diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..15c9108 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/log \ No newline at end of file diff --git a/README.md b/README.md index 87405d1..34ac53a 100644 --- a/README.md +++ b/README.md @@ -1 +1,14 @@ -# Place for wiaas based on woo commerce \ No newline at end of file +# Place for wiaas based on woo commerce + +wordpress credentials : + user : wpUser + password : Test987! + +wooCommerce API key : + consumer key : ck_1ee57854e327639d33ca072073499d4adaf9d8f4 + consumer secret : cs_e51bf71b6ce05fe9a0d17d3e4f249c2b6ec8cbd5 + +mysql : + user : wp_user + password : wp_password + database : wordpress \ No newline at end of file diff --git a/backend/index.php b/backend/index.php new file mode 100644 index 0000000..dd3d554 --- /dev/null +++ b/backend/index.php @@ -0,0 +1,17 @@ + + Copyright (C) + + 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. + + , 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. + +WRITTEN OFFER + +The source code for any program binaries or compressed scripts that are +included with WordPress can be freely obtained at the following URL: + + https://wordpress.org/download/source/ diff --git a/backend/readme.html b/backend/readme.html new file mode 100644 index 0000000..031c076 --- /dev/null +++ b/backend/readme.html @@ -0,0 +1,98 @@ + + + + + + WordPress › ReadMe + + + +

+ WordPress +

+

Semantic Personal Publishing Platform

+ +

First Things First

+

Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I’m proud to be a part of. Thousands of hours have gone into WordPress, and we’re dedicated to making it better every day. Thank you for making it part of your world.

+

— Matt Mullenweg

+ +

Installation: Famous 5-minute install

+
    +
  1. Unzip the package in an empty directory and upload everything.
  2. +
  3. Open wp-admin/install.php in your browser. It will take you through the process to set up a wp-config.php file with your database connection details. +
      +
    1. If for some reason this doesn’t work, don’t worry. It doesn’t work on all web hosts. Open up wp-config-sample.php with a text editor like WordPad or similar and fill in your database connection details.
    2. +
    3. Save the file as wp-config.php and upload it.
    4. +
    5. Open wp-admin/install.php in your browser.
    6. +
    +
  4. +
  5. Once the configuration file is set up, the installer will set up the tables needed for your blog. If there is an error, double check your wp-config.php file, and try again. If it fails again, please go to the support forums with as much data as you can gather.
  6. +
  7. If you did not enter a password, note the password given to you. If you did not provide a username, it will be admin.
  8. +
  9. The installer should then send you to the login page. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on “Profile” to change the password.
  10. +
+ +

Updating

+

Using the Automatic Updater

+

If you are updating from version 2.7 or higher, you can use the automatic updater:

+
    +
  1. Open wp-admin/update-core.php in your browser and follow the instructions.
  2. +
  3. You wanted more, perhaps? That’s it!
  4. +
+ +

Updating Manually

+
    +
  1. Before you update anything, make sure you have backup copies of any files you may have modified such as index.php.
  2. +
  3. Delete your old WordPress files, saving ones you’ve modified.
  4. +
  5. Upload the new files.
  6. +
  7. Point your browser to /wp-admin/upgrade.php.
  8. +
+ +

Migrating from other systems

+

WordPress can import from a number of systems. First you need to get WordPress installed and working as described above, before using our import tools.

+ +

System Requirements

+
    +
  • PHP version 5.2.4 or higher.
  • +
  • MySQL version 5.0 or higher.
  • +
+ +

Recommendations

+ + +

Online Resources

+

If you have any questions that aren’t addressed in this document, please take advantage of WordPress’ numerous online resources:

+
+
The WordPress Codex
+
The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.
+
The WordPress Blog
+
This is where you’ll find the latest updates and news related to WordPress. Recent WordPress news appears in your administrative dashboard by default.
+
WordPress Planet
+
The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.
+
WordPress Support Forums
+
If you’ve looked everywhere and still can’t find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.
+
WordPress IRC Channel
+
There is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpress)
+
+ +

Final Notes

+
    +
  • If you have any suggestions, ideas, or comments, or if you (gasp!) found a bug, join us in the Support Forums.
  • +
  • WordPress has a robust plugin API that makes extending the code easy. If you are a developer interested in utilizing this, see the Plugin Developer Handbook. You shouldn’t modify any of the core code.
  • +
+ +

Share the Love

+

WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better—you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.

+ +

WordPress is the official continuation of b2/cafélog, which came from Michel V. The work has been continued by the WordPress developers. If you would like to support WordPress, please consider donating.

+ +

License

+

WordPress is free software, and is released under the terms of the GPL version 2 or (at your option) any later version. See license.txt.

+ + + diff --git a/backend/wp-activate.php b/backend/wp-activate.php new file mode 100644 index 0000000..6aae1ca --- /dev/null +++ b/backend/wp-activate.php @@ -0,0 +1,163 @@ +cache_enabled = false; + +// Fix for page title +$wp_query->is_404 = false; + +/** + * Fires before the Site Activation page is loaded. + * + * @since 3.0.0 + */ +do_action( 'activate_header' ); + +/** + * Adds an action hook specific to this page. + * + * Fires on {@see 'wp_head'}. + * + * @since MU (3.0.0) + */ +function do_activate_header() { + /** + * Fires before the Site Activation page is loaded. + * + * Fires on the {@see 'wp_head'} action. + * + * @since 3.0.0 + */ + do_action( 'activate_wp_head' ); +} +add_action( 'wp_head', 'do_activate_header' ); + +/** + * Loads styles specific to this page. + * + * @since MU (3.0.0) + */ +function wpmu_activate_stylesheet() { + ?> + + + +
+
+ + +

+
+

+ +
+

+

+ +

+
+ + get_error_code() || 'blog_taken' == $result->get_error_code() ) { + $signup = $result->get_error_data(); + ?> +

+ '; + if ( $signup->domain . $signup->path == '' ) { + printf( + /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */ + __( 'Your account has been activated. You may now log in to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.' ), + network_site_url( 'wp-login.php', 'login' ), + $signup->user_login, + $signup->user_email, + wp_lostpassword_url() + ); + } else { + printf( + /* translators: 1: site URL, 2: username, 3: user email, 4: lost password URL */ + __( 'Your site at %1$s is active. You may now log in to your site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can reset your password.' ), + sprintf( '%1$s', $signup->domain ), + $signup->user_login, + $signup->user_email, + wp_lostpassword_url() + ); + } + echo '

'; + } else { + ?> +

+

get_error_message(); ?>

+ +

+ +
+

user_login ?>

+

+
+ + +

View your site or Log in' ), $url, esc_url( $login_url ) ); + ?>

+ +

Log in or go back to the homepage.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); + ?>

+ +
+
+ + +
+

+ +

+
+ + + +
+

+

+ Version %1$s addressed %2$s bug.', + 'Version %1$s addressed %2$s bugs.', + 18 + ), + '4.9.6', + number_format_i18n( 18 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.6' ); + ?> +

+

+ Version %1$s addressed some security issues and fixed %2$s bug.', + 'Version %1$s addressed some security issues and fixed %2$s bugs.', + 28 + ), + '4.9.5', + number_format_i18n( 28 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.5' ); + ?> +

+

+ Version %1$s addressed %2$s bug.', + 'Version %1$s addressed %2$s bugs.', + 1 + ), + '4.9.4', + number_format_i18n( 1 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.4' ); + ?> +

+

+ Version %1$s addressed %2$s bug.', + 'Version %1$s addressed %2$s bugs.', + 34 + ), + '4.9.3', + number_format_i18n( 34 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.3' ); + ?> +

+

+ Version %1$s addressed some security issues and fixed %2$s bug.', + 'Version %1$s addressed some security issues and fixed %2$s bugs.', + 22 + ), + '4.9.2', + number_format_i18n( 22 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.2' ); + ?> +

+

+ Version %1$s addressed some security issues and fixed %2$s bug.', + 'Version %1$s addressed some security issues and fixed %2$s bugs.', + 11 + ), + '4.9.1', + number_format_i18n( 11 ) + ); + ?> + the release notes.' ), 'https://codex.wordpress.org/Version_4.9.1' ); + ?> +

+
+ +
+
+

+ +

+

+
+
+ +
+ + + + +
+ +
+
+

+
+ +
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+
+

+
+ +
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+
+

+
+ +
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+
+

+
+ +
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+ + + + +
+ +
+

+ +

+

early tester or getting involved with the Gutenberg project? Contribute on GitHub.' ), + __( 'https://wordpress.org/plugins/gutenberg/' ), + 'https://github.com/WordPress/gutenberg' ); ?>

+
+ +
+ +
+

+ +
+
+

+

Check out the full list.' ), + 'https://make.wordpress.org/core/2017/11/01/improvements-to-the-customize-js-api-in-4-9/' + ); + ?>

+
+
+

+

+
+
+

+

+
+
+

+

+
+
+
+ +
+ +
+ + + + | + + +
+
+ + + +Version %s addressed one security issue.' ); +/* translators: %s: WordPress version number */ +__( 'Version %s addressed some security issues.' ); + +/* translators: 1: WordPress version number, 2: plural number of bugs. */ +_n_noop( 'Version %1$s addressed %2$s bug.', + 'Version %1$s addressed %2$s bugs.' ); + +/* translators: 1: WordPress version number, 2: plural number of bugs. Singular security issue. */ +_n_noop( 'Version %1$s addressed a security issue and fixed %2$s bug.', + 'Version %1$s addressed a security issue and fixed %2$s bugs.' ); + +/* translators: 1: WordPress version number, 2: plural number of bugs. More than one security issue. */ +_n_noop( 'Version %1$s addressed some security issues and fixed %2$s bug.', + 'Version %1$s addressed some security issues and fixed %2$s bugs.' ); + +/* translators: %s: Codex URL */ +__( 'For more information, see the release notes.' ); diff --git a/backend/wp-admin/admin-ajax.php b/backend/wp-admin/admin-ajax.php new file mode 100644 index 0000000..cbef078 --- /dev/null +++ b/backend/wp-admin/admin-ajax.php @@ -0,0 +1,117 @@ + + +
+
+
+ + + + +
+ + + diff --git a/backend/wp-admin/admin-functions.php b/backend/wp-admin/admin-functions.php new file mode 100644 index 0000000..abbb079 --- /dev/null +++ b/backend/wp-admin/admin-functions.php @@ -0,0 +1,15 @@ +site_name ) ); +} elseif ( is_user_admin() ) { + /* translators: User dashboard screen title. 1: Network name */ + $admin_title = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) ); +} else { + $admin_title = get_bloginfo( 'name' ); +} + +if ( $admin_title == $title ) { + /* translators: Admin screen title. 1: Admin screen name */ + $admin_title = sprintf( __( '%1$s — WordPress' ), $title ); +} else { + /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */ + $admin_title = sprintf( __( '%1$s ‹ %2$s — WordPress' ), $title, $admin_title ); +} + +/** + * Filters the title tag content for an admin page. + * + * @since 3.1.0 + * + * @param string $admin_title The page title, with extra context added. + * @param string $title The original page title. + */ +$admin_title = apply_filters( 'admin_title', $admin_title, $title ); + +wp_user_settings(); + +_wp_admin_html_begin(); +?> +<?php echo $admin_title; ?> + + + +post_type ) + $admin_body_class .= ' post-type-' . $current_screen->post_type; + +if ( $current_screen->taxonomy ) + $admin_body_class .= ' taxonomy-' . $current_screen->taxonomy; + +$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) ); +$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) ); +$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); +$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); + +if ( wp_is_mobile() ) + $admin_body_class .= ' mobile'; + +if ( is_multisite() ) + $admin_body_class .= ' multisite'; + +if ( is_network_admin() ) + $admin_body_class .= ' network-admin'; + +$admin_body_class .= ' no-customize-support no-svg'; + +?> + + + + + + + +
+ +
+ + + +
+set_parentage( $parent_file ); + +?> + +
+render_screen_meta(); + +if ( is_network_admin() ) { + /** + * Prints network admin screen notices. + * + * @since 3.1.0 + */ + do_action( 'network_admin_notices' ); +} elseif ( is_user_admin() ) { + /** + * Prints user admin screen notices. + * + * @since 3.1.0 + */ + do_action( 'user_admin_notices' ); +} else { + /** + * Prints admin screen notices. + * + * @since 3.1.0 + */ + do_action( 'admin_notices' ); +} + +/** + * Prints generic admin screen notices. + * + * @since 3.1.0 + */ +do_action( 'all_admin_notices' ); + +if ( $parent_file == 'options-general.php' ) + require(ABSPATH . 'wp-admin/options-head.php'); diff --git a/backend/wp-admin/admin-post.php b/backend/wp-admin/admin-post.php new file mode 100644 index 0000000..d3135f2 --- /dev/null +++ b/backend/wp-admin/admin-post.php @@ -0,0 +1,71 @@ + 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { + require_once( ABSPATH . WPINC . '/http.php' ); + $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); + /** This action is documented in wp-admin/network/upgrade.php */ + do_action( 'after_mu_upgrade', $response ); + unset($response); + } + unset($c); + } +} + +require_once(ABSPATH . 'wp-admin/includes/admin.php'); + +auth_redirect(); + +// Schedule trash collection +if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) + wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); + +// Schedule Transient cleanup. +if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { + wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); +} + +set_screen_options(); + +$date_format = __( 'F j, Y' ); +$time_format = __( 'g:i a' ); + +wp_enqueue_script( 'common' ); + +/** + * $pagenow is set in vars.php + * $wp_importers is sometimes set in wp-admin/includes/import.php + * The remaining variables are imported as globals elsewhere, declared as globals here + * + * @global string $pagenow + * @global array $wp_importers + * @global string $hook_suffix + * @global string $plugin_page + * @global string $typenow + * @global string $taxnow + */ +global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow; + +$page_hook = null; + +$editing = false; + +if ( isset($_GET['page']) ) { + $plugin_page = wp_unslash( $_GET['page'] ); + $plugin_page = plugin_basename($plugin_page); +} + +if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) + $typenow = $_REQUEST['post_type']; +else + $typenow = ''; + +if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) + $taxnow = $_REQUEST['taxonomy']; +else + $taxnow = ''; + +if ( WP_NETWORK_ADMIN ) + require(ABSPATH . 'wp-admin/network/menu.php'); +elseif ( WP_USER_ADMIN ) + require(ABSPATH . 'wp-admin/user/menu.php'); +else + require(ABSPATH . 'wp-admin/menu.php'); + +if ( current_user_can( 'manage_options' ) ) { + wp_raise_memory_limit( 'admin' ); +} + +/** + * Fires as an admin screen or script is being initialized. + * + * Note, this does not just run on user-facing admin screens. + * It runs on admin-ajax.php and admin-post.php as well. + * + * This is roughly analogous to the more general {@see 'init'} hook, which fires earlier. + * + * @since 2.5.0 + */ +do_action( 'admin_init' ); + +if ( isset($plugin_page) ) { + if ( !empty($typenow) ) + $the_parent = $pagenow . '?post_type=' . $typenow; + else + $the_parent = $pagenow; + if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { + $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); + + // Back-compat for plugins using add_management_page(). + if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { + // There could be plugin specific params on the URL, so we need the whole query string + if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) + $query_string = $_SERVER[ 'QUERY_STRING' ]; + else + $query_string = 'page=' . $plugin_page; + wp_redirect( admin_url('tools.php?' . $query_string) ); + exit; + } + } + unset($the_parent); +} + +$hook_suffix = ''; +if ( isset( $page_hook ) ) { + $hook_suffix = $page_hook; +} elseif ( isset( $plugin_page ) ) { + $hook_suffix = $plugin_page; +} elseif ( isset( $pagenow ) ) { + $hook_suffix = $pagenow; +} + +set_current_screen(); + +// Handle plugin admin pages. +if ( isset($plugin_page) ) { + if ( $page_hook ) { + /** + * Fires before a particular screen is loaded. + * + * The load-* hook fires in a number of contexts. This hook is for plugin screens + * where a callback is provided when the screen is registered. + * + * The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin + * page information including: + * 1. The page type. If the plugin page is registered as a submenu page, such as for + * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. + * 2. A separator of '_page_'. + * 3. The plugin basename minus the file extension. + * + * Together, the three parts form the `$page_hook`. Citing the example above, + * the hook name used would be 'load-settings_page_pluginbasename'. + * + * @see get_plugin_page_hook() + * + * @since 2.1.0 + */ + do_action( "load-{$page_hook}" ); + if (! isset($_GET['noheader'])) + require_once(ABSPATH . 'wp-admin/admin-header.php'); + + /** + * Used to call the registered callback for a plugin screen. + * + * @ignore + * @since 1.5.0 + */ + do_action( $page_hook ); + } else { + if ( validate_file( $plugin_page ) ) { + wp_die( __( 'Invalid plugin page.' ) ); + } + + if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) ) + wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); + + /** + * Fires before a particular screen is loaded. + * + * The load-* hook fires in a number of contexts. This hook is for plugin screens + * where the file to load is directly included, rather than the use of a function. + * + * The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename. + * + * @see plugin_basename() + * + * @since 1.5.0 + */ + do_action( "load-{$plugin_page}" ); + + if ( !isset($_GET['noheader'])) + require_once(ABSPATH . 'wp-admin/admin-header.php'); + + if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) + include(WPMU_PLUGIN_DIR . "/$plugin_page"); + else + include(WP_PLUGIN_DIR . "/$plugin_page"); + } + + include(ABSPATH . 'wp-admin/admin-footer.php'); + + exit(); +} elseif ( isset( $_GET['import'] ) ) { + + $importer = $_GET['import']; + + if ( ! current_user_can( 'import' ) ) { + wp_die( __( 'Sorry, you are not allowed to import content.' ) ); + } + + if ( validate_file($importer) ) { + wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); + exit; + } + + if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]) ) { + wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); + exit; + } + + /** + * Fires before an importer screen is loaded. + * + * The dynamic portion of the hook name, `$importer`, refers to the importer slug. + * + * @since 3.5.0 + */ + do_action( "load-importer-{$importer}" ); + + $parent_file = 'tools.php'; + $submenu_file = 'import.php'; + $title = __('Import'); + + if (! isset($_GET['noheader'])) + require_once(ABSPATH . 'wp-admin/admin-header.php'); + + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); + + define('WP_IMPORTING', true); + + /** + * Whether to filter imported data through kses on import. + * + * Multisite uses this hook to filter all data through kses by default, + * as a super administrator may be assisting an untrusted user. + * + * @since 3.1.0 + * + * @param bool $force Whether to force data to be filtered through kses. Default false. + */ + if ( apply_filters( 'force_filtered_html_on_import', false ) ) { + kses_init_filters(); // Always filter imported data with kses on multisite. + } + + call_user_func($wp_importers[$importer][2]); + + include(ABSPATH . 'wp-admin/admin-footer.php'); + + // Make sure rules are flushed + flush_rewrite_rules(false); + + exit(); +} else { + /** + * Fires before a particular screen is loaded. + * + * The load-* hook fires in a number of contexts. This hook is for core screens. + * + * The dynamic portion of the hook name, `$pagenow`, is a global variable + * referring to the filename of the current page, such as 'admin.php', + * 'post-new.php' etc. A complete hook for the latter would be + * 'load-post-new.php'. + * + * @since 2.1.0 + */ + do_action( "load-{$pagenow}" ); + + /* + * The following hooks are fired to ensure backward compatibility. + * In all other cases, 'load-' . $pagenow should be used instead. + */ + if ( $typenow == 'page' ) { + if ( $pagenow == 'post-new.php' ) + do_action( 'load-page-new.php' ); + elseif ( $pagenow == 'post.php' ) + do_action( 'load-page.php' ); + } elseif ( $pagenow == 'edit-tags.php' ) { + if ( $taxnow == 'category' ) + do_action( 'load-categories.php' ); + elseif ( $taxnow == 'link_category' ) + do_action( 'load-edit-link-categories.php' ); + } elseif( 'term.php' === $pagenow ) { + do_action( 'load-edit-tags.php' ); + } +} + +if ( ! empty( $_REQUEST['action'] ) ) { + /** + * Fires when an 'action' request variable is sent. + * + * The dynamic portion of the hook name, `$_REQUEST['action']`, + * refers to the action derived from the `GET` or `POST` request. + * + * @since 2.6.0 + */ + do_action( 'admin_action_' . $_REQUEST['action'] ); +} diff --git a/backend/wp-admin/async-upload.php b/backend/wp-admin/async-upload.php new file mode 100644 index 0000000..2293fde --- /dev/null +++ b/backend/wp-admin/async-upload.php @@ -0,0 +1,108 @@ +post_type ) + wp_die( __( 'Invalid post type.' ) ); + if ( ! current_user_can( 'edit_post', $id ) ) + wp_die( __( 'Sorry, you are not allowed to edit this item.' ) ); + + switch ( $_REQUEST['fetch'] ) { + case 3 : + if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) ) + echo ''; + echo '' . _x( 'Edit', 'media item' ) . ''; + + // Title shouldn't ever be empty, but use filename just in case. + $file = get_attached_file( $post->ID ); + $title = $post->post_title ? $post->post_title : wp_basename( $file ); + echo '
' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '
'; + break; + case 2 : + add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2); + echo get_media_item($id, array( 'send' => false, 'delete' => true )); + break; + default: + add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); + echo get_media_item($id); + break; + } + exit; +} + +check_admin_referer('media-form'); + +$post_id = 0; +if ( isset( $_REQUEST['post_id'] ) ) { + $post_id = absint( $_REQUEST['post_id'] ); + if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) + $post_id = 0; +} + +$id = media_handle_upload( 'async-upload', $post_id ); +if ( is_wp_error($id) ) { + echo '
+ ' . __('Dismiss') . ' + ' . sprintf(__('“%s” has failed to upload.'), esc_html($_FILES['async-upload']['name']) ) . '
' . + esc_html($id->get_error_message()) . '
'; + exit; +} + +if ( $_REQUEST['short'] ) { + // Short form response - attachment ID only. + echo $id; +} else { + // Long form response - big chunk o html. + $type = $_REQUEST['type']; + + /** + * Filters the returned ID of an uploaded attachment. + * + * The dynamic portion of the hook name, `$type`, refers to the attachment type, + * such as 'image', 'audio', 'video', 'file', etc. + * + * @since 2.5.0 + * + * @param int $id Uploaded attachment ID. + */ + echo apply_filters( "async_upload_{$type}", $id ); +} diff --git a/backend/wp-admin/comment.php b/backend/wp-admin/comment.php new file mode 100644 index 0000000..c2eca11 --- /dev/null +++ b/backend/wp-admin/comment.php @@ -0,0 +1,333 @@ +add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '

' . + '

' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '

' + ) ); + + get_current_screen()->set_help_sidebar( + '

' . __( 'For more information:' ) . '

' . + '

' . __( 'Documentation on Comments' ) . '

' . + '

' . __( 'Support Forums' ) . '

' + ); + + wp_enqueue_script('comment'); + require_once( ABSPATH . 'wp-admin/admin-header.php' ); + + $comment_id = absint( $_GET['c'] ); + + if ( !$comment = get_comment( $comment_id ) ) + comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' ' . __('Go back') . '.', 'javascript:history.go(-1)') ); + + if ( !current_user_can( 'edit_comment', $comment_id ) ) + comment_footer_die( __('Sorry, you are not allowed to edit this comment.') ); + + if ( 'trash' == $comment->comment_approved ) + comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); + + $comment = get_comment_to_edit( $comment_id ); + + include( ABSPATH . 'wp-admin/edit-form-comment.php' ); + + break; + +case 'delete' : +case 'approve' : +case 'trash' : +case 'spam' : + + $title = __('Moderate Comment'); + + $comment_id = absint( $_GET['c'] ); + + if ( ! $comment = get_comment( $comment_id ) ) { + wp_redirect( admin_url('edit-comments.php?error=1') ); + die(); + } + + if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { + wp_redirect( admin_url('edit-comments.php?error=2') ); + die(); + } + + // No need to re-approve/re-trash/re-spam a comment. + if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { + wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) ); + die(); + } + + require_once( ABSPATH . 'wp-admin/admin-header.php' ); + + $formaction = $action . 'comment'; + $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; + $nonce_action .= $comment_id; + +?> +
+ +

+ +comment_approved != '0' ) { // if not unapproved + $message = ''; + switch ( $comment->comment_approved ) { + case '1' : + $message = __('This comment is currently approved.'); + break; + case 'spam' : + $message = __('This comment is currently marked as spam.'); + break; + case 'trash' : + $message = __('This comment is currently in the Trash.'); + break; + } + if ( $message ) { + echo '

' . $message . '

'; + } +} +?> +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ comment_post_ID; + if ( current_user_can( 'edit_post', $post_id ) ) { + $post_link = ""; + $post_link .= esc_html( get_the_title( $post_id ) ) . ''; + } else { + $post_link = esc_html( get_the_title( $post_id ) ); + } + echo $post_link; + + if ( $comment->comment_parent ) { + $parent = get_comment( $comment->comment_parent ); + $parent_link = esc_url( get_comment_link( $parent ) ); + $name = get_comment_author( $parent ); + printf( + /* translators: %s: comment link */ + ' | ' . __( 'In reply to %s.' ), + '' . $name . '' + ); + } + ?> +
+ comment_post_ID ) ) { + echo '' . $submitted . ''; + } else { + echo $submitted; + } + ?> +
+ +

comment_ID}" ); ?>">

+
+ +
+ +

+ + +

+ + + + + +
+ +
+' . __('Go back') . '.', 'edit-comments.php') ); + if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) + comment_footer_die( __('Sorry, you are not allowed to edit comments on this post.') ); + + if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) + $redir = wp_get_referer(); + elseif ( '' != wp_get_original_referer() && ! $noredir ) + $redir = wp_get_original_referer(); + elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) + $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); + else + $redir = admin_url('edit-comments.php'); + + $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); + + switch ( $action ) { + case 'deletecomment' : + wp_delete_comment( $comment ); + $redir = add_query_arg( array('deleted' => '1'), $redir ); + break; + case 'trashcomment' : + wp_trash_comment( $comment ); + $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); + break; + case 'untrashcomment' : + wp_untrash_comment( $comment ); + $redir = add_query_arg( array('untrashed' => '1'), $redir ); + break; + case 'spamcomment' : + wp_spam_comment( $comment ); + $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); + break; + case 'unspamcomment' : + wp_unspam_comment( $comment ); + $redir = add_query_arg( array('unspammed' => '1'), $redir ); + break; + case 'approvecomment' : + wp_set_comment_status( $comment, 'approve' ); + $redir = add_query_arg( array( 'approved' => 1 ), $redir ); + break; + case 'unapprovecomment' : + wp_set_comment_status( $comment, 'hold' ); + $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); + break; + } + + wp_redirect( $redir ); + die; + +case 'editedcomment' : + + $comment_id = absint( $_POST['comment_ID'] ); + $comment_post_id = absint( $_POST['comment_post_ID'] ); + + check_admin_referer( 'update-comment_' . $comment_id ); + + edit_comment(); + + $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; + + /** + * Filters the URI the user is redirected to after editing a comment in the admin. + * + * @since 2.1.0 + * + * @param string $location The URI the user will be redirected to. + * @param int $comment_id The ID of the comment being edited. + */ + $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); + wp_redirect( $location ); + + exit(); + +default: + wp_die( __('Unknown action.') ); + +} // end switch + +include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/backend/wp-admin/credits.php b/backend/wp-admin/credits.php new file mode 100644 index 0000000..1ec2d67 --- /dev/null +++ b/backend/wp-admin/credits.php @@ -0,0 +1,128 @@ + +
+ +

+ +

+ +
+ + + +
+'; + /* translators: 1: https://wordpress.org/about/, 2: https://make.wordpress.org/ */ + printf( __( 'WordPress is created by a worldwide team of passionate individuals. Get involved in WordPress.' ), + 'https://wordpress.org/about/', + __( 'https://make.wordpress.org/' ) + ); + echo '

'; + echo '
'; + echo '
'; + include( ABSPATH . 'wp-admin/admin-footer.php' ); + exit; +} + +echo '

' . __( 'WordPress is created by a worldwide team of passionate individuals.' ) . "

\n"; + +echo '

' . sprintf( + /* translators: %s: https://make.wordpress.org/ */ + __( 'Want to see your name in lights on this page? Get involved in WordPress.' ), + __( 'https://make.wordpress.org/' ) +) . '

'; + +foreach ( $credits['groups'] as $group_slug => $group_data ) { + if ( $group_data['name'] ) { + if ( 'Translators' == $group_data['name'] ) { + // Considered a special slug in the API response. (Also, will never be returned for en_US.) + $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' ); + } elseif ( isset( $group_data['placeholders'] ) ) { + $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] ); + } else { + $title = translate( $group_data['name'] ); + } + + echo '

' . esc_html( $title ) . "

\n"; + } + + if ( ! empty( $group_data['shuffle'] ) ) + shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. + + switch ( $group_data['type'] ) { + case 'list' : + array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] ); + echo '

' . wp_sprintf( '%l.', $group_data['data'] ) . "

\n\n"; + break; + case 'libraries' : + array_walk( $group_data['data'], '_wp_credits_build_object_link' ); + echo '

' . wp_sprintf( '%l.', $group_data['data'] ) . "

\n\n"; + break; + default: + $compact = 'compact' == $group_data['type']; + $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' ); + echo '\n"; + break; + } +} + +?> +
+
+ a:focus, +#adminmenu .wp-submenu a:hover, +#adminmenu .wp-submenu a:focus { + color: #00b9eb; +} + +#adminmenu li.menu-top { + border: none; + min-height: 34px; + position: relative; +} + +#adminmenu .wp-submenu { + list-style: none; + position: absolute; + top: -1000em; + right: 160px; + overflow: visible; + word-wrap: break-word; +} + +#adminmenu .wp-submenu, +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + padding: 7px 0 8px; + z-index: 9999; + background-color: #32373c; + box-shadow: 0 3px 5px rgba(0,0,0,0.2); +} + +.js #adminmenu .sub-open, +.js #adminmenu .opensub .wp-submenu, +#adminmenu a.menu-top:focus + .wp-submenu, +.no-js li.wp-has-submenu:hover .wp-submenu { + top: -1px; +} + +#adminmenu .wp-has-current-submenu .wp-submenu, +.no-js li.wp-has-current-submenu:hover .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu.sub-open, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu { + position: relative; + z-index: 3; + top: auto; + right: auto; + left: auto; + bottom: auto; + border: 0 none; + margin-top: 0; + box-shadow: none; + background-color: #32373c; +} + +/* ensure that wp-submenu's box shadow doesn't appear on top of the focused menu item's background. */ +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + position: relative; + background-color: #191e23; + color: #00b9eb; +} + +.folded #adminmenu li.menu-top:hover, +.folded #adminmenu li.opensub > a.menu-top, +.folded #adminmenu li > a.menu-top:focus { + z-index: 10000; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.current a.menu-top, +.folded #adminmenu li.wp-has-current-submenu, +.folded #adminmenu li.current.menu-top, +#adminmenu .wp-menu-arrow, +#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, +#adminmenu .wp-menu-arrow div { + background: #0073aa; + color: #fff; +} + +.folded #adminmenu .wp-submenu.sub-open, +.folded #adminmenu .opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, +.folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu a.menu-top:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu, +.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu { + top: 0; + right: 36px; +} + +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + position: absolute; + top: -1000em; +} + +#adminmenu .wp-not-current-submenu .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + min-width: 160px; + width: auto; +} + +#adminmenu .wp-submenu a { + font-size: 13px; + line-height: 18px; + margin: 0; + padding: 5px 0; +} + +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .opensub .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover, +#adminmenu .wp-submenu li.current a:focus { + color: #fff; +} + +#adminmenu .wp-not-current-submenu li > a, +.folded #adminmenu .wp-has-current-submenu li > a { + padding-left: 16px; + padding-right: 14px; + transition: all .1s ease-in-out; +} + +#adminmenu .wp-has-current-submenu ul > li > a, +.folded #adminmenu li.menu-top .wp-submenu > li > a { + padding: 5px 12px; +} + +#adminmenu a.menu-top, +#adminmenu .wp-submenu-head { + font-size: 14px; + font-weight: 400; + line-height: 18px; + padding: 0; +} + +#adminmenu .wp-submenu-head { + display: none; +} + +.folded #adminmenu .wp-menu-name { + position: absolute; + right: -999px; +} + +.folded #adminmenu .wp-submenu-head { + display: block; +} + +#adminmenu .wp-submenu li { + padding: 0; + margin: 0; + overflow: hidden; +} + +#adminmenu .wp-menu-image img { + padding: 9px 0 0 0; + opacity: 0.6; + filter: alpha(opacity=60); +} + +#adminmenu div.wp-menu-name { + padding: 8px 0; +} + +#adminmenu div.wp-menu-image { + float: right; + width: 36px; + height: 34px; + margin: 0; + text-align: center; +} + +#adminmenu div.wp-menu-image.svg { + background-repeat: no-repeat; + background-position: center; + background-size: 20px auto; +} + +div.wp-menu-image:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); + padding: 7px 0; + transition: all .1s ease-in-out; +} + +#adminmenu div.wp-menu-image:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); +} + +#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before, +#adminmenu .wp-has-current-submenu div.wp-menu-image:before, +#adminmenu .current div.wp-menu-image:before, +#adminmenu a.wp-has-current-submenu:hover div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before { + color: #fff; +} + +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before { + color: #00b9eb; +} + +/* IE8 doesn't redraw the pseudo elements unless you make a change to the content, this restore the initial color after hover */ +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #a0a5aa; +} + +.folded #adminmenu div.wp-menu-image { + width: 35px; + height: 30px; + position: absolute; + z-index: 25; +} + +.folded #adminmenu a.menu-top { + height: 34px; +} + +/* No @font-face support */ +.no-font-face #adminmenu .wp-menu-image { + display: none; +} + +.no-font-face #adminmenu div.wp-menu-name { + padding: 8px 12px; +} + +.no-font-face.auto-fold #adminmenu .wp-menu-name { + margin-right: 0; +} +/* End no @font-face support */ + +/* Sticky admin menu */ +.sticky-menu #adminmenuwrap { + position: fixed; +} + +/* A new arrow */ + +.wp-menu-arrow { + display: none !important; +} + +ul#adminmenu a.wp-has-current-submenu { + position: relative; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + left: 0; + border: solid 8px transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-left-color: #f1f1f1; + top: 50%; + margin-top: -8px; +} + +.folded ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: none; +} + +.folded ul#adminmenu a.wp-has-current-submenu:after, +.folded ul#adminmenu > li a.current:after { + border-width: 4px; + margin-top: -4px; +} + +/* flyout menu arrow */ +#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + left: 0; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-width: 8px; + top: 10px; + z-index: 10000; +} + +.folded ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + border-width: 4px; + margin-top: -4px; + top: 18px; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #32373c; +} + +#adminmenu li.menu-top:hover .wp-menu-image img, +#adminmenu li.wp-has-current-submenu .wp-menu-image img { + opacity: 1; + filter: alpha(opacity=100); +} + +#adminmenu li.wp-menu-separator { + height: 5px; + padding: 0; + margin: 0 0 6px 0; + cursor: inherit; +} + +/* @todo: is this even needed given that it's nested beneath the above li.wp-menu-separator? */ +#adminmenu div.separator { + height: 2px; + padding: 0; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #fff; + font-weight: 400; + font-size: 14px; + padding: 8px 11px 8px 4px; + margin: -7px 0px 4px; +} + +#adminmenu li.current, +.folded #adminmenu li.wp-menu-open { + border: 0 none; +} + +/* @todo: consider to use a single rule for these counters and the list table comments counters. */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + display: inline-block; + vertical-align: top; + margin: 1px 2px 0 0; + padding: 0 5px; + min-width: 7px; + height: 17px; + border-radius: 11px; + background-color: #ca4a1f; + color: #fff; + font-size: 9px; + line-height: 17px; + text-align: center; + z-index: 26; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins { + background-color: #00b9eb; + color: #fff; +} + +#adminmenu li span.count-0 { + display: none; +} + +#collapse-button { + display: block; + width: 100%; + height: 34px; + margin: 0; + border: none; + padding: 0; + position: relative; + overflow: visible; + line-height: 34px; + background: none; + color: #aaa; + cursor: pointer; + outline: 0; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #00b9eb; +} + +#collapse-button .collapse-button-icon, +#collapse-button .collapse-button-label { + /* absolutely positioned to avoid 1px shift in IE when button is pressed */ + display: block; + position: absolute; + top: 0; + right: 0; + line-height: 34px; +} + +#collapse-button .collapse-button-icon { + width: 36px; + height: 34px; +} + +#collapse-button .collapse-button-label { + padding: 0 36px 0 0; +} + +.folded #collapse-button .collapse-button-label { + display: none; +} + +#collapse-button .collapse-button-icon:after { + content: "\f148"; + display: block; + position: relative; + top: 7px; + text-align: center; + font: normal 20px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* rtl:ignore */ +.folded #collapse-button .collapse-button-icon:after, +.rtl #collapse-button .collapse-button-icon:after { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); +} + +.rtl.folded #collapse-button .collapse-button-icon:after { + -webkit-transform: none; + transform: none; +} + +#collapse-button .collapse-button-icon:after, +#collapse-button .collapse-button-label { + transition: all .1s ease-in-out; +} + +/** + * Toolbar menu toggle + */ +li#wp-admin-bar-menu-toggle { + display: none; +} + +/* Hide-if-customize for items we can't add classes to */ +.customize-support #menu-appearance a[href="themes.php?page=custom-header"], +.customize-support #menu-appearance a[href="themes.php?page=custom-background"] { + display: none; +} + +/* Auto-folding of the admin menu */ +@media only screen and (max-width: 960px) { + .auto-fold #wpcontent, + .auto-fold #wpfooter { + margin-right: 36px; + } + + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap, + .auto-fold #adminmenu, + .auto-fold #adminmenu li.menu-top { + width: 36px; + } + + .auto-fold #adminmenu .wp-submenu.sub-open, + .auto-fold #adminmenu .opensub .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, + .auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu, + .auto-fold #adminmenu a.menu-top:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { + top: 0px; + right: 36px; + } + + .auto-fold #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu { + position: absolute; + top: -1000em; + margin-left: -1px; + padding: 7px 0 8px; + z-index: 9999; + } + + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu { + min-width: 150px; + width: auto; + } + + .auto-fold #adminmenu .wp-has-current-submenu li > a { + padding-left: 16px; + padding-right: 14px; + } + + + .auto-fold #adminmenu li.menu-top .wp-submenu > li > a { + padding-right: 12px; + } + + .auto-fold #adminmenu .wp-menu-name { + position: absolute; + right: -999px; + } + + .auto-fold #adminmenu .wp-submenu-head { + display: block; + } + + .auto-fold #adminmenu div.wp-menu-image { + height: 30px; + width: 34px; + position: absolute; + z-index: 25; + } + + .auto-fold #adminmenu a.menu-top { + height: 34px; + } + + .auto-fold #adminmenu li.wp-menu-open { + border: 0 none; + } + + .auto-fold #adminmenu .wp-has-current-submenu.menu-top-last { + margin-bottom: 0; + } + + .auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: none; + } + + .auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + border-width: 4px; + margin-top: -4px; + top: 16px; + } + + .auto-fold ul#adminmenu a.wp-has-current-submenu:after, + .auto-fold ul#adminmenu > li a.current:after { + border-width: 4px; + margin-top: -4px; + } + + .auto-fold #adminmenu li.menu-top:hover, + .auto-fold #adminmenu li.opensub > a.menu-top, + .auto-fold #adminmenu li > a.menu-top:focus { + z-index: 10000; + } + + .auto-fold #collapse-menu .collapse-button-label { + display: none; + } + + /* rtl:ignore */ + .auto-fold #collapse-button .collapse-button-icon:after { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); + } + + .rtl.auto-fold #collapse-button .collapse-button-icon:after { + -webkit-transform: none; + transform: none; + } + +} + +@media screen and ( max-width: 782px ) { + .auto-fold #wpcontent { + position: relative; + margin-right: 0; + padding-right: 10px; + } + + .sticky-menu #adminmenuwrap { + position: relative; + z-index: auto; + top: 0; + } + + /* Sidebar Adjustments */ + .auto-fold #adminmenu, + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap { + position: absolute; + width: 190px; + z-index: 100; + } + + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap { + display: none; + } + + .auto-fold .wp-responsive-open #adminmenuback, + .auto-fold .wp-responsive-open #adminmenuwrap { + display: block; + } + + .auto-fold #adminmenu li.menu-top { + width: 100%; + } + + /* Resize the admin menu items to a comfortable touch size */ + .auto-fold #adminmenu li a { + font-size: 16px; + padding: 5px; + } + + .auto-fold #adminmenu li.menu-top .wp-submenu > li > a { + padding: 10px 20px 10px 10px; + } + + /* Restore the menu names */ + .auto-fold #adminmenu .wp-menu-name { + position: static; + margin-right: 35px; + } + + /* Switch the arrow side */ + .auto-fold ul#adminmenu a.wp-has-current-submenu:after, + .auto-fold ul#adminmenu > li.current > a.current:after { + border-width: 8px; + margin-top: -8px; + } + + .auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + display: none; + } + + /* Make the submenus appear correctly when tapped. */ + #adminmenu .wp-submenu { + position: relative; + display: none; + } + + .auto-fold #adminmenu .selected .wp-submenu, + .auto-fold #adminmenu .wp-menu-open .wp-submenu { + position: relative; + display: block; + top: 0; + right: -1px; + box-shadow: none; + } + + .auto-fold #adminmenu .selected .wp-submenu:after, + .auto-fold #adminmenu .wp-menu-open .wp-submenu:after { + display: none; + } + + .auto-fold #adminmenu .opensub .wp-submenu { + display: none; + } + + .auto-fold #adminmenu .selected .wp-submenu { + display: block; + } + + .auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: block; + } + + .auto-fold #adminmenu a.menu-top:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { + position: relative; + right: -1px; + left: 0; + top: 0; + } + + /* Remove submenu headers and adjust sub meu*/ + #adminmenu .wp-submenu .wp-submenu-head { + display: none; + } + + /* Toolbar menu toggle */ + #wp-responsive-toggle { + position: fixed; + top: 5px; + right: 4px; + padding-left: 10px; + z-index: 99999; + border: none; + box-sizing: border-box; + } + + #wpadminbar #wp-admin-bar-menu-toggle a { + display: block; + padding: 0; + overflow: hidden; + outline: none; + text-decoration: none; + border: 1px solid transparent; + background: none; + height: 44px; + margin-right: -1px; + } + + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #32373c; + } + + li#wp-admin-bar-menu-toggle { + display: block; + } + + #wpadminbar #wp-admin-bar-menu-toggle a:hover { + border: 1px solid transparent; + } + + #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + content: "\f228"; + display: inline-block; + float: right; + font: normal 40px/45px dashicons; + vertical-align: middle; + outline: none; + margin: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + height: 44px; + width: 50px; + padding: 0; + border: none; + text-align: center; + text-decoration: none; + box-sizing: border-box; + } + + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #00b9eb; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + #adminmenuwrap, + #adminmenuback { + display: none; + } + + .wp-responsive-open #adminmenuwrap, + .wp-responsive-open #adminmenuback { + display: block; + } + + .auto-fold #adminmenu { + top: 46px; + } +} diff --git a/backend/wp-admin/css/admin-menu-rtl.min.css b/backend/wp-admin/css/admin-menu-rtl.min.css new file mode 100644 index 0000000..b44f2a0 --- /dev/null +++ b/backend/wp-admin/css/admin-menu-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:160px;background-color:#23282d}#adminmenuback{position:fixed;top:0;bottom:-120px;z-index:1}#adminmenu{clear:right;margin:12px 0;padding:0;list-style:none}.folded #adminmenu,.folded #adminmenu li.menu-top,.folded #adminmenuback,.folded #adminmenuwrap{width:36px}.icon16{height:18px;width:18px;padding:6px;margin:-6px -8px 0 0;float:right}.icon16:before{color:#82878c;font:400 20px/1 dashicons;speak:none;padding:6px 0;height:34px;width:20px;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transition:all .1s ease-in-out}.icon16.icon-dashboard:before{content:"\f226"}.icon16.icon-post:before{content:"\f109"}.icon16.icon-media:before{content:"\f104"}.icon16.icon-links:before{content:"\f103"}.icon16.icon-page:before{content:"\f105"}.icon16.icon-comments:before{content:"\f101";margin-top:1px}.icon16.icon-appearance:before{content:"\f100"}.icon16.icon-plugins:before{content:"\f106"}.icon16.icon-users:before{content:"\f110"}.icon16.icon-tools:before{content:"\f107"}.icon16.icon-settings:before{content:"\f108"}.icon16.icon-site:before{content:"\f541"}.icon16.icon-generic:before{content:"\f111"}.icon16.icon-appearance,.icon16.icon-comments,.icon16.icon-dashboard,.icon16.icon-generic,.icon16.icon-links,.icon16.icon-media,.icon16.icon-page,.icon16.icon-plugins,.icon16.icon-post,.icon16.icon-settings,.icon16.icon-site,.icon16.icon-tools,.icon16.icon-users,.menu-icon-appearance div.wp-menu-image,.menu-icon-comments div.wp-menu-image,.menu-icon-dashboard div.wp-menu-image,.menu-icon-generic div.wp-menu-image,.menu-icon-links div.wp-menu-image,.menu-icon-media div.wp-menu-image,.menu-icon-page div.wp-menu-image,.menu-icon-plugins div.wp-menu-image,.menu-icon-post div.wp-menu-image,.menu-icon-settings div.wp-menu-image,.menu-icon-site div.wp-menu-image,.menu-icon-tools div.wp-menu-image,.menu-icon-users div.wp-menu-image{background-image:none!important}#adminmenuwrap{position:relative;float:right;z-index:9990}#adminmenu *{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#adminmenu li{margin:0;padding:0;cursor:pointer}#adminmenu a{display:block;line-height:18px;padding:2px 5px;color:#eee}#adminmenu .wp-submenu a{color:#b4b9be;color:rgba(240,245,250,.7)}#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover{background:0 0}#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a:hover,#adminmenu li.menu-top>a:focus{color:#00b9eb}#adminmenu li.menu-top{border:none;min-height:34px;position:relative}#adminmenu .wp-submenu{list-style:none;position:absolute;top:-1000em;right:160px;overflow:visible;word-wrap:break-word}#adminmenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{padding:7px 0 8px;z-index:9999;background-color:#32373c;box-shadow:0 3px 5px rgba(0,0,0,.2)}#adminmenu a.menu-top:focus+.wp-submenu,.js #adminmenu .opensub .wp-submenu,.js #adminmenu .sub-open,.no-js li.wp-has-submenu:hover .wp-submenu{top:-1px}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu .wp-submenu.sub-open,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.no-js li.wp-has-current-submenu:hover .wp-submenu{position:relative;z-index:3;top:auto;right:auto;left:auto;bottom:auto;border:0;margin-top:0;box-shadow:none;background-color:#32373c}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{position:relative;background-color:#191e23;color:#00b9eb}.folded #adminmenu li.menu-top:hover,.folded #adminmenu li.opensub>a.menu-top,.folded #adminmenu li>a.menu-top:focus{z-index:10000}#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu .wp-menu-arrow,#adminmenu .wp-menu-arrow div,#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu{background:#0073aa;color:#fff}.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,.folded #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu,.folded #adminmenu .wp-submenu.sub-open,.folded #adminmenu a.menu-top:focus+.wp-submenu,.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu{top:0;right:36px}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{position:absolute;top:-1000em}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:160px;width:auto}#adminmenu .wp-submenu a{font-size:13px;line-height:18px;margin:0;padding:5px 0}#adminmenu .opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-not-current-submenu li>a,.folded #adminmenu .wp-has-current-submenu li>a{padding-left:16px;padding-right:14px;transition:all .1s ease-in-out}#adminmenu .wp-has-current-submenu ul>li>a,.folded #adminmenu li.menu-top .wp-submenu>li>a{padding:5px 12px}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{font-size:14px;font-weight:400;line-height:18px;padding:0}#adminmenu .wp-submenu-head{display:none}.folded #adminmenu .wp-menu-name{position:absolute;right:-999px}.folded #adminmenu .wp-submenu-head{display:block}#adminmenu .wp-submenu li{padding:0;margin:0;overflow:hidden}#adminmenu .wp-menu-image img{padding:9px 0 0;opacity:.6;filter:alpha(opacity=60)}#adminmenu div.wp-menu-name{padding:8px 0}#adminmenu div.wp-menu-image{float:right;width:36px;height:34px;margin:0;text-align:center}#adminmenu div.wp-menu-image.svg{background-repeat:no-repeat;background-position:center;background-size:20px auto}div.wp-menu-image:before{color:#a0a5aa;color:rgba(240,245,250,.6);padding:7px 0;transition:all .1s ease-in-out}#adminmenu div.wp-menu-image:before{color:#a0a5aa;color:rgba(240,245,250,.6)}#adminmenu .current div.wp-menu-image:before,#adminmenu .wp-has-current-submenu div.wp-menu-image:before,#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu a.wp-has-current-submenu:hover div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before{color:#fff}#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before{color:#00b9eb}.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#a0a5aa}.folded #adminmenu div.wp-menu-image{width:35px;height:30px;position:absolute;z-index:25}.folded #adminmenu a.menu-top{height:34px}.no-font-face #adminmenu .wp-menu-image{display:none}.no-font-face #adminmenu div.wp-menu-name{padding:8px 12px}.no-font-face.auto-fold #adminmenu .wp-menu-name{margin-right:0}.sticky-menu #adminmenuwrap{position:fixed}.wp-menu-arrow{display:none!important}ul#adminmenu a.wp-has-current-submenu{position:relative}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{left:0;border:8px solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-left-color:#f1f1f1;top:50%;margin-top:-8px}.folded ul#adminmenu li:hover a.wp-has-current-submenu:after{display:none}.folded ul#adminmenu a.wp-has-current-submenu:after,.folded ul#adminmenu>li a.current:after{border-width:4px;margin-top:-4px}#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{left:0;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-width:8px;top:10px;z-index:10000}.folded ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{border-width:4px;margin-top:-4px;top:18px}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#32373c}#adminmenu li.menu-top:hover .wp-menu-image img,#adminmenu li.wp-has-current-submenu .wp-menu-image img{opacity:1;filter:alpha(opacity=100)}#adminmenu li.wp-menu-separator{height:5px;padding:0;margin:0 0 6px;cursor:inherit}#adminmenu div.separator{height:2px;padding:0}#adminmenu .wp-submenu .wp-submenu-head{color:#fff;font-weight:400;font-size:14px;padding:8px 11px 8px 4px;margin:-7px 0 4px}#adminmenu li.current,.folded #adminmenu li.wp-menu-open{border:0}#adminmenu .awaiting-mod,#adminmenu .update-plugins{display:inline-block;vertical-align:top;margin:1px 2px 0 0;padding:0 5px;min-width:7px;height:17px;border-radius:11px;background-color:#ca4a1f;color:#fff;font-size:9px;line-height:17px;text-align:center;z-index:26}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod{background-color:#00b9eb;color:#fff}#adminmenu li span.count-0{display:none}#collapse-button{display:block;width:100%;height:34px;margin:0;border:none;padding:0;position:relative;overflow:visible;line-height:34px;background:0 0;color:#aaa;cursor:pointer;outline:0}#collapse-button:focus,#collapse-button:hover{color:#00b9eb}#collapse-button .collapse-button-icon,#collapse-button .collapse-button-label{display:block;position:absolute;top:0;right:0;line-height:34px}#collapse-button .collapse-button-icon{width:36px;height:34px}#collapse-button .collapse-button-label{padding:0 36px 0 0}.folded #collapse-button .collapse-button-label{display:none}#collapse-button .collapse-button-icon:after{content:"\f148";display:block;position:relative;top:7px;text-align:center;font:400 20px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.folded #collapse-button .collapse-button-icon:after,.rtl #collapse-button .collapse-button-icon:after{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.rtl.folded #collapse-button .collapse-button-icon:after{-webkit-transform:none;transform:none}#collapse-button .collapse-button-icon:after,#collapse-button .collapse-button-label{transition:all .1s ease-in-out}.customize-support #menu-appearance a[href="themes.php?page=custom-header"],.customize-support #menu-appearance a[href="themes.php?page=custom-background"],li#wp-admin-bar-menu-toggle{display:none}@media only screen and (max-width:960px){.auto-fold #wpcontent,.auto-fold #wpfooter{margin-right:36px}.auto-fold #adminmenu,.auto-fold #adminmenu li.menu-top,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:36px}.auto-fold #adminmenu .opensub .wp-submenu,.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu,.auto-fold #adminmenu .wp-submenu.sub-open,.auto-fold #adminmenu a.menu-top:focus+.wp-submenu{top:0;right:36px}.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu,.auto-fold #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{position:absolute;top:-1000em;margin-left:-1px;padding:7px 0 8px;z-index:9999}.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu{min-width:150px;width:auto}.auto-fold #adminmenu .wp-has-current-submenu li>a{padding-left:16px;padding-right:14px}.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-right:12px}.auto-fold #adminmenu .wp-menu-name{position:absolute;right:-999px}.auto-fold #adminmenu .wp-submenu-head{display:block}.auto-fold #adminmenu div.wp-menu-image{height:30px;width:34px;position:absolute;z-index:25}.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.wp-menu-open{border:0}.auto-fold #adminmenu .wp-has-current-submenu.menu-top-last{margin-bottom:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after{display:none}.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{border-width:4px;margin-top:-4px;top:16px}.auto-fold ul#adminmenu a.wp-has-current-submenu:after,.auto-fold ul#adminmenu>li a.current:after{border-width:4px;margin-top:-4px}.auto-fold #adminmenu li.menu-top:hover,.auto-fold #adminmenu li.opensub>a.menu-top,.auto-fold #adminmenu li>a.menu-top:focus{z-index:10000}.auto-fold #collapse-menu .collapse-button-label{display:none}.auto-fold #collapse-button .collapse-button-icon:after{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.rtl.auto-fold #collapse-button .collapse-button-icon:after{-webkit-transform:none;transform:none}}@media screen and (max-width:782px){.auto-fold #wpcontent{position:relative;margin-right:0;padding-right:10px}.sticky-menu #adminmenuwrap{position:relative;z-index:auto;top:0}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{position:absolute;width:190px;z-index:100}.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{display:none}.auto-fold .wp-responsive-open #adminmenuback,.auto-fold .wp-responsive-open #adminmenuwrap{display:block}.auto-fold #adminmenu li.menu-top{width:100%}.auto-fold #adminmenu li a{font-size:16px;padding:5px}.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding:10px 20px 10px 10px}.auto-fold #adminmenu .wp-menu-name{position:static;margin-right:35px}.auto-fold ul#adminmenu a.wp-has-current-submenu:after,.auto-fold ul#adminmenu>li.current>a.current:after{border-width:8px;margin-top:-8px}.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{display:none}#adminmenu .wp-submenu{position:relative;display:none}.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu{position:relative;display:block;top:0;right:-1px;box-shadow:none}.auto-fold #adminmenu .selected .wp-submenu:after,.auto-fold #adminmenu .wp-menu-open .wp-submenu:after{display:none}.auto-fold #adminmenu .opensub .wp-submenu{display:none}.auto-fold #adminmenu .selected .wp-submenu{display:block}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after{display:block}.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.auto-fold #adminmenu a.menu-top:focus+.wp-submenu{position:relative;right:-1px;left:0;top:0}#adminmenu .wp-submenu .wp-submenu-head{display:none}#wp-responsive-toggle{position:fixed;top:5px;right:4px;padding-left:10px;z-index:99999;border:none;box-sizing:border-box}#wpadminbar #wp-admin-bar-menu-toggle a{display:block;padding:0;overflow:hidden;outline:0;text-decoration:none;border:1px solid transparent;background:0 0;height:44px;margin-right:-1px}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#32373c}li#wp-admin-bar-menu-toggle{display:block}#wpadminbar #wp-admin-bar-menu-toggle a:hover{border:1px solid transparent}#wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{content:"\f228";display:inline-block;float:right;font:400 40px/45px dashicons;vertical-align:middle;outline:0;margin:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;height:44px;width:50px;padding:0;border:none;text-align:center;text-decoration:none;box-sizing:border-box}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#00b9eb}}@media screen and (max-width:600px){#adminmenuback,#adminmenuwrap{display:none}.wp-responsive-open #adminmenuback,.wp-responsive-open #adminmenuwrap{display:block}.auto-fold #adminmenu{top:46px}} \ No newline at end of file diff --git a/backend/wp-admin/css/admin-menu.css b/backend/wp-admin/css/admin-menu.css new file mode 100644 index 0000000..9c09dac --- /dev/null +++ b/backend/wp-admin/css/admin-menu.css @@ -0,0 +1,924 @@ +#adminmenuback, +#adminmenuwrap, +#adminmenu, +#adminmenu .wp-submenu { + width: 160px; + background-color: #23282d; +} + +#adminmenuback { + position: fixed; + top: 0; + bottom: -120px; + z-index: 1; /* positive z-index to avoid elastic scrolling woes in Safari */ +} + +#adminmenu { + clear: left; + margin: 12px 0; + padding: 0; + list-style: none; +} + +.folded #adminmenuback, +.folded #adminmenuwrap, +.folded #adminmenu, +.folded #adminmenu li.menu-top { + width: 36px; +} + +.icon16 { + height: 18px; + width: 18px; + padding: 6px 6px; + margin: -6px 0 0 -8px; + float: left; +} + +/* New Menu icons */ + +.icon16:before { + color: #82878c; /* same as new icons */ + font: normal 20px/1 dashicons; + speak: none; + padding: 6px 0; + height: 34px; + width: 20px; + display: inline-block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + transition: all .1s ease-in-out; +} + +.icon16.icon-dashboard:before { + content: "\f226"; +} + +.icon16.icon-post:before { + content: "\f109"; +} + +.icon16.icon-media:before { + content: "\f104"; +} + +.icon16.icon-links:before { + content: "\f103"; +} + +.icon16.icon-page:before { + content: "\f105"; +} + +.icon16.icon-comments:before { + content: "\f101"; + margin-top: 1px; +} + +.icon16.icon-appearance:before { + content: "\f100"; +} + +.icon16.icon-plugins:before { + content: "\f106"; +} + +.icon16.icon-users:before { + content: "\f110"; +} + +.icon16.icon-tools:before { + content: "\f107"; +} + +.icon16.icon-settings:before { + content: "\f108"; +} + +.icon16.icon-site:before { + content: "\f541"; +} + +.icon16.icon-generic:before { + content: "\f111"; +} + +/* hide background-image for icons above */ +.icon16.icon-dashboard, +.menu-icon-dashboard div.wp-menu-image, +.icon16.icon-post, +.menu-icon-post div.wp-menu-image, +.icon16.icon-media, +.menu-icon-media div.wp-menu-image, +.icon16.icon-links, +.menu-icon-links div.wp-menu-image, +.icon16.icon-page, +.menu-icon-page div.wp-menu-image, +.icon16.icon-comments, +.menu-icon-comments div.wp-menu-image, +.icon16.icon-appearance, +.menu-icon-appearance div.wp-menu-image, +.icon16.icon-plugins, +.menu-icon-plugins div.wp-menu-image, +.icon16.icon-users, +.menu-icon-users div.wp-menu-image, +.icon16.icon-tools, +.menu-icon-tools div.wp-menu-image, +.icon16.icon-settings, +.menu-icon-settings div.wp-menu-image, +.icon16.icon-site, +.menu-icon-site div.wp-menu-image, +.icon16.icon-generic, +.menu-icon-generic div.wp-menu-image { + background-image: none !important; +} + +/*------------------------------------------------------------------------------ + 7.0 - Main Navigation (Left Menu) +------------------------------------------------------------------------------*/ + +#adminmenuwrap { + position: relative; + float: left; + z-index: 9990; +} + +/* side admin menu */ +#adminmenu * { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +#adminmenu li { + margin: 0; + padding: 0; + cursor: pointer; +} + +#adminmenu a { + display: block; + line-height: 18px; + padding: 2px 5px; + color: #eee; +} + +#adminmenu .wp-submenu a { + color: #b4b9be; + color: rgba(240,245,250,0.7); +} + +#adminmenu .wp-submenu a:hover, +#adminmenu .wp-submenu a:focus { + background: none; +} + +#adminmenu a:hover, +#adminmenu li.menu-top > a:focus, +#adminmenu .wp-submenu a:hover, +#adminmenu .wp-submenu a:focus { + color: #00b9eb; +} + +#adminmenu li.menu-top { + border: none; + min-height: 34px; + position: relative; +} + +#adminmenu .wp-submenu { + list-style: none; + position: absolute; + top: -1000em; + left: 160px; + overflow: visible; + word-wrap: break-word; +} + +#adminmenu .wp-submenu, +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + padding: 7px 0 8px; + z-index: 9999; + background-color: #32373c; + box-shadow: 0 3px 5px rgba(0,0,0,0.2); +} + +.js #adminmenu .sub-open, +.js #adminmenu .opensub .wp-submenu, +#adminmenu a.menu-top:focus + .wp-submenu, +.no-js li.wp-has-submenu:hover .wp-submenu { + top: -1px; +} + +#adminmenu .wp-has-current-submenu .wp-submenu, +.no-js li.wp-has-current-submenu:hover .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu.sub-open, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu { + position: relative; + z-index: 3; + top: auto; + left: auto; + right: auto; + bottom: auto; + border: 0 none; + margin-top: 0; + box-shadow: none; + background-color: #32373c; +} + +/* ensure that wp-submenu's box shadow doesn't appear on top of the focused menu item's background. */ +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + position: relative; + background-color: #191e23; + color: #00b9eb; +} + +.folded #adminmenu li.menu-top:hover, +.folded #adminmenu li.opensub > a.menu-top, +.folded #adminmenu li > a.menu-top:focus { + z-index: 10000; +} + +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.current a.menu-top, +.folded #adminmenu li.wp-has-current-submenu, +.folded #adminmenu li.current.menu-top, +#adminmenu .wp-menu-arrow, +#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head, +#adminmenu .wp-menu-arrow div { + background: #0073aa; + color: #fff; +} + +.folded #adminmenu .wp-submenu.sub-open, +.folded #adminmenu .opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, +.folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu a.menu-top:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu, +.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu { + top: 0; + left: 36px; +} + +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + position: absolute; + top: -1000em; +} + +#adminmenu .wp-not-current-submenu .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + min-width: 160px; + width: auto; +} + +#adminmenu .wp-submenu a { + font-size: 13px; + line-height: 18px; + margin: 0; + padding: 5px 0; +} + +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .opensub .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover, +#adminmenu .wp-submenu li.current a:focus { + color: #fff; +} + +#adminmenu .wp-not-current-submenu li > a, +.folded #adminmenu .wp-has-current-submenu li > a { + padding-right: 16px; + padding-left: 14px; + transition: all .1s ease-in-out; +} + +#adminmenu .wp-has-current-submenu ul > li > a, +.folded #adminmenu li.menu-top .wp-submenu > li > a { + padding: 5px 12px; +} + +#adminmenu a.menu-top, +#adminmenu .wp-submenu-head { + font-size: 14px; + font-weight: 400; + line-height: 18px; + padding: 0; +} + +#adminmenu .wp-submenu-head { + display: none; +} + +.folded #adminmenu .wp-menu-name { + position: absolute; + left: -999px; +} + +.folded #adminmenu .wp-submenu-head { + display: block; +} + +#adminmenu .wp-submenu li { + padding: 0; + margin: 0; + overflow: hidden; +} + +#adminmenu .wp-menu-image img { + padding: 9px 0 0 0; + opacity: 0.6; + filter: alpha(opacity=60); +} + +#adminmenu div.wp-menu-name { + padding: 8px 0; +} + +#adminmenu div.wp-menu-image { + float: left; + width: 36px; + height: 34px; + margin: 0; + text-align: center; +} + +#adminmenu div.wp-menu-image.svg { + background-repeat: no-repeat; + background-position: center; + background-size: 20px auto; +} + +div.wp-menu-image:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); + padding: 7px 0; + transition: all .1s ease-in-out; +} + +#adminmenu div.wp-menu-image:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); +} + +#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before, +#adminmenu .wp-has-current-submenu div.wp-menu-image:before, +#adminmenu .current div.wp-menu-image:before, +#adminmenu a.wp-has-current-submenu:hover div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before { + color: #fff; +} + +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before { + color: #00b9eb; +} + +/* IE8 doesn't redraw the pseudo elements unless you make a change to the content, this restore the initial color after hover */ +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #a0a5aa; +} + +.folded #adminmenu div.wp-menu-image { + width: 35px; + height: 30px; + position: absolute; + z-index: 25; +} + +.folded #adminmenu a.menu-top { + height: 34px; +} + +/* No @font-face support */ +.no-font-face #adminmenu .wp-menu-image { + display: none; +} + +.no-font-face #adminmenu div.wp-menu-name { + padding: 8px 12px; +} + +.no-font-face.auto-fold #adminmenu .wp-menu-name { + margin-left: 0; +} +/* End no @font-face support */ + +/* Sticky admin menu */ +.sticky-menu #adminmenuwrap { + position: fixed; +} + +/* A new arrow */ + +.wp-menu-arrow { + display: none !important; +} + +ul#adminmenu a.wp-has-current-submenu { + position: relative; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + right: 0; + border: solid 8px transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-right-color: #f1f1f1; + top: 50%; + margin-top: -8px; +} + +.folded ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: none; +} + +.folded ul#adminmenu a.wp-has-current-submenu:after, +.folded ul#adminmenu > li a.current:after { + border-width: 4px; + margin-top: -4px; +} + +/* flyout menu arrow */ +#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + right: 0; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-width: 8px; + top: 10px; + z-index: 10000; +} + +.folded ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + border-width: 4px; + margin-top: -4px; + top: 18px; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #32373c; +} + +#adminmenu li.menu-top:hover .wp-menu-image img, +#adminmenu li.wp-has-current-submenu .wp-menu-image img { + opacity: 1; + filter: alpha(opacity=100); +} + +#adminmenu li.wp-menu-separator { + height: 5px; + padding: 0; + margin: 0 0 6px 0; + cursor: inherit; +} + +/* @todo: is this even needed given that it's nested beneath the above li.wp-menu-separator? */ +#adminmenu div.separator { + height: 2px; + padding: 0; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #fff; + font-weight: 400; + font-size: 14px; + padding: 8px 4px 8px 11px; + margin: -7px 0px 4px; +} + +#adminmenu li.current, +.folded #adminmenu li.wp-menu-open { + border: 0 none; +} + +/* @todo: consider to use a single rule for these counters and the list table comments counters. */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + display: inline-block; + vertical-align: top; + margin: 1px 0 0 2px; + padding: 0 5px; + min-width: 7px; + height: 17px; + border-radius: 11px; + background-color: #ca4a1f; + color: #fff; + font-size: 9px; + line-height: 17px; + text-align: center; + z-index: 26; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins { + background-color: #00b9eb; + color: #fff; +} + +#adminmenu li span.count-0 { + display: none; +} + +#collapse-button { + display: block; + width: 100%; + height: 34px; + margin: 0; + border: none; + padding: 0; + position: relative; + overflow: visible; + line-height: 34px; + background: none; + color: #aaa; + cursor: pointer; + outline: 0; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #00b9eb; +} + +#collapse-button .collapse-button-icon, +#collapse-button .collapse-button-label { + /* absolutely positioned to avoid 1px shift in IE when button is pressed */ + display: block; + position: absolute; + top: 0; + left: 0; + line-height: 34px; +} + +#collapse-button .collapse-button-icon { + width: 36px; + height: 34px; +} + +#collapse-button .collapse-button-label { + padding: 0 0 0 36px; +} + +.folded #collapse-button .collapse-button-label { + display: none; +} + +#collapse-button .collapse-button-icon:after { + content: "\f148"; + display: block; + position: relative; + top: 7px; + text-align: center; + font: normal 20px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* rtl:ignore */ +.folded #collapse-button .collapse-button-icon:after, +.rtl #collapse-button .collapse-button-icon:after { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); +} + +.rtl.folded #collapse-button .collapse-button-icon:after { + -webkit-transform: none; + transform: none; +} + +#collapse-button .collapse-button-icon:after, +#collapse-button .collapse-button-label { + transition: all .1s ease-in-out; +} + +/** + * Toolbar menu toggle + */ +li#wp-admin-bar-menu-toggle { + display: none; +} + +/* Hide-if-customize for items we can't add classes to */ +.customize-support #menu-appearance a[href="themes.php?page=custom-header"], +.customize-support #menu-appearance a[href="themes.php?page=custom-background"] { + display: none; +} + +/* Auto-folding of the admin menu */ +@media only screen and (max-width: 960px) { + .auto-fold #wpcontent, + .auto-fold #wpfooter { + margin-left: 36px; + } + + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap, + .auto-fold #adminmenu, + .auto-fold #adminmenu li.menu-top { + width: 36px; + } + + .auto-fold #adminmenu .wp-submenu.sub-open, + .auto-fold #adminmenu .opensub .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open, + .auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu, + .auto-fold #adminmenu a.menu-top:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { + top: 0px; + left: 36px; + } + + .auto-fold #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu { + position: absolute; + top: -1000em; + margin-right: -1px; + padding: 7px 0 8px; + z-index: 9999; + } + + .auto-fold #adminmenu .wp-has-current-submenu .wp-submenu { + min-width: 150px; + width: auto; + } + + .auto-fold #adminmenu .wp-has-current-submenu li > a { + padding-right: 16px; + padding-left: 14px; + } + + + .auto-fold #adminmenu li.menu-top .wp-submenu > li > a { + padding-left: 12px; + } + + .auto-fold #adminmenu .wp-menu-name { + position: absolute; + left: -999px; + } + + .auto-fold #adminmenu .wp-submenu-head { + display: block; + } + + .auto-fold #adminmenu div.wp-menu-image { + height: 30px; + width: 34px; + position: absolute; + z-index: 25; + } + + .auto-fold #adminmenu a.menu-top { + height: 34px; + } + + .auto-fold #adminmenu li.wp-menu-open { + border: 0 none; + } + + .auto-fold #adminmenu .wp-has-current-submenu.menu-top-last { + margin-bottom: 0; + } + + .auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: none; + } + + .auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + border-width: 4px; + margin-top: -4px; + top: 16px; + } + + .auto-fold ul#adminmenu a.wp-has-current-submenu:after, + .auto-fold ul#adminmenu > li a.current:after { + border-width: 4px; + margin-top: -4px; + } + + .auto-fold #adminmenu li.menu-top:hover, + .auto-fold #adminmenu li.opensub > a.menu-top, + .auto-fold #adminmenu li > a.menu-top:focus { + z-index: 10000; + } + + .auto-fold #collapse-menu .collapse-button-label { + display: none; + } + + /* rtl:ignore */ + .auto-fold #collapse-button .collapse-button-icon:after { + -webkit-transform: rotate(180deg); + transform: rotate(180deg); + } + + .rtl.auto-fold #collapse-button .collapse-button-icon:after { + -webkit-transform: none; + transform: none; + } + +} + +@media screen and ( max-width: 782px ) { + .auto-fold #wpcontent { + position: relative; + margin-left: 0; + padding-left: 10px; + } + + .sticky-menu #adminmenuwrap { + position: relative; + z-index: auto; + top: 0; + } + + /* Sidebar Adjustments */ + .auto-fold #adminmenu, + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap { + position: absolute; + width: 190px; + z-index: 100; + } + + .auto-fold #adminmenuback, + .auto-fold #adminmenuwrap { + display: none; + } + + .auto-fold .wp-responsive-open #adminmenuback, + .auto-fold .wp-responsive-open #adminmenuwrap { + display: block; + } + + .auto-fold #adminmenu li.menu-top { + width: 100%; + } + + /* Resize the admin menu items to a comfortable touch size */ + .auto-fold #adminmenu li a { + font-size: 16px; + padding: 5px; + } + + .auto-fold #adminmenu li.menu-top .wp-submenu > li > a { + padding: 10px 10px 10px 20px; + } + + /* Restore the menu names */ + .auto-fold #adminmenu .wp-menu-name { + position: static; + margin-left: 35px; + } + + /* Switch the arrow side */ + .auto-fold ul#adminmenu a.wp-has-current-submenu:after, + .auto-fold ul#adminmenu > li.current > a.current:after { + border-width: 8px; + margin-top: -8px; + } + + .auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after { + display: none; + } + + /* Make the submenus appear correctly when tapped. */ + #adminmenu .wp-submenu { + position: relative; + display: none; + } + + .auto-fold #adminmenu .selected .wp-submenu, + .auto-fold #adminmenu .wp-menu-open .wp-submenu { + position: relative; + display: block; + top: 0; + left: -1px; + box-shadow: none; + } + + .auto-fold #adminmenu .selected .wp-submenu:after, + .auto-fold #adminmenu .wp-menu-open .wp-submenu:after { + display: none; + } + + .auto-fold #adminmenu .opensub .wp-submenu { + display: none; + } + + .auto-fold #adminmenu .selected .wp-submenu { + display: block; + } + + .auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after { + display: block; + } + + .auto-fold #adminmenu a.menu-top:focus + .wp-submenu, + .auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus + .wp-submenu { + position: relative; + left: -1px; + right: 0; + top: 0; + } + + /* Remove submenu headers and adjust sub meu*/ + #adminmenu .wp-submenu .wp-submenu-head { + display: none; + } + + /* Toolbar menu toggle */ + #wp-responsive-toggle { + position: fixed; + top: 5px; + left: 4px; + padding-right: 10px; + z-index: 99999; + border: none; + box-sizing: border-box; + } + + #wpadminbar #wp-admin-bar-menu-toggle a { + display: block; + padding: 0; + overflow: hidden; + outline: none; + text-decoration: none; + border: 1px solid transparent; + background: none; + height: 44px; + margin-left: -1px; + } + + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #32373c; + } + + li#wp-admin-bar-menu-toggle { + display: block; + } + + #wpadminbar #wp-admin-bar-menu-toggle a:hover { + border: 1px solid transparent; + } + + #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + content: "\f228"; + display: inline-block; + float: left; + font: normal 40px/45px dashicons; + vertical-align: middle; + outline: none; + margin: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + height: 44px; + width: 50px; + padding: 0; + border: none; + text-align: center; + text-decoration: none; + box-sizing: border-box; + } + + .wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #00b9eb; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + #adminmenuwrap, + #adminmenuback { + display: none; + } + + .wp-responsive-open #adminmenuwrap, + .wp-responsive-open #adminmenuback { + display: block; + } + + .auto-fold #adminmenu { + top: 46px; + } +} diff --git a/backend/wp-admin/css/admin-menu.min.css b/backend/wp-admin/css/admin-menu.min.css new file mode 100644 index 0000000..1709f16 --- /dev/null +++ b/backend/wp-admin/css/admin-menu.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#adminmenu,#adminmenu .wp-submenu,#adminmenuback,#adminmenuwrap{width:160px;background-color:#23282d}#adminmenuback{position:fixed;top:0;bottom:-120px;z-index:1}#adminmenu{clear:left;margin:12px 0;padding:0;list-style:none}.folded #adminmenu,.folded #adminmenu li.menu-top,.folded #adminmenuback,.folded #adminmenuwrap{width:36px}.icon16{height:18px;width:18px;padding:6px;margin:-6px 0 0 -8px;float:left}.icon16:before{color:#82878c;font:400 20px/1 dashicons;speak:none;padding:6px 0;height:34px;width:20px;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transition:all .1s ease-in-out}.icon16.icon-dashboard:before{content:"\f226"}.icon16.icon-post:before{content:"\f109"}.icon16.icon-media:before{content:"\f104"}.icon16.icon-links:before{content:"\f103"}.icon16.icon-page:before{content:"\f105"}.icon16.icon-comments:before{content:"\f101";margin-top:1px}.icon16.icon-appearance:before{content:"\f100"}.icon16.icon-plugins:before{content:"\f106"}.icon16.icon-users:before{content:"\f110"}.icon16.icon-tools:before{content:"\f107"}.icon16.icon-settings:before{content:"\f108"}.icon16.icon-site:before{content:"\f541"}.icon16.icon-generic:before{content:"\f111"}.icon16.icon-appearance,.icon16.icon-comments,.icon16.icon-dashboard,.icon16.icon-generic,.icon16.icon-links,.icon16.icon-media,.icon16.icon-page,.icon16.icon-plugins,.icon16.icon-post,.icon16.icon-settings,.icon16.icon-site,.icon16.icon-tools,.icon16.icon-users,.menu-icon-appearance div.wp-menu-image,.menu-icon-comments div.wp-menu-image,.menu-icon-dashboard div.wp-menu-image,.menu-icon-generic div.wp-menu-image,.menu-icon-links div.wp-menu-image,.menu-icon-media div.wp-menu-image,.menu-icon-page div.wp-menu-image,.menu-icon-plugins div.wp-menu-image,.menu-icon-post div.wp-menu-image,.menu-icon-settings div.wp-menu-image,.menu-icon-site div.wp-menu-image,.menu-icon-tools div.wp-menu-image,.menu-icon-users div.wp-menu-image{background-image:none!important}#adminmenuwrap{position:relative;float:left;z-index:9990}#adminmenu *{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#adminmenu li{margin:0;padding:0;cursor:pointer}#adminmenu a{display:block;line-height:18px;padding:2px 5px;color:#eee}#adminmenu .wp-submenu a{color:#b4b9be;color:rgba(240,245,250,.7)}#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover{background:0 0}#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a:hover,#adminmenu li.menu-top>a:focus{color:#00b9eb}#adminmenu li.menu-top{border:none;min-height:34px;position:relative}#adminmenu .wp-submenu{list-style:none;position:absolute;top:-1000em;left:160px;overflow:visible;word-wrap:break-word}#adminmenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{padding:7px 0 8px;z-index:9999;background-color:#32373c;box-shadow:0 3px 5px rgba(0,0,0,.2)}#adminmenu a.menu-top:focus+.wp-submenu,.js #adminmenu .opensub .wp-submenu,.js #adminmenu .sub-open,.no-js li.wp-has-submenu:hover .wp-submenu{top:-1px}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu .wp-submenu.sub-open,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.no-js li.wp-has-current-submenu:hover .wp-submenu{position:relative;z-index:3;top:auto;left:auto;right:auto;bottom:auto;border:0;margin-top:0;box-shadow:none;background-color:#32373c}#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{position:relative;background-color:#191e23;color:#00b9eb}.folded #adminmenu li.menu-top:hover,.folded #adminmenu li.opensub>a.menu-top,.folded #adminmenu li>a.menu-top:focus{z-index:10000}#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu .wp-menu-arrow,#adminmenu .wp-menu-arrow div,#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top,.folded #adminmenu li.wp-has-current-submenu{background:#0073aa;color:#fff}.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,.folded #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu.opensub .wp-submenu,.folded #adminmenu .wp-submenu.sub-open,.folded #adminmenu a.menu-top:focus+.wp-submenu,.no-js.folded #adminmenu .wp-has-submenu:hover .wp-submenu{top:0;left:36px}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{position:absolute;top:-1000em}#adminmenu .wp-not-current-submenu .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{min-width:160px;width:auto}#adminmenu .wp-submenu a{font-size:13px;line-height:18px;margin:0;padding:5px 0}#adminmenu .opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-not-current-submenu li>a,.folded #adminmenu .wp-has-current-submenu li>a{padding-right:16px;padding-left:14px;transition:all .1s ease-in-out}#adminmenu .wp-has-current-submenu ul>li>a,.folded #adminmenu li.menu-top .wp-submenu>li>a{padding:5px 12px}#adminmenu .wp-submenu-head,#adminmenu a.menu-top{font-size:14px;font-weight:400;line-height:18px;padding:0}#adminmenu .wp-submenu-head{display:none}.folded #adminmenu .wp-menu-name{position:absolute;left:-999px}.folded #adminmenu .wp-submenu-head{display:block}#adminmenu .wp-submenu li{padding:0;margin:0;overflow:hidden}#adminmenu .wp-menu-image img{padding:9px 0 0;opacity:.6;filter:alpha(opacity=60)}#adminmenu div.wp-menu-name{padding:8px 0}#adminmenu div.wp-menu-image{float:left;width:36px;height:34px;margin:0;text-align:center}#adminmenu div.wp-menu-image.svg{background-repeat:no-repeat;background-position:center;background-size:20px auto}div.wp-menu-image:before{color:#a0a5aa;color:rgba(240,245,250,.6);padding:7px 0;transition:all .1s ease-in-out}#adminmenu div.wp-menu-image:before{color:#a0a5aa;color:rgba(240,245,250,.6)}#adminmenu .current div.wp-menu-image:before,#adminmenu .wp-has-current-submenu div.wp-menu-image:before,#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu a.wp-has-current-submenu:hover div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu:hover div.wp-menu-image:before{color:#fff}#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before{color:#00b9eb}.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#a0a5aa}.folded #adminmenu div.wp-menu-image{width:35px;height:30px;position:absolute;z-index:25}.folded #adminmenu a.menu-top{height:34px}.no-font-face #adminmenu .wp-menu-image{display:none}.no-font-face #adminmenu div.wp-menu-name{padding:8px 12px}.no-font-face.auto-fold #adminmenu .wp-menu-name{margin-left:0}.sticky-menu #adminmenuwrap{position:fixed}.wp-menu-arrow{display:none!important}ul#adminmenu a.wp-has-current-submenu{position:relative}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{right:0;border:8px solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-right-color:#f1f1f1;top:50%;margin-top:-8px}.folded ul#adminmenu li:hover a.wp-has-current-submenu:after{display:none}.folded ul#adminmenu a.wp-has-current-submenu:after,.folded ul#adminmenu>li a.current:after{border-width:4px;margin-top:-4px}#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{right:0;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-width:8px;top:10px;z-index:10000}.folded ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{border-width:4px;margin-top:-4px;top:18px}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#32373c}#adminmenu li.menu-top:hover .wp-menu-image img,#adminmenu li.wp-has-current-submenu .wp-menu-image img{opacity:1;filter:alpha(opacity=100)}#adminmenu li.wp-menu-separator{height:5px;padding:0;margin:0 0 6px;cursor:inherit}#adminmenu div.separator{height:2px;padding:0}#adminmenu .wp-submenu .wp-submenu-head{color:#fff;font-weight:400;font-size:14px;padding:8px 4px 8px 11px;margin:-7px 0 4px}#adminmenu li.current,.folded #adminmenu li.wp-menu-open{border:0}#adminmenu .awaiting-mod,#adminmenu .update-plugins{display:inline-block;vertical-align:top;margin:1px 0 0 2px;padding:0 5px;min-width:7px;height:17px;border-radius:11px;background-color:#ca4a1f;color:#fff;font-size:9px;line-height:17px;text-align:center;z-index:26}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod{background-color:#00b9eb;color:#fff}#adminmenu li span.count-0{display:none}#collapse-button{display:block;width:100%;height:34px;margin:0;border:none;padding:0;position:relative;overflow:visible;line-height:34px;background:0 0;color:#aaa;cursor:pointer;outline:0}#collapse-button:focus,#collapse-button:hover{color:#00b9eb}#collapse-button .collapse-button-icon,#collapse-button .collapse-button-label{display:block;position:absolute;top:0;left:0;line-height:34px}#collapse-button .collapse-button-icon{width:36px;height:34px}#collapse-button .collapse-button-label{padding:0 0 0 36px}.folded #collapse-button .collapse-button-label{display:none}#collapse-button .collapse-button-icon:after{content:"\f148";display:block;position:relative;top:7px;text-align:center;font:400 20px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.folded #collapse-button .collapse-button-icon:after,.rtl #collapse-button .collapse-button-icon:after{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.rtl.folded #collapse-button .collapse-button-icon:after{-webkit-transform:none;transform:none}#collapse-button .collapse-button-icon:after,#collapse-button .collapse-button-label{transition:all .1s ease-in-out}.customize-support #menu-appearance a[href="themes.php?page=custom-header"],.customize-support #menu-appearance a[href="themes.php?page=custom-background"],li#wp-admin-bar-menu-toggle{display:none}@media only screen and (max-width:960px){.auto-fold #wpcontent,.auto-fold #wpfooter{margin-left:36px}.auto-fold #adminmenu,.auto-fold #adminmenu li.menu-top,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{width:36px}.auto-fold #adminmenu .opensub .wp-submenu,.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.auto-fold #adminmenu .wp-has-current-submenu.opensub .wp-submenu,.auto-fold #adminmenu .wp-submenu.sub-open,.auto-fold #adminmenu a.menu-top:focus+.wp-submenu{top:0;left:36px}.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu,.auto-fold #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{position:absolute;top:-1000em;margin-right:-1px;padding:7px 0 8px;z-index:9999}.auto-fold #adminmenu .wp-has-current-submenu .wp-submenu{min-width:150px;width:auto}.auto-fold #adminmenu .wp-has-current-submenu li>a{padding-right:16px;padding-left:14px}.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding-left:12px}.auto-fold #adminmenu .wp-menu-name{position:absolute;left:-999px}.auto-fold #adminmenu .wp-submenu-head{display:block}.auto-fold #adminmenu div.wp-menu-image{height:30px;width:34px;position:absolute;z-index:25}.auto-fold #adminmenu a.menu-top{height:34px}.auto-fold #adminmenu li.wp-menu-open{border:0}.auto-fold #adminmenu .wp-has-current-submenu.menu-top-last{margin-bottom:0}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after{display:none}.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{border-width:4px;margin-top:-4px;top:16px}.auto-fold ul#adminmenu a.wp-has-current-submenu:after,.auto-fold ul#adminmenu>li a.current:after{border-width:4px;margin-top:-4px}.auto-fold #adminmenu li.menu-top:hover,.auto-fold #adminmenu li.opensub>a.menu-top,.auto-fold #adminmenu li>a.menu-top:focus{z-index:10000}.auto-fold #collapse-menu .collapse-button-label{display:none}.auto-fold #collapse-button .collapse-button-icon:after{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.rtl.auto-fold #collapse-button .collapse-button-icon:after{-webkit-transform:none;transform:none}}@media screen and (max-width:782px){.auto-fold #wpcontent{position:relative;margin-left:0;padding-left:10px}.sticky-menu #adminmenuwrap{position:relative;z-index:auto;top:0}.auto-fold #adminmenu,.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{position:absolute;width:190px;z-index:100}.auto-fold #adminmenuback,.auto-fold #adminmenuwrap{display:none}.auto-fold .wp-responsive-open #adminmenuback,.auto-fold .wp-responsive-open #adminmenuwrap{display:block}.auto-fold #adminmenu li.menu-top{width:100%}.auto-fold #adminmenu li a{font-size:16px;padding:5px}.auto-fold #adminmenu li.menu-top .wp-submenu>li>a{padding:10px 10px 10px 20px}.auto-fold #adminmenu .wp-menu-name{position:static;margin-left:35px}.auto-fold ul#adminmenu a.wp-has-current-submenu:after,.auto-fold ul#adminmenu>li.current>a.current:after{border-width:8px;margin-top:-8px}.auto-fold ul#adminmenu li.wp-has-submenu.wp-not-current-submenu:hover:after{display:none}#adminmenu .wp-submenu{position:relative;display:none}.auto-fold #adminmenu .selected .wp-submenu,.auto-fold #adminmenu .wp-menu-open .wp-submenu{position:relative;display:block;top:0;left:-1px;box-shadow:none}.auto-fold #adminmenu .selected .wp-submenu:after,.auto-fold #adminmenu .wp-menu-open .wp-submenu:after{display:none}.auto-fold #adminmenu .opensub .wp-submenu{display:none}.auto-fold #adminmenu .selected .wp-submenu{display:block}.auto-fold ul#adminmenu li:hover a.wp-has-current-submenu:after{display:block}.auto-fold #adminmenu .wp-has-current-submenu a.menu-top:focus+.wp-submenu,.auto-fold #adminmenu a.menu-top:focus+.wp-submenu{position:relative;left:-1px;right:0;top:0}#adminmenu .wp-submenu .wp-submenu-head{display:none}#wp-responsive-toggle{position:fixed;top:5px;left:4px;padding-right:10px;z-index:99999;border:none;box-sizing:border-box}#wpadminbar #wp-admin-bar-menu-toggle a{display:block;padding:0;overflow:hidden;outline:0;text-decoration:none;border:1px solid transparent;background:0 0;height:44px;margin-left:-1px}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#32373c}li#wp-admin-bar-menu-toggle{display:block}#wpadminbar #wp-admin-bar-menu-toggle a:hover{border:1px solid transparent}#wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{content:"\f228";display:inline-block;float:left;font:400 40px/45px dashicons;vertical-align:middle;outline:0;margin:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;height:44px;width:50px;padding:0;border:none;text-align:center;text-decoration:none;box-sizing:border-box}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#00b9eb}}@media screen and (max-width:600px){#adminmenuback,#adminmenuwrap{display:none}.wp-responsive-open #adminmenuback,.wp-responsive-open #adminmenuwrap{display:block}.auto-fold #adminmenu{top:46px}} \ No newline at end of file diff --git a/backend/wp-admin/css/code-editor-rtl.css b/backend/wp-admin/css/code-editor-rtl.css new file mode 100644 index 0000000..a33caa0 --- /dev/null +++ b/backend/wp-admin/css/code-editor-rtl.css @@ -0,0 +1,72 @@ +.wrap [class*="CodeMirror-lint-marker"], +.wp-core-ui [class*="CodeMirror-lint-message"], +.wrap .CodeMirror-lint-marker-multiple { + background-image: none; +} + +.wp-core-ui .CodeMirror-lint-marker-error, +.wp-core-ui .CodeMirror-lint-marker-warning { + cursor: help; +} + +.wrap .CodeMirror-lint-marker-multiple { + position: absolute; + top: 0; +} + +.wrap [class*="CodeMirror-lint-marker"]:before { + font: normal 18px/1 dashicons; + position: relative; + top: -2px; +} + +.wp-core-ui [class*="CodeMirror-lint-message"]:before { + font: normal 16px/1 dashicons; + right: 16px; + position: absolute; +} + +.wp-core-ui .CodeMirror-lint-message-error, +.wp-core-ui .CodeMirror-lint-message-warning { + box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); + margin: 5px 0 2px; + padding: 3px 28px 3px 12px; +} + +.wp-core-ui .CodeMirror-lint-message-warning { + background-color: #fff8e5; + border-right: 4px solid #ffb900; +} + +.wrap .CodeMirror-lint-marker-warning:before, +.wp-core-ui .CodeMirror-lint-message-warning:before { + content: "\f534"; + color: #f6a306; +} + +.wp-core-ui .CodeMirror-lint-message-error { + background-color: #fbeaea; + border-right: 4px solid #dc3232; +} + +.wrap .CodeMirror-lint-marker-error:before, +.wp-core-ui .CodeMirror-lint-message-error:before { + content: "\f153"; + color: #dc3232; +} + +.wp-core-ui .CodeMirror-lint-tooltip { + background: none; + border: none; + border-radius: 0; + direction: rtl; +} + +.wrap .CodeMirror .CodeMirror-matchingbracket { + background: rgba(255, 150, 0, .3); + color: inherit; +} + +.CodeMirror { + text-align: right; +} diff --git a/backend/wp-admin/css/code-editor-rtl.min.css b/backend/wp-admin/css/code-editor-rtl.min.css new file mode 100644 index 0000000..96717e1 --- /dev/null +++ b/backend/wp-admin/css/code-editor-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-core-ui [class*=CodeMirror-lint-message],.wrap .CodeMirror-lint-marker-multiple,.wrap [class*=CodeMirror-lint-marker]{background-image:none}.wp-core-ui .CodeMirror-lint-marker-error,.wp-core-ui .CodeMirror-lint-marker-warning{cursor:help}.wrap .CodeMirror-lint-marker-multiple{position:absolute;top:0}.wrap [class*=CodeMirror-lint-marker]:before{font:400 18px/1 dashicons;position:relative;top:-2px}.wp-core-ui [class*=CodeMirror-lint-message]:before{font:400 16px/1 dashicons;right:16px;position:absolute}.wp-core-ui .CodeMirror-lint-message-error,.wp-core-ui .CodeMirror-lint-message-warning{box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 0 2px;padding:3px 28px 3px 12px}.wp-core-ui .CodeMirror-lint-message-warning{background-color:#fff8e5;border-right:4px solid #ffb900}.wp-core-ui .CodeMirror-lint-message-warning:before,.wrap .CodeMirror-lint-marker-warning:before{content:"\f534";color:#f6a306}.wp-core-ui .CodeMirror-lint-message-error{background-color:#fbeaea;border-right:4px solid #dc3232}.wp-core-ui .CodeMirror-lint-message-error:before,.wrap .CodeMirror-lint-marker-error:before{content:"\f153";color:#dc3232}.wp-core-ui .CodeMirror-lint-tooltip{background:0 0;border:none;border-radius:0;direction:rtl}.wrap .CodeMirror .CodeMirror-matchingbracket{background:rgba(255,150,0,.3);color:inherit}.CodeMirror{text-align:right} \ No newline at end of file diff --git a/backend/wp-admin/css/code-editor.css b/backend/wp-admin/css/code-editor.css new file mode 100644 index 0000000..3c2f5e5 --- /dev/null +++ b/backend/wp-admin/css/code-editor.css @@ -0,0 +1,72 @@ +.wrap [class*="CodeMirror-lint-marker"], +.wp-core-ui [class*="CodeMirror-lint-message"], +.wrap .CodeMirror-lint-marker-multiple { + background-image: none; +} + +.wp-core-ui .CodeMirror-lint-marker-error, +.wp-core-ui .CodeMirror-lint-marker-warning { + cursor: help; +} + +.wrap .CodeMirror-lint-marker-multiple { + position: absolute; + top: 0; +} + +.wrap [class*="CodeMirror-lint-marker"]:before { + font: normal 18px/1 dashicons; + position: relative; + top: -2px; +} + +.wp-core-ui [class*="CodeMirror-lint-message"]:before { + font: normal 16px/1 dashicons; + left: 16px; + position: absolute; +} + +.wp-core-ui .CodeMirror-lint-message-error, +.wp-core-ui .CodeMirror-lint-message-warning { + box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); + margin: 5px 0 2px; + padding: 3px 12px 3px 28px; +} + +.wp-core-ui .CodeMirror-lint-message-warning { + background-color: #fff8e5; + border-left: 4px solid #ffb900; +} + +.wrap .CodeMirror-lint-marker-warning:before, +.wp-core-ui .CodeMirror-lint-message-warning:before { + content: "\f534"; + color: #f6a306; +} + +.wp-core-ui .CodeMirror-lint-message-error { + background-color: #fbeaea; + border-left: 4px solid #dc3232; +} + +.wrap .CodeMirror-lint-marker-error:before, +.wp-core-ui .CodeMirror-lint-message-error:before { + content: "\f153"; + color: #dc3232; +} + +.wp-core-ui .CodeMirror-lint-tooltip { + background: none; + border: none; + border-radius: 0; + direction: ltr; +} + +.wrap .CodeMirror .CodeMirror-matchingbracket { + background: rgba(255, 150, 0, .3); + color: inherit; +} + +.CodeMirror { + text-align: left; +} diff --git a/backend/wp-admin/css/code-editor.min.css b/backend/wp-admin/css/code-editor.min.css new file mode 100644 index 0000000..922f908 --- /dev/null +++ b/backend/wp-admin/css/code-editor.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-core-ui [class*=CodeMirror-lint-message],.wrap .CodeMirror-lint-marker-multiple,.wrap [class*=CodeMirror-lint-marker]{background-image:none}.wp-core-ui .CodeMirror-lint-marker-error,.wp-core-ui .CodeMirror-lint-marker-warning{cursor:help}.wrap .CodeMirror-lint-marker-multiple{position:absolute;top:0}.wrap [class*=CodeMirror-lint-marker]:before{font:400 18px/1 dashicons;position:relative;top:-2px}.wp-core-ui [class*=CodeMirror-lint-message]:before{font:400 16px/1 dashicons;left:16px;position:absolute}.wp-core-ui .CodeMirror-lint-message-error,.wp-core-ui .CodeMirror-lint-message-warning{box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 0 2px;padding:3px 12px 3px 28px}.wp-core-ui .CodeMirror-lint-message-warning{background-color:#fff8e5;border-left:4px solid #ffb900}.wp-core-ui .CodeMirror-lint-message-warning:before,.wrap .CodeMirror-lint-marker-warning:before{content:"\f534";color:#f6a306}.wp-core-ui .CodeMirror-lint-message-error{background-color:#fbeaea;border-left:4px solid #dc3232}.wp-core-ui .CodeMirror-lint-message-error:before,.wrap .CodeMirror-lint-marker-error:before{content:"\f153";color:#dc3232}.wp-core-ui .CodeMirror-lint-tooltip{background:0 0;border:none;border-radius:0;direction:ltr}.wrap .CodeMirror .CodeMirror-matchingbracket{background:rgba(255,150,0,.3);color:inherit}.CodeMirror{text-align:left} \ No newline at end of file diff --git a/backend/wp-admin/css/color-picker-rtl.css b/backend/wp-admin/css/color-picker-rtl.css new file mode 100644 index 0000000..aca78d9 --- /dev/null +++ b/backend/wp-admin/css/color-picker-rtl.css @@ -0,0 +1,173 @@ +.wp-color-picker { + width: 80px; +} + +.wp-picker-container .hidden { + display: none; +} + +/* Needs higher specificiity. */ +.wp-picker-container .wp-color-result.button { + height: 24px; + margin: 0 0px 6px 6px; + padding: 0 30px 0 0; + font-size: 11px; +} + +.wp-color-result-text { + background: #f7f7f7; + border-radius: 2px 0 0 2px; + border-right: 1px solid #ccc; + color: #555; + display: block; + line-height: 22px; + padding: 0 6px; + text-align: center; +} + +.wp-color-result:hover, +.wp-color-result:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.wp-color-result:hover:after, +.wp-color-result:focus:after { + color: #23282d; + border-color: #a0a5aa; + border-right: 1px solid #999; +} + +.wp-picker-containers { + display: inline-block; +} + +.wp-color-result:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-color-result:active { + /* See Trac ticket #39662 */ + -webkit-transform: none !important; + transform: none !important; +} + +.wp-picker-open + .wp-picker-input-wrap { + display: inline-block; + vertical-align: top; +} + +.wp-picker-input-wrap label { + display: inline-block; + vertical-align: top; +} + +/* For the old `custom-background` page, to override the inline-block and margins from `.form-table td fieldset label`. */ +.form-table .wp-picker-input-wrap label { + margin: 0 !important; +} + +.wp-picker-input-wrap .button, +.wp-customizer .wp-picker-input-wrap .button { + margin-right: 6px; +} + +.wp-picker-container .iris-square-slider .ui-slider-handle:focus { + background-color: #555 +} + +.wp-picker-container .iris-picker { + border-radius: 0; + border-color: #ddd; + margin-top: 6px; +} + +.wp-picker-container input[type="text"].wp-color-picker { + width: 65px; + font-size: 12px; + font-family: monospace; + line-height: 16px; + margin: 0; + vertical-align: top; +} + +.wp-color-picker::-webkit-input-placeholder { + color: #72777c; +} + +.wp-color-picker::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +.wp-color-picker:-ms-input-placeholder { + color: #72777c; +} + +.wp-picker-container input[type="text"].iris-error { + background-color: #ffebe8; + border-color: #c00; + color: #000; +} + +.iris-picker .ui-square-handle:focus, +.iris-picker .iris-strip .ui-slider-handle:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.iris-picker .iris-palette:focus { + box-shadow: + inset 0 0 5px rgba(0,0,0,.4), + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +@media screen and ( max-width: 782px ) { + .wp-picker-container input[type="text"].wp-color-picker { + width: 80px; + padding: 6px 5px 5px; + font-size: 16px; + line-height: 18px; + } + + .wp-customizer .wp-picker-container input[type="text"].wp-color-picker { + padding: 5px 5px 4px; + } + + .wp-picker-container .wp-color-result.button { + height: auto; + padding: 0 40px 0 0; + font-size: 14px; + line-height: 29px; + } + + .wp-customizer .wp-picker-container .wp-color-result.button { + font-size: 13px; + line-height: 26px; + } + + .wp-picker-container .wp-color-result-text { + padding: 0 14px; + font-size: inherit; + line-height: inherit; + } + + .wp-customizer .wp-picker-container .wp-color-result-text { + padding: 0 10px; + } +} + +@media screen and ( max-width: 640px ) { + .wp-customizer .wp-picker-container .wp-color-result.button { + font-size: 14px; + line-height: 29px; + } + + .wp-customizer .wp-picker-container input[type="text"].wp-color-picker { + padding: 6px 5px; + } +} diff --git a/backend/wp-admin/css/color-picker-rtl.min.css b/backend/wp-admin/css/color-picker-rtl.min.css new file mode 100644 index 0000000..ad86822 --- /dev/null +++ b/backend/wp-admin/css/color-picker-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-color-picker{width:80px}.wp-picker-container .hidden{display:none}.wp-picker-container .wp-color-result.button{height:24px;margin:0 0 6px 6px;padding:0 30px 0 0;font-size:11px}.wp-color-result-text{background:#f7f7f7;border-radius:2px 0 0 2px;border-right:1px solid #ccc;color:#555;display:block;line-height:22px;padding:0 6px;text-align:center}.wp-color-result:focus,.wp-color-result:hover{background:#fafafa;border-color:#999;color:#23282d}.wp-color-result:focus:after,.wp-color-result:hover:after{color:#23282d;border-color:#a0a5aa;border-right:1px solid #999}.wp-picker-containers{display:inline-block}.wp-color-result:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-color-result:active{-webkit-transform:none!important;transform:none!important}.wp-picker-input-wrap label,.wp-picker-open+.wp-picker-input-wrap{display:inline-block;vertical-align:top}.form-table .wp-picker-input-wrap label{margin:0!important}.wp-customizer .wp-picker-input-wrap .button,.wp-picker-input-wrap .button{margin-right:6px}.wp-picker-container .iris-square-slider .ui-slider-handle:focus{background-color:#555}.wp-picker-container .iris-picker{border-radius:0;border-color:#ddd;margin-top:6px}.wp-picker-container input[type=text].wp-color-picker{width:65px;font-size:12px;font-family:monospace;line-height:16px;margin:0;vertical-align:top}.wp-color-picker::-webkit-input-placeholder{color:#72777c}.wp-color-picker::-moz-placeholder{color:#72777c;opacity:1}.wp-color-picker:-ms-input-placeholder{color:#72777c}.wp-picker-container input[type=text].iris-error{background-color:#ffebe8;border-color:#c00;color:#000}.iris-picker .iris-strip .ui-slider-handle:focus,.iris-picker .ui-square-handle:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.iris-picker .iris-palette:focus{box-shadow:inset 0 0 5px rgba(0,0,0,.4),0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}@media screen and (max-width:782px){.wp-picker-container input[type=text].wp-color-picker{width:80px;padding:6px 5px 5px;font-size:16px;line-height:18px}.wp-customizer .wp-picker-container input[type=text].wp-color-picker{padding:5px 5px 4px}.wp-picker-container .wp-color-result.button{height:auto;padding:0 40px 0 0;font-size:14px;line-height:29px}.wp-customizer .wp-picker-container .wp-color-result.button{font-size:13px;line-height:26px}.wp-picker-container .wp-color-result-text{padding:0 14px;font-size:inherit;line-height:inherit}.wp-customizer .wp-picker-container .wp-color-result-text{padding:0 10px}}@media screen and (max-width:640px){.wp-customizer .wp-picker-container .wp-color-result.button{font-size:14px;line-height:29px}.wp-customizer .wp-picker-container input[type=text].wp-color-picker{padding:6px 5px}} \ No newline at end of file diff --git a/backend/wp-admin/css/color-picker.css b/backend/wp-admin/css/color-picker.css new file mode 100644 index 0000000..00d7caf --- /dev/null +++ b/backend/wp-admin/css/color-picker.css @@ -0,0 +1,173 @@ +.wp-color-picker { + width: 80px; +} + +.wp-picker-container .hidden { + display: none; +} + +/* Needs higher specificiity. */ +.wp-picker-container .wp-color-result.button { + height: 24px; + margin: 0 6px 6px 0px; + padding: 0 0 0 30px; + font-size: 11px; +} + +.wp-color-result-text { + background: #f7f7f7; + border-radius: 0 2px 2px 0; + border-left: 1px solid #ccc; + color: #555; + display: block; + line-height: 22px; + padding: 0 6px; + text-align: center; +} + +.wp-color-result:hover, +.wp-color-result:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.wp-color-result:hover:after, +.wp-color-result:focus:after { + color: #23282d; + border-color: #a0a5aa; + border-left: 1px solid #999; +} + +.wp-picker-containers { + display: inline-block; +} + +.wp-color-result:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-color-result:active { + /* See Trac ticket #39662 */ + -webkit-transform: none !important; + transform: none !important; +} + +.wp-picker-open + .wp-picker-input-wrap { + display: inline-block; + vertical-align: top; +} + +.wp-picker-input-wrap label { + display: inline-block; + vertical-align: top; +} + +/* For the old `custom-background` page, to override the inline-block and margins from `.form-table td fieldset label`. */ +.form-table .wp-picker-input-wrap label { + margin: 0 !important; +} + +.wp-picker-input-wrap .button, +.wp-customizer .wp-picker-input-wrap .button { + margin-left: 6px; +} + +.wp-picker-container .iris-square-slider .ui-slider-handle:focus { + background-color: #555 +} + +.wp-picker-container .iris-picker { + border-radius: 0; + border-color: #ddd; + margin-top: 6px; +} + +.wp-picker-container input[type="text"].wp-color-picker { + width: 65px; + font-size: 12px; + font-family: monospace; + line-height: 16px; + margin: 0; + vertical-align: top; +} + +.wp-color-picker::-webkit-input-placeholder { + color: #72777c; +} + +.wp-color-picker::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +.wp-color-picker:-ms-input-placeholder { + color: #72777c; +} + +.wp-picker-container input[type="text"].iris-error { + background-color: #ffebe8; + border-color: #c00; + color: #000; +} + +.iris-picker .ui-square-handle:focus, +.iris-picker .iris-strip .ui-slider-handle:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.iris-picker .iris-palette:focus { + box-shadow: + inset 0 0 5px rgba(0,0,0,.4), + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +@media screen and ( max-width: 782px ) { + .wp-picker-container input[type="text"].wp-color-picker { + width: 80px; + padding: 6px 5px 5px; + font-size: 16px; + line-height: 18px; + } + + .wp-customizer .wp-picker-container input[type="text"].wp-color-picker { + padding: 5px 5px 4px; + } + + .wp-picker-container .wp-color-result.button { + height: auto; + padding: 0 0 0 40px; + font-size: 14px; + line-height: 29px; + } + + .wp-customizer .wp-picker-container .wp-color-result.button { + font-size: 13px; + line-height: 26px; + } + + .wp-picker-container .wp-color-result-text { + padding: 0 14px; + font-size: inherit; + line-height: inherit; + } + + .wp-customizer .wp-picker-container .wp-color-result-text { + padding: 0 10px; + } +} + +@media screen and ( max-width: 640px ) { + .wp-customizer .wp-picker-container .wp-color-result.button { + font-size: 14px; + line-height: 29px; + } + + .wp-customizer .wp-picker-container input[type="text"].wp-color-picker { + padding: 6px 5px; + } +} diff --git a/backend/wp-admin/css/color-picker.min.css b/backend/wp-admin/css/color-picker.min.css new file mode 100644 index 0000000..d5e49a1 --- /dev/null +++ b/backend/wp-admin/css/color-picker.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-color-picker{width:80px}.wp-picker-container .hidden{display:none}.wp-picker-container .wp-color-result.button{height:24px;margin:0 6px 6px 0;padding:0 0 0 30px;font-size:11px}.wp-color-result-text{background:#f7f7f7;border-radius:0 2px 2px 0;border-left:1px solid #ccc;color:#555;display:block;line-height:22px;padding:0 6px;text-align:center}.wp-color-result:focus,.wp-color-result:hover{background:#fafafa;border-color:#999;color:#23282d}.wp-color-result:focus:after,.wp-color-result:hover:after{color:#23282d;border-color:#a0a5aa;border-left:1px solid #999}.wp-picker-containers{display:inline-block}.wp-color-result:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-color-result:active{-webkit-transform:none!important;transform:none!important}.wp-picker-input-wrap label,.wp-picker-open+.wp-picker-input-wrap{display:inline-block;vertical-align:top}.form-table .wp-picker-input-wrap label{margin:0!important}.wp-customizer .wp-picker-input-wrap .button,.wp-picker-input-wrap .button{margin-left:6px}.wp-picker-container .iris-square-slider .ui-slider-handle:focus{background-color:#555}.wp-picker-container .iris-picker{border-radius:0;border-color:#ddd;margin-top:6px}.wp-picker-container input[type=text].wp-color-picker{width:65px;font-size:12px;font-family:monospace;line-height:16px;margin:0;vertical-align:top}.wp-color-picker::-webkit-input-placeholder{color:#72777c}.wp-color-picker::-moz-placeholder{color:#72777c;opacity:1}.wp-color-picker:-ms-input-placeholder{color:#72777c}.wp-picker-container input[type=text].iris-error{background-color:#ffebe8;border-color:#c00;color:#000}.iris-picker .iris-strip .ui-slider-handle:focus,.iris-picker .ui-square-handle:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.iris-picker .iris-palette:focus{box-shadow:inset 0 0 5px rgba(0,0,0,.4),0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}@media screen and (max-width:782px){.wp-picker-container input[type=text].wp-color-picker{width:80px;padding:6px 5px 5px;font-size:16px;line-height:18px}.wp-customizer .wp-picker-container input[type=text].wp-color-picker{padding:5px 5px 4px}.wp-picker-container .wp-color-result.button{height:auto;padding:0 0 0 40px;font-size:14px;line-height:29px}.wp-customizer .wp-picker-container .wp-color-result.button{font-size:13px;line-height:26px}.wp-picker-container .wp-color-result-text{padding:0 14px;font-size:inherit;line-height:inherit}.wp-customizer .wp-picker-container .wp-color-result-text{padding:0 10px}}@media screen and (max-width:640px){.wp-customizer .wp-picker-container .wp-color-result.button{font-size:14px;line-height:29px}.wp-customizer .wp-picker-container input[type=text].wp-color-picker{padding:6px 5px}} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/_admin.scss b/backend/wp-admin/css/colors/_admin.scss new file mode 100644 index 0000000..928670d --- /dev/null +++ b/backend/wp-admin/css/colors/_admin.scss @@ -0,0 +1,493 @@ + +@import 'variables'; +@import 'mixins'; + + +body { + background: $body-background; +} + + +/* Links */ + +a { + color: $link; + + &:hover, + &:active, + &:focus { + color: $link-focus; + } +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: $link-focus; +} + + +/* Forms */ + +input[type=checkbox]:checked:before { + color: $form-checked; +} + +input[type=radio]:checked:before { + background: $form-checked; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: $link-focus; +} + + +/* Core UI */ + +.wp-core-ui { + .button-primary { + @include button( $button-color ); + } + + .wp-ui-primary { + color: $text-color; + background-color: $base-color; + } + .wp-ui-text-primary { + color: $base-color; + } + + .wp-ui-highlight { + color: $menu-highlight-text; + background-color: $menu-highlight-background; + } + .wp-ui-text-highlight { + color: $menu-highlight-background; + } + + .wp-ui-notification { + color: $menu-bubble-text; + background-color: $menu-bubble-background; + } + .wp-ui-text-notification { + color: $menu-bubble-background; + } + + .wp-ui-text-icon { + color: $menu-icon; + } +} + + +/* List tables */ + +.wrap .add-new-h2:hover, /* deprecated */ +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: $menu-text; + background-color: $menu-background; +} + +.view-switch a.current:before { + color: $menu-background; +} + +.view-switch a:hover:before { + color: $menu-bubble-background; +} + + +/* Admin Menu */ + +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: $menu-background; +} + +#adminmenu a { + color: $menu-text; +} + +#adminmenu div.wp-menu-image:before { + color: $menu-icon; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: $menu-highlight-text; + background-color: $menu-highlight-background; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: $menu-highlight-icon; +} + + +/* Active tabs use a bottom border color that matches the page background color. */ + +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: $body-background; + border-bottom-color: $body-background; +} + + +/* Admin Menu: submenu */ + +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: $menu-submenu-background; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: $menu-submenu-background; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: $menu-submenu-text; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: $menu-submenu-text; + + &:focus, &:hover { + color: $menu-submenu-focus-text; + } +} + + +/* Admin Menu: current */ + +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: $menu-submenu-current-text; + + &:hover, &:focus { + color: $menu-submenu-focus-text; + } +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: $body-background; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: $menu-current-text; + background: $menu-current-background; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: $menu-current-icon; +} + + +/* Admin Menu: bubble */ + +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: $menu-bubble-text; + background: $menu-bubble-background; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: $menu-bubble-current-text; + background: $menu-bubble-current-background; +} + + +/* Admin Menu: collapse button */ + +#collapse-button { + color: $menu-collapse-text; +} + +#collapse-button:hover, +#collapse-button:focus { + color: $menu-submenu-focus-text; +} + +/* Admin Bar */ + +#wpadminbar { + color: $menu-text; + background: $menu-background; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: $menu-text; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: $menu-icon; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: $menu-submenu-focus-text; + background: $menu-submenu-background; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: $menu-submenu-focus-text; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: $menu-highlight-icon; +} + + +/* Admin Bar: submenu */ + +#wpadminbar .menupop .ab-sub-wrapper { + background: $menu-submenu-background; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: $menu-submenu-background-alt; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: $menu-submenu-text; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: $menu-icon; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: $menu-submenu-focus-text; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: $menu-submenu-focus-text; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: $menu-icon; +} + + +/* Admin Bar: search */ + +#wpadminbar #adminbarsearch:before { + color: $menu-icon; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: $menu-text; + background: $adminbar-input-background; +} + +/* Admin Bar: my account */ + +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: $adminbar-avatar-frame; + background-color: $adminbar-avatar-frame; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: $menu-text; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: $menu-submenu-focus-text; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: $menu-submenu-text; +} + + +/* Pointers */ + +.wp-pointer .wp-pointer-content h3 { + background-color: $highlight-color; + border-color: darken( $highlight-color, 5% ); +} + +.wp-pointer .wp-pointer-content h3:before { + color: $highlight-color; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: $highlight-color; +} + + +/* Media */ + +.media-item .bar, +.media-progress-bar div { + background-color: $highlight-color; +} + +.details.attachment { + box-shadow: + inset 0 0 0 3px #fff, + inset 0 0 0 7px $highlight-color; +} + +.attachment.details .check { + background-color: $highlight-color; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px $highlight-color; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px $highlight-color; +} + + +/* Themes */ + +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: $highlight-color; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: $highlight-color; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: $menu-background; +} + +body.more-filters-opened .more-filters { + color: $menu-text; + background-color: $menu-background; +} + +body.more-filters-opened .more-filters:before { + color: $menu-text; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: $menu-highlight-background; + color: $menu-highlight-text; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: $menu-highlight-text; +} + +/* Widgets */ + +.widgets-chooser li.widgets-chooser-selected { + background-color: $menu-highlight-background; + color: $menu-highlight-text; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: $menu-highlight-text; +} + +/* Responsive Component */ + +div#wp-responsive-toggle a:before { + color: $menu-icon; +} + +.wp-responsive-open div#wp-responsive-toggle a { + // ToDo: make inset border + border-color: transparent; + background: $menu-highlight-background; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: $menu-submenu-background; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: $menu-icon; +} + +/* TinyMCE */ + +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: $highlight-color; +} diff --git a/backend/wp-admin/css/colors/_mixins.scss b/backend/wp-admin/css/colors/_mixins.scss new file mode 100644 index 0000000..7a764ab --- /dev/null +++ b/backend/wp-admin/css/colors/_mixins.scss @@ -0,0 +1,54 @@ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +@mixin button( $button-color, $text-color: #fff ) { + background: $button-color; + border-color: darken( $button-color, 10% ) darken( $button-color, 15% ) darken( $button-color, 15% ); + color: $text-color; + box-shadow: 0 1px 0 darken( $button-color, 15% ); + text-shadow: 0 -1px 1px darken( $button-color, 15% ), + 1px 0 1px darken( $button-color, 15% ), + 0 1px 1px darken( $button-color, 15% ), + -1px 0 1px darken( $button-color, 15% ); + + &:hover, + &:focus { + background: lighten( $button-color, 3% ); + border-color: darken( $button-color, 15% ); + color: $text-color; + box-shadow: 0 1px 0 darken( $button-color, 15% ); + } + + &:focus { + box-shadow: inset 0 1px 0 darken( $button-color, 10% ), + 0 0 2px 1px #33b3db; + } + + &:active, + &.active, + &.active:focus, + &.active:hover { + background: darken( $button-color, 10% ); + border-color: darken( $button-color, 15% ); + box-shadow: inset 0 2px 0 darken( $button-color, 15% ); + } + + &[disabled], + &:disabled, + &.button-primary-disabled, + &.disabled { + color: hsl( hue( $button-color ), 10%, 80% ) !important; + background: darken( $button-color, 8% ) !important; + border-color: darken( $button-color, 15% ) !important; + text-shadow: none !important; + } + + &.button-hero { + box-shadow: 0 2px 0 darken( $button-color, 15% ) !important; + &:active { + box-shadow: inset 0 3px 0 darken( $button-color, 15% ) !important; + } + } + +} diff --git a/backend/wp-admin/css/colors/_variables.scss b/backend/wp-admin/css/colors/_variables.scss new file mode 100644 index 0000000..c203f1b --- /dev/null +++ b/backend/wp-admin/css/colors/_variables.scss @@ -0,0 +1,58 @@ +// assign default value to all undefined variables + + +// core variables + +$text-color: #fff !default; +$base-color: #23282d !default; +$icon-color: hsl( hue( $base-color ), 7%, 95% ) !default; +$highlight-color: #0073aa !default; +$notification-color: #d54e21 !default; + + +// global + +$body-background: #f1f1f1 !default; + +$link: #0073aa !default; +$link-focus: lighten( $link, 10% ) !default; + +$button-color: $highlight-color !default; +$form-checked: $highlight-color !default; + + +// admin menu & admin-bar + +$menu-text: $text-color !default; +$menu-icon: $icon-color !default; +$menu-background: $base-color !default; + +$menu-highlight-text: $text-color !default; +$menu-highlight-icon: $text-color !default; +$menu-highlight-background: $highlight-color !default; + +$menu-current-text: $menu-highlight-text !default; +$menu-current-icon: $menu-highlight-icon !default; +$menu-current-background: $menu-highlight-background !default; + +$menu-submenu-text: mix( $base-color, $text-color, 30% ) !default; +$menu-submenu-background: darken( $base-color, 7% ) !default; +$menu-submenu-background-alt: desaturate( lighten( $menu-background, 7% ), 7% ) !default; + +$menu-submenu-focus-text: $highlight-color !default; +$menu-submenu-current-text: $text-color !default; + +$menu-bubble-text: $text-color !default; +$menu-bubble-background: $notification-color !default; +$menu-bubble-current-text: $text-color !default; +$menu-bubble-current-background: $menu-submenu-background !default; + +$menu-collapse-text: $menu-icon !default; +$menu-collapse-icon: $menu-icon !default; +$menu-collapse-focus-text: $text-color !default; +$menu-collapse-focus-icon: $menu-highlight-icon !default; + +$adminbar-avatar-frame: lighten( $menu-background, 7% ) !default; +$adminbar-input-background: lighten( $menu-background, 7% ) !default; + +$menu-customizer-text: mix( $base-color, $text-color, 40% ) !default; diff --git a/backend/wp-admin/css/colors/blue/colors-rtl.css b/backend/wp-admin/css/colors/blue/colors-rtl.css new file mode 100644 index 0000000..b5d44c5 --- /dev/null +++ b/backend/wp-admin/css/colors/blue/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #096484; +} + +input[type=radio]:checked:before { + background: #096484; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #e1a948; + border-color: #d39323 #bd831f #bd831f; + color: #fff; + box-shadow: 0 1px 0 #bd831f; + text-shadow: 0 -1px 1px #bd831f, -1px 0 1px #bd831f, 0 1px 1px #bd831f, 1px 0 1px #bd831f; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #e3af55; + border-color: #bd831f; + color: #fff; + box-shadow: 0 1px 0 #bd831f; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #d39323, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #d39323; + border-color: #bd831f; + box-shadow: inset 0 2px 0 #bd831f; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1cdc7 !important; + background: #db9925 !important; + border-color: #bd831f !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #bd831f !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #bd831f !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #52accc; +} + +.wp-core-ui .wp-ui-text-primary { + color: #52accc; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #096484; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #096484; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #e1a948; +} + +.wp-core-ui .wp-ui-text-notification { + color: #e1a948; +} + +.wp-core-ui .wp-ui-text-icon { + color: #e5f8ff; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #52accc; +} + +.view-switch a.current:before { + color: #52accc; +} + +.view-switch a:hover:before { + color: #e1a948; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #52accc; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #e5f8ff; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #096484; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #4796b3; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #4796b3; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #e2ecf1; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #e2ecf1; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #fff; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #fff; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #096484; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #e1a948; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #4796b3; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #e5f8ff; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #fff; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #52accc; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #e5f8ff; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #fff; + background: #4796b3; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #fff; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #4796b3; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #74b6ce; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #e2ecf1; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #e5f8ff; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #fff; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #fff; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #e5f8ff; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #e5f8ff; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #6eb9d4; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #6eb9d4; + background-color: #6eb9d4; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #e2ecf1; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #096484; + border-color: #07526c; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #096484; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #096484; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #096484; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #096484; +} + +.attachment.details .check { + background-color: #096484; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #096484; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #096484; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #096484; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #52accc; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #52accc; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #096484; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #096484; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #e5f8ff; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #096484; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #4796b3; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #e5f8ff; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #096484; +} diff --git a/backend/wp-admin/css/colors/blue/colors-rtl.min.css b/backend/wp-admin/css/colors/blue/colors-rtl.min.css new file mode 100644 index 0000000..abbbeec --- /dev/null +++ b/backend/wp-admin/css/colors/blue/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#096484}input[type=radio]:checked:before{background:#096484}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#e1a948;border-color:#d39323 #bd831f #bd831f;color:#fff;box-shadow:0 1px 0 #bd831f;text-shadow:0 -1px 1px #bd831f,-1px 0 1px #bd831f,0 1px 1px #bd831f,1px 0 1px #bd831f}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#e3af55;border-color:#bd831f;color:#fff;box-shadow:0 1px 0 #bd831f}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #d39323,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#d39323;border-color:#bd831f;box-shadow:inset 0 2px 0 #bd831f}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1cdc7!important;background:#db9925!important;border-color:#bd831f!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #bd831f!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #bd831f!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#52accc}.wp-core-ui .wp-ui-text-primary{color:#52accc}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#096484}.wp-core-ui .wp-ui-text-highlight{color:#096484}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#e1a948}.wp-core-ui .wp-ui-text-notification{color:#e1a948}.wp-core-ui .wp-ui-text-icon{color:#e5f8ff}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#52accc}.view-switch a.current:before{color:#52accc}.view-switch a:hover:before{color:#e1a948}#adminmenu,#adminmenuback,#adminmenuwrap{background:#52accc}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#e5f8ff}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#096484}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#4796b3}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#4796b3}#adminmenu .wp-submenu .wp-submenu-head{color:#e2ecf1}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#e2ecf1}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#fff}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#096484}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#e1a948}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#4796b3}#collapse-button{color:#e5f8ff}#collapse-button:focus,#collapse-button:hover{color:#fff}#wpadminbar{color:#fff;background:#52accc}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#e5f8ff}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#fff;background:#4796b3}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#fff}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#4796b3}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#74b6ce}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#e2ecf1}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#e5f8ff}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#fff}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#fff}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#e5f8ff}#wpadminbar #adminbarsearch:before{color:#e5f8ff}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#6eb9d4}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#6eb9d4;background-color:#6eb9d4}#wpadminbar #wp-admin-bar-user-info .display-name,#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info .username{color:#e2ecf1}.wp-pointer .wp-pointer-content h3{background-color:#096484;border-color:#07526c}.wp-pointer .wp-pointer-content h3:before{color:#096484}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#096484}.media-item .bar,.media-progress-bar div{background-color:#096484}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #096484}.attachment.details .check{background-color:#096484;box-shadow:0 0 0 1px #fff,0 0 0 2px #096484}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #096484}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#096484}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#096484}.theme-filter.current,.theme-section.current{border-bottom-color:#52accc}body.more-filters-opened .more-filters{color:#fff;background-color:#52accc}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#096484;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#096484;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#e5f8ff}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#096484}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#4796b3}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#e5f8ff}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#096484} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/blue/colors.css b/backend/wp-admin/css/colors/blue/colors.css new file mode 100644 index 0000000..06955e3 --- /dev/null +++ b/backend/wp-admin/css/colors/blue/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #096484; +} + +input[type=radio]:checked:before { + background: #096484; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #e1a948; + border-color: #d39323 #bd831f #bd831f; + color: #fff; + box-shadow: 0 1px 0 #bd831f; + text-shadow: 0 -1px 1px #bd831f, 1px 0 1px #bd831f, 0 1px 1px #bd831f, -1px 0 1px #bd831f; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #e3af55; + border-color: #bd831f; + color: #fff; + box-shadow: 0 1px 0 #bd831f; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #d39323, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #d39323; + border-color: #bd831f; + box-shadow: inset 0 2px 0 #bd831f; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1cdc7 !important; + background: #db9925 !important; + border-color: #bd831f !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #bd831f !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #bd831f !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #52accc; +} + +.wp-core-ui .wp-ui-text-primary { + color: #52accc; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #096484; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #096484; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #e1a948; +} + +.wp-core-ui .wp-ui-text-notification { + color: #e1a948; +} + +.wp-core-ui .wp-ui-text-icon { + color: #e5f8ff; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #52accc; +} + +.view-switch a.current:before { + color: #52accc; +} + +.view-switch a:hover:before { + color: #e1a948; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #52accc; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #e5f8ff; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #096484; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #4796b3; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #4796b3; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #e2ecf1; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #e2ecf1; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #fff; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #fff; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #096484; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #e1a948; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #4796b3; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #e5f8ff; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #fff; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #52accc; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #e5f8ff; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #fff; + background: #4796b3; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #fff; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #4796b3; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #74b6ce; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #e2ecf1; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #e5f8ff; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #fff; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #fff; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #e5f8ff; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #e5f8ff; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #6eb9d4; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #6eb9d4; + background-color: #6eb9d4; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #e2ecf1; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #096484; + border-color: #07526c; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #096484; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #096484; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #096484; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #096484; +} + +.attachment.details .check { + background-color: #096484; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #096484; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #096484; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #096484; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #096484; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #52accc; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #52accc; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #096484; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #096484; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #e5f8ff; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #096484; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #4796b3; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #e5f8ff; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #096484; +} diff --git a/backend/wp-admin/css/colors/blue/colors.min.css b/backend/wp-admin/css/colors/blue/colors.min.css new file mode 100644 index 0000000..792845d --- /dev/null +++ b/backend/wp-admin/css/colors/blue/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#096484}input[type=radio]:checked:before{background:#096484}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#e1a948;border-color:#d39323 #bd831f #bd831f;color:#fff;box-shadow:0 1px 0 #bd831f;text-shadow:0 -1px 1px #bd831f,1px 0 1px #bd831f,0 1px 1px #bd831f,-1px 0 1px #bd831f}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#e3af55;border-color:#bd831f;color:#fff;box-shadow:0 1px 0 #bd831f}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #d39323,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#d39323;border-color:#bd831f;box-shadow:inset 0 2px 0 #bd831f}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1cdc7!important;background:#db9925!important;border-color:#bd831f!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #bd831f!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #bd831f!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#52accc}.wp-core-ui .wp-ui-text-primary{color:#52accc}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#096484}.wp-core-ui .wp-ui-text-highlight{color:#096484}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#e1a948}.wp-core-ui .wp-ui-text-notification{color:#e1a948}.wp-core-ui .wp-ui-text-icon{color:#e5f8ff}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#52accc}.view-switch a.current:before{color:#52accc}.view-switch a:hover:before{color:#e1a948}#adminmenu,#adminmenuback,#adminmenuwrap{background:#52accc}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#e5f8ff}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#096484}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#4796b3}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#4796b3}#adminmenu .wp-submenu .wp-submenu-head{color:#e2ecf1}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#e2ecf1}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#fff}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#096484}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#e1a948}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#4796b3}#collapse-button{color:#e5f8ff}#collapse-button:focus,#collapse-button:hover{color:#fff}#wpadminbar{color:#fff;background:#52accc}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#e5f8ff}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#fff;background:#4796b3}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#fff}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#4796b3}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#74b6ce}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#e2ecf1}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#e5f8ff}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#fff}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#fff}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#e5f8ff}#wpadminbar #adminbarsearch:before{color:#e5f8ff}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#6eb9d4}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#6eb9d4;background-color:#6eb9d4}#wpadminbar #wp-admin-bar-user-info .display-name,#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info .username{color:#e2ecf1}.wp-pointer .wp-pointer-content h3{background-color:#096484;border-color:#07526c}.wp-pointer .wp-pointer-content h3:before{color:#096484}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#096484}.media-item .bar,.media-progress-bar div{background-color:#096484}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #096484}.attachment.details .check{background-color:#096484;box-shadow:0 0 0 1px #fff,0 0 0 2px #096484}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #096484}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#096484}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#096484}.theme-filter.current,.theme-section.current{border-bottom-color:#52accc}body.more-filters-opened .more-filters{color:#fff;background-color:#52accc}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#096484;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#096484;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#e5f8ff}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#096484}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#4796b3}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#e5f8ff}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#096484} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/blue/colors.scss b/backend/wp-admin/css/colors/blue/colors.scss new file mode 100644 index 0000000..b254d73 --- /dev/null +++ b/backend/wp-admin/css/colors/blue/colors.scss @@ -0,0 +1,11 @@ +$base-color: #52accc; +$icon-color: #e5f8ff; +$highlight-color: #096484; +$notification-color: #e1a948; +$button-color: #e1a948; + +$menu-submenu-text: #e2ecf1; +$menu-submenu-focus-text: #fff; +$menu-submenu-background: #4796b3; + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/colors/coffee/colors-rtl.css b/backend/wp-admin/css/colors/coffee/colors-rtl.css new file mode 100644 index 0000000..f393a49 --- /dev/null +++ b/backend/wp-admin/css/colors/coffee/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #59524c; +} + +input[type=radio]:checked:before { + background: #59524c; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #c7a589; + border-color: #b78b66 #ae7d55 #ae7d55; + color: #fff; + box-shadow: 0 1px 0 #ae7d55; + text-shadow: 0 -1px 1px #ae7d55, -1px 0 1px #ae7d55, 0 1px 1px #ae7d55, 1px 0 1px #ae7d55; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #ccad93; + border-color: #ae7d55; + color: #fff; + box-shadow: 0 1px 0 #ae7d55; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #b78b66, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #b78b66; + border-color: #ae7d55; + box-shadow: inset 0 2px 0 #ae7d55; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1ccc7 !important; + background: #ba906d !important; + border-color: #ae7d55 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ae7d55 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ae7d55 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #59524c; +} + +.wp-core-ui .wp-ui-text-primary { + color: #59524c; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #c7a589; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #c7a589; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #9ea476; +} + +.wp-core-ui .wp-ui-text-notification { + color: #9ea476; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f3f2f1; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #59524c; +} + +.view-switch a.current:before { + color: #59524c; +} + +.view-switch a:hover:before { + color: #9ea476; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #59524c; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f3f2f1; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #c7a589; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #46403c; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #46403c; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #cdcbc9; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #cdcbc9; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #c7a589; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #c7a589; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #c7a589; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #9ea476; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #46403c; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f3f2f1; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #c7a589; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #59524c; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f3f2f1; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #c7a589; + background: #46403c; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #c7a589; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #46403c; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #656463; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #cdcbc9; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f3f2f1; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #c7a589; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #c7a589; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f3f2f1; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f3f2f1; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #6c645c; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #6c645c; + background-color: #6c645c; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #c7a589; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #cdcbc9; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #c7a589; + border-color: #bf9878; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #c7a589; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #c7a589; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #c7a589; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #c7a589; +} + +.attachment.details .check { + background-color: #c7a589; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #c7a589; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #c7a589; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #c7a589; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #59524c; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #59524c; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #c7a589; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #c7a589; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f3f2f1; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #c7a589; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #46403c; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f3f2f1; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #c7a589; +} diff --git a/backend/wp-admin/css/colors/coffee/colors-rtl.min.css b/backend/wp-admin/css/colors/coffee/colors-rtl.min.css new file mode 100644 index 0000000..ab7b492 --- /dev/null +++ b/backend/wp-admin/css/colors/coffee/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#59524c}input[type=radio]:checked:before{background:#59524c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#c7a589;border-color:#b78b66 #ae7d55 #ae7d55;color:#fff;box-shadow:0 1px 0 #ae7d55;text-shadow:0 -1px 1px #ae7d55,-1px 0 1px #ae7d55,0 1px 1px #ae7d55,1px 0 1px #ae7d55}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#ccad93;border-color:#ae7d55;color:#fff;box-shadow:0 1px 0 #ae7d55}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #b78b66,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#b78b66;border-color:#ae7d55;box-shadow:inset 0 2px 0 #ae7d55}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1ccc7!important;background:#ba906d!important;border-color:#ae7d55!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ae7d55!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ae7d55!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#59524c}.wp-core-ui .wp-ui-text-primary{color:#59524c}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#c7a589}.wp-core-ui .wp-ui-text-highlight{color:#c7a589}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#9ea476}.wp-core-ui .wp-ui-text-notification{color:#9ea476}.wp-core-ui .wp-ui-text-icon{color:#f3f2f1}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#59524c}.view-switch a.current:before{color:#59524c}.view-switch a:hover:before{color:#9ea476}#adminmenu,#adminmenuback,#adminmenuwrap{background:#59524c}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f3f2f1}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#c7a589}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#46403c}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#46403c}#adminmenu .wp-submenu .wp-submenu-head{color:#cdcbc9}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#cdcbc9}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#c7a589}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#c7a589}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#c7a589}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#9ea476}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#46403c}#collapse-button{color:#f3f2f1}#collapse-button:focus,#collapse-button:hover{color:#c7a589}#wpadminbar{color:#fff;background:#59524c}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f3f2f1}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#c7a589;background:#46403c}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#c7a589}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#46403c}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#656463}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#cdcbc9}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f3f2f1}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#c7a589}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#c7a589}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f3f2f1}#wpadminbar #adminbarsearch:before{color:#f3f2f1}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#6c645c}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#6c645c;background-color:#6c645c}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#c7a589}#wpadminbar #wp-admin-bar-user-info .username{color:#cdcbc9}.wp-pointer .wp-pointer-content h3{background-color:#c7a589;border-color:#bf9878}.wp-pointer .wp-pointer-content h3:before{color:#c7a589}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#c7a589}.media-item .bar,.media-progress-bar div{background-color:#c7a589}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #c7a589}.attachment.details .check{background-color:#c7a589;box-shadow:0 0 0 1px #fff,0 0 0 2px #c7a589}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #c7a589}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#c7a589}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#c7a589}.theme-filter.current,.theme-section.current{border-bottom-color:#59524c}body.more-filters-opened .more-filters{color:#fff;background-color:#59524c}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#c7a589;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#c7a589;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f3f2f1}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#c7a589}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#46403c}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f3f2f1}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#c7a589} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/coffee/colors.css b/backend/wp-admin/css/colors/coffee/colors.css new file mode 100644 index 0000000..2fb55a2 --- /dev/null +++ b/backend/wp-admin/css/colors/coffee/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #59524c; +} + +input[type=radio]:checked:before { + background: #59524c; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #c7a589; + border-color: #b78b66 #ae7d55 #ae7d55; + color: #fff; + box-shadow: 0 1px 0 #ae7d55; + text-shadow: 0 -1px 1px #ae7d55, 1px 0 1px #ae7d55, 0 1px 1px #ae7d55, -1px 0 1px #ae7d55; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #ccad93; + border-color: #ae7d55; + color: #fff; + box-shadow: 0 1px 0 #ae7d55; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #b78b66, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #b78b66; + border-color: #ae7d55; + box-shadow: inset 0 2px 0 #ae7d55; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1ccc7 !important; + background: #ba906d !important; + border-color: #ae7d55 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ae7d55 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ae7d55 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #59524c; +} + +.wp-core-ui .wp-ui-text-primary { + color: #59524c; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #c7a589; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #c7a589; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #9ea476; +} + +.wp-core-ui .wp-ui-text-notification { + color: #9ea476; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f3f2f1; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #59524c; +} + +.view-switch a.current:before { + color: #59524c; +} + +.view-switch a:hover:before { + color: #9ea476; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #59524c; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f3f2f1; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #c7a589; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #46403c; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #46403c; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #cdcbc9; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #cdcbc9; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #c7a589; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #c7a589; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #c7a589; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #9ea476; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #46403c; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f3f2f1; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #c7a589; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #59524c; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f3f2f1; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #c7a589; + background: #46403c; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #c7a589; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #46403c; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #656463; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #cdcbc9; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f3f2f1; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #c7a589; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #c7a589; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f3f2f1; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f3f2f1; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #6c645c; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #6c645c; + background-color: #6c645c; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #c7a589; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #cdcbc9; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #c7a589; + border-color: #bf9878; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #c7a589; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #c7a589; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #c7a589; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #c7a589; +} + +.attachment.details .check { + background-color: #c7a589; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #c7a589; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #c7a589; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #c7a589; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #c7a589; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #59524c; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #59524c; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #c7a589; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #c7a589; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f3f2f1; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #c7a589; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #46403c; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f3f2f1; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #c7a589; +} diff --git a/backend/wp-admin/css/colors/coffee/colors.min.css b/backend/wp-admin/css/colors/coffee/colors.min.css new file mode 100644 index 0000000..8de31ca --- /dev/null +++ b/backend/wp-admin/css/colors/coffee/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#59524c}input[type=radio]:checked:before{background:#59524c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#c7a589;border-color:#b78b66 #ae7d55 #ae7d55;color:#fff;box-shadow:0 1px 0 #ae7d55;text-shadow:0 -1px 1px #ae7d55,1px 0 1px #ae7d55,0 1px 1px #ae7d55,-1px 0 1px #ae7d55}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#ccad93;border-color:#ae7d55;color:#fff;box-shadow:0 1px 0 #ae7d55}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #b78b66,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#b78b66;border-color:#ae7d55;box-shadow:inset 0 2px 0 #ae7d55}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1ccc7!important;background:#ba906d!important;border-color:#ae7d55!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ae7d55!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ae7d55!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#59524c}.wp-core-ui .wp-ui-text-primary{color:#59524c}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#c7a589}.wp-core-ui .wp-ui-text-highlight{color:#c7a589}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#9ea476}.wp-core-ui .wp-ui-text-notification{color:#9ea476}.wp-core-ui .wp-ui-text-icon{color:#f3f2f1}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#59524c}.view-switch a.current:before{color:#59524c}.view-switch a:hover:before{color:#9ea476}#adminmenu,#adminmenuback,#adminmenuwrap{background:#59524c}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f3f2f1}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#c7a589}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#46403c}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#46403c}#adminmenu .wp-submenu .wp-submenu-head{color:#cdcbc9}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#cdcbc9}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#c7a589}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#c7a589}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#c7a589}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#9ea476}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#46403c}#collapse-button{color:#f3f2f1}#collapse-button:focus,#collapse-button:hover{color:#c7a589}#wpadminbar{color:#fff;background:#59524c}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f3f2f1}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#c7a589;background:#46403c}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#c7a589}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#46403c}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#656463}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#cdcbc9}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f3f2f1}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#c7a589}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#c7a589}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f3f2f1}#wpadminbar #adminbarsearch:before{color:#f3f2f1}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#6c645c}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#6c645c;background-color:#6c645c}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#c7a589}#wpadminbar #wp-admin-bar-user-info .username{color:#cdcbc9}.wp-pointer .wp-pointer-content h3{background-color:#c7a589;border-color:#bf9878}.wp-pointer .wp-pointer-content h3:before{color:#c7a589}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#c7a589}.media-item .bar,.media-progress-bar div{background-color:#c7a589}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #c7a589}.attachment.details .check{background-color:#c7a589;box-shadow:0 0 0 1px #fff,0 0 0 2px #c7a589}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #c7a589}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#c7a589}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#c7a589}.theme-filter.current,.theme-section.current{border-bottom-color:#59524c}body.more-filters-opened .more-filters{color:#fff;background-color:#59524c}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#c7a589;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#c7a589;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f3f2f1}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#c7a589}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#46403c}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f3f2f1}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#c7a589} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/coffee/colors.scss b/backend/wp-admin/css/colors/coffee/colors.scss new file mode 100644 index 0000000..49bee9b --- /dev/null +++ b/backend/wp-admin/css/colors/coffee/colors.scss @@ -0,0 +1,7 @@ +$base-color: #59524c; +$highlight-color: #c7a589; +$notification-color: #9ea476; + +$form-checked: $base-color; + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/colors/ectoplasm/colors-rtl.css b/backend/wp-admin/css/colors/ectoplasm/colors-rtl.css new file mode 100644 index 0000000..0f8fdd3 --- /dev/null +++ b/backend/wp-admin/css/colors/ectoplasm/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #523f6d; +} + +input[type=radio]:checked:before { + background: #523f6d; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #a3b745; + border-color: #829237 #727f30 #727f30; + color: #fff; + box-shadow: 0 1px 0 #727f30; + text-shadow: 0 -1px 1px #727f30, -1px 0 1px #727f30, 0 1px 1px #727f30, 1px 0 1px #727f30; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #a9bd4f; + border-color: #727f30; + color: #fff; + box-shadow: 0 1px 0 #727f30; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #829237, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #829237; + border-color: #727f30; + box-shadow: inset 0 2px 0 #727f30; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #cfd1c7 !important; + background: #89993a !important; + border-color: #727f30 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #727f30 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #727f30 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #523f6d; +} + +.wp-core-ui .wp-ui-text-primary { + color: #523f6d; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #a3b745; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #a3b745; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #d46f15; +} + +.wp-core-ui .wp-ui-text-notification { + color: #d46f15; +} + +.wp-core-ui .wp-ui-text-icon { + color: #ece6f6; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #523f6d; +} + +.view-switch a.current:before { + color: #523f6d; +} + +.view-switch a:hover:before { + color: #d46f15; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #523f6d; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #ece6f6; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #a3b745; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #413256; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #413256; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #cbc5d3; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #cbc5d3; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #a3b745; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #a3b745; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #a3b745; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #d46f15; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #413256; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #ece6f6; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #a3b745; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #523f6d; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #ece6f6; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #a3b745; + background: #413256; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #a3b745; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #413256; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #64537c; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #cbc5d3; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #ece6f6; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #a3b745; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #a3b745; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #ece6f6; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #ece6f6; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #634c84; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #634c84; + background-color: #634c84; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #a3b745; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #cbc5d3; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #a3b745; + border-color: #93a43e; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #a3b745; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #a3b745; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #a3b745; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #a3b745; +} + +.attachment.details .check { + background-color: #a3b745; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #a3b745; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #a3b745; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #a3b745; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #523f6d; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #523f6d; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #a3b745; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #a3b745; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #ece6f6; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #a3b745; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #413256; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #ece6f6; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #a3b745; +} diff --git a/backend/wp-admin/css/colors/ectoplasm/colors-rtl.min.css b/backend/wp-admin/css/colors/ectoplasm/colors-rtl.min.css new file mode 100644 index 0000000..e57241f --- /dev/null +++ b/backend/wp-admin/css/colors/ectoplasm/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#523f6d}input[type=radio]:checked:before{background:#523f6d}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#a3b745;border-color:#829237 #727f30 #727f30;color:#fff;box-shadow:0 1px 0 #727f30;text-shadow:0 -1px 1px #727f30,-1px 0 1px #727f30,0 1px 1px #727f30,1px 0 1px #727f30}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#a9bd4f;border-color:#727f30;color:#fff;box-shadow:0 1px 0 #727f30}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #829237,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#829237;border-color:#727f30;box-shadow:inset 0 2px 0 #727f30}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#cfd1c7!important;background:#89993a!important;border-color:#727f30!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #727f30!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #727f30!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#523f6d}.wp-core-ui .wp-ui-text-primary{color:#523f6d}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#a3b745}.wp-core-ui .wp-ui-text-highlight{color:#a3b745}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#d46f15}.wp-core-ui .wp-ui-text-notification{color:#d46f15}.wp-core-ui .wp-ui-text-icon{color:#ece6f6}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#523f6d}.view-switch a.current:before{color:#523f6d}.view-switch a:hover:before{color:#d46f15}#adminmenu,#adminmenuback,#adminmenuwrap{background:#523f6d}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#ece6f6}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#a3b745}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#413256}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#413256}#adminmenu .wp-submenu .wp-submenu-head{color:#cbc5d3}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#cbc5d3}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#a3b745}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#a3b745}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#a3b745}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#d46f15}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#413256}#collapse-button{color:#ece6f6}#collapse-button:focus,#collapse-button:hover{color:#a3b745}#wpadminbar{color:#fff;background:#523f6d}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#ece6f6}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#a3b745;background:#413256}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#a3b745}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#413256}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#64537c}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#cbc5d3}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#ece6f6}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#a3b745}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#a3b745}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#ece6f6}#wpadminbar #adminbarsearch:before{color:#ece6f6}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#634c84}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#634c84;background-color:#634c84}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#a3b745}#wpadminbar #wp-admin-bar-user-info .username{color:#cbc5d3}.wp-pointer .wp-pointer-content h3{background-color:#a3b745;border-color:#93a43e}.wp-pointer .wp-pointer-content h3:before{color:#a3b745}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#a3b745}.media-item .bar,.media-progress-bar div{background-color:#a3b745}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #a3b745}.attachment.details .check{background-color:#a3b745;box-shadow:0 0 0 1px #fff,0 0 0 2px #a3b745}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #a3b745}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#a3b745}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#a3b745}.theme-filter.current,.theme-section.current{border-bottom-color:#523f6d}body.more-filters-opened .more-filters{color:#fff;background-color:#523f6d}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#a3b745;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#a3b745;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#ece6f6}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#a3b745}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#413256}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#ece6f6}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#a3b745} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/ectoplasm/colors.css b/backend/wp-admin/css/colors/ectoplasm/colors.css new file mode 100644 index 0000000..d2e8f40 --- /dev/null +++ b/backend/wp-admin/css/colors/ectoplasm/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #523f6d; +} + +input[type=radio]:checked:before { + background: #523f6d; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #a3b745; + border-color: #829237 #727f30 #727f30; + color: #fff; + box-shadow: 0 1px 0 #727f30; + text-shadow: 0 -1px 1px #727f30, 1px 0 1px #727f30, 0 1px 1px #727f30, -1px 0 1px #727f30; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #a9bd4f; + border-color: #727f30; + color: #fff; + box-shadow: 0 1px 0 #727f30; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #829237, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #829237; + border-color: #727f30; + box-shadow: inset 0 2px 0 #727f30; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #cfd1c7 !important; + background: #89993a !important; + border-color: #727f30 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #727f30 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #727f30 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #523f6d; +} + +.wp-core-ui .wp-ui-text-primary { + color: #523f6d; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #a3b745; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #a3b745; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #d46f15; +} + +.wp-core-ui .wp-ui-text-notification { + color: #d46f15; +} + +.wp-core-ui .wp-ui-text-icon { + color: #ece6f6; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #523f6d; +} + +.view-switch a.current:before { + color: #523f6d; +} + +.view-switch a:hover:before { + color: #d46f15; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #523f6d; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #ece6f6; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #a3b745; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #413256; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #413256; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #cbc5d3; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #cbc5d3; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #a3b745; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #a3b745; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #a3b745; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #d46f15; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #413256; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #ece6f6; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #a3b745; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #523f6d; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #ece6f6; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #a3b745; + background: #413256; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #a3b745; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #413256; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #64537c; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #cbc5d3; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #ece6f6; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #a3b745; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #a3b745; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #ece6f6; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #ece6f6; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #634c84; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #634c84; + background-color: #634c84; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #a3b745; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #cbc5d3; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #a3b745; + border-color: #93a43e; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #a3b745; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #a3b745; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #a3b745; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #a3b745; +} + +.attachment.details .check { + background-color: #a3b745; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #a3b745; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #a3b745; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #a3b745; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #a3b745; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #523f6d; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #523f6d; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #a3b745; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #a3b745; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #ece6f6; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #a3b745; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #413256; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #ece6f6; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #a3b745; +} diff --git a/backend/wp-admin/css/colors/ectoplasm/colors.min.css b/backend/wp-admin/css/colors/ectoplasm/colors.min.css new file mode 100644 index 0000000..389e097 --- /dev/null +++ b/backend/wp-admin/css/colors/ectoplasm/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#523f6d}input[type=radio]:checked:before{background:#523f6d}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#a3b745;border-color:#829237 #727f30 #727f30;color:#fff;box-shadow:0 1px 0 #727f30;text-shadow:0 -1px 1px #727f30,1px 0 1px #727f30,0 1px 1px #727f30,-1px 0 1px #727f30}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#a9bd4f;border-color:#727f30;color:#fff;box-shadow:0 1px 0 #727f30}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #829237,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#829237;border-color:#727f30;box-shadow:inset 0 2px 0 #727f30}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#cfd1c7!important;background:#89993a!important;border-color:#727f30!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #727f30!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #727f30!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#523f6d}.wp-core-ui .wp-ui-text-primary{color:#523f6d}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#a3b745}.wp-core-ui .wp-ui-text-highlight{color:#a3b745}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#d46f15}.wp-core-ui .wp-ui-text-notification{color:#d46f15}.wp-core-ui .wp-ui-text-icon{color:#ece6f6}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#523f6d}.view-switch a.current:before{color:#523f6d}.view-switch a:hover:before{color:#d46f15}#adminmenu,#adminmenuback,#adminmenuwrap{background:#523f6d}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#ece6f6}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#a3b745}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#413256}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#413256}#adminmenu .wp-submenu .wp-submenu-head{color:#cbc5d3}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#cbc5d3}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#a3b745}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#a3b745}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#a3b745}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#d46f15}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#413256}#collapse-button{color:#ece6f6}#collapse-button:focus,#collapse-button:hover{color:#a3b745}#wpadminbar{color:#fff;background:#523f6d}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#ece6f6}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#a3b745;background:#413256}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#a3b745}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#413256}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#64537c}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#cbc5d3}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#ece6f6}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#a3b745}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#a3b745}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#ece6f6}#wpadminbar #adminbarsearch:before{color:#ece6f6}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#634c84}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#634c84;background-color:#634c84}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#a3b745}#wpadminbar #wp-admin-bar-user-info .username{color:#cbc5d3}.wp-pointer .wp-pointer-content h3{background-color:#a3b745;border-color:#93a43e}.wp-pointer .wp-pointer-content h3:before{color:#a3b745}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#a3b745}.media-item .bar,.media-progress-bar div{background-color:#a3b745}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #a3b745}.attachment.details .check{background-color:#a3b745;box-shadow:0 0 0 1px #fff,0 0 0 2px #a3b745}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #a3b745}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#a3b745}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#a3b745}.theme-filter.current,.theme-section.current{border-bottom-color:#523f6d}body.more-filters-opened .more-filters{color:#fff;background-color:#523f6d}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#a3b745;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#a3b745;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#ece6f6}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#a3b745}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#413256}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#ece6f6}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#a3b745} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/ectoplasm/colors.scss b/backend/wp-admin/css/colors/ectoplasm/colors.scss new file mode 100644 index 0000000..8d14570 --- /dev/null +++ b/backend/wp-admin/css/colors/ectoplasm/colors.scss @@ -0,0 +1,8 @@ +$base-color: #523f6d; +$icon-color: #ece6f6; +$highlight-color: #a3b745; +$notification-color: #d46f15; + +$form-checked: $base-color; + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/colors/light/colors-rtl.css b/backend/wp-admin/css/colors/light/colors-rtl.css new file mode 100644 index 0000000..e474d49 --- /dev/null +++ b/backend/wp-admin/css/colors/light/colors-rtl.css @@ -0,0 +1,520 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f5f5f5; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #04a4cc; +} + +input[type=radio]:checked:before { + background: #04a4cc; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #04a4cc; + border-color: #037c9a #036881 #036881; + color: #fff; + box-shadow: 0 1px 0 #036881; + text-shadow: 0 -1px 1px #036881, -1px 0 1px #036881, 0 1px 1px #036881, 1px 0 1px #036881; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #04b0db; + border-color: #036881; + color: #fff; + box-shadow: 0 1px 0 #036881; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #037c9a, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #037c9a; + border-color: #036881; + box-shadow: inset 0 2px 0 #036881; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #c7cfd1 !important; + background: #0384a4 !important; + border-color: #036881 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #036881 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #036881 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #333; + background-color: #e5e5e5; +} + +.wp-core-ui .wp-ui-text-primary { + color: #e5e5e5; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #888; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #888; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #d64e07; +} + +.wp-core-ui .wp-ui-text-notification { + color: #d64e07; +} + +.wp-core-ui .wp-ui-text-icon { + color: #999; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #333; + background-color: #e5e5e5; +} + +.view-switch a.current:before { + color: #e5e5e5; +} + +.view-switch a:hover:before { + color: #d64e07; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #e5e5e5; +} + +#adminmenu a { + color: #333; +} + +#adminmenu div.wp-menu-image:before { + color: #999; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #888; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #ccc; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f5f5f5; + border-bottom-color: #f5f5f5; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #fff; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #fff; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #686868; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #686868; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #04a4cc; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #333; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #04a4cc; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f5f5f5; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #888; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #ccc; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #d64e07; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #333; + background: #fff; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #777; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #04a4cc; +} + +/* Admin Bar */ +#wpadminbar { + color: #333; + background: #e5e5e5; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #333; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #999; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #04a4cc; + background: #fff; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #04a4cc; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #ccc; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #fff; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #f7f7f7; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #686868; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #999; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #04a4cc; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #04a4cc; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #999; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #999; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #333; + background: #f7f7f7; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #f7f7f7; + background-color: #f7f7f7; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #333; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #04a4cc; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #686868; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #04a4cc; + border-color: #0490b3; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #04a4cc; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #04a4cc; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #04a4cc; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #04a4cc; +} + +.attachment.details .check { + background-color: #04a4cc; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #04a4cc; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #04a4cc; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #04a4cc; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #e5e5e5; +} + +body.more-filters-opened .more-filters { + color: #333; + background-color: #e5e5e5; +} + +body.more-filters-opened .more-filters:before { + color: #333; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #888; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #888; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #999; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #888; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #fff; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #999; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #04a4cc; +} + +/* temporary fix for admin-bar hover color */ +#wpadminbar .ab-top-menu > li:hover > .ab-item, +#wpadminbar .ab-top-menu > li.hover > .ab-item, +#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, +#wpadminbar .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #333; +} + +/* Override the theme filter highlight color for this scheme */ +.theme-section.current, +.theme-filter.current { + border-bottom-color: #04a4cc; +} diff --git a/backend/wp-admin/css/colors/light/colors-rtl.min.css b/backend/wp-admin/css/colors/light/colors-rtl.min.css new file mode 100644 index 0000000..8bb8a5e --- /dev/null +++ b/backend/wp-admin/css/colors/light/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f5f5f5}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#04a4cc}input[type=radio]:checked:before{background:#04a4cc}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#04a4cc;border-color:#037c9a #036881 #036881;color:#fff;box-shadow:0 1px 0 #036881;text-shadow:0 -1px 1px #036881,-1px 0 1px #036881,0 1px 1px #036881,1px 0 1px #036881}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#04b0db;border-color:#036881;color:#fff;box-shadow:0 1px 0 #036881}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #037c9a,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#037c9a;border-color:#036881;box-shadow:inset 0 2px 0 #036881}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#c7cfd1!important;background:#0384a4!important;border-color:#036881!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #036881!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #036881!important}.wp-core-ui .wp-ui-primary{color:#333;background-color:#e5e5e5}.wp-core-ui .wp-ui-text-primary{color:#e5e5e5}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#888}.wp-core-ui .wp-ui-text-highlight{color:#888}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#d64e07}.wp-core-ui .wp-ui-text-notification{color:#d64e07}.wp-core-ui .wp-ui-text-icon{color:#999}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#333;background-color:#e5e5e5}.view-switch a.current:before{color:#e5e5e5}.view-switch a:hover:before{color:#d64e07}#adminmenu,#adminmenuback,#adminmenuwrap{background:#e5e5e5}#adminmenu a{color:#333}#adminmenu div.wp-menu-image:before{color:#999}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#888}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#ccc}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f5f5f5;border-bottom-color:#f5f5f5}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#fff}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#fff}#adminmenu .wp-submenu .wp-submenu-head{color:#686868}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#686868}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#04a4cc}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#333}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#04a4cc}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f5f5f5}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#888}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#ccc}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#d64e07}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#333;background:#fff}#collapse-button{color:#777}#collapse-button:focus,#collapse-button:hover{color:#04a4cc}#wpadminbar{color:#333;background:#e5e5e5}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#333}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#999}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#04a4cc;background:#fff}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#04a4cc}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#ccc}#wpadminbar .menupop .ab-sub-wrapper{background:#fff}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#f7f7f7}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#686868}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#999}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#04a4cc}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#04a4cc}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#999}#wpadminbar #adminbarsearch:before{color:#999}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#333;background:#f7f7f7}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#f7f7f7;background-color:#f7f7f7}#wpadminbar #wp-admin-bar-user-info .display-name{color:#333}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#04a4cc}#wpadminbar #wp-admin-bar-user-info .username{color:#686868}.wp-pointer .wp-pointer-content h3{background-color:#04a4cc;border-color:#0490b3}.wp-pointer .wp-pointer-content h3:before{color:#04a4cc}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#04a4cc}.media-item .bar,.media-progress-bar div{background-color:#04a4cc}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #04a4cc}.attachment.details .check{background-color:#04a4cc;box-shadow:0 0 0 1px #fff,0 0 0 2px #04a4cc}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #04a4cc}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#04a4cc}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#04a4cc}body.more-filters-opened .more-filters{color:#333;background-color:#e5e5e5}body.more-filters-opened .more-filters:before{color:#333}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#888;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#888;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#999}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#888}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#fff}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#999}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#04a4cc}#wpadminbar .ab-top-menu>li.hover>.ab-item,#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar .ab-top-menu>li:hover>.ab-item,#wpadminbar .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default li:hover span.ab-label,#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary li.hover span.ab-label{color:#333}.theme-filter.current,.theme-section.current{border-bottom-color:#04a4cc} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/light/colors.css b/backend/wp-admin/css/colors/light/colors.css new file mode 100644 index 0000000..92d974f --- /dev/null +++ b/backend/wp-admin/css/colors/light/colors.css @@ -0,0 +1,520 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f5f5f5; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #04a4cc; +} + +input[type=radio]:checked:before { + background: #04a4cc; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #04a4cc; + border-color: #037c9a #036881 #036881; + color: #fff; + box-shadow: 0 1px 0 #036881; + text-shadow: 0 -1px 1px #036881, 1px 0 1px #036881, 0 1px 1px #036881, -1px 0 1px #036881; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #04b0db; + border-color: #036881; + color: #fff; + box-shadow: 0 1px 0 #036881; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #037c9a, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #037c9a; + border-color: #036881; + box-shadow: inset 0 2px 0 #036881; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #c7cfd1 !important; + background: #0384a4 !important; + border-color: #036881 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #036881 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #036881 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #333; + background-color: #e5e5e5; +} + +.wp-core-ui .wp-ui-text-primary { + color: #e5e5e5; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #888; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #888; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #d64e07; +} + +.wp-core-ui .wp-ui-text-notification { + color: #d64e07; +} + +.wp-core-ui .wp-ui-text-icon { + color: #999; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #333; + background-color: #e5e5e5; +} + +.view-switch a.current:before { + color: #e5e5e5; +} + +.view-switch a:hover:before { + color: #d64e07; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #e5e5e5; +} + +#adminmenu a { + color: #333; +} + +#adminmenu div.wp-menu-image:before { + color: #999; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #888; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #ccc; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f5f5f5; + border-bottom-color: #f5f5f5; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #fff; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #fff; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #686868; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #686868; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #04a4cc; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #333; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #04a4cc; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f5f5f5; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #888; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #ccc; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #d64e07; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #333; + background: #fff; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #777; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #04a4cc; +} + +/* Admin Bar */ +#wpadminbar { + color: #333; + background: #e5e5e5; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #333; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #999; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #04a4cc; + background: #fff; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #04a4cc; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #ccc; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #fff; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #f7f7f7; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #686868; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #999; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #04a4cc; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #04a4cc; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #999; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #999; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #333; + background: #f7f7f7; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #f7f7f7; + background-color: #f7f7f7; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #333; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #04a4cc; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #686868; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #04a4cc; + border-color: #0490b3; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #04a4cc; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #04a4cc; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #04a4cc; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #04a4cc; +} + +.attachment.details .check { + background-color: #04a4cc; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #04a4cc; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #04a4cc; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #04a4cc; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #04a4cc; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #e5e5e5; +} + +body.more-filters-opened .more-filters { + color: #333; + background-color: #e5e5e5; +} + +body.more-filters-opened .more-filters:before { + color: #333; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #888; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #888; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #999; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #888; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #fff; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #999; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #04a4cc; +} + +/* temporary fix for admin-bar hover color */ +#wpadminbar .ab-top-menu > li:hover > .ab-item, +#wpadminbar .ab-top-menu > li.hover > .ab-item, +#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, +#wpadminbar .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #333; +} + +/* Override the theme filter highlight color for this scheme */ +.theme-section.current, +.theme-filter.current { + border-bottom-color: #04a4cc; +} diff --git a/backend/wp-admin/css/colors/light/colors.min.css b/backend/wp-admin/css/colors/light/colors.min.css new file mode 100644 index 0000000..31d0fd5 --- /dev/null +++ b/backend/wp-admin/css/colors/light/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f5f5f5}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#04a4cc}input[type=radio]:checked:before{background:#04a4cc}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#04a4cc;border-color:#037c9a #036881 #036881;color:#fff;box-shadow:0 1px 0 #036881;text-shadow:0 -1px 1px #036881,1px 0 1px #036881,0 1px 1px #036881,-1px 0 1px #036881}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#04b0db;border-color:#036881;color:#fff;box-shadow:0 1px 0 #036881}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #037c9a,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#037c9a;border-color:#036881;box-shadow:inset 0 2px 0 #036881}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#c7cfd1!important;background:#0384a4!important;border-color:#036881!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #036881!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #036881!important}.wp-core-ui .wp-ui-primary{color:#333;background-color:#e5e5e5}.wp-core-ui .wp-ui-text-primary{color:#e5e5e5}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#888}.wp-core-ui .wp-ui-text-highlight{color:#888}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#d64e07}.wp-core-ui .wp-ui-text-notification{color:#d64e07}.wp-core-ui .wp-ui-text-icon{color:#999}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#333;background-color:#e5e5e5}.view-switch a.current:before{color:#e5e5e5}.view-switch a:hover:before{color:#d64e07}#adminmenu,#adminmenuback,#adminmenuwrap{background:#e5e5e5}#adminmenu a{color:#333}#adminmenu div.wp-menu-image:before{color:#999}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#888}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#ccc}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f5f5f5;border-bottom-color:#f5f5f5}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#fff}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#fff}#adminmenu .wp-submenu .wp-submenu-head{color:#686868}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#686868}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#04a4cc}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#333}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#04a4cc}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f5f5f5}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#888}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#ccc}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#d64e07}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#333;background:#fff}#collapse-button{color:#777}#collapse-button:focus,#collapse-button:hover{color:#04a4cc}#wpadminbar{color:#333;background:#e5e5e5}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#333}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#999}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#04a4cc;background:#fff}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#04a4cc}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#ccc}#wpadminbar .menupop .ab-sub-wrapper{background:#fff}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#f7f7f7}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#686868}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#999}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#04a4cc}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#04a4cc}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#999}#wpadminbar #adminbarsearch:before{color:#999}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#333;background:#f7f7f7}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#f7f7f7;background-color:#f7f7f7}#wpadminbar #wp-admin-bar-user-info .display-name{color:#333}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#04a4cc}#wpadminbar #wp-admin-bar-user-info .username{color:#686868}.wp-pointer .wp-pointer-content h3{background-color:#04a4cc;border-color:#0490b3}.wp-pointer .wp-pointer-content h3:before{color:#04a4cc}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#04a4cc}.media-item .bar,.media-progress-bar div{background-color:#04a4cc}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #04a4cc}.attachment.details .check{background-color:#04a4cc;box-shadow:0 0 0 1px #fff,0 0 0 2px #04a4cc}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #04a4cc}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#04a4cc}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#04a4cc}body.more-filters-opened .more-filters{color:#333;background-color:#e5e5e5}body.more-filters-opened .more-filters:before{color:#333}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#888;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#888;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#999}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#888}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#fff}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#999}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#04a4cc}#wpadminbar .ab-top-menu>li.hover>.ab-item,#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar .ab-top-menu>li:hover>.ab-item,#wpadminbar .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default li:hover span.ab-label,#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary li.hover span.ab-label{color:#333}.theme-filter.current,.theme-section.current{border-bottom-color:#04a4cc} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/light/colors.scss b/backend/wp-admin/css/colors/light/colors.scss new file mode 100644 index 0000000..ab4230b --- /dev/null +++ b/backend/wp-admin/css/colors/light/colors.scss @@ -0,0 +1,38 @@ +$base-color: #e5e5e5; +$icon-color: #999; +$text-color: #333; +$highlight-color: #04a4cc; +$notification-color: #d64e07; + +$body-background: #f5f5f5; + +$menu-highlight-text: #fff; +$menu-highlight-icon: #ccc; +$menu-highlight-background: #888; + +$menu-bubble-text: #fff; +$menu-avatar-frame: #aaa; +$menu-submenu-background: #fff; + +$menu-collapse-text: #777; +$menu-collapse-focus-icon: #555; + +@import "../_admin.scss"; + +/* temporary fix for admin-bar hover color */ +#wpadminbar .ab-top-menu > li:hover > .ab-item, +#wpadminbar .ab-top-menu > li.hover > .ab-item, +#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default li:hover span.ab-label, +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary li.hover span.ab-label, +#wpadminbar .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: $text-color; +} + +/* Override the theme filter highlight color for this scheme */ +.theme-section.current, +.theme-filter.current { + border-bottom-color: $highlight-color; +} diff --git a/backend/wp-admin/css/colors/midnight/colors-rtl.css b/backend/wp-admin/css/colors/midnight/colors-rtl.css new file mode 100644 index 0000000..933e5d5 --- /dev/null +++ b/backend/wp-admin/css/colors/midnight/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #e14d43; +} + +input[type=radio]:checked:before { + background: #e14d43; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #e14d43; + border-color: #d02c21 #ba281e #ba281e; + color: #fff; + box-shadow: 0 1px 0 #ba281e; + text-shadow: 0 -1px 1px #ba281e, -1px 0 1px #ba281e, 0 1px 1px #ba281e, 1px 0 1px #ba281e; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #e35950; + border-color: #ba281e; + color: #fff; + box-shadow: 0 1px 0 #ba281e; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #d02c21, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #d02c21; + border-color: #ba281e; + box-shadow: inset 0 2px 0 #ba281e; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1c8c7 !important; + background: #d92e23 !important; + border-color: #ba281e !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ba281e !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ba281e !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #363b3f; +} + +.wp-core-ui .wp-ui-text-primary { + color: #363b3f; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #e14d43; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #e14d43; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #69a8bb; +} + +.wp-core-ui .wp-ui-text-notification { + color: #69a8bb; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f1f2f3; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #363b3f; +} + +.view-switch a.current:before { + color: #363b3f; +} + +.view-switch a:hover:before { + color: #69a8bb; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #363b3f; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f1f2f3; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #e14d43; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #26292c; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #26292c; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #c3c4c5; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #c3c4c5; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #e14d43; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #e14d43; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #e14d43; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #69a8bb; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #26292c; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f1f2f3; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #e14d43; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #363b3f; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f1f2f3; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #e14d43; + background: #26292c; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #e14d43; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #26292c; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #4c4c4d; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #c3c4c5; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f1f2f3; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #e14d43; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #e14d43; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f1f2f3; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f1f2f3; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #464d52; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #464d52; + background-color: #464d52; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #e14d43; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #c3c4c5; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #e14d43; + border-color: #dd382d; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #e14d43; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #e14d43; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #e14d43; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #e14d43; +} + +.attachment.details .check { + background-color: #e14d43; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #e14d43; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #e14d43; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #e14d43; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #363b3f; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #363b3f; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #e14d43; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #e14d43; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f1f2f3; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #e14d43; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #26292c; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f1f2f3; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #e14d43; +} diff --git a/backend/wp-admin/css/colors/midnight/colors-rtl.min.css b/backend/wp-admin/css/colors/midnight/colors-rtl.min.css new file mode 100644 index 0000000..cb3046a --- /dev/null +++ b/backend/wp-admin/css/colors/midnight/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#e14d43}input[type=radio]:checked:before{background:#e14d43}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#e14d43;border-color:#d02c21 #ba281e #ba281e;color:#fff;box-shadow:0 1px 0 #ba281e;text-shadow:0 -1px 1px #ba281e,-1px 0 1px #ba281e,0 1px 1px #ba281e,1px 0 1px #ba281e}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#e35950;border-color:#ba281e;color:#fff;box-shadow:0 1px 0 #ba281e}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #d02c21,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#d02c21;border-color:#ba281e;box-shadow:inset 0 2px 0 #ba281e}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1c8c7!important;background:#d92e23!important;border-color:#ba281e!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ba281e!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ba281e!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#363b3f}.wp-core-ui .wp-ui-text-primary{color:#363b3f}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#e14d43}.wp-core-ui .wp-ui-text-highlight{color:#e14d43}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#69a8bb}.wp-core-ui .wp-ui-text-notification{color:#69a8bb}.wp-core-ui .wp-ui-text-icon{color:#f1f2f3}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#363b3f}.view-switch a.current:before{color:#363b3f}.view-switch a:hover:before{color:#69a8bb}#adminmenu,#adminmenuback,#adminmenuwrap{background:#363b3f}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f1f2f3}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#e14d43}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#26292c}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#26292c}#adminmenu .wp-submenu .wp-submenu-head{color:#c3c4c5}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#c3c4c5}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#e14d43}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#e14d43}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#e14d43}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#69a8bb}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#26292c}#collapse-button{color:#f1f2f3}#collapse-button:focus,#collapse-button:hover{color:#e14d43}#wpadminbar{color:#fff;background:#363b3f}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f1f2f3}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#e14d43;background:#26292c}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#e14d43}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#26292c}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#4c4c4d}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#c3c4c5}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f1f2f3}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#e14d43}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#e14d43}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f1f2f3}#wpadminbar #adminbarsearch:before{color:#f1f2f3}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#464d52}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#464d52;background-color:#464d52}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#e14d43}#wpadminbar #wp-admin-bar-user-info .username{color:#c3c4c5}.wp-pointer .wp-pointer-content h3{background-color:#e14d43;border-color:#dd382d}.wp-pointer .wp-pointer-content h3:before{color:#e14d43}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#e14d43}.media-item .bar,.media-progress-bar div{background-color:#e14d43}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #e14d43}.attachment.details .check{background-color:#e14d43;box-shadow:0 0 0 1px #fff,0 0 0 2px #e14d43}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #e14d43}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#e14d43}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#e14d43}.theme-filter.current,.theme-section.current{border-bottom-color:#363b3f}body.more-filters-opened .more-filters{color:#fff;background-color:#363b3f}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#e14d43;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#e14d43;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f1f2f3}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#e14d43}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#26292c}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f1f2f3}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#e14d43} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/midnight/colors.css b/backend/wp-admin/css/colors/midnight/colors.css new file mode 100644 index 0000000..9aa3c57 --- /dev/null +++ b/backend/wp-admin/css/colors/midnight/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #e14d43; +} + +input[type=radio]:checked:before { + background: #e14d43; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #e14d43; + border-color: #d02c21 #ba281e #ba281e; + color: #fff; + box-shadow: 0 1px 0 #ba281e; + text-shadow: 0 -1px 1px #ba281e, 1px 0 1px #ba281e, 0 1px 1px #ba281e, -1px 0 1px #ba281e; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #e35950; + border-color: #ba281e; + color: #fff; + box-shadow: 0 1px 0 #ba281e; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #d02c21, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #d02c21; + border-color: #ba281e; + box-shadow: inset 0 2px 0 #ba281e; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1c8c7 !important; + background: #d92e23 !important; + border-color: #ba281e !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ba281e !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ba281e !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #363b3f; +} + +.wp-core-ui .wp-ui-text-primary { + color: #363b3f; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #e14d43; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #e14d43; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #69a8bb; +} + +.wp-core-ui .wp-ui-text-notification { + color: #69a8bb; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f1f2f3; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #363b3f; +} + +.view-switch a.current:before { + color: #363b3f; +} + +.view-switch a:hover:before { + color: #69a8bb; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #363b3f; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f1f2f3; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #e14d43; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #26292c; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #26292c; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #c3c4c5; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #c3c4c5; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #e14d43; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #e14d43; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #e14d43; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #69a8bb; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #26292c; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f1f2f3; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #e14d43; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #363b3f; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f1f2f3; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #e14d43; + background: #26292c; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #e14d43; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #26292c; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #4c4c4d; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #c3c4c5; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f1f2f3; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #e14d43; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #e14d43; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f1f2f3; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f1f2f3; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #464d52; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #464d52; + background-color: #464d52; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #e14d43; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #c3c4c5; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #e14d43; + border-color: #dd382d; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #e14d43; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #e14d43; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #e14d43; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #e14d43; +} + +.attachment.details .check { + background-color: #e14d43; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #e14d43; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #e14d43; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #e14d43; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #e14d43; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #363b3f; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #363b3f; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #e14d43; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #e14d43; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f1f2f3; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #e14d43; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #26292c; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f1f2f3; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #e14d43; +} diff --git a/backend/wp-admin/css/colors/midnight/colors.min.css b/backend/wp-admin/css/colors/midnight/colors.min.css new file mode 100644 index 0000000..2393a56 --- /dev/null +++ b/backend/wp-admin/css/colors/midnight/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#e14d43}input[type=radio]:checked:before{background:#e14d43}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#e14d43;border-color:#d02c21 #ba281e #ba281e;color:#fff;box-shadow:0 1px 0 #ba281e;text-shadow:0 -1px 1px #ba281e,1px 0 1px #ba281e,0 1px 1px #ba281e,-1px 0 1px #ba281e}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#e35950;border-color:#ba281e;color:#fff;box-shadow:0 1px 0 #ba281e}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #d02c21,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#d02c21;border-color:#ba281e;box-shadow:inset 0 2px 0 #ba281e}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1c8c7!important;background:#d92e23!important;border-color:#ba281e!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ba281e!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ba281e!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#363b3f}.wp-core-ui .wp-ui-text-primary{color:#363b3f}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#e14d43}.wp-core-ui .wp-ui-text-highlight{color:#e14d43}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#69a8bb}.wp-core-ui .wp-ui-text-notification{color:#69a8bb}.wp-core-ui .wp-ui-text-icon{color:#f1f2f3}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#363b3f}.view-switch a.current:before{color:#363b3f}.view-switch a:hover:before{color:#69a8bb}#adminmenu,#adminmenuback,#adminmenuwrap{background:#363b3f}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f1f2f3}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#e14d43}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#26292c}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#26292c}#adminmenu .wp-submenu .wp-submenu-head{color:#c3c4c5}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#c3c4c5}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#e14d43}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#e14d43}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#e14d43}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#69a8bb}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#26292c}#collapse-button{color:#f1f2f3}#collapse-button:focus,#collapse-button:hover{color:#e14d43}#wpadminbar{color:#fff;background:#363b3f}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f1f2f3}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#e14d43;background:#26292c}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#e14d43}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#26292c}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#4c4c4d}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#c3c4c5}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f1f2f3}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#e14d43}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#e14d43}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f1f2f3}#wpadminbar #adminbarsearch:before{color:#f1f2f3}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#464d52}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#464d52;background-color:#464d52}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#e14d43}#wpadminbar #wp-admin-bar-user-info .username{color:#c3c4c5}.wp-pointer .wp-pointer-content h3{background-color:#e14d43;border-color:#dd382d}.wp-pointer .wp-pointer-content h3:before{color:#e14d43}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#e14d43}.media-item .bar,.media-progress-bar div{background-color:#e14d43}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #e14d43}.attachment.details .check{background-color:#e14d43;box-shadow:0 0 0 1px #fff,0 0 0 2px #e14d43}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #e14d43}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#e14d43}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#e14d43}.theme-filter.current,.theme-section.current{border-bottom-color:#363b3f}body.more-filters-opened .more-filters{color:#fff;background-color:#363b3f}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#e14d43;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#e14d43;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f1f2f3}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#e14d43}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#26292c}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f1f2f3}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#e14d43} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/midnight/colors.scss b/backend/wp-admin/css/colors/midnight/colors.scss new file mode 100644 index 0000000..591232b --- /dev/null +++ b/backend/wp-admin/css/colors/midnight/colors.scss @@ -0,0 +1,5 @@ +$base-color: #363b3f; +$highlight-color: #e14d43; +$notification-color: #69a8bb; + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/colors/ocean/colors-rtl.css b/backend/wp-admin/css/colors/ocean/colors-rtl.css new file mode 100644 index 0000000..8ca2884 --- /dev/null +++ b/backend/wp-admin/css/colors/ocean/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #738e96; +} + +input[type=radio]:checked:before { + background: #738e96; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #9ebaa0; + border-color: #80a583 #719a74 #719a74; + color: #fff; + box-shadow: 0 1px 0 #719a74; + text-shadow: 0 -1px 1px #719a74, -1px 0 1px #719a74, 0 1px 1px #719a74, 1px 0 1px #719a74; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #a7c0a9; + border-color: #719a74; + color: #fff; + box-shadow: 0 1px 0 #719a74; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #80a583, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #80a583; + border-color: #719a74; + box-shadow: inset 0 2px 0 #719a74; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #c7d1c8 !important; + background: #86a989 !important; + border-color: #719a74 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #719a74 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #719a74 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #738e96; +} + +.wp-core-ui .wp-ui-text-primary { + color: #738e96; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #9ebaa0; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #9ebaa0; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #aa9d88; +} + +.wp-core-ui .wp-ui-text-notification { + color: #aa9d88; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f2fcff; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #738e96; +} + +.view-switch a.current:before { + color: #738e96; +} + +.view-switch a:hover:before { + color: #aa9d88; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #738e96; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f2fcff; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #9ebaa0; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #627c83; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #627c83; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #d5dde0; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #d5dde0; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #9ebaa0; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #9ebaa0; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #9ebaa0; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #aa9d88; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #627c83; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f2fcff; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #9ebaa0; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #738e96; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f2fcff; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #9ebaa0; + background: #627c83; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #9ebaa0; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #627c83; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #8f9a9e; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #d5dde0; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f2fcff; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #9ebaa0; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #9ebaa0; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f2fcff; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f2fcff; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #879ea5; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #879ea5; + background-color: #879ea5; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #9ebaa0; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #d5dde0; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #9ebaa0; + border-color: #8faf91; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #9ebaa0; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #9ebaa0; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #9ebaa0; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #9ebaa0; +} + +.attachment.details .check { + background-color: #9ebaa0; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #9ebaa0; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #9ebaa0; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #9ebaa0; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #9ebaa0; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #738e96; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #738e96; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #9ebaa0; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #9ebaa0; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f2fcff; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #9ebaa0; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #627c83; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f2fcff; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #9ebaa0; +} diff --git a/backend/wp-admin/css/colors/ocean/colors-rtl.min.css b/backend/wp-admin/css/colors/ocean/colors-rtl.min.css new file mode 100644 index 0000000..71871d3 --- /dev/null +++ b/backend/wp-admin/css/colors/ocean/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#738e96}input[type=radio]:checked:before{background:#738e96}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#9ebaa0;border-color:#80a583 #719a74 #719a74;color:#fff;box-shadow:0 1px 0 #719a74;text-shadow:0 -1px 1px #719a74,-1px 0 1px #719a74,0 1px 1px #719a74,1px 0 1px #719a74}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#a7c0a9;border-color:#719a74;color:#fff;box-shadow:0 1px 0 #719a74}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #80a583,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#80a583;border-color:#719a74;box-shadow:inset 0 2px 0 #719a74}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#c7d1c8!important;background:#86a989!important;border-color:#719a74!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #719a74!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #719a74!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#738e96}.wp-core-ui .wp-ui-text-primary{color:#738e96}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#9ebaa0}.wp-core-ui .wp-ui-text-highlight{color:#9ebaa0}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#aa9d88}.wp-core-ui .wp-ui-text-notification{color:#aa9d88}.wp-core-ui .wp-ui-text-icon{color:#f2fcff}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#738e96}.view-switch a.current:before{color:#738e96}.view-switch a:hover:before{color:#aa9d88}#adminmenu,#adminmenuback,#adminmenuwrap{background:#738e96}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f2fcff}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#9ebaa0}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#627c83}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#627c83}#adminmenu .wp-submenu .wp-submenu-head{color:#d5dde0}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#d5dde0}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#9ebaa0}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#9ebaa0}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#9ebaa0}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#aa9d88}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#627c83}#collapse-button{color:#f2fcff}#collapse-button:focus,#collapse-button:hover{color:#9ebaa0}#wpadminbar{color:#fff;background:#738e96}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f2fcff}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#9ebaa0;background:#627c83}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#9ebaa0}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#627c83}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#8f9a9e}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#d5dde0}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f2fcff}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#9ebaa0}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#9ebaa0}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f2fcff}#wpadminbar #adminbarsearch:before{color:#f2fcff}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#879ea5}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#879ea5;background-color:#879ea5}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#9ebaa0}#wpadminbar #wp-admin-bar-user-info .username{color:#d5dde0}.wp-pointer .wp-pointer-content h3{background-color:#9ebaa0;border-color:#8faf91}.wp-pointer .wp-pointer-content h3:before{color:#9ebaa0}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#9ebaa0}.media-item .bar,.media-progress-bar div{background-color:#9ebaa0}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #9ebaa0}.attachment.details .check{background-color:#9ebaa0;box-shadow:0 0 0 1px #fff,0 0 0 2px #9ebaa0}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #9ebaa0}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#9ebaa0}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#9ebaa0}.theme-filter.current,.theme-section.current{border-bottom-color:#738e96}body.more-filters-opened .more-filters{color:#fff;background-color:#738e96}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#9ebaa0;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#9ebaa0;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f2fcff}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#9ebaa0}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#627c83}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f2fcff}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#9ebaa0} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/ocean/colors.css b/backend/wp-admin/css/colors/ocean/colors.css new file mode 100644 index 0000000..2046a95 --- /dev/null +++ b/backend/wp-admin/css/colors/ocean/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #738e96; +} + +input[type=radio]:checked:before { + background: #738e96; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #9ebaa0; + border-color: #80a583 #719a74 #719a74; + color: #fff; + box-shadow: 0 1px 0 #719a74; + text-shadow: 0 -1px 1px #719a74, 1px 0 1px #719a74, 0 1px 1px #719a74, -1px 0 1px #719a74; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #a7c0a9; + border-color: #719a74; + color: #fff; + box-shadow: 0 1px 0 #719a74; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #80a583, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #80a583; + border-color: #719a74; + box-shadow: inset 0 2px 0 #719a74; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #c7d1c8 !important; + background: #86a989 !important; + border-color: #719a74 !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #719a74 !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #719a74 !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #738e96; +} + +.wp-core-ui .wp-ui-text-primary { + color: #738e96; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #9ebaa0; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #9ebaa0; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #aa9d88; +} + +.wp-core-ui .wp-ui-text-notification { + color: #aa9d88; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f2fcff; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #738e96; +} + +.view-switch a.current:before { + color: #738e96; +} + +.view-switch a:hover:before { + color: #aa9d88; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #738e96; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f2fcff; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #9ebaa0; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #627c83; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #627c83; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #d5dde0; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #d5dde0; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #9ebaa0; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #9ebaa0; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #9ebaa0; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #aa9d88; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #627c83; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f2fcff; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #9ebaa0; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #738e96; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f2fcff; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #9ebaa0; + background: #627c83; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #9ebaa0; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #627c83; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #8f9a9e; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #d5dde0; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f2fcff; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #9ebaa0; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #9ebaa0; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f2fcff; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f2fcff; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #879ea5; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #879ea5; + background-color: #879ea5; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #9ebaa0; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #d5dde0; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #9ebaa0; + border-color: #8faf91; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #9ebaa0; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #9ebaa0; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #9ebaa0; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #9ebaa0; +} + +.attachment.details .check { + background-color: #9ebaa0; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #9ebaa0; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #9ebaa0; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #9ebaa0; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #9ebaa0; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #738e96; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #738e96; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #9ebaa0; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #9ebaa0; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f2fcff; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #9ebaa0; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #627c83; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f2fcff; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #9ebaa0; +} diff --git a/backend/wp-admin/css/colors/ocean/colors.min.css b/backend/wp-admin/css/colors/ocean/colors.min.css new file mode 100644 index 0000000..a381100 --- /dev/null +++ b/backend/wp-admin/css/colors/ocean/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#738e96}input[type=radio]:checked:before{background:#738e96}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#9ebaa0;border-color:#80a583 #719a74 #719a74;color:#fff;box-shadow:0 1px 0 #719a74;text-shadow:0 -1px 1px #719a74,1px 0 1px #719a74,0 1px 1px #719a74,-1px 0 1px #719a74}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#a7c0a9;border-color:#719a74;color:#fff;box-shadow:0 1px 0 #719a74}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #80a583,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#80a583;border-color:#719a74;box-shadow:inset 0 2px 0 #719a74}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#c7d1c8!important;background:#86a989!important;border-color:#719a74!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #719a74!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #719a74!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#738e96}.wp-core-ui .wp-ui-text-primary{color:#738e96}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#9ebaa0}.wp-core-ui .wp-ui-text-highlight{color:#9ebaa0}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#aa9d88}.wp-core-ui .wp-ui-text-notification{color:#aa9d88}.wp-core-ui .wp-ui-text-icon{color:#f2fcff}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#738e96}.view-switch a.current:before{color:#738e96}.view-switch a:hover:before{color:#aa9d88}#adminmenu,#adminmenuback,#adminmenuwrap{background:#738e96}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f2fcff}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#9ebaa0}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#627c83}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#627c83}#adminmenu .wp-submenu .wp-submenu-head{color:#d5dde0}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#d5dde0}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#9ebaa0}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#9ebaa0}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#9ebaa0}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#aa9d88}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#627c83}#collapse-button{color:#f2fcff}#collapse-button:focus,#collapse-button:hover{color:#9ebaa0}#wpadminbar{color:#fff;background:#738e96}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f2fcff}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#9ebaa0;background:#627c83}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#9ebaa0}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#627c83}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#8f9a9e}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#d5dde0}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f2fcff}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#9ebaa0}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#9ebaa0}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f2fcff}#wpadminbar #adminbarsearch:before{color:#f2fcff}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#879ea5}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#879ea5;background-color:#879ea5}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#9ebaa0}#wpadminbar #wp-admin-bar-user-info .username{color:#d5dde0}.wp-pointer .wp-pointer-content h3{background-color:#9ebaa0;border-color:#8faf91}.wp-pointer .wp-pointer-content h3:before{color:#9ebaa0}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#9ebaa0}.media-item .bar,.media-progress-bar div{background-color:#9ebaa0}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #9ebaa0}.attachment.details .check{background-color:#9ebaa0;box-shadow:0 0 0 1px #fff,0 0 0 2px #9ebaa0}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #9ebaa0}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#9ebaa0}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#9ebaa0}.theme-filter.current,.theme-section.current{border-bottom-color:#738e96}body.more-filters-opened .more-filters{color:#fff;background-color:#738e96}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#9ebaa0;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#9ebaa0;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f2fcff}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#9ebaa0}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#627c83}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f2fcff}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#9ebaa0} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/ocean/colors.scss b/backend/wp-admin/css/colors/ocean/colors.scss new file mode 100644 index 0000000..d52339c --- /dev/null +++ b/backend/wp-admin/css/colors/ocean/colors.scss @@ -0,0 +1,8 @@ +$base-color: #738e96; +$icon-color: #f2fcff; +$highlight-color: #9ebaa0; +$notification-color: #aa9d88; + +$form-checked: $base-color; + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/colors/sunrise/colors-rtl.css b/backend/wp-admin/css/colors/sunrise/colors-rtl.css new file mode 100644 index 0000000..7e227e0 --- /dev/null +++ b/backend/wp-admin/css/colors/sunrise/colors-rtl.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #dd823b; +} + +input[type=radio]:checked:before { + background: #dd823b; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #dd823b; + border-color: #c36922 #ad5d1e #ad5d1e; + color: #fff; + box-shadow: 0 1px 0 #ad5d1e; + text-shadow: 0 -1px 1px #ad5d1e, -1px 0 1px #ad5d1e, 0 1px 1px #ad5d1e, 1px 0 1px #ad5d1e; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #df8a48; + border-color: #ad5d1e; + color: #fff; + box-shadow: 0 1px 0 #ad5d1e; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #c36922, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #c36922; + border-color: #ad5d1e; + box-shadow: inset 0 2px 0 #ad5d1e; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1cbc7 !important; + background: #cc6d23 !important; + border-color: #ad5d1e !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ad5d1e !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ad5d1e !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #cf4944; +} + +.wp-core-ui .wp-ui-text-primary { + color: #cf4944; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #dd823b; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #dd823b; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #ccaf0b; +} + +.wp-core-ui .wp-ui-text-notification { + color: #ccaf0b; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f3f1f1; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #cf4944; +} + +.view-switch a.current:before { + color: #cf4944; +} + +.view-switch a:hover:before { + color: #ccaf0b; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #cf4944; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f3f1f1; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #dd823b; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #be3631; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-left-color: #be3631; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #f1c8c7; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #f1c8c7; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #f7e3d3; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #f7e3d3; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-left-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #dd823b; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #ccaf0b; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #be3631; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f3f1f1; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #f7e3d3; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #cf4944; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f3f1f1; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #f7e3d3; + background: #be3631; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #f7e3d3; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #be3631; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #cf6b67; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #f1c8c7; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f3f1f1; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #f7e3d3; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #f7e3d3; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f3f1f1; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f3f1f1; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #d66560; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #d66560; + background-color: #d66560; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #f7e3d3; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #f1c8c7; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #dd823b; + border-color: #d97426; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #dd823b; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #dd823b; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #dd823b; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #dd823b; +} + +.attachment.details .check { + background-color: #dd823b; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #dd823b; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #dd823b; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #dd823b; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #dd823b; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #cf4944; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #cf4944; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #dd823b; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #dd823b; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f3f1f1; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #dd823b; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #be3631; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f3f1f1; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #dd823b; +} diff --git a/backend/wp-admin/css/colors/sunrise/colors-rtl.min.css b/backend/wp-admin/css/colors/sunrise/colors-rtl.min.css new file mode 100644 index 0000000..2c28b2a --- /dev/null +++ b/backend/wp-admin/css/colors/sunrise/colors-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#dd823b}input[type=radio]:checked:before{background:#dd823b}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#dd823b;border-color:#c36922 #ad5d1e #ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e;text-shadow:0 -1px 1px #ad5d1e,-1px 0 1px #ad5d1e,0 1px 1px #ad5d1e,1px 0 1px #ad5d1e}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#df8a48;border-color:#ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #c36922,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#c36922;border-color:#ad5d1e;box-shadow:inset 0 2px 0 #ad5d1e}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1cbc7!important;background:#cc6d23!important;border-color:#ad5d1e!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ad5d1e!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ad5d1e!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#cf4944}.wp-core-ui .wp-ui-text-primary{color:#cf4944}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#dd823b}.wp-core-ui .wp-ui-text-highlight{color:#dd823b}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#ccaf0b}.wp-core-ui .wp-ui-text-notification{color:#ccaf0b}.wp-core-ui .wp-ui-text-icon{color:#f3f1f1}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#cf4944}.view-switch a.current:before{color:#cf4944}.view-switch a:hover:before{color:#ccaf0b}#adminmenu,#adminmenuback,#adminmenuwrap{background:#cf4944}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f3f1f1}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#dd823b}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#be3631}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-left-color:#be3631}#adminmenu .wp-submenu .wp-submenu-head{color:#f1c8c7}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#f1c8c7}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#f7e3d3}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#f7e3d3}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#dd823b}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#ccaf0b}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#be3631}#collapse-button{color:#f3f1f1}#collapse-button:focus,#collapse-button:hover{color:#f7e3d3}#wpadminbar{color:#fff;background:#cf4944}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f3f1f1}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#f7e3d3;background:#be3631}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#f7e3d3}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#be3631}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#cf6b67}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#f1c8c7}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f3f1f1}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#f7e3d3}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#f7e3d3}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f3f1f1}#wpadminbar #adminbarsearch:before{color:#f3f1f1}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#d66560}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#d66560;background-color:#d66560}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#f7e3d3}#wpadminbar #wp-admin-bar-user-info .username{color:#f1c8c7}.wp-pointer .wp-pointer-content h3{background-color:#dd823b;border-color:#d97426}.wp-pointer .wp-pointer-content h3:before{color:#dd823b}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#dd823b}.media-item .bar,.media-progress-bar div{background-color:#dd823b}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #dd823b}.attachment.details .check{background-color:#dd823b;box-shadow:0 0 0 1px #fff,0 0 0 2px #dd823b}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #dd823b}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#dd823b}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#dd823b}.theme-filter.current,.theme-section.current{border-bottom-color:#cf4944}body.more-filters-opened .more-filters{color:#fff;background-color:#cf4944}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#dd823b;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#dd823b;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f3f1f1}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#dd823b}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#be3631}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f3f1f1}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#dd823b} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/sunrise/colors.css b/backend/wp-admin/css/colors/sunrise/colors.css new file mode 100644 index 0000000..a0d483b --- /dev/null +++ b/backend/wp-admin/css/colors/sunrise/colors.css @@ -0,0 +1,502 @@ +/*! This file is auto-generated */ +/* + * Button mixin- creates 3d-ish button effect with correct + * highlights/shadows, based on a base color. + */ +body { + background: #f1f1f1; +} + +/* Links */ +a { + color: #0073aa; +} + +a:hover, a:active, a:focus { + color: #0096dd; +} + +#media-upload a.del-link:hover, +div.dashboard-widget-submit input:hover, +.subsubsub a:hover, +.subsubsub a.current:hover { + color: #0096dd; +} + +/* Forms */ +input[type=checkbox]:checked:before { + color: #dd823b; +} + +input[type=radio]:checked:before { + background: #dd823b; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #0096dd; +} + +/* Core UI */ +.wp-core-ui .button-primary { + background: #dd823b; + border-color: #c36922 #ad5d1e #ad5d1e; + color: #fff; + box-shadow: 0 1px 0 #ad5d1e; + text-shadow: 0 -1px 1px #ad5d1e, 1px 0 1px #ad5d1e, 0 1px 1px #ad5d1e, -1px 0 1px #ad5d1e; +} + +.wp-core-ui .button-primary:hover, .wp-core-ui .button-primary:focus { + background: #df8a48; + border-color: #ad5d1e; + color: #fff; + box-shadow: 0 1px 0 #ad5d1e; +} + +.wp-core-ui .button-primary:focus { + box-shadow: inset 0 1px 0 #c36922, 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary:active, .wp-core-ui .button-primary.active, .wp-core-ui .button-primary.active:focus, .wp-core-ui .button-primary.active:hover { + background: #c36922; + border-color: #ad5d1e; + box-shadow: inset 0 2px 0 #ad5d1e; +} + +.wp-core-ui .button-primary[disabled], .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary.button-primary-disabled, .wp-core-ui .button-primary.disabled { + color: #d1cbc7 !important; + background: #cc6d23 !important; + border-color: #ad5d1e !important; + text-shadow: none !important; +} + +.wp-core-ui .button-primary.button-hero { + box-shadow: 0 2px 0 #ad5d1e !important; +} + +.wp-core-ui .button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #ad5d1e !important; +} + +.wp-core-ui .wp-ui-primary { + color: #fff; + background-color: #cf4944; +} + +.wp-core-ui .wp-ui-text-primary { + color: #cf4944; +} + +.wp-core-ui .wp-ui-highlight { + color: #fff; + background-color: #dd823b; +} + +.wp-core-ui .wp-ui-text-highlight { + color: #dd823b; +} + +.wp-core-ui .wp-ui-notification { + color: #fff; + background-color: #ccaf0b; +} + +.wp-core-ui .wp-ui-text-notification { + color: #ccaf0b; +} + +.wp-core-ui .wp-ui-text-icon { + color: #f3f1f1; +} + +/* List tables */ +.wrap .add-new-h2:hover, +.wrap .page-title-action:hover, +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + color: #fff; + background-color: #cf4944; +} + +.view-switch a.current:before { + color: #cf4944; +} + +.view-switch a:hover:before { + color: #ccaf0b; +} + +/* Admin Menu */ +#adminmenuback, +#adminmenuwrap, +#adminmenu { + background: #cf4944; +} + +#adminmenu a { + color: #fff; +} + +#adminmenu div.wp-menu-image:before { + color: #f3f1f1; +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #fff; + background-color: #dd823b; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #fff; +} + +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap h2 .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + background-color: #f1f1f1; + border-bottom-color: #f1f1f1; +} + +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #be3631; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { + border-right-color: #be3631; +} + +#adminmenu .wp-submenu .wp-submenu-head { + color: #f1c8c7; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #f1c8c7; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #f7e3d3; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #fff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #f7e3d3; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #f1f1f1; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #fff; + background: #dd823b; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #fff; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #fff; + background: #ccaf0b; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + color: #fff; + background: #be3631; +} + +/* Admin Menu: collapse button */ +#collapse-button { + color: #f3f1f1; +} + +#collapse-button:hover, +#collapse-button:focus { + color: #f7e3d3; +} + +/* Admin Bar */ +#wpadminbar { + color: #fff; + background: #cf4944; +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #fff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f3f1f1; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #f7e3d3; + background: #be3631; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #f7e3d3; +} + +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #fff; +} + +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: #be3631; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #cf6b67; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #f1c8c7; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f3f1f1; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #f7e3d3; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #f7e3d3; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f3f1f1; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f3f1f1; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + color: #fff; + background: #d66560; +} + +/* Admin Bar: my account */ +#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + border-color: #d66560; + background-color: #d66560; +} + +#wpadminbar #wp-admin-bar-user-info .display-name { + color: #fff; +} + +#wpadminbar #wp-admin-bar-user-info a:hover .display-name { + color: #f7e3d3; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #f1c8c7; +} + +/* Pointers */ +.wp-pointer .wp-pointer-content h3 { + background-color: #dd823b; + border-color: #d97426; +} + +.wp-pointer .wp-pointer-content h3:before { + color: #dd823b; +} + +.wp-pointer.wp-pointer-top .wp-pointer-arrow, +.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow, +.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner { + border-bottom-color: #dd823b; +} + +/* Media */ +.media-item .bar, +.media-progress-bar div { + background-color: #dd823b; +} + +.details.attachment { + box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 7px #dd823b; +} + +.attachment.details .check { + background-color: #dd823b; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px #dd823b; +} + +.media-selection .attachment.selection.details .thumbnail { + box-shadow: 0 0 0 1px #fff, 0 0 0 3px #dd823b; +} + +/* Themes */ +.theme-browser .theme.active .theme-name, +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + background: #dd823b; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + color: #dd823b; +} + +.theme-section.current, +.theme-filter.current { + border-bottom-color: #cf4944; +} + +body.more-filters-opened .more-filters { + color: #fff; + background-color: #cf4944; +} + +body.more-filters-opened .more-filters:before { + color: #fff; +} + +body.more-filters-opened .more-filters:hover, +body.more-filters-opened .more-filters:focus { + background-color: #dd823b; + color: #fff; +} + +body.more-filters-opened .more-filters:hover:before, +body.more-filters-opened .more-filters:focus:before { + color: #fff; +} + +/* Widgets */ +.widgets-chooser li.widgets-chooser-selected { + background-color: #dd823b; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + color: #fff; +} + +/* Responsive Component */ +div#wp-responsive-toggle a:before { + color: #f3f1f1; +} + +.wp-responsive-open div#wp-responsive-toggle a { + border-color: transparent; + background: #dd823b; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a { + background: #be3631; +} + +.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before { + color: #f3f1f1; +} + +/* TinyMCE */ +.mce-container.mce-menu .mce-menu-item:hover, +.mce-container.mce-menu .mce-menu-item.mce-selected, +.mce-container.mce-menu .mce-menu-item:focus, +.mce-container.mce-menu .mce-menu-item-normal.mce-active, +.mce-container.mce-menu .mce-menu-item-preview.mce-active { + background: #dd823b; +} diff --git a/backend/wp-admin/css/colors/sunrise/colors.min.css b/backend/wp-admin/css/colors/sunrise/colors.min.css new file mode 100644 index 0000000..c5d093f --- /dev/null +++ b/backend/wp-admin/css/colors/sunrise/colors.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body{background:#f1f1f1}a{color:#0073aa}a:active,a:focus,a:hover{color:#0096dd}#media-upload a.del-link:hover,.subsubsub a.current:hover,.subsubsub a:hover,div.dashboard-widget-submit input:hover{color:#0096dd}input[type=checkbox]:checked:before{color:#dd823b}input[type=radio]:checked:before{background:#dd823b}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#0096dd}.wp-core-ui .button-primary{background:#dd823b;border-color:#c36922 #ad5d1e #ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e;text-shadow:0 -1px 1px #ad5d1e,1px 0 1px #ad5d1e,0 1px 1px #ad5d1e,-1px 0 1px #ad5d1e}.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#df8a48;border-color:#ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e}.wp-core-ui .button-primary:focus{box-shadow:inset 0 1px 0 #c36922,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#c36922;border-color:#ad5d1e;box-shadow:inset 0 2px 0 #ad5d1e}.wp-core-ui .button-primary.button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#d1cbc7!important;background:#cc6d23!important;border-color:#ad5d1e!important;text-shadow:none!important}.wp-core-ui .button-primary.button-hero{box-shadow:0 2px 0 #ad5d1e!important}.wp-core-ui .button-primary.button-hero:active{box-shadow:inset 0 3px 0 #ad5d1e!important}.wp-core-ui .wp-ui-primary{color:#fff;background-color:#cf4944}.wp-core-ui .wp-ui-text-primary{color:#cf4944}.wp-core-ui .wp-ui-highlight{color:#fff;background-color:#dd823b}.wp-core-ui .wp-ui-text-highlight{color:#dd823b}.wp-core-ui .wp-ui-notification{color:#fff;background-color:#ccaf0b}.wp-core-ui .wp-ui-text-notification{color:#ccaf0b}.wp-core-ui .wp-ui-text-icon{color:#f3f1f1}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover,.wrap .add-new-h2:hover,.wrap .page-title-action:hover{color:#fff;background-color:#cf4944}.view-switch a.current:before{color:#cf4944}.view-switch a:hover:before{color:#ccaf0b}#adminmenu,#adminmenuback,#adminmenuwrap{background:#cf4944}#adminmenu a{color:#fff}#adminmenu div.wp-menu-image:before{color:#f3f1f1}#adminmenu a:hover,#adminmenu li.menu-top:hover,#adminmenu li.opensub>a.menu-top,#adminmenu li>a.menu-top:focus{color:#fff;background-color:#dd823b}#adminmenu li.menu-top:hover div.wp-menu-image:before,#adminmenu li.opensub>a.menu-top div.wp-menu-image:before{color:#fff}.about-wrap h2 .nav-tab-active,.nav-tab-active,.nav-tab-active:hover{background-color:#f1f1f1;border-bottom-color:#f1f1f1}#adminmenu .wp-has-current-submenu .wp-submenu,#adminmenu .wp-has-current-submenu.opensub .wp-submenu,#adminmenu .wp-submenu,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{background:#be3631}#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after{border-right-color:#be3631}#adminmenu .wp-submenu .wp-submenu-head{color:#f1c8c7}#adminmenu .wp-has-current-submenu .wp-submenu a,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a,#adminmenu .wp-submenu a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a,.folded #adminmenu .wp-has-current-submenu .wp-submenu a{color:#f1c8c7}#adminmenu .wp-has-current-submenu .wp-submenu a:focus,#adminmenu .wp-has-current-submenu .wp-submenu a:hover,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover,#adminmenu .wp-submenu a:focus,#adminmenu .wp-submenu a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu a:hover,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus,.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover{color:#f7e3d3}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a,#adminmenu .wp-submenu li.current a,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a{color:#fff}#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus,#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover,#adminmenu .wp-submenu li.current a:focus,#adminmenu .wp-submenu li.current a:hover,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:focus,#adminmenu a.wp-has-current-submenu:focus+.wp-submenu li.current a:hover{color:#f7e3d3}ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#f1f1f1}#adminmenu li.current a.menu-top,#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head,#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,.folded #adminmenu li.current.menu-top{color:#fff;background:#dd823b}#adminmenu a.current:hover div.wp-menu-image:before,#adminmenu li a:focus div.wp-menu-image:before,#adminmenu li.opensub div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu div.wp-menu-image:before,#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before,#adminmenu li:hover div.wp-menu-image:before,.ie8 #adminmenu li.opensub div.wp-menu-image:before{color:#fff}#adminmenu .awaiting-mod,#adminmenu .update-plugins{color:#fff;background:#ccaf0b}#adminmenu li a.wp-has-current-submenu .update-plugins,#adminmenu li.current a .awaiting-mod,#adminmenu li.menu-top:hover>a .update-plugins,#adminmenu li:hover a .awaiting-mod{color:#fff;background:#be3631}#collapse-button{color:#f3f1f1}#collapse-button:focus,#collapse-button:hover{color:#f7e3d3}#wpadminbar{color:#fff;background:#cf4944}#wpadminbar .ab-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#fff}#wpadminbar .ab-icon,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:after,#wpadminbar .ab-item:before{color:#f3f1f1}#wpadminbar .ab-top-menu>li.menupop.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar.nojs .ab-top-menu>li.menupop:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{color:#f7e3d3;background:#be3631}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li.hover span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label{color:#f7e3d3}#wpadminbar:not(.mobile) li:hover #adminbarsearch:before,#wpadminbar:not(.mobile) li:hover .ab-icon:before,#wpadminbar:not(.mobile) li:hover .ab-item:after,#wpadminbar:not(.mobile) li:hover .ab-item:before{color:#fff}#wpadminbar .menupop .ab-sub-wrapper{background:#be3631}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#cf6b67}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#f1c8c7}#wpadminbar .menupop .menupop>.ab-item:before,#wpadminbar .quicklinks li .blavatar{color:#f3f1f1}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#f7e3d3}#wpadminbar .menupop .menupop>.ab-item:hover:before,#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar,#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#f7e3d3}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#f3f1f1}#wpadminbar #adminbarsearch:before{color:#f3f1f1}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{color:#fff;background:#d66560}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{border-color:#d66560;background-color:#d66560}#wpadminbar #wp-admin-bar-user-info .display-name{color:#fff}#wpadminbar #wp-admin-bar-user-info a:hover .display-name{color:#f7e3d3}#wpadminbar #wp-admin-bar-user-info .username{color:#f1c8c7}.wp-pointer .wp-pointer-content h3{background-color:#dd823b;border-color:#d97426}.wp-pointer .wp-pointer-content h3:before{color:#dd823b}.wp-pointer.wp-pointer-top .wp-pointer-arrow,.wp-pointer.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow,.wp-pointer.wp-pointer-undefined .wp-pointer-arrow-inner{border-bottom-color:#dd823b}.media-item .bar,.media-progress-bar div{background-color:#dd823b}.details.attachment{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #dd823b}.attachment.details .check{background-color:#dd823b;box-shadow:0 0 0 1px #fff,0 0 0 2px #dd823b}.media-selection .attachment.selection.details .thumbnail{box-shadow:0 0 0 1px #fff,0 0 0 3px #dd823b}.theme-browser .theme.active .theme-name,.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{background:#dd823b}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{color:#dd823b}.theme-filter.current,.theme-section.current{border-bottom-color:#cf4944}body.more-filters-opened .more-filters{color:#fff;background-color:#cf4944}body.more-filters-opened .more-filters:before{color:#fff}body.more-filters-opened .more-filters:focus,body.more-filters-opened .more-filters:hover{background-color:#dd823b;color:#fff}body.more-filters-opened .more-filters:focus:before,body.more-filters-opened .more-filters:hover:before{color:#fff}.widgets-chooser li.widgets-chooser-selected{background-color:#dd823b;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{color:#fff}div#wp-responsive-toggle a:before{color:#f3f1f1}.wp-responsive-open div#wp-responsive-toggle a{border-color:transparent;background:#dd823b}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle a{background:#be3631}.wp-responsive-open #wpadminbar #wp-admin-bar-menu-toggle .ab-icon:before{color:#f3f1f1}.mce-container.mce-menu .mce-menu-item-normal.mce-active,.mce-container.mce-menu .mce-menu-item-preview.mce-active,.mce-container.mce-menu .mce-menu-item.mce-selected,.mce-container.mce-menu .mce-menu-item:focus,.mce-container.mce-menu .mce-menu-item:hover{background:#dd823b} \ No newline at end of file diff --git a/backend/wp-admin/css/colors/sunrise/colors.scss b/backend/wp-admin/css/colors/sunrise/colors.scss new file mode 100644 index 0000000..5dd8d82 --- /dev/null +++ b/backend/wp-admin/css/colors/sunrise/colors.scss @@ -0,0 +1,6 @@ +$base-color: #cf4944; +$highlight-color: #dd823b; +$notification-color: #ccaf0b; +$menu-submenu-focus-text: lighten( $highlight-color, 35% ); + +@import "../_admin.scss"; diff --git a/backend/wp-admin/css/common-rtl.css b/backend/wp-admin/css/common-rtl.css new file mode 100644 index 0000000..e404826 --- /dev/null +++ b/backend/wp-admin/css/common-rtl.css @@ -0,0 +1,3955 @@ +/* 2 column liquid layout */ +#wpwrap { + height: auto; + min-height: 100%; + width: 100%; + position: relative; + -webkit-font-smoothing: subpixel-antialiased; +} + +#wpcontent { + height: 100%; + padding-right: 20px; +} + +#wpcontent, +#wpfooter { + margin-right: 160px; +} + +.folded #wpcontent, +.folded #wpfooter { + margin-right: 36px; +} + +#wpbody-content { + padding-bottom: 65px; + float: right; + width: 100%; + overflow: visible !important; +} + +/* inner 2 column liquid layout */ + +.inner-sidebar { + float: left; + clear: left; + display: none; + width: 281px; + position: relative; +} + +.columns-2 .inner-sidebar { + margin-left: auto; + width: 286px; + display: block; +} + +.inner-sidebar #side-sortables, +.columns-2 .inner-sidebar #side-sortables { + min-height: 300px; + width: 280px; + padding: 0; +} + +.has-right-sidebar .inner-sidebar { + display: block; +} + +.has-right-sidebar #post-body { + float: right; + clear: right; + width: 100%; + margin-left: -2000px; +} + +.has-right-sidebar #post-body-content { + margin-left: 300px; + float: none; + width: auto; +} + +/* 2 columns main area */ + +#col-left { + float: right; + width: 35%; +} + +#col-right { + float: left; + width: 65%; +} + +#col-left .col-wrap { + padding: 0 0 0 6px; +} + +#col-right .col-wrap { + padding: 0 6px 0 0; +} + +/* utility classes */ +.alignleft { + float: right; +} + +.alignright { + float: left; +} + +.textleft { + text-align: right; +} + +.textright { + text-align: left; +} + +.clear { + clear: both; +} + +/* modern clearfix */ +.wp-clearfix:after { + content: ""; + display: table; + clear: both; +} + +/* Hide visually but not from screen readers */ +.screen-reader-text, +.screen-reader-text span, +.ui-helper-hidden-accessible { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ +} + +.screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +.screen-reader-shortcut:focus { + right: 6px; + top: -25px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); + text-decoration: none; + outline: none; +} + +.hidden, +.js .closed .inside, +.js .hide-if-js, +.no-js .hide-if-no-js, +.js.wp-core-ui .hide-if-js, +.js .wp-core-ui .hide-if-js, +.no-js.wp-core-ui .hide-if-no-js, +.no-js .wp-core-ui .hide-if-no-js { + display: none; +} + +/* @todo: Take a second look. Large chunks of shared color, from the colors.css merge */ +.widget-top, +.menu-item-handle, +.widget-inside, +#menu-settings-column .accordion-container, +#menu-management .menu-edit, +.manage-menus, +table.widefat, +.stuffbox, +p.popular-tags, +.widgets-holder-wrap, +.wp-editor-container, +.popular-tags, +.feature-filter, +.imgedit-group, +.comment-ays { + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +table.widefat, +.wp-editor-container, +.stuffbox, +p.popular-tags, +.widgets-holder-wrap, +.popular-tags, +.feature-filter, +.imgedit-group, +.comment-ays { + background: #fff; +} + +/* general */ +html, +body { + height: 100%; + margin: 0; + padding: 0; +} + +body { + background: #f1f1f1; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 13px; + line-height: 1.4em; + min-width: 600px; +} + +body.iframe { + min-width: 0; + padding-top: 1px; +} + +body.modal-open { + overflow: hidden; +} + +body.mobile.modal-open #wpwrap { + overflow: hidden; + position: fixed; + height: 100%; +} + +iframe, +img { + border: 0; +} + +td { + font-family: inherit; + font-size: inherit; + font-weight: inherit; + line-height: inherit; +} + +/* Any change to the default link style must be applied to button-link too. */ +a { + color: #0073aa; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +a, +div { + outline: 0; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus, +a:focus .media-icon img, +.wp-person a:focus .gravatar { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +#adminmenu a:focus, +.screen-reader-text:focus { + box-shadow: none; + outline: none; +} + +blockquote, +q { + quotes: none; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; + content: none; +} + +p { + font-size: 13px; + line-height: 1.5; + margin: 1em 0; +} + +blockquote { + margin: 1em; +} + +li, +dd { + margin-bottom: 6px; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + display: block; + font-weight: 600; +} + +h1 { + color: #23282d; + font-size: 2em; + margin: .67em 0; +} + +h2, +h3 { + color: #23282d; + font-size: 1.3em; + margin: 1em 0; +} + +.update-core-php h2 { + margin-top: 2em; +} + +.update-php h2, +.update-messages h2, +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.67em; + margin: 2.33em 0; +} + +ul, +ol { + padding: 0; +} + +ul { + list-style: none; +} + +ol { + list-style-type: decimal; + margin-right: 2em; +} + +ul.ul-disc { + list-style: disc outside; +} + +ul.ul-square { + list-style: square outside; +} + +ol.ol-decimal { + list-style: decimal outside; +} + +ul.ul-disc, +ul.ul-square, +ol.ol-decimal { + margin-right: 1.8em; +} + +ul.ul-disc > li, +ul.ul-square > li, +ol.ol-decimal > li { + margin: 0 0 0.5em; +} + +/* rtl:ignore */ +.ltr { + direction: ltr; +} + +/* rtl:ignore */ +.code, +code { + font-family: Consolas, Monaco, monospace; + direction: ltr; + unicode-bidi: embed; +} + +kbd, +code { + padding: 3px 5px 2px 5px; + margin: 0 1px; + background: #eaeaea; + background: rgba(0,0,0,0.07); + font-size: 13px; +} + +.subsubsub { + list-style: none; + margin: 8px 0 0; + padding: 0; + font-size: 13px; + float: right; + color: #666; +} + +.subsubsub a { + line-height: 2; + padding: .2em; + text-decoration: none; +} + +.subsubsub a .count, +.subsubsub a.current .count { + color: #555d66; /* #f1f1f1 background */ + font-weight: 400; +} + +.subsubsub a.current { + font-weight: 600; + border: none; +} + +.subsubsub li { + display: inline-block; + margin: 0; + padding: 0; + white-space: nowrap; +} + +/* .widefat - main style for tables */ +.widefat { + border-spacing: 0; + width: 100%; + clear: both; + margin: 0; +} + +.widefat * { + word-wrap: break-word; +} + +.widefat a, +.widefat button.button-link { + text-decoration: none; +} + +.widefat td, +.widefat th { + padding: 8px 10px; +} + +.widefat thead th, +.widefat thead td { + border-bottom: 1px solid #e1e1e1; +} + +.widefat tfoot th, +.widefat tfoot td { + border-top: 1px solid #e1e1e1; + border-bottom: none; +} + +.widefat .no-items td { + border-bottom-width: 0; +} + +.widefat td { + vertical-align: top; +} + +.widefat td, +.widefat td p, +.widefat td ol, +.widefat td ul { + font-size: 13px; + line-height: 1.5em; +} + +.widefat th, +.widefat thead td, +.widefat tfoot td { + text-align: right; + line-height: 1.3em; + font-size: 14px; +} + +.widefat th input, +.updates-table td input, +.widefat thead td input, +.widefat tfoot td input { + margin: 0 8px 0 0; + padding: 0; + vertical-align: text-top; +} + +.widefat .check-column { + width: 2.2em; + padding: 6px 0 25px; + vertical-align: top; +} + +.widefat tbody th.check-column { + padding: 9px 0 22px; +} + +.widefat thead td.check-column, +.widefat tbody th.check-column, +.updates-table tbody td.check-column, +.widefat tfoot td.check-column { + padding: 11px 3px 0 0; +} + +.widefat thead td.check-column, +.widefat tfoot td.check-column { + padding-top: 4px; + vertical-align: middle; +} + +.update-php div.updated, +.update-php div.error { + margin-right: 0; +} + +.no-js .widefat thead .check-column input, +.no-js .widefat tfoot .check-column input { + display: none; +} + +.widefat .num, +.column-comments, +.column-links, +.column-posts { + text-align: center; +} + +.widefat th#comments { + vertical-align: middle; +} + +.wrap { + margin: 10px 2px 0 20px; +} + +.wrap > h2:first-child, /* Back-compat for pre-4.4 */ +.wrap [class$="icon32"] + h2, /* Back-compat for pre-4.4 */ +.postbox .inside h2, /* Back-compat for pre-4.4 */ +.wrap h1 { + font-size: 23px; + font-weight: 400; + margin: 0; + padding: 9px 0 4px 0; + line-height: 29px; +} + +.wrap h1.wp-heading-inline { + display: inline-block; + margin-left: 5px; +} + +.wp-header-end { + visibility: hidden; + margin: -2px 0 0; +} + +.subtitle { + margin: 0; + padding-right: 25px; + color: #555d66; + font-size: 14px; + font-weight: 400; + line-height: 1; +} + +.wrap .add-new-h2, /* deprecated */ +.wrap .add-new-h2:active, /* deprecated */ +.wrap .page-title-action, +.wrap .page-title-action:active { + margin-right: 4px; + padding: 4px 8px; + position: relative; + top: -3px; + text-decoration: none; + border: none; + border: 1px solid #ccc; + border-radius: 2px; + background: #f7f7f7; + text-shadow: none; + font-weight: 600; + font-size: 13px; + line-height: normal; /* IE8-IE11 need this for buttons */ + color: #0073aa; /* some of these controls are button elements and don't inherit from links */ + cursor: pointer; + outline: 0; +} + +.wrap .wp-heading-inline + .page-title-action { + margin-right: 0; +} + +.wrap .add-new-h2:hover, /* deprecated */ +.wrap .page-title-action:hover { + border-color: #008EC2; + background: #00a0d2; + color: #fff; +} + +/* lower specificity: color needs to be overridden by :hover and :active */ +.page-title-action:focus { + color: #124964; +} + +.wrap .page-title-action:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +.wrap h1.long-header { + padding-left: 0; +} + +.wp-dialog { + background-color: #fff; +} + +.widgets-chooser ul, +#widgets-left .widget-in-question .widget-top, +#available-widgets .widget-top:hover, +div#widgets-right .widget-top:hover, +#widgets-left .widget-top:hover { + border-color: #999; + box-shadow: 0 1px 2px rgba(0,0,0,0.1); +} + +.sorthelper { + background-color: #ccf3fa; +} + +.ac_match, +.subsubsub a.current { + color: #000; +} + +.striped > tbody > :nth-child(odd), +ul.striped > :nth-child(odd), +.alternate { + background-color: #f9f9f9; +} + +.bar { + background-color: #e8e8e8; + border-left-color: #99d; +} + +/* Helper classes for plugins to leverage the active WordPress color scheme */ + +.highlight { + background-color: #e4f2fd; + color: #000; +} + +.wp-ui-primary { + color: #fff; + background-color: #32373c; +} +.wp-ui-text-primary { + color: #32373c; +} + +.wp-ui-highlight { + color: #fff; + background-color: #1e8cbe; +} +.wp-ui-text-highlight { + color: #1e8cbe; +} + +.wp-ui-notification { + color: #fff; + background-color: #d54e21; +} +.wp-ui-text-notification { + color: #d54e21; +} + +.wp-ui-text-icon { + color: #82878c; /* same as new icons */ +} + +/* For emoji replacement images */ +img.emoji { + display: inline !important; + border: none !important; + height: 1em !important; + width: 1em !important; + margin: 0 .07em !important; + vertical-align: -0.1em !important; + background: none !important; + padding: 0 !important; + box-shadow: none !important; +} + +/*------------------------------------------------------------------------------ + 1.0 - Text Styles +------------------------------------------------------------------------------*/ + +.widget .widget-top, +.postbox .hndle, +.stuffbox .hndle, +.control-section .accordion-section-title, +.sidebar-name, +#nav-menu-header, +#nav-menu-footer, +.menu-item-handle, +.checkbox, +.side-info, +#your-profile #rich_editing, +.widefat thead th, +.widefat thead td, +.widefat tfoot th, +.widefat tfoot td { + line-height: 1.4em; +} + +.widget .widget-top, +.menu-item-handle { + background: #fafafa; + color: #23282d; +} + +.postbox .hndle, +.stuffbox .hndle { + border-bottom: 1px solid #eee; +} + +.quicktags, +.search { + background-color: #ccc; + color: #000; + font-size: 12px; +} + +.icon32 { + display: none; +} + +/* @todo can we combine these into a class or use an existing dashicon one? */ +.welcome-panel .welcome-panel-close:before, +.tagchecklist .ntdelbutton .remove-tag-icon:before, +#bulk-titles div a:before, +.notice-dismiss:before { + background: none; + color: #72777c; + content: "\f153"; + display: block; + font: normal 16px/20px dashicons; + speak: none; + height: 20px; + text-align: center; + width: 20px; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.welcome-panel .welcome-panel-close:before { + margin: 0; +} + +#bulk-titles div a:before { + margin: 1px 0; +} + +.tagchecklist .ntdelbutton .remove-tag-icon:before { + margin-right: 2px; + border-radius: 50%; + color: #0073aa; + /* vertically center the icon cross browsers */ + line-height: 1.28; +} + +.tagchecklist .ntdelbutton:focus { + outline: 0; +} + +.welcome-panel .welcome-panel-close:hover:before, +.welcome-panel .welcome-panel-close:focus:before, +.tagchecklist .ntdelbutton:hover .remove-tag-icon:before, +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before, +#bulk-titles div a:hover:before, +#bulk-titles div a:focus:before { + color: #c00; +} + +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.key-labels label { + line-height: 24px; +} + +strong, b { + font-weight: 600; +} + +.pre { + /* https://developer.mozilla.org/en-US/docs/CSS/white-space */ + white-space: pre-wrap; /* css-3 */ + word-wrap: break-word; /* IE 5.5 - 7 */ +} + +.howto { + color: #666; + font-style: italic; + display: block; +} + +p.install-help { + margin: 8px 0; + font-style: italic; +} + +.no-break { + white-space: nowrap; +} + +hr { + border: 0; + border-top: 1px solid #ddd; + border-bottom: 1px solid #fafafa; +} + +.row-actions span.delete a, +.row-actions span.trash a, +.row-actions span.spam a, +.plugins a.delete, +#all-plugins-table .plugins a.delete, +#search-plugins-table .plugins a.delete, +.submitbox .submitdelete, +#media-items a.delete, +#media-items a.delete-permanently, +#nav-menu-footer .menu-delete, +#delete-link a.delete { + color: #a00; +} + +abbr.required, +span.required, +.file-error, +.row-actions .delete a:hover, +.row-actions .trash a:hover, +.row-actions .spam a:hover, +.plugins a.delete:hover, +#all-plugins-table .plugins a.delete:hover, +#search-plugins-table .plugins a.delete:hover, +.submitbox .submitdelete:hover, +#media-items a.delete:hover, +#media-items a.delete-permanently:hover, +#nav-menu-footer .menu-delete:hover, +#delete-link a.delete:hover { + color: #dc3232; + border: none; +} + +/*------------------------------------------------------------------------------ + 3.0 - Actions +------------------------------------------------------------------------------*/ + +#major-publishing-actions { + padding: 10px; + clear: both; + border-top: 1px solid #ddd; + background: #f5f5f5; +} + +#delete-action { + float: right; + line-height: 28px; +} + +#delete-link { + line-height: 28px; + vertical-align: middle; + text-align: right; + margin-right: 8px; +} + +#delete-link a { + text-decoration: none; +} + +#publishing-action { + text-align: left; + float: left; + line-height: 23px; +} + +#publishing-action .spinner { + float: right; +} + +#misc-publishing-actions { + padding: 6px 0 0; +} + +.misc-pub-section { + padding: 6px 10px 8px; +} + +.misc-pub-filename { + word-wrap: break-word; +} + +#minor-publishing-actions { + padding: 10px 10px 0 10px; + text-align: left; +} + +#save-post { + float: right; +} + +.preview { + float: left; +} + +#sticky-span { + margin-right: 18px; +} + +.approve, +.unapproved .unapprove { + display: none; +} + +.unapproved .approve, +.spam .approve, +.trash .approve { + display: inline; +} + +td.action-links, +th.action-links { + text-align: left; +} + +#misc-publishing-actions .notice { + margin-right: 10px; + margin-left: 10px; +} + +/* Filter bar */ +.wp-filter { + display: inline-block; + position: relative; + box-sizing: border-box; + margin: 12px 0 25px; + padding: 0 10px; + width: 100%; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + border: 1px solid #e5e5e5; + background: #fff; + color: #555; + font-size: 13px; +} + +.wp-filter a { + text-decoration: none; +} + +.filter-count { + display: inline-block; + vertical-align: middle; + min-width: 4em; +} + +.title-count, +.filter-count .count { + display: inline-block; + position: relative; + top: -1px; + padding: 4px 10px; + border-radius: 30px; + background: #72777c; + color: #fff; + font-size: 14px; + font-weight: 600; +} + +/* not a part of filter bar, but derived from it, so here for now */ +.title-count { + display: inline; + top: -3px; + margin-right: 5px; + margin-left: 20px; +} + +.filter-items { + float: right; +} + +.filter-links { + display: inline-block; + margin: 0; +} + +.filter-links li { + display: inline-block; + margin: 0; +} + +.filter-links li > a { + display: inline-block; + margin: 0 10px; + padding: 15px 0; + border-bottom: 4px solid #fff; + color: #666; + cursor: pointer; +} + +.filter-links .current { + box-shadow: none; + border-bottom: 4px solid #666; + color: #23282d; +} + +.filter-links li > a:hover, +.filter-links li > a:focus, +.show-filters .filter-links a.current:hover, +.show-filters .filter-links a.current:focus { + color: #00a0d2; +} + +.wp-filter .search-form { + float: left; + margin: 10px 0; +} + +.wp-filter .search-form input[type="search"] { + margin: 0; + padding: 3px 5px; + width: 280px; + max-width: 100%; + font-size: 16px; + font-weight: 300; + line-height: 1.5; +} + +.wp-filter .search-form select { + margin: 0; + height: 32px; + vertical-align: top; +} + +.wp-filter .search-form.search-plugins { + display: inline-block; +} + +.wp-filter .button.drawer-toggle { + margin: 10px 9px 0; + padding: 0 6px 0 10px; + border-color: transparent; + background-color: transparent; + color: #666; + vertical-align: baseline; + box-shadow: none; +} + +.wp-filter .drawer-toggle:before { + content: "\f111"; + margin: 0 0 0 5px; + color: #72777c; + font: normal 16px/1 dashicons; + vertical-align: text-bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-filter .button.drawer-toggle:hover, +.wp-filter .drawer-toggle:hover:before, +.wp-filter .button.drawer-toggle:focus, +.wp-filter .drawer-toggle:focus:before { + background-color: transparent; + color: #00a0d2; +} + +.wp-filter .button.drawer-toggle:hover, +.wp-filter .button.drawer-toggle:focus:active { + border-color: transparent; +} + +.wp-filter .button.drawer-toggle:focus { + border-color: #5b9dd9; +} + +.wp-filter .button.drawer-toggle:active { + background: transparent; + box-shadow: none; + -webkit-transform: none; + transform: none; +} + +.wp-filter .drawer-toggle.current:before { + color: #fff; +} + +.filter-drawer, +.wp-filter .favorites-form { + display: none; + margin: 0 -20px 0 -10px; + padding: 20px; + border-top: 1px solid #eee; + background: #fafafa; + overflow: hidden; +} + +.show-filters .filter-drawer, +.show-favorites-form .favorites-form { + display: block; +} + +.show-filters .filter-links a.current { + border-bottom: none; +} + +.show-filters .wp-filter .button.drawer-toggle { + border-radius: 2px; + background: #72777c; + color: #fff; +} + +.show-filters .wp-filter .drawer-toggle:hover, +.show-filters .wp-filter .drawer-toggle:focus { + background: rgb(46, 162, 204); +} + +.show-filters .wp-filter .drawer-toggle:before { + color: #fff; +} + +.filter-group { + box-sizing: border-box; + position: relative; + float: right; + margin: 0 0 0 1%; + padding: 20px 10px 10px; + width: 24%; + background: #fff; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +.filter-group legend { + position: absolute; + top: 10px; + display: block; + margin: 0; + padding: 0; + font-size: 1em; + font-weight: 600; +} + +.filter-drawer .filter-group-feature { + margin: 28px 0 0; + list-style-type: none; + font-size: 12px; +} + +.filter-drawer .filter-group-feature input, +.filter-drawer .filter-group-feature label { + line-height: 16px; +} + +.filter-drawer .filter-group-feature input { + position: absolute; + margin: 0; +} + +.filter-group .filter-group-feature label { + display: block; + margin: 14px 23px 14px 0px; +} + +.filter-drawer .buttons { + clear: both; + margin-bottom: 20px; +} + +.filter-drawer .filter-group + .buttons { + margin-bottom: 0; + padding-top: 20px; +} + +.filter-drawer .buttons .button span { + display: inline-block; + opacity: 0.8; + font-size: 12px; + text-indent: 10px; +} + +.wp-filter .button.clear-filters { + display: none; + margin-right: 10px; +} + +.wp-filter .button-link.edit-filters { + padding: 0 5px; + line-height: 28px; +} + +.filtered-by { + display: none; + margin: 0; +} + +.filtered-by > span { + font-weight: 600; +} + +.filtered-by a { + margin-right: 10px; +} + +.filtered-by .tags { + display: inline; +} + +.filtered-by .tag { + margin: 0 5px; + padding: 4px 8px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; + font-size: 11px; +} + +.filters-applied .filter-group, +.filters-applied .filter-drawer .buttons, +.filters-applied .filter-drawer br { + display: none !important; +} + +.filters-applied .filtered-by { + display: block; +} + +.filters-applied .filter-drawer { + padding: 20px; +} + +.show-filters .favorites-form, +.show-filters .content-filterable, +.show-filters.filters-applied.loading-content .content-filterable, +.loading-content .content-filterable, +.error .content-filterable { + display: none; +} + +.show-filters.filters-applied .content-filterable { + display: block; +} + +.loading-content .spinner { + display: block; + margin: 40px auto 0; + float: none; +} + +@media only screen and (max-width: 1120px) { + .filter-drawer { + border-bottom: 1px solid #eee; + } + + .filter-group { + margin-bottom: 0; + margin-top: 5px; + width: 100%; + } + + .filter-group li { + margin: 10px 0; + } +} + +@media only screen and (max-width: 1000px) { + .filter-items { + float: none; + } + + .wp-filter .media-toolbar-primary, + .wp-filter .media-toolbar-secondary, + .wp-filter .search-form { + float: none; /* Remove float from media-views.css */ + position: relative; + max-width: 100%; + } +} + +@media only screen and (max-width: 782px) { + .filter-group li { + padding: 0; + width: 50%; + } +} + +@media only screen and (max-width: 320px) { + .filter-count { + display: none; + } + + .wp-filter .drawer-toggle { + margin: 10px 0; + } + + .filter-group li, + .wp-filter .search-form input[type="search"] { + width: 100%; + } +} + +/*------------------------------------------------------------------------------ + 4.0 - Notifications +------------------------------------------------------------------------------*/ + +.notice, +div.updated, +div.error { + background: #fff; + border-right: 4px solid #fff; + box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); + margin: 5px 15px 2px; + padding: 1px 12px; +} + +div[class="update-message"] { /* back-compat for pre-4.6 */ + padding: 0.5em 0 0.5em 12px; +} + +.notice p, +.notice-title, +div.updated p, +div.error p, +.form-table td .notice p { + margin: 0.5em 0; + padding: 2px; +} + +.error a { + text-decoration: underline; +} + +.updated a { + padding-bottom: 2px; +} + +.notice-alt { + box-shadow: none; +} + +.notice-large { + padding: 10px 20px; +} + +.notice-title { + display: inline-block; + color: #23282d; + font-size: 18px; +} + +.wp-core-ui .notice.is-dismissible { + padding-left: 38px; + position: relative; +} + +.notice-dismiss { + position: absolute; + top: 0; + left: 1px; + border: none; + margin: 0; + padding: 9px; + background: none; + color: #72777c; + cursor: pointer; +} + +.notice-dismiss:hover:before, +.notice-dismiss:active:before, +.notice-dismiss:focus:before { + color: #c00; +} + +.notice-dismiss:focus { + outline: none; + box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 .notice-dismiss:focus { + outline: 1px solid #5b9dd9; +} + +.notice-success, +div.updated { + border-right-color: #46b450; +} + +.notice-success.notice-alt { + background-color: #ecf7ed; +} + +.notice-warning { + border-right-color: #ffb900; +} + +.notice-warning.notice-alt { + background-color: #fff8e5; +} + +.notice-error, +div.error { + border-right-color: #dc3232; +} + +.notice-error.notice-alt { + background-color: #fbeaea; +} + +.notice-info { + border-right-color: #00a0d2; +} + +.notice-info.notice-alt { + background-color: #e5f5fa; +} + +.update-message p:before, +.updating-message p:before, +.updated-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.updated-message:before, +.button.installed:before, +.button.installing:before { + display: inline-block; + font: normal 20px/1 'dashicons'; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.wrap .notice, +.wrap div.updated, +.wrap div.error, +.media-upload-form .notice, +.media-upload-form div.error { + margin: 5px 0 15px; +} + +.wrap #templateside .notice { + display: block; + margin: 0; + padding: 5px 8px; + font-weight: 600; + text-decoration: none; +} + +.wrap #templateside span.notice { + margin-right: -12px; +} + +#templateside li.notice a { + padding: 0; +} + +/* Update icon. */ +.update-message p:before, +.updating-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.installing:before { + color: #f56e28; + content: "\f463"; +} + +/* Spins the update icon. */ +.updating-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.installing:before { + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +/* Updated icon (check mark). */ +.updated-message p:before, +.installed p:before, +.button.updated-message:before { + color: #79ba49; + content: '\f147'; +} + +/* Error icon. */ +.update-message.notice-error p:before { + color: #dc3232; + content: "\f534"; +} + +.wrap .notice p:before, +.import-php .updating-message:before { + margin-left: 6px; + vertical-align: bottom; +} + +#update-nag, +.update-nag { + display: inline-block; + line-height: 19px; + padding: 11px 15px; + font-size: 14px; + text-align: right; + margin: 25px 2px 0 20px; + background-color: #fff; + border-right: 4px solid #ffba00; + box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1); +} + +ul#dismissed-updates { + display: none; +} + +form.upgrade { + margin-top: 8px; +} + +form.upgrade .hint { + font-style: italic; + font-size: 85%; + margin: -0.5em 0 2em 0; +} + +.update-php .spinner { + float: none; + margin: -4px 0; +} + +#ajax-loading, +.ajax-loading, +.ajax-feedback, +.imgedit-wait-spin, +.list-ajax-loading { /* deprecated */ + visibility: hidden; +} + +#ajax-response.alignleft { + margin-right: 2em; +} + +.button.updating-message:before, +.button.updated-message:before, +.button.installed:before, +.button.installing:before { + margin: 3px -2px 0 5px; +} + +.button-primary.updating-message:before { + color: #fff; +} + +.button-primary.updated-message:before { + color: #66c6e4; +} + +.button.updated-message { + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +@media aural { + .wrap .notice p:before, + .button.installing:before, + .button.installed:before, + .update-message p:before { + speak: none; + } +} + + +/* @todo: this does not need its own section anymore */ +/*------------------------------------------------------------------------------ + 6.0 - Admin Header +------------------------------------------------------------------------------*/ +#adminmenu a, +#taglist a, +#catlist a { + text-decoration: none; +} + +/*------------------------------------------------------------------------------ + 6.1 - Screen Options Tabs +------------------------------------------------------------------------------*/ + +#screen-options-wrap, +#contextual-help-wrap { + margin: 0; + padding: 8px 20px 12px; + position: relative; +} + +#contextual-help-wrap { + overflow: auto; + margin-right: 0 !important; +} + +#screen-meta-links { + margin: 0 0 0 20px; +} + +/* screen options and help tabs revert */ +#screen-meta { + display: none; + margin: 0 0px -1px 20px; + position: relative; + background-color: #fff; + border: 1px solid #ddd; + border-top: none; + box-shadow: 0 1px 0 rgba(0,0,0,.025); +} + +#screen-options-link-wrap, +#contextual-help-link-wrap { + float: left; + height: 28px; + margin: 0 6px 0 0; + border: 1px solid #ddd; + border-top: none; + background: #fff; + box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1); +} + +#screen-meta-links .screen-meta-toggle { + position: relative; + top: 0; +} + +#screen-meta-links .show-settings { + border: 0; + background: none; + border-radius: 0; + color: #72777c; + line-height: 1.7; + padding: 3px 16px 3px 6px; +} + +#screen-meta-links .show-settings:hover, +#screen-meta-links .show-settings:active, +#screen-meta-links .show-settings:focus { + color: #32373c; +} + +#screen-meta-links .show-settings:active { + box-shadow: none; + -webkit-transform: none; + transform: none; +} + +#screen-meta-links .show-settings:after { + left: 0; + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0 0 0 5px; + bottom: 2px; + position: relative; + vertical-align: bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #72777c; +} + +#screen-meta-links .screen-meta-active:after { + content: "\f142"; +} + +/* end screen options and help tabs */ + +.toggle-arrow { + background-repeat: no-repeat; + background-position: top right; + background-color: transparent; + height: 22px; + line-height: 22px; + display: block; +} + +.toggle-arrow-active { + background-position: bottom right; +} + +#screen-options-wrap h5, /* Back-compat for old plugins */ +#screen-options-wrap legend, +#contextual-help-wrap h5 { + margin: 0; + padding: 8px 0; + font-size: 13px; + font-weight: 600; +} + +.ie8 #screen-options-wrap legend { + color: inherit; +} + +.metabox-prefs label { + display: inline-block; + padding-left: 15px; + line-height: 30px; +} + +#number-of-columns { + display: inline-block; + vertical-align: middle; + line-height: 30px; +} + +.metabox-prefs input[type=checkbox] { + margin-top: 0; + margin-left: 6px; +} + +.metabox-prefs label input, +.metabox-prefs label input[type=checkbox] { + margin: -4px 0 0 5px; +} + +.metabox-prefs .columns-prefs label input { + margin: -1px 0 0 2px; +} + +.metabox-prefs label a { + display: none; +} + +.metabox-prefs .screen-options input, +.metabox-prefs .screen-options label { + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.metabox-prefs .screen-options .screen-per-page { + margin-left: 15px; +} + +.metabox-prefs .screen-options label { + line-height: 28px; + padding-left: 0; +} + +.screen-options + .screen-options { + margin-top: 10px; +} + +.metabox-prefs .submit { + margin-top: 1em; + padding: 0; +} + +/*------------------------------------------------------------------------------ + 6.2 - Help Menu +------------------------------------------------------------------------------*/ + +#contextual-help-wrap { + padding: 0; +} + +#contextual-help-columns { + position: relative; +} + +#contextual-help-back { + position: absolute; + top: 0; + bottom: 0; + right: 150px; + left: 170px; + border: 1px solid #e1e1e1; + border-top: none; + border-bottom: none; + background: #f6fbfd; +} + +#contextual-help-wrap.no-sidebar #contextual-help-back { + left: 0; + border-left-width: 0; + border-bottom-left-radius: 2px; +} + +.contextual-help-tabs { + float: right; + width: 150px; + margin: 0; +} + +.contextual-help-tabs ul { + margin: 1em 0; +} + +.contextual-help-tabs li { + margin-bottom: 0; + list-style-type: none; + border-style: solid; + border-width: 0 2px 0 0; + border-color: transparent; +} + +.contextual-help-tabs a { + display: block; + padding: 5px 12px 5px 5px; + line-height: 18px; + text-decoration: none; + border: 1px solid transparent; + border-left: none; + border-right: none; +} + +.contextual-help-tabs a:hover { + color: #32373c; +} + +.contextual-help-tabs .active { + padding: 0; + margin: 0 0 0 -1px; + border-right: 2px solid #00a0d2; + background: #f6fbfd; + box-shadow: 0 2px 0 rgba(0,0,0,0.02), 0 1px 0 rgba(0,0,0,0.02); +} + +.contextual-help-tabs .active a { + border-color: #e1e1e1; + color: #32373c; +} + +.contextual-help-tabs-wrap { + padding: 0 20px; + overflow: auto; +} + +.help-tab-content { + display: none; + margin: 0 0 12px 22px; + line-height: 1.6em; +} + +.help-tab-content.active { + display: block; +} + +.help-tab-content ul li { + list-style-type: disc; + margin-right: 18px; +} + +.contextual-help-sidebar { + width: 150px; + float: left; + padding: 0 12px 0 8px; + overflow: auto; +} + +/*------------------------------------------------------------------------------ + 8.0 - Layout Blocks +------------------------------------------------------------------------------*/ + +html.wp-toolbar { + padding-top: 32px; + box-sizing: border-box; +} + +.widefat th, +.widefat td { + color: #555; +} + +.widefat th, +.widefat thead td, +.widefat tfoot td { + font-weight: 400; +} + +.widefat thead tr th, +.widefat thead tr td, +.widefat tfoot tr th, +.widefat tfoot tr td { + color: #32373c; +} + +.widefat td p { + margin: 2px 0 0.8em; +} + +.widefat p, +.widefat ol, +.widefat ul { + color: #32373c; +} + +.widefat .column-comment p { + margin: 0.6em 0; +} + +.widefat .column-comment ul { + list-style: initial; + margin-right: 2em; +} + +/* Screens with postboxes */ +.postbox-container { + float: right; +} + +.postbox-container .meta-box-sortables { + box-sizing: border-box; +} + +#wpbody-content .metabox-holder { + padding-top: 10px; +} + +.metabox-holder .postbox-container .empty-container { + border: 3px dashed #b4b9be; + height: 250px; + position: relative; +} + +.metabox-holder .postbox-container .empty-container:after { + content: attr(data-emptystring); + margin: auto; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + height: 1em; + width: 200px; + text-align: center; + color: #ccc; + font-size:18px; + display: none; +} + +.metabox-holder.columns-1 .postbox-container .empty-container, +.columns-2 #postbox-container-3 .empty-container, +.columns-2 #postbox-container-4 .empty-container, +.columns-3 #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +#post-body-content { + width: 100%; + min-width: 463px; + float: right; +} + +#post-body.columns-2 #postbox-container-1 { + float: left; + margin-left: -300px; + width: 280px; +} + +#post-body.columns-2 #side-sortables { + min-height: 250px; +} + +/* one column on the dash */ +@media only screen and (max-width: 799px) { + #wpbody-content .metabox-holder .postbox-container .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } +} + +.js .widget .widget-top, +.js .postbox .hndle { + cursor: move; +} + +.hndle a { + font-size: 11px; + font-weight: 400; +} + +.postbox .handlediv { + display: none; + float: left; + width: 36px; + height: 36px; + margin: 0; + padding: 0; + border: 0; + background: none; + cursor: pointer; +} + +.js .postbox .handlediv { + display: block; +} + +.sortable-placeholder { + border: 1px dashed #b4b9be; + margin-bottom: 20px; +} + +.postbox, +.stuffbox { + margin-bottom: 20px; + padding: 0; + line-height: 1; +} + +/* user-select is not a part of the CSS standard - may change behavior in the future */ +.postbox .hndle, +.stuffbox .hndle { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.postbox .inside, +.stuffbox .inside { + padding: 0 12px 12px; + line-height: 1.4em; + font-size: 13px; +} + +.postbox .inside { + margin: 11px 0; + position: relative; +} + +.postbox .inside > p:last-child, +.rss-widget ul li:last-child { + margin-bottom: 1px !important; +} + +.postbox.closed h3 { + border: none; + box-shadow: none; +} + +.postbox table.form-table { + margin-bottom: 0; +} + +.postbox table.widefat { + box-shadow: none; +} + +.temp-border { + border: 1px dotted #ccc; +} + +.columns-prefs label { + padding: 0 0 0 10px; +} + +/* @todo: what is this doing here */ +#dashboard_right_now .versions .b, +#post-status-display, +#post-visibility-display, +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover, +.media-item .percent, +.plugins .name, +#pass-strength-result.strong, +#pass-strength-result.short, +#ed_reply_toolbar #ed_reply_strong, +.item-controls .item-order a, +.feature-filter .feature-name { + font-weight: 600; +} + +/*------------------------------------------------------------------------------ + 21.0 - Admin Footer +------------------------------------------------------------------------------*/ + +#wpfooter { + position: absolute; + bottom: 0; + right: 0; + left: 0; + padding: 10px 20px; + color: #555d66; +} + +#wpfooter p { + font-size: 13px; + margin: 0; + line-height: 20px; +} + +#footer-thankyou { + font-style: italic; +} + +/*------------------------------------------------------------------------------ + 25.0 - Tabbed Admin Screen Interface (Experimental) +------------------------------------------------------------------------------*/ + +.nav-tab { + float: right; + border: 1px solid #ccc; + border-bottom: none; + margin-right: 0.5em; /* half the font size so set the font size properly */ + padding: 5px 10px; + font-size: 14px; + line-height: 24px; + font-weight: 600; + background: #e5e5e5; + color: #555; + text-decoration: none; + white-space: nowrap; +} + +h3 .nav-tab, /* Back-compat for pre-4.4 */ +.nav-tab-small .nav-tab { + padding: 5px 14px; + font-size: 12px; + line-height: 16px; +} + +.nav-tab:hover, +.nav-tab:focus { + background-color: #fff; + color: #444; +} + +.nav-tab-active, +.nav-tab:focus:active { + box-shadow: none; +} + +.nav-tab-active { + margin-bottom: -1px; + color: #444; +} + +.nav-tab-active, +.nav-tab-active:hover, +.nav-tab-active:focus, +.nav-tab-active:focus:active { + border-bottom: 1px solid #f1f1f1; + background: #f1f1f1; + color: #000; +} + +h1.nav-tab-wrapper, /* Back-compat for pre-4.4 */ +.wrap h2.nav-tab-wrapper, /* higher specificity to override .wrap > h2:first-child */ +.nav-tab-wrapper { + border-bottom: 1px solid #ccc; + margin: 0; + padding-top: 9px; + padding-bottom: 0; + line-height: inherit; +} + +/* Back-compat for plugins. Deprecated. Use .wp-clearfix instead. */ +.nav-tab-wrapper:not(.wp-clearfix):after { + content: ""; + display: table; + clear: both; + } + +.ie8 .nav-tab-wrapper { + /* contain floats establishing a new block formatting context */ + display: inline-block; + width: 100%; + vertical-align: top; +} + +/*------------------------------------------------------------------------------ + 26.0 - Misc +------------------------------------------------------------------------------*/ + +.spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + display: inline-block; + visibility: hidden; + float: left; + vertical-align: middle; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 4px 10px 0; +} + +.spinner.is-active, +.loading-content .spinner { + visibility: visible; +} + +#template > div { + margin-left: 16em; +} +#template .notice { + margin-top: 1em; + margin-left: 3%; +} +#template .notice p { + width: auto; +} +#template .submit .spinner { + float: none; +} + +.metabox-holder .stuffbox > h3, /* Back-compat for pre-4.4 */ +.metabox-holder .postbox > h3, /* Back-compat for pre-4.4 */ +.metabox-holder h3.hndle, /* Back-compat for pre-4.4 */ +.metabox-holder h2.hndle { + font-size: 14px; + padding: 8px 12px; + margin: 0; + line-height: 1.4; +} + +/* Back-compat for nav-menus screen */ +.nav-menus-php .metabox-holder h3 { + padding: 10px 14px 11px 10px; + line-height: 21px; +} + +#templateside ul li a { + text-decoration: none; +} + +.plugin-install #description, +.plugin-install-network #description { + width: 60%; +} + +table .vers, +table .column-visible, +table .column-rating { + text-align: right; +} + +.attention, +.error-message { + color: #dc3232; + font-weight: 600; +} + +/* Scrollbar fix for bulk upgrade iframe */ +body.iframe { + height: 98%; +} + +/* Upgrader styles, Specific to Language Packs */ +.lp-show-latest p { + display: none; +} +.lp-show-latest p:last-child, +.lp-show-latest .lp-error p { + display: block; +} + +/* - Only used once or twice in all of WP - deprecate for global style +------------------------------------------------------------------------------*/ +.media-icon { + width: 62px; /* icon + border */ + text-align: center; +} + +.media-icon img { + border: 1px solid #e5e5e5; + border: 1px solid rgba(0, 0, 0, 0.07); +} + +#howto { + font-size: 11px; + margin: 0 5px; + display: block; +} + +.importers { + font-size: 16px; + width: auto; +} + +.importers td { + padding-left: 14px; + line-height: 1.5em; +} + +.importers .import-system { + max-width: 250px; +} + +.importers td.desc { + max-width: 500px; +} + +.importer-title, +.importer-desc, +.importer-action { + display: block; +} + +.importer-title { + color: #000; + font-size: 14px; + font-weight: 400; + margin-bottom: .2em; +} + +.importer-action { + line-height: 20px; /* Same as with .updating-message */ + color: #555; + margin-bottom: 1em; +} + +#post-body #post-body-content #namediv h3, /* Back-compat for pre-4.4 */ +#post-body #post-body-content #namediv h2 { + margin-top: 0; +} + +.edit-comment-author { + font-size: 14px; + line-height: 1.4; + font-weight: 600; + color: #222; + margin: 2px 9px 0 0; +} + +#namediv h3 label, /* Back-compat for pre-4.4 */ +#namediv h2 label { + vertical-align: baseline; +} + +#namediv table { + width: 100%; +} + +#namediv td.first { + width: 10px; + white-space: nowrap; +} + +#namediv input { + width: 98%; +} + +#namediv p { + margin: 10px 0; +} + +#submitdiv h3 { + margin-bottom: 0 !important; +} + +/* - Used - but could/should be deprecated with a CSS reset +------------------------------------------------------------------------------*/ +.zerosize { + height: 0; + width: 0; + margin: 0; + border: 0; + padding: 0; + overflow: hidden; + position: absolute; +} + +br.clear { + height: 2px; + line-height: 2px; +} + +.checkbox { + border: none; + margin: 0; + padding: 0; +} + +fieldset { + border: 0; + padding: 0; + margin: 0; +} + +.post-categories { + display: inline; + margin: 0; + padding: 0; +} + +.post-categories li { + display: inline; +} + +/* Star Ratings - Back-compat for pre-3.8 */ +div.star-holder { + position: relative; + height: 17px; + width: 100px; + background: url(../images/stars.png?ver=20121108) repeat-x bottom left; +} + +div.star-holder .star-rating { + background: url(../images/stars.png?ver=20121108) repeat-x top left; + height: 17px; + float: right; +} + +/* Star Ratings */ +.star-rating { + white-space: nowrap; +} +.star-rating .star { + display: inline-block; + width: 20px; + height: 20px; + -webkit-font-smoothing: antialiased; + font-size: 20px; + line-height: 1; + font-family: dashicons; + text-decoration: inherit; + font-weight: 400; + font-style: normal; + vertical-align: top; + transition: color .1s ease-in 0; + text-align: center; + color: #ffb900; +} + +.star-rating .star-full:before { + content: "\f155"; +} + +.star-rating .star-half:before { + content: "\f459"; +} + +.rtl .star-rating .star-half { + -webkit-transform: rotateY(180deg); + transform: rotateY(180deg); +} + +.star-rating .star-empty:before { + content: "\f154"; +} + +div.action-links { + font-weight: 400; + margin: 6px 0 0; +} + +/* Plugin install thickbox */ +#plugin-information { + background: #fff; + position: fixed; + top: 0; + left: 0; + bottom: 0; + right: 0; + height: 100%; + padding: 0; +} + +#plugin-information-scrollable { + overflow: auto; + -webkit-overflow-scrolling: touch; + height: 100%; +} + +#plugin-information-title { + padding: 0 26px; + background: #f5f5f5; + font-size: 22px; + font-weight: 600; + line-height: 56px; + position: relative; + height: 56px; +} + +#plugin-information-title.with-banner { + margin-left: 0; + height: 250px; + background-size: cover; +} + +#plugin-information-title h2 { + font-size: 1em; + font-weight: 600; + padding: 0; + margin: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +#plugin-information-title.with-banner h2 { + position: relative; + font-family: "Helvetica Neue", sans-serif; + display: inline-block; + font-size: 30px; + line-height: 50px; + box-sizing: border-box; + max-width: 100%; + padding: 0 15px; + margin-top: 174px; + color: #fff; + background: rgba( 30, 30, 30, 0.9 ); + text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.4 ); + box-shadow: 0 0 30px rgba( 255, 255, 255, 0.1 ); + border-radius: 8px; +} + +#plugin-information-title div.vignette { + display: none; +} + +#plugin-information-title.with-banner div.vignette { + position: absolute; + display: block; + top: 0; + right: 0; + height: 250px; + width: 100%; + background: transparent; + box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 ); +} + +#plugin-information-tabs { + padding: 0 16px; + position: relative; + left: 0; + right: 0; + min-height: 36px; + font-size: 0; + z-index: 1; + border-bottom: 1px solid #ddd; + background: #f3f3f3; +} + +#plugin-information-tabs a { + position: relative; + display: inline-block; + padding: 9px 10px; + margin: 0; + height: 18px; + line-height: 18px; + font-size: 14px; + text-decoration: none; + transition: none; +} + +#plugin-information-tabs a.current { + margin: 0 -1px -1px; + background: #fff; + border: 1px solid #ddd; + border-bottom-color: #fff; + padding-top: 8px; + color: #32373c; +} + +#plugin-information-tabs.with-banner a.current { + border-top: none; + padding-top: 9px; +} + +#plugin-information-tabs a:active, +#plugin-information-tabs a:focus { + outline: none; +} + +#plugin-information-content { + overflow: hidden; /* equal height column trick */ + background: #fff; + position: relative; + top: 0; + left: 0; + right: 0; + min-height: 100%; + /* Height of title + tabs + install now */ + min-height: calc( 100% - 152px ); +} + +#plugin-information-content.with-banner { + /* Height of banner + tabs + install now */ + min-height: calc( 100% - 346px ); +} + +#section-holder { + position: relative; + top: 0; + left: 250px; + bottom: 0; + right: 0; + margin-left: 250px; /* FYI box */ + padding: 10px 26px; + margin-bottom: -99939px; /* 60px less than the padding below to accommodate footer */ + padding-bottom: 99999px; /* equal height column trick */ +} + +#section-holder .updated { + margin: 16px 0; +} + +#plugin-information .fyi { + float: left; + position: relative; + top: 0; + left: 0; + padding: 16px; + margin-bottom: -99939px; /* 60px less than the padding below to accommodate footer */ + padding-bottom: 99999px; /* equal height column trick */ + width: 217px; + border-right: 1px solid #ddd; + background: #f3f3f3; + color: #666; +} + +#plugin-information .fyi strong { + color: #444; +} + +#plugin-information .fyi h3 { + font-weight: 600; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 24px 0 8px; +} + +#plugin-information .fyi h2 { + font-size: 0.9em; + margin-bottom: 0; + margin-left: 0; +} + +#plugin-information .fyi ul { + padding: 0; + margin: 0; + list-style: none; +} + +#plugin-information .fyi li { + margin: 0 0 10px; +} + +#plugin-information .fyi-description { + margin-top: 0; +} + +#plugin-information .counter-container { + margin: 3px 0; +} + +#plugin-information .counter-label { + float: right; + margin-left: 5px; + min-width: 55px; +} + +#plugin-information .counter-back { + height: 17px; + width: 92px; + background-color: #e5e5e5; + float: right; +} + +#plugin-information .counter-bar { + height: 17px; + background-color: #ffc733; /* slightly lighter than stars due to larger expanse */ + float: right; +} + +#plugin-information .counter-count { + margin-right: 5px; +} + +#plugin-information .fyi ul.contributors { + margin-top: 10px; +} + +#plugin-information .fyi ul.contributors li { + display: inline-block; + margin-left: 8px; + vertical-align: middle; +} + +#plugin-information .fyi ul.contributors li { + display: inline-block; + margin-left: 8px; + vertical-align: middle; +} + +#plugin-information .fyi ul.contributors li img { + vertical-align: middle; + margin-left: 4px; +} + +#plugin-information-footer { + padding: 13px 16px; + position: absolute; + left: 0; + bottom: 0; + right: 0; + height: 33px; /* 33+13+13+1=60 */ + border-top: 1px solid #ddd; + background: #f3f3f3; +} + +/* rtl:ignore */ +#plugin-information .section { + direction: ltr; +} + +/* rtl:ignore */ +#plugin-information .section ul, +#plugin-information .section ol { + list-style-type: disc; + margin-left: 24px; +} + +#plugin-information .section, +#plugin-information .section p { + font-size: 14px; + line-height: 1.7; +} + +#plugin-information #section-screenshots ol { + list-style: none; + margin: 0; +} + +#plugin-information #section-screenshots li img { + vertical-align: text-top; + margin-top: 16px; + max-width: 100%; + width: auto; + height: auto; + box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.3 ); +} + +/* rtl:ignore */ +#plugin-information #section-screenshots li p { + font-style: italic; + padding-left: 20px; +} + +#plugin-information pre { + padding: 7px; + overflow: auto; + border: 1px solid #ccc; +} + +#plugin-information blockquote { + border-right: 2px solid #ddd; + color: #666; + font-style: italic; + margin: 1em 0; + padding: 0 1em 0 0; +} + +/* rtl:ignore */ +#plugin-information .review { + overflow: hidden; /* clearfix */ + width: 100%; + margin-bottom: 20px; + border-bottom: 1px solid #e5e5e5; +} + +#plugin-information .review-title-section { + overflow: hidden; /* clearfix */ +} + +/* rtl:ignore */ +#plugin-information .review-title-section h4 { + display: inline-block; + float: left; + margin: 0 6px 0 0; +} + +#plugin-information .reviewer-info p { + clear: both; + margin: 0; + padding-top: 2px; +} + +/* rtl:ignore */ +#plugin-information .reviewer-info .avatar { + float: left; + margin: 4px 6px 0 0; +} + +/* rtl:ignore */ +#plugin-information .reviewer-info .star-rating { + float: left; +} + +/* rtl:ignore */ +#plugin-information .review-meta { + float: left; + margin-left: 0.75em; +} + +/* rtl:ignore */ +#plugin-information .review-body { + float: left; + width: 100%; +} + +.plugin-version-author-uri { + font-size: 13px; +} + +/* For non-js plugin installation screen ticket #36430. */ +.update-php .button.button-primary { + margin-left: 1em; +} + +@media screen and ( max-width: 771px ) { + #plugin-information-title.with-banner { + height: 100px; + } + + #plugin-information-title.with-banner h2 { + margin-top: 30px; + font-size: 20px; + line-height: 40px; + max-width: 85%; + } + + #plugin-information-title.with-banner div.vignette { + height: 100px; + } + + #plugin-information-tabs { + overflow: hidden; /* clearfix */ + padding: 0; + height: auto; /* let tabs wrap */ + } + + #plugin-information-tabs a.current { + margin-bottom: 0; + border-bottom: none; + } + + #plugin-information .fyi { + float: none; + border: 1px solid #ddd; + position: static; + width: auto; + margin: 26px 26px 0; + padding-bottom: 0; /* reset from the two column height fix */ + } + + #section-holder { + position: static; + margin: 0; + padding-bottom: 70px; /* reset from the two column height fix, plus accommodate footer */ + } + + #plugin-information .fyi h3, + #plugin-information .fyi small { + display: none; + } + + #plugin-information-footer { + padding: 12px 16px 0; + height: 46px; + } +} + +/* Thickbox for the Plugin details modal. */ +#TB_window.plugin-details-modal { + background: #fcfcfc; +} + +#TB_window.plugin-details-modal.thickbox-loading:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + right: 50%; + top: 50%; + z-index: -1; + margin: -10px -10px 0 0; + background: #fcfcfc url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + #TB_window.plugin-details-modal.thickbox-loading:before { + background-image: url(../images/spinner-2x.gif); + } +} + +.plugin-details-modal #TB_title { + float: right; + height: 1px; +} + +.plugin-details-modal #TB_ajaxWindowTitle { + display: none; +} + +.plugin-details-modal #TB_closeWindowButton { + right: auto; + left: -30px; + color: #eee; +} + +.plugin-details-modal #TB_closeWindowButton:hover, +.plugin-details-modal #TB_closeWindowButton:focus { + color: #00a0d2; + outline: none; + box-shadow: none; +} + +.plugin-details-modal .tb-close-icon { + display: none; +} + +.plugin-details-modal #TB_closeWindowButton:after { + content: "\f335"; + font: normal 32px/29px 'dashicons'; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* move plugin install close icon to top on narrow screens */ +@media screen and ( max-width: 830px ) { + .plugin-details-modal #TB_closeWindowButton { + left: 0; + top: -30px; + } +} + +/* @todo: move this. */ +img { + border: none; +} + +/* Metabox collapse arrow indicators */ +.sidebar-name .toggle-indicator:before, +.js .meta-box-sortables .postbox .toggle-indicator:before, +.bulk-action-notice .toggle-indicator:before, +.privacy-text-box .toggle-indicator:before { + content: "\f142"; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.js .widgets-holder-wrap.closed .toggle-indicator:before, +.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before, +.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before, +.privacy-text-box.closed .toggle-indicator:before { + content: "\f140"; +} + +.js .postbox .handlediv .toggle-indicator:before { + margin-top: 4px; + width: 20px; + border-radius: 50%; + text-indent: -1px; /* account for the dashicon alignment */ +} + +.rtl.js .postbox .handlediv .toggle-indicator:before { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.bulk-action-notice .toggle-indicator:before { + line-height: 16px; + vertical-align: top; + color: #72777c; +} + +.js .postbox .handlediv:focus { + box-shadow: none; + outline: none; +} + +.js .postbox .handlediv:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +/* @todo: appears to be Press This only and overridden */ +#photo-add-url-div input[type="text"] { + width: 300px; +} + +/* Theme/Plugin Editor */ +.alignleft h2 { + margin: 0; +} + +#template textarea { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + background: #f9f9f9; + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; +} + +#template textarea, +#template .CodeMirror { + width: 100%; + min-height: 60vh; + height: calc( 100vh - 295px ); + border: 1px solid #ddd; + box-sizing: border-box; +} + +#templateside > h2 { + padding-top: 6px; + padding-bottom: 7px; + margin: 0; +} + +#templateside ol, +#templateside ul { + margin: 0; + padding: 0; +} +#templateside > ul { + box-sizing: border-box; + margin-top: 0; + overflow: auto; + padding: 0; + min-height: 60vh; + height: calc(100vh - 295px); + background-color: #f7f7f7; + border: 1px solid #ddd; + border-right: none; +} +#templateside ul ul { + padding-right: 12px; +} +#templateside > ul > li > ul[role=group] { + padding-right: 0; +} + +/* + * Styles for Theme and Plugin editors. + */ + +/* Hide collapsed items. */ +[role="treeitem"][aria-expanded="false"] > ul { + display: none; +} + +/* Use arrow dashicons for folder states, but hide from screen readers. */ +[role="treeitem"] span[aria-hidden] { + display: inline; + font-family: dashicons; + font-size: 20px; + position: absolute; + pointer-events: none; +} +[role="treeitem"][aria-expanded="false"] > .folder-label .icon:after { + content: "\f141"; +} +[role="treeitem"][aria-expanded="true"] > .folder-label .icon:after { + content: "\f140"; +} +[role="treeitem"] .folder-label { + display: block; + padding: 3px 12px 3px 3px; + cursor: pointer; +} + +/* Remove outline, and create our own focus and hover styles */ +[role="treeitem"] { + outline: 0; +} +[role="treeitem"] .folder-label.focus { + color: #124964; + box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); +} +[role="treeitem"].hover, +[role="treeitem"] .folder-label.hover { + background-color: #eaeaea; +} + +.tree-folder { + margin: 0; + position: relative; +} +[role="treeitem"] li { + position: relative; +} + +/* Styles for folder indicators/depth */ +.tree-folder .tree-folder::after { + content: ' '; + display: block; + position: absolute; + right: 2px; + border-right: 1px solid #ccc; + top: -13px; + bottom: 10px; +} +.tree-folder > li::before { + content: ' '; + position: absolute; + display: block; + border-right: 1px solid #ccc; + right: 2px; + top: -5px; + height: 18px; + width: 7px; + border-bottom: 1px solid #ccc; +} +.tree-folder > li::after { + content: ' '; + position: absolute; + display: block; + border-right: 1px solid #ccc; + right: 2px; + bottom: -7px; + top: 0; +} + +/* current-file needs to adjustment for .notice styles */ +#templateside .current-file { + margin: -4px 0 -2px; +} +.tree-folder > .current-file::before { + right: 4px; + height: 15px; + width: 0px; + border-right: none; + top: 3px; +} +.tree-folder > .current-file::after { + bottom: -4px; + height: 7px; + right: 2px; + top: auto; +} + +/* Lines shouldn't continue on last item */ +.tree-folder > li:last-child::after, +.tree-folder li:last-child > .tree-folder::after { + display: none; +} + + +#theme-plugin-editor-label { + display: inline-block; + margin-bottom: 1em; + font-weight: 600; +} + +/* rtl:ignore */ +#template textarea, +#docs-list { + direction: ltr; +} + +.fileedit-sub #theme, +.fileedit-sub #plugin { + max-width: 40%; +} +.fileedit-sub .alignright { + text-align: left; +} + +#template p { + width: 97%; +} + +#file-editor-linting-error { + margin-top: 1em; + margin-bottom: 1em; +} +#file-editor-linting-error > .notice { + margin: 0; + display: inline-block; +} +#file-editor-linting-error > .notice > p { + width: auto; +} +#template .submit { + margin-top: 1em; + padding: 0; +} + +#template .submit input[type=submit][disabled] { + cursor: not-allowed; +} +#templateside { + float: left; + width: 16em; + word-wrap: break-word; +} + +#postcustomstuff p.submit { + margin: 0; +} + +#templateside h4 { + margin: 1em 0 0; +} + +#templateside li { + margin: 4px 0; +} + +#templateside li:not(.howto) a, +.theme-editor-php .highlight { + display: block; + padding: 3px 12px 3px 0; + text-decoration: none; +} + +#templateside li:not(.howto) > a:first-of-type { + padding-top: 0; +} + +#templateside li.howto { + padding: 6px 12px 12px 12px; +} + +.theme-editor-php .highlight { + margin: -3px -12px -3px 3px; +} + +#templateside .highlight { + border: none; + font-weight: 600; +} + +.nonessential { + color: #666; + font-size: 11px; + font-style: italic; + padding-right: 12px; +} + +#documentation { + margin-top: 10px; +} + +#documentation label { + line-height: 22px; + vertical-align: baseline; + font-weight: 600; +} + +.fileedit-sub { + padding: 10px 0 8px; + line-height: 180%; +} + +#file-editor-warning .file-editor-warning-content { + margin: 25px; +} + +/* @todo: can we use a common class for these? */ +.nav-menus-php .item-edit:before, +.widget-top .widget-action .toggle-indicator:before, +.control-section .accordion-section-title:after, +.accordion-section-title:after { + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.widget-top .widget-action .toggle-indicator:before { + padding: 1px 0px 1px 2px; + border-radius: 50%; +} + +.handlediv, +.postbox .handlediv.button-link, +.item-edit, +.toggle-indicator, +.accordion-section-title:after { + color: #72777c; +} + +.widget-action { + color: #555d66; /* #fafafa background in the Widgets screen */ +} + +.widget-top:hover .widget-action, +.widget-action:focus, +.handlediv:hover, +.handlediv:focus, +.postbox .handlediv.button-link:hover, +.postbox .handlediv.button-link:focus, +.item-edit:hover, +.item-edit:focus, +.sidebar-name:hover .toggle-indicator, +.accordion-section-title:hover:after { + color: #23282d; +} + +.widget-top .widget-action:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30,140,190,.8); +} + +.control-section .accordion-section-title:after, +.accordion-section-title:after { + float: left; + left: 20px; + top: -2px; +} + +.control-section.open .accordion-section-title:after, +#customize-info.open .accordion-section-title:after, +.nav-menus-php .menu-item-edit-active .item-edit:before, +.widget.open .widget-top .widget-action .toggle-indicator:before { + content: "\f142"; +} + +/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-draggable-handle, +.ui-sortable-handle { + touch-action: none; +} + +/* Accordion */ +.accordion-section { + border-bottom: 1px solid #ddd; + margin: 0; +} + +.accordion-section.open .accordion-section-content, +.no-js .accordion-section .accordion-section-content { + display: block; +} + +.accordion-section.open:hover { + border-bottom-color: #ddd; +} + +.accordion-section-content { + display: none; + padding: 10px 20px 15px; + overflow: hidden; + background: #fff; +} + +.accordion-section-title { + margin: 0; + padding: 12px 15px 15px; + position: relative; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.js .accordion-section-title { + cursor: pointer; +} + +.js .accordion-section-title:after { + position: absolute; + top: 12px; + left: 10px; + z-index: 1; +} + +.accordion-section-title:focus { + outline: none; +} + +.accordion-section-title:hover:after, +.accordion-section-title:focus:after { + border-color: #a0a5aa transparent; +} + +.cannot-expand .accordion-section-title { + cursor: auto; +} + +.cannot-expand .accordion-section-title:after { + display: none; +} + +.control-section .accordion-section-title, +.customize-pane-child .accordion-section-title { + border-right: none; + border-left: none; + padding: 10px 14px 11px 10px; + line-height: 21px; + background: #fff; +} + +.control-section .accordion-section-title:after, +.customize-pane-child .accordion-section-title:after { + top: calc(50% - 10px); /* Arrow height is 20px, so use half of that to vertically center */ +} + +.js .control-section:hover .accordion-section-title, +.js .control-section .accordion-section-title:hover, +.js .control-section.open .accordion-section-title, +.js .control-section .accordion-section-title:focus { + color: #23282d; + background: #f5f5f5; +} + +.control-section.open .accordion-section-title { + /* When expanded */ + border-bottom: 1px solid #ddd; +} + +/* Edit Site */ +.network-admin .edit-site-actions { + margin-top: 0; +} + +/* My Sites */ +.my-sites { + display: block; + overflow: auto; + zoom: 1; +} + +.my-sites li { + display: block; + padding: 8px 3%; + min-height: 130px; + margin: 0; +} + +@media only screen and (max-width: 599px) { + .my-sites li { + min-height: 0; + } +} + +@media only screen and (min-width: 600px) { + .my-sites.striped li { + background-color: #fff; + position: relative; + } + .my-sites.striped li:after { + content: ""; + width: 1px; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #ccc; + } + +} +@media only screen and (min-width: 600px) and (max-width: 699px) { + .my-sites li{ + float: right; + width: 44%; + } + .my-sites.striped li { + background-color: #fff; + } + .my-sites.striped li:nth-of-type(2n+1) { + clear: right; + } + .my-sites.striped li:nth-of-type(2n+2):after { + content: none; + } + .my-sites li:nth-of-type(4n+1), + .my-sites li:nth-of-type(4n+2) { + background-color: #f9f9f9; + } + +} + +@media only screen and (min-width: 700px) and (max-width: 1199px) { + .my-sites li { + float: right; + width: 27.333333%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(3n+3):after { + content: none; + } + .my-sites li:nth-of-type(6n+1), + .my-sites li:nth-of-type(6n+2), + .my-sites li:nth-of-type(6n+3) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1200px) and (max-width: 1399px) { + .my-sites li { + float: right; + width: 21%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(4n+1) { + clear: right; + } + .my-sites.striped li:nth-of-type(4n+4):after { + content: none; + } + .my-sites li:nth-of-type(8n+1), + .my-sites li:nth-of-type(8n+2), + .my-sites li:nth-of-type(8n+3), + .my-sites li:nth-of-type(8n+4) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1400px) and (max-width: 1599px) { + .my-sites li { + float: right; + width: 16%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(5n+1) { + clear: right; + } + .my-sites.striped li:nth-of-type(5n+5):after { + content: none; + } + .my-sites li:nth-of-type(10n+1), + .my-sites li:nth-of-type(10n+2), + .my-sites li:nth-of-type(10n+3), + .my-sites li:nth-of-type(10n+4), + .my-sites li:nth-of-type(10n+5) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1600px) { + .my-sites li { + float: right; + width: 12.666666%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(6n+1) { + clear: right; + } + .my-sites.striped li:nth-of-type(6n+6):after { + content: none; + } + .my-sites li:nth-of-type(12n+1), + .my-sites li:nth-of-type(12n+2), + .my-sites li:nth-of-type(12n+3), + .my-sites li:nth-of-type(12n+4), + .my-sites li:nth-of-type(12n+5), + .my-sites li:nth-of-type(12n+6) { + background-color: #f9f9f9; + } +} + +.my-sites li a { + text-decoration: none; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + /* Back-compat for pre-3.8 */ + div.star-holder, + div.star-holder .star-rating { + background: url(../images/stars-2x.png?ver=20121108) repeat-x bottom left; + background-size: 21px 37px; + } + + .spinner { + background-image: url(../images/spinner-2x.gif); + } + + /* @todo: evaluate - most of these were likely replaced by dashicons */ + .curtime #timestamp, + #screen-meta-links a.show-settings, + .widget-top .widget-action, + .widget-top .widget-action:hover, + .sidebar-name .toggle-indicator, + .sidebar-name:hover .toggle-indicator, + .meta-box-sortables .postbox:hover .handlediv, + #bulk-titles div a, + #bulk-titles div a:hover { + background: none !important; + } + +} + +@-ms-viewport { + width: device-width; +} + +@media screen and ( max-width: 782px ) { + html.wp-toolbar { + padding-top: 46px; + } + + body { + min-width: 240px; + overflow-x: hidden; + } + + body * { + -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important; + } + + #wpcontent { + position: relative; + margin-right: 0; + padding-right: 10px; + } + + #wpbody-content { + padding-bottom: 100px; + } + + .wrap { + margin-left: 12px; + margin-right: 0; + } + + /* categories */ + #col-left, + #col-right { + float: none; + width: auto; + } + + #col-left .col-wrap, + #col-right .col-wrap { + padding: 0; + } + + /* Hidden Elements */ + #screen-meta, + #screen-meta-links, + #collapse-menu, + .post-format-select { + display: none !important; + } + + .wrap h1.wp-heading-inline { + margin-bottom: 0.5em; + } + + .wrap .add-new-h2, /* deprecated */ + .wrap .add-new-h2:active, /* deprecated */ + .wrap .page-title-action, + .wrap .page-title-action:active { + padding: 10px 15px; + font-size: 14px; + white-space: nowrap; + } + + /* Feedback Messages */ + .notice, + .wrap div.updated, + .wrap div.error, + .media-upload-form div.error { + margin: 20px 0 10px 0; + padding: 5px 10px; + font-size: 14px; + line-height: 175%; + } + + .wp-core-ui .notice.is-dismissible { + padding-left: 46px; + } + + .notice-dismiss { + padding: 13px; + } + + .wrap .icon32 + h2 { + margin-top: -2px; + } + + .wp-responsive-open #wpbody { + left: -16em; + } + + code { + word-wrap: break-word; + } + + /* General Metabox */ + .postbox { + font-size: 14px; + } + + .metabox-holder h3.hndle, /* Back-compat for pre-4.4 */ + .metabox-holder .stuffbox > h3, /* Back-compat for pre-4.4 */ + .metabox-holder .postbox > h3, /* Back-compat for pre-4.4 */ + .metabox-holder h2 { + padding: 12px; + } + + .postbox .handlediv { + margin-top: 3px; + } + + /* Subsubsub Nav */ + .subsubsub { + font-size: 16px; + text-align: center; + margin-bottom: 15px; + } + + /* Theme/Plugin File Editor */ + + #template textarea, + #template .CodeMirror { + box-sizing: border-box; + } + + #templateside { + float: none; + width: auto; + } + + #templateside > ul { + border-right: 1px solid #ddd; + } + + #templateside li { + margin: 0; + } + + #templateside li:not(.howto) a { + display: block; + padding: 5px; + } + #templateside li.howto { + padding: 12px; + } + + #templateside .highlight { + padding: 5px; + margin-right: -5px; + margin-top: -5px; + } + + #template > div, + #template .notice { + float: none; + margin: 1em 0; + width: auto; + } + + #template .CodeMirror, + #template textarea { + width: 100%; + } + + #templateside ul ul { + padding-right: 1.5em; + } + [role="treeitem"] .folder-label { + display: block; + padding: 5px; + } + .tree-folder > li::before, + .tree-folder > li::after, + .tree-folder .tree-folder::after { + right: -8px; + } + .tree-folder > li::before { + top: 0px; + height: 13px; + } + .tree-folder > .current-file::before { + right: -5px; + top: 7px; + width: 4px; + } + .tree-folder > .current-file::after { + height: 9px; + right: -8px; + } + .wrap #templateside span.notice { + margin-right: -5px; + width: 100%; + } + + .fileedit-sub .alignright { + float: right; + margin-top: 15px; + width: 100%; + text-align: right; + } + + .fileedit-sub .alignright label { + display: block; + } + + .fileedit-sub #theme, + .fileedit-sub #plugin { + margin-right: 0; + max-width: 70%; + } + + .fileedit-sub input[type="submit"] { + margin-bottom: 0px; + padding: 8px 18px; + } + + #documentation label[for="docs-list"] { + display: block; + } + + #documentation select[name="docs-list"] { + margin-right: 0; + max-width: 60%; + } + + #documentation input[type="button"] { + margin-bottom: 0; + padding: 8px 18px; + } + + #wpfooter { + display: none; + } + + #comments-form .checkforspam { + display: none; + } + + .edit-comment-author { + margin: 2px 0 0; + } + + .filter-drawer .filter-group-feature input, + .filter-drawer .filter-group-feature label { + line-height: 25px; + } + + .filter-drawer .filter-group-feature label { + margin-right: 32px; + } + + .wp-filter .button.drawer-toggle { + font-size: 13px; + line-height: 26px; + height: 28px; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Disable horizontal scroll when responsive menu is open + since we push the main content off to the right. */ + #wpwrap.wp-responsive-open { + overflow-x: hidden; + } + + html.wp-toolbar { + padding-top: 0; + } + + #wpbody { + padding-top: 46px; + } + + /* Keep full-width boxes on Edit Post page from causing horizontal scroll */ + div#post-body.metabox-holder.columns-1 { + overflow-x: hidden; + } + + h1.nav-tab-wrapper, + .wrap h2.nav-tab-wrapper, + .nav-tab-wrapper { + border-bottom: 0; + } + + h1 .nav-tab, + h2 .nav-tab, + h3 .nav-tab { + margin: 10px 0 0 10px; + border-bottom: 1px solid #ccc; + } +} + +@media screen and (max-width: 320px) { + /* Prevent default center alignment and larger font for the Right Now widget when + the network dashboard is viewed on a small mobile device. */ + #network_dashboard_right_now .subsubsub { + font-size: 14px; + text-align: right; + } +} diff --git a/backend/wp-admin/css/common-rtl.min.css b/backend/wp-admin/css/common-rtl.min.css new file mode 100644 index 0000000..c3a9bc4 --- /dev/null +++ b/backend/wp-admin/css/common-rtl.min.css @@ -0,0 +1,9 @@ +/*! This file is auto-generated */ +.button.updated-message,a{transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}#ajax-loading,.ajax-feedback,.ajax-loading,.imgedit-wait-spin,.list-ajax-loading,.spinner,.wp-header-end{visibility:hidden}.filter-group,.postbox-container .meta-box-sortables,.wp-filter,html.wp-toolbar{box-sizing:border-box}#docs-list,#plugin-information .section,#template textarea,.code,.ltr,code{direction:ltr}#wpwrap{height:auto;min-height:100%;width:100%;position:relative;-webkit-font-smoothing:subpixel-antialiased}#wpcontent{height:100%;padding-right:20px}#wpcontent,#wpfooter{margin-right:160px}.folded #wpcontent,.folded #wpfooter{margin-right:36px}#wpbody-content{padding-bottom:65px;float:right;width:100%;overflow:visible!important}.inner-sidebar{float:left;clear:left;display:none;width:281px;position:relative}.columns-2 .inner-sidebar{margin-left:auto;width:286px;display:block}.columns-2 .inner-sidebar #side-sortables,.inner-sidebar #side-sortables{min-height:300px;width:280px;padding:0}.has-right-sidebar .inner-sidebar{display:block}.has-right-sidebar #post-body{float:right;clear:right;width:100%;margin-left:-2000px}.has-right-sidebar #post-body-content{margin-left:300px;float:none;width:auto}#col-left{float:right;width:35%}#col-right{float:left;width:65%}#col-left .col-wrap{padding:0 0 0 6px}#col-right .col-wrap{padding:0 6px 0 0}.alignleft{float:right}.alignright{float:left}#publishing-action .spinner,#save-post,.subsubsub{float:right}.textleft{text-align:right}.textright{text-align:left}.clear{clear:both}.wp-clearfix:after{content:"";display:table;clear:both}.screen-reader-text,.screen-reader-text span,.ui-helper-hidden-accessible{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}#templateside,.misc-pub-filename,.pre,.widefat *{word-wrap:break-word}.screen-reader-shortcut{position:absolute;top:-1000em}.screen-reader-shortcut:focus{right:6px;top:-25px;height:auto;width:auto;display:block;font-size:14px;font-weight:600;padding:15px 23px 14px;background:#f1f1f1;color:#0073aa;z-index:100000;line-height:normal;box-shadow:0 0 2px 2px rgba(0,0,0,.6);text-decoration:none;outline:0}.hidden,.js .closed .inside,.js .hide-if-js,.js .wp-core-ui .hide-if-js,.js.wp-core-ui .hide-if-js,.no-js .hide-if-no-js,.no-js .wp-core-ui .hide-if-no-js,.no-js.wp-core-ui .hide-if-no-js{display:none}#menu-management .menu-edit,#menu-settings-column .accordion-container,.comment-ays,.feature-filter,.imgedit-group,.manage-menus,.menu-item-handle,.popular-tags,.stuffbox,.widget-inside,.widget-top,.widgets-holder-wrap,.wp-editor-container,p.popular-tags,table.widefat{border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04)}.comment-ays,.feature-filter,.imgedit-group,.popular-tags,.stuffbox,.widgets-holder-wrap,.wp-editor-container,p.popular-tags,table.widefat{background:#fff}body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4em;min-width:600px}body.iframe{min-width:0;padding-top:1px}body.modal-open{overflow:hidden}body.mobile.modal-open #wpwrap{overflow:hidden;position:fixed;height:100%}iframe,img{border:0}td{font-family:inherit;font-size:inherit;font-weight:inherit;line-height:inherit}a{color:#0073aa}a,div{outline:0}a:active,a:hover{color:#00a0d2}.wp-person a:focus .gravatar,a:focus,a:focus .media-icon img{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}h1,h2,h3{color:#23282d}.ie8 a:focus{outline:#5b9dd9 solid 1px}#adminmenu a:focus,.screen-reader-text:focus{box-shadow:none;outline:0}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}p{font-size:13px;line-height:1.5;margin:1em 0}blockquote{margin:1em}dd,li{margin-bottom:6px}h1,h2,h3,h4,h5,h6{display:block;font-weight:600}h1{font-size:2em;margin:.67em 0}h2,h3{font-size:1.3em;margin:1em 0}.update-core-php h2{margin-top:2em}.update-messages h2,.update-php h2,h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.67em;margin:2.33em 0}ol,ul{padding:0}ul{list-style:none}ol{list-style-type:decimal;margin-right:2em}ul.ul-disc{list-style:disc}ul.ul-square{list-style:square}ol.ol-decimal{list-style:decimal}ol.ol-decimal,ul.ul-disc,ul.ul-square{margin-right:1.8em}ol.ol-decimal>li,ul.ul-disc>li,ul.ul-square>li{margin:0 0 .5em}.code,code{font-family:Consolas,Monaco,monospace;unicode-bidi:embed}code,kbd{padding:3px 5px 2px;margin:0 1px;background:#eaeaea;background:rgba(0,0,0,.07);font-size:13px}.subsubsub{list-style:none;margin:8px 0 0;padding:0;font-size:13px;color:#666}.subsubsub a{line-height:2;padding:.2em;text-decoration:none}.subsubsub a .count,.subsubsub a.current .count{color:#555d66;font-weight:400}.subsubsub a.current{font-weight:600;border:none}.subsubsub li{display:inline-block;margin:0;padding:0;white-space:nowrap}.widefat{border-spacing:0;width:100%;clear:both;margin:0}.widefat a,.widefat button.button-link{text-decoration:none}.widefat td,.widefat th{padding:8px 10px}.widefat thead td,.widefat thead th{border-bottom:1px solid #e1e1e1}.widefat tfoot td,.widefat tfoot th{border-top:1px solid #e1e1e1;border-bottom:none}.widefat .no-items td{border-bottom-width:0}.widefat td{vertical-align:top}.widefat td,.widefat td ol,.widefat td p,.widefat td ul{font-size:13px;line-height:1.5em}.widefat tfoot td,.widefat th,.widefat thead td{text-align:right;line-height:1.3em;font-size:14px}.updates-table td input,.widefat tfoot td input,.widefat th input,.widefat thead td input{margin:0 8px 0 0;padding:0;vertical-align:text-top}.widefat .check-column{width:2.2em;padding:6px 0 25px;vertical-align:top}.updates-table tbody td.check-column,.widefat tbody th.check-column,.widefat tfoot td.check-column,.widefat thead td.check-column{padding:11px 3px 0 0}.widefat tfoot td.check-column,.widefat thead td.check-column{padding-top:4px;vertical-align:middle}.update-php div.error,.update-php div.updated{margin-right:0}.no-js .widefat tfoot .check-column input,.no-js .widefat thead .check-column input{display:none}.column-comments,.column-links,.column-posts,.widefat .num{text-align:center}.widefat th#comments{vertical-align:middle}.wrap{margin:10px 2px 0 20px}.postbox .inside h2,.wrap [class$=icon32]+h2,.wrap h1,.wrap>h2:first-child{font-size:23px;font-weight:400;margin:0;padding:9px 0 4px;line-height:29px}.wrap h1.wp-heading-inline{display:inline-block;margin-left:5px}.wp-header-end{margin:-2px 0 0}.subtitle{margin:0;padding-right:25px;color:#555d66;font-size:14px;font-weight:400;line-height:1}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{margin-right:4px;padding:4px 8px;position:relative;top:-3px;text-decoration:none;border:none;border:1px solid #ccc;border-radius:2px;background:#f7f7f7;text-shadow:none;font-weight:600;font-size:13px;line-height:normal;color:#0073aa;cursor:pointer;outline:0}.wrap .wp-heading-inline+.page-title-action{margin-right:0}.wrap .add-new-h2:hover,.wrap .page-title-action:hover{border-color:#008EC2;background:#00a0d2;color:#fff}.page-title-action:focus{color:#124964}.ac_match,.highlight,.subsubsub a.current{color:#000}.wrap .page-title-action:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.wrap h1.long-header{padding-left:0}.wp-dialog{background-color:#fff}#available-widgets .widget-top:hover,#widgets-left .widget-in-question .widget-top,#widgets-left .widget-top:hover,.widgets-chooser ul,div#widgets-right .widget-top:hover{border-color:#999;box-shadow:0 1px 2px rgba(0,0,0,.1)}.sorthelper{background-color:#ccf3fa}.alternate,.striped>tbody>:nth-child(odd),ul.striped>:nth-child(odd){background-color:#f9f9f9}.bar{background-color:#e8e8e8;border-left-color:#99d}.highlight{background-color:#e4f2fd}.wp-ui-primary{color:#fff;background-color:#32373c}.wp-ui-text-primary{color:#32373c}.wp-ui-highlight{color:#fff;background-color:#1e8cbe}.wp-ui-text-highlight{color:#1e8cbe}.wp-ui-notification{color:#fff;background-color:#d54e21}.wp-ui-text-notification{color:#d54e21}.wp-ui-text-icon{color:#82878c}img.emoji{display:inline!important;border:none!important;height:1em!important;width:1em!important;margin:0 .07em!important;vertical-align:-.1em!important;background:0 0!important;padding:0!important;box-shadow:none!important}#nav-menu-footer,#nav-menu-header,#your-profile #rich_editing,.checkbox,.control-section .accordion-section-title,.menu-item-handle,.postbox .hndle,.side-info,.sidebar-name,.stuffbox .hndle,.widefat tfoot td,.widefat tfoot th,.widefat thead td,.widefat thead th,.widget .widget-top{line-height:1.4em}.menu-item-handle,.widget .widget-top{background:#fafafa;color:#23282d}.postbox .hndle,.stuffbox .hndle{border-bottom:1px solid #eee;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.quicktags,.search{background-color:#ccc;color:#000;font-size:12px}.icon32{display:none}#bulk-titles div a:before,.notice-dismiss:before,.tagchecklist .ntdelbutton .remove-tag-icon:before,.welcome-panel .welcome-panel-close:before{background:0 0;color:#72777c;content:"\f153";display:block;font:400 16px/20px dashicons;speak:none;height:20px;text-align:center;width:20px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.welcome-panel .welcome-panel-close:before{margin:0}#bulk-titles div a:before{margin:1px 0}.tagchecklist .ntdelbutton .remove-tag-icon:before{margin-right:2px;border-radius:50%;color:#0073aa;line-height:1.28}.tagchecklist .ntdelbutton:focus{outline:0}#bulk-titles div a:focus:before,#bulk-titles div a:hover:before,.tagchecklist .ntdelbutton:focus .remove-tag-icon:before,.tagchecklist .ntdelbutton:hover .remove-tag-icon:before,.welcome-panel .welcome-panel-close:focus:before,.welcome-panel .welcome-panel-close:hover:before{color:#c00}.tagchecklist .ntdelbutton:focus .remove-tag-icon:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.key-labels label{line-height:24px}b,strong{font-weight:600}.pre{white-space:pre-wrap}#namediv td.first,.nav-tab,.no-break,.star-rating{white-space:nowrap}.howto{color:#666;font-style:italic;display:block}p.install-help{margin:8px 0;font-style:italic}hr{border:0;border-top:1px solid #ddd;border-bottom:1px solid #fafafa}#all-plugins-table .plugins a.delete,#delete-link a.delete,#media-items a.delete,#media-items a.delete-permanently,#nav-menu-footer .menu-delete,#search-plugins-table .plugins a.delete,.plugins a.delete,.row-actions span.delete a,.row-actions span.spam a,.row-actions span.trash a,.submitbox .submitdelete{color:#a00}#all-plugins-table .plugins a.delete:hover,#delete-link a.delete:hover,#media-items a.delete-permanently:hover,#media-items a.delete:hover,#nav-menu-footer .menu-delete:hover,#search-plugins-table .plugins a.delete:hover,.file-error,.plugins a.delete:hover,.row-actions .delete a:hover,.row-actions .spam a:hover,.row-actions .trash a:hover,.submitbox .submitdelete:hover,abbr.required,span.required{color:#dc3232;border:none}#major-publishing-actions{padding:10px;clear:both;border-top:1px solid #ddd;background:#f5f5f5}#delete-action{float:right;line-height:28px}#delete-link{line-height:28px;vertical-align:middle;text-align:right;margin-right:8px}#delete-link a{text-decoration:none}#publishing-action{text-align:left;float:left;line-height:23px}#misc-publishing-actions{padding:6px 0 0}.misc-pub-section{padding:6px 10px 8px}#minor-publishing-actions{padding:10px 10px 0;text-align:left}.preview{float:left}#sticky-span{margin-right:18px}.approve,.unapproved .unapprove{display:none}.spam .approve,.trash .approve,.unapproved .approve{display:inline}td.action-links,th.action-links{text-align:left}#misc-publishing-actions .notice{margin-right:10px;margin-left:10px}.wp-filter{display:inline-block;position:relative;margin:12px 0 25px;padding:0 10px;width:100%;box-shadow:0 1px 1px rgba(0,0,0,.04);border:1px solid #e5e5e5;background:#fff;color:#555;font-size:13px}.wp-filter a{text-decoration:none}.filter-count{display:inline-block;vertical-align:middle;min-width:4em}.filter-count .count,.title-count{display:inline-block;position:relative;top:-1px;padding:4px 10px;border-radius:30px;background:#72777c;color:#fff;font-size:14px;font-weight:600}.title-count{display:inline;top:-3px;margin-right:5px;margin-left:20px}.filter-links li>a,.wp-filter .search-form.search-plugins{display:inline-block}.filter-items{float:right}.filter-links,.filter-links li{display:inline-block;margin:0}.filter-links li>a{margin:0 10px;padding:15px 0;border-bottom:4px solid #fff;color:#666;cursor:pointer}.filter-links .current{box-shadow:none;border-bottom:4px solid #666;color:#23282d}.filter-links li>a:focus,.filter-links li>a:hover,.show-filters .filter-links a.current:focus,.show-filters .filter-links a.current:hover{color:#00a0d2}.wp-filter .search-form{float:left;margin:10px 0}.wp-filter .search-form input[type=search]{margin:0;padding:3px 5px;width:280px;max-width:100%;font-size:16px;font-weight:300;line-height:1.5}.wp-filter .search-form select{margin:0;height:32px;vertical-align:top}.wp-filter .button.drawer-toggle{margin:10px 9px 0;padding:0 6px 0 10px;border-color:transparent;background-color:transparent;color:#666;vertical-align:baseline;box-shadow:none}.wp-filter .drawer-toggle:before{content:"\f111";margin:0 0 0 5px;color:#72777c;font:400 16px/1 dashicons;vertical-align:text-bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-filter .button.drawer-toggle:focus,.wp-filter .button.drawer-toggle:hover,.wp-filter .drawer-toggle:focus:before,.wp-filter .drawer-toggle:hover:before{background-color:transparent;color:#00a0d2}.wp-filter .button.drawer-toggle:focus:active,.wp-filter .button.drawer-toggle:hover{border-color:transparent}.wp-filter .button.drawer-toggle:focus{border-color:#5b9dd9}.wp-filter .button.drawer-toggle:active{background:0 0;box-shadow:none;-webkit-transform:none;transform:none}.wp-filter .drawer-toggle.current:before{color:#fff}.filter-drawer,.wp-filter .favorites-form{display:none;margin:0 -20px 0 -10px;padding:20px;border-top:1px solid #eee;background:#fafafa;overflow:hidden}.show-favorites-form .favorites-form,.show-filters .filter-drawer{display:block}.show-filters .filter-links a.current{border-bottom:none}.show-filters .wp-filter .button.drawer-toggle{border-radius:2px;background:#72777c;color:#fff}.filter-group,.filtered-by .tag{border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04)}.show-filters .wp-filter .drawer-toggle:focus,.show-filters .wp-filter .drawer-toggle:hover{background:#2ea2cc}.show-filters .wp-filter .drawer-toggle:before{color:#fff}.filter-group{position:relative;float:right;margin:0 0 0 1%;padding:20px 10px 10px;width:24%;background:#fff}.filter-group legend{position:absolute;top:10px;display:block;margin:0;padding:0;font-size:1em;font-weight:600}.filter-drawer .filter-group-feature{margin:28px 0 0;list-style-type:none;font-size:12px}.filter-drawer .filter-group-feature input,.filter-drawer .filter-group-feature label{line-height:16px}.filter-drawer .filter-group-feature input{position:absolute;margin:0}.filter-group .filter-group-feature label{display:block;margin:14px 23px 14px 0}.filter-drawer .buttons{clear:both;margin-bottom:20px}.filter-drawer .filter-group+.buttons{margin-bottom:0;padding-top:20px}.filter-drawer .buttons .button span{display:inline-block;opacity:.8;font-size:12px;text-indent:10px}.wp-filter .button.clear-filters{display:none;margin-right:10px}.wp-filter .button-link.edit-filters{padding:0 5px;line-height:28px}.filtered-by{display:none;margin:0}.filtered-by>span{font-weight:600}.filtered-by a{margin-right:10px}.filtered-by .tags{display:inline}.filtered-by .tag{margin:0 5px;padding:4px 8px;background:#fff;font-size:11px}.filters-applied .filter-drawer .buttons,.filters-applied .filter-drawer br,.filters-applied .filter-group{display:none!important}.filters-applied .filtered-by{display:block}.filters-applied .filter-drawer{padding:20px}.error .content-filterable,.loading-content .content-filterable,.show-filters .content-filterable,.show-filters .favorites-form,.show-filters.filters-applied.loading-content .content-filterable{display:none}.show-filters.filters-applied .content-filterable{display:block}.loading-content .spinner{display:block;margin:40px auto 0;float:none}@media only screen and (max-width:1120px){.filter-drawer{border-bottom:1px solid #eee}.filter-group{margin-bottom:0;margin-top:5px;width:100%}.filter-group li{margin:10px 0}}@media only screen and (max-width:1000px){.filter-items{float:none}.wp-filter .media-toolbar-primary,.wp-filter .media-toolbar-secondary,.wp-filter .search-form{float:none;position:relative;max-width:100%}}@media only screen and (max-width:782px){.filter-group li{padding:0;width:50%}}@media only screen and (max-width:320px){.filter-count{display:none}.wp-filter .drawer-toggle{margin:10px 0}.filter-group li,.wp-filter .search-form input[type=search]{width:100%}}.notice,div.error,div.updated{background:#fff;border-right:4px solid #fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 15px 2px;padding:1px 12px}div[class=update-message]{padding:.5em 0 .5em 12px}.form-table td .notice p,.notice p,.notice-title,div.error p,div.updated p{margin:.5em 0;padding:2px}.error a{text-decoration:underline}.updated a{padding-bottom:2px}.notice-alt{box-shadow:none}.notice-large{padding:10px 20px}.notice-title{display:inline-block;color:#23282d;font-size:18px}.wp-core-ui .notice.is-dismissible{padding-left:38px;position:relative}.notice-dismiss{position:absolute;top:0;left:1px;border:none;margin:0;padding:9px;background:0 0;color:#72777c;cursor:pointer}.notice-dismiss:active:before,.notice-dismiss:focus:before,.notice-dismiss:hover:before{color:#c00}.notice-dismiss:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 .notice-dismiss:focus{outline:#5b9dd9 solid 1px}.notice-success,div.updated{border-right-color:#46b450}.notice-success.notice-alt{background-color:#ecf7ed}.notice-warning{border-right-color:#ffb900}.notice-warning.notice-alt{background-color:#fff8e5}.notice-error,div.error{border-right-color:#dc3232}.notice-error.notice-alt{background-color:#fbeaea}.notice-info{border-right-color:#00a0d2}.notice-info.notice-alt{background-color:#e5f5fa}.button.installed:before,.button.installing:before,.button.updated-message:before,.button.updating-message:before,.import-php .updating-message:before,.update-message p:before,.updated-message p:before,.updating-message p:before{display:inline-block;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.media-upload-form .notice,.media-upload-form div.error,.wrap .notice,.wrap div.error,.wrap div.updated{margin:5px 0 15px}.wrap #templateside .notice{display:block;margin:0;padding:5px 8px;font-weight:600;text-decoration:none}.wrap #templateside span.notice{margin-right:-12px}#templateside li.notice a{padding:0}.button.installing:before,.button.updating-message:before,.import-php .updating-message:before,.update-message p:before,.updating-message p:before{color:#f56e28;content:"\f463"}.button.installing:before,.button.updating-message:before,.import-php .updating-message:before,.updating-message p:before{-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.button.updated-message:before,.installed p:before,.updated-message p:before{color:#79ba49;content:'\f147'}.update-message.notice-error p:before{color:#dc3232;content:"\f534"}.import-php .updating-message:before,.wrap .notice p:before{margin-left:6px;vertical-align:bottom}#update-nag,.update-nag{display:inline-block;line-height:19px;padding:11px 15px;font-size:14px;text-align:right;margin:25px 2px 0 20px;background-color:#fff;border-right:4px solid #ffba00;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}#screen-meta,ul#dismissed-updates{display:none}form.upgrade{margin-top:8px}form.upgrade .hint{font-style:italic;font-size:85%;margin:-.5em 0 2em}.update-php .spinner{float:none;margin:-4px 0}#ajax-response.alignleft{margin-right:2em}.button.installed:before,.button.installing:before,.button.updated-message:before,.button.updating-message:before{margin:3px -2px 0 5px}.button-primary.updating-message:before{color:#fff}.button-primary.updated-message:before{color:#66c6e4}@media aural{.button.installed:before,.button.installing:before,.update-message p:before,.wrap .notice p:before{speak:none}}#adminmenu a,#catlist a,#taglist a{text-decoration:none}#contextual-help-wrap,#screen-options-wrap{margin:0;padding:8px 20px 12px;position:relative}#contextual-help-wrap{overflow:auto;margin-right:0!important}#screen-meta-links{margin:0 0 0 20px}#screen-meta{margin:0 0 -1px 20px;position:relative;background-color:#fff;border:1px solid #ddd;border-top:none;box-shadow:0 1px 0 rgba(0,0,0,.025)}#contextual-help-link-wrap,#screen-options-link-wrap{float:left;height:28px;margin:0 6px 0 0;border:1px solid #ddd;border-top:none;background:#fff;box-shadow:0 1px 1px -1px rgba(0,0,0,.1)}#screen-meta-links .screen-meta-toggle{position:relative;top:0}#screen-meta-links .show-settings{border:0;background:0 0;border-radius:0;color:#72777c;line-height:1.7;padding:3px 16px 3px 6px}#screen-meta-links .show-settings:active,#screen-meta-links .show-settings:focus,#screen-meta-links .show-settings:hover{color:#32373c}#screen-meta-links .show-settings:active{box-shadow:none;-webkit-transform:none;transform:none}#screen-meta-links .show-settings:after{left:0;content:"\f140";font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 0 0 5px;bottom:2px;position:relative;vertical-align:bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#72777c}#templateside ul li a,.contextual-help-tabs a,.nav-tab{text-decoration:none}#screen-meta-links .screen-meta-active:after{content:"\f142"}.toggle-arrow{background-repeat:no-repeat;background-position:top right;background-color:transparent;height:22px;line-height:22px;display:block}.toggle-arrow-active{background-position:bottom right}#contextual-help-wrap h5,#screen-options-wrap h5,#screen-options-wrap legend{margin:0;padding:8px 0;font-size:13px;font-weight:600}.hndle a,.widefat tfoot td,.widefat th,.widefat thead td{font-weight:400}.ie8 #screen-options-wrap legend{color:inherit}.metabox-prefs label{display:inline-block;padding-left:15px;line-height:30px}#number-of-columns{display:inline-block;vertical-align:middle;line-height:30px}.metabox-prefs input[type=checkbox]{margin-top:0;margin-left:6px}.metabox-prefs label input,.metabox-prefs label input[type=checkbox]{margin:-4px 0 0 5px}.metabox-prefs .columns-prefs label input{margin:-1px 0 0 2px}.metabox-prefs label a{display:none}.metabox-prefs .screen-options input,.metabox-prefs .screen-options label{margin-top:0;margin-bottom:0;vertical-align:middle}.metabox-prefs .screen-options .screen-per-page{margin-left:15px}.metabox-prefs .screen-options label{line-height:28px;padding-left:0}.screen-options+.screen-options{margin-top:10px}.metabox-prefs .submit{margin-top:1em;padding:0}#contextual-help-wrap{padding:0}#contextual-help-columns{position:relative}#contextual-help-back{position:absolute;top:0;bottom:0;right:150px;left:170px;border:1px solid #e1e1e1;border-top:none;border-bottom:none;background:#f6fbfd}#contextual-help-wrap.no-sidebar #contextual-help-back{left:0;border-left-width:0;border-bottom-left-radius:2px}.contextual-help-tabs{float:right;width:150px;margin:0}.contextual-help-tabs ul{margin:1em 0}.contextual-help-tabs li{margin-bottom:0;list-style-type:none;border-style:solid;border-width:0 2px 0 0;border-color:transparent}.contextual-help-tabs a{display:block;padding:5px 12px 5px 5px;line-height:18px;border:1px solid transparent;border-left:none;border-right:none}.contextual-help-tabs a:hover{color:#32373c}.contextual-help-tabs .active{padding:0;margin:0 0 0 -1px;border-right:2px solid #00a0d2;background:#f6fbfd;box-shadow:0 2px 0 rgba(0,0,0,.02),0 1px 0 rgba(0,0,0,.02)}.contextual-help-tabs .active a{border-color:#e1e1e1;color:#32373c}.contextual-help-tabs-wrap{padding:0 20px;overflow:auto}.help-tab-content{display:none;margin:0 0 12px 22px;line-height:1.6em}.help-tab-content.active{display:block}.help-tab-content ul li{list-style-type:disc;margin-right:18px}.contextual-help-sidebar{width:150px;float:left;padding:0 12px 0 8px;overflow:auto}html.wp-toolbar{padding-top:32px}.widefat td,.widefat th{color:#555}.widefat ol,.widefat p,.widefat tfoot tr td,.widefat tfoot tr th,.widefat thead tr td,.widefat thead tr th,.widefat ul{color:#32373c}.widefat td p{margin:2px 0 .8em}.widefat .column-comment p{margin:.6em 0}.widefat .column-comment ul{list-style:outside;margin-right:2em}.postbox-container{float:right}#wpbody-content .metabox-holder{padding-top:10px}.metabox-holder .postbox-container .empty-container{border:3px dashed #b4b9be;height:250px;position:relative}.metabox-holder .postbox-container .empty-container:after{content:attr(data-emptystring);margin:auto;position:absolute;top:0;right:0;bottom:0;left:0;height:1em;width:200px;text-align:center;color:#ccc;font-size:18px;display:none}.columns-2 #postbox-container-3 .empty-container,.columns-2 #postbox-container-4 .empty-container,.columns-3 #postbox-container-4 .empty-container,.metabox-holder.columns-1 .postbox-container .empty-container{border:0;height:0;min-height:0}#post-body-content{width:100%;min-width:463px;float:right}#post-body.columns-2 #postbox-container-1{float:left;margin-left:-300px;width:280px}#post-body.columns-2 #side-sortables{min-height:250px}@media only screen and (max-width:799px){#wpbody-content .metabox-holder .postbox-container .empty-container{border:0;height:0;min-height:0}}.js .postbox .hndle,.js .widget .widget-top{cursor:move}.hndle a{font-size:11px}#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:hover,#dashboard_right_now .versions .b,#ed_reply_toolbar #ed_reply_strong,#pass-strength-result.short,#pass-strength-result.strong,#post-status-display,#post-visibility-display,.feature-filter .feature-name,.item-controls .item-order a,.media-item .percent,.nav-tab,.plugins .name{font-weight:600}.postbox .handlediv{display:none;float:left;width:36px;height:36px;margin:0;padding:0;border:0;background:0 0;cursor:pointer}.js .postbox .handlediv{display:block}.sortable-placeholder{border:1px dashed #b4b9be;margin-bottom:20px}.postbox,.stuffbox{margin-bottom:20px;padding:0;line-height:1}.postbox .inside,.stuffbox .inside{padding:0 12px 12px;line-height:1.4em;font-size:13px}.postbox .inside{margin:11px 0;position:relative}.postbox .inside>p:last-child,.rss-widget ul li:last-child{margin-bottom:1px!important}.postbox.closed h3{border:none;box-shadow:none}.postbox table.form-table{margin-bottom:0}.postbox table.widefat{box-shadow:none}.temp-border{border:1px dotted #ccc}.columns-prefs label{padding:0 0 0 10px}#wpfooter{position:absolute;bottom:0;right:0;left:0;padding:10px 20px;color:#555d66}#wpfooter p{font-size:13px;margin:0;line-height:20px}#footer-thankyou{font-style:italic}.nav-tab{float:right;border:1px solid #ccc;border-bottom:none;margin-right:.5em;padding:5px 10px;font-size:14px;line-height:24px;background:#e5e5e5;color:#555}.nav-tab-small .nav-tab,h3 .nav-tab{padding:5px 14px;font-size:12px;line-height:16px}.nav-tab:focus,.nav-tab:hover{background-color:#fff;color:#444}.nav-tab-active,.nav-tab:focus:active{box-shadow:none}.nav-tab-active{margin-bottom:-1px;color:#444}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{border-bottom:1px solid #f1f1f1;background:#f1f1f1;color:#000}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper,h1.nav-tab-wrapper{border-bottom:1px solid #ccc;margin:0;padding-top:9px;padding-bottom:0;line-height:inherit}.nav-tab-wrapper:not(.wp-clearfix):after{content:"";display:table;clear:both}.ie8 .nav-tab-wrapper{display:inline-block;width:100%;vertical-align:top}.spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;display:inline-block;float:left;vertical-align:middle;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:4px 10px 0}.loading-content .spinner,.spinner.is-active{visibility:visible}#template>div{margin-left:16em}#template .notice{margin-top:1em;margin-left:3%}#template .notice p{width:auto}#template .submit .spinner{float:none}.metabox-holder .postbox>h3,.metabox-holder .stuffbox>h3,.metabox-holder h2.hndle,.metabox-holder h3.hndle{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}.nav-menus-php .metabox-holder h3{padding:10px 14px 11px 10px;line-height:21px}.plugin-install #description,.plugin-install-network #description{width:60%}table .column-rating,table .column-visible,table .vers{text-align:right}.attention,.error-message{color:#dc3232;font-weight:600}body.iframe{height:98%}.lp-show-latest p{display:none}#howto,.importer-action,.importer-desc,.importer-title{display:block}.lp-show-latest .lp-error p,.lp-show-latest p:last-child{display:block}.media-icon{width:62px;text-align:center}.media-icon img{border:1px solid #e5e5e5;border:1px solid rgba(0,0,0,.07)}#howto{font-size:11px;margin:0 5px}.importers{font-size:16px;width:auto}.importers td{padding-left:14px;line-height:1.5em}.importers .import-system{max-width:250px}.importers td.desc{max-width:500px}.post-categories,.post-categories li{display:inline}.importer-title{color:#000;font-size:14px;font-weight:400;margin-bottom:.2em}.importer-action{line-height:20px;color:#555;margin-bottom:1em}#post-body #post-body-content #namediv h2,#post-body #post-body-content #namediv h3{margin-top:0}.edit-comment-author{font-size:14px;line-height:1.4;font-weight:600;color:#222;margin:2px 9px 0 0}#namediv h2 label,#namediv h3 label{vertical-align:baseline}#namediv table{width:100%}#namediv td.first{width:10px}#namediv input{width:98%}#namediv p{margin:10px 0}#submitdiv h3{margin-bottom:0!important}.checkbox,.post-categories,.zerosize,fieldset{margin:0;padding:0}.zerosize{height:0;width:0;border:0;overflow:hidden;position:absolute}br.clear{height:2px;line-height:2px}.checkbox{border:none}fieldset{border:0}div.star-holder{position:relative;height:17px;width:100px;background:url(../images/stars.png?ver=20121108) bottom left repeat-x}div.star-holder .star-rating{background:url(../images/stars.png?ver=20121108) top left repeat-x;height:17px;float:right}.star-rating .star{display:inline-block;width:20px;height:20px;-webkit-font-smoothing:antialiased;font-size:20px;line-height:1;font-family:dashicons;text-decoration:inherit;font-weight:400;font-style:normal;vertical-align:top;transition:color .1s ease-in 0;text-align:center;color:#ffb900}.star-rating .star-full:before{content:"\f155"}.star-rating .star-half:before{content:"\f459"}.rtl .star-rating .star-half{-webkit-transform:rotateY(180deg);transform:rotateY(180deg)}.star-rating .star-empty:before{content:"\f154"}div.action-links{font-weight:400;margin:6px 0 0}#plugin-information{background:#fff;position:fixed;top:0;left:0;bottom:0;right:0;height:100%;padding:0}#plugin-information-scrollable{overflow:auto;-webkit-overflow-scrolling:touch;height:100%}#plugin-information-title{padding:0 26px;background:#f5f5f5;font-size:22px;font-weight:600;line-height:56px;position:relative;height:56px}#plugin-information-title.with-banner{margin-left:0;height:250px;background-size:cover}#plugin-information-title h2{font-size:1em;font-weight:600;padding:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#plugin-information-title.with-banner h2{position:relative;font-family:"Helvetica Neue",sans-serif;display:inline-block;font-size:30px;line-height:50px;box-sizing:border-box;max-width:100%;padding:0 15px;margin-top:174px;color:#fff;background:rgba(30,30,30,.9);text-shadow:0 1px 3px rgba(0,0,0,.4);box-shadow:0 0 30px rgba(255,255,255,.1);border-radius:8px}#plugin-information-title div.vignette{display:none}#plugin-information-title.with-banner div.vignette{position:absolute;display:block;top:0;right:0;height:250px;width:100%;background:0 0;box-shadow:inset 0 0 50px 4px rgba(0,0,0,.2),inset 0 -1px 0 rgba(0,0,0,.1)}#plugin-information-tabs{padding:0 16px;position:relative;left:0;right:0;min-height:36px;font-size:0;z-index:1;border-bottom:1px solid #ddd;background:#f3f3f3}#plugin-information-tabs a{position:relative;display:inline-block;padding:9px 10px;margin:0;height:18px;line-height:18px;font-size:14px;text-decoration:none;transition:none}#plugin-information-tabs a.current{margin:0 -1px -1px;background:#fff;border:1px solid #ddd;border-bottom-color:#fff;padding-top:8px;color:#32373c}#plugin-information-tabs.with-banner a.current{border-top:none;padding-top:9px}#plugin-information-tabs a:active,#plugin-information-tabs a:focus{outline:0}#plugin-information-content{overflow:hidden;background:#fff;position:relative;top:0;left:0;right:0;min-height:100%;min-height:calc(100% - 152px)}#plugin-information-content.with-banner{min-height:calc(100% - 346px)}#section-holder{position:relative;top:0;left:250px;bottom:0;right:0;margin-left:250px;padding:10px 26px 99999px;margin-bottom:-99939px}#section-holder .updated{margin:16px 0}#plugin-information .fyi{float:left;position:relative;top:0;left:0;padding:16px 16px 99999px;margin-bottom:-99939px;width:217px;border-right:1px solid #ddd;background:#f3f3f3;color:#666}#plugin-information .fyi strong{color:#444}#plugin-information .fyi h3{font-weight:600;text-transform:uppercase;font-size:12px;color:#666;margin:24px 0 8px}#plugin-information .fyi h2{font-size:.9em;margin-bottom:0;margin-left:0}#plugin-information .fyi ul{padding:0;margin:0;list-style:none}#plugin-information .fyi li{margin:0 0 10px}#plugin-information .fyi-description{margin-top:0}#plugin-information .counter-container{margin:3px 0}#plugin-information .counter-label{float:right;margin-left:5px;min-width:55px}#plugin-information .counter-back{height:17px;width:92px;background-color:#e5e5e5;float:right}#plugin-information .counter-bar{height:17px;background-color:#ffc733;float:right}#plugin-information .counter-count{margin-right:5px}#plugin-information .fyi ul.contributors{margin-top:10px}#plugin-information .fyi ul.contributors li{display:inline-block;margin-left:8px;vertical-align:middle}#plugin-information .fyi ul.contributors li img{vertical-align:middle;margin-left:4px}#plugin-information-footer{padding:13px 16px;position:absolute;left:0;bottom:0;right:0;height:33px;border-top:1px solid #ddd;background:#f3f3f3}#plugin-information .section ol,#plugin-information .section ul{list-style-type:disc;margin-left:24px}#plugin-information .section,#plugin-information .section p{font-size:14px;line-height:1.7}#plugin-information #section-screenshots ol{list-style:none;margin:0}#plugin-information #section-screenshots li img{vertical-align:text-top;margin-top:16px;max-width:100%;width:auto;height:auto;box-shadow:0 1px 2px rgba(0,0,0,.3)}#plugin-information #section-screenshots li p{font-style:italic;padding-left:20px}#plugin-information pre{padding:7px;overflow:auto;border:1px solid #ccc}#plugin-information blockquote{border-right:2px solid #ddd;color:#666;font-style:italic;margin:1em 0;padding:0 1em 0 0}#plugin-information .review{overflow:hidden;width:100%;margin-bottom:20px;border-bottom:1px solid #e5e5e5}#plugin-information .review-title-section{overflow:hidden}#plugin-information .review-title-section h4{display:inline-block;float:left;margin:0 6px 0 0}#plugin-information .reviewer-info p{clear:both;margin:0;padding-top:2px}#plugin-information .reviewer-info .avatar{float:left;margin:4px 6px 0 0}#plugin-information .reviewer-info .star-rating{float:left}#plugin-information .review-meta{float:left;margin-left:.75em}#plugin-information .review-body{float:left;width:100%}.plugin-version-author-uri{font-size:13px}.update-php .button.button-primary{margin-left:1em}@media screen and (max-width:771px){#plugin-information-title.with-banner,#plugin-information-title.with-banner div.vignette{height:100px}#plugin-information-title.with-banner h2{margin-top:30px;font-size:20px;line-height:40px;max-width:85%}#plugin-information-tabs{overflow:hidden;padding:0;height:auto}#plugin-information-tabs a.current{margin-bottom:0;border-bottom:none}#plugin-information .fyi{float:none;border:1px solid #ddd;position:static;width:auto;margin:26px 26px 0;padding-bottom:0}#section-holder{position:static;margin:0;padding-bottom:70px}#plugin-information .fyi h3,#plugin-information .fyi small{display:none}#plugin-information-footer{padding:12px 16px 0;height:46px}}#TB_window.plugin-details-modal{background:#fcfcfc}#TB_window.plugin-details-modal.thickbox-loading:before{content:"";display:block;width:20px;height:20px;position:absolute;right:50%;top:50%;z-index:-1;margin:-10px -10px 0 0;background:url(../images/spinner.gif) center no-repeat #fcfcfc;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}.plugin-details-modal #TB_ajaxWindowTitle,.plugin-details-modal .tb-close-icon{display:none}.tree-folder,[role=treeitem] li{position:relative}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#TB_window.plugin-details-modal.thickbox-loading:before{background-image:url(../images/spinner-2x.gif)}}.plugin-details-modal #TB_title{float:right;height:1px}.plugin-details-modal #TB_closeWindowButton{right:auto;left:-30px;color:#eee}.plugin-details-modal #TB_closeWindowButton:focus,.plugin-details-modal #TB_closeWindowButton:hover{color:#00a0d2;outline:0;box-shadow:none}.plugin-details-modal #TB_closeWindowButton:after{content:"\f335";font:400 32px/29px dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media screen and (max-width:830px){.plugin-details-modal #TB_closeWindowButton{left:0;top:-30px}}img{border:none}.bulk-action-notice .toggle-indicator:before,.js .meta-box-sortables .postbox .toggle-indicator:before,.privacy-text-box .toggle-indicator:before,.sidebar-name .toggle-indicator:before{content:"\f142";display:inline-block;font:400 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before,.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before,.js .widgets-holder-wrap.closed .toggle-indicator:before,.privacy-text-box.closed .toggle-indicator:before{content:"\f140"}.js .postbox .handlediv .toggle-indicator:before{margin-top:4px;width:20px;border-radius:50%;text-indent:-1px}#template .CodeMirror,#template textarea,#templateside>ul{box-sizing:border-box;min-height:60vh;height:calc(100vh - 295px);border:1px solid #ddd}.rtl.js .postbox .handlediv .toggle-indicator:before{text-indent:1px}.bulk-action-notice .toggle-indicator:before{line-height:16px;vertical-align:top;color:#72777c}.js .postbox .handlediv:focus{box-shadow:none;outline:0}.js .postbox .handlediv:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#photo-add-url-div input[type=text]{width:300px}.alignleft h2{margin:0}#template textarea{font-family:Consolas,Monaco,monospace;font-size:13px;background:#f9f9f9;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#template .CodeMirror,#template textarea{width:100%}#templateside>h2{padding-top:6px;padding-bottom:7px;margin:0}#templateside ol,#templateside ul{margin:0;padding:0}#templateside>ul{margin-top:0;overflow:auto;padding:0;background-color:#f7f7f7;border-right:none}#templateside ul ul{padding-right:12px}#templateside>ul>li>ul[role=group]{padding-right:0}[role=treeitem][aria-expanded=false]>ul{display:none}[role=treeitem] span[aria-hidden]{display:inline;font-family:dashicons;font-size:20px;position:absolute;pointer-events:none}[role=treeitem][aria-expanded=false]>.folder-label .icon:after{content:"\f141"}[role=treeitem][aria-expanded=true]>.folder-label .icon:after{content:"\f140"}[role=treeitem] .folder-label{display:block;padding:3px 12px 3px 3px;cursor:pointer}[role=treeitem]{outline:0}[role=treeitem] .folder-label.focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}[role=treeitem] .folder-label.hover,[role=treeitem].hover{background-color:#eaeaea}.tree-folder{margin:0}.tree-folder .tree-folder::after{content:' ';display:block;position:absolute;right:2px;border-right:1px solid #ccc;top:-13px;bottom:10px}.tree-folder>li::before{content:' ';position:absolute;display:block;border-right:1px solid #ccc;right:2px;top:-5px;height:18px;width:7px;border-bottom:1px solid #ccc}.tree-folder>li::after{content:' ';position:absolute;display:block;border-right:1px solid #ccc;right:2px;bottom:-7px;top:0}#templateside .current-file{margin:-4px 0 -2px}.tree-folder>.current-file::before{right:4px;height:15px;width:0;border-right:none;top:3px}.tree-folder>.current-file::after{bottom:-4px;height:7px;right:2px;top:auto}.tree-folder li:last-child>.tree-folder::after,.tree-folder>li:last-child::after{display:none}#theme-plugin-editor-label{display:inline-block;margin-bottom:1em;font-weight:600}.fileedit-sub #plugin,.fileedit-sub #theme{max-width:40%}.fileedit-sub .alignright{text-align:left}#template p{width:97%}#file-editor-linting-error{margin-top:1em;margin-bottom:1em}#file-editor-linting-error>.notice{margin:0;display:inline-block}#file-editor-linting-error>.notice>p{width:auto}#template .submit{margin-top:1em;padding:0}#template .submit input[type=submit][disabled]{cursor:not-allowed}#templateside{float:left;width:16em}#postcustomstuff p.submit{margin:0}#templateside h4{margin:1em 0 0}#templateside li{margin:4px 0}#templateside li:not(.howto) a,.theme-editor-php .highlight{display:block;padding:3px 12px 3px 0;text-decoration:none}#templateside li:not(.howto)>a:first-of-type{padding-top:0}#templateside li.howto{padding:6px 12px 12px}.theme-editor-php .highlight{margin:-3px -12px -3px 3px}#templateside .highlight{border:none;font-weight:600}.nonessential{color:#666;font-size:11px;font-style:italic;padding-right:12px}#documentation{margin-top:10px}#documentation label{line-height:22px;vertical-align:baseline;font-weight:600}.fileedit-sub{padding:10px 0 8px;line-height:180%}#file-editor-warning .file-editor-warning-content{margin:25px}.accordion-section-title:after,.control-section .accordion-section-title:after,.nav-menus-php .item-edit:before,.widget-top .widget-action .toggle-indicator:before{content:"\f140";font:400 20px/1 dashicons;speak:none;display:block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.widget-top .widget-action .toggle-indicator:before{padding:1px 0 1px 2px;border-radius:50%}.accordion-section-title:after,.handlediv,.item-edit,.postbox .handlediv.button-link,.toggle-indicator{color:#72777c}.widget-action{color:#555d66}.accordion-section-title:hover:after,.handlediv:focus,.handlediv:hover,.item-edit:focus,.item-edit:hover,.postbox .handlediv.button-link:focus,.postbox .handlediv.button-link:hover,.sidebar-name:hover .toggle-indicator,.widget-action:focus,.widget-top:hover .widget-action{color:#23282d}.widget-top .widget-action:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.accordion-section-title:after,.control-section .accordion-section-title:after{float:left;left:20px;top:-2px}#customize-info.open .accordion-section-title:after,.control-section.open .accordion-section-title:after,.nav-menus-php .menu-item-edit-active .item-edit:before,.widget.open .widget-top .widget-action .toggle-indicator:before{content:"\f142"}/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-draggable-handle,.ui-sortable-handle{touch-action:none}.accordion-section{border-bottom:1px solid #ddd;margin:0}.accordion-section.open .accordion-section-content,.no-js .accordion-section .accordion-section-content{display:block}.accordion-section.open:hover{border-bottom-color:#ddd}.accordion-section-content{display:none;padding:10px 20px 15px;overflow:hidden;background:#fff}.accordion-section-title{margin:0;padding:12px 15px 15px;position:relative;border-right:1px solid #ddd;border-left:1px solid #ddd;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.js .accordion-section-title{cursor:pointer}.js .accordion-section-title:after{position:absolute;top:12px;left:10px;z-index:1}.accordion-section-title:focus{outline:0}.accordion-section-title:focus:after,.accordion-section-title:hover:after{border-color:#a0a5aa transparent}.cannot-expand .accordion-section-title{cursor:auto}.cannot-expand .accordion-section-title:after{display:none}.control-section .accordion-section-title,.customize-pane-child .accordion-section-title{border-right:none;border-left:none;padding:10px 14px 11px 10px;line-height:21px;background:#fff}.control-section .accordion-section-title:after,.customize-pane-child .accordion-section-title:after{top:calc(50% - 10px)}.js .control-section .accordion-section-title:focus,.js .control-section .accordion-section-title:hover,.js .control-section.open .accordion-section-title,.js .control-section:hover .accordion-section-title{color:#23282d;background:#f5f5f5}.control-section.open .accordion-section-title{border-bottom:1px solid #ddd}.network-admin .edit-site-actions{margin-top:0}.my-sites{display:block;overflow:auto;zoom:1}.my-sites li{display:block;padding:8px 3%;min-height:130px;margin:0}@media only screen and (max-width:599px){.my-sites li{min-height:0}}@media only screen and (min-width:600px){.my-sites.striped li{background-color:#fff;position:relative}.my-sites.striped li:after{content:"";width:1px;height:100%;position:absolute;top:0;left:0;background:#ccc}}@media only screen and (min-width:600px) and (max-width:699px){.my-sites li{float:right;width:44%}.my-sites.striped li{background-color:#fff}.my-sites.striped li:nth-of-type(2n+1){clear:right}.my-sites.striped li:nth-of-type(2n+2):after{content:none}.my-sites li:nth-of-type(4n+1),.my-sites li:nth-of-type(4n+2){background-color:#f9f9f9}}@media only screen and (min-width:700px) and (max-width:1199px){.my-sites li{float:right;width:27.333333%;background-color:#fff}.my-sites.striped li:nth-of-type(3n+3):after{content:none}.my-sites li:nth-of-type(6n+1),.my-sites li:nth-of-type(6n+2),.my-sites li:nth-of-type(6n+3){background-color:#f9f9f9}}@media only screen and (min-width:1200px) and (max-width:1399px){.my-sites li{float:right;width:21%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(4n+1){clear:right}.my-sites.striped li:nth-of-type(4n+4):after{content:none}.my-sites li:nth-of-type(8n+1),.my-sites li:nth-of-type(8n+2),.my-sites li:nth-of-type(8n+3),.my-sites li:nth-of-type(8n+4){background-color:#f9f9f9}}@media only screen and (min-width:1400px) and (max-width:1599px){.my-sites li{float:right;width:16%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(5n+1){clear:right}.my-sites.striped li:nth-of-type(5n+5):after{content:none}.my-sites li:nth-of-type(10n+1),.my-sites li:nth-of-type(10n+2),.my-sites li:nth-of-type(10n+3),.my-sites li:nth-of-type(10n+4),.my-sites li:nth-of-type(10n+5){background-color:#f9f9f9}}@media only screen and (min-width:1600px){.my-sites li{float:right;width:12.666666%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(6n+1){clear:right}.my-sites.striped li:nth-of-type(6n+6):after{content:none}.my-sites li:nth-of-type(12n+1),.my-sites li:nth-of-type(12n+2),.my-sites li:nth-of-type(12n+3),.my-sites li:nth-of-type(12n+4),.my-sites li:nth-of-type(12n+5),.my-sites li:nth-of-type(12n+6){background-color:#f9f9f9}}.my-sites li a{text-decoration:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){div.star-holder,div.star-holder .star-rating{background:url(../images/stars-2x.png?ver=20121108) bottom left repeat-x;background-size:21px 37px}.spinner{background-image:url(../images/spinner-2x.gif)}#bulk-titles div a,#bulk-titles div a:hover,#screen-meta-links a.show-settings,.curtime #timestamp,.meta-box-sortables .postbox:hover .handlediv,.sidebar-name .toggle-indicator,.sidebar-name:hover .toggle-indicator,.widget-top .widget-action,.widget-top .widget-action:hover{background:0 0!important}}@-ms-viewport{width:device-width}@media screen and (max-width:782px){#col-left,#col-right,#templateside{float:none;width:auto}html.wp-toolbar{padding-top:46px}body{min-width:240px;overflow-x:hidden}body *{-webkit-tap-highlight-color:rgba(0,0,0,0)!important}#wpcontent{position:relative;margin-right:0;padding-right:10px}#wpbody-content{padding-bottom:100px}.wrap{margin-left:12px;margin-right:0}#col-left .col-wrap,#col-right .col-wrap{padding:0}#collapse-menu,#screen-meta,#screen-meta-links,.post-format-select{display:none!important}#documentation label[for=docs-list],.fileedit-sub .alignright label{display:block}.wrap h1.wp-heading-inline{margin-bottom:.5em}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{padding:10px 15px;font-size:14px;white-space:nowrap}.media-upload-form div.error,.notice,.wrap div.error,.wrap div.updated{margin:20px 0 10px;padding:5px 10px;font-size:14px;line-height:175%}.wp-core-ui .notice.is-dismissible{padding-left:46px}.notice-dismiss{padding:13px}.wrap .icon32+h2{margin-top:-2px}.wp-responsive-open #wpbody{left:-16em}code{word-wrap:break-word}.postbox{font-size:14px}.metabox-holder .postbox>h3,.metabox-holder .stuffbox>h3,.metabox-holder h2,.metabox-holder h3.hndle{padding:12px}.postbox .handlediv{margin-top:3px}.subsubsub{font-size:16px;text-align:center;margin-bottom:15px}#templateside>ul{border-right:1px solid #ddd}#templateside li{margin:0}#templateside li:not(.howto) a{display:block;padding:5px}#templateside li.howto{padding:12px}#templateside .highlight{padding:5px;margin-right:-5px;margin-top:-5px}#template .notice,#template>div{float:none;margin:1em 0;width:auto}#template .CodeMirror,#template textarea{box-sizing:border-box;width:100%}#templateside ul ul{padding-right:1.5em}[role=treeitem] .folder-label{display:block;padding:5px}#documentation input[type=button],.fileedit-sub input[type=submit]{margin-bottom:0;padding:8px 18px}.tree-folder .tree-folder::after,.tree-folder>li::after,.tree-folder>li::before{right:-8px}.tree-folder>li::before{top:0;height:13px}.tree-folder>.current-file::before{right:-5px;top:7px;width:4px}.tree-folder>.current-file::after{height:9px;right:-8px}.wrap #templateside span.notice{margin-right:-5px;width:100%}.fileedit-sub .alignright{float:right;margin-top:15px;width:100%;text-align:right}.fileedit-sub #plugin,.fileedit-sub #theme{margin-right:0;max-width:70%}#documentation select[name=docs-list]{margin-right:0;max-width:60%}#comments-form .checkforspam,#wpfooter{display:none}.edit-comment-author{margin:2px 0 0}.filter-drawer .filter-group-feature input,.filter-drawer .filter-group-feature label{line-height:25px}.filter-drawer .filter-group-feature label{margin-right:32px}.wp-filter .button.drawer-toggle{font-size:13px;line-height:26px;height:28px}}@media screen and (max-width:600px){#wpwrap.wp-responsive-open,div#post-body.metabox-holder.columns-1{overflow-x:hidden}html.wp-toolbar{padding-top:0}#wpbody{padding-top:46px}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper,h1.nav-tab-wrapper{border-bottom:0}h1 .nav-tab,h2 .nav-tab,h3 .nav-tab{margin:10px 0 0 10px;border-bottom:1px solid #ccc}}@media screen and (max-width:320px){#network_dashboard_right_now .subsubsub{font-size:14px;text-align:right}} \ No newline at end of file diff --git a/backend/wp-admin/css/common.css b/backend/wp-admin/css/common.css new file mode 100644 index 0000000..ac3a7c6 --- /dev/null +++ b/backend/wp-admin/css/common.css @@ -0,0 +1,3955 @@ +/* 2 column liquid layout */ +#wpwrap { + height: auto; + min-height: 100%; + width: 100%; + position: relative; + -webkit-font-smoothing: subpixel-antialiased; +} + +#wpcontent { + height: 100%; + padding-left: 20px; +} + +#wpcontent, +#wpfooter { + margin-left: 160px; +} + +.folded #wpcontent, +.folded #wpfooter { + margin-left: 36px; +} + +#wpbody-content { + padding-bottom: 65px; + float: left; + width: 100%; + overflow: visible !important; +} + +/* inner 2 column liquid layout */ + +.inner-sidebar { + float: right; + clear: right; + display: none; + width: 281px; + position: relative; +} + +.columns-2 .inner-sidebar { + margin-right: auto; + width: 286px; + display: block; +} + +.inner-sidebar #side-sortables, +.columns-2 .inner-sidebar #side-sortables { + min-height: 300px; + width: 280px; + padding: 0; +} + +.has-right-sidebar .inner-sidebar { + display: block; +} + +.has-right-sidebar #post-body { + float: left; + clear: left; + width: 100%; + margin-right: -2000px; +} + +.has-right-sidebar #post-body-content { + margin-right: 300px; + float: none; + width: auto; +} + +/* 2 columns main area */ + +#col-left { + float: left; + width: 35%; +} + +#col-right { + float: right; + width: 65%; +} + +#col-left .col-wrap { + padding: 0 6px 0 0; +} + +#col-right .col-wrap { + padding: 0 0 0 6px; +} + +/* utility classes */ +.alignleft { + float: left; +} + +.alignright { + float: right; +} + +.textleft { + text-align: left; +} + +.textright { + text-align: right; +} + +.clear { + clear: both; +} + +/* modern clearfix */ +.wp-clearfix:after { + content: ""; + display: table; + clear: both; +} + +/* Hide visually but not from screen readers */ +.screen-reader-text, +.screen-reader-text span, +.ui-helper-hidden-accessible { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ +} + +.screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +.screen-reader-shortcut:focus { + left: 6px; + top: -25px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); + text-decoration: none; + outline: none; +} + +.hidden, +.js .closed .inside, +.js .hide-if-js, +.no-js .hide-if-no-js, +.js.wp-core-ui .hide-if-js, +.js .wp-core-ui .hide-if-js, +.no-js.wp-core-ui .hide-if-no-js, +.no-js .wp-core-ui .hide-if-no-js { + display: none; +} + +/* @todo: Take a second look. Large chunks of shared color, from the colors.css merge */ +.widget-top, +.menu-item-handle, +.widget-inside, +#menu-settings-column .accordion-container, +#menu-management .menu-edit, +.manage-menus, +table.widefat, +.stuffbox, +p.popular-tags, +.widgets-holder-wrap, +.wp-editor-container, +.popular-tags, +.feature-filter, +.imgedit-group, +.comment-ays { + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +table.widefat, +.wp-editor-container, +.stuffbox, +p.popular-tags, +.widgets-holder-wrap, +.popular-tags, +.feature-filter, +.imgedit-group, +.comment-ays { + background: #fff; +} + +/* general */ +html, +body { + height: 100%; + margin: 0; + padding: 0; +} + +body { + background: #f1f1f1; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 13px; + line-height: 1.4em; + min-width: 600px; +} + +body.iframe { + min-width: 0; + padding-top: 1px; +} + +body.modal-open { + overflow: hidden; +} + +body.mobile.modal-open #wpwrap { + overflow: hidden; + position: fixed; + height: 100%; +} + +iframe, +img { + border: 0; +} + +td { + font-family: inherit; + font-size: inherit; + font-weight: inherit; + line-height: inherit; +} + +/* Any change to the default link style must be applied to button-link too. */ +a { + color: #0073aa; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +a, +div { + outline: 0; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus, +a:focus .media-icon img, +.wp-person a:focus .gravatar { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +#adminmenu a:focus, +.screen-reader-text:focus { + box-shadow: none; + outline: none; +} + +blockquote, +q { + quotes: none; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; + content: none; +} + +p { + font-size: 13px; + line-height: 1.5; + margin: 1em 0; +} + +blockquote { + margin: 1em; +} + +li, +dd { + margin-bottom: 6px; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + display: block; + font-weight: 600; +} + +h1 { + color: #23282d; + font-size: 2em; + margin: .67em 0; +} + +h2, +h3 { + color: #23282d; + font-size: 1.3em; + margin: 1em 0; +} + +.update-core-php h2 { + margin-top: 2em; +} + +.update-php h2, +.update-messages h2, +h4 { + font-size: 1em; + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.67em; + margin: 2.33em 0; +} + +ul, +ol { + padding: 0; +} + +ul { + list-style: none; +} + +ol { + list-style-type: decimal; + margin-left: 2em; +} + +ul.ul-disc { + list-style: disc outside; +} + +ul.ul-square { + list-style: square outside; +} + +ol.ol-decimal { + list-style: decimal outside; +} + +ul.ul-disc, +ul.ul-square, +ol.ol-decimal { + margin-left: 1.8em; +} + +ul.ul-disc > li, +ul.ul-square > li, +ol.ol-decimal > li { + margin: 0 0 0.5em; +} + +/* rtl:ignore */ +.ltr { + direction: ltr; +} + +/* rtl:ignore */ +.code, +code { + font-family: Consolas, Monaco, monospace; + direction: ltr; + unicode-bidi: embed; +} + +kbd, +code { + padding: 3px 5px 2px 5px; + margin: 0 1px; + background: #eaeaea; + background: rgba(0,0,0,0.07); + font-size: 13px; +} + +.subsubsub { + list-style: none; + margin: 8px 0 0; + padding: 0; + font-size: 13px; + float: left; + color: #666; +} + +.subsubsub a { + line-height: 2; + padding: .2em; + text-decoration: none; +} + +.subsubsub a .count, +.subsubsub a.current .count { + color: #555d66; /* #f1f1f1 background */ + font-weight: 400; +} + +.subsubsub a.current { + font-weight: 600; + border: none; +} + +.subsubsub li { + display: inline-block; + margin: 0; + padding: 0; + white-space: nowrap; +} + +/* .widefat - main style for tables */ +.widefat { + border-spacing: 0; + width: 100%; + clear: both; + margin: 0; +} + +.widefat * { + word-wrap: break-word; +} + +.widefat a, +.widefat button.button-link { + text-decoration: none; +} + +.widefat td, +.widefat th { + padding: 8px 10px; +} + +.widefat thead th, +.widefat thead td { + border-bottom: 1px solid #e1e1e1; +} + +.widefat tfoot th, +.widefat tfoot td { + border-top: 1px solid #e1e1e1; + border-bottom: none; +} + +.widefat .no-items td { + border-bottom-width: 0; +} + +.widefat td { + vertical-align: top; +} + +.widefat td, +.widefat td p, +.widefat td ol, +.widefat td ul { + font-size: 13px; + line-height: 1.5em; +} + +.widefat th, +.widefat thead td, +.widefat tfoot td { + text-align: left; + line-height: 1.3em; + font-size: 14px; +} + +.widefat th input, +.updates-table td input, +.widefat thead td input, +.widefat tfoot td input { + margin: 0 0 0 8px; + padding: 0; + vertical-align: text-top; +} + +.widefat .check-column { + width: 2.2em; + padding: 6px 0 25px; + vertical-align: top; +} + +.widefat tbody th.check-column { + padding: 9px 0 22px; +} + +.widefat thead td.check-column, +.widefat tbody th.check-column, +.updates-table tbody td.check-column, +.widefat tfoot td.check-column { + padding: 11px 0 0 3px; +} + +.widefat thead td.check-column, +.widefat tfoot td.check-column { + padding-top: 4px; + vertical-align: middle; +} + +.update-php div.updated, +.update-php div.error { + margin-left: 0; +} + +.no-js .widefat thead .check-column input, +.no-js .widefat tfoot .check-column input { + display: none; +} + +.widefat .num, +.column-comments, +.column-links, +.column-posts { + text-align: center; +} + +.widefat th#comments { + vertical-align: middle; +} + +.wrap { + margin: 10px 20px 0 2px; +} + +.wrap > h2:first-child, /* Back-compat for pre-4.4 */ +.wrap [class$="icon32"] + h2, /* Back-compat for pre-4.4 */ +.postbox .inside h2, /* Back-compat for pre-4.4 */ +.wrap h1 { + font-size: 23px; + font-weight: 400; + margin: 0; + padding: 9px 0 4px 0; + line-height: 29px; +} + +.wrap h1.wp-heading-inline { + display: inline-block; + margin-right: 5px; +} + +.wp-header-end { + visibility: hidden; + margin: -2px 0 0; +} + +.subtitle { + margin: 0; + padding-left: 25px; + color: #555d66; + font-size: 14px; + font-weight: 400; + line-height: 1; +} + +.wrap .add-new-h2, /* deprecated */ +.wrap .add-new-h2:active, /* deprecated */ +.wrap .page-title-action, +.wrap .page-title-action:active { + margin-left: 4px; + padding: 4px 8px; + position: relative; + top: -3px; + text-decoration: none; + border: none; + border: 1px solid #ccc; + border-radius: 2px; + background: #f7f7f7; + text-shadow: none; + font-weight: 600; + font-size: 13px; + line-height: normal; /* IE8-IE11 need this for buttons */ + color: #0073aa; /* some of these controls are button elements and don't inherit from links */ + cursor: pointer; + outline: 0; +} + +.wrap .wp-heading-inline + .page-title-action { + margin-left: 0; +} + +.wrap .add-new-h2:hover, /* deprecated */ +.wrap .page-title-action:hover { + border-color: #008EC2; + background: #00a0d2; + color: #fff; +} + +/* lower specificity: color needs to be overridden by :hover and :active */ +.page-title-action:focus { + color: #124964; +} + +.wrap .page-title-action:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +.wrap h1.long-header { + padding-right: 0; +} + +.wp-dialog { + background-color: #fff; +} + +.widgets-chooser ul, +#widgets-left .widget-in-question .widget-top, +#available-widgets .widget-top:hover, +div#widgets-right .widget-top:hover, +#widgets-left .widget-top:hover { + border-color: #999; + box-shadow: 0 1px 2px rgba(0,0,0,0.1); +} + +.sorthelper { + background-color: #ccf3fa; +} + +.ac_match, +.subsubsub a.current { + color: #000; +} + +.striped > tbody > :nth-child(odd), +ul.striped > :nth-child(odd), +.alternate { + background-color: #f9f9f9; +} + +.bar { + background-color: #e8e8e8; + border-right-color: #99d; +} + +/* Helper classes for plugins to leverage the active WordPress color scheme */ + +.highlight { + background-color: #e4f2fd; + color: #000; +} + +.wp-ui-primary { + color: #fff; + background-color: #32373c; +} +.wp-ui-text-primary { + color: #32373c; +} + +.wp-ui-highlight { + color: #fff; + background-color: #1e8cbe; +} +.wp-ui-text-highlight { + color: #1e8cbe; +} + +.wp-ui-notification { + color: #fff; + background-color: #d54e21; +} +.wp-ui-text-notification { + color: #d54e21; +} + +.wp-ui-text-icon { + color: #82878c; /* same as new icons */ +} + +/* For emoji replacement images */ +img.emoji { + display: inline !important; + border: none !important; + height: 1em !important; + width: 1em !important; + margin: 0 .07em !important; + vertical-align: -0.1em !important; + background: none !important; + padding: 0 !important; + box-shadow: none !important; +} + +/*------------------------------------------------------------------------------ + 1.0 - Text Styles +------------------------------------------------------------------------------*/ + +.widget .widget-top, +.postbox .hndle, +.stuffbox .hndle, +.control-section .accordion-section-title, +.sidebar-name, +#nav-menu-header, +#nav-menu-footer, +.menu-item-handle, +.checkbox, +.side-info, +#your-profile #rich_editing, +.widefat thead th, +.widefat thead td, +.widefat tfoot th, +.widefat tfoot td { + line-height: 1.4em; +} + +.widget .widget-top, +.menu-item-handle { + background: #fafafa; + color: #23282d; +} + +.postbox .hndle, +.stuffbox .hndle { + border-bottom: 1px solid #eee; +} + +.quicktags, +.search { + background-color: #ccc; + color: #000; + font-size: 12px; +} + +.icon32 { + display: none; +} + +/* @todo can we combine these into a class or use an existing dashicon one? */ +.welcome-panel .welcome-panel-close:before, +.tagchecklist .ntdelbutton .remove-tag-icon:before, +#bulk-titles div a:before, +.notice-dismiss:before { + background: none; + color: #72777c; + content: "\f153"; + display: block; + font: normal 16px/20px dashicons; + speak: none; + height: 20px; + text-align: center; + width: 20px; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.welcome-panel .welcome-panel-close:before { + margin: 0; +} + +#bulk-titles div a:before { + margin: 1px 0; +} + +.tagchecklist .ntdelbutton .remove-tag-icon:before { + margin-left: 2px; + border-radius: 50%; + color: #0073aa; + /* vertically center the icon cross browsers */ + line-height: 1.28; +} + +.tagchecklist .ntdelbutton:focus { + outline: 0; +} + +.welcome-panel .welcome-panel-close:hover:before, +.welcome-panel .welcome-panel-close:focus:before, +.tagchecklist .ntdelbutton:hover .remove-tag-icon:before, +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before, +#bulk-titles div a:hover:before, +#bulk-titles div a:focus:before { + color: #c00; +} + +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.key-labels label { + line-height: 24px; +} + +strong, b { + font-weight: 600; +} + +.pre { + /* https://developer.mozilla.org/en-US/docs/CSS/white-space */ + white-space: pre-wrap; /* css-3 */ + word-wrap: break-word; /* IE 5.5 - 7 */ +} + +.howto { + color: #666; + font-style: italic; + display: block; +} + +p.install-help { + margin: 8px 0; + font-style: italic; +} + +.no-break { + white-space: nowrap; +} + +hr { + border: 0; + border-top: 1px solid #ddd; + border-bottom: 1px solid #fafafa; +} + +.row-actions span.delete a, +.row-actions span.trash a, +.row-actions span.spam a, +.plugins a.delete, +#all-plugins-table .plugins a.delete, +#search-plugins-table .plugins a.delete, +.submitbox .submitdelete, +#media-items a.delete, +#media-items a.delete-permanently, +#nav-menu-footer .menu-delete, +#delete-link a.delete { + color: #a00; +} + +abbr.required, +span.required, +.file-error, +.row-actions .delete a:hover, +.row-actions .trash a:hover, +.row-actions .spam a:hover, +.plugins a.delete:hover, +#all-plugins-table .plugins a.delete:hover, +#search-plugins-table .plugins a.delete:hover, +.submitbox .submitdelete:hover, +#media-items a.delete:hover, +#media-items a.delete-permanently:hover, +#nav-menu-footer .menu-delete:hover, +#delete-link a.delete:hover { + color: #dc3232; + border: none; +} + +/*------------------------------------------------------------------------------ + 3.0 - Actions +------------------------------------------------------------------------------*/ + +#major-publishing-actions { + padding: 10px; + clear: both; + border-top: 1px solid #ddd; + background: #f5f5f5; +} + +#delete-action { + float: left; + line-height: 28px; +} + +#delete-link { + line-height: 28px; + vertical-align: middle; + text-align: left; + margin-left: 8px; +} + +#delete-link a { + text-decoration: none; +} + +#publishing-action { + text-align: right; + float: right; + line-height: 23px; +} + +#publishing-action .spinner { + float: left; +} + +#misc-publishing-actions { + padding: 6px 0 0; +} + +.misc-pub-section { + padding: 6px 10px 8px; +} + +.misc-pub-filename { + word-wrap: break-word; +} + +#minor-publishing-actions { + padding: 10px 10px 0 10px; + text-align: right; +} + +#save-post { + float: left; +} + +.preview { + float: right; +} + +#sticky-span { + margin-left: 18px; +} + +.approve, +.unapproved .unapprove { + display: none; +} + +.unapproved .approve, +.spam .approve, +.trash .approve { + display: inline; +} + +td.action-links, +th.action-links { + text-align: right; +} + +#misc-publishing-actions .notice { + margin-left: 10px; + margin-right: 10px; +} + +/* Filter bar */ +.wp-filter { + display: inline-block; + position: relative; + box-sizing: border-box; + margin: 12px 0 25px; + padding: 0 10px; + width: 100%; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + border: 1px solid #e5e5e5; + background: #fff; + color: #555; + font-size: 13px; +} + +.wp-filter a { + text-decoration: none; +} + +.filter-count { + display: inline-block; + vertical-align: middle; + min-width: 4em; +} + +.title-count, +.filter-count .count { + display: inline-block; + position: relative; + top: -1px; + padding: 4px 10px; + border-radius: 30px; + background: #72777c; + color: #fff; + font-size: 14px; + font-weight: 600; +} + +/* not a part of filter bar, but derived from it, so here for now */ +.title-count { + display: inline; + top: -3px; + margin-left: 5px; + margin-right: 20px; +} + +.filter-items { + float: left; +} + +.filter-links { + display: inline-block; + margin: 0; +} + +.filter-links li { + display: inline-block; + margin: 0; +} + +.filter-links li > a { + display: inline-block; + margin: 0 10px; + padding: 15px 0; + border-bottom: 4px solid #fff; + color: #666; + cursor: pointer; +} + +.filter-links .current { + box-shadow: none; + border-bottom: 4px solid #666; + color: #23282d; +} + +.filter-links li > a:hover, +.filter-links li > a:focus, +.show-filters .filter-links a.current:hover, +.show-filters .filter-links a.current:focus { + color: #00a0d2; +} + +.wp-filter .search-form { + float: right; + margin: 10px 0; +} + +.wp-filter .search-form input[type="search"] { + margin: 0; + padding: 3px 5px; + width: 280px; + max-width: 100%; + font-size: 16px; + font-weight: 300; + line-height: 1.5; +} + +.wp-filter .search-form select { + margin: 0; + height: 32px; + vertical-align: top; +} + +.wp-filter .search-form.search-plugins { + display: inline-block; +} + +.wp-filter .button.drawer-toggle { + margin: 10px 9px 0; + padding: 0 10px 0 6px; + border-color: transparent; + background-color: transparent; + color: #666; + vertical-align: baseline; + box-shadow: none; +} + +.wp-filter .drawer-toggle:before { + content: "\f111"; + margin: 0 5px 0 0; + color: #72777c; + font: normal 16px/1 dashicons; + vertical-align: text-bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-filter .button.drawer-toggle:hover, +.wp-filter .drawer-toggle:hover:before, +.wp-filter .button.drawer-toggle:focus, +.wp-filter .drawer-toggle:focus:before { + background-color: transparent; + color: #00a0d2; +} + +.wp-filter .button.drawer-toggle:hover, +.wp-filter .button.drawer-toggle:focus:active { + border-color: transparent; +} + +.wp-filter .button.drawer-toggle:focus { + border-color: #5b9dd9; +} + +.wp-filter .button.drawer-toggle:active { + background: transparent; + box-shadow: none; + -webkit-transform: none; + transform: none; +} + +.wp-filter .drawer-toggle.current:before { + color: #fff; +} + +.filter-drawer, +.wp-filter .favorites-form { + display: none; + margin: 0 -10px 0 -20px; + padding: 20px; + border-top: 1px solid #eee; + background: #fafafa; + overflow: hidden; +} + +.show-filters .filter-drawer, +.show-favorites-form .favorites-form { + display: block; +} + +.show-filters .filter-links a.current { + border-bottom: none; +} + +.show-filters .wp-filter .button.drawer-toggle { + border-radius: 2px; + background: #72777c; + color: #fff; +} + +.show-filters .wp-filter .drawer-toggle:hover, +.show-filters .wp-filter .drawer-toggle:focus { + background: rgb(46, 162, 204); +} + +.show-filters .wp-filter .drawer-toggle:before { + color: #fff; +} + +.filter-group { + box-sizing: border-box; + position: relative; + float: left; + margin: 0 1% 0 0; + padding: 20px 10px 10px; + width: 24%; + background: #fff; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +.filter-group legend { + position: absolute; + top: 10px; + display: block; + margin: 0; + padding: 0; + font-size: 1em; + font-weight: 600; +} + +.filter-drawer .filter-group-feature { + margin: 28px 0 0; + list-style-type: none; + font-size: 12px; +} + +.filter-drawer .filter-group-feature input, +.filter-drawer .filter-group-feature label { + line-height: 16px; +} + +.filter-drawer .filter-group-feature input { + position: absolute; + margin: 0; +} + +.filter-group .filter-group-feature label { + display: block; + margin: 14px 0px 14px 23px; +} + +.filter-drawer .buttons { + clear: both; + margin-bottom: 20px; +} + +.filter-drawer .filter-group + .buttons { + margin-bottom: 0; + padding-top: 20px; +} + +.filter-drawer .buttons .button span { + display: inline-block; + opacity: 0.8; + font-size: 12px; + text-indent: 10px; +} + +.wp-filter .button.clear-filters { + display: none; + margin-left: 10px; +} + +.wp-filter .button-link.edit-filters { + padding: 0 5px; + line-height: 28px; +} + +.filtered-by { + display: none; + margin: 0; +} + +.filtered-by > span { + font-weight: 600; +} + +.filtered-by a { + margin-left: 10px; +} + +.filtered-by .tags { + display: inline; +} + +.filtered-by .tag { + margin: 0 5px; + padding: 4px 8px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; + font-size: 11px; +} + +.filters-applied .filter-group, +.filters-applied .filter-drawer .buttons, +.filters-applied .filter-drawer br { + display: none !important; +} + +.filters-applied .filtered-by { + display: block; +} + +.filters-applied .filter-drawer { + padding: 20px; +} + +.show-filters .favorites-form, +.show-filters .content-filterable, +.show-filters.filters-applied.loading-content .content-filterable, +.loading-content .content-filterable, +.error .content-filterable { + display: none; +} + +.show-filters.filters-applied .content-filterable { + display: block; +} + +.loading-content .spinner { + display: block; + margin: 40px auto 0; + float: none; +} + +@media only screen and (max-width: 1120px) { + .filter-drawer { + border-bottom: 1px solid #eee; + } + + .filter-group { + margin-bottom: 0; + margin-top: 5px; + width: 100%; + } + + .filter-group li { + margin: 10px 0; + } +} + +@media only screen and (max-width: 1000px) { + .filter-items { + float: none; + } + + .wp-filter .media-toolbar-primary, + .wp-filter .media-toolbar-secondary, + .wp-filter .search-form { + float: none; /* Remove float from media-views.css */ + position: relative; + max-width: 100%; + } +} + +@media only screen and (max-width: 782px) { + .filter-group li { + padding: 0; + width: 50%; + } +} + +@media only screen and (max-width: 320px) { + .filter-count { + display: none; + } + + .wp-filter .drawer-toggle { + margin: 10px 0; + } + + .filter-group li, + .wp-filter .search-form input[type="search"] { + width: 100%; + } +} + +/*------------------------------------------------------------------------------ + 4.0 - Notifications +------------------------------------------------------------------------------*/ + +.notice, +div.updated, +div.error { + background: #fff; + border-left: 4px solid #fff; + box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); + margin: 5px 15px 2px; + padding: 1px 12px; +} + +div[class="update-message"] { /* back-compat for pre-4.6 */ + padding: 0.5em 12px 0.5em 0; +} + +.notice p, +.notice-title, +div.updated p, +div.error p, +.form-table td .notice p { + margin: 0.5em 0; + padding: 2px; +} + +.error a { + text-decoration: underline; +} + +.updated a { + padding-bottom: 2px; +} + +.notice-alt { + box-shadow: none; +} + +.notice-large { + padding: 10px 20px; +} + +.notice-title { + display: inline-block; + color: #23282d; + font-size: 18px; +} + +.wp-core-ui .notice.is-dismissible { + padding-right: 38px; + position: relative; +} + +.notice-dismiss { + position: absolute; + top: 0; + right: 1px; + border: none; + margin: 0; + padding: 9px; + background: none; + color: #72777c; + cursor: pointer; +} + +.notice-dismiss:hover:before, +.notice-dismiss:active:before, +.notice-dismiss:focus:before { + color: #c00; +} + +.notice-dismiss:focus { + outline: none; + box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 .notice-dismiss:focus { + outline: 1px solid #5b9dd9; +} + +.notice-success, +div.updated { + border-left-color: #46b450; +} + +.notice-success.notice-alt { + background-color: #ecf7ed; +} + +.notice-warning { + border-left-color: #ffb900; +} + +.notice-warning.notice-alt { + background-color: #fff8e5; +} + +.notice-error, +div.error { + border-left-color: #dc3232; +} + +.notice-error.notice-alt { + background-color: #fbeaea; +} + +.notice-info { + border-left-color: #00a0d2; +} + +.notice-info.notice-alt { + background-color: #e5f5fa; +} + +.update-message p:before, +.updating-message p:before, +.updated-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.updated-message:before, +.button.installed:before, +.button.installing:before { + display: inline-block; + font: normal 20px/1 'dashicons'; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.wrap .notice, +.wrap div.updated, +.wrap div.error, +.media-upload-form .notice, +.media-upload-form div.error { + margin: 5px 0 15px; +} + +.wrap #templateside .notice { + display: block; + margin: 0; + padding: 5px 8px; + font-weight: 600; + text-decoration: none; +} + +.wrap #templateside span.notice { + margin-left: -12px; +} + +#templateside li.notice a { + padding: 0; +} + +/* Update icon. */ +.update-message p:before, +.updating-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.installing:before { + color: #f56e28; + content: "\f463"; +} + +/* Spins the update icon. */ +.updating-message p:before, +.import-php .updating-message:before, +.button.updating-message:before, +.button.installing:before { + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +/* Updated icon (check mark). */ +.updated-message p:before, +.installed p:before, +.button.updated-message:before { + color: #79ba49; + content: '\f147'; +} + +/* Error icon. */ +.update-message.notice-error p:before { + color: #dc3232; + content: "\f534"; +} + +.wrap .notice p:before, +.import-php .updating-message:before { + margin-right: 6px; + vertical-align: bottom; +} + +#update-nag, +.update-nag { + display: inline-block; + line-height: 19px; + padding: 11px 15px; + font-size: 14px; + text-align: left; + margin: 25px 20px 0 2px; + background-color: #fff; + border-left: 4px solid #ffba00; + box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1); +} + +ul#dismissed-updates { + display: none; +} + +form.upgrade { + margin-top: 8px; +} + +form.upgrade .hint { + font-style: italic; + font-size: 85%; + margin: -0.5em 0 2em 0; +} + +.update-php .spinner { + float: none; + margin: -4px 0; +} + +#ajax-loading, +.ajax-loading, +.ajax-feedback, +.imgedit-wait-spin, +.list-ajax-loading { /* deprecated */ + visibility: hidden; +} + +#ajax-response.alignleft { + margin-left: 2em; +} + +.button.updating-message:before, +.button.updated-message:before, +.button.installed:before, +.button.installing:before { + margin: 3px 5px 0 -2px; +} + +.button-primary.updating-message:before { + color: #fff; +} + +.button-primary.updated-message:before { + color: #66c6e4; +} + +.button.updated-message { + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +@media aural { + .wrap .notice p:before, + .button.installing:before, + .button.installed:before, + .update-message p:before { + speak: none; + } +} + + +/* @todo: this does not need its own section anymore */ +/*------------------------------------------------------------------------------ + 6.0 - Admin Header +------------------------------------------------------------------------------*/ +#adminmenu a, +#taglist a, +#catlist a { + text-decoration: none; +} + +/*------------------------------------------------------------------------------ + 6.1 - Screen Options Tabs +------------------------------------------------------------------------------*/ + +#screen-options-wrap, +#contextual-help-wrap { + margin: 0; + padding: 8px 20px 12px; + position: relative; +} + +#contextual-help-wrap { + overflow: auto; + margin-left: 0 !important; +} + +#screen-meta-links { + margin: 0 20px 0 0; +} + +/* screen options and help tabs revert */ +#screen-meta { + display: none; + margin: 0 20px -1px 0px; + position: relative; + background-color: #fff; + border: 1px solid #ddd; + border-top: none; + box-shadow: 0 1px 0 rgba(0,0,0,.025); +} + +#screen-options-link-wrap, +#contextual-help-link-wrap { + float: right; + height: 28px; + margin: 0 0 0 6px; + border: 1px solid #ddd; + border-top: none; + background: #fff; + box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1); +} + +#screen-meta-links .screen-meta-toggle { + position: relative; + top: 0; +} + +#screen-meta-links .show-settings { + border: 0; + background: none; + border-radius: 0; + color: #72777c; + line-height: 1.7; + padding: 3px 6px 3px 16px; +} + +#screen-meta-links .show-settings:hover, +#screen-meta-links .show-settings:active, +#screen-meta-links .show-settings:focus { + color: #32373c; +} + +#screen-meta-links .show-settings:active { + box-shadow: none; + -webkit-transform: none; + transform: none; +} + +#screen-meta-links .show-settings:after { + right: 0; + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0 5px 0 0; + bottom: 2px; + position: relative; + vertical-align: bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #72777c; +} + +#screen-meta-links .screen-meta-active:after { + content: "\f142"; +} + +/* end screen options and help tabs */ + +.toggle-arrow { + background-repeat: no-repeat; + background-position: top left; + background-color: transparent; + height: 22px; + line-height: 22px; + display: block; +} + +.toggle-arrow-active { + background-position: bottom left; +} + +#screen-options-wrap h5, /* Back-compat for old plugins */ +#screen-options-wrap legend, +#contextual-help-wrap h5 { + margin: 0; + padding: 8px 0; + font-size: 13px; + font-weight: 600; +} + +.ie8 #screen-options-wrap legend { + color: inherit; +} + +.metabox-prefs label { + display: inline-block; + padding-right: 15px; + line-height: 30px; +} + +#number-of-columns { + display: inline-block; + vertical-align: middle; + line-height: 30px; +} + +.metabox-prefs input[type=checkbox] { + margin-top: 0; + margin-right: 6px; +} + +.metabox-prefs label input, +.metabox-prefs label input[type=checkbox] { + margin: -4px 5px 0 0; +} + +.metabox-prefs .columns-prefs label input { + margin: -1px 2px 0 0; +} + +.metabox-prefs label a { + display: none; +} + +.metabox-prefs .screen-options input, +.metabox-prefs .screen-options label { + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; +} + +.metabox-prefs .screen-options .screen-per-page { + margin-right: 15px; +} + +.metabox-prefs .screen-options label { + line-height: 28px; + padding-right: 0; +} + +.screen-options + .screen-options { + margin-top: 10px; +} + +.metabox-prefs .submit { + margin-top: 1em; + padding: 0; +} + +/*------------------------------------------------------------------------------ + 6.2 - Help Menu +------------------------------------------------------------------------------*/ + +#contextual-help-wrap { + padding: 0; +} + +#contextual-help-columns { + position: relative; +} + +#contextual-help-back { + position: absolute; + top: 0; + bottom: 0; + left: 150px; + right: 170px; + border: 1px solid #e1e1e1; + border-top: none; + border-bottom: none; + background: #f6fbfd; +} + +#contextual-help-wrap.no-sidebar #contextual-help-back { + right: 0; + border-right-width: 0; + border-bottom-right-radius: 2px; +} + +.contextual-help-tabs { + float: left; + width: 150px; + margin: 0; +} + +.contextual-help-tabs ul { + margin: 1em 0; +} + +.contextual-help-tabs li { + margin-bottom: 0; + list-style-type: none; + border-style: solid; + border-width: 0 0 0 2px; + border-color: transparent; +} + +.contextual-help-tabs a { + display: block; + padding: 5px 5px 5px 12px; + line-height: 18px; + text-decoration: none; + border: 1px solid transparent; + border-right: none; + border-left: none; +} + +.contextual-help-tabs a:hover { + color: #32373c; +} + +.contextual-help-tabs .active { + padding: 0; + margin: 0 -1px 0 0; + border-left: 2px solid #00a0d2; + background: #f6fbfd; + box-shadow: 0 2px 0 rgba(0,0,0,0.02), 0 1px 0 rgba(0,0,0,0.02); +} + +.contextual-help-tabs .active a { + border-color: #e1e1e1; + color: #32373c; +} + +.contextual-help-tabs-wrap { + padding: 0 20px; + overflow: auto; +} + +.help-tab-content { + display: none; + margin: 0 22px 12px 0; + line-height: 1.6em; +} + +.help-tab-content.active { + display: block; +} + +.help-tab-content ul li { + list-style-type: disc; + margin-left: 18px; +} + +.contextual-help-sidebar { + width: 150px; + float: right; + padding: 0 8px 0 12px; + overflow: auto; +} + +/*------------------------------------------------------------------------------ + 8.0 - Layout Blocks +------------------------------------------------------------------------------*/ + +html.wp-toolbar { + padding-top: 32px; + box-sizing: border-box; +} + +.widefat th, +.widefat td { + color: #555; +} + +.widefat th, +.widefat thead td, +.widefat tfoot td { + font-weight: 400; +} + +.widefat thead tr th, +.widefat thead tr td, +.widefat tfoot tr th, +.widefat tfoot tr td { + color: #32373c; +} + +.widefat td p { + margin: 2px 0 0.8em; +} + +.widefat p, +.widefat ol, +.widefat ul { + color: #32373c; +} + +.widefat .column-comment p { + margin: 0.6em 0; +} + +.widefat .column-comment ul { + list-style: initial; + margin-left: 2em; +} + +/* Screens with postboxes */ +.postbox-container { + float: left; +} + +.postbox-container .meta-box-sortables { + box-sizing: border-box; +} + +#wpbody-content .metabox-holder { + padding-top: 10px; +} + +.metabox-holder .postbox-container .empty-container { + border: 3px dashed #b4b9be; + height: 250px; + position: relative; +} + +.metabox-holder .postbox-container .empty-container:after { + content: attr(data-emptystring); + margin: auto; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + height: 1em; + width: 200px; + text-align: center; + color: #ccc; + font-size:18px; + display: none; +} + +.metabox-holder.columns-1 .postbox-container .empty-container, +.columns-2 #postbox-container-3 .empty-container, +.columns-2 #postbox-container-4 .empty-container, +.columns-3 #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +#post-body-content { + width: 100%; + min-width: 463px; + float: left; +} + +#post-body.columns-2 #postbox-container-1 { + float: right; + margin-right: -300px; + width: 280px; +} + +#post-body.columns-2 #side-sortables { + min-height: 250px; +} + +/* one column on the dash */ +@media only screen and (max-width: 799px) { + #wpbody-content .metabox-holder .postbox-container .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } +} + +.js .widget .widget-top, +.js .postbox .hndle { + cursor: move; +} + +.hndle a { + font-size: 11px; + font-weight: 400; +} + +.postbox .handlediv { + display: none; + float: right; + width: 36px; + height: 36px; + margin: 0; + padding: 0; + border: 0; + background: none; + cursor: pointer; +} + +.js .postbox .handlediv { + display: block; +} + +.sortable-placeholder { + border: 1px dashed #b4b9be; + margin-bottom: 20px; +} + +.postbox, +.stuffbox { + margin-bottom: 20px; + padding: 0; + line-height: 1; +} + +/* user-select is not a part of the CSS standard - may change behavior in the future */ +.postbox .hndle, +.stuffbox .hndle { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.postbox .inside, +.stuffbox .inside { + padding: 0 12px 12px; + line-height: 1.4em; + font-size: 13px; +} + +.postbox .inside { + margin: 11px 0; + position: relative; +} + +.postbox .inside > p:last-child, +.rss-widget ul li:last-child { + margin-bottom: 1px !important; +} + +.postbox.closed h3 { + border: none; + box-shadow: none; +} + +.postbox table.form-table { + margin-bottom: 0; +} + +.postbox table.widefat { + box-shadow: none; +} + +.temp-border { + border: 1px dotted #ccc; +} + +.columns-prefs label { + padding: 0 10px 0 0; +} + +/* @todo: what is this doing here */ +#dashboard_right_now .versions .b, +#post-status-display, +#post-visibility-display, +#adminmenu .wp-submenu li.current, +#adminmenu .wp-submenu li.current a, +#adminmenu .wp-submenu li.current a:hover, +.media-item .percent, +.plugins .name, +#pass-strength-result.strong, +#pass-strength-result.short, +#ed_reply_toolbar #ed_reply_strong, +.item-controls .item-order a, +.feature-filter .feature-name { + font-weight: 600; +} + +/*------------------------------------------------------------------------------ + 21.0 - Admin Footer +------------------------------------------------------------------------------*/ + +#wpfooter { + position: absolute; + bottom: 0; + left: 0; + right: 0; + padding: 10px 20px; + color: #555d66; +} + +#wpfooter p { + font-size: 13px; + margin: 0; + line-height: 20px; +} + +#footer-thankyou { + font-style: italic; +} + +/*------------------------------------------------------------------------------ + 25.0 - Tabbed Admin Screen Interface (Experimental) +------------------------------------------------------------------------------*/ + +.nav-tab { + float: left; + border: 1px solid #ccc; + border-bottom: none; + margin-left: 0.5em; /* half the font size so set the font size properly */ + padding: 5px 10px; + font-size: 14px; + line-height: 24px; + font-weight: 600; + background: #e5e5e5; + color: #555; + text-decoration: none; + white-space: nowrap; +} + +h3 .nav-tab, /* Back-compat for pre-4.4 */ +.nav-tab-small .nav-tab { + padding: 5px 14px; + font-size: 12px; + line-height: 16px; +} + +.nav-tab:hover, +.nav-tab:focus { + background-color: #fff; + color: #444; +} + +.nav-tab-active, +.nav-tab:focus:active { + box-shadow: none; +} + +.nav-tab-active { + margin-bottom: -1px; + color: #444; +} + +.nav-tab-active, +.nav-tab-active:hover, +.nav-tab-active:focus, +.nav-tab-active:focus:active { + border-bottom: 1px solid #f1f1f1; + background: #f1f1f1; + color: #000; +} + +h1.nav-tab-wrapper, /* Back-compat for pre-4.4 */ +.wrap h2.nav-tab-wrapper, /* higher specificity to override .wrap > h2:first-child */ +.nav-tab-wrapper { + border-bottom: 1px solid #ccc; + margin: 0; + padding-top: 9px; + padding-bottom: 0; + line-height: inherit; +} + +/* Back-compat for plugins. Deprecated. Use .wp-clearfix instead. */ +.nav-tab-wrapper:not(.wp-clearfix):after { + content: ""; + display: table; + clear: both; + } + +.ie8 .nav-tab-wrapper { + /* contain floats establishing a new block formatting context */ + display: inline-block; + width: 100%; + vertical-align: top; +} + +/*------------------------------------------------------------------------------ + 26.0 - Misc +------------------------------------------------------------------------------*/ + +.spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + display: inline-block; + visibility: hidden; + float: right; + vertical-align: middle; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 4px 10px 0; +} + +.spinner.is-active, +.loading-content .spinner { + visibility: visible; +} + +#template > div { + margin-right: 16em; +} +#template .notice { + margin-top: 1em; + margin-right: 3%; +} +#template .notice p { + width: auto; +} +#template .submit .spinner { + float: none; +} + +.metabox-holder .stuffbox > h3, /* Back-compat for pre-4.4 */ +.metabox-holder .postbox > h3, /* Back-compat for pre-4.4 */ +.metabox-holder h3.hndle, /* Back-compat for pre-4.4 */ +.metabox-holder h2.hndle { + font-size: 14px; + padding: 8px 12px; + margin: 0; + line-height: 1.4; +} + +/* Back-compat for nav-menus screen */ +.nav-menus-php .metabox-holder h3 { + padding: 10px 10px 11px 14px; + line-height: 21px; +} + +#templateside ul li a { + text-decoration: none; +} + +.plugin-install #description, +.plugin-install-network #description { + width: 60%; +} + +table .vers, +table .column-visible, +table .column-rating { + text-align: left; +} + +.attention, +.error-message { + color: #dc3232; + font-weight: 600; +} + +/* Scrollbar fix for bulk upgrade iframe */ +body.iframe { + height: 98%; +} + +/* Upgrader styles, Specific to Language Packs */ +.lp-show-latest p { + display: none; +} +.lp-show-latest p:last-child, +.lp-show-latest .lp-error p { + display: block; +} + +/* - Only used once or twice in all of WP - deprecate for global style +------------------------------------------------------------------------------*/ +.media-icon { + width: 62px; /* icon + border */ + text-align: center; +} + +.media-icon img { + border: 1px solid #e5e5e5; + border: 1px solid rgba(0, 0, 0, 0.07); +} + +#howto { + font-size: 11px; + margin: 0 5px; + display: block; +} + +.importers { + font-size: 16px; + width: auto; +} + +.importers td { + padding-right: 14px; + line-height: 1.5em; +} + +.importers .import-system { + max-width: 250px; +} + +.importers td.desc { + max-width: 500px; +} + +.importer-title, +.importer-desc, +.importer-action { + display: block; +} + +.importer-title { + color: #000; + font-size: 14px; + font-weight: 400; + margin-bottom: .2em; +} + +.importer-action { + line-height: 20px; /* Same as with .updating-message */ + color: #555; + margin-bottom: 1em; +} + +#post-body #post-body-content #namediv h3, /* Back-compat for pre-4.4 */ +#post-body #post-body-content #namediv h2 { + margin-top: 0; +} + +.edit-comment-author { + font-size: 14px; + line-height: 1.4; + font-weight: 600; + color: #222; + margin: 2px 0 0 9px; +} + +#namediv h3 label, /* Back-compat for pre-4.4 */ +#namediv h2 label { + vertical-align: baseline; +} + +#namediv table { + width: 100%; +} + +#namediv td.first { + width: 10px; + white-space: nowrap; +} + +#namediv input { + width: 98%; +} + +#namediv p { + margin: 10px 0; +} + +#submitdiv h3 { + margin-bottom: 0 !important; +} + +/* - Used - but could/should be deprecated with a CSS reset +------------------------------------------------------------------------------*/ +.zerosize { + height: 0; + width: 0; + margin: 0; + border: 0; + padding: 0; + overflow: hidden; + position: absolute; +} + +br.clear { + height: 2px; + line-height: 2px; +} + +.checkbox { + border: none; + margin: 0; + padding: 0; +} + +fieldset { + border: 0; + padding: 0; + margin: 0; +} + +.post-categories { + display: inline; + margin: 0; + padding: 0; +} + +.post-categories li { + display: inline; +} + +/* Star Ratings - Back-compat for pre-3.8 */ +div.star-holder { + position: relative; + height: 17px; + width: 100px; + background: url(../images/stars.png?ver=20121108) repeat-x bottom left; +} + +div.star-holder .star-rating { + background: url(../images/stars.png?ver=20121108) repeat-x top left; + height: 17px; + float: left; +} + +/* Star Ratings */ +.star-rating { + white-space: nowrap; +} +.star-rating .star { + display: inline-block; + width: 20px; + height: 20px; + -webkit-font-smoothing: antialiased; + font-size: 20px; + line-height: 1; + font-family: dashicons; + text-decoration: inherit; + font-weight: 400; + font-style: normal; + vertical-align: top; + transition: color .1s ease-in 0; + text-align: center; + color: #ffb900; +} + +.star-rating .star-full:before { + content: "\f155"; +} + +.star-rating .star-half:before { + content: "\f459"; +} + +.rtl .star-rating .star-half { + -webkit-transform: rotateY(180deg); + transform: rotateY(180deg); +} + +.star-rating .star-empty:before { + content: "\f154"; +} + +div.action-links { + font-weight: 400; + margin: 6px 0 0; +} + +/* Plugin install thickbox */ +#plugin-information { + background: #fff; + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + height: 100%; + padding: 0; +} + +#plugin-information-scrollable { + overflow: auto; + -webkit-overflow-scrolling: touch; + height: 100%; +} + +#plugin-information-title { + padding: 0 26px; + background: #f5f5f5; + font-size: 22px; + font-weight: 600; + line-height: 56px; + position: relative; + height: 56px; +} + +#plugin-information-title.with-banner { + margin-right: 0; + height: 250px; + background-size: cover; +} + +#plugin-information-title h2 { + font-size: 1em; + font-weight: 600; + padding: 0; + margin: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +#plugin-information-title.with-banner h2 { + position: relative; + font-family: "Helvetica Neue", sans-serif; + display: inline-block; + font-size: 30px; + line-height: 50px; + box-sizing: border-box; + max-width: 100%; + padding: 0 15px; + margin-top: 174px; + color: #fff; + background: rgba( 30, 30, 30, 0.9 ); + text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.4 ); + box-shadow: 0 0 30px rgba( 255, 255, 255, 0.1 ); + border-radius: 8px; +} + +#plugin-information-title div.vignette { + display: none; +} + +#plugin-information-title.with-banner div.vignette { + position: absolute; + display: block; + top: 0; + left: 0; + height: 250px; + width: 100%; + background: transparent; + box-shadow: inset 0 0 50px 4px rgba( 0, 0, 0, 0.2 ), inset 0 -1px 0 rgba( 0, 0, 0, 0.1 ); +} + +#plugin-information-tabs { + padding: 0 16px; + position: relative; + right: 0; + left: 0; + min-height: 36px; + font-size: 0; + z-index: 1; + border-bottom: 1px solid #ddd; + background: #f3f3f3; +} + +#plugin-information-tabs a { + position: relative; + display: inline-block; + padding: 9px 10px; + margin: 0; + height: 18px; + line-height: 18px; + font-size: 14px; + text-decoration: none; + transition: none; +} + +#plugin-information-tabs a.current { + margin: 0 -1px -1px; + background: #fff; + border: 1px solid #ddd; + border-bottom-color: #fff; + padding-top: 8px; + color: #32373c; +} + +#plugin-information-tabs.with-banner a.current { + border-top: none; + padding-top: 9px; +} + +#plugin-information-tabs a:active, +#plugin-information-tabs a:focus { + outline: none; +} + +#plugin-information-content { + overflow: hidden; /* equal height column trick */ + background: #fff; + position: relative; + top: 0; + right: 0; + left: 0; + min-height: 100%; + /* Height of title + tabs + install now */ + min-height: calc( 100% - 152px ); +} + +#plugin-information-content.with-banner { + /* Height of banner + tabs + install now */ + min-height: calc( 100% - 346px ); +} + +#section-holder { + position: relative; + top: 0; + right: 250px; + bottom: 0; + left: 0; + margin-right: 250px; /* FYI box */ + padding: 10px 26px; + margin-bottom: -99939px; /* 60px less than the padding below to accommodate footer */ + padding-bottom: 99999px; /* equal height column trick */ +} + +#section-holder .updated { + margin: 16px 0; +} + +#plugin-information .fyi { + float: right; + position: relative; + top: 0; + right: 0; + padding: 16px; + margin-bottom: -99939px; /* 60px less than the padding below to accommodate footer */ + padding-bottom: 99999px; /* equal height column trick */ + width: 217px; + border-left: 1px solid #ddd; + background: #f3f3f3; + color: #666; +} + +#plugin-information .fyi strong { + color: #444; +} + +#plugin-information .fyi h3 { + font-weight: 600; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 24px 0 8px; +} + +#plugin-information .fyi h2 { + font-size: 0.9em; + margin-bottom: 0; + margin-right: 0; +} + +#plugin-information .fyi ul { + padding: 0; + margin: 0; + list-style: none; +} + +#plugin-information .fyi li { + margin: 0 0 10px; +} + +#plugin-information .fyi-description { + margin-top: 0; +} + +#plugin-information .counter-container { + margin: 3px 0; +} + +#plugin-information .counter-label { + float: left; + margin-right: 5px; + min-width: 55px; +} + +#plugin-information .counter-back { + height: 17px; + width: 92px; + background-color: #e5e5e5; + float: left; +} + +#plugin-information .counter-bar { + height: 17px; + background-color: #ffc733; /* slightly lighter than stars due to larger expanse */ + float: left; +} + +#plugin-information .counter-count { + margin-left: 5px; +} + +#plugin-information .fyi ul.contributors { + margin-top: 10px; +} + +#plugin-information .fyi ul.contributors li { + display: inline-block; + margin-right: 8px; + vertical-align: middle; +} + +#plugin-information .fyi ul.contributors li { + display: inline-block; + margin-right: 8px; + vertical-align: middle; +} + +#plugin-information .fyi ul.contributors li img { + vertical-align: middle; + margin-right: 4px; +} + +#plugin-information-footer { + padding: 13px 16px; + position: absolute; + right: 0; + bottom: 0; + left: 0; + height: 33px; /* 33+13+13+1=60 */ + border-top: 1px solid #ddd; + background: #f3f3f3; +} + +/* rtl:ignore */ +#plugin-information .section { + direction: ltr; +} + +/* rtl:ignore */ +#plugin-information .section ul, +#plugin-information .section ol { + list-style-type: disc; + margin-left: 24px; +} + +#plugin-information .section, +#plugin-information .section p { + font-size: 14px; + line-height: 1.7; +} + +#plugin-information #section-screenshots ol { + list-style: none; + margin: 0; +} + +#plugin-information #section-screenshots li img { + vertical-align: text-top; + margin-top: 16px; + max-width: 100%; + width: auto; + height: auto; + box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.3 ); +} + +/* rtl:ignore */ +#plugin-information #section-screenshots li p { + font-style: italic; + padding-left: 20px; +} + +#plugin-information pre { + padding: 7px; + overflow: auto; + border: 1px solid #ccc; +} + +#plugin-information blockquote { + border-left: 2px solid #ddd; + color: #666; + font-style: italic; + margin: 1em 0; + padding: 0 0 0 1em; +} + +/* rtl:ignore */ +#plugin-information .review { + overflow: hidden; /* clearfix */ + width: 100%; + margin-bottom: 20px; + border-bottom: 1px solid #e5e5e5; +} + +#plugin-information .review-title-section { + overflow: hidden; /* clearfix */ +} + +/* rtl:ignore */ +#plugin-information .review-title-section h4 { + display: inline-block; + float: left; + margin: 0 6px 0 0; +} + +#plugin-information .reviewer-info p { + clear: both; + margin: 0; + padding-top: 2px; +} + +/* rtl:ignore */ +#plugin-information .reviewer-info .avatar { + float: left; + margin: 4px 6px 0 0; +} + +/* rtl:ignore */ +#plugin-information .reviewer-info .star-rating { + float: left; +} + +/* rtl:ignore */ +#plugin-information .review-meta { + float: left; + margin-left: 0.75em; +} + +/* rtl:ignore */ +#plugin-information .review-body { + float: left; + width: 100%; +} + +.plugin-version-author-uri { + font-size: 13px; +} + +/* For non-js plugin installation screen ticket #36430. */ +.update-php .button.button-primary { + margin-right: 1em; +} + +@media screen and ( max-width: 771px ) { + #plugin-information-title.with-banner { + height: 100px; + } + + #plugin-information-title.with-banner h2 { + margin-top: 30px; + font-size: 20px; + line-height: 40px; + max-width: 85%; + } + + #plugin-information-title.with-banner div.vignette { + height: 100px; + } + + #plugin-information-tabs { + overflow: hidden; /* clearfix */ + padding: 0; + height: auto; /* let tabs wrap */ + } + + #plugin-information-tabs a.current { + margin-bottom: 0; + border-bottom: none; + } + + #plugin-information .fyi { + float: none; + border: 1px solid #ddd; + position: static; + width: auto; + margin: 26px 26px 0; + padding-bottom: 0; /* reset from the two column height fix */ + } + + #section-holder { + position: static; + margin: 0; + padding-bottom: 70px; /* reset from the two column height fix, plus accommodate footer */ + } + + #plugin-information .fyi h3, + #plugin-information .fyi small { + display: none; + } + + #plugin-information-footer { + padding: 12px 16px 0; + height: 46px; + } +} + +/* Thickbox for the Plugin details modal. */ +#TB_window.plugin-details-modal { + background: #fcfcfc; +} + +#TB_window.plugin-details-modal.thickbox-loading:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + left: 50%; + top: 50%; + z-index: -1; + margin: -10px 0 0 -10px; + background: #fcfcfc url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + #TB_window.plugin-details-modal.thickbox-loading:before { + background-image: url(../images/spinner-2x.gif); + } +} + +.plugin-details-modal #TB_title { + float: left; + height: 1px; +} + +.plugin-details-modal #TB_ajaxWindowTitle { + display: none; +} + +.plugin-details-modal #TB_closeWindowButton { + left: auto; + right: -30px; + color: #eee; +} + +.plugin-details-modal #TB_closeWindowButton:hover, +.plugin-details-modal #TB_closeWindowButton:focus { + color: #00a0d2; + outline: none; + box-shadow: none; +} + +.plugin-details-modal .tb-close-icon { + display: none; +} + +.plugin-details-modal #TB_closeWindowButton:after { + content: "\f335"; + font: normal 32px/29px 'dashicons'; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* move plugin install close icon to top on narrow screens */ +@media screen and ( max-width: 830px ) { + .plugin-details-modal #TB_closeWindowButton { + right: 0; + top: -30px; + } +} + +/* @todo: move this. */ +img { + border: none; +} + +/* Metabox collapse arrow indicators */ +.sidebar-name .toggle-indicator:before, +.js .meta-box-sortables .postbox .toggle-indicator:before, +.bulk-action-notice .toggle-indicator:before, +.privacy-text-box .toggle-indicator:before { + content: "\f142"; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.js .widgets-holder-wrap.closed .toggle-indicator:before, +.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before, +.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before, +.privacy-text-box.closed .toggle-indicator:before { + content: "\f140"; +} + +.js .postbox .handlediv .toggle-indicator:before { + margin-top: 4px; + width: 20px; + border-radius: 50%; + text-indent: -1px; /* account for the dashicon alignment */ +} + +.rtl.js .postbox .handlediv .toggle-indicator:before { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.bulk-action-notice .toggle-indicator:before { + line-height: 16px; + vertical-align: top; + color: #72777c; +} + +.js .postbox .handlediv:focus { + box-shadow: none; + outline: none; +} + +.js .postbox .handlediv:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +/* @todo: appears to be Press This only and overridden */ +#photo-add-url-div input[type="text"] { + width: 300px; +} + +/* Theme/Plugin Editor */ +.alignleft h2 { + margin: 0; +} + +#template textarea { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + background: #f9f9f9; + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; +} + +#template textarea, +#template .CodeMirror { + width: 100%; + min-height: 60vh; + height: calc( 100vh - 295px ); + border: 1px solid #ddd; + box-sizing: border-box; +} + +#templateside > h2 { + padding-top: 6px; + padding-bottom: 7px; + margin: 0; +} + +#templateside ol, +#templateside ul { + margin: 0; + padding: 0; +} +#templateside > ul { + box-sizing: border-box; + margin-top: 0; + overflow: auto; + padding: 0; + min-height: 60vh; + height: calc(100vh - 295px); + background-color: #f7f7f7; + border: 1px solid #ddd; + border-left: none; +} +#templateside ul ul { + padding-left: 12px; +} +#templateside > ul > li > ul[role=group] { + padding-left: 0; +} + +/* + * Styles for Theme and Plugin editors. + */ + +/* Hide collapsed items. */ +[role="treeitem"][aria-expanded="false"] > ul { + display: none; +} + +/* Use arrow dashicons for folder states, but hide from screen readers. */ +[role="treeitem"] span[aria-hidden] { + display: inline; + font-family: dashicons; + font-size: 20px; + position: absolute; + pointer-events: none; +} +[role="treeitem"][aria-expanded="false"] > .folder-label .icon:after { + content: "\f139"; +} +[role="treeitem"][aria-expanded="true"] > .folder-label .icon:after { + content: "\f140"; +} +[role="treeitem"] .folder-label { + display: block; + padding: 3px 3px 3px 12px; + cursor: pointer; +} + +/* Remove outline, and create our own focus and hover styles */ +[role="treeitem"] { + outline: 0; +} +[role="treeitem"] .folder-label.focus { + color: #124964; + box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); +} +[role="treeitem"].hover, +[role="treeitem"] .folder-label.hover { + background-color: #eaeaea; +} + +.tree-folder { + margin: 0; + position: relative; +} +[role="treeitem"] li { + position: relative; +} + +/* Styles for folder indicators/depth */ +.tree-folder .tree-folder::after { + content: ' '; + display: block; + position: absolute; + left: 2px; + border-left: 1px solid #ccc; + top: -13px; + bottom: 10px; +} +.tree-folder > li::before { + content: ' '; + position: absolute; + display: block; + border-left: 1px solid #ccc; + left: 2px; + top: -5px; + height: 18px; + width: 7px; + border-bottom: 1px solid #ccc; +} +.tree-folder > li::after { + content: ' '; + position: absolute; + display: block; + border-left: 1px solid #ccc; + left: 2px; + bottom: -7px; + top: 0; +} + +/* current-file needs to adjustment for .notice styles */ +#templateside .current-file { + margin: -4px 0 -2px; +} +.tree-folder > .current-file::before { + left: 4px; + height: 15px; + width: 0px; + border-left: none; + top: 3px; +} +.tree-folder > .current-file::after { + bottom: -4px; + height: 7px; + left: 2px; + top: auto; +} + +/* Lines shouldn't continue on last item */ +.tree-folder > li:last-child::after, +.tree-folder li:last-child > .tree-folder::after { + display: none; +} + + +#theme-plugin-editor-label { + display: inline-block; + margin-bottom: 1em; + font-weight: 600; +} + +/* rtl:ignore */ +#template textarea, +#docs-list { + direction: ltr; +} + +.fileedit-sub #theme, +.fileedit-sub #plugin { + max-width: 40%; +} +.fileedit-sub .alignright { + text-align: right; +} + +#template p { + width: 97%; +} + +#file-editor-linting-error { + margin-top: 1em; + margin-bottom: 1em; +} +#file-editor-linting-error > .notice { + margin: 0; + display: inline-block; +} +#file-editor-linting-error > .notice > p { + width: auto; +} +#template .submit { + margin-top: 1em; + padding: 0; +} + +#template .submit input[type=submit][disabled] { + cursor: not-allowed; +} +#templateside { + float: right; + width: 16em; + word-wrap: break-word; +} + +#postcustomstuff p.submit { + margin: 0; +} + +#templateside h4 { + margin: 1em 0 0; +} + +#templateside li { + margin: 4px 0; +} + +#templateside li:not(.howto) a, +.theme-editor-php .highlight { + display: block; + padding: 3px 0 3px 12px; + text-decoration: none; +} + +#templateside li:not(.howto) > a:first-of-type { + padding-top: 0; +} + +#templateside li.howto { + padding: 6px 12px 12px 12px; +} + +.theme-editor-php .highlight { + margin: -3px 3px -3px -12px; +} + +#templateside .highlight { + border: none; + font-weight: 600; +} + +.nonessential { + color: #666; + font-size: 11px; + font-style: italic; + padding-left: 12px; +} + +#documentation { + margin-top: 10px; +} + +#documentation label { + line-height: 22px; + vertical-align: baseline; + font-weight: 600; +} + +.fileedit-sub { + padding: 10px 0 8px; + line-height: 180%; +} + +#file-editor-warning .file-editor-warning-content { + margin: 25px; +} + +/* @todo: can we use a common class for these? */ +.nav-menus-php .item-edit:before, +.widget-top .widget-action .toggle-indicator:before, +.control-section .accordion-section-title:after, +.accordion-section-title:after { + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.widget-top .widget-action .toggle-indicator:before { + padding: 1px 2px 1px 0px; + border-radius: 50%; +} + +.handlediv, +.postbox .handlediv.button-link, +.item-edit, +.toggle-indicator, +.accordion-section-title:after { + color: #72777c; +} + +.widget-action { + color: #555d66; /* #fafafa background in the Widgets screen */ +} + +.widget-top:hover .widget-action, +.widget-action:focus, +.handlediv:hover, +.handlediv:focus, +.postbox .handlediv.button-link:hover, +.postbox .handlediv.button-link:focus, +.item-edit:hover, +.item-edit:focus, +.sidebar-name:hover .toggle-indicator, +.accordion-section-title:hover:after { + color: #23282d; +} + +.widget-top .widget-action:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30,140,190,.8); +} + +.control-section .accordion-section-title:after, +.accordion-section-title:after { + float: right; + right: 20px; + top: -2px; +} + +.control-section.open .accordion-section-title:after, +#customize-info.open .accordion-section-title:after, +.nav-menus-php .menu-item-edit-active .item-edit:before, +.widget.open .widget-top .widget-action .toggle-indicator:before { + content: "\f142"; +} + +/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-draggable-handle, +.ui-sortable-handle { + touch-action: none; +} + +/* Accordion */ +.accordion-section { + border-bottom: 1px solid #ddd; + margin: 0; +} + +.accordion-section.open .accordion-section-content, +.no-js .accordion-section .accordion-section-content { + display: block; +} + +.accordion-section.open:hover { + border-bottom-color: #ddd; +} + +.accordion-section-content { + display: none; + padding: 10px 20px 15px; + overflow: hidden; + background: #fff; +} + +.accordion-section-title { + margin: 0; + padding: 12px 15px 15px; + position: relative; + border-left: 1px solid #ddd; + border-right: 1px solid #ddd; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.js .accordion-section-title { + cursor: pointer; +} + +.js .accordion-section-title:after { + position: absolute; + top: 12px; + right: 10px; + z-index: 1; +} + +.accordion-section-title:focus { + outline: none; +} + +.accordion-section-title:hover:after, +.accordion-section-title:focus:after { + border-color: #a0a5aa transparent; +} + +.cannot-expand .accordion-section-title { + cursor: auto; +} + +.cannot-expand .accordion-section-title:after { + display: none; +} + +.control-section .accordion-section-title, +.customize-pane-child .accordion-section-title { + border-left: none; + border-right: none; + padding: 10px 10px 11px 14px; + line-height: 21px; + background: #fff; +} + +.control-section .accordion-section-title:after, +.customize-pane-child .accordion-section-title:after { + top: calc(50% - 10px); /* Arrow height is 20px, so use half of that to vertically center */ +} + +.js .control-section:hover .accordion-section-title, +.js .control-section .accordion-section-title:hover, +.js .control-section.open .accordion-section-title, +.js .control-section .accordion-section-title:focus { + color: #23282d; + background: #f5f5f5; +} + +.control-section.open .accordion-section-title { + /* When expanded */ + border-bottom: 1px solid #ddd; +} + +/* Edit Site */ +.network-admin .edit-site-actions { + margin-top: 0; +} + +/* My Sites */ +.my-sites { + display: block; + overflow: auto; + zoom: 1; +} + +.my-sites li { + display: block; + padding: 8px 3%; + min-height: 130px; + margin: 0; +} + +@media only screen and (max-width: 599px) { + .my-sites li { + min-height: 0; + } +} + +@media only screen and (min-width: 600px) { + .my-sites.striped li { + background-color: #fff; + position: relative; + } + .my-sites.striped li:after { + content: ""; + width: 1px; + height: 100%; + position: absolute; + top: 0; + right: 0; + background: #ccc; + } + +} +@media only screen and (min-width: 600px) and (max-width: 699px) { + .my-sites li{ + float: left; + width: 44%; + } + .my-sites.striped li { + background-color: #fff; + } + .my-sites.striped li:nth-of-type(2n+1) { + clear: left; + } + .my-sites.striped li:nth-of-type(2n+2):after { + content: none; + } + .my-sites li:nth-of-type(4n+1), + .my-sites li:nth-of-type(4n+2) { + background-color: #f9f9f9; + } + +} + +@media only screen and (min-width: 700px) and (max-width: 1199px) { + .my-sites li { + float: left; + width: 27.333333%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(3n+3):after { + content: none; + } + .my-sites li:nth-of-type(6n+1), + .my-sites li:nth-of-type(6n+2), + .my-sites li:nth-of-type(6n+3) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1200px) and (max-width: 1399px) { + .my-sites li { + float: left; + width: 21%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(4n+1) { + clear: left; + } + .my-sites.striped li:nth-of-type(4n+4):after { + content: none; + } + .my-sites li:nth-of-type(8n+1), + .my-sites li:nth-of-type(8n+2), + .my-sites li:nth-of-type(8n+3), + .my-sites li:nth-of-type(8n+4) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1400px) and (max-width: 1599px) { + .my-sites li { + float: left; + width: 16%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(5n+1) { + clear: left; + } + .my-sites.striped li:nth-of-type(5n+5):after { + content: none; + } + .my-sites li:nth-of-type(10n+1), + .my-sites li:nth-of-type(10n+2), + .my-sites li:nth-of-type(10n+3), + .my-sites li:nth-of-type(10n+4), + .my-sites li:nth-of-type(10n+5) { + background-color: #f9f9f9; + } +} + +@media only screen and (min-width: 1600px) { + .my-sites li { + float: left; + width: 12.666666%; + padding: 8px 2%; + background-color: #fff; + } + .my-sites.striped li:nth-of-type(6n+1) { + clear: left; + } + .my-sites.striped li:nth-of-type(6n+6):after { + content: none; + } + .my-sites li:nth-of-type(12n+1), + .my-sites li:nth-of-type(12n+2), + .my-sites li:nth-of-type(12n+3), + .my-sites li:nth-of-type(12n+4), + .my-sites li:nth-of-type(12n+5), + .my-sites li:nth-of-type(12n+6) { + background-color: #f9f9f9; + } +} + +.my-sites li a { + text-decoration: none; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + /* Back-compat for pre-3.8 */ + div.star-holder, + div.star-holder .star-rating { + background: url(../images/stars-2x.png?ver=20121108) repeat-x bottom left; + background-size: 21px 37px; + } + + .spinner { + background-image: url(../images/spinner-2x.gif); + } + + /* @todo: evaluate - most of these were likely replaced by dashicons */ + .curtime #timestamp, + #screen-meta-links a.show-settings, + .widget-top .widget-action, + .widget-top .widget-action:hover, + .sidebar-name .toggle-indicator, + .sidebar-name:hover .toggle-indicator, + .meta-box-sortables .postbox:hover .handlediv, + #bulk-titles div a, + #bulk-titles div a:hover { + background: none !important; + } + +} + +@-ms-viewport { + width: device-width; +} + +@media screen and ( max-width: 782px ) { + html.wp-toolbar { + padding-top: 46px; + } + + body { + min-width: 240px; + overflow-x: hidden; + } + + body * { + -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important; + } + + #wpcontent { + position: relative; + margin-left: 0; + padding-left: 10px; + } + + #wpbody-content { + padding-bottom: 100px; + } + + .wrap { + margin-right: 12px; + margin-left: 0; + } + + /* categories */ + #col-left, + #col-right { + float: none; + width: auto; + } + + #col-left .col-wrap, + #col-right .col-wrap { + padding: 0; + } + + /* Hidden Elements */ + #screen-meta, + #screen-meta-links, + #collapse-menu, + .post-format-select { + display: none !important; + } + + .wrap h1.wp-heading-inline { + margin-bottom: 0.5em; + } + + .wrap .add-new-h2, /* deprecated */ + .wrap .add-new-h2:active, /* deprecated */ + .wrap .page-title-action, + .wrap .page-title-action:active { + padding: 10px 15px; + font-size: 14px; + white-space: nowrap; + } + + /* Feedback Messages */ + .notice, + .wrap div.updated, + .wrap div.error, + .media-upload-form div.error { + margin: 20px 0 10px 0; + padding: 5px 10px; + font-size: 14px; + line-height: 175%; + } + + .wp-core-ui .notice.is-dismissible { + padding-right: 46px; + } + + .notice-dismiss { + padding: 13px; + } + + .wrap .icon32 + h2 { + margin-top: -2px; + } + + .wp-responsive-open #wpbody { + right: -16em; + } + + code { + word-wrap: break-word; + } + + /* General Metabox */ + .postbox { + font-size: 14px; + } + + .metabox-holder h3.hndle, /* Back-compat for pre-4.4 */ + .metabox-holder .stuffbox > h3, /* Back-compat for pre-4.4 */ + .metabox-holder .postbox > h3, /* Back-compat for pre-4.4 */ + .metabox-holder h2 { + padding: 12px; + } + + .postbox .handlediv { + margin-top: 3px; + } + + /* Subsubsub Nav */ + .subsubsub { + font-size: 16px; + text-align: center; + margin-bottom: 15px; + } + + /* Theme/Plugin File Editor */ + + #template textarea, + #template .CodeMirror { + box-sizing: border-box; + } + + #templateside { + float: none; + width: auto; + } + + #templateside > ul { + border-left: 1px solid #ddd; + } + + #templateside li { + margin: 0; + } + + #templateside li:not(.howto) a { + display: block; + padding: 5px; + } + #templateside li.howto { + padding: 12px; + } + + #templateside .highlight { + padding: 5px; + margin-left: -5px; + margin-top: -5px; + } + + #template > div, + #template .notice { + float: none; + margin: 1em 0; + width: auto; + } + + #template .CodeMirror, + #template textarea { + width: 100%; + } + + #templateside ul ul { + padding-left: 1.5em; + } + [role="treeitem"] .folder-label { + display: block; + padding: 5px; + } + .tree-folder > li::before, + .tree-folder > li::after, + .tree-folder .tree-folder::after { + left: -8px; + } + .tree-folder > li::before { + top: 0px; + height: 13px; + } + .tree-folder > .current-file::before { + left: -5px; + top: 7px; + width: 4px; + } + .tree-folder > .current-file::after { + height: 9px; + left: -8px; + } + .wrap #templateside span.notice { + margin-left: -5px; + width: 100%; + } + + .fileedit-sub .alignright { + float: left; + margin-top: 15px; + width: 100%; + text-align: left; + } + + .fileedit-sub .alignright label { + display: block; + } + + .fileedit-sub #theme, + .fileedit-sub #plugin { + margin-left: 0; + max-width: 70%; + } + + .fileedit-sub input[type="submit"] { + margin-bottom: 0px; + padding: 8px 18px; + } + + #documentation label[for="docs-list"] { + display: block; + } + + #documentation select[name="docs-list"] { + margin-left: 0; + max-width: 60%; + } + + #documentation input[type="button"] { + margin-bottom: 0; + padding: 8px 18px; + } + + #wpfooter { + display: none; + } + + #comments-form .checkforspam { + display: none; + } + + .edit-comment-author { + margin: 2px 0 0; + } + + .filter-drawer .filter-group-feature input, + .filter-drawer .filter-group-feature label { + line-height: 25px; + } + + .filter-drawer .filter-group-feature label { + margin-left: 32px; + } + + .wp-filter .button.drawer-toggle { + font-size: 13px; + line-height: 26px; + height: 28px; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Disable horizontal scroll when responsive menu is open + since we push the main content off to the right. */ + #wpwrap.wp-responsive-open { + overflow-x: hidden; + } + + html.wp-toolbar { + padding-top: 0; + } + + #wpbody { + padding-top: 46px; + } + + /* Keep full-width boxes on Edit Post page from causing horizontal scroll */ + div#post-body.metabox-holder.columns-1 { + overflow-x: hidden; + } + + h1.nav-tab-wrapper, + .wrap h2.nav-tab-wrapper, + .nav-tab-wrapper { + border-bottom: 0; + } + + h1 .nav-tab, + h2 .nav-tab, + h3 .nav-tab { + margin: 10px 10px 0 0; + border-bottom: 1px solid #ccc; + } +} + +@media screen and (max-width: 320px) { + /* Prevent default center alignment and larger font for the Right Now widget when + the network dashboard is viewed on a small mobile device. */ + #network_dashboard_right_now .subsubsub { + font-size: 14px; + text-align: left; + } +} diff --git a/backend/wp-admin/css/common.min.css b/backend/wp-admin/css/common.min.css new file mode 100644 index 0000000..7be7bcd --- /dev/null +++ b/backend/wp-admin/css/common.min.css @@ -0,0 +1,9 @@ +/*! This file is auto-generated */ +.button.updated-message,a{transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}#ajax-loading,.ajax-feedback,.ajax-loading,.imgedit-wait-spin,.list-ajax-loading,.spinner,.wp-header-end{visibility:hidden}.filter-group,.postbox-container .meta-box-sortables,.wp-filter,html.wp-toolbar{box-sizing:border-box}#docs-list,#plugin-information .section,#template textarea,.code,.ltr,code{direction:ltr}#wpwrap{height:auto;min-height:100%;width:100%;position:relative;-webkit-font-smoothing:subpixel-antialiased}#wpcontent{height:100%;padding-left:20px}#wpcontent,#wpfooter{margin-left:160px}.folded #wpcontent,.folded #wpfooter{margin-left:36px}#wpbody-content{padding-bottom:65px;float:left;width:100%;overflow:visible!important}.inner-sidebar{float:right;clear:right;display:none;width:281px;position:relative}.columns-2 .inner-sidebar{margin-right:auto;width:286px;display:block}.columns-2 .inner-sidebar #side-sortables,.inner-sidebar #side-sortables{min-height:300px;width:280px;padding:0}.has-right-sidebar .inner-sidebar{display:block}.has-right-sidebar #post-body{float:left;clear:left;width:100%;margin-right:-2000px}.has-right-sidebar #post-body-content{margin-right:300px;float:none;width:auto}#col-left{float:left;width:35%}#col-right{float:right;width:65%}#col-left .col-wrap{padding:0 6px 0 0}#col-right .col-wrap{padding:0 0 0 6px}.alignleft{float:left}.alignright{float:right}#publishing-action .spinner,#save-post,.subsubsub{float:left}.textleft{text-align:left}.textright{text-align:right}.clear{clear:both}.wp-clearfix:after{content:"";display:table;clear:both}.screen-reader-text,.screen-reader-text span,.ui-helper-hidden-accessible{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}#templateside,.misc-pub-filename,.pre,.widefat *{word-wrap:break-word}.screen-reader-shortcut{position:absolute;top:-1000em}.screen-reader-shortcut:focus{left:6px;top:-25px;height:auto;width:auto;display:block;font-size:14px;font-weight:600;padding:15px 23px 14px;background:#f1f1f1;color:#0073aa;z-index:100000;line-height:normal;box-shadow:0 0 2px 2px rgba(0,0,0,.6);text-decoration:none;outline:0}.hidden,.js .closed .inside,.js .hide-if-js,.js .wp-core-ui .hide-if-js,.js.wp-core-ui .hide-if-js,.no-js .hide-if-no-js,.no-js .wp-core-ui .hide-if-no-js,.no-js.wp-core-ui .hide-if-no-js{display:none}#menu-management .menu-edit,#menu-settings-column .accordion-container,.comment-ays,.feature-filter,.imgedit-group,.manage-menus,.menu-item-handle,.popular-tags,.stuffbox,.widget-inside,.widget-top,.widgets-holder-wrap,.wp-editor-container,p.popular-tags,table.widefat{border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04)}.comment-ays,.feature-filter,.imgedit-group,.popular-tags,.stuffbox,.widgets-holder-wrap,.wp-editor-container,p.popular-tags,table.widefat{background:#fff}body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4em;min-width:600px}body.iframe{min-width:0;padding-top:1px}body.modal-open{overflow:hidden}body.mobile.modal-open #wpwrap{overflow:hidden;position:fixed;height:100%}iframe,img{border:0}td{font-family:inherit;font-size:inherit;font-weight:inherit;line-height:inherit}a{color:#0073aa}a,div{outline:0}a:active,a:hover{color:#00a0d2}.wp-person a:focus .gravatar,a:focus,a:focus .media-icon img{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}h1,h2,h3{color:#23282d}.ie8 a:focus{outline:#5b9dd9 solid 1px}#adminmenu a:focus,.screen-reader-text:focus{box-shadow:none;outline:0}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}p{font-size:13px;line-height:1.5;margin:1em 0}blockquote{margin:1em}dd,li{margin-bottom:6px}h1,h2,h3,h4,h5,h6{display:block;font-weight:600}h1{font-size:2em;margin:.67em 0}h2,h3{font-size:1.3em;margin:1em 0}.update-core-php h2{margin-top:2em}.update-messages h2,.update-php h2,h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.67em;margin:2.33em 0}ol,ul{padding:0}ul{list-style:none}ol{list-style-type:decimal;margin-left:2em}ul.ul-disc{list-style:disc}ul.ul-square{list-style:square}ol.ol-decimal{list-style:decimal}ol.ol-decimal,ul.ul-disc,ul.ul-square{margin-left:1.8em}ol.ol-decimal>li,ul.ul-disc>li,ul.ul-square>li{margin:0 0 .5em}.code,code{font-family:Consolas,Monaco,monospace;unicode-bidi:embed}code,kbd{padding:3px 5px 2px;margin:0 1px;background:#eaeaea;background:rgba(0,0,0,.07);font-size:13px}.subsubsub{list-style:none;margin:8px 0 0;padding:0;font-size:13px;color:#666}.subsubsub a{line-height:2;padding:.2em;text-decoration:none}.subsubsub a .count,.subsubsub a.current .count{color:#555d66;font-weight:400}.subsubsub a.current{font-weight:600;border:none}.subsubsub li{display:inline-block;margin:0;padding:0;white-space:nowrap}.widefat{border-spacing:0;width:100%;clear:both;margin:0}.widefat a,.widefat button.button-link{text-decoration:none}.widefat td,.widefat th{padding:8px 10px}.widefat thead td,.widefat thead th{border-bottom:1px solid #e1e1e1}.widefat tfoot td,.widefat tfoot th{border-top:1px solid #e1e1e1;border-bottom:none}.widefat .no-items td{border-bottom-width:0}.widefat td{vertical-align:top}.widefat td,.widefat td ol,.widefat td p,.widefat td ul{font-size:13px;line-height:1.5em}.widefat tfoot td,.widefat th,.widefat thead td{text-align:left;line-height:1.3em;font-size:14px}.updates-table td input,.widefat tfoot td input,.widefat th input,.widefat thead td input{margin:0 0 0 8px;padding:0;vertical-align:text-top}.widefat .check-column{width:2.2em;padding:6px 0 25px;vertical-align:top}.updates-table tbody td.check-column,.widefat tbody th.check-column,.widefat tfoot td.check-column,.widefat thead td.check-column{padding:11px 0 0 3px}.widefat tfoot td.check-column,.widefat thead td.check-column{padding-top:4px;vertical-align:middle}.update-php div.error,.update-php div.updated{margin-left:0}.no-js .widefat tfoot .check-column input,.no-js .widefat thead .check-column input{display:none}.column-comments,.column-links,.column-posts,.widefat .num{text-align:center}.widefat th#comments{vertical-align:middle}.wrap{margin:10px 20px 0 2px}.postbox .inside h2,.wrap [class$=icon32]+h2,.wrap h1,.wrap>h2:first-child{font-size:23px;font-weight:400;margin:0;padding:9px 0 4px;line-height:29px}.wrap h1.wp-heading-inline{display:inline-block;margin-right:5px}.wp-header-end{margin:-2px 0 0}.subtitle{margin:0;padding-left:25px;color:#555d66;font-size:14px;font-weight:400;line-height:1}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{margin-left:4px;padding:4px 8px;position:relative;top:-3px;text-decoration:none;border:none;border:1px solid #ccc;border-radius:2px;background:#f7f7f7;text-shadow:none;font-weight:600;font-size:13px;line-height:normal;color:#0073aa;cursor:pointer;outline:0}.wrap .wp-heading-inline+.page-title-action{margin-left:0}.wrap .add-new-h2:hover,.wrap .page-title-action:hover{border-color:#008EC2;background:#00a0d2;color:#fff}.page-title-action:focus{color:#124964}.ac_match,.highlight,.subsubsub a.current{color:#000}.wrap .page-title-action:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.wrap h1.long-header{padding-right:0}.wp-dialog{background-color:#fff}#available-widgets .widget-top:hover,#widgets-left .widget-in-question .widget-top,#widgets-left .widget-top:hover,.widgets-chooser ul,div#widgets-right .widget-top:hover{border-color:#999;box-shadow:0 1px 2px rgba(0,0,0,.1)}.sorthelper{background-color:#ccf3fa}.alternate,.striped>tbody>:nth-child(odd),ul.striped>:nth-child(odd){background-color:#f9f9f9}.bar{background-color:#e8e8e8;border-right-color:#99d}.highlight{background-color:#e4f2fd}.wp-ui-primary{color:#fff;background-color:#32373c}.wp-ui-text-primary{color:#32373c}.wp-ui-highlight{color:#fff;background-color:#1e8cbe}.wp-ui-text-highlight{color:#1e8cbe}.wp-ui-notification{color:#fff;background-color:#d54e21}.wp-ui-text-notification{color:#d54e21}.wp-ui-text-icon{color:#82878c}img.emoji{display:inline!important;border:none!important;height:1em!important;width:1em!important;margin:0 .07em!important;vertical-align:-.1em!important;background:0 0!important;padding:0!important;box-shadow:none!important}#nav-menu-footer,#nav-menu-header,#your-profile #rich_editing,.checkbox,.control-section .accordion-section-title,.menu-item-handle,.postbox .hndle,.side-info,.sidebar-name,.stuffbox .hndle,.widefat tfoot td,.widefat tfoot th,.widefat thead td,.widefat thead th,.widget .widget-top{line-height:1.4em}.menu-item-handle,.widget .widget-top{background:#fafafa;color:#23282d}.postbox .hndle,.stuffbox .hndle{border-bottom:1px solid #eee;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.quicktags,.search{background-color:#ccc;color:#000;font-size:12px}.icon32{display:none}#bulk-titles div a:before,.notice-dismiss:before,.tagchecklist .ntdelbutton .remove-tag-icon:before,.welcome-panel .welcome-panel-close:before{background:0 0;color:#72777c;content:"\f153";display:block;font:400 16px/20px dashicons;speak:none;height:20px;text-align:center;width:20px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.welcome-panel .welcome-panel-close:before{margin:0}#bulk-titles div a:before{margin:1px 0}.tagchecklist .ntdelbutton .remove-tag-icon:before{margin-left:2px;border-radius:50%;color:#0073aa;line-height:1.28}.tagchecklist .ntdelbutton:focus{outline:0}#bulk-titles div a:focus:before,#bulk-titles div a:hover:before,.tagchecklist .ntdelbutton:focus .remove-tag-icon:before,.tagchecklist .ntdelbutton:hover .remove-tag-icon:before,.welcome-panel .welcome-panel-close:focus:before,.welcome-panel .welcome-panel-close:hover:before{color:#c00}.tagchecklist .ntdelbutton:focus .remove-tag-icon:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.key-labels label{line-height:24px}b,strong{font-weight:600}.pre{white-space:pre-wrap}#namediv td.first,.nav-tab,.no-break,.star-rating{white-space:nowrap}.howto{color:#666;font-style:italic;display:block}p.install-help{margin:8px 0;font-style:italic}hr{border:0;border-top:1px solid #ddd;border-bottom:1px solid #fafafa}#all-plugins-table .plugins a.delete,#delete-link a.delete,#media-items a.delete,#media-items a.delete-permanently,#nav-menu-footer .menu-delete,#search-plugins-table .plugins a.delete,.plugins a.delete,.row-actions span.delete a,.row-actions span.spam a,.row-actions span.trash a,.submitbox .submitdelete{color:#a00}#all-plugins-table .plugins a.delete:hover,#delete-link a.delete:hover,#media-items a.delete-permanently:hover,#media-items a.delete:hover,#nav-menu-footer .menu-delete:hover,#search-plugins-table .plugins a.delete:hover,.file-error,.plugins a.delete:hover,.row-actions .delete a:hover,.row-actions .spam a:hover,.row-actions .trash a:hover,.submitbox .submitdelete:hover,abbr.required,span.required{color:#dc3232;border:none}#major-publishing-actions{padding:10px;clear:both;border-top:1px solid #ddd;background:#f5f5f5}#delete-action{float:left;line-height:28px}#delete-link{line-height:28px;vertical-align:middle;text-align:left;margin-left:8px}#delete-link a{text-decoration:none}#publishing-action{text-align:right;float:right;line-height:23px}#misc-publishing-actions{padding:6px 0 0}.misc-pub-section{padding:6px 10px 8px}#minor-publishing-actions{padding:10px 10px 0;text-align:right}.preview{float:right}#sticky-span{margin-left:18px}.approve,.unapproved .unapprove{display:none}.spam .approve,.trash .approve,.unapproved .approve{display:inline}td.action-links,th.action-links{text-align:right}#misc-publishing-actions .notice{margin-left:10px;margin-right:10px}.wp-filter{display:inline-block;position:relative;margin:12px 0 25px;padding:0 10px;width:100%;box-shadow:0 1px 1px rgba(0,0,0,.04);border:1px solid #e5e5e5;background:#fff;color:#555;font-size:13px}.wp-filter a{text-decoration:none}.filter-count{display:inline-block;vertical-align:middle;min-width:4em}.filter-count .count,.title-count{display:inline-block;position:relative;top:-1px;padding:4px 10px;border-radius:30px;background:#72777c;color:#fff;font-size:14px;font-weight:600}.title-count{display:inline;top:-3px;margin-left:5px;margin-right:20px}.filter-links li>a,.wp-filter .search-form.search-plugins{display:inline-block}.filter-items{float:left}.filter-links,.filter-links li{display:inline-block;margin:0}.filter-links li>a{margin:0 10px;padding:15px 0;border-bottom:4px solid #fff;color:#666;cursor:pointer}.filter-links .current{box-shadow:none;border-bottom:4px solid #666;color:#23282d}.filter-links li>a:focus,.filter-links li>a:hover,.show-filters .filter-links a.current:focus,.show-filters .filter-links a.current:hover{color:#00a0d2}.wp-filter .search-form{float:right;margin:10px 0}.wp-filter .search-form input[type=search]{margin:0;padding:3px 5px;width:280px;max-width:100%;font-size:16px;font-weight:300;line-height:1.5}.wp-filter .search-form select{margin:0;height:32px;vertical-align:top}.wp-filter .button.drawer-toggle{margin:10px 9px 0;padding:0 10px 0 6px;border-color:transparent;background-color:transparent;color:#666;vertical-align:baseline;box-shadow:none}.wp-filter .drawer-toggle:before{content:"\f111";margin:0 5px 0 0;color:#72777c;font:400 16px/1 dashicons;vertical-align:text-bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-filter .button.drawer-toggle:focus,.wp-filter .button.drawer-toggle:hover,.wp-filter .drawer-toggle:focus:before,.wp-filter .drawer-toggle:hover:before{background-color:transparent;color:#00a0d2}.wp-filter .button.drawer-toggle:focus:active,.wp-filter .button.drawer-toggle:hover{border-color:transparent}.wp-filter .button.drawer-toggle:focus{border-color:#5b9dd9}.wp-filter .button.drawer-toggle:active{background:0 0;box-shadow:none;-webkit-transform:none;transform:none}.wp-filter .drawer-toggle.current:before{color:#fff}.filter-drawer,.wp-filter .favorites-form{display:none;margin:0 -10px 0 -20px;padding:20px;border-top:1px solid #eee;background:#fafafa;overflow:hidden}.show-favorites-form .favorites-form,.show-filters .filter-drawer{display:block}.show-filters .filter-links a.current{border-bottom:none}.show-filters .wp-filter .button.drawer-toggle{border-radius:2px;background:#72777c;color:#fff}.filter-group,.filtered-by .tag{border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04)}.show-filters .wp-filter .drawer-toggle:focus,.show-filters .wp-filter .drawer-toggle:hover{background:#2ea2cc}.show-filters .wp-filter .drawer-toggle:before{color:#fff}.filter-group{position:relative;float:left;margin:0 1% 0 0;padding:20px 10px 10px;width:24%;background:#fff}.filter-group legend{position:absolute;top:10px;display:block;margin:0;padding:0;font-size:1em;font-weight:600}.filter-drawer .filter-group-feature{margin:28px 0 0;list-style-type:none;font-size:12px}.filter-drawer .filter-group-feature input,.filter-drawer .filter-group-feature label{line-height:16px}.filter-drawer .filter-group-feature input{position:absolute;margin:0}.filter-group .filter-group-feature label{display:block;margin:14px 0 14px 23px}.filter-drawer .buttons{clear:both;margin-bottom:20px}.filter-drawer .filter-group+.buttons{margin-bottom:0;padding-top:20px}.filter-drawer .buttons .button span{display:inline-block;opacity:.8;font-size:12px;text-indent:10px}.wp-filter .button.clear-filters{display:none;margin-left:10px}.wp-filter .button-link.edit-filters{padding:0 5px;line-height:28px}.filtered-by{display:none;margin:0}.filtered-by>span{font-weight:600}.filtered-by a{margin-left:10px}.filtered-by .tags{display:inline}.filtered-by .tag{margin:0 5px;padding:4px 8px;background:#fff;font-size:11px}.filters-applied .filter-drawer .buttons,.filters-applied .filter-drawer br,.filters-applied .filter-group{display:none!important}.filters-applied .filtered-by{display:block}.filters-applied .filter-drawer{padding:20px}.error .content-filterable,.loading-content .content-filterable,.show-filters .content-filterable,.show-filters .favorites-form,.show-filters.filters-applied.loading-content .content-filterable{display:none}.show-filters.filters-applied .content-filterable{display:block}.loading-content .spinner{display:block;margin:40px auto 0;float:none}@media only screen and (max-width:1120px){.filter-drawer{border-bottom:1px solid #eee}.filter-group{margin-bottom:0;margin-top:5px;width:100%}.filter-group li{margin:10px 0}}@media only screen and (max-width:1000px){.filter-items{float:none}.wp-filter .media-toolbar-primary,.wp-filter .media-toolbar-secondary,.wp-filter .search-form{float:none;position:relative;max-width:100%}}@media only screen and (max-width:782px){.filter-group li{padding:0;width:50%}}@media only screen and (max-width:320px){.filter-count{display:none}.wp-filter .drawer-toggle{margin:10px 0}.filter-group li,.wp-filter .search-form input[type=search]{width:100%}}.notice,div.error,div.updated{background:#fff;border-left:4px solid #fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 15px 2px;padding:1px 12px}div[class=update-message]{padding:.5em 12px .5em 0}.form-table td .notice p,.notice p,.notice-title,div.error p,div.updated p{margin:.5em 0;padding:2px}.error a{text-decoration:underline}.updated a{padding-bottom:2px}.notice-alt{box-shadow:none}.notice-large{padding:10px 20px}.notice-title{display:inline-block;color:#23282d;font-size:18px}.wp-core-ui .notice.is-dismissible{padding-right:38px;position:relative}.notice-dismiss{position:absolute;top:0;right:1px;border:none;margin:0;padding:9px;background:0 0;color:#72777c;cursor:pointer}.notice-dismiss:active:before,.notice-dismiss:focus:before,.notice-dismiss:hover:before{color:#c00}.notice-dismiss:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 .notice-dismiss:focus{outline:#5b9dd9 solid 1px}.notice-success,div.updated{border-left-color:#46b450}.notice-success.notice-alt{background-color:#ecf7ed}.notice-warning{border-left-color:#ffb900}.notice-warning.notice-alt{background-color:#fff8e5}.notice-error,div.error{border-left-color:#dc3232}.notice-error.notice-alt{background-color:#fbeaea}.notice-info{border-left-color:#00a0d2}.notice-info.notice-alt{background-color:#e5f5fa}.button.installed:before,.button.installing:before,.button.updated-message:before,.button.updating-message:before,.import-php .updating-message:before,.update-message p:before,.updated-message p:before,.updating-message p:before{display:inline-block;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.media-upload-form .notice,.media-upload-form div.error,.wrap .notice,.wrap div.error,.wrap div.updated{margin:5px 0 15px}.wrap #templateside .notice{display:block;margin:0;padding:5px 8px;font-weight:600;text-decoration:none}.wrap #templateside span.notice{margin-left:-12px}#templateside li.notice a{padding:0}.button.installing:before,.button.updating-message:before,.import-php .updating-message:before,.update-message p:before,.updating-message p:before{color:#f56e28;content:"\f463"}.button.installing:before,.button.updating-message:before,.import-php .updating-message:before,.updating-message p:before{-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.button.updated-message:before,.installed p:before,.updated-message p:before{color:#79ba49;content:'\f147'}.update-message.notice-error p:before{color:#dc3232;content:"\f534"}.import-php .updating-message:before,.wrap .notice p:before{margin-right:6px;vertical-align:bottom}#update-nag,.update-nag{display:inline-block;line-height:19px;padding:11px 15px;font-size:14px;text-align:left;margin:25px 20px 0 2px;background-color:#fff;border-left:4px solid #ffba00;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}#screen-meta,ul#dismissed-updates{display:none}form.upgrade{margin-top:8px}form.upgrade .hint{font-style:italic;font-size:85%;margin:-.5em 0 2em}.update-php .spinner{float:none;margin:-4px 0}#ajax-response.alignleft{margin-left:2em}.button.installed:before,.button.installing:before,.button.updated-message:before,.button.updating-message:before{margin:3px 5px 0 -2px}.button-primary.updating-message:before{color:#fff}.button-primary.updated-message:before{color:#66c6e4}@media aural{.button.installed:before,.button.installing:before,.update-message p:before,.wrap .notice p:before{speak:none}}#adminmenu a,#catlist a,#taglist a{text-decoration:none}#contextual-help-wrap,#screen-options-wrap{margin:0;padding:8px 20px 12px;position:relative}#contextual-help-wrap{overflow:auto;margin-left:0!important}#screen-meta-links{margin:0 20px 0 0}#screen-meta{margin:0 20px -1px 0;position:relative;background-color:#fff;border:1px solid #ddd;border-top:none;box-shadow:0 1px 0 rgba(0,0,0,.025)}#contextual-help-link-wrap,#screen-options-link-wrap{float:right;height:28px;margin:0 0 0 6px;border:1px solid #ddd;border-top:none;background:#fff;box-shadow:0 1px 1px -1px rgba(0,0,0,.1)}#screen-meta-links .screen-meta-toggle{position:relative;top:0}#screen-meta-links .show-settings{border:0;background:0 0;border-radius:0;color:#72777c;line-height:1.7;padding:3px 6px 3px 16px}#screen-meta-links .show-settings:active,#screen-meta-links .show-settings:focus,#screen-meta-links .show-settings:hover{color:#32373c}#screen-meta-links .show-settings:active{box-shadow:none;-webkit-transform:none;transform:none}#screen-meta-links .show-settings:after{right:0;content:"\f140";font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 5px 0 0;bottom:2px;position:relative;vertical-align:bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#72777c}#templateside ul li a,.contextual-help-tabs a,.nav-tab{text-decoration:none}#screen-meta-links .screen-meta-active:after{content:"\f142"}.toggle-arrow{background-repeat:no-repeat;background-position:top left;background-color:transparent;height:22px;line-height:22px;display:block}.toggle-arrow-active{background-position:bottom left}#contextual-help-wrap h5,#screen-options-wrap h5,#screen-options-wrap legend{margin:0;padding:8px 0;font-size:13px;font-weight:600}.hndle a,.widefat tfoot td,.widefat th,.widefat thead td{font-weight:400}.ie8 #screen-options-wrap legend{color:inherit}.metabox-prefs label{display:inline-block;padding-right:15px;line-height:30px}#number-of-columns{display:inline-block;vertical-align:middle;line-height:30px}.metabox-prefs input[type=checkbox]{margin-top:0;margin-right:6px}.metabox-prefs label input,.metabox-prefs label input[type=checkbox]{margin:-4px 5px 0 0}.metabox-prefs .columns-prefs label input{margin:-1px 2px 0 0}.metabox-prefs label a{display:none}.metabox-prefs .screen-options input,.metabox-prefs .screen-options label{margin-top:0;margin-bottom:0;vertical-align:middle}.metabox-prefs .screen-options .screen-per-page{margin-right:15px}.metabox-prefs .screen-options label{line-height:28px;padding-right:0}.screen-options+.screen-options{margin-top:10px}.metabox-prefs .submit{margin-top:1em;padding:0}#contextual-help-wrap{padding:0}#contextual-help-columns{position:relative}#contextual-help-back{position:absolute;top:0;bottom:0;left:150px;right:170px;border:1px solid #e1e1e1;border-top:none;border-bottom:none;background:#f6fbfd}#contextual-help-wrap.no-sidebar #contextual-help-back{right:0;border-right-width:0;border-bottom-right-radius:2px}.contextual-help-tabs{float:left;width:150px;margin:0}.contextual-help-tabs ul{margin:1em 0}.contextual-help-tabs li{margin-bottom:0;list-style-type:none;border-style:solid;border-width:0 0 0 2px;border-color:transparent}.contextual-help-tabs a{display:block;padding:5px 5px 5px 12px;line-height:18px;border:1px solid transparent;border-right:none;border-left:none}.contextual-help-tabs a:hover{color:#32373c}.contextual-help-tabs .active{padding:0;margin:0 -1px 0 0;border-left:2px solid #00a0d2;background:#f6fbfd;box-shadow:0 2px 0 rgba(0,0,0,.02),0 1px 0 rgba(0,0,0,.02)}.contextual-help-tabs .active a{border-color:#e1e1e1;color:#32373c}.contextual-help-tabs-wrap{padding:0 20px;overflow:auto}.help-tab-content{display:none;margin:0 22px 12px 0;line-height:1.6em}.help-tab-content.active{display:block}.help-tab-content ul li{list-style-type:disc;margin-left:18px}.contextual-help-sidebar{width:150px;float:right;padding:0 8px 0 12px;overflow:auto}html.wp-toolbar{padding-top:32px}.widefat td,.widefat th{color:#555}.widefat ol,.widefat p,.widefat tfoot tr td,.widefat tfoot tr th,.widefat thead tr td,.widefat thead tr th,.widefat ul{color:#32373c}.widefat td p{margin:2px 0 .8em}.widefat .column-comment p{margin:.6em 0}.widefat .column-comment ul{list-style:outside;margin-left:2em}.postbox-container{float:left}#wpbody-content .metabox-holder{padding-top:10px}.metabox-holder .postbox-container .empty-container{border:3px dashed #b4b9be;height:250px;position:relative}.metabox-holder .postbox-container .empty-container:after{content:attr(data-emptystring);margin:auto;position:absolute;top:0;left:0;bottom:0;right:0;height:1em;width:200px;text-align:center;color:#ccc;font-size:18px;display:none}.columns-2 #postbox-container-3 .empty-container,.columns-2 #postbox-container-4 .empty-container,.columns-3 #postbox-container-4 .empty-container,.metabox-holder.columns-1 .postbox-container .empty-container{border:0;height:0;min-height:0}#post-body-content{width:100%;min-width:463px;float:left}#post-body.columns-2 #postbox-container-1{float:right;margin-right:-300px;width:280px}#post-body.columns-2 #side-sortables{min-height:250px}@media only screen and (max-width:799px){#wpbody-content .metabox-holder .postbox-container .empty-container{border:0;height:0;min-height:0}}.js .postbox .hndle,.js .widget .widget-top{cursor:move}.hndle a{font-size:11px}#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:hover,#dashboard_right_now .versions .b,#ed_reply_toolbar #ed_reply_strong,#pass-strength-result.short,#pass-strength-result.strong,#post-status-display,#post-visibility-display,.feature-filter .feature-name,.item-controls .item-order a,.media-item .percent,.nav-tab,.plugins .name{font-weight:600}.postbox .handlediv{display:none;float:right;width:36px;height:36px;margin:0;padding:0;border:0;background:0 0;cursor:pointer}.js .postbox .handlediv{display:block}.sortable-placeholder{border:1px dashed #b4b9be;margin-bottom:20px}.postbox,.stuffbox{margin-bottom:20px;padding:0;line-height:1}.postbox .inside,.stuffbox .inside{padding:0 12px 12px;line-height:1.4em;font-size:13px}.postbox .inside{margin:11px 0;position:relative}.postbox .inside>p:last-child,.rss-widget ul li:last-child{margin-bottom:1px!important}.postbox.closed h3{border:none;box-shadow:none}.postbox table.form-table{margin-bottom:0}.postbox table.widefat{box-shadow:none}.temp-border{border:1px dotted #ccc}.columns-prefs label{padding:0 10px 0 0}#wpfooter{position:absolute;bottom:0;left:0;right:0;padding:10px 20px;color:#555d66}#wpfooter p{font-size:13px;margin:0;line-height:20px}#footer-thankyou{font-style:italic}.nav-tab{float:left;border:1px solid #ccc;border-bottom:none;margin-left:.5em;padding:5px 10px;font-size:14px;line-height:24px;background:#e5e5e5;color:#555}.nav-tab-small .nav-tab,h3 .nav-tab{padding:5px 14px;font-size:12px;line-height:16px}.nav-tab:focus,.nav-tab:hover{background-color:#fff;color:#444}.nav-tab-active,.nav-tab:focus:active{box-shadow:none}.nav-tab-active{margin-bottom:-1px;color:#444}.nav-tab-active,.nav-tab-active:focus,.nav-tab-active:focus:active,.nav-tab-active:hover{border-bottom:1px solid #f1f1f1;background:#f1f1f1;color:#000}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper,h1.nav-tab-wrapper{border-bottom:1px solid #ccc;margin:0;padding-top:9px;padding-bottom:0;line-height:inherit}.nav-tab-wrapper:not(.wp-clearfix):after{content:"";display:table;clear:both}.ie8 .nav-tab-wrapper{display:inline-block;width:100%;vertical-align:top}.spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;display:inline-block;float:right;vertical-align:middle;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:4px 10px 0}.loading-content .spinner,.spinner.is-active{visibility:visible}#template>div{margin-right:16em}#template .notice{margin-top:1em;margin-right:3%}#template .notice p{width:auto}#template .submit .spinner{float:none}.metabox-holder .postbox>h3,.metabox-holder .stuffbox>h3,.metabox-holder h2.hndle,.metabox-holder h3.hndle{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}.nav-menus-php .metabox-holder h3{padding:10px 10px 11px 14px;line-height:21px}.plugin-install #description,.plugin-install-network #description{width:60%}table .column-rating,table .column-visible,table .vers{text-align:left}.attention,.error-message{color:#dc3232;font-weight:600}body.iframe{height:98%}.lp-show-latest p{display:none}#howto,.importer-action,.importer-desc,.importer-title{display:block}.lp-show-latest .lp-error p,.lp-show-latest p:last-child{display:block}.media-icon{width:62px;text-align:center}.media-icon img{border:1px solid #e5e5e5;border:1px solid rgba(0,0,0,.07)}#howto{font-size:11px;margin:0 5px}.importers{font-size:16px;width:auto}.importers td{padding-right:14px;line-height:1.5em}.importers .import-system{max-width:250px}.importers td.desc{max-width:500px}.post-categories,.post-categories li{display:inline}.importer-title{color:#000;font-size:14px;font-weight:400;margin-bottom:.2em}.importer-action{line-height:20px;color:#555;margin-bottom:1em}#post-body #post-body-content #namediv h2,#post-body #post-body-content #namediv h3{margin-top:0}.edit-comment-author{font-size:14px;line-height:1.4;font-weight:600;color:#222;margin:2px 0 0 9px}#namediv h2 label,#namediv h3 label{vertical-align:baseline}#namediv table{width:100%}#namediv td.first{width:10px}#namediv input{width:98%}#namediv p{margin:10px 0}#submitdiv h3{margin-bottom:0!important}.checkbox,.post-categories,.zerosize,fieldset{margin:0;padding:0}.zerosize{height:0;width:0;border:0;overflow:hidden;position:absolute}br.clear{height:2px;line-height:2px}.checkbox{border:none}fieldset{border:0}div.star-holder{position:relative;height:17px;width:100px;background:url(../images/stars.png?ver=20121108) bottom left repeat-x}div.star-holder .star-rating{background:url(../images/stars.png?ver=20121108) top left repeat-x;height:17px;float:left}.star-rating .star{display:inline-block;width:20px;height:20px;-webkit-font-smoothing:antialiased;font-size:20px;line-height:1;font-family:dashicons;text-decoration:inherit;font-weight:400;font-style:normal;vertical-align:top;transition:color .1s ease-in 0;text-align:center;color:#ffb900}.star-rating .star-full:before{content:"\f155"}.star-rating .star-half:before{content:"\f459"}.rtl .star-rating .star-half{-webkit-transform:rotateY(180deg);transform:rotateY(180deg)}.star-rating .star-empty:before{content:"\f154"}div.action-links{font-weight:400;margin:6px 0 0}#plugin-information{background:#fff;position:fixed;top:0;right:0;bottom:0;left:0;height:100%;padding:0}#plugin-information-scrollable{overflow:auto;-webkit-overflow-scrolling:touch;height:100%}#plugin-information-title{padding:0 26px;background:#f5f5f5;font-size:22px;font-weight:600;line-height:56px;position:relative;height:56px}#plugin-information-title.with-banner{margin-right:0;height:250px;background-size:cover}#plugin-information-title h2{font-size:1em;font-weight:600;padding:0;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#plugin-information-title.with-banner h2{position:relative;font-family:"Helvetica Neue",sans-serif;display:inline-block;font-size:30px;line-height:50px;box-sizing:border-box;max-width:100%;padding:0 15px;margin-top:174px;color:#fff;background:rgba(30,30,30,.9);text-shadow:0 1px 3px rgba(0,0,0,.4);box-shadow:0 0 30px rgba(255,255,255,.1);border-radius:8px}#plugin-information-title div.vignette{display:none}#plugin-information-title.with-banner div.vignette{position:absolute;display:block;top:0;left:0;height:250px;width:100%;background:0 0;box-shadow:inset 0 0 50px 4px rgba(0,0,0,.2),inset 0 -1px 0 rgba(0,0,0,.1)}#plugin-information-tabs{padding:0 16px;position:relative;right:0;left:0;min-height:36px;font-size:0;z-index:1;border-bottom:1px solid #ddd;background:#f3f3f3}#plugin-information-tabs a{position:relative;display:inline-block;padding:9px 10px;margin:0;height:18px;line-height:18px;font-size:14px;text-decoration:none;transition:none}#plugin-information-tabs a.current{margin:0 -1px -1px;background:#fff;border:1px solid #ddd;border-bottom-color:#fff;padding-top:8px;color:#32373c}#plugin-information-tabs.with-banner a.current{border-top:none;padding-top:9px}#plugin-information-tabs a:active,#plugin-information-tabs a:focus{outline:0}#plugin-information-content{overflow:hidden;background:#fff;position:relative;top:0;right:0;left:0;min-height:100%;min-height:calc(100% - 152px)}#plugin-information-content.with-banner{min-height:calc(100% - 346px)}#section-holder{position:relative;top:0;right:250px;bottom:0;left:0;margin-right:250px;padding:10px 26px 99999px;margin-bottom:-99939px}#section-holder .updated{margin:16px 0}#plugin-information .fyi{float:right;position:relative;top:0;right:0;padding:16px 16px 99999px;margin-bottom:-99939px;width:217px;border-left:1px solid #ddd;background:#f3f3f3;color:#666}#plugin-information .fyi strong{color:#444}#plugin-information .fyi h3{font-weight:600;text-transform:uppercase;font-size:12px;color:#666;margin:24px 0 8px}#plugin-information .fyi h2{font-size:.9em;margin-bottom:0;margin-right:0}#plugin-information .fyi ul{padding:0;margin:0;list-style:none}#plugin-information .fyi li{margin:0 0 10px}#plugin-information .fyi-description{margin-top:0}#plugin-information .counter-container{margin:3px 0}#plugin-information .counter-label{float:left;margin-right:5px;min-width:55px}#plugin-information .counter-back{height:17px;width:92px;background-color:#e5e5e5;float:left}#plugin-information .counter-bar{height:17px;background-color:#ffc733;float:left}#plugin-information .counter-count{margin-left:5px}#plugin-information .fyi ul.contributors{margin-top:10px}#plugin-information .fyi ul.contributors li{display:inline-block;margin-right:8px;vertical-align:middle}#plugin-information .fyi ul.contributors li img{vertical-align:middle;margin-right:4px}#plugin-information-footer{padding:13px 16px;position:absolute;right:0;bottom:0;left:0;height:33px;border-top:1px solid #ddd;background:#f3f3f3}#plugin-information .section ol,#plugin-information .section ul{list-style-type:disc;margin-left:24px}#plugin-information .section,#plugin-information .section p{font-size:14px;line-height:1.7}#plugin-information #section-screenshots ol{list-style:none;margin:0}#plugin-information #section-screenshots li img{vertical-align:text-top;margin-top:16px;max-width:100%;width:auto;height:auto;box-shadow:0 1px 2px rgba(0,0,0,.3)}#plugin-information #section-screenshots li p{font-style:italic;padding-left:20px}#plugin-information pre{padding:7px;overflow:auto;border:1px solid #ccc}#plugin-information blockquote{border-left:2px solid #ddd;color:#666;font-style:italic;margin:1em 0;padding:0 0 0 1em}#plugin-information .review{overflow:hidden;width:100%;margin-bottom:20px;border-bottom:1px solid #e5e5e5}#plugin-information .review-title-section{overflow:hidden}#plugin-information .review-title-section h4{display:inline-block;float:left;margin:0 6px 0 0}#plugin-information .reviewer-info p{clear:both;margin:0;padding-top:2px}#plugin-information .reviewer-info .avatar{float:left;margin:4px 6px 0 0}#plugin-information .reviewer-info .star-rating{float:left}#plugin-information .review-meta{float:left;margin-left:.75em}#plugin-information .review-body{float:left;width:100%}.plugin-version-author-uri{font-size:13px}.update-php .button.button-primary{margin-right:1em}@media screen and (max-width:771px){#plugin-information-title.with-banner,#plugin-information-title.with-banner div.vignette{height:100px}#plugin-information-title.with-banner h2{margin-top:30px;font-size:20px;line-height:40px;max-width:85%}#plugin-information-tabs{overflow:hidden;padding:0;height:auto}#plugin-information-tabs a.current{margin-bottom:0;border-bottom:none}#plugin-information .fyi{float:none;border:1px solid #ddd;position:static;width:auto;margin:26px 26px 0;padding-bottom:0}#section-holder{position:static;margin:0;padding-bottom:70px}#plugin-information .fyi h3,#plugin-information .fyi small{display:none}#plugin-information-footer{padding:12px 16px 0;height:46px}}#TB_window.plugin-details-modal{background:#fcfcfc}#TB_window.plugin-details-modal.thickbox-loading:before{content:"";display:block;width:20px;height:20px;position:absolute;left:50%;top:50%;z-index:-1;margin:-10px 0 0 -10px;background:url(../images/spinner.gif) center no-repeat #fcfcfc;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}.plugin-details-modal #TB_ajaxWindowTitle,.plugin-details-modal .tb-close-icon{display:none}.tree-folder,[role=treeitem] li{position:relative}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#TB_window.plugin-details-modal.thickbox-loading:before{background-image:url(../images/spinner-2x.gif)}}.plugin-details-modal #TB_title{float:left;height:1px}.plugin-details-modal #TB_closeWindowButton{left:auto;right:-30px;color:#eee}.plugin-details-modal #TB_closeWindowButton:focus,.plugin-details-modal #TB_closeWindowButton:hover{color:#00a0d2;outline:0;box-shadow:none}.plugin-details-modal #TB_closeWindowButton:after{content:"\f335";font:400 32px/29px dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media screen and (max-width:830px){.plugin-details-modal #TB_closeWindowButton{right:0;top:-30px}}img{border:none}.bulk-action-notice .toggle-indicator:before,.js .meta-box-sortables .postbox .toggle-indicator:before,.privacy-text-box .toggle-indicator:before,.sidebar-name .toggle-indicator:before{content:"\f142";display:inline-block;font:400 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before,.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before,.js .widgets-holder-wrap.closed .toggle-indicator:before,.privacy-text-box.closed .toggle-indicator:before{content:"\f140"}.js .postbox .handlediv .toggle-indicator:before{margin-top:4px;width:20px;border-radius:50%;text-indent:-1px}#template .CodeMirror,#template textarea,#templateside>ul{box-sizing:border-box;min-height:60vh;height:calc(100vh - 295px);border:1px solid #ddd}.rtl.js .postbox .handlediv .toggle-indicator:before{text-indent:1px}.bulk-action-notice .toggle-indicator:before{line-height:16px;vertical-align:top;color:#72777c}.js .postbox .handlediv:focus{box-shadow:none;outline:0}.js .postbox .handlediv:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#photo-add-url-div input[type=text]{width:300px}.alignleft h2{margin:0}#template textarea{font-family:Consolas,Monaco,monospace;font-size:13px;background:#f9f9f9;-moz-tab-size:4;-o-tab-size:4;tab-size:4}#template .CodeMirror,#template textarea{width:100%}#templateside>h2{padding-top:6px;padding-bottom:7px;margin:0}#templateside ol,#templateside ul{margin:0;padding:0}#templateside>ul{margin-top:0;overflow:auto;padding:0;background-color:#f7f7f7;border-left:none}#templateside ul ul{padding-left:12px}#templateside>ul>li>ul[role=group]{padding-left:0}[role=treeitem][aria-expanded=false]>ul{display:none}[role=treeitem] span[aria-hidden]{display:inline;font-family:dashicons;font-size:20px;position:absolute;pointer-events:none}[role=treeitem][aria-expanded=false]>.folder-label .icon:after{content:"\f139"}[role=treeitem][aria-expanded=true]>.folder-label .icon:after{content:"\f140"}[role=treeitem] .folder-label{display:block;padding:3px 3px 3px 12px;cursor:pointer}[role=treeitem]{outline:0}[role=treeitem] .folder-label.focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}[role=treeitem] .folder-label.hover,[role=treeitem].hover{background-color:#eaeaea}.tree-folder{margin:0}.tree-folder .tree-folder::after{content:' ';display:block;position:absolute;left:2px;border-left:1px solid #ccc;top:-13px;bottom:10px}.tree-folder>li::before{content:' ';position:absolute;display:block;border-left:1px solid #ccc;left:2px;top:-5px;height:18px;width:7px;border-bottom:1px solid #ccc}.tree-folder>li::after{content:' ';position:absolute;display:block;border-left:1px solid #ccc;left:2px;bottom:-7px;top:0}#templateside .current-file{margin:-4px 0 -2px}.tree-folder>.current-file::before{left:4px;height:15px;width:0;border-left:none;top:3px}.tree-folder>.current-file::after{bottom:-4px;height:7px;left:2px;top:auto}.tree-folder li:last-child>.tree-folder::after,.tree-folder>li:last-child::after{display:none}#theme-plugin-editor-label{display:inline-block;margin-bottom:1em;font-weight:600}.fileedit-sub #plugin,.fileedit-sub #theme{max-width:40%}.fileedit-sub .alignright{text-align:right}#template p{width:97%}#file-editor-linting-error{margin-top:1em;margin-bottom:1em}#file-editor-linting-error>.notice{margin:0;display:inline-block}#file-editor-linting-error>.notice>p{width:auto}#template .submit{margin-top:1em;padding:0}#template .submit input[type=submit][disabled]{cursor:not-allowed}#templateside{float:right;width:16em}#postcustomstuff p.submit{margin:0}#templateside h4{margin:1em 0 0}#templateside li{margin:4px 0}#templateside li:not(.howto) a,.theme-editor-php .highlight{display:block;padding:3px 0 3px 12px;text-decoration:none}#templateside li:not(.howto)>a:first-of-type{padding-top:0}#templateside li.howto{padding:6px 12px 12px}.theme-editor-php .highlight{margin:-3px 3px -3px -12px}#templateside .highlight{border:none;font-weight:600}.nonessential{color:#666;font-size:11px;font-style:italic;padding-left:12px}#documentation{margin-top:10px}#documentation label{line-height:22px;vertical-align:baseline;font-weight:600}.fileedit-sub{padding:10px 0 8px;line-height:180%}#file-editor-warning .file-editor-warning-content{margin:25px}.accordion-section-title:after,.control-section .accordion-section-title:after,.nav-menus-php .item-edit:before,.widget-top .widget-action .toggle-indicator:before{content:"\f140";font:400 20px/1 dashicons;speak:none;display:block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.widget-top .widget-action .toggle-indicator:before{padding:1px 2px 1px 0;border-radius:50%}.accordion-section-title:after,.handlediv,.item-edit,.postbox .handlediv.button-link,.toggle-indicator{color:#72777c}.widget-action{color:#555d66}.accordion-section-title:hover:after,.handlediv:focus,.handlediv:hover,.item-edit:focus,.item-edit:hover,.postbox .handlediv.button-link:focus,.postbox .handlediv.button-link:hover,.sidebar-name:hover .toggle-indicator,.widget-action:focus,.widget-top:hover .widget-action{color:#23282d}.widget-top .widget-action:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.accordion-section-title:after,.control-section .accordion-section-title:after{float:right;right:20px;top:-2px}#customize-info.open .accordion-section-title:after,.control-section.open .accordion-section-title:after,.nav-menus-php .menu-item-edit-active .item-edit:before,.widget.open .widget-top .widget-action .toggle-indicator:before{content:"\f142"}/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-draggable-handle,.ui-sortable-handle{touch-action:none}.accordion-section{border-bottom:1px solid #ddd;margin:0}.accordion-section.open .accordion-section-content,.no-js .accordion-section .accordion-section-content{display:block}.accordion-section.open:hover{border-bottom-color:#ddd}.accordion-section-content{display:none;padding:10px 20px 15px;overflow:hidden;background:#fff}.accordion-section-title{margin:0;padding:12px 15px 15px;position:relative;border-left:1px solid #ddd;border-right:1px solid #ddd;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.js .accordion-section-title{cursor:pointer}.js .accordion-section-title:after{position:absolute;top:12px;right:10px;z-index:1}.accordion-section-title:focus{outline:0}.accordion-section-title:focus:after,.accordion-section-title:hover:after{border-color:#a0a5aa transparent}.cannot-expand .accordion-section-title{cursor:auto}.cannot-expand .accordion-section-title:after{display:none}.control-section .accordion-section-title,.customize-pane-child .accordion-section-title{border-left:none;border-right:none;padding:10px 10px 11px 14px;line-height:21px;background:#fff}.control-section .accordion-section-title:after,.customize-pane-child .accordion-section-title:after{top:calc(50% - 10px)}.js .control-section .accordion-section-title:focus,.js .control-section .accordion-section-title:hover,.js .control-section.open .accordion-section-title,.js .control-section:hover .accordion-section-title{color:#23282d;background:#f5f5f5}.control-section.open .accordion-section-title{border-bottom:1px solid #ddd}.network-admin .edit-site-actions{margin-top:0}.my-sites{display:block;overflow:auto;zoom:1}.my-sites li{display:block;padding:8px 3%;min-height:130px;margin:0}@media only screen and (max-width:599px){.my-sites li{min-height:0}}@media only screen and (min-width:600px){.my-sites.striped li{background-color:#fff;position:relative}.my-sites.striped li:after{content:"";width:1px;height:100%;position:absolute;top:0;right:0;background:#ccc}}@media only screen and (min-width:600px) and (max-width:699px){.my-sites li{float:left;width:44%}.my-sites.striped li{background-color:#fff}.my-sites.striped li:nth-of-type(2n+1){clear:left}.my-sites.striped li:nth-of-type(2n+2):after{content:none}.my-sites li:nth-of-type(4n+1),.my-sites li:nth-of-type(4n+2){background-color:#f9f9f9}}@media only screen and (min-width:700px) and (max-width:1199px){.my-sites li{float:left;width:27.333333%;background-color:#fff}.my-sites.striped li:nth-of-type(3n+3):after{content:none}.my-sites li:nth-of-type(6n+1),.my-sites li:nth-of-type(6n+2),.my-sites li:nth-of-type(6n+3){background-color:#f9f9f9}}@media only screen and (min-width:1200px) and (max-width:1399px){.my-sites li{float:left;width:21%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(4n+1){clear:left}.my-sites.striped li:nth-of-type(4n+4):after{content:none}.my-sites li:nth-of-type(8n+1),.my-sites li:nth-of-type(8n+2),.my-sites li:nth-of-type(8n+3),.my-sites li:nth-of-type(8n+4){background-color:#f9f9f9}}@media only screen and (min-width:1400px) and (max-width:1599px){.my-sites li{float:left;width:16%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(5n+1){clear:left}.my-sites.striped li:nth-of-type(5n+5):after{content:none}.my-sites li:nth-of-type(10n+1),.my-sites li:nth-of-type(10n+2),.my-sites li:nth-of-type(10n+3),.my-sites li:nth-of-type(10n+4),.my-sites li:nth-of-type(10n+5){background-color:#f9f9f9}}@media only screen and (min-width:1600px){.my-sites li{float:left;width:12.666666%;padding:8px 2%;background-color:#fff}.my-sites.striped li:nth-of-type(6n+1){clear:left}.my-sites.striped li:nth-of-type(6n+6):after{content:none}.my-sites li:nth-of-type(12n+1),.my-sites li:nth-of-type(12n+2),.my-sites li:nth-of-type(12n+3),.my-sites li:nth-of-type(12n+4),.my-sites li:nth-of-type(12n+5),.my-sites li:nth-of-type(12n+6){background-color:#f9f9f9}}.my-sites li a{text-decoration:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){div.star-holder,div.star-holder .star-rating{background:url(../images/stars-2x.png?ver=20121108) bottom left repeat-x;background-size:21px 37px}.spinner{background-image:url(../images/spinner-2x.gif)}#bulk-titles div a,#bulk-titles div a:hover,#screen-meta-links a.show-settings,.curtime #timestamp,.meta-box-sortables .postbox:hover .handlediv,.sidebar-name .toggle-indicator,.sidebar-name:hover .toggle-indicator,.widget-top .widget-action,.widget-top .widget-action:hover{background:0 0!important}}@-ms-viewport{width:device-width}@media screen and (max-width:782px){#col-left,#col-right,#templateside{float:none;width:auto}html.wp-toolbar{padding-top:46px}body{min-width:240px;overflow-x:hidden}body *{-webkit-tap-highlight-color:rgba(0,0,0,0)!important}#wpcontent{position:relative;margin-left:0;padding-left:10px}#wpbody-content{padding-bottom:100px}.wrap{margin-right:12px;margin-left:0}#col-left .col-wrap,#col-right .col-wrap{padding:0}#collapse-menu,#screen-meta,#screen-meta-links,.post-format-select{display:none!important}#documentation label[for=docs-list],.fileedit-sub .alignright label{display:block}.wrap h1.wp-heading-inline{margin-bottom:.5em}.wrap .add-new-h2,.wrap .add-new-h2:active,.wrap .page-title-action,.wrap .page-title-action:active{padding:10px 15px;font-size:14px;white-space:nowrap}.media-upload-form div.error,.notice,.wrap div.error,.wrap div.updated{margin:20px 0 10px;padding:5px 10px;font-size:14px;line-height:175%}.wp-core-ui .notice.is-dismissible{padding-right:46px}.notice-dismiss{padding:13px}.wrap .icon32+h2{margin-top:-2px}.wp-responsive-open #wpbody{right:-16em}code{word-wrap:break-word}.postbox{font-size:14px}.metabox-holder .postbox>h3,.metabox-holder .stuffbox>h3,.metabox-holder h2,.metabox-holder h3.hndle{padding:12px}.postbox .handlediv{margin-top:3px}.subsubsub{font-size:16px;text-align:center;margin-bottom:15px}#templateside>ul{border-left:1px solid #ddd}#templateside li{margin:0}#templateside li:not(.howto) a{display:block;padding:5px}#templateside li.howto{padding:12px}#templateside .highlight{padding:5px;margin-left:-5px;margin-top:-5px}#template .notice,#template>div{float:none;margin:1em 0;width:auto}#template .CodeMirror,#template textarea{box-sizing:border-box;width:100%}#templateside ul ul{padding-left:1.5em}[role=treeitem] .folder-label{display:block;padding:5px}#documentation input[type=button],.fileedit-sub input[type=submit]{margin-bottom:0;padding:8px 18px}.tree-folder .tree-folder::after,.tree-folder>li::after,.tree-folder>li::before{left:-8px}.tree-folder>li::before{top:0;height:13px}.tree-folder>.current-file::before{left:-5px;top:7px;width:4px}.tree-folder>.current-file::after{height:9px;left:-8px}.wrap #templateside span.notice{margin-left:-5px;width:100%}.fileedit-sub .alignright{float:left;margin-top:15px;width:100%;text-align:left}.fileedit-sub #plugin,.fileedit-sub #theme{margin-left:0;max-width:70%}#documentation select[name=docs-list]{margin-left:0;max-width:60%}#comments-form .checkforspam,#wpfooter{display:none}.edit-comment-author{margin:2px 0 0}.filter-drawer .filter-group-feature input,.filter-drawer .filter-group-feature label{line-height:25px}.filter-drawer .filter-group-feature label{margin-left:32px}.wp-filter .button.drawer-toggle{font-size:13px;line-height:26px;height:28px}}@media screen and (max-width:600px){#wpwrap.wp-responsive-open,div#post-body.metabox-holder.columns-1{overflow-x:hidden}html.wp-toolbar{padding-top:0}#wpbody{padding-top:46px}.nav-tab-wrapper,.wrap h2.nav-tab-wrapper,h1.nav-tab-wrapper{border-bottom:0}h1 .nav-tab,h2 .nav-tab,h3 .nav-tab{margin:10px 10px 0 0;border-bottom:1px solid #ccc}}@media screen and (max-width:320px){#network_dashboard_right_now .subsubsub{font-size:14px;text-align:left}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-controls-rtl.css b/backend/wp-admin/css/customize-controls-rtl.css new file mode 100644 index 0000000..39c635a --- /dev/null +++ b/backend/wp-admin/css/customize-controls-rtl.css @@ -0,0 +1,3032 @@ +body { + overflow: hidden; + -webkit-text-size-adjust: 100%; +} + +.customize-controls-close, +.widget-control-actions a { + text-decoration: none; +} + +#customize-controls h3 { + font-size: 14px; +} + +#customize-controls img { + max-width: 100%; +} + +#customize-controls .submit { + text-align: center; +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked { + background-color: rgba( 0, 0, 0, 0.7 ); + padding: 25px; +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .customize-changeset-locked-message { + margin-right: auto; + margin-left: auto; + max-width: 366px; + min-height: 64px; + width: auto; + padding: 25px 109px 25px 25px; + position: relative; + background: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + line-height: 1.5; + overflow-y: auto; + text-align: right; + top: calc( 50% - 100px ); +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .currently-editing { + margin-top: 0; +} +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .action-buttons { + margin-bottom: 0; +} + +.customize-changeset-locked-avatar { + width: 64px; + position: absolute; + right: 25px; + top: 25px; +} + +.wp-core-ui.wp-customizer .customize-changeset-locked-message a.button { + margin-left: 10px; + margin-top: 0; +} + +#customize-controls .description { + color: #555d66; +} + +#customize-save-button-wrapper { + float: left; + margin-top: 9px; +} + +body:not(.ready) #customize-save-button-wrapper .save { + visibility: hidden; +} +#customize-save-button-wrapper .save { + float: right; + border-radius: 3px; + box-shadow: none; /* @todo Adjust box shadow based on the disable states of paired button. */ + margin-top: 0; +} + +#customize-save-button-wrapper .save:focus, #publish-settings:focus { + box-shadow: 0 1px 0 #0073aa, 0 0 2px 1px #33b3db; /* This is default box shadow for focus */ +} + +#customize-save-button-wrapper .save.has-next-sibling { + border-radius: 0 3px 3px 0; +} + +#customize-sidebar-outer-content { + position: absolute; + top: 0; + bottom: 0; + right: 0; + visibility: hidden; + overflow-x: hidden; + overflow-y: auto; + width: 100%; + margin: 0; + z-index: -1; + background: #eee; + transition: right .18s; + border-left: 1px solid #ddd; + border-right: 1px solid #ddd; + height: 100%; +} + +#customize-theme-controls .control-section-outer { + display: none !important; +} + +#customize-outer-theme-controls .accordion-section-content { + padding: 12px; +} + +#customize-outer-theme-controls .accordion-section-content.open { + display: block; +} + +.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content { + visibility: visible; + right: 100%; + transition: right .18s; +} + +.customize-outer-pane-parent { + margin: 0; +} + +.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { + right: 300px; + opacity: 0.4; +} + +.outer-section-open .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, +.adding-menu-items .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, +.adding-widget .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main { + right: 64%; +} + +#customize-outer-theme-controls li.notice { + padding-top: 8px; + padding-bottom: 8px; + margin-right: 0; + margin-bottom: 10px; +} + +#publish-settings { + text-indent: 0; + border-radius: 3px 0 0 3px; + padding-right: 0; + padding-left: 0; + box-shadow: none; /* @todo Adjust box shadow based on the disable states of paired button. */ + font-size: 14px; + width: 30px; + float: right; + -webkit-transform: none; + transform: none; + margin-top: 0; +} + +body:not(.ready) #publish-settings, +body.trashing #customize-save-button-wrapper .save, +body.trashing #publish-settings { + display: none; +} + +#customize-header-actions .spinner { + margin-top: 13px; + margin-left: 4px; +} + +.saving #customize-header-actions .spinner, +.trashing #customize-header-actions .spinner { + visibility: visible; +} + +#customize-header-actions { + border-bottom: 1px solid #ddd; +} + +#customize-controls .wp-full-overlay-sidebar-content { + overflow-y: auto; + overflow-x: hidden; +} + +.outer-section-open #customize-controls .wp-full-overlay-sidebar-content { + background: #eee; +} + +#customize-controls .customize-info { + border: none; + border-bottom: 1px solid #ddd; + margin-bottom: 15px; +} + +#customize-control-changeset_status .customize-inside-control-row, +#customize-control-changeset_preview_link input { + background-color: #ffffff; + border-bottom: 1px solid #ddd; + box-sizing: content-box; + width: 100%; + margin-right: -12px; + padding-right: 12px; + padding-left: 12px; +} + +#customize-control-trash_changeset { + margin-top: 20px; +} +#customize-control-trash_changeset .button-link { + position: relative; + padding-right: 24px; + display: inline-block; +} +#customize-control-trash_changeset .button-link:before { + content: "\f182"; + font: normal 22px dashicons; + text-decoration: none; + position: absolute; + right: 0; + top: -2px; +} + +#customize-controls .date-input:invalid { + border-color: #dc3232; +} + +#customize-control-changeset_status .customize-inside-control-row { + padding-top: 10px; + padding-bottom: 10px; + font-weight: 500; +} + +#customize-control-changeset_status .customize-inside-control-row:first-of-type { + border-top: 1px solid #ddd; +} + +#customize-control-changeset_status .customize-control-title { + margin-bottom: 6px; +} + +#customize-control-changeset_status input { + margin-right: 0; +} + +#customize-control-changeset_preview_link { + position: relative; + display: block; +} + +.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button { + margin: 0; + position: absolute; + bottom: 9px; + left: 0; +} + +.preview-link-wrapper { + position: relative; +} + +.customize-copy-preview-link:before, +.customize-copy-preview-link:after { + content: ""; + height: 28px; + position: absolute; + background: #ffffff; + top: -1px; +} + +.customize-copy-preview-link:before { + right: -10px; + width: 9px; + opacity: 0.75; +} + +.customize-copy-preview-link:after { + right: -5px; + width: 4px; + opacity: 0.8; +} + +#customize-control-changeset_preview_link input { + line-height: 2.5; + border-top: 1px solid #ddd; + border-right: none; + border-left: none; + text-indent: -999px; + color: #fff; +} + +#customize-control-changeset_preview_link label { + position: relative; + display: block; +} + +#customize-control-changeset_preview_link a { + display: inline-block; + position: absolute; + white-space: nowrap; + overflow: hidden; + width: 90%; + bottom: 14px; + font-size: 14px; + text-decoration: none; +} + +#customize-control-changeset_preview_link a.disabled, +#customize-control-changeset_preview_link a.disabled:active, +#customize-control-changeset_preview_link a.disabled:focus, +#customize-control-changeset_preview_link a.disabled:visited { + color: black; + opacity: 0.4; + cursor: default; + outline: none; + box-shadow: none; +} + +#sub-accordion-section-publish_settings .customize-section-description-container { + display: none; +} + +#customize-controls .customize-info.section-meta { + margin-bottom: 15px; +} + +.customize-control-date_time .customize-control-description + .date-time-fields.includes-time { + margin-top: 10px; +} + +.customize-control.customize-control-date_time .date-time-fields .date-input.day { + margin-left: 0; +} + +.date-time-fields .date-input.month { + width: auto; + margin: 0; +} + +.date-time-fields .date-input.day, +.date-time-fields .date-input.hour, +.date-time-fields .date-input.minute { + width: 46px; +} + +.date-time-fields .date-input.year { + width: 60px; +} + +.date-time-fields .date-input.meridian { + width: auto; + margin: 0; +} + +.date-time-fields .time-row { + margin-top: 12px; +} + +.date-time-fields .date-timezone { + line-height: 2.2; + text-decoration: none; +} + +#customize-control-changeset_preview_link { + margin-top: 6px; +} + +#customize-control-changeset_status { + margin-bottom: 0; + padding-bottom: 0; +} + +#customize-control-changeset_scheduled_date { + box-sizing: content-box; + width: 100%; + margin-right: -12px; + padding: 12px; + background: #ffffff; + border-bottom: 1px solid #ddd; + margin-bottom: 0; +} + +#customize-control-changeset_scheduled_date .customize-control-description { + font-style: normal; +} + +#customize-controls .customize-info.is-in-view, +#customize-controls .customize-section-title.is-in-view { + position: absolute; + z-index: 9; + width: 100%; + box-shadow: 0 1px 0 rgba(0, 0, 0, .1); +} + +#customize-controls .customize-section-title.is-in-view { + margin-top: 0; +} + +#customize-controls .customize-info.is-in-view + .accordion-section { + margin-top: 15px; +} + +#customize-controls .customize-info.is-sticky, +#customize-controls .customize-section-title.is-sticky { + position: fixed; + top: 46px; +} + +#customize-controls .customize-info .accordion-section-title { + background: #fff; + color: #555d66; + border-right: none; + border-left: none; + border-bottom: none; + cursor: default; +} + +#customize-controls .customize-info.open .accordion-section-title:after, +#customize-controls .customize-info .accordion-section-title:hover:after, +#customize-controls .customize-info .accordion-section-title:focus:after { + color: #32373c; +} + +#customize-controls .customize-info .accordion-section-title:after { + display: none; +} + +#customize-controls .customize-info .preview-notice { + font-size: 13px; + line-height: 24px; +} + +#customize-controls .customize-pane-child .customize-section-title h3, +#customize-controls .customize-pane-child h3.customize-section-title, +#customize-outer-theme-controls .customize-pane-child .customize-section-title h3, +#customize-outer-theme-controls .customize-pane-child h3.customize-section-title, +#customize-controls .customize-info .panel-title { + font-size: 20px; + font-weight: 200; + line-height: 26px; + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +#customize-controls .customize-section-title span.customize-action { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +#customize-controls .customize-info .customize-help-toggle { + position: absolute; + top: 4px; + left: 1px; + padding: 20px 10px 10px 20px; + width: 20px; + height: 20px; + cursor: pointer; + box-shadow: none; + -webkit-appearance: none; + background: transparent; + color: #555d66; + border: none; +} + +#customize-controls .customize-info .customize-help-toggle:before { + position: absolute; + top: 5px; + right: 6px; +} + +#customize-controls .customize-info.open .customize-help-toggle, +#customize-controls .customize-info .customize-help-toggle:focus, +#customize-controls .customize-info .customize-help-toggle:hover { + color: #0073aa; +} + +#customize-controls .customize-info .customize-panel-description, +#customize-controls .customize-info .customize-section-description, +#customize-outer-theme-controls .customize-info .customize-section-description, +#customize-controls .no-widget-areas-rendered-notice { + color: #555d66; + display: none; + background: #fff; + padding: 12px 15px; + border-top: 1px solid #ddd; +} + +#customize-controls .customize-info .customize-panel-description.open + .no-widget-areas-rendered-notice { + border-top: none; +} +.no-widget-areas-rendered-notice { + font-style: italic; +} +.no-widget-areas-rendered-notice p:first-child { + margin-top: 0; +} +.no-widget-areas-rendered-notice p:last-child { + margin-bottom: 0; +} + +#customize-controls .customize-info .customize-section-description { + margin-bottom: 15px; +} + +#customize-controls .customize-info .customize-panel-description p:first-child, +#customize-controls .customize-info .customize-section-description p:first-child { + margin-top: 0; +} + +#customize-controls .customize-info .customize-panel-description p:last-child, +#customize-controls .customize-info .customize-section-description p:last-child { + margin-bottom: 0; +} + +#customize-controls .current-panel .control-section > h3.accordion-section-title { + padding-left: 30px; +} + +#customize-theme-controls .control-section, +#customize-outer-theme-controls .control-section { + border: none; +} + +#customize-theme-controls .accordion-section-title, +#customize-outer-theme-controls .accordion-section-title { + color: #555d66; + background-color: #fff; + border-bottom: 1px solid #ddd; + border-right: 4px solid #fff; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; +} + +#customize-controls #customize-theme-controls .customize-themes-panel .accordion-section-title { + color: #555; + background-color: #fff; + border-right: 4px solid #fff; +} + +#customize-theme-controls .accordion-section-title:after, +#customize-outer-theme-controls .accordion-section-title:after { + content: "\f341"; + color: #a0a5aa; +} + +#customize-theme-controls .accordion-section-content, +#customize-outer-theme-controls .accordion-section-content { + color: #555d66; + background: transparent; +} + +#customize-controls .control-section:hover > .accordion-section-title, +#customize-controls .control-section .accordion-section-title:hover, +#customize-controls .control-section.open .accordion-section-title, +#customize-controls .control-section .accordion-section-title:focus { + color: #0073aa; + background: #f3f3f5; + border-right-color: #0073aa; +} + +#accordion-section-themes + .control-section { + border-top: 1px solid #ddd; +} + +.js .control-section:hover .accordion-section-title, +.js .control-section .accordion-section-title:hover, +.js .control-section.open .accordion-section-title, +.js .control-section .accordion-section-title:focus { + background: #f3f3f5; +} + +#customize-theme-controls .control-section:hover > .accordion-section-title:after, +#customize-theme-controls .control-section .accordion-section-title:hover:after, +#customize-theme-controls .control-section.open .accordion-section-title:after, +#customize-theme-controls .control-section .accordion-section-title:focus:after, +#customize-outer-theme-controls .control-section:hover > .accordion-section-title:after, +#customize-outer-theme-controls .control-section .accordion-section-title:hover:after, +#customize-outer-theme-controls .control-section.open .accordion-section-title:after, +#customize-outer-theme-controls .control-section .accordion-section-title:focus:after { + color: #0073aa; +} + +#customize-theme-controls .control-section.open { + border-bottom: 1px solid #eee; +} + +#customize-theme-controls .control-section.open .accordion-section-title, +#customize-outer-theme-controls .control-section.open .accordion-section-title { + border-bottom-color: #eee !important; +} + +#customize-theme-controls .control-section:last-of-type.open, +#customize-theme-controls .control-section:last-of-type > .accordion-section-title { + border-bottom-color: #ddd; +} + +#customize-theme-controls .control-panel-content:not(.control-panel-nav_menus) .control-section:nth-child(2), +#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu, +#customize-theme-controls .control-section-nav_menu_locations .accordion-section-title { + border-top: 1px solid #ddd; +} + +#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu + .control-section-nav_menu { + border-top: none; +} + +#customize-theme-controls > ul { + margin: 0; +} + +#customize-theme-controls .accordion-section-content { + position: absolute; + top: 0; + right: 100%; + width: 100%; + margin: 0; + padding: 12px; + box-sizing: border-box; +} + +#customize-info, +#customize-theme-controls .customize-pane-parent, +#customize-theme-controls .customize-pane-child { + overflow: visible; + width: 100%; + margin: 0; + padding: 0; + box-sizing: border-box; + transition: 0.18s -webkit-transform cubic-bezier(0.645, 0.045, 0.355, 1); + transition: 0.18s transform cubic-bezier(0.645, 0.045, 0.355, 1); + transition: 0.18s transform cubic-bezier(0.645, 0.045, 0.355, 1), 0.18s -webkit-transform cubic-bezier(0.645, 0.045, 0.355, 1); /* easeInOutCubic */ +} + +#customize-theme-controls .customize-pane-child.skip-transition { + transition: none; +} + +#customize-info, +#customize-theme-controls .customize-pane-parent { + position: relative; + visibility: visible; + height: auto; + max-height: none; + overflow: auto; + -webkit-transform: none; + transform: none; +} + +#customize-theme-controls .customize-pane-child { + position: absolute; + top: 0; + right: 0; + visibility: hidden; + height: 0; + max-height: none; + overflow: hidden; + -webkit-transform: translateX(-100%); + transform: translateX(-100%); +} + +#customize-theme-controls .customize-pane-child.open, +#customize-theme-controls .customize-pane-child.current-panel { + -webkit-transform: none; + transform: none; +} + +.section-open #customize-theme-controls .customize-pane-parent, +.in-sub-panel #customize-theme-controls .customize-pane-parent, +.section-open #customize-info, +.in-sub-panel #customize-info, +.in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel { + visibility: hidden; + height: 0; + overflow: hidden; + -webkit-transform: translateX(100%); + transform: translateX(100%); +} + +.section-open #customize-theme-controls .customize-pane-parent.busy, +.in-sub-panel #customize-theme-controls .customize-pane-parent.busy, +.section-open #customize-info.busy, +.in-sub-panel #customize-info.busy, +.busy.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel, +#customize-theme-controls .customize-pane-child.open, +#customize-theme-controls .customize-pane-child.current-panel, +#customize-theme-controls .customize-pane-child.busy { + visibility: visible; + height: auto; + overflow: auto; +} + +#customize-theme-controls .customize-pane-child.accordion-section-content, +#customize-theme-controls .customize-pane-child.accordion-sub-container { + display: block; + overflow-x: hidden; +} + +#customize-theme-controls .customize-pane-child.accordion-section-content { + padding: 12px; +} + +#customize-theme-controls .customize-pane-child.menu li { + position: static; +} + +.customize-section-description-container, +.control-section-nav_menu .customize-section-description-container, +.control-section-new_menu .customize-section-description-container { + margin-bottom: 15px; +} + +.control-section-nav_menu .customize-control, +.control-section-new_menu .customize-control { + /* Override default `margin-bottom` for `.customize-control` */ + margin-bottom: 0; +} + +.customize-section-title { + margin: -12px -12px 0 -12px; + border-bottom: 1px solid #ddd; + background: #fff; +} + +div.customize-section-description { + margin-top: 22px; +} + +.customize-info div.customize-section-description { + margin-top: 0; +} + +div.customize-section-description p:first-child { + margin-top: 0; +} + +div.customize-section-description p:last-child { + margin-bottom: 0; +} + +#customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child { + border-bottom: 1px solid #ddd; + padding: 12px 12px 12px 12px; +} + +.ios #customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child { + padding: 12px 12px 13px 12px; +} + +.customize-section-title h3, +h3.customize-section-title { + padding: 10px 14px 12px 10px; + margin: 0; + line-height: 21px; + color: #555d66; +} + +.accordion-sub-container.control-panel-content { + display: none; + position: absolute; + top: 0; + width: 100%; +} + +.accordion-sub-container.control-panel-content.busy { + display: block; +} + +.current-panel .accordion-sub-container.control-panel-content { + width: 100%; +} + +.customize-controls-close { + display: block; + position: absolute; + top: 0; + right: 0; + width: 45px; + height: 41px; + padding: 0 0 0 2px; + background: #eee; + border: none; + border-top: 4px solid #eee; + border-left: 1px solid #ddd; + color: #444; + text-align: right; + cursor: pointer; + transition: color .15s ease-in-out, + border-color .15s ease-in-out, + background .15s ease-in-out; + box-sizing: content-box; +} + +.customize-panel-back, +.customize-section-back { + display: block; + float: right; + width: 48px; + height: 71px; + padding: 0 0 0 24px; + margin: 0; + background: #fff; + border: none; + border-left: 1px solid #ddd; + border-right: 4px solid #fff; + box-shadow: none; + cursor: pointer; + transition: color .15s ease-in-out, + border-color .15s ease-in-out, + background .15s ease-in-out; +} + +.customize-section-back { + height: 74px; +} + +.ios .customize-panel-back { + display: none; +} + +.ios .expanded.in-sub-panel .customize-panel-back { + display: block; +} + +#customize-controls .panel-meta.customize-info .accordion-section-title { + margin-right: 48px; + border-right: none; +} + +#customize-controls .panel-meta.customize-info .accordion-section-title:hover, +#customize-controls .cannot-expand:hover .accordion-section-title { + background: #fff; + color: #555d66; + border-right-color: #fff; +} + +.customize-controls-close:focus, +.customize-controls-close:hover, +.customize-controls-preview-toggle:focus, +.customize-controls-preview-toggle:hover { + background: #fff; + color: #0073aa; + border-top-color: #0073aa; + outline: none; + box-shadow: none; +} + + +.customize-panel-back:hover, +.customize-panel-back:focus, +.customize-section-back:hover, +.customize-section-back:focus { + color: #0073aa; + background: #f3f3f5; + border-right-color: #0073aa; + outline: none; + box-shadow: none; +} + +.customize-controls-close:before { + font: normal 22px/45px dashicons; + content: "\f335"; + position: relative; + top: -3px; + right: 13px; +} + +.customize-panel-back:before, +.customize-section-back:before { + font: normal 20px/72px dashicons; + content: "\f345"; + position: relative; + right: 9px; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header { + background-color: #eee; + transition: padding ease-in-out .18s; +} + +.in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header { + padding-right: 62px; +} + +p.customize-section-description { + font-style: normal; + margin-top: 22px; + margin-bottom: 0; +} + +.customize-section-description ul { + margin-right: 1em; +} + +.customize-section-description ul > li { + list-style: disc; +} + +.section-description-buttons { + text-align: left; +} + +.section-description-buttons button.button-link { + color: #0073aa; + text-decoration: underline; +} + +.customize-control { + width: 100%; + float: right; + clear: both; + margin-bottom: 12px; +} + +.customize-control select, +.customize-control input[type="radio"], +.customize-control input[type="checkbox"] { + line-height: 28px; +} + +.customize-control input[type="text"], +.customize-control input[type="password"], +.customize-control input[type="email"], +.customize-control input[type="number"], +.customize-control input[type="search"], +.customize-control input[type="tel"], +.customize-control input[type="url"] { + width: 100%; + line-height: 18px; + margin: 0; +} + +.customize-control-hidden { + margin: 0; +} + +.customize-control-textarea textarea { + width: 100%; + resize: vertical; +} + +.customize-control select { + width: 100%; + height: 28px; + line-height: 28px; +} + +.customize-control select[multiple] { + height: auto; +} + +.customize-control-title { + display: block; + font-size: 14px; + line-height: 24px; + font-weight: 600; + margin-bottom: 4px; +} + +.customize-control-description { + display: block; + font-style: italic; + line-height: 18px; + margin-top: 0; + margin-bottom: 5px; +} + +.customize-section-description a.external-link:after { + font: 16px/11px dashicons; + content: "\f310"; + top: 3px; + position: relative; + padding-right: 3px; + display: inline-block; + text-decoration: none; +} + +.customize-control-color .color-picker, +.customize-control-upload div { + line-height: 28px; +} + +.customize-control .customize-inside-control-row { + line-height: 20px; + display: block; + margin-right: 24px; + padding-top: 6px; + padding-bottom: 6px; +} + +.customize-control-radio input, +.customize-control-checkbox input, +.customize-control-nav_menu_auto_add input { + margin-left: 4px; + margin-right: -24px; +} + +.customize-control-radio { + padding: 5px 0 10px; +} + +.customize-control-radio .customize-control-title { + margin-bottom: 0; + line-height: 22px; +} + +.customize-control-radio .customize-control-title + .customize-control-description { + margin-top: 7px; +} + +.customize-control-radio label, +.customize-control-checkbox label { + vertical-align: top; +} + +.customize-control .attachment-thumb.type-icon { + float: right; + margin: 10px; + width: auto; +} + +.customize-control .attachment-title { + font-weight: 600; + margin: 0; + padding: 5px 10px; +} + +.customize-control .attachment-meta { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin: 0; + padding: 0 10px; +} + +.customize-control .attachment-meta-title { + padding-top: 7px; +} + +/* Remove descender space. */ +.customize-control .thumbnail-image, +.customize-control-header .current, +.customize-control .wp-media-wrapper.wp-video { + line-height: 0; +} + +/* Remove descender space. */ +.customize-control-site_icon .favicon-preview .browser-preview { + vertical-align: top; +} + +.customize-control .thumbnail-image img { + cursor: pointer; +} + +#customize-controls .thumbnail-audio .thumbnail { + max-width: 64px; + max-height: 64px; + margin: 10px; + float: right; +} + +#available-menu-items .accordion-section-content .new-content-item, +.customize-control-dropdown-pages .new-content-item { + width: calc(100% - 30px); + padding: 8px 15px; + position: absolute; + bottom: 0; + z-index: 10; + background: #eee; + display: -webkit-box; + display: flex; +} + +.customize-control-dropdown-pages .new-content-item { + width: 100%; + padding: 5px 1px 5px 0; + position: relative; +} + +#available-menu-items .new-content-item .create-item-input, +.customize-control-dropdown-pages .new-content-item .create-item-input { + -webkit-box-flex: 10; + flex-grow: 10; +} + +#available-menu-items .new-content-item .add-content, +.customize-control-dropdown-pages .new-content-item .add-content { + margin: 2px 6px 2px 0; + -webkit-box-flex: 10; + flex-grow: 1; +} + +.customize-control-dropdown-pages .new-content-item .create-item-input.invalid { + border: 1px solid #dc3232; +} + +.customize-control-dropdown-pages .add-new-toggle { + margin-right: 1px; + font-weight: 600; + line-height: 28px; +} + +#customize-preview iframe { + width: 100%; + height: 100%; + position: absolute; +} +#customize-preview iframe + iframe { + visibility: hidden; +} + +.wp-full-overlay-sidebar { + background: #eee; + border-left: 1px solid #ddd; +} + + +/** + * Notifications + */ + +#customize-controls .customize-control-notifications-container { /* Scoped to #customize-controls for specificity over notification styles in common.css. */ + margin: 4px 0 8px 0; + padding: 0; + cursor: default; +} + +#customize-controls .customize-control-widget_form.has-error .widget .widget-top, +.customize-control-nav_menu_item.has-error .menu-item-bar .menu-item-handle { + box-shadow: inset 0 0 0 2px #dc3232; + transition: .15s box-shadow linear; +} + +#customize-controls .customize-control-notifications-container li.notice { + list-style: none; + margin: 0 0 6px 0; + padding: 9px 14px; + overflow: hidden; +} +#customize-controls .customize-control-notifications-container .notice.is-dismissible { + padding-left: 38px; +} + +.customize-control-notifications-container li.notice:last-child { + margin-bottom: 0; +} + +#customize-controls .customize-control-nav_menu_item .customize-control-notifications-container { + margin-top: 0; +} + +#customize-controls .customize-control-widget_form .customize-control-notifications-container { + margin-top: 8px; +} + +.customize-control-text.has-error input { + outline: 2px solid #dc3232; +} + +#customize-controls #customize-notifications-area { + position: absolute; + top: 46px; + width: 100%; + border-bottom: 1px solid #ddd; + display: block; + padding: 0; + margin: 0; +} + +.wp-full-overlay.collapsed #customize-controls #customize-notifications-area { + display: none !important; +} + +#customize-controls #customize-notifications-area:not(.has-overlay-notifications), +#customize-controls .customize-section-title > .customize-control-notifications-container:not(.has-overlay-notifications), +#customize-controls .panel-meta > .customize-control-notifications-container:not(.has-overlay-notifications) { + max-height: 210px; + overflow-x: hidden; + overflow-y: auto; +} + +#customize-controls #customize-notifications-area > ul, +#customize-controls #customize-notifications-area .notice, +#customize-controls .panel-meta > .customize-control-notifications-container, +#customize-controls .panel-meta > .customize-control-notifications-container .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice { + margin: 0; +} +#customize-controls .panel-meta > .customize-control-notifications-container, +#customize-controls .customize-section-title > .customize-control-notifications-container { + border-top: 1px solid #ddd; +} +#customize-controls #customize-notifications-area .notice, +#customize-controls .panel-meta > .customize-control-notifications-container .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice { + padding: 9px 14px; +} +#customize-controls #customize-notifications-area .notice.is-dismissible, +#customize-controls .panel-meta > .customize-control-notifications-container .notice.is-dismissible, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice.is-dismissible { + padding-left: 38px; +} +#customize-controls #customize-notifications-area .notice + .notice, +#customize-controls .panel-meta > .customize-control-notifications-container .notice + .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice + .notice { + margin-top: 1px; +} + +@-webkit-keyframes customize-fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +@keyframes customize-fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +#customize-controls .notice.notification-overlay, +#customize-controls #customize-notifications-area .notice.notification-overlay { + margin: 0; + border-right: 0; /* @todo Appropriate styles could be added for notice-error, notice-warning, notice-success, etc */ +} + +#customize-controls .customize-control-notifications-container.has-overlay-notifications { + -webkit-animation: customize-fade-in 0.5s; + animation: customize-fade-in 0.5s; + z-index: 30; +} + +/* Note: Styles for this are also defined in themes.css */ +#customize-controls #customize-notifications-area .notice.notification-overlay .notification-message { + clear: both; + color: #191e23; + font-size: 18px; + font-style: normal; + margin: 0; + padding: 2em 0; + text-align: center; + width: 100%; + display: block; + top: 50%; + position: relative; +} + +/* Style for custom settings */ + +/** + * Static front page + */ + +#customize-control-show_on_front.has-error { + margin-bottom: 0; +} +#customize-control-show_on_front.has-error .customize-control-notifications-container { + margin-top: 12px; +} + +/** + * Dropdowns + */ + +.accordion-section .dropdown { + float: right; + display: block; + position: relative; + cursor: pointer; +} + +.accordion-section .dropdown-content { + overflow: hidden; + float: right; + min-width: 30px; + height: 16px; + line-height: 16px; + margin-left: 16px; + padding: 4px 5px; + border: 2px solid #eee; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* @todo maybe no more used? */ +.customize-control .dropdown-arrow { + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 20px; + background: #eee; +} + +.customize-control .dropdown-arrow:after { + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: block; + padding: 0; + text-indent: 0; + text-align: center; + position: relative; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #32373c; +} + +.customize-control .dropdown-status { + color: #32373c; + background: #eee; + display: none; + max-width: 112px; +} + +.customize-control-color .dropdown { + margin-left: 5px; + margin-bottom: 5px; +} + +.customize-control-color .dropdown .dropdown-content { + background-color: #555d66; + border: 1px solid rgba(0, 0, 0, 0.15); +} + +.customize-control-color .dropdown:hover .dropdown-content { + border-color: rgba(0, 0, 0, 0.25); +} + +/** + * iOS can't scroll iframes, + * instead it expands the iframe size to match the size of the content + */ + +.ios .wp-full-overlay { + position: relative; +} + +.ios #customize-controls .wp-full-overlay-sidebar-content { + -webkit-overflow-scrolling: touch; +} + +/* Media controls */ + +.customize-control .actions .button { + margin-top: 12px; +} + +.customize-control-header .actions, +.customize-control-header .uploaded { + margin-bottom: 18px; +} + +.customize-control-header .uploaded button:not(.random), +.customize-control-header .default button:not(.random) { + width: 100%; + padding: 0; + margin: 0; + background: none; + border: none; + color: inherit; + cursor: pointer; +} + +.customize-control-header button img { + display: block; +} + +.customize-control .attachment-media-view .remove-button, +.customize-control .attachment-media-view .default-button, +.customize-control .attachment-media-view .upload-button, +.customize-control-header button.new, +.customize-control-header button.remove { + width: auto; + height: auto; + white-space: normal; +} + +.customize-control .attachment-media-view .thumbnail, +.customize-control-header .current .container { + overflow: hidden; +} + +.customize-control .attachment-media-view .placeholder, +.customize-control-header .placeholder { + width: 100%; + position: relative; + text-align: center; + cursor: default; + border: 1px dashed #b4b9be; + box-sizing: border-box; + padding: 9px 0; + line-height: 20px; +} + +.customize-control-header .inner { + display: none; + position: absolute; + width: 100%; + color: #555d66; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.customize-control-header .inner, +.customize-control-header .inner .dashicons { + line-height: 20px; + top: 8px; +} + +.customize-control-header .list .inner, +.customize-control-header .list .inner .dashicons { + top: 9px; +} + +.customize-control-header .header-view { + position: relative; + width: 100%; + margin-bottom: 12px; +} + +.customize-control-header .header-view:last-child { + margin-bottom: 0px; +} + +/* Convoluted, but 'outline' support isn't good enough yet */ +.customize-control-header .header-view:after { + border: 0; +} + +.customize-control-header .header-view.selected .choice:focus { + outline: none; +} + +.customize-control-header .header-view.selected:after { + content: ''; + position: absolute; + height: auto; + top: 0; + right: 0; + bottom: 0; + left: 0; + border: 4px solid #00a0d2; + border-radius: 2px; +} + +.customize-control-header .header-view.button.selected { + border: 0; +} + +/* Header control: overlay "close" button */ + +.customize-control-header .uploaded .header-view .close { + font-size: 20px; + color: #fff; + background: #555d66; + background: rgba(0, 0, 0, 0.5); + position: absolute; + top: 10px; + right: -999px; + z-index: 1; + width: 26px; + height: 26px; + cursor: pointer; +} + +.customize-control-header .header-view:hover .close, +.customize-control-header .header-view .close:focus { + right: auto; + left: 10px; +} + +.customize-control-header .header-view .close:focus { + outline: 1px solid #5b9dd9; +} + +/* Header control: randomiz(s)er */ + +.customize-control-header .random.placeholder { + cursor: pointer; + border-radius: 2px; + height: 40px; +} + +.customize-control-header button.random { + width: 100%; + height: auto; + min-height: 40px; + white-space: normal; +} + +.customize-control-header button.random .dice { + margin-top: 4px; +} + +.customize-control-header .placeholder:hover .dice, +.customize-control-header .header-view:hover > button.random .dice { + -webkit-animation: dice-color-change 3s infinite; + animation: dice-color-change 3s infinite; +} + +.button-see-me { + -webkit-animation: bounce .7s 1; + animation: bounce .7s 1; + -webkit-transform-origin: center bottom; + transform-origin: center bottom; +} + +@-webkit-keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -12px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -6px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-1px,0); + } +} + +@keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -12px, 0); + transform: translate3d(0, -12px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -6px, 0); + transform: translate3d(0, -6px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-1px,0); + transform: translate3d(0,-1px,0); + } +} + +.customize-control-header .choice { + position: relative; + display: block; + margin-bottom: 9px; +} + +.customize-control-header .choice:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 3px 1px rgba(30, 140, 190, .8); +} + +.customize-control-header .uploaded div:last-child > .choice { + margin-bottom: 0; +} + +.customize-control .attachment-media-view .thumbnail-image img, +.customize-control-header img { + max-width: 100%; +} + +.customize-control .attachment-media-view .remove-button, +.customize-control .attachment-media-view .default-button, +.customize-control-header .remove { + margin-left: 8px; +} + +/* Background position control */ +.customize-control-background_position .background-position-control .button-group { + display: block; +} + +/** + * Code Editor Control and Custom CSS Section + * + * Modifications to the Section Container to make the textarea full-width and + * full-height, if the control is the only control in the section. + */ + +.customize-control-code_editor textarea { + width: 100%; + font-family: Consolas, Monaco, monospace; + font-size: 12px; + padding: 6px 8px; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +.customize-control-code_editor textarea, +.customize-control-code_editor .CodeMirror { + height: 14em; +} + +#customize-controls .customize-section-description-container.section-meta.customize-info { + border-bottom: none; +} + +#sub-accordion-section-custom_css .customize-control-notifications-container { + margin-bottom: 15px; +} + +#customize-control-custom_css textarea { + display: block; + height: 500px; +} + +.customize-section-description-container + #customize-control-custom_css .customize-control-title { + margin-right: 12px; +} + +.customize-section-description-container + #customize-control-custom_css:last-child textarea { + border-left: 0; + border-right: 0; + height: calc( 100vh - 185px ); + resize: none; +} + +.customize-section-description-container + #customize-control-custom_css:last-child { + margin-right: -12px; + width: 299px; + width: calc( 100% + 24px ); + margin-bottom: -12px; +} + +.customize-section-description-container + #customize-control-custom_css:last-child .CodeMirror { + height: calc( 100vh - 185px ); +} + +.CodeMirror-lint-tooltip, +.CodeMirror-hints { + z-index: 500000 !important; +} + +.customize-section-description-container + #customize-control-custom_css:last-child .customize-control-notifications-container { + margin-right: 12px; + margin-left: 12px; +} + +.theme-browser .theme.active .theme-actions, +.wp-customizer .theme-browser .theme .theme-actions { + padding: 10px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); +} + +@media screen and ( max-width: 640px ) { + .customize-section-description-container + #customize-control-custom_css:last-child { + margin-left: 0; + } + + .customize-section-description-container + #customize-control-custom_css:last-child textarea { + height: calc( 100vh - 140px ); + } +} + +/** + * Themes + */ + +#customize-theme-controls .control-panel-themes { + border-bottom: none; +} + +#customize-theme-controls .control-panel-themes > .accordion-section-title:hover, /* Not a focusable element. */ +#customize-theme-controls .control-panel-themes > .accordion-section-title { + cursor: default; + background: #fff; + color: #555d66; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + border-right: none; + border-left: none; + margin: 0 0 15px 0; + padding-left: 100px; /* Space for the button */ +} + +#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child:hover, /* Not a focusable element. */ +#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child { + border-top: 0; +} + +#customize-theme-controls .control-section-themes > .accordion-section-title:hover, /* Not a focusable element. */ +#customize-theme-controls .control-section-themes > .accordion-section-title { + margin: 0 0 15px; +} + +#customize-controls .customize-themes-panel .accordion-section-title:hover, +#customize-controls .customize-themes-panel .accordion-section-title { + margin: 15px -8px; +} + +#customize-controls .control-section-themes .accordion-section-title, +#customize-controls .customize-themes-panel .accordion-section-title { + padding-left: 100px; /* Space for the button */ +} + +.control-panel-themes .accordion-section-title span.customize-action, +#customize-controls .customize-section-title span.customize-action, +#customize-controls .control-section-themes .accordion-section-title span.customize-action, +#customize-controls .customize-section-title span.customize-action { + font-size: 13px; + display: block; + font-weight: 400; +} + +#customize-theme-controls .control-panel-themes .accordion-section-title .change-theme { + position: absolute; + left: 10px; + top: 50%; + margin-top: -14px; + font-weight: 400; +} + +#customize-theme-controls .control-panel-themes > .accordion-section-title:after { + display: none; +} + +.control-panel-themes .customize-themes-full-container { + position: fixed; + top: 0; + right: 0; + transition: .18s right ease-in-out; + margin: 0 300px 0 0; + padding: 71px 0 25px; + overflow-y: scroll; + width: calc(100% - 300px); + height: calc(100% - 96px); + background: #eee; + z-index: 20; +} + +@media screen and (min-width: 1670px) { + .control-panel-themes .customize-themes-full-container { + width: 82%; + left: 0; + right: initial; + } +} + +.modal-open .control-panel-themes .customize-themes-full-container { + overflow-y: visible; +} + +/* Animations for opening the themes panel */ +#customize-save-button-wrapper, +#customize-header-actions .spinner, +#customize-header-actions .customize-controls-preview-toggle { + transition: .18s margin ease-in-out; +} + +#customize-footer-actions, +#customize-footer-actions .collapse-sidebar { + bottom: 0; + transition: .18s bottom ease-in-out; +} + +.in-themes-panel:not(.animating) #customize-header-actions .spinner, +.in-themes-panel:not(.animating) #customize-header-actions .customize-controls-preview-toggle, +.in-themes-panel:not(.animating) #customize-preview, +.in-themes-panel:not(.animating) #customize-footer-actions { + visibility: hidden; +} + +.wp-full-overlay.in-themes-panel { + background: #eee; /* Prevents a black flash when fading in the panel */ +} + +.in-themes-panel #customize-save-button-wrapper, +.in-themes-panel #customize-header-actions .spinner, +.in-themes-panel #customize-header-actions .customize-controls-preview-toggle { + margin-top: -46px; /* Height of header actions bar */ +} + +.in-themes-panel #customize-footer-actions, +.in-themes-panel #customize-footer-actions .collapse-sidebar { + bottom: -45px; +} + +/* Don't show the theme count while the panel opens, as it's in the wrong place during the animation */ +.in-themes-panel.animating .control-panel-themes .filter-themes-count { + display: none; +} + +.in-themes-panel.wp-full-overlay .wp-full-overlay-sidebar-content { + bottom: 0; +} + +.themes-filter-bar .feature-filter-toggle { + float: left; + margin: 3px 25px 3px 0; +} + +.themes-filter-bar .feature-filter-toggle:before { + content: "\f111"; + margin: 0 0 0 5px; + font: normal 16px/1 dashicons; + vertical-align: text-bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.themes-filter-bar .feature-filter-toggle.open { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.themes-filter-bar .feature-filter-toggle .filter-count-filters { + display: none; +} + +.filter-drawer { + box-sizing: border-box; + width: 100%; + position: absolute; + top: 46px; + right: 0; + padding: 25px 25px 25px 0; + border-top: 0; + margin: 0; + background: #eee; + border-bottom: 1px solid #ddd; +} + +.filter-drawer .filter-group { + margin: 0 0 0 25px; + width: calc( (100% - 75px) / 3); + min-width: 200px; + max-width: 320px; +} + +/* Adds a delay before fading in to avoid it "jumping" */ +@-webkit-keyframes themes-fade-in { + 0% { + opacity: 0; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@keyframes themes-fade-in { + 0% { + opacity: 0; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.control-panel-themes .customize-themes-full-container.animate { + -webkit-animation: .6s themes-fade-in 1; + animation: .6s themes-fade-in 1; +} + +.in-themes-panel:not(.animating) .control-panel-themes .filter-themes-count { + -webkit-animation: .6s themes-fade-in 1; + animation: .6s themes-fade-in 1; +} + +.control-panel-themes .filter-themes-count { + position: relative; + float: left; + line-height: 34px; +} + +.control-panel-themes .filter-themes-count .themes-displayed { + font-weight: 600; + color: #555d66; +} + +.customize-themes-notifications { + margin: 0; +} + +.control-panel-themes .customize-themes-notifications .notice { + margin: 0 0 25px 0; +} + +.customize-themes-full-container .customize-themes-section { + display: none !important; /* There is unknown JS that perpetually tries to show all theme sections when more items are added. */ + overflow: hidden; +} + +.customize-themes-full-container .customize-themes-section.current-section { + display: list-item !important; /* There is unknown JS that perpetually tries to show all theme sections when more items are added. */ +} + +.control-section .customize-section-text-before { + padding: 0 15px 8px 0; + margin: 15px 0 0 0; + line-height: 16px; + border-bottom: 1px solid #ddd; + color: #555d66; +} + +.control-panel-themes .customize-themes-section-title { + width: 100%; + background: #fff; + box-shadow: none; + outline: none; + border-top: none; + border-bottom: 1px solid #ddd; + border-right: 4px solid #fff; + border-left: none; + cursor: pointer; + padding: 10px 15px; + position: relative; + text-align: right; + font-size: 14px; + font-weight: 600; + color: #555d66; + text-shadow: none; +} + +.control-panel-themes #accordion-section-installed_themes { + border-top: 1px solid #ddd; +} + +.control-panel-themes .theme-section { + margin: 0; + position: relative; +} + +.control-panel-themes .customize-themes-section-title:focus, +.control-panel-themes .customize-themes-section-title:hover { + border-right-color: #0073aa; + color: #0073aa; + background: #f5f5f5; +} + +.customize-themes-section-title:not(.selected):after { + content: ""; + display: block; + position: absolute; + top: 9px; + left: 15px; + width: 18px; + height: 18px; + border-radius: 100%; + border: 1px solid #ccc; + background: #fff; +} + +.control-panel-themes .theme-section .customize-themes-section-title.selected:after { + content: "\f147"; + font: 16px/1 dashicons; + box-sizing: border-box; + width: 20px; + height: 20px; + padding: 3px 1px 1px 3px; /* Re-align the icon to the smaller grid */ + border-radius: 100%; + position: absolute; + top: 9px; + left: 15px; + background: #0073aa; + color: #fff; +} + +.control-panel-themes .customize-themes-section-title.selected { + color: #0073aa; +} + +#customize-theme-controls .themes.accordion-section-content { + position: relative; + right: 0; + padding: 0; + width: 100%; +} + +.loading .customize-themes-section .spinner { + display: block; + visibility: visible; + position: relative; + clear: both; + width: 20px; + height: 20px; + right: calc(50% - 10px); + float: none; + margin-top: 50px; +} + +.customize-themes-section .no-themes, +.customize-themes-section .no-themes-local { + display: none; +} + +.themes-section-installed_themes .theme .notice-success:not(.updated-message) { + display: none; /* Hide "installed" notice on installed themes tab. */ +} + +.customize-control-theme .theme { + width: 100%; + margin: 0; + border: 1px solid #ddd; + background: #fff; +} + +.customize-control-theme .theme .theme-name, .customize-control-theme .theme .theme-actions { + background: #fff; + border: none; +} + +.customize-control.customize-control-theme { /* override most properties on .customize-control */ + box-sizing: border-box; + width: 25%; + max-width: 600px; /* Max. screenshot size / 2 */ + margin: 0 0 25px 25px; + padding: 0; + clear: none; +} + +/* 5 columns above 2100px */ +@media screen and (min-width: 2101px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 125px ) / 5 - 1px ); /* 1px offset accounts for browser rounding, typical all grids */ + } +} + +/* 4 columns up to 2100px */ +@media screen and (min-width: 1601px) and (max-width: 2100px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 100px ) / 4 - 1px ); + } +} + +/* 3 columns up to 1600px */ +@media screen and (min-width: 1201px) and (max-width: 1600px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 75px ) / 3 - 1px ); + } +} + +/* 2 columns up to 1200px */ +@media screen and (min-width: 851px) and (max-width: 1200px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 50px ) / 2 - 1px ); + + } +} + +/* 1 column up to 850 px */ +@media screen and (max-width: 850px) { + .customize-control.customize-control-theme { + width: 100%; + } +} + +.wp-customizer .theme-browser .themes { + padding: 0 25px 25px 0; + transition: .18s margin-top linear; +} + +.wp-customizer .theme-browser .theme .theme-actions { + opacity: 1; +} + +#customize-controls h3.theme-name { + font-size: 15px; +} + +#customize-controls .theme-overlay .theme-name { + font-size: 32px; +} + +.customize-preview-header.themes-filter-bar { + position: fixed; + top: 0; + right: 300px; + width: calc(100% - 300px); + height: 46px; + background: #eee; + z-index: 10; + padding: 6px 25px; + box-sizing: border-box; + border-bottom: 1px solid #ddd; +} + +@media screen and (min-width: 1670px) { + .customize-preview-header.themes-filter-bar { + width: 82%; + left: 0; + right: initial; + } +} + +.themes-filter-bar .themes-filter-container { + margin: 0; + padding: 0; +} + +.themes-filter-bar .wp-filter-search { + line-height: 25px; + padding: 6px 30px 6px 10px; + max-width: 100%; + width: 40%; + min-width: 300px; + position: absolute; + top: 6px; + right: 25px; + height: 32px; + margin: 1px 0; +} + +/* Unstick the filter bar on short windows/screens. This breakpoint is based on the + current length of .org feature filters assuming translations do not wrap lines. */ +@media screen and (max-height:540px), screen and (max-width:1018px) { + .customize-preview-header.themes-filter-bar { + position: relative; + right: 0; + width: 100%; + margin: 0 0 25px 0; + } + .filter-drawer { + top: 46px; + } + .wp-customizer .theme-browser .themes { + padding: 0 25px 25px 0; + overflow: hidden; + } + + .control-panel-themes .customize-themes-full-container { + margin-top: 0; + padding: 0; + height: 100%; + width: calc(100% - 300px); + } +} + +@media screen and (max-width:1018px) { + .filter-drawer .filter-group { + width: calc( (100% - 50px) / 2); + } +} + +@media screen and (max-width:900px) { + .customize-preview-header.themes-filter-bar { + height: 86px; + padding-top: 46px; + } + + .themes-filter-bar .wp-filter-search { + width: calc(100% - 50px); + margin: 0; + min-width: 200px; + } + + .filter-drawer { + top: 86px; + } + + .control-panel-themes .filter-themes-count { + float: right; + } +} + +@media screen and (max-width:792px) { + .filter-drawer .filter-group { + width: calc( 100% - 25px); + } +} + +.control-panel-themes .customize-themes-mobile-back { + display: none; +} + +/* Mobile - toggle between themes and filters */ +@media screen and (max-width:600px) { + + .filter-drawer { + top: 132px; + } + + .wp-full-overlay.showing-themes .control-panel-themes .filter-themes-count .filter-themes { + display: block; + float: left; + } + + .control-panel-themes .customize-themes-full-container { + width: 100%; + margin: 0; + padding-top: 46px; + height: calc(100% - 46px); + z-index: 1; + display: none; + } + + .showing-themes .control-panel-themes .customize-themes-full-container { + display: block; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back { + display: block; + position: fixed; + top: 0; + right: 0; + background: #eee; + color: #444; + border-radius: 0; + box-shadow: none; + border: none; + height: 46px; + width: 100%; + z-index: 10; + text-align: right; + text-shadow: none; + border-bottom: 1px solid #ddd; + border-right: 4px solid transparent; + margin: 0; + padding: 0; + font-size: 0; + overflow: hidden; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:before { + right: 0; + top: 0; + height: 46px; + width: 26px; + display: block; + line-height: 46px; + padding: 0 8px 0 8px; + border-left: 1px solid #ddd; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:hover, + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:focus { + color: #0073aa; + background: #f3f3f5; + border-right-color: #0073aa; + outline: none; + box-shadow: none; + } + + .showing-themes #customize-header-actions { + display: none; + } + + #customize-controls { + width: 100%; + } +} + +/* Details View */ +.wp-customizer .theme-overlay { + display: none; +} + +.wp-customizer.modal-open .theme-overlay { + position: fixed; + right: 0; + top: 0; + left: 0; + bottom: 0; + z-index: 109; +} + +/* Avoid a z-index war by resetting elements that should be under the overlay. + This is likely required because of the way that sections and panels are positioned. */ +.wp-customizer.modal-open #customize-header-actions, +.wp-customizer.modal-open .control-panel-themes .filter-themes-count, +.wp-customizer.modal-open .control-panel-themes .customize-themes-section-title.selected:after { + z-index: -1; +} + +.wp-full-overlay.in-themes-panel.themes-panel-expanded #customize-controls .wp-full-overlay-sidebar-content { + overflow: visible; +} + +.wp-customizer .theme-overlay .theme-backdrop { + background: rgba( 238, 238, 238, 0.75 ); + position: fixed; + z-index: 110; +} + +.wp-customizer .theme-overlay .star-rating { + float: right; + margin-left: 8px; +} + +.wp-customizer .theme-rating .num-ratings { + line-height: 20px; +} + +.wp-customizer .theme-overlay .theme-wrap { + right: 90px; + left: 90px; + top: 45px; + bottom: 45px; + z-index: 120; +} + +.wp-customizer .theme-overlay .theme-actions { + text-align: left; /* Because there're only one or two actions, match the UI pattern of media modals and right-align the action. */ + padding: 10px 25px; + background: #eee; + border-top: 1px solid #ddd; +} + +.wp-customizer .theme-overlay .theme-actions .theme-install.preview { + margin-right: 8px; +} + +.control-panel-themes .theme-actions .delete-theme { + right: 15px; /* these override themes.css on mobile */ + left: auto; + bottom: auto; + position: absolute; +} + +.modal-open .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content { + overflow: visible; /* Prevent the top-level Customizer controls from becoming visible when elements on the right of the details modal are focused. */ +} + +.wp-customizer .theme-header { + background: #eee; +} + +.wp-customizer .theme-overlay .theme-header button, +.wp-customizer .theme-overlay .theme-header .close:before { + color: #444; +} + +.wp-customizer .theme-overlay .theme-header .close:focus, +.wp-customizer .theme-overlay .theme-header .close:hover, +.wp-customizer .theme-overlay .theme-header .right:focus, +.wp-customizer .theme-overlay .theme-header .right:hover, +.wp-customizer .theme-overlay .theme-header .left:focus, +.wp-customizer .theme-overlay .theme-header .left:hover { + background: #fff; + border-bottom: 4px solid #0073aa; + color: #0073aa; +} + +.wp-customizer .theme-overlay .theme-header .close:focus:before, +.wp-customizer .theme-overlay .theme-header .close:hover:before { + color: #0073aa; +} + +.wp-customizer .theme-overlay .theme-header button.disabled, +.wp-customizer .theme-overlay .theme-header button.disabled:hover, +.wp-customizer .theme-overlay .theme-header button.disabled:focus { + border-bottom: none; + background: transparent; + color: #ccc; +} + +/* Small Screens */ +@media (max-width:850px), (max-height:472px) { + .wp-customizer .theme-overlay .theme-wrap { + right: 0; + left: 0; + top: 0; + bottom: 0; + } + + .wp-customizer .theme-browser .themes { + padding-left: 25px; + } +} + +/* Handle cheaters. */ +body.cheatin { + font-size: medium; + height: auto; + background: #fff; + margin: 50px auto 2em; + padding: 1em 2em; + max-width: 700px; + min-width: 0; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +body.cheatin h1 { + border-bottom: 1px solid #ddd; + clear: both; + color: #555d66; + font-size: 24px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + margin: 30px 0 0 0; + padding: 0; + padding-bottom: 7px; +} + +body.cheatin p { + font-size: 14px; + line-height: 1.5; + margin: 25px 0 20px; +} + +/** + * Widgets and Menus common styles + */ + +/* higher specificity than .wp-core-ui .button */ +#customize-theme-controls .add-new-widget, +#customize-theme-controls .add-new-menu-item { + cursor: pointer; + float: left; + margin: 0; + margin-right: 10px; + transition: all 0.2s; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + outline: none; +} + +.reordering .add-new-widget, +.reordering .add-new-menu-item { + opacity: 0.2; + pointer-events: none; + cursor: not-allowed; /* doesn't work in conjunction with pointer-events */ +} + +.add-new-widget:before, +.add-new-menu-item:before, +#available-menu-items .new-content-item .add-content:before { + content: "\f132"; + display: inline-block; + position: relative; + right: -2px; + top: 0; + font: normal 20px/1 dashicons; + vertical-align: middle; + transition: all 0.2s; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* Reordering */ +.reorder-toggle { + float: left; + padding: 5px 8px; + text-decoration: none; + cursor: pointer; + outline: none; +} + +.reorder, +.reordering .reorder-done { + display: block; + padding: 5px 8px; +} + +.reorder-done, +.reordering .reorder { + display: none; +} + +.widget-reorder-nav span, +.menu-item-reorder-nav button { + position: relative; + overflow: hidden; + float: right; + display: block; + width: 33px; /* was 42px for mobile */ + height: 43px; + color: #82878c; + text-indent: -9999px; + cursor: pointer; + outline: none; +} + +.menu-item-reorder-nav button { + width: 30px; + height: 40px; + background: transparent; + border: none; + box-shadow: none; +} + +.widget-reorder-nav span:before, +.menu-item-reorder-nav button:before { + display: inline-block; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + font: normal 20px/43px dashicons; + text-align: center; + text-indent: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.widget-reorder-nav span:hover, +.widget-reorder-nav span:focus, +.menu-item-reorder-nav button:hover, +.menu-item-reorder-nav button:focus { + color: #191e23; + background: #eee; +} + +.move-widget-down:before, +.menus-move-down:before { + content: "\f347"; +} + +.move-widget-up:before, +.menus-move-up:before { + content: "\f343"; +} + +#customize-theme-controls .first-widget .move-widget-up, +#customize-theme-controls .last-widget .move-widget-down, +.move-up-disabled .menus-move-up, +.move-down-disabled .menus-move-down, +.move-right-disabled .menus-move-right, +.move-left-disabled .menus-move-left { + color: #d5d5d5; + background-color: #fff; + cursor: default; + pointer-events: none; +} + +/** + * New widget and Add-menu-items modes and panels + */ + +.wp-full-overlay-main { + left: auto; /* this overrides a right: 0; which causes the preview to resize, I'd rather have it go off screen at the normal size. */ + width: 100%; +} + +body.adding-widget .add-new-widget, +body.adding-widget .add-new-widget:hover, +.adding-menu-items .add-new-menu-item, +.adding-menu-items .add-new-menu-item:hover, +.add-menu-toggle.open, +.add-menu-toggle.open:hover { + background: #eee; + border-color: #929793; + color: #32373c; + box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); +} + +body.adding-widget .add-new-widget:before, +.adding-menu-items .add-new-menu-item:before, +#accordion-section-add_menu .add-new-menu-item.open:before { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); +} + +#available-widgets, +#available-menu-items { + position: absolute; + top: 0; + bottom: 0; + right: -301px; + visibility: hidden; + overflow-x: hidden; + overflow-y: auto; + width: 300px; + margin: 0; + z-index: 4; + background: #eee; + transition: right .18s; + border-left: 1px solid #ddd; +} + +#available-widgets .customize-section-title, +#available-menu-items .customize-section-title { + display: none; +} + +#available-widgets-list { + top: 60px; + position: absolute; + overflow: auto; + bottom: 0; + width: 100%; + border-top: 1px solid #ddd; +} + +.no-widgets-found #available-widgets-list { + border-top: none; +} + +#available-widgets-filter { + position: fixed; + top: 0; + z-index: 1; + width: 300px; + background: #eee; +} + +/* search field container */ +#available-widgets-filter, +#available-menu-items-search .accordion-section-title { + padding: 13px 15px; + box-sizing: border-box; +} + +#available-widgets-filter input, +#available-menu-items-search input { + width: 100%; + height: 32px; + margin: 1px 0; + padding: 6px 30px; +} + +#available-widgets-filter input::-ms-clear, +#available-menu-items-search input::-ms-clear { + display: none; /* remove the "x" in IE, which conflicts with the "x" icon on button.clear-results */ +} + +#available-menu-items-search .search-icon, +#available-widgets-filter .search-icon { + display: block; + position: absolute; + top: 15px; /* 13 container padding +1 input margin +1 input border */ + right: 16px; + width: 30px; + height: 30px; + line-height: 28px; + text-align: center; + color: #72777c; +} + +#available-widgets-filter .clear-results, +#available-menu-items-search .clear-results { + position: absolute; + top: 15px; /* 13 container padding +1 input margin +1 input border */ + left: 16px; + width: 30px; + height: 30px; + padding: 0; + border: 0; + cursor: pointer; + background: none; + color: #a00; + text-decoration: none; + outline: 0; +} + +#available-widgets-filter .clear-results, +#available-menu-items-search .clear-results, +#available-menu-items-search.loading .clear-results.is-visible { + display: none; +} + +#available-widgets-filter .clear-results.is-visible, +#available-menu-items-search .clear-results.is-visible { + display: block; +} + +#available-widgets-filter .clear-results:before, +#available-menu-items-search .clear-results:before { + content: "\f335"; + font: normal 20px/1 dashicons; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#available-widgets-filter .clear-results:hover, +#available-widgets-filter .clear-results:focus, +#available-menu-items-search .clear-results:hover, +#available-menu-items-search .clear-results:focus { + color: #dc3232; +} + +#available-widgets-filter .clear-results:focus, +#available-menu-items-search .clear-results:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#available-menu-items-search .search-icon:after, +#available-widgets-filter .search-icon:after, +.themes-filter-bar .search-icon:after { + content: "\f179"; + font: normal 20px/1 dashicons; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.themes-filter-bar .search-icon { + position: absolute; + top: 7px; + right: 26px; + z-index: 1; + color: #72777c; + height: 30px; + width: 30px; + line-height: 2; + text-align: center; +} + +.no-widgets-found-message { + display: none; + margin: 0; + padding: 0 15px; + line-height: inherit; +} + +.no-widgets-found .no-widgets-found-message { + display: block; +} + +#available-widgets .widget-top, +#available-widgets .widget-top:hover, +#available-menu-items .item-top, +#available-menu-items .item-top:hover { + border: none; + background: transparent; + box-shadow: none; +} + +#available-widgets .widget-tpl, +#available-menu-items .item-tpl { + position: relative; + padding: 15px 60px 15px 15px; + background: #fff; + border-bottom: 1px solid #ddd; + border-right: 4px solid #fff; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; + cursor: pointer; + display: none; +} + +#available-widgets .widget, +#available-menu-items .item { + position: static; +} + + +/* Responsive */ +.customize-controls-preview-toggle { + display: none; +} + +@media only screen and (max-width: 782px) { + .wp-customizer .theme:not(.active):hover .theme-actions, + .wp-customizer .theme:not(.active):focus .theme-actions { + display: block; + } + + .wp-customizer .theme-browser .theme.active .theme-name span { + display: inline; + } + + .customize-control-header button.random .dice { + margin-top: 0; + } + + .customize-control-radio .customize-inside-control-row, + .customize-control-checkbox .customize-inside-control-row, + .customize-control-nav_menu_auto_add .customize-inside-control-row { + margin-right: 32px; + } + + .customize-control-radio input, + .customize-control-checkbox input, + .customize-control-nav_menu_auto_add input { + margin-right: -32px; + } + + .customize-control input[type="radio"] + label + br, + .customize-control input[type="checkbox"] + label + br { + line-height: 32px; /* For widgets checkboxes */ + } + + .customize-control .date-time-fields select { + height: 39px; + } + + .date-time-fields .date-input.month { + width: 79px; + } + + .date-time-fields .date-input.day, + .date-time-fields .date-input.hour, + .date-time-fields .date-input.minute { + width: 55px; + } + + .date-time-fields .date-input.year { + width: 80px; + } + + .date-time-fields .date-timezone { + line-height: 3.2; + } + + #customize-control-changeset_preview_link a { + bottom: 16px; + } + + .preview-link-wrapper .customize-copy-preview-link.preview-control-element.button { + bottom: 10px; + } + + .media-widget-control .media-widget-buttons .button.edit-media, + .media-widget-control .media-widget-buttons .button.change-media, + .media-widget-control .media-widget-buttons .button.select-media { + margin-top: 12px; + } + + .wp-core-ui .themes-filter-bar .feature-filter-toggle { + margin: 3px 25px 3px 0; + } +} + +@media screen and ( max-width: 1200px ) { + .outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, + .adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, + .adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main { + right: 67%; + } +} + +@media screen and ( max-width: 640px ) { + + /* when the sidebar is collapsed and switching to responsive view, + bring it back see ticket #35220 */ + .wp-full-overlay.collapsed #customize-controls { + margin-right: 0; + } + + .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content { + bottom: 0; + } + + .customize-controls-preview-toggle { + display: block; + position: absolute; + top: 0; + right: 48px; + line-height: 45px; + font-size: 14px; + padding: 0 12px; + margin: 0; + height: 45px; + background: #eee; + border: 0; + border-left: 1px solid #ddd; + color: #555d66; + cursor: pointer; + transition: color .1s ease-in-out, background .1s ease-in-out; + } + + #customize-footer-actions, + /*#customize-preview,*/ + .customize-controls-preview-toggle .controls, + .preview-only .wp-full-overlay-sidebar-content, + .preview-only .customize-controls-preview-toggle .preview { + display: none; + } + + .preview-only #customize-save-button-wrapper { + margin-top: -46px; + } + + .customize-controls-preview-toggle .preview:before, + .customize-controls-preview-toggle .controls:before { + font: normal 20px/1 dashicons; + content: "\f177"; + position: relative; + top: 4px; + margin-left: 6px; + } + + .customize-controls-preview-toggle .controls:before { + content: "\f540"; + } + + .preview-only #customize-controls { + height: 45px; + } + + .preview-only #customize-preview, + .preview-only .customize-controls-preview-toggle .controls { + display: block; + } + + .wp-core-ui.wp-customizer .button { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + } + + #publish-settings { + height: 31px; + } + + #customize-control-changeset_status .customize-inside-control-row { + padding-top: 15px; + } + + body.adding-widget div#available-widgets, + body.adding-menu-items div#available-menu-items, + body.outer-section-open div#customize-sidebar-outer-content { + width: 100%; + } + + #available-widgets .customize-section-title, + #available-menu-items .customize-section-title { + display: block; + margin: 0; + } + + #available-widgets .customize-section-back, + #available-menu-items .customize-section-back { + height: 69px; + } + + #available-widgets .customize-section-title h3, + #available-menu-items .customize-section-title h3 { + font-size: 20px; + font-weight: 200; + padding: 9px 14px 12px 10px; + margin: 0; + line-height: 24px; + color: #555d66; + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + #available-widgets .customize-section-title .customize-action, + #available-menu-items .customize-section-title .customize-action { + font-size: 13px; + display: block; + font-weight: 400; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + #available-widgets-filter { + position: relative; + width: 100%; + height: auto; + } + + #available-widgets-list { + top: 130px; + } + + #available-menu-items-search .clear-results, + #available-menu-items-search .search-icon { + top: 85px; /* 70 section title height + 13 container padding +1 input margin +1 input border */ + } + + .reorder, + .reordering .reorder-done { + padding: 8px; + } + + .wp-core-ui .themes-filter-bar .feature-filter-toggle { + margin: 0; + } + + .theme-browser .theme.active .theme-actions, + .wp-customizer .theme-browser .theme .theme-actions { + padding: 9px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); + } +} + +@media screen and ( max-width: 600px ) { + .theme-browser .theme.active .theme-actions, + .wp-customizer .theme-browser .theme .theme-actions { + padding: 8px 15px; + box-shadow: none; + } + + .wp-full-overlay.expanded { + margin-right: 0; + } + + body.adding-widget div#available-widgets, + body.adding-menu-items div#available-menu-items, + body.outer-section-open div#customize-sidebar-outer-content { + top: 46px; + z-index: 10; + } + + body.wp-customizer .wp-full-overlay.expanded #customize-sidebar-outer-content { + right: -100%; + } + + body.wp-customizer.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content { + right: 0; + } +} diff --git a/backend/wp-admin/css/customize-controls-rtl.min.css b/backend/wp-admin/css/customize-controls-rtl.min.css new file mode 100644 index 0000000..786043a --- /dev/null +++ b/backend/wp-admin/css/customize-controls-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#customize-controls .wp-full-overlay-sidebar-content,#customize-sidebar-outer-content{overflow-x:hidden;overflow-y:auto}.customize-control-checkbox label,.customize-control-radio label,.customize-control-site_icon .favicon-preview .browser-preview{vertical-align:top}body{overflow:hidden;-webkit-text-size-adjust:100%}.customize-controls-close,.widget-control-actions a{text-decoration:none}#customize-controls h3{font-size:14px}#customize-controls img{max-width:100%}#customize-controls .submit{text-align:center}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked{background-color:rgba(0,0,0,.7);padding:25px}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .customize-changeset-locked-message{margin-right:auto;margin-left:auto;max-width:366px;min-height:64px;width:auto;padding:25px 109px 25px 25px;position:relative;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);line-height:1.5;overflow-y:auto;text-align:right;top:calc(50% - 100px)}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .currently-editing{margin-top:0}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .action-buttons{margin-bottom:0}.customize-changeset-locked-avatar{width:64px;position:absolute;right:25px;top:25px}.wp-core-ui.wp-customizer .customize-changeset-locked-message a.button{margin-left:10px;margin-top:0}#customize-controls .description{color:#555d66}#customize-save-button-wrapper{float:left;margin-top:9px}body:not(.ready) #customize-save-button-wrapper .save{visibility:hidden}#customize-save-button-wrapper .save{float:right;border-radius:3px;box-shadow:none;margin-top:0}#customize-save-button-wrapper .save:focus,#publish-settings:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}#customize-save-button-wrapper .save.has-next-sibling{border-radius:0 3px 3px 0}#customize-sidebar-outer-content{position:absolute;top:0;bottom:0;right:0;visibility:hidden;width:100%;margin:0;z-index:-1;background:#eee;transition:right .18s;border-left:1px solid #ddd;border-right:1px solid #ddd;height:100%}#customize-theme-controls .control-section-outer{display:none!important}#customize-outer-theme-controls .accordion-section-content{padding:12px}#customize-outer-theme-controls .accordion-section-content.open{display:block}.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content{visibility:visible;right:100%;transition:right .18s}.customize-outer-pane-parent{margin:0}.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main{right:300px;opacity:.4}.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-menu-items .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main{right:64%}#customize-outer-theme-controls li.notice{padding-top:8px;padding-bottom:8px;margin-right:0;margin-bottom:10px}#publish-settings{text-indent:0;border-radius:3px 0 0 3px;padding-right:0;padding-left:0;box-shadow:none;font-size:14px;width:30px;float:right;-webkit-transform:none;transform:none;margin-top:0}body.trashing #customize-save-button-wrapper .save,body.trashing #publish-settings,body:not(.ready) #publish-settings{display:none}#customize-header-actions .spinner{margin-top:13px;margin-left:4px}.saving #customize-header-actions .spinner,.trashing #customize-header-actions .spinner{visibility:visible}#customize-header-actions{border-bottom:1px solid #ddd}.outer-section-open #customize-controls .wp-full-overlay-sidebar-content{background:#eee}#customize-controls .customize-info{border:none;border-bottom:1px solid #ddd;margin-bottom:15px}#customize-control-changeset_preview_link input,#customize-control-changeset_status .customize-inside-control-row{background-color:#fff;border-bottom:1px solid #ddd;box-sizing:content-box;width:100%;margin-right:-12px;padding-right:12px;padding-left:12px}#customize-control-trash_changeset{margin-top:20px}#customize-control-trash_changeset .button-link{position:relative;padding-right:24px;display:inline-block}#customize-control-trash_changeset .button-link:before{content:"\f182";font:400 22px dashicons;text-decoration:none;position:absolute;right:0;top:-2px}#customize-controls .date-input:invalid{border-color:#dc3232}#customize-control-changeset_status .customize-inside-control-row{padding-top:10px;padding-bottom:10px;font-weight:500}#customize-control-changeset_status .customize-inside-control-row:first-of-type{border-top:1px solid #ddd}#customize-control-changeset_status .customize-control-title{margin-bottom:6px}#customize-control-changeset_status input{margin-right:0}#customize-control-changeset_preview_link{position:relative;display:block}.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button{margin:0;position:absolute;bottom:9px;left:0}.preview-link-wrapper{position:relative}.customize-copy-preview-link:after,.customize-copy-preview-link:before{content:"";height:28px;position:absolute;background:#fff;top:-1px}.customize-copy-preview-link:before{right:-10px;width:9px;opacity:.75}.customize-copy-preview-link:after{right:-5px;width:4px;opacity:.8}#customize-control-changeset_preview_link input{line-height:2.5;border-top:1px solid #ddd;border-right:none;border-left:none;text-indent:-999px;color:#fff}#customize-control-changeset_preview_link label{position:relative;display:block}#customize-control-changeset_preview_link a{display:inline-block;position:absolute;white-space:nowrap;overflow:hidden;width:90%;bottom:14px;font-size:14px;text-decoration:none}#customize-control-changeset_preview_link a.disabled,#customize-control-changeset_preview_link a.disabled:active,#customize-control-changeset_preview_link a.disabled:focus,#customize-control-changeset_preview_link a.disabled:visited{color:#000;opacity:.4;cursor:default;outline:0;box-shadow:none}#sub-accordion-section-publish_settings .customize-section-description-container{display:none}#customize-controls .customize-info.section-meta{margin-bottom:15px}.customize-control-date_time .customize-control-description+.date-time-fields.includes-time{margin-top:10px}.customize-control.customize-control-date_time .date-time-fields .date-input.day{margin-left:0}.date-time-fields .date-input.month{width:auto;margin:0}.date-time-fields .date-input.day,.date-time-fields .date-input.hour,.date-time-fields .date-input.minute{width:46px}.date-time-fields .date-input.year{width:60px}.date-time-fields .date-input.meridian{width:auto;margin:0}.date-time-fields .time-row{margin-top:12px}.date-time-fields .date-timezone{line-height:2.2;text-decoration:none}#customize-control-changeset_preview_link{margin-top:6px}#customize-control-changeset_status{margin-bottom:0;padding-bottom:0}#customize-control-changeset_scheduled_date{box-sizing:content-box;width:100%;margin-right:-12px;padding:12px;background:#fff;border-bottom:1px solid #ddd;margin-bottom:0}#customize-control-changeset_scheduled_date .customize-control-description{font-style:normal}#customize-controls .customize-info.is-in-view,#customize-controls .customize-section-title.is-in-view{position:absolute;z-index:9;width:100%;box-shadow:0 1px 0 rgba(0,0,0,.1)}#customize-controls .customize-section-title.is-in-view{margin-top:0}#customize-controls .customize-info.is-in-view+.accordion-section{margin-top:15px}#customize-controls .customize-info .customize-panel-description p:first-child,#customize-controls .customize-info .customize-section-description p:first-child,.no-widget-areas-rendered-notice p:first-child{margin-top:0}#customize-controls .customize-info.is-sticky,#customize-controls .customize-section-title.is-sticky{position:fixed;top:46px}#customize-controls .customize-info .accordion-section-title{background:#fff;color:#555d66;border-right:none;border-left:none;border-bottom:none;cursor:default}#customize-controls .customize-info .accordion-section-title:focus:after,#customize-controls .customize-info .accordion-section-title:hover:after,#customize-controls .customize-info.open .accordion-section-title:after{color:#32373c}#customize-controls .customize-info .accordion-section-title:after{display:none}#customize-controls .customize-info .preview-notice{font-size:13px;line-height:24px}#customize-controls .customize-info .panel-title,#customize-controls .customize-pane-child .customize-section-title h3,#customize-controls .customize-pane-child h3.customize-section-title,#customize-outer-theme-controls .customize-pane-child .customize-section-title h3,#customize-outer-theme-controls .customize-pane-child h3.customize-section-title{font-size:20px;font-weight:200;line-height:26px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .customize-section-title span.customize-action{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .customize-info .customize-help-toggle{position:absolute;top:4px;left:1px;padding:20px 10px 10px 20px;width:20px;height:20px;cursor:pointer;box-shadow:none;-webkit-appearance:none;background:0 0;color:#555d66;border:none}#customize-controls .customize-info .customize-help-toggle:before{position:absolute;top:5px;right:6px}#customize-controls .customize-info .customize-help-toggle:focus,#customize-controls .customize-info .customize-help-toggle:hover,#customize-controls .customize-info.open .customize-help-toggle{color:#0073aa}#customize-controls .customize-info .customize-panel-description,#customize-controls .customize-info .customize-section-description,#customize-controls .no-widget-areas-rendered-notice,#customize-outer-theme-controls .customize-info .customize-section-description{color:#555d66;display:none;background:#fff;padding:12px 15px;border-top:1px solid #ddd}#customize-controls .customize-info .customize-panel-description.open+.no-widget-areas-rendered-notice{border-top:none}.no-widget-areas-rendered-notice{font-style:italic}.no-widget-areas-rendered-notice p:last-child{margin-bottom:0}#customize-controls .customize-info .customize-section-description{margin-bottom:15px}#customize-controls .customize-info .customize-panel-description p:last-child,#customize-controls .customize-info .customize-section-description p:last-child{margin-bottom:0}#customize-controls .current-panel .control-section>h3.accordion-section-title{padding-left:30px}#customize-outer-theme-controls .control-section,#customize-theme-controls .control-section{border:none}#customize-outer-theme-controls .accordion-section-title,#customize-theme-controls .accordion-section-title{color:#555d66;background-color:#fff;border-bottom:1px solid #ddd;border-right:4px solid #fff;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out}#customize-controls #customize-theme-controls .customize-themes-panel .accordion-section-title{color:#555;background-color:#fff;border-right:4px solid #fff}#customize-outer-theme-controls .accordion-section-title:after,#customize-theme-controls .accordion-section-title:after{content:"\f341";color:#a0a5aa}#customize-outer-theme-controls .accordion-section-content,#customize-theme-controls .accordion-section-content{color:#555d66;background:0 0}#customize-controls .control-section .accordion-section-title:focus,#customize-controls .control-section .accordion-section-title:hover,#customize-controls .control-section.open .accordion-section-title,#customize-controls .control-section:hover>.accordion-section-title{color:#0073aa;background:#f3f3f5;border-right-color:#0073aa}#accordion-section-themes+.control-section{border-top:1px solid #ddd}.js .control-section .accordion-section-title:focus,.js .control-section .accordion-section-title:hover,.js .control-section.open .accordion-section-title,.js .control-section:hover .accordion-section-title{background:#f3f3f5}#customize-outer-theme-controls .control-section .accordion-section-title:focus:after,#customize-outer-theme-controls .control-section .accordion-section-title:hover:after,#customize-outer-theme-controls .control-section.open .accordion-section-title:after,#customize-outer-theme-controls .control-section:hover>.accordion-section-title:after,#customize-theme-controls .control-section .accordion-section-title:focus:after,#customize-theme-controls .control-section .accordion-section-title:hover:after,#customize-theme-controls .control-section.open .accordion-section-title:after,#customize-theme-controls .control-section:hover>.accordion-section-title:after{color:#0073aa}#customize-theme-controls .control-section.open{border-bottom:1px solid #eee}#customize-outer-theme-controls .control-section.open .accordion-section-title,#customize-theme-controls .control-section.open .accordion-section-title{border-bottom-color:#eee!important}#customize-theme-controls .control-section:last-of-type.open,#customize-theme-controls .control-section:last-of-type>.accordion-section-title{border-bottom-color:#ddd}#customize-theme-controls .control-panel-content:not(.control-panel-nav_menus) .control-section:nth-child(2),#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu,#customize-theme-controls .control-section-nav_menu_locations .accordion-section-title{border-top:1px solid #ddd}#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu+.control-section-nav_menu{border-top:none}#customize-theme-controls>ul{margin:0}#customize-theme-controls .accordion-section-content{position:absolute;top:0;right:100%;width:100%;margin:0;padding:12px;box-sizing:border-box}#customize-info,#customize-theme-controls .customize-pane-child,#customize-theme-controls .customize-pane-parent{width:100%;margin:0;padding:0;box-sizing:border-box;transition:.18s -webkit-transform cubic-bezier(.645,.045,.355,1);transition:.18s transform cubic-bezier(.645,.045,.355,1);transition:.18s transform cubic-bezier(.645,.045,.355,1),.18s -webkit-transform cubic-bezier(.645,.045,.355,1)}#customize-theme-controls .customize-pane-child.skip-transition{transition:none}#customize-info,#customize-theme-controls .customize-pane-parent{position:relative;visibility:visible;height:auto;max-height:none;overflow:auto;-webkit-transform:none;transform:none}#customize-theme-controls .customize-pane-child{position:absolute;top:0;right:0;visibility:hidden;height:0;max-height:none;overflow:hidden;-webkit-transform:translateX(-100%);transform:translateX(-100%)}#customize-theme-controls .customize-pane-child.current-panel,#customize-theme-controls .customize-pane-child.open{-webkit-transform:none;transform:none}.in-sub-panel #customize-info,.in-sub-panel #customize-theme-controls .customize-pane-parent,.in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel,.section-open #customize-info,.section-open #customize-theme-controls .customize-pane-parent{visibility:hidden;height:0;overflow:hidden;-webkit-transform:translateX(100%);transform:translateX(100%)}#customize-theme-controls .customize-pane-child.busy,#customize-theme-controls .customize-pane-child.current-panel,#customize-theme-controls .customize-pane-child.open,.busy.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel,.in-sub-panel #customize-info.busy,.in-sub-panel #customize-theme-controls .customize-pane-parent.busy,.section-open #customize-info.busy,.section-open #customize-theme-controls .customize-pane-parent.busy{visibility:visible;height:auto;overflow:auto}#customize-theme-controls .customize-pane-child.accordion-section-content,#customize-theme-controls .customize-pane-child.accordion-sub-container{display:block;overflow-x:hidden}#customize-theme-controls .customize-pane-child.accordion-section-content{padding:12px}#customize-theme-controls .customize-pane-child.menu li{position:static}.control-section-nav_menu .customize-section-description-container,.control-section-new_menu .customize-section-description-container,.customize-section-description-container{margin-bottom:15px}.control-section-nav_menu .customize-control,.control-section-new_menu .customize-control{margin-bottom:0}.customize-section-title{margin:-12px -12px 0;border-bottom:1px solid #ddd;background:#fff}div.customize-section-description{margin-top:22px}.customize-info div.customize-section-description,div.customize-section-description p:first-child{margin-top:0}div.customize-section-description p:last-child{margin-bottom:0}#customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child{border-bottom:1px solid #ddd;padding:12px}.ios #customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child{padding:12px 12px 13px}.customize-section-title h3,h3.customize-section-title{padding:10px 14px 12px 10px;margin:0;line-height:21px;color:#555d66}.accordion-sub-container.control-panel-content{display:none;position:absolute;top:0;width:100%}.accordion-sub-container.control-panel-content.busy{display:block}.current-panel .accordion-sub-container.control-panel-content{width:100%}.customize-controls-close{display:block;position:absolute;top:0;right:0;width:45px;height:41px;padding:0 0 0 2px;background:#eee;border:none;border-top:4px solid #eee;border-left:1px solid #ddd;color:#444;text-align:right;cursor:pointer;transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;box-sizing:content-box}.customize-panel-back,.customize-section-back{display:block;float:right;width:48px;height:71px;padding:0 0 0 24px;margin:0;background:#fff;border:none;border-left:1px solid #ddd;border-right:4px solid #fff;box-shadow:none;cursor:pointer;transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out}.customize-section-back{height:74px}.ios .customize-panel-back{display:none}.ios .expanded.in-sub-panel .customize-panel-back{display:block}#customize-controls .panel-meta.customize-info .accordion-section-title{margin-right:48px;border-right:none}#customize-controls .cannot-expand:hover .accordion-section-title,#customize-controls .panel-meta.customize-info .accordion-section-title:hover{background:#fff;color:#555d66;border-right-color:#fff}.customize-controls-close:focus,.customize-controls-close:hover,.customize-controls-preview-toggle:focus,.customize-controls-preview-toggle:hover{background:#fff;color:#0073aa;border-top-color:#0073aa;outline:0;box-shadow:none}.customize-panel-back:focus,.customize-panel-back:hover,.customize-section-back:focus,.customize-section-back:hover{color:#0073aa;background:#f3f3f5;border-right-color:#0073aa;outline:0;box-shadow:none}.customize-controls-close:before{font:400 22px/45px dashicons;content:"\f335";position:relative;top:-3px;right:13px}.customize-panel-back:before,.customize-section-back:before{font:400 20px/72px dashicons;content:"\f345";position:relative;right:9px}.wp-full-overlay-sidebar .wp-full-overlay-header{background-color:#eee;transition:padding ease-in-out .18s}.in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header{padding-right:62px}p.customize-section-description{font-style:normal;margin-top:22px;margin-bottom:0}.customize-section-description ul{margin-right:1em}.customize-section-description ul>li{list-style:disc}.section-description-buttons{text-align:left}.section-description-buttons button.button-link{color:#0073aa;text-decoration:underline}.customize-control{width:100%;float:right;clear:both;margin-bottom:12px}.customize-control input[type=radio],.customize-control input[type=checkbox],.customize-control select{line-height:28px}.customize-control input[type=number],.customize-control input[type=search],.customize-control input[type=tel],.customize-control input[type=url],.customize-control input[type=text],.customize-control input[type=password],.customize-control input[type=email]{width:100%;line-height:18px;margin:0}.customize-control-hidden{margin:0}.customize-control-textarea textarea{width:100%;resize:vertical}.customize-control select{width:100%;height:28px;line-height:28px}.customize-control select[multiple]{height:auto}.customize-control-title{display:block;font-size:14px;line-height:24px;font-weight:600;margin-bottom:4px}.customize-control-description{display:block;font-style:italic;line-height:18px;margin-top:0;margin-bottom:5px}.customize-section-description a.external-link:after{font:16px/11px dashicons;content:"\f310";top:3px;position:relative;padding-right:3px;display:inline-block;text-decoration:none}.customize-control-color .color-picker,.customize-control-upload div{line-height:28px}.customize-control .customize-inside-control-row{line-height:20px;display:block;margin-right:24px;padding-top:6px;padding-bottom:6px}.customize-control-checkbox input,.customize-control-nav_menu_auto_add input,.customize-control-radio input{margin-left:4px;margin-right:-24px}.customize-control-radio{padding:5px 0 10px}.customize-control-radio .customize-control-title{margin-bottom:0;line-height:22px}.customize-control-radio .customize-control-title+.customize-control-description{margin-top:7px}.customize-control .attachment-thumb.type-icon{float:right;margin:10px;width:auto}.customize-control .attachment-title{font-weight:600;margin:0;padding:5px 10px}.customize-control .attachment-meta{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0;padding:0 10px}.customize-control .attachment-meta-title{padding-top:7px}.customize-control .thumbnail-image,.customize-control .wp-media-wrapper.wp-video,.customize-control-header .current{line-height:0}.customize-control .thumbnail-image img{cursor:pointer}#customize-controls .thumbnail-audio .thumbnail{max-width:64px;max-height:64px;margin:10px;float:right}#available-menu-items .accordion-section-content .new-content-item,.customize-control-dropdown-pages .new-content-item{width:calc(100% - 30px);padding:8px 15px;position:absolute;bottom:0;z-index:10;background:#eee;display:-webkit-box;display:flex}.customize-control-dropdown-pages .new-content-item{width:100%;padding:5px 1px 5px 0;position:relative}#available-menu-items .new-content-item .create-item-input,.customize-control-dropdown-pages .new-content-item .create-item-input{-webkit-box-flex:10;flex-grow:10}#available-menu-items .new-content-item .add-content,.customize-control-dropdown-pages .new-content-item .add-content{margin:2px 6px 2px 0;-webkit-box-flex:10;flex-grow:1}.customize-control-dropdown-pages .new-content-item .create-item-input.invalid{border:1px solid #dc3232}.customize-control-dropdown-pages .add-new-toggle{margin-right:1px;font-weight:600;line-height:28px}#customize-preview iframe{width:100%;height:100%;position:absolute}#customize-preview iframe+iframe{visibility:hidden}.wp-full-overlay-sidebar{background:#eee;border-left:1px solid #ddd}#customize-controls .customize-control-notifications-container{margin:4px 0 8px;padding:0;cursor:default}#customize-controls .customize-control-widget_form.has-error .widget .widget-top,.customize-control-nav_menu_item.has-error .menu-item-bar .menu-item-handle{box-shadow:inset 0 0 0 2px #dc3232;transition:.15s box-shadow linear}#customize-controls .customize-control-notifications-container li.notice{list-style:none;margin:0 0 6px;padding:9px 14px;overflow:hidden}#customize-controls .customize-control-notifications-container .notice.is-dismissible{padding-left:38px}.customize-control-notifications-container li.notice:last-child{margin-bottom:0}#customize-controls .customize-control-nav_menu_item .customize-control-notifications-container{margin-top:0}#customize-controls .customize-control-widget_form .customize-control-notifications-container{margin-top:8px}.customize-control-text.has-error input{outline:#dc3232 solid 2px}#customize-controls #customize-notifications-area{position:absolute;top:46px;width:100%;border-bottom:1px solid #ddd;display:block;padding:0;margin:0}.wp-full-overlay.collapsed #customize-controls #customize-notifications-area{display:none!important}#customize-controls #customize-notifications-area:not(.has-overlay-notifications),#customize-controls .customize-section-title>.customize-control-notifications-container:not(.has-overlay-notifications),#customize-controls .panel-meta>.customize-control-notifications-container:not(.has-overlay-notifications){max-height:210px;overflow-x:hidden;overflow-y:auto}#customize-controls #customize-notifications-area .notice,#customize-controls #customize-notifications-area>ul,#customize-controls .customize-section-title>.customize-control-notifications-container,#customize-controls .customize-section-title>.customize-control-notifications-container .notice,#customize-controls .panel-meta>.customize-control-notifications-container,#customize-controls .panel-meta>.customize-control-notifications-container .notice{margin:0}#customize-controls .customize-section-title>.customize-control-notifications-container,#customize-controls .panel-meta>.customize-control-notifications-container{border-top:1px solid #ddd}#customize-controls #customize-notifications-area .notice,#customize-controls .customize-section-title>.customize-control-notifications-container .notice,#customize-controls .panel-meta>.customize-control-notifications-container .notice{padding:9px 14px}#customize-controls #customize-notifications-area .notice.is-dismissible,#customize-controls .customize-section-title>.customize-control-notifications-container .notice.is-dismissible,#customize-controls .panel-meta>.customize-control-notifications-container .notice.is-dismissible{padding-left:38px}#customize-controls #customize-notifications-area .notice+.notice,#customize-controls .customize-section-title>.customize-control-notifications-container .notice+.notice,#customize-controls .panel-meta>.customize-control-notifications-container .notice+.notice{margin-top:1px}@-webkit-keyframes customize-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes customize-fade-in{0%{opacity:0}100%{opacity:1}}#customize-controls #customize-notifications-area .notice.notification-overlay,#customize-controls .notice.notification-overlay{margin:0;border-right:0}#customize-controls .customize-control-notifications-container.has-overlay-notifications{-webkit-animation:customize-fade-in .5s;animation:customize-fade-in .5s;z-index:30}#customize-controls #customize-notifications-area .notice.notification-overlay .notification-message{clear:both;color:#191e23;font-size:18px;font-style:normal;margin:0;padding:2em 0;text-align:center;width:100%;display:block;top:50%;position:relative}#customize-control-show_on_front.has-error .customize-control-notifications-container,.customize-control .actions .button{margin-top:12px}#customize-control-show_on_front.has-error{margin-bottom:0}.accordion-section .dropdown{float:right;display:block;position:relative;cursor:pointer}.accordion-section .dropdown-content{overflow:hidden;float:right;min-width:30px;height:16px;line-height:16px;margin-left:16px;padding:4px 5px;border:2px solid #eee;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.customize-control .dropdown-arrow{position:absolute;top:0;bottom:0;left:0;width:20px;background:#eee}.customize-control .dropdown-arrow:after{content:"\f140";font:400 20px/1 dashicons;speak:none;display:block;padding:0;text-indent:0;text-align:center;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#32373c}.customize-control .dropdown-status{color:#32373c;background:#eee;display:none;max-width:112px}.customize-control-color .dropdown{margin-left:5px;margin-bottom:5px}.customize-control-color .dropdown .dropdown-content{background-color:#555d66;border:1px solid rgba(0,0,0,.15)}.customize-control-color .dropdown:hover .dropdown-content{border-color:rgba(0,0,0,.25)}.ios .wp-full-overlay{position:relative}.ios #customize-controls .wp-full-overlay-sidebar-content{-webkit-overflow-scrolling:touch}.customize-control-header .actions,.customize-control-header .uploaded{margin-bottom:18px}.customize-control-header .default button:not(.random),.customize-control-header .uploaded button:not(.random){width:100%;padding:0;margin:0;background:0 0;border:none;color:inherit;cursor:pointer}.customize-control-header button img{display:block}.customize-control .attachment-media-view .default-button,.customize-control .attachment-media-view .remove-button,.customize-control .attachment-media-view .upload-button,.customize-control-header button.new,.customize-control-header button.remove{width:auto;height:auto;white-space:normal}.customize-control .attachment-media-view .thumbnail,.customize-control-header .current .container{overflow:hidden}.customize-control .attachment-media-view .placeholder,.customize-control-header .placeholder{width:100%;position:relative;text-align:center;cursor:default;border:1px dashed #b4b9be;box-sizing:border-box;padding:9px 0;line-height:20px}.customize-control-header .inner{display:none;position:absolute;width:100%;color:#555d66;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.customize-control-header .inner,.customize-control-header .inner .dashicons{line-height:20px;top:8px}.customize-control-header .list .inner,.customize-control-header .list .inner .dashicons{top:9px}.customize-control-header .header-view{position:relative;width:100%;margin-bottom:12px}.customize-control-header .header-view:last-child{margin-bottom:0}.customize-control-header .header-view:after{border:0}.customize-control-header .header-view.selected .choice:focus{outline:0}.customize-control-header .header-view.selected:after{content:'';position:absolute;height:auto;top:0;right:0;bottom:0;left:0;border:4px solid #00a0d2;border-radius:2px}.customize-control-header .header-view.button.selected{border:0}#customize-controls .customize-section-description-container.section-meta.customize-info,#customize-theme-controls .control-panel-themes{border-bottom:none}.customize-control-header .uploaded .header-view .close{font-size:20px;color:#fff;background:#555d66;background:rgba(0,0,0,.5);position:absolute;top:10px;right:-999px;z-index:1;width:26px;height:26px;cursor:pointer}.customize-control-header .header-view .close:focus,.customize-control-header .header-view:hover .close{right:auto;left:10px}.customize-control-header .header-view .close:focus{outline:#5b9dd9 solid 1px}.customize-control-header .random.placeholder{cursor:pointer;border-radius:2px;height:40px}.customize-control-header button.random{width:100%;height:auto;min-height:40px;white-space:normal}.customize-control-header button.random .dice{margin-top:4px}.customize-control-header .header-view:hover>button.random .dice,.customize-control-header .placeholder:hover .dice{-webkit-animation:dice-color-change 3s infinite;animation:dice-color-change 3s infinite}.button-see-me{-webkit-animation:bounce .7s 1;animation:bounce .7s 1;-webkit-transform-origin:center bottom;transform-origin:center bottom}@-webkit-keyframes bounce{20%,53%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translate3d(0,0,0)}40%,43%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-12px,0)}70%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-6px,0)}90%{-webkit-transform:translate3d(0,-1px,0)}}@keyframes bounce{20%,53%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}40%,43%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-12px,0);transform:translate3d(0,-12px,0)}70%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-6px,0);transform:translate3d(0,-6px,0)}90%{-webkit-transform:translate3d(0,-1px,0);transform:translate3d(0,-1px,0)}}.customize-control-header .choice{position:relative;display:block;margin-bottom:9px}.customize-control-header .choice:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 3px 1px rgba(30,140,190,.8)}.customize-control-header .uploaded div:last-child>.choice{margin-bottom:0}.customize-control .attachment-media-view .thumbnail-image img,.customize-control-header img{max-width:100%}.customize-control .attachment-media-view .default-button,.customize-control .attachment-media-view .remove-button,.customize-control-header .remove{margin-left:8px}.customize-control-background_position .background-position-control .button-group{display:block}.customize-control-code_editor textarea{width:100%;font-family:Consolas,Monaco,monospace;font-size:12px;padding:6px 8px;-moz-tab-size:2;-o-tab-size:2;tab-size:2}.customize-control-code_editor .CodeMirror,.customize-control-code_editor textarea{height:14em}#sub-accordion-section-custom_css .customize-control-notifications-container{margin-bottom:15px}#customize-control-custom_css textarea{display:block;height:500px}.customize-section-description-container+#customize-control-custom_css .customize-control-title{margin-right:12px}.customize-section-description-container+#customize-control-custom_css:last-child textarea{border-left:0;border-right:0;height:calc(100vh - 185px);resize:none}.customize-section-description-container+#customize-control-custom_css:last-child{margin-right:-12px;width:299px;width:calc(100% + 24px);margin-bottom:-12px}.customize-section-description-container+#customize-control-custom_css:last-child .CodeMirror{height:calc(100vh - 185px)}.CodeMirror-hints,.CodeMirror-lint-tooltip{z-index:500000!important}.customize-section-description-container+#customize-control-custom_css:last-child .customize-control-notifications-container{margin-right:12px;margin-left:12px}.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:10px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}@media screen and (max-width:640px){.customize-section-description-container+#customize-control-custom_css:last-child{margin-left:0}.customize-section-description-container+#customize-control-custom_css:last-child textarea{height:calc(100vh - 140px)}}#customize-theme-controls .control-panel-themes>.accordion-section-title,#customize-theme-controls .control-panel-themes>.accordion-section-title:hover{cursor:default;background:#fff;color:#555d66;border-top:1px solid #ddd;border-bottom:1px solid #ddd;border-right:none;border-left:none;margin:0 0 15px;padding-left:100px}#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child,#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child:hover{border-top:0}#customize-theme-controls .control-section-themes>.accordion-section-title,#customize-theme-controls .control-section-themes>.accordion-section-title:hover{margin:0 0 15px}#customize-controls .customize-themes-panel .accordion-section-title,#customize-controls .customize-themes-panel .accordion-section-title:hover{margin:15px -8px}#customize-controls .control-section-themes .accordion-section-title,#customize-controls .customize-themes-panel .accordion-section-title{padding-left:100px}#customize-controls .control-section-themes .accordion-section-title span.customize-action,#customize-controls .customize-section-title span.customize-action,.control-panel-themes .accordion-section-title span.customize-action{font-size:13px;display:block;font-weight:400}.in-themes-panel.animating .control-panel-themes .filter-themes-count,.themes-filter-bar .feature-filter-toggle .filter-count-filters{display:none}#customize-theme-controls .control-panel-themes .accordion-section-title .change-theme{position:absolute;left:10px;top:50%;margin-top:-14px;font-weight:400}#customize-theme-controls .control-panel-themes>.accordion-section-title:after{display:none}.control-panel-themes .customize-themes-full-container{position:fixed;top:0;right:0;transition:.18s right ease-in-out;margin:0 300px 0 0;padding:71px 0 25px;overflow-y:scroll;width:calc(100% - 300px);height:calc(100% - 96px);background:#eee;z-index:20}@media screen and (min-width:1670px){.control-panel-themes .customize-themes-full-container{width:82%;left:0;right:initial}}.modal-open .control-panel-themes .customize-themes-full-container{overflow-y:visible}#customize-header-actions .customize-controls-preview-toggle,#customize-header-actions .spinner,#customize-save-button-wrapper{transition:.18s margin ease-in-out}#customize-footer-actions,#customize-footer-actions .collapse-sidebar{bottom:0;transition:.18s bottom ease-in-out}.in-themes-panel:not(.animating) #customize-footer-actions,.in-themes-panel:not(.animating) #customize-header-actions .customize-controls-preview-toggle,.in-themes-panel:not(.animating) #customize-header-actions .spinner,.in-themes-panel:not(.animating) #customize-preview{visibility:hidden}.wp-full-overlay.in-themes-panel{background:#eee}.in-themes-panel #customize-header-actions .customize-controls-preview-toggle,.in-themes-panel #customize-header-actions .spinner,.in-themes-panel #customize-save-button-wrapper{margin-top:-46px}.in-themes-panel #customize-footer-actions,.in-themes-panel #customize-footer-actions .collapse-sidebar{bottom:-45px}.in-themes-panel.wp-full-overlay .wp-full-overlay-sidebar-content{bottom:0}.themes-filter-bar .feature-filter-toggle{float:left;margin:3px 25px 3px 0}.themes-filter-bar .feature-filter-toggle:before{content:"\f111";margin:0 0 0 5px;font:400 16px/1 dashicons;vertical-align:text-bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.themes-filter-bar .feature-filter-toggle.open{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.filter-drawer{box-sizing:border-box;width:100%;position:absolute;top:46px;right:0;padding:25px 25px 25px 0;border-top:0;margin:0;background:#eee;border-bottom:1px solid #ddd}.filter-drawer .filter-group{margin:0 0 0 25px;width:calc((100% - 75px)/ 3);min-width:200px;max-width:320px}@-webkit-keyframes themes-fade-in{0%,50%{opacity:0}100%{opacity:1}}@keyframes themes-fade-in{0%,50%{opacity:0}100%{opacity:1}}.control-panel-themes .customize-themes-full-container.animate{-webkit-animation:.6s themes-fade-in 1;animation:.6s themes-fade-in 1}.in-themes-panel:not(.animating) .control-panel-themes .filter-themes-count{-webkit-animation:.6s themes-fade-in 1;animation:.6s themes-fade-in 1}.control-panel-themes .filter-themes-count{position:relative;float:left;line-height:34px}.control-panel-themes .filter-themes-count .themes-displayed{font-weight:600;color:#555d66}.customize-themes-notifications{margin:0}.control-panel-themes .customize-themes-notifications .notice{margin:0 0 25px}.customize-themes-full-container .customize-themes-section{display:none!important;overflow:hidden}.customize-themes-full-container .customize-themes-section.current-section{display:list-item!important}.control-section .customize-section-text-before{padding:0 15px 8px 0;margin:15px 0 0;line-height:16px;border-bottom:1px solid #ddd;color:#555d66}.control-panel-themes .customize-themes-section-title{width:100%;background:#fff;box-shadow:none;outline:0;border-top:none;border-bottom:1px solid #ddd;border-right:4px solid #fff;border-left:none;cursor:pointer;padding:10px 15px;position:relative;text-align:right;font-size:14px;font-weight:600;color:#555d66;text-shadow:none}.control-panel-themes #accordion-section-installed_themes{border-top:1px solid #ddd}.control-panel-themes .theme-section{margin:0;position:relative}.control-panel-themes .customize-themes-section-title:focus,.control-panel-themes .customize-themes-section-title:hover{border-right-color:#0073aa;color:#0073aa;background:#f5f5f5}.customize-themes-section-title:not(.selected):after{content:"";display:block;position:absolute;top:9px;left:15px;width:18px;height:18px;border-radius:100%;border:1px solid #ccc;background:#fff}.control-panel-themes .theme-section .customize-themes-section-title.selected:after{content:"\f147";font:16px/1 dashicons;box-sizing:border-box;width:20px;height:20px;padding:3px 1px 1px 3px;border-radius:100%;position:absolute;top:9px;left:15px;background:#0073aa;color:#fff}.control-panel-themes .customize-themes-section-title.selected{color:#0073aa}#customize-theme-controls .themes.accordion-section-content{position:relative;right:0;padding:0;width:100%}.loading .customize-themes-section .spinner{display:block;visibility:visible;position:relative;clear:both;width:20px;height:20px;right:calc(50% - 10px);float:none;margin-top:50px}.control-panel-themes .customize-themes-mobile-back,.customize-themes-section .no-themes,.customize-themes-section .no-themes-local{display:none}.themes-section-installed_themes .theme .notice-success:not(.updated-message){display:none}.customize-control-theme .theme{width:100%;margin:0;border:1px solid #ddd;background:#fff}.customize-control-theme .theme .theme-actions,.customize-control-theme .theme .theme-name{background:#fff;border:none}.customize-control.customize-control-theme{box-sizing:border-box;width:25%;max-width:600px;margin:0 0 25px 25px;padding:0;clear:none}@media screen and (min-width:2101px){.customize-control.customize-control-theme{width:calc((100% - 125px)/ 5 - 1px)}}@media screen and (min-width:1601px) and (max-width:2100px){.customize-control.customize-control-theme{width:calc((100% - 100px)/ 4 - 1px)}}@media screen and (min-width:1201px) and (max-width:1600px){.customize-control.customize-control-theme{width:calc((100% - 75px)/ 3 - 1px)}}@media screen and (min-width:851px) and (max-width:1200px){.customize-control.customize-control-theme{width:calc((100% - 50px)/ 2 - 1px)}}@media screen and (max-width:850px){.customize-control.customize-control-theme{width:100%}}.wp-customizer .theme-browser .themes{padding:0 25px 25px 0;transition:.18s margin-top linear}.wp-customizer .theme-browser .theme .theme-actions{opacity:1}#customize-controls h3.theme-name{font-size:15px}#customize-controls .theme-overlay .theme-name{font-size:32px}.customize-preview-header.themes-filter-bar{position:fixed;top:0;right:300px;width:calc(100% - 300px);height:46px;background:#eee;z-index:10;padding:6px 25px;box-sizing:border-box;border-bottom:1px solid #ddd}@media screen and (min-width:1670px){.customize-preview-header.themes-filter-bar{width:82%;left:0;right:initial}}.themes-filter-bar .themes-filter-container{margin:0;padding:0}.themes-filter-bar .wp-filter-search{line-height:25px;padding:6px 30px 6px 10px;max-width:100%;width:40%;min-width:300px;position:absolute;top:6px;right:25px;height:32px;margin:1px 0}@media screen and (max-height:540px),screen and (max-width:1018px){.customize-preview-header.themes-filter-bar{position:relative;right:0;width:100%;margin:0 0 25px}.filter-drawer{top:46px}.wp-customizer .theme-browser .themes{padding:0 25px 25px 0;overflow:hidden}.control-panel-themes .customize-themes-full-container{margin-top:0;padding:0;height:100%;width:calc(100% - 300px)}}@media screen and (max-width:1018px){.filter-drawer .filter-group{width:calc((100% - 50px)/ 2)}}@media screen and (max-width:900px){.customize-preview-header.themes-filter-bar{height:86px;padding-top:46px}.themes-filter-bar .wp-filter-search{width:calc(100% - 50px);margin:0;min-width:200px}.filter-drawer{top:86px}.control-panel-themes .filter-themes-count{float:right}}@media screen and (max-width:792px){.filter-drawer .filter-group{width:calc(100% - 25px)}}@media screen and (max-width:600px){.filter-drawer{top:132px}.wp-full-overlay.showing-themes .control-panel-themes .filter-themes-count .filter-themes{display:block;float:left}.control-panel-themes .customize-themes-full-container{width:100%;margin:0;padding-top:46px;height:calc(100% - 46px);z-index:1;display:none}.showing-themes .control-panel-themes .customize-themes-full-container{display:block}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back{display:block;position:fixed;top:0;right:0;background:#eee;color:#444;border-radius:0;box-shadow:none;border:none;height:46px;width:100%;z-index:10;text-align:right;text-shadow:none;border-bottom:1px solid #ddd;border-right:4px solid transparent;margin:0;padding:0;font-size:0;overflow:hidden}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:before{right:0;top:0;height:46px;width:26px;display:block;line-height:46px;padding:0 8px;border-left:1px solid #ddd}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:focus,.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:hover{color:#0073aa;background:#f3f3f5;border-right-color:#0073aa;outline:0;box-shadow:none}.showing-themes #customize-header-actions{display:none}#customize-controls{width:100%}}.modal-open .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content,.wp-full-overlay.in-themes-panel.themes-panel-expanded #customize-controls .wp-full-overlay-sidebar-content{overflow:visible}.wp-customizer .theme-overlay{display:none}.wp-customizer.modal-open .theme-overlay{position:fixed;right:0;top:0;left:0;bottom:0;z-index:109}.wp-customizer.modal-open #customize-header-actions,.wp-customizer.modal-open .control-panel-themes .customize-themes-section-title.selected:after,.wp-customizer.modal-open .control-panel-themes .filter-themes-count{z-index:-1}.wp-customizer .theme-overlay .theme-backdrop{background:rgba(238,238,238,.75);position:fixed;z-index:110}.wp-customizer .theme-overlay .star-rating{float:right;margin-left:8px}.wp-customizer .theme-rating .num-ratings{line-height:20px}.wp-customizer .theme-overlay .theme-wrap{right:90px;left:90px;top:45px;bottom:45px;z-index:120}.wp-customizer .theme-overlay .theme-actions{text-align:left;padding:10px 25px;background:#eee;border-top:1px solid #ddd}.wp-customizer .theme-overlay .theme-actions .theme-install.preview{margin-right:8px}.control-panel-themes .theme-actions .delete-theme{right:15px;left:auto;bottom:auto;position:absolute}.wp-customizer .theme-header{background:#eee}.wp-customizer .theme-overlay .theme-header .close:before,.wp-customizer .theme-overlay .theme-header button{color:#444}.wp-customizer .theme-overlay .theme-header .close:focus,.wp-customizer .theme-overlay .theme-header .close:hover,.wp-customizer .theme-overlay .theme-header .left:focus,.wp-customizer .theme-overlay .theme-header .left:hover,.wp-customizer .theme-overlay .theme-header .right:focus,.wp-customizer .theme-overlay .theme-header .right:hover{background:#fff;border-bottom:4px solid #0073aa;color:#0073aa}.wp-customizer .theme-overlay .theme-header .close:focus:before,.wp-customizer .theme-overlay .theme-header .close:hover:before{color:#0073aa}.wp-customizer .theme-overlay .theme-header button.disabled,.wp-customizer .theme-overlay .theme-header button.disabled:focus,.wp-customizer .theme-overlay .theme-header button.disabled:hover{border-bottom:none;background:0 0;color:#ccc}@media (max-width:850px),(max-height:472px){.wp-customizer .theme-overlay .theme-wrap{right:0;left:0;top:0;bottom:0}.wp-customizer .theme-browser .themes{padding-left:25px}}body.cheatin{font-size:medium;height:auto;background:#fff;margin:50px auto 2em;padding:1em 2em;max-width:700px;min-width:0;box-shadow:0 1px 3px rgba(0,0,0,.13)}body.cheatin h1{border-bottom:1px solid #ddd;clear:both;color:#555d66;font-size:24px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;margin:30px 0 0;padding:0 0 7px}body.cheatin p{font-size:14px;line-height:1.5;margin:25px 0 20px}#customize-theme-controls .add-new-menu-item,#customize-theme-controls .add-new-widget{cursor:pointer;float:left;margin:0 10px 0 0;transition:all .2s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:0}.reordering .add-new-menu-item,.reordering .add-new-widget{opacity:.2;pointer-events:none;cursor:not-allowed}#available-menu-items .new-content-item .add-content:before,.add-new-menu-item:before,.add-new-widget:before{content:"\f132";display:inline-block;position:relative;right:-2px;top:0;font:400 20px/1 dashicons;vertical-align:middle;transition:all .2s;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.reorder-toggle{float:left;padding:5px 8px;text-decoration:none;cursor:pointer;outline:0}.reorder,.reordering .reorder-done{display:block;padding:5px 8px}.reorder-done,.reordering .reorder{display:none}.menu-item-reorder-nav button,.widget-reorder-nav span{position:relative;overflow:hidden;float:right;display:block;width:33px;height:43px;color:#82878c;text-indent:-9999px;cursor:pointer;outline:0}.menu-item-reorder-nav button{width:30px;height:40px;background:0 0;border:none;box-shadow:none}.menu-item-reorder-nav button:before,.widget-reorder-nav span:before{display:inline-block;position:absolute;top:0;left:0;width:100%;height:100%;font:400 20px/43px dashicons;text-align:center;text-indent:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.menu-item-reorder-nav button:focus,.menu-item-reorder-nav button:hover,.widget-reorder-nav span:focus,.widget-reorder-nav span:hover{color:#191e23;background:#eee}.menus-move-down:before,.move-widget-down:before{content:"\f347"}.menus-move-up:before,.move-widget-up:before{content:"\f343"}#customize-theme-controls .first-widget .move-widget-up,#customize-theme-controls .last-widget .move-widget-down,.move-down-disabled .menus-move-down,.move-left-disabled .menus-move-left,.move-right-disabled .menus-move-right,.move-up-disabled .menus-move-up{color:#d5d5d5;background-color:#fff;cursor:default;pointer-events:none}.wp-full-overlay-main{left:auto;width:100%}.add-menu-toggle.open,.add-menu-toggle.open:hover,.adding-menu-items .add-new-menu-item,.adding-menu-items .add-new-menu-item:hover,body.adding-widget .add-new-widget,body.adding-widget .add-new-widget:hover{background:#eee;border-color:#929793;color:#32373c;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5)}#accordion-section-add_menu .add-new-menu-item.open:before,.adding-menu-items .add-new-menu-item:before,body.adding-widget .add-new-widget:before{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}#available-menu-items,#available-widgets{position:absolute;top:0;bottom:0;right:-301px;visibility:hidden;overflow-x:hidden;overflow-y:auto;width:300px;margin:0;z-index:4;background:#eee;transition:right .18s;border-left:1px solid #ddd}#available-menu-items .customize-section-title,#available-widgets .customize-section-title{display:none}#available-widgets-list{top:60px;position:absolute;overflow:auto;bottom:0;width:100%;border-top:1px solid #ddd}.no-widgets-found #available-widgets-list{border-top:none}#available-widgets-filter{position:fixed;top:0;z-index:1;width:300px;background:#eee}#available-menu-items-search .accordion-section-title,#available-widgets-filter{padding:13px 15px;box-sizing:border-box}#available-menu-items-search input,#available-widgets-filter input{width:100%;height:32px;margin:1px 0;padding:6px 30px}#available-menu-items-search input::-ms-clear,#available-widgets-filter input::-ms-clear{display:none}#available-menu-items-search .search-icon,#available-widgets-filter .search-icon{display:block;position:absolute;top:15px;right:16px;width:30px;height:30px;line-height:28px;text-align:center;color:#72777c}#available-menu-items-search .clear-results,#available-widgets-filter .clear-results{position:absolute;top:15px;left:16px;width:30px;height:30px;padding:0;border:0;cursor:pointer;background:0 0;color:#a00;text-decoration:none;outline:0}#available-menu-items-search .clear-results,#available-menu-items-search.loading .clear-results.is-visible,#available-widgets-filter .clear-results{display:none}#available-menu-items-search .clear-results.is-visible,#available-widgets-filter .clear-results.is-visible{display:block}#available-menu-items-search .clear-results:before,#available-widgets-filter .clear-results:before{content:"\f335";font:400 20px/1 dashicons;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#available-menu-items-search .clear-results:focus,#available-menu-items-search .clear-results:hover,#available-widgets-filter .clear-results:focus,#available-widgets-filter .clear-results:hover{color:#dc3232}#available-menu-items-search .clear-results:focus,#available-widgets-filter .clear-results:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#available-menu-items-search .search-icon:after,#available-widgets-filter .search-icon:after,.themes-filter-bar .search-icon:after{content:"\f179";font:400 20px/1 dashicons;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.themes-filter-bar .search-icon{position:absolute;top:7px;right:26px;z-index:1;color:#72777c;height:30px;width:30px;line-height:2;text-align:center}.no-widgets-found-message{display:none;margin:0;padding:0 15px;line-height:inherit}.no-widgets-found .no-widgets-found-message{display:block}#available-menu-items .item-top,#available-menu-items .item-top:hover,#available-widgets .widget-top,#available-widgets .widget-top:hover{border:none;background:0 0;box-shadow:none}#available-menu-items .item-tpl,#available-widgets .widget-tpl{position:relative;padding:15px 60px 15px 15px;background:#fff;border-bottom:1px solid #ddd;border-right:4px solid #fff;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out;cursor:pointer;display:none}#available-menu-items .item,#available-widgets .widget{position:static}.customize-controls-preview-toggle{display:none}@media only screen and (max-width:782px){.wp-customizer .theme:not(.active):focus .theme-actions,.wp-customizer .theme:not(.active):hover .theme-actions{display:block}.wp-customizer .theme-browser .theme.active .theme-name span{display:inline}.customize-control-header button.random .dice{margin-top:0}.customize-control-checkbox .customize-inside-control-row,.customize-control-nav_menu_auto_add .customize-inside-control-row,.customize-control-radio .customize-inside-control-row{margin-right:32px}.customize-control-checkbox input,.customize-control-nav_menu_auto_add input,.customize-control-radio input{margin-right:-32px}.customize-control input[type=radio]+label+br,.customize-control input[type=checkbox]+label+br{line-height:32px}.customize-control .date-time-fields select{height:39px}.date-time-fields .date-input.month{width:79px}.date-time-fields .date-input.day,.date-time-fields .date-input.hour,.date-time-fields .date-input.minute{width:55px}.date-time-fields .date-input.year{width:80px}.date-time-fields .date-timezone{line-height:3.2}#customize-control-changeset_preview_link a{bottom:16px}.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button{bottom:10px}.media-widget-control .media-widget-buttons .button.change-media,.media-widget-control .media-widget-buttons .button.edit-media,.media-widget-control .media-widget-buttons .button.select-media{margin-top:12px}.wp-core-ui .themes-filter-bar .feature-filter-toggle{margin:3px 25px 3px 0}}@media screen and (max-width:1200px){.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main{right:67%}}@media screen and (max-width:640px){.wp-full-overlay.collapsed #customize-controls{margin-right:0}.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{bottom:0}.customize-controls-preview-toggle{display:block;position:absolute;top:0;right:48px;line-height:45px;font-size:14px;padding:0 12px;margin:0;height:45px;background:#eee;border:0;border-left:1px solid #ddd;color:#555d66;cursor:pointer;transition:color .1s ease-in-out,background .1s ease-in-out}#customize-footer-actions,.customize-controls-preview-toggle .controls,.preview-only .customize-controls-preview-toggle .preview,.preview-only .wp-full-overlay-sidebar-content{display:none}.preview-only #customize-save-button-wrapper{margin-top:-46px}.customize-controls-preview-toggle .controls:before,.customize-controls-preview-toggle .preview:before{font:400 20px/1 dashicons;content:"\f177";position:relative;top:4px;margin-left:6px}.customize-controls-preview-toggle .controls:before{content:"\f540"}.preview-only #customize-controls{height:45px}.preview-only #customize-preview,.preview-only .customize-controls-preview-toggle .controls{display:block}.wp-core-ui.wp-customizer .button{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto}#publish-settings{height:31px}#customize-control-changeset_status .customize-inside-control-row{padding-top:15px}body.adding-menu-items div#available-menu-items,body.adding-widget div#available-widgets,body.outer-section-open div#customize-sidebar-outer-content{width:100%}#available-menu-items .customize-section-title,#available-widgets .customize-section-title{display:block;margin:0}#available-menu-items .customize-section-back,#available-widgets .customize-section-back{height:69px}#available-menu-items .customize-section-title h3,#available-widgets .customize-section-title h3{font-size:20px;font-weight:200;padding:9px 14px 12px 10px;margin:0;line-height:24px;color:#555d66;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#available-menu-items .customize-section-title .customize-action,#available-widgets .customize-section-title .customize-action{font-size:13px;display:block;font-weight:400;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#available-widgets-filter{position:relative;width:100%;height:auto}#available-widgets-list{top:130px}#available-menu-items-search .clear-results,#available-menu-items-search .search-icon{top:85px}.reorder,.reordering .reorder-done{padding:8px}.wp-core-ui .themes-filter-bar .feature-filter-toggle{margin:0}.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:9px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}}@media screen and (max-width:600px){.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:8px 15px;box-shadow:none}.wp-full-overlay.expanded{margin-right:0}body.adding-menu-items div#available-menu-items,body.adding-widget div#available-widgets,body.outer-section-open div#customize-sidebar-outer-content{top:46px;z-index:10}body.wp-customizer .wp-full-overlay.expanded #customize-sidebar-outer-content{right:-100%}body.wp-customizer.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content{right:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-controls.css b/backend/wp-admin/css/customize-controls.css new file mode 100644 index 0000000..b595e2a --- /dev/null +++ b/backend/wp-admin/css/customize-controls.css @@ -0,0 +1,3032 @@ +body { + overflow: hidden; + -webkit-text-size-adjust: 100%; +} + +.customize-controls-close, +.widget-control-actions a { + text-decoration: none; +} + +#customize-controls h3 { + font-size: 14px; +} + +#customize-controls img { + max-width: 100%; +} + +#customize-controls .submit { + text-align: center; +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked { + background-color: rgba( 0, 0, 0, 0.7 ); + padding: 25px; +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .customize-changeset-locked-message { + margin-left: auto; + margin-right: auto; + max-width: 366px; + min-height: 64px; + width: auto; + padding: 25px 25px 25px 109px; + position: relative; + background: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + line-height: 1.5; + overflow-y: auto; + text-align: left; + top: calc( 50% - 100px ); +} + +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .currently-editing { + margin-top: 0; +} +#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .action-buttons { + margin-bottom: 0; +} + +.customize-changeset-locked-avatar { + width: 64px; + position: absolute; + left: 25px; + top: 25px; +} + +.wp-core-ui.wp-customizer .customize-changeset-locked-message a.button { + margin-right: 10px; + margin-top: 0; +} + +#customize-controls .description { + color: #555d66; +} + +#customize-save-button-wrapper { + float: right; + margin-top: 9px; +} + +body:not(.ready) #customize-save-button-wrapper .save { + visibility: hidden; +} +#customize-save-button-wrapper .save { + float: left; + border-radius: 3px; + box-shadow: none; /* @todo Adjust box shadow based on the disable states of paired button. */ + margin-top: 0; +} + +#customize-save-button-wrapper .save:focus, #publish-settings:focus { + box-shadow: 0 1px 0 #0073aa, 0 0 2px 1px #33b3db; /* This is default box shadow for focus */ +} + +#customize-save-button-wrapper .save.has-next-sibling { + border-radius: 3px 0 0 3px; +} + +#customize-sidebar-outer-content { + position: absolute; + top: 0; + bottom: 0; + left: 0; + visibility: hidden; + overflow-x: hidden; + overflow-y: auto; + width: 100%; + margin: 0; + z-index: -1; + background: #eee; + transition: left .18s; + border-right: 1px solid #ddd; + border-left: 1px solid #ddd; + height: 100%; +} + +#customize-theme-controls .control-section-outer { + display: none !important; +} + +#customize-outer-theme-controls .accordion-section-content { + padding: 12px; +} + +#customize-outer-theme-controls .accordion-section-content.open { + display: block; +} + +.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content { + visibility: visible; + left: 100%; + transition: left .18s; +} + +.customize-outer-pane-parent { + margin: 0; +} + +.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { + left: 300px; + opacity: 0.4; +} + +.outer-section-open .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, +.adding-menu-items .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, +.adding-widget .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main, +.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main { + left: 64%; +} + +#customize-outer-theme-controls li.notice { + padding-top: 8px; + padding-bottom: 8px; + margin-left: 0; + margin-bottom: 10px; +} + +#publish-settings { + text-indent: 0; + border-radius: 0 3px 3px 0; + padding-left: 0; + padding-right: 0; + box-shadow: none; /* @todo Adjust box shadow based on the disable states of paired button. */ + font-size: 14px; + width: 30px; + float: left; + -webkit-transform: none; + transform: none; + margin-top: 0; +} + +body:not(.ready) #publish-settings, +body.trashing #customize-save-button-wrapper .save, +body.trashing #publish-settings { + display: none; +} + +#customize-header-actions .spinner { + margin-top: 13px; + margin-right: 4px; +} + +.saving #customize-header-actions .spinner, +.trashing #customize-header-actions .spinner { + visibility: visible; +} + +#customize-header-actions { + border-bottom: 1px solid #ddd; +} + +#customize-controls .wp-full-overlay-sidebar-content { + overflow-y: auto; + overflow-x: hidden; +} + +.outer-section-open #customize-controls .wp-full-overlay-sidebar-content { + background: #eee; +} + +#customize-controls .customize-info { + border: none; + border-bottom: 1px solid #ddd; + margin-bottom: 15px; +} + +#customize-control-changeset_status .customize-inside-control-row, +#customize-control-changeset_preview_link input { + background-color: #ffffff; + border-bottom: 1px solid #ddd; + box-sizing: content-box; + width: 100%; + margin-left: -12px; + padding-left: 12px; + padding-right: 12px; +} + +#customize-control-trash_changeset { + margin-top: 20px; +} +#customize-control-trash_changeset .button-link { + position: relative; + padding-left: 24px; + display: inline-block; +} +#customize-control-trash_changeset .button-link:before { + content: "\f182"; + font: normal 22px dashicons; + text-decoration: none; + position: absolute; + left: 0; + top: -2px; +} + +#customize-controls .date-input:invalid { + border-color: #dc3232; +} + +#customize-control-changeset_status .customize-inside-control-row { + padding-top: 10px; + padding-bottom: 10px; + font-weight: 500; +} + +#customize-control-changeset_status .customize-inside-control-row:first-of-type { + border-top: 1px solid #ddd; +} + +#customize-control-changeset_status .customize-control-title { + margin-bottom: 6px; +} + +#customize-control-changeset_status input { + margin-left: 0; +} + +#customize-control-changeset_preview_link { + position: relative; + display: block; +} + +.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button { + margin: 0; + position: absolute; + bottom: 9px; + right: 0; +} + +.preview-link-wrapper { + position: relative; +} + +.customize-copy-preview-link:before, +.customize-copy-preview-link:after { + content: ""; + height: 28px; + position: absolute; + background: #ffffff; + top: -1px; +} + +.customize-copy-preview-link:before { + left: -10px; + width: 9px; + opacity: 0.75; +} + +.customize-copy-preview-link:after { + left: -5px; + width: 4px; + opacity: 0.8; +} + +#customize-control-changeset_preview_link input { + line-height: 2.5; + border-top: 1px solid #ddd; + border-left: none; + border-right: none; + text-indent: -999px; + color: #fff; +} + +#customize-control-changeset_preview_link label { + position: relative; + display: block; +} + +#customize-control-changeset_preview_link a { + display: inline-block; + position: absolute; + white-space: nowrap; + overflow: hidden; + width: 90%; + bottom: 14px; + font-size: 14px; + text-decoration: none; +} + +#customize-control-changeset_preview_link a.disabled, +#customize-control-changeset_preview_link a.disabled:active, +#customize-control-changeset_preview_link a.disabled:focus, +#customize-control-changeset_preview_link a.disabled:visited { + color: black; + opacity: 0.4; + cursor: default; + outline: none; + box-shadow: none; +} + +#sub-accordion-section-publish_settings .customize-section-description-container { + display: none; +} + +#customize-controls .customize-info.section-meta { + margin-bottom: 15px; +} + +.customize-control-date_time .customize-control-description + .date-time-fields.includes-time { + margin-top: 10px; +} + +.customize-control.customize-control-date_time .date-time-fields .date-input.day { + margin-right: 0; +} + +.date-time-fields .date-input.month { + width: auto; + margin: 0; +} + +.date-time-fields .date-input.day, +.date-time-fields .date-input.hour, +.date-time-fields .date-input.minute { + width: 46px; +} + +.date-time-fields .date-input.year { + width: 60px; +} + +.date-time-fields .date-input.meridian { + width: auto; + margin: 0; +} + +.date-time-fields .time-row { + margin-top: 12px; +} + +.date-time-fields .date-timezone { + line-height: 2.2; + text-decoration: none; +} + +#customize-control-changeset_preview_link { + margin-top: 6px; +} + +#customize-control-changeset_status { + margin-bottom: 0; + padding-bottom: 0; +} + +#customize-control-changeset_scheduled_date { + box-sizing: content-box; + width: 100%; + margin-left: -12px; + padding: 12px; + background: #ffffff; + border-bottom: 1px solid #ddd; + margin-bottom: 0; +} + +#customize-control-changeset_scheduled_date .customize-control-description { + font-style: normal; +} + +#customize-controls .customize-info.is-in-view, +#customize-controls .customize-section-title.is-in-view { + position: absolute; + z-index: 9; + width: 100%; + box-shadow: 0 1px 0 rgba(0, 0, 0, .1); +} + +#customize-controls .customize-section-title.is-in-view { + margin-top: 0; +} + +#customize-controls .customize-info.is-in-view + .accordion-section { + margin-top: 15px; +} + +#customize-controls .customize-info.is-sticky, +#customize-controls .customize-section-title.is-sticky { + position: fixed; + top: 46px; +} + +#customize-controls .customize-info .accordion-section-title { + background: #fff; + color: #555d66; + border-left: none; + border-right: none; + border-bottom: none; + cursor: default; +} + +#customize-controls .customize-info.open .accordion-section-title:after, +#customize-controls .customize-info .accordion-section-title:hover:after, +#customize-controls .customize-info .accordion-section-title:focus:after { + color: #32373c; +} + +#customize-controls .customize-info .accordion-section-title:after { + display: none; +} + +#customize-controls .customize-info .preview-notice { + font-size: 13px; + line-height: 24px; +} + +#customize-controls .customize-pane-child .customize-section-title h3, +#customize-controls .customize-pane-child h3.customize-section-title, +#customize-outer-theme-controls .customize-pane-child .customize-section-title h3, +#customize-outer-theme-controls .customize-pane-child h3.customize-section-title, +#customize-controls .customize-info .panel-title { + font-size: 20px; + font-weight: 200; + line-height: 26px; + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +#customize-controls .customize-section-title span.customize-action { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +#customize-controls .customize-info .customize-help-toggle { + position: absolute; + top: 4px; + right: 1px; + padding: 20px 20px 10px 10px; + width: 20px; + height: 20px; + cursor: pointer; + box-shadow: none; + -webkit-appearance: none; + background: transparent; + color: #555d66; + border: none; +} + +#customize-controls .customize-info .customize-help-toggle:before { + position: absolute; + top: 5px; + left: 6px; +} + +#customize-controls .customize-info.open .customize-help-toggle, +#customize-controls .customize-info .customize-help-toggle:focus, +#customize-controls .customize-info .customize-help-toggle:hover { + color: #0073aa; +} + +#customize-controls .customize-info .customize-panel-description, +#customize-controls .customize-info .customize-section-description, +#customize-outer-theme-controls .customize-info .customize-section-description, +#customize-controls .no-widget-areas-rendered-notice { + color: #555d66; + display: none; + background: #fff; + padding: 12px 15px; + border-top: 1px solid #ddd; +} + +#customize-controls .customize-info .customize-panel-description.open + .no-widget-areas-rendered-notice { + border-top: none; +} +.no-widget-areas-rendered-notice { + font-style: italic; +} +.no-widget-areas-rendered-notice p:first-child { + margin-top: 0; +} +.no-widget-areas-rendered-notice p:last-child { + margin-bottom: 0; +} + +#customize-controls .customize-info .customize-section-description { + margin-bottom: 15px; +} + +#customize-controls .customize-info .customize-panel-description p:first-child, +#customize-controls .customize-info .customize-section-description p:first-child { + margin-top: 0; +} + +#customize-controls .customize-info .customize-panel-description p:last-child, +#customize-controls .customize-info .customize-section-description p:last-child { + margin-bottom: 0; +} + +#customize-controls .current-panel .control-section > h3.accordion-section-title { + padding-right: 30px; +} + +#customize-theme-controls .control-section, +#customize-outer-theme-controls .control-section { + border: none; +} + +#customize-theme-controls .accordion-section-title, +#customize-outer-theme-controls .accordion-section-title { + color: #555d66; + background-color: #fff; + border-bottom: 1px solid #ddd; + border-left: 4px solid #fff; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; +} + +#customize-controls #customize-theme-controls .customize-themes-panel .accordion-section-title { + color: #555; + background-color: #fff; + border-left: 4px solid #fff; +} + +#customize-theme-controls .accordion-section-title:after, +#customize-outer-theme-controls .accordion-section-title:after { + content: "\f345"; + color: #a0a5aa; +} + +#customize-theme-controls .accordion-section-content, +#customize-outer-theme-controls .accordion-section-content { + color: #555d66; + background: transparent; +} + +#customize-controls .control-section:hover > .accordion-section-title, +#customize-controls .control-section .accordion-section-title:hover, +#customize-controls .control-section.open .accordion-section-title, +#customize-controls .control-section .accordion-section-title:focus { + color: #0073aa; + background: #f3f3f5; + border-left-color: #0073aa; +} + +#accordion-section-themes + .control-section { + border-top: 1px solid #ddd; +} + +.js .control-section:hover .accordion-section-title, +.js .control-section .accordion-section-title:hover, +.js .control-section.open .accordion-section-title, +.js .control-section .accordion-section-title:focus { + background: #f3f3f5; +} + +#customize-theme-controls .control-section:hover > .accordion-section-title:after, +#customize-theme-controls .control-section .accordion-section-title:hover:after, +#customize-theme-controls .control-section.open .accordion-section-title:after, +#customize-theme-controls .control-section .accordion-section-title:focus:after, +#customize-outer-theme-controls .control-section:hover > .accordion-section-title:after, +#customize-outer-theme-controls .control-section .accordion-section-title:hover:after, +#customize-outer-theme-controls .control-section.open .accordion-section-title:after, +#customize-outer-theme-controls .control-section .accordion-section-title:focus:after { + color: #0073aa; +} + +#customize-theme-controls .control-section.open { + border-bottom: 1px solid #eee; +} + +#customize-theme-controls .control-section.open .accordion-section-title, +#customize-outer-theme-controls .control-section.open .accordion-section-title { + border-bottom-color: #eee !important; +} + +#customize-theme-controls .control-section:last-of-type.open, +#customize-theme-controls .control-section:last-of-type > .accordion-section-title { + border-bottom-color: #ddd; +} + +#customize-theme-controls .control-panel-content:not(.control-panel-nav_menus) .control-section:nth-child(2), +#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu, +#customize-theme-controls .control-section-nav_menu_locations .accordion-section-title { + border-top: 1px solid #ddd; +} + +#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu + .control-section-nav_menu { + border-top: none; +} + +#customize-theme-controls > ul { + margin: 0; +} + +#customize-theme-controls .accordion-section-content { + position: absolute; + top: 0; + left: 100%; + width: 100%; + margin: 0; + padding: 12px; + box-sizing: border-box; +} + +#customize-info, +#customize-theme-controls .customize-pane-parent, +#customize-theme-controls .customize-pane-child { + overflow: visible; + width: 100%; + margin: 0; + padding: 0; + box-sizing: border-box; + transition: 0.18s -webkit-transform cubic-bezier(0.645, 0.045, 0.355, 1); + transition: 0.18s transform cubic-bezier(0.645, 0.045, 0.355, 1); + transition: 0.18s transform cubic-bezier(0.645, 0.045, 0.355, 1), 0.18s -webkit-transform cubic-bezier(0.645, 0.045, 0.355, 1); /* easeInOutCubic */ +} + +#customize-theme-controls .customize-pane-child.skip-transition { + transition: none; +} + +#customize-info, +#customize-theme-controls .customize-pane-parent { + position: relative; + visibility: visible; + height: auto; + max-height: none; + overflow: auto; + -webkit-transform: none; + transform: none; +} + +#customize-theme-controls .customize-pane-child { + position: absolute; + top: 0; + left: 0; + visibility: hidden; + height: 0; + max-height: none; + overflow: hidden; + -webkit-transform: translateX(100%); + transform: translateX(100%); +} + +#customize-theme-controls .customize-pane-child.open, +#customize-theme-controls .customize-pane-child.current-panel { + -webkit-transform: none; + transform: none; +} + +.section-open #customize-theme-controls .customize-pane-parent, +.in-sub-panel #customize-theme-controls .customize-pane-parent, +.section-open #customize-info, +.in-sub-panel #customize-info, +.in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel { + visibility: hidden; + height: 0; + overflow: hidden; + -webkit-transform: translateX(-100%); + transform: translateX(-100%); +} + +.section-open #customize-theme-controls .customize-pane-parent.busy, +.in-sub-panel #customize-theme-controls .customize-pane-parent.busy, +.section-open #customize-info.busy, +.in-sub-panel #customize-info.busy, +.busy.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel, +#customize-theme-controls .customize-pane-child.open, +#customize-theme-controls .customize-pane-child.current-panel, +#customize-theme-controls .customize-pane-child.busy { + visibility: visible; + height: auto; + overflow: auto; +} + +#customize-theme-controls .customize-pane-child.accordion-section-content, +#customize-theme-controls .customize-pane-child.accordion-sub-container { + display: block; + overflow-x: hidden; +} + +#customize-theme-controls .customize-pane-child.accordion-section-content { + padding: 12px; +} + +#customize-theme-controls .customize-pane-child.menu li { + position: static; +} + +.customize-section-description-container, +.control-section-nav_menu .customize-section-description-container, +.control-section-new_menu .customize-section-description-container { + margin-bottom: 15px; +} + +.control-section-nav_menu .customize-control, +.control-section-new_menu .customize-control { + /* Override default `margin-bottom` for `.customize-control` */ + margin-bottom: 0; +} + +.customize-section-title { + margin: -12px -12px 0 -12px; + border-bottom: 1px solid #ddd; + background: #fff; +} + +div.customize-section-description { + margin-top: 22px; +} + +.customize-info div.customize-section-description { + margin-top: 0; +} + +div.customize-section-description p:first-child { + margin-top: 0; +} + +div.customize-section-description p:last-child { + margin-bottom: 0; +} + +#customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child { + border-bottom: 1px solid #ddd; + padding: 12px 12px 12px 12px; +} + +.ios #customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child { + padding: 12px 12px 13px 12px; +} + +.customize-section-title h3, +h3.customize-section-title { + padding: 10px 10px 12px 14px; + margin: 0; + line-height: 21px; + color: #555d66; +} + +.accordion-sub-container.control-panel-content { + display: none; + position: absolute; + top: 0; + width: 100%; +} + +.accordion-sub-container.control-panel-content.busy { + display: block; +} + +.current-panel .accordion-sub-container.control-panel-content { + width: 100%; +} + +.customize-controls-close { + display: block; + position: absolute; + top: 0; + left: 0; + width: 45px; + height: 41px; + padding: 0 2px 0 0; + background: #eee; + border: none; + border-top: 4px solid #eee; + border-right: 1px solid #ddd; + color: #444; + text-align: left; + cursor: pointer; + transition: color .15s ease-in-out, + border-color .15s ease-in-out, + background .15s ease-in-out; + box-sizing: content-box; +} + +.customize-panel-back, +.customize-section-back { + display: block; + float: left; + width: 48px; + height: 71px; + padding: 0 24px 0 0; + margin: 0; + background: #fff; + border: none; + border-right: 1px solid #ddd; + border-left: 4px solid #fff; + box-shadow: none; + cursor: pointer; + transition: color .15s ease-in-out, + border-color .15s ease-in-out, + background .15s ease-in-out; +} + +.customize-section-back { + height: 74px; +} + +.ios .customize-panel-back { + display: none; +} + +.ios .expanded.in-sub-panel .customize-panel-back { + display: block; +} + +#customize-controls .panel-meta.customize-info .accordion-section-title { + margin-left: 48px; + border-left: none; +} + +#customize-controls .panel-meta.customize-info .accordion-section-title:hover, +#customize-controls .cannot-expand:hover .accordion-section-title { + background: #fff; + color: #555d66; + border-left-color: #fff; +} + +.customize-controls-close:focus, +.customize-controls-close:hover, +.customize-controls-preview-toggle:focus, +.customize-controls-preview-toggle:hover { + background: #fff; + color: #0073aa; + border-top-color: #0073aa; + outline: none; + box-shadow: none; +} + + +.customize-panel-back:hover, +.customize-panel-back:focus, +.customize-section-back:hover, +.customize-section-back:focus { + color: #0073aa; + background: #f3f3f5; + border-left-color: #0073aa; + outline: none; + box-shadow: none; +} + +.customize-controls-close:before { + font: normal 22px/45px dashicons; + content: "\f335"; + position: relative; + top: -3px; + left: 13px; +} + +.customize-panel-back:before, +.customize-section-back:before { + font: normal 20px/72px dashicons; + content: "\f341"; + position: relative; + left: 9px; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header { + background-color: #eee; + transition: padding ease-in-out .18s; +} + +.in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header { + padding-left: 62px; +} + +p.customize-section-description { + font-style: normal; + margin-top: 22px; + margin-bottom: 0; +} + +.customize-section-description ul { + margin-left: 1em; +} + +.customize-section-description ul > li { + list-style: disc; +} + +.section-description-buttons { + text-align: right; +} + +.section-description-buttons button.button-link { + color: #0073aa; + text-decoration: underline; +} + +.customize-control { + width: 100%; + float: left; + clear: both; + margin-bottom: 12px; +} + +.customize-control select, +.customize-control input[type="radio"], +.customize-control input[type="checkbox"] { + line-height: 28px; +} + +.customize-control input[type="text"], +.customize-control input[type="password"], +.customize-control input[type="email"], +.customize-control input[type="number"], +.customize-control input[type="search"], +.customize-control input[type="tel"], +.customize-control input[type="url"] { + width: 100%; + line-height: 18px; + margin: 0; +} + +.customize-control-hidden { + margin: 0; +} + +.customize-control-textarea textarea { + width: 100%; + resize: vertical; +} + +.customize-control select { + width: 100%; + height: 28px; + line-height: 28px; +} + +.customize-control select[multiple] { + height: auto; +} + +.customize-control-title { + display: block; + font-size: 14px; + line-height: 24px; + font-weight: 600; + margin-bottom: 4px; +} + +.customize-control-description { + display: block; + font-style: italic; + line-height: 18px; + margin-top: 0; + margin-bottom: 5px; +} + +.customize-section-description a.external-link:after { + font: 16px/11px dashicons; + content: "\f310"; + top: 3px; + position: relative; + padding-left: 3px; + display: inline-block; + text-decoration: none; +} + +.customize-control-color .color-picker, +.customize-control-upload div { + line-height: 28px; +} + +.customize-control .customize-inside-control-row { + line-height: 20px; + display: block; + margin-left: 24px; + padding-top: 6px; + padding-bottom: 6px; +} + +.customize-control-radio input, +.customize-control-checkbox input, +.customize-control-nav_menu_auto_add input { + margin-right: 4px; + margin-left: -24px; +} + +.customize-control-radio { + padding: 5px 0 10px; +} + +.customize-control-radio .customize-control-title { + margin-bottom: 0; + line-height: 22px; +} + +.customize-control-radio .customize-control-title + .customize-control-description { + margin-top: 7px; +} + +.customize-control-radio label, +.customize-control-checkbox label { + vertical-align: top; +} + +.customize-control .attachment-thumb.type-icon { + float: left; + margin: 10px; + width: auto; +} + +.customize-control .attachment-title { + font-weight: 600; + margin: 0; + padding: 5px 10px; +} + +.customize-control .attachment-meta { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin: 0; + padding: 0 10px; +} + +.customize-control .attachment-meta-title { + padding-top: 7px; +} + +/* Remove descender space. */ +.customize-control .thumbnail-image, +.customize-control-header .current, +.customize-control .wp-media-wrapper.wp-video { + line-height: 0; +} + +/* Remove descender space. */ +.customize-control-site_icon .favicon-preview .browser-preview { + vertical-align: top; +} + +.customize-control .thumbnail-image img { + cursor: pointer; +} + +#customize-controls .thumbnail-audio .thumbnail { + max-width: 64px; + max-height: 64px; + margin: 10px; + float: left; +} + +#available-menu-items .accordion-section-content .new-content-item, +.customize-control-dropdown-pages .new-content-item { + width: calc(100% - 30px); + padding: 8px 15px; + position: absolute; + bottom: 0; + z-index: 10; + background: #eee; + display: -webkit-box; + display: flex; +} + +.customize-control-dropdown-pages .new-content-item { + width: 100%; + padding: 5px 0 5px 1px; + position: relative; +} + +#available-menu-items .new-content-item .create-item-input, +.customize-control-dropdown-pages .new-content-item .create-item-input { + -webkit-box-flex: 10; + flex-grow: 10; +} + +#available-menu-items .new-content-item .add-content, +.customize-control-dropdown-pages .new-content-item .add-content { + margin: 2px 0 2px 6px; + -webkit-box-flex: 10; + flex-grow: 1; +} + +.customize-control-dropdown-pages .new-content-item .create-item-input.invalid { + border: 1px solid #dc3232; +} + +.customize-control-dropdown-pages .add-new-toggle { + margin-left: 1px; + font-weight: 600; + line-height: 28px; +} + +#customize-preview iframe { + width: 100%; + height: 100%; + position: absolute; +} +#customize-preview iframe + iframe { + visibility: hidden; +} + +.wp-full-overlay-sidebar { + background: #eee; + border-right: 1px solid #ddd; +} + + +/** + * Notifications + */ + +#customize-controls .customize-control-notifications-container { /* Scoped to #customize-controls for specificity over notification styles in common.css. */ + margin: 4px 0 8px 0; + padding: 0; + cursor: default; +} + +#customize-controls .customize-control-widget_form.has-error .widget .widget-top, +.customize-control-nav_menu_item.has-error .menu-item-bar .menu-item-handle { + box-shadow: inset 0 0 0 2px #dc3232; + transition: .15s box-shadow linear; +} + +#customize-controls .customize-control-notifications-container li.notice { + list-style: none; + margin: 0 0 6px 0; + padding: 9px 14px; + overflow: hidden; +} +#customize-controls .customize-control-notifications-container .notice.is-dismissible { + padding-right: 38px; +} + +.customize-control-notifications-container li.notice:last-child { + margin-bottom: 0; +} + +#customize-controls .customize-control-nav_menu_item .customize-control-notifications-container { + margin-top: 0; +} + +#customize-controls .customize-control-widget_form .customize-control-notifications-container { + margin-top: 8px; +} + +.customize-control-text.has-error input { + outline: 2px solid #dc3232; +} + +#customize-controls #customize-notifications-area { + position: absolute; + top: 46px; + width: 100%; + border-bottom: 1px solid #ddd; + display: block; + padding: 0; + margin: 0; +} + +.wp-full-overlay.collapsed #customize-controls #customize-notifications-area { + display: none !important; +} + +#customize-controls #customize-notifications-area:not(.has-overlay-notifications), +#customize-controls .customize-section-title > .customize-control-notifications-container:not(.has-overlay-notifications), +#customize-controls .panel-meta > .customize-control-notifications-container:not(.has-overlay-notifications) { + max-height: 210px; + overflow-x: hidden; + overflow-y: auto; +} + +#customize-controls #customize-notifications-area > ul, +#customize-controls #customize-notifications-area .notice, +#customize-controls .panel-meta > .customize-control-notifications-container, +#customize-controls .panel-meta > .customize-control-notifications-container .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice { + margin: 0; +} +#customize-controls .panel-meta > .customize-control-notifications-container, +#customize-controls .customize-section-title > .customize-control-notifications-container { + border-top: 1px solid #ddd; +} +#customize-controls #customize-notifications-area .notice, +#customize-controls .panel-meta > .customize-control-notifications-container .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice { + padding: 9px 14px; +} +#customize-controls #customize-notifications-area .notice.is-dismissible, +#customize-controls .panel-meta > .customize-control-notifications-container .notice.is-dismissible, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice.is-dismissible { + padding-right: 38px; +} +#customize-controls #customize-notifications-area .notice + .notice, +#customize-controls .panel-meta > .customize-control-notifications-container .notice + .notice, +#customize-controls .customize-section-title > .customize-control-notifications-container .notice + .notice { + margin-top: 1px; +} + +@-webkit-keyframes customize-fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +@keyframes customize-fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +#customize-controls .notice.notification-overlay, +#customize-controls #customize-notifications-area .notice.notification-overlay { + margin: 0; + border-left: 0; /* @todo Appropriate styles could be added for notice-error, notice-warning, notice-success, etc */ +} + +#customize-controls .customize-control-notifications-container.has-overlay-notifications { + -webkit-animation: customize-fade-in 0.5s; + animation: customize-fade-in 0.5s; + z-index: 30; +} + +/* Note: Styles for this are also defined in themes.css */ +#customize-controls #customize-notifications-area .notice.notification-overlay .notification-message { + clear: both; + color: #191e23; + font-size: 18px; + font-style: normal; + margin: 0; + padding: 2em 0; + text-align: center; + width: 100%; + display: block; + top: 50%; + position: relative; +} + +/* Style for custom settings */ + +/** + * Static front page + */ + +#customize-control-show_on_front.has-error { + margin-bottom: 0; +} +#customize-control-show_on_front.has-error .customize-control-notifications-container { + margin-top: 12px; +} + +/** + * Dropdowns + */ + +.accordion-section .dropdown { + float: left; + display: block; + position: relative; + cursor: pointer; +} + +.accordion-section .dropdown-content { + overflow: hidden; + float: left; + min-width: 30px; + height: 16px; + line-height: 16px; + margin-right: 16px; + padding: 4px 5px; + border: 2px solid #eee; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* @todo maybe no more used? */ +.customize-control .dropdown-arrow { + position: absolute; + top: 0; + bottom: 0; + right: 0; + width: 20px; + background: #eee; +} + +.customize-control .dropdown-arrow:after { + content: "\f140"; + font: normal 20px/1 dashicons; + speak: none; + display: block; + padding: 0; + text-indent: 0; + text-align: center; + position: relative; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #32373c; +} + +.customize-control .dropdown-status { + color: #32373c; + background: #eee; + display: none; + max-width: 112px; +} + +.customize-control-color .dropdown { + margin-right: 5px; + margin-bottom: 5px; +} + +.customize-control-color .dropdown .dropdown-content { + background-color: #555d66; + border: 1px solid rgba(0, 0, 0, 0.15); +} + +.customize-control-color .dropdown:hover .dropdown-content { + border-color: rgba(0, 0, 0, 0.25); +} + +/** + * iOS can't scroll iframes, + * instead it expands the iframe size to match the size of the content + */ + +.ios .wp-full-overlay { + position: relative; +} + +.ios #customize-controls .wp-full-overlay-sidebar-content { + -webkit-overflow-scrolling: touch; +} + +/* Media controls */ + +.customize-control .actions .button { + margin-top: 12px; +} + +.customize-control-header .actions, +.customize-control-header .uploaded { + margin-bottom: 18px; +} + +.customize-control-header .uploaded button:not(.random), +.customize-control-header .default button:not(.random) { + width: 100%; + padding: 0; + margin: 0; + background: none; + border: none; + color: inherit; + cursor: pointer; +} + +.customize-control-header button img { + display: block; +} + +.customize-control .attachment-media-view .remove-button, +.customize-control .attachment-media-view .default-button, +.customize-control .attachment-media-view .upload-button, +.customize-control-header button.new, +.customize-control-header button.remove { + width: auto; + height: auto; + white-space: normal; +} + +.customize-control .attachment-media-view .thumbnail, +.customize-control-header .current .container { + overflow: hidden; +} + +.customize-control .attachment-media-view .placeholder, +.customize-control-header .placeholder { + width: 100%; + position: relative; + text-align: center; + cursor: default; + border: 1px dashed #b4b9be; + box-sizing: border-box; + padding: 9px 0; + line-height: 20px; +} + +.customize-control-header .inner { + display: none; + position: absolute; + width: 100%; + color: #555d66; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.customize-control-header .inner, +.customize-control-header .inner .dashicons { + line-height: 20px; + top: 8px; +} + +.customize-control-header .list .inner, +.customize-control-header .list .inner .dashicons { + top: 9px; +} + +.customize-control-header .header-view { + position: relative; + width: 100%; + margin-bottom: 12px; +} + +.customize-control-header .header-view:last-child { + margin-bottom: 0px; +} + +/* Convoluted, but 'outline' support isn't good enough yet */ +.customize-control-header .header-view:after { + border: 0; +} + +.customize-control-header .header-view.selected .choice:focus { + outline: none; +} + +.customize-control-header .header-view.selected:after { + content: ''; + position: absolute; + height: auto; + top: 0; + left: 0; + bottom: 0; + right: 0; + border: 4px solid #00a0d2; + border-radius: 2px; +} + +.customize-control-header .header-view.button.selected { + border: 0; +} + +/* Header control: overlay "close" button */ + +.customize-control-header .uploaded .header-view .close { + font-size: 20px; + color: #fff; + background: #555d66; + background: rgba(0, 0, 0, 0.5); + position: absolute; + top: 10px; + left: -999px; + z-index: 1; + width: 26px; + height: 26px; + cursor: pointer; +} + +.customize-control-header .header-view:hover .close, +.customize-control-header .header-view .close:focus { + left: auto; + right: 10px; +} + +.customize-control-header .header-view .close:focus { + outline: 1px solid #5b9dd9; +} + +/* Header control: randomiz(s)er */ + +.customize-control-header .random.placeholder { + cursor: pointer; + border-radius: 2px; + height: 40px; +} + +.customize-control-header button.random { + width: 100%; + height: auto; + min-height: 40px; + white-space: normal; +} + +.customize-control-header button.random .dice { + margin-top: 4px; +} + +.customize-control-header .placeholder:hover .dice, +.customize-control-header .header-view:hover > button.random .dice { + -webkit-animation: dice-color-change 3s infinite; + animation: dice-color-change 3s infinite; +} + +.button-see-me { + -webkit-animation: bounce .7s 1; + animation: bounce .7s 1; + -webkit-transform-origin: center bottom; + transform-origin: center bottom; +} + +@-webkit-keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -12px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -6px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-1px,0); + } +} + +@keyframes bounce { + from, 20%, 53%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + -webkit-transform: translate3d(0,0,0); + transform: translate3d(0,0,0); + } + + 40%, 43% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -12px, 0); + transform: translate3d(0, -12px, 0); + } + + 70% { + -webkit-animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060); + -webkit-transform: translate3d(0, -6px, 0); + transform: translate3d(0, -6px, 0); + } + + 90% { + -webkit-transform: translate3d(0,-1px,0); + transform: translate3d(0,-1px,0); + } +} + +.customize-control-header .choice { + position: relative; + display: block; + margin-bottom: 9px; +} + +.customize-control-header .choice:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 3px 1px rgba(30, 140, 190, .8); +} + +.customize-control-header .uploaded div:last-child > .choice { + margin-bottom: 0; +} + +.customize-control .attachment-media-view .thumbnail-image img, +.customize-control-header img { + max-width: 100%; +} + +.customize-control .attachment-media-view .remove-button, +.customize-control .attachment-media-view .default-button, +.customize-control-header .remove { + margin-right: 8px; +} + +/* Background position control */ +.customize-control-background_position .background-position-control .button-group { + display: block; +} + +/** + * Code Editor Control and Custom CSS Section + * + * Modifications to the Section Container to make the textarea full-width and + * full-height, if the control is the only control in the section. + */ + +.customize-control-code_editor textarea { + width: 100%; + font-family: Consolas, Monaco, monospace; + font-size: 12px; + padding: 6px 8px; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +.customize-control-code_editor textarea, +.customize-control-code_editor .CodeMirror { + height: 14em; +} + +#customize-controls .customize-section-description-container.section-meta.customize-info { + border-bottom: none; +} + +#sub-accordion-section-custom_css .customize-control-notifications-container { + margin-bottom: 15px; +} + +#customize-control-custom_css textarea { + display: block; + height: 500px; +} + +.customize-section-description-container + #customize-control-custom_css .customize-control-title { + margin-left: 12px; +} + +.customize-section-description-container + #customize-control-custom_css:last-child textarea { + border-right: 0; + border-left: 0; + height: calc( 100vh - 185px ); + resize: none; +} + +.customize-section-description-container + #customize-control-custom_css:last-child { + margin-left: -12px; + width: 299px; + width: calc( 100% + 24px ); + margin-bottom: -12px; +} + +.customize-section-description-container + #customize-control-custom_css:last-child .CodeMirror { + height: calc( 100vh - 185px ); +} + +.CodeMirror-lint-tooltip, +.CodeMirror-hints { + z-index: 500000 !important; +} + +.customize-section-description-container + #customize-control-custom_css:last-child .customize-control-notifications-container { + margin-left: 12px; + margin-right: 12px; +} + +.theme-browser .theme.active .theme-actions, +.wp-customizer .theme-browser .theme .theme-actions { + padding: 10px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); +} + +@media screen and ( max-width: 640px ) { + .customize-section-description-container + #customize-control-custom_css:last-child { + margin-right: 0; + } + + .customize-section-description-container + #customize-control-custom_css:last-child textarea { + height: calc( 100vh - 140px ); + } +} + +/** + * Themes + */ + +#customize-theme-controls .control-panel-themes { + border-bottom: none; +} + +#customize-theme-controls .control-panel-themes > .accordion-section-title:hover, /* Not a focusable element. */ +#customize-theme-controls .control-panel-themes > .accordion-section-title { + cursor: default; + background: #fff; + color: #555d66; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + border-left: none; + border-right: none; + margin: 0 0 15px 0; + padding-right: 100px; /* Space for the button */ +} + +#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child:hover, /* Not a focusable element. */ +#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child { + border-top: 0; +} + +#customize-theme-controls .control-section-themes > .accordion-section-title:hover, /* Not a focusable element. */ +#customize-theme-controls .control-section-themes > .accordion-section-title { + margin: 0 0 15px; +} + +#customize-controls .customize-themes-panel .accordion-section-title:hover, +#customize-controls .customize-themes-panel .accordion-section-title { + margin: 15px -8px; +} + +#customize-controls .control-section-themes .accordion-section-title, +#customize-controls .customize-themes-panel .accordion-section-title { + padding-right: 100px; /* Space for the button */ +} + +.control-panel-themes .accordion-section-title span.customize-action, +#customize-controls .customize-section-title span.customize-action, +#customize-controls .control-section-themes .accordion-section-title span.customize-action, +#customize-controls .customize-section-title span.customize-action { + font-size: 13px; + display: block; + font-weight: 400; +} + +#customize-theme-controls .control-panel-themes .accordion-section-title .change-theme { + position: absolute; + right: 10px; + top: 50%; + margin-top: -14px; + font-weight: 400; +} + +#customize-theme-controls .control-panel-themes > .accordion-section-title:after { + display: none; +} + +.control-panel-themes .customize-themes-full-container { + position: fixed; + top: 0; + left: 0; + transition: .18s left ease-in-out; + margin: 0 0 0 300px; + padding: 71px 0 25px; + overflow-y: scroll; + width: calc(100% - 300px); + height: calc(100% - 96px); + background: #eee; + z-index: 20; +} + +@media screen and (min-width: 1670px) { + .control-panel-themes .customize-themes-full-container { + width: 82%; + right: 0; + left: initial; + } +} + +.modal-open .control-panel-themes .customize-themes-full-container { + overflow-y: visible; +} + +/* Animations for opening the themes panel */ +#customize-save-button-wrapper, +#customize-header-actions .spinner, +#customize-header-actions .customize-controls-preview-toggle { + transition: .18s margin ease-in-out; +} + +#customize-footer-actions, +#customize-footer-actions .collapse-sidebar { + bottom: 0; + transition: .18s bottom ease-in-out; +} + +.in-themes-panel:not(.animating) #customize-header-actions .spinner, +.in-themes-panel:not(.animating) #customize-header-actions .customize-controls-preview-toggle, +.in-themes-panel:not(.animating) #customize-preview, +.in-themes-panel:not(.animating) #customize-footer-actions { + visibility: hidden; +} + +.wp-full-overlay.in-themes-panel { + background: #eee; /* Prevents a black flash when fading in the panel */ +} + +.in-themes-panel #customize-save-button-wrapper, +.in-themes-panel #customize-header-actions .spinner, +.in-themes-panel #customize-header-actions .customize-controls-preview-toggle { + margin-top: -46px; /* Height of header actions bar */ +} + +.in-themes-panel #customize-footer-actions, +.in-themes-panel #customize-footer-actions .collapse-sidebar { + bottom: -45px; +} + +/* Don't show the theme count while the panel opens, as it's in the wrong place during the animation */ +.in-themes-panel.animating .control-panel-themes .filter-themes-count { + display: none; +} + +.in-themes-panel.wp-full-overlay .wp-full-overlay-sidebar-content { + bottom: 0; +} + +.themes-filter-bar .feature-filter-toggle { + float: right; + margin: 3px 0 3px 25px; +} + +.themes-filter-bar .feature-filter-toggle:before { + content: "\f111"; + margin: 0 5px 0 0; + font: normal 16px/1 dashicons; + vertical-align: text-bottom; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.themes-filter-bar .feature-filter-toggle.open { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.themes-filter-bar .feature-filter-toggle .filter-count-filters { + display: none; +} + +.filter-drawer { + box-sizing: border-box; + width: 100%; + position: absolute; + top: 46px; + left: 0; + padding: 25px 0 25px 25px; + border-top: 0; + margin: 0; + background: #eee; + border-bottom: 1px solid #ddd; +} + +.filter-drawer .filter-group { + margin: 0 25px 0 0; + width: calc( (100% - 75px) / 3); + min-width: 200px; + max-width: 320px; +} + +/* Adds a delay before fading in to avoid it "jumping" */ +@-webkit-keyframes themes-fade-in { + 0% { + opacity: 0; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} +@keyframes themes-fade-in { + 0% { + opacity: 0; + } + 50% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.control-panel-themes .customize-themes-full-container.animate { + -webkit-animation: .6s themes-fade-in 1; + animation: .6s themes-fade-in 1; +} + +.in-themes-panel:not(.animating) .control-panel-themes .filter-themes-count { + -webkit-animation: .6s themes-fade-in 1; + animation: .6s themes-fade-in 1; +} + +.control-panel-themes .filter-themes-count { + position: relative; + float: right; + line-height: 34px; +} + +.control-panel-themes .filter-themes-count .themes-displayed { + font-weight: 600; + color: #555d66; +} + +.customize-themes-notifications { + margin: 0; +} + +.control-panel-themes .customize-themes-notifications .notice { + margin: 0 0 25px 0; +} + +.customize-themes-full-container .customize-themes-section { + display: none !important; /* There is unknown JS that perpetually tries to show all theme sections when more items are added. */ + overflow: hidden; +} + +.customize-themes-full-container .customize-themes-section.current-section { + display: list-item !important; /* There is unknown JS that perpetually tries to show all theme sections when more items are added. */ +} + +.control-section .customize-section-text-before { + padding: 0 0 8px 15px; + margin: 15px 0 0 0; + line-height: 16px; + border-bottom: 1px solid #ddd; + color: #555d66; +} + +.control-panel-themes .customize-themes-section-title { + width: 100%; + background: #fff; + box-shadow: none; + outline: none; + border-top: none; + border-bottom: 1px solid #ddd; + border-left: 4px solid #fff; + border-right: none; + cursor: pointer; + padding: 10px 15px; + position: relative; + text-align: left; + font-size: 14px; + font-weight: 600; + color: #555d66; + text-shadow: none; +} + +.control-panel-themes #accordion-section-installed_themes { + border-top: 1px solid #ddd; +} + +.control-panel-themes .theme-section { + margin: 0; + position: relative; +} + +.control-panel-themes .customize-themes-section-title:focus, +.control-panel-themes .customize-themes-section-title:hover { + border-left-color: #0073aa; + color: #0073aa; + background: #f5f5f5; +} + +.customize-themes-section-title:not(.selected):after { + content: ""; + display: block; + position: absolute; + top: 9px; + right: 15px; + width: 18px; + height: 18px; + border-radius: 100%; + border: 1px solid #ccc; + background: #fff; +} + +.control-panel-themes .theme-section .customize-themes-section-title.selected:after { + content: "\f147"; + font: 16px/1 dashicons; + box-sizing: border-box; + width: 20px; + height: 20px; + padding: 3px 3px 1px 1px; /* Re-align the icon to the smaller grid */ + border-radius: 100%; + position: absolute; + top: 9px; + right: 15px; + background: #0073aa; + color: #fff; +} + +.control-panel-themes .customize-themes-section-title.selected { + color: #0073aa; +} + +#customize-theme-controls .themes.accordion-section-content { + position: relative; + left: 0; + padding: 0; + width: 100%; +} + +.loading .customize-themes-section .spinner { + display: block; + visibility: visible; + position: relative; + clear: both; + width: 20px; + height: 20px; + left: calc(50% - 10px); + float: none; + margin-top: 50px; +} + +.customize-themes-section .no-themes, +.customize-themes-section .no-themes-local { + display: none; +} + +.themes-section-installed_themes .theme .notice-success:not(.updated-message) { + display: none; /* Hide "installed" notice on installed themes tab. */ +} + +.customize-control-theme .theme { + width: 100%; + margin: 0; + border: 1px solid #ddd; + background: #fff; +} + +.customize-control-theme .theme .theme-name, .customize-control-theme .theme .theme-actions { + background: #fff; + border: none; +} + +.customize-control.customize-control-theme { /* override most properties on .customize-control */ + box-sizing: border-box; + width: 25%; + max-width: 600px; /* Max. screenshot size / 2 */ + margin: 0 25px 25px 0; + padding: 0; + clear: none; +} + +/* 5 columns above 2100px */ +@media screen and (min-width: 2101px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 125px ) / 5 - 1px ); /* 1px offset accounts for browser rounding, typical all grids */ + } +} + +/* 4 columns up to 2100px */ +@media screen and (min-width: 1601px) and (max-width: 2100px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 100px ) / 4 - 1px ); + } +} + +/* 3 columns up to 1600px */ +@media screen and (min-width: 1201px) and (max-width: 1600px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 75px ) / 3 - 1px ); + } +} + +/* 2 columns up to 1200px */ +@media screen and (min-width: 851px) and (max-width: 1200px) { + .customize-control.customize-control-theme { + width: calc( ( 100% - 50px ) / 2 - 1px ); + + } +} + +/* 1 column up to 850 px */ +@media screen and (max-width: 850px) { + .customize-control.customize-control-theme { + width: 100%; + } +} + +.wp-customizer .theme-browser .themes { + padding: 0 0 25px 25px; + transition: .18s margin-top linear; +} + +.wp-customizer .theme-browser .theme .theme-actions { + opacity: 1; +} + +#customize-controls h3.theme-name { + font-size: 15px; +} + +#customize-controls .theme-overlay .theme-name { + font-size: 32px; +} + +.customize-preview-header.themes-filter-bar { + position: fixed; + top: 0; + left: 300px; + width: calc(100% - 300px); + height: 46px; + background: #eee; + z-index: 10; + padding: 6px 25px; + box-sizing: border-box; + border-bottom: 1px solid #ddd; +} + +@media screen and (min-width: 1670px) { + .customize-preview-header.themes-filter-bar { + width: 82%; + right: 0; + left: initial; + } +} + +.themes-filter-bar .themes-filter-container { + margin: 0; + padding: 0; +} + +.themes-filter-bar .wp-filter-search { + line-height: 25px; + padding: 6px 10px 6px 30px; + max-width: 100%; + width: 40%; + min-width: 300px; + position: absolute; + top: 6px; + left: 25px; + height: 32px; + margin: 1px 0; +} + +/* Unstick the filter bar on short windows/screens. This breakpoint is based on the + current length of .org feature filters assuming translations do not wrap lines. */ +@media screen and (max-height:540px), screen and (max-width:1018px) { + .customize-preview-header.themes-filter-bar { + position: relative; + left: 0; + width: 100%; + margin: 0 0 25px 0; + } + .filter-drawer { + top: 46px; + } + .wp-customizer .theme-browser .themes { + padding: 0 0 25px 25px; + overflow: hidden; + } + + .control-panel-themes .customize-themes-full-container { + margin-top: 0; + padding: 0; + height: 100%; + width: calc(100% - 300px); + } +} + +@media screen and (max-width:1018px) { + .filter-drawer .filter-group { + width: calc( (100% - 50px) / 2); + } +} + +@media screen and (max-width:900px) { + .customize-preview-header.themes-filter-bar { + height: 86px; + padding-top: 46px; + } + + .themes-filter-bar .wp-filter-search { + width: calc(100% - 50px); + margin: 0; + min-width: 200px; + } + + .filter-drawer { + top: 86px; + } + + .control-panel-themes .filter-themes-count { + float: left; + } +} + +@media screen and (max-width:792px) { + .filter-drawer .filter-group { + width: calc( 100% - 25px); + } +} + +.control-panel-themes .customize-themes-mobile-back { + display: none; +} + +/* Mobile - toggle between themes and filters */ +@media screen and (max-width:600px) { + + .filter-drawer { + top: 132px; + } + + .wp-full-overlay.showing-themes .control-panel-themes .filter-themes-count .filter-themes { + display: block; + float: right; + } + + .control-panel-themes .customize-themes-full-container { + width: 100%; + margin: 0; + padding-top: 46px; + height: calc(100% - 46px); + z-index: 1; + display: none; + } + + .showing-themes .control-panel-themes .customize-themes-full-container { + display: block; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back { + display: block; + position: fixed; + top: 0; + left: 0; + background: #eee; + color: #444; + border-radius: 0; + box-shadow: none; + border: none; + height: 46px; + width: 100%; + z-index: 10; + text-align: left; + text-shadow: none; + border-bottom: 1px solid #ddd; + border-left: 4px solid transparent; + margin: 0; + padding: 0; + font-size: 0; + overflow: hidden; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:before { + left: 0; + top: 0; + height: 46px; + width: 26px; + display: block; + line-height: 46px; + padding: 0 8px 0 8px; + border-right: 1px solid #ddd; + } + + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:hover, + .wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:focus { + color: #0073aa; + background: #f3f3f5; + border-left-color: #0073aa; + outline: none; + box-shadow: none; + } + + .showing-themes #customize-header-actions { + display: none; + } + + #customize-controls { + width: 100%; + } +} + +/* Details View */ +.wp-customizer .theme-overlay { + display: none; +} + +.wp-customizer.modal-open .theme-overlay { + position: fixed; + left: 0; + top: 0; + right: 0; + bottom: 0; + z-index: 109; +} + +/* Avoid a z-index war by resetting elements that should be under the overlay. + This is likely required because of the way that sections and panels are positioned. */ +.wp-customizer.modal-open #customize-header-actions, +.wp-customizer.modal-open .control-panel-themes .filter-themes-count, +.wp-customizer.modal-open .control-panel-themes .customize-themes-section-title.selected:after { + z-index: -1; +} + +.wp-full-overlay.in-themes-panel.themes-panel-expanded #customize-controls .wp-full-overlay-sidebar-content { + overflow: visible; +} + +.wp-customizer .theme-overlay .theme-backdrop { + background: rgba( 238, 238, 238, 0.75 ); + position: fixed; + z-index: 110; +} + +.wp-customizer .theme-overlay .star-rating { + float: left; + margin-right: 8px; +} + +.wp-customizer .theme-rating .num-ratings { + line-height: 20px; +} + +.wp-customizer .theme-overlay .theme-wrap { + left: 90px; + right: 90px; + top: 45px; + bottom: 45px; + z-index: 120; +} + +.wp-customizer .theme-overlay .theme-actions { + text-align: right; /* Because there're only one or two actions, match the UI pattern of media modals and right-align the action. */ + padding: 10px 25px; + background: #eee; + border-top: 1px solid #ddd; +} + +.wp-customizer .theme-overlay .theme-actions .theme-install.preview { + margin-left: 8px; +} + +.control-panel-themes .theme-actions .delete-theme { + left: 15px; /* these override themes.css on mobile */ + right: auto; + bottom: auto; + position: absolute; +} + +.modal-open .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content { + overflow: visible; /* Prevent the top-level Customizer controls from becoming visible when elements on the right of the details modal are focused. */ +} + +.wp-customizer .theme-header { + background: #eee; +} + +.wp-customizer .theme-overlay .theme-header button, +.wp-customizer .theme-overlay .theme-header .close:before { + color: #444; +} + +.wp-customizer .theme-overlay .theme-header .close:focus, +.wp-customizer .theme-overlay .theme-header .close:hover, +.wp-customizer .theme-overlay .theme-header .right:focus, +.wp-customizer .theme-overlay .theme-header .right:hover, +.wp-customizer .theme-overlay .theme-header .left:focus, +.wp-customizer .theme-overlay .theme-header .left:hover { + background: #fff; + border-bottom: 4px solid #0073aa; + color: #0073aa; +} + +.wp-customizer .theme-overlay .theme-header .close:focus:before, +.wp-customizer .theme-overlay .theme-header .close:hover:before { + color: #0073aa; +} + +.wp-customizer .theme-overlay .theme-header button.disabled, +.wp-customizer .theme-overlay .theme-header button.disabled:hover, +.wp-customizer .theme-overlay .theme-header button.disabled:focus { + border-bottom: none; + background: transparent; + color: #ccc; +} + +/* Small Screens */ +@media (max-width:850px), (max-height:472px) { + .wp-customizer .theme-overlay .theme-wrap { + left: 0; + right: 0; + top: 0; + bottom: 0; + } + + .wp-customizer .theme-browser .themes { + padding-right: 25px; + } +} + +/* Handle cheaters. */ +body.cheatin { + font-size: medium; + height: auto; + background: #fff; + margin: 50px auto 2em; + padding: 1em 2em; + max-width: 700px; + min-width: 0; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +body.cheatin h1 { + border-bottom: 1px solid #ddd; + clear: both; + color: #555d66; + font-size: 24px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + margin: 30px 0 0 0; + padding: 0; + padding-bottom: 7px; +} + +body.cheatin p { + font-size: 14px; + line-height: 1.5; + margin: 25px 0 20px; +} + +/** + * Widgets and Menus common styles + */ + +/* higher specificity than .wp-core-ui .button */ +#customize-theme-controls .add-new-widget, +#customize-theme-controls .add-new-menu-item { + cursor: pointer; + float: right; + margin: 0; + margin-left: 10px; + transition: all 0.2s; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + outline: none; +} + +.reordering .add-new-widget, +.reordering .add-new-menu-item { + opacity: 0.2; + pointer-events: none; + cursor: not-allowed; /* doesn't work in conjunction with pointer-events */ +} + +.add-new-widget:before, +.add-new-menu-item:before, +#available-menu-items .new-content-item .add-content:before { + content: "\f132"; + display: inline-block; + position: relative; + left: -2px; + top: 0; + font: normal 20px/1 dashicons; + vertical-align: middle; + transition: all 0.2s; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* Reordering */ +.reorder-toggle { + float: right; + padding: 5px 8px; + text-decoration: none; + cursor: pointer; + outline: none; +} + +.reorder, +.reordering .reorder-done { + display: block; + padding: 5px 8px; +} + +.reorder-done, +.reordering .reorder { + display: none; +} + +.widget-reorder-nav span, +.menu-item-reorder-nav button { + position: relative; + overflow: hidden; + float: left; + display: block; + width: 33px; /* was 42px for mobile */ + height: 43px; + color: #82878c; + text-indent: -9999px; + cursor: pointer; + outline: none; +} + +.menu-item-reorder-nav button { + width: 30px; + height: 40px; + background: transparent; + border: none; + box-shadow: none; +} + +.widget-reorder-nav span:before, +.menu-item-reorder-nav button:before { + display: inline-block; + position: absolute; + top: 0; + right: 0; + width: 100%; + height: 100%; + font: normal 20px/43px dashicons; + text-align: center; + text-indent: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.widget-reorder-nav span:hover, +.widget-reorder-nav span:focus, +.menu-item-reorder-nav button:hover, +.menu-item-reorder-nav button:focus { + color: #191e23; + background: #eee; +} + +.move-widget-down:before, +.menus-move-down:before { + content: "\f347"; +} + +.move-widget-up:before, +.menus-move-up:before { + content: "\f343"; +} + +#customize-theme-controls .first-widget .move-widget-up, +#customize-theme-controls .last-widget .move-widget-down, +.move-up-disabled .menus-move-up, +.move-down-disabled .menus-move-down, +.move-right-disabled .menus-move-right, +.move-left-disabled .menus-move-left { + color: #d5d5d5; + background-color: #fff; + cursor: default; + pointer-events: none; +} + +/** + * New widget and Add-menu-items modes and panels + */ + +.wp-full-overlay-main { + right: auto; /* this overrides a right: 0; which causes the preview to resize, I'd rather have it go off screen at the normal size. */ + width: 100%; +} + +body.adding-widget .add-new-widget, +body.adding-widget .add-new-widget:hover, +.adding-menu-items .add-new-menu-item, +.adding-menu-items .add-new-menu-item:hover, +.add-menu-toggle.open, +.add-menu-toggle.open:hover { + background: #eee; + border-color: #929793; + color: #32373c; + box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5); +} + +body.adding-widget .add-new-widget:before, +.adding-menu-items .add-new-menu-item:before, +#accordion-section-add_menu .add-new-menu-item.open:before { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); +} + +#available-widgets, +#available-menu-items { + position: absolute; + top: 0; + bottom: 0; + left: -301px; + visibility: hidden; + overflow-x: hidden; + overflow-y: auto; + width: 300px; + margin: 0; + z-index: 4; + background: #eee; + transition: left .18s; + border-right: 1px solid #ddd; +} + +#available-widgets .customize-section-title, +#available-menu-items .customize-section-title { + display: none; +} + +#available-widgets-list { + top: 60px; + position: absolute; + overflow: auto; + bottom: 0; + width: 100%; + border-top: 1px solid #ddd; +} + +.no-widgets-found #available-widgets-list { + border-top: none; +} + +#available-widgets-filter { + position: fixed; + top: 0; + z-index: 1; + width: 300px; + background: #eee; +} + +/* search field container */ +#available-widgets-filter, +#available-menu-items-search .accordion-section-title { + padding: 13px 15px; + box-sizing: border-box; +} + +#available-widgets-filter input, +#available-menu-items-search input { + width: 100%; + height: 32px; + margin: 1px 0; + padding: 6px 30px; +} + +#available-widgets-filter input::-ms-clear, +#available-menu-items-search input::-ms-clear { + display: none; /* remove the "x" in IE, which conflicts with the "x" icon on button.clear-results */ +} + +#available-menu-items-search .search-icon, +#available-widgets-filter .search-icon { + display: block; + position: absolute; + top: 15px; /* 13 container padding +1 input margin +1 input border */ + left: 16px; + width: 30px; + height: 30px; + line-height: 28px; + text-align: center; + color: #72777c; +} + +#available-widgets-filter .clear-results, +#available-menu-items-search .clear-results { + position: absolute; + top: 15px; /* 13 container padding +1 input margin +1 input border */ + right: 16px; + width: 30px; + height: 30px; + padding: 0; + border: 0; + cursor: pointer; + background: none; + color: #a00; + text-decoration: none; + outline: 0; +} + +#available-widgets-filter .clear-results, +#available-menu-items-search .clear-results, +#available-menu-items-search.loading .clear-results.is-visible { + display: none; +} + +#available-widgets-filter .clear-results.is-visible, +#available-menu-items-search .clear-results.is-visible { + display: block; +} + +#available-widgets-filter .clear-results:before, +#available-menu-items-search .clear-results:before { + content: "\f335"; + font: normal 20px/1 dashicons; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#available-widgets-filter .clear-results:hover, +#available-widgets-filter .clear-results:focus, +#available-menu-items-search .clear-results:hover, +#available-menu-items-search .clear-results:focus { + color: #dc3232; +} + +#available-widgets-filter .clear-results:focus, +#available-menu-items-search .clear-results:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#available-menu-items-search .search-icon:after, +#available-widgets-filter .search-icon:after, +.themes-filter-bar .search-icon:after { + content: "\f179"; + font: normal 20px/1 dashicons; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.themes-filter-bar .search-icon { + position: absolute; + top: 7px; + left: 26px; + z-index: 1; + color: #72777c; + height: 30px; + width: 30px; + line-height: 2; + text-align: center; +} + +.no-widgets-found-message { + display: none; + margin: 0; + padding: 0 15px; + line-height: inherit; +} + +.no-widgets-found .no-widgets-found-message { + display: block; +} + +#available-widgets .widget-top, +#available-widgets .widget-top:hover, +#available-menu-items .item-top, +#available-menu-items .item-top:hover { + border: none; + background: transparent; + box-shadow: none; +} + +#available-widgets .widget-tpl, +#available-menu-items .item-tpl { + position: relative; + padding: 15px 15px 15px 60px; + background: #fff; + border-bottom: 1px solid #ddd; + border-left: 4px solid #fff; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; + cursor: pointer; + display: none; +} + +#available-widgets .widget, +#available-menu-items .item { + position: static; +} + + +/* Responsive */ +.customize-controls-preview-toggle { + display: none; +} + +@media only screen and (max-width: 782px) { + .wp-customizer .theme:not(.active):hover .theme-actions, + .wp-customizer .theme:not(.active):focus .theme-actions { + display: block; + } + + .wp-customizer .theme-browser .theme.active .theme-name span { + display: inline; + } + + .customize-control-header button.random .dice { + margin-top: 0; + } + + .customize-control-radio .customize-inside-control-row, + .customize-control-checkbox .customize-inside-control-row, + .customize-control-nav_menu_auto_add .customize-inside-control-row { + margin-left: 32px; + } + + .customize-control-radio input, + .customize-control-checkbox input, + .customize-control-nav_menu_auto_add input { + margin-left: -32px; + } + + .customize-control input[type="radio"] + label + br, + .customize-control input[type="checkbox"] + label + br { + line-height: 32px; /* For widgets checkboxes */ + } + + .customize-control .date-time-fields select { + height: 39px; + } + + .date-time-fields .date-input.month { + width: 79px; + } + + .date-time-fields .date-input.day, + .date-time-fields .date-input.hour, + .date-time-fields .date-input.minute { + width: 55px; + } + + .date-time-fields .date-input.year { + width: 80px; + } + + .date-time-fields .date-timezone { + line-height: 3.2; + } + + #customize-control-changeset_preview_link a { + bottom: 16px; + } + + .preview-link-wrapper .customize-copy-preview-link.preview-control-element.button { + bottom: 10px; + } + + .media-widget-control .media-widget-buttons .button.edit-media, + .media-widget-control .media-widget-buttons .button.change-media, + .media-widget-control .media-widget-buttons .button.select-media { + margin-top: 12px; + } + + .wp-core-ui .themes-filter-bar .feature-filter-toggle { + margin: 3px 0 3px 25px; + } +} + +@media screen and ( max-width: 1200px ) { + .outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, + .adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main, + .adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main { + left: 67%; + } +} + +@media screen and ( max-width: 640px ) { + + /* when the sidebar is collapsed and switching to responsive view, + bring it back see ticket #35220 */ + .wp-full-overlay.collapsed #customize-controls { + margin-left: 0; + } + + .wp-full-overlay-sidebar .wp-full-overlay-sidebar-content { + bottom: 0; + } + + .customize-controls-preview-toggle { + display: block; + position: absolute; + top: 0; + left: 48px; + line-height: 45px; + font-size: 14px; + padding: 0 12px; + margin: 0; + height: 45px; + background: #eee; + border: 0; + border-right: 1px solid #ddd; + color: #555d66; + cursor: pointer; + transition: color .1s ease-in-out, background .1s ease-in-out; + } + + #customize-footer-actions, + /*#customize-preview,*/ + .customize-controls-preview-toggle .controls, + .preview-only .wp-full-overlay-sidebar-content, + .preview-only .customize-controls-preview-toggle .preview { + display: none; + } + + .preview-only #customize-save-button-wrapper { + margin-top: -46px; + } + + .customize-controls-preview-toggle .preview:before, + .customize-controls-preview-toggle .controls:before { + font: normal 20px/1 dashicons; + content: "\f177"; + position: relative; + top: 4px; + margin-right: 6px; + } + + .customize-controls-preview-toggle .controls:before { + content: "\f540"; + } + + .preview-only #customize-controls { + height: 45px; + } + + .preview-only #customize-preview, + .preview-only .customize-controls-preview-toggle .controls { + display: block; + } + + .wp-core-ui.wp-customizer .button { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + } + + #publish-settings { + height: 31px; + } + + #customize-control-changeset_status .customize-inside-control-row { + padding-top: 15px; + } + + body.adding-widget div#available-widgets, + body.adding-menu-items div#available-menu-items, + body.outer-section-open div#customize-sidebar-outer-content { + width: 100%; + } + + #available-widgets .customize-section-title, + #available-menu-items .customize-section-title { + display: block; + margin: 0; + } + + #available-widgets .customize-section-back, + #available-menu-items .customize-section-back { + height: 69px; + } + + #available-widgets .customize-section-title h3, + #available-menu-items .customize-section-title h3 { + font-size: 20px; + font-weight: 200; + padding: 9px 10px 12px 14px; + margin: 0; + line-height: 24px; + color: #555d66; + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + #available-widgets .customize-section-title .customize-action, + #available-menu-items .customize-section-title .customize-action { + font-size: 13px; + display: block; + font-weight: 400; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + + #available-widgets-filter { + position: relative; + width: 100%; + height: auto; + } + + #available-widgets-list { + top: 130px; + } + + #available-menu-items-search .clear-results, + #available-menu-items-search .search-icon { + top: 85px; /* 70 section title height + 13 container padding +1 input margin +1 input border */ + } + + .reorder, + .reordering .reorder-done { + padding: 8px; + } + + .wp-core-ui .themes-filter-bar .feature-filter-toggle { + margin: 0; + } + + .theme-browser .theme.active .theme-actions, + .wp-customizer .theme-browser .theme .theme-actions { + padding: 9px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); + } +} + +@media screen and ( max-width: 600px ) { + .theme-browser .theme.active .theme-actions, + .wp-customizer .theme-browser .theme .theme-actions { + padding: 8px 15px; + box-shadow: none; + } + + .wp-full-overlay.expanded { + margin-left: 0; + } + + body.adding-widget div#available-widgets, + body.adding-menu-items div#available-menu-items, + body.outer-section-open div#customize-sidebar-outer-content { + top: 46px; + z-index: 10; + } + + body.wp-customizer .wp-full-overlay.expanded #customize-sidebar-outer-content { + left: -100%; + } + + body.wp-customizer.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content { + left: 0; + } +} diff --git a/backend/wp-admin/css/customize-controls.min.css b/backend/wp-admin/css/customize-controls.min.css new file mode 100644 index 0000000..f6cf3dd --- /dev/null +++ b/backend/wp-admin/css/customize-controls.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#customize-controls .wp-full-overlay-sidebar-content,#customize-sidebar-outer-content{overflow-x:hidden;overflow-y:auto}.customize-control-checkbox label,.customize-control-radio label,.customize-control-site_icon .favicon-preview .browser-preview{vertical-align:top}body{overflow:hidden;-webkit-text-size-adjust:100%}.customize-controls-close,.widget-control-actions a{text-decoration:none}#customize-controls h3{font-size:14px}#customize-controls img{max-width:100%}#customize-controls .submit{text-align:center}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked{background-color:rgba(0,0,0,.7);padding:25px}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .customize-changeset-locked-message{margin-left:auto;margin-right:auto;max-width:366px;min-height:64px;width:auto;padding:25px 25px 25px 109px;position:relative;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);line-height:1.5;overflow-y:auto;text-align:left;top:calc(50% - 100px)}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .currently-editing{margin-top:0}#customize-controls #customize-notifications-area .notice.notification-overlay.notification-changeset-locked .action-buttons{margin-bottom:0}.customize-changeset-locked-avatar{width:64px;position:absolute;left:25px;top:25px}.wp-core-ui.wp-customizer .customize-changeset-locked-message a.button{margin-right:10px;margin-top:0}#customize-controls .description{color:#555d66}#customize-save-button-wrapper{float:right;margin-top:9px}body:not(.ready) #customize-save-button-wrapper .save{visibility:hidden}#customize-save-button-wrapper .save{float:left;border-radius:3px;box-shadow:none;margin-top:0}#customize-save-button-wrapper .save:focus,#publish-settings:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}#customize-save-button-wrapper .save.has-next-sibling{border-radius:3px 0 0 3px}#customize-sidebar-outer-content{position:absolute;top:0;bottom:0;left:0;visibility:hidden;width:100%;margin:0;z-index:-1;background:#eee;transition:left .18s;border-right:1px solid #ddd;border-left:1px solid #ddd;height:100%}#customize-theme-controls .control-section-outer{display:none!important}#customize-outer-theme-controls .accordion-section-content{padding:12px}#customize-outer-theme-controls .accordion-section-content.open{display:block}.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content{visibility:visible;left:100%;transition:left .18s}.customize-outer-pane-parent{margin:0}.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main{left:300px;opacity:.4}.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-menu-items .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-tablet .wp-full-overlay-main{left:64%}#customize-outer-theme-controls li.notice{padding-top:8px;padding-bottom:8px;margin-left:0;margin-bottom:10px}#publish-settings{text-indent:0;border-radius:0 3px 3px 0;padding-left:0;padding-right:0;box-shadow:none;font-size:14px;width:30px;float:left;-webkit-transform:none;transform:none;margin-top:0}body.trashing #customize-save-button-wrapper .save,body.trashing #publish-settings,body:not(.ready) #publish-settings{display:none}#customize-header-actions .spinner{margin-top:13px;margin-right:4px}.saving #customize-header-actions .spinner,.trashing #customize-header-actions .spinner{visibility:visible}#customize-header-actions{border-bottom:1px solid #ddd}.outer-section-open #customize-controls .wp-full-overlay-sidebar-content{background:#eee}#customize-controls .customize-info{border:none;border-bottom:1px solid #ddd;margin-bottom:15px}#customize-control-changeset_preview_link input,#customize-control-changeset_status .customize-inside-control-row{background-color:#fff;border-bottom:1px solid #ddd;box-sizing:content-box;width:100%;margin-left:-12px;padding-left:12px;padding-right:12px}#customize-control-trash_changeset{margin-top:20px}#customize-control-trash_changeset .button-link{position:relative;padding-left:24px;display:inline-block}#customize-control-trash_changeset .button-link:before{content:"\f182";font:400 22px dashicons;text-decoration:none;position:absolute;left:0;top:-2px}#customize-controls .date-input:invalid{border-color:#dc3232}#customize-control-changeset_status .customize-inside-control-row{padding-top:10px;padding-bottom:10px;font-weight:500}#customize-control-changeset_status .customize-inside-control-row:first-of-type{border-top:1px solid #ddd}#customize-control-changeset_status .customize-control-title{margin-bottom:6px}#customize-control-changeset_status input{margin-left:0}#customize-control-changeset_preview_link{position:relative;display:block}.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button{margin:0;position:absolute;bottom:9px;right:0}.preview-link-wrapper{position:relative}.customize-copy-preview-link:after,.customize-copy-preview-link:before{content:"";height:28px;position:absolute;background:#fff;top:-1px}.customize-copy-preview-link:before{left:-10px;width:9px;opacity:.75}.customize-copy-preview-link:after{left:-5px;width:4px;opacity:.8}#customize-control-changeset_preview_link input{line-height:2.5;border-top:1px solid #ddd;border-left:none;border-right:none;text-indent:-999px;color:#fff}#customize-control-changeset_preview_link label{position:relative;display:block}#customize-control-changeset_preview_link a{display:inline-block;position:absolute;white-space:nowrap;overflow:hidden;width:90%;bottom:14px;font-size:14px;text-decoration:none}#customize-control-changeset_preview_link a.disabled,#customize-control-changeset_preview_link a.disabled:active,#customize-control-changeset_preview_link a.disabled:focus,#customize-control-changeset_preview_link a.disabled:visited{color:#000;opacity:.4;cursor:default;outline:0;box-shadow:none}#sub-accordion-section-publish_settings .customize-section-description-container{display:none}#customize-controls .customize-info.section-meta{margin-bottom:15px}.customize-control-date_time .customize-control-description+.date-time-fields.includes-time{margin-top:10px}.customize-control.customize-control-date_time .date-time-fields .date-input.day{margin-right:0}.date-time-fields .date-input.month{width:auto;margin:0}.date-time-fields .date-input.day,.date-time-fields .date-input.hour,.date-time-fields .date-input.minute{width:46px}.date-time-fields .date-input.year{width:60px}.date-time-fields .date-input.meridian{width:auto;margin:0}.date-time-fields .time-row{margin-top:12px}.date-time-fields .date-timezone{line-height:2.2;text-decoration:none}#customize-control-changeset_preview_link{margin-top:6px}#customize-control-changeset_status{margin-bottom:0;padding-bottom:0}#customize-control-changeset_scheduled_date{box-sizing:content-box;width:100%;margin-left:-12px;padding:12px;background:#fff;border-bottom:1px solid #ddd;margin-bottom:0}#customize-control-changeset_scheduled_date .customize-control-description{font-style:normal}#customize-controls .customize-info.is-in-view,#customize-controls .customize-section-title.is-in-view{position:absolute;z-index:9;width:100%;box-shadow:0 1px 0 rgba(0,0,0,.1)}#customize-controls .customize-section-title.is-in-view{margin-top:0}#customize-controls .customize-info.is-in-view+.accordion-section{margin-top:15px}#customize-controls .customize-info .customize-panel-description p:first-child,#customize-controls .customize-info .customize-section-description p:first-child,.no-widget-areas-rendered-notice p:first-child{margin-top:0}#customize-controls .customize-info.is-sticky,#customize-controls .customize-section-title.is-sticky{position:fixed;top:46px}#customize-controls .customize-info .accordion-section-title{background:#fff;color:#555d66;border-left:none;border-right:none;border-bottom:none;cursor:default}#customize-controls .customize-info .accordion-section-title:focus:after,#customize-controls .customize-info .accordion-section-title:hover:after,#customize-controls .customize-info.open .accordion-section-title:after{color:#32373c}#customize-controls .customize-info .accordion-section-title:after{display:none}#customize-controls .customize-info .preview-notice{font-size:13px;line-height:24px}#customize-controls .customize-info .panel-title,#customize-controls .customize-pane-child .customize-section-title h3,#customize-controls .customize-pane-child h3.customize-section-title,#customize-outer-theme-controls .customize-pane-child .customize-section-title h3,#customize-outer-theme-controls .customize-pane-child h3.customize-section-title{font-size:20px;font-weight:200;line-height:26px;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .customize-section-title span.customize-action{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#customize-controls .customize-info .customize-help-toggle{position:absolute;top:4px;right:1px;padding:20px 20px 10px 10px;width:20px;height:20px;cursor:pointer;box-shadow:none;-webkit-appearance:none;background:0 0;color:#555d66;border:none}#customize-controls .customize-info .customize-help-toggle:before{position:absolute;top:5px;left:6px}#customize-controls .customize-info .customize-help-toggle:focus,#customize-controls .customize-info .customize-help-toggle:hover,#customize-controls .customize-info.open .customize-help-toggle{color:#0073aa}#customize-controls .customize-info .customize-panel-description,#customize-controls .customize-info .customize-section-description,#customize-controls .no-widget-areas-rendered-notice,#customize-outer-theme-controls .customize-info .customize-section-description{color:#555d66;display:none;background:#fff;padding:12px 15px;border-top:1px solid #ddd}#customize-controls .customize-info .customize-panel-description.open+.no-widget-areas-rendered-notice{border-top:none}.no-widget-areas-rendered-notice{font-style:italic}.no-widget-areas-rendered-notice p:last-child{margin-bottom:0}#customize-controls .customize-info .customize-section-description{margin-bottom:15px}#customize-controls .customize-info .customize-panel-description p:last-child,#customize-controls .customize-info .customize-section-description p:last-child{margin-bottom:0}#customize-controls .current-panel .control-section>h3.accordion-section-title{padding-right:30px}#customize-outer-theme-controls .control-section,#customize-theme-controls .control-section{border:none}#customize-outer-theme-controls .accordion-section-title,#customize-theme-controls .accordion-section-title{color:#555d66;background-color:#fff;border-bottom:1px solid #ddd;border-left:4px solid #fff;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out}#customize-controls #customize-theme-controls .customize-themes-panel .accordion-section-title{color:#555;background-color:#fff;border-left:4px solid #fff}#customize-outer-theme-controls .accordion-section-title:after,#customize-theme-controls .accordion-section-title:after{content:"\f345";color:#a0a5aa}#customize-outer-theme-controls .accordion-section-content,#customize-theme-controls .accordion-section-content{color:#555d66;background:0 0}#customize-controls .control-section .accordion-section-title:focus,#customize-controls .control-section .accordion-section-title:hover,#customize-controls .control-section.open .accordion-section-title,#customize-controls .control-section:hover>.accordion-section-title{color:#0073aa;background:#f3f3f5;border-left-color:#0073aa}#accordion-section-themes+.control-section{border-top:1px solid #ddd}.js .control-section .accordion-section-title:focus,.js .control-section .accordion-section-title:hover,.js .control-section.open .accordion-section-title,.js .control-section:hover .accordion-section-title{background:#f3f3f5}#customize-outer-theme-controls .control-section .accordion-section-title:focus:after,#customize-outer-theme-controls .control-section .accordion-section-title:hover:after,#customize-outer-theme-controls .control-section.open .accordion-section-title:after,#customize-outer-theme-controls .control-section:hover>.accordion-section-title:after,#customize-theme-controls .control-section .accordion-section-title:focus:after,#customize-theme-controls .control-section .accordion-section-title:hover:after,#customize-theme-controls .control-section.open .accordion-section-title:after,#customize-theme-controls .control-section:hover>.accordion-section-title:after{color:#0073aa}#customize-theme-controls .control-section.open{border-bottom:1px solid #eee}#customize-outer-theme-controls .control-section.open .accordion-section-title,#customize-theme-controls .control-section.open .accordion-section-title{border-bottom-color:#eee!important}#customize-theme-controls .control-section:last-of-type.open,#customize-theme-controls .control-section:last-of-type>.accordion-section-title{border-bottom-color:#ddd}#customize-theme-controls .control-panel-content:not(.control-panel-nav_menus) .control-section:nth-child(2),#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu,#customize-theme-controls .control-section-nav_menu_locations .accordion-section-title{border-top:1px solid #ddd}#customize-theme-controls .control-panel-nav_menus .control-section-nav_menu+.control-section-nav_menu{border-top:none}#customize-theme-controls>ul{margin:0}#customize-theme-controls .accordion-section-content{position:absolute;top:0;left:100%;width:100%;margin:0;padding:12px;box-sizing:border-box}#customize-info,#customize-theme-controls .customize-pane-child,#customize-theme-controls .customize-pane-parent{width:100%;margin:0;padding:0;box-sizing:border-box;transition:.18s -webkit-transform cubic-bezier(.645,.045,.355,1);transition:.18s transform cubic-bezier(.645,.045,.355,1);transition:.18s transform cubic-bezier(.645,.045,.355,1),.18s -webkit-transform cubic-bezier(.645,.045,.355,1)}#customize-theme-controls .customize-pane-child.skip-transition{transition:none}#customize-info,#customize-theme-controls .customize-pane-parent{position:relative;visibility:visible;height:auto;max-height:none;overflow:auto;-webkit-transform:none;transform:none}#customize-theme-controls .customize-pane-child{position:absolute;top:0;left:0;visibility:hidden;height:0;max-height:none;overflow:hidden;-webkit-transform:translateX(100%);transform:translateX(100%)}#customize-theme-controls .customize-pane-child.current-panel,#customize-theme-controls .customize-pane-child.open{-webkit-transform:none;transform:none}.in-sub-panel #customize-info,.in-sub-panel #customize-theme-controls .customize-pane-parent,.in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel,.section-open #customize-info,.section-open #customize-theme-controls .customize-pane-parent{visibility:hidden;height:0;overflow:hidden;-webkit-transform:translateX(-100%);transform:translateX(-100%)}#customize-theme-controls .customize-pane-child.busy,#customize-theme-controls .customize-pane-child.current-panel,#customize-theme-controls .customize-pane-child.open,.busy.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel,.in-sub-panel #customize-info.busy,.in-sub-panel #customize-theme-controls .customize-pane-parent.busy,.section-open #customize-info.busy,.section-open #customize-theme-controls .customize-pane-parent.busy{visibility:visible;height:auto;overflow:auto}#customize-theme-controls .customize-pane-child.accordion-section-content,#customize-theme-controls .customize-pane-child.accordion-sub-container{display:block;overflow-x:hidden}#customize-theme-controls .customize-pane-child.accordion-section-content{padding:12px}#customize-theme-controls .customize-pane-child.menu li{position:static}.control-section-nav_menu .customize-section-description-container,.control-section-new_menu .customize-section-description-container,.customize-section-description-container{margin-bottom:15px}.control-section-nav_menu .customize-control,.control-section-new_menu .customize-control{margin-bottom:0}.customize-section-title{margin:-12px -12px 0;border-bottom:1px solid #ddd;background:#fff}div.customize-section-description{margin-top:22px}.customize-info div.customize-section-description,div.customize-section-description p:first-child{margin-top:0}div.customize-section-description p:last-child{margin-bottom:0}#customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child{border-bottom:1px solid #ddd;padding:12px}.ios #customize-theme-controls .customize-themes-panel h3.customize-section-title:first-child{padding:12px 12px 13px}.customize-section-title h3,h3.customize-section-title{padding:10px 10px 12px 14px;margin:0;line-height:21px;color:#555d66}.accordion-sub-container.control-panel-content{display:none;position:absolute;top:0;width:100%}.accordion-sub-container.control-panel-content.busy{display:block}.current-panel .accordion-sub-container.control-panel-content{width:100%}.customize-controls-close{display:block;position:absolute;top:0;left:0;width:45px;height:41px;padding:0 2px 0 0;background:#eee;border:none;border-top:4px solid #eee;border-right:1px solid #ddd;color:#444;text-align:left;cursor:pointer;transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out;box-sizing:content-box}.customize-panel-back,.customize-section-back{display:block;float:left;width:48px;height:71px;padding:0 24px 0 0;margin:0;background:#fff;border:none;border-right:1px solid #ddd;border-left:4px solid #fff;box-shadow:none;cursor:pointer;transition:color .15s ease-in-out,border-color .15s ease-in-out,background .15s ease-in-out}.customize-section-back{height:74px}.ios .customize-panel-back{display:none}.ios .expanded.in-sub-panel .customize-panel-back{display:block}#customize-controls .panel-meta.customize-info .accordion-section-title{margin-left:48px;border-left:none}#customize-controls .cannot-expand:hover .accordion-section-title,#customize-controls .panel-meta.customize-info .accordion-section-title:hover{background:#fff;color:#555d66;border-left-color:#fff}.customize-controls-close:focus,.customize-controls-close:hover,.customize-controls-preview-toggle:focus,.customize-controls-preview-toggle:hover{background:#fff;color:#0073aa;border-top-color:#0073aa;outline:0;box-shadow:none}.customize-panel-back:focus,.customize-panel-back:hover,.customize-section-back:focus,.customize-section-back:hover{color:#0073aa;background:#f3f3f5;border-left-color:#0073aa;outline:0;box-shadow:none}.customize-controls-close:before{font:400 22px/45px dashicons;content:"\f335";position:relative;top:-3px;left:13px}.customize-panel-back:before,.customize-section-back:before{font:400 20px/72px dashicons;content:"\f341";position:relative;left:9px}.wp-full-overlay-sidebar .wp-full-overlay-header{background-color:#eee;transition:padding ease-in-out .18s}.in-sub-panel .wp-full-overlay-sidebar .wp-full-overlay-header{padding-left:62px}p.customize-section-description{font-style:normal;margin-top:22px;margin-bottom:0}.customize-section-description ul{margin-left:1em}.customize-section-description ul>li{list-style:disc}.section-description-buttons{text-align:right}.section-description-buttons button.button-link{color:#0073aa;text-decoration:underline}.customize-control{width:100%;float:left;clear:both;margin-bottom:12px}.customize-control input[type=radio],.customize-control input[type=checkbox],.customize-control select{line-height:28px}.customize-control input[type=number],.customize-control input[type=search],.customize-control input[type=tel],.customize-control input[type=url],.customize-control input[type=text],.customize-control input[type=password],.customize-control input[type=email]{width:100%;line-height:18px;margin:0}.customize-control-hidden{margin:0}.customize-control-textarea textarea{width:100%;resize:vertical}.customize-control select{width:100%;height:28px;line-height:28px}.customize-control select[multiple]{height:auto}.customize-control-title{display:block;font-size:14px;line-height:24px;font-weight:600;margin-bottom:4px}.customize-control-description{display:block;font-style:italic;line-height:18px;margin-top:0;margin-bottom:5px}.customize-section-description a.external-link:after{font:16px/11px dashicons;content:"\f310";top:3px;position:relative;padding-left:3px;display:inline-block;text-decoration:none}.customize-control-color .color-picker,.customize-control-upload div{line-height:28px}.customize-control .customize-inside-control-row{line-height:20px;display:block;margin-left:24px;padding-top:6px;padding-bottom:6px}.customize-control-checkbox input,.customize-control-nav_menu_auto_add input,.customize-control-radio input{margin-right:4px;margin-left:-24px}.customize-control-radio{padding:5px 0 10px}.customize-control-radio .customize-control-title{margin-bottom:0;line-height:22px}.customize-control-radio .customize-control-title+.customize-control-description{margin-top:7px}.customize-control .attachment-thumb.type-icon{float:left;margin:10px;width:auto}.customize-control .attachment-title{font-weight:600;margin:0;padding:5px 10px}.customize-control .attachment-meta{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0;padding:0 10px}.customize-control .attachment-meta-title{padding-top:7px}.customize-control .thumbnail-image,.customize-control .wp-media-wrapper.wp-video,.customize-control-header .current{line-height:0}.customize-control .thumbnail-image img{cursor:pointer}#customize-controls .thumbnail-audio .thumbnail{max-width:64px;max-height:64px;margin:10px;float:left}#available-menu-items .accordion-section-content .new-content-item,.customize-control-dropdown-pages .new-content-item{width:calc(100% - 30px);padding:8px 15px;position:absolute;bottom:0;z-index:10;background:#eee;display:-webkit-box;display:flex}.customize-control-dropdown-pages .new-content-item{width:100%;padding:5px 0 5px 1px;position:relative}#available-menu-items .new-content-item .create-item-input,.customize-control-dropdown-pages .new-content-item .create-item-input{-webkit-box-flex:10;flex-grow:10}#available-menu-items .new-content-item .add-content,.customize-control-dropdown-pages .new-content-item .add-content{margin:2px 0 2px 6px;-webkit-box-flex:10;flex-grow:1}.customize-control-dropdown-pages .new-content-item .create-item-input.invalid{border:1px solid #dc3232}.customize-control-dropdown-pages .add-new-toggle{margin-left:1px;font-weight:600;line-height:28px}#customize-preview iframe{width:100%;height:100%;position:absolute}#customize-preview iframe+iframe{visibility:hidden}.wp-full-overlay-sidebar{background:#eee;border-right:1px solid #ddd}#customize-controls .customize-control-notifications-container{margin:4px 0 8px;padding:0;cursor:default}#customize-controls .customize-control-widget_form.has-error .widget .widget-top,.customize-control-nav_menu_item.has-error .menu-item-bar .menu-item-handle{box-shadow:inset 0 0 0 2px #dc3232;transition:.15s box-shadow linear}#customize-controls .customize-control-notifications-container li.notice{list-style:none;margin:0 0 6px;padding:9px 14px;overflow:hidden}#customize-controls .customize-control-notifications-container .notice.is-dismissible{padding-right:38px}.customize-control-notifications-container li.notice:last-child{margin-bottom:0}#customize-controls .customize-control-nav_menu_item .customize-control-notifications-container{margin-top:0}#customize-controls .customize-control-widget_form .customize-control-notifications-container{margin-top:8px}.customize-control-text.has-error input{outline:#dc3232 solid 2px}#customize-controls #customize-notifications-area{position:absolute;top:46px;width:100%;border-bottom:1px solid #ddd;display:block;padding:0;margin:0}.wp-full-overlay.collapsed #customize-controls #customize-notifications-area{display:none!important}#customize-controls #customize-notifications-area:not(.has-overlay-notifications),#customize-controls .customize-section-title>.customize-control-notifications-container:not(.has-overlay-notifications),#customize-controls .panel-meta>.customize-control-notifications-container:not(.has-overlay-notifications){max-height:210px;overflow-x:hidden;overflow-y:auto}#customize-controls #customize-notifications-area .notice,#customize-controls #customize-notifications-area>ul,#customize-controls .customize-section-title>.customize-control-notifications-container,#customize-controls .customize-section-title>.customize-control-notifications-container .notice,#customize-controls .panel-meta>.customize-control-notifications-container,#customize-controls .panel-meta>.customize-control-notifications-container .notice{margin:0}#customize-controls .customize-section-title>.customize-control-notifications-container,#customize-controls .panel-meta>.customize-control-notifications-container{border-top:1px solid #ddd}#customize-controls #customize-notifications-area .notice,#customize-controls .customize-section-title>.customize-control-notifications-container .notice,#customize-controls .panel-meta>.customize-control-notifications-container .notice{padding:9px 14px}#customize-controls #customize-notifications-area .notice.is-dismissible,#customize-controls .customize-section-title>.customize-control-notifications-container .notice.is-dismissible,#customize-controls .panel-meta>.customize-control-notifications-container .notice.is-dismissible{padding-right:38px}#customize-controls #customize-notifications-area .notice+.notice,#customize-controls .customize-section-title>.customize-control-notifications-container .notice+.notice,#customize-controls .panel-meta>.customize-control-notifications-container .notice+.notice{margin-top:1px}@-webkit-keyframes customize-fade-in{0%{opacity:0}100%{opacity:1}}@keyframes customize-fade-in{0%{opacity:0}100%{opacity:1}}#customize-controls #customize-notifications-area .notice.notification-overlay,#customize-controls .notice.notification-overlay{margin:0;border-left:0}#customize-controls .customize-control-notifications-container.has-overlay-notifications{-webkit-animation:customize-fade-in .5s;animation:customize-fade-in .5s;z-index:30}#customize-controls #customize-notifications-area .notice.notification-overlay .notification-message{clear:both;color:#191e23;font-size:18px;font-style:normal;margin:0;padding:2em 0;text-align:center;width:100%;display:block;top:50%;position:relative}#customize-control-show_on_front.has-error .customize-control-notifications-container,.customize-control .actions .button{margin-top:12px}#customize-control-show_on_front.has-error{margin-bottom:0}.accordion-section .dropdown{float:left;display:block;position:relative;cursor:pointer}.accordion-section .dropdown-content{overflow:hidden;float:left;min-width:30px;height:16px;line-height:16px;margin-right:16px;padding:4px 5px;border:2px solid #eee;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.customize-control .dropdown-arrow{position:absolute;top:0;bottom:0;right:0;width:20px;background:#eee}.customize-control .dropdown-arrow:after{content:"\f140";font:400 20px/1 dashicons;speak:none;display:block;padding:0;text-indent:0;text-align:center;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#32373c}.customize-control .dropdown-status{color:#32373c;background:#eee;display:none;max-width:112px}.customize-control-color .dropdown{margin-right:5px;margin-bottom:5px}.customize-control-color .dropdown .dropdown-content{background-color:#555d66;border:1px solid rgba(0,0,0,.15)}.customize-control-color .dropdown:hover .dropdown-content{border-color:rgba(0,0,0,.25)}.ios .wp-full-overlay{position:relative}.ios #customize-controls .wp-full-overlay-sidebar-content{-webkit-overflow-scrolling:touch}.customize-control-header .actions,.customize-control-header .uploaded{margin-bottom:18px}.customize-control-header .default button:not(.random),.customize-control-header .uploaded button:not(.random){width:100%;padding:0;margin:0;background:0 0;border:none;color:inherit;cursor:pointer}.customize-control-header button img{display:block}.customize-control .attachment-media-view .default-button,.customize-control .attachment-media-view .remove-button,.customize-control .attachment-media-view .upload-button,.customize-control-header button.new,.customize-control-header button.remove{width:auto;height:auto;white-space:normal}.customize-control .attachment-media-view .thumbnail,.customize-control-header .current .container{overflow:hidden}.customize-control .attachment-media-view .placeholder,.customize-control-header .placeholder{width:100%;position:relative;text-align:center;cursor:default;border:1px dashed #b4b9be;box-sizing:border-box;padding:9px 0;line-height:20px}.customize-control-header .inner{display:none;position:absolute;width:100%;color:#555d66;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.customize-control-header .inner,.customize-control-header .inner .dashicons{line-height:20px;top:8px}.customize-control-header .list .inner,.customize-control-header .list .inner .dashicons{top:9px}.customize-control-header .header-view{position:relative;width:100%;margin-bottom:12px}.customize-control-header .header-view:last-child{margin-bottom:0}.customize-control-header .header-view:after{border:0}.customize-control-header .header-view.selected .choice:focus{outline:0}.customize-control-header .header-view.selected:after{content:'';position:absolute;height:auto;top:0;left:0;bottom:0;right:0;border:4px solid #00a0d2;border-radius:2px}.customize-control-header .header-view.button.selected{border:0}#customize-controls .customize-section-description-container.section-meta.customize-info,#customize-theme-controls .control-panel-themes{border-bottom:none}.customize-control-header .uploaded .header-view .close{font-size:20px;color:#fff;background:#555d66;background:rgba(0,0,0,.5);position:absolute;top:10px;left:-999px;z-index:1;width:26px;height:26px;cursor:pointer}.customize-control-header .header-view .close:focus,.customize-control-header .header-view:hover .close{left:auto;right:10px}.customize-control-header .header-view .close:focus{outline:#5b9dd9 solid 1px}.customize-control-header .random.placeholder{cursor:pointer;border-radius:2px;height:40px}.customize-control-header button.random{width:100%;height:auto;min-height:40px;white-space:normal}.customize-control-header button.random .dice{margin-top:4px}.customize-control-header .header-view:hover>button.random .dice,.customize-control-header .placeholder:hover .dice{-webkit-animation:dice-color-change 3s infinite;animation:dice-color-change 3s infinite}.button-see-me{-webkit-animation:bounce .7s 1;animation:bounce .7s 1;-webkit-transform-origin:center bottom;transform-origin:center bottom}@-webkit-keyframes bounce{20%,53%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translate3d(0,0,0)}40%,43%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-12px,0)}70%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-6px,0)}90%{-webkit-transform:translate3d(0,-1px,0)}}@keyframes bounce{20%,53%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}40%,43%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-12px,0);transform:translate3d(0,-12px,0)}70%{-webkit-animation-timing-function:cubic-bezier(.755,.050,.855,.060);animation-timing-function:cubic-bezier(.755,.050,.855,.060);-webkit-transform:translate3d(0,-6px,0);transform:translate3d(0,-6px,0)}90%{-webkit-transform:translate3d(0,-1px,0);transform:translate3d(0,-1px,0)}}.customize-control-header .choice{position:relative;display:block;margin-bottom:9px}.customize-control-header .choice:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 3px 1px rgba(30,140,190,.8)}.customize-control-header .uploaded div:last-child>.choice{margin-bottom:0}.customize-control .attachment-media-view .thumbnail-image img,.customize-control-header img{max-width:100%}.customize-control .attachment-media-view .default-button,.customize-control .attachment-media-view .remove-button,.customize-control-header .remove{margin-right:8px}.customize-control-background_position .background-position-control .button-group{display:block}.customize-control-code_editor textarea{width:100%;font-family:Consolas,Monaco,monospace;font-size:12px;padding:6px 8px;-moz-tab-size:2;-o-tab-size:2;tab-size:2}.customize-control-code_editor .CodeMirror,.customize-control-code_editor textarea{height:14em}#sub-accordion-section-custom_css .customize-control-notifications-container{margin-bottom:15px}#customize-control-custom_css textarea{display:block;height:500px}.customize-section-description-container+#customize-control-custom_css .customize-control-title{margin-left:12px}.customize-section-description-container+#customize-control-custom_css:last-child textarea{border-right:0;border-left:0;height:calc(100vh - 185px);resize:none}.customize-section-description-container+#customize-control-custom_css:last-child{margin-left:-12px;width:299px;width:calc(100% + 24px);margin-bottom:-12px}.customize-section-description-container+#customize-control-custom_css:last-child .CodeMirror{height:calc(100vh - 185px)}.CodeMirror-hints,.CodeMirror-lint-tooltip{z-index:500000!important}.customize-section-description-container+#customize-control-custom_css:last-child .customize-control-notifications-container{margin-left:12px;margin-right:12px}.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:10px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}@media screen and (max-width:640px){.customize-section-description-container+#customize-control-custom_css:last-child{margin-right:0}.customize-section-description-container+#customize-control-custom_css:last-child textarea{height:calc(100vh - 140px)}}#customize-theme-controls .control-panel-themes>.accordion-section-title,#customize-theme-controls .control-panel-themes>.accordion-section-title:hover{cursor:default;background:#fff;color:#555d66;border-top:1px solid #ddd;border-bottom:1px solid #ddd;border-left:none;border-right:none;margin:0 0 15px;padding-right:100px}#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child,#customize-theme-controls .control-section-themes .customize-themes-panel .accordion-section-title:first-child:hover{border-top:0}#customize-theme-controls .control-section-themes>.accordion-section-title,#customize-theme-controls .control-section-themes>.accordion-section-title:hover{margin:0 0 15px}#customize-controls .customize-themes-panel .accordion-section-title,#customize-controls .customize-themes-panel .accordion-section-title:hover{margin:15px -8px}#customize-controls .control-section-themes .accordion-section-title,#customize-controls .customize-themes-panel .accordion-section-title{padding-right:100px}#customize-controls .control-section-themes .accordion-section-title span.customize-action,#customize-controls .customize-section-title span.customize-action,.control-panel-themes .accordion-section-title span.customize-action{font-size:13px;display:block;font-weight:400}.in-themes-panel.animating .control-panel-themes .filter-themes-count,.themes-filter-bar .feature-filter-toggle .filter-count-filters{display:none}#customize-theme-controls .control-panel-themes .accordion-section-title .change-theme{position:absolute;right:10px;top:50%;margin-top:-14px;font-weight:400}#customize-theme-controls .control-panel-themes>.accordion-section-title:after{display:none}.control-panel-themes .customize-themes-full-container{position:fixed;top:0;left:0;transition:.18s left ease-in-out;margin:0 0 0 300px;padding:71px 0 25px;overflow-y:scroll;width:calc(100% - 300px);height:calc(100% - 96px);background:#eee;z-index:20}@media screen and (min-width:1670px){.control-panel-themes .customize-themes-full-container{width:82%;right:0;left:initial}}.modal-open .control-panel-themes .customize-themes-full-container{overflow-y:visible}#customize-header-actions .customize-controls-preview-toggle,#customize-header-actions .spinner,#customize-save-button-wrapper{transition:.18s margin ease-in-out}#customize-footer-actions,#customize-footer-actions .collapse-sidebar{bottom:0;transition:.18s bottom ease-in-out}.in-themes-panel:not(.animating) #customize-footer-actions,.in-themes-panel:not(.animating) #customize-header-actions .customize-controls-preview-toggle,.in-themes-panel:not(.animating) #customize-header-actions .spinner,.in-themes-panel:not(.animating) #customize-preview{visibility:hidden}.wp-full-overlay.in-themes-panel{background:#eee}.in-themes-panel #customize-header-actions .customize-controls-preview-toggle,.in-themes-panel #customize-header-actions .spinner,.in-themes-panel #customize-save-button-wrapper{margin-top:-46px}.in-themes-panel #customize-footer-actions,.in-themes-panel #customize-footer-actions .collapse-sidebar{bottom:-45px}.in-themes-panel.wp-full-overlay .wp-full-overlay-sidebar-content{bottom:0}.themes-filter-bar .feature-filter-toggle{float:right;margin:3px 0 3px 25px}.themes-filter-bar .feature-filter-toggle:before{content:"\f111";margin:0 5px 0 0;font:400 16px/1 dashicons;vertical-align:text-bottom;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.themes-filter-bar .feature-filter-toggle.open{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.filter-drawer{box-sizing:border-box;width:100%;position:absolute;top:46px;left:0;padding:25px 0 25px 25px;border-top:0;margin:0;background:#eee;border-bottom:1px solid #ddd}.filter-drawer .filter-group{margin:0 25px 0 0;width:calc((100% - 75px)/ 3);min-width:200px;max-width:320px}@-webkit-keyframes themes-fade-in{0%,50%{opacity:0}100%{opacity:1}}@keyframes themes-fade-in{0%,50%{opacity:0}100%{opacity:1}}.control-panel-themes .customize-themes-full-container.animate{-webkit-animation:.6s themes-fade-in 1;animation:.6s themes-fade-in 1}.in-themes-panel:not(.animating) .control-panel-themes .filter-themes-count{-webkit-animation:.6s themes-fade-in 1;animation:.6s themes-fade-in 1}.control-panel-themes .filter-themes-count{position:relative;float:right;line-height:34px}.control-panel-themes .filter-themes-count .themes-displayed{font-weight:600;color:#555d66}.customize-themes-notifications{margin:0}.control-panel-themes .customize-themes-notifications .notice{margin:0 0 25px}.customize-themes-full-container .customize-themes-section{display:none!important;overflow:hidden}.customize-themes-full-container .customize-themes-section.current-section{display:list-item!important}.control-section .customize-section-text-before{padding:0 0 8px 15px;margin:15px 0 0;line-height:16px;border-bottom:1px solid #ddd;color:#555d66}.control-panel-themes .customize-themes-section-title{width:100%;background:#fff;box-shadow:none;outline:0;border-top:none;border-bottom:1px solid #ddd;border-left:4px solid #fff;border-right:none;cursor:pointer;padding:10px 15px;position:relative;text-align:left;font-size:14px;font-weight:600;color:#555d66;text-shadow:none}.control-panel-themes #accordion-section-installed_themes{border-top:1px solid #ddd}.control-panel-themes .theme-section{margin:0;position:relative}.control-panel-themes .customize-themes-section-title:focus,.control-panel-themes .customize-themes-section-title:hover{border-left-color:#0073aa;color:#0073aa;background:#f5f5f5}.customize-themes-section-title:not(.selected):after{content:"";display:block;position:absolute;top:9px;right:15px;width:18px;height:18px;border-radius:100%;border:1px solid #ccc;background:#fff}.control-panel-themes .theme-section .customize-themes-section-title.selected:after{content:"\f147";font:16px/1 dashicons;box-sizing:border-box;width:20px;height:20px;padding:3px 3px 1px 1px;border-radius:100%;position:absolute;top:9px;right:15px;background:#0073aa;color:#fff}.control-panel-themes .customize-themes-section-title.selected{color:#0073aa}#customize-theme-controls .themes.accordion-section-content{position:relative;left:0;padding:0;width:100%}.loading .customize-themes-section .spinner{display:block;visibility:visible;position:relative;clear:both;width:20px;height:20px;left:calc(50% - 10px);float:none;margin-top:50px}.control-panel-themes .customize-themes-mobile-back,.customize-themes-section .no-themes,.customize-themes-section .no-themes-local{display:none}.themes-section-installed_themes .theme .notice-success:not(.updated-message){display:none}.customize-control-theme .theme{width:100%;margin:0;border:1px solid #ddd;background:#fff}.customize-control-theme .theme .theme-actions,.customize-control-theme .theme .theme-name{background:#fff;border:none}.customize-control.customize-control-theme{box-sizing:border-box;width:25%;max-width:600px;margin:0 25px 25px 0;padding:0;clear:none}@media screen and (min-width:2101px){.customize-control.customize-control-theme{width:calc((100% - 125px)/ 5 - 1px)}}@media screen and (min-width:1601px) and (max-width:2100px){.customize-control.customize-control-theme{width:calc((100% - 100px)/ 4 - 1px)}}@media screen and (min-width:1201px) and (max-width:1600px){.customize-control.customize-control-theme{width:calc((100% - 75px)/ 3 - 1px)}}@media screen and (min-width:851px) and (max-width:1200px){.customize-control.customize-control-theme{width:calc((100% - 50px)/ 2 - 1px)}}@media screen and (max-width:850px){.customize-control.customize-control-theme{width:100%}}.wp-customizer .theme-browser .themes{padding:0 0 25px 25px;transition:.18s margin-top linear}.wp-customizer .theme-browser .theme .theme-actions{opacity:1}#customize-controls h3.theme-name{font-size:15px}#customize-controls .theme-overlay .theme-name{font-size:32px}.customize-preview-header.themes-filter-bar{position:fixed;top:0;left:300px;width:calc(100% - 300px);height:46px;background:#eee;z-index:10;padding:6px 25px;box-sizing:border-box;border-bottom:1px solid #ddd}@media screen and (min-width:1670px){.customize-preview-header.themes-filter-bar{width:82%;right:0;left:initial}}.themes-filter-bar .themes-filter-container{margin:0;padding:0}.themes-filter-bar .wp-filter-search{line-height:25px;padding:6px 10px 6px 30px;max-width:100%;width:40%;min-width:300px;position:absolute;top:6px;left:25px;height:32px;margin:1px 0}@media screen and (max-height:540px),screen and (max-width:1018px){.customize-preview-header.themes-filter-bar{position:relative;left:0;width:100%;margin:0 0 25px}.filter-drawer{top:46px}.wp-customizer .theme-browser .themes{padding:0 0 25px 25px;overflow:hidden}.control-panel-themes .customize-themes-full-container{margin-top:0;padding:0;height:100%;width:calc(100% - 300px)}}@media screen and (max-width:1018px){.filter-drawer .filter-group{width:calc((100% - 50px)/ 2)}}@media screen and (max-width:900px){.customize-preview-header.themes-filter-bar{height:86px;padding-top:46px}.themes-filter-bar .wp-filter-search{width:calc(100% - 50px);margin:0;min-width:200px}.filter-drawer{top:86px}.control-panel-themes .filter-themes-count{float:left}}@media screen and (max-width:792px){.filter-drawer .filter-group{width:calc(100% - 25px)}}@media screen and (max-width:600px){.filter-drawer{top:132px}.wp-full-overlay.showing-themes .control-panel-themes .filter-themes-count .filter-themes{display:block;float:right}.control-panel-themes .customize-themes-full-container{width:100%;margin:0;padding-top:46px;height:calc(100% - 46px);z-index:1;display:none}.showing-themes .control-panel-themes .customize-themes-full-container{display:block}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back{display:block;position:fixed;top:0;left:0;background:#eee;color:#444;border-radius:0;box-shadow:none;border:none;height:46px;width:100%;z-index:10;text-align:left;text-shadow:none;border-bottom:1px solid #ddd;border-left:4px solid transparent;margin:0;padding:0;font-size:0;overflow:hidden}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:before{left:0;top:0;height:46px;width:26px;display:block;line-height:46px;padding:0 8px;border-right:1px solid #ddd}.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:focus,.wp-customizer .showing-themes .control-panel-themes .customize-themes-mobile-back:hover{color:#0073aa;background:#f3f3f5;border-left-color:#0073aa;outline:0;box-shadow:none}.showing-themes #customize-header-actions{display:none}#customize-controls{width:100%}}.modal-open .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content,.wp-full-overlay.in-themes-panel.themes-panel-expanded #customize-controls .wp-full-overlay-sidebar-content{overflow:visible}.wp-customizer .theme-overlay{display:none}.wp-customizer.modal-open .theme-overlay{position:fixed;left:0;top:0;right:0;bottom:0;z-index:109}.wp-customizer.modal-open #customize-header-actions,.wp-customizer.modal-open .control-panel-themes .customize-themes-section-title.selected:after,.wp-customizer.modal-open .control-panel-themes .filter-themes-count{z-index:-1}.wp-customizer .theme-overlay .theme-backdrop{background:rgba(238,238,238,.75);position:fixed;z-index:110}.wp-customizer .theme-overlay .star-rating{float:left;margin-right:8px}.wp-customizer .theme-rating .num-ratings{line-height:20px}.wp-customizer .theme-overlay .theme-wrap{left:90px;right:90px;top:45px;bottom:45px;z-index:120}.wp-customizer .theme-overlay .theme-actions{text-align:right;padding:10px 25px;background:#eee;border-top:1px solid #ddd}.wp-customizer .theme-overlay .theme-actions .theme-install.preview{margin-left:8px}.control-panel-themes .theme-actions .delete-theme{left:15px;right:auto;bottom:auto;position:absolute}.wp-customizer .theme-header{background:#eee}.wp-customizer .theme-overlay .theme-header .close:before,.wp-customizer .theme-overlay .theme-header button{color:#444}.wp-customizer .theme-overlay .theme-header .close:focus,.wp-customizer .theme-overlay .theme-header .close:hover,.wp-customizer .theme-overlay .theme-header .left:focus,.wp-customizer .theme-overlay .theme-header .left:hover,.wp-customizer .theme-overlay .theme-header .right:focus,.wp-customizer .theme-overlay .theme-header .right:hover{background:#fff;border-bottom:4px solid #0073aa;color:#0073aa}.wp-customizer .theme-overlay .theme-header .close:focus:before,.wp-customizer .theme-overlay .theme-header .close:hover:before{color:#0073aa}.wp-customizer .theme-overlay .theme-header button.disabled,.wp-customizer .theme-overlay .theme-header button.disabled:focus,.wp-customizer .theme-overlay .theme-header button.disabled:hover{border-bottom:none;background:0 0;color:#ccc}@media (max-width:850px),(max-height:472px){.wp-customizer .theme-overlay .theme-wrap{left:0;right:0;top:0;bottom:0}.wp-customizer .theme-browser .themes{padding-right:25px}}body.cheatin{font-size:medium;height:auto;background:#fff;margin:50px auto 2em;padding:1em 2em;max-width:700px;min-width:0;box-shadow:0 1px 3px rgba(0,0,0,.13)}body.cheatin h1{border-bottom:1px solid #ddd;clear:both;color:#555d66;font-size:24px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;margin:30px 0 0;padding:0 0 7px}body.cheatin p{font-size:14px;line-height:1.5;margin:25px 0 20px}#customize-theme-controls .add-new-menu-item,#customize-theme-controls .add-new-widget{cursor:pointer;float:right;margin:0 0 0 10px;transition:all .2s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:0}.reordering .add-new-menu-item,.reordering .add-new-widget{opacity:.2;pointer-events:none;cursor:not-allowed}#available-menu-items .new-content-item .add-content:before,.add-new-menu-item:before,.add-new-widget:before{content:"\f132";display:inline-block;position:relative;left:-2px;top:0;font:400 20px/1 dashicons;vertical-align:middle;transition:all .2s;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.reorder-toggle{float:right;padding:5px 8px;text-decoration:none;cursor:pointer;outline:0}.reorder,.reordering .reorder-done{display:block;padding:5px 8px}.reorder-done,.reordering .reorder{display:none}.menu-item-reorder-nav button,.widget-reorder-nav span{position:relative;overflow:hidden;float:left;display:block;width:33px;height:43px;color:#82878c;text-indent:-9999px;cursor:pointer;outline:0}.menu-item-reorder-nav button{width:30px;height:40px;background:0 0;border:none;box-shadow:none}.menu-item-reorder-nav button:before,.widget-reorder-nav span:before{display:inline-block;position:absolute;top:0;right:0;width:100%;height:100%;font:400 20px/43px dashicons;text-align:center;text-indent:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.menu-item-reorder-nav button:focus,.menu-item-reorder-nav button:hover,.widget-reorder-nav span:focus,.widget-reorder-nav span:hover{color:#191e23;background:#eee}.menus-move-down:before,.move-widget-down:before{content:"\f347"}.menus-move-up:before,.move-widget-up:before{content:"\f343"}#customize-theme-controls .first-widget .move-widget-up,#customize-theme-controls .last-widget .move-widget-down,.move-down-disabled .menus-move-down,.move-left-disabled .menus-move-left,.move-right-disabled .menus-move-right,.move-up-disabled .menus-move-up{color:#d5d5d5;background-color:#fff;cursor:default;pointer-events:none}.wp-full-overlay-main{right:auto;width:100%}.add-menu-toggle.open,.add-menu-toggle.open:hover,.adding-menu-items .add-new-menu-item,.adding-menu-items .add-new-menu-item:hover,body.adding-widget .add-new-widget,body.adding-widget .add-new-widget:hover{background:#eee;border-color:#929793;color:#32373c;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5)}#accordion-section-add_menu .add-new-menu-item.open:before,.adding-menu-items .add-new-menu-item:before,body.adding-widget .add-new-widget:before{-webkit-transform:rotate(45deg);transform:rotate(45deg)}#available-menu-items,#available-widgets{position:absolute;top:0;bottom:0;left:-301px;visibility:hidden;overflow-x:hidden;overflow-y:auto;width:300px;margin:0;z-index:4;background:#eee;transition:left .18s;border-right:1px solid #ddd}#available-menu-items .customize-section-title,#available-widgets .customize-section-title{display:none}#available-widgets-list{top:60px;position:absolute;overflow:auto;bottom:0;width:100%;border-top:1px solid #ddd}.no-widgets-found #available-widgets-list{border-top:none}#available-widgets-filter{position:fixed;top:0;z-index:1;width:300px;background:#eee}#available-menu-items-search .accordion-section-title,#available-widgets-filter{padding:13px 15px;box-sizing:border-box}#available-menu-items-search input,#available-widgets-filter input{width:100%;height:32px;margin:1px 0;padding:6px 30px}#available-menu-items-search input::-ms-clear,#available-widgets-filter input::-ms-clear{display:none}#available-menu-items-search .search-icon,#available-widgets-filter .search-icon{display:block;position:absolute;top:15px;left:16px;width:30px;height:30px;line-height:28px;text-align:center;color:#72777c}#available-menu-items-search .clear-results,#available-widgets-filter .clear-results{position:absolute;top:15px;right:16px;width:30px;height:30px;padding:0;border:0;cursor:pointer;background:0 0;color:#a00;text-decoration:none;outline:0}#available-menu-items-search .clear-results,#available-menu-items-search.loading .clear-results.is-visible,#available-widgets-filter .clear-results{display:none}#available-menu-items-search .clear-results.is-visible,#available-widgets-filter .clear-results.is-visible{display:block}#available-menu-items-search .clear-results:before,#available-widgets-filter .clear-results:before{content:"\f335";font:400 20px/1 dashicons;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#available-menu-items-search .clear-results:focus,#available-menu-items-search .clear-results:hover,#available-widgets-filter .clear-results:focus,#available-widgets-filter .clear-results:hover{color:#dc3232}#available-menu-items-search .clear-results:focus,#available-widgets-filter .clear-results:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#available-menu-items-search .search-icon:after,#available-widgets-filter .search-icon:after,.themes-filter-bar .search-icon:after{content:"\f179";font:400 20px/1 dashicons;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.themes-filter-bar .search-icon{position:absolute;top:7px;left:26px;z-index:1;color:#72777c;height:30px;width:30px;line-height:2;text-align:center}.no-widgets-found-message{display:none;margin:0;padding:0 15px;line-height:inherit}.no-widgets-found .no-widgets-found-message{display:block}#available-menu-items .item-top,#available-menu-items .item-top:hover,#available-widgets .widget-top,#available-widgets .widget-top:hover{border:none;background:0 0;box-shadow:none}#available-menu-items .item-tpl,#available-widgets .widget-tpl{position:relative;padding:15px 15px 15px 60px;background:#fff;border-bottom:1px solid #ddd;border-left:4px solid #fff;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out;cursor:pointer;display:none}#available-menu-items .item,#available-widgets .widget{position:static}.customize-controls-preview-toggle{display:none}@media only screen and (max-width:782px){.wp-customizer .theme:not(.active):focus .theme-actions,.wp-customizer .theme:not(.active):hover .theme-actions{display:block}.wp-customizer .theme-browser .theme.active .theme-name span{display:inline}.customize-control-header button.random .dice{margin-top:0}.customize-control-checkbox .customize-inside-control-row,.customize-control-nav_menu_auto_add .customize-inside-control-row,.customize-control-radio .customize-inside-control-row{margin-left:32px}.customize-control-checkbox input,.customize-control-nav_menu_auto_add input,.customize-control-radio input{margin-left:-32px}.customize-control input[type=radio]+label+br,.customize-control input[type=checkbox]+label+br{line-height:32px}.customize-control .date-time-fields select{height:39px}.date-time-fields .date-input.month{width:79px}.date-time-fields .date-input.day,.date-time-fields .date-input.hour,.date-time-fields .date-input.minute{width:55px}.date-time-fields .date-input.year{width:80px}.date-time-fields .date-timezone{line-height:3.2}#customize-control-changeset_preview_link a{bottom:16px}.preview-link-wrapper .customize-copy-preview-link.preview-control-element.button{bottom:10px}.media-widget-control .media-widget-buttons .button.change-media,.media-widget-control .media-widget-buttons .button.edit-media,.media-widget-control .media-widget-buttons .button.select-media{margin-top:12px}.wp-core-ui .themes-filter-bar .feature-filter-toggle{margin:3px 0 3px 25px}}@media screen and (max-width:1200px){.adding-menu-items .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.adding-widget .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main,.outer-section-open .wp-full-overlay.expanded.preview-mobile .wp-full-overlay-main{left:67%}}@media screen and (max-width:640px){.wp-full-overlay.collapsed #customize-controls{margin-left:0}.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{bottom:0}.customize-controls-preview-toggle{display:block;position:absolute;top:0;left:48px;line-height:45px;font-size:14px;padding:0 12px;margin:0;height:45px;background:#eee;border:0;border-right:1px solid #ddd;color:#555d66;cursor:pointer;transition:color .1s ease-in-out,background .1s ease-in-out}#customize-footer-actions,.customize-controls-preview-toggle .controls,.preview-only .customize-controls-preview-toggle .preview,.preview-only .wp-full-overlay-sidebar-content{display:none}.preview-only #customize-save-button-wrapper{margin-top:-46px}.customize-controls-preview-toggle .controls:before,.customize-controls-preview-toggle .preview:before{font:400 20px/1 dashicons;content:"\f177";position:relative;top:4px;margin-right:6px}.customize-controls-preview-toggle .controls:before{content:"\f540"}.preview-only #customize-controls{height:45px}.preview-only #customize-preview,.preview-only .customize-controls-preview-toggle .controls{display:block}.wp-core-ui.wp-customizer .button{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto}#publish-settings{height:31px}#customize-control-changeset_status .customize-inside-control-row{padding-top:15px}body.adding-menu-items div#available-menu-items,body.adding-widget div#available-widgets,body.outer-section-open div#customize-sidebar-outer-content{width:100%}#available-menu-items .customize-section-title,#available-widgets .customize-section-title{display:block;margin:0}#available-menu-items .customize-section-back,#available-widgets .customize-section-back{height:69px}#available-menu-items .customize-section-title h3,#available-widgets .customize-section-title h3{font-size:20px;font-weight:200;padding:9px 10px 12px 14px;margin:0;line-height:24px;color:#555d66;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#available-menu-items .customize-section-title .customize-action,#available-widgets .customize-section-title .customize-action{font-size:13px;display:block;font-weight:400;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#available-widgets-filter{position:relative;width:100%;height:auto}#available-widgets-list{top:130px}#available-menu-items-search .clear-results,#available-menu-items-search .search-icon{top:85px}.reorder,.reordering .reorder-done{padding:8px}.wp-core-ui .themes-filter-bar .feature-filter-toggle{margin:0}.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:9px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}}@media screen and (max-width:600px){.theme-browser .theme.active .theme-actions,.wp-customizer .theme-browser .theme .theme-actions{padding:8px 15px;box-shadow:none}.wp-full-overlay.expanded{margin-left:0}body.adding-menu-items div#available-menu-items,body.adding-widget div#available-widgets,body.outer-section-open div#customize-sidebar-outer-content{top:46px;z-index:10}body.wp-customizer .wp-full-overlay.expanded #customize-sidebar-outer-content{left:-100%}body.wp-customizer.outer-section-open .wp-full-overlay.expanded #customize-sidebar-outer-content{left:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-nav-menus-rtl.css b/backend/wp-admin/css/customize-nav-menus-rtl.css new file mode 100644 index 0000000..6ba34ea --- /dev/null +++ b/backend/wp-admin/css/customize-nav-menus-rtl.css @@ -0,0 +1,887 @@ +#customize-theme-controls #accordion-section-menu_locations { + position: relative; + margin-top: 30px; +} + +#customize-theme-controls #accordion-section-menu_locations > .accordion-section-title { + border-bottom-color: #ddd; + margin-top: 15px; +} + +#customize-theme-controls .customize-section-title-nav_menus-heading, +#customize-theme-controls .customize-section-title-menu_locations-heading, +#customize-theme-controls .customize-section-title-menu_locations-description { + padding: 0 12px 0 12px; +} + +#customize-theme-controls .customize-control-description.customize-section-title-menu_locations-description { + /* Override the default italic style for control descriptions */ + font-style: normal; +} + +.menu-in-location, +.menu-in-locations { + display: block; + font-weight: 600; + font-size: 10px; +} + +#customize-controls .theme-location-set, +#customize-controls .control-section .accordion-section-title:focus .menu-in-location, +#customize-controls .control-section .accordion-section-title:hover .menu-in-location { + color: #555; +} + +/* The `edit-menu` and `create-menu` buttons also use the `button-link` class. */ +.customize-control-nav_menu_location .edit-menu, +.customize-control-nav_menu_location .create-menu { + margin-right: 6px; + vertical-align: middle; + line-height: 28px; +} + +#customize-controls .customize-control-nav_menu_name { + margin-bottom: 12px; +} + +.customize-control-nav_menu_name p:last-of-type { + margin-bottom: 0; +} + +#customize-new-menu-submit { + float: left; + min-width: 85px; +} + +.wp-customizer .menu-item-bar .menu-item-handle, +.wp-customizer .menu-item-settings, +.wp-customizer .menu-item-settings .description-thin { + box-sizing: border-box; +} + +.wp-customizer .menu-item-bar { + margin: 0; +} + +.wp-customizer .menu-item-bar .menu-item-handle { + width: 100%; + background: #fff; +} + +.wp-customizer .menu-item-handle .item-title { + margin-left: 0; +} + +.wp-customizer .menu-item-handle .item-type { + padding: 1px 5px 0 21px; + float: left; + text-align: left; +} + +.wp-customizer .menu-item-handle:hover { + z-index: 8; +} + +.customize-control-nav_menu_item.has-notifications .menu-item-handle { + border-right: 4px solid #00a0d2; +} + +.wp-customizer .menu-item-settings { + max-width: 100%; + overflow: hidden; + z-index: 8; + padding: 10px; + background: #eee; + border: 1px solid #999; + border-top: none; +} + +.wp-customizer .menu-item-settings .description-thin { + width: 100%; + height: auto; + margin: 0 0 8px 0; +} + +.wp-customizer .menu-item-settings input[type="text"] { + width: 100%; +} + +.wp-customizer .menu-item-settings .submitbox { + margin: 0; + padding: 0; +} + +.wp-customizer .menu-item-settings .link-to-original { + padding: 5px 0; + border: none; + font-style: normal; + margin: 0; + width: 100%; +} + +.wp-customizer .menu-item .submitbox .submitdelete { + float: right; + margin: 6px 0 0; + padding: 0; + cursor: pointer; +} + + +/** + * Menu items reordering styles + */ + +.menu-item-reorder-nav { + display: none; + background-color: #fff; + position: absolute; + top: 0; + left: 0; +} + +.menus-move-left:before { + content: "\f345"; +} + +.menus-move-right:before { + content: "\f341"; +} + +.reordering .menu-item .item-controls, +.reordering .menu-item .item-type { + display: none; +} + +.reordering .menu-item-reorder-nav { + display: block; +} + +.customize-control input.menu-name-field { + width: 100%; /* Override the 98% default for customizer inputs, to align with the size of menu items. */ +} + +.wp-customizer .menu-item .item-edit { + position: absolute; + left: -19px; + top: 2px; + display: block; + width: 30px; + height: 38px; + margin-left: 0 !important; + box-shadow: none; + outline: none; + overflow: hidden; + cursor: pointer; + text-align: center; +} + +.wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:before { + content: "\f142"; +} + +.wp-customizer .menu-item-settings p.description { + font-style: normal; +} + +.wp-customizer .menu-settings dl { + margin: 12px 0 0 0; + padding: 0; +} + +.wp-customizer .menu-settings .checkbox-input { + margin-top: 8px; +} + +.wp-customizer .menu-settings .menu-theme-locations { + border-top: 1px solid #ccc; +} + +.wp-customizer .menu-settings { + margin-top: 36px; + border-top: none; +} + +.wp-customizer .menu-location-settings { + margin-top: 12px; + border-top: none; +} + +.wp-customizer .control-section-nav_menu .menu-location-settings { + margin-top: 24px; + border-top: 1px solid #ddd; +} + +.wp-customizer .control-section-nav_menu .menu-location-settings, +.customize-control-nav_menu_auto_add { + padding-top: 12px; +} + +.menu-location-settings .customize-control-checkbox .theme-location-set { + line-height: 1; +} + +.customize-control-nav_menu_auto_add label { + vertical-align: top; +} + +.menu-location-settings .new-menu-locations-widget-note { + display: block; +} + +.customize-control-menu { + margin-top: 4px; +} + +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle { + color: #555; +} + +/* Screen Options */ +.customize-screen-options-toggle { + background: none; + border: none; + color: #555; + cursor: pointer; + margin: 0; + padding: 20px; + position: absolute; + left: 0; + top: 30px; +} + +#customize-controls .customize-info .customize-help-toggle { + padding: 20px; +} + +#customize-controls .customize-info .customize-help-toggle:before { + padding: 4px; +} + +.customize-screen-options-toggle:hover, +.customize-screen-options-toggle:active, +.customize-screen-options-toggle:focus, +.active-menu-screen-options .customize-screen-options-toggle, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus { + color: #0073aa; +} + +.customize-screen-options-toggle:focus, +#customize-controls .customize-info .customize-help-toggle:focus { + outline: none; +} + +.customize-screen-options-toggle:before { + -moz-osx-font-smoothing: grayscale; + border: none; + content: "\f111"; + display: block; + font: 18px/1 dashicons; + padding: 5px; + text-align: center; + text-decoration: none !important; + text-indent: 0; + right: 6px; + position: absolute; + top: 6px; +} + +.customize-screen-options-toggle:focus:before, +#customize-controls .customize-info .customize-help-toggle:focus:before { + border-radius: 100%; +} + +.wp-customizer #screen-options-wrap { + display: none; + background: #fff; + border-top: 1px solid #ddd; + padding: 4px 15px 15px; +} + +.wp-customizer .metabox-prefs label { + display: block; + padding-left: 0; + line-height: 30px; +} + +/* rework the arrow indicator implementation for NVDA bug same as #32715 */ +.wp-customizer .toggle-indicator { + display: inline-block; + font-size: 20px; + line-height: 1; +} + +.rtl .wp-customizer .toggle-indicator { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.wp-customizer .menu-item .item-edit .toggle-indicator:before, +#available-menu-items .accordion-section-title .toggle-indicator:before { + content: "\f140"; + display: block; + padding: 1px 0px 1px 2px; + speak: none; + border-radius: 50%; + color: #72777c; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.control-section-nav_menu .field-link-target, +.control-section-nav_menu .field-title-attribute, +.control-section-nav_menu .field-css-classes, +.control-section-nav_menu .field-xfn, +.control-section-nav_menu .field-description { + display: none; +} + +.control-section-nav_menu.field-link-target-active .field-link-target, +.control-section-nav_menu.field-title-attribute-active .field-title-attribute, +.control-section-nav_menu.field-css-classes-active .field-css-classes, +.control-section-nav_menu.field-xfn-active .field-xfn, +.control-section-nav_menu.field-description-active .field-description { + display: block; +} + +/* WARNING: The 20px factor is hard-coded in JS. */ +.menu-item-depth-0 { margin-right: 0; } +.menu-item-depth-1 { margin-right: 20px; } +.menu-item-depth-2 { margin-right: 40px; } +.menu-item-depth-3 { margin-right: 60px; } +.menu-item-depth-4 { margin-right: 80px; } +.menu-item-depth-5 { margin-right: 100px; } +.menu-item-depth-6 { margin-right: 120px; } +.menu-item-depth-7 { margin-right: 140px; } +.menu-item-depth-8 { margin-right: 160px; } /* Not likely to be used or useful beyond this depth */ +.menu-item-depth-9 { margin-right: 180px; } +.menu-item-depth-10 { margin-right: 200px; } +.menu-item-depth-11 { margin-right: 220px; } + +/* @todo handle .menu-item-settings width */ +.menu-item-depth-0 > .menu-item-bar { margin-left: 0; } +.menu-item-depth-1 > .menu-item-bar { margin-left: 20px; } +.menu-item-depth-2 > .menu-item-bar { margin-left: 40px; } +.menu-item-depth-3 > .menu-item-bar { margin-left: 60px; } +.menu-item-depth-4 > .menu-item-bar { margin-left: 80px; } +.menu-item-depth-5 > .menu-item-bar { margin-left: 100px; } +.menu-item-depth-6 > .menu-item-bar { margin-left: 120px; } +.menu-item-depth-7 > .menu-item-bar { margin-left: 140px; } +.menu-item-depth-8 > .menu-item-bar { margin-left: 160px; } +.menu-item-depth-9 > .menu-item-bar { margin-left: 180px; } +.menu-item-depth-10 > .menu-item-bar { margin-left: 200px; } +.menu-item-depth-11 > .menu-item-bar { margin-left: 220px; } + +/* Submenu left margin. */ +.menu-item-depth-0 .menu-item-transport { margin-right: 0; } +.menu-item-depth-1 .menu-item-transport { margin-right: -20px; } +.menu-item-depth-3 .menu-item-transport { margin-right: -60px; } +.menu-item-depth-4 .menu-item-transport { margin-right: -80px; } +.menu-item-depth-2 .menu-item-transport { margin-right: -40px; } +.menu-item-depth-5 .menu-item-transport { margin-right: -100px; } +.menu-item-depth-6 .menu-item-transport { margin-right: -120px; } +.menu-item-depth-7 .menu-item-transport { margin-right: -140px; } +.menu-item-depth-8 .menu-item-transport { margin-right: -160px; } +.menu-item-depth-9 .menu-item-transport { margin-right: -180px; } +.menu-item-depth-10 .menu-item-transport { margin-right: -200px; } +.menu-item-depth-11 .menu-item-transport { margin-right: -220px; } + +/* WARNING: The 20px factor is hard-coded in JS. */ +.reordering .menu-item-depth-0 { margin-right: 0; } +.reordering .menu-item-depth-1 { margin-right: 15px; } +.reordering .menu-item-depth-2 { margin-right: 30px; } +.reordering .menu-item-depth-3 { margin-right: 45px; } +.reordering .menu-item-depth-4 { margin-right: 60px; } +.reordering .menu-item-depth-5 { margin-right: 75px; } +.reordering .menu-item-depth-6 { margin-right: 90px; } +.reordering .menu-item-depth-7 { margin-right: 105px; } +.reordering .menu-item-depth-8 { margin-right: 120px; } /* Not likely to be used or useful beyond this depth */ +.reordering .menu-item-depth-9 { margin-right: 135px; } +.reordering .menu-item-depth-10 { margin-right: 150px; } +.reordering .menu-item-depth-11 { margin-right: 165px; } + +.reordering .menu-item-depth-0 > .menu-item-bar { margin-left: 0; } +.reordering .menu-item-depth-1 > .menu-item-bar { margin-left: 15px; } +.reordering .menu-item-depth-2 > .menu-item-bar { margin-left: 30px; } +.reordering .menu-item-depth-3 > .menu-item-bar { margin-left: 45px; } +.reordering .menu-item-depth-4 > .menu-item-bar { margin-left: 60px; } +.reordering .menu-item-depth-5 > .menu-item-bar { margin-left: 75px; } +.reordering .menu-item-depth-6 > .menu-item-bar { margin-left: 90px; } +.reordering .menu-item-depth-7 > .menu-item-bar { margin-left: 105px; } +.reordering .menu-item-depth-8 > .menu-item-bar { margin-left: 120px; } +.reordering .menu-item-depth-9 > .menu-item-bar { margin-left: 135px; } +.reordering .menu-item-depth-10 > .menu-item-bar { margin-left: 150px; } +.reordering .menu-item-depth-11 > .menu-item-bar { margin-left: 165px; } + +.control-section-nav_menu.menu .menu-item-edit-active { + margin-right: 0; +} + +.control-section-nav_menu.menu .menu-item-edit-active .menu-item-bar { + margin-left: 0; +} + +.control-section-nav_menu.menu .sortable-placeholder { + margin-top: 0; + margin-bottom: 1px; + max-width: calc(100% - 2px); + float: right; + display: list-item; + border-color: #a0a5aa; +} + +.menu-item-transport li.customize-control { + float: none; +} + +.control-section-nav_menu.menu ul.menu-item-transport .menu-item-bar { + margin-top: 0; +} + +/** + * Add-menu-items mode + */ + +.adding-menu-items .control-section { + opacity: .4; +} + +.adding-menu-items .control-panel.control-section, +.adding-menu-items .control-section.open { + opacity: 1; +} + +.menu-item-bar .item-delete { + color: #a00; + position: absolute; + top: 2px; + left: -19px; + width: 30px; + height: 38px; + cursor: pointer; + display: none; +} + +.menu-item-bar .item-delete:before { + content: "\f335"; + position: absolute; + top: 9px; + right: 5px; + border-radius: 50%; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.ie8 .menu-item-bar .item-delete:before { + top: -10px; +} + +.menu-item-bar .item-delete:hover, +.menu-item-bar .item-delete:focus { + box-shadow: none; + outline: none; + color: #dc3232; +} + +.adding-menu-items .menu-item-bar .item-edit { + display: none; +} + +.adding-menu-items .menu-item-bar .item-delete { + display: block; +} + +/** + * Styles for menu-item addition panel + */ + +#available-menu-items.opening { + overflow-y: hidden; /* avoid scrollbar jitter with animating heights */ +} + +#available-menu-items #available-menu-items-search.open { + height: 100%; + border-bottom: none; +} + +#available-menu-items .accordion-section-title { + border-right: none; + border-left: none; + background: #fff; + transition: background-color 0.15s; + /* Reset the value inherited from the base .accordion-section-title style. Ticket #37589. */ + -webkit-user-select: auto; + -moz-user-select: auto; + -ms-user-select: auto; + user-select: auto; +} + +#available-menu-items .open .accordion-section-title, +#available-menu-items #available-menu-items-search .accordion-section-title { + background: #eee; +} + +/* rework the arrow indicator implementation for NVDA bug see #32715 */ +#available-menu-items .accordion-section-title:after { + content: none !important; +} + +#available-menu-items .accordion-section-title:hover .toggle-indicator:before, +#available-menu-items .button-link:hover .toggle-indicator:before, +#available-menu-items .button-link:focus .toggle-indicator:before { + color: #23282d; +} + +#available-menu-items .open .accordion-section-title .toggle-indicator:before { + content: "\f142"; + color: #23282d; +} + +#available-menu-items .available-menu-items-list { + overflow-y: auto; + max-height: 200px; /* This gets set in JS to fit the screen size, and based on # of sections. */ + background: transparent; +} + +#available-menu-items .accordion-section-title button { + display: block; + width: 28px; + height: 35px; + position: absolute; + top: 5px; + left: 5px; + box-shadow: none; + outline: none; + cursor: pointer; + text-align: center; +} + +#available-menu-items .accordion-section-title .no-items, +#available-menu-items .cannot-expand .accordion-section-title .spinner, +#available-menu-items .cannot-expand .accordion-section-title > button { + display: none; +} + +#available-menu-items-search.cannot-expand .accordion-section-title .spinner { + display: block; +} + +#available-menu-items .cannot-expand .accordion-section-title .no-items { + float: left; + color: #555d66; + font-weight: 400; + margin-right: 5px; +} + +#available-menu-items .accordion-section-content { + max-height: 290px; + margin: 0; + padding: 0; + position: relative; + background: transparent; +} + +#available-menu-items .accordion-section-content .available-menu-items-list { + margin: 0 0 45px 0; + padding: 1px 15px 15px 15px; +} + +#available-menu-items .accordion-section-content .available-menu-items-list:only-child { /* Types that do not support new items for the current user */ + margin-bottom: 0; +} + +#new-custom-menu-item .accordion-section-content { + padding: 0 15px 15px 15px; +} + +#available-menu-items .menu-item-tpl { + margin: 0; +} + +#custom-menu-item-name.invalid, +#custom-menu-item-url.invalid, +.edit-menu-item-url.invalid, +.menu-name-field.invalid, +.menu-name-field.invalid:focus, +#available-menu-items .new-content-item .create-item-input.invalid, +#available-menu-items .new-content-item .create-item-input.invalid:focus { + border: 1px solid #dc3232; +} + +#available-menu-items .menu-item-handle .item-type { + padding-left: 0; +} + +#available-menu-items .menu-item-handle .item-title { + padding-right: 20px; +} + +#available-menu-items .menu-item-handle { + cursor: pointer; +} + +#available-menu-items .menu-item-handle { + box-shadow: none; + margin-top: -1px; +} + +#available-menu-items .menu-item-handle:hover { + z-index: 1; +} + +#available-menu-items .item-title h4 { + padding: 0 0 5px; + font-size: 14px; +} + +#available-menu-items .item-add { + position: absolute; + top: 1px; + right: 1px; + color: #82878c; + width: 30px; + height: 38px; + box-shadow: none; + outline: none; + cursor: pointer; + text-align: center; +} + +#available-menu-items .menu-item-handle .item-add:focus { + color: #23282d; +} + +#available-menu-items .item-add:before { + content: "\f543"; + position: relative; + right: 2px; + top: 3px; + display: inline-block; + height: 20px; + border-radius: 50%; + font: normal 20px/1.05 dashicons; /* line height is to account for the dashicon's vertical alignment */ +} + +#available-menu-items .menu-item-handle.item-added .item-type, +#available-menu-items .menu-item-handle.item-added .item-title, +#available-menu-items .menu-item-handle.item-added:hover .item-add, +#available-menu-items .menu-item-handle.item-added .item-add:focus { + color: #82878c; +} + +#available-menu-items .menu-item-handle.item-added .item-add:before { + content: "\f147"; +} + +#available-menu-items .accordion-section-title.loading .spinner, +#available-menu-items-search.loading .accordion-section-title .spinner { + visibility: visible; + margin: 0 20px; +} + +#available-menu-items-search .spinner { + position: absolute; + top: 20px; /* 13 container padding +1 input margin +6 ( ( 32 input height - 20 spinner height ) / 2 ) */ + left: 21px; + margin: 0 !important; +} + +/* search results list */ +#available-menu-items #available-menu-items-search .accordion-section-content { + position: absolute; + right: 0; + top: 60px; /* below title div / search input */ + bottom: 0px; /* 100% height that still triggers lazy load */ + max-height: none; + width: 100%; + padding: 1px 15px 15px; + box-sizing: border-box; +} + +#available-menu-items-search .nothing-found { + /* Compensate the 1px top padding of the container. */ + margin-top: -1px; +} + +#available-menu-items-search .accordion-section-title:after { + display: none; +} + +#available-menu-items-search .accordion-section-content:empty { + min-height: 0; + padding: 0; +} + +#available-menu-items-search.loading .accordion-section-content div { + opacity: .5; +} + +#available-menu-items-search.loading.loading-more .accordion-section-content div { + opacity: 1; +} + +#customize-preview { + transition: all 0.2s; +} + +body.adding-menu-items #available-menu-items { + right: 0; + visibility: visible; +} + +body.adding-menu-items .wp-full-overlay-main { + right: 300px; +} + +body.adding-menu-items #customize-preview { + opacity: 0.4; +} + +body.adding-menu-items #customize-preview iframe { + pointer-events: none; +} + +.menu-item-handle .spinner { + display: none; + float: right; + margin: 0 0 0 8px; +} + +.nav-menu-inserted-item-loading .spinner { + display: block; +} + +.nav-menu-inserted-item-loading .menu-item-handle .item-type { + padding: 0 8px 0 0; +} + +.nav-menu-inserted-item-loading .menu-item-handle, +.added-menu-item .menu-item-handle.loading { + padding: 10px 8px 10px 15px; + cursor: default; + opacity: .5; + background: #fff; + color: #727773; +} + +.added-menu-item .menu-item-handle { + transition-property: opacity, background, color; + transition-duration: 1.25s; + transition-timing-function: cubic-bezier( .25, -2.5, .75, 8 ); /* Replacement for .hide().fadeIn('slow') in JS to add emphasis when it's loaded. */ +} + +/* Add/delete Menus */ + +#customize-theme-controls .control-panel-content .control-section-nav_menu:nth-last-child(2) .accordion-section-title { + border-bottom-color: #ddd; +} + +/* @todo update selector */ +#accordion-section-add_menu { + margin: 15px 12px; +} + +#accordion-section-add_menu h3 { + text-align: left; +} + +#accordion-section-add_menu h3, +#accordion-section-add_menu .customize-add-menu-button { + margin: 0; +} + +#accordion-section-add_menu .customize-add-menu-button { + font-weight: normal; +} + +#create-new-menu-submit { + float: left; + margin: 0 0 12px 0; +} + +.menu-delete-item { + float: right; + padding: 1em 0; + width: 100%; +} + +.assigned-menu-locations-title p { + margin: 0 0 8px 0; +} + +li.assigned-to-menu-location .menu-delete-item { + display: none; +} + +li.assigned-to-menu-location .add-new-menu-item { + margin-bottom: 1em; +} + +.menu-item-handle { + margin-top: -1px; +} +.ui-sortable-disabled .menu-item-handle { + cursor: default; +} + +.menu-item-handle:hover { + position: relative; + z-index: 10; + color: #0073aa; +} + +.menu-item-handle:hover .item-type, +.menu-item-handle:hover .item-edit, +#available-menu-items .menu-item-handle:hover .item-add { + color: #0073aa; +} + +.menu-item-edit-active .menu-item-handle { + border-color: #999; + border-bottom: none; +} + +.customize-control-nav_menu_item { + margin-bottom: 0; +} + +.customize-control-nav_menu .new-menu-item-invitation { + margin-top: 0; + margin-bottom: 0; +} + +.customize-control-nav_menu .customize-control-nav_menu-buttons { + margin-top: 12px; +} + +/** + * box-shadows + */ + +.wp-customizer .menu-item .submitbox .submitdelete:focus, +.customize-screen-options-toggle:focus:before, +#customize-controls .customize-info .customize-help-toggle:focus:before, +.wp-customizer button:focus .toggle-indicator:before, +.menu-delete:focus, +.menu-item-bar .item-delete:focus:before, +#available-menu-items .item-add:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + + +@media screen and ( max-width: 782px ) { + #available-menu-items #available-menu-items-search .accordion-section-content { + top: 63px; + } +} + +@media screen and ( max-width: 640px ) { + #available-menu-items #available-menu-items-search .accordion-section-content { + top: 130px; + } +} diff --git a/backend/wp-admin/css/customize-nav-menus-rtl.min.css b/backend/wp-admin/css/customize-nav-menus-rtl.min.css new file mode 100644 index 0000000..4eddad2 --- /dev/null +++ b/backend/wp-admin/css/customize-nav-menus-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#customize-theme-controls .customize-control-description.customize-section-title-menu_locations-description,.wp-customizer .menu-item-settings p.description{font-style:normal}#customize-theme-controls #accordion-section-menu_locations{position:relative;margin-top:30px}#customize-theme-controls #accordion-section-menu_locations>.accordion-section-title{border-bottom-color:#ddd;margin-top:15px}#customize-theme-controls .customize-section-title-menu_locations-description,#customize-theme-controls .customize-section-title-menu_locations-heading,#customize-theme-controls .customize-section-title-nav_menus-heading{padding:0 12px}.menu-in-location,.menu-in-locations{display:block;font-weight:600;font-size:10px}#customize-controls .control-section .accordion-section-title:focus .menu-in-location,#customize-controls .control-section .accordion-section-title:hover .menu-in-location,#customize-controls .theme-location-set{color:#555}.customize-control-nav_menu_location .create-menu,.customize-control-nav_menu_location .edit-menu{margin-right:6px;vertical-align:middle;line-height:28px}#customize-controls .customize-control-nav_menu_name{margin-bottom:12px}.customize-control-nav_menu_name p:last-of-type{margin-bottom:0}#customize-new-menu-submit{float:left;min-width:85px}.wp-customizer .menu-item-bar .menu-item-handle,.wp-customizer .menu-item-settings,.wp-customizer .menu-item-settings .description-thin{box-sizing:border-box}.wp-customizer .menu-item-bar{margin:0}.wp-customizer .menu-item-bar .menu-item-handle{width:100%;background:#fff}.wp-customizer .menu-item-handle .item-title{margin-left:0}.wp-customizer .menu-item-handle .item-type{padding:1px 5px 0 21px;float:left;text-align:left}.wp-customizer .menu-item-handle:hover{z-index:8}.customize-control-nav_menu_item.has-notifications .menu-item-handle{border-right:4px solid #00a0d2}.wp-customizer .menu-item-settings{max-width:100%;overflow:hidden;z-index:8;padding:10px;background:#eee;border:1px solid #999;border-top:none}.wp-customizer .menu-item-settings .description-thin{width:100%;height:auto;margin:0 0 8px}.wp-customizer .menu-item-settings input[type=text]{width:100%}.wp-customizer .menu-item-settings .submitbox{margin:0;padding:0}.wp-customizer .menu-item-settings .link-to-original{padding:5px 0;border:none;font-style:normal;margin:0;width:100%}.wp-customizer .menu-item .submitbox .submitdelete{float:right;margin:6px 0 0;padding:0;cursor:pointer}.menu-item-reorder-nav{display:none;background-color:#fff;position:absolute;top:0;left:0}.menus-move-left:before{content:"\f345"}.menus-move-right:before{content:"\f341"}.reordering .menu-item .item-controls,.reordering .menu-item .item-type{display:none}.menu-location-settings .new-menu-locations-widget-note,.reordering .menu-item-reorder-nav{display:block}.customize-control input.menu-name-field{width:100%}.wp-customizer .menu-item .item-edit{position:absolute;left:-19px;top:2px;display:block;width:30px;height:38px;margin-left:0!important;box-shadow:none;outline:0;overflow:hidden;cursor:pointer;text-align:center}.wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:before{content:"\f142"}.wp-customizer .menu-settings dl{margin:12px 0 0;padding:0}.wp-customizer .menu-settings .checkbox-input{margin-top:8px}.wp-customizer .menu-settings .menu-theme-locations{border-top:1px solid #ccc}.wp-customizer .menu-settings{margin-top:36px;border-top:none}.wp-customizer .menu-location-settings{margin-top:12px;border-top:none}.wp-customizer .control-section-nav_menu .menu-location-settings{margin-top:24px;border-top:1px solid #ddd}.customize-control-nav_menu_auto_add,.wp-customizer .control-section-nav_menu .menu-location-settings{padding-top:12px}.menu-location-settings .customize-control-checkbox .theme-location-set{line-height:1}.customize-control-nav_menu_auto_add label{vertical-align:top}.customize-control-menu{margin-top:4px}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle{color:#555}.customize-screen-options-toggle{background:0 0;border:none;color:#555;cursor:pointer;margin:0;padding:20px;position:absolute;left:0;top:30px}#customize-controls .customize-info .customize-help-toggle{padding:20px}#customize-controls .customize-info .customize-help-toggle:before{padding:4px}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover,.active-menu-screen-options .customize-screen-options-toggle,.customize-screen-options-toggle:active,.customize-screen-options-toggle:focus,.customize-screen-options-toggle:hover{color:#0073aa}#customize-controls .customize-info .customize-help-toggle:focus,.customize-screen-options-toggle:focus{outline:0}.customize-screen-options-toggle:before{-moz-osx-font-smoothing:grayscale;border:none;content:"\f111";display:block;font:18px/1 dashicons;padding:5px;text-align:center;text-decoration:none!important;text-indent:0;right:6px;position:absolute;top:6px}#customize-controls .customize-info .customize-help-toggle:focus:before,.customize-screen-options-toggle:focus:before{border-radius:100%}.wp-customizer #screen-options-wrap{display:none;background:#fff;border-top:1px solid #ddd;padding:4px 15px 15px}.wp-customizer .metabox-prefs label{display:block;padding-left:0;line-height:30px}.wp-customizer .toggle-indicator{display:inline-block;font-size:20px;line-height:1}.rtl .wp-customizer .toggle-indicator{text-indent:1px}#available-menu-items .accordion-section-title .toggle-indicator:before,.wp-customizer .menu-item .item-edit .toggle-indicator:before{content:"\f140";display:block;padding:1px 0 1px 2px;speak:none;border-radius:50%;color:#72777c;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.control-section-nav_menu .field-css-classes,.control-section-nav_menu .field-description,.control-section-nav_menu .field-link-target,.control-section-nav_menu .field-title-attribute,.control-section-nav_menu .field-xfn{display:none}.control-section-nav_menu.field-css-classes-active .field-css-classes,.control-section-nav_menu.field-description-active .field-description,.control-section-nav_menu.field-link-target-active .field-link-target,.control-section-nav_menu.field-title-attribute-active .field-title-attribute,.control-section-nav_menu.field-xfn-active .field-xfn{display:block}.menu-item-depth-0{margin-right:0}.menu-item-depth-1{margin-right:20px}.menu-item-depth-2{margin-right:40px}.menu-item-depth-3{margin-right:60px}.menu-item-depth-4{margin-right:80px}.menu-item-depth-5{margin-right:100px}.menu-item-depth-6{margin-right:120px}.menu-item-depth-7{margin-right:140px}.menu-item-depth-8{margin-right:160px}.menu-item-depth-9{margin-right:180px}.menu-item-depth-10{margin-right:200px}.menu-item-depth-11{margin-right:220px}.menu-item-depth-0>.menu-item-bar{margin-left:0}.menu-item-depth-1>.menu-item-bar{margin-left:20px}.menu-item-depth-2>.menu-item-bar{margin-left:40px}.menu-item-depth-3>.menu-item-bar{margin-left:60px}.menu-item-depth-4>.menu-item-bar{margin-left:80px}.menu-item-depth-5>.menu-item-bar{margin-left:100px}.menu-item-depth-6>.menu-item-bar{margin-left:120px}.menu-item-depth-7>.menu-item-bar{margin-left:140px}.menu-item-depth-8>.menu-item-bar{margin-left:160px}.menu-item-depth-9>.menu-item-bar{margin-left:180px}.menu-item-depth-10>.menu-item-bar{margin-left:200px}.menu-item-depth-11>.menu-item-bar{margin-left:220px}.menu-item-depth-0 .menu-item-transport{margin-right:0}.menu-item-depth-1 .menu-item-transport{margin-right:-20px}.menu-item-depth-3 .menu-item-transport{margin-right:-60px}.menu-item-depth-4 .menu-item-transport{margin-right:-80px}.menu-item-depth-2 .menu-item-transport{margin-right:-40px}.menu-item-depth-5 .menu-item-transport{margin-right:-100px}.menu-item-depth-6 .menu-item-transport{margin-right:-120px}.menu-item-depth-7 .menu-item-transport{margin-right:-140px}.menu-item-depth-8 .menu-item-transport{margin-right:-160px}.menu-item-depth-9 .menu-item-transport{margin-right:-180px}.menu-item-depth-10 .menu-item-transport{margin-right:-200px}.menu-item-depth-11 .menu-item-transport{margin-right:-220px}.reordering .menu-item-depth-0{margin-right:0}.reordering .menu-item-depth-1{margin-right:15px}.reordering .menu-item-depth-2{margin-right:30px}.reordering .menu-item-depth-3{margin-right:45px}.reordering .menu-item-depth-4{margin-right:60px}.reordering .menu-item-depth-5{margin-right:75px}.reordering .menu-item-depth-6{margin-right:90px}.reordering .menu-item-depth-7{margin-right:105px}.reordering .menu-item-depth-8{margin-right:120px}.reordering .menu-item-depth-9{margin-right:135px}.reordering .menu-item-depth-10{margin-right:150px}.reordering .menu-item-depth-11{margin-right:165px}.reordering .menu-item-depth-0>.menu-item-bar{margin-left:0}.reordering .menu-item-depth-1>.menu-item-bar{margin-left:15px}.reordering .menu-item-depth-2>.menu-item-bar{margin-left:30px}.reordering .menu-item-depth-3>.menu-item-bar{margin-left:45px}.reordering .menu-item-depth-4>.menu-item-bar{margin-left:60px}.reordering .menu-item-depth-5>.menu-item-bar{margin-left:75px}.reordering .menu-item-depth-6>.menu-item-bar{margin-left:90px}.reordering .menu-item-depth-7>.menu-item-bar{margin-left:105px}.reordering .menu-item-depth-8>.menu-item-bar{margin-left:120px}.reordering .menu-item-depth-9>.menu-item-bar{margin-left:135px}.reordering .menu-item-depth-10>.menu-item-bar{margin-left:150px}.reordering .menu-item-depth-11>.menu-item-bar{margin-left:165px}.control-section-nav_menu.menu .menu-item-edit-active{margin-right:0}.control-section-nav_menu.menu .menu-item-edit-active .menu-item-bar{margin-left:0}.control-section-nav_menu.menu .sortable-placeholder{margin-top:0;margin-bottom:1px;max-width:calc(100% - 2px);float:right;display:list-item;border-color:#a0a5aa}.menu-item-transport li.customize-control{float:none}.control-section-nav_menu.menu ul.menu-item-transport .menu-item-bar{margin-top:0}.adding-menu-items .control-section{opacity:.4}.adding-menu-items .control-panel.control-section,.adding-menu-items .control-section.open{opacity:1}.menu-item-bar .item-delete{color:#a00;position:absolute;top:2px;left:-19px;width:30px;height:38px;cursor:pointer;display:none}.menu-item-bar .item-delete:before{content:"\f335";position:absolute;top:9px;right:5px;border-radius:50%;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ie8 .menu-item-bar .item-delete:before{top:-10px}.menu-item-bar .item-delete:focus,.menu-item-bar .item-delete:hover{box-shadow:none;outline:0;color:#dc3232}.adding-menu-items .menu-item-bar .item-edit{display:none}.adding-menu-items .menu-item-bar .item-delete{display:block}#available-menu-items.opening{overflow-y:hidden}#available-menu-items #available-menu-items-search.open{height:100%;border-bottom:none}#available-menu-items .accordion-section-title{border-right:none;border-left:none;background:#fff;transition:background-color .15s;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}#available-menu-items #available-menu-items-search .accordion-section-title,#available-menu-items .open .accordion-section-title{background:#eee}#available-menu-items .accordion-section-title:after{content:none!important}#available-menu-items .accordion-section-title:hover .toggle-indicator:before,#available-menu-items .button-link:focus .toggle-indicator:before,#available-menu-items .button-link:hover .toggle-indicator:before{color:#23282d}#available-menu-items .open .accordion-section-title .toggle-indicator:before{content:"\f142";color:#23282d}#available-menu-items .available-menu-items-list{overflow-y:auto;max-height:200px;background:0 0}#available-menu-items .accordion-section-title button{display:block;width:28px;height:35px;position:absolute;top:5px;left:5px;box-shadow:none;outline:0;cursor:pointer;text-align:center}#available-menu-items .accordion-section-title .no-items,#available-menu-items .cannot-expand .accordion-section-title .spinner,#available-menu-items .cannot-expand .accordion-section-title>button{display:none}#available-menu-items-search.cannot-expand .accordion-section-title .spinner{display:block}#available-menu-items .cannot-expand .accordion-section-title .no-items{float:left;color:#555d66;font-weight:400;margin-right:5px}#available-menu-items .accordion-section-content{max-height:290px;margin:0;padding:0;position:relative;background:0 0}#available-menu-items .accordion-section-content .available-menu-items-list{margin:0 0 45px;padding:1px 15px 15px}#available-menu-items .accordion-section-content .available-menu-items-list:only-child{margin-bottom:0}#new-custom-menu-item .accordion-section-content{padding:0 15px 15px}#available-menu-items .menu-item-tpl{margin:0}#available-menu-items .new-content-item .create-item-input.invalid,#available-menu-items .new-content-item .create-item-input.invalid:focus,#custom-menu-item-name.invalid,#custom-menu-item-url.invalid,.edit-menu-item-url.invalid,.menu-name-field.invalid,.menu-name-field.invalid:focus{border:1px solid #dc3232}#available-menu-items .menu-item-handle .item-type{padding-left:0}#available-menu-items .menu-item-handle .item-title{padding-right:20px}#available-menu-items .menu-item-handle{cursor:pointer;box-shadow:none;margin-top:-1px}#available-menu-items .menu-item-handle:hover{z-index:1}#available-menu-items .item-title h4{padding:0 0 5px;font-size:14px}#available-menu-items .item-add{position:absolute;top:1px;right:1px;color:#82878c;width:30px;height:38px;box-shadow:none;outline:0;cursor:pointer;text-align:center}#available-menu-items .menu-item-handle .item-add:focus{color:#23282d}#available-menu-items .item-add:before{content:"\f543";position:relative;right:2px;top:3px;display:inline-block;height:20px;border-radius:50%;font:400 20px/1.05 dashicons}#available-menu-items .menu-item-handle.item-added .item-add:focus,#available-menu-items .menu-item-handle.item-added .item-title,#available-menu-items .menu-item-handle.item-added .item-type,#available-menu-items .menu-item-handle.item-added:hover .item-add{color:#82878c}#available-menu-items .menu-item-handle.item-added .item-add:before{content:"\f147"}#available-menu-items .accordion-section-title.loading .spinner,#available-menu-items-search.loading .accordion-section-title .spinner{visibility:visible;margin:0 20px}#available-menu-items-search .spinner{position:absolute;top:20px;left:21px;margin:0!important}#available-menu-items #available-menu-items-search .accordion-section-content{position:absolute;right:0;top:60px;bottom:0;max-height:none;width:100%;padding:1px 15px 15px;box-sizing:border-box}#available-menu-items-search .nothing-found{margin-top:-1px}#available-menu-items-search .accordion-section-title:after{display:none}#available-menu-items-search .accordion-section-content:empty{min-height:0;padding:0}#available-menu-items-search.loading .accordion-section-content div{opacity:.5}#available-menu-items-search.loading.loading-more .accordion-section-content div{opacity:1}#customize-preview{transition:all .2s}body.adding-menu-items #available-menu-items{right:0;visibility:visible}body.adding-menu-items .wp-full-overlay-main{right:300px}body.adding-menu-items #customize-preview{opacity:.4}body.adding-menu-items #customize-preview iframe{pointer-events:none}.menu-item-handle .spinner{display:none;float:right;margin:0 0 0 8px}.nav-menu-inserted-item-loading .spinner{display:block}.nav-menu-inserted-item-loading .menu-item-handle .item-type{padding:0 8px 0 0}.added-menu-item .menu-item-handle.loading,.nav-menu-inserted-item-loading .menu-item-handle{padding:10px 8px 10px 15px;cursor:default;opacity:.5;background:#fff;color:#727773}.added-menu-item .menu-item-handle{transition-property:opacity,background,color;transition-duration:1.25s;transition-timing-function:cubic-bezier(.25,-2.5,.75,8)}#customize-theme-controls .control-panel-content .control-section-nav_menu:nth-last-child(2) .accordion-section-title{border-bottom-color:#ddd}#accordion-section-add_menu{margin:15px 12px}#accordion-section-add_menu h3{text-align:left}#accordion-section-add_menu .customize-add-menu-button,#accordion-section-add_menu h3{margin:0}#accordion-section-add_menu .customize-add-menu-button{font-weight:400}#create-new-menu-submit{float:left;margin:0 0 12px}.menu-delete-item{float:right;padding:1em 0;width:100%}.assigned-menu-locations-title p{margin:0 0 8px}li.assigned-to-menu-location .menu-delete-item{display:none}li.assigned-to-menu-location .add-new-menu-item{margin-bottom:1em}.menu-item-handle{margin-top:-1px}.ui-sortable-disabled .menu-item-handle{cursor:default}.menu-item-handle:hover{position:relative;z-index:10;color:#0073aa}#available-menu-items .menu-item-handle:hover .item-add,.menu-item-handle:hover .item-edit,.menu-item-handle:hover .item-type{color:#0073aa}.menu-item-edit-active .menu-item-handle{border-color:#999;border-bottom:none}.customize-control-nav_menu_item{margin-bottom:0}.customize-control-nav_menu .new-menu-item-invitation{margin-top:0;margin-bottom:0}.customize-control-nav_menu .customize-control-nav_menu-buttons{margin-top:12px}#available-menu-items .item-add:focus:before,#customize-controls .customize-info .customize-help-toggle:focus:before,.customize-screen-options-toggle:focus:before,.menu-delete:focus,.menu-item-bar .item-delete:focus:before,.wp-customizer .menu-item .submitbox .submitdelete:focus,.wp-customizer button:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}@media screen and (max-width:782px){#available-menu-items #available-menu-items-search .accordion-section-content{top:63px}}@media screen and (max-width:640px){#available-menu-items #available-menu-items-search .accordion-section-content{top:130px}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-nav-menus.css b/backend/wp-admin/css/customize-nav-menus.css new file mode 100644 index 0000000..899c078 --- /dev/null +++ b/backend/wp-admin/css/customize-nav-menus.css @@ -0,0 +1,887 @@ +#customize-theme-controls #accordion-section-menu_locations { + position: relative; + margin-top: 30px; +} + +#customize-theme-controls #accordion-section-menu_locations > .accordion-section-title { + border-bottom-color: #ddd; + margin-top: 15px; +} + +#customize-theme-controls .customize-section-title-nav_menus-heading, +#customize-theme-controls .customize-section-title-menu_locations-heading, +#customize-theme-controls .customize-section-title-menu_locations-description { + padding: 0 12px 0 12px; +} + +#customize-theme-controls .customize-control-description.customize-section-title-menu_locations-description { + /* Override the default italic style for control descriptions */ + font-style: normal; +} + +.menu-in-location, +.menu-in-locations { + display: block; + font-weight: 600; + font-size: 10px; +} + +#customize-controls .theme-location-set, +#customize-controls .control-section .accordion-section-title:focus .menu-in-location, +#customize-controls .control-section .accordion-section-title:hover .menu-in-location { + color: #555; +} + +/* The `edit-menu` and `create-menu` buttons also use the `button-link` class. */ +.customize-control-nav_menu_location .edit-menu, +.customize-control-nav_menu_location .create-menu { + margin-left: 6px; + vertical-align: middle; + line-height: 28px; +} + +#customize-controls .customize-control-nav_menu_name { + margin-bottom: 12px; +} + +.customize-control-nav_menu_name p:last-of-type { + margin-bottom: 0; +} + +#customize-new-menu-submit { + float: right; + min-width: 85px; +} + +.wp-customizer .menu-item-bar .menu-item-handle, +.wp-customizer .menu-item-settings, +.wp-customizer .menu-item-settings .description-thin { + box-sizing: border-box; +} + +.wp-customizer .menu-item-bar { + margin: 0; +} + +.wp-customizer .menu-item-bar .menu-item-handle { + width: 100%; + background: #fff; +} + +.wp-customizer .menu-item-handle .item-title { + margin-right: 0; +} + +.wp-customizer .menu-item-handle .item-type { + padding: 1px 21px 0 5px; + float: right; + text-align: right; +} + +.wp-customizer .menu-item-handle:hover { + z-index: 8; +} + +.customize-control-nav_menu_item.has-notifications .menu-item-handle { + border-left: 4px solid #00a0d2; +} + +.wp-customizer .menu-item-settings { + max-width: 100%; + overflow: hidden; + z-index: 8; + padding: 10px; + background: #eee; + border: 1px solid #999; + border-top: none; +} + +.wp-customizer .menu-item-settings .description-thin { + width: 100%; + height: auto; + margin: 0 0 8px 0; +} + +.wp-customizer .menu-item-settings input[type="text"] { + width: 100%; +} + +.wp-customizer .menu-item-settings .submitbox { + margin: 0; + padding: 0; +} + +.wp-customizer .menu-item-settings .link-to-original { + padding: 5px 0; + border: none; + font-style: normal; + margin: 0; + width: 100%; +} + +.wp-customizer .menu-item .submitbox .submitdelete { + float: left; + margin: 6px 0 0; + padding: 0; + cursor: pointer; +} + + +/** + * Menu items reordering styles + */ + +.menu-item-reorder-nav { + display: none; + background-color: #fff; + position: absolute; + top: 0; + right: 0; +} + +.menus-move-left:before { + content: "\f341"; +} + +.menus-move-right:before { + content: "\f345"; +} + +.reordering .menu-item .item-controls, +.reordering .menu-item .item-type { + display: none; +} + +.reordering .menu-item-reorder-nav { + display: block; +} + +.customize-control input.menu-name-field { + width: 100%; /* Override the 98% default for customizer inputs, to align with the size of menu items. */ +} + +.wp-customizer .menu-item .item-edit { + position: absolute; + right: -19px; + top: 2px; + display: block; + width: 30px; + height: 38px; + margin-right: 0 !important; + box-shadow: none; + outline: none; + overflow: hidden; + cursor: pointer; + text-align: center; +} + +.wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:before { + content: "\f142"; +} + +.wp-customizer .menu-item-settings p.description { + font-style: normal; +} + +.wp-customizer .menu-settings dl { + margin: 12px 0 0 0; + padding: 0; +} + +.wp-customizer .menu-settings .checkbox-input { + margin-top: 8px; +} + +.wp-customizer .menu-settings .menu-theme-locations { + border-top: 1px solid #ccc; +} + +.wp-customizer .menu-settings { + margin-top: 36px; + border-top: none; +} + +.wp-customizer .menu-location-settings { + margin-top: 12px; + border-top: none; +} + +.wp-customizer .control-section-nav_menu .menu-location-settings { + margin-top: 24px; + border-top: 1px solid #ddd; +} + +.wp-customizer .control-section-nav_menu .menu-location-settings, +.customize-control-nav_menu_auto_add { + padding-top: 12px; +} + +.menu-location-settings .customize-control-checkbox .theme-location-set { + line-height: 1; +} + +.customize-control-nav_menu_auto_add label { + vertical-align: top; +} + +.menu-location-settings .new-menu-locations-widget-note { + display: block; +} + +.customize-control-menu { + margin-top: 4px; +} + +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle { + color: #555; +} + +/* Screen Options */ +.customize-screen-options-toggle { + background: none; + border: none; + color: #555; + cursor: pointer; + margin: 0; + padding: 20px; + position: absolute; + right: 0; + top: 30px; +} + +#customize-controls .customize-info .customize-help-toggle { + padding: 20px; +} + +#customize-controls .customize-info .customize-help-toggle:before { + padding: 4px; +} + +.customize-screen-options-toggle:hover, +.customize-screen-options-toggle:active, +.customize-screen-options-toggle:focus, +.active-menu-screen-options .customize-screen-options-toggle, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active, +#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus { + color: #0073aa; +} + +.customize-screen-options-toggle:focus, +#customize-controls .customize-info .customize-help-toggle:focus { + outline: none; +} + +.customize-screen-options-toggle:before { + -moz-osx-font-smoothing: grayscale; + border: none; + content: "\f111"; + display: block; + font: 18px/1 dashicons; + padding: 5px; + text-align: center; + text-decoration: none !important; + text-indent: 0; + left: 6px; + position: absolute; + top: 6px; +} + +.customize-screen-options-toggle:focus:before, +#customize-controls .customize-info .customize-help-toggle:focus:before { + border-radius: 100%; +} + +.wp-customizer #screen-options-wrap { + display: none; + background: #fff; + border-top: 1px solid #ddd; + padding: 4px 15px 15px; +} + +.wp-customizer .metabox-prefs label { + display: block; + padding-right: 0; + line-height: 30px; +} + +/* rework the arrow indicator implementation for NVDA bug same as #32715 */ +.wp-customizer .toggle-indicator { + display: inline-block; + font-size: 20px; + line-height: 1; +} + +.rtl .wp-customizer .toggle-indicator { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.wp-customizer .menu-item .item-edit .toggle-indicator:before, +#available-menu-items .accordion-section-title .toggle-indicator:before { + content: "\f140"; + display: block; + padding: 1px 2px 1px 0px; + speak: none; + border-radius: 50%; + color: #72777c; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; +} + +.control-section-nav_menu .field-link-target, +.control-section-nav_menu .field-title-attribute, +.control-section-nav_menu .field-css-classes, +.control-section-nav_menu .field-xfn, +.control-section-nav_menu .field-description { + display: none; +} + +.control-section-nav_menu.field-link-target-active .field-link-target, +.control-section-nav_menu.field-title-attribute-active .field-title-attribute, +.control-section-nav_menu.field-css-classes-active .field-css-classes, +.control-section-nav_menu.field-xfn-active .field-xfn, +.control-section-nav_menu.field-description-active .field-description { + display: block; +} + +/* WARNING: The 20px factor is hard-coded in JS. */ +.menu-item-depth-0 { margin-left: 0; } +.menu-item-depth-1 { margin-left: 20px; } +.menu-item-depth-2 { margin-left: 40px; } +.menu-item-depth-3 { margin-left: 60px; } +.menu-item-depth-4 { margin-left: 80px; } +.menu-item-depth-5 { margin-left: 100px; } +.menu-item-depth-6 { margin-left: 120px; } +.menu-item-depth-7 { margin-left: 140px; } +.menu-item-depth-8 { margin-left: 160px; } /* Not likely to be used or useful beyond this depth */ +.menu-item-depth-9 { margin-left: 180px; } +.menu-item-depth-10 { margin-left: 200px; } +.menu-item-depth-11 { margin-left: 220px; } + +/* @todo handle .menu-item-settings width */ +.menu-item-depth-0 > .menu-item-bar { margin-right: 0; } +.menu-item-depth-1 > .menu-item-bar { margin-right: 20px; } +.menu-item-depth-2 > .menu-item-bar { margin-right: 40px; } +.menu-item-depth-3 > .menu-item-bar { margin-right: 60px; } +.menu-item-depth-4 > .menu-item-bar { margin-right: 80px; } +.menu-item-depth-5 > .menu-item-bar { margin-right: 100px; } +.menu-item-depth-6 > .menu-item-bar { margin-right: 120px; } +.menu-item-depth-7 > .menu-item-bar { margin-right: 140px; } +.menu-item-depth-8 > .menu-item-bar { margin-right: 160px; } +.menu-item-depth-9 > .menu-item-bar { margin-right: 180px; } +.menu-item-depth-10 > .menu-item-bar { margin-right: 200px; } +.menu-item-depth-11 > .menu-item-bar { margin-right: 220px; } + +/* Submenu left margin. */ +.menu-item-depth-0 .menu-item-transport { margin-left: 0; } +.menu-item-depth-1 .menu-item-transport { margin-left: -20px; } +.menu-item-depth-3 .menu-item-transport { margin-left: -60px; } +.menu-item-depth-4 .menu-item-transport { margin-left: -80px; } +.menu-item-depth-2 .menu-item-transport { margin-left: -40px; } +.menu-item-depth-5 .menu-item-transport { margin-left: -100px; } +.menu-item-depth-6 .menu-item-transport { margin-left: -120px; } +.menu-item-depth-7 .menu-item-transport { margin-left: -140px; } +.menu-item-depth-8 .menu-item-transport { margin-left: -160px; } +.menu-item-depth-9 .menu-item-transport { margin-left: -180px; } +.menu-item-depth-10 .menu-item-transport { margin-left: -200px; } +.menu-item-depth-11 .menu-item-transport { margin-left: -220px; } + +/* WARNING: The 20px factor is hard-coded in JS. */ +.reordering .menu-item-depth-0 { margin-left: 0; } +.reordering .menu-item-depth-1 { margin-left: 15px; } +.reordering .menu-item-depth-2 { margin-left: 30px; } +.reordering .menu-item-depth-3 { margin-left: 45px; } +.reordering .menu-item-depth-4 { margin-left: 60px; } +.reordering .menu-item-depth-5 { margin-left: 75px; } +.reordering .menu-item-depth-6 { margin-left: 90px; } +.reordering .menu-item-depth-7 { margin-left: 105px; } +.reordering .menu-item-depth-8 { margin-left: 120px; } /* Not likely to be used or useful beyond this depth */ +.reordering .menu-item-depth-9 { margin-left: 135px; } +.reordering .menu-item-depth-10 { margin-left: 150px; } +.reordering .menu-item-depth-11 { margin-left: 165px; } + +.reordering .menu-item-depth-0 > .menu-item-bar { margin-right: 0; } +.reordering .menu-item-depth-1 > .menu-item-bar { margin-right: 15px; } +.reordering .menu-item-depth-2 > .menu-item-bar { margin-right: 30px; } +.reordering .menu-item-depth-3 > .menu-item-bar { margin-right: 45px; } +.reordering .menu-item-depth-4 > .menu-item-bar { margin-right: 60px; } +.reordering .menu-item-depth-5 > .menu-item-bar { margin-right: 75px; } +.reordering .menu-item-depth-6 > .menu-item-bar { margin-right: 90px; } +.reordering .menu-item-depth-7 > .menu-item-bar { margin-right: 105px; } +.reordering .menu-item-depth-8 > .menu-item-bar { margin-right: 120px; } +.reordering .menu-item-depth-9 > .menu-item-bar { margin-right: 135px; } +.reordering .menu-item-depth-10 > .menu-item-bar { margin-right: 150px; } +.reordering .menu-item-depth-11 > .menu-item-bar { margin-right: 165px; } + +.control-section-nav_menu.menu .menu-item-edit-active { + margin-left: 0; +} + +.control-section-nav_menu.menu .menu-item-edit-active .menu-item-bar { + margin-right: 0; +} + +.control-section-nav_menu.menu .sortable-placeholder { + margin-top: 0; + margin-bottom: 1px; + max-width: calc(100% - 2px); + float: left; + display: list-item; + border-color: #a0a5aa; +} + +.menu-item-transport li.customize-control { + float: none; +} + +.control-section-nav_menu.menu ul.menu-item-transport .menu-item-bar { + margin-top: 0; +} + +/** + * Add-menu-items mode + */ + +.adding-menu-items .control-section { + opacity: .4; +} + +.adding-menu-items .control-panel.control-section, +.adding-menu-items .control-section.open { + opacity: 1; +} + +.menu-item-bar .item-delete { + color: #a00; + position: absolute; + top: 2px; + right: -19px; + width: 30px; + height: 38px; + cursor: pointer; + display: none; +} + +.menu-item-bar .item-delete:before { + content: "\f335"; + position: absolute; + top: 9px; + left: 5px; + border-radius: 50%; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.ie8 .menu-item-bar .item-delete:before { + top: -10px; +} + +.menu-item-bar .item-delete:hover, +.menu-item-bar .item-delete:focus { + box-shadow: none; + outline: none; + color: #dc3232; +} + +.adding-menu-items .menu-item-bar .item-edit { + display: none; +} + +.adding-menu-items .menu-item-bar .item-delete { + display: block; +} + +/** + * Styles for menu-item addition panel + */ + +#available-menu-items.opening { + overflow-y: hidden; /* avoid scrollbar jitter with animating heights */ +} + +#available-menu-items #available-menu-items-search.open { + height: 100%; + border-bottom: none; +} + +#available-menu-items .accordion-section-title { + border-left: none; + border-right: none; + background: #fff; + transition: background-color 0.15s; + /* Reset the value inherited from the base .accordion-section-title style. Ticket #37589. */ + -webkit-user-select: auto; + -moz-user-select: auto; + -ms-user-select: auto; + user-select: auto; +} + +#available-menu-items .open .accordion-section-title, +#available-menu-items #available-menu-items-search .accordion-section-title { + background: #eee; +} + +/* rework the arrow indicator implementation for NVDA bug see #32715 */ +#available-menu-items .accordion-section-title:after { + content: none !important; +} + +#available-menu-items .accordion-section-title:hover .toggle-indicator:before, +#available-menu-items .button-link:hover .toggle-indicator:before, +#available-menu-items .button-link:focus .toggle-indicator:before { + color: #23282d; +} + +#available-menu-items .open .accordion-section-title .toggle-indicator:before { + content: "\f142"; + color: #23282d; +} + +#available-menu-items .available-menu-items-list { + overflow-y: auto; + max-height: 200px; /* This gets set in JS to fit the screen size, and based on # of sections. */ + background: transparent; +} + +#available-menu-items .accordion-section-title button { + display: block; + width: 28px; + height: 35px; + position: absolute; + top: 5px; + right: 5px; + box-shadow: none; + outline: none; + cursor: pointer; + text-align: center; +} + +#available-menu-items .accordion-section-title .no-items, +#available-menu-items .cannot-expand .accordion-section-title .spinner, +#available-menu-items .cannot-expand .accordion-section-title > button { + display: none; +} + +#available-menu-items-search.cannot-expand .accordion-section-title .spinner { + display: block; +} + +#available-menu-items .cannot-expand .accordion-section-title .no-items { + float: right; + color: #555d66; + font-weight: 400; + margin-left: 5px; +} + +#available-menu-items .accordion-section-content { + max-height: 290px; + margin: 0; + padding: 0; + position: relative; + background: transparent; +} + +#available-menu-items .accordion-section-content .available-menu-items-list { + margin: 0 0 45px 0; + padding: 1px 15px 15px 15px; +} + +#available-menu-items .accordion-section-content .available-menu-items-list:only-child { /* Types that do not support new items for the current user */ + margin-bottom: 0; +} + +#new-custom-menu-item .accordion-section-content { + padding: 0 15px 15px 15px; +} + +#available-menu-items .menu-item-tpl { + margin: 0; +} + +#custom-menu-item-name.invalid, +#custom-menu-item-url.invalid, +.edit-menu-item-url.invalid, +.menu-name-field.invalid, +.menu-name-field.invalid:focus, +#available-menu-items .new-content-item .create-item-input.invalid, +#available-menu-items .new-content-item .create-item-input.invalid:focus { + border: 1px solid #dc3232; +} + +#available-menu-items .menu-item-handle .item-type { + padding-right: 0; +} + +#available-menu-items .menu-item-handle .item-title { + padding-left: 20px; +} + +#available-menu-items .menu-item-handle { + cursor: pointer; +} + +#available-menu-items .menu-item-handle { + box-shadow: none; + margin-top: -1px; +} + +#available-menu-items .menu-item-handle:hover { + z-index: 1; +} + +#available-menu-items .item-title h4 { + padding: 0 0 5px; + font-size: 14px; +} + +#available-menu-items .item-add { + position: absolute; + top: 1px; + left: 1px; + color: #82878c; + width: 30px; + height: 38px; + box-shadow: none; + outline: none; + cursor: pointer; + text-align: center; +} + +#available-menu-items .menu-item-handle .item-add:focus { + color: #23282d; +} + +#available-menu-items .item-add:before { + content: "\f543"; + position: relative; + left: 2px; + top: 3px; + display: inline-block; + height: 20px; + border-radius: 50%; + font: normal 20px/1.05 dashicons; /* line height is to account for the dashicon's vertical alignment */ +} + +#available-menu-items .menu-item-handle.item-added .item-type, +#available-menu-items .menu-item-handle.item-added .item-title, +#available-menu-items .menu-item-handle.item-added:hover .item-add, +#available-menu-items .menu-item-handle.item-added .item-add:focus { + color: #82878c; +} + +#available-menu-items .menu-item-handle.item-added .item-add:before { + content: "\f147"; +} + +#available-menu-items .accordion-section-title.loading .spinner, +#available-menu-items-search.loading .accordion-section-title .spinner { + visibility: visible; + margin: 0 20px; +} + +#available-menu-items-search .spinner { + position: absolute; + top: 20px; /* 13 container padding +1 input margin +6 ( ( 32 input height - 20 spinner height ) / 2 ) */ + right: 21px; + margin: 0 !important; +} + +/* search results list */ +#available-menu-items #available-menu-items-search .accordion-section-content { + position: absolute; + left: 0; + top: 60px; /* below title div / search input */ + bottom: 0px; /* 100% height that still triggers lazy load */ + max-height: none; + width: 100%; + padding: 1px 15px 15px; + box-sizing: border-box; +} + +#available-menu-items-search .nothing-found { + /* Compensate the 1px top padding of the container. */ + margin-top: -1px; +} + +#available-menu-items-search .accordion-section-title:after { + display: none; +} + +#available-menu-items-search .accordion-section-content:empty { + min-height: 0; + padding: 0; +} + +#available-menu-items-search.loading .accordion-section-content div { + opacity: .5; +} + +#available-menu-items-search.loading.loading-more .accordion-section-content div { + opacity: 1; +} + +#customize-preview { + transition: all 0.2s; +} + +body.adding-menu-items #available-menu-items { + left: 0; + visibility: visible; +} + +body.adding-menu-items .wp-full-overlay-main { + left: 300px; +} + +body.adding-menu-items #customize-preview { + opacity: 0.4; +} + +body.adding-menu-items #customize-preview iframe { + pointer-events: none; +} + +.menu-item-handle .spinner { + display: none; + float: left; + margin: 0 8px 0 0; +} + +.nav-menu-inserted-item-loading .spinner { + display: block; +} + +.nav-menu-inserted-item-loading .menu-item-handle .item-type { + padding: 0 0 0 8px; +} + +.nav-menu-inserted-item-loading .menu-item-handle, +.added-menu-item .menu-item-handle.loading { + padding: 10px 15px 10px 8px; + cursor: default; + opacity: .5; + background: #fff; + color: #727773; +} + +.added-menu-item .menu-item-handle { + transition-property: opacity, background, color; + transition-duration: 1.25s; + transition-timing-function: cubic-bezier( .25, -2.5, .75, 8 ); /* Replacement for .hide().fadeIn('slow') in JS to add emphasis when it's loaded. */ +} + +/* Add/delete Menus */ + +#customize-theme-controls .control-panel-content .control-section-nav_menu:nth-last-child(2) .accordion-section-title { + border-bottom-color: #ddd; +} + +/* @todo update selector */ +#accordion-section-add_menu { + margin: 15px 12px; +} + +#accordion-section-add_menu h3 { + text-align: right; +} + +#accordion-section-add_menu h3, +#accordion-section-add_menu .customize-add-menu-button { + margin: 0; +} + +#accordion-section-add_menu .customize-add-menu-button { + font-weight: normal; +} + +#create-new-menu-submit { + float: right; + margin: 0 0 12px 0; +} + +.menu-delete-item { + float: left; + padding: 1em 0; + width: 100%; +} + +.assigned-menu-locations-title p { + margin: 0 0 8px 0; +} + +li.assigned-to-menu-location .menu-delete-item { + display: none; +} + +li.assigned-to-menu-location .add-new-menu-item { + margin-bottom: 1em; +} + +.menu-item-handle { + margin-top: -1px; +} +.ui-sortable-disabled .menu-item-handle { + cursor: default; +} + +.menu-item-handle:hover { + position: relative; + z-index: 10; + color: #0073aa; +} + +.menu-item-handle:hover .item-type, +.menu-item-handle:hover .item-edit, +#available-menu-items .menu-item-handle:hover .item-add { + color: #0073aa; +} + +.menu-item-edit-active .menu-item-handle { + border-color: #999; + border-bottom: none; +} + +.customize-control-nav_menu_item { + margin-bottom: 0; +} + +.customize-control-nav_menu .new-menu-item-invitation { + margin-top: 0; + margin-bottom: 0; +} + +.customize-control-nav_menu .customize-control-nav_menu-buttons { + margin-top: 12px; +} + +/** + * box-shadows + */ + +.wp-customizer .menu-item .submitbox .submitdelete:focus, +.customize-screen-options-toggle:focus:before, +#customize-controls .customize-info .customize-help-toggle:focus:before, +.wp-customizer button:focus .toggle-indicator:before, +.menu-delete:focus, +.menu-item-bar .item-delete:focus:before, +#available-menu-items .item-add:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + + +@media screen and ( max-width: 782px ) { + #available-menu-items #available-menu-items-search .accordion-section-content { + top: 63px; + } +} + +@media screen and ( max-width: 640px ) { + #available-menu-items #available-menu-items-search .accordion-section-content { + top: 130px; + } +} diff --git a/backend/wp-admin/css/customize-nav-menus.min.css b/backend/wp-admin/css/customize-nav-menus.min.css new file mode 100644 index 0000000..1862dfd --- /dev/null +++ b/backend/wp-admin/css/customize-nav-menus.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#customize-theme-controls .customize-control-description.customize-section-title-menu_locations-description,.wp-customizer .menu-item-settings p.description{font-style:normal}#customize-theme-controls #accordion-section-menu_locations{position:relative;margin-top:30px}#customize-theme-controls #accordion-section-menu_locations>.accordion-section-title{border-bottom-color:#ddd;margin-top:15px}#customize-theme-controls .customize-section-title-menu_locations-description,#customize-theme-controls .customize-section-title-menu_locations-heading,#customize-theme-controls .customize-section-title-nav_menus-heading{padding:0 12px}.menu-in-location,.menu-in-locations{display:block;font-weight:600;font-size:10px}#customize-controls .control-section .accordion-section-title:focus .menu-in-location,#customize-controls .control-section .accordion-section-title:hover .menu-in-location,#customize-controls .theme-location-set{color:#555}.customize-control-nav_menu_location .create-menu,.customize-control-nav_menu_location .edit-menu{margin-left:6px;vertical-align:middle;line-height:28px}#customize-controls .customize-control-nav_menu_name{margin-bottom:12px}.customize-control-nav_menu_name p:last-of-type{margin-bottom:0}#customize-new-menu-submit{float:right;min-width:85px}.wp-customizer .menu-item-bar .menu-item-handle,.wp-customizer .menu-item-settings,.wp-customizer .menu-item-settings .description-thin{box-sizing:border-box}.wp-customizer .menu-item-bar{margin:0}.wp-customizer .menu-item-bar .menu-item-handle{width:100%;background:#fff}.wp-customizer .menu-item-handle .item-title{margin-right:0}.wp-customizer .menu-item-handle .item-type{padding:1px 21px 0 5px;float:right;text-align:right}.wp-customizer .menu-item-handle:hover{z-index:8}.customize-control-nav_menu_item.has-notifications .menu-item-handle{border-left:4px solid #00a0d2}.wp-customizer .menu-item-settings{max-width:100%;overflow:hidden;z-index:8;padding:10px;background:#eee;border:1px solid #999;border-top:none}.wp-customizer .menu-item-settings .description-thin{width:100%;height:auto;margin:0 0 8px}.wp-customizer .menu-item-settings input[type=text]{width:100%}.wp-customizer .menu-item-settings .submitbox{margin:0;padding:0}.wp-customizer .menu-item-settings .link-to-original{padding:5px 0;border:none;font-style:normal;margin:0;width:100%}.wp-customizer .menu-item .submitbox .submitdelete{float:left;margin:6px 0 0;padding:0;cursor:pointer}.menu-item-reorder-nav{display:none;background-color:#fff;position:absolute;top:0;right:0}.menus-move-left:before{content:"\f341"}.menus-move-right:before{content:"\f345"}.reordering .menu-item .item-controls,.reordering .menu-item .item-type{display:none}.menu-location-settings .new-menu-locations-widget-note,.reordering .menu-item-reorder-nav{display:block}.customize-control input.menu-name-field{width:100%}.wp-customizer .menu-item .item-edit{position:absolute;right:-19px;top:2px;display:block;width:30px;height:38px;margin-right:0!important;box-shadow:none;outline:0;overflow:hidden;cursor:pointer;text-align:center}.wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:before{content:"\f142"}.wp-customizer .menu-settings dl{margin:12px 0 0;padding:0}.wp-customizer .menu-settings .checkbox-input{margin-top:8px}.wp-customizer .menu-settings .menu-theme-locations{border-top:1px solid #ccc}.wp-customizer .menu-settings{margin-top:36px;border-top:none}.wp-customizer .menu-location-settings{margin-top:12px;border-top:none}.wp-customizer .control-section-nav_menu .menu-location-settings{margin-top:24px;border-top:1px solid #ddd}.customize-control-nav_menu_auto_add,.wp-customizer .control-section-nav_menu .menu-location-settings{padding-top:12px}.menu-location-settings .customize-control-checkbox .theme-location-set{line-height:1}.customize-control-nav_menu_auto_add label{vertical-align:top}.customize-control-menu{margin-top:4px}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle{color:#555}.customize-screen-options-toggle{background:0 0;border:none;color:#555;cursor:pointer;margin:0;padding:20px;position:absolute;right:0;top:30px}#customize-controls .customize-info .customize-help-toggle{padding:20px}#customize-controls .customize-info .customize-help-toggle:before{padding:4px}#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:active,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:focus,#customize-controls .customize-info.open.active-menu-screen-options .customize-help-toggle:hover,.active-menu-screen-options .customize-screen-options-toggle,.customize-screen-options-toggle:active,.customize-screen-options-toggle:focus,.customize-screen-options-toggle:hover{color:#0073aa}#customize-controls .customize-info .customize-help-toggle:focus,.customize-screen-options-toggle:focus{outline:0}.customize-screen-options-toggle:before{-moz-osx-font-smoothing:grayscale;border:none;content:"\f111";display:block;font:18px/1 dashicons;padding:5px;text-align:center;text-decoration:none!important;text-indent:0;left:6px;position:absolute;top:6px}#customize-controls .customize-info .customize-help-toggle:focus:before,.customize-screen-options-toggle:focus:before{border-radius:100%}.wp-customizer #screen-options-wrap{display:none;background:#fff;border-top:1px solid #ddd;padding:4px 15px 15px}.wp-customizer .metabox-prefs label{display:block;padding-right:0;line-height:30px}.wp-customizer .toggle-indicator{display:inline-block;font-size:20px;line-height:1}.rtl .wp-customizer .toggle-indicator{text-indent:1px}#available-menu-items .accordion-section-title .toggle-indicator:before,.wp-customizer .menu-item .item-edit .toggle-indicator:before{content:"\f140";display:block;padding:1px 2px 1px 0;speak:none;border-radius:50%;color:#72777c;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important}.control-section-nav_menu .field-css-classes,.control-section-nav_menu .field-description,.control-section-nav_menu .field-link-target,.control-section-nav_menu .field-title-attribute,.control-section-nav_menu .field-xfn{display:none}.control-section-nav_menu.field-css-classes-active .field-css-classes,.control-section-nav_menu.field-description-active .field-description,.control-section-nav_menu.field-link-target-active .field-link-target,.control-section-nav_menu.field-title-attribute-active .field-title-attribute,.control-section-nav_menu.field-xfn-active .field-xfn{display:block}.menu-item-depth-0{margin-left:0}.menu-item-depth-1{margin-left:20px}.menu-item-depth-2{margin-left:40px}.menu-item-depth-3{margin-left:60px}.menu-item-depth-4{margin-left:80px}.menu-item-depth-5{margin-left:100px}.menu-item-depth-6{margin-left:120px}.menu-item-depth-7{margin-left:140px}.menu-item-depth-8{margin-left:160px}.menu-item-depth-9{margin-left:180px}.menu-item-depth-10{margin-left:200px}.menu-item-depth-11{margin-left:220px}.menu-item-depth-0>.menu-item-bar{margin-right:0}.menu-item-depth-1>.menu-item-bar{margin-right:20px}.menu-item-depth-2>.menu-item-bar{margin-right:40px}.menu-item-depth-3>.menu-item-bar{margin-right:60px}.menu-item-depth-4>.menu-item-bar{margin-right:80px}.menu-item-depth-5>.menu-item-bar{margin-right:100px}.menu-item-depth-6>.menu-item-bar{margin-right:120px}.menu-item-depth-7>.menu-item-bar{margin-right:140px}.menu-item-depth-8>.menu-item-bar{margin-right:160px}.menu-item-depth-9>.menu-item-bar{margin-right:180px}.menu-item-depth-10>.menu-item-bar{margin-right:200px}.menu-item-depth-11>.menu-item-bar{margin-right:220px}.menu-item-depth-0 .menu-item-transport{margin-left:0}.menu-item-depth-1 .menu-item-transport{margin-left:-20px}.menu-item-depth-3 .menu-item-transport{margin-left:-60px}.menu-item-depth-4 .menu-item-transport{margin-left:-80px}.menu-item-depth-2 .menu-item-transport{margin-left:-40px}.menu-item-depth-5 .menu-item-transport{margin-left:-100px}.menu-item-depth-6 .menu-item-transport{margin-left:-120px}.menu-item-depth-7 .menu-item-transport{margin-left:-140px}.menu-item-depth-8 .menu-item-transport{margin-left:-160px}.menu-item-depth-9 .menu-item-transport{margin-left:-180px}.menu-item-depth-10 .menu-item-transport{margin-left:-200px}.menu-item-depth-11 .menu-item-transport{margin-left:-220px}.reordering .menu-item-depth-0{margin-left:0}.reordering .menu-item-depth-1{margin-left:15px}.reordering .menu-item-depth-2{margin-left:30px}.reordering .menu-item-depth-3{margin-left:45px}.reordering .menu-item-depth-4{margin-left:60px}.reordering .menu-item-depth-5{margin-left:75px}.reordering .menu-item-depth-6{margin-left:90px}.reordering .menu-item-depth-7{margin-left:105px}.reordering .menu-item-depth-8{margin-left:120px}.reordering .menu-item-depth-9{margin-left:135px}.reordering .menu-item-depth-10{margin-left:150px}.reordering .menu-item-depth-11{margin-left:165px}.reordering .menu-item-depth-0>.menu-item-bar{margin-right:0}.reordering .menu-item-depth-1>.menu-item-bar{margin-right:15px}.reordering .menu-item-depth-2>.menu-item-bar{margin-right:30px}.reordering .menu-item-depth-3>.menu-item-bar{margin-right:45px}.reordering .menu-item-depth-4>.menu-item-bar{margin-right:60px}.reordering .menu-item-depth-5>.menu-item-bar{margin-right:75px}.reordering .menu-item-depth-6>.menu-item-bar{margin-right:90px}.reordering .menu-item-depth-7>.menu-item-bar{margin-right:105px}.reordering .menu-item-depth-8>.menu-item-bar{margin-right:120px}.reordering .menu-item-depth-9>.menu-item-bar{margin-right:135px}.reordering .menu-item-depth-10>.menu-item-bar{margin-right:150px}.reordering .menu-item-depth-11>.menu-item-bar{margin-right:165px}.control-section-nav_menu.menu .menu-item-edit-active{margin-left:0}.control-section-nav_menu.menu .menu-item-edit-active .menu-item-bar{margin-right:0}.control-section-nav_menu.menu .sortable-placeholder{margin-top:0;margin-bottom:1px;max-width:calc(100% - 2px);float:left;display:list-item;border-color:#a0a5aa}.menu-item-transport li.customize-control{float:none}.control-section-nav_menu.menu ul.menu-item-transport .menu-item-bar{margin-top:0}.adding-menu-items .control-section{opacity:.4}.adding-menu-items .control-panel.control-section,.adding-menu-items .control-section.open{opacity:1}.menu-item-bar .item-delete{color:#a00;position:absolute;top:2px;right:-19px;width:30px;height:38px;cursor:pointer;display:none}.menu-item-bar .item-delete:before{content:"\f335";position:absolute;top:9px;left:5px;border-radius:50%;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ie8 .menu-item-bar .item-delete:before{top:-10px}.menu-item-bar .item-delete:focus,.menu-item-bar .item-delete:hover{box-shadow:none;outline:0;color:#dc3232}.adding-menu-items .menu-item-bar .item-edit{display:none}.adding-menu-items .menu-item-bar .item-delete{display:block}#available-menu-items.opening{overflow-y:hidden}#available-menu-items #available-menu-items-search.open{height:100%;border-bottom:none}#available-menu-items .accordion-section-title{border-left:none;border-right:none;background:#fff;transition:background-color .15s;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}#available-menu-items #available-menu-items-search .accordion-section-title,#available-menu-items .open .accordion-section-title{background:#eee}#available-menu-items .accordion-section-title:after{content:none!important}#available-menu-items .accordion-section-title:hover .toggle-indicator:before,#available-menu-items .button-link:focus .toggle-indicator:before,#available-menu-items .button-link:hover .toggle-indicator:before{color:#23282d}#available-menu-items .open .accordion-section-title .toggle-indicator:before{content:"\f142";color:#23282d}#available-menu-items .available-menu-items-list{overflow-y:auto;max-height:200px;background:0 0}#available-menu-items .accordion-section-title button{display:block;width:28px;height:35px;position:absolute;top:5px;right:5px;box-shadow:none;outline:0;cursor:pointer;text-align:center}#available-menu-items .accordion-section-title .no-items,#available-menu-items .cannot-expand .accordion-section-title .spinner,#available-menu-items .cannot-expand .accordion-section-title>button{display:none}#available-menu-items-search.cannot-expand .accordion-section-title .spinner{display:block}#available-menu-items .cannot-expand .accordion-section-title .no-items{float:right;color:#555d66;font-weight:400;margin-left:5px}#available-menu-items .accordion-section-content{max-height:290px;margin:0;padding:0;position:relative;background:0 0}#available-menu-items .accordion-section-content .available-menu-items-list{margin:0 0 45px;padding:1px 15px 15px}#available-menu-items .accordion-section-content .available-menu-items-list:only-child{margin-bottom:0}#new-custom-menu-item .accordion-section-content{padding:0 15px 15px}#available-menu-items .menu-item-tpl{margin:0}#available-menu-items .new-content-item .create-item-input.invalid,#available-menu-items .new-content-item .create-item-input.invalid:focus,#custom-menu-item-name.invalid,#custom-menu-item-url.invalid,.edit-menu-item-url.invalid,.menu-name-field.invalid,.menu-name-field.invalid:focus{border:1px solid #dc3232}#available-menu-items .menu-item-handle .item-type{padding-right:0}#available-menu-items .menu-item-handle .item-title{padding-left:20px}#available-menu-items .menu-item-handle{cursor:pointer;box-shadow:none;margin-top:-1px}#available-menu-items .menu-item-handle:hover{z-index:1}#available-menu-items .item-title h4{padding:0 0 5px;font-size:14px}#available-menu-items .item-add{position:absolute;top:1px;left:1px;color:#82878c;width:30px;height:38px;box-shadow:none;outline:0;cursor:pointer;text-align:center}#available-menu-items .menu-item-handle .item-add:focus{color:#23282d}#available-menu-items .item-add:before{content:"\f543";position:relative;left:2px;top:3px;display:inline-block;height:20px;border-radius:50%;font:400 20px/1.05 dashicons}#available-menu-items .menu-item-handle.item-added .item-add:focus,#available-menu-items .menu-item-handle.item-added .item-title,#available-menu-items .menu-item-handle.item-added .item-type,#available-menu-items .menu-item-handle.item-added:hover .item-add{color:#82878c}#available-menu-items .menu-item-handle.item-added .item-add:before{content:"\f147"}#available-menu-items .accordion-section-title.loading .spinner,#available-menu-items-search.loading .accordion-section-title .spinner{visibility:visible;margin:0 20px}#available-menu-items-search .spinner{position:absolute;top:20px;right:21px;margin:0!important}#available-menu-items #available-menu-items-search .accordion-section-content{position:absolute;left:0;top:60px;bottom:0;max-height:none;width:100%;padding:1px 15px 15px;box-sizing:border-box}#available-menu-items-search .nothing-found{margin-top:-1px}#available-menu-items-search .accordion-section-title:after{display:none}#available-menu-items-search .accordion-section-content:empty{min-height:0;padding:0}#available-menu-items-search.loading .accordion-section-content div{opacity:.5}#available-menu-items-search.loading.loading-more .accordion-section-content div{opacity:1}#customize-preview{transition:all .2s}body.adding-menu-items #available-menu-items{left:0;visibility:visible}body.adding-menu-items .wp-full-overlay-main{left:300px}body.adding-menu-items #customize-preview{opacity:.4}body.adding-menu-items #customize-preview iframe{pointer-events:none}.menu-item-handle .spinner{display:none;float:left;margin:0 8px 0 0}.nav-menu-inserted-item-loading .spinner{display:block}.nav-menu-inserted-item-loading .menu-item-handle .item-type{padding:0 0 0 8px}.added-menu-item .menu-item-handle.loading,.nav-menu-inserted-item-loading .menu-item-handle{padding:10px 15px 10px 8px;cursor:default;opacity:.5;background:#fff;color:#727773}.added-menu-item .menu-item-handle{transition-property:opacity,background,color;transition-duration:1.25s;transition-timing-function:cubic-bezier(.25,-2.5,.75,8)}#customize-theme-controls .control-panel-content .control-section-nav_menu:nth-last-child(2) .accordion-section-title{border-bottom-color:#ddd}#accordion-section-add_menu{margin:15px 12px}#accordion-section-add_menu h3{text-align:right}#accordion-section-add_menu .customize-add-menu-button,#accordion-section-add_menu h3{margin:0}#accordion-section-add_menu .customize-add-menu-button{font-weight:400}#create-new-menu-submit{float:right;margin:0 0 12px}.menu-delete-item{float:left;padding:1em 0;width:100%}.assigned-menu-locations-title p{margin:0 0 8px}li.assigned-to-menu-location .menu-delete-item{display:none}li.assigned-to-menu-location .add-new-menu-item{margin-bottom:1em}.menu-item-handle{margin-top:-1px}.ui-sortable-disabled .menu-item-handle{cursor:default}.menu-item-handle:hover{position:relative;z-index:10;color:#0073aa}#available-menu-items .menu-item-handle:hover .item-add,.menu-item-handle:hover .item-edit,.menu-item-handle:hover .item-type{color:#0073aa}.menu-item-edit-active .menu-item-handle{border-color:#999;border-bottom:none}.customize-control-nav_menu_item{margin-bottom:0}.customize-control-nav_menu .new-menu-item-invitation{margin-top:0;margin-bottom:0}.customize-control-nav_menu .customize-control-nav_menu-buttons{margin-top:12px}#available-menu-items .item-add:focus:before,#customize-controls .customize-info .customize-help-toggle:focus:before,.customize-screen-options-toggle:focus:before,.menu-delete:focus,.menu-item-bar .item-delete:focus:before,.wp-customizer .menu-item .submitbox .submitdelete:focus,.wp-customizer button:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}@media screen and (max-width:782px){#available-menu-items #available-menu-items-search .accordion-section-content{top:63px}}@media screen and (max-width:640px){#available-menu-items #available-menu-items-search .accordion-section-content{top:130px}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-widgets-rtl.css b/backend/wp-admin/css/customize-widgets-rtl.css new file mode 100644 index 0000000..8c13bfb --- /dev/null +++ b/backend/wp-admin/css/customize-widgets-rtl.css @@ -0,0 +1,478 @@ +.wp-full-overlay-sidebar { + overflow: visible; +} + +/** + * Hide all sidebar sections by default, only show them (via JS) once the + * preview loads and we know whether the sidebars are used in the template. + */ + +.control-section.control-section-sidebar, +.customize-control-sidebar_widgets label, +.customize-control-sidebar_widgets .hide-if-js { + /* The link in .customize-control-sidebar_widgets .hide-if-js will fail if it ever gets used. */ + display: none; +} + +.control-section.control-section-sidebar .accordion-section-content.ui-sortable { + overflow: visible; +} + +/* Note: widget-tops are more compact when (max-height: 700px) and (min-width: 981px). */ +.customize-control-widget_form .widget-top { + background: #fff; + transition: opacity 0.5s; +} + +.customize-control .widget-action { + color: #72777c; +} + +.customize-control .widget-top:hover .widget-action, +.customize-control .widget-action:focus { + color: #23282d; +} + +.customize-control-widget_form:not(.widget-rendered) .widget-top { + opacity: 0.5; +} + +.customize-control-widget_form .widget-control-save { + display: none; +} + +.customize-control-widget_form .spinner { + visibility: hidden; + margin-top: 0; +} + +.customize-control-widget_form.previewer-loading .spinner { + visibility: visible; +} + +.customize-control-widget_form.widget-form-disabled .widget-content { + opacity: 0.7; + pointer-events: none; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.customize-control-widget_form .widget { + margin-bottom: 0; +} + +.customize-control-widget_form.wide-widget-control .widget-inside { + position: fixed; + right: 299px; + top: 25%; + border: 1px solid rgb(229, 229, 229); + overflow: auto; +} +.customize-control-widget_form.wide-widget-control .widget-inside > .form { + padding: 20px; +} + +.customize-control-widget_form.wide-widget-control .widget-top { + transition: background-color 0.4s; +} +.customize-control-widget_form.wide-widget-control.expanding .widget-top, +.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top { + background-color: rgb(227, 227, 227); +} + +.widget-inside { + padding: 1px 10px 10px 10px; + border-top: none; + line-height: 16px; +} + +.customize-control-widget_form.expanded .widget-action .toggle-indicator:before { + content: "\f142"; +} + +.customize-control-widget_form.wide-widget-control .widget-action .toggle-indicator:before { + content: "\f141"; +} + +.customize-control-widget_form.wide-widget-control.expanded .widget-action .toggle-indicator:before { + content: "\f139"; +} + +.widget-title-action { + cursor: pointer; +} + +.widget-top, +.customize-control-widget_form .widget .customize-control-title { + cursor: move; +} + +.control-section.accordion-section.highlighted > .accordion-section-title, +.customize-control-widget_form.highlighted { + outline: none; + box-shadow: 0 0 2px rgba(30,140,190,0.8); + position: relative; + z-index: 1; +} + +#widget-customizer-control-templates { + display: none; +} + +/** + * Widget reordering styles + */ + +#customize-theme-controls .widget-reorder-nav { + display: none; + float: left; + background-color: #fafafa; +} + +.move-widget:before { + content: "\f504"; +} + +#customize-theme-controls .move-widget-area { + display: none; + background: #fff; + border: 1px solid #ddd; + border-top: none; + cursor: auto; +} + +#customize-theme-controls .reordering .move-widget-area.active { + display: block; +} + +#customize-theme-controls .move-widget-area .description { + margin: 0; + padding: 15px 20px; + font-weight: 400; +} + +#customize-theme-controls .widget-area-select { + margin: 0; + padding: 0; + list-style: none; +} + +#customize-theme-controls .widget-area-select li { + position: relative; + margin: 0; + padding: 13px 42px 15px 15px; + color: #555; + border-top: 1px solid #eee; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +#customize-theme-controls .widget-area-select li:before { + display: none; + content: "\f147"; + position: absolute; + top: 12px; + right: 10px; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#customize-theme-controls .widget-area-select li:last-child { + border-bottom: 1px solid #eee; +} + +#customize-theme-controls .widget-area-select .selected { + color: #fff; + text-shadow: 0 -1px 0 rgba(0,0,0,.4); + background: #00a0d2; +} + +#customize-theme-controls .widget-area-select .selected:before { + display: block; +} + +#customize-theme-controls .move-widget-actions { + text-align: left; + padding: 12px; +} + +#customize-theme-controls .reordering .widget-title-action { + display: none; +} + +#customize-theme-controls .reordering .widget-reorder-nav { + display: block; +} + +/* Text Widget */ +.wp-customizer div.mce-inline-toolbar-grp, +.wp-customizer div.mce-tooltip { + z-index: 500100 !important; +} +.wp-customizer .ui-autocomplete.wplink-autocomplete { + z-index: 500110; /* originally 100110, but z-index of .wp-full-overlay is 500000 */ +} +.wp-customizer #wp-link-backdrop { + z-index: 500100; /* originally 100100, but z-index of .wp-full-overlay is 500000 */ +} +.wp-customizer #wp-link-wrap { + z-index: 500105; /* originally 100105, but z-index of .wp-full-overlay is 500000 */ +} + +/** + * Styles for new widget addition panel + */ + +/* override widgets admin page rules in wp-admin/css/widgets.css */ +#widgets-left #available-widgets .widget { + float: none !important; + width: auto !important; +} + +.ios #available-widgets { + transition: right 0s; +} + +#available-widgets .widget-tpl:hover, +#available-widgets .widget-tpl.selected { + background: #f3f3f5; + border-bottom-color: #ccc; + color: #0073aa; + border-right: 4px solid #0073aa; +} + +#customize-controls .widget-title h3 { + font-size: 1em; +} + +#available-widgets .widget-title h3 { + padding: 0 0 5px; + font-size: 14px; +} + +#available-widgets .widget .widget-description { + padding: 0; + color: #72777c; +} + +#customize-preview { + transition: all 0.2s; +} + +body.adding-widget #available-widgets { + right: 0; + visibility: visible; +} + +body.adding-widget .wp-full-overlay-main { + right: 300px; +} + +body.adding-widget #customize-preview { + opacity: 0.4; +} + + +/** + * Widget Icon styling + * No plurals in naming. + * Ordered from lowest to highest specificity. + */ + +#available-widgets .widget-title { + position: relative; +} + +#available-widgets .widget-title:before { + content: "\f132"; + position: absolute; + top: -3px; + left: 100%; + margin-left: 20px; + width: 20px; + height: 20px; + color: #32373c; + font: normal 20px/1 dashicons; + text-align: center; + box-sizing: border-box; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* smiley */ +#available-widgets [class*="easy"] .widget-title:before { content: "\f328"; top: -4px; } + +/* star-filled */ +#available-widgets [class*="super"] .widget-title:before, +#available-widgets [class*="like"] .widget-title:before { content: "\f155"; top: -4px; } + +/* wordpress */ +#available-widgets [class*="meta"] .widget-title:before { content: "\f120"; } + +/* archive-box */ +#available-widgets [class*="archives"] .widget-title:before { content: "\f480"; top: -4px; } + +/* category */ +#available-widgets [class*="categor"] .widget-title:before { content: "\f318"; top: -4px; } + +/* comments */ +#available-widgets [class*="comment"] .widget-title:before, +#available-widgets [class*="testimonial"] .widget-title:before, +#available-widgets [class*="chat"] .widget-title:before { content: "\f101"; } + +/* post */ +#available-widgets [class*="post"] .widget-title:before { content: "\f109"; } + +/* admin-page */ +#available-widgets [class*="page"] .widget-title:before { content: "\f105"; } + +/* text */ +#available-widgets [class*="text"] .widget-title:before { content: "\f478"; } + +/* links */ +#available-widgets [class*="link"] .widget-title:before { content: "\f103"; } + +/* search */ +#available-widgets [class*="search"] .widget-title:before { content: "\f179"; } + +/* menu */ +#available-widgets [class*="menu"] .widget-title:before, +#available-widgets [class*="nav"] .widget-title:before { content: "\f333"; } + +/* tag-cloud */ +#available-widgets [class*="tag"] .widget-title:before { content: "\f479"; } + +/* rss */ +#available-widgets [class*="rss"] .widget-title:before { content: "\f303"; top: -6px; } + +/* calendar */ +#available-widgets [class*="event"] .widget-title:before, +#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;} + +/* format-image */ +#available-widgets [class*="image"] .widget-title:before, +#available-widgets [class*="photo"] .widget-title:before, +#available-widgets [class*="slide"] .widget-title:before, +#available-widgets [class*="instagram"] .widget-title:before { content: "\f128"; } + +/* format-gallery */ +#available-widgets [class*="album"] .widget-title:before, +#available-widgets [class*="galler"] .widget-title:before { content: "\f161"; } + +/* format-video */ +#available-widgets [class*="video"] .widget-title:before, +#available-widgets [class*="tube"] .widget-title:before { content: "\f126"; } + +/* format-audio */ +#available-widgets [class*="music"] .widget-title:before, +#available-widgets [class*="radio"] .widget-title:before, +#available-widgets [class*="audio"] .widget-title:before { content: "\f127"; } + +/* admin-users */ +#available-widgets [class*="login"] .widget-title:before, +#available-widgets [class*="user"] .widget-title:before, +#available-widgets [class*="member"] .widget-title:before, +#available-widgets [class*="avatar"] .widget-title:before, +#available-widgets [class*="subscriber"] .widget-title:before, +#available-widgets [class*="profile"] .widget-title:before, +#available-widgets [class*="grofile"] .widget-title:before { content: "\f110"; } + +/* cart */ +#available-widgets [class*="commerce"] .widget-title:before, +#available-widgets [class*="shop"] .widget-title:before, +#available-widgets [class*="cart"] .widget-title:before { content: "\f174"; top: -4px; } + +/* shield */ +#available-widgets [class*="secur"] .widget-title:before, +#available-widgets [class*="firewall"] .widget-title:before { content: "\f332"; } + +/* chart-bar */ +#available-widgets [class*="analytic"] .widget-title:before, +#available-widgets [class*="stat"] .widget-title:before, +#available-widgets [class*="poll"] .widget-title:before { content: "\f185"; } + +/* feedback */ +#available-widgets [class*="form"] .widget-title:before { content: "\f175"; } + +/* email-alt */ +#available-widgets [class*="subscribe"] .widget-title:before, +#available-widgets [class*="news"] .widget-title:before, +#available-widgets [class*="contact"] .widget-title:before, +#available-widgets [class*="mail"] .widget-title:before { content: "\f466"; } + +/* share */ +#available-widgets [class*="share"] .widget-title:before, +#available-widgets [class*="socia"] .widget-title:before { content: "\f237"; } + +/* translation */ +#available-widgets [class*="lang"] .widget-title:before, +#available-widgets [class*="translat"] .widget-title:before { content: "\f326"; } + +/* location-alt */ +#available-widgets [class*="locat"] .widget-title:before, +#available-widgets [class*="map"] .widget-title:before { content: "\f231"; } + +/* download */ +#available-widgets [class*="download"] .widget-title:before { content: "\f316"; } + +/* cloud */ +#available-widgets [class*="weather"] .widget-title:before { content: "\f176"; top: -4px;} + +/* facebook */ +#available-widgets [class*="facebook"] .widget-title:before { content: "\f304"; } + +/* twitter */ +#available-widgets [class*="tweet"] .widget-title:before, +#available-widgets [class*="twitter"] .widget-title:before { content: "\f301"; } + +@media screen and (max-height: 700px) and (min-width: 981px) { + /* Compact widget-tops on smaller laptops, but not tablets. See ticket #27112#comment:4 */ + .customize-control-widget_form { + margin-bottom: 0; + } + + .widget-top { + box-shadow: none; + margin-top: -1px; + } + + .widget-top:hover { + position: relative; + z-index: 1; + } + + .last-widget { + margin-bottom: 15px; + } + + .widget-title h3 { + padding: 13px 15px; + } + + .widget-top .widget-action { + padding: 8px 10px; + } + + .widget-reorder-nav span { + height: 39px; + } + + .widget-reorder-nav span:before { + line-height: 39px; + } + + /* Compact the move widget areas. */ + #customize-theme-controls .widget-area-select li { + padding: 9px 42px 11px 15px; + } + + #customize-theme-controls .widget-area-select li:before { + top: 8px; + } +} diff --git a/backend/wp-admin/css/customize-widgets-rtl.min.css b/backend/wp-admin/css/customize-widgets-rtl.min.css new file mode 100644 index 0000000..dd701c0 --- /dev/null +++ b/backend/wp-admin/css/customize-widgets-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.control-section.control-section-sidebar .accordion-section-content.ui-sortable,.wp-full-overlay-sidebar{overflow:visible}.control-section.control-section-sidebar,.customize-control-sidebar_widgets .hide-if-js,.customize-control-sidebar_widgets label{display:none}.customize-control-widget_form .widget-top{background:#fff;transition:opacity .5s}.customize-control .widget-action{color:#72777c}.customize-control .widget-action:focus,.customize-control .widget-top:hover .widget-action{color:#23282d}.customize-control-widget_form:not(.widget-rendered) .widget-top{opacity:.5}.customize-control-widget_form .widget-control-save{display:none}.customize-control-widget_form .spinner{visibility:hidden;margin-top:0}.customize-control-widget_form.previewer-loading .spinner{visibility:visible}.customize-control-widget_form.widget-form-disabled .widget-content{opacity:.7;pointer-events:none;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.customize-control-widget_form .widget{margin-bottom:0}.customize-control-widget_form.wide-widget-control .widget-inside{position:fixed;right:299px;top:25%;border:1px solid #e5e5e5;overflow:auto}.customize-control-widget_form.wide-widget-control .widget-inside>.form{padding:20px}.customize-control-widget_form.wide-widget-control .widget-top{transition:background-color .4s}.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top,.customize-control-widget_form.wide-widget-control.expanding .widget-top{background-color:#e3e3e3}.widget-inside{padding:1px 10px 10px;border-top:none;line-height:16px}.customize-control-widget_form.expanded .widget-action .toggle-indicator:before{content:"\f142"}.customize-control-widget_form.wide-widget-control .widget-action .toggle-indicator:before{content:"\f141"}.customize-control-widget_form.wide-widget-control.expanded .widget-action .toggle-indicator:before{content:"\f139"}.widget-title-action{cursor:pointer}.customize-control-widget_form .widget .customize-control-title,.widget-top{cursor:move}.control-section.accordion-section.highlighted>.accordion-section-title,.customize-control-widget_form.highlighted{outline:0;box-shadow:0 0 2px rgba(30,140,190,.8);position:relative;z-index:1}#widget-customizer-control-templates{display:none}#customize-theme-controls .widget-reorder-nav{display:none;float:left;background-color:#fafafa}.move-widget:before{content:"\f504"}#customize-theme-controls .move-widget-area{display:none;background:#fff;border:1px solid #ddd;border-top:none;cursor:auto}#customize-theme-controls .reordering .move-widget-area.active{display:block}#customize-theme-controls .move-widget-area .description{margin:0;padding:15px 20px;font-weight:400}#customize-theme-controls .widget-area-select{margin:0;padding:0;list-style:none}#customize-theme-controls .widget-area-select li{position:relative;margin:0;padding:13px 42px 15px 15px;color:#555;border-top:1px solid #eee;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#customize-theme-controls .widget-area-select li:before{display:none;content:"\f147";position:absolute;top:12px;right:10px;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#customize-theme-controls .widget-area-select li:last-child{border-bottom:1px solid #eee}#customize-theme-controls .widget-area-select .selected{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.4);background:#00a0d2}#customize-theme-controls .widget-area-select .selected:before{display:block}#customize-theme-controls .move-widget-actions{text-align:left;padding:12px}#customize-theme-controls .reordering .widget-title-action{display:none}#customize-theme-controls .reordering .widget-reorder-nav{display:block}.wp-customizer div.mce-inline-toolbar-grp,.wp-customizer div.mce-tooltip{z-index:500100!important}.wp-customizer .ui-autocomplete.wplink-autocomplete{z-index:500110}.wp-customizer #wp-link-backdrop{z-index:500100}.wp-customizer #wp-link-wrap{z-index:500105}#widgets-left #available-widgets .widget{float:none!important;width:auto!important}.ios #available-widgets{transition:right 0s}#available-widgets .widget-tpl.selected,#available-widgets .widget-tpl:hover{background:#f3f3f5;border-bottom-color:#ccc;color:#0073aa;border-right:4px solid #0073aa}#customize-controls .widget-title h3{font-size:1em}#available-widgets .widget-title h3{padding:0 0 5px;font-size:14px}#available-widgets .widget .widget-description{padding:0;color:#72777c}#customize-preview{transition:all .2s}body.adding-widget #available-widgets{right:0;visibility:visible}body.adding-widget .wp-full-overlay-main{right:300px}body.adding-widget #customize-preview{opacity:.4}#available-widgets .widget-title{position:relative}#available-widgets .widget-title:before{content:"\f132";position:absolute;top:-3px;left:100%;margin-left:20px;width:20px;height:20px;color:#32373c;font:400 20px/1 dashicons;text-align:center;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#available-widgets [class*=easy] .widget-title:before{content:"\f328";top:-4px}#available-widgets [class*=super] .widget-title:before,#available-widgets [class*=like] .widget-title:before{content:"\f155";top:-4px}#available-widgets [class*=meta] .widget-title:before{content:"\f120"}#available-widgets [class*=archives] .widget-title:before{content:"\f480";top:-4px}#available-widgets [class*=categor] .widget-title:before{content:"\f318";top:-4px}#available-widgets [class*=comment] .widget-title:before,#available-widgets [class*=testimonial] .widget-title:before,#available-widgets [class*=chat] .widget-title:before{content:"\f101"}#available-widgets [class*=post] .widget-title:before{content:"\f109"}#available-widgets [class*=page] .widget-title:before{content:"\f105"}#available-widgets [class*=text] .widget-title:before{content:"\f478"}#available-widgets [class*=link] .widget-title:before{content:"\f103"}#available-widgets [class*=search] .widget-title:before{content:"\f179"}#available-widgets [class*=menu] .widget-title:before,#available-widgets [class*=nav] .widget-title:before{content:"\f333"}#available-widgets [class*=tag] .widget-title:before{content:"\f479"}#available-widgets [class*=rss] .widget-title:before{content:"\f303";top:-6px}#available-widgets [class*=event] .widget-title:before,#available-widgets [class*=calendar] .widget-title:before{content:"\f145";top:-4px}#available-widgets [class*=image] .widget-title:before,#available-widgets [class*=photo] .widget-title:before,#available-widgets [class*=slide] .widget-title:before,#available-widgets [class*=instagram] .widget-title:before{content:"\f128"}#available-widgets [class*=album] .widget-title:before,#available-widgets [class*=galler] .widget-title:before{content:"\f161"}#available-widgets [class*=video] .widget-title:before,#available-widgets [class*=tube] .widget-title:before{content:"\f126"}#available-widgets [class*=music] .widget-title:before,#available-widgets [class*=radio] .widget-title:before,#available-widgets [class*=audio] .widget-title:before{content:"\f127"}#available-widgets [class*=login] .widget-title:before,#available-widgets [class*=user] .widget-title:before,#available-widgets [class*=member] .widget-title:before,#available-widgets [class*=avatar] .widget-title:before,#available-widgets [class*=subscriber] .widget-title:before,#available-widgets [class*=profile] .widget-title:before,#available-widgets [class*=grofile] .widget-title:before{content:"\f110"}#available-widgets [class*=commerce] .widget-title:before,#available-widgets [class*=shop] .widget-title:before,#available-widgets [class*=cart] .widget-title:before{content:"\f174";top:-4px}#available-widgets [class*=secur] .widget-title:before,#available-widgets [class*=firewall] .widget-title:before{content:"\f332"}#available-widgets [class*=analytic] .widget-title:before,#available-widgets [class*=stat] .widget-title:before,#available-widgets [class*=poll] .widget-title:before{content:"\f185"}#available-widgets [class*=form] .widget-title:before{content:"\f175"}#available-widgets [class*=subscribe] .widget-title:before,#available-widgets [class*=news] .widget-title:before,#available-widgets [class*=contact] .widget-title:before,#available-widgets [class*=mail] .widget-title:before{content:"\f466"}#available-widgets [class*=share] .widget-title:before,#available-widgets [class*=socia] .widget-title:before{content:"\f237"}#available-widgets [class*=lang] .widget-title:before,#available-widgets [class*=translat] .widget-title:before{content:"\f326"}#available-widgets [class*=locat] .widget-title:before,#available-widgets [class*=map] .widget-title:before{content:"\f231"}#available-widgets [class*=download] .widget-title:before{content:"\f316"}#available-widgets [class*=weather] .widget-title:before{content:"\f176";top:-4px}#available-widgets [class*=facebook] .widget-title:before{content:"\f304"}#available-widgets [class*=tweet] .widget-title:before,#available-widgets [class*=twitter] .widget-title:before{content:"\f301"}@media screen and (max-height:700px) and (min-width:981px){.customize-control-widget_form{margin-bottom:0}.widget-top{box-shadow:none;margin-top:-1px}.widget-top:hover{position:relative;z-index:1}.last-widget{margin-bottom:15px}.widget-title h3{padding:13px 15px}.widget-top .widget-action{padding:8px 10px}.widget-reorder-nav span{height:39px}.widget-reorder-nav span:before{line-height:39px}#customize-theme-controls .widget-area-select li{padding:9px 42px 11px 15px}#customize-theme-controls .widget-area-select li:before{top:8px}} \ No newline at end of file diff --git a/backend/wp-admin/css/customize-widgets.css b/backend/wp-admin/css/customize-widgets.css new file mode 100644 index 0000000..ab4f91b --- /dev/null +++ b/backend/wp-admin/css/customize-widgets.css @@ -0,0 +1,478 @@ +.wp-full-overlay-sidebar { + overflow: visible; +} + +/** + * Hide all sidebar sections by default, only show them (via JS) once the + * preview loads and we know whether the sidebars are used in the template. + */ + +.control-section.control-section-sidebar, +.customize-control-sidebar_widgets label, +.customize-control-sidebar_widgets .hide-if-js { + /* The link in .customize-control-sidebar_widgets .hide-if-js will fail if it ever gets used. */ + display: none; +} + +.control-section.control-section-sidebar .accordion-section-content.ui-sortable { + overflow: visible; +} + +/* Note: widget-tops are more compact when (max-height: 700px) and (min-width: 981px). */ +.customize-control-widget_form .widget-top { + background: #fff; + transition: opacity 0.5s; +} + +.customize-control .widget-action { + color: #72777c; +} + +.customize-control .widget-top:hover .widget-action, +.customize-control .widget-action:focus { + color: #23282d; +} + +.customize-control-widget_form:not(.widget-rendered) .widget-top { + opacity: 0.5; +} + +.customize-control-widget_form .widget-control-save { + display: none; +} + +.customize-control-widget_form .spinner { + visibility: hidden; + margin-top: 0; +} + +.customize-control-widget_form.previewer-loading .spinner { + visibility: visible; +} + +.customize-control-widget_form.widget-form-disabled .widget-content { + opacity: 0.7; + pointer-events: none; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.customize-control-widget_form .widget { + margin-bottom: 0; +} + +.customize-control-widget_form.wide-widget-control .widget-inside { + position: fixed; + left: 299px; + top: 25%; + border: 1px solid rgb(229, 229, 229); + overflow: auto; +} +.customize-control-widget_form.wide-widget-control .widget-inside > .form { + padding: 20px; +} + +.customize-control-widget_form.wide-widget-control .widget-top { + transition: background-color 0.4s; +} +.customize-control-widget_form.wide-widget-control.expanding .widget-top, +.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top { + background-color: rgb(227, 227, 227); +} + +.widget-inside { + padding: 1px 10px 10px 10px; + border-top: none; + line-height: 16px; +} + +.customize-control-widget_form.expanded .widget-action .toggle-indicator:before { + content: "\f142"; +} + +.customize-control-widget_form.wide-widget-control .widget-action .toggle-indicator:before { + content: "\f139"; +} + +.customize-control-widget_form.wide-widget-control.expanded .widget-action .toggle-indicator:before { + content: "\f141"; +} + +.widget-title-action { + cursor: pointer; +} + +.widget-top, +.customize-control-widget_form .widget .customize-control-title { + cursor: move; +} + +.control-section.accordion-section.highlighted > .accordion-section-title, +.customize-control-widget_form.highlighted { + outline: none; + box-shadow: 0 0 2px rgba(30,140,190,0.8); + position: relative; + z-index: 1; +} + +#widget-customizer-control-templates { + display: none; +} + +/** + * Widget reordering styles + */ + +#customize-theme-controls .widget-reorder-nav { + display: none; + float: right; + background-color: #fafafa; +} + +.move-widget:before { + content: "\f504"; +} + +#customize-theme-controls .move-widget-area { + display: none; + background: #fff; + border: 1px solid #ddd; + border-top: none; + cursor: auto; +} + +#customize-theme-controls .reordering .move-widget-area.active { + display: block; +} + +#customize-theme-controls .move-widget-area .description { + margin: 0; + padding: 15px 20px; + font-weight: 400; +} + +#customize-theme-controls .widget-area-select { + margin: 0; + padding: 0; + list-style: none; +} + +#customize-theme-controls .widget-area-select li { + position: relative; + margin: 0; + padding: 13px 15px 15px 42px; + color: #555; + border-top: 1px solid #eee; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +#customize-theme-controls .widget-area-select li:before { + display: none; + content: "\f147"; + position: absolute; + top: 12px; + left: 10px; + font: normal 20px/1 dashicons; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#customize-theme-controls .widget-area-select li:last-child { + border-bottom: 1px solid #eee; +} + +#customize-theme-controls .widget-area-select .selected { + color: #fff; + text-shadow: 0 -1px 0 rgba(0,0,0,.4); + background: #00a0d2; +} + +#customize-theme-controls .widget-area-select .selected:before { + display: block; +} + +#customize-theme-controls .move-widget-actions { + text-align: right; + padding: 12px; +} + +#customize-theme-controls .reordering .widget-title-action { + display: none; +} + +#customize-theme-controls .reordering .widget-reorder-nav { + display: block; +} + +/* Text Widget */ +.wp-customizer div.mce-inline-toolbar-grp, +.wp-customizer div.mce-tooltip { + z-index: 500100 !important; +} +.wp-customizer .ui-autocomplete.wplink-autocomplete { + z-index: 500110; /* originally 100110, but z-index of .wp-full-overlay is 500000 */ +} +.wp-customizer #wp-link-backdrop { + z-index: 500100; /* originally 100100, but z-index of .wp-full-overlay is 500000 */ +} +.wp-customizer #wp-link-wrap { + z-index: 500105; /* originally 100105, but z-index of .wp-full-overlay is 500000 */ +} + +/** + * Styles for new widget addition panel + */ + +/* override widgets admin page rules in wp-admin/css/widgets.css */ +#widgets-left #available-widgets .widget { + float: none !important; + width: auto !important; +} + +.ios #available-widgets { + transition: left 0s; +} + +#available-widgets .widget-tpl:hover, +#available-widgets .widget-tpl.selected { + background: #f3f3f5; + border-bottom-color: #ccc; + color: #0073aa; + border-left: 4px solid #0073aa; +} + +#customize-controls .widget-title h3 { + font-size: 1em; +} + +#available-widgets .widget-title h3 { + padding: 0 0 5px; + font-size: 14px; +} + +#available-widgets .widget .widget-description { + padding: 0; + color: #72777c; +} + +#customize-preview { + transition: all 0.2s; +} + +body.adding-widget #available-widgets { + left: 0; + visibility: visible; +} + +body.adding-widget .wp-full-overlay-main { + left: 300px; +} + +body.adding-widget #customize-preview { + opacity: 0.4; +} + + +/** + * Widget Icon styling + * No plurals in naming. + * Ordered from lowest to highest specificity. + */ + +#available-widgets .widget-title { + position: relative; +} + +#available-widgets .widget-title:before { + content: "\f132"; + position: absolute; + top: -3px; + right: 100%; + margin-right: 20px; + width: 20px; + height: 20px; + color: #32373c; + font: normal 20px/1 dashicons; + text-align: center; + box-sizing: border-box; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* smiley */ +#available-widgets [class*="easy"] .widget-title:before { content: "\f328"; top: -4px; } + +/* star-filled */ +#available-widgets [class*="super"] .widget-title:before, +#available-widgets [class*="like"] .widget-title:before { content: "\f155"; top: -4px; } + +/* wordpress */ +#available-widgets [class*="meta"] .widget-title:before { content: "\f120"; } + +/* archive-box */ +#available-widgets [class*="archives"] .widget-title:before { content: "\f480"; top: -4px; } + +/* category */ +#available-widgets [class*="categor"] .widget-title:before { content: "\f318"; top: -4px; } + +/* comments */ +#available-widgets [class*="comment"] .widget-title:before, +#available-widgets [class*="testimonial"] .widget-title:before, +#available-widgets [class*="chat"] .widget-title:before { content: "\f101"; } + +/* post */ +#available-widgets [class*="post"] .widget-title:before { content: "\f109"; } + +/* admin-page */ +#available-widgets [class*="page"] .widget-title:before { content: "\f105"; } + +/* text */ +#available-widgets [class*="text"] .widget-title:before { content: "\f478"; } + +/* links */ +#available-widgets [class*="link"] .widget-title:before { content: "\f103"; } + +/* search */ +#available-widgets [class*="search"] .widget-title:before { content: "\f179"; } + +/* menu */ +#available-widgets [class*="menu"] .widget-title:before, +#available-widgets [class*="nav"] .widget-title:before { content: "\f333"; } + +/* tag-cloud */ +#available-widgets [class*="tag"] .widget-title:before { content: "\f479"; } + +/* rss */ +#available-widgets [class*="rss"] .widget-title:before { content: "\f303"; top: -6px; } + +/* calendar */ +#available-widgets [class*="event"] .widget-title:before, +#available-widgets [class*="calendar"] .widget-title:before { content: "\f145"; top: -4px;} + +/* format-image */ +#available-widgets [class*="image"] .widget-title:before, +#available-widgets [class*="photo"] .widget-title:before, +#available-widgets [class*="slide"] .widget-title:before, +#available-widgets [class*="instagram"] .widget-title:before { content: "\f128"; } + +/* format-gallery */ +#available-widgets [class*="album"] .widget-title:before, +#available-widgets [class*="galler"] .widget-title:before { content: "\f161"; } + +/* format-video */ +#available-widgets [class*="video"] .widget-title:before, +#available-widgets [class*="tube"] .widget-title:before { content: "\f126"; } + +/* format-audio */ +#available-widgets [class*="music"] .widget-title:before, +#available-widgets [class*="radio"] .widget-title:before, +#available-widgets [class*="audio"] .widget-title:before { content: "\f127"; } + +/* admin-users */ +#available-widgets [class*="login"] .widget-title:before, +#available-widgets [class*="user"] .widget-title:before, +#available-widgets [class*="member"] .widget-title:before, +#available-widgets [class*="avatar"] .widget-title:before, +#available-widgets [class*="subscriber"] .widget-title:before, +#available-widgets [class*="profile"] .widget-title:before, +#available-widgets [class*="grofile"] .widget-title:before { content: "\f110"; } + +/* cart */ +#available-widgets [class*="commerce"] .widget-title:before, +#available-widgets [class*="shop"] .widget-title:before, +#available-widgets [class*="cart"] .widget-title:before { content: "\f174"; top: -4px; } + +/* shield */ +#available-widgets [class*="secur"] .widget-title:before, +#available-widgets [class*="firewall"] .widget-title:before { content: "\f332"; } + +/* chart-bar */ +#available-widgets [class*="analytic"] .widget-title:before, +#available-widgets [class*="stat"] .widget-title:before, +#available-widgets [class*="poll"] .widget-title:before { content: "\f185"; } + +/* feedback */ +#available-widgets [class*="form"] .widget-title:before { content: "\f175"; } + +/* email-alt */ +#available-widgets [class*="subscribe"] .widget-title:before, +#available-widgets [class*="news"] .widget-title:before, +#available-widgets [class*="contact"] .widget-title:before, +#available-widgets [class*="mail"] .widget-title:before { content: "\f466"; } + +/* share */ +#available-widgets [class*="share"] .widget-title:before, +#available-widgets [class*="socia"] .widget-title:before { content: "\f237"; } + +/* translation */ +#available-widgets [class*="lang"] .widget-title:before, +#available-widgets [class*="translat"] .widget-title:before { content: "\f326"; } + +/* location-alt */ +#available-widgets [class*="locat"] .widget-title:before, +#available-widgets [class*="map"] .widget-title:before { content: "\f231"; } + +/* download */ +#available-widgets [class*="download"] .widget-title:before { content: "\f316"; } + +/* cloud */ +#available-widgets [class*="weather"] .widget-title:before { content: "\f176"; top: -4px;} + +/* facebook */ +#available-widgets [class*="facebook"] .widget-title:before { content: "\f304"; } + +/* twitter */ +#available-widgets [class*="tweet"] .widget-title:before, +#available-widgets [class*="twitter"] .widget-title:before { content: "\f301"; } + +@media screen and (max-height: 700px) and (min-width: 981px) { + /* Compact widget-tops on smaller laptops, but not tablets. See ticket #27112#comment:4 */ + .customize-control-widget_form { + margin-bottom: 0; + } + + .widget-top { + box-shadow: none; + margin-top: -1px; + } + + .widget-top:hover { + position: relative; + z-index: 1; + } + + .last-widget { + margin-bottom: 15px; + } + + .widget-title h3 { + padding: 13px 15px; + } + + .widget-top .widget-action { + padding: 8px 10px; + } + + .widget-reorder-nav span { + height: 39px; + } + + .widget-reorder-nav span:before { + line-height: 39px; + } + + /* Compact the move widget areas. */ + #customize-theme-controls .widget-area-select li { + padding: 9px 15px 11px 42px; + } + + #customize-theme-controls .widget-area-select li:before { + top: 8px; + } +} diff --git a/backend/wp-admin/css/customize-widgets.min.css b/backend/wp-admin/css/customize-widgets.min.css new file mode 100644 index 0000000..f170f39 --- /dev/null +++ b/backend/wp-admin/css/customize-widgets.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.control-section.control-section-sidebar .accordion-section-content.ui-sortable,.wp-full-overlay-sidebar{overflow:visible}.control-section.control-section-sidebar,.customize-control-sidebar_widgets .hide-if-js,.customize-control-sidebar_widgets label{display:none}.customize-control-widget_form .widget-top{background:#fff;transition:opacity .5s}.customize-control .widget-action{color:#72777c}.customize-control .widget-action:focus,.customize-control .widget-top:hover .widget-action{color:#23282d}.customize-control-widget_form:not(.widget-rendered) .widget-top{opacity:.5}.customize-control-widget_form .widget-control-save{display:none}.customize-control-widget_form .spinner{visibility:hidden;margin-top:0}.customize-control-widget_form.previewer-loading .spinner{visibility:visible}.customize-control-widget_form.widget-form-disabled .widget-content{opacity:.7;pointer-events:none;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.customize-control-widget_form .widget{margin-bottom:0}.customize-control-widget_form.wide-widget-control .widget-inside{position:fixed;left:299px;top:25%;border:1px solid #e5e5e5;overflow:auto}.customize-control-widget_form.wide-widget-control .widget-inside>.form{padding:20px}.customize-control-widget_form.wide-widget-control .widget-top{transition:background-color .4s}.customize-control-widget_form.wide-widget-control.expanded:not(.collapsing) .widget-top,.customize-control-widget_form.wide-widget-control.expanding .widget-top{background-color:#e3e3e3}.widget-inside{padding:1px 10px 10px;border-top:none;line-height:16px}.customize-control-widget_form.expanded .widget-action .toggle-indicator:before{content:"\f142"}.customize-control-widget_form.wide-widget-control .widget-action .toggle-indicator:before{content:"\f139"}.customize-control-widget_form.wide-widget-control.expanded .widget-action .toggle-indicator:before{content:"\f141"}.widget-title-action{cursor:pointer}.customize-control-widget_form .widget .customize-control-title,.widget-top{cursor:move}.control-section.accordion-section.highlighted>.accordion-section-title,.customize-control-widget_form.highlighted{outline:0;box-shadow:0 0 2px rgba(30,140,190,.8);position:relative;z-index:1}#widget-customizer-control-templates{display:none}#customize-theme-controls .widget-reorder-nav{display:none;float:right;background-color:#fafafa}.move-widget:before{content:"\f504"}#customize-theme-controls .move-widget-area{display:none;background:#fff;border:1px solid #ddd;border-top:none;cursor:auto}#customize-theme-controls .reordering .move-widget-area.active{display:block}#customize-theme-controls .move-widget-area .description{margin:0;padding:15px 20px;font-weight:400}#customize-theme-controls .widget-area-select{margin:0;padding:0;list-style:none}#customize-theme-controls .widget-area-select li{position:relative;margin:0;padding:13px 15px 15px 42px;color:#555;border-top:1px solid #eee;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#customize-theme-controls .widget-area-select li:before{display:none;content:"\f147";position:absolute;top:12px;left:10px;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#customize-theme-controls .widget-area-select li:last-child{border-bottom:1px solid #eee}#customize-theme-controls .widget-area-select .selected{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.4);background:#00a0d2}#customize-theme-controls .widget-area-select .selected:before{display:block}#customize-theme-controls .move-widget-actions{text-align:right;padding:12px}#customize-theme-controls .reordering .widget-title-action{display:none}#customize-theme-controls .reordering .widget-reorder-nav{display:block}.wp-customizer div.mce-inline-toolbar-grp,.wp-customizer div.mce-tooltip{z-index:500100!important}.wp-customizer .ui-autocomplete.wplink-autocomplete{z-index:500110}.wp-customizer #wp-link-backdrop{z-index:500100}.wp-customizer #wp-link-wrap{z-index:500105}#widgets-left #available-widgets .widget{float:none!important;width:auto!important}.ios #available-widgets{transition:left 0s}#available-widgets .widget-tpl.selected,#available-widgets .widget-tpl:hover{background:#f3f3f5;border-bottom-color:#ccc;color:#0073aa;border-left:4px solid #0073aa}#customize-controls .widget-title h3{font-size:1em}#available-widgets .widget-title h3{padding:0 0 5px;font-size:14px}#available-widgets .widget .widget-description{padding:0;color:#72777c}#customize-preview{transition:all .2s}body.adding-widget #available-widgets{left:0;visibility:visible}body.adding-widget .wp-full-overlay-main{left:300px}body.adding-widget #customize-preview{opacity:.4}#available-widgets .widget-title{position:relative}#available-widgets .widget-title:before{content:"\f132";position:absolute;top:-3px;right:100%;margin-right:20px;width:20px;height:20px;color:#32373c;font:400 20px/1 dashicons;text-align:center;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#available-widgets [class*=easy] .widget-title:before{content:"\f328";top:-4px}#available-widgets [class*=super] .widget-title:before,#available-widgets [class*=like] .widget-title:before{content:"\f155";top:-4px}#available-widgets [class*=meta] .widget-title:before{content:"\f120"}#available-widgets [class*=archives] .widget-title:before{content:"\f480";top:-4px}#available-widgets [class*=categor] .widget-title:before{content:"\f318";top:-4px}#available-widgets [class*=comment] .widget-title:before,#available-widgets [class*=testimonial] .widget-title:before,#available-widgets [class*=chat] .widget-title:before{content:"\f101"}#available-widgets [class*=post] .widget-title:before{content:"\f109"}#available-widgets [class*=page] .widget-title:before{content:"\f105"}#available-widgets [class*=text] .widget-title:before{content:"\f478"}#available-widgets [class*=link] .widget-title:before{content:"\f103"}#available-widgets [class*=search] .widget-title:before{content:"\f179"}#available-widgets [class*=menu] .widget-title:before,#available-widgets [class*=nav] .widget-title:before{content:"\f333"}#available-widgets [class*=tag] .widget-title:before{content:"\f479"}#available-widgets [class*=rss] .widget-title:before{content:"\f303";top:-6px}#available-widgets [class*=event] .widget-title:before,#available-widgets [class*=calendar] .widget-title:before{content:"\f145";top:-4px}#available-widgets [class*=image] .widget-title:before,#available-widgets [class*=photo] .widget-title:before,#available-widgets [class*=slide] .widget-title:before,#available-widgets [class*=instagram] .widget-title:before{content:"\f128"}#available-widgets [class*=album] .widget-title:before,#available-widgets [class*=galler] .widget-title:before{content:"\f161"}#available-widgets [class*=video] .widget-title:before,#available-widgets [class*=tube] .widget-title:before{content:"\f126"}#available-widgets [class*=music] .widget-title:before,#available-widgets [class*=radio] .widget-title:before,#available-widgets [class*=audio] .widget-title:before{content:"\f127"}#available-widgets [class*=login] .widget-title:before,#available-widgets [class*=user] .widget-title:before,#available-widgets [class*=member] .widget-title:before,#available-widgets [class*=avatar] .widget-title:before,#available-widgets [class*=subscriber] .widget-title:before,#available-widgets [class*=profile] .widget-title:before,#available-widgets [class*=grofile] .widget-title:before{content:"\f110"}#available-widgets [class*=commerce] .widget-title:before,#available-widgets [class*=shop] .widget-title:before,#available-widgets [class*=cart] .widget-title:before{content:"\f174";top:-4px}#available-widgets [class*=secur] .widget-title:before,#available-widgets [class*=firewall] .widget-title:before{content:"\f332"}#available-widgets [class*=analytic] .widget-title:before,#available-widgets [class*=stat] .widget-title:before,#available-widgets [class*=poll] .widget-title:before{content:"\f185"}#available-widgets [class*=form] .widget-title:before{content:"\f175"}#available-widgets [class*=subscribe] .widget-title:before,#available-widgets [class*=news] .widget-title:before,#available-widgets [class*=contact] .widget-title:before,#available-widgets [class*=mail] .widget-title:before{content:"\f466"}#available-widgets [class*=share] .widget-title:before,#available-widgets [class*=socia] .widget-title:before{content:"\f237"}#available-widgets [class*=lang] .widget-title:before,#available-widgets [class*=translat] .widget-title:before{content:"\f326"}#available-widgets [class*=locat] .widget-title:before,#available-widgets [class*=map] .widget-title:before{content:"\f231"}#available-widgets [class*=download] .widget-title:before{content:"\f316"}#available-widgets [class*=weather] .widget-title:before{content:"\f176";top:-4px}#available-widgets [class*=facebook] .widget-title:before{content:"\f304"}#available-widgets [class*=tweet] .widget-title:before,#available-widgets [class*=twitter] .widget-title:before{content:"\f301"}@media screen and (max-height:700px) and (min-width:981px){.customize-control-widget_form{margin-bottom:0}.widget-top{box-shadow:none;margin-top:-1px}.widget-top:hover{position:relative;z-index:1}.last-widget{margin-bottom:15px}.widget-title h3{padding:13px 15px}.widget-top .widget-action{padding:8px 10px}.widget-reorder-nav span{height:39px}.widget-reorder-nav span:before{line-height:39px}#customize-theme-controls .widget-area-select li{padding:9px 15px 11px 42px}#customize-theme-controls .widget-area-select li:before{top:8px}} \ No newline at end of file diff --git a/backend/wp-admin/css/dashboard-rtl.css b/backend/wp-admin/css/dashboard-rtl.css new file mode 100644 index 0000000..373d2be --- /dev/null +++ b/backend/wp-admin/css/dashboard-rtl.css @@ -0,0 +1,1313 @@ +#wpbody-content #dashboard-widgets.columns-1 .postbox-container { + width: 100%; +} + +#wpbody-content #dashboard-widgets.columns-2 .postbox-container { + width: 49.5%; +} + +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-2, +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-3, +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-4 { + float: left; + width: 50.5%; +} + +#wpbody-content #dashboard-widgets.columns-3 .postbox-container { + width: 33.5%; +} + +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-1 { + width: 33%; +} + +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-3, +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-4 { + float: left; +} + +#wpbody-content #dashboard-widgets.columns-4 .postbox-container { + width: 25%; +} + +#dashboard-widgets .postbox-container { + width: 25%; +} + +#dashboard-widgets-wrap .columns-3 #postbox-container-4 .empty-container { + border: none !important; +} + +.ie8 #wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; +} + +.ie8 #wpbody-content #dashboard-widgets #postbox-container-2, +.ie8 #wpbody-content #dashboard-widgets #postbox-container-3, +.ie8 #wpbody-content #dashboard-widgets #postbox-container-4 { + float: left; + width: 50.5%; +} + +.ie8 #dashboard-widgets #postbox-container-3 .empty-container, +.ie8 #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +#dashboard-widgets-wrap { + overflow: hidden; + margin: 0 -8px; +} + +#dashboard-widgets .postbox .inside { + margin-bottom: 0; +} + +#dashboard-widgets .meta-box-sortables { + margin: 0 8px; + min-height: 100px; +} + +/* @todo: this was originally in this section, but likely belongs elsewhere */ +#the-comment-list td.comment p.comment-author { + margin-top: 0; + margin-right: 0; +} + +#the-comment-list p.comment-author img { + float: right; + margin-left: 8px; +} + +#the-comment-list p.comment-author strong a { + border: none; +} + +#the-comment-list td { + vertical-align: top; +} + +#the-comment-list td.comment { + word-wrap: break-word; +} + +#the-comment-list td.comment img { + max-width: 100%; +} + +/* Welcome Panel */ +.welcome-panel { + position: relative; + overflow: auto; + margin: 16px 0; + padding: 23px 10px 0; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; + font-size: 13px; + line-height: 2.1em; +} + +.welcome-panel h2 { + margin: 0; + font-size: 21px; + font-weight: 400; + line-height: 1.2; +} + +.welcome-panel h3 { + margin: 1.33em 0 0; + font-size: 16px; +} + +.welcome-panel li { + font-size: 14px; +} + +.welcome-panel p { + color: #72777c; +} + +.welcome-panel a { + text-decoration: none; +} + +.welcome-panel .about-description { + font-size: 16px; + margin: 0; +} + +.welcome-panel .welcome-panel-close { + position: absolute; + top: 10px; + left: 10px; + padding: 10px 21px 10px 15px; + font-size: 13px; + line-height: 1.23076923; /* Chrome rounding, needs to be 16px equivalent */ + text-decoration: none; +} + +.welcome-panel .welcome-panel-close:before { + position: absolute; + top: 8px; + right: 0; + transition: all .1s ease-in-out; +} + +.wp-core-ui .welcome-panel .button.button-hero { + margin: 15px 0 3px 13px; + padding: 12px 36px; + height: auto; + line-height: 1.4285714; + white-space: normal; +} + +.welcome-panel-content { + margin-right: 13px; + max-width: 1500px; +} + +.welcome-panel .welcome-panel-column-container { + clear: both; + position: relative; +} + +.welcome-panel .welcome-panel-column { + width: 32%; + min-width: 200px; + float: right; +} + +.ie8 .welcome-panel .welcome-panel-column { + min-width: 230px; +} + +.welcome-panel .welcome-panel-column:first-child { + width: 36%; +} + +.welcome-panel-column p.hide-if-no-customize { + margin-top: 10px; +} + +.welcome-panel-column p { + margin-top: 7px; + color: #444; +} + +.welcome-panel .welcome-widgets-menus { + line-height: 16px; +} + +.welcome-panel .welcome-panel-column ul { + margin: 0.8em 0 1em 1em; +} + +.welcome-panel .welcome-panel-column li { + line-height: 16px; + list-style-type: none; + padding: 0 0 8px; +} + +.welcome-panel .welcome-icon { + background: transparent !important; +} + +/* Welcome Panel and Right Now common Icons style */ + +.welcome-panel .welcome-icon:before, +#dashboard_right_now li a:before, +#dashboard_right_now li span:before { + color: #82878c; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0 0 0 10px; + position: relative; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + vertical-align: top; +} + +/* Welcome Panel specific Icons styles */ + +.welcome-panel .welcome-write-blog:before, +.welcome-panel .welcome-edit-page:before { + content: "\f119"; + top: -3px; +} + +.welcome-panel .welcome-add-page:before { + content: "\f132"; + top: -1px; +} + +.welcome-panel .welcome-view-site:before { + content: "\f115"; + top: -2px; +} + +.welcome-panel .welcome-widgets-menus:before { + content: "\f116"; + top: -2px; +} + +.welcome-panel .welcome-comments:before { + content: "\f117"; + top: -1px; +} + +.welcome-panel .welcome-learn-more:before { + content: "\f118"; + top: -1px; +} + +/* Right Now specific Icons styles */ + +#dashboard_right_now li a:before, +#dashboard_right_now li > span:before { /* get only the first level span to exclude screen-reader-text in mu-storage */ + content: "\f159"; /* generic icon for items added by CPTs ? */ + padding: 0 0 0 5px; +} + +#dashboard_right_now .page-count a:before, +#dashboard_right_now .page-count span:before { + content: "\f105"; +} + +#dashboard_right_now .post-count a:before, +#dashboard_right_now .post-count span:before { + content: "\f109"; +} + +#dashboard_right_now .comment-count a:before { + content: "\f101"; +} + +#dashboard_right_now .comment-mod-count a:before { + content: "\f125"; +} + +#dashboard_right_now .storage-count a:before { + content: "\f104"; +} + +#dashboard_right_now .storage-count.warning a:before { + content: "\f153"; +} + +/* Dashboard WordPress events */ + +.community-events-errors { + margin: 0; +} + +.community-events-loading { + padding: 10px 12px 8px; +} + +.community-events { + margin-bottom: 6px; + padding: 0 12px; +} + +.community-events .spinner { + float: none; + margin: 5px 2px 0; + vertical-align: top; +} + +.community-events-errors[aria-hidden="true"], +.community-events-errors [aria-hidden="true"], +.community-events-loading[aria-hidden="true"], +.community-events[aria-hidden="true"], +.community-events [aria-hidden="true"] { + display: none; +} + +.community-events .activity-block:first-child, +.community-events h2 { + padding-top: 12px; + padding-bottom: 10px; +} + +.community-events-form { + margin: 15px 0 5px; +} + +.community-events-form .regular-text { + width: 40%; + height: 29px; + margin: 0; + vertical-align: top; +} + +.community-events li.event-none { + border-right: 4px solid #00a0d2; +} + +.community-events-form label { + display: inline-block; + vertical-align: top; + line-height: 28px; + height: 28px; +} + +.community-events .activity-block > p { + margin-bottom: 0; + display: inline; +} + +.community-events-toggle-location { + vertical-align: middle; +} + +#community-events-submit { + margin-right: 3px; + margin-left: 3px; +} + +/* Needs higher specificity than #dashboard-widgets .button-link */ +#dashboard-widgets .community-events-cancel.button-link { + vertical-align: top; + /* Same properties as the submit button for cross-browsers alignment. */ + line-height: 26px; + height: 28px; + text-decoration: underline; +} + +.community-events ul { + background-color: #fafafa; + padding-right: 0; + padding-left: 0; + padding-bottom: 0; +} + +.community-events li { + margin: 0; + padding: 8px 12px; + color: #72777c; +} +.community-events li:first-child { + border-top: 1px solid #eee; +} + +.community-events li ~ li { + border-top: 1px solid #eee; +} + +.community-events .activity-block.last { + border-bottom: 1px solid #eee; + padding-top: 0; + margin-top: -1px; +} + +.community-events .event-info { + display: block; +} + +.event-icon { + height: 18px; + padding-left: 10px; + width: 18px; + display: none; /* Hide on smaller screens */ +} + +.event-icon:before { + color: #82878C; + font-size: 18px; +} +.event-meetup .event-icon:before { + content: "\f484"; +} +.event-wordcamp .event-icon:before { + content: "\f486"; +} + +.community-events .event-title { + font-weight: 600; + display: block; +} + +.community-events .event-date, +.community-events .event-time { + display: block; +} + +.community-events-footer { + margin-top: 0; + margin-bottom: 0; + padding: 12px; + border-top: 1px solid #eee; + color: #ddd; +} + +/* Safari 10 + VoiceOver specific: without this, the hidden text gets read out before the link. */ +.community-events-footer .screen-reader-text { + height: inherit; + white-space: nowrap; +} + +/* Dashboard WordPress news */ + +#dashboard_primary .inside { + margin: 0; + padding: 0; +} + +#dashboard_primary .widget-loading { + padding: 12px 12px 0; + margin-bottom: 1em !important; /* Needs to override `.postbox .inside > p:last-child` in common.css */ +} + +/* Notice when JS is off. */ +#dashboard_primary .inside .notice { + margin: 0; +} + +body #dashboard-widgets .postbox form .submit { + margin: 0; +} + +/* Used only for configurable widgets. */ +.dashboard-widget-control-form p { + margin-top: 0; +} + +.rssSummary { + color: #72777c; + margin-top: 4px; +} + +#dashboard_primary .rss-widget { + font-size: 13px; + padding: 0 12px 0; +} + +#dashboard_primary .rss-widget:last-child { + border-bottom: none; + padding-bottom: 8px; +} + +#dashboard_primary .rss-widget a { + font-weight: 400; +} + +#dashboard_primary .rss-widget span, +#dashboard_primary .rss-widget span.rss-date { + color: #72777c; +} + +#dashboard_primary .rss-widget span.rss-date { + margin-right: 12px; +} + +#dashboard_primary .rss-widget ul li { + padding: 4px 0; + margin: 0; +} + +/* Dashboard right now */ + +#dashboard_right_now ul { + margin: 0; + /* contain floats but don't use overflow: hidden */ + display: inline-block; + width: 100%; +} + +#dashboard_right_now li { + width: 50%; + float: right; + margin-bottom: 10px; +} + +#dashboard_right_now .inside { + padding: 0; +} + +#dashboard_right_now .main { + padding: 0 12px 11px; +} + +#dashboard_right_now .main p { + margin: 0; +} + +#dashboard_right_now #wp-version-message .button { + float: left; + position: relative; + top: -5px; + margin-right: 5px; +} + +.mu-storage { + overflow: hidden; +} + +#dashboard-widgets h3.mu-storage { + margin: 0 0 10px; + padding: 0; + font-size: 14px; + font-weight: 400; +} + +/* Dashboard right now - Colors */ + +#dashboard_right_now .sub { + color: #555d66; + background: #f5f5f5; + border-top: 1px solid #eee; + padding: 10px 12px 6px 12px; +} + +#dashboard_right_now .sub h3 { + color: #555; +} + +#dashboard_right_now .sub p { + margin: 0 0 1em; +} + +#dashboard_right_now .warning a:before, +#dashboard_right_now .warning span:before { + color: #d54e21; +} + +/* Dashboard Quick Draft */ + +#dashboard_quick_press .inside { + margin: 0; + padding: 0; +} + +#dashboard_quick_press div.updated { + margin-bottom: 10px; + border: 1px solid #eee; + border-width: 1px 0 1px 1px; +} + +#dashboard_quick_press form { + margin: 12px; +} + +#dashboard_quick_press .drafts, +#dashboard_quick_press .easy-blogging { + padding: 10px 0 0; +} + +/* Dashboard Quick Draft - Form styling */ + +input#save-post { + float: right; +} + +form.initial-form.quickpress-open label.prompt { + font-style: normal; +} + +form.initial-form.quickpress-open input#title { + height: auto; +} + +#dashboard_quick_press input, +#dashboard_quick_press textarea { + box-sizing: border-box; + margin: 0; +} + +#dashboard_quick_press textarea { + resize: vertical; +} + +#dashboard-widgets .postbox form .submit { + margin: -39px 0; + float: left; +} + +#description-wrap { + margin-top: 12px; +} + +#title-wrap #title-prompt-text, +.textarea-wrap #content-prompt-text { + color: #72777c; +} + +#title-wrap #title-prompt-text { + font-size: 1.1em; + padding: 7px 8px; +} + +.input-text-wrap, +.textarea-wrap { + position: relative; +} + +.input-text-wrap .prompt, +.textarea-wrap .prompt { + position: absolute; +} + +.textarea-wrap #content-prompt-text { + font-size: 1.1em; + padding: 7px 8px; +} + +.textarea-wrap textarea#content { + margin: 0 0 8px; + padding: 6px 7px; +} + +#quick-press textarea#content { + min-height: 90px; + max-height: 1300px; + resize: none; +} + +/* Dashboard Quick Draft - Drafts list */ + +.js #dashboard_quick_press .drafts { + border-top: 1px solid #eee; +} + +#dashboard_quick_press .drafts abbr { + border: none; +} + +#dashboard_quick_press .drafts .view-all { + float: left; + margin: 0 0 0 12px; +} + +#dashboard_primary a.rsswidget { + font-weight: 400; +} + +#dashboard_quick_press .drafts ul { + margin: 0 12px; +} + +#dashboard_quick_press .drafts li { + margin-bottom: 1em; +} +#dashboard_quick_press .drafts li time { + color: #72777c; +} + +#dashboard_quick_press .drafts p { + margin: 0; + word-wrap: break-word; +} + +#dashboard_quick_press .draft-title { + word-wrap: break-word; +} + +#dashboard_quick_press .draft-title a, +#dashboard_quick_press .draft-title time { + margin: 0 0 0 5px; +} + +/* Dashboard common styles */ + +#dashboard-widgets h4, /* Back-compat for pre-4.4 */ +#dashboard-widgets h3, +#dashboard_quick_press .drafts h2 { + margin: 0 12px 8px; + padding: 0; + font-size: 14px; + font-weight: 400; + color: #23282d; +} + +#dashboard_quick_press .drafts h2 { + line-height: inherit; +} + +#dashboard-widgets .inside h4, /* Back-compat for pre-4.4 */ +#dashboard-widgets .inside h3 { + margin-right: 0; + margin-left: 0; +} + +/* Dashboard activity widget */ + +#dashboard_activity .comment-meta span.approve:before { + content: "\f227"; + font: 20px/.5 dashicons; + margin-right: 5px; + vertical-align: middle; + position: relative; + top: -1px; + margin-left: 2px; +} + +#dashboard_activity .inside { + margin: 0; + padding-bottom: 0; +} + +#dashboard_activity .no-activity { + overflow: hidden; + padding: 0 0 12px; + text-align: center; +} + +#dashboard_activity .no-activity p { + color: #72777c; + font-size: 16px; +} + +#dashboard_activity .no-activity .smiley { + margin-top: 0; +} + +#dashboard_activity .no-activity .smiley:before { + content: "\f328"; + font: normal 120px/1 dashicons; + speak: none; + display: block; + margin: 0 0 0 5px; + padding: 0; + text-indent: 0; + text-align: center; + position: relative; + -webkit-font-smoothing: antialiased; + text-decoration: none !important; +} + +#dashboard_activity .subsubsub { + float: none; + border-top: 1px solid #eee; + margin: 0 -12px; + padding: 8px 12px 4px; +} + +#dashboard_activity .subsubsub a .count, +#dashboard_activity .subsubsub a.current .count { + color: #72777c; /* white background on the dashboard but #f1f1f1 on list tables */ +} + +#future-posts ul, +#published-posts ul { + clear: both; + margin-bottom: 0; +} + +#future-posts li, +#published-posts li { + margin-bottom: 8px; +} + +#future-posts ul span, +#published-posts ul span { + display: inline-block; + margin-left: 5px; + min-width: 150px; + color: #72777c; +} + +.activity-block { + border-bottom: 1px solid #eee; + margin: 0 -12px; + padding: 8px 12px 4px; +} + +.activity-block:last-child { + border-bottom: none; +} + +.activity-block .subsubsub li { + color: #ddd; +} + +/* Dashboard activity widget - Comments */ +/* @todo: needs serious de-duplication */ + +#activity-widget #the-comment-list tr.undo, +#activity-widget #the-comment-list div.undo { + background: none; + padding: 6px 0; + margin-right: 12px; +} + +#activity-widget #the-comment-list .comment-item { + background: #fafafa; + padding: 12px; + position: relative; +} + +#activity-widget #the-comment-list .avatar { + position: absolute; + top: 12px; +} + +#activity-widget #the-comment-list .dashboard-comment-wrap { + padding-right: 63px; +} + +#activity-widget #the-comment-list .dashboard-comment-wrap blockquote { + margin: 1em 0; +} + +#activity-widget #the-comment-list .comment-item p.row-actions { + margin: 4px 0 0 0; +} + +#activity-widget #the-comment-list .comment-item:first-child { + border-top: 1px solid #eeeeee; +} + +#activity-widget #the-comment-list .unapproved { + background-color: #fef7f1; +} + +#activity-widget #the-comment-list .unapproved:before { + content: ""; + display: block; + position: absolute; + right: 0; + top: 0; + bottom: 0; + background: #d54e21; + width: 4px; +} + +#activity-widget #the-comment-list .spam-undo-inside .avatar, +#activity-widget #the-comment-list .trash-undo-inside .avatar { + position: relative; + top: 0; +} + +/* Browse happy box */ + +#dashboard-widgets #dashboard_browser_nag.postbox .inside { + margin: 10px; +} + +.postbox .button-link .edit-box { + display: none; +} + +.edit-box { + opacity: 0; +} + +.hndle:hover .edit-box, +.edit-box:focus { + opacity: 1; +} + +#dashboard-widgets form .input-text-wrap input { + width: 100%; +} + +#dashboard-widgets form .textarea-wrap textarea { + width: 100%; +} + +#dashboard-widgets .postbox form .submit { + float: none; + margin: .5em 0 0; + padding: 0; + border: none; +} + +#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish { + min-width: 0; +} + +#dashboard-widgets a, +#dashboard-widgets .button-link { + text-decoration: none; +} + +#dashboard-widgets h2 a { + text-decoration: underline; +} + +#dashboard-widgets .hndle .postbox-title-action { + float: left; + line-height: 1.2; +} + +#dashboard_plugins h5 { + font-size: 14px; +} + +/* Recent Comments */ + +#latest-comments #the-comment-list { + position: relative; + margin: 0 -12px; +} + +#activity-widget #the-comment-list .comment, +#activity-widget #the-comment-list .pingback { + box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.06); +} + +#activity-widget .comments #the-comment-list .alt { + background-color: transparent; +} + +#activity-widget #latest-comments #the-comment-list .comment-item { + /* the row-actions paragraph is output only for users with 'edit_comment' capabilities, + for other users this needs a min height equal to the gravatar image */ + min-height: 50px; + margin: 0; + padding: 12px; +} + +#latest-comments #the-comment-list .pingback { + padding-right: 12px !important; +} + +#latest-comments #the-comment-list .comment-item:first-child { + border-top: none; +} + +#latest-comments #the-comment-list .comment-meta { + line-height: 1.5em; + margin: 0; + color: #666; +} + +#latest-comments #the-comment-list .comment-meta cite { + font-style: normal; + font-weight: 400; +} + +#latest-comments #the-comment-list .comment-item blockquote, +#latest-comments #the-comment-list .comment-item blockquote p { + margin: 0; + padding: 0; + display: inline; +} + +#latest-comments #the-comment-list .comment-item p.row-actions { + margin: 3px 0 0; + padding: 0; + font-size: 13px; +} + +/* QuickDraft */ + +#title-wrap label, +#description-wrap label { + cursor: text; +} + +#title-wrap #title { + padding: 2px 6px; + font-size: 1.3em; + outline: none; +} + +#title-wrap #title-prompt-text { + font-size: 1.1em; + padding: 5px 8px; +} + +/* Feeds */ +.rss-widget ul { + margin: 0; + padding: 0; + list-style: none; +} + +a.rsswidget { + font-size: 13px; + font-weight: 600; + line-height: 1.4em; +} + +.rss-widget ul li { + line-height: 1.5em; + margin-bottom: 12px; +} + +.rss-widget span.rss-date { + color: #72777c; + font-size: 13px; + margin-right: 3px; +} + +.rss-widget cite { + display: block; + text-align: left; + margin: 0 0 1em; + padding: 0; +} + +.rss-widget cite:before { + content: "\2014"; +} + +.dashboard-comment-wrap { + word-wrap: break-word; +} + +/* Browser Nag */ +#dashboard_browser_nag a.update-browser-link { + font-size: 1.2em; + font-weight: 600; +} + +#dashboard_browser_nag a { + text-decoration: underline; +} + +#dashboard_browser_nag p.browser-update-nag.has-browser-icon { + padding-left: 125px; +} + +#dashboard_browser_nag .browser-icon { + margin-top: -35px; +} + +#dashboard_browser_nag.postbox.browser-insecure { + background-color: #ac1b1b; + border-color: #ac1b1b; +} + +#dashboard_browser_nag.postbox { + background-color: #e29808; + background-image: none; + border-color: #edc048; + color: #fff; + box-shadow: none; +} + +#dashboard_browser_nag.postbox.browser-insecure h2 { + border-bottom-color: #cd5a5a; + color: #fff; +} + +#dashboard_browser_nag.postbox h2 { + border-bottom-color: #f6e2ac; + background: transparent none; + color: #fff; + box-shadow: none; +} + +#dashboard_browser_nag a { + color: #fff; +} + +#dashboard_browser_nag h2.hndle { + border: none; + font-weight: 600; + font-size: 20px; + padding-top: 10px; +} + +.postbox#dashboard_browser_nag p a.dismiss { + font-size: 14px; +} + +.postbox#dashboard_browser_nag p, +.postbox#dashboard_browser_nag a, +.postbox#dashboard_browser_nag p.browser-update-nag { + font-size: 16px; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/* one column on the dash */ +@media only screen and (max-width: 799px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 100%; + } +} + +/* two columns on the dash, but keep the setting if one is selected */ +@media only screen and (min-width: 800px) and (max-width: 1499px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; + } + + #wpbody-content #dashboard-widgets #postbox-container-2, + #wpbody-content #dashboard-widgets #postbox-container-3, + #wpbody-content #dashboard-widgets #postbox-container-4 { + float: left; + width: 50.5%; + } + + #dashboard-widgets #postbox-container-3 .empty-container, + #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + #dashboard-widgets #postbox-container-3 .empty-container:after, + #dashboard-widgets #postbox-container-4 .empty-container:after { + display: none; + } + + #wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container { + width: 100%; + } + + #wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + /* show the radio buttons for column prefs only for one or two columns */ + .index-php .screen-layout, + .index-php .columns-prefs { + display: block; + } + + .columns-prefs .columns-prefs-3, + .columns-prefs .columns-prefs-4 { + display: none; + } + + .metabox-holder .postbox-container .empty-container:after { + display: block; + } +} + +/* three columns on the dash */ +@media only screen and (min-width: 1500px) and (max-width: 1800px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 33.5%; + } + + #wpbody-content #dashboard-widgets #postbox-container-1 { + width: 33%; + } + + #wpbody-content #dashboard-widgets #postbox-container-3, + #wpbody-content #dashboard-widgets #postbox-container-4 { + float: left; + } + + #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + #dashboard-widgets #postbox-container-4 .empty-container:after { + display: none; + } + + .metabox-holder .postbox-container .empty-container:after { + display: block; + } +} + +@media screen and (max-width: 870px) { + .welcome-panel .welcome-panel-column, + .welcome-panel .welcome-panel-column:first-child { + display: block; + float: none; + width: 100%; + } + + .welcome-panel .welcome-panel-column li { + display: inline-block; + margin-left: 13px; + } + + .welcome-panel .welcome-panel-column ul { + margin: 0.4em 0 0; + } + +} + +@media screen and ( max-width: 782px ) { + #dashboard_recent_comments #the-comment-list .comment-item .avatar { + height: 30px; + width: 30px; + margin: 4px 0 5px 10px; + } + + .community-events-toggle-location { + height: 38px; + vertical-align: baseline; + } + + .community-events-form .regular-text { + height: 32px; + } + + #community-events-submit { + margin-bottom: 0; + /* Override .wp-core-ui .button */ + vertical-align: top; + } + + .community-events-form label, + #dashboard-widgets .community-events-cancel.button-link { + /* Same properties as the submit button for cross-browsers alignment. */ + font-size: 14px; + line-height: normal; + height: auto; + padding: 6px 0; + border: 1px solid transparent; + } + + .community-events .spinner { + margin-top: 7px; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Keep the close icon from overlapping the Welcome text. */ + .welcome-panel .welcome-panel-close { + overflow: hidden; + text-indent: 40px; + white-space: nowrap; + width: 20px; + height: 20px; + padding: 5px; + top: 5px; + left: 5px; + } + + /* Make the close icon larger for tappability. */ + .welcome-panel .welcome-panel-close:before { + font-size: 20px; + top: 5px; + right: -35px; + } +} + +@media screen and (min-width: 355px) { + .community-events .event-info { + display: table-row; + float: right; + max-width: 59%; + } + + .event-icon, + .event-icon[aria-hidden="true"] { + display: table-cell; + } + + .event-info-inner { + display: table-cell; + } + + .community-events .event-date-time { + float: left; + max-width: 39%; + } + + .community-events .event-date, + .community-events .event-time { + text-align: left; + } +} diff --git a/backend/wp-admin/css/dashboard-rtl.min.css b/backend/wp-admin/css/dashboard-rtl.min.css new file mode 100644 index 0000000..184f3c0 --- /dev/null +++ b/backend/wp-admin/css/dashboard-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#dashboard_quick_press .draft-title,#the-comment-list td.comment,.dashboard-comment-wrap{word-wrap:break-word}#wpbody-content #dashboard-widgets.columns-1 .postbox-container{width:100%}#wpbody-content #dashboard-widgets.columns-2 .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets.columns-2 #postbox-container-2,#wpbody-content #dashboard-widgets.columns-2 #postbox-container-3,#wpbody-content #dashboard-widgets.columns-2 #postbox-container-4{float:left;width:50.5%}#wpbody-content #dashboard-widgets.columns-3 .postbox-container{width:33.5%}#wpbody-content #dashboard-widgets.columns-3 #postbox-container-1{width:33%}#wpbody-content #dashboard-widgets.columns-3 #postbox-container-3,#wpbody-content #dashboard-widgets.columns-3 #postbox-container-4{float:left}#dashboard-widgets .postbox-container,#wpbody-content #dashboard-widgets.columns-4 .postbox-container{width:25%}#dashboard-widgets-wrap .columns-3 #postbox-container-4 .empty-container{border:none!important}.ie8 #wpbody-content #dashboard-widgets .postbox-container{width:49.5%}.ie8 #wpbody-content #dashboard-widgets #postbox-container-2,.ie8 #wpbody-content #dashboard-widgets #postbox-container-3,.ie8 #wpbody-content #dashboard-widgets #postbox-container-4{float:left;width:50.5%}.ie8 #dashboard-widgets #postbox-container-3 .empty-container,.ie8 #dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}#dashboard-widgets-wrap{overflow:hidden;margin:0 -8px}#dashboard-widgets .postbox .inside{margin-bottom:0}#dashboard-widgets .meta-box-sortables{margin:0 8px;min-height:100px}#the-comment-list td.comment p.comment-author{margin-top:0;margin-right:0}#the-comment-list p.comment-author img{float:right;margin-left:8px}#the-comment-list p.comment-author strong a{border:none}#the-comment-list td{vertical-align:top}#the-comment-list td.comment img{max-width:100%}.welcome-panel{position:relative;overflow:auto;margin:16px 0;padding:23px 10px 0;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff;font-size:13px;line-height:2.1em}#dashboard_right_now .sub,.community-events li:first-child,.community-events li~li,.community-events-footer{border-top:1px solid #eee}.welcome-panel h2{margin:0;font-size:21px;font-weight:400;line-height:1.2}.welcome-panel h3{margin:1.33em 0 0;font-size:16px}.welcome-panel li{font-size:14px}.welcome-panel p{color:#72777c}.welcome-panel a{text-decoration:none}.welcome-panel .about-description{font-size:16px;margin:0}.welcome-panel .welcome-panel-close{position:absolute;top:10px;left:10px;padding:10px 21px 10px 15px;font-size:13px;line-height:1.23076923;text-decoration:none}.welcome-panel .welcome-panel-close:before{position:absolute;top:8px;right:0;transition:all .1s ease-in-out}.wp-core-ui .welcome-panel .button.button-hero{margin:15px 0 3px 13px;padding:12px 36px;height:auto;line-height:1.4285714;white-space:normal}.welcome-panel-content{margin-right:13px;max-width:1500px}.welcome-panel .welcome-panel-column-container{clear:both;position:relative}.welcome-panel .welcome-panel-column{width:32%;min-width:200px;float:right}.ie8 .welcome-panel .welcome-panel-column{min-width:230px}.welcome-panel .welcome-panel-column:first-child{width:36%}.welcome-panel-column p.hide-if-no-customize{margin-top:10px}.welcome-panel-column p{margin-top:7px;color:#444}.welcome-panel .welcome-widgets-menus{line-height:16px}.welcome-panel .welcome-panel-column ul{margin:.8em 0 1em 1em}.welcome-panel .welcome-panel-column li{line-height:16px;list-style-type:none;padding:0 0 8px}.welcome-panel .welcome-icon{background:0 0!important}#dashboard_right_now li a:before,#dashboard_right_now li span:before,.welcome-panel .welcome-icon:before{color:#82878c;font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 0 0 10px;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;vertical-align:top}.welcome-panel .welcome-edit-page:before,.welcome-panel .welcome-write-blog:before{content:"\f119";top:-3px}.welcome-panel .welcome-add-page:before{content:"\f132";top:-1px}.welcome-panel .welcome-view-site:before{content:"\f115";top:-2px}.welcome-panel .welcome-widgets-menus:before{content:"\f116";top:-2px}.welcome-panel .welcome-comments:before{content:"\f117";top:-1px}.welcome-panel .welcome-learn-more:before{content:"\f118";top:-1px}#dashboard_right_now li a:before,#dashboard_right_now li>span:before{content:"\f159";padding:0 0 0 5px}#dashboard_right_now .page-count a:before,#dashboard_right_now .page-count span:before{content:"\f105"}#dashboard_right_now .post-count a:before,#dashboard_right_now .post-count span:before{content:"\f109"}#dashboard_right_now .comment-count a:before{content:"\f101"}#dashboard_right_now .comment-mod-count a:before{content:"\f125"}#dashboard_right_now .storage-count a:before{content:"\f104"}#dashboard_right_now .storage-count.warning a:before{content:"\f153"}.community-events-errors{margin:0}.community-events-loading{padding:10px 12px 8px}.community-events{margin-bottom:6px;padding:0 12px}.community-events .spinner{float:none;margin:5px 2px 0;vertical-align:top}.community-events [aria-hidden=true],.community-events-errors [aria-hidden=true],.community-events-errors[aria-hidden=true],.community-events-loading[aria-hidden=true],.community-events[aria-hidden=true]{display:none}.community-events .activity-block:first-child,.community-events h2{padding-top:12px;padding-bottom:10px}.community-events-form{margin:15px 0 5px}.community-events-form .regular-text{width:40%;height:29px;margin:0;vertical-align:top}.community-events li.event-none{border-right:4px solid #00a0d2}.community-events-form label{display:inline-block;vertical-align:top;line-height:28px;height:28px}.community-events .activity-block>p{margin-bottom:0;display:inline}.community-events-toggle-location{vertical-align:middle}#community-events-submit{margin-right:3px;margin-left:3px}#dashboard-widgets .community-events-cancel.button-link{vertical-align:top;line-height:26px;height:28px;text-decoration:underline}.community-events ul{background-color:#fafafa;padding-right:0;padding-left:0;padding-bottom:0}.community-events li{margin:0;padding:8px 12px;color:#72777c}.community-events .activity-block.last{border-bottom:1px solid #eee;padding-top:0;margin-top:-1px}.community-events .event-info{display:block}.event-icon{height:18px;padding-left:10px;width:18px;display:none}.event-icon:before{color:#82878C;font-size:18px}.event-meetup .event-icon:before{content:"\f484"}.event-wordcamp .event-icon:before{content:"\f486"}.community-events .event-title{font-weight:600;display:block}.community-events .event-date,.community-events .event-time{display:block}.community-events-footer{margin-top:0;margin-bottom:0;padding:12px;color:#ddd}#dashboard_primary .rss-widget span,#dashboard_primary .rss-widget span.rss-date,.rssSummary{color:#72777c}.community-events-footer .screen-reader-text{height:inherit;white-space:nowrap}#dashboard_primary .inside{margin:0;padding:0}#dashboard_primary .widget-loading{padding:12px 12px 0;margin-bottom:1em!important}#dashboard_primary .inside .notice,body #dashboard-widgets .postbox form .submit{margin:0}.dashboard-widget-control-form p{margin-top:0}.rssSummary{margin-top:4px}#dashboard_primary .rss-widget{font-size:13px;padding:0 12px}#dashboard_primary .rss-widget:last-child{border-bottom:none;padding-bottom:8px}#dashboard_primary .rss-widget a{font-weight:400}#dashboard_primary .rss-widget span.rss-date{margin-right:12px}#dashboard_primary .rss-widget ul li{padding:4px 0;margin:0}#dashboard_right_now ul{margin:0;display:inline-block;width:100%}#dashboard_right_now li{width:50%;float:right;margin-bottom:10px}#dashboard_right_now .inside{padding:0}#dashboard_right_now .main{padding:0 12px 11px}#dashboard_right_now .main p{margin:0}#dashboard_right_now #wp-version-message .button{float:left;position:relative;top:-5px;margin-right:5px}.mu-storage{overflow:hidden}#dashboard-widgets h3.mu-storage{margin:0 0 10px;padding:0;font-size:14px;font-weight:400}#dashboard_right_now .sub{color:#555d66;background:#f5f5f5;padding:10px 12px 6px}#dashboard_right_now .sub h3{color:#555}#dashboard_right_now .sub p{margin:0 0 1em}#dashboard_right_now .warning a:before,#dashboard_right_now .warning span:before{color:#d54e21}#dashboard_quick_press .drafts li time,#title-wrap #title-prompt-text,.textarea-wrap #content-prompt-text{color:#72777c}#dashboard_quick_press .inside{margin:0;padding:0}#dashboard_quick_press div.updated{margin-bottom:10px;border:1px solid #eee;border-width:1px 0 1px 1px}#dashboard_quick_press form{margin:12px}#dashboard_quick_press .drafts,#dashboard_quick_press .easy-blogging{padding:10px 0 0}input#save-post{float:right}form.initial-form.quickpress-open label.prompt{font-style:normal}form.initial-form.quickpress-open input#title{height:auto}#dashboard_quick_press input,#dashboard_quick_press textarea{box-sizing:border-box;margin:0}#dashboard_quick_press textarea{resize:vertical}#description-wrap{margin-top:12px}.input-text-wrap,.textarea-wrap{position:relative}.input-text-wrap .prompt,.textarea-wrap .prompt{position:absolute}.textarea-wrap #content-prompt-text{font-size:1.1em;padding:7px 8px}.textarea-wrap textarea#content{margin:0 0 8px;padding:6px 7px}#quick-press textarea#content{min-height:90px;max-height:1300px;resize:none}.js #dashboard_quick_press .drafts{border-top:1px solid #eee}#dashboard_quick_press .drafts abbr{border:none}#dashboard_quick_press .drafts .view-all{float:left;margin:0 0 0 12px}#dashboard_primary a.rsswidget{font-weight:400}#dashboard_quick_press .drafts ul{margin:0 12px}#dashboard_quick_press .drafts li{margin-bottom:1em}#dashboard_quick_press .drafts p{margin:0;word-wrap:break-word}#dashboard_quick_press .draft-title a,#dashboard_quick_press .draft-title time{margin:0 0 0 5px}#dashboard-widgets h3,#dashboard-widgets h4,#dashboard_quick_press .drafts h2{margin:0 12px 8px;padding:0;font-size:14px;font-weight:400;color:#23282d}#dashboard_quick_press .drafts h2{line-height:inherit}#dashboard-widgets .inside h3,#dashboard-widgets .inside h4{margin-right:0;margin-left:0}#dashboard_activity .comment-meta span.approve:before{content:"\f227";font:20px/.5 dashicons;margin-right:5px;vertical-align:middle;position:relative;top:-1px;margin-left:2px}#dashboard_activity .inside{margin:0;padding-bottom:0}#dashboard_activity .no-activity{overflow:hidden;padding:0 0 12px;text-align:center}#dashboard_activity .no-activity p{color:#72777c;font-size:16px}#dashboard_activity .no-activity .smiley{margin-top:0}#dashboard_activity .no-activity .smiley:before{content:"\f328";font:400 120px/1 dashicons;speak:none;display:block;margin:0 0 0 5px;padding:0;text-indent:0;text-align:center;position:relative;-webkit-font-smoothing:antialiased;text-decoration:none!important}#dashboard_activity .subsubsub{float:none;border-top:1px solid #eee;margin:0 -12px;padding:8px 12px 4px}#dashboard_activity .subsubsub a .count,#dashboard_activity .subsubsub a.current .count{color:#72777c}#future-posts ul,#published-posts ul{clear:both;margin-bottom:0}#future-posts li,#published-posts li{margin-bottom:8px}#future-posts ul span,#published-posts ul span{display:inline-block;margin-left:5px;min-width:150px;color:#72777c}.activity-block{border-bottom:1px solid #eee;margin:0 -12px;padding:8px 12px 4px}.activity-block:last-child{border-bottom:none}.activity-block .subsubsub li{color:#ddd}#activity-widget #the-comment-list div.undo,#activity-widget #the-comment-list tr.undo{background:0 0;padding:6px 0;margin-right:12px}#activity-widget #the-comment-list .comment-item{background:#fafafa;padding:12px;position:relative}#activity-widget #the-comment-list .avatar{position:absolute;top:12px}#activity-widget #the-comment-list .dashboard-comment-wrap{padding-right:63px}#activity-widget #the-comment-list .dashboard-comment-wrap blockquote{margin:1em 0}#activity-widget #the-comment-list .comment-item p.row-actions{margin:4px 0 0}#activity-widget #the-comment-list .comment-item:first-child{border-top:1px solid #eee}#activity-widget #the-comment-list .unapproved{background-color:#fef7f1}#activity-widget #the-comment-list .unapproved:before{content:"";display:block;position:absolute;right:0;top:0;bottom:0;background:#d54e21;width:4px}#activity-widget #the-comment-list .spam-undo-inside .avatar,#activity-widget #the-comment-list .trash-undo-inside .avatar{position:relative;top:0}#dashboard-widgets #dashboard_browser_nag.postbox .inside{margin:10px}.postbox .button-link .edit-box{display:none}.edit-box{opacity:0}.edit-box:focus,.hndle:hover .edit-box{opacity:1}#dashboard-widgets form .input-text-wrap input,#dashboard-widgets form .textarea-wrap textarea{width:100%}#dashboard-widgets .postbox form .submit{float:none;margin:.5em 0 0;padding:0;border:none}#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish{min-width:0}#dashboard-widgets .button-link,#dashboard-widgets a{text-decoration:none}#dashboard-widgets h2 a,#dashboard_browser_nag a{text-decoration:underline}#dashboard-widgets .hndle .postbox-title-action{float:left;line-height:1.2}#dashboard_plugins h5{font-size:14px}#latest-comments #the-comment-list{position:relative;margin:0 -12px}#activity-widget #the-comment-list .comment,#activity-widget #the-comment-list .pingback{box-shadow:inset 0 1px 0 rgba(0,0,0,.06)}#activity-widget .comments #the-comment-list .alt{background-color:transparent}#activity-widget #latest-comments #the-comment-list .comment-item{min-height:50px;margin:0;padding:12px}#latest-comments #the-comment-list .pingback{padding-right:12px!important}#latest-comments #the-comment-list .comment-item:first-child{border-top:none}#latest-comments #the-comment-list .comment-meta{line-height:1.5em;margin:0;color:#666}#latest-comments #the-comment-list .comment-meta cite{font-style:normal;font-weight:400}#latest-comments #the-comment-list .comment-item blockquote,#latest-comments #the-comment-list .comment-item blockquote p{margin:0;padding:0;display:inline}#latest-comments #the-comment-list .comment-item p.row-actions{margin:3px 0 0;padding:0;font-size:13px}#description-wrap label,#title-wrap label{cursor:text}#title-wrap #title{padding:2px 6px;font-size:1.3em;outline:0}#title-wrap #title-prompt-text{font-size:1.1em;padding:5px 8px}.rss-widget ul{margin:0;padding:0;list-style:none}a.rsswidget{font-size:13px;font-weight:600;line-height:1.4em}.rss-widget ul li{line-height:1.5em;margin-bottom:12px}.rss-widget span.rss-date{color:#72777c;font-size:13px;margin-right:3px}.rss-widget cite{display:block;text-align:left;margin:0 0 1em;padding:0}.rss-widget cite:before{content:"\2014"}#dashboard_browser_nag a.update-browser-link{font-size:1.2em;font-weight:600}#dashboard_browser_nag a{color:#fff}#dashboard_browser_nag p.browser-update-nag.has-browser-icon{padding-left:125px}#dashboard_browser_nag .browser-icon{margin-top:-35px}#dashboard_browser_nag.postbox.browser-insecure{background-color:#ac1b1b;border-color:#ac1b1b}#dashboard_browser_nag.postbox{background-color:#e29808;background-image:none;border-color:#edc048;color:#fff;box-shadow:none}#dashboard_browser_nag.postbox.browser-insecure h2{border-bottom-color:#cd5a5a;color:#fff}#dashboard_browser_nag.postbox h2{border-bottom-color:#f6e2ac;background:0 0;color:#fff;box-shadow:none}#dashboard_browser_nag h2.hndle{border:none;font-weight:600;font-size:20px;padding-top:10px}.postbox#dashboard_browser_nag p a.dismiss{font-size:14px}.postbox#dashboard_browser_nag a,.postbox#dashboard_browser_nag p,.postbox#dashboard_browser_nag p.browser-update-nag{font-size:16px}@media only screen and (max-width:799px){#wpbody-content #dashboard-widgets .postbox-container{width:100%}}@media only screen and (min-width:800px) and (max-width:1499px){#dashboard-widgets #postbox-container-3 .empty-container,#dashboard-widgets #postbox-container-4 .empty-container,#wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container{border:0;height:0;min-height:0}#wpbody-content #dashboard-widgets .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets #postbox-container-2,#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:left;width:50.5%}#dashboard-widgets #postbox-container-3 .empty-container:after,#dashboard-widgets #postbox-container-4 .empty-container:after{display:none}#wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container{width:100%}.index-php .columns-prefs,.index-php .screen-layout{display:block}.columns-prefs .columns-prefs-3,.columns-prefs .columns-prefs-4{display:none}.metabox-holder .postbox-container .empty-container:after{display:block}}@media only screen and (min-width:1500px) and (max-width:1800px){#wpbody-content #dashboard-widgets .postbox-container{width:33.5%}#wpbody-content #dashboard-widgets #postbox-container-1{width:33%}#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:left}#dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}#dashboard-widgets #postbox-container-4 .empty-container:after{display:none}.metabox-holder .postbox-container .empty-container:after{display:block}}@media screen and (max-width:870px){.welcome-panel .welcome-panel-column,.welcome-panel .welcome-panel-column:first-child{display:block;float:none;width:100%}.welcome-panel .welcome-panel-column li{display:inline-block;margin-left:13px}.welcome-panel .welcome-panel-column ul{margin:.4em 0 0}}@media screen and (max-width:782px){#dashboard_recent_comments #the-comment-list .comment-item .avatar{height:30px;width:30px;margin:4px 0 5px 10px}.community-events-toggle-location{height:38px;vertical-align:baseline}.community-events-form .regular-text{height:32px}#community-events-submit{margin-bottom:0;vertical-align:top}#dashboard-widgets .community-events-cancel.button-link,.community-events-form label{font-size:14px;line-height:normal;height:auto;padding:6px 0;border:1px solid transparent}.community-events .spinner{margin-top:7px}}@media screen and (max-width:600px){.welcome-panel .welcome-panel-close{overflow:hidden;text-indent:40px;white-space:nowrap;width:20px;height:20px;padding:5px;top:5px;left:5px}.welcome-panel .welcome-panel-close:before{font-size:20px;top:5px;right:-35px}}@media screen and (min-width:355px){.community-events .event-info{display:table-row;float:right;max-width:59%}.event-icon,.event-icon[aria-hidden=true],.event-info-inner{display:table-cell}.community-events .event-date-time{float:left;max-width:39%}.community-events .event-date,.community-events .event-time{text-align:left}} \ No newline at end of file diff --git a/backend/wp-admin/css/dashboard.css b/backend/wp-admin/css/dashboard.css new file mode 100644 index 0000000..f64cc92 --- /dev/null +++ b/backend/wp-admin/css/dashboard.css @@ -0,0 +1,1313 @@ +#wpbody-content #dashboard-widgets.columns-1 .postbox-container { + width: 100%; +} + +#wpbody-content #dashboard-widgets.columns-2 .postbox-container { + width: 49.5%; +} + +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-2, +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-3, +#wpbody-content #dashboard-widgets.columns-2 #postbox-container-4 { + float: right; + width: 50.5%; +} + +#wpbody-content #dashboard-widgets.columns-3 .postbox-container { + width: 33.5%; +} + +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-1 { + width: 33%; +} + +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-3, +#wpbody-content #dashboard-widgets.columns-3 #postbox-container-4 { + float: right; +} + +#wpbody-content #dashboard-widgets.columns-4 .postbox-container { + width: 25%; +} + +#dashboard-widgets .postbox-container { + width: 25%; +} + +#dashboard-widgets-wrap .columns-3 #postbox-container-4 .empty-container { + border: none !important; +} + +.ie8 #wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; +} + +.ie8 #wpbody-content #dashboard-widgets #postbox-container-2, +.ie8 #wpbody-content #dashboard-widgets #postbox-container-3, +.ie8 #wpbody-content #dashboard-widgets #postbox-container-4 { + float: right; + width: 50.5%; +} + +.ie8 #dashboard-widgets #postbox-container-3 .empty-container, +.ie8 #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +#dashboard-widgets-wrap { + overflow: hidden; + margin: 0 -8px; +} + +#dashboard-widgets .postbox .inside { + margin-bottom: 0; +} + +#dashboard-widgets .meta-box-sortables { + margin: 0 8px; + min-height: 100px; +} + +/* @todo: this was originally in this section, but likely belongs elsewhere */ +#the-comment-list td.comment p.comment-author { + margin-top: 0; + margin-left: 0; +} + +#the-comment-list p.comment-author img { + float: left; + margin-right: 8px; +} + +#the-comment-list p.comment-author strong a { + border: none; +} + +#the-comment-list td { + vertical-align: top; +} + +#the-comment-list td.comment { + word-wrap: break-word; +} + +#the-comment-list td.comment img { + max-width: 100%; +} + +/* Welcome Panel */ +.welcome-panel { + position: relative; + overflow: auto; + margin: 16px 0; + padding: 23px 10px 0; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; + font-size: 13px; + line-height: 2.1em; +} + +.welcome-panel h2 { + margin: 0; + font-size: 21px; + font-weight: 400; + line-height: 1.2; +} + +.welcome-panel h3 { + margin: 1.33em 0 0; + font-size: 16px; +} + +.welcome-panel li { + font-size: 14px; +} + +.welcome-panel p { + color: #72777c; +} + +.welcome-panel a { + text-decoration: none; +} + +.welcome-panel .about-description { + font-size: 16px; + margin: 0; +} + +.welcome-panel .welcome-panel-close { + position: absolute; + top: 10px; + right: 10px; + padding: 10px 15px 10px 21px; + font-size: 13px; + line-height: 1.23076923; /* Chrome rounding, needs to be 16px equivalent */ + text-decoration: none; +} + +.welcome-panel .welcome-panel-close:before { + position: absolute; + top: 8px; + left: 0; + transition: all .1s ease-in-out; +} + +.wp-core-ui .welcome-panel .button.button-hero { + margin: 15px 13px 3px 0; + padding: 12px 36px; + height: auto; + line-height: 1.4285714; + white-space: normal; +} + +.welcome-panel-content { + margin-left: 13px; + max-width: 1500px; +} + +.welcome-panel .welcome-panel-column-container { + clear: both; + position: relative; +} + +.welcome-panel .welcome-panel-column { + width: 32%; + min-width: 200px; + float: left; +} + +.ie8 .welcome-panel .welcome-panel-column { + min-width: 230px; +} + +.welcome-panel .welcome-panel-column:first-child { + width: 36%; +} + +.welcome-panel-column p.hide-if-no-customize { + margin-top: 10px; +} + +.welcome-panel-column p { + margin-top: 7px; + color: #444; +} + +.welcome-panel .welcome-widgets-menus { + line-height: 16px; +} + +.welcome-panel .welcome-panel-column ul { + margin: 0.8em 1em 1em 0; +} + +.welcome-panel .welcome-panel-column li { + line-height: 16px; + list-style-type: none; + padding: 0 0 8px; +} + +.welcome-panel .welcome-icon { + background: transparent !important; +} + +/* Welcome Panel and Right Now common Icons style */ + +.welcome-panel .welcome-icon:before, +#dashboard_right_now li a:before, +#dashboard_right_now li span:before { + color: #82878c; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0 10px 0 0; + position: relative; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + vertical-align: top; +} + +/* Welcome Panel specific Icons styles */ + +.welcome-panel .welcome-write-blog:before, +.welcome-panel .welcome-edit-page:before { + content: "\f119"; + top: -3px; +} + +.welcome-panel .welcome-add-page:before { + content: "\f132"; + top: -1px; +} + +.welcome-panel .welcome-view-site:before { + content: "\f115"; + top: -2px; +} + +.welcome-panel .welcome-widgets-menus:before { + content: "\f116"; + top: -2px; +} + +.welcome-panel .welcome-comments:before { + content: "\f117"; + top: -1px; +} + +.welcome-panel .welcome-learn-more:before { + content: "\f118"; + top: -1px; +} + +/* Right Now specific Icons styles */ + +#dashboard_right_now li a:before, +#dashboard_right_now li > span:before { /* get only the first level span to exclude screen-reader-text in mu-storage */ + content: "\f159"; /* generic icon for items added by CPTs ? */ + padding: 0 5px 0 0; +} + +#dashboard_right_now .page-count a:before, +#dashboard_right_now .page-count span:before { + content: "\f105"; +} + +#dashboard_right_now .post-count a:before, +#dashboard_right_now .post-count span:before { + content: "\f109"; +} + +#dashboard_right_now .comment-count a:before { + content: "\f101"; +} + +#dashboard_right_now .comment-mod-count a:before { + content: "\f125"; +} + +#dashboard_right_now .storage-count a:before { + content: "\f104"; +} + +#dashboard_right_now .storage-count.warning a:before { + content: "\f153"; +} + +/* Dashboard WordPress events */ + +.community-events-errors { + margin: 0; +} + +.community-events-loading { + padding: 10px 12px 8px; +} + +.community-events { + margin-bottom: 6px; + padding: 0 12px; +} + +.community-events .spinner { + float: none; + margin: 5px 2px 0; + vertical-align: top; +} + +.community-events-errors[aria-hidden="true"], +.community-events-errors [aria-hidden="true"], +.community-events-loading[aria-hidden="true"], +.community-events[aria-hidden="true"], +.community-events [aria-hidden="true"] { + display: none; +} + +.community-events .activity-block:first-child, +.community-events h2 { + padding-top: 12px; + padding-bottom: 10px; +} + +.community-events-form { + margin: 15px 0 5px; +} + +.community-events-form .regular-text { + width: 40%; + height: 29px; + margin: 0; + vertical-align: top; +} + +.community-events li.event-none { + border-left: 4px solid #00a0d2; +} + +.community-events-form label { + display: inline-block; + vertical-align: top; + line-height: 28px; + height: 28px; +} + +.community-events .activity-block > p { + margin-bottom: 0; + display: inline; +} + +.community-events-toggle-location { + vertical-align: middle; +} + +#community-events-submit { + margin-left: 3px; + margin-right: 3px; +} + +/* Needs higher specificity than #dashboard-widgets .button-link */ +#dashboard-widgets .community-events-cancel.button-link { + vertical-align: top; + /* Same properties as the submit button for cross-browsers alignment. */ + line-height: 26px; + height: 28px; + text-decoration: underline; +} + +.community-events ul { + background-color: #fafafa; + padding-left: 0; + padding-right: 0; + padding-bottom: 0; +} + +.community-events li { + margin: 0; + padding: 8px 12px; + color: #72777c; +} +.community-events li:first-child { + border-top: 1px solid #eee; +} + +.community-events li ~ li { + border-top: 1px solid #eee; +} + +.community-events .activity-block.last { + border-bottom: 1px solid #eee; + padding-top: 0; + margin-top: -1px; +} + +.community-events .event-info { + display: block; +} + +.event-icon { + height: 18px; + padding-right: 10px; + width: 18px; + display: none; /* Hide on smaller screens */ +} + +.event-icon:before { + color: #82878C; + font-size: 18px; +} +.event-meetup .event-icon:before { + content: "\f484"; +} +.event-wordcamp .event-icon:before { + content: "\f486"; +} + +.community-events .event-title { + font-weight: 600; + display: block; +} + +.community-events .event-date, +.community-events .event-time { + display: block; +} + +.community-events-footer { + margin-top: 0; + margin-bottom: 0; + padding: 12px; + border-top: 1px solid #eee; + color: #ddd; +} + +/* Safari 10 + VoiceOver specific: without this, the hidden text gets read out before the link. */ +.community-events-footer .screen-reader-text { + height: inherit; + white-space: nowrap; +} + +/* Dashboard WordPress news */ + +#dashboard_primary .inside { + margin: 0; + padding: 0; +} + +#dashboard_primary .widget-loading { + padding: 12px 12px 0; + margin-bottom: 1em !important; /* Needs to override `.postbox .inside > p:last-child` in common.css */ +} + +/* Notice when JS is off. */ +#dashboard_primary .inside .notice { + margin: 0; +} + +body #dashboard-widgets .postbox form .submit { + margin: 0; +} + +/* Used only for configurable widgets. */ +.dashboard-widget-control-form p { + margin-top: 0; +} + +.rssSummary { + color: #72777c; + margin-top: 4px; +} + +#dashboard_primary .rss-widget { + font-size: 13px; + padding: 0 12px 0; +} + +#dashboard_primary .rss-widget:last-child { + border-bottom: none; + padding-bottom: 8px; +} + +#dashboard_primary .rss-widget a { + font-weight: 400; +} + +#dashboard_primary .rss-widget span, +#dashboard_primary .rss-widget span.rss-date { + color: #72777c; +} + +#dashboard_primary .rss-widget span.rss-date { + margin-left: 12px; +} + +#dashboard_primary .rss-widget ul li { + padding: 4px 0; + margin: 0; +} + +/* Dashboard right now */ + +#dashboard_right_now ul { + margin: 0; + /* contain floats but don't use overflow: hidden */ + display: inline-block; + width: 100%; +} + +#dashboard_right_now li { + width: 50%; + float: left; + margin-bottom: 10px; +} + +#dashboard_right_now .inside { + padding: 0; +} + +#dashboard_right_now .main { + padding: 0 12px 11px; +} + +#dashboard_right_now .main p { + margin: 0; +} + +#dashboard_right_now #wp-version-message .button { + float: right; + position: relative; + top: -5px; + margin-left: 5px; +} + +.mu-storage { + overflow: hidden; +} + +#dashboard-widgets h3.mu-storage { + margin: 0 0 10px; + padding: 0; + font-size: 14px; + font-weight: 400; +} + +/* Dashboard right now - Colors */ + +#dashboard_right_now .sub { + color: #555d66; + background: #f5f5f5; + border-top: 1px solid #eee; + padding: 10px 12px 6px 12px; +} + +#dashboard_right_now .sub h3 { + color: #555; +} + +#dashboard_right_now .sub p { + margin: 0 0 1em; +} + +#dashboard_right_now .warning a:before, +#dashboard_right_now .warning span:before { + color: #d54e21; +} + +/* Dashboard Quick Draft */ + +#dashboard_quick_press .inside { + margin: 0; + padding: 0; +} + +#dashboard_quick_press div.updated { + margin-bottom: 10px; + border: 1px solid #eee; + border-width: 1px 1px 1px 0; +} + +#dashboard_quick_press form { + margin: 12px; +} + +#dashboard_quick_press .drafts, +#dashboard_quick_press .easy-blogging { + padding: 10px 0 0; +} + +/* Dashboard Quick Draft - Form styling */ + +input#save-post { + float: left; +} + +form.initial-form.quickpress-open label.prompt { + font-style: normal; +} + +form.initial-form.quickpress-open input#title { + height: auto; +} + +#dashboard_quick_press input, +#dashboard_quick_press textarea { + box-sizing: border-box; + margin: 0; +} + +#dashboard_quick_press textarea { + resize: vertical; +} + +#dashboard-widgets .postbox form .submit { + margin: -39px 0; + float: right; +} + +#description-wrap { + margin-top: 12px; +} + +#title-wrap #title-prompt-text, +.textarea-wrap #content-prompt-text { + color: #72777c; +} + +#title-wrap #title-prompt-text { + font-size: 1.1em; + padding: 7px 8px; +} + +.input-text-wrap, +.textarea-wrap { + position: relative; +} + +.input-text-wrap .prompt, +.textarea-wrap .prompt { + position: absolute; +} + +.textarea-wrap #content-prompt-text { + font-size: 1.1em; + padding: 7px 8px; +} + +.textarea-wrap textarea#content { + margin: 0 0 8px; + padding: 6px 7px; +} + +#quick-press textarea#content { + min-height: 90px; + max-height: 1300px; + resize: none; +} + +/* Dashboard Quick Draft - Drafts list */ + +.js #dashboard_quick_press .drafts { + border-top: 1px solid #eee; +} + +#dashboard_quick_press .drafts abbr { + border: none; +} + +#dashboard_quick_press .drafts .view-all { + float: right; + margin: 0 12px 0 0; +} + +#dashboard_primary a.rsswidget { + font-weight: 400; +} + +#dashboard_quick_press .drafts ul { + margin: 0 12px; +} + +#dashboard_quick_press .drafts li { + margin-bottom: 1em; +} +#dashboard_quick_press .drafts li time { + color: #72777c; +} + +#dashboard_quick_press .drafts p { + margin: 0; + word-wrap: break-word; +} + +#dashboard_quick_press .draft-title { + word-wrap: break-word; +} + +#dashboard_quick_press .draft-title a, +#dashboard_quick_press .draft-title time { + margin: 0 5px 0 0; +} + +/* Dashboard common styles */ + +#dashboard-widgets h4, /* Back-compat for pre-4.4 */ +#dashboard-widgets h3, +#dashboard_quick_press .drafts h2 { + margin: 0 12px 8px; + padding: 0; + font-size: 14px; + font-weight: 400; + color: #23282d; +} + +#dashboard_quick_press .drafts h2 { + line-height: inherit; +} + +#dashboard-widgets .inside h4, /* Back-compat for pre-4.4 */ +#dashboard-widgets .inside h3 { + margin-left: 0; + margin-right: 0; +} + +/* Dashboard activity widget */ + +#dashboard_activity .comment-meta span.approve:before { + content: "\f227"; + font: 20px/.5 dashicons; + margin-left: 5px; + vertical-align: middle; + position: relative; + top: -1px; + margin-right: 2px; +} + +#dashboard_activity .inside { + margin: 0; + padding-bottom: 0; +} + +#dashboard_activity .no-activity { + overflow: hidden; + padding: 0 0 12px; + text-align: center; +} + +#dashboard_activity .no-activity p { + color: #72777c; + font-size: 16px; +} + +#dashboard_activity .no-activity .smiley { + margin-top: 0; +} + +#dashboard_activity .no-activity .smiley:before { + content: "\f328"; + font: normal 120px/1 dashicons; + speak: none; + display: block; + margin: 0 5px 0 0; + padding: 0; + text-indent: 0; + text-align: center; + position: relative; + -webkit-font-smoothing: antialiased; + text-decoration: none !important; +} + +#dashboard_activity .subsubsub { + float: none; + border-top: 1px solid #eee; + margin: 0 -12px; + padding: 8px 12px 4px; +} + +#dashboard_activity .subsubsub a .count, +#dashboard_activity .subsubsub a.current .count { + color: #72777c; /* white background on the dashboard but #f1f1f1 on list tables */ +} + +#future-posts ul, +#published-posts ul { + clear: both; + margin-bottom: 0; +} + +#future-posts li, +#published-posts li { + margin-bottom: 8px; +} + +#future-posts ul span, +#published-posts ul span { + display: inline-block; + margin-right: 5px; + min-width: 150px; + color: #72777c; +} + +.activity-block { + border-bottom: 1px solid #eee; + margin: 0 -12px; + padding: 8px 12px 4px; +} + +.activity-block:last-child { + border-bottom: none; +} + +.activity-block .subsubsub li { + color: #ddd; +} + +/* Dashboard activity widget - Comments */ +/* @todo: needs serious de-duplication */ + +#activity-widget #the-comment-list tr.undo, +#activity-widget #the-comment-list div.undo { + background: none; + padding: 6px 0; + margin-left: 12px; +} + +#activity-widget #the-comment-list .comment-item { + background: #fafafa; + padding: 12px; + position: relative; +} + +#activity-widget #the-comment-list .avatar { + position: absolute; + top: 12px; +} + +#activity-widget #the-comment-list .dashboard-comment-wrap { + padding-left: 63px; +} + +#activity-widget #the-comment-list .dashboard-comment-wrap blockquote { + margin: 1em 0; +} + +#activity-widget #the-comment-list .comment-item p.row-actions { + margin: 4px 0 0 0; +} + +#activity-widget #the-comment-list .comment-item:first-child { + border-top: 1px solid #eeeeee; +} + +#activity-widget #the-comment-list .unapproved { + background-color: #fef7f1; +} + +#activity-widget #the-comment-list .unapproved:before { + content: ""; + display: block; + position: absolute; + left: 0; + top: 0; + bottom: 0; + background: #d54e21; + width: 4px; +} + +#activity-widget #the-comment-list .spam-undo-inside .avatar, +#activity-widget #the-comment-list .trash-undo-inside .avatar { + position: relative; + top: 0; +} + +/* Browse happy box */ + +#dashboard-widgets #dashboard_browser_nag.postbox .inside { + margin: 10px; +} + +.postbox .button-link .edit-box { + display: none; +} + +.edit-box { + opacity: 0; +} + +.hndle:hover .edit-box, +.edit-box:focus { + opacity: 1; +} + +#dashboard-widgets form .input-text-wrap input { + width: 100%; +} + +#dashboard-widgets form .textarea-wrap textarea { + width: 100%; +} + +#dashboard-widgets .postbox form .submit { + float: none; + margin: .5em 0 0; + padding: 0; + border: none; +} + +#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish { + min-width: 0; +} + +#dashboard-widgets a, +#dashboard-widgets .button-link { + text-decoration: none; +} + +#dashboard-widgets h2 a { + text-decoration: underline; +} + +#dashboard-widgets .hndle .postbox-title-action { + float: right; + line-height: 1.2; +} + +#dashboard_plugins h5 { + font-size: 14px; +} + +/* Recent Comments */ + +#latest-comments #the-comment-list { + position: relative; + margin: 0 -12px; +} + +#activity-widget #the-comment-list .comment, +#activity-widget #the-comment-list .pingback { + box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.06); +} + +#activity-widget .comments #the-comment-list .alt { + background-color: transparent; +} + +#activity-widget #latest-comments #the-comment-list .comment-item { + /* the row-actions paragraph is output only for users with 'edit_comment' capabilities, + for other users this needs a min height equal to the gravatar image */ + min-height: 50px; + margin: 0; + padding: 12px; +} + +#latest-comments #the-comment-list .pingback { + padding-left: 12px !important; +} + +#latest-comments #the-comment-list .comment-item:first-child { + border-top: none; +} + +#latest-comments #the-comment-list .comment-meta { + line-height: 1.5em; + margin: 0; + color: #666; +} + +#latest-comments #the-comment-list .comment-meta cite { + font-style: normal; + font-weight: 400; +} + +#latest-comments #the-comment-list .comment-item blockquote, +#latest-comments #the-comment-list .comment-item blockquote p { + margin: 0; + padding: 0; + display: inline; +} + +#latest-comments #the-comment-list .comment-item p.row-actions { + margin: 3px 0 0; + padding: 0; + font-size: 13px; +} + +/* QuickDraft */ + +#title-wrap label, +#description-wrap label { + cursor: text; +} + +#title-wrap #title { + padding: 2px 6px; + font-size: 1.3em; + outline: none; +} + +#title-wrap #title-prompt-text { + font-size: 1.1em; + padding: 5px 8px; +} + +/* Feeds */ +.rss-widget ul { + margin: 0; + padding: 0; + list-style: none; +} + +a.rsswidget { + font-size: 13px; + font-weight: 600; + line-height: 1.4em; +} + +.rss-widget ul li { + line-height: 1.5em; + margin-bottom: 12px; +} + +.rss-widget span.rss-date { + color: #72777c; + font-size: 13px; + margin-left: 3px; +} + +.rss-widget cite { + display: block; + text-align: right; + margin: 0 0 1em; + padding: 0; +} + +.rss-widget cite:before { + content: "\2014"; +} + +.dashboard-comment-wrap { + word-wrap: break-word; +} + +/* Browser Nag */ +#dashboard_browser_nag a.update-browser-link { + font-size: 1.2em; + font-weight: 600; +} + +#dashboard_browser_nag a { + text-decoration: underline; +} + +#dashboard_browser_nag p.browser-update-nag.has-browser-icon { + padding-right: 125px; +} + +#dashboard_browser_nag .browser-icon { + margin-top: -35px; +} + +#dashboard_browser_nag.postbox.browser-insecure { + background-color: #ac1b1b; + border-color: #ac1b1b; +} + +#dashboard_browser_nag.postbox { + background-color: #e29808; + background-image: none; + border-color: #edc048; + color: #fff; + box-shadow: none; +} + +#dashboard_browser_nag.postbox.browser-insecure h2 { + border-bottom-color: #cd5a5a; + color: #fff; +} + +#dashboard_browser_nag.postbox h2 { + border-bottom-color: #f6e2ac; + background: transparent none; + color: #fff; + box-shadow: none; +} + +#dashboard_browser_nag a { + color: #fff; +} + +#dashboard_browser_nag h2.hndle { + border: none; + font-weight: 600; + font-size: 20px; + padding-top: 10px; +} + +.postbox#dashboard_browser_nag p a.dismiss { + font-size: 14px; +} + +.postbox#dashboard_browser_nag p, +.postbox#dashboard_browser_nag a, +.postbox#dashboard_browser_nag p.browser-update-nag { + font-size: 16px; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/* one column on the dash */ +@media only screen and (max-width: 799px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 100%; + } +} + +/* two columns on the dash, but keep the setting if one is selected */ +@media only screen and (min-width: 800px) and (max-width: 1499px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; + } + + #wpbody-content #dashboard-widgets #postbox-container-2, + #wpbody-content #dashboard-widgets #postbox-container-3, + #wpbody-content #dashboard-widgets #postbox-container-4 { + float: right; + width: 50.5%; + } + + #dashboard-widgets #postbox-container-3 .empty-container, + #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + #dashboard-widgets #postbox-container-3 .empty-container:after, + #dashboard-widgets #postbox-container-4 .empty-container:after { + display: none; + } + + #wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container { + width: 100%; + } + + #wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + /* show the radio buttons for column prefs only for one or two columns */ + .index-php .screen-layout, + .index-php .columns-prefs { + display: block; + } + + .columns-prefs .columns-prefs-3, + .columns-prefs .columns-prefs-4 { + display: none; + } + + .metabox-holder .postbox-container .empty-container:after { + display: block; + } +} + +/* three columns on the dash */ +@media only screen and (min-width: 1500px) and (max-width: 1800px) { + #wpbody-content #dashboard-widgets .postbox-container { + width: 33.5%; + } + + #wpbody-content #dashboard-widgets #postbox-container-1 { + width: 33%; + } + + #wpbody-content #dashboard-widgets #postbox-container-3, + #wpbody-content #dashboard-widgets #postbox-container-4 { + float: right; + } + + #dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; + } + + #dashboard-widgets #postbox-container-4 .empty-container:after { + display: none; + } + + .metabox-holder .postbox-container .empty-container:after { + display: block; + } +} + +@media screen and (max-width: 870px) { + .welcome-panel .welcome-panel-column, + .welcome-panel .welcome-panel-column:first-child { + display: block; + float: none; + width: 100%; + } + + .welcome-panel .welcome-panel-column li { + display: inline-block; + margin-right: 13px; + } + + .welcome-panel .welcome-panel-column ul { + margin: 0.4em 0 0; + } + +} + +@media screen and ( max-width: 782px ) { + #dashboard_recent_comments #the-comment-list .comment-item .avatar { + height: 30px; + width: 30px; + margin: 4px 10px 5px 0; + } + + .community-events-toggle-location { + height: 38px; + vertical-align: baseline; + } + + .community-events-form .regular-text { + height: 32px; + } + + #community-events-submit { + margin-bottom: 0; + /* Override .wp-core-ui .button */ + vertical-align: top; + } + + .community-events-form label, + #dashboard-widgets .community-events-cancel.button-link { + /* Same properties as the submit button for cross-browsers alignment. */ + font-size: 14px; + line-height: normal; + height: auto; + padding: 6px 0; + border: 1px solid transparent; + } + + .community-events .spinner { + margin-top: 7px; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Keep the close icon from overlapping the Welcome text. */ + .welcome-panel .welcome-panel-close { + overflow: hidden; + text-indent: 40px; + white-space: nowrap; + width: 20px; + height: 20px; + padding: 5px; + top: 5px; + right: 5px; + } + + /* Make the close icon larger for tappability. */ + .welcome-panel .welcome-panel-close:before { + font-size: 20px; + top: 5px; + left: -35px; + } +} + +@media screen and (min-width: 355px) { + .community-events .event-info { + display: table-row; + float: left; + max-width: 59%; + } + + .event-icon, + .event-icon[aria-hidden="true"] { + display: table-cell; + } + + .event-info-inner { + display: table-cell; + } + + .community-events .event-date-time { + float: right; + max-width: 39%; + } + + .community-events .event-date, + .community-events .event-time { + text-align: right; + } +} diff --git a/backend/wp-admin/css/dashboard.min.css b/backend/wp-admin/css/dashboard.min.css new file mode 100644 index 0000000..ba0b6b5 --- /dev/null +++ b/backend/wp-admin/css/dashboard.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#dashboard_quick_press .draft-title,#the-comment-list td.comment,.dashboard-comment-wrap{word-wrap:break-word}#wpbody-content #dashboard-widgets.columns-1 .postbox-container{width:100%}#wpbody-content #dashboard-widgets.columns-2 .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets.columns-2 #postbox-container-2,#wpbody-content #dashboard-widgets.columns-2 #postbox-container-3,#wpbody-content #dashboard-widgets.columns-2 #postbox-container-4{float:right;width:50.5%}#wpbody-content #dashboard-widgets.columns-3 .postbox-container{width:33.5%}#wpbody-content #dashboard-widgets.columns-3 #postbox-container-1{width:33%}#wpbody-content #dashboard-widgets.columns-3 #postbox-container-3,#wpbody-content #dashboard-widgets.columns-3 #postbox-container-4{float:right}#dashboard-widgets .postbox-container,#wpbody-content #dashboard-widgets.columns-4 .postbox-container{width:25%}#dashboard-widgets-wrap .columns-3 #postbox-container-4 .empty-container{border:none!important}.ie8 #wpbody-content #dashboard-widgets .postbox-container{width:49.5%}.ie8 #wpbody-content #dashboard-widgets #postbox-container-2,.ie8 #wpbody-content #dashboard-widgets #postbox-container-3,.ie8 #wpbody-content #dashboard-widgets #postbox-container-4{float:right;width:50.5%}.ie8 #dashboard-widgets #postbox-container-3 .empty-container,.ie8 #dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}#dashboard-widgets-wrap{overflow:hidden;margin:0 -8px}#dashboard-widgets .postbox .inside{margin-bottom:0}#dashboard-widgets .meta-box-sortables{margin:0 8px;min-height:100px}#the-comment-list td.comment p.comment-author{margin-top:0;margin-left:0}#the-comment-list p.comment-author img{float:left;margin-right:8px}#the-comment-list p.comment-author strong a{border:none}#the-comment-list td{vertical-align:top}#the-comment-list td.comment img{max-width:100%}.welcome-panel{position:relative;overflow:auto;margin:16px 0;padding:23px 10px 0;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff;font-size:13px;line-height:2.1em}#dashboard_right_now .sub,.community-events li:first-child,.community-events li~li,.community-events-footer{border-top:1px solid #eee}.welcome-panel h2{margin:0;font-size:21px;font-weight:400;line-height:1.2}.welcome-panel h3{margin:1.33em 0 0;font-size:16px}.welcome-panel li{font-size:14px}.welcome-panel p{color:#72777c}.welcome-panel a{text-decoration:none}.welcome-panel .about-description{font-size:16px;margin:0}.welcome-panel .welcome-panel-close{position:absolute;top:10px;right:10px;padding:10px 15px 10px 21px;font-size:13px;line-height:1.23076923;text-decoration:none}.welcome-panel .welcome-panel-close:before{position:absolute;top:8px;left:0;transition:all .1s ease-in-out}.wp-core-ui .welcome-panel .button.button-hero{margin:15px 13px 3px 0;padding:12px 36px;height:auto;line-height:1.4285714;white-space:normal}.welcome-panel-content{margin-left:13px;max-width:1500px}.welcome-panel .welcome-panel-column-container{clear:both;position:relative}.welcome-panel .welcome-panel-column{width:32%;min-width:200px;float:left}.ie8 .welcome-panel .welcome-panel-column{min-width:230px}.welcome-panel .welcome-panel-column:first-child{width:36%}.welcome-panel-column p.hide-if-no-customize{margin-top:10px}.welcome-panel-column p{margin-top:7px;color:#444}.welcome-panel .welcome-widgets-menus{line-height:16px}.welcome-panel .welcome-panel-column ul{margin:.8em 1em 1em 0}.welcome-panel .welcome-panel-column li{line-height:16px;list-style-type:none;padding:0 0 8px}.welcome-panel .welcome-icon{background:0 0!important}#dashboard_right_now li a:before,#dashboard_right_now li span:before,.welcome-panel .welcome-icon:before{color:#82878c;font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0 10px 0 0;position:relative;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;vertical-align:top}.welcome-panel .welcome-edit-page:before,.welcome-panel .welcome-write-blog:before{content:"\f119";top:-3px}.welcome-panel .welcome-add-page:before{content:"\f132";top:-1px}.welcome-panel .welcome-view-site:before{content:"\f115";top:-2px}.welcome-panel .welcome-widgets-menus:before{content:"\f116";top:-2px}.welcome-panel .welcome-comments:before{content:"\f117";top:-1px}.welcome-panel .welcome-learn-more:before{content:"\f118";top:-1px}#dashboard_right_now li a:before,#dashboard_right_now li>span:before{content:"\f159";padding:0 5px 0 0}#dashboard_right_now .page-count a:before,#dashboard_right_now .page-count span:before{content:"\f105"}#dashboard_right_now .post-count a:before,#dashboard_right_now .post-count span:before{content:"\f109"}#dashboard_right_now .comment-count a:before{content:"\f101"}#dashboard_right_now .comment-mod-count a:before{content:"\f125"}#dashboard_right_now .storage-count a:before{content:"\f104"}#dashboard_right_now .storage-count.warning a:before{content:"\f153"}.community-events-errors{margin:0}.community-events-loading{padding:10px 12px 8px}.community-events{margin-bottom:6px;padding:0 12px}.community-events .spinner{float:none;margin:5px 2px 0;vertical-align:top}.community-events [aria-hidden=true],.community-events-errors [aria-hidden=true],.community-events-errors[aria-hidden=true],.community-events-loading[aria-hidden=true],.community-events[aria-hidden=true]{display:none}.community-events .activity-block:first-child,.community-events h2{padding-top:12px;padding-bottom:10px}.community-events-form{margin:15px 0 5px}.community-events-form .regular-text{width:40%;height:29px;margin:0;vertical-align:top}.community-events li.event-none{border-left:4px solid #00a0d2}.community-events-form label{display:inline-block;vertical-align:top;line-height:28px;height:28px}.community-events .activity-block>p{margin-bottom:0;display:inline}.community-events-toggle-location{vertical-align:middle}#community-events-submit{margin-left:3px;margin-right:3px}#dashboard-widgets .community-events-cancel.button-link{vertical-align:top;line-height:26px;height:28px;text-decoration:underline}.community-events ul{background-color:#fafafa;padding-left:0;padding-right:0;padding-bottom:0}.community-events li{margin:0;padding:8px 12px;color:#72777c}.community-events .activity-block.last{border-bottom:1px solid #eee;padding-top:0;margin-top:-1px}.community-events .event-info{display:block}.event-icon{height:18px;padding-right:10px;width:18px;display:none}.event-icon:before{color:#82878C;font-size:18px}.event-meetup .event-icon:before{content:"\f484"}.event-wordcamp .event-icon:before{content:"\f486"}.community-events .event-title{font-weight:600;display:block}.community-events .event-date,.community-events .event-time{display:block}.community-events-footer{margin-top:0;margin-bottom:0;padding:12px;color:#ddd}#dashboard_primary .rss-widget span,#dashboard_primary .rss-widget span.rss-date,.rssSummary{color:#72777c}.community-events-footer .screen-reader-text{height:inherit;white-space:nowrap}#dashboard_primary .inside{margin:0;padding:0}#dashboard_primary .widget-loading{padding:12px 12px 0;margin-bottom:1em!important}#dashboard_primary .inside .notice,body #dashboard-widgets .postbox form .submit{margin:0}.dashboard-widget-control-form p{margin-top:0}.rssSummary{margin-top:4px}#dashboard_primary .rss-widget{font-size:13px;padding:0 12px}#dashboard_primary .rss-widget:last-child{border-bottom:none;padding-bottom:8px}#dashboard_primary .rss-widget a{font-weight:400}#dashboard_primary .rss-widget span.rss-date{margin-left:12px}#dashboard_primary .rss-widget ul li{padding:4px 0;margin:0}#dashboard_right_now ul{margin:0;display:inline-block;width:100%}#dashboard_right_now li{width:50%;float:left;margin-bottom:10px}#dashboard_right_now .inside{padding:0}#dashboard_right_now .main{padding:0 12px 11px}#dashboard_right_now .main p{margin:0}#dashboard_right_now #wp-version-message .button{float:right;position:relative;top:-5px;margin-left:5px}.mu-storage{overflow:hidden}#dashboard-widgets h3.mu-storage{margin:0 0 10px;padding:0;font-size:14px;font-weight:400}#dashboard_right_now .sub{color:#555d66;background:#f5f5f5;padding:10px 12px 6px}#dashboard_right_now .sub h3{color:#555}#dashboard_right_now .sub p{margin:0 0 1em}#dashboard_right_now .warning a:before,#dashboard_right_now .warning span:before{color:#d54e21}#dashboard_quick_press .drafts li time,#title-wrap #title-prompt-text,.textarea-wrap #content-prompt-text{color:#72777c}#dashboard_quick_press .inside{margin:0;padding:0}#dashboard_quick_press div.updated{margin-bottom:10px;border:1px solid #eee;border-width:1px 1px 1px 0}#dashboard_quick_press form{margin:12px}#dashboard_quick_press .drafts,#dashboard_quick_press .easy-blogging{padding:10px 0 0}input#save-post{float:left}form.initial-form.quickpress-open label.prompt{font-style:normal}form.initial-form.quickpress-open input#title{height:auto}#dashboard_quick_press input,#dashboard_quick_press textarea{box-sizing:border-box;margin:0}#dashboard_quick_press textarea{resize:vertical}#description-wrap{margin-top:12px}.input-text-wrap,.textarea-wrap{position:relative}.input-text-wrap .prompt,.textarea-wrap .prompt{position:absolute}.textarea-wrap #content-prompt-text{font-size:1.1em;padding:7px 8px}.textarea-wrap textarea#content{margin:0 0 8px;padding:6px 7px}#quick-press textarea#content{min-height:90px;max-height:1300px;resize:none}.js #dashboard_quick_press .drafts{border-top:1px solid #eee}#dashboard_quick_press .drafts abbr{border:none}#dashboard_quick_press .drafts .view-all{float:right;margin:0 12px 0 0}#dashboard_primary a.rsswidget{font-weight:400}#dashboard_quick_press .drafts ul{margin:0 12px}#dashboard_quick_press .drafts li{margin-bottom:1em}#dashboard_quick_press .drafts p{margin:0;word-wrap:break-word}#dashboard_quick_press .draft-title a,#dashboard_quick_press .draft-title time{margin:0 5px 0 0}#dashboard-widgets h3,#dashboard-widgets h4,#dashboard_quick_press .drafts h2{margin:0 12px 8px;padding:0;font-size:14px;font-weight:400;color:#23282d}#dashboard_quick_press .drafts h2{line-height:inherit}#dashboard-widgets .inside h3,#dashboard-widgets .inside h4{margin-left:0;margin-right:0}#dashboard_activity .comment-meta span.approve:before{content:"\f227";font:20px/.5 dashicons;margin-left:5px;vertical-align:middle;position:relative;top:-1px;margin-right:2px}#dashboard_activity .inside{margin:0;padding-bottom:0}#dashboard_activity .no-activity{overflow:hidden;padding:0 0 12px;text-align:center}#dashboard_activity .no-activity p{color:#72777c;font-size:16px}#dashboard_activity .no-activity .smiley{margin-top:0}#dashboard_activity .no-activity .smiley:before{content:"\f328";font:400 120px/1 dashicons;speak:none;display:block;margin:0 5px 0 0;padding:0;text-indent:0;text-align:center;position:relative;-webkit-font-smoothing:antialiased;text-decoration:none!important}#dashboard_activity .subsubsub{float:none;border-top:1px solid #eee;margin:0 -12px;padding:8px 12px 4px}#dashboard_activity .subsubsub a .count,#dashboard_activity .subsubsub a.current .count{color:#72777c}#future-posts ul,#published-posts ul{clear:both;margin-bottom:0}#future-posts li,#published-posts li{margin-bottom:8px}#future-posts ul span,#published-posts ul span{display:inline-block;margin-right:5px;min-width:150px;color:#72777c}.activity-block{border-bottom:1px solid #eee;margin:0 -12px;padding:8px 12px 4px}.activity-block:last-child{border-bottom:none}.activity-block .subsubsub li{color:#ddd}#activity-widget #the-comment-list div.undo,#activity-widget #the-comment-list tr.undo{background:0 0;padding:6px 0;margin-left:12px}#activity-widget #the-comment-list .comment-item{background:#fafafa;padding:12px;position:relative}#activity-widget #the-comment-list .avatar{position:absolute;top:12px}#activity-widget #the-comment-list .dashboard-comment-wrap{padding-left:63px}#activity-widget #the-comment-list .dashboard-comment-wrap blockquote{margin:1em 0}#activity-widget #the-comment-list .comment-item p.row-actions{margin:4px 0 0}#activity-widget #the-comment-list .comment-item:first-child{border-top:1px solid #eee}#activity-widget #the-comment-list .unapproved{background-color:#fef7f1}#activity-widget #the-comment-list .unapproved:before{content:"";display:block;position:absolute;left:0;top:0;bottom:0;background:#d54e21;width:4px}#activity-widget #the-comment-list .spam-undo-inside .avatar,#activity-widget #the-comment-list .trash-undo-inside .avatar{position:relative;top:0}#dashboard-widgets #dashboard_browser_nag.postbox .inside{margin:10px}.postbox .button-link .edit-box{display:none}.edit-box{opacity:0}.edit-box:focus,.hndle:hover .edit-box{opacity:1}#dashboard-widgets form .input-text-wrap input,#dashboard-widgets form .textarea-wrap textarea{width:100%}#dashboard-widgets .postbox form .submit{float:none;margin:.5em 0 0;padding:0;border:none}#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish{min-width:0}#dashboard-widgets .button-link,#dashboard-widgets a{text-decoration:none}#dashboard-widgets h2 a,#dashboard_browser_nag a{text-decoration:underline}#dashboard-widgets .hndle .postbox-title-action{float:right;line-height:1.2}#dashboard_plugins h5{font-size:14px}#latest-comments #the-comment-list{position:relative;margin:0 -12px}#activity-widget #the-comment-list .comment,#activity-widget #the-comment-list .pingback{box-shadow:inset 0 1px 0 rgba(0,0,0,.06)}#activity-widget .comments #the-comment-list .alt{background-color:transparent}#activity-widget #latest-comments #the-comment-list .comment-item{min-height:50px;margin:0;padding:12px}#latest-comments #the-comment-list .pingback{padding-left:12px!important}#latest-comments #the-comment-list .comment-item:first-child{border-top:none}#latest-comments #the-comment-list .comment-meta{line-height:1.5em;margin:0;color:#666}#latest-comments #the-comment-list .comment-meta cite{font-style:normal;font-weight:400}#latest-comments #the-comment-list .comment-item blockquote,#latest-comments #the-comment-list .comment-item blockquote p{margin:0;padding:0;display:inline}#latest-comments #the-comment-list .comment-item p.row-actions{margin:3px 0 0;padding:0;font-size:13px}#description-wrap label,#title-wrap label{cursor:text}#title-wrap #title{padding:2px 6px;font-size:1.3em;outline:0}#title-wrap #title-prompt-text{font-size:1.1em;padding:5px 8px}.rss-widget ul{margin:0;padding:0;list-style:none}a.rsswidget{font-size:13px;font-weight:600;line-height:1.4em}.rss-widget ul li{line-height:1.5em;margin-bottom:12px}.rss-widget span.rss-date{color:#72777c;font-size:13px;margin-left:3px}.rss-widget cite{display:block;text-align:right;margin:0 0 1em;padding:0}.rss-widget cite:before{content:"\2014"}#dashboard_browser_nag a.update-browser-link{font-size:1.2em;font-weight:600}#dashboard_browser_nag a{color:#fff}#dashboard_browser_nag p.browser-update-nag.has-browser-icon{padding-right:125px}#dashboard_browser_nag .browser-icon{margin-top:-35px}#dashboard_browser_nag.postbox.browser-insecure{background-color:#ac1b1b;border-color:#ac1b1b}#dashboard_browser_nag.postbox{background-color:#e29808;background-image:none;border-color:#edc048;color:#fff;box-shadow:none}#dashboard_browser_nag.postbox.browser-insecure h2{border-bottom-color:#cd5a5a;color:#fff}#dashboard_browser_nag.postbox h2{border-bottom-color:#f6e2ac;background:0 0;color:#fff;box-shadow:none}#dashboard_browser_nag h2.hndle{border:none;font-weight:600;font-size:20px;padding-top:10px}.postbox#dashboard_browser_nag p a.dismiss{font-size:14px}.postbox#dashboard_browser_nag a,.postbox#dashboard_browser_nag p,.postbox#dashboard_browser_nag p.browser-update-nag{font-size:16px}@media only screen and (max-width:799px){#wpbody-content #dashboard-widgets .postbox-container{width:100%}}@media only screen and (min-width:800px) and (max-width:1499px){#dashboard-widgets #postbox-container-3 .empty-container,#dashboard-widgets #postbox-container-4 .empty-container,#wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container{border:0;height:0;min-height:0}#wpbody-content #dashboard-widgets .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets #postbox-container-2,#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:right;width:50.5%}#dashboard-widgets #postbox-container-3 .empty-container:after,#dashboard-widgets #postbox-container-4 .empty-container:after{display:none}#wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container{width:100%}.index-php .columns-prefs,.index-php .screen-layout{display:block}.columns-prefs .columns-prefs-3,.columns-prefs .columns-prefs-4{display:none}.metabox-holder .postbox-container .empty-container:after{display:block}}@media only screen and (min-width:1500px) and (max-width:1800px){#wpbody-content #dashboard-widgets .postbox-container{width:33.5%}#wpbody-content #dashboard-widgets #postbox-container-1{width:33%}#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:right}#dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}#dashboard-widgets #postbox-container-4 .empty-container:after{display:none}.metabox-holder .postbox-container .empty-container:after{display:block}}@media screen and (max-width:870px){.welcome-panel .welcome-panel-column,.welcome-panel .welcome-panel-column:first-child{display:block;float:none;width:100%}.welcome-panel .welcome-panel-column li{display:inline-block;margin-right:13px}.welcome-panel .welcome-panel-column ul{margin:.4em 0 0}}@media screen and (max-width:782px){#dashboard_recent_comments #the-comment-list .comment-item .avatar{height:30px;width:30px;margin:4px 10px 5px 0}.community-events-toggle-location{height:38px;vertical-align:baseline}.community-events-form .regular-text{height:32px}#community-events-submit{margin-bottom:0;vertical-align:top}#dashboard-widgets .community-events-cancel.button-link,.community-events-form label{font-size:14px;line-height:normal;height:auto;padding:6px 0;border:1px solid transparent}.community-events .spinner{margin-top:7px}}@media screen and (max-width:600px){.welcome-panel .welcome-panel-close{overflow:hidden;text-indent:40px;white-space:nowrap;width:20px;height:20px;padding:5px;top:5px;right:5px}.welcome-panel .welcome-panel-close:before{font-size:20px;top:5px;left:-35px}}@media screen and (min-width:355px){.community-events .event-info{display:table-row;float:left;max-width:59%}.event-icon,.event-icon[aria-hidden=true],.event-info-inner{display:table-cell}.community-events .event-date-time{float:right;max-width:39%}.community-events .event-date,.community-events .event-time{text-align:right}} \ No newline at end of file diff --git a/backend/wp-admin/css/deprecated-media-rtl.css b/backend/wp-admin/css/deprecated-media-rtl.css new file mode 100644 index 0000000..c83d3b0 --- /dev/null +++ b/backend/wp-admin/css/deprecated-media-rtl.css @@ -0,0 +1,413 @@ +/* Styles for the media library iframe (not used on the Library screen) */ + +div#media-upload-header { + margin: 0; + padding: 5px 5px 0; + font-weight: 600; + position: relative; + border-bottom: 1px solid #ddd; + background: #f9f9f9; +} + +#sidemenu { + overflow: hidden; + float: none; + position: relative; + right: 0; + bottom: -1px; + margin: 0 5px; + padding-right: 10px; + list-style: none; + font-size: 12px; + font-weight: 400; +} + +#sidemenu a { + padding: 0 7px; + display: block; + float: right; + line-height: 28px; + border-top: 1px solid #f9f9f9; + border-bottom: 1px solid #ddd; + background-color: #f9f9f9; + text-decoration: none; + transition: none; +} + +#sidemenu li { + display: inline; + line-height: 200%; + list-style: none; + text-align: center; + white-space: nowrap; + margin: 0; + padding: 0; +} + +#sidemenu a.current { + font-weight: 400; + padding-right: 6px; + padding-left: 6px; + border: 1px solid #ddd; + border-bottom-color: #f1f1f1; + background-color: #f1f1f1; + color: #000; +} + +#media-upload:after { /* clearfix */ + content: ""; + display: table; + clear: both; +} + +#media-upload .slidetoggle { + border-top-color: #ddd; +} + +#media-upload input[type="radio"] { + padding: 0; +} + +.media-upload-form label.form-help, +td.help { + color: #72777c; +} + +form { + margin: 1em; +} + +#search-filter { + text-align: left; +} + +th { + position: relative; +} + +.media-upload-form label.form-help, td.help { + font-family: sans-serif; + font-style: italic; + font-weight: 400; +} + +.media-upload-form p.help { + margin: 0; + padding: 0; +} + +.media-upload-form fieldset { + width: 100%; + border: none; + text-align: justify; + margin: 0 0 1em 0; + padding: 0; +} + +/* specific to the image upload form */ + +.image-align-none-label { + background: url(../images/align-none.png) no-repeat center left; +} + +.image-align-left-label { + background: url(../images/align-left.png) no-repeat center left; +} + +.image-align-center-label { + background: url(../images/align-center.png) no-repeat center left; +} + +.image-align-right-label { + background: url(../images/align-right.png) no-repeat center left; +} + +tr.image-size td { + width: 460px; +} + +tr.image-size div.image-size-item { + margin: 0 0 5px; +} + +#library-form .progress, +#gallery-form .progress, +.insert-gallery, +.describe.startopen, +.describe.startclosed { + display: none; +} + +.media-item .thumbnail { + max-width: 128px; + max-height: 128px; +} + +thead.media-item-info tr { + background-color: transparent; +} + +.form-table thead.media-item-info { + border: 8px solid #fff; +} + +abbr.required, +span.required { + text-decoration: none; + border: none; +} + +.describe label { + display: inline; +} + +.describe td.error { + padding: 2px 8px; +} + +.describe td.A1 { + width: 132px; +} + +.describe input[type="text"], +.describe textarea { + width: 460px; + border-width: 1px; + border-style: solid; +} + +/* Specific to Uploader */ + +#media-upload p.ml-submit { + padding: 1em 0; +} + +#media-upload p.help, +#media-upload label.help { + font-family: sans-serif; + font-style: italic; + font-weight: 400; +} + +#media-upload .ui-sortable .media-item { + cursor: move; +} + +#media-upload tr.image-size { + margin-bottom: 1em; + height: 3em; +} + +#media-upload #filter { + width: 623px; +} + +#media-upload #filter .subsubsub { + margin: 8px 0; +} + +#filter .tablenav select { + border-style: solid; + border-width: 1px; + padding: 2px; + vertical-align: top; + width: auto; +} + +#media-upload .del-attachment { + display: none; + margin: 5px 0; +} + +.menu_order { + float: left; + font-size: 11px; + margin: 8px 10px 0; +} + +.menu_order_input { + border: 1px solid #ddd; + font-size: 10px; + padding: 1px; + width: 23px; +} + +.ui-sortable-helper { + background-color: #fff; + border: 1px solid #a0a5aa; + opacity: 0.6; + filter: alpha(opacity=60); +} + +#media-upload th.order-head { + width: 20%; + text-align: center; +} + +#media-upload th.actions-head { + width: 25%; + text-align: center; +} + +#media-upload a.wp-post-thumbnail { + margin: 0 20px; +} + +#media-upload .widefat { + border-style: solid solid none; +} + +.sorthelper { + height: 37px; + width: 623px; + display: block; +} + +#gallery-settings th.label { + width: 160px; +} + +#gallery-settings #basic th.label { + padding: 5px 0 5px 5px; +} + +#gallery-settings .title { + clear: both; + padding: 0 0 3px; + font-size: 1.6em; + border-bottom: 1px solid #ddd; +} + +h3.media-title { + font-size: 1.6em; +} + +h4.media-sub-title { + border-bottom: 1px solid #ddd; + font-size: 1.3em; + margin: 12px; + padding: 0 0 3px; +} + +#gallery-settings .title, +h3.media-title, +h4.media-sub-title { + font-family: Georgia,"Times New Roman",Times,serif; + font-weight: 400; + color: #5A5A5A; +} + +#gallery-settings .describe td { + vertical-align: middle; + height: 3em; +} + +#gallery-settings .describe th.label { + padding-top: .5em; + text-align: right; +} + +#gallery-settings .describe { + padding: 5px; + width: 100%; + clear: both; + cursor: default; + background: #fff; +} + +#gallery-settings .describe select { + width: 15em; +} + +#gallery-settings .describe select option, +#gallery-settings .describe td { + padding: 0; +} + +#gallery-settings label, +#gallery-settings legend { + font-size: 13px; + color: #444; + margin-left: 15px; +} + +#gallery-settings .align .field label { + margin: 0 3px 0 1em; +} + +#gallery-settings p.ml-submit { + border-top: 1px solid #ddd; +} + +#gallery-settings select#columns { + width: 6em; +} + +#sort-buttons { + font-size: 0.8em; + margin: 3px 0 -8px 25px; + text-align: left; + max-width: 625px; +} + +#sort-buttons a { + text-decoration: none; +} + +#sort-buttons #asc, +#sort-buttons #showall { + padding-right: 5px; +} + +#sort-buttons span { + margin-left: 25px; +} + +p.media-types { + margin: 0; + padding: 1em; +} + +p.media-types-required-info { + padding-top: 0; +} + +tr.not-image { + display: none; +} + +table.not-image tr.not-image { + display: table-row; +} + +table.not-image tr.image-only { + display: none; +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .image-align-none-label { + background-image: url(../images/align-none-2x.png?ver=20120916); + background-size: 21px 15px; + } + + .image-align-left-label { + background-image: url(../images/align-left-2x.png?ver=20120916); + background-size: 22px 15px; + } + + .image-align-center-label { + background-image: url(../images/align-center-2x.png?ver=20120916); + background-size: 21px 15px; + } + + .image-align-right-label { + background-image: url(../images/align-right-2x.png?ver=20120916); + background-size: 22px 15px; + } +} diff --git a/backend/wp-admin/css/deprecated-media-rtl.min.css b/backend/wp-admin/css/deprecated-media-rtl.min.css new file mode 100644 index 0000000..e8d5312 --- /dev/null +++ b/backend/wp-admin/css/deprecated-media-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#sidemenu,th{position:relative}#sidemenu a,#sort-buttons a{text-decoration:none}div#media-upload-header{margin:0;padding:5px 5px 0;font-weight:600;position:relative;border-bottom:1px solid #ddd;background:#f9f9f9}#sidemenu{overflow:hidden;float:none;right:0;bottom:-1px;margin:0 5px;padding-right:10px;list-style:none;font-size:12px;font-weight:400}#sidemenu a{padding:0 7px;display:block;float:right;line-height:28px;border-top:1px solid #f9f9f9;border-bottom:1px solid #ddd;background-color:#f9f9f9;transition:none}#sidemenu li{display:inline;line-height:200%;list-style:none;text-align:center;white-space:nowrap;margin:0;padding:0}#sidemenu a.current{font-weight:400;padding-right:6px;padding-left:6px;border:1px solid #ddd;border-bottom-color:#f1f1f1;background-color:#f1f1f1;color:#000}#media-upload:after{content:"";display:table;clear:both}#media-upload .slidetoggle{border-top-color:#ddd}#media-upload input[type=radio]{padding:0}.media-upload-form label.form-help,td.help{color:#72777c;font-family:sans-serif;font-style:italic;font-weight:400}form{margin:1em}#search-filter{text-align:left}.media-upload-form p.help{margin:0;padding:0}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em;padding:0}.image-align-none-label{background:url(../images/align-none.png) center left no-repeat}.image-align-left-label{background:url(../images/align-left.png) center left no-repeat}.image-align-center-label{background:url(../images/align-center.png) center left no-repeat}.image-align-right-label{background:url(../images/align-right.png) center left no-repeat}tr.image-size td{width:460px}tr.image-size div.image-size-item{margin:0 0 5px}#gallery-form .progress,#library-form .progress,.describe.startclosed,.describe.startopen,.insert-gallery{display:none}.media-item .thumbnail{max-width:128px;max-height:128px}thead.media-item-info tr{background-color:transparent}.form-table thead.media-item-info{border:8px solid #fff}abbr.required,span.required{text-decoration:none;border:none}.describe label{display:inline}.describe td.error{padding:2px 8px}.describe td.A1{width:132px}.describe input[type=text],.describe textarea{width:460px;border-width:1px;border-style:solid}#media-upload p.ml-submit{padding:1em 0}#media-upload label.help,#media-upload p.help{font-family:sans-serif;font-style:italic;font-weight:400}#media-upload .ui-sortable .media-item{cursor:move}#media-upload tr.image-size{margin-bottom:1em;height:3em}#media-upload #filter{width:623px}#media-upload #filter .subsubsub{margin:8px 0}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto}#media-upload .del-attachment{display:none;margin:5px 0}.menu_order{float:left;font-size:11px;margin:8px 10px 0}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px}.ui-sortable-helper{background-color:#fff;border:1px solid #a0a5aa;opacity:.6;filter:alpha(opacity=60)}#media-upload th.order-head{width:20%;text-align:center}#media-upload th.actions-head{width:25%;text-align:center}#media-upload a.wp-post-thumbnail{margin:0 20px}#media-upload .widefat{border-style:solid solid none}.sorthelper{height:37px;width:623px;display:block}#gallery-settings th.label{width:160px}#gallery-settings #basic th.label{padding:5px 0 5px 5px}#gallery-settings .title,h4.media-sub-title{border-bottom:1px solid #ddd;padding:0 0 3px}#gallery-settings .title{clear:both;font-size:1.6em}h3.media-title{font-size:1.6em}h4.media-sub-title{font-size:1.3em;margin:12px}#gallery-settings .title,h3.media-title,h4.media-sub-title{font-family:Georgia,"Times New Roman",Times,serif;font-weight:400;color:#5A5A5A}#gallery-settings .describe td{vertical-align:middle;height:3em}#gallery-settings .describe th.label{padding-top:.5em;text-align:right}#gallery-settings .describe{padding:5px;width:100%;clear:both;cursor:default;background:#fff}#gallery-settings .describe select{width:15em}#gallery-settings .describe select option,#gallery-settings .describe td{padding:0}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#444;margin-left:15px}#gallery-settings .align .field label{margin:0 3px 0 1em}#gallery-settings p.ml-submit{border-top:1px solid #ddd}#gallery-settings select#columns{width:6em}#sort-buttons{font-size:.8em;margin:3px 0 -8px 25px;text-align:left;max-width:625px}#sort-buttons #asc,#sort-buttons #showall{padding-right:5px}#sort-buttons span{margin-left:25px}p.media-types{margin:0;padding:1em}p.media-types-required-info{padding-top:0}tr.not-image{display:none}table.not-image tr.not-image{display:table-row}table.not-image tr.image-only{display:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.image-align-none-label{background-image:url(../images/align-none-2x.png?ver=20120916);background-size:21px 15px}.image-align-left-label{background-image:url(../images/align-left-2x.png?ver=20120916);background-size:22px 15px}.image-align-center-label{background-image:url(../images/align-center-2x.png?ver=20120916);background-size:21px 15px}.image-align-right-label{background-image:url(../images/align-right-2x.png?ver=20120916);background-size:22px 15px}} \ No newline at end of file diff --git a/backend/wp-admin/css/deprecated-media.css b/backend/wp-admin/css/deprecated-media.css new file mode 100644 index 0000000..01848f3 --- /dev/null +++ b/backend/wp-admin/css/deprecated-media.css @@ -0,0 +1,413 @@ +/* Styles for the media library iframe (not used on the Library screen) */ + +div#media-upload-header { + margin: 0; + padding: 5px 5px 0; + font-weight: 600; + position: relative; + border-bottom: 1px solid #ddd; + background: #f9f9f9; +} + +#sidemenu { + overflow: hidden; + float: none; + position: relative; + left: 0; + bottom: -1px; + margin: 0 5px; + padding-left: 10px; + list-style: none; + font-size: 12px; + font-weight: 400; +} + +#sidemenu a { + padding: 0 7px; + display: block; + float: left; + line-height: 28px; + border-top: 1px solid #f9f9f9; + border-bottom: 1px solid #ddd; + background-color: #f9f9f9; + text-decoration: none; + transition: none; +} + +#sidemenu li { + display: inline; + line-height: 200%; + list-style: none; + text-align: center; + white-space: nowrap; + margin: 0; + padding: 0; +} + +#sidemenu a.current { + font-weight: 400; + padding-left: 6px; + padding-right: 6px; + border: 1px solid #ddd; + border-bottom-color: #f1f1f1; + background-color: #f1f1f1; + color: #000; +} + +#media-upload:after { /* clearfix */ + content: ""; + display: table; + clear: both; +} + +#media-upload .slidetoggle { + border-top-color: #ddd; +} + +#media-upload input[type="radio"] { + padding: 0; +} + +.media-upload-form label.form-help, +td.help { + color: #72777c; +} + +form { + margin: 1em; +} + +#search-filter { + text-align: right; +} + +th { + position: relative; +} + +.media-upload-form label.form-help, td.help { + font-family: sans-serif; + font-style: italic; + font-weight: 400; +} + +.media-upload-form p.help { + margin: 0; + padding: 0; +} + +.media-upload-form fieldset { + width: 100%; + border: none; + text-align: justify; + margin: 0 0 1em 0; + padding: 0; +} + +/* specific to the image upload form */ + +.image-align-none-label { + background: url(../images/align-none.png) no-repeat center left; +} + +.image-align-left-label { + background: url(../images/align-left.png) no-repeat center left; +} + +.image-align-center-label { + background: url(../images/align-center.png) no-repeat center left; +} + +.image-align-right-label { + background: url(../images/align-right.png) no-repeat center left; +} + +tr.image-size td { + width: 460px; +} + +tr.image-size div.image-size-item { + margin: 0 0 5px; +} + +#library-form .progress, +#gallery-form .progress, +.insert-gallery, +.describe.startopen, +.describe.startclosed { + display: none; +} + +.media-item .thumbnail { + max-width: 128px; + max-height: 128px; +} + +thead.media-item-info tr { + background-color: transparent; +} + +.form-table thead.media-item-info { + border: 8px solid #fff; +} + +abbr.required, +span.required { + text-decoration: none; + border: none; +} + +.describe label { + display: inline; +} + +.describe td.error { + padding: 2px 8px; +} + +.describe td.A1 { + width: 132px; +} + +.describe input[type="text"], +.describe textarea { + width: 460px; + border-width: 1px; + border-style: solid; +} + +/* Specific to Uploader */ + +#media-upload p.ml-submit { + padding: 1em 0; +} + +#media-upload p.help, +#media-upload label.help { + font-family: sans-serif; + font-style: italic; + font-weight: 400; +} + +#media-upload .ui-sortable .media-item { + cursor: move; +} + +#media-upload tr.image-size { + margin-bottom: 1em; + height: 3em; +} + +#media-upload #filter { + width: 623px; +} + +#media-upload #filter .subsubsub { + margin: 8px 0; +} + +#filter .tablenav select { + border-style: solid; + border-width: 1px; + padding: 2px; + vertical-align: top; + width: auto; +} + +#media-upload .del-attachment { + display: none; + margin: 5px 0; +} + +.menu_order { + float: right; + font-size: 11px; + margin: 8px 10px 0; +} + +.menu_order_input { + border: 1px solid #ddd; + font-size: 10px; + padding: 1px; + width: 23px; +} + +.ui-sortable-helper { + background-color: #fff; + border: 1px solid #a0a5aa; + opacity: 0.6; + filter: alpha(opacity=60); +} + +#media-upload th.order-head { + width: 20%; + text-align: center; +} + +#media-upload th.actions-head { + width: 25%; + text-align: center; +} + +#media-upload a.wp-post-thumbnail { + margin: 0 20px; +} + +#media-upload .widefat { + border-style: solid solid none; +} + +.sorthelper { + height: 37px; + width: 623px; + display: block; +} + +#gallery-settings th.label { + width: 160px; +} + +#gallery-settings #basic th.label { + padding: 5px 5px 5px 0; +} + +#gallery-settings .title { + clear: both; + padding: 0 0 3px; + font-size: 1.6em; + border-bottom: 1px solid #ddd; +} + +h3.media-title { + font-size: 1.6em; +} + +h4.media-sub-title { + border-bottom: 1px solid #ddd; + font-size: 1.3em; + margin: 12px; + padding: 0 0 3px; +} + +#gallery-settings .title, +h3.media-title, +h4.media-sub-title { + font-family: Georgia,"Times New Roman",Times,serif; + font-weight: 400; + color: #5A5A5A; +} + +#gallery-settings .describe td { + vertical-align: middle; + height: 3em; +} + +#gallery-settings .describe th.label { + padding-top: .5em; + text-align: left; +} + +#gallery-settings .describe { + padding: 5px; + width: 100%; + clear: both; + cursor: default; + background: #fff; +} + +#gallery-settings .describe select { + width: 15em; +} + +#gallery-settings .describe select option, +#gallery-settings .describe td { + padding: 0; +} + +#gallery-settings label, +#gallery-settings legend { + font-size: 13px; + color: #444; + margin-right: 15px; +} + +#gallery-settings .align .field label { + margin: 0 1em 0 3px; +} + +#gallery-settings p.ml-submit { + border-top: 1px solid #ddd; +} + +#gallery-settings select#columns { + width: 6em; +} + +#sort-buttons { + font-size: 0.8em; + margin: 3px 25px -8px 0; + text-align: right; + max-width: 625px; +} + +#sort-buttons a { + text-decoration: none; +} + +#sort-buttons #asc, +#sort-buttons #showall { + padding-left: 5px; +} + +#sort-buttons span { + margin-right: 25px; +} + +p.media-types { + margin: 0; + padding: 1em; +} + +p.media-types-required-info { + padding-top: 0; +} + +tr.not-image { + display: none; +} + +table.not-image tr.not-image { + display: table-row; +} + +table.not-image tr.image-only { + display: none; +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .image-align-none-label { + background-image: url(../images/align-none-2x.png?ver=20120916); + background-size: 21px 15px; + } + + .image-align-left-label { + background-image: url(../images/align-left-2x.png?ver=20120916); + background-size: 22px 15px; + } + + .image-align-center-label { + background-image: url(../images/align-center-2x.png?ver=20120916); + background-size: 21px 15px; + } + + .image-align-right-label { + background-image: url(../images/align-right-2x.png?ver=20120916); + background-size: 22px 15px; + } +} diff --git a/backend/wp-admin/css/deprecated-media.min.css b/backend/wp-admin/css/deprecated-media.min.css new file mode 100644 index 0000000..a22cb40 --- /dev/null +++ b/backend/wp-admin/css/deprecated-media.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#sidemenu,th{position:relative}#sidemenu a,#sort-buttons a{text-decoration:none}div#media-upload-header{margin:0;padding:5px 5px 0;font-weight:600;position:relative;border-bottom:1px solid #ddd;background:#f9f9f9}#sidemenu{overflow:hidden;float:none;left:0;bottom:-1px;margin:0 5px;padding-left:10px;list-style:none;font-size:12px;font-weight:400}#sidemenu a{padding:0 7px;display:block;float:left;line-height:28px;border-top:1px solid #f9f9f9;border-bottom:1px solid #ddd;background-color:#f9f9f9;transition:none}#sidemenu li{display:inline;line-height:200%;list-style:none;text-align:center;white-space:nowrap;margin:0;padding:0}#sidemenu a.current{font-weight:400;padding-left:6px;padding-right:6px;border:1px solid #ddd;border-bottom-color:#f1f1f1;background-color:#f1f1f1;color:#000}#media-upload:after{content:"";display:table;clear:both}#media-upload .slidetoggle{border-top-color:#ddd}#media-upload input[type=radio]{padding:0}.media-upload-form label.form-help,td.help{color:#72777c;font-family:sans-serif;font-style:italic;font-weight:400}form{margin:1em}#search-filter{text-align:right}.media-upload-form p.help{margin:0;padding:0}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em;padding:0}.image-align-none-label{background:url(../images/align-none.png) center left no-repeat}.image-align-left-label{background:url(../images/align-left.png) center left no-repeat}.image-align-center-label{background:url(../images/align-center.png) center left no-repeat}.image-align-right-label{background:url(../images/align-right.png) center left no-repeat}tr.image-size td{width:460px}tr.image-size div.image-size-item{margin:0 0 5px}#gallery-form .progress,#library-form .progress,.describe.startclosed,.describe.startopen,.insert-gallery{display:none}.media-item .thumbnail{max-width:128px;max-height:128px}thead.media-item-info tr{background-color:transparent}.form-table thead.media-item-info{border:8px solid #fff}abbr.required,span.required{text-decoration:none;border:none}.describe label{display:inline}.describe td.error{padding:2px 8px}.describe td.A1{width:132px}.describe input[type=text],.describe textarea{width:460px;border-width:1px;border-style:solid}#media-upload p.ml-submit{padding:1em 0}#media-upload label.help,#media-upload p.help{font-family:sans-serif;font-style:italic;font-weight:400}#media-upload .ui-sortable .media-item{cursor:move}#media-upload tr.image-size{margin-bottom:1em;height:3em}#media-upload #filter{width:623px}#media-upload #filter .subsubsub{margin:8px 0}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto}#media-upload .del-attachment{display:none;margin:5px 0}.menu_order{float:right;font-size:11px;margin:8px 10px 0}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px}.ui-sortable-helper{background-color:#fff;border:1px solid #a0a5aa;opacity:.6;filter:alpha(opacity=60)}#media-upload th.order-head{width:20%;text-align:center}#media-upload th.actions-head{width:25%;text-align:center}#media-upload a.wp-post-thumbnail{margin:0 20px}#media-upload .widefat{border-style:solid solid none}.sorthelper{height:37px;width:623px;display:block}#gallery-settings th.label{width:160px}#gallery-settings #basic th.label{padding:5px 5px 5px 0}#gallery-settings .title,h4.media-sub-title{border-bottom:1px solid #ddd;padding:0 0 3px}#gallery-settings .title{clear:both;font-size:1.6em}h3.media-title{font-size:1.6em}h4.media-sub-title{font-size:1.3em;margin:12px}#gallery-settings .title,h3.media-title,h4.media-sub-title{font-family:Georgia,"Times New Roman",Times,serif;font-weight:400;color:#5A5A5A}#gallery-settings .describe td{vertical-align:middle;height:3em}#gallery-settings .describe th.label{padding-top:.5em;text-align:left}#gallery-settings .describe{padding:5px;width:100%;clear:both;cursor:default;background:#fff}#gallery-settings .describe select{width:15em}#gallery-settings .describe select option,#gallery-settings .describe td{padding:0}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#444;margin-right:15px}#gallery-settings .align .field label{margin:0 1em 0 3px}#gallery-settings p.ml-submit{border-top:1px solid #ddd}#gallery-settings select#columns{width:6em}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px}#sort-buttons span{margin-right:25px}p.media-types{margin:0;padding:1em}p.media-types-required-info{padding-top:0}tr.not-image{display:none}table.not-image tr.not-image{display:table-row}table.not-image tr.image-only{display:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.image-align-none-label{background-image:url(../images/align-none-2x.png?ver=20120916);background-size:21px 15px}.image-align-left-label{background-image:url(../images/align-left-2x.png?ver=20120916);background-size:22px 15px}.image-align-center-label{background-image:url(../images/align-center-2x.png?ver=20120916);background-size:21px 15px}.image-align-right-label{background-image:url(../images/align-right-2x.png?ver=20120916);background-size:22px 15px}} \ No newline at end of file diff --git a/backend/wp-admin/css/edit-rtl.css b/backend/wp-admin/css/edit-rtl.css new file mode 100644 index 0000000..793d6d4 --- /dev/null +++ b/backend/wp-admin/css/edit-rtl.css @@ -0,0 +1,1675 @@ +#poststuff { + padding-top: 10px; + min-width: 763px; +} + +#poststuff #post-body { + padding: 0; +} + +#poststuff .postbox-container { + width: 100%; +} + +#poststuff #post-body.columns-2 { + margin-left: 300px; +} + +/*------------------------------------------------------------------------------ + 11.0 - Write/Edit Post Screen +------------------------------------------------------------------------------*/ + +#show-comments { + overflow: hidden; +} + +#save-action .spinner, +#show-comments a { + float: right; +} + +#show-comments .spinner { + float: none; + margin-top: 0; +} + +#lost-connection-notice .spinner { + visibility: visible; + float: right; + margin: 0 0 0 5px; +} + +#titlediv { + position: relative; +} + +#titlediv label { + cursor: text; +} + +#titlediv div.inside { + margin: 0; +} + +#poststuff #titlewrap { + border: 0; + padding: 0; +} + +#titlediv #title { + padding: 3px 8px; + font-size: 1.7em; + line-height: 100%; + height: 1.7em; + width: 100%; + outline: none; + margin: 0 0 3px; + background-color: #fff; +} + +#titlediv #title-prompt-text { + color: #72777c; + position: absolute; + font-size: 1.7em; + padding: 11px 10px; +} + +input#link_description, +input#link_url { + width: 98%; +} + +#pending { + background: 100% none; + border: 0 none; + padding: 0; + font-size: 11px; + margin-top: -1px; +} + +#edit-slug-box, +#comment-link-box { + line-height: 24px; + min-height: 25px; /* Yes, line-height + 1 */ + margin-top: 5px; + padding: 0 10px; + color: #666; +} + +#edit-slug-box .cancel { + margin-left: 10px; + padding: 0; + font-size: 11px; +} + +#comment-link-box { + margin: 5px 0; + padding: 0 5px; +} + +#editable-post-name-full { + display: none; +} + +#editable-post-name { + font-weight: 600; +} + +#editable-post-name input { + font-size: 13px; + font-weight: 400; + height: 24px; + margin: 0; + width: 16em; +} + +.postarea h3 label { + float: right; +} + +body.post-new-php .submitbox .submitdelete { + display: none; +} + +.submitbox .submit a:hover { + text-decoration: underline; +} + +.submitbox .submit input { + margin-bottom: 8px; + margin-left: 4px; + padding: 6px; +} + +#post-status-select { + margin-top: 3px; +} + +/* Post Screen */ +#post-body #normal-sortables { + min-height: 50px; +} + +.postbox { + position: relative; + min-width: 255px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; +} + +#trackback_url { + width: 99%; +} + +#normal-sortables .postbox .submit { + background: transparent none; + border: 0 none; + float: left; + padding: 0 12px; + margin:0; +} + +.category-add input[type="text"], +.category-add select { + width: 100%; + max-width: 260px; + vertical-align: baseline; +} + +#side-sortables .category-add input[type="text"], +#side-sortables .category-add select { + margin: 0 0 1em; +} + +ul.category-tabs li, +#side-sortables .add-menu-item-tabs li, +.wp-tab-bar li { + display: inline; + line-height: 1.35em; +} + +.no-js .category-tabs li.hide-if-no-js { + display: none; +} + +.category-tabs a, +#side-sortables .add-menu-item-tabs a, +.wp-tab-bar a { + text-decoration: none; +} + +/* @todo: do these really need to be so specific? */ +#side-sortables .category-tabs .tabs a, +#side-sortables .add-menu-item-tabs .tabs a, +.wp-tab-bar .wp-tab-active a, +#post-body ul.category-tabs li.tabs a, +#post-body ul.add-menu-item-tabs li.tabs a { + color: #32373c; +} + +.category-tabs { + margin: 8px 0 5px; +} + +/* Back-compat for pre-4.4 */ +#category-adder h4 { + margin: 0; +} + +.taxonomy-add-new { + display: inline-block; + margin: 10px 0; + font-weight: 600; +} + +#side-sortables .add-menu-item-tabs, +.wp-tab-bar { + margin-bottom: 3px; +} + +#normal-sortables .postbox #replyrow .submit { + float: none; + margin: 0; + padding: 5px 7px 10px; + overflow: hidden; +} + +#side-sortables .submitbox .submit input, +#side-sortables .submitbox .submit .preview, +#side-sortables .submitbox .submit a.preview:hover { + border: 0 none; +} + +/* @todo: make this a more generic class */ +ul.category-tabs, +ul.add-menu-item-tabs, +ul.wp-tab-bar { + margin-top: 12px; +} + +ul.category-tabs li, +ul.add-menu-item-tabs li { + border: solid 1px transparent; + position: relative; +} + +ul.category-tabs li.tabs, +ul.add-menu-item-tabs li.tabs, +.wp-tab-active { + border: 1px solid #ddd; + border-bottom-color: #fdfdfd; + background-color: #fdfdfd; +} + +ul.category-tabs li, +ul.add-menu-item-tabs li, +ul.wp-tab-bar li { + padding: 3px 5px 6px; +} + +#set-post-thumbnail { + display: inline-block; + max-width: 100%; +} + +#postimagediv .inside img { + max-width: 100%; + height: auto; + width: auto; + vertical-align: top; + background-image: linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 100% 0, 10px 10px; + background-size: 20px 20px; +} + +form#tags-filter { + position: relative; +} + +/* Global classes */ +.wp-hidden-children .wp-hidden-child, +.ui-tabs-hide { + display: none; +} + +#post-body .tagsdiv #newtag { + margin-left: 5px; + width: 16em; +} + +#side-sortables input#post_password { + width: 94% +} + +#side-sortables .tagsdiv #newtag { + width: 68%; +} + +#post-status-info { + width: 100%; + border-spacing: 0; + border: 1px solid #e5e5e5; + border-top: none; + background-color: #f7f7f7; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + z-index: 999; +} + +#post-status-info td { + font-size: 12px; +} + +.autosave-info { + padding: 2px 10px; + text-align: left; +} + +#editorcontent #post-status-info { + border: none; +} + +#content-resize-handle { + background: transparent url(../images/resize.gif) no-repeat scroll left bottom; + width: 12px; + cursor: row-resize; +} + +/*rtl:ignore*/ +.rtl #content-resize-handle { + background-image: url(../images/resize-rtl.gif); + background-position: left bottom; +} + +.wp-editor-expand #content-resize-handle { + display: none; +} + +#postdivrich #content { + resize: none; +} + +#wp-word-count { + display: block; + padding: 2px 10px; +} + +#wp-content-editor-container { + position: relative; +} + +.wp-editor-expand #wp-content-editor-tools { + z-index: 1000; + border-bottom: 1px solid #e5e5e5; +} + +.wp-editor-expand #wp-content-editor-container { + box-shadow: none; + margin-top: -1px; +} + +.wp-editor-expand #wp-content-editor-container { + border-bottom: 0 none; +} + +.wp-editor-expand div.mce-statusbar { + z-index: 1; +} + +.wp-editor-expand #post-status-info { + border-top: 1px solid #e5e5e5; +} + +.wp-editor-expand div.mce-toolbar-grp { + z-index: 999; +} + +/* TinyMCE native fullscreen mode override */ +.mce-fullscreen #wp-content-wrap .mce-menubar, +.mce-fullscreen #wp-content-wrap .mce-toolbar-grp, +.mce-fullscreen #wp-content-wrap .mce-edit-area, +.mce-fullscreen #wp-content-wrap .mce-statusbar { + position: static !important; + width: auto !important; + padding: 0 !important; +} + +.mce-fullscreen #wp-content-wrap .mce-statusbar { + visibility: visible !important; +} + +.mce-fullscreen #wp-content-wrap .mce-tinymce .mce-wp-dfw { + display: none; +} + +.post-php.mce-fullscreen #wpadminbar, +.mce-fullscreen #wp-content-wrap .mce-wp-dfw { + display: none; +} +/* End TinyMCE native fullscreen mode override */ + +#wp-content-editor-tools { + background-color: #f1f1f1; + padding-top: 20px; +} + +#poststuff #post-body.columns-2 #side-sortables { + width: 280px; +} + +#timestampdiv select { + height: 21px; + line-height: 14px; + padding: 0; + vertical-align: top; + font-size: 12px; +} + +#aa, #jj, #hh, #mn { + padding: 1px; + font-size: 12px; +} + +#jj, #hh, #mn { + width: 2em; +} + +#aa { + width: 3.4em; +} + +.curtime #timestamp { + padding: 2px 0 1px 0; + display: inline !important; + height: auto !important; +} + +#post-body .misc-pub-post-status:before, +#post-body #visibility:before, +.curtime #timestamp:before, +#post-body .misc-pub-revisions:before, +span.wp-media-buttons-icon:before { + color: #82878c; +} + +#post-body .misc-pub-post-status:before, +#post-body #visibility:before, +.curtime #timestamp:before, +#post-body .misc-pub-revisions:before { + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + margin-right: -1px; + padding-left: 3px; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#post-body .misc-pub-post-status:before { + content: "\f173"; +} + +#post-body #visibility:before { + content: "\f177"; +} + +.curtime #timestamp:before { + content: "\f145"; + position: relative; + top: -1px; +} + +#post-body .misc-pub-revisions:before { + content: "\f321"; +} + +#timestampdiv { + padding-top: 5px; + line-height: 23px; +} + +#timestampdiv p { + margin: 8px 0 6px; +} + +#timestampdiv input { + border-width: 1px; + border-style: solid; +} + +.notification-dialog { + position: fixed; + top: 30%; + max-height: 70%; + right: 50%; + width: 450px; + margin-right: -225px; + background: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + line-height: 1.5; + z-index: 1000005; + overflow-y: auto; +} + +.notification-dialog-background { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 1000000; +} + +#post-lock-dialog .post-locked-message, +#post-lock-dialog .post-taken-over { + margin: 25px; +} + +#post-lock-dialog .post-locked-message a.button, +#file-editor-warning .button { + margin-left: 10px; +} + +#post-lock-dialog .post-locked-avatar { + float: right; + margin: 0 0 20px 20px; +} + +#post-lock-dialog .wp-tab-first { + outline: 0; +} + +#post-lock-dialog .locked-saving img { + float: right; + margin-left: 3px; +} + +#post-lock-dialog.saving .locked-saving, +#post-lock-dialog.saved .locked-saved { + display: inline; +} + +#excerpt { + display: block; + margin: 12px 0 0; + height: 4em; + width: 100%; +} + +.tagchecklist { + margin-right: 14px; + font-size: 12px; + overflow: auto; +} + +.tagchecklist br { + display: none; +} + +.tagchecklist strong { + margin-right: -8px; + position: absolute; +} + +.tagchecklist > li { + float: right; + margin-left: 25px; + font-size: 13px; + line-height: 1.8em; + cursor: default; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; +} + +.tagchecklist .ntdelbutton { + position: absolute; + width: 24px; + height: 24px; + border: none; + margin: 0 -19px 0 0; + padding: 0; + background: none; + cursor: pointer; + text-indent: 0; +} + +#poststuff h3.hndle, /* Back-compat for pre-4.4 */ +#poststuff .stuffbox > h3, /* Back-compat for pre-4.4 */ +#poststuff h2 { + font-size: 14px; + padding: 8px 12px; + margin: 0; + line-height: 1.4; +} + +#poststuff .inside { + margin: 6px 0 0 0; +} + +#poststuff .inside #parent_id, +#poststuff .inside #page_template { + max-width: 100%; +} + +.ie8 #poststuff .inside #parent_id, +.ie8 #poststuff .inside #page_template { + width: 250px; +} + +.post-attributes-label-wrapper { + margin-bottom: 0.5em; +} + +.post-attributes-label { + vertical-align: baseline; + font-weight: 600; +} + +#post-visibility-select { + line-height: 1.5em; + margin-top: 3px; +} + +#linksubmitdiv .inside, /* Old Link Manager back-compat. */ +#poststuff #submitdiv .inside { + margin: 0; + padding: 0; +} + +#post-body-content, +.edit-form-section { + margin-bottom: 20px; +} + +/* Suggested text for privacy policy */ +.wp-privacy-policy-guide { + max-width: 1000px; +} + +.privacy-text-box { + width: calc(100% - 260px); +} + +.privacy-text-box-toc { + float: left; + width: 250px; + background-color: #fff; +} + +.privacy-text-box-toc p { + margin: 0; + padding: 0.7em 1em; + border-bottom: 1px solid #eee; +} + +.privacy-text-box-toc ol { + margin-right: 2em; +} + +.wp-privacy-policy-guide h3 { + font-size: 1.2em; + margin: 1em 0 0.5em; +} + +.privacy-text-section .privacy-text-copy { + float: left; +} + +.privacy-text-section { + position: relative; + border-top: 1px solid #e3e3e3; +} + +.privacy-text-box-head, +.privacy-text-section.text-removed { + padding-bottom: 12px; +} + +.text-removed .policy-text { + font-style: italic; + color: #666; + font-weight: 600; +} + +.privacy-text-actions { + height: 32px; + line-height: 32px; + padding-bottom: 6px; +} + +.wp-privacy-policy-guide .policy-text h2 { + margin: 1.2em 0 1em; + padding: 0; +} + +.suggested-policy-content { + font-style: italic; +} + +.privacy-text-section a.return-to-top { + float: left; + margin-left: -250px; + margin-top: 6px; +} + +.hide-privacy-policy-tutorial .privacy-policy-tutorial { + visibility: hidden; +} + +.wp-suggested-text p { + font-style: italic; +} + +.wp-suggested-text p.privacy-policy-tutorial { + font-style: normal; +} + +.notice.wp-pp-notice { + margin: 15px 0 3px; +} + +/*------------------------------------------------------------------------------ + 11.1 - Custom Fields +------------------------------------------------------------------------------*/ + +#postcustomstuff thead th { + padding: 5px 8px 8px; + background-color: #f1f1f1; +} + +#postcustom #postcustomstuff .submit { + border: 0 none; + float: none; + padding: 0 8px 8px; +} + +#side-sortables #postcustom #postcustomstuff .submit { + margin: 0; + padding: 0; +} + +#side-sortables #postcustom #postcustomstuff #the-list textarea { + height: 85px; +} + +#side-sortables #postcustom #postcustomstuff td.left input, +#side-sortables #postcustom #postcustomstuff td.left select, +#side-sortables #postcustomstuff #newmetaleft a { + margin: 3px 3px 0; +} + +#postcustomstuff table { + margin: 0; + width: 100%; + border: 1px solid #ddd; + border-spacing: 0; + background-color: #f9f9f9; +} + +#postcustomstuff tr { + vertical-align: top; +} + +#postcustomstuff table input, +#postcustomstuff table select, +#postcustomstuff table textarea { + width: 96%; + margin: 8px; +} + +#side-sortables #postcustomstuff table input, +#side-sortables #postcustomstuff table select, +#side-sortables #postcustomstuff table textarea { + margin: 3px; +} + +#postcustomstuff th.left, +#postcustomstuff td.left { + width: 38%; +} + +#postcustomstuff .submit input { + margin: 0; + width: auto; +} + +#postcustomstuff #newmetaleft a { + display: inline-block; + margin: 0 8px 8px; + text-decoration: none; +} + +.no-js #postcustomstuff #enternew { + display: none; +} + +#post-body-content .compat-attachment-fields { + margin-bottom: 20px; +} + +.compat-attachment-fields th { + padding-top: 5px; + padding-left: 10px; +} + +/*------------------------------------------------------------------------------ + 11.3 - Featured Images +------------------------------------------------------------------------------*/ + +#select-featured-image { + padding: 4px 0; + overflow: hidden; +} + +#select-featured-image img { + max-width: 100%; + height: auto; + margin-bottom: 10px; +} + +#select-featured-image a { + float: right; + clear: both; +} + +#select-featured-image .remove { + display: none; + margin-top: 10px; +} + +.js #select-featured-image.has-featured-image .remove { + display: inline-block; +} + +.no-js #select-featured-image .choose { + display: none; +} + +/*------------------------------------------------------------------------------ + 11.4 - Post formats +------------------------------------------------------------------------------*/ + +.post-state-format { + overflow: hidden; + display: inline-block; + vertical-align: middle; + height: 20px; + width: 20px; + margin-left: 5px; + margin-top: -4px; +} + +.post-state-format:before { + display: block; + height: 20px; + width: 20px; + font: normal 20px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.post-state-format:before, +.post-format-icon:before { + color: #ddd; + transition: all .1s ease-in-out; +} + +a.post-state-format:hover:before, +a.post-format-icon:hover:before { + color: #00a0d2; +} + +#post-formats-select { + line-height: 2em; +} + +#post-formats-select .post-format-icon:before { + top: 5px; +} + +input.post-format { + margin-top: 1px; +} + +label.post-format-icon { + margin-right: 0px; + padding: 2px 0px 2px 0; +} + +.post-format-icon:before { + position: relative; + display: inline-block; + margin-left: 7px; + font: normal 20px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.post-state-format.post-format-standard:before, +.post-format-icon.post-format-standard:before, +a.post-state-format.format-standard:before { + content: "\f109"; +} + +.post-state-format.post-format-image:before, +.post-format-icon.post-format-image:before, +a.post-state-format.format-image:before { + content: "\f128"; +} + +.post-state-format.post-format-gallery:before, +.post-format-icon.post-format-gallery:before, +a.post-state-format.format-gallery:before { + content: "\f161"; +} + +.post-state-format.post-format-audio:before, +.post-format-icon.post-format-audio:before, +a.post-state-format.format-audio:before { + content: "\f127"; +} + +.post-state-format.post-format-video:before, +.post-format-icon.post-format-video:before, +a.post-state-format.format-video:before { + content: "\f126"; +} + +.post-state-format.post-format-chat:before, +.post-format-icon.post-format-chat:before, +a.post-state-format.format-chat:before { + content: "\f125"; +} + +.post-state-format.post-format-status:before, +.post-format-icon.post-format-status:before, +a.post-state-format.format-status:before { + content: "\f130"; +} + +.post-state-format.post-format-aside:before, +.post-format-icon.post-format-aside:before, +a.post-state-format.format-aside:before { + content: "\f123"; +} + +.post-state-format.post-format-quote:before, +.post-format-icon.post-format-quote:before, +a.post-state-format.format-quote:before { + content: "\f122"; +} + +.post-state-format.post-format-link:before, +.post-format-icon.post-format-link:before, +a.post-state-format.format-link:before { + content: "\f103"; +} + +/*------------------------------------------------------------------------------ + 12.0 - Categories +------------------------------------------------------------------------------*/ + +.category-adder { + margin-right: 120px; + padding: 4px 0; +} + +.category-adder h4 { + margin: 0 0 8px; +} + +#side-sortables .category-adder { + margin: 0; +} + +.wp-tab-panel, +.categorydiv div.tabs-panel, +.customlinkdiv div.tabs-panel, +.posttypediv div.tabs-panel, +.taxonomydiv div.tabs-panel { + min-height: 42px; + max-height: 200px; + overflow: auto; + padding: 0 0.9em; + border: solid 1px #ddd; + background-color: #fdfdfd; +} + +div.tabs-panel-active { + display:block; +} + +div.tabs-panel-inactive { + display:none; +} + +#front-page-warning, +#front-static-pages ul, +ul.export-filters, +.inline-editor ul.cat-checklist ul, +.categorydiv ul.categorychecklist ul, +.customlinkdiv ul.categorychecklist ul, +.posttypediv ul.categorychecklist ul, +.taxonomydiv ul.categorychecklist ul { + margin-right: 18px; +} + +ul.categorychecklist li { + margin: 0; + padding: 0; + line-height: 22px; + word-wrap: break-word; +} + +.categorydiv .tabs-panel, +.customlinkdiv .tabs-panel, +.posttypediv .tabs-panel, +.taxonomydiv .tabs-panel { + border-width: 3px; + border-style: solid; +} + +.form-wrap label { + display: block; + padding: 2px 0; +} + +.form-field input[type="text"], +.form-field input[type="password"], +.form-field input[type="email"], +.form-field input[type="number"], +.form-field input[type="search"], +.form-field input[type="tel"], +.form-field input[type="url"], +.form-field textarea { + border-style: solid; + border-width: 1px; + width: 95%; +} + +p.description, +.form-wrap p { + margin: 2px 0 5px; + color: #666; +} + +p.help, +p.description, +span.description, +.form-wrap p { + font-size: 13px; + font-style: italic; +} + +.form-wrap .form-field { + margin: 1em 0; + padding: 0; +} + +.form-wrap .form-field #parent { + max-width: 100%; +} + +.col-wrap h2 { + margin: 12px 0; + font-size: 1.1em; +} + +.col-wrap p.submit { + margin-top: -10px; +} + +.edit-term-notes { + margin-top: 2em; +} + +/*------------------------------------------------------------------------------ + 13.0 - Tags +------------------------------------------------------------------------------*/ + +#poststuff .tagsdiv .howto { + margin: 0 0 6px 0; +} + +.ajaxtag .newtag { + position: relative; +} + +.tagsdiv .newtag { + width: 180px; +} + +.tagsdiv .the-tags { + display: block; + height: 60px; + margin: 0 auto; + overflow: auto; + width: 260px; +} + +#post-body-content .tagsdiv .the-tags { + margin: 0 5px; +} + +p.popular-tags { + border: none; + line-height: 2em; + padding: 8px 12px 12px; + text-align: justify; +} + +p.popular-tags a { + padding: 0 3px; +} + +.tagcloud { + width: 97%; + margin: 0 0 40px; + text-align: justify; +} + +.tagcloud h2 { + margin: 2px 0 12px; +} + +.the-tagcloud ul { + margin: 0; +} + +.the-tagcloud ul li { + display: inline-block; +} + +/* Suggest.js autocomplete, no more used by core. */ +.ac_results { + display: none; + margin: -1px 0 0; + padding: 0; + list-style: none; + position: absolute; + z-index: 10000; + border: 1px solid #5b9dd9; + background-color: #fff; +} + +.wp-customizer .ac_results { + z-index: 500000; +} + +.ac_results li { + margin: 0; + padding: 5px 10px; + white-space: nowrap; + text-align: right; +} + +.ac_results .ac_over, +.ac_over .ac_match { + background-color: #0073aa; + color: #fff; + cursor: pointer; +} + +.ac_match { + text-decoration: underline; +} + +#edittag { + max-width: 800px; +} + +.edit-tag-actions { + margin-top: 20px; + overflow: hidden; + padding: 10px; + margin-left: 10px; +} + +/* Comments */ + +.comment-php .wp-editor-area { + height: 200px; +} + +.comment-ays th, +.comment-ays td { + padding: 10px 15px; +} + +.comment-ays .comment-content ul { + list-style: initial; + margin-right: 2em; +} + +.comment-ays .comment-content a[href]:after { + content: '(' attr( href ) ')'; + display: inline-block; + padding: 0 4px; + color: #72777C; + font-size: 13px; + word-break: break-all; +} + +.comment-ays .comment-content p.edit-comment { + margin-top: 10px; +} + +.comment-ays .comment-content p.edit-comment a[href]:after { + content: ''; + padding: 0; +} + +.comment-ays-submit .button-cancel { + margin-right: 1em; +} + +.trash-undo-inside, +.spam-undo-inside { + margin: 1px 0 1px 8px; + line-height: 16px; +} + +.spam-undo-inside .avatar, +.trash-undo-inside .avatar { + height: 20px; + width: 20px; + margin-left: 8px; + vertical-align: middle; +} + +.stuffbox .editcomment { + clear: none; +} + +#comment-status-radio p { + margin: 3px 0 5px; +} + +#comment-status-radio input { + margin: 2px 0 5px 3px; + vertical-align: middle; +} + +#comment-status-radio label { + padding: 5px 0; +} + +/* links tables */ +table.links-table { + width: 100%; + border-spacing: 0; +} + +.links-table th { + font-weight: 400; + text-align: right; + vertical-align: top; + min-width: 80px; + width: 20%; + word-wrap: break-word; +} + +.links-table th, +.links-table td { + padding: 5px 0; +} + +.links-table td label { + margin-left: 8px; +} + +.links-table td input[type="text"], +.links-table td textarea { + width: 100%; +} + +.links-table #link_rel { + max-width: 280px; +} + +/* DFW 2 +-------------------------------------------------------------- */ + +#wp-content-wrap .mce-wp-dfw, +#qt_content_dfw { + display: none; +} + +.wp-editor-expand #wp-content-wrap .mce-wp-dfw, +.wp-editor-expand #qt_content_dfw { + display: inline-block; +} + +.focus-on .wrap > h1, +.focus-on .page-title-action, +.focus-on #wpfooter, +.focus-on .postbox-container > *, +.focus-on div.updated, +.focus-on div.error, +.focus-on div.notice, +.focus-on .update-nag, +.focus-on #wp-toolbar, +.focus-on #screen-meta-links, +.focus-on #screen-meta { + opacity: 0; + transition-duration: 0.6s; + transition-property: opacity; + transition-timing-function: ease-in-out; +} + +.focus-on #wp-toolbar { + opacity: 0.3; +} + +.focus-off .wrap > h1, +.focus-off .page-title-action, +.focus-off #wpfooter, +.focus-off .postbox-container > *, +.focus-off div.updated, +.focus-off div.error, +.focus-off div.notice, +.focus-off .update-nag, +.focus-off #wp-toolbar, +.focus-off #screen-meta-links, +.focus-off #screen-meta { + opacity: 1; + transition-duration: 0.2s; + transition-property: opacity; + transition-timing-function: ease-in-out; +} + +.focus-off #wp-toolbar { + -webkit-transform: translate(0, 0); +} + +.focus-on #adminmenuback, +.focus-on #adminmenuwrap { + transition-duration: 0.6s; + transition-property: -webkit-transform; + transition-property: transform; + transition-property: transform, -webkit-transform; + transition-timing-function: ease-in-out; +} + +.focus-on #adminmenuback, +.focus-on #adminmenuwrap { + -webkit-transform: translateX( 100% ); + transform: translateX( 100% ); +} + +.focus-off #adminmenuback, +.focus-off #adminmenuwrap { + -webkit-transform: translateX( 0 ); + transform: translateX( 0 ); + transition-duration: 0.2s; + transition-property: -webkit-transform; + transition-property: transform; + transition-property: transform, -webkit-transform; + transition-timing-function: ease-in-out; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + #content-resize-handle, + #post-body .wp_themeSkin .mceStatusbar a.mceResize { + background: transparent url(../images/resize-2x.gif) no-repeat scroll left bottom; + background-size: 11px 11px; + } + + /*rtl:ignore*/ + .rtl #content-resize-handle, + .rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize { + background-image: url(../images/resize-rtl-2x.gif); + background-position: left bottom; + } +} + +/* one column on the post write/edit screen */ +@media only screen and (max-width: 850px) { + #poststuff { + min-width: 0; + } + + #wpbody-content #poststuff #post-body { + margin: 0; + } + + #wpbody-content #post-body.columns-2 #postbox-container-1 { + margin-left: 0; + width: 100%; + } + + #poststuff #postbox-container-1 .empty-container, + #poststuff #postbox-container-1 #side-sortables:empty { + border: 0 none; + height: 0; + min-height: 0; + } + + #poststuff #post-body.columns-2 #side-sortables { + min-height: 0; + width: auto; + } + + /* hide the radio buttons for column prefs */ + .screen-layout, + .columns-prefs { + display: none; + } +} + +@media screen and ( max-width: 782px ) { + .wp-core-ui .edit-tag-actions .button-primary { + margin-bottom: 0; + } + + #post-body-content { + min-width: 0; + } + + #titlediv #title-prompt-text { + padding: 10px 10px; + } + + #poststuff h3.hndle, /* Back-compat for pre-4.4 */ + #poststuff .stuffbox > h3, /* Back-compat for pre-4.4 */ + #poststuff h2 { + padding: 12px; + } + + .post-format-options { + padding-left: 0; + } + + .post-format-options a { + margin-left: 5px; + margin-bottom: 5px; + min-width: 52px; + } + + .post-format-options .post-format-title { + font-size: 11px; + } + + .post-format-options a div { + height: 28px; + width: 28px; + } + + .post-format-options a div:before { + font-size: 26px !important; + } + + /* Publish Metabox Options */ + #post-visibility-select { + line-height: 280%; + } + + .wp-core-ui .save-post-visibility, + .wp-core-ui .save-timestamp { + vertical-align: middle; + margin-left: 15px; + } + + .timestamp-wrap select#mm { + display: block; + width: 100%; + margin-bottom: 10px; + } + + .timestamp-wrap #jj, + .timestamp-wrap #aa, + .timestamp-wrap #hh, + .timestamp-wrap #mn { + padding: 12px 3px; + font-size: 14px; + margin-bottom: 5px; + width: auto; + text-align: center; + } + + /* Categories Metabox */ + ul.category-tabs { + margin: 30px 0 15px; + } + + ul.category-tabs li.tabs { + padding: 15px; + } + + ul.categorychecklist li { + margin-bottom: 15px; + } + + ul.categorychecklist ul { + margin-top: 15px; + } + + .category-add input[type=text], + .category-add select { + max-width: none; + margin-bottom: 15px; + } + + /* Tags Metabox */ + .tagsdiv .newtag { + width: 100%; + height: auto; + margin-bottom: 15px; + } + + .tagchecklist { + margin: 25px 10px; + } + + .tagchecklist > li { + font-size: 16px; + line-height: 1.4; + } + + /* Discussion */ + #commentstatusdiv p { + line-height: 2.8; + } + + /* TinyMCE Adjustments */ + .mceToolbar * { + white-space: normal !important; + } + + .mceToolbar tr, + .mceToolbar td { + float: right !important; + } + + .wp_themeSkin a.mceButton { + width: 30px; + height: 30px; + } + + .wp_themeSkin .mceButton .mceIcon { + margin-top: 5px; + margin-right: 5px; + } + + .wp_themeSkin .mceSplitButton { + margin-top: 1px; + } + + .wp_themeSkin .mceSplitButton td a.mceAction { + padding-top: 6px; + padding-bottom: 6px; + padding-right: 6px; + padding-left: 3px; + } + + .wp_themeSkin .mceSplitButton td a.mceOpen, + .wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen { + padding-top: 6px; + padding-bottom: 6px; + background-position: 1px 6px; + } + + .wp_themeSkin table.mceListBox { + margin: 5px; + } + + div.quicktags-toolbar input { + padding: 10px 20px; + } + + button.wp-switch-editor { + font-size: 16px; + line-height: 1em; + margin: 7px 7px 0 0; + padding: 8px 12px; + } + + #wp-content-media-buttons a { + font-size: 14px; + padding: 6px 10px; + } + + .wp-media-buttons span.wp-media-buttons-icon, + .wp-media-buttons span.jetpack-contact-form-icon { + width: 22px !important; + margin-right: -2px !important; + } + + .wp-media-buttons .add_media span.wp-media-buttons-icon:before, + .wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before { + font-size: 20px !important; + } + + #content_wp_fullscreen { + display: none; + } + + .misc-pub-section { + padding: 20px 10px 20px; + } + + .misc-pub-section > a { + float: left; + font-size: 16px; + } + + #delete-action, + #publishing-action { + line-height: 47px; + } + + #publishing-action .spinner { + float: none; + margin-top: -2px; /* Half of the Publish button's bottom margin. */ + } + + /* Moderate Comment */ + .comment-ays th, + .comment-ays td { + padding-bottom: 0; + } + + .comment-ays td { + padding-top: 6px; + } + + /* Links */ + .links-table #link_rel { + max-width: none; + } + + .links-table th, + .links-table td { + padding: 10px 0; + } + + .privacy-text-box { + width: auto; + } + + .privacy-text-box-toc { + float: none; + width: auto; + height: 100%; + } + + .privacy-text-section a.return-to-top { + float: none; + margin: 0; + } +} diff --git a/backend/wp-admin/css/edit-rtl.min.css b/backend/wp-admin/css/edit-rtl.min.css new file mode 100644 index 0000000..c69ffbe --- /dev/null +++ b/backend/wp-admin/css/edit-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#pending,#poststuff #titlewrap{border:0;padding:0}#pending,#poststuff #post-body{padding:0}#editable-post-name-full,body.post-new-php .submitbox .submitdelete{display:none}#post-status-info,.postbox{box-shadow:0 1px 1px rgba(0,0,0,.04)}#titlediv,#wp-content-editor-container,.postbox,form#tags-filter{position:relative}#poststuff{padding-top:10px;min-width:763px}#poststuff .postbox-container{width:100%}#poststuff #post-body.columns-2{margin-left:300px}#show-comments{overflow:hidden}#save-action .spinner,#show-comments a{float:right}#show-comments .spinner{float:none;margin-top:0}#lost-connection-notice .spinner{visibility:visible;float:right;margin:0 0 0 5px}#titlediv label{cursor:text}#titlediv div.inside{margin:0}#titlediv #title{padding:3px 8px;font-size:1.7em;line-height:100%;height:1.7em;width:100%;outline:0;margin:0 0 3px;background-color:#fff}#titlediv #title-prompt-text{color:#72777c;position:absolute;font-size:1.7em;padding:11px 10px}input#link_description,input#link_url{width:98%}#pending{background:100% none;font-size:11px;margin-top:-1px}#comment-link-box,#edit-slug-box{line-height:24px;min-height:25px;margin-top:5px;padding:0 10px;color:#666}#edit-slug-box .cancel{margin-left:10px;padding:0;font-size:11px}#comment-link-box{margin:5px 0;padding:0 5px}#editable-post-name{font-weight:600}#editable-post-name input{font-size:13px;font-weight:400;height:24px;margin:0;width:16em}.postarea h3 label{float:right}.submitbox .submit a:hover{text-decoration:underline}.submitbox .submit input{margin-bottom:8px;margin-left:4px;padding:6px}#post-status-select{margin-top:3px}#post-body #normal-sortables{min-height:50px}.postbox{min-width:255px;border:1px solid #e5e5e5;background:#fff}#trackback_url{width:99%}#normal-sortables .postbox .submit{background:0 0;border:0;float:left;padding:0 12px;margin:0}.category-add input[type=text],.category-add select{width:100%;max-width:260px;vertical-align:baseline}#side-sortables .category-add input[type=text],#side-sortables .category-add select{margin:0 0 1em}#side-sortables .add-menu-item-tabs li,.wp-tab-bar li,ul.category-tabs li{display:inline;line-height:1.35em}.no-js .category-tabs li.hide-if-no-js{display:none}#side-sortables .add-menu-item-tabs a,.category-tabs a,.wp-tab-bar a{text-decoration:none}#post-body ul.add-menu-item-tabs li.tabs a,#post-body ul.category-tabs li.tabs a,#side-sortables .add-menu-item-tabs .tabs a,#side-sortables .category-tabs .tabs a,.wp-tab-bar .wp-tab-active a{color:#32373c}.category-tabs{margin:8px 0 5px}#category-adder h4{margin:0}.taxonomy-add-new{display:inline-block;margin:10px 0;font-weight:600}#side-sortables .add-menu-item-tabs,.wp-tab-bar{margin-bottom:3px}#normal-sortables .postbox #replyrow .submit{float:none;margin:0;padding:5px 7px 10px;overflow:hidden}#side-sortables .submitbox .submit .preview,#side-sortables .submitbox .submit a.preview:hover,#side-sortables .submitbox .submit input{border:0}ul.add-menu-item-tabs,ul.category-tabs,ul.wp-tab-bar{margin-top:12px}ul.add-menu-item-tabs li,ul.category-tabs li{border:1px solid transparent;position:relative}.wp-tab-active,ul.add-menu-item-tabs li.tabs,ul.category-tabs li.tabs{border:1px solid #ddd;border-bottom-color:#fdfdfd;background-color:#fdfdfd}ul.add-menu-item-tabs li,ul.category-tabs li,ul.wp-tab-bar li{padding:3px 5px 6px}#set-post-thumbnail{display:inline-block;max-width:100%}.ui-tabs-hide,.wp-editor-expand #content-resize-handle,.wp-hidden-children .wp-hidden-child{display:none}#postimagediv .inside img{max-width:100%;height:auto;width:auto;vertical-align:top;background-image:linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:100% 0,10px 10px;background-size:20px 20px}#post-body .tagsdiv #newtag{margin-left:5px;width:16em}#side-sortables input#post_password{width:94%}#side-sortables .tagsdiv #newtag{width:68%}#post-status-info{width:100%;border-spacing:0;border:1px solid #e5e5e5;border-top:none;background-color:#f7f7f7;z-index:999}#post-status-info td{font-size:12px}.autosave-info{padding:2px 10px;text-align:left}#editorcontent #post-status-info{border:none}#content-resize-handle{background:url(../images/resize.gif) left bottom no-repeat;width:12px;cursor:row-resize}.rtl #content-resize-handle{background-image:url(../images/resize-rtl.gif);background-position:left bottom}#postdivrich #content{resize:none}#wp-word-count{display:block;padding:2px 10px}.wp-editor-expand #wp-content-editor-tools{z-index:1000;border-bottom:1px solid #e5e5e5}.wp-editor-expand #wp-content-editor-container{box-shadow:none;margin-top:-1px;border-bottom:0 none}.wp-editor-expand div.mce-statusbar{z-index:1}.wp-editor-expand #post-status-info{border-top:1px solid #e5e5e5}.wp-editor-expand div.mce-toolbar-grp{z-index:999}.mce-fullscreen #wp-content-wrap .mce-edit-area,.mce-fullscreen #wp-content-wrap .mce-menubar,.mce-fullscreen #wp-content-wrap .mce-statusbar,.mce-fullscreen #wp-content-wrap .mce-toolbar-grp{position:static!important;width:auto!important;padding:0!important}.mce-fullscreen #wp-content-wrap .mce-statusbar{visibility:visible!important}.mce-fullscreen #wp-content-wrap .mce-tinymce .mce-wp-dfw,.mce-fullscreen #wp-content-wrap .mce-wp-dfw,.post-php.mce-fullscreen #wpadminbar{display:none}#wp-content-editor-tools{background-color:#f1f1f1;padding-top:20px}#poststuff #post-body.columns-2 #side-sortables{width:280px}#timestampdiv select{height:21px;line-height:14px;padding:0;vertical-align:top;font-size:12px}#aa,#hh,#jj,#mn{padding:1px;font-size:12px}#hh,#jj,#mn{width:2em}#aa{width:3.4em}.curtime #timestamp{padding:2px 0 1px;display:inline!important;height:auto!important}#post-body #visibility:before,#post-body .misc-pub-post-status:before,#post-body .misc-pub-revisions:before,.curtime #timestamp:before,span.wp-media-buttons-icon:before{color:#82878c}#post-body #visibility:before,#post-body .misc-pub-post-status:before,#post-body .misc-pub-revisions:before,.curtime #timestamp:before{font:400 20px/1 dashicons;speak:none;display:inline-block;margin-right:-1px;padding-left:3px;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.suggested-policy-content,.wp-suggested-text p{font-style:italic}#post-body .misc-pub-post-status:before{content:"\f173"}#post-body #visibility:before{content:"\f177"}.curtime #timestamp:before{content:"\f145";position:relative;top:-1px}#post-body .misc-pub-revisions:before{content:"\f321"}#timestampdiv{padding-top:5px;line-height:23px}#timestampdiv p{margin:8px 0 6px}#timestampdiv input{border-width:1px;border-style:solid}.notification-dialog{position:fixed;top:30%;max-height:70%;right:50%;width:450px;margin-right:-225px;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);line-height:1.5;z-index:1000005;overflow-y:auto}.notification-dialog-background{position:fixed;top:0;right:0;left:0;bottom:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:1000000}#post-lock-dialog .post-locked-message,#post-lock-dialog .post-taken-over{margin:25px}#file-editor-warning .button,#post-lock-dialog .post-locked-message a.button{margin-left:10px}#post-lock-dialog .post-locked-avatar{float:right;margin:0 0 20px 20px}#post-lock-dialog .wp-tab-first{outline:0}#post-lock-dialog .locked-saving img{float:right;margin-left:3px}#post-lock-dialog.saved .locked-saved,#post-lock-dialog.saving .locked-saving{display:inline}#excerpt{display:block;margin:12px 0 0;height:4em;width:100%}.tagchecklist{margin-right:14px;font-size:12px;overflow:auto}.tagchecklist br{display:none}.tagchecklist strong{margin-right:-8px;position:absolute}.tagchecklist>li{float:right;margin-left:25px;font-size:13px;line-height:1.8em;cursor:default;max-width:100%;overflow:hidden;text-overflow:ellipsis}.tagchecklist .ntdelbutton{position:absolute;width:24px;height:24px;border:none;margin:0 -19px 0 0;padding:0;background:0 0;cursor:pointer;text-indent:0}#poststuff .stuffbox>h3,#poststuff h2,#poststuff h3.hndle{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}#poststuff .inside{margin:6px 0 0}#poststuff .inside #page_template,#poststuff .inside #parent_id{max-width:100%}.ie8 #poststuff .inside #page_template,.ie8 #poststuff .inside #parent_id{width:250px}.post-attributes-label-wrapper{margin-bottom:.5em}.post-attributes-label{vertical-align:baseline;font-weight:600}#post-visibility-select{line-height:1.5em;margin-top:3px}#linksubmitdiv .inside,#poststuff #submitdiv .inside{margin:0;padding:0}#post-body-content,.edit-form-section{margin-bottom:20px}.wp-privacy-policy-guide{max-width:1000px}.privacy-text-box{width:calc(100% - 260px)}.privacy-text-box-toc{float:left;width:250px;background-color:#fff}.privacy-text-box-toc p{margin:0;padding:.7em 1em;border-bottom:1px solid #eee}.privacy-text-box-toc ol{margin-right:2em}.wp-privacy-policy-guide h3{font-size:1.2em;margin:1em 0 .5em}.privacy-text-section .privacy-text-copy{float:left}.privacy-text-section{position:relative;border-top:1px solid #e3e3e3}.privacy-text-box-head,.privacy-text-section.text-removed{padding-bottom:12px}.text-removed .policy-text{font-style:italic;color:#666;font-weight:600}.privacy-text-actions{height:32px;line-height:32px;padding-bottom:6px}.wp-privacy-policy-guide .policy-text h2{margin:1.2em 0 1em;padding:0}.privacy-text-section a.return-to-top{float:left;margin-left:-250px;margin-top:6px}.hide-privacy-policy-tutorial .privacy-policy-tutorial{visibility:hidden}.wp-suggested-text p.privacy-policy-tutorial{font-style:normal}.notice.wp-pp-notice{margin:15px 0 3px}#postcustomstuff thead th{padding:5px 8px 8px;background-color:#f1f1f1}#postcustom #postcustomstuff .submit{border:0;float:none;padding:0 8px 8px}#side-sortables #postcustom #postcustomstuff .submit{margin:0;padding:0}#side-sortables #postcustom #postcustomstuff #the-list textarea{height:85px}#side-sortables #postcustom #postcustomstuff td.left input,#side-sortables #postcustom #postcustomstuff td.left select,#side-sortables #postcustomstuff #newmetaleft a{margin:3px 3px 0}#postcustomstuff table{margin:0;width:100%;border:1px solid #ddd;border-spacing:0;background-color:#f9f9f9}#postcustomstuff tr{vertical-align:top}#postcustomstuff table input,#postcustomstuff table select,#postcustomstuff table textarea{width:96%;margin:8px}#side-sortables #postcustomstuff table input,#side-sortables #postcustomstuff table select,#side-sortables #postcustomstuff table textarea{margin:3px}#postcustomstuff td.left,#postcustomstuff th.left{width:38%}#postcustomstuff .submit input{margin:0;width:auto}#postcustomstuff #newmetaleft a{display:inline-block;margin:0 8px 8px;text-decoration:none}.no-js #postcustomstuff #enternew{display:none}#post-body-content .compat-attachment-fields{margin-bottom:20px}.compat-attachment-fields th{padding-top:5px;padding-left:10px}#select-featured-image{padding:4px 0;overflow:hidden}#select-featured-image img{max-width:100%;height:auto;margin-bottom:10px}#select-featured-image a{float:right;clear:both}#select-featured-image .remove{display:none;margin-top:10px}.js #select-featured-image.has-featured-image .remove{display:inline-block}.no-js #select-featured-image .choose{display:none}.post-state-format{overflow:hidden;display:inline-block;vertical-align:middle;height:20px;width:20px;margin-left:5px;margin-top:-4px}.post-state-format:before{display:block;height:20px;width:20px;font:400 20px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.post-format-icon:before,.post-state-format:before{color:#ddd;transition:all .1s ease-in-out}a.post-format-icon:hover:before,a.post-state-format:hover:before{color:#00a0d2}#post-formats-select{line-height:2em}#post-formats-select .post-format-icon:before{top:5px}input.post-format{margin-top:1px}label.post-format-icon{margin-right:0;padding:2px 0}.post-format-icon:before{position:relative;display:inline-block;margin-left:7px;font:400 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.post-format-icon.post-format-standard:before,.post-state-format.post-format-standard:before,a.post-state-format.format-standard:before{content:"\f109"}.post-format-icon.post-format-image:before,.post-state-format.post-format-image:before,a.post-state-format.format-image:before{content:"\f128"}.post-format-icon.post-format-gallery:before,.post-state-format.post-format-gallery:before,a.post-state-format.format-gallery:before{content:"\f161"}.post-format-icon.post-format-audio:before,.post-state-format.post-format-audio:before,a.post-state-format.format-audio:before{content:"\f127"}.post-format-icon.post-format-video:before,.post-state-format.post-format-video:before,a.post-state-format.format-video:before{content:"\f126"}.post-format-icon.post-format-chat:before,.post-state-format.post-format-chat:before,a.post-state-format.format-chat:before{content:"\f125"}.post-format-icon.post-format-status:before,.post-state-format.post-format-status:before,a.post-state-format.format-status:before{content:"\f130"}.post-format-icon.post-format-aside:before,.post-state-format.post-format-aside:before,a.post-state-format.format-aside:before{content:"\f123"}.post-format-icon.post-format-quote:before,.post-state-format.post-format-quote:before,a.post-state-format.format-quote:before{content:"\f122"}.post-format-icon.post-format-link:before,.post-state-format.post-format-link:before,a.post-state-format.format-link:before{content:"\f103"}.category-adder{margin-right:120px;padding:4px 0}.category-adder h4{margin:0 0 8px}#side-sortables .category-adder{margin:0}.categorydiv div.tabs-panel,.customlinkdiv div.tabs-panel,.posttypediv div.tabs-panel,.taxonomydiv div.tabs-panel,.wp-tab-panel{min-height:42px;max-height:200px;overflow:auto;padding:0 .9em;border:1px solid #ddd;background-color:#fdfdfd}div.tabs-panel-active{display:block}div.tabs-panel-inactive{display:none}#front-page-warning,#front-static-pages ul,.categorydiv ul.categorychecklist ul,.customlinkdiv ul.categorychecklist ul,.inline-editor ul.cat-checklist ul,.posttypediv ul.categorychecklist ul,.taxonomydiv ul.categorychecklist ul,ul.export-filters{margin-right:18px}ul.categorychecklist li{margin:0;padding:0;line-height:22px;word-wrap:break-word}.categorydiv .tabs-panel,.customlinkdiv .tabs-panel,.posttypediv .tabs-panel,.taxonomydiv .tabs-panel{border-width:3px;border-style:solid}.form-wrap label{display:block;padding:2px 0}.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field input[type=number],.form-field input[type=search],.form-field input[type=tel],.form-field input[type=url],.form-field textarea{border-style:solid;border-width:1px;width:95%}.form-wrap p,p.description{margin:2px 0 5px;color:#666}.form-wrap p,p.description,p.help,span.description{font-size:13px;font-style:italic}.form-wrap .form-field{margin:1em 0;padding:0}.form-wrap .form-field #parent{max-width:100%}.col-wrap h2{margin:12px 0;font-size:1.1em}.col-wrap p.submit{margin-top:-10px}.edit-term-notes{margin-top:2em}#poststuff .tagsdiv .howto{margin:0 0 6px}.ajaxtag .newtag{position:relative}.tagsdiv .newtag{width:180px}.tagsdiv .the-tags{display:block;height:60px;margin:0 auto;overflow:auto;width:260px}#post-body-content .tagsdiv .the-tags{margin:0 5px}p.popular-tags{border:none;line-height:2em;padding:8px 12px 12px;text-align:justify}p.popular-tags a{padding:0 3px}.tagcloud{width:97%;margin:0 0 40px;text-align:justify}.tagcloud h2{margin:2px 0 12px}.the-tagcloud ul{margin:0}.the-tagcloud ul li{display:inline-block}.ac_results{display:none;margin:-1px 0 0;padding:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;background-color:#fff}.wp-customizer .ac_results{z-index:500000}.ac_results li{margin:0;padding:5px 10px;white-space:nowrap;text-align:right}.ac_over .ac_match,.ac_results .ac_over{background-color:#0073aa;color:#fff;cursor:pointer}.ac_match{text-decoration:underline}#edittag{max-width:800px}.edit-tag-actions{margin-top:20px;overflow:hidden;padding:10px;margin-left:10px}.comment-php .wp-editor-area{height:200px}.comment-ays td,.comment-ays th{padding:10px 15px}.comment-ays .comment-content ul{list-style:outside;margin-right:2em}.comment-ays .comment-content a[href]:after{content:'(' attr(href) ')';display:inline-block;padding:0 4px;color:#72777C;font-size:13px;word-break:break-all}.comment-ays .comment-content p.edit-comment{margin-top:10px}.comment-ays .comment-content p.edit-comment a[href]:after{content:'';padding:0}#comment-status-radio label,.links-table td,.links-table th{padding:5px 0}.comment-ays-submit .button-cancel{margin-right:1em}.spam-undo-inside,.trash-undo-inside{margin:1px 0 1px 8px;line-height:16px}.spam-undo-inside .avatar,.trash-undo-inside .avatar{height:20px;width:20px;margin-left:8px;vertical-align:middle}.stuffbox .editcomment{clear:none}#comment-status-radio p{margin:3px 0 5px}#comment-status-radio input{margin:2px 0 5px 3px;vertical-align:middle}table.links-table{width:100%;border-spacing:0}.links-table th{font-weight:400;text-align:right;vertical-align:top;min-width:80px;width:20%;word-wrap:break-word}.links-table td label{margin-left:8px}.links-table td input[type=text],.links-table td textarea{width:100%}.links-table #link_rel{max-width:280px}#qt_content_dfw,#wp-content-wrap .mce-wp-dfw{display:none}.wp-editor-expand #qt_content_dfw,.wp-editor-expand #wp-content-wrap .mce-wp-dfw{display:inline-block}.focus-on #screen-meta,.focus-on #screen-meta-links,.focus-on #wp-toolbar,.focus-on #wpfooter,.focus-on .page-title-action,.focus-on .postbox-container>*,.focus-on .update-nag,.focus-on .wrap>h1,.focus-on div.error,.focus-on div.notice,.focus-on div.updated{opacity:0;transition-duration:.6s;transition-property:opacity;transition-timing-function:ease-in-out}.focus-on #wp-toolbar{opacity:.3}.focus-off #screen-meta,.focus-off #screen-meta-links,.focus-off #wp-toolbar,.focus-off #wpfooter,.focus-off .page-title-action,.focus-off .postbox-container>*,.focus-off .update-nag,.focus-off .wrap>h1,.focus-off div.error,.focus-off div.notice,.focus-off div.updated{opacity:1;transition-duration:.2s;transition-property:opacity;transition-timing-function:ease-in-out}.focus-off #wp-toolbar{-webkit-transform:translate(0,0)}.focus-on #adminmenuback,.focus-on #adminmenuwrap{transition-duration:.6s;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform;transition-timing-function:ease-in-out;-webkit-transform:translateX(100%);transform:translateX(100%)}.focus-off #adminmenuback,.focus-off #adminmenuwrap{-webkit-transform:translateX(0);transform:translateX(0);transition-duration:.2s;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform;transition-timing-function:ease-in-out}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#content-resize-handle,#post-body .wp_themeSkin .mceStatusbar a.mceResize{background:url(../images/resize-2x.gif) left bottom no-repeat;background-size:11px 11px}.rtl #content-resize-handle,.rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize{background-image:url(../images/resize-rtl-2x.gif);background-position:left bottom}}@media only screen and (max-width:850px){#poststuff{min-width:0}#wpbody-content #poststuff #post-body{margin:0}#wpbody-content #post-body.columns-2 #postbox-container-1{margin-left:0;width:100%}#poststuff #postbox-container-1 #side-sortables:empty,#poststuff #postbox-container-1 .empty-container{border:0;height:0;min-height:0}#poststuff #post-body.columns-2 #side-sortables{min-height:0;width:auto}.columns-prefs,.screen-layout{display:none}}@media screen and (max-width:782px){.wp-core-ui .edit-tag-actions .button-primary{margin-bottom:0}#post-body-content{min-width:0}#titlediv #title-prompt-text{padding:10px}#poststuff .stuffbox>h3,#poststuff h2,#poststuff h3.hndle{padding:12px}.post-format-options{padding-left:0}.post-format-options a{margin-left:5px;margin-bottom:5px;min-width:52px}.post-format-options .post-format-title{font-size:11px}.post-format-options a div{height:28px;width:28px}.post-format-options a div:before{font-size:26px!important}#post-visibility-select{line-height:280%}.wp-core-ui .save-post-visibility,.wp-core-ui .save-timestamp{vertical-align:middle;margin-left:15px}.timestamp-wrap select#mm{display:block;width:100%;margin-bottom:10px}.timestamp-wrap #aa,.timestamp-wrap #hh,.timestamp-wrap #jj,.timestamp-wrap #mn{padding:12px 3px;font-size:14px;margin-bottom:5px;width:auto;text-align:center}ul.category-tabs{margin:30px 0 15px}.tagsdiv .newtag,ul.categorychecklist li{margin-bottom:15px}ul.category-tabs li.tabs{padding:15px}ul.categorychecklist ul{margin-top:15px}.category-add input[type=text],.category-add select{max-width:none;margin-bottom:15px}.tagsdiv .newtag{width:100%;height:auto}.tagchecklist{margin:25px 10px}.tagchecklist>li{font-size:16px;line-height:1.4}#commentstatusdiv p{line-height:2.8}.mceToolbar *{white-space:normal!important}.mceToolbar td,.mceToolbar tr{float:right!important}.wp_themeSkin a.mceButton{width:30px;height:30px}.wp_themeSkin .mceButton .mceIcon{margin-top:5px;margin-right:5px}.wp_themeSkin .mceSplitButton{margin-top:1px}.wp_themeSkin .mceSplitButton td a.mceAction{padding:6px 6px 6px 3px}.wp_themeSkin .mceSplitButton td a.mceOpen,.wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen{padding-top:6px;padding-bottom:6px;background-position:1px 6px}.wp_themeSkin table.mceListBox{margin:5px}div.quicktags-toolbar input{padding:10px 20px}button.wp-switch-editor{font-size:16px;line-height:1em;margin:7px 7px 0 0;padding:8px 12px}#wp-content-media-buttons a{font-size:14px;padding:6px 10px}.wp-media-buttons span.jetpack-contact-form-icon,.wp-media-buttons span.wp-media-buttons-icon{width:22px!important;margin-right:-2px!important}.wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before,.wp-media-buttons .add_media span.wp-media-buttons-icon:before{font-size:20px!important}#content_wp_fullscreen{display:none}.misc-pub-section{padding:20px 10px}.misc-pub-section>a{float:left;font-size:16px}#delete-action,#publishing-action{line-height:47px}#publishing-action .spinner{float:none;margin-top:-2px}.comment-ays td,.comment-ays th{padding-bottom:0}.comment-ays td{padding-top:6px}.links-table #link_rel{max-width:none}.links-table td,.links-table th{padding:10px 0}.privacy-text-box{width:auto}.privacy-text-box-toc{float:none;width:auto;height:100%}.privacy-text-section a.return-to-top{float:none;margin:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/edit.css b/backend/wp-admin/css/edit.css new file mode 100644 index 0000000..1c3f8b4 --- /dev/null +++ b/backend/wp-admin/css/edit.css @@ -0,0 +1,1675 @@ +#poststuff { + padding-top: 10px; + min-width: 763px; +} + +#poststuff #post-body { + padding: 0; +} + +#poststuff .postbox-container { + width: 100%; +} + +#poststuff #post-body.columns-2 { + margin-right: 300px; +} + +/*------------------------------------------------------------------------------ + 11.0 - Write/Edit Post Screen +------------------------------------------------------------------------------*/ + +#show-comments { + overflow: hidden; +} + +#save-action .spinner, +#show-comments a { + float: left; +} + +#show-comments .spinner { + float: none; + margin-top: 0; +} + +#lost-connection-notice .spinner { + visibility: visible; + float: left; + margin: 0 5px 0 0; +} + +#titlediv { + position: relative; +} + +#titlediv label { + cursor: text; +} + +#titlediv div.inside { + margin: 0; +} + +#poststuff #titlewrap { + border: 0; + padding: 0; +} + +#titlediv #title { + padding: 3px 8px; + font-size: 1.7em; + line-height: 100%; + height: 1.7em; + width: 100%; + outline: none; + margin: 0 0 3px; + background-color: #fff; +} + +#titlediv #title-prompt-text { + color: #72777c; + position: absolute; + font-size: 1.7em; + padding: 11px 10px; +} + +input#link_description, +input#link_url { + width: 98%; +} + +#pending { + background: 0 none; + border: 0 none; + padding: 0; + font-size: 11px; + margin-top: -1px; +} + +#edit-slug-box, +#comment-link-box { + line-height: 24px; + min-height: 25px; /* Yes, line-height + 1 */ + margin-top: 5px; + padding: 0 10px; + color: #666; +} + +#edit-slug-box .cancel { + margin-right: 10px; + padding: 0; + font-size: 11px; +} + +#comment-link-box { + margin: 5px 0; + padding: 0 5px; +} + +#editable-post-name-full { + display: none; +} + +#editable-post-name { + font-weight: 600; +} + +#editable-post-name input { + font-size: 13px; + font-weight: 400; + height: 24px; + margin: 0; + width: 16em; +} + +.postarea h3 label { + float: left; +} + +body.post-new-php .submitbox .submitdelete { + display: none; +} + +.submitbox .submit a:hover { + text-decoration: underline; +} + +.submitbox .submit input { + margin-bottom: 8px; + margin-right: 4px; + padding: 6px; +} + +#post-status-select { + margin-top: 3px; +} + +/* Post Screen */ +#post-body #normal-sortables { + min-height: 50px; +} + +.postbox { + position: relative; + min-width: 255px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; +} + +#trackback_url { + width: 99%; +} + +#normal-sortables .postbox .submit { + background: transparent none; + border: 0 none; + float: right; + padding: 0 12px; + margin:0; +} + +.category-add input[type="text"], +.category-add select { + width: 100%; + max-width: 260px; + vertical-align: baseline; +} + +#side-sortables .category-add input[type="text"], +#side-sortables .category-add select { + margin: 0 0 1em; +} + +ul.category-tabs li, +#side-sortables .add-menu-item-tabs li, +.wp-tab-bar li { + display: inline; + line-height: 1.35em; +} + +.no-js .category-tabs li.hide-if-no-js { + display: none; +} + +.category-tabs a, +#side-sortables .add-menu-item-tabs a, +.wp-tab-bar a { + text-decoration: none; +} + +/* @todo: do these really need to be so specific? */ +#side-sortables .category-tabs .tabs a, +#side-sortables .add-menu-item-tabs .tabs a, +.wp-tab-bar .wp-tab-active a, +#post-body ul.category-tabs li.tabs a, +#post-body ul.add-menu-item-tabs li.tabs a { + color: #32373c; +} + +.category-tabs { + margin: 8px 0 5px; +} + +/* Back-compat for pre-4.4 */ +#category-adder h4 { + margin: 0; +} + +.taxonomy-add-new { + display: inline-block; + margin: 10px 0; + font-weight: 600; +} + +#side-sortables .add-menu-item-tabs, +.wp-tab-bar { + margin-bottom: 3px; +} + +#normal-sortables .postbox #replyrow .submit { + float: none; + margin: 0; + padding: 5px 7px 10px; + overflow: hidden; +} + +#side-sortables .submitbox .submit input, +#side-sortables .submitbox .submit .preview, +#side-sortables .submitbox .submit a.preview:hover { + border: 0 none; +} + +/* @todo: make this a more generic class */ +ul.category-tabs, +ul.add-menu-item-tabs, +ul.wp-tab-bar { + margin-top: 12px; +} + +ul.category-tabs li, +ul.add-menu-item-tabs li { + border: solid 1px transparent; + position: relative; +} + +ul.category-tabs li.tabs, +ul.add-menu-item-tabs li.tabs, +.wp-tab-active { + border: 1px solid #ddd; + border-bottom-color: #fdfdfd; + background-color: #fdfdfd; +} + +ul.category-tabs li, +ul.add-menu-item-tabs li, +ul.wp-tab-bar li { + padding: 3px 5px 6px; +} + +#set-post-thumbnail { + display: inline-block; + max-width: 100%; +} + +#postimagediv .inside img { + max-width: 100%; + height: auto; + width: auto; + vertical-align: top; + background-image: linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 0 0, 10px 10px; + background-size: 20px 20px; +} + +form#tags-filter { + position: relative; +} + +/* Global classes */ +.wp-hidden-children .wp-hidden-child, +.ui-tabs-hide { + display: none; +} + +#post-body .tagsdiv #newtag { + margin-right: 5px; + width: 16em; +} + +#side-sortables input#post_password { + width: 94% +} + +#side-sortables .tagsdiv #newtag { + width: 68%; +} + +#post-status-info { + width: 100%; + border-spacing: 0; + border: 1px solid #e5e5e5; + border-top: none; + background-color: #f7f7f7; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + z-index: 999; +} + +#post-status-info td { + font-size: 12px; +} + +.autosave-info { + padding: 2px 10px; + text-align: right; +} + +#editorcontent #post-status-info { + border: none; +} + +#content-resize-handle { + background: transparent url(../images/resize.gif) no-repeat scroll right bottom; + width: 12px; + cursor: row-resize; +} + +/*rtl:ignore*/ +.rtl #content-resize-handle { + background-image: url(../images/resize-rtl.gif); + background-position: left bottom; +} + +.wp-editor-expand #content-resize-handle { + display: none; +} + +#postdivrich #content { + resize: none; +} + +#wp-word-count { + display: block; + padding: 2px 10px; +} + +#wp-content-editor-container { + position: relative; +} + +.wp-editor-expand #wp-content-editor-tools { + z-index: 1000; + border-bottom: 1px solid #e5e5e5; +} + +.wp-editor-expand #wp-content-editor-container { + box-shadow: none; + margin-top: -1px; +} + +.wp-editor-expand #wp-content-editor-container { + border-bottom: 0 none; +} + +.wp-editor-expand div.mce-statusbar { + z-index: 1; +} + +.wp-editor-expand #post-status-info { + border-top: 1px solid #e5e5e5; +} + +.wp-editor-expand div.mce-toolbar-grp { + z-index: 999; +} + +/* TinyMCE native fullscreen mode override */ +.mce-fullscreen #wp-content-wrap .mce-menubar, +.mce-fullscreen #wp-content-wrap .mce-toolbar-grp, +.mce-fullscreen #wp-content-wrap .mce-edit-area, +.mce-fullscreen #wp-content-wrap .mce-statusbar { + position: static !important; + width: auto !important; + padding: 0 !important; +} + +.mce-fullscreen #wp-content-wrap .mce-statusbar { + visibility: visible !important; +} + +.mce-fullscreen #wp-content-wrap .mce-tinymce .mce-wp-dfw { + display: none; +} + +.post-php.mce-fullscreen #wpadminbar, +.mce-fullscreen #wp-content-wrap .mce-wp-dfw { + display: none; +} +/* End TinyMCE native fullscreen mode override */ + +#wp-content-editor-tools { + background-color: #f1f1f1; + padding-top: 20px; +} + +#poststuff #post-body.columns-2 #side-sortables { + width: 280px; +} + +#timestampdiv select { + height: 21px; + line-height: 14px; + padding: 0; + vertical-align: top; + font-size: 12px; +} + +#aa, #jj, #hh, #mn { + padding: 1px; + font-size: 12px; +} + +#jj, #hh, #mn { + width: 2em; +} + +#aa { + width: 3.4em; +} + +.curtime #timestamp { + padding: 2px 0 1px 0; + display: inline !important; + height: auto !important; +} + +#post-body .misc-pub-post-status:before, +#post-body #visibility:before, +.curtime #timestamp:before, +#post-body .misc-pub-revisions:before, +span.wp-media-buttons-icon:before { + color: #82878c; +} + +#post-body .misc-pub-post-status:before, +#post-body #visibility:before, +.curtime #timestamp:before, +#post-body .misc-pub-revisions:before { + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + margin-left: -1px; + padding-right: 3px; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#post-body .misc-pub-post-status:before { + content: "\f173"; +} + +#post-body #visibility:before { + content: "\f177"; +} + +.curtime #timestamp:before { + content: "\f145"; + position: relative; + top: -1px; +} + +#post-body .misc-pub-revisions:before { + content: "\f321"; +} + +#timestampdiv { + padding-top: 5px; + line-height: 23px; +} + +#timestampdiv p { + margin: 8px 0 6px; +} + +#timestampdiv input { + border-width: 1px; + border-style: solid; +} + +.notification-dialog { + position: fixed; + top: 30%; + max-height: 70%; + left: 50%; + width: 450px; + margin-left: -225px; + background: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + line-height: 1.5; + z-index: 1000005; + overflow-y: auto; +} + +.notification-dialog-background { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 1000000; +} + +#post-lock-dialog .post-locked-message, +#post-lock-dialog .post-taken-over { + margin: 25px; +} + +#post-lock-dialog .post-locked-message a.button, +#file-editor-warning .button { + margin-right: 10px; +} + +#post-lock-dialog .post-locked-avatar { + float: left; + margin: 0 20px 20px 0; +} + +#post-lock-dialog .wp-tab-first { + outline: 0; +} + +#post-lock-dialog .locked-saving img { + float: left; + margin-right: 3px; +} + +#post-lock-dialog.saving .locked-saving, +#post-lock-dialog.saved .locked-saved { + display: inline; +} + +#excerpt { + display: block; + margin: 12px 0 0; + height: 4em; + width: 100%; +} + +.tagchecklist { + margin-left: 14px; + font-size: 12px; + overflow: auto; +} + +.tagchecklist br { + display: none; +} + +.tagchecklist strong { + margin-left: -8px; + position: absolute; +} + +.tagchecklist > li { + float: left; + margin-right: 25px; + font-size: 13px; + line-height: 1.8em; + cursor: default; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; +} + +.tagchecklist .ntdelbutton { + position: absolute; + width: 24px; + height: 24px; + border: none; + margin: 0 0 0 -19px; + padding: 0; + background: none; + cursor: pointer; + text-indent: 0; +} + +#poststuff h3.hndle, /* Back-compat for pre-4.4 */ +#poststuff .stuffbox > h3, /* Back-compat for pre-4.4 */ +#poststuff h2 { + font-size: 14px; + padding: 8px 12px; + margin: 0; + line-height: 1.4; +} + +#poststuff .inside { + margin: 6px 0 0 0; +} + +#poststuff .inside #parent_id, +#poststuff .inside #page_template { + max-width: 100%; +} + +.ie8 #poststuff .inside #parent_id, +.ie8 #poststuff .inside #page_template { + width: 250px; +} + +.post-attributes-label-wrapper { + margin-bottom: 0.5em; +} + +.post-attributes-label { + vertical-align: baseline; + font-weight: 600; +} + +#post-visibility-select { + line-height: 1.5em; + margin-top: 3px; +} + +#linksubmitdiv .inside, /* Old Link Manager back-compat. */ +#poststuff #submitdiv .inside { + margin: 0; + padding: 0; +} + +#post-body-content, +.edit-form-section { + margin-bottom: 20px; +} + +/* Suggested text for privacy policy */ +.wp-privacy-policy-guide { + max-width: 1000px; +} + +.privacy-text-box { + width: calc(100% - 260px); +} + +.privacy-text-box-toc { + float: right; + width: 250px; + background-color: #fff; +} + +.privacy-text-box-toc p { + margin: 0; + padding: 0.7em 1em; + border-bottom: 1px solid #eee; +} + +.privacy-text-box-toc ol { + margin-left: 2em; +} + +.wp-privacy-policy-guide h3 { + font-size: 1.2em; + margin: 1em 0 0.5em; +} + +.privacy-text-section .privacy-text-copy { + float: right; +} + +.privacy-text-section { + position: relative; + border-top: 1px solid #e3e3e3; +} + +.privacy-text-box-head, +.privacy-text-section.text-removed { + padding-bottom: 12px; +} + +.text-removed .policy-text { + font-style: italic; + color: #666; + font-weight: 600; +} + +.privacy-text-actions { + height: 32px; + line-height: 32px; + padding-bottom: 6px; +} + +.wp-privacy-policy-guide .policy-text h2 { + margin: 1.2em 0 1em; + padding: 0; +} + +.suggested-policy-content { + font-style: italic; +} + +.privacy-text-section a.return-to-top { + float: right; + margin-right: -250px; + margin-top: 6px; +} + +.hide-privacy-policy-tutorial .privacy-policy-tutorial { + visibility: hidden; +} + +.wp-suggested-text p { + font-style: italic; +} + +.wp-suggested-text p.privacy-policy-tutorial { + font-style: normal; +} + +.notice.wp-pp-notice { + margin: 15px 0 3px; +} + +/*------------------------------------------------------------------------------ + 11.1 - Custom Fields +------------------------------------------------------------------------------*/ + +#postcustomstuff thead th { + padding: 5px 8px 8px; + background-color: #f1f1f1; +} + +#postcustom #postcustomstuff .submit { + border: 0 none; + float: none; + padding: 0 8px 8px; +} + +#side-sortables #postcustom #postcustomstuff .submit { + margin: 0; + padding: 0; +} + +#side-sortables #postcustom #postcustomstuff #the-list textarea { + height: 85px; +} + +#side-sortables #postcustom #postcustomstuff td.left input, +#side-sortables #postcustom #postcustomstuff td.left select, +#side-sortables #postcustomstuff #newmetaleft a { + margin: 3px 3px 0; +} + +#postcustomstuff table { + margin: 0; + width: 100%; + border: 1px solid #ddd; + border-spacing: 0; + background-color: #f9f9f9; +} + +#postcustomstuff tr { + vertical-align: top; +} + +#postcustomstuff table input, +#postcustomstuff table select, +#postcustomstuff table textarea { + width: 96%; + margin: 8px; +} + +#side-sortables #postcustomstuff table input, +#side-sortables #postcustomstuff table select, +#side-sortables #postcustomstuff table textarea { + margin: 3px; +} + +#postcustomstuff th.left, +#postcustomstuff td.left { + width: 38%; +} + +#postcustomstuff .submit input { + margin: 0; + width: auto; +} + +#postcustomstuff #newmetaleft a { + display: inline-block; + margin: 0 8px 8px; + text-decoration: none; +} + +.no-js #postcustomstuff #enternew { + display: none; +} + +#post-body-content .compat-attachment-fields { + margin-bottom: 20px; +} + +.compat-attachment-fields th { + padding-top: 5px; + padding-right: 10px; +} + +/*------------------------------------------------------------------------------ + 11.3 - Featured Images +------------------------------------------------------------------------------*/ + +#select-featured-image { + padding: 4px 0; + overflow: hidden; +} + +#select-featured-image img { + max-width: 100%; + height: auto; + margin-bottom: 10px; +} + +#select-featured-image a { + float: left; + clear: both; +} + +#select-featured-image .remove { + display: none; + margin-top: 10px; +} + +.js #select-featured-image.has-featured-image .remove { + display: inline-block; +} + +.no-js #select-featured-image .choose { + display: none; +} + +/*------------------------------------------------------------------------------ + 11.4 - Post formats +------------------------------------------------------------------------------*/ + +.post-state-format { + overflow: hidden; + display: inline-block; + vertical-align: middle; + height: 20px; + width: 20px; + margin-right: 5px; + margin-top: -4px; +} + +.post-state-format:before { + display: block; + height: 20px; + width: 20px; + font: normal 20px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.post-state-format:before, +.post-format-icon:before { + color: #ddd; + transition: all .1s ease-in-out; +} + +a.post-state-format:hover:before, +a.post-format-icon:hover:before { + color: #00a0d2; +} + +#post-formats-select { + line-height: 2em; +} + +#post-formats-select .post-format-icon:before { + top: 5px; +} + +input.post-format { + margin-top: 1px; +} + +label.post-format-icon { + margin-left: 0px; + padding: 2px 0 2px 0px; +} + +.post-format-icon:before { + position: relative; + display: inline-block; + margin-right: 7px; + font: normal 20px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.post-state-format.post-format-standard:before, +.post-format-icon.post-format-standard:before, +a.post-state-format.format-standard:before { + content: "\f109"; +} + +.post-state-format.post-format-image:before, +.post-format-icon.post-format-image:before, +a.post-state-format.format-image:before { + content: "\f128"; +} + +.post-state-format.post-format-gallery:before, +.post-format-icon.post-format-gallery:before, +a.post-state-format.format-gallery:before { + content: "\f161"; +} + +.post-state-format.post-format-audio:before, +.post-format-icon.post-format-audio:before, +a.post-state-format.format-audio:before { + content: "\f127"; +} + +.post-state-format.post-format-video:before, +.post-format-icon.post-format-video:before, +a.post-state-format.format-video:before { + content: "\f126"; +} + +.post-state-format.post-format-chat:before, +.post-format-icon.post-format-chat:before, +a.post-state-format.format-chat:before { + content: "\f125"; +} + +.post-state-format.post-format-status:before, +.post-format-icon.post-format-status:before, +a.post-state-format.format-status:before { + content: "\f130"; +} + +.post-state-format.post-format-aside:before, +.post-format-icon.post-format-aside:before, +a.post-state-format.format-aside:before { + content: "\f123"; +} + +.post-state-format.post-format-quote:before, +.post-format-icon.post-format-quote:before, +a.post-state-format.format-quote:before { + content: "\f122"; +} + +.post-state-format.post-format-link:before, +.post-format-icon.post-format-link:before, +a.post-state-format.format-link:before { + content: "\f103"; +} + +/*------------------------------------------------------------------------------ + 12.0 - Categories +------------------------------------------------------------------------------*/ + +.category-adder { + margin-left: 120px; + padding: 4px 0; +} + +.category-adder h4 { + margin: 0 0 8px; +} + +#side-sortables .category-adder { + margin: 0; +} + +.wp-tab-panel, +.categorydiv div.tabs-panel, +.customlinkdiv div.tabs-panel, +.posttypediv div.tabs-panel, +.taxonomydiv div.tabs-panel { + min-height: 42px; + max-height: 200px; + overflow: auto; + padding: 0 0.9em; + border: solid 1px #ddd; + background-color: #fdfdfd; +} + +div.tabs-panel-active { + display:block; +} + +div.tabs-panel-inactive { + display:none; +} + +#front-page-warning, +#front-static-pages ul, +ul.export-filters, +.inline-editor ul.cat-checklist ul, +.categorydiv ul.categorychecklist ul, +.customlinkdiv ul.categorychecklist ul, +.posttypediv ul.categorychecklist ul, +.taxonomydiv ul.categorychecklist ul { + margin-left: 18px; +} + +ul.categorychecklist li { + margin: 0; + padding: 0; + line-height: 22px; + word-wrap: break-word; +} + +.categorydiv .tabs-panel, +.customlinkdiv .tabs-panel, +.posttypediv .tabs-panel, +.taxonomydiv .tabs-panel { + border-width: 3px; + border-style: solid; +} + +.form-wrap label { + display: block; + padding: 2px 0; +} + +.form-field input[type="text"], +.form-field input[type="password"], +.form-field input[type="email"], +.form-field input[type="number"], +.form-field input[type="search"], +.form-field input[type="tel"], +.form-field input[type="url"], +.form-field textarea { + border-style: solid; + border-width: 1px; + width: 95%; +} + +p.description, +.form-wrap p { + margin: 2px 0 5px; + color: #666; +} + +p.help, +p.description, +span.description, +.form-wrap p { + font-size: 13px; + font-style: italic; +} + +.form-wrap .form-field { + margin: 1em 0; + padding: 0; +} + +.form-wrap .form-field #parent { + max-width: 100%; +} + +.col-wrap h2 { + margin: 12px 0; + font-size: 1.1em; +} + +.col-wrap p.submit { + margin-top: -10px; +} + +.edit-term-notes { + margin-top: 2em; +} + +/*------------------------------------------------------------------------------ + 13.0 - Tags +------------------------------------------------------------------------------*/ + +#poststuff .tagsdiv .howto { + margin: 0 0 6px 0; +} + +.ajaxtag .newtag { + position: relative; +} + +.tagsdiv .newtag { + width: 180px; +} + +.tagsdiv .the-tags { + display: block; + height: 60px; + margin: 0 auto; + overflow: auto; + width: 260px; +} + +#post-body-content .tagsdiv .the-tags { + margin: 0 5px; +} + +p.popular-tags { + border: none; + line-height: 2em; + padding: 8px 12px 12px; + text-align: justify; +} + +p.popular-tags a { + padding: 0 3px; +} + +.tagcloud { + width: 97%; + margin: 0 0 40px; + text-align: justify; +} + +.tagcloud h2 { + margin: 2px 0 12px; +} + +.the-tagcloud ul { + margin: 0; +} + +.the-tagcloud ul li { + display: inline-block; +} + +/* Suggest.js autocomplete, no more used by core. */ +.ac_results { + display: none; + margin: -1px 0 0; + padding: 0; + list-style: none; + position: absolute; + z-index: 10000; + border: 1px solid #5b9dd9; + background-color: #fff; +} + +.wp-customizer .ac_results { + z-index: 500000; +} + +.ac_results li { + margin: 0; + padding: 5px 10px; + white-space: nowrap; + text-align: left; +} + +.ac_results .ac_over, +.ac_over .ac_match { + background-color: #0073aa; + color: #fff; + cursor: pointer; +} + +.ac_match { + text-decoration: underline; +} + +#edittag { + max-width: 800px; +} + +.edit-tag-actions { + margin-top: 20px; + overflow: hidden; + padding: 10px; + margin-right: 10px; +} + +/* Comments */ + +.comment-php .wp-editor-area { + height: 200px; +} + +.comment-ays th, +.comment-ays td { + padding: 10px 15px; +} + +.comment-ays .comment-content ul { + list-style: initial; + margin-left: 2em; +} + +.comment-ays .comment-content a[href]:after { + content: '(' attr( href ) ')'; + display: inline-block; + padding: 0 4px; + color: #72777C; + font-size: 13px; + word-break: break-all; +} + +.comment-ays .comment-content p.edit-comment { + margin-top: 10px; +} + +.comment-ays .comment-content p.edit-comment a[href]:after { + content: ''; + padding: 0; +} + +.comment-ays-submit .button-cancel { + margin-left: 1em; +} + +.trash-undo-inside, +.spam-undo-inside { + margin: 1px 8px 1px 0; + line-height: 16px; +} + +.spam-undo-inside .avatar, +.trash-undo-inside .avatar { + height: 20px; + width: 20px; + margin-right: 8px; + vertical-align: middle; +} + +.stuffbox .editcomment { + clear: none; +} + +#comment-status-radio p { + margin: 3px 0 5px; +} + +#comment-status-radio input { + margin: 2px 3px 5px 0; + vertical-align: middle; +} + +#comment-status-radio label { + padding: 5px 0; +} + +/* links tables */ +table.links-table { + width: 100%; + border-spacing: 0; +} + +.links-table th { + font-weight: 400; + text-align: left; + vertical-align: top; + min-width: 80px; + width: 20%; + word-wrap: break-word; +} + +.links-table th, +.links-table td { + padding: 5px 0; +} + +.links-table td label { + margin-right: 8px; +} + +.links-table td input[type="text"], +.links-table td textarea { + width: 100%; +} + +.links-table #link_rel { + max-width: 280px; +} + +/* DFW 2 +-------------------------------------------------------------- */ + +#wp-content-wrap .mce-wp-dfw, +#qt_content_dfw { + display: none; +} + +.wp-editor-expand #wp-content-wrap .mce-wp-dfw, +.wp-editor-expand #qt_content_dfw { + display: inline-block; +} + +.focus-on .wrap > h1, +.focus-on .page-title-action, +.focus-on #wpfooter, +.focus-on .postbox-container > *, +.focus-on div.updated, +.focus-on div.error, +.focus-on div.notice, +.focus-on .update-nag, +.focus-on #wp-toolbar, +.focus-on #screen-meta-links, +.focus-on #screen-meta { + opacity: 0; + transition-duration: 0.6s; + transition-property: opacity; + transition-timing-function: ease-in-out; +} + +.focus-on #wp-toolbar { + opacity: 0.3; +} + +.focus-off .wrap > h1, +.focus-off .page-title-action, +.focus-off #wpfooter, +.focus-off .postbox-container > *, +.focus-off div.updated, +.focus-off div.error, +.focus-off div.notice, +.focus-off .update-nag, +.focus-off #wp-toolbar, +.focus-off #screen-meta-links, +.focus-off #screen-meta { + opacity: 1; + transition-duration: 0.2s; + transition-property: opacity; + transition-timing-function: ease-in-out; +} + +.focus-off #wp-toolbar { + -webkit-transform: translate(0, 0); +} + +.focus-on #adminmenuback, +.focus-on #adminmenuwrap { + transition-duration: 0.6s; + transition-property: -webkit-transform; + transition-property: transform; + transition-property: transform, -webkit-transform; + transition-timing-function: ease-in-out; +} + +.focus-on #adminmenuback, +.focus-on #adminmenuwrap { + -webkit-transform: translateX( -100% ); + transform: translateX( -100% ); +} + +.focus-off #adminmenuback, +.focus-off #adminmenuwrap { + -webkit-transform: translateX( 0 ); + transform: translateX( 0 ); + transition-duration: 0.2s; + transition-property: -webkit-transform; + transition-property: transform; + transition-property: transform, -webkit-transform; + transition-timing-function: ease-in-out; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + #content-resize-handle, + #post-body .wp_themeSkin .mceStatusbar a.mceResize { + background: transparent url(../images/resize-2x.gif) no-repeat scroll right bottom; + background-size: 11px 11px; + } + + /*rtl:ignore*/ + .rtl #content-resize-handle, + .rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize { + background-image: url(../images/resize-rtl-2x.gif); + background-position: left bottom; + } +} + +/* one column on the post write/edit screen */ +@media only screen and (max-width: 850px) { + #poststuff { + min-width: 0; + } + + #wpbody-content #poststuff #post-body { + margin: 0; + } + + #wpbody-content #post-body.columns-2 #postbox-container-1 { + margin-right: 0; + width: 100%; + } + + #poststuff #postbox-container-1 .empty-container, + #poststuff #postbox-container-1 #side-sortables:empty { + border: 0 none; + height: 0; + min-height: 0; + } + + #poststuff #post-body.columns-2 #side-sortables { + min-height: 0; + width: auto; + } + + /* hide the radio buttons for column prefs */ + .screen-layout, + .columns-prefs { + display: none; + } +} + +@media screen and ( max-width: 782px ) { + .wp-core-ui .edit-tag-actions .button-primary { + margin-bottom: 0; + } + + #post-body-content { + min-width: 0; + } + + #titlediv #title-prompt-text { + padding: 10px 10px; + } + + #poststuff h3.hndle, /* Back-compat for pre-4.4 */ + #poststuff .stuffbox > h3, /* Back-compat for pre-4.4 */ + #poststuff h2 { + padding: 12px; + } + + .post-format-options { + padding-right: 0; + } + + .post-format-options a { + margin-right: 5px; + margin-bottom: 5px; + min-width: 52px; + } + + .post-format-options .post-format-title { + font-size: 11px; + } + + .post-format-options a div { + height: 28px; + width: 28px; + } + + .post-format-options a div:before { + font-size: 26px !important; + } + + /* Publish Metabox Options */ + #post-visibility-select { + line-height: 280%; + } + + .wp-core-ui .save-post-visibility, + .wp-core-ui .save-timestamp { + vertical-align: middle; + margin-right: 15px; + } + + .timestamp-wrap select#mm { + display: block; + width: 100%; + margin-bottom: 10px; + } + + .timestamp-wrap #jj, + .timestamp-wrap #aa, + .timestamp-wrap #hh, + .timestamp-wrap #mn { + padding: 12px 3px; + font-size: 14px; + margin-bottom: 5px; + width: auto; + text-align: center; + } + + /* Categories Metabox */ + ul.category-tabs { + margin: 30px 0 15px; + } + + ul.category-tabs li.tabs { + padding: 15px; + } + + ul.categorychecklist li { + margin-bottom: 15px; + } + + ul.categorychecklist ul { + margin-top: 15px; + } + + .category-add input[type=text], + .category-add select { + max-width: none; + margin-bottom: 15px; + } + + /* Tags Metabox */ + .tagsdiv .newtag { + width: 100%; + height: auto; + margin-bottom: 15px; + } + + .tagchecklist { + margin: 25px 10px; + } + + .tagchecklist > li { + font-size: 16px; + line-height: 1.4; + } + + /* Discussion */ + #commentstatusdiv p { + line-height: 2.8; + } + + /* TinyMCE Adjustments */ + .mceToolbar * { + white-space: normal !important; + } + + .mceToolbar tr, + .mceToolbar td { + float: left !important; + } + + .wp_themeSkin a.mceButton { + width: 30px; + height: 30px; + } + + .wp_themeSkin .mceButton .mceIcon { + margin-top: 5px; + margin-left: 5px; + } + + .wp_themeSkin .mceSplitButton { + margin-top: 1px; + } + + .wp_themeSkin .mceSplitButton td a.mceAction { + padding-top: 6px; + padding-bottom: 6px; + padding-left: 6px; + padding-right: 3px; + } + + .wp_themeSkin .mceSplitButton td a.mceOpen, + .wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen { + padding-top: 6px; + padding-bottom: 6px; + background-position: 1px 6px; + } + + .wp_themeSkin table.mceListBox { + margin: 5px; + } + + div.quicktags-toolbar input { + padding: 10px 20px; + } + + button.wp-switch-editor { + font-size: 16px; + line-height: 1em; + margin: 7px 0 0 7px; + padding: 8px 12px; + } + + #wp-content-media-buttons a { + font-size: 14px; + padding: 6px 10px; + } + + .wp-media-buttons span.wp-media-buttons-icon, + .wp-media-buttons span.jetpack-contact-form-icon { + width: 22px !important; + margin-left: -2px !important; + } + + .wp-media-buttons .add_media span.wp-media-buttons-icon:before, + .wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before { + font-size: 20px !important; + } + + #content_wp_fullscreen { + display: none; + } + + .misc-pub-section { + padding: 20px 10px 20px; + } + + .misc-pub-section > a { + float: right; + font-size: 16px; + } + + #delete-action, + #publishing-action { + line-height: 47px; + } + + #publishing-action .spinner { + float: none; + margin-top: -2px; /* Half of the Publish button's bottom margin. */ + } + + /* Moderate Comment */ + .comment-ays th, + .comment-ays td { + padding-bottom: 0; + } + + .comment-ays td { + padding-top: 6px; + } + + /* Links */ + .links-table #link_rel { + max-width: none; + } + + .links-table th, + .links-table td { + padding: 10px 0; + } + + .privacy-text-box { + width: auto; + } + + .privacy-text-box-toc { + float: none; + width: auto; + height: 100%; + } + + .privacy-text-section a.return-to-top { + float: none; + margin: 0; + } +} diff --git a/backend/wp-admin/css/edit.min.css b/backend/wp-admin/css/edit.min.css new file mode 100644 index 0000000..b8e1519 --- /dev/null +++ b/backend/wp-admin/css/edit.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#pending,#poststuff #titlewrap{border:0;padding:0}#pending,#poststuff #post-body{padding:0}#editable-post-name-full,body.post-new-php .submitbox .submitdelete{display:none}#post-status-info,.postbox{box-shadow:0 1px 1px rgba(0,0,0,.04)}#titlediv,#wp-content-editor-container,.postbox,form#tags-filter{position:relative}#poststuff{padding-top:10px;min-width:763px}#poststuff .postbox-container{width:100%}#poststuff #post-body.columns-2{margin-right:300px}#show-comments{overflow:hidden}#save-action .spinner,#show-comments a{float:left}#show-comments .spinner{float:none;margin-top:0}#lost-connection-notice .spinner{visibility:visible;float:left;margin:0 5px 0 0}#titlediv label{cursor:text}#titlediv div.inside{margin:0}#titlediv #title{padding:3px 8px;font-size:1.7em;line-height:100%;height:1.7em;width:100%;outline:0;margin:0 0 3px;background-color:#fff}#titlediv #title-prompt-text{color:#72777c;position:absolute;font-size:1.7em;padding:11px 10px}input#link_description,input#link_url{width:98%}#pending{background:0 none;font-size:11px;margin-top:-1px}#comment-link-box,#edit-slug-box{line-height:24px;min-height:25px;margin-top:5px;padding:0 10px;color:#666}#edit-slug-box .cancel{margin-right:10px;padding:0;font-size:11px}#comment-link-box{margin:5px 0;padding:0 5px}#editable-post-name{font-weight:600}#editable-post-name input{font-size:13px;font-weight:400;height:24px;margin:0;width:16em}.postarea h3 label{float:left}.submitbox .submit a:hover{text-decoration:underline}.submitbox .submit input{margin-bottom:8px;margin-right:4px;padding:6px}#post-status-select{margin-top:3px}#post-body #normal-sortables{min-height:50px}.postbox{min-width:255px;border:1px solid #e5e5e5;background:#fff}#trackback_url{width:99%}#normal-sortables .postbox .submit{background:0 0;border:0;float:right;padding:0 12px;margin:0}.category-add input[type=text],.category-add select{width:100%;max-width:260px;vertical-align:baseline}#side-sortables .category-add input[type=text],#side-sortables .category-add select{margin:0 0 1em}#side-sortables .add-menu-item-tabs li,.wp-tab-bar li,ul.category-tabs li{display:inline;line-height:1.35em}.no-js .category-tabs li.hide-if-no-js{display:none}#side-sortables .add-menu-item-tabs a,.category-tabs a,.wp-tab-bar a{text-decoration:none}#post-body ul.add-menu-item-tabs li.tabs a,#post-body ul.category-tabs li.tabs a,#side-sortables .add-menu-item-tabs .tabs a,#side-sortables .category-tabs .tabs a,.wp-tab-bar .wp-tab-active a{color:#32373c}.category-tabs{margin:8px 0 5px}#category-adder h4{margin:0}.taxonomy-add-new{display:inline-block;margin:10px 0;font-weight:600}#side-sortables .add-menu-item-tabs,.wp-tab-bar{margin-bottom:3px}#normal-sortables .postbox #replyrow .submit{float:none;margin:0;padding:5px 7px 10px;overflow:hidden}#side-sortables .submitbox .submit .preview,#side-sortables .submitbox .submit a.preview:hover,#side-sortables .submitbox .submit input{border:0}ul.add-menu-item-tabs,ul.category-tabs,ul.wp-tab-bar{margin-top:12px}ul.add-menu-item-tabs li,ul.category-tabs li{border:1px solid transparent;position:relative}.wp-tab-active,ul.add-menu-item-tabs li.tabs,ul.category-tabs li.tabs{border:1px solid #ddd;border-bottom-color:#fdfdfd;background-color:#fdfdfd}ul.add-menu-item-tabs li,ul.category-tabs li,ul.wp-tab-bar li{padding:3px 5px 6px}#set-post-thumbnail{display:inline-block;max-width:100%}.ui-tabs-hide,.wp-editor-expand #content-resize-handle,.wp-hidden-children .wp-hidden-child{display:none}#postimagediv .inside img{max-width:100%;height:auto;width:auto;vertical-align:top;background-image:linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:0 0,10px 10px;background-size:20px 20px}#post-body .tagsdiv #newtag{margin-right:5px;width:16em}#side-sortables input#post_password{width:94%}#side-sortables .tagsdiv #newtag{width:68%}#post-status-info{width:100%;border-spacing:0;border:1px solid #e5e5e5;border-top:none;background-color:#f7f7f7;z-index:999}#post-status-info td{font-size:12px}.autosave-info{padding:2px 10px;text-align:right}#editorcontent #post-status-info{border:none}#content-resize-handle{background:url(../images/resize.gif) right bottom no-repeat;width:12px;cursor:row-resize}.rtl #content-resize-handle{background-image:url(../images/resize-rtl.gif);background-position:left bottom}#postdivrich #content{resize:none}#wp-word-count{display:block;padding:2px 10px}.wp-editor-expand #wp-content-editor-tools{z-index:1000;border-bottom:1px solid #e5e5e5}.wp-editor-expand #wp-content-editor-container{box-shadow:none;margin-top:-1px;border-bottom:0 none}.wp-editor-expand div.mce-statusbar{z-index:1}.wp-editor-expand #post-status-info{border-top:1px solid #e5e5e5}.wp-editor-expand div.mce-toolbar-grp{z-index:999}.mce-fullscreen #wp-content-wrap .mce-edit-area,.mce-fullscreen #wp-content-wrap .mce-menubar,.mce-fullscreen #wp-content-wrap .mce-statusbar,.mce-fullscreen #wp-content-wrap .mce-toolbar-grp{position:static!important;width:auto!important;padding:0!important}.mce-fullscreen #wp-content-wrap .mce-statusbar{visibility:visible!important}.mce-fullscreen #wp-content-wrap .mce-tinymce .mce-wp-dfw,.mce-fullscreen #wp-content-wrap .mce-wp-dfw,.post-php.mce-fullscreen #wpadminbar{display:none}#wp-content-editor-tools{background-color:#f1f1f1;padding-top:20px}#poststuff #post-body.columns-2 #side-sortables{width:280px}#timestampdiv select{height:21px;line-height:14px;padding:0;vertical-align:top;font-size:12px}#aa,#hh,#jj,#mn{padding:1px;font-size:12px}#hh,#jj,#mn{width:2em}#aa{width:3.4em}.curtime #timestamp{padding:2px 0 1px;display:inline!important;height:auto!important}#post-body #visibility:before,#post-body .misc-pub-post-status:before,#post-body .misc-pub-revisions:before,.curtime #timestamp:before,span.wp-media-buttons-icon:before{color:#82878c}#post-body #visibility:before,#post-body .misc-pub-post-status:before,#post-body .misc-pub-revisions:before,.curtime #timestamp:before{font:400 20px/1 dashicons;speak:none;display:inline-block;margin-left:-1px;padding-right:3px;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.suggested-policy-content,.wp-suggested-text p{font-style:italic}#post-body .misc-pub-post-status:before{content:"\f173"}#post-body #visibility:before{content:"\f177"}.curtime #timestamp:before{content:"\f145";position:relative;top:-1px}#post-body .misc-pub-revisions:before{content:"\f321"}#timestampdiv{padding-top:5px;line-height:23px}#timestampdiv p{margin:8px 0 6px}#timestampdiv input{border-width:1px;border-style:solid}.notification-dialog{position:fixed;top:30%;max-height:70%;left:50%;width:450px;margin-left:-225px;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);line-height:1.5;z-index:1000005;overflow-y:auto}.notification-dialog-background{position:fixed;top:0;left:0;right:0;bottom:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:1000000}#post-lock-dialog .post-locked-message,#post-lock-dialog .post-taken-over{margin:25px}#file-editor-warning .button,#post-lock-dialog .post-locked-message a.button{margin-right:10px}#post-lock-dialog .post-locked-avatar{float:left;margin:0 20px 20px 0}#post-lock-dialog .wp-tab-first{outline:0}#post-lock-dialog .locked-saving img{float:left;margin-right:3px}#post-lock-dialog.saved .locked-saved,#post-lock-dialog.saving .locked-saving{display:inline}#excerpt{display:block;margin:12px 0 0;height:4em;width:100%}.tagchecklist{margin-left:14px;font-size:12px;overflow:auto}.tagchecklist br{display:none}.tagchecklist strong{margin-left:-8px;position:absolute}.tagchecklist>li{float:left;margin-right:25px;font-size:13px;line-height:1.8em;cursor:default;max-width:100%;overflow:hidden;text-overflow:ellipsis}.tagchecklist .ntdelbutton{position:absolute;width:24px;height:24px;border:none;margin:0 0 0 -19px;padding:0;background:0 0;cursor:pointer;text-indent:0}#poststuff .stuffbox>h3,#poststuff h2,#poststuff h3.hndle{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}#poststuff .inside{margin:6px 0 0}#poststuff .inside #page_template,#poststuff .inside #parent_id{max-width:100%}.ie8 #poststuff .inside #page_template,.ie8 #poststuff .inside #parent_id{width:250px}.post-attributes-label-wrapper{margin-bottom:.5em}.post-attributes-label{vertical-align:baseline;font-weight:600}#post-visibility-select{line-height:1.5em;margin-top:3px}#linksubmitdiv .inside,#poststuff #submitdiv .inside{margin:0;padding:0}#post-body-content,.edit-form-section{margin-bottom:20px}.wp-privacy-policy-guide{max-width:1000px}.privacy-text-box{width:calc(100% - 260px)}.privacy-text-box-toc{float:right;width:250px;background-color:#fff}.privacy-text-box-toc p{margin:0;padding:.7em 1em;border-bottom:1px solid #eee}.privacy-text-box-toc ol{margin-left:2em}.wp-privacy-policy-guide h3{font-size:1.2em;margin:1em 0 .5em}.privacy-text-section .privacy-text-copy{float:right}.privacy-text-section{position:relative;border-top:1px solid #e3e3e3}.privacy-text-box-head,.privacy-text-section.text-removed{padding-bottom:12px}.text-removed .policy-text{font-style:italic;color:#666;font-weight:600}.privacy-text-actions{height:32px;line-height:32px;padding-bottom:6px}.wp-privacy-policy-guide .policy-text h2{margin:1.2em 0 1em;padding:0}.privacy-text-section a.return-to-top{float:right;margin-right:-250px;margin-top:6px}.hide-privacy-policy-tutorial .privacy-policy-tutorial{visibility:hidden}.wp-suggested-text p.privacy-policy-tutorial{font-style:normal}.notice.wp-pp-notice{margin:15px 0 3px}#postcustomstuff thead th{padding:5px 8px 8px;background-color:#f1f1f1}#postcustom #postcustomstuff .submit{border:0;float:none;padding:0 8px 8px}#side-sortables #postcustom #postcustomstuff .submit{margin:0;padding:0}#side-sortables #postcustom #postcustomstuff #the-list textarea{height:85px}#side-sortables #postcustom #postcustomstuff td.left input,#side-sortables #postcustom #postcustomstuff td.left select,#side-sortables #postcustomstuff #newmetaleft a{margin:3px 3px 0}#postcustomstuff table{margin:0;width:100%;border:1px solid #ddd;border-spacing:0;background-color:#f9f9f9}#postcustomstuff tr{vertical-align:top}#postcustomstuff table input,#postcustomstuff table select,#postcustomstuff table textarea{width:96%;margin:8px}#side-sortables #postcustomstuff table input,#side-sortables #postcustomstuff table select,#side-sortables #postcustomstuff table textarea{margin:3px}#postcustomstuff td.left,#postcustomstuff th.left{width:38%}#postcustomstuff .submit input{margin:0;width:auto}#postcustomstuff #newmetaleft a{display:inline-block;margin:0 8px 8px;text-decoration:none}.no-js #postcustomstuff #enternew{display:none}#post-body-content .compat-attachment-fields{margin-bottom:20px}.compat-attachment-fields th{padding-top:5px;padding-right:10px}#select-featured-image{padding:4px 0;overflow:hidden}#select-featured-image img{max-width:100%;height:auto;margin-bottom:10px}#select-featured-image a{float:left;clear:both}#select-featured-image .remove{display:none;margin-top:10px}.js #select-featured-image.has-featured-image .remove{display:inline-block}.no-js #select-featured-image .choose{display:none}.post-state-format{overflow:hidden;display:inline-block;vertical-align:middle;height:20px;width:20px;margin-right:5px;margin-top:-4px}.post-state-format:before{display:block;height:20px;width:20px;font:400 20px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.post-format-icon:before,.post-state-format:before{color:#ddd;transition:all .1s ease-in-out}a.post-format-icon:hover:before,a.post-state-format:hover:before{color:#00a0d2}#post-formats-select{line-height:2em}#post-formats-select .post-format-icon:before{top:5px}input.post-format{margin-top:1px}label.post-format-icon{margin-left:0;padding:2px 0}.post-format-icon:before{position:relative;display:inline-block;margin-right:7px;font:400 20px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.post-format-icon.post-format-standard:before,.post-state-format.post-format-standard:before,a.post-state-format.format-standard:before{content:"\f109"}.post-format-icon.post-format-image:before,.post-state-format.post-format-image:before,a.post-state-format.format-image:before{content:"\f128"}.post-format-icon.post-format-gallery:before,.post-state-format.post-format-gallery:before,a.post-state-format.format-gallery:before{content:"\f161"}.post-format-icon.post-format-audio:before,.post-state-format.post-format-audio:before,a.post-state-format.format-audio:before{content:"\f127"}.post-format-icon.post-format-video:before,.post-state-format.post-format-video:before,a.post-state-format.format-video:before{content:"\f126"}.post-format-icon.post-format-chat:before,.post-state-format.post-format-chat:before,a.post-state-format.format-chat:before{content:"\f125"}.post-format-icon.post-format-status:before,.post-state-format.post-format-status:before,a.post-state-format.format-status:before{content:"\f130"}.post-format-icon.post-format-aside:before,.post-state-format.post-format-aside:before,a.post-state-format.format-aside:before{content:"\f123"}.post-format-icon.post-format-quote:before,.post-state-format.post-format-quote:before,a.post-state-format.format-quote:before{content:"\f122"}.post-format-icon.post-format-link:before,.post-state-format.post-format-link:before,a.post-state-format.format-link:before{content:"\f103"}.category-adder{margin-left:120px;padding:4px 0}.category-adder h4{margin:0 0 8px}#side-sortables .category-adder{margin:0}.categorydiv div.tabs-panel,.customlinkdiv div.tabs-panel,.posttypediv div.tabs-panel,.taxonomydiv div.tabs-panel,.wp-tab-panel{min-height:42px;max-height:200px;overflow:auto;padding:0 .9em;border:1px solid #ddd;background-color:#fdfdfd}div.tabs-panel-active{display:block}div.tabs-panel-inactive{display:none}#front-page-warning,#front-static-pages ul,.categorydiv ul.categorychecklist ul,.customlinkdiv ul.categorychecklist ul,.inline-editor ul.cat-checklist ul,.posttypediv ul.categorychecklist ul,.taxonomydiv ul.categorychecklist ul,ul.export-filters{margin-left:18px}ul.categorychecklist li{margin:0;padding:0;line-height:22px;word-wrap:break-word}.categorydiv .tabs-panel,.customlinkdiv .tabs-panel,.posttypediv .tabs-panel,.taxonomydiv .tabs-panel{border-width:3px;border-style:solid}.form-wrap label{display:block;padding:2px 0}.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field input[type=number],.form-field input[type=search],.form-field input[type=tel],.form-field input[type=url],.form-field textarea{border-style:solid;border-width:1px;width:95%}.form-wrap p,p.description{margin:2px 0 5px;color:#666}.form-wrap p,p.description,p.help,span.description{font-size:13px;font-style:italic}.form-wrap .form-field{margin:1em 0;padding:0}.form-wrap .form-field #parent{max-width:100%}.col-wrap h2{margin:12px 0;font-size:1.1em}.col-wrap p.submit{margin-top:-10px}.edit-term-notes{margin-top:2em}#poststuff .tagsdiv .howto{margin:0 0 6px}.ajaxtag .newtag{position:relative}.tagsdiv .newtag{width:180px}.tagsdiv .the-tags{display:block;height:60px;margin:0 auto;overflow:auto;width:260px}#post-body-content .tagsdiv .the-tags{margin:0 5px}p.popular-tags{border:none;line-height:2em;padding:8px 12px 12px;text-align:justify}p.popular-tags a{padding:0 3px}.tagcloud{width:97%;margin:0 0 40px;text-align:justify}.tagcloud h2{margin:2px 0 12px}.the-tagcloud ul{margin:0}.the-tagcloud ul li{display:inline-block}.ac_results{display:none;margin:-1px 0 0;padding:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;background-color:#fff}.wp-customizer .ac_results{z-index:500000}.ac_results li{margin:0;padding:5px 10px;white-space:nowrap;text-align:left}.ac_over .ac_match,.ac_results .ac_over{background-color:#0073aa;color:#fff;cursor:pointer}.ac_match{text-decoration:underline}#edittag{max-width:800px}.edit-tag-actions{margin-top:20px;overflow:hidden;padding:10px;margin-right:10px}.comment-php .wp-editor-area{height:200px}.comment-ays td,.comment-ays th{padding:10px 15px}.comment-ays .comment-content ul{list-style:outside;margin-left:2em}.comment-ays .comment-content a[href]:after{content:'(' attr(href) ')';display:inline-block;padding:0 4px;color:#72777C;font-size:13px;word-break:break-all}.comment-ays .comment-content p.edit-comment{margin-top:10px}.comment-ays .comment-content p.edit-comment a[href]:after{content:'';padding:0}#comment-status-radio label,.links-table td,.links-table th{padding:5px 0}.comment-ays-submit .button-cancel{margin-left:1em}.spam-undo-inside,.trash-undo-inside{margin:1px 8px 1px 0;line-height:16px}.spam-undo-inside .avatar,.trash-undo-inside .avatar{height:20px;width:20px;margin-right:8px;vertical-align:middle}.stuffbox .editcomment{clear:none}#comment-status-radio p{margin:3px 0 5px}#comment-status-radio input{margin:2px 3px 5px 0;vertical-align:middle}table.links-table{width:100%;border-spacing:0}.links-table th{font-weight:400;text-align:left;vertical-align:top;min-width:80px;width:20%;word-wrap:break-word}.links-table td label{margin-right:8px}.links-table td input[type=text],.links-table td textarea{width:100%}.links-table #link_rel{max-width:280px}#qt_content_dfw,#wp-content-wrap .mce-wp-dfw{display:none}.wp-editor-expand #qt_content_dfw,.wp-editor-expand #wp-content-wrap .mce-wp-dfw{display:inline-block}.focus-on #screen-meta,.focus-on #screen-meta-links,.focus-on #wp-toolbar,.focus-on #wpfooter,.focus-on .page-title-action,.focus-on .postbox-container>*,.focus-on .update-nag,.focus-on .wrap>h1,.focus-on div.error,.focus-on div.notice,.focus-on div.updated{opacity:0;transition-duration:.6s;transition-property:opacity;transition-timing-function:ease-in-out}.focus-on #wp-toolbar{opacity:.3}.focus-off #screen-meta,.focus-off #screen-meta-links,.focus-off #wp-toolbar,.focus-off #wpfooter,.focus-off .page-title-action,.focus-off .postbox-container>*,.focus-off .update-nag,.focus-off .wrap>h1,.focus-off div.error,.focus-off div.notice,.focus-off div.updated{opacity:1;transition-duration:.2s;transition-property:opacity;transition-timing-function:ease-in-out}.focus-off #wp-toolbar{-webkit-transform:translate(0,0)}.focus-on #adminmenuback,.focus-on #adminmenuwrap{transition-duration:.6s;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform;transition-timing-function:ease-in-out;-webkit-transform:translateX(-100%);transform:translateX(-100%)}.focus-off #adminmenuback,.focus-off #adminmenuwrap{-webkit-transform:translateX(0);transform:translateX(0);transition-duration:.2s;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform;transition-timing-function:ease-in-out}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#content-resize-handle,#post-body .wp_themeSkin .mceStatusbar a.mceResize{background:url(../images/resize-2x.gif) right bottom no-repeat;background-size:11px 11px}.rtl #content-resize-handle,.rtl #post-body .wp_themeSkin .mceStatusbar a.mceResize{background-image:url(../images/resize-rtl-2x.gif);background-position:left bottom}}@media only screen and (max-width:850px){#poststuff{min-width:0}#wpbody-content #poststuff #post-body{margin:0}#wpbody-content #post-body.columns-2 #postbox-container-1{margin-right:0;width:100%}#poststuff #postbox-container-1 #side-sortables:empty,#poststuff #postbox-container-1 .empty-container{border:0;height:0;min-height:0}#poststuff #post-body.columns-2 #side-sortables{min-height:0;width:auto}.columns-prefs,.screen-layout{display:none}}@media screen and (max-width:782px){.wp-core-ui .edit-tag-actions .button-primary{margin-bottom:0}#post-body-content{min-width:0}#titlediv #title-prompt-text{padding:10px}#poststuff .stuffbox>h3,#poststuff h2,#poststuff h3.hndle{padding:12px}.post-format-options{padding-right:0}.post-format-options a{margin-right:5px;margin-bottom:5px;min-width:52px}.post-format-options .post-format-title{font-size:11px}.post-format-options a div{height:28px;width:28px}.post-format-options a div:before{font-size:26px!important}#post-visibility-select{line-height:280%}.wp-core-ui .save-post-visibility,.wp-core-ui .save-timestamp{vertical-align:middle;margin-right:15px}.timestamp-wrap select#mm{display:block;width:100%;margin-bottom:10px}.timestamp-wrap #aa,.timestamp-wrap #hh,.timestamp-wrap #jj,.timestamp-wrap #mn{padding:12px 3px;font-size:14px;margin-bottom:5px;width:auto;text-align:center}ul.category-tabs{margin:30px 0 15px}.tagsdiv .newtag,ul.categorychecklist li{margin-bottom:15px}ul.category-tabs li.tabs{padding:15px}ul.categorychecklist ul{margin-top:15px}.category-add input[type=text],.category-add select{max-width:none;margin-bottom:15px}.tagsdiv .newtag{width:100%;height:auto}.tagchecklist{margin:25px 10px}.tagchecklist>li{font-size:16px;line-height:1.4}#commentstatusdiv p{line-height:2.8}.mceToolbar *{white-space:normal!important}.mceToolbar td,.mceToolbar tr{float:left!important}.wp_themeSkin a.mceButton{width:30px;height:30px}.wp_themeSkin .mceButton .mceIcon{margin-top:5px;margin-left:5px}.wp_themeSkin .mceSplitButton{margin-top:1px}.wp_themeSkin .mceSplitButton td a.mceAction{padding:6px 3px 6px 6px}.wp_themeSkin .mceSplitButton td a.mceOpen,.wp_themeSkin .mceSplitButtonEnabled:hover td a.mceOpen{padding-top:6px;padding-bottom:6px;background-position:1px 6px}.wp_themeSkin table.mceListBox{margin:5px}div.quicktags-toolbar input{padding:10px 20px}button.wp-switch-editor{font-size:16px;line-height:1em;margin:7px 0 0 7px;padding:8px 12px}#wp-content-media-buttons a{font-size:14px;padding:6px 10px}.wp-media-buttons span.jetpack-contact-form-icon,.wp-media-buttons span.wp-media-buttons-icon{width:22px!important;margin-left:-2px!important}.wp-media-buttons #insert-jetpack-contact-form span.jetpack-contact-form-icon:before,.wp-media-buttons .add_media span.wp-media-buttons-icon:before{font-size:20px!important}#content_wp_fullscreen{display:none}.misc-pub-section{padding:20px 10px}.misc-pub-section>a{float:right;font-size:16px}#delete-action,#publishing-action{line-height:47px}#publishing-action .spinner{float:none;margin-top:-2px}.comment-ays td,.comment-ays th{padding-bottom:0}.comment-ays td{padding-top:6px}.links-table #link_rel{max-width:none}.links-table td,.links-table th{padding:10px 0}.privacy-text-box{width:auto}.privacy-text-box-toc{float:none;width:auto;height:100%}.privacy-text-section a.return-to-top{float:none;margin:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/farbtastic-rtl.css b/backend/wp-admin/css/farbtastic-rtl.css new file mode 100644 index 0000000..b7aebad --- /dev/null +++ b/backend/wp-admin/css/farbtastic-rtl.css @@ -0,0 +1,41 @@ + +.farbtastic { + position: relative; +} + +.farbtastic * { + position: absolute; + cursor: crosshair; +} + +.farbtastic, +.farbtastic .wheel { + width: 195px; + height: 195px; +} + +.farbtastic .color, +.farbtastic .overlay { + top: 47px; + right: 47px; + width: 101px; + height: 101px; +} + +.farbtastic .wheel { + background: url(../images/wheel.png) no-repeat; + width: 195px; + height: 195px; +} + +.farbtastic .overlay { + background: url(../images/mask.png) no-repeat; +} + +.farbtastic .marker { + width: 17px; + height: 17px; + margin: -8px -8px 0 0; + overflow: hidden; + background: url(../images/marker.png) no-repeat; +} diff --git a/backend/wp-admin/css/farbtastic-rtl.min.css b/backend/wp-admin/css/farbtastic-rtl.min.css new file mode 100644 index 0000000..26cc0c4 --- /dev/null +++ b/backend/wp-admin/css/farbtastic-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.farbtastic{position:relative}.farbtastic *{position:absolute;cursor:crosshair}.farbtastic,.farbtastic .wheel{width:195px;height:195px}.farbtastic .color,.farbtastic .overlay{top:47px;right:47px;width:101px;height:101px}.farbtastic .wheel{background:url(../images/wheel.png) no-repeat;width:195px;height:195px}.farbtastic .overlay{background:url(../images/mask.png) no-repeat}.farbtastic .marker{width:17px;height:17px;margin:-8px -8px 0 0;overflow:hidden;background:url(../images/marker.png) no-repeat} \ No newline at end of file diff --git a/backend/wp-admin/css/farbtastic.css b/backend/wp-admin/css/farbtastic.css new file mode 100644 index 0000000..2bb73bf --- /dev/null +++ b/backend/wp-admin/css/farbtastic.css @@ -0,0 +1,41 @@ + +.farbtastic { + position: relative; +} + +.farbtastic * { + position: absolute; + cursor: crosshair; +} + +.farbtastic, +.farbtastic .wheel { + width: 195px; + height: 195px; +} + +.farbtastic .color, +.farbtastic .overlay { + top: 47px; + left: 47px; + width: 101px; + height: 101px; +} + +.farbtastic .wheel { + background: url(../images/wheel.png) no-repeat; + width: 195px; + height: 195px; +} + +.farbtastic .overlay { + background: url(../images/mask.png) no-repeat; +} + +.farbtastic .marker { + width: 17px; + height: 17px; + margin: -8px 0 0 -8px; + overflow: hidden; + background: url(../images/marker.png) no-repeat; +} diff --git a/backend/wp-admin/css/farbtastic.min.css b/backend/wp-admin/css/farbtastic.min.css new file mode 100644 index 0000000..e276808 --- /dev/null +++ b/backend/wp-admin/css/farbtastic.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.farbtastic{position:relative}.farbtastic *{position:absolute;cursor:crosshair}.farbtastic,.farbtastic .wheel{width:195px;height:195px}.farbtastic .color,.farbtastic .overlay{top:47px;left:47px;width:101px;height:101px}.farbtastic .wheel{background:url(../images/wheel.png) no-repeat;width:195px;height:195px}.farbtastic .overlay{background:url(../images/mask.png) no-repeat}.farbtastic .marker{width:17px;height:17px;margin:-8px 0 0 -8px;overflow:hidden;background:url(../images/marker.png) no-repeat} \ No newline at end of file diff --git a/backend/wp-admin/css/forms-rtl.css b/backend/wp-admin/css/forms-rtl.css new file mode 100644 index 0000000..dff8430 --- /dev/null +++ b/backend/wp-admin/css/forms-rtl.css @@ -0,0 +1,1592 @@ +/* Include margin and padding in the width calculation of input and textarea. */ +input, +textarea { + box-sizing: border-box; +} + +input[type="text"], +input[type="password"], +input[type="checkbox"], +input[type="color"], +input[type="date"], +input[type="datetime"], +input[type="datetime-local"], +input[type="email"], +input[type="month"], +input[type="number"], +input[type="search"], +input[type="radio"], +input[type="tel"], +input[type="text"], +input[type="time"], +input[type="url"], +input[type="week"], +select, +textarea { + border: 1px solid #ddd; + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 ); + background-color: #fff; + color: #32373c; + outline: none; + transition: 0.05s border-color ease-in-out; +} + +input[type="text"]:focus, +input[type="password"]:focus, +input[type="color"]:focus, +input[type="date"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="email"]:focus, +input[type="month"]:focus, +input[type="number"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="text"]:focus, +input[type="time"]:focus, +input[type="url"]:focus, +input[type="week"]:focus, +input[type="checkbox"]:focus, +input[type="radio"]:focus, +select:focus, +textarea:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +/* rtl:ignore */ +input[type="email"], +input[type="url"] { + direction: ltr; +} + +/* Vertically align the number selector with the input. */ +input[type="number"] { + height: 28px; + line-height: 1; +} + +input[type="checkbox"], +input[type="radio"] { + border: 1px solid #b4b9be; + background: #fff; + color: #555; + clear: none; + cursor: pointer; + display: inline-block; + line-height: 0; + height: 16px; + margin: -4px 0 0 4px; + outline: 0; + padding: 0 !important; + text-align: center; + vertical-align: middle; + width: 16px; + min-width: 16px; + -webkit-appearance: none; + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.1 ); + transition: .05s border-color ease-in-out; +} + +input[type="radio"]:checked + label:before { + color: #82878c; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #00a0d2; +} + +td > input[type="checkbox"], +.wp-admin p input[type="checkbox"], +.wp-admin p input[type="radio"] { + margin-top: 0; +} + +.wp-admin p label input[type="checkbox"] { + margin-top: -4px; +} + +.wp-admin p label input[type="radio"] { + margin-top: -2px; +} + +input[type="radio"] { + border-radius: 50%; + margin-left: 4px; + line-height: 10px; +} + +input[type="checkbox"]:checked:before, +input[type="radio"]:checked:before { + float: right; + display: inline-block; + vertical-align: middle; + width: 16px; + font: normal 21px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +input[type="checkbox"]:checked:before { + content: "\f147"; + margin: -3px -4px 0 0; + color: #1e8cbe; +} + +input[type="radio"]:checked:before { + content: "\2022"; + text-indent: -9999px; + border-radius: 50px; + font-size: 24px; + width: 6px; + height: 6px; + margin: 4px; + line-height: 16px; + background-color: #1e8cbe; +} + +@-moz-document url-prefix() { + input[type="checkbox"], + input[type="radio"], + .form-table input.tog { + margin-bottom: -1px; + } +} + +/* Search */ +input[type="search"] { + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-decoration { + display: none; +} + +.ie8 input[type="password"] { + font-family: sans-serif; +} + +textarea, +input, +select, +button { + font-family: inherit; + font-size: inherit; + font-weight: inherit; +} + +textarea, +input, +select { + font-size: 14px; + padding: 3px 5px; + border-radius: 0; /* Reset mobile webkit's default element styling */ +} + +textarea { + overflow: auto; + padding: 2px 6px; + line-height: 1.4; + resize: vertical; +} + +.wp-admin input[type="file"] { + padding: 3px 0; + cursor: pointer; +} + +label { + cursor: pointer; +} + +input, +select { + margin: 1px; + padding: 3px 5px; +} + +input.code { + padding-top: 6px; +} + +textarea.code { + line-height: 1.4; + padding: 4px 6px 1px 6px; +} + +input.readonly, +input[readonly], +textarea.readonly, +textarea[readonly] { + background-color: #eee; +} + +::-webkit-input-placeholder { + color: #72777c; +} + +::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +:-ms-input-placeholder { + color: #72777c; +} + +.form-invalid input, .form-invalid input:focus, +.form-invalid select, .form-invalid select:focus { + border-color: #dc3232 !important; + box-shadow: 0 0 2px rgba( 204, 0, 0, 0.8 ); +} + +.form-table .form-required.form-invalid td:after { + content: "\f534"; + font: normal 20px/1 dashicons; + color: #dc3232; + margin-right: -25px; + vertical-align: middle; +} + +/* Adjust error indicator for password layout */ +.form-table .form-required.user-pass1-wrap.form-invalid td:after { + content: ''; +} + +.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after { + content: '\f534'; + font: normal 20px/1 dashicons; + color: #dc3232; + margin: 0 -29px 0 6px; + vertical-align: middle; +} + +.form-input-tip { + color: #666; +} + +input:disabled, +input.disabled, +select:disabled, +select.disabled, +textarea:disabled, +textarea.disabled { + background: rgba( 255, 255, 255, 0.5 ); + border-color: rgba( 222, 222, 222, 0.75 ); + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.04 ); + color: rgba( 51, 51, 51, 0.5 ); +} + +input[type="file"]:disabled, +input[type="file"].disabled, +input[type="range"]:disabled, +input[type="range"].disabled { + background: none; + box-shadow: none; + cursor: default; +} + +input[type="checkbox"]:disabled, +input[type="checkbox"].disabled, +input[type="radio"]:disabled, +input[type="radio"].disabled, +input[type="checkbox"]:disabled:checked:before, +input[type="checkbox"].disabled:checked:before, +input[type="radio"]:disabled:checked:before, +input[type="radio"].disabled:checked:before { + opacity: 0.7; +} + +/*------------------------------------------------------------------------------ + 2.0 - Forms +------------------------------------------------------------------------------*/ + + +.wp-admin select { + padding: 2px; + line-height: 28px; + height: 28px; + vertical-align: middle; +} + +.wp-admin .button-cancel { + padding: 0 5px; + line-height: 2; +} + +.meta-box-sortables select { + max-width: 100%; +} + +.wp-admin select[multiple] { + height: auto; +} + +.submit { + padding: 1.5em 0; + margin: 5px 0; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; + border: none; +} + +form p.submit a.cancel:hover { + text-decoration: none; +} + +p.submit { + text-align: right; + max-width: 100%; + margin-top: 20px; + padding-top: 10px; +} + +.textright p.submit { + border: none; + text-align: left; +} + +table.form-table + p.submit, +table.form-table + input + p.submit, +table.form-table + input + input + p.submit { + border-top: none; + padding-top: 0; +} + +#minor-publishing-actions input, +#major-publishing-actions input, +#minor-publishing-actions .preview { + text-align: center; +} + +textarea.all-options, +input.all-options { + width: 250px; +} + +input.large-text, +textarea.large-text { + width: 99%; +} + +.regular-text { + width: 25em; +} + +input.small-text { + width: 50px; + padding: 1px 6px; +} + +input[type="number"].small-text { + width: 65px; +} + +input.tiny-text { + width: 35px; +} + +input[type="number"].tiny-text { + width: 45px; +} + +#doaction, +#doaction2, +#post-query-submit { + margin: 1px 0 0 8px; +} + +.tablenav #changeit, +.tablenav #delete_all, +.tablenav #clear-recent-list, +.wp-filter #delete_all { + margin-top: 1px; +} + +.tablenav .actions select { + float: right; + margin-left: 6px; + max-width: 200px; +} + +.ie8 .tablenav .actions select { + width: 155px; +} + +.ie8 .tablenav .actions select#cat { + width: 200px; +} + +#timezone_string option { + margin-right: 1em; +} + +button.wp-hide-pw > .dashicons { + position: relative; + top: 3px; +} + +label, +#your-profile label + a { + vertical-align: middle; +} + +fieldset label, +#your-profile label + a { + vertical-align: middle; +} + +.options-media-php [for*="_size_"] { + min-width: 10em; + vertical-align: baseline; +} + +.options-media-php .small-text[name*="_size_"] { + margin: 0 0 1em; +} + +#misc-publishing-actions label { + vertical-align: baseline; +} + +#pass-strength-result { + background-color: #eee; + border: 1px solid #ddd; + color: #23282d; + margin: -2px 1px 5px 5px; + padding: 3px 5px; + text-align: center; + width: 25em; + box-sizing: border-box; + opacity: 0; +} + +#pass-strength-result.short { + background-color: #f1adad; + border-color: #e35b5b; + opacity: 1; +} + +#pass-strength-result.bad { + background-color: #fbc5a9; + border-color: #f78b53; + opacity: 1; +} + +#pass-strength-result.good { + background-color: #ffe399; + border-color: #ffc733; + opacity: 1; +} + +#pass-strength-result.strong { + background-color: #c1e1b9; + border-color: #83c373; + opacity: 1; +} + +#pass1.short, #pass1-text.short { + border-color: #e35b5b; +} + +#pass1.bad, #pass1-text.bad { + border-color: #f78b53; +} + +#pass1.good, #pass1-text.good { + border-color: #ffc733; +} + +#pass1.strong, #pass1-text.strong { + border-color: #83c373; +} + +.pw-weak { + display:none; +} + +.indicator-hint { + padding-top: 8px; +} + +#pass1-text, +.show-password #pass1 { + display: none; +} + +.show-password #pass1-text +{ + display: inline-block; +} + +.form-table span.description.important { + font-size: 12px; +} + +p.search-box { + float: left; + margin: 0; +} + +.network-admin.themes-php p.search-box { + clear: right; +} + +.search-box input[name="s"], +.tablenav .search-plugins input[name="s"], +.tagsdiv .newtag { + float: right; + height: 28px; + margin: 0 0 0 4px; +} + +.js.plugins-php .search-box .wp-filter-search { + margin: 0; + width: 280px; + font-size: 16px; + font-weight: 300; + line-height: 1.5; + padding: 3px 5px; + height: 32px; +} + +input[type="text"].ui-autocomplete-loading, +input[type="email"].ui-autocomplete-loading { + background-image: url(../images/loading.gif); + background-repeat: no-repeat; + background-position: left center; + visibility: visible; +} + +input.ui-autocomplete-input.open { + border-bottom-color: transparent; +} + +ul#add-to-blog-users { + margin: 0 14px 0 0; +} + +.ui-autocomplete { + padding: 0; + margin: 0; + list-style: none; + position: absolute; + z-index: 10000; + border: 1px solid #5b9dd9; + box-shadow: 0 1px 2px rgba( 30, 140, 190, 0.8 ); + background-color: #fff; +} + +.ui-autocomplete li { + margin-bottom: 0; + padding: 4px 10px; + white-space: nowrap; + text-align: right; + cursor: pointer; +} + +/* Colors for the wplink toolbar autocomplete. */ +.ui-autocomplete .ui-state-focus { + background-color: #ddd; +} + +/* Colors for the tags autocomplete. */ +.wp-tags-autocomplete .ui-state-focus { + background-color: #0073aa; + color: #fff; +} + +/*------------------------------------------------------------------------------ + 15.0 - Comments Screen +------------------------------------------------------------------------------*/ + +.form-table { + border-collapse: collapse; + margin-top: 0.5em; + width: 100%; + clear: both; +} + +.form-table, +.form-table td, +.form-table th, +.form-table td p { + font-size: 14px; +} + +.form-table td { + margin-bottom: 9px; + padding: 15px 10px; + line-height: 1.3; + vertical-align: middle; +} + +.form-table th, +.form-wrap label { + color: #23282d; + font-weight: 400; + text-shadow: none; + vertical-align: baseline; +} + +.form-table th { + vertical-align: top; + text-align: right; + padding: 20px 0 20px 10px; + width: 200px; + line-height: 1.3; + font-weight: 600; +} + +.form-table th.th-full, /* Not used by core. Back-compat for pre-4.8 */ +.form-table .td-full { + width: auto; + padding: 20px 0 20px 10px; + font-weight: 400; +} + +.form-table td p { + margin-top: 4px; + margin-bottom: 0; +} + +.form-table .date-time-doc { + margin-top: 1em; +} + +.form-table p.timezone-info { + margin: 1em 0; +} + +.form-table td fieldset label { + margin: 0.25em 0 0.5em !important; + display: inline-block; +} + +.form-table td fieldset label, +.form-table td fieldset p, +.form-table td fieldset li { + line-height: 1.4em; +} + +.form-table input.tog, +.form-table input[type="radio"] { + margin-top: -4px; + margin-left: 4px; + float: none; +} + +.form-table .pre { + padding: 8px; + margin: 0; +} + +table.form-table td .updated { + font-size: 13px; +} + +table.form-table td .updated p { + font-size: 13px; + margin: 0.3em 0; +} + +/*------------------------------------------------------------------------------ + 18.0 - Users +------------------------------------------------------------------------------*/ + +#profile-page .form-table textarea { + width: 500px; + margin-bottom: 6px; +} + +#profile-page .form-table #rich_editing { + margin-left: 5px +} + +#your-profile legend { + font-size: 22px; +} + +#display_name { + width: 15em; +} + +#adduser .form-field input, +#createuser .form-field input { + width: 25em; +} + +.color-option { + display: inline-block; + width: 24%; + padding: 5px 15px 15px; + box-sizing: border-box; + margin-bottom: 3px; +} + +.color-option:hover, +.color-option.selected { + background: #ddd; +} + +.color-palette { + width: 100%; + border-spacing: 0; + border-collapse: collapse; +} +.color-palette td { + height: 20px; + padding: 0; + border: none; +} + +.color-option { + cursor: pointer; +} + +/*------------------------------------------------------------------------------ + 19.0 - Tools +------------------------------------------------------------------------------*/ + +.tool-box .title { + margin: 8px 0; + font-size: 18px; + font-weight: 400; + line-height: 24px; +} + +.label-responsive { + vertical-align: middle; +} + +#export-filters p { + margin: 0 0 1em; +} + +#export-filters p.submit { + margin: 7px 0 5px; +} + +/* Card styles */ + +.card { + position: relative; + margin-top: 20px; + padding: 0.7em 2em 1em; + min-width: 255px; + max-width: 520px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; +} + +/* Press this styles */ + +.pressthis h4 { + margin: 2em 0 1em; +} + +.pressthis textarea { + width: 100%; + font-size: 1em; +} + +#pressthis-code-wrap { + overflow: auto; +} + +.pressthis-bookmarklet-wrapper { + margin: 20px 0 8px; + vertical-align: top; + position: relative; + z-index: 1; +} + +.pressthis-bookmarklet, +.pressthis-bookmarklet:hover, +.pressthis-bookmarklet:focus, +.pressthis-bookmarklet:active { + display: inline-block; + position: relative; + cursor: move; + color: #32373c; + background: #e5e5e5; + border-radius: 5px; + border: 1px solid #b4b9be; + font-style: normal; + line-height: 16px; + font-size: 14px; + text-decoration: none; +} + +.pressthis-bookmarklet:active { + outline: none; +} + +.pressthis-bookmarklet:after { + content: ""; + width: 70%; + height: 55%; + z-index: -1; + position: absolute; + left: 10px; + bottom: 9px; + background: transparent; + -webkit-transform: skew(-20deg) rotate(-6deg); + transform: skew(-20deg) rotate(-6deg); + box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); +} + +.pressthis-bookmarklet:hover:after { + -webkit-transform: skew(-20deg) rotate(-9deg); + transform: skew(-20deg) rotate(-9deg); + box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); +} + +.pressthis-bookmarklet span { + display: inline-block; + margin: 0px 0 0; + padding: 0px 9px 8px 12px; +} + +.pressthis-bookmarklet span:before { + color: #72777c; + font: normal 20px/1 dashicons; + content: "\f157"; + position: relative; + display: inline-block; + top: 4px; + margin-left: 4px; +} + +.pressthis-js-toggle { + margin-right: 10px; + padding: 0; + height: auto; + vertical-align: top; +} + +/* to override the button class being applied */ +.pressthis-js-toggle.button.button { + margin-right: 10px; + padding: 0; + height: auto; + vertical-align: top; +} + +.pressthis-js-toggle .dashicons { + margin: 5px 7px 6px 8px; + color: #555d66; +} + +/*------------------------------------------------------------------------------ + 20.0 - Settings +------------------------------------------------------------------------------*/ + +.timezone-info code { + white-space: nowrap; +} + +.defaultavatarpicker .avatar { + margin: 2px 0; + vertical-align: middle; +} + +.options-general-php .date-time-text { + display: inline-block; + min-width: 10em; +} + +.options-general-php input.small-text { + width: 56px; +} + +.options-general-php .spinner { + float: none; + margin: -3px 3px 0; +} + +.settings-php .language-install-spinner, +.options-general-php .language-install-spinner { + display: inline-block; + float: none; + margin: -3px 5px 0; + vertical-align: middle; +} + +.form-table.permalink-structure .available-structure-tags li { + float: right; + margin-left: 5px; +} + +/*------------------------------------------------------------------------------ + 21.0 - Network Admin +------------------------------------------------------------------------------*/ + +.setup-php textarea { + max-width: 100%; +} + +.form-field #site-address { + max-width: 25em; +} + +.form-field #domain { + max-width: 22em; +} + +.form-field #site-title, +.form-field #admin-email, +.form-field #path, +.form-field #blog_registered, +.form-field #blog_last_updated { + max-width: 25em; +} + +.form-field #path { + margin-bottom: 5px; +} + +#search-users, +#search-sites { + max-width: 100%; +} + +/*------------------------------------------------------------------------------ + Credentials check dialog for Install and Updates +------------------------------------------------------------------------------*/ + +.request-filesystem-credentials-dialog { + display: none; + /* The customizer uses visibility: hidden on the body for full-overlays. */ + visibility: visible; +} + +.request-filesystem-credentials-dialog .notification-dialog { + top: 10%; + max-height: 85%; +} + +.request-filesystem-credentials-dialog-content { + margin: 25px; +} + +#request-filesystem-credentials-title { + font-size: 1.3em; + margin: 1em 0; +} + +.request-filesystem-credentials-form legend { + font-size: 1em; + padding: 1.33em 0; + font-weight: 600; +} + +.request-filesystem-credentials-form input[type="text"], +.request-filesystem-credentials-form input[type="password"] { + display: block; +} + +.request-filesystem-credentials-dialog input[type="text"], +.request-filesystem-credentials-dialog input[type="password"] { + width: 100%; +} + +.request-filesystem-credentials-form .field-title { + font-weight: 600; +} + +.request-filesystem-credentials-dialog label[for="hostname"], +.request-filesystem-credentials-dialog label[for="public_key"], +.request-filesystem-credentials-dialog label[for="private_key"] { + display: block; + margin-bottom: 1em; +} + +.request-filesystem-credentials-dialog .ftp-username, +.request-filesystem-credentials-dialog .ftp-password { + float: right; + width: 48%; +} + +.request-filesystem-credentials-dialog .ftp-password { + margin-right: 4%; +} + +.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons { + text-align: left; +} + +.request-filesystem-credentials-dialog label[for="ftp"] { + margin-left: 10px; +} + +.request-filesystem-credentials-dialog #auth-keys-desc { + margin-bottom: 0; +} + +#request-filesystem-credentials-dialog .button:not(:last-child) { + margin-left: 10px; +} + +#request-filesystem-credentials-form .cancel-button { + display: none; +} + +#request-filesystem-credentials-dialog .cancel-button { + display: inline; +} + +.request-filesystem-credentials-dialog .ftp-username, +.request-filesystem-credentials-dialog .ftp-password { + float: none; + width: auto; +} + +.request-filesystem-credentials-dialog .ftp-username { + margin-bottom: 1em; +} + +.request-filesystem-credentials-dialog .ftp-password { + margin: 0; +} + +.request-filesystem-credentials-dialog .ftp-password em { + color: #888; +} + +.request-filesystem-credentials-dialog label { + display: block; + line-height: 1.5; + margin-bottom: 1em; +} + +.request-filesystem-credentials-form legend { + padding-bottom: 0; +} + +.request-filesystem-credentials-form #ssh-keys legend { + font-size: 1.3em; +} + +.request-filesystem-credentials-form .notice { + margin: 0 0 20px 0; + clear: both; +} + +/*------------------------------------------------------------------------------ + Privacy Policy settings screen +------------------------------------------------------------------------------*/ +.tools-privacy-policy-page form { + margin-bottom: 1.3em; +} + +.tools-privacy-policy-page input.button, +.tools-privacy-policy-page select { + margin-right: 6px; +} + +.tools-privacy-edit { + margin: 1.5em 0; +} + +.tools-privacy-policy-page span { + line-height: 2em; +} + +.privacy_requests .column-email { + width: 40%; +} + +.privacy_requests .column-type { + text-align: center; +} + +.privacy_requests thead td:first-child, +.privacy_requests tfoot td:first-child { + border-right: 4px solid #fff; +} + +.privacy_requests tbody th { + border-right: 4px solid #fff; + background: #fff; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.privacy_requests tbody .has-request-results th { + box-shadow: none; +} + +.privacy_requests tbody .request-results th .notice { + margin: 0 0 5px; +} + +.privacy_requests tbody td { + background: #fff; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.privacy_requests tbody .has-request-results td { + box-shadow: none; +} + +.privacy_requests .next_steps .button { + height: auto; + line-height: 1.5; + padding: 4px 10px; + word-break: break-all; + white-space: unset; +} + +.privacy_requests .status-request-confirmed th, +.privacy_requests .status-request-confirmed td { + background-color: #f7fcfe; + border-right-color: #00a0d2; +} + +.privacy_requests .status-request-failed th, +.privacy_requests .status-request-failed td { + background-color: #fef7f1; + border-right-color: #d64d21; +} + +.privacy_requests .export_personal_data_failed a { + vertical-align: baseline; +} + +.status-label { + font-weight: bold; +} + +.status-label.status-request-pending { + font-weight: normal; + font-style: italic; + color: #6c7781; +} + +.status-label.status-request-failed { + color: #aa0000; + font-weight: bold; +} + +.wp-privacy-request-form { + clear: both; +} + +.wp-privacy-request-form-field { + margin: 1.5em 0; +} + +.wp-privacy-request-form label { + font-weight: bold; + line-height: 1.5; + padding-bottom: .5em; + display: block; +} + +.wp-privacy-request-form input { + line-height: 1.5; + margin: 0; +} + +.email-personal-data::before { + display: inline-block; + font: normal 20px/1 dashicons; + margin: 3px -2px 0 5px; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.email-personal-data--sending::before { + color: #f56e28; + content: "\f463"; + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +.email-personal-data--sent::before { + color: #79ba49; + content: "\f147"; +} + + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and ( max-width: 782px ) { + /* Input Elements */ + textarea { + -webkit-appearance: none; + } + + input[type="text"], + input[type="email"], + input[type="search"], + input[type="password"], + input[type="number"] { + -webkit-appearance: none; + padding: 6px 10px; + } + + input[type="number"] { + height: 40px; + } + + input.code { + padding-bottom: 5px; + padding-top: 10px; + } + + input[type="checkbox"], + .widefat th input[type="checkbox"], + .widefat thead td input[type="checkbox"], + .widefat tfoot td input[type="checkbox"] { + -webkit-appearance: none; + padding: 10px; + } + + .widefat th input[type="checkbox"], + .widefat thead td input[type="checkbox"], + .widefat tfoot td input[type="checkbox"] { + margin-bottom: 8px; + } + + input[type="checkbox"]:checked:before, + .widefat th input[type="checkbox"]:before, + .widefat thead td input[type="checkbox"]:before, + .widefat tfoot td input[type="checkbox"]:before { + font: normal 30px/1 dashicons; + margin: -3px -5px; + } + + input[type="radio"], + input[type="checkbox"] { + height: 25px; + width: 25px; + } + + .wp-admin p input[type="checkbox"], + .wp-admin p input[type="radio"] { + margin-top: -3px; + } + + input[type="radio"]:checked:before { + vertical-align: middle; + width: 9px; + height: 9px; + margin: 7px; + line-height: 16px; + } + + .wp-upload-form input[type="submit"] { + margin-top: 10px; + } + + #wpbody select { + height: 36px; + font-size: 16px; + } + + .wp-admin .button-cancel { + padding: 0; + font-size: 14px; + } + + #adduser .form-field input, + #createuser .form-field input { + width: 100%; + } + + .form-table { + box-sizing: border-box; + } + + .form-table th, + .form-table td, + .label-responsive { + display: block; + width: auto; + vertical-align: middle; + } + + .label-responsive { + margin: 0.5em 0; + } + + .export-filters li { + margin-bottom: 0; + } + + .form-table .color-palette td { + display: table-cell; + width: 15px; + } + + .form-table table.color-palette { + margin-left: 10px; + } + + textarea, + input { + font-size: 16px; + } + + .form-table td input[type="text"], + .form-table td input[type="email"], + .form-table td input[type="password"], + .form-table td select, + .form-table td textarea, + .form-table span.description, + #profile-page .form-table textarea { + width: 100%; + font-size: 16px; + line-height: 1.5; + padding: 7px 10px; + display: block; + max-width: none; + box-sizing: border-box; + } + + .form-table .form-required.form-invalid td:after { + float: left; + margin: -30px 0 0 3px; + } + + #wpbody .form-table td select { + height: 40px; + } + + input[type="text"].small-text, + input[type="search"].small-text, + input[type="password"].small-text, + input[type="number"].small-text, + input[type="number"].small-text, + .form-table input[type="text"].small-text { + width: auto; + max-width: 4.375em; /* 70px, enough for 4 digits to fit comfortably */ + display: inline; + padding: 3px 6px; + margin: 0 3px; + } + + #pass-strength-result { + width: 100%; + box-sizing: border-box; + padding: 8px; + } + + p.search-box { + float: none; + position: absolute; + bottom: 0; + width: 98%; + height: 90px; + margin-bottom: 20px; + } + + p.search-box input[name="s"] { + height: auto; + float: none; + width: 100%; + margin-bottom: 10px; + vertical-align: middle; + -webkit-appearance: none; + } + + p.search-box input[type="submit"] { + margin-bottom: 10px; + } + + .form-table span.description { + display: inline; + padding: 4px 0 0; + line-height: 1.4em; + font-size: 14px; + } + + .form-table th { + padding-top: 10px; + padding-bottom: 0; + border-bottom: 0; + } + + .form-table td { + margin-bottom: 0; + padding-bottom: 6px; + padding-top: 4px; + padding-right: 0; + } + + .form-table.permalink-structure td code { + margin-right: 32px; + } + + .form-table.permalink-structure td input[type="text"] { + margin-right: 32px; + margin-top: 4px; + width: 96%; + } + + .form-table input.regular-text { + width: 100%; + } + + .form-table label { + font-size: 14px; + } + + .form-table fieldset label { + display: block; + } + + #utc-time, + #local-time { + display: block; + float: none; + margin-top: 0.5em; + } + + .form-field #domain { + max-width: none; + } + + /* New Password */ + .wp-pwd { + position: relative; + } + + .wp-pwd [type="text"], + .wp-pwd [type="password"] { + padding-left: 40px; + } + + .wp-pwd button.button { + background: transparent; + border: none; + box-shadow: none; + line-height: 2; + margin: 0; + padding: 5px 10px; + position: absolute; + left: 0; + top: 0; + } + + .wp-pwd button.button:hover, + .wp-pwd button.button:focus, + .wp-pwd button.button:active { + background: transparent; + } + + .wp-pwd .button .text { + display: none; + } + + .options-general-php input[type="text"].small-text { + max-width: 6.25em; + margin: 0; + } + + /* Privacy Policy settings screen */ + .tools-privacy-policy-page form.wp-create-privacy-page { + margin-bottom: 1em; + } + + .tools-privacy-policy-page input#set-page, + .tools-privacy-policy-page select { + margin: 10px 0 0; + } + + .tools-privacy-policy-page .wp-create-privacy-page span { + display: block; + margin-bottom: 1em; + } + + .tools-privacy-policy-page .wp-create-privacy-page .button { + margin-right: 0; + } + + .wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column) { + display: table-cell; + } + + .wp-list-table.privacy_requests.widefat th input, + .wp-list-table.privacy_requests.widefat thead td input { + margin-right: 5px; + } +} + +@media only screen and (max-width: 768px) { + .form-field input[type="text"], + .form-field input[type="email"], + .form-field input[type="password"], + .form-field select, + .form-field textarea { + width: 99%; + } + + .form-wrap .form-field { + padding:0; + } + + /* users */ + #profile-page .form-table textarea { + max-width: 400px; + width: auto; + } +} + +@media only screen and (max-height: 480px), screen and (max-width: 450px) { + /* Request Credentials / File Editor Warning */ + .request-filesystem-credentials-dialog .notification-dialog, + .file-editor-warning .notification-dialog { + width: 100%; + height: 100%; + max-height: 100%; + position: fixed; + top: 0; + margin: 0; + right: 0; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Color Picker Options */ + .color-option { + width: 49%; + } +} + +@media only screen and (max-width: 320px) { + .options-general-php .date-time-text.date-time-custom-text { + min-width: 0; + margin-left: 0.5em; + } +} + +@-webkit-keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(-359deg); + transform: rotate(-359deg); + } +} + +@keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(-359deg); + transform: rotate(-359deg); + } +} diff --git a/backend/wp-admin/css/forms-rtl.min.css b/backend/wp-admin/css/forms-rtl.min.css new file mode 100644 index 0000000..bc5ddfc --- /dev/null +++ b/backend/wp-admin/css/forms-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#your-profile label+a,.wp-admin select,fieldset label,label{vertical-align:middle}#pass-strength-result,.color-option,input,textarea{box-sizing:border-box}#pressthis-code-wrap,textarea{overflow:auto}input[type=text],input[type=search],input[type=radio],input[type=tel],input[type=time],input[type=url],input[type=week],input[type=password],input[type=checkbox],input[type=color],input[type=date],input[type=datetime],input[type=datetime-local],input[type=email],input[type=month],input[type=number],select,textarea{border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;transition:50ms border-color ease-in-out}input[type=text]:focus,input[type=search]:focus,input[type=radio]:focus,input[type=tel]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,input[type=password]:focus,input[type=checkbox]:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,select:focus,textarea:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}input[type=url],input[type=email]{direction:ltr}input[type=number]{height:28px;line-height:1}input[type=radio],input[type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 0 0 4px;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.1);transition:.05s border-color ease-in-out}input[type=radio]:checked+label:before{color:#82878c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#00a0d2}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox],td>input[type=checkbox]{margin-top:0}.wp-admin p label input[type=checkbox]{margin-top:-4px}.wp-admin p label input[type=radio]{margin-top:-2px}input[type=radio]{border-radius:50%;margin-left:4px;line-height:10px}input[type=radio]:checked:before,input[type=checkbox]:checked:before{float:right;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#pass1-text,.pw-weak,.show-password #pass1{display:none}input[type=checkbox]:checked:before{content:"\f147";margin:-3px -4px 0 0;color:#1e8cbe}input[type=radio]:checked:before{content:"\2022";text-indent:-9999px;border-radius:50px;font-size:24px;width:6px;height:6px;margin:4px;line-height:16px;background-color:#1e8cbe}@-moz-document url-prefix(){.form-table input.tog,input[type=radio],input[type=checkbox]{margin-bottom:-1px}}input[type=search]{-webkit-appearance:textfield}input[type=search]::-webkit-search-decoration{display:none}.ie8 input[type=password]{font-family:sans-serif}button,input,select,textarea{font-family:inherit;font-size:inherit;font-weight:inherit}input,select,textarea{font-size:14px;border-radius:0}textarea{padding:2px 6px;line-height:1.4;resize:vertical}.wp-admin input[type=file]{padding:3px 0;cursor:pointer}label{cursor:pointer}input,select{margin:1px;padding:3px 5px}input.code{padding-top:6px}textarea.code{line-height:1.4;padding:4px 6px 1px}input.readonly,input[readonly],textarea.readonly,textarea[readonly]{background-color:#eee}::-webkit-input-placeholder{color:#72777c}::-moz-placeholder{color:#72777c;opacity:1}:-ms-input-placeholder{color:#72777c}.form-invalid input,.form-invalid input:focus,.form-invalid select,.form-invalid select:focus{border-color:#dc3232!important;box-shadow:0 0 2px rgba(204,0,0,.8)}.form-table .form-required.form-invalid td:after{content:"\f534";font:400 20px/1 dashicons;color:#dc3232;margin-right:-25px;vertical-align:middle}.form-table .form-required.user-pass1-wrap.form-invalid td:after{content:''}.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after{content:'\f534';font:400 20px/1 dashicons;color:#dc3232;margin:0 -29px 0 6px;vertical-align:middle}.form-input-tip{color:#666}input.disabled,input:disabled,select.disabled,select:disabled,textarea.disabled,textarea:disabled{background:rgba(255,255,255,.5);border-color:rgba(222,222,222,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5)}input[type=file].disabled,input[type=file]:disabled,input[type=range].disabled,input[type=range]:disabled{background:0 0;box-shadow:none;cursor:default}input[type=radio].disabled,input[type=radio].disabled:checked:before,input[type=radio]:disabled,input[type=radio]:disabled:checked:before,input[type=checkbox].disabled,input[type=checkbox].disabled:checked:before,input[type=checkbox]:disabled,input[type=checkbox]:disabled:checked:before{opacity:.7}.wp-admin select{padding:2px;line-height:28px;height:28px}.wp-admin .button-cancel{padding:0 5px;line-height:2}.meta-box-sortables select{max-width:100%}.wp-admin select[multiple]{height:auto}.submit{padding:1.5em 0;margin:5px 0;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:none}form p.submit a.cancel:hover{text-decoration:none}p.submit{text-align:right;max-width:100%;margin-top:20px;padding-top:10px}.textright p.submit{border:none;text-align:left}table.form-table+input+input+p.submit,table.form-table+input+p.submit,table.form-table+p.submit{border-top:none;padding-top:0}#major-publishing-actions input,#minor-publishing-actions .preview,#minor-publishing-actions input{text-align:center}input.all-options,textarea.all-options{width:250px}input.large-text,textarea.large-text{width:99%}.regular-text{width:25em}input.small-text{width:50px;padding:1px 6px}input[type=number].small-text{width:65px}input.tiny-text{width:35px}input[type=number].tiny-text{width:45px}#doaction,#doaction2,#post-query-submit{margin:1px 0 0 8px}.tablenav #changeit,.tablenav #clear-recent-list,.tablenav #delete_all,.wp-filter #delete_all{margin-top:1px}.tablenav .actions select{float:right;margin-left:6px;max-width:200px}.ie8 .tablenav .actions select{width:155px}.ie8 .tablenav .actions select#cat{width:200px}#timezone_string option{margin-right:1em}button.wp-hide-pw>.dashicons{position:relative;top:3px}.options-media-php [for*="_size_"]{min-width:10em;vertical-align:baseline}.options-media-php .small-text[name*="_size_"]{margin:0 0 1em}#misc-publishing-actions label{vertical-align:baseline}#pass-strength-result{background-color:#eee;border:1px solid #ddd;color:#23282d;margin:-2px 1px 5px 5px;padding:3px 5px;text-align:center;width:25em;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.indicator-hint{padding-top:8px}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}p.search-box{float:left;margin:0}.network-admin.themes-php p.search-box{clear:right}.search-box input[name="s"],.tablenav .search-plugins input[name="s"],.tagsdiv .newtag{float:right;height:28px;margin:0 0 0 4px}.js.plugins-php .search-box .wp-filter-search{margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5;padding:3px 5px;height:32px}input[type=text].ui-autocomplete-loading,input[type=email].ui-autocomplete-loading{background-image:url(../images/loading.gif);background-repeat:no-repeat;background-position:left center;visibility:visible}input.ui-autocomplete-input.open{border-bottom-color:transparent}ul#add-to-blog-users{margin:0 14px 0 0}.ui-autocomplete{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete li{margin-bottom:0;padding:4px 10px;white-space:nowrap;text-align:right;cursor:pointer}.ui-autocomplete .ui-state-focus{background-color:#ddd}.wp-tags-autocomplete .ui-state-focus{background-color:#0073aa;color:#fff}.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both}.form-table,.form-table td,.form-table td p,.form-table th{font-size:14px}.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle}.form-table th,.form-wrap label{color:#23282d;font-weight:400;text-shadow:none;vertical-align:baseline}.form-table th{vertical-align:top;text-align:right;padding:20px 0 20px 10px;width:200px;line-height:1.3;font-weight:600}.form-table .td-full,.form-table th.th-full{width:auto;padding:20px 0 20px 10px;font-weight:400}.form-table td p{margin-top:4px;margin-bottom:0}.form-table .date-time-doc{margin-top:1em}.form-table p.timezone-info{margin:1em 0}.form-table td fieldset label{margin:.25em 0 .5em!important;display:inline-block}.form-table td fieldset label,.form-table td fieldset li,.form-table td fieldset p{line-height:1.4em}.form-table input.tog,.form-table input[type=radio]{margin-top:-4px;margin-left:4px;float:none}.form-table .pre{padding:8px;margin:0}table.form-table td .updated{font-size:13px}table.form-table td .updated p{font-size:13px;margin:.3em 0}#profile-page .form-table textarea{width:500px;margin-bottom:6px}#profile-page .form-table #rich_editing{margin-left:5px}#your-profile legend{font-size:22px}#display_name{width:15em}#adduser .form-field input,#createuser .form-field input{width:25em}.color-option{display:inline-block;width:24%;padding:5px 15px 15px;margin-bottom:3px;cursor:pointer}.color-option.selected,.color-option:hover{background:#ddd}.color-palette{width:100%;border-spacing:0;border-collapse:collapse}.color-palette td{height:20px;padding:0;border:none}.tool-box .title{margin:8px 0;font-size:18px;font-weight:400;line-height:24px}.label-responsive{vertical-align:middle}#export-filters p{margin:0 0 1em}#export-filters p.submit{margin:7px 0 5px}.card{position:relative;margin-top:20px;padding:.7em 2em 1em;min-width:255px;max-width:520px;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff}.pressthis h4{margin:2em 0 1em}.pressthis textarea{width:100%;font-size:1em}.pressthis-bookmarklet-wrapper{margin:20px 0 8px;vertical-align:top;position:relative;z-index:1}.pressthis-bookmarklet,.pressthis-bookmarklet:active,.pressthis-bookmarklet:focus,.pressthis-bookmarklet:hover{display:inline-block;position:relative;cursor:move;color:#32373c;background:#e5e5e5;border-radius:5px;border:1px solid #b4b9be;font-style:normal;line-height:16px;font-size:14px;text-decoration:none}.privacy_requests tbody th,.privacy_requests tfoot td:first-child,.privacy_requests thead td:first-child{border-right:4px solid #fff}.pressthis-bookmarklet:active{outline:0}.pressthis-bookmarklet:after{content:"";width:70%;height:55%;z-index:-1;position:absolute;left:10px;bottom:9px;background:0 0;-webkit-transform:skew(-20deg) rotate(-6deg);transform:skew(-20deg) rotate(-6deg);box-shadow:0 10px 8px rgba(0,0,0,.6)}.pressthis-bookmarklet:hover:after{-webkit-transform:skew(-20deg) rotate(-9deg);transform:skew(-20deg) rotate(-9deg);box-shadow:0 10px 8px rgba(0,0,0,.7)}.pressthis-bookmarklet span{display:inline-block;margin:0;padding:0 9px 8px 12px}.pressthis-bookmarklet span:before{color:#72777c;font:400 20px/1 dashicons;content:"\f157";position:relative;display:inline-block;top:4px;margin-left:4px}.pressthis-js-toggle,.pressthis-js-toggle.button.button{margin-right:10px;padding:0;height:auto;vertical-align:top}.pressthis-js-toggle .dashicons{margin:5px 7px 6px 8px;color:#555d66}.timezone-info code{white-space:nowrap}.defaultavatarpicker .avatar{margin:2px 0;vertical-align:middle}.options-general-php .date-time-text{display:inline-block;min-width:10em}.options-general-php input.small-text{width:56px}.options-general-php .spinner{float:none;margin:-3px 3px 0}.options-general-php .language-install-spinner,.settings-php .language-install-spinner{display:inline-block;float:none;margin:-3px 5px 0;vertical-align:middle}.form-table.permalink-structure .available-structure-tags li{float:right;margin-left:5px}.setup-php textarea{max-width:100%}.form-field #site-address{max-width:25em}.form-field #domain{max-width:22em}.form-field #admin-email,.form-field #blog_last_updated,.form-field #blog_registered,.form-field #path,.form-field #site-title{max-width:25em}.form-field #path{margin-bottom:5px}#search-sites,#search-users{max-width:100%}.request-filesystem-credentials-dialog{display:none;visibility:visible}.request-filesystem-credentials-dialog .notification-dialog{top:10%;max-height:85%}.request-filesystem-credentials-dialog-content{margin:25px}#request-filesystem-credentials-title{font-size:1.3em;margin:1em 0}.request-filesystem-credentials-form legend{font-size:1em;padding:1.33em 0 0;font-weight:600}.request-filesystem-credentials-form input[type=text],.request-filesystem-credentials-form input[type=password]{display:block}.request-filesystem-credentials-dialog input[type=text],.request-filesystem-credentials-dialog input[type=password]{width:100%}.request-filesystem-credentials-form .field-title{font-weight:600}.request-filesystem-credentials-dialog label[for=hostname],.request-filesystem-credentials-dialog label[for=public_key],.request-filesystem-credentials-dialog label[for=private_key]{display:block;margin-bottom:1em}.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons{text-align:left}.request-filesystem-credentials-dialog label[for=ftp]{margin-left:10px}.request-filesystem-credentials-dialog #auth-keys-desc{margin-bottom:0}#request-filesystem-credentials-dialog .button:not(:last-child){margin-left:10px}#request-filesystem-credentials-form .cancel-button{display:none}#request-filesystem-credentials-dialog .cancel-button{display:inline}.request-filesystem-credentials-dialog .ftp-password,.request-filesystem-credentials-dialog .ftp-username{float:none;width:auto}.request-filesystem-credentials-dialog .ftp-username{margin-bottom:1em}.request-filesystem-credentials-dialog .ftp-password{margin:0}.request-filesystem-credentials-dialog .ftp-password em{color:#888}.request-filesystem-credentials-dialog label{display:block;line-height:1.5;margin-bottom:1em}.request-filesystem-credentials-form #ssh-keys legend{font-size:1.3em}.request-filesystem-credentials-form .notice{margin:0 0 20px;clear:both}.tools-privacy-policy-page form{margin-bottom:1.3em}.tools-privacy-policy-page input.button,.tools-privacy-policy-page select{margin-right:6px}.tools-privacy-edit{margin:1.5em 0}.tools-privacy-policy-page span{line-height:2em}.privacy_requests .column-email{width:40%}.privacy_requests .column-type{text-align:center}.privacy_requests tbody th{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results th{box-shadow:none}.privacy_requests tbody .request-results th .notice{margin:0 0 5px}.privacy_requests tbody td{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results td{box-shadow:none}.privacy_requests .next_steps .button{height:auto;line-height:1.5;padding:4px 10px;word-break:break-all;white-space:unset}.privacy_requests .status-request-confirmed td,.privacy_requests .status-request-confirmed th{background-color:#f7fcfe;border-right-color:#00a0d2}.privacy_requests .status-request-failed td,.privacy_requests .status-request-failed th{background-color:#fef7f1;border-right-color:#d64d21}.privacy_requests .export_personal_data_failed a{vertical-align:baseline}.status-label{font-weight:700}.status-label.status-request-pending{font-weight:400;font-style:italic;color:#6c7781}.status-label.status-request-failed{color:#a00;font-weight:700}.wp-privacy-request-form{clear:both}.wp-privacy-request-form-field{margin:1.5em 0}.wp-privacy-request-form label{font-weight:700;line-height:1.5;padding-bottom:.5em;display:block}.wp-privacy-request-form input{line-height:1.5;margin:0}.email-personal-data::before{display:inline-block;font:400 20px/1 dashicons;margin:3px -2px 0 5px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.email-personal-data--sending::before{color:#f56e28;content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.email-personal-data--sent::before{color:#79ba49;content:"\f147"}@media screen and (max-width:782px){#pass-strength-result,.form-table{box-sizing:border-box}textarea{-webkit-appearance:none}input[type=text],input[type=search],input[type=password],input[type=email],input[type=number]{-webkit-appearance:none;padding:6px 10px}input[type=number]{height:40px}input.code{padding-bottom:5px;padding-top:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox],input[type=checkbox]{-webkit-appearance:none;padding:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox]{margin-bottom:8px}.widefat tfoot td input[type=checkbox]:before,.widefat th input[type=checkbox]:before,.widefat thead td input[type=checkbox]:before,input[type=checkbox]:checked:before{font:400 30px/1 dashicons;margin:-3px -5px}input[type=radio],input[type=checkbox]{height:25px;width:25px}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox]{margin-top:-3px}input[type=radio]:checked:before{vertical-align:middle;width:9px;height:9px;margin:7px;line-height:16px}.wp-upload-form input[type=submit]{margin-top:10px}#wpbody select{height:36px;font-size:16px}.wp-admin .button-cancel{padding:0;font-size:14px}#adduser .form-field input,#createuser .form-field input{width:100%}.form-table td,.form-table th,.label-responsive{display:block;width:auto;vertical-align:middle}.label-responsive{margin:.5em 0}.export-filters li{margin-bottom:0}.form-table .color-palette td{display:table-cell;width:15px}.form-table table.color-palette{margin-left:10px}input,textarea{font-size:16px}#profile-page .form-table textarea,.form-table span.description,.form-table td input[type=text],.form-table td input[type=password],.form-table td input[type=email],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}.form-table .form-required.form-invalid td:after{float:left;margin:-30px 0 0 3px}#wpbody .form-table td select{height:40px}.form-table input[type=text].small-text,input[type=text].small-text,input[type=search].small-text,input[type=password].small-text,input[type=number].small-text{width:auto;max-width:4.375em;display:inline;padding:3px 6px;margin:0 3px}#pass-strength-result{width:100%;padding:8px}p.search-box{float:none;position:absolute;bottom:0;width:98%;height:90px;margin-bottom:20px}p.search-box input[name="s"]{height:auto;float:none;width:100%;margin-bottom:10px;vertical-align:middle;-webkit-appearance:none}p.search-box input[type=submit]{margin-bottom:10px}.form-table span.description{display:inline;padding:4px 0 0;line-height:1.4em;font-size:14px}.form-table th{padding-top:10px;padding-bottom:0;border-bottom:0}.form-table td{margin-bottom:0;padding-bottom:6px;padding-top:4px;padding-right:0}.form-table.permalink-structure td code{margin-right:32px}.form-table.permalink-structure td input[type=text]{margin-right:32px;margin-top:4px;width:96%}.form-table input.regular-text{width:100%}.form-table label{font-size:14px}.form-table fieldset label{display:block}#local-time,#utc-time{display:block;float:none;margin-top:.5em}.form-field #domain{max-width:none}.wp-pwd{position:relative}.wp-pwd [type=text],.wp-pwd [type=password]{padding-left:40px}.wp-pwd button.button{background:0 0;border:none;box-shadow:none;line-height:2;margin:0;padding:5px 10px;position:absolute;left:0;top:0}.wp-pwd button.button:active,.wp-pwd button.button:focus,.wp-pwd button.button:hover{background:0 0}.wp-pwd .button .text{display:none}.options-general-php input[type=text].small-text{max-width:6.25em;margin:0}.tools-privacy-policy-page form.wp-create-privacy-page{margin-bottom:1em}.tools-privacy-policy-page input#set-page,.tools-privacy-policy-page select{margin:10px 0 0}.tools-privacy-policy-page .wp-create-privacy-page span{display:block;margin-bottom:1em}.tools-privacy-policy-page .wp-create-privacy-page .button{margin-right:0}.wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column){display:table-cell}.wp-list-table.privacy_requests.widefat th input,.wp-list-table.privacy_requests.widefat thead td input{margin-right:5px}}@media only screen and (max-width:768px){.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field select,.form-field textarea{width:99%}.form-wrap .form-field{padding:0}#profile-page .form-table textarea{max-width:400px;width:auto}}@media only screen and (max-height:480px),screen and (max-width:450px){.file-editor-warning .notification-dialog,.request-filesystem-credentials-dialog .notification-dialog{width:100%;height:100%;max-height:100%;position:fixed;top:0;margin:0;right:0}}@media screen and (max-width:600px){.color-option{width:49%}}@media only screen and (max-width:320px){.options-general-php .date-time-text.date-time-custom-text{min-width:0;margin-left:.5em}}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}} \ No newline at end of file diff --git a/backend/wp-admin/css/forms.css b/backend/wp-admin/css/forms.css new file mode 100644 index 0000000..9b14751 --- /dev/null +++ b/backend/wp-admin/css/forms.css @@ -0,0 +1,1592 @@ +/* Include margin and padding in the width calculation of input and textarea. */ +input, +textarea { + box-sizing: border-box; +} + +input[type="text"], +input[type="password"], +input[type="checkbox"], +input[type="color"], +input[type="date"], +input[type="datetime"], +input[type="datetime-local"], +input[type="email"], +input[type="month"], +input[type="number"], +input[type="search"], +input[type="radio"], +input[type="tel"], +input[type="text"], +input[type="time"], +input[type="url"], +input[type="week"], +select, +textarea { + border: 1px solid #ddd; + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 ); + background-color: #fff; + color: #32373c; + outline: none; + transition: 0.05s border-color ease-in-out; +} + +input[type="text"]:focus, +input[type="password"]:focus, +input[type="color"]:focus, +input[type="date"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="email"]:focus, +input[type="month"]:focus, +input[type="number"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="text"]:focus, +input[type="time"]:focus, +input[type="url"]:focus, +input[type="week"]:focus, +input[type="checkbox"]:focus, +input[type="radio"]:focus, +select:focus, +textarea:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +/* rtl:ignore */ +input[type="email"], +input[type="url"] { + direction: ltr; +} + +/* Vertically align the number selector with the input. */ +input[type="number"] { + height: 28px; + line-height: 1; +} + +input[type="checkbox"], +input[type="radio"] { + border: 1px solid #b4b9be; + background: #fff; + color: #555; + clear: none; + cursor: pointer; + display: inline-block; + line-height: 0; + height: 16px; + margin: -4px 4px 0 0; + outline: 0; + padding: 0 !important; + text-align: center; + vertical-align: middle; + width: 16px; + min-width: 16px; + -webkit-appearance: none; + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.1 ); + transition: .05s border-color ease-in-out; +} + +input[type="radio"]:checked + label:before { + color: #82878c; +} + +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active { + color: #00a0d2; +} + +td > input[type="checkbox"], +.wp-admin p input[type="checkbox"], +.wp-admin p input[type="radio"] { + margin-top: 0; +} + +.wp-admin p label input[type="checkbox"] { + margin-top: -4px; +} + +.wp-admin p label input[type="radio"] { + margin-top: -2px; +} + +input[type="radio"] { + border-radius: 50%; + margin-right: 4px; + line-height: 10px; +} + +input[type="checkbox"]:checked:before, +input[type="radio"]:checked:before { + float: left; + display: inline-block; + vertical-align: middle; + width: 16px; + font: normal 21px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +input[type="checkbox"]:checked:before { + content: "\f147"; + margin: -3px 0 0 -4px; + color: #1e8cbe; +} + +input[type="radio"]:checked:before { + content: "\2022"; + text-indent: -9999px; + border-radius: 50px; + font-size: 24px; + width: 6px; + height: 6px; + margin: 4px; + line-height: 16px; + background-color: #1e8cbe; +} + +@-moz-document url-prefix() { + input[type="checkbox"], + input[type="radio"], + .form-table input.tog { + margin-bottom: -1px; + } +} + +/* Search */ +input[type="search"] { + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-decoration { + display: none; +} + +.ie8 input[type="password"] { + font-family: sans-serif; +} + +textarea, +input, +select, +button { + font-family: inherit; + font-size: inherit; + font-weight: inherit; +} + +textarea, +input, +select { + font-size: 14px; + padding: 3px 5px; + border-radius: 0; /* Reset mobile webkit's default element styling */ +} + +textarea { + overflow: auto; + padding: 2px 6px; + line-height: 1.4; + resize: vertical; +} + +.wp-admin input[type="file"] { + padding: 3px 0; + cursor: pointer; +} + +label { + cursor: pointer; +} + +input, +select { + margin: 1px; + padding: 3px 5px; +} + +input.code { + padding-top: 6px; +} + +textarea.code { + line-height: 1.4; + padding: 4px 6px 1px 6px; +} + +input.readonly, +input[readonly], +textarea.readonly, +textarea[readonly] { + background-color: #eee; +} + +::-webkit-input-placeholder { + color: #72777c; +} + +::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +:-ms-input-placeholder { + color: #72777c; +} + +.form-invalid input, .form-invalid input:focus, +.form-invalid select, .form-invalid select:focus { + border-color: #dc3232 !important; + box-shadow: 0 0 2px rgba( 204, 0, 0, 0.8 ); +} + +.form-table .form-required.form-invalid td:after { + content: "\f534"; + font: normal 20px/1 dashicons; + color: #dc3232; + margin-left: -25px; + vertical-align: middle; +} + +/* Adjust error indicator for password layout */ +.form-table .form-required.user-pass1-wrap.form-invalid td:after { + content: ''; +} + +.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after { + content: '\f534'; + font: normal 20px/1 dashicons; + color: #dc3232; + margin: 0 6px 0 -29px; + vertical-align: middle; +} + +.form-input-tip { + color: #666; +} + +input:disabled, +input.disabled, +select:disabled, +select.disabled, +textarea:disabled, +textarea.disabled { + background: rgba( 255, 255, 255, 0.5 ); + border-color: rgba( 222, 222, 222, 0.75 ); + box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.04 ); + color: rgba( 51, 51, 51, 0.5 ); +} + +input[type="file"]:disabled, +input[type="file"].disabled, +input[type="range"]:disabled, +input[type="range"].disabled { + background: none; + box-shadow: none; + cursor: default; +} + +input[type="checkbox"]:disabled, +input[type="checkbox"].disabled, +input[type="radio"]:disabled, +input[type="radio"].disabled, +input[type="checkbox"]:disabled:checked:before, +input[type="checkbox"].disabled:checked:before, +input[type="radio"]:disabled:checked:before, +input[type="radio"].disabled:checked:before { + opacity: 0.7; +} + +/*------------------------------------------------------------------------------ + 2.0 - Forms +------------------------------------------------------------------------------*/ + + +.wp-admin select { + padding: 2px; + line-height: 28px; + height: 28px; + vertical-align: middle; +} + +.wp-admin .button-cancel { + padding: 0 5px; + line-height: 2; +} + +.meta-box-sortables select { + max-width: 100%; +} + +.wp-admin select[multiple] { + height: auto; +} + +.submit { + padding: 1.5em 0; + margin: 5px 0; + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; + border: none; +} + +form p.submit a.cancel:hover { + text-decoration: none; +} + +p.submit { + text-align: left; + max-width: 100%; + margin-top: 20px; + padding-top: 10px; +} + +.textright p.submit { + border: none; + text-align: right; +} + +table.form-table + p.submit, +table.form-table + input + p.submit, +table.form-table + input + input + p.submit { + border-top: none; + padding-top: 0; +} + +#minor-publishing-actions input, +#major-publishing-actions input, +#minor-publishing-actions .preview { + text-align: center; +} + +textarea.all-options, +input.all-options { + width: 250px; +} + +input.large-text, +textarea.large-text { + width: 99%; +} + +.regular-text { + width: 25em; +} + +input.small-text { + width: 50px; + padding: 1px 6px; +} + +input[type="number"].small-text { + width: 65px; +} + +input.tiny-text { + width: 35px; +} + +input[type="number"].tiny-text { + width: 45px; +} + +#doaction, +#doaction2, +#post-query-submit { + margin: 1px 8px 0 0; +} + +.tablenav #changeit, +.tablenav #delete_all, +.tablenav #clear-recent-list, +.wp-filter #delete_all { + margin-top: 1px; +} + +.tablenav .actions select { + float: left; + margin-right: 6px; + max-width: 200px; +} + +.ie8 .tablenav .actions select { + width: 155px; +} + +.ie8 .tablenav .actions select#cat { + width: 200px; +} + +#timezone_string option { + margin-left: 1em; +} + +button.wp-hide-pw > .dashicons { + position: relative; + top: 3px; +} + +label, +#your-profile label + a { + vertical-align: middle; +} + +fieldset label, +#your-profile label + a { + vertical-align: middle; +} + +.options-media-php [for*="_size_"] { + min-width: 10em; + vertical-align: baseline; +} + +.options-media-php .small-text[name*="_size_"] { + margin: 0 0 1em; +} + +#misc-publishing-actions label { + vertical-align: baseline; +} + +#pass-strength-result { + background-color: #eee; + border: 1px solid #ddd; + color: #23282d; + margin: -2px 5px 5px 1px; + padding: 3px 5px; + text-align: center; + width: 25em; + box-sizing: border-box; + opacity: 0; +} + +#pass-strength-result.short { + background-color: #f1adad; + border-color: #e35b5b; + opacity: 1; +} + +#pass-strength-result.bad { + background-color: #fbc5a9; + border-color: #f78b53; + opacity: 1; +} + +#pass-strength-result.good { + background-color: #ffe399; + border-color: #ffc733; + opacity: 1; +} + +#pass-strength-result.strong { + background-color: #c1e1b9; + border-color: #83c373; + opacity: 1; +} + +#pass1.short, #pass1-text.short { + border-color: #e35b5b; +} + +#pass1.bad, #pass1-text.bad { + border-color: #f78b53; +} + +#pass1.good, #pass1-text.good { + border-color: #ffc733; +} + +#pass1.strong, #pass1-text.strong { + border-color: #83c373; +} + +.pw-weak { + display:none; +} + +.indicator-hint { + padding-top: 8px; +} + +#pass1-text, +.show-password #pass1 { + display: none; +} + +.show-password #pass1-text +{ + display: inline-block; +} + +.form-table span.description.important { + font-size: 12px; +} + +p.search-box { + float: right; + margin: 0; +} + +.network-admin.themes-php p.search-box { + clear: left; +} + +.search-box input[name="s"], +.tablenav .search-plugins input[name="s"], +.tagsdiv .newtag { + float: left; + height: 28px; + margin: 0 4px 0 0; +} + +.js.plugins-php .search-box .wp-filter-search { + margin: 0; + width: 280px; + font-size: 16px; + font-weight: 300; + line-height: 1.5; + padding: 3px 5px; + height: 32px; +} + +input[type="text"].ui-autocomplete-loading, +input[type="email"].ui-autocomplete-loading { + background-image: url(../images/loading.gif); + background-repeat: no-repeat; + background-position: right center; + visibility: visible; +} + +input.ui-autocomplete-input.open { + border-bottom-color: transparent; +} + +ul#add-to-blog-users { + margin: 0 0 0 14px; +} + +.ui-autocomplete { + padding: 0; + margin: 0; + list-style: none; + position: absolute; + z-index: 10000; + border: 1px solid #5b9dd9; + box-shadow: 0 1px 2px rgba( 30, 140, 190, 0.8 ); + background-color: #fff; +} + +.ui-autocomplete li { + margin-bottom: 0; + padding: 4px 10px; + white-space: nowrap; + text-align: left; + cursor: pointer; +} + +/* Colors for the wplink toolbar autocomplete. */ +.ui-autocomplete .ui-state-focus { + background-color: #ddd; +} + +/* Colors for the tags autocomplete. */ +.wp-tags-autocomplete .ui-state-focus { + background-color: #0073aa; + color: #fff; +} + +/*------------------------------------------------------------------------------ + 15.0 - Comments Screen +------------------------------------------------------------------------------*/ + +.form-table { + border-collapse: collapse; + margin-top: 0.5em; + width: 100%; + clear: both; +} + +.form-table, +.form-table td, +.form-table th, +.form-table td p { + font-size: 14px; +} + +.form-table td { + margin-bottom: 9px; + padding: 15px 10px; + line-height: 1.3; + vertical-align: middle; +} + +.form-table th, +.form-wrap label { + color: #23282d; + font-weight: 400; + text-shadow: none; + vertical-align: baseline; +} + +.form-table th { + vertical-align: top; + text-align: left; + padding: 20px 10px 20px 0; + width: 200px; + line-height: 1.3; + font-weight: 600; +} + +.form-table th.th-full, /* Not used by core. Back-compat for pre-4.8 */ +.form-table .td-full { + width: auto; + padding: 20px 10px 20px 0; + font-weight: 400; +} + +.form-table td p { + margin-top: 4px; + margin-bottom: 0; +} + +.form-table .date-time-doc { + margin-top: 1em; +} + +.form-table p.timezone-info { + margin: 1em 0; +} + +.form-table td fieldset label { + margin: 0.25em 0 0.5em !important; + display: inline-block; +} + +.form-table td fieldset label, +.form-table td fieldset p, +.form-table td fieldset li { + line-height: 1.4em; +} + +.form-table input.tog, +.form-table input[type="radio"] { + margin-top: -4px; + margin-right: 4px; + float: none; +} + +.form-table .pre { + padding: 8px; + margin: 0; +} + +table.form-table td .updated { + font-size: 13px; +} + +table.form-table td .updated p { + font-size: 13px; + margin: 0.3em 0; +} + +/*------------------------------------------------------------------------------ + 18.0 - Users +------------------------------------------------------------------------------*/ + +#profile-page .form-table textarea { + width: 500px; + margin-bottom: 6px; +} + +#profile-page .form-table #rich_editing { + margin-right: 5px +} + +#your-profile legend { + font-size: 22px; +} + +#display_name { + width: 15em; +} + +#adduser .form-field input, +#createuser .form-field input { + width: 25em; +} + +.color-option { + display: inline-block; + width: 24%; + padding: 5px 15px 15px; + box-sizing: border-box; + margin-bottom: 3px; +} + +.color-option:hover, +.color-option.selected { + background: #ddd; +} + +.color-palette { + width: 100%; + border-spacing: 0; + border-collapse: collapse; +} +.color-palette td { + height: 20px; + padding: 0; + border: none; +} + +.color-option { + cursor: pointer; +} + +/*------------------------------------------------------------------------------ + 19.0 - Tools +------------------------------------------------------------------------------*/ + +.tool-box .title { + margin: 8px 0; + font-size: 18px; + font-weight: 400; + line-height: 24px; +} + +.label-responsive { + vertical-align: middle; +} + +#export-filters p { + margin: 0 0 1em; +} + +#export-filters p.submit { + margin: 7px 0 5px; +} + +/* Card styles */ + +.card { + position: relative; + margin-top: 20px; + padding: 0.7em 2em 1em; + min-width: 255px; + max-width: 520px; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); + background: #fff; +} + +/* Press this styles */ + +.pressthis h4 { + margin: 2em 0 1em; +} + +.pressthis textarea { + width: 100%; + font-size: 1em; +} + +#pressthis-code-wrap { + overflow: auto; +} + +.pressthis-bookmarklet-wrapper { + margin: 20px 0 8px; + vertical-align: top; + position: relative; + z-index: 1; +} + +.pressthis-bookmarklet, +.pressthis-bookmarklet:hover, +.pressthis-bookmarklet:focus, +.pressthis-bookmarklet:active { + display: inline-block; + position: relative; + cursor: move; + color: #32373c; + background: #e5e5e5; + border-radius: 5px; + border: 1px solid #b4b9be; + font-style: normal; + line-height: 16px; + font-size: 14px; + text-decoration: none; +} + +.pressthis-bookmarklet:active { + outline: none; +} + +.pressthis-bookmarklet:after { + content: ""; + width: 70%; + height: 55%; + z-index: -1; + position: absolute; + right: 10px; + bottom: 9px; + background: transparent; + -webkit-transform: skew(20deg) rotate(6deg); + transform: skew(20deg) rotate(6deg); + box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6); +} + +.pressthis-bookmarklet:hover:after { + -webkit-transform: skew(20deg) rotate(9deg); + transform: skew(20deg) rotate(9deg); + box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7); +} + +.pressthis-bookmarklet span { + display: inline-block; + margin: 0px 0 0; + padding: 0px 12px 8px 9px; +} + +.pressthis-bookmarklet span:before { + color: #72777c; + font: normal 20px/1 dashicons; + content: "\f157"; + position: relative; + display: inline-block; + top: 4px; + margin-right: 4px; +} + +.pressthis-js-toggle { + margin-left: 10px; + padding: 0; + height: auto; + vertical-align: top; +} + +/* to override the button class being applied */ +.pressthis-js-toggle.button.button { + margin-left: 10px; + padding: 0; + height: auto; + vertical-align: top; +} + +.pressthis-js-toggle .dashicons { + margin: 5px 8px 6px 7px; + color: #555d66; +} + +/*------------------------------------------------------------------------------ + 20.0 - Settings +------------------------------------------------------------------------------*/ + +.timezone-info code { + white-space: nowrap; +} + +.defaultavatarpicker .avatar { + margin: 2px 0; + vertical-align: middle; +} + +.options-general-php .date-time-text { + display: inline-block; + min-width: 10em; +} + +.options-general-php input.small-text { + width: 56px; +} + +.options-general-php .spinner { + float: none; + margin: -3px 3px 0; +} + +.settings-php .language-install-spinner, +.options-general-php .language-install-spinner { + display: inline-block; + float: none; + margin: -3px 5px 0; + vertical-align: middle; +} + +.form-table.permalink-structure .available-structure-tags li { + float: left; + margin-right: 5px; +} + +/*------------------------------------------------------------------------------ + 21.0 - Network Admin +------------------------------------------------------------------------------*/ + +.setup-php textarea { + max-width: 100%; +} + +.form-field #site-address { + max-width: 25em; +} + +.form-field #domain { + max-width: 22em; +} + +.form-field #site-title, +.form-field #admin-email, +.form-field #path, +.form-field #blog_registered, +.form-field #blog_last_updated { + max-width: 25em; +} + +.form-field #path { + margin-bottom: 5px; +} + +#search-users, +#search-sites { + max-width: 100%; +} + +/*------------------------------------------------------------------------------ + Credentials check dialog for Install and Updates +------------------------------------------------------------------------------*/ + +.request-filesystem-credentials-dialog { + display: none; + /* The customizer uses visibility: hidden on the body for full-overlays. */ + visibility: visible; +} + +.request-filesystem-credentials-dialog .notification-dialog { + top: 10%; + max-height: 85%; +} + +.request-filesystem-credentials-dialog-content { + margin: 25px; +} + +#request-filesystem-credentials-title { + font-size: 1.3em; + margin: 1em 0; +} + +.request-filesystem-credentials-form legend { + font-size: 1em; + padding: 1.33em 0; + font-weight: 600; +} + +.request-filesystem-credentials-form input[type="text"], +.request-filesystem-credentials-form input[type="password"] { + display: block; +} + +.request-filesystem-credentials-dialog input[type="text"], +.request-filesystem-credentials-dialog input[type="password"] { + width: 100%; +} + +.request-filesystem-credentials-form .field-title { + font-weight: 600; +} + +.request-filesystem-credentials-dialog label[for="hostname"], +.request-filesystem-credentials-dialog label[for="public_key"], +.request-filesystem-credentials-dialog label[for="private_key"] { + display: block; + margin-bottom: 1em; +} + +.request-filesystem-credentials-dialog .ftp-username, +.request-filesystem-credentials-dialog .ftp-password { + float: left; + width: 48%; +} + +.request-filesystem-credentials-dialog .ftp-password { + margin-left: 4%; +} + +.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons { + text-align: right; +} + +.request-filesystem-credentials-dialog label[for="ftp"] { + margin-right: 10px; +} + +.request-filesystem-credentials-dialog #auth-keys-desc { + margin-bottom: 0; +} + +#request-filesystem-credentials-dialog .button:not(:last-child) { + margin-right: 10px; +} + +#request-filesystem-credentials-form .cancel-button { + display: none; +} + +#request-filesystem-credentials-dialog .cancel-button { + display: inline; +} + +.request-filesystem-credentials-dialog .ftp-username, +.request-filesystem-credentials-dialog .ftp-password { + float: none; + width: auto; +} + +.request-filesystem-credentials-dialog .ftp-username { + margin-bottom: 1em; +} + +.request-filesystem-credentials-dialog .ftp-password { + margin: 0; +} + +.request-filesystem-credentials-dialog .ftp-password em { + color: #888; +} + +.request-filesystem-credentials-dialog label { + display: block; + line-height: 1.5; + margin-bottom: 1em; +} + +.request-filesystem-credentials-form legend { + padding-bottom: 0; +} + +.request-filesystem-credentials-form #ssh-keys legend { + font-size: 1.3em; +} + +.request-filesystem-credentials-form .notice { + margin: 0 0 20px 0; + clear: both; +} + +/*------------------------------------------------------------------------------ + Privacy Policy settings screen +------------------------------------------------------------------------------*/ +.tools-privacy-policy-page form { + margin-bottom: 1.3em; +} + +.tools-privacy-policy-page input.button, +.tools-privacy-policy-page select { + margin-left: 6px; +} + +.tools-privacy-edit { + margin: 1.5em 0; +} + +.tools-privacy-policy-page span { + line-height: 2em; +} + +.privacy_requests .column-email { + width: 40%; +} + +.privacy_requests .column-type { + text-align: center; +} + +.privacy_requests thead td:first-child, +.privacy_requests tfoot td:first-child { + border-left: 4px solid #fff; +} + +.privacy_requests tbody th { + border-left: 4px solid #fff; + background: #fff; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.privacy_requests tbody .has-request-results th { + box-shadow: none; +} + +.privacy_requests tbody .request-results th .notice { + margin: 0 0 5px; +} + +.privacy_requests tbody td { + background: #fff; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.privacy_requests tbody .has-request-results td { + box-shadow: none; +} + +.privacy_requests .next_steps .button { + height: auto; + line-height: 1.5; + padding: 4px 10px; + word-break: break-all; + white-space: unset; +} + +.privacy_requests .status-request-confirmed th, +.privacy_requests .status-request-confirmed td { + background-color: #f7fcfe; + border-left-color: #00a0d2; +} + +.privacy_requests .status-request-failed th, +.privacy_requests .status-request-failed td { + background-color: #fef7f1; + border-left-color: #d64d21; +} + +.privacy_requests .export_personal_data_failed a { + vertical-align: baseline; +} + +.status-label { + font-weight: bold; +} + +.status-label.status-request-pending { + font-weight: normal; + font-style: italic; + color: #6c7781; +} + +.status-label.status-request-failed { + color: #aa0000; + font-weight: bold; +} + +.wp-privacy-request-form { + clear: both; +} + +.wp-privacy-request-form-field { + margin: 1.5em 0; +} + +.wp-privacy-request-form label { + font-weight: bold; + line-height: 1.5; + padding-bottom: .5em; + display: block; +} + +.wp-privacy-request-form input { + line-height: 1.5; + margin: 0; +} + +.email-personal-data::before { + display: inline-block; + font: normal 20px/1 dashicons; + margin: 3px 5px 0 -2px; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.email-personal-data--sending::before { + color: #f56e28; + content: "\f463"; + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +.email-personal-data--sent::before { + color: #79ba49; + content: "\f147"; +} + + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and ( max-width: 782px ) { + /* Input Elements */ + textarea { + -webkit-appearance: none; + } + + input[type="text"], + input[type="email"], + input[type="search"], + input[type="password"], + input[type="number"] { + -webkit-appearance: none; + padding: 6px 10px; + } + + input[type="number"] { + height: 40px; + } + + input.code { + padding-bottom: 5px; + padding-top: 10px; + } + + input[type="checkbox"], + .widefat th input[type="checkbox"], + .widefat thead td input[type="checkbox"], + .widefat tfoot td input[type="checkbox"] { + -webkit-appearance: none; + padding: 10px; + } + + .widefat th input[type="checkbox"], + .widefat thead td input[type="checkbox"], + .widefat tfoot td input[type="checkbox"] { + margin-bottom: 8px; + } + + input[type="checkbox"]:checked:before, + .widefat th input[type="checkbox"]:before, + .widefat thead td input[type="checkbox"]:before, + .widefat tfoot td input[type="checkbox"]:before { + font: normal 30px/1 dashicons; + margin: -3px -5px; + } + + input[type="radio"], + input[type="checkbox"] { + height: 25px; + width: 25px; + } + + .wp-admin p input[type="checkbox"], + .wp-admin p input[type="radio"] { + margin-top: -3px; + } + + input[type="radio"]:checked:before { + vertical-align: middle; + width: 9px; + height: 9px; + margin: 7px; + line-height: 16px; + } + + .wp-upload-form input[type="submit"] { + margin-top: 10px; + } + + #wpbody select { + height: 36px; + font-size: 16px; + } + + .wp-admin .button-cancel { + padding: 0; + font-size: 14px; + } + + #adduser .form-field input, + #createuser .form-field input { + width: 100%; + } + + .form-table { + box-sizing: border-box; + } + + .form-table th, + .form-table td, + .label-responsive { + display: block; + width: auto; + vertical-align: middle; + } + + .label-responsive { + margin: 0.5em 0; + } + + .export-filters li { + margin-bottom: 0; + } + + .form-table .color-palette td { + display: table-cell; + width: 15px; + } + + .form-table table.color-palette { + margin-right: 10px; + } + + textarea, + input { + font-size: 16px; + } + + .form-table td input[type="text"], + .form-table td input[type="email"], + .form-table td input[type="password"], + .form-table td select, + .form-table td textarea, + .form-table span.description, + #profile-page .form-table textarea { + width: 100%; + font-size: 16px; + line-height: 1.5; + padding: 7px 10px; + display: block; + max-width: none; + box-sizing: border-box; + } + + .form-table .form-required.form-invalid td:after { + float: right; + margin: -30px 3px 0 0; + } + + #wpbody .form-table td select { + height: 40px; + } + + input[type="text"].small-text, + input[type="search"].small-text, + input[type="password"].small-text, + input[type="number"].small-text, + input[type="number"].small-text, + .form-table input[type="text"].small-text { + width: auto; + max-width: 4.375em; /* 70px, enough for 4 digits to fit comfortably */ + display: inline; + padding: 3px 6px; + margin: 0 3px; + } + + #pass-strength-result { + width: 100%; + box-sizing: border-box; + padding: 8px; + } + + p.search-box { + float: none; + position: absolute; + bottom: 0; + width: 98%; + height: 90px; + margin-bottom: 20px; + } + + p.search-box input[name="s"] { + height: auto; + float: none; + width: 100%; + margin-bottom: 10px; + vertical-align: middle; + -webkit-appearance: none; + } + + p.search-box input[type="submit"] { + margin-bottom: 10px; + } + + .form-table span.description { + display: inline; + padding: 4px 0 0; + line-height: 1.4em; + font-size: 14px; + } + + .form-table th { + padding-top: 10px; + padding-bottom: 0; + border-bottom: 0; + } + + .form-table td { + margin-bottom: 0; + padding-bottom: 6px; + padding-top: 4px; + padding-left: 0; + } + + .form-table.permalink-structure td code { + margin-left: 32px; + } + + .form-table.permalink-structure td input[type="text"] { + margin-left: 32px; + margin-top: 4px; + width: 96%; + } + + .form-table input.regular-text { + width: 100%; + } + + .form-table label { + font-size: 14px; + } + + .form-table fieldset label { + display: block; + } + + #utc-time, + #local-time { + display: block; + float: none; + margin-top: 0.5em; + } + + .form-field #domain { + max-width: none; + } + + /* New Password */ + .wp-pwd { + position: relative; + } + + .wp-pwd [type="text"], + .wp-pwd [type="password"] { + padding-right: 40px; + } + + .wp-pwd button.button { + background: transparent; + border: none; + box-shadow: none; + line-height: 2; + margin: 0; + padding: 5px 10px; + position: absolute; + right: 0; + top: 0; + } + + .wp-pwd button.button:hover, + .wp-pwd button.button:focus, + .wp-pwd button.button:active { + background: transparent; + } + + .wp-pwd .button .text { + display: none; + } + + .options-general-php input[type="text"].small-text { + max-width: 6.25em; + margin: 0; + } + + /* Privacy Policy settings screen */ + .tools-privacy-policy-page form.wp-create-privacy-page { + margin-bottom: 1em; + } + + .tools-privacy-policy-page input#set-page, + .tools-privacy-policy-page select { + margin: 10px 0 0; + } + + .tools-privacy-policy-page .wp-create-privacy-page span { + display: block; + margin-bottom: 1em; + } + + .tools-privacy-policy-page .wp-create-privacy-page .button { + margin-left: 0; + } + + .wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column) { + display: table-cell; + } + + .wp-list-table.privacy_requests.widefat th input, + .wp-list-table.privacy_requests.widefat thead td input { + margin-left: 5px; + } +} + +@media only screen and (max-width: 768px) { + .form-field input[type="text"], + .form-field input[type="email"], + .form-field input[type="password"], + .form-field select, + .form-field textarea { + width: 99%; + } + + .form-wrap .form-field { + padding:0; + } + + /* users */ + #profile-page .form-table textarea { + max-width: 400px; + width: auto; + } +} + +@media only screen and (max-height: 480px), screen and (max-width: 450px) { + /* Request Credentials / File Editor Warning */ + .request-filesystem-credentials-dialog .notification-dialog, + .file-editor-warning .notification-dialog { + width: 100%; + height: 100%; + max-height: 100%; + position: fixed; + top: 0; + margin: 0; + left: 0; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + /* Color Picker Options */ + .color-option { + width: 49%; + } +} + +@media only screen and (max-width: 320px) { + .options-general-php .date-time-text.date-time-custom-text { + min-width: 0; + margin-right: 0.5em; + } +} + +@-webkit-keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} + +@keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} diff --git a/backend/wp-admin/css/forms.min.css b/backend/wp-admin/css/forms.min.css new file mode 100644 index 0000000..fa1a6c2 --- /dev/null +++ b/backend/wp-admin/css/forms.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#your-profile label+a,.wp-admin select,fieldset label,label{vertical-align:middle}#pass-strength-result,.color-option,input,textarea{box-sizing:border-box}#pressthis-code-wrap,textarea{overflow:auto}input[type=text],input[type=search],input[type=radio],input[type=tel],input[type=time],input[type=url],input[type=week],input[type=password],input[type=checkbox],input[type=color],input[type=date],input[type=datetime],input[type=datetime-local],input[type=email],input[type=month],input[type=number],select,textarea{border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;transition:50ms border-color ease-in-out}input[type=text]:focus,input[type=search]:focus,input[type=radio]:focus,input[type=tel]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,input[type=password]:focus,input[type=checkbox]:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,select:focus,textarea:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}input[type=url],input[type=email]{direction:ltr}input[type=number]{height:28px;line-height:1}input[type=radio],input[type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 4px 0 0;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.1);transition:.05s border-color ease-in-out}input[type=radio]:checked+label:before{color:#82878c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#00a0d2}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox],td>input[type=checkbox]{margin-top:0}.wp-admin p label input[type=checkbox]{margin-top:-4px}.wp-admin p label input[type=radio]{margin-top:-2px}input[type=radio]{border-radius:50%;margin-right:4px;line-height:10px}input[type=radio]:checked:before,input[type=checkbox]:checked:before{float:left;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#pass1-text,.pw-weak,.show-password #pass1{display:none}input[type=checkbox]:checked:before{content:"\f147";margin:-3px 0 0 -4px;color:#1e8cbe}input[type=radio]:checked:before{content:"\2022";text-indent:-9999px;border-radius:50px;font-size:24px;width:6px;height:6px;margin:4px;line-height:16px;background-color:#1e8cbe}@-moz-document url-prefix(){.form-table input.tog,input[type=radio],input[type=checkbox]{margin-bottom:-1px}}input[type=search]{-webkit-appearance:textfield}input[type=search]::-webkit-search-decoration{display:none}.ie8 input[type=password]{font-family:sans-serif}button,input,select,textarea{font-family:inherit;font-size:inherit;font-weight:inherit}input,select,textarea{font-size:14px;border-radius:0}textarea{padding:2px 6px;line-height:1.4;resize:vertical}.wp-admin input[type=file]{padding:3px 0;cursor:pointer}label{cursor:pointer}input,select{margin:1px;padding:3px 5px}input.code{padding-top:6px}textarea.code{line-height:1.4;padding:4px 6px 1px}input.readonly,input[readonly],textarea.readonly,textarea[readonly]{background-color:#eee}::-webkit-input-placeholder{color:#72777c}::-moz-placeholder{color:#72777c;opacity:1}:-ms-input-placeholder{color:#72777c}.form-invalid input,.form-invalid input:focus,.form-invalid select,.form-invalid select:focus{border-color:#dc3232!important;box-shadow:0 0 2px rgba(204,0,0,.8)}.form-table .form-required.form-invalid td:after{content:"\f534";font:400 20px/1 dashicons;color:#dc3232;margin-left:-25px;vertical-align:middle}.form-table .form-required.user-pass1-wrap.form-invalid td:after{content:''}.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after{content:'\f534';font:400 20px/1 dashicons;color:#dc3232;margin:0 6px 0 -29px;vertical-align:middle}.form-input-tip{color:#666}input.disabled,input:disabled,select.disabled,select:disabled,textarea.disabled,textarea:disabled{background:rgba(255,255,255,.5);border-color:rgba(222,222,222,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5)}input[type=file].disabled,input[type=file]:disabled,input[type=range].disabled,input[type=range]:disabled{background:0 0;box-shadow:none;cursor:default}input[type=radio].disabled,input[type=radio].disabled:checked:before,input[type=radio]:disabled,input[type=radio]:disabled:checked:before,input[type=checkbox].disabled,input[type=checkbox].disabled:checked:before,input[type=checkbox]:disabled,input[type=checkbox]:disabled:checked:before{opacity:.7}.wp-admin select{padding:2px;line-height:28px;height:28px}.wp-admin .button-cancel{padding:0 5px;line-height:2}.meta-box-sortables select{max-width:100%}.wp-admin select[multiple]{height:auto}.submit{padding:1.5em 0;margin:5px 0;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border:none}form p.submit a.cancel:hover{text-decoration:none}p.submit{text-align:left;max-width:100%;margin-top:20px;padding-top:10px}.textright p.submit{border:none;text-align:right}table.form-table+input+input+p.submit,table.form-table+input+p.submit,table.form-table+p.submit{border-top:none;padding-top:0}#major-publishing-actions input,#minor-publishing-actions .preview,#minor-publishing-actions input{text-align:center}input.all-options,textarea.all-options{width:250px}input.large-text,textarea.large-text{width:99%}.regular-text{width:25em}input.small-text{width:50px;padding:1px 6px}input[type=number].small-text{width:65px}input.tiny-text{width:35px}input[type=number].tiny-text{width:45px}#doaction,#doaction2,#post-query-submit{margin:1px 8px 0 0}.tablenav #changeit,.tablenav #clear-recent-list,.tablenav #delete_all,.wp-filter #delete_all{margin-top:1px}.tablenav .actions select{float:left;margin-right:6px;max-width:200px}.ie8 .tablenav .actions select{width:155px}.ie8 .tablenav .actions select#cat{width:200px}#timezone_string option{margin-left:1em}button.wp-hide-pw>.dashicons{position:relative;top:3px}.options-media-php [for*="_size_"]{min-width:10em;vertical-align:baseline}.options-media-php .small-text[name*="_size_"]{margin:0 0 1em}#misc-publishing-actions label{vertical-align:baseline}#pass-strength-result{background-color:#eee;border:1px solid #ddd;color:#23282d;margin:-2px 5px 5px 1px;padding:3px 5px;text-align:center;width:25em;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.indicator-hint{padding-top:8px}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}p.search-box{float:right;margin:0}.network-admin.themes-php p.search-box{clear:left}.search-box input[name="s"],.tablenav .search-plugins input[name="s"],.tagsdiv .newtag{float:left;height:28px;margin:0 4px 0 0}.js.plugins-php .search-box .wp-filter-search{margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5;padding:3px 5px;height:32px}input[type=text].ui-autocomplete-loading,input[type=email].ui-autocomplete-loading{background-image:url(../images/loading.gif);background-repeat:no-repeat;background-position:right center;visibility:visible}input.ui-autocomplete-input.open{border-bottom-color:transparent}ul#add-to-blog-users{margin:0 0 0 14px}.ui-autocomplete{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete li{margin-bottom:0;padding:4px 10px;white-space:nowrap;text-align:left;cursor:pointer}.ui-autocomplete .ui-state-focus{background-color:#ddd}.wp-tags-autocomplete .ui-state-focus{background-color:#0073aa;color:#fff}.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both}.form-table,.form-table td,.form-table td p,.form-table th{font-size:14px}.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle}.form-table th,.form-wrap label{color:#23282d;font-weight:400;text-shadow:none;vertical-align:baseline}.form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;width:200px;line-height:1.3;font-weight:600}.form-table .td-full,.form-table th.th-full{width:auto;padding:20px 10px 20px 0;font-weight:400}.form-table td p{margin-top:4px;margin-bottom:0}.form-table .date-time-doc{margin-top:1em}.form-table p.timezone-info{margin:1em 0}.form-table td fieldset label{margin:.25em 0 .5em!important;display:inline-block}.form-table td fieldset label,.form-table td fieldset li,.form-table td fieldset p{line-height:1.4em}.form-table input.tog,.form-table input[type=radio]{margin-top:-4px;margin-right:4px;float:none}.form-table .pre{padding:8px;margin:0}table.form-table td .updated{font-size:13px}table.form-table td .updated p{font-size:13px;margin:.3em 0}#profile-page .form-table textarea{width:500px;margin-bottom:6px}#profile-page .form-table #rich_editing{margin-right:5px}#your-profile legend{font-size:22px}#display_name{width:15em}#adduser .form-field input,#createuser .form-field input{width:25em}.color-option{display:inline-block;width:24%;padding:5px 15px 15px;margin-bottom:3px;cursor:pointer}.color-option.selected,.color-option:hover{background:#ddd}.color-palette{width:100%;border-spacing:0;border-collapse:collapse}.color-palette td{height:20px;padding:0;border:none}.tool-box .title{margin:8px 0;font-size:18px;font-weight:400;line-height:24px}.label-responsive{vertical-align:middle}#export-filters p{margin:0 0 1em}#export-filters p.submit{margin:7px 0 5px}.card{position:relative;margin-top:20px;padding:.7em 2em 1em;min-width:255px;max-width:520px;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff}.pressthis h4{margin:2em 0 1em}.pressthis textarea{width:100%;font-size:1em}.pressthis-bookmarklet-wrapper{margin:20px 0 8px;vertical-align:top;position:relative;z-index:1}.pressthis-bookmarklet,.pressthis-bookmarklet:active,.pressthis-bookmarklet:focus,.pressthis-bookmarklet:hover{display:inline-block;position:relative;cursor:move;color:#32373c;background:#e5e5e5;border-radius:5px;border:1px solid #b4b9be;font-style:normal;line-height:16px;font-size:14px;text-decoration:none}.privacy_requests tbody th,.privacy_requests tfoot td:first-child,.privacy_requests thead td:first-child{border-left:4px solid #fff}.pressthis-bookmarklet:active{outline:0}.pressthis-bookmarklet:after{content:"";width:70%;height:55%;z-index:-1;position:absolute;right:10px;bottom:9px;background:0 0;-webkit-transform:skew(20deg) rotate(6deg);transform:skew(20deg) rotate(6deg);box-shadow:0 10px 8px rgba(0,0,0,.6)}.pressthis-bookmarklet:hover:after{-webkit-transform:skew(20deg) rotate(9deg);transform:skew(20deg) rotate(9deg);box-shadow:0 10px 8px rgba(0,0,0,.7)}.pressthis-bookmarklet span{display:inline-block;margin:0;padding:0 12px 8px 9px}.pressthis-bookmarklet span:before{color:#72777c;font:400 20px/1 dashicons;content:"\f157";position:relative;display:inline-block;top:4px;margin-right:4px}.pressthis-js-toggle,.pressthis-js-toggle.button.button{margin-left:10px;padding:0;height:auto;vertical-align:top}.pressthis-js-toggle .dashicons{margin:5px 8px 6px 7px;color:#555d66}.timezone-info code{white-space:nowrap}.defaultavatarpicker .avatar{margin:2px 0;vertical-align:middle}.options-general-php .date-time-text{display:inline-block;min-width:10em}.options-general-php input.small-text{width:56px}.options-general-php .spinner{float:none;margin:-3px 3px 0}.options-general-php .language-install-spinner,.settings-php .language-install-spinner{display:inline-block;float:none;margin:-3px 5px 0;vertical-align:middle}.form-table.permalink-structure .available-structure-tags li{float:left;margin-right:5px}.setup-php textarea{max-width:100%}.form-field #site-address{max-width:25em}.form-field #domain{max-width:22em}.form-field #admin-email,.form-field #blog_last_updated,.form-field #blog_registered,.form-field #path,.form-field #site-title{max-width:25em}.form-field #path{margin-bottom:5px}#search-sites,#search-users{max-width:100%}.request-filesystem-credentials-dialog{display:none;visibility:visible}.request-filesystem-credentials-dialog .notification-dialog{top:10%;max-height:85%}.request-filesystem-credentials-dialog-content{margin:25px}#request-filesystem-credentials-title{font-size:1.3em;margin:1em 0}.request-filesystem-credentials-form legend{font-size:1em;padding:1.33em 0 0;font-weight:600}.request-filesystem-credentials-form input[type=text],.request-filesystem-credentials-form input[type=password]{display:block}.request-filesystem-credentials-dialog input[type=text],.request-filesystem-credentials-dialog input[type=password]{width:100%}.request-filesystem-credentials-form .field-title{font-weight:600}.request-filesystem-credentials-dialog label[for=hostname],.request-filesystem-credentials-dialog label[for=public_key],.request-filesystem-credentials-dialog label[for=private_key]{display:block;margin-bottom:1em}.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons{text-align:right}.request-filesystem-credentials-dialog label[for=ftp]{margin-right:10px}.request-filesystem-credentials-dialog #auth-keys-desc{margin-bottom:0}#request-filesystem-credentials-dialog .button:not(:last-child){margin-right:10px}#request-filesystem-credentials-form .cancel-button{display:none}#request-filesystem-credentials-dialog .cancel-button{display:inline}.request-filesystem-credentials-dialog .ftp-password,.request-filesystem-credentials-dialog .ftp-username{float:none;width:auto}.request-filesystem-credentials-dialog .ftp-username{margin-bottom:1em}.request-filesystem-credentials-dialog .ftp-password{margin:0}.request-filesystem-credentials-dialog .ftp-password em{color:#888}.request-filesystem-credentials-dialog label{display:block;line-height:1.5;margin-bottom:1em}.request-filesystem-credentials-form #ssh-keys legend{font-size:1.3em}.request-filesystem-credentials-form .notice{margin:0 0 20px;clear:both}.tools-privacy-policy-page form{margin-bottom:1.3em}.tools-privacy-policy-page input.button,.tools-privacy-policy-page select{margin-left:6px}.tools-privacy-edit{margin:1.5em 0}.tools-privacy-policy-page span{line-height:2em}.privacy_requests .column-email{width:40%}.privacy_requests .column-type{text-align:center}.privacy_requests tbody th{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results th{box-shadow:none}.privacy_requests tbody .request-results th .notice{margin:0 0 5px}.privacy_requests tbody td{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results td{box-shadow:none}.privacy_requests .next_steps .button{height:auto;line-height:1.5;padding:4px 10px;word-break:break-all;white-space:unset}.privacy_requests .status-request-confirmed td,.privacy_requests .status-request-confirmed th{background-color:#f7fcfe;border-left-color:#00a0d2}.privacy_requests .status-request-failed td,.privacy_requests .status-request-failed th{background-color:#fef7f1;border-left-color:#d64d21}.privacy_requests .export_personal_data_failed a{vertical-align:baseline}.status-label{font-weight:700}.status-label.status-request-pending{font-weight:400;font-style:italic;color:#6c7781}.status-label.status-request-failed{color:#a00;font-weight:700}.wp-privacy-request-form{clear:both}.wp-privacy-request-form-field{margin:1.5em 0}.wp-privacy-request-form label{font-weight:700;line-height:1.5;padding-bottom:.5em;display:block}.wp-privacy-request-form input{line-height:1.5;margin:0}.email-personal-data::before{display:inline-block;font:400 20px/1 dashicons;margin:3px 5px 0 -2px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.email-personal-data--sending::before{color:#f56e28;content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.email-personal-data--sent::before{color:#79ba49;content:"\f147"}@media screen and (max-width:782px){#pass-strength-result,.form-table{box-sizing:border-box}textarea{-webkit-appearance:none}input[type=text],input[type=search],input[type=password],input[type=email],input[type=number]{-webkit-appearance:none;padding:6px 10px}input[type=number]{height:40px}input.code{padding-bottom:5px;padding-top:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox],input[type=checkbox]{-webkit-appearance:none;padding:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox]{margin-bottom:8px}.widefat tfoot td input[type=checkbox]:before,.widefat th input[type=checkbox]:before,.widefat thead td input[type=checkbox]:before,input[type=checkbox]:checked:before{font:400 30px/1 dashicons;margin:-3px -5px}input[type=radio],input[type=checkbox]{height:25px;width:25px}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox]{margin-top:-3px}input[type=radio]:checked:before{vertical-align:middle;width:9px;height:9px;margin:7px;line-height:16px}.wp-upload-form input[type=submit]{margin-top:10px}#wpbody select{height:36px;font-size:16px}.wp-admin .button-cancel{padding:0;font-size:14px}#adduser .form-field input,#createuser .form-field input{width:100%}.form-table td,.form-table th,.label-responsive{display:block;width:auto;vertical-align:middle}.label-responsive{margin:.5em 0}.export-filters li{margin-bottom:0}.form-table .color-palette td{display:table-cell;width:15px}.form-table table.color-palette{margin-right:10px}input,textarea{font-size:16px}#profile-page .form-table textarea,.form-table span.description,.form-table td input[type=text],.form-table td input[type=password],.form-table td input[type=email],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}.form-table .form-required.form-invalid td:after{float:right;margin:-30px 3px 0 0}#wpbody .form-table td select{height:40px}.form-table input[type=text].small-text,input[type=text].small-text,input[type=search].small-text,input[type=password].small-text,input[type=number].small-text{width:auto;max-width:4.375em;display:inline;padding:3px 6px;margin:0 3px}#pass-strength-result{width:100%;padding:8px}p.search-box{float:none;position:absolute;bottom:0;width:98%;height:90px;margin-bottom:20px}p.search-box input[name="s"]{height:auto;float:none;width:100%;margin-bottom:10px;vertical-align:middle;-webkit-appearance:none}p.search-box input[type=submit]{margin-bottom:10px}.form-table span.description{display:inline;padding:4px 0 0;line-height:1.4em;font-size:14px}.form-table th{padding-top:10px;padding-bottom:0;border-bottom:0}.form-table td{margin-bottom:0;padding-bottom:6px;padding-top:4px;padding-left:0}.form-table.permalink-structure td code{margin-left:32px}.form-table.permalink-structure td input[type=text]{margin-left:32px;margin-top:4px;width:96%}.form-table input.regular-text{width:100%}.form-table label{font-size:14px}.form-table fieldset label{display:block}#local-time,#utc-time{display:block;float:none;margin-top:.5em}.form-field #domain{max-width:none}.wp-pwd{position:relative}.wp-pwd [type=text],.wp-pwd [type=password]{padding-right:40px}.wp-pwd button.button{background:0 0;border:none;box-shadow:none;line-height:2;margin:0;padding:5px 10px;position:absolute;right:0;top:0}.wp-pwd button.button:active,.wp-pwd button.button:focus,.wp-pwd button.button:hover{background:0 0}.wp-pwd .button .text{display:none}.options-general-php input[type=text].small-text{max-width:6.25em;margin:0}.tools-privacy-policy-page form.wp-create-privacy-page{margin-bottom:1em}.tools-privacy-policy-page input#set-page,.tools-privacy-policy-page select{margin:10px 0 0}.tools-privacy-policy-page .wp-create-privacy-page span{display:block;margin-bottom:1em}.tools-privacy-policy-page .wp-create-privacy-page .button{margin-left:0}.wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column){display:table-cell}.wp-list-table.privacy_requests.widefat th input,.wp-list-table.privacy_requests.widefat thead td input{margin-left:5px}}@media only screen and (max-width:768px){.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field select,.form-field textarea{width:99%}.form-wrap .form-field{padding:0}#profile-page .form-table textarea{max-width:400px;width:auto}}@media only screen and (max-height:480px),screen and (max-width:450px){.file-editor-warning .notification-dialog,.request-filesystem-credentials-dialog .notification-dialog{width:100%;height:100%;max-height:100%;position:fixed;top:0;margin:0;left:0}}@media screen and (max-width:600px){.color-option{width:49%}}@media only screen and (max-width:320px){.options-general-php .date-time-text.date-time-custom-text{min-width:0;margin-right:.5em}}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}} \ No newline at end of file diff --git a/backend/wp-admin/css/ie-rtl.css b/backend/wp-admin/css/ie-rtl.css new file mode 100644 index 0000000..1e748c2 --- /dev/null +++ b/backend/wp-admin/css/ie-rtl.css @@ -0,0 +1,770 @@ +/* Fixes for IE 7 bugs */ + +#dashboard-widgets form .input-text-wrap input, +#dashboard-widgets form .textarea-wrap textarea { + width: 99%; +} + +#dashboard-widgets form #title { + width: 98%; +} + +#wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; +} + +#wpbody-content #dashboard-widgets #postbox-container-2, +#wpbody-content #dashboard-widgets #postbox-container-3, +#wpbody-content #dashboard-widgets #postbox-container-4 { + float: left; + width: 50.5%; +} + +#dashboard-widgets #postbox-container-3 .empty-container, +#dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +.wp-editor-wrap .wp-editor-tools, +.wp-editor-wrap .wp-switch-editor, +.wp-editor-wrap .wp-editor-tabs, +.wp-editor-wrap .wp-editor-container { + zoom: 100%; +} + +.wp-editor-wrap .wp-editor-container textarea.wp-editor-area { + width: 97%; +} + +#post-body.columns-2 #postbox-container-1 { + padding-right: 19px; +} + +.welcome-panel .wp-badge { + position: absolute; +} + +.welcome-panel .welcome-panel-column:first-child { + width: 35%; +} + +#adminmenuback { + right: 0; + background-image: none; +} + +#adminmenuwrap { + position: static; +} + +#adminmenu { + position: relative; +} + +#adminmenu, +#adminmenu a { + cursor: pointer; +} + +#adminmenu li.wp-menu-separator, +#adminmenu li.wp-menu-separator-last { + font-size: 1px; + line-height: 1; +} + +#adminmenu a.menu-top { + border-bottom: 0 none; + border-top: 1px solid #ddd; +} + +#adminmenu .separator { + font-size: 1px; + line-height: 1px; +} + +#adminmenu .wp-submenu { + right: 110px; +} + +#adminmenu .wp-submenu ul { + margin: 0; +} + +.folded #wpcontent, +.folded #wpfooter { + margin-right: 170px; +} + +.folded #adminmenuback, +.folded #adminmenuwrap, +.folded #adminmenu, +.folded #adminmenu li.menu-top { + width: 150px; +} + +.folded #adminmenu .wp-submenu { + border-top-color: transparent; +} + +.folded #adminmenu .wp-menu-name { + display: block; +} + +.folded #adminmenu .wp-submenu.sub-open, +.folded #adminmenu .opensub .wp-submenu { + right: 110px; +} + +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + top: -1px; + position: relative; +} + +.folded #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head { + background-color: transparent; +} + +#adminmenu .wp-submenu .wp-submenu-head { + border-top-color: #ddd; +} + +.folded #adminmenu .wp-submenu ul { + margin-right: 5px; +} + +#adminmenu li.menu-top { + margin-bottom: -2px; +} + +#adminmenu .wp-menu-arrow { + display: none !important; +} + +.js.folded #adminmenu li.menu-top { + display: block; + zoom: 100%; +} + +ul#adminmenu { + z-index: 99; +} + +#adminmenu li.menu-top a.menu-top { + min-width: auto; + width: auto; +} + +#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu { + font-style: normal; +} + +#wpcontent #adminmenu .wp-submenu li { + padding: 0; +} + +#adminmenu li.wp-has-current-submenu .wp-submenu { + right: -40px; +} + +#adminmenu .wp-menu-image { + display: none !important; +} + +#adminmenu a.menu-top .wp-menu-name { + padding-right: 8px; +} + +#collapse-menu { + line-height: 23px; +} + +#wpadminbar .ab-comments-icon { + padding-top: 7px; +} + + +.theme-browser .theme { + width: 30%; + margin: 0 0 4% 3%; + cursor: auto; +} + +.theme-browser .theme:hover, +.theme-browser .theme:focus { + cursor: auto; +} + +.theme-browser .theme .theme-screenshot { + height: 180px; +} + +.theme-browser .theme .theme-actions { + position: static; + background-color: #e8e8e8; +} + +.theme-browser .theme .more-details { + display: none; +} + +.plugins td, +.plugins th { + border-top: 1px solid #ddd; +} + +table.fixed th, +table.fixed td { + border-top: 1px solid #ddd; +} + +#wpbody-content input.button, +#wpbody-content input.button-primary { + overflow: visible; +} + +#dashboard-widgets h3 a { + height: 14px; + line-height: 14px; +} + +#dashboard_browser_nag { + color: #fff; +} + +#dashboard_browser_nag .browser-icon { + position: relative; +} + +.tablenav-pages .current-page { + vertical-align: middle; +} + +#wpbody-content .postbox { + border: 1px solid #ddd; +} + +#wpbody-content .postbox .hndle { + margin-bottom: -1px; +} + +.major-publishing-actions, +.wp-submenu, +.wp-submenu li, +#template, +#template div, +#editcat, +#addcat { + zoom: 100%; +} + +.wp-menu-arrow { + height: 28px; +} + +.submitbox { + margin-top: 10px; +} + +/* Inline Editor */ +#wpbody-content .quick-edit-row-post .inline-edit-col-left { + width: 39%; +} + +#wpbody-content .inline-edit-row-post .inline-edit-col-center { + width: 19%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-left { + width: 49%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-left { + width: 29%; +} + +.inline-edit-row .submit { + zoom: 100%; +} + +.inline-edit-row fieldset label span.title { + display: block; + float: right; + width: 5em; +} + +.inline-edit-row fieldset label span.input-text-wrap { + margin-right: 0; + zoom: 100%; +} + +#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input { + line-height: 130%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input { + width: 95%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input { + width: 8em; +} +/* end Inline Editor */ + +#titlediv #title { + width: 98%; +} + +.button, +input[type="reset"], +input[type="button"], +input[type="submit"] { + padding: 0 8px; + line-height: 20px; + height: auto; +} + +.button.button-large, +input[type="reset"].button-large, +input[type="button"].button-large, +input[type="submit"].button-large { + padding: 0 10px; + line-height: 24px; + height: auto; +} + +.button.button-small, +input[type="reset"].button-small, +input[type="button"].button-small, +input[type="submit"].button-small { + padding: 0 6px; + line-height: 16px; + height: auto; +} + +a.button { + margin: 1px; + padding: 1px 9px 2px; +} + +a.button.button-large { + padding: 1px 11px 2px; +} + +a.button.button-small { + padding: 1px 7px 2px; +} + +#screen-options-wrap { + overflow: hidden; +} + +#the-comment-list .comment-item, +#post-status-info, +#wpwrap, +#wrap, +#postdivrich, +#postdiv, +#poststuff, +.metabox-holder, +#titlediv, +#post-body, +#editorcontainer, +.tablenav, +.widget-liquid-left, +.widget-liquid-right, +#widgets-left, +.widgets-sortables, +#dragHelper, +.widget .widget-top, +.widget-control-actions, +.tagchecklist, +#col-container, +#col-left, +#col-right, +.fileedit-sub { + display: block; + zoom: 100%; +} + +p.search-box { + position: static; + float: left; + margin: -3px 0 4px; +} + +#widget-list .widget { + display: inline; +} + +#editorcontainer #content { + overflow: auto; + margin: auto; + width: 98%; +} + +form#template div { + width: 100%; +} + +.wp-editor-container .quicktags-toolbar input { + overflow: visible; + padding: 0 4px; +} + +#poststuff h2 { + font-size: 1.6em; +} + +#poststuff .inside #parent_id, +#poststuff .inside #page_template, +.inline-edit-row #post_parent, +.inline-edit-row select[name="page_template"] { + width: 250px; +} + +#submitdiv input, +#submitdiv select, +#submitdiv a.button { + position: relative; +} + +#bh { + margin: 7px 0 0 10px; + float: left; +} + +/* without this dashboard widgets appear in one column for some screen widths */ +div#dashboard-widgets { + padding-left: 1px; +} + +.tagchecklist > li, .tagchecklist .ntdelbutton { + display: inline-block; + display: block; +} + +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before { + outline: 1px solid #5b9dd9; +} + +.tablenav .button, +.nav .button { + padding-top: 2px; + padding-bottom: 2px; +} + +.tablenav select { + font-size: 13px; + display: inline-block; + vertical-align: top; + margin-top: 2px; +} + +.tablenav .actions select { + width: 155px; +} + +.subsubsub li { + display: inline; +} + +a.post-state-format { + text-indent: 0; + line-height: 0; + font-size: 0; +} + +table.ie-fixed { + table-layout: fixed; +} + +.widefat tr, +.widefat th, +.widefat thead td, +.widefat tfoot td { + margin-bottom: 0; + border-spacing: 0; +} + +.widefat th input, +.widefat thead td input, +.widefat tfoot td input { + margin: 0 5px 0 0; +} + +.widefat thead .check-column, +.widefat tfoot .check-column { + padding-top: 6px; +} + +.widefat tbody th.check-column, +.media.widefat tbody th.check-column { + padding: 4px 0 0; +} + +.widefat { + empty-cells: show; + border-collapse: collapse; +} + +.tablenav a.button { + display: inline-block; + padding: 2px 5px; +} + +.inactive-sidebar .widgets-sortables { + padding-bottom: 8px; +} + +#available-widgets .widget-holder { + padding-bottom: 65px; +} + +#widgets-left .inactive { + padding-bottom: 10px; +} + +.widget-liquid-right .widget, +.inactive-sidebar .widget { + position: relative; +} + +.inactive-sidebar .widget { + display: block; + float: right; +} + +#wpcontent .button-primary-disabled { + color: #9FD0D5; + background: #298CBA; +} + +#the-comment-list .unapproved tr, +#the-comment-list .unapproved td { + background-color: #ffffe0; +} + +.imgedit-submit { + width: 300px; +} + +#nav-menus-frame, +#wpbody, +.menu li { + zoom: 100%; +} + +#update-nav-menu #post-body { + overflow:hidden; +} + +.menu li { + min-width: 100%; +} + +.menu li.sortable-placeholder { + min-width: 400px; +} + +.available-theme { + display: inline; +} + +.available-theme ul { + margin: 0; +} + +.available-theme .action-links li { + padding-left: 7px; + margin-left: 7px; +} + +.about-wrap .three-col.about-updates .col-2 { + width: 15%; +} + +.about-wrap .about-password-meter input { + width: 98%; +} + +.revisions-tickmarks, +.revisions-tooltip { + display: none !important; +} + +.revisions.pinned .revisions-controls { + position: relative; +} + +input[type="password"], +.login form .input { + font-family: sans-serif; +} + +/* TinyMCE icons */ +.mce-btn i.mce-i-bold, +.mce-btn i.mce-i-italic, +.mce-btn i.mce-i-bullist, +.mce-btn i.mce-i-numlist, +.mce-btn i.mce-i-blockquote, +.mce-btn i.mce-i-alignleft, +.mce-btn i.mce-i-aligncenter, +.mce-btn i.mce-i-alignright, +.mce-btn i.mce-i-link, +.mce-btn i.mce-i-unlink, +.mce-btn i.mce-i-wp_more, +.mce-btn i.mce-i-strikethrough, +.mce-btn i.mce-i-spellchecker, +.mce-btn i.mce-i-fullscreen, +.mce-btn i.mce-i-wp_fullscreen, +.mce-btn i.mce-i-wp_adv, +.mce-btn i.mce-i-underline, +.mce-btn i.mce-i-alignjustify, +.mce-btn i.mce-i-forecolor, +.mce-btn i.mce-i-pastetext, +.mce-btn i.mce-i-pasteword, +.mce-btn i.mce-i-removeformat, +.mce-btn i.mce-i-charmap, +.mce-btn i.mce-i-outdent, +.mce-btn i.mce-i-indent, +.mce-btn i.mce-i-undo, +.mce-btn i.mce-i-redo, +.mce-btn i.mce-i-help, +.mce-btn i.mce-i-wp_help, +.mce-btn i.mce-i-wp-media-library, +.mce-btn i.mce-i-ltr, +.mce-btn i.mce-i-wp_page, +.mce-btn i.mce-i-hr, +.mce-close { + font-family: 'tinymce', Arial; + font-style: normal; + font-weight: 400; + font-variant: normal; + font-size: 16px; + margin-right: 0; + padding-left: 0; +} + +.mce-btn i.mce-i-wp_fullscreen, +.qt-fullscreen { + -ie7-icon: '\e023'; +} + +.mce-btn i.mce-i-wp_more, +.mce-btn i.mce-i-wp_page { + -ie7-icon: '\e027'; +} + +.mce-btn i.mce-i-wp_adv { + background-color: #a0a5aa; +} + +.mce-btn i.mce-i-help, +.mce-btn i.mce-i-wp_help { + -ie7-icon: '\e016'; +} + + +/* IE6 leftovers */ +* html .row-actions { + visibility: visible; +} + +* html div.widget-liquid-left, +* html div.widget-liquid-right { + display: block; + position: relative; +} + +* html #editorcontainer { + padding: 0; +} + +* html #poststuff h2 { + margin-right: 0; +} + +* html .stuffbox, +* html .stuffbox input, +* html .stuffbox textarea { + border: 1px solid #ddd; +} + +* html div.widget-liquid-left { + width: 99%; +} + +* html .widgets-sortables { + height: 50px; +} + +* html a#content_resize { + left: -2px; +} + +* html .widget-title h4 { + width: 205px; +} + +* html #removing-widget .in-widget-title { + display: none; +} + +* html .media-item .pinkynail { + height: 32px; + width: 40px; +} + +* html .describe .field input.text, +* html .describe .field textarea { + width: 440px; +} + +* html input { + border: 1px solid #ddd; +} + +* html .edit-box { + display: inline; +} + +* html .postbox-container .meta-box-sortables { + height: 300px; +} + +* html #wpbody-content #screen-options-link-wrap { + display: inline-block; + width: 150px; + text-align: center; +} + +* html #wpbody-content #contextual-help-link-wrap { + display: inline-block; + width: 100px; + text-align: center; +} + +* html #adminmenu { + margin-right: -80px; +} + +* html .folded #adminmenu { + margin-right: -22px; +} + +* html #wpcontent #adminmenu li.menu-top { + display: inline; + padding: 0; + margin: 0; +} + +* html #wpfooter { + margin: 0; +} + +* html #adminmenu div.wp-menu-image { + height: 29px; +} diff --git a/backend/wp-admin/css/ie-rtl.min.css b/backend/wp-admin/css/ie-rtl.min.css new file mode 100644 index 0000000..d7a680f --- /dev/null +++ b/backend/wp-admin/css/ie-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#dashboard-widgets form .input-text-wrap input,#dashboard-widgets form .textarea-wrap textarea{width:99%}#dashboard-widgets form #title{width:98%}#wpbody-content #dashboard-widgets .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets #postbox-container-2,#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:left;width:50.5%}#dashboard-widgets #postbox-container-3 .empty-container,#dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}.wp-editor-wrap .wp-editor-container,.wp-editor-wrap .wp-editor-tabs,.wp-editor-wrap .wp-editor-tools,.wp-editor-wrap .wp-switch-editor{zoom:100%}.wp-editor-wrap .wp-editor-container textarea.wp-editor-area{width:97%}#post-body.columns-2 #postbox-container-1{padding-right:19px}.welcome-panel .wp-badge{position:absolute}.welcome-panel .welcome-panel-column:first-child{width:35%}#adminmenuback{right:0;background-image:none}#adminmenu .wp-submenu,.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .wp-submenu.sub-open{right:110px}#adminmenuwrap{position:static}#adminmenu{position:relative}#adminmenu,#adminmenu a{cursor:pointer}#adminmenu li.wp-menu-separator,#adminmenu li.wp-menu-separator-last{font-size:1px;line-height:1}#adminmenu a.menu-top{border-bottom:0 none;border-top:1px solid #ddd}#adminmenu .separator{font-size:1px;line-height:1px}#adminmenu .wp-submenu ul{margin:0}.folded #wpcontent,.folded #wpfooter{margin-right:170px}.folded #adminmenu,.folded #adminmenu li.menu-top,.folded #adminmenuback,.folded #adminmenuwrap{width:150px}.folded #adminmenu .wp-submenu{border-top-color:transparent}.folded #adminmenu .wp-menu-name{display:block}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{top:-1px;position:relative}.folded #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head{background-color:transparent}#adminmenu .wp-submenu .wp-submenu-head{border-top-color:#ddd}#wpbody-content .postbox,* html .stuffbox,* html .stuffbox input,* html .stuffbox textarea,* html input{border:1px solid #ddd}.folded #adminmenu .wp-submenu ul{margin-right:5px}#adminmenu li.menu-top{margin-bottom:-2px}#adminmenu .wp-menu-arrow{display:none!important}.js.folded #adminmenu li.menu-top{display:block;zoom:100%}ul#adminmenu{z-index:99}#adminmenu li.menu-top a.menu-top{min-width:auto;width:auto}#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu{font-style:normal}#wpcontent #adminmenu .wp-submenu li{padding:0}#adminmenu li.wp-has-current-submenu .wp-submenu{right:-40px}#adminmenu .wp-menu-image{display:none!important}#adminmenu a.menu-top .wp-menu-name{padding-right:8px}#collapse-menu{line-height:23px}#wpadminbar .ab-comments-icon{padding-top:7px}.theme-browser .theme{width:30%;margin:0 0 4% 3%;cursor:auto}.theme-browser .theme:focus,.theme-browser .theme:hover{cursor:auto}.theme-browser .theme .theme-screenshot{height:180px}.theme-browser .theme .theme-actions{position:static;background-color:#e8e8e8}.theme-browser .theme .more-details{display:none}.plugins td,.plugins th,table.fixed td,table.fixed th{border-top:1px solid #ddd}#wpbody-content input.button,#wpbody-content input.button-primary{overflow:visible}#dashboard-widgets h3 a{height:14px;line-height:14px}#dashboard_browser_nag{color:#fff}#dashboard_browser_nag .browser-icon{position:relative}.tablenav-pages .current-page{vertical-align:middle}#wpbody-content .postbox .hndle{margin-bottom:-1px}#addcat,#editcat,#template,#template div,.major-publishing-actions,.wp-submenu,.wp-submenu li{zoom:100%}.wp-menu-arrow{height:28px}.submitbox{margin-top:10px}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:39%}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:19%}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:49%}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:29%}.inline-edit-row .submit{zoom:100%}.inline-edit-row fieldset label span.title{display:block;float:right;width:5em}.inline-edit-row fieldset label span.input-text-wrap{margin-right:0;zoom:100%}#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input{line-height:130%}#wpbody-content .inline-edit-row .input-text-wrap input{width:95%}#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input{width:8em}#titlediv #title{width:98%}.button,input[type=reset],input[type=button],input[type=submit]{padding:0 8px;line-height:20px;height:auto}.button.button-large,input[type=reset].button-large,input[type=button].button-large,input[type=submit].button-large{padding:0 10px;line-height:24px;height:auto}.button.button-small,input[type=reset].button-small,input[type=button].button-small,input[type=submit].button-small{padding:0 6px;line-height:16px;height:auto}a.button{margin:1px;padding:1px 9px 2px}a.button.button-large{padding:1px 11px 2px}a.button.button-small{padding:1px 7px 2px}#screen-options-wrap{overflow:hidden}#col-container,#col-left,#col-right,#dragHelper,#editorcontainer,#post-body,#post-status-info,#postdiv,#postdivrich,#poststuff,#the-comment-list .comment-item,#titlediv,#widgets-left,#wpwrap,#wrap,.fileedit-sub,.metabox-holder,.tablenav,.tagchecklist,.widget .widget-top,.widget-control-actions,.widget-liquid-left,.widget-liquid-right,.widgets-sortables{display:block;zoom:100%}p.search-box{position:static;float:left;margin:-3px 0 4px}#submitdiv a.button,#submitdiv input,#submitdiv select,.inactive-sidebar .widget,.revisions.pinned .revisions-controls,.widget-liquid-right .widget{position:relative}#widget-list .widget{display:inline}#editorcontainer #content{overflow:auto;margin:auto;width:98%}form#template div{width:100%}.wp-editor-container .quicktags-toolbar input{overflow:visible;padding:0 4px}#poststuff h2{font-size:1.6em}#poststuff .inside #page_template,#poststuff .inside #parent_id,.inline-edit-row #post_parent,.inline-edit-row select[name=page_template]{width:250px}#bh{margin:7px 0 0 10px;float:left}div#dashboard-widgets{padding-left:1px}.tagchecklist .ntdelbutton,.tagchecklist>li{display:inline-block;display:block}.tagchecklist .ntdelbutton:focus .remove-tag-icon:before{outline:#5b9dd9 solid 1px}.nav .button,.tablenav .button{padding-top:2px;padding-bottom:2px}.tablenav select{font-size:13px;display:inline-block;vertical-align:top;margin-top:2px}.tablenav .actions select{width:155px}.subsubsub li{display:inline}a.post-state-format{text-indent:0;line-height:0;font-size:0}table.ie-fixed{table-layout:fixed}.widefat tfoot td,.widefat th,.widefat thead td,.widefat tr{margin-bottom:0;border-spacing:0}.widefat tfoot td input,.widefat th input,.widefat thead td input{margin:0 5px 0 0}.widefat tfoot .check-column,.widefat thead .check-column{padding-top:6px}.media.widefat tbody th.check-column,.widefat tbody th.check-column{padding:4px 0 0}.widefat{empty-cells:show;border-collapse:collapse}.tablenav a.button{display:inline-block;padding:2px 5px}.inactive-sidebar .widgets-sortables{padding-bottom:8px}#available-widgets .widget-holder{padding-bottom:65px}#widgets-left .inactive{padding-bottom:10px}.inactive-sidebar .widget{display:block;float:right}#wpcontent .button-primary-disabled{color:#9FD0D5;background:#298CBA}#the-comment-list .unapproved td,#the-comment-list .unapproved tr{background-color:#ffffe0}.imgedit-submit{width:300px}#nav-menus-frame,#wpbody,.menu li{zoom:100%}#update-nav-menu #post-body{overflow:hidden}.menu li{min-width:100%}.menu li.sortable-placeholder{min-width:400px}.available-theme{display:inline}.available-theme ul{margin:0}.available-theme .action-links li{padding-left:7px;margin-left:7px}.about-wrap .three-col.about-updates .col-2{width:15%}.about-wrap .about-password-meter input{width:98%}.revisions-tickmarks,.revisions-tooltip{display:none!important}.login form .input,input[type=password]{font-family:sans-serif}.mce-btn i.mce-i-aligncenter,.mce-btn i.mce-i-alignjustify,.mce-btn i.mce-i-alignleft,.mce-btn i.mce-i-alignright,.mce-btn i.mce-i-blockquote,.mce-btn i.mce-i-bold,.mce-btn i.mce-i-bullist,.mce-btn i.mce-i-charmap,.mce-btn i.mce-i-forecolor,.mce-btn i.mce-i-fullscreen,.mce-btn i.mce-i-help,.mce-btn i.mce-i-hr,.mce-btn i.mce-i-indent,.mce-btn i.mce-i-italic,.mce-btn i.mce-i-link,.mce-btn i.mce-i-ltr,.mce-btn i.mce-i-numlist,.mce-btn i.mce-i-outdent,.mce-btn i.mce-i-pastetext,.mce-btn i.mce-i-pasteword,.mce-btn i.mce-i-redo,.mce-btn i.mce-i-removeformat,.mce-btn i.mce-i-spellchecker,.mce-btn i.mce-i-strikethrough,.mce-btn i.mce-i-underline,.mce-btn i.mce-i-undo,.mce-btn i.mce-i-unlink,.mce-btn i.mce-i-wp-media-library,.mce-btn i.mce-i-wp_adv,.mce-btn i.mce-i-wp_fullscreen,.mce-btn i.mce-i-wp_help,.mce-btn i.mce-i-wp_more,.mce-btn i.mce-i-wp_page,.mce-close{font-family:tinymce,Arial;font-style:normal;font-weight:400;font-variant:normal;font-size:16px;margin-right:0;padding-left:0}.mce-btn i.mce-i-wp_fullscreen,.qt-fullscreen{-ie7-icon:'\e023'}.mce-btn i.mce-i-wp_more,.mce-btn i.mce-i-wp_page{-ie7-icon:'\e027'}.mce-btn i.mce-i-wp_adv{background-color:#a0a5aa}.mce-btn i.mce-i-help,.mce-btn i.mce-i-wp_help{-ie7-icon:'\e016'}* html .row-actions{visibility:visible}* html div.widget-liquid-left,* html div.widget-liquid-right{display:block;position:relative}* html #editorcontainer{padding:0}* html #poststuff h2{margin-right:0}* html div.widget-liquid-left{width:99%}* html .widgets-sortables{height:50px}* html a#content_resize{left:-2px}* html .widget-title h4{width:205px}* html #removing-widget .in-widget-title{display:none}* html .media-item .pinkynail{height:32px;width:40px}* html .describe .field input.text,* html .describe .field textarea{width:440px}* html .edit-box{display:inline}* html .postbox-container .meta-box-sortables{height:300px}* html #wpbody-content #screen-options-link-wrap{display:inline-block;width:150px;text-align:center}* html #wpbody-content #contextual-help-link-wrap{display:inline-block;width:100px;text-align:center}* html #adminmenu{margin-right:-80px}* html .folded #adminmenu{margin-right:-22px}* html #wpcontent #adminmenu li.menu-top{display:inline;padding:0;margin:0}* html #wpfooter{margin:0}* html #adminmenu div.wp-menu-image{height:29px} \ No newline at end of file diff --git a/backend/wp-admin/css/ie.css b/backend/wp-admin/css/ie.css new file mode 100644 index 0000000..e3dc913 --- /dev/null +++ b/backend/wp-admin/css/ie.css @@ -0,0 +1,770 @@ +/* Fixes for IE 7 bugs */ + +#dashboard-widgets form .input-text-wrap input, +#dashboard-widgets form .textarea-wrap textarea { + width: 99%; +} + +#dashboard-widgets form #title { + width: 98%; +} + +#wpbody-content #dashboard-widgets .postbox-container { + width: 49.5%; +} + +#wpbody-content #dashboard-widgets #postbox-container-2, +#wpbody-content #dashboard-widgets #postbox-container-3, +#wpbody-content #dashboard-widgets #postbox-container-4 { + float: right; + width: 50.5%; +} + +#dashboard-widgets #postbox-container-3 .empty-container, +#dashboard-widgets #postbox-container-4 .empty-container { + border: 0 none; + height: 0; + min-height: 0; +} + +.wp-editor-wrap .wp-editor-tools, +.wp-editor-wrap .wp-switch-editor, +.wp-editor-wrap .wp-editor-tabs, +.wp-editor-wrap .wp-editor-container { + zoom: 100%; +} + +.wp-editor-wrap .wp-editor-container textarea.wp-editor-area { + width: 97%; +} + +#post-body.columns-2 #postbox-container-1 { + padding-left: 19px; +} + +.welcome-panel .wp-badge { + position: absolute; +} + +.welcome-panel .welcome-panel-column:first-child { + width: 35%; +} + +#adminmenuback { + left: 0; + background-image: none; +} + +#adminmenuwrap { + position: static; +} + +#adminmenu { + position: relative; +} + +#adminmenu, +#adminmenu a { + cursor: pointer; +} + +#adminmenu li.wp-menu-separator, +#adminmenu li.wp-menu-separator-last { + font-size: 1px; + line-height: 1; +} + +#adminmenu a.menu-top { + border-bottom: 0 none; + border-top: 1px solid #ddd; +} + +#adminmenu .separator { + font-size: 1px; + line-height: 1px; +} + +#adminmenu .wp-submenu { + left: 110px; +} + +#adminmenu .wp-submenu ul { + margin: 0; +} + +.folded #wpcontent, +.folded #wpfooter { + margin-left: 170px; +} + +.folded #adminmenuback, +.folded #adminmenuwrap, +.folded #adminmenu, +.folded #adminmenu li.menu-top { + width: 150px; +} + +.folded #adminmenu .wp-submenu { + border-top-color: transparent; +} + +.folded #adminmenu .wp-menu-name { + display: block; +} + +.folded #adminmenu .wp-submenu.sub-open, +.folded #adminmenu .opensub .wp-submenu { + left: 110px; +} + +.folded #adminmenu a.wp-has-current-submenu:focus + .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu { + top: -1px; + position: relative; +} + +.folded #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head { + background-color: transparent; +} + +#adminmenu .wp-submenu .wp-submenu-head { + border-top-color: #ddd; +} + +.folded #adminmenu .wp-submenu ul { + margin-left: 5px; +} + +#adminmenu li.menu-top { + margin-bottom: -2px; +} + +#adminmenu .wp-menu-arrow { + display: none !important; +} + +.js.folded #adminmenu li.menu-top { + display: block; + zoom: 100%; +} + +ul#adminmenu { + z-index: 99; +} + +#adminmenu li.menu-top a.menu-top { + min-width: auto; + width: auto; +} + +#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu { + font-style: normal; +} + +#wpcontent #adminmenu .wp-submenu li { + padding: 0; +} + +#adminmenu li.wp-has-current-submenu .wp-submenu { + left: -40px; +} + +#adminmenu .wp-menu-image { + display: none !important; +} + +#adminmenu a.menu-top .wp-menu-name { + padding-left: 8px; +} + +#collapse-menu { + line-height: 23px; +} + +#wpadminbar .ab-comments-icon { + padding-top: 7px; +} + + +.theme-browser .theme { + width: 30%; + margin: 0 3% 4% 0; + cursor: auto; +} + +.theme-browser .theme:hover, +.theme-browser .theme:focus { + cursor: auto; +} + +.theme-browser .theme .theme-screenshot { + height: 180px; +} + +.theme-browser .theme .theme-actions { + position: static; + background-color: #e8e8e8; +} + +.theme-browser .theme .more-details { + display: none; +} + +.plugins td, +.plugins th { + border-top: 1px solid #ddd; +} + +table.fixed th, +table.fixed td { + border-top: 1px solid #ddd; +} + +#wpbody-content input.button, +#wpbody-content input.button-primary { + overflow: visible; +} + +#dashboard-widgets h3 a { + height: 14px; + line-height: 14px; +} + +#dashboard_browser_nag { + color: #fff; +} + +#dashboard_browser_nag .browser-icon { + position: relative; +} + +.tablenav-pages .current-page { + vertical-align: middle; +} + +#wpbody-content .postbox { + border: 1px solid #ddd; +} + +#wpbody-content .postbox .hndle { + margin-bottom: -1px; +} + +.major-publishing-actions, +.wp-submenu, +.wp-submenu li, +#template, +#template div, +#editcat, +#addcat { + zoom: 100%; +} + +.wp-menu-arrow { + height: 28px; +} + +.submitbox { + margin-top: 10px; +} + +/* Inline Editor */ +#wpbody-content .quick-edit-row-post .inline-edit-col-left { + width: 39%; +} + +#wpbody-content .inline-edit-row-post .inline-edit-col-center { + width: 19%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-left { + width: 49%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-left { + width: 29%; +} + +.inline-edit-row .submit { + zoom: 100%; +} + +.inline-edit-row fieldset label span.title { + display: block; + float: left; + width: 5em; +} + +.inline-edit-row fieldset label span.input-text-wrap { + margin-left: 0; + zoom: 100%; +} + +#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input { + line-height: 130%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input { + width: 95%; +} + +#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input { + width: 8em; +} +/* end Inline Editor */ + +#titlediv #title { + width: 98%; +} + +.button, +input[type="reset"], +input[type="button"], +input[type="submit"] { + padding: 0 8px; + line-height: 20px; + height: auto; +} + +.button.button-large, +input[type="reset"].button-large, +input[type="button"].button-large, +input[type="submit"].button-large { + padding: 0 10px; + line-height: 24px; + height: auto; +} + +.button.button-small, +input[type="reset"].button-small, +input[type="button"].button-small, +input[type="submit"].button-small { + padding: 0 6px; + line-height: 16px; + height: auto; +} + +a.button { + margin: 1px; + padding: 1px 9px 2px; +} + +a.button.button-large { + padding: 1px 11px 2px; +} + +a.button.button-small { + padding: 1px 7px 2px; +} + +#screen-options-wrap { + overflow: hidden; +} + +#the-comment-list .comment-item, +#post-status-info, +#wpwrap, +#wrap, +#postdivrich, +#postdiv, +#poststuff, +.metabox-holder, +#titlediv, +#post-body, +#editorcontainer, +.tablenav, +.widget-liquid-left, +.widget-liquid-right, +#widgets-left, +.widgets-sortables, +#dragHelper, +.widget .widget-top, +.widget-control-actions, +.tagchecklist, +#col-container, +#col-left, +#col-right, +.fileedit-sub { + display: block; + zoom: 100%; +} + +p.search-box { + position: static; + float: right; + margin: -3px 0 4px; +} + +#widget-list .widget { + display: inline; +} + +#editorcontainer #content { + overflow: auto; + margin: auto; + width: 98%; +} + +form#template div { + width: 100%; +} + +.wp-editor-container .quicktags-toolbar input { + overflow: visible; + padding: 0 4px; +} + +#poststuff h2 { + font-size: 1.6em; +} + +#poststuff .inside #parent_id, +#poststuff .inside #page_template, +.inline-edit-row #post_parent, +.inline-edit-row select[name="page_template"] { + width: 250px; +} + +#submitdiv input, +#submitdiv select, +#submitdiv a.button { + position: relative; +} + +#bh { + margin: 7px 10px 0 0; + float: right; +} + +/* without this dashboard widgets appear in one column for some screen widths */ +div#dashboard-widgets { + padding-right: 1px; +} + +.tagchecklist > li, .tagchecklist .ntdelbutton { + display: inline-block; + display: block; +} + +.tagchecklist .ntdelbutton:focus .remove-tag-icon:before { + outline: 1px solid #5b9dd9; +} + +.tablenav .button, +.nav .button { + padding-top: 2px; + padding-bottom: 2px; +} + +.tablenav select { + font-size: 13px; + display: inline-block; + vertical-align: top; + margin-top: 2px; +} + +.tablenav .actions select { + width: 155px; +} + +.subsubsub li { + display: inline; +} + +a.post-state-format { + text-indent: 0; + line-height: 0; + font-size: 0; +} + +table.ie-fixed { + table-layout: fixed; +} + +.widefat tr, +.widefat th, +.widefat thead td, +.widefat tfoot td { + margin-bottom: 0; + border-spacing: 0; +} + +.widefat th input, +.widefat thead td input, +.widefat tfoot td input { + margin: 0 0 0 5px; +} + +.widefat thead .check-column, +.widefat tfoot .check-column { + padding-top: 6px; +} + +.widefat tbody th.check-column, +.media.widefat tbody th.check-column { + padding: 4px 0 0; +} + +.widefat { + empty-cells: show; + border-collapse: collapse; +} + +.tablenav a.button { + display: inline-block; + padding: 2px 5px; +} + +.inactive-sidebar .widgets-sortables { + padding-bottom: 8px; +} + +#available-widgets .widget-holder { + padding-bottom: 65px; +} + +#widgets-left .inactive { + padding-bottom: 10px; +} + +.widget-liquid-right .widget, +.inactive-sidebar .widget { + position: relative; +} + +.inactive-sidebar .widget { + display: block; + float: left; +} + +#wpcontent .button-primary-disabled { + color: #9FD0D5; + background: #298CBA; +} + +#the-comment-list .unapproved tr, +#the-comment-list .unapproved td { + background-color: #ffffe0; +} + +.imgedit-submit { + width: 300px; +} + +#nav-menus-frame, +#wpbody, +.menu li { + zoom: 100%; +} + +#update-nav-menu #post-body { + overflow:hidden; +} + +.menu li { + min-width: 100%; +} + +.menu li.sortable-placeholder { + min-width: 400px; +} + +.available-theme { + display: inline; +} + +.available-theme ul { + margin: 0; +} + +.available-theme .action-links li { + padding-right: 7px; + margin-right: 7px; +} + +.about-wrap .three-col.about-updates .col-2 { + width: 15%; +} + +.about-wrap .about-password-meter input { + width: 98%; +} + +.revisions-tickmarks, +.revisions-tooltip { + display: none !important; +} + +.revisions.pinned .revisions-controls { + position: relative; +} + +input[type="password"], +.login form .input { + font-family: sans-serif; +} + +/* TinyMCE icons */ +.mce-btn i.mce-i-bold, +.mce-btn i.mce-i-italic, +.mce-btn i.mce-i-bullist, +.mce-btn i.mce-i-numlist, +.mce-btn i.mce-i-blockquote, +.mce-btn i.mce-i-alignleft, +.mce-btn i.mce-i-aligncenter, +.mce-btn i.mce-i-alignright, +.mce-btn i.mce-i-link, +.mce-btn i.mce-i-unlink, +.mce-btn i.mce-i-wp_more, +.mce-btn i.mce-i-strikethrough, +.mce-btn i.mce-i-spellchecker, +.mce-btn i.mce-i-fullscreen, +.mce-btn i.mce-i-wp_fullscreen, +.mce-btn i.mce-i-wp_adv, +.mce-btn i.mce-i-underline, +.mce-btn i.mce-i-alignjustify, +.mce-btn i.mce-i-forecolor, +.mce-btn i.mce-i-pastetext, +.mce-btn i.mce-i-pasteword, +.mce-btn i.mce-i-removeformat, +.mce-btn i.mce-i-charmap, +.mce-btn i.mce-i-outdent, +.mce-btn i.mce-i-indent, +.mce-btn i.mce-i-undo, +.mce-btn i.mce-i-redo, +.mce-btn i.mce-i-help, +.mce-btn i.mce-i-wp_help, +.mce-btn i.mce-i-wp-media-library, +.mce-btn i.mce-i-ltr, +.mce-btn i.mce-i-wp_page, +.mce-btn i.mce-i-hr, +.mce-close { + font-family: 'tinymce', Arial; + font-style: normal; + font-weight: 400; + font-variant: normal; + font-size: 16px; + margin-left: 0; + padding-right: 0; +} + +.mce-btn i.mce-i-wp_fullscreen, +.qt-fullscreen { + -ie7-icon: '\e023'; +} + +.mce-btn i.mce-i-wp_more, +.mce-btn i.mce-i-wp_page { + -ie7-icon: '\e027'; +} + +.mce-btn i.mce-i-wp_adv { + background-color: #a0a5aa; +} + +.mce-btn i.mce-i-help, +.mce-btn i.mce-i-wp_help { + -ie7-icon: '\e016'; +} + + +/* IE6 leftovers */ +* html .row-actions { + visibility: visible; +} + +* html div.widget-liquid-left, +* html div.widget-liquid-right { + display: block; + position: relative; +} + +* html #editorcontainer { + padding: 0; +} + +* html #poststuff h2 { + margin-left: 0; +} + +* html .stuffbox, +* html .stuffbox input, +* html .stuffbox textarea { + border: 1px solid #ddd; +} + +* html div.widget-liquid-left { + width: 99%; +} + +* html .widgets-sortables { + height: 50px; +} + +* html a#content_resize { + right: -2px; +} + +* html .widget-title h4 { + width: 205px; +} + +* html #removing-widget .in-widget-title { + display: none; +} + +* html .media-item .pinkynail { + height: 32px; + width: 40px; +} + +* html .describe .field input.text, +* html .describe .field textarea { + width: 440px; +} + +* html input { + border: 1px solid #ddd; +} + +* html .edit-box { + display: inline; +} + +* html .postbox-container .meta-box-sortables { + height: 300px; +} + +* html #wpbody-content #screen-options-link-wrap { + display: inline-block; + width: 150px; + text-align: center; +} + +* html #wpbody-content #contextual-help-link-wrap { + display: inline-block; + width: 100px; + text-align: center; +} + +* html #adminmenu { + margin-left: -80px; +} + +* html .folded #adminmenu { + margin-left: -22px; +} + +* html #wpcontent #adminmenu li.menu-top { + display: inline; + padding: 0; + margin: 0; +} + +* html #wpfooter { + margin: 0; +} + +* html #adminmenu div.wp-menu-image { + height: 29px; +} diff --git a/backend/wp-admin/css/ie.min.css b/backend/wp-admin/css/ie.min.css new file mode 100644 index 0000000..c942844 --- /dev/null +++ b/backend/wp-admin/css/ie.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#dashboard-widgets form .input-text-wrap input,#dashboard-widgets form .textarea-wrap textarea{width:99%}#dashboard-widgets form #title{width:98%}#wpbody-content #dashboard-widgets .postbox-container{width:49.5%}#wpbody-content #dashboard-widgets #postbox-container-2,#wpbody-content #dashboard-widgets #postbox-container-3,#wpbody-content #dashboard-widgets #postbox-container-4{float:right;width:50.5%}#dashboard-widgets #postbox-container-3 .empty-container,#dashboard-widgets #postbox-container-4 .empty-container{border:0;height:0;min-height:0}.wp-editor-wrap .wp-editor-container,.wp-editor-wrap .wp-editor-tabs,.wp-editor-wrap .wp-editor-tools,.wp-editor-wrap .wp-switch-editor{zoom:100%}.wp-editor-wrap .wp-editor-container textarea.wp-editor-area{width:97%}#post-body.columns-2 #postbox-container-1{padding-left:19px}.welcome-panel .wp-badge{position:absolute}.welcome-panel .welcome-panel-column:first-child{width:35%}#adminmenuback{left:0;background-image:none}#adminmenu .wp-submenu,.folded #adminmenu .opensub .wp-submenu,.folded #adminmenu .wp-submenu.sub-open{left:110px}#adminmenuwrap{position:static}#adminmenu{position:relative}#adminmenu,#adminmenu a{cursor:pointer}#adminmenu li.wp-menu-separator,#adminmenu li.wp-menu-separator-last{font-size:1px;line-height:1}#adminmenu a.menu-top{border-bottom:0 none;border-top:1px solid #ddd}#adminmenu .separator{font-size:1px;line-height:1px}#adminmenu .wp-submenu ul{margin:0}.folded #wpcontent,.folded #wpfooter{margin-left:170px}.folded #adminmenu,.folded #adminmenu li.menu-top,.folded #adminmenuback,.folded #adminmenuwrap{width:150px}.folded #adminmenu .wp-submenu{border-top-color:transparent}.folded #adminmenu .wp-menu-name{display:block}.folded #adminmenu .wp-has-current-submenu .wp-submenu,.folded #adminmenu a.wp-has-current-submenu:focus+.wp-submenu{top:-1px;position:relative}.folded #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head{background-color:transparent}#adminmenu .wp-submenu .wp-submenu-head{border-top-color:#ddd}#wpbody-content .postbox,* html .stuffbox,* html .stuffbox input,* html .stuffbox textarea,* html input{border:1px solid #ddd}.folded #adminmenu .wp-submenu ul{margin-left:5px}#adminmenu li.menu-top{margin-bottom:-2px}#adminmenu .wp-menu-arrow{display:none!important}.js.folded #adminmenu li.menu-top{display:block;zoom:100%}ul#adminmenu{z-index:99}#adminmenu li.menu-top a.menu-top{min-width:auto;width:auto}#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu{font-style:normal}#wpcontent #adminmenu .wp-submenu li{padding:0}#adminmenu li.wp-has-current-submenu .wp-submenu{left:-40px}#adminmenu .wp-menu-image{display:none!important}#adminmenu a.menu-top .wp-menu-name{padding-left:8px}#collapse-menu{line-height:23px}#wpadminbar .ab-comments-icon{padding-top:7px}.theme-browser .theme{width:30%;margin:0 3% 4% 0;cursor:auto}.theme-browser .theme:focus,.theme-browser .theme:hover{cursor:auto}.theme-browser .theme .theme-screenshot{height:180px}.theme-browser .theme .theme-actions{position:static;background-color:#e8e8e8}.theme-browser .theme .more-details{display:none}.plugins td,.plugins th,table.fixed td,table.fixed th{border-top:1px solid #ddd}#wpbody-content input.button,#wpbody-content input.button-primary{overflow:visible}#dashboard-widgets h3 a{height:14px;line-height:14px}#dashboard_browser_nag{color:#fff}#dashboard_browser_nag .browser-icon{position:relative}.tablenav-pages .current-page{vertical-align:middle}#wpbody-content .postbox .hndle{margin-bottom:-1px}#addcat,#editcat,#template,#template div,.major-publishing-actions,.wp-submenu,.wp-submenu li{zoom:100%}.wp-menu-arrow{height:28px}.submitbox{margin-top:10px}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:39%}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:19%}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:49%}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:29%}.inline-edit-row .submit{zoom:100%}.inline-edit-row fieldset label span.title{display:block;float:left;width:5em}.inline-edit-row fieldset label span.input-text-wrap{margin-left:0;zoom:100%}#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input{line-height:130%}#wpbody-content .inline-edit-row .input-text-wrap input{width:95%}#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input{width:8em}#titlediv #title{width:98%}.button,input[type=reset],input[type=button],input[type=submit]{padding:0 8px;line-height:20px;height:auto}.button.button-large,input[type=reset].button-large,input[type=button].button-large,input[type=submit].button-large{padding:0 10px;line-height:24px;height:auto}.button.button-small,input[type=reset].button-small,input[type=button].button-small,input[type=submit].button-small{padding:0 6px;line-height:16px;height:auto}a.button{margin:1px;padding:1px 9px 2px}a.button.button-large{padding:1px 11px 2px}a.button.button-small{padding:1px 7px 2px}#screen-options-wrap{overflow:hidden}#col-container,#col-left,#col-right,#dragHelper,#editorcontainer,#post-body,#post-status-info,#postdiv,#postdivrich,#poststuff,#the-comment-list .comment-item,#titlediv,#widgets-left,#wpwrap,#wrap,.fileedit-sub,.metabox-holder,.tablenav,.tagchecklist,.widget .widget-top,.widget-control-actions,.widget-liquid-left,.widget-liquid-right,.widgets-sortables{display:block;zoom:100%}p.search-box{position:static;float:right;margin:-3px 0 4px}#submitdiv a.button,#submitdiv input,#submitdiv select,.inactive-sidebar .widget,.revisions.pinned .revisions-controls,.widget-liquid-right .widget{position:relative}#widget-list .widget{display:inline}#editorcontainer #content{overflow:auto;margin:auto;width:98%}form#template div{width:100%}.wp-editor-container .quicktags-toolbar input{overflow:visible;padding:0 4px}#poststuff h2{font-size:1.6em}#poststuff .inside #page_template,#poststuff .inside #parent_id,.inline-edit-row #post_parent,.inline-edit-row select[name=page_template]{width:250px}#bh{margin:7px 10px 0 0;float:right}div#dashboard-widgets{padding-right:1px}.tagchecklist .ntdelbutton,.tagchecklist>li{display:inline-block;display:block}.tagchecklist .ntdelbutton:focus .remove-tag-icon:before{outline:#5b9dd9 solid 1px}.nav .button,.tablenav .button{padding-top:2px;padding-bottom:2px}.tablenav select{font-size:13px;display:inline-block;vertical-align:top;margin-top:2px}.tablenav .actions select{width:155px}.subsubsub li{display:inline}a.post-state-format{text-indent:0;line-height:0;font-size:0}table.ie-fixed{table-layout:fixed}.widefat tfoot td,.widefat th,.widefat thead td,.widefat tr{margin-bottom:0;border-spacing:0}.widefat tfoot td input,.widefat th input,.widefat thead td input{margin:0 0 0 5px}.widefat tfoot .check-column,.widefat thead .check-column{padding-top:6px}.media.widefat tbody th.check-column,.widefat tbody th.check-column{padding:4px 0 0}.widefat{empty-cells:show;border-collapse:collapse}.tablenav a.button{display:inline-block;padding:2px 5px}.inactive-sidebar .widgets-sortables{padding-bottom:8px}#available-widgets .widget-holder{padding-bottom:65px}#widgets-left .inactive{padding-bottom:10px}.inactive-sidebar .widget{display:block;float:left}#wpcontent .button-primary-disabled{color:#9FD0D5;background:#298CBA}#the-comment-list .unapproved td,#the-comment-list .unapproved tr{background-color:#ffffe0}.imgedit-submit{width:300px}#nav-menus-frame,#wpbody,.menu li{zoom:100%}#update-nav-menu #post-body{overflow:hidden}.menu li{min-width:100%}.menu li.sortable-placeholder{min-width:400px}.available-theme{display:inline}.available-theme ul{margin:0}.available-theme .action-links li{padding-right:7px;margin-right:7px}.about-wrap .three-col.about-updates .col-2{width:15%}.about-wrap .about-password-meter input{width:98%}.revisions-tickmarks,.revisions-tooltip{display:none!important}.login form .input,input[type=password]{font-family:sans-serif}.mce-btn i.mce-i-aligncenter,.mce-btn i.mce-i-alignjustify,.mce-btn i.mce-i-alignleft,.mce-btn i.mce-i-alignright,.mce-btn i.mce-i-blockquote,.mce-btn i.mce-i-bold,.mce-btn i.mce-i-bullist,.mce-btn i.mce-i-charmap,.mce-btn i.mce-i-forecolor,.mce-btn i.mce-i-fullscreen,.mce-btn i.mce-i-help,.mce-btn i.mce-i-hr,.mce-btn i.mce-i-indent,.mce-btn i.mce-i-italic,.mce-btn i.mce-i-link,.mce-btn i.mce-i-ltr,.mce-btn i.mce-i-numlist,.mce-btn i.mce-i-outdent,.mce-btn i.mce-i-pastetext,.mce-btn i.mce-i-pasteword,.mce-btn i.mce-i-redo,.mce-btn i.mce-i-removeformat,.mce-btn i.mce-i-spellchecker,.mce-btn i.mce-i-strikethrough,.mce-btn i.mce-i-underline,.mce-btn i.mce-i-undo,.mce-btn i.mce-i-unlink,.mce-btn i.mce-i-wp-media-library,.mce-btn i.mce-i-wp_adv,.mce-btn i.mce-i-wp_fullscreen,.mce-btn i.mce-i-wp_help,.mce-btn i.mce-i-wp_more,.mce-btn i.mce-i-wp_page,.mce-close{font-family:tinymce,Arial;font-style:normal;font-weight:400;font-variant:normal;font-size:16px;margin-left:0;padding-right:0}.mce-btn i.mce-i-wp_fullscreen,.qt-fullscreen{-ie7-icon:'\e023'}.mce-btn i.mce-i-wp_more,.mce-btn i.mce-i-wp_page{-ie7-icon:'\e027'}.mce-btn i.mce-i-wp_adv{background-color:#a0a5aa}.mce-btn i.mce-i-help,.mce-btn i.mce-i-wp_help{-ie7-icon:'\e016'}* html .row-actions{visibility:visible}* html div.widget-liquid-left,* html div.widget-liquid-right{display:block;position:relative}* html #editorcontainer{padding:0}* html #poststuff h2{margin-left:0}* html div.widget-liquid-left{width:99%}* html .widgets-sortables{height:50px}* html a#content_resize{right:-2px}* html .widget-title h4{width:205px}* html #removing-widget .in-widget-title{display:none}* html .media-item .pinkynail{height:32px;width:40px}* html .describe .field input.text,* html .describe .field textarea{width:440px}* html .edit-box{display:inline}* html .postbox-container .meta-box-sortables{height:300px}* html #wpbody-content #screen-options-link-wrap{display:inline-block;width:150px;text-align:center}* html #wpbody-content #contextual-help-link-wrap{display:inline-block;width:100px;text-align:center}* html #adminmenu{margin-left:-80px}* html .folded #adminmenu{margin-left:-22px}* html #wpcontent #adminmenu li.menu-top{display:inline;padding:0;margin:0}* html #wpfooter{margin:0}* html #adminmenu div.wp-menu-image{height:29px} \ No newline at end of file diff --git a/backend/wp-admin/css/install-rtl.css b/backend/wp-admin/css/install-rtl.css new file mode 100644 index 0000000..a045ebf --- /dev/null +++ b/backend/wp-admin/css/install-rtl.css @@ -0,0 +1,451 @@ +html { + background: #f1f1f1; + margin: 0 20px; +} + +body { + background: #fff; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + margin: 140px auto 25px; + padding: 20px 20px 10px 20px; + max-width: 700px; + -webkit-font-smoothing: subpixel-antialiased; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +a { + color: #0073aa; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +h1, h2 { + border-bottom: 1px solid #ddd; + clear: both; + color: #666; + font-size: 24px; + padding: 0; + padding-bottom: 7px; + font-weight: 400; +} + +h3 { + font-size: 16px; +} + +p, li, dd, dt { + padding-bottom: 2px; + font-size: 14px; + line-height: 1.5; +} + +code, .code { + font-family: Consolas, Monaco, monospace; +} + +ul, ol, dl { + padding: 5px 22px 5px 5px; +} + +a img { + border:0 +} +abbr { + border: 0; + font-variant: normal; +} + +fieldset { + border: 0; + padding: 0; + margin: 0; +} + +label { + cursor: pointer; +} + +#logo { + margin: 6px 0 14px 0; + padding: 0 0 7px 0; + border-bottom: none; + text-align:center +} +#logo a { + background-image: url(../images/w-logo-blue.png?ver=20131202); + background-image: none, url(../images/wordpress-logo.svg?ver=20131107); + background-size: 84px; + background-position: center top; + background-repeat: no-repeat; + color: #444; /* same as login.css */ + height: 84px; + font-size: 20px; + font-weight: 400; + line-height: 1.3em; + margin: -130px auto 25px; + padding: 0; + text-decoration: none; + width: 84px; + text-indent: -9999px; + outline: none; + overflow: hidden; + display: block; +} + +#logo a:focus { + box-shadow: none; +} + +.step { + margin: 20px 0 15px; +} +.step, th { + text-align: right; + padding: 0; +} +.language-chooser.wp-core-ui .step .button.button-large { + height: 36px; + font-size: 14px; + line-height: 33px; + vertical-align: middle; +} +textarea { + border: 1px solid #ddd; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + width: 100%; + box-sizing: border-box; +} + +.form-table { + border-collapse: collapse; + margin-top: 1em; + width: 100%; +} + +.form-table td { + margin-bottom: 9px; + padding: 10px 0 10px 20px; + font-size: 14px; + vertical-align: top +} + +.form-table th { + font-size: 14px; + text-align: right; + padding: 10px 0 10px 20px; + width: 140px; + vertical-align: top; +} + +.form-table code { + line-height: 18px; + font-size: 14px; +} + +.form-table p { + margin: 4px 0 0 0; + font-size: 11px; +} + +.form-table input { + line-height: 20px; + font-size: 15px; + padding: 3px 5px; + border: 1px solid #ddd; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.07); +} + +input, +submit { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; +} + +.form-table input[type=text], +.form-table input[type=email], +.form-table input[type=url], +.form-table input[type=password] { + width: 206px; +} + +.form-table th p { + font-weight: 400; +} + +.form-table.install-success th, +.form-table.install-success td { + vertical-align: middle; + padding: 16px 0 16px 20px; +} + +.form-table.install-success td p { + margin: 0; + font-size: 14px; +} + +.form-table.install-success td code { + margin: 0; + font-size: 18px; +} + +#error-page { + margin-top: 50px; +} + +#error-page p { + font-size: 14px; + line-height: 18px; + margin: 25px 0 20px; +} + +#error-page code, .code { + font-family: Consolas, Monaco, monospace; +} + +.wp-hide-pw > .dashicons { + line-height: inherit; +} + +#pass-strength-result { + background-color: #eee; + border: 1px solid #ddd; + color: #23282d; + margin: -2px 0px 5px 5px; + padding: 3px 5px; + text-align: center; + width: 218px; + box-sizing: border-box; + opacity: 0; +} + +#pass-strength-result.short { + background-color: #f1adad; + border-color: #e35b5b; + opacity: 1; +} + +#pass-strength-result.bad { + background-color: #fbc5a9; + border-color: #f78b53; + opacity: 1; +} + +#pass-strength-result.good { + background-color: #ffe399; + border-color: #ffc733; + opacity: 1; +} + +#pass-strength-result.strong { + background-color: #c1e1b9; + border-color: #83c373; + opacity: 1; +} + +#pass1.short, #pass1-text.short { + border-color: #e35b5b; +} + +#pass1.bad, #pass1-text.bad { + border-color: #f78b53; +} + +#pass1.good, #pass1-text.good { + border-color: #ffc733; +} + +#pass1.strong, #pass1-text.strong { + border-color: #83c373; +} + +.pw-weak { + display: none; +} + +.message { + border-right: 4px solid #dc3232; + padding: .7em .6em; + background-color: #fbeaea; +} + +/* rtl:ignore */ +#dbname, +#uname, +#pwd, +#dbhost, +#prefix, +#user_login, +#admin_email, +#pass1, +#pass2 { + direction: ltr; +} + +#pass1-text, +.show-password #pass1 { + display: none; +} + +.show-password #pass1-text +{ + display: inline-block; +} + +.form-table span.description.important { + font-size: 12px; +} + + +/* localization */ +body.rtl, +.rtl textarea, +.rtl input, +.rtl submit { + font-family: Tahoma, sans-serif; +} + +:lang(he-il) body.rtl, +:lang(he-il) .rtl textarea, +:lang(he-il) .rtl input, +:lang(he-il) .rtl submit { + font-family: Arial, sans-serif; +} + +@media only screen and (max-width: 799px) { + body { + margin-top: 115px; + } + #logo a { + margin: -125px auto 30px; + } +} + +@media screen and ( max-width: 782px ) { + + .form-table { + margin-top: 0; + } + + .form-table th, + .form-table td { + display: block; + width: auto; + vertical-align: middle; + } + + .form-table th { + padding: 20px 0 0; + } + + .form-table td { + padding: 5px 0; + border: 0; + margin: 0; + } + + textarea, + input { + font-size: 16px; + } + + .form-table td input[type="text"], + .form-table td input[type="email"], + .form-table td input[type="url"], + .form-table td input[type="password"], + .form-table td select, + .form-table td textarea, + .form-table span.description { + width: 100%; + font-size: 16px; + line-height: 1.5; + padding: 7px 10px; + display: block; + max-width: none; + box-sizing: border-box; + } + +} + +body.language-chooser { + max-width: 300px; +} + +.language-chooser select { + padding: 8px; + width: 100%; + display: block; + border: 1px solid #ddd; + background-color: #fff; + color: #32373c; + font-size: 16px; + font-family: Arial, sans-serif; + font-weight: 400; +} + +.language-chooser p { + text-align: left; +} + +.screen-reader-input, +.screen-reader-text { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +.spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + visibility: hidden; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 2px 5px 0; +} + +.step .spinner { + display: inline-block; + vertical-align: middle; + margin-left: 15px; +} + +.button.hide-if-no-js, +.hide-if-no-js { + display: none; +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .spinner { + background-image: url(../images/spinner-2x.gif); + } + +} diff --git a/backend/wp-admin/css/install-rtl.min.css b/backend/wp-admin/css/install-rtl.min.css new file mode 100644 index 0000000..fe0f98a --- /dev/null +++ b/backend/wp-admin/css/install-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +a img,abbr,fieldset{border:0}#logo,h1,h2{padding:0 0 7px}#pass-strength-result,textarea{border:1px solid #ddd;box-sizing:border-box}#logo a,.form-table th p,h1,h2{font-weight:400}html{background:#f1f1f1;margin:0 20px}body{background:#fff;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;margin:140px auto 25px;padding:20px 20px 10px;max-width:700px;-webkit-font-smoothing:subpixel-antialiased;box-shadow:0 1px 3px rgba(0,0,0,.13)}a{color:#0073aa}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}h1,h2{border-bottom:1px solid #ddd;clear:both;color:#666;font-size:24px}h3{font-size:16px}dd,dt,li,p{padding-bottom:2px;font-size:14px;line-height:1.5}.code,code{font-family:Consolas,Monaco,monospace}input,submit,textarea{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}dl,ol,ul{padding:5px 22px 5px 5px}abbr{font-variant:normal}fieldset{padding:0;margin:0}label{cursor:pointer}#logo{margin:6px 0 14px;border-bottom:none;text-align:center}#logo a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;line-height:1.3em;margin:-130px auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#pass1-text,.pw-weak,.show-password #pass1{display:none}#logo a:focus{box-shadow:none}.step{margin:20px 0 15px}.step,th{text-align:right;padding:0}.language-chooser.wp-core-ui .step .button.button-large{height:36px;font-size:14px;line-height:33px;vertical-align:middle}.form-table td,.form-table th{padding:10px 0 10px 20px;vertical-align:top;font-size:14px}textarea{width:100%}.form-table{border-collapse:collapse;margin-top:1em;width:100%}.form-table td{margin-bottom:9px}.form-table th{text-align:right;width:140px}.form-table code{line-height:18px;font-size:14px}.form-table p{margin:4px 0 0;font-size:11px}.form-table input{line-height:20px;font-size:15px;padding:3px 5px;border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07)}.form-table input[type=email],.form-table input[type=password],.form-table input[type=text],.form-table input[type=url]{width:206px}.form-table.install-success td,.form-table.install-success th{vertical-align:middle;padding:16px 0 16px 20px}.form-table.install-success td p{margin:0;font-size:14px}.form-table.install-success td code{margin:0;font-size:18px}#error-page{margin-top:50px}#error-page p{font-size:14px;line-height:18px;margin:25px 0 20px}#error-page code,.code{font-family:Consolas,Monaco,monospace}.wp-hide-pw>.dashicons{line-height:inherit}#pass-strength-result{background-color:#eee;color:#23282d;margin:-2px 0 5px 5px;padding:3px 5px;text-align:center;width:218px;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.message{border-right:4px solid #dc3232;padding:.7em .6em;background-color:#fbeaea}#admin_email,#dbhost,#dbname,#pass1,#pass2,#prefix,#pwd,#uname,#user_login{direction:ltr}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}.rtl input,.rtl submit,.rtl textarea,body.rtl{font-family:Tahoma,sans-serif}.language-chooser select,:lang(he-il) .rtl input,:lang(he-il) .rtl submit,:lang(he-il) .rtl textarea,:lang(he-il) body.rtl{font-family:Arial,sans-serif}@media only screen and (max-width:799px){body{margin-top:115px}#logo a{margin:-125px auto 30px}}@media screen and (max-width:782px){.form-table{margin-top:0}.form-table td,.form-table th{display:block;width:auto;vertical-align:middle}.form-table th{padding:20px 0 0}.form-table td{padding:5px 0;border:0;margin:0}input,textarea{font-size:16px}.form-table span.description,.form-table td input[type=text],.form-table td input[type=email],.form-table td input[type=url],.form-table td input[type=password],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}}body.language-chooser{max-width:300px}.language-chooser select{padding:8px;width:100%;display:block;border:1px solid #ddd;background-color:#fff;color:#32373c;font-size:16px;font-weight:400}.language-chooser p{text-align:left}.screen-reader-input,.screen-reader-text{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}.spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;visibility:hidden;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:2px 5px 0}.step .spinner{display:inline-block;vertical-align:middle;margin-left:15px}.button.hide-if-no-js,.hide-if-no-js{display:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.spinner{background-image:url(../images/spinner-2x.gif)}} \ No newline at end of file diff --git a/backend/wp-admin/css/install.css b/backend/wp-admin/css/install.css new file mode 100644 index 0000000..84c2f5e --- /dev/null +++ b/backend/wp-admin/css/install.css @@ -0,0 +1,451 @@ +html { + background: #f1f1f1; + margin: 0 20px; +} + +body { + background: #fff; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + margin: 140px auto 25px; + padding: 20px 20px 10px 20px; + max-width: 700px; + -webkit-font-smoothing: subpixel-antialiased; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +a { + color: #0073aa; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +h1, h2 { + border-bottom: 1px solid #ddd; + clear: both; + color: #666; + font-size: 24px; + padding: 0; + padding-bottom: 7px; + font-weight: 400; +} + +h3 { + font-size: 16px; +} + +p, li, dd, dt { + padding-bottom: 2px; + font-size: 14px; + line-height: 1.5; +} + +code, .code { + font-family: Consolas, Monaco, monospace; +} + +ul, ol, dl { + padding: 5px 5px 5px 22px; +} + +a img { + border:0 +} +abbr { + border: 0; + font-variant: normal; +} + +fieldset { + border: 0; + padding: 0; + margin: 0; +} + +label { + cursor: pointer; +} + +#logo { + margin: 6px 0 14px 0; + padding: 0 0 7px 0; + border-bottom: none; + text-align:center +} +#logo a { + background-image: url(../images/w-logo-blue.png?ver=20131202); + background-image: none, url(../images/wordpress-logo.svg?ver=20131107); + background-size: 84px; + background-position: center top; + background-repeat: no-repeat; + color: #444; /* same as login.css */ + height: 84px; + font-size: 20px; + font-weight: 400; + line-height: 1.3em; + margin: -130px auto 25px; + padding: 0; + text-decoration: none; + width: 84px; + text-indent: -9999px; + outline: none; + overflow: hidden; + display: block; +} + +#logo a:focus { + box-shadow: none; +} + +.step { + margin: 20px 0 15px; +} +.step, th { + text-align: left; + padding: 0; +} +.language-chooser.wp-core-ui .step .button.button-large { + height: 36px; + font-size: 14px; + line-height: 33px; + vertical-align: middle; +} +textarea { + border: 1px solid #ddd; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + width: 100%; + box-sizing: border-box; +} + +.form-table { + border-collapse: collapse; + margin-top: 1em; + width: 100%; +} + +.form-table td { + margin-bottom: 9px; + padding: 10px 20px 10px 0; + font-size: 14px; + vertical-align: top +} + +.form-table th { + font-size: 14px; + text-align: left; + padding: 10px 20px 10px 0; + width: 140px; + vertical-align: top; +} + +.form-table code { + line-height: 18px; + font-size: 14px; +} + +.form-table p { + margin: 4px 0 0 0; + font-size: 11px; +} + +.form-table input { + line-height: 20px; + font-size: 15px; + padding: 3px 5px; + border: 1px solid #ddd; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.07); +} + +input, +submit { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; +} + +.form-table input[type=text], +.form-table input[type=email], +.form-table input[type=url], +.form-table input[type=password] { + width: 206px; +} + +.form-table th p { + font-weight: 400; +} + +.form-table.install-success th, +.form-table.install-success td { + vertical-align: middle; + padding: 16px 20px 16px 0; +} + +.form-table.install-success td p { + margin: 0; + font-size: 14px; +} + +.form-table.install-success td code { + margin: 0; + font-size: 18px; +} + +#error-page { + margin-top: 50px; +} + +#error-page p { + font-size: 14px; + line-height: 18px; + margin: 25px 0 20px; +} + +#error-page code, .code { + font-family: Consolas, Monaco, monospace; +} + +.wp-hide-pw > .dashicons { + line-height: inherit; +} + +#pass-strength-result { + background-color: #eee; + border: 1px solid #ddd; + color: #23282d; + margin: -2px 5px 5px 0px; + padding: 3px 5px; + text-align: center; + width: 218px; + box-sizing: border-box; + opacity: 0; +} + +#pass-strength-result.short { + background-color: #f1adad; + border-color: #e35b5b; + opacity: 1; +} + +#pass-strength-result.bad { + background-color: #fbc5a9; + border-color: #f78b53; + opacity: 1; +} + +#pass-strength-result.good { + background-color: #ffe399; + border-color: #ffc733; + opacity: 1; +} + +#pass-strength-result.strong { + background-color: #c1e1b9; + border-color: #83c373; + opacity: 1; +} + +#pass1.short, #pass1-text.short { + border-color: #e35b5b; +} + +#pass1.bad, #pass1-text.bad { + border-color: #f78b53; +} + +#pass1.good, #pass1-text.good { + border-color: #ffc733; +} + +#pass1.strong, #pass1-text.strong { + border-color: #83c373; +} + +.pw-weak { + display: none; +} + +.message { + border-left: 4px solid #dc3232; + padding: .7em .6em; + background-color: #fbeaea; +} + +/* rtl:ignore */ +#dbname, +#uname, +#pwd, +#dbhost, +#prefix, +#user_login, +#admin_email, +#pass1, +#pass2 { + direction: ltr; +} + +#pass1-text, +.show-password #pass1 { + display: none; +} + +.show-password #pass1-text +{ + display: inline-block; +} + +.form-table span.description.important { + font-size: 12px; +} + + +/* localization */ +body.rtl, +.rtl textarea, +.rtl input, +.rtl submit { + font-family: Tahoma, sans-serif; +} + +:lang(he-il) body.rtl, +:lang(he-il) .rtl textarea, +:lang(he-il) .rtl input, +:lang(he-il) .rtl submit { + font-family: Arial, sans-serif; +} + +@media only screen and (max-width: 799px) { + body { + margin-top: 115px; + } + #logo a { + margin: -125px auto 30px; + } +} + +@media screen and ( max-width: 782px ) { + + .form-table { + margin-top: 0; + } + + .form-table th, + .form-table td { + display: block; + width: auto; + vertical-align: middle; + } + + .form-table th { + padding: 20px 0 0; + } + + .form-table td { + padding: 5px 0; + border: 0; + margin: 0; + } + + textarea, + input { + font-size: 16px; + } + + .form-table td input[type="text"], + .form-table td input[type="email"], + .form-table td input[type="url"], + .form-table td input[type="password"], + .form-table td select, + .form-table td textarea, + .form-table span.description { + width: 100%; + font-size: 16px; + line-height: 1.5; + padding: 7px 10px; + display: block; + max-width: none; + box-sizing: border-box; + } + +} + +body.language-chooser { + max-width: 300px; +} + +.language-chooser select { + padding: 8px; + width: 100%; + display: block; + border: 1px solid #ddd; + background-color: #fff; + color: #32373c; + font-size: 16px; + font-family: Arial, sans-serif; + font-weight: 400; +} + +.language-chooser p { + text-align: right; +} + +.screen-reader-input, +.screen-reader-text { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +.spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + visibility: hidden; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 2px 5px 0; +} + +.step .spinner { + display: inline-block; + vertical-align: middle; + margin-right: 15px; +} + +.button.hide-if-no-js, +.hide-if-no-js { + display: none; +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .spinner { + background-image: url(../images/spinner-2x.gif); + } + +} diff --git a/backend/wp-admin/css/install.min.css b/backend/wp-admin/css/install.min.css new file mode 100644 index 0000000..e9dfb67 --- /dev/null +++ b/backend/wp-admin/css/install.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +a img,abbr,fieldset{border:0}#logo,h1,h2{padding:0 0 7px}#pass-strength-result,textarea{border:1px solid #ddd;box-sizing:border-box}#logo a,.form-table th p,h1,h2{font-weight:400}html{background:#f1f1f1;margin:0 20px}body{background:#fff;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;margin:140px auto 25px;padding:20px 20px 10px;max-width:700px;-webkit-font-smoothing:subpixel-antialiased;box-shadow:0 1px 3px rgba(0,0,0,.13)}a{color:#0073aa}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}h1,h2{border-bottom:1px solid #ddd;clear:both;color:#666;font-size:24px}h3{font-size:16px}dd,dt,li,p{padding-bottom:2px;font-size:14px;line-height:1.5}.code,code{font-family:Consolas,Monaco,monospace}input,submit,textarea{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}dl,ol,ul{padding:5px 5px 5px 22px}abbr{font-variant:normal}fieldset{padding:0;margin:0}label{cursor:pointer}#logo{margin:6px 0 14px;border-bottom:none;text-align:center}#logo a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;line-height:1.3em;margin:-130px auto 25px;padding:0;text-decoration:none;width:84px;text-indent:-9999px;outline:0;overflow:hidden;display:block}#pass1-text,.pw-weak,.show-password #pass1{display:none}#logo a:focus{box-shadow:none}.step{margin:20px 0 15px}.step,th{text-align:left;padding:0}.language-chooser.wp-core-ui .step .button.button-large{height:36px;font-size:14px;line-height:33px;vertical-align:middle}.form-table td,.form-table th{padding:10px 20px 10px 0;vertical-align:top;font-size:14px}textarea{width:100%}.form-table{border-collapse:collapse;margin-top:1em;width:100%}.form-table td{margin-bottom:9px}.form-table th{text-align:left;width:140px}.form-table code{line-height:18px;font-size:14px}.form-table p{margin:4px 0 0;font-size:11px}.form-table input{line-height:20px;font-size:15px;padding:3px 5px;border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07)}.form-table input[type=email],.form-table input[type=password],.form-table input[type=text],.form-table input[type=url]{width:206px}.form-table.install-success td,.form-table.install-success th{vertical-align:middle;padding:16px 20px 16px 0}.form-table.install-success td p{margin:0;font-size:14px}.form-table.install-success td code{margin:0;font-size:18px}#error-page{margin-top:50px}#error-page p{font-size:14px;line-height:18px;margin:25px 0 20px}#error-page code,.code{font-family:Consolas,Monaco,monospace}.wp-hide-pw>.dashicons{line-height:inherit}#pass-strength-result{background-color:#eee;color:#23282d;margin:-2px 5px 5px 0;padding:3px 5px;text-align:center;width:218px;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.message{border-left:4px solid #dc3232;padding:.7em .6em;background-color:#fbeaea}#admin_email,#dbhost,#dbname,#pass1,#pass2,#prefix,#pwd,#uname,#user_login{direction:ltr}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}.rtl input,.rtl submit,.rtl textarea,body.rtl{font-family:Tahoma,sans-serif}.language-chooser select,:lang(he-il) .rtl input,:lang(he-il) .rtl submit,:lang(he-il) .rtl textarea,:lang(he-il) body.rtl{font-family:Arial,sans-serif}@media only screen and (max-width:799px){body{margin-top:115px}#logo a{margin:-125px auto 30px}}@media screen and (max-width:782px){.form-table{margin-top:0}.form-table td,.form-table th{display:block;width:auto;vertical-align:middle}.form-table th{padding:20px 0 0}.form-table td{padding:5px 0;border:0;margin:0}input,textarea{font-size:16px}.form-table span.description,.form-table td input[type=text],.form-table td input[type=email],.form-table td input[type=url],.form-table td input[type=password],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}}body.language-chooser{max-width:300px}.language-chooser select{padding:8px;width:100%;display:block;border:1px solid #ddd;background-color:#fff;color:#32373c;font-size:16px;font-weight:400}.language-chooser p{text-align:right}.screen-reader-input,.screen-reader-text{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}.spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;visibility:hidden;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:2px 5px 0}.step .spinner{display:inline-block;vertical-align:middle;margin-right:15px}.button.hide-if-no-js,.hide-if-no-js{display:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.spinner{background-image:url(../images/spinner-2x.gif)}} \ No newline at end of file diff --git a/backend/wp-admin/css/l10n-rtl.css b/backend/wp-admin/css/l10n-rtl.css new file mode 100644 index 0000000..82ea545 --- /dev/null +++ b/backend/wp-admin/css/l10n-rtl.css @@ -0,0 +1,120 @@ +/*------------------------------------------------------------------------------ + 27.0 - Localization +------------------------------------------------------------------------------*/ + +/* RTL except Hebrew (see below): Tahoma as the first font; */ +body.rtl, +body.rtl .press-this a.wp-switch-editor { + font-family: Tahoma, Arial, sans-serif; +} + +/* Arial is best for RTL headings. */ +.rtl h1, +.rtl h2, +.rtl h3, +.rtl h4, +.rtl h5, +.rtl h6 { + font-family: Arial, sans-serif; + font-weight: 600; +} + +/* he_IL: Remove Tahoma from the font stack. Arial is best for Hebrew. */ +body.locale-he-il, +body.locale-he-il .press-this a.wp-switch-editor { + font-family: Arial, sans-serif; +} + +/* he_IL: Have be bold rather than italic. */ +.locale-he-il em { + font-style: normal; + font-weight: 600; +} + +/* zh_CN: Remove italic properties. */ +.locale-zh-cn .howto, +.locale-zh-cn .tablenav .displaying-num, +.locale-zh-cn .js .input-with-default-title, +.locale-zh-cn .link-to-original, +.locale-zh-cn .inline-edit-row fieldset span.title, +.locale-zh-cn .inline-edit-row fieldset span.checkbox-title, +.locale-zh-cn #utc-time, +.locale-zh-cn #local-time, +.locale-zh-cn p.install-help, +.locale-zh-cn p.help, +.locale-zh-cn p.description, +.locale-zh-cn span.description, +.locale-zh-cn .form-wrap p { + font-style: normal; +} + +/* zh_CN: Enlarge dashboard widget 'Configure' link */ +.locale-zh-cn .hdnle a { font-size: 12px; } + +/* zn_CH: Enlarge font size, set font-size: normal */ +.locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; } + +/* zh_CN: Enlarge font-size. */ +.locale-zh-cn #sort-buttons { font-size: 1em !important; } + +/* de_DE: Text needs more space for translation */ +.locale-de-de #customize-header-actions .button, +.locale-de-de-formal #customize-header-actions .button { + padding: 0 5px 1px; /* default 0 10px 1px */ +} +.locale-de-de #customize-header-actions .spinner, +.locale-de-de-formal #customize-header-actions .spinner { + margin: 16px 3px 0; /* default 16px 4px 0 5px */ +} + +/* ru_RU: Text needs more room to breathe. */ +.locale-ru-ru #adminmenu { + width: inherit; /* back-compat for pre-3.2 */ +} +.locale-ru-ru #adminmenu, +.locale-ru-ru #wpbody { + margin-right: 0; /* back-compat for pre-3.2 */ +} +.locale-ru-ru .inline-edit-row fieldset label span.title, +.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend { + width: 8em; /* default 6em */ +} +.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap, +.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap { + margin-right: 8em; /* default 6em */ +} +.locale-ru-ru.post-php .tagsdiv .newtag, +.locale-ru-ru.post-new-php .tagsdiv .newtag { + width: 165px; /* default 180px - 15px */ +} +.locale-ru-ru.press-this .posting { + margin-left: 277px; /* default 252px + 25px */ +} +.locale-ru-ru .press-this-sidebar { + width: 265px; /* default 240px + 25px */ +} +.locale-ru-ru #customize-header-actions .button { + padding: 0 5px 1px; /* default 0 10px 1px */ +} +.locale-ru-ru #customize-header-actions .spinner { + margin: 16px 3px 0; /* default 16px 4px 0 5px */ +} + +/* lt_LT: QuickEdit */ +.locale-lt-lt .inline-edit-row fieldset label span.title, +.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend { + width: 8em; /* default 6em */ +} +.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap, +.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap { + margin-right: 8em; /* default 6em */ +} + +@media screen and (max-width: 782px) { + .locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap, + .locale-ru-ru .inline-edit-row fieldset .timestamp-wrap, + .locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap, + .locale-lt-lt .inline-edit-row fieldset .timestamp-wrap { + margin-right: 0; + } +} diff --git a/backend/wp-admin/css/l10n-rtl.min.css b/backend/wp-admin/css/l10n-rtl.min.css new file mode 100644 index 0000000..c22eeb3 --- /dev/null +++ b/backend/wp-admin/css/l10n-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.locale-he-il em,.locale-zh-cn #local-time,.locale-zh-cn #utc-time,.locale-zh-cn .form-wrap p,.locale-zh-cn .howto,.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,.locale-zh-cn .inline-edit-row fieldset span.title,.locale-zh-cn .js .input-with-default-title,.locale-zh-cn .link-to-original,.locale-zh-cn .tablenav .displaying-num,.locale-zh-cn p.description,.locale-zh-cn p.help,.locale-zh-cn p.install-help,.locale-zh-cn span.description{font-style:normal}.locale-de-de #customize-header-actions .button,.locale-de-de-formal #customize-header-actions .button,.locale-ru-ru #customize-header-actions .button{padding:0 5px 1px}body.rtl,body.rtl .press-this a.wp-switch-editor{font-family:Tahoma,Arial,sans-serif}.rtl h1,.rtl h2,.rtl h3,.rtl h4,.rtl h5,.rtl h6{font-family:Arial,sans-serif;font-weight:600}body.locale-he-il,body.locale-he-il .press-this a.wp-switch-editor{font-family:Arial,sans-serif}.locale-he-il em{font-weight:600}.locale-zh-cn .hdnle a{font-size:12px}.locale-zh-cn form.upgrade .hint{font-style:normal;font-size:100%}.locale-zh-cn #sort-buttons{font-size:1em!important}.locale-de-de #customize-header-actions .spinner,.locale-de-de-formal #customize-header-actions .spinner{margin:16px 3px 0}.locale-ru-ru #adminmenu{width:inherit}.locale-ru-ru #adminmenu,.locale-ru-ru #wpbody{margin-right:0}.locale-ru-ru .inline-edit-row fieldset label span.title,.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-right:8em}.locale-ru-ru.post-new-php .tagsdiv .newtag,.locale-ru-ru.post-php .tagsdiv .newtag{width:165px}.locale-ru-ru.press-this .posting{margin-left:277px}.locale-ru-ru .press-this-sidebar{width:265px}.locale-ru-ru #customize-header-actions .spinner{margin:16px 3px 0}.locale-lt-lt .inline-edit-row fieldset label span.title,.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap{margin-right:8em}@media screen and (max-width:782px){.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap,.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-right:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/l10n.css b/backend/wp-admin/css/l10n.css new file mode 100644 index 0000000..967fb4c --- /dev/null +++ b/backend/wp-admin/css/l10n.css @@ -0,0 +1,120 @@ +/*------------------------------------------------------------------------------ + 27.0 - Localization +------------------------------------------------------------------------------*/ + +/* RTL except Hebrew (see below): Tahoma as the first font; */ +body.rtl, +body.rtl .press-this a.wp-switch-editor { + font-family: Tahoma, Arial, sans-serif; +} + +/* Arial is best for RTL headings. */ +.rtl h1, +.rtl h2, +.rtl h3, +.rtl h4, +.rtl h5, +.rtl h6 { + font-family: Arial, sans-serif; + font-weight: 600; +} + +/* he_IL: Remove Tahoma from the font stack. Arial is best for Hebrew. */ +body.locale-he-il, +body.locale-he-il .press-this a.wp-switch-editor { + font-family: Arial, sans-serif; +} + +/* he_IL: Have be bold rather than italic. */ +.locale-he-il em { + font-style: normal; + font-weight: 600; +} + +/* zh_CN: Remove italic properties. */ +.locale-zh-cn .howto, +.locale-zh-cn .tablenav .displaying-num, +.locale-zh-cn .js .input-with-default-title, +.locale-zh-cn .link-to-original, +.locale-zh-cn .inline-edit-row fieldset span.title, +.locale-zh-cn .inline-edit-row fieldset span.checkbox-title, +.locale-zh-cn #utc-time, +.locale-zh-cn #local-time, +.locale-zh-cn p.install-help, +.locale-zh-cn p.help, +.locale-zh-cn p.description, +.locale-zh-cn span.description, +.locale-zh-cn .form-wrap p { + font-style: normal; +} + +/* zh_CN: Enlarge dashboard widget 'Configure' link */ +.locale-zh-cn .hdnle a { font-size: 12px; } + +/* zn_CH: Enlarge font size, set font-size: normal */ +.locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; } + +/* zh_CN: Enlarge font-size. */ +.locale-zh-cn #sort-buttons { font-size: 1em !important; } + +/* de_DE: Text needs more space for translation */ +.locale-de-de #customize-header-actions .button, +.locale-de-de-formal #customize-header-actions .button { + padding: 0 5px 1px; /* default 0 10px 1px */ +} +.locale-de-de #customize-header-actions .spinner, +.locale-de-de-formal #customize-header-actions .spinner { + margin: 16px 3px 0; /* default 16px 4px 0 5px */ +} + +/* ru_RU: Text needs more room to breathe. */ +.locale-ru-ru #adminmenu { + width: inherit; /* back-compat for pre-3.2 */ +} +.locale-ru-ru #adminmenu, +.locale-ru-ru #wpbody { + margin-left: 0; /* back-compat for pre-3.2 */ +} +.locale-ru-ru .inline-edit-row fieldset label span.title, +.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend { + width: 8em; /* default 6em */ +} +.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap, +.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap { + margin-left: 8em; /* default 6em */ +} +.locale-ru-ru.post-php .tagsdiv .newtag, +.locale-ru-ru.post-new-php .tagsdiv .newtag { + width: 165px; /* default 180px - 15px */ +} +.locale-ru-ru.press-this .posting { + margin-right: 277px; /* default 252px + 25px */ +} +.locale-ru-ru .press-this-sidebar { + width: 265px; /* default 240px + 25px */ +} +.locale-ru-ru #customize-header-actions .button { + padding: 0 5px 1px; /* default 0 10px 1px */ +} +.locale-ru-ru #customize-header-actions .spinner { + margin: 16px 3px 0; /* default 16px 4px 0 5px */ +} + +/* lt_LT: QuickEdit */ +.locale-lt-lt .inline-edit-row fieldset label span.title, +.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend { + width: 8em; /* default 6em */ +} +.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap, +.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap { + margin-left: 8em; /* default 6em */ +} + +@media screen and (max-width: 782px) { + .locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap, + .locale-ru-ru .inline-edit-row fieldset .timestamp-wrap, + .locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap, + .locale-lt-lt .inline-edit-row fieldset .timestamp-wrap { + margin-left: 0; + } +} diff --git a/backend/wp-admin/css/l10n.min.css b/backend/wp-admin/css/l10n.min.css new file mode 100644 index 0000000..76dc704 --- /dev/null +++ b/backend/wp-admin/css/l10n.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.locale-he-il em,.locale-zh-cn #local-time,.locale-zh-cn #utc-time,.locale-zh-cn .form-wrap p,.locale-zh-cn .howto,.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,.locale-zh-cn .inline-edit-row fieldset span.title,.locale-zh-cn .js .input-with-default-title,.locale-zh-cn .link-to-original,.locale-zh-cn .tablenav .displaying-num,.locale-zh-cn p.description,.locale-zh-cn p.help,.locale-zh-cn p.install-help,.locale-zh-cn span.description{font-style:normal}.locale-de-de #customize-header-actions .button,.locale-de-de-formal #customize-header-actions .button,.locale-ru-ru #customize-header-actions .button{padding:0 5px 1px}body.rtl,body.rtl .press-this a.wp-switch-editor{font-family:Tahoma,Arial,sans-serif}.rtl h1,.rtl h2,.rtl h3,.rtl h4,.rtl h5,.rtl h6{font-family:Arial,sans-serif;font-weight:600}body.locale-he-il,body.locale-he-il .press-this a.wp-switch-editor{font-family:Arial,sans-serif}.locale-he-il em{font-weight:600}.locale-zh-cn .hdnle a{font-size:12px}.locale-zh-cn form.upgrade .hint{font-style:normal;font-size:100%}.locale-zh-cn #sort-buttons{font-size:1em!important}.locale-de-de #customize-header-actions .spinner,.locale-de-de-formal #customize-header-actions .spinner{margin:16px 3px 0}.locale-ru-ru #adminmenu{width:inherit}.locale-ru-ru #adminmenu,.locale-ru-ru #wpbody{margin-left:0}.locale-ru-ru .inline-edit-row fieldset label span.title,.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-left:8em}.locale-ru-ru.post-new-php .tagsdiv .newtag,.locale-ru-ru.post-php .tagsdiv .newtag{width:165px}.locale-ru-ru.press-this .posting{margin-right:277px}.locale-ru-ru .press-this-sidebar{width:265px}.locale-ru-ru #customize-header-actions .spinner{margin:16px 3px 0}.locale-lt-lt .inline-edit-row fieldset label span.title,.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap{margin-left:8em}@media screen and (max-width:782px){.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap,.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-left:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/list-tables-rtl.css b/backend/wp-admin/css/list-tables-rtl.css new file mode 100644 index 0000000..fa32892 --- /dev/null +++ b/backend/wp-admin/css/list-tables-rtl.css @@ -0,0 +1,2145 @@ +.response-links { + display: block; + margin-bottom: 1em; +} + +.response-links a { + display: block; +} + +.response-links a.comments-edit-item-link { + font-weight: 600; +} + +.response-links a.comments-view-item-link { + font-size: 12px; +} + +.post-com-count-wrapper strong { + font-weight: 400; +} + +.comments-view-item-link { + display: inline-block; + clear: both; +} + +.column-response .post-com-count-wrapper, +.column-comments .post-com-count-wrapper { + white-space: nowrap; + word-wrap: normal; +} + +/* comments bubble common */ +.column-response .post-com-count, +.column-comments .post-com-count { + display: inline-block; + vertical-align: top; +} + +/* comments bubble approved */ +.column-response .post-com-count-no-comments, +.column-response .post-com-count-approved, +.column-comments .post-com-count-no-comments, +.column-comments .post-com-count-approved { + margin-top: 5px; +} + +.column-response .comment-count-no-comments, +.column-response .comment-count-approved, +.column-comments .comment-count-no-comments, +.column-comments .comment-count-approved { + box-sizing: border-box; + display: block; + padding: 0 8px; + min-width: 24px; + height: 2em; + border-radius: 5px; + background-color: #72777c; + color: #fff; + font-size: 11px; + line-height: 21px; + text-align: center; +} + +.ie8 .column-response .comment-count-no-comments, +.ie8 .column-response .comment-count-approved, +.ie8 .column-comments .comment-count-no-comments, +.ie8 .column-comments .comment-count-approved { + min-width: 0; +} + +.column-response .post-com-count-no-comments:after, +.column-response .post-com-count-approved:after, +.column-comments .post-com-count-no-comments:after, +.column-comments .post-com-count-approved:after { + content: ""; + display: block; + margin-right: 8px; + width: 0; + height: 0; + border-top: 5px solid #72777c; + border-left: 5px solid transparent; +} + +.column-response .post-com-count-approved:hover .comment-count-approved, +.column-response .post-com-count-approved:focus .comment-count-approved, +.column-comments .post-com-count-approved:hover .comment-count-approved, +.column-comments .post-com-count-approved:focus .comment-count-approved { + background: #0073aa; +} + +.column-response .post-com-count-approved:hover:after, +.column-response .post-com-count-approved:focus:after, +.column-comments .post-com-count-approved:hover:after, +.column-comments .post-com-count-approved:focus:after { + border-top-color: #0073aa; +} + +/* @todo: consider to use a single rule for these counters and the admin menu counters. */ +.column-response .post-com-count-pending, +.column-comments .post-com-count-pending { + position: relative; + right: -3px; + padding: 0 5px; + min-width: 7px; + height: 17px; + border: 2px solid #fff; + border-radius: 11px; + background: #ca4a1f; + color: #fff; + font-size: 9px; + line-height: 17px; + text-align: center; +} + +.column-response .post-com-count-no-pending, +.column-comments .post-com-count-no-pending { + display: none; +} + +/* comments */ + +.commentlist li { + padding: 1em 1em .2em; + margin: 0; + border-bottom: 1px solid #ccc; +} + +.commentlist li li { + border-bottom: 0; + padding: 0; +} + +.commentlist p { + padding: 0; + margin: 0 0 .8em; +} + +#submitted-on, +.submitted-on { + color: #555d66; +} + +/* reply to comments */ +#replyrow td { + padding: 2px; +} + +#replysubmit { + margin: 0; + padding: 5px 7px 10px; + overflow: hidden; +} + +#replysubmit .button { + margin-left: 5px; +} + +#replyrow.inline-edit-row fieldset.comment-reply { + font-size: inherit; + line-height: inherit; +} + +#replyrow legend { + margin: 0; + padding: .2em 5px 0; + font-size: 13px; + line-height: 1.4; + font-weight: 600; +} + +#replyrow.inline-edit-row label { + display: inline; + vertical-align: baseline; + line-height: inherit; +} + +#edithead .inside, +#commentsdiv #edithead .inside { + float: right; + padding: 3px 5px 2px 0; + margin: 0; + text-align: center; +} + +#edithead .inside input { + width: 180px; +} + +#edithead label { + padding: 2px 0; +} + +#replycontainer { + padding: 5px; +} + +#replycontent { + height: 120px; + box-shadow: none; +} + +#replyerror { + border-color: #ddd; + background-color: #f9f9f9; +} + +/* @todo: is this used? */ +.commentlist .avatar { + vertical-align: text-top; +} + +#the-comment-list tr.undo, +#the-comment-list div.undo { + background-color: #f5f5f5; +} + +#the-comment-list .unapproved th, +#the-comment-list .unapproved td { + background-color: #fef7f1; +} + +#the-comment-list .unapproved th.check-column { + border-right: 4px solid #d54e21; +} + +#the-comment-list .unapproved th.check-column input { + margin-right: 4px; +} + +#the-comment-list .approve a { + color: #006505; +} + +#the-comment-list .unapprove a { + color: #d98500; +} + +#the-comment-list th, +#the-comment-list td { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); +} + +#the-comment-list tr:last-child th, +#the-comment-list tr:last-child td { + box-shadow: none; +} + +#the-comment-list tr.unapproved + tr.approved th, +#the-comment-list tr.unapproved + tr.approved td { + border-top: 1px solid rgba(0, 0, 0, 0.03); +} + +/* table vim shortcuts */ +.vim-current, +.vim-current th, +.vim-current td { + background-color: #e4f2fd !important; +} + +th .comment-grey-bubble { + height: 16px; + width: 16px; +} + +th .comment-grey-bubble:before { + content: "\f101"; + font: normal 20px/.5 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: 4px; + right: -4px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +/*------------------------------------------------------------------------------ + 10.0 - List Posts (/Pages/etc) +------------------------------------------------------------------------------*/ + +table.fixed { + table-layout: fixed; +} + +.fixed .column-rating, +.fixed .column-visible { + width: 8%; +} + +.fixed .column-posts, +.fixed .column-date, +.fixed .column-parent, +.fixed .column-links, +.fixed .column-author, +.fixed .column-format { + width: 10%; +} + +.fixed .column-posts { + width: 74px; +} + +.fixed .column-comment .comment-author { + display: none; +} + +.fixed .column-response, +.fixed .column-categories, +.fixed .column-tags, +.fixed .column-rel, +.fixed .column-role { + width: 15%; +} + +.fixed .column-slug { + width: 25%; +} + +.fixed .column-locations { + width: 35%; +} + +.fixed .column-comments { + width: 5.5em; + padding: 8px 0; + text-align: right; +} + +.fixed .column-comments .vers { + padding-right: 3px; +} + +td.column-title strong, +td.plugin-title strong { + display: block; + margin-bottom: .2em; + font-size: 14px; +} + +td.column-title p, +td.plugin-title p { + margin: 6px 0; +} + +/* Media file column */ +table.media .column-title .media-icon { + float: right; + min-height: 60px; + margin: 0 0 0 9px; +} + +table.media .column-title .media-icon img { + max-width: 60px; + height: auto; + vertical-align: top; /* Remove descender white-space. */ +} + +table.media .column-title .has-media-icon ~ .row-actions { + margin-right: 70px; /* 60px image + margin */ +} + +table.media .column-title .filename { + margin-bottom: 0.2em; +} + +/* @todo: pick a consistent list table selector */ +.wp-list-table a { + transition: none; +} + +#the-list tr:last-child td, +#the-list tr:last-child th { + border-bottom: none !important; + box-shadow: none; +} + +#comments-form .fixed .column-author { + width: 20%; +} + +#comments-form .fixed .column-date { + width: 14%; +} + +#commentsdiv.postbox .inside { + margin: 0; + padding: 0; +} + +#commentsdiv .inside .row-actions { + line-height:18px; +} + +#commentsdiv .inside .column-author { + width: 25%; +} + +#commentsdiv .column-comment p { + margin: 0.6em 0; + padding: 0; +} + +#commentsdiv #replyrow td { + padding: 0; +} + +#commentsdiv p { + padding: 8px 10px; + margin: 0; +} + +#commentsdiv .comments-box { + border: 0 none; +} + +#commentsdiv .comments-box thead th, +#commentsdiv .comments-box thead td { + background: transparent; + padding: 0 7px 4px; + font-style: italic; +} + +#commentsdiv .comments-box tr:last-child td { + border-bottom: 0 none; +} + +#commentsdiv #edithead .inside input { + width: 160px; +} + +.sorting-indicator { + display: block; + visibility: hidden; + width: 10px; + height: 4px; + margin-top: 8px; + margin-right: 7px; +} + +.sorting-indicator:before { + content: "\f142"; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: -4px; + right: -8px; + color: #444; + line-height: 10px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +.column-comments .sorting-indicator:before { + top: 0; + right: -10px; +} + +th.sorted.asc .sorting-indicator:before, +th.desc:hover span.sorting-indicator:before, +th.desc a:focus span.sorting-indicator:before { + content: "\f142"; +} + +th.sorted.desc .sorting-indicator:before, +th.asc:hover span.sorting-indicator:before, +th.asc a:focus span.sorting-indicator:before { + content: "\f140"; +} + +.wp-list-table .toggle-row { + position: absolute; + left: 8px; + top: 10px; + display: none; + padding: 0; + width: 40px; + height: 40px; + border: none; + outline: none; + background: transparent; +} + +.wp-list-table .toggle-row:hover { + cursor: pointer; +} + +.wp-list-table .toggle-row:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 .wp-list-table .toggle-row:focus:before { + outline: #5b9dd9 solid 1px; +} + +.wp-list-table .toggle-row:active { + box-shadow: none; +} + +.wp-list-table .toggle-row:before { + position: absolute; + top: -5px; + right: 10px; + border-radius: 50%; + display: block; + padding: 1px 0 1px 2px; + color: #444; /* same as table headers sort arrows */ + content: "\f140"; + font: normal 20px/1 dashicons; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + speak: none; +} + +.wp-list-table .is-expanded .toggle-row:before { + content: "\f142"; +} + +tr.wp-locked .locked-indicator { + margin-right: 6px; + height: 20px; + width: 16px; +} + +tr.wp-locked .locked-indicator-icon:before { + color: #82878c; + content: "\f160"; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +tr.wp-locked .check-column label, +tr.wp-locked .check-column input[type="checkbox"], +tr.wp-locked .row-actions .inline, +tr.wp-locked .row-actions .trash { + display: none; +} + +tr .locked-info { + height: 0; + opacity: 0; +} + +tr.wp-locked .locked-info { + margin-top: 4px; + height: auto; + opacity: 1; +} + +.locked-text { + vertical-align: top; +} + +tr.locked-info, tr.wp-locked .locked-info { + transition: height 1s, opacity 0.5s; +} + +.fixed .column-comments .sorting-indicator { + margin-top: 3px; +} + +#menu-locations-wrap .widefat { + width: 60%; +} + +.widefat th.sortable, +.widefat th.sorted { + padding: 0; +} + +th.sortable a, +th.sorted a { + display: block; + overflow: hidden; + padding: 8px; +} + +.fixed .column-comments.sortable a, +.fixed .column-comments.sorted a { + padding: 8px 0; +} + +th.sortable a span, +th.sorted a span { + float: right; + cursor: pointer; +} + +th.sorted .sorting-indicator, +th.desc:hover span.sorting-indicator, +th.desc a:focus span.sorting-indicator, +th.asc:hover span.sorting-indicator, +th.asc a:focus span.sorting-indicator { + visibility: visible; +} + +/* Bulk Actions */ +.tablenav-pages a, +.tablenav-pages-navspan { + font-weight: 600; + padding: 0 2px; +} + +.tablenav-pages .current-page { + margin: 0 0 0 2px; + padding-bottom: 5px; + font-size: 13px; + text-align: center; +} + +.tablenav .total-pages { + margin-left: 2px; +} + +.tablenav #table-paging { + margin-right: 2px; +} + +.tablenav a.button, +.tablenav a.button-secondary { + display: block; + margin: 3px 0 0 8px; +} + +.tablenav { + clear: both; + height: 30px; + margin: 6px 0 4px; + vertical-align: middle; +} + +.tablenav.themes { + max-width: 98%; +} + +.tablenav .tablenav-pages { + float: left; + height: 28px; + margin-top: 3px; + cursor: default; + color: #555; +} + +.tablenav .no-pages, +.tablenav .one-page .pagination-links { + display: none; +} + +.tablenav .tablenav-pages a, +.tablenav-pages span.current { + text-decoration: none; + padding: 3px 6px; +} + +.tablenav .tablenav-pages a, +.tablenav-pages-navspan { + display: inline-block; + min-width: 17px; + border: 1px solid #ccc; /* same color as buttons border */ + padding: 3px 5px 7px; + background: #e5e5e5; + font-size: 16px; + line-height: 1; + font-weight: 400; + text-align: center; +} + +.tablenav-pages-navspan { + height: 16px; + border-color: #ddd; /* same as disabled buttons */ + background: #f7f7f7; /* same as disabled buttons */ + color: #a0a5aa; /* same as disabled buttons */ +} + +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + border-color: #5b9dd9; + color: #fff; + background: #00a0d2; + box-shadow: none; + outline: none; /* IE8 */ +} + +.tablenav .displaying-num { + margin-left: 7px; +} + +.tablenav .one-page .displaying-num { + display: inline-block; + margin-top: 5px; + margin-left: 0; +} + +.tablenav .actions { + overflow: hidden; + padding: 2px 0 0 8px; +} + +.wp-filter .actions { + display: inline-block; + vertical-align: middle; +} + +.tablenav .delete { + margin-left: 20px; +} + +/* @todo: unclear if the following tablenav rules are actually used. +classes exist in paginate_links() but not seen in list table output. */ +.tablenav .dots { + border-color: transparent; +} + +.tablenav .next, +.tablenav .prev { + border-color: transparent; + color: #0073aa; +} + +.tablenav .next:hover, +.tablenav .prev:hover { + border-color: transparent; + color: #00a0d2; +} + +.tablenav .view-switch { + float: left; + margin: 0 5px; + padding-top: 3px; +} + +.wp-filter .view-switch { + display: inline-block; + vertical-align: middle; + padding: 12px 0; + margin: 0 2px 0 8px; +} + +.media-toolbar.wp-filter .view-switch { + margin: 0 2px 0 12px; +} + +.view-switch a { + float: right; + width: 28px; + height: 28px; + text-align: center; + line-height: 24px; + text-decoration: none; +} + +.view-switch a:before { + color: #b4b9be; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.view-switch a:hover:before, +.view-switch a:focus:before { + color: #727272; +} + +.view-switch a.current:before { + color: #0073aa; +} + +.view-switch .view-list:before { + content: "\f163"; +} + +.view-switch .view-excerpt:before { + content: "\f164"; +} + +.view-switch .view-grid:before { + content: "\f509"; +} + +.filter { + float: right; + margin: -5px 10px 0 0; +} + +.filter .subsubsub { + margin-right: -10px; + margin-top: 13px; +} +.screen-per-page { + width: 4em; +} + +#posts-filter .wp-filter { + margin-bottom: 0; +} + +#posts-filter fieldset { + float: right; + margin: 0 0 1em 1.5ex; + padding: 0; +} + +#posts-filter fieldset legend { + padding: 0 1px .2em 0; +} + +p.pagenav { + margin: 0; + display: inline; +} + +.pagenav span { + font-weight: 600; + margin: 0 6px; +} + +.row-title { + font-size: 14px !important; + font-weight: 600; +} + +.column-comment .comment-author { + margin-bottom: 0.6em; +} + +.column-author img, +.column-username img, +.column-comment .comment-author img { + float: right; + margin-left: 10px; + margin-top: 1px; +} + +.row-actions { + color: #ddd; + font-size: 13px; + padding: 2px 0 0; + position: relative; + right: -9999em; +} + +/* ticket #34150 */ +.rtl .row-actions a { + display: inline-block; +} + +.row-actions .network_only, +.row-actions .network_active { + color: #000; +} + +.no-js .row-actions, +tr:hover .row-actions, +.mobile .row-actions, +.row-actions.visible, +.comment-item:hover .row-actions { + position: static; +} + +/* deprecated */ +.row-actions-visible { + padding: 2px 0 0; +} + + +/*------------------------------------------------------------------------------ + 10.1 - Inline Editing +------------------------------------------------------------------------------*/ + +/* +.quick-edit* is for Quick Edit +.bulk-edit* is for Bulk Edit +.inline-edit* is for everything +*/ + +/* Layout */ + +#wpbody-content .inline-edit-row fieldset { + font-size: 12px; + float: right; + margin: 0; + padding: 0; + width: 100%; +} + +tr.inline-edit-row td, +#wpbody-content .inline-edit-row fieldset .inline-edit-col { + padding: 0 0.5em; +} + +#wpbody-content .quick-edit-row-post .inline-edit-col-left { + width: 40%; +} + +#wpbody-content .quick-edit-row-post .inline-edit-col-right { + width: 39%; +} + +#wpbody-content .inline-edit-row-post .inline-edit-col-center { + width: 20%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-left { + width: 50%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-right, +#wpbody-content .bulk-edit-row-post .inline-edit-col-right { + width: 49%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-left { + width: 30%; +} + +#wpbody-content .bulk-edit-row-page .inline-edit-col-right { + width: 69%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-bottom { + float: left; + width: 69%; +} + +#wpbody-content .inline-edit-row-page .inline-edit-col-right { + margin-top: 27px; +} + +.inline-edit-row fieldset .inline-edit-group { + clear: both; + line-height: 2.5; +} + +.inline-edit-row .submit { + clear: both; + padding: 0.5em; + margin: 0.5em 0 0; +} + +.inline-edit-row .notice-error { + margin-top: 1em; +} + +.inline-edit-row .notice-error .error { + margin: 0.5em 0; + padding: 2px; +} + +/* Positioning */ + +/* Needs higher specificity for the padding */ +#the-list .inline-edit-row .inline-edit-legend { + margin: 0; + padding: 0.2em 0.5em 0; + line-height: 2.5; + font-weight: 600; +} + +#the-list #bulk-edit.inline-edit-row .inline-edit-legend { + padding: 0.2em 0.5em; +} + +.inline-edit-row fieldset span.title, +.inline-edit-row fieldset span.checkbox-title { + margin: 0; + padding: 0; +} + +.inline-edit-row fieldset label, +.inline-edit-row fieldset span.inline-edit-categories-label { + display: block; + margin: .2em 0; + line-height: 2.5; +} + +.inline-edit-row fieldset.inline-edit-date label { + display: inline-block; + margin: 0; + line-height: 1.5; + vertical-align: baseline; +} + +.inline-edit-row fieldset label.inline-edit-tags { + margin-top: 0; +} + +.inline-edit-row fieldset label.inline-edit-tags span.title { + margin: .2em 0; + width: auto; +} + +.inline-edit-row fieldset label span.title, +.inline-edit-row fieldset.inline-edit-date legend { + display: block; + float: right; + width: 6em; + line-height: 2.5; +} + +#posts-filter fieldset.inline-edit-date legend { + padding: 0; +} + +.inline-edit-row fieldset.inline-edit-date select { + margin: 1px; + line-height: 28px; +} + +.inline-edit-row fieldset label span.input-text-wrap, +.inline-edit-row fieldset .timestamp-wrap { + display: block; + margin-right: 6em; +} + +.quick-edit-row-post fieldset.inline-edit-col-right label span.title { + width: auto; + padding-left: 0.5em; +} + +.inline-edit-row .inline-edit-or { + margin: .2em 0 .2em 6px; + line-height: 2.5; +} + +.inline-edit-row .input-text-wrap input[type=text] { + width: 100%; +} + +.inline-edit-row fieldset label input[type=checkbox] { + vertical-align: middle; +} + +.inline-edit-row fieldset label textarea { + width: 100%; + height: 4em; + vertical-align: top; +} + +#wpbody-content .bulk-edit-row fieldset .inline-edit-group label { + max-width: 50%; +} + +#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child { + margin-left: 0.5em +} + +.inline-edit-col-right .input-text-wrap input.inline-edit-menu-order-input { + width: 6em; +} + +/* Styling */ +.inline-edit-row .inline-edit-legend { + text-transform: uppercase; +} + +.inline-edit-row fieldset span.title, +.inline-edit-row fieldset span.checkbox-title { + font-style: italic; +} + +/* Specific Elements */ +.inline-edit-row fieldset .inline-edit-date { + float: right; +} + +.inline-edit-row fieldset input[name=jj], +.inline-edit-row fieldset input[name=hh], +.inline-edit-row fieldset input[name=mn] { + font-size: 12px; + width: 2.3em; +} + +.inline-edit-row fieldset input[name=aa] { + font-size: 12px; + width: 3.5em; +} + +.inline-edit-row fieldset label input.inline-edit-password-input { + width: 8em; +} + +ul.cat-checklist { + height: 12em; + border: solid 1px #ddd; + overflow-y: scroll; + padding: 0 5px; + margin: 0; + background-color: #fff; +} + +#bulk-titles { + display: block; + height: 12em; + border: 1px solid #ddd; + overflow-y: scroll; + padding: 0 5px; + margin: 0 0 5px; +} + +.inline-edit-row fieldset ul.cat-checklist li, +.inline-edit-row fieldset ul.cat-checklist input { + margin: 0; + position: relative; /* RTL fix, #WP27629 */ +} + +.inline-edit-row fieldset ul.cat-checklist label, +.inline-edit-row #bulk-titles div { + font-style: normal; + font-size: 11px; +} + +.inline-edit-row fieldset label input.inline-edit-menu-order-input { + width: 3em; +} + +.inline-edit-row fieldset label input.inline-edit-slug-input { + width: 75%; +} + +.inline-edit-row #post_parent, +.inline-edit-row select[name="page_template"] { + max-width: 80%; +} + +.ie8 .inline-edit-row #post_parent, +.ie8 .inline-edit-row select[name="page_template"] { + width: 250px; +} + +.quick-edit-row-post fieldset label.inline-edit-status { + float: right; +} + +#bulk-titles { + line-height: 140%; +} +#bulk-titles div { + margin: 0.2em 0.3em; +} + +#bulk-titles div a { + cursor: pointer; + display: block; + float: right; + height: 18px; + margin: 0 -2px 0 3px; + overflow: hidden; + position: relative; + width: 20px; +} + +#bulk-titles div a:before { + position: relative; + top: -3px; +} + +/*------------------------------------------------------------------------------ + 17.0 - Plugins +------------------------------------------------------------------------------*/ + +.plugins tbody th.check-column, +.plugins tbody { + padding: 8px 2px 0 0; +} + +.plugins tbody th.check-column input[type=checkbox] { + margin-top: 4px; +} + +.updates-table .plugin-title p { + margin-top: 0; +} + +.plugins thead td.check-column, +.plugins tfoot td.check-column, +.plugins .inactive th.check-column { + padding-right: 6px; +} + +.plugins, +.plugins th, +.plugins td { + color: #000; +} + +.plugins tr { + background: #fff; +} + +.plugins p { + margin: 0 4px; + padding: 0; +} + +.plugins .desc p { + margin: 0 0 8px; +} + +.plugins td.desc { + line-height: 1.5em; +} + +.plugins .desc ul, +.plugins .desc ol { + margin: 0 2em 0 0; +} + +.plugins .desc ul { + list-style-type: disc; +} + +.plugins .row-actions { + font-size: 13px; + padding: 0; +} + +.plugins .inactive td, +.plugins .inactive th, +.plugins .active td, +.plugins .active th { + padding: 10px 9px; +} + +.plugins .active td, +.plugins .active th { + background-color: #f7fcfe; +} + +.plugins .update th, +.plugins .update td { + border-bottom: 0; +} + +.plugins .inactive td, +.plugins .inactive th, +.plugins .active td, +.plugins .active th, +.plugin-install #the-list td, +.upgrade .plugins td, +.upgrade .plugins th { + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.plugins tr.active.plugin-update-tr + tr.inactive th, +.plugins tr.active.plugin-update-tr + tr.inactive td, +.plugins tr.active + tr.inactive th, +.plugins tr.active + tr.inactive td { + border-top: 1px solid rgba(0,0,0,0.03); + box-shadow: inset 0 1px 0 rgba(0,0,0,0.02), inset 0 -1px 0 #e1e1e1; +} + +.plugins .update td, +.plugins .update th, +.upgrade .plugins tr:last-of-type td, +.upgrade .plugins tr:last-of-type th, +.plugins tr.active + tr.inactive.update th, +.plugins tr.active + tr.inactive.update td, +.plugins .updated td, +.plugins .updated th, +.plugins tr.active + tr.inactive.updated th, +.plugins tr.active + tr.inactive.updated td { + box-shadow: none; +} + +.plugins .active th.check-column, +.plugin-update-tr.active td { + border-right: 4px solid #00a0d2; +} + +.wp-list-table.plugins .plugin-title, +.wp-list-table.plugins .theme-title { + padding-left: 12px; + white-space: nowrap; +} + +.plugins .plugin-title img, +.plugins .plugin-title .dashicons { + float: right; + padding: 0 0 0 10px; + width: 64px; + height: 64px; +} + +.plugins .plugin-title .dashicons:before { + padding: 2px; + background-color: #eee; + box-shadow: inset 0 0 10px rgba(160,165,170,.15); + font-size: 60px; + color: #B4B9BE; +} + +#update-themes-table .plugin-title img, +#update-themes-table .plugin-title .dashicons { + width: 85px; +} + +.plugins .inactive .plugin-title strong { + font-weight: 400; +} + +.plugins .second, +.plugins .row-actions { + padding: 0 0 5px; +} + +.plugins .update .second, +.plugins .update .row-actions, +.plugins .updated .second, +.plugins .updated .row-actions { + padding-bottom: 0; +} + +.plugins-php .widefat tfoot th, +.plugins-php .widefat tfoot td { + border-top-style: solid; + border-top-width: 1px; +} + +.plugins .plugin-update-tr .plugin-update { + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); + overflow: hidden; /* clearfix */ + padding: 0; +} + +.plugins .plugin-update-tr .notice, +.plugins .plugin-update-tr div[class="update-message"] { /* back-compat for pre-4.6 */ + margin: 5px 40px 15px 20px; +} + +.plugins .notice p { + margin: 0.5em 0; +} + +.plugin-card .update-now:before { + color: #f56e28; + content: "\f463"; + display: inline-block; + font: normal 20px/1 dashicons; + margin: 3px -2px 0 5px; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.plugin-card .updating-message:before { + content: "\f463"; + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +@-webkit-keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(-359deg); + transform: rotate(-359deg); + } +} + +@keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(-359deg); + transform: rotate(-359deg); + } +} + +.plugin-card .updated-message:before { + color: #79ba49; + content: "\f147"; +} + +.plugin-install-php h2 { + clear: both; +} + +.plugin-install-php h3 { + margin: 2.5em 0 8px; +} + +.plugin-install-php .wp-filter { + margin-bottom: 0; +} + +/* Plugin card table view */ +.plugin-group { + overflow: hidden; /* clearfix */ + margin-top: 1.5em; +} + +.plugin-group h3 { + margin-top: 0; +} + +.plugin-card { + float: right; + margin: 0 8px 16px; + width: 48.5%; + width: calc( 50% - 8px ); + background-color: #fff; + border: 1px solid #ddd; + box-sizing: border-box; +} + +.plugin-card:nth-child(odd) { + clear: both; + margin-right: 0; +} + +.plugin-card:nth-child(even) { + margin-left: 0; +} + +@media screen and ( min-width: 1600px ) { + .plugin-card { + width: 30%; + width: calc( 33.1% - 8px ); + } + + .plugin-card:nth-child(odd) { + clear: none; + margin-right: 8px; + } + + .plugin-card:nth-child(even) { + margin-left: 8px; + } + + .plugin-card:nth-child(3n+1) { + clear: both; + margin-right: 0; + } + + .plugin-card:nth-child(3n) { + margin-left: 0; + } +} + +.plugin-card-top { + position: relative; + padding: 20px 20px 10px; + min-height: 135px; +} + +div.action-links, +.plugin-action-buttons { + margin: 0; /* Override existing margins */ +} + +.plugin-card h3 { + margin: 0 0 12px; + font-size: 18px; + line-height: 1.3; +} + +.plugin-card .name, +.plugin-card .desc { + margin-right: 148px; /* icon + margin */ + margin-left: 120px; /* action links */ +} + +.plugin-card .action-links { + position: absolute; + top: 20px; + left: 20px; + width: 120px; +} + +.plugin-action-buttons { + clear: left; + float: left; + margin-right: 2em; + margin-bottom: 1em; + text-align: left; +} + +.plugin-action-buttons li { + margin-bottom: 10px; +} + +.plugin-card-bottom { + clear: both; + padding: 12px 20px; + background-color: #fafafa; + border-top: 1px solid #ddd; + overflow: hidden; +} + +.plugin-card-bottom .star-rating { + display: inline; +} + +.plugin-card-update-failed .update-now { + font-weight: 600; +} + +.plugin-card-update-failed .notice-error { + margin: 0; + padding-right: 16px; + box-shadow: 0 -1px 0 #ddd; +} + +.plugin-card-update-failed .plugin-card-bottom { + display: none; +} + +.plugin-card .column-rating { + line-height: 23px; +} + +.plugin-card .column-rating, +.plugin-card .column-updated { + margin-bottom: 4px; +} + +.plugin-card .column-rating, +.plugin-card .column-downloaded { + float: right; + clear: right; + max-width: 180px; +} + +.plugin-card .column-updated, +.plugin-card .column-compatibility { + text-align: left; + float: left; + clear: left; + width: 65%; + width: calc( 100% - 180px ); +} + +.plugin-card .column-compatibility span:before { + font: normal 20px/.5 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: 4px; + right: -2px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +.plugin-card .compatibility-incompatible:before { + content: "\f158"; +} + +.plugin-card .compatibility-compatible:before { + content: "\f147"; +} + +.plugin-icon { + position: absolute; + top: 20px; + right: 20px; + width: 128px; + height: 128px; + margin: 0 0 20px 20px; +} + +.no-plugin-results { + color: #666; /* same as no themes and no media */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0 0; + text-align: center; +} + +/* ms */ +/* Background Color for Site Status */ +.wp-list-table .site-deleted, +.wp-list-table tr.site-deleted { + background: #ff8573; +} +.wp-list-table .site-spammed, +.wp-list-table tr.site-spammed { + background: #faafaa; +} +.wp-list-table .site-archived, +.wp-list-table tr.site-archived { + background: #ffebe8; +} +.wp-list-table .site-mature, +.wp-list-table tr.site-mature { + background: #fecac2; +} + +.sites.fixed .column-lastupdated, +.sites.fixed .column-registered { + width: 20%; +} + +.sites.fixed .column-users { + width: 80px; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and ( max-width: 1100px ) and ( min-width: 782px ), ( max-width: 480px ) { + .plugin-card .action-links { + position: static; + margin-right: 148px; + width: auto; + } + + .plugin-action-buttons { + float: none; + margin: 1em 0 0; + text-align: right; + } + + .plugin-action-buttons li { + display: inline-block; + vertical-align: middle; + } + + .plugin-action-buttons li .button { + margin-left: 20px; + } + + .plugin-card .name, + .plugin-card .desc { + margin-left: 0; + } + + .plugin-card .desc p:first-of-type { + margin-top: 0; + } + + .fixed .column-date { + width: 14%; + } +} + +@media screen and ( max-width: 782px ) { + /* WP List Table Options & Filters */ + .tablenav { + height: auto; + } + + .tablenav.top { + margin: 20px 0 5px 0; + } + + .tablenav.bottom { + position: relative; + margin-top: 15px; + } + + .tablenav br { + display: none; + } + + .tablenav br.clear { + display: block; + } + + .tablenav.top .actions, + .tablenav .view-switch { + display: none; + } + + .view-switch a { + width: 36px; + height: 36px; + line-height: 33px; + } + + /* Pagination */ + .tablenav.top .displaying-num { + display: none; + } + + .tablenav.bottom .displaying-num { + position: absolute; + left: 0; + top: 11px; + margin: 0; + font-size: 14px; + } + + .tablenav .tablenav-pages { + width: 100%; + height: auto; + text-align: center; + margin: 0 0 25px; + } + + .tablenav.bottom .tablenav-pages { + margin-top: 25px; + } + + .tablenav.top .tablenav-pages.one-page { + display: none; + } + + .tablenav.bottom .tablenav-pages.one-page { + margin: 15px 0 0 0; + height: 0; + } + + .tablenav-pages .pagination-links { + font-size: 16px; + } + + .tablenav-pages .pagination-links a, + .tablenav-pages-navspan { + padding: 9px 11px 12px; + font-size: 18px; + } + + .tablenav-pages-navspan { + height: 18px; + } + + .tablenav-pages .pagination-links .current-page { + padding: 8px 9px 9px; + font-size: 16px; + } + + /* WP List Table Adjustments: General */ + .form-wrap > p { + display: none; + } + + .comment-count { + font-size: 14px; + } + + .wp-list-table th.column-primary ~ th, + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary ~ td:not(.check-column) { + display: none; + } + + .wp-list-table thead th.column-primary { + width: 100%; + } + + /* Checkboxes need to show */ + .wp-list-table tr th.check-column { + display: table-cell; + width: 35px; + } + + .wp-list-table .column-primary .toggle-row { + display: block; + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) { + position: relative; + clear: both; + display: block; + width: auto !important; /* needs to override some columns that are more specifically targeted */ + } + + .wp-list-table td.column-primary { + padding-left: 50px; /* space for toggle button */ + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary ~ td:not(.check-column) { + padding: 3px 35% 3px 8px; + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.column-primary)::before { + position: absolute; + right: 10px; /* match padding of regular table cell */ + display: block; + overflow: hidden; + width: 32%; /* leave a little space for a gutter */ + content: attr(data-colname); + white-space: nowrap; + text-overflow: ellipsis; + } + + .wp-list-table .is-expanded td:not(.hidden) { + display: block !important; + overflow: hidden; /* clearfix */ + } + + /* Special cases */ + .widefat .num, + .column-posts { + text-align: right; + } + + #comments-form .fixed .column-author, + #commentsdiv .fixed .column-author { + display: none !important; + } + + .fixed .column-comment .comment-author { + display: block; + } + + #the-comment-list .is-expanded td { + box-shadow: none; + } + + #the-comment-list .is-expanded td:last-child { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); + } + + /* Show comment bubble as text instead */ + .post-com-count .screen-reader-text { + position: static; + -webkit-clip-path: none; + clip-path: none; + width: auto; + height: auto; + margin: 0; + } + + .column-response .post-com-count-no-comments:after, + .column-response .post-com-count-approved:after, + .column-comments .post-com-count-no-comments:after, + .column-comments .post-com-count-approved:after { + content: none; + } + + .column-response .post-com-count [aria-hidden="true"], + .column-comments .post-com-count [aria-hidden="true"] { + display: none; + } + + .column-response .post-com-count-wrapper, + .column-comments .post-com-count-wrapper { + white-space: normal; + } + + .column-response .post-com-count-wrapper > a, + .column-comments .post-com-count-wrapper > a { + display: block; + } + + .column-response .post-com-count-no-comments, + .column-response .post-com-count-approved, + .column-comments .post-com-count-no-comments, + .column-comments .post-com-count-approved { + margin-top: 0; + margin-left: 0.5em; + } + + .column-response .post-com-count-pending, + .column-comments .post-com-count-pending { + position: static; + height: auto; + min-width: 0; + padding: 0; + border: none; + border-radius: 0; + background: none; + color: #bb2a2a; + font-size: inherit; + line-height: inherit; + text-align: right; + } + + .column-response .post-com-count-pending:hover, + .column-comments .post-com-count-pending:hover { + color: #dc3232; + } + + .widefat thead td.check-column, + .widefat tfoot td.check-column { + padding-top: 10px; + } + + .widefat * { + word-wrap: normal; + } + + /* Quick Edit and Bulk Edit */ + #wpbody-content .quick-edit-row-post .inline-edit-col-left, + #wpbody-content .quick-edit-row-post .inline-edit-col-right, + #wpbody-content .inline-edit-row-post .inline-edit-col-center, + #wpbody-content .quick-edit-row-page .inline-edit-col-left, + #wpbody-content .quick-edit-row-page .inline-edit-col-right, + #wpbody-content .bulk-edit-row-post .inline-edit-col-right, + #wpbody-content .bulk-edit-row .inline-edit-col-left, + #wpbody-content .bulk-edit-row-page .inline-edit-col-right, + #wpbody-content .bulk-edit-row .inline-edit-col-bottom { + float: none; + width: 100%; + } + + #wpbody-content .quick-edit-row fieldset .inline-edit-col label, + #wpbody-content .quick-edit-row fieldset .inline-edit-group label, + #wpbody-content .bulk-edit-row fieldset .inline-edit-col label, + #wpbody-content .bulk-edit-row fieldset .inline-edit-group label { + max-width: none; + float: none; + margin-bottom: 5px; + } + + #wpbody .bulk-edit-row fieldset select { + display: block; + width: 100%; + max-width: none; + box-sizing: border-box; + } + + .inline-edit-row fieldset ul.cat-checklist label, + .inline-edit-row #bulk-titles div { + font-size: 16px; + } + + .inline-edit-row fieldset label span.title, + .inline-edit-row fieldset.inline-edit-date legend { + float: none; + } + + .inline-edit-row fieldset label.inline-edit-tags { + padding: 0 0.5em; + } + + .inline-edit-row fieldset .inline-edit-col label.inline-edit-tags { + padding: 0; + } + + .inline-edit-row fieldset label span.input-text-wrap, + .inline-edit-row fieldset .timestamp-wrap { + margin-right: 0; + } + + .inline-edit-row fieldset input[name=jj], + .inline-edit-row fieldset input[name=hh], + .inline-edit-row fieldset input[name=mn] { + width: 3em; + } + + .inline-edit-row fieldset input[name=aa] { + width: 4.5em; + } + + .inline-edit-row .inline-edit-or { + margin: 0 0 0 6px; + } + + #edithead .inside, + #commentsdiv #edithead .inside { + float: none; + text-align: right; + padding: 3px 5px; + } + + #commentsdiv #edithead .inside input, + #edithead .inside input { + width: 100%; + } + + #edithead label { + display: block; + } + + #bulk-titles div { + margin: 0.8em 0.3em; + } + + #bulk-titles div a { + height: 22px; + } + + /* Updates */ + #wpbody-content .updates-table .plugin-title { + width: auto; + white-space: normal; + } + + /* Links */ + .link-manager-php #posts-filter { + margin-top: 25px; + } + + .link-manager-php .tablenav.bottom { + overflow: hidden; + } + + /* List tables that don't toggle rows */ + .comments-box .toggle-row, + .wp-list-table.plugins .toggle-row { + display: none; + } + + /* Plugin/Theme Management */ + #wpbody-content .wp-list-table.plugins td { + display: block; + width: auto; + padding: 10px 9px; /* reset from other list tables that have a label at this width */ + } + + #wpbody-content .wp-list-table.plugins .column-description { + padding-top: 2px; + } + + #wpbody-content .wp-list-table.plugins .plugin-title, + #wpbody-content .wp-list-table.plugins .theme-title { + padding-left: 12px; + white-space: normal; + } + + .wp-list-table.plugins .plugin-title, + .wp-list-table.plugins .theme-title { + padding-top: 13px; + padding-bottom: 4px; + } + + .plugins #the-list tr > td:not(:last-child), + .plugins #the-list .update th, + .plugins #the-list .update td, + .wp-list-table.plugins #the-list .theme-title { + box-shadow: none; + border-top: none; + } + + .plugins #the-list tr td { + border-top: none; + } + + .plugins tbody { + padding: 1px 0 0; + } + + .plugins tr.active + tr.inactive th.check-column, + .plugins tr.active + tr.inactive td.column-description, + .plugins .plugin-update-tr:before { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); + } + + .plugins tr.active + tr.inactive th.check-column, + .plugins tr.active + tr.inactive td { + border-top: none; + } + + /* mimic the checkbox th */ + .plugins .plugin-update-tr:before { + content: ""; + display: table-cell; + } + + .plugins .active.update + .plugin-update-tr:before { + border-right: 4px solid #d54e21; + background-color: #fef7f1; + } + + .plugins #the-list .plugin-update-tr .plugin-update { + border-right: none; + } + + .plugin-update-tr .update-message { + margin-right: 0; + } + + .plugins .active.update + .plugin-update-tr:before { + background-color: #f7fcfe; + border-right: 4px solid #00a0d2; + } + + .plugins .plugin-update-tr .update-message { + margin-right: 0; + } + + .wp-list-table.plugins .plugin-title strong, + .wp-list-table.plugins .theme-title strong { + font-size: 1.4em; + line-height: 1.5; + } + + /* Add New plugins page */ + table.plugin-install .column-name, + table.plugin-install .column-version, + table.plugin-install .column-rating, + table.plugin-install .column-description { + display: block; + width: auto; + } + + table.plugin-install th.column-name, + table.plugin-install th.column-version, + table.plugin-install th.column-rating, + table.plugin-install th.column-description { + display: none; + } + + table.plugin-install td.column-name strong { + font-size: 1.4em; + line-height: 1.6em; + } + + table.plugin-install #the-list td { + box-shadow: none; + } + + table.plugin-install #the-list tr { + display: block; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); + } + + .plugin-card { + margin-right: 0; + margin-left: 0; + width: 100%; + } +} + +@media screen and ( max-width: 480px ) { + .tablenav-pages .current-page { + margin: 0; + } + + .tablenav-pages .tablenav-paging-text { + float: right; + width: 100%; + padding-top: 0.5em; + } +} diff --git a/backend/wp-admin/css/list-tables-rtl.min.css b/backend/wp-admin/css/list-tables-rtl.min.css new file mode 100644 index 0000000..ca27e7c --- /dev/null +++ b/backend/wp-admin/css/list-tables-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.response-links{display:block;margin-bottom:1em}.response-links a{display:block}.response-links a.comments-edit-item-link{font-weight:600}.response-links a.comments-view-item-link{font-size:12px}.post-com-count-wrapper strong{font-weight:400}.comments-view-item-link{display:inline-block;clear:both}.column-comments .post-com-count-wrapper,.column-response .post-com-count-wrapper{white-space:nowrap;word-wrap:normal}.column-comments .post-com-count,.column-response .post-com-count{display:inline-block;vertical-align:top}.column-comments .post-com-count-approved,.column-comments .post-com-count-no-comments,.column-response .post-com-count-approved,.column-response .post-com-count-no-comments{margin-top:5px}.column-comments .comment-count-approved,.column-comments .comment-count-no-comments,.column-response .comment-count-approved,.column-response .comment-count-no-comments{box-sizing:border-box;display:block;padding:0 8px;min-width:24px;height:2em;border-radius:5px;background-color:#72777c;color:#fff;font-size:11px;line-height:21px;text-align:center}.ie8 .column-comments .comment-count-approved,.ie8 .column-comments .comment-count-no-comments,.ie8 .column-response .comment-count-approved,.ie8 .column-response .comment-count-no-comments{min-width:0}.column-comments .post-com-count-approved:after,.column-comments .post-com-count-no-comments:after,.column-response .post-com-count-approved:after,.column-response .post-com-count-no-comments:after{content:"";display:block;margin-right:8px;width:0;height:0;border-top:5px solid #72777c;border-left:5px solid transparent}.column-comments .post-com-count-approved:focus .comment-count-approved,.column-comments .post-com-count-approved:hover .comment-count-approved,.column-response .post-com-count-approved:focus .comment-count-approved,.column-response .post-com-count-approved:hover .comment-count-approved{background:#0073aa}.column-comments .post-com-count-approved:focus:after,.column-comments .post-com-count-approved:hover:after,.column-response .post-com-count-approved:focus:after,.column-response .post-com-count-approved:hover:after{border-top-color:#0073aa}.column-comments .post-com-count-pending,.column-response .post-com-count-pending{position:relative;right:-3px;padding:0 5px;min-width:7px;height:17px;border:2px solid #fff;border-radius:11px;background:#ca4a1f;color:#fff;font-size:9px;line-height:17px;text-align:center}.column-comments .post-com-count-no-pending,.column-response .post-com-count-no-pending{display:none}.commentlist li{padding:1em 1em .2em;margin:0;border-bottom:1px solid #ccc}.commentlist li li{border-bottom:0;padding:0}.commentlist p{padding:0;margin:0 0 .8em}#submitted-on,.submitted-on{color:#555d66}#replyrow td{padding:2px}#replysubmit{margin:0;padding:5px 7px 10px;overflow:hidden}#replysubmit .button{margin-left:5px}#replyrow.inline-edit-row fieldset.comment-reply{font-size:inherit;line-height:inherit}#replyrow legend{margin:0;padding:.2em 5px 0;font-size:13px;line-height:1.4;font-weight:600}#replyrow.inline-edit-row label{display:inline;vertical-align:baseline;line-height:inherit}#commentsdiv #edithead .inside,#edithead .inside{float:right;padding:3px 5px 2px 0;margin:0;text-align:center}#edithead .inside input{width:180px}#edithead label{padding:2px 0}#replycontainer{padding:5px}#replycontent{height:120px;box-shadow:none}#replyerror{border-color:#ddd;background-color:#f9f9f9}.commentlist .avatar{vertical-align:text-top}#the-comment-list div.undo,#the-comment-list tr.undo{background-color:#f5f5f5}#the-comment-list .unapproved td,#the-comment-list .unapproved th{background-color:#fef7f1}#the-comment-list .unapproved th.check-column{border-right:4px solid #d54e21}#the-comment-list .unapproved th.check-column input{margin-right:4px}#the-comment-list .approve a{color:#006505}#the-comment-list .unapprove a{color:#d98500}#the-comment-list td,#the-comment-list th{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}#the-comment-list tr:last-child td,#the-comment-list tr:last-child th{box-shadow:none}#the-comment-list tr.unapproved+tr.approved td,#the-comment-list tr.unapproved+tr.approved th{border-top:1px solid rgba(0,0,0,.03)}.vim-current,.vim-current td,.vim-current th{background-color:#e4f2fd!important}th .comment-grey-bubble{height:16px;width:16px}th .comment-grey-bubble:before{content:"\f101";font:400 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;right:-4px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}table.fixed{table-layout:fixed}.fixed .column-rating,.fixed .column-visible{width:8%}.fixed .column-author,.fixed .column-date,.fixed .column-format,.fixed .column-links,.fixed .column-parent,.fixed .column-posts{width:10%}.fixed .column-posts{width:74px}.fixed .column-comment .comment-author{display:none}.fixed .column-categories,.fixed .column-rel,.fixed .column-response,.fixed .column-role,.fixed .column-tags{width:15%}.fixed .column-slug{width:25%}.fixed .column-locations{width:35%}.fixed .column-comments{width:5.5em;padding:8px 0;text-align:right}.fixed .column-comments .vers{padding-right:3px}td.column-title strong,td.plugin-title strong{display:block;margin-bottom:.2em;font-size:14px}td.column-title p,td.plugin-title p{margin:6px 0}table.media .column-title .media-icon{float:right;min-height:60px;margin:0 0 0 9px}table.media .column-title .media-icon img{max-width:60px;height:auto;vertical-align:top}table.media .column-title .has-media-icon~.row-actions{margin-right:70px}table.media .column-title .filename{margin-bottom:.2em}.wp-list-table a{transition:none}#the-list tr:last-child td,#the-list tr:last-child th{border-bottom:none!important;box-shadow:none}#comments-form .fixed .column-author{width:20%}#comments-form .fixed .column-date{width:14%}#commentsdiv.postbox .inside{margin:0;padding:0}#commentsdiv .inside .row-actions{line-height:18px}#commentsdiv .inside .column-author{width:25%}#commentsdiv .column-comment p{margin:.6em 0;padding:0}#commentsdiv #replyrow td{padding:0}#commentsdiv p{padding:8px 10px;margin:0}#commentsdiv .comments-box{border:0}#commentsdiv .comments-box thead td,#commentsdiv .comments-box thead th{background:0 0;padding:0 7px 4px;font-style:italic}#commentsdiv .comments-box tr:last-child td{border-bottom:0 none}#commentsdiv #edithead .inside input{width:160px}.sorting-indicator{display:block;visibility:hidden;width:10px;height:4px;margin-top:8px;margin-right:7px}.sorting-indicator:before{content:"\f142";font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0;top:-4px;right:-8px;line-height:10px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}.column-comments .sorting-indicator:before{top:0;right:-10px}th.desc a:focus span.sorting-indicator:before,th.desc:hover span.sorting-indicator:before,th.sorted.asc .sorting-indicator:before{content:"\f142"}th.asc a:focus span.sorting-indicator:before,th.asc:hover span.sorting-indicator:before,th.sorted.desc .sorting-indicator:before{content:"\f140"}.wp-list-table .toggle-row{position:absolute;left:8px;top:10px;display:none;padding:0;width:40px;height:40px;border:none;outline:0;background:0 0}.wp-list-table .toggle-row:hover{cursor:pointer}.wp-list-table .toggle-row:focus:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 .wp-list-table .toggle-row:focus:before{outline:#5b9dd9 solid 1px}.wp-list-table .toggle-row:active{box-shadow:none}.wp-list-table .toggle-row:before{position:absolute;top:-5px;right:10px;border-radius:50%;display:block;padding:1px 0 1px 2px;color:#444;content:"\f140";font:400 20px/1 dashicons;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.wp-list-table .is-expanded .toggle-row:before{content:"\f142"}tr.wp-locked .locked-indicator{margin-right:6px;height:20px;width:16px}tr.wp-locked .locked-indicator-icon:before{color:#82878c;content:"\f160";display:inline-block;font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}tr.wp-locked .check-column input[type=checkbox],tr.wp-locked .check-column label,tr.wp-locked .row-actions .inline,tr.wp-locked .row-actions .trash{display:none}tr .locked-info{height:0;opacity:0}tr.wp-locked .locked-info{margin-top:4px;height:auto;opacity:1}.locked-text{vertical-align:top}tr.locked-info,tr.wp-locked .locked-info{transition:height 1s,opacity .5s}.fixed .column-comments .sorting-indicator{margin-top:3px}#menu-locations-wrap .widefat{width:60%}.widefat th.sortable,.widefat th.sorted{padding:0}th.sortable a,th.sorted a{display:block;overflow:hidden;padding:8px}.fixed .column-comments.sortable a,.fixed .column-comments.sorted a{padding:8px 0}th.sortable a span,th.sorted a span{float:right;cursor:pointer}th.asc a:focus span.sorting-indicator,th.asc:hover span.sorting-indicator,th.desc a:focus span.sorting-indicator,th.desc:hover span.sorting-indicator,th.sorted .sorting-indicator{visibility:visible}.tablenav-pages a,.tablenav-pages-navspan{font-weight:600;padding:0 2px}.tablenav-pages .current-page{margin:0 0 0 2px;padding-bottom:5px;font-size:13px;text-align:center}.tablenav .total-pages{margin-left:2px}.tablenav #table-paging{margin-right:2px}.tablenav a.button,.tablenav a.button-secondary{display:block;margin:3px 0 0 8px}.tablenav{clear:both;height:30px;margin:6px 0 4px;vertical-align:middle}.tablenav.themes{max-width:98%}.tablenav .tablenav-pages{float:left;height:28px;margin-top:3px;cursor:default;color:#555}.tablenav .no-pages,.tablenav .one-page .pagination-links{display:none}.tablenav .tablenav-pages a,.tablenav-pages span.current{text-decoration:none;padding:3px 6px}.tablenav .tablenav-pages a,.tablenav-pages-navspan{display:inline-block;min-width:17px;border:1px solid #ccc;padding:3px 5px 7px;background:#e5e5e5;font-size:16px;line-height:1;font-weight:400;text-align:center}.tablenav-pages-navspan{height:16px;border-color:#ddd;background:#f7f7f7;color:#a0a5aa}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover{border-color:#5b9dd9;color:#fff;background:#00a0d2;box-shadow:none;outline:0}.tablenav .displaying-num{margin-left:7px}.tablenav .one-page .displaying-num{display:inline-block;margin-top:5px;margin-left:0}.tablenav .actions{overflow:hidden;padding:2px 0 0 8px}.wp-filter .actions{display:inline-block;vertical-align:middle}.tablenav .delete{margin-left:20px}.tablenav .dots{border-color:transparent}.tablenav .next,.tablenav .prev{border-color:transparent;color:#0073aa}.tablenav .next:hover,.tablenav .prev:hover{border-color:transparent;color:#00a0d2}.tablenav .view-switch{float:left;margin:0 5px;padding-top:3px}.wp-filter .view-switch{display:inline-block;vertical-align:middle;padding:12px 0;margin:0 2px 0 8px}.media-toolbar.wp-filter .view-switch{margin:0 2px 0 12px}.view-switch a{float:right;width:28px;height:28px;text-align:center;line-height:24px;text-decoration:none}.view-switch a:before{color:#b4b9be;display:inline-block;font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.view-switch a:focus:before,.view-switch a:hover:before{color:#727272}.view-switch a.current:before{color:#0073aa}.view-switch .view-list:before{content:"\f163"}.view-switch .view-excerpt:before{content:"\f164"}.view-switch .view-grid:before{content:"\f509"}.filter{float:right;margin:-5px 10px 0 0}.filter .subsubsub{margin-right:-10px;margin-top:13px}.screen-per-page{width:4em}#posts-filter .wp-filter{margin-bottom:0}#posts-filter fieldset{float:right;margin:0 0 1em 1.5ex;padding:0}#posts-filter fieldset legend{padding:0 1px .2em 0}.row-actions,.row-actions-visible{padding:2px 0 0}p.pagenav{margin:0;display:inline}.pagenav span{font-weight:600;margin:0 6px}.row-title{font-size:14px!important;font-weight:600}.column-comment .comment-author{margin-bottom:.6em}.column-author img,.column-comment .comment-author img,.column-username img{float:right;margin-left:10px;margin-top:1px}.row-actions{color:#ddd;font-size:13px;position:relative;right:-9999em}.plugins,.plugins td,.plugins th,.row-actions .network_active,.row-actions .network_only{color:#000}.rtl .row-actions a{display:inline-block}.comment-item:hover .row-actions,.mobile .row-actions,.no-js .row-actions,.row-actions.visible,tr:hover .row-actions{position:static}#wpbody-content .inline-edit-row fieldset{font-size:12px;float:right;margin:0;padding:0;width:100%}#wpbody-content .inline-edit-row fieldset .inline-edit-col,tr.inline-edit-row td{padding:0 .5em}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:40%}#wpbody-content .quick-edit-row-post .inline-edit-col-right{width:39%}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:20%}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:50%}#wpbody-content .bulk-edit-row-post .inline-edit-col-right,#wpbody-content .quick-edit-row-page .inline-edit-col-right{width:49%}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:30%}#wpbody-content .bulk-edit-row-page .inline-edit-col-right{width:69%}#wpbody-content .bulk-edit-row .inline-edit-col-bottom{float:left;width:69%}#wpbody-content .inline-edit-row-page .inline-edit-col-right{margin-top:27px}.inline-edit-row fieldset .inline-edit-group{clear:both;line-height:2.5}.inline-edit-row .submit{clear:both;padding:.5em;margin:.5em 0 0}.inline-edit-row .notice-error{margin-top:1em}.inline-edit-row .notice-error .error{margin:.5em 0;padding:2px}#the-list .inline-edit-row .inline-edit-legend{margin:0;padding:.2em .5em 0;line-height:2.5;font-weight:600}#the-list #bulk-edit.inline-edit-row .inline-edit-legend{padding:.2em .5em}.inline-edit-row fieldset span.checkbox-title,.inline-edit-row fieldset span.title{margin:0;padding:0;font-style:italic}.inline-edit-row fieldset label,.inline-edit-row fieldset span.inline-edit-categories-label{display:block;margin:.2em 0;line-height:2.5}.inline-edit-row fieldset.inline-edit-date label{display:inline-block;margin:0;line-height:1.5;vertical-align:baseline}.inline-edit-row fieldset label.inline-edit-tags{margin-top:0}.inline-edit-row fieldset label.inline-edit-tags span.title{margin:.2em 0;width:auto}.inline-edit-row fieldset label span.title,.inline-edit-row fieldset.inline-edit-date legend{display:block;float:right;width:6em;line-height:2.5}#posts-filter fieldset.inline-edit-date legend{padding:0}.inline-edit-row fieldset.inline-edit-date select{margin:1px;line-height:28px}.inline-edit-row fieldset .timestamp-wrap,.inline-edit-row fieldset label span.input-text-wrap{display:block;margin-right:6em}.quick-edit-row-post fieldset.inline-edit-col-right label span.title{width:auto;padding-left:.5em}.inline-edit-row .inline-edit-or{margin:.2em 0 .2em 6px;line-height:2.5}.inline-edit-row .input-text-wrap input[type=text]{width:100%}.inline-edit-row fieldset label input[type=checkbox]{vertical-align:middle}.inline-edit-row fieldset label textarea{width:100%;height:4em;vertical-align:top}#bulk-titles,ul.cat-checklist{height:12em;border:1px solid #ddd;overflow-y:scroll;padding:0 5px}#wpbody-content .bulk-edit-row fieldset .inline-edit-group label{max-width:50%}#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child{margin-left:.5em}.inline-edit-col-right .input-text-wrap input.inline-edit-menu-order-input{width:6em}.inline-edit-row .inline-edit-legend{text-transform:uppercase}.inline-edit-row fieldset .inline-edit-date{float:right}.inline-edit-row fieldset input[name=hh],.inline-edit-row fieldset input[name=jj],.inline-edit-row fieldset input[name=mn]{font-size:12px;width:2.3em}.inline-edit-row fieldset input[name=aa]{font-size:12px;width:3.5em}.inline-edit-row fieldset label input.inline-edit-password-input{width:8em}ul.cat-checklist{margin:0;background-color:#fff}#bulk-titles{display:block;margin:0 0 5px;line-height:140%}.inline-edit-row fieldset ul.cat-checklist input,.inline-edit-row fieldset ul.cat-checklist li{margin:0;position:relative}.inline-edit-row #bulk-titles div,.inline-edit-row fieldset ul.cat-checklist label{font-style:normal;font-size:11px}.inline-edit-row fieldset label input.inline-edit-menu-order-input{width:3em}.inline-edit-row fieldset label input.inline-edit-slug-input{width:75%}.inline-edit-row #post_parent,.inline-edit-row select[name=page_template]{max-width:80%}.ie8 .inline-edit-row #post_parent,.ie8 .inline-edit-row select[name=page_template]{width:250px}.quick-edit-row-post fieldset label.inline-edit-status{float:right}#bulk-titles div{margin:.2em .3em}#bulk-titles div a{cursor:pointer;display:block;float:right;height:18px;margin:0 -2px 0 3px;overflow:hidden;position:relative;width:20px}#bulk-titles div a:before{position:relative;top:-3px}.plugins tbody,.plugins tbody th.check-column{padding:8px 2px 0 0}.plugins tbody th.check-column input[type=checkbox]{margin-top:4px}.updates-table .plugin-title p{margin-top:0}.plugins .inactive th.check-column,.plugins tfoot td.check-column,.plugins thead td.check-column{padding-right:6px}.plugins tr{background:#fff}.plugins p{margin:0 4px;padding:0}.plugins .desc p{margin:0 0 8px}.plugins td.desc{line-height:1.5em}.plugins .desc ol,.plugins .desc ul{margin:0 2em 0 0}.plugins .desc ul{list-style-type:disc}.plugins .row-actions{font-size:13px}.plugins .active td,.plugins .active th,.plugins .inactive td,.plugins .inactive th{padding:10px 9px}.plugins .active td,.plugins .active th{background-color:#f7fcfe}.plugins .update td,.plugins .update th{border-bottom:0}.plugin-install #the-list td,.plugins .active td,.plugins .active th,.plugins .inactive td,.plugins .inactive th,.upgrade .plugins td,.upgrade .plugins th{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugins tr.active+tr.inactive td,.plugins tr.active+tr.inactive th,.plugins tr.active.plugin-update-tr+tr.inactive td,.plugins tr.active.plugin-update-tr+tr.inactive th{border-top:1px solid rgba(0,0,0,.03);box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1}.plugins .update td,.plugins .update th,.plugins .updated td,.plugins .updated th,.plugins tr.active+tr.inactive.update td,.plugins tr.active+tr.inactive.update th,.plugins tr.active+tr.inactive.updated td,.plugins tr.active+tr.inactive.updated th,.upgrade .plugins tr:last-of-type td,.upgrade .plugins tr:last-of-type th{box-shadow:none}.plugin-update-tr.active td,.plugins .active th.check-column{border-right:4px solid #00a0d2}.wp-list-table.plugins .plugin-title,.wp-list-table.plugins .theme-title{padding-left:12px;white-space:nowrap}.plugins .plugin-title .dashicons,.plugins .plugin-title img{float:right;padding:0 0 0 10px;width:64px;height:64px}.plugins .plugin-title .dashicons:before{padding:2px;background-color:#eee;box-shadow:inset 0 0 10px rgba(160,165,170,.15);font-size:60px;color:#B4B9BE}#update-themes-table .plugin-title .dashicons,#update-themes-table .plugin-title img{width:85px}.plugins .inactive .plugin-title strong{font-weight:400}.plugins .row-actions,.plugins .second{padding:0 0 5px}.plugins .update .row-actions,.plugins .update .second,.plugins .updated .row-actions,.plugins .updated .second{padding-bottom:0}.plugins-php .widefat tfoot td,.plugins-php .widefat tfoot th{border-top-style:solid;border-top-width:1px}.plugins .plugin-update-tr .plugin-update{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);overflow:hidden;padding:0}.plugins .plugin-update-tr .notice,.plugins .plugin-update-tr div[class=update-message]{margin:5px 40px 15px 20px}.plugins .notice p{margin:.5em 0}.plugin-card .update-now:before{color:#f56e28;content:"\f463";display:inline-block;font:400 20px/1 dashicons;margin:3px -2px 0 5px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.plugin-card .updating-message:before{content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}}.plugin-card .updated-message:before{color:#79ba49;content:"\f147"}.plugin-install-php h2{clear:both}.plugin-install-php h3{margin:2.5em 0 8px}.plugin-install-php .wp-filter{margin-bottom:0}.plugin-group{overflow:hidden;margin-top:1.5em}.plugin-group h3{margin-top:0}.plugin-card{float:right;margin:0 8px 16px;width:48.5%;width:calc(50% - 8px);background-color:#fff;border:1px solid #ddd;box-sizing:border-box}.plugin-card:nth-child(odd){clear:both;margin-right:0}.plugin-card:nth-child(even){margin-left:0}@media screen and (min-width:1600px){.plugin-card{width:30%;width:calc(33.1% - 8px)}.plugin-card:nth-child(odd){clear:none;margin-right:8px}.plugin-card:nth-child(even){margin-left:8px}.plugin-card:nth-child(3n+1){clear:both;margin-right:0}.plugin-card:nth-child(3n){margin-left:0}}.plugin-card-top{position:relative;padding:20px 20px 10px;min-height:135px}.plugin-action-buttons,div.action-links{margin:0}.plugin-card h3{margin:0 0 12px;font-size:18px;line-height:1.3}.plugin-card .desc,.plugin-card .name{margin-right:148px;margin-left:120px}.plugin-card .action-links{position:absolute;top:20px;left:20px;width:120px}.plugin-action-buttons{clear:left;float:left;margin-right:2em;margin-bottom:1em;text-align:left}.plugin-action-buttons li{margin-bottom:10px}.plugin-card-bottom{clear:both;padding:12px 20px;background-color:#fafafa;border-top:1px solid #ddd;overflow:hidden}.plugin-card-bottom .star-rating{display:inline}.plugin-card-update-failed .update-now{font-weight:600}.plugin-card-update-failed .notice-error{margin:0;padding-right:16px;box-shadow:0 -1px 0 #ddd}.plugin-card-update-failed .plugin-card-bottom{display:none}.plugin-card .column-rating{line-height:23px}.plugin-card .column-rating,.plugin-card .column-updated{margin-bottom:4px}.plugin-card .column-downloaded,.plugin-card .column-rating{float:right;clear:right;max-width:180px}.plugin-card .column-compatibility,.plugin-card .column-updated{text-align:left;float:left;clear:left;width:65%;width:calc(100% - 180px)}.plugin-card .column-compatibility span:before{font:400 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;right:-2px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}.plugin-card .compatibility-incompatible:before{content:"\f158"}.plugin-card .compatibility-compatible:before{content:"\f147"}.plugin-icon{position:absolute;top:20px;right:20px;width:128px;height:128px;margin:0 0 20px 20px}.no-plugin-results{color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0 0;text-align:center}.wp-list-table .site-deleted,.wp-list-table tr.site-deleted{background:#ff8573}.wp-list-table .site-spammed,.wp-list-table tr.site-spammed{background:#faafaa}.wp-list-table .site-archived,.wp-list-table tr.site-archived{background:#ffebe8}.wp-list-table .site-mature,.wp-list-table tr.site-mature{background:#fecac2}.sites.fixed .column-lastupdated,.sites.fixed .column-registered{width:20%}.sites.fixed .column-users{width:80px}@media screen and (max-width:1100px) and (min-width:782px),(max-width:480px){.plugin-card .action-links{position:static;margin-right:148px;width:auto}.plugin-action-buttons{float:none;margin:1em 0 0;text-align:right}.plugin-action-buttons li{display:inline-block;vertical-align:middle}.plugin-action-buttons li .button{margin-left:20px}.plugin-card .desc,.plugin-card .name{margin-left:0}.plugin-card .desc p:first-of-type{margin-top:0}.fixed .column-date{width:14%}}@media screen and (max-width:782px){.plugins #the-list tr td,.plugins tr.active+tr.inactive td,.plugins tr.active+tr.inactive th.check-column{border-top:none}.tablenav{height:auto}.tablenav.top{margin:20px 0 5px}.tablenav.bottom{position:relative;margin-top:15px}.tablenav br{display:none}.tablenav br.clear{display:block}.form-wrap>p,.tablenav .view-switch,.tablenav.top .actions,.tablenav.top .displaying-num,.tablenav.top .tablenav-pages.one-page{display:none}.view-switch a{width:36px;height:36px;line-height:33px}.tablenav.bottom .displaying-num{position:absolute;left:0;top:11px;margin:0;font-size:14px}.tablenav .tablenav-pages{width:100%;height:auto;text-align:center;margin:0 0 25px}.tablenav.bottom .tablenav-pages{margin-top:25px}.tablenav.bottom .tablenav-pages.one-page{margin:15px 0 0;height:0}.tablenav-pages .pagination-links{font-size:16px}.tablenav-pages .pagination-links a,.tablenav-pages-navspan{padding:9px 11px 12px;font-size:18px}.tablenav-pages-navspan{height:18px}.tablenav-pages .pagination-links .current-page{padding:8px 9px 9px;font-size:16px}.comment-count{font-size:14px}.wp-list-table th.column-primary~th,.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary~td:not(.check-column){display:none}.wp-list-table thead th.column-primary{width:100%}.wp-list-table tr th.check-column{display:table-cell;width:35px}.wp-list-table .column-primary .toggle-row{display:block}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){position:relative;clear:both;display:block;width:auto!important}.wp-list-table td.column-primary{padding-left:50px}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary~td:not(.check-column){padding:3px 35% 3px 8px}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.column-primary)::before{position:absolute;right:10px;display:block;overflow:hidden;width:32%;content:attr(data-colname);white-space:nowrap;text-overflow:ellipsis}.wp-list-table .is-expanded td:not(.hidden){display:block!important;overflow:hidden}.column-posts,.widefat .num{text-align:right}#comments-form .fixed .column-author,#commentsdiv .fixed .column-author{display:none!important}.fixed .column-comment .comment-author{display:block}#the-comment-list .is-expanded td{box-shadow:none}#the-comment-list .is-expanded td:last-child{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.post-com-count .screen-reader-text{position:static;-webkit-clip-path:none;clip-path:none;width:auto;height:auto;margin:0}.column-comments .post-com-count-approved:after,.column-comments .post-com-count-no-comments:after,.column-response .post-com-count-approved:after,.column-response .post-com-count-no-comments:after{content:none}.column-comments .post-com-count [aria-hidden=true],.column-response .post-com-count [aria-hidden=true]{display:none}#edithead label,.column-comments .post-com-count-wrapper>a,.column-response .post-com-count-wrapper>a{display:block}.column-comments .post-com-count-wrapper,.column-response .post-com-count-wrapper{white-space:normal}.column-comments .post-com-count-approved,.column-comments .post-com-count-no-comments,.column-response .post-com-count-approved,.column-response .post-com-count-no-comments{margin-top:0;margin-left:.5em}.column-comments .post-com-count-pending,.column-response .post-com-count-pending{position:static;height:auto;min-width:0;padding:0;border:none;border-radius:0;background:0 0;color:#bb2a2a;font-size:inherit;line-height:inherit;text-align:right}.column-comments .post-com-count-pending:hover,.column-response .post-com-count-pending:hover{color:#dc3232}.widefat tfoot td.check-column,.widefat thead td.check-column{padding-top:10px}.widefat *{word-wrap:normal}#wpbody-content .bulk-edit-row .inline-edit-col-bottom,#wpbody-content .bulk-edit-row .inline-edit-col-left,#wpbody-content .bulk-edit-row-page .inline-edit-col-right,#wpbody-content .bulk-edit-row-post .inline-edit-col-right,#wpbody-content .inline-edit-row-post .inline-edit-col-center,#wpbody-content .quick-edit-row-page .inline-edit-col-left,#wpbody-content .quick-edit-row-page .inline-edit-col-right,#wpbody-content .quick-edit-row-post .inline-edit-col-left,#wpbody-content .quick-edit-row-post .inline-edit-col-right{float:none;width:100%}#wpbody-content .bulk-edit-row fieldset .inline-edit-col label,#wpbody-content .bulk-edit-row fieldset .inline-edit-group label,#wpbody-content .quick-edit-row fieldset .inline-edit-col label,#wpbody-content .quick-edit-row fieldset .inline-edit-group label{max-width:none;float:none;margin-bottom:5px}#wpbody .bulk-edit-row fieldset select{display:block;width:100%;max-width:none;box-sizing:border-box}.inline-edit-row #bulk-titles div,.inline-edit-row fieldset ul.cat-checklist label{font-size:16px}.inline-edit-row fieldset label span.title,.inline-edit-row fieldset.inline-edit-date legend{float:none}.inline-edit-row fieldset label.inline-edit-tags{padding:0 .5em}.inline-edit-row fieldset .inline-edit-col label.inline-edit-tags{padding:0}.inline-edit-row fieldset .timestamp-wrap,.inline-edit-row fieldset label span.input-text-wrap{margin-right:0}.inline-edit-row fieldset input[name=hh],.inline-edit-row fieldset input[name=jj],.inline-edit-row fieldset input[name=mn]{width:3em}.inline-edit-row fieldset input[name=aa]{width:4.5em}.inline-edit-row .inline-edit-or{margin:0 0 0 6px}#commentsdiv #edithead .inside,#edithead .inside{float:none;text-align:right;padding:3px 5px}#commentsdiv #edithead .inside input,#edithead .inside input{width:100%}#bulk-titles div{margin:.8em .3em}.plugin-card,.plugin-update-tr .update-message,.plugins .plugin-update-tr .update-message{margin-right:0}#bulk-titles div a{height:22px}#wpbody-content .updates-table .plugin-title{width:auto;white-space:normal}.link-manager-php #posts-filter{margin-top:25px}.link-manager-php .tablenav.bottom{overflow:hidden}.comments-box .toggle-row,.wp-list-table.plugins .toggle-row{display:none}#wpbody-content .wp-list-table.plugins td{display:block;width:auto;padding:10px 9px}#wpbody-content .wp-list-table.plugins .column-description{padding-top:2px}#wpbody-content .wp-list-table.plugins .plugin-title,#wpbody-content .wp-list-table.plugins .theme-title{padding-left:12px;white-space:normal}.wp-list-table.plugins .plugin-title,.wp-list-table.plugins .theme-title{padding-top:13px;padding-bottom:4px}.plugins #the-list .update td,.plugins #the-list .update th,.plugins #the-list tr>td:not(:last-child),.wp-list-table.plugins #the-list .theme-title{box-shadow:none;border-top:none}.plugins tbody{padding:1px 0 0}.plugins .plugin-update-tr:before,.plugins tr.active+tr.inactive td.column-description,.plugins tr.active+tr.inactive th.check-column{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugins .plugin-update-tr:before{content:"";display:table-cell}.plugins #the-list .plugin-update-tr .plugin-update{border-right:none}.plugins .active.update+.plugin-update-tr:before{background-color:#f7fcfe;border-right:4px solid #00a0d2}.wp-list-table.plugins .plugin-title strong,.wp-list-table.plugins .theme-title strong{font-size:1.4em;line-height:1.5}table.plugin-install .column-description,table.plugin-install .column-name,table.plugin-install .column-rating,table.plugin-install .column-version{display:block;width:auto}table.plugin-install th.column-description,table.plugin-install th.column-name,table.plugin-install th.column-rating,table.plugin-install th.column-version{display:none}table.plugin-install td.column-name strong{font-size:1.4em;line-height:1.6em}table.plugin-install #the-list td{box-shadow:none}table.plugin-install #the-list tr{display:block;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugin-card{margin-left:0;width:100%}}@media screen and (max-width:480px){.tablenav-pages .current-page{margin:0}.tablenav-pages .tablenav-paging-text{float:right;width:100%;padding-top:.5em}} \ No newline at end of file diff --git a/backend/wp-admin/css/list-tables.css b/backend/wp-admin/css/list-tables.css new file mode 100644 index 0000000..495c49b --- /dev/null +++ b/backend/wp-admin/css/list-tables.css @@ -0,0 +1,2145 @@ +.response-links { + display: block; + margin-bottom: 1em; +} + +.response-links a { + display: block; +} + +.response-links a.comments-edit-item-link { + font-weight: 600; +} + +.response-links a.comments-view-item-link { + font-size: 12px; +} + +.post-com-count-wrapper strong { + font-weight: 400; +} + +.comments-view-item-link { + display: inline-block; + clear: both; +} + +.column-response .post-com-count-wrapper, +.column-comments .post-com-count-wrapper { + white-space: nowrap; + word-wrap: normal; +} + +/* comments bubble common */ +.column-response .post-com-count, +.column-comments .post-com-count { + display: inline-block; + vertical-align: top; +} + +/* comments bubble approved */ +.column-response .post-com-count-no-comments, +.column-response .post-com-count-approved, +.column-comments .post-com-count-no-comments, +.column-comments .post-com-count-approved { + margin-top: 5px; +} + +.column-response .comment-count-no-comments, +.column-response .comment-count-approved, +.column-comments .comment-count-no-comments, +.column-comments .comment-count-approved { + box-sizing: border-box; + display: block; + padding: 0 8px; + min-width: 24px; + height: 2em; + border-radius: 5px; + background-color: #72777c; + color: #fff; + font-size: 11px; + line-height: 21px; + text-align: center; +} + +.ie8 .column-response .comment-count-no-comments, +.ie8 .column-response .comment-count-approved, +.ie8 .column-comments .comment-count-no-comments, +.ie8 .column-comments .comment-count-approved { + min-width: 0; +} + +.column-response .post-com-count-no-comments:after, +.column-response .post-com-count-approved:after, +.column-comments .post-com-count-no-comments:after, +.column-comments .post-com-count-approved:after { + content: ""; + display: block; + margin-left: 8px; + width: 0; + height: 0; + border-top: 5px solid #72777c; + border-right: 5px solid transparent; +} + +.column-response .post-com-count-approved:hover .comment-count-approved, +.column-response .post-com-count-approved:focus .comment-count-approved, +.column-comments .post-com-count-approved:hover .comment-count-approved, +.column-comments .post-com-count-approved:focus .comment-count-approved { + background: #0073aa; +} + +.column-response .post-com-count-approved:hover:after, +.column-response .post-com-count-approved:focus:after, +.column-comments .post-com-count-approved:hover:after, +.column-comments .post-com-count-approved:focus:after { + border-top-color: #0073aa; +} + +/* @todo: consider to use a single rule for these counters and the admin menu counters. */ +.column-response .post-com-count-pending, +.column-comments .post-com-count-pending { + position: relative; + left: -3px; + padding: 0 5px; + min-width: 7px; + height: 17px; + border: 2px solid #fff; + border-radius: 11px; + background: #ca4a1f; + color: #fff; + font-size: 9px; + line-height: 17px; + text-align: center; +} + +.column-response .post-com-count-no-pending, +.column-comments .post-com-count-no-pending { + display: none; +} + +/* comments */ + +.commentlist li { + padding: 1em 1em .2em; + margin: 0; + border-bottom: 1px solid #ccc; +} + +.commentlist li li { + border-bottom: 0; + padding: 0; +} + +.commentlist p { + padding: 0; + margin: 0 0 .8em; +} + +#submitted-on, +.submitted-on { + color: #555d66; +} + +/* reply to comments */ +#replyrow td { + padding: 2px; +} + +#replysubmit { + margin: 0; + padding: 5px 7px 10px; + overflow: hidden; +} + +#replysubmit .button { + margin-right: 5px; +} + +#replyrow.inline-edit-row fieldset.comment-reply { + font-size: inherit; + line-height: inherit; +} + +#replyrow legend { + margin: 0; + padding: .2em 5px 0; + font-size: 13px; + line-height: 1.4; + font-weight: 600; +} + +#replyrow.inline-edit-row label { + display: inline; + vertical-align: baseline; + line-height: inherit; +} + +#edithead .inside, +#commentsdiv #edithead .inside { + float: left; + padding: 3px 0 2px 5px; + margin: 0; + text-align: center; +} + +#edithead .inside input { + width: 180px; +} + +#edithead label { + padding: 2px 0; +} + +#replycontainer { + padding: 5px; +} + +#replycontent { + height: 120px; + box-shadow: none; +} + +#replyerror { + border-color: #ddd; + background-color: #f9f9f9; +} + +/* @todo: is this used? */ +.commentlist .avatar { + vertical-align: text-top; +} + +#the-comment-list tr.undo, +#the-comment-list div.undo { + background-color: #f5f5f5; +} + +#the-comment-list .unapproved th, +#the-comment-list .unapproved td { + background-color: #fef7f1; +} + +#the-comment-list .unapproved th.check-column { + border-left: 4px solid #d54e21; +} + +#the-comment-list .unapproved th.check-column input { + margin-left: 4px; +} + +#the-comment-list .approve a { + color: #006505; +} + +#the-comment-list .unapprove a { + color: #d98500; +} + +#the-comment-list th, +#the-comment-list td { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); +} + +#the-comment-list tr:last-child th, +#the-comment-list tr:last-child td { + box-shadow: none; +} + +#the-comment-list tr.unapproved + tr.approved th, +#the-comment-list tr.unapproved + tr.approved td { + border-top: 1px solid rgba(0, 0, 0, 0.03); +} + +/* table vim shortcuts */ +.vim-current, +.vim-current th, +.vim-current td { + background-color: #e4f2fd !important; +} + +th .comment-grey-bubble { + height: 16px; + width: 16px; +} + +th .comment-grey-bubble:before { + content: "\f101"; + font: normal 20px/.5 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: 4px; + left: -4px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +/*------------------------------------------------------------------------------ + 10.0 - List Posts (/Pages/etc) +------------------------------------------------------------------------------*/ + +table.fixed { + table-layout: fixed; +} + +.fixed .column-rating, +.fixed .column-visible { + width: 8%; +} + +.fixed .column-posts, +.fixed .column-date, +.fixed .column-parent, +.fixed .column-links, +.fixed .column-author, +.fixed .column-format { + width: 10%; +} + +.fixed .column-posts { + width: 74px; +} + +.fixed .column-comment .comment-author { + display: none; +} + +.fixed .column-response, +.fixed .column-categories, +.fixed .column-tags, +.fixed .column-rel, +.fixed .column-role { + width: 15%; +} + +.fixed .column-slug { + width: 25%; +} + +.fixed .column-locations { + width: 35%; +} + +.fixed .column-comments { + width: 5.5em; + padding: 8px 0; + text-align: left; +} + +.fixed .column-comments .vers { + padding-left: 3px; +} + +td.column-title strong, +td.plugin-title strong { + display: block; + margin-bottom: .2em; + font-size: 14px; +} + +td.column-title p, +td.plugin-title p { + margin: 6px 0; +} + +/* Media file column */ +table.media .column-title .media-icon { + float: left; + min-height: 60px; + margin: 0 9px 0 0; +} + +table.media .column-title .media-icon img { + max-width: 60px; + height: auto; + vertical-align: top; /* Remove descender white-space. */ +} + +table.media .column-title .has-media-icon ~ .row-actions { + margin-left: 70px; /* 60px image + margin */ +} + +table.media .column-title .filename { + margin-bottom: 0.2em; +} + +/* @todo: pick a consistent list table selector */ +.wp-list-table a { + transition: none; +} + +#the-list tr:last-child td, +#the-list tr:last-child th { + border-bottom: none !important; + box-shadow: none; +} + +#comments-form .fixed .column-author { + width: 20%; +} + +#comments-form .fixed .column-date { + width: 14%; +} + +#commentsdiv.postbox .inside { + margin: 0; + padding: 0; +} + +#commentsdiv .inside .row-actions { + line-height:18px; +} + +#commentsdiv .inside .column-author { + width: 25%; +} + +#commentsdiv .column-comment p { + margin: 0.6em 0; + padding: 0; +} + +#commentsdiv #replyrow td { + padding: 0; +} + +#commentsdiv p { + padding: 8px 10px; + margin: 0; +} + +#commentsdiv .comments-box { + border: 0 none; +} + +#commentsdiv .comments-box thead th, +#commentsdiv .comments-box thead td { + background: transparent; + padding: 0 7px 4px; + font-style: italic; +} + +#commentsdiv .comments-box tr:last-child td { + border-bottom: 0 none; +} + +#commentsdiv #edithead .inside input { + width: 160px; +} + +.sorting-indicator { + display: block; + visibility: hidden; + width: 10px; + height: 4px; + margin-top: 8px; + margin-left: 7px; +} + +.sorting-indicator:before { + content: "\f142"; + font: normal 20px/1 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: -4px; + left: -8px; + color: #444; + line-height: 10px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +.column-comments .sorting-indicator:before { + top: 0; + left: -10px; +} + +th.sorted.asc .sorting-indicator:before, +th.desc:hover span.sorting-indicator:before, +th.desc a:focus span.sorting-indicator:before { + content: "\f142"; +} + +th.sorted.desc .sorting-indicator:before, +th.asc:hover span.sorting-indicator:before, +th.asc a:focus span.sorting-indicator:before { + content: "\f140"; +} + +.wp-list-table .toggle-row { + position: absolute; + right: 8px; + top: 10px; + display: none; + padding: 0; + width: 40px; + height: 40px; + border: none; + outline: none; + background: transparent; +} + +.wp-list-table .toggle-row:hover { + cursor: pointer; +} + +.wp-list-table .toggle-row:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 .wp-list-table .toggle-row:focus:before { + outline: #5b9dd9 solid 1px; +} + +.wp-list-table .toggle-row:active { + box-shadow: none; +} + +.wp-list-table .toggle-row:before { + position: absolute; + top: -5px; + left: 10px; + border-radius: 50%; + display: block; + padding: 1px 2px 1px 0; + color: #444; /* same as table headers sort arrows */ + content: "\f140"; + font: normal 20px/1 dashicons; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + speak: none; +} + +.wp-list-table .is-expanded .toggle-row:before { + content: "\f142"; +} + +tr.wp-locked .locked-indicator { + margin-left: 6px; + height: 20px; + width: 16px; +} + +tr.wp-locked .locked-indicator-icon:before { + color: #82878c; + content: "\f160"; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +tr.wp-locked .check-column label, +tr.wp-locked .check-column input[type="checkbox"], +tr.wp-locked .row-actions .inline, +tr.wp-locked .row-actions .trash { + display: none; +} + +tr .locked-info { + height: 0; + opacity: 0; +} + +tr.wp-locked .locked-info { + margin-top: 4px; + height: auto; + opacity: 1; +} + +.locked-text { + vertical-align: top; +} + +tr.locked-info, tr.wp-locked .locked-info { + transition: height 1s, opacity 0.5s; +} + +.fixed .column-comments .sorting-indicator { + margin-top: 3px; +} + +#menu-locations-wrap .widefat { + width: 60%; +} + +.widefat th.sortable, +.widefat th.sorted { + padding: 0; +} + +th.sortable a, +th.sorted a { + display: block; + overflow: hidden; + padding: 8px; +} + +.fixed .column-comments.sortable a, +.fixed .column-comments.sorted a { + padding: 8px 0; +} + +th.sortable a span, +th.sorted a span { + float: left; + cursor: pointer; +} + +th.sorted .sorting-indicator, +th.desc:hover span.sorting-indicator, +th.desc a:focus span.sorting-indicator, +th.asc:hover span.sorting-indicator, +th.asc a:focus span.sorting-indicator { + visibility: visible; +} + +/* Bulk Actions */ +.tablenav-pages a, +.tablenav-pages-navspan { + font-weight: 600; + padding: 0 2px; +} + +.tablenav-pages .current-page { + margin: 0 2px 0 0; + padding-bottom: 5px; + font-size: 13px; + text-align: center; +} + +.tablenav .total-pages { + margin-right: 2px; +} + +.tablenav #table-paging { + margin-left: 2px; +} + +.tablenav a.button, +.tablenav a.button-secondary { + display: block; + margin: 3px 8px 0 0; +} + +.tablenav { + clear: both; + height: 30px; + margin: 6px 0 4px; + vertical-align: middle; +} + +.tablenav.themes { + max-width: 98%; +} + +.tablenav .tablenav-pages { + float: right; + height: 28px; + margin-top: 3px; + cursor: default; + color: #555; +} + +.tablenav .no-pages, +.tablenav .one-page .pagination-links { + display: none; +} + +.tablenav .tablenav-pages a, +.tablenav-pages span.current { + text-decoration: none; + padding: 3px 6px; +} + +.tablenav .tablenav-pages a, +.tablenav-pages-navspan { + display: inline-block; + min-width: 17px; + border: 1px solid #ccc; /* same color as buttons border */ + padding: 3px 5px 7px; + background: #e5e5e5; + font-size: 16px; + line-height: 1; + font-weight: 400; + text-align: center; +} + +.tablenav-pages-navspan { + height: 16px; + border-color: #ddd; /* same as disabled buttons */ + background: #f7f7f7; /* same as disabled buttons */ + color: #a0a5aa; /* same as disabled buttons */ +} + +.tablenav .tablenav-pages a:hover, +.tablenav .tablenav-pages a:focus { + border-color: #5b9dd9; + color: #fff; + background: #00a0d2; + box-shadow: none; + outline: none; /* IE8 */ +} + +.tablenav .displaying-num { + margin-right: 7px; +} + +.tablenav .one-page .displaying-num { + display: inline-block; + margin-top: 5px; + margin-right: 0; +} + +.tablenav .actions { + overflow: hidden; + padding: 2px 8px 0 0; +} + +.wp-filter .actions { + display: inline-block; + vertical-align: middle; +} + +.tablenav .delete { + margin-right: 20px; +} + +/* @todo: unclear if the following tablenav rules are actually used. +classes exist in paginate_links() but not seen in list table output. */ +.tablenav .dots { + border-color: transparent; +} + +.tablenav .next, +.tablenav .prev { + border-color: transparent; + color: #0073aa; +} + +.tablenav .next:hover, +.tablenav .prev:hover { + border-color: transparent; + color: #00a0d2; +} + +.tablenav .view-switch { + float: right; + margin: 0 5px; + padding-top: 3px; +} + +.wp-filter .view-switch { + display: inline-block; + vertical-align: middle; + padding: 12px 0; + margin: 0 8px 0 2px; +} + +.media-toolbar.wp-filter .view-switch { + margin: 0 12px 0 2px; +} + +.view-switch a { + float: left; + width: 28px; + height: 28px; + text-align: center; + line-height: 24px; + text-decoration: none; +} + +.view-switch a:before { + color: #b4b9be; + display: inline-block; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.view-switch a:hover:before, +.view-switch a:focus:before { + color: #727272; +} + +.view-switch a.current:before { + color: #0073aa; +} + +.view-switch .view-list:before { + content: "\f163"; +} + +.view-switch .view-excerpt:before { + content: "\f164"; +} + +.view-switch .view-grid:before { + content: "\f509"; +} + +.filter { + float: left; + margin: -5px 0 0 10px; +} + +.filter .subsubsub { + margin-left: -10px; + margin-top: 13px; +} +.screen-per-page { + width: 4em; +} + +#posts-filter .wp-filter { + margin-bottom: 0; +} + +#posts-filter fieldset { + float: left; + margin: 0 1.5ex 1em 0; + padding: 0; +} + +#posts-filter fieldset legend { + padding: 0 0 .2em 1px; +} + +p.pagenav { + margin: 0; + display: inline; +} + +.pagenav span { + font-weight: 600; + margin: 0 6px; +} + +.row-title { + font-size: 14px !important; + font-weight: 600; +} + +.column-comment .comment-author { + margin-bottom: 0.6em; +} + +.column-author img, +.column-username img, +.column-comment .comment-author img { + float: left; + margin-right: 10px; + margin-top: 1px; +} + +.row-actions { + color: #ddd; + font-size: 13px; + padding: 2px 0 0; + position: relative; + left: -9999em; +} + +/* ticket #34150 */ +.rtl .row-actions a { + display: inline-block; +} + +.row-actions .network_only, +.row-actions .network_active { + color: #000; +} + +.no-js .row-actions, +tr:hover .row-actions, +.mobile .row-actions, +.row-actions.visible, +.comment-item:hover .row-actions { + position: static; +} + +/* deprecated */ +.row-actions-visible { + padding: 2px 0 0; +} + + +/*------------------------------------------------------------------------------ + 10.1 - Inline Editing +------------------------------------------------------------------------------*/ + +/* +.quick-edit* is for Quick Edit +.bulk-edit* is for Bulk Edit +.inline-edit* is for everything +*/ + +/* Layout */ + +#wpbody-content .inline-edit-row fieldset { + font-size: 12px; + float: left; + margin: 0; + padding: 0; + width: 100%; +} + +tr.inline-edit-row td, +#wpbody-content .inline-edit-row fieldset .inline-edit-col { + padding: 0 0.5em; +} + +#wpbody-content .quick-edit-row-post .inline-edit-col-left { + width: 40%; +} + +#wpbody-content .quick-edit-row-post .inline-edit-col-right { + width: 39%; +} + +#wpbody-content .inline-edit-row-post .inline-edit-col-center { + width: 20%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-left { + width: 50%; +} + +#wpbody-content .quick-edit-row-page .inline-edit-col-right, +#wpbody-content .bulk-edit-row-post .inline-edit-col-right { + width: 49%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-left { + width: 30%; +} + +#wpbody-content .bulk-edit-row-page .inline-edit-col-right { + width: 69%; +} + +#wpbody-content .bulk-edit-row .inline-edit-col-bottom { + float: right; + width: 69%; +} + +#wpbody-content .inline-edit-row-page .inline-edit-col-right { + margin-top: 27px; +} + +.inline-edit-row fieldset .inline-edit-group { + clear: both; + line-height: 2.5; +} + +.inline-edit-row .submit { + clear: both; + padding: 0.5em; + margin: 0.5em 0 0; +} + +.inline-edit-row .notice-error { + margin-top: 1em; +} + +.inline-edit-row .notice-error .error { + margin: 0.5em 0; + padding: 2px; +} + +/* Positioning */ + +/* Needs higher specificity for the padding */ +#the-list .inline-edit-row .inline-edit-legend { + margin: 0; + padding: 0.2em 0.5em 0; + line-height: 2.5; + font-weight: 600; +} + +#the-list #bulk-edit.inline-edit-row .inline-edit-legend { + padding: 0.2em 0.5em; +} + +.inline-edit-row fieldset span.title, +.inline-edit-row fieldset span.checkbox-title { + margin: 0; + padding: 0; +} + +.inline-edit-row fieldset label, +.inline-edit-row fieldset span.inline-edit-categories-label { + display: block; + margin: .2em 0; + line-height: 2.5; +} + +.inline-edit-row fieldset.inline-edit-date label { + display: inline-block; + margin: 0; + line-height: 1.5; + vertical-align: baseline; +} + +.inline-edit-row fieldset label.inline-edit-tags { + margin-top: 0; +} + +.inline-edit-row fieldset label.inline-edit-tags span.title { + margin: .2em 0; + width: auto; +} + +.inline-edit-row fieldset label span.title, +.inline-edit-row fieldset.inline-edit-date legend { + display: block; + float: left; + width: 6em; + line-height: 2.5; +} + +#posts-filter fieldset.inline-edit-date legend { + padding: 0; +} + +.inline-edit-row fieldset.inline-edit-date select { + margin: 1px; + line-height: 28px; +} + +.inline-edit-row fieldset label span.input-text-wrap, +.inline-edit-row fieldset .timestamp-wrap { + display: block; + margin-left: 6em; +} + +.quick-edit-row-post fieldset.inline-edit-col-right label span.title { + width: auto; + padding-right: 0.5em; +} + +.inline-edit-row .inline-edit-or { + margin: .2em 6px .2em 0; + line-height: 2.5; +} + +.inline-edit-row .input-text-wrap input[type=text] { + width: 100%; +} + +.inline-edit-row fieldset label input[type=checkbox] { + vertical-align: middle; +} + +.inline-edit-row fieldset label textarea { + width: 100%; + height: 4em; + vertical-align: top; +} + +#wpbody-content .bulk-edit-row fieldset .inline-edit-group label { + max-width: 50%; +} + +#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child { + margin-right: 0.5em +} + +.inline-edit-col-right .input-text-wrap input.inline-edit-menu-order-input { + width: 6em; +} + +/* Styling */ +.inline-edit-row .inline-edit-legend { + text-transform: uppercase; +} + +.inline-edit-row fieldset span.title, +.inline-edit-row fieldset span.checkbox-title { + font-style: italic; +} + +/* Specific Elements */ +.inline-edit-row fieldset .inline-edit-date { + float: left; +} + +.inline-edit-row fieldset input[name=jj], +.inline-edit-row fieldset input[name=hh], +.inline-edit-row fieldset input[name=mn] { + font-size: 12px; + width: 2.3em; +} + +.inline-edit-row fieldset input[name=aa] { + font-size: 12px; + width: 3.5em; +} + +.inline-edit-row fieldset label input.inline-edit-password-input { + width: 8em; +} + +ul.cat-checklist { + height: 12em; + border: solid 1px #ddd; + overflow-y: scroll; + padding: 0 5px; + margin: 0; + background-color: #fff; +} + +#bulk-titles { + display: block; + height: 12em; + border: 1px solid #ddd; + overflow-y: scroll; + padding: 0 5px; + margin: 0 0 5px; +} + +.inline-edit-row fieldset ul.cat-checklist li, +.inline-edit-row fieldset ul.cat-checklist input { + margin: 0; + position: relative; /* RTL fix, #WP27629 */ +} + +.inline-edit-row fieldset ul.cat-checklist label, +.inline-edit-row #bulk-titles div { + font-style: normal; + font-size: 11px; +} + +.inline-edit-row fieldset label input.inline-edit-menu-order-input { + width: 3em; +} + +.inline-edit-row fieldset label input.inline-edit-slug-input { + width: 75%; +} + +.inline-edit-row #post_parent, +.inline-edit-row select[name="page_template"] { + max-width: 80%; +} + +.ie8 .inline-edit-row #post_parent, +.ie8 .inline-edit-row select[name="page_template"] { + width: 250px; +} + +.quick-edit-row-post fieldset label.inline-edit-status { + float: left; +} + +#bulk-titles { + line-height: 140%; +} +#bulk-titles div { + margin: 0.2em 0.3em; +} + +#bulk-titles div a { + cursor: pointer; + display: block; + float: left; + height: 18px; + margin: 0 3px 0 -2px; + overflow: hidden; + position: relative; + width: 20px; +} + +#bulk-titles div a:before { + position: relative; + top: -3px; +} + +/*------------------------------------------------------------------------------ + 17.0 - Plugins +------------------------------------------------------------------------------*/ + +.plugins tbody th.check-column, +.plugins tbody { + padding: 8px 0 0 2px; +} + +.plugins tbody th.check-column input[type=checkbox] { + margin-top: 4px; +} + +.updates-table .plugin-title p { + margin-top: 0; +} + +.plugins thead td.check-column, +.plugins tfoot td.check-column, +.plugins .inactive th.check-column { + padding-left: 6px; +} + +.plugins, +.plugins th, +.plugins td { + color: #000; +} + +.plugins tr { + background: #fff; +} + +.plugins p { + margin: 0 4px; + padding: 0; +} + +.plugins .desc p { + margin: 0 0 8px; +} + +.plugins td.desc { + line-height: 1.5em; +} + +.plugins .desc ul, +.plugins .desc ol { + margin: 0 0 0 2em; +} + +.plugins .desc ul { + list-style-type: disc; +} + +.plugins .row-actions { + font-size: 13px; + padding: 0; +} + +.plugins .inactive td, +.plugins .inactive th, +.plugins .active td, +.plugins .active th { + padding: 10px 9px; +} + +.plugins .active td, +.plugins .active th { + background-color: #f7fcfe; +} + +.plugins .update th, +.plugins .update td { + border-bottom: 0; +} + +.plugins .inactive td, +.plugins .inactive th, +.plugins .active td, +.plugins .active th, +.plugin-install #the-list td, +.upgrade .plugins td, +.upgrade .plugins th { + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); +} + +.plugins tr.active.plugin-update-tr + tr.inactive th, +.plugins tr.active.plugin-update-tr + tr.inactive td, +.plugins tr.active + tr.inactive th, +.plugins tr.active + tr.inactive td { + border-top: 1px solid rgba(0,0,0,0.03); + box-shadow: inset 0 1px 0 rgba(0,0,0,0.02), inset 0 -1px 0 #e1e1e1; +} + +.plugins .update td, +.plugins .update th, +.upgrade .plugins tr:last-of-type td, +.upgrade .plugins tr:last-of-type th, +.plugins tr.active + tr.inactive.update th, +.plugins tr.active + tr.inactive.update td, +.plugins .updated td, +.plugins .updated th, +.plugins tr.active + tr.inactive.updated th, +.plugins tr.active + tr.inactive.updated td { + box-shadow: none; +} + +.plugins .active th.check-column, +.plugin-update-tr.active td { + border-left: 4px solid #00a0d2; +} + +.wp-list-table.plugins .plugin-title, +.wp-list-table.plugins .theme-title { + padding-right: 12px; + white-space: nowrap; +} + +.plugins .plugin-title img, +.plugins .plugin-title .dashicons { + float: left; + padding: 0 10px 0 0; + width: 64px; + height: 64px; +} + +.plugins .plugin-title .dashicons:before { + padding: 2px; + background-color: #eee; + box-shadow: inset 0 0 10px rgba(160,165,170,.15); + font-size: 60px; + color: #B4B9BE; +} + +#update-themes-table .plugin-title img, +#update-themes-table .plugin-title .dashicons { + width: 85px; +} + +.plugins .inactive .plugin-title strong { + font-weight: 400; +} + +.plugins .second, +.plugins .row-actions { + padding: 0 0 5px; +} + +.plugins .update .second, +.plugins .update .row-actions, +.plugins .updated .second, +.plugins .updated .row-actions { + padding-bottom: 0; +} + +.plugins-php .widefat tfoot th, +.plugins-php .widefat tfoot td { + border-top-style: solid; + border-top-width: 1px; +} + +.plugins .plugin-update-tr .plugin-update { + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); + overflow: hidden; /* clearfix */ + padding: 0; +} + +.plugins .plugin-update-tr .notice, +.plugins .plugin-update-tr div[class="update-message"] { /* back-compat for pre-4.6 */ + margin: 5px 20px 15px 40px; +} + +.plugins .notice p { + margin: 0.5em 0; +} + +.plugin-card .update-now:before { + color: #f56e28; + content: "\f463"; + display: inline-block; + font: normal 20px/1 dashicons; + margin: 3px 5px 0 -2px; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.plugin-card .updating-message:before { + content: "\f463"; + -webkit-animation: rotation 2s infinite linear; + animation: rotation 2s infinite linear; +} + +@-webkit-keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} + +@keyframes rotation { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} + +.plugin-card .updated-message:before { + color: #79ba49; + content: "\f147"; +} + +.plugin-install-php h2 { + clear: both; +} + +.plugin-install-php h3 { + margin: 2.5em 0 8px; +} + +.plugin-install-php .wp-filter { + margin-bottom: 0; +} + +/* Plugin card table view */ +.plugin-group { + overflow: hidden; /* clearfix */ + margin-top: 1.5em; +} + +.plugin-group h3 { + margin-top: 0; +} + +.plugin-card { + float: left; + margin: 0 8px 16px; + width: 48.5%; + width: calc( 50% - 8px ); + background-color: #fff; + border: 1px solid #ddd; + box-sizing: border-box; +} + +.plugin-card:nth-child(odd) { + clear: both; + margin-left: 0; +} + +.plugin-card:nth-child(even) { + margin-right: 0; +} + +@media screen and ( min-width: 1600px ) { + .plugin-card { + width: 30%; + width: calc( 33.1% - 8px ); + } + + .plugin-card:nth-child(odd) { + clear: none; + margin-left: 8px; + } + + .plugin-card:nth-child(even) { + margin-right: 8px; + } + + .plugin-card:nth-child(3n+1) { + clear: both; + margin-left: 0; + } + + .plugin-card:nth-child(3n) { + margin-right: 0; + } +} + +.plugin-card-top { + position: relative; + padding: 20px 20px 10px; + min-height: 135px; +} + +div.action-links, +.plugin-action-buttons { + margin: 0; /* Override existing margins */ +} + +.plugin-card h3 { + margin: 0 0 12px; + font-size: 18px; + line-height: 1.3; +} + +.plugin-card .name, +.plugin-card .desc { + margin-left: 148px; /* icon + margin */ + margin-right: 120px; /* action links */ +} + +.plugin-card .action-links { + position: absolute; + top: 20px; + right: 20px; + width: 120px; +} + +.plugin-action-buttons { + clear: right; + float: right; + margin-left: 2em; + margin-bottom: 1em; + text-align: right; +} + +.plugin-action-buttons li { + margin-bottom: 10px; +} + +.plugin-card-bottom { + clear: both; + padding: 12px 20px; + background-color: #fafafa; + border-top: 1px solid #ddd; + overflow: hidden; +} + +.plugin-card-bottom .star-rating { + display: inline; +} + +.plugin-card-update-failed .update-now { + font-weight: 600; +} + +.plugin-card-update-failed .notice-error { + margin: 0; + padding-left: 16px; + box-shadow: 0 -1px 0 #ddd; +} + +.plugin-card-update-failed .plugin-card-bottom { + display: none; +} + +.plugin-card .column-rating { + line-height: 23px; +} + +.plugin-card .column-rating, +.plugin-card .column-updated { + margin-bottom: 4px; +} + +.plugin-card .column-rating, +.plugin-card .column-downloaded { + float: left; + clear: left; + max-width: 180px; +} + +.plugin-card .column-updated, +.plugin-card .column-compatibility { + text-align: right; + float: right; + clear: right; + width: 65%; + width: calc( 100% - 180px ); +} + +.plugin-card .column-compatibility span:before { + font: normal 20px/.5 dashicons; + speak: none; + display: inline-block; + padding: 0; + top: 4px; + left: -2px; + position: relative; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + text-decoration: none !important; + color: #444; +} + +.plugin-card .compatibility-incompatible:before { + content: "\f158"; +} + +.plugin-card .compatibility-compatible:before { + content: "\f147"; +} + +.plugin-icon { + position: absolute; + top: 20px; + left: 20px; + width: 128px; + height: 128px; + margin: 0 20px 20px 0; +} + +.no-plugin-results { + color: #666; /* same as no themes and no media */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0 0; + text-align: center; +} + +/* ms */ +/* Background Color for Site Status */ +.wp-list-table .site-deleted, +.wp-list-table tr.site-deleted { + background: #ff8573; +} +.wp-list-table .site-spammed, +.wp-list-table tr.site-spammed { + background: #faafaa; +} +.wp-list-table .site-archived, +.wp-list-table tr.site-archived { + background: #ffebe8; +} +.wp-list-table .site-mature, +.wp-list-table tr.site-mature { + background: #fecac2; +} + +.sites.fixed .column-lastupdated, +.sites.fixed .column-registered { + width: 20%; +} + +.sites.fixed .column-users { + width: 80px; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and ( max-width: 1100px ) and ( min-width: 782px ), ( max-width: 480px ) { + .plugin-card .action-links { + position: static; + margin-left: 148px; + width: auto; + } + + .plugin-action-buttons { + float: none; + margin: 1em 0 0; + text-align: left; + } + + .plugin-action-buttons li { + display: inline-block; + vertical-align: middle; + } + + .plugin-action-buttons li .button { + margin-right: 20px; + } + + .plugin-card .name, + .plugin-card .desc { + margin-right: 0; + } + + .plugin-card .desc p:first-of-type { + margin-top: 0; + } + + .fixed .column-date { + width: 14%; + } +} + +@media screen and ( max-width: 782px ) { + /* WP List Table Options & Filters */ + .tablenav { + height: auto; + } + + .tablenav.top { + margin: 20px 0 5px 0; + } + + .tablenav.bottom { + position: relative; + margin-top: 15px; + } + + .tablenav br { + display: none; + } + + .tablenav br.clear { + display: block; + } + + .tablenav.top .actions, + .tablenav .view-switch { + display: none; + } + + .view-switch a { + width: 36px; + height: 36px; + line-height: 33px; + } + + /* Pagination */ + .tablenav.top .displaying-num { + display: none; + } + + .tablenav.bottom .displaying-num { + position: absolute; + right: 0; + top: 11px; + margin: 0; + font-size: 14px; + } + + .tablenav .tablenav-pages { + width: 100%; + height: auto; + text-align: center; + margin: 0 0 25px; + } + + .tablenav.bottom .tablenav-pages { + margin-top: 25px; + } + + .tablenav.top .tablenav-pages.one-page { + display: none; + } + + .tablenav.bottom .tablenav-pages.one-page { + margin: 15px 0 0 0; + height: 0; + } + + .tablenav-pages .pagination-links { + font-size: 16px; + } + + .tablenav-pages .pagination-links a, + .tablenav-pages-navspan { + padding: 9px 11px 12px; + font-size: 18px; + } + + .tablenav-pages-navspan { + height: 18px; + } + + .tablenav-pages .pagination-links .current-page { + padding: 8px 9px 9px; + font-size: 16px; + } + + /* WP List Table Adjustments: General */ + .form-wrap > p { + display: none; + } + + .comment-count { + font-size: 14px; + } + + .wp-list-table th.column-primary ~ th, + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary ~ td:not(.check-column) { + display: none; + } + + .wp-list-table thead th.column-primary { + width: 100%; + } + + /* Checkboxes need to show */ + .wp-list-table tr th.check-column { + display: table-cell; + width: 35px; + } + + .wp-list-table .column-primary .toggle-row { + display: block; + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column) { + position: relative; + clear: both; + display: block; + width: auto !important; /* needs to override some columns that are more specifically targeted */ + } + + .wp-list-table td.column-primary { + padding-right: 50px; /* space for toggle button */ + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary ~ td:not(.check-column) { + padding: 3px 8px 3px 35%; + } + + .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.column-primary)::before { + position: absolute; + left: 10px; /* match padding of regular table cell */ + display: block; + overflow: hidden; + width: 32%; /* leave a little space for a gutter */ + content: attr(data-colname); + white-space: nowrap; + text-overflow: ellipsis; + } + + .wp-list-table .is-expanded td:not(.hidden) { + display: block !important; + overflow: hidden; /* clearfix */ + } + + /* Special cases */ + .widefat .num, + .column-posts { + text-align: left; + } + + #comments-form .fixed .column-author, + #commentsdiv .fixed .column-author { + display: none !important; + } + + .fixed .column-comment .comment-author { + display: block; + } + + #the-comment-list .is-expanded td { + box-shadow: none; + } + + #the-comment-list .is-expanded td:last-child { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); + } + + /* Show comment bubble as text instead */ + .post-com-count .screen-reader-text { + position: static; + -webkit-clip-path: none; + clip-path: none; + width: auto; + height: auto; + margin: 0; + } + + .column-response .post-com-count-no-comments:after, + .column-response .post-com-count-approved:after, + .column-comments .post-com-count-no-comments:after, + .column-comments .post-com-count-approved:after { + content: none; + } + + .column-response .post-com-count [aria-hidden="true"], + .column-comments .post-com-count [aria-hidden="true"] { + display: none; + } + + .column-response .post-com-count-wrapper, + .column-comments .post-com-count-wrapper { + white-space: normal; + } + + .column-response .post-com-count-wrapper > a, + .column-comments .post-com-count-wrapper > a { + display: block; + } + + .column-response .post-com-count-no-comments, + .column-response .post-com-count-approved, + .column-comments .post-com-count-no-comments, + .column-comments .post-com-count-approved { + margin-top: 0; + margin-right: 0.5em; + } + + .column-response .post-com-count-pending, + .column-comments .post-com-count-pending { + position: static; + height: auto; + min-width: 0; + padding: 0; + border: none; + border-radius: 0; + background: none; + color: #bb2a2a; + font-size: inherit; + line-height: inherit; + text-align: left; + } + + .column-response .post-com-count-pending:hover, + .column-comments .post-com-count-pending:hover { + color: #dc3232; + } + + .widefat thead td.check-column, + .widefat tfoot td.check-column { + padding-top: 10px; + } + + .widefat * { + word-wrap: normal; + } + + /* Quick Edit and Bulk Edit */ + #wpbody-content .quick-edit-row-post .inline-edit-col-left, + #wpbody-content .quick-edit-row-post .inline-edit-col-right, + #wpbody-content .inline-edit-row-post .inline-edit-col-center, + #wpbody-content .quick-edit-row-page .inline-edit-col-left, + #wpbody-content .quick-edit-row-page .inline-edit-col-right, + #wpbody-content .bulk-edit-row-post .inline-edit-col-right, + #wpbody-content .bulk-edit-row .inline-edit-col-left, + #wpbody-content .bulk-edit-row-page .inline-edit-col-right, + #wpbody-content .bulk-edit-row .inline-edit-col-bottom { + float: none; + width: 100%; + } + + #wpbody-content .quick-edit-row fieldset .inline-edit-col label, + #wpbody-content .quick-edit-row fieldset .inline-edit-group label, + #wpbody-content .bulk-edit-row fieldset .inline-edit-col label, + #wpbody-content .bulk-edit-row fieldset .inline-edit-group label { + max-width: none; + float: none; + margin-bottom: 5px; + } + + #wpbody .bulk-edit-row fieldset select { + display: block; + width: 100%; + max-width: none; + box-sizing: border-box; + } + + .inline-edit-row fieldset ul.cat-checklist label, + .inline-edit-row #bulk-titles div { + font-size: 16px; + } + + .inline-edit-row fieldset label span.title, + .inline-edit-row fieldset.inline-edit-date legend { + float: none; + } + + .inline-edit-row fieldset label.inline-edit-tags { + padding: 0 0.5em; + } + + .inline-edit-row fieldset .inline-edit-col label.inline-edit-tags { + padding: 0; + } + + .inline-edit-row fieldset label span.input-text-wrap, + .inline-edit-row fieldset .timestamp-wrap { + margin-left: 0; + } + + .inline-edit-row fieldset input[name=jj], + .inline-edit-row fieldset input[name=hh], + .inline-edit-row fieldset input[name=mn] { + width: 3em; + } + + .inline-edit-row fieldset input[name=aa] { + width: 4.5em; + } + + .inline-edit-row .inline-edit-or { + margin: 0 6px 0 0; + } + + #edithead .inside, + #commentsdiv #edithead .inside { + float: none; + text-align: left; + padding: 3px 5px; + } + + #commentsdiv #edithead .inside input, + #edithead .inside input { + width: 100%; + } + + #edithead label { + display: block; + } + + #bulk-titles div { + margin: 0.8em 0.3em; + } + + #bulk-titles div a { + height: 22px; + } + + /* Updates */ + #wpbody-content .updates-table .plugin-title { + width: auto; + white-space: normal; + } + + /* Links */ + .link-manager-php #posts-filter { + margin-top: 25px; + } + + .link-manager-php .tablenav.bottom { + overflow: hidden; + } + + /* List tables that don't toggle rows */ + .comments-box .toggle-row, + .wp-list-table.plugins .toggle-row { + display: none; + } + + /* Plugin/Theme Management */ + #wpbody-content .wp-list-table.plugins td { + display: block; + width: auto; + padding: 10px 9px; /* reset from other list tables that have a label at this width */ + } + + #wpbody-content .wp-list-table.plugins .column-description { + padding-top: 2px; + } + + #wpbody-content .wp-list-table.plugins .plugin-title, + #wpbody-content .wp-list-table.plugins .theme-title { + padding-right: 12px; + white-space: normal; + } + + .wp-list-table.plugins .plugin-title, + .wp-list-table.plugins .theme-title { + padding-top: 13px; + padding-bottom: 4px; + } + + .plugins #the-list tr > td:not(:last-child), + .plugins #the-list .update th, + .plugins #the-list .update td, + .wp-list-table.plugins #the-list .theme-title { + box-shadow: none; + border-top: none; + } + + .plugins #the-list tr td { + border-top: none; + } + + .plugins tbody { + padding: 1px 0 0; + } + + .plugins tr.active + tr.inactive th.check-column, + .plugins tr.active + tr.inactive td.column-description, + .plugins .plugin-update-tr:before { + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1); + } + + .plugins tr.active + tr.inactive th.check-column, + .plugins tr.active + tr.inactive td { + border-top: none; + } + + /* mimic the checkbox th */ + .plugins .plugin-update-tr:before { + content: ""; + display: table-cell; + } + + .plugins .active.update + .plugin-update-tr:before { + border-left: 4px solid #d54e21; + background-color: #fef7f1; + } + + .plugins #the-list .plugin-update-tr .plugin-update { + border-left: none; + } + + .plugin-update-tr .update-message { + margin-left: 0; + } + + .plugins .active.update + .plugin-update-tr:before { + background-color: #f7fcfe; + border-left: 4px solid #00a0d2; + } + + .plugins .plugin-update-tr .update-message { + margin-left: 0; + } + + .wp-list-table.plugins .plugin-title strong, + .wp-list-table.plugins .theme-title strong { + font-size: 1.4em; + line-height: 1.5; + } + + /* Add New plugins page */ + table.plugin-install .column-name, + table.plugin-install .column-version, + table.plugin-install .column-rating, + table.plugin-install .column-description { + display: block; + width: auto; + } + + table.plugin-install th.column-name, + table.plugin-install th.column-version, + table.plugin-install th.column-rating, + table.plugin-install th.column-description { + display: none; + } + + table.plugin-install td.column-name strong { + font-size: 1.4em; + line-height: 1.6em; + } + + table.plugin-install #the-list td { + box-shadow: none; + } + + table.plugin-install #the-list tr { + display: block; + box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1); + } + + .plugin-card { + margin-left: 0; + margin-right: 0; + width: 100%; + } +} + +@media screen and ( max-width: 480px ) { + .tablenav-pages .current-page { + margin: 0; + } + + .tablenav-pages .tablenav-paging-text { + float: left; + width: 100%; + padding-top: 0.5em; + } +} diff --git a/backend/wp-admin/css/list-tables.min.css b/backend/wp-admin/css/list-tables.min.css new file mode 100644 index 0000000..821d57f --- /dev/null +++ b/backend/wp-admin/css/list-tables.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.response-links{display:block;margin-bottom:1em}.response-links a{display:block}.response-links a.comments-edit-item-link{font-weight:600}.response-links a.comments-view-item-link{font-size:12px}.post-com-count-wrapper strong{font-weight:400}.comments-view-item-link{display:inline-block;clear:both}.column-comments .post-com-count-wrapper,.column-response .post-com-count-wrapper{white-space:nowrap;word-wrap:normal}.column-comments .post-com-count,.column-response .post-com-count{display:inline-block;vertical-align:top}.column-comments .post-com-count-approved,.column-comments .post-com-count-no-comments,.column-response .post-com-count-approved,.column-response .post-com-count-no-comments{margin-top:5px}.column-comments .comment-count-approved,.column-comments .comment-count-no-comments,.column-response .comment-count-approved,.column-response .comment-count-no-comments{box-sizing:border-box;display:block;padding:0 8px;min-width:24px;height:2em;border-radius:5px;background-color:#72777c;color:#fff;font-size:11px;line-height:21px;text-align:center}.ie8 .column-comments .comment-count-approved,.ie8 .column-comments .comment-count-no-comments,.ie8 .column-response .comment-count-approved,.ie8 .column-response .comment-count-no-comments{min-width:0}.column-comments .post-com-count-approved:after,.column-comments .post-com-count-no-comments:after,.column-response .post-com-count-approved:after,.column-response .post-com-count-no-comments:after{content:"";display:block;margin-left:8px;width:0;height:0;border-top:5px solid #72777c;border-right:5px solid transparent}.column-comments .post-com-count-approved:focus .comment-count-approved,.column-comments .post-com-count-approved:hover .comment-count-approved,.column-response .post-com-count-approved:focus .comment-count-approved,.column-response .post-com-count-approved:hover .comment-count-approved{background:#0073aa}.column-comments .post-com-count-approved:focus:after,.column-comments .post-com-count-approved:hover:after,.column-response .post-com-count-approved:focus:after,.column-response .post-com-count-approved:hover:after{border-top-color:#0073aa}.column-comments .post-com-count-pending,.column-response .post-com-count-pending{position:relative;left:-3px;padding:0 5px;min-width:7px;height:17px;border:2px solid #fff;border-radius:11px;background:#ca4a1f;color:#fff;font-size:9px;line-height:17px;text-align:center}.column-comments .post-com-count-no-pending,.column-response .post-com-count-no-pending{display:none}.commentlist li{padding:1em 1em .2em;margin:0;border-bottom:1px solid #ccc}.commentlist li li{border-bottom:0;padding:0}.commentlist p{padding:0;margin:0 0 .8em}#submitted-on,.submitted-on{color:#555d66}#replyrow td{padding:2px}#replysubmit{margin:0;padding:5px 7px 10px;overflow:hidden}#replysubmit .button{margin-right:5px}#replyrow.inline-edit-row fieldset.comment-reply{font-size:inherit;line-height:inherit}#replyrow legend{margin:0;padding:.2em 5px 0;font-size:13px;line-height:1.4;font-weight:600}#replyrow.inline-edit-row label{display:inline;vertical-align:baseline;line-height:inherit}#commentsdiv #edithead .inside,#edithead .inside{float:left;padding:3px 0 2px 5px;margin:0;text-align:center}#edithead .inside input{width:180px}#edithead label{padding:2px 0}#replycontainer{padding:5px}#replycontent{height:120px;box-shadow:none}#replyerror{border-color:#ddd;background-color:#f9f9f9}.commentlist .avatar{vertical-align:text-top}#the-comment-list div.undo,#the-comment-list tr.undo{background-color:#f5f5f5}#the-comment-list .unapproved td,#the-comment-list .unapproved th{background-color:#fef7f1}#the-comment-list .unapproved th.check-column{border-left:4px solid #d54e21}#the-comment-list .unapproved th.check-column input{margin-left:4px}#the-comment-list .approve a{color:#006505}#the-comment-list .unapprove a{color:#d98500}#the-comment-list td,#the-comment-list th{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}#the-comment-list tr:last-child td,#the-comment-list tr:last-child th{box-shadow:none}#the-comment-list tr.unapproved+tr.approved td,#the-comment-list tr.unapproved+tr.approved th{border-top:1px solid rgba(0,0,0,.03)}.vim-current,.vim-current td,.vim-current th{background-color:#e4f2fd!important}th .comment-grey-bubble{height:16px;width:16px}th .comment-grey-bubble:before{content:"\f101";font:400 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;left:-4px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}table.fixed{table-layout:fixed}.fixed .column-rating,.fixed .column-visible{width:8%}.fixed .column-author,.fixed .column-date,.fixed .column-format,.fixed .column-links,.fixed .column-parent,.fixed .column-posts{width:10%}.fixed .column-posts{width:74px}.fixed .column-comment .comment-author{display:none}.fixed .column-categories,.fixed .column-rel,.fixed .column-response,.fixed .column-role,.fixed .column-tags{width:15%}.fixed .column-slug{width:25%}.fixed .column-locations{width:35%}.fixed .column-comments{width:5.5em;padding:8px 0;text-align:left}.fixed .column-comments .vers{padding-left:3px}td.column-title strong,td.plugin-title strong{display:block;margin-bottom:.2em;font-size:14px}td.column-title p,td.plugin-title p{margin:6px 0}table.media .column-title .media-icon{float:left;min-height:60px;margin:0 9px 0 0}table.media .column-title .media-icon img{max-width:60px;height:auto;vertical-align:top}table.media .column-title .has-media-icon~.row-actions{margin-left:70px}table.media .column-title .filename{margin-bottom:.2em}.wp-list-table a{transition:none}#the-list tr:last-child td,#the-list tr:last-child th{border-bottom:none!important;box-shadow:none}#comments-form .fixed .column-author{width:20%}#comments-form .fixed .column-date{width:14%}#commentsdiv.postbox .inside{margin:0;padding:0}#commentsdiv .inside .row-actions{line-height:18px}#commentsdiv .inside .column-author{width:25%}#commentsdiv .column-comment p{margin:.6em 0;padding:0}#commentsdiv #replyrow td{padding:0}#commentsdiv p{padding:8px 10px;margin:0}#commentsdiv .comments-box{border:0}#commentsdiv .comments-box thead td,#commentsdiv .comments-box thead th{background:0 0;padding:0 7px 4px;font-style:italic}#commentsdiv .comments-box tr:last-child td{border-bottom:0 none}#commentsdiv #edithead .inside input{width:160px}.sorting-indicator{display:block;visibility:hidden;width:10px;height:4px;margin-top:8px;margin-left:7px}.sorting-indicator:before{content:"\f142";font:400 20px/1 dashicons;speak:none;display:inline-block;padding:0;top:-4px;left:-8px;line-height:10px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}.column-comments .sorting-indicator:before{top:0;left:-10px}th.desc a:focus span.sorting-indicator:before,th.desc:hover span.sorting-indicator:before,th.sorted.asc .sorting-indicator:before{content:"\f142"}th.asc a:focus span.sorting-indicator:before,th.asc:hover span.sorting-indicator:before,th.sorted.desc .sorting-indicator:before{content:"\f140"}.wp-list-table .toggle-row{position:absolute;right:8px;top:10px;display:none;padding:0;width:40px;height:40px;border:none;outline:0;background:0 0}.wp-list-table .toggle-row:hover{cursor:pointer}.wp-list-table .toggle-row:focus:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 .wp-list-table .toggle-row:focus:before{outline:#5b9dd9 solid 1px}.wp-list-table .toggle-row:active{box-shadow:none}.wp-list-table .toggle-row:before{position:absolute;top:-5px;left:10px;border-radius:50%;display:block;padding:1px 2px 1px 0;color:#444;content:"\f140";font:400 20px/1 dashicons;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.wp-list-table .is-expanded .toggle-row:before{content:"\f142"}tr.wp-locked .locked-indicator{margin-left:6px;height:20px;width:16px}tr.wp-locked .locked-indicator-icon:before{color:#82878c;content:"\f160";display:inline-block;font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}tr.wp-locked .check-column input[type=checkbox],tr.wp-locked .check-column label,tr.wp-locked .row-actions .inline,tr.wp-locked .row-actions .trash{display:none}tr .locked-info{height:0;opacity:0}tr.wp-locked .locked-info{margin-top:4px;height:auto;opacity:1}.locked-text{vertical-align:top}tr.locked-info,tr.wp-locked .locked-info{transition:height 1s,opacity .5s}.fixed .column-comments .sorting-indicator{margin-top:3px}#menu-locations-wrap .widefat{width:60%}.widefat th.sortable,.widefat th.sorted{padding:0}th.sortable a,th.sorted a{display:block;overflow:hidden;padding:8px}.fixed .column-comments.sortable a,.fixed .column-comments.sorted a{padding:8px 0}th.sortable a span,th.sorted a span{float:left;cursor:pointer}th.asc a:focus span.sorting-indicator,th.asc:hover span.sorting-indicator,th.desc a:focus span.sorting-indicator,th.desc:hover span.sorting-indicator,th.sorted .sorting-indicator{visibility:visible}.tablenav-pages a,.tablenav-pages-navspan{font-weight:600;padding:0 2px}.tablenav-pages .current-page{margin:0 2px 0 0;padding-bottom:5px;font-size:13px;text-align:center}.tablenav .total-pages{margin-right:2px}.tablenav #table-paging{margin-left:2px}.tablenav a.button,.tablenav a.button-secondary{display:block;margin:3px 8px 0 0}.tablenav{clear:both;height:30px;margin:6px 0 4px;vertical-align:middle}.tablenav.themes{max-width:98%}.tablenav .tablenav-pages{float:right;height:28px;margin-top:3px;cursor:default;color:#555}.tablenav .no-pages,.tablenav .one-page .pagination-links{display:none}.tablenav .tablenav-pages a,.tablenav-pages span.current{text-decoration:none;padding:3px 6px}.tablenav .tablenav-pages a,.tablenav-pages-navspan{display:inline-block;min-width:17px;border:1px solid #ccc;padding:3px 5px 7px;background:#e5e5e5;font-size:16px;line-height:1;font-weight:400;text-align:center}.tablenav-pages-navspan{height:16px;border-color:#ddd;background:#f7f7f7;color:#a0a5aa}.tablenav .tablenav-pages a:focus,.tablenav .tablenav-pages a:hover{border-color:#5b9dd9;color:#fff;background:#00a0d2;box-shadow:none;outline:0}.tablenav .displaying-num{margin-right:7px}.tablenav .one-page .displaying-num{display:inline-block;margin-top:5px;margin-right:0}.tablenav .actions{overflow:hidden;padding:2px 8px 0 0}.wp-filter .actions{display:inline-block;vertical-align:middle}.tablenav .delete{margin-right:20px}.tablenav .dots{border-color:transparent}.tablenav .next,.tablenav .prev{border-color:transparent;color:#0073aa}.tablenav .next:hover,.tablenav .prev:hover{border-color:transparent;color:#00a0d2}.tablenav .view-switch{float:right;margin:0 5px;padding-top:3px}.wp-filter .view-switch{display:inline-block;vertical-align:middle;padding:12px 0;margin:0 8px 0 2px}.media-toolbar.wp-filter .view-switch{margin:0 12px 0 2px}.view-switch a{float:left;width:28px;height:28px;text-align:center;line-height:24px;text-decoration:none}.view-switch a:before{color:#b4b9be;display:inline-block;font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.view-switch a:focus:before,.view-switch a:hover:before{color:#727272}.view-switch a.current:before{color:#0073aa}.view-switch .view-list:before{content:"\f163"}.view-switch .view-excerpt:before{content:"\f164"}.view-switch .view-grid:before{content:"\f509"}.filter{float:left;margin:-5px 0 0 10px}.filter .subsubsub{margin-left:-10px;margin-top:13px}.screen-per-page{width:4em}#posts-filter .wp-filter{margin-bottom:0}#posts-filter fieldset{float:left;margin:0 1.5ex 1em 0;padding:0}#posts-filter fieldset legend{padding:0 0 .2em 1px}.row-actions,.row-actions-visible{padding:2px 0 0}p.pagenav{margin:0;display:inline}.pagenav span{font-weight:600;margin:0 6px}.row-title{font-size:14px!important;font-weight:600}.column-comment .comment-author{margin-bottom:.6em}.column-author img,.column-comment .comment-author img,.column-username img{float:left;margin-right:10px;margin-top:1px}.row-actions{color:#ddd;font-size:13px;position:relative;left:-9999em}.plugins,.plugins td,.plugins th,.row-actions .network_active,.row-actions .network_only{color:#000}.rtl .row-actions a{display:inline-block}.comment-item:hover .row-actions,.mobile .row-actions,.no-js .row-actions,.row-actions.visible,tr:hover .row-actions{position:static}#wpbody-content .inline-edit-row fieldset{font-size:12px;float:left;margin:0;padding:0;width:100%}#wpbody-content .inline-edit-row fieldset .inline-edit-col,tr.inline-edit-row td{padding:0 .5em}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:40%}#wpbody-content .quick-edit-row-post .inline-edit-col-right{width:39%}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:20%}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:50%}#wpbody-content .bulk-edit-row-post .inline-edit-col-right,#wpbody-content .quick-edit-row-page .inline-edit-col-right{width:49%}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:30%}#wpbody-content .bulk-edit-row-page .inline-edit-col-right{width:69%}#wpbody-content .bulk-edit-row .inline-edit-col-bottom{float:right;width:69%}#wpbody-content .inline-edit-row-page .inline-edit-col-right{margin-top:27px}.inline-edit-row fieldset .inline-edit-group{clear:both;line-height:2.5}.inline-edit-row .submit{clear:both;padding:.5em;margin:.5em 0 0}.inline-edit-row .notice-error{margin-top:1em}.inline-edit-row .notice-error .error{margin:.5em 0;padding:2px}#the-list .inline-edit-row .inline-edit-legend{margin:0;padding:.2em .5em 0;line-height:2.5;font-weight:600}#the-list #bulk-edit.inline-edit-row .inline-edit-legend{padding:.2em .5em}.inline-edit-row fieldset span.checkbox-title,.inline-edit-row fieldset span.title{margin:0;padding:0;font-style:italic}.inline-edit-row fieldset label,.inline-edit-row fieldset span.inline-edit-categories-label{display:block;margin:.2em 0;line-height:2.5}.inline-edit-row fieldset.inline-edit-date label{display:inline-block;margin:0;line-height:1.5;vertical-align:baseline}.inline-edit-row fieldset label.inline-edit-tags{margin-top:0}.inline-edit-row fieldset label.inline-edit-tags span.title{margin:.2em 0;width:auto}.inline-edit-row fieldset label span.title,.inline-edit-row fieldset.inline-edit-date legend{display:block;float:left;width:6em;line-height:2.5}#posts-filter fieldset.inline-edit-date legend{padding:0}.inline-edit-row fieldset.inline-edit-date select{margin:1px;line-height:28px}.inline-edit-row fieldset .timestamp-wrap,.inline-edit-row fieldset label span.input-text-wrap{display:block;margin-left:6em}.quick-edit-row-post fieldset.inline-edit-col-right label span.title{width:auto;padding-right:.5em}.inline-edit-row .inline-edit-or{margin:.2em 6px .2em 0;line-height:2.5}.inline-edit-row .input-text-wrap input[type=text]{width:100%}.inline-edit-row fieldset label input[type=checkbox]{vertical-align:middle}.inline-edit-row fieldset label textarea{width:100%;height:4em;vertical-align:top}#bulk-titles,ul.cat-checklist{height:12em;border:1px solid #ddd;overflow-y:scroll;padding:0 5px}#wpbody-content .bulk-edit-row fieldset .inline-edit-group label{max-width:50%}#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child{margin-right:.5em}.inline-edit-col-right .input-text-wrap input.inline-edit-menu-order-input{width:6em}.inline-edit-row .inline-edit-legend{text-transform:uppercase}.inline-edit-row fieldset .inline-edit-date{float:left}.inline-edit-row fieldset input[name=hh],.inline-edit-row fieldset input[name=jj],.inline-edit-row fieldset input[name=mn]{font-size:12px;width:2.3em}.inline-edit-row fieldset input[name=aa]{font-size:12px;width:3.5em}.inline-edit-row fieldset label input.inline-edit-password-input{width:8em}ul.cat-checklist{margin:0;background-color:#fff}#bulk-titles{display:block;margin:0 0 5px;line-height:140%}.inline-edit-row fieldset ul.cat-checklist input,.inline-edit-row fieldset ul.cat-checklist li{margin:0;position:relative}.inline-edit-row #bulk-titles div,.inline-edit-row fieldset ul.cat-checklist label{font-style:normal;font-size:11px}.inline-edit-row fieldset label input.inline-edit-menu-order-input{width:3em}.inline-edit-row fieldset label input.inline-edit-slug-input{width:75%}.inline-edit-row #post_parent,.inline-edit-row select[name=page_template]{max-width:80%}.ie8 .inline-edit-row #post_parent,.ie8 .inline-edit-row select[name=page_template]{width:250px}.quick-edit-row-post fieldset label.inline-edit-status{float:left}#bulk-titles div{margin:.2em .3em}#bulk-titles div a{cursor:pointer;display:block;float:left;height:18px;margin:0 3px 0 -2px;overflow:hidden;position:relative;width:20px}#bulk-titles div a:before{position:relative;top:-3px}.plugins tbody,.plugins tbody th.check-column{padding:8px 0 0 2px}.plugins tbody th.check-column input[type=checkbox]{margin-top:4px}.updates-table .plugin-title p{margin-top:0}.plugins .inactive th.check-column,.plugins tfoot td.check-column,.plugins thead td.check-column{padding-left:6px}.plugins tr{background:#fff}.plugins p{margin:0 4px;padding:0}.plugins .desc p{margin:0 0 8px}.plugins td.desc{line-height:1.5em}.plugins .desc ol,.plugins .desc ul{margin:0 0 0 2em}.plugins .desc ul{list-style-type:disc}.plugins .row-actions{font-size:13px}.plugins .active td,.plugins .active th,.plugins .inactive td,.plugins .inactive th{padding:10px 9px}.plugins .active td,.plugins .active th{background-color:#f7fcfe}.plugins .update td,.plugins .update th{border-bottom:0}.plugin-install #the-list td,.plugins .active td,.plugins .active th,.plugins .inactive td,.plugins .inactive th,.upgrade .plugins td,.upgrade .plugins th{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugins tr.active+tr.inactive td,.plugins tr.active+tr.inactive th,.plugins tr.active.plugin-update-tr+tr.inactive td,.plugins tr.active.plugin-update-tr+tr.inactive th{border-top:1px solid rgba(0,0,0,.03);box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1}.plugins .update td,.plugins .update th,.plugins .updated td,.plugins .updated th,.plugins tr.active+tr.inactive.update td,.plugins tr.active+tr.inactive.update th,.plugins tr.active+tr.inactive.updated td,.plugins tr.active+tr.inactive.updated th,.upgrade .plugins tr:last-of-type td,.upgrade .plugins tr:last-of-type th{box-shadow:none}.plugin-update-tr.active td,.plugins .active th.check-column{border-left:4px solid #00a0d2}.wp-list-table.plugins .plugin-title,.wp-list-table.plugins .theme-title{padding-right:12px;white-space:nowrap}.plugins .plugin-title .dashicons,.plugins .plugin-title img{float:left;padding:0 10px 0 0;width:64px;height:64px}.plugins .plugin-title .dashicons:before{padding:2px;background-color:#eee;box-shadow:inset 0 0 10px rgba(160,165,170,.15);font-size:60px;color:#B4B9BE}#update-themes-table .plugin-title .dashicons,#update-themes-table .plugin-title img{width:85px}.plugins .inactive .plugin-title strong{font-weight:400}.plugins .row-actions,.plugins .second{padding:0 0 5px}.plugins .update .row-actions,.plugins .update .second,.plugins .updated .row-actions,.plugins .updated .second{padding-bottom:0}.plugins-php .widefat tfoot td,.plugins-php .widefat tfoot th{border-top-style:solid;border-top-width:1px}.plugins .plugin-update-tr .plugin-update{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);overflow:hidden;padding:0}.plugins .plugin-update-tr .notice,.plugins .plugin-update-tr div[class=update-message]{margin:5px 20px 15px 40px}.plugins .notice p{margin:.5em 0}.plugin-card .update-now:before{color:#f56e28;content:"\f463";display:inline-block;font:400 20px/1 dashicons;margin:3px 5px 0 -2px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.plugin-card .updating-message:before{content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.plugin-card .updated-message:before{color:#79ba49;content:"\f147"}.plugin-install-php h2{clear:both}.plugin-install-php h3{margin:2.5em 0 8px}.plugin-install-php .wp-filter{margin-bottom:0}.plugin-group{overflow:hidden;margin-top:1.5em}.plugin-group h3{margin-top:0}.plugin-card{float:left;margin:0 8px 16px;width:48.5%;width:calc(50% - 8px);background-color:#fff;border:1px solid #ddd;box-sizing:border-box}.plugin-card:nth-child(odd){clear:both;margin-left:0}.plugin-card:nth-child(even){margin-right:0}@media screen and (min-width:1600px){.plugin-card{width:30%;width:calc(33.1% - 8px)}.plugin-card:nth-child(odd){clear:none;margin-left:8px}.plugin-card:nth-child(even){margin-right:8px}.plugin-card:nth-child(3n+1){clear:both;margin-left:0}.plugin-card:nth-child(3n){margin-right:0}}.plugin-card-top{position:relative;padding:20px 20px 10px;min-height:135px}.plugin-action-buttons,div.action-links{margin:0}.plugin-card h3{margin:0 0 12px;font-size:18px;line-height:1.3}.plugin-card .desc,.plugin-card .name{margin-left:148px;margin-right:120px}.plugin-card .action-links{position:absolute;top:20px;right:20px;width:120px}.plugin-action-buttons{clear:right;float:right;margin-left:2em;margin-bottom:1em;text-align:right}.plugin-action-buttons li{margin-bottom:10px}.plugin-card-bottom{clear:both;padding:12px 20px;background-color:#fafafa;border-top:1px solid #ddd;overflow:hidden}.plugin-card-bottom .star-rating{display:inline}.plugin-card-update-failed .update-now{font-weight:600}.plugin-card-update-failed .notice-error{margin:0;padding-left:16px;box-shadow:0 -1px 0 #ddd}.plugin-card-update-failed .plugin-card-bottom{display:none}.plugin-card .column-rating{line-height:23px}.plugin-card .column-rating,.plugin-card .column-updated{margin-bottom:4px}.plugin-card .column-downloaded,.plugin-card .column-rating{float:left;clear:left;max-width:180px}.plugin-card .column-compatibility,.plugin-card .column-updated{text-align:right;float:right;clear:right;width:65%;width:calc(100% - 180px)}.plugin-card .column-compatibility span:before{font:400 20px/.5 dashicons;speak:none;display:inline-block;padding:0;top:4px;left:-2px;position:relative;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-decoration:none!important;color:#444}.plugin-card .compatibility-incompatible:before{content:"\f158"}.plugin-card .compatibility-compatible:before{content:"\f147"}.plugin-icon{position:absolute;top:20px;left:20px;width:128px;height:128px;margin:0 20px 20px 0}.no-plugin-results{color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0 0;text-align:center}.wp-list-table .site-deleted,.wp-list-table tr.site-deleted{background:#ff8573}.wp-list-table .site-spammed,.wp-list-table tr.site-spammed{background:#faafaa}.wp-list-table .site-archived,.wp-list-table tr.site-archived{background:#ffebe8}.wp-list-table .site-mature,.wp-list-table tr.site-mature{background:#fecac2}.sites.fixed .column-lastupdated,.sites.fixed .column-registered{width:20%}.sites.fixed .column-users{width:80px}@media screen and (max-width:1100px) and (min-width:782px),(max-width:480px){.plugin-card .action-links{position:static;margin-left:148px;width:auto}.plugin-action-buttons{float:none;margin:1em 0 0;text-align:left}.plugin-action-buttons li{display:inline-block;vertical-align:middle}.plugin-action-buttons li .button{margin-right:20px}.plugin-card .desc,.plugin-card .name{margin-right:0}.plugin-card .desc p:first-of-type{margin-top:0}.fixed .column-date{width:14%}}@media screen and (max-width:782px){.plugins #the-list tr td,.plugins tr.active+tr.inactive td,.plugins tr.active+tr.inactive th.check-column{border-top:none}.tablenav{height:auto}.tablenav.top{margin:20px 0 5px}.tablenav.bottom{position:relative;margin-top:15px}.tablenav br{display:none}.tablenav br.clear{display:block}.form-wrap>p,.tablenav .view-switch,.tablenav.top .actions,.tablenav.top .displaying-num,.tablenav.top .tablenav-pages.one-page{display:none}.view-switch a{width:36px;height:36px;line-height:33px}.tablenav.bottom .displaying-num{position:absolute;right:0;top:11px;margin:0;font-size:14px}.tablenav .tablenav-pages{width:100%;height:auto;text-align:center;margin:0 0 25px}.tablenav.bottom .tablenav-pages{margin-top:25px}.tablenav.bottom .tablenav-pages.one-page{margin:15px 0 0;height:0}.tablenav-pages .pagination-links{font-size:16px}.tablenav-pages .pagination-links a,.tablenav-pages-navspan{padding:9px 11px 12px;font-size:18px}.tablenav-pages-navspan{height:18px}.tablenav-pages .pagination-links .current-page{padding:8px 9px 9px;font-size:16px}.comment-count{font-size:14px}.wp-list-table th.column-primary~th,.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary~td:not(.check-column){display:none}.wp-list-table thead th.column-primary{width:100%}.wp-list-table tr th.check-column{display:table-cell;width:35px}.wp-list-table .column-primary .toggle-row{display:block}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.check-column){position:relative;clear:both;display:block;width:auto!important}.wp-list-table td.column-primary{padding-right:50px}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-primary~td:not(.check-column){padding:3px 8px 3px 35%}.wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.column-primary)::before{position:absolute;left:10px;display:block;overflow:hidden;width:32%;content:attr(data-colname);white-space:nowrap;text-overflow:ellipsis}.wp-list-table .is-expanded td:not(.hidden){display:block!important;overflow:hidden}.column-posts,.widefat .num{text-align:left}#comments-form .fixed .column-author,#commentsdiv .fixed .column-author{display:none!important}.fixed .column-comment .comment-author{display:block}#the-comment-list .is-expanded td{box-shadow:none}#the-comment-list .is-expanded td:last-child{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.post-com-count .screen-reader-text{position:static;-webkit-clip-path:none;clip-path:none;width:auto;height:auto;margin:0}.column-comments .post-com-count-approved:after,.column-comments .post-com-count-no-comments:after,.column-response .post-com-count-approved:after,.column-response .post-com-count-no-comments:after{content:none}.column-comments .post-com-count [aria-hidden=true],.column-response .post-com-count [aria-hidden=true]{display:none}#edithead label,.column-comments .post-com-count-wrapper>a,.column-response .post-com-count-wrapper>a{display:block}.column-comments .post-com-count-wrapper,.column-response .post-com-count-wrapper{white-space:normal}.column-comments .post-com-count-approved,.column-comments .post-com-count-no-comments,.column-response .post-com-count-approved,.column-response .post-com-count-no-comments{margin-top:0;margin-right:.5em}.column-comments .post-com-count-pending,.column-response .post-com-count-pending{position:static;height:auto;min-width:0;padding:0;border:none;border-radius:0;background:0 0;color:#bb2a2a;font-size:inherit;line-height:inherit;text-align:left}.column-comments .post-com-count-pending:hover,.column-response .post-com-count-pending:hover{color:#dc3232}.widefat tfoot td.check-column,.widefat thead td.check-column{padding-top:10px}.widefat *{word-wrap:normal}#wpbody-content .bulk-edit-row .inline-edit-col-bottom,#wpbody-content .bulk-edit-row .inline-edit-col-left,#wpbody-content .bulk-edit-row-page .inline-edit-col-right,#wpbody-content .bulk-edit-row-post .inline-edit-col-right,#wpbody-content .inline-edit-row-post .inline-edit-col-center,#wpbody-content .quick-edit-row-page .inline-edit-col-left,#wpbody-content .quick-edit-row-page .inline-edit-col-right,#wpbody-content .quick-edit-row-post .inline-edit-col-left,#wpbody-content .quick-edit-row-post .inline-edit-col-right{float:none;width:100%}#wpbody-content .bulk-edit-row fieldset .inline-edit-col label,#wpbody-content .bulk-edit-row fieldset .inline-edit-group label,#wpbody-content .quick-edit-row fieldset .inline-edit-col label,#wpbody-content .quick-edit-row fieldset .inline-edit-group label{max-width:none;float:none;margin-bottom:5px}#wpbody .bulk-edit-row fieldset select{display:block;width:100%;max-width:none;box-sizing:border-box}.inline-edit-row #bulk-titles div,.inline-edit-row fieldset ul.cat-checklist label{font-size:16px}.inline-edit-row fieldset label span.title,.inline-edit-row fieldset.inline-edit-date legend{float:none}.inline-edit-row fieldset label.inline-edit-tags{padding:0 .5em}.inline-edit-row fieldset .inline-edit-col label.inline-edit-tags{padding:0}.inline-edit-row fieldset .timestamp-wrap,.inline-edit-row fieldset label span.input-text-wrap{margin-left:0}.inline-edit-row fieldset input[name=hh],.inline-edit-row fieldset input[name=jj],.inline-edit-row fieldset input[name=mn]{width:3em}.inline-edit-row fieldset input[name=aa]{width:4.5em}.inline-edit-row .inline-edit-or{margin:0 6px 0 0}#commentsdiv #edithead .inside,#edithead .inside{float:none;text-align:left;padding:3px 5px}#commentsdiv #edithead .inside input,#edithead .inside input{width:100%}#bulk-titles div{margin:.8em .3em}.plugin-card,.plugin-update-tr .update-message,.plugins .plugin-update-tr .update-message{margin-left:0}#bulk-titles div a{height:22px}#wpbody-content .updates-table .plugin-title{width:auto;white-space:normal}.link-manager-php #posts-filter{margin-top:25px}.link-manager-php .tablenav.bottom{overflow:hidden}.comments-box .toggle-row,.wp-list-table.plugins .toggle-row{display:none}#wpbody-content .wp-list-table.plugins td{display:block;width:auto;padding:10px 9px}#wpbody-content .wp-list-table.plugins .column-description{padding-top:2px}#wpbody-content .wp-list-table.plugins .plugin-title,#wpbody-content .wp-list-table.plugins .theme-title{padding-right:12px;white-space:normal}.wp-list-table.plugins .plugin-title,.wp-list-table.plugins .theme-title{padding-top:13px;padding-bottom:4px}.plugins #the-list .update td,.plugins #the-list .update th,.plugins #the-list tr>td:not(:last-child),.wp-list-table.plugins #the-list .theme-title{box-shadow:none;border-top:none}.plugins tbody{padding:1px 0 0}.plugins .plugin-update-tr:before,.plugins tr.active+tr.inactive td.column-description,.plugins tr.active+tr.inactive th.check-column{box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugins .plugin-update-tr:before{content:"";display:table-cell}.plugins #the-list .plugin-update-tr .plugin-update{border-left:none}.plugins .active.update+.plugin-update-tr:before{background-color:#f7fcfe;border-left:4px solid #00a0d2}.wp-list-table.plugins .plugin-title strong,.wp-list-table.plugins .theme-title strong{font-size:1.4em;line-height:1.5}table.plugin-install .column-description,table.plugin-install .column-name,table.plugin-install .column-rating,table.plugin-install .column-version{display:block;width:auto}table.plugin-install th.column-description,table.plugin-install th.column-name,table.plugin-install th.column-rating,table.plugin-install th.column-version{display:none}table.plugin-install td.column-name strong{font-size:1.4em;line-height:1.6em}table.plugin-install #the-list td{box-shadow:none}table.plugin-install #the-list tr{display:block;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.plugin-card{margin-right:0;width:100%}}@media screen and (max-width:480px){.tablenav-pages .current-page{margin:0}.tablenav-pages .tablenav-paging-text{float:left;width:100%;padding-top:.5em}} \ No newline at end of file diff --git a/backend/wp-admin/css/login-rtl.css b/backend/wp-admin/css/login-rtl.css new file mode 100644 index 0000000..7c7d85b --- /dev/null +++ b/backend/wp-admin/css/login-rtl.css @@ -0,0 +1,283 @@ +@import url(forms-rtl.css); +@import url(l10n-rtl.css); + +html, +body { + height: 100%; + margin: 0; + padding: 0; +} + +body { + background: #f1f1f1; + min-width: 0; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 13px; + line-height: 1.4em; +} + +a { + color: #0073aa; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +a { + outline: 0; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +p { + line-height: 1.5; +} + +.login .message, +.login .success, +.login #login_error { + border-right: 4px solid #00a0d2; + padding: 12px; + margin-right: 0; + margin-bottom: 20px; + background-color: #fff; + box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1); +} + +.login .success { + border-right-color: #46b450; +} + +.login #login_error { + border-right-color: #dc3232; +} + +#loginform p.submit, +.login-action-lostpassword p.submit { + border: none; + margin: -10px 0 20px; /* May want to revisit this */ +} + +.login * { + margin: 0; + padding: 0; +} + +.login .password-input-wrapper { + display: table; +} + +.login .input.password-input { + display: table-cell; + margin: 0; +} + +.login .pw-weak { + margin-bottom: 15px; +} + +.login .button.button-secondary { + display: table-cell; + border-radius: 0; + vertical-align: middle; +} + +.login form { + margin-top: 20px; + margin-right: 0; + padding: 26px 24px 46px; + font-weight: 400; + overflow: hidden; + background: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +.login form .forgetmenot { + font-weight: 400; + float: right; + margin-bottom: 0; +} + +.login .button-primary { + float: left; +} + +#login form p { + margin-bottom: 0; +} + +#login form p.submit { + margin: 0; + padding: 0; +} + +.login label { + color: #72777c; + font-size: 14px; +} + +.login form .forgetmenot label { + font-size: 12px; + line-height: 19px; +} + +.login h1 { + text-align: center; +} + +.login h1 a { + background-image: url(../images/w-logo-blue.png?ver=20131202); + background-image: none, url(../images/wordpress-logo.svg?ver=20131107); + background-size: 84px; + background-position: center top; + background-repeat: no-repeat; + color: #444; + height: 84px; + font-size: 20px; + font-weight: 400; + line-height: 1.3em; + margin: 0 auto 25px; + padding: 0; + text-decoration: none; + width: 84px; + text-indent: -9999px; + outline: none; + overflow: hidden; + display: block; +} + +#login { + width: 320px; + padding: 8% 0 0; + margin: auto; +} + +.login #nav, +.login #backtoblog { + font-size: 13px; + padding: 0 24px 0; +} + +.login #nav { + margin: 24px 0 0 0; +} + +#backtoblog { + margin: 16px 0; +} + +.login #nav a, +.login #backtoblog a { + text-decoration: none; + color: #555d66; +} + +.login #nav a:hover, +.login #backtoblog a:hover, +.login h1 a:hover { + color: #00a0d2; +} + +.login #nav a:focus, +.login #backtoblog a:focus, +.login h1 a:focus { + color: #124964; +} + +.login .privacy-policy-page-link { + text-align: center; + width: 100%; + margin: 5em 0 2em; +} + +.login form .input, +.login input[type="text"] { + font-size: 24px; + width: 100%; + padding: 3px; + margin: 2px 0 16px 6px; +} + +.login form .input, +.login input[type="text"], +.login form input[type="checkbox"] { + background: #fbfbfb; +} + +.ie7 .login form .input, +.ie8 .login form .input { + font-family: sans-serif; +} + +.login-action-rp input[type="text"] { + box-shadow: none; + margin: 0; +} + +.login #pass-strength-result { + font-weight: 600; + margin: -1px 0 16px 5px; + padding: 6px 5px; + text-align: center; + width: 100%; +} + +body.interim-login { + height: auto; +} + +.interim-login #login { + padding: 0; + margin: 5px auto 20px; +} + +.interim-login.login h1 a { + width: auto; +} + +.interim-login #login_error, +.interim-login.login .message { + margin: 0 0 16px; +} + +.interim-login.login form { + margin: 0; +} + +@-ms-viewport { + width: device-width; +} + +@media screen and ( max-height: 550px ) { + #login { + padding: 20px 0; + } +} + +@media screen and ( max-width: 782px ) { + .interim-login input[type=checkbox] { + height: 16px; + width: 16px; + } + + .interim-login input[type=checkbox]:checked:before { + width: 16px; + font: normal 21px/1 dashicons; + margin: -3px -4px 0 0; + } +} diff --git a/backend/wp-admin/css/login-rtl.min.css b/backend/wp-admin/css/login-rtl.min.css new file mode 100644 index 0000000..1106a8a --- /dev/null +++ b/backend/wp-admin/css/login-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#your-profile label+a,.wp-admin select,fieldset label,label{vertical-align:middle}#pass-strength-result,.color-option,input,textarea{box-sizing:border-box}#pressthis-code-wrap,textarea{overflow:auto}.login h1 a,form p.submit a.cancel:hover{text-decoration:none}input[type=text],input[type=search],input[type=radio],input[type=tel],input[type=time],input[type=url],input[type=week],input[type=password],input[type=checkbox],input[type=color],input[type=date],input[type=datetime],input[type=datetime-local],input[type=email],input[type=month],input[type=number],select,textarea{border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;transition:50ms border-color ease-in-out}input[type=text]:focus,input[type=search]:focus,input[type=radio]:focus,input[type=tel]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,input[type=password]:focus,input[type=checkbox]:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,select:focus,textarea:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}input[type=url],input[type=email]{direction:ltr}input[type=number]{height:28px;line-height:1}input[type=radio],input[type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 0 0 4px;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.1);transition:.05s border-color ease-in-out}input[type=radio]:checked+label:before{color:#82878c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#00a0d2}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox],td>input[type=checkbox]{margin-top:0}.wp-admin p label input[type=checkbox]{margin-top:-4px}.wp-admin p label input[type=radio]{margin-top:-2px}input[type=radio]{border-radius:50%;margin-left:4px;line-height:10px}input[type=radio]:checked:before,input[type=checkbox]:checked:before{float:right;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#pass1-text,.pw-weak,.show-password #pass1{display:none}input[type=checkbox]:checked:before{content:"\f147";margin:-3px -4px 0 0;color:#1e8cbe}input[type=radio]:checked:before{content:"\2022";text-indent:-9999px;border-radius:50px;font-size:24px;width:6px;height:6px;margin:4px;line-height:16px;background-color:#1e8cbe}@-moz-document url-prefix(){.form-table input.tog,input[type=radio],input[type=checkbox]{margin-bottom:-1px}}input[type=search]{-webkit-appearance:textfield}input[type=search]::-webkit-search-decoration{display:none}.ie8 input[type=password]{font-family:sans-serif}button,input,select,textarea{font-family:inherit;font-size:inherit;font-weight:inherit}input,select,textarea{font-size:14px;border-radius:0}textarea{padding:2px 6px;line-height:1.4;resize:vertical}.wp-admin input[type=file]{padding:3px 0;cursor:pointer}label{cursor:pointer}input,select{margin:1px;padding:3px 5px}input.code{padding-top:6px}textarea.code{line-height:1.4;padding:4px 6px 1px}input.readonly,input[readonly],textarea.readonly,textarea[readonly]{background-color:#eee}::-webkit-input-placeholder{color:#72777c}::-moz-placeholder{color:#72777c;opacity:1}:-ms-input-placeholder{color:#72777c}.form-invalid input,.form-invalid input:focus,.form-invalid select,.form-invalid select:focus{border-color:#dc3232!important;box-shadow:0 0 2px rgba(204,0,0,.8)}.form-table .form-required.form-invalid td:after{content:"\f534";font:400 20px/1 dashicons;color:#dc3232;margin-right:-25px;vertical-align:middle}.form-table .form-required.user-pass1-wrap.form-invalid td:after{content:''}.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after{content:'\f534';font:400 20px/1 dashicons;color:#dc3232;margin:0 -29px 0 6px;vertical-align:middle}.form-input-tip{color:#666}input.disabled,input:disabled,select.disabled,select:disabled,textarea.disabled,textarea:disabled{background:rgba(255,255,255,.5);border-color:rgba(222,222,222,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5)}input[type=file].disabled,input[type=file]:disabled,input[type=range].disabled,input[type=range]:disabled{background:0 0;box-shadow:none;cursor:default}input[type=radio].disabled,input[type=radio].disabled:checked:before,input[type=radio]:disabled,input[type=radio]:disabled:checked:before,input[type=checkbox].disabled,input[type=checkbox].disabled:checked:before,input[type=checkbox]:disabled,input[type=checkbox]:disabled:checked:before{opacity:.7}.wp-admin select{padding:2px;line-height:28px;height:28px}.wp-admin .button-cancel{padding:0 5px;line-height:2}.meta-box-sortables select{max-width:100%}.wp-admin select[multiple]{height:auto}.submit{padding:1.5em 0;margin:5px 0;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:none}p.submit{text-align:right;max-width:100%;margin-top:20px;padding-top:10px}.textright p.submit{border:none;text-align:left}table.form-table+input+input+p.submit,table.form-table+input+p.submit,table.form-table+p.submit{border-top:none;padding-top:0}#major-publishing-actions input,#minor-publishing-actions .preview,#minor-publishing-actions input{text-align:center}input.all-options,textarea.all-options{width:250px}input.large-text,textarea.large-text{width:99%}.regular-text{width:25em}input.small-text{width:50px;padding:1px 6px}input[type=number].small-text{width:65px}input.tiny-text{width:35px}input[type=number].tiny-text{width:45px}#doaction,#doaction2,#post-query-submit{margin:1px 0 0 8px}.tablenav #changeit,.tablenav #clear-recent-list,.tablenav #delete_all,.wp-filter #delete_all{margin-top:1px}.tablenav .actions select{float:right;margin-left:6px;max-width:200px}.ie8 .tablenav .actions select{width:155px}.ie8 .tablenav .actions select#cat{width:200px}#timezone_string option{margin-right:1em}button.wp-hide-pw>.dashicons{position:relative;top:3px}.options-media-php [for*="_size_"]{min-width:10em;vertical-align:baseline}.options-media-php .small-text[name*="_size_"]{margin:0 0 1em}#misc-publishing-actions label{vertical-align:baseline}#pass-strength-result{background-color:#eee;border:1px solid #ddd;color:#23282d;margin:-2px 1px 5px 5px;padding:3px 5px;text-align:center;width:25em;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.indicator-hint{padding-top:8px}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}p.search-box{float:left;margin:0}.network-admin.themes-php p.search-box{clear:right}.search-box input[name="s"],.tablenav .search-plugins input[name="s"],.tagsdiv .newtag{float:right;height:28px;margin:0 0 0 4px}.js.plugins-php .search-box .wp-filter-search{margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5;padding:3px 5px;height:32px}input[type=text].ui-autocomplete-loading,input[type=email].ui-autocomplete-loading{background-image:url(../images/loading.gif);background-repeat:no-repeat;background-position:left center;visibility:visible}input.ui-autocomplete-input.open{border-bottom-color:transparent}ul#add-to-blog-users{margin:0 14px 0 0}.ui-autocomplete{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete li{margin-bottom:0;padding:4px 10px;white-space:nowrap;text-align:right;cursor:pointer}.ui-autocomplete .ui-state-focus{background-color:#ddd}.wp-tags-autocomplete .ui-state-focus{background-color:#0073aa;color:#fff}.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both}.form-table,.form-table td,.form-table td p,.form-table th{font-size:14px}.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle}.form-table th,.form-wrap label{color:#23282d;font-weight:400;text-shadow:none;vertical-align:baseline}.form-table th{vertical-align:top;text-align:right;padding:20px 0 20px 10px;width:200px;line-height:1.3;font-weight:600}.form-table .td-full,.form-table th.th-full{width:auto;padding:20px 0 20px 10px;font-weight:400}.form-table td p{margin-top:4px;margin-bottom:0}.form-table .date-time-doc{margin-top:1em}.form-table p.timezone-info{margin:1em 0}.form-table td fieldset label{margin:.25em 0 .5em!important;display:inline-block}.form-table td fieldset label,.form-table td fieldset li,.form-table td fieldset p{line-height:1.4em}.form-table input.tog,.form-table input[type=radio]{margin-top:-4px;margin-left:4px;float:none}.form-table .pre{padding:8px;margin:0}table.form-table td .updated{font-size:13px}table.form-table td .updated p{font-size:13px;margin:.3em 0}#profile-page .form-table textarea{width:500px;margin-bottom:6px}#profile-page .form-table #rich_editing{margin-left:5px}#your-profile legend{font-size:22px}#display_name{width:15em}#adduser .form-field input,#createuser .form-field input{width:25em}.color-option{display:inline-block;width:24%;padding:5px 15px 15px;margin-bottom:3px;cursor:pointer}.color-option.selected,.color-option:hover{background:#ddd}.color-palette{width:100%;border-spacing:0;border-collapse:collapse}.color-palette td{height:20px;padding:0;border:none}.tool-box .title{margin:8px 0;font-size:18px;font-weight:400;line-height:24px}.label-responsive{vertical-align:middle}#export-filters p{margin:0 0 1em}#export-filters p.submit{margin:7px 0 5px}.card{position:relative;margin-top:20px;padding:.7em 2em 1em;min-width:255px;max-width:520px;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff}.pressthis h4{margin:2em 0 1em}.pressthis textarea{width:100%;font-size:1em}.login form,.login h1 a{overflow:hidden;font-weight:400}.pressthis-bookmarklet-wrapper{margin:20px 0 8px;vertical-align:top;position:relative;z-index:1}.pressthis-bookmarklet,.pressthis-bookmarklet:active,.pressthis-bookmarklet:focus,.pressthis-bookmarklet:hover{display:inline-block;position:relative;cursor:move;color:#32373c;background:#e5e5e5;border-radius:5px;border:1px solid #b4b9be;font-style:normal;line-height:16px;font-size:14px;text-decoration:none}.privacy_requests tbody th,.privacy_requests tfoot td:first-child,.privacy_requests thead td:first-child{border-right:4px solid #fff}.pressthis-bookmarklet:active{outline:0}.pressthis-bookmarklet:after{content:"";width:70%;height:55%;z-index:-1;position:absolute;left:10px;bottom:9px;background:0 0;-webkit-transform:skew(-20deg) rotate(-6deg);transform:skew(-20deg) rotate(-6deg);box-shadow:0 10px 8px rgba(0,0,0,.6)}.pressthis-bookmarklet:hover:after{-webkit-transform:skew(-20deg) rotate(-9deg);transform:skew(-20deg) rotate(-9deg);box-shadow:0 10px 8px rgba(0,0,0,.7)}.pressthis-bookmarklet span{display:inline-block;margin:0;padding:0 9px 8px 12px}.pressthis-bookmarklet span:before{color:#72777c;font:400 20px/1 dashicons;content:"\f157";position:relative;display:inline-block;top:4px;margin-left:4px}.pressthis-js-toggle,.pressthis-js-toggle.button.button{margin-right:10px;padding:0;height:auto;vertical-align:top}.pressthis-js-toggle .dashicons{margin:5px 7px 6px 8px;color:#555d66}.timezone-info code{white-space:nowrap}.defaultavatarpicker .avatar{margin:2px 0;vertical-align:middle}.options-general-php .date-time-text{display:inline-block;min-width:10em}.options-general-php input.small-text{width:56px}.options-general-php .spinner{float:none;margin:-3px 3px 0}.options-general-php .language-install-spinner,.settings-php .language-install-spinner{display:inline-block;float:none;margin:-3px 5px 0;vertical-align:middle}.form-table.permalink-structure .available-structure-tags li{float:right;margin-left:5px}.setup-php textarea{max-width:100%}.form-field #site-address{max-width:25em}.form-field #domain{max-width:22em}.form-field #admin-email,.form-field #blog_last_updated,.form-field #blog_registered,.form-field #path,.form-field #site-title{max-width:25em}.form-field #path{margin-bottom:5px}#search-sites,#search-users{max-width:100%}.request-filesystem-credentials-dialog{display:none;visibility:visible}.request-filesystem-credentials-dialog .notification-dialog{top:10%;max-height:85%}.request-filesystem-credentials-dialog-content{margin:25px}#request-filesystem-credentials-title{font-size:1.3em;margin:1em 0}.request-filesystem-credentials-form legend{font-size:1em;padding:1.33em 0 0;font-weight:600}.request-filesystem-credentials-form input[type=text],.request-filesystem-credentials-form input[type=password]{display:block}.request-filesystem-credentials-dialog input[type=text],.request-filesystem-credentials-dialog input[type=password]{width:100%}.request-filesystem-credentials-form .field-title{font-weight:600}.request-filesystem-credentials-dialog label[for=hostname],.request-filesystem-credentials-dialog label[for=public_key],.request-filesystem-credentials-dialog label[for=private_key]{display:block;margin-bottom:1em}.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons{text-align:left}.login #pass-strength-result,.login h1,.privacy_requests .column-type{text-align:center}.request-filesystem-credentials-dialog label[for=ftp]{margin-left:10px}.request-filesystem-credentials-dialog #auth-keys-desc{margin-bottom:0}#request-filesystem-credentials-dialog .button:not(:last-child){margin-left:10px}#request-filesystem-credentials-form .cancel-button{display:none}#request-filesystem-credentials-dialog .cancel-button{display:inline}.request-filesystem-credentials-dialog .ftp-password,.request-filesystem-credentials-dialog .ftp-username{float:none;width:auto}.request-filesystem-credentials-dialog .ftp-username{margin-bottom:1em}.request-filesystem-credentials-dialog .ftp-password{margin:0}.request-filesystem-credentials-dialog .ftp-password em{color:#888}.request-filesystem-credentials-dialog label{display:block;line-height:1.5;margin-bottom:1em}.request-filesystem-credentials-form #ssh-keys legend{font-size:1.3em}.request-filesystem-credentials-form .notice{margin:0 0 20px;clear:both}.tools-privacy-policy-page form{margin-bottom:1.3em}.tools-privacy-policy-page input.button,.tools-privacy-policy-page select{margin-right:6px}.tools-privacy-edit{margin:1.5em 0}.tools-privacy-policy-page span{line-height:2em}.privacy_requests .column-email{width:40%}.privacy_requests tbody th{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results th{box-shadow:none}.privacy_requests tbody .request-results th .notice{margin:0 0 5px}.privacy_requests tbody td{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results td{box-shadow:none}.privacy_requests .next_steps .button{height:auto;line-height:1.5;padding:4px 10px;word-break:break-all;white-space:unset}.privacy_requests .status-request-confirmed td,.privacy_requests .status-request-confirmed th{background-color:#f7fcfe;border-right-color:#00a0d2}.privacy_requests .status-request-failed td,.privacy_requests .status-request-failed th{background-color:#fef7f1;border-right-color:#d64d21}.privacy_requests .export_personal_data_failed a{vertical-align:baseline}.status-label{font-weight:700}.status-label.status-request-pending{font-weight:400;font-style:italic;color:#6c7781}.status-label.status-request-failed{color:#a00;font-weight:700}.wp-privacy-request-form{clear:both}.wp-privacy-request-form-field{margin:1.5em 0}.wp-privacy-request-form label{font-weight:700;line-height:1.5;padding-bottom:.5em;display:block}.wp-privacy-request-form input{line-height:1.5;margin:0}.email-personal-data::before{display:inline-block;font:400 20px/1 dashicons;margin:3px -2px 0 5px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.email-personal-data--sending::before{color:#f56e28;content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.email-personal-data--sent::before{color:#79ba49;content:"\f147"}@media screen and (max-width:782px){#pass-strength-result,.form-table{box-sizing:border-box}textarea{-webkit-appearance:none}input[type=text],input[type=search],input[type=password],input[type=email],input[type=number]{-webkit-appearance:none;padding:6px 10px}input[type=number]{height:40px}input.code{padding-bottom:5px;padding-top:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox],input[type=checkbox]{-webkit-appearance:none;padding:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox]{margin-bottom:8px}.widefat tfoot td input[type=checkbox]:before,.widefat th input[type=checkbox]:before,.widefat thead td input[type=checkbox]:before,input[type=checkbox]:checked:before{font:400 30px/1 dashicons;margin:-3px -5px}input[type=radio],input[type=checkbox]{height:25px;width:25px}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox]{margin-top:-3px}input[type=radio]:checked:before{vertical-align:middle;width:9px;height:9px;margin:7px;line-height:16px}.wp-upload-form input[type=submit]{margin-top:10px}#wpbody select{height:36px;font-size:16px}.wp-admin .button-cancel{padding:0;font-size:14px}#adduser .form-field input,#createuser .form-field input{width:100%}.form-table td,.form-table th,.label-responsive{display:block;width:auto;vertical-align:middle}.label-responsive{margin:.5em 0}.export-filters li{margin-bottom:0}.form-table .color-palette td{display:table-cell;width:15px}.form-table table.color-palette{margin-left:10px}input,textarea{font-size:16px}#profile-page .form-table textarea,.form-table span.description,.form-table td input[type=text],.form-table td input[type=password],.form-table td input[type=email],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}.form-table .form-required.form-invalid td:after{float:left;margin:-30px 0 0 3px}#wpbody .form-table td select{height:40px}.form-table input[type=text].small-text,input[type=text].small-text,input[type=search].small-text,input[type=password].small-text,input[type=number].small-text{width:auto;max-width:4.375em;display:inline;padding:3px 6px;margin:0 3px}#pass-strength-result{width:100%;padding:8px}p.search-box{float:none;position:absolute;bottom:0;width:98%;height:90px;margin-bottom:20px}p.search-box input[name="s"]{height:auto;float:none;width:100%;margin-bottom:10px;vertical-align:middle;-webkit-appearance:none}p.search-box input[type=submit]{margin-bottom:10px}.form-table span.description{display:inline;padding:4px 0 0;line-height:1.4em;font-size:14px}.form-table th{padding-top:10px;padding-bottom:0;border-bottom:0}.form-table td{margin-bottom:0;padding-bottom:6px;padding-top:4px;padding-right:0}.form-table.permalink-structure td code{margin-right:32px}.form-table.permalink-structure td input[type=text]{margin-right:32px;margin-top:4px;width:96%}.form-table input.regular-text{width:100%}.form-table label{font-size:14px}.form-table fieldset label{display:block}#local-time,#utc-time{display:block;float:none;margin-top:.5em}.form-field #domain{max-width:none}.wp-pwd{position:relative}.wp-pwd [type=text],.wp-pwd [type=password]{padding-left:40px}.wp-pwd button.button{background:0 0;border:none;box-shadow:none;line-height:2;margin:0;padding:5px 10px;position:absolute;left:0;top:0}.wp-pwd button.button:active,.wp-pwd button.button:focus,.wp-pwd button.button:hover{background:0 0}.wp-pwd .button .text{display:none}.options-general-php input[type=text].small-text{max-width:6.25em;margin:0}.tools-privacy-policy-page form.wp-create-privacy-page{margin-bottom:1em}.tools-privacy-policy-page input#set-page,.tools-privacy-policy-page select{margin:10px 0 0}.tools-privacy-policy-page .wp-create-privacy-page span{display:block;margin-bottom:1em}.tools-privacy-policy-page .wp-create-privacy-page .button{margin-right:0}.wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column){display:table-cell}.wp-list-table.privacy_requests.widefat th input,.wp-list-table.privacy_requests.widefat thead td input{margin-right:5px}}.locale-he-il em,.locale-zh-cn #local-time,.locale-zh-cn #utc-time,.locale-zh-cn .form-wrap p,.locale-zh-cn .howto,.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,.locale-zh-cn .inline-edit-row fieldset span.title,.locale-zh-cn .js .input-with-default-title,.locale-zh-cn .link-to-original,.locale-zh-cn .tablenav .displaying-num,.locale-zh-cn p.description,.locale-zh-cn p.help,.locale-zh-cn p.install-help,.locale-zh-cn span.description{font-style:normal}@media only screen and (max-width:768px){.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field select,.form-field textarea{width:99%}.form-wrap .form-field{padding:0}#profile-page .form-table textarea{max-width:400px;width:auto}}.locale-de-de #customize-header-actions .button,.locale-de-de-formal #customize-header-actions .button,.locale-ru-ru #customize-header-actions .button{padding:0 5px 1px}@media only screen and (max-height:480px),screen and (max-width:450px){.file-editor-warning .notification-dialog,.request-filesystem-credentials-dialog .notification-dialog{width:100%;height:100%;max-height:100%;position:fixed;top:0;margin:0;right:0}}@media screen and (max-width:600px){.color-option{width:49%}}@media only screen and (max-width:320px){.options-general-php .date-time-text.date-time-custom-text{min-width:0;margin-left:.5em}}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(-359deg);transform:rotate(-359deg)}}body.rtl,body.rtl .press-this a.wp-switch-editor{font-family:Tahoma,Arial,sans-serif}.rtl h1,.rtl h2,.rtl h3,.rtl h4,.rtl h5,.rtl h6{font-family:Arial,sans-serif;font-weight:600}body.locale-he-il,body.locale-he-il .press-this a.wp-switch-editor{font-family:Arial,sans-serif}.locale-he-il em{font-weight:600}.locale-zh-cn .hdnle a{font-size:12px}.locale-zh-cn form.upgrade .hint{font-style:normal;font-size:100%}.locale-zh-cn #sort-buttons{font-size:1em!important}.locale-de-de #customize-header-actions .spinner,.locale-de-de-formal #customize-header-actions .spinner{margin:16px 3px 0}.locale-ru-ru #adminmenu{width:inherit}.locale-ru-ru #adminmenu,.locale-ru-ru #wpbody{margin-right:0}.locale-ru-ru .inline-edit-row fieldset label span.title,.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-right:8em}.locale-ru-ru.post-new-php .tagsdiv .newtag,.locale-ru-ru.post-php .tagsdiv .newtag{width:165px}.locale-ru-ru.press-this .posting{margin-left:277px}.locale-ru-ru .press-this-sidebar{width:265px}.locale-ru-ru #customize-header-actions .spinner{margin:16px 3px 0}.locale-lt-lt .inline-edit-row fieldset label span.title,.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap{margin-right:8em}@media screen and (max-width:782px){.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap,.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-right:0}}body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4em}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out;outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-right:4px solid #00a0d2;padding:12px;margin-right:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-right-color:#46b450}.login #login_error{border-right-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{display:table}.login .input.password-input{display:table-cell;margin:0}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{display:table-cell;border-radius:0;vertical-align:middle}.login form{margin-top:20px;margin-right:0;padding:26px 24px 46px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login form .forgetmenot{font-weight:400;float:right;margin-bottom:0}.login .button-primary{float:left}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{color:#72777c;font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:19px}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;line-height:1.3em;margin:0 auto 25px;padding:0;width:84px;text-indent:-9999px;outline:0;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px}.login #nav{margin:24px 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:3px;margin:2px 0 16px 6px}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 0 16px 5px;padding:6px 5px;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:400 21px/1 dashicons;margin:-3px -4px 0 0}} \ No newline at end of file diff --git a/backend/wp-admin/css/login.css b/backend/wp-admin/css/login.css new file mode 100644 index 0000000..686be7d --- /dev/null +++ b/backend/wp-admin/css/login.css @@ -0,0 +1,283 @@ +@import url(forms.css); +@import url(l10n.css); + +html, +body { + height: 100%; + margin: 0; + padding: 0; +} + +body { + background: #f1f1f1; + min-width: 0; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 13px; + line-height: 1.4em; +} + +a { + color: #0073aa; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +a { + outline: 0; +} + +a:hover, +a:active { + color: #00a0d2; +} + +a:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.ie8 a:focus { + outline: #5b9dd9 solid 1px; +} + +p { + line-height: 1.5; +} + +.login .message, +.login .success, +.login #login_error { + border-left: 4px solid #00a0d2; + padding: 12px; + margin-left: 0; + margin-bottom: 20px; + background-color: #fff; + box-shadow: 0 1px 1px 0 rgba(0,0,0,0.1); +} + +.login .success { + border-left-color: #46b450; +} + +.login #login_error { + border-left-color: #dc3232; +} + +#loginform p.submit, +.login-action-lostpassword p.submit { + border: none; + margin: -10px 0 20px; /* May want to revisit this */ +} + +.login * { + margin: 0; + padding: 0; +} + +.login .password-input-wrapper { + display: table; +} + +.login .input.password-input { + display: table-cell; + margin: 0; +} + +.login .pw-weak { + margin-bottom: 15px; +} + +.login .button.button-secondary { + display: table-cell; + border-radius: 0; + vertical-align: middle; +} + +.login form { + margin-top: 20px; + margin-left: 0; + padding: 26px 24px 46px; + font-weight: 400; + overflow: hidden; + background: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.13); +} + +.login form .forgetmenot { + font-weight: 400; + float: left; + margin-bottom: 0; +} + +.login .button-primary { + float: right; +} + +#login form p { + margin-bottom: 0; +} + +#login form p.submit { + margin: 0; + padding: 0; +} + +.login label { + color: #72777c; + font-size: 14px; +} + +.login form .forgetmenot label { + font-size: 12px; + line-height: 19px; +} + +.login h1 { + text-align: center; +} + +.login h1 a { + background-image: url(../images/w-logo-blue.png?ver=20131202); + background-image: none, url(../images/wordpress-logo.svg?ver=20131107); + background-size: 84px; + background-position: center top; + background-repeat: no-repeat; + color: #444; + height: 84px; + font-size: 20px; + font-weight: 400; + line-height: 1.3em; + margin: 0 auto 25px; + padding: 0; + text-decoration: none; + width: 84px; + text-indent: -9999px; + outline: none; + overflow: hidden; + display: block; +} + +#login { + width: 320px; + padding: 8% 0 0; + margin: auto; +} + +.login #nav, +.login #backtoblog { + font-size: 13px; + padding: 0 24px 0; +} + +.login #nav { + margin: 24px 0 0 0; +} + +#backtoblog { + margin: 16px 0; +} + +.login #nav a, +.login #backtoblog a { + text-decoration: none; + color: #555d66; +} + +.login #nav a:hover, +.login #backtoblog a:hover, +.login h1 a:hover { + color: #00a0d2; +} + +.login #nav a:focus, +.login #backtoblog a:focus, +.login h1 a:focus { + color: #124964; +} + +.login .privacy-policy-page-link { + text-align: center; + width: 100%; + margin: 5em 0 2em; +} + +.login form .input, +.login input[type="text"] { + font-size: 24px; + width: 100%; + padding: 3px; + margin: 2px 6px 16px 0; +} + +.login form .input, +.login input[type="text"], +.login form input[type="checkbox"] { + background: #fbfbfb; +} + +.ie7 .login form .input, +.ie8 .login form .input { + font-family: sans-serif; +} + +.login-action-rp input[type="text"] { + box-shadow: none; + margin: 0; +} + +.login #pass-strength-result { + font-weight: 600; + margin: -1px 5px 16px 0; + padding: 6px 5px; + text-align: center; + width: 100%; +} + +body.interim-login { + height: auto; +} + +.interim-login #login { + padding: 0; + margin: 5px auto 20px; +} + +.interim-login.login h1 a { + width: auto; +} + +.interim-login #login_error, +.interim-login.login .message { + margin: 0 0 16px; +} + +.interim-login.login form { + margin: 0; +} + +@-ms-viewport { + width: device-width; +} + +@media screen and ( max-height: 550px ) { + #login { + padding: 20px 0; + } +} + +@media screen and ( max-width: 782px ) { + .interim-login input[type=checkbox] { + height: 16px; + width: 16px; + } + + .interim-login input[type=checkbox]:checked:before { + width: 16px; + font: normal 21px/1 dashicons; + margin: -3px 0 0 -4px; + } +} diff --git a/backend/wp-admin/css/login.min.css b/backend/wp-admin/css/login.min.css new file mode 100644 index 0000000..e672055 --- /dev/null +++ b/backend/wp-admin/css/login.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#your-profile label+a,.wp-admin select,fieldset label,label{vertical-align:middle}#pass-strength-result,.color-option,input,textarea{box-sizing:border-box}#pressthis-code-wrap,textarea{overflow:auto}.login h1 a,form p.submit a.cancel:hover{text-decoration:none}input[type=text],input[type=search],input[type=radio],input[type=tel],input[type=time],input[type=url],input[type=week],input[type=password],input[type=checkbox],input[type=color],input[type=date],input[type=datetime],input[type=datetime-local],input[type=email],input[type=month],input[type=number],select,textarea{border:1px solid #ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;transition:50ms border-color ease-in-out}input[type=text]:focus,input[type=search]:focus,input[type=radio]:focus,input[type=tel]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus,input[type=password]:focus,input[type=checkbox]:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime]:focus,input[type=datetime-local]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,select:focus,textarea:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}input[type=url],input[type=email]{direction:ltr}input[type=number]{height:28px;line-height:1}input[type=radio],input[type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 4px 0 0;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.1);transition:.05s border-color ease-in-out}input[type=radio]:checked+label:before{color:#82878c}.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:hover{color:#00a0d2}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox],td>input[type=checkbox]{margin-top:0}.wp-admin p label input[type=checkbox]{margin-top:-4px}.wp-admin p label input[type=radio]{margin-top:-2px}input[type=radio]{border-radius:50%;margin-right:4px;line-height:10px}input[type=radio]:checked:before,input[type=checkbox]:checked:before{float:left;display:inline-block;vertical-align:middle;width:16px;font:400 21px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#pass1-text,.pw-weak,.show-password #pass1{display:none}input[type=checkbox]:checked:before{content:"\f147";margin:-3px 0 0 -4px;color:#1e8cbe}input[type=radio]:checked:before{content:"\2022";text-indent:-9999px;border-radius:50px;font-size:24px;width:6px;height:6px;margin:4px;line-height:16px;background-color:#1e8cbe}@-moz-document url-prefix(){.form-table input.tog,input[type=radio],input[type=checkbox]{margin-bottom:-1px}}input[type=search]{-webkit-appearance:textfield}input[type=search]::-webkit-search-decoration{display:none}.ie8 input[type=password]{font-family:sans-serif}button,input,select,textarea{font-family:inherit;font-size:inherit;font-weight:inherit}input,select,textarea{font-size:14px;border-radius:0}textarea{padding:2px 6px;line-height:1.4;resize:vertical}.wp-admin input[type=file]{padding:3px 0;cursor:pointer}label{cursor:pointer}input,select{margin:1px;padding:3px 5px}input.code{padding-top:6px}textarea.code{line-height:1.4;padding:4px 6px 1px}input.readonly,input[readonly],textarea.readonly,textarea[readonly]{background-color:#eee}::-webkit-input-placeholder{color:#72777c}::-moz-placeholder{color:#72777c;opacity:1}:-ms-input-placeholder{color:#72777c}.form-invalid input,.form-invalid input:focus,.form-invalid select,.form-invalid select:focus{border-color:#dc3232!important;box-shadow:0 0 2px rgba(204,0,0,.8)}.form-table .form-required.form-invalid td:after{content:"\f534";font:400 20px/1 dashicons;color:#dc3232;margin-left:-25px;vertical-align:middle}.form-table .form-required.user-pass1-wrap.form-invalid td:after{content:''}.form-table .form-required.user-pass1-wrap.form-invalid .password-input-wrapper:after{content:'\f534';font:400 20px/1 dashicons;color:#dc3232;margin:0 6px 0 -29px;vertical-align:middle}.form-input-tip{color:#666}input.disabled,input:disabled,select.disabled,select:disabled,textarea.disabled,textarea:disabled{background:rgba(255,255,255,.5);border-color:rgba(222,222,222,.75);box-shadow:inset 0 1px 2px rgba(0,0,0,.04);color:rgba(51,51,51,.5)}input[type=file].disabled,input[type=file]:disabled,input[type=range].disabled,input[type=range]:disabled{background:0 0;box-shadow:none;cursor:default}input[type=radio].disabled,input[type=radio].disabled:checked:before,input[type=radio]:disabled,input[type=radio]:disabled:checked:before,input[type=checkbox].disabled,input[type=checkbox].disabled:checked:before,input[type=checkbox]:disabled,input[type=checkbox]:disabled:checked:before{opacity:.7}.wp-admin select{padding:2px;line-height:28px;height:28px}.wp-admin .button-cancel{padding:0 5px;line-height:2}.meta-box-sortables select{max-width:100%}.wp-admin select[multiple]{height:auto}.submit{padding:1.5em 0;margin:5px 0;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border:none}p.submit{text-align:left;max-width:100%;margin-top:20px;padding-top:10px}.textright p.submit{border:none;text-align:right}table.form-table+input+input+p.submit,table.form-table+input+p.submit,table.form-table+p.submit{border-top:none;padding-top:0}#major-publishing-actions input,#minor-publishing-actions .preview,#minor-publishing-actions input{text-align:center}input.all-options,textarea.all-options{width:250px}input.large-text,textarea.large-text{width:99%}.regular-text{width:25em}input.small-text{width:50px;padding:1px 6px}input[type=number].small-text{width:65px}input.tiny-text{width:35px}input[type=number].tiny-text{width:45px}#doaction,#doaction2,#post-query-submit{margin:1px 8px 0 0}.tablenav #changeit,.tablenav #clear-recent-list,.tablenav #delete_all,.wp-filter #delete_all{margin-top:1px}.tablenav .actions select{float:left;margin-right:6px;max-width:200px}.ie8 .tablenav .actions select{width:155px}.ie8 .tablenav .actions select#cat{width:200px}#timezone_string option{margin-left:1em}button.wp-hide-pw>.dashicons{position:relative;top:3px}.options-media-php [for*="_size_"]{min-width:10em;vertical-align:baseline}.options-media-php .small-text[name*="_size_"]{margin:0 0 1em}#misc-publishing-actions label{vertical-align:baseline}#pass-strength-result{background-color:#eee;border:1px solid #ddd;color:#23282d;margin:-2px 5px 5px 1px;padding:3px 5px;text-align:center;width:25em;opacity:0}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass1-text.short,#pass1.short{border-color:#e35b5b}#pass1-text.bad,#pass1.bad{border-color:#f78b53}#pass1-text.good,#pass1.good{border-color:#ffc733}#pass1-text.strong,#pass1.strong{border-color:#83c373}.indicator-hint{padding-top:8px}.show-password #pass1-text{display:inline-block}.form-table span.description.important{font-size:12px}p.search-box{float:right;margin:0}.network-admin.themes-php p.search-box{clear:left}.search-box input[name="s"],.tablenav .search-plugins input[name="s"],.tagsdiv .newtag{float:left;height:28px;margin:0 4px 0 0}.js.plugins-php .search-box .wp-filter-search{margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5;padding:3px 5px;height:32px}input[type=text].ui-autocomplete-loading,input[type=email].ui-autocomplete-loading{background-image:url(../images/loading.gif);background-repeat:no-repeat;background-position:right center;visibility:visible}input.ui-autocomplete-input.open{border-bottom-color:transparent}ul#add-to-blog-users{margin:0 0 0 14px}.ui-autocomplete{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete li{margin-bottom:0;padding:4px 10px;white-space:nowrap;text-align:left;cursor:pointer}.ui-autocomplete .ui-state-focus{background-color:#ddd}.wp-tags-autocomplete .ui-state-focus{background-color:#0073aa;color:#fff}.form-table{border-collapse:collapse;margin-top:.5em;width:100%;clear:both}.form-table,.form-table td,.form-table td p,.form-table th{font-size:14px}.form-table td{margin-bottom:9px;padding:15px 10px;line-height:1.3;vertical-align:middle}.form-table th,.form-wrap label{color:#23282d;font-weight:400;text-shadow:none;vertical-align:baseline}.form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;width:200px;line-height:1.3;font-weight:600}.form-table .td-full,.form-table th.th-full{width:auto;padding:20px 10px 20px 0;font-weight:400}.form-table td p{margin-top:4px;margin-bottom:0}.form-table .date-time-doc{margin-top:1em}.form-table p.timezone-info{margin:1em 0}.form-table td fieldset label{margin:.25em 0 .5em!important;display:inline-block}.form-table td fieldset label,.form-table td fieldset li,.form-table td fieldset p{line-height:1.4em}.form-table input.tog,.form-table input[type=radio]{margin-top:-4px;margin-right:4px;float:none}.form-table .pre{padding:8px;margin:0}table.form-table td .updated{font-size:13px}table.form-table td .updated p{font-size:13px;margin:.3em 0}#profile-page .form-table textarea{width:500px;margin-bottom:6px}#profile-page .form-table #rich_editing{margin-right:5px}#your-profile legend{font-size:22px}#display_name{width:15em}#adduser .form-field input,#createuser .form-field input{width:25em}.color-option{display:inline-block;width:24%;padding:5px 15px 15px;margin-bottom:3px;cursor:pointer}.color-option.selected,.color-option:hover{background:#ddd}.color-palette{width:100%;border-spacing:0;border-collapse:collapse}.color-palette td{height:20px;padding:0;border:none}.tool-box .title{margin:8px 0;font-size:18px;font-weight:400;line-height:24px}.label-responsive{vertical-align:middle}#export-filters p{margin:0 0 1em}#export-filters p.submit{margin:7px 0 5px}.card{position:relative;margin-top:20px;padding:.7em 2em 1em;min-width:255px;max-width:520px;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff}.pressthis h4{margin:2em 0 1em}.pressthis textarea{width:100%;font-size:1em}.login form,.login h1 a{overflow:hidden;font-weight:400}.pressthis-bookmarklet-wrapper{margin:20px 0 8px;vertical-align:top;position:relative;z-index:1}.pressthis-bookmarklet,.pressthis-bookmarklet:active,.pressthis-bookmarklet:focus,.pressthis-bookmarklet:hover{display:inline-block;position:relative;cursor:move;color:#32373c;background:#e5e5e5;border-radius:5px;border:1px solid #b4b9be;font-style:normal;line-height:16px;font-size:14px;text-decoration:none}.privacy_requests tbody th,.privacy_requests tfoot td:first-child,.privacy_requests thead td:first-child{border-left:4px solid #fff}.pressthis-bookmarklet:active{outline:0}.pressthis-bookmarklet:after{content:"";width:70%;height:55%;z-index:-1;position:absolute;right:10px;bottom:9px;background:0 0;-webkit-transform:skew(20deg) rotate(6deg);transform:skew(20deg) rotate(6deg);box-shadow:0 10px 8px rgba(0,0,0,.6)}.pressthis-bookmarklet:hover:after{-webkit-transform:skew(20deg) rotate(9deg);transform:skew(20deg) rotate(9deg);box-shadow:0 10px 8px rgba(0,0,0,.7)}.pressthis-bookmarklet span{display:inline-block;margin:0;padding:0 12px 8px 9px}.pressthis-bookmarklet span:before{color:#72777c;font:400 20px/1 dashicons;content:"\f157";position:relative;display:inline-block;top:4px;margin-right:4px}.pressthis-js-toggle,.pressthis-js-toggle.button.button{margin-left:10px;padding:0;height:auto;vertical-align:top}.pressthis-js-toggle .dashicons{margin:5px 8px 6px 7px;color:#555d66}.timezone-info code{white-space:nowrap}.defaultavatarpicker .avatar{margin:2px 0;vertical-align:middle}.options-general-php .date-time-text{display:inline-block;min-width:10em}.options-general-php input.small-text{width:56px}.options-general-php .spinner{float:none;margin:-3px 3px 0}.options-general-php .language-install-spinner,.settings-php .language-install-spinner{display:inline-block;float:none;margin:-3px 5px 0;vertical-align:middle}.form-table.permalink-structure .available-structure-tags li{float:left;margin-right:5px}.setup-php textarea{max-width:100%}.form-field #site-address{max-width:25em}.form-field #domain{max-width:22em}.form-field #admin-email,.form-field #blog_last_updated,.form-field #blog_registered,.form-field #path,.form-field #site-title{max-width:25em}.form-field #path{margin-bottom:5px}#search-sites,#search-users{max-width:100%}.request-filesystem-credentials-dialog{display:none;visibility:visible}.request-filesystem-credentials-dialog .notification-dialog{top:10%;max-height:85%}.request-filesystem-credentials-dialog-content{margin:25px}#request-filesystem-credentials-title{font-size:1.3em;margin:1em 0}.request-filesystem-credentials-form legend{font-size:1em;padding:1.33em 0 0;font-weight:600}.request-filesystem-credentials-form input[type=text],.request-filesystem-credentials-form input[type=password]{display:block}.request-filesystem-credentials-dialog input[type=text],.request-filesystem-credentials-dialog input[type=password]{width:100%}.request-filesystem-credentials-form .field-title{font-weight:600}.request-filesystem-credentials-dialog label[for=hostname],.request-filesystem-credentials-dialog label[for=public_key],.request-filesystem-credentials-dialog label[for=private_key]{display:block;margin-bottom:1em}.request-filesystem-credentials-dialog .request-filesystem-credentials-action-buttons{text-align:right}.login #pass-strength-result,.login h1,.privacy_requests .column-type{text-align:center}.request-filesystem-credentials-dialog label[for=ftp]{margin-right:10px}.request-filesystem-credentials-dialog #auth-keys-desc{margin-bottom:0}#request-filesystem-credentials-dialog .button:not(:last-child){margin-right:10px}#request-filesystem-credentials-form .cancel-button{display:none}#request-filesystem-credentials-dialog .cancel-button{display:inline}.request-filesystem-credentials-dialog .ftp-password,.request-filesystem-credentials-dialog .ftp-username{float:none;width:auto}.request-filesystem-credentials-dialog .ftp-username{margin-bottom:1em}.request-filesystem-credentials-dialog .ftp-password{margin:0}.request-filesystem-credentials-dialog .ftp-password em{color:#888}.request-filesystem-credentials-dialog label{display:block;line-height:1.5;margin-bottom:1em}.request-filesystem-credentials-form #ssh-keys legend{font-size:1.3em}.request-filesystem-credentials-form .notice{margin:0 0 20px;clear:both}.tools-privacy-policy-page form{margin-bottom:1.3em}.tools-privacy-policy-page input.button,.tools-privacy-policy-page select{margin-left:6px}.tools-privacy-edit{margin:1.5em 0}.tools-privacy-policy-page span{line-height:2em}.privacy_requests .column-email{width:40%}.privacy_requests tbody th{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results th{box-shadow:none}.privacy_requests tbody .request-results th .notice{margin:0 0 5px}.privacy_requests tbody td{background:#fff;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.privacy_requests tbody .has-request-results td{box-shadow:none}.privacy_requests .next_steps .button{height:auto;line-height:1.5;padding:4px 10px;word-break:break-all;white-space:unset}.privacy_requests .status-request-confirmed td,.privacy_requests .status-request-confirmed th{background-color:#f7fcfe;border-left-color:#00a0d2}.privacy_requests .status-request-failed td,.privacy_requests .status-request-failed th{background-color:#fef7f1;border-left-color:#d64d21}.privacy_requests .export_personal_data_failed a{vertical-align:baseline}.status-label{font-weight:700}.status-label.status-request-pending{font-weight:400;font-style:italic;color:#6c7781}.status-label.status-request-failed{color:#a00;font-weight:700}.wp-privacy-request-form{clear:both}.wp-privacy-request-form-field{margin:1.5em 0}.wp-privacy-request-form label{font-weight:700;line-height:1.5;padding-bottom:.5em;display:block}.wp-privacy-request-form input{line-height:1.5;margin:0}.email-personal-data::before{display:inline-block;font:400 20px/1 dashicons;margin:3px 5px 0 -2px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.email-personal-data--sending::before{color:#f56e28;content:"\f463";-webkit-animation:rotation 2s infinite linear;animation:rotation 2s infinite linear}.email-personal-data--sent::before{color:#79ba49;content:"\f147"}@media screen and (max-width:782px){#pass-strength-result,.form-table{box-sizing:border-box}textarea{-webkit-appearance:none}input[type=text],input[type=search],input[type=password],input[type=email],input[type=number]{-webkit-appearance:none;padding:6px 10px}input[type=number]{height:40px}input.code{padding-bottom:5px;padding-top:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox],input[type=checkbox]{-webkit-appearance:none;padding:10px}.widefat tfoot td input[type=checkbox],.widefat th input[type=checkbox],.widefat thead td input[type=checkbox]{margin-bottom:8px}.widefat tfoot td input[type=checkbox]:before,.widefat th input[type=checkbox]:before,.widefat thead td input[type=checkbox]:before,input[type=checkbox]:checked:before{font:400 30px/1 dashicons;margin:-3px -5px}input[type=radio],input[type=checkbox]{height:25px;width:25px}.wp-admin p input[type=radio],.wp-admin p input[type=checkbox]{margin-top:-3px}input[type=radio]:checked:before{vertical-align:middle;width:9px;height:9px;margin:7px;line-height:16px}.wp-upload-form input[type=submit]{margin-top:10px}#wpbody select{height:36px;font-size:16px}.wp-admin .button-cancel{padding:0;font-size:14px}#adduser .form-field input,#createuser .form-field input{width:100%}.form-table td,.form-table th,.label-responsive{display:block;width:auto;vertical-align:middle}.label-responsive{margin:.5em 0}.export-filters li{margin-bottom:0}.form-table .color-palette td{display:table-cell;width:15px}.form-table table.color-palette{margin-right:10px}input,textarea{font-size:16px}#profile-page .form-table textarea,.form-table span.description,.form-table td input[type=text],.form-table td input[type=password],.form-table td input[type=email],.form-table td select,.form-table td textarea{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block;max-width:none;box-sizing:border-box}.form-table .form-required.form-invalid td:after{float:right;margin:-30px 3px 0 0}#wpbody .form-table td select{height:40px}.form-table input[type=text].small-text,input[type=text].small-text,input[type=search].small-text,input[type=password].small-text,input[type=number].small-text{width:auto;max-width:4.375em;display:inline;padding:3px 6px;margin:0 3px}#pass-strength-result{width:100%;padding:8px}p.search-box{float:none;position:absolute;bottom:0;width:98%;height:90px;margin-bottom:20px}p.search-box input[name="s"]{height:auto;float:none;width:100%;margin-bottom:10px;vertical-align:middle;-webkit-appearance:none}p.search-box input[type=submit]{margin-bottom:10px}.form-table span.description{display:inline;padding:4px 0 0;line-height:1.4em;font-size:14px}.form-table th{padding-top:10px;padding-bottom:0;border-bottom:0}.form-table td{margin-bottom:0;padding-bottom:6px;padding-top:4px;padding-left:0}.form-table.permalink-structure td code{margin-left:32px}.form-table.permalink-structure td input[type=text]{margin-left:32px;margin-top:4px;width:96%}.form-table input.regular-text{width:100%}.form-table label{font-size:14px}.form-table fieldset label{display:block}#local-time,#utc-time{display:block;float:none;margin-top:.5em}.form-field #domain{max-width:none}.wp-pwd{position:relative}.wp-pwd [type=text],.wp-pwd [type=password]{padding-right:40px}.wp-pwd button.button{background:0 0;border:none;box-shadow:none;line-height:2;margin:0;padding:5px 10px;position:absolute;right:0;top:0}.wp-pwd button.button:active,.wp-pwd button.button:focus,.wp-pwd button.button:hover{background:0 0}.wp-pwd .button .text{display:none}.options-general-php input[type=text].small-text{max-width:6.25em;margin:0}.tools-privacy-policy-page form.wp-create-privacy-page{margin-bottom:1em}.tools-privacy-policy-page input#set-page,.tools-privacy-policy-page select{margin:10px 0 0}.tools-privacy-policy-page .wp-create-privacy-page span{display:block;margin-bottom:1em}.tools-privacy-policy-page .wp-create-privacy-page .button{margin-left:0}.wp-list-table.privacy_requests tr:not(.inline-edit-row):not(.no-items) td.column-primary:not(.check-column){display:table-cell}.wp-list-table.privacy_requests.widefat th input,.wp-list-table.privacy_requests.widefat thead td input{margin-left:5px}}.locale-he-il em,.locale-zh-cn #local-time,.locale-zh-cn #utc-time,.locale-zh-cn .form-wrap p,.locale-zh-cn .howto,.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,.locale-zh-cn .inline-edit-row fieldset span.title,.locale-zh-cn .js .input-with-default-title,.locale-zh-cn .link-to-original,.locale-zh-cn .tablenav .displaying-num,.locale-zh-cn p.description,.locale-zh-cn p.help,.locale-zh-cn p.install-help,.locale-zh-cn span.description{font-style:normal}@media only screen and (max-width:768px){.form-field input[type=text],.form-field input[type=password],.form-field input[type=email],.form-field select,.form-field textarea{width:99%}.form-wrap .form-field{padding:0}#profile-page .form-table textarea{max-width:400px;width:auto}}.locale-de-de #customize-header-actions .button,.locale-de-de-formal #customize-header-actions .button,.locale-ru-ru #customize-header-actions .button{padding:0 5px 1px}@media only screen and (max-height:480px),screen and (max-width:450px){.file-editor-warning .notification-dialog,.request-filesystem-credentials-dialog .notification-dialog{width:100%;height:100%;max-height:100%;position:fixed;top:0;margin:0;left:0}}@media screen and (max-width:600px){.color-option{width:49%}}@media only screen and (max-width:320px){.options-general-php .date-time-text.date-time-custom-text{min-width:0;margin-right:.5em}}@-webkit-keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes rotation{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}body.rtl,body.rtl .press-this a.wp-switch-editor{font-family:Tahoma,Arial,sans-serif}.rtl h1,.rtl h2,.rtl h3,.rtl h4,.rtl h5,.rtl h6{font-family:Arial,sans-serif;font-weight:600}body.locale-he-il,body.locale-he-il .press-this a.wp-switch-editor{font-family:Arial,sans-serif}.locale-he-il em{font-weight:600}.locale-zh-cn .hdnle a{font-size:12px}.locale-zh-cn form.upgrade .hint{font-style:normal;font-size:100%}.locale-zh-cn #sort-buttons{font-size:1em!important}.locale-de-de #customize-header-actions .spinner,.locale-de-de-formal #customize-header-actions .spinner{margin:16px 3px 0}.locale-ru-ru #adminmenu{width:inherit}.locale-ru-ru #adminmenu,.locale-ru-ru #wpbody{margin-left:0}.locale-ru-ru .inline-edit-row fieldset label span.title,.locale-ru-ru .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-left:8em}.locale-ru-ru.post-new-php .tagsdiv .newtag,.locale-ru-ru.post-php .tagsdiv .newtag{width:165px}.locale-ru-ru.press-this .posting{margin-right:277px}.locale-ru-ru .press-this-sidebar{width:265px}.locale-ru-ru #customize-header-actions .spinner{margin:16px 3px 0}.locale-lt-lt .inline-edit-row fieldset label span.title,.locale-lt-lt .inline-edit-row fieldset.inline-edit-date legend{width:8em}.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap{margin-left:8em}@media screen and (max-width:782px){.locale-lt-lt .inline-edit-row fieldset .timestamp-wrap,.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap,.locale-ru-ru .inline-edit-row fieldset .timestamp-wrap,.locale-ru-ru .inline-edit-row fieldset label span.input-text-wrap{margin-left:0}}body,html{height:100%;margin:0;padding:0}body{background:#f1f1f1;min-width:0;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:13px;line-height:1.4em}a{color:#0073aa;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out;outline:0}a:active,a:hover{color:#00a0d2}a:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.ie8 a:focus{outline:#5b9dd9 solid 1px}p{line-height:1.5}.login #login_error,.login .message,.login .success{border-left:4px solid #00a0d2;padding:12px;margin-left:0;margin-bottom:20px;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.login .success{border-left-color:#46b450}.login #login_error{border-left-color:#dc3232}#loginform p.submit,.login-action-lostpassword p.submit{border:none;margin:-10px 0 20px}.login *{margin:0;padding:0}.login .password-input-wrapper{display:table}.login .input.password-input{display:table-cell;margin:0}.login .pw-weak{margin-bottom:15px}.login .button.button-secondary{display:table-cell;border-radius:0;vertical-align:middle}.login form{margin-top:20px;margin-left:0;padding:26px 24px 46px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13)}.login form .forgetmenot{font-weight:400;float:left;margin-bottom:0}.login .button-primary{float:right}#login form p{margin-bottom:0}#login form p.submit{margin:0;padding:0}.login label{color:#72777c;font-size:14px}.login form .forgetmenot label{font-size:12px;line-height:19px}.login h1 a{background-image:url(../images/w-logo-blue.png?ver=20131202);background-image:none,url(../images/wordpress-logo.svg?ver=20131107);background-size:84px;background-position:center top;background-repeat:no-repeat;color:#444;height:84px;font-size:20px;line-height:1.3em;margin:0 auto 25px;padding:0;width:84px;text-indent:-9999px;outline:0;display:block}#login{width:320px;padding:8% 0 0;margin:auto}.login #backtoblog,.login #nav{font-size:13px;padding:0 24px}.login #nav{margin:24px 0 0}#backtoblog{margin:16px 0}.login #backtoblog a,.login #nav a{text-decoration:none;color:#555d66}.login #backtoblog a:hover,.login #nav a:hover,.login h1 a:hover{color:#00a0d2}.login #backtoblog a:focus,.login #nav a:focus,.login h1 a:focus{color:#124964}.login .privacy-policy-page-link{text-align:center;width:100%;margin:5em 0 2em}.login form .input,.login input[type=text]{font-size:24px;width:100%;padding:3px;margin:2px 6px 16px 0}.login form .input,.login form input[type=checkbox],.login input[type=text]{background:#fbfbfb}.ie7 .login form .input,.ie8 .login form .input{font-family:sans-serif}.login-action-rp input[type=text]{box-shadow:none;margin:0}.login #pass-strength-result{font-weight:600;margin:-1px 5px 16px 0;padding:6px 5px;width:100%}body.interim-login{height:auto}.interim-login #login{padding:0;margin:5px auto 20px}.interim-login.login h1 a{width:auto}.interim-login #login_error,.interim-login.login .message{margin:0 0 16px}.interim-login.login form{margin:0}@-ms-viewport{width:device-width}@media screen and (max-height:550px){#login{padding:20px 0}}@media screen and (max-width:782px){.interim-login input[type=checkbox]{height:16px;width:16px}.interim-login input[type=checkbox]:checked:before{width:16px;font:400 21px/1 dashicons;margin:-3px 0 0 -4px}} \ No newline at end of file diff --git a/backend/wp-admin/css/media-rtl.css b/backend/wp-admin/css/media-rtl.css new file mode 100644 index 0000000..eb7a65d --- /dev/null +++ b/backend/wp-admin/css/media-rtl.css @@ -0,0 +1,1270 @@ +/*------------------------------------------------------------------------------ + 14.0 - Media Screen +------------------------------------------------------------------------------*/ + +.media-item .describe { + border-collapse: collapse; + width: 100%; + border-top: 1px solid #ddd; + clear: both; + cursor: default; +} + +.media-item.media-blank .describe { + border: 0; +} + +.media-item .describe th { + vertical-align: top; + text-align: right; + padding: 5px 10px 10px; + width: 140px; +} + +.media-item .describe .align th { + padding-top: 0; +} + +.media-item .media-item-info tr { + background-color: transparent; +} + +.media-item .describe td { + padding: 0 0 8px 8px; + vertical-align: top; +} + +.media-item thead.media-item-info td { + padding: 4px 10px 0; +} + +.media-item .media-item-info .A1B1 { + padding: 0 10px 0 0; +} + +.media-item td.savesend { + padding-bottom: 15px; +} + +.media-item .thumbnail { + max-height: 128px; + max-width: 128px; +} + +#wpbody-content #async-upload-wrap a { + display: none; +} + +.media-upload-form { + margin-top: 20px; +} + +.media-upload-form td label { + margin-left: 6px; + margin-right: 2px; +} + +.media-upload-form .align .field label { + display: inline; + padding: 0 23px 0 0; + margin: 0 3px 0 1em; + font-weight: 600; +} + +.media-upload-form tr.image-size label { + margin: 0 5px 0 0; + font-weight: 600; +} + +.media-upload-form th.label label { + font-weight: 600; + margin: 0.5em; + font-size: 13px; +} + +.media-upload-form th.label label span { + padding: 0 5px; +} + +.media-item .describe input[type="text"], +.media-item .describe textarea { + width: 460px; +} + +.media-item .describe p.help { + margin: 0; + padding: 0 5px 0 0; +} + +.media-item .edit-attachment, +.describe-toggle-on, +.describe-toggle-off { + display: block; + line-height: 36px; + float: left; + margin-left: 10px; +} + +.media-item .describe-toggle-off, +.media-item.open .describe-toggle-on { + display: none; +} + +.media-item.open .describe-toggle-off { + display: block; +} + +.media-upload-form .media-item { + min-height: 36px; + margin-bottom: 1px; + position: relative; + width: 100%; + background: #fff; +} + +.media-upload-form .media-item, +.media-upload-form .media-item .error { + box-shadow: 0 1px 0 #ddd; +} + +#media-items:empty { + border: 0 none; +} + +.media-item .filename { + line-height: 36px; + overflow: hidden; + margin-right: 6px; +} + +.media-item .pinkynail { + float: right; + margin: 2px 3px 0 10px; + max-width: 40px; + max-height: 32px; +} + +.media-item .startopen, +.media-item .startclosed { + display: none; +} + +.media-item .original { + position: relative; + height: 34px; +} + +.media-item .progress { + float: left; + height: 22px; + margin: 7px 6px; + width: 200px; + line-height: 2em; + padding: 0; + overflow: hidden; + border-radius: 22px; + background: #ddd; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); +} + +.media-item .bar { + z-index: 9; + width: 0; + height: 100%; + margin-top: -22px; + border-radius: 22px; + background-color: #0073aa; + box-shadow: inset 0 0 2px rgba(0,0,0,0.3); +} + +.media-item .progress .percent { + z-index: 10; + position: relative; + width: 200px; + padding: 0; + color: #fff; + text-align: center; + line-height: 22px; + font-weight: 400; + text-shadow: 0 1px 2px rgba(0,0,0,0.2); +} + +.upload-php .fixed .column-parent { + width: 15%; +} + +.js .html-uploader #plupload-upload-ui { + display: none; +} + +.js .html-uploader #html-upload-ui { + display: block; +} + +.media-upload-form .media-item.error, +.media-upload-form .media-item .error { + width: auto; + margin: 0 0 1px 0; +} + +.media-upload-form .media-item .error { + padding: 10px 14px 10px 0; +} + +.media-item .error-div a.dismiss { + display: block; + float: left; + margin: 0 15px 0 10px; +} + +/*------------------------------------------------------------------------------ + 14.1 - Media Library +------------------------------------------------------------------------------*/ + +.find-box { + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + width: 600px; + overflow: hidden; + margin-right: -300px; + position: fixed; + top: 30px; + bottom: 30px; + right: 50%; + z-index: 100105; +} + +.find-box-head { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + padding: 0 16px 0 36px; + position: absolute; + top: 0; + right: 0; + left: 0; +} + +.find-box-inside { + overflow: auto; + padding: 16px; + background-color: #fff; + position: absolute; + top: 37px; + bottom: 45px; + overflow-y: scroll; + width: 100%; + box-sizing: border-box; +} + +.find-box-search { + padding-bottom: 16px; +} + +.find-box-search .spinner { + float: none; + right: 105px; + position: absolute; +} + +.find-box-search, +#find-posts-response { + position: relative; /* RTL fix, #WP28010 */ +} + +#find-posts-input, +#find-posts-search { + float: right; +} + +#find-posts-input { + width: 140px; + height: 28px; + margin: 0 0 0 4px; +} + +.widefat .found-radio { + padding-left: 0; + width: 16px; +} + +#find-posts-close { + width: 36px; + height: 36px; + border: none; + padding: 0; + position: absolute; + top: 0; + left: 0; + cursor: pointer; + text-align: center; + background: none; + color: #666; +} + +#find-posts-close:hover, +#find-posts-close:focus { + color: #00a0d2; +} + +#find-posts-close:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#find-posts-close:before { + font: normal 20px/36px dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + content: "\f158"; +} + +.find-box-buttons { + padding: 8px 16px; + background: #fcfcfc; + border-top: 1px solid #ddd; + position: absolute; + bottom: 0; + right: 0; + left: 0; +} + +@media screen and ( max-width: 782px ) { + .find-box-inside { + bottom: 57px; + } +} + +@media screen and ( max-width: 660px ) { + + .find-box { + top: 0; + bottom: 0; + right: 0; + left: 0; + margin: 0; + width: 100%; + } + +} + +.ui-find-overlay { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100100; +} + +ul#dismissed-updates { + display: none; +} + +form.upgrade { + margin-top: 8px; +} + +form.upgrade .hint { + font-style: italic; + font-size: 85%; + margin: -0.5em 0 2em 0; +} + +#poststuff .inside .the-tagcloud { + margin: 5px 0 10px; + padding: 8px; + border: 1px solid #ddd; + line-height: 1.8em; + word-spacing: 3px; +} + +.drag-drop #drag-drop-area { + border: 4px dashed #b4b9be; + height: 200px; +} + +.drag-drop .drag-drop-inside { + margin: 70px auto 0; + width: 250px; +} + +.drag-drop-inside p { + color: #a0a5aa; + font-size: 14px; + margin: 5px 0; + display: none; +} + +.drag-drop .drag-drop-inside p { + text-align: center; +} + +.drag-drop-inside p.drag-drop-info { + font-size: 20px; +} + +.drag-drop .drag-drop-inside p, +.drag-drop-inside p.drag-drop-buttons { + display: block; +} + +/* +#drag-drop-area:-moz-drag-over { + border-color: #83b4d8; +} +border color while dragging a file over the uploader drop area */ +.drag-drop.drag-over #drag-drop-area { + border-color: #83b4d8; +} + +#plupload-upload-ui { + position: relative; +} + +/** + * Media Library grid view + */ + +.media-frame.mode-grid, +.media-frame.mode-grid .media-frame-content, +.media-frame.mode-grid .attachments-browser .attachments, +.media-frame.mode-grid .uploader-inline-content { + position: static; +} + +/* Regions we don't use at all */ +.media-frame.mode-grid .media-frame-title, +.media-frame.mode-grid .media-frame-router, +.media-frame.mode-grid .media-frame-menu { + display: none; +} + +.media-frame.mode-grid .media-frame-content { + background-color: transparent; + border: none; +} + +.upload-php .mode-grid .media-sidebar { + position: relative; + width: auto; + margin-top: 12px; + padding: 0 16px; + border-right: 4px solid #dd3d36; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); + background-color: #fff; +} + +.upload-php .mode-grid .hide-sidebar .media-sidebar { + display: none; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status { + border-bottom: none; + padding-bottom: 0; + max-width: 100%; +} + +.upload-php .mode-grid .media-sidebar .upload-error { + margin: 12px 0; + padding: 4px 0 0; + border: none; + box-shadow: none; + background: none; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors { + top: -10px; + left: -14px; + padding: 10px; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:before { + content: "\f153"; + display: block; + font: normal 16px/1 dashicons; + color: #72777c; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before, +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before { + color: #c00; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h3, /* Back-compat for pre-4.4 */ +.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h2 { + display: none; +} + +.media-frame.mode-grid .uploader-inline { + position: relative; + top: auto; + left: auto; + right: auto; + bottom: auto; + padding-top: 0; + margin-top: 20px; + border: 4px dashed #b4b9be; +} + +.media-frame.mode-select .attachments-browser.fixed .attachments { + position: relative; + top: 94px; /* prevent jumping up when the toolbar becomes fixed */ + padding-bottom: 94px; /* offset for above so the bottom doesn't get cut off */ +} + +.media-frame.mode-grid .attachment:focus, +.media-frame.mode-grid .selected.attachment:focus, +.media-frame.mode-grid .attachment.details:focus { + box-shadow: + inset 0 0 2px 3px #f1f1f1, + inset 0 0 0 7px #5b9dd9; + outline: none; +} + +.media-frame.mode-grid .selected.attachment { + box-shadow: + inset 0 0 0 5px #f1f1f1, + inset 0 0 0 7px #ccc; +} + +.media-frame.mode-grid .attachment.details { + box-shadow: + inset 0 0 0 3px #f1f1f1, + inset 0 0 0 7px #1e8cbe; +} + +.media-frame.mode-grid.mode-select .attachment .thumbnail { + opacity: 0.65; +} + +.media-frame.mode-select .attachment.selected .thumbnail { + opacity: 1; +} + +.media-frame.mode-grid .media-toolbar { + margin-bottom: 15px; + height: auto; +} + +.media-frame.mode-grid .media-toolbar select { + margin: 0 0 0 10px; + font-size: 14px; +} + +.media-frame.mode-grid.mode-edit .media-toolbar-secondary > .select-mode-toggle-button { + margin: 0 0 0 8px; + vertical-align: middle; +} + +.media-frame.mode-grid .attachments-browser .bulk-select { + display: inline-block; + margin: 0 0 0 10px; +} + +.media-frame.mode-grid .search { + margin-top: 0; +} + +.media-frame.mode-grid .spinner { + margin-top: 16px; +} + +.attachments-browser .media-toolbar-secondary > .media-button { + margin-left: 10px; +} + +.media-frame.mode-select .attachments-browser.fixed .media-toolbar { + position: fixed; + top: 32px; + right: auto; + left: 20px; + margin-top: 0; +} + +.media-frame.mode-grid .attachments-browser { + padding: 0; +} + +.media-frame.mode-grid .attachments-browser .attachments { + padding: 2px; +} + +.media-frame.mode-grid .attachments-browser .no-media { + color: #666; /* same as no plugins and no themes */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0 0; + text-align: center; +} + +/** + * Attachment details modal + */ + +.edit-attachment-frame { + display: block; + height: 100%; + width: 100%; +} + +.edit-attachment-frame .edit-media-header { + overflow: hidden; +} + +.upload-php .media-modal-close .media-modal-icon:before { + content: "\f335"; + font-size: 22px; +} + +.upload-php .media-modal-close, +.edit-attachment-frame .edit-media-header .left, +.edit-attachment-frame .edit-media-header .right { + cursor: pointer; + color: #72777c; + background-color: transparent; + height: 50px; + width: 50px; + padding: 0; + position: absolute; + text-align: center; + border: 0; + border-right: 1px solid #ddd; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.upload-php .media-modal-close { + top: 0; + left: 0; +} + +.edit-attachment-frame .edit-media-header .left { + left: 102px; +} + +.edit-attachment-frame .edit-media-header .right { + left: 51px; +} + +.edit-attachment-frame .media-frame-title { + right: 0; + left: 150px; /* leave space for prev/next/close */ +} + +.edit-attachment-frame .edit-media-header .right:before, +.edit-attachment-frame .edit-media-header .left:before { + font: normal 20px/50px dashicons !important; + display: inline; + font-weight: 300; +} + +.upload-php .media-modal-close:hover, +.upload-php .media-modal-close:focus, +.edit-attachment-frame .edit-media-header .left:hover, +.edit-attachment-frame .edit-media-header .right:hover, +.edit-attachment-frame .edit-media-header .left:focus, +.edit-attachment-frame .edit-media-header .right:focus { + background: #ddd; + border-color: #ccc; + color: #000; + outline: none; + box-shadow: none; +} + +.upload-php .media-modal-close:focus .media-modal-icon:before, +.upload-php .media-modal-close:hover .media-modal-icon:before { + color: #000; +} + +.edit-attachment-frame .edit-media-header .left:before, +.rtl .edit-attachment-frame .edit-media-header .right:before { + content: "\f345"; +} + +.edit-attachment-frame .edit-media-header .right:before, +.rtl .edit-attachment-frame .edit-media-header .left:before { + content: "\f341"; +} + +.edit-attachment-frame .edit-media-header .left.disabled, +.edit-attachment-frame .edit-media-header .right.disabled, +.edit-attachment-frame .edit-media-header .left.disabled:hover, +.edit-attachment-frame .edit-media-header .right.disabled:hover { + color: #ccc; + background: inherit; + cursor: default; + pointer-events: none; +} + +.edit-attachment-frame .media-frame-content, +.edit-attachment-frame .media-frame-router { + right: 0; +} + +.edit-attachment-frame .media-frame-content { + border-bottom: none; + bottom: 0; + top: 50px; +} + +.edit-attachment-frame .attachment-details { + position: absolute; + overflow: auto; + top: 0; + bottom: 0; + left: 0; + right: 0; + box-shadow: inset 0px 4px 4px -4px rgba(0, 0, 0, 0.1); +} + +.edit-attachment-frame .attachment-media-view { + float: right; + width: 65%; + height: 100%; +} + +.edit-attachment-frame .attachment-media-view .thumbnail { + box-sizing: border-box; + padding: 16px; + height: 100%; +} + +.edit-attachment-frame .attachment-media-view .details-image { + display: block; + margin: 0 auto 16px; + max-width: 100%; + max-height: 90%; + max-height: calc( 100% - 42px ); /* leave space for actions underneath */ + background-image: linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 100% 0, 10px 10px; + background-size: 20px 20px; +} + +.edit-attachment-frame .attachment-media-view .attachment-actions { + text-align: center; +} + +.edit-attachment-frame .wp-media-wrapper { + margin-bottom: 12px; +} + +.edit-attachment-frame input, +.edit-attachment-frame textarea { + padding: 6px 8px; + line-height: 16px; +} + +.edit-attachment-frame .attachment-info { + overflow: auto; + box-sizing: border-box; + margin-bottom: 0; + padding: 12px 16px 0; + width: 35%; + height: 100%; + box-shadow: inset 0px 4px 4px -4px rgba(0, 0, 0, 0.1); + border-bottom: 0; + border-right: 1px solid #ddd; + background: #f3f3f3; +} + +.edit-attachment-frame .attachment-info .details, +.edit-attachment-frame .attachment-info .settings { + position: relative; /* RTL fix, #WP29352 */ + overflow: hidden; + float: none; + margin-bottom: 15px; + padding-bottom: 15px; + border-bottom: 1px solid #ddd; +} + +.edit-attachment-frame .attachment-info .filename { + font-weight: 400; + color: #666; +} + +.edit-attachment-frame .attachment-info .thumbnail { + margin-bottom: 12px; +} + +.attachment-info .actions { + margin-bottom: 16px; +} + +.attachment-info .actions a { + display: inline; + text-decoration: none; +} + + +/*------------------------------------------------------------------------------ + 14.2 - Image Editor +------------------------------------------------------------------------------*/ + +.wp_attachment_details label[for="content"] { + font-size: 13px; + line-height: 1.5; + margin: 1em 0; +} + +.wp_attachment_details #attachment_caption { + height: 4em; +} + +.describe .image-editor { + vertical-align: top; +} + +.imgedit-wrap { + position: relative; + padding-top: 10px; +} + +.imgedit-settings p, +.imgedit-settings fieldset { + margin: 8px 0; +} + +.imgedit-settings legend { + margin-bottom: 5px; +} + +.describe .imgedit-wrap .imgedit-settings { + padding: 0 5px; +} + +.wp_attachment_holder div.updated { + margin-top: 0; +} + +.wp_attachment_holder .imgedit-wrap > div { + height: auto; +} + +.wp_attachment_holder .imgedit-wrap .imgedit-panel-content { + padding: 3px 0 0 16px; + float: right; +} + +.wp_attachment_holder .imgedit-wrap .imgedit-settings { + float: left; + width: 250px; +} + +.imgedit-settings input { + margin-top: 0; + vertical-align: middle; +} + +.imgedit-wait { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + background: #fff; + opacity: 0.7; + filter: alpha(opacity=70); + display: none; +} + +.imgedit-wait:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + right: 50%; + top: 50%; + margin: -10px -10px 0 0; + background: transparent url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +.no-float { + float: none; +} + +.media-disabled, +.imgedit-settings .disabled { + /* WCAG 1.4.3 Text or images of text that are part of an inactive user + interface component ... have no contrast requirement. */ + color: #a0a5aa; +} + +.A1B1 { + overflow: hidden; +} + +.wp_attachment_image .button, +.A1B1 .button { + float: right; +} + +.no-js .wp_attachment_image .button { + display: none; +} + +.wp_attachment_image .spinner, +.A1B1 .spinner { + float: right; +} + +.imgedit-menu { + min-width: 300px; + margin: 0 0 12px; +} + +.imgedit-menu .note-no-rotate { + clear: both; + margin: 0; + padding: 1em 0 0; +} + +.image-editor .imgedit-menu .button { + float: right; + width: 32px; + height: 32px; + margin: 0 0 0 8px; + padding: 0; + background: #f1f1f1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 16px; + color: #72777c; +} + +.imgedit-menu .button:before { + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; +} + +.imgedit-menu .button.disabled { + border-color: #ccc; + background-color: #ddd; + color: #72777c; + filter: alpha(opacity=50); + opacity: 0.5; + cursor: default; +} + +.imgedit-crop:before { + content: "\f165"; +} + +.imgedit-rleft:before { + content: "\f166"; +} + +.imgedit-rright:before { + content: "\f167"; +} + +.imgedit-flipv:before { + content: "\f168"; +} + +.imgedit-fliph:before { + content: "\f169"; +} + +.imgedit-undo:before { + content: "\f171"; +} + +.imgedit-redo:before { + content: "\f172"; +} + +.imgedit-crop-wrap { + position: relative; +} + +.imgedit-crop-wrap img { + background-image: linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(-45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 100% 0, 10px 10px; + background-size: 20px 20px; +} + +.imgedit-crop { + margin: 0 0 0 8px; +} + +.imgedit-rleft { + margin: 0 3px; +} + +.imgedit-rright { + margin: 0 3px 0 8px; +} + +.imgedit-flipv { + margin: 0 3px; +} + +.imgedit-fliph { + margin: 0 3px 0 8px; +} + +.imgedit-undo { + margin: 0 3px; +} + +.imgedit-redo { + margin: 0 3px 0 8px; +} + +.imgedit-thumbnail-preview { + margin: 10px 0 0 8px; +} + +.imgedit-thumbnail-preview-caption { + display: block; +} + +#poststuff .imgedit-group-top h3, /* Back-compat for pre-4.4 */ +#poststuff .imgedit-group-top h2 { + display: inline-block; + margin: 0; + padding: 0; + font-size: 14px; + line-height: 1.4; +} + +#poststuff .imgedit-group-top .button-link { + text-decoration: none; + color: #23282d; +} + +.imgedit-applyto .imgedit-label { + display: block; + padding: .5em 0 0; +} + +.imgedit-help { + display: none; + font-style: italic; +} + +/* higher specificity than buttons */ +.image-editor .imgedit-settings .imgedit-help-toggle, +.image-editor .imgedit-settings .imgedit-help-toggle:hover, +.image-editor .imgedit-settings .imgedit-help-toggle:active { + border: 1px solid transparent; + margin: -1px -1px 0 0; + padding: 0; + background: transparent; + color: #0074a2; + font-size: 20px; + line-height: 1; + cursor: pointer; + box-sizing: content-box; + box-shadow: none; +} + +.image-editor .imgedit-settings .imgedit-help-toggle:focus { + color: #0074a2; + border-color: #5b9dd9; + outline: none; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.form-table td.imgedit-response { + padding: 0; +} + +.imgedit-submit { + margin: 8px 0 0; +} + +.imgedit-submit-btn { + margin-right: 20px; +} + +.imgedit-wrap .nowrap { + white-space: nowrap; + font-size: 12px; + line-height: inherit; +} + +span.imgedit-scale-warn { + color: #dc3232; + font-size: 20px; + font-style: normal; + visibility: hidden; + vertical-align: middle; +} + +.imgedit-save-target { + margin: 8px 0; +} + +.imgedit-group { + margin-bottom: 8px; + padding: 10px; +} + +.imgedit-settings .imgedit-scale input[type="text"], +.imgedit-settings .imgedit-crop-ratio input[type="text"], +.imgedit-settings .imgedit-crop-sel input[type="text"] { + width: 50px; + font-size: 14px; + padding: 5px 8px; +} + +.imgedit-separator { + display: inline-block; + width: 7px; + text-align: center; + vertical-align: middle; + font-size: 13px; + color: #444; +} + +.imgedit-settings .imgedit-scale .button { + margin-bottom: 0; +} + +audio, video { + display: inline-block; + max-width: 100%; +} + +.mejs-container { + width: 100%; + max-width: 100%; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .imgedit-wait:before { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + .wp_attachment_details label[for="content"] { + font-size: 14px; + line-height: 1.5em; + } + + .media-upload-form .media-item.error, + .media-upload-form .media-item .error { + font-size: 13px; + line-height: 1.5; + } + + .media-upload-form .media-item.error { + padding: 1px 10px; + } + + .media-upload-form .media-item .error { + padding: 10px 12px 10px 0; + } + + .imgedit-settings .imgedit-scale input[type="text"], + .imgedit-settings .imgedit-crop-ratio input[type="text"], + .imgedit-settings .imgedit-crop-sel input[type="text"] { + width: 60px; + font-size: 16px; + padding: 6px 10px; + } + + .imgedit-applyto .imgedit-label { + vertical-align: middle; + } +} + +/** + * Media queries for media grid. + */ + +@media only screen and (max-width: 1120px) { + /* override for media-views.css */ + #wp-media-grid .wp-filter .attachment-filters { + max-width: 100%; + } +} + +@media only screen and ( max-width: 782px ) { + .media-frame.mode-select .attachments-browser.fixed .media-toolbar { + top: 46px; + left: 10px; + } +} + +@media only screen and (max-width: 600px) { + .media-frame.mode-select .attachments-browser.fixed .media-toolbar { + top: 0; + } +} + +@media only screen and (max-width: 480px) { + .edit-attachment-frame .media-frame-title { + left: 110px; + } + + .upload-php .media-modal-close, + .edit-attachment-frame .edit-media-header .left, + .edit-attachment-frame .edit-media-header .right { + width: 40px; + height: 40px; + } + + .upload-php .media-modal-close .media-modal-icon { + margin: 9px 10px; + } + + .edit-attachment-frame .edit-media-header .right:before, + .edit-attachment-frame .edit-media-header .left:before { + line-height: 40px !important; + } + + .edit-attachment-frame .edit-media-header .left { + left: 82px; + } + + .edit-attachment-frame .edit-media-header .right { + left: 41px; + } + + .edit-attachment-frame .media-frame-content { + top: 40px; + } + + .edit-attachment-frame .attachment-media-view { + float: none; + height: auto; + width: 100%; + } + + .edit-attachment-frame .attachment-info { + height: auto; + width: 100%; + } +} + +@media only screen and (max-width: 640px), screen and (max-height: 400px) { + .upload-php .mode-grid .media-sidebar{ + max-width: 100%; + } +} diff --git a/backend/wp-admin/css/media-rtl.min.css b/backend/wp-admin/css/media-rtl.min.css new file mode 100644 index 0000000..6ac72cc --- /dev/null +++ b/backend/wp-admin/css/media-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.media-item .describe{border-collapse:collapse;width:100%;border-top:1px solid #ddd;clear:both;cursor:default}.media-item.media-blank .describe{border:0}.media-item .describe th{vertical-align:top;text-align:right;padding:5px 10px 10px;width:140px}.media-item .describe .align th{padding-top:0}.media-item .media-item-info tr{background-color:transparent}.media-item .describe td{padding:0 0 8px 8px;vertical-align:top}.media-item thead.media-item-info td{padding:4px 10px 0}.media-item .media-item-info .A1B1{padding:0 10px 0 0}.media-item td.savesend{padding-bottom:15px}.media-item .thumbnail{max-height:128px;max-width:128px}#wpbody-content #async-upload-wrap a{display:none}.media-upload-form{margin-top:20px}.media-upload-form td label{margin-left:6px;margin-right:2px}.media-upload-form .align .field label{display:inline;padding:0 23px 0 0;margin:0 3px 0 1em;font-weight:600}.media-upload-form tr.image-size label{margin:0 5px 0 0;font-weight:600}.media-upload-form th.label label{font-weight:600;margin:.5em;font-size:13px}.media-upload-form th.label label span{padding:0 5px}.media-item .describe input[type=text],.media-item .describe textarea{width:460px}.media-item .describe p.help{margin:0;padding:0 5px 0 0}.describe-toggle-off,.describe-toggle-on,.media-item .edit-attachment{display:block;line-height:36px;float:left;margin-left:10px}.media-item .describe-toggle-off,.media-item.open .describe-toggle-on{display:none}.media-item.open .describe-toggle-off{display:block}.js .html-uploader #plupload-upload-ui,.media-item .startclosed,.media-item .startopen{display:none}.media-upload-form .media-item{min-height:36px;margin-bottom:1px;position:relative;width:100%;background:#fff}.media-upload-form .media-item,.media-upload-form .media-item .error{box-shadow:0 1px 0 #ddd}#media-items:empty{border:0}.media-item .filename{line-height:36px;overflow:hidden;margin-right:6px}.media-item .pinkynail{float:right;margin:2px 3px 0 10px;max-width:40px;max-height:32px}.media-item .original{position:relative;height:34px}.media-item .progress{float:left;height:22px;margin:7px 6px;width:200px;line-height:2em;padding:0;overflow:hidden;border-radius:22px;background:#ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.media-item .bar{z-index:9;width:0;height:100%;margin-top:-22px;border-radius:22px;background-color:#0073aa;box-shadow:inset 0 0 2px rgba(0,0,0,.3)}.media-item .progress .percent{z-index:10;position:relative;width:200px;padding:0;color:#fff;text-align:center;line-height:22px;font-weight:400;text-shadow:0 1px 2px rgba(0,0,0,.2)}.upload-php .fixed .column-parent{width:15%}.js .html-uploader #html-upload-ui{display:block}.media-upload-form .media-item .error,.media-upload-form .media-item.error{width:auto;margin:0 0 1px}.media-upload-form .media-item .error{padding:10px 14px 10px 0}.media-item .error-div a.dismiss{display:block;float:left;margin:0 15px 0 10px}.find-box{background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);width:600px;overflow:hidden;margin-right:-300px;position:fixed;top:30px;bottom:30px;right:50%;z-index:100105}.find-box-head{background:#fcfcfc;border-bottom:1px solid #ddd;height:36px;font-size:18px;font-weight:600;line-height:36px;padding:0 16px 0 36px;position:absolute;top:0;right:0;left:0}.find-box-inside{overflow:auto;padding:16px;background-color:#fff;position:absolute;top:37px;bottom:45px;overflow-y:scroll;width:100%;box-sizing:border-box}.find-box-search{padding-bottom:16px}.find-box-search .spinner{float:none;right:105px;position:absolute}#find-posts-response,.find-box-search{position:relative}#find-posts-input,#find-posts-search{float:right}#find-posts-input{width:140px;height:28px;margin:0 0 0 4px}.widefat .found-radio{padding-left:0;width:16px}#find-posts-close{width:36px;height:36px;border:none;padding:0;position:absolute;top:0;left:0;cursor:pointer;text-align:center;background:0 0;color:#666}#find-posts-close:focus,#find-posts-close:hover{color:#00a0d2}#find-posts-close:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#find-posts-close:before{font:400 20px/36px dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f158"}.find-box-buttons{padding:8px 16px;background:#fcfcfc;border-top:1px solid #ddd;position:absolute;bottom:0;right:0;left:0}@media screen and (max-width:782px){.find-box-inside{bottom:57px}}@media screen and (max-width:660px){.find-box{top:0;bottom:0;right:0;left:0;margin:0;width:100%}}.ui-find-overlay{position:fixed;top:0;right:0;left:0;bottom:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100100}ul#dismissed-updates{display:none}form.upgrade{margin-top:8px}form.upgrade .hint{font-style:italic;font-size:85%;margin:-.5em 0 2em}#poststuff .inside .the-tagcloud{margin:5px 0 10px;padding:8px;border:1px solid #ddd;line-height:1.8em;word-spacing:3px}.drag-drop #drag-drop-area{border:4px dashed #b4b9be;height:200px}.drag-drop .drag-drop-inside{margin:70px auto 0;width:250px}.drag-drop-inside p{color:#a0a5aa;font-size:14px;margin:5px 0;display:none}.drag-drop .drag-drop-inside p{text-align:center}.drag-drop-inside p.drag-drop-info{font-size:20px}.drag-drop .drag-drop-inside p,.drag-drop-inside p.drag-drop-buttons{display:block}.media-frame.mode-grid .media-frame-menu,.media-frame.mode-grid .media-frame-router,.media-frame.mode-grid .media-frame-title,.upload-php .mode-grid .hide-sidebar .media-sidebar{display:none}.drag-drop.drag-over #drag-drop-area{border-color:#83b4d8}#plupload-upload-ui{position:relative}.media-frame.mode-grid,.media-frame.mode-grid .attachments-browser .attachments,.media-frame.mode-grid .media-frame-content,.media-frame.mode-grid .uploader-inline-content{position:static}.media-frame.mode-grid .media-frame-content{background-color:transparent;border:none}.upload-php .mode-grid .media-sidebar{position:relative;width:auto;margin-top:12px;padding:0 16px;border-right:4px solid #dd3d36;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);background-color:#fff}.upload-php .mode-grid .media-sidebar .media-uploader-status{border-bottom:none;padding-bottom:0;max-width:100%}.upload-php .mode-grid .media-sidebar .upload-error{margin:12px 0;padding:4px 0 0;border:none;box-shadow:none;background:0 0}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors{top:-10px;left:-14px;padding:10px}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:before{content:"\f153";display:block;font:400 16px/1 dashicons;color:#72777c}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before,.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before{color:#c00}.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h2,.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h3{display:none}.media-frame.mode-grid .uploader-inline{position:relative;top:auto;left:auto;right:auto;bottom:auto;padding-top:0;margin-top:20px;border:4px dashed #b4b9be}.media-frame.mode-select .attachments-browser.fixed .attachments{position:relative;top:94px;padding-bottom:94px}.media-frame.mode-grid .attachment.details:focus,.media-frame.mode-grid .attachment:focus,.media-frame.mode-grid .selected.attachment:focus{box-shadow:inset 0 0 2px 3px #f1f1f1,inset 0 0 0 7px #5b9dd9;outline:0}.media-frame.mode-grid .selected.attachment{box-shadow:inset 0 0 0 5px #f1f1f1,inset 0 0 0 7px #ccc}.media-frame.mode-grid .attachment.details{box-shadow:inset 0 0 0 3px #f1f1f1,inset 0 0 0 7px #1e8cbe}.media-frame.mode-grid.mode-select .attachment .thumbnail{opacity:.65}.media-frame.mode-select .attachment.selected .thumbnail{opacity:1}.media-frame.mode-grid .media-toolbar{margin-bottom:15px;height:auto}.media-frame.mode-grid .media-toolbar select{margin:0 0 0 10px;font-size:14px}.media-frame.mode-grid.mode-edit .media-toolbar-secondary>.select-mode-toggle-button{margin:0 0 0 8px;vertical-align:middle}.media-frame.mode-grid .attachments-browser .bulk-select{display:inline-block;margin:0 0 0 10px}.media-frame.mode-grid .search{margin-top:0}.media-frame.mode-grid .spinner{margin-top:16px}.attachments-browser .media-toolbar-secondary>.media-button{margin-left:10px}.media-frame.mode-select .attachments-browser.fixed .media-toolbar{position:fixed;top:32px;right:auto;left:20px;margin-top:0}.media-frame.mode-grid .attachments-browser{padding:0}.media-frame.mode-grid .attachments-browser .attachments{padding:2px}.media-frame.mode-grid .attachments-browser .no-media{color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0 0;text-align:center}.edit-attachment-frame{display:block;height:100%;width:100%}.edit-attachment-frame .edit-media-header{overflow:hidden}.upload-php .media-modal-close .media-modal-icon:before{content:"\f335";font-size:22px}.edit-attachment-frame .edit-media-header .left,.edit-attachment-frame .edit-media-header .right,.upload-php .media-modal-close{cursor:pointer;color:#72777c;background-color:transparent;height:50px;width:50px;padding:0;position:absolute;text-align:center;border:0;border-right:1px solid #ddd;transition:color .1s ease-in-out,background .1s ease-in-out}.upload-php .media-modal-close{top:0;left:0}.edit-attachment-frame .edit-media-header .left{left:102px}.edit-attachment-frame .edit-media-header .right{left:51px}.edit-attachment-frame .media-frame-title{right:0;left:150px}.edit-attachment-frame .edit-media-header .left:before,.edit-attachment-frame .edit-media-header .right:before{font:400 20px/50px dashicons!important;display:inline;font-weight:300}.edit-attachment-frame .edit-media-header .left:focus,.edit-attachment-frame .edit-media-header .left:hover,.edit-attachment-frame .edit-media-header .right:focus,.edit-attachment-frame .edit-media-header .right:hover,.upload-php .media-modal-close:focus,.upload-php .media-modal-close:hover{background:#ddd;border-color:#ccc;color:#000;outline:0;box-shadow:none}.upload-php .media-modal-close:focus .media-modal-icon:before,.upload-php .media-modal-close:hover .media-modal-icon:before{color:#000}.edit-attachment-frame .edit-media-header .left:before,.rtl .edit-attachment-frame .edit-media-header .right:before{content:"\f345"}.edit-attachment-frame .edit-media-header .right:before,.rtl .edit-attachment-frame .edit-media-header .left:before{content:"\f341"}.edit-attachment-frame .edit-media-header .left.disabled,.edit-attachment-frame .edit-media-header .left.disabled:hover,.edit-attachment-frame .edit-media-header .right.disabled,.edit-attachment-frame .edit-media-header .right.disabled:hover{color:#ccc;background:inherit;cursor:default;pointer-events:none}.edit-attachment-frame .media-frame-content,.edit-attachment-frame .media-frame-router{right:0}.edit-attachment-frame .media-frame-content{border-bottom:none;bottom:0;top:50px}.edit-attachment-frame .attachment-details{position:absolute;overflow:auto;top:0;bottom:0;left:0;right:0;box-shadow:inset 0 4px 4px -4px rgba(0,0,0,.1)}.edit-attachment-frame .attachment-media-view{float:right;width:65%;height:100%}.edit-attachment-frame .attachment-media-view .thumbnail{box-sizing:border-box;padding:16px;height:100%}.edit-attachment-frame .attachment-media-view .details-image{display:block;margin:0 auto 16px;max-width:100%;max-height:90%;max-height:calc(100% - 42px);background-image:linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:100% 0,10px 10px;background-size:20px 20px}.edit-attachment-frame .attachment-media-view .attachment-actions{text-align:center}.edit-attachment-frame .wp-media-wrapper{margin-bottom:12px}.edit-attachment-frame input,.edit-attachment-frame textarea{padding:6px 8px;line-height:16px}.edit-attachment-frame .attachment-info{overflow:auto;box-sizing:border-box;margin-bottom:0;padding:12px 16px 0;width:35%;height:100%;box-shadow:inset 0 4px 4px -4px rgba(0,0,0,.1);border-bottom:0;border-right:1px solid #ddd;background:#f3f3f3}.edit-attachment-frame .attachment-info .details,.edit-attachment-frame .attachment-info .settings{position:relative;overflow:hidden;float:none;margin-bottom:15px;padding-bottom:15px;border-bottom:1px solid #ddd}.edit-attachment-frame .attachment-info .filename{font-weight:400;color:#666}.edit-attachment-frame .attachment-info .thumbnail{margin-bottom:12px}.attachment-info .actions{margin-bottom:16px}.attachment-info .actions a{display:inline;text-decoration:none}.wp_attachment_details label[for=content]{font-size:13px;line-height:1.5;margin:1em 0}.wp_attachment_details #attachment_caption{height:4em}.describe .image-editor{vertical-align:top}.imgedit-wrap{position:relative;padding-top:10px}.imgedit-settings fieldset,.imgedit-settings p{margin:8px 0}.imgedit-settings legend{margin-bottom:5px}.describe .imgedit-wrap .imgedit-settings{padding:0 5px}.wp_attachment_holder div.updated{margin-top:0}.wp_attachment_holder .imgedit-wrap>div{height:auto}.wp_attachment_holder .imgedit-wrap .imgedit-panel-content{padding:3px 0 0 16px;float:right}.wp_attachment_holder .imgedit-wrap .imgedit-settings{float:left;width:250px}.imgedit-settings input{margin-top:0;vertical-align:middle}.imgedit-wait{position:absolute;top:0;bottom:0;width:100%;background:#fff;opacity:.7;filter:alpha(opacity=70);display:none}.imgedit-wait:before{content:"";display:block;width:20px;height:20px;position:absolute;right:50%;top:50%;margin:-10px -10px 0 0;background:url(../images/spinner.gif) center no-repeat;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}.no-float{float:none}.A1B1 .button,.A1B1 .spinner,.wp_attachment_image .button,.wp_attachment_image .spinner{float:right}.imgedit-settings .disabled,.media-disabled{color:#a0a5aa}.A1B1{overflow:hidden}.no-js .wp_attachment_image .button{display:none}.imgedit-menu{min-width:300px;margin:0 0 12px}.imgedit-menu .note-no-rotate{clear:both;margin:0;padding:1em 0 0}.image-editor .imgedit-menu .button{float:right;width:32px;height:32px;margin:0 0 0 8px;padding:0;background:#f1f1f1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:16px;color:#72777c}.imgedit-menu .button:before{font:400 20px/1 dashicons;speak:none;vertical-align:middle}.imgedit-menu .button.disabled{border-color:#ccc;background-color:#ddd;color:#72777c;filter:alpha(opacity=50);opacity:.5;cursor:default}.imgedit-crop:before{content:"\f165"}.imgedit-rleft:before{content:"\f166"}.imgedit-rright:before{content:"\f167"}.imgedit-flipv:before{content:"\f168"}.imgedit-fliph:before{content:"\f169"}.imgedit-undo:before{content:"\f171"}.imgedit-redo:before{content:"\f172"}.imgedit-crop-wrap{position:relative}.imgedit-crop-wrap img{background-image:linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(-45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:100% 0,10px 10px;background-size:20px 20px}.imgedit-crop{margin:0 0 0 8px}.imgedit-rleft{margin:0 3px}.imgedit-rright{margin:0 3px 0 8px}.imgedit-flipv{margin:0 3px}.imgedit-fliph{margin:0 3px 0 8px}.imgedit-undo{margin:0 3px}.imgedit-redo{margin:0 3px 0 8px}.imgedit-thumbnail-preview{margin:10px 0 0 8px}.imgedit-thumbnail-preview-caption{display:block}#poststuff .imgedit-group-top h2,#poststuff .imgedit-group-top h3{display:inline-block;margin:0;padding:0;font-size:14px;line-height:1.4}#poststuff .imgedit-group-top .button-link{text-decoration:none;color:#23282d}.imgedit-applyto .imgedit-label{display:block;padding:.5em 0 0}.imgedit-help{display:none;font-style:italic}.image-editor .imgedit-settings .imgedit-help-toggle,.image-editor .imgedit-settings .imgedit-help-toggle:active,.image-editor .imgedit-settings .imgedit-help-toggle:hover{border:1px solid transparent;margin:-1px -1px 0 0;padding:0;background:0 0;color:#0074a2;font-size:20px;line-height:1;cursor:pointer;box-sizing:content-box;box-shadow:none}.image-editor .imgedit-settings .imgedit-help-toggle:focus{color:#0074a2;border-color:#5b9dd9;outline:0;box-shadow:0 0 3px rgba(0,115,170,.8)}.form-table td.imgedit-response{padding:0}.imgedit-submit{margin:8px 0 0}.imgedit-submit-btn{margin-right:20px}.imgedit-wrap .nowrap{white-space:nowrap;font-size:12px;line-height:inherit}span.imgedit-scale-warn{color:#dc3232;font-size:20px;font-style:normal;visibility:hidden;vertical-align:middle}.imgedit-save-target{margin:8px 0}.imgedit-group{margin-bottom:8px;padding:10px}.imgedit-settings .imgedit-crop-ratio input[type=text],.imgedit-settings .imgedit-crop-sel input[type=text],.imgedit-settings .imgedit-scale input[type=text]{width:50px;font-size:14px;padding:5px 8px}.imgedit-separator{display:inline-block;width:7px;text-align:center;vertical-align:middle;font-size:13px;color:#444}.imgedit-settings .imgedit-scale .button{margin-bottom:0}audio,video{display:inline-block;max-width:100%}.mejs-container{width:100%;max-width:100%}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.imgedit-wait:before{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){.wp_attachment_details label[for=content]{font-size:14px;line-height:1.5em}.media-upload-form .media-item .error,.media-upload-form .media-item.error{font-size:13px;line-height:1.5}.media-upload-form .media-item.error{padding:1px 10px}.media-upload-form .media-item .error{padding:10px 12px 10px 0}.imgedit-settings .imgedit-crop-ratio input[type=text],.imgedit-settings .imgedit-crop-sel input[type=text],.imgedit-settings .imgedit-scale input[type=text]{width:60px;font-size:16px;padding:6px 10px}.imgedit-applyto .imgedit-label{vertical-align:middle}}@media only screen and (max-width:1120px){#wp-media-grid .wp-filter .attachment-filters{max-width:100%}}@media only screen and (max-width:782px){.media-frame.mode-select .attachments-browser.fixed .media-toolbar{top:46px;left:10px}}@media only screen and (max-width:600px){.media-frame.mode-select .attachments-browser.fixed .media-toolbar{top:0}}@media only screen and (max-width:480px){.edit-attachment-frame .media-frame-title{left:110px}.edit-attachment-frame .edit-media-header .left,.edit-attachment-frame .edit-media-header .right,.upload-php .media-modal-close{width:40px;height:40px}.upload-php .media-modal-close .media-modal-icon{margin:9px 10px}.edit-attachment-frame .edit-media-header .left:before,.edit-attachment-frame .edit-media-header .right:before{line-height:40px!important}.edit-attachment-frame .edit-media-header .left{left:82px}.edit-attachment-frame .edit-media-header .right{left:41px}.edit-attachment-frame .media-frame-content{top:40px}.edit-attachment-frame .attachment-media-view{float:none;height:auto;width:100%}.edit-attachment-frame .attachment-info{height:auto;width:100%}}@media only screen and (max-width:640px),screen and (max-height:400px){.upload-php .mode-grid .media-sidebar{max-width:100%}} \ No newline at end of file diff --git a/backend/wp-admin/css/media.css b/backend/wp-admin/css/media.css new file mode 100644 index 0000000..95e52ac --- /dev/null +++ b/backend/wp-admin/css/media.css @@ -0,0 +1,1270 @@ +/*------------------------------------------------------------------------------ + 14.0 - Media Screen +------------------------------------------------------------------------------*/ + +.media-item .describe { + border-collapse: collapse; + width: 100%; + border-top: 1px solid #ddd; + clear: both; + cursor: default; +} + +.media-item.media-blank .describe { + border: 0; +} + +.media-item .describe th { + vertical-align: top; + text-align: left; + padding: 5px 10px 10px; + width: 140px; +} + +.media-item .describe .align th { + padding-top: 0; +} + +.media-item .media-item-info tr { + background-color: transparent; +} + +.media-item .describe td { + padding: 0 8px 8px 0; + vertical-align: top; +} + +.media-item thead.media-item-info td { + padding: 4px 10px 0; +} + +.media-item .media-item-info .A1B1 { + padding: 0 0 0 10px; +} + +.media-item td.savesend { + padding-bottom: 15px; +} + +.media-item .thumbnail { + max-height: 128px; + max-width: 128px; +} + +#wpbody-content #async-upload-wrap a { + display: none; +} + +.media-upload-form { + margin-top: 20px; +} + +.media-upload-form td label { + margin-right: 6px; + margin-left: 2px; +} + +.media-upload-form .align .field label { + display: inline; + padding: 0 0 0 23px; + margin: 0 1em 0 3px; + font-weight: 600; +} + +.media-upload-form tr.image-size label { + margin: 0 0 0 5px; + font-weight: 600; +} + +.media-upload-form th.label label { + font-weight: 600; + margin: 0.5em; + font-size: 13px; +} + +.media-upload-form th.label label span { + padding: 0 5px; +} + +.media-item .describe input[type="text"], +.media-item .describe textarea { + width: 460px; +} + +.media-item .describe p.help { + margin: 0; + padding: 0 0 0 5px; +} + +.media-item .edit-attachment, +.describe-toggle-on, +.describe-toggle-off { + display: block; + line-height: 36px; + float: right; + margin-right: 10px; +} + +.media-item .describe-toggle-off, +.media-item.open .describe-toggle-on { + display: none; +} + +.media-item.open .describe-toggle-off { + display: block; +} + +.media-upload-form .media-item { + min-height: 36px; + margin-bottom: 1px; + position: relative; + width: 100%; + background: #fff; +} + +.media-upload-form .media-item, +.media-upload-form .media-item .error { + box-shadow: 0 1px 0 #ddd; +} + +#media-items:empty { + border: 0 none; +} + +.media-item .filename { + line-height: 36px; + overflow: hidden; + margin-left: 6px; +} + +.media-item .pinkynail { + float: left; + margin: 2px 10px 0 3px; + max-width: 40px; + max-height: 32px; +} + +.media-item .startopen, +.media-item .startclosed { + display: none; +} + +.media-item .original { + position: relative; + height: 34px; +} + +.media-item .progress { + float: right; + height: 22px; + margin: 7px 6px; + width: 200px; + line-height: 2em; + padding: 0; + overflow: hidden; + border-radius: 22px; + background: #ddd; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); +} + +.media-item .bar { + z-index: 9; + width: 0; + height: 100%; + margin-top: -22px; + border-radius: 22px; + background-color: #0073aa; + box-shadow: inset 0 0 2px rgba(0,0,0,0.3); +} + +.media-item .progress .percent { + z-index: 10; + position: relative; + width: 200px; + padding: 0; + color: #fff; + text-align: center; + line-height: 22px; + font-weight: 400; + text-shadow: 0 1px 2px rgba(0,0,0,0.2); +} + +.upload-php .fixed .column-parent { + width: 15%; +} + +.js .html-uploader #plupload-upload-ui { + display: none; +} + +.js .html-uploader #html-upload-ui { + display: block; +} + +.media-upload-form .media-item.error, +.media-upload-form .media-item .error { + width: auto; + margin: 0 0 1px 0; +} + +.media-upload-form .media-item .error { + padding: 10px 0 10px 14px; +} + +.media-item .error-div a.dismiss { + display: block; + float: right; + margin: 0 10px 0 15px; +} + +/*------------------------------------------------------------------------------ + 14.1 - Media Library +------------------------------------------------------------------------------*/ + +.find-box { + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + width: 600px; + overflow: hidden; + margin-left: -300px; + position: fixed; + top: 30px; + bottom: 30px; + left: 50%; + z-index: 100105; +} + +.find-box-head { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + padding: 0 36px 0 16px; + position: absolute; + top: 0; + left: 0; + right: 0; +} + +.find-box-inside { + overflow: auto; + padding: 16px; + background-color: #fff; + position: absolute; + top: 37px; + bottom: 45px; + overflow-y: scroll; + width: 100%; + box-sizing: border-box; +} + +.find-box-search { + padding-bottom: 16px; +} + +.find-box-search .spinner { + float: none; + left: 105px; + position: absolute; +} + +.find-box-search, +#find-posts-response { + position: relative; /* RTL fix, #WP28010 */ +} + +#find-posts-input, +#find-posts-search { + float: left; +} + +#find-posts-input { + width: 140px; + height: 28px; + margin: 0 4px 0 0; +} + +.widefat .found-radio { + padding-right: 0; + width: 16px; +} + +#find-posts-close { + width: 36px; + height: 36px; + border: none; + padding: 0; + position: absolute; + top: 0; + right: 0; + cursor: pointer; + text-align: center; + background: none; + color: #666; +} + +#find-posts-close:hover, +#find-posts-close:focus { + color: #00a0d2; +} + +#find-posts-close:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#find-posts-close:before { + font: normal 20px/36px dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + content: "\f158"; +} + +.find-box-buttons { + padding: 8px 16px; + background: #fcfcfc; + border-top: 1px solid #ddd; + position: absolute; + bottom: 0; + left: 0; + right: 0; +} + +@media screen and ( max-width: 782px ) { + .find-box-inside { + bottom: 57px; + } +} + +@media screen and ( max-width: 660px ) { + + .find-box { + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: 0; + width: 100%; + } + +} + +.ui-find-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100100; +} + +ul#dismissed-updates { + display: none; +} + +form.upgrade { + margin-top: 8px; +} + +form.upgrade .hint { + font-style: italic; + font-size: 85%; + margin: -0.5em 0 2em 0; +} + +#poststuff .inside .the-tagcloud { + margin: 5px 0 10px; + padding: 8px; + border: 1px solid #ddd; + line-height: 1.8em; + word-spacing: 3px; +} + +.drag-drop #drag-drop-area { + border: 4px dashed #b4b9be; + height: 200px; +} + +.drag-drop .drag-drop-inside { + margin: 70px auto 0; + width: 250px; +} + +.drag-drop-inside p { + color: #a0a5aa; + font-size: 14px; + margin: 5px 0; + display: none; +} + +.drag-drop .drag-drop-inside p { + text-align: center; +} + +.drag-drop-inside p.drag-drop-info { + font-size: 20px; +} + +.drag-drop .drag-drop-inside p, +.drag-drop-inside p.drag-drop-buttons { + display: block; +} + +/* +#drag-drop-area:-moz-drag-over { + border-color: #83b4d8; +} +border color while dragging a file over the uploader drop area */ +.drag-drop.drag-over #drag-drop-area { + border-color: #83b4d8; +} + +#plupload-upload-ui { + position: relative; +} + +/** + * Media Library grid view + */ + +.media-frame.mode-grid, +.media-frame.mode-grid .media-frame-content, +.media-frame.mode-grid .attachments-browser .attachments, +.media-frame.mode-grid .uploader-inline-content { + position: static; +} + +/* Regions we don't use at all */ +.media-frame.mode-grid .media-frame-title, +.media-frame.mode-grid .media-frame-router, +.media-frame.mode-grid .media-frame-menu { + display: none; +} + +.media-frame.mode-grid .media-frame-content { + background-color: transparent; + border: none; +} + +.upload-php .mode-grid .media-sidebar { + position: relative; + width: auto; + margin-top: 12px; + padding: 0 16px; + border-left: 4px solid #dd3d36; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); + background-color: #fff; +} + +.upload-php .mode-grid .hide-sidebar .media-sidebar { + display: none; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status { + border-bottom: none; + padding-bottom: 0; + max-width: 100%; +} + +.upload-php .mode-grid .media-sidebar .upload-error { + margin: 12px 0; + padding: 4px 0 0; + border: none; + box-shadow: none; + background: none; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors { + top: -10px; + right: -14px; + padding: 10px; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:before { + content: "\f153"; + display: block; + font: normal 16px/1 dashicons; + color: #72777c; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before, +.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before { + color: #c00; +} + +.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h3, /* Back-compat for pre-4.4 */ +.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h2 { + display: none; +} + +.media-frame.mode-grid .uploader-inline { + position: relative; + top: auto; + right: auto; + left: auto; + bottom: auto; + padding-top: 0; + margin-top: 20px; + border: 4px dashed #b4b9be; +} + +.media-frame.mode-select .attachments-browser.fixed .attachments { + position: relative; + top: 94px; /* prevent jumping up when the toolbar becomes fixed */ + padding-bottom: 94px; /* offset for above so the bottom doesn't get cut off */ +} + +.media-frame.mode-grid .attachment:focus, +.media-frame.mode-grid .selected.attachment:focus, +.media-frame.mode-grid .attachment.details:focus { + box-shadow: + inset 0 0 2px 3px #f1f1f1, + inset 0 0 0 7px #5b9dd9; + outline: none; +} + +.media-frame.mode-grid .selected.attachment { + box-shadow: + inset 0 0 0 5px #f1f1f1, + inset 0 0 0 7px #ccc; +} + +.media-frame.mode-grid .attachment.details { + box-shadow: + inset 0 0 0 3px #f1f1f1, + inset 0 0 0 7px #1e8cbe; +} + +.media-frame.mode-grid.mode-select .attachment .thumbnail { + opacity: 0.65; +} + +.media-frame.mode-select .attachment.selected .thumbnail { + opacity: 1; +} + +.media-frame.mode-grid .media-toolbar { + margin-bottom: 15px; + height: auto; +} + +.media-frame.mode-grid .media-toolbar select { + margin: 0 10px 0 0; + font-size: 14px; +} + +.media-frame.mode-grid.mode-edit .media-toolbar-secondary > .select-mode-toggle-button { + margin: 0 8px 0 0; + vertical-align: middle; +} + +.media-frame.mode-grid .attachments-browser .bulk-select { + display: inline-block; + margin: 0 10px 0 0; +} + +.media-frame.mode-grid .search { + margin-top: 0; +} + +.media-frame.mode-grid .spinner { + margin-top: 16px; +} + +.attachments-browser .media-toolbar-secondary > .media-button { + margin-right: 10px; +} + +.media-frame.mode-select .attachments-browser.fixed .media-toolbar { + position: fixed; + top: 32px; + left: auto; + right: 20px; + margin-top: 0; +} + +.media-frame.mode-grid .attachments-browser { + padding: 0; +} + +.media-frame.mode-grid .attachments-browser .attachments { + padding: 2px; +} + +.media-frame.mode-grid .attachments-browser .no-media { + color: #666; /* same as no plugins and no themes */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0 0; + text-align: center; +} + +/** + * Attachment details modal + */ + +.edit-attachment-frame { + display: block; + height: 100%; + width: 100%; +} + +.edit-attachment-frame .edit-media-header { + overflow: hidden; +} + +.upload-php .media-modal-close .media-modal-icon:before { + content: "\f335"; + font-size: 22px; +} + +.upload-php .media-modal-close, +.edit-attachment-frame .edit-media-header .left, +.edit-attachment-frame .edit-media-header .right { + cursor: pointer; + color: #72777c; + background-color: transparent; + height: 50px; + width: 50px; + padding: 0; + position: absolute; + text-align: center; + border: 0; + border-left: 1px solid #ddd; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.upload-php .media-modal-close { + top: 0; + right: 0; +} + +.edit-attachment-frame .edit-media-header .left { + right: 102px; +} + +.edit-attachment-frame .edit-media-header .right { + right: 51px; +} + +.edit-attachment-frame .media-frame-title { + left: 0; + right: 150px; /* leave space for prev/next/close */ +} + +.edit-attachment-frame .edit-media-header .right:before, +.edit-attachment-frame .edit-media-header .left:before { + font: normal 20px/50px dashicons !important; + display: inline; + font-weight: 300; +} + +.upload-php .media-modal-close:hover, +.upload-php .media-modal-close:focus, +.edit-attachment-frame .edit-media-header .left:hover, +.edit-attachment-frame .edit-media-header .right:hover, +.edit-attachment-frame .edit-media-header .left:focus, +.edit-attachment-frame .edit-media-header .right:focus { + background: #ddd; + border-color: #ccc; + color: #000; + outline: none; + box-shadow: none; +} + +.upload-php .media-modal-close:focus .media-modal-icon:before, +.upload-php .media-modal-close:hover .media-modal-icon:before { + color: #000; +} + +.edit-attachment-frame .edit-media-header .left:before, +.rtl .edit-attachment-frame .edit-media-header .right:before { + content: "\f341"; +} + +.edit-attachment-frame .edit-media-header .right:before, +.rtl .edit-attachment-frame .edit-media-header .left:before { + content: "\f345"; +} + +.edit-attachment-frame .edit-media-header .left.disabled, +.edit-attachment-frame .edit-media-header .right.disabled, +.edit-attachment-frame .edit-media-header .left.disabled:hover, +.edit-attachment-frame .edit-media-header .right.disabled:hover { + color: #ccc; + background: inherit; + cursor: default; + pointer-events: none; +} + +.edit-attachment-frame .media-frame-content, +.edit-attachment-frame .media-frame-router { + left: 0; +} + +.edit-attachment-frame .media-frame-content { + border-bottom: none; + bottom: 0; + top: 50px; +} + +.edit-attachment-frame .attachment-details { + position: absolute; + overflow: auto; + top: 0; + bottom: 0; + right: 0; + left: 0; + box-shadow: inset 0px 4px 4px -4px rgba(0, 0, 0, 0.1); +} + +.edit-attachment-frame .attachment-media-view { + float: left; + width: 65%; + height: 100%; +} + +.edit-attachment-frame .attachment-media-view .thumbnail { + box-sizing: border-box; + padding: 16px; + height: 100%; +} + +.edit-attachment-frame .attachment-media-view .details-image { + display: block; + margin: 0 auto 16px; + max-width: 100%; + max-height: 90%; + max-height: calc( 100% - 42px ); /* leave space for actions underneath */ + background-image: linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 0 0, 10px 10px; + background-size: 20px 20px; +} + +.edit-attachment-frame .attachment-media-view .attachment-actions { + text-align: center; +} + +.edit-attachment-frame .wp-media-wrapper { + margin-bottom: 12px; +} + +.edit-attachment-frame input, +.edit-attachment-frame textarea { + padding: 6px 8px; + line-height: 16px; +} + +.edit-attachment-frame .attachment-info { + overflow: auto; + box-sizing: border-box; + margin-bottom: 0; + padding: 12px 16px 0; + width: 35%; + height: 100%; + box-shadow: inset 0px 4px 4px -4px rgba(0, 0, 0, 0.1); + border-bottom: 0; + border-left: 1px solid #ddd; + background: #f3f3f3; +} + +.edit-attachment-frame .attachment-info .details, +.edit-attachment-frame .attachment-info .settings { + position: relative; /* RTL fix, #WP29352 */ + overflow: hidden; + float: none; + margin-bottom: 15px; + padding-bottom: 15px; + border-bottom: 1px solid #ddd; +} + +.edit-attachment-frame .attachment-info .filename { + font-weight: 400; + color: #666; +} + +.edit-attachment-frame .attachment-info .thumbnail { + margin-bottom: 12px; +} + +.attachment-info .actions { + margin-bottom: 16px; +} + +.attachment-info .actions a { + display: inline; + text-decoration: none; +} + + +/*------------------------------------------------------------------------------ + 14.2 - Image Editor +------------------------------------------------------------------------------*/ + +.wp_attachment_details label[for="content"] { + font-size: 13px; + line-height: 1.5; + margin: 1em 0; +} + +.wp_attachment_details #attachment_caption { + height: 4em; +} + +.describe .image-editor { + vertical-align: top; +} + +.imgedit-wrap { + position: relative; + padding-top: 10px; +} + +.imgedit-settings p, +.imgedit-settings fieldset { + margin: 8px 0; +} + +.imgedit-settings legend { + margin-bottom: 5px; +} + +.describe .imgedit-wrap .imgedit-settings { + padding: 0 5px; +} + +.wp_attachment_holder div.updated { + margin-top: 0; +} + +.wp_attachment_holder .imgedit-wrap > div { + height: auto; +} + +.wp_attachment_holder .imgedit-wrap .imgedit-panel-content { + padding: 3px 16px 0 0; + float: left; +} + +.wp_attachment_holder .imgedit-wrap .imgedit-settings { + float: right; + width: 250px; +} + +.imgedit-settings input { + margin-top: 0; + vertical-align: middle; +} + +.imgedit-wait { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + background: #fff; + opacity: 0.7; + filter: alpha(opacity=70); + display: none; +} + +.imgedit-wait:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + left: 50%; + top: 50%; + margin: -10px 0 0 -10px; + background: transparent url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +.no-float { + float: none; +} + +.media-disabled, +.imgedit-settings .disabled { + /* WCAG 1.4.3 Text or images of text that are part of an inactive user + interface component ... have no contrast requirement. */ + color: #a0a5aa; +} + +.A1B1 { + overflow: hidden; +} + +.wp_attachment_image .button, +.A1B1 .button { + float: left; +} + +.no-js .wp_attachment_image .button { + display: none; +} + +.wp_attachment_image .spinner, +.A1B1 .spinner { + float: left; +} + +.imgedit-menu { + min-width: 300px; + margin: 0 0 12px; +} + +.imgedit-menu .note-no-rotate { + clear: both; + margin: 0; + padding: 1em 0 0; +} + +.image-editor .imgedit-menu .button { + float: left; + width: 32px; + height: 32px; + margin: 0 8px 0 0; + padding: 0; + background: #f1f1f1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 16px; + color: #72777c; +} + +.imgedit-menu .button:before { + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; +} + +.imgedit-menu .button.disabled { + border-color: #ccc; + background-color: #ddd; + color: #72777c; + filter: alpha(opacity=50); + opacity: 0.5; + cursor: default; +} + +.imgedit-crop:before { + content: "\f165"; +} + +.imgedit-rleft:before { + content: "\f166"; +} + +.imgedit-rright:before { + content: "\f167"; +} + +.imgedit-flipv:before { + content: "\f168"; +} + +.imgedit-fliph:before { + content: "\f169"; +} + +.imgedit-undo:before { + content: "\f171"; +} + +.imgedit-redo:before { + content: "\f172"; +} + +.imgedit-crop-wrap { + position: relative; +} + +.imgedit-crop-wrap img { + background-image: linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4), linear-gradient(45deg, #c4c4c4 25%, transparent 25%, transparent 75%, #c4c4c4 75%, #c4c4c4); + background-position: 0 0, 10px 10px; + background-size: 20px 20px; +} + +.imgedit-crop { + margin: 0 8px 0 0; +} + +.imgedit-rleft { + margin: 0 3px; +} + +.imgedit-rright { + margin: 0 8px 0 3px; +} + +.imgedit-flipv { + margin: 0 3px; +} + +.imgedit-fliph { + margin: 0 8px 0 3px; +} + +.imgedit-undo { + margin: 0 3px; +} + +.imgedit-redo { + margin: 0 8px 0 3px; +} + +.imgedit-thumbnail-preview { + margin: 10px 8px 0 0; +} + +.imgedit-thumbnail-preview-caption { + display: block; +} + +#poststuff .imgedit-group-top h3, /* Back-compat for pre-4.4 */ +#poststuff .imgedit-group-top h2 { + display: inline-block; + margin: 0; + padding: 0; + font-size: 14px; + line-height: 1.4; +} + +#poststuff .imgedit-group-top .button-link { + text-decoration: none; + color: #23282d; +} + +.imgedit-applyto .imgedit-label { + display: block; + padding: .5em 0 0; +} + +.imgedit-help { + display: none; + font-style: italic; +} + +/* higher specificity than buttons */ +.image-editor .imgedit-settings .imgedit-help-toggle, +.image-editor .imgedit-settings .imgedit-help-toggle:hover, +.image-editor .imgedit-settings .imgedit-help-toggle:active { + border: 1px solid transparent; + margin: -1px 0 0 -1px; + padding: 0; + background: transparent; + color: #0074a2; + font-size: 20px; + line-height: 1; + cursor: pointer; + box-sizing: content-box; + box-shadow: none; +} + +.image-editor .imgedit-settings .imgedit-help-toggle:focus { + color: #0074a2; + border-color: #5b9dd9; + outline: none; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.form-table td.imgedit-response { + padding: 0; +} + +.imgedit-submit { + margin: 8px 0 0; +} + +.imgedit-submit-btn { + margin-left: 20px; +} + +.imgedit-wrap .nowrap { + white-space: nowrap; + font-size: 12px; + line-height: inherit; +} + +span.imgedit-scale-warn { + color: #dc3232; + font-size: 20px; + font-style: normal; + visibility: hidden; + vertical-align: middle; +} + +.imgedit-save-target { + margin: 8px 0; +} + +.imgedit-group { + margin-bottom: 8px; + padding: 10px; +} + +.imgedit-settings .imgedit-scale input[type="text"], +.imgedit-settings .imgedit-crop-ratio input[type="text"], +.imgedit-settings .imgedit-crop-sel input[type="text"] { + width: 50px; + font-size: 14px; + padding: 5px 8px; +} + +.imgedit-separator { + display: inline-block; + width: 7px; + text-align: center; + vertical-align: middle; + font-size: 13px; + color: #444; +} + +.imgedit-settings .imgedit-scale .button { + margin-bottom: 0; +} + +audio, video { + display: inline-block; + max-width: 100%; +} + +.mejs-container { + width: 100%; + max-width: 100%; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .imgedit-wait:before { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + .wp_attachment_details label[for="content"] { + font-size: 14px; + line-height: 1.5em; + } + + .media-upload-form .media-item.error, + .media-upload-form .media-item .error { + font-size: 13px; + line-height: 1.5; + } + + .media-upload-form .media-item.error { + padding: 1px 10px; + } + + .media-upload-form .media-item .error { + padding: 10px 0 10px 12px; + } + + .imgedit-settings .imgedit-scale input[type="text"], + .imgedit-settings .imgedit-crop-ratio input[type="text"], + .imgedit-settings .imgedit-crop-sel input[type="text"] { + width: 60px; + font-size: 16px; + padding: 6px 10px; + } + + .imgedit-applyto .imgedit-label { + vertical-align: middle; + } +} + +/** + * Media queries for media grid. + */ + +@media only screen and (max-width: 1120px) { + /* override for media-views.css */ + #wp-media-grid .wp-filter .attachment-filters { + max-width: 100%; + } +} + +@media only screen and ( max-width: 782px ) { + .media-frame.mode-select .attachments-browser.fixed .media-toolbar { + top: 46px; + right: 10px; + } +} + +@media only screen and (max-width: 600px) { + .media-frame.mode-select .attachments-browser.fixed .media-toolbar { + top: 0; + } +} + +@media only screen and (max-width: 480px) { + .edit-attachment-frame .media-frame-title { + right: 110px; + } + + .upload-php .media-modal-close, + .edit-attachment-frame .edit-media-header .left, + .edit-attachment-frame .edit-media-header .right { + width: 40px; + height: 40px; + } + + .upload-php .media-modal-close .media-modal-icon { + margin: 9px 10px; + } + + .edit-attachment-frame .edit-media-header .right:before, + .edit-attachment-frame .edit-media-header .left:before { + line-height: 40px !important; + } + + .edit-attachment-frame .edit-media-header .left { + right: 82px; + } + + .edit-attachment-frame .edit-media-header .right { + right: 41px; + } + + .edit-attachment-frame .media-frame-content { + top: 40px; + } + + .edit-attachment-frame .attachment-media-view { + float: none; + height: auto; + width: 100%; + } + + .edit-attachment-frame .attachment-info { + height: auto; + width: 100%; + } +} + +@media only screen and (max-width: 640px), screen and (max-height: 400px) { + .upload-php .mode-grid .media-sidebar{ + max-width: 100%; + } +} diff --git a/backend/wp-admin/css/media.min.css b/backend/wp-admin/css/media.min.css new file mode 100644 index 0000000..3256b80 --- /dev/null +++ b/backend/wp-admin/css/media.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.media-item .describe{border-collapse:collapse;width:100%;border-top:1px solid #ddd;clear:both;cursor:default}.media-item.media-blank .describe{border:0}.media-item .describe th{vertical-align:top;text-align:left;padding:5px 10px 10px;width:140px}.media-item .describe .align th{padding-top:0}.media-item .media-item-info tr{background-color:transparent}.media-item .describe td{padding:0 8px 8px 0;vertical-align:top}.media-item thead.media-item-info td{padding:4px 10px 0}.media-item .media-item-info .A1B1{padding:0 0 0 10px}.media-item td.savesend{padding-bottom:15px}.media-item .thumbnail{max-height:128px;max-width:128px}#wpbody-content #async-upload-wrap a{display:none}.media-upload-form{margin-top:20px}.media-upload-form td label{margin-right:6px;margin-left:2px}.media-upload-form .align .field label{display:inline;padding:0 0 0 23px;margin:0 1em 0 3px;font-weight:600}.media-upload-form tr.image-size label{margin:0 0 0 5px;font-weight:600}.media-upload-form th.label label{font-weight:600;margin:.5em;font-size:13px}.media-upload-form th.label label span{padding:0 5px}.media-item .describe input[type=text],.media-item .describe textarea{width:460px}.media-item .describe p.help{margin:0;padding:0 0 0 5px}.describe-toggle-off,.describe-toggle-on,.media-item .edit-attachment{display:block;line-height:36px;float:right;margin-right:10px}.media-item .describe-toggle-off,.media-item.open .describe-toggle-on{display:none}.media-item.open .describe-toggle-off{display:block}.js .html-uploader #plupload-upload-ui,.media-item .startclosed,.media-item .startopen{display:none}.media-upload-form .media-item{min-height:36px;margin-bottom:1px;position:relative;width:100%;background:#fff}.media-upload-form .media-item,.media-upload-form .media-item .error{box-shadow:0 1px 0 #ddd}#media-items:empty{border:0}.media-item .filename{line-height:36px;overflow:hidden;margin-left:6px}.media-item .pinkynail{float:left;margin:2px 10px 0 3px;max-width:40px;max-height:32px}.media-item .original{position:relative;height:34px}.media-item .progress{float:right;height:22px;margin:7px 6px;width:200px;line-height:2em;padding:0;overflow:hidden;border-radius:22px;background:#ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.media-item .bar{z-index:9;width:0;height:100%;margin-top:-22px;border-radius:22px;background-color:#0073aa;box-shadow:inset 0 0 2px rgba(0,0,0,.3)}.media-item .progress .percent{z-index:10;position:relative;width:200px;padding:0;color:#fff;text-align:center;line-height:22px;font-weight:400;text-shadow:0 1px 2px rgba(0,0,0,.2)}.upload-php .fixed .column-parent{width:15%}.js .html-uploader #html-upload-ui{display:block}.media-upload-form .media-item .error,.media-upload-form .media-item.error{width:auto;margin:0 0 1px}.media-upload-form .media-item .error{padding:10px 0 10px 14px}.media-item .error-div a.dismiss{display:block;float:right;margin:0 10px 0 15px}.find-box{background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3);width:600px;overflow:hidden;margin-left:-300px;position:fixed;top:30px;bottom:30px;left:50%;z-index:100105}.find-box-head{background:#fcfcfc;border-bottom:1px solid #ddd;height:36px;font-size:18px;font-weight:600;line-height:36px;padding:0 36px 0 16px;position:absolute;top:0;left:0;right:0}.find-box-inside{overflow:auto;padding:16px;background-color:#fff;position:absolute;top:37px;bottom:45px;overflow-y:scroll;width:100%;box-sizing:border-box}.find-box-search{padding-bottom:16px}.find-box-search .spinner{float:none;left:105px;position:absolute}#find-posts-response,.find-box-search{position:relative}#find-posts-input,#find-posts-search{float:left}#find-posts-input{width:140px;height:28px;margin:0 4px 0 0}.widefat .found-radio{padding-right:0;width:16px}#find-posts-close{width:36px;height:36px;border:none;padding:0;position:absolute;top:0;right:0;cursor:pointer;text-align:center;background:0 0;color:#666}#find-posts-close:focus,#find-posts-close:hover{color:#00a0d2}#find-posts-close:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#find-posts-close:before{font:400 20px/36px dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f158"}.find-box-buttons{padding:8px 16px;background:#fcfcfc;border-top:1px solid #ddd;position:absolute;bottom:0;left:0;right:0}@media screen and (max-width:782px){.find-box-inside{bottom:57px}}@media screen and (max-width:660px){.find-box{top:0;bottom:0;left:0;right:0;margin:0;width:100%}}.ui-find-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100100}ul#dismissed-updates{display:none}form.upgrade{margin-top:8px}form.upgrade .hint{font-style:italic;font-size:85%;margin:-.5em 0 2em}#poststuff .inside .the-tagcloud{margin:5px 0 10px;padding:8px;border:1px solid #ddd;line-height:1.8em;word-spacing:3px}.drag-drop #drag-drop-area{border:4px dashed #b4b9be;height:200px}.drag-drop .drag-drop-inside{margin:70px auto 0;width:250px}.drag-drop-inside p{color:#a0a5aa;font-size:14px;margin:5px 0;display:none}.drag-drop .drag-drop-inside p{text-align:center}.drag-drop-inside p.drag-drop-info{font-size:20px}.drag-drop .drag-drop-inside p,.drag-drop-inside p.drag-drop-buttons{display:block}.media-frame.mode-grid .media-frame-menu,.media-frame.mode-grid .media-frame-router,.media-frame.mode-grid .media-frame-title,.upload-php .mode-grid .hide-sidebar .media-sidebar{display:none}.drag-drop.drag-over #drag-drop-area{border-color:#83b4d8}#plupload-upload-ui{position:relative}.media-frame.mode-grid,.media-frame.mode-grid .attachments-browser .attachments,.media-frame.mode-grid .media-frame-content,.media-frame.mode-grid .uploader-inline-content{position:static}.media-frame.mode-grid .media-frame-content{background-color:transparent;border:none}.upload-php .mode-grid .media-sidebar{position:relative;width:auto;margin-top:12px;padding:0 16px;border-left:4px solid #dd3d36;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);background-color:#fff}.upload-php .mode-grid .media-sidebar .media-uploader-status{border-bottom:none;padding-bottom:0;max-width:100%}.upload-php .mode-grid .media-sidebar .upload-error{margin:12px 0;padding:4px 0 0;border:none;box-shadow:none;background:0 0}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors{top:-10px;right:-14px;padding:10px}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:before{content:"\f153";display:block;font:400 16px/1 dashicons;color:#72777c}.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before,.upload-php .mode-grid .media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before{color:#c00}.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h2,.upload-php .mode-grid .media-sidebar .media-uploader-status.errors h3{display:none}.media-frame.mode-grid .uploader-inline{position:relative;top:auto;right:auto;left:auto;bottom:auto;padding-top:0;margin-top:20px;border:4px dashed #b4b9be}.media-frame.mode-select .attachments-browser.fixed .attachments{position:relative;top:94px;padding-bottom:94px}.media-frame.mode-grid .attachment.details:focus,.media-frame.mode-grid .attachment:focus,.media-frame.mode-grid .selected.attachment:focus{box-shadow:inset 0 0 2px 3px #f1f1f1,inset 0 0 0 7px #5b9dd9;outline:0}.media-frame.mode-grid .selected.attachment{box-shadow:inset 0 0 0 5px #f1f1f1,inset 0 0 0 7px #ccc}.media-frame.mode-grid .attachment.details{box-shadow:inset 0 0 0 3px #f1f1f1,inset 0 0 0 7px #1e8cbe}.media-frame.mode-grid.mode-select .attachment .thumbnail{opacity:.65}.media-frame.mode-select .attachment.selected .thumbnail{opacity:1}.media-frame.mode-grid .media-toolbar{margin-bottom:15px;height:auto}.media-frame.mode-grid .media-toolbar select{margin:0 10px 0 0;font-size:14px}.media-frame.mode-grid.mode-edit .media-toolbar-secondary>.select-mode-toggle-button{margin:0 8px 0 0;vertical-align:middle}.media-frame.mode-grid .attachments-browser .bulk-select{display:inline-block;margin:0 10px 0 0}.media-frame.mode-grid .search{margin-top:0}.media-frame.mode-grid .spinner{margin-top:16px}.attachments-browser .media-toolbar-secondary>.media-button{margin-right:10px}.media-frame.mode-select .attachments-browser.fixed .media-toolbar{position:fixed;top:32px;left:auto;right:20px;margin-top:0}.media-frame.mode-grid .attachments-browser{padding:0}.media-frame.mode-grid .attachments-browser .attachments{padding:2px}.media-frame.mode-grid .attachments-browser .no-media{color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0 0;text-align:center}.edit-attachment-frame{display:block;height:100%;width:100%}.edit-attachment-frame .edit-media-header{overflow:hidden}.upload-php .media-modal-close .media-modal-icon:before{content:"\f335";font-size:22px}.edit-attachment-frame .edit-media-header .left,.edit-attachment-frame .edit-media-header .right,.upload-php .media-modal-close{cursor:pointer;color:#72777c;background-color:transparent;height:50px;width:50px;padding:0;position:absolute;text-align:center;border:0;border-left:1px solid #ddd;transition:color .1s ease-in-out,background .1s ease-in-out}.upload-php .media-modal-close{top:0;right:0}.edit-attachment-frame .edit-media-header .left{right:102px}.edit-attachment-frame .edit-media-header .right{right:51px}.edit-attachment-frame .media-frame-title{left:0;right:150px}.edit-attachment-frame .edit-media-header .left:before,.edit-attachment-frame .edit-media-header .right:before{font:400 20px/50px dashicons!important;display:inline;font-weight:300}.edit-attachment-frame .edit-media-header .left:focus,.edit-attachment-frame .edit-media-header .left:hover,.edit-attachment-frame .edit-media-header .right:focus,.edit-attachment-frame .edit-media-header .right:hover,.upload-php .media-modal-close:focus,.upload-php .media-modal-close:hover{background:#ddd;border-color:#ccc;color:#000;outline:0;box-shadow:none}.upload-php .media-modal-close:focus .media-modal-icon:before,.upload-php .media-modal-close:hover .media-modal-icon:before{color:#000}.edit-attachment-frame .edit-media-header .left:before,.rtl .edit-attachment-frame .edit-media-header .right:before{content:"\f341"}.edit-attachment-frame .edit-media-header .right:before,.rtl .edit-attachment-frame .edit-media-header .left:before{content:"\f345"}.edit-attachment-frame .edit-media-header .left.disabled,.edit-attachment-frame .edit-media-header .left.disabled:hover,.edit-attachment-frame .edit-media-header .right.disabled,.edit-attachment-frame .edit-media-header .right.disabled:hover{color:#ccc;background:inherit;cursor:default;pointer-events:none}.edit-attachment-frame .media-frame-content,.edit-attachment-frame .media-frame-router{left:0}.edit-attachment-frame .media-frame-content{border-bottom:none;bottom:0;top:50px}.edit-attachment-frame .attachment-details{position:absolute;overflow:auto;top:0;bottom:0;right:0;left:0;box-shadow:inset 0 4px 4px -4px rgba(0,0,0,.1)}.edit-attachment-frame .attachment-media-view{float:left;width:65%;height:100%}.edit-attachment-frame .attachment-media-view .thumbnail{box-sizing:border-box;padding:16px;height:100%}.edit-attachment-frame .attachment-media-view .details-image{display:block;margin:0 auto 16px;max-width:100%;max-height:90%;max-height:calc(100% - 42px);background-image:linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:0 0,10px 10px;background-size:20px 20px}.edit-attachment-frame .attachment-media-view .attachment-actions{text-align:center}.edit-attachment-frame .wp-media-wrapper{margin-bottom:12px}.edit-attachment-frame input,.edit-attachment-frame textarea{padding:6px 8px;line-height:16px}.edit-attachment-frame .attachment-info{overflow:auto;box-sizing:border-box;margin-bottom:0;padding:12px 16px 0;width:35%;height:100%;box-shadow:inset 0 4px 4px -4px rgba(0,0,0,.1);border-bottom:0;border-left:1px solid #ddd;background:#f3f3f3}.edit-attachment-frame .attachment-info .details,.edit-attachment-frame .attachment-info .settings{position:relative;overflow:hidden;float:none;margin-bottom:15px;padding-bottom:15px;border-bottom:1px solid #ddd}.edit-attachment-frame .attachment-info .filename{font-weight:400;color:#666}.edit-attachment-frame .attachment-info .thumbnail{margin-bottom:12px}.attachment-info .actions{margin-bottom:16px}.attachment-info .actions a{display:inline;text-decoration:none}.wp_attachment_details label[for=content]{font-size:13px;line-height:1.5;margin:1em 0}.wp_attachment_details #attachment_caption{height:4em}.describe .image-editor{vertical-align:top}.imgedit-wrap{position:relative;padding-top:10px}.imgedit-settings fieldset,.imgedit-settings p{margin:8px 0}.imgedit-settings legend{margin-bottom:5px}.describe .imgedit-wrap .imgedit-settings{padding:0 5px}.wp_attachment_holder div.updated{margin-top:0}.wp_attachment_holder .imgedit-wrap>div{height:auto}.wp_attachment_holder .imgedit-wrap .imgedit-panel-content{padding:3px 16px 0 0;float:left}.wp_attachment_holder .imgedit-wrap .imgedit-settings{float:right;width:250px}.imgedit-settings input{margin-top:0;vertical-align:middle}.imgedit-wait{position:absolute;top:0;bottom:0;width:100%;background:#fff;opacity:.7;filter:alpha(opacity=70);display:none}.imgedit-wait:before{content:"";display:block;width:20px;height:20px;position:absolute;left:50%;top:50%;margin:-10px 0 0 -10px;background:url(../images/spinner.gif) center no-repeat;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}.no-float{float:none}.A1B1 .button,.A1B1 .spinner,.wp_attachment_image .button,.wp_attachment_image .spinner{float:left}.imgedit-settings .disabled,.media-disabled{color:#a0a5aa}.A1B1{overflow:hidden}.no-js .wp_attachment_image .button{display:none}.imgedit-menu{min-width:300px;margin:0 0 12px}.imgedit-menu .note-no-rotate{clear:both;margin:0;padding:1em 0 0}.image-editor .imgedit-menu .button{float:left;width:32px;height:32px;margin:0 8px 0 0;padding:0;background:#f1f1f1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:16px;color:#72777c}.imgedit-menu .button:before{font:400 20px/1 dashicons;speak:none;vertical-align:middle}.imgedit-menu .button.disabled{border-color:#ccc;background-color:#ddd;color:#72777c;filter:alpha(opacity=50);opacity:.5;cursor:default}.imgedit-crop:before{content:"\f165"}.imgedit-rleft:before{content:"\f166"}.imgedit-rright:before{content:"\f167"}.imgedit-flipv:before{content:"\f168"}.imgedit-fliph:before{content:"\f169"}.imgedit-undo:before{content:"\f171"}.imgedit-redo:before{content:"\f172"}.imgedit-crop-wrap{position:relative}.imgedit-crop-wrap img{background-image:linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4),linear-gradient(45deg,#c4c4c4 25%,transparent 25%,transparent 75%,#c4c4c4 75%,#c4c4c4);background-position:0 0,10px 10px;background-size:20px 20px}.imgedit-crop{margin:0 8px 0 0}.imgedit-rleft{margin:0 3px}.imgedit-rright{margin:0 8px 0 3px}.imgedit-flipv{margin:0 3px}.imgedit-fliph{margin:0 8px 0 3px}.imgedit-undo{margin:0 3px}.imgedit-redo{margin:0 8px 0 3px}.imgedit-thumbnail-preview{margin:10px 8px 0 0}.imgedit-thumbnail-preview-caption{display:block}#poststuff .imgedit-group-top h2,#poststuff .imgedit-group-top h3{display:inline-block;margin:0;padding:0;font-size:14px;line-height:1.4}#poststuff .imgedit-group-top .button-link{text-decoration:none;color:#23282d}.imgedit-applyto .imgedit-label{display:block;padding:.5em 0 0}.imgedit-help{display:none;font-style:italic}.image-editor .imgedit-settings .imgedit-help-toggle,.image-editor .imgedit-settings .imgedit-help-toggle:active,.image-editor .imgedit-settings .imgedit-help-toggle:hover{border:1px solid transparent;margin:-1px 0 0 -1px;padding:0;background:0 0;color:#0074a2;font-size:20px;line-height:1;cursor:pointer;box-sizing:content-box;box-shadow:none}.image-editor .imgedit-settings .imgedit-help-toggle:focus{color:#0074a2;border-color:#5b9dd9;outline:0;box-shadow:0 0 3px rgba(0,115,170,.8)}.form-table td.imgedit-response{padding:0}.imgedit-submit{margin:8px 0 0}.imgedit-submit-btn{margin-left:20px}.imgedit-wrap .nowrap{white-space:nowrap;font-size:12px;line-height:inherit}span.imgedit-scale-warn{color:#dc3232;font-size:20px;font-style:normal;visibility:hidden;vertical-align:middle}.imgedit-save-target{margin:8px 0}.imgedit-group{margin-bottom:8px;padding:10px}.imgedit-settings .imgedit-crop-ratio input[type=text],.imgedit-settings .imgedit-crop-sel input[type=text],.imgedit-settings .imgedit-scale input[type=text]{width:50px;font-size:14px;padding:5px 8px}.imgedit-separator{display:inline-block;width:7px;text-align:center;vertical-align:middle;font-size:13px;color:#444}.imgedit-settings .imgedit-scale .button{margin-bottom:0}audio,video{display:inline-block;max-width:100%}.mejs-container{width:100%;max-width:100%}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.imgedit-wait:before{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){.wp_attachment_details label[for=content]{font-size:14px;line-height:1.5em}.media-upload-form .media-item .error,.media-upload-form .media-item.error{font-size:13px;line-height:1.5}.media-upload-form .media-item.error{padding:1px 10px}.media-upload-form .media-item .error{padding:10px 0 10px 12px}.imgedit-settings .imgedit-crop-ratio input[type=text],.imgedit-settings .imgedit-crop-sel input[type=text],.imgedit-settings .imgedit-scale input[type=text]{width:60px;font-size:16px;padding:6px 10px}.imgedit-applyto .imgedit-label{vertical-align:middle}}@media only screen and (max-width:1120px){#wp-media-grid .wp-filter .attachment-filters{max-width:100%}}@media only screen and (max-width:782px){.media-frame.mode-select .attachments-browser.fixed .media-toolbar{top:46px;right:10px}}@media only screen and (max-width:600px){.media-frame.mode-select .attachments-browser.fixed .media-toolbar{top:0}}@media only screen and (max-width:480px){.edit-attachment-frame .media-frame-title{right:110px}.edit-attachment-frame .edit-media-header .left,.edit-attachment-frame .edit-media-header .right,.upload-php .media-modal-close{width:40px;height:40px}.upload-php .media-modal-close .media-modal-icon{margin:9px 10px}.edit-attachment-frame .edit-media-header .left:before,.edit-attachment-frame .edit-media-header .right:before{line-height:40px!important}.edit-attachment-frame .edit-media-header .left{right:82px}.edit-attachment-frame .edit-media-header .right{right:41px}.edit-attachment-frame .media-frame-content{top:40px}.edit-attachment-frame .attachment-media-view{float:none;height:auto;width:100%}.edit-attachment-frame .attachment-info{height:auto;width:100%}}@media only screen and (max-width:640px),screen and (max-height:400px){.upload-php .mode-grid .media-sidebar{max-width:100%}} \ No newline at end of file diff --git a/backend/wp-admin/css/nav-menus-rtl.css b/backend/wp-admin/css/nav-menus-rtl.css new file mode 100644 index 0000000..dd99b5a --- /dev/null +++ b/backend/wp-admin/css/nav-menus-rtl.css @@ -0,0 +1,901 @@ +/* nav-menu */ + +/* @todo: determine if this is truly for nav menus only */ +.no-js #message { + display: block; +} + +ul.add-menu-item-tabs li { + padding: 3px 8px 4px 5px; +} + +.accordion-section ul.category-tabs, +.accordion-section ul.add-menu-item-tabs, +.accordion-section ul.wp-tab-bar { + margin: 0; +} + +.accordion-section .categorychecklist { + margin: 13px 0; +} + +#nav-menu-meta .accordion-section-content { + padding: 18px 13px; +} + +#nav-menu-meta .button-controls { + margin-bottom: 0; +} + +.has-no-menu-item .button-controls { + display: none; +} + +#nav-menus-frame { + margin-right: 300px; + margin-top: 23px; +} + +#wpbody-content #menu-settings-column { + display:inline; + width:281px; + margin-right: -300px; + clear: both; + float: right; + padding-top: 0; +} + +#menu-settings-column .inside { + clear: both; + margin: 10px 0 0; +} + +.metabox-holder-disabled .postbox, +.metabox-holder-disabled .accordion-section-content, +.metabox-holder-disabled .accordion-section-title { + opacity: 0.5; + filter: alpha(opacity=50); +} + +.metabox-holder-disabled .button-controls .select-all { + display: none; +} + +#wpbody { + position: relative; +} + +.blank-slate .menu-settings { + border: none; + margin-top: 0; + padding-top: 0; + overflow: hidden; +} + +.is-submenu { + color: #555d66; /* #fafafa background */ + font-style: italic; + font-weight: 400; + margin-right: 4px; +} + +.manage-menus { + margin-top: 23px; + padding: 10px; + overflow: hidden; + background: #fbfbfb; +} + +.manage-menus .selected-menu, +.manage-menus select, +.manage-menus .submit-btn, +.nav-menus-php .add-new-menu-action { + display: inline-block; + margin-left: 3px; + vertical-align: middle; +} + +.manage-menus select, +.menu-location-menus select { + max-width: 100%; +} + +.menu-edit #post-body-content h3 { + margin: 1em 0 10px; +} + +.menu-settings { + border-top: 1px solid #eee; + margin-top: 2em; +} + +.menu-settings-group { + margin: 0 0 10px; + overflow: hidden; + padding-right: 20%; +} + +.menu-settings-group:last-of-type { + margin-bottom: 0; +} + +.menu-settings-input { + float: right; + margin: 0; + width: 100%; +} + +.menu-settings-group-name { + float: right; + clear: both; + width: 25%; + padding: 3px 0 0; + margin-right: -25%; /* 20 container left padding x ( 100 container % width / 80 this % width ) */ +} + +.menu-settings label { + vertical-align: baseline; +} + +.menu-edit .checkbox-input { + margin-top: 4px; +} + +.theme-location-set { + color: #72777c; + font-size: 11px; +} + +/* Menu Container */ + +/* @todo: responsive view. */ +#menu-management-liquid { + float: right; + min-width: 100%; + margin-top: 3px; +} + +/* @todo: responsive view. */ +#menu-management { + position: relative; + margin-left: 20px; + margin-top: -3px; + width: 100%; + background: #f5f5f5; +} + +#menu-management .menu-edit { + margin-bottom: 20px; +} + +.nav-menus-php #post-body { + padding: 0 10px 10px; + border-top: 1px solid #fff; + border-bottom: 1px solid #ddd; + background: #fff; +} + +#nav-menu-header, +#nav-menu-footer { + padding: 0 10px; +} + +#nav-menu-header { + border-bottom: 1px solid #ddd; + margin-bottom: 0; +} + +#nav-menu-header .menu-name-label { + display: inline-block; + vertical-align: middle; + margin-left: 7px; + font-style: italic; +} + +.nav-menus-php #post-body div.updated, +.nav-menus-php #post-body div.error { + margin: 0; +} + +.nav-menus-php #post-body-content { + position: relative; + float: none; +} + +#menu-management .menu-add-new abbr { + font-weight:600; +} + +#select-nav-menu-container { + text-align: left; + padding: 0 10px 3px 10px; + margin-bottom: 5px; +} + +#select-nav-menu { + width: 100px; + display: inline; +} + +#menu-name-label { + margin-top: -2px; +} + +.widefat .menu-locations .menu-location-title { + padding: 13px 10px 0; +} + +.menu-location-title label { + font-weight: 600; +} + +.menu-location-menus select { + float: right; +} + +#locations-nav-menu-wrapper { + padding: 5px 0; +} + +.locations-nav-menu-select select { + float: right; + width: 160px; + margin-left: 5px; +} + +.locations-row-links { + float: right; + margin: 6px 6px 0 0; +} + +.locations-edit-menu-link, +.locations-add-menu-link { + margin: 0 3px; +} + +.locations-edit-menu-link { + padding-left: 3px; + border-left: 1px solid #ccc; +} + +#menu-management .inside { + padding: 0 10px; +} + +/* Add Menu Item Boxes */ +.postbox .howto input, +.customlinkdiv .menu-item-textbox { + width: 180px; + float: left; +} + +.accordion-container .outer-border { + margin: 0; +} + +.customlinkdiv p { + margin-top: 0 +} + +#nav-menu-theme-locations .howto select { + width: 100%; +} + +#nav-menu-theme-locations .button-controls { + text-align: left; +} + +.add-menu-item-view-all { + height: 400px; +} + +/* Button Primary Actions */ +#menu-container .submit { + margin: 0 0 10px; + padding: 0; +} + +/* @todo: is this actually used? */ +#cancel-save { + text-decoration: underline; + font-size: 12px; + margin-right: 20px; + margin-top: 5px; +} + +.button.right, .button-secondary.right, .button-primary.right { + float: left; +} + +/* Button Secondary Actions */ +.list-controls { + float: right; + margin-top: 5px; +} + +.add-to-menu { + float: left; +} + +.button-controls { + clear:both; + margin: 10px 0; +} + +.show-all, +.hide-all { + cursor: pointer; +} + +.hide-all { + display: none; +} + +/* Create Menu */ +#menu-name { + width: 270px; + vertical-align: middle; +} + +#manage-menu .inside { + padding: 0px 0px; +} + +/* Custom Links */ +#available-links dt { + display: block; +} + +#add-custom-link .howto { + font-size: 12px; +} + +#add-custom-link label span { + display: block; + float: right; + margin-top: 5px; + padding-left: 5px; +} + +.menu-item-textbox { + width: 180px; +} + +.customlinkdiv label, +.nav-menus-php .howto span { + float: right; + margin-top: 6px; +} + +/* Menu item types */ +.quick-search { + width: 190px; +} + +.quick-search-wrap .spinner { + float: none; + margin: -3px 0 0 -10px; +} + +.nav-menus-php .list-wrap { + display: none; + clear: both; + margin-bottom: 10px; +} + +.nav-menus-php .postbox p.submit { + margin-bottom: 0; +} + +/* Listings */ +.nav-menus-php .list li { + display: none; + margin: 0; + margin-bottom: 5px; +} + +.nav-menus-php .list li .menu-item-title { + cursor: pointer; + display: block; +} + +.nav-menus-php .list li .menu-item-title input { + margin-left: 3px; + margin-top: -3px; +} + +.menu-item-title input[type=checkbox] { + display: inline-block; + margin-top: -4px; +} + +/* Nav Menu */ +#menu-container .inside { + padding-bottom: 10px; +} + +.menu { + padding-top:1em; +} + +#menu-to-edit { + margin: 0; + padding: 0.1em 0; +} + +.menu ul { + width: 100%; +} + +.menu li { + margin-bottom: 0; + position:relative; +} + +.menu-item-bar { + clear:both; + line-height:1.5em; + position:relative; + margin: 9px 0 0; +} + +.menu-item-bar .menu-item-handle { + border: 1px solid #ddd; + position: relative; + padding: 10px 15px; + height: auto; + min-height: 20px; + width: 382px; + line-height: 30px; + overflow: hidden; + word-wrap: break-word; +} + +.menu-item-bar .menu-item-handle:hover { + border-color: #999; +} + +#menu-to-edit .menu-item-invalid .menu-item-handle { + background: #f6c9cc; + border-color: #f1acb1; +} + +.no-js .menu-item-edit-active .item-edit { + display: none; +} + +.js .menu-item-handle { + cursor: move; +} + +.menu li.deleting .menu-item-handle { + background-image: none; + background-color: #f66; +} + +.menu-item-handle .item-title { + font-size: 13px; + font-weight: 600; + line-height: 20px; + display: block; + /* @todo: responsive view. */ + margin-left: 13em; +} + +.menu-item-handle .menu-item-title.no-title { + color: #72777c; +} + +/* Sortables */ +li.menu-item.ui-sortable-helper .menu-item-bar { + margin-top: 0; +} + +li.menu-item.ui-sortable-helper .menu-item-transport .menu-item-bar { + margin-top: 13px; +} + +.menu .sortable-placeholder { + height: 35px; + width: 410px; + margin-top: 13px; +} + +/* Hide the transport list when it's empty */ +.menu-item .menu-item-transport:empty { + display: none; +} + +/* WARNING: The factor of 30px is hardcoded into the nav-menus JavaScript. */ +.menu-item-depth-0 { margin-right: 0px; } +.menu-item-depth-1 { margin-right: 30px; } +.menu-item-depth-2 { margin-right: 60px; } +.menu-item-depth-3 { margin-right: 90px; } +.menu-item-depth-4 { margin-right: 120px; } +.menu-item-depth-5 { margin-right: 150px; } +.menu-item-depth-6 { margin-right: 180px; } +.menu-item-depth-7 { margin-right: 210px; } +.menu-item-depth-8 { margin-right: 240px; } +.menu-item-depth-9 { margin-right: 270px; } +.menu-item-depth-10 { margin-right: 300px; } +.menu-item-depth-11 { margin-right: 330px; } + +.menu-item-depth-0 .menu-item-transport { margin-right: 0px; } +.menu-item-depth-1 .menu-item-transport { margin-right: -30px; } +.menu-item-depth-2 .menu-item-transport { margin-right: -60px; } +.menu-item-depth-3 .menu-item-transport { margin-right: -90px; } +.menu-item-depth-4 .menu-item-transport { margin-right: -120px; } +.menu-item-depth-5 .menu-item-transport { margin-right: -150px; } +.menu-item-depth-6 .menu-item-transport { margin-right: -180px; } +.menu-item-depth-7 .menu-item-transport { margin-right: -210px; } +.menu-item-depth-8 .menu-item-transport { margin-right: -240px; } +.menu-item-depth-9 .menu-item-transport { margin-right: -270px; } +.menu-item-depth-10 .menu-item-transport { margin-right: -300px; } +.menu-item-depth-11 .menu-item-transport { margin-right: -330px; } + +body.menu-max-depth-0 { min-width: 950px !important; } +body.menu-max-depth-1 { min-width: 980px !important; } +body.menu-max-depth-2 { min-width: 1010px !important; } +body.menu-max-depth-3 { min-width: 1040px !important; } +body.menu-max-depth-4 { min-width: 1070px !important; } +body.menu-max-depth-5 { min-width: 1100px !important; } +body.menu-max-depth-6 { min-width: 1130px !important; } +body.menu-max-depth-7 { min-width: 1160px !important; } +body.menu-max-depth-8 { min-width: 1190px !important; } +body.menu-max-depth-9 { min-width: 1220px !important; } +body.menu-max-depth-10 { min-width: 1250px !important; } +body.menu-max-depth-11 { min-width: 1280px !important; } + +/* Menu item controls */ +.item-type { + display: inline-block; + padding: 12px 16px; + color: #666; + font-size: 12px; + line-height: 18px; +} + +.item-controls { + font-size: 12px; + position: absolute; + left: 20px; + top: -1px; +} + +.item-controls a { + text-decoration: none; +} + +.item-controls a:hover { + cursor: pointer; +} + +.item-controls .item-order { + padding-left: 10px; +} + +.nav-menus-php .item-edit { + position: absolute; + left: -20px; + top: 0; + display: block; + width: 30px; + height: 40px; + outline: none; +} + +.no-js.nav-menus-php .item-edit { + position: static; + float: left; + width: auto; + height: auto; + margin: 12px 0 12px -10px; + padding: 0; + color: #0073aa; + text-decoration: underline; + font-size: 12px; + line-height: 18px; +} + +.no-js.nav-menus-php .item-edit .screen-reader-text { + position: static; + -webkit-clip-path: none; + clip-path: none; + width: auto; + height: auto; + margin: 0; +} + +.nav-menus-php .item-edit:before { + margin-top: 10px; + margin-right: 4px; + width: 20px; + border-radius: 50%; + text-indent: -1px; /* account for the dashicon alignment */ +} + +.no-js.nav-menus-php .item-edit:before { + display: none; +} + +.rtl .nav-menus-php .item-edit:before { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.js.nav-menus-php .item-edit:focus { + box-shadow: none; +} + +.nav-menus-php .item-edit:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +/* Menu editing */ +.menu-instructions-inactive { + display: none; +} + +.menu-item-settings { + display: block; + width: 402px; + padding: 10px 10px 10px 0; + position: relative; + z-index: 10; /* Keep .item-title's shadow from appearing on top of .menu-item-settings */ + border: 1px solid #e5e5e5; + border-top: none; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +.menu-item-settings .field-move { + margin: 3px 0 5px; + line-height: 1.5; +} + +.field-move-visual-label { + float: right; + margin-left: 4px; + font-style: italic; +} + +.menu-item-settings .field-move .button-link { + display: none; + margin: 0 2px; + font-style: italic; +} + +.menu-item-edit-active .menu-item-settings { + display: block; +} + +.menu-item-edit-inactive .menu-item-settings { + display: none; +} + +.add-menu-item-pagelinks { + margin: .5em -10px; + text-align: center; +} + +.add-menu-item-pagelinks .page-numbers { + display: inline-block; + min-width: 20px; +} + +.add-menu-item-pagelinks .page-numbers.dots { + min-width: 0; +} + +.link-to-original { + display: block; + margin: 0 0 15px; + padding: 3px 5px 5px; + border: 1px solid #ddd; + color: #72777c; + font-size: 12px; + font-style: italic; +} + +.link-to-original a { + padding-right: 4px; + font-style: normal; +} + +.hidden-field { + display: none; +} + +.menu-item-settings .description-thin, +.menu-item-settings .description-wide { + margin-left: 10px; + float: right; +} + +.description-thin { + width: 190px; +} + +.description-wide { + width: 390px; +} + +.menu-item-actions { + padding-top: 15px; + padding-bottom: 7px; +} + +#cancel-save { + cursor: pointer; +} + +/* Major/minor publishing actions (classes) */ +.nav-menus-php .major-publishing-actions { + clear: both; + padding: 10px 0; + line-height: 28px; +} + +.nav-menus-php .major-publishing-actions .publishing-action { + text-align: left; + float: left; +} + +.nav-menus-php .blank-slate .menu-settings { + display: none; +} + +/* Same as the Publish Meta Box #delete-action */ +.nav-menus-php .delete-action { + float: right; + line-height: 28px; +} + +.nav-menus-php .major-publishing-actions .form-invalid { + padding-right: 4px; + margin-right: -4px; +} + +#nav-menus-frame, +.button-controls, +#menu-item-url-wrap, +#menu-item-name-wrap { + display: block; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media only screen and (min-width: 769px) and (max-width: 1000px){ + body.menu-max-depth-0 { + min-width: 0 !important; + } + + #menu-management-liquid{ + width: 100%; + } + + .nav-menus-php #post-body-content{ + min-width: 0; + } + + .menu-item-bar .menu-item-handle{ + width: 90%; + } +} + +@media screen and ( max-width: 782px ) { + body.nav-menus-php, + body.wp-customizer { + min-width: 0 !important; + } + + #nav-menus-frame { + margin-right: 0; + float: none; + width: 100%; + } + + #wpbody-content #menu-settings-column { + display: block; + width: 100%; + float: none; + margin-right: 0; + } + + #side-sortables .add-menu-item-tabs { + margin: 15px 0 14px; + } + + ul.add-menu-item-tabs li.tabs { + padding: 13px 15px 14px; + } + + .nav-menus-php .customlinkdiv .howto input { + width: 65%; + } + + .nav-menus-php .quick-search { + width: 85%; + } + + #menu-management-liquid { + margin-top: 25px; + } + + .nav-menus-php .menu-name-label.howto span { + margin-top: 13px + } + + #menu-name { + width: 100%; + } + + .nav-menus-php .major-publishing-actions .publishing-action { + padding-top: 1em; + } + + .nav-menus-php .delete-action { + font-size: 14px; + line-height: 30px; + } + + .menu-item-bar .menu-item-handle, + .menu-item-settings, + .description-wide { + width: auto; + } + + .menu-item-settings { + padding: 10px; + } + + .menu-item-settings .description-thin, + .menu-item-settings .description-wide { + width: 100%; + } + + .menu-item-settings input { + width: 100%; + } + + .menu-item-settings input[type="checkbox"], + .menu-item-settings input[type="radio"] { + width: 25px; + } + + .menu-settings-group { + padding-right: 0; + } + + .menu-settings-group-name { + float: none; + width: auto; + margin-right: 0; + margin-bottom: 15px; + } + + .menu-settings-input { + float: none; + margin-bottom: 15px; + } + + .menu-edit .checkbox-input { + margin-top: 0; + } + + .manage-menus select { + margin: 0.5em 0; + } + + .widefat .menu-locations .menu-location-title { + padding-top: 16px; + } +} + +@media only screen and (max-width: 768px) { + /* menu locations */ + #menu-locations-wrap .widefat { + width: 100%; + } +} diff --git a/backend/wp-admin/css/nav-menus-rtl.min.css b/backend/wp-admin/css/nav-menus-rtl.min.css new file mode 100644 index 0000000..388d1bd --- /dev/null +++ b/backend/wp-admin/css/nav-menus-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.no-js #message{display:block}ul.add-menu-item-tabs li{padding:3px 8px 4px 5px}.accordion-section ul.add-menu-item-tabs,.accordion-section ul.category-tabs,.accordion-section ul.wp-tab-bar{margin:0}.accordion-section .categorychecklist{margin:13px 0}#nav-menu-meta .accordion-section-content{padding:18px 13px}#nav-menu-meta .button-controls{margin-bottom:0}.has-no-menu-item .button-controls{display:none}#nav-menus-frame{margin-right:300px;margin-top:23px}#wpbody-content #menu-settings-column{display:inline;width:281px;margin-right:-300px;clear:both;float:right;padding-top:0}#menu-settings-column .inside{clear:both;margin:10px 0 0}.metabox-holder-disabled .accordion-section-content,.metabox-holder-disabled .accordion-section-title,.metabox-holder-disabled .postbox{opacity:.5;filter:alpha(opacity=50)}.metabox-holder-disabled .button-controls .select-all{display:none}#wpbody{position:relative}.blank-slate .menu-settings{border:none;margin-top:0;padding-top:0;overflow:hidden}.is-submenu{color:#555d66;font-style:italic;font-weight:400;margin-right:4px}#menu-management .menu-add-new abbr,.menu-location-title label{font-weight:600}.manage-menus{margin-top:23px;padding:10px;overflow:hidden;background:#fbfbfb}.manage-menus .selected-menu,.manage-menus .submit-btn,.manage-menus select,.nav-menus-php .add-new-menu-action{display:inline-block;margin-left:3px;vertical-align:middle}.manage-menus select,.menu-location-menus select{max-width:100%}.menu-edit #post-body-content h3{margin:1em 0 10px}.menu-settings{border-top:1px solid #eee;margin-top:2em}.menu-settings-group{margin:0 0 10px;overflow:hidden;padding-right:20%}.menu-settings-group:last-of-type{margin-bottom:0}.menu-settings-input{float:right;margin:0;width:100%}.menu-settings-group-name{float:right;clear:both;width:25%;padding:3px 0 0;margin-right:-25%}.menu-settings label{vertical-align:baseline}.menu-edit .checkbox-input{margin-top:4px}.theme-location-set{color:#72777c;font-size:11px}#add-custom-link .howto,#cancel-save{font-size:12px}#menu-management-liquid{float:right;min-width:100%;margin-top:3px}#menu-management{position:relative;margin-left:20px;margin-top:-3px;width:100%;background:#f5f5f5}#menu-management .menu-edit{margin-bottom:20px}.nav-menus-php #post-body{padding:0 10px 10px;border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff}#nav-menu-footer,#nav-menu-header{padding:0 10px}#nav-menu-header{border-bottom:1px solid #ddd;margin-bottom:0}#nav-menu-header .menu-name-label{display:inline-block;vertical-align:middle;margin-left:7px;font-style:italic}.nav-menus-php #post-body div.error,.nav-menus-php #post-body div.updated{margin:0}.nav-menus-php #post-body-content{position:relative;float:none}#select-nav-menu-container{text-align:left;padding:0 10px 3px;margin-bottom:5px}#select-nav-menu{width:100px;display:inline}#menu-name-label{margin-top:-2px}.widefat .menu-locations .menu-location-title{padding:13px 10px 0}.menu-location-menus select{float:right}#locations-nav-menu-wrapper{padding:5px 0}.locations-nav-menu-select select{float:right;width:160px;margin-left:5px}.locations-row-links{float:right;margin:6px 6px 0 0}.locations-add-menu-link,.locations-edit-menu-link{margin:0 3px}.locations-edit-menu-link{padding-left:3px;border-left:1px solid #ccc}#menu-management .inside{padding:0 10px}.customlinkdiv .menu-item-textbox,.postbox .howto input{width:180px;float:left}.accordion-container .outer-border{margin:0}.customlinkdiv p{margin-top:0}#nav-menu-theme-locations .howto select{width:100%}#nav-menu-theme-locations .button-controls{text-align:left}.add-menu-item-view-all{height:400px}#menu-container .submit{margin:0 0 10px;padding:0}#cancel-save{text-decoration:underline;margin-right:20px;margin-top:5px}.button-primary.right,.button-secondary.right,.button.right{float:left}.list-controls{float:right;margin-top:5px}.add-to-menu{float:left}.button-controls{clear:both;margin:10px 0}.hide-all,.show-all{cursor:pointer}.hide-all{display:none}#menu-name{width:270px;vertical-align:middle}#manage-menu .inside{padding:0}#available-links dt{display:block}#add-custom-link label span{display:block;float:right;margin-top:5px;padding-left:5px}.menu-item-textbox{width:180px}.customlinkdiv label,.nav-menus-php .howto span{float:right;margin-top:6px}.quick-search{width:190px}.quick-search-wrap .spinner{float:none;margin:-3px 0 0 -10px}.nav-menus-php .list-wrap{display:none;clear:both;margin-bottom:10px}.nav-menus-php .postbox p.submit{margin-bottom:0}.nav-menus-php .list li{display:none;margin:0 0 5px}.nav-menus-php .list li .menu-item-title{cursor:pointer;display:block}.nav-menus-php .list li .menu-item-title input{margin-left:3px;margin-top:-3px}.menu-item-title input[type=checkbox]{display:inline-block;margin-top:-4px}#menu-container .inside{padding-bottom:10px}.menu{padding-top:1em}#menu-to-edit{margin:0;padding:.1em 0}.menu ul{width:100%}.menu li{margin-bottom:0;position:relative}.menu-item-bar{clear:both;line-height:1.5em;position:relative;margin:9px 0 0}.menu-item-bar .menu-item-handle{border:1px solid #ddd;position:relative;padding:10px 15px;height:auto;min-height:20px;width:382px;line-height:30px;overflow:hidden;word-wrap:break-word}.menu-item-bar .menu-item-handle:hover{border-color:#999}#menu-to-edit .menu-item-invalid .menu-item-handle{background:#f6c9cc;border-color:#f1acb1}.no-js .menu-item-edit-active .item-edit{display:none}.js .menu-item-handle{cursor:move}#cancel-save,.item-controls a:hover{cursor:pointer}.menu li.deleting .menu-item-handle{background-image:none;background-color:#f66}.menu-item-handle .item-title{font-size:13px;font-weight:600;line-height:20px;display:block;margin-left:13em}.menu-item-handle .menu-item-title.no-title{color:#72777c}li.menu-item.ui-sortable-helper .menu-item-bar{margin-top:0}li.menu-item.ui-sortable-helper .menu-item-transport .menu-item-bar{margin-top:13px}.menu .sortable-placeholder{height:35px;width:410px;margin-top:13px}.menu-item .menu-item-transport:empty{display:none}.menu-item-depth-0{margin-right:0}.menu-item-depth-1{margin-right:30px}.menu-item-depth-2{margin-right:60px}.menu-item-depth-3{margin-right:90px}.menu-item-depth-4{margin-right:120px}.menu-item-depth-5{margin-right:150px}.menu-item-depth-6{margin-right:180px}.menu-item-depth-7{margin-right:210px}.menu-item-depth-8{margin-right:240px}.menu-item-depth-9{margin-right:270px}.menu-item-depth-10{margin-right:300px}.menu-item-depth-11{margin-right:330px}.menu-item-depth-0 .menu-item-transport{margin-right:0}.menu-item-depth-1 .menu-item-transport{margin-right:-30px}.menu-item-depth-2 .menu-item-transport{margin-right:-60px}.menu-item-depth-3 .menu-item-transport{margin-right:-90px}.menu-item-depth-4 .menu-item-transport{margin-right:-120px}.menu-item-depth-5 .menu-item-transport{margin-right:-150px}.menu-item-depth-6 .menu-item-transport{margin-right:-180px}.menu-item-depth-7 .menu-item-transport{margin-right:-210px}.menu-item-depth-8 .menu-item-transport{margin-right:-240px}.menu-item-depth-9 .menu-item-transport{margin-right:-270px}.menu-item-depth-10 .menu-item-transport{margin-right:-300px}.menu-item-depth-11 .menu-item-transport{margin-right:-330px}body.menu-max-depth-0{min-width:950px!important}body.menu-max-depth-1{min-width:980px!important}body.menu-max-depth-2{min-width:1010px!important}body.menu-max-depth-3{min-width:1040px!important}body.menu-max-depth-4{min-width:1070px!important}body.menu-max-depth-5{min-width:1100px!important}body.menu-max-depth-6{min-width:1130px!important}body.menu-max-depth-7{min-width:1160px!important}body.menu-max-depth-8{min-width:1190px!important}body.menu-max-depth-9{min-width:1220px!important}body.menu-max-depth-10{min-width:1250px!important}body.menu-max-depth-11{min-width:1280px!important}.item-type{display:inline-block;padding:12px 16px;color:#666;font-size:12px;line-height:18px}.item-controls{font-size:12px;position:absolute;left:20px;top:-1px}.item-controls a{text-decoration:none}.item-controls .item-order{padding-left:10px}.nav-menus-php .item-edit{position:absolute;left:-20px;top:0;display:block;width:30px;height:40px;outline:0}.no-js.nav-menus-php .item-edit{position:static;float:left;width:auto;height:auto;margin:12px 0 12px -10px;padding:0;color:#0073aa;text-decoration:underline;font-size:12px;line-height:18px}.no-js.nav-menus-php .item-edit .screen-reader-text{position:static;-webkit-clip-path:none;clip-path:none;width:auto;height:auto;margin:0}.nav-menus-php .item-edit:before{margin-top:10px;margin-right:4px;width:20px;border-radius:50%;text-indent:-1px}.no-js.nav-menus-php .item-edit:before{display:none}.rtl .nav-menus-php .item-edit:before{text-indent:1px}.js.nav-menus-php .item-edit:focus{box-shadow:none}.nav-menus-php .item-edit:focus:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.menu-instructions-inactive{display:none}.menu-item-settings{display:block;width:402px;padding:10px 10px 10px 0;position:relative;z-index:10;border:1px solid #e5e5e5;border-top:none;box-shadow:0 1px 1px rgba(0,0,0,.04)}.menu-item-settings .field-move{margin:3px 0 5px;line-height:1.5}.field-move-visual-label{float:right;margin-left:4px;font-style:italic}.menu-item-settings .field-move .button-link{display:none;margin:0 2px;font-style:italic}.menu-item-edit-active .menu-item-settings{display:block}.menu-item-edit-inactive .menu-item-settings{display:none}.add-menu-item-pagelinks{margin:.5em -10px;text-align:center}.add-menu-item-pagelinks .page-numbers{display:inline-block;min-width:20px}.add-menu-item-pagelinks .page-numbers.dots{min-width:0}.link-to-original{display:block;margin:0 0 15px;padding:3px 5px 5px;border:1px solid #ddd;color:#72777c;font-size:12px;font-style:italic}.hidden-field,.nav-menus-php .blank-slate .menu-settings{display:none}.link-to-original a{padding-right:4px;font-style:normal}.menu-item-settings .description-thin,.menu-item-settings .description-wide{margin-left:10px;float:right}.description-thin{width:190px}.description-wide{width:390px}.menu-item-actions{padding-top:15px;padding-bottom:7px}.nav-menus-php .major-publishing-actions{clear:both;padding:10px 0;line-height:28px}.nav-menus-php .major-publishing-actions .publishing-action{text-align:left;float:left}.nav-menus-php .delete-action{float:right;line-height:28px}.nav-menus-php .major-publishing-actions .form-invalid{padding-right:4px;margin-right:-4px}#menu-item-name-wrap,#menu-item-url-wrap,#nav-menus-frame,.button-controls{display:block}@media only screen and (min-width:769px) and (max-width:1000px){body.menu-max-depth-0{min-width:0!important}#menu-management-liquid{width:100%}.nav-menus-php #post-body-content{min-width:0}.menu-item-bar .menu-item-handle{width:90%}}@media screen and (max-width:782px){body.nav-menus-php,body.wp-customizer{min-width:0!important}#nav-menus-frame{margin-right:0;float:none;width:100%}#wpbody-content #menu-settings-column{display:block;width:100%;float:none;margin-right:0}#side-sortables .add-menu-item-tabs{margin:15px 0 14px}.menu-settings-group-name,.menu-settings-input{float:none;margin-bottom:15px}ul.add-menu-item-tabs li.tabs{padding:13px 15px 14px}.nav-menus-php .customlinkdiv .howto input{width:65%}.nav-menus-php .quick-search{width:85%}#menu-management-liquid{margin-top:25px}.nav-menus-php .menu-name-label.howto span{margin-top:13px}#menu-name{width:100%}.nav-menus-php .major-publishing-actions .publishing-action{padding-top:1em}.nav-menus-php .delete-action{font-size:14px;line-height:30px}.description-wide,.menu-item-bar .menu-item-handle,.menu-item-settings{width:auto}.menu-item-settings{padding:10px}.menu-item-settings .description-thin,.menu-item-settings .description-wide,.menu-item-settings input{width:100%}.menu-item-settings input[type=checkbox],.menu-item-settings input[type=radio]{width:25px}.menu-settings-group{padding-right:0}.menu-settings-group-name{width:auto;margin-right:0}.menu-edit .checkbox-input{margin-top:0}.manage-menus select{margin:.5em 0}.widefat .menu-locations .menu-location-title{padding-top:16px}}@media only screen and (max-width:768px){#menu-locations-wrap .widefat{width:100%}} \ No newline at end of file diff --git a/backend/wp-admin/css/nav-menus.css b/backend/wp-admin/css/nav-menus.css new file mode 100644 index 0000000..4021b03 --- /dev/null +++ b/backend/wp-admin/css/nav-menus.css @@ -0,0 +1,901 @@ +/* nav-menu */ + +/* @todo: determine if this is truly for nav menus only */ +.no-js #message { + display: block; +} + +ul.add-menu-item-tabs li { + padding: 3px 5px 4px 8px; +} + +.accordion-section ul.category-tabs, +.accordion-section ul.add-menu-item-tabs, +.accordion-section ul.wp-tab-bar { + margin: 0; +} + +.accordion-section .categorychecklist { + margin: 13px 0; +} + +#nav-menu-meta .accordion-section-content { + padding: 18px 13px; +} + +#nav-menu-meta .button-controls { + margin-bottom: 0; +} + +.has-no-menu-item .button-controls { + display: none; +} + +#nav-menus-frame { + margin-left: 300px; + margin-top: 23px; +} + +#wpbody-content #menu-settings-column { + display:inline; + width:281px; + margin-left: -300px; + clear: both; + float: left; + padding-top: 0; +} + +#menu-settings-column .inside { + clear: both; + margin: 10px 0 0; +} + +.metabox-holder-disabled .postbox, +.metabox-holder-disabled .accordion-section-content, +.metabox-holder-disabled .accordion-section-title { + opacity: 0.5; + filter: alpha(opacity=50); +} + +.metabox-holder-disabled .button-controls .select-all { + display: none; +} + +#wpbody { + position: relative; +} + +.blank-slate .menu-settings { + border: none; + margin-top: 0; + padding-top: 0; + overflow: hidden; +} + +.is-submenu { + color: #555d66; /* #fafafa background */ + font-style: italic; + font-weight: 400; + margin-left: 4px; +} + +.manage-menus { + margin-top: 23px; + padding: 10px; + overflow: hidden; + background: #fbfbfb; +} + +.manage-menus .selected-menu, +.manage-menus select, +.manage-menus .submit-btn, +.nav-menus-php .add-new-menu-action { + display: inline-block; + margin-right: 3px; + vertical-align: middle; +} + +.manage-menus select, +.menu-location-menus select { + max-width: 100%; +} + +.menu-edit #post-body-content h3 { + margin: 1em 0 10px; +} + +.menu-settings { + border-top: 1px solid #eee; + margin-top: 2em; +} + +.menu-settings-group { + margin: 0 0 10px; + overflow: hidden; + padding-left: 20%; +} + +.menu-settings-group:last-of-type { + margin-bottom: 0; +} + +.menu-settings-input { + float: left; + margin: 0; + width: 100%; +} + +.menu-settings-group-name { + float: left; + clear: both; + width: 25%; + padding: 3px 0 0; + margin-left: -25%; /* 20 container left padding x ( 100 container % width / 80 this % width ) */ +} + +.menu-settings label { + vertical-align: baseline; +} + +.menu-edit .checkbox-input { + margin-top: 4px; +} + +.theme-location-set { + color: #72777c; + font-size: 11px; +} + +/* Menu Container */ + +/* @todo: responsive view. */ +#menu-management-liquid { + float: left; + min-width: 100%; + margin-top: 3px; +} + +/* @todo: responsive view. */ +#menu-management { + position: relative; + margin-right: 20px; + margin-top: -3px; + width: 100%; + background: #f5f5f5; +} + +#menu-management .menu-edit { + margin-bottom: 20px; +} + +.nav-menus-php #post-body { + padding: 0 10px 10px; + border-top: 1px solid #fff; + border-bottom: 1px solid #ddd; + background: #fff; +} + +#nav-menu-header, +#nav-menu-footer { + padding: 0 10px; +} + +#nav-menu-header { + border-bottom: 1px solid #ddd; + margin-bottom: 0; +} + +#nav-menu-header .menu-name-label { + display: inline-block; + vertical-align: middle; + margin-right: 7px; + font-style: italic; +} + +.nav-menus-php #post-body div.updated, +.nav-menus-php #post-body div.error { + margin: 0; +} + +.nav-menus-php #post-body-content { + position: relative; + float: none; +} + +#menu-management .menu-add-new abbr { + font-weight:600; +} + +#select-nav-menu-container { + text-align: right; + padding: 0 10px 3px 10px; + margin-bottom: 5px; +} + +#select-nav-menu { + width: 100px; + display: inline; +} + +#menu-name-label { + margin-top: -2px; +} + +.widefat .menu-locations .menu-location-title { + padding: 13px 10px 0; +} + +.menu-location-title label { + font-weight: 600; +} + +.menu-location-menus select { + float: left; +} + +#locations-nav-menu-wrapper { + padding: 5px 0; +} + +.locations-nav-menu-select select { + float: left; + width: 160px; + margin-right: 5px; +} + +.locations-row-links { + float: left; + margin: 6px 0 0 6px; +} + +.locations-edit-menu-link, +.locations-add-menu-link { + margin: 0 3px; +} + +.locations-edit-menu-link { + padding-right: 3px; + border-right: 1px solid #ccc; +} + +#menu-management .inside { + padding: 0 10px; +} + +/* Add Menu Item Boxes */ +.postbox .howto input, +.customlinkdiv .menu-item-textbox { + width: 180px; + float: right; +} + +.accordion-container .outer-border { + margin: 0; +} + +.customlinkdiv p { + margin-top: 0 +} + +#nav-menu-theme-locations .howto select { + width: 100%; +} + +#nav-menu-theme-locations .button-controls { + text-align: right; +} + +.add-menu-item-view-all { + height: 400px; +} + +/* Button Primary Actions */ +#menu-container .submit { + margin: 0 0 10px; + padding: 0; +} + +/* @todo: is this actually used? */ +#cancel-save { + text-decoration: underline; + font-size: 12px; + margin-left: 20px; + margin-top: 5px; +} + +.button.right, .button-secondary.right, .button-primary.right { + float: right; +} + +/* Button Secondary Actions */ +.list-controls { + float: left; + margin-top: 5px; +} + +.add-to-menu { + float: right; +} + +.button-controls { + clear:both; + margin: 10px 0; +} + +.show-all, +.hide-all { + cursor: pointer; +} + +.hide-all { + display: none; +} + +/* Create Menu */ +#menu-name { + width: 270px; + vertical-align: middle; +} + +#manage-menu .inside { + padding: 0px 0px; +} + +/* Custom Links */ +#available-links dt { + display: block; +} + +#add-custom-link .howto { + font-size: 12px; +} + +#add-custom-link label span { + display: block; + float: left; + margin-top: 5px; + padding-right: 5px; +} + +.menu-item-textbox { + width: 180px; +} + +.customlinkdiv label, +.nav-menus-php .howto span { + float: left; + margin-top: 6px; +} + +/* Menu item types */ +.quick-search { + width: 190px; +} + +.quick-search-wrap .spinner { + float: none; + margin: -3px -10px 0 0; +} + +.nav-menus-php .list-wrap { + display: none; + clear: both; + margin-bottom: 10px; +} + +.nav-menus-php .postbox p.submit { + margin-bottom: 0; +} + +/* Listings */ +.nav-menus-php .list li { + display: none; + margin: 0; + margin-bottom: 5px; +} + +.nav-menus-php .list li .menu-item-title { + cursor: pointer; + display: block; +} + +.nav-menus-php .list li .menu-item-title input { + margin-right: 3px; + margin-top: -3px; +} + +.menu-item-title input[type=checkbox] { + display: inline-block; + margin-top: -4px; +} + +/* Nav Menu */ +#menu-container .inside { + padding-bottom: 10px; +} + +.menu { + padding-top:1em; +} + +#menu-to-edit { + margin: 0; + padding: 0.1em 0; +} + +.menu ul { + width: 100%; +} + +.menu li { + margin-bottom: 0; + position:relative; +} + +.menu-item-bar { + clear:both; + line-height:1.5em; + position:relative; + margin: 9px 0 0; +} + +.menu-item-bar .menu-item-handle { + border: 1px solid #ddd; + position: relative; + padding: 10px 15px; + height: auto; + min-height: 20px; + width: 382px; + line-height: 30px; + overflow: hidden; + word-wrap: break-word; +} + +.menu-item-bar .menu-item-handle:hover { + border-color: #999; +} + +#menu-to-edit .menu-item-invalid .menu-item-handle { + background: #f6c9cc; + border-color: #f1acb1; +} + +.no-js .menu-item-edit-active .item-edit { + display: none; +} + +.js .menu-item-handle { + cursor: move; +} + +.menu li.deleting .menu-item-handle { + background-image: none; + background-color: #f66; +} + +.menu-item-handle .item-title { + font-size: 13px; + font-weight: 600; + line-height: 20px; + display: block; + /* @todo: responsive view. */ + margin-right: 13em; +} + +.menu-item-handle .menu-item-title.no-title { + color: #72777c; +} + +/* Sortables */ +li.menu-item.ui-sortable-helper .menu-item-bar { + margin-top: 0; +} + +li.menu-item.ui-sortable-helper .menu-item-transport .menu-item-bar { + margin-top: 13px; +} + +.menu .sortable-placeholder { + height: 35px; + width: 410px; + margin-top: 13px; +} + +/* Hide the transport list when it's empty */ +.menu-item .menu-item-transport:empty { + display: none; +} + +/* WARNING: The factor of 30px is hardcoded into the nav-menus JavaScript. */ +.menu-item-depth-0 { margin-left: 0px; } +.menu-item-depth-1 { margin-left: 30px; } +.menu-item-depth-2 { margin-left: 60px; } +.menu-item-depth-3 { margin-left: 90px; } +.menu-item-depth-4 { margin-left: 120px; } +.menu-item-depth-5 { margin-left: 150px; } +.menu-item-depth-6 { margin-left: 180px; } +.menu-item-depth-7 { margin-left: 210px; } +.menu-item-depth-8 { margin-left: 240px; } +.menu-item-depth-9 { margin-left: 270px; } +.menu-item-depth-10 { margin-left: 300px; } +.menu-item-depth-11 { margin-left: 330px; } + +.menu-item-depth-0 .menu-item-transport { margin-left: 0px; } +.menu-item-depth-1 .menu-item-transport { margin-left: -30px; } +.menu-item-depth-2 .menu-item-transport { margin-left: -60px; } +.menu-item-depth-3 .menu-item-transport { margin-left: -90px; } +.menu-item-depth-4 .menu-item-transport { margin-left: -120px; } +.menu-item-depth-5 .menu-item-transport { margin-left: -150px; } +.menu-item-depth-6 .menu-item-transport { margin-left: -180px; } +.menu-item-depth-7 .menu-item-transport { margin-left: -210px; } +.menu-item-depth-8 .menu-item-transport { margin-left: -240px; } +.menu-item-depth-9 .menu-item-transport { margin-left: -270px; } +.menu-item-depth-10 .menu-item-transport { margin-left: -300px; } +.menu-item-depth-11 .menu-item-transport { margin-left: -330px; } + +body.menu-max-depth-0 { min-width: 950px !important; } +body.menu-max-depth-1 { min-width: 980px !important; } +body.menu-max-depth-2 { min-width: 1010px !important; } +body.menu-max-depth-3 { min-width: 1040px !important; } +body.menu-max-depth-4 { min-width: 1070px !important; } +body.menu-max-depth-5 { min-width: 1100px !important; } +body.menu-max-depth-6 { min-width: 1130px !important; } +body.menu-max-depth-7 { min-width: 1160px !important; } +body.menu-max-depth-8 { min-width: 1190px !important; } +body.menu-max-depth-9 { min-width: 1220px !important; } +body.menu-max-depth-10 { min-width: 1250px !important; } +body.menu-max-depth-11 { min-width: 1280px !important; } + +/* Menu item controls */ +.item-type { + display: inline-block; + padding: 12px 16px; + color: #666; + font-size: 12px; + line-height: 18px; +} + +.item-controls { + font-size: 12px; + position: absolute; + right: 20px; + top: -1px; +} + +.item-controls a { + text-decoration: none; +} + +.item-controls a:hover { + cursor: pointer; +} + +.item-controls .item-order { + padding-right: 10px; +} + +.nav-menus-php .item-edit { + position: absolute; + right: -20px; + top: 0; + display: block; + width: 30px; + height: 40px; + outline: none; +} + +.no-js.nav-menus-php .item-edit { + position: static; + float: right; + width: auto; + height: auto; + margin: 12px -10px 12px 0; + padding: 0; + color: #0073aa; + text-decoration: underline; + font-size: 12px; + line-height: 18px; +} + +.no-js.nav-menus-php .item-edit .screen-reader-text { + position: static; + -webkit-clip-path: none; + clip-path: none; + width: auto; + height: auto; + margin: 0; +} + +.nav-menus-php .item-edit:before { + margin-top: 10px; + margin-left: 4px; + width: 20px; + border-radius: 50%; + text-indent: -1px; /* account for the dashicon alignment */ +} + +.no-js.nav-menus-php .item-edit:before { + display: none; +} + +.rtl .nav-menus-php .item-edit:before { + text-indent: 1px; /* account for the dashicon alignment */ +} + +.js.nav-menus-php .item-edit:focus { + box-shadow: none; +} + +.nav-menus-php .item-edit:focus:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +/* Menu editing */ +.menu-instructions-inactive { + display: none; +} + +.menu-item-settings { + display: block; + width: 402px; + padding: 10px 0 10px 10px; + position: relative; + z-index: 10; /* Keep .item-title's shadow from appearing on top of .menu-item-settings */ + border: 1px solid #e5e5e5; + border-top: none; + box-shadow: 0 1px 1px rgba(0,0,0,0.04); +} + +.menu-item-settings .field-move { + margin: 3px 0 5px; + line-height: 1.5; +} + +.field-move-visual-label { + float: left; + margin-right: 4px; + font-style: italic; +} + +.menu-item-settings .field-move .button-link { + display: none; + margin: 0 2px; + font-style: italic; +} + +.menu-item-edit-active .menu-item-settings { + display: block; +} + +.menu-item-edit-inactive .menu-item-settings { + display: none; +} + +.add-menu-item-pagelinks { + margin: .5em -10px; + text-align: center; +} + +.add-menu-item-pagelinks .page-numbers { + display: inline-block; + min-width: 20px; +} + +.add-menu-item-pagelinks .page-numbers.dots { + min-width: 0; +} + +.link-to-original { + display: block; + margin: 0 0 15px; + padding: 3px 5px 5px; + border: 1px solid #ddd; + color: #72777c; + font-size: 12px; + font-style: italic; +} + +.link-to-original a { + padding-left: 4px; + font-style: normal; +} + +.hidden-field { + display: none; +} + +.menu-item-settings .description-thin, +.menu-item-settings .description-wide { + margin-right: 10px; + float: left; +} + +.description-thin { + width: 190px; +} + +.description-wide { + width: 390px; +} + +.menu-item-actions { + padding-top: 15px; + padding-bottom: 7px; +} + +#cancel-save { + cursor: pointer; +} + +/* Major/minor publishing actions (classes) */ +.nav-menus-php .major-publishing-actions { + clear: both; + padding: 10px 0; + line-height: 28px; +} + +.nav-menus-php .major-publishing-actions .publishing-action { + text-align: right; + float: right; +} + +.nav-menus-php .blank-slate .menu-settings { + display: none; +} + +/* Same as the Publish Meta Box #delete-action */ +.nav-menus-php .delete-action { + float: left; + line-height: 28px; +} + +.nav-menus-php .major-publishing-actions .form-invalid { + padding-left: 4px; + margin-left: -4px; +} + +#nav-menus-frame, +.button-controls, +#menu-item-url-wrap, +#menu-item-name-wrap { + display: block; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media only screen and (min-width: 769px) and (max-width: 1000px){ + body.menu-max-depth-0 { + min-width: 0 !important; + } + + #menu-management-liquid{ + width: 100%; + } + + .nav-menus-php #post-body-content{ + min-width: 0; + } + + .menu-item-bar .menu-item-handle{ + width: 90%; + } +} + +@media screen and ( max-width: 782px ) { + body.nav-menus-php, + body.wp-customizer { + min-width: 0 !important; + } + + #nav-menus-frame { + margin-left: 0; + float: none; + width: 100%; + } + + #wpbody-content #menu-settings-column { + display: block; + width: 100%; + float: none; + margin-left: 0; + } + + #side-sortables .add-menu-item-tabs { + margin: 15px 0 14px; + } + + ul.add-menu-item-tabs li.tabs { + padding: 13px 15px 14px; + } + + .nav-menus-php .customlinkdiv .howto input { + width: 65%; + } + + .nav-menus-php .quick-search { + width: 85%; + } + + #menu-management-liquid { + margin-top: 25px; + } + + .nav-menus-php .menu-name-label.howto span { + margin-top: 13px + } + + #menu-name { + width: 100%; + } + + .nav-menus-php .major-publishing-actions .publishing-action { + padding-top: 1em; + } + + .nav-menus-php .delete-action { + font-size: 14px; + line-height: 30px; + } + + .menu-item-bar .menu-item-handle, + .menu-item-settings, + .description-wide { + width: auto; + } + + .menu-item-settings { + padding: 10px; + } + + .menu-item-settings .description-thin, + .menu-item-settings .description-wide { + width: 100%; + } + + .menu-item-settings input { + width: 100%; + } + + .menu-item-settings input[type="checkbox"], + .menu-item-settings input[type="radio"] { + width: 25px; + } + + .menu-settings-group { + padding-left: 0; + } + + .menu-settings-group-name { + float: none; + width: auto; + margin-left: 0; + margin-bottom: 15px; + } + + .menu-settings-input { + float: none; + margin-bottom: 15px; + } + + .menu-edit .checkbox-input { + margin-top: 0; + } + + .manage-menus select { + margin: 0.5em 0; + } + + .widefat .menu-locations .menu-location-title { + padding-top: 16px; + } +} + +@media only screen and (max-width: 768px) { + /* menu locations */ + #menu-locations-wrap .widefat { + width: 100%; + } +} diff --git a/backend/wp-admin/css/nav-menus.min.css b/backend/wp-admin/css/nav-menus.min.css new file mode 100644 index 0000000..94d637a --- /dev/null +++ b/backend/wp-admin/css/nav-menus.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.no-js #message{display:block}ul.add-menu-item-tabs li{padding:3px 5px 4px 8px}.accordion-section ul.add-menu-item-tabs,.accordion-section ul.category-tabs,.accordion-section ul.wp-tab-bar{margin:0}.accordion-section .categorychecklist{margin:13px 0}#nav-menu-meta .accordion-section-content{padding:18px 13px}#nav-menu-meta .button-controls{margin-bottom:0}.has-no-menu-item .button-controls{display:none}#nav-menus-frame{margin-left:300px;margin-top:23px}#wpbody-content #menu-settings-column{display:inline;width:281px;margin-left:-300px;clear:both;float:left;padding-top:0}#menu-settings-column .inside{clear:both;margin:10px 0 0}.metabox-holder-disabled .accordion-section-content,.metabox-holder-disabled .accordion-section-title,.metabox-holder-disabled .postbox{opacity:.5;filter:alpha(opacity=50)}.metabox-holder-disabled .button-controls .select-all{display:none}#wpbody{position:relative}.blank-slate .menu-settings{border:none;margin-top:0;padding-top:0;overflow:hidden}.is-submenu{color:#555d66;font-style:italic;font-weight:400;margin-left:4px}#menu-management .menu-add-new abbr,.menu-location-title label{font-weight:600}.manage-menus{margin-top:23px;padding:10px;overflow:hidden;background:#fbfbfb}.manage-menus .selected-menu,.manage-menus .submit-btn,.manage-menus select,.nav-menus-php .add-new-menu-action{display:inline-block;margin-right:3px;vertical-align:middle}.manage-menus select,.menu-location-menus select{max-width:100%}.menu-edit #post-body-content h3{margin:1em 0 10px}.menu-settings{border-top:1px solid #eee;margin-top:2em}.menu-settings-group{margin:0 0 10px;overflow:hidden;padding-left:20%}.menu-settings-group:last-of-type{margin-bottom:0}.menu-settings-input{float:left;margin:0;width:100%}.menu-settings-group-name{float:left;clear:both;width:25%;padding:3px 0 0;margin-left:-25%}.menu-settings label{vertical-align:baseline}.menu-edit .checkbox-input{margin-top:4px}.theme-location-set{color:#72777c;font-size:11px}#add-custom-link .howto,#cancel-save{font-size:12px}#menu-management-liquid{float:left;min-width:100%;margin-top:3px}#menu-management{position:relative;margin-right:20px;margin-top:-3px;width:100%;background:#f5f5f5}#menu-management .menu-edit{margin-bottom:20px}.nav-menus-php #post-body{padding:0 10px 10px;border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#fff}#nav-menu-footer,#nav-menu-header{padding:0 10px}#nav-menu-header{border-bottom:1px solid #ddd;margin-bottom:0}#nav-menu-header .menu-name-label{display:inline-block;vertical-align:middle;margin-right:7px;font-style:italic}.nav-menus-php #post-body div.error,.nav-menus-php #post-body div.updated{margin:0}.nav-menus-php #post-body-content{position:relative;float:none}#select-nav-menu-container{text-align:right;padding:0 10px 3px;margin-bottom:5px}#select-nav-menu{width:100px;display:inline}#menu-name-label{margin-top:-2px}.widefat .menu-locations .menu-location-title{padding:13px 10px 0}.menu-location-menus select{float:left}#locations-nav-menu-wrapper{padding:5px 0}.locations-nav-menu-select select{float:left;width:160px;margin-right:5px}.locations-row-links{float:left;margin:6px 0 0 6px}.locations-add-menu-link,.locations-edit-menu-link{margin:0 3px}.locations-edit-menu-link{padding-right:3px;border-right:1px solid #ccc}#menu-management .inside{padding:0 10px}.customlinkdiv .menu-item-textbox,.postbox .howto input{width:180px;float:right}.accordion-container .outer-border{margin:0}.customlinkdiv p{margin-top:0}#nav-menu-theme-locations .howto select{width:100%}#nav-menu-theme-locations .button-controls{text-align:right}.add-menu-item-view-all{height:400px}#menu-container .submit{margin:0 0 10px;padding:0}#cancel-save{text-decoration:underline;margin-left:20px;margin-top:5px}.button-primary.right,.button-secondary.right,.button.right{float:right}.list-controls{float:left;margin-top:5px}.add-to-menu{float:right}.button-controls{clear:both;margin:10px 0}.hide-all,.show-all{cursor:pointer}.hide-all{display:none}#menu-name{width:270px;vertical-align:middle}#manage-menu .inside{padding:0}#available-links dt{display:block}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px}.menu-item-textbox{width:180px}.customlinkdiv label,.nav-menus-php .howto span{float:left;margin-top:6px}.quick-search{width:190px}.quick-search-wrap .spinner{float:none;margin:-3px -10px 0 0}.nav-menus-php .list-wrap{display:none;clear:both;margin-bottom:10px}.nav-menus-php .postbox p.submit{margin-bottom:0}.nav-menus-php .list li{display:none;margin:0 0 5px}.nav-menus-php .list li .menu-item-title{cursor:pointer;display:block}.nav-menus-php .list li .menu-item-title input{margin-right:3px;margin-top:-3px}.menu-item-title input[type=checkbox]{display:inline-block;margin-top:-4px}#menu-container .inside{padding-bottom:10px}.menu{padding-top:1em}#menu-to-edit{margin:0;padding:.1em 0}.menu ul{width:100%}.menu li{margin-bottom:0;position:relative}.menu-item-bar{clear:both;line-height:1.5em;position:relative;margin:9px 0 0}.menu-item-bar .menu-item-handle{border:1px solid #ddd;position:relative;padding:10px 15px;height:auto;min-height:20px;width:382px;line-height:30px;overflow:hidden;word-wrap:break-word}.menu-item-bar .menu-item-handle:hover{border-color:#999}#menu-to-edit .menu-item-invalid .menu-item-handle{background:#f6c9cc;border-color:#f1acb1}.no-js .menu-item-edit-active .item-edit{display:none}.js .menu-item-handle{cursor:move}#cancel-save,.item-controls a:hover{cursor:pointer}.menu li.deleting .menu-item-handle{background-image:none;background-color:#f66}.menu-item-handle .item-title{font-size:13px;font-weight:600;line-height:20px;display:block;margin-right:13em}.menu-item-handle .menu-item-title.no-title{color:#72777c}li.menu-item.ui-sortable-helper .menu-item-bar{margin-top:0}li.menu-item.ui-sortable-helper .menu-item-transport .menu-item-bar{margin-top:13px}.menu .sortable-placeholder{height:35px;width:410px;margin-top:13px}.menu-item .menu-item-transport:empty{display:none}.menu-item-depth-0{margin-left:0}.menu-item-depth-1{margin-left:30px}.menu-item-depth-2{margin-left:60px}.menu-item-depth-3{margin-left:90px}.menu-item-depth-4{margin-left:120px}.menu-item-depth-5{margin-left:150px}.menu-item-depth-6{margin-left:180px}.menu-item-depth-7{margin-left:210px}.menu-item-depth-8{margin-left:240px}.menu-item-depth-9{margin-left:270px}.menu-item-depth-10{margin-left:300px}.menu-item-depth-11{margin-left:330px}.menu-item-depth-0 .menu-item-transport{margin-left:0}.menu-item-depth-1 .menu-item-transport{margin-left:-30px}.menu-item-depth-2 .menu-item-transport{margin-left:-60px}.menu-item-depth-3 .menu-item-transport{margin-left:-90px}.menu-item-depth-4 .menu-item-transport{margin-left:-120px}.menu-item-depth-5 .menu-item-transport{margin-left:-150px}.menu-item-depth-6 .menu-item-transport{margin-left:-180px}.menu-item-depth-7 .menu-item-transport{margin-left:-210px}.menu-item-depth-8 .menu-item-transport{margin-left:-240px}.menu-item-depth-9 .menu-item-transport{margin-left:-270px}.menu-item-depth-10 .menu-item-transport{margin-left:-300px}.menu-item-depth-11 .menu-item-transport{margin-left:-330px}body.menu-max-depth-0{min-width:950px!important}body.menu-max-depth-1{min-width:980px!important}body.menu-max-depth-2{min-width:1010px!important}body.menu-max-depth-3{min-width:1040px!important}body.menu-max-depth-4{min-width:1070px!important}body.menu-max-depth-5{min-width:1100px!important}body.menu-max-depth-6{min-width:1130px!important}body.menu-max-depth-7{min-width:1160px!important}body.menu-max-depth-8{min-width:1190px!important}body.menu-max-depth-9{min-width:1220px!important}body.menu-max-depth-10{min-width:1250px!important}body.menu-max-depth-11{min-width:1280px!important}.item-type{display:inline-block;padding:12px 16px;color:#666;font-size:12px;line-height:18px}.item-controls{font-size:12px;position:absolute;right:20px;top:-1px}.item-controls a{text-decoration:none}.item-controls .item-order{padding-right:10px}.nav-menus-php .item-edit{position:absolute;right:-20px;top:0;display:block;width:30px;height:40px;outline:0}.no-js.nav-menus-php .item-edit{position:static;float:right;width:auto;height:auto;margin:12px -10px 12px 0;padding:0;color:#0073aa;text-decoration:underline;font-size:12px;line-height:18px}.no-js.nav-menus-php .item-edit .screen-reader-text{position:static;-webkit-clip-path:none;clip-path:none;width:auto;height:auto;margin:0}.nav-menus-php .item-edit:before{margin-top:10px;margin-left:4px;width:20px;border-radius:50%;text-indent:-1px}.no-js.nav-menus-php .item-edit:before{display:none}.rtl .nav-menus-php .item-edit:before{text-indent:1px}.js.nav-menus-php .item-edit:focus{box-shadow:none}.nav-menus-php .item-edit:focus:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.menu-instructions-inactive{display:none}.menu-item-settings{display:block;width:402px;padding:10px 0 10px 10px;position:relative;z-index:10;border:1px solid #e5e5e5;border-top:none;box-shadow:0 1px 1px rgba(0,0,0,.04)}.menu-item-settings .field-move{margin:3px 0 5px;line-height:1.5}.field-move-visual-label{float:left;margin-right:4px;font-style:italic}.menu-item-settings .field-move .button-link{display:none;margin:0 2px;font-style:italic}.menu-item-edit-active .menu-item-settings{display:block}.menu-item-edit-inactive .menu-item-settings{display:none}.add-menu-item-pagelinks{margin:.5em -10px;text-align:center}.add-menu-item-pagelinks .page-numbers{display:inline-block;min-width:20px}.add-menu-item-pagelinks .page-numbers.dots{min-width:0}.link-to-original{display:block;margin:0 0 15px;padding:3px 5px 5px;border:1px solid #ddd;color:#72777c;font-size:12px;font-style:italic}.hidden-field,.nav-menus-php .blank-slate .menu-settings{display:none}.link-to-original a{padding-left:4px;font-style:normal}.menu-item-settings .description-thin,.menu-item-settings .description-wide{margin-right:10px;float:left}.description-thin{width:190px}.description-wide{width:390px}.menu-item-actions{padding-top:15px;padding-bottom:7px}.nav-menus-php .major-publishing-actions{clear:both;padding:10px 0;line-height:28px}.nav-menus-php .major-publishing-actions .publishing-action{text-align:right;float:right}.nav-menus-php .delete-action{float:left;line-height:28px}.nav-menus-php .major-publishing-actions .form-invalid{padding-left:4px;margin-left:-4px}#menu-item-name-wrap,#menu-item-url-wrap,#nav-menus-frame,.button-controls{display:block}@media only screen and (min-width:769px) and (max-width:1000px){body.menu-max-depth-0{min-width:0!important}#menu-management-liquid{width:100%}.nav-menus-php #post-body-content{min-width:0}.menu-item-bar .menu-item-handle{width:90%}}@media screen and (max-width:782px){body.nav-menus-php,body.wp-customizer{min-width:0!important}#nav-menus-frame{margin-left:0;float:none;width:100%}#wpbody-content #menu-settings-column{display:block;width:100%;float:none;margin-left:0}#side-sortables .add-menu-item-tabs{margin:15px 0 14px}.menu-settings-group-name,.menu-settings-input{float:none;margin-bottom:15px}ul.add-menu-item-tabs li.tabs{padding:13px 15px 14px}.nav-menus-php .customlinkdiv .howto input{width:65%}.nav-menus-php .quick-search{width:85%}#menu-management-liquid{margin-top:25px}.nav-menus-php .menu-name-label.howto span{margin-top:13px}#menu-name{width:100%}.nav-menus-php .major-publishing-actions .publishing-action{padding-top:1em}.nav-menus-php .delete-action{font-size:14px;line-height:30px}.description-wide,.menu-item-bar .menu-item-handle,.menu-item-settings{width:auto}.menu-item-settings{padding:10px}.menu-item-settings .description-thin,.menu-item-settings .description-wide,.menu-item-settings input{width:100%}.menu-item-settings input[type=checkbox],.menu-item-settings input[type=radio]{width:25px}.menu-settings-group{padding-left:0}.menu-settings-group-name{width:auto;margin-left:0}.menu-edit .checkbox-input{margin-top:0}.manage-menus select{margin:.5em 0}.widefat .menu-locations .menu-location-title{padding-top:16px}}@media only screen and (max-width:768px){#menu-locations-wrap .widefat{width:100%}} \ No newline at end of file diff --git a/backend/wp-admin/css/revisions-rtl.css b/backend/wp-admin/css/revisions-rtl.css new file mode 100644 index 0000000..537d993 --- /dev/null +++ b/backend/wp-admin/css/revisions-rtl.css @@ -0,0 +1,578 @@ +/*------------------------------------------------------------------------------ + 11.2 - Post Revisions +------------------------------------------------------------------------------*/ +.revisions-control-frame, +.revisions-diff-frame { + position: relative; +} + +.revisions-controls { + padding-top: 40px; + height: 100px; + z-index: 1; +} + +.revisions-controls input[type="checkbox"] { + position: relative; + top: -1px; + vertical-align: text-bottom; +} + +.revisions.pinned .revisions-controls { + position: fixed; + top: 0; + height: 82px; + background: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions-tickmarks { + position: relative; + margin: 0 auto; + height: 0.7em; + top: 7px; + max-width: 70%; + box-sizing: border-box; + background-color: #fff; +} + +.revisions-tickmarks > div { + position: absolute; + height: 100%; + border-right: 1px solid #a0a5aa; + box-sizing: border-box; +} + +.revisions-tickmarks > div:first-child { + border-width: 0; +} + +.comparing-two-revisions .revisions-controls { + height: 140px; +} + +.comparing-two-revisions.pinned .revisions-controls { + height: 124px; +} + +.revisions .diff-error { + position: absolute; + text-align: center; + margin: 0 auto; + width: 100%; + display: none; +} + +.revisions.diff-error .diff-error { + display: block; +} + +.revisions .loading-indicator { + position: absolute; + vertical-align: middle; + opacity: 0; + width: 100%; + width: calc( 100% - 30px ); + top: 50%; + top: calc( 50% - 10px ); + transition: opacity 0.5s; + filter: alpha(opacity=0); /* ie8 and earlier */ +} + +body.folded .revisions .loading-indicator { + margin-right: -32px; +} + +.revisions .loading-indicator span.spinner { + display: block; + margin: 0 auto; + float: none; +} + +.revisions.loading .loading-indicator { + opacity: 1; + filter: alpha(opacity=100); /* ie8 and earlier */ +} + +.revisions .diff { + transition: opacity 0.5s; +} + +.revisions.loading .diff { + opacity: 0.5; + filter: alpha(opacity=50); /* ie8 and earlier */ +} + +.revisions.diff-error .diff { + visibility: hidden; +} + +.revisions-meta { + margin-top: 20px; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions.pinned .revisions-meta { + box-shadow: none; +} + +.revision-toggle-compare-mode { + position: absolute; + top: 0; + left: 0; +} + +.comparing-two-revisions .revisions-previous, +.comparing-two-revisions .revisions-next, +.revisions-meta .diff-meta-to strong { + display: none; +} + +.revisions-controls .author-card .date { + color: #72777c; +} + +.revisions-controls .author-card.autosave { + color: #d54e21; +} + +.revisions-controls .author-card .author-name { + font-weight: 600; +} + +.comparing-two-revisions .diff-meta-to strong { + display: block; +} + +.revisions.pinned .revisions-buttons { + padding: 0 11px; +} + +.revisions-previous, +.revisions-next { + position: relative; + z-index: 1; +} + +.revisions-previous { + float: right; +} + +.revisions-next { + float: left; +} + +.revisions-controls .wp-slider { + max-width: 70%; + margin: 0 auto; + top: -3px; +} + +.revisions-diff { + padding: 15px; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions-diff h3:first-child { + margin-top: 0; +} + +/* Revision meta box */ +.post-revisions li img, +#revisions-meta-restored img { + vertical-align: middle; +} + +table.diff tbody tr td:nth-child(2) { + width: 4%; +} + +table.diff { + table-layout: fixed; + width: 100%; + white-space: pre-wrap; +} + +table.diff col.content { + width: auto; +} + +table.diff col.content.diffsplit { + width: 48%; +} + +table.diff col.diffsplit.middle { + width: auto; +} + +table.diff col.ltype { + width: 30px; +} + +table.diff tr { + background-color: transparent; +} + +table.diff td, +table.diff th { + font-family: Consolas, Monaco, monospace; + font-size: 14px; + line-height: 1.618; + padding: .5em; + vertical-align: top; + word-wrap: break-word; +} + +table.diff td h1, +table.diff td h2, +table.diff td h3, +table.diff td h4, +table.diff td h5, +table.diff td h6 { + margin: 0; +} + +table.diff .diff-deletedline del, +table.diff .diff-addedline ins { + text-decoration: none; +} + +table.diff .diff-deletedline { + background-color: #ffe9e9; +} + +table.diff .diff-deletedline del { + background-color: #faa; +} + +table.diff .diff-addedline { + background-color: #e9ffe9; +} + +table.diff .diff-addedline ins { + background-color: #afa; +} + +.diff-meta { + padding: 5px; + clear: both; + min-height: 32px; +} + +.diff-title strong { + line-height: 32px; + min-width: 60px; + text-align: left; + float: right; + margin-left: 5px; +} + +.revisions-controls .author-card .author-info { + font-size: 12px; + line-height: 16px; +} + +.revisions-controls .author-card .avatar, +.revisions-controls .author-card .author-info { + float: right; + margin-right: 6px; + margin-left: 6px; +} + +.revisions-controls .author-card .byline { + display: block; + font-size: 12px; +} + +.revisions-controls .author-card .avatar { + vertical-align: middle; +} + +.diff-meta input.restore-revision { + float: left; + margin-right: 6px; + margin-left: 6px; + margin-top: 4px; +} + +.diff-meta-from { + display: none; +} + +.comparing-two-revisions .diff-meta-from { + display: block; +} + +.revisions-tooltip { + position: absolute; + bottom: 105px; + margin-left: 0; + margin-right: -69px; + z-index: 0; + max-width: 350px; + min-width: 130px; + padding: 8px 4px; + display: none; + opacity: 0; +} + +.revisions-tooltip.flipped { + margin-right: 0; + margin-left: -70px; +} + +.revisions.pinned .revisions-tooltip { + display: none !important; +} + +.comparing-two-revisions .revisions-tooltip { + bottom: 145px; +} + +.revisions-tooltip-arrow { + width: 70px; + height: 15px; + overflow: hidden; + position: absolute; + right: 0; + margin-right: 35px; + bottom: -15px; +} + +.revisions-tooltip.flipped .revisions-tooltip-arrow { + margin-right: 0; + margin-left: 35px; + right: auto; + left: 0; +} + +.revisions-tooltip-arrow > span { + content: ""; + position: absolute; + right: 20px; + top: -20px; + width: 25px; + height: 25px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); +} + +.revisions-tooltip.flipped .revisions-tooltip-arrow > span { + right: auto; + left: 20px; +} + +.ie8 .revisions-tooltip-arrow > span { + right: 15px; + top: -25px; + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; +} + +.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow > span { + left: 25px; +} + +.revisions-tooltip, +.revisions-tooltip-arrow > span { + border: 1px solid #ddd; + background-color: #fff; +} + +.revisions-tooltip { + display: none; +} + +.arrow { + width: 70px; + height: 16px; + overflow: hidden; + position: absolute; + right: 0; + margin-right: -35px; + bottom: 90px; + z-index: 10000; +} + +.arrow:after { + z-index: 9999; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.arrow.top { + top: -16px; + bottom: auto; +} + +.arrow.left { + right: 20%; +} + +.arrow:after { + content: ""; + position: absolute; + right: 20px; + top: -20px; + width: 25px; + height: 25px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); +} + +.revisions-tooltip, +.revisions-tooltip-arrow:after { + border-width: 1px; + border-style: solid; +} + +div.revisions-controls > .wp-slider > .ui-slider-handle { + margin-right: -10px; +} + +.rtl div.revisions-controls > .wp-slider > .ui-slider-handle { + margin-left: -10px; +} + +/* jQuery UI Slider */ +.wp-slider.ui-slider { + position: relative; + border: 1px solid #ddd; + text-align: right; + cursor: pointer; +} + +.wp-slider .ui-slider-handle { + border-radius: 50%; + height: 18px; + margin-top: -5px; + outline: none; + padding: 2px; + position: absolute; + width: 18px; + z-index: 2; + touch-action: none; +} + +.wp-slider .ui-slider-handle, +.wp-slider .ui-slider-handle.focus { + background: #f7f7f7; + border: 1px solid #ccc; + box-shadow: 0 1px 0 #cccccc; +} + +.wp-slider .ui-slider-handle:hover, +.wp-slider .ui-slider-handle.ui-state-hover { + background: #fafafa; + border-color: #999; +} + +.wp-slider .ui-slider-handle:active, +.wp-slider .ui-slider-handle.ui-state-active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + + +.wp-slider .ui-slider-handle:before { + background: none; + position: absolute; + top: 2px; + right: 2px; + color: #555; + content: "\f229"; + font: normal 18px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-slider .ui-slider-handle:hover:before, +.wp-slider .ui-slider-handle.ui-state-hover:before { + color: #23282d; +} + +.wp-slider .ui-slider-handle.from-handle:before, +.wp-slider .ui-slider-handle.to-handle:before { + font-size: 20px !important; + margin: -1px -1px 0 0; +} + +.wp-slider .ui-slider-handle.from-handle:before { + content: "\f141"; +} + +.wp-slider .ui-slider-handle.to-handle:before { + content: "\f139"; +} + +.rtl .wp-slider .ui-slider-handle.from-handle:before { + content: "\f139"; +} + +.rtl .wp-slider .ui-slider-handle.to-handle:before { + content: "\f141"; + left: -1px; +} + +.wp-slider .ui-slider-range { + position: absolute; + font-size: .7em; + display: block; + border: 0; + background-color: transparent; + background-image: none; +} + +.wp-slider.ui-slider-horizontal { + height: .7em; +} + +.wp-slider.ui-slider-horizontal .ui-slider-handle { + top: -.25em; + margin-right: -.6em; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range { + top: 0; + height: 100%; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range-min { + right: 0; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range-max { + left: 0; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .revision-tick.completed-false { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + #diff-next-revision, + #diff-previous-revision { + margin-top: -1em; + } + + table.diff { + -ms-word-break: break-all; + word-break: break-all; + word-wrap: break-word; + } +} diff --git a/backend/wp-admin/css/revisions-rtl.min.css b/backend/wp-admin/css/revisions-rtl.min.css new file mode 100644 index 0000000..0f6f251 --- /dev/null +++ b/backend/wp-admin/css/revisions-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.revisions-control-frame,.revisions-diff-frame{position:relative}.revisions-controls{padding-top:40px;height:100px;z-index:1}.revisions-controls input[type=checkbox]{position:relative;top:-1px;vertical-align:text-bottom}.revisions.pinned .revisions-controls{position:fixed;top:0;height:82px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions-tickmarks{position:relative;margin:0 auto;height:.7em;top:7px;max-width:70%;box-sizing:border-box;background-color:#fff}.revisions-tickmarks>div{position:absolute;height:100%;border-right:1px solid #a0a5aa;box-sizing:border-box}.revisions-tickmarks>div:first-child{border-width:0}.comparing-two-revisions .revisions-controls{height:140px}.comparing-two-revisions.pinned .revisions-controls{height:124px}.revisions .diff-error{position:absolute;text-align:center;margin:0 auto;width:100%;display:none}.revisions.diff-error .diff-error{display:block}.revisions .loading-indicator{position:absolute;vertical-align:middle;opacity:0;width:100%;width:calc(100% - 30px);top:50%;top:calc(50% - 10px);transition:opacity .5s;filter:alpha(opacity=0)}body.folded .revisions .loading-indicator{margin-right:-32px}.revisions .loading-indicator span.spinner{display:block;margin:0 auto;float:none}.revisions.loading .loading-indicator{opacity:1;filter:alpha(opacity=100)}.revisions .diff{transition:opacity .5s}.revisions.loading .diff{opacity:.5;filter:alpha(opacity=50)}.revisions.diff-error .diff{visibility:hidden}.revisions-meta{margin-top:20px;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions.pinned .revisions-meta{box-shadow:none}.revision-toggle-compare-mode{position:absolute;top:0;left:0}.comparing-two-revisions .revisions-next,.comparing-two-revisions .revisions-previous,.revisions-meta .diff-meta-to strong{display:none}.revisions-controls .author-card .date{color:#72777c}.revisions-controls .author-card.autosave{color:#d54e21}.revisions-controls .author-card .author-name{font-weight:600}.comparing-two-revisions .diff-meta-to strong{display:block}.revisions.pinned .revisions-buttons{padding:0 11px}.revisions-next,.revisions-previous{position:relative;z-index:1}.revisions-previous{float:right}.revisions-next{float:left}.revisions-controls .wp-slider{max-width:70%;margin:0 auto;top:-3px}.revisions-diff{padding:15px;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions-diff h3:first-child{margin-top:0}#revisions-meta-restored img,.post-revisions li img{vertical-align:middle}table.diff tbody tr td:nth-child(2){width:4%}table.diff{table-layout:fixed;width:100%;white-space:pre-wrap}table.diff col.content{width:auto}table.diff col.content.diffsplit{width:48%}table.diff col.diffsplit.middle{width:auto}table.diff col.ltype{width:30px}table.diff tr{background-color:transparent}table.diff td,table.diff th{font-family:Consolas,Monaco,monospace;font-size:14px;line-height:1.618;padding:.5em;vertical-align:top;word-wrap:break-word}table.diff td h1,table.diff td h2,table.diff td h3,table.diff td h4,table.diff td h5,table.diff td h6{margin:0}table.diff .diff-addedline ins,table.diff .diff-deletedline del{text-decoration:none}table.diff .diff-deletedline{background-color:#ffe9e9}table.diff .diff-deletedline del{background-color:#faa}table.diff .diff-addedline{background-color:#e9ffe9}table.diff .diff-addedline ins{background-color:#afa}.diff-meta{padding:5px;clear:both;min-height:32px}.diff-title strong{line-height:32px;min-width:60px;text-align:left;float:right;margin-left:5px}.revisions-controls .author-card .author-info{font-size:12px;line-height:16px}.revisions-controls .author-card .author-info,.revisions-controls .author-card .avatar{float:right;margin-right:6px;margin-left:6px}.revisions-controls .author-card .byline{display:block;font-size:12px}.revisions-controls .author-card .avatar{vertical-align:middle}.diff-meta input.restore-revision{float:left;margin-right:6px;margin-left:6px;margin-top:4px}.diff-meta-from{display:none}.comparing-two-revisions .diff-meta-from{display:block}.revisions-tooltip{position:absolute;bottom:105px;margin-left:0;margin-right:-69px;z-index:0;max-width:350px;min-width:130px;padding:8px 4px;opacity:0}.revisions-tooltip.flipped{margin-right:0;margin-left:-70px}.revisions.pinned .revisions-tooltip{display:none!important}.comparing-two-revisions .revisions-tooltip{bottom:145px}.revisions-tooltip-arrow{width:70px;height:15px;overflow:hidden;position:absolute;right:0;margin-right:35px;bottom:-15px}.revisions-tooltip.flipped .revisions-tooltip-arrow{margin-right:0;margin-left:35px;right:auto;left:0}.revisions-tooltip-arrow>span{content:"";position:absolute;right:20px;top:-20px;width:25px;height:25px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.revisions-tooltip.flipped .revisions-tooltip-arrow>span{right:auto;left:20px}.ie8 .revisions-tooltip-arrow>span{right:15px;top:-25px;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"}.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow>span{left:25px}.revisions-tooltip,.revisions-tooltip-arrow>span{border:1px solid #ddd;background-color:#fff}.revisions-tooltip{display:none}.arrow{width:70px;height:16px;overflow:hidden;position:absolute;right:0;margin-right:-35px;bottom:90px;z-index:10000}.arrow.top{top:-16px;bottom:auto}.arrow.left{right:20%}.arrow:after{z-index:9999;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1);content:"";position:absolute;right:20px;top:-20px;width:25px;height:25px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.revisions-tooltip,.revisions-tooltip-arrow:after{border-width:1px;border-style:solid}div.revisions-controls>.wp-slider>.ui-slider-handle{margin-right:-10px}.rtl div.revisions-controls>.wp-slider>.ui-slider-handle{margin-left:-10px}.wp-slider.ui-slider{position:relative;border:1px solid #ddd;text-align:right;cursor:pointer}.wp-slider .ui-slider-handle{border-radius:50%;height:18px;margin-top:-5px;outline:0;padding:2px;position:absolute;width:18px;z-index:2;touch-action:none}.wp-slider .ui-slider-handle,.wp-slider .ui-slider-handle.focus{background:#f7f7f7;border:1px solid #ccc;box-shadow:0 1px 0 #ccc}.wp-slider .ui-slider-handle.ui-state-hover,.wp-slider .ui-slider-handle:hover{background:#fafafa;border-color:#999}.wp-slider .ui-slider-handle.ui-state-active,.wp-slider .ui-slider-handle:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.wp-slider .ui-slider-handle:before{background:0 0;position:absolute;top:2px;right:2px;color:#555;content:"\f229";font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-slider .ui-slider-handle.ui-state-hover:before,.wp-slider .ui-slider-handle:hover:before{color:#23282d}.wp-slider .ui-slider-handle.from-handle:before,.wp-slider .ui-slider-handle.to-handle:before{font-size:20px!important;margin:-1px -1px 0 0}.wp-slider .ui-slider-handle.from-handle:before{content:"\f141"}.wp-slider .ui-slider-handle.to-handle:before{content:"\f139"}.rtl .wp-slider .ui-slider-handle.from-handle:before{content:"\f139"}.rtl .wp-slider .ui-slider-handle.to-handle:before{content:"\f141";left:-1px}.wp-slider .ui-slider-range{position:absolute;font-size:.7em;display:block;border:0;background-color:transparent;background-image:none}.wp-slider.ui-slider-horizontal{height:.7em}.wp-slider.ui-slider-horizontal .ui-slider-handle{top:-.25em;margin-right:-.6em}.wp-slider.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.wp-slider.ui-slider-horizontal .ui-slider-range-min{right:0}.wp-slider.ui-slider-horizontal .ui-slider-range-max{left:0}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.revision-tick.completed-false{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){#diff-next-revision,#diff-previous-revision{margin-top:-1em}table.diff{-ms-word-break:break-all;word-break:break-all;word-wrap:break-word}} \ No newline at end of file diff --git a/backend/wp-admin/css/revisions.css b/backend/wp-admin/css/revisions.css new file mode 100644 index 0000000..236d762 --- /dev/null +++ b/backend/wp-admin/css/revisions.css @@ -0,0 +1,578 @@ +/*------------------------------------------------------------------------------ + 11.2 - Post Revisions +------------------------------------------------------------------------------*/ +.revisions-control-frame, +.revisions-diff-frame { + position: relative; +} + +.revisions-controls { + padding-top: 40px; + height: 100px; + z-index: 1; +} + +.revisions-controls input[type="checkbox"] { + position: relative; + top: -1px; + vertical-align: text-bottom; +} + +.revisions.pinned .revisions-controls { + position: fixed; + top: 0; + height: 82px; + background: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions-tickmarks { + position: relative; + margin: 0 auto; + height: 0.7em; + top: 7px; + max-width: 70%; + box-sizing: border-box; + background-color: #fff; +} + +.revisions-tickmarks > div { + position: absolute; + height: 100%; + border-left: 1px solid #a0a5aa; + box-sizing: border-box; +} + +.revisions-tickmarks > div:first-child { + border-width: 0; +} + +.comparing-two-revisions .revisions-controls { + height: 140px; +} + +.comparing-two-revisions.pinned .revisions-controls { + height: 124px; +} + +.revisions .diff-error { + position: absolute; + text-align: center; + margin: 0 auto; + width: 100%; + display: none; +} + +.revisions.diff-error .diff-error { + display: block; +} + +.revisions .loading-indicator { + position: absolute; + vertical-align: middle; + opacity: 0; + width: 100%; + width: calc( 100% - 30px ); + top: 50%; + top: calc( 50% - 10px ); + transition: opacity 0.5s; + filter: alpha(opacity=0); /* ie8 and earlier */ +} + +body.folded .revisions .loading-indicator { + margin-left: -32px; +} + +.revisions .loading-indicator span.spinner { + display: block; + margin: 0 auto; + float: none; +} + +.revisions.loading .loading-indicator { + opacity: 1; + filter: alpha(opacity=100); /* ie8 and earlier */ +} + +.revisions .diff { + transition: opacity 0.5s; +} + +.revisions.loading .diff { + opacity: 0.5; + filter: alpha(opacity=50); /* ie8 and earlier */ +} + +.revisions.diff-error .diff { + visibility: hidden; +} + +.revisions-meta { + margin-top: 20px; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions.pinned .revisions-meta { + box-shadow: none; +} + +.revision-toggle-compare-mode { + position: absolute; + top: 0; + right: 0; +} + +.comparing-two-revisions .revisions-previous, +.comparing-two-revisions .revisions-next, +.revisions-meta .diff-meta-to strong { + display: none; +} + +.revisions-controls .author-card .date { + color: #72777c; +} + +.revisions-controls .author-card.autosave { + color: #d54e21; +} + +.revisions-controls .author-card .author-name { + font-weight: 600; +} + +.comparing-two-revisions .diff-meta-to strong { + display: block; +} + +.revisions.pinned .revisions-buttons { + padding: 0 11px; +} + +.revisions-previous, +.revisions-next { + position: relative; + z-index: 1; +} + +.revisions-previous { + float: left; +} + +.revisions-next { + float: right; +} + +.revisions-controls .wp-slider { + max-width: 70%; + margin: 0 auto; + top: -3px; +} + +.revisions-diff { + padding: 15px; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.revisions-diff h3:first-child { + margin-top: 0; +} + +/* Revision meta box */ +.post-revisions li img, +#revisions-meta-restored img { + vertical-align: middle; +} + +table.diff tbody tr td:nth-child(2) { + width: 4%; +} + +table.diff { + table-layout: fixed; + width: 100%; + white-space: pre-wrap; +} + +table.diff col.content { + width: auto; +} + +table.diff col.content.diffsplit { + width: 48%; +} + +table.diff col.diffsplit.middle { + width: auto; +} + +table.diff col.ltype { + width: 30px; +} + +table.diff tr { + background-color: transparent; +} + +table.diff td, +table.diff th { + font-family: Consolas, Monaco, monospace; + font-size: 14px; + line-height: 1.618; + padding: .5em; + vertical-align: top; + word-wrap: break-word; +} + +table.diff td h1, +table.diff td h2, +table.diff td h3, +table.diff td h4, +table.diff td h5, +table.diff td h6 { + margin: 0; +} + +table.diff .diff-deletedline del, +table.diff .diff-addedline ins { + text-decoration: none; +} + +table.diff .diff-deletedline { + background-color: #ffe9e9; +} + +table.diff .diff-deletedline del { + background-color: #faa; +} + +table.diff .diff-addedline { + background-color: #e9ffe9; +} + +table.diff .diff-addedline ins { + background-color: #afa; +} + +.diff-meta { + padding: 5px; + clear: both; + min-height: 32px; +} + +.diff-title strong { + line-height: 32px; + min-width: 60px; + text-align: right; + float: left; + margin-right: 5px; +} + +.revisions-controls .author-card .author-info { + font-size: 12px; + line-height: 16px; +} + +.revisions-controls .author-card .avatar, +.revisions-controls .author-card .author-info { + float: left; + margin-left: 6px; + margin-right: 6px; +} + +.revisions-controls .author-card .byline { + display: block; + font-size: 12px; +} + +.revisions-controls .author-card .avatar { + vertical-align: middle; +} + +.diff-meta input.restore-revision { + float: right; + margin-left: 6px; + margin-right: 6px; + margin-top: 4px; +} + +.diff-meta-from { + display: none; +} + +.comparing-two-revisions .diff-meta-from { + display: block; +} + +.revisions-tooltip { + position: absolute; + bottom: 105px; + margin-right: 0; + margin-left: -69px; + z-index: 0; + max-width: 350px; + min-width: 130px; + padding: 8px 4px; + display: none; + opacity: 0; +} + +.revisions-tooltip.flipped { + margin-left: 0; + margin-right: -70px; +} + +.revisions.pinned .revisions-tooltip { + display: none !important; +} + +.comparing-two-revisions .revisions-tooltip { + bottom: 145px; +} + +.revisions-tooltip-arrow { + width: 70px; + height: 15px; + overflow: hidden; + position: absolute; + left: 0; + margin-left: 35px; + bottom: -15px; +} + +.revisions-tooltip.flipped .revisions-tooltip-arrow { + margin-left: 0; + margin-right: 35px; + left: auto; + right: 0; +} + +.revisions-tooltip-arrow > span { + content: ""; + position: absolute; + left: 20px; + top: -20px; + width: 25px; + height: 25px; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); +} + +.revisions-tooltip.flipped .revisions-tooltip-arrow > span { + left: auto; + right: 20px; +} + +.ie8 .revisions-tooltip-arrow > span { + left: 15px; + top: -25px; + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; +} + +.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow > span { + right: 25px; +} + +.revisions-tooltip, +.revisions-tooltip-arrow > span { + border: 1px solid #ddd; + background-color: #fff; +} + +.revisions-tooltip { + display: none; +} + +.arrow { + width: 70px; + height: 16px; + overflow: hidden; + position: absolute; + left: 0; + margin-left: -35px; + bottom: 90px; + z-index: 10000; +} + +.arrow:after { + z-index: 9999; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.arrow.top { + top: -16px; + bottom: auto; +} + +.arrow.left { + left: 20%; +} + +.arrow:after { + content: ""; + position: absolute; + left: 20px; + top: -20px; + width: 25px; + height: 25px; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); +} + +.revisions-tooltip, +.revisions-tooltip-arrow:after { + border-width: 1px; + border-style: solid; +} + +div.revisions-controls > .wp-slider > .ui-slider-handle { + margin-left: -10px; +} + +.rtl div.revisions-controls > .wp-slider > .ui-slider-handle { + margin-right: -10px; +} + +/* jQuery UI Slider */ +.wp-slider.ui-slider { + position: relative; + border: 1px solid #ddd; + text-align: left; + cursor: pointer; +} + +.wp-slider .ui-slider-handle { + border-radius: 50%; + height: 18px; + margin-top: -5px; + outline: none; + padding: 2px; + position: absolute; + width: 18px; + z-index: 2; + touch-action: none; +} + +.wp-slider .ui-slider-handle, +.wp-slider .ui-slider-handle.focus { + background: #f7f7f7; + border: 1px solid #ccc; + box-shadow: 0 1px 0 #cccccc; +} + +.wp-slider .ui-slider-handle:hover, +.wp-slider .ui-slider-handle.ui-state-hover { + background: #fafafa; + border-color: #999; +} + +.wp-slider .ui-slider-handle:active, +.wp-slider .ui-slider-handle.ui-state-active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + + +.wp-slider .ui-slider-handle:before { + background: none; + position: absolute; + top: 2px; + left: 2px; + color: #555; + content: "\f229"; + font: normal 18px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-slider .ui-slider-handle:hover:before, +.wp-slider .ui-slider-handle.ui-state-hover:before { + color: #23282d; +} + +.wp-slider .ui-slider-handle.from-handle:before, +.wp-slider .ui-slider-handle.to-handle:before { + font-size: 20px !important; + margin: -1px 0 0 -1px; +} + +.wp-slider .ui-slider-handle.from-handle:before { + content: "\f139"; +} + +.wp-slider .ui-slider-handle.to-handle:before { + content: "\f141"; +} + +.rtl .wp-slider .ui-slider-handle.from-handle:before { + content: "\f141"; +} + +.rtl .wp-slider .ui-slider-handle.to-handle:before { + content: "\f139"; + right: -1px; +} + +.wp-slider .ui-slider-range { + position: absolute; + font-size: .7em; + display: block; + border: 0; + background-color: transparent; + background-image: none; +} + +.wp-slider.ui-slider-horizontal { + height: .7em; +} + +.wp-slider.ui-slider-horizontal .ui-slider-handle { + top: -.25em; + margin-left: -.6em; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range { + top: 0; + height: 100%; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range-min { + left: 0; +} + +.wp-slider.ui-slider-horizontal .ui-slider-range-max { + right: 0; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .revision-tick.completed-false { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + #diff-next-revision, + #diff-previous-revision { + margin-top: -1em; + } + + table.diff { + -ms-word-break: break-all; + word-break: break-all; + word-wrap: break-word; + } +} diff --git a/backend/wp-admin/css/revisions.min.css b/backend/wp-admin/css/revisions.min.css new file mode 100644 index 0000000..9192e4a --- /dev/null +++ b/backend/wp-admin/css/revisions.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.revisions-control-frame,.revisions-diff-frame{position:relative}.revisions-controls{padding-top:40px;height:100px;z-index:1}.revisions-controls input[type=checkbox]{position:relative;top:-1px;vertical-align:text-bottom}.revisions.pinned .revisions-controls{position:fixed;top:0;height:82px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions-tickmarks{position:relative;margin:0 auto;height:.7em;top:7px;max-width:70%;box-sizing:border-box;background-color:#fff}.revisions-tickmarks>div{position:absolute;height:100%;border-left:1px solid #a0a5aa;box-sizing:border-box}.revisions-tickmarks>div:first-child{border-width:0}.comparing-two-revisions .revisions-controls{height:140px}.comparing-two-revisions.pinned .revisions-controls{height:124px}.revisions .diff-error{position:absolute;text-align:center;margin:0 auto;width:100%;display:none}.revisions.diff-error .diff-error{display:block}.revisions .loading-indicator{position:absolute;vertical-align:middle;opacity:0;width:100%;width:calc(100% - 30px);top:50%;top:calc(50% - 10px);transition:opacity .5s;filter:alpha(opacity=0)}body.folded .revisions .loading-indicator{margin-left:-32px}.revisions .loading-indicator span.spinner{display:block;margin:0 auto;float:none}.revisions.loading .loading-indicator{opacity:1;filter:alpha(opacity=100)}.revisions .diff{transition:opacity .5s}.revisions.loading .diff{opacity:.5;filter:alpha(opacity=50)}.revisions.diff-error .diff{visibility:hidden}.revisions-meta{margin-top:20px;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions.pinned .revisions-meta{box-shadow:none}.revision-toggle-compare-mode{position:absolute;top:0;right:0}.comparing-two-revisions .revisions-next,.comparing-two-revisions .revisions-previous,.revisions-meta .diff-meta-to strong{display:none}.revisions-controls .author-card .date{color:#72777c}.revisions-controls .author-card.autosave{color:#d54e21}.revisions-controls .author-card .author-name{font-weight:600}.comparing-two-revisions .diff-meta-to strong{display:block}.revisions.pinned .revisions-buttons{padding:0 11px}.revisions-next,.revisions-previous{position:relative;z-index:1}.revisions-previous{float:left}.revisions-next{float:right}.revisions-controls .wp-slider{max-width:70%;margin:0 auto;top:-3px}.revisions-diff{padding:15px;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1)}.revisions-diff h3:first-child{margin-top:0}#revisions-meta-restored img,.post-revisions li img{vertical-align:middle}table.diff tbody tr td:nth-child(2){width:4%}table.diff{table-layout:fixed;width:100%;white-space:pre-wrap}table.diff col.content{width:auto}table.diff col.content.diffsplit{width:48%}table.diff col.diffsplit.middle{width:auto}table.diff col.ltype{width:30px}table.diff tr{background-color:transparent}table.diff td,table.diff th{font-family:Consolas,Monaco,monospace;font-size:14px;line-height:1.618;padding:.5em;vertical-align:top;word-wrap:break-word}table.diff td h1,table.diff td h2,table.diff td h3,table.diff td h4,table.diff td h5,table.diff td h6{margin:0}table.diff .diff-addedline ins,table.diff .diff-deletedline del{text-decoration:none}table.diff .diff-deletedline{background-color:#ffe9e9}table.diff .diff-deletedline del{background-color:#faa}table.diff .diff-addedline{background-color:#e9ffe9}table.diff .diff-addedline ins{background-color:#afa}.diff-meta{padding:5px;clear:both;min-height:32px}.diff-title strong{line-height:32px;min-width:60px;text-align:right;float:left;margin-right:5px}.revisions-controls .author-card .author-info{font-size:12px;line-height:16px}.revisions-controls .author-card .author-info,.revisions-controls .author-card .avatar{float:left;margin-left:6px;margin-right:6px}.revisions-controls .author-card .byline{display:block;font-size:12px}.revisions-controls .author-card .avatar{vertical-align:middle}.diff-meta input.restore-revision{float:right;margin-left:6px;margin-right:6px;margin-top:4px}.diff-meta-from{display:none}.comparing-two-revisions .diff-meta-from{display:block}.revisions-tooltip{position:absolute;bottom:105px;margin-right:0;margin-left:-69px;z-index:0;max-width:350px;min-width:130px;padding:8px 4px;opacity:0}.revisions-tooltip.flipped{margin-left:0;margin-right:-70px}.revisions.pinned .revisions-tooltip{display:none!important}.comparing-two-revisions .revisions-tooltip{bottom:145px}.revisions-tooltip-arrow{width:70px;height:15px;overflow:hidden;position:absolute;left:0;margin-left:35px;bottom:-15px}.revisions-tooltip.flipped .revisions-tooltip-arrow{margin-left:0;margin-right:35px;left:auto;right:0}.revisions-tooltip-arrow>span{content:"";position:absolute;left:20px;top:-20px;width:25px;height:25px;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.revisions-tooltip.flipped .revisions-tooltip-arrow>span{left:auto;right:20px}.ie8 .revisions-tooltip-arrow>span{left:15px;top:-25px;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"}.ie8 .revisions-tooltip.flipped .revisions-tooltip-arrow>span{right:25px}.revisions-tooltip,.revisions-tooltip-arrow>span{border:1px solid #ddd;background-color:#fff}.revisions-tooltip{display:none}.arrow{width:70px;height:16px;overflow:hidden;position:absolute;left:0;margin-left:-35px;bottom:90px;z-index:10000}.arrow.top{top:-16px;bottom:auto}.arrow.left{left:20%}.arrow:after{z-index:9999;background-color:#fff;box-shadow:0 1px 3px rgba(0,0,0,.1);content:"";position:absolute;left:20px;top:-20px;width:25px;height:25px;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.revisions-tooltip,.revisions-tooltip-arrow:after{border-width:1px;border-style:solid}div.revisions-controls>.wp-slider>.ui-slider-handle{margin-left:-10px}.rtl div.revisions-controls>.wp-slider>.ui-slider-handle{margin-right:-10px}.wp-slider.ui-slider{position:relative;border:1px solid #ddd;text-align:left;cursor:pointer}.wp-slider .ui-slider-handle{border-radius:50%;height:18px;margin-top:-5px;outline:0;padding:2px;position:absolute;width:18px;z-index:2;touch-action:none}.wp-slider .ui-slider-handle,.wp-slider .ui-slider-handle.focus{background:#f7f7f7;border:1px solid #ccc;box-shadow:0 1px 0 #ccc}.wp-slider .ui-slider-handle.ui-state-hover,.wp-slider .ui-slider-handle:hover{background:#fafafa;border-color:#999}.wp-slider .ui-slider-handle.ui-state-active,.wp-slider .ui-slider-handle:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.wp-slider .ui-slider-handle:before{background:0 0;position:absolute;top:2px;left:2px;color:#555;content:"\f229";font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-slider .ui-slider-handle.ui-state-hover:before,.wp-slider .ui-slider-handle:hover:before{color:#23282d}.wp-slider .ui-slider-handle.from-handle:before,.wp-slider .ui-slider-handle.to-handle:before{font-size:20px!important;margin:-1px 0 0 -1px}.wp-slider .ui-slider-handle.from-handle:before{content:"\f139"}.wp-slider .ui-slider-handle.to-handle:before{content:"\f141"}.rtl .wp-slider .ui-slider-handle.from-handle:before{content:"\f141"}.rtl .wp-slider .ui-slider-handle.to-handle:before{content:"\f139";right:-1px}.wp-slider .ui-slider-range{position:absolute;font-size:.7em;display:block;border:0;background-color:transparent;background-image:none}.wp-slider.ui-slider-horizontal{height:.7em}.wp-slider.ui-slider-horizontal .ui-slider-handle{top:-.25em;margin-left:-.6em}.wp-slider.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.wp-slider.ui-slider-horizontal .ui-slider-range-min{left:0}.wp-slider.ui-slider-horizontal .ui-slider-range-max{right:0}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.revision-tick.completed-false{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){#diff-next-revision,#diff-previous-revision{margin-top:-1em}table.diff{-ms-word-break:break-all;word-break:break-all;word-wrap:break-word}} \ No newline at end of file diff --git a/backend/wp-admin/css/site-icon-rtl.css b/backend/wp-admin/css/site-icon-rtl.css new file mode 100644 index 0000000..29211f3 --- /dev/null +++ b/backend/wp-admin/css/site-icon-rtl.css @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------ + 28.0 - Site Icon +------------------------------------------------------------------------------*/ + +.site-icon-preview .favicon-preview { + margin: 5px 0 20px; + overflow: hidden; + position: relative; + max-width: 180px; +} + +.site-icon-preview .favicon, +.site-icon-preview .browser-title { + height: 16px; + right: 88px; + overflow: hidden; + position: absolute; + top: 16px; +} + +.site-icon-preview .favicon { + width: 16px; +} + +.site-icon-preview .browser-title { + right: 109px; + width: 72px; + white-space: nowrap; +} + +.site-icon-preview .app-icon-preview { + background-color: #000; + border-radius: 16px; + height: 64px; + overflow: hidden; + width: 64px; + margin-top: 5px; +} + +/* rtl:ignore */ +.site-icon-preview .favicon, +.site-icon-preview .app-icon-preview { + direction: ltr; +} + +.customize-control-site_icon .favicon-preview { + float: right; + margin-left: 12px; + margin-bottom: 0; +} + +.customize-control-site_icon .app-icon-preview { + margin-top: 9px; +} diff --git a/backend/wp-admin/css/site-icon-rtl.min.css b/backend/wp-admin/css/site-icon-rtl.min.css new file mode 100644 index 0000000..901a1eb --- /dev/null +++ b/backend/wp-admin/css/site-icon-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;right:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{right:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:right;margin-left:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px} \ No newline at end of file diff --git a/backend/wp-admin/css/site-icon.css b/backend/wp-admin/css/site-icon.css new file mode 100644 index 0000000..eae9a57 --- /dev/null +++ b/backend/wp-admin/css/site-icon.css @@ -0,0 +1,54 @@ +/*------------------------------------------------------------------------------ + 28.0 - Site Icon +------------------------------------------------------------------------------*/ + +.site-icon-preview .favicon-preview { + margin: 5px 0 20px; + overflow: hidden; + position: relative; + max-width: 180px; +} + +.site-icon-preview .favicon, +.site-icon-preview .browser-title { + height: 16px; + left: 88px; + overflow: hidden; + position: absolute; + top: 16px; +} + +.site-icon-preview .favicon { + width: 16px; +} + +.site-icon-preview .browser-title { + left: 109px; + width: 72px; + white-space: nowrap; +} + +.site-icon-preview .app-icon-preview { + background-color: #000; + border-radius: 16px; + height: 64px; + overflow: hidden; + width: 64px; + margin-top: 5px; +} + +/* rtl:ignore */ +.site-icon-preview .favicon, +.site-icon-preview .app-icon-preview { + direction: ltr; +} + +.customize-control-site_icon .favicon-preview { + float: left; + margin-right: 12px; + margin-bottom: 0; +} + +.customize-control-site_icon .app-icon-preview { + margin-top: 9px; +} diff --git a/backend/wp-admin/css/site-icon.min.css b/backend/wp-admin/css/site-icon.min.css new file mode 100644 index 0000000..5287d07 --- /dev/null +++ b/backend/wp-admin/css/site-icon.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.site-icon-preview .favicon-preview{margin:5px 0 20px;overflow:hidden;position:relative;max-width:180px}.site-icon-preview .browser-title,.site-icon-preview .favicon{height:16px;left:88px;overflow:hidden;position:absolute;top:16px}.site-icon-preview .favicon{width:16px}.site-icon-preview .browser-title{left:109px;width:72px;white-space:nowrap}.site-icon-preview .app-icon-preview{background-color:#000;border-radius:16px;height:64px;overflow:hidden;width:64px;margin-top:5px}.site-icon-preview .app-icon-preview,.site-icon-preview .favicon{direction:ltr}.customize-control-site_icon .favicon-preview{float:left;margin-right:12px;margin-bottom:0}.customize-control-site_icon .app-icon-preview{margin-top:9px} \ No newline at end of file diff --git a/backend/wp-admin/css/themes-rtl.css b/backend/wp-admin/css/themes-rtl.css new file mode 100644 index 0000000..e6c5ee7 --- /dev/null +++ b/backend/wp-admin/css/themes-rtl.css @@ -0,0 +1,1929 @@ +/*------------------------------------------------------------------------------ + 16.0 - Themes +------------------------------------------------------------------------------*/ + + +/*------------------------------------------------------------------------------ + 16.1 - Manage Themes +------------------------------------------------------------------------------*/ + +body.js .theme-browser.search-loading { + display: none; +} + +.theme-browser .themes { + clear: both; +} + +.themes-php:not(.network-admin) .wrap h1 { + margin-bottom: 15px; +} + +.themes-php .wrap h1 .button { + margin-right: 20px; +} + +/* Search form */ +.themes-php .search-form { + display: inline; +} + +.themes-php .wp-filter-search { + position: relative; + top: -2px; + right: 20px; + margin: 0; + width: 280px; + font-size: 16px; + font-weight: 300; + line-height: 1.5; +} + +/* Position admin messages */ +.theme .notice, +.theme .notice.is-dismissible { + right: 0; + margin: 0; + position: absolute; + left: 0; + top: 0; +} + +/** + * Main theme element + * (has flexible margins) + */ +.theme-browser .theme { + cursor: pointer; + float: right; + margin: 0 0 4% 4%; + position: relative; + width: 30.6%; + border: 1px solid #ddd; + box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1); + box-sizing: border-box; +} + +.ie8 .theme-browser .theme { + width: 30%; + margin: 0 0 4% 3%; +} + +.theme-browser .theme:nth-child(3n) { + margin-left: 0; +} + +.theme-browser .theme:hover, +.theme-browser .theme:focus { + cursor: pointer; +} + +.theme-browser .theme .theme-name { + font-size: 15px; + font-weight: 600; + height: 18px; + margin: 0; + padding: 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + background: #fff; + background: rgba(255,255,255,0.65); +} + +/* Activate and Customize buttons, shown on hover and focus */ +.theme-browser .theme .theme-actions { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + opacity: 0; + transition: opacity 0.1s ease-in-out; + height: auto; + background: rgba(244, 244, 244, 0.7); + border-right: 1px solid rgba(0,0,0,0.05); +} + +.theme-browser .theme:hover .theme-actions, +.theme-browser .theme.focus .theme-actions, +.theme-browser .theme:focus .theme-actions { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + opacity: 1; +} + +.theme-browser .theme .theme-actions .button-primary { + margin-left: 3px; +} + +.theme-browser .theme .theme-actions .button { + float: none; + margin-right: 3px; +} + +/** + * Theme Screenshot + * + * Has a fixed aspect ratio of 1.5 to 1 regardless of screenshot size + * It is also responsive. + */ +.theme-browser .theme .theme-screenshot { + display: block; + overflow: hidden; + position: relative; + -webkit-backface-visibility: hidden; /* Prevents flicker of the screenshot on hover. */ + transition: opacity 0.2s ease-in-out; +} + +.theme-browser .theme .theme-screenshot:after { + content: ""; + display: block; + padding-top: 66.66666%; /* using a 3/2 aspect ratio */ +} + +.theme-browser .theme .theme-screenshot img { + height: auto; + position: absolute; + right: 0; + top: 0; + width: 100%; + transition: opacity 0.2s ease-in-out; +} + +.theme-browser .theme:hover .theme-screenshot, +.theme-browser .theme:focus .theme-screenshot { + background: #fff; +} + +.theme-browser.rendered .theme:hover .theme-screenshot img, +.theme-browser.rendered .theme:focus .theme-screenshot img { + opacity: 0.4; +} + +.theme-browser .theme .more-details { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + opacity: 0; + position: absolute; + top: 35%; + left: 20%; + right: 20%; + background: #23282d; + background: rgba(0,0,0,0.7); + color: #fff; + font-size: 15px; + text-shadow: 0 1px 0 rgba(0,0,0,0.6); + -webkit-font-smoothing: antialiased; + font-weight: 600; + padding: 15px 12px; + text-align: center; + border-radius: 3px; + transition: opacity 0.1s ease-in-out; +} + +.theme-browser .theme:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +.theme-browser .theme:focus .more-details { + opacity: 1; +} + +/* Current theme needs to have its action always on view */ +.theme-browser .theme.active:focus .theme-actions { + display: block; +} + +.theme-browser.rendered .theme:hover .more-details, +.theme-browser.rendered .theme:focus .more-details { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + opacity: 1; +} + +/** + * The currently active theme + */ +.theme-browser .theme.active .theme-name { + background: #23282d; + color: #fff; + padding-left: 110px; + font-weight: 300; + box-shadow: inset 0 1px 1px rgba(0,0,0,0.5); +} + +.theme-browser .customize-control .theme.active .theme-name { + padding-left: 15px; +} + +.theme-browser .theme.active .theme-name span { + font-weight: 600; +} + +.theme-browser .theme.active .theme-actions { + background: rgba(49,49,49,0.7); + border-right: none; + opacity: 1; +} + +.theme-id-container { + position: relative; +} + +.theme-browser .theme.active .theme-actions, +.theme-browser .theme .theme-actions { + position: absolute; + top: 50%; + -webkit-transform: translateY(-50%); + transform: translateY(-50%); + left: 0; + padding: 10px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); +} + +.theme-browser .theme.active .theme-actions .button-primary { + margin-left: 0; +} + +.theme-browser .theme .theme-author { + background: #23282d; + color: #eee; + display: none; + font-size: 14px; + margin: 0 10px; + padding: 5px 10px; + position: absolute; + bottom: 56px; +} + +.theme-browser .theme.display-author .theme-author { + display: block; +} + +.theme-browser .theme.display-author .theme-author a { + color: inherit; + text-decoration: none; +} + +/** + * Add new theme + */ +.theme-browser .theme.add-new-theme { + border: none; + box-shadow: none; +} + +.theme-browser .theme.add-new-theme a { + text-decoration: none; + display: block; + position: relative; + z-index: 1; +} + +.theme-browser .theme.add-new-theme a:after { + display: block; + content: ""; + background: transparent; + background: rgba(0, 0, 0, 0); + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + padding: 0; + text-shadow: none; + border: 5px dashed #d5d2ca; + border: 5px dashed rgba(0, 0, 0, 0.1); + box-sizing: border-box; +} + +.theme-browser .theme.add-new-theme span:after { + background: #e5e5e5; + background: rgba(153, 153, 153, 0.1); + border-radius: 50%; + display: inline-block; + content: "\f132"; + -webkit-font-smoothing: antialiased; + font: normal 74px/115px dashicons; + width: 100px; + height: 100px; + vertical-align: middle; + text-align: center; + color: rgb(153, 153, 153); + position: absolute; + top: 30%; + right: 50%; + margin-right: -50px; + text-indent: -4px; + padding: 0; + text-shadow: none; + z-index:4; +} + +.rtl .theme-browser .theme.add-new-theme span:after { + text-indent: 4px; +} + +.theme-browser .theme.add-new-theme a:hover .theme-screenshot, +.theme-browser .theme.add-new-theme a:focus .theme-screenshot { + background: none; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + background: #fff; + color: #0073aa; +} + +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + border-color: transparent; + color: #fff; + background: #0073aa; + content: ""; +} + +.theme-browser .theme.add-new-theme .theme-name { + background: none; + text-align: center; + box-shadow: none; + font-weight: 400; + position: relative; + top: 0; + margin-top: -18px; + padding-top: 0; + padding-bottom: 48px; +} + +.theme-browser .theme.add-new-theme a:hover .theme-name, +.theme-browser .theme.add-new-theme a:focus .theme-name { + color: #fff; + z-index: 2; +} + +/** + * Theme Overlay + * Shown when clicking a theme + */ +.theme-overlay .theme-backdrop { + position: absolute; + right: -20px; + left: 0; + top: 0; + bottom: 0; + background: #f1f1f1; + background: rgba( 238, 238, 238, 0.9 ); + z-index: 10000; /* Over WP Pointers. */ +} + +.theme-overlay .theme-header { + position: absolute; + top: 0; + right: 0; + left: 0; + height: 48px; + border-bottom: 1px solid #ddd; +} + +.theme-overlay .theme-header button { + padding: 0; +} + +.theme-overlay .theme-header .close { + cursor: pointer; + height: 48px; + width: 50px; + text-align: center; + float: left; + border: 0; + border-right: 1px solid #ddd; + background-color: transparent; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-overlay .theme-header .close:before { + font: normal 22px/50px dashicons !important; + color: #72777c; + display: inline-block; + content: "\f335"; + font-weight: 300; +} + +/* Left and right navigation */ +.theme-overlay .theme-header .right, +.theme-overlay .theme-header .left { + cursor: pointer; + color: #72777c; + background-color: transparent; + height: 48px; + width: 54px; + float: right; + text-align: center; + border: 0; + border-left: 1px solid #ddd; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-overlay .theme-header .close:focus, +.theme-overlay .theme-header .close:hover, +.theme-overlay .theme-header .right:focus, +.theme-overlay .theme-header .right:hover, +.theme-overlay .theme-header .left:focus, +.theme-overlay .theme-header .left:hover { + background: #ddd; + border-color: #ccc; + color: #000; +} + +.theme-overlay .theme-header .close:focus:before, +.theme-overlay .theme-header .close:hover:before { + color: #000; +} + +.theme-overlay .theme-header .close:focus, +.theme-overlay .theme-header .right:focus, +.theme-overlay .theme-header .left:focus { + box-shadow: none; + outline: none; +} + +.theme-overlay .theme-header .left.disabled, +.theme-overlay .theme-header .right.disabled, +.theme-overlay .theme-header .left.disabled:hover, +.theme-overlay .theme-header .right.disabled:hover { + color: #ccc; + background: inherit; + cursor: inherit; +} + +.theme-overlay .theme-header .right:before, +.theme-overlay .theme-header .left:before { + font: normal 20px/50px dashicons !important; + display: inline; + font-weight: 300; +} + +.theme-overlay .theme-header .left:before { + content: "\f345"; +} + +.theme-overlay .theme-header .right:before { + content: "\f341"; +} + +.theme-overlay .theme-wrap { + clear: both; + position: fixed; + top: 9%; + right: 190px; + left: 30px; + bottom: 3%; + background: #fff; + box-shadow: 0 1px 20px 5px rgba(0, 0, 0, 0.1); + z-index: 10000; /* Over WP Pointers. */ + box-sizing: border-box; + -webkit-overflow-scrolling: touch; +} + +body.folded .theme-browser ~ .theme-overlay .theme-wrap { + right: 70px; +} + +.theme-overlay .theme-about { + position: absolute; + top: 49px; + bottom: 57px; + right: 0; + left: 0; + overflow: auto; + padding: 2% 4%; +} + +.theme-overlay .theme-actions { + position: absolute; + text-align: center; + bottom: 0; + right: 0; + left: 0; + padding: 10px 25px 5px; + background: #f3f3f3; + z-index: 30; + box-sizing: border-box; + border-top: 1px solid #eee; +} + +.ie8 .theme-overlay .theme-actions { + border: 1px solid #eee; +} + +.theme-overlay .theme-actions a { + margin-left: 5px; + margin-bottom: 5px; +} + +/* Hide-if-customize for items we can't add classes to */ +.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-header"], +.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-background"] { + display: none; +} + +.broken-themes a.delete-theme, +.theme-overlay .theme-actions .delete-theme { + color: #a00; + text-decoration: none; + border-color: transparent; + box-shadow: none; + background: transparent; +} + +.theme-overlay .theme-actions .delete-theme { + position: absolute; + left: 10px; + bottom: 5px; +} + +.broken-themes a.delete-theme:hover, +.broken-themes a.delete-theme:focus, +.theme-overlay .theme-actions .delete-theme:hover, +.theme-overlay .theme-actions .delete-theme:focus { + background: #d54e21; + color: #fff; + border-color: #d54e21; +} + +.theme-overlay .theme-actions .active-theme, +.theme-overlay.active .theme-actions .inactive-theme { + display: none; +} + +.theme-overlay .theme-actions .inactive-theme, +.theme-overlay.active .theme-actions .active-theme { + display: block; +} + +/** + * Theme Screenshots gallery + */ +.theme-overlay .theme-screenshots { + float: right; + margin: 0 0 0 30px; + width: 55%; + max-width: 1200px; /* Recommended theme screenshot width, set here to avoid stretching */ + text-align: center; +} + +/* First screenshot, shown big */ +.theme-overlay .screenshot { + border: 1px solid #fff; + box-sizing: border-box; + overflow: hidden; + position: relative; + box-shadow: 0 0 0 1px rgba(0,0,0,0.2); +} + +.theme-overlay .screenshot:after { + content: ""; + display: block; + padding-top: 75%; /* using a 4/3 aspect ratio */ +} + +.theme-overlay .screenshot img { + height: auto; + position: absolute; + right: 0; + top: 0; + width: 100%; +} +/* Handles old 300px screenshots */ +.theme-overlay.small-screenshot .theme-screenshots { + position: absolute; + width: 302px; +} +.theme-overlay.small-screenshot .theme-info { + margin-right: 350px; + width: auto; +} + +/* Other screenshots, shown small and square */ +.theme-overlay .screenshot.thumb { + background: #ccc; + border: 1px solid #eee; + float: none; + display: inline-block; + margin: 10px 5px 0; + width: 140px; + height: 80px; + cursor: pointer; +} + +.theme-overlay .screenshot.thumb:after { + content: ""; + display: block; + padding-top: 100%; /* using a 1/1 aspect ratio */ +} + +.theme-overlay .screenshot.thumb img { + cursor: pointer; + height: auto; + position: absolute; + right: 0; + top: 0; + width: 100%; + height: auto; +} + +.theme-overlay .screenshot.selected { + background: transparent; + border: 2px solid #00a0d2; +} + +.theme-overlay .screenshot.selected img { + opacity: 0.8; +} + +/* No screenshot placeholder */ +.theme-browser .theme .theme-screenshot.blank, +.theme-overlay .screenshot.blank { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAALElEQVQYGWO8d+/efwYkoKioiMRjYGBC4WHhUK6A8T8QIJt8//59ZC493AAAQssKpBK4F5AAAAAASUVORK5CYII=); +} + +/** + * Theme heading information + */ +.theme-overlay .theme-info { + width: 40%; + float: right; +} + +.theme-overlay .current-label { + background: #32373c; + color: #fff; + font-size: 11px; + display: inline-block; + padding: 2px 8px; + border-radius: 2px; + margin: 0 0 -10px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.theme-overlay .theme-name { + color: #23282d; + font-size: 32px; + font-weight: 100; + margin: 10px 0 0; + line-height: 1.3; + word-wrap: break-word; + overflow-wrap: break-word; +} + +.theme-overlay .theme-version { + color: #72777c; + font-size: 13px; + font-weight: 400; + float: none; + display: inline-block; + margin-right: 10px; +} + +.theme-overlay .theme-author { + margin: 15px 0 25px; + color: #72777c; + font-size: 16px; + font-weight: 400; + line-height: inherit; +} + +.theme-overlay .theme-author a { + text-decoration: none; +} + +.theme-overlay .theme-description { + color: #555; + font-size: 15px; + font-weight: 400; + line-height: 1.5; + margin: 30px 0 0 0; +} + +.theme-overlay .theme-tags { + border-top: 3px solid #eee; + color: #82878c; + font-size: 13px; + font-weight: 400; + margin: 30px 0 0 0; + padding-top: 20px; +} + +.theme-overlay .theme-tags span { + color: #444; + font-weight: 600; + margin-left: 5px; +} + +.theme-overlay .parent-theme { + background: #f7fcfe; + border: 1px solid #eee; + border-right: 4px solid #00a0d2; + font-size: 14px; + font-weight: 400; + margin-top: 30px; + padding: 10px 20px 10px 10px; +} + +.theme-overlay .parent-theme strong { + font-weight: 700; +} + +/** + * Single Theme Mode + * Displays detailed view inline when a user has no switch capabilities + */ +.single-theme .theme-overlay .theme-backdrop, +.single-theme .theme-overlay .theme-header, +.single-theme .theme { + display: none; +} + +.single-theme .theme-overlay .theme-wrap { + clear: both; + min-height: 330px; + position: relative; + right: auto; + left: auto; + top: auto; + bottom: auto; + z-index: 10; +} + +.single-theme .theme-overlay .theme-about { + padding: 30px 30px 70px; + position: static; +} + +.single-theme .theme-overlay .theme-actions { + position: absolute; +} + +/** + * Basic Responsive structure... + * + * Shuffles theme columns around based on screen width + */ + +@media only screen and (min-width: 2000px) { + #wpwrap .theme-browser .theme { + width: 17.6%; + margin: 0 0 3% 3%; + } + + #wpwrap .theme-browser .theme:nth-child(3n), + #wpwrap .theme-browser .theme:nth-child(4n) { + margin-left: 3%; + } + + #wpwrap .theme-browser .theme:nth-child(5n) { + margin-left: 0; + } +} + +@media only screen and (min-width: 1680px) { + .theme-overlay .theme-wrap { + width: 1450px; + margin: 0 auto; + } +} + +/* Maximum screenshot width reaches 440px */ +@media only screen and (min-width: 1640px) { + .theme-browser .theme { + width: 22.7%; + margin: 0 0 3% 3%; + } + .theme-browser .theme .theme-screenshot:after { + padding-top: 75%; /* using a 4/3 aspect ratio */ + } + + .theme-browser .theme:nth-child(3n) { + margin-left: 3%; + } + + .theme-browser .theme:nth-child(4n) { + margin-left: 0; + } +} +/* Maximum screenshot width reaches 440px */ +@media only screen and (max-width: 1120px) { + .theme-browser .theme { + width: 47.5%; + margin-left: 0; + } + + .theme-browser .theme:nth-child(even) { + margin-left: 0; + } + + .theme-browser .theme:nth-child(odd) { + margin-left: 5%; + } +} + +/* Admin menu is folded */ +@media only screen and (max-width: 900px) { + .theme-overlay .theme-wrap { + right: 65px; + } +} + +@media only screen and (max-width: 780px) { + body.folded .theme-overlay .theme-wrap, + .theme-overlay .theme-wrap { + top: 0; /* The adminmenu isn't fixed on mobile, so this can use the full viewport height */ + left: 0; + bottom: 0; + right: 0; + padding: 70px 20px 20px; + border: none; + z-index: 100000; /* should overlap #wpadminbar. */ + position: fixed; + } + + .theme-browser .theme.active .theme-name span { + /* Hide the "Active: " label on smaller screens. */ + display: none; + } + + .theme-overlay .theme-screenshots { + width: 40%; + } + + .theme-overlay .theme-info { + width: 50%; + } + .single-theme .theme-wrap { + padding: 10px; + } + + .theme-browser .theme .theme-actions { + padding: 5px 10px 4px 10px; + } + + .theme-overlay.small-screenshot .theme-screenshots { + position: static; + float: none; + max-width: 302px; + } + + .theme-overlay.small-screenshot .theme-info { + margin-right: 0; + width: auto; + } + + .theme:not(.active):hover .theme-actions, + .theme:not(.active):focus .theme-actions, + .theme:hover .more-details, + .theme:focus .more-details { + display: none; + } + + .theme-browser.rendered .theme:hover .theme-screenshot img, + .theme-browser.rendered .theme:focus .theme-screenshot img { + opacity: 1.0; + } +} + +@media only screen and (max-width: 480px) { + .theme-browser .theme { + width: 100%; + margin-left: 0; + } + + .theme-browser .theme:nth-child(2n), + .theme-browser .theme:nth-child(3n) { + margin-left: 0; + } +} + +@media only screen and (max-width: 650px) { + .theme-overlay .theme-description { + margin-right: 0; + } + + .theme-overlay .theme-actions .delete-theme { + position: relative; + left: auto; + bottom: auto; + } + + .theme-overlay .theme-actions .inactive-theme { + display: inline; + } + + .theme-overlay .theme-screenshots { + width: 100%; + float: none; + } + + .theme-overlay .theme-info { + width: 100%; + } + + .theme-overlay .theme-author { + margin: 5px 0 15px 0; + } + + .theme-overlay .current-label { + margin-top: 10px; + font-size: 13px; + } + + .themes-php .wp-filter-search { + float: none; + clear: both; + right: 0; + left: 0; + margin: -5px 0 20px 0; + width: 100%; + max-width: 280px; + } + + .theme-browser .theme.add-new-theme span:after { + font: normal 60px/90px dashicons; + width: 80px; + height: 80px; + top: 30%; + right: 50%; + text-indent: 0; + margin-right: -40px; + } + + .single-theme .theme-wrap { + margin: 0 -10px 0 -12px; + padding: 10px; + } + .single-theme .theme-overlay .theme-about { + padding: 10px; + overflow: visible; + } + .single-theme .current-label { + display: none; + } + .single-theme .theme-overlay .theme-actions { + position: static; + } +} + +.broken-themes { + clear: both; +} + +.broken-themes table { + text-align: right; + width: 50%; + border-spacing: 3px; + padding: 3px; +} + + +/*------------------------------------------------------------------------------ + 16.2 - Install Themes +------------------------------------------------------------------------------*/ + +/* Already installed theme */ +.theme-browser .theme .theme-installed { + background: #0073aa; +} +.theme-browser .theme .notice-success p:before { + color: #79ba49; + content: "\f147"; + display: inline-block; + font: normal 20px/1 'dashicons'; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.theme-install.updated-message:before { + content: ''; +} + +.theme-install-php .wp-filter { + padding-right: 20px; +} + +.theme-install-php a.upload, +.theme-install-php a.browse-themes { + cursor: pointer; +} + +.upload-view-toggle .browse, +.plugin-install-tab-upload .upload-view-toggle .upload { + display: none; +} + +.plugin-install-tab-upload .upload-view-toggle .browse { + display: inline; +} + +.upload-theme, +.upload-plugin { + box-sizing: border-box; + display: none; + margin: 0; + padding: 50px 0; + width: 100%; + overflow: hidden; + position: relative; + top: 10px; +} + +.upload-plugin-wrap { + display: none; +} + +.show-upload-view .upload-theme, +.show-upload-view .upload-plugin, +.show-upload-view .upload-plugin-wrap, +.plugin-install-tab-upload .upload-plugin { + display: block; +} + +.upload-theme .wp-upload-form, +.upload-plugin .wp-upload-form { + background: #fafafa; + border: 1px solid #e5e5e5; + padding: 30px; + margin: 30px auto; + max-width: 380px; +} +.upload-theme .install-help, +.upload-plugin .install-help { + color: #555d66; /* #f1f1f1 background */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 0; + text-align: center; +} + +p.no-themes, +p.no-themes-local { + clear: both; + color: #666; + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0; + text-align: center; + display: none; +} + +.no-results p.no-themes { + display: block; +} + +.theme-install-php .add-new-theme { + display: none !important; +} + +@media only screen and (max-width: 1120px) { + .upload-theme .wp-upload-form { + margin: 20px 0; + max-width: 100%; + } + .upload-theme .install-help { + font-size: 15px; + padding: 20px 0 0; + text-align: right; + } +} + +.theme-details .theme-rating { + line-height: 23px; +} + +.theme-details .star-rating { + display: inline; +} + +.theme-details .num-ratings, +.theme-details .no-rating { + font-size: 11px; + color: #72777c; +} + +.theme-details .no-rating { + display: block; + line-height: 20px; +} + +/*------------------------------------------------------------------------------ + 16.3 - Custom Header Screen +------------------------------------------------------------------------------*/ + +.appearance_page_custom-header #headimg { + border: 1px solid #ddd; + overflow: hidden; + width: 100%; +} + +.appearance_page_custom-header #upload-form p label { + font-size: 12px; +} + +.appearance_page_custom-header .available-headers .default-header { + float: right; + margin: 0 0 20px 20px; +} + +.appearance_page_custom-header .random-header { + clear: both; + margin: 0 0 20px 20px; + vertical-align: middle; +} + +.appearance_page_custom-header .available-headers label input, +.appearance_page_custom-header .random-header label input { + margin-left: 10px; +} + +.appearance_page_custom-header .available-headers label img { + vertical-align: middle; +} + + +/*------------------------------------------------------------------------------ + 16.4 - Custom Background Screen +------------------------------------------------------------------------------*/ + +div#custom-background-image { + min-height: 100px; + border: 1px solid #ddd; +} + +div#custom-background-image img { + max-width: 400px; + max-height: 300px; +} + +.background-position-control input[type="radio"]:checked ~ .button { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, .5 ); + z-index: 1; +} + +.background-position-control input[type="radio"]:focus ~ .button { + border-color: #5b9dd9; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, .5 ), 0 0 3px rgba( 0, 115, 170, .8 ); + color: #23282d; +} + +.background-position-control .background-position-center-icon, +.background-position-control .background-position-center-icon:before { + display: inline-block; + line-height: 1; + text-align: center; + transition: background-color .1s ease-in 0; +} + +.background-position-control .background-position-center-icon { + height: 20px; + margin-top: 13px; + vertical-align: top; + width: 20px; +} + +.background-position-control .background-position-center-icon:before { + background-color: #555; + border-radius: 50%; + content: ""; + height: 12px; + width: 12px; +} + +.background-position-control .button:hover .background-position-center-icon:before, +.background-position-control input[type="radio"]:focus ~ .button .background-position-center-icon:before { + background-color: #23282d; +} + +.background-position-control .button-group { + display: block; +} + +.background-position-control .button-group .button { + border-radius: 0; + box-shadow: none; + /* Following properties are overridden by buttons responsive styles (see: wp-includes/css/buttons.css). */ + height: 40px !important; + line-height: 37px !important; + margin: 0 0 0 -1px !important; + padding: 0 10px 1px !important; + position: relative; +} + +.background-position-control .button-group .button:active, +.background-position-control .button-group .button:hover, +.background-position-control .button-group .button:focus { + z-index: 1; +} + +.background-position-control .button-group:last-child .button { + box-shadow: 0 1px 0 #ccc; +} + +.background-position-control .button-group > label { + margin: 0 !important; +} + +.background-position-control .button-group:first-child > label:first-child .button { + border-radius: 0 3px 0 0; +} + +.background-position-control .button-group:first-child > label:first-child .dashicons { + -webkit-transform: rotate( -45deg ); + transform: rotate( -45deg ); +} + +.background-position-control .button-group:first-child > label:last-child .button { + border-radius: 3px 0 0 0; +} + +.background-position-control .button-group:first-child > label:last-child .dashicons { + -webkit-transform: rotate( 45deg ); + transform: rotate( 45deg ); +} + +.background-position-control .button-group:last-child > label:first-child .button { + border-radius: 0 0 3px 0; +} + +.background-position-control .button-group:last-child > label:first-child .dashicons { + -webkit-transform: rotate( 45deg ); + transform: rotate( 45deg ); +} + +.background-position-control .button-group:last-child > label:last-child .button { + border-radius: 0 0 0 3px; +} + +.background-position-control .button-group:last-child > label:last-child .dashicons { + -webkit-transform: rotate( -45deg ); + transform: rotate( -45deg ); +} + +.background-position-control .button-group .dashicons { + margin-top: 9px; +} + +.background-position-control .button-group + .button-group { + margin-top: -1px; +} + +/*------------------------------------------------------------------------------ + 23.0 - Full Overlay w/ Sidebar +------------------------------------------------------------------------------*/ + +body.full-overlay-active { + overflow: hidden; + /* Hide all the content, the Customizer overlay is then made visible to be the only available content. */ + visibility: hidden; +} + +.wp-full-overlay { + background: transparent; + z-index: 500000; + position: fixed; + overflow: visible; + top: 0; + bottom: 0; + right: 0; + left: 0; + height: 100%; + min-width: 0; +} + +.wp-full-overlay-sidebar { + box-sizing: border-box; + position: fixed; + min-width: 300px; + max-width: 600px; + width: 18%; + height: 100%; + top: 0; + bottom: 0; + right: 0; + padding: 0; + margin: 0; + z-index: 10; + background: #eee; + border-left: none; +} + +.wp-full-overlay.collapsed .wp-full-overlay-sidebar { + overflow: visible; +} + +.wp-full-overlay.collapsed, +.wp-full-overlay.expanded .wp-full-overlay-sidebar { + margin-right: 0 !important; +} + +.wp-full-overlay.expanded { + margin-right: 300px; +} + +.wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-right: -300px; +} + +@media screen and (min-width: 1667px) { + .wp-full-overlay.expanded { + margin-right: 18%; + } + + .wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-right: -18%; + } +} + +@media screen and (min-width: 3333px) { + .wp-full-overlay.expanded { + margin-right: 600px; + } + + .wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-right: -600px; + } +} + +.wp-full-overlay-sidebar:after { + content: ""; + display: block; + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 3px; + z-index: 1000; +} + +.wp-full-overlay-main { + position: absolute; + right: 0; + left: 0; + top: 0; + bottom: 0; + height: 100%; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header { + position: absolute; + right: 0; + left: 0; + height: 45px; + padding: 0 15px; + line-height: 45px; + z-index: 10; + margin: 0; + border-top: none; + box-shadow: none; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header a.back { + margin-top: 9px; +} + +.wp-full-overlay-sidebar .wp-full-overlay-footer { + bottom: 0; + border-bottom: none; + border-top: none; + box-shadow: none; +} + +.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content { + position: absolute; + top: 45px; + bottom: 45px; + right: 0; + left: 0; + overflow: auto; +} + +/* Close & Navigation Links */ +.theme-install-overlay .wp-full-overlay-sidebar .wp-full-overlay-header { + padding: 0; +} + +.theme-install-overlay .close-full-overlay, +.theme-install-overlay .previous-theme, +.theme-install-overlay .next-theme { + display: block; + position: relative; + float: right; + width: 45px; + height: 45px; + padding-left: 2px; + background: #eee; + border-left: 1px solid #ddd; + color: #444; + cursor: pointer; + text-decoration: none; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-install-overlay .close-full-overlay:hover, +.theme-install-overlay .close-full-overlay:focus, +.theme-install-overlay .previous-theme:hover, +.theme-install-overlay .previous-theme:focus, +.theme-install-overlay .next-theme:hover, +.theme-install-overlay .next-theme:focus { + background: #ddd; + border-color: #ccc; + color: #000; + outline: none; + box-shadow: none; +} + +.theme-install-overlay .close-full-overlay:before { + font: normal 22px/1 dashicons; + content: "\f335"; + position: relative; + top: 7px; + right: 13px; +} + +.theme-install-overlay .previous-theme:before { + font: normal 20px/1 dashicons; + content: "\f345"; + position: relative; + top: 6px; + right: 14px; +} + +.theme-install-overlay .next-theme:before { + font: normal 20px/1 dashicons; + content: "\f341"; + position: relative; + top: 6px; + right: 13px; +} + +.theme-install-overlay .previous-theme.disabled, +.theme-install-overlay .next-theme.disabled, +.theme-install-overlay .previous-theme.disabled:hover, +.theme-install-overlay .previous-theme.disabled:focus, +.theme-install-overlay .next-theme.disabled:hover, +.theme-install-overlay .next-theme.disabled:focus { + color: #b4b9be; + background: #eee; + cursor: default; + pointer-events: none; +} + +.theme-install-overlay .close-full-overlay, +.theme-install-overlay .previous-theme, +.theme-install-overlay .next-theme { + border-right: 0; + border-top: 0; + border-bottom: 0; +} + +.theme-install-overlay .close-full-overlay:before, +.theme-install-overlay .previous-theme:before, +.theme-install-overlay .next-theme:before { + top: 2px; + right: 0; +} + +/* Collapse Button */ +.wp-core-ui .wp-full-overlay .collapse-sidebar { + position: fixed; + bottom: 0; + right: 0; + padding: 9px 10px 9px 0; + height: 45px; + color: #656a6f; + outline: 0; + line-height: 1; + background-color: transparent !important; + border: none !important; + box-shadow: none !important; + border-radius: 0 !important; +} + +.wp-core-ui .wp-full-overlay .collapse-sidebar:hover, +.wp-core-ui .wp-full-overlay .collapse-sidebar:focus { + color: #0073aa; +} + +.wp-full-overlay .collapse-sidebar-arrow, +.wp-full-overlay .collapse-sidebar-label { + display: inline-block; + vertical-align: middle; + line-height: 20px; +} + +.wp-full-overlay .collapse-sidebar-arrow { + width: 20px; + height: 20px; + margin: 0 2px; /* avoid the focus box-shadow to be cut-off */ + border-radius: 50%; + overflow: hidden; +} + +.wp-full-overlay .collapse-sidebar:hover .collapse-sidebar-arrow, +.wp-full-overlay .collapse-sidebar:focus .collapse-sidebar-arrow { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.wp-full-overlay .collapse-sidebar-label { + margin-right: 3px; +} + +.wp-full-overlay.collapsed .collapse-sidebar-label { + display: none; +} + +.wp-full-overlay .collapse-sidebar-arrow:before { + display: block; + content: "\f148"; + background: #eee; + font: normal 20px/1 dashicons; + speak: none; + padding: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-core-ui .wp-full-overlay.collapsed .collapse-sidebar { + padding: 9px 10px; +} + +/* rtl:ignore */ +.wp-full-overlay.collapsed .collapse-sidebar-arrow:before, +.rtl .wp-full-overlay .collapse-sidebar-arrow:before { + -webkit-transform: rotate(180.001deg); + transform: rotate(180.001deg); /* Firefox: promoting to its own layer to trigger anti-aliasing */ +} + +.rtl .wp-full-overlay.collapsed .collapse-sidebar-arrow:before { + -webkit-transform: none; + transform: none; +} + +/* Animations */ +.wp-full-overlay, +.wp-full-overlay-sidebar, +.wp-full-overlay .collapse-sidebar, +.wp-full-overlay-main { + transition-property: right, left, top, bottom, width, margin; + transition-duration: 0.2s; +} + +/* Device/preview size toggles */ + +.wp-full-overlay { + background: #191e23; +} + +.wp-full-overlay-main { + background-color: #f1f1f1; +} + +.expanded .wp-full-overlay-footer { + position: fixed; + bottom: 0; + right: 0; + min-width: 299px; + max-width: 599px; + width: 18%; + width: calc( 18% - 1px ); + height: 45px; + border-top: 1px solid #ddd; + background: #eee; +} + +.wp-full-overlay-footer .devices-wrapper { + float: left; +} + +.wp-full-overlay-footer .devices { + position: relative; + background: #eee; + box-shadow: 20px 0 10px -5px #eee; +} + +.wp-full-overlay-footer .devices button { + cursor: pointer; + background: transparent; + border: none; + height: 45px; + padding: 0 3px; + margin: 0 -4px 0 0; + box-shadow: none; + border-top: 1px solid transparent; + border-bottom: 4px solid transparent; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; +} + +.wp-full-overlay-footer .devices button:focus { + box-shadow: none; + outline: none; +} + +.wp-full-overlay-footer .devices button:before { + display: inline-block; + -webkit-font-smoothing: antialiased; + font: normal 20px/30px "dashicons"; + vertical-align: top; + margin: 3px 0; + padding: 4px 8px; + color: #656a6f; +} + +.wp-full-overlay-footer .devices button.active { + border-bottom-color: #191e23; +} + +.wp-full-overlay-footer .devices button:hover, +.wp-full-overlay-footer .devices button:focus { + background-color: #fff; +} + +.wp-full-overlay-footer .devices button:focus, +.wp-full-overlay-footer .devices button.active:hover { + border-bottom-color: #0073aa; +} + +.wp-full-overlay-footer .devices button.active:before { + color: #191e23; +} + +.wp-full-overlay-footer .devices button:hover:before, +.wp-full-overlay-footer .devices button:focus:before { + color: #0073aa; +} + +.wp-full-overlay-footer .devices .preview-desktop:before { + content: "\f472"; +} + +.wp-full-overlay-footer .devices .preview-tablet:before { + content: "\f471"; +} + +.wp-full-overlay-footer .devices .preview-mobile:before { + content: "\f470"; +} + +@media screen and (max-width:1024px) { + .wp-full-overlay-footer .devices { + display: none; + } +} + +.collapsed .wp-full-overlay-footer .devices button:before { + display: none; +} + +.preview-mobile .wp-full-overlay-main { + margin: auto -160px auto 0; + width: 320px; + height: 480px; + max-height: 100%; + max-width: 100%; + right: 50%; +} + +.preview-tablet .wp-full-overlay-main { + margin: auto -360px auto 0; + width: 720px; /* Size is loosely based on a typical "tablet" device size. Intentionally ambiguous - this does not represent any particular device precisely. */ + height: 1080px; + max-height: 100%; + max-width: 100%; + right: 50%; +} + + +/*------------------------------------------------------------------------------ + 24.0 - Customize Loader +------------------------------------------------------------------------------*/ + +.no-customize-support .hide-if-no-customize, +.customize-support .hide-if-customize, +.no-customize-support.wp-core-ui .hide-if-no-customize, +.no-customize-support .wp-core-ui .hide-if-no-customize, +.customize-support.wp-core-ui .hide-if-customize, +.customize-support .wp-core-ui .hide-if-customize { + display: none; +} + +#customize-container, +#customize-controls .notice.notification-overlay { + background: #eee; + z-index: 500000; + position: fixed; + overflow: visible; + top: 0; + bottom: 0; + right: 0; + left: 0; + height: 100%; +} +#customize-container { + display: none; +} + +/* Make the Customizer and Theme installer overlays the only available content. */ +#customize-container, +.theme-install-overlay { + visibility: visible; +} + +.customize-loading #customize-container iframe { + opacity: 0; +} + +#customize-container iframe, +.theme-install-overlay iframe { + height: 100%; + width: 100%; + z-index: 20; + transition: opacity 0.3s; +} + +#customize-controls { + margin-top: 0; +} + +.theme-install-overlay { + display: none; +} + +.theme-install-overlay.single-theme { + display: block; +} + +.install-theme-info { + display: none; + padding: 10px 20px 60px; +} + +.single-theme .install-theme-info { + padding-top: 15px; +} + +.theme-install-overlay .install-theme-info { + display: block; +} + +.install-theme-info .theme-install { + float: left; + margin-top: 18px; +} + +.install-theme-info .theme-name { + font-size: 16px; + line-height: 24px; + margin-bottom: 0; + margin-top: 0; +} + +.install-theme-info .theme-screenshot { + margin: 15px 0; + width: 258px; + border: 1px solid #ccc; +} + +.install-theme-info .theme-details { + overflow: hidden; +} + +.theme-details .theme-version { + margin: 15px 0; +} + +.theme-details .theme-description { + float: right; + color: #72777c; + line-height: 20px; + max-width: 100%; +} + +.theme-install-overlay .wp-full-overlay-header .button { + float: left; + margin: 8px 0 0 10px; + /* For when .theme-install is a span rather than a.button-primary (already installed theme) */ + line-height: 26px; +} + +.theme-install-overlay .wp-full-overlay-sidebar { + background: #eee; + border-left: 1px solid #ddd; +} + +.theme-install-overlay .wp-full-overlay-sidebar-content { + background: #fff; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; +} + +.theme-install-overlay .wp-full-overlay-main { + position: absolute; + z-index: 0; + background-color: #f1f1f1; +} + +.customize-loading #customize-container { + background-color: #f1f1f1; +} + +#customize-preview.wp-full-overlay-main:before, +.customize-loading #customize-container:before, +#customize-controls .notice.notification-overlay.notification-loading:before, +.theme-install-overlay .wp-full-overlay-main:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + right: 50%; + top: 50%; + z-index: -1; + margin: -10px -10px 0 0; + -webkit-transform: translateZ(0); + transform: translateZ(0); + background: transparent url(../images/spinner.gif) no-repeat center center; + background-size: 20px 20px; +} + +#customize-preview.wp-full-overlay-main.iframe-ready:before, +.theme-install-overlay.iframe-ready .wp-full-overlay-main:before { + background-image: none; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .wp-full-overlay .collapse-sidebar-arrow { + background-image: url(../images/arrows-2x.png); + background-size: 15px 123px; + } + + #customize-preview.wp-full-overlay-main:before, + .customize-loading #customize-container:before, + #customize-controls .notice.notification-overlay.notification-loading:before, + .theme-install-overlay .wp-full-overlay-main:before { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + .available-theme .action-links .delete-theme { + float: none; + margin: 0; + padding: 0; + clear: both; + } + + .available-theme .action-links .delete-theme a { + padding: 0; + } + + .broken-themes table { + width: 100%; + } + + .theme-install-overlay .wp-full-overlay-header .theme-install { + margin-top: 6px; + line-height: normal; + } + + .theme-browser .theme .theme-actions .button { + margin-bottom: 0; + } + + .theme-browser .theme.active .theme-actions, + .theme-browser .theme .theme-actions { + padding-top: 8px; + padding-bottom: 8px; + } +} + +@media aural { + .theme .notice:before, + .theme-info .updating-message:before, + .theme-info .updated-message:before, + .theme-install.updating-message:before { + speak: none; + } +} diff --git a/backend/wp-admin/css/themes-rtl.min.css b/backend/wp-admin/css/themes-rtl.min.css new file mode 100644 index 0000000..d9af4ae --- /dev/null +++ b/backend/wp-admin/css/themes-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body.js .theme-browser.search-loading{display:none}.theme-browser .themes{clear:both}.themes-php:not(.network-admin) .wrap h1{margin-bottom:15px}.themes-php .wrap h1 .button{margin-right:20px}.themes-php .search-form{display:inline}.themes-php .wp-filter-search{position:relative;top:-2px;right:20px;margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5}.theme .notice,.theme .notice.is-dismissible{right:0;margin:0;position:absolute;left:0;top:0}.theme-browser .theme{cursor:pointer;float:right;margin:0 0 4% 4%;position:relative;width:30.6%;border:1px solid #ddd;box-shadow:0 1px 1px -1px rgba(0,0,0,.1);box-sizing:border-box}.ie8 .theme-browser .theme{width:30%;margin:0 0 4% 3%}.theme-browser .theme:nth-child(3n){margin-left:0}.theme-browser .theme:focus,.theme-browser .theme:hover{cursor:pointer}.theme-browser .theme .theme-name{font-size:15px;font-weight:600;height:18px;margin:0;padding:15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;background:#fff;background:rgba(255,255,255,.65)}.theme-browser .theme .theme-actions{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";opacity:0;transition:opacity .1s ease-in-out;height:auto;background:rgba(244,244,244,.7);border-right:1px solid rgba(0,0,0,.05)}.theme-browser .theme.focus .theme-actions,.theme-browser .theme:focus .theme-actions,.theme-browser .theme:hover .theme-actions{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}.theme-browser .theme .theme-actions .button-primary{margin-left:3px}.theme-browser .theme .theme-actions .button{float:none;margin-right:3px}.theme-browser .theme .theme-screenshot{display:block;overflow:hidden;position:relative;-webkit-backface-visibility:hidden;transition:opacity .2s ease-in-out}.theme-browser .theme .theme-screenshot:after{content:"";display:block;padding-top:66.66666%}.theme-browser .theme .theme-screenshot img{height:auto;position:absolute;right:0;top:0;width:100%;transition:opacity .2s ease-in-out}.theme-browser .theme:focus .theme-screenshot,.theme-browser .theme:hover .theme-screenshot{background:#fff}.theme-browser.rendered .theme:focus .theme-screenshot img,.theme-browser.rendered .theme:hover .theme-screenshot img{opacity:.4}.theme-browser .theme .more-details{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";opacity:0;position:absolute;top:35%;left:20%;right:20%;background:#23282d;background:rgba(0,0,0,.7);color:#fff;font-size:15px;text-shadow:0 1px 0 rgba(0,0,0,.6);-webkit-font-smoothing:antialiased;font-weight:600;padding:15px 12px;text-align:center;border-radius:3px;transition:opacity .1s ease-in-out}.theme-browser .theme:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.theme-browser .theme:focus .more-details{opacity:1}.theme-browser .theme.active:focus .theme-actions{display:block}.theme-browser.rendered .theme:focus .more-details,.theme-browser.rendered .theme:hover .more-details{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}.theme-browser .theme.active .theme-name{background:#23282d;color:#fff;padding-left:110px;font-weight:300;box-shadow:inset 0 1px 1px rgba(0,0,0,.5)}.theme-browser .customize-control .theme.active .theme-name{padding-left:15px}.theme-browser .theme.active .theme-name span{font-weight:600}.theme-browser .theme.active .theme-actions{background:rgba(49,49,49,.7);border-right:none;opacity:1}.theme-id-container{position:relative}.theme-browser .theme .theme-actions,.theme-browser .theme.active .theme-actions{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);left:0;padding:10px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}.theme-browser .theme.active .theme-actions .button-primary{margin-left:0}.theme-browser .theme .theme-author{background:#23282d;color:#eee;display:none;font-size:14px;margin:0 10px;padding:5px 10px;position:absolute;bottom:56px}.theme-browser .theme.display-author .theme-author{display:block}.theme-browser .theme.display-author .theme-author a{color:inherit;text-decoration:none}.theme-browser .theme.add-new-theme{border:none;box-shadow:none}.theme-browser .theme.add-new-theme a{text-decoration:none;display:block;position:relative;z-index:1}.theme-browser .theme.add-new-theme a:after{display:block;content:"";background:0 0;background:rgba(0,0,0,0);position:absolute;top:0;right:0;left:0;bottom:0;padding:0;text-shadow:none;border:5px dashed #d5d2ca;border:5px dashed rgba(0,0,0,.1);box-sizing:border-box}.theme-browser .theme.add-new-theme span:after{background:#e5e5e5;background:rgba(153,153,153,.1);border-radius:50%;display:inline-block;content:"\f132";-webkit-font-smoothing:antialiased;font:400 74px/115px dashicons;width:100px;height:100px;vertical-align:middle;text-align:center;color:#999;position:absolute;top:30%;right:50%;margin-right:-50px;text-indent:-4px;padding:0;text-shadow:none;z-index:4}.rtl .theme-browser .theme.add-new-theme span:after{text-indent:4px}.theme-browser .theme.add-new-theme a:focus .theme-screenshot,.theme-browser .theme.add-new-theme a:hover .theme-screenshot{background:0 0}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{background:#fff;color:#0073aa}.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{border-color:transparent;color:#fff;background:#0073aa;content:""}.theme-browser .theme.add-new-theme .theme-name{background:0 0;text-align:center;box-shadow:none;font-weight:400;position:relative;top:0;margin-top:-18px;padding-top:0;padding-bottom:48px}.theme-browser .theme.add-new-theme a:focus .theme-name,.theme-browser .theme.add-new-theme a:hover .theme-name{color:#fff;z-index:2}.theme-overlay .theme-backdrop{position:absolute;right:-20px;left:0;top:0;bottom:0;background:#f1f1f1;background:rgba(238,238,238,.9);z-index:10000}.theme-overlay .theme-header .close,.theme-overlay .theme-header .left,.theme-overlay .theme-header .right{cursor:pointer;background-color:transparent;height:48px;transition:color .1s ease-in-out,background .1s ease-in-out;text-align:center}.theme-overlay .theme-header{position:absolute;top:0;right:0;left:0;height:48px;border-bottom:1px solid #ddd}.theme-overlay .theme-header button{padding:0}.theme-overlay .theme-header .close{width:50px;float:left;border:0;border-right:1px solid #ddd}.theme-overlay .theme-header .close:before{font:400 22px/50px dashicons!important;color:#72777c;display:inline-block;content:"\f335";font-weight:300}.theme-overlay .theme-header .left,.theme-overlay .theme-header .right{color:#72777c;width:54px;float:right;border:0;border-left:1px solid #ddd}.theme-overlay .theme-header .close:focus,.theme-overlay .theme-header .close:hover,.theme-overlay .theme-header .left:focus,.theme-overlay .theme-header .left:hover,.theme-overlay .theme-header .right:focus,.theme-overlay .theme-header .right:hover{background:#ddd;border-color:#ccc;color:#000}.theme-overlay .theme-header .close:focus:before,.theme-overlay .theme-header .close:hover:before{color:#000}.theme-overlay .theme-header .close:focus,.theme-overlay .theme-header .left:focus,.theme-overlay .theme-header .right:focus{box-shadow:none;outline:0}.theme-overlay .theme-header .left.disabled,.theme-overlay .theme-header .left.disabled:hover,.theme-overlay .theme-header .right.disabled,.theme-overlay .theme-header .right.disabled:hover{color:#ccc;background:inherit;cursor:inherit}.theme-overlay .theme-header .left:before,.theme-overlay .theme-header .right:before{font:400 20px/50px dashicons!important;display:inline;font-weight:300}.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-header"],.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-background"],.theme-overlay .theme-actions .active-theme,.theme-overlay.active .theme-actions .inactive-theme{display:none}.theme-overlay .theme-header .left:before{content:"\f345"}.theme-overlay .theme-header .right:before{content:"\f341"}.theme-overlay .theme-wrap{clear:both;position:fixed;top:9%;right:190px;left:30px;bottom:3%;background:#fff;box-shadow:0 1px 20px 5px rgba(0,0,0,.1);z-index:10000;box-sizing:border-box;-webkit-overflow-scrolling:touch}body.folded .theme-browser~.theme-overlay .theme-wrap{right:70px}.theme-overlay .theme-about{position:absolute;top:49px;bottom:57px;right:0;left:0;overflow:auto;padding:2% 4%}.theme-overlay .theme-actions{position:absolute;text-align:center;bottom:0;right:0;left:0;padding:10px 25px 5px;background:#f3f3f3;z-index:30;box-sizing:border-box;border-top:1px solid #eee}.ie8 .theme-overlay .theme-actions{border:1px solid #eee}.theme-overlay .theme-actions a{margin-left:5px;margin-bottom:5px}.broken-themes a.delete-theme,.theme-overlay .theme-actions .delete-theme{color:#a00;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.theme-overlay .theme-actions .delete-theme{position:absolute;left:10px;bottom:5px}.broken-themes a.delete-theme:focus,.broken-themes a.delete-theme:hover,.theme-overlay .theme-actions .delete-theme:focus,.theme-overlay .theme-actions .delete-theme:hover{background:#d54e21;color:#fff;border-color:#d54e21}.theme-overlay .theme-actions .inactive-theme,.theme-overlay.active .theme-actions .active-theme{display:block}.theme-overlay .theme-screenshots{float:right;margin:0 0 0 30px;width:55%;max-width:1200px;text-align:center}.theme-overlay .screenshot{border:1px solid #fff;box-sizing:border-box;overflow:hidden;position:relative;box-shadow:0 0 0 1px rgba(0,0,0,.2)}.theme-overlay .screenshot:after{content:"";display:block;padding-top:75%}.theme-overlay .screenshot img{height:auto;position:absolute;right:0;top:0;width:100%}.theme-overlay.small-screenshot .theme-screenshots{position:absolute;width:302px}.theme-overlay.small-screenshot .theme-info{margin-right:350px;width:auto}.theme-overlay .screenshot.thumb{background:#ccc;border:1px solid #eee;float:none;display:inline-block;margin:10px 5px 0;width:140px;height:80px;cursor:pointer}.theme-overlay .screenshot.thumb:after{content:"";display:block;padding-top:100%}.theme-overlay .screenshot.thumb img{cursor:pointer;position:absolute;right:0;top:0;width:100%;height:auto}.theme-overlay .screenshot.selected{background:0 0;border:2px solid #00a0d2}.theme-overlay .screenshot.selected img{opacity:.8}.theme-browser .theme .theme-screenshot.blank,.theme-overlay .screenshot.blank{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAALElEQVQYGWO8d+/efwYkoKioiMRjYGBC4WHhUK6A8T8QIJt8//59ZC493AAAQssKpBK4F5AAAAAASUVORK5CYII=)}.theme-overlay .theme-info{width:40%;float:right}.theme-overlay .current-label{background:#32373c;color:#fff;font-size:11px;display:inline-block;padding:2px 8px;border-radius:2px;margin:0 0 -10px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.theme-overlay .theme-name{color:#23282d;font-size:32px;font-weight:100;margin:10px 0 0;line-height:1.3;word-wrap:break-word;overflow-wrap:break-word}.theme-overlay .theme-version{color:#72777c;font-size:13px;font-weight:400;float:none;display:inline-block;margin-right:10px}.theme-overlay .theme-author{margin:15px 0 25px;color:#72777c;font-size:16px;font-weight:400;line-height:inherit}.theme-overlay .theme-author a{text-decoration:none}.theme-overlay .theme-description{color:#555;font-size:15px;font-weight:400;line-height:1.5;margin:30px 0 0}.theme-overlay .theme-tags{border-top:3px solid #eee;color:#82878c;font-size:13px;font-weight:400;margin:30px 0 0;padding-top:20px}.theme-overlay .theme-tags span{color:#444;font-weight:600;margin-left:5px}.theme-overlay .parent-theme{background:#f7fcfe;border:1px solid #eee;border-right:4px solid #00a0d2;font-size:14px;font-weight:400;margin-top:30px;padding:10px 20px 10px 10px}.theme-overlay .parent-theme strong{font-weight:700}.single-theme .theme,.single-theme .theme-overlay .theme-backdrop,.single-theme .theme-overlay .theme-header{display:none}.single-theme .theme-overlay .theme-wrap{clear:both;min-height:330px;position:relative;right:auto;left:auto;top:auto;bottom:auto;z-index:10}.single-theme .theme-overlay .theme-about{padding:30px 30px 70px;position:static}.single-theme .theme-overlay .theme-actions{position:absolute}@media only screen and (min-width:2000px){#wpwrap .theme-browser .theme{width:17.6%;margin:0 0 3% 3%}#wpwrap .theme-browser .theme:nth-child(3n),#wpwrap .theme-browser .theme:nth-child(4n){margin-left:3%}#wpwrap .theme-browser .theme:nth-child(5n){margin-left:0}}@media only screen and (min-width:1680px){.theme-overlay .theme-wrap{width:1450px;margin:0 auto}}@media only screen and (min-width:1640px){.theme-browser .theme{width:22.7%;margin:0 0 3% 3%}.theme-browser .theme .theme-screenshot:after{padding-top:75%}.theme-browser .theme:nth-child(3n){margin-left:3%}.theme-browser .theme:nth-child(4n){margin-left:0}}@media only screen and (max-width:1120px){.theme-browser .theme{width:47.5%;margin-left:0}.theme-browser .theme:nth-child(even){margin-left:0}.theme-browser .theme:nth-child(odd){margin-left:5%}}@media only screen and (max-width:900px){.theme-overlay .theme-wrap{right:65px}}@media only screen and (max-width:780px){.theme-overlay .theme-wrap,body.folded .theme-overlay .theme-wrap{top:0;left:0;bottom:0;right:0;padding:70px 20px 20px;border:none;z-index:100000;position:fixed}.theme-browser .theme.active .theme-name span{display:none}.theme-overlay .theme-screenshots{width:40%}.theme-overlay .theme-info{width:50%}.single-theme .theme-wrap{padding:10px}.theme-browser .theme .theme-actions{padding:5px 10px 4px}.theme-overlay.small-screenshot .theme-screenshots{position:static;float:none;max-width:302px}.theme-overlay.small-screenshot .theme-info{margin-right:0;width:auto}.theme:focus .more-details,.theme:hover .more-details,.theme:not(.active):focus .theme-actions,.theme:not(.active):hover .theme-actions{display:none}.theme-browser.rendered .theme:focus .theme-screenshot img,.theme-browser.rendered .theme:hover .theme-screenshot img{opacity:1}}@media only screen and (max-width:480px){.theme-browser .theme{width:100%;margin-left:0}.theme-browser .theme:nth-child(2n),.theme-browser .theme:nth-child(3n){margin-left:0}}@media only screen and (max-width:650px){.theme-overlay .theme-description{margin-right:0}.theme-overlay .theme-actions .delete-theme{position:relative;left:auto;bottom:auto}.theme-overlay .theme-actions .inactive-theme{display:inline}.theme-overlay .theme-screenshots{width:100%;float:none}.theme-overlay .theme-info{width:100%}.theme-overlay .theme-author{margin:5px 0 15px}.theme-overlay .current-label{margin-top:10px;font-size:13px}.themes-php .wp-filter-search{float:none;clear:both;right:0;left:0;margin:-5px 0 20px;width:100%;max-width:280px}.theme-browser .theme.add-new-theme span:after{font:400 60px/90px dashicons;width:80px;height:80px;top:30%;right:50%;text-indent:0;margin-right:-40px}.single-theme .theme-wrap{margin:0 -10px 0 -12px;padding:10px}.single-theme .theme-overlay .theme-about{padding:10px;overflow:visible}.single-theme .current-label{display:none}.single-theme .theme-overlay .theme-actions{position:static}}.broken-themes{clear:both}.broken-themes table{text-align:right;width:50%;border-spacing:3px;padding:3px}.theme-browser .theme .theme-installed{background:#0073aa}.theme-browser .theme .notice-success p:before{color:#79ba49;content:"\f147";display:inline-block;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.theme-install.updated-message:before{content:''}.theme-install-php .wp-filter{padding-right:20px}.theme-install-php a.browse-themes,.theme-install-php a.upload{cursor:pointer}.plugin-install-tab-upload .upload-view-toggle .upload,.upload-view-toggle .browse{display:none}.plugin-install-tab-upload .upload-view-toggle .browse{display:inline}.upload-plugin,.upload-theme{box-sizing:border-box;display:none;margin:0;padding:50px 0;width:100%;overflow:hidden;position:relative;top:10px}.upload-plugin-wrap{display:none}.plugin-install-tab-upload .upload-plugin,.show-upload-view .upload-plugin,.show-upload-view .upload-plugin-wrap,.show-upload-view .upload-theme{display:block}.upload-plugin .wp-upload-form,.upload-theme .wp-upload-form{background:#fafafa;border:1px solid #e5e5e5;padding:30px;margin:30px auto;max-width:380px}.upload-plugin .install-help,.upload-theme .install-help{color:#555d66;font-size:18px;font-style:normal;margin:0;padding:0;text-align:center}p.no-themes,p.no-themes-local{clear:both;color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0;text-align:center;display:none}.no-results p.no-themes{display:block}.theme-install-php .add-new-theme{display:none!important}@media only screen and (max-width:1120px){.upload-theme .wp-upload-form{margin:20px 0;max-width:100%}.upload-theme .install-help{font-size:15px;padding:20px 0 0;text-align:right}}.theme-details .theme-rating{line-height:23px}.theme-details .star-rating{display:inline}.theme-details .no-rating,.theme-details .num-ratings{font-size:11px;color:#72777c}.theme-details .no-rating{display:block;line-height:20px}.appearance_page_custom-header #headimg{border:1px solid #ddd;overflow:hidden;width:100%}.appearance_page_custom-header #upload-form p label{font-size:12px}.appearance_page_custom-header .available-headers .default-header{float:right;margin:0 0 20px 20px}.appearance_page_custom-header .random-header{clear:both;margin:0 0 20px 20px;vertical-align:middle}.appearance_page_custom-header .available-headers label input,.appearance_page_custom-header .random-header label input{margin-left:10px}.appearance_page_custom-header .available-headers label img{vertical-align:middle}div#custom-background-image{min-height:100px;border:1px solid #ddd}div#custom-background-image img{max-width:400px;max-height:300px}.background-position-control input[type=radio]:checked~.button{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);z-index:1}.background-position-control input[type=radio]:focus~.button{border-color:#5b9dd9;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5),0 0 3px rgba(0,115,170,.8);color:#23282d}.background-position-control .background-position-center-icon,.background-position-control .background-position-center-icon:before{display:inline-block;line-height:1;text-align:center;transition:background-color .1s ease-in 0}.background-position-control .background-position-center-icon{height:20px;margin-top:13px;vertical-align:top;width:20px}.background-position-control .background-position-center-icon:before{background-color:#555;border-radius:50%;content:"";height:12px;width:12px}.background-position-control .button:hover .background-position-center-icon:before,.background-position-control input[type=radio]:focus~.button .background-position-center-icon:before{background-color:#23282d}.background-position-control .button-group{display:block}.background-position-control .button-group .button{border-radius:0;box-shadow:none;height:40px!important;line-height:37px!important;margin:0 0 0 -1px!important;padding:0 10px 1px!important;position:relative}.wp-full-overlay,.wp-full-overlay-sidebar{position:fixed;top:0;height:100%;bottom:0;right:0}.background-position-control .button-group .button:active,.background-position-control .button-group .button:focus,.background-position-control .button-group .button:hover{z-index:1}.background-position-control .button-group:last-child .button{box-shadow:0 1px 0 #ccc}.background-position-control .button-group>label{margin:0!important}.background-position-control .button-group:first-child>label:first-child .button{border-radius:0 3px 0 0}.background-position-control .button-group:first-child>label:first-child .dashicons{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.background-position-control .button-group:first-child>label:last-child .button{border-radius:3px 0 0}.background-position-control .button-group:first-child>label:last-child .dashicons{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.background-position-control .button-group:last-child>label:first-child .button{border-radius:0 0 3px}.background-position-control .button-group:last-child>label:first-child .dashicons{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.background-position-control .button-group:last-child>label:last-child .button{border-radius:0 0 0 3px}.background-position-control .button-group:last-child>label:last-child .dashicons{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.background-position-control .button-group .dashicons{margin-top:9px}.background-position-control .button-group+.button-group{margin-top:-1px}body.full-overlay-active{overflow:hidden;visibility:hidden}.wp-full-overlay{z-index:500000;overflow:visible;left:0;min-width:0}.wp-full-overlay-sidebar{box-sizing:border-box;min-width:300px;max-width:600px;width:18%;padding:0;margin:0;z-index:10;background:#eee;border-left:none}.wp-full-overlay.collapsed,.wp-full-overlay.expanded .wp-full-overlay-sidebar{margin-right:0!important}.wp-full-overlay.expanded{margin-right:300px}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{overflow:visible;margin-right:-300px}@media screen and (min-width:1667px){.wp-full-overlay.expanded{margin-right:18%}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-18%}}@media screen and (min-width:3333px){.wp-full-overlay.expanded{margin-right:600px}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-right:-600px}}.wp-full-overlay-sidebar:after{content:"";display:block;position:absolute;top:0;bottom:0;left:0;width:3px;z-index:1000}.wp-full-overlay-main{position:absolute;right:0;left:0;top:0;bottom:0;height:100%}.wp-full-overlay-sidebar .wp-full-overlay-header{position:absolute;right:0;left:0;height:45px;padding:0 15px;line-height:45px;z-index:10;margin:0;border-top:none;box-shadow:none}.wp-full-overlay-sidebar .wp-full-overlay-header a.back{margin-top:9px}.wp-full-overlay-sidebar .wp-full-overlay-footer{bottom:0;border-bottom:none;border-top:none;box-shadow:none}.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{position:absolute;top:45px;bottom:45px;right:0;left:0;overflow:auto}.theme-install-overlay .wp-full-overlay-sidebar .wp-full-overlay-header{padding:0}.theme-install-overlay .close-full-overlay,.theme-install-overlay .next-theme,.theme-install-overlay .previous-theme{display:block;position:relative;float:right;width:45px;height:45px;padding-left:2px;background:#eee;border-left:1px solid #ddd;color:#444;cursor:pointer;text-decoration:none;transition:color .1s ease-in-out,background .1s ease-in-out}.theme-install-overlay .close-full-overlay:focus,.theme-install-overlay .close-full-overlay:hover,.theme-install-overlay .next-theme:focus,.theme-install-overlay .next-theme:hover,.theme-install-overlay .previous-theme:focus,.theme-install-overlay .previous-theme:hover{background:#ddd;border-color:#ccc;color:#000;outline:0;box-shadow:none}.theme-install-overlay .close-full-overlay:before{font:400 22px/1 dashicons;content:"\f335";position:relative;top:7px;right:13px}.theme-install-overlay .previous-theme:before{font:400 20px/1 dashicons;content:"\f345";position:relative;top:6px;right:14px}.theme-install-overlay .next-theme:before{font:400 20px/1 dashicons;content:"\f341";position:relative;top:6px;right:13px}.theme-install-overlay .next-theme.disabled,.theme-install-overlay .next-theme.disabled:focus,.theme-install-overlay .next-theme.disabled:hover,.theme-install-overlay .previous-theme.disabled,.theme-install-overlay .previous-theme.disabled:focus,.theme-install-overlay .previous-theme.disabled:hover{color:#b4b9be;background:#eee;cursor:default;pointer-events:none}.theme-install-overlay .close-full-overlay,.theme-install-overlay .next-theme,.theme-install-overlay .previous-theme{border-right:0;border-top:0;border-bottom:0}.theme-install-overlay .close-full-overlay:before,.theme-install-overlay .next-theme:before,.theme-install-overlay .previous-theme:before{top:2px;right:0}.wp-core-ui .wp-full-overlay .collapse-sidebar{position:fixed;bottom:0;right:0;padding:9px 10px 9px 0;height:45px;color:#656a6f;outline:0;line-height:1;background-color:transparent!important;border:none!important;box-shadow:none!important;border-radius:0!important}.wp-core-ui .wp-full-overlay .collapse-sidebar:focus,.wp-core-ui .wp-full-overlay .collapse-sidebar:hover{color:#0073aa}.wp-full-overlay .collapse-sidebar-arrow,.wp-full-overlay .collapse-sidebar-label{display:inline-block;vertical-align:middle;line-height:20px}.wp-full-overlay .collapse-sidebar-arrow{width:20px;height:20px;margin:0 2px;border-radius:50%;overflow:hidden}.wp-full-overlay .collapse-sidebar:focus .collapse-sidebar-arrow,.wp-full-overlay .collapse-sidebar:hover .collapse-sidebar-arrow{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.wp-full-overlay .collapse-sidebar-label{margin-right:3px}.wp-full-overlay.collapsed .collapse-sidebar-label{display:none}.wp-full-overlay .collapse-sidebar-arrow:before{display:block;content:"\f148";background:#eee;font:400 20px/1 dashicons;speak:none;padding:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-core-ui .wp-full-overlay.collapsed .collapse-sidebar{padding:9px 10px}.rtl .wp-full-overlay .collapse-sidebar-arrow:before,.wp-full-overlay.collapsed .collapse-sidebar-arrow:before{-webkit-transform:rotate(180.001deg);transform:rotate(180.001deg)}.rtl .wp-full-overlay.collapsed .collapse-sidebar-arrow:before{-webkit-transform:none;transform:none}.wp-full-overlay,.wp-full-overlay .collapse-sidebar,.wp-full-overlay-main,.wp-full-overlay-sidebar{transition-property:right,left,top,bottom,width,margin;transition-duration:.2s}.wp-full-overlay{background:#191e23}.wp-full-overlay-main{background-color:#f1f1f1}.expanded .wp-full-overlay-footer{position:fixed;bottom:0;right:0;min-width:299px;max-width:599px;width:18%;width:calc(18% - 1px);height:45px;border-top:1px solid #ddd;background:#eee}.wp-full-overlay-footer .devices-wrapper{float:left}.wp-full-overlay-footer .devices{position:relative;background:#eee;box-shadow:20px 0 10px -5px #eee}.wp-full-overlay-footer .devices button{cursor:pointer;background:0 0;border:none;height:45px;padding:0 3px;margin:0 -4px 0 0;box-shadow:none;border-top:1px solid transparent;border-bottom:4px solid transparent;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out}.wp-full-overlay-footer .devices button:focus{box-shadow:none;outline:0}.wp-full-overlay-footer .devices button:before{display:inline-block;-webkit-font-smoothing:antialiased;font:400 20px/30px dashicons;vertical-align:top;margin:3px 0;padding:4px 8px;color:#656a6f}#customize-container,.customize-support .hide-if-customize,.customize-support .wp-core-ui .hide-if-customize,.customize-support.wp-core-ui .hide-if-customize,.no-customize-support .hide-if-no-customize,.no-customize-support .wp-core-ui .hide-if-no-customize,.no-customize-support.wp-core-ui .hide-if-no-customize,.theme-install-overlay{display:none}.wp-full-overlay-footer .devices button.active{border-bottom-color:#191e23}.wp-full-overlay-footer .devices button:focus,.wp-full-overlay-footer .devices button:hover{background-color:#fff}.wp-full-overlay-footer .devices button.active:hover,.wp-full-overlay-footer .devices button:focus{border-bottom-color:#0073aa}.wp-full-overlay-footer .devices button.active:before{color:#191e23}.wp-full-overlay-footer .devices button:focus:before,.wp-full-overlay-footer .devices button:hover:before{color:#0073aa}.wp-full-overlay-footer .devices .preview-desktop:before{content:"\f472"}.wp-full-overlay-footer .devices .preview-tablet:before{content:"\f471"}.wp-full-overlay-footer .devices .preview-mobile:before{content:"\f470"}@media screen and (max-width:1024px){.wp-full-overlay-footer .devices{display:none}}.collapsed .wp-full-overlay-footer .devices button:before{display:none}.preview-mobile .wp-full-overlay-main{margin:auto -160px auto 0;width:320px;height:480px;max-height:100%;max-width:100%;right:50%}.preview-tablet .wp-full-overlay-main{margin:auto -360px auto 0;width:720px;height:1080px;max-height:100%;max-width:100%;right:50%}#customize-container,#customize-controls .notice.notification-overlay{background:#eee;z-index:500000;position:fixed;overflow:visible;top:0;bottom:0;right:0;left:0;height:100%}#customize-container,.theme-install-overlay{visibility:visible}.customize-loading #customize-container iframe{opacity:0}#customize-container iframe,.theme-install-overlay iframe{height:100%;width:100%;z-index:20;transition:opacity .3s}#customize-controls{margin-top:0}.theme-install-overlay.single-theme{display:block}.install-theme-info{display:none;padding:10px 20px 60px}.single-theme .install-theme-info{padding-top:15px}.theme-install-overlay .install-theme-info{display:block}.install-theme-info .theme-install{float:left;margin-top:18px}.install-theme-info .theme-name{font-size:16px;line-height:24px;margin-bottom:0;margin-top:0}.install-theme-info .theme-screenshot{margin:15px 0;width:258px;border:1px solid #ccc}.install-theme-info .theme-details{overflow:hidden}.theme-details .theme-version{margin:15px 0}.theme-details .theme-description{float:right;color:#72777c;line-height:20px;max-width:100%}.theme-install-overlay .wp-full-overlay-header .button{float:left;margin:8px 0 0 10px;line-height:26px}.theme-install-overlay .wp-full-overlay-sidebar{background:#eee;border-left:1px solid #ddd}.theme-install-overlay .wp-full-overlay-sidebar-content{background:#fff;border-top:1px solid #ddd;border-bottom:1px solid #ddd}.theme-install-overlay .wp-full-overlay-main{position:absolute;z-index:0;background-color:#f1f1f1}.customize-loading #customize-container{background-color:#f1f1f1}#customize-controls .notice.notification-overlay.notification-loading:before,#customize-preview.wp-full-overlay-main:before,.customize-loading #customize-container:before,.theme-install-overlay .wp-full-overlay-main:before{content:"";display:block;width:20px;height:20px;position:absolute;right:50%;top:50%;z-index:-1;margin:-10px -10px 0 0;-webkit-transform:translateZ(0);transform:translateZ(0);background:url(../images/spinner.gif) center center no-repeat;background-size:20px 20px}#customize-preview.wp-full-overlay-main.iframe-ready:before,.theme-install-overlay.iframe-ready .wp-full-overlay-main:before{background-image:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-full-overlay .collapse-sidebar-arrow{background-image:url(../images/arrows-2x.png);background-size:15px 123px}#customize-controls .notice.notification-overlay.notification-loading:before,#customize-preview.wp-full-overlay-main:before,.customize-loading #customize-container:before,.theme-install-overlay .wp-full-overlay-main:before{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){.available-theme .action-links .delete-theme{float:none;margin:0;padding:0;clear:both}.available-theme .action-links .delete-theme a{padding:0}.broken-themes table{width:100%}.theme-install-overlay .wp-full-overlay-header .theme-install{margin-top:6px;line-height:normal}.theme-browser .theme .theme-actions .button{margin-bottom:0}.theme-browser .theme .theme-actions,.theme-browser .theme.active .theme-actions{padding-top:8px;padding-bottom:8px}}@media aural{.theme .notice:before,.theme-info .updated-message:before,.theme-info .updating-message:before,.theme-install.updating-message:before{speak:none}} \ No newline at end of file diff --git a/backend/wp-admin/css/themes.css b/backend/wp-admin/css/themes.css new file mode 100644 index 0000000..eece216 --- /dev/null +++ b/backend/wp-admin/css/themes.css @@ -0,0 +1,1929 @@ +/*------------------------------------------------------------------------------ + 16.0 - Themes +------------------------------------------------------------------------------*/ + + +/*------------------------------------------------------------------------------ + 16.1 - Manage Themes +------------------------------------------------------------------------------*/ + +body.js .theme-browser.search-loading { + display: none; +} + +.theme-browser .themes { + clear: both; +} + +.themes-php:not(.network-admin) .wrap h1 { + margin-bottom: 15px; +} + +.themes-php .wrap h1 .button { + margin-left: 20px; +} + +/* Search form */ +.themes-php .search-form { + display: inline; +} + +.themes-php .wp-filter-search { + position: relative; + top: -2px; + left: 20px; + margin: 0; + width: 280px; + font-size: 16px; + font-weight: 300; + line-height: 1.5; +} + +/* Position admin messages */ +.theme .notice, +.theme .notice.is-dismissible { + left: 0; + margin: 0; + position: absolute; + right: 0; + top: 0; +} + +/** + * Main theme element + * (has flexible margins) + */ +.theme-browser .theme { + cursor: pointer; + float: left; + margin: 0 4% 4% 0; + position: relative; + width: 30.6%; + border: 1px solid #ddd; + box-shadow: 0 1px 1px -1px rgba(0,0,0,0.1); + box-sizing: border-box; +} + +.ie8 .theme-browser .theme { + width: 30%; + margin: 0 3% 4% 0; +} + +.theme-browser .theme:nth-child(3n) { + margin-right: 0; +} + +.theme-browser .theme:hover, +.theme-browser .theme:focus { + cursor: pointer; +} + +.theme-browser .theme .theme-name { + font-size: 15px; + font-weight: 600; + height: 18px; + margin: 0; + padding: 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + background: #fff; + background: rgba(255,255,255,0.65); +} + +/* Activate and Customize buttons, shown on hover and focus */ +.theme-browser .theme .theme-actions { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + opacity: 0; + transition: opacity 0.1s ease-in-out; + height: auto; + background: rgba(244, 244, 244, 0.7); + border-left: 1px solid rgba(0,0,0,0.05); +} + +.theme-browser .theme:hover .theme-actions, +.theme-browser .theme.focus .theme-actions, +.theme-browser .theme:focus .theme-actions { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + opacity: 1; +} + +.theme-browser .theme .theme-actions .button-primary { + margin-right: 3px; +} + +.theme-browser .theme .theme-actions .button { + float: none; + margin-left: 3px; +} + +/** + * Theme Screenshot + * + * Has a fixed aspect ratio of 1.5 to 1 regardless of screenshot size + * It is also responsive. + */ +.theme-browser .theme .theme-screenshot { + display: block; + overflow: hidden; + position: relative; + -webkit-backface-visibility: hidden; /* Prevents flicker of the screenshot on hover. */ + transition: opacity 0.2s ease-in-out; +} + +.theme-browser .theme .theme-screenshot:after { + content: ""; + display: block; + padding-top: 66.66666%; /* using a 3/2 aspect ratio */ +} + +.theme-browser .theme .theme-screenshot img { + height: auto; + position: absolute; + left: 0; + top: 0; + width: 100%; + transition: opacity 0.2s ease-in-out; +} + +.theme-browser .theme:hover .theme-screenshot, +.theme-browser .theme:focus .theme-screenshot { + background: #fff; +} + +.theme-browser.rendered .theme:hover .theme-screenshot img, +.theme-browser.rendered .theme:focus .theme-screenshot img { + opacity: 0.4; +} + +.theme-browser .theme .more-details { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + opacity: 0; + position: absolute; + top: 35%; + right: 20%; + left: 20%; + background: #23282d; + background: rgba(0,0,0,0.7); + color: #fff; + font-size: 15px; + text-shadow: 0 1px 0 rgba(0,0,0,0.6); + -webkit-font-smoothing: antialiased; + font-weight: 600; + padding: 15px 12px; + text-align: center; + border-radius: 3px; + transition: opacity 0.1s ease-in-out; +} + +.theme-browser .theme:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba( 30, 140, 190, 0.8 ); +} + +.theme-browser .theme:focus .more-details { + opacity: 1; +} + +/* Current theme needs to have its action always on view */ +.theme-browser .theme.active:focus .theme-actions { + display: block; +} + +.theme-browser.rendered .theme:hover .more-details, +.theme-browser.rendered .theme:focus .more-details { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + opacity: 1; +} + +/** + * The currently active theme + */ +.theme-browser .theme.active .theme-name { + background: #23282d; + color: #fff; + padding-right: 110px; + font-weight: 300; + box-shadow: inset 0 1px 1px rgba(0,0,0,0.5); +} + +.theme-browser .customize-control .theme.active .theme-name { + padding-right: 15px; +} + +.theme-browser .theme.active .theme-name span { + font-weight: 600; +} + +.theme-browser .theme.active .theme-actions { + background: rgba(49,49,49,0.7); + border-left: none; + opacity: 1; +} + +.theme-id-container { + position: relative; +} + +.theme-browser .theme.active .theme-actions, +.theme-browser .theme .theme-actions { + position: absolute; + top: 50%; + -webkit-transform: translateY(-50%); + transform: translateY(-50%); + right: 0; + padding: 10px 15px; + box-shadow: inset 0 1px 0 rgba(0,0,0,0.1); +} + +.theme-browser .theme.active .theme-actions .button-primary { + margin-right: 0; +} + +.theme-browser .theme .theme-author { + background: #23282d; + color: #eee; + display: none; + font-size: 14px; + margin: 0 10px; + padding: 5px 10px; + position: absolute; + bottom: 56px; +} + +.theme-browser .theme.display-author .theme-author { + display: block; +} + +.theme-browser .theme.display-author .theme-author a { + color: inherit; + text-decoration: none; +} + +/** + * Add new theme + */ +.theme-browser .theme.add-new-theme { + border: none; + box-shadow: none; +} + +.theme-browser .theme.add-new-theme a { + text-decoration: none; + display: block; + position: relative; + z-index: 1; +} + +.theme-browser .theme.add-new-theme a:after { + display: block; + content: ""; + background: transparent; + background: rgba(0, 0, 0, 0); + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + padding: 0; + text-shadow: none; + border: 5px dashed #d5d2ca; + border: 5px dashed rgba(0, 0, 0, 0.1); + box-sizing: border-box; +} + +.theme-browser .theme.add-new-theme span:after { + background: #e5e5e5; + background: rgba(153, 153, 153, 0.1); + border-radius: 50%; + display: inline-block; + content: "\f132"; + -webkit-font-smoothing: antialiased; + font: normal 74px/115px dashicons; + width: 100px; + height: 100px; + vertical-align: middle; + text-align: center; + color: rgb(153, 153, 153); + position: absolute; + top: 30%; + left: 50%; + margin-left: -50px; + text-indent: -4px; + padding: 0; + text-shadow: none; + z-index:4; +} + +.rtl .theme-browser .theme.add-new-theme span:after { + text-indent: 4px; +} + +.theme-browser .theme.add-new-theme a:hover .theme-screenshot, +.theme-browser .theme.add-new-theme a:focus .theme-screenshot { + background: none; +} + +.theme-browser .theme.add-new-theme a:hover span:after, +.theme-browser .theme.add-new-theme a:focus span:after { + background: #fff; + color: #0073aa; +} + +.theme-browser .theme.add-new-theme a:hover:after, +.theme-browser .theme.add-new-theme a:focus:after { + border-color: transparent; + color: #fff; + background: #0073aa; + content: ""; +} + +.theme-browser .theme.add-new-theme .theme-name { + background: none; + text-align: center; + box-shadow: none; + font-weight: 400; + position: relative; + top: 0; + margin-top: -18px; + padding-top: 0; + padding-bottom: 48px; +} + +.theme-browser .theme.add-new-theme a:hover .theme-name, +.theme-browser .theme.add-new-theme a:focus .theme-name { + color: #fff; + z-index: 2; +} + +/** + * Theme Overlay + * Shown when clicking a theme + */ +.theme-overlay .theme-backdrop { + position: absolute; + left: -20px; + right: 0; + top: 0; + bottom: 0; + background: #f1f1f1; + background: rgba( 238, 238, 238, 0.9 ); + z-index: 10000; /* Over WP Pointers. */ +} + +.theme-overlay .theme-header { + position: absolute; + top: 0; + left: 0; + right: 0; + height: 48px; + border-bottom: 1px solid #ddd; +} + +.theme-overlay .theme-header button { + padding: 0; +} + +.theme-overlay .theme-header .close { + cursor: pointer; + height: 48px; + width: 50px; + text-align: center; + float: right; + border: 0; + border-left: 1px solid #ddd; + background-color: transparent; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-overlay .theme-header .close:before { + font: normal 22px/50px dashicons !important; + color: #72777c; + display: inline-block; + content: "\f335"; + font-weight: 300; +} + +/* Left and right navigation */ +.theme-overlay .theme-header .right, +.theme-overlay .theme-header .left { + cursor: pointer; + color: #72777c; + background-color: transparent; + height: 48px; + width: 54px; + float: left; + text-align: center; + border: 0; + border-right: 1px solid #ddd; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-overlay .theme-header .close:focus, +.theme-overlay .theme-header .close:hover, +.theme-overlay .theme-header .right:focus, +.theme-overlay .theme-header .right:hover, +.theme-overlay .theme-header .left:focus, +.theme-overlay .theme-header .left:hover { + background: #ddd; + border-color: #ccc; + color: #000; +} + +.theme-overlay .theme-header .close:focus:before, +.theme-overlay .theme-header .close:hover:before { + color: #000; +} + +.theme-overlay .theme-header .close:focus, +.theme-overlay .theme-header .right:focus, +.theme-overlay .theme-header .left:focus { + box-shadow: none; + outline: none; +} + +.theme-overlay .theme-header .left.disabled, +.theme-overlay .theme-header .right.disabled, +.theme-overlay .theme-header .left.disabled:hover, +.theme-overlay .theme-header .right.disabled:hover { + color: #ccc; + background: inherit; + cursor: inherit; +} + +.theme-overlay .theme-header .right:before, +.theme-overlay .theme-header .left:before { + font: normal 20px/50px dashicons !important; + display: inline; + font-weight: 300; +} + +.theme-overlay .theme-header .left:before { + content: "\f341"; +} + +.theme-overlay .theme-header .right:before { + content: "\f345"; +} + +.theme-overlay .theme-wrap { + clear: both; + position: fixed; + top: 9%; + left: 190px; + right: 30px; + bottom: 3%; + background: #fff; + box-shadow: 0 1px 20px 5px rgba(0, 0, 0, 0.1); + z-index: 10000; /* Over WP Pointers. */ + box-sizing: border-box; + -webkit-overflow-scrolling: touch; +} + +body.folded .theme-browser ~ .theme-overlay .theme-wrap { + left: 70px; +} + +.theme-overlay .theme-about { + position: absolute; + top: 49px; + bottom: 57px; + left: 0; + right: 0; + overflow: auto; + padding: 2% 4%; +} + +.theme-overlay .theme-actions { + position: absolute; + text-align: center; + bottom: 0; + left: 0; + right: 0; + padding: 10px 25px 5px; + background: #f3f3f3; + z-index: 30; + box-sizing: border-box; + border-top: 1px solid #eee; +} + +.ie8 .theme-overlay .theme-actions { + border: 1px solid #eee; +} + +.theme-overlay .theme-actions a { + margin-right: 5px; + margin-bottom: 5px; +} + +/* Hide-if-customize for items we can't add classes to */ +.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-header"], +.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-background"] { + display: none; +} + +.broken-themes a.delete-theme, +.theme-overlay .theme-actions .delete-theme { + color: #a00; + text-decoration: none; + border-color: transparent; + box-shadow: none; + background: transparent; +} + +.theme-overlay .theme-actions .delete-theme { + position: absolute; + right: 10px; + bottom: 5px; +} + +.broken-themes a.delete-theme:hover, +.broken-themes a.delete-theme:focus, +.theme-overlay .theme-actions .delete-theme:hover, +.theme-overlay .theme-actions .delete-theme:focus { + background: #d54e21; + color: #fff; + border-color: #d54e21; +} + +.theme-overlay .theme-actions .active-theme, +.theme-overlay.active .theme-actions .inactive-theme { + display: none; +} + +.theme-overlay .theme-actions .inactive-theme, +.theme-overlay.active .theme-actions .active-theme { + display: block; +} + +/** + * Theme Screenshots gallery + */ +.theme-overlay .theme-screenshots { + float: left; + margin: 0 30px 0 0; + width: 55%; + max-width: 1200px; /* Recommended theme screenshot width, set here to avoid stretching */ + text-align: center; +} + +/* First screenshot, shown big */ +.theme-overlay .screenshot { + border: 1px solid #fff; + box-sizing: border-box; + overflow: hidden; + position: relative; + box-shadow: 0 0 0 1px rgba(0,0,0,0.2); +} + +.theme-overlay .screenshot:after { + content: ""; + display: block; + padding-top: 75%; /* using a 4/3 aspect ratio */ +} + +.theme-overlay .screenshot img { + height: auto; + position: absolute; + left: 0; + top: 0; + width: 100%; +} +/* Handles old 300px screenshots */ +.theme-overlay.small-screenshot .theme-screenshots { + position: absolute; + width: 302px; +} +.theme-overlay.small-screenshot .theme-info { + margin-left: 350px; + width: auto; +} + +/* Other screenshots, shown small and square */ +.theme-overlay .screenshot.thumb { + background: #ccc; + border: 1px solid #eee; + float: none; + display: inline-block; + margin: 10px 5px 0; + width: 140px; + height: 80px; + cursor: pointer; +} + +.theme-overlay .screenshot.thumb:after { + content: ""; + display: block; + padding-top: 100%; /* using a 1/1 aspect ratio */ +} + +.theme-overlay .screenshot.thumb img { + cursor: pointer; + height: auto; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: auto; +} + +.theme-overlay .screenshot.selected { + background: transparent; + border: 2px solid #00a0d2; +} + +.theme-overlay .screenshot.selected img { + opacity: 0.8; +} + +/* No screenshot placeholder */ +.theme-browser .theme .theme-screenshot.blank, +.theme-overlay .screenshot.blank { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAALElEQVQYGWO8d+/efwYkoKioiMRjYGBC4WHhUK6A8T8QIJt8//59ZC493AAAQssKpBK4F5AAAAAASUVORK5CYII=); +} + +/** + * Theme heading information + */ +.theme-overlay .theme-info { + width: 40%; + float: left; +} + +.theme-overlay .current-label { + background: #32373c; + color: #fff; + font-size: 11px; + display: inline-block; + padding: 2px 8px; + border-radius: 2px; + margin: 0 0 -10px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.theme-overlay .theme-name { + color: #23282d; + font-size: 32px; + font-weight: 100; + margin: 10px 0 0; + line-height: 1.3; + word-wrap: break-word; + overflow-wrap: break-word; +} + +.theme-overlay .theme-version { + color: #72777c; + font-size: 13px; + font-weight: 400; + float: none; + display: inline-block; + margin-left: 10px; +} + +.theme-overlay .theme-author { + margin: 15px 0 25px; + color: #72777c; + font-size: 16px; + font-weight: 400; + line-height: inherit; +} + +.theme-overlay .theme-author a { + text-decoration: none; +} + +.theme-overlay .theme-description { + color: #555; + font-size: 15px; + font-weight: 400; + line-height: 1.5; + margin: 30px 0 0 0; +} + +.theme-overlay .theme-tags { + border-top: 3px solid #eee; + color: #82878c; + font-size: 13px; + font-weight: 400; + margin: 30px 0 0 0; + padding-top: 20px; +} + +.theme-overlay .theme-tags span { + color: #444; + font-weight: 600; + margin-right: 5px; +} + +.theme-overlay .parent-theme { + background: #f7fcfe; + border: 1px solid #eee; + border-left: 4px solid #00a0d2; + font-size: 14px; + font-weight: 400; + margin-top: 30px; + padding: 10px 10px 10px 20px; +} + +.theme-overlay .parent-theme strong { + font-weight: 700; +} + +/** + * Single Theme Mode + * Displays detailed view inline when a user has no switch capabilities + */ +.single-theme .theme-overlay .theme-backdrop, +.single-theme .theme-overlay .theme-header, +.single-theme .theme { + display: none; +} + +.single-theme .theme-overlay .theme-wrap { + clear: both; + min-height: 330px; + position: relative; + left: auto; + right: auto; + top: auto; + bottom: auto; + z-index: 10; +} + +.single-theme .theme-overlay .theme-about { + padding: 30px 30px 70px; + position: static; +} + +.single-theme .theme-overlay .theme-actions { + position: absolute; +} + +/** + * Basic Responsive structure... + * + * Shuffles theme columns around based on screen width + */ + +@media only screen and (min-width: 2000px) { + #wpwrap .theme-browser .theme { + width: 17.6%; + margin: 0 3% 3% 0; + } + + #wpwrap .theme-browser .theme:nth-child(3n), + #wpwrap .theme-browser .theme:nth-child(4n) { + margin-right: 3%; + } + + #wpwrap .theme-browser .theme:nth-child(5n) { + margin-right: 0; + } +} + +@media only screen and (min-width: 1680px) { + .theme-overlay .theme-wrap { + width: 1450px; + margin: 0 auto; + } +} + +/* Maximum screenshot width reaches 440px */ +@media only screen and (min-width: 1640px) { + .theme-browser .theme { + width: 22.7%; + margin: 0 3% 3% 0; + } + .theme-browser .theme .theme-screenshot:after { + padding-top: 75%; /* using a 4/3 aspect ratio */ + } + + .theme-browser .theme:nth-child(3n) { + margin-right: 3%; + } + + .theme-browser .theme:nth-child(4n) { + margin-right: 0; + } +} +/* Maximum screenshot width reaches 440px */ +@media only screen and (max-width: 1120px) { + .theme-browser .theme { + width: 47.5%; + margin-right: 0; + } + + .theme-browser .theme:nth-child(even) { + margin-right: 0; + } + + .theme-browser .theme:nth-child(odd) { + margin-right: 5%; + } +} + +/* Admin menu is folded */ +@media only screen and (max-width: 900px) { + .theme-overlay .theme-wrap { + left: 65px; + } +} + +@media only screen and (max-width: 780px) { + body.folded .theme-overlay .theme-wrap, + .theme-overlay .theme-wrap { + top: 0; /* The adminmenu isn't fixed on mobile, so this can use the full viewport height */ + right: 0; + bottom: 0; + left: 0; + padding: 70px 20px 20px; + border: none; + z-index: 100000; /* should overlap #wpadminbar. */ + position: fixed; + } + + .theme-browser .theme.active .theme-name span { + /* Hide the "Active: " label on smaller screens. */ + display: none; + } + + .theme-overlay .theme-screenshots { + width: 40%; + } + + .theme-overlay .theme-info { + width: 50%; + } + .single-theme .theme-wrap { + padding: 10px; + } + + .theme-browser .theme .theme-actions { + padding: 5px 10px 4px 10px; + } + + .theme-overlay.small-screenshot .theme-screenshots { + position: static; + float: none; + max-width: 302px; + } + + .theme-overlay.small-screenshot .theme-info { + margin-left: 0; + width: auto; + } + + .theme:not(.active):hover .theme-actions, + .theme:not(.active):focus .theme-actions, + .theme:hover .more-details, + .theme:focus .more-details { + display: none; + } + + .theme-browser.rendered .theme:hover .theme-screenshot img, + .theme-browser.rendered .theme:focus .theme-screenshot img { + opacity: 1.0; + } +} + +@media only screen and (max-width: 480px) { + .theme-browser .theme { + width: 100%; + margin-right: 0; + } + + .theme-browser .theme:nth-child(2n), + .theme-browser .theme:nth-child(3n) { + margin-right: 0; + } +} + +@media only screen and (max-width: 650px) { + .theme-overlay .theme-description { + margin-left: 0; + } + + .theme-overlay .theme-actions .delete-theme { + position: relative; + right: auto; + bottom: auto; + } + + .theme-overlay .theme-actions .inactive-theme { + display: inline; + } + + .theme-overlay .theme-screenshots { + width: 100%; + float: none; + } + + .theme-overlay .theme-info { + width: 100%; + } + + .theme-overlay .theme-author { + margin: 5px 0 15px 0; + } + + .theme-overlay .current-label { + margin-top: 10px; + font-size: 13px; + } + + .themes-php .wp-filter-search { + float: none; + clear: both; + left: 0; + right: 0; + margin: -5px 0 20px 0; + width: 100%; + max-width: 280px; + } + + .theme-browser .theme.add-new-theme span:after { + font: normal 60px/90px dashicons; + width: 80px; + height: 80px; + top: 30%; + left: 50%; + text-indent: 0; + margin-left: -40px; + } + + .single-theme .theme-wrap { + margin: 0 -12px 0 -10px; + padding: 10px; + } + .single-theme .theme-overlay .theme-about { + padding: 10px; + overflow: visible; + } + .single-theme .current-label { + display: none; + } + .single-theme .theme-overlay .theme-actions { + position: static; + } +} + +.broken-themes { + clear: both; +} + +.broken-themes table { + text-align: left; + width: 50%; + border-spacing: 3px; + padding: 3px; +} + + +/*------------------------------------------------------------------------------ + 16.2 - Install Themes +------------------------------------------------------------------------------*/ + +/* Already installed theme */ +.theme-browser .theme .theme-installed { + background: #0073aa; +} +.theme-browser .theme .notice-success p:before { + color: #79ba49; + content: "\f147"; + display: inline-block; + font: normal 20px/1 'dashicons'; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + vertical-align: top; +} + +.theme-install.updated-message:before { + content: ''; +} + +.theme-install-php .wp-filter { + padding-left: 20px; +} + +.theme-install-php a.upload, +.theme-install-php a.browse-themes { + cursor: pointer; +} + +.upload-view-toggle .browse, +.plugin-install-tab-upload .upload-view-toggle .upload { + display: none; +} + +.plugin-install-tab-upload .upload-view-toggle .browse { + display: inline; +} + +.upload-theme, +.upload-plugin { + box-sizing: border-box; + display: none; + margin: 0; + padding: 50px 0; + width: 100%; + overflow: hidden; + position: relative; + top: 10px; +} + +.upload-plugin-wrap { + display: none; +} + +.show-upload-view .upload-theme, +.show-upload-view .upload-plugin, +.show-upload-view .upload-plugin-wrap, +.plugin-install-tab-upload .upload-plugin { + display: block; +} + +.upload-theme .wp-upload-form, +.upload-plugin .wp-upload-form { + background: #fafafa; + border: 1px solid #e5e5e5; + padding: 30px; + margin: 30px auto; + max-width: 380px; +} +.upload-theme .install-help, +.upload-plugin .install-help { + color: #555d66; /* #f1f1f1 background */ + font-size: 18px; + font-style: normal; + margin: 0; + padding: 0; + text-align: center; +} + +p.no-themes, +p.no-themes-local { + clear: both; + color: #666; + font-size: 18px; + font-style: normal; + margin: 0; + padding: 100px 0; + text-align: center; + display: none; +} + +.no-results p.no-themes { + display: block; +} + +.theme-install-php .add-new-theme { + display: none !important; +} + +@media only screen and (max-width: 1120px) { + .upload-theme .wp-upload-form { + margin: 20px 0; + max-width: 100%; + } + .upload-theme .install-help { + font-size: 15px; + padding: 20px 0 0; + text-align: left; + } +} + +.theme-details .theme-rating { + line-height: 23px; +} + +.theme-details .star-rating { + display: inline; +} + +.theme-details .num-ratings, +.theme-details .no-rating { + font-size: 11px; + color: #72777c; +} + +.theme-details .no-rating { + display: block; + line-height: 20px; +} + +/*------------------------------------------------------------------------------ + 16.3 - Custom Header Screen +------------------------------------------------------------------------------*/ + +.appearance_page_custom-header #headimg { + border: 1px solid #ddd; + overflow: hidden; + width: 100%; +} + +.appearance_page_custom-header #upload-form p label { + font-size: 12px; +} + +.appearance_page_custom-header .available-headers .default-header { + float: left; + margin: 0 20px 20px 0; +} + +.appearance_page_custom-header .random-header { + clear: both; + margin: 0 20px 20px 0; + vertical-align: middle; +} + +.appearance_page_custom-header .available-headers label input, +.appearance_page_custom-header .random-header label input { + margin-right: 10px; +} + +.appearance_page_custom-header .available-headers label img { + vertical-align: middle; +} + + +/*------------------------------------------------------------------------------ + 16.4 - Custom Background Screen +------------------------------------------------------------------------------*/ + +div#custom-background-image { + min-height: 100px; + border: 1px solid #ddd; +} + +div#custom-background-image img { + max-width: 400px; + max-height: 300px; +} + +.background-position-control input[type="radio"]:checked ~ .button { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, .5 ); + z-index: 1; +} + +.background-position-control input[type="radio"]:focus ~ .button { + border-color: #5b9dd9; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, .5 ), 0 0 3px rgba( 0, 115, 170, .8 ); + color: #23282d; +} + +.background-position-control .background-position-center-icon, +.background-position-control .background-position-center-icon:before { + display: inline-block; + line-height: 1; + text-align: center; + transition: background-color .1s ease-in 0; +} + +.background-position-control .background-position-center-icon { + height: 20px; + margin-top: 13px; + vertical-align: top; + width: 20px; +} + +.background-position-control .background-position-center-icon:before { + background-color: #555; + border-radius: 50%; + content: ""; + height: 12px; + width: 12px; +} + +.background-position-control .button:hover .background-position-center-icon:before, +.background-position-control input[type="radio"]:focus ~ .button .background-position-center-icon:before { + background-color: #23282d; +} + +.background-position-control .button-group { + display: block; +} + +.background-position-control .button-group .button { + border-radius: 0; + box-shadow: none; + /* Following properties are overridden by buttons responsive styles (see: wp-includes/css/buttons.css). */ + height: 40px !important; + line-height: 37px !important; + margin: 0 -1px 0 0 !important; + padding: 0 10px 1px !important; + position: relative; +} + +.background-position-control .button-group .button:active, +.background-position-control .button-group .button:hover, +.background-position-control .button-group .button:focus { + z-index: 1; +} + +.background-position-control .button-group:last-child .button { + box-shadow: 0 1px 0 #ccc; +} + +.background-position-control .button-group > label { + margin: 0 !important; +} + +.background-position-control .button-group:first-child > label:first-child .button { + border-radius: 3px 0 0; +} + +.background-position-control .button-group:first-child > label:first-child .dashicons { + -webkit-transform: rotate( 45deg ); + transform: rotate( 45deg ); +} + +.background-position-control .button-group:first-child > label:last-child .button { + border-radius: 0 3px 0 0; +} + +.background-position-control .button-group:first-child > label:last-child .dashicons { + -webkit-transform: rotate( -45deg ); + transform: rotate( -45deg ); +} + +.background-position-control .button-group:last-child > label:first-child .button { + border-radius: 0 0 0 3px; +} + +.background-position-control .button-group:last-child > label:first-child .dashicons { + -webkit-transform: rotate( -45deg ); + transform: rotate( -45deg ); +} + +.background-position-control .button-group:last-child > label:last-child .button { + border-radius: 0 0 3px 0; +} + +.background-position-control .button-group:last-child > label:last-child .dashicons { + -webkit-transform: rotate( 45deg ); + transform: rotate( 45deg ); +} + +.background-position-control .button-group .dashicons { + margin-top: 9px; +} + +.background-position-control .button-group + .button-group { + margin-top: -1px; +} + +/*------------------------------------------------------------------------------ + 23.0 - Full Overlay w/ Sidebar +------------------------------------------------------------------------------*/ + +body.full-overlay-active { + overflow: hidden; + /* Hide all the content, the Customizer overlay is then made visible to be the only available content. */ + visibility: hidden; +} + +.wp-full-overlay { + background: transparent; + z-index: 500000; + position: fixed; + overflow: visible; + top: 0; + bottom: 0; + left: 0; + right: 0; + height: 100%; + min-width: 0; +} + +.wp-full-overlay-sidebar { + box-sizing: border-box; + position: fixed; + min-width: 300px; + max-width: 600px; + width: 18%; + height: 100%; + top: 0; + bottom: 0; + left: 0; + padding: 0; + margin: 0; + z-index: 10; + background: #eee; + border-right: none; +} + +.wp-full-overlay.collapsed .wp-full-overlay-sidebar { + overflow: visible; +} + +.wp-full-overlay.collapsed, +.wp-full-overlay.expanded .wp-full-overlay-sidebar { + margin-left: 0 !important; +} + +.wp-full-overlay.expanded { + margin-left: 300px; +} + +.wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-left: -300px; +} + +@media screen and (min-width: 1667px) { + .wp-full-overlay.expanded { + margin-left: 18%; + } + + .wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-left: -18%; + } +} + +@media screen and (min-width: 3333px) { + .wp-full-overlay.expanded { + margin-left: 600px; + } + + .wp-full-overlay.collapsed .wp-full-overlay-sidebar { + margin-left: -600px; + } +} + +.wp-full-overlay-sidebar:after { + content: ""; + display: block; + position: absolute; + top: 0; + bottom: 0; + right: 0; + width: 3px; + z-index: 1000; +} + +.wp-full-overlay-main { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + height: 100%; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header { + position: absolute; + left: 0; + right: 0; + height: 45px; + padding: 0 15px; + line-height: 45px; + z-index: 10; + margin: 0; + border-top: none; + box-shadow: none; +} + +.wp-full-overlay-sidebar .wp-full-overlay-header a.back { + margin-top: 9px; +} + +.wp-full-overlay-sidebar .wp-full-overlay-footer { + bottom: 0; + border-bottom: none; + border-top: none; + box-shadow: none; +} + +.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content { + position: absolute; + top: 45px; + bottom: 45px; + left: 0; + right: 0; + overflow: auto; +} + +/* Close & Navigation Links */ +.theme-install-overlay .wp-full-overlay-sidebar .wp-full-overlay-header { + padding: 0; +} + +.theme-install-overlay .close-full-overlay, +.theme-install-overlay .previous-theme, +.theme-install-overlay .next-theme { + display: block; + position: relative; + float: left; + width: 45px; + height: 45px; + padding-right: 2px; + background: #eee; + border-right: 1px solid #ddd; + color: #444; + cursor: pointer; + text-decoration: none; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.theme-install-overlay .close-full-overlay:hover, +.theme-install-overlay .close-full-overlay:focus, +.theme-install-overlay .previous-theme:hover, +.theme-install-overlay .previous-theme:focus, +.theme-install-overlay .next-theme:hover, +.theme-install-overlay .next-theme:focus { + background: #ddd; + border-color: #ccc; + color: #000; + outline: none; + box-shadow: none; +} + +.theme-install-overlay .close-full-overlay:before { + font: normal 22px/1 dashicons; + content: "\f335"; + position: relative; + top: 7px; + left: 13px; +} + +.theme-install-overlay .previous-theme:before { + font: normal 20px/1 dashicons; + content: "\f341"; + position: relative; + top: 6px; + left: 14px; +} + +.theme-install-overlay .next-theme:before { + font: normal 20px/1 dashicons; + content: "\f345"; + position: relative; + top: 6px; + left: 13px; +} + +.theme-install-overlay .previous-theme.disabled, +.theme-install-overlay .next-theme.disabled, +.theme-install-overlay .previous-theme.disabled:hover, +.theme-install-overlay .previous-theme.disabled:focus, +.theme-install-overlay .next-theme.disabled:hover, +.theme-install-overlay .next-theme.disabled:focus { + color: #b4b9be; + background: #eee; + cursor: default; + pointer-events: none; +} + +.theme-install-overlay .close-full-overlay, +.theme-install-overlay .previous-theme, +.theme-install-overlay .next-theme { + border-left: 0; + border-top: 0; + border-bottom: 0; +} + +.theme-install-overlay .close-full-overlay:before, +.theme-install-overlay .previous-theme:before, +.theme-install-overlay .next-theme:before { + top: 2px; + left: 0; +} + +/* Collapse Button */ +.wp-core-ui .wp-full-overlay .collapse-sidebar { + position: fixed; + bottom: 0; + left: 0; + padding: 9px 0 9px 10px; + height: 45px; + color: #656a6f; + outline: 0; + line-height: 1; + background-color: transparent !important; + border: none !important; + box-shadow: none !important; + border-radius: 0 !important; +} + +.wp-core-ui .wp-full-overlay .collapse-sidebar:hover, +.wp-core-ui .wp-full-overlay .collapse-sidebar:focus { + color: #0073aa; +} + +.wp-full-overlay .collapse-sidebar-arrow, +.wp-full-overlay .collapse-sidebar-label { + display: inline-block; + vertical-align: middle; + line-height: 20px; +} + +.wp-full-overlay .collapse-sidebar-arrow { + width: 20px; + height: 20px; + margin: 0 2px; /* avoid the focus box-shadow to be cut-off */ + border-radius: 50%; + overflow: hidden; +} + +.wp-full-overlay .collapse-sidebar:hover .collapse-sidebar-arrow, +.wp-full-overlay .collapse-sidebar:focus .collapse-sidebar-arrow { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.wp-full-overlay .collapse-sidebar-label { + margin-left: 3px; +} + +.wp-full-overlay.collapsed .collapse-sidebar-label { + display: none; +} + +.wp-full-overlay .collapse-sidebar-arrow:before { + display: block; + content: "\f148"; + background: #eee; + font: normal 20px/1 dashicons; + speak: none; + padding: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-core-ui .wp-full-overlay.collapsed .collapse-sidebar { + padding: 9px 10px; +} + +/* rtl:ignore */ +.wp-full-overlay.collapsed .collapse-sidebar-arrow:before, +.rtl .wp-full-overlay .collapse-sidebar-arrow:before { + -webkit-transform: rotate(180.001deg); + transform: rotate(180.001deg); /* Firefox: promoting to its own layer to trigger anti-aliasing */ +} + +.rtl .wp-full-overlay.collapsed .collapse-sidebar-arrow:before { + -webkit-transform: none; + transform: none; +} + +/* Animations */ +.wp-full-overlay, +.wp-full-overlay-sidebar, +.wp-full-overlay .collapse-sidebar, +.wp-full-overlay-main { + transition-property: left, right, top, bottom, width, margin; + transition-duration: 0.2s; +} + +/* Device/preview size toggles */ + +.wp-full-overlay { + background: #191e23; +} + +.wp-full-overlay-main { + background-color: #f1f1f1; +} + +.expanded .wp-full-overlay-footer { + position: fixed; + bottom: 0; + left: 0; + min-width: 299px; + max-width: 599px; + width: 18%; + width: calc( 18% - 1px ); + height: 45px; + border-top: 1px solid #ddd; + background: #eee; +} + +.wp-full-overlay-footer .devices-wrapper { + float: right; +} + +.wp-full-overlay-footer .devices { + position: relative; + background: #eee; + box-shadow: -20px 0 10px -5px #eee; +} + +.wp-full-overlay-footer .devices button { + cursor: pointer; + background: transparent; + border: none; + height: 45px; + padding: 0 3px; + margin: 0 0 0 -4px; + box-shadow: none; + border-top: 1px solid transparent; + border-bottom: 4px solid transparent; + transition: .15s color ease-in-out, + .15s background-color ease-in-out, + .15s border-color ease-in-out; +} + +.wp-full-overlay-footer .devices button:focus { + box-shadow: none; + outline: none; +} + +.wp-full-overlay-footer .devices button:before { + display: inline-block; + -webkit-font-smoothing: antialiased; + font: normal 20px/30px "dashicons"; + vertical-align: top; + margin: 3px 0; + padding: 4px 8px; + color: #656a6f; +} + +.wp-full-overlay-footer .devices button.active { + border-bottom-color: #191e23; +} + +.wp-full-overlay-footer .devices button:hover, +.wp-full-overlay-footer .devices button:focus { + background-color: #fff; +} + +.wp-full-overlay-footer .devices button:focus, +.wp-full-overlay-footer .devices button.active:hover { + border-bottom-color: #0073aa; +} + +.wp-full-overlay-footer .devices button.active:before { + color: #191e23; +} + +.wp-full-overlay-footer .devices button:hover:before, +.wp-full-overlay-footer .devices button:focus:before { + color: #0073aa; +} + +.wp-full-overlay-footer .devices .preview-desktop:before { + content: "\f472"; +} + +.wp-full-overlay-footer .devices .preview-tablet:before { + content: "\f471"; +} + +.wp-full-overlay-footer .devices .preview-mobile:before { + content: "\f470"; +} + +@media screen and (max-width:1024px) { + .wp-full-overlay-footer .devices { + display: none; + } +} + +.collapsed .wp-full-overlay-footer .devices button:before { + display: none; +} + +.preview-mobile .wp-full-overlay-main { + margin: auto 0 auto -160px; + width: 320px; + height: 480px; + max-height: 100%; + max-width: 100%; + left: 50%; +} + +.preview-tablet .wp-full-overlay-main { + margin: auto 0 auto -360px; + width: 720px; /* Size is loosely based on a typical "tablet" device size. Intentionally ambiguous - this does not represent any particular device precisely. */ + height: 1080px; + max-height: 100%; + max-width: 100%; + left: 50%; +} + + +/*------------------------------------------------------------------------------ + 24.0 - Customize Loader +------------------------------------------------------------------------------*/ + +.no-customize-support .hide-if-no-customize, +.customize-support .hide-if-customize, +.no-customize-support.wp-core-ui .hide-if-no-customize, +.no-customize-support .wp-core-ui .hide-if-no-customize, +.customize-support.wp-core-ui .hide-if-customize, +.customize-support .wp-core-ui .hide-if-customize { + display: none; +} + +#customize-container, +#customize-controls .notice.notification-overlay { + background: #eee; + z-index: 500000; + position: fixed; + overflow: visible; + top: 0; + bottom: 0; + left: 0; + right: 0; + height: 100%; +} +#customize-container { + display: none; +} + +/* Make the Customizer and Theme installer overlays the only available content. */ +#customize-container, +.theme-install-overlay { + visibility: visible; +} + +.customize-loading #customize-container iframe { + opacity: 0; +} + +#customize-container iframe, +.theme-install-overlay iframe { + height: 100%; + width: 100%; + z-index: 20; + transition: opacity 0.3s; +} + +#customize-controls { + margin-top: 0; +} + +.theme-install-overlay { + display: none; +} + +.theme-install-overlay.single-theme { + display: block; +} + +.install-theme-info { + display: none; + padding: 10px 20px 60px; +} + +.single-theme .install-theme-info { + padding-top: 15px; +} + +.theme-install-overlay .install-theme-info { + display: block; +} + +.install-theme-info .theme-install { + float: right; + margin-top: 18px; +} + +.install-theme-info .theme-name { + font-size: 16px; + line-height: 24px; + margin-bottom: 0; + margin-top: 0; +} + +.install-theme-info .theme-screenshot { + margin: 15px 0; + width: 258px; + border: 1px solid #ccc; +} + +.install-theme-info .theme-details { + overflow: hidden; +} + +.theme-details .theme-version { + margin: 15px 0; +} + +.theme-details .theme-description { + float: left; + color: #72777c; + line-height: 20px; + max-width: 100%; +} + +.theme-install-overlay .wp-full-overlay-header .button { + float: right; + margin: 8px 10px 0 0; + /* For when .theme-install is a span rather than a.button-primary (already installed theme) */ + line-height: 26px; +} + +.theme-install-overlay .wp-full-overlay-sidebar { + background: #eee; + border-right: 1px solid #ddd; +} + +.theme-install-overlay .wp-full-overlay-sidebar-content { + background: #fff; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; +} + +.theme-install-overlay .wp-full-overlay-main { + position: absolute; + z-index: 0; + background-color: #f1f1f1; +} + +.customize-loading #customize-container { + background-color: #f1f1f1; +} + +#customize-preview.wp-full-overlay-main:before, +.customize-loading #customize-container:before, +#customize-controls .notice.notification-overlay.notification-loading:before, +.theme-install-overlay .wp-full-overlay-main:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + left: 50%; + top: 50%; + z-index: -1; + margin: -10px 0 0 -10px; + -webkit-transform: translateZ(0); + transform: translateZ(0); + background: transparent url(../images/spinner.gif) no-repeat center center; + background-size: 20px 20px; +} + +#customize-preview.wp-full-overlay-main.iframe-ready:before, +.theme-install-overlay.iframe-ready .wp-full-overlay-main:before { + background-image: none; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .wp-full-overlay .collapse-sidebar-arrow { + background-image: url(../images/arrows-2x.png); + background-size: 15px 123px; + } + + #customize-preview.wp-full-overlay-main:before, + .customize-loading #customize-container:before, + #customize-controls .notice.notification-overlay.notification-loading:before, + .theme-install-overlay .wp-full-overlay-main:before { + background-image: url(../images/spinner-2x.gif); + } +} + +@media screen and ( max-width: 782px ) { + .available-theme .action-links .delete-theme { + float: none; + margin: 0; + padding: 0; + clear: both; + } + + .available-theme .action-links .delete-theme a { + padding: 0; + } + + .broken-themes table { + width: 100%; + } + + .theme-install-overlay .wp-full-overlay-header .theme-install { + margin-top: 6px; + line-height: normal; + } + + .theme-browser .theme .theme-actions .button { + margin-bottom: 0; + } + + .theme-browser .theme.active .theme-actions, + .theme-browser .theme .theme-actions { + padding-top: 8px; + padding-bottom: 8px; + } +} + +@media aural { + .theme .notice:before, + .theme-info .updating-message:before, + .theme-info .updated-message:before, + .theme-install.updating-message:before { + speak: none; + } +} diff --git a/backend/wp-admin/css/themes.min.css b/backend/wp-admin/css/themes.min.css new file mode 100644 index 0000000..952e8d5 --- /dev/null +++ b/backend/wp-admin/css/themes.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body.js .theme-browser.search-loading{display:none}.theme-browser .themes{clear:both}.themes-php:not(.network-admin) .wrap h1{margin-bottom:15px}.themes-php .wrap h1 .button{margin-left:20px}.themes-php .search-form{display:inline}.themes-php .wp-filter-search{position:relative;top:-2px;left:20px;margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5}.theme .notice,.theme .notice.is-dismissible{left:0;margin:0;position:absolute;right:0;top:0}.theme-browser .theme{cursor:pointer;float:left;margin:0 4% 4% 0;position:relative;width:30.6%;border:1px solid #ddd;box-shadow:0 1px 1px -1px rgba(0,0,0,.1);box-sizing:border-box}.ie8 .theme-browser .theme{width:30%;margin:0 3% 4% 0}.theme-browser .theme:nth-child(3n){margin-right:0}.theme-browser .theme:focus,.theme-browser .theme:hover{cursor:pointer}.theme-browser .theme .theme-name{font-size:15px;font-weight:600;height:18px;margin:0;padding:15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;background:#fff;background:rgba(255,255,255,.65)}.theme-browser .theme .theme-actions{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";opacity:0;transition:opacity .1s ease-in-out;height:auto;background:rgba(244,244,244,.7);border-left:1px solid rgba(0,0,0,.05)}.theme-browser .theme.focus .theme-actions,.theme-browser .theme:focus .theme-actions,.theme-browser .theme:hover .theme-actions{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}.theme-browser .theme .theme-actions .button-primary{margin-right:3px}.theme-browser .theme .theme-actions .button{float:none;margin-left:3px}.theme-browser .theme .theme-screenshot{display:block;overflow:hidden;position:relative;-webkit-backface-visibility:hidden;transition:opacity .2s ease-in-out}.theme-browser .theme .theme-screenshot:after{content:"";display:block;padding-top:66.66666%}.theme-browser .theme .theme-screenshot img{height:auto;position:absolute;left:0;top:0;width:100%;transition:opacity .2s ease-in-out}.theme-browser .theme:focus .theme-screenshot,.theme-browser .theme:hover .theme-screenshot{background:#fff}.theme-browser.rendered .theme:focus .theme-screenshot img,.theme-browser.rendered .theme:hover .theme-screenshot img{opacity:.4}.theme-browser .theme .more-details{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";opacity:0;position:absolute;top:35%;right:20%;left:20%;background:#23282d;background:rgba(0,0,0,.7);color:#fff;font-size:15px;text-shadow:0 1px 0 rgba(0,0,0,.6);-webkit-font-smoothing:antialiased;font-weight:600;padding:15px 12px;text-align:center;border-radius:3px;transition:opacity .1s ease-in-out}.theme-browser .theme:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.theme-browser .theme:focus .more-details{opacity:1}.theme-browser .theme.active:focus .theme-actions{display:block}.theme-browser.rendered .theme:focus .more-details,.theme-browser.rendered .theme:hover .more-details{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";opacity:1}.theme-browser .theme.active .theme-name{background:#23282d;color:#fff;padding-right:110px;font-weight:300;box-shadow:inset 0 1px 1px rgba(0,0,0,.5)}.theme-browser .customize-control .theme.active .theme-name{padding-right:15px}.theme-browser .theme.active .theme-name span{font-weight:600}.theme-browser .theme.active .theme-actions{background:rgba(49,49,49,.7);border-left:none;opacity:1}.theme-id-container{position:relative}.theme-browser .theme .theme-actions,.theme-browser .theme.active .theme-actions{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);right:0;padding:10px 15px;box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}.theme-browser .theme.active .theme-actions .button-primary{margin-right:0}.theme-browser .theme .theme-author{background:#23282d;color:#eee;display:none;font-size:14px;margin:0 10px;padding:5px 10px;position:absolute;bottom:56px}.theme-browser .theme.display-author .theme-author{display:block}.theme-browser .theme.display-author .theme-author a{color:inherit;text-decoration:none}.theme-browser .theme.add-new-theme{border:none;box-shadow:none}.theme-browser .theme.add-new-theme a{text-decoration:none;display:block;position:relative;z-index:1}.theme-browser .theme.add-new-theme a:after{display:block;content:"";background:0 0;background:rgba(0,0,0,0);position:absolute;top:0;left:0;right:0;bottom:0;padding:0;text-shadow:none;border:5px dashed #d5d2ca;border:5px dashed rgba(0,0,0,.1);box-sizing:border-box}.theme-browser .theme.add-new-theme span:after{background:#e5e5e5;background:rgba(153,153,153,.1);border-radius:50%;display:inline-block;content:"\f132";-webkit-font-smoothing:antialiased;font:400 74px/115px dashicons;width:100px;height:100px;vertical-align:middle;text-align:center;color:#999;position:absolute;top:30%;left:50%;margin-left:-50px;text-indent:-4px;padding:0;text-shadow:none;z-index:4}.rtl .theme-browser .theme.add-new-theme span:after{text-indent:4px}.theme-browser .theme.add-new-theme a:focus .theme-screenshot,.theme-browser .theme.add-new-theme a:hover .theme-screenshot{background:0 0}.theme-browser .theme.add-new-theme a:focus span:after,.theme-browser .theme.add-new-theme a:hover span:after{background:#fff;color:#0073aa}.theme-browser .theme.add-new-theme a:focus:after,.theme-browser .theme.add-new-theme a:hover:after{border-color:transparent;color:#fff;background:#0073aa;content:""}.theme-browser .theme.add-new-theme .theme-name{background:0 0;text-align:center;box-shadow:none;font-weight:400;position:relative;top:0;margin-top:-18px;padding-top:0;padding-bottom:48px}.theme-browser .theme.add-new-theme a:focus .theme-name,.theme-browser .theme.add-new-theme a:hover .theme-name{color:#fff;z-index:2}.theme-overlay .theme-backdrop{position:absolute;left:-20px;right:0;top:0;bottom:0;background:#f1f1f1;background:rgba(238,238,238,.9);z-index:10000}.theme-overlay .theme-header .close,.theme-overlay .theme-header .left,.theme-overlay .theme-header .right{cursor:pointer;background-color:transparent;height:48px;transition:color .1s ease-in-out,background .1s ease-in-out;text-align:center}.theme-overlay .theme-header{position:absolute;top:0;left:0;right:0;height:48px;border-bottom:1px solid #ddd}.theme-overlay .theme-header button{padding:0}.theme-overlay .theme-header .close{width:50px;float:right;border:0;border-left:1px solid #ddd}.theme-overlay .theme-header .close:before{font:400 22px/50px dashicons!important;color:#72777c;display:inline-block;content:"\f335";font-weight:300}.theme-overlay .theme-header .left,.theme-overlay .theme-header .right{color:#72777c;width:54px;float:left;border:0;border-right:1px solid #ddd}.theme-overlay .theme-header .close:focus,.theme-overlay .theme-header .close:hover,.theme-overlay .theme-header .left:focus,.theme-overlay .theme-header .left:hover,.theme-overlay .theme-header .right:focus,.theme-overlay .theme-header .right:hover{background:#ddd;border-color:#ccc;color:#000}.theme-overlay .theme-header .close:focus:before,.theme-overlay .theme-header .close:hover:before{color:#000}.theme-overlay .theme-header .close:focus,.theme-overlay .theme-header .left:focus,.theme-overlay .theme-header .right:focus{box-shadow:none;outline:0}.theme-overlay .theme-header .left.disabled,.theme-overlay .theme-header .left.disabled:hover,.theme-overlay .theme-header .right.disabled,.theme-overlay .theme-header .right.disabled:hover{color:#ccc;background:inherit;cursor:inherit}.theme-overlay .theme-header .left:before,.theme-overlay .theme-header .right:before{font:400 20px/50px dashicons!important;display:inline;font-weight:300}.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-header"],.customize-support .theme-overlay .theme-actions a[href="themes.php?page=custom-background"],.theme-overlay .theme-actions .active-theme,.theme-overlay.active .theme-actions .inactive-theme{display:none}.theme-overlay .theme-header .left:before{content:"\f341"}.theme-overlay .theme-header .right:before{content:"\f345"}.theme-overlay .theme-wrap{clear:both;position:fixed;top:9%;left:190px;right:30px;bottom:3%;background:#fff;box-shadow:0 1px 20px 5px rgba(0,0,0,.1);z-index:10000;box-sizing:border-box;-webkit-overflow-scrolling:touch}body.folded .theme-browser~.theme-overlay .theme-wrap{left:70px}.theme-overlay .theme-about{position:absolute;top:49px;bottom:57px;left:0;right:0;overflow:auto;padding:2% 4%}.theme-overlay .theme-actions{position:absolute;text-align:center;bottom:0;left:0;right:0;padding:10px 25px 5px;background:#f3f3f3;z-index:30;box-sizing:border-box;border-top:1px solid #eee}.ie8 .theme-overlay .theme-actions{border:1px solid #eee}.theme-overlay .theme-actions a{margin-right:5px;margin-bottom:5px}.broken-themes a.delete-theme,.theme-overlay .theme-actions .delete-theme{color:#a00;text-decoration:none;border-color:transparent;box-shadow:none;background:0 0}.theme-overlay .theme-actions .delete-theme{position:absolute;right:10px;bottom:5px}.broken-themes a.delete-theme:focus,.broken-themes a.delete-theme:hover,.theme-overlay .theme-actions .delete-theme:focus,.theme-overlay .theme-actions .delete-theme:hover{background:#d54e21;color:#fff;border-color:#d54e21}.theme-overlay .theme-actions .inactive-theme,.theme-overlay.active .theme-actions .active-theme{display:block}.theme-overlay .theme-screenshots{float:left;margin:0 30px 0 0;width:55%;max-width:1200px;text-align:center}.theme-overlay .screenshot{border:1px solid #fff;box-sizing:border-box;overflow:hidden;position:relative;box-shadow:0 0 0 1px rgba(0,0,0,.2)}.theme-overlay .screenshot:after{content:"";display:block;padding-top:75%}.theme-overlay .screenshot img{height:auto;position:absolute;left:0;top:0;width:100%}.theme-overlay.small-screenshot .theme-screenshots{position:absolute;width:302px}.theme-overlay.small-screenshot .theme-info{margin-left:350px;width:auto}.theme-overlay .screenshot.thumb{background:#ccc;border:1px solid #eee;float:none;display:inline-block;margin:10px 5px 0;width:140px;height:80px;cursor:pointer}.theme-overlay .screenshot.thumb:after{content:"";display:block;padding-top:100%}.theme-overlay .screenshot.thumb img{cursor:pointer;position:absolute;left:0;top:0;width:100%;height:auto}.theme-overlay .screenshot.selected{background:0 0;border:2px solid #00a0d2}.theme-overlay .screenshot.selected img{opacity:.8}.theme-browser .theme .theme-screenshot.blank,.theme-overlay .screenshot.blank{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAALElEQVQYGWO8d+/efwYkoKioiMRjYGBC4WHhUK6A8T8QIJt8//59ZC493AAAQssKpBK4F5AAAAAASUVORK5CYII=)}.theme-overlay .theme-info{width:40%;float:left}.theme-overlay .current-label{background:#32373c;color:#fff;font-size:11px;display:inline-block;padding:2px 8px;border-radius:2px;margin:0 0 -10px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.theme-overlay .theme-name{color:#23282d;font-size:32px;font-weight:100;margin:10px 0 0;line-height:1.3;word-wrap:break-word;overflow-wrap:break-word}.theme-overlay .theme-version{color:#72777c;font-size:13px;font-weight:400;float:none;display:inline-block;margin-left:10px}.theme-overlay .theme-author{margin:15px 0 25px;color:#72777c;font-size:16px;font-weight:400;line-height:inherit}.theme-overlay .theme-author a{text-decoration:none}.theme-overlay .theme-description{color:#555;font-size:15px;font-weight:400;line-height:1.5;margin:30px 0 0}.theme-overlay .theme-tags{border-top:3px solid #eee;color:#82878c;font-size:13px;font-weight:400;margin:30px 0 0;padding-top:20px}.theme-overlay .theme-tags span{color:#444;font-weight:600;margin-right:5px}.theme-overlay .parent-theme{background:#f7fcfe;border:1px solid #eee;border-left:4px solid #00a0d2;font-size:14px;font-weight:400;margin-top:30px;padding:10px 10px 10px 20px}.theme-overlay .parent-theme strong{font-weight:700}.single-theme .theme,.single-theme .theme-overlay .theme-backdrop,.single-theme .theme-overlay .theme-header{display:none}.single-theme .theme-overlay .theme-wrap{clear:both;min-height:330px;position:relative;left:auto;right:auto;top:auto;bottom:auto;z-index:10}.single-theme .theme-overlay .theme-about{padding:30px 30px 70px;position:static}.single-theme .theme-overlay .theme-actions{position:absolute}@media only screen and (min-width:2000px){#wpwrap .theme-browser .theme{width:17.6%;margin:0 3% 3% 0}#wpwrap .theme-browser .theme:nth-child(3n),#wpwrap .theme-browser .theme:nth-child(4n){margin-right:3%}#wpwrap .theme-browser .theme:nth-child(5n){margin-right:0}}@media only screen and (min-width:1680px){.theme-overlay .theme-wrap{width:1450px;margin:0 auto}}@media only screen and (min-width:1640px){.theme-browser .theme{width:22.7%;margin:0 3% 3% 0}.theme-browser .theme .theme-screenshot:after{padding-top:75%}.theme-browser .theme:nth-child(3n){margin-right:3%}.theme-browser .theme:nth-child(4n){margin-right:0}}@media only screen and (max-width:1120px){.theme-browser .theme{width:47.5%;margin-right:0}.theme-browser .theme:nth-child(even){margin-right:0}.theme-browser .theme:nth-child(odd){margin-right:5%}}@media only screen and (max-width:900px){.theme-overlay .theme-wrap{left:65px}}@media only screen and (max-width:780px){.theme-overlay .theme-wrap,body.folded .theme-overlay .theme-wrap{top:0;right:0;bottom:0;left:0;padding:70px 20px 20px;border:none;z-index:100000;position:fixed}.theme-browser .theme.active .theme-name span{display:none}.theme-overlay .theme-screenshots{width:40%}.theme-overlay .theme-info{width:50%}.single-theme .theme-wrap{padding:10px}.theme-browser .theme .theme-actions{padding:5px 10px 4px}.theme-overlay.small-screenshot .theme-screenshots{position:static;float:none;max-width:302px}.theme-overlay.small-screenshot .theme-info{margin-left:0;width:auto}.theme:focus .more-details,.theme:hover .more-details,.theme:not(.active):focus .theme-actions,.theme:not(.active):hover .theme-actions{display:none}.theme-browser.rendered .theme:focus .theme-screenshot img,.theme-browser.rendered .theme:hover .theme-screenshot img{opacity:1}}@media only screen and (max-width:480px){.theme-browser .theme{width:100%;margin-right:0}.theme-browser .theme:nth-child(2n),.theme-browser .theme:nth-child(3n){margin-right:0}}@media only screen and (max-width:650px){.theme-overlay .theme-description{margin-left:0}.theme-overlay .theme-actions .delete-theme{position:relative;right:auto;bottom:auto}.theme-overlay .theme-actions .inactive-theme{display:inline}.theme-overlay .theme-screenshots{width:100%;float:none}.theme-overlay .theme-info{width:100%}.theme-overlay .theme-author{margin:5px 0 15px}.theme-overlay .current-label{margin-top:10px;font-size:13px}.themes-php .wp-filter-search{float:none;clear:both;left:0;right:0;margin:-5px 0 20px;width:100%;max-width:280px}.theme-browser .theme.add-new-theme span:after{font:400 60px/90px dashicons;width:80px;height:80px;top:30%;left:50%;text-indent:0;margin-left:-40px}.single-theme .theme-wrap{margin:0 -12px 0 -10px;padding:10px}.single-theme .theme-overlay .theme-about{padding:10px;overflow:visible}.single-theme .current-label{display:none}.single-theme .theme-overlay .theme-actions{position:static}}.broken-themes{clear:both}.broken-themes table{text-align:left;width:50%;border-spacing:3px;padding:3px}.theme-browser .theme .theme-installed{background:#0073aa}.theme-browser .theme .notice-success p:before{color:#79ba49;content:"\f147";display:inline-block;font:400 20px/1 dashicons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}.theme-install.updated-message:before{content:''}.theme-install-php .wp-filter{padding-left:20px}.theme-install-php a.browse-themes,.theme-install-php a.upload{cursor:pointer}.plugin-install-tab-upload .upload-view-toggle .upload,.upload-view-toggle .browse{display:none}.plugin-install-tab-upload .upload-view-toggle .browse{display:inline}.upload-plugin,.upload-theme{box-sizing:border-box;display:none;margin:0;padding:50px 0;width:100%;overflow:hidden;position:relative;top:10px}.upload-plugin-wrap{display:none}.plugin-install-tab-upload .upload-plugin,.show-upload-view .upload-plugin,.show-upload-view .upload-plugin-wrap,.show-upload-view .upload-theme{display:block}.upload-plugin .wp-upload-form,.upload-theme .wp-upload-form{background:#fafafa;border:1px solid #e5e5e5;padding:30px;margin:30px auto;max-width:380px}.upload-plugin .install-help,.upload-theme .install-help{color:#555d66;font-size:18px;font-style:normal;margin:0;padding:0;text-align:center}p.no-themes,p.no-themes-local{clear:both;color:#666;font-size:18px;font-style:normal;margin:0;padding:100px 0;text-align:center;display:none}.no-results p.no-themes{display:block}.theme-install-php .add-new-theme{display:none!important}@media only screen and (max-width:1120px){.upload-theme .wp-upload-form{margin:20px 0;max-width:100%}.upload-theme .install-help{font-size:15px;padding:20px 0 0;text-align:left}}.theme-details .theme-rating{line-height:23px}.theme-details .star-rating{display:inline}.theme-details .no-rating,.theme-details .num-ratings{font-size:11px;color:#72777c}.theme-details .no-rating{display:block;line-height:20px}.appearance_page_custom-header #headimg{border:1px solid #ddd;overflow:hidden;width:100%}.appearance_page_custom-header #upload-form p label{font-size:12px}.appearance_page_custom-header .available-headers .default-header{float:left;margin:0 20px 20px 0}.appearance_page_custom-header .random-header{clear:both;margin:0 20px 20px 0;vertical-align:middle}.appearance_page_custom-header .available-headers label input,.appearance_page_custom-header .random-header label input{margin-right:10px}.appearance_page_custom-header .available-headers label img{vertical-align:middle}div#custom-background-image{min-height:100px;border:1px solid #ddd}div#custom-background-image img{max-width:400px;max-height:300px}.background-position-control input[type=radio]:checked~.button{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);z-index:1}.background-position-control input[type=radio]:focus~.button{border-color:#5b9dd9;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5),0 0 3px rgba(0,115,170,.8);color:#23282d}.background-position-control .background-position-center-icon,.background-position-control .background-position-center-icon:before{display:inline-block;line-height:1;text-align:center;transition:background-color .1s ease-in 0}.background-position-control .background-position-center-icon{height:20px;margin-top:13px;vertical-align:top;width:20px}.background-position-control .background-position-center-icon:before{background-color:#555;border-radius:50%;content:"";height:12px;width:12px}.background-position-control .button:hover .background-position-center-icon:before,.background-position-control input[type=radio]:focus~.button .background-position-center-icon:before{background-color:#23282d}.background-position-control .button-group{display:block}.background-position-control .button-group .button{border-radius:0;box-shadow:none;height:40px!important;line-height:37px!important;margin:0 -1px 0 0!important;padding:0 10px 1px!important;position:relative}.wp-full-overlay,.wp-full-overlay-sidebar{position:fixed;top:0;height:100%;bottom:0;left:0}.background-position-control .button-group .button:active,.background-position-control .button-group .button:focus,.background-position-control .button-group .button:hover{z-index:1}.background-position-control .button-group:last-child .button{box-shadow:0 1px 0 #ccc}.background-position-control .button-group>label{margin:0!important}.background-position-control .button-group:first-child>label:first-child .button{border-radius:3px 0 0}.background-position-control .button-group:first-child>label:first-child .dashicons{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.background-position-control .button-group:first-child>label:last-child .button{border-radius:0 3px 0 0}.background-position-control .button-group:first-child>label:last-child .dashicons{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.background-position-control .button-group:last-child>label:first-child .button{border-radius:0 0 0 3px}.background-position-control .button-group:last-child>label:first-child .dashicons{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.background-position-control .button-group:last-child>label:last-child .button{border-radius:0 0 3px}.background-position-control .button-group:last-child>label:last-child .dashicons{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.background-position-control .button-group .dashicons{margin-top:9px}.background-position-control .button-group+.button-group{margin-top:-1px}body.full-overlay-active{overflow:hidden;visibility:hidden}.wp-full-overlay{z-index:500000;overflow:visible;right:0;min-width:0}.wp-full-overlay-sidebar{box-sizing:border-box;min-width:300px;max-width:600px;width:18%;padding:0;margin:0;z-index:10;background:#eee;border-right:none}.wp-full-overlay.collapsed,.wp-full-overlay.expanded .wp-full-overlay-sidebar{margin-left:0!important}.wp-full-overlay.expanded{margin-left:300px}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{overflow:visible;margin-left:-300px}@media screen and (min-width:1667px){.wp-full-overlay.expanded{margin-left:18%}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-18%}}@media screen and (min-width:3333px){.wp-full-overlay.expanded{margin-left:600px}.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left:-600px}}.wp-full-overlay-sidebar:after{content:"";display:block;position:absolute;top:0;bottom:0;right:0;width:3px;z-index:1000}.wp-full-overlay-main{position:absolute;left:0;right:0;top:0;bottom:0;height:100%}.wp-full-overlay-sidebar .wp-full-overlay-header{position:absolute;left:0;right:0;height:45px;padding:0 15px;line-height:45px;z-index:10;margin:0;border-top:none;box-shadow:none}.wp-full-overlay-sidebar .wp-full-overlay-header a.back{margin-top:9px}.wp-full-overlay-sidebar .wp-full-overlay-footer{bottom:0;border-bottom:none;border-top:none;box-shadow:none}.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content{position:absolute;top:45px;bottom:45px;left:0;right:0;overflow:auto}.theme-install-overlay .wp-full-overlay-sidebar .wp-full-overlay-header{padding:0}.theme-install-overlay .close-full-overlay,.theme-install-overlay .next-theme,.theme-install-overlay .previous-theme{display:block;position:relative;float:left;width:45px;height:45px;padding-right:2px;background:#eee;border-right:1px solid #ddd;color:#444;cursor:pointer;text-decoration:none;transition:color .1s ease-in-out,background .1s ease-in-out}.theme-install-overlay .close-full-overlay:focus,.theme-install-overlay .close-full-overlay:hover,.theme-install-overlay .next-theme:focus,.theme-install-overlay .next-theme:hover,.theme-install-overlay .previous-theme:focus,.theme-install-overlay .previous-theme:hover{background:#ddd;border-color:#ccc;color:#000;outline:0;box-shadow:none}.theme-install-overlay .close-full-overlay:before{font:400 22px/1 dashicons;content:"\f335";position:relative;top:7px;left:13px}.theme-install-overlay .previous-theme:before{font:400 20px/1 dashicons;content:"\f341";position:relative;top:6px;left:14px}.theme-install-overlay .next-theme:before{font:400 20px/1 dashicons;content:"\f345";position:relative;top:6px;left:13px}.theme-install-overlay .next-theme.disabled,.theme-install-overlay .next-theme.disabled:focus,.theme-install-overlay .next-theme.disabled:hover,.theme-install-overlay .previous-theme.disabled,.theme-install-overlay .previous-theme.disabled:focus,.theme-install-overlay .previous-theme.disabled:hover{color:#b4b9be;background:#eee;cursor:default;pointer-events:none}.theme-install-overlay .close-full-overlay,.theme-install-overlay .next-theme,.theme-install-overlay .previous-theme{border-left:0;border-top:0;border-bottom:0}.theme-install-overlay .close-full-overlay:before,.theme-install-overlay .next-theme:before,.theme-install-overlay .previous-theme:before{top:2px;left:0}.wp-core-ui .wp-full-overlay .collapse-sidebar{position:fixed;bottom:0;left:0;padding:9px 0 9px 10px;height:45px;color:#656a6f;outline:0;line-height:1;background-color:transparent!important;border:none!important;box-shadow:none!important;border-radius:0!important}.wp-core-ui .wp-full-overlay .collapse-sidebar:focus,.wp-core-ui .wp-full-overlay .collapse-sidebar:hover{color:#0073aa}.wp-full-overlay .collapse-sidebar-arrow,.wp-full-overlay .collapse-sidebar-label{display:inline-block;vertical-align:middle;line-height:20px}.wp-full-overlay .collapse-sidebar-arrow{width:20px;height:20px;margin:0 2px;border-radius:50%;overflow:hidden}.wp-full-overlay .collapse-sidebar:focus .collapse-sidebar-arrow,.wp-full-overlay .collapse-sidebar:hover .collapse-sidebar-arrow{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.wp-full-overlay .collapse-sidebar-label{margin-left:3px}.wp-full-overlay.collapsed .collapse-sidebar-label{display:none}.wp-full-overlay .collapse-sidebar-arrow:before{display:block;content:"\f148";background:#eee;font:400 20px/1 dashicons;speak:none;padding:0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-core-ui .wp-full-overlay.collapsed .collapse-sidebar{padding:9px 10px}.rtl .wp-full-overlay .collapse-sidebar-arrow:before,.wp-full-overlay.collapsed .collapse-sidebar-arrow:before{-webkit-transform:rotate(180.001deg);transform:rotate(180.001deg)}.rtl .wp-full-overlay.collapsed .collapse-sidebar-arrow:before{-webkit-transform:none;transform:none}.wp-full-overlay,.wp-full-overlay .collapse-sidebar,.wp-full-overlay-main,.wp-full-overlay-sidebar{transition-property:left,right,top,bottom,width,margin;transition-duration:.2s}.wp-full-overlay{background:#191e23}.wp-full-overlay-main{background-color:#f1f1f1}.expanded .wp-full-overlay-footer{position:fixed;bottom:0;left:0;min-width:299px;max-width:599px;width:18%;width:calc(18% - 1px);height:45px;border-top:1px solid #ddd;background:#eee}.wp-full-overlay-footer .devices-wrapper{float:right}.wp-full-overlay-footer .devices{position:relative;background:#eee;box-shadow:-20px 0 10px -5px #eee}.wp-full-overlay-footer .devices button{cursor:pointer;background:0 0;border:none;height:45px;padding:0 3px;margin:0 0 0 -4px;box-shadow:none;border-top:1px solid transparent;border-bottom:4px solid transparent;transition:.15s color ease-in-out,.15s background-color ease-in-out,.15s border-color ease-in-out}.wp-full-overlay-footer .devices button:focus{box-shadow:none;outline:0}.wp-full-overlay-footer .devices button:before{display:inline-block;-webkit-font-smoothing:antialiased;font:400 20px/30px dashicons;vertical-align:top;margin:3px 0;padding:4px 8px;color:#656a6f}#customize-container,.customize-support .hide-if-customize,.customize-support .wp-core-ui .hide-if-customize,.customize-support.wp-core-ui .hide-if-customize,.no-customize-support .hide-if-no-customize,.no-customize-support .wp-core-ui .hide-if-no-customize,.no-customize-support.wp-core-ui .hide-if-no-customize,.theme-install-overlay{display:none}.wp-full-overlay-footer .devices button.active{border-bottom-color:#191e23}.wp-full-overlay-footer .devices button:focus,.wp-full-overlay-footer .devices button:hover{background-color:#fff}.wp-full-overlay-footer .devices button.active:hover,.wp-full-overlay-footer .devices button:focus{border-bottom-color:#0073aa}.wp-full-overlay-footer .devices button.active:before{color:#191e23}.wp-full-overlay-footer .devices button:focus:before,.wp-full-overlay-footer .devices button:hover:before{color:#0073aa}.wp-full-overlay-footer .devices .preview-desktop:before{content:"\f472"}.wp-full-overlay-footer .devices .preview-tablet:before{content:"\f471"}.wp-full-overlay-footer .devices .preview-mobile:before{content:"\f470"}@media screen and (max-width:1024px){.wp-full-overlay-footer .devices{display:none}}.collapsed .wp-full-overlay-footer .devices button:before{display:none}.preview-mobile .wp-full-overlay-main{margin:auto 0 auto -160px;width:320px;height:480px;max-height:100%;max-width:100%;left:50%}.preview-tablet .wp-full-overlay-main{margin:auto 0 auto -360px;width:720px;height:1080px;max-height:100%;max-width:100%;left:50%}#customize-container,#customize-controls .notice.notification-overlay{background:#eee;z-index:500000;position:fixed;overflow:visible;top:0;bottom:0;left:0;right:0;height:100%}#customize-container,.theme-install-overlay{visibility:visible}.customize-loading #customize-container iframe{opacity:0}#customize-container iframe,.theme-install-overlay iframe{height:100%;width:100%;z-index:20;transition:opacity .3s}#customize-controls{margin-top:0}.theme-install-overlay.single-theme{display:block}.install-theme-info{display:none;padding:10px 20px 60px}.single-theme .install-theme-info{padding-top:15px}.theme-install-overlay .install-theme-info{display:block}.install-theme-info .theme-install{float:right;margin-top:18px}.install-theme-info .theme-name{font-size:16px;line-height:24px;margin-bottom:0;margin-top:0}.install-theme-info .theme-screenshot{margin:15px 0;width:258px;border:1px solid #ccc}.install-theme-info .theme-details{overflow:hidden}.theme-details .theme-version{margin:15px 0}.theme-details .theme-description{float:left;color:#72777c;line-height:20px;max-width:100%}.theme-install-overlay .wp-full-overlay-header .button{float:right;margin:8px 10px 0 0;line-height:26px}.theme-install-overlay .wp-full-overlay-sidebar{background:#eee;border-right:1px solid #ddd}.theme-install-overlay .wp-full-overlay-sidebar-content{background:#fff;border-top:1px solid #ddd;border-bottom:1px solid #ddd}.theme-install-overlay .wp-full-overlay-main{position:absolute;z-index:0;background-color:#f1f1f1}.customize-loading #customize-container{background-color:#f1f1f1}#customize-controls .notice.notification-overlay.notification-loading:before,#customize-preview.wp-full-overlay-main:before,.customize-loading #customize-container:before,.theme-install-overlay .wp-full-overlay-main:before{content:"";display:block;width:20px;height:20px;position:absolute;left:50%;top:50%;z-index:-1;margin:-10px 0 0 -10px;-webkit-transform:translateZ(0);transform:translateZ(0);background:url(../images/spinner.gif) center center no-repeat;background-size:20px 20px}#customize-preview.wp-full-overlay-main.iframe-ready:before,.theme-install-overlay.iframe-ready .wp-full-overlay-main:before{background-image:none}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-full-overlay .collapse-sidebar-arrow{background-image:url(../images/arrows-2x.png);background-size:15px 123px}#customize-controls .notice.notification-overlay.notification-loading:before,#customize-preview.wp-full-overlay-main:before,.customize-loading #customize-container:before,.theme-install-overlay .wp-full-overlay-main:before{background-image:url(../images/spinner-2x.gif)}}@media screen and (max-width:782px){.available-theme .action-links .delete-theme{float:none;margin:0;padding:0;clear:both}.available-theme .action-links .delete-theme a{padding:0}.broken-themes table{width:100%}.theme-install-overlay .wp-full-overlay-header .theme-install{margin-top:6px;line-height:normal}.theme-browser .theme .theme-actions .button{margin-bottom:0}.theme-browser .theme .theme-actions,.theme-browser .theme.active .theme-actions{padding-top:8px;padding-bottom:8px}}@media aural{.theme .notice:before,.theme-info .updated-message:before,.theme-info .updating-message:before,.theme-install.updating-message:before{speak:none}} \ No newline at end of file diff --git a/backend/wp-admin/css/widgets-rtl.css b/backend/wp-admin/css/widgets-rtl.css new file mode 100644 index 0000000..f90b6cb --- /dev/null +++ b/backend/wp-admin/css/widgets-rtl.css @@ -0,0 +1,834 @@ +/* General Widgets Styles */ + +.widget { + margin: 0 auto 10px; + position: relative; + box-sizing: border-box; +} + +.widget-top { + font-size: 13px; + font-weight: 600; + background: #f7f7f7; +} + +.widget-top .widget-action { + border: 0; + margin: 0; + padding: 10px; + background: none; + cursor: pointer; + outline: none; +} + +.widget-title h3, +.widget-title h4 { + margin: 0; + padding: 15px; + font-size: 1em; + line-height: 1; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.widgets-holder-wrap .widget-inside { + border-top: none; + padding: 1px 15px 15px 15px; + line-height: 16px; +} + +.widget.widget-dirty .widget-control-close-wrapper { + display: none; +} + +.in-widget-title, +#widgets-right a.widget-control-edit, +#available-widgets .widget-description { + color: #666; +} + +.deleting .widget-title, +.deleting .widget-top .widget-action .toggle-indicator:before { + color: #a0a5aa; +} + +/* Media Widgets */ +.wp-core-ui .media-widget-control.selected .placeholder, +.wp-core-ui .media-widget-control.selected .not-selected, +.wp-core-ui .media-widget-control .selected { + display: none; +} + +.media-widget-control.selected .selected { + display: inline-block; +} + +.media-widget-buttons { + text-align: right; + margin-top: 0; +} + +.media-widget-control .media-widget-buttons .button { + width: auto; + height: auto; + margin-top: 12px; + white-space: normal; +} + +.media-widget-buttons .button:first-child { + margin-left: 8px; +} + +.media-widget-control .placeholder { + border: 1px dashed #b4b9be; + box-sizing: border-box; + cursor: pointer; + line-height: 20px; + padding: 9px 0; + position: relative; + text-align: center; + width: 100%; +} + +.media-widget-control .media-widget-preview { + background: transparent; + text-align: center; +} +.media-widget-control .media-widget-preview .notice { + text-align: initial; +} +.media-frame .media-widget-embed-notice p code, +.media-widget-control .notice p code { + padding: 0 0 0 3px; +} +.media-frame .media-widget-embed-notice { + margin-top: 16px; +} +.media-widget-control .media-widget-preview img { + max-width: 100%; + vertical-align: middle; +} +.media-widget-control .media-widget-preview .wp-video-shortcode { + background: #000; +} + +.media-frame.media-widget .media-toolbar-secondary { + min-width: 300px; +} + +.media-frame.media-widget .image-details .embed-media-settings .setting.align, +.media-frame.media-widget .attachment-display-settings .setting.align, +.media-frame.media-widget .embed-media-settings .setting.align, +.media-frame.media-widget .embed-link-settings .setting.link-text, +.media-frame.media-widget .replace-attachment, +.media-frame.media-widget .checkbox-setting.autoplay { + display: none; +} + +.media-widget-video-preview { + width: 100%; +} + +.media-widget-video-link { + display: inline-block; + min-height: 132px; + width: 100%; + background: black; +} + +.media-widget-video-link .dashicons { + font: normal 60px/1 'dashicons'; + position: relative; + width: 100%; + top: -90px; + color: white; + text-decoration: none; +} + +.media-widget-video-link.no-poster .dashicons { + top: 30px; +} + +.media-frame #embed-url-field.invalid, +.media-widget-image-link > .link:invalid { + border: 1px solid #dc3232; +} + +.media-widget-image-link { + margin: 1em 0; +} + +.media-widget-gallery-preview { + display: -webkit-box; + display: flex; + -webkit-box-pack: start; + justify-content: flex-start; + flex-wrap: wrap; + margin: -1.79104477%; +} + +.media-widget-preview.media_gallery, +.media-widget-preview.media_image { + cursor: pointer; +} + +.media-widget-preview .placeholder { + background: #f1f1f1; +} + +.media-widget-gallery-preview .gallery-item { + box-sizing: border-box; + width: 50%; + margin: 0; + background: transparent; +} + +.media-widget-gallery-preview .gallery-item .gallery-icon { + margin: 4.5%; +} + +/* + * Use targeted nth-last-child selectors to control the size of each image + * based on how many gallery items are present in the grid. + * See: https://alistapart.com/article/quantity-queries-for-css + */ +.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child, +.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child ~ .gallery-item, +.media-widget-gallery-preview .gallery-item:nth-last-child(n+5), +.media-widget-gallery-preview .gallery-item:nth-last-child(n+5) ~ .gallery-item, +.media-widget-gallery-preview .gallery-item:nth-last-child(n+6), +.media-widget-gallery-preview .gallery-item:nth-last-child(n+6) ~ .gallery-item { + max-width: 33.33%; +} + +.media-widget-gallery-preview .gallery-item img { + height: auto; + vertical-align: bottom; +} + +.media-widget-gallery-preview .gallery-icon { + position: relative; +} + +.media-widget-gallery-preview .gallery-icon-placeholder { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + box-sizing: border-box; + display: -webkit-box; + display: flex; + -webkit-box-align: center; + align-items: center; + -webkit-box-pack: center; + justify-content: center; + background-color: rgba( 0, 0, 0, .5 ); +} + +.media-widget-gallery-preview .gallery-icon-placeholder-text { + font-weight: 600; + font-size: 2em; + color: white; +} + + +/* Widget Dragging Helpers */ +.widget.ui-draggable-dragging { + min-width: 100%; +} + +.widget.ui-sortable-helper { + opacity: 0.8; +} + +.widget-placeholder { + border: 1px dashed #b4b9be; + margin: 0 auto 10px; + height: 45px; + width: 100%; + box-sizing: border-box; +} + +#widgets-right .widget-placeholder { + margin-top: 0; +} + +#widgets-right .closed .widget-placeholder { + height: 0; + border: 0; + margin-top: -10px; +} + +/* Widget Sidebars */ +.sidebar-name { + position: relative; + box-sizing: border-box; +} + +.js .sidebar-name { + cursor: pointer; +} + +.sidebar-name .handlediv { + float: left; + width: 38px; + height: 38px; + border: 0; + margin: 0; + padding: 8px; + background: none; + cursor: pointer; + outline: none; +} + +#widgets-right .sidebar-name .handlediv { + margin: 5px 0 0 3px; +} + +.sidebar-name .handlediv:focus { + box-shadow: none; + outline: none; +} + +#widgets-left .sidebar-name .toggle-indicator { + display: none; +} + +#widgets-left .widgets-holder-wrap.closed .sidebar-name .toggle-indicator, +#widgets-left .sidebar-name:hover .toggle-indicator, +#widgets-left .sidebar-name .handlediv:focus .toggle-indicator { + display: block; +} + +.sidebar-name .toggle-indicator:before { + padding: 1px 0 1px 2px; + border-radius: 50%; +} + +.sidebar-name .handlediv:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.sidebar-name h2, +.sidebar-name h3 { + margin: 0; + padding: 8px 10px; + overflow: hidden; + white-space: nowrap; +} + +.widgets-holder-wrap .description { + padding: 0 0 15px; + margin: 0; + font-style: normal; + color: #72777c; +} + +.widget-holder .description, +.inactive-sidebar .description { + color: #555d66; +} + +#widgets-right .widgets-holder-wrap .description { + padding-right: 7px; + padding-left: 7px; +} + +/* Widgets 2-col Layout */ +div.widget-liquid-left { + margin: 0; + width: 38%; + float: right; +} + +div.widget-liquid-right { + float: left; + width: 58%; +} + +/* Widgets Left - Available Widgets */ + +div#widgets-left { + padding-top: 12px; +} + +div#widgets-left .closed .sidebar-name, +div#widgets-left .inactive-sidebar.closed .sidebar-name { + margin-bottom: 10px; +} + +div#widgets-left .sidebar-name h2, +div#widgets-left .sidebar-name h3 { + padding: 10px 0; + margin: 0 0 0 10px; +} + +#widgets-left .widgets-holder-wrap, +div#widgets-left .widget-holder { + background: transparent; + border: none; +} + +#widgets-left .widgets-holder-wrap { + border: none; + box-shadow: none; +} + +#available-widgets .widget-action { + display: none; +} + +#available-widgets .widget { + margin: 0; +} + +#available-widgets .widget:nth-child(odd) { + clear: both; +} + +#available-widgets .widget .widget-description { + display: block; + padding: 10px 15px; + font-size: 12px; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; + -ms-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +#available-widgets #widget-list { + position: relative; +} + +/* Inactive Sidebars */ +#widgets-left .inactive-sidebar { + clear: both; + width: 100%; + background: transparent; + padding: 0; + margin: 0 0 20px 0; + border: none; + box-shadow: none; +} + +#widgets-left .inactive-sidebar.first { + margin-top: 40px; +} + +/* Not sure what this is for... */ +div#widgets-left .inactive-sidebar .widget.expanded { + right: auto; +} + +.widget-title-action { + float: left; + position: relative; +} + +div#widgets-left .inactive-sidebar .widgets-sortables { + min-height: 42px; + padding: 0; + background: transparent; + margin: 0; + position: relative; +} + +/* Widgets Right */ + +div#widgets-right .sidebars-column-1, +div#widgets-right .sidebars-column-2 { + max-width: 450px; +} + +div#widgets-right .widgets-holder-wrap { + margin: 10px 0 0 0; +} + +div#widgets-right .sidebar-description { + min-height: 20px; + margin-top: -5px; +} + +div#widgets-right .sidebar-name h2, +div#widgets-right .sidebar-name h3 { + padding: 15px 7px; +} + +div#widgets-right .widget-top { + padding: 0; +} + +div#widgets-right .widgets-sortables { + padding: 0 8px; + margin-bottom: 9px; + position: relative; + min-height: 123px; +} + +div#widgets-right .closed .widgets-sortables { + min-height: 0; + margin-bottom: 0; +} + +.sidebar-name .spinner, +.remove-inactive-widgets .spinner { + float: none; + position: relative; + top: -2px; + margin: -5px 5px; +} + +/* Dragging a widget over a closed sidebar */ +#widgets-right .widgets-holder-wrap.widget-hover { + border-color: #72777c; + box-shadow: 0 1px 2px rgba(0,0,0,0.3); +} + +/* Accessibility Mode */ +.widgets_access #widgets-left .widget .widget-top { + cursor: auto; +} + +.widgets_access #wpwrap .widgets-holder-wrap.closed .sidebar-description, +.widgets_access #wpwrap .widgets-holder-wrap.closed .widget, +.widgets_access #wpwrap .widget-control-edit { + display: block; +} + +.widgets_access #widgets-left .widget .widget-top:hover, +.widgets_access #widgets-right .widget .widget-top:hover { + border-color: #ddd; +} + +#available-widgets .widget-control-edit .edit, +#widgets-left .inactive-sidebar .widget-control-edit .add, +#widgets-right .widget-control-edit .add { + display: none; +} + +.widget-control-edit { + display: block; + color: #666; + background: #EEE; + padding: 0 15px; + line-height: 43px; + border-right: 1px solid #DDD; +} + +#widgets-left .widget-control-edit:hover, +#widgets-right .widget-control-edit:hover { + color: #fff; + background: #444; + border-right: 0; + outline: 1px solid #444; +} + +.widgets-holder-wrap .sidebar-name, +.widgets-holder-wrap .sidebar-description { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.editwidget { + margin: 0 auto; +} + +.editwidget .widget-inside { + display: block; + padding: 0 15px; +} + +.editwidget .widget-control-actions { + margin-top: 20px; +} + +.js .widgets-holder-wrap.closed .widget, +.js .widgets-holder-wrap.closed .sidebar-description, +.js .widgets-holder-wrap.closed .remove-inactive-widgets, +.js .widgets-holder-wrap.closed .description, +.js .closed br.clear { + display: none; +} + +.js .widgets-holder-wrap.closed .widget.ui-sortable-helper { + display: block; +} + +/* Hide Widget Settings by Default */ +.widget-inside, +.widget-description { + display: none; +} + +.widget-inside { + background: #fff; +} + +/* Dragging widgets over the available widget area show's a "Deactivate" message */ +#removing-widget { + display: none; + font-weight: 400; + padding-right: 15px; + font-size: 12px; + line-height: 1; + color: black; +} + +.js #removing-widget { + color: #00a0d2; +} + +.widget-control-noform, +#access-off, +.widgets_access .widget-action, +.widgets_access .handlediv, +.widgets_access #access-on, +.widgets_access .widget-holder .description, +.no-js .widget-holder .description { + display: none; +} + +.widgets_access .widget-holder, +.widgets_access #widget-list { + padding-top: 10px; +} + +.widgets_access #access-off { + display: inline; +} + +.widgets_access .sidebar-name, +.widgets_access .widget .widget-top { + cursor: default; +} + + +/* Widgets Area Chooser */ +.widget-liquid-left #widgets-left.chooser #available-widgets .widget, +.widget-liquid-left #widgets-left.chooser .inactive-sidebar { + transition: opacity 0.1s linear; +} + +.widget-liquid-left #widgets-left.chooser #available-widgets .widget, +.widget-liquid-left #widgets-left.chooser .inactive-sidebar { + /* -webkit-filter: blur(1px); */ + opacity: 0.2; + pointer-events: none; +} + +.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question { + /* -webkit-filter: none; */ + opacity: 1; + pointer-events: auto; +} + +.widgets-chooser ul, +#widgets-left .widget-in-question .widget-top, +#available-widgets .widget-top:hover, +div#widgets-right .widget-top:hover, +#widgets-left .widget-top:hover { + border-color: #999; + box-shadow: 0 1px 2px rgba(0,0,0,0.1); +} + +.widgets-chooser ul.widgets-chooser-sidebars { + margin: 0; + list-style-type: none; + max-height: 300px; + overflow: auto; +} + +.widgets-chooser { + display: none; +} + +.widgets-chooser ul { + border: 1px solid #ccc; +} + +.widgets-chooser li { + padding: 10px 35px 10px 15px; + border-bottom: 1px solid #ccc; + background: #fff; + margin: 0; + cursor: pointer; + outline: none; + position: relative; + transition: background 0.2s ease-in-out; +} + + /* @todo looks like these hover/focus states are overridden by .widgets-chooser-selected */ +.widgets-chooser li:hover, +.widgets-chooser li:focus { + background: rgba(255,255,255,0.7); +} + +.widgets-chooser li:focus:before { + content: "\f147"; + display: block; + -webkit-font-smoothing: antialiased; + font: normal 26px/1 dashicons; + color: #555d66; + position: absolute; + top: 7px; + right: 5px; +} + +.widgets-chooser li:last-child { + border: none; +} + +.widgets-chooser li.widgets-chooser-selected { + background: #00a0d2; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + content: "\f147"; + display: block; + -webkit-font-smoothing: antialiased; + font: normal 26px/1 dashicons; + color: #fff; + position: absolute; + top: 7px; + right: 5px; +} + +.widgets-chooser .widgets-chooser-actions { + padding: 10px 0 12px 0; + text-align: center; +} + +.widgets-chooser button { + margin-left: 5px; +} + +#available-widgets .widget .widget-top { + cursor: pointer; +} + +#available-widgets .widget.ui-draggable-dragging .widget-top { + cursor: move; +} + +/* =Specific widget styling +-------------------------------------------------------------- */ +.text-widget-fields { + position: relative; +} +.text-widget-fields [hidden] { + display: none; +} +.text-widget-fields .wp-pointer.wp-pointer-top { + position: absolute; + z-index: 3; + top: 100px; + left: 10px; + right: 10px; +} +.text-widget-fields .wp-pointer .wp-pointer-arrow { + right: auto; + left: 15px; +} +.text-widget-fields .wp-pointer .wp-pointer-buttons { + line-height: 1.4em; +} + +.custom-html-widget-fields > p > .CodeMirror { + border: 1px solid #e5e5e5; +} +.custom-html-widget-fields code { + padding-top: 1px; + padding-bottom: 1px; +} +ul.CodeMirror-hints { + z-index: 101; /* Due to z-index 100 set on .widget.open */ +} +.widget-control-actions .custom-html-widget-save-button.button.validation-blocked { + cursor: not-allowed; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and (max-width: 480px) { + div.widget-liquid-left { + width: 100%; + float: none; + border-left: none; + padding-left: 0; + } + + #widgets-left .sidebar-name { + margin-left: 0; + } + + #widgets-left #available-widgets .widget-top { + margin-left: 0; + } + + #widgets-left .inactive-sidebar .widgets-sortables { + margin-left: 0; + } + + div.widget-liquid-right { + width: 100%; + float: none; + } + + div.widget { + margin: 0 auto !important; + max-width: 480px; + } +} + +@media screen and (max-width: 320px) { + div.widget { + max-width: 320px; + } +} + +@media only screen and (min-width: 1250px) { + #widgets-left #available-widgets .widget { + width: 49%; + float: right; + } + + .widget.ui-draggable-dragging { + min-width: 49%; + } + + #widgets-left #available-widgets .widget:nth-child(even) { + float: left; + } + + #widgets-right .sidebars-column-1, + #widgets-right .sidebars-column-2 { + float: right; + width: 49%; + } + + #widgets-right .sidebars-column-1 { + margin-left: 2%; + } + + #widgets-right.single-sidebar .sidebars-column-1, + #widgets-right.single-sidebar .sidebars-column-2 { + float: none; + width: 100%; + margin: 0; + } +} diff --git a/backend/wp-admin/css/widgets-rtl.min.css b/backend/wp-admin/css/widgets-rtl.min.css new file mode 100644 index 0000000..8889b84 --- /dev/null +++ b/backend/wp-admin/css/widgets-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.widget.widget-dirty .widget-control-close-wrapper,.wp-core-ui .media-widget-control .selected,.wp-core-ui .media-widget-control.selected .not-selected,.wp-core-ui .media-widget-control.selected .placeholder{display:none}.widget{margin:0 auto 10px;position:relative;box-sizing:border-box}.widget-top{font-size:13px;font-weight:600;background:#f7f7f7}.widget-top .widget-action{border:0;margin:0;padding:10px;background:0 0;cursor:pointer;outline:0}.widget-title h3,.widget-title h4{margin:0;padding:15px;font-size:1em;line-height:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.widgets-holder-wrap .widget-inside{border-top:none;padding:1px 15px 15px;line-height:16px}#available-widgets .widget-description,#widgets-right a.widget-control-edit,.in-widget-title{color:#666}.deleting .widget-title,.deleting .widget-top .widget-action .toggle-indicator:before{color:#a0a5aa}.media-widget-control.selected .selected{display:inline-block}.media-widget-buttons{text-align:right;margin-top:0}.media-widget-control .media-widget-buttons .button{width:auto;height:auto;margin-top:12px;white-space:normal}.media-widget-buttons .button:first-child{margin-left:8px}.media-widget-control .placeholder{border:1px dashed #b4b9be;box-sizing:border-box;cursor:pointer;line-height:20px;padding:9px 0;position:relative;text-align:center;width:100%}.media-widget-control .media-widget-preview{background:0 0;text-align:center}.media-widget-control .media-widget-preview .notice{text-align:initial}.media-frame .media-widget-embed-notice p code,.media-widget-control .notice p code{padding:0 0 0 3px}.media-frame .media-widget-embed-notice{margin-top:16px}.media-widget-control .media-widget-preview img{max-width:100%;vertical-align:middle}.media-widget-control .media-widget-preview .wp-video-shortcode{background:#000}.media-frame.media-widget .media-toolbar-secondary{min-width:300px}.media-frame.media-widget .attachment-display-settings .setting.align,.media-frame.media-widget .checkbox-setting.autoplay,.media-frame.media-widget .embed-link-settings .setting.link-text,.media-frame.media-widget .embed-media-settings .setting.align,.media-frame.media-widget .image-details .embed-media-settings .setting.align,.media-frame.media-widget .replace-attachment{display:none}.media-widget-video-preview{width:100%}.media-widget-video-link{display:inline-block;min-height:132px;width:100%;background:#000}.media-widget-video-link .dashicons{font:400 60px/1 dashicons;position:relative;width:100%;top:-90px;color:#fff;text-decoration:none}.media-widget-video-link.no-poster .dashicons{top:30px}.media-frame #embed-url-field.invalid,.media-widget-image-link>.link:invalid{border:1px solid #dc3232}.media-widget-image-link{margin:1em 0}.media-widget-gallery-preview{display:-webkit-box;display:flex;-webkit-box-pack:start;justify-content:flex-start;flex-wrap:wrap;margin:-1.79104477%}.media-widget-preview.media_gallery,.media-widget-preview.media_image{cursor:pointer}.media-widget-preview .placeholder{background:#f1f1f1}.media-widget-gallery-preview .gallery-item{box-sizing:border-box;width:50%;margin:0;background:0 0}.media-widget-gallery-preview .gallery-item .gallery-icon{margin:4.5%}.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child,.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child~.gallery-item,.media-widget-gallery-preview .gallery-item:nth-last-child(n+5),.media-widget-gallery-preview .gallery-item:nth-last-child(n+5)~.gallery-item,.media-widget-gallery-preview .gallery-item:nth-last-child(n+6),.media-widget-gallery-preview .gallery-item:nth-last-child(n+6)~.gallery-item{max-width:33.33%}.media-widget-gallery-preview .gallery-item img{height:auto;vertical-align:bottom}.media-widget-gallery-preview .gallery-icon{position:relative}.media-widget-gallery-preview .gallery-icon-placeholder{position:absolute;top:0;bottom:0;width:100%;box-sizing:border-box;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;background-color:rgba(0,0,0,.5)}.media-widget-gallery-preview .gallery-icon-placeholder-text{font-weight:600;font-size:2em;color:#fff}.widget.ui-draggable-dragging{min-width:100%}.widget.ui-sortable-helper{opacity:.8}.widget-placeholder{border:1px dashed #b4b9be;margin:0 auto 10px;height:45px;width:100%;box-sizing:border-box}#widgets-right .widget-placeholder{margin-top:0}#widgets-right .closed .widget-placeholder{height:0;border:0;margin-top:-10px}.sidebar-name{position:relative;box-sizing:border-box}.js .sidebar-name{cursor:pointer}.sidebar-name .handlediv{float:left;width:38px;height:38px;border:0;margin:0;padding:8px;background:0 0;cursor:pointer;outline:0}#widgets-right .sidebar-name .handlediv{margin:5px 0 0 3px}.sidebar-name .handlediv:focus{box-shadow:none;outline:0}#widgets-left .sidebar-name .toggle-indicator{display:none}#widgets-left .sidebar-name .handlediv:focus .toggle-indicator,#widgets-left .sidebar-name:hover .toggle-indicator,#widgets-left .widgets-holder-wrap.closed .sidebar-name .toggle-indicator{display:block}.sidebar-name .toggle-indicator:before{padding:1px 0 1px 2px;border-radius:50%}.sidebar-name .handlediv:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.sidebar-name h2,.sidebar-name h3{margin:0;padding:8px 10px;overflow:hidden;white-space:nowrap}.widgets-holder-wrap .description{padding:0 0 15px;margin:0;font-style:normal;color:#72777c}.inactive-sidebar .description,.widget-holder .description{color:#555d66}#widgets-right .widgets-holder-wrap .description{padding-right:7px;padding-left:7px}div.widget-liquid-left{margin:0;width:38%;float:right}div.widget-liquid-right{float:left;width:58%}div#widgets-left{padding-top:12px}div#widgets-left .closed .sidebar-name,div#widgets-left .inactive-sidebar.closed .sidebar-name{margin-bottom:10px}div#widgets-left .sidebar-name h2,div#widgets-left .sidebar-name h3{padding:10px 0;margin:0 0 0 10px}#widgets-left .widgets-holder-wrap,div#widgets-left .widget-holder{background:0 0;border:none}#widgets-left .widgets-holder-wrap{border:none;box-shadow:none}#available-widgets .widget-action{display:none}#available-widgets .widget{margin:0}#available-widgets .widget:nth-child(odd){clear:both}#available-widgets .widget .widget-description{display:block;padding:10px 15px;font-size:12px;overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}#available-widgets #widget-list{position:relative}#widgets-left .inactive-sidebar{clear:both;width:100%;background:0 0;padding:0;margin:0 0 20px;border:none;box-shadow:none}#widgets-left .inactive-sidebar.first{margin-top:40px}div#widgets-left .inactive-sidebar .widget.expanded{right:auto}.widget-title-action{float:left;position:relative}div#widgets-left .inactive-sidebar .widgets-sortables{min-height:42px;padding:0;background:0 0;margin:0;position:relative}div#widgets-right .sidebars-column-1,div#widgets-right .sidebars-column-2{max-width:450px}div#widgets-right .widgets-holder-wrap{margin:10px 0 0}div#widgets-right .sidebar-description{min-height:20px;margin-top:-5px}div#widgets-right .sidebar-name h2,div#widgets-right .sidebar-name h3{padding:15px 7px}div#widgets-right .widget-top{padding:0}div#widgets-right .widgets-sortables{padding:0 8px;margin-bottom:9px;position:relative;min-height:123px}div#widgets-right .closed .widgets-sortables{min-height:0;margin-bottom:0}.remove-inactive-widgets .spinner,.sidebar-name .spinner{float:none;position:relative;top:-2px;margin:-5px 5px}#widgets-right .widgets-holder-wrap.widget-hover{border-color:#72777c;box-shadow:0 1px 2px rgba(0,0,0,.3)}.widgets_access #widgets-left .widget .widget-top{cursor:auto}.widgets_access #wpwrap .widget-control-edit,.widgets_access #wpwrap .widgets-holder-wrap.closed .sidebar-description,.widgets_access #wpwrap .widgets-holder-wrap.closed .widget{display:block}.widgets_access #widgets-left .widget .widget-top:hover,.widgets_access #widgets-right .widget .widget-top:hover{border-color:#ddd}#available-widgets .widget-control-edit .edit,#widgets-left .inactive-sidebar .widget-control-edit .add,#widgets-right .widget-control-edit .add{display:none}.editwidget .widget-inside,.widget-control-edit{display:block;padding:0 15px}.widget-control-edit{color:#666;background:#EEE;line-height:43px;border-right:1px solid #DDD}#widgets-left .widget-control-edit:hover,#widgets-right .widget-control-edit:hover{color:#fff;background:#444;border-right:0;outline:#444 solid 1px}.widgets-holder-wrap .sidebar-description,.widgets-holder-wrap .sidebar-name{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.editwidget{margin:0 auto}.editwidget .widget-control-actions{margin-top:20px}.js .closed br.clear,.js .widgets-holder-wrap.closed .description,.js .widgets-holder-wrap.closed .remove-inactive-widgets,.js .widgets-holder-wrap.closed .sidebar-description,.js .widgets-holder-wrap.closed .widget{display:none}.js .widgets-holder-wrap.closed .widget.ui-sortable-helper{display:block}#access-off,.no-js .widget-holder .description,.widget-control-noform,.widget-description,.widget-inside,.widgets_access #access-on,.widgets_access .handlediv,.widgets_access .widget-action,.widgets_access .widget-holder .description{display:none}.widget-inside{background:#fff}#removing-widget{display:none;font-weight:400;padding-right:15px;font-size:12px;line-height:1;color:#000}.js #removing-widget{color:#00a0d2}.widgets_access #widget-list,.widgets_access .widget-holder{padding-top:10px}.widgets_access #access-off{display:inline}.widgets_access .sidebar-name,.widgets_access .widget .widget-top{cursor:default}.widget-liquid-left #widgets-left.chooser #available-widgets .widget,.widget-liquid-left #widgets-left.chooser .inactive-sidebar{transition:opacity .1s linear;opacity:.2;pointer-events:none}.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question{opacity:1;pointer-events:auto}#available-widgets .widget-top:hover,#widgets-left .widget-in-question .widget-top,#widgets-left .widget-top:hover,.widgets-chooser ul,div#widgets-right .widget-top:hover{border-color:#999;box-shadow:0 1px 2px rgba(0,0,0,.1)}.widgets-chooser ul.widgets-chooser-sidebars{margin:0;list-style-type:none;max-height:300px;overflow:auto}.widgets-chooser{display:none}.widgets-chooser ul{border:1px solid #ccc}.widgets-chooser li{padding:10px 35px 10px 15px;border-bottom:1px solid #ccc;background:#fff;margin:0;cursor:pointer;outline:0;position:relative;transition:background .2s ease-in-out}.widgets-chooser li:focus,.widgets-chooser li:hover{background:rgba(255,255,255,.7)}.widgets-chooser li:focus:before{content:"\f147";display:block;-webkit-font-smoothing:antialiased;font:400 26px/1 dashicons;color:#555d66;position:absolute;top:7px;right:5px}.widgets-chooser li:last-child{border:none}.widgets-chooser li.widgets-chooser-selected{background:#00a0d2;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{content:"\f147";display:block;-webkit-font-smoothing:antialiased;font:400 26px/1 dashicons;color:#fff;position:absolute;top:7px;right:5px}.widgets-chooser .widgets-chooser-actions{padding:10px 0 12px;text-align:center}.widgets-chooser button{margin-left:5px}#available-widgets .widget .widget-top{cursor:pointer}#available-widgets .widget.ui-draggable-dragging .widget-top{cursor:move}.text-widget-fields{position:relative}.text-widget-fields [hidden]{display:none}.text-widget-fields .wp-pointer.wp-pointer-top{position:absolute;z-index:3;top:100px;left:10px;right:10px}.text-widget-fields .wp-pointer .wp-pointer-arrow{right:auto;left:15px}.text-widget-fields .wp-pointer .wp-pointer-buttons{line-height:1.4em}.custom-html-widget-fields>p>.CodeMirror{border:1px solid #e5e5e5}.custom-html-widget-fields code{padding-top:1px;padding-bottom:1px}ul.CodeMirror-hints{z-index:101}.widget-control-actions .custom-html-widget-save-button.button.validation-blocked{cursor:not-allowed}@media screen and (max-width:480px){div.widget-liquid-left{width:100%;float:none;border-left:none;padding-left:0}#widgets-left #available-widgets .widget-top,#widgets-left .inactive-sidebar .widgets-sortables,#widgets-left .sidebar-name{margin-left:0}div.widget-liquid-right{width:100%;float:none}div.widget{margin:0 auto!important;max-width:480px}}@media screen and (max-width:320px){div.widget{max-width:320px}}@media only screen and (min-width:1250px){#widgets-left #available-widgets .widget{width:49%;float:right}.widget.ui-draggable-dragging{min-width:49%}#widgets-left #available-widgets .widget:nth-child(even){float:left}#widgets-right .sidebars-column-1,#widgets-right .sidebars-column-2{float:right;width:49%}#widgets-right .sidebars-column-1{margin-left:2%}#widgets-right.single-sidebar .sidebars-column-1,#widgets-right.single-sidebar .sidebars-column-2{float:none;width:100%;margin:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/widgets.css b/backend/wp-admin/css/widgets.css new file mode 100644 index 0000000..a4d314a --- /dev/null +++ b/backend/wp-admin/css/widgets.css @@ -0,0 +1,834 @@ +/* General Widgets Styles */ + +.widget { + margin: 0 auto 10px; + position: relative; + box-sizing: border-box; +} + +.widget-top { + font-size: 13px; + font-weight: 600; + background: #f7f7f7; +} + +.widget-top .widget-action { + border: 0; + margin: 0; + padding: 10px; + background: none; + cursor: pointer; + outline: none; +} + +.widget-title h3, +.widget-title h4 { + margin: 0; + padding: 15px; + font-size: 1em; + line-height: 1; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.widgets-holder-wrap .widget-inside { + border-top: none; + padding: 1px 15px 15px 15px; + line-height: 16px; +} + +.widget.widget-dirty .widget-control-close-wrapper { + display: none; +} + +.in-widget-title, +#widgets-right a.widget-control-edit, +#available-widgets .widget-description { + color: #666; +} + +.deleting .widget-title, +.deleting .widget-top .widget-action .toggle-indicator:before { + color: #a0a5aa; +} + +/* Media Widgets */ +.wp-core-ui .media-widget-control.selected .placeholder, +.wp-core-ui .media-widget-control.selected .not-selected, +.wp-core-ui .media-widget-control .selected { + display: none; +} + +.media-widget-control.selected .selected { + display: inline-block; +} + +.media-widget-buttons { + text-align: left; + margin-top: 0; +} + +.media-widget-control .media-widget-buttons .button { + width: auto; + height: auto; + margin-top: 12px; + white-space: normal; +} + +.media-widget-buttons .button:first-child { + margin-right: 8px; +} + +.media-widget-control .placeholder { + border: 1px dashed #b4b9be; + box-sizing: border-box; + cursor: pointer; + line-height: 20px; + padding: 9px 0; + position: relative; + text-align: center; + width: 100%; +} + +.media-widget-control .media-widget-preview { + background: transparent; + text-align: center; +} +.media-widget-control .media-widget-preview .notice { + text-align: initial; +} +.media-frame .media-widget-embed-notice p code, +.media-widget-control .notice p code { + padding: 0 3px 0 0; +} +.media-frame .media-widget-embed-notice { + margin-top: 16px; +} +.media-widget-control .media-widget-preview img { + max-width: 100%; + vertical-align: middle; +} +.media-widget-control .media-widget-preview .wp-video-shortcode { + background: #000; +} + +.media-frame.media-widget .media-toolbar-secondary { + min-width: 300px; +} + +.media-frame.media-widget .image-details .embed-media-settings .setting.align, +.media-frame.media-widget .attachment-display-settings .setting.align, +.media-frame.media-widget .embed-media-settings .setting.align, +.media-frame.media-widget .embed-link-settings .setting.link-text, +.media-frame.media-widget .replace-attachment, +.media-frame.media-widget .checkbox-setting.autoplay { + display: none; +} + +.media-widget-video-preview { + width: 100%; +} + +.media-widget-video-link { + display: inline-block; + min-height: 132px; + width: 100%; + background: black; +} + +.media-widget-video-link .dashicons { + font: normal 60px/1 'dashicons'; + position: relative; + width: 100%; + top: -90px; + color: white; + text-decoration: none; +} + +.media-widget-video-link.no-poster .dashicons { + top: 30px; +} + +.media-frame #embed-url-field.invalid, +.media-widget-image-link > .link:invalid { + border: 1px solid #dc3232; +} + +.media-widget-image-link { + margin: 1em 0; +} + +.media-widget-gallery-preview { + display: -webkit-box; + display: flex; + -webkit-box-pack: start; + justify-content: flex-start; + flex-wrap: wrap; + margin: -1.79104477%; +} + +.media-widget-preview.media_gallery, +.media-widget-preview.media_image { + cursor: pointer; +} + +.media-widget-preview .placeholder { + background: #f1f1f1; +} + +.media-widget-gallery-preview .gallery-item { + box-sizing: border-box; + width: 50%; + margin: 0; + background: transparent; +} + +.media-widget-gallery-preview .gallery-item .gallery-icon { + margin: 4.5%; +} + +/* + * Use targeted nth-last-child selectors to control the size of each image + * based on how many gallery items are present in the grid. + * See: https://alistapart.com/article/quantity-queries-for-css + */ +.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child, +.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child ~ .gallery-item, +.media-widget-gallery-preview .gallery-item:nth-last-child(n+5), +.media-widget-gallery-preview .gallery-item:nth-last-child(n+5) ~ .gallery-item, +.media-widget-gallery-preview .gallery-item:nth-last-child(n+6), +.media-widget-gallery-preview .gallery-item:nth-last-child(n+6) ~ .gallery-item { + max-width: 33.33%; +} + +.media-widget-gallery-preview .gallery-item img { + height: auto; + vertical-align: bottom; +} + +.media-widget-gallery-preview .gallery-icon { + position: relative; +} + +.media-widget-gallery-preview .gallery-icon-placeholder { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + box-sizing: border-box; + display: -webkit-box; + display: flex; + -webkit-box-align: center; + align-items: center; + -webkit-box-pack: center; + justify-content: center; + background-color: rgba( 0, 0, 0, .5 ); +} + +.media-widget-gallery-preview .gallery-icon-placeholder-text { + font-weight: 600; + font-size: 2em; + color: white; +} + + +/* Widget Dragging Helpers */ +.widget.ui-draggable-dragging { + min-width: 100%; +} + +.widget.ui-sortable-helper { + opacity: 0.8; +} + +.widget-placeholder { + border: 1px dashed #b4b9be; + margin: 0 auto 10px; + height: 45px; + width: 100%; + box-sizing: border-box; +} + +#widgets-right .widget-placeholder { + margin-top: 0; +} + +#widgets-right .closed .widget-placeholder { + height: 0; + border: 0; + margin-top: -10px; +} + +/* Widget Sidebars */ +.sidebar-name { + position: relative; + box-sizing: border-box; +} + +.js .sidebar-name { + cursor: pointer; +} + +.sidebar-name .handlediv { + float: right; + width: 38px; + height: 38px; + border: 0; + margin: 0; + padding: 8px; + background: none; + cursor: pointer; + outline: none; +} + +#widgets-right .sidebar-name .handlediv { + margin: 5px 3px 0 0; +} + +.sidebar-name .handlediv:focus { + box-shadow: none; + outline: none; +} + +#widgets-left .sidebar-name .toggle-indicator { + display: none; +} + +#widgets-left .widgets-holder-wrap.closed .sidebar-name .toggle-indicator, +#widgets-left .sidebar-name:hover .toggle-indicator, +#widgets-left .sidebar-name .handlediv:focus .toggle-indicator { + display: block; +} + +.sidebar-name .toggle-indicator:before { + padding: 1px 2px 1px 0; + border-radius: 50%; +} + +.sidebar-name .handlediv:focus .toggle-indicator:before { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.sidebar-name h2, +.sidebar-name h3 { + margin: 0; + padding: 8px 10px; + overflow: hidden; + white-space: nowrap; +} + +.widgets-holder-wrap .description { + padding: 0 0 15px; + margin: 0; + font-style: normal; + color: #72777c; +} + +.widget-holder .description, +.inactive-sidebar .description { + color: #555d66; +} + +#widgets-right .widgets-holder-wrap .description { + padding-left: 7px; + padding-right: 7px; +} + +/* Widgets 2-col Layout */ +div.widget-liquid-left { + margin: 0; + width: 38%; + float: left; +} + +div.widget-liquid-right { + float: right; + width: 58%; +} + +/* Widgets Left - Available Widgets */ + +div#widgets-left { + padding-top: 12px; +} + +div#widgets-left .closed .sidebar-name, +div#widgets-left .inactive-sidebar.closed .sidebar-name { + margin-bottom: 10px; +} + +div#widgets-left .sidebar-name h2, +div#widgets-left .sidebar-name h3 { + padding: 10px 0; + margin: 0 10px 0 0; +} + +#widgets-left .widgets-holder-wrap, +div#widgets-left .widget-holder { + background: transparent; + border: none; +} + +#widgets-left .widgets-holder-wrap { + border: none; + box-shadow: none; +} + +#available-widgets .widget-action { + display: none; +} + +#available-widgets .widget { + margin: 0; +} + +#available-widgets .widget:nth-child(odd) { + clear: both; +} + +#available-widgets .widget .widget-description { + display: block; + padding: 10px 15px; + font-size: 12px; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; + -ms-hyphens: auto; + -webkit-hyphens: auto; + hyphens: auto; +} + +#available-widgets #widget-list { + position: relative; +} + +/* Inactive Sidebars */ +#widgets-left .inactive-sidebar { + clear: both; + width: 100%; + background: transparent; + padding: 0; + margin: 0 0 20px 0; + border: none; + box-shadow: none; +} + +#widgets-left .inactive-sidebar.first { + margin-top: 40px; +} + +/* Not sure what this is for... */ +div#widgets-left .inactive-sidebar .widget.expanded { + left: auto; +} + +.widget-title-action { + float: right; + position: relative; +} + +div#widgets-left .inactive-sidebar .widgets-sortables { + min-height: 42px; + padding: 0; + background: transparent; + margin: 0; + position: relative; +} + +/* Widgets Right */ + +div#widgets-right .sidebars-column-1, +div#widgets-right .sidebars-column-2 { + max-width: 450px; +} + +div#widgets-right .widgets-holder-wrap { + margin: 10px 0 0 0; +} + +div#widgets-right .sidebar-description { + min-height: 20px; + margin-top: -5px; +} + +div#widgets-right .sidebar-name h2, +div#widgets-right .sidebar-name h3 { + padding: 15px 7px; +} + +div#widgets-right .widget-top { + padding: 0; +} + +div#widgets-right .widgets-sortables { + padding: 0 8px; + margin-bottom: 9px; + position: relative; + min-height: 123px; +} + +div#widgets-right .closed .widgets-sortables { + min-height: 0; + margin-bottom: 0; +} + +.sidebar-name .spinner, +.remove-inactive-widgets .spinner { + float: none; + position: relative; + top: -2px; + margin: -5px 5px; +} + +/* Dragging a widget over a closed sidebar */ +#widgets-right .widgets-holder-wrap.widget-hover { + border-color: #72777c; + box-shadow: 0 1px 2px rgba(0,0,0,0.3); +} + +/* Accessibility Mode */ +.widgets_access #widgets-left .widget .widget-top { + cursor: auto; +} + +.widgets_access #wpwrap .widgets-holder-wrap.closed .sidebar-description, +.widgets_access #wpwrap .widgets-holder-wrap.closed .widget, +.widgets_access #wpwrap .widget-control-edit { + display: block; +} + +.widgets_access #widgets-left .widget .widget-top:hover, +.widgets_access #widgets-right .widget .widget-top:hover { + border-color: #ddd; +} + +#available-widgets .widget-control-edit .edit, +#widgets-left .inactive-sidebar .widget-control-edit .add, +#widgets-right .widget-control-edit .add { + display: none; +} + +.widget-control-edit { + display: block; + color: #666; + background: #EEE; + padding: 0 15px; + line-height: 43px; + border-left: 1px solid #DDD; +} + +#widgets-left .widget-control-edit:hover, +#widgets-right .widget-control-edit:hover { + color: #fff; + background: #444; + border-left: 0; + outline: 1px solid #444; +} + +.widgets-holder-wrap .sidebar-name, +.widgets-holder-wrap .sidebar-description { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.editwidget { + margin: 0 auto; +} + +.editwidget .widget-inside { + display: block; + padding: 0 15px; +} + +.editwidget .widget-control-actions { + margin-top: 20px; +} + +.js .widgets-holder-wrap.closed .widget, +.js .widgets-holder-wrap.closed .sidebar-description, +.js .widgets-holder-wrap.closed .remove-inactive-widgets, +.js .widgets-holder-wrap.closed .description, +.js .closed br.clear { + display: none; +} + +.js .widgets-holder-wrap.closed .widget.ui-sortable-helper { + display: block; +} + +/* Hide Widget Settings by Default */ +.widget-inside, +.widget-description { + display: none; +} + +.widget-inside { + background: #fff; +} + +/* Dragging widgets over the available widget area show's a "Deactivate" message */ +#removing-widget { + display: none; + font-weight: 400; + padding-left: 15px; + font-size: 12px; + line-height: 1; + color: black; +} + +.js #removing-widget { + color: #00a0d2; +} + +.widget-control-noform, +#access-off, +.widgets_access .widget-action, +.widgets_access .handlediv, +.widgets_access #access-on, +.widgets_access .widget-holder .description, +.no-js .widget-holder .description { + display: none; +} + +.widgets_access .widget-holder, +.widgets_access #widget-list { + padding-top: 10px; +} + +.widgets_access #access-off { + display: inline; +} + +.widgets_access .sidebar-name, +.widgets_access .widget .widget-top { + cursor: default; +} + + +/* Widgets Area Chooser */ +.widget-liquid-left #widgets-left.chooser #available-widgets .widget, +.widget-liquid-left #widgets-left.chooser .inactive-sidebar { + transition: opacity 0.1s linear; +} + +.widget-liquid-left #widgets-left.chooser #available-widgets .widget, +.widget-liquid-left #widgets-left.chooser .inactive-sidebar { + /* -webkit-filter: blur(1px); */ + opacity: 0.2; + pointer-events: none; +} + +.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question { + /* -webkit-filter: none; */ + opacity: 1; + pointer-events: auto; +} + +.widgets-chooser ul, +#widgets-left .widget-in-question .widget-top, +#available-widgets .widget-top:hover, +div#widgets-right .widget-top:hover, +#widgets-left .widget-top:hover { + border-color: #999; + box-shadow: 0 1px 2px rgba(0,0,0,0.1); +} + +.widgets-chooser ul.widgets-chooser-sidebars { + margin: 0; + list-style-type: none; + max-height: 300px; + overflow: auto; +} + +.widgets-chooser { + display: none; +} + +.widgets-chooser ul { + border: 1px solid #ccc; +} + +.widgets-chooser li { + padding: 10px 15px 10px 35px; + border-bottom: 1px solid #ccc; + background: #fff; + margin: 0; + cursor: pointer; + outline: none; + position: relative; + transition: background 0.2s ease-in-out; +} + + /* @todo looks like these hover/focus states are overridden by .widgets-chooser-selected */ +.widgets-chooser li:hover, +.widgets-chooser li:focus { + background: rgba(255,255,255,0.7); +} + +.widgets-chooser li:focus:before { + content: "\f147"; + display: block; + -webkit-font-smoothing: antialiased; + font: normal 26px/1 dashicons; + color: #555d66; + position: absolute; + top: 7px; + left: 5px; +} + +.widgets-chooser li:last-child { + border: none; +} + +.widgets-chooser li.widgets-chooser-selected { + background: #00a0d2; + color: #fff; +} + +.widgets-chooser li.widgets-chooser-selected:before, +.widgets-chooser li.widgets-chooser-selected:focus:before { + content: "\f147"; + display: block; + -webkit-font-smoothing: antialiased; + font: normal 26px/1 dashicons; + color: #fff; + position: absolute; + top: 7px; + left: 5px; +} + +.widgets-chooser .widgets-chooser-actions { + padding: 10px 0 12px 0; + text-align: center; +} + +.widgets-chooser button { + margin-right: 5px; +} + +#available-widgets .widget .widget-top { + cursor: pointer; +} + +#available-widgets .widget.ui-draggable-dragging .widget-top { + cursor: move; +} + +/* =Specific widget styling +-------------------------------------------------------------- */ +.text-widget-fields { + position: relative; +} +.text-widget-fields [hidden] { + display: none; +} +.text-widget-fields .wp-pointer.wp-pointer-top { + position: absolute; + z-index: 3; + top: 100px; + right: 10px; + left: 10px; +} +.text-widget-fields .wp-pointer .wp-pointer-arrow { + left: auto; + right: 15px; +} +.text-widget-fields .wp-pointer .wp-pointer-buttons { + line-height: 1.4em; +} + +.custom-html-widget-fields > p > .CodeMirror { + border: 1px solid #e5e5e5; +} +.custom-html-widget-fields code { + padding-top: 1px; + padding-bottom: 1px; +} +ul.CodeMirror-hints { + z-index: 101; /* Due to z-index 100 set on .widget.open */ +} +.widget-control-actions .custom-html-widget-save-button.button.validation-blocked { + cursor: not-allowed; +} + +/* =Media Queries +-------------------------------------------------------------- */ + +@media screen and (max-width: 480px) { + div.widget-liquid-left { + width: 100%; + float: none; + border-right: none; + padding-right: 0; + } + + #widgets-left .sidebar-name { + margin-right: 0; + } + + #widgets-left #available-widgets .widget-top { + margin-right: 0; + } + + #widgets-left .inactive-sidebar .widgets-sortables { + margin-right: 0; + } + + div.widget-liquid-right { + width: 100%; + float: none; + } + + div.widget { + margin: 0 auto !important; + max-width: 480px; + } +} + +@media screen and (max-width: 320px) { + div.widget { + max-width: 320px; + } +} + +@media only screen and (min-width: 1250px) { + #widgets-left #available-widgets .widget { + width: 49%; + float: left; + } + + .widget.ui-draggable-dragging { + min-width: 49%; + } + + #widgets-left #available-widgets .widget:nth-child(even) { + float: right; + } + + #widgets-right .sidebars-column-1, + #widgets-right .sidebars-column-2 { + float: left; + width: 49%; + } + + #widgets-right .sidebars-column-1 { + margin-right: 2%; + } + + #widgets-right.single-sidebar .sidebars-column-1, + #widgets-right.single-sidebar .sidebars-column-2 { + float: none; + width: 100%; + margin: 0; + } +} diff --git a/backend/wp-admin/css/widgets.min.css b/backend/wp-admin/css/widgets.min.css new file mode 100644 index 0000000..6021b87 --- /dev/null +++ b/backend/wp-admin/css/widgets.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.widget.widget-dirty .widget-control-close-wrapper,.wp-core-ui .media-widget-control .selected,.wp-core-ui .media-widget-control.selected .not-selected,.wp-core-ui .media-widget-control.selected .placeholder{display:none}.widget{margin:0 auto 10px;position:relative;box-sizing:border-box}.widget-top{font-size:13px;font-weight:600;background:#f7f7f7}.widget-top .widget-action{border:0;margin:0;padding:10px;background:0 0;cursor:pointer;outline:0}.widget-title h3,.widget-title h4{margin:0;padding:15px;font-size:1em;line-height:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.widgets-holder-wrap .widget-inside{border-top:none;padding:1px 15px 15px;line-height:16px}#available-widgets .widget-description,#widgets-right a.widget-control-edit,.in-widget-title{color:#666}.deleting .widget-title,.deleting .widget-top .widget-action .toggle-indicator:before{color:#a0a5aa}.media-widget-control.selected .selected{display:inline-block}.media-widget-buttons{text-align:left;margin-top:0}.media-widget-control .media-widget-buttons .button{width:auto;height:auto;margin-top:12px;white-space:normal}.media-widget-buttons .button:first-child{margin-right:8px}.media-widget-control .placeholder{border:1px dashed #b4b9be;box-sizing:border-box;cursor:pointer;line-height:20px;padding:9px 0;position:relative;text-align:center;width:100%}.media-widget-control .media-widget-preview{background:0 0;text-align:center}.media-widget-control .media-widget-preview .notice{text-align:initial}.media-frame .media-widget-embed-notice p code,.media-widget-control .notice p code{padding:0 3px 0 0}.media-frame .media-widget-embed-notice{margin-top:16px}.media-widget-control .media-widget-preview img{max-width:100%;vertical-align:middle}.media-widget-control .media-widget-preview .wp-video-shortcode{background:#000}.media-frame.media-widget .media-toolbar-secondary{min-width:300px}.media-frame.media-widget .attachment-display-settings .setting.align,.media-frame.media-widget .checkbox-setting.autoplay,.media-frame.media-widget .embed-link-settings .setting.link-text,.media-frame.media-widget .embed-media-settings .setting.align,.media-frame.media-widget .image-details .embed-media-settings .setting.align,.media-frame.media-widget .replace-attachment{display:none}.media-widget-video-preview{width:100%}.media-widget-video-link{display:inline-block;min-height:132px;width:100%;background:#000}.media-widget-video-link .dashicons{font:400 60px/1 dashicons;position:relative;width:100%;top:-90px;color:#fff;text-decoration:none}.media-widget-video-link.no-poster .dashicons{top:30px}.media-frame #embed-url-field.invalid,.media-widget-image-link>.link:invalid{border:1px solid #dc3232}.media-widget-image-link{margin:1em 0}.media-widget-gallery-preview{display:-webkit-box;display:flex;-webkit-box-pack:start;justify-content:flex-start;flex-wrap:wrap;margin:-1.79104477%}.media-widget-preview.media_gallery,.media-widget-preview.media_image{cursor:pointer}.media-widget-preview .placeholder{background:#f1f1f1}.media-widget-gallery-preview .gallery-item{box-sizing:border-box;width:50%;margin:0;background:0 0}.media-widget-gallery-preview .gallery-item .gallery-icon{margin:4.5%}.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child,.media-widget-gallery-preview .gallery-item:nth-last-child(3):first-child~.gallery-item,.media-widget-gallery-preview .gallery-item:nth-last-child(n+5),.media-widget-gallery-preview .gallery-item:nth-last-child(n+5)~.gallery-item,.media-widget-gallery-preview .gallery-item:nth-last-child(n+6),.media-widget-gallery-preview .gallery-item:nth-last-child(n+6)~.gallery-item{max-width:33.33%}.media-widget-gallery-preview .gallery-item img{height:auto;vertical-align:bottom}.media-widget-gallery-preview .gallery-icon{position:relative}.media-widget-gallery-preview .gallery-icon-placeholder{position:absolute;top:0;bottom:0;width:100%;box-sizing:border-box;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;background-color:rgba(0,0,0,.5)}.media-widget-gallery-preview .gallery-icon-placeholder-text{font-weight:600;font-size:2em;color:#fff}.widget.ui-draggable-dragging{min-width:100%}.widget.ui-sortable-helper{opacity:.8}.widget-placeholder{border:1px dashed #b4b9be;margin:0 auto 10px;height:45px;width:100%;box-sizing:border-box}#widgets-right .widget-placeholder{margin-top:0}#widgets-right .closed .widget-placeholder{height:0;border:0;margin-top:-10px}.sidebar-name{position:relative;box-sizing:border-box}.js .sidebar-name{cursor:pointer}.sidebar-name .handlediv{float:right;width:38px;height:38px;border:0;margin:0;padding:8px;background:0 0;cursor:pointer;outline:0}#widgets-right .sidebar-name .handlediv{margin:5px 3px 0 0}.sidebar-name .handlediv:focus{box-shadow:none;outline:0}#widgets-left .sidebar-name .toggle-indicator{display:none}#widgets-left .sidebar-name .handlediv:focus .toggle-indicator,#widgets-left .sidebar-name:hover .toggle-indicator,#widgets-left .widgets-holder-wrap.closed .sidebar-name .toggle-indicator{display:block}.sidebar-name .toggle-indicator:before{padding:1px 2px 1px 0;border-radius:50%}.sidebar-name .handlediv:focus .toggle-indicator:before{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.sidebar-name h2,.sidebar-name h3{margin:0;padding:8px 10px;overflow:hidden;white-space:nowrap}.widgets-holder-wrap .description{padding:0 0 15px;margin:0;font-style:normal;color:#72777c}.inactive-sidebar .description,.widget-holder .description{color:#555d66}#widgets-right .widgets-holder-wrap .description{padding-left:7px;padding-right:7px}div.widget-liquid-left{margin:0;width:38%;float:left}div.widget-liquid-right{float:right;width:58%}div#widgets-left{padding-top:12px}div#widgets-left .closed .sidebar-name,div#widgets-left .inactive-sidebar.closed .sidebar-name{margin-bottom:10px}div#widgets-left .sidebar-name h2,div#widgets-left .sidebar-name h3{padding:10px 0;margin:0 10px 0 0}#widgets-left .widgets-holder-wrap,div#widgets-left .widget-holder{background:0 0;border:none}#widgets-left .widgets-holder-wrap{border:none;box-shadow:none}#available-widgets .widget-action{display:none}#available-widgets .widget{margin:0}#available-widgets .widget:nth-child(odd){clear:both}#available-widgets .widget .widget-description{display:block;padding:10px 15px;font-size:12px;overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}#available-widgets #widget-list{position:relative}#widgets-left .inactive-sidebar{clear:both;width:100%;background:0 0;padding:0;margin:0 0 20px;border:none;box-shadow:none}#widgets-left .inactive-sidebar.first{margin-top:40px}div#widgets-left .inactive-sidebar .widget.expanded{left:auto}.widget-title-action{float:right;position:relative}div#widgets-left .inactive-sidebar .widgets-sortables{min-height:42px;padding:0;background:0 0;margin:0;position:relative}div#widgets-right .sidebars-column-1,div#widgets-right .sidebars-column-2{max-width:450px}div#widgets-right .widgets-holder-wrap{margin:10px 0 0}div#widgets-right .sidebar-description{min-height:20px;margin-top:-5px}div#widgets-right .sidebar-name h2,div#widgets-right .sidebar-name h3{padding:15px 7px}div#widgets-right .widget-top{padding:0}div#widgets-right .widgets-sortables{padding:0 8px;margin-bottom:9px;position:relative;min-height:123px}div#widgets-right .closed .widgets-sortables{min-height:0;margin-bottom:0}.remove-inactive-widgets .spinner,.sidebar-name .spinner{float:none;position:relative;top:-2px;margin:-5px 5px}#widgets-right .widgets-holder-wrap.widget-hover{border-color:#72777c;box-shadow:0 1px 2px rgba(0,0,0,.3)}.widgets_access #widgets-left .widget .widget-top{cursor:auto}.widgets_access #wpwrap .widget-control-edit,.widgets_access #wpwrap .widgets-holder-wrap.closed .sidebar-description,.widgets_access #wpwrap .widgets-holder-wrap.closed .widget{display:block}.widgets_access #widgets-left .widget .widget-top:hover,.widgets_access #widgets-right .widget .widget-top:hover{border-color:#ddd}#available-widgets .widget-control-edit .edit,#widgets-left .inactive-sidebar .widget-control-edit .add,#widgets-right .widget-control-edit .add{display:none}.editwidget .widget-inside,.widget-control-edit{display:block;padding:0 15px}.widget-control-edit{color:#666;background:#EEE;line-height:43px;border-left:1px solid #DDD}#widgets-left .widget-control-edit:hover,#widgets-right .widget-control-edit:hover{color:#fff;background:#444;border-left:0;outline:#444 solid 1px}.widgets-holder-wrap .sidebar-description,.widgets-holder-wrap .sidebar-name{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.editwidget{margin:0 auto}.editwidget .widget-control-actions{margin-top:20px}.js .closed br.clear,.js .widgets-holder-wrap.closed .description,.js .widgets-holder-wrap.closed .remove-inactive-widgets,.js .widgets-holder-wrap.closed .sidebar-description,.js .widgets-holder-wrap.closed .widget{display:none}.js .widgets-holder-wrap.closed .widget.ui-sortable-helper{display:block}#access-off,.no-js .widget-holder .description,.widget-control-noform,.widget-description,.widget-inside,.widgets_access #access-on,.widgets_access .handlediv,.widgets_access .widget-action,.widgets_access .widget-holder .description{display:none}.widget-inside{background:#fff}#removing-widget{display:none;font-weight:400;padding-left:15px;font-size:12px;line-height:1;color:#000}.js #removing-widget{color:#00a0d2}.widgets_access #widget-list,.widgets_access .widget-holder{padding-top:10px}.widgets_access #access-off{display:inline}.widgets_access .sidebar-name,.widgets_access .widget .widget-top{cursor:default}.widget-liquid-left #widgets-left.chooser #available-widgets .widget,.widget-liquid-left #widgets-left.chooser .inactive-sidebar{transition:opacity .1s linear;opacity:.2;pointer-events:none}.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question{opacity:1;pointer-events:auto}#available-widgets .widget-top:hover,#widgets-left .widget-in-question .widget-top,#widgets-left .widget-top:hover,.widgets-chooser ul,div#widgets-right .widget-top:hover{border-color:#999;box-shadow:0 1px 2px rgba(0,0,0,.1)}.widgets-chooser ul.widgets-chooser-sidebars{margin:0;list-style-type:none;max-height:300px;overflow:auto}.widgets-chooser{display:none}.widgets-chooser ul{border:1px solid #ccc}.widgets-chooser li{padding:10px 15px 10px 35px;border-bottom:1px solid #ccc;background:#fff;margin:0;cursor:pointer;outline:0;position:relative;transition:background .2s ease-in-out}.widgets-chooser li:focus,.widgets-chooser li:hover{background:rgba(255,255,255,.7)}.widgets-chooser li:focus:before{content:"\f147";display:block;-webkit-font-smoothing:antialiased;font:400 26px/1 dashicons;color:#555d66;position:absolute;top:7px;left:5px}.widgets-chooser li:last-child{border:none}.widgets-chooser li.widgets-chooser-selected{background:#00a0d2;color:#fff}.widgets-chooser li.widgets-chooser-selected:before,.widgets-chooser li.widgets-chooser-selected:focus:before{content:"\f147";display:block;-webkit-font-smoothing:antialiased;font:400 26px/1 dashicons;color:#fff;position:absolute;top:7px;left:5px}.widgets-chooser .widgets-chooser-actions{padding:10px 0 12px;text-align:center}.widgets-chooser button{margin-right:5px}#available-widgets .widget .widget-top{cursor:pointer}#available-widgets .widget.ui-draggable-dragging .widget-top{cursor:move}.text-widget-fields{position:relative}.text-widget-fields [hidden]{display:none}.text-widget-fields .wp-pointer.wp-pointer-top{position:absolute;z-index:3;top:100px;right:10px;left:10px}.text-widget-fields .wp-pointer .wp-pointer-arrow{left:auto;right:15px}.text-widget-fields .wp-pointer .wp-pointer-buttons{line-height:1.4em}.custom-html-widget-fields>p>.CodeMirror{border:1px solid #e5e5e5}.custom-html-widget-fields code{padding-top:1px;padding-bottom:1px}ul.CodeMirror-hints{z-index:101}.widget-control-actions .custom-html-widget-save-button.button.validation-blocked{cursor:not-allowed}@media screen and (max-width:480px){div.widget-liquid-left{width:100%;float:none;border-right:none;padding-right:0}#widgets-left #available-widgets .widget-top,#widgets-left .inactive-sidebar .widgets-sortables,#widgets-left .sidebar-name{margin-right:0}div.widget-liquid-right{width:100%;float:none}div.widget{margin:0 auto!important;max-width:480px}}@media screen and (max-width:320px){div.widget{max-width:320px}}@media only screen and (min-width:1250px){#widgets-left #available-widgets .widget{width:49%;float:left}.widget.ui-draggable-dragging{min-width:49%}#widgets-left #available-widgets .widget:nth-child(even){float:right}#widgets-right .sidebars-column-1,#widgets-right .sidebars-column-2{float:left;width:49%}#widgets-right .sidebars-column-1{margin-right:2%}#widgets-right.single-sidebar .sidebars-column-1,#widgets-right.single-sidebar .sidebars-column-2{float:none;width:100%;margin:0}} \ No newline at end of file diff --git a/backend/wp-admin/css/wp-admin-rtl.css b/backend/wp-admin/css/wp-admin-rtl.css new file mode 100644 index 0000000..5e7c37d --- /dev/null +++ b/backend/wp-admin/css/wp-admin-rtl.css @@ -0,0 +1,14 @@ +@import url(common-rtl.css); +@import url(forms-rtl.css); +@import url(admin-menu-rtl.css); +@import url(dashboard-rtl.css); +@import url(list-tables-rtl.css); +@import url(edit-rtl.css); +@import url(revisions-rtl.css); +@import url(media-rtl.css); +@import url(themes-rtl.css); +@import url(about-rtl.css); +@import url(nav-menus-rtl.css); +@import url(widgets-rtl.css); +@import url(site-icon-rtl.css); +@import url(l10n-rtl.css); diff --git a/backend/wp-admin/css/wp-admin-rtl.min.css b/backend/wp-admin/css/wp-admin-rtl.min.css new file mode 100644 index 0000000..486af53 --- /dev/null +++ b/backend/wp-admin/css/wp-admin-rtl.min.css @@ -0,0 +1,15 @@ +/*! This file is auto-generated */ +@import url(common-rtl.min.css); +@import url(forms-rtl.min.css); +@import url(admin-menu-rtl.min.css); +@import url(dashboard-rtl.min.css); +@import url(list-tables-rtl.min.css); +@import url(edit-rtl.min.css); +@import url(revisions-rtl.min.css); +@import url(media-rtl.min.css); +@import url(themes-rtl.min.css); +@import url(about-rtl.min.css); +@import url(nav-menus-rtl.min.css); +@import url(widgets-rtl.min.css); +@import url(site-icon-rtl.min.css); +@import url(l10n-rtl.min.css); diff --git a/backend/wp-admin/css/wp-admin.css b/backend/wp-admin/css/wp-admin.css new file mode 100644 index 0000000..14c10f9 --- /dev/null +++ b/backend/wp-admin/css/wp-admin.css @@ -0,0 +1,14 @@ +@import url(common.css); +@import url(forms.css); +@import url(admin-menu.css); +@import url(dashboard.css); +@import url(list-tables.css); +@import url(edit.css); +@import url(revisions.css); +@import url(media.css); +@import url(themes.css); +@import url(about.css); +@import url(nav-menus.css); +@import url(widgets.css); +@import url(site-icon.css); +@import url(l10n.css); diff --git a/backend/wp-admin/css/wp-admin.min.css b/backend/wp-admin/css/wp-admin.min.css new file mode 100644 index 0000000..e139523 --- /dev/null +++ b/backend/wp-admin/css/wp-admin.min.css @@ -0,0 +1,15 @@ +/*! This file is auto-generated */ +@import url(common.min.css); +@import url(forms.min.css); +@import url(admin-menu.min.css); +@import url(dashboard.min.css); +@import url(list-tables.min.css); +@import url(edit.min.css); +@import url(revisions.min.css); +@import url(media.min.css); +@import url(themes.min.css); +@import url(about.min.css); +@import url(nav-menus.min.css); +@import url(widgets.min.css); +@import url(site-icon.min.css); +@import url(l10n.min.css); diff --git a/backend/wp-admin/custom-background.php b/backend/wp-admin/custom-background.php new file mode 100644 index 0000000..7326f7e --- /dev/null +++ b/backend/wp-admin/custom-background.php @@ -0,0 +1,559 @@ +admin_header_callback = $admin_header_callback; + $this->admin_image_div_callback = $admin_image_div_callback; + + add_action( 'admin_menu', array( $this, 'init' ) ); + + add_action( 'wp_ajax_custom-background-add', array( $this, 'ajax_background_add' ) ); + + // Unused since 3.5.0. + add_action( 'wp_ajax_set-background-image', array( $this, 'wp_set_background_image' ) ); + } + + /** + * Set up the hooks for the Custom Background admin page. + * + * @since 3.0.0 + */ + public function init() { + $page = add_theme_page( __( 'Background' ), __( 'Background' ), 'edit_theme_options', 'custom-background', array( $this, 'admin_page' ) ); + if ( ! $page ) { + return; + } + + add_action( "load-$page", array( $this, 'admin_load' ) ); + add_action( "load-$page", array( $this, 'take_action' ), 49 ); + add_action( "load-$page", array( $this, 'handle_upload' ), 49 ); + + if ( $this->admin_header_callback ) { + add_action( "admin_head-$page", $this->admin_header_callback, 51 ); + } + } + + /** + * Set up the enqueue for the CSS & JavaScript files. + * + * @since 3.0.0 + */ + public function admin_load() { + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

' . __( 'You can customize the look of your site without touching any of your theme’s code by using a custom background. Your background can be an image or a color.' ) . '

' . + '

' . __( 'To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the “Choose Image” button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '

' . + '

' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '

' . + '

' . __( 'Don’t forget to click on the Save Changes button when you are finished.' ) . '

' + ) ); + + get_current_screen()->set_help_sidebar( + '

' . __( 'For more information:' ) . '

' . + '

' . __( 'Documentation on Custom Background' ) . '

' . + '

' . __( 'Support Forums' ) . '

' + ); + + wp_enqueue_media(); + wp_enqueue_script('custom-background'); + wp_enqueue_style('wp-color-picker'); + } + + /** + * Execute custom background modification. + * + * @since 3.0.0 + */ + public function take_action() { + if ( empty($_POST) ) + return; + + if ( isset($_POST['reset-background']) ) { + check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset'); + remove_theme_mod('background_image'); + remove_theme_mod('background_image_thumb'); + $this->updated = true; + return; + } + + if ( isset($_POST['remove-background']) ) { + // @TODO: Uploaded files are not removed here. + check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove'); + set_theme_mod('background_image', ''); + set_theme_mod('background_image_thumb', ''); + $this->updated = true; + wp_safe_redirect( $_POST['_wp_http_referer'] ); + return; + } + + if ( isset( $_POST['background-preset'] ) ) { + check_admin_referer( 'custom-background' ); + + if ( in_array( $_POST['background-preset'], array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) { + $preset = $_POST['background-preset']; + } else { + $preset = 'default'; + } + + set_theme_mod( 'background_preset', $preset ); + } + + if ( isset( $_POST['background-position'] ) ) { + check_admin_referer( 'custom-background' ); + + $position = explode( ' ', $_POST['background-position'] ); + + if ( in_array( $position[0], array( 'left', 'center', 'right' ), true ) ) { + $position_x = $position[0]; + } else { + $position_x = 'left'; + } + + if ( in_array( $position[1], array( 'top', 'center', 'bottom' ), true ) ) { + $position_y = $position[1]; + } else { + $position_y = 'top'; + } + + set_theme_mod( 'background_position_x', $position_x ); + set_theme_mod( 'background_position_y', $position_y ); + } + + if ( isset( $_POST['background-size'] ) ) { + check_admin_referer( 'custom-background' ); + + if ( in_array( $_POST['background-size'], array( 'auto', 'contain', 'cover' ), true ) ) { + $size = $_POST['background-size']; + } else { + $size = 'auto'; + } + + set_theme_mod( 'background_size', $size ); + } + + if ( isset( $_POST['background-repeat'] ) ) { + check_admin_referer( 'custom-background' ); + + $repeat = $_POST['background-repeat']; + + if ( 'no-repeat' !== $repeat ) { + $repeat = 'repeat'; + } + + set_theme_mod( 'background_repeat', $repeat ); + } + + if ( isset( $_POST['background-attachment'] ) ) { + check_admin_referer( 'custom-background' ); + + $attachment = $_POST['background-attachment']; + + if ( 'fixed' !== $attachment ) { + $attachment = 'scroll'; + } + + set_theme_mod( 'background_attachment', $attachment ); + } + + if ( isset($_POST['background-color']) ) { + check_admin_referer('custom-background'); + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']); + if ( strlen($color) == 6 || strlen($color) == 3 ) + set_theme_mod('background_color', $color); + else + set_theme_mod('background_color', ''); + } + + $this->updated = true; + } + + /** + * Display the custom background page. + * + * @since 3.0.0 + */ + public function admin_page() { +?> +
+

+ + +
+

+ Customizer.' ), + admin_url( 'customize.php?autofocus[control]=background_image' ) + ); + ?> +

+
+ + +updated ) ) { ?> +
+

Visit your site to see how it looks.' ), home_url( '/' ) ); ?>

+
+ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ admin_image_div_callback ) { + call_user_func( $this->admin_image_div_callback ); + } else { + $background_styles = ''; + if ( $bgcolor = get_background_color() ) + $background_styles .= 'background-color: #' . $bgcolor . ';'; + + $background_image_thumb = get_background_image(); + if ( $background_image_thumb ) { + $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) ); + $background_position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ); + $background_position_y = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) ); + $background_size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ); + $background_repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ); + $background_attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ); + + // Background-image URL must be single quote, see below. + $background_styles .= " background-image: url('$background_image_thumb');" + . " background-size: $background_size;" + . " background-position: $background_position_x $background_position_y;" + . " background-repeat: $background_repeat;" + . " background-attachment: $background_attachment;"; + } + ?> +
+ +
+ + +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+

+
+ + + + +

+

+
+ +

+
+
+ +

+
+ + + + + + array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ), + 'right top' => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), + array( + 'left center' => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ), + 'right center' => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), + array( + 'left bottom' => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ), + 'right bottom' => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), +); +?> + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ $input ) : ?> + + +
+ +
+
+ +
+ + +
+ + +
+ +> +
+ + + +
+ +
+ false); + + $uploaded_file = $_FILES['import']; + $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); + if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) + wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); + + $file = wp_handle_upload($uploaded_file, $overrides); + + if ( isset($file['error']) ) + wp_die( $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $filename = basename($file); + + // Construct the object array + $object = array( + 'post_title' => $filename, + 'post_content' => $url, + 'post_mime_type' => $type, + 'guid' => $url, + 'context' => 'custom-background' + ); + + // Save the data + $id = wp_insert_attachment($object, $file); + + // Add the meta-data + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) ); + + set_theme_mod('background_image', esc_url_raw($url)); + + $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); + set_theme_mod('background_image_thumb', esc_url_raw( $thumbnail[0] ) ); + + /** This action is documented in wp-admin/custom-header.php */ + do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication + $this->updated = true; + } + + /** + * Ajax handler for adding custom background context to an attachment. + * + * Triggered when the user adds a new background image from the + * Media Manager. + * + * @since 4.1.0 + */ + public function ajax_background_add() { + check_ajax_referer( 'background-add', 'nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_send_json_error(); + } + + $attachment_id = absint( $_POST['attachment_id'] ); + if ( $attachment_id < 1 ) { + wp_send_json_error(); + } + + update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_stylesheet() ); + + wp_send_json_success(); + } + + /** + * + * @since 3.4.0 + * @deprecated 3.5.0 + * + * @param array $form_fields + * @return array $form_fields + */ + public function attachment_fields_to_edit( $form_fields ) { + return $form_fields; + } + + /** + * + * @since 3.4.0 + * @deprecated 3.5.0 + * + * @param array $tabs + * @return array $tabs + */ + public function filter_upload_tabs( $tabs ) { + return $tabs; + } + + /** + * + * @since 3.4.0 + * @deprecated 3.5.0 + */ + public function wp_set_background_image() { + if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit; + $attachment_id = absint($_POST['attachment_id']); + /** This filter is documented in wp-admin/includes/media.php */ + $sizes = array_keys(apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) )); + $size = 'thumbnail'; + if ( in_array( $_POST['size'], $sizes ) ) + $size = esc_attr( $_POST['size'] ); + + update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) ); + $url = wp_get_attachment_image_src( $attachment_id, $size ); + $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); + set_theme_mod( 'background_image', esc_url_raw( $url[0] ) ); + set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) ); + exit; + } +} diff --git a/backend/wp-admin/custom-header.php b/backend/wp-admin/custom-header.php new file mode 100644 index 0000000..d345766 --- /dev/null +++ b/backend/wp-admin/custom-header.php @@ -0,0 +1,1445 @@ +admin_header_callback = $admin_header_callback; + $this->admin_image_div_callback = $admin_image_div_callback; + + add_action( 'admin_menu', array( $this, 'init' ) ); + + add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) ); + add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) ); + add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) ); + add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) ); + } + + /** + * Set up the hooks for the Custom Header admin page. + * + * @since 2.1.0 + */ + public function init() { + $page = add_theme_page( __( 'Header' ), __( 'Header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) ); + if ( ! $page ) { + return; + } + + add_action( "admin_print_scripts-$page", array( $this, 'js_includes' ) ); + add_action( "admin_print_styles-$page", array( $this, 'css_includes' ) ); + add_action( "admin_head-$page", array( $this, 'help' ) ); + add_action( "admin_head-$page", array( $this, 'take_action' ), 50 ); + add_action( "admin_head-$page", array( $this, 'js' ), 50 ); + if ( $this->admin_header_callback ) { + add_action( "admin_head-$page", $this->admin_header_callback, 51 ); + } + } + + /** + * Adds contextual help. + * + * @since 3.0.0 + */ + public function help() { + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

' . __( 'This screen is used to customize the header section of your theme.') . '

' . + '

' . __( 'You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.') . '

' + ) ); + + get_current_screen()->add_help_tab( array( + 'id' => 'set-header-image', + 'title' => __('Header Image'), + 'content' => + '

' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.' ) . '

' . + '

' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” button.' ) . '

' . + '

' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.') . '

' . + '

' . __( 'If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.') . '

' + ) ); + + get_current_screen()->add_help_tab( array( + 'id' => 'set-header-text', + 'title' => __('Header Text'), + 'content' => + '

' . sprintf( __( 'For most themes, the header text is your Site Title and Tagline, as defined in the General Settings section.' ), admin_url( 'options-general.php' ) ) . '

' . + '

' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '

' . + '

' . __( 'Don’t forget to click “Save Changes” when you’re done!') . '

' + ) ); + + get_current_screen()->set_help_sidebar( + '

' . __( 'For more information:' ) . '

' . + '

' . __( 'Documentation on Custom Header' ) . '

' . + '

' . __( 'Support Forums' ) . '

' + ); + } + + /** + * Get the current step. + * + * @since 2.6.0 + * + * @return int Current step + */ + public function step() { + if ( ! isset( $_GET['step'] ) ) + return 1; + + $step = (int) $_GET['step']; + if ( $step < 1 || 3 < $step || + ( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || + ( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) + ) + return 1; + + return $step; + } + + /** + * Set up the enqueue for the JavaScript files. + * + * @since 2.1.0 + */ + public function js_includes() { + $step = $this->step(); + + if ( ( 1 == $step || 3 == $step ) ) { + wp_enqueue_media(); + wp_enqueue_script( 'custom-header' ); + if ( current_theme_supports( 'custom-header', 'header-text' ) ) + wp_enqueue_script( 'wp-color-picker' ); + } elseif ( 2 == $step ) { + wp_enqueue_script('imgareaselect'); + } + } + + /** + * Set up the enqueue for the CSS files + * + * @since 2.7.0 + */ + public function css_includes() { + $step = $this->step(); + + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) + wp_enqueue_style( 'wp-color-picker' ); + elseif ( 2 == $step ) + wp_enqueue_style('imgareaselect'); + } + + /** + * Execute custom header modification. + * + * @since 2.6.0 + */ + public function take_action() { + if ( ! current_user_can('edit_theme_options') ) + return; + + if ( empty( $_POST ) ) + return; + + $this->updated = true; + + if ( isset( $_POST['resetheader'] ) ) { + check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); + $this->reset_header_image(); + return; + } + + if ( isset( $_POST['removeheader'] ) ) { + check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); + $this->remove_header_image(); + return; + } + + if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) { + check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); + set_theme_mod( 'header_textcolor', 'blank' ); + } elseif ( isset( $_POST['text-color'] ) ) { + check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); + $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); + if ( strlen($color) == 6 || strlen($color) == 3 ) + set_theme_mod('header_textcolor', $color); + elseif ( ! $color ) + set_theme_mod( 'header_textcolor', 'blank' ); + } + + if ( isset( $_POST['default-header'] ) ) { + check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); + $this->set_header_image( $_POST['default-header'] ); + return; + } + } + + /** + * Process the default headers + * + * @since 3.0.0 + * + * @global array $_wp_default_headers + */ + public function process_default_headers() { + global $_wp_default_headers; + + if ( !isset($_wp_default_headers) ) + return; + + if ( ! empty( $this->default_headers ) ) { + return; + } + + $this->default_headers = $_wp_default_headers; + $template_directory_uri = get_template_directory_uri(); + $stylesheet_directory_uri = get_stylesheet_directory_uri(); + foreach ( array_keys($this->default_headers) as $header ) { + $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri ); + $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri ); + } + } + + /** + * Display UI for selecting one of several default headers. + * + * Show the random image option if this theme has multiple header images. + * Random image option is on by default if no header has been set. + * + * @since 3.0.0 + * + * @param string $type The header type. One of 'default' (for the Uploaded Images control) + * or 'uploaded' (for the Uploaded Images control). + */ + public function show_header_selector( $type = 'default' ) { + if ( 'default' == $type ) { + $headers = $this->default_headers; + } else { + $headers = get_uploaded_header_images(); + $type = 'uploaded'; + } + + if ( 1 < count( $headers ) ) { + echo '
'; + echo ''; + echo '
'; + } + + echo '
'; + foreach ( $headers as $header_key => $header ) { + $header_thumbnail = $header['thumbnail_url']; + $header_url = $header['url']; + $header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text']; + echo '
'; + echo ''; + echo '
'; + } + echo '
'; + } + + /** + * Execute JavaScript depending on step. + * + * @since 2.1.0 + */ + public function js() { + $step = $this->step(); + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) + $this->js_1(); + elseif ( 2 == $step ) + $this->js_2(); + } + + /** + * Display JavaScript based on Step 1 and 3. + * + * @since 2.6.0 + */ + public function js_1() { + $default_color = ''; + if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { + $default_color = get_theme_support( 'custom-header', 'default-text-color' ); + if ( $default_color && false === strpos( $default_color, '#' ) ) { + $default_color = '#' . $default_color; + } + } + ?> + + + +process_default_headers(); +?> + +
+

+ + +
+

+ Customizer.' ), + admin_url( 'customize.php?autofocus[control]=header_image' ) + ); + ?> +

+
+ + +updated ) ) { ?> +
+

Visit your site to see how it looks.' ), home_url( '/' ) ); ?>

+
+ + +

+ + + + + + + + + + + + + + + + + + +
+ admin_image_div_callback ) { + call_user_func( $this->admin_image_div_callback ); + } else { + $custom_header = get_custom_header(); + $header_image = get_header_image(); + + if ( $header_image ) { + $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; + } else { + $header_image_style = ''; + } + + if ( $custom_header->width ) + $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; + if ( $custom_header->height ) + $header_image_style .= 'height:' . $custom_header->height . 'px;'; + ?> + + +
+


+ %1$d × %2$d pixels will be used as-is.' ) . '
', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); + } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { + if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) + printf( + /* translators: %s: size in pixels */ + __( 'Images should be at least %s wide.' ) . ' ', + sprintf( + /* translators: %d: custom header width */ + '' . __( '%d pixels' ) . '', + get_theme_support( 'custom-header', 'width' ) + ) + ); + } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { + if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) + printf( + /* translators: %s: size in pixels */ + __( 'Images should be at least %s tall.' ) . ' ', + sprintf( + /* translators: %d: custom header height */ + '' . __( '%d pixels' ) . '', + get_theme_support( 'custom-header', 'height' ) + ) + ); + } + if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { + if ( current_theme_supports( 'custom-header', 'width' ) ) + printf( + /* translators: %s: size in pixels */ + __( 'Suggested width is %s.' ) . ' ', + sprintf( + /* translators: %d: custom header width */ + '' . __( '%d pixels' ) . '', + get_theme_support( 'custom-header', 'width' ) + ) + ); + if ( current_theme_supports( 'custom-header', 'height' ) ) + printf( + /* translators: %s: size in pixels */ + __( 'Suggested height is %s.' ) . ' ', + sprintf( + /* translators: %d: custom header height */ + '' . __( '%d pixels' ) . '', + get_theme_support( 'custom-header', 'height' ) + ) + ); + } + ?>

+
+

+
+ + + + +

+ 'custom-header', + 'step' => 2, + '_wpnonce-custom-header-upload' => wp_create_nonce('custom-header-upload'), + ), admin_url('themes.php') ) ); + ?> +

+
+ +

+
+
+ +
+ + + + + + + + + default_headers ) ) : ?> + + + + + + + + + + + + + + + + +
+

+ show_header_selector( 'uploaded' ); + ?> +
+ +

+ +

+ + show_header_selector( 'default' ); + ?> +
+

+ +
+

+ +
+ + + +

+ + + + + + + + + + + + + +
+

+ +

+
+

+ '; + if ( $default_color ) { + echo ' ' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . ''; + } + ?> +

+
+ + + +
+
+ +' . __( 'Something went wrong.' ) . '' . + '

' . __( 'The current theme does not support uploading a custom header image.' ) . '

', + 403 + ); + } + + if ( empty( $_POST ) && isset( $_GET['file'] ) ) { + $attachment_id = absint( $_GET['file'] ); + $file = get_attached_file( $attachment_id, true ); + $url = wp_get_attachment_image_src( $attachment_id, 'full' ); + $url = $url[0]; + } elseif ( isset( $_POST ) ) { + $data = $this->step_2_manage_upload(); + $attachment_id = $data['attachment_id']; + $file = $data['file']; + $url = $data['url']; + } + + if ( file_exists( $file ) ) { + list( $width, $height, $type, $attr ) = getimagesize( $file ); + } else { + $data = wp_get_attachment_metadata( $attachment_id ); + $height = isset( $data[ 'height' ] ) ? $data[ 'height' ] : 0; + $width = isset( $data[ 'width' ] ) ? $data[ 'width' ] : 0; + unset( $data ); + } + + $max_width = 0; + // For flex, limit size of image displayed to 1500px unless theme says otherwise + if ( current_theme_supports( 'custom-header', 'flex-width' ) ) + $max_width = 1500; + + if ( current_theme_supports( 'custom-header', 'max-width' ) ) + $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); + $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); + + // If flexible height isn't supported and the image is the exact right size + if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) + && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) + { + // Add the meta-data + if ( file_exists( $file ) ) + wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); + + $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); + + /** + * Fires after the header image is set or an error is returned. + * + * @since 2.1.0 + * + * @param string $file Path to the file. + * @param int $attachment_id Attachment ID. + */ + do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication + + return $this->finished(); + } elseif ( $width > $max_width ) { + $oitar = $width / $max_width; + $image = wp_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); + if ( ! $image || is_wp_error( $image ) ) + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); + + /** This filter is documented in wp-admin/custom-header.php */ + $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication + + $url = str_replace(basename($url), basename($image), $url); + $width = $width / $oitar; + $height = $height / $oitar; + } else { + $oitar = 1; + } + ?> + +
+

+ +
+

+

+ +
+ +
+ + + + + + + + + + + + +

+ + +

+
+
+ false); + + $uploaded_file = $_FILES['import']; + $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); + if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) + wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); + + $file = wp_handle_upload($uploaded_file, $overrides); + + if ( isset($file['error']) ) + wp_die( $file['error'], __( 'Image Upload Error' ) ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $filename = basename($file); + + // Construct the object array + $object = array( + 'post_title' => $filename, + 'post_content' => $url, + 'post_mime_type' => $type, + 'guid' => $url, + 'context' => 'custom-header' + ); + + // Save the data + $attachment_id = wp_insert_attachment( $object, $file ); + return compact( 'attachment_id', 'file', 'filename', 'url', 'type' ); + } + + /** + * Display third step of custom header image page. + * + * @since 2.1.0 + * @since 4.4.0 Switched to using wp_get_attachment_url() instead of the guid + * for retrieving the header image URL. + */ + public function step_3() { + check_admin_referer( 'custom-header-crop-image' ); + + if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { + wp_die( + '

' . __( 'Something went wrong.' ) . '

' . + '

' . __( 'The current theme does not support uploading a custom header image.' ) . '

', + 403 + ); + } + + if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { + wp_die( + '

' . __( 'Something went wrong.' ) . '

' . + '

' . __( 'The current theme does not support a flexible sized header image.' ) . '

', + 403 + ); + } + + if ( $_POST['oitar'] > 1 ) { + $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; + $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; + $_POST['width'] = $_POST['width'] * $_POST['oitar']; + $_POST['height'] = $_POST['height'] * $_POST['oitar']; + } + + $attachment_id = absint( $_POST['attachment_id'] ); + $original = get_attached_file($attachment_id); + + $dimensions = $this->get_header_dimensions( array( + 'height' => $_POST['height'], + 'width' => $_POST['width'], + ) ); + $height = $dimensions['dst_height']; + $width = $dimensions['dst_width']; + + if ( empty( $_POST['skip-cropping'] ) ) + $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); + elseif ( ! empty( $_POST['create-new-attachment'] ) ) + $cropped = _copy_image_file( $attachment_id ); + else + $cropped = get_attached_file( $attachment_id ); + + if ( ! $cropped || is_wp_error( $cropped ) ) + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); + + /** This filter is documented in wp-admin/custom-header.php */ + $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication + + $object = $this->create_attachment_object( $cropped, $attachment_id ); + + if ( ! empty( $_POST['create-new-attachment'] ) ) + unset( $object['ID'] ); + + // Update the attachment + $attachment_id = $this->insert_attachment( $object, $cropped ); + + $url = wp_get_attachment_url( $attachment_id ); + $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); + + // Cleanup. + $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original ); + if ( file_exists( $medium ) ) { + wp_delete_file( $medium ); + } + + if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) { + wp_delete_file( $original ); + } + + return $this->finished(); + } + + /** + * Display last step of custom header image page. + * + * @since 2.1.0 + */ + public function finished() { + $this->updated = true; + $this->step_1(); + } + + /** + * Display the page based on the current step. + * + * @since 2.1.0 + */ + public function admin_page() { + if ( ! current_user_can('edit_theme_options') ) + wp_die(__('Sorry, you are not allowed to customize headers.')); + $step = $this->step(); + if ( 2 == $step ) + $this->step_2(); + elseif ( 3 == $step ) + $this->step_3(); + else + $this->step_1(); + } + + /** + * Unused since 3.5.0. + * + * @since 3.4.0 + * + * @param array $form_fields + * @return array $form_fields + */ + public function attachment_fields_to_edit( $form_fields ) { + return $form_fields; + } + + /** + * Unused since 3.5.0. + * + * @since 3.4.0 + * + * @param array $tabs + * @return array $tabs + */ + public function filter_upload_tabs( $tabs ) { + return $tabs; + } + + /** + * Choose a header image, selected from existing uploaded and default headers, + * or provide an array of uploaded header data (either new, or from media library). + * + * @since 3.4.0 + * + * @param mixed $choice Which header image to select. Allows for values of 'random-default-image', + * for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling + * among the uploaded images; the key of a default image registered for that theme; and + * the key of an image uploaded for that theme (the attachment ID of the image). + * Or an array of arguments: attachment_id, url, width, height. All are required. + */ + final public function set_header_image( $choice ) { + if ( is_array( $choice ) || is_object( $choice ) ) { + $choice = (array) $choice; + if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) + return; + + $choice['url'] = esc_url_raw( $choice['url'] ); + + $header_image_data = (object) array( + 'attachment_id' => $choice['attachment_id'], + 'url' => $choice['url'], + 'thumbnail_url' => $choice['url'], + 'height' => $choice['height'], + 'width' => $choice['width'], + ); + + update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() ); + set_theme_mod( 'header_image', $choice['url'] ); + set_theme_mod( 'header_image_data', $header_image_data ); + return; + } + + if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ) ) ) { + set_theme_mod( 'header_image', $choice ); + remove_theme_mod( 'header_image_data' ); + return; + } + + $uploaded = get_uploaded_header_images(); + if ( $uploaded && isset( $uploaded[ $choice ] ) ) { + $header_image_data = $uploaded[ $choice ]; + + } else { + $this->process_default_headers(); + if ( isset( $this->default_headers[ $choice ] ) ) + $header_image_data = $this->default_headers[ $choice ]; + else + return; + } + + set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); + set_theme_mod( 'header_image_data', $header_image_data ); + } + + /** + * Remove a header image. + * + * @since 3.4.0 + */ + final public function remove_header_image() { + $this->set_header_image( 'remove-header' ); + } + + /** + * Reset a header image to the default image for the theme. + * + * This method does not do anything if the theme does not have a default header image. + * + * @since 3.4.0 + */ + final public function reset_header_image() { + $this->process_default_headers(); + $default = get_theme_support( 'custom-header', 'default-image' ); + + if ( ! $default ) { + $this->remove_header_image(); + return; + } + $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); + + $default_data = array(); + foreach ( $this->default_headers as $header => $details ) { + if ( $details['url'] == $default ) { + $default_data = $details; + break; + } + } + + set_theme_mod( 'header_image', $default ); + set_theme_mod( 'header_image_data', (object) $default_data ); + } + + /** + * Calculate width and height based on what the currently selected theme supports. + * + * @since 3.9.0 + * + * @param array $dimensions + * @return array dst_height and dst_width of header image. + */ + final public function get_header_dimensions( $dimensions ) { + $max_width = 0; + $width = absint( $dimensions['width'] ); + $height = absint( $dimensions['height'] ); + $theme_height = get_theme_support( 'custom-header', 'height' ); + $theme_width = get_theme_support( 'custom-header', 'width' ); + $has_flex_width = current_theme_supports( 'custom-header', 'flex-width' ); + $has_flex_height = current_theme_supports( 'custom-header', 'flex-height' ); + $has_max_width = current_theme_supports( 'custom-header', 'max-width' ) ; + $dst = array( 'dst_height' => null, 'dst_width' => null ); + + // For flex, limit size of image displayed to 1500px unless theme says otherwise + if ( $has_flex_width ) { + $max_width = 1500; + } + + if ( $has_max_width ) { + $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); + } + $max_width = max( $max_width, $theme_width ); + + if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { + $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); + } + elseif ( $has_flex_height && $has_flex_width ) { + $dst['dst_height'] = $height; + } + else { + $dst['dst_height'] = $theme_height; + } + + if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { + $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); + } + elseif ( $has_flex_width && $has_flex_height ) { + $dst['dst_width'] = $width; + } + else { + $dst['dst_width'] = $theme_width; + } + + return $dst; + } + + /** + * Create an attachment 'object'. + * + * @since 3.9.0 + * + * @param string $cropped Cropped image URL. + * @param int $parent_attachment_id Attachment ID of parent image. + * @return array Attachment object. + */ + final public function create_attachment_object( $cropped, $parent_attachment_id ) { + $parent = get_post( $parent_attachment_id ); + $parent_url = wp_get_attachment_url( $parent->ID ); + $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); + + $size = @getimagesize( $cropped ); + $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; + + $object = array( + 'ID' => $parent_attachment_id, + 'post_title' => basename($cropped), + 'post_mime_type' => $image_type, + 'guid' => $url, + 'context' => 'custom-header', + 'post_parent' => $parent_attachment_id, + ); + + return $object; + } + + /** + * Insert an attachment and its metadata. + * + * @since 3.9.0 + * + * @param array $object Attachment object. + * @param string $cropped Cropped image URL. + * @return int Attachment ID. + */ + final public function insert_attachment( $object, $cropped ) { + $parent_id = isset( $object['post_parent'] ) ? $object['post_parent'] : null; + unset( $object['post_parent'] ); + + $attachment_id = wp_insert_attachment( $object, $cropped ); + $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); + + // If this is a crop, save the original attachment ID as metadata. + if ( $parent_id ) { + $metadata['attachment_parent'] = $parent_id; + } + + /** + * Filters the header image attachment metadata. + * + * @since 3.9.0 + * + * @see wp_generate_attachment_metadata() + * + * @param array $metadata Attachment metadata. + */ + $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); + + wp_update_attachment_metadata( $attachment_id, $metadata ); + + return $attachment_id; + } + + /** + * Gets attachment uploaded by Media Manager, crops it, then saves it as a + * new object. Returns JSON-encoded object details. + * + * @since 3.9.0 + */ + public function ajax_header_crop() { + check_ajax_referer( 'image_editor-' . $_POST['id'], 'nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_send_json_error(); + } + + if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { + wp_send_json_error(); + } + + $crop_details = $_POST['cropDetails']; + + $dimensions = $this->get_header_dimensions( array( + 'height' => $crop_details['height'], + 'width' => $crop_details['width'], + ) ); + + $attachment_id = absint( $_POST['id'] ); + + $cropped = wp_crop_image( + $attachment_id, + (int) $crop_details['x1'], + (int) $crop_details['y1'], + (int) $crop_details['width'], + (int) $crop_details['height'], + (int) $dimensions['dst_width'], + (int) $dimensions['dst_height'] + ); + + if ( ! $cropped || is_wp_error( $cropped ) ) { + wp_send_json_error( array( 'message' => __( 'Image could not be processed. Please go back and try again.' ) ) ); + } + + /** This filter is documented in wp-admin/custom-header.php */ + $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication + + $object = $this->create_attachment_object( $cropped, $attachment_id ); + + $previous = $this->get_previous_crop( $object ); + + if ( $previous ) { + $object['ID'] = $previous; + } else { + unset( $object['ID'] ); + } + + $new_attachment_id = $this->insert_attachment( $object, $cropped ); + + $object['attachment_id'] = $new_attachment_id; + $object['url'] = wp_get_attachment_url( $new_attachment_id );; + $object['width'] = $dimensions['dst_width']; + $object['height'] = $dimensions['dst_height']; + + wp_send_json_success( $object ); + } + + /** + * Given an attachment ID for a header image, updates its "last used" + * timestamp to now. + * + * Triggered when the user tries adds a new header image from the + * Media Manager, even if s/he doesn't save that change. + * + * @since 3.9.0 + */ + public function ajax_header_add() { + check_ajax_referer( 'header-add', 'nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_send_json_error(); + } + + $attachment_id = absint( $_POST['attachment_id'] ); + if ( $attachment_id < 1 ) { + wp_send_json_error(); + } + + $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); + update_post_meta( $attachment_id, $key, time() ); + update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); + + wp_send_json_success(); + } + + /** + * Given an attachment ID for a header image, unsets it as a user-uploaded + * header image for the current theme. + * + * Triggered when the user clicks the overlay "X" button next to each image + * choice in the Customizer's Header tool. + * + * @since 3.9.0 + */ + public function ajax_header_remove() { + check_ajax_referer( 'header-remove', 'nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_send_json_error(); + } + + $attachment_id = absint( $_POST['attachment_id'] ); + if ( $attachment_id < 1 ) { + wp_send_json_error(); + } + + $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); + delete_post_meta( $attachment_id, $key ); + delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); + + wp_send_json_success(); + } + + /** + * Updates the last-used postmeta on a header image attachment after saving a new header image via the Customizer. + * + * @since 3.9.0 + * + * @param WP_Customize_Manager $wp_customize Customize manager. + */ + public function customize_set_last_used( $wp_customize ) { + + $header_image_data_setting = $wp_customize->get_setting( 'header_image_data' ); + if ( ! $header_image_data_setting ) { + return; + } + $data = $header_image_data_setting->post_value(); + + if ( ! isset( $data['attachment_id'] ) ) { + return; + } + + $attachment_id = $data['attachment_id']; + $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); + update_post_meta( $attachment_id, $key, time() ); + } + + /** + * Gets the details of default header images if defined. + * + * @since 3.9.0 + * + * @return array Default header images. + */ + public function get_default_header_images() { + $this->process_default_headers(); + + // Get the default image if there is one. + $default = get_theme_support( 'custom-header', 'default-image' ); + + if ( ! $default ) { // If not, + return $this->default_headers; // easy peasy. + } + + $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); + $already_has_default = false; + + foreach ( $this->default_headers as $k => $h ) { + if ( $h['url'] === $default ) { + $already_has_default = true; + break; + } + } + + if ( $already_has_default ) { + return $this->default_headers; + } + + // If the one true image isn't included in the default set, prepend it. + $header_images = array(); + $header_images['default'] = array( + 'url' => $default, + 'thumbnail_url' => $default, + 'description' => 'Default' + ); + + // The rest of the set comes after. + return array_merge( $header_images, $this->default_headers ); + } + + /** + * Gets the previously uploaded header images. + * + * @since 3.9.0 + * + * @return array Uploaded header images. + */ + public function get_uploaded_header_images() { + $header_images = get_uploaded_header_images(); + $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); + $alt_text_key = '_wp_attachment_image_alt'; + + foreach ( $header_images as &$header_image ) { + $header_meta = get_post_meta( $header_image['attachment_id'] ); + $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; + $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; + } + + return $header_images; + } + + /** + * Get the ID of a previous crop from the same base image. + * + * @since 4.9.0 + * + * @param array $object A crop attachment object. + * @return int|false An attachment ID if one exists. False if none. + */ + public function get_previous_crop( $object ) { + $header_images = $this->get_uploaded_header_images(); + + // Bail early if there are no header images. + if ( empty( $header_images ) ) { + return false; + } + + $previous = false; + + foreach ( $header_images as $image ) { + if ( $image['attachment_parent'] === $object['post_parent'] ) { + $previous = $image['attachment_id']; + break; + } + } + + return $previous; + } +} diff --git a/backend/wp-admin/customize.php b/backend/wp-admin/customize.php new file mode 100644 index 0000000..d98c2a1 --- /dev/null +++ b/backend/wp-admin/customize.php @@ -0,0 +1,262 @@ +' . __( 'You need a higher level of permission.' ) . '' . + '

' . __( 'Sorry, you are not allowed to customize this site.' ) . '

', + 403 + ); +} + +/** + * @global WP_Scripts $wp_scripts + * @global WP_Customize_Manager $wp_customize + */ +global $wp_scripts, $wp_customize; + +if ( $wp_customize->changeset_post_id() ) { + $changeset_post = get_post( $wp_customize->changeset_post_id() ); + + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post->ID ) ) { + wp_die( + '

' . __( 'You need a higher level of permission.' ) . '

' . + '

' . __( 'Sorry, you are not allowed to edit this changeset.' ) . '

', + 403 + ); + } + + $missed_schedule = ( + 'future' === $changeset_post->post_status && + get_post_time( 'G', true, $changeset_post ) < time() + ); + if ( $missed_schedule ) { + /* + * Note that an Ajax request spawns here instead of just calling `wp_publish_post( $changeset_post->ID )`. + * + * Because WP_Customize_Manager is not instantiated for customize.php with the `settings_previewed=false` + * argument, settings cannot be reliably saved. Some logic short-circuits if the current value is the + * same as the value being saved. This is particularly true for options via `update_option()`. + * + * By opening an Ajax request, this is avoided and the changeset is published. See #39221. + */ + $nonces = $wp_customize->get_nonces(); + $request_args = array( + 'nonce' => $nonces['save'], + 'customize_changeset_uuid' => $wp_customize->changeset_uuid(), + 'wp_customize' => 'on', + 'customize_changeset_status' => 'publish', + ); + ob_start(); + ?> + + + ' . __( 'Your scheduled changes just published' ) . '' . + '

' . __( 'Customize New Changes' ) . '

' . $script, + 200 + ); + } + + if ( in_array( get_post_status( $changeset_post->ID ), array( 'publish', 'trash' ), true ) ) { + wp_die( + '

' . __( 'Something went wrong.' ) . '

' . + '

' . __( 'This changeset cannot be further modified.' ) . '

' . + '

' . __( 'Customize New Changes' ) . '

', + 403 + ); + } +} + + +wp_reset_vars( array( 'url', 'return', 'autofocus' ) ); +if ( ! empty( $url ) ) { + $wp_customize->set_preview_url( wp_unslash( $url ) ); +} +if ( ! empty( $return ) ) { + $wp_customize->set_return_url( wp_unslash( $return ) ); +} +if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { + $wp_customize->set_autofocus( wp_unslash( $autofocus ) ); +} + +$registered = $wp_scripts->registered; +$wp_scripts = new WP_Scripts; +$wp_scripts->registered = $registered; + +add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 ); +add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' ); +add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 ); + +/** + * Fires when Customizer controls are initialized, before scripts are enqueued. + * + * @since 3.4.0 + */ +do_action( 'customize_controls_init' ); + +wp_enqueue_script( 'heartbeat' ); +wp_enqueue_script( 'customize-controls' ); +wp_enqueue_style( 'customize-controls' ); + +/** + * Enqueue Customizer control scripts. + * + * @since 3.4.0 + */ +do_action( 'customize_controls_enqueue_scripts' ); + +// Let's roll. +@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); + +wp_user_settings(); +_wp_admin_html_begin(); + +$body_class = 'wp-core-ui wp-customizer js'; + +if ( wp_is_mobile() ) : + $body_class .= ' mobile'; + + ?>is_ios() ) { + $body_class .= ' ios'; +} + +if ( is_rtl() ) { + $body_class .= ' rtl'; +} +$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); + +$admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) ); + +?><?php echo $admin_title; ?> + + + + + + +
+
+
+ is_theme_active() ? __( 'Publish' ) : __( 'Activate & Publish' ); ?> +
+ + +
+ + + + + +
+ +
+
+
+
+
+ +
+
+
    +
    +
    +
    +
    + ' . get_bloginfo( 'name', 'display' ) . '' ); + ?> + +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    + +
    + + diff --git a/backend/wp-admin/edit-comments.php b/backend/wp-admin/edit-comments.php new file mode 100644 index 0000000..4076bf2 --- /dev/null +++ b/backend/wp-admin/edit-comments.php @@ -0,0 +1,334 @@ +' . __( 'You need a higher level of permission.' ) . '' . + '

    ' . __( 'Sorry, you are not allowed to edit comments.' ) . '

    ', + 403 + ); +} + +$wp_list_table = _get_list_table('WP_Comments_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); + +$doaction = $wp_list_table->current_action(); + +if ( $doaction ) { + check_admin_referer( 'bulk-comments' ); + + if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) { + $comment_status = wp_unslash( $_REQUEST['comment_status'] ); + $delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] ); + $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) ); + $doaction = 'delete'; + } elseif ( isset( $_REQUEST['delete_comments'] ) ) { + $comment_ids = $_REQUEST['delete_comments']; + $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2']; + } elseif ( isset( $_REQUEST['ids'] ) ) { + $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) ); + } elseif ( wp_get_referer() ) { + wp_safe_redirect( wp_get_referer() ); + exit; + } + + $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; + + $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); + $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); + + wp_defer_comment_counting( true ); + + foreach ( $comment_ids as $comment_id ) { // Check the permissions on each + if ( !current_user_can( 'edit_comment', $comment_id ) ) + continue; + + switch ( $doaction ) { + case 'approve' : + wp_set_comment_status( $comment_id, 'approve' ); + $approved++; + break; + case 'unapprove' : + wp_set_comment_status( $comment_id, 'hold' ); + $unapproved++; + break; + case 'spam' : + wp_spam_comment( $comment_id ); + $spammed++; + break; + case 'unspam' : + wp_unspam_comment( $comment_id ); + $unspammed++; + break; + case 'trash' : + wp_trash_comment( $comment_id ); + $trashed++; + break; + case 'untrash' : + wp_untrash_comment( $comment_id ); + $untrashed++; + break; + case 'delete' : + wp_delete_comment( $comment_id ); + $deleted++; + break; + } + } + + if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) { + $screen = get_current_screen()->id; + + /** + * Fires when a custom bulk action should be handled. + * + * The redirect link should be modified with success or failure feedback + * from the action to be used to display feedback to the user. + * + * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. + * + * @since 4.7.0 + * + * @param string $redirect_url The redirect URL. + * @param string $doaction The action being taken. + * @param array $items The items to take the action on. + */ + $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); + } + + wp_defer_comment_counting( false ); + + if ( $approved ) + $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); + if ( $unapproved ) + $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); + if ( $spammed ) + $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); + if ( $unspammed ) + $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); + if ( $trashed ) + $redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to ); + if ( $untrashed ) + $redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to ); + if ( $deleted ) + $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); + if ( $trashed || $spammed ) + $redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to ); + + wp_safe_redirect( $redirect_to ); + exit; +} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { + wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); + exit; +} + +$wp_list_table->prepare_items(); + +wp_enqueue_script('admin-comments'); +enqueue_comment_hotkeys_js(); + +if ( $post_id ) { + $comments_count = wp_count_comments( $post_id ); + $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ); + if ( $comments_count->moderated > 0 ) { + /* translators: 1: comments count 2: post title */ + $title = sprintf( __( 'Comments (%1$s) on “%2$s”' ), + number_format_i18n( $comments_count->moderated ), + $draft_or_post_title + ); + } else { + /* translators: %s: post title */ + $title = sprintf( __( 'Comments on “%s”' ), + $draft_or_post_title + ); + } +} else { + $comments_count = wp_count_comments(); + if ( $comments_count->moderated > 0 ) { + /* translators: %s: comments count */ + $title = sprintf( __( 'Comments (%s)' ), + number_format_i18n( $comments_count->moderated ) + ); + } else { + $title = __( 'Comments' ); + } +} + +add_screen_option( 'per_page' ); + +get_current_screen()->add_help_tab( array( +'id' => 'overview', +'title' => __('Overview'), +'content' => + '

    ' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '

    ' +) ); +get_current_screen()->add_help_tab( array( +'id' => 'moderating-comments', +'title' => __('Moderating Comments'), +'content' => + '

    ' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '

    ' . + '

    ' . __( 'In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '

    ' . + '

    ' . __( 'In the Comment column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '

    ' . + '

    ' . __( 'In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.' ) . '

    ' . + '

    ' . __( 'In the Submitted On column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.' ) . '

    ' . + '

    ' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '

    ' +) ); + +get_current_screen()->set_help_sidebar( + '

    ' . __( 'For more information:' ) . '

    ' . + '

    ' . __( 'Documentation on Comments' ) . '

    ' . + '

    ' . __( 'Documentation on Comment Spam' ) . '

    ' . + '

    ' . __( 'Documentation on Keyboard Shortcuts' ) . '

    ' . + '

    ' . __( 'Support Forums' ) . '

    ' +); + +get_current_screen()->set_screen_reader_content( array( + 'heading_views' => __( 'Filter comments list' ), + 'heading_pagination' => __( 'Comments list navigation' ), + 'heading_list' => __( 'Comments list' ), +) ); + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); +?> + +
    +

    %2$s', + get_edit_post_link( $post_id ), + wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) + ) + ); +} else { + _e( 'Comments' ); +} +?>

    + +'; + /* translators: %s: search keywords */ + printf( __( 'Search results for “%s”' ), + wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) + ); + echo ''; +} +?> + +
    + +

    ' . $error_msg . '

    '; +} + +if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) { + $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; + $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; + $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; + $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0; + $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; + $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; + $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0; + + if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { + if ( $approved > 0 ) { + /* translators: %s: number of comments approved */ + $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); + } + + if ( $spammed > 0 ) { + $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; + /* translators: %s: number of comments marked as spam */ + $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' ' . __('Undo') . '
    '; + } + + if ( $unspammed > 0 ) { + /* translators: %s: number of comments restored from the spam */ + $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); + } + + if ( $trashed > 0 ) { + $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; + /* translators: %s: number of comments moved to the Trash */ + $messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' ' . __('Undo') . '
    '; + } + + if ( $untrashed > 0 ) { + /* translators: %s: number of comments restored from the Trash */ + $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed ); + } + + if ( $deleted > 0 ) { + /* translators: %s: number of comments permanently deleted */ + $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); + } + + if ( $same > 0 && $comment = get_comment( $same ) ) { + switch ( $comment->comment_approved ) { + case '1' : + $messages[] = __('This comment is already approved.') . ' ' . __( 'Edit comment' ) . ''; + break; + case 'trash' : + $messages[] = __( 'This comment is already in the Trash.' ) . ' ' . __( 'View Trash' ) . ''; + break; + case 'spam' : + $messages[] = __( 'This comment is already marked as spam.' ) . ' ' . __( 'Edit comment' ) . ''; + break; + } + } + + echo '

    ' . implode( "
    \n", $messages ) . '

    '; + } +} +?> + +views(); ?> + +
    + +search_box( __( 'Search Comments' ), 'comment' ); ?> + + + + + + + + + + + + + + + +display(); ?> +
    +
    + +
    + + diff --git a/backend/wp-admin/edit-form-advanced.php b/backend/wp-admin/edit-form-advanced.php new file mode 100644 index 0000000..2400521 --- /dev/null +++ b/backend/wp-admin/edit-form-advanced.php @@ -0,0 +1,768 @@ + 'ID', 'number' => 2 ) ); + + if ( count( $check_users ) > 1 ) + add_action( 'admin_footer', '_admin_notice_post_locked' ); + + unset( $check_users ); +} + +wp_enqueue_script('post'); +$_wp_editor_expand = $_content_editor_dfw = false; + +/** + * Filters whether to enable the 'expand' functionality in the post editor. + * + * @since 4.0.0 + * @since 4.1.0 Added the `$post_type` parameter. + * + * @param bool $expand Whether to enable the 'expand' functionality. Default true. + * @param string $post_type Post type. + */ +if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() && + ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) && + apply_filters( 'wp_editor_expand', true, $post_type ) ) { + + wp_enqueue_script('editor-expand'); + $_content_editor_dfw = true; + $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' ); +} + +if ( wp_is_mobile() ) + wp_enqueue_script( 'jquery-touch-punch' ); + +/** + * Post ID global + * @name $post_ID + * @var int + */ +$post_ID = isset($post_ID) ? (int) $post_ID : 0; +$user_ID = isset($user_ID) ? (int) $user_ID : 0; +$action = isset($action) ? $action : ''; + +if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) { + add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); + remove_post_type_support( $post_type, 'editor' ); +} + +$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); +if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { + if ( wp_attachment_is( 'audio', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); + } elseif ( wp_attachment_is( 'video', $post ) ) { + $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); + } +} + +if ( $thumbnail_support ) { + add_thickbox(); + wp_enqueue_media( array( 'post' => $post_ID ) ); +} + +// Add the local autosave notice HTML +add_action( 'admin_footer', '_local_storage_notice' ); + +/* + * @todo Document the $messages array(s). + */ +$permalink = get_permalink( $post_ID ); +if ( ! $permalink ) { + $permalink = ''; +} + +$messages = array(); + +$preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = ''; +$preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = ''; + +$preview_url = get_preview_post_link( $post ); + +$viewable = is_post_type_viewable( $post_type_object ); + +if ( $viewable ) { + + // Preview post link. + $preview_post_link_html = sprintf( ' %2$s', + esc_url( $preview_url ), + __( 'Preview post' ) + ); + + // Scheduled post preview link. + $scheduled_post_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'Preview post' ) + ); + + // View post link. + $view_post_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'View post' ) + ); + + // Preview page link. + $preview_page_link_html = sprintf( ' %2$s', + esc_url( $preview_url ), + __( 'Preview page' ) + ); + + // Scheduled page preview link. + $scheduled_page_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'Preview page' ) + ); + + // View page link. + $view_page_link_html = sprintf( ' %2$s', + esc_url( $permalink ), + __( 'View page' ) + ); + +} + +/* translators: Publish box date format, see https://secure.php.net/date */ +$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ); + +$messages['post'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Post updated.' ) . $view_post_link_html, + 2 => __( 'Custom field updated.' ), + 3 => __( 'Custom field deleted.' ), + 4 => __( 'Post updated.' ), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Post published.' ) . $view_post_link_html, + 7 => __( 'Post saved.' ), + 8 => __( 'Post submitted.' ) . $preview_post_link_html, + 9 => sprintf( __( 'Post scheduled for: %s.' ), '' . $scheduled_date . '' ) . $scheduled_post_link_html, + 10 => __( 'Post draft updated.' ) . $preview_post_link_html, +); +$messages['page'] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => __( 'Page updated.' ) . $view_page_link_html, + 2 => __( 'Custom field updated.' ), + 3 => __( 'Custom field deleted.' ), + 4 => __( 'Page updated.' ), + /* translators: %s: date and time of the revision */ + 5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => __( 'Page published.' ) . $view_page_link_html, + 7 => __( 'Page saved.' ), + 8 => __( 'Page submitted.' ) . $preview_page_link_html, + 9 => sprintf( __( 'Page scheduled for: %s.' ), '' . $scheduled_date . '' ) . $scheduled_page_link_html, + 10 => __( 'Page draft updated.' ) . $preview_page_link_html, +); +$messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now. + +/** + * Filters the post updated messages. + * + * @since 3.0.0 + * + * @param array $messages Post updated messages. For defaults @see $messages declarations above. + */ +$messages = apply_filters( 'post_updated_messages', $messages ); + +$message = false; +if ( isset($_GET['message']) ) { + $_GET['message'] = absint( $_GET['message'] ); + if ( isset($messages[$post_type][$_GET['message']]) ) + $message = $messages[$post_type][$_GET['message']]; + elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) ) + $message = $messages['post'][$_GET['message']]; +} + +$notice = false; +$form_extra = ''; +if ( 'auto-draft' == $post->post_status ) { + if ( 'edit' == $action ) + $post->post_title = ''; + $autosave = false; + $form_extra .= ""; +} else { + $autosave = wp_get_post_autosave( $post_ID ); +} + +$form_action = 'editpost'; +$nonce_action = 'update-post_' . $post_ID; +$form_extra .= ""; + +// Detect if there exists an autosave newer than the post and if that autosave is different than the post +if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { + foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { + if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { + $notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. View the autosave' ), get_edit_post_link( $autosave->ID ) ); + break; + } + } + // If this autosave isn't different from the current post, begone. + if ( ! $notice ) + wp_delete_post_revision( $autosave->ID ); + unset($autosave_field, $_autosave_field); +} + +$post_type_object = get_post_type_object($post_type); + +// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action). +require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); + + +$publish_callback_args = null; +if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) { + $revisions = wp_get_post_revisions( $post_ID ); + + // We should aim to show the revisions meta box only when there are revisions. + if ( count( $revisions ) > 1 ) { + reset( $revisions ); // Reset pointer for key() + $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) ); + add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core'); + } +} + +if ( 'attachment' == $post_type ) { + wp_enqueue_script( 'image-edit' ); + wp_enqueue_style( 'imgareaselect' ); + add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' ); + add_action( 'edit_form_after_title', 'edit_form_image_editor' ); + + if ( wp_attachment_is( 'audio', $post ) ) { + add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core' ); + } +} else { + add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); +} + +if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) + add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' ); + +// all taxonomies +foreach ( get_object_taxonomies( $post ) as $tax_name ) { + $taxonomy = get_taxonomy( $tax_name ); + if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) + continue; + + $label = $taxonomy->labels->name; + + if ( ! is_taxonomy_hierarchical( $tax_name ) ) + $tax_meta_box_id = 'tagsdiv-' . $tax_name; + else + $tax_meta_box_id = $tax_name . 'div'; + + add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) ); +} + +if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { + add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' ); +} + +if ( $thumbnail_support && current_user_can( 'upload_files' ) ) + add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low'); + +if ( post_type_supports($post_type, 'excerpt') ) + add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core'); + +if ( post_type_supports($post_type, 'trackbacks') ) + add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core'); + +if ( post_type_supports($post_type, 'custom-fields') ) + add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core'); + +/** + * Fires in the middle of built-in meta box registration. + * + * @since 2.1.0 + * @deprecated 3.7.0 Use 'add_meta_boxes' instead. + * + * @param WP_Post $post Post object. + */ +do_action( 'dbx_post_advanced', $post ); + +// Allow the Discussion meta box to show up if the post type supports comments, +// or if comments or pings are open. +if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core' ); +} + +$stati = get_post_stati( array( 'public' => true ) ); +if ( empty( $stati ) ) { + $stati = array( 'publish' ); +} +$stati[] = 'private'; + +if ( in_array( get_post_status( $post ), $stati ) ) { + // If the post type support comments, or the post has comments, allow the + // Comments meta box. + if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { + add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core' ); + } +} + +if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) + add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); + +if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { + add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core' ); +} + +/** + * Fires after all built-in meta boxes have been added. + * + * @since 3.0.0 + * + * @param string $post_type Post type. + * @param WP_Post $post Post object. + */ +do_action( 'add_meta_boxes', $post_type, $post ); + +/** + * Fires after all built-in meta boxes have been added, contextually for the given post type. + * + * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. + * + * @since 3.0.0 + * + * @param WP_Post $post Post object. + */ +do_action( "add_meta_boxes_{$post_type}", $post ); + +/** + * Fires after meta boxes have been added. + * + * Fires once for each of the default meta box contexts: normal, advanced, and side. + * + * @since 3.0.0 + * + * @param string $post_type Post type of the post. + * @param string $context string Meta box context. + * @param WP_Post $post Post object. + */ +do_action( 'do_meta_boxes', $post_type, 'normal', $post ); +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'do_meta_boxes', $post_type, 'side', $post ); + +add_screen_option('layout_columns', array('max' => 2, 'default' => 2) ); + +if ( 'post' == $post_type ) { + $customize_display = '

    ' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'customize-display', + 'title' => __('Customizing This Display'), + 'content' => $customize_display, + ) ); + + $title_and_editor = '

    ' . __('Title — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '

    '; + $title_and_editor .= '

    ' . __( 'Post editor — Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '

    '; + $title_and_editor .= '

    ' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '

    '; + $title_and_editor .= '

    ' . __( 'The Text mode allows you to enter HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '

    '; + $title_and_editor .= '

    ' . __( 'You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '

    '; + $title_and_editor .= '

    ' . __( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '

    '; + $title_and_editor .= '

    ' . __( 'Keyboard users: When you’re working in the visual editor, you can use Alt + F10 to access the toolbar.' ) . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'title-post-editor', + 'title' => __('Title and Post Editor'), + 'content' => $title_and_editor, + ) ); + + get_current_screen()->set_help_sidebar( + '

    ' . sprintf(__('You can also create posts with the Press This bookmarklet.'), 'tools.php') . '

    ' . + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Writing and Editing Posts') . '

    ' . + '

    ' . __('Support Forums') . '

    ' + ); +} elseif ( 'page' == $post_type ) { + $about_pages = '

    ' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.') . '

    ' . + '

    ' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.') . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'about-pages', + 'title' => __('About Pages'), + 'content' => $about_pages, + ) ); + + get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Adding New Pages') . '

    ' . + '

    ' . __('Documentation on Editing Pages') . '

    ' . + '

    ' . __('Support Forums') . '

    ' + ); +} elseif ( 'attachment' == $post_type ) { + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

    ' . __('This screen allows you to edit four fields for metadata in a file within the media library.') . '

    ' . + '

    ' . __('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.') . '

    ' . + '

    ' . __('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.') . '

    ' . + '

    ' . __('Remember to click Update Media to save metadata entered or changed.') . '

    ' + ) ); + + get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Edit Media') . '

    ' . + '

    ' . __('Support Forums') . '

    ' + ); +} + +if ( 'post' == $post_type || 'page' == $post_type ) { + $inserting_media = '

    ' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the “Create a new gallery” button.' ) . '

    '; + $inserting_media .= '

    ' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to learn more about embeds.' ) . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'inserting-media', + 'title' => __( 'Inserting Media' ), + 'content' => $inserting_media, + ) ); +} + +if ( 'post' == $post_type ) { + $publish_box = '

    ' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '

    '; + $publish_box .= '
    • ' . + __( 'Publish — You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) . + '
    • '; + + if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) { + $publish_box .= '
    • ' . __( 'Format — Post Formats designate how your theme will display a specific post. For example, you could have a standard blog post with a title and paragraphs, or a short aside that omits the title and contains a short text blurb. Please refer to the Codex for descriptions of each post format. Your theme could enable all or some of 10 possible formats.' ) . '
    • '; + } + + if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) { + /* translators: %s: Featured Image */ + $publish_box .= '
    • ' . sprintf( __( '%s — This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the image as a post thumbnail on the home page, a custom header, etc.' ), esc_html( $post_type_object->labels->featured_image ) ) . '
    • '; + } + + $publish_box .= '
    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'publish-box', + 'title' => __('Publish Settings'), + 'content' => $publish_box, + ) ); + + $discussion_settings = '

    ' . __('Send Trackbacks — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '

    '; + $discussion_settings .= '

    ' . __('Discussion — You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'discussion-settings', + 'title' => __('Discussion Settings'), + 'content' => $discussion_settings, + ) ); +} elseif ( 'page' == $post_type ) { + $page_attributes = '

    ' . __('Parent — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.') . '

    ' . + '

    ' . __('Template — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '

    ' . + '

    ' . __('Order — Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'page-attributes', + 'title' => __('Page Attributes'), + 'content' => $page_attributes, + ) ); +} + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); +?> + +
    +

    + +cap->create_posts ) ) { + echo ' ' . esc_html( $post_type_object->labels->add_new ) . ''; +} +?> + +
    + + +

    + + +

    + + +
    > + + + + + + + + + + + + + + +
    +
    +
    + + +
    +
    + + + +
    + +
    +public ? get_sample_permalink_html($post->ID) : ''; + +// As of 4.4, the Get Shortlink button is hidden by default. +if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) { + $shortlink = wp_get_shortlink($post->ID, 'post'); + + if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) { + $sample_permalink_html .= ''; + } +} + +if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { + $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status; +?> +
    + +
    + +
    + +
    + +
    + +post_content, 'content', array( + '_content_editor_dfw' => $_content_editor_dfw, + 'drag_drop_upload' => true, + 'tabfocus_elements' => 'content-html,save-post', + 'editor_height' => 300, + 'tinymce' => array( + 'resize' => false, + 'wp_autoresize_on' => $_wp_editor_expand, + 'add_unload_trigger' => false, + 'wp_keep_scroll_position' => ! $is_IE, + ), +) ); ?> + + + + +
    0' ); ?> +   +post_status ) { + echo ''; + if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) { + /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */ + printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); + } else { + /* translators: 1: Post edited date, 2: Post edited time */ + printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) ); + } + echo ''; + } ?> +
    + +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +
    +
    + + + +post_title ) : ?> + + diff --git a/backend/wp-admin/edit-form-comment.php b/backend/wp-admin/edit-form-comment.php new file mode 100644 index 0000000..2ae7957 --- /dev/null +++ b/backend/wp-admin/edit-form-comment.php @@ -0,0 +1,209 @@ + +
    +comment_ID) ?> +
    +

    + +
    + + + + +
    +
    +comment_post_ID > 0 ) : + $comment_link = get_comment_link( $comment ); +?> +
    + +
    + +
    +
    +
    + + + + + + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +' . __( 'Comment' ) . ''; + $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); + wp_editor( $comment->comment_content, 'content', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); + wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> +
    +
    + +
    +
    +

    +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +' . date_i18n( $datef, strtotime( $comment->comment_date ) ) . '' +); +?> + +
    + + +
    +
    + +comment_post_ID; +if ( current_user_can( 'edit_post', $post_id ) ) { + $post_link = ""; + $post_link .= esc_html( get_the_title( $post_id ) ) . ''; +} else { + $post_link = esc_html( get_the_title( $post_id ) ); +} +?> + +
    + ' . $post_link . '' + ); ?> +
    + +comment_parent ) : + $parent = get_comment( $comment->comment_parent ); + if ( $parent ) : + $parent_link = esc_url( get_comment_link( $parent ) ); + $name = get_comment_author( $parent ); + ?> +
    + ' . $name . '' + ); ?> +
    + + + + +
    +
    +
    + +
    +
    +comment_ID&_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . ( !EMPTY_TRASH_DAYS ? __('Delete Permanently') : __('Move to Trash') ) . "\n"; ?> +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    + + + + + + + +
    +
    +
    +
    + + + +Links / Edit Link' ), 'link-manager.php' ); + $submit_text = __('Update Link'); + $form_name = 'editlink'; + $nonce_action = 'update-bookmark_' . $link_id; +} else { + $heading = sprintf( __( 'Links / Add New Link' ), 'link-manager.php' ); + $submit_text = __('Add Link'); + $form_name = 'addlink'; + $nonce_action = 'add-bookmark'; +} + +require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); + +add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', null, 'side', 'core'); +add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core'); +add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', null, 'normal', 'core'); +add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', null, 'normal', 'core'); +add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core'); + +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'add_meta_boxes', 'link', $link ); + +/** + * Fires when link-specific meta boxes are added. + * + * @since 3.0.0 + * + * @param object $link Link object. + */ +do_action( 'add_meta_boxes_link', $link ); + +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'do_meta_boxes', 'link', 'normal', $link ); +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'do_meta_boxes', 'link', 'advanced', $link ); +/** This action is documented in wp-admin/edit-form-advanced.php */ +do_action( 'do_meta_boxes', 'link', 'side', $link ); + +add_screen_option('layout_columns', array('max' => 2, 'default' => 2) ); + +get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

    ' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '

    ' . + '

    ' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '

    ' . + '

    ' . __( 'XFN stands for XHTML Friends Network, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '

    ' +) ); + +get_current_screen()->set_help_sidebar( + '

    ' . __( 'For more information:' ) . '

    ' . + '

    ' . __( 'Documentation on Creating Links' ) . '

    ' . + '

    ' . __( 'Support Forums' ) . '

    ' +); + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); +?> + +
    +

    + + + +
    + + +

    + + +
    + + +
    + +
    +
    +
    +

    +
    + +

    +
    +
    + +
    +

    +
    + +

    http://wordpress.org/ — don’t forget the http://'); ?>

    +
    +
    + +
    +

    +
    + +

    +
    +
    +
    + +
    + +
    +
    + +
    + + + + + + + + +
    +
    + +
    +
    diff --git a/backend/wp-admin/edit-tag-form.php b/backend/wp-admin/edit-tag-form.php new file mode 100644 index 0000000..81e62a6 --- /dev/null +++ b/backend/wp-admin/edit-tag-form.php @@ -0,0 +1,277 @@ + + +
    +

    labels->edit_item; ?>

    + + + + + +
    + +
    > + + + + + + + + + + + + + slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : ''; + ?> + + + + + + + + + + + + + + +
    +

    +

    + 0, + 'hide_if_empty' => false, + 'taxonomy' => $taxonomy, + 'name' => 'parent', + 'orderby' => 'name', + 'selected' => $tag->parent, + 'exclude_tree' => $tag->term_id, + 'hierarchical' => true, + 'show_option_none' => __( 'None' ), + ); + + /** This filter is documented in wp-admin/edit-tags.php */ + $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' ); + wp_dropdown_categories( $dropdown_args ); ?> + +

    + +

    + +
    +

    + + +
    + + + + term_id ) ) : ?> + + term_id", 'delete-tag_' . $tag->term_id ) ) ?>"> + + + +
    + +
    +
    + + + +name, get_taxonomies( array( 'show_ui' => true ) ) ) ) { + wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); +} + +if ( ! current_user_can( $tax->cap->manage_terms ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '

    ', + 403 + ); +} + +/** + * $post_type is set when the WP_Terms_List_Table instance is created + * + * @global string $post_type + */ +global $post_type; + +$wp_list_table = _get_list_table('WP_Terms_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); + +$title = $tax->labels->name; + +if ( 'post' != $post_type ) { + $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type"; + $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; +} elseif ( 'link_category' == $tax->name ) { + $parent_file = 'link-manager.php'; + $submenu_file = 'edit-tags.php?taxonomy=link_category'; +} else { + $parent_file = 'edit.php'; + $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; +} + +add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) ); + +get_current_screen()->set_screen_reader_content( array( + 'heading_pagination' => $tax->labels->items_list_navigation, + 'heading_list' => $tax->labels->items_list, +) ); + +$location = false; +$referer = wp_get_referer(); +if ( ! $referer ) { // For POST requests. + $referer = wp_unslash( $_SERVER['REQUEST_URI'] ); +} +$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer ); +switch ( $wp_list_table->current_action() ) { + +case 'add-tag': + check_admin_referer( 'add-tag', '_wpnonce_add-tag' ); + + if ( ! current_user_can( $tax->cap->edit_terms ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '

    ', + 403 + ); + } + + $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); + if ( $ret && !is_wp_error( $ret ) ) + $location = add_query_arg( 'message', 1, $referer ); + else + $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); + + break; + +case 'delete': + if ( ! isset( $_REQUEST['tag_ID'] ) ) { + break; + } + + $tag_ID = (int) $_REQUEST['tag_ID']; + check_admin_referer( 'delete-tag_' . $tag_ID ); + + if ( ! current_user_can( 'delete_term', $tag_ID ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to delete this item.' ) . '

    ', + 403 + ); + } + + wp_delete_term( $tag_ID, $taxonomy ); + + $location = add_query_arg( 'message', 2, $referer ); + + // When deleting a term, prevent the action from redirecting back to a term that no longer exists. + $location = remove_query_arg( array( 'tag_ID', 'action' ), $location ); + + break; + +case 'bulk-delete': + check_admin_referer( 'bulk-tags' ); + + if ( ! current_user_can( $tax->cap->delete_terms ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to delete these items.' ) . '

    ', + 403 + ); + } + + $tags = (array) $_REQUEST['delete_tags']; + foreach ( $tags as $tag_ID ) { + wp_delete_term( $tag_ID, $taxonomy ); + } + + $location = add_query_arg( 'message', 6, $referer ); + + break; + +case 'edit': + if ( ! isset( $_REQUEST['tag_ID'] ) ) { + break; + } + + $term_id = (int) $_REQUEST['tag_ID']; + $term = get_term( $term_id ); + + if ( ! $term instanceof WP_Term ) { + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); + } + + wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); + exit; + +case 'editedtag': + $tag_ID = (int) $_POST['tag_ID']; + check_admin_referer( 'update-tag_' . $tag_ID ); + + if ( ! current_user_can( 'edit_term', $tag_ID ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to edit this item.' ) . '

    ', + 403 + ); + } + + $tag = get_term( $tag_ID, $taxonomy ); + if ( ! $tag ) + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); + + $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); + + if ( $ret && ! is_wp_error( $ret ) ) { + $location = add_query_arg( 'message', 3, $referer ); + } else { + $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer ); + } + break; +default: + if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) { + break; + } + check_admin_referer( 'bulk-tags' ); + $tags = (array) $_REQUEST['delete_tags']; + /** This action is documented in wp-admin/edit-comments.php */ + $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); + break; +} + +if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) { + $location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ); +} + +if ( $location ) { + if ( $pagenum > 1 ) { + $location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages. + } + + /** + * Filters the taxonomy redirect destination URL. + * + * @since 4.6.0 + * + * @param string $location The destination URL. + * @param object $tax The taxonomy object. + */ + wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) ); + exit; +} + +$wp_list_table->prepare_items(); +$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); + +if ( $pagenum > $total_pages && $total_pages > 0 ) { + wp_redirect( add_query_arg( 'paged', $total_pages ) ); + exit; +} + +wp_enqueue_script('admin-tags'); +if ( current_user_can($tax->cap->edit_terms) ) + wp_enqueue_script('inline-edit-tax'); + +if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) { + $help =''; + if ( 'category' == $taxonomy ) + $help = '

    ' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your writing settings.' ) , 'options-writing.php' ) . '

    '; + elseif ( 'link_category' == $taxonomy ) + $help = '

    ' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '

    '; + else + $help = '

    ' . __( 'You can assign keywords to your posts using tags. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '

    '; + + if ( 'link_category' == $taxonomy ) + $help .= '

    ' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '

    '; + else + $help .='

    ' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => $help, + ) ); + + if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { + if ( 'category' == $taxonomy ) + $help = '

    ' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '

    '; + else + $help = '

    ' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '

    '; + + $help .= '
      ' . + '
    • ' . __( 'Name — The name is how it appears on your site.' ) . '
    • '; + + if ( ! global_terms_enabled() ) + $help .= '
    • ' . __( 'Slug — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '
    • '; + + if ( 'category' == $taxonomy ) + $help .= '
    • ' . __( 'Parent — Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '
    • '; + + $help .= '
    • ' . __( 'Description — The description is not prominent by default; however, some themes may display it.' ) . '
    • ' . + '
    ' . + '

    ' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '

    '; + + get_current_screen()->add_help_tab( array( + 'id' => 'adding-terms', + 'title' => 'category' == $taxonomy ? __( 'Adding Categories' ) : __( 'Adding Tags' ), + 'content' => $help, + ) ); + } + + $help = '

    ' . __( 'For more information:' ) . '

    '; + + if ( 'category' == $taxonomy ) + $help .= '

    ' . __( 'Documentation on Categories' ) . '

    '; + elseif ( 'link_category' == $taxonomy ) + $help .= '

    ' . __( 'Documentation on Link Categories' ) . '

    '; + else + $help .= '

    ' . __( 'Documentation on Tags' ) . '

    '; + + $help .= '

    ' . __('Support Forums') . '

    '; + + get_current_screen()->set_help_sidebar( $help ); + + unset( $help ); +} + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); + +/** Also used by the Edit Tag form */ +require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); + +$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated'; + +if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) { + $import_link = admin_url( 'admin.php?import=wpcat2tag' ); +} else { + $import_link = admin_url( 'import.php' ); +} + +?> + +
    +

    + +' . __( 'Search results for “%s”' ) . '', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); +} +?> + +
    + + +

    + +
    + +
    + + + +search_box( $tax->labels->search_items, 'tag' ); ?> + +
    + +
    + +
    +
    + +cap->edit_terms) ) { + if ( 'category' == $taxonomy ) { + /** + * Fires before the Add Category form. + * + * @since 2.1.0 + * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead. + * + * @param object $arg Optional arguments cast to an object. + */ + do_action( 'add_category_form_pre', (object) array( 'parent' => 0 ) ); + } elseif ( 'link_category' == $taxonomy ) { + /** + * Fires before the link category form. + * + * @since 2.3.0 + * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead. + * + * @param object $arg Optional arguments cast to an object. + */ + do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) ); + } else { + /** + * Fires before the Add Tag form. + * + * @since 2.5.0 + * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead. + * + * @param string $taxonomy The taxonomy slug. + */ + do_action( 'add_tag_form_pre', $taxonomy ); + } + + /** + * Fires before the Add Term form for all taxonomies. + * + * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. + * + * @since 3.0.0 + * + * @param string $taxonomy The taxonomy slug. + */ + do_action( "{$taxonomy}_pre_add_form", $taxonomy ); +?> + +
    +

    labels->add_new_item; ?>

    +
    > + + + + + + +
    + + +

    +
    + +
    + + +

    +
    + + +
    + + 0, + 'hide_if_empty' => false, + 'taxonomy' => $taxonomy, + 'name' => 'parent', + 'orderby' => 'name', + 'hierarchical' => true, + 'show_option_none' => __( 'None' ), + ); + + /** + * Filters the taxonomy parent drop-down on the Edit Term page. + * + * @since 3.7.0 + * @since 4.2.0 Added `$context` parameter. + * + * @param array $dropdown_args { + * An array of taxonomy parent drop-down arguments. + * + * @type int|bool $hide_empty Whether to hide terms not attached to any posts. Default 0|false. + * @type bool $hide_if_empty Whether to hide the drop-down if no terms exist. Default false. + * @type string $taxonomy The taxonomy slug. + * @type string $name Value of the name attribute to use for the drop-down select element. + * Default 'parent'. + * @type string $orderby The field to order by. Default 'name'. + * @type bool $hierarchical Whether the taxonomy is hierarchical. Default true. + * @type string $show_option_none Label to display if there are no terms. Default 'None'. + * } + * @param string $taxonomy The taxonomy slug. + * @param string $context Filter context. Accepts 'new' or 'edit'. + */ + $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' ); + + wp_dropdown_categories( $dropdown_args ); + ?> + +

    + +

    + +
    + +
    + + +

    +
    + +labels->add_new_item ); + +if ( 'category' == $taxonomy ) { + /** + * Fires at the end of the Edit Category form. + * + * @since 2.1.0 + * @deprecated 3.0.0 Use {$taxonomy}_add_form instead. + * + * @param object $arg Optional arguments cast to an object. + */ + do_action( 'edit_category_form', (object) array( 'parent' => 0 ) ); +} elseif ( 'link_category' == $taxonomy ) { + /** + * Fires at the end of the Edit Link form. + * + * @since 2.3.0 + * @deprecated 3.0.0 Use {$taxonomy}_add_form instead. + * + * @param object $arg Optional arguments cast to an object. + */ + do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) ); +} else { + /** + * Fires at the end of the Add Tag form. + * + * @since 2.7.0 + * @deprecated 3.0.0 Use {$taxonomy}_add_form instead. + * + * @param string $taxonomy The taxonomy slug. + */ + do_action( 'add_tag_form', $taxonomy ); +} + +/** + * Fires at the end of the Add Term form for all taxonomies. + * + * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. + * + * @since 3.0.0 + * + * @param string $taxonomy The taxonomy slug. + */ +do_action( "{$taxonomy}_add_form", $taxonomy ); +?> +
    + + +
    +
    + +
    +
    + +views(); ?> + +
    + + + +display(); ?> + +
    + + +
    +

    + ' . __( 'Note:' ) . '
    '; + printf( + /* translators: %s: default category */ + __( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ), + /** This filter is documented in wp-includes/category-template.php */ + '' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ), '', '' ) . '' + ); + ?> +

    + +

    category to tag converter.' ), esc_url( $import_link ) ) ?>

    + +
    + +
    +

    tag to category converter.' ), esc_url( $import_link ) ) ;?>

    +
    + + +
    +
    + +
    +
    + + + +inline_edit(); + +include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/backend/wp-admin/edit.php b/backend/wp-admin/edit.php new file mode 100644 index 0000000..258952e --- /dev/null +++ b/backend/wp-admin/edit.php @@ -0,0 +1,376 @@ + true ) ) ) ) { + wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); +} + +if ( 'attachment' === $typenow ) { + if ( wp_redirect( admin_url( 'upload.php' ) ) ) { + exit; + } +} + +/** + * @global string $post_type + * @global WP_Post_Type $post_type_object + */ +global $post_type, $post_type_object; + +$post_type = $typenow; +$post_type_object = get_post_type_object( $post_type ); + +if ( ! $post_type_object ) + wp_die( __( 'Invalid post type.' ) ); + +if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) { + wp_die( + '

    ' . __( 'You need a higher level of permission.' ) . '

    ' . + '

    ' . __( 'Sorry, you are not allowed to edit posts in this post type.' ) . '

    ', + 403 + ); +} + +$wp_list_table = _get_list_table('WP_Posts_List_Table'); +$pagenum = $wp_list_table->get_pagenum(); + +// Back-compat for viewing comments of an entry +foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { + if ( ! empty( $_REQUEST[ $_redirect ] ) ) { + wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); + exit; + } +} +unset( $_redirect ); + +if ( 'post' != $post_type ) { + $parent_file = "edit.php?post_type=$post_type"; + $submenu_file = "edit.php?post_type=$post_type"; + $post_new_file = "post-new.php?post_type=$post_type"; +} else { + $parent_file = 'edit.php'; + $submenu_file = 'edit.php'; + $post_new_file = 'post-new.php'; +} + +$doaction = $wp_list_table->current_action(); + +if ( $doaction ) { + check_admin_referer('bulk-posts'); + + $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() ); + if ( ! $sendback ) + $sendback = admin_url( $parent_file ); + $sendback = add_query_arg( 'paged', $pagenum, $sendback ); + if ( strpos($sendback, 'post.php') !== false ) + $sendback = admin_url($post_new_file); + + if ( 'delete_all' == $doaction ) { + // Prepare for deletion of all posts with a specified post status (i.e. Empty trash). + $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']); + // Validate the post status exists. + if ( get_post_status_object( $post_status ) ) { + $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); + } + $doaction = 'delete'; + } elseif ( isset( $_REQUEST['media'] ) ) { + $post_ids = $_REQUEST['media']; + } elseif ( isset( $_REQUEST['ids'] ) ) { + $post_ids = explode( ',', $_REQUEST['ids'] ); + } elseif ( !empty( $_REQUEST['post'] ) ) { + $post_ids = array_map('intval', $_REQUEST['post']); + } + + if ( !isset( $post_ids ) ) { + wp_redirect( $sendback ); + exit; + } + + switch ( $doaction ) { + case 'trash': + $trashed = $locked = 0; + + foreach ( (array) $post_ids as $post_id ) { + if ( !current_user_can( 'delete_post', $post_id) ) + wp_die( __('Sorry, you are not allowed to move this item to the Trash.') ); + + if ( wp_check_post_lock( $post_id ) ) { + $locked++; + continue; + } + + if ( !wp_trash_post($post_id) ) + wp_die( __('Error in moving to Trash.') ); + + $trashed++; + } + + $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback ); + break; + case 'untrash': + $untrashed = 0; + foreach ( (array) $post_ids as $post_id ) { + if ( !current_user_can( 'delete_post', $post_id) ) + wp_die( __('Sorry, you are not allowed to restore this item from the Trash.') ); + + if ( !wp_untrash_post($post_id) ) + wp_die( __('Error in restoring from Trash.') ); + + $untrashed++; + } + $sendback = add_query_arg('untrashed', $untrashed, $sendback); + break; + case 'delete': + $deleted = 0; + foreach ( (array) $post_ids as $post_id ) { + $post_del = get_post($post_id); + + if ( !current_user_can( 'delete_post', $post_id ) ) + wp_die( __('Sorry, you are not allowed to delete this item.') ); + + if ( $post_del->post_type == 'attachment' ) { + if ( ! wp_delete_attachment($post_id) ) + wp_die( __('Error in deleting.') ); + } else { + if ( !wp_delete_post($post_id) ) + wp_die( __('Error in deleting.') ); + } + $deleted++; + } + $sendback = add_query_arg('deleted', $deleted, $sendback); + break; + case 'edit': + if ( isset($_REQUEST['bulk_edit']) ) { + $done = bulk_edit_posts($_REQUEST); + + if ( is_array($done) ) { + $done['updated'] = count( $done['updated'] ); + $done['skipped'] = count( $done['skipped'] ); + $done['locked'] = count( $done['locked'] ); + $sendback = add_query_arg( $done, $sendback ); + } + } + break; + default: + /** This action is documented in wp-admin/edit-comments.php */ + $sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $post_ids ); + break; + } + + $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback ); + + wp_redirect($sendback); + exit(); +} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) { + wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) ); + exit; +} + +$wp_list_table->prepare_items(); + +wp_enqueue_script('inline-edit-post'); +wp_enqueue_script('heartbeat'); + +$title = $post_type_object->labels->name; + +if ( 'post' == $post_type ) { + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

    ' . __('This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.') . '

    ' + ) ); + get_current_screen()->add_help_tab( array( + 'id' => 'screen-content', + 'title' => __('Screen Content'), + 'content' => + '

    ' . __('You can customize the display of this screen’s contents in a number of ways:') . '

    ' . + '
      ' . + '
    • ' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '
    • ' . + '
    • ' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '
    • ' . + '
    • ' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . '
    • ' . + '
    • ' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '
    • ' . + '
    ' + ) ); + get_current_screen()->add_help_tab( array( + 'id' => 'action-links', + 'title' => __('Available Actions'), + 'content' => + '

    ' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '

    ' . + '
      ' . + '
    • ' . __('Edit takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . '
    • ' . + '
    • ' . __('Quick Edit provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.') . '
    • ' . + '
    • ' . __('Trash removes your post from this list and places it in the trash, from which you can permanently delete it.') . '
    • ' . + '
    • ' . __('Preview will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post’s status.') . '
    • ' . + '
    ' + ) ); + get_current_screen()->add_help_tab( array( + 'id' => 'bulk-actions', + 'title' => __('Bulk Actions'), + 'content' => + '

    ' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '

    ' . + '

    ' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '

    ' + ) ); + + get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Managing Posts') . '

    ' . + '

    ' . __('Support Forums') . '

    ' + ); + +} elseif ( 'page' == $post_type ) { + get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

    ' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.') . '

    ' + ) ); + get_current_screen()->add_help_tab( array( + 'id' => 'managing-pages', + 'title' => __('Managing Pages'), + 'content' => + '

    ' . __('Managing pages is very similar to managing posts, and the screens can be customized in the same way.') . '

    ' . + '

    ' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.') . '

    ' + ) ); + + get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Managing Pages') . '

    ' . + '

    ' . __('Support Forums') . '

    ' + ); + +} + +get_current_screen()->set_screen_reader_content( array( + 'heading_views' => $post_type_object->labels->filter_items_list, + 'heading_pagination' => $post_type_object->labels->items_list_navigation, + 'heading_list' => $post_type_object->labels->items_list, +) ); + +add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) ); + +$bulk_counts = array( + 'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0, + 'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0, + 'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0, + 'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0, + 'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0, +); + +$bulk_messages = array(); +$bulk_messages['post'] = array( + 'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ), + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) : + _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s post restored from the Trash.', '%s posts restored from the Trash.', $bulk_counts['untrashed'] ), +); +$bulk_messages['page'] = array( + 'updated' => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ), + 'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) : + _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ), + 'deleted' => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $bulk_counts['deleted'] ), + 'trashed' => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $bulk_counts['trashed'] ), + 'untrashed' => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $bulk_counts['untrashed'] ), +); + +/** + * Filters the bulk action updated messages. + * + * By default, custom post types use the messages for the 'post' post type. + * + * @since 3.7.0 + * + * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. Messages are + * keyed with 'updated', 'locked', 'deleted', 'trashed', and 'untrashed'. + * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings. + */ +$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts ); +$bulk_counts = array_filter( $bulk_counts ); + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); +?> +
    +

    labels->name ); +?>

    + +cap->create_posts ) ) { + echo ' ' . esc_html( $post_type_object->labels->add_new ) . ''; +} + +if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { + /* translators: %s: search keywords */ + printf( ' ' . __( 'Search results for “%s”' ) . '', get_search_query() ); +} +?> + +
    + + $count ) { + if ( isset( $bulk_messages[ $post_type ][ $message ] ) ) + $messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) ); + elseif ( isset( $bulk_messages['post'][ $message ] ) ) + $messages[] = sprintf( $bulk_messages['post'][ $message ], number_format_i18n( $count ) ); + + if ( $message == 'trashed' && isset( $_REQUEST['ids'] ) ) { + $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] ); + $messages[] = '' . __('Undo') . ''; + } +} + +if ( $messages ) + echo '

    ' . join( ' ', $messages ) . '

    '; +unset( $messages ); + +$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] ); +?> + +views(); ?> + +
    + +search_box( $post_type_object->labels->search_items, 'post' ); ?> + + + + + + + + + + + + +display(); ?> + +
    + +has_items() ) + $wp_list_table->inline_edit(); +?> + +
    +
    +
    + + + +add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => '

    ' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '

    ' . + '

    ' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '

    ', +) ); + +get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Export') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +// If the 'download' URL parameter is set, a WXR export file is baked and returned. +if ( isset( $_GET['download'] ) ) { + $args = array(); + + if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { + $args['content'] = 'all'; + } elseif ( 'posts' == $_GET['content'] ) { + $args['content'] = 'post'; + + if ( $_GET['cat'] ) + $args['category'] = (int) $_GET['cat']; + + if ( $_GET['post_author'] ) + $args['author'] = (int) $_GET['post_author']; + + if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { + $args['start_date'] = $_GET['post_start_date']; + $args['end_date'] = $_GET['post_end_date']; + } + + if ( $_GET['post_status'] ) + $args['status'] = $_GET['post_status']; + } elseif ( 'pages' == $_GET['content'] ) { + $args['content'] = 'page'; + + if ( $_GET['page_author'] ) + $args['author'] = (int) $_GET['page_author']; + + if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { + $args['start_date'] = $_GET['page_start_date']; + $args['end_date'] = $_GET['page_end_date']; + } + + if ( $_GET['page_status'] ) + $args['status'] = $_GET['page_status']; + } elseif ( 'attachment' == $_GET['content'] ) { + $args['content'] = 'attachment'; + + if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { + $args['start_date'] = $_GET['attachment_start_date']; + $args['end_date'] = $_GET['attachment_end_date']; + } + } + else { + $args['content'] = $_GET['content']; + } + + /** + * Filters the export args. + * + * @since 3.5.0 + * + * @param array $args The arguments to send to the exporter. + */ + $args = apply_filters( 'export_args', $args ); + + export_wp( $args ); + die(); +} + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); + +/** + * Create the date options fields for exporting a given post type. + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global WP_Locale $wp_locale Date and Time Locale object. + * + * @since 3.1.0 + * + * @param string $post_type The post type. Default 'post'. + */ +function export_date_options( $post_type = 'post' ) { + global $wpdb, $wp_locale; + + $months = $wpdb->get_results( $wpdb->prepare( " + SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = %s AND post_status != 'auto-draft' + ORDER BY post_date DESC + ", $post_type ) ); + + $month_count = count( $months ); + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) + return; + + foreach ( $months as $date ) { + if ( 0 == $date->year ) + continue; + + $month = zeroise( $date->month, 2 ); + echo ''; + } +} +?> + +
    +

    + +

    +

    +

    + +

    +
    +
    + + +

    +

    + +

    +
      +
    • + +
    • +
    • + +
    • +
    • +
      + + + + + +
      +
    • +
    • + + +
    • +
    + +

    +
      +
    • + +
    • +
    • +
      + + + + + +
      +
    • +
    • + + +
    • +
    + + false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> +

    + + +

    +
      +
    • +
      + + + + + +
      +
    • +
    + +
    + + + +
    +
    + + diff --git a/backend/wp-admin/freedoms.php b/backend/wp-admin/freedoms.php new file mode 100644 index 0000000..229137a --- /dev/null +++ b/backend/wp-admin/freedoms.php @@ -0,0 +1,71 @@ + +
    + +

    + +

    + +
    + + + + + +
    +

    + +

    WordPress.org stats page.' ), 'https://wordpress.org/about/stats/' ); ?>

    + +

    WordPress.org/about/privacy.' ), 'https://wordpress.org/about/privacy/' ); ?>

    +
    + + +
    +

    license, the GPL.' ), 'https://wordpress.org/about/license/' ); ?>

    + +
      +
    1. +
    2. +
    3. +
    4. +
    + +

    check out our trademark guidelines first.' ), 'https://wordpressfoundation.org/trademark-policy/' ); ?>

    + +

    plugins and themes there. If you get a plugin or theme from another source, make sure to ask them if it’s GPL first. If they don’t respect the WordPress license, we don’t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' ); ?>

    + +

    Free Software Foundation.' ); ?>

    +
    + + +
    + diff --git a/backend/wp-admin/images/align-center-2x.png b/backend/wp-admin/images/align-center-2x.png new file mode 100644 index 0000000..0b62734 Binary files /dev/null and b/backend/wp-admin/images/align-center-2x.png differ diff --git a/backend/wp-admin/images/align-center.png b/backend/wp-admin/images/align-center.png new file mode 100644 index 0000000..e7bc807 Binary files /dev/null and b/backend/wp-admin/images/align-center.png differ diff --git a/backend/wp-admin/images/align-left-2x.png b/backend/wp-admin/images/align-left-2x.png new file mode 100644 index 0000000..1b2d428 Binary files /dev/null and b/backend/wp-admin/images/align-left-2x.png differ diff --git a/backend/wp-admin/images/align-left.png b/backend/wp-admin/images/align-left.png new file mode 100644 index 0000000..b438f7e Binary files /dev/null and b/backend/wp-admin/images/align-left.png differ diff --git a/backend/wp-admin/images/align-none-2x.png b/backend/wp-admin/images/align-none-2x.png new file mode 100644 index 0000000..a64a0be Binary files /dev/null and b/backend/wp-admin/images/align-none-2x.png differ diff --git a/backend/wp-admin/images/align-none.png b/backend/wp-admin/images/align-none.png new file mode 100644 index 0000000..b72df64 Binary files /dev/null and b/backend/wp-admin/images/align-none.png differ diff --git a/backend/wp-admin/images/align-right-2x.png b/backend/wp-admin/images/align-right-2x.png new file mode 100644 index 0000000..0131505 Binary files /dev/null and b/backend/wp-admin/images/align-right-2x.png differ diff --git a/backend/wp-admin/images/align-right.png b/backend/wp-admin/images/align-right.png new file mode 100644 index 0000000..86a1b2e Binary files /dev/null and b/backend/wp-admin/images/align-right.png differ diff --git a/backend/wp-admin/images/arrows-2x.png b/backend/wp-admin/images/arrows-2x.png new file mode 100644 index 0000000..0b0c53d Binary files /dev/null and b/backend/wp-admin/images/arrows-2x.png differ diff --git a/backend/wp-admin/images/arrows.png b/backend/wp-admin/images/arrows.png new file mode 100644 index 0000000..9e4a96c Binary files /dev/null and b/backend/wp-admin/images/arrows.png differ diff --git a/backend/wp-admin/images/browser-rtl.png b/backend/wp-admin/images/browser-rtl.png new file mode 100644 index 0000000..a4d3695 Binary files /dev/null and b/backend/wp-admin/images/browser-rtl.png differ diff --git a/backend/wp-admin/images/browser.png b/backend/wp-admin/images/browser.png new file mode 100644 index 0000000..83ead47 Binary files /dev/null and b/backend/wp-admin/images/browser.png differ diff --git a/backend/wp-admin/images/bubble_bg-2x.gif b/backend/wp-admin/images/bubble_bg-2x.gif new file mode 100644 index 0000000..77ac312 Binary files /dev/null and b/backend/wp-admin/images/bubble_bg-2x.gif differ diff --git a/backend/wp-admin/images/bubble_bg.gif b/backend/wp-admin/images/bubble_bg.gif new file mode 100644 index 0000000..f3bfdcd Binary files /dev/null and b/backend/wp-admin/images/bubble_bg.gif differ diff --git a/backend/wp-admin/images/comment-grey-bubble-2x.png b/backend/wp-admin/images/comment-grey-bubble-2x.png new file mode 100644 index 0000000..0eec4a6 Binary files /dev/null and b/backend/wp-admin/images/comment-grey-bubble-2x.png differ diff --git a/backend/wp-admin/images/comment-grey-bubble.png b/backend/wp-admin/images/comment-grey-bubble.png new file mode 100644 index 0000000..558ee8f Binary files /dev/null and b/backend/wp-admin/images/comment-grey-bubble.png differ diff --git a/backend/wp-admin/images/date-button-2x.gif b/backend/wp-admin/images/date-button-2x.gif new file mode 100644 index 0000000..f658b51 Binary files /dev/null and b/backend/wp-admin/images/date-button-2x.gif differ diff --git a/backend/wp-admin/images/date-button.gif b/backend/wp-admin/images/date-button.gif new file mode 100644 index 0000000..5080544 Binary files /dev/null and b/backend/wp-admin/images/date-button.gif differ diff --git a/backend/wp-admin/images/generic.png b/backend/wp-admin/images/generic.png new file mode 100644 index 0000000..00575a0 Binary files /dev/null and b/backend/wp-admin/images/generic.png differ diff --git a/backend/wp-admin/images/icons32-2x.png b/backend/wp-admin/images/icons32-2x.png new file mode 100644 index 0000000..b86b727 Binary files /dev/null and b/backend/wp-admin/images/icons32-2x.png differ diff --git a/backend/wp-admin/images/icons32-vs-2x.png b/backend/wp-admin/images/icons32-vs-2x.png new file mode 100644 index 0000000..54e2fb2 Binary files /dev/null and b/backend/wp-admin/images/icons32-vs-2x.png differ diff --git a/backend/wp-admin/images/icons32-vs.png b/backend/wp-admin/images/icons32-vs.png new file mode 100644 index 0000000..e46d6be Binary files /dev/null and b/backend/wp-admin/images/icons32-vs.png differ diff --git a/backend/wp-admin/images/icons32.png b/backend/wp-admin/images/icons32.png new file mode 100644 index 0000000..e491b1a Binary files /dev/null and b/backend/wp-admin/images/icons32.png differ diff --git a/backend/wp-admin/images/imgedit-icons-2x.png b/backend/wp-admin/images/imgedit-icons-2x.png new file mode 100644 index 0000000..98dd412 Binary files /dev/null and b/backend/wp-admin/images/imgedit-icons-2x.png differ diff --git a/backend/wp-admin/images/imgedit-icons.png b/backend/wp-admin/images/imgedit-icons.png new file mode 100644 index 0000000..0d544ee Binary files /dev/null and b/backend/wp-admin/images/imgedit-icons.png differ diff --git a/backend/wp-admin/images/list-2x.png b/backend/wp-admin/images/list-2x.png new file mode 100644 index 0000000..05c6eb3 Binary files /dev/null and b/backend/wp-admin/images/list-2x.png differ diff --git a/backend/wp-admin/images/list.png b/backend/wp-admin/images/list.png new file mode 100644 index 0000000..85d1295 Binary files /dev/null and b/backend/wp-admin/images/list.png differ diff --git a/backend/wp-admin/images/loading.gif b/backend/wp-admin/images/loading.gif new file mode 100644 index 0000000..1e9dea9 Binary files /dev/null and b/backend/wp-admin/images/loading.gif differ diff --git a/backend/wp-admin/images/marker.png b/backend/wp-admin/images/marker.png new file mode 100644 index 0000000..30313b8 Binary files /dev/null and b/backend/wp-admin/images/marker.png differ diff --git a/backend/wp-admin/images/mask.png b/backend/wp-admin/images/mask.png new file mode 100644 index 0000000..0fc9cbe Binary files /dev/null and b/backend/wp-admin/images/mask.png differ diff --git a/backend/wp-admin/images/media-button-2x.png b/backend/wp-admin/images/media-button-2x.png new file mode 100644 index 0000000..b8f8ed4 Binary files /dev/null and b/backend/wp-admin/images/media-button-2x.png differ diff --git a/backend/wp-admin/images/media-button-image.gif b/backend/wp-admin/images/media-button-image.gif new file mode 100644 index 0000000..56a9747 Binary files /dev/null and b/backend/wp-admin/images/media-button-image.gif differ diff --git a/backend/wp-admin/images/media-button-music.gif b/backend/wp-admin/images/media-button-music.gif new file mode 100644 index 0000000..42e65b2 Binary files /dev/null and b/backend/wp-admin/images/media-button-music.gif differ diff --git a/backend/wp-admin/images/media-button-other.gif b/backend/wp-admin/images/media-button-other.gif new file mode 100644 index 0000000..c7544ec Binary files /dev/null and b/backend/wp-admin/images/media-button-other.gif differ diff --git a/backend/wp-admin/images/media-button-video.gif b/backend/wp-admin/images/media-button-video.gif new file mode 100644 index 0000000..405083b Binary files /dev/null and b/backend/wp-admin/images/media-button-video.gif differ diff --git a/backend/wp-admin/images/media-button.png b/backend/wp-admin/images/media-button.png new file mode 100644 index 0000000..752ee45 Binary files /dev/null and b/backend/wp-admin/images/media-button.png differ diff --git a/backend/wp-admin/images/menu-2x.png b/backend/wp-admin/images/menu-2x.png new file mode 100644 index 0000000..7131763 Binary files /dev/null and b/backend/wp-admin/images/menu-2x.png differ diff --git a/backend/wp-admin/images/menu-vs-2x.png b/backend/wp-admin/images/menu-vs-2x.png new file mode 100644 index 0000000..99b3823 Binary files /dev/null and b/backend/wp-admin/images/menu-vs-2x.png differ diff --git a/backend/wp-admin/images/menu-vs.png b/backend/wp-admin/images/menu-vs.png new file mode 100644 index 0000000..fe28108 Binary files /dev/null and b/backend/wp-admin/images/menu-vs.png differ diff --git a/backend/wp-admin/images/menu.png b/backend/wp-admin/images/menu.png new file mode 100644 index 0000000..c1d15af Binary files /dev/null and b/backend/wp-admin/images/menu.png differ diff --git a/backend/wp-admin/images/no.png b/backend/wp-admin/images/no.png new file mode 100644 index 0000000..59c35bd Binary files /dev/null and b/backend/wp-admin/images/no.png differ diff --git a/backend/wp-admin/images/post-formats-vs.png b/backend/wp-admin/images/post-formats-vs.png new file mode 100644 index 0000000..d77f91c Binary files /dev/null and b/backend/wp-admin/images/post-formats-vs.png differ diff --git a/backend/wp-admin/images/post-formats.png b/backend/wp-admin/images/post-formats.png new file mode 100644 index 0000000..cae309e Binary files /dev/null and b/backend/wp-admin/images/post-formats.png differ diff --git a/backend/wp-admin/images/post-formats32-vs.png b/backend/wp-admin/images/post-formats32-vs.png new file mode 100644 index 0000000..f565340 Binary files /dev/null and b/backend/wp-admin/images/post-formats32-vs.png differ diff --git a/backend/wp-admin/images/post-formats32.png b/backend/wp-admin/images/post-formats32.png new file mode 100644 index 0000000..69ec095 Binary files /dev/null and b/backend/wp-admin/images/post-formats32.png differ diff --git a/backend/wp-admin/images/resize-2x.gif b/backend/wp-admin/images/resize-2x.gif new file mode 100644 index 0000000..315ea06 Binary files /dev/null and b/backend/wp-admin/images/resize-2x.gif differ diff --git a/backend/wp-admin/images/resize-rtl-2x.gif b/backend/wp-admin/images/resize-rtl-2x.gif new file mode 100644 index 0000000..51edc79 Binary files /dev/null and b/backend/wp-admin/images/resize-rtl-2x.gif differ diff --git a/backend/wp-admin/images/resize-rtl.gif b/backend/wp-admin/images/resize-rtl.gif new file mode 100644 index 0000000..61afefe Binary files /dev/null and b/backend/wp-admin/images/resize-rtl.gif differ diff --git a/backend/wp-admin/images/resize.gif b/backend/wp-admin/images/resize.gif new file mode 100644 index 0000000..ca42227 Binary files /dev/null and b/backend/wp-admin/images/resize.gif differ diff --git a/backend/wp-admin/images/se.png b/backend/wp-admin/images/se.png new file mode 100644 index 0000000..eb487b4 Binary files /dev/null and b/backend/wp-admin/images/se.png differ diff --git a/backend/wp-admin/images/sort-2x.gif b/backend/wp-admin/images/sort-2x.gif new file mode 100644 index 0000000..60b6084 Binary files /dev/null and b/backend/wp-admin/images/sort-2x.gif differ diff --git a/backend/wp-admin/images/sort.gif b/backend/wp-admin/images/sort.gif new file mode 100644 index 0000000..aa65db1 Binary files /dev/null and b/backend/wp-admin/images/sort.gif differ diff --git a/backend/wp-admin/images/spinner-2x.gif b/backend/wp-admin/images/spinner-2x.gif new file mode 100644 index 0000000..a4e161e Binary files /dev/null and b/backend/wp-admin/images/spinner-2x.gif differ diff --git a/backend/wp-admin/images/spinner.gif b/backend/wp-admin/images/spinner.gif new file mode 100644 index 0000000..209d10b Binary files /dev/null and b/backend/wp-admin/images/spinner.gif differ diff --git a/backend/wp-admin/images/stars-2x.png b/backend/wp-admin/images/stars-2x.png new file mode 100644 index 0000000..15aa9de Binary files /dev/null and b/backend/wp-admin/images/stars-2x.png differ diff --git a/backend/wp-admin/images/stars.png b/backend/wp-admin/images/stars.png new file mode 100644 index 0000000..c01ada1 Binary files /dev/null and b/backend/wp-admin/images/stars.png differ diff --git a/backend/wp-admin/images/w-logo-blue.png b/backend/wp-admin/images/w-logo-blue.png new file mode 100644 index 0000000..11e550c Binary files /dev/null and b/backend/wp-admin/images/w-logo-blue.png differ diff --git a/backend/wp-admin/images/w-logo-white.png b/backend/wp-admin/images/w-logo-white.png new file mode 100644 index 0000000..ed5efcd Binary files /dev/null and b/backend/wp-admin/images/w-logo-white.png differ diff --git a/backend/wp-admin/images/wheel.png b/backend/wp-admin/images/wheel.png new file mode 100644 index 0000000..9b9fdf4 Binary files /dev/null and b/backend/wp-admin/images/wheel.png differ diff --git a/backend/wp-admin/images/wordpress-logo-white.svg b/backend/wp-admin/images/wordpress-logo-white.svg new file mode 100644 index 0000000..682e80b --- /dev/null +++ b/backend/wp-admin/images/wordpress-logo-white.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/backend/wp-admin/images/wordpress-logo.png b/backend/wp-admin/images/wordpress-logo.png new file mode 100644 index 0000000..63b0379 Binary files /dev/null and b/backend/wp-admin/images/wordpress-logo.png differ diff --git a/backend/wp-admin/images/wordpress-logo.svg b/backend/wp-admin/images/wordpress-logo.svg new file mode 100644 index 0000000..ba26fef --- /dev/null +++ b/backend/wp-admin/images/wordpress-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/backend/wp-admin/images/wpspin_light-2x.gif b/backend/wp-admin/images/wpspin_light-2x.gif new file mode 100644 index 0000000..392e82f Binary files /dev/null and b/backend/wp-admin/images/wpspin_light-2x.gif differ diff --git a/backend/wp-admin/images/wpspin_light.gif b/backend/wp-admin/images/wpspin_light.gif new file mode 100644 index 0000000..4c42dcb Binary files /dev/null and b/backend/wp-admin/images/wpspin_light.gif differ diff --git a/backend/wp-admin/images/xit-2x.gif b/backend/wp-admin/images/xit-2x.gif new file mode 100644 index 0000000..3a72ee1 Binary files /dev/null and b/backend/wp-admin/images/xit-2x.gif differ diff --git a/backend/wp-admin/images/xit.gif b/backend/wp-admin/images/xit.gif new file mode 100644 index 0000000..d288954 Binary files /dev/null and b/backend/wp-admin/images/xit.gif differ diff --git a/backend/wp-admin/images/yes.png b/backend/wp-admin/images/yes.png new file mode 100644 index 0000000..fbb3983 Binary files /dev/null and b/backend/wp-admin/images/yes.png differ diff --git a/backend/wp-admin/import.php b/backend/wp-admin/import.php new file mode 100644 index 0000000..1aa682a --- /dev/null +++ b/backend/wp-admin/import.php @@ -0,0 +1,206 @@ +add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => '

    ' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '

    ' . + '

    ' . __('In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.') . '

    ', +) ); + +get_current_screen()->set_help_sidebar( + '

    ' . __('For more information:') . '

    ' . + '

    ' . __('Documentation on Import') . '

    ' . + '

    ' . __('Support Forums') . '

    ' +); + +if ( current_user_can( 'install_plugins' ) ) { + // List of popular importer plugins from the WordPress.org API. + $popular_importers = wp_get_popular_importers(); +} else { + $popular_importers = array(); +} + +// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt' +if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) { + $importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id']; + if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops. + wp_redirect( admin_url( 'admin.php?import=' . $importer_id ) ); + exit; + } + unset( $importer_id ); +} + +add_thickbox(); +wp_enqueue_script( 'plugin-install' ); +wp_enqueue_script( 'updates' ); + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); +$parent_file = 'tools.php'; +?> + +
    +

    + +
    +

    ' . esc_html( $_GET['invalid'] ) . '' ); + ?>

    +
    + +

    + + $pop_data ) { + if ( isset( $importers[ $pop_importer ] ) ) + continue; + if ( isset( $importers[ $pop_data['importer-id'] ] ) ) + continue; + + // Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API. + $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] ); +} + +if ( empty( $importers ) ) { + echo '

    ' . __('No importers are available.') . '

    '; // TODO: make more helpful +} else { + uasort( $importers, '_usort_by_first_member' ); +?> + + + $data ) { + $plugin_slug = $action = ''; + $is_plugin_installed = false; + + if ( isset( $data['install'] ) ) { + $plugin_slug = $data['install']; + + if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { + // Looks like an importer is installed, but not active. + $plugins = get_plugins( '/' . $plugin_slug ); + if ( ! empty( $plugins ) ) { + $keys = array_keys( $plugins ); + $plugin_file = $plugin_slug . '/' . $keys[0]; + $url = wp_nonce_url( add_query_arg( array( + 'action' => 'activate', + 'plugin' => $plugin_file, + 'from' => 'import', + ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file ); + $action = sprintf( + '%s', + esc_url( $url ), + /* translators: %s: Importer name */ + esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ), + __( 'Run Importer' ) + ); + + $is_plugin_installed = true; + } + } + + if ( empty( $action ) ) { + if ( is_main_site() ) { + $url = wp_nonce_url( add_query_arg( array( + 'action' => 'install-plugin', + 'plugin' => $plugin_slug, + 'from' => 'import', + ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug ); + $action = sprintf( + '%5$s', + esc_url( $url ), + esc_attr( $plugin_slug ), + esc_attr( $data[0] ), + /* translators: %s: Importer name */ + esc_attr( sprintf( __( 'Install %s' ), $data[0] ) ), + __( 'Install Now' ) + ); + } else { + $action = sprintf( + /* translators: URL to wp-admin/import.php */ + __( 'This importer is not installed. Please install importers from the main site.' ), + get_admin_url( get_current_network_id(), 'import.php' ) + ); + } + } + } else { + $url = add_query_arg( array( + 'import' => $importer_id, + ), self_admin_url( 'admin.php' ) ); + $action = sprintf( + '%3$s', + esc_url( $url ), + /* translators: %s: Importer name */ + esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ), + __( 'Run Importer' ) + ); + + $is_plugin_installed = true; + } + + if ( ! $is_plugin_installed && is_main_site() ) { + $url = add_query_arg( array( + 'tab' => 'plugin-information', + 'plugin' => $plugin_slug, + 'from' => 'import', + 'TB_iframe' => 'true', + 'width' => 600, + 'height' => 550, + ), network_admin_url( 'plugin-install.php' ) ); + $action .= sprintf( + ' | %3$s', + esc_url( $url ), + /* translators: %s: Importer name */ + esc_attr( sprintf( __( 'More information about %s' ), $data[0] ) ), + __( 'Details' ) + ); + } + + echo " + + + + "; + } + ?> +
    + {$data[0]} + {$action} + + {$data[1]} +
    +' . sprintf( __('If the importer you need is not listed, search the plugin directory to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '

    '; +?> + +
    + +id and the JS global 'pagenow'. + if ( ! empty($_POST['screen_id']) ) + $screen_id = sanitize_key($_POST['screen_id']); + else + $screen_id = 'front'; + + if ( ! empty($_POST['data']) ) { + $data = wp_unslash( (array) $_POST['data'] ); + + /** + * Filters Heartbeat Ajax response in no-privilege environments. + * + * @since 3.6.0 + * + * @param array|object $response The no-priv Heartbeat response object or array. + * @param array $data An array of data passed via $_POST. + * @param string $screen_id The screen id. + */ + $response = apply_filters( 'heartbeat_nopriv_received', $response, $data, $screen_id ); + } + + /** + * Filters Heartbeat Ajax response when no data is passed. + * + * @since 3.6.0 + * + * @param array|object $response The Heartbeat response object or array. + * @param string $screen_id The screen id. + */ + $response = apply_filters( 'heartbeat_nopriv_send', $response, $screen_id ); + + /** + * Fires when Heartbeat ticks in no-privilege environments. + * + * Allows the transport to be easily replaced with long-polling. + * + * @since 3.6.0 + * + * @param array|object $response The no-priv Heartbeat response. + * @param string $screen_id The screen id. + */ + do_action( 'heartbeat_nopriv_tick', $response, $screen_id ); + + // Send the current time according to the server. + $response['server_time'] = time(); + + wp_send_json($response); +} + +// +// GET-based Ajax handlers. +// + +/** + * Ajax handler for fetching a list table. + * + * @since 3.1.0 + */ +function wp_ajax_fetch_list() { + $list_class = $_GET['list_args']['class']; + check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' ); + + $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) ); + if ( ! $wp_list_table ) { + wp_die( 0 ); + } + + if ( ! $wp_list_table->ajax_user_can() ) { + wp_die( -1 ); + } + + $wp_list_table->ajax_response(); + + wp_die( 0 ); +} + +/** + * Ajax handler for tag search. + * + * @since 3.1.0 + */ +function wp_ajax_ajax_tag_search() { + if ( ! isset( $_GET['tax'] ) ) { + wp_die( 0 ); + } + + $taxonomy = sanitize_key( $_GET['tax'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) { + wp_die( 0 ); + } + + if ( ! current_user_can( $tax->cap->assign_terms ) ) { + wp_die( -1 ); + } + + $s = wp_unslash( $_GET['q'] ); + + $comma = _x( ',', 'tag delimiter' ); + if ( ',' !== $comma ) + $s = str_replace( $comma, ',', $s ); + if ( false !== strpos( $s, ',' ) ) { + $s = explode( ',', $s ); + $s = $s[count( $s ) - 1]; + } + $s = trim( $s ); + + /** + * Filters the minimum number of characters required to fire a tag search via Ajax. + * + * @since 4.0.0 + * + * @param int $characters The minimum number of characters required. Default 2. + * @param WP_Taxonomy $tax The taxonomy object. + * @param string $s The search term. + */ + $term_search_min_chars = (int) apply_filters( 'term_search_min_chars', 2, $tax, $s ); + + /* + * Require $term_search_min_chars chars for matching (default: 2) + * ensure it's a non-negative, non-zero integer. + */ + if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){ + wp_die(); + } + + $results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) ); + + echo join( $results, "\n" ); + wp_die(); +} + +/** + * Ajax handler for compression testing. + * + * @since 3.1.0 + */ +function wp_ajax_wp_compression_test() { + if ( !current_user_can( 'manage_options' ) ) + wp_die( -1 ); + + if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) { + update_site_option('can_compress_scripts', 0); + wp_die( 0 ); + } + + if ( isset($_GET['test']) ) { + header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); + header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); + header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); + header('Content-Type: application/javascript; charset=UTF-8'); + $force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP ); + $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; + + if ( 1 == $_GET['test'] ) { + echo $test_str; + wp_die(); + } elseif ( 2 == $_GET['test'] ) { + if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) + wp_die( -1 ); + if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { + header('Content-Encoding: deflate'); + $out = gzdeflate( $test_str, 1 ); + } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { + header('Content-Encoding: gzip'); + $out = gzencode( $test_str, 1 ); + } else { + wp_die( -1 ); + } + echo $out; + wp_die(); + } elseif ( 'no' == $_GET['test'] ) { + check_ajax_referer( 'update_can_compress_scripts' ); + update_site_option('can_compress_scripts', 0); + } elseif ( 'yes' == $_GET['test'] ) { + check_ajax_referer( 'update_can_compress_scripts' ); + update_site_option('can_compress_scripts', 1); + } + } + + wp_die( 0 ); +} + +/** + * Ajax handler for image editor previews. + * + * @since 3.1.0 + */ +function wp_ajax_imgedit_preview() { + $post_id = intval($_GET['postid']); + if ( empty($post_id) || !current_user_can('edit_post', $post_id) ) + wp_die( -1 ); + + check_ajax_referer( "image_editor-$post_id" ); + + include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); + if ( ! stream_preview_image($post_id) ) + wp_die( -1 ); + + wp_die(); +} + +/** + * Ajax handler for oEmbed caching. + * + * @since 3.1.0 + * + * @global WP_Embed $wp_embed + */ +function wp_ajax_oembed_cache() { + $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); + wp_die( 0 ); +} + +/** + * Ajax handler for user autocomplete. + * + * @since 3.4.0 + */ +function wp_ajax_autocomplete_user() { + if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) + wp_die( -1 ); + + /** This filter is documented in wp-admin/user-new.php */ + if ( ! current_user_can( 'manage_network_users' ) && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) + wp_die( -1 ); + + $return = array(); + + // Check the type of request + // Current allowed values are `add` and `search` + if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { + $type = $_REQUEST['autocomplete_type']; + } else { + $type = 'add'; + } + + // Check the desired field for value + // Current allowed values are `user_email` and `user_login` + if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { + $field = $_REQUEST['autocomplete_field']; + } else { + $field = 'user_login'; + } + + // Exclude current users of this blog + if ( isset( $_REQUEST['site_id'] ) ) { + $id = absint( $_REQUEST['site_id'] ); + } else { + $id = get_current_blog_id(); + } + + $include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() ); + $exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() ); + + $users = get_users( array( + 'blog_id' => false, + 'search' => '*' . $_REQUEST['term'] . '*', + 'include' => $include_blog_users, + 'exclude' => $exclude_blog_users, + 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ), + ) ); + + foreach ( $users as $user ) { + $return[] = array( + /* translators: 1: user_login, 2: user_email */ + 'label' => sprintf( _x( '%1$s (%2$s)', 'user autocomplete result' ), $user->user_login, $user->user_email ), + 'value' => $user->$field, + ); + } + + wp_die( wp_json_encode( $return ) ); +} + +/** + * Handles AJAX requests for community events + * + * @since 4.8.0 + */ +function wp_ajax_get_community_events() { + require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); + + check_ajax_referer( 'community_events' ); + + $search = isset( $_POST['location'] ) ? wp_unslash( $_POST['location'] ) : ''; + $timezone = isset( $_POST['timezone'] ) ? wp_unslash( $_POST['timezone'] ) : ''; + $user_id = get_current_user_id(); + $saved_location = get_user_option( 'community-events-location', $user_id ); + $events_client = new WP_Community_Events( $user_id, $saved_location ); + $events = $events_client->get_events( $search, $timezone ); + $ip_changed = false; + + if ( is_wp_error( $events ) ) { + wp_send_json_error( array( + 'error' => $events->get_error_message(), + ) ); + } else { + if ( empty( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) ) { + $ip_changed = true; + } elseif ( isset( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) && $saved_location['ip'] !== $events['location']['ip'] ) { + $ip_changed = true; + } + + /* + * The location should only be updated when it changes. The API doesn't always return + * a full location; sometimes it's missing the description or country. The location + * that was saved during the initial request is known to be good and complete, though. + * It should be left in tact until the user explicitly changes it (either by manually + * searching for a new location, or by changing their IP address). + * + * If the location were updated with an incomplete response from the API, then it could + * break assumptions that the UI makes (e.g., that there will always be a description + * that corresponds to a latitude/longitude location). + * + * The location is stored network-wide, so that the user doesn't have to set it on each site. + */ + if ( $ip_changed || $search ) { + update_user_option( $user_id, 'community-events-location', $events['location'], true ); + } + + wp_send_json_success( $events ); + } +} + +/** + * Ajax handler for dashboard widgets. + * + * @since 3.4.0 + */ +function wp_ajax_dashboard_widgets() { + require_once ABSPATH . 'wp-admin/includes/dashboard.php'; + + $pagenow = $_GET['pagenow']; + if ( $pagenow === 'dashboard-user' || $pagenow === 'dashboard-network' || $pagenow === 'dashboard' ) { + set_current_screen( $pagenow ); + } + + switch ( $_GET['widget'] ) { + case 'dashboard_primary' : + wp_dashboard_primary(); + break; + } + wp_die(); +} + +/** + * Ajax handler for Customizer preview logged-in status. + * + * @since 3.4.0 + */ +function wp_ajax_logged_in() { + wp_die( 1 ); +} + +// +// Ajax helpers. +// + +/** + * Sends back current comment total and new page links if they need to be updated. + * + * Contrary to normal success Ajax response ("1"), die with time() on success. + * + * @access private + * @since 2.7.0 + * + * @param int $comment_id + * @param int $delta + */ +function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { + $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0; + $per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0; + $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; + $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : ''; + + // JS didn't send us everything we need to know. Just die with success message + if ( ! $total || ! $per_page || ! $page || ! $url ) { + $time = time(); + $comment = get_comment( $comment_id ); + $comment_status = ''; + $comment_link = ''; + + if ( $comment ) { + $comment_status = $comment->comment_approved; + } + + if ( 1 === (int) $comment_status ) { + $comment_link = get_comment_link( $comment ); + } + + $counts = wp_count_comments(); + + $x = new WP_Ajax_Response( array( + 'what' => 'comment', + // Here for completeness - not used. + 'id' => $comment_id, + 'supplemental' => array( + 'status' => $comment_status, + 'postId' => $comment ? $comment->comment_post_ID : '', + 'time' => $time, + 'in_moderation' => $counts->moderated, + 'i18n_comments_text' => sprintf( + _n( '%s Comment', '%s Comments', $counts->approved ), + number_format_i18n( $counts->approved ) + ), + 'i18n_moderation_text' => sprintf( + _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), + number_format_i18n( $counts->moderated ) + ), + 'comment_link' => $comment_link, + ) + ) ); + $x->send(); + } + + $total += $delta; + if ( $total < 0 ) + $total = 0; + + // Only do the expensive stuff on a page-break, and about 1 other time per page + if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { + $post_id = 0; + // What type of comment count are we looking for? + $status = 'all'; + $parsed = parse_url( $url ); + if ( isset( $parsed['query'] ) ) { + parse_str( $parsed['query'], $query_vars ); + if ( !empty( $query_vars['comment_status'] ) ) + $status = $query_vars['comment_status']; + if ( !empty( $query_vars['p'] ) ) + $post_id = (int) $query_vars['p']; + if ( ! empty( $query_vars['comment_type'] ) ) + $type = $query_vars['comment_type']; + } + + if ( empty( $type ) ) { + // Only use the comment count if not filtering by a comment_type. + $comment_count = wp_count_comments($post_id); + + // We're looking for a known type of comment count. + if ( isset( $comment_count->$status ) ) { + $total = $comment_count->$status; + } + } + // Else use the decremented value from above. + } + + // The time since the last comment count. + $time = time(); + $comment = get_comment( $comment_id ); + + $x = new WP_Ajax_Response( array( + 'what' => 'comment', + // Here for completeness - not used. + 'id' => $comment_id, + 'supplemental' => array( + 'status' => $comment ? $comment->comment_approved : '', + 'postId' => $comment ? $comment->comment_post_ID : '', + 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), + 'total_pages' => ceil( $total / $per_page ), + 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), + 'total' => $total, + 'time' => $time + ) + ) ); + $x->send(); +} + +// +// POST-based Ajax handlers. +// + +/** + * Ajax handler for adding a hierarchical term. + * + * @access private + * @since 3.1.0 + */ +function _wp_ajax_add_hierarchical_term() { + $action = $_POST['action']; + $taxonomy = get_taxonomy(substr($action, 4)); + check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); + if ( !current_user_can( $taxonomy->cap->edit_terms ) ) + wp_die( -1 ); + $names = explode(',', $_POST['new'.$taxonomy->name]); + $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0; + if ( 0 > $parent ) + $parent = 0; + if ( $taxonomy->name == 'category' ) + $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); + else + $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); + $checked_categories = array_map( 'absint', (array) $post_category ); + $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); + + foreach ( $names as $cat_name ) { + $cat_name = trim($cat_name); + $category_nicename = sanitize_title($cat_name); + if ( '' === $category_nicename ) + continue; + + $cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) ); + if ( ! $cat_id || is_wp_error( $cat_id ) ) { + continue; + } else { + $cat_id = $cat_id['term_id']; + } + $checked_categories[] = $cat_id; + if ( $parent ) // Do these all at once in a second + continue; + + ob_start(); + + wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids )); + + $data = ob_get_clean(); + + $add = array( + 'what' => $taxonomy->name, + 'id' => $cat_id, + 'data' => str_replace( array("\n", "\t"), '', $data), + 'position' => -1 + ); + } + + if ( $parent ) { // Foncy - replace the parent and all its children + $parent = get_term( $parent, $taxonomy->name ); + $term_id = $parent->term_id; + + while ( $parent->parent ) { // get the top parent + $parent = get_term( $parent->parent, $taxonomy->name ); + if ( is_wp_error( $parent ) ) + break; + $term_id = $parent->term_id; + } + + ob_start(); + + wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); + + $data = ob_get_clean(); + + $add = array( + 'what' => $taxonomy->name, + 'id' => $term_id, + 'data' => str_replace( array("\n", "\t"), '', $data), + 'position' => -1 + ); + } + + ob_start(); + + wp_dropdown_categories( array( + 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', + 'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —' + ) ); + + $sup = ob_get_clean(); + + $add['supplemental'] = array( 'newcat_parent' => $sup ); + + $x = new WP_Ajax_Response( $add ); + $x->send(); +} + +/** + * Ajax handler for deleting a comment. + * + * @since 3.1.0 + */ +function wp_ajax_delete_comment() { + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + if ( !$comment = get_comment( $id ) ) + wp_die( time() ); + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) + wp_die( -1 ); + + check_ajax_referer( "delete-comment_$id" ); + $status = wp_get_comment_status( $comment ); + + $delta = -1; + if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { + if ( 'trash' == $status ) + wp_die( time() ); + $r = wp_trash_comment( $comment ); + } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) { + if ( 'trash' != $status ) + wp_die( time() ); + $r = wp_untrash_comment( $comment ); + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash + $delta = 1; + } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { + if ( 'spam' == $status ) + wp_die( time() ); + $r = wp_spam_comment( $comment ); + } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) { + if ( 'spam' != $status ) + wp_die( time() ); + $r = wp_unspam_comment( $comment ); + if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam + $delta = 1; + } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { + $r = wp_delete_comment( $comment ); + } else { + wp_die( -1 ); + } + + if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts + _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); + wp_die( 0 ); +} + +/** + * Ajax handler for deleting a tag. + * + * @since 3.1.0 + */ +function wp_ajax_delete_tag() { + $tag_id = (int) $_POST['tag_ID']; + check_ajax_referer( "delete-tag_$tag_id" ); + + if ( ! current_user_can( 'delete_term', $tag_id ) ) { + wp_die( -1 ); + } + + $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; + $tag = get_term( $tag_id, $taxonomy ); + if ( !$tag || is_wp_error( $tag ) ) + wp_die( 1 ); + + if ( wp_delete_term($tag_id, $taxonomy)) + wp_die( 1 ); + else + wp_die( 0 ); +} + +/** + * Ajax handler for deleting a link. + * + * @since 3.1.0 + */ +function wp_ajax_delete_link() { + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + check_ajax_referer( "delete-bookmark_$id" ); + if ( !current_user_can( 'manage_links' ) ) + wp_die( -1 ); + + $link = get_bookmark( $id ); + if ( !$link || is_wp_error( $link ) ) + wp_die( 1 ); + + if ( wp_delete_link( $id ) ) + wp_die( 1 ); + else + wp_die( 0 ); +} + +/** + * Ajax handler for deleting meta. + * + * @since 3.1.0 + */ +function wp_ajax_delete_meta() { + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + check_ajax_referer( "delete-meta_$id" ); + if ( !$meta = get_metadata_by_mid( 'post', $id ) ) + wp_die( 1 ); + + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) + wp_die( -1 ); + if ( delete_meta( $meta->meta_id ) ) + wp_die( 1 ); + wp_die( 0 ); +} + +/** + * Ajax handler for deleting a post. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_delete_post( $action ) { + if ( empty( $action ) ) + $action = 'delete-post'; + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + check_ajax_referer( "{$action}_$id" ); + if ( !current_user_can( 'delete_post', $id ) ) + wp_die( -1 ); + + if ( !get_post( $id ) ) + wp_die( 1 ); + + if ( wp_delete_post( $id ) ) + wp_die( 1 ); + else + wp_die( 0 ); +} + +/** + * Ajax handler for sending a post to the trash. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_trash_post( $action ) { + if ( empty( $action ) ) + $action = 'trash-post'; + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + check_ajax_referer( "{$action}_$id" ); + if ( !current_user_can( 'delete_post', $id ) ) + wp_die( -1 ); + + if ( !get_post( $id ) ) + wp_die( 1 ); + + if ( 'trash-post' == $action ) + $done = wp_trash_post( $id ); + else + $done = wp_untrash_post( $id ); + + if ( $done ) + wp_die( 1 ); + + wp_die( 0 ); +} + +/** + * Ajax handler to restore a post from the trash. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_untrash_post( $action ) { + if ( empty( $action ) ) + $action = 'untrash-post'; + wp_ajax_trash_post( $action ); +} + +/** + * @since 3.1.0 + * + * @param string $action + */ +function wp_ajax_delete_page( $action ) { + if ( empty( $action ) ) + $action = 'delete-page'; + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + check_ajax_referer( "{$action}_$id" ); + if ( !current_user_can( 'delete_page', $id ) ) + wp_die( -1 ); + + if ( ! get_post( $id ) ) + wp_die( 1 ); + + if ( wp_delete_post( $id ) ) + wp_die( 1 ); + else + wp_die( 0 ); +} + +/** + * Ajax handler to dim a comment. + * + * @since 3.1.0 + */ +function wp_ajax_dim_comment() { + $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; + + if ( !$comment = get_comment( $id ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'comment', + 'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id)) + ) ); + $x->send(); + } + + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) + wp_die( -1 ); + + $current = wp_get_comment_status( $comment ); + if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) + wp_die( time() ); + + check_ajax_referer( "approve-comment_$id" ); + if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { + $result = wp_set_comment_status( $comment, 'approve', true ); + } else { + $result = wp_set_comment_status( $comment, 'hold', true ); + } + + if ( is_wp_error($result) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'comment', + 'id' => $result + ) ); + $x->send(); + } + + // Decide if we need to send back '1' or a more complicated response including page links and comment counts + _wp_ajax_delete_comment_response( $comment->comment_ID ); + wp_die( 0 ); +} + +/** + * Ajax handler for adding a link category. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_add_link_category( $action ) { + if ( empty( $action ) ) + $action = 'add-link-category'; + check_ajax_referer( $action ); + $tax = get_taxonomy( 'link_category' ); + if ( ! current_user_can( $tax->cap->manage_terms ) ) { + wp_die( -1 ); + } + $names = explode(',', wp_unslash( $_POST['newcat'] ) ); + $x = new WP_Ajax_Response(); + foreach ( $names as $cat_name ) { + $cat_name = trim($cat_name); + $slug = sanitize_title($cat_name); + if ( '' === $slug ) + continue; + + $cat_id = wp_insert_term( $cat_name, 'link_category' ); + if ( ! $cat_id || is_wp_error( $cat_id ) ) { + continue; + } else { + $cat_id = $cat_id['term_id']; + } + $cat_name = esc_html( $cat_name ); + $x->add( array( + 'what' => 'link-category', + 'id' => $cat_id, + 'data' => "", + 'position' => -1 + ) ); + } + $x->send(); +} + +/** + * Ajax handler to add a tag. + * + * @since 3.1.0 + */ +function wp_ajax_add_tag() { + check_ajax_referer( 'add-tag', '_wpnonce_add-tag' ); + $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag'; + $tax = get_taxonomy($taxonomy); + + if ( !current_user_can( $tax->cap->edit_terms ) ) + wp_die( -1 ); + + $x = new WP_Ajax_Response(); + + $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST ); + + if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { + $message = __('An error has occurred. Please reload the page and try again.'); + if ( is_wp_error($tag) && $tag->get_error_message() ) + $message = $tag->get_error_message(); + + $x->add( array( + 'what' => 'taxonomy', + 'data' => new WP_Error('error', $message ) + ) ); + $x->send(); + } + + $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); + + $level = 0; + if ( is_taxonomy_hierarchical($taxonomy) ) { + $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); + ob_start(); + $wp_list_table->single_row( $tag, $level ); + $noparents = ob_get_clean(); + } + + ob_start(); + $wp_list_table->single_row( $tag ); + $parents = ob_get_clean(); + + $x->add( array( + 'what' => 'taxonomy', + 'supplemental' => compact('parents', 'noparents') + ) ); + $x->add( array( + 'what' => 'term', + 'position' => $level, + 'supplemental' => (array) $tag + ) ); + $x->send(); +} + +/** + * Ajax handler for getting a tagcloud. + * + * @since 3.1.0 + */ +function wp_ajax_get_tagcloud() { + if ( ! isset( $_POST['tax'] ) ) { + wp_die( 0 ); + } + + $taxonomy = sanitize_key( $_POST['tax'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) { + wp_die( 0 ); + } + + if ( ! current_user_can( $tax->cap->assign_terms ) ) { + wp_die( -1 ); + } + + $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); + + if ( empty( $tags ) ) + wp_die( $tax->labels->not_found ); + + if ( is_wp_error( $tags ) ) + wp_die( $tags->get_error_message() ); + + foreach ( $tags as $key => $tag ) { + $tags[ $key ]->link = '#'; + $tags[ $key ]->id = $tag->term_id; + } + + // We need raw tag names here, so don't filter the output + $return = wp_generate_tag_cloud( $tags, array( 'filter' => 0, 'format' => 'list' ) ); + + if ( empty($return) ) + wp_die( 0 ); + + echo $return; + + wp_die(); +} + +/** + * Ajax handler for getting comments. + * + * @since 3.1.0 + * + * @global int $post_id + * + * @param string $action Action to perform. + */ +function wp_ajax_get_comments( $action ) { + global $post_id; + if ( empty( $action ) ) { + $action = 'get-comments'; + } + check_ajax_referer( $action ); + + if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) { + $id = absint( $_REQUEST['p'] ); + if ( ! empty( $id ) ) { + $post_id = $id; + } + } + + if ( empty( $post_id ) ) { + wp_die( -1 ); + } + + $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); + + if ( ! current_user_can( 'edit_post', $post_id ) ) { + wp_die( -1 ); + } + + $wp_list_table->prepare_items(); + + if ( ! $wp_list_table->has_items() ) { + wp_die( 1 ); + } + + $x = new WP_Ajax_Response(); + ob_start(); + foreach ( $wp_list_table->items as $comment ) { + if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) + continue; + get_comment( $comment ); + $wp_list_table->single_row( $comment ); + } + $comment_list_item = ob_get_clean(); + + $x->add( array( + 'what' => 'comments', + 'data' => $comment_list_item + ) ); + $x->send(); +} + +/** + * Ajax handler for replying to a comment. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_replyto_comment( $action ) { + if ( empty( $action ) ) + $action = 'replyto-comment'; + + check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); + + $comment_post_ID = (int) $_POST['comment_post_ID']; + $post = get_post( $comment_post_ID ); + if ( ! $post ) + wp_die( -1 ); + + if ( !current_user_can( 'edit_post', $comment_post_ID ) ) + wp_die( -1 ); + + if ( empty( $post->post_status ) ) + wp_die( 1 ); + elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) ) + wp_die( __('ERROR: you are replying to a comment on a draft post.') ); + + $user = wp_get_current_user(); + if ( $user->exists() ) { + $user_ID = $user->ID; + $comment_author = wp_slash( $user->display_name ); + $comment_author_email = wp_slash( $user->user_email ); + $comment_author_url = wp_slash( $user->user_url ); + $comment_content = trim( $_POST['content'] ); + $comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : ''; + if ( current_user_can( 'unfiltered_html' ) ) { + if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) + $_POST['_wp_unfiltered_html_comment'] = ''; + + if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { + kses_remove_filters(); // start with a clean slate + kses_init_filters(); // set up the filters + } + } + } else { + wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) ); + } + + if ( '' == $comment_content ) + wp_die( __( 'ERROR: please type a comment.' ) ); + + $comment_parent = 0; + if ( isset( $_POST['comment_ID'] ) ) + $comment_parent = absint( $_POST['comment_ID'] ); + $comment_auto_approved = false; + $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); + + // Automatically approve parent comment. + if ( !empty($_POST['approve_parent']) ) { + $parent = get_comment( $comment_parent ); + + if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) { + if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { + wp_die( -1 ); + } + + if ( wp_set_comment_status( $parent, 'approve' ) ) + $comment_auto_approved = true; + } + } + + $comment_id = wp_new_comment( $commentdata ); + + if ( is_wp_error( $comment_id ) ) { + wp_die( $comment_id->get_error_message() ); + } + + $comment = get_comment($comment_id); + if ( ! $comment ) wp_die( 1 ); + + $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; + + ob_start(); + if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) { + require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); + _wp_dashboard_recent_comments_row( $comment ); + } else { + if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) { + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); + } else { + $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); + } + $wp_list_table->single_row( $comment ); + } + $comment_list_item = ob_get_clean(); + + $response = array( + 'what' => 'comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item, + 'position' => $position + ); + + $counts = wp_count_comments(); + $response['supplemental'] = array( + 'in_moderation' => $counts->moderated, + 'i18n_comments_text' => sprintf( + _n( '%s Comment', '%s Comments', $counts->approved ), + number_format_i18n( $counts->approved ) + ), + 'i18n_moderation_text' => sprintf( + _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ), + number_format_i18n( $counts->moderated ) + ) + ); + + if ( $comment_auto_approved ) { + $response['supplemental']['parent_approved'] = $parent->comment_ID; + $response['supplemental']['parent_post_id'] = $parent->comment_post_ID; + } + + $x = new WP_Ajax_Response(); + $x->add( $response ); + $x->send(); +} + +/** + * Ajax handler for editing a comment. + * + * @since 3.1.0 + */ +function wp_ajax_edit_comment() { + check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); + + $comment_id = (int) $_POST['comment_ID']; + if ( ! current_user_can( 'edit_comment', $comment_id ) ) + wp_die( -1 ); + + if ( '' == $_POST['content'] ) + wp_die( __( 'ERROR: please type a comment.' ) ); + + if ( isset( $_POST['status'] ) ) + $_POST['comment_status'] = $_POST['status']; + edit_comment(); + + $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; + $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; + $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); + + $comment = get_comment( $comment_id ); + if ( empty( $comment->comment_ID ) ) + wp_die( -1 ); + + ob_start(); + $wp_list_table->single_row( $comment ); + $comment_list_item = ob_get_clean(); + + $x = new WP_Ajax_Response(); + + $x->add( array( + 'what' => 'edit_comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item, + 'position' => $position + )); + + $x->send(); +} + +/** + * Ajax handler for adding a menu item. + * + * @since 3.1.0 + */ +function wp_ajax_add_menu_item() { + check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) + wp_die( -1 ); + + require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; + + // For performance reasons, we omit some object properties from the checklist. + // The following is a hacky way to restore them when adding non-custom items. + + $menu_items_data = array(); + foreach ( (array) $_POST['menu-item'] as $menu_item_data ) { + if ( + ! empty( $menu_item_data['menu-item-type'] ) && + 'custom' != $menu_item_data['menu-item-type'] && + ! empty( $menu_item_data['menu-item-object-id'] ) + ) { + switch( $menu_item_data['menu-item-type'] ) { + case 'post_type' : + $_object = get_post( $menu_item_data['menu-item-object-id'] ); + break; + + case 'post_type_archive' : + $_object = get_post_type_object( $menu_item_data['menu-item-object'] ); + break; + + case 'taxonomy' : + $_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] ); + break; + } + + $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); + $_menu_item = reset( $_menu_items ); + + // Restore the missing menu item properties + $menu_item_data['menu-item-description'] = $_menu_item->description; + } + + $menu_items_data[] = $menu_item_data; + } + + $item_ids = wp_save_nav_menu_items( 0, $menu_items_data ); + if ( is_wp_error( $item_ids ) ) + wp_die( 0 ); + + $menu_items = array(); + + foreach ( (array) $item_ids as $menu_item_id ) { + $menu_obj = get_post( $menu_item_id ); + if ( ! empty( $menu_obj->ID ) ) { + $menu_obj = wp_setup_nav_menu_item( $menu_obj ); + $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items + $menu_items[] = $menu_obj; + } + } + + /** This filter is documented in wp-admin/includes/nav-menu.php */ + $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); + + if ( ! class_exists( $walker_class_name ) ) + wp_die( 0 ); + + if ( ! empty( $menu_items ) ) { + $args = array( + 'after' => '', + 'before' => '', + 'link_after' => '', + 'link_before' => '', + 'walker' => new $walker_class_name, + ); + echo walk_nav_menu_tree( $menu_items, 0, (object) $args ); + } + wp_die(); +} + +/** + * Ajax handler for adding meta. + * + * @since 3.1.0 + */ +function wp_ajax_add_meta() { + check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' ); + $c = 0; + $pid = (int) $_POST['post_id']; + $post = get_post( $pid ); + + if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) { + if ( !current_user_can( 'edit_post', $pid ) ) + wp_die( -1 ); + if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) ) + wp_die( 1 ); + + // If the post is an autodraft, save the post as a draft and then attempt to save the meta. + if ( $post->post_status == 'auto-draft' ) { + $post_data = array(); + $post_data['action'] = 'draft'; // Warning fix + $post_data['post_ID'] = $pid; + $post_data['post_type'] = $post->post_type; + $post_data['post_status'] = 'draft'; + $now = current_time('timestamp', 1); + /* translators: 1: Post creation date, 2: Post creation time */ + $post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) ); + + $pid = edit_post( $post_data ); + if ( $pid ) { + if ( is_wp_error( $pid ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'data' => $pid + ) ); + $x->send(); + } + + if ( !$mid = add_meta( $pid ) ) + wp_die( __( 'Please provide a custom field value.' ) ); + } else { + wp_die( 0 ); + } + } elseif ( ! $mid = add_meta( $pid ) ) { + wp_die( __( 'Please provide a custom field value.' ) ); + } + + $meta = get_metadata_by_mid( 'post', $mid ); + $pid = (int) $meta->post_id; + $meta = get_object_vars( $meta ); + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, + 'data' => _list_meta_row( $meta, $c ), + 'position' => 1, + 'supplemental' => array('postid' => $pid) + ) ); + } else { // Update? + $mid = (int) key( $_POST['meta'] ); + $key = wp_unslash( $_POST['meta'][$mid]['key'] ); + $value = wp_unslash( $_POST['meta'][$mid]['value'] ); + if ( '' == trim($key) ) + wp_die( __( 'Please provide a custom field name.' ) ); + if ( '' == trim($value) ) + wp_die( __( 'Please provide a custom field value.' ) ); + if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) + wp_die( 0 ); // if meta doesn't exist + if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) || + ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) || + ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) + wp_die( -1 ); + if ( $meta->meta_value != $value || $meta->meta_key != $key ) { + if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) + wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). + } + + $x = new WP_Ajax_Response( array( + 'what' => 'meta', + 'id' => $mid, 'old_id' => $mid, + 'data' => _list_meta_row( array( + 'meta_key' => $key, + 'meta_value' => $value, + 'meta_id' => $mid + ), $c ), + 'position' => 0, + 'supplemental' => array('postid' => $meta->post_id) + ) ); + } + $x->send(); +} + +/** + * Ajax handler for adding a user. + * + * @since 3.1.0 + * + * @param string $action Action to perform. + */ +function wp_ajax_add_user( $action ) { + if ( empty( $action ) ) { + $action = 'add-user'; + } + + check_ajax_referer( $action ); + if ( ! current_user_can('create_users') ) + wp_die( -1 ); + if ( ! $user_id = edit_user() ) { + wp_die( 0 ); + } elseif ( is_wp_error( $user_id ) ) { + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id + ) ); + $x->send(); + } + $user_object = get_userdata( $user_id ); + + $wp_list_table = _get_list_table('WP_Users_List_Table'); + + $role = current( $user_object->roles ); + + $x = new WP_Ajax_Response( array( + 'what' => 'user', + 'id' => $user_id, + 'data' => $wp_list_table->single_row( $user_object, '', $role ), + 'supplemental' => array( + 'show-link' => sprintf( + /* translators: %s: the new user */ + __( 'User %s added' ), + '' . $user_object->user_login . '' + ), + 'role' => $role, + ) + ) ); + $x->send(); +} + +/** + * Ajax handler for closed post boxes. + * + * @since 3.1.0 + */ +function wp_ajax_closed_postboxes() { + check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' ); + $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array(); + $closed = array_filter($closed); + + $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array(); + $hidden = array_filter($hidden); + + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( $page != sanitize_key( $page ) ) + wp_die( 0 ); + + if ( ! $user = wp_get_current_user() ) + wp_die( -1 ); + + if ( is_array($closed) ) + update_user_option($user->ID, "closedpostboxes_$page", $closed, true); + + if ( is_array($hidden) ) { + $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown + update_user_option($user->ID, "metaboxhidden_$page", $hidden, true); + } + + wp_die( 1 ); +} + +/** + * Ajax handler for hidden columns. + * + * @since 3.1.0 + */ +function wp_ajax_hidden_columns() { + check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( $page != sanitize_key( $page ) ) + wp_die( 0 ); + + if ( ! $user = wp_get_current_user() ) + wp_die( -1 ); + + $hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array(); + update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true ); + + wp_die( 1 ); +} + +/** + * Ajax handler for updating whether to display the welcome panel. + * + * @since 3.1.0 + */ +function wp_ajax_update_welcome_panel() { + check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) + wp_die( -1 ); + + update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 ); + + wp_die( 1 ); +} + +/** + * Ajax handler for retrieving menu meta boxes. + * + * @since 3.1.0 + */ +function wp_ajax_menu_get_metabox() { + if ( ! current_user_can( 'edit_theme_options' ) ) + wp_die( -1 ); + + require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; + + if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) { + $type = 'posttype'; + $callback = 'wp_nav_menu_item_post_type_meta_box'; + $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); + } elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) { + $type = 'taxonomy'; + $callback = 'wp_nav_menu_item_taxonomy_meta_box'; + $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' ); + } + + if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) { + $menus_meta_box_object = $items[ $_POST['item-object'] ]; + + /** This filter is documented in wp-admin/includes/nav-menu.php */ + $item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object ); + ob_start(); + call_user_func_array($callback, array( + null, + array( + 'id' => 'add-' . $item->name, + 'title' => $item->labels->name, + 'callback' => $callback, + 'args' => $item, + ) + )); + + $markup = ob_get_clean(); + + echo wp_json_encode(array( + 'replace-id' => $type . '-' . $item->name, + 'markup' => $markup, + )); + } + + wp_die(); +} + +/** + * Ajax handler for internal linking. + * + * @since 3.1.0 + */ +function wp_ajax_wp_link_ajax() { + check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' ); + + $args = array(); + + if ( isset( $_POST['search'] ) ) { + $args['s'] = wp_unslash( $_POST['search'] ); + } + + if ( isset( $_POST['term'] ) ) { + $args['s'] = wp_unslash( $_POST['term'] ); + } + + $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; + + if ( ! class_exists( '_WP_Editors', false ) ) { + require( ABSPATH . WPINC . '/class-wp-editor.php' ); + } + + $results = _WP_Editors::wp_link_query( $args ); + + if ( ! isset( $results ) ) + wp_die( 0 ); + + echo wp_json_encode( $results ); + echo "\n"; + + wp_die(); +} + +/** + * Ajax handler for menu locations save. + * + * @since 3.1.0 + */ +function wp_ajax_menu_locations_save() { + if ( ! current_user_can( 'edit_theme_options' ) ) + wp_die( -1 ); + check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' ); + if ( ! isset( $_POST['menu-locations'] ) ) + wp_die( 0 ); + set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) ); + wp_die( 1 ); +} + +/** + * Ajax handler for saving the meta box order. + * + * @since 3.1.0 + */ +function wp_ajax_meta_box_order() { + check_ajax_referer( 'meta-box-order' ); + $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false; + $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto'; + + if ( $page_columns != 'auto' ) + $page_columns = (int) $page_columns; + + $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; + + if ( $page != sanitize_key( $page ) ) + wp_die( 0 ); + + if ( ! $user = wp_get_current_user() ) + wp_die( -1 ); + + if ( $order ) + update_user_option($user->ID, "meta-box-order_$page", $order, true); + + if ( $page_columns ) + update_user_option($user->ID, "screen_layout_$page", $page_columns, true); + + wp_die( 1 ); +} + +/** + * Ajax handler for menu quick searching. + * + * @since 3.1.0 + */ +function wp_ajax_menu_quick_search() { + if ( ! current_user_can( 'edit_theme_options' ) ) + wp_die( -1 ); + + require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; + + _wp_ajax_menu_quick_search( $_POST ); + + wp_die(); +} + +/** + * Ajax handler to retrieve a permalink. + * + * @since 3.1.0 + */ +function wp_ajax_get_permalink() { + check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + wp_die( get_preview_post_link( $post_id ) ); +} + +/** + * Ajax handler to retrieve a sample permalink. + * + * @since 3.1.0 + */ +function wp_ajax_sample_permalink() { + check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); + $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; + $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; + $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null; + wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); +} + +/** + * Ajax handler for Quick Edit saving a post from a list table. + * + * @since 3.1.0 + * + * @global string $mode List table view mode. + */ +function wp_ajax_inline_save() { + global $mode; + + check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); + + if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) + wp_die(); + + if ( 'page' == $_POST['post_type'] ) { + if ( ! current_user_can( 'edit_page', $post_ID ) ) + wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); + } else { + if ( ! current_user_can( 'edit_post', $post_ID ) ) + wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); + } + + if ( $last = wp_check_post_lock( $post_ID ) ) { + $last_user = get_userdata( $last ); + $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); + printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) ); + wp_die(); + } + + $data = &$_POST; + + $post = get_post( $post_ID, ARRAY_A ); + + // Since it's coming from the database. + $post = wp_slash($post); + + $data['content'] = $post['post_content']; + $data['excerpt'] = $post['post_excerpt']; + + // Rename. + $data['user_ID'] = get_current_user_id(); + + if ( isset($data['post_parent']) ) + $data['parent_id'] = $data['post_parent']; + + // Status. + if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) { + $data['visibility'] = 'private'; + $data['post_status'] = 'private'; + } else { + $data['post_status'] = $data['_status']; + } + + if ( empty($data['comment_status']) ) + $data['comment_status'] = 'closed'; + if ( empty($data['ping_status']) ) + $data['ping_status'] = 'closed'; + + // Exclude terms from taxonomies that are not supposed to appear in Quick Edit. + if ( ! empty( $data['tax_input'] ) ) { + foreach ( $data['tax_input'] as $taxonomy => $terms ) { + $tax_object = get_taxonomy( $taxonomy ); + /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ + if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) { + unset( $data['tax_input'][ $taxonomy ] ); + } + } + } + + // Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published. + if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) { + $post['post_status'] = 'publish'; + $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] ); + } + + // Update the post. + edit_post(); + + $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) ); + + $mode = $_POST['post_view'] === 'excerpt' ? 'excerpt' : 'list'; + + $level = 0; + if ( is_post_type_hierarchical( $wp_list_table->screen->post_type ) ) { + $request_post = array( get_post( $_POST['post_ID'] ) ); + $parent = $request_post[0]->post_parent; + + while ( $parent > 0 ) { + $parent_post = get_post( $parent ); + $parent = $parent_post->post_parent; + $level++; + } + } + + $wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level ); + + wp_die(); +} + +/** + * Ajax handler for quick edit saving for a term. + * + * @since 3.1.0 + */ +function wp_ajax_inline_save_tax() { + check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); + + $taxonomy = sanitize_key( $_POST['taxonomy'] ); + $tax = get_taxonomy( $taxonomy ); + if ( ! $tax ) + wp_die( 0 ); + + if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] ) ) { + wp_die( -1 ); + } + + if ( ! current_user_can( 'edit_term', $id ) ) { + wp_die( -1 ); + } + + $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); + + $tag = get_term( $id, $taxonomy ); + $_POST['description'] = $tag->description; + + $updated = wp_update_term($id, $taxonomy, $_POST); + if ( $updated && !is_wp_error($updated) ) { + $tag = get_term( $updated['term_id'], $taxonomy ); + if ( !$tag || is_wp_error( $tag ) ) { + if ( is_wp_error($tag) && $tag->get_error_message() ) + wp_die( $tag->get_error_message() ); + wp_die( __( 'Item not updated.' ) ); + } + } else { + if ( is_wp_error($updated) && $updated->get_error_message() ) + wp_die( $updated->get_error_message() ); + wp_die( __( 'Item not updated.' ) ); + } + $level = 0; + $parent = $tag->parent; + while ( $parent > 0 ) { + $parent_tag = get_term( $parent, $taxonomy ); + $parent = $parent_tag->parent; + $level++; + } + $wp_list_table->single_row( $tag, $level ); + wp_die(); +} + +/** + * Ajax handler for querying posts for the Find Posts modal. + * + * @see window.findPosts + * + * @since 3.1.0 + */ +function wp_ajax_find_posts() { + check_ajax_referer( 'find-posts' ); + + $post_types = get_post_types( array( 'public' => true ), 'objects' ); + unset( $post_types['attachment'] ); + + $s = wp_unslash( $_POST['ps'] ); + $args = array( + 'post_type' => array_keys( $post_types ), + 'post_status' => 'any', + 'posts_per_page' => 50, + ); + if ( '' !== $s ) + $args['s'] = $s; + + $posts = get_posts( $args ); + + if ( ! $posts ) { + wp_send_json_error( __( 'No items found.' ) ); + } + + $html = ''; + $alt = ''; + foreach ( $posts as $post ) { + $title = trim( $post->post_title ) ? $post->post_title : __( '(no title)' ); + $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; + + switch ( $post->post_status ) { + case 'publish' : + case 'private' : + $stat = __('Published'); + break; + case 'future' : + $stat = __('Scheduled'); + break; + case 'pending' : + $stat = __('Pending Review'); + break; + case 'draft' : + $stat = __('Draft'); + break; + } + + if ( '0000-00-00 00:00:00' == $post->post_date ) { + $time = ''; + } else { + /* translators: date format in table columns, see https://secure.php.net/date */ + $time = mysql2date(__('Y/m/d'), $post->post_date); + } + + $html .= ''; + $html .= '' . "\n\n"; + } + + $html .= '

    '.__('Title').''.__('Type').''.__('Date').''.__('Status').'
    ' . esc_html( $post_types[$post->post_type]->labels->singular_name ) . ''.esc_html( $time ) . '' . esc_html( $stat ). '
    '; + + wp_send_json_success( $html ); +} + +/** + * Ajax handler for saving the widgets order. + * + * @since 3.1.0 + */ +function wp_ajax_widgets_order() { + check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); + + if ( !current_user_can('edit_theme_options') ) + wp_die( -1 ); + + unset( $_POST['savewidgets'], $_POST['action'] ); + + // Save widgets order for all sidebars. + if ( is_array($_POST['sidebars']) ) { + $sidebars = array(); + foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) { + $sb = array(); + if ( !empty($val) ) { + $val = explode(',', $val); + foreach ( $val as $k => $v ) { + if ( strpos($v, 'widget-') === false ) + continue; + + $sb[$k] = substr($v, strpos($v, '_') + 1); + } + } + $sidebars[$key] = $sb; + } + wp_set_sidebars_widgets($sidebars); + wp_die( 1 ); + } + + wp_die( -1 ); +} + +/** + * Ajax handler for saving a widget. + * + * @since 3.1.0 + * + * @global array $wp_registered_widgets + * @global array $wp_registered_widget_controls + * @global array $wp_registered_widget_updates + */ +function wp_ajax_save_widget() { + global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates; + + check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); + + if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) ) + wp_die( -1 ); + + unset( $_POST['savewidgets'], $_POST['action'] ); + + /** + * Fires early when editing the widgets displayed in sidebars. + * + * @since 2.8.0 + */ + do_action( 'load-widgets.php' ); + + /** + * Fires early when editing the widgets displayed in sidebars. + * + * @since 2.8.0 + */ + do_action( 'widgets.php' ); + + /** This action is documented in wp-admin/widgets.php */ + do_action( 'sidebar_admin_setup' ); + + $id_base = wp_unslash( $_POST['id_base'] ); + $widget_id = wp_unslash( $_POST['widget-id'] ); + $sidebar_id = $_POST['sidebar']; + $multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0; + $settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false; + $error = '

    ' . __('An error has occurred. Please reload the page and try again.') . '

    '; + + $sidebars = wp_get_sidebars_widgets(); + $sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array(); + + // Delete. + if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { + + if ( !isset($wp_registered_widgets[$widget_id]) ) + wp_die( $error ); + + $sidebar = array_diff( $sidebar, array($widget_id) ); + $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1'); + + /** This action is documented in wp-admin/widgets.php */ + do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base ); + + } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) { + if ( !$multi_number ) + wp_die( $error ); + + $_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) ); + $widget_id = $id_base . '-' . $multi_number; + $sidebar[] = $widget_id; + } + $_POST['widget-id'] = $sidebar; + + foreach ( (array) $wp_registered_widget_updates as $name => $control ) { + + if ( $name == $id_base ) { + if ( !is_callable( $control['callback'] ) ) + continue; + + ob_start(); + call_user_func_array( $control['callback'], $control['params'] ); + ob_end_clean(); + break; + } + } + + if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { + $sidebars[$sidebar_id] = $sidebar; + wp_set_sidebars_widgets($sidebars); + echo "deleted:$widget_id"; + wp_die(); + } + + if ( !empty($_POST['add_new']) ) + wp_die(); + + if ( $form = $wp_registered_widget_controls[$widget_id] ) + call_user_func_array( $form['callback'], $form['params'] ); + + wp_die(); +} + +/** + * Ajax handler for saving a widget. + * + * @since 3.9.0 + * + * @global WP_Customize_Manager $wp_customize + */ +function wp_ajax_update_widget() { + global $wp_customize; + $wp_customize->widgets->wp_ajax_update_widget(); +} + +/** + * Ajax handler for removing inactive widgets. + * + * @since 4.4.0 + */ +function wp_ajax_delete_inactive_widgets() { + check_ajax_referer( 'remove-inactive-widgets', 'removeinactivewidgets' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_die( -1 ); + } + + unset( $_POST['removeinactivewidgets'], $_POST['action'] ); + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'load-widgets.php' ); + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'widgets.php' ); + /** This action is documented in wp-admin/widgets.php */ + do_action( 'sidebar_admin_setup' ); + + $sidebars_widgets = wp_get_sidebars_widgets(); + + foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) { + $pieces = explode( '-', $widget_id ); + $multi_number = array_pop( $pieces ); + $id_base = implode( '-', $pieces ); + $widget = get_option( 'widget_' . $id_base ); + unset( $widget[$multi_number] ); + update_option( 'widget_' . $id_base, $widget ); + unset( $sidebars_widgets['wp_inactive_widgets'][$key] ); + } + + wp_set_sidebars_widgets( $sidebars_widgets ); + + wp_die(); +} + +/** + * Ajax handler for uploading attachments + * + * @since 3.3.0 + */ +function wp_ajax_upload_attachment() { + check_ajax_referer( 'media-form' ); + /* + * This function does not use wp_send_json_success() / wp_send_json_error() + * as the html4 Plupload handler requires a text/html content-type for older IE. + * See https://core.trac.wordpress.org/ticket/31037 + */ + + if ( ! current_user_can( 'upload_files' ) ) { + echo wp_json_encode( array( + 'success' => false, + 'data' => array( + 'message' => __( 'Sorry, you are not allowed to upload files.' ), + 'filename' => $_FILES['async-upload']['name'], + ) + ) ); + + wp_die(); + } + + if ( isset( $_REQUEST['post_id'] ) ) { + $post_id = $_REQUEST['post_id']; + if ( ! current_user_can( 'edit_post', $post_id ) ) { + echo wp_json_encode( array( + 'success' => false, + 'data' => array( + 'message' => __( 'Sorry, you are not allowed to attach files to this post.' ), + 'filename' => $_FILES['async-upload']['name'], + ) + ) ); + + wp_die(); + } + } else { + $post_id = null; + } + + $post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array(); + + // If the context is custom header or background, make sure the uploaded file is an image. + if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) { + $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] ); + if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { + echo wp_json_encode( array( + 'success' => false, + 'data' => array( + 'message' => __( 'The uploaded file is not a valid image. Please try again.' ), + 'filename' => $_FILES['async-upload']['name'], + ) + ) ); + + wp_die(); + } + } + + $attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data ); + + if ( is_wp_error( $attachment_id ) ) { + echo wp_json_encode( array( + 'success' => false, + 'data' => array( + 'message' => $attachment_id->get_error_message(), + 'filename' => $_FILES['async-upload']['name'], + ) + ) ); + + wp_die(); + } + + if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { + if ( 'custom-background' === $post_data['context'] ) + update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); + + if ( 'custom-header' === $post_data['context'] ) + update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); + } + + if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) + wp_die(); + + echo wp_json_encode( array( + 'success' => true, + 'data' => $attachment, + ) ); + + wp_die(); +} + +/** + * Ajax handler for image editing. + * + * @since 3.1.0 + */ +function wp_ajax_image_editor() { + $attachment_id = intval($_POST['postid']); + if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) ) + wp_die( -1 ); + + check_ajax_referer( "image_editor-$attachment_id" ); + include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); + + $msg = false; + switch ( $_POST['do'] ) { + case 'save' : + $msg = wp_save_image($attachment_id); + $msg = wp_json_encode($msg); + wp_die( $msg ); + break; + case 'scale' : + $msg = wp_save_image($attachment_id); + break; + case 'restore' : + $msg = wp_restore_image($attachment_id); + break; + } + + wp_image_editor($attachment_id, $msg); + wp_die(); +} + +/** + * Ajax handler for setting the featured image. + * + * @since 3.1.0 + */ +function wp_ajax_set_post_thumbnail() { + $json = ! empty( $_REQUEST['json'] ); // New-style request + + $post_ID = intval( $_POST['post_id'] ); + if ( ! current_user_can( 'edit_post', $post_ID ) ) + wp_die( -1 ); + + $thumbnail_id = intval( $_POST['thumbnail_id'] ); + + if ( $json ) + check_ajax_referer( "update-post_$post_ID" ); + else + check_ajax_referer( "set_post_thumbnail-$post_ID" ); + + if ( $thumbnail_id == '-1' ) { + if ( delete_post_thumbnail( $post_ID ) ) { + $return = _wp_post_thumbnail_html( null, $post_ID ); + $json ? wp_send_json_success( $return ) : wp_die( $return ); + } else { + wp_die( 0 ); + } + } + + if ( set_post_thumbnail( $post_ID, $thumbnail_id ) ) { + $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); + $json ? wp_send_json_success( $return ) : wp_die( $return ); + } + + wp_die( 0 ); +} + +/** + * Ajax handler for retrieving HTML for the featured image. + * + * @since 4.6.0 + */ +function wp_ajax_get_post_thumbnail_html() { + $post_ID = intval( $_POST['post_id'] ); + + check_ajax_referer( "update-post_$post_ID" ); + + if ( ! current_user_can( 'edit_post', $post_ID ) ) { + wp_die( -1 ); + } + + $thumbnail_id = intval( $_POST['thumbnail_id'] ); + + // For backward compatibility, -1 refers to no featured image. + if ( -1 === $thumbnail_id ) { + $thumbnail_id = null; + } + + $return = _wp_post_thumbnail_html( $thumbnail_id, $post_ID ); + wp_send_json_success( $return ); +} + +/** + * Ajax handler for setting the featured image for an attachment. + * + * @since 4.0.0 + * + * @see set_post_thumbnail() + */ +function wp_ajax_set_attachment_thumbnail() { + if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) { + wp_send_json_error(); + } + + $thumbnail_id = (int) $_POST['thumbnail_id']; + if ( empty( $thumbnail_id ) ) { + wp_send_json_error(); + } + + $post_ids = array(); + // For each URL, try to find its corresponding post ID. + foreach ( $_POST['urls'] as $url ) { + $post_id = attachment_url_to_postid( $url ); + if ( ! empty( $post_id ) ) { + $post_ids[] = $post_id; + } + } + + if ( empty( $post_ids ) ) { + wp_send_json_error(); + } + + $success = 0; + // For each found attachment, set its thumbnail. + foreach ( $post_ids as $post_id ) { + if ( ! current_user_can( 'edit_post', $post_id ) ) { + continue; + } + + if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) { + $success++; + } + } + + if ( 0 === $success ) { + wp_send_json_error(); + } else { + wp_send_json_success(); + } + + wp_send_json_error(); +} + +/** + * Ajax handler for date formatting. + * + * @since 3.1.0 + */ +function wp_ajax_date_format() { + wp_die( date_i18n( sanitize_option( 'date_format', wp_unslash( $_POST['date'] ) ) ) ); +} + +/** + * Ajax handler for time formatting. + * + * @since 3.1.0 + */ +function wp_ajax_time_format() { + wp_die( date_i18n( sanitize_option( 'time_format', wp_unslash( $_POST['date'] ) ) ) ); +} + +/** + * Ajax handler for saving posts from the fullscreen editor. + * + * @since 3.1.0 + * @deprecated 4.3.0 + */ +function wp_ajax_wp_fullscreen_save_post() { + $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; + + $post = null; + + if ( $post_id ) + $post = get_post( $post_id ); + + check_ajax_referer('update-post_' . $post_id, '_wpnonce'); + + $post_id = edit_post(); + + if ( is_wp_error( $post_id ) ) { + wp_send_json_error(); + } + + if ( $post ) { + $last_date = mysql2date( __( 'F j, Y' ), $post->post_modified ); + $last_time = mysql2date( __( 'g:i a' ), $post->post_modified ); + } else { + $last_date = date_i18n( __( 'F j, Y' ) ); + $last_time = date_i18n( __( 'g:i a' ) ); + } + + if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) { + $last_user = get_userdata( $last_id ); + $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time ); + } else { + $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time ); + } + + wp_send_json_success( array( 'last_edited' => $last_edited ) ); +} + +/** + * Ajax handler for removing a post lock. + * + * @since 3.1.0 + */ +function wp_ajax_wp_remove_post_lock() { + if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) + wp_die( 0 ); + $post_id = (int) $_POST['post_ID']; + if ( ! $post = get_post( $post_id ) ) + wp_die( 0 ); + + check_ajax_referer( 'update-post_' . $post_id ); + + if ( ! current_user_can( 'edit_post', $post_id ) ) + wp_die( -1 ); + + $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); + if ( $active_lock[1] != get_current_user_id() ) + wp_die( 0 ); + + /** + * Filters the post lock window duration. + * + * @since 3.3.0 + * + * @param int $interval The interval in seconds the post lock duration + * should last, plus 5 seconds. Default 150. + */ + $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; + update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); + wp_die( 1 ); +} + +/** + * Ajax handler for dismissing a WordPress pointer. + * + * @since 3.1.0 + */ +function wp_ajax_dismiss_wp_pointer() { + $pointer = $_POST['pointer']; + if ( $pointer != sanitize_key( $pointer ) ) + wp_die( 0 ); + +// check_ajax_referer( 'dismiss-pointer_' . $pointer ); + + $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); + + if ( in_array( $pointer, $dismissed ) ) + wp_die( 0 ); + + $dismissed[] = $pointer; + $dismissed = implode( ',', $dismissed ); + + update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); + wp_die( 1 ); +} + +/** + * Ajax handler for getting an attachment. + * + * @since 3.5.0 + */ +function wp_ajax_get_attachment() { + if ( ! isset( $_REQUEST['id'] ) ) + wp_send_json_error(); + + if ( ! $id = absint( $_REQUEST['id'] ) ) + wp_send_json_error(); + + if ( ! $post = get_post( $id ) ) + wp_send_json_error(); + + if ( 'attachment' != $post->post_type ) + wp_send_json_error(); + + if ( ! current_user_can( 'upload_files' ) ) + wp_send_json_error(); + + if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) + wp_send_json_error(); + + wp_send_json_success( $attachment ); +} + +/** + * Ajax handler for querying attachments. + * + * @since 3.5.0 + */ +function wp_ajax_query_attachments() { + if ( ! current_user_can( 'upload_files' ) ) + wp_send_json_error(); + + $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); + $keys = array( + 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', + 'post_parent', 'author', 'post__in', 'post__not_in', 'year', 'monthnum' + ); + foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { + if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { + $keys[] = $t->query_var; + } + } + + $query = array_intersect_key( $query, array_flip( $keys ) ); + $query['post_type'] = 'attachment'; + if ( MEDIA_TRASH + && ! empty( $_REQUEST['query']['post_status'] ) + && 'trash' === $_REQUEST['query']['post_status'] ) { + $query['post_status'] = 'trash'; + } else { + $query['post_status'] = 'inherit'; + } + + if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) + $query['post_status'] .= ',private'; + + // Filter query clauses to include filenames. + if ( isset( $query['s'] ) ) { + add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); + } + + /** + * Filters the arguments passed to WP_Query during an Ajax + * call for querying attachments. + * + * @since 3.7.0 + * + * @see WP_Query::parse_query() + * + * @param array $query An array of query variables. + */ + $query = apply_filters( 'ajax_query_attachments_args', $query ); + $query = new WP_Query( $query ); + + $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); + $posts = array_filter( $posts ); + + wp_send_json_success( $posts ); +} + +/** + * Ajax handler for updating attachment attributes. + * + * @since 3.5.0 + */ +function wp_ajax_save_attachment() { + if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) + wp_send_json_error(); + + if ( ! $id = absint( $_REQUEST['id'] ) ) + wp_send_json_error(); + + check_ajax_referer( 'update-post_' . $id, 'nonce' ); + + if ( ! current_user_can( 'edit_post', $id ) ) + wp_send_json_error(); + + $changes = $_REQUEST['changes']; + $post = get_post( $id, ARRAY_A ); + + if ( 'attachment' != $post['post_type'] ) + wp_send_json_error(); + + if ( isset( $changes['parent'] ) ) + $post['post_parent'] = $changes['parent']; + + if ( isset( $changes['title'] ) ) + $post['post_title'] = $changes['title']; + + if ( isset( $changes['caption'] ) ) + $post['post_excerpt'] = $changes['caption']; + + if ( isset( $changes['description'] ) ) + $post['post_content'] = $changes['description']; + + if ( MEDIA_TRASH && isset( $changes['status'] ) ) + $post['post_status'] = $changes['status']; + + if ( isset( $changes['alt'] ) ) { + $alt = wp_unslash( $changes['alt'] ); + if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) { + $alt = wp_strip_all_tags( $alt, true ); + update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) ); + } + } + + if ( wp_attachment_is( 'audio', $post['ID'] ) ) { + $changed = false; + $id3data = wp_get_attachment_metadata( $post['ID'] ); + if ( ! is_array( $id3data ) ) { + $changed = true; + $id3data = array(); + } + foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) { + if ( isset( $changes[ $key ] ) ) { + $changed = true; + $id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) ); + } + } + + if ( $changed ) { + wp_update_attachment_metadata( $id, $id3data ); + } + } + + if ( MEDIA_TRASH && isset( $changes['status'] ) && 'trash' === $changes['status'] ) { + wp_delete_post( $id ); + } else { + wp_update_post( $post ); + } + + wp_send_json_success(); +} + +/** + * Ajax handler for saving backward compatible attachment attributes. + * + * @since 3.5.0 + */ +function wp_ajax_save_attachment_compat() { + if ( ! isset( $_REQUEST['id'] ) ) + wp_send_json_error(); + + if ( ! $id = absint( $_REQUEST['id'] ) ) + wp_send_json_error(); + + if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) + wp_send_json_error(); + $attachment_data = $_REQUEST['attachments'][ $id ]; + + check_ajax_referer( 'update-post_' . $id, 'nonce' ); + + if ( ! current_user_can( 'edit_post', $id ) ) + wp_send_json_error(); + + $post = get_post( $id, ARRAY_A ); + + if ( 'attachment' != $post['post_type'] ) + wp_send_json_error(); + + /** This filter is documented in wp-admin/includes/media.php */ + $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); + + if ( isset( $post['errors'] ) ) { + $errors = $post['errors']; // @todo return me and display me! + unset( $post['errors'] ); + } + + wp_update_post( $post ); + + foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) { + if ( isset( $attachment_data[ $taxonomy ] ) ) + wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false ); + } + + if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) + wp_send_json_error(); + + wp_send_json_success( $attachment ); +} + +/** + * Ajax handler for saving the attachment order. + * + * @since 3.5.0 + */ +function wp_ajax_save_attachment_order() { + if ( ! isset( $_REQUEST['post_id'] ) ) + wp_send_json_error(); + + if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) + wp_send_json_error(); + + if ( empty( $_REQUEST['attachments'] ) ) + wp_send_json_error(); + + check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); + + $attachments = $_REQUEST['attachments']; + + if ( ! current_user_can( 'edit_post', $post_id ) ) + wp_send_json_error(); + + foreach ( $attachments as $attachment_id => $menu_order ) { + if ( ! current_user_can( 'edit_post', $attachment_id ) ) + continue; + if ( ! $attachment = get_post( $attachment_id ) ) + continue; + if ( 'attachment' != $attachment->post_type ) + continue; + + wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) ); + } + + wp_send_json_success(); +} + +/** + * Ajax handler for sending an attachment to the editor. + * + * Generates the HTML to send an attachment to the editor. + * Backward compatible with the {@see 'media_send_to_editor'} filter + * and the chain of filters that follow. + * + * @since 3.5.0 + */ +function wp_ajax_send_attachment_to_editor() { + check_ajax_referer( 'media-send-to-editor', 'nonce' ); + + $attachment = wp_unslash( $_POST['attachment'] ); + + $id = intval( $attachment['id'] ); + + if ( ! $post = get_post( $id ) ) + wp_send_json_error(); + + if ( 'attachment' != $post->post_type ) + wp_send_json_error(); + + if ( current_user_can( 'edit_post', $id ) ) { + // If this attachment is unattached, attach it. Primarily a back compat thing. + if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) { + wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) ); + } + } + + $url = empty( $attachment['url'] ) ? '' : $attachment['url']; + $rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ); + + remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); + + if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { + $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; + $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; + $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; + + // No whitespace-only captions. + $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; + if ( '' === trim( $caption ) ) { + $caption = ''; + } + + $title = ''; // We no longer insert title tags into tags, as they are redundant. + $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); + } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { + $html = stripslashes_deep( $_POST['html'] ); + } else { + $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; + $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized + + if ( ! empty( $url ) ) { + $html = '' . $html . ''; + } + } + + /** This filter is documented in wp-admin/includes/media.php */ + $html = apply_filters( 'media_send_to_editor', $html, $id, $attachment ); + + wp_send_json_success( $html ); +} + +/** + * Ajax handler for sending a link to the editor. + * + * Generates the HTML to send a non-image embed link to the editor. + * + * Backward compatible with the following filters: + * - file_send_to_editor_url + * - audio_send_to_editor_url + * - video_send_to_editor_url + * + * @since 3.5.0 + * + * @global WP_Post $post + * @global WP_Embed $wp_embed + */ +function wp_ajax_send_link_to_editor() { + global $post, $wp_embed; + + check_ajax_referer( 'media-send-to-editor', 'nonce' ); + + if ( ! $src = wp_unslash( $_POST['src'] ) ) + wp_send_json_error(); + + if ( ! strpos( $src, '://' ) ) + $src = 'http://' . $src; + + if ( ! $src = esc_url_raw( $src ) ) + wp_send_json_error(); + + if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) + $link_text = wp_basename( $src ); + + $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); + + // Ping WordPress for an embed. + $check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' ); + + // Fallback that WordPress creates when no oEmbed was found. + $fallback = $wp_embed->maybe_make_link( $src ); + + if ( $check_embed !== $fallback ) { + // TinyMCE view for [embed] will parse this + $html = '[embed]' . $src . '[/embed]'; + } elseif ( $link_text ) { + $html = '' . $link_text . ''; + } else { + $html = ''; + } + + // Figure out what filter to run: + $type = 'file'; + if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) + && ( 'audio' == $ext_type || 'video' == $ext_type ) ) + $type = $ext_type; + + /** This filter is documented in wp-admin/includes/media.php */ + $html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text ); + + wp_send_json_success( $html ); +} + +/** + * Ajax handler for the Heartbeat API. + * + * Runs when the user is logged in. + * + * @since 3.6.0 + */ +function wp_ajax_heartbeat() { + if ( empty( $_POST['_nonce'] ) ) { + wp_send_json_error(); + } + + $response = $data = array(); + $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); + + // screen_id is the same as $current_screen->id and the JS global 'pagenow'. + if ( ! empty( $_POST['screen_id'] ) ) { + $screen_id = sanitize_key($_POST['screen_id']); + } else { + $screen_id = 'front'; + } + + if ( ! empty( $_POST['data'] ) ) { + $data = wp_unslash( (array) $_POST['data'] ); + } + + if ( 1 !== $nonce_state ) { + $response = apply_filters( 'wp_refresh_nonces', $response, $data, $screen_id ); + + if ( false === $nonce_state ) { + // User is logged in but nonces have expired. + $response['nonces_expired'] = true; + wp_send_json( $response ); + } + } + + if ( ! empty( $data ) ) { + /** + * Filters the Heartbeat response received. + * + * @since 3.6.0 + * + * @param array $response The Heartbeat response. + * @param array $data The $_POST data sent. + * @param string $screen_id The screen id. + */ + $response = apply_filters( 'heartbeat_received', $response, $data, $screen_id ); + } + + /** + * Filters the Heartbeat response sent. + * + * @since 3.6.0 + * + * @param array $response The Heartbeat response. + * @param string $screen_id The screen id. + */ + $response = apply_filters( 'heartbeat_send', $response, $screen_id ); + + /** + * Fires when Heartbeat ticks in logged-in environments. + * + * Allows the transport to be easily replaced with long-polling. + * + * @since 3.6.0 + * + * @param array $response The Heartbeat response. + * @param string $screen_id The screen id. + */ + do_action( 'heartbeat_tick', $response, $screen_id ); + + // Send the current time according to the server + $response['server_time'] = time(); + + wp_send_json( $response ); +} + +/** + * Ajax handler for getting revision diffs. + * + * @since 3.6.0 + */ +function wp_ajax_get_revision_diffs() { + require ABSPATH . 'wp-admin/includes/revision.php'; + + if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) + wp_send_json_error(); + + if ( ! current_user_can( 'edit_post', $post->ID ) ) + wp_send_json_error(); + + // Really just pre-loading the cache here. + if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) + wp_send_json_error(); + + $return = array(); + @set_time_limit( 0 ); + + foreach ( $_REQUEST['compare'] as $compare_key ) { + list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to + + $return[] = array( + 'id' => $compare_key, + 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ), + ); + } + wp_send_json_success( $return ); +} + +/** + * Ajax handler for auto-saving the selected color scheme for + * a user's own profile. + * + * @since 3.8.0 + * + * @global array $_wp_admin_css_colors + */ +function wp_ajax_save_user_color_scheme() { + global $_wp_admin_css_colors; + + check_ajax_referer( 'save-color-scheme', 'nonce' ); + + $color_scheme = sanitize_key( $_POST['color_scheme'] ); + + if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { + wp_send_json_error(); + } + + $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); + update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); + + wp_send_json_success( array( + 'previousScheme' => 'admin-color-' . $previous_color_scheme, + 'currentScheme' => 'admin-color-' . $color_scheme + ) ); +} + +/** + * Ajax handler for getting themes from themes_api(). + * + * @since 3.9.0 + * + * @global array $themes_allowedtags + * @global array $theme_field_defaults + */ +function wp_ajax_query_themes() { + global $themes_allowedtags, $theme_field_defaults; + + if ( ! current_user_can( 'install_themes' ) ) { + wp_send_json_error(); + } + + $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array( + 'per_page' => 20, + 'fields' => $theme_field_defaults + ) ); + + if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) { + $user = get_user_option( 'wporg_favorites' ); + if ( $user ) { + $args['user'] = $user; + } + } + + $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; + + /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ + $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); + + $api = themes_api( 'query_themes', $args ); + + if ( is_wp_error( $api ) ) { + wp_send_json_error(); + } + + $update_php = network_admin_url( 'update.php?action=install-theme' ); + foreach ( $api->themes as &$theme ) { + $theme->install_url = add_query_arg( array( + 'theme' => $theme->slug, + '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ) + ), $update_php ); + + if ( current_user_can( 'switch_themes' ) ) { + if ( is_multisite() ) { + $theme->activate_url = add_query_arg( array( + 'action' => 'enable', + '_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ), + 'theme' => $theme->slug, + ), network_admin_url( 'themes.php' ) ); + } else { + $theme->activate_url = add_query_arg( array( + 'action' => 'activate', + '_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ), + 'stylesheet' => $theme->slug, + ), admin_url( 'themes.php' ) ); + } + } + + if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $theme->customize_url = add_query_arg( array( + 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), + ), wp_customize_url( $theme->slug ) ); + } + + $theme->name = wp_kses( $theme->name, $themes_allowedtags ); + $theme->author = wp_kses( $theme->author, $themes_allowedtags ); + $theme->version = wp_kses( $theme->version, $themes_allowedtags ); + $theme->description = wp_kses( $theme->description, $themes_allowedtags ); + $theme->stars = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false ) ); + $theme->num_ratings = number_format_i18n( $theme->num_ratings ); + $theme->preview_url = set_url_scheme( $theme->preview_url ); + } + + wp_send_json_success( $api ); +} + +/** + * Apply [embed] Ajax handlers to a string. + * + * @since 4.0.0 + * + * @global WP_Post $post Global $post. + * @global WP_Embed $wp_embed Embed API instance. + * @global WP_Scripts $wp_scripts + * @global int $content_width + */ +function wp_ajax_parse_embed() { + global $post, $wp_embed, $content_width; + + if ( empty( $_POST['shortcode'] ) ) { + wp_send_json_error(); + } + $post_id = isset( $_POST[ 'post_ID' ] ) ? intval( $_POST[ 'post_ID' ] ) : 0; + if ( $post_id > 0 ) { + $post = get_post( $post_id ); + if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { + wp_send_json_error(); + } + setup_postdata( $post ); + } elseif ( ! current_user_can( 'edit_posts' ) ) { // See WP_oEmbed_Controller::get_proxy_item_permissions_check(). + wp_send_json_error(); + } + + $shortcode = wp_unslash( $_POST['shortcode'] ); + + preg_match( '/' . get_shortcode_regex() . '/s', $shortcode, $matches ); + $atts = shortcode_parse_atts( $matches[3] ); + if ( ! empty( $matches[5] ) ) { + $url = $matches[5]; + } elseif ( ! empty( $atts['src'] ) ) { + $url = $atts['src']; + } else { + $url = ''; + } + + $parsed = false; + $wp_embed->return_false_on_fail = true; + + if ( 0 === $post_id ) { + /* + * Refresh oEmbeds cached outside of posts that are past their TTL. + * Posts are excluded because they have separate logic for refreshing + * their post meta caches. See WP_Embed::cache_oembed(). + */ + $wp_embed->usecache = false; + } + + if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { + // Admin is ssl and the user pasted non-ssl URL. + // Check if the provider supports ssl embeds and use that for the preview. + $ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode ); + $parsed = $wp_embed->run_shortcode( $ssl_shortcode ); + + if ( ! $parsed ) { + $no_ssl_support = true; + } + } + + // Set $content_width so any embeds fit in the destination iframe. + if ( isset( $_POST['maxwidth'] ) && is_numeric( $_POST['maxwidth'] ) && $_POST['maxwidth'] > 0 ) { + if ( ! isset( $content_width ) ) { + $content_width = intval( $_POST['maxwidth'] ); + } else { + $content_width = min( $content_width, intval( $_POST['maxwidth'] ) ); + } + } + + if ( $url && ! $parsed ) { + $parsed = $wp_embed->run_shortcode( $shortcode ); + } + + if ( ! $parsed ) { + wp_send_json_error( array( + 'type' => 'not-embeddable', + 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '' ), + ) ); + } + + if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) { + $styles = ''; + $mce_styles = wpview_media_sandbox_styles(); + foreach ( $mce_styles as $style ) { + $styles .= sprintf( '', $style ); + } + + $html = do_shortcode( $parsed ); + + global $wp_scripts; + if ( ! empty( $wp_scripts ) ) { + $wp_scripts->done = array(); + } + ob_start(); + wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); + $scripts = ob_get_clean(); + + $parsed = $styles . $html . $scripts; + } + + if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || + preg_match( '%]*href="http://%', $parsed ) ) ) ) { + // Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked. + wp_send_json_error( array( + 'type' => 'not-ssl', + 'message' => __( 'This preview is unavailable in the editor.' ), + ) ); + } + + $return = array( + 'body' => $parsed, + 'attr' => $wp_embed->last_attr + ); + + if ( strpos( $parsed, 'class="wp-embedded-content' ) ) { + if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { + $script_src = includes_url( 'js/wp-embed.js' ); + } else { + $script_src = includes_url( 'js/wp-embed.min.js' ); + } + + $return['head'] = ''; + $return['sandbox'] = true; + } + + wp_send_json_success( $return ); +} + +/** + * @since 4.0.0 + * + * @global WP_Post $post + * @global WP_Scripts $wp_scripts + */ +function wp_ajax_parse_media_shortcode() { + global $post, $wp_scripts; + + if ( empty( $_POST['shortcode'] ) ) { + wp_send_json_error(); + } + + $shortcode = wp_unslash( $_POST['shortcode'] ); + + if ( ! empty( $_POST['post_ID'] ) ) { + $post = get_post( (int) $_POST['post_ID'] ); + } + + // the embed shortcode requires a post + if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { + if ( 'embed' === $shortcode ) { + wp_send_json_error(); + } + } else { + setup_postdata( $post ); + } + + $parsed = do_shortcode( $shortcode ); + + if ( empty( $parsed ) ) { + wp_send_json_error( array( + 'type' => 'no-items', + 'message' => __( 'No items found.' ), + ) ); + } + + $head = ''; + $styles = wpview_media_sandbox_styles(); + + foreach ( $styles as $style ) { + $head .= ''; + } + + if ( ! empty( $wp_scripts ) ) { + $wp_scripts->done = array(); + } + + ob_start(); + + echo $parsed; + + if ( 'playlist' === $_REQUEST['type'] ) { + wp_underscore_playlist_templates(); + + wp_print_scripts( 'wp-playlist' ); + } else { + wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) ); + } + + wp_send_json_success( array( + 'head' => $head, + 'body' => ob_get_clean() + ) ); +} + +/** + * Ajax handler for destroying multiple open sessions for a user. + * + * @since 4.1.0 + */ +function wp_ajax_destroy_sessions() { + $user = get_userdata( (int) $_POST['user_id'] ); + if ( $user ) { + if ( ! current_user_can( 'edit_user', $user->ID ) ) { + $user = false; + } elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) { + $user = false; + } + } + + if ( ! $user ) { + wp_send_json_error( array( + 'message' => __( 'Could not log out user sessions. Please try again.' ), + ) ); + } + + $sessions = WP_Session_Tokens::get_instance( $user->ID ); + + if ( $user->ID === get_current_user_id() ) { + $sessions->destroy_others( wp_get_session_token() ); + $message = __( 'You are now logged out everywhere else.' ); + } else { + $sessions->destroy_all(); + /* translators: %s: User's display name. */ + $message = sprintf( __( '%s has been logged out.' ), $user->display_name ); + } + + wp_send_json_success( array( 'message' => $message ) ); +} + +/** + * Ajax handler for cropping an image. + * + * @since 4.3.0 + */ +function wp_ajax_crop_image() { + $attachment_id = absint( $_POST['id'] ); + + check_ajax_referer( 'image_editor-' . $attachment_id, 'nonce' ); + if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) { + wp_send_json_error(); + } + + $context = str_replace( '_', '-', $_POST['context'] ); + $data = array_map( 'absint', $_POST['cropDetails'] ); + $cropped = wp_crop_image( $attachment_id, $data['x1'], $data['y1'], $data['width'], $data['height'], $data['dst_width'], $data['dst_height'] ); + + if ( ! $cropped || is_wp_error( $cropped ) ) { + wp_send_json_error( array( 'message' => __( 'Image could not be processed.' ) ) ); + } + + switch ( $context ) { + case 'site-icon': + require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php'; + $wp_site_icon = new WP_Site_Icon(); + + // Skip creating a new attachment if the attachment is a Site Icon. + if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { + + // Delete the temporary cropped file, we don't need it. + wp_delete_file( $cropped ); + + // Additional sizes in wp_prepare_attachment_for_js(). + add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); + break; + } + + /** This filter is documented in wp-admin/custom-header.php */ + $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. + $object = $wp_site_icon->create_attachment_object( $cropped, $attachment_id ); + unset( $object['ID'] ); + + // Update the attachment. + add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); + $attachment_id = $wp_site_icon->insert_attachment( $object, $cropped ); + remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) ); + + // Additional sizes in wp_prepare_attachment_for_js(). + add_filter( 'image_size_names_choose', array( $wp_site_icon, 'additional_sizes' ) ); + break; + + default: + + /** + * Fires before a cropped image is saved. + * + * Allows to add filters to modify the way a cropped image is saved. + * + * @since 4.3.0 + * + * @param string $context The Customizer control requesting the cropped image. + * @param int $attachment_id The attachment ID of the original image. + * @param string $cropped Path to the cropped image file. + */ + do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped ); + + /** This filter is documented in wp-admin/custom-header.php */ + $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. + + $parent_url = wp_get_attachment_url( $attachment_id ); + $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); + + $size = @getimagesize( $cropped ); + $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; + + $object = array( + 'post_title' => basename( $cropped ), + 'post_content' => $url, + 'post_mime_type' => $image_type, + 'guid' => $url, + 'context' => $context, + ); + + $attachment_id = wp_insert_attachment( $object, $cropped ); + $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); + + /** + * Filters the cropped image attachment metadata. + * + * @since 4.3.0 + * + * @see wp_generate_attachment_metadata() + * + * @param array $metadata Attachment metadata. + */ + $metadata = apply_filters( 'wp_ajax_cropped_attachment_metadata', $metadata ); + wp_update_attachment_metadata( $attachment_id, $metadata ); + + /** + * Filters the attachment ID for a cropped image. + * + * @since 4.3.0 + * + * @param int $attachment_id The attachment ID of the cropped image. + * @param string $context The Customizer control requesting the cropped image. + */ + $attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context ); + } + + wp_send_json_success( wp_prepare_attachment_for_js( $attachment_id ) ); +} + +/** + * Ajax handler for generating a password. + * + * @since 4.4.0 + */ +function wp_ajax_generate_password() { + wp_send_json_success( wp_generate_password( 24 ) ); +} + +/** + * Ajax handler for saving the user's WordPress.org username. + * + * @since 4.4.0 + */ +function wp_ajax_save_wporg_username() { + if ( ! current_user_can( 'install_themes' ) && ! current_user_can( 'install_plugins' ) ) { + wp_send_json_error(); + } + + check_ajax_referer( 'save_wporg_username_' . get_current_user_id() ); + + $username = isset( $_REQUEST['username'] ) ? wp_unslash( $_REQUEST['username'] ) : false; + + if ( ! $username ) { + wp_send_json_error(); + } + + wp_send_json_success( update_user_meta( get_current_user_id(), 'wporg_favorites', $username ) ); +} + +/** + * Ajax handler for installing a theme. + * + * @since 4.6.0 + * + * @see Theme_Upgrader + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_install_theme() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['slug'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_theme_specified', + 'errorMessage' => __( 'No theme specified.' ), + ) ); + } + + $slug = sanitize_key( wp_unslash( $_POST['slug'] ) ); + + $status = array( + 'install' => 'theme', + 'slug' => $slug, + ); + + if ( ! current_user_can( 'install_themes' ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to install themes on this site.' ); + wp_send_json_error( $status ); + } + + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + include_once( ABSPATH . 'wp-admin/includes/theme.php' ); + + $api = themes_api( 'theme_information', array( + 'slug' => $slug, + 'fields' => array( 'sections' => false ), + ) ); + + if ( is_wp_error( $api ) ) { + $status['errorMessage'] = $api->get_error_message(); + wp_send_json_error( $status ); + } + + $skin = new WP_Ajax_Upgrader_Skin(); + $upgrader = new Theme_Upgrader( $skin ); + $result = $upgrader->install( $api->download_link ); + + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + $status['debug'] = $skin->get_upgrade_messages(); + } + + if ( is_wp_error( $result ) ) { + $status['errorCode'] = $result->get_error_code(); + $status['errorMessage'] = $result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( is_wp_error( $skin->result ) ) { + $status['errorCode'] = $skin->result->get_error_code(); + $status['errorMessage'] = $skin->result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( $skin->get_errors()->get_error_code() ) { + $status['errorMessage'] = $skin->get_error_messages(); + wp_send_json_error( $status ); + } elseif ( is_null( $result ) ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + $status['themeName'] = wp_get_theme( $slug )->get( 'Name' ); + + if ( current_user_can( 'switch_themes' ) ) { + if ( is_multisite() ) { + $status['activateUrl'] = add_query_arg( array( + 'action' => 'enable', + '_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ), + 'theme' => $slug, + ), network_admin_url( 'themes.php' ) ); + } else { + $status['activateUrl'] = add_query_arg( array( + 'action' => 'activate', + '_wpnonce' => wp_create_nonce( 'switch-theme_' . $slug ), + 'stylesheet' => $slug, + ), admin_url( 'themes.php' ) ); + } + } + + if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $status['customizeUrl'] = add_query_arg( array( + 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ), + ), wp_customize_url( $slug ) ); + } + + /* + * See WP_Theme_Install_List_Table::_get_theme_status() if we wanted to check + * on post-installation status. + */ + wp_send_json_success( $status ); +} + +/** + * Ajax handler for updating a theme. + * + * @since 4.6.0 + * + * @see Theme_Upgrader + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_update_theme() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['slug'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_theme_specified', + 'errorMessage' => __( 'No theme specified.' ), + ) ); + } + + $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); + $status = array( + 'update' => 'theme', + 'slug' => $stylesheet, + 'oldVersion' => '', + 'newVersion' => '', + ); + + if ( ! current_user_can( 'update_themes' ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to update themes for this site.' ); + wp_send_json_error( $status ); + } + + $theme = wp_get_theme( $stylesheet ); + if ( $theme->exists() ) { + $status['oldVersion'] = $theme->get( 'Version' ); + } + + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + + $current = get_site_transient( 'update_themes' ); + if ( empty( $current ) ) { + wp_update_themes(); + } + + $skin = new WP_Ajax_Upgrader_Skin(); + $upgrader = new Theme_Upgrader( $skin ); + $result = $upgrader->bulk_upgrade( array( $stylesheet ) ); + + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + $status['debug'] = $skin->get_upgrade_messages(); + } + + if ( is_wp_error( $skin->result ) ) { + $status['errorCode'] = $skin->result->get_error_code(); + $status['errorMessage'] = $skin->result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( $skin->get_errors()->get_error_code() ) { + $status['errorMessage'] = $skin->get_error_messages(); + wp_send_json_error( $status ); + } elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) { + + // Theme is already at the latest version. + if ( true === $result[ $stylesheet ] ) { + $status['errorMessage'] = $upgrader->strings['up_to_date']; + wp_send_json_error( $status ); + } + + $theme = wp_get_theme( $stylesheet ); + if ( $theme->exists() ) { + $status['newVersion'] = $theme->get( 'Version' ); + } + + wp_send_json_success( $status ); + } elseif ( false === $result ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + // An unhandled error occurred. + $status['errorMessage'] = __( 'Update failed.' ); + wp_send_json_error( $status ); +} + +/** + * Ajax handler for deleting a theme. + * + * @since 4.6.0 + * + * @see delete_theme() + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_delete_theme() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['slug'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_theme_specified', + 'errorMessage' => __( 'No theme specified.' ), + ) ); + } + + $stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) ); + $status = array( + 'delete' => 'theme', + 'slug' => $stylesheet, + ); + + if ( ! current_user_can( 'delete_themes' ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to delete themes on this site.' ); + wp_send_json_error( $status ); + } + + if ( ! wp_get_theme( $stylesheet )->exists() ) { + $status['errorMessage'] = __( 'The requested theme does not exist.' ); + wp_send_json_error( $status ); + } + + // Check filesystem credentials. `delete_theme()` will bail otherwise. + $url = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ); + ob_start(); + $credentials = request_filesystem_credentials( $url ); + ob_end_clean(); + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + include_once( ABSPATH . 'wp-admin/includes/theme.php' ); + + $result = delete_theme( $stylesheet ); + + if ( is_wp_error( $result ) ) { + $status['errorMessage'] = $result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( false === $result ) { + $status['errorMessage'] = __( 'Theme could not be deleted.' ); + wp_send_json_error( $status ); + } + + wp_send_json_success( $status ); +} + +/** + * Ajax handler for installing a plugin. + * + * @since 4.6.0 + * + * @see Plugin_Upgrader + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_install_plugin() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['slug'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_plugin_specified', + 'errorMessage' => __( 'No plugin specified.' ), + ) ); + } + + $status = array( + 'install' => 'plugin', + 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), + ); + + if ( ! current_user_can( 'install_plugins' ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to install plugins on this site.' ); + wp_send_json_error( $status ); + } + + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); + + $api = plugins_api( 'plugin_information', array( + 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), + 'fields' => array( + 'sections' => false, + ), + ) ); + + if ( is_wp_error( $api ) ) { + $status['errorMessage'] = $api->get_error_message(); + wp_send_json_error( $status ); + } + + $status['pluginName'] = $api->name; + + $skin = new WP_Ajax_Upgrader_Skin(); + $upgrader = new Plugin_Upgrader( $skin ); + $result = $upgrader->install( $api->download_link ); + + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + $status['debug'] = $skin->get_upgrade_messages(); + } + + if ( is_wp_error( $result ) ) { + $status['errorCode'] = $result->get_error_code(); + $status['errorMessage'] = $result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( is_wp_error( $skin->result ) ) { + $status['errorCode'] = $skin->result->get_error_code(); + $status['errorMessage'] = $skin->result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( $skin->get_errors()->get_error_code() ) { + $status['errorMessage'] = $skin->get_error_messages(); + wp_send_json_error( $status ); + } elseif ( is_null( $result ) ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + $install_status = install_plugin_install_status( $api ); + $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; + + // If installation request is coming from import page, do not return network activation link. + $plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' ); + + if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) { + $status['activateUrl'] = add_query_arg( array( + '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ), + 'action' => 'activate', + 'plugin' => $install_status['file'], + ), $plugins_url ); + } + + if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) { + $status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] ); + } + + wp_send_json_success( $status ); +} + +/** + * Ajax handler for updating a plugin. + * + * @since 4.2.0 + * + * @see Plugin_Upgrader + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_update_plugin() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_plugin_specified', + 'errorMessage' => __( 'No plugin specified.' ), + ) ); + } + + $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); + + $status = array( + 'update' => 'plugin', + 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), + 'oldVersion' => '', + 'newVersion' => '', + ); + + if ( ! current_user_can( 'update_plugins' ) || 0 !== validate_file( $plugin ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to update plugins for this site.' ); + wp_send_json_error( $status ); + } + + $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); + $status['plugin'] = $plugin; + $status['pluginName'] = $plugin_data['Name']; + + if ( $plugin_data['Version'] ) { + /* translators: %s: Plugin version */ + $status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); + } + + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + + wp_update_plugins(); + + $skin = new WP_Ajax_Upgrader_Skin(); + $upgrader = new Plugin_Upgrader( $skin ); + $result = $upgrader->bulk_upgrade( array( $plugin ) ); + + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + $status['debug'] = $skin->get_upgrade_messages(); + } + + if ( is_wp_error( $skin->result ) ) { + $status['errorCode'] = $skin->result->get_error_code(); + $status['errorMessage'] = $skin->result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( $skin->get_errors()->get_error_code() ) { + $status['errorMessage'] = $skin->get_error_messages(); + wp_send_json_error( $status ); + } elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) { + $plugin_update_data = current( $result ); + + /* + * If the `update_plugins` site transient is empty (e.g. when you update + * two plugins in quick succession before the transient repopulates), + * this may be the return. + * + * Preferably something can be done to ensure `update_plugins` isn't empty. + * For now, surface some sort of error here. + */ + if ( true === $plugin_update_data ) { + $status['errorMessage'] = __( 'Plugin update failed.' ); + wp_send_json_error( $status ); + } + + $plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name'] ); + $plugin_data = reset( $plugin_data ); + + if ( $plugin_data['Version'] ) { + /* translators: %s: Plugin version */ + $status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); + } + wp_send_json_success( $status ); + } elseif ( false === $result ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + // An unhandled error occurred. + $status['errorMessage'] = __( 'Plugin update failed.' ); + wp_send_json_error( $status ); +} + +/** + * Ajax handler for deleting a plugin. + * + * @since 4.6.0 + * + * @see delete_plugins() + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + */ +function wp_ajax_delete_plugin() { + check_ajax_referer( 'updates' ); + + if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) { + wp_send_json_error( array( + 'slug' => '', + 'errorCode' => 'no_plugin_specified', + 'errorMessage' => __( 'No plugin specified.' ), + ) ); + } + + $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ); + + $status = array( + 'delete' => 'plugin', + 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ), + ); + + if ( ! current_user_can( 'delete_plugins' ) || 0 !== validate_file( $plugin ) ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to delete plugins for this site.' ); + wp_send_json_error( $status ); + } + + $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); + $status['plugin'] = $plugin; + $status['pluginName'] = $plugin_data['Name']; + + if ( is_plugin_active( $plugin ) ) { + $status['errorMessage'] = __( 'You cannot delete a plugin while it is active on the main site.' ); + wp_send_json_error( $status ); + } + + // Check filesystem credentials. `delete_plugins()` will bail otherwise. + $url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins' ); + ob_start(); + $credentials = request_filesystem_credentials( $url ); + ob_end_clean(); + if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { + global $wp_filesystem; + + $status['errorCode'] = 'unable_to_connect_to_filesystem'; + $status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + + // Pass through the error from WP_Filesystem if one was raised. + if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { + $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); + } + + wp_send_json_error( $status ); + } + + $result = delete_plugins( array( $plugin ) ); + + if ( is_wp_error( $result ) ) { + $status['errorMessage'] = $result->get_error_message(); + wp_send_json_error( $status ); + } elseif ( false === $result ) { + $status['errorMessage'] = __( 'Plugin could not be deleted.' ); + wp_send_json_error( $status ); + } + + wp_send_json_success( $status ); +} + +/** + * Ajax handler for searching plugins. + * + * @since 4.6.0 + * + * @global string $s Search term. + */ +function wp_ajax_search_plugins() { + check_ajax_referer( 'updates' ); + + $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; + if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) { + set_current_screen( $pagenow ); + } + + /** @var WP_Plugins_List_Table $wp_list_table */ + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array( + 'screen' => get_current_screen(), + ) ); + + $status = array(); + + if ( ! $wp_list_table->ajax_user_can() ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); + wp_send_json_error( $status ); + } + + // Set the correct requester, so pagination works. + $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( + '_ajax_nonce' => null, + 'action' => null, + ) ), network_admin_url( 'plugins.php', 'relative' ) ); + + $GLOBALS['s'] = wp_unslash( $_POST['s'] ); + + $wp_list_table->prepare_items(); + + ob_start(); + $wp_list_table->display(); + $status['count'] = count( $wp_list_table->items ); + $status['items'] = ob_get_clean(); + + wp_send_json_success( $status ); +} + +/** + * Ajax handler for searching plugins to install. + * + * @since 4.6.0 + */ +function wp_ajax_search_install_plugins() { + check_ajax_referer( 'updates' ); + + $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; + if ( 'plugin-install-network' === $pagenow || 'plugin-install' === $pagenow ) { + set_current_screen( $pagenow ); + } + + /** @var WP_Plugin_Install_List_Table $wp_list_table */ + $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array( + 'screen' => get_current_screen(), + ) ); + + $status = array(); + + if ( ! $wp_list_table->ajax_user_can() ) { + $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); + wp_send_json_error( $status ); + } + + // Set the correct requester, so pagination works. + $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( + '_ajax_nonce' => null, + 'action' => null, + ) ), network_admin_url( 'plugin-install.php', 'relative' ) ); + + $wp_list_table->prepare_items(); + + ob_start(); + $wp_list_table->display(); + $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' ); + $status['items'] = ob_get_clean(); + + wp_send_json_success( $status ); +} + +/** + * Ajax handler for editing a theme or plugin file. + * + * @since 4.9.0 + * @see wp_edit_theme_plugin_file() + */ +function wp_ajax_edit_theme_plugin_file() { + $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file(). + if ( is_wp_error( $r ) ) { + wp_send_json_error( array_merge( + array( + 'code' => $r->get_error_code(), + 'message' => $r->get_error_message(), + ), + (array) $r->get_error_data() + ) ); + } else { + wp_send_json_success( array( + 'message' => __( 'File edited successfully.' ), + ) ); + } +} + +/** + * Ajax handler for exporting a user's personal data. + * + * @since 4.9.6 + */ +function wp_ajax_wp_privacy_export_personal_data() { + + if ( empty( $_POST['id'] ) ) { + wp_send_json_error( __( 'Missing request ID.' ) ); + } + $request_id = (int) $_POST['id']; + + if ( $request_id < 1 ) { + wp_send_json_error( __( 'Invalid request ID.' ) ); + } + + if ( ! current_user_can( 'export_others_personal_data' ) ) { + wp_send_json_error( __( 'Invalid request.' ) ); + } + + check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); + + // Get the request data. + $request = wp_get_user_request_data( $request_id ); + + if ( ! $request || 'export_personal_data' !== $request->action_name ) { + wp_send_json_error( __( 'Invalid request type.' ) ); + } + + $email_address = $request->email; + if ( ! is_email( $email_address ) ) { + wp_send_json_error( __( 'A valid email address must be given.' ) ); + } + + if ( ! isset( $_POST['exporter'] ) ) { + wp_send_json_error( __( 'Missing exporter index.' ) ); + } + $exporter_index = (int) $_POST['exporter']; + + if ( ! isset( $_POST['page'] ) ) { + wp_send_json_error( __( 'Missing page index.' ) ); + } + $page = (int) $_POST['page']; + + $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( 'true' === $_POST['sendAsEmail'] ) : false; + + /** + * Filters the array of exporter callbacks. + * + * @since 4.9.6 + * + * @param array $args { + * An array of callable exporters of personal data. Default empty array. + * + * @type array { + * Array of personal data exporters. + * + * @type string $callback Callable exporter function that accepts an + * email address and a page and returns an array + * of name => value pairs of personal data. + * @type string $exporter_friendly_name Translated user facing friendly name for the + * exporter. + * } + * } + */ + $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); + + if ( ! is_array( $exporters ) ) { + wp_send_json_error( __( 'An exporter has improperly used the registration filter.' ) ); + } + + // Do we have any registered exporters? + if ( 0 < count( $exporters ) ) { + if ( $exporter_index < 1 ) { + wp_send_json_error( __( 'Exporter index cannot be negative.' ) ); + } + + if ( $exporter_index > count( $exporters ) ) { + wp_send_json_error( __( 'Exporter index out of range.' ) ); + } + + if ( $page < 1 ) { + wp_send_json_error( __( 'Page index cannot be less than one.' ) ); + } + + $exporter_keys = array_keys( $exporters ); + $exporter_key = $exporter_keys[ $exporter_index - 1 ]; + $exporter = $exporters[ $exporter_key ]; + + if ( ! is_array( $exporter ) ) { + wp_send_json_error( + /* translators: %s: array index */ + sprintf( __( 'Expected an array describing the exporter at index %s.' ), $exporter_key ) + ); + } + if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { + wp_send_json_error( + /* translators: %s: array index */ + sprintf( __( 'Exporter array at index %s does not include a friendly name.' ), $exporter_key ) + ); + } + if ( ! array_key_exists( 'callback', $exporter ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter['exporter_friendly_name'] ) ) + ); + } + if ( ! is_callable( $exporter['callback'] ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter['exporter_friendly_name'] ) ) + ); + } + + $callback = $exporter['callback']; + $exporter_friendly_name = $exporter['exporter_friendly_name']; + + $response = call_user_func( $callback, $email_address, $page ); + if ( is_wp_error( $response ) ) { + wp_send_json_error( $response ); + } + + if ( ! is_array( $response ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Expected response as an array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) + ); + } + if ( ! array_key_exists( 'data', $response ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Expected data in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) + ); + } + if ( ! is_array( $response['data'] ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Expected data array in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) + ); + } + if ( ! array_key_exists( 'done', $response ) ) { + wp_send_json_error( + /* translators: %s: exporter friendly name */ + sprintf( __( 'Expected done (boolean) in response array from exporter: %s.' ), esc_html( $exporter_friendly_name ) ) + ); + } + } else { + // No exporters, so we're done. + $exporter_key = ''; + + $response = array( + 'data' => array(), + 'done' => true, + ); + } + + /** + * Filters a page of personal data exporter data. Used to build the export report. + * + * Allows the export response to be consumed by destinations in addition to Ajax. + * + * @since 4.9.6 + * + * @param array $response The personal data for the given exporter and page. + * @param int $exporter_index The index of the exporter that provided this data. + * @param string $email_address The email address associated with this personal data. + * @param int $page The page for this response. + * @param int $request_id The privacy request post ID associated with this request. + * @param bool $send_as_email Whether the final results of the export should be emailed to the user. + * @param string $exporter_key The key (slug) of the exporter that provided this data. + */ + $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ); + + if ( is_wp_error( $response ) ) { + wp_send_json_error( $response ); + } + + wp_send_json_success( $response ); +} + +/** + * Ajax handler for erasing personal data. + * + * @since 4.9.6 + */ +function wp_ajax_wp_privacy_erase_personal_data() { + + if ( empty( $_POST['id'] ) ) { + wp_send_json_error( __( 'Missing request ID.' ) ); + } + + $request_id = (int) $_POST['id']; + + if ( $request_id < 1 ) { + wp_send_json_error( __( 'Invalid request ID.' ) ); + } + + // Both capabilities are required to avoid confusion, see `_wp_personal_data_removal_page()`. + if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) { + wp_send_json_error( __( 'Invalid request.' ) ); + } + + check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); + + // Get the request data. + $request = wp_get_user_request_data( $request_id ); + + if ( ! $request || 'remove_personal_data' !== $request->action_name ) { + wp_send_json_error( __( 'Invalid request ID.' ) ); + } + + $email_address = $request->email; + + if ( ! is_email( $email_address ) ) { + wp_send_json_error( __( 'Invalid email address in request.' ) ); + } + + if ( ! isset( $_POST['eraser'] ) ) { + wp_send_json_error( __( 'Missing eraser index.' ) ); + } + + $eraser_index = (int) $_POST['eraser']; + + if ( ! isset( $_POST['page'] ) ) { + wp_send_json_error( __( 'Missing page index.' ) ); + } + + $page = (int) $_POST['page']; + + /** + * Filters the array of personal data eraser callbacks. + * + * @since 4.9.6 + * + * @param array $args { + * An array of callable erasers of personal data. Default empty array. + * + * @type array { + * Array of personal data exporters. + * + * @type string $callback Callable eraser that accepts an email address and + * a page and returns an array with boolean values for + * whether items were removed or retained and any messages + * from the eraser, as well as if additional pages are + * available. + * @type string $exporter_friendly_name Translated user facing friendly name for the eraser. + * } + * } + */ + $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); + + // Do we have any registered erasers? + if ( 0 < count( $erasers ) ) { + + if ( $eraser_index < 1 ) { + wp_send_json_error( __( 'Eraser index cannot be less than one.' ) ); + } + + if ( $eraser_index > count( $erasers ) ) { + wp_send_json_error( __( 'Eraser index is out of range.' ) ); + } + + if ( $page < 1 ) { + wp_send_json_error( __( 'Page index cannot be less than one.' ) ); + } + + $eraser_keys = array_keys( $erasers ); + $eraser_key = $eraser_keys[ $eraser_index - 1 ]; + $eraser = $erasers[ $eraser_key ]; + + if ( ! is_array( $eraser ) ) { + /* translators: %d: array index */ + wp_send_json_error( sprintf( __( 'Expected an array describing the eraser at index %d.' ), $eraser_index ) ); + } + + if ( ! array_key_exists( 'callback', $eraser ) ) { + /* translators: %d: array index */ + wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a callback.' ), $eraser_index ) ); + } + + if ( ! is_callable( $eraser['callback'] ) ) { + /* translators: %d: array index */ + wp_send_json_error( sprintf( __( 'Eraser callback at index %d is not a valid callback.' ), $eraser_index ) ); + } + + if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) { + /* translators: %d: array index */ + wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a friendly name.' ), $eraser_index ) ); + } + + $callback = $eraser['callback']; + $eraser_friendly_name = $eraser['eraser_friendly_name']; + + $response = call_user_func( $callback, $email_address, $page ); + + if ( is_wp_error( $response ) ) { + wp_send_json_error( $response ); + } + + if ( ! is_array( $response ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Did not receive array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + + if ( ! array_key_exists( 'items_removed', $response ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + + if ( ! array_key_exists( 'items_retained', $response ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + + if ( ! array_key_exists( 'messages', $response ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Expected messages key in response array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + + if ( ! is_array( $response['messages'] ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Expected messages key to reference an array in response array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + + if ( ! array_key_exists( 'done', $response ) ) { + wp_send_json_error( + sprintf( + /* translators: 1: eraser friendly name, 2: array index */ + __( 'Expected done flag in response array from %1$s eraser (index %2$d).' ), + esc_html( $eraser_friendly_name ), + $eraser_index + ) + ); + } + } else { + // No erasers, so we're done. + $eraser_key = ''; + + $response = array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + } + + /** + * Filters a page of personal data eraser data. + * + * Allows the erasure response to be consumed by destinations in addition to Ajax. + * + * @since 4.9.6 + * + * @param array $response The personal data for the given exporter and page. + * @param int $eraser_index The index of the eraser that provided this data. + * @param string $email_address The email address associated with this personal data. + * @param int $page The page for this response. + * @param int $request_id The privacy request post ID associated with this request. + * @param string $eraser_key The key (slug) of the eraser that provided this data. + */ + $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id, $eraser_key ); + + if ( is_wp_error( $response ) ) { + wp_send_json_error( $response ); + } + + wp_send_json_success( $response ); +} diff --git a/backend/wp-admin/includes/bookmark.php b/backend/wp-admin/includes/bookmark.php new file mode 100644 index 0000000..2608af7 --- /dev/null +++ b/backend/wp-admin/includes/bookmark.php @@ -0,0 +1,316 @@ +' . __( 'You need a higher level of permission.' ) . '' . + '

    ' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '

    ', + 403 + ); + } + + $_POST['link_url'] = esc_html( $_POST['link_url'] ); + $_POST['link_url'] = esc_url($_POST['link_url']); + $_POST['link_name'] = esc_html( $_POST['link_name'] ); + $_POST['link_image'] = esc_html( $_POST['link_image'] ); + $_POST['link_rss'] = esc_url($_POST['link_rss']); + if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) + $_POST['link_visible'] = 'Y'; + + if ( !empty( $link_id ) ) { + $_POST['link_id'] = $link_id; + return wp_update_link( $_POST ); + } else { + return wp_insert_link( $_POST ); + } +} + +/** + * Retrieves the default link for editing. + * + * @since 2.0.0 + * + * @return stdClass Default link object. + */ +function get_default_link_to_edit() { + $link = new stdClass; + if ( isset( $_GET['linkurl'] ) ) + $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) ); + else + $link->link_url = ''; + + if ( isset( $_GET['name'] ) ) + $link->link_name = esc_attr( wp_unslash( $_GET['name'] ) ); + else + $link->link_name = ''; + + $link->link_visible = 'Y'; + + return $link; +} + +/** + * Deletes a specified link from the database. + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $link_id ID of the link to delete + * @return true Always true. + */ +function wp_delete_link( $link_id ) { + global $wpdb; + /** + * Fires before a link is deleted. + * + * @since 2.0.0 + * + * @param int $link_id ID of the link to delete. + */ + do_action( 'delete_link', $link_id ); + + wp_delete_object_term_relationships( $link_id, 'link_category' ); + + $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); + + /** + * Fires after a link has been deleted. + * + * @since 2.2.0 + * + * @param int $link_id ID of the deleted link. + */ + do_action( 'deleted_link', $link_id ); + + clean_bookmark_cache( $link_id ); + + return true; +} + +/** + * Retrieves the link categories associated with the link specified. + * + * @since 2.1.0 + * + * @param int $link_id Link ID to look up + * @return array The requested link's categories + */ +function wp_get_link_cats( $link_id = 0 ) { + $cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') ); + return array_unique( $cats ); +} + +/** + * Retrieves link data based on its ID. + * + * @since 2.0.0 + * + * @param int|stdClass $link Link ID or object to retrieve. + * @return object Link object for editing. + */ +function get_link_to_edit( $link ) { + return get_bookmark( $link, OBJECT, 'edit' ); +} + +/** + * Inserts/updates links into/in the database. + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $linkdata Elements that make up the link to insert. + * @param bool $wp_error Optional. Whether to return a WP_Error object on failure. Default false. + * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. + */ +function wp_insert_link( $linkdata, $wp_error = false ) { + global $wpdb; + + $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); + + $args = wp_parse_args( $linkdata, $defaults ); + $r = wp_unslash( sanitize_bookmark( $args, 'db' ) ); + + $link_id = $r['link_id']; + $link_name = $r['link_name']; + $link_url = $r['link_url']; + + $update = false; + if ( ! empty( $link_id ) ) { + $update = true; + } + + if ( trim( $link_name ) == '' ) { + if ( trim( $link_url ) != '' ) { + $link_name = $link_url; + } else { + return 0; + } + } + + if ( trim( $link_url ) == '' ) { + return 0; + } + + $link_rating = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0; + $link_image = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : ''; + $link_target = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : ''; + $link_visible = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y'; + $link_owner = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id(); + $link_notes = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : ''; + $link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : ''; + $link_rss = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : ''; + $link_rel = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : ''; + $link_category = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array(); + + // Make sure we set a valid category. + if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) { + $link_category = array( get_option( 'default_link_category' ) ); + } + + if ( $update ) { + if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) { + if ( $wp_error ) { + return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error ); + } else { + return 0; + } + } + } else { + if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) { + if ( $wp_error ) { + return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error ); + } else { + return 0; + } + } + $link_id = (int) $wpdb->insert_id; + } + + wp_set_link_cats( $link_id, $link_category ); + + if ( $update ) { + /** + * Fires after a link was updated in the database. + * + * @since 2.0.0 + * + * @param int $link_id ID of the link that was updated. + */ + do_action( 'edit_link', $link_id ); + } else { + /** + * Fires after a link was added to the database. + * + * @since 2.0.0 + * + * @param int $link_id ID of the link that was added. + */ + do_action( 'add_link', $link_id ); + } + clean_bookmark_cache( $link_id ); + + return $link_id; +} + +/** + * Update link with the specified link categories. + * + * @since 2.1.0 + * + * @param int $link_id ID of the link to update. + * @param array $link_categories Array of link categories to add the link to. + */ +function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { + // If $link_categories isn't already an array, make it one: + if ( !is_array( $link_categories ) || 0 == count( $link_categories ) ) + $link_categories = array( get_option( 'default_link_category' ) ); + + $link_categories = array_map( 'intval', $link_categories ); + $link_categories = array_unique( $link_categories ); + + wp_set_object_terms( $link_id, $link_categories, 'link_category' ); + + clean_bookmark_cache( $link_id ); +} + +/** + * Updates a link in the database. + * + * @since 2.0.0 + * + * @param array $linkdata Link data to update. + * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success. + */ +function wp_update_link( $linkdata ) { + $link_id = (int) $linkdata['link_id']; + + $link = get_bookmark( $link_id, ARRAY_A ); + + // Escape data pulled from DB. + $link = wp_slash( $link ); + + // Passed link category list overwrites existing category list if not empty. + if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) + && 0 != count( $linkdata['link_category'] ) ) + $link_cats = $linkdata['link_category']; + else + $link_cats = $link['link_category']; + + // Merge old and new fields with new fields overwriting old ones. + $linkdata = array_merge( $link, $linkdata ); + $linkdata['link_category'] = $link_cats; + + return wp_insert_link( $linkdata ); +} + +/** + * Outputs the 'disabled' message for the WordPress Link Manager. + * + * @since 3.5.0 + * @access private + * + * @global string $pagenow + */ +function wp_link_manager_disabled_message() { + global $pagenow; + if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) + return; + + add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); + $really_can_manage_links = current_user_can( 'manage_links' ); + remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); + + if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) { + $link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' ); + wp_die( sprintf( __( 'If you are looking to use the link manager, please install the Link Manager plugin.' ), $link ) ); + } + + wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); +} diff --git a/backend/wp-admin/includes/class-automatic-upgrader-skin.php b/backend/wp-admin/includes/class-automatic-upgrader-skin.php new file mode 100644 index 0000000..dd37da9 --- /dev/null +++ b/backend/wp-admin/includes/class-automatic-upgrader-skin.php @@ -0,0 +1,113 @@ +options['context'] = $context; + } + // TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version + // This will output a credentials form in event of failure, We don't want that, so just hide with a buffer + ob_start(); + $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); + ob_end_clean(); + return $result; + } + + /** + * + * @return array + */ + public function get_upgrade_messages() { + return $this->messages; + } + + /** + * + * @param string|array|WP_Error $data + */ + public function feedback( $data ) { + if ( is_wp_error( $data ) ) { + $string = $data->get_error_message(); + } elseif ( is_array( $data ) ) { + return; + } else { + $string = $data; + } + if ( ! empty( $this->upgrader->strings[ $string ] ) ) + $string = $this->upgrader->strings[ $string ]; + + if ( strpos( $string, '%' ) !== false ) { + $args = func_get_args(); + $args = array_splice( $args, 1 ); + if ( ! empty( $args ) ) + $string = vsprintf( $string, $args ); + } + + $string = trim( $string ); + + // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output. + $string = wp_kses( $string, array( + 'a' => array( + 'href' => true + ), + 'br' => true, + 'em' => true, + 'strong' => true, + ) ); + + if ( empty( $string ) ) + return; + + $this->messages[] = $string; + } + + /** + */ + public function header() { + ob_start(); + } + + /** + */ + public function footer() { + $output = ob_get_clean(); + if ( ! empty( $output ) ) + $this->feedback( $output ); + } +} diff --git a/backend/wp-admin/includes/class-bulk-plugin-upgrader-skin.php b/backend/wp-admin/includes/class-bulk-plugin-upgrader-skin.php new file mode 100644 index 0000000..34dcbd4 --- /dev/null +++ b/backend/wp-admin/includes/class-bulk-plugin-upgrader-skin.php @@ -0,0 +1,67 @@ +upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)'); + } + + /** + * + * @param string $title + */ + public function before($title = '') { + parent::before($this->plugin_info['Title']); + } + + /** + * + * @param string $title + */ + public function after($title = '') { + parent::after($this->plugin_info['Title']); + $this->decrement_update_count( 'plugin' ); + } + + /** + */ + public function bulk_footer() { + parent::bulk_footer(); + $update_actions = array( + 'plugins_page' => '' . __( 'Return to Plugins page' ) . '', + 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . '' + ); + if ( ! current_user_can( 'activate_plugins' ) ) + unset( $update_actions['plugins_page'] ); + + /** + * Filters the list of action links available following bulk plugin updates. + * + * @since 3.0.0 + * + * @param array $update_actions Array of plugin action links. + * @param array $plugin_info Array of information for the last-updated plugin. + */ + $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); + + if ( ! empty($update_actions) ) + $this->feedback(implode(' | ', (array)$update_actions)); + } +} diff --git a/backend/wp-admin/includes/class-bulk-theme-upgrader-skin.php b/backend/wp-admin/includes/class-bulk-theme-upgrader-skin.php new file mode 100644 index 0000000..85ee6f2 --- /dev/null +++ b/backend/wp-admin/includes/class-bulk-theme-upgrader-skin.php @@ -0,0 +1,67 @@ +upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)'); + } + + /** + * + * @param string $title + */ + public function before($title = '') { + parent::before( $this->theme_info->display('Name') ); + } + + /** + * + * @param string $title + */ + public function after($title = '') { + parent::after( $this->theme_info->display('Name') ); + $this->decrement_update_count( 'theme' ); + } + + /** + */ + public function bulk_footer() { + parent::bulk_footer(); + $update_actions = array( + 'themes_page' => '' . __( 'Return to Themes page' ) . '', + 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . '' + ); + if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) + unset( $update_actions['themes_page'] ); + + /** + * Filters the list of action links available following bulk theme updates. + * + * @since 3.0.0 + * + * @param array $update_actions Array of theme action links. + * @param array $theme_info Array of information for the last-updated theme. + */ + $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); + + if ( ! empty($update_actions) ) + $this->feedback(implode(' | ', (array)$update_actions)); + } +} diff --git a/backend/wp-admin/includes/class-bulk-upgrader-skin.php b/backend/wp-admin/includes/class-bulk-upgrader-skin.php new file mode 100644 index 0000000..6541de9 --- /dev/null +++ b/backend/wp-admin/includes/class-bulk-upgrader-skin.php @@ -0,0 +1,175 @@ + '', 'nonce' => '' ); + $args = wp_parse_args($args, $defaults); + + parent::__construct($args); + } + + /** + */ + public function add_strings() { + $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.'); + /* translators: 1: Title of an update, 2: Error message */ + $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s'); + /* translators: 1: Title of an update */ + $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); + /* translators: 1: Title of an update */ + $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ); + $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.'); + } + + /** + * + * @param string $string + */ + public function feedback($string) { + if ( isset( $this->upgrader->strings[$string] ) ) + $string = $this->upgrader->strings[$string]; + + if ( strpos($string, '%') !== false ) { + $args = func_get_args(); + $args = array_splice($args, 1); + if ( $args ) { + $args = array_map( 'strip_tags', $args ); + $args = array_map( 'esc_html', $args ); + $string = vsprintf($string, $args); + } + } + if ( empty($string) ) + return; + if ( $this->in_loop ) + echo "$string
    \n"; + else + echo "

    $string

    \n"; + } + + /** + */ + public function header() { + // Nothing, This will be displayed within a iframe. + } + + /** + */ + public function footer() { + // Nothing, This will be displayed within a iframe. + } + + /** + * + * @param string|WP_Error $error + */ + public function error($error) { + if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) + $this->error = $this->upgrader->strings[$error]; + + if ( is_wp_error($error) ) { + $messages = array(); + foreach ( $error->get_error_messages() as $emessage ) { + if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) + $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); + else + $messages[] = $emessage; + } + $this->error = implode(', ', $messages); + } + echo ''; + } + + /** + */ + public function bulk_header() { + $this->feedback('skin_upgrade_start'); + } + + /** + */ + public function bulk_footer() { + $this->feedback('skin_upgrade_end'); + } + + /** + * + * @param string $title + */ + public function before($title = '') { + $this->in_loop = true; + printf( '

    ' . $this->upgrader->strings['skin_before_update_header'] . '

    ', $title, $this->upgrader->update_current, $this->upgrader->update_count ); + echo ''; + // This progress messages div gets moved via JavaScript when clicking on "Show details.". + echo '

    '; + $this->flush_output(); + } + + /** + * + * @param string $title + */ + public function after($title = '') { + echo '

    '; + if ( $this->error || ! $this->result ) { + if ( $this->error ) { + echo '

    ' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '' . $this->error . '' ) . '

    '; + } else { + echo '

    ' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '

    '; + } + + echo ''; + } + if ( $this->result && ! is_wp_error( $this->result ) ) { + if ( ! $this->error ) { + echo '
    ' . + '

    ' . sprintf( $this->upgrader->strings['skin_update_successful'], $title ) . + ' ' . + '

    '; + } + + echo ''; + } + + $this->reset(); + $this->flush_output(); + } + + /** + */ + public function reset() { + $this->in_loop = false; + $this->error = false; + } + + /** + */ + public function flush_output() { + wp_ob_end_flush_all(); + flush(); + } +} diff --git a/backend/wp-admin/includes/class-core-upgrader.php b/backend/wp-admin/includes/class-core-upgrader.php new file mode 100644 index 0000000..195e588 --- /dev/null +++ b/backend/wp-admin/includes/class-core-upgrader.php @@ -0,0 +1,362 @@ +strings['up_to_date'] = __('WordPress is at the latest version.'); + $this->strings['locked'] = __('Another update is currently in progress.'); + $this->strings['no_package'] = __('Update package not available.'); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s' ); + $this->strings['unpack_package'] = __('Unpacking the update…'); + $this->strings['copy_failed'] = __('Could not copy files.'); + $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' ); + $this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' ); + $this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' ); + } + + /** + * Upgrade WordPress core. + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * @global callable $_wp_filesystem_direct_method + * + * @param object $current Response object for whether WordPress is current. + * @param array $args { + * Optional. Arguments for upgrading WordPress core. Default empty array. + * + * @type bool $pre_check_md5 Whether to check the file checksums before + * attempting the upgrade. Default true. + * @type bool $attempt_rollback Whether to attempt to rollback the chances if + * there is a problem. Default false. + * @type bool $do_rollback Whether to perform this "upgrade" as a rollback. + * Default false. + * } + * @return null|false|WP_Error False or WP_Error on failure, null on success. + */ + public function upgrade( $current, $args = array() ) { + global $wp_filesystem; + + include( ABSPATH . WPINC . '/version.php' ); // $wp_version; + + $start_time = time(); + + $defaults = array( + 'pre_check_md5' => true, + 'attempt_rollback' => false, + 'do_rollback' => false, + 'allow_relaxed_file_ownership' => false, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->upgrade_strings(); + + // Is an update available? + if ( !isset( $current->response ) || $current->response == 'latest' ) + return new WP_Error('up_to_date', $this->strings['up_to_date']); + + $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] ); + if ( ! $res || is_wp_error( $res ) ) { + return $res; + } + + $wp_dir = trailingslashit($wp_filesystem->abspath()); + + $partial = true; + if ( $parsed_args['do_rollback'] ) + $partial = false; + elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) + $partial = false; + + /* + * If partial update is returned from the API, use that, unless we're doing + * a reinstallation. If we cross the new_bundled version number, then use + * the new_bundled zip. Don't though if the constant is set to skip bundled items. + * If the API returns a no_content zip, go with it. Finally, default to the full zip. + */ + if ( $parsed_args['do_rollback'] && $current->packages->rollback ) + $to_download = 'rollback'; + elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) + $to_download = 'partial'; + elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' ) + && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) + $to_download = 'new_bundled'; + elseif ( $current->packages->no_content ) + $to_download = 'no_content'; + else + $to_download = 'full'; + + // Lock to prevent multiple Core Updates occurring + $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS ); + if ( ! $lock ) { + return new WP_Error( 'locked', $this->strings['locked'] ); + } + + $download = $this->download_package( $current->packages->$to_download ); + if ( is_wp_error( $download ) ) { + WP_Upgrader::release_lock( 'core_updater' ); + return $download; + } + + $working_dir = $this->unpack_package( $download ); + if ( is_wp_error( $working_dir ) ) { + WP_Upgrader::release_lock( 'core_updater' ); + return $working_dir; + } + + // Copy update-core.php from the new version into place. + if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { + $wp_filesystem->delete($working_dir, true); + WP_Upgrader::release_lock( 'core_updater' ); + return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' ); + } + $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); + + require_once( ABSPATH . 'wp-admin/includes/update-core.php' ); + + if ( ! function_exists( 'update_core' ) ) { + WP_Upgrader::release_lock( 'core_updater' ); + return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] ); + } + + $result = update_core( $working_dir, $wp_dir ); + + // In the event of an issue, we may be able to roll back. + if ( $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) { + $try_rollback = false; + if ( is_wp_error( $result ) ) { + $error_code = $result->get_error_code(); + /* + * Not all errors are equal. These codes are critical: copy_failed__copy_dir, + * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full. + * do_rollback allows for update_core() to trigger a rollback if needed. + */ + if ( false !== strpos( $error_code, 'do_rollback' ) ) + $try_rollback = true; + elseif ( false !== strpos( $error_code, '__copy_dir' ) ) + $try_rollback = true; + elseif ( 'disk_full' === $error_code ) + $try_rollback = true; + } + + if ( $try_rollback ) { + /** This filter is documented in wp-admin/includes/update-core.php */ + apply_filters( 'update_feedback', $result ); + + /** This filter is documented in wp-admin/includes/update-core.php */ + apply_filters( 'update_feedback', $this->strings['start_rollback'] ); + + $rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) ); + + $original_result = $result; + $result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], (object) array( 'update' => $original_result, 'rollback' => $rollback_result ) ); + } + } + + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ + do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ) ); + + // Clear the current updates + delete_site_transient( 'update_core' ); + + if ( ! $parsed_args['do_rollback'] ) { + $stats = array( + 'update_type' => $current->response, + 'success' => true, + 'fs_method' => $wp_filesystem->method, + 'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ), + 'fs_method_direct' => !empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '', + 'time_taken' => time() - $start_time, + 'reported' => $wp_version, + 'attempted' => $current->version, + ); + + if ( is_wp_error( $result ) ) { + $stats['success'] = false; + // Did a rollback occur? + if ( ! empty( $try_rollback ) ) { + $stats['error_code'] = $original_result->get_error_code(); + $stats['error_data'] = $original_result->get_error_data(); + // Was the rollback successful? If not, collect its error too. + $stats['rollback'] = ! is_wp_error( $rollback_result ); + if ( is_wp_error( $rollback_result ) ) { + $stats['rollback_code'] = $rollback_result->get_error_code(); + $stats['rollback_data'] = $rollback_result->get_error_data(); + } + } else { + $stats['error_code'] = $result->get_error_code(); + $stats['error_data'] = $result->get_error_data(); + } + } + + wp_version_check( $stats ); + } + + WP_Upgrader::release_lock( 'core_updater' ); + + return $result; + } + + /** + * Determines if this WordPress Core version should update to an offered version or not. + * + * @since 3.7.0 + * + * @static + * + * @param string $offered_ver The offered version, of the format x.y.z. + * @return bool True if we should update to the offered version, otherwise false. + */ + public static function should_update_to_version( $offered_ver ) { + include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z + + $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y + $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y + $current_is_development_version = (bool) strpos( $wp_version, '-' ); + + // Defaults: + $upgrade_dev = true; + $upgrade_minor = true; + $upgrade_major = false; + + // WP_AUTO_UPDATE_CORE = true (all), 'minor', false. + if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { + if ( false === WP_AUTO_UPDATE_CORE ) { + // Defaults to turned off, unless a filter allows it + $upgrade_dev = $upgrade_minor = $upgrade_major = false; + } elseif ( true === WP_AUTO_UPDATE_CORE ) { + // ALL updates for core + $upgrade_dev = $upgrade_minor = $upgrade_major = true; + } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { + // Only minor updates for core + $upgrade_dev = $upgrade_major = false; + $upgrade_minor = true; + } + } + + // 1: If we're already on that version, not much point in updating? + if ( $offered_ver == $wp_version ) + return false; + + // 2: If we're running a newer version, that's a nope + if ( version_compare( $wp_version, $offered_ver, '>' ) ) + return false; + + $failure_data = get_site_option( 'auto_core_update_failed' ); + if ( $failure_data ) { + // If this was a critical update failure, cannot update. + if ( ! empty( $failure_data['critical'] ) ) + return false; + + // Don't claim we can update on update-core.php if we have a non-critical failure logged. + if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) + return false; + + // Cannot update if we're retrying the same A to B update that caused a non-critical failure. + // Some non-critical failures do allow retries, like download_failed. + // 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2. + if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) + return false; + } + + // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2 + if ( $current_is_development_version ) { + + /** + * Filters whether to enable automatic core updates for development versions. + * + * @since 3.7.0 + * + * @param bool $upgrade_dev Whether to enable automatic updates for + * development versions. + */ + if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) + return false; + // Else fall through to minor + major branches below. + } + + // 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4) + if ( $current_branch == $new_branch ) { + + /** + * Filters whether to enable minor automatic core updates. + * + * @since 3.7.0 + * + * @param bool $upgrade_minor Whether to enable minor automatic core updates. + */ + return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); + } + + // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1) + if ( version_compare( $new_branch, $current_branch, '>' ) ) { + + /** + * Filters whether to enable major automatic core updates. + * + * @since 3.7.0 + * + * @param bool $upgrade_major Whether to enable major automatic core updates. + */ + return apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); + } + + // If we're not sure, we don't want it + return false; + } + + /** + * Compare the disk file checksums against the expected checksums. + * + * @since 3.7.0 + * + * @global string $wp_version + * @global string $wp_local_package + * + * @return bool True if the checksums match, otherwise false. + */ + public function check_files() { + global $wp_version, $wp_local_package; + + $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); + + if ( ! is_array( $checksums ) ) + return false; + + foreach ( $checksums as $file => $checksum ) { + // Skip files which get updated + if ( 'wp-content' == substr( $file, 0, 10 ) ) + continue; + if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) + return false; + } + + return true; + } +} diff --git a/backend/wp-admin/includes/class-file-upload-upgrader.php b/backend/wp-admin/includes/class-file-upload-upgrader.php new file mode 100644 index 0000000..a182b62 --- /dev/null +++ b/backend/wp-admin/includes/class-file-upload-upgrader.php @@ -0,0 +1,124 @@ + false, 'test_type' => false ); + $file = wp_handle_upload( $_FILES[$form], $overrides ); + + if ( isset( $file['error'] ) ) + wp_die( $file['error'] ); + + $this->filename = $_FILES[$form]['name']; + $this->package = $file['file']; + + // Construct the object array + $object = array( + 'post_title' => $this->filename, + 'post_content' => $file['url'], + 'post_mime_type' => $file['type'], + 'guid' => $file['url'], + 'context' => 'upgrader', + 'post_status' => 'private' + ); + + // Save the data. + $this->id = wp_insert_attachment( $object, $file['file'] ); + + // Schedule a cleanup for 2 hours from now in case of failed installation. + wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) ); + + } elseif ( is_numeric( $_GET[$urlholder] ) ) { + // Numeric Package = previously uploaded file, see above. + $this->id = (int) $_GET[$urlholder]; + $attachment = get_post( $this->id ); + if ( empty($attachment) ) + wp_die(__('Please select a file')); + + $this->filename = $attachment->post_title; + $this->package = get_attached_file( $attachment->ID ); + } else { + // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler. + if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) + wp_die( $uploads['error'] ); + + $this->filename = sanitize_file_name( $_GET[ $urlholder ] ); + $this->package = $uploads['basedir'] . '/' . $this->filename; + + if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) { + wp_die( __( 'Please select a file' ) ); + } + } + } + + /** + * Delete the attachment/uploaded file. + * + * @since 3.2.2 + * + * @return bool Whether the cleanup was successful. + */ + public function cleanup() { + if ( $this->id ) + wp_delete_attachment( $this->id ); + + elseif ( file_exists( $this->package ) ) + return @unlink( $this->package ); + + return true; + } +} diff --git a/backend/wp-admin/includes/class-ftp-pure.php b/backend/wp-admin/includes/class-ftp-pure.php new file mode 100644 index 0000000..38d348b --- /dev/null +++ b/backend/wp-admin/includes/class-ftp-pure.php @@ -0,0 +1,186 @@ + +// +// + + function _settimeout($sock) { + if(!@stream_set_timeout($sock, $this->_timeout)) { + $this->PushError('_settimeout','socket set send timeout'); + $this->_quit(); + return FALSE; + } + return TRUE; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); + if (!$sock) { + $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction, 'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@fgets($this->_ftp_control_sock, 512); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed'); + } else { + $this->_message.=$tmp; + if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false; + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@fputs($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed'); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout); + if(!$this->_ftp_data_sock) { + $this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")"); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_data_sock; + } else { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + while (!feof($this->_ftp_data_sock)) { + $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size); + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Only passive connections available!"); + return FALSE; + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return TRUE; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) { + $this->PushError("_data_write","Can't write to socket"); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @fclose($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit($force=FALSE) { + if($this->_connected or $force) { + @fclose($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} + +?> diff --git a/backend/wp-admin/includes/class-ftp-sockets.php b/backend/wp-admin/includes/class-ftp-sockets.php new file mode 100644 index 0000000..5ca4a2b --- /dev/null +++ b/backend/wp-admin/includes/class-ftp-sockets.php @@ -0,0 +1,246 @@ + +// +// + + function _settimeout($sock) { + if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) { + $this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + return true; + } + + function _connect($host, $port) { + $this->SendMSG("Creating socket"); + if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { + $this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock))); + return FALSE; + } + if(!$this->_settimeout($sock)) return FALSE; + $this->SendMSG("Connecting to \"".$host.":".$port."\""); + if (!($res = @socket_connect($sock, $host, $port))) { + $this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock))); + @socket_close($sock); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock))); + } else { + $this->_message.=$tmp; + $go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs); + } + } while($go); + if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF; + $this->_code=(int)$regs[1]; + return $result; + } + + function _exec($cmd, $fnction="_exec") { + if(!$this->_ready) { + $this->PushError($fnction,'Connect first'); + return FALSE; + } + if($this->LocalEcho) echo "PUT > ",$cmd,CRLF; + $status=@socket_write($this->_ftp_control_sock, $cmd.CRLF); + if($status===false) { + $this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream))); + return FALSE; + } + $this->_lastaction=time(); + if(!$this->_readmsg($fnction)) return FALSE; + return TRUE; + } + + function _data_prepare($mode=FTP_ASCII) { + if(!$this->_settype($mode)) return FALSE; + $this->SendMSG("Creating data socket"); + $this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if ($this->_ftp_data_sock < 0) { + $this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock))); + return FALSE; + } + if(!$this->_settimeout($this->_ftp_data_sock)) { + $this->_data_close(); + return FALSE; + } + if($this->_passive) { + if(!$this->_exec("PASV", "pasv")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ip_port = explode(",", preg_replace("/^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*$/s", "\\1", $this->_message)); + $this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3]; + $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]); + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + else $this->_ftp_temp_sock=$this->_ftp_data_sock; + } else { + if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) { + $this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_bind($this->_ftp_data_sock,$addr)){ + $this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_listen($this->_ftp_data_sock)) { + $this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) { + $this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock))); + $this->_data_close(); + return FALSE; + } + if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + } + return TRUE; + } + + function _data_read($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + } + + while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) { + if($block==="") break; + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block); + if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block)); + else $out.=$block; + } + return $out; + } + + function _data_write($mode=FTP_ASCII, $fp=NULL) { + $NewLine=$this->_eol_code[$this->OS_local]; + if(is_resource($fp)) $out=0; + else $out=""; + if(!$this->_passive) { + $this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport); + $this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock); + if($this->_ftp_temp_sock===FALSE) { + $this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return false; + } + } + if(is_resource($fp)) { + while(!feof($fp)) { + $block=fread($fp, $this->_ftp_buff_size); + if(!$this->_data_write_block($mode, $block)) return false; + } + } elseif(!$this->_data_write_block($mode, $fp)) return false; + return true; + } + + function _data_write_block($mode, $block) { + if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block); + do { + if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) { + $this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock))); + $this->_data_close(); + return FALSE; + } + $block=substr($block, $t); + } while(!empty($block)); + return true; + } + + function _data_close() { + @socket_close($this->_ftp_temp_sock); + @socket_close($this->_ftp_data_sock); + $this->SendMSG("Disconnected data from remote host"); + return TRUE; + } + + function _quit() { + if($this->_connected) { + @socket_close($this->_ftp_control_sock); + $this->_connected=false; + $this->SendMSG("Socket closed"); + } + } +} +?> diff --git a/backend/wp-admin/includes/class-ftp.php b/backend/wp-admin/includes/class-ftp.php new file mode 100644 index 0000000..35f670f --- /dev/null +++ b/backend/wp-admin/includes/class-ftp.php @@ -0,0 +1,912 @@ +LocalEcho=$le; + $this->Verbose=$verb; + $this->_lastaction=NULL; + $this->_error_array=array(); + $this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n"); + $this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY); + $this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS'); + $this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT"); + $this->_port_available=($port_mode==TRUE); + $this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support")); + $this->_connected=FALSE; + $this->_ready=FALSE; + $this->_can_restore=FALSE; + $this->_code=0; + $this->_message=""; + $this->_ftp_buff_size=4096; + $this->_curtype=NULL; + $this->SetUmask(0022); + $this->SetType(FTP_AUTOASCII); + $this->SetTimeout(30); + $this->Passive(!$this->_port_available); + $this->_login="anonymous"; + $this->_password="anon@ftp.com"; + $this->_features=array(); + $this->OS_local=FTP_OS_Unix; + $this->OS_remote=FTP_OS_Unix; + $this->features=array(); + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; + elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; + } + + function ftp_base($port_mode=FALSE) { + $this->__construct($port_mode); + } + +// +// +// + + function parselisting($line) { + $is_windows = ($this->OS_remote == FTP_OS_Windows); + if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/",$line,$lucifer)) { + $b = array(); + if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix + $b['isdir'] = ($lucifer[7]==""); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount=count($lucifer); + if ($lcount<8) return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === "d"; + $b['islink'] = $lucifer[0]{0} === "l"; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ($lcount==8) { + sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']); + sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']); + $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute'])); + $b['name'] = $lucifer[8]; + } + } + + return $b; + } + + function SendMSG($message = "", $crlf=true) { + if ($this->Verbose) { + echo $message.($crlf?CRLF:""); + flush(); + } + return TRUE; + } + + function SetType($mode=FTP_AUTOASCII) { + if(!in_array($mode, $this->AuthorizedTransferMode)) { + $this->SendMSG("Wrong type"); + return FALSE; + } + $this->_type=$mode; + $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); + return TRUE; + } + + function _settype($mode=FTP_ASCII) { + if($this->_ready) { + if($mode==FTP_BINARY) { + if($this->_curtype!=FTP_BINARY) { + if(!$this->_exec("TYPE I", "SetType")) return FALSE; + $this->_curtype=FTP_BINARY; + } + } elseif($this->_curtype!=FTP_ASCII) { + if(!$this->_exec("TYPE A", "SetType")) return FALSE; + $this->_curtype=FTP_ASCII; + } + } else return FALSE; + return TRUE; + } + + function Passive($pasv=NULL) { + if(is_null($pasv)) $this->_passive=!$this->_passive; + else $this->_passive=$pasv; + if(!$this->_port_available and !$this->_passive) { + $this->SendMSG("Only passive connections available!"); + $this->_passive=TRUE; + return FALSE; + } + $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); + return TRUE; + } + + function SetServer($host, $port=21, $reconnect=true) { + if(!is_long($port)) { + $this->verbose=true; + $this->SendMSG("Incorrect port syntax"); + return FALSE; + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip=$host; + if(!$dns) $dns=$host; + // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false + // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid + $ipaslong = ip2long($ip); + if ( ($ipaslong == false) || ($ipaslong === -1) ) { + $this->SendMSG("Wrong host name/address \"".$host."\""); + return FALSE; + } + $this->_host=$ip; + $this->_fullhost=$dns; + $this->_port=$port; + $this->_dataport=$port-1; + } + $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); + if($reconnect){ + if($this->_connected) { + $this->SendMSG("Reconnecting"); + if(!$this->quit(FTP_FORCE)) return FALSE; + if(!$this->connect()) return FALSE; + } + } + return TRUE; + } + + function SetUmask($umask=0022) { + $this->_umask=$umask; + umask($this->_umask); + $this->SendMSG("UMASK 0".decoct($this->_umask)); + return TRUE; + } + + function SetTimeout($timeout=30) { + $this->_timeout=$timeout; + $this->SendMSG("Timeout ".$this->_timeout); + if($this->_connected) + if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; + return TRUE; + } + + function connect($server=NULL) { + if(!empty($server)) { + if(!$this->SetServer($server)) return false; + } + if($this->_ready) return true; + $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); + if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { + $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); + return FALSE; + } + $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); + do { + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + $this->_lastaction=time(); + } while($this->_code<200); + $this->_ready=true; + $syst=$this->systype(); + if(!$syst) $this->SendMSG("Can't detect remote OS"); + else { + if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows; + elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac; + elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix; + else $this->OS_remote=FTP_OS_Mac; + $this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]); + } + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + return TRUE; + } + + function quit($force=false) { + if($this->_ready) { + if(!$this->_exec("QUIT") and !$force) return FALSE; + if(!$this->_checkCode() and !$force) return FALSE; + $this->_ready=false; + $this->SendMSG("Session finished"); + } + $this->_quit(); + return TRUE; + } + + function login($user=NULL, $pass=NULL) { + if(!is_null($user)) $this->_login=$user; + else $this->_login="anonymous"; + if(!is_null($pass)) $this->_password=$pass; + else $this->_password="anon@anon.com"; + if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code!=230) { + if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + $this->SendMSG("Authentication succeeded"); + if(empty($this->_features)) { + if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled"); + else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features))); + } + return TRUE; + } + + function pwd() { + if(!$this->_exec("PWD", "pwd")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message); + } + + function cdup() { + if(!$this->_exec("CDUP", "cdup")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return true; + } + + function chdir($pathname) { + if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rmdir($pathname) { + if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function mkdir($pathname) { + if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rename($from, $to) { + if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code==350) { + if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } else return FALSE; + return TRUE; + } + + function filesize($pathname) { + if(!isset($this->_features["SIZE"])) { + $this->PushError("filesize", "not supported by server"); + return FALSE; + } + if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); + } + + function abort() { + if(!$this->_exec("ABOR", "abort")) return FALSE; + if(!$this->_checkCode()) { + if($this->_code!=426) return FALSE; + if(!$this->_readmsg("abort")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + return true; + } + + function mdtm($pathname) { + if(!isset($this->_features["MDTM"])) { + $this->PushError("mdtm", "not supported by server"); + return FALSE; + } + if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message); + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); + return $timestamp; + } + + function systype() { + if(!$this->_exec("SYST", "systype")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $DATA = explode(" ", $this->_message); + return array($DATA[1], $DATA[3]); + } + + function delete($pathname) { + if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function site($command, $fnction="site") { + if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function chmod($pathname, $mode) { + if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE; + return TRUE; + } + + function restore($from) { + if(!isset($this->_features["REST"])) { + $this->PushError("restore", "not supported by server"); + return FALSE; + } + if($this->_curtype!=FTP_BINARY) { + $this->PushError("restore", "can't restore in ASCII mode"); + return FALSE; + } + if(!$this->_exec("REST ".$from, "resore")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function features() { + if(!$this->_exec("FEAT", "features")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); + $this->_features=array(); + foreach($f as $k=>$v) { + $v=explode(" ", trim($v)); + $this->_features[array_shift($v)]=$v; + } + return true; + } + + function rawlist($pathname="", $arg="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); + } + + function nlist($pathname="", $arg="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); + } + + function is_exists($pathname) { + return $this->file_exists($pathname); + } + + function file_exists($pathname) { + $exists=true; + if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE; + else { + if(!$this->_checkCode()) $exists=FALSE; + $this->abort(); + } + if($exists) $this->SendMSG("Remote file ".$pathname." exists"); + else $this->SendMSG("Remote file ".$pathname." does not exist"); + return $exists; + } + + function fget($fp, $remotefile,$rest=0) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function get($remotefile, $localfile=NULL, $rest=0) { + if(is_null($localfile)) $localfile=$remotefile; + if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); + $fp = @fopen($localfile, "w"); + if (!$fp) { + $this->PushError("get","can't open local file", "Cannot create \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function fput($remotefile, $fp) { + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function put($localfile, $remotefile=NULL, $rest=0) { + if(is_null($remotefile)) $remotefile=$localfile; + if (!file_exists($localfile)) { + $this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\""); + return FALSE; + } + $fp = @fopen($localfile, "r"); + + if (!$fp) { + $this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\""); + return FALSE; + } + if($this->_can_restore and $rest!=0) fseek($fp, $rest); + $pi=pathinfo($localfile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore and $rest!=0) $this->restore($rest); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + + function mput($local=".", $remote=NULL, $continious=false) { + $local=realpath($local); + if(!@file_exists($local)) { + $this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\""); + return FALSE; + } + if(!is_dir($local)) return $this->put($local, $remote); + if(empty($remote)) $remote="."; + elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE; + if($handle = opendir($local)) { + $list=array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") $list[]=$file; + } + closedir($handle); + } else { + $this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\""); + return FALSE; + } + if(empty($list)) return TRUE; + $ret=true; + foreach($list as $el) { + if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el); + else $t=$this->put($local."/".$el, $remote."/".$el); + if(!$t) { + $ret=FALSE; + if(!$continious) break; + } + } + return $ret; + + } + + function mget($remote, $local=".", $continious=false) { + $list=$this->rawlist($remote, "-lA"); + if($list===false) { + $this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return FALSE; + } + if(empty($list)) return true; + if(!@file_exists($local)) { + if(!@mkdir($local)) { + $this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\""); + return FALSE; + } + } + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + foreach($list as $el) { + if($el["type"]=="d") { + if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) { + $this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } else { + if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) { + $this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + @chmod($local."/".$el["name"], $el["perms"]); + $t=strtotime($el["date"]); + if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t); + } + return $ret; + } + + function mdel($remote, $continious=false) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + foreach($list as $k=>$v) { + $list[$k]=$this->parselisting($v); + if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]); + } + $ret=true; + + foreach($list as $el) { + if ( empty($el) ) + continue; + + if($el["type"]=="d") { + if(!$this->mdel($remote."/".$el["name"], $continious)) { + $ret=false; + if(!$continious) break; + } + } else { + if (!$this->delete($remote."/".$el["name"])) { + $this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\""); + $ret=false; + if(!$continious) break; + } + } + } + + if(!$this->rmdir($remote)) { + $this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\""); + $ret=false; + } + return $ret; + } + + function mmkdir($dir, $mode = 0777) { + if(empty($dir)) return FALSE; + if($this->is_exists($dir) or $dir == "/" ) return TRUE; + if(!$this->mmkdir(dirname($dir), $mode)) return false; + $r=$this->mkdir($dir, $mode); + $this->chmod($dir,$mode); + return $r; + } + + function glob($pattern, $handle=NULL) { + $path=$output=null; + if(PHP_OS=='WIN32') $slash='\\'; + else $slash='/'; + $lastpos=strrpos($pattern,$slash); + if(!($lastpos===false)) { + $path=substr($pattern,0,-$lastpos-1); + $pattern=substr($pattern,$lastpos); + } else $path=getcwd(); + if(is_array($handle) and !empty($handle)) { + while($dir=each($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + } else { + $handle=@opendir($path); + if($handle===false) return false; + while($dir=readdir($handle)) { + if($this->glob_pattern_match($pattern,$dir)) + $output[]=$dir; + } + closedir($handle); + } + if(is_array($output)) return $output; + return false; + } + + function glob_pattern_match($pattern,$string) { + $out=null; + $chunks=explode(';',$pattern); + foreach($chunks as $pattern) { + $escape=array('$','^','.','{','}','(',')','[',']','|'); + while(strpos($pattern,'**')!==false) + $pattern=str_replace('**','*',$pattern); + foreach($escape as $probe) + $pattern=str_replace($probe,"\\$probe",$pattern); + $pattern=str_replace('?*','*', + str_replace('*?','*', + str_replace('*',".*", + str_replace('?','.{1,1}',$pattern)))); + $out[]=$pattern; + } + if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string)); + else { + foreach($out as $tester) + if($this->my_regexp("^$tester$",$string)) return true; + } + return false; + } + + function glob_regexp($pattern,$probe) { + $sensitive=(PHP_OS!='WIN32'); + return ($sensitive? + preg_match( '/' . preg_quote( $pattern, '/' ) . '/', $probe ) : + preg_match( '/' . preg_quote( $pattern, '/' ) . '/i', $probe ) + ); + } + + function dirlist($remote) { + $list=$this->rawlist($remote, "-la"); + if($list===false) { + $this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents"); + return false; + } + + $dirlist = array(); + foreach($list as $k=>$v) { + $entry=$this->parselisting($v); + if ( empty($entry) ) + continue; + + if($entry["name"]=="." or $entry["name"]=="..") + continue; + + $dirlist[$entry['name']] = $entry; + } + + return $dirlist; + } +// +// +// + function _checkCode() { + return ($this->_code<400 and $this->_code>0); + } + + function _list($arg="", $cmd="LIST", $fnction="_list") { + if(!$this->_data_prepare()) return false; + if(!$this->_exec($cmd.$arg, $fnction)) { + $this->_data_close(); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=""; + if($this->_code<200) { + $out=$this->_data_read(); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($out === FALSE ) return FALSE; + $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); +// $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out)); + } + return $out; + } + +// +// +// +// Gnre une erreur pour traitement externe la classe + function PushError($fctname,$msg,$desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + $this->SendMSG($fctname.': '.$msg.$tmp); + return(array_push($this->_error_array,$error)); + } + +// Rcupre une erreur externe + function PopError(){ + if(count($this->_error_array)) return(array_pop($this->_error_array)); + else return(false); + } +} + +$mod_sockets = extension_loaded( 'sockets' ); +if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) { + $prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : ''; + @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); + $mod_sockets = extension_loaded( 'sockets' ); +} + +require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php"; + +if ( $mod_sockets ) { + class ftp extends ftp_sockets {} +} else { + class ftp extends ftp_pure {} +} diff --git a/backend/wp-admin/includes/class-language-pack-upgrader-skin.php b/backend/wp-admin/includes/class-language-pack-upgrader-skin.php new file mode 100644 index 0000000..9efc877 --- /dev/null +++ b/backend/wp-admin/includes/class-language-pack-upgrader-skin.php @@ -0,0 +1,84 @@ + '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false ); + $args = wp_parse_args( $args, $defaults ); + if ( $args['skip_header_footer'] ) { + $this->done_header = true; + $this->done_footer = true; + $this->display_footer_actions = false; + } + parent::__construct( $args ); + } + + /** + */ + public function before() { + $name = $this->upgrader->get_name_for_update( $this->language_update ); + + echo '
    '; + + printf( '

    ' . __( 'Updating translations for %1$s (%2$s)…' ) . '

    ', $name, $this->language_update->language ); + } + + /** + * + * @param string|WP_Error $error + */ + public function error( $error ) { + echo '
    '; + parent::error( $error ); + echo '
    '; + } + + /** + */ + public function after() { + echo '
    '; + } + + /** + */ + public function bulk_footer() { + $this->decrement_update_count( 'translation' ); + $update_actions = array(); + $update_actions['updates_page'] = '' . __( 'Return to WordPress Updates page' ) . ''; + + /** + * Filters the list of action links available following a translations update. + * + * @since 3.7.0 + * + * @param array $update_actions Array of translations update links. + */ + $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions ); + + if ( $update_actions && $this->display_footer_actions ) + $this->feedback( implode( ' | ', $update_actions ) ); + } +} diff --git a/backend/wp-admin/includes/class-language-pack-upgrader.php b/backend/wp-admin/includes/class-language-pack-upgrader.php new file mode 100644 index 0000000..404c4a2 --- /dev/null +++ b/backend/wp-admin/includes/class-language-pack-upgrader.php @@ -0,0 +1,370 @@ +is_vcs_checkout( WP_CONTENT_DIR ) ) { + return; + } + + foreach ( $language_updates as $key => $language_update ) { + $update = ! empty( $language_update->autoupdate ); + + /** + * Filters whether to asynchronously update translation for core, a plugin, or a theme. + * + * @since 4.0.0 + * + * @param bool $update Whether to update. + * @param object $language_update The update offer. + */ + $update = apply_filters( 'async_update_translation', $update, $language_update ); + + if ( ! $update ) { + unset( $language_updates[ $key ] ); + } + } + + if ( empty( $language_updates ) ) { + return; + } + + // Re-use the automatic upgrader skin if the parent upgrader is using it. + if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) { + $skin = $upgrader->skin; + } else { + $skin = new Language_Pack_Upgrader_Skin( array( + 'skip_header_footer' => true, + ) ); + } + + $lp_upgrader = new Language_Pack_Upgrader( $skin ); + $lp_upgrader->bulk_upgrade( $language_updates ); + } + + /** + * Initialize the upgrade strings. + * + * @since 3.7.0 + */ + public function upgrade_strings() { + $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' ); + $this->strings['up_to_date'] = __( 'The translations are up to date.' ); + $this->strings['no_package'] = __( 'Update package not available.' ); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '%s' ); + $this->strings['unpack_package'] = __( 'Unpacking the update…' ); + $this->strings['process_failed'] = __( 'Translation update failed.' ); + $this->strings['process_success'] = __( 'Translation updated successfully.' ); + } + + /** + * Upgrade a language pack. + * + * @since 3.7.0 + * + * @param string|false $update Optional. Whether an update offer is available. Default false. + * @param array $args Optional. Other optional arguments, see + * Language_Pack_Upgrader::bulk_upgrade(). Default empty array. + * @return array|bool|WP_Error The result of the upgrade, or a WP_Error object instead. + */ + public function upgrade( $update = false, $args = array() ) { + if ( $update ) { + $update = array( $update ); + } + + $results = $this->bulk_upgrade( $update, $args ); + + if ( ! is_array( $results ) ) { + return $results; + } + + return $results[0]; + } + + /** + * Bulk upgrade language packs. + * + * @since 3.7.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param array $language_updates Optional. Language pack updates. Default empty array. + * @param array $args { + * Optional. Other arguments for upgrading multiple language packs. Default empty array + * + * @type bool $clear_update_cache Whether to clear the update cache when done. + * Default true. + * } + * @return array|bool|WP_Error Will return an array of results, or true if there are no updates, + * false or WP_Error for initial errors. + */ + public function bulk_upgrade( $language_updates = array(), $args = array() ) { + global $wp_filesystem; + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->upgrade_strings(); + + if ( ! $language_updates ) + $language_updates = wp_get_translation_updates(); + + if ( empty( $language_updates ) ) { + $this->skin->header(); + $this->skin->set_result( true ); + $this->skin->feedback( 'up_to_date' ); + $this->skin->bulk_footer(); + $this->skin->footer(); + return true; + } + + if ( 'upgrader_process_complete' == current_filter() ) + $this->skin->feedback( 'starting_upgrade' ); + + // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230 + remove_all_filters( 'upgrader_pre_install' ); + remove_all_filters( 'upgrader_clear_destination' ); + remove_all_filters( 'upgrader_post_install' ); + remove_all_filters( 'upgrader_source_selection' ); + + add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 ); + + $this->skin->header(); + + // Connect to the Filesystem first. + $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) ); + if ( ! $res ) { + $this->skin->footer(); + return false; + } + + $results = array(); + + $this->update_count = count( $language_updates ); + $this->update_current = 0; + + /* + * The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists, + * as we then may need to create a /plugins or /themes directory inside of it. + */ + $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR ); + if ( ! $wp_filesystem->exists( $remote_destination ) ) + if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) + return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination ); + + $language_updates_results = array(); + + foreach ( $language_updates as $language_update ) { + + $this->skin->language_update = $language_update; + + $destination = WP_LANG_DIR; + if ( 'plugin' == $language_update->type ) + $destination .= '/plugins'; + elseif ( 'theme' == $language_update->type ) + $destination .= '/themes'; + + $this->update_current++; + + $options = array( + 'package' => $language_update->package, + 'destination' => $destination, + 'clear_destination' => false, + 'abort_if_destination_exists' => false, // We expect the destination to exist. + 'clear_working' => true, + 'is_multi' => true, + 'hook_extra' => array( + 'language_update_type' => $language_update->type, + 'language_update' => $language_update, + ) + ); + + $result = $this->run( $options ); + + $results[] = $this->result; + + // Prevent credentials auth screen from displaying multiple times. + if ( false === $result ) { + break; + } + + $language_updates_results[] = array( + 'language' => $language_update->language, + 'type' => $language_update->type, + 'slug' => isset( $language_update->slug ) ? $language_update->slug : 'default', + 'version' => $language_update->version, + ); + } + + // Remove upgrade hooks which are not required for translation updates. + remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); + remove_action( 'upgrader_process_complete', 'wp_version_check' ); + remove_action( 'upgrader_process_complete', 'wp_update_plugins' ); + remove_action( 'upgrader_process_complete', 'wp_update_themes' ); + + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ + do_action( 'upgrader_process_complete', $this, array( + 'action' => 'update', + 'type' => 'translation', + 'bulk' => true, + 'translations' => $language_updates_results + ) ); + + // Re-add upgrade hooks. + add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); + add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); + add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); + add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); + + $this->skin->bulk_footer(); + + $this->skin->footer(); + + // Clean up our hooks, in case something else does an upgrade on this connection. + remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); + + if ( $parsed_args['clear_update_cache'] ) { + wp_clean_update_cache(); + } + + return $results; + } + + /** + * Check the package source to make sure there are .mo and .po files. + * + * Hooked to the {@see 'upgrader_source_selection'} filter by + * Language_Pack_Upgrader::bulk_upgrade(). + * + * @since 3.7.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string|WP_Error $source + * @param string $remote_source + */ + public function check_package( $source, $remote_source ) { + global $wp_filesystem; + + if ( is_wp_error( $source ) ) + return $source; + + // Check that the folder contains a valid language. + $files = $wp_filesystem->dirlist( $remote_source ); + + // Check to see if a .po and .mo exist in the folder. + $po = $mo = false; + foreach ( (array) $files as $file => $filedata ) { + if ( '.po' == substr( $file, -3 ) ) + $po = true; + elseif ( '.mo' == substr( $file, -3 ) ) + $mo = true; + } + + if ( ! $mo || ! $po ) { + return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'], + /* translators: 1: .po 2: .mo */ + sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ), + '.po', + '.mo' + ) + ); + } + + return $source; + } + + /** + * Get the name of an item being updated. + * + * @since 3.7.0 + * + * @param object $update The data for an update. + * @return string The name of the item being updated. + */ + public function get_name_for_update( $update ) { + switch ( $update->type ) { + case 'core': + return 'WordPress'; // Not translated + + case 'theme': + $theme = wp_get_theme( $update->slug ); + if ( $theme->exists() ) + return $theme->Get( 'Name' ); + break; + case 'plugin': + $plugin_data = get_plugins( '/' . $update->slug ); + $plugin_data = reset( $plugin_data ); + if ( $plugin_data ) + return $plugin_data['Name']; + break; + } + return ''; + } + +} diff --git a/backend/wp-admin/includes/class-pclzip.php b/backend/wp-admin/includes/class-pclzip.php new file mode 100644 index 0000000..ae0af7a --- /dev/null +++ b/backend/wp-admin/includes/class-pclzip.php @@ -0,0 +1,5692 @@ +zipname = $p_zipname; + $this->zip_fd = 0; + $this->magic_quotes_status = -1; + + // ----- Return + return; + } + + public function PclZip($p_zipname) { + self::__construct($p_zipname); + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // create($p_filelist, $p_add_dir="", $p_remove_dir="") + // create($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two different synopsis. The first one is historical. + // This method creates a Zip Archive. The Zip file is created in the + // filesystem. The files and directories indicated in $p_filelist + // are added in the archive. See the parameters description for the + // supported format of $p_filelist. + // When a directory is in the list, the directory and its content is added + // in the archive. + // In this synopsis, the function takes an optional variable list of + // options. See bellow the supported options. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function create($p_filelist) + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove from the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional', + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', + PCLZIP_OPT_TEMP_FILE_ON => 'optional', + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Invalid number / type of arguments"); + return 0; + } + } + } + + // ----- Look for default option values + $this->privOptionDefaultThreshold($v_options); + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + if ($v_string != '') { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + else { + } + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ,PCLZIP_ATT_FILE_MTIME => 'optional' + ,PCLZIP_ATT_FILE_CONTENT => 'optional' + ,PCLZIP_ATT_FILE_COMMENT => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + return 0; + } + + // ----- Call the create fct + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + return 0; + } + + // ----- Return + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // add($p_filelist, $p_add_dir="", $p_remove_dir="") + // add($p_filelist, $p_option, $p_option_value, ...) + // Description : + // This method supports two synopsis. The first one is historical. + // This methods add the list of files in an existing archive. + // If a file with the same name already exists, it is added at the end of the + // archive, the first one is still present. + // If the archive does not exist, it is created. + // Parameters : + // $p_filelist : An array containing file or directory names, or + // a string containing one filename or one directory name, or + // a string containing a list of filenames and/or directory + // names separated by spaces. + // $p_add_dir : A path to add before the real path of the archived file, + // in order to have it memorized in the archive. + // $p_remove_dir : A path to remove from the real path of the file to archive, + // in order to have a shorter path memorized in the archive. + // When $p_add_dir and $p_remove_dir are set, $p_remove_dir + // is removed first, before $p_add_dir is added. + // Options : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_COMMENT : + // PCLZIP_OPT_ADD_COMMENT : + // PCLZIP_OPT_PREPEND_COMMENT : + // PCLZIP_CB_PRE_ADD : + // PCLZIP_CB_POST_ADD : + // Return Values : + // 0 on failure, + // The list of the added files, with a status of the add action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function add($p_filelist) + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Set default values + $v_options = array(); + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_ADD => 'optional', + PCLZIP_CB_POST_ADD => 'optional', + PCLZIP_OPT_NO_COMPRESSION => 'optional', + PCLZIP_OPT_COMMENT => 'optional', + PCLZIP_OPT_ADD_COMMENT => 'optional', + PCLZIP_OPT_PREPEND_COMMENT => 'optional', + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', + PCLZIP_OPT_TEMP_FILE_ON => 'optional', + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' + //, PCLZIP_OPT_CRYPT => 'optional' + )); + if ($v_result != 1) { + return 0; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + + // ----- Get the first argument + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + return 0; + } + } + } + + // ----- Look for default option values + $this->privOptionDefaultThreshold($v_options); + + // ----- Init + $v_string_list = array(); + $v_att_list = array(); + $v_filedescr_list = array(); + $p_result_list = array(); + + // ----- Look if the $p_filelist is really an array + if (is_array($p_filelist)) { + + // ----- Look if the first element is also an array + // This will mean that this is a file description entry + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { + $v_att_list = $p_filelist; + } + + // ----- The list is a list of string names + else { + $v_string_list = $p_filelist; + } + } + + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) { + // ----- Create a list from the string + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); + } + + // ----- Invalid variable type for $p_filelist + else { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); + return 0; + } + + // ----- Reformat the string list + if (sizeof($v_string_list) != 0) { + foreach ($v_string_list as $v_string) { + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; + } + } + + // ----- For each file in the list check the attributes + $v_supported_attributes + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' + ,PCLZIP_ATT_FILE_MTIME => 'optional' + ,PCLZIP_ATT_FILE_CONTENT => 'optional' + ,PCLZIP_ATT_FILE_COMMENT => 'optional' + ); + foreach ($v_att_list as $v_entry) { + $v_result = $this->privFileDescrParseAtt($v_entry, + $v_filedescr_list[], + $v_options, + $v_supported_attributes); + if ($v_result != 1) { + return 0; + } + } + + // ----- Expand the filelist (expand directories) + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); + if ($v_result != 1) { + return 0; + } + + // ----- Call the create fct + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); + if ($v_result != 1) { + return 0; + } + + // ----- Return + return $p_result_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : listContent() + // Description : + // This public method, gives the list of the files and directories, with their + // properties. + // The properties of each entries in the list are (used also in other functions) : + // filename : Name of the file. For a create or add action it is the filename + // given by the user. For an extract function it is the filename + // of the extracted file. + // stored_filename : Name of the file / directory stored in the archive. + // size : Size of the stored file. + // compressed_size : Size of the file's data compressed in the archive + // (without the headers overhead) + // mtime : Last known modification date of the file (UNIX timestamp) + // comment : Comment associated with the file + // folder : true | false + // index : index of the file in the archive + // status : status of the action (depending of the action) : + // Values are : + // ok : OK ! + // filtered : the file / dir is not extracted (filtered by user) + // already_a_directory : the file can not be extracted because a + // directory with the same name already exists + // write_protected : the file can not be extracted because a file + // with the same name already exists and is + // write protected + // newer_exist : the file was not extracted because a newer file exists + // path_creation_fail : the file is not extracted because the folder + // does not exist and can not be created + // write_error : the file was not extracted because there was a + // error while writing the file + // read_error : the file was not extracted because there was a error + // while reading the file + // invalid_header : the file was not extracted because of an archive + // format error (bad file header) + // Note that each time a method can continue operating when there + // is an action error on a file, the error is only logged in the file status. + // Return Values : + // 0 on an unrecoverable failure, + // The list of the files in the archive. + // -------------------------------------------------------------------------------- + function listContent() + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + return(0); + } + + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privList($p_list)) != 1) + { + unset($p_list); + return(0); + } + + // ----- Return + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // extract($p_path="./", $p_remove_path="") + // extract([$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method extract all the files / directories from the archive to the + // folder indicated in $p_path. + // If you want to ignore the 'root' part of path of the memorized files + // you can indicate this in the optional $p_remove_path parameter. + // By default, if a newer file with the same name already exists, the + // file is not extracted. + // + // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions + // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append + // at the end of the path value of PCLZIP_OPT_PATH. + // Parameters : + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 or a negative value on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function extract() + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', + PCLZIP_OPT_TEMP_FILE_ON => 'optional', + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' + )); + if ($v_result != 1) { + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + return 0; + } + } + } + + // ----- Look for default option values + $this->privOptionDefaultThreshold($v_options); + + // ----- Trace + + // ----- Call the extracting fct + $p_list = array(); + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, + $v_remove_all_path, $v_options); + if ($v_result < 1) { + unset($p_list); + return(0); + } + + // ----- Return + return $p_list; + } + // -------------------------------------------------------------------------------- + + + // -------------------------------------------------------------------------------- + // Function : + // extractByIndex($p_index, $p_path="./", $p_remove_path="") + // extractByIndex($p_index, [$p_option, $p_option_value, ...]) + // Description : + // This method supports two synopsis. The first one is historical. + // This method is doing a partial extract of the archive. + // The extracted files or folders are identified by their index in the + // archive (from 0 to n). + // Note that if the index identify a folder, only the folder entry is + // extracted, not all the files included in the archive. + // Parameters : + // $p_index : A single index (integer) or a string of indexes of files to + // extract. The form of the string is "0,4-6,8-12" with only numbers + // and '-' for range or ',' to separate ranges. No spaces or ';' + // are allowed. + // $p_path : Path where the files and directories are to be extracted + // $p_remove_path : First part ('root' part) of the memorized path + // (if any similar) to remove while extracting. + // Options : + // PCLZIP_OPT_PATH : + // PCLZIP_OPT_ADD_PATH : + // PCLZIP_OPT_REMOVE_PATH : + // PCLZIP_OPT_REMOVE_ALL_PATH : + // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and + // not as files. + // The resulting content is in a new field 'content' in the file + // structure. + // This option must be used alone (any other options are ignored). + // PCLZIP_CB_PRE_EXTRACT : + // PCLZIP_CB_POST_EXTRACT : + // Return Values : + // 0 on failure, + // The list of the extracted files, with a status of the action. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + //function extractByIndex($p_index, options...) + function extractByIndex($p_index) + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + return(0); + } + + // ----- Set default values + $v_options = array(); +// $v_path = "./"; + $v_path = ''; + $v_remove_path = ""; + $v_remove_all_path = false; + + // ----- Look for variable options arguments + $v_size = func_num_args(); + + // ----- Default values for option + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + + // ----- Look for arguments + if ($v_size > 1) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Remove form the options list the first argument + array_shift($v_arg_list); + $v_size--; + + // ----- Look for first arg + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_PATH => 'optional', + PCLZIP_OPT_REMOVE_PATH => 'optional', + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', + PCLZIP_OPT_ADD_PATH => 'optional', + PCLZIP_CB_PRE_EXTRACT => 'optional', + PCLZIP_CB_POST_EXTRACT => 'optional', + PCLZIP_OPT_SET_CHMOD => 'optional', + PCLZIP_OPT_REPLACE_NEWER => 'optional' + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', + PCLZIP_OPT_TEMP_FILE_ON => 'optional', + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' + )); + if ($v_result != 1) { + return 0; + } + + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_PATH])) { + $v_path = $v_options[PCLZIP_OPT_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; + } + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + // ----- Check for '/' in last path char + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { + $v_path .= '/'; + } + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; + } + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; + } + else { + } + } + + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + + // ----- Get the first argument + $v_path = $v_arg_list[0]; + + // ----- Look for the optional second argument + if ($v_size == 2) { + $v_remove_path = $v_arg_list[1]; + } + else if ($v_size > 2) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); + + // ----- Return + return 0; + } + } + } + + // ----- Trace + + // ----- Trick + // Here I want to reuse extractByRule(), so I need to parse the $p_index + // with privParseOptions() + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); + $v_options_trick = array(); + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, + array (PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + return 0; + } + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; + + // ----- Look for default option values + $this->privOptionDefaultThreshold($v_options); + + // ----- Call the extracting fct + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { + return(0); + } + + // ----- Return + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : + // delete([$p_option, $p_option_value, ...]) + // Description : + // This method removes files from the archive. + // If no parameters are given, then all the archive is emptied. + // Parameters : + // None or optional arguments. + // Options : + // PCLZIP_OPT_BY_INDEX : + // PCLZIP_OPT_BY_NAME : + // PCLZIP_OPT_BY_EREG : + // PCLZIP_OPT_BY_PREG : + // Return Values : + // 0 on failure, + // The list of the files which are still present in the archive. + // (see PclZip::listContent() for list entry format) + // -------------------------------------------------------------------------------- + function delete() + { + $v_result=1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + return(0); + } + + // ----- Set default values + $v_options = array(); + + // ----- Look for variable options arguments + $v_size = func_num_args(); + + // ----- Look for arguments + if ($v_size > 0) { + // ----- Get the arguments + $v_arg_list = func_get_args(); + + // ----- Parse the options + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, + array (PCLZIP_OPT_BY_NAME => 'optional', + PCLZIP_OPT_BY_EREG => 'optional', + PCLZIP_OPT_BY_PREG => 'optional', + PCLZIP_OPT_BY_INDEX => 'optional' )); + if ($v_result != 1) { + return 0; + } + } + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Call the delete fct + $v_list = array(); + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { + $this->privSwapBackMagicQuotes(); + unset($v_list); + return(0); + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : deleteByIndex() + // Description : + // ***** Deprecated ***** + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. + // -------------------------------------------------------------------------------- + function deleteByIndex($p_index) + { + + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); + + // ----- Return + return $p_list; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : properties() + // Description : + // This method gives the properties of the archive. + // The properties are : + // nb : Number of files in the archive + // comment : Comment associated with the archive file + // status : not_exist, ok + // Parameters : + // None + // Return Values : + // 0 on failure, + // An array with the archive properties. + // -------------------------------------------------------------------------------- + function properties() + { + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + $this->privSwapBackMagicQuotes(); + return(0); + } + + // ----- Default properties + $v_prop = array(); + $v_prop['comment'] = ''; + $v_prop['nb'] = 0; + $v_prop['status'] = 'not_exist'; + + // ----- Look if file exists + if (@is_file($this->zipname)) + { + // ----- Open the zip file + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + return 0; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + return 0; + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Set the user attributes + $v_prop['comment'] = $v_central_dir['comment']; + $v_prop['nb'] = $v_central_dir['entries']; + $v_prop['status'] = 'ok'; + } + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_prop; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : duplicate() + // Description : + // This method creates an archive by copying the content of an other one. If + // the archive already exist, it is replaced by the new one without any warning. + // Parameters : + // $p_archive : The filename of a valid archive, or + // a valid PclZip object. + // Return Values : + // 1 on success. + // 0 or a negative value on error (error code). + // -------------------------------------------------------------------------------- + function duplicate($p_archive) + { + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the $p_archive is a PclZip object + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) + { + + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive->zipname); + } + + // ----- Look if the $p_archive is a string (so a filename) + else if (is_string($p_archive)) + { + + // ----- Check that $p_archive is a valid zip file + // TBC : Should also check the archive format + if (!is_file($p_archive)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); + $v_result = PCLZIP_ERR_MISSING_FILE; + } + else { + // ----- Duplicate the archive + $v_result = $this->privDuplicate($p_archive); + } + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : merge() + // Description : + // This method merge the $p_archive_to_add archive at the end of the current + // one ($this). + // If the archive ($this) does not exist, the merge becomes a duplicate. + // If the $p_archive_to_add archive does not exist, the merge is a success. + // Parameters : + // $p_archive_to_add : It can be directly the filename of a valid zip archive, + // or a PclZip object archive. + // Return Values : + // 1 on success, + // 0 or negative values on error (see below). + // -------------------------------------------------------------------------------- + function merge($p_archive_to_add) + { + $v_result = 1; + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Check archive + if (!$this->privCheckFormat()) { + return(0); + } + + // ----- Look if the $p_archive_to_add is a PclZip object + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) + { + + // ----- Merge the archive + $v_result = $this->privMerge($p_archive_to_add); + } + + // ----- Look if the $p_archive_to_add is a string (so a filename) + else if (is_string($p_archive_to_add)) + { + + // ----- Create a temporary archive + $v_object_archive = new PclZip($p_archive_to_add); + + // ----- Merge the archive + $v_result = $this->privMerge($v_object_archive); + } + + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : errorCode() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorCode() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorCode()); + } + else { + return($this->error_code); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorName() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorName($p_with_code=false) + { + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' + ); + + if (isset($v_name[$this->error_code])) { + $v_value = $v_name[$this->error_code]; + } + else { + $v_value = 'NoName'; + } + + if ($p_with_code) { + return($v_value.' ('.$this->error_code.')'); + } + else { + return($v_value); + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : errorInfo() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function errorInfo($p_full=false) + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + return(PclErrorString()); + } + else { + if ($p_full) { + return($this->errorName(true)." : ".$this->error_string); + } + else { + return($this->error_string." [code ".$this->error_code."]"); + } + } + } + // -------------------------------------------------------------------------------- + + +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** +// ***** ***** +// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** +// -------------------------------------------------------------------------------- + + + + // -------------------------------------------------------------------------------- + // Function : privCheckFormat() + // Description : + // This method check that the archive exists and is a valid zip archive. + // Several level of check exists. (futur) + // Parameters : + // $p_level : Level of check. Default 0. + // 0 : Check the first bytes (magic codes) (default value)) + // 1 : 0 + Check the central directory (futur) + // 2 : 1 + Check each file header (futur) + // Return Values : + // true on success, + // false on error, the error code is set. + // -------------------------------------------------------------------------------- + function privCheckFormat($p_level=0) + { + $v_result = true; + + // ----- Reset the file system cache + clearstatcache(); + + // ----- Reset the error handler + $this->privErrorReset(); + + // ----- Look if the file exits + if (!is_file($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); + return(false); + } + + // ----- Check that the file is readeable + if (!is_readable($this->zipname)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); + return(false); + } + + // ----- Check the magic code + // TBC + + // ----- Check the central header + // TBC + + // ----- Check each file header + // TBC + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privParseOptions() + // Description : + // This internal methods reads the variable list of arguments ($p_options_list, + // $p_size) and generate an array with the options and values ($v_result_list). + // $v_requested_options contains the options that can be present and those that + // must be present. + // $v_requested_options is an array, with the option value as key, and 'optional', + // or 'mandatory' as value. + // Parameters : + // See above. + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) + { + $v_result=1; + + // ----- Read the options + $i=0; + while ($i<$p_size) { + + // ----- Check if the option is supported + if (!isset($v_requested_options[$p_options_list[$i]])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Look for next option + switch ($p_options_list[$i]) { + // ----- Look for options that request a path value + case PCLZIP_OPT_PATH : + case PCLZIP_OPT_REMOVE_PATH : + case PCLZIP_OPT_ADD_PATH : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); + $i++; + break; + + case PCLZIP_OPT_TEMP_FILE_THRESHOLD : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + return PclZip::errorCode(); + } + + // ----- Check for incompatible options + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); + return PclZip::errorCode(); + } + + // ----- Check the value + $v_value = $p_options_list[$i+1]; + if ((!is_integer($v_value)) || ($v_value<0)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + return PclZip::errorCode(); + } + + // ----- Get the value (and convert it in bytes) + $v_result_list[$p_options_list[$i]] = $v_value*1048576; + $i++; + break; + + case PCLZIP_OPT_TEMP_FILE_ON : + // ----- Check for incompatible options + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); + return PclZip::errorCode(); + } + + $v_result_list[$p_options_list[$i]] = true; + break; + + case PCLZIP_OPT_TEMP_FILE_OFF : + // ----- Check for incompatible options + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); + return PclZip::errorCode(); + } + // ----- Check for incompatible options + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); + return PclZip::errorCode(); + } + + $v_result_list[$p_options_list[$i]] = true; + break; + + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + if ( is_string($p_options_list[$i+1]) + && ($p_options_list[$i+1] != '')) { + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); + $i++; + } + else { + } + break; + + // ----- Look for options that request an array of string for value + case PCLZIP_OPT_BY_NAME : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + $i++; + break; + + // ----- Look for options that request an EREG or PREG expression + case PCLZIP_OPT_BY_EREG : + // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG + // to PCLZIP_OPT_BY_PREG + $p_options_list[$i] = PCLZIP_OPT_BY_PREG; + case PCLZIP_OPT_BY_PREG : + //case PCLZIP_OPT_CRYPT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + $i++; + break; + + // ----- Look for options that takes a string + case PCLZIP_OPT_COMMENT : + case PCLZIP_OPT_ADD_COMMENT : + case PCLZIP_OPT_PREPEND_COMMENT : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, + "Missing parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + if (is_string($p_options_list[$i+1])) { + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, + "Wrong parameter value for option '" + .PclZipUtilOptionText($p_options_list[$i]) + ."'"); + + // ----- Return + return PclZip::errorCode(); + } + $i++; + break; + + // ----- Look for options that request an array of index + case PCLZIP_OPT_BY_INDEX : + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + $v_work_list = array(); + if (is_string($p_options_list[$i+1])) { + + // ----- Remove spaces + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); + + // ----- Parse items + $v_work_list = explode(",", $p_options_list[$i+1]); + } + else if (is_integer($p_options_list[$i+1])) { + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; + } + else if (is_array($p_options_list[$i+1])) { + $v_work_list = $p_options_list[$i+1]; + } + else { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Reduce the index list + // each index item in the list must be a couple with a start and + // an end value : [0,3], [5-5], [8-10], ... + // ----- Check the format of each item + $v_sort_flag=false; + $v_sort_value=0; + for ($j=0; $j= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + $i++; + break; + + // ----- Look for options that request a call-back + case PCLZIP_CB_PRE_EXTRACT : + case PCLZIP_CB_POST_EXTRACT : + case PCLZIP_CB_PRE_ADD : + case PCLZIP_CB_POST_ADD : + /* for futur use + case PCLZIP_CB_PRE_DELETE : + case PCLZIP_CB_POST_DELETE : + case PCLZIP_CB_PRE_LIST : + case PCLZIP_CB_POST_LIST : + */ + // ----- Check the number of parameters + if (($i+1) >= $p_size) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Get the value + $v_function_name = $p_options_list[$i+1]; + + // ----- Check that the value is a valid existing function + if (!function_exists($v_function_name)) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Set the attribute + $v_result_list[$p_options_list[$i]] = $v_function_name; + $i++; + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '" + .$p_options_list[$i]."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Next options + $i++; + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + // ----- Look if present + if (!isset($v_result_list[$key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + + // ----- Return + return PclZip::errorCode(); + } + } + } + } + + // ----- Look for default values + if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { + + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privOptionDefaultThreshold() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privOptionDefaultThreshold(&$p_options) + { + $v_result=1; + + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) + || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { + return $v_result; + } + + // ----- Get 'memory_limit' configuration value + $v_memory_limit = ini_get('memory_limit'); + $v_memory_limit = trim($v_memory_limit); + $v_memory_limit_int = (int) $v_memory_limit; + $last = strtolower(substr($v_memory_limit, -1)); + + if($last == 'g') + //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; + $v_memory_limit_int = $v_memory_limit_int*1073741824; + if($last == 'm') + //$v_memory_limit_int = $v_memory_limit_int*1024*1024; + $v_memory_limit_int = $v_memory_limit_int*1048576; + if($last == 'k') + $v_memory_limit_int = $v_memory_limit_int*1024; + + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); + + + // ----- Sanity check : No threshold if value lower than 1M + if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { + unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrParseAtt() + // Description : + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) + { + $v_result=1; + + // ----- For each file in the list check the attributes + foreach ($p_file_list as $v_key => $v_value) { + + // ----- Check if the option is supported + if (!isset($v_requested_options[$v_key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Look for attribute + switch ($v_key) { + case PCLZIP_ATT_FILE_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); + + if ($p_filedescr['filename'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + break; + + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); + + if ($p_filedescr['new_short_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + break; + + case PCLZIP_ATT_FILE_NEW_FULL_NAME : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); + + if ($p_filedescr['new_full_name'] == '') { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + break; + + // ----- Look for options that takes a string + case PCLZIP_ATT_FILE_COMMENT : + if (!is_string($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + $p_filedescr['comment'] = $v_value; + break; + + case PCLZIP_ATT_FILE_MTIME : + if (!is_integer($v_value)) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); + return PclZip::errorCode(); + } + + $p_filedescr['mtime'] = $v_value; + break; + + case PCLZIP_ATT_FILE_CONTENT : + $p_filedescr['content'] = $v_value; + break; + + default : + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, + "Unknown parameter '".$v_key."'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Look for mandatory options + if ($v_requested_options !== false) { + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { + // ----- Look for mandatory option + if ($v_requested_options[$key] == 'mandatory') { + // ----- Look if present + if (!isset($p_file_list[$key])) { + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + return PclZip::errorCode(); + } + } + } + } + + // end foreach + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privFileDescrExpand() + // Description : + // This method look for each item of the list to see if its a file, a folder + // or a string to be added as file. For any other type of files (link, other) + // just ignore the item. + // Then prepare the information that will be stored for that file. + // When its a folder, expand the folder with all the files that are in that + // folder (recursively). + // Parameters : + // Return Values : + // 1 on success. + // 0 on failure. + // -------------------------------------------------------------------------------- + function privFileDescrExpand(&$p_filedescr_list, &$p_options) + { + $v_result=1; + + // ----- Create a result list + $v_result_list = array(); + + // ----- Look each entry + for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options); + + // ----- Add the descriptor in result list + $v_result_list[sizeof($v_result_list)] = $v_descr; + + // ----- Look for folder + if ($v_descr['type'] == 'folder') { + // ----- List of items in folder + $v_dirlist_descr = array(); + $v_dirlist_nb = 0; + if ($v_folder_handler = @opendir($v_descr['filename'])) { + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { + + // ----- Skip '.' and '..' + if (($v_item_handler == '.') || ($v_item_handler == '..')) { + continue; + } + + // ----- Compose the full filename + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; + + // ----- Look for different stored filename + // Because the name of the folder was changed, the name of the + // files/sub-folders also change + if (($v_descr['stored_filename'] != $v_descr['filename']) + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { + if ($v_descr['stored_filename'] != '') { + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; + } + else { + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; + } + } + + $v_dirlist_nb++; + } + + @closedir($v_folder_handler); + } + else { + // TBC : unable to open folder in read mode + } + + // ----- Expand each element of the list + if ($v_dirlist_nb != 0) { + // ----- Expand + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { + return $v_result; + } + + // ----- Concat the resulting list + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); + } + else { + } + + // ----- Free local array + unset($v_dirlist_descr); + } + } + + // ----- Get the result list + $p_filedescr_list = $v_result_list; + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCreate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCreate($p_filedescr_list, &$p_result_list, &$p_options) + { + $v_result=1; + $v_list_detail = array(); + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the file in write mode + if (($v_result = $this->privOpenFd('wb')) != 1) + { + // ----- Return + return $v_result; + } + + // ----- Add the list of files + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); + + // ----- Close + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAdd() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAdd($p_filedescr_list, &$p_result_list, &$p_options) + { + $v_result=1; + $v_list_detail = array(); + + // ----- Look if the archive exists or is empty + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) + { + + // ----- Do a create + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); + + // ----- Return + return $v_result; + } + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result; + } + + // ----- Go to beginning of File + @rewind($this->zip_fd); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Create the Central Dir files header + for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = $v_central_dir['comment']; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; + } + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privOpenFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privOpenFd($p_mode) + { + $v_result=1; + + // ----- Look if already open + if ($this->zip_fd != 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Open the zip file + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCloseFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privCloseFd() + { + $v_result=1; + + if ($this->zip_fd != 0) + @fclose($this->zip_fd); + $this->zip_fd = 0; + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddList() + // Description : + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is + // different from the real path of the file. This is usefull if you want to have PclTar + // running in any directory, and memorize relative path from an other directory. + // Parameters : + // $p_list : An array containing the file or directory names to add in the tar + // $p_result_list : list of added files with their properties (specially the status field) + // $p_add_dir : Path to add in the filename path archived + // $p_remove_dir : Path to remove in the filename path archived + // Return Values : + // -------------------------------------------------------------------------------- +// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + function privAddList($p_filedescr_list, &$p_result_list, &$p_options) + { + $v_result=1; + + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) + { + // ----- Return + return $v_result; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + + // ----- Create the Central Dir files header + for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + // ----- Return + return $v_result; + } + $v_count++; + } + + // ----- Transform the header to a 'usable' info + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($this->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) + { + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + return $v_result; + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFileList() + // Description : + // Parameters : + // $p_filedescr_list : An array containing the file description + // or directory names to add in the zip + // $p_result_list : list of added files with their properties (specially the status field) + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) + { + $v_result=1; + $v_header = array(); + + // ----- Recuperate the current number of elt in list + $v_nb = sizeof($p_result_list); + + // ----- Loop on the files + for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header, + $p_options); + if ($v_result != 1) { + return $v_result; + } + + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFile($p_filedescr, &$p_header, &$p_options) + { + $v_result=1; + + // ----- Working variable + $p_filename = $p_filedescr['filename']; + + // TBC : Already done in the fileAtt check ... ? + if ($p_filename == "") { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Look for a stored different filename + /* TBC : Removed + if (isset($p_filedescr['stored_filename'])) { + $v_stored_filename = $p_filedescr['stored_filename']; + } + else { + $v_stored_filename = $p_filedescr['stored_filename']; + } + */ + + // ----- Set the file properties + clearstatcache(); + $p_header['version'] = 20; + $p_header['version_extracted'] = 10; + $p_header['flag'] = 0; + $p_header['compression'] = 0; + $p_header['crc'] = 0; + $p_header['compressed_size'] = 0; + $p_header['filename_len'] = strlen($p_filename); + $p_header['extra_len'] = 0; + $p_header['disk'] = 0; + $p_header['internal'] = 0; + $p_header['offset'] = 0; + $p_header['filename'] = $p_filename; +// TBC : Removed $p_header['stored_filename'] = $v_stored_filename; + $p_header['stored_filename'] = $p_filedescr['stored_filename']; + $p_header['extra'] = ''; + $p_header['status'] = 'ok'; + $p_header['index'] = -1; + + // ----- Look for regular file + if ($p_filedescr['type']=='file') { + $p_header['external'] = 0x00000000; + $p_header['size'] = filesize($p_filename); + } + + // ----- Look for regular folder + else if ($p_filedescr['type']=='folder') { + $p_header['external'] = 0x00000010; + $p_header['mtime'] = filemtime($p_filename); + $p_header['size'] = filesize($p_filename); + } + + // ----- Look for virtual file + else if ($p_filedescr['type'] == 'virtual_file') { + $p_header['external'] = 0x00000000; + $p_header['size'] = strlen($p_filedescr['content']); + } + + + // ----- Look for filetime + if (isset($p_filedescr['mtime'])) { + $p_header['mtime'] = $p_filedescr['mtime']; + } + else if ($p_filedescr['type'] == 'virtual_file') { + $p_header['mtime'] = time(); + } + else { + $p_header['mtime'] = filemtime($p_filename); + } + + // ------ Look for file comment + if (isset($p_filedescr['comment'])) { + $p_header['comment_len'] = strlen($p_filedescr['comment']); + $p_header['comment'] = $p_filedescr['comment']; + } + else { + $p_header['comment_len'] = 0; + $p_header['comment'] = ''; + } + + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); + if ($v_result == 0) { + // ----- Change the file status + $p_header['status'] = "skipped"; + $v_result = 1; + } + + // ----- Update the informations + // Only some fields can be modified + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); + } + } + + // ----- Look for empty stored filename + if ($p_header['stored_filename'] == "") { + $p_header['status'] = "filtered"; + } + + // ----- Check the path length + if (strlen($p_header['stored_filename']) > 0xFF) { + $p_header['status'] = 'filename_too_long'; + } + + // ----- Look if no error, or file not skipped + if ($p_header['status'] == 'ok') { + + // ----- Look for a file + if ($p_filedescr['type'] == 'file') { + // ----- Look for using temporary file to zip + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { + $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); + if ($v_result < PCLZIP_ERR_NO_ERROR) { + return $v_result; + } + } + + // ----- Use "in memory" zip algo + else { + + // ----- Open the source file + if (($v_file = @fopen($p_filename, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); + return PclZip::errorCode(); + } + + // ----- Read the file content + $v_content = @fread($v_file, $p_header['size']); + + // ----- Close the file + @fclose($v_file); + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content); + + // ----- Look for no compression + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + // ----- Set header parameters + $p_header['compressed_size'] = $p_header['size']; + $p_header['compression'] = 0; + } + + // ----- Look for normal compression + else { + // ----- Compress the content + $v_content = @gzdeflate($v_content); + + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content); + $p_header['compression'] = 8; + } + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + return $v_result; + } + + // ----- Write the compressed (or not) content + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); + + } + + } + + // ----- Look for a virtual file (a file from string) + else if ($p_filedescr['type'] == 'virtual_file') { + + $v_content = $p_filedescr['content']; + + // ----- Calculate the CRC + $p_header['crc'] = @crc32($v_content); + + // ----- Look for no compression + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + // ----- Set header parameters + $p_header['compressed_size'] = $p_header['size']; + $p_header['compression'] = 0; + } + + // ----- Look for normal compression + else { + // ----- Compress the content + $v_content = @gzdeflate($v_content); + + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content); + $p_header['compression'] = 8; + } + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + return $v_result; + } + + // ----- Write the compressed (or not) content + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); + } + + // ----- Look for a directory + else if ($p_filedescr['type'] == 'folder') { + // ----- Look for directory last '/' + if (@substr($p_header['stored_filename'], -1) != '/') { + $p_header['stored_filename'] .= '/'; + } + + // ----- Set the file properties + $p_header['size'] = 0; + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked + $p_header['external'] = 0x00000010; // Value for a folder : to be checked + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) + { + return $v_result; + } + } + } + + // ----- Look for post-add callback + if (isset($p_options[PCLZIP_CB_POST_ADD])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_header, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); + if ($v_result == 0) { + // ----- Ignored + $v_result = 1; + } + + // ----- Update the informations + // Nothing can be modified + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privAddFileUsingTempFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) + { + $v_result=PCLZIP_ERR_NO_ERROR; + + // ----- Working variable + $p_filename = $p_filedescr['filename']; + + + // ----- Open the source file + if (($v_file = @fopen($p_filename, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); + return PclZip::errorCode(); + } + + // ----- Creates a compressed temporary file + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; + if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { + fclose($v_file); + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); + return PclZip::errorCode(); + } + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = filesize($p_filename); + while ($v_size != 0) { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($v_file, $v_read_size); + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); + @gzputs($v_file_compressed, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close the file + @fclose($v_file); + @gzclose($v_file_compressed); + + // ----- Check the minimum file size + if (filesize($v_gzip_temp_name) < 18) { + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); + return PclZip::errorCode(); + } + + // ----- Extract the compressed attributes + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); + return PclZip::errorCode(); + } + + // ----- Read the gzip file header + $v_binary_data = @fread($v_file_compressed, 10); + $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); + + // ----- Check some parameters + $v_data_header['os'] = bin2hex($v_data_header['os']); + + // ----- Read the gzip file footer + @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); + $v_binary_data = @fread($v_file_compressed, 8); + $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); + + // ----- Set the attributes + $p_header['compression'] = ord($v_data_header['cm']); + //$p_header['mtime'] = $v_data_header['mtime']; + $p_header['crc'] = $v_data_footer['crc']; + $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; + + // ----- Close the file + @fclose($v_file_compressed); + + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + return $v_result; + } + + // ----- Add the compressed data + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) + { + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); + return PclZip::errorCode(); + } + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + fseek($v_file_compressed, 10); + $v_size = $p_header['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($v_file_compressed, $v_read_size); + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close the file + @fclose($v_file_compressed); + + // ----- Unlink the temporary file + @unlink($v_gzip_temp_name); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCalculateStoredFilename() + // Description : + // Based on file descriptor properties and global options, this method + // calculate the filename that will be stored in the archive. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCalculateStoredFilename(&$p_filedescr, &$p_options) + { + $v_result=1; + + // ----- Working variables + $p_filename = $p_filedescr['filename']; + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; + } + else { + $p_add_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; + } + else { + $p_remove_dir = ''; + } + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; + } + else { + $p_remove_all_dir = 0; + } + + + // ----- Look for full name change + if (isset($p_filedescr['new_full_name'])) { + // ----- Remove drive letter if any + $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); + } + + // ----- Look for path and/or short name change + else { + + // ----- Look for short name change + // Its when we cahnge just the filename but not the path + if (isset($p_filedescr['new_short_name'])) { + $v_path_info = pathinfo($p_filename); + $v_dir = ''; + if ($v_path_info['dirname'] != '') { + $v_dir = $v_path_info['dirname'].'/'; + } + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; + } + else { + // ----- Calculate the stored filename + $v_stored_filename = $p_filename; + } + + // ----- Look for all path to remove + if ($p_remove_all_dir) { + $v_stored_filename = basename($p_filename); + } + // ----- Look for partial path remove + else if ($p_remove_dir != "") { + if (substr($p_remove_dir, -1) != '/') + $p_remove_dir .= "/"; + + if ( (substr($p_filename, 0, 2) == "./") + || (substr($p_remove_dir, 0, 2) == "./")) { + + if ( (substr($p_filename, 0, 2) == "./") + && (substr($p_remove_dir, 0, 2) != "./")) { + $p_remove_dir = "./".$p_remove_dir; + } + if ( (substr($p_filename, 0, 2) != "./") + && (substr($p_remove_dir, 0, 2) == "./")) { + $p_remove_dir = substr($p_remove_dir, 2); + } + } + + $v_compare = PclZipUtilPathInclusion($p_remove_dir, + $v_stored_filename); + if ($v_compare > 0) { + if ($v_compare == 2) { + $v_stored_filename = ""; + } + else { + $v_stored_filename = substr($v_stored_filename, + strlen($p_remove_dir)); + } + } + } + + // ----- Remove drive letter if any + $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); + + // ----- Look for path to add + if ($p_add_dir != "") { + if (substr($p_add_dir, -1) == "/") + $v_stored_filename = $p_add_dir.$v_stored_filename; + else + $v_stored_filename = $p_add_dir."/".$v_stored_filename; + } + } + + // ----- Filename (reduce the path of stored name) + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); + $p_filedescr['stored_filename'] = $v_stored_filename; + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteFileHeader(&$p_header) + { + $v_result=1; + + // ----- Store the offset position of the file + $p_header['offset'] = ftell($this->zip_fd); + + // ----- Transform UNIX mtime to DOS format mdate/mtime + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + // ----- Packed data + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, + $p_header['version_extracted'], $p_header['flag'], + $p_header['compression'], $v_mtime, $v_mdate, + $p_header['crc'], $p_header['compressed_size'], + $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len']); + + // ----- Write the first 148 bytes of the header in the archive + fputs($this->zip_fd, $v_binary_data, 30); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralFileHeader(&$p_header) + { + $v_result=1; + + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + //} + + // ----- Transform UNIX mtime to DOS format mdate/mtime + $v_date = getdate($p_header['mtime']); + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; + + + // ----- Packed data + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, + $p_header['version'], $p_header['version_extracted'], + $p_header['flag'], $p_header['compression'], + $v_mtime, $v_mdate, $p_header['crc'], + $p_header['compressed_size'], $p_header['size'], + strlen($p_header['stored_filename']), + $p_header['extra_len'], $p_header['comment_len'], + $p_header['disk'], $p_header['internal'], + $p_header['external'], $p_header['offset']); + + // ----- Write the 42 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 46); + + // ----- Write the variable fields + if (strlen($p_header['stored_filename']) != 0) + { + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); + } + if ($p_header['extra_len'] != 0) + { + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); + } + if ($p_header['comment_len'] != 0) + { + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privWriteCentralHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) + { + $v_result=1; + + // ----- Packed data + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, + $p_nb_entries, $p_size, + $p_offset, strlen($p_comment)); + + // ----- Write the 22 bytes of the header in the zip file + fputs($this->zip_fd, $v_binary_data, 22); + + // ----- Write the variable fields + if (strlen($p_comment) != 0) + { + fputs($this->zip_fd, $p_comment, strlen($p_comment)); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privList() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privList(&$p_list) + { + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Open the zip file + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privSwapBackMagicQuotes(); + return $v_result; + } + + // ----- Go to beginning of Central Dir + @rewind($this->zip_fd); + if (@fseek($this->zip_fd, $v_central_dir['offset'])) + { + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read each entry + for ($i=0; $i<$v_central_dir['entries']; $i++) + { + // ----- Read the file header + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + $this->privSwapBackMagicQuotes(); + return $v_result; + } + $v_header['index'] = $i; + + // ----- Get the only interesting attributes + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); + unset($v_header); + } + + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Magic quotes trick + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privConvertHeader2FileInfo() + // Description : + // This function takes the file informations from the central directory + // entries and extract the interesting parameters that will be given back. + // The resulting file infos are set in the array $p_info + // $p_info['filename'] : Filename with full path. Given by user (add), + // extracted in the filesystem (extract). + // $p_info['stored_filename'] : Stored filename in the archive. + // $p_info['size'] = Size of the file. + // $p_info['compressed_size'] = Compressed size of the file. + // $p_info['mtime'] = Last modification date of the file. + // $p_info['comment'] = Comment associated with the file. + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. + // $p_info['status'] = status of the action on the file. + // $p_info['crc'] = CRC of the file content. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privConvertHeader2FileInfo($p_header, &$p_info) + { + $v_result=1; + + // ----- Get the interesting attributes + $v_temp_path = PclZipUtilPathReduction($p_header['filename']); + $p_info['filename'] = $v_temp_path; + $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); + $p_info['stored_filename'] = $v_temp_path; + $p_info['size'] = $p_header['size']; + $p_info['compressed_size'] = $p_header['compressed_size']; + $p_info['mtime'] = $p_header['mtime']; + $p_info['comment'] = $p_header['comment']; + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); + $p_info['index'] = $p_header['index']; + $p_info['status'] = $p_header['status']; + $p_info['crc'] = $p_header['crc']; + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractByRule() + // Description : + // Extract a file or directory depending of rules (by index, by name, ...) + // Parameters : + // $p_file_list : An array where will be placed the properties of each + // extracted file + // $p_path : Path to add while writing the extracted files + // $p_remove_path : Path to remove (from the file memorized path) while writing the + // extracted files. If the path does not match the file path, + // the file is extracted with its memorized path. + // $p_remove_path does not apply to 'list' mode. + // $p_path and $p_remove_path are commulative. + // Return Values : + // 1 on success,0 or less on error (see error code list) + // -------------------------------------------------------------------------------- + function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + $v_result=1; + + // ----- Magic quotes trick + $this->privDisableMagicQuotes(); + + // ----- Check the path + if ( ($p_path == "") + || ( (substr($p_path, 0, 1) != "/") + && (substr($p_path, 0, 3) != "../") + && (substr($p_path,1,2)!=":/"))) + $p_path = "./".$p_path; + + // ----- Reduce the path last (and duplicated) '/' + if (($p_path != "./") && ($p_path != "/")) + { + // ----- Look for the path end '/' + while (substr($p_path, -1) == "/") + { + $p_path = substr($p_path, 0, strlen($p_path)-1); + } + } + + // ----- Look for path to remove format (should end by /) + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) + { + $p_remove_path .= '/'; + } + $p_remove_path_size = strlen($p_remove_path); + + // ----- Open the zip file + if (($v_result = $this->privOpenFd('rb')) != 1) + { + $this->privSwapBackMagicQuotes(); + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + return $v_result; + } + + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + + // ----- Read each entry + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + + // ----- Read next Central dir entry + @rewind($this->zip_fd); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + return $v_result; + } + + // ----- Store the index + $v_header['index'] = $i; + + // ----- Store the file position + $v_pos_entry = ftell($this->zip_fd); + + // ----- Look for the specific extract rules + $v_extract = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + $v_extract = true; + } + } + // ----- Look for a filename + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + $v_extract = true; + } + } + } + + // ----- Look for extract by ereg rule + // ereg() is deprecated with PHP 5.3 + /* + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { + $v_extract = true; + } + } + */ + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { + $v_extract = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + $v_extract = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + break; + } + } + } + + // ----- Look for no rule, which means extract all the archive + else { + $v_extract = true; + } + + // ----- Check compression method + if ( ($v_extract) + && ( ($v_header['compression'] != 8) + && ($v_header['compression'] != 0))) { + $v_header['status'] = 'unsupported_compression'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, + "Filename '".$v_header['stored_filename']."' is " + ."compressed by an unsupported compression " + ."method (".$v_header['compression'].") "); + + return PclZip::errorCode(); + } + } + + // ----- Check encrypted files + if (($v_extract) && (($v_header['flag'] & 1) == 1)) { + $v_header['status'] = 'unsupported_encryption'; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + + $this->privSwapBackMagicQuotes(); + + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, + "Unsupported encryption for " + ." filename '".$v_header['stored_filename'] + ."'"); + + return PclZip::errorCode(); + } + } + + // ----- Look for real extraction + if (($v_extract) && ($v_header['status'] != 'ok')) { + $v_result = $this->privConvertHeader2FileInfo($v_header, + $p_file_list[$v_nb_extracted++]); + if ($v_result != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result; + } + + $v_extract = false; + } + + // ----- Look for real extraction + if ($v_extract) + { + + // ----- Go to the file position + @rewind($this->zip_fd); + if (@fseek($this->zip_fd, $v_header['offset'])) + { + // ----- Close the zip file + $this->privCloseFd(); + + $this->privSwapBackMagicQuotes(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Look for extraction as string + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { + + $v_string = ''; + + // ----- Extracting the file + $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + return $v_result; + } + + // ----- Set the file content + $p_file_list[$v_nb_extracted]['content'] = $v_string; + + // ----- Next extracted file + $v_nb_extracted++; + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for extraction in standard output + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { + // ----- Extracting the file in standard output + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + // ----- Look for normal extraction + else { + // ----- Extracting the file + $v_result1 = $this->privExtractFile($v_header, + $p_path, $p_remove_path, + $p_remove_all_path, + $p_options); + if ($v_result1 < 1) { + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + return $v_result1; + } + + // ----- Get the only interesting attributes + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + return $v_result; + } + + // ----- Look for user callback abort + if ($v_result1 == 2) { + break; + } + } + } + } + + // ----- Close the zip file + $this->privCloseFd(); + $this->privSwapBackMagicQuotes(); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFile() + // Description : + // Parameters : + // Return Values : + // + // 1 : ... ? + // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback + // -------------------------------------------------------------------------------- + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + return $v_result; + } + + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for all path to remove + if ($p_remove_all_path == true) { + // ----- Look for folder entry that not need to be extracted + if (($p_entry['external']&0x00000010)==0x00000010) { + + $p_entry['status'] = "filtered"; + + return $v_result; + } + + // ----- Get the basename of the path + $p_entry['filename'] = basename($p_entry['filename']); + } + + // ----- Look for path to remove + else if ($p_remove_path != "") + { + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) + { + + // ----- Change the file status + $p_entry['status'] = "filtered"; + + // ----- Return + return $v_result; + } + + $p_remove_path_size = strlen($p_remove_path); + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) + { + + // ----- Remove the path + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); + + } + } + + // ----- Add the path + if ($p_path != '') { + $p_entry['filename'] = $p_path."/".$p_entry['filename']; + } + + // ----- Check a base_dir_restriction + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { + $v_inclusion + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], + $p_entry['filename']); + if ($v_inclusion == 0) { + + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, + "Filename '".$p_entry['filename']."' is " + ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); + + return PclZip::errorCode(); + } + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + } + + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Look for specific actions while the file exist + if (file_exists($p_entry['filename'])) + { + + // ----- Look if file is a directory + if (is_dir($p_entry['filename'])) + { + + // ----- Change the file status + $p_entry['status'] = "already_a_directory"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, + "Filename '".$p_entry['filename']."' is " + ."already used by an existing directory"); + + return PclZip::errorCode(); + } + } + // ----- Look if file is write protected + else if (!is_writeable($p_entry['filename'])) + { + + // ----- Change the file status + $p_entry['status'] = "write_protected"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Filename '".$p_entry['filename']."' exists " + ."and is write protected"); + + return PclZip::errorCode(); + } + } + + // ----- Look if the extracted file is older + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) + { + // ----- Change the file status + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { + } + else { + $p_entry['status'] = "newer_exist"; + + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR + // For historical reason first PclZip implementation does not stop + // when this kind of error occurs. + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { + + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, + "Newer version of '".$p_entry['filename']."' exists " + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); + + return PclZip::errorCode(); + } + } + } + else { + } + } + + // ----- Check the directory availability and create it if necessary + else { + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) + $v_dir_to_check = $p_entry['filename']; + else if (!strstr($p_entry['filename'], "/")) + $v_dir_to_check = ""; + else + $v_dir_to_check = dirname($p_entry['filename']); + + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { + + // ----- Change the file status + $p_entry['status'] = "path_creation_fail"; + + // ----- Return + //return $v_result; + $v_result = 1; + } + } + } + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) + { + // ----- Look for not compressed file + if ($p_entry['compression'] == 0) { + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) + { + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + // ----- Return + return $v_result; + } + + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($this->zip_fd, $v_read_size); + /* Try to speed up the code + $v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_binary_data, $v_read_size); + */ + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Closing the destination file + fclose($v_dest_file); + + // ----- Change the file mtime + touch($p_entry['filename'], $p_entry['mtime']); + + + } + else { + // ----- TBC + // Need to be finished + if (($p_entry['flag'] & 1) == 1) { + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); + return PclZip::errorCode(); + } + + + // ----- Look for using temporary file to unzip + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { + $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); + if ($v_result < PCLZIP_ERR_NO_ERROR) { + return $v_result; + } + } + + // ----- Look for extract in memory + else { + + + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + $v_file_content = @gzinflate($v_buffer); + unset($v_buffer); + if ($v_file_content === FALSE) { + + // ----- Change the file status + // TBC + $p_entry['status'] = "error"; + + return $v_result; + } + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + + // ----- Change the file status + $p_entry['status'] = "write_error"; + + return $v_result; + } + + // ----- Write the uncompressed data + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); + unset($v_file_content); + + // ----- Closing the destination file + @fclose($v_dest_file); + + } + + // ----- Change the file mtime + @touch($p_entry['filename'], $p_entry['mtime']); + } + + // ----- Look for chmod option + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { + + // ----- Change the mode of the file + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); + } + + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); + + // ----- Look for abort result + if ($v_result == 2) { + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileUsingTempFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileUsingTempFile(&$p_entry, &$p_options) + { + $v_result=1; + + // ----- Creates a temporary file + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; + if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { + fclose($v_file); + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); + return PclZip::errorCode(); + } + + + // ----- Write gz file format header + $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); + @fwrite($v_dest_file, $v_binary_data, 10); + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['compressed_size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($this->zip_fd, $v_read_size); + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Write gz file format footer + $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); + @fwrite($v_dest_file, $v_binary_data, 8); + + // ----- Close the temporary file + @fclose($v_dest_file); + + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + $p_entry['status'] = "write_error"; + return $v_result; + } + + // ----- Open the temporary gz file + if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { + @fclose($v_dest_file); + $p_entry['status'] = "read_error"; + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); + return PclZip::errorCode(); + } + + + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks + $v_size = $p_entry['size']; + while ($v_size != 0) { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @gzread($v_src_file, $v_read_size); + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + @fclose($v_dest_file); + @gzclose($v_src_file); + + // ----- Delete the temporary file + @unlink($v_gzip_temp_name); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileInOutput() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileInOutput(&$p_entry, &$p_options) + { + $v_result=1; + + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { + return $v_result; + } + + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. +// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + } + + // ----- Trace + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) { + // ----- Look for not compressed file + if ($p_entry['compressed_size'] == $p_entry['size']) { + + // ----- Read the file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Send the file to the output + echo $v_buffer; + unset($v_buffer); + } + else { + + // ----- Read the compressed file in a buffer (one shot) + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + $v_file_content = gzinflate($v_buffer); + unset($v_buffer); + + // ----- Send the file to the output + echo $v_file_content; + unset($v_file_content); + } + } + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); + + // ----- Look for abort result + if ($v_result == 2) { + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privExtractFileAsString() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) + { + $v_result=1; + + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + return $v_result; + } + + + // ----- Check that the file header is coherent with $p_entry info + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { + // TBC + } + + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + + // ----- Look for abort result + if ($v_result == 2) { + // ----- This status is internal and will be changed in 'skipped' + $p_entry['status'] = "aborted"; + $v_result = PCLZIP_ERR_USER_ABORTED; + } + + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + } + + + // ----- Look if extraction should be done + if ($p_entry['status'] == 'ok') { + + // ----- Do the extraction (if not a folder) + if (!(($p_entry['external']&0x00000010)==0x00000010)) { + // ----- Look for not compressed file + // if ($p_entry['compressed_size'] == $p_entry['size']) + if ($p_entry['compression'] == 0) { + + // ----- Reading the file + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); + } + else { + + // ----- Reading the file + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); + + // ----- Decompress the file + if (($p_string = @gzinflate($v_data)) === FALSE) { + // TBC + } + } + + // ----- Trace + } + else { + // TBC : error : can not extract a folder in a string + } + + } + + // ----- Change abort status + if ($p_entry['status'] == "aborted") { + $p_entry['status'] = "skipped"; + } + + // ----- Look for post-extract callback + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + + // ----- Generate a local information + $v_local_header = array(); + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); + + // ----- Swap the content to header + $v_local_header['content'] = $p_string; + $p_string = ''; + + // ----- Call the callback + // Here I do not use call_user_func() because I need to send a reference to the + // header. + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); + + // ----- Swap back the content to header + $p_string = $v_local_header['content']; + unset($v_local_header['content']); + + // ----- Look for abort result + if ($v_result == 2) { + $v_result = PCLZIP_ERR_USER_ABORTED; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadFileHeader(&$p_header) + { + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + $v_data = unpack('Vid', $v_binary_data); + + // ----- Check signature + if ($v_data['id'] != 0x04034b50) + { + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 26); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 26) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Extract the values + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); + + // ----- Get filename + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); + + // ----- Get extra_fields + if ($v_data['extra_len'] != 0) { + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); + } + else { + $p_header['extra'] = ''; + } + + // ----- Extract properties + $p_header['version_extracted'] = $v_data['version']; + $p_header['compression'] = $v_data['compression']; + $p_header['size'] = $v_data['size']; + $p_header['compressed_size'] = $v_data['compressed_size']; + $p_header['crc'] = $v_data['crc']; + $p_header['flag'] = $v_data['flag']; + $p_header['filename_len'] = $v_data['filename_len']; + + // ----- Recuperate date in UNIX format + $p_header['mdate'] = $v_data['mdate']; + $p_header['mtime'] = $v_data['mtime']; + if ($p_header['mdate'] && $p_header['mtime']) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + } + else + { + $p_header['mtime'] = time(); + } + + // TBC + //for(reset($v_data); $key = key($v_data); next($v_data)) { + //} + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set the status field + $p_header['status'] = "ok"; + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadCentralFileHeader(&$p_header) + { + $v_result=1; + + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + $v_data = unpack('Vid', $v_binary_data); + + // ----- Check signature + if ($v_data['id'] != 0x02014b50) + { + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read the first 42 bytes of the header + $v_binary_data = fread($this->zip_fd, 42); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 42) + { + $p_header['filename'] = ""; + $p_header['status'] = "invalid_header"; + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Extract the values + $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); + + // ----- Get filename + if ($p_header['filename_len'] != 0) + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); + else + $p_header['filename'] = ''; + + // ----- Get extra + if ($p_header['extra_len'] != 0) + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); + else + $p_header['extra'] = ''; + + // ----- Get comment + if ($p_header['comment_len'] != 0) + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); + else + $p_header['comment'] = ''; + + // ----- Extract properties + + // ----- Recuperate date in UNIX format + //if ($p_header['mdate'] && $p_header['mtime']) + // TBC : bug : this was ignoring time with 0/0/0 + if (1) + { + // ----- Extract time + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; + $v_seconde = ($p_header['mtime'] & 0x001F)*2; + + // ----- Extract date + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; + $v_day = $p_header['mdate'] & 0x001F; + + // ----- Get UNIX date format + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); + + } + else + { + $p_header['mtime'] = time(); + } + + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + + // ----- Set default status to ok + $p_header['status'] = 'ok'; + + // ----- Look if it is a directory + if (substr($p_header['filename'], -1) == '/') { + //$p_header['external'] = 0x41FF0010; + $p_header['external'] = 0x00000010; + } + + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privCheckFileHeaders() + // Description : + // Parameters : + // Return Values : + // 1 on success, + // 0 on error; + // -------------------------------------------------------------------------------- + function privCheckFileHeaders(&$p_local_header, &$p_central_header) + { + $v_result=1; + + // ----- Check the static values + // TBC + if ($p_local_header['filename'] != $p_central_header['filename']) { + } + if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { + } + if ($p_local_header['flag'] != $p_central_header['flag']) { + } + if ($p_local_header['compression'] != $p_central_header['compression']) { + } + if ($p_local_header['mtime'] != $p_central_header['mtime']) { + } + if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { + } + + // ----- Look for flag bit 3 + if (($p_local_header['flag'] & 8) == 8) { + $p_local_header['size'] = $p_central_header['size']; + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; + $p_local_header['crc'] = $p_central_header['crc']; + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privReadEndCentralDir() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadEndCentralDir(&$p_central_dir) + { + $v_result=1; + + // ----- Go to the end of the zip file + $v_size = filesize($this->zipname); + @fseek($this->zip_fd, $v_size); + if (@ftell($this->zip_fd) != $v_size) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- First try : look if this is an archive with no commentaries (most of the time) + // in this case the end of central dir is at 22 bytes of the file end + $v_found = 0; + if ($v_size > 26) { + @fseek($this->zip_fd, $v_size-22); + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read for bytes + $v_binary_data = @fread($this->zip_fd, 4); + $v_data = @unpack('Vid', $v_binary_data); + + // ----- Check signature + if ($v_data['id'] == 0x06054b50) { + $v_found = 1; + } + + $v_pos = ftell($this->zip_fd); + } + + // ----- Go back to the maximum possible size of the Central Dir End Record + if (!$v_found) { + $v_maximum_size = 65557; // 0xFFFF + 22; + if ($v_maximum_size > $v_size) + $v_maximum_size = $v_size; + @fseek($this->zip_fd, $v_size-$v_maximum_size); + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read byte per byte in order to find the signature + $v_pos = ftell($this->zip_fd); + $v_bytes = 0x00000000; + while ($v_pos < $v_size) + { + // ----- Read a byte + $v_byte = @fread($this->zip_fd, 1); + + // ----- Add the byte + //$v_bytes = ($v_bytes << 8) | Ord($v_byte); + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); + + // ----- Compare the bytes + if ($v_bytes == 0x504b0506) + { + $v_pos++; + break; + } + + $v_pos++; + } + + // ----- Look if not found end of central dir + if ($v_pos == $v_size) + { + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); + + // ----- Return + return PclZip::errorCode(); + } + } + + // ----- Read the first 18 bytes of the header + $v_binary_data = fread($this->zip_fd, 18); + + // ----- Look for invalid block size + if (strlen($v_binary_data) != 18) + { + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Extract the values + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); + + // ----- Check the global size + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { + + // ----- Removed in release 2.2 see readme file + // The check of the file size is a little too strict. + // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. + // While decrypted, zip has training 0 bytes + if (0) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, + 'The central dir is not at the end of the archive.' + .' Some trailing bytes exists after the archive.'); + + // ----- Return + return PclZip::errorCode(); + } + } + + // ----- Get comment + if ($v_data['comment_size'] != 0) { + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); + } + else + $p_central_dir['comment'] = ''; + + $p_central_dir['entries'] = $v_data['entries']; + $p_central_dir['disk_entries'] = $v_data['disk_entries']; + $p_central_dir['offset'] = $v_data['offset']; + $p_central_dir['size'] = $v_data['size']; + $p_central_dir['disk'] = $v_data['disk']; + $p_central_dir['disk_start'] = $v_data['disk_start']; + + // TBC + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { + //} + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDeleteByRule() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDeleteByRule(&$p_result_list, &$p_options) + { + $v_result=1; + $v_list_detail = array(); + + // ----- Open the zip file + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + return $v_result; + } + + // ----- Go to beginning of File + @rewind($this->zip_fd); + + // ----- Scan all the files + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + @rewind($this->zip_fd); + if (@fseek($this->zip_fd, $v_pos_entry)) + { + // ----- Close the zip file + $this->privCloseFd(); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read each entry + $v_header_list = array(); + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + + // ----- Read the file header + $v_header_list[$v_nb_extracted] = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + + return $v_result; + } + + + // ----- Store the index + $v_header_list[$v_nb_extracted]['index'] = $i; + + // ----- Look for the specific extract rules + $v_found = false; + + // ----- Look for extract by name rule + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { + + // ----- Look if the filename is in the list + for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) + && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + $v_found = true; + } + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { + $v_found = true; + } + } + // ----- Look for a filename + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + $v_found = true; + } + } + } + + // ----- Look for extract by ereg rule + // ereg() is deprecated with PHP 5.3 + /* + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + $v_found = true; + } + } + */ + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + $v_found = true; + } + } + + // ----- Look for extract by index rule + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { + + // ----- Look if the index is in the list + for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + $v_found = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + $j_start = $j+1; + } + + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + break; + } + } + } + else { + $v_found = true; + } + + // ----- Look for deletion + if ($v_found) + { + unset($v_header_list[$v_nb_extracted]); + } + else + { + $v_nb_extracted++; + } + } + + // ----- Look if something need to be deleted + if ($v_nb_extracted > 0) { + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Creates a temporary zip archive + $v_temp_zip = new PclZip($v_zip_temp_name); + + // ----- Open the temporary zip file in write mode + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { + $this->privCloseFd(); + + // ----- Return + return $v_result; + } + + // ----- Look which file need to be kept + for ($i=0; $izip_fd); + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Read the file header + $v_local_header = array(); + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + return $v_result; + } + + // ----- Check that local file header is same as central file header + if ($this->privCheckFileHeaders($v_local_header, + $v_header_list[$i]) != 1) { + // TBC + } + unset($v_local_header); + + // ----- Write the file header + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + return $v_result; + } + + // ----- Read/write the data block + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + return $v_result; + } + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_temp_zip->zip_fd); + + // ----- Re-Create the Central Dir files header + for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) { + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + return $v_result; + } + + // ----- Transform the header to a 'usable' info + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + + + // ----- Zip file comment + $v_comment = ''; + if (isset($p_options[PCLZIP_OPT_COMMENT])) { + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; + } + + // ----- Calculate the size of the central header + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; + + // ----- Create the central dir footer + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { + // ----- Reset the file list + unset($v_header_list); + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + + // ----- Return + return $v_result; + } + + // ----- Close + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Destroy the temporary archive + unset($v_temp_zip); + } + + // ----- Remove every files : reset the file + else if ($v_central_dir['entries'] != 0) { + $this->privCloseFd(); + + if (($v_result = $this->privOpenFd('wb')) != 1) { + return $v_result; + } + + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { + return $v_result; + } + + $this->privCloseFd(); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDirCheck() + // Description : + // Check if a directory exists, if not it creates it and all the parents directory + // which may be useful. + // Parameters : + // $p_dir : Directory path to check. + // Return Values : + // 1 : OK + // -1 : Unable to create directory + // -------------------------------------------------------------------------------- + function privDirCheck($p_dir, $p_is_dir=false) + { + $v_result = 1; + + + // ----- Remove the final '/' + if (($p_is_dir) && (substr($p_dir, -1)=='/')) + { + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); + } + + // ----- Check the directory availability + if ((is_dir($p_dir)) || ($p_dir == "")) + { + return 1; + } + + // ----- Extract parent directory + $p_parent_dir = dirname($p_dir); + + // ----- Just a check + if ($p_parent_dir != $p_dir) + { + // ----- Look for parent directory + if ($p_parent_dir != "") + { + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) + { + return $v_result; + } + } + } + + // ----- Create the directory + if (!@mkdir($p_dir, 0777)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privMerge() + // Description : + // If $p_archive_to_add does not exist, the function exit with a success result. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privMerge(&$p_archive_to_add) + { + $v_result=1; + + // ----- Look if the archive_to_add exists + if (!is_file($p_archive_to_add->zipname)) + { + + // ----- Nothing to merge, so merge is a success + $v_result = 1; + + // ----- Return + return $v_result; + } + + // ----- Look if the archive exists + if (!is_file($this->zipname)) + { + + // ----- Do a duplicate + $v_result = $this->privDuplicate($p_archive_to_add->zipname); + + // ----- Return + return $v_result; + } + + // ----- Open the zip file + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + return $v_result; + } + + // ----- Go to beginning of File + @rewind($this->zip_fd); + + // ----- Open the archive_to_add file + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) + { + $this->privCloseFd(); + + // ----- Return + return $v_result; + } + + // ----- Read the central directory informations + $v_central_dir_to_add = array(); + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + return $v_result; + } + + // ----- Go to beginning of File + @rewind($p_archive_to_add->zip_fd); + + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + + // ----- Open the temporary file in write mode + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = $v_central_dir['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the files from the archive_to_add into the temporary file + $v_size = $v_central_dir_to_add['offset']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Store the offset of the central dir + $v_offset = @ftell($v_zip_temp_fd); + + // ----- Copy the block of file headers from the old archive + $v_size = $v_central_dir['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($this->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Copy the block of file headers from the archive_to_add + $v_size = $v_central_dir_to_add['size']; + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Merge the file comments + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; + + // ----- Calculate the size of the (new) central header + $v_size = @ftell($v_zip_temp_fd)-$v_offset; + + // ----- Swap the file descriptor + // Here is a trick : I swap the temporary fd with the zip fd, in order to use + // the following methods on the temporary fil and not the real archive fd + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Create the central dir footer + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) + { + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + @fclose($v_zip_temp_fd); + $this->zip_fd = null; + + // ----- Reset the file list + unset($v_header_list); + + // ----- Return + return $v_result; + } + + // ----- Swap back the file descriptor + $v_swap = $this->zip_fd; + $this->zip_fd = $v_zip_temp_fd; + $v_zip_temp_fd = $v_swap; + + // ----- Close + $this->privCloseFd(); + $p_archive_to_add->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Delete the zip file + // TBC : I should test the result ... + @unlink($this->zipname); + + // ----- Rename the temporary file + // TBC : I should test the result ... + //@rename($v_zip_temp_name, $this->zipname); + PclZipUtilRename($v_zip_temp_name, $this->zipname); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDuplicate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDuplicate($p_archive_filename) + { + $v_result=1; + + // ----- Look if the $p_archive_filename exists + if (!is_file($p_archive_filename)) + { + + // ----- Nothing to duplicate, so duplicate is a success. + $v_result = 1; + + // ----- Return + return $v_result; + } + + // ----- Open the zip file + if (($v_result=$this->privOpenFd('wb')) != 1) + { + // ----- Return + return $v_result; + } + + // ----- Open the temporary file in write mode + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) + { + $this->privCloseFd(); + + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); + + // ----- Return + return PclZip::errorCode(); + } + + // ----- Copy the files from the archive to the temporary file + // TBC : Here I should better append the file and go back to erase the central dir + $v_size = filesize($p_archive_filename); + while ($v_size != 0) + { + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = fread($v_zip_temp_fd, $v_read_size); + @fwrite($this->zip_fd, $v_buffer, $v_read_size); + $v_size -= $v_read_size; + } + + // ----- Close + $this->privCloseFd(); + + // ----- Close the temporary file + @fclose($v_zip_temp_fd); + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorLog() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorLog($p_error_code=0, $p_error_string='') + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclError($p_error_code, $p_error_string); + } + else { + $this->error_code = $p_error_code; + $this->error_string = $p_error_string; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privErrorReset() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privErrorReset() + { + if (PCLZIP_ERROR_EXTERNAL == 1) { + PclErrorReset(); + } + else { + $this->error_code = 0; + $this->error_string = ''; + } + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privDisableMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDisableMagicQuotes() + { + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + return $v_result; + } + + // ----- Look if already done + if ($this->magic_quotes_status != -1) { + return $v_result; + } + + // ----- Get and memorize the magic_quote value + $this->magic_quotes_status = @get_magic_quotes_runtime(); + + // ----- Disable magic_quotes + if ($this->magic_quotes_status == 1) { + @set_magic_quotes_runtime(0); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : privSwapBackMagicQuotes() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privSwapBackMagicQuotes() + { + $v_result=1; + + // ----- Look if function exists + if ( (!function_exists("get_magic_quotes_runtime")) + || (!function_exists("set_magic_quotes_runtime"))) { + return $v_result; + } + + // ----- Look if something to do + if ($this->magic_quotes_status != -1) { + return $v_result; + } + + // ----- Swap back magic_quotes + if ($this->magic_quotes_status == 1) { + @set_magic_quotes_runtime($this->magic_quotes_status); + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + } + // End of class + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathReduction() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilPathReduction($p_dir) + { + $v_result = ""; + + // ----- Look for not empty path + if ($p_dir != "") { + // ----- Explode path by directory names + $v_list = explode("/", $p_dir); + + // ----- Study directories from last to first + $v_skip = 0; + for ($i=sizeof($v_list)-1; $i>=0; $i--) { + // ----- Look for current path + if ($v_list[$i] == ".") { + // ----- Ignore this directory + // Should be the first $i=0, but no check is done + } + else if ($v_list[$i] == "..") { + $v_skip++; + } + else if ($v_list[$i] == "") { + // ----- First '/' i.e. root slash + if ($i == 0) { + $v_result = "/".$v_result; + if ($v_skip > 0) { + // ----- It is an invalid path, so the path is not modified + // TBC + $v_result = $p_dir; + $v_skip = 0; + } + } + // ----- Last '/' i.e. indicates a directory + else if ($i == (sizeof($v_list)-1)) { + $v_result = $v_list[$i]; + } + // ----- Double '/' inside the path + else { + // ----- Ignore only the double '//' in path, + // but not the first and last '/' + } + } + else { + // ----- Look for item to skip + if ($v_skip > 0) { + $v_skip--; + } + else { + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); + } + } + } + + // ----- Look for skip + if ($v_skip > 0) { + while ($v_skip > 0) { + $v_result = '../'.$v_result; + $v_skip--; + } + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathInclusion() + // Description : + // This function indicates if the path $p_path is under the $p_dir tree. Or, + // said in an other way, if the file or sub-dir $p_path is inside the dir + // $p_dir. + // The function indicates also if the path is exactly the same as the dir. + // This function supports path with duplicated '/' like '//', but does not + // support '.' or '..' statements. + // Parameters : + // Return Values : + // 0 if $p_path is not inside directory $p_dir + // 1 if $p_path is inside directory $p_dir + // 2 if $p_path is exactly the same as $p_dir + // -------------------------------------------------------------------------------- + function PclZipUtilPathInclusion($p_dir, $p_path) + { + $v_result = 1; + + // ----- Look for path beginning by ./ + if ( ($p_dir == '.') + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); + } + if ( ($p_path == '.') + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); + } + + // ----- Explode dir and path by directory separator + $v_list_dir = explode("/", $p_dir); + $v_list_dir_size = sizeof($v_list_dir); + $v_list_path = explode("/", $p_path); + $v_list_path_size = sizeof($v_list_path); + + // ----- Study directories paths + $i = 0; + $j = 0; + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { + + // ----- Look for empty dir (path reduction) + if ($v_list_dir[$i] == '') { + $i++; + continue; + } + if ($v_list_path[$j] == '') { + $j++; + continue; + } + + // ----- Compare the items + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { + $v_result = 0; + } + + // ----- Next items + $i++; + $j++; + } + + // ----- Look if everything seems to be the same + if ($v_result) { + // ----- Skip all the empty items + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; + + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { + // ----- There are exactly the same + $v_result = 2; + } + else if ($i < $v_list_dir_size) { + // ----- The path is shorter than the dir + $v_result = 0; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilCopyBlock() + // Description : + // Parameters : + // $p_mode : read/write compression mode + // 0 : src & dest normal + // 1 : src gzip, dest normal + // 2 : src normal, dest gzip + // 3 : src & dest gzip + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) + { + $v_result = 1; + + if ($p_mode==0) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==1) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @gzread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==2) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @fread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + else if ($p_mode==3) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + $v_buffer = @gzread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilRename() + // Description : + // This function tries to do a simple rename() function. If it fails, it + // tries to copy the $p_src file in a new $p_dest file and then unlink the + // first one. + // Parameters : + // $p_src : Old filename + // $p_dest : New filename + // Return Values : + // 1 on success, 0 on failure. + // -------------------------------------------------------------------------------- + function PclZipUtilRename($p_src, $p_dest) + { + $v_result = 1; + + // ----- Try to rename the files + if (!@rename($p_src, $p_dest)) { + + // ----- Try to copy & unlink the src + if (!@copy($p_src, $p_dest)) { + $v_result = 0; + } + else if (!@unlink($p_src)) { + $v_result = 0; + } + } + + // ----- Return + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilOptionText() + // Description : + // Translate option value in text. Mainly for debug purpose. + // Parameters : + // $p_option : the option value. + // Return Values : + // The option text value. + // -------------------------------------------------------------------------------- + function PclZipUtilOptionText($p_option) + { + + $v_list = get_defined_constants(); + for (reset($v_list); $v_key = key($v_list); next($v_list)) { + $v_prefix = substr($v_key, 0, 10); + if (( ($v_prefix == 'PCLZIP_OPT') + || ($v_prefix == 'PCLZIP_CB_') + || ($v_prefix == 'PCLZIP_ATT')) + && ($v_list[$v_key] == $p_option)) { + return $v_key; + } + } + + $v_result = 'Unknown'; + + return $v_result; + } + // -------------------------------------------------------------------------------- + + // -------------------------------------------------------------------------------- + // Function : PclZipUtilTranslateWinPath() + // Description : + // Translate windows path by replacing '\' by '/' and optionally removing + // drive letter. + // Parameters : + // $p_path : path to translate. + // $p_remove_disk_letter : true | false + // Return Values : + // The path translated. + // -------------------------------------------------------------------------------- + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) + { + if (stristr(php_uname(), 'windows')) { + // ----- Look for potential disk letter + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { + $p_path = substr($p_path, $v_position+1); + } + // ----- Change potential windows directory separator + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { + $p_path = strtr($p_path, '\\', '/'); + } + } + return $p_path; + } + // -------------------------------------------------------------------------------- + + +?> diff --git a/backend/wp-admin/includes/class-plugin-installer-skin.php b/backend/wp-admin/includes/class-plugin-installer-skin.php new file mode 100644 index 0000000..66f4062 --- /dev/null +++ b/backend/wp-admin/includes/class-plugin-installer-skin.php @@ -0,0 +1,98 @@ + 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' ); + $args = wp_parse_args($args, $defaults); + + $this->type = $args['type']; + $this->api = isset($args['api']) ? $args['api'] : array(); + + parent::__construct($args); + } + + /** + */ + public function before() { + if ( !empty($this->api) ) + $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin %s %s.'), $this->api->name, $this->api->version); + } + + /** + */ + public function after() { + $plugin_file = $this->upgrader->plugin_info(); + + $install_actions = array(); + + $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins'; + + if ( 'import' == $from ) { + $install_actions['activate_plugin'] = '' . __( 'Activate Plugin & Run Importer' ) . ''; + } else if ( 'press-this' == $from ) { + $install_actions['activate_plugin'] = '' . __( 'Activate Plugin & Return to Press This' ) . ''; + } else { + $install_actions['activate_plugin'] = '' . __( 'Activate Plugin' ) . ''; + } + + if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { + $install_actions['network_activate'] = '' . __( 'Network Activate' ) . ''; + unset( $install_actions['activate_plugin'] ); + } + + if ( 'import' == $from ) { + $install_actions['importers_page'] = '' . __( 'Return to Importers' ) . ''; + } elseif ( $this->type == 'web' ) { + $install_actions['plugins_page'] = '' . __( 'Return to Plugin Installer' ) . ''; + } elseif ( 'upload' == $this->type && 'plugins' == $from ) { + $install_actions['plugins_page'] = '' . __( 'Return to Plugin Installer' ) . ''; + } else { + $install_actions['plugins_page'] = '' . __( 'Return to Plugins page' ) . ''; + } + + if ( ! $this->result || is_wp_error($this->result) ) { + unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); + } elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) ) { + unset( $install_actions['activate_plugin'] ); + } + + /** + * Filters the list of action links available following a single plugin installation. + * + * @since 2.7.0 + * + * @param array $install_actions Array of plugin action links. + * @param object $api Object containing WordPress.org API plugin data. Empty + * for non-API installs, such as when a plugin is installed + * via upload. + * @param string $plugin_file Path to the plugin file. + */ + $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file ); + + if ( ! empty( $install_actions ) ) { + $this->feedback( implode( ' ', (array) $install_actions ) ); + } + } +} diff --git a/backend/wp-admin/includes/class-plugin-upgrader-skin.php b/backend/wp-admin/includes/class-plugin-upgrader-skin.php new file mode 100644 index 0000000..ba8c30f --- /dev/null +++ b/backend/wp-admin/includes/class-plugin-upgrader-skin.php @@ -0,0 +1,70 @@ + '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') ); + $args = wp_parse_args($args, $defaults); + + $this->plugin = $args['plugin']; + + $this->plugin_active = is_plugin_active( $this->plugin ); + $this->plugin_network_active = is_plugin_active_for_network( $this->plugin ); + + parent::__construct($args); + } + + /** + */ + public function after() { + $this->plugin = $this->upgrader->plugin_info(); + if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ + // Currently used only when JS is off for a single plugin update? + echo ''; + } + + $this->decrement_update_count( 'plugin' ); + + $update_actions = array( + 'activate_plugin' => '' . __( 'Activate Plugin' ) . '', + 'plugins_page' => '' . __( 'Return to Plugins page' ) . '' + ); + if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) + unset( $update_actions['activate_plugin'] ); + + /** + * Filters the list of action links available following a single plugin update. + * + * @since 2.7.0 + * + * @param array $update_actions Array of plugin action links. + * @param string $plugin Path to the plugin file. + */ + $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin ); + + if ( ! empty($update_actions) ) + $this->feedback(implode(' | ', (array)$update_actions)); + } +} diff --git a/backend/wp-admin/includes/class-plugin-upgrader.php b/backend/wp-admin/includes/class-plugin-upgrader.php new file mode 100644 index 0000000..3c05353 --- /dev/null +++ b/backend/wp-admin/includes/class-plugin-upgrader.php @@ -0,0 +1,459 @@ +strings['up_to_date'] = __('The plugin is at the latest version.'); + $this->strings['no_package'] = __('Update package not available.'); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s' ); + $this->strings['unpack_package'] = __('Unpacking the update…'); + $this->strings['remove_old'] = __('Removing the old version of the plugin…'); + $this->strings['remove_old_failed'] = __('Could not remove the old plugin.'); + $this->strings['process_failed'] = __('Plugin update failed.'); + $this->strings['process_success'] = __('Plugin updated successfully.'); + $this->strings['process_bulk_success'] = __('Plugins updated successfully.'); + } + + /** + * Initialize the installation strings. + * + * @since 2.8.0 + */ + public function install_strings() { + $this->strings['no_package'] = __('Installation package not available.'); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '%s' ); + $this->strings['unpack_package'] = __('Unpacking the package…'); + $this->strings['installing_package'] = __('Installing the plugin…'); + $this->strings['no_files'] = __('The plugin contains no files.'); + $this->strings['process_failed'] = __('Plugin installation failed.'); + $this->strings['process_success'] = __('Plugin installed successfully.'); + } + + /** + * Install a plugin package. + * + * @since 2.8.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. + * + * @param string $package The full local path or URI of the package. + * @param array $args { + * Optional. Other arguments for installing a plugin package. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. + * Default true. + * } + * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. + */ + public function install( $package, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->install_strings(); + + add_filter('upgrader_source_selection', array($this, 'check_package') ); + if ( $parsed_args['clear_update_cache'] ) { + // Clear cache so wp_update_plugins() knows about the new plugin. + add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); + } + + $this->run( array( + 'package' => $package, + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => false, // Do not overwrite files. + 'clear_working' => true, + 'hook_extra' => array( + 'type' => 'plugin', + 'action' => 'install', + ) + ) ); + + remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); + remove_filter('upgrader_source_selection', array($this, 'check_package') ); + + if ( ! $this->result || is_wp_error($this->result) ) + return $this->result; + + // Force refresh of plugin update information + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); + + return true; + } + + /** + * Upgrade a plugin. + * + * @since 2.8.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. + * + * @param string $plugin The basename path to the main plugin file. + * @param array $args { + * Optional. Other arguments for upgrading a plugin package. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. + * Default true. + * } + * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. + */ + public function upgrade( $plugin, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->upgrade_strings(); + + $current = get_site_transient( 'update_plugins' ); + if ( !isset( $current->response[ $plugin ] ) ) { + $this->skin->before(); + $this->skin->set_result(false); + $this->skin->error('up_to_date'); + $this->skin->after(); + return false; + } + + // Get the URL to the zip file + $r = $current->response[ $plugin ]; + + add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); + add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); + //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. + if ( $parsed_args['clear_update_cache'] ) { + // Clear cache so wp_update_plugins() knows about the new plugin. + add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); + } + + $this->run( array( + 'package' => $r->package, + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => true, + 'clear_working' => true, + 'hook_extra' => array( + 'plugin' => $plugin, + 'type' => 'plugin', + 'action' => 'update', + ), + ) ); + + // Cleanup our hooks, in case something else does a upgrade on this connection. + remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); + remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); + remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); + + if ( ! $this->result || is_wp_error($this->result) ) + return $this->result; + + // Force refresh of plugin update information + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); + + return true; + } + + /** + * Bulk upgrade several plugins at once. + * + * @since 2.8.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. + * + * @param array $plugins Array of the basename paths of the plugins' main files. + * @param array $args { + * Optional. Other arguments for upgrading several plugins at once. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. + * Default true. + * } + * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. + */ + public function bulk_upgrade( $plugins, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->bulk = true; + $this->upgrade_strings(); + + $current = get_site_transient( 'update_plugins' ); + + add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); + + $this->skin->header(); + + // Connect to the Filesystem first. + $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) ); + if ( ! $res ) { + $this->skin->footer(); + return false; + } + + $this->skin->bulk_header(); + + /* + * Only start maintenance mode if: + * - running Multisite and there are one or more plugins specified, OR + * - a plugin with an update available is currently active. + * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. + */ + $maintenance = ( is_multisite() && ! empty( $plugins ) ); + foreach ( $plugins as $plugin ) + $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); + if ( $maintenance ) + $this->maintenance_mode(true); + + $results = array(); + + $this->update_count = count($plugins); + $this->update_current = 0; + foreach ( $plugins as $plugin ) { + $this->update_current++; + $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); + + if ( !isset( $current->response[ $plugin ] ) ) { + $this->skin->set_result('up_to_date'); + $this->skin->before(); + $this->skin->feedback('up_to_date'); + $this->skin->after(); + $results[$plugin] = true; + continue; + } + + // Get the URL to the zip file. + $r = $current->response[ $plugin ]; + + $this->skin->plugin_active = is_plugin_active($plugin); + + $result = $this->run( array( + 'package' => $r->package, + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => true, + 'clear_working' => true, + 'is_multi' => true, + 'hook_extra' => array( + 'plugin' => $plugin + ) + ) ); + + $results[$plugin] = $this->result; + + // Prevent credentials auth screen from displaying multiple times + if ( false === $result ) + break; + } //end foreach $plugins + + $this->maintenance_mode(false); + + // Force refresh of plugin update information. + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); + + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ + do_action( 'upgrader_process_complete', $this, array( + 'action' => 'update', + 'type' => 'plugin', + 'bulk' => true, + 'plugins' => $plugins, + ) ); + + $this->skin->bulk_footer(); + + $this->skin->footer(); + + // Cleanup our hooks, in case something else does a upgrade on this connection. + remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); + + return $results; + } + + /** + * Check a source package to be sure it contains a plugin. + * + * This function is added to the {@see 'upgrader_source_selection'} filter by + * Plugin_Upgrader::install(). + * + * @since 3.3.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $source The path to the downloaded package source. + * @return string|WP_Error The source as passed, or a WP_Error object + * if no plugins were found. + */ + public function check_package($source) { + global $wp_filesystem; + + if ( is_wp_error($source) ) + return $source; + + $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); + if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation. + return $source; + + // Check the folder contains at least 1 valid plugin. + $plugins_found = false; + $files = glob( $working_directory . '*.php' ); + if ( $files ) { + foreach ( $files as $file ) { + $info = get_plugin_data( $file, false, false ); + if ( ! empty( $info['Name'] ) ) { + $plugins_found = true; + break; + } + } + } + + if ( ! $plugins_found ) + return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); + + return $source; + } + + /** + * Retrieve the path to the file that contains the plugin info. + * + * This isn't used internally in the class, but is called by the skins. + * + * @since 2.8.0 + * + * @return string|false The full path to the main plugin file, or false. + */ + public function plugin_info() { + if ( ! is_array($this->result) ) + return false; + if ( empty($this->result['destination_name']) ) + return false; + + $plugin = get_plugins('/' . $this->result['destination_name']); //Ensure to pass with leading slash + if ( empty($plugin) ) + return false; + + $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list + + return $this->result['destination_name'] . '/' . $pluginfiles[0]; + } + + /** + * Deactivates a plugin before it is upgraded. + * + * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). + * + * @since 2.8.0 + * @since 4.1.0 Added a return value. + * + * @param bool|WP_Error $return Upgrade offer return. + * @param array $plugin Plugin package arguments. + * @return bool|WP_Error The passed in $return param or WP_Error. + */ + public function deactivate_plugin_before_upgrade($return, $plugin) { + + if ( is_wp_error($return) ) //Bypass. + return $return; + + // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it + if ( wp_doing_cron() ) + return $return; + + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; + if ( empty($plugin) ) + return new WP_Error('bad_request', $this->strings['bad_request']); + + if ( is_plugin_active($plugin) ) { + //Deactivate the plugin silently, Prevent deactivation hooks from running. + deactivate_plugins($plugin, true); + } + + return $return; + } + + /** + * Delete the old plugin during an upgrade. + * + * Hooked to the {@see 'upgrader_clear_destination'} filter by + * Plugin_Upgrader::upgrade() and Plugin_Upgrader::bulk_upgrade(). + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param bool|WP_Error $removed + * @param string $local_destination + * @param string $remote_destination + * @param array $plugin + * @return WP_Error|bool + */ + public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { + global $wp_filesystem; + + if ( is_wp_error($removed) ) + return $removed; //Pass errors through. + + $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; + if ( empty($plugin) ) + return new WP_Error('bad_request', $this->strings['bad_request']); + + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) ); + + if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If it's already vanished. + return $removed; + + // If plugin is in its own directory, recursively delete the directory. + if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder + $deleted = $wp_filesystem->delete($this_plugin_dir, true); + else + $deleted = $wp_filesystem->delete($plugins_dir . $plugin); + + if ( ! $deleted ) + return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']); + + return true; + } +} diff --git a/backend/wp-admin/includes/class-theme-installer-skin.php b/backend/wp-admin/includes/class-theme-installer-skin.php new file mode 100644 index 0000000..3d39492 --- /dev/null +++ b/backend/wp-admin/includes/class-theme-installer-skin.php @@ -0,0 +1,103 @@ + 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); + $args = wp_parse_args($args, $defaults); + + $this->type = $args['type']; + $this->api = isset($args['api']) ? $args['api'] : array(); + + parent::__construct($args); + } + + /** + */ + public function before() { + if ( !empty($this->api) ) + $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); + } + + /** + */ + public function after() { + if ( empty($this->upgrader->result['destination_name']) ) + return; + + $theme_info = $this->upgrader->theme_info(); + if ( empty( $theme_info ) ) + return; + + $name = $theme_info->display('Name'); + $stylesheet = $this->upgrader->result['destination_name']; + $template = $theme_info->get_template(); + + $activate_link = add_query_arg( array( + 'action' => 'activate', + 'template' => urlencode( $template ), + 'stylesheet' => urlencode( $stylesheet ), + ), admin_url('themes.php') ); + $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); + + $install_actions = array(); + + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $customize_url = add_query_arg( + array( + 'theme' => urlencode( $stylesheet ), + 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), + ), + admin_url( 'customize.php' ) + ); + $install_actions['preview'] = '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; + } + $install_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; + + if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) + $install_actions['network_enable'] = '' . __( 'Network Enable' ) . ''; + + if ( $this->type == 'web' ) + $install_actions['themes_page'] = '' . __( 'Return to Theme Installer' ) . ''; + elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) + $install_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ''; + + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) + unset( $install_actions['activate'], $install_actions['preview'] ); + + /** + * Filters the list of action links available following a single theme installation. + * + * @since 2.8.0 + * + * @param array $install_actions Array of theme action links. + * @param object $api Object containing WordPress.org API theme data. + * @param string $stylesheet Theme directory name. + * @param WP_Theme $theme_info Theme object. + */ + $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); + if ( ! empty($install_actions) ) + $this->feedback(implode(' | ', (array)$install_actions)); + } +} diff --git a/backend/wp-admin/includes/class-theme-upgrader-skin.php b/backend/wp-admin/includes/class-theme-upgrader-skin.php new file mode 100644 index 0000000..f923757 --- /dev/null +++ b/backend/wp-admin/includes/class-theme-upgrader-skin.php @@ -0,0 +1,89 @@ + '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); + $args = wp_parse_args($args, $defaults); + + $this->theme = $args['theme']; + + parent::__construct($args); + } + + /** + */ + public function after() { + $this->decrement_update_count( 'theme' ); + + $update_actions = array(); + if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { + $name = $theme_info->display('Name'); + $stylesheet = $this->upgrader->result['destination_name']; + $template = $theme_info->get_template(); + + $activate_link = add_query_arg( array( + 'action' => 'activate', + 'template' => urlencode( $template ), + 'stylesheet' => urlencode( $stylesheet ), + ), admin_url('themes.php') ); + $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); + + $customize_url = add_query_arg( + array( + 'theme' => urlencode( $stylesheet ), + 'return' => urlencode( admin_url( 'themes.php' ) ), + ), + admin_url( 'customize.php' ) + ); + if ( get_stylesheet() == $stylesheet ) { + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $update_actions['preview'] = '' . sprintf( __( 'Customize “%s”' ), $name ) . ''; + } + } elseif ( current_user_can( 'switch_themes' ) ) { + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $update_actions['preview'] = '' . sprintf( __( 'Live Preview “%s”' ), $name ) . ''; + } + $update_actions['activate'] = '' . sprintf( __( 'Activate “%s”' ), $name ) . ''; + } + + if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) + unset( $update_actions['preview'], $update_actions['activate'] ); + } + + $update_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ''; + + /** + * Filters the list of action links available following a single theme update. + * + * @since 2.8.0 + * + * @param array $update_actions Array of theme action links. + * @param string $theme Theme directory name. + */ + $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); + + if ( ! empty($update_actions) ) + $this->feedback(implode(' | ', (array)$update_actions)); + } +} diff --git a/backend/wp-admin/includes/class-theme-upgrader.php b/backend/wp-admin/includes/class-theme-upgrader.php new file mode 100644 index 0000000..7e46b5f --- /dev/null +++ b/backend/wp-admin/includes/class-theme-upgrader.php @@ -0,0 +1,593 @@ +strings['up_to_date'] = __('The theme is at the latest version.'); + $this->strings['no_package'] = __('Update package not available.'); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s' ); + $this->strings['unpack_package'] = __('Unpacking the update…'); + $this->strings['remove_old'] = __('Removing the old version of the theme…'); + $this->strings['remove_old_failed'] = __('Could not remove the old theme.'); + $this->strings['process_failed'] = __('Theme update failed.'); + $this->strings['process_success'] = __('Theme updated successfully.'); + } + + /** + * Initialize the installation strings. + * + * @since 2.8.0 + */ + public function install_strings() { + $this->strings['no_package'] = __('Installation package not available.'); + /* translators: %s: package URL */ + $this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '%s' ); + $this->strings['unpack_package'] = __('Unpacking the package…'); + $this->strings['installing_package'] = __('Installing the theme…'); + $this->strings['no_files'] = __('The theme contains no files.'); + $this->strings['process_failed'] = __('Theme installation failed.'); + $this->strings['process_success'] = __('Theme installed successfully.'); + /* translators: 1: theme name, 2: version */ + $this->strings['process_success_specific'] = __('Successfully installed the theme %1$s %2$s.'); + $this->strings['parent_theme_search'] = __('This theme requires a parent theme. Checking if it is installed…'); + /* translators: 1: theme name, 2: version */ + $this->strings['parent_theme_prepare_install'] = __('Preparing to install %1$s %2$s…'); + /* translators: 1: theme name, 2: version */ + $this->strings['parent_theme_currently_installed'] = __('The parent theme, %1$s %2$s, is currently installed.'); + /* translators: 1: theme name, 2: version */ + $this->strings['parent_theme_install_success'] = __('Successfully installed the parent theme, %1$s %2$s.'); + /* translators: %s: theme name */ + $this->strings['parent_theme_not_found'] = sprintf( __( 'The parent theme could not be found. You will need to install the parent theme, %s, before you can use this child theme.' ), '%s' ); + } + + /** + * Check if a child theme is being installed and we need to install its parent. + * + * Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::install(). + * + * @since 3.4.0 + * + * @param bool $install_result + * @param array $hook_extra + * @param array $child_result + * @return type + */ + public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { + // Check to see if we need to install a parent theme + $theme_info = $this->theme_info(); + + if ( ! $theme_info->parent() ) + return $install_result; + + $this->skin->feedback( 'parent_theme_search' ); + + if ( ! $theme_info->parent()->errors() ) { + $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') ); + // We already have the theme, fall through. + return $install_result; + } + + // We don't have the parent theme, let's install it. + $api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. + + if ( ! $api || is_wp_error($api) ) { + $this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') ); + // Don't show activate or preview actions after installation + add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') ); + return $install_result; + } + + // Backup required data we're going to override: + $child_api = $this->skin->api; + $child_success_message = $this->strings['process_success']; + + // Override them + $this->skin->api = $api; + $this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version); + + $this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version); + + add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme. + + // Install the parent theme + $parent_result = $this->run( array( + 'package' => $api->download_link, + 'destination' => get_theme_root(), + 'clear_destination' => false, //Do not overwrite files. + 'clear_working' => true + ) ); + + if ( is_wp_error($parent_result) ) + add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') ); + + // Start cleaning up after the parents installation + remove_filter('install_theme_complete_actions', '__return_false', 999); + + // Reset child's result and data + $this->result = $child_result; + $this->skin->api = $child_api; + $this->strings['process_success'] = $child_success_message; + + return $install_result; + } + + /** + * Don't display the activate and preview actions to the user. + * + * Hooked to the {@see 'install_theme_complete_actions'} filter by + * Theme_Upgrader::check_parent_theme_filter() when installing + * a child theme and installing the parent theme fails. + * + * @since 3.4.0 + * + * @param array $actions Preview actions. + * @return array + */ + public function hide_activate_preview_actions( $actions ) { + unset($actions['activate'], $actions['preview']); + return $actions; + } + + /** + * Install a theme package. + * + * @since 2.8.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. + * + * @param string $package The full local path or URI of the package. + * @param array $args { + * Optional. Other arguments for installing a theme package. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the updates cache if successful. + * Default true. + * } + * + * @return bool|WP_Error True if the installation was successful, false or a WP_Error object otherwise. + */ + public function install( $package, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->install_strings(); + + add_filter('upgrader_source_selection', array($this, 'check_package') ); + add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3); + if ( $parsed_args['clear_update_cache'] ) { + // Clear cache so wp_update_themes() knows about the new theme. + add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); + } + + $this->run( array( + 'package' => $package, + 'destination' => get_theme_root(), + 'clear_destination' => false, //Do not overwrite files. + 'clear_working' => true, + 'hook_extra' => array( + 'type' => 'theme', + 'action' => 'install', + ), + ) ); + + remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); + remove_filter('upgrader_source_selection', array($this, 'check_package') ); + remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter')); + + if ( ! $this->result || is_wp_error($this->result) ) + return $this->result; + + // Refresh the Theme Update information + wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); + + return true; + } + + /** + * Upgrade a theme. + * + * @since 2.8.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. + * + * @param string $theme The theme slug. + * @param array $args { + * Optional. Other arguments for upgrading a theme. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the update cache if successful. + * Default true. + * } + * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. + */ + public function upgrade( $theme, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->upgrade_strings(); + + // Is an update available? + $current = get_site_transient( 'update_themes' ); + if ( !isset( $current->response[ $theme ] ) ) { + $this->skin->before(); + $this->skin->set_result(false); + $this->skin->error( 'up_to_date' ); + $this->skin->after(); + return false; + } + + $r = $current->response[ $theme ]; + + add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); + add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); + add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); + if ( $parsed_args['clear_update_cache'] ) { + // Clear cache so wp_update_themes() knows about the new theme. + add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); + } + + $this->run( array( + 'package' => $r['package'], + 'destination' => get_theme_root( $theme ), + 'clear_destination' => true, + 'clear_working' => true, + 'hook_extra' => array( + 'theme' => $theme, + 'type' => 'theme', + 'action' => 'update', + ), + ) ); + + remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); + remove_filter('upgrader_pre_install', array($this, 'current_before')); + remove_filter('upgrader_post_install', array($this, 'current_after')); + remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); + + if ( ! $this->result || is_wp_error($this->result) ) + return $this->result; + + wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); + + return true; + } + + /** + * Upgrade several themes at once. + * + * @since 3.0.0 + * @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional. + * + * @param array $themes The theme slugs. + * @param array $args { + * Optional. Other arguments for upgrading several themes at once. Default empty array. + * + * @type bool $clear_update_cache Whether to clear the update cache if successful. + * Default true. + * } + * @return array[]|false An array of results, or false if unable to connect to the filesystem. + */ + public function bulk_upgrade( $themes, $args = array() ) { + + $defaults = array( + 'clear_update_cache' => true, + ); + $parsed_args = wp_parse_args( $args, $defaults ); + + $this->init(); + $this->bulk = true; + $this->upgrade_strings(); + + $current = get_site_transient( 'update_themes' ); + + add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); + add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); + add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); + + $this->skin->header(); + + // Connect to the Filesystem first. + $res = $this->fs_connect( array(WP_CONTENT_DIR) ); + if ( ! $res ) { + $this->skin->footer(); + return false; + } + + $this->skin->bulk_header(); + + // Only start maintenance mode if: + // - running Multisite and there are one or more themes specified, OR + // - a theme with an update available is currently in use. + // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. + $maintenance = ( is_multisite() && ! empty( $themes ) ); + foreach ( $themes as $theme ) + $maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template(); + if ( $maintenance ) + $this->maintenance_mode(true); + + $results = array(); + + $this->update_count = count($themes); + $this->update_current = 0; + foreach ( $themes as $theme ) { + $this->update_current++; + + $this->skin->theme_info = $this->theme_info($theme); + + if ( !isset( $current->response[ $theme ] ) ) { + $this->skin->set_result(true); + $this->skin->before(); + $this->skin->feedback( 'up_to_date' ); + $this->skin->after(); + $results[$theme] = true; + continue; + } + + // Get the URL to the zip file + $r = $current->response[ $theme ]; + + $result = $this->run( array( + 'package' => $r['package'], + 'destination' => get_theme_root( $theme ), + 'clear_destination' => true, + 'clear_working' => true, + 'is_multi' => true, + 'hook_extra' => array( + 'theme' => $theme + ), + ) ); + + $results[$theme] = $this->result; + + // Prevent credentials auth screen from displaying multiple times + if ( false === $result ) + break; + } //end foreach $plugins + + $this->maintenance_mode(false); + + // Refresh the Theme Update information + wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); + + /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ + do_action( 'upgrader_process_complete', $this, array( + 'action' => 'update', + 'type' => 'theme', + 'bulk' => true, + 'themes' => $themes, + ) ); + + $this->skin->bulk_footer(); + + $this->skin->footer(); + + // Cleanup our hooks, in case something else does a upgrade on this connection. + remove_filter('upgrader_pre_install', array($this, 'current_before')); + remove_filter('upgrader_post_install', array($this, 'current_after')); + remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); + + return $results; + } + + /** + * Check that the package source contains a valid theme. + * + * Hooked to the {@see 'upgrader_source_selection'} filter by Theme_Upgrader::install(). + * It will return an error if the theme doesn't have style.css or index.php + * files. + * + * @since 3.3.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $source The full path to the package source. + * @return string|WP_Error The source or a WP_Error. + */ + public function check_package( $source ) { + global $wp_filesystem; + + if ( is_wp_error($source) ) + return $source; + + // Check the folder contains a valid theme + $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source); + if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation. + return $source; + + // A proper archive should have a style.css file in the single subdirectory + if ( ! file_exists( $working_directory . 'style.css' ) ) { + return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'], + /* translators: %s: style.css */ + sprintf( __( 'The theme is missing the %s stylesheet.' ), + 'style.css' + ) + ); + } + + $info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) ); + + if ( empty( $info['Name'] ) ) { + return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'], + /* translators: %s: style.css */ + sprintf( __( 'The %s stylesheet doesn’t contain a valid theme header.' ), + 'style.css' + ) + ); + } + + // If it's not a child theme, it must have at least an index.php to be legit. + if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) { + return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'], + /* translators: %s: index.php */ + sprintf( __( 'The theme is missing the %s file.' ), + 'index.php' + ) + ); + } + + return $source; + } + + /** + * Turn on maintenance mode before attempting to upgrade the current theme. + * + * Hooked to the {@see 'upgrader_pre_install'} filter by Theme_Upgrader::upgrade() and + * Theme_Upgrader::bulk_upgrade(). + * + * @since 2.8.0 + * + * @param bool|WP_Error $return + * @param array $theme + * @return bool|WP_Error + */ + public function current_before($return, $theme) { + if ( is_wp_error($return) ) + return $return; + + $theme = isset($theme['theme']) ? $theme['theme'] : ''; + + if ( $theme != get_stylesheet() ) //If not current + return $return; + //Change to maintenance mode now. + if ( ! $this->bulk ) + $this->maintenance_mode(true); + + return $return; + } + + /** + * Turn off maintenance mode after upgrading the current theme. + * + * Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::upgrade() + * and Theme_Upgrader::bulk_upgrade(). + * + * @since 2.8.0 + * + * @param bool|WP_Error $return + * @param array $theme + * @return bool|WP_Error + */ + public function current_after($return, $theme) { + if ( is_wp_error($return) ) + return $return; + + $theme = isset($theme['theme']) ? $theme['theme'] : ''; + + if ( $theme != get_stylesheet() ) // If not current + return $return; + + // Ensure stylesheet name hasn't changed after the upgrade: + if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) { + wp_clean_themes_cache(); + $stylesheet = $this->result['destination_name']; + switch_theme( $stylesheet ); + } + + //Time to remove maintenance mode + if ( ! $this->bulk ) + $this->maintenance_mode(false); + return $return; + } + + /** + * Delete the old theme during an upgrade. + * + * Hooked to the {@see 'upgrader_clear_destination'} filter by Theme_Upgrader::upgrade() + * and Theme_Upgrader::bulk_upgrade(). + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param bool $removed + * @param string $local_destination + * @param string $remote_destination + * @param array $theme + * @return bool + */ + public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) { + global $wp_filesystem; + + if ( is_wp_error( $removed ) ) + return $removed; // Pass errors through. + + if ( ! isset( $theme['theme'] ) ) + return $removed; + + $theme = $theme['theme']; + $themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) ); + if ( $wp_filesystem->exists( $themes_dir . $theme ) ) { + if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) + return false; + } + + return true; + } + + /** + * Get the WP_Theme object for a theme. + * + * @since 2.8.0 + * @since 3.0.0 The `$theme` argument was added. + * + * @param string $theme The directory name of the theme. This is optional, and if not supplied, + * the directory name from the last result will be used. + * @return WP_Theme|false The theme's info object, or false `$theme` is not supplied + * and the last result isn't set. + */ + public function theme_info($theme = null) { + + if ( empty($theme) ) { + if ( !empty($this->result['destination_name']) ) + $theme = $this->result['destination_name']; + else + return false; + } + return wp_get_theme( $theme ); + } + +} diff --git a/backend/wp-admin/includes/class-walker-category-checklist.php b/backend/wp-admin/includes/class-walker-category-checklist.php new file mode 100644 index 0000000..cd5e157 --- /dev/null +++ b/backend/wp-admin/includes/class-walker-category-checklist.php @@ -0,0 +1,125 @@ + 'parent', 'id' => 'term_id'); //TODO: decouple this + + /** + * Starts the list before the elements are added. + * + * @see Walker:start_lvl() + * + * @since 2.5.1 + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
      \n"; + } + + /** + * Ends the list of after the elements are added. + * + * @see Walker::end_lvl() + * + * @since 2.5.1 + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat("\t", $depth); + $output .= "$indent
    \n"; + } + + /** + * Start the element output. + * + * @see Walker::start_el() + * + * @since 2.5.1 + * + * @param string $output Used to append additional content (passed by reference). + * @param object $category The current term object. + * @param int $depth Depth of the term in reference to parents. Default 0. + * @param array $args An array of arguments. @see wp_terms_checklist() + * @param int $id ID of the current term. + */ + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + if ( empty( $args['taxonomy'] ) ) { + $taxonomy = 'category'; + } else { + $taxonomy = $args['taxonomy']; + } + + if ( $taxonomy == 'category' ) { + $name = 'post_category'; + } else { + $name = 'tax_input[' . $taxonomy . ']'; + } + + $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; + $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : ''; + + $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; + + if ( ! empty( $args['list_only'] ) ) { + $aria_checked = 'false'; + $inner_class = 'category'; + + if ( in_array( $category->term_id, $args['selected_cats'] ) ) { + $inner_class .= ' selected'; + $aria_checked = 'true'; + } + + /** This filter is documented in wp-includes/category-template.php */ + $output .= "\n" . '' . + ''; + } else { + /** This filter is documented in wp-includes/category-template.php */ + $output .= "\n
  • " . + ''; + } + } + + /** + * Ends the element output, if needed. + * + * @see Walker::end_el() + * + * @since 2.5.1 + * + * @param string $output Used to append additional content (passed by reference). + * @param object $category The current term object. + * @param int $depth Depth of the term in reference to parents. Default 0. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function end_el( &$output, $category, $depth = 0, $args = array() ) { + $output .= "
  • \n"; + } +} diff --git a/backend/wp-admin/includes/class-walker-nav-menu-checklist.php b/backend/wp-admin/includes/class-walker-nav-menu-checklist.php new file mode 100644 index 0000000..a4d8018 --- /dev/null +++ b/backend/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -0,0 +1,117 @@ +db_fields = $fields; + } + } + + /** + * Starts the list before the elements are added. + * + * @see Walker_Nav_Menu::start_lvl() + * + * @since 3.0.0 + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of page. Used for padding. + * @param array $args Not used. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat( "\t", $depth ); + $output .= "\n$indent
      \n"; + } + + /** + * Ends the list of after the elements are added. + * + * @see Walker_Nav_Menu::end_lvl() + * + * @since 3.0.0 + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of page. Used for padding. + * @param array $args Not used. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat( "\t", $depth ); + $output .= "\n$indent
    "; + } + + /** + * Start the element output. + * + * @see Walker_Nav_Menu::start_el() + * + * @since 3.0.0 + * + * @global int $_nav_menu_placeholder + * + * @param string $output Used to append additional content (passed by reference). + * @param object $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. + * @param int $id Not used. + */ + public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { + global $_nav_menu_placeholder; + + $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; + $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; + $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; + + $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; + + $output .= $indent . '
  • '; + $output .= ''; + + // Menu item hidden fields + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + $output .= ''; + } + +} // Walker_Nav_Menu_Checklist diff --git a/backend/wp-admin/includes/class-walker-nav-menu-edit.php b/backend/wp-admin/includes/class-walker-nav-menu-edit.php new file mode 100644 index 0000000..36ced40 --- /dev/null +++ b/backend/wp-admin/includes/class-walker-nav-menu-edit.php @@ -0,0 +1,241 @@ + $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; + + ob_start(); + $item_id = esc_attr( $item->ID ); + $removed_args = array( + 'action', + 'customlink-tab', + 'edit-menu-item', + 'menu-item', + 'page-tab', + '_wpnonce', + ); + + $original_title = false; + if ( 'taxonomy' == $item->type ) { + $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); + if ( is_wp_error( $original_title ) ) + $original_title = false; + } elseif ( 'post_type' == $item->type ) { + $original_object = get_post( $item->object_id ); + $original_title = get_the_title( $original_object->ID ); + } elseif ( 'post_type_archive' == $item->type ) { + $original_object = get_post_type_object( $item->object ); + if ( $original_object ) { + $original_title = $original_object->labels->archives; + } + } + + $classes = array( + 'menu-item menu-item-depth-' . $depth, + 'menu-item-' . esc_attr( $item->object ), + 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'), + ); + + $title = $item->title; + + if ( ! empty( $item->_invalid ) ) { + $classes[] = 'menu-item-invalid'; + /* translators: %s: title of menu item which is invalid */ + $title = sprintf( __( '%s (Invalid)' ), $item->title ); + } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) { + $classes[] = 'pending'; + /* translators: %s: title of menu item in draft status */ + $title = sprintf( __('%s (Pending)'), $item->title ); + } + + $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; + + $submenu_text = ''; + if ( 0 == $depth ) + $submenu_text = 'style="display: none;"'; + + ?> +
  • '; + + if ( $comment->comment_parent ) { + $parent = get_comment( $comment->comment_parent ); + if ( $parent ) { + $parent_link = esc_url( get_comment_link( $parent ) ); + $name = get_comment_author( $parent ); + printf( + /* translators: %s: comment link */ + __( 'In reply to %s.' ), + '' . $name . '' + ); + } + } + + comment_text( $comment ); + if ( $this->user_can ) { ?> + + 50 ) { + $author_url_display = wp_html_excerpt( $author_url_display, 49, '…' ); + } + + echo ""; comment_author( $comment ); echo '
    '; + if ( ! empty( $author_url_display ) ) { + printf( '%s
    ', esc_url( $author_url ), esc_html( $author_url_display ) ); + } + + if ( $this->user_can ) { + if ( ! empty( $comment->comment_author_email ) ) { + /** This filter is documented in wp-includes/comment-template.php */ + $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); + + if ( ! empty( $email ) && '@' !== $email ) { + printf( '%2$s
    ', esc_url( 'mailto:' . $email ), esc_html( $email ) ); + } + } + + $author_ip = get_comment_author_IP( $comment ); + if ( $author_ip ) { + $author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), admin_url( 'edit-comments.php' ) ); + if ( 'spam' === $comment_status ) { + $author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url ); + } + printf( '%2$s', esc_url( $author_ip_url ), esc_html( $author_ip ) ); + } + } + } + + /** + * + * @param WP_Comment $comment The comment object. + */ + public function column_date( $comment ) { + /* translators: 1: comment date, 2: comment time */ + $submitted = sprintf( __( '%1$s at %2$s' ), + /* translators: comment date format. See https://secure.php.net/date */ + get_comment_date( __( 'Y/m/d' ), $comment ), + get_comment_date( __( 'g:i a' ), $comment ) + ); + + echo ''; + } + + /** + * + * @param WP_Comment $comment The comment object. + */ + public function column_response( $comment ) { + $post = get_post(); + + if ( ! $post ) { + return; + } + + if ( isset( $this->pending_count[$post->ID] ) ) { + $pending_comments = $this->pending_count[$post->ID]; + } else { + $_pending_count_temp = get_pending_comments_num( array( $post->ID ) ); + $pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID]; + } + + if ( current_user_can( 'edit_post', $post->ID ) ) { + $post_link = ""; + $post_link .= esc_html( get_the_title( $post->ID ) ) . ''; + } else { + $post_link = esc_html( get_the_title( $post->ID ) ); + } + + echo ''; + } + + /** + * + * @param WP_Comment $comment The comment object. + * @param string $column_name The custom column's name. + */ + public function column_default( $comment, $column_name ) { + /** + * Fires when the default column output is displayed for a single row. + * + * @since 2.8.0 + * + * @param string $column_name The custom column's name. + * @param int $comment->comment_ID The custom column's unique ID number. + */ + do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); + } +} diff --git a/backend/wp-admin/includes/class-wp-community-events.php b/backend/wp-admin/includes/class-wp-community-events.php new file mode 100644 index 0000000..bbb743d --- /dev/null +++ b/backend/wp-admin/includes/class-wp-community-events.php @@ -0,0 +1,442 @@ +user_id = absint( $user_id ); + $this->user_location = $user_location; + } + + /** + * Gets data about events near a particular location. + * + * Cached events will be immediately returned if the `user_location` property + * is set for the current user, and cached events exist for that location. + * + * Otherwise, this method sends a request to the w.org Events API with location + * data. The API will send back a recognized location based on the data, along + * with nearby events. + * + * The browser's request for events is proxied with this method, rather + * than having the browser make the request directly to api.wordpress.org, + * because it allows results to be cached server-side and shared with other + * users and sites in the network. This makes the process more efficient, + * since increasing the number of visits that get cached data means users + * don't have to wait as often; if the user's browser made the request + * directly, it would also need to make a second request to WP in order to + * pass the data for caching. Having WP make the request also introduces + * the opportunity to anonymize the IP before sending it to w.org, which + * mitigates possible privacy concerns. + * + * @since 4.8.0 + * + * @param string $location_search Optional. City name to help determine the location. + * e.g., "Seattle". Default empty string. + * @param string $timezone Optional. Timezone to help determine the location. + * Default empty string. + * @return array|WP_Error A WP_Error on failure; an array with location and events on + * success. + */ + public function get_events( $location_search = '', $timezone = '' ) { + $cached_events = $this->get_cached_events(); + + if ( ! $location_search && $cached_events ) { + return $cached_events; + } + + // include an unmodified $wp_version + include( ABSPATH . WPINC . '/version.php' ); + + $api_url = 'http://api.wordpress.org/events/1.0/'; + $request_args = $this->get_request_args( $location_search, $timezone ); + $request_args['user-agent'] = 'WordPress/' . $wp_version . '; ' . home_url( '/' ); + + if ( wp_http_supports( array( 'ssl' ) ) ) { + $api_url = set_url_scheme( $api_url, 'https' ); + } + + $response = wp_remote_get( $api_url, $request_args ); + $response_code = wp_remote_retrieve_response_code( $response ); + $response_body = json_decode( wp_remote_retrieve_body( $response ), true ); + $response_error = null; + + if ( is_wp_error( $response ) ) { + $response_error = $response; + } elseif ( 200 !== $response_code ) { + $response_error = new WP_Error( + 'api-error', + /* translators: %d: numeric HTTP status code, e.g. 400, 403, 500, 504, etc. */ + sprintf( __( 'Invalid API response code (%d)' ), $response_code ) + ); + } elseif ( ! isset( $response_body['location'], $response_body['events'] ) ) { + $response_error = new WP_Error( + 'api-invalid-response', + isset( $response_body['error'] ) ? $response_body['error'] : __( 'Unknown API error.' ) + ); + } + + if ( is_wp_error( $response_error ) ) { + return $response_error; + } else { + $expiration = false; + + if ( isset( $response_body['ttl'] ) ) { + $expiration = $response_body['ttl']; + unset( $response_body['ttl'] ); + } + + /* + * The IP in the response is usually the same as the one that was sent + * in the request, but in some cases it is different. In those cases, + * it's important to reset it back to the IP from the request. + * + * For example, if the IP sent in the request is private (e.g., 192.168.1.100), + * then the API will ignore that and use the corresponding public IP instead, + * and the public IP will get returned. If the public IP were saved, though, + * then get_cached_events() would always return `false`, because the transient + * would be generated based on the public IP when saving the cache, but generated + * based on the private IP when retrieving the cache. + */ + if ( ! empty( $response_body['location']['ip'] ) ) { + $response_body['location']['ip'] = $request_args['body']['ip']; + } + + /* + * The API doesn't return a description for latitude/longitude requests, + * but the description is already saved in the user location, so that + * one can be used instead. + */ + if ( $this->coordinates_match( $request_args['body'], $response_body['location'] ) && empty( $response_body['location']['description'] ) ) { + $response_body['location']['description'] = $this->user_location['description']; + } + + $this->cache_events( $response_body, $expiration ); + + $response_body = $this->trim_events( $response_body ); + $response_body = $this->format_event_data_time( $response_body ); + + return $response_body; + } + } + + /** + * Builds an array of args to use in an HTTP request to the w.org Events API. + * + * @since 4.8.0 + * + * @param string $search Optional. City search string. Default empty string. + * @param string $timezone Optional. Timezone string. Default empty string. + * @return array The request args. + */ + protected function get_request_args( $search = '', $timezone = '' ) { + $args = array( + 'number' => 5, // Get more than three in case some get trimmed out. + 'ip' => self::get_unsafe_client_ip(), + ); + + /* + * Include the minimal set of necessary arguments, in order to increase the + * chances of a cache-hit on the API side. + */ + if ( empty( $search ) && isset( $this->user_location['latitude'], $this->user_location['longitude'] ) ) { + $args['latitude'] = $this->user_location['latitude']; + $args['longitude'] = $this->user_location['longitude']; + } else { + $args['locale'] = get_user_locale( $this->user_id ); + + if ( $timezone ) { + $args['timezone'] = $timezone; + } + + if ( $search ) { + $args['location'] = $search; + } + } + + // Wrap the args in an array compatible with the second parameter of `wp_remote_get()`. + return array( + 'body' => $args + ); + } + + /** + * Determines the user's actual IP address and attempts to partially + * anonymize an IP address by converting it to a network ID. + * + * Geolocating the network ID usually returns a similar location as the + * actual IP, but provides some privacy for the user. + * + * $_SERVER['REMOTE_ADDR'] cannot be used in all cases, such as when the user + * is making their request through a proxy, or when the web server is behind + * a proxy. In those cases, $_SERVER['REMOTE_ADDR'] is set to the proxy address rather + * than the user's actual address. + * + * Modified from https://stackoverflow.com/a/2031935/450127, MIT license. + * Modified from https://github.com/geertw/php-ip-anonymizer, MIT license. + * + * SECURITY WARNING: This function is _NOT_ intended to be used in + * circumstances where the authenticity of the IP address matters. This does + * _NOT_ guarantee that the returned address is valid or accurate, and it can + * be easily spoofed. + * + * @since 4.8.0 + * + * @return false|string The anonymized address on success; the given address + * or false on failure. + */ + public static function get_unsafe_client_ip() { + $client_ip = $netmask = false; + + // In order of preference, with the best ones for this purpose first. + $address_headers = array( + 'HTTP_CLIENT_IP', + 'HTTP_X_FORWARDED_FOR', + 'HTTP_X_FORWARDED', + 'HTTP_X_CLUSTER_CLIENT_IP', + 'HTTP_FORWARDED_FOR', + 'HTTP_FORWARDED', + 'REMOTE_ADDR', + ); + + foreach ( $address_headers as $header ) { + if ( array_key_exists( $header, $_SERVER ) ) { + /* + * HTTP_X_FORWARDED_FOR can contain a chain of comma-separated + * addresses. The first one is the original client. It can't be + * trusted for authenticity, but we don't need to for this purpose. + */ + $address_chain = explode( ',', $_SERVER[ $header ] ); + $client_ip = trim( $address_chain[0] ); + + break; + } + } + + if ( ! $client_ip ) { + return false; + } + + $anon_ip = wp_privacy_anonymize_ip( $client_ip, true ); + + if ( '0.0.0.0' === $anon_ip || '::' === $anon_ip ) { + return false; + } + + return $anon_ip; + } + + /** + * Test if two pairs of latitude/longitude coordinates match each other. + * + * @since 4.8.0 + * + * @param array $a The first pair, with indexes 'latitude' and 'longitude'. + * @param array $b The second pair, with indexes 'latitude' and 'longitude'. + * @return bool True if they match, false if they don't. + */ + protected function coordinates_match( $a, $b ) { + if ( ! isset( $a['latitude'], $a['longitude'], $b['latitude'], $b['longitude'] ) ) { + return false; + } + + return $a['latitude'] === $b['latitude'] && $a['longitude'] === $b['longitude']; + } + + /** + * Generates a transient key based on user location. + * + * This could be reduced to a one-liner in the calling functions, but it's + * intentionally a separate function because it's called from multiple + * functions, and having it abstracted keeps the logic consistent and DRY, + * which is less prone to errors. + * + * @since 4.8.0 + * + * @param array $location Should contain 'latitude' and 'longitude' indexes. + * @return bool|string false on failure, or a string on success. + */ + protected function get_events_transient_key( $location ) { + $key = false; + + if ( isset( $location['ip'] ) ) { + $key = 'community-events-' . md5( $location['ip'] ); + } else if ( isset( $location['latitude'], $location['longitude'] ) ) { + $key = 'community-events-' . md5( $location['latitude'] . $location['longitude'] ); + } + + return $key; + } + + /** + * Caches an array of events data from the Events API. + * + * @since 4.8.0 + * + * @param array $events Response body from the API request. + * @param int|bool $expiration Optional. Amount of time to cache the events. Defaults to false. + * @return bool true if events were cached; false if not. + */ + protected function cache_events( $events, $expiration = false ) { + $set = false; + $transient_key = $this->get_events_transient_key( $events['location'] ); + $cache_expiration = $expiration ? absint( $expiration ) : HOUR_IN_SECONDS * 12; + + if ( $transient_key ) { + $set = set_site_transient( $transient_key, $events, $cache_expiration ); + } + + return $set; + } + + /** + * Gets cached events. + * + * @since 4.8.0 + * + * @return false|array false on failure; an array containing `location` + * and `events` items on success. + */ + public function get_cached_events() { + $cached_response = get_site_transient( $this->get_events_transient_key( $this->user_location ) ); + $cached_response = $this->trim_events( $cached_response ); + + return $this->format_event_data_time( $cached_response ); + } + + /** + * Adds formatted date and time items for each event in an API response. + * + * This has to be called after the data is pulled from the cache, because + * the cached events are shared by all users. If it was called before storing + * the cache, then all users would see the events in the localized data/time + * of the user who triggered the cache refresh, rather than their own. + * + * @since 4.8.0 + * + * @param array $response_body The response which contains the events. + * @return array The response with dates and times formatted. + */ + protected function format_event_data_time( $response_body ) { + if ( isset( $response_body['events'] ) ) { + foreach ( $response_body['events'] as $key => $event ) { + $timestamp = strtotime( $event['date'] ); + + /* + * The `date_format` option is not used because it's important + * in this context to keep the day of the week in the formatted date, + * so that users can tell at a glance if the event is on a day they + * are available, without having to open the link. + */ + /* translators: Date format for upcoming events on the dashboard. Include the day of the week. See https://secure.php.net/date. */ + $response_body['events'][ $key ]['formatted_date'] = date_i18n( __( 'l, M j, Y' ), $timestamp ); + $response_body['events'][ $key ]['formatted_time'] = date_i18n( get_option( 'time_format' ), $timestamp ); + } + } + + return $response_body; + } + + /** + * Discards expired events, and reduces the remaining list. + * + * @since 4.8.0 + * + * @param array $response_body The response body which contains the events. + * @return array The response body with events trimmed. + */ + protected function trim_events( $response_body ) { + if ( isset( $response_body['events'] ) ) { + $current_timestamp = current_time( 'timestamp' ); + + foreach ( $response_body['events'] as $key => $event ) { + // Skip WordCamps, because they might be multi-day events. + if ( 'meetup' !== $event['type'] ) { + continue; + } + + $event_timestamp = strtotime( $event['date'] ); + + if ( $current_timestamp > $event_timestamp && ( $current_timestamp - $event_timestamp ) > DAY_IN_SECONDS ) { + unset( $response_body['events'][ $key ] ); + } + } + + $response_body['events'] = array_slice( $response_body['events'], 0, 3 ); + } + + return $response_body; + } + + /** + * Logs responses to Events API requests. + * + * @since 4.8.0 + * @deprecated 4.9.0 Use a plugin instead. See #41217 for an example. + * + * @param string $message A description of what occurred. + * @param array $details Details that provide more context for the + * log entry. + */ + protected function maybe_log_events_response( $message, $details ) { + _deprecated_function( __METHOD__, '4.9.0' ); + + if ( ! WP_DEBUG_LOG ) { + return; + } + + error_log( sprintf( + '%s: %s. Details: %s', + __METHOD__, + trim( $message, '.' ), + wp_json_encode( $details ) + ) ); + } +} diff --git a/backend/wp-admin/includes/class-wp-filesystem-base.php b/backend/wp-admin/includes/class-wp-filesystem-base.php new file mode 100644 index 0000000..0611305 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-filesystem-base.php @@ -0,0 +1,801 @@ +find_folder(ABSPATH); + // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. + if ( ! $folder && $this->is_dir( '/' . WPINC ) ) + $folder = '/'; + return $folder; + } + + /** + * Return the path on the remote filesystem of WP_CONTENT_DIR. + * + * @since 2.7.0 + * + * @return string The location of the remote path. + */ + public function wp_content_dir() { + return $this->find_folder(WP_CONTENT_DIR); + } + + /** + * Return the path on the remote filesystem of WP_PLUGIN_DIR. + * + * @since 2.7.0 + * + * @return string The location of the remote path. + */ + public function wp_plugins_dir() { + return $this->find_folder(WP_PLUGIN_DIR); + } + + /** + * Return the path on the remote filesystem of the Themes Directory. + * + * @since 2.7.0 + * + * @param string $theme The Theme stylesheet or template for the directory. + * @return string The location of the remote path. + */ + public function wp_themes_dir( $theme = false ) { + $theme_root = get_theme_root( $theme ); + + // Account for relative theme roots + if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) + $theme_root = WP_CONTENT_DIR . $theme_root; + + return $this->find_folder( $theme_root ); + } + + /** + * Return the path on the remote filesystem of WP_LANG_DIR. + * + * @since 3.2.0 + * + * @return string The location of the remote path. + */ + public function wp_lang_dir() { + return $this->find_folder(WP_LANG_DIR); + } + + /** + * Locate a folder on the remote filesystem. + * + * @since 2.5.0 + * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead. + * @see WP_Filesystem::abspath() + * @see WP_Filesystem::wp_content_dir() + * @see WP_Filesystem::wp_plugins_dir() + * @see WP_Filesystem::wp_themes_dir() + * @see WP_Filesystem::wp_lang_dir() + * + * @param string $base The folder to start searching from. + * @param bool $echo True to display debug information. + * Default false. + * @return string The location of the remote path. + */ + public function find_base_dir( $base = '.', $echo = false ) { + _deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); + $this->verbose = $echo; + return $this->abspath(); + } + + /** + * Locate a folder on the remote filesystem. + * + * @since 2.5.0 + * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead. + * @see WP_Filesystem::abspath() + * @see WP_Filesystem::wp_content_dir() + * @see WP_Filesystem::wp_plugins_dir() + * @see WP_Filesystem::wp_themes_dir() + * @see WP_Filesystem::wp_lang_dir() + * + * @param string $base The folder to start searching from. + * @param bool $echo True to display debug information. + * @return string The location of the remote path. + */ + public function get_base_dir( $base = '.', $echo = false ) { + _deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' ); + $this->verbose = $echo; + return $this->abspath(); + } + + /** + * Locate a folder on the remote filesystem. + * + * Assumes that on Windows systems, Stripping off the Drive + * letter is OK Sanitizes \\ to / in windows filepaths. + * + * @since 2.7.0 + * + * @param string $folder the folder to locate. + * @return string|false The location of the remote path, false on failure. + */ + public function find_folder( $folder ) { + if ( isset( $this->cache[ $folder ] ) ) + return $this->cache[ $folder ]; + + if ( stripos($this->method, 'ftp') !== false ) { + $constant_overrides = array( + 'FTP_BASE' => ABSPATH, + 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, + 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR, + 'FTP_LANG_DIR' => WP_LANG_DIR + ); + + // Direct matches ( folder = CONSTANT/ ) + foreach ( $constant_overrides as $constant => $dir ) { + if ( ! defined( $constant ) ) + continue; + if ( $folder === $dir ) + return trailingslashit( constant( $constant ) ); + } + + // Prefix Matches ( folder = CONSTANT/subdir ) + foreach ( $constant_overrides as $constant => $dir ) { + if ( ! defined( $constant ) ) + continue; + if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir + $potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder ); + $potential_folder = trailingslashit( $potential_folder ); + + if ( $this->is_dir( $potential_folder ) ) { + $this->cache[ $folder ] = $potential_folder; + return $potential_folder; + } + } + } + } elseif ( 'direct' == $this->method ) { + $folder = str_replace('\\', '/', $folder); // Windows path sanitisation + return trailingslashit($folder); + } + + $folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there. + $folder = str_replace('\\', '/', $folder); // Windows path sanitisation + + if ( isset($this->cache[ $folder ] ) ) + return $this->cache[ $folder ]; + + if ( $this->exists($folder) ) { // Folder exists at that absolute path. + $folder = trailingslashit($folder); + $this->cache[ $folder ] = $folder; + return $folder; + } + if ( $return = $this->search_for_folder($folder) ) + $this->cache[ $folder ] = $return; + return $return; + } + + /** + * Locate a folder on the remote filesystem. + * + * Expects Windows sanitized path. + * + * @since 2.7.0 + * + * @param string $folder The folder to locate. + * @param string $base The folder to start searching from. + * @param bool $loop If the function has recursed, Internal use only. + * @return string|false The location of the remote path, false to cease looping. + */ + public function search_for_folder( $folder, $base = '.', $loop = false ) { + if ( empty( $base ) || '.' == $base ) + $base = trailingslashit($this->cwd()); + + $folder = untrailingslashit($folder); + + if ( $this->verbose ) { + /* translators: 1: folder to locate, 2: folder to start searching from */ + printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "
    \n", $folder, $base ); + } + + $folder_parts = explode('/', $folder); + $folder_part_keys = array_keys( $folder_parts ); + $last_index = array_pop( $folder_part_keys ); + $last_path = $folder_parts[ $last_index ]; + + $files = $this->dirlist( $base ); + + foreach ( $folder_parts as $index => $key ) { + if ( $index == $last_index ) + continue; // We want this to be caught by the next code block. + + /* + * Working from /home/ to /user/ to /wordpress/ see if that file exists within + * the current folder, If it's found, change into it and follow through looking + * for it. If it cant find WordPress down that route, it'll continue onto the next + * folder level, and see if that matches, and so on. If it reaches the end, and still + * cant find it, it'll return false for the entire function. + */ + if ( isset($files[ $key ]) ){ + + // Let's try that folder: + $newdir = trailingslashit(path_join($base, $key)); + if ( $this->verbose ) { + /* translators: %s: directory name */ + printf( "\n" . __( 'Changing to %s' ) . "
    \n", $newdir ); + } + + // Only search for the remaining path tokens in the directory, not the full path again. + $newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) ); + if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) ) + return $ret; + } + } + + // Only check this as a last resort, to prevent locating the incorrect install. + // All above procedures will fail quickly if this is the right branch to take. + if (isset( $files[ $last_path ] ) ) { + if ( $this->verbose ) { + /* translators: %s: directory name */ + printf( "\n" . __( 'Found %s' ) . "
    \n", $base . $last_path ); + } + return trailingslashit($base . $last_path); + } + + // Prevent this function from looping again. + // No need to proceed if we've just searched in / + if ( $loop || '/' == $base ) + return false; + + // As an extra last resort, Change back to / if the folder wasn't found. + // This comes into effect when the CWD is /home/user/ but WP is at /var/www/.... + return $this->search_for_folder( $folder, '/', true ); + + } + + /** + * Return the *nix-style file permissions for a file. + * + * From the PHP documentation page for fileperms(). + * + * @link https://secure.php.net/manual/en/function.fileperms.php + * + * @since 2.5.0 + * + * @param string $file String filename. + * @return string The *nix-style representation of permissions. + */ + public function gethchmod( $file ){ + $perms = intval( $this->getchmod( $file ), 8 ); + if (($perms & 0xC000) == 0xC000) // Socket + $info = 's'; + elseif (($perms & 0xA000) == 0xA000) // Symbolic Link + $info = 'l'; + elseif (($perms & 0x8000) == 0x8000) // Regular + $info = '-'; + elseif (($perms & 0x6000) == 0x6000) // Block special + $info = 'b'; + elseif (($perms & 0x4000) == 0x4000) // Directory + $info = 'd'; + elseif (($perms & 0x2000) == 0x2000) // Character special + $info = 'c'; + elseif (($perms & 0x1000) == 0x1000) // FIFO pipe + $info = 'p'; + else // Unknown + $info = 'u'; + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + return $info; + } + + /** + * Gets the permissions of the specified file or filepath in their octal format + * + * @since 2.5.0 + * @param string $file + * @return string the last 3 characters of the octal number + */ + public function getchmod( $file ) { + return '777'; + } + + /** + * Convert *nix-style file permissions to a octal number. + * + * Converts '-rw-r--r--' to 0644 + * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod() + * + * @link https://secure.php.net/manual/en/function.chmod.php#49614 + * + * @since 2.5.0 + * + * @param string $mode string The *nix-style file permission. + * @return int octal representation + */ + public function getnumchmodfromh( $mode ) { + $realmode = ''; + $legal = array('', 'w', 'r', 'x', '-'); + $attarray = preg_split('//', $mode); + + for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) { + if ($key = array_search($attarray[$i], $legal)) { + $realmode .= $legal[$key]; + } + } + + $mode = str_pad($realmode, 10, '-', STR_PAD_LEFT); + $trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1'); + $mode = strtr($mode,$trans); + + $newmode = $mode[0]; + $newmode .= $mode[1] + $mode[2] + $mode[3]; + $newmode .= $mode[4] + $mode[5] + $mode[6]; + $newmode .= $mode[7] + $mode[8] + $mode[9]; + return $newmode; + } + + /** + * Determine if the string provided contains binary characters. + * + * @since 2.7.0 + * + * @param string $text String to test against. + * @return bool true if string is binary, false otherwise. + */ + public function is_binary( $text ) { + return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127) + } + + /** + * Change the ownership of a file / folder. + * + * Default behavior is to do nothing, override this in your subclass, if desired. + * + * @since 2.5.0 + * + * @param string $file Path to the file. + * @param mixed $owner A user name or number. + * @param bool $recursive Optional. If set True changes file owner recursivly. Defaults to False. + * @return bool Returns true on success or false on failure. + */ + public function chown( $file, $owner, $recursive = false ) { + return false; + } + + /** + * Connect filesystem. + * + * @since 2.5.0 + * @abstract + * + * @return bool True on success or false on failure (always true for WP_Filesystem_Direct). + */ + public function connect() { + return true; + } + + /** + * Read entire file into a string. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Name of the file to read. + * @return mixed|bool Returns the read data or false on failure. + */ + public function get_contents( $file ) { + return false; + } + + /** + * Read entire file into an array. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @return array|bool the file contents in an array or false on failure. + */ + public function get_contents_array( $file ) { + return false; + } + + /** + * Write a string to a file. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Remote path to the file where to write the data. + * @param string $contents The data to write. + * @param int $mode Optional. The file permissions as octal number, usually 0644. + * @return bool False on failure. + */ + public function put_contents( $file, $contents, $mode = false ) { + return false; + } + + /** + * Get the current working directory. + * + * @since 2.5.0 + * @abstract + * + * @return string|bool The current working directory on success, or false on failure. + */ + public function cwd() { + return false; + } + + /** + * Change current directory. + * + * @since 2.5.0 + * @abstract + * + * @param string $dir The new current directory. + * @return bool|string + */ + public function chdir( $dir ) { + return false; + } + + /** + * Change the file group. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @param mixed $group A group name or number. + * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False. + * @return bool|string + */ + public function chgrp( $file, $group, $recursive = false ) { + return false; + } + + /** + * Change filesystem permissions. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs. + * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False. + * @return bool|string + */ + public function chmod( $file, $mode = false, $recursive = false ) { + return false; + } + + /** + * Get the file owner. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @return string|bool Username of the user or false on error. + */ + public function owner( $file ) { + return false; + } + + /** + * Get the file's group. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @return string|bool The group or false on error. + */ + public function group( $file ) { + return false; + } + + /** + * Copy a file. + * + * @since 2.5.0 + * @abstract + * + * @param string $source Path to the source file. + * @param string $destination Path to the destination file. + * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists. + * Default false. + * @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs. + * Default false. + * @return bool True if file copied successfully, False otherwise. + */ + public function copy( $source, $destination, $overwrite = false, $mode = false ) { + return false; + } + + /** + * Move a file. + * + * @since 2.5.0 + * @abstract + * + * @param string $source Path to the source file. + * @param string $destination Path to the destination file. + * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists. + * Default false. + * @return bool True if file copied successfully, False otherwise. + */ + public function move( $source, $destination, $overwrite = false ) { + return false; + } + + /** + * Delete a file or directory. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to the file. + * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False. + * Default false. + * @param bool $type Type of resource. 'f' for file, 'd' for directory. + * Default false. + * @return bool True if the file or directory was deleted, false on failure. + */ + public function delete( $file, $recursive = false, $type = false ) { + return false; + } + + /** + * Check if a file or directory exists. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file/directory. + * @return bool Whether $file exists or not. + */ + public function exists( $file ) { + return false; + } + + /** + * Check if resource is a file. + * + * @since 2.5.0 + * @abstract + * + * @param string $file File path. + * @return bool Whether $file is a file. + */ + public function is_file( $file ) { + return false; + } + + /** + * Check if resource is a directory. + * + * @since 2.5.0 + * @abstract + * + * @param string $path Directory path. + * @return bool Whether $path is a directory. + */ + public function is_dir( $path ) { + return false; + } + + /** + * Check if a file is readable. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @return bool Whether $file is readable. + */ + public function is_readable( $file ) { + return false; + } + + /** + * Check if a file or directory is writable. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @return bool Whether $file is writable. + */ + public function is_writable( $file ) { + return false; + } + + /** + * Gets the file's last access time. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @return int|bool Unix timestamp representing last access time. + */ + public function atime( $file ) { + return false; + } + + /** + * Gets the file modification time. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @return int|bool Unix timestamp representing modification time. + */ + public function mtime( $file ) { + return false; + } + + /** + * Gets the file size (in bytes). + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @return int|bool Size of the file in bytes. + */ + public function size( $file ) { + return false; + } + + /** + * Set the access and modification times of a file. + * + * Note: If $file doesn't exist, it will be created. + * + * @since 2.5.0 + * @abstract + * + * @param string $file Path to file. + * @param int $time Optional. Modified time to set for file. + * Default 0. + * @param int $atime Optional. Access time to set for file. + * Default 0. + * @return bool Whether operation was successful or not. + */ + public function touch( $file, $time = 0, $atime = 0 ) { + return false; + } + + /** + * Create a directory. + * + * @since 2.5.0 + * @abstract + * + * @param string $path Path for new directory. + * @param mixed $chmod Optional. The permissions as octal number, (or False to skip chmod) + * Default false. + * @param mixed $chown Optional. A user name or number (or False to skip chown) + * Default false. + * @param mixed $chgrp Optional. A group name or number (or False to skip chgrp). + * Default false. + * @return bool False if directory cannot be created, true otherwise. + */ + public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) { + return false; + } + + /** + * Delete a directory. + * + * @since 2.5.0 + * @abstract + * + * @param string $path Path to directory. + * @param bool $recursive Optional. Whether to recursively remove files/directories. + * Default false. + * @return bool Whether directory is deleted successfully or not. + */ + public function rmdir( $path, $recursive = false ) { + return false; + } + + /** + * Get details for files in a directory or a specific file. + * + * @since 2.5.0 + * @abstract + * + * @param string $path Path to directory or file. + * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files. + * Default true. + * @param bool $recursive Optional. Whether to recursively include file details in nested directories. + * Default false. + * @return array|bool { + * Array of files. False if unable to list directory contents. + * + * @type string $name Name of the file/directory. + * @type string $perms *nix representation of permissions. + * @type int $permsn Octal representation of permissions. + * @type string $owner Owner name or ID. + * @type int $size Size of file in bytes. + * @type int $lastmodunix Last modified unix timestamp. + * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0). + * @type int $time Last modified time. + * @type string $type Type of resource. 'f' for file, 'd' for directory. + * @type mixed $files If a directory and $recursive is true, contains another array of files. + * } + */ + public function dirlist( $path, $include_hidden = true, $recursive = false ) { + return false; + } + +} // WP_Filesystem_Base diff --git a/backend/wp-admin/includes/class-wp-filesystem-direct.php b/backend/wp-admin/includes/class-wp-filesystem-direct.php new file mode 100644 index 0000000..42c8fe2 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-filesystem-direct.php @@ -0,0 +1,489 @@ +method = 'direct'; + $this->errors = new WP_Error(); + } + + /** + * Reads entire file into a string + * + * + * @param string $file Name of the file to read. + * @return string|bool The function returns the read data or false on failure. + */ + public function get_contents($file) { + return @file_get_contents($file); + } + + /** + * Reads entire file into an array + * + * + * @param string $file Path to the file. + * @return array|bool the file contents in an array or false on failure. + */ + public function get_contents_array($file) { + return @file($file); + } + + /** + * Write a string to a file + * + * + * @param string $file Remote path to the file where to write the data. + * @param string $contents The data to write. + * @param int $mode Optional. The file permissions as octal number, usually 0644. + * Default false. + * @return bool False upon failure, true otherwise. + */ + public function put_contents( $file, $contents, $mode = false ) { + $fp = @fopen( $file, 'wb' ); + if ( ! $fp ) + return false; + + mbstring_binary_safe_encoding(); + + $data_length = strlen( $contents ); + + $bytes_written = fwrite( $fp, $contents ); + + reset_mbstring_encoding(); + + fclose( $fp ); + + if ( $data_length !== $bytes_written ) + return false; + + $this->chmod( $file, $mode ); + + return true; + } + + /** + * Gets the current working directory + * + * + * @return string|bool the current working directory on success, or false on failure. + */ + public function cwd() { + return @getcwd(); + } + + /** + * Change directory + * + * + * @param string $dir The new current directory. + * @return bool Returns true on success or false on failure. + */ + public function chdir($dir) { + return @chdir($dir); + } + + /** + * Changes file group + * + * + * @param string $file Path to the file. + * @param mixed $group A group name or number. + * @param bool $recursive Optional. If set True changes file group recursively. Default false. + * @return bool Returns true on success or false on failure. + */ + public function chgrp($file, $group, $recursive = false) { + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive ) + return @chgrp($file, $group); + if ( ! $this->is_dir($file) ) + return @chgrp($file, $group); + // Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach ($filelist as $filename) + $this->chgrp($file . $filename, $group, $recursive); + + return true; + } + + /** + * Changes filesystem permissions + * + * + * @param string $file Path to the file. + * @param int $mode Optional. The permissions as octal number, usually 0644 for files, + * 0755 for dirs. Default false. + * @param bool $recursive Optional. If set True changes file group recursively. Default false. + * @return bool Returns true on success or false on failure. + */ + public function chmod($file, $mode = false, $recursive = false) { + if ( ! $mode ) { + if ( $this->is_file($file) ) + $mode = FS_CHMOD_FILE; + elseif ( $this->is_dir($file) ) + $mode = FS_CHMOD_DIR; + else + return false; + } + + if ( ! $recursive || ! $this->is_dir($file) ) + return @chmod($file, $mode); + // Is a directory, and we want recursive + $file = trailingslashit($file); + $filelist = $this->dirlist($file); + foreach ( (array)$filelist as $filename => $filemeta) + $this->chmod($file . $filename, $mode, $recursive); + + return true; + } + + /** + * Changes file owner + * + * + * @param string $file Path to the file. + * @param mixed $owner A user name or number. + * @param bool $recursive Optional. If set True changes file owner recursively. + * Default false. + * @return bool Returns true on success or false on failure. + */ + public function chown($file, $owner, $recursive = false) { + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive ) + return @chown($file, $owner); + if ( ! $this->is_dir($file) ) + return @chown($file, $owner); + // Is a directory, and we want recursive + $filelist = $this->dirlist($file); + foreach ($filelist as $filename) { + $this->chown($file . '/' . $filename, $owner, $recursive); + } + return true; + } + + /** + * Gets file owner + * + * + * @param string $file Path to the file. + * @return string|bool Username of the user or false on error. + */ + public function owner($file) { + $owneruid = @fileowner($file); + if ( ! $owneruid ) + return false; + if ( ! function_exists('posix_getpwuid') ) + return $owneruid; + $ownerarray = posix_getpwuid($owneruid); + return $ownerarray['name']; + } + + /** + * Gets file permissions + * + * FIXME does not handle errors in fileperms() + * + * + * @param string $file Path to the file. + * @return string Mode of the file (last 3 digits). + */ + public function getchmod($file) { + return substr( decoct( @fileperms( $file ) ), -3 ); + } + + /** + * + * @param string $file + * @return string|false + */ + public function group($file) { + $gid = @filegroup($file); + if ( ! $gid ) + return false; + if ( ! function_exists('posix_getgrgid') ) + return $gid; + $grouparray = posix_getgrgid($gid); + return $grouparray['name']; + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @param int $mode + * @return bool + */ + public function copy($source, $destination, $overwrite = false, $mode = false) { + if ( ! $overwrite && $this->exists($destination) ) + return false; + + $rtval = copy($source, $destination); + if ( $mode ) + $this->chmod($destination, $mode); + return $rtval; + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @return bool + */ + public function move($source, $destination, $overwrite = false) { + if ( ! $overwrite && $this->exists($destination) ) + return false; + + // Try using rename first. if that fails (for example, source is read only) try copy. + if ( @rename($source, $destination) ) + return true; + + if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) { + $this->delete($source); + return true; + } else { + return false; + } + } + + /** + * + * @param string $file + * @param bool $recursive + * @param string $type + * @return bool + */ + public function delete($file, $recursive = false, $type = false) { + if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. + return false; + $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise + + if ( 'f' == $type || $this->is_file($file) ) + return @unlink($file); + if ( ! $recursive && $this->is_dir($file) ) + return @rmdir($file); + + // At this point it's a folder, and we're in recursive mode + $file = trailingslashit($file); + $filelist = $this->dirlist($file, true); + + $retval = true; + if ( is_array( $filelist ) ) { + foreach ( $filelist as $filename => $fileinfo ) { + if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) ) + $retval = false; + } + } + + if ( file_exists($file) && ! @rmdir($file) ) + $retval = false; + + return $retval; + } + /** + * + * @param string $file + * @return bool + */ + public function exists($file) { + return @file_exists($file); + } + /** + * + * @param string $file + * @return bool + */ + public function is_file($file) { + return @is_file($file); + } + /** + * + * @param string $path + * @return bool + */ + public function is_dir($path) { + return @is_dir($path); + } + + /** + * + * @param string $file + * @return bool + */ + public function is_readable($file) { + return @is_readable($file); + } + + /** + * + * @param string $file + * @return bool + */ + public function is_writable($file) { + return @is_writable($file); + } + + /** + * + * @param string $file + * @return int + */ + public function atime($file) { + return @fileatime($file); + } + + /** + * + * @param string $file + * @return int + */ + public function mtime($file) { + return @filemtime($file); + } + + /** + * + * @param string $file + * @return int + */ + public function size($file) { + return @filesize($file); + } + + /** + * + * @param string $file + * @param int $time + * @param int $atime + * @return bool + */ + public function touch($file, $time = 0, $atime = 0) { + if ($time == 0) + $time = time(); + if ($atime == 0) + $atime = time(); + return @touch($file, $time, $atime); + } + + /** + * + * @param string $path + * @param mixed $chmod + * @param mixed $chown + * @param mixed $chgrp + * @return bool + */ + public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { + // Safe mode fails with a trailing slash under certain PHP versions. + $path = untrailingslashit($path); + if ( empty($path) ) + return false; + + if ( ! $chmod ) + $chmod = FS_CHMOD_DIR; + + if ( ! @mkdir($path) ) + return false; + $this->chmod($path, $chmod); + if ( $chown ) + $this->chown($path, $chown); + if ( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + /** + * + * @param string $path + * @param bool $recursive + * @return bool + */ + public function rmdir($path, $recursive = false) { + return $this->delete($path, $recursive); + } + + /** + * + * @param string $path + * @param bool $include_hidden + * @param bool $recursive + * @return bool|array + */ + public function dirlist($path, $include_hidden = true, $recursive = false) { + if ( $this->is_file($path) ) { + $limit_file = basename($path); + $path = dirname($path); + } else { + $limit_file = false; + } + + if ( ! $this->is_dir($path) ) + return false; + + $dir = @dir($path); + if ( ! $dir ) + return false; + + $ret = array(); + + while (false !== ($entry = $dir->read()) ) { + $struc = array(); + $struc['name'] = $entry; + + if ( '.' == $struc['name'] || '..' == $struc['name'] ) + continue; + + if ( ! $include_hidden && '.' == $struc['name'][0] ) + continue; + + if ( $limit_file && $struc['name'] != $limit_file) + continue; + + $struc['perms'] = $this->gethchmod($path.'/'.$entry); + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); + $struc['number'] = false; + $struc['owner'] = $this->owner($path.'/'.$entry); + $struc['group'] = $this->group($path.'/'.$entry); + $struc['size'] = $this->size($path.'/'.$entry); + $struc['lastmodunix']= $this->mtime($path.'/'.$entry); + $struc['lastmod'] = date('M j',$struc['lastmodunix']); + $struc['time'] = date('h:i:s',$struc['lastmodunix']); + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; + + if ( 'd' == $struc['type'] ) { + if ( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); + else + $struc['files'] = array(); + } + + $ret[ $struc['name'] ] = $struc; + } + $dir->close(); + unset($dir); + return $ret; + } +} diff --git a/backend/wp-admin/includes/class-wp-filesystem-ftpext.php b/backend/wp-admin/includes/class-wp-filesystem-ftpext.php new file mode 100644 index 0000000..52e4357 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -0,0 +1,581 @@ +method = 'ftpext'; + $this->errors = new WP_Error(); + + // Check if possible to use ftp functions. + if ( ! extension_loaded('ftp') ) { + $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); + return; + } + + // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. + + if ( ! defined('FS_TIMEOUT') ) + define('FS_TIMEOUT', 240); + + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + // Check if the options provided are OK. + if ( empty($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + + $this->options['ssl'] = false; + if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) + $this->options['ssl'] = true; + } + + /** + * + * @return bool + */ + public function connect() { + if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); + else + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); + + if ( ! $this->link ) { + $this->errors->add( 'connect', + /* translators: %s: hostname:port */ + sprintf( __( 'Failed to connect to FTP Server %s' ), + $this->options['hostname'] . ':' . $this->options['port'] + ) + ); + return false; + } + + if ( ! @ftp_login( $this->link,$this->options['username'], $this->options['password'] ) ) { + $this->errors->add( 'auth', + /* translators: %s: username */ + sprintf( __( 'Username/Password incorrect for %s' ), + $this->options['username'] + ) + ); + return false; + } + + // Set the Connection to use Passive FTP + @ftp_pasv( $this->link, true ); + if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) + @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); + + return true; + } + + /** + * Retrieves the file contents. + * + * @since 2.5.0 + * + * @param string $file Filename. + * @return string|false File contents on success, false if no temp file could be opened, + * or if the file couldn't be retrieved. + */ + public function get_contents( $file ) { + $tempfile = wp_tempnam($file); + $temp = fopen($tempfile, 'w+'); + + if ( ! $temp ) { + unlink( $tempfile ); + return false; + } + + if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) { + fclose( $temp ); + unlink( $tempfile ); + return false; + } + + fseek( $temp, 0 ); // Skip back to the start of the file being written to + $contents = ''; + + while ( ! feof($temp) ) + $contents .= fread($temp, 8192); + + fclose($temp); + unlink($tempfile); + return $contents; + } + + /** + * + * @param string $file + * @return array + */ + public function get_contents_array($file) { + return explode("\n", $this->get_contents($file)); + } + + /** + * + * @param string $file + * @param string $contents + * @param bool|int $mode + * @return bool + */ + public function put_contents($file, $contents, $mode = false ) { + $tempfile = wp_tempnam($file); + $temp = fopen( $tempfile, 'wb+' ); + + if ( ! $temp ) { + unlink( $tempfile ); + return false; + } + + mbstring_binary_safe_encoding(); + + $data_length = strlen( $contents ); + $bytes_written = fwrite( $temp, $contents ); + + reset_mbstring_encoding(); + + if ( $data_length !== $bytes_written ) { + fclose( $temp ); + unlink( $tempfile ); + return false; + } + + fseek( $temp, 0 ); // Skip back to the start of the file being written to + + $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY ); + + fclose($temp); + unlink($tempfile); + + $this->chmod($file, $mode); + + return $ret; + } + + /** + * + * @return string + */ + public function cwd() { + $cwd = @ftp_pwd($this->link); + if ( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + + /** + * + * @param string $dir + * @return bool + */ + public function chdir($dir) { + return @ftp_chdir($this->link, $dir); + } + + /** + * + * @param string $file + * @param int $mode + * @param bool $recursive + * @return bool + */ + public function chmod($file, $mode = false, $recursive = false) { + if ( ! $mode ) { + if ( $this->is_file($file) ) + $mode = FS_CHMOD_FILE; + elseif ( $this->is_dir($file) ) + $mode = FS_CHMOD_DIR; + else + return false; + } + + // chmod any sub-objects if recursive. + if ( $recursive && $this->is_dir($file) ) { + $filelist = $this->dirlist($file); + foreach ( (array)$filelist as $filename => $filemeta ) + $this->chmod($file . '/' . $filename, $mode, $recursive); + } + + // chmod the file or directory + if ( ! function_exists('ftp_chmod') ) + return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); + return (bool)@ftp_chmod($this->link, $mode, $file); + } + + /** + * + * @param string $file + * @return string + */ + public function owner($file) { + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + /** + * + * @param string $file + * @return string + */ + public function getchmod($file) { + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + /** + * + * @param string $file + * @return string + */ + public function group($file) { + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @param string|bool $mode + * @return bool + */ + public function copy($source, $destination, $overwrite = false, $mode = false) { + if ( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if ( false === $content ) + return false; + return $this->put_contents($destination, $content, $mode); + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @return bool + */ + public function move($source, $destination, $overwrite = false) { + return ftp_rename($this->link, $source, $destination); + } + + /** + * + * @param string $file + * @param bool $recursive + * @param string $type + * @return bool + */ + public function delete($file, $recursive = false, $type = false) { + if ( empty($file) ) + return false; + if ( 'f' == $type || $this->is_file($file) ) + return @ftp_delete($this->link, $file); + if ( !$recursive ) + return @ftp_rmdir($this->link, $file); + + $filelist = $this->dirlist( trailingslashit($file) ); + if ( !empty($filelist) ) + foreach ( $filelist as $delete_file ) + $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); + return @ftp_rmdir($this->link, $file); + } + + /** + * + * @param string $file + * @return bool + */ + public function exists($file) { + $list = @ftp_nlist($this->link, $file); + + if ( empty( $list ) && $this->is_dir( $file ) ) { + return true; // File is an empty directory. + } + + return !empty($list); //empty list = no file, so invert. + } + + /** + * + * @param string $file + * @return bool + */ + public function is_file($file) { + return $this->exists($file) && !$this->is_dir($file); + } + + /** + * + * @param string $path + * @return bool + */ + public function is_dir($path) { + $cwd = $this->cwd(); + $result = @ftp_chdir($this->link, trailingslashit($path) ); + if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { + @ftp_chdir($this->link, $cwd); + return true; + } + return false; + } + + /** + * + * @param string $file + * @return bool + */ + public function is_readable($file) { + return true; + } + + /** + * + * @param string $file + * @return bool + */ + public function is_writable($file) { + return true; + } + + /** + * + * @param string $file + * @return bool + */ + public function atime($file) { + return false; + } + + /** + * + * @param string $file + * @return int + */ + public function mtime($file) { + return ftp_mdtm($this->link, $file); + } + + /** + * + * @param string $file + * @return int + */ + public function size($file) { + return ftp_size($this->link, $file); + } + + /** + * + * @param string $file + * @return bool + */ + public function touch($file, $time = 0, $atime = 0) { + return false; + } + + /** + * + * @param string $path + * @param mixed $chmod + * @param mixed $chown + * @param mixed $chgrp + * @return bool + */ + public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { + $path = untrailingslashit($path); + if ( empty($path) ) + return false; + + if ( !@ftp_mkdir($this->link, $path) ) + return false; + $this->chmod($path, $chmod); + return true; + } + + /** + * + * @param string $path + * @param bool $recursive + * @return bool + */ + public function rmdir($path, $recursive = false) { + return $this->delete($path, $recursive); + } + + /** + * + * @staticvar bool $is_windows + * @param string $line + * @return array + */ + public function parselisting($line) { + static $is_windows = null; + if ( is_null($is_windows) ) + $is_windows = stripos( ftp_systype($this->link), 'win') !== false; + + if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|
    ) +(.+)/', $line, $lucifer) ) { + $b = array(); + if ( $lucifer[3] < 70 ) + $lucifer[3] +=2000; + else + $lucifer[3] += 1900; // 4digit year fix + $b['isdir'] = ( $lucifer[7] == ''); + if ( $b['isdir'] ) + $b['type'] = 'd'; + else + $b['type'] = 'f'; + $b['size'] = $lucifer[7]; + $b['month'] = $lucifer[1]; + $b['day'] = $lucifer[2]; + $b['year'] = $lucifer[3]; + $b['hour'] = $lucifer[4]; + $b['minute'] = $lucifer[5]; + $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]); + $b['am/pm'] = $lucifer[6]; + $b['name'] = $lucifer[8]; + } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { + //echo $line."\n"; + $lcount = count($lucifer); + if ( $lcount < 8 ) + return ''; + $b = array(); + $b['isdir'] = $lucifer[0]{0} === 'd'; + $b['islink'] = $lucifer[0]{0} === 'l'; + if ( $b['isdir'] ) + $b['type'] = 'd'; + elseif ( $b['islink'] ) + $b['type'] = 'l'; + else + $b['type'] = 'f'; + $b['perms'] = $lucifer[0]; + $b['permsn'] = $this->getnumchmodfromh( $b['perms'] ); + $b['number'] = $lucifer[1]; + $b['owner'] = $lucifer[2]; + $b['group'] = $lucifer[3]; + $b['size'] = $lucifer[4]; + if ( $lcount == 8 ) { + sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']); + sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']); + $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']); + $b['name'] = $lucifer[7]; + } else { + $b['month'] = $lucifer[5]; + $b['day'] = $lucifer[6]; + if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) { + $b['year'] = date("Y"); + $b['hour'] = $l2[1]; + $b['minute'] = $l2[2]; + } else { + $b['year'] = $lucifer[7]; + $b['hour'] = 0; + $b['minute'] = 0; + } + $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) ); + $b['name'] = $lucifer[8]; + } + } + + // Replace symlinks formatted as "source -> target" with just the source name + if ( isset( $b['islink'] ) && $b['islink'] ) { + $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); + } + + return $b; + } + + /** + * + * @param string $path + * @param bool $include_hidden + * @param bool $recursive + * @return bool|array + */ + public function dirlist($path = '.', $include_hidden = true, $recursive = false) { + if ( $this->is_file($path) ) { + $limit_file = basename($path); + $path = dirname($path) . '/'; + } else { + $limit_file = false; + } + + $pwd = @ftp_pwd($this->link); + if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist + return false; + $list = @ftp_rawlist($this->link, '-a', false); + @ftp_chdir($this->link, $pwd); + + if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least) + return false; + + $dirlist = array(); + foreach ( $list as $k => $v ) { + $entry = $this->parselisting($v); + if ( empty($entry) ) + continue; + + if ( '.' == $entry['name'] || '..' == $entry['name'] ) + continue; + + if ( ! $include_hidden && '.' == $entry['name'][0] ) + continue; + + if ( $limit_file && $entry['name'] != $limit_file) + continue; + + $dirlist[ $entry['name'] ] = $entry; + } + + $ret = array(); + foreach ( (array)$dirlist as $struc ) { + if ( 'd' == $struc['type'] ) { + if ( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); + else + $struc['files'] = array(); + } + + $ret[ $struc['name'] ] = $struc; + } + return $ret; + } + + /** + */ + public function __destruct() { + if ( $this->link ) + ftp_close($this->link); + } +} diff --git a/backend/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/backend/wp-admin/includes/class-wp-filesystem-ftpsockets.php new file mode 100644 index 0000000..3366554 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -0,0 +1,517 @@ +method = 'ftpsockets'; + $this->errors = new WP_Error(); + + // Check if possible to use ftp functions. + if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) { + return; + } + $this->ftp = new ftp(); + + if ( empty($opt['port']) ) + $this->options['port'] = 21; + else + $this->options['port'] = (int) $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('FTP hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + // Check if the options provided are OK. + if ( empty ($opt['username']) ) + $this->errors->add('empty_username', __('FTP username is required')); + else + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) + $this->errors->add('empty_password', __('FTP password is required')); + else + $this->options['password'] = $opt['password']; + } + + /** + * + * @return bool + */ + public function connect() { + if ( ! $this->ftp ) + return false; + + $this->ftp->setTimeout(FS_CONNECT_TIMEOUT); + + if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) { + $this->errors->add( 'connect', + /* translators: %s: hostname:port */ + sprintf( __( 'Failed to connect to FTP Server %s' ), + $this->options['hostname'] . ':' . $this->options['port'] + ) + ); + return false; + } + + if ( ! $this->ftp->connect() ) { + $this->errors->add( 'connect', + /* translators: %s: hostname:port */ + sprintf( __( 'Failed to connect to FTP Server %s' ), + $this->options['hostname'] . ':' . $this->options['port'] + ) + ); + return false; + } + + if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) { + $this->errors->add( 'auth', + /* translators: %s: username */ + sprintf( __( 'Username/Password incorrect for %s' ), + $this->options['username'] + ) + ); + return false; + } + + $this->ftp->SetType( FTP_BINARY ); + $this->ftp->Passive( true ); + $this->ftp->setTimeout( FS_TIMEOUT ); + return true; + } + + /** + * Retrieves the file contents. + * + * @since 2.5.0 + * + * @param string $file Filename. + * @return string|false File contents on success, false if no temp file could be opened, + * or if the file doesn't exist. + */ + public function get_contents( $file ) { + if ( ! $this->exists($file) ) + return false; + + $temp = wp_tempnam( $file ); + + if ( ! $temphandle = fopen( $temp, 'w+' ) ) { + unlink( $temp ); + return false; + } + + mbstring_binary_safe_encoding(); + + if ( ! $this->ftp->fget($temphandle, $file) ) { + fclose($temphandle); + unlink($temp); + + reset_mbstring_encoding(); + + return ''; // Blank document, File does exist, It's just blank. + } + + reset_mbstring_encoding(); + + fseek( $temphandle, 0 ); // Skip back to the start of the file being written to + $contents = ''; + + while ( ! feof($temphandle) ) + $contents .= fread($temphandle, 8192); + + fclose($temphandle); + unlink($temp); + return $contents; + } + + /** + * + * @param string $file + * @return array + */ + public function get_contents_array($file) { + return explode("\n", $this->get_contents($file) ); + } + + /** + * + * @param string $file + * @param string $contents + * @param int|bool $mode + * @return bool + */ + public function put_contents($file, $contents, $mode = false ) { + $temp = wp_tempnam( $file ); + if ( ! $temphandle = @fopen($temp, 'w+') ) { + unlink($temp); + return false; + } + + // The FTP class uses string functions internally during file download/upload + mbstring_binary_safe_encoding(); + + $bytes_written = fwrite( $temphandle, $contents ); + if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) { + fclose( $temphandle ); + unlink( $temp ); + + reset_mbstring_encoding(); + + return false; + } + + fseek( $temphandle, 0 ); // Skip back to the start of the file being written to + + $ret = $this->ftp->fput($file, $temphandle); + + reset_mbstring_encoding(); + + fclose($temphandle); + unlink($temp); + + $this->chmod($file, $mode); + + return $ret; + } + + /** + * + * @return string + */ + public function cwd() { + $cwd = $this->ftp->pwd(); + if ( $cwd ) + $cwd = trailingslashit($cwd); + return $cwd; + } + + /** + * + * @param string $file + * @return bool + */ + public function chdir($file) { + return $this->ftp->chdir($file); + } + + /** + * + * @param string $file + * @param int|bool $mode + * @param bool $recursive + * @return bool + */ + public function chmod($file, $mode = false, $recursive = false ) { + if ( ! $mode ) { + if ( $this->is_file($file) ) + $mode = FS_CHMOD_FILE; + elseif ( $this->is_dir($file) ) + $mode = FS_CHMOD_DIR; + else + return false; + } + + // chmod any sub-objects if recursive. + if ( $recursive && $this->is_dir($file) ) { + $filelist = $this->dirlist($file); + foreach ( (array)$filelist as $filename => $filemeta ) + $this->chmod($file . '/' . $filename, $mode, $recursive); + } + + // chmod the file or directory + return $this->ftp->chmod($file, $mode); + } + + /** + * + * @param string $file + * @return string + */ + public function owner($file) { + $dir = $this->dirlist($file); + return $dir[$file]['owner']; + } + + /** + * + * @param string $file + * @return string + */ + public function getchmod($file) { + $dir = $this->dirlist($file); + return $dir[$file]['permsn']; + } + + /** + * + * @param string $file + * @return string + */ + public function group($file) { + $dir = $this->dirlist($file); + return $dir[$file]['group']; + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @param int|bool $mode + * @return bool + */ + public function copy($source, $destination, $overwrite = false, $mode = false) { + if ( ! $overwrite && $this->exists($destination) ) + return false; + + $content = $this->get_contents($source); + if ( false === $content ) + return false; + + return $this->put_contents($destination, $content, $mode); + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @return bool + */ + public function move($source, $destination, $overwrite = false ) { + return $this->ftp->rename($source, $destination); + } + + /** + * + * @param string $file + * @param bool $recursive + * @param string $type + * @return bool + */ + public function delete($file, $recursive = false, $type = false) { + if ( empty($file) ) + return false; + if ( 'f' == $type || $this->is_file($file) ) + return $this->ftp->delete($file); + if ( !$recursive ) + return $this->ftp->rmdir($file); + + return $this->ftp->mdel($file); + } + + /** + * + * @param string $file + * @return bool + */ + public function exists( $file ) { + $list = $this->ftp->nlist( $file ); + + if ( empty( $list ) && $this->is_dir( $file ) ) { + return true; // File is an empty directory. + } + + return !empty( $list ); //empty list = no file, so invert. + // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server. + } + + /** + * + * @param string $file + * @return bool + */ + public function is_file($file) { + if ( $this->is_dir($file) ) + return false; + if ( $this->exists($file) ) + return true; + return false; + } + + /** + * + * @param string $path + * @return bool + */ + public function is_dir($path) { + $cwd = $this->cwd(); + if ( $this->chdir($path) ) { + $this->chdir($cwd); + return true; + } + return false; + } + + /** + * + * @param string $file + * @return bool + */ + public function is_readable($file) { + return true; + } + + /** + * + * @param string $file + * @return bool + */ + public function is_writable($file) { + return true; + } + + /** + * + * @param string $file + * @return bool + */ + public function atime($file) { + return false; + } + + /** + * + * @param string $file + * @return int + */ + public function mtime($file) { + return $this->ftp->mdtm($file); + } + + /** + * @param string $file + * @return int + */ + public function size($file) { + return $this->ftp->filesize($file); + } + + /** + * + * @param string $file + * @param int $time + * @param int $atime + * @return bool + */ + public function touch($file, $time = 0, $atime = 0 ) { + return false; + } + + /** + * + * @param string $path + * @param mixed $chmod + * @param mixed $chown + * @param mixed $chgrp + * @return bool + */ + public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) { + $path = untrailingslashit($path); + if ( empty($path) ) + return false; + + if ( ! $this->ftp->mkdir($path) ) + return false; + if ( ! $chmod ) + $chmod = FS_CHMOD_DIR; + $this->chmod($path, $chmod); + return true; + } + + /** + * + * @param string $path + * @param bool $recursive + * @return bool + */ + public function rmdir($path, $recursive = false ) { + return $this->delete($path, $recursive); + } + + /** + * + * @param string $path + * @param bool $include_hidden + * @param bool $recursive + * @return bool|array + */ + public function dirlist($path = '.', $include_hidden = true, $recursive = false ) { + if ( $this->is_file($path) ) { + $limit_file = basename($path); + $path = dirname($path) . '/'; + } else { + $limit_file = false; + } + + mbstring_binary_safe_encoding(); + + $list = $this->ftp->dirlist($path); + if ( empty( $list ) && ! $this->exists( $path ) ) { + + reset_mbstring_encoding(); + + return false; + } + + $ret = array(); + foreach ( $list as $struc ) { + + if ( '.' == $struc['name'] || '..' == $struc['name'] ) + continue; + + if ( ! $include_hidden && '.' == $struc['name'][0] ) + continue; + + if ( $limit_file && $struc['name'] != $limit_file ) + continue; + + if ( 'd' == $struc['type'] ) { + if ( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); + else + $struc['files'] = array(); + } + + // Replace symlinks formatted as "source -> target" with just the source name + if ( $struc['islink'] ) + $struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] ); + + // Add the Octal representation of the file permissions + $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] ); + + $ret[ $struc['name'] ] = $struc; + } + + reset_mbstring_encoding(); + + return $ret; + } + + /** + */ + public function __destruct() { + $this->ftp->quit(); + } +} diff --git a/backend/wp-admin/includes/class-wp-filesystem-ssh2.php b/backend/wp-admin/includes/class-wp-filesystem-ssh2.php new file mode 100644 index 0000000..072fdce --- /dev/null +++ b/backend/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -0,0 +1,599 @@ +method = 'ssh2'; + $this->errors = new WP_Error(); + + //Check if possible to use ssh2 functions. + if ( ! extension_loaded('ssh2') ) { + $this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available')); + return; + } + if ( !function_exists('stream_get_contents') ) { + $this->errors->add( + 'ssh2_php_requirement', + sprintf( + /* translators: %s: stream_get_contents() */ + __( 'The ssh2 PHP extension is available, however, we require the PHP5 function %s' ), + 'stream_get_contents()' + ) + ); + return; + } + + // Set defaults: + if ( empty($opt['port']) ) + $this->options['port'] = 22; + else + $this->options['port'] = $opt['port']; + + if ( empty($opt['hostname']) ) + $this->errors->add('empty_hostname', __('SSH2 hostname is required')); + else + $this->options['hostname'] = $opt['hostname']; + + // Check if the options provided are OK. + if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) { + $this->options['public_key'] = $opt['public_key']; + $this->options['private_key'] = $opt['private_key']; + + $this->options['hostkey'] = array('hostkey' => 'ssh-rsa'); + + $this->keys = true; + } elseif ( empty ($opt['username']) ) { + $this->errors->add('empty_username', __('SSH2 username is required')); + } + + if ( !empty($opt['username']) ) + $this->options['username'] = $opt['username']; + + if ( empty ($opt['password']) ) { + // Password can be blank if we are using keys. + if ( !$this->keys ) + $this->errors->add('empty_password', __('SSH2 password is required')); + } else { + $this->options['password'] = $opt['password']; + } + } + + /** + * + * @return bool + */ + public function connect() { + if ( ! $this->keys ) { + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']); + } else { + $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']); + } + + if ( ! $this->link ) { + $this->errors->add( 'connect', + /* translators: %s: hostname:port */ + sprintf( __( 'Failed to connect to SSH2 Server %s' ), + $this->options['hostname'] . ':' . $this->options['port'] + ) + ); + return false; + } + + if ( !$this->keys ) { + if ( ! @ssh2_auth_password($this->link, $this->options['username'], $this->options['password']) ) { + $this->errors->add( 'auth', + /* translators: %s: username */ + sprintf( __( 'Username/Password incorrect for %s' ), + $this->options['username'] + ) + ); + return false; + } + } else { + if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) { + $this->errors->add( 'auth', + /* translators: %s: username */ + sprintf( __( 'Public and Private keys incorrect for %s' ), + $this->options['username'] + ) + ); + return false; + } + } + + $this->sftp_link = ssh2_sftp( $this->link ); + if ( ! $this->sftp_link ) { + $this->errors->add( 'connect', + /* translators: %s: hostname:port */ + sprintf( __( 'Failed to initialize a SFTP subsystem session with the SSH2 Server %s' ), + $this->options['hostname'] . ':' . $this->options['port'] + ) + ); + return false; + } + + return true; + } + + /** + * Gets the ssh2.sftp PHP stream wrapper path to open for the given file. + * + * This method also works around a PHP bug where the root directory (/) cannot + * be opened by PHP functions, causing a false failure. In order to work around + * this, the path is converted to /./ which is semantically the same as / + * See https://bugs.php.net/bug.php?id=64169 for more details. + * + * + * @since 4.4.0 + * + * @param string $path The File/Directory path on the remote server to return + * @return string The ssh2.sftp:// wrapped path to use. + */ + public function sftp_path( $path ) { + if ( '/' === $path ) { + $path = '/./'; + } + return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' ); + } + + /** + * + * @param string $command + * @param bool $returnbool + * @return bool|string True on success, false on failure. String if the command was executed, `$returnbool` + * is false (default), and data from the resulting stream was retrieved. + */ + public function run_command( $command, $returnbool = false ) { + if ( ! $this->link ) + return false; + + if ( ! ($stream = ssh2_exec($this->link, $command)) ) { + $this->errors->add( 'command', + /* translators: %s: command */ + sprintf( __( 'Unable to perform command: %s'), + $command + ) + ); + } else { + stream_set_blocking( $stream, true ); + stream_set_timeout( $stream, FS_TIMEOUT ); + $data = stream_get_contents( $stream ); + fclose( $stream ); + + if ( $returnbool ) + return ( $data === false ) ? false : '' != trim($data); + else + return $data; + } + return false; + } + + /** + * + * @param string $file + * @return string|false + */ + public function get_contents( $file ) { + return file_get_contents( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @return array + */ + public function get_contents_array($file) { + return file( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @param string $contents + * @param bool|int $mode + * @return bool + */ + public function put_contents($file, $contents, $mode = false ) { + $ret = file_put_contents( $this->sftp_path( $file ), $contents ); + + if ( $ret !== strlen( $contents ) ) + return false; + + $this->chmod($file, $mode); + + return true; + } + + /** + * + * @return bool + */ + public function cwd() { + $cwd = ssh2_sftp_realpath( $this->sftp_link, '.' ); + if ( $cwd ) { + $cwd = trailingslashit( trim( $cwd ) ); + } + return $cwd; + } + + /** + * + * @param string $dir + * @return bool|string + */ + public function chdir($dir) { + return $this->run_command('cd ' . $dir, true); + } + + /** + * + * @param string $file + * @param string $group + * @param bool $recursive + * + * @return bool + */ + public function chgrp($file, $group, $recursive = false ) { + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command(sprintf('chgrp %s %s', escapeshellarg($group), escapeshellarg($file)), true); + return $this->run_command(sprintf('chgrp -R %s %s', escapeshellarg($group), escapeshellarg($file)), true); + } + + /** + * + * @param string $file + * @param int $mode + * @param bool $recursive + * @return bool|string + */ + public function chmod($file, $mode = false, $recursive = false) { + if ( ! $this->exists($file) ) + return false; + + if ( ! $mode ) { + if ( $this->is_file($file) ) + $mode = FS_CHMOD_FILE; + elseif ( $this->is_dir($file) ) + $mode = FS_CHMOD_DIR; + else + return false; + } + + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command(sprintf('chmod %o %s', $mode, escapeshellarg($file)), true); + return $this->run_command(sprintf('chmod -R %o %s', $mode, escapeshellarg($file)), true); + } + + /** + * Change the ownership of a file / folder. + * + * + * @param string $file Path to the file. + * @param string|int $owner A user name or number. + * @param bool $recursive Optional. If set True changes file owner recursivly. Default False. + * @return bool True on success or false on failure. + */ + public function chown( $file, $owner, $recursive = false ) { + if ( ! $this->exists($file) ) + return false; + if ( ! $recursive || ! $this->is_dir($file) ) + return $this->run_command(sprintf('chown %s %s', escapeshellarg($owner), escapeshellarg($file)), true); + return $this->run_command(sprintf('chown -R %s %s', escapeshellarg($owner), escapeshellarg($file)), true); + } + + /** + * + * @param string $file + * @return string|false + */ + public function owner($file) { + $owneruid = @fileowner( $this->sftp_path( $file ) ); + if ( ! $owneruid ) + return false; + if ( ! function_exists('posix_getpwuid') ) + return $owneruid; + $ownerarray = posix_getpwuid($owneruid); + return $ownerarray['name']; + } + + /** + * + * @param string $file + * @return string + */ + public function getchmod($file) { + return substr( decoct( @fileperms( $this->sftp_path( $file ) ) ), -3 ); + } + + /** + * + * @param string $file + * @return string|false + */ + public function group($file) { + $gid = @filegroup( $this->sftp_path( $file ) ); + if ( ! $gid ) + return false; + if ( ! function_exists('posix_getgrgid') ) + return $gid; + $grouparray = posix_getgrgid($gid); + return $grouparray['name']; + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @param int|bool $mode + * @return bool + */ + public function copy($source, $destination, $overwrite = false, $mode = false) { + if ( ! $overwrite && $this->exists($destination) ) + return false; + $content = $this->get_contents($source); + if ( false === $content) + return false; + return $this->put_contents($destination, $content, $mode); + } + + /** + * + * @param string $source + * @param string $destination + * @param bool $overwrite + * @return bool + */ + public function move($source, $destination, $overwrite = false) { + return @ssh2_sftp_rename( $this->sftp_link, $source, $destination ); + } + + /** + * + * @param string $file + * @param bool $recursive + * @param string|bool $type + * @return bool + */ + public function delete($file, $recursive = false, $type = false) { + if ( 'f' == $type || $this->is_file($file) ) + return ssh2_sftp_unlink($this->sftp_link, $file); + if ( ! $recursive ) + return ssh2_sftp_rmdir($this->sftp_link, $file); + $filelist = $this->dirlist($file); + if ( is_array($filelist) ) { + foreach ( $filelist as $filename => $fileinfo) { + $this->delete($file . '/' . $filename, $recursive, $fileinfo['type']); + } + } + return ssh2_sftp_rmdir($this->sftp_link, $file); + } + + /** + * + * @param string $file + * @return bool + */ + public function exists($file) { + return file_exists( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @return bool + */ + public function is_file($file) { + return is_file( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $path + * @return bool + */ + public function is_dir($path) { + return is_dir( $this->sftp_path( $path ) ); + } + + /** + * + * @param string $file + * @return bool + */ + public function is_readable($file) { + return is_readable( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @return bool + */ + public function is_writable($file) { + // PHP will base it's writable checks on system_user === file_owner, not ssh_user === file_owner + return true; + } + + /** + * + * @param string $file + * @return int + */ + public function atime($file) { + return fileatime( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @return int + */ + public function mtime($file) { + return filemtime( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @return int + */ + public function size($file) { + return filesize( $this->sftp_path( $file ) ); + } + + /** + * + * @param string $file + * @param int $time + * @param int $atime + */ + public function touch($file, $time = 0, $atime = 0) { + //Not implemented. + } + + /** + * + * @param string $path + * @param mixed $chmod + * @param mixed $chown + * @param mixed $chgrp + * @return bool + */ + public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { + $path = untrailingslashit($path); + if ( empty($path) ) + return false; + + if ( ! $chmod ) + $chmod = FS_CHMOD_DIR; + if ( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) ) + return false; + if ( $chown ) + $this->chown($path, $chown); + if ( $chgrp ) + $this->chgrp($path, $chgrp); + return true; + } + + /** + * + * @param string $path + * @param bool $recursive + * @return bool + */ + public function rmdir($path, $recursive = false) { + return $this->delete($path, $recursive); + } + + /** + * + * @param string $path + * @param bool $include_hidden + * @param bool $recursive + * @return bool|array + */ + public function dirlist($path, $include_hidden = true, $recursive = false) { + if ( $this->is_file($path) ) { + $limit_file = basename($path); + $path = dirname($path); + } else { + $limit_file = false; + } + + if ( ! $this->is_dir($path) ) + return false; + + $ret = array(); + $dir = @dir( $this->sftp_path( $path ) ); + + if ( ! $dir ) + return false; + + while (false !== ($entry = $dir->read()) ) { + $struc = array(); + $struc['name'] = $entry; + + if ( '.' == $struc['name'] || '..' == $struc['name'] ) + continue; //Do not care about these folders. + + if ( ! $include_hidden && '.' == $struc['name'][0] ) + continue; + + if ( $limit_file && $struc['name'] != $limit_file ) + continue; + + $struc['perms'] = $this->gethchmod($path.'/'.$entry); + $struc['permsn'] = $this->getnumchmodfromh($struc['perms']); + $struc['number'] = false; + $struc['owner'] = $this->owner($path.'/'.$entry); + $struc['group'] = $this->group($path.'/'.$entry); + $struc['size'] = $this->size($path.'/'.$entry); + $struc['lastmodunix']= $this->mtime($path.'/'.$entry); + $struc['lastmod'] = date('M j',$struc['lastmodunix']); + $struc['time'] = date('h:i:s',$struc['lastmodunix']); + $struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f'; + + if ( 'd' == $struc['type'] ) { + if ( $recursive ) + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); + else + $struc['files'] = array(); + } + + $ret[ $struc['name'] ] = $struc; + } + $dir->close(); + unset($dir); + return $ret; + } +} diff --git a/backend/wp-admin/includes/class-wp-importer.php b/backend/wp-admin/includes/class-wp-importer.php new file mode 100644 index 0000000..c5d400b --- /dev/null +++ b/backend/wp-admin/includes/class-wp-importer.php @@ -0,0 +1,323 @@ +prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit ); + $results = $wpdb->get_results( $sql ); + + // Increment offset + $offset = ( $limit + $offset ); + + if ( !empty( $results ) ) { + foreach ( $results as $r ) { + // Set permalinks into array + $hashtable[$r->meta_value] = intval( $r->post_id ); + } + } + } while ( count( $results ) == $limit ); + + // Unset to save memory. + unset( $results, $r ); + + return $hashtable; + } + + /** + * Return count of imported permalinks from WordPress database + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $importer_name + * @param string $bid + * @return int + */ + public function count_imported_posts( $importer_name, $bid ) { + global $wpdb; + + $count = 0; + + // Get count of permalinks + $meta_key = $importer_name . '_' . $bid . '_permalink'; + $sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = '%s'", $meta_key ); + + $result = $wpdb->get_results( $sql ); + + if ( !empty( $result ) ) + $count = intval( $result[0]->cnt ); + + // Unset to save memory. + unset( $results ); + + return $count; + } + + /** + * Set array with imported comments from WordPress database + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $bid + * @return array + */ + public function get_imported_comments( $bid ) { + global $wpdb; + + $hashtable = array(); + + $limit = 100; + $offset = 0; + + // Grab all comments in chunks + do { + $sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit ); + $results = $wpdb->get_results( $sql ); + + // Increment offset + $offset = ( $limit + $offset ); + + if ( !empty( $results ) ) { + foreach ( $results as $r ) { + // Explode comment_agent key + list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent ); + $source_comment_id = intval( $source_comment_id ); + + // Check if this comment came from this blog + if ( $bid == $ca_bid ) { + $hashtable[$source_comment_id] = intval( $r->comment_ID ); + } + } + } + } while ( count( $results ) == $limit ); + + // Unset to save memory. + unset( $results, $r ); + + return $hashtable; + } + + /** + * + * @param int $blog_id + * @return int|void + */ + public function set_blog( $blog_id ) { + if ( is_numeric( $blog_id ) ) { + $blog_id = (int) $blog_id; + } else { + $blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id ); + if ( ( !$parsed = parse_url( $blog ) ) || empty( $parsed['host'] ) ) { + fwrite( STDERR, "Error: can not determine blog_id from $blog_id\n" ); + exit(); + } + if ( empty( $parsed['path'] ) ) { + $parsed['path'] = '/'; + } + $blogs = get_sites( array( 'domain' => $parsed['host'], 'number' => 1, 'path' => $parsed['path'] ) ); + if ( ! $blogs ) { + fwrite( STDERR, "Error: Could not find blog\n" ); + exit(); + } + $blog = array_shift( $blogs ); + $blog_id = (int) $blog->blog_id; + } + + if ( function_exists( 'is_multisite' ) ) { + if ( is_multisite() ) + switch_to_blog( $blog_id ); + } + + return $blog_id; + } + + /** + * + * @param int $user_id + * @return int|void + */ + public function set_user( $user_id ) { + if ( is_numeric( $user_id ) ) { + $user_id = (int) $user_id; + } else { + $user_id = (int) username_exists( $user_id ); + } + + if ( !$user_id || !wp_set_current_user( $user_id ) ) { + fwrite( STDERR, "Error: can not find user\n" ); + exit(); + } + + return $user_id; + } + + /** + * Sort by strlen, longest string first + * + * @param string $a + * @param string $b + * @return int + */ + public function cmpr_strlen( $a, $b ) { + return strlen( $b ) - strlen( $a ); + } + + /** + * GET URL + * + * @param string $url + * @param string $username + * @param string $password + * @param bool $head + * @return array + */ + public function get_page( $url, $username = '', $password = '', $head = false ) { + // Increase the timeout + add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) ); + + $headers = array(); + $args = array(); + if ( true === $head ) + $args['method'] = 'HEAD'; + if ( !empty( $username ) && !empty( $password ) ) + $headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" ); + + $args['headers'] = $headers; + + return wp_safe_remote_request( $url, $args ); + } + + /** + * Bump up the request timeout for http requests + * + * @param int $val + * @return int + */ + public function bump_request_timeout( $val ) { + return 60; + } + + /** + * Check if user has exceeded disk quota + * + * @return bool + */ + public function is_user_over_quota() { + if ( function_exists( 'upload_is_user_over_quota' ) ) { + if ( upload_is_user_over_quota() ) { + return true; + } + } + + return false; + } + + /** + * Replace newlines, tabs, and multiple spaces with a single space + * + * @param string $string + * @return string + */ + public function min_whitespace( $string ) { + return preg_replace( '|[\r\n\t ]+|', ' ', $string ); + } + + /** + * Resets global variables that grow out of control during imports. + * + * @since 3.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global array $wp_actions + */ + public function stop_the_insanity() { + global $wpdb, $wp_actions; + // Or define( 'WP_IMPORTING', true ); + $wpdb->queries = array(); + // Reset $wp_actions to keep it from growing out of control + $wp_actions = array(); + } +} + +/** + * Returns value of command line params. + * Exits when a required param is not set. + * + * @param string $param + * @param bool $required + * @return mixed + */ +function get_cli_args( $param, $required = false ) { + $args = $_SERVER['argv']; + + $out = array(); + + $last_arg = null; + $return = null; + + $il = sizeof( $args ); + + for ( $i = 1, $il; $i < $il; $i++ ) { + if ( (bool) preg_match( "/^--(.+)/", $args[$i], $match ) ) { + $parts = explode( "=", $match[1] ); + $key = preg_replace( "/[^a-z0-9]+/", "", $parts[0] ); + + if ( isset( $parts[1] ) ) { + $out[$key] = $parts[1]; + } else { + $out[$key] = true; + } + + $last_arg = $key; + } elseif ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) { + for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) { + $key = $match[1]{$j}; + $out[$key] = true; + } + + $last_arg = $key; + } elseif ( $last_arg !== null ) { + $out[$last_arg] = $args[$i]; + } + } + + // Check array for specified param + if ( isset( $out[$param] ) ) { + // Set return value + $return = $out[$param]; + } + + // Check for missing required param + if ( !isset( $out[$param] ) && $required ) { + // Display message and exit + echo "\"$param\" parameter is required but was not specified\n"; + exit(); + } + + return $return; +} diff --git a/backend/wp-admin/includes/class-wp-internal-pointers.php b/backend/wp-admin/includes/class-wp-internal-pointers.php new file mode 100644 index 0000000..abdb0de --- /dev/null +++ b/backend/wp-admin/includes/class-wp-internal-pointers.php @@ -0,0 +1,203 @@ + pointer callback + * ) + * + * Example: + * array( + * 'themes.php' => 'wp390_widgets' + * ) + */ + $registered_pointers = array( + 'index.php' => 'wp496_privacy', + ); + + // Check if screen related pointer is registered + if ( empty( $registered_pointers[ $hook_suffix ] ) ) + return; + + $pointers = (array) $registered_pointers[ $hook_suffix ]; + + /* + * Specify required capabilities for feature pointers + * + * Format: + * array( + * pointer callback => Array of required capabilities + * ) + * + * Example: + * array( + * 'wp390_widgets' => array( 'edit_theme_options' ) + * ) + */ + $caps_required = array( + 'wp496_privacy' => array( + 'manage_privacy_options', + 'export_others_personal_data', + 'erase_others_personal_data', + ), + ); + + // Get dismissed pointers + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); + + $got_pointers = false; + foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { + if ( isset( $caps_required[ $pointer ] ) ) { + foreach ( $caps_required[ $pointer ] as $cap ) { + if ( ! current_user_can( $cap ) ) + continue 2; + } + } + + // Bind pointer print function + add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); + $got_pointers = true; + } + + if ( ! $got_pointers ) + return; + + // Add pointers script and style to queue + wp_enqueue_style( 'wp-pointer' ); + wp_enqueue_script( 'wp-pointer' ); + } + + /** + * Print the pointer JavaScript data. + * + * @since 3.3.0 + * + * @static + * + * @param string $pointer_id The pointer ID. + * @param string $selector The HTML elements, on which the pointer should be attached. + * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). + */ + private static function print_js( $pointer_id, $selector, $args ) { + if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) + return; + + ?> + + ' . __( 'Personal Data and Privacy' ) . ''; + $content .= '

    ' . __( 'Personal Data Export and Erasure' ) . '

    '; + $content .= '

    ' . __( 'New Tools have been added to help you with personal data export and erasure requests.' ) . '

    '; + $content .= '

    ' . __( 'Privacy Policy' ) . '

    '; + $content .= '

    ' . __( 'Create or select your site’s privacy policy page under Settings > Privacy to keep your users informed and aware.' ) . '

    '; + + if ( is_rtl() ) { + $position = array( + 'edge' => 'right', + 'align' => 'bottom', + ); + } else { + $position = array( + 'edge' => 'left', + 'align' => 'bottom', + ); + } + + $js_args = array( + 'content' => $content, + 'position' => $position, + 'pointerClass' => 'wp-pointer arrow-bottom', + 'pointerWidth' => 420, + ); + self::print_js( 'wp496_privacy', '#menu-tools', $js_args ); + } + + /** + * Prevents new users from seeing existing 'new feature' pointers. + * + * @since 3.3.0 + * + * @static + * + * @param int $user_id User ID. + */ + public static function dismiss_pointers_for_new_users( $user_id ) { + add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp496_privacy' ); + } +} diff --git a/backend/wp-admin/includes/class-wp-links-list-table.php b/backend/wp-admin/includes/class-wp-links-list-table.php new file mode 100644 index 0000000..0c24121 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-links-list-table.php @@ -0,0 +1,321 @@ + 'bookmarks', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + return current_user_can( 'manage_links' ); + } + + /** + * + * @global int $cat_id + * @global string $s + * @global string $orderby + * @global string $order + */ + public function prepare_items() { + global $cat_id, $s, $orderby, $order; + + wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); + + $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); + + if ( 'all' != $cat_id ) + $args['category'] = $cat_id; + if ( !empty( $s ) ) + $args['search'] = $s; + if ( !empty( $orderby ) ) + $args['orderby'] = $orderby; + if ( !empty( $order ) ) + $args['order'] = $order; + + $this->items = get_bookmarks( $args ); + } + + /** + */ + public function no_items() { + _e( 'No links found.' ); + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + $actions['delete'] = __( 'Delete' ); + + return $actions; + } + + /** + * + * @global int $cat_id + * @param string $which + */ + protected function extra_tablenav( $which ) { + global $cat_id; + + if ( 'top' != $which ) + return; +?> +
    + $cat_id, + 'name' => 'cat_id', + 'taxonomy' => 'link_category', + 'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items, + 'hide_empty' => true, + 'hierarchical' => 1, + 'show_count' => 0, + 'orderby' => 'name', + ); + + echo ''; + wp_dropdown_categories( $dropdown_options ); + submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); +?> +
    + '', + 'name' => _x( 'Name', 'link name' ), + 'url' => __( 'URL' ), + 'categories' => __( 'Categories' ), + 'rel' => __( 'Relationship' ), + 'visible' => __( 'Visible' ), + 'rating' => __( 'Rating' ) + ); + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'name' => 'name', + 'url' => 'url', + 'visible' => 'visible', + 'rating' => 'rating' + ); + } + + /** + * Get the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, 'name'. + */ + protected function get_default_primary_column_name() { + return 'name'; + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param object $link The current link object. + */ + public function column_cb( $link ) { + ?> + + + %s', + $edit_link, + /* translators: %s: link name */ + esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ), + $link->link_name + ); + } + + /** + * Handles the link URL column output. + * + * @since 4.3.0 + * + * @param object $link The current link object. + */ + public function column_url( $link ) { + $short_url = url_shorten( $link->link_url ); + echo "$short_url"; + } + + /** + * Handles the link categories column output. + * + * @since 4.3.0 + * + * @global int $cat_id + * + * @param object $link The current link object. + */ + public function column_categories( $link ) { + global $cat_id; + + $cat_names = array(); + foreach ( $link->link_category as $category ) { + $cat = get_term( $category, 'link_category', OBJECT, 'display' ); + if ( is_wp_error( $cat ) ) { + echo $cat->get_error_message(); + } + $cat_name = $cat->name; + if ( $cat_id != $category ) { + $cat_name = "$cat_name"; + } + $cat_names[] = $cat_name; + } + echo implode( ', ', $cat_names ); + } + + /** + * Handles the link relation column output. + * + * @since 4.3.0 + * + * @param object $link The current link object. + */ + public function column_rel( $link ) { + echo empty( $link->link_rel ) ? '
    ' : $link->link_rel; + } + + /** + * Handles the link visibility column output. + * + * @since 4.3.0 + * + * @param object $link The current link object. + */ + public function column_visible( $link ) { + if ( 'Y' === $link->link_visible ) { + _e( 'Yes' ); + } else { + _e( 'No' ); + } + } + + /** + * Handles the link rating column output. + * + * @since 4.3.0 + * + * @param object $link The current link object. + */ + public function column_rating( $link ) { + echo $link->link_rating; + } + + /** + * Handles the default column output. + * + * @since 4.3.0 + * + * @param object $link Link object. + * @param string $column_name Current column name. + */ + public function column_default( $link, $column_name ) { + /** + * Fires for each registered custom link column. + * + * @since 2.1.0 + * + * @param string $column_name Name of the custom column. + * @param int $link_id Link ID. + */ + do_action( 'manage_link_custom_column', $column_name, $link->link_id ); + } + + public function display_rows() { + foreach ( $this->items as $link ) { + $link = sanitize_bookmark( $link ); + $link->link_name = esc_attr( $link->link_name ); + $link->link_category = wp_get_link_cats( $link->link_id ); +?> + + single_row_columns( $link ) ?> + +' . __('Edit') . ''; + $actions['delete'] = "link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . ""; + return $this->row_actions( $actions ); + } +} diff --git a/backend/wp-admin/includes/class-wp-list-table-compat.php b/backend/wp-admin/includes/class-wp-list-table-compat.php new file mode 100644 index 0000000..b52e04c --- /dev/null +++ b/backend/wp-admin/includes/class-wp-list-table-compat.php @@ -0,0 +1,51 @@ +_screen = $screen; + + if ( !empty( $columns ) ) { + $this->_columns = $columns; + add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 ); + } + } + + /** + * + * @return array + */ + protected function get_column_info() { + $columns = get_column_headers( $this->_screen ); + $hidden = get_hidden_columns( $this->_screen ); + $sortable = array(); + $primary = $this->get_default_primary_column_name(); + + return array( $columns, $hidden, $sortable, $primary ); + } + + /** + * + * @return array + */ + public function get_columns() { + return $this->_columns; + } +} diff --git a/backend/wp-admin/includes/class-wp-list-table.php b/backend/wp-admin/includes/class-wp-list-table.php new file mode 100644 index 0000000..d47b530 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-list-table.php @@ -0,0 +1,1323 @@ +get_column_info(). + * + * @since 4.1.0 + * @var array + */ + protected $_column_headers; + + /** + * {@internal Missing Summary} + * + * @var array + */ + protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); + + /** + * {@internal Missing Summary} + * + * @var array + */ + protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', + 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination', + 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', + 'single_row_columns' ); + + /** + * Constructor. + * + * The child class should call this constructor from its own constructor to override + * the default $args. + * + * @since 3.1.0 + * + * @param array|string $args { + * Array or string of arguments. + * + * @type string $plural Plural value used for labels and the objects being listed. + * This affects things such as CSS class-names and nonces used + * in the list table, e.g. 'posts'. Default empty. + * @type string $singular Singular label for an object being listed, e.g. 'post'. + * Default empty + * @type bool $ajax Whether the list table supports Ajax. This includes loading + * and sorting data, for example. If true, the class will call + * the _js_vars() method in the footer to provide variables + * to any scripts handling Ajax events. Default false. + * @type string $screen String containing the hook name used to determine the current + * screen. If left null, the current screen will be automatically set. + * Default null. + * } + */ + public function __construct( $args = array() ) { + $args = wp_parse_args( $args, array( + 'plural' => '', + 'singular' => '', + 'ajax' => false, + 'screen' => null, + ) ); + + $this->screen = convert_to_screen( $args['screen'] ); + + add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); + + if ( !$args['plural'] ) + $args['plural'] = $this->screen->base; + + $args['plural'] = sanitize_key( $args['plural'] ); + $args['singular'] = sanitize_key( $args['singular'] ); + + $this->_args = $args; + + if ( $args['ajax'] ) { + // wp_enqueue_script( 'list-table' ); + add_action( 'admin_footer', array( $this, '_js_vars' ) ); + } + + if ( empty( $this->modes ) ) { + $this->modes = array( + 'list' => __( 'List View' ), + 'excerpt' => __( 'Excerpt View' ) + ); + } + } + + /** + * Make private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name; + } + } + + /** + * Make private properties settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set( $name, $value ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name = $value; + } + } + + /** + * Make private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } + } + + /** + * Make private properties un-settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to unset. + */ + public function __unset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + unset( $this->$name ); + } + } + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|bool Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( in_array( $name, $this->compat_methods ) ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Checks the current user's permissions + * + * @since 3.1.0 + * @abstract + */ + public function ajax_user_can() { + die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' ); + } + + /** + * Prepares the list of items for displaying. + * @uses WP_List_Table::set_pagination_args() + * + * @since 3.1.0 + * @abstract + */ + public function prepare_items() { + die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' ); + } + + /** + * An internal method that sets all the necessary pagination arguments + * + * @since 3.1.0 + * + * @param array|string $args Array or string of arguments with information about the pagination. + */ + protected function set_pagination_args( $args ) { + $args = wp_parse_args( $args, array( + 'total_items' => 0, + 'total_pages' => 0, + 'per_page' => 0, + ) ); + + if ( !$args['total_pages'] && $args['per_page'] > 0 ) + $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); + + // Redirect if page number is invalid and headers are not already sent. + if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { + wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); + exit; + } + + $this->_pagination_args = $args; + } + + /** + * Access the pagination args. + * + * @since 3.1.0 + * + * @param string $key Pagination argument to retrieve. Common values include 'total_items', + * 'total_pages', 'per_page', or 'infinite_scroll'. + * @return int Number of items that correspond to the given pagination argument. + */ + public function get_pagination_arg( $key ) { + if ( 'page' === $key ) { + return $this->get_pagenum(); + } + + if ( isset( $this->_pagination_args[$key] ) ) { + return $this->_pagination_args[$key]; + } + } + + /** + * Whether the table has items to display or not + * + * @since 3.1.0 + * + * @return bool + */ + public function has_items() { + return !empty( $this->items ); + } + + /** + * Message to be displayed when there are no items + * + * @since 3.1.0 + */ + public function no_items() { + _e( 'No items found.' ); + } + + /** + * Displays the search box. + * + * @since 3.1.0 + * + * @param string $text The 'submit' button label. + * @param string $input_id ID attribute value for the search input field. + */ + public function search_box( $text, $input_id ) { + if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) + return; + + $input_id = $input_id . '-search-input'; + + if ( ! empty( $_REQUEST['orderby'] ) ) + echo ''; + if ( ! empty( $_REQUEST['order'] ) ) + echo ''; + if ( ! empty( $_REQUEST['post_mime_type'] ) ) + echo ''; + if ( ! empty( $_REQUEST['detached'] ) ) + echo ''; +?> + + link ) with the list + * of views available on this table. + * + * @since 3.1.0 + * + * @return array + */ + protected function get_views() { + return array(); + } + + /** + * Display the list of views available on this table. + * + * @since 3.1.0 + */ + public function views() { + $views = $this->get_views(); + /** + * Filters the list of available list table views. + * + * The dynamic portion of the hook name, `$this->screen->id`, refers + * to the ID of the current screen, usually a string. + * + * @since 3.5.0 + * + * @param array $views An array of available list table views. + */ + $views = apply_filters( "views_{$this->screen->id}", $views ); + + if ( empty( $views ) ) + return; + + $this->screen->render_screen_reader_content( 'heading_views' ); + + echo "
      \n"; + foreach ( $views as $class => $view ) { + $views[ $class ] = "\t
    • $view"; + } + echo implode( " |
    • \n", $views ) . "\n"; + echo "
    "; + } + + /** + * Get an associative array ( option_name => option_title ) with the list + * of bulk actions available on this table. + * + * @since 3.1.0 + * + * @return array + */ + protected function get_bulk_actions() { + return array(); + } + + /** + * Display the bulk actions dropdown. + * + * @since 3.1.0 + * + * @param string $which The location of the bulk actions: 'top' or 'bottom'. + * This is designated as optional for backward compatibility. + */ + protected function bulk_actions( $which = '' ) { + if ( is_null( $this->_actions ) ) { + $this->_actions = $this->get_bulk_actions(); + /** + * Filters the list table Bulk Actions drop-down. + * + * The dynamic portion of the hook name, `$this->screen->id`, refers + * to the ID of the current screen, usually a string. + * + * This filter can currently only be used to remove bulk actions. + * + * @since 3.5.0 + * + * @param array $actions An array of the available bulk actions. + */ + $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); + $two = ''; + } else { + $two = '2'; + } + + if ( empty( $this->_actions ) ) + return; + + echo ''; + echo '\n"; + + submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); + echo "\n"; + } + + /** + * Get the current action selected from the bulk actions dropdown. + * + * @since 3.1.0 + * + * @return string|false The action name or False if no action was selected + */ + public function current_action() { + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) + return false; + + if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) + return $_REQUEST['action']; + + if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) + return $_REQUEST['action2']; + + return false; + } + + /** + * Generate row actions div + * + * @since 3.1.0 + * + * @param array $actions The list of actions + * @param bool $always_visible Whether the actions should be always visible + * @return string + */ + protected function row_actions( $actions, $always_visible = false ) { + $action_count = count( $actions ); + $i = 0; + + if ( !$action_count ) + return ''; + + $out = '
    '; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $out .= "$link$sep"; + } + $out .= '
    '; + + $out .= ''; + + return $out; + } + + /** + * Display a monthly dropdown for filtering items + * + * @since 3.1.0 + * + * @global wpdb $wpdb + * @global WP_Locale $wp_locale + * + * @param string $post_type + */ + protected function months_dropdown( $post_type ) { + global $wpdb, $wp_locale; + + /** + * Filters whether to remove the 'Months' drop-down from the post list table. + * + * @since 4.2.0 + * + * @param bool $disable Whether to disable the drop-down. Default false. + * @param string $post_type The post type. + */ + if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { + return; + } + + $extra_checks = "AND post_status != 'auto-draft'"; + if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) { + $extra_checks .= " AND post_status != 'trash'"; + } elseif ( isset( $_GET['post_status'] ) ) { + $extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] ); + } + + $months = $wpdb->get_results( $wpdb->prepare( " + SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = %s + $extra_checks + ORDER BY post_date DESC + ", $post_type ) ); + + /** + * Filters the 'Months' drop-down results. + * + * @since 3.7.0 + * + * @param object $months The months drop-down query results. + * @param string $post_type The post type. + */ + $months = apply_filters( 'months_dropdown_results', $months, $post_type ); + + $month_count = count( $months ); + + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) + return; + + $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; +?> + + + + +
    +modes as $mode => $title ) { + $classes = array( 'view-' . $mode ); + if ( $current_mode === $mode ) + $classes[] = 'current'; + printf( + "%s\n", + esc_url( add_query_arg( 'mode', $mode ) ), + implode( ' ', $classes ), + $title + ); + } + ?> +
    +%s', + __( 'No comments' ) + ); + // Approved comments have different display depending on some conditions. + } elseif ( $approved_comments ) { + printf( '%s', + esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ), + $approved_comments_number, + $pending_comments ? $approved_phrase : $approved_only_phrase + ); + } else { + printf( '%s', + $approved_comments_number, + $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) + ); + } + + if ( $pending_comments ) { + printf( '%s', + esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ), + $pending_comments_number, + $pending_phrase + ); + } else { + printf( '%s', + $pending_comments_number, + $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) + ); + } + } + + /** + * Get the current page number + * + * @since 3.1.0 + * + * @return int + */ + public function get_pagenum() { + $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; + + if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) + $pagenum = $this->_pagination_args['total_pages']; + + return max( 1, $pagenum ); + } + + /** + * Get number of items to display on a single page + * + * @since 3.1.0 + * + * @param string $option + * @param int $default + * @return int + */ + protected function get_items_per_page( $option, $default = 20 ) { + $per_page = (int) get_user_option( $option ); + if ( empty( $per_page ) || $per_page < 1 ) + $per_page = $default; + + /** + * Filters the number of items to be displayed on each page of the list table. + * + * The dynamic hook name, $option, refers to the `per_page` option depending + * on the type of list table in use. Possible values include: 'edit_comments_per_page', + * 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page', + * 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page', + * 'edit_{$post_type}_per_page', etc. + * + * @since 2.9.0 + * + * @param int $per_page Number of items to be displayed. Default 20. + */ + return (int) apply_filters( "{$option}", $per_page ); + } + + /** + * Display the pagination. + * + * @since 3.1.0 + * + * @param string $which + */ + protected function pagination( $which ) { + if ( empty( $this->_pagination_args ) ) { + return; + } + + $total_items = $this->_pagination_args['total_items']; + $total_pages = $this->_pagination_args['total_pages']; + $infinite_scroll = false; + if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { + $infinite_scroll = $this->_pagination_args['infinite_scroll']; + } + + if ( 'top' === $which && $total_pages > 1 ) { + $this->screen->render_screen_reader_content( 'heading_pagination' ); + } + + $output = '' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . ''; + + $current = $this->get_pagenum(); + $removable_query_args = wp_removable_query_args(); + + $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + + $current_url = remove_query_arg( $removable_query_args, $current_url ); + + $page_links = array(); + + $total_pages_before = ''; + $total_pages_after = ''; + + $disable_first = $disable_last = $disable_prev = $disable_next = false; + + if ( $current == 1 ) { + $disable_first = true; + $disable_prev = true; + } + if ( $current == 2 ) { + $disable_first = true; + } + if ( $current == $total_pages ) { + $disable_last = true; + $disable_next = true; + } + if ( $current == $total_pages - 1 ) { + $disable_last = true; + } + + if ( $disable_first ) { + $page_links[] = ''; + } else { + $page_links[] = sprintf( "%s", + esc_url( remove_query_arg( 'paged', $current_url ) ), + __( 'First page' ), + '«' + ); + } + + if ( $disable_prev ) { + $page_links[] = ''; + } else { + $page_links[] = sprintf( "%s", + esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), + __( 'Previous page' ), + '‹' + ); + } + + if ( 'bottom' === $which ) { + $html_current_page = $current; + $total_pages_before = '' . __( 'Current Page' ) . ''; + } else { + $html_current_page = sprintf( "%s", + '', + $current, + strlen( $total_pages ) + ); + } + $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); + $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; + + if ( $disable_next ) { + $page_links[] = ''; + } else { + $page_links[] = sprintf( "%s", + esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), + __( 'Next page' ), + '›' + ); + } + + if ( $disable_last ) { + $page_links[] = ''; + } else { + $page_links[] = sprintf( "%s", + esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), + __( 'Last page' ), + '»' + ); + } + + $pagination_links_class = 'pagination-links'; + if ( ! empty( $infinite_scroll ) ) { + $pagination_links_class .= ' hide-if-js'; + } + $output .= "\n" . join( "\n", $page_links ) . ''; + + if ( $total_pages ) { + $page_class = $total_pages < 2 ? ' one-page' : ''; + } else { + $page_class = ' no-pages'; + } + $this->_pagination = "
    $output
    "; + + echo $this->_pagination; + } + + /** + * Get a list of columns. The format is: + * 'internal-name' => 'Title' + * + * @since 3.1.0 + * @abstract + * + * @return array + */ + public function get_columns() { + die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' ); + } + + /** + * Get a list of sortable columns. The format is: + * 'internal-name' => 'orderby' + * or + * 'internal-name' => array( 'orderby', true ) + * + * The second format will make the initial sorting order be descending + * + * @since 3.1.0 + * + * @return array + */ + protected function get_sortable_columns() { + return array(); + } + + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, an empty string. + */ + protected function get_default_primary_column_name() { + $columns = $this->get_columns(); + $column = ''; + + if ( empty( $columns ) ) { + return $column; + } + + // We need a primary defined so responsive views show something, + // so let's fall back to the first non-checkbox column. + foreach ( $columns as $col => $column_name ) { + if ( 'cb' === $col ) { + continue; + } + + $column = $col; + break; + } + + return $column; + } + + /** + * Public wrapper for WP_List_Table::get_default_primary_column_name(). + * + * @since 4.4.0 + * + * @return string Name of the default primary column. + */ + public function get_primary_column() { + return $this->get_primary_column_name(); + } + + /** + * Gets the name of the primary column. + * + * @since 4.3.0 + * + * @return string The name of the primary column. + */ + protected function get_primary_column_name() { + $columns = get_column_headers( $this->screen ); + $default = $this->get_default_primary_column_name(); + + // If the primary column doesn't exist fall back to the + // first non-checkbox column. + if ( ! isset( $columns[ $default ] ) ) { + $default = WP_List_Table::get_default_primary_column_name(); + } + + /** + * Filters the name of the primary column for the current list table. + * + * @since 4.3.0 + * + * @param string $default Column name default for the specific list table, e.g. 'name'. + * @param string $context Screen ID for specific list table, e.g. 'plugins'. + */ + $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); + + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { + $column = $default; + } + + return $column; + } + + /** + * Get a list of all, hidden and sortable columns, with filter applied + * + * @since 3.1.0 + * + * @return array + */ + protected function get_column_info() { + // $_column_headers is already set / cached + if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { + // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. + // In 4.3, we added a fourth argument for primary column. + $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); + foreach ( $this->_column_headers as $key => $value ) { + $column_headers[ $key ] = $value; + } + + return $column_headers; + } + + $columns = get_column_headers( $this->screen ); + $hidden = get_hidden_columns( $this->screen ); + + $sortable_columns = $this->get_sortable_columns(); + /** + * Filters the list table sortable columns for a specific screen. + * + * The dynamic portion of the hook name, `$this->screen->id`, refers + * to the ID of the current screen, usually a string. + * + * @since 3.5.0 + * + * @param array $sortable_columns An array of sortable columns. + */ + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); + + $sortable = array(); + foreach ( $_sortable as $id => $data ) { + if ( empty( $data ) ) + continue; + + $data = (array) $data; + if ( !isset( $data[1] ) ) + $data[1] = false; + + $sortable[$id] = $data; + } + + $primary = $this->get_primary_column_name(); + $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); + + return $this->_column_headers; + } + + /** + * Return number of visible columns + * + * @since 3.1.0 + * + * @return int + */ + public function get_column_count() { + list ( $columns, $hidden ) = $this->get_column_info(); + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); + return count( $columns ) - count( $hidden ); + } + + /** + * Print column headers, accounting for hidden and sortable columns. + * + * @since 3.1.0 + * + * @staticvar int $cb_counter + * + * @param bool $with_id Whether to set the id attribute or not + */ + public function print_column_headers( $with_id = true ) { + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); + + $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + $current_url = remove_query_arg( 'paged', $current_url ); + + if ( isset( $_GET['orderby'] ) ) { + $current_orderby = $_GET['orderby']; + } else { + $current_orderby = ''; + } + + if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { + $current_order = 'desc'; + } else { + $current_order = 'asc'; + } + + if ( ! empty( $columns['cb'] ) ) { + static $cb_counter = 1; + $columns['cb'] = '' + . ''; + $cb_counter++; + } + + foreach ( $columns as $column_key => $column_display_name ) { + $class = array( 'manage-column', "column-$column_key" ); + + if ( in_array( $column_key, $hidden ) ) { + $class[] = 'hidden'; + } + + if ( 'cb' === $column_key ) + $class[] = 'check-column'; + elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) + $class[] = 'num'; + + if ( $column_key === $primary ) { + $class[] = 'column-primary'; + } + + if ( isset( $sortable[$column_key] ) ) { + list( $orderby, $desc_first ) = $sortable[$column_key]; + + if ( $current_orderby === $orderby ) { + $order = 'asc' === $current_order ? 'desc' : 'asc'; + $class[] = 'sorted'; + $class[] = $current_order; + } else { + $order = $desc_first ? 'desc' : 'asc'; + $class[] = 'sortable'; + $class[] = $desc_first ? 'asc' : 'desc'; + } + + $column_display_name = '' . $column_display_name . ''; + } + + $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; + $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; + $id = $with_id ? "id='$column_key'" : ''; + + if ( !empty( $class ) ) + $class = "class='" . join( ' ', $class ) . "'"; + + echo "<$tag $scope $id $class>$column_display_name"; + } + } + + /** + * Display the table + * + * @since 3.1.0 + */ + public function display() { + $singular = $this->_args['singular']; + + $this->display_tablenav( 'top' ); + + $this->screen->render_screen_reader_content( 'heading_list' ); +?> + + + + print_column_headers(); ?> + + + + > + display_rows_or_placeholder(); ?> + + + + + print_column_headers( false ); ?> + + + +
    +display_tablenav( 'bottom' ); + } + + /** + * Get a list of CSS classes for the WP_List_Table table tag. + * + * @since 3.1.0 + * + * @return array List of CSS classes for the table tag. + */ + protected function get_table_classes() { + return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] ); + } + + /** + * Generate the table navigation above or below the table + * + * @since 3.1.0 + * @param string $which + */ + protected function display_tablenav( $which ) { + if ( 'top' === $which ) { + wp_nonce_field( 'bulk-' . $this->_args['plural'] ); + } + ?> +
    + + has_items() ): ?> +
    + bulk_actions( $which ); ?> +
    + extra_tablenav( $which ); + $this->pagination( $which ); +?> + +
    +
    +has_items() ) { + $this->display_rows(); + } else { + echo ''; + $this->no_items(); + echo ''; + } + } + + /** + * Generate the table rows + * + * @since 3.1.0 + */ + public function display_rows() { + foreach ( $this->items as $item ) + $this->single_row( $item ); + } + + /** + * Generates content for a single row of the table + * + * @since 3.1.0 + * + * @param object $item The current item + */ + public function single_row( $item ) { + echo ''; + $this->single_row_columns( $item ); + echo ''; + } + + /** + * + * @param object $item + * @param string $column_name + */ + protected function column_default( $item, $column_name ) {} + + /** + * + * @param object $item + */ + protected function column_cb( $item ) {} + + /** + * Generates the columns for a single row of the table + * + * @since 3.1.0 + * + * @param object $item The current item + */ + protected function single_row_columns( $item ) { + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $classes = "$column_name column-$column_name"; + if ( $primary === $column_name ) { + $classes .= ' has-row-actions column-primary'; + } + + if ( in_array( $column_name, $hidden ) ) { + $classes .= ' hidden'; + } + + // Comments column uses HTML in the display name with screen reader text. + // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string. + $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; + + $attributes = "class='$classes' $data"; + + if ( 'cb' === $column_name ) { + echo ''; + echo $this->column_cb( $item ); + echo ''; + } elseif ( method_exists( $this, '_column_' . $column_name ) ) { + echo call_user_func( + array( $this, '_column_' . $column_name ), + $item, + $classes, + $data, + $primary + ); + } elseif ( method_exists( $this, 'column_' . $column_name ) ) { + echo ""; + echo call_user_func( array( $this, 'column_' . $column_name ), $item ); + echo $this->handle_row_actions( $item, $column_name, $primary ); + echo ""; + } else { + echo ""; + echo $this->column_default( $item, $column_name ); + echo $this->handle_row_actions( $item, $column_name, $primary ); + echo ""; + } + } + } + + /** + * Generates and display row actions links for the list table. + * + * @since 4.3.0 + * + * @param object $item The item being acted upon. + * @param string $column_name Current column name. + * @param string $primary Primary column name. + * @return string The row actions HTML, or an empty string if the current column is the primary column. + */ + protected function handle_row_actions( $item, $column_name, $primary ) { + return $column_name === $primary ? '' : ''; + } + + /** + * Handle an incoming ajax request (called from admin-ajax.php) + * + * @since 3.1.0 + */ + public function ajax_response() { + $this->prepare_items(); + + ob_start(); + if ( ! empty( $_REQUEST['no_placeholder'] ) ) { + $this->display_rows(); + } else { + $this->display_rows_or_placeholder(); + } + + $rows = ob_get_clean(); + + $response = array( 'rows' => $rows ); + + if ( isset( $this->_pagination_args['total_items'] ) ) { + $response['total_items_i18n'] = sprintf( + _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), + number_format_i18n( $this->_pagination_args['total_items'] ) + ); + } + if ( isset( $this->_pagination_args['total_pages'] ) ) { + $response['total_pages'] = $this->_pagination_args['total_pages']; + $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); + } + + die( wp_json_encode( $response ) ); + } + + /** + * Send required variables to JavaScript land + * + */ + public function _js_vars() { + $args = array( + 'class' => get_class( $this ), + 'screen' => array( + 'id' => $this->screen->id, + 'base' => $this->screen->base, + ) + ); + + printf( "\n", wp_json_encode( $args ) ); + } +} diff --git a/backend/wp-admin/includes/class-wp-media-list-table.php b/backend/wp-admin/includes/class-wp-media-list-table.php new file mode 100644 index 0000000..9cbae42 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-media-list-table.php @@ -0,0 +1,777 @@ +detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); + + $this->modes = array( + 'list' => __( 'List View' ), + 'grid' => __( 'Grid View' ) + ); + + parent::__construct( array( + 'plural' => 'media', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + return current_user_can('upload_files'); + } + + /** + * + * @global WP_Query $wp_query + * @global array $post_mime_types + * @global array $avail_post_mime_types + * @global string $mode + */ + public function prepare_items() { + global $wp_query, $post_mime_types, $avail_post_mime_types, $mode; + + list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); + + $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; + + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + + $this->set_pagination_args( array( + 'total_items' => $wp_query->found_posts, + 'total_pages' => $wp_query->max_num_pages, + 'per_page' => $wp_query->query_vars['posts_per_page'], + ) ); + } + + /** + * @global array $post_mime_types + * @global array $avail_post_mime_types + * @return array + */ + protected function get_views() { + global $post_mime_types, $avail_post_mime_types; + + $type_links = array(); + + $filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter']; + + $type_links['all'] = sprintf( + '', + selected( $filter, true, false ), + __( 'All media items' ) + ); + + foreach ( $post_mime_types as $mime_type => $label ) { + if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { + continue; + } + + $selected = selected( + $filter && 0 === strpos( $filter, 'post_mime_type:' ) && + wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), + true, + false + ); + + $type_links[$mime_type] = sprintf( + '', + esc_attr( $mime_type ), + $selected, + $label[0] + ); + } + + $type_links['detached'] = ''; + + $type_links['mine'] = sprintf( + '', + selected( 'mine' === $filter, true, false ), + _x( 'Mine', 'media items' ) + ); + + if ( $this->is_trash || ( defined( 'MEDIA_TRASH') && MEDIA_TRASH ) ) { + $type_links['trash'] = sprintf( + '', + selected( 'trash' === $filter, true, false ), + _x( 'Trash', 'attachment filter' ) + ); + } + + return $type_links; + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + if ( MEDIA_TRASH ) { + if ( $this->is_trash ) { + $actions['untrash'] = __( 'Restore' ); + $actions['delete'] = __( 'Delete Permanently' ); + } else { + $actions['trash'] = _x( 'Trash', 'verb' ); + } + } else { + $actions['delete'] = __( 'Delete Permanently' ); + } + + if ( $this->detached ) + $actions['attach'] = __( 'Attach' ); + + return $actions; + } + + /** + * @param string $which + */ + protected function extra_tablenav( $which ) { + if ( 'bar' !== $which ) { + return; + } +?> +
    +is_trash ) { + $this->months_dropdown( 'attachment' ); + } + + /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ + do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); + + submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); + } + + if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { + submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); + } ?> +
    +get_views(); + + $this->screen->render_screen_reader_content( 'heading_views' ); +?> +
    +
    + view_switcher( $mode ); ?> + + + + +extra_tablenav( 'bar' ); + + /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ + $views = apply_filters( "views_{$this->screen->id}", array() ); + + // Back compat for pre-4.0 view links. + if ( ! empty( $views ) ) { + echo ''; + } +?> +
    + +
    + +
    +
    + '; + /* translators: column name */ + $posts_columns['title'] = _x( 'File', 'column name' ); + $posts_columns['author'] = __( 'Author' ); + + $taxonomies = get_taxonomies_for_attachments( 'objects' ); + $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); + + /** + * Filters the taxonomy columns for attachments in the Media list table. + * + * @since 3.5.0 + * + * @param array $taxonomies An array of registered taxonomies to show for attachments. + * @param string $post_type The post type. Default 'attachment'. + */ + $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); + $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); + + foreach ( $taxonomies as $taxonomy ) { + if ( 'category' === $taxonomy ) { + $column_key = 'categories'; + } elseif ( 'post_tag' === $taxonomy ) { + $column_key = 'tags'; + } else { + $column_key = 'taxonomy-' . $taxonomy; + } + $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; + } + + /* translators: column name */ + if ( !$this->detached ) { + $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); + if ( post_type_supports( 'attachment', 'comments' ) ) + $posts_columns['comments'] = '' . __( 'Comments' ) . ''; + } + /* translators: column name */ + $posts_columns['date'] = _x( 'Date', 'column name' ); + /** + * Filters the Media list table columns. + * + * @since 2.5.0 + * + * @param array $posts_columns An array of columns displayed in the Media list table. + * @param bool $detached Whether the list table contains media not attached + * to any posts. Default true. + */ + return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'title' => 'title', + 'author' => 'author', + 'parent' => 'parent', + 'comments' => 'comment_count', + 'date' => array( 'date', true ), + ); + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_cb( $post ) { + if ( current_user_can( 'edit_post', $post->ID ) ) { ?> + + + post_mime_type ); + + $title = _draft_or_post_title(); + $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); + $link_start = $link_end = ''; + + if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { + $link_start = sprintf( + '', + get_edit_post_link( $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) + ); + $link_end = ''; + } + + $class = $thumb ? ' class="has-media-icon"' : ''; + ?> + > + + + + +

    + + ID ); + echo esc_html( wp_basename( $file ) ); + ?> +

    + %s', + esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ), + get_the_author() + ); + } + + /** + * Handles the description column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_desc( $post ) { + echo has_excerpt() ? $post->post_excerpt : ''; + } + + /** + * Handles the date column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_date( $post ) { + if ( '0000-00-00 00:00:00' === $post->post_date ) { + $h_time = __( 'Unpublished' ); + } else { + $m_time = $post->post_date; + $time = get_post_time( 'G', true, $post, false ); + if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { + if ( $t_diff < 0 ) { + $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); + } else { + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); + } + } else { + $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + } + } + + echo $h_time; + } + + /** + * Handles the parent column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_parent( $post ) { + $user_can_edit = current_user_can( 'edit_post', $post->ID ); + + if ( $post->post_parent > 0 ) { + $parent = get_post( $post->post_parent ); + } else { + $parent = false; + } + + if ( $parent ) { + $title = _draft_or_post_title( $post->post_parent ); + $parent_type = get_post_type_object( $parent->post_type ); + + if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { +?> + + post_parent ) ) { +?> + $post->post_parent, + 'media[]' => $post->ID, + '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) + ), 'upload.php' ); + printf( + '
    %s', + $detach_url, + /* translators: %s: title of the post the attachment is attached to */ + esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), + __( 'Detach' ) + ); + endif; + } else { + _e( '(Unattached)' ); ?> + post_parent ); + printf( + '
    %s', + $post->ID, + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), + __( 'Attach' ) + ); + } + } + } + + /** + * Handles the comments column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_comments( $post ) { + echo '
    '; + + if ( isset( $this->comment_pending_count[ $post->ID ] ) ) { + $pending_comments = $this->comment_pending_count[ $post->ID ]; + } else { + $pending_comments = get_pending_comments_num( $post->ID ); + } + + $this->comments_bubble( $post->ID, $pending_comments ); + + echo '
    '; + } + + /** + * Handles output for the default column. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + * @param string $column_name Current column name. + */ + public function column_default( $post, $column_name ) { + if ( 'categories' === $column_name ) { + $taxonomy = 'category'; + } elseif ( 'tags' === $column_name ) { + $taxonomy = 'post_tag'; + } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { + $taxonomy = substr( $column_name, 9 ); + } else { + $taxonomy = false; + } + + if ( $taxonomy ) { + $terms = get_the_terms( $post->ID, $taxonomy ); + if ( is_array( $terms ) ) { + $out = array(); + foreach ( $terms as $t ) { + $posts_in_term_qv = array(); + $posts_in_term_qv['taxonomy'] = $taxonomy; + $posts_in_term_qv['term'] = $t->slug; + + $out[] = sprintf( '%s', + esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), + esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) + ); + } + /* translators: used between list items, there is a space after the comma */ + echo join( __( ', ' ), $out ); + } else { + echo '' . get_taxonomy( $taxonomy )->labels->no_terms . ''; + } + + return; + } + + /** + * Fires for each custom column in the Media list table. + * + * Custom columns are registered using the {@see 'manage_media_columns'} filter. + * + * @since 2.5.0 + * + * @param string $column_name Name of the custom column. + * @param int $post_id Attachment ID. + */ + do_action( 'manage_media_custom_column', $column_name, $post->ID ); + } + + /** + * + * @global WP_Post $post + */ + public function display_rows() { + global $post, $wp_query; + + $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); + reset( $wp_query->posts ); + + $this->comment_pending_count = get_pending_comments_num( $post_ids ); + + add_filter( 'the_title','esc_html' ); + + while ( have_posts() ) : the_post(); + if ( + ( $this->is_trash && $post->post_status != 'trash' ) + || ( ! $this->is_trash && $post->post_status === 'trash' ) + ) { + continue; + } + $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; + ?> + + single_row_columns( $post ); ?> + + detached ) { + if ( current_user_can( 'edit_post', $post->ID ) ) { + $actions['edit'] = sprintf( + '%s', + get_edit_post_link( $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), + __( 'Edit' ) + ); + } + if ( current_user_can( 'delete_post', $post->ID ) ) { + if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { + $actions['trash'] = sprintf( + '%s', + wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), + _x( 'Trash', 'verb' ) + ); + } else { + $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; + $actions['delete'] = sprintf( + '%s', + wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), + $delete_ays, + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), + __( 'Delete Permanently' ) + ); + } + } + $actions['view'] = sprintf( + '%s', + get_permalink( $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), + __( 'View' ) + ); + + if ( current_user_can( 'edit_post', $post->ID ) ) { + $actions['attach'] = sprintf( + '%s', + $post->ID, + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), + __( 'Attach' ) + ); + } + } + else { + if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) { + $actions['edit'] = sprintf( + '%s', + get_edit_post_link( $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), + __( 'Edit' ) + ); + } + if ( current_user_can( 'delete_post', $post->ID ) ) { + if ( $this->is_trash ) { + $actions['untrash'] = sprintf( + '%s', + wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), + __( 'Restore' ) + ); + } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { + $actions['trash'] = sprintf( + '%s', + wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), + _x( 'Trash', 'verb' ) + ); + } + if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { + $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; + $actions['delete'] = sprintf( + '%s', + wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), + $delete_ays, + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), + __( 'Delete Permanently' ) + ); + } + } + if ( ! $this->is_trash ) { + $actions['view'] = sprintf( + '%s', + get_permalink( $post->ID ), + /* translators: %s: attachment title */ + esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), + __( 'View' ) + ); + } + } + + /** + * Filters the action links for each attachment in the Media list table. + * + * @since 2.8.0 + * + * @param array $actions An array of action links for each attachment. + * Default 'Edit', 'Delete Permanently', 'View'. + * @param WP_Post $post WP_Post object for the current attachment. + * @param bool $detached Whether the list table contains media not attached + * to any posts. Default true. + */ + return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); + } + + /** + * Generates and displays row action links. + * + * @since 4.3.0 + * + * @param object $post Attachment being acted upon. + * @param string $column_name Current column name. + * @param string $primary Primary column name. + * @return string Row actions output for media attachments. + */ + protected function handle_row_actions( $post, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return ''; + } + + $att_title = _draft_or_post_title(); + return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); + } +} diff --git a/backend/wp-admin/includes/class-wp-ms-sites-list-table.php b/backend/wp-admin/includes/class-wp-ms-sites-list-table.php new file mode 100644 index 0000000..f639b36 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -0,0 +1,559 @@ +status_list = array( + 'archived' => array( 'site-archived', __( 'Archived' ) ), + 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), + 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), + 'mature' => array( 'site-mature', __( 'Mature' ) ) + ); + + parent::__construct( array( + 'plural' => 'sites', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + return current_user_can( 'manage_sites' ); + } + + /** + * Prepares the list of sites for display. + * + * @since 3.1.0 + * + * @global string $s + * @global string $mode + * @global wpdb $wpdb + */ + public function prepare_items() { + global $s, $mode, $wpdb; + + if ( ! empty( $_REQUEST['mode'] ) ) { + $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; + set_user_setting( 'sites_list_mode', $mode ); + } else { + $mode = get_user_setting( 'sites_list_mode', 'list' ); + } + + $per_page = $this->get_items_per_page( 'sites_network_per_page' ); + + $pagenum = $this->get_pagenum(); + + $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : ''; + $wild = ''; + if ( false !== strpos($s, '*') ) { + $wild = '*'; + $s = trim($s, '*'); + } + + /* + * If the network is large and a search is not being performed, show only + * the latest sites with no paging in order to avoid expensive count queries. + */ + if ( !$s && wp_is_large_network() ) { + if ( !isset($_REQUEST['orderby']) ) + $_GET['orderby'] = $_REQUEST['orderby'] = ''; + if ( !isset($_REQUEST['order']) ) + $_GET['order'] = $_REQUEST['order'] = 'DESC'; + } + + $args = array( + 'number' => intval( $per_page ), + 'offset' => intval( ( $pagenum - 1 ) * $per_page ), + 'network_id' => get_current_network_id(), + ); + + if ( empty($s) ) { + // Nothing to do. + } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || + preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || + preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || + preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { + // IPv4 address + $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) ); + $reg_blog_ids = $wpdb->get_col( $sql ); + + if ( $reg_blog_ids ) { + $args['site__in'] = $reg_blog_ids; + } + } elseif ( is_numeric( $s ) && empty( $wild ) ) { + $args['ID'] = $s; + } else { + $args['search'] = $s; + + if ( ! is_subdomain_install() ) { + $args['search_columns'] = array( 'path' ); + } + } + + $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; + if ( 'registered' === $order_by ) { + // registered is a valid field name. + } elseif ( 'lastupdated' === $order_by ) { + $order_by = 'last_updated'; + } elseif ( 'blogname' === $order_by ) { + if ( is_subdomain_install() ) { + $order_by = 'domain'; + } else { + $order_by = 'path'; + } + } elseif ( 'blog_id' === $order_by ) { + $order_by = 'id'; + } elseif ( ! $order_by ) { + $order_by = false; + } + + $args['orderby'] = $order_by; + + if ( $order_by ) { + $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC"; + } + + if ( wp_is_large_network() ) { + $args['no_found_rows'] = true; + } else { + $args['no_found_rows'] = false; + } + + /** + * Filters the arguments for the site query in the sites list table. + * + * @since 4.6.0 + * + * @param array $args An array of get_sites() arguments. + */ + $args = apply_filters( 'ms_sites_list_table_query_args', $args ); + + $_sites = get_sites( $args ); + if ( is_array( $_sites ) ) { + update_site_cache( $_sites ); + + $this->items = array_slice( $_sites, 0, $per_page ); + } + + $total_sites = get_sites( array_merge( $args, array( + 'count' => true, + 'offset' => 0, + 'number' => 0, + ) ) ); + + $this->set_pagination_args( array( + 'total_items' => $total_sites, + 'per_page' => $per_page, + ) ); + } + + /** + */ + public function no_items() { + _e( 'No sites found.' ); + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + if ( current_user_can( 'delete_sites' ) ) + $actions['delete'] = __( 'Delete' ); + $actions['spam'] = _x( 'Mark as Spam', 'site' ); + $actions['notspam'] = _x( 'Not Spam', 'site' ); + + return $actions; + } + + /** + * @global string $mode List table view mode. + * + * @param string $which + */ + protected function pagination( $which ) { + global $mode; + + parent::pagination( $which ); + + if ( 'top' === $which ) + $this->view_switcher( $mode ); + } + + /** + * @return array + */ + public function get_columns() { + $sites_columns = array( + 'cb' => '', + 'blogname' => __( 'URL' ), + 'lastupdated' => __( 'Last Updated' ), + 'registered' => _x( 'Registered', 'site' ), + 'users' => __( 'Users' ), + ); + + if ( has_filter( 'wpmublogsaction' ) ) { + $sites_columns['plugins'] = __( 'Actions' ); + } + + /** + * Filters the displayed site columns in Sites list table. + * + * @since MU (3.0.0) + * + * @param array $sites_columns An array of displayed site columns. Default 'cb', + * 'blogname', 'lastupdated', 'registered', 'users'. + */ + return apply_filters( 'wpmu_blogs_columns', $sites_columns ); + } + + /** + * @return array + */ + protected function get_sortable_columns() { + return array( + 'blogname' => 'blogname', + 'lastupdated' => 'lastupdated', + 'registered' => 'blog_id', + ); + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param array $blog Current site. + */ + public function column_cb( $blog ) { + if ( ! is_main_site( $blog['blog_id'] ) ) : + $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); + ?> + + + status_list ); + + foreach ( $this->status_list as $status => $col ) { + if ( $blog[ $status ] == 1 ) { + $blog_states[] = $col[1]; + } + } + $blog_state = ''; + if ( ! empty( $blog_states ) ) { + $state_count = count( $blog_states ); + $i = 0; + $blog_state .= ' — '; + foreach ( $blog_states as $state ) { + ++$i; + $sep = ( $i == $state_count ) ? '' : ', '; + $blog_state .= "$state$sep"; + } + } + + ?> + + + + + '; + printf( + /* translators: 1: site name, 2: site tagline. */ + __( '%1$s – %2$s' ), + get_option( 'blogname' ), + '' . get_option( 'blogdescription ' ) . '' + ); + echo '

    '; + restore_current_blog(); + } + } + + /** + * Handles the lastupdated column output. + * + * @since 4.3.0 + * + * @global string $mode List table view mode. + * + * @param array $blog Current site. + */ + public function column_lastupdated( $blog ) { + global $mode; + + if ( 'list' === $mode ) { + $date = __( 'Y/m/d' ); + } else { + $date = __( 'Y/m/d g:i:s a' ); + } + + echo ( $blog['last_updated'] === '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); + } + + /** + * Handles the registered column output. + * + * @since 4.3.0 + * + * @global string $mode List table view mode. + * + * @param array $blog Current site. + */ + public function column_registered( $blog ) { + global $mode; + + if ( 'list' === $mode ) { + $date = __( 'Y/m/d' ); + } else { + $date = __( 'Y/m/d g:i:s a' ); + } + + if ( $blog['registered'] === '0000-00-00 00:00:00' ) { + echo '—'; + } else { + echo mysql2date( $date, $blog['registered'] ); + } + } + + /** + * Handles the users column output. + * + * @since 4.3.0 + * + * @param array $blog Current site. + */ + public function column_users( $blog ) { + $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ); + if ( ! $user_count ) { + $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) ); + $user_count = count( $blog_users ); + unset( $blog_users ); + wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS ); + } + + printf( + '%s', + esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), + number_format_i18n( $user_count ) + ); + } + + /** + * Handles the plugins column output. + * + * @since 4.3.0 + * + * @param array $blog Current site. + */ + public function column_plugins( $blog ) { + if ( has_filter( 'wpmublogsaction' ) ) { + /** + * Fires inside the auxiliary 'Actions' column of the Sites list table. + * + * By default this column is hidden unless something is hooked to the action. + * + * @since MU (3.0.0) + * + * @param int $blog_id The site ID. + */ + do_action( 'wpmublogsaction', $blog['blog_id'] ); + } + } + + /** + * Handles output for the default column. + * + * @since 4.3.0 + * + * @param array $blog Current site. + * @param string $column_name Current column name. + */ + public function column_default( $blog, $column_name ) { + /** + * Fires for each registered custom column in the Sites list table. + * + * @since 3.1.0 + * + * @param string $column_name The name of the column to display. + * @param int $blog_id The site ID. + */ + do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); + } + + /** + * + * @global string $mode + */ + public function display_rows() { + foreach ( $this->items as $blog ) { + $blog = $blog->to_array(); + $class = ''; + reset( $this->status_list ); + + foreach ( $this->status_list as $status => $col ) { + if ( $blog[ $status ] == 1 ) { + $class = " class='{$col[0]}'"; + } + } + + echo ""; + + $this->single_row_columns( $blog ); + + echo ''; + } + } + + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, 'blogname'. + */ + protected function get_default_primary_column_name() { + return 'blogname'; + } + + /** + * Generates and displays row action links. + * + * @since 4.3.0 + * + * @param object $blog Site being acted upon. + * @param string $column_name Current column name. + * @param string $primary Primary column name. + * @return string Row actions output. + */ + protected function handle_row_actions( $blog, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return; + } + + $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); + + // Preordered. + $actions = array( + 'edit' => '', 'backend' => '', + 'activate' => '', 'deactivate' => '', + 'archive' => '', 'unarchive' => '', + 'spam' => '', 'unspam' => '', + 'delete' => '', + 'visit' => '', + ); + + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['backend'] = "" . __( 'Dashboard' ) . ''; + if ( get_network()->site_id != $blog['blog_id'] ) { + if ( $blog['deleted'] == '1' ) { + $actions['activate'] = '' . __( 'Activate' ) . ''; + } else { + $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; + } + + if ( $blog['archived'] == '1' ) { + $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; + } else { + $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; + } + + if ( $blog['spam'] == '1' ) { + $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; + } else { + $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; + } + + if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + } + + $actions['visit'] = "" . __( 'Visit' ) . ''; + + /** + * Filters the action links displayed for each site in the Sites list table. + * + * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by + * default for each site. The site's status determines whether to show the + * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and + * 'Not Spam' or 'Spam' link for each site. + * + * @since 3.1.0 + * + * @param array $actions An array of action links to be displayed. + * @param int $blog_id The site ID. + * @param string $blogname Site path, formatted depending on whether it is a sub-domain + * or subdirectory multisite installation. + */ + $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); + return $this->row_actions( $actions ); + } +} diff --git a/backend/wp-admin/includes/class-wp-ms-themes-list-table.php b/backend/wp-admin/includes/class-wp-ms-themes-list-table.php new file mode 100644 index 0000000..c90d6d5 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -0,0 +1,726 @@ + 'themes', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + + $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; + if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) + $status = 'all'; + + $page = $this->get_pagenum(); + + $this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false; + + if ( $this->is_site_themes ) + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + } + + /** + * + * @return array + */ + protected function get_table_classes() { + // todo: remove and add CSS for .themes + return array( 'widefat', 'plugins' ); + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + if ( $this->is_site_themes ) + return current_user_can( 'manage_sites' ); + else + return current_user_can( 'manage_network_themes' ); + } + + /** + * + * @global string $status + * @global array $totals + * @global int $page + * @global string $orderby + * @global string $order + * @global string $s + */ + public function prepare_items() { + global $status, $totals, $page, $orderby, $order, $s; + + wp_reset_vars( array( 'orderby', 'order', 's' ) ); + + $themes = array( + /** + * Filters the full array of WP_Theme objects to list in the Multisite + * themes list table. + * + * @since 3.1.0 + * + * @param array $all An array of WP_Theme objects to display in the list table. + */ + 'all' => apply_filters( 'all_themes', wp_get_themes() ), + 'search' => array(), + 'enabled' => array(), + 'disabled' => array(), + 'upgrade' => array(), + 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), + ); + + if ( $this->is_site_themes ) { + $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); + $allowed_where = 'site'; + } else { + $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); + $allowed_where = 'network'; + } + + $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' ); + + foreach ( (array) $themes['all'] as $key => $theme ) { + if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { + unset( $themes['all'][ $key ] ); + continue; + } + + if ( $maybe_update && isset( $current->response[ $key ] ) ) { + $themes['all'][ $key ]->update = true; + $themes['upgrade'][ $key ] = $themes['all'][ $key ]; + } + + $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; + $themes[ $filter ][ $key ] = $themes['all'][ $key ]; + } + + if ( $s ) { + $status = 'search'; + $themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); + } + + $totals = array(); + foreach ( $themes as $type => $list ) + $totals[ $type ] = count( $list ); + + if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) + $status = 'all'; + + $this->items = $themes[ $status ]; + WP_Theme::sort_by_name( $this->items ); + + $this->has_items = ! empty( $themes['all'] ); + $total_this_page = $totals[ $status ]; + + wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( + 'themes' => $totals, + 'totals' => wp_get_update_data(), + ) ); + + if ( $orderby ) { + $orderby = ucfirst( $orderby ); + $order = strtoupper( $order ); + + if ( $orderby === 'Name' ) { + if ( 'ASC' === $order ) { + $this->items = array_reverse( $this->items ); + } + } else { + uasort( $this->items, array( $this, '_order_callback' ) ); + } + } + + $start = ( $page - 1 ) * $themes_per_page; + + if ( $total_this_page > $themes_per_page ) + $this->items = array_slice( $this->items, $start, $themes_per_page, true ); + + $this->set_pagination_args( array( + 'total_items' => $total_this_page, + 'per_page' => $themes_per_page, + ) ); + } + + /** + * @staticvar string $term + * @param WP_Theme $theme + * @return bool + */ + public function _search_callback( $theme ) { + static $term = null; + if ( is_null( $term ) ) + $term = wp_unslash( $_REQUEST['s'] ); + + foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { + // Don't mark up; Do translate. + if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) + return true; + } + + if ( false !== stripos( $theme->get_stylesheet(), $term ) ) + return true; + + if ( false !== stripos( $theme->get_template(), $term ) ) + return true; + + return false; + } + + // Not used by any core columns. + /** + * @global string $orderby + * @global string $order + * @param array $theme_a + * @param array $theme_b + * @return int + */ + public function _order_callback( $theme_a, $theme_b ) { + global $orderby, $order; + + $a = $theme_a[ $orderby ]; + $b = $theme_b[ $orderby ]; + + if ( $a == $b ) + return 0; + + if ( 'DESC' === $order ) + return ( $a < $b ) ? 1 : -1; + else + return ( $a < $b ) ? -1 : 1; + } + + /** + */ + public function no_items() { + if ( $this->has_items ) { + _e( 'No themes found.' ); + } else { + _e( 'You do not appear to have any themes available at this time.' ); + } + } + + /** + * + * @return array + */ + public function get_columns() { + return array( + 'cb' => '', + 'name' => __( 'Theme' ), + 'description' => __( 'Description' ), + ); + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'name' => 'name', + ); + } + + /** + * Gets the name of the primary column. + * + * @since 4.3.0 + * + * @return string Unalterable name of the primary column name, in this case, 'name'. + */ + protected function get_primary_column_name() { + return 'name'; + } + + /** + * + * @global array $totals + * @global string $status + * @return array + */ + protected function get_views() { + global $totals, $status; + + $status_links = array(); + foreach ( $totals as $type => $count ) { + if ( !$count ) + continue; + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'themes' ); + break; + case 'enabled': + $text = _n( 'Enabled (%s)', 'Enabled (%s)', $count ); + break; + case 'disabled': + $text = _n( 'Disabled (%s)', 'Disabled (%s)', $count ); + break; + case 'upgrade': + $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count ); + break; + case 'broken' : + $text = _n( 'Broken (%s)', 'Broken (%s)', $count ); + break; + } + + if ( $this->is_site_themes ) + $url = 'site-themes.php?id=' . $this->site_id; + else + $url = 'themes.php'; + + if ( 'search' != $type ) { + $status_links[$type] = sprintf( "%s", + esc_url( add_query_arg('theme_status', $type, $url) ), + ( $type === $status ) ? ' class="current" aria-current="page"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + } + + return $status_links; + } + + /** + * @global string $status + * + * @return array + */ + protected function get_bulk_actions() { + global $status; + + $actions = array(); + if ( 'enabled' != $status ) + $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); + if ( 'disabled' != $status ) + $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); + if ( ! $this->is_site_themes ) { + if ( current_user_can( 'update_themes' ) ) + $actions['update-selected'] = __( 'Update' ); + if ( current_user_can( 'delete_themes' ) ) + $actions['delete-selected'] = __( 'Delete' ); + } + return $actions; + } + + /** + */ + public function display_rows() { + foreach ( $this->items as $theme ) + $this->single_row( $theme ); + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param WP_Theme $theme The current WP_Theme object. + */ + public function column_cb( $theme ) { + $checkbox_id = 'checkbox_' . md5( $theme->get('Name') ); + ?> + + + is_site_themes ) { + $url = "site-themes.php?id={$this->site_id}&"; + $allowed = $theme->is_allowed( 'site', $this->site_id ); + } else { + $url = 'themes.php?'; + $allowed = $theme->is_allowed( 'network' ); + } + + // Pre-order. + $actions = array( + 'enable' => '', + 'disable' => '', + 'delete' => '' + ); + + $stylesheet = $theme->get_stylesheet(); + $theme_key = urlencode( $stylesheet ); + + if ( ! $allowed ) { + if ( ! $theme->errors() ) { + $url = add_query_arg( array( + 'action' => 'enable', + 'theme' => $theme_key, + 'paged' => $page, + 's' => $s, + ), $url ); + + if ( $this->is_site_themes ) { + /* translators: %s: theme name */ + $aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) ); + } else { + /* translators: %s: theme name */ + $aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) ); + } + + $actions['enable'] = sprintf( '%s', + esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ), + esc_attr( $aria_label ), + ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) + ); + } + } else { + $url = add_query_arg( array( + 'action' => 'disable', + 'theme' => $theme_key, + 'paged' => $page, + 's' => $s, + ), $url ); + + if ( $this->is_site_themes ) { + /* translators: %s: theme name */ + $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); + } else { + /* translators: %s: theme name */ + $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); + } + + $actions['disable'] = sprintf( '%s', + esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), + esc_attr( $aria_label ), + ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) + ); + } + + if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) { + $url = add_query_arg( array( + 'action' => 'delete-selected', + 'checked[]' => $theme_key, + 'theme_status' => $context, + 'paged' => $page, + 's' => $s, + ), 'themes.php' ); + + /* translators: %s: theme name */ + $aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) ); + + $actions['delete'] = sprintf( '%s', + esc_url( wp_nonce_url( $url, 'bulk-themes' ) ), + esc_attr( $aria_label ), + __( 'Delete' ) + ); + } + /** + * Filters the action links displayed for each theme in the Multisite + * themes list table. + * + * The action links displayed are determined by the theme's status, and + * which Multisite themes list table is being displayed - the Network + * themes list table (themes.php), which displays all installed themes, + * or the Site themes list table (site-themes.php), which displays the + * non-network enabled themes when editing a site in the Network admin. + * + * The default action links for the Network themes list table include + * 'Network Enable', 'Network Disable', and 'Delete'. + * + * The default action links for the Site themes list table include + * 'Enable', and 'Disable'. + * + * @since 2.8.0 + * + * @param array $actions An array of action links. + * @param WP_Theme $theme The current WP_Theme object. + * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. + */ + $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); + + /** + * Filters the action links of a specific theme in the Multisite themes + * list table. + * + * The dynamic portion of the hook name, `$stylesheet`, refers to the + * directory name of the theme, which in most cases is synonymous + * with the template name. + * + * @since 3.1.0 + * + * @param array $actions An array of action links. + * @param WP_Theme $theme The current WP_Theme object. + * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. + */ + $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context ); + + echo $this->row_actions( $actions, true ); + } + + /** + * Handles the description column output. + * + * @since 4.3.0 + * + * @global string $status + * @global array $totals + * + * @param WP_Theme $theme The current WP_Theme object. + */ + public function column_description( $theme ) { + global $status, $totals; + if ( $theme->errors() ) { + $pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : ''; + echo '

    ' . $pre . $theme->errors()->get_error_message() . '

    '; + } + + if ( $this->is_site_themes ) { + $allowed = $theme->is_allowed( 'site', $this->site_id ); + } else { + $allowed = $theme->is_allowed( 'network' ); + } + + $class = ! $allowed ? 'inactive' : 'active'; + if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) + $class .= ' update'; + + echo "

    " . $theme->display( 'Description' ) . "

    +
    "; + + $stylesheet = $theme->get_stylesheet(); + $theme_meta = array(); + + if ( $theme->get('Version') ) { + $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') ); + } + $theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') ); + + if ( $theme->get('ThemeURI') ) { + /* translators: %s: theme name */ + $aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) ); + + $theme_meta[] = sprintf( '%s', + $theme->display( 'ThemeURI' ), + esc_attr( $aria_label ), + __( 'Visit Theme Site' ) + ); + } + /** + * Filters the array of row meta for each theme in the Multisite themes + * list table. + * + * @since 3.1.0 + * + * @param array $theme_meta An array of the theme's metadata, + * including the version, author, and + * theme URI. + * @param string $stylesheet Directory name of the theme. + * @param WP_Theme $theme WP_Theme object. + * @param string $status Status of the theme. + */ + $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); + echo implode( ' | ', $theme_meta ); + + echo '
    '; + } + + /** + * Handles default column output. + * + * @since 4.3.0 + * + * @param WP_Theme $theme The current WP_Theme object. + * @param string $column_name The current column name. + */ + public function column_default( $theme, $column_name ) { + $stylesheet = $theme->get_stylesheet(); + + /** + * Fires inside each custom column of the Multisite themes list table. + * + * @since 3.1.0 + * + * @param string $column_name Name of the column. + * @param string $stylesheet Directory name of the theme. + * @param WP_Theme $theme Current WP_Theme object. + */ + do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); + } + + /** + * Handles the output for a single table row. + * + * @since 4.3.0 + * + * @param WP_Theme $item The current WP_Theme object. + */ + public function single_row_columns( $item ) { + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $extra_classes = ''; + if ( in_array( $column_name, $hidden ) ) { + $extra_classes .= ' hidden'; + } + + switch ( $column_name ) { + case 'cb': + echo ''; + + $this->column_cb( $item ); + + echo ''; + break; + + case 'name': + + $active_theme_label = ''; + + /* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */ + if ( ! empty( $this->site_id ) ) { + $stylesheet = get_blog_option( $this->site_id, 'stylesheet' ); + $template = get_blog_option( $this->site_id, 'template' ); + + /* Add a label for the active template */ + if ( $item->get_template() === $template ) { + $active_theme_label = ' — ' . __( 'Active Theme' ); + } + + /* In case this is a child theme, label it properly */ + if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet) { + $active_theme_label = ' — ' . __( 'Active Child Theme' ); + } + } + + echo "" . $item->display( 'Name' ) . $active_theme_label . ''; + + $this->column_name( $item ); + + echo ""; + break; + + case 'description': + echo ""; + + $this->column_description( $item ); + + echo ''; + break; + + default: + echo ""; + + $this->column_default( $item, $column_name ); + + echo ""; + break; + } + } + } + + /** + * @global string $status + * @global array $totals + * + * @param WP_Theme $theme + */ + public function single_row( $theme ) { + global $status, $totals; + + if ( $this->is_site_themes ) { + $allowed = $theme->is_allowed( 'site', $this->site_id ); + } else { + $allowed = $theme->is_allowed( 'network' ); + } + + $stylesheet = $theme->get_stylesheet(); + + $class = ! $allowed ? 'inactive' : 'active'; + if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { + $class .= ' update'; + } + + printf( '', + esc_attr( $class ), + esc_attr( $stylesheet ) + ); + + $this->single_row_columns( $theme ); + + echo ""; + + if ( $this->is_site_themes ) + remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); + + /** + * Fires after each row in the Multisite themes list table. + * + * @since 3.1.0 + * + * @param string $stylesheet Directory name of the theme. + * @param WP_Theme $theme Current WP_Theme object. + * @param string $status Status of the theme. + */ + do_action( 'after_theme_row', $stylesheet, $theme, $status ); + + /** + * Fires after each specific row in the Multisite themes list table. + * + * The dynamic portion of the hook name, `$stylesheet`, refers to the + * directory name of the theme, most often synonymous with the template + * name of the theme. + * + * @since 3.5.0 + * + * @param string $stylesheet Directory name of the theme. + * @param WP_Theme $theme Current WP_Theme object. + * @param string $status Status of the theme. + */ + do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status ); + } +} diff --git a/backend/wp-admin/includes/class-wp-ms-users-list-table.php b/backend/wp-admin/includes/class-wp-ms-users-list-table.php new file mode 100644 index 0000000..c2216f6 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-ms-users-list-table.php @@ -0,0 +1,457 @@ +get_items_per_page( 'users_network_per_page' ); + + $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + + $paged = $this->get_pagenum(); + + $args = array( + 'number' => $users_per_page, + 'offset' => ( $paged-1 ) * $users_per_page, + 'search' => $usersearch, + 'blog_id' => 0, + 'fields' => 'all_with_meta' + ); + + if ( wp_is_large_network( 'users' ) ) { + $args['search'] = ltrim( $args['search'], '*' ); + } else if ( '' !== $args['search'] ) { + $args['search'] = trim( $args['search'], '*' ); + $args['search'] = '*' . $args['search'] . '*'; + } + + if ( $role === 'super' ) { + $logins = implode( "', '", get_super_admins() ); + $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" ); + } + + /* + * If the network is large and a search is not being performed, + * show only the latest users with no paging in order to avoid + * expensive count queries. + */ + if ( !$usersearch && wp_is_large_network( 'users' ) ) { + if ( !isset($_REQUEST['orderby']) ) + $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; + if ( !isset($_REQUEST['order']) ) + $_GET['order'] = $_REQUEST['order'] = 'DESC'; + $args['count_total'] = false; + } + + if ( isset( $_REQUEST['orderby'] ) ) + $args['orderby'] = $_REQUEST['orderby']; + + if ( isset( $_REQUEST['order'] ) ) + $args['order'] = $_REQUEST['order']; + + if ( ! empty( $_REQUEST['mode'] ) ) { + $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; + set_user_setting( 'network_users_list_mode', $mode ); + } else { + $mode = get_user_setting( 'network_users_list_mode', 'list' ); + } + + /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ + $args = apply_filters( 'users_list_table_query_args', $args ); + + // Query the user IDs for this page + $wp_user_search = new WP_User_Query( $args ); + + $this->items = $wp_user_search->get_results(); + + $this->set_pagination_args( array( + 'total_items' => $wp_user_search->get_total(), + 'per_page' => $users_per_page, + ) ); + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + if ( current_user_can( 'delete_users' ) ) + $actions['delete'] = __( 'Delete' ); + $actions['spam'] = _x( 'Mark as Spam', 'user' ); + $actions['notspam'] = _x( 'Not Spam', 'user' ); + + return $actions; + } + + /** + */ + public function no_items() { + _e( 'No users found.' ); + } + + /** + * + * @global string $role + * @return array + */ + protected function get_views() { + global $role; + + $total_users = get_user_count(); + $super_admins = get_super_admins(); + $total_admins = count( $super_admins ); + + $current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : ''; + $role_links = array(); + $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + $current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : ''; + $role_links['super'] = "" . sprintf( _n( 'Super Admin (%s)', 'Super Admins (%s)', $total_admins ), number_format_i18n( $total_admins ) ) . ''; + + return $role_links; + } + + /** + * @global string $mode List table view mode. + * + * @param string $which + */ + protected function pagination( $which ) { + global $mode; + + parent::pagination ( $which ); + + if ( 'top' === $which ) { + $this->view_switcher( $mode ); + } + } + + /** + * + * @return array + */ + public function get_columns() { + $users_columns = array( + 'cb' => '', + 'username' => __( 'Username' ), + 'name' => __( 'Name' ), + 'email' => __( 'Email' ), + 'registered' => _x( 'Registered', 'user' ), + 'blogs' => __( 'Sites' ) + ); + /** + * Filters the columns displayed in the Network Admin Users list table. + * + * @since MU (3.0.0) + * + * @param array $users_columns An array of user columns. Default 'cb', 'username', + * 'name', 'email', 'registered', 'blogs'. + */ + return apply_filters( 'wpmu_users_columns', $users_columns ); + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'username' => 'login', + 'name' => 'name', + 'email' => 'email', + 'registered' => 'id', + ); + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param WP_User $user The current WP_User object. + */ + public function column_cb( $user ) { + if ( is_super_admin( $user->ID ) ) { + return; + } + ?> + + + ID; + } + + /** + * Handles the username column output. + * + * @since 4.3.0 + * + * @param WP_User $user The current WP_User object. + */ + public function column_username( $user ) { + $super_admins = get_super_admins(); + $avatar = get_avatar( $user->user_email, 32 ); + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); + + echo $avatar; + + ?>user_login; ?>user_login, $super_admins ) ) { + echo ' — ' . __( 'Super Admin' ); + } + ?> + first_name && $user->last_name ) { + echo "$user->first_name $user->last_name"; + } elseif ( $user->first_name ) { + echo $user->first_name; + } elseif ( $user->last_name ) { + echo $user->last_name; + } else { + echo '' . _x( 'Unknown', 'name' ) . ''; + } + } + + /** + * Handles the email column output. + * + * @since 4.3.0 + * + * @param WP_User $user The current WP_User object. + */ + public function column_email( $user ) { + echo "$user->user_email"; + } + + /** + * Handles the registered date column output. + * + * @since 4.3.0 + * + * @global string $mode List table view mode. + * + * @param WP_User $user The current WP_User object. + */ + public function column_registered( $user ) { + global $mode; + if ( 'list' === $mode ) { + $date = __( 'Y/m/d' ); + } else { + $date = __( 'Y/m/d g:i:s a' ); + } + echo mysql2date( $date, $user->user_registered ); + } + + /** + * @since 4.3.0 + * + * @param WP_User $user + * @param string $classes + * @param string $data + * @param string $primary + */ + protected function _column_blogs( $user, $classes, $data, $primary ) { + echo ''; + echo $this->column_blogs( $user ); + echo $this->handle_row_actions( $user, 'blogs', $primary ); + echo ''; + } + + /** + * Handles the sites column output. + * + * @since 4.3.0 + * + * @param WP_User $user The current WP_User object. + */ + public function column_blogs( $user ) { + $blogs = get_blogs_of_user( $user->ID, true ); + if ( ! is_array( $blogs ) ) { + return; + } + + foreach ( $blogs as $val ) { + if ( ! can_edit_network( $val->site_id ) ) { + continue; + } + + $path = ( $val->path === '/' ) ? '' : $val->path; + echo ''; + echo '' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . ''; + echo ' '; + $actions = array(); + $actions['edit'] = '' . __( 'Edit' ) . ''; + + $class = ''; + if ( $val->spam == 1 ) { + $class .= 'site-spammed '; + } + if ( $val->mature == 1 ) { + $class .= 'site-mature '; + } + if ( $val->deleted == 1 ) { + $class .= 'site-deleted '; + } + if ( $val->archived == 1 ) { + $class .= 'site-archived '; + } + + $actions['view'] = '' . __( 'View' ) . ''; + + /** + * Filters the action links displayed next the sites a user belongs to + * in the Network Admin Users list table. + * + * @since 3.1.0 + * + * @param array $actions An array of action links to be displayed. + * Default 'Edit', 'View'. + * @param int $userblog_id The site ID. + */ + $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id ); + + $i=0; + $action_count = count( $actions ); + foreach ( $actions as $action => $link ) { + ++$i; + $sep = ( $i == $action_count ) ? '' : ' | '; + echo "$link$sep"; + } + echo '
    '; + } + } + + /** + * Handles the default column output. + * + * @since 4.3.0 + * + * @param WP_User $user The current WP_User object. + * @param string $column_name The current column name. + */ + public function column_default( $user, $column_name ) { + /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ + echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); + } + + public function display_rows() { + foreach ( $this->items as $user ) { + $class = ''; + + $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' ); + + foreach ( $status_list as $status => $col ) { + if ( $user->$status ) { + $class .= " $col"; + } + } + + ?> + + single_row_columns( $user ); ?> + + ID ) ) ); + + $actions = array(); + $actions['edit'] = '' . __( 'Edit' ) . ''; + + if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + + /** + * Filters the action links displayed under each user in the Network Admin Users list table. + * + * @since 3.2.0 + * + * @param array $actions An array of action links to be displayed. + * Default 'Edit', 'Delete'. + * @param WP_User $user WP_User object. + */ + $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); + return $this->row_actions( $actions ); + } +} diff --git a/backend/wp-admin/includes/class-wp-plugin-install-list-table.php b/backend/wp-admin/includes/class-wp-plugin-install-list-table.php new file mode 100644 index 0000000..9bcf652 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -0,0 +1,634 @@ +no_update ) ) { + foreach ( $plugin_info->no_update as $plugin ) { + $plugin->upgrade = false; + $plugins[ $plugin->slug ] = $plugin; + } + } + + if ( isset( $plugin_info->response ) ) { + foreach ( $plugin_info->response as $plugin ) { + $plugin->upgrade = true; + $plugins[ $plugin->slug ] = $plugin; + } + } + + return $plugins; + } + + /** + * Return a list of slugs of installed plugins, if known. + * + * Uses the transient data from the updates API to determine the slugs of + * known installed plugins. This might be better elsewhere, perhaps even + * within get_plugins(). + * + * @since 4.0.0 + * + * @return array + */ + protected function get_installed_plugin_slugs() { + return array_keys( $this->get_installed_plugins() ); + } + + /** + * + * @global array $tabs + * @global string $tab + * @global int $paged + * @global string $type + * @global string $term + */ + public function prepare_items() { + include( ABSPATH . 'wp-admin/includes/plugin-install.php' ); + + global $tabs, $tab, $paged, $type, $term; + + wp_reset_vars( array( 'tab' ) ); + + $paged = $this->get_pagenum(); + + $per_page = 30; + + // These are the tabs which are shown on the page + $tabs = array(); + + if ( 'search' === $tab ) { + $tabs['search'] = __( 'Search Results' ); + } + if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { + $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); + } + $tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); + $tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); + $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); + $tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' ); + if ( current_user_can( 'upload_plugins' ) ) { + // No longer a real tab. Here for filter compatibility. + // Gets skipped in get_views(). + $tabs['upload'] = __( 'Upload Plugin' ); + } + + $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. + + /** + * Filters the tabs shown on the Plugin Install screen. + * + * @since 2.7.0 + * + * @param array $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular', + * 'recommended', 'favorites', and 'upload'. + */ + $tabs = apply_filters( 'install_plugins_tabs', $tabs ); + + /** + * Filters tabs not associated with a menu item on the Plugin Install screen. + * + * @since 2.7.0 + * + * @param array $nonmenu_tabs The tabs that don't have a Menu item on the Plugin Install screen. + */ + $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); + + // If a non-valid menu tab has been selected, And it's not a non-menu action. + if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) + $tab = key( $tabs ); + + $installed_plugins = $this->get_installed_plugins(); + + $args = array( + 'page' => $paged, + 'per_page' => $per_page, + 'fields' => array( + 'last_updated' => true, + 'icons' => true, + 'active_installs' => true + ), + // Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. + 'locale' => get_user_locale(), + 'installed_plugins' => array_keys( $installed_plugins ), + ); + + switch ( $tab ) { + case 'search': + $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; + $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; + + switch ( $type ) { + case 'tag': + $args['tag'] = sanitize_title_with_dashes( $term ); + break; + case 'term': + $args['search'] = $term; + break; + case 'author': + $args['author'] = $term; + break; + } + + break; + + case 'featured': + $args['fields']['group'] = true; + $this->orderby = 'group'; + // No break! + case 'popular': + case 'new': + case 'beta': + case 'recommended': + $args['browse'] = $tab; + break; + + case 'favorites': + $action = 'save_wporg_username_' . get_current_user_id(); + if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) { + $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); + update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); + } else { + $user = get_user_option( 'wporg_favorites' ); + } + if ( $user ) + $args['user'] = $user; + else + $args = false; + + add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); + break; + + default: + $args = false; + break; + } + + /** + * Filters API request arguments for each Plugin Install screen tab. + * + * The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs. + * Default tabs include 'featured', 'popular', 'recommended', 'favorites', and 'upload'. + * + * @since 3.7.0 + * + * @param array|bool $args Plugin Install API arguments. + */ + $args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); + + if ( !$args ) + return; + + $api = plugins_api( 'query_plugins', $args ); + + if ( is_wp_error( $api ) ) { + $this->error = $api; + return; + } + + $this->items = $api->plugins; + + if ( $this->orderby ) { + uasort( $this->items, array( $this, 'order_callback' ) ); + } + + $this->set_pagination_args( array( + 'total_items' => $api->info['results'], + 'per_page' => $args['per_page'], + ) ); + + if ( isset( $api->info['groups'] ) ) { + $this->groups = $api->info['groups']; + } + + if ( $installed_plugins ) { + $js_plugins = array_fill_keys( + array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ), + array() + ); + + $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) ); + $upgrade_plugins = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' ); + + if ( $upgrade_plugins ) { + $js_plugins['upgrade'] = array_values( $upgrade_plugins ); + } + + wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( + 'plugins' => $js_plugins, + 'totals' => wp_get_update_data(), + ) ); + } + } + + /** + */ + public function no_items() { + if ( isset( $this->error ) ) { ?> +

    error->get_error_message(); ?>

    +

    +
    + +
    + $text ) { + $current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; + $href = self_admin_url('plugin-install.php?tab=' . $action); + $display_tabs['plugin-install-'.$action] = "$text"; + } + // No longer a real tab. + unset( $display_tabs['plugin-install-upload'] ); + + return $display_tabs; + } + + /** + * Override parent views so we can use the filter bar display. + */ + public function views() { + $views = $this->get_views(); + + /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ + $views = apply_filters( "views_{$this->screen->id}", $views ); + + $this->screen->render_screen_reader_content( 'heading_views' ); +?> +
    + + + +
    +_args['singular']; + + $data_attr = ''; + + if ( $singular ) { + $data_attr = " data-wp-lists='list:$singular'"; + } + + $this->display_tablenav( 'top' ); + +?> +
    +screen->render_screen_reader_content( 'heading_list' ); +?> +
    > + display_rows_or_placeholder(); ?> +
    +
    +display_tablenav( 'bottom' ); + } + + /** + * @global string $tab + * + * @param string $which + */ + protected function display_tablenav( $which ) { + if ( $GLOBALS['tab'] === 'featured' ) { + return; + } + + if ( 'top' === $which ) { + wp_referer_field(); + ?> +
    +
    + +
    + pagination( $which ); ?> +
    +
    + +
    + pagination( $which ); ?> +
    +
    + _args['plural'] ); + } + + /** + * @return array + */ + public function get_columns() { + return array(); + } + + /** + * @param object $plugin_a + * @param object $plugin_b + * @return int + */ + private function order_callback( $plugin_a, $plugin_b ) { + $orderby = $this->orderby; + if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) { + return 0; + } + + $a = $plugin_a->$orderby; + $b = $plugin_b->$orderby; + + if ( $a == $b ) { + return 0; + } + + if ( 'DESC' === $this->order ) { + return ( $a < $b ) ? 1 : -1; + } else { + return ( $a < $b ) ? -1 : 1; + } + } + + public function display_rows() { + $plugins_allowedtags = array( + 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), + 'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ), + 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), + 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array() + ); + + $plugins_group_titles = array( + 'Performance' => _x( 'Performance', 'Plugin installer group title' ), + 'Social' => _x( 'Social', 'Plugin installer group title' ), + 'Tools' => _x( 'Tools', 'Plugin installer group title' ), + ); + + $group = null; + + foreach ( (array) $this->items as $plugin ) { + if ( is_object( $plugin ) ) { + $plugin = (array) $plugin; + } + + // Display the group heading if there is one + if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { + if ( isset( $this->groups[ $plugin['group'] ] ) ) { + $group_name = $this->groups[ $plugin['group'] ]; + if ( isset( $plugins_group_titles[ $group_name ] ) ) { + $group_name = $plugins_group_titles[ $group_name ]; + } + } else { + $group_name = $plugin['group']; + } + + // Starting a new group, close off the divs of the last one + if ( ! empty( $group ) ) { + echo ''; + } + + echo '

    ' . esc_html( $group_name ) . '

    '; + // needs an extra wrapping div for nth-child selectors to work + echo '
    '; + + $group = $plugin['group']; + } + $title = wp_kses( $plugin['name'], $plugins_allowedtags ); + + // Remove any HTML from the description. + $description = strip_tags( $plugin['short_description'] ); + $version = wp_kses( $plugin['version'], $plugins_allowedtags ); + + $name = strip_tags( $title . ' ' . $version ); + + $author = wp_kses( $plugin['author'], $plugins_allowedtags ); + if ( ! empty( $author ) ) { + $author = ' ' . sprintf( __( 'By %s' ), $author ) . ''; + } + + $action_links = array(); + + if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { + $status = install_plugin_install_status( $plugin ); + + switch ( $status['status'] ) { + case 'install': + if ( $status['url'] ) { + /* translators: 1: Plugin name and version. */ + $action_links[] = '' . __( 'Install Now' ) . ''; + } + break; + + case 'update_available': + if ( $status['url'] ) { + /* translators: 1: Plugin name and version */ + $action_links[] = '' . __( 'Update Now' ) . ''; + } + break; + + case 'latest_installed': + case 'newer_installed': + if ( is_plugin_active( $status['file'] ) ) { + $action_links[] = ''; + } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { + $button_text = __( 'Activate' ); + /* translators: %s: Plugin name */ + $button_label = _x( 'Activate %s', 'plugin' ); + $activate_url = add_query_arg( array( + '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), + 'action' => 'activate', + 'plugin' => $status['file'], + ), network_admin_url( 'plugins.php' ) ); + + if ( is_network_admin() ) { + $button_text = __( 'Network Activate' ); + /* translators: %s: Plugin name */ + $button_label = _x( 'Network Activate %s', 'plugin' ); + $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url ); + } + + $action_links[] = sprintf( + '%3$s', + esc_url( $activate_url ), + esc_attr( sprintf( $button_label, $plugin['name'] ) ), + $button_text + ); + } else { + $action_links[] = ''; + } + break; + } + } + + $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . + '&TB_iframe=true&width=600&height=550' ); + + /* translators: 1: Plugin name and version. */ + $action_links[] = '' . __( 'More Details' ) . ''; + + if ( !empty( $plugin['icons']['svg'] ) ) { + $plugin_icon_url = $plugin['icons']['svg']; + } elseif ( !empty( $plugin['icons']['2x'] ) ) { + $plugin_icon_url = $plugin['icons']['2x']; + } elseif ( !empty( $plugin['icons']['1x'] ) ) { + $plugin_icon_url = $plugin['icons']['1x']; + } else { + $plugin_icon_url = $plugin['icons']['default']; + } + + /** + * Filters the install action links for a plugin. + * + * @since 2.7.0 + * + * @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now. + * @param array $plugin The plugin currently being listed. + */ + $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); + + $last_updated_timestamp = strtotime( $plugin['last_updated'] ); + ?> +
    +
    +
    +

    + + + + +

    +
    + +
    +

    +

    +
    +
    +
    +
    + $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?> + +
    +
    + +
    +
    + = 1000000 ) { + $active_installs_text = _x( '1+ Million', 'Active plugin installations' ); + } elseif ( 0 == $plugin['active_installs'] ) { + $active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); + } else { + $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; + } + printf( __( '%s Active Installations' ), $active_installs_text ); + ?> +
    +
    + ' ) ) { + echo '' . __( 'Untested with your version of WordPress' ) . ''; + } elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) { + echo '' . __( 'Incompatible with your version of WordPress' ) . ''; + } else { + echo '' . __( 'Compatible with your version of WordPress' ) . ''; + } + ?> +
    +
    +
    +
    '; + } + } +} diff --git a/backend/wp-admin/includes/class-wp-plugins-list-table.php b/backend/wp-admin/includes/class-wp-plugins-list-table.php new file mode 100644 index 0000000..2cc6c77 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-plugins-list-table.php @@ -0,0 +1,872 @@ + 'plugins', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + + $status = 'all'; + if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) + $status = $_REQUEST['plugin_status']; + + if ( isset($_REQUEST['s']) ) + $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) ); + + $page = $this->get_pagenum(); + } + + /** + * @return array + */ + protected function get_table_classes() { + return array( 'widefat', $this->_args['plural'] ); + } + + /** + * @return bool + */ + public function ajax_user_can() { + return current_user_can('activate_plugins'); + } + + /** + * + * @global string $status + * @global array $plugins + * @global array $totals + * @global int $page + * @global string $orderby + * @global string $order + * @global string $s + */ + public function prepare_items() { + global $status, $plugins, $totals, $page, $orderby, $order, $s; + + wp_reset_vars( array( 'orderby', 'order' ) ); + + /** + * Filters the full array of plugins to list in the Plugins list table. + * + * @since 3.0.0 + * + * @see get_plugins() + * + * @param array $all_plugins An array of plugins to display in the list table. + */ + $all_plugins = apply_filters( 'all_plugins', get_plugins() ); + + $plugins = array( + 'all' => $all_plugins, + 'search' => array(), + 'active' => array(), + 'inactive' => array(), + 'recently_activated' => array(), + 'upgrade' => array(), + 'mustuse' => array(), + 'dropins' => array(), + ); + + $screen = $this->screen; + + if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) { + + /** + * Filters whether to display the advanced plugins list table. + * + * There are two types of advanced plugins - must-use and drop-ins - + * which can be used in a single site or Multisite network. + * + * The $type parameter allows you to differentiate between the type of advanced + * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'. + * + * @since 3.0.0 + * + * @param bool $show Whether to show the advanced plugins for the specified + * plugin type. Default true. + * @param string $type The plugin type. Accepts 'mustuse', 'dropins'. + */ + if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) { + $plugins['mustuse'] = get_mu_plugins(); + } + + /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ + if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) + $plugins['dropins'] = get_dropins(); + + if ( current_user_can( 'update_plugins' ) ) { + $current = get_site_transient( 'update_plugins' ); + foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { + if ( isset( $current->response[ $plugin_file ] ) ) { + $plugins['all'][ $plugin_file ]['update'] = true; + $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; + } + } + } + } + + if ( ! $screen->in_admin( 'network' ) ) { + $show = current_user_can( 'manage_network_plugins' ); + /** + * Filters whether to display network-active plugins alongside plugins active for the current site. + * + * This also controls the display of inactive network-only plugins (plugins with + * "Network: true" in the plugin header). + * + * Plugins cannot be network-activated or network-deactivated from this screen. + * + * @since 4.4.0 + * + * @param bool $show Whether to show network-active plugins. Default is whether the current + * user can manage network plugins (ie. a Super Admin). + */ + $show_network_active = apply_filters( 'show_network_active_plugins', $show ); + } + + set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS ); + + if ( $screen->in_admin( 'network' ) ) { + $recently_activated = get_site_option( 'recently_activated', array() ); + } else { + $recently_activated = get_option( 'recently_activated', array() ); + } + + foreach ( $recently_activated as $key => $time ) { + if ( $time + WEEK_IN_SECONDS < time() ) { + unset( $recently_activated[$key] ); + } + } + + if ( $screen->in_admin( 'network' ) ) { + update_site_option( 'recently_activated', $recently_activated ); + } else { + update_option( 'recently_activated', $recently_activated ); + } + + $plugin_info = get_site_transient( 'update_plugins' ); + + foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { + // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. + if ( isset( $plugin_info->response[ $plugin_file ] ) ) { + $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); + // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade + if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { + $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); + } + + } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { + $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); + // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade + if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { + $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); + } + } + + // Filter into individual sections + if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) { + if ( $show_network_active ) { + // On the non-network screen, show inactive network-only plugins if allowed + $plugins['inactive'][ $plugin_file ] = $plugin_data; + } else { + // On the non-network screen, filter out network-only plugins as long as they're not individually active + unset( $plugins['all'][ $plugin_file ] ); + } + } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) { + if ( $show_network_active ) { + // On the non-network screen, show network-active plugins if allowed + $plugins['active'][ $plugin_file ] = $plugin_data; + } else { + // On the non-network screen, filter out network-active plugins + unset( $plugins['all'][ $plugin_file ] ); + } + } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) ) + || ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) { + // On the non-network screen, populate the active list with plugins that are individually activated + // On the network-admin screen, populate the active list with plugins that are network activated + $plugins['active'][ $plugin_file ] = $plugin_data; + } else { + if ( isset( $recently_activated[ $plugin_file ] ) ) { + // Populate the recently activated list with plugins that have been recently activated + $plugins['recently_activated'][ $plugin_file ] = $plugin_data; + } + // Populate the inactive list with plugins that aren't activated + $plugins['inactive'][ $plugin_file ] = $plugin_data; + } + } + + if ( strlen( $s ) ) { + $status = 'search'; + $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) ); + } + + $totals = array(); + foreach ( $plugins as $type => $list ) + $totals[ $type ] = count( $list ); + + if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) + $status = 'all'; + + $this->items = array(); + foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { + // Translate, Don't Apply Markup, Sanitize HTML + $this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); + } + + $total_this_page = $totals[ $status ]; + + $js_plugins = array(); + foreach ( $plugins as $key => $list ) { + $js_plugins[ $key ] = array_keys( (array) $list ); + } + + wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( + 'plugins' => $js_plugins, + 'totals' => wp_get_update_data(), + ) ); + + if ( ! $orderby ) { + $orderby = 'Name'; + } else { + $orderby = ucfirst( $orderby ); + } + + $order = strtoupper( $order ); + + uasort( $this->items, array( $this, '_order_callback' ) ); + + $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 ); + + $start = ( $page - 1 ) * $plugins_per_page; + + if ( $total_this_page > $plugins_per_page ) + $this->items = array_slice( $this->items, $start, $plugins_per_page ); + + $this->set_pagination_args( array( + 'total_items' => $total_this_page, + 'per_page' => $plugins_per_page, + ) ); + } + + /** + * @global string $s URL encoded search term. + * + * @param array $plugin + * @return bool + */ + public function _search_callback( $plugin ) { + global $s; + + foreach ( $plugin as $value ) { + if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) { + return true; + } + } + + return false; + } + + /** + * @global string $orderby + * @global string $order + * @param array $plugin_a + * @param array $plugin_b + * @return int + */ + public function _order_callback( $plugin_a, $plugin_b ) { + global $orderby, $order; + + $a = $plugin_a[$orderby]; + $b = $plugin_b[$orderby]; + + if ( $a == $b ) + return 0; + + if ( 'DESC' === $order ) { + return strcasecmp( $b, $a ); + } else { + return strcasecmp( $a, $b ); + } + } + + /** + * + * @global array $plugins + */ + public function no_items() { + global $plugins; + + if ( ! empty( $_REQUEST['s'] ) ) { + $s = esc_html( wp_unslash( $_REQUEST['s'] ) ); + + printf( __( 'No plugins found for “%s”.' ), $s ); + + // We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link. + if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) { + echo ' ' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . ''; + } + } elseif ( ! empty( $plugins['all'] ) ) + _e( 'No plugins found.' ); + else + _e( 'You do not appear to have any plugins available at this time.' ); + } + + /** + * Displays the search box. + * + * @since 4.6.0 + * + * @param string $text The 'submit' button label. + * @param string $input_id ID attribute value for the search input field. + */ + public function search_box( $text, $input_id ) { + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { + return; + } + + $input_id = $input_id . '-search-input'; + + if ( ! empty( $_REQUEST['orderby'] ) ) { + echo ''; + } + if ( ! empty( $_REQUEST['order'] ) ) { + echo ''; + } + ?> + + !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : '', + 'name' => __( 'Plugin' ), + 'description' => __( 'Description' ), + ); + } + + /** + * @return array + */ + protected function get_sortable_columns() { + return array(); + } + + /** + * + * @global array $totals + * @global string $status + * @return array + */ + protected function get_views() { + global $totals, $status; + + $status_links = array(); + foreach ( $totals as $type => $count ) { + if ( !$count ) + continue; + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'plugins' ); + break; + case 'active': + $text = _n( 'Active (%s)', 'Active (%s)', $count ); + break; + case 'recently_activated': + $text = _n( 'Recently Active (%s)', 'Recently Active (%s)', $count ); + break; + case 'inactive': + $text = _n( 'Inactive (%s)', 'Inactive (%s)', $count ); + break; + case 'mustuse': + $text = _n( 'Must-Use (%s)', 'Must-Use (%s)', $count ); + break; + case 'dropins': + $text = _n( 'Drop-ins (%s)', 'Drop-ins (%s)', $count ); + break; + case 'upgrade': + $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count ); + break; + } + + if ( 'search' !== $type ) { + $status_links[$type] = sprintf( "%s", + add_query_arg('plugin_status', $type, 'plugins.php'), + ( $type === $status ) ? ' class="current" aria-current="page"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + } + + return $status_links; + } + + /** + * + * @global string $status + * @return array + */ + protected function get_bulk_actions() { + global $status; + + $actions = array(); + + if ( 'active' != $status ) + $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); + + if ( 'inactive' != $status && 'recent' != $status ) + $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); + + if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) { + if ( current_user_can( 'update_plugins' ) ) + $actions['update-selected'] = __( 'Update' ); + if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) + $actions['delete-selected'] = __( 'Delete' ); + } + + return $actions; + } + + /** + * @global string $status + * @param string $which + */ + public function bulk_actions( $which = '' ) { + global $status; + + if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) + return; + + parent::bulk_actions( $which ); + } + + /** + * @global string $status + * @param string $which + */ + protected function extra_tablenav( $which ) { + global $status; + + if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) ) + return; + + echo '
    '; + + if ( 'recently_activated' == $status ) { + submit_button( __( 'Clear List' ), '', 'clear-recent-list', false ); + } elseif ( 'top' === $which && 'mustuse' === $status ) { + /* translators: %s: mu-plugins directory name */ + echo '

    ' . sprintf( __( 'Files in the %s directory are executed automatically.' ), + '' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '' + ) . '

    '; + } elseif ( 'top' === $which && 'dropins' === $status ) { + /* translators: %s: wp-content directory name */ + echo '

    ' . sprintf( __( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ), + '' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '' + ) . '

    '; + } + echo '
    '; + } + + /** + * @return string + */ + public function current_action() { + if ( isset($_POST['clear-recent-list']) ) + return 'clear-recent-list'; + + return parent::current_action(); + } + + /** + * + * @global string $status + */ + public function display_rows() { + global $status; + + if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) + return; + + foreach ( $this->items as $plugin_file => $plugin_data ) + $this->single_row( array( $plugin_file, $plugin_data ) ); + } + + /** + * @global string $status + * @global int $page + * @global string $s + * @global array $totals + * + * @param array $item + */ + public function single_row( $item ) { + global $status, $page, $s, $totals; + + list( $plugin_file, $plugin_data ) = $item; + $context = $status; + $screen = $this->screen; + + // Pre-order. + $actions = array( + 'deactivate' => '', + 'activate' => '', + 'details' => '', + 'delete' => '', + ); + + // Do not restrict by default + $restrict_network_active = false; + $restrict_network_only = false; + + if ( 'mustuse' === $context ) { + $is_active = true; + } elseif ( 'dropins' === $context ) { + $dropins = _get_dropins(); + $plugin_name = $plugin_file; + if ( $plugin_file != $plugin_data['Name'] ) + $plugin_name .= '
    ' . $plugin_data['Name']; + if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant + $is_active = true; + $description = '

    ' . $dropins[ $plugin_file ][0] . '

    '; + } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true + $is_active = true; + $description = '

    ' . $dropins[ $plugin_file ][0] . '

    '; + } else { + $is_active = false; + $description = '

    ' . $dropins[ $plugin_file ][0] . ' ' . __( 'Inactive:' ) . ' ' . + /* translators: 1: drop-in constant name, 2: wp-config.php */ + sprintf( __( 'Requires %1$s in %2$s file.' ), + "define('" . $dropins[ $plugin_file ][1] . "', true);", + 'wp-config.php' + ) . '

    '; + } + if ( $plugin_data['Description'] ) + $description .= '

    ' . $plugin_data['Description'] . '

    '; + } else { + if ( $screen->in_admin( 'network' ) ) { + $is_active = is_plugin_active_for_network( $plugin_file ); + } else { + $is_active = is_plugin_active( $plugin_file ); + $restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) ); + $restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active ); + } + + if ( $screen->in_admin( 'network' ) ) { + if ( $is_active ) { + if ( current_user_can( 'manage_network_plugins' ) ) { + /* translators: %s: plugin name */ + $actions['deactivate'] = '' . __( 'Network Deactivate' ) . ''; + } + } else { + if ( current_user_can( 'manage_network_plugins' ) ) { + /* translators: %s: plugin name */ + $actions['activate'] = '' . __( 'Network Activate' ) . ''; + } + if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) { + /* translators: %s: plugin name */ + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + } + } else { + if ( $restrict_network_active ) { + $actions = array( + 'network_active' => __( 'Network Active' ), + ); + } elseif ( $restrict_network_only ) { + $actions = array( + 'network_only' => __( 'Network Only' ), + ); + } elseif ( $is_active ) { + if ( current_user_can( 'deactivate_plugin', $plugin_file ) ) { + /* translators: %s: plugin name */ + $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; + } + } else { + if ( current_user_can( 'activate_plugin', $plugin_file ) ) { + /* translators: %s: plugin name */ + $actions['activate'] = '' . __( 'Activate' ) . ''; + } + + if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) { + /* translators: %s: plugin name */ + $actions['delete'] = '' . __( 'Delete' ) . ''; + } + } // end if $is_active + + } // end if $screen->in_admin( 'network' ) + + } // end if $context + + $actions = array_filter( $actions ); + + if ( $screen->in_admin( 'network' ) ) { + + /** + * Filters the action links displayed for each plugin in the Network Admin Plugins list table. + * + * @since 3.1.0 + * + * @param array $actions An array of plugin action links. By default this can include 'activate', + * 'deactivate', and 'delete'. + * @param string $plugin_file Path to the plugin file relative to the plugins directory. + * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. + * @param string $context The plugin context. By default this can include 'all', 'active', 'inactive', + * 'recently_activated', 'upgrade', 'mustuse', 'dropins', and 'search'. + */ + $actions = apply_filters( 'network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); + + /** + * Filters the list of action links displayed for a specific plugin in the Network Admin Plugins list table. + * + * The dynamic portion of the hook name, `$plugin_file`, refers to the path + * to the plugin file, relative to the plugins directory. + * + * @since 3.1.0 + * + * @param array $actions An array of plugin action links. By default this can include 'activate', + * 'deactivate', and 'delete'. + * @param string $plugin_file Path to the plugin file relative to the plugins directory. + * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. + * @param string $context The plugin context. By default this can include 'all', 'active', 'inactive', + * 'recently_activated', 'upgrade', 'mustuse', 'dropins', and 'search'. + */ + $actions = apply_filters( "network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context ); + + } else { + + /** + * Filters the action links displayed for each plugin in the Plugins list table. + * + * @since 2.5.0 + * @since 2.6.0 The `$context` parameter was added. + * @since 4.9.0 The 'Edit' link was removed from the list of action links. + * + * @param array $actions An array of plugin action links. By default this can include 'activate', + * 'deactivate', and 'delete'. With Multisite active this can also include + * 'network_active' and 'network_only' items. + * @param string $plugin_file Path to the plugin file relative to the plugins directory. + * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. + * @param string $context The plugin context. By default this can include 'all', 'active', 'inactive', + * 'recently_activated', 'upgrade', 'mustuse', 'dropins', and 'search'. + */ + $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); + + /** + * Filters the list of action links displayed for a specific plugin in the Plugins list table. + * + * The dynamic portion of the hook name, `$plugin_file`, refers to the path + * to the plugin file, relative to the plugins directory. + * + * @since 2.7.0 + * @since 4.9.0 The 'Edit' link was removed from the list of action links. + * + * @param array $actions An array of plugin action links. By default this can include 'activate', + * 'deactivate', and 'delete'. With Multisite active this can also include + * 'network_active' and 'network_only' items. + * @param string $plugin_file Path to the plugin file relative to the plugins directory. + * @param array $plugin_data An array of plugin data. See `get_plugin_data()`. + * @param string $context The plugin context. By default this can include 'all', 'active', 'inactive', + * 'recently_activated', 'upgrade', 'mustuse', 'dropins', and 'search'. + */ + $actions = apply_filters( "plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context ); + + } + + $class = $is_active ? 'active' : 'inactive'; + $checkbox_id = "checkbox_" . md5($plugin_data['Name']); + if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) { + $checkbox = ''; + } else { + $checkbox = "" + . ""; + } + if ( 'dropins' != $context ) { + $description = '

    ' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '

    '; + $plugin_name = $plugin_data['Name']; + } + + if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) + $class .= ' update'; + + $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name ); + printf( '', + esc_attr( $class ), + esc_attr( $plugin_slug ), + esc_attr( $plugin_file ) + ); + + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $extra_classes = ''; + if ( in_array( $column_name, $hidden ) ) { + $extra_classes = ' hidden'; + } + + switch ( $column_name ) { + case 'cb': + echo "$checkbox"; + break; + case 'name': + echo "$plugin_name"; + echo $this->row_actions( $actions, true ); + echo ""; + break; + case 'description': + $classes = 'column-description desc'; + + echo " +
    $description
    +
    "; + + $plugin_meta = array(); + if ( !empty( $plugin_data['Version'] ) ) + $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); + if ( !empty( $plugin_data['Author'] ) ) { + $author = $plugin_data['Author']; + if ( !empty( $plugin_data['AuthorURI'] ) ) + $author = '' . $plugin_data['Author'] . ''; + $plugin_meta[] = sprintf( __( 'By %s' ), $author ); + } + + // Details link using API info, if available + if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) { + $plugin_meta[] = sprintf( '%s', + esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] . + '&TB_iframe=true&width=600&height=550' ) ), + esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ), + esc_attr( $plugin_name ), + __( 'View details' ) + ); + } elseif ( ! empty( $plugin_data['PluginURI'] ) ) { + $plugin_meta[] = sprintf( '%s', + esc_url( $plugin_data['PluginURI'] ), + __( 'Visit plugin site' ) + ); + } + + /** + * Filters the array of row meta for each plugin in the Plugins list table. + * + * @since 2.8.0 + * + * @param array $plugin_meta An array of the plugin's metadata, + * including the version, author, + * author URI, and plugin URI. + * @param string $plugin_file Path to the plugin file, relative to the plugins directory. + * @param array $plugin_data An array of plugin data. + * @param string $status Status of the plugin. Defaults are 'All', 'Active', + * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', + * 'Drop-ins', 'Search'. + */ + $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); + echo implode( ' | ', $plugin_meta ); + + echo "
    "; + break; + default: + $classes = "$column_name column-$column_name $class"; + + echo ""; + + /** + * Fires inside each custom column of the Plugins list table. + * + * @since 3.1.0 + * + * @param string $column_name Name of the column. + * @param string $plugin_file Path to the plugin file. + * @param array $plugin_data An array of plugin data. + */ + do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data ); + + echo ""; + } + } + + echo ""; + + /** + * Fires after each row in the Plugins list table. + * + * @since 2.3.0 + * + * @param string $plugin_file Path to the plugin file, relative to the plugins directory. + * @param array $plugin_data An array of plugin data. + * @param string $status Status of the plugin. Defaults are 'All', 'Active', + * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', + * 'Drop-ins', 'Search'. + */ + do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); + + /** + * Fires after each specific row in the Plugins list table. + * + * The dynamic portion of the hook name, `$plugin_file`, refers to the path + * to the plugin file, relative to the plugins directory. + * + * @since 2.7.0 + * + * @param string $plugin_file Path to the plugin file, relative to the plugins directory. + * @param array $plugin_data An array of plugin data. + * @param string $status Status of the plugin. Defaults are 'All', 'Active', + * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', + * 'Drop-ins', 'Search'. + */ + do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status ); + } + + /** + * Gets the name of the primary column for this specific list table. + * + * @since 4.3.0 + * + * @return string Unalterable name for the primary column, in this case, 'name'. + */ + protected function get_primary_column_name() { + return 'name'; + } +} diff --git a/backend/wp-admin/includes/class-wp-post-comments-list-table.php b/backend/wp-admin/includes/class-wp-post-comments-list-table.php new file mode 100644 index 0000000..719d655 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-post-comments-list-table.php @@ -0,0 +1,77 @@ + __( 'Author' ), + 'comment' => _x( 'Comment', 'column name' ), + ), + array(), + array(), + 'comment', + ); + } + + /** + * + * @return array + */ + protected function get_table_classes() { + $classes = parent::get_table_classes(); + $classes[] = 'wp-list-table'; + $classes[] = 'comments-box'; + return $classes; + } + + /** + * + * @param bool $output_empty + */ + public function display( $output_empty = false ) { + $singular = $this->_args['singular']; + + wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); +?> + + > + display_rows_or_placeholder(); + } ?> + + + 'posts', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + + $post_type = $this->screen->post_type; + $post_type_object = get_post_type_object( $post_type ); + + $exclude_states = get_post_stati( array( + 'show_in_admin_all_list' => false, + ) ); + $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( " + SELECT COUNT( 1 ) + FROM $wpdb->posts + WHERE post_type = %s + AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) + AND post_author = %d + ", $post_type, get_current_user_id() ) ) ); + + if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { + $_GET['author'] = get_current_user_id(); + } + + if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { + $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); + $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) ); + } + } + + /** + * Sets whether the table layout should be hierarchical or not. + * + * @since 4.2.0 + * + * @param bool $display Whether the table layout should be hierarchical. + */ + public function set_hierarchical_display( $display ) { + $this->hierarchical_display = $display; + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); + } + + /** + * + * @global array $avail_post_stati + * @global WP_Query $wp_query + * @global int $per_page + * @global string $mode + */ + public function prepare_items() { + global $avail_post_stati, $wp_query, $per_page, $mode; + + // is going to call wp() + $avail_post_stati = wp_edit_posts_query(); + + $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] ); + + $post_type = $this->screen->post_type; + $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); + + /** This filter is documented in wp-admin/includes/post.php */ + $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); + + if ( $this->hierarchical_display ) { + $total_items = $wp_query->post_count; + } elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { + $total_items = $wp_query->found_posts; + } else { + $post_counts = (array) wp_count_posts( $post_type, 'readable' ); + + if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) { + $total_items = $post_counts[ $_REQUEST['post_status'] ]; + } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { + $total_items = $this->sticky_posts_count; + } elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) { + $total_items = $this->user_posts_count; + } else { + $total_items = array_sum( $post_counts ); + + // Subtract post types that are not included in the admin all list. + foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { + $total_items -= $post_counts[ $state ]; + } + } + } + + if ( ! empty( $_REQUEST['mode'] ) ) { + $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; + set_user_setting( 'posts_list_mode', $mode ); + } else { + $mode = get_user_setting( 'posts_list_mode', 'list' ); + } + + $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash'; + + $this->set_pagination_args( array( + 'total_items' => $total_items, + 'per_page' => $per_page + ) ); + } + + /** + * + * @return bool + */ + public function has_items() { + return have_posts(); + } + + /** + */ + public function no_items() { + if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) + echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; + else + echo get_post_type_object( $this->screen->post_type )->labels->not_found; + } + + /** + * Determine if the current view is the "All" view. + * + * @since 4.2.0 + * + * @return bool Whether the current view is the "All" view. + */ + protected function is_base_request() { + $vars = $_GET; + unset( $vars['paged'] ); + + if ( empty( $vars ) ) { + return true; + } elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { + return $this->screen->post_type === $vars['post_type']; + } + + return 1 === count( $vars ) && ! empty( $vars['mode'] ); + } + + /** + * Helper to create links to edit.php with params. + * + * @since 4.4.0 + * + * @param array $args URL parameters for the link. + * @param string $label Link text. + * @param string $class Optional. Class attribute. Default empty string. + * @return string The formatted link string. + */ + protected function get_edit_link( $args, $label, $class = '' ) { + $url = add_query_arg( $args, 'edit.php' ); + + $class_html = $aria_current = ''; + if ( ! empty( $class ) ) { + $class_html = sprintf( + ' class="%s"', + esc_attr( $class ) + ); + + if ( 'current' === $class ) { + $aria_current = ' aria-current="page"'; + } + } + + return sprintf( + '%s', + esc_url( $url ), + $class_html, + $aria_current, + $label + ); + } + + /** + * + * @global array $locked_post_status This seems to be deprecated. + * @global array $avail_post_stati + * @return array + */ + protected function get_views() { + global $locked_post_status, $avail_post_stati; + + $post_type = $this->screen->post_type; + + if ( !empty($locked_post_status) ) + return array(); + + $status_links = array(); + $num_posts = wp_count_posts( $post_type, 'readable' ); + $total_posts = array_sum( (array) $num_posts ); + $class = ''; + + $current_user_id = get_current_user_id(); + $all_args = array( 'post_type' => $post_type ); + $mine = ''; + + // Subtract post types that are not included in the admin all list. + foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { + $total_posts -= $num_posts->$state; + } + + if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { + if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { + $class = 'current'; + } + + $mine_args = array( + 'post_type' => $post_type, + 'author' => $current_user_id + ); + + $mine_inner_html = sprintf( + _nx( + 'Mine (%s)', + 'Mine (%s)', + $this->user_posts_count, + 'posts' + ), + number_format_i18n( $this->user_posts_count ) + ); + + $mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); + + $all_args['all_posts'] = 1; + $class = ''; + } + + if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) { + $class = 'current'; + } + + $all_inner_html = sprintf( + _nx( + 'All (%s)', + 'All (%s)', + $total_posts, + 'posts' + ), + number_format_i18n( $total_posts ) + ); + + $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); + if ( $mine ) { + $status_links['mine'] = $mine; + } + + foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { + $class = ''; + + $status_name = $status->name; + + if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) { + continue; + } + + if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) { + $class = 'current'; + } + + $status_args = array( + 'post_status' => $status_name, + 'post_type' => $post_type, + ); + + $status_label = sprintf( + translate_nooped_plural( $status->label_count, $num_posts->$status_name ), + number_format_i18n( $num_posts->$status_name ) + ); + + $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class ); + } + + if ( ! empty( $this->sticky_posts_count ) ) { + $class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; + + $sticky_args = array( + 'post_type' => $post_type, + 'show_sticky' => 1 + ); + + $sticky_inner_html = sprintf( + _nx( + 'Sticky (%s)', + 'Sticky (%s)', + $this->sticky_posts_count, + 'posts' + ), + number_format_i18n( $this->sticky_posts_count ) + ); + + $sticky_link = array( + 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ) + ); + + // Sticky comes after Publish, or if not listed, after All. + $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); + $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); + } + + return $status_links; + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + $post_type_obj = get_post_type_object( $this->screen->post_type ); + + if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { + if ( $this->is_trash ) { + $actions['untrash'] = __( 'Restore' ); + } else { + $actions['edit'] = __( 'Edit' ); + } + } + + if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { + if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { + $actions['delete'] = __( 'Delete Permanently' ); + } else { + $actions['trash'] = __( 'Move to Trash' ); + } + } + + return $actions; + } + + /** + * Displays a categories drop-down for filtering on the Posts list table. + * + * @since 4.6.0 + * + * @global int $cat Currently selected category. + * + * @param string $post_type Post type slug. + */ + protected function categories_dropdown( $post_type ) { + global $cat; + + /** + * Filters whether to remove the 'Categories' drop-down from the post list table. + * + * @since 4.6.0 + * + * @param bool $disable Whether to disable the categories drop-down. Default false. + * @param string $post_type Post type slug. + */ + if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { + return; + } + + if ( is_object_in_taxonomy( $post_type, 'category' ) ) { + $dropdown_options = array( + 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, + 'hide_empty' => 0, + 'hierarchical' => 1, + 'show_count' => 0, + 'orderby' => 'name', + 'selected' => $cat + ); + + echo ''; + wp_dropdown_categories( $dropdown_options ); + } + } + + /** + * @param string $which + */ + protected function extra_tablenav( $which ) { +?> +
    +months_dropdown( $this->screen->post_type ); + $this->categories_dropdown( $this->screen->post_type ); + + /** + * Fires before the Filter button on the Posts and Pages list tables. + * + * The Filter button allows sorting by date and/or category on the + * Posts list table, and sorting by date on the Pages list table. + * + * @since 2.1.0 + * @since 4.4.0 The `$post_type` parameter was added. + * @since 4.6.0 The `$which` parameter was added. + * + * @param string $post_type The post type slug. + * @param string $which The location of the extra table nav markup: + * 'top' or 'bottom' for WP_Posts_List_Table, + * 'bar' for WP_Media_List_Table. + */ + do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); + + $output = ob_get_clean(); + + if ( ! empty( $output ) ) { + echo $output; + submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); + } + } + + if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) { + submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); + } +?> +
    +screen->post_type ) ? 'pages' : 'posts' ); + } + + /** + * + * @return array + */ + public function get_columns() { + $post_type = $this->screen->post_type; + + $posts_columns = array(); + + $posts_columns['cb'] = ''; + + /* translators: manage posts column name */ + $posts_columns['title'] = _x( 'Title', 'column name' ); + + if ( post_type_supports( $post_type, 'author' ) ) { + $posts_columns['author'] = __( 'Author' ); + } + + $taxonomies = get_object_taxonomies( $post_type, 'objects' ); + $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); + + /** + * Filters the taxonomy columns in the Posts list table. + * + * The dynamic portion of the hook name, `$post_type`, refers to the post + * type slug. + * + * @since 3.5.0 + * + * @param array $taxonomies Array of taxonomies to show columns for. + * @param string $post_type The post type. + */ + $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); + $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); + + foreach ( $taxonomies as $taxonomy ) { + if ( 'category' === $taxonomy ) + $column_key = 'categories'; + elseif ( 'post_tag' === $taxonomy ) + $column_key = 'tags'; + else + $column_key = 'taxonomy-' . $taxonomy; + + $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; + } + + $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; + if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) + $posts_columns['comments'] = '' . __( 'Comments' ) . ''; + + $posts_columns['date'] = __( 'Date' ); + + if ( 'page' === $post_type ) { + + /** + * Filters the columns displayed in the Pages list table. + * + * @since 2.5.0 + * + * @param array $post_columns An array of column names. + */ + $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); + } else { + + /** + * Filters the columns displayed in the Posts list table. + * + * @since 1.5.0 + * + * @param array $posts_columns An array of column names. + * @param string $post_type The post type slug. + */ + $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); + } + + /** + * Filters the columns displayed in the Posts list table for a specific post type. + * + * The dynamic portion of the hook name, `$post_type`, refers to the post type slug. + * + * @since 3.0.0 + * + * @param array $post_columns An array of column names. + */ + return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'title' => 'title', + 'parent' => 'parent', + 'comments' => 'comment_count', + 'date' => array( 'date', true ) + ); + } + + /** + * @global WP_Query $wp_query + * @global int $per_page + * @param array $posts + * @param int $level + */ + public function display_rows( $posts = array(), $level = 0 ) { + global $wp_query, $per_page; + + if ( empty( $posts ) ) + $posts = $wp_query->posts; + + add_filter( 'the_title', 'esc_html' ); + + if ( $this->hierarchical_display ) { + $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); + } else { + $this->_display_rows( $posts, $level ); + } + } + + /** + * @param array $posts + * @param int $level + */ + private function _display_rows( $posts, $level = 0 ) { + // Create array of post IDs. + $post_ids = array(); + + foreach ( $posts as $a_post ) + $post_ids[] = $a_post->ID; + + $this->comment_pending_count = get_pending_comments_num( $post_ids ); + + foreach ( $posts as $post ) + $this->single_row( $post, $level ); + } + + /** + * @global wpdb $wpdb + * @global WP_Post $post + * @param array $pages + * @param int $pagenum + * @param int $per_page + */ + private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { + global $wpdb; + + $level = 0; + + if ( ! $pages ) { + $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); + + if ( ! $pages ) + return; + } + + /* + * Arrange pages into two parts: top level pages and children_pages + * children_pages is two dimensional array, eg. + * children_pages[10][] contains all sub-pages whose parent is 10. + * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations + * If searching, ignore hierarchy and treat everything as top level + */ + if ( empty( $_REQUEST['s'] ) ) { + + $top_level_pages = array(); + $children_pages = array(); + + foreach ( $pages as $page ) { + + // Catch and repair bad pages. + if ( $page->post_parent == $page->ID ) { + $page->post_parent = 0; + $wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); + clean_post_cache( $page ); + } + + if ( 0 == $page->post_parent ) + $top_level_pages[] = $page; + else + $children_pages[ $page->post_parent ][] = $page; + } + + $pages = &$top_level_pages; + } + + $count = 0; + $start = ( $pagenum - 1 ) * $per_page; + $end = $start + $per_page; + $to_display = array(); + + foreach ( $pages as $page ) { + if ( $count >= $end ) + break; + + if ( $count >= $start ) { + $to_display[$page->ID] = $level; + } + + $count++; + + if ( isset( $children_pages ) ) + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); + } + + // If it is the last pagenum and there are orphaned pages, display them with paging as well. + if ( isset( $children_pages ) && $count < $end ){ + foreach ( $children_pages as $orphans ){ + foreach ( $orphans as $op ) { + if ( $count >= $end ) + break; + + if ( $count >= $start ) { + $to_display[$op->ID] = 0; + } + + $count++; + } + } + } + + $ids = array_keys( $to_display ); + _prime_post_caches( $ids ); + + if ( ! isset( $GLOBALS['post'] ) ) { + $GLOBALS['post'] = reset( $ids ); + } + + foreach ( $to_display as $page_id => $level ) { + echo "\t"; + $this->single_row( $page_id, $level ); + } + } + + /** + * Given a top level page ID, display the nested hierarchy of sub-pages + * together with paging support + * + * @since 3.1.0 (Standalone function exists since 2.6.0) + * @since 4.2.0 Added the `$to_display` parameter. + * + * @param array $children_pages + * @param int $count + * @param int $parent + * @param int $level + * @param int $pagenum + * @param int $per_page + * @param array $to_display List of pages to be displayed. Passed by reference. + */ + private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { + if ( ! isset( $children_pages[$parent] ) ) + return; + + $start = ( $pagenum - 1 ) * $per_page; + $end = $start + $per_page; + + foreach ( $children_pages[$parent] as $page ) { + if ( $count >= $end ) + break; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $page->post_parent > 0 ) { + $my_parents = array(); + $my_parent = $page->post_parent; + while ( $my_parent ) { + // Get the ID from the list or the attribute if my_parent is an object + $parent_id = $my_parent; + if ( is_object( $my_parent ) ) { + $parent_id = $my_parent->ID; + } + + $my_parent = get_post( $parent_id ); + $my_parents[] = $my_parent; + if ( !$my_parent->post_parent ) + break; + $my_parent = $my_parent->post_parent; + } + $num_parents = count( $my_parents ); + while ( $my_parent = array_pop( $my_parents ) ) { + $to_display[$my_parent->ID] = $level - $num_parents; + $num_parents--; + } + } + + if ( $count >= $start ) { + $to_display[$page->ID] = $level; + } + + $count++; + + $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); + } + + unset( $children_pages[$parent] ); //required in order to keep track of orphans + } + + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_cb( $post ) { + if ( current_user_can( 'edit_post', $post->ID ) ): ?> + + +
    + + +
    + '; + echo $this->column_title( $post ); + echo $this->handle_row_actions( $post, 'title', $primary ); + echo ''; + } + + /** + * Handles the title column output. + * + * @since 4.3.0 + * + * @global string $mode List table view mode. + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_title( $post ) { + global $mode; + + if ( $this->hierarchical_display ) { + if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { + // Sent level 0 by accident, by default, or because we don't know the actual level. + $find_main_page = (int) $post->post_parent; + while ( $find_main_page > 0 ) { + $parent = get_post( $find_main_page ); + + if ( is_null( $parent ) ) { + break; + } + + $this->current_level++; + $find_main_page = (int) $parent->post_parent; + + if ( ! isset( $parent_name ) ) { + /** This filter is documented in wp-includes/post-template.php */ + $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); + } + } + } + } + + $can_edit_post = current_user_can( 'edit_post', $post->ID ); + + if ( $can_edit_post && $post->post_status != 'trash' ) { + $lock_holder = wp_check_post_lock( $post->ID ); + + if ( $lock_holder ) { + $lock_holder = get_userdata( $lock_holder ); + $locked_avatar = get_avatar( $lock_holder->ID, 18 ); + $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); + } else { + $locked_avatar = $locked_text = ''; + } + + echo '
    ' . $locked_avatar . ' ' . $locked_text . "
    \n"; + } + + $pad = str_repeat( '— ', $this->current_level ); + echo ""; + + $format = get_post_format( $post->ID ); + if ( $format ) { + $label = get_post_format_string( $format ); + + $format_class = 'post-state-format post-format-icon post-format-' . $format; + + $format_args = array( + 'post_format' => $format, + 'post_type' => $post->post_type + ); + + echo $this->get_edit_link( $format_args, $label . ':', $format_class ); + } + + $title = _draft_or_post_title(); + + if ( $can_edit_post && $post->post_status != 'trash' ) { + printf( + '%s%s', + get_edit_post_link( $post->ID ), + /* translators: %s: post title */ + esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), + $pad, + $title + ); + } else { + echo $pad . $title; + } + _post_states( $post ); + + if ( isset( $parent_name ) ) { + $post_type_object = get_post_type_object( $post->post_type ); + echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); + } + echo "\n"; + + if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) { + if ( post_password_required( $post ) ) { + echo '' . esc_html( get_the_excerpt() ) . ''; + } else { + echo esc_html( get_the_excerpt() ); + } + } + + get_inline_data( $post ); + } + + /** + * Handles the post date column output. + * + * @since 4.3.0 + * + * @global string $mode List table view mode. + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_date( $post ) { + global $mode; + + if ( '0000-00-00 00:00:00' === $post->post_date ) { + $t_time = $h_time = __( 'Unpublished' ); + $time_diff = 0; + } else { + $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); + $m_time = $post->post_date; + $time = get_post_time( 'G', true, $post ); + + $time_diff = time() - $time; + + if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); + } else { + $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + } + } + + if ( 'publish' === $post->post_status ) { + $status = __( 'Published' ); + } elseif ( 'future' === $post->post_status ) { + if ( $time_diff > 0 ) { + $status = '' . __( 'Missed schedule' ) . ''; + } else { + $status = __( 'Scheduled' ); + } + } else { + $status = __( 'Last Modified' ); + } + + /** + * Filters the status text of the post. + * + * @since 4.8.0 + * + * @param string $status The status text. + * @param WP_Post $post Post object. + * @param string $column_name The column name. + * @param string $mode The list display mode ('excerpt' or 'list'). + */ + $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); + + if ( $status ) { + echo $status . '
    '; + } + + if ( 'excerpt' === $mode ) { + /** + * Filters the published time of the post. + * + * If `$mode` equals 'excerpt', the published time and date are both displayed. + * If `$mode` equals 'list' (default), the publish date is displayed, with the + * time and date together available as an abbreviation definition. + * + * @since 2.5.1 + * + * @param string $t_time The published time. + * @param WP_Post $post Post object. + * @param string $column_name The column name. + * @param string $mode The list display mode ('excerpt' or 'list'). + */ + echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); + } else { + + /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ + echo '' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . ''; + } + } + + /** + * Handles the comments column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + */ + public function column_comments( $post ) { + ?> +
    + comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; + + $this->comments_bubble( $post->ID, $pending_comments ); + ?> +
    + $post->post_type, + 'author' => get_the_author_meta( 'ID' ) + ); + echo $this->get_edit_link( $args, get_the_author() ); + } + + /** + * Handles the default column output. + * + * @since 4.3.0 + * + * @param WP_Post $post The current WP_Post object. + * @param string $column_name The current column name. + */ + public function column_default( $post, $column_name ) { + if ( 'categories' === $column_name ) { + $taxonomy = 'category'; + } elseif ( 'tags' === $column_name ) { + $taxonomy = 'post_tag'; + } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { + $taxonomy = substr( $column_name, 9 ); + } else { + $taxonomy = false; + } + if ( $taxonomy ) { + $taxonomy_object = get_taxonomy( $taxonomy ); + $terms = get_the_terms( $post->ID, $taxonomy ); + if ( is_array( $terms ) ) { + $out = array(); + foreach ( $terms as $t ) { + $posts_in_term_qv = array(); + if ( 'post' != $post->post_type ) { + $posts_in_term_qv['post_type'] = $post->post_type; + } + if ( $taxonomy_object->query_var ) { + $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; + } else { + $posts_in_term_qv['taxonomy'] = $taxonomy; + $posts_in_term_qv['term'] = $t->slug; + } + + $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); + $out[] = $this->get_edit_link( $posts_in_term_qv, $label ); + } + /* translators: used between list items, there is a space after the comma */ + echo join( __( ', ' ), $out ); + } else { + echo '' . $taxonomy_object->labels->no_terms . ''; + } + return; + } + + if ( is_post_type_hierarchical( $post->post_type ) ) { + + /** + * Fires in each custom column on the Posts list table. + * + * This hook only fires if the current post type is hierarchical, + * such as pages. + * + * @since 2.5.0 + * + * @param string $column_name The name of the column to display. + * @param int $post_id The current post ID. + */ + do_action( 'manage_pages_custom_column', $column_name, $post->ID ); + } else { + + /** + * Fires in each custom column in the Posts list table. + * + * This hook only fires if the current post type is non-hierarchical, + * such as posts. + * + * @since 1.5.0 + * + * @param string $column_name The name of the column to display. + * @param int $post_id The current post ID. + */ + do_action( 'manage_posts_custom_column', $column_name, $post->ID ); + } + + /** + * Fires for each custom column of a specific post type in the Posts list table. + * + * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. + * + * @since 3.1.0 + * + * @param string $column_name The name of the column to display. + * @param int $post_id The current post ID. + */ + do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); + } + + /** + * @global WP_Post $post + * + * @param int|WP_Post $post + * @param int $level + */ + public function single_row( $post, $level = 0 ) { + $global_post = get_post(); + + $post = get_post( $post ); + $this->current_level = $level; + + $GLOBALS['post'] = $post; + setup_postdata( $post ); + + $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); + + $lock_holder = wp_check_post_lock( $post->ID ); + if ( $lock_holder ) { + $classes .= ' wp-locked'; + } + + if ( $post->post_parent ) { + $count = count( get_post_ancestors( $post->ID ) ); + $classes .= ' level-'. $count; + } else { + $classes .= ' level-0'; + } + ?> + + single_row_columns( $post ); ?> + + post_type ); + $can_edit_post = current_user_can( 'edit_post', $post->ID ); + $actions = array(); + $title = _draft_or_post_title(); + + if ( $can_edit_post && 'trash' != $post->post_status ) { + $actions['edit'] = sprintf( + '%s', + get_edit_post_link( $post->ID ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), + __( 'Edit' ) + ); + $actions['inline hide-if-no-js'] = sprintf( + '%s', + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), + __( 'Quick Edit' ) + ); + } + + if ( current_user_can( 'delete_post', $post->ID ) ) { + if ( 'trash' === $post->post_status ) { + $actions['untrash'] = sprintf( + '%s', + wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), + __( 'Restore' ) + ); + } elseif ( EMPTY_TRASH_DAYS ) { + $actions['trash'] = sprintf( + '%s', + get_delete_post_link( $post->ID ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), + _x( 'Trash', 'verb' ) + ); + } + if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { + $actions['delete'] = sprintf( + '%s', + get_delete_post_link( $post->ID, '', true ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), + __( 'Delete Permanently' ) + ); + } + } + + if ( is_post_type_viewable( $post_type_object ) ) { + if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { + if ( $can_edit_post ) { + $preview_link = get_preview_post_link( $post ); + $actions['view'] = sprintf( + '%s', + esc_url( $preview_link ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), + __( 'Preview' ) + ); + } + } elseif ( 'trash' != $post->post_status ) { + $actions['view'] = sprintf( + '%s', + get_permalink( $post->ID ), + /* translators: %s: post title */ + esc_attr( sprintf( __( 'View “%s”' ), $title ) ), + __( 'View' ) + ); + } + } + + if ( is_post_type_hierarchical( $post->post_type ) ) { + + /** + * Filters the array of row action links on the Pages list table. + * + * The filter is evaluated only for hierarchical post types. + * + * @since 2.8.0 + * + * @param array $actions An array of row action links. Defaults are + * 'Edit', 'Quick Edit', 'Restore', 'Trash', + * 'Delete Permanently', 'Preview', and 'View'. + * @param WP_Post $post The post object. + */ + $actions = apply_filters( 'page_row_actions', $actions, $post ); + } else { + + /** + * Filters the array of row action links on the Posts list table. + * + * The filter is evaluated only for non-hierarchical post types. + * + * @since 2.8.0 + * + * @param array $actions An array of row action links. Defaults are + * 'Edit', 'Quick Edit', 'Restore', 'Trash', + * 'Delete Permanently', 'Preview', and 'View'. + * @param WP_Post $post The post object. + */ + $actions = apply_filters( 'post_row_actions', $actions, $post ); + } + + return $this->row_actions( $actions ); + } + + /** + * Outputs the hidden row displayed when inline editing + * + * @since 3.1.0 + * + * @global string $mode List table view mode. + */ + public function inline_edit() { + global $mode; + + $screen = $this->screen; + + $post = get_default_post_to_edit( $screen->post_type ); + $post_type_object = get_post_type_object( $screen->post_type ); + + $taxonomy_names = get_object_taxonomies( $screen->post_type ); + $hierarchical_taxonomies = array(); + $flat_taxonomies = array(); + foreach ( $taxonomy_names as $taxonomy_name ) { + + $taxonomy = get_taxonomy( $taxonomy_name ); + + $show_in_quick_edit = $taxonomy->show_in_quick_edit; + + /** + * Filters whether the current taxonomy should be shown in the Quick Edit panel. + * + * @since 4.2.0 + * + * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. + * @param string $taxonomy_name Taxonomy name. + * @param string $post_type Post type of current Quick Edit post. + */ + if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { + continue; + } + + if ( $taxonomy->hierarchical ) + $hierarchical_taxonomies[] = $taxonomy; + else + $flat_taxonomies[] = $taxonomy; + } + + $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; + $can_publish = current_user_can( $post_type_object->cap->publish_posts ); + $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); + + ?> + +
    + post_type}"; + $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; + + $bulk = 0; + while ( $bulk < 2 ) { ?> + + + +
    +post_type; + } + break; + case 'edit-tags' : + case 'term' : + if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) + $post_type = 'post'; + break; + case 'upload': + $post_type = 'attachment'; + break; + } + } + + switch ( $base ) { + case 'post' : + if ( null === $post_type ) + $post_type = 'post'; + $id = $post_type; + break; + case 'edit' : + if ( null === $post_type ) + $post_type = 'post'; + $id .= '-' . $post_type; + break; + case 'edit-tags' : + case 'term' : + if ( null === $taxonomy ) + $taxonomy = 'post_tag'; + // The edit-tags ID does not contain the post type. Look for it in the request. + if ( null === $post_type ) { + $post_type = 'post'; + if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) + $post_type = $_REQUEST['post_type']; + } + + $id = 'edit-' . $taxonomy; + break; + } + + if ( 'network' == $in_admin ) { + $id .= '-network'; + $base .= '-network'; + } elseif ( 'user' == $in_admin ) { + $id .= '-user'; + $base .= '-user'; + } + + if ( isset( self::$_registry[ $id ] ) ) { + $screen = self::$_registry[ $id ]; + if ( $screen === get_current_screen() ) + return $screen; + } else { + $screen = new WP_Screen(); + $screen->id = $id; + } + + $screen->base = $base; + $screen->action = $action; + $screen->post_type = (string) $post_type; + $screen->taxonomy = (string) $taxonomy; + $screen->is_user = ( 'user' == $in_admin ); + $screen->is_network = ( 'network' == $in_admin ); + $screen->in_admin = $in_admin; + + self::$_registry[ $id ] = $screen; + + return $screen; + } + + /** + * Makes the screen object the current screen. + * + * @see set_current_screen() + * @since 3.3.0 + * + * @global WP_Screen $current_screen + * @global string $taxnow + * @global string $typenow + */ + public function set_current_screen() { + global $current_screen, $taxnow, $typenow; + $current_screen = $this; + $taxnow = $this->taxonomy; + $typenow = $this->post_type; + + /** + * Fires after the current screen has been set. + * + * @since 3.0.0 + * + * @param WP_Screen $current_screen Current WP_Screen object. + */ + do_action( 'current_screen', $current_screen ); + } + + /** + * Constructor + * + * @since 3.3.0 + */ + private function __construct() {} + + /** + * Indicates whether the screen is in a particular admin + * + * @since 3.5.0 + * + * @param string $admin The admin to check against (network | user | site). + * If empty any of the three admins will result in true. + * @return bool True if the screen is in the indicated admin, false otherwise. + */ + public function in_admin( $admin = null ) { + if ( empty( $admin ) ) + return (bool) $this->in_admin; + + return ( $admin == $this->in_admin ); + } + + /** + * Sets the old string-based contextual help for the screen for backward compatibility. + * + * @since 3.3.0 + * + * @static + * + * @param WP_Screen $screen A screen object. + * @param string $help Help text. + */ + public static function add_old_compat_help( $screen, $help ) { + self::$_old_compat_help[ $screen->id ] = $help; + } + + /** + * Set the parent information for the screen. + * This is called in admin-header.php after the menu parent for the screen has been determined. + * + * @since 3.3.0 + * + * @param string $parent_file The parent file of the screen. Typically the $parent_file global. + */ + public function set_parentage( $parent_file ) { + $this->parent_file = $parent_file; + list( $this->parent_base ) = explode( '?', $parent_file ); + $this->parent_base = str_replace( '.php', '', $this->parent_base ); + } + + /** + * Adds an option for the screen. + * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options. + * + * @since 3.3.0 + * + * @param string $option Option ID + * @param mixed $args Option-dependent arguments. + */ + public function add_option( $option, $args = array() ) { + $this->_options[ $option ] = $args; + } + + /** + * Remove an option from the screen. + * + * @since 3.8.0 + * + * @param string $option Option ID. + */ + public function remove_option( $option ) { + unset( $this->_options[ $option ] ); + } + + /** + * Remove all options from the screen. + * + * @since 3.8.0 + */ + public function remove_options() { + $this->_options = array(); + } + + /** + * Get the options registered for the screen. + * + * @since 3.8.0 + * + * @return array Options with arguments. + */ + public function get_options() { + return $this->_options; + } + + /** + * Gets the arguments for an option for the screen. + * + * @since 3.3.0 + * + * @param string $option Option name. + * @param string $key Optional. Specific array key for when the option is an array. + * Default false. + * @return string The option value if set, null otherwise. + */ + public function get_option( $option, $key = false ) { + if ( ! isset( $this->_options[ $option ] ) ) + return null; + if ( $key ) { + if ( isset( $this->_options[ $option ][ $key ] ) ) + return $this->_options[ $option ][ $key ]; + return null; + } + return $this->_options[ $option ]; + } + + /** + * Gets the help tabs registered for the screen. + * + * @since 3.4.0 + * @since 4.4.0 Help tabs are ordered by their priority. + * + * @return array Help tabs with arguments. + */ + public function get_help_tabs() { + $help_tabs = $this->_help_tabs; + + $priorities = array(); + foreach ( $help_tabs as $help_tab ) { + if ( isset( $priorities[ $help_tab['priority'] ] ) ) { + $priorities[ $help_tab['priority'] ][] = $help_tab; + } else { + $priorities[ $help_tab['priority'] ] = array( $help_tab ); + } + } + + ksort( $priorities ); + + $sorted = array(); + foreach ( $priorities as $list ) { + foreach ( $list as $tab ) { + $sorted[ $tab['id'] ] = $tab; + } + } + + return $sorted; + } + + /** + * Gets the arguments for a help tab. + * + * @since 3.4.0 + * + * @param string $id Help Tab ID. + * @return array Help tab arguments. + */ + public function get_help_tab( $id ) { + if ( ! isset( $this->_help_tabs[ $id ] ) ) + return null; + return $this->_help_tabs[ $id ]; + } + + /** + * Add a help tab to the contextual help for the screen. + * Call this on the load-$pagenow hook for the relevant screen. + * + * @since 3.3.0 + * @since 4.4.0 The `$priority` argument was added. + * + * @param array $args { + * Array of arguments used to display the help tab. + * + * @type string $title Title for the tab. Default false. + * @type string $id Tab ID. Must be HTML-safe. Default false. + * @type string $content Optional. Help tab content in plain text or HTML. Default empty string. + * @type string $callback Optional. A callback to generate the tab content. Default false. + * @type int $priority Optional. The priority of the tab, used for ordering. Default 10. + * } + */ + public function add_help_tab( $args ) { + $defaults = array( + 'title' => false, + 'id' => false, + 'content' => '', + 'callback' => false, + 'priority' => 10, + ); + $args = wp_parse_args( $args, $defaults ); + + $args['id'] = sanitize_html_class( $args['id'] ); + + // Ensure we have an ID and title. + if ( ! $args['id'] || ! $args['title'] ) + return; + + // Allows for overriding an existing tab with that ID. + $this->_help_tabs[ $args['id'] ] = $args; + } + + /** + * Removes a help tab from the contextual help for the screen. + * + * @since 3.3.0 + * + * @param string $id The help tab ID. + */ + public function remove_help_tab( $id ) { + unset( $this->_help_tabs[ $id ] ); + } + + /** + * Removes all help tabs from the contextual help for the screen. + * + * @since 3.3.0 + */ + public function remove_help_tabs() { + $this->_help_tabs = array(); + } + + /** + * Gets the content from a contextual help sidebar. + * + * @since 3.4.0 + * + * @return string Contents of the help sidebar. + */ + public function get_help_sidebar() { + return $this->_help_sidebar; + } + + /** + * Add a sidebar to the contextual help for the screen. + * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help. + * + * @since 3.3.0 + * + * @param string $content Sidebar content in plain text or HTML. + */ + public function set_help_sidebar( $content ) { + $this->_help_sidebar = $content; + } + + /** + * Gets the number of layout columns the user has selected. + * + * The layout_columns option controls the max number and default number of + * columns. This method returns the number of columns within that range selected + * by the user via Screen Options. If no selection has been made, the default + * provisioned in layout_columns is returned. If the screen does not support + * selecting the number of layout columns, 0 is returned. + * + * @since 3.4.0 + * + * @return int Number of columns to display. + */ + public function get_columns() { + return $this->columns; + } + + /** + * Get the accessible hidden headings and text used in the screen. + * + * @since 4.4.0 + * + * @see set_screen_reader_content() For more information on the array format. + * + * @return array An associative array of screen reader text strings. + */ + public function get_screen_reader_content() { + return $this->_screen_reader_content; + } + + /** + * Get a screen reader text string. + * + * @since 4.4.0 + * + * @param string $key Screen reader text array named key. + * @return string Screen reader text string. + */ + public function get_screen_reader_text( $key ) { + if ( ! isset( $this->_screen_reader_content[ $key ] ) ) { + return null; + } + return $this->_screen_reader_content[ $key ]; + } + + /** + * Add accessible hidden headings and text for the screen. + * + * @since 4.4.0 + * + * @param array $content { + * An associative array of screen reader text strings. + * + * @type string $heading_views Screen reader text for the filter links heading. + * Default 'Filter items list'. + * @type string $heading_pagination Screen reader text for the pagination heading. + * Default 'Items list navigation'. + * @type string $heading_list Screen reader text for the items list heading. + * Default 'Items list'. + * } + */ + public function set_screen_reader_content( $content = array() ) { + $defaults = array( + 'heading_views' => __( 'Filter items list' ), + 'heading_pagination' => __( 'Items list navigation' ), + 'heading_list' => __( 'Items list' ), + ); + $content = wp_parse_args( $content, $defaults ); + + $this->_screen_reader_content = $content; + } + + /** + * Remove all the accessible hidden headings and text for the screen. + * + * @since 4.4.0 + */ + public function remove_screen_reader_content() { + $this->_screen_reader_content = array(); + } + + /** + * Render the screen's help section. + * + * This will trigger the deprecated filters for backward compatibility. + * + * @since 3.3.0 + * + * @global string $screen_layout_columns + */ + public function render_screen_meta() { + + /** + * Filters the legacy contextual help list. + * + * @since 2.7.0 + * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or + * get_current_screen()->remove_help_tab() instead. + * + * @param array $old_compat_help Old contextual help. + * @param WP_Screen $this Current WP_Screen instance. + */ + self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this ); + + $old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : ''; + + /** + * Filters the legacy contextual help text. + * + * @since 2.7.0 + * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or + * get_current_screen()->remove_help_tab() instead. + * + * @param string $old_help Help text that appears on the screen. + * @param string $screen_id Screen ID. + * @param WP_Screen $this Current WP_Screen instance. + * + */ + $old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this ); + + // Default help only if there is no old-style block of text and no new-style help tabs. + if ( empty( $old_help ) && ! $this->get_help_tabs() ) { + + /** + * Filters the default legacy contextual help text. + * + * @since 2.8.0 + * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or + * get_current_screen()->remove_help_tab() instead. + * + * @param string $old_help_default Default contextual help text. + */ + $default_help = apply_filters( 'default_contextual_help', '' ); + if ( $default_help ) + $old_help = '

    ' . $default_help . '

    '; + } + + if ( $old_help ) { + $this->add_help_tab( array( + 'id' => 'old-contextual-help', + 'title' => __('Overview'), + 'content' => $old_help, + ) ); + } + + $help_sidebar = $this->get_help_sidebar(); + + $help_class = 'hidden'; + if ( ! $help_sidebar ) + $help_class .= ' no-sidebar'; + + // Time to render! + ?> +
    + +
    +
    +
    +
    +
      + get_help_tabs() as $tab ) : + $link_id = "tab-link-{$tab['id']}"; + $panel_id = "tab-panel-{$tab['id']}"; + ?> + + + +
    +
    + + +
    + +
    + + +
    + get_help_tabs() as $tab ): + $panel_id = "tab-panel-{$tab['id']}"; + ?> + +
    + +
    + +
    +
    +
    + id, $this ); + + if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) + $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); + + if ( $this->get_option( 'layout_columns' ) ) { + $this->columns = (int) get_user_option("screen_layout_$this->id"); + + if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) + $this->columns = $this->get_option( 'layout_columns', 'default' ); + } + $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. + + // Add screen options + if ( $this->show_screen_options() ) + $this->render_screen_options(); + ?> +
    + get_help_tabs() && ! $this->show_screen_options() ) + return; + ?> + + _show_screen_options ) ) + return $this->_show_screen_options; + + $columns = get_column_headers( $this ); + + $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); + + switch ( $this->base ) { + case 'widgets': + $nonce = wp_create_nonce( 'widgets-access' ); + $this->_screen_settings = '

    ' . __('Enable accessibility mode') . '' . __('Disable accessibility mode') . "

    \n"; + break; + case 'post' : + $expand = ''; + $this->_screen_settings = $expand; + break; + default: + $this->_screen_settings = ''; + break; + } + + /** + * Filters the screen settings text displayed in the Screen Options tab. + * + * This filter is currently only used on the Widgets screen to enable + * accessibility mode. + * + * @since 3.0.0 + * + * @param string $screen_settings Screen settings. + * @param WP_Screen $this WP_Screen object. + */ + $this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this ); + + if ( $this->_screen_settings || $this->_options ) + $show_screen = true; + + /** + * Filters whether to show the Screen Options tab. + * + * @since 3.2.0 + * + * @param bool $show_screen Whether to show Screen Options tab. + * Default true. + * @param WP_Screen $this Current WP_Screen instance. + */ + $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); + return $this->_show_screen_options; + } + + /** + * Render the screen options tab. + * + * @since 3.3.0 + * + * @param array $options { + * @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true. + * } + */ + public function render_screen_options( $options = array() ) { + $options = wp_parse_args( $options, array( + 'wrap' => true, + ) ); + + $wrapper_start = $wrapper_end = $form_start = $form_end = ''; + + // Output optional wrapper. + if ( $options['wrap'] ) { + $wrapper_start = ''; + } + + // Don't output the form and nonce for the widgets accessibility mode links. + if ( 'widgets' !== $this->base ) { + $form_start = "\n
    \n"; + $form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n
    \n"; + } + + echo $wrapper_start . $form_start; + + $this->render_meta_boxes_preferences(); + $this->render_list_table_columns_preferences(); + $this->render_screen_layout(); + $this->render_per_page_options(); + $this->render_view_mode(); + echo $this->_screen_settings; + + /** + * Filters whether to show the Screen Options submit button. + * + * @since 4.4.0 + * + * @param bool $show_button Whether to show Screen Options submit button. + * Default false. + * @param WP_Screen $this Current WP_Screen instance. + */ + $show_button = apply_filters( 'screen_options_show_submit', false, $this ); + + if ( $show_button ) { + submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true ); + } + + echo $form_end . $wrapper_end; + } + + /** + * Render the meta boxes preferences. + * + * @since 4.4.0 + * + * @global array $wp_meta_boxes + */ + public function render_meta_boxes_preferences() { + global $wp_meta_boxes; + + if ( ! isset( $wp_meta_boxes[ $this->id ] ) ) { + return; + } + ?> +
    + + id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { + if ( isset( $_GET['welcome'] ) ) { + $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; + update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); + } else { + $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); + if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) { + $welcome_checked = false; + } + } + echo '\n"; + } + ?> +
    + +
    + + $title ) { + // Can't hide these for they are special + if ( in_array( $column, $special ) ) { + continue; + } + + if ( empty( $title ) ) { + continue; + } + + /* + * The Comments column uses HTML in the display name with some screen + * reader text. Make sure to strip tags from the Comments column + * title and any other custom column title plugins might add. + */ + $title = wp_strip_all_tags( $title ); + + $id = "$column-hide"; + echo '\n"; + } + ?> +
    + get_option( 'layout_columns' ) ) { + return; + } + + $screen_layout_columns = $this->get_columns(); + $num = $this->get_option( 'layout_columns', 'max' ); + + ?> +
    + + + +
    + get_option( 'per_page' ) ) { + return; + } + + $per_page_label = $this->get_option( 'per_page', 'label' ); + if ( null === $per_page_label ) { + $per_page_label = __( 'Number of items per page:' ); + } + + $option = $this->get_option( 'per_page', 'option' ); + if ( ! $option ) { + $option = str_replace( '-', '_', "{$this->id}_per_page" ); + } + + $per_page = (int) get_user_option( $option ); + if ( empty( $per_page ) || $per_page < 1 ) { + $per_page = $this->get_option( 'per_page', 'default' ); + if ( ! $per_page ) { + $per_page = 20; + } + } + + if ( 'edit_comments_per_page' == $option ) { + $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; + + /** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */ + $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status ); + } elseif ( 'categories_per_page' == $option ) { + /** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */ + $per_page = apply_filters( 'edit_categories_per_page', $per_page ); + } else { + /** This filter is documented in wp-admin/includes/class-wp-list-table.php */ + $per_page = apply_filters( "{$option}", $per_page ); + } + + // Back compat + if ( isset( $this->post_type ) ) { + /** This filter is documented in wp-admin/includes/post.php */ + $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); + } + + // This needs a submit button + add_filter( 'screen_options_show_submit', '__return_true' ); + + ?> +
    + + + + + + +
    + base ) { + return; + } + + $view_mode_post_types = get_post_types( array( 'hierarchical' => false, 'show_ui' => true ) ); + + /** + * Filters the post types that have different view mode options. + * + * @since 4.4.0 + * + * @param array $view_mode_post_types Array of post types that can change view modes. + * Default non-hierarchical post types with show_ui on. + */ + $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types ); + + if ( ! in_array( $this->post_type, $view_mode_post_types ) ) { + return; + } + + global $mode; + + // This needs a submit button + add_filter( 'screen_options_show_submit', '__return_true' ); +?> +
    + + + +
    +_screen_reader_content[ $key ] ) ) { + return; + } + echo "<$tag class='screen-reader-text'>" . $this->_screen_reader_content[ $key ] . ""; + } +} diff --git a/backend/wp-admin/includes/class-wp-site-icon.php b/backend/wp-admin/includes/class-wp-site-icon.php new file mode 100644 index 0000000..518ebf4 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-site-icon.php @@ -0,0 +1,233 @@ +ID ); + $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); + + $size = @getimagesize( $cropped ); + $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; + + $object = array( + 'ID' => $parent_attachment_id, + 'post_title' => basename( $cropped ), + 'post_content' => $url, + 'post_mime_type' => $image_type, + 'guid' => $url, + 'context' => 'site-icon' + ); + + return $object; + } + + /** + * Inserts an attachment. + * + * @since 4.3.0 + * + * @param array $object Attachment object. + * @param string $file File path of the attached image. + * @return int Attachment ID + */ + public function insert_attachment( $object, $file ) { + $attachment_id = wp_insert_attachment( $object, $file ); + $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); + + /** + * Filters the site icon attachment metadata. + * + * @since 4.3.0 + * + * @see wp_generate_attachment_metadata() + * + * @param array $metadata Attachment metadata. + */ + $metadata = apply_filters( 'site_icon_attachment_metadata', $metadata ); + wp_update_attachment_metadata( $attachment_id, $metadata ); + + return $attachment_id; + } + + /** + * Adds additional sizes to be made when creating the site_icon images. + * + * @since 4.3.0 + * + * @param array $sizes List of additional sizes. + * @return array Additional image sizes. + */ + public function additional_sizes( $sizes = array() ) { + $only_crop_sizes = array(); + + /** + * Filters the different dimensions that a site icon is saved in. + * + * @since 4.3.0 + * + * @param array $site_icon_sizes Sizes available for the Site Icon. + */ + $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); + + // Use a natural sort of numbers. + natsort( $this->site_icon_sizes ); + $this->site_icon_sizes = array_reverse( $this->site_icon_sizes ); + + // ensure that we only resize the image into + foreach ( $sizes as $name => $size_array ) { + if ( isset( $size_array['crop'] ) ) { + $only_crop_sizes[ $name ] = $size_array; + } + } + + foreach ( $this->site_icon_sizes as $size ) { + if ( $size < $this->min_size ) { + $only_crop_sizes[ 'site_icon-' . $size ] = array( + 'width ' => $size, + 'height' => $size, + 'crop' => true, + ); + } + } + + return $only_crop_sizes; + } + + /** + * Adds Site Icon sizes to the array of image sizes on demand. + * + * @since 4.3.0 + * + * @param array $sizes List of image sizes. + * @return array List of intermediate image sizes. + */ + public function intermediate_image_sizes( $sizes = array() ) { + /** This filter is documented in wp-admin/includes/class-wp-site-icon.php */ + $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); + foreach ( $this->site_icon_sizes as $size ) { + $sizes[] = 'site_icon-' . $size; + } + + return $sizes; + } + + /** + * Deletes the Site Icon when the image file is deleted. + * + * @since 4.3.0 + * + * @param int $post_id Attachment ID. + */ + public function delete_attachment_data( $post_id ) { + $site_icon_id = get_option( 'site_icon' ); + + if ( $site_icon_id && $post_id == $site_icon_id ) { + delete_option( 'site_icon' ); + } + } + + /** + * Adds custom image sizes when meta data for an image is requested, that happens to be used as Site Icon. + * + * @since 4.3.0 + * + * @param null|array|string $value The value get_metadata() should return a single metadata value, or an + * array of values. + * @param int $post_id Post ID. + * @param string $meta_key Meta key. + * @param string|array $single Meta value, or an array of values. + * @return array|null|string The attachment metadata value, array of values, or null. + */ + public function get_post_metadata( $value, $post_id, $meta_key, $single ) { + if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) { + $site_icon_id = get_option( 'site_icon' ); + + if ( $post_id == $site_icon_id ) { + add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); + } + } + + return $value; + } +} diff --git a/backend/wp-admin/includes/class-wp-terms-list-table.php b/backend/wp-admin/includes/class-wp-terms-list-table.php new file mode 100644 index 0000000..cb2b169 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-terms-list-table.php @@ -0,0 +1,635 @@ + 'tags', + 'singular' => 'tag', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + + $action = $this->screen->action; + $post_type = $this->screen->post_type; + $taxonomy = $this->screen->taxonomy; + + if ( empty( $taxonomy ) ) + $taxonomy = 'post_tag'; + + if ( ! taxonomy_exists( $taxonomy ) ) + wp_die( __( 'Invalid taxonomy.' ) ); + + $tax = get_taxonomy( $taxonomy ); + + // @todo Still needed? Maybe just the show_ui part. + if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) + $post_type = 'post'; + + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); + } + + /** + */ + public function prepare_items() { + $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); + + if ( 'post_tag' === $this->screen->taxonomy ) { + /** + * Filters the number of terms displayed per page for the Tags list table. + * + * @since 2.8.0 + * + * @param int $tags_per_page Number of tags to be displayed. Default 20. + */ + $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); + + /** + * Filters the number of terms displayed per page for the Tags list table. + * + * @since 2.7.0 + * @deprecated 2.8.0 Use edit_tags_per_page instead. + * + * @param int $tags_per_page Number of tags to be displayed. Default 20. + */ + $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); + } elseif ( 'category' === $this->screen->taxonomy ) { + /** + * Filters the number of terms displayed per page for the Categories list table. + * + * @since 2.8.0 + * + * @param int $tags_per_page Number of categories to be displayed. Default 20. + */ + $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); + } + + $search = !empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; + + $args = array( + 'search' => $search, + 'page' => $this->get_pagenum(), + 'number' => $tags_per_page, + ); + + if ( !empty( $_REQUEST['orderby'] ) ) + $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); + + if ( !empty( $_REQUEST['order'] ) ) + $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); + + $this->callback_args = $args; + + $this->set_pagination_args( array( + 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), + 'per_page' => $tags_per_page, + ) ); + } + + /** + * + * @return bool + */ + public function has_items() { + // todo: populate $this->items in prepare_items() + return true; + } + + /** + */ + public function no_items() { + echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; + } + + /** + * + * @return array + */ + protected function get_bulk_actions() { + $actions = array(); + + if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) { + $actions['delete'] = __( 'Delete' ); + } + + return $actions; + } + + /** + * + * @return string + */ + public function current_action() { + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) + return 'bulk-delete'; + + return parent::current_action(); + } + + /** + * + * @return array + */ + public function get_columns() { + $columns = array( + 'cb' => '', + 'name' => _x( 'Name', 'term name' ), + 'description' => __( 'Description' ), + 'slug' => __( 'Slug' ), + ); + + if ( 'link_category' === $this->screen->taxonomy ) { + $columns['links'] = __( 'Links' ); + } else { + $columns['posts'] = _x( 'Count', 'Number/count of items' ); + } + + return $columns; + } + + /** + * + * @return array + */ + protected function get_sortable_columns() { + return array( + 'name' => 'name', + 'description' => 'description', + 'slug' => 'slug', + 'posts' => 'count', + 'links' => 'count' + ); + } + + /** + */ + public function display_rows_or_placeholder() { + $taxonomy = $this->screen->taxonomy; + + $args = wp_parse_args( $this->callback_args, array( + 'page' => 1, + 'number' => 20, + 'search' => '', + 'hide_empty' => 0 + ) ); + + $page = $args['page']; + + // Set variable because $args['number'] can be subsequently overridden. + $number = $args['number']; + + $args['offset'] = $offset = ( $page - 1 ) * $number; + + // Convert it to table rows. + $count = 0; + + if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { + // We'll need the full set of terms then. + $args['number'] = $args['offset'] = 0; + } + $terms = get_terms( $taxonomy, $args ); + + if ( empty( $terms ) || ! is_array( $terms ) ) { + echo ''; + $this->no_items(); + echo ''; + return; + } + + if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { + if ( ! empty( $args['search'] ) ) {// Ignore children on searches. + $children = array(); + } else { + $children = _get_term_hierarchy( $taxonomy ); + } + // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake + $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); + } else { + foreach ( $terms as $term ) { + $this->single_row( $term ); + } + } + } + + /** + * @param string $taxonomy + * @param array $terms + * @param array $children + * @param int $start + * @param int $per_page + * @param int $count + * @param int $parent + * @param int $level + */ + private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { + + $end = $start + $per_page; + + foreach ( $terms as $key => $term ) { + + if ( $count >= $end ) + break; + + if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) + continue; + + // If the page starts in a subtree, print the parents. + if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { + $my_parents = $parent_ids = array(); + $p = $term->parent; + while ( $p ) { + $my_parent = get_term( $p, $taxonomy ); + $my_parents[] = $my_parent; + $p = $my_parent->parent; + if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. + break; + $parent_ids[] = $p; + } + unset( $parent_ids ); + + $num_parents = count( $my_parents ); + while ( $my_parent = array_pop( $my_parents ) ) { + echo "\t"; + $this->single_row( $my_parent, $level - $num_parents ); + $num_parents--; + } + } + + if ( $count >= $start ) { + echo "\t"; + $this->single_row( $term, $level ); + } + + ++$count; + + unset( $terms[$key] ); + + if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) + $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); + } + } + + /** + * @global string $taxonomy + * @param WP_Term $tag Term object. + * @param int $level + */ + public function single_row( $tag, $level = 0 ) { + global $taxonomy; + $tag = sanitize_term( $tag, $taxonomy ); + + $this->level = $level; + + echo ''; + $this->single_row_columns( $tag ); + echo ''; + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_cb( $tag ) { + if ( current_user_can( 'delete_term', $tag->term_id ) ) { + return '' + . ''; + } + + return ' '; + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_name( $tag ) { + $taxonomy = $this->screen->taxonomy; + + $pad = str_repeat( '— ', max( 0, $this->level ) ); + + /** + * Filters display of the term name in the terms list table. + * + * The default output may include padding due to the term's + * current level in the term hierarchy. + * + * @since 2.5.0 + * + * @see WP_Terms_List_Table::column_name() + * + * @param string $pad_tag_name The term name, padded if not top-level. + * @param WP_Term $tag Term object. + */ + $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); + + $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); + + $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; + + $edit_link = add_query_arg( + 'wp_http_referer', + urlencode( wp_unslash( $uri ) ), + get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) + ); + + $out = sprintf( + '%s
    ', + esc_url( $edit_link ), + /* translators: %s: taxonomy term name */ + esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), + $name + ); + + $out .= ''; + + return $out; + } + + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, 'name'. + */ + protected function get_default_primary_column_name() { + return 'name'; + } + + /** + * Generates and displays row action links. + * + * @since 4.3.0 + * + * @param WP_Term $tag Tag being acted upon. + * @param string $column_name Current column name. + * @param string $primary Primary column name. + * @return string Row actions output for terms. + */ + protected function handle_row_actions( $tag, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return ''; + } + + $taxonomy = $this->screen->taxonomy; + $tax = get_taxonomy( $taxonomy ); + $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; + + $edit_link = add_query_arg( + 'wp_http_referer', + urlencode( wp_unslash( $uri ) ), + get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) + ); + + $actions = array(); + if ( current_user_can( 'edit_term', $tag->term_id ) ) { + $actions['edit'] = sprintf( + '%s', + esc_url( $edit_link ), + /* translators: %s: taxonomy term name */ + esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), + __( 'Edit' ) + ); + $actions['inline hide-if-no-js'] = sprintf( + '%s', + /* translators: %s: taxonomy term name */ + esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), + __( 'Quick Edit' ) + ); + } + if ( current_user_can( 'delete_term', $tag->term_id ) ) { + $actions['delete'] = sprintf( + '%s', + wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), + /* translators: %s: taxonomy term name */ + esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), + __( 'Delete' ) + ); + } + if ( $tax->public ) { + $actions['view'] = sprintf( + '%s', + get_term_link( $tag ), + /* translators: %s: taxonomy term name */ + esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), + __( 'View' ) + ); + } + + /** + * Filters the action links displayed for each term in the Tags list table. + * + * @since 2.8.0 + * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. + * + * @param array $actions An array of action links to be displayed. Default + * 'Edit', 'Quick Edit', 'Delete', and 'View'. + * @param WP_Term $tag Term object. + */ + $actions = apply_filters( 'tag_row_actions', $actions, $tag ); + + /** + * Filters the action links displayed for each term in the terms list table. + * + * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. + * + * @since 3.0.0 + * + * @param array $actions An array of action links to be displayed. Default + * 'Edit', 'Quick Edit', 'Delete', and 'View'. + * @param WP_Term $tag Term object. + */ + $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); + + return $this->row_actions( $actions ); + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_description( $tag ) { + if ( $tag->description ) { + return $tag->description; + } else { + return '' . __( 'No description' ) . ''; + } + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_slug( $tag ) { + /** This filter is documented in wp-admin/edit-tag-form.php */ + return apply_filters( 'editable_slug', $tag->slug, $tag ); + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_posts( $tag ) { + $count = number_format_i18n( $tag->count ); + + $tax = get_taxonomy( $this->screen->taxonomy ); + + $ptype_object = get_post_type_object( $this->screen->post_type ); + if ( ! $ptype_object->show_ui ) + return $count; + + if ( $tax->query_var ) { + $args = array( $tax->query_var => $tag->slug ); + } else { + $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); + } + + if ( 'post' != $this->screen->post_type ) + $args['post_type'] = $this->screen->post_type; + + if ( 'attachment' === $this->screen->post_type ) + return "$count"; + + return "$count"; + } + + /** + * @param WP_Term $tag Term object. + * @return string + */ + public function column_links( $tag ) { + $count = number_format_i18n( $tag->count ); + if ( $count ) + $count = "$count"; + return $count; + } + + /** + * @param WP_Term $tag Term object. + * @param string $column_name + * @return string + */ + public function column_default( $tag, $column_name ) { + /** + * Filters the displayed columns in the terms list table. + * + * The dynamic portion of the hook name, `$this->screen->taxonomy`, + * refers to the slug of the current taxonomy. + * + * @since 2.8.0 + * + * @param string $string Blank string. + * @param string $column_name Name of the column. + * @param int $term_id Term ID. + */ + return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); + } + + /** + * Outputs the hidden row displayed when inline editing + * + * @since 3.1.0 + */ + public function inline_edit() { + $tax = get_taxonomy( $this->screen->taxonomy ); + + if ( ! current_user_can( $tax->cap->edit_terms ) ) + return; +?> + +
    + +
    + features = $_REQUEST['features']; + + $paged = $this->get_pagenum(); + + $per_page = 36; + + // These are the tabs which are shown on the page, + $tabs = array(); + $tabs['dashboard'] = __( 'Search' ); + if ( 'search' === $tab ) + $tabs['search'] = __( 'Search Results' ); + $tabs['upload'] = __( 'Upload' ); + $tabs['featured'] = _x( 'Featured', 'themes' ); + //$tabs['popular'] = _x( 'Popular', 'themes' ); + $tabs['new'] = _x( 'Latest', 'themes' ); + $tabs['updated'] = _x( 'Recently Updated', 'themes' ); + + $nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item. + + /** This filter is documented in wp-admin/theme-install.php */ + $tabs = apply_filters( 'install_themes_tabs', $tabs ); + + /** + * Filters tabs not associated with a menu item on the Install Themes screen. + * + * @since 2.8.0 + * + * @param array $nonmenu_tabs The tabs that don't have a menu item on + * the Install Themes screen. + */ + $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); + + // If a non-valid menu tab has been selected, And it's not a non-menu action. + if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) + $tab = key( $tabs ); + + $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults ); + + switch ( $tab ) { + case 'search': + $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; + switch ( $type ) { + case 'tag': + $args['tag'] = array_map( 'sanitize_key', $search_terms ); + break; + case 'term': + $args['search'] = $search_string; + break; + case 'author': + $args['author'] = $search_string; + break; + } + + if ( ! empty( $this->features ) ) { + $args['tag'] = $this->features; + $_REQUEST['s'] = implode( ',', $this->features ); + $_REQUEST['type'] = 'tag'; + } + + add_action( 'install_themes_table_header', 'install_theme_search_form', 10, 0 ); + break; + + case 'featured': + // case 'popular': + case 'new': + case 'updated': + $args['browse'] = $tab; + break; + + default: + $args = false; + break; + } + + /** + * Filters API request arguments for each Install Themes screen tab. + * + * The dynamic portion of the hook name, `$tab`, refers to the theme install + * tabs. Default tabs are 'dashboard', 'search', 'upload', 'featured', + * 'new', and 'updated'. + * + * @since 3.7.0 + * + * @param array $args An array of themes API arguments. + */ + $args = apply_filters( "install_themes_table_api_args_{$tab}", $args ); + + if ( ! $args ) + return; + + $api = themes_api( 'query_themes', $args ); + + if ( is_wp_error( $api ) ) + wp_die( $api->get_error_message() . '

    ' . __( 'Try again' ) . '' ); + + $this->items = $api->themes; + + $this->set_pagination_args( array( + 'total_items' => $api->info['results'], + 'per_page' => $args['per_page'], + 'infinite_scroll' => true, + ) ); + } + + /** + */ + public function no_items() { + _e( 'No themes match your request.' ); + } + + /** + * + * @global array $tabs + * @global string $tab + * @return array + */ + protected function get_views() { + global $tabs, $tab; + + $display_tabs = array(); + foreach ( (array) $tabs as $action => $text ) { + $current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; + $href = self_admin_url('theme-install.php?tab=' . $action); + $display_tabs['theme-install-'.$action] = "$text"; + } + + return $display_tabs; + } + + /** + */ + public function display() { + wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); +?> +

    +
    + +
    + pagination( 'top' ); ?> +
    +
    + +
    + display_rows_or_placeholder(); ?> +
    + + tablenav( 'bottom' ); + } + + /** + */ + public function display_rows() { + $themes = $this->items; + foreach ( $themes as $theme ) { + ?> +
    single_row( $theme ); + ?>
    + theme_installer(); + } + + /** + * Prints a theme from the WordPress.org API. + * + * @since 3.1.0 + * + * @global array $themes_allowedtags + * + * @param object $theme { + * An object that contains theme data returned by the WordPress.org API. + * + * @type string $name Theme name, e.g. 'Twenty Seventeen'. + * @type string $slug Theme slug, e.g. 'twentyseventeen'. + * @type string $version Theme version, e.g. '1.1'. + * @type string $author Theme author username, e.g. 'melchoyce'. + * @type string $preview_url Preview URL, e.g. 'http://2017.wordpress.net/'. + * @type string $screenshot_url Screenshot URL, e.g. 'https://wordpress.org/themes/twentyseventeen/'. + * @type float $rating Rating score. + * @type int $num_ratings The number of ratings. + * @type string $homepage Theme homepage, e.g. 'https://wordpress.org/themes/twentyseventeen/'. + * @type string $description Theme description. + * @type string $download_link Theme ZIP download URL. + * } + */ + public function single_row( $theme ) { + global $themes_allowedtags; + + if ( empty( $theme ) ) + return; + + $name = wp_kses( $theme->name, $themes_allowedtags ); + $author = wp_kses( $theme->author, $themes_allowedtags ); + + $preview_title = sprintf( __('Preview “%s”'), $name ); + $preview_url = add_query_arg( array( + 'tab' => 'theme-information', + 'theme' => $theme->slug, + ), self_admin_url( 'theme-install.php' ) ); + + $actions = array(); + + $install_url = add_query_arg( array( + 'action' => 'install-theme', + 'theme' => $theme->slug, + ), self_admin_url( 'update.php' ) ); + + $update_url = add_query_arg( array( + 'action' => 'upgrade-theme', + 'theme' => $theme->slug, + ), self_admin_url( 'update.php' ) ); + + $status = $this->_get_theme_status( $theme ); + + switch ( $status ) { + case 'update_available': + $actions[] = '' . __( 'Update' ) . ''; + break; + case 'newer_installed': + case 'latest_installed': + $actions[] = '' . _x( 'Installed', 'theme' ) . ''; + break; + case 'install': + default: + $actions[] = '' . __( 'Install Now' ) . ''; + break; + } + + $actions[] = '' . __( 'Preview' ) . ''; + + /** + * Filters the install action links for a theme in the Install Themes list table. + * + * @since 3.4.0 + * + * @param array $actions An array of theme action hyperlinks. Defaults are + * links to Install Now, Preview, and Details. + * @param WP_Theme $theme Theme object. + */ + $actions = apply_filters( 'theme_install_actions', $actions, $theme ); + + ?> + + + + +

    +
    + + + + install_theme_info( $theme ); + } + + /** + * Prints the wrapper for the theme installer. + */ + public function theme_installer() { + ?> +
    +
    +
    + + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    + install_theme_info( $theme ); ?> +
    +
    + +
    +
    + name, $themes_allowedtags ); + $author = wp_kses( $theme->author, $themes_allowedtags ); + + $install_url = add_query_arg( array( + 'action' => 'install-theme', + 'theme' => $theme->slug, + ), self_admin_url( 'update.php' ) ); + + $update_url = add_query_arg( array( + 'action' => 'upgrade-theme', + 'theme' => $theme->slug, + ), self_admin_url( 'update.php' ) ); + + $status = $this->_get_theme_status( $theme ); + + ?> +
    slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . ''; + break; + case 'newer_installed': + case 'latest_installed': + echo '' . _x( 'Installed', 'theme' ) . ''; + break; + case 'install': + default: + echo '' . __( 'Install' ) . ''; + break; + } ?> +

    + + screenshot_url ) ): ?> + + +
    + $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?> +
    + + version, $themes_allowedtags ); ?> +
    +
    + description, $themes_allowedtags ); ?> +
    +
    + +
    + Install screen + * @global string $type Type of search. + * + * @param array $extra_args Unused. + */ + public function _js_vars( $extra_args = array() ) { + global $tab, $type; + parent::_js_vars( compact( 'tab', 'type' ) ); + } + + /** + * Check to see if the theme is already installed. + * + * @since 3.4.0 + * + * @param object $theme - A WordPress.org Theme API object. + * @return string Theme status. + */ + private function _get_theme_status( $theme ) { + $status = 'install'; + + $installed_theme = wp_get_theme( $theme->slug ); + if ( $installed_theme->exists() ) { + if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) + $status = 'latest_installed'; + elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) + $status = 'newer_installed'; + else + $status = 'update_available'; + } + + return $status; + } +} diff --git a/backend/wp-admin/includes/class-wp-themes-list-table.php b/backend/wp-admin/includes/class-wp-themes-list-table.php new file mode 100644 index 0000000..a0e008d --- /dev/null +++ b/backend/wp-admin/includes/class-wp-themes-list-table.php @@ -0,0 +1,302 @@ + true, + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + } + + /** + * + * @return bool + */ + public function ajax_user_can() { + // Do not check edit_theme_options here. Ajax calls for available themes require switch_themes. + return current_user_can( 'switch_themes' ); + } + + /** + */ + public function prepare_items() { + $themes = wp_get_themes( array( 'allowed' => true ) ); + + if ( ! empty( $_REQUEST['s'] ) ) + $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); + + if ( ! empty( $_REQUEST['features'] ) ) + $this->features = $_REQUEST['features']; + + if ( $this->search_terms || $this->features ) { + foreach ( $themes as $key => $theme ) { + if ( ! $this->search_theme( $theme ) ) + unset( $themes[ $key ] ); + } + } + + unset( $themes[ get_option( 'stylesheet' ) ] ); + WP_Theme::sort_by_name( $themes ); + + $per_page = 36; + $page = $this->get_pagenum(); + + $start = ( $page - 1 ) * $per_page; + + $this->items = array_slice( $themes, $start, $per_page, true ); + + $this->set_pagination_args( array( + 'total_items' => count( $themes ), + 'per_page' => $per_page, + 'infinite_scroll' => true, + ) ); + } + + /** + */ + public function no_items() { + if ( $this->search_terms || $this->features ) { + _e( 'No items found.' ); + return; + } + + $blog_id = get_current_blog_id(); + if ( is_multisite() ) { + if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { + printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to enable or install more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ), network_admin_url( 'theme-install.php' ) ); + + return; + } elseif ( current_user_can( 'manage_network_themes' ) ) { + printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to enable more themes.' ), network_admin_url( 'site-themes.php?id=' . $blog_id ) ); + + return; + } + // Else, fallthrough. install_themes doesn't help if you can't enable it. + } else { + if ( current_user_can( 'install_themes' ) ) { + printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the Install Themes tab above.' ), admin_url( 'theme-install.php' ) ); + + return; + } + } + // Fallthrough. + printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) ); + } + + /** + * @param string $which + */ + public function tablenav( $which = 'top' ) { + if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) + return; + ?> +
    + pagination( $which ); ?> + +
    +
    + + tablenav( 'top' ); ?> + +
    + display_rows_or_placeholder(); ?> +
    + + tablenav( 'bottom' ); ?> +has_items() ) { + $this->display_rows(); + } else { + echo '
    '; + $this->no_items(); + echo '
    '; + } + } + + /** + */ + public function display_rows() { + $themes = $this->items; + + foreach ( $themes as $theme ): + ?>
    get_template(); + $stylesheet = $theme->get_stylesheet(); + $title = $theme->display('Name'); + $version = $theme->display('Version'); + $author = $theme->display('Author'); + + $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); + + $actions = array(); + $actions['activate'] = '' . __( 'Activate' ) . ''; + + if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { + $actions['preview'] .= '' + . __( 'Live Preview' ) . ''; + } + + if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) + $actions['delete'] = '' . __( 'Delete' ) . ''; + + /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ + $actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); + + /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ + $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, 'all' ); + $delete_action = isset( $actions['delete'] ) ? '
    ' . $actions['delete'] . '
    ' : ''; + unset( $actions['delete'] ); + + ?> + + + get_screenshot() ) : ?> + + + + + get_screenshot() ) : ?> + + + + +

    +
    + + +
    +

    +

    display('Description'); ?>

    + parent() ) { + printf( '

    ' . __( 'This child theme requires its parent theme, %2$s.' ) . '

    ', + __( 'https://codex.wordpress.org/Child_Themes' ), + $theme->parent()->display( 'Name' ) ); + } ?> +
    + +
    + features as $word ) { + if ( ! in_array( $word, $theme->get('Tags') ) ) + return false; + } + + // Match all phrases + foreach ( $this->search_terms as $word ) { + if ( in_array( $word, $theme->get('Tags') ) ) + continue; + + foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { + // Don't mark up; Do translate. + if ( false !== stripos( strip_tags( $theme->display( $header, false, true ) ), $word ) ) { + continue 2; + } + } + + if ( false !== stripos( $theme->get_stylesheet(), $word ) ) + continue; + + if ( false !== stripos( $theme->get_template(), $word ) ) + continue; + + return false; + } + + return true; + } + + /** + * Send required variables to JavaScript land + * + * @since 3.4.0 + * + * @param array $extra_args + */ + public function _js_vars( $extra_args = array() ) { + $search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; + + $args = array( + 'search' => $search_string, + 'features' => $this->features, + 'paged' => $this->get_pagenum(), + 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, + ); + + if ( is_array( $extra_args ) ) + $args = array_merge( $args, $extra_args ); + + printf( "\n", wp_json_encode( $args ) ); + parent::_js_vars(); + } +} diff --git a/backend/wp-admin/includes/class-wp-upgrader-skin.php b/backend/wp-admin/includes/class-wp-upgrader-skin.php new file mode 100644 index 0000000..ad4d8de --- /dev/null +++ b/backend/wp-admin/includes/class-wp-upgrader-skin.php @@ -0,0 +1,203 @@ + '', 'nonce' => '', 'title' => '', 'context' => false ); + $this->options = wp_parse_args($args, $defaults); + } + + /** + * + * @param WP_Upgrader $upgrader + */ + public function set_upgrader(&$upgrader) { + if ( is_object($upgrader) ) + $this->upgrader =& $upgrader; + $this->add_strings(); + } + + /** + */ + public function add_strings() { + } + + /** + * Sets the result of an upgrade. + * + * @since 2.8.0 + * + * @param string|bool|WP_Error $result The result of an upgrade. + */ + public function set_result( $result ) { + $this->result = $result; + } + + /** + * Displays a form to the user to request for their FTP/SSH details in order + * to connect to the filesystem. + * + * @since 2.8.0 + * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. + * + * @see request_filesystem_credentials() + * + * @param bool $error Optional. Whether the current request has failed to connect. + * Default false. + * @param string $context Optional. Full path to the directory that is tested + * for being writable. Default empty. + * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. + * @return bool False on failure, true on success. + */ + public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { + $url = $this->options['url']; + if ( ! $context ) { + $context = $this->options['context']; + } + if ( !empty($this->options['nonce']) ) { + $url = wp_nonce_url($url, $this->options['nonce']); + } + + $extra_fields = array(); + + return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership ); + } + + /** + */ + public function header() { + if ( $this->done_header ) { + return; + } + $this->done_header = true; + echo '
    '; + echo '

    ' . $this->options['title'] . '

    '; + } + + /** + */ + public function footer() { + if ( $this->done_footer ) { + return; + } + $this->done_footer = true; + echo '
    '; + } + + /** + * + * @param string|WP_Error $errors + */ + public function error($errors) { + if ( ! $this->done_header ) + $this->header(); + if ( is_string($errors) ) { + $this->feedback($errors); + } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { + foreach ( $errors->get_error_messages() as $message ) { + if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) + $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); + else + $this->feedback($message); + } + } + } + + /** + * + * @param string $string + */ + public function feedback($string) { + if ( isset( $this->upgrader->strings[$string] ) ) + $string = $this->upgrader->strings[$string]; + + if ( strpos($string, '%') !== false ) { + $args = func_get_args(); + $args = array_splice($args, 1); + if ( $args ) { + $args = array_map( 'strip_tags', $args ); + $args = array_map( 'esc_html', $args ); + $string = vsprintf($string, $args); + } + } + if ( empty($string) ) + return; + show_message($string); + } + + /** + */ + public function before() {} + + /** + */ + public function after() {} + + /** + * Output JavaScript that calls function to decrement the update counts. + * + * @since 3.9.0 + * + * @param string $type Type of update count to decrement. Likely values include 'plugin', + * 'theme', 'translation', etc. + */ + protected function decrement_update_count( $type ) { + if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) { + return; + } + + if ( defined( 'IFRAME_REQUEST' ) ) { + echo ''; + } else { + echo ''; + } + } + + /** + */ + public function bulk_header() {} + + /** + */ + public function bulk_footer() {} +} diff --git a/backend/wp-admin/includes/class-wp-upgrader-skins.php b/backend/wp-admin/includes/class-wp-upgrader-skins.php new file mode 100644 index 0000000..183a011 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-upgrader-skins.php @@ -0,0 +1,43 @@ +skin = new WP_Upgrader_Skin(); + else + $this->skin = $skin; + } + + /** + * Initialize the upgrader. + * + * This will set the relationship between the skin being used and this upgrader, + * and also add the generic strings to `WP_Upgrader::$strings`. + * + * @since 2.8.0 + */ + public function init() { + $this->skin->set_upgrader($this); + $this->generic_strings(); + } + + /** + * Add the generic strings to WP_Upgrader::$strings. + * + * @since 2.8.0 + */ + public function generic_strings() { + $this->strings['bad_request'] = __('Invalid data provided.'); + $this->strings['fs_unavailable'] = __('Could not access filesystem.'); + $this->strings['fs_error'] = __('Filesystem error.'); + $this->strings['fs_no_root_dir'] = __('Unable to locate WordPress root directory.'); + $this->strings['fs_no_content_dir'] = __('Unable to locate WordPress content directory (wp-content).'); + $this->strings['fs_no_plugins_dir'] = __('Unable to locate WordPress plugin directory.'); + $this->strings['fs_no_themes_dir'] = __('Unable to locate WordPress theme directory.'); + /* translators: %s: directory name */ + $this->strings['fs_no_folder'] = __('Unable to locate needed folder (%s).'); + + $this->strings['download_failed'] = __('Download failed.'); + $this->strings['installing_package'] = __('Installing the latest version…'); + $this->strings['no_files'] = __('The package contains no files.'); + $this->strings['folder_exists'] = __('Destination folder already exists.'); + $this->strings['mkdir_failed'] = __('Could not create directory.'); + $this->strings['incompatible_archive'] = __('The package could not be installed.'); + $this->strings['files_not_writable'] = __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ); + + $this->strings['maintenance_start'] = __('Enabling Maintenance mode…'); + $this->strings['maintenance_end'] = __('Disabling Maintenance mode…'); + } + + /** + * Connect to the filesystem. + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param array $directories Optional. A list of directories. If any of these do + * not exist, a WP_Error object will be returned. + * Default empty array. + * @param bool $allow_relaxed_file_ownership Whether to allow relaxed file ownership. + * Default false. + * @return bool|WP_Error True if able to connect, false or a WP_Error otherwise. + */ + public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) { + global $wp_filesystem; + + if ( false === ( $credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership ) ) ) { + return false; + } + + if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) { + $error = true; + if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() ) + $error = $wp_filesystem->errors; + // Failed to connect, Error and request again + $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership ); + return false; + } + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', $this->strings['fs_unavailable'] ); + + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors); + + foreach ( (array)$directories as $dir ) { + switch ( $dir ) { + case ABSPATH: + if ( ! $wp_filesystem->abspath() ) + return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']); + break; + case WP_CONTENT_DIR: + if ( ! $wp_filesystem->wp_content_dir() ) + return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']); + break; + case WP_PLUGIN_DIR: + if ( ! $wp_filesystem->wp_plugins_dir() ) + return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']); + break; + case get_theme_root(): + if ( ! $wp_filesystem->wp_themes_dir() ) + return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']); + break; + default: + if ( ! $wp_filesystem->find_folder($dir) ) + return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) ); + break; + } + } + return true; + } //end fs_connect(); + + /** + * Download a package. + * + * @since 2.8.0 + * + * @param string $package The URI of the package. If this is the full path to an + * existing local file, it will be returned untouched. + * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object. + */ + public function download_package( $package ) { + + /** + * Filters whether to return the package. + * + * @since 3.7.0 + * + * @param bool $reply Whether to bail without returning the package. + * Default false. + * @param string $package The package file name. + * @param WP_Upgrader $this The WP_Upgrader instance. + */ + $reply = apply_filters( 'upgrader_pre_download', false, $package, $this ); + if ( false !== $reply ) + return $reply; + + if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote? + return $package; //must be a local file.. + + if ( empty($package) ) + return new WP_Error('no_package', $this->strings['no_package']); + + $this->skin->feedback('downloading_package', $package); + + $download_file = download_url($package); + + if ( is_wp_error($download_file) ) + return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message()); + + return $download_file; + } + + /** + * Unpack a compressed package file. + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $package Full path to the package file. + * @param bool $delete_package Optional. Whether to delete the package file after attempting + * to unpack it. Default true. + * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure. + */ + public function unpack_package( $package, $delete_package = true ) { + global $wp_filesystem; + + $this->skin->feedback('unpack_package'); + + $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/'; + + //Clean up contents of upgrade directory beforehand. + $upgrade_files = $wp_filesystem->dirlist($upgrade_folder); + if ( !empty($upgrade_files) ) { + foreach ( $upgrade_files as $file ) + $wp_filesystem->delete($upgrade_folder . $file['name'], true); + } + + // We need a working directory - Strip off any .tmp or .zip suffixes + $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' ); + + // Clean up working directory + if ( $wp_filesystem->is_dir($working_dir) ) + $wp_filesystem->delete($working_dir, true); + + // Unzip package to working directory + $result = unzip_file( $package, $working_dir ); + + // Once extracted, delete the package if required. + if ( $delete_package ) + unlink($package); + + if ( is_wp_error($result) ) { + $wp_filesystem->delete($working_dir, true); + if ( 'incompatible_archive' == $result->get_error_code() ) { + return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() ); + } + return $result; + } + + return $working_dir; + } + + /** + * Flatten the results of WP_Filesystem::dirlist() for iterating over. + * + * @since 4.9.0 + * @access protected + * + * @param array $nested_files Array of files as returned by WP_Filesystem::dirlist() + * @param string $path Relative path to prepend to child nodes. Optional. + * @return array $files A flattened array of the $nested_files specified. + */ + protected function flatten_dirlist( $nested_files, $path = '' ) { + $files = array(); + + foreach ( $nested_files as $name => $details ) { + $files[ $path . $name ] = $details; + + // Append children recursively + if ( ! empty( $details['files'] ) ) { + $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); + + // Merge keeping possible numeric keys, which array_merge() will reindex from 0..n + $files = $files + $children; + } + } + + return $files; + } + + /** + * Clears the directory where this item is going to be installed into. + * + * @since 4.3.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $remote_destination The location on the remote filesystem to be cleared + * @return bool|WP_Error True upon success, WP_Error on failure. + */ + public function clear_destination( $remote_destination ) { + global $wp_filesystem; + + $files = $wp_filesystem->dirlist( $remote_destination, true, true ); + + // False indicates that the $remote_destination doesn't exist. + if ( false === $files ) { + return true; + } + + // Flatten the file list to iterate over + $files = $this->flatten_dirlist( $files ); + + // Check all files are writable before attempting to clear the destination. + $unwritable_files = array(); + + // Check writability. + foreach ( $files as $filename => $file_details ) { + if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { + // Attempt to alter permissions to allow writes and try again. + $wp_filesystem->chmod( $remote_destination . $filename, ( 'd' == $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) ); + if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) { + $unwritable_files[] = $filename; + } + } + } + + if ( ! empty( $unwritable_files ) ) { + return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) ); + } + + if ( ! $wp_filesystem->delete( $remote_destination, true ) ) { + return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] ); + } + + return true; + } + + /** + * Install a package. + * + * Copies the contents of a package form a source directory, and installs them in + * a destination directory. Optionally removes the source. It can also optionally + * clear out the destination folder if it already exists. + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * @global array $wp_theme_directories + * + * @param array|string $args { + * Optional. Array or string of arguments for installing a package. Default empty array. + * + * @type string $source Required path to the package source. Default empty. + * @type string $destination Required path to a folder to install the package in. + * Default empty. + * @type bool $clear_destination Whether to delete any files already in the destination + * folder. Default false. + * @type bool $clear_working Whether to delete the files form the working directory + * after copying to the destination. Default false. + * @type bool $abort_if_destination_exists Whether to abort the installation if + * the destination folder already exists. Default true. + * @type array $hook_extra Extra arguments to pass to the filter hooks called by + * WP_Upgrader::install_package(). Default empty array. + * } + * + * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure. + */ + public function install_package( $args = array() ) { + global $wp_filesystem, $wp_theme_directories; + + $defaults = array( + 'source' => '', // Please always pass this + 'destination' => '', // and this + 'clear_destination' => false, + 'clear_working' => false, + 'abort_if_destination_exists' => true, + 'hook_extra' => array() + ); + + $args = wp_parse_args($args, $defaults); + + // These were previously extract()'d. + $source = $args['source']; + $destination = $args['destination']; + $clear_destination = $args['clear_destination']; + + @set_time_limit( 300 ); + + if ( empty( $source ) || empty( $destination ) ) { + return new WP_Error( 'bad_request', $this->strings['bad_request'] ); + } + $this->skin->feedback( 'installing_package' ); + + /** + * Filters the install response before the installation has started. + * + * Returning a truthy value, or one that could be evaluated as a WP_Error + * will effectively short-circuit the installation, returning that value + * instead. + * + * @since 2.8.0 + * + * @param bool|WP_Error $response Response. + * @param array $hook_extra Extra arguments passed to hooked filters. + */ + $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] ); + + if ( is_wp_error( $res ) ) { + return $res; + } + + //Retain the Original source and destinations + $remote_source = $args['source']; + $local_destination = $destination; + + $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); + $remote_destination = $wp_filesystem->find_folder( $local_destination ); + + //Locate which directory to copy to the new folder, This is based on the actual folder holding the files. + if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. + $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); + } elseif ( count( $source_files ) == 0 ) { + return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files? + } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename. + $source = trailingslashit( $args['source'] ); + } + + /** + * Filters the source file location for the upgrade package. + * + * @since 2.8.0 + * @since 4.4.0 The $hook_extra parameter became available. + * + * @param string $source File source location. + * @param string $remote_source Remote file source location. + * @param WP_Upgrader $this WP_Upgrader instance. + * @param array $hook_extra Extra arguments passed to hooked filters. + */ + $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] ); + + if ( is_wp_error( $source ) ) { + return $source; + } + + // Has the source location changed? If so, we need a new source_files list. + if ( $source !== $remote_source ) { + $source_files = array_keys( $wp_filesystem->dirlist( $source ) ); + } + + /* + * Protection against deleting files in any important base directories. + * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the + * destination directory (WP_PLUGIN_DIR / wp-content/themes) intending + * to copy the directory into the directory, whilst they pass the source + * as the actual files to copy. + */ + $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' ); + + if ( is_array( $wp_theme_directories ) ) { + $protected_directories = array_merge( $protected_directories, $wp_theme_directories ); + } + + if ( in_array( $destination, $protected_directories ) ) { + $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) ); + $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) ); + } + + if ( $clear_destination ) { + // We're going to clear the destination if there's something there. + $this->skin->feedback('remove_old'); + + $removed = $this->clear_destination( $remote_destination ); + + /** + * Filters whether the upgrader cleared the destination. + * + * @since 2.8.0 + * + * @param mixed $removed Whether the destination was cleared. true on success, WP_Error on failure + * @param string $local_destination The local package destination. + * @param string $remote_destination The remote package destination. + * @param array $hook_extra Extra arguments passed to hooked filters. + */ + $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] ); + + if ( is_wp_error( $removed ) ) { + return $removed; + } + } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists($remote_destination) ) { + //If we're not clearing the destination folder and something exists there already, Bail. + //But first check to see if there are actually any files in the folder. + $_files = $wp_filesystem->dirlist($remote_destination); + if ( ! empty($_files) ) { + $wp_filesystem->delete($remote_source, true); //Clear out the source files. + return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination ); + } + } + + //Create destination if needed + if ( ! $wp_filesystem->exists( $remote_destination ) ) { + if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { + return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination ); + } + } + // Copy new version of item into place. + $result = copy_dir($source, $remote_destination); + if ( is_wp_error($result) ) { + if ( $args['clear_working'] ) { + $wp_filesystem->delete( $remote_source, true ); + } + return $result; + } + + //Clear the Working folder? + if ( $args['clear_working'] ) { + $wp_filesystem->delete( $remote_source, true ); + } + + $destination_name = basename( str_replace($local_destination, '', $destination) ); + if ( '.' == $destination_name ) { + $destination_name = ''; + } + + $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' ); + + /** + * Filters the installation response after the installation has finished. + * + * @since 2.8.0 + * + * @param bool $response Installation response. + * @param array $hook_extra Extra arguments passed to hooked filters. + * @param array $result Installation result data. + */ + $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result ); + + if ( is_wp_error($res) ) { + $this->result = $res; + return $res; + } + + //Bombard the calling function will all the info which we've just used. + return $this->result; + } + + /** + * Run an upgrade/installation. + * + * Attempts to download the package (if it is not a local file), unpack it, and + * install it in the destination folder. + * + * @since 2.8.0 + * + * @param array $options { + * Array or string of arguments for upgrading/installing a package. + * + * @type string $package The full path or URI of the package to install. + * Default empty. + * @type string $destination The full path to the destination folder. + * Default empty. + * @type bool $clear_destination Whether to delete any files already in the + * destination folder. Default false. + * @type bool $clear_working Whether to delete the files form the working + * directory after copying to the destination. + * Default false. + * @type bool $abort_if_destination_exists Whether to abort the installation if the destination + * folder already exists. When true, `$clear_destination` + * should be false. Default true. + * @type bool $is_multi Whether this run is one of multiple upgrade/installation + * actions being performed in bulk. When true, the skin + * WP_Upgrader::header() and WP_Upgrader::footer() + * aren't called. Default false. + * @type array $hook_extra Extra arguments to pass to the filter hooks called by + * WP_Upgrader::run(). + * } + * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error, + * or false if unable to connect to the filesystem. + */ + public function run( $options ) { + + $defaults = array( + 'package' => '', // Please always pass this. + 'destination' => '', // And this + 'clear_destination' => false, + 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please + 'clear_working' => true, + 'is_multi' => false, + 'hook_extra' => array() // Pass any extra $hook_extra args here, this will be passed to any hooked filters. + ); + + $options = wp_parse_args( $options, $defaults ); + + /** + * Filters the package options before running an update. + * + * See also {@see 'upgrader_process_complete'}. + * + * @since 4.3.0 + * + * @param array $options { + * Options used by the upgrader. + * + * @type string $package Package for update. + * @type string $destination Update location. + * @type bool $clear_destination Clear the destination resource. + * @type bool $clear_working Clear the working resource. + * @type bool $abort_if_destination_exists Abort if the Destination directory exists. + * @type bool $is_multi Whether the upgrader is running multiple times. + * @type array $hook_extra { + * Extra hook arguments. + * + * @type string $action Type of action. Default 'update'. + * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. + * @type bool $bulk Whether the update process is a bulk update. Default true. + * @type string $plugin The base plugin path from the plugins directory. + * @type string $theme The stylesheet or template name of the theme. + * @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme', + * or 'core'. + * @type object $language_update The language pack update offer. + * } + * } + */ + $options = apply_filters( 'upgrader_package_options', $options ); + + if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times + $this->skin->header(); + } + + // Connect to the Filesystem first. + $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); + // Mainly for non-connected filesystem. + if ( ! $res ) { + if ( ! $options['is_multi'] ) { + $this->skin->footer(); + } + return false; + } + + $this->skin->before(); + + if ( is_wp_error($res) ) { + $this->skin->error($res); + $this->skin->after(); + if ( ! $options['is_multi'] ) { + $this->skin->footer(); + } + return $res; + } + + /* + * Download the package (Note, This just returns the filename + * of the file if the package is a local file) + */ + $download = $this->download_package( $options['package'] ); + if ( is_wp_error($download) ) { + $this->skin->error($download); + $this->skin->after(); + if ( ! $options['is_multi'] ) { + $this->skin->footer(); + } + return $download; + } + + $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file + + // Unzips the file into a temporary directory. + $working_dir = $this->unpack_package( $download, $delete_package ); + if ( is_wp_error($working_dir) ) { + $this->skin->error($working_dir); + $this->skin->after(); + if ( ! $options['is_multi'] ) { + $this->skin->footer(); + } + return $working_dir; + } + + // With the given options, this installs it to the destination directory. + $result = $this->install_package( array( + 'source' => $working_dir, + 'destination' => $options['destination'], + 'clear_destination' => $options['clear_destination'], + 'abort_if_destination_exists' => $options['abort_if_destination_exists'], + 'clear_working' => $options['clear_working'], + 'hook_extra' => $options['hook_extra'] + ) ); + + $this->skin->set_result($result); + if ( is_wp_error($result) ) { + $this->skin->error($result); + $this->skin->feedback('process_failed'); + } else { + // Installation succeeded. + $this->skin->feedback('process_success'); + } + + $this->skin->after(); + + if ( ! $options['is_multi'] ) { + + /** + * Fires when the upgrader process is complete. + * + * See also {@see 'upgrader_package_options'}. + * + * @since 3.6.0 + * @since 3.7.0 Added to WP_Upgrader::run(). + * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`. + * + * @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a + * Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance. + * @param array $hook_extra { + * Array of bulk item update data. + * + * @type string $action Type of action. Default 'update'. + * @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'. + * @type bool $bulk Whether the update process is a bulk update. Default true. + * @type array $plugins Array of the basename paths of the plugins' main files. + * @type array $themes The theme slugs. + * @type array $translations { + * Array of translations update data. + * + * @type string $language The locale the translation is for. + * @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'. + * @type string $slug Text domain the translation is for. The slug of a theme/plugin or + * 'default' for core translations. + * @type string $version The version of a theme, plugin, or core. + * } + * } + */ + do_action( 'upgrader_process_complete', $this, $options['hook_extra'] ); + + $this->skin->footer(); + } + + return $result; + } + + /** + * Toggle maintenance mode for the site. + * + * Creates/deletes the maintenance file to enable/disable maintenance mode. + * + * @since 2.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param bool $enable True to enable maintenance mode, false to disable. + */ + public function maintenance_mode( $enable = false ) { + global $wp_filesystem; + $file = $wp_filesystem->abspath() . '.maintenance'; + if ( $enable ) { + $this->skin->feedback('maintenance_start'); + // Create maintenance file to signal that we are upgrading + $maintenance_string = ''; + $wp_filesystem->delete($file); + $wp_filesystem->put_contents($file, $maintenance_string, FS_CHMOD_FILE); + } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) { + $this->skin->feedback('maintenance_end'); + $wp_filesystem->delete($file); + } + } + + /** + * Creates a lock using WordPress options. + * + * @since 4.5.0 + * @static + * + * @param string $lock_name The name of this unique lock. + * @param int $release_timeout Optional. The duration in seconds to respect an existing lock. + * Default: 1 hour. + * @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise. + */ + public static function create_lock( $lock_name, $release_timeout = null ) { + global $wpdb; + if ( ! $release_timeout ) { + $release_timeout = HOUR_IN_SECONDS; + } + $lock_option = $lock_name . '.lock'; + + // Try to lock. + $lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) ); + + if ( ! $lock_result ) { + $lock_result = get_option( $lock_option ); + + // If a lock couldn't be created, and there isn't a lock, bail. + if ( ! $lock_result ) { + return false; + } + + // Check to see if the lock is still valid. If it is, bail. + if ( $lock_result > ( time() - $release_timeout ) ) { + return false; + } + + // There must exist an expired lock, clear it and re-gain it. + WP_Upgrader::release_lock( $lock_name ); + + return WP_Upgrader::create_lock( $lock_name, $release_timeout ); + } + + // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. + update_option( $lock_option, time() ); + + return true; + } + + /** + * Releases an upgrader lock. + * + * @since 4.5.0 + * @static + * + * @see WP_Upgrader::create_lock() + * + * @param string $lock_name The name of this unique lock. + * @return bool True if the lock was successfully released. False on failure. + */ + public static function release_lock( $lock_name ) { + return delete_option( $lock_name . '.lock' ); + } + +} + +/** Plugin_Upgrader class */ +require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; + +/** Theme_Upgrader class */ +require_once ABSPATH . 'wp-admin/includes/class-theme-upgrader.php'; + +/** Language_Pack_Upgrader class */ +require_once ABSPATH . 'wp-admin/includes/class-language-pack-upgrader.php'; + +/** Core_Upgrader class */ +require_once ABSPATH . 'wp-admin/includes/class-core-upgrader.php'; + +/** File_Upload_Upgrader class */ +require_once ABSPATH . 'wp-admin/includes/class-file-upload-upgrader.php'; + +/** WP_Automatic_Updater class */ +require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php'; diff --git a/backend/wp-admin/includes/class-wp-users-list-table.php b/backend/wp-admin/includes/class-wp-users-list-table.php new file mode 100644 index 0000000..8dd5793 --- /dev/null +++ b/backend/wp-admin/includes/class-wp-users-list-table.php @@ -0,0 +1,584 @@ + 'user', + 'plural' => 'users', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) ); + + $this->is_site_users = 'site-users-network' === $this->screen->id; + + if ( $this->is_site_users ) + $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; + } + + /** + * Check the current user's permissions. + * + * @since 3.1.0 + * + * @return bool + */ + public function ajax_user_can() { + if ( $this->is_site_users ) + return current_user_can( 'manage_sites' ); + else + return current_user_can( 'list_users' ); + } + + /** + * Prepare the users list for display. + * + * @since 3.1.0 + * + * @global string $role + * @global string $usersearch + */ + public function prepare_items() { + global $role, $usersearch; + + $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; + + $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + + $per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page'; + $users_per_page = $this->get_items_per_page( $per_page ); + + $paged = $this->get_pagenum(); + + if ( 'none' === $role ) { + $args = array( + 'number' => $users_per_page, + 'offset' => ( $paged-1 ) * $users_per_page, + 'include' => wp_get_users_with_no_role( $this->site_id ), + 'search' => $usersearch, + 'fields' => 'all_with_meta' + ); + } else { + $args = array( + 'number' => $users_per_page, + 'offset' => ( $paged-1 ) * $users_per_page, + 'role' => $role, + 'search' => $usersearch, + 'fields' => 'all_with_meta' + ); + } + + if ( '' !== $args['search'] ) + $args['search'] = '*' . $args['search'] . '*'; + + if ( $this->is_site_users ) + $args['blog_id'] = $this->site_id; + + if ( isset( $_REQUEST['orderby'] ) ) + $args['orderby'] = $_REQUEST['orderby']; + + if ( isset( $_REQUEST['order'] ) ) + $args['order'] = $_REQUEST['order']; + + /** + * Filters the query arguments used to retrieve users for the current users list table. + * + * @since 4.4.0 + * + * @param array $args Arguments passed to WP_User_Query to retrieve items for the current + * users list table. + */ + $args = apply_filters( 'users_list_table_query_args', $args ); + + // Query the user IDs for this page + $wp_user_search = new WP_User_Query( $args ); + + $this->items = $wp_user_search->get_results(); + + $this->set_pagination_args( array( + 'total_items' => $wp_user_search->get_total(), + 'per_page' => $users_per_page, + ) ); + } + + /** + * Output 'no users' message. + * + * @since 3.1.0 + */ + public function no_items() { + _e( 'No users found.' ); + } + + /** + * Return an associative array listing all the views that can be used + * with this table. + * + * Provides a list of roles and user count for that role for easy + * Filtersing of the user table. + * + * @since 3.1.0 + * + * @global string $role + * + * @return array An array of HTML links, one for each view. + */ + protected function get_views() { + global $role; + + $wp_roles = wp_roles(); + + if ( $this->is_site_users ) { + $url = 'site-users.php?id=' . $this->site_id; + switch_to_blog( $this->site_id ); + $users_of_blog = count_users( 'time', $this->site_id ); + restore_current_blog(); + } else { + $url = 'users.php'; + $users_of_blog = count_users(); + } + + $total_users = $users_of_blog['total_users']; + $avail_roles =& $users_of_blog['avail_roles']; + unset($users_of_blog); + + $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; + + $role_links = array(); + $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + foreach ( $wp_roles->get_names() as $this_role => $name ) { + if ( !isset($avail_roles[$this_role]) ) + continue; + + $current_link_attributes = ''; + + if ( $this_role === $role ) { + $current_link_attributes = ' class="current" aria-current="page"'; + } + + $name = translate_user_role( $name ); + /* translators: User role name with count */ + $name = sprintf( __('%1$s (%2$s)'), $name, number_format_i18n( $avail_roles[$this_role] ) ); + $role_links[$this_role] = "$name"; + } + + if ( ! empty( $avail_roles['none' ] ) ) { + + $current_link_attributes = ''; + + if ( 'none' === $role ) { + $current_link_attributes = ' class="current" aria-current="page"'; + } + + $name = __( 'No role' ); + /* translators: User role name with count */ + $name = sprintf( __('%1$s (%2$s)'), $name, number_format_i18n( $avail_roles['none' ] ) ); + $role_links['none'] = "$name"; + + } + + return $role_links; + } + + /** + * Retrieve an associative array of bulk actions available on this table. + * + * @since 3.1.0 + * + * @return array Array of bulk actions. + */ + protected function get_bulk_actions() { + $actions = array(); + + if ( is_multisite() ) { + if ( current_user_can( 'remove_users' ) ) + $actions['remove'] = __( 'Remove' ); + } else { + if ( current_user_can( 'delete_users' ) ) + $actions['delete'] = __( 'Delete' ); + } + + return $actions; + } + + /** + * Output the controls to allow user roles to be changed in bulk. + * + * @since 3.1.0 + * + * @param string $which Whether this is being invoked above ("top") + * or below the table ("bottom"). + */ + protected function extra_tablenav( $which ) { + $id = 'bottom' === $which ? 'new_role2' : 'new_role'; + $button_id = 'bottom' === $which ? 'changeit2' : 'changeit'; + ?> +
    + has_items() ) : ?> + + + +
    + '', + 'username' => __( 'Username' ), + 'name' => __( 'Name' ), + 'email' => __( 'Email' ), + 'role' => __( 'Role' ), + 'posts' => __( 'Posts' ) + ); + + if ( $this->is_site_users ) + unset( $c['posts'] ); + + return $c; + } + + /** + * Get a list of sortable columns for the list table. + * + * @since 3.1.0 + * + * @return array Array of sortable columns. + */ + protected function get_sortable_columns() { + $c = array( + 'username' => 'login', + 'email' => 'email', + ); + + return $c; + } + + /** + * Generate the list table rows. + * + * @since 3.1.0 + */ + public function display_rows() { + // Query the post counts for this page + if ( ! $this->is_site_users ) + $post_counts = count_many_users_posts( array_keys( $this->items ) ); + + foreach ( $this->items as $userid => $user_object ) { + echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); + } + } + + /** + * Generate HTML for a single row on the users.php admin panel. + * + * @since 3.1.0 + * @since 4.2.0 The `$style` parameter was deprecated. + * @since 4.4.0 The `$role` parameter was deprecated. + * + * @param WP_User $user_object The current user object. + * @param string $style Deprecated. Not used. + * @param string $role Deprecated. Not used. + * @param int $numposts Optional. Post count to display for this user. Defaults + * to zero, as in, a new user has made zero posts. + * @return string Output for a single row. + */ + public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { + if ( ! ( $user_object instanceof WP_User ) ) { + $user_object = get_userdata( (int) $user_object ); + } + $user_object->filter = 'display'; + $email = $user_object->user_email; + + if ( $this->is_site_users ) + $url = "site-users.php?id={$this->site_id}&"; + else + $url = 'users.php?'; + + $user_roles = $this->get_role_list( $user_object ); + + // Set up the hover actions for this user + $actions = array(); + $checkbox = ''; + $super_admin = ''; + + if ( is_multisite() && current_user_can( 'manage_network_users' ) ) { + if ( in_array( $user_object->user_login, get_super_admins(), true ) ) { + $super_admin = ' — ' . __( 'Super Admin' ); + } + } + + // Check if the user for this row is editable + if ( current_user_can( 'list_users' ) ) { + // Set up the user editing link + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) ); + + if ( current_user_can( 'edit_user', $user_object->ID ) ) { + $edit = "{$user_object->user_login}{$super_admin}
    "; + $actions['edit'] = '' . __( 'Edit' ) . ''; + } else { + $edit = "{$user_object->user_login}{$super_admin}
    "; + } + + if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) + $actions['delete'] = "" . __( 'Delete' ) . ""; + if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) + $actions['remove'] = "" . __( 'Remove' ) . ""; + + // Add a link to the user's author archive, if not empty. + $author_posts_url = get_author_posts_url( $user_object->ID ); + if ( $author_posts_url ) { + $actions['view'] = sprintf( + '%s', + esc_url( $author_posts_url ), + /* translators: %s: author's display name */ + esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ), + __( 'View' ) + ); + } + + /** + * Filters the action links displayed under each user in the Users list table. + * + * @since 2.8.0 + * + * @param array $actions An array of action links to be displayed. + * Default 'Edit', 'Delete' for single site, and + * 'Edit', 'Remove' for Multisite. + * @param WP_User $user_object WP_User object for the currently-listed user. + */ + $actions = apply_filters( 'user_row_actions', $actions, $user_object ); + + // Role classes. + $role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) ); + + // Set up the checkbox ( because the user is editable, otherwise it's empty ) + $checkbox = '' + . ""; + + } else { + $edit = "{$user_object->user_login}{$super_admin}"; + } + $avatar = get_avatar( $user_object->ID, 32 ); + + // Comma-separated list of user roles. + $roles_list = implode( ', ', $user_roles ); + + $r = ""; + + list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); + + foreach ( $columns as $column_name => $column_display_name ) { + $classes = "$column_name column-$column_name"; + if ( $primary === $column_name ) { + $classes .= ' has-row-actions column-primary'; + } + if ( 'posts' === $column_name ) { + $classes .= ' num'; // Special case for that column + } + + if ( in_array( $column_name, $hidden ) ) { + $classes .= ' hidden'; + } + + $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; + + $attributes = "class='$classes' $data"; + + if ( 'cb' === $column_name ) { + $r .= "$checkbox"; + } else { + $r .= ""; + switch ( $column_name ) { + case 'username': + $r .= "$avatar $edit"; + break; + case 'name': + if ( $user_object->first_name && $user_object->last_name ) { + $r .= "$user_object->first_name $user_object->last_name"; + } elseif ( $user_object->first_name ) { + $r .= $user_object->first_name; + } elseif ( $user_object->last_name ) { + $r .= $user_object->last_name; + } else { + $r .= '' . _x( 'Unknown', 'name' ) . ''; + } + break; + case 'email': + $r .= "$email"; + break; + case 'role': + $r .= esc_html( $roles_list ); + break; + case 'posts': + if ( $numposts > 0 ) { + $r .= ""; + $r .= ''; + $r .= '' . sprintf( _n( '%s post by this author', '%s posts by this author', $numposts ), number_format_i18n( $numposts ) ) . ''; + $r .= ''; + } else { + $r .= 0; + } + break; + default: + /** + * Filters the display output of custom columns in the Users list table. + * + * @since 2.8.0 + * + * @param string $output Custom column output. Default empty. + * @param string $column_name Column name. + * @param int $user_id ID of the currently-listed user. + */ + $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); + } + + if ( $primary === $column_name ) { + $r .= $this->row_actions( $actions ); + } + $r .= ""; + } + } + $r .= ''; + + return $r; + } + + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, 'username'. + */ + protected function get_default_primary_column_name() { + return 'username'; + } + + /** + * Returns an array of user roles for a given user object. + * + * @since 4.4.0 + * + * @param WP_User $user_object The WP_User object. + * @return array An array of user roles. + */ + protected function get_role_list( $user_object ) { + $wp_roles = wp_roles(); + + $role_list = array(); + + foreach ( $user_object->roles as $role ) { + if ( isset( $wp_roles->role_names[ $role ] ) ) { + $role_list[ $role ] = translate_user_role( $wp_roles->role_names[ $role ] ); + } + } + + if ( empty( $role_list ) ) { + $role_list['none'] = _x( 'None', 'no user roles' ); + } + + /** + * Filters the returned array of roles for a user. + * + * @since 4.4.0 + * + * @param array $role_list An array of user roles. + * @param WP_User $user_object A WP_User object. + */ + return apply_filters( 'get_role_list', $role_list, $user_object ); + } + +} diff --git a/backend/wp-admin/includes/comment.php b/backend/wp-admin/includes/comment.php new file mode 100644 index 0000000..87e0a25 --- /dev/null +++ b/backend/wp-admin/includes/comment.php @@ -0,0 +1,196 @@ +get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments + WHERE comment_author = %s AND $date_field = %s", + stripslashes( $comment_author ), + stripslashes( $comment_date ) + ) ); +} + +/** + * Update a comment with values provided in $_POST. + * + * @since 2.0.0 + */ +function edit_comment() { + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) + wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); + + if ( isset( $_POST['newcomment_author'] ) ) + $_POST['comment_author'] = $_POST['newcomment_author']; + if ( isset( $_POST['newcomment_author_email'] ) ) + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; + if ( isset( $_POST['newcomment_author_url'] ) ) + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; + if ( isset( $_POST['comment_status'] ) ) + $_POST['comment_approved'] = $_POST['comment_status']; + if ( isset( $_POST['content'] ) ) + $_POST['comment_content'] = $_POST['content']; + if ( isset( $_POST['comment_ID'] ) ) + $_POST['comment_ID'] = (int) $_POST['comment_ID']; + + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + + if ( !empty ( $_POST['edit_date'] ) ) { + $aa = $_POST['aa']; + $mm = $_POST['mm']; + $jj = $_POST['jj']; + $hh = $_POST['hh']; + $mn = $_POST['mn']; + $ss = $_POST['ss']; + $jj = ($jj > 31 ) ? 31 : $jj; + $hh = ($hh > 23 ) ? $hh -24 : $hh; + $mn = ($mn > 59 ) ? $mn -60 : $mn; + $ss = ($ss > 59 ) ? $ss -60 : $ss; + $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; + } + + wp_update_comment( $_POST ); +} + +/** + * Returns a WP_Comment object based on comment ID. + * + * @since 2.0.0 + * + * @param int $id ID of comment to retrieve. + * @return WP_Comment|false Comment if found. False on failure. + */ +function get_comment_to_edit( $id ) { + if ( !$comment = get_comment($id) ) + return false; + + $comment->comment_ID = (int) $comment->comment_ID; + $comment->comment_post_ID = (int) $comment->comment_post_ID; + + $comment->comment_content = format_to_edit( $comment->comment_content ); + /** + * Filters the comment content before editing. + * + * @since 2.0.0 + * + * @param string $comment->comment_content Comment content. + */ + $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); + + $comment->comment_author = format_to_edit( $comment->comment_author ); + $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); + $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); + $comment->comment_author_url = esc_url($comment->comment_author_url); + + return $comment; +} + +/** + * Get the number of pending comments on a post or posts + * + * @since 2.3.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|array $post_id Either a single Post ID or an array of Post IDs + * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs + */ +function get_pending_comments_num( $post_id ) { + global $wpdb; + + $single = false; + if ( !is_array($post_id) ) { + $post_id_array = (array) $post_id; + $single = true; + } else { + $post_id_array = $post_id; + } + $post_id_array = array_map('intval', $post_id_array); + $post_id_in = "'" . implode("', '", $post_id_array) . "'"; + + $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); + + if ( $single ) { + if ( empty($pending) ) + return 0; + else + return absint($pending[0]['num_comments']); + } + + $pending_keyed = array(); + + // Default to zero pending for all posts in request + foreach ( $post_id_array as $id ) + $pending_keyed[$id] = 0; + + if ( !empty($pending) ) + foreach ( $pending as $pend ) + $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); + + return $pending_keyed; +} + +/** + * Add avatars to relevant places in admin, or try to. + * + * @since 2.5.0 + * + * @param string $name User name. + * @return string Avatar with Admin name. + */ +function floated_admin_avatar( $name ) { + $avatar = get_avatar( get_comment(), 32, 'mystery' ); + return "$avatar $name"; +} + +/** + * @since 2.7.0 + */ +function enqueue_comment_hotkeys_js() { + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) + wp_enqueue_script( 'jquery-table-hotkeys' ); +} + +/** + * Display error message at bottom of comments. + * + * @param string $msg Error Message. Assumed to contain HTML and be sanitized. + */ +function comment_footer_die( $msg ) { + echo "

    $msg

    "; + include( ABSPATH . 'wp-admin/admin-footer.php' ); + die; +} \ No newline at end of file diff --git a/backend/wp-admin/includes/continents-cities.php b/backend/wp-admin/includes/continents-cities.php new file mode 100644 index 0000000..2b9d2f2 --- /dev/null +++ b/backend/wp-admin/includes/continents-cities.php @@ -0,0 +1,549 @@ + 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ); + + if ( wp_http_supports( array( 'ssl' ) ) ) { + $url = set_url_scheme( $url, 'https' ); + } + + $response = wp_remote_get( $url, $options ); + + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) + return false; + + $results = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( ! is_array( $results ) ) + return false; + + set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS ); + } + + return $results; +} + +/** + * Retrieve the link to a contributor's WordPress.org profile page. + * + * @access private + * @since 3.2.0 + * + * @param string $display_name The contributor's display name (passed by reference). + * @param string $username The contributor's username. + * @param string $profiles URL to the contributor's WordPress.org profile page. + */ +function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) { + $display_name = '' . esc_html( $display_name ) . ''; +} + +/** + * Retrieve the link to an external library used in WordPress. + * + * @access private + * @since 3.2.0 + * + * @param string $data External library data (passed by reference). + */ +function _wp_credits_build_object_link( &$data ) { + $data = '' . esc_html( $data[0] ) . ''; +} diff --git a/backend/wp-admin/includes/dashboard.php b/backend/wp-admin/includes/dashboard.php new file mode 100644 index 0000000..fa1d2ff --- /dev/null +++ b/backend/wp-admin/includes/dashboard.php @@ -0,0 +1,1621 @@ +cap->create_posts ) ) { + $quick_draft_title = sprintf( '%1$s %2$s', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) ); + wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); + } + + // WordPress Events and News + wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); + + if ( is_network_admin() ) { + + /** + * Fires after core widgets for the Network Admin dashboard have been registered. + * + * @since 3.1.0 + */ + do_action( 'wp_network_dashboard_setup' ); + + /** + * Filters the list of widgets to load for the Network Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ + $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); + } elseif ( is_user_admin() ) { + + /** + * Fires after core widgets for the User Admin dashboard have been registered. + * + * @since 3.1.0 + */ + do_action( 'wp_user_dashboard_setup' ); + + /** + * Filters the list of widgets to load for the User Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ + $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); + } else { + + /** + * Fires after core widgets for the admin dashboard have been registered. + * + * @since 2.5.0 + */ + do_action( 'wp_dashboard_setup' ); + + /** + * Filters the list of widgets to load for the admin dashboard. + * + * @since 2.5.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ + $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); + } + + foreach ( $dashboard_widgets as $widget_id ) { + $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " " . __('View all') . ''; + wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] ); + } + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { + check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); + ob_start(); // hack - but the same hack wp-admin/widgets.php uses + wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); + ob_end_clean(); + wp_redirect( remove_query_arg( 'edit' ) ); + exit; + } + + /** This action is documented in wp-admin/edit-form-advanced.php */ + do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); + + /** This action is documented in wp-admin/edit-form-advanced.php */ + do_action( 'do_meta_boxes', $screen->id, 'side', '' ); +} + +/** + * Adds a new dashboard widget. + * + * @since 2.7.0 + * + * @global array $wp_dashboard_control_callbacks + * + * @param string $widget_id Widget ID (used in the 'id' attribute for the widget). + * @param string $widget_name Title of the widget. + * @param callable $callback Function that fills the widget with the desired content. + * The function should echo its output. + * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null. + * @param array $callback_args Optional. Data that should be set as the $args property of the widget array + * (which is the second parameter passed to your callback). Default null. + */ +function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { + $screen = get_current_screen(); + global $wp_dashboard_control_callbacks; + + $private_callback_args = array( '__widget_basename' => $widget_name ); + + if ( is_null( $callback_args ) ) { + $callback_args = $private_callback_args; + } else if ( is_array( $callback_args ) ) { + $callback_args = array_merge( $callback_args, $private_callback_args ); + } + + if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { + $wp_dashboard_control_callbacks[$widget_id] = $control_callback; + if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { + list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); + $widget_name .= ' ' . __( 'Cancel' ) . ''; + $callback = '_wp_dashboard_control_callback'; + } else { + list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); + $widget_name .= ' ' . __( 'Configure' ) . ''; + } + } + + $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); + + $location = 'normal'; + if ( in_array($widget_id, $side_widgets) ) + $location = 'side'; + + $priority = 'core'; + if ( 'dashboard_browser_nag' === $widget_id ) + $priority = 'high'; + + add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); +} + +/** + * Outputs controls for the current dashboard widget. + * + * @access private + * @since 2.7.0 + * + * @param mixed $dashboard + * @param array $meta_box + */ +function _wp_dashboard_control_callback( $dashboard, $meta_box ) { + echo '
    '; + wp_dashboard_trigger_widget_control( $meta_box['id'] ); + wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); + echo ''; + submit_button( __('Submit') ); + echo '
    '; +} + +/** + * Displays the dashboard. + * + * @since 2.5.0 + */ +function wp_dashboard() { + $screen = get_current_screen(); + $columns = absint( $screen->get_columns() ); + $columns_css = ''; + if ( $columns ) { + $columns_css = " columns-$columns"; + } + +?> +
    +
    + id, 'normal', '' ); ?> +
    +
    + id, 'side', '' ); ?> +
    +
    + id, 'column3', '' ); ?> +
    +
    + id, 'column4', '' ); ?> +
    +
    + + +
    +
      + publish ) { + if ( 'post' == $post_type ) { + $text = _n( '%s Post', '%s Posts', $num_posts->publish ); + } else { + $text = _n( '%s Page', '%s Pages', $num_posts->publish ); + } + $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); + $post_type_object = get_post_type_object( $post_type ); + if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { + printf( '
    • %2$s
    • ', $post_type, $text ); + } else { + printf( '
    • %2$s
    • ', $post_type, $text ); + } + + } + } + // Comments + $num_comm = wp_count_comments(); + if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { + $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); + ?> +
    • + moderated ); + /* translators: %s: number of comments in moderation */ + $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); + /* translators: %s: number of comments in moderation */ + $aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); + ?> +
    • + ' . implode( "\n
    • ", $elements ) . "
    • \n"; + } + + ?> +
    + $content

    "; + } + ?> +
    + +
    + +
    + ' . __( 'Create a New Site' ) . ''; + if ( current_user_can('create_users') ) + $actions['create-user'] = '' . __( 'Create a New User' ) . ''; + + $c_users = get_user_count(); + $c_blogs = get_blog_count(); + + /* translators: %s: number of users on the network */ + $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); + /* translators: %s: number of sites on the network */ + $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); + + /* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */ + $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); + + if ( $actions ) { + echo '
      '; + foreach ( $actions as $class => $action ) { + $actions[ $class ] = "\t
    • $action"; + } + echo implode( " |
    • \n", $actions ) . "\n"; + echo '
    '; + } +?> +
    + +

    + + + + +
    +

    + + + 'submit_users' ) ); ?> +

    +
    + +
    +

    + + + 'submit_sites' ) ); ?> +

    +
    +post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore + $post = get_default_post_to_edit( 'post', true ); + update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + } else { + $post->post_title = ''; // Remove the auto draft title + } + } else { + $post = get_default_post_to_edit( 'post' , true); + $user_id = get_current_user_id(); + // Don't create an option if this is a super admin who does not belong to this site. + if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + } + + $post_ID = (int) $post->ID; +?> + +
    + + +
    + + +
    + + +
    + +
    + + +
    + +

    + + + + + 'save-post' ) ); ?> +
    +

    + +
    + 'post', + 'post_status' => 'draft', + 'author' => get_current_user_id(), + 'posts_per_page' => 4, + 'orderby' => 'modified', + 'order' => 'DESC' + ); + + /** + * Filters the post query arguments for the 'Recent Drafts' dashboard widget. + * + * @since 4.4.0 + * + * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget. + */ + $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args ); + + $drafts = get_posts( $query_args ); + if ( ! $drafts ) { + return; + } + } + + echo '
    '; + if ( count( $drafts ) > 3 ) { + echo '

    ' . __( 'View all drafts' ) . "

    \n"; + } + echo '

    ' . __( 'Your Recent Drafts' ) . "

    \n
      "; + + $drafts = array_slice( $drafts, 0, 3 ); + foreach ( $drafts as $draft ) { + $url = get_edit_post_link( $draft->ID ); + $title = _draft_or_post_title( $draft->ID ); + echo "
    • \n"; + /* translators: %s: post title */ + echo '
      ' . esc_html( $title ) . ''; + echo '
      '; + if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { + echo '

      ' . $the_content . '

      '; + } + echo "
    • \n"; + } + echo "
    \n
    "; +} + +/** + * Outputs a row for the Recent Comments widget. + * + * @access private + * @since 2.7.0 + * + * @global WP_Comment $comment + * + * @param WP_Comment $comment The current comment. + * @param bool $show_date Optional. Whether to display the date. + */ +function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { + $GLOBALS['comment'] = clone $comment; + + if ( $comment->comment_post_ID > 0 ) { + + $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); + $comment_post_url = get_the_permalink( $comment->comment_post_ID ); + $comment_post_link = "$comment_post_title"; + } else { + $comment_post_link = ''; + } + + $actions_string = ''; + if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { + // Pre-order it: Approve | Reply | Edit | Spam | Trash. + $actions = array( + 'approve' => '', 'unapprove' => '', + 'reply' => '', + 'edit' => '', + 'spam' => '', + 'trash' => '', 'delete' => '', + 'view' => '', + ); + + $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); + $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); + + $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); + $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); + $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); + + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['edit'] = "". __( 'Edit' ) . ''; + $actions['reply'] = '' . __( 'Reply' ) . ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + + if ( ! EMPTY_TRASH_DAYS ) { + $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; + } else { + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; + } + + $actions['view'] = '' . __( 'View' ) . ''; + + /** + * Filters the action links displayed for each comment in the 'Recent Comments' + * dashboard widget. + * + * @since 2.6.0 + * + * @param array $actions An array of comment actions. Default actions include: + * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', + * 'Delete', and 'Trash'. + * @param WP_Comment $comment The comment object. + */ + $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); + + $i = 0; + foreach ( $actions as $action => $link ) { + ++$i; + ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + // Reply and quickedit need a hide-if-no-js span + if ( 'reply' == $action || 'quickedit' == $action ) { + $action .= ' hide-if-no-js'; + } + + if ( 'view' === $action && '1' !== $comment->comment_approved ) { + $action .= ' hidden'; + } + $actions_string .= "$sep$link"; + } + } +?> + +
  • > + + + + comment_type || 'comment' == $comment->comment_type ) : ?> + +
    +

    + ' . get_comment_author_link( $comment ) . '', + $comment_post_link, + '' . __( '[Pending]' ) . '' + ); + } else { + printf( + /* translators: 1: comment author, 2: notification if the comment is pending */ + __( 'From %1$s %2$s' ), + '' . get_comment_author_link( $comment ) . '', + '' . __( '[Pending]' ) . '' + ); + } + ?> +

    + + comment_type ) { + case 'pingback' : + $type = __( 'Pingback' ); + break; + case 'trackback' : + $type = __( 'Trackback' ); + break; + default : + $type = ucwords( $comment->comment_type ); + } + $type = esc_html( $type ); + ?> +
    +

    + $type", + $comment_post_link, + '' . __( '[Pending]' ) . '' + ); + } else { + printf( + /* translators: 1: type of comment, 2: notification if the comment is pending */ + _x( '%1$s %2$s', 'dashboard' ), + "$type", + '' . __( '[Pending]' ) . '' + ); + } + ?> +

    +

    + + +

    + +

    + +
    +
  • +'; + + $future_posts = wp_dashboard_recent_posts( array( + 'max' => 5, + 'status' => 'future', + 'order' => 'ASC', + 'title' => __( 'Publishing Soon' ), + 'id' => 'future-posts', + ) ); + $recent_posts = wp_dashboard_recent_posts( array( + 'max' => 5, + 'status' => 'publish', + 'order' => 'DESC', + 'title' => __( 'Recently Published' ), + 'id' => 'published-posts', + ) ); + + $recent_comments = wp_dashboard_recent_comments(); + + if ( !$future_posts && !$recent_posts && !$recent_comments ) { + echo '
    '; + echo ''; + echo '

    ' . __( 'No activity yet!' ) . '

    '; + echo '
    '; + } + + echo '
    '; +} + +/** + * Generates Publishing Soon and Recently Published sections. + * + * @since 3.8.0 + * + * @param array $args { + * An array of query and display arguments. + * + * @type int $max Number of posts to display. + * @type string $status Post status. + * @type string $order Designates ascending ('ASC') or descending ('DESC') order. + * @type string $title Section title. + * @type string $id The container id. + * } + * @return bool False if no posts were found. True otherwise. + */ +function wp_dashboard_recent_posts( $args ) { + $query_args = array( + 'post_type' => 'post', + 'post_status' => $args['status'], + 'orderby' => 'date', + 'order' => $args['order'], + 'posts_per_page' => intval( $args['max'] ), + 'no_found_rows' => true, + 'cache_results' => false, + 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', + ); + + /** + * Filters the query arguments used for the Recent Posts widget. + * + * @since 4.2.0 + * + * @param array $query_args The arguments passed to WP_Query to produce the list of posts. + */ + $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); + $posts = new WP_Query( $query_args ); + + if ( $posts->have_posts() ) { + + echo '
    '; + + echo '

    ' . $args['title'] . '

    '; + + echo '
      '; + + $today = date( 'Y-m-d', current_time( 'timestamp' ) ); + $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); + + while ( $posts->have_posts() ) { + $posts->the_post(); + + $time = get_the_time( 'U' ); + if ( date( 'Y-m-d', $time ) == $today ) { + $relative = __( 'Today' ); + } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { + $relative = __( 'Tomorrow' ); + } elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) { + /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ + $relative = date_i18n( __( 'M jS Y' ), $time ); + } else { + /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */ + $relative = date_i18n( __( 'M jS' ), $time ); + } + + // Use the post edit link for those who can edit, the permalink otherwise. + $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); + + $draft_or_post_title = _draft_or_post_title(); + printf( + '
    • %1$s %4$s
    • ', + /* translators: 1: relative date, 2: time */ + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), + $recent_post_link, + /* translators: %s: post title */ + esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), + $draft_or_post_title + ); + } + + echo '
    '; + echo '
    '; + + } else { + return false; + } + + wp_reset_postdata(); + + return true; +} + +/** + * Show Comments section. + * + * @since 3.8.0 + * + * @param int $total_items Optional. Number of comments to query. Default 5. + * @return bool False if no comments were found. True otherwise. + */ +function wp_dashboard_recent_comments( $total_items = 5 ) { + // Select all comment types and filter out spam later for better query performance. + $comments = array(); + + $comments_query = array( + 'number' => $total_items * 5, + 'offset' => 0 + ); + if ( ! current_user_can( 'edit_posts' ) ) + $comments_query['status'] = 'approve'; + + while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { + if ( ! is_array( $possible ) ) { + break; + } + foreach ( $possible as $comment ) { + if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) + continue; + $comments[] = $comment; + if ( count( $comments ) == $total_items ) + break 2; + } + $comments_query['offset'] += $comments_query['number']; + $comments_query['number'] = $total_items * 10; + } + + if ( $comments ) { + echo '
    '; + echo '

    ' . __( 'Recent Comments' ) . '

    '; + + echo '
      '; + foreach ( $comments as $comment ) + _wp_dashboard_recent_comments_row( $comment ); + echo '
    '; + + if ( current_user_can( 'edit_posts' ) ) { + echo '

    ' . __( 'View more comments' ) . '

    '; + _get_list_table( 'WP_Comments_List_Table' )->views(); + } + + wp_comment_reply( -1, false, 'dashboard', false ); + wp_comment_trashnotice(); + + echo '
    '; + } else { + return false; + } + return true; +} + +/** + * Display generic dashboard RSS widget feed. + * + * @since 2.5.0 + * + * @param string $widget_id + */ +function wp_dashboard_rss_output( $widget_id ) { + $widgets = get_option( 'dashboard_widget_options' ); + echo '
    '; + wp_widget_rss_output( $widgets[ $widget_id ] ); + echo "
    "; +} + +/** + * Checks to see if all of the feed url in $check_urls are cached. + * + * If $check_urls is empty, look for the rss feed url found in the dashboard + * widget options of $widget_id. If cached, call $callback, a function that + * echoes out output for this widget. If not cache, echo a "Loading..." stub + * which is later replaced by Ajax call (see top of /wp-admin/index.php) + * + * @since 2.5.0 + * + * @param string $widget_id + * @param callable $callback + * @param array $check_urls RSS feeds + * @return bool False on failure. True on success. + */ +function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { + $loading = '

    ' . __( 'Loading…' ) . '

    ' . __( 'This widget requires JavaScript.' ) . '

    '; + $doing_ajax = wp_doing_ajax(); + + if ( empty($check_urls) ) { + $widgets = get_option( 'dashboard_widget_options' ); + if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) { + echo $loading; + return false; + } + $check_urls = array( $widgets[$widget_id]['url'] ); + } + + $locale = get_user_locale(); + $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); + if ( false !== ( $output = get_transient( $cache_key ) ) ) { + echo $output; + return true; + } + + if ( ! $doing_ajax ) { + echo $loading; + return false; + } + + if ( $callback && is_callable( $callback ) ) { + $args = array_slice( func_get_args(), 3 ); + array_unshift( $args, $widget_id, $check_urls ); + ob_start(); + call_user_func_array( $callback, $args ); + set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) + } + + return true; +} + +// +// Dashboard Widgets Controls +// + +/** + * Calls widget control callback. + * + * @since 2.5.0 + * + * @global array $wp_dashboard_control_callbacks + * + * @param int $widget_control_id Registered Widget ID. + */ +function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { + global $wp_dashboard_control_callbacks; + + if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) { + call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) ); + } +} + +/** + * The RSS dashboard widget control. + * + * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data + * from RSS-type widgets. + * + * @since 2.5.0 + * + * @param string $widget_id + * @param array $form_inputs + */ +function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { + if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) + $widget_options = array(); + + if ( !isset($widget_options[$widget_id]) ) + $widget_options[$widget_id] = array(); + + $number = 1; // Hack to use wp_widget_rss_form() + $widget_options[$widget_id]['number'] = $number; + + if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { + $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); + $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); + $widget_options[$widget_id]['number'] = $number; + + // Title is optional. If black, fill it if possible. + if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { + $rss = fetch_feed($widget_options[$widget_id]['url']); + if ( is_wp_error($rss) ) { + $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); + } else { + $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); + $rss->__destruct(); + unset($rss); + } + } + update_option( 'dashboard_widget_options', $widget_options ); + $locale = get_user_locale(); + $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); + delete_transient( $cache_key ); + } + + wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); +} + + +/** + * Renders the Events and News dashboard widget. + * + * @since 4.8.0 + */ +function wp_dashboard_events_news() { + wp_print_community_events_markup(); + + ?> + +
    + +
    + + + + + +
    +

    + +

    + + + + +
    + +
    + +
    + + + + + + + + + + + + + + array( + + /** + * Filters the primary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.5.0 + * + * @param string $link The widget's primary link URL. + */ + 'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ), + + /** + * Filters the primary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's primary feed URL. + */ + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), + + /** + * Filters the primary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's primary link. + */ + 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), + 'items' => 1, + 'show_summary' => 0, + 'show_author' => 0, + 'show_date' => 0, + ), + 'planet' => array( + + /** + * Filters the secondary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $link The widget's secondary link URL. + */ + 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), + + /** + * Filters the secondary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's secondary feed URL. + */ + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), + + /** + * Filters the secondary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's secondary link. + */ + 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), + + /** + * Filters the number of secondary link items for the 'WordPress News' dashboard widget. + * + * @since 4.4.0 + * + * @param string $items How many items to show in the secondary feed. + */ + 'items' => apply_filters( 'dashboard_secondary_items', 3 ), + 'show_summary' => 0, + 'show_author' => 0, + 'show_date' => 0, + ) + ); + + wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds ); +} + +/** + * Display the WordPress news feeds. + * + * @since 3.8.0 + * @since 4.8.0 Removed popular plugins feed. + * + * @param string $widget_id Widget ID. + * @param array $feeds Array of RSS feeds. + */ +function wp_dashboard_primary_output( $widget_id, $feeds ) { + foreach ( $feeds as $type => $args ) { + $args['type'] = $type; + echo '
    '; + wp_widget_rss_output( $args['url'], $args ); + echo "
    "; + } +} + +/** + * Display file upload quota on dashboard. + * + * Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now(). + * + * @since 3.0.0 + * + * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. + */ +function wp_dashboard_quota() { + if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) + return true; + + $quota = get_space_allowed(); + $used = get_space_used(); + + if ( $used > $quota ) + $percentused = '100'; + else + $percentused = ( $used / $quota ) * 100; + $used_class = ( $percentused >= 70 ) ? ' warning' : ''; + $used = round( $used, 2 ); + $percentused = number_format( $percentused ); + + ?> +

    +
    +
      +
    • + %2$s (%3$s)', + esc_url( admin_url( 'upload.php' ) ), + $text, + __( 'Manage Uploads' ) + ); ?> +
    • + %2$s (%3$s)', + esc_url( admin_url( 'upload.php' ) ), + $text, + __( 'Manage Uploads' ) + ); ?> +
    • +
    +
    + %s', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) + ); + } else { + /* translators: %s: browser name and link */ + $msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), + sprintf( '%s', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) + ); + } + + $browser_nag_class = ''; + if ( !empty( $response['img_src'] ) ) { + $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; + + $notice .= '
    '; + $browser_nag_class = ' has-browser-icon'; + } + $notice .= "

    {$msg}

    "; + + $browsehappy = 'https://browsehappy.com/'; + $locale = get_user_locale(); + if ( 'en_US' !== $locale ) + $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); + + $notice .= '

    ' . sprintf( __( 'Update %2$s or learn how to browse happy' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '

    '; + $notice .= '

    ' . __( 'Dismiss' ) . '

    '; + $notice .= '
    '; + } + + /** + * Filters the notice output for the 'Browse Happy' nag meta box. + * + * @since 3.2.0 + * + * @param string $notice The notice content. + * @param array $response An array containing web browser information. + */ + echo apply_filters( 'browse-happy-notice', $notice, $response ); +} + +/** + * @since 3.2.0 + * + * @param array $classes + * @return array + */ +function dashboard_browser_nag_class( $classes ) { + $response = wp_check_browser_version(); + + if ( $response && $response['insecure'] ) + $classes[] = 'browser-insecure'; + + return $classes; +} + +/** + * Check if the user needs a browser update + * + * @since 3.2.0 + * + * @return array|bool False on failure, array of browser data on success. + */ +function wp_check_browser_version() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) + return false; + + $key = md5( $_SERVER['HTTP_USER_AGENT'] ); + + if ( false === ($response = get_site_transient('browser_' . $key) ) ) { + // include an unmodified $wp_version + include( ABSPATH . WPINC . '/version.php' ); + + $url = 'http://api.wordpress.org/core/browse-happy/1.1/'; + $options = array( + 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), + 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) + ); + + if ( wp_http_supports( array( 'ssl' ) ) ) { + $url = set_url_scheme( $url, 'https' ); + } + + $response = wp_remote_post( $url, $options ); + + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) + return false; + + /** + * Response should be an array with: + * 'platform' - string - A user-friendly platform name, if it can be determined + * 'name' - string - A user-friendly browser name + * 'version' - string - The version of the browser the user is using + * 'current_version' - string - The most recent version of the browser + * 'upgrade' - boolean - Whether the browser needs an upgrade + * 'insecure' - boolean - Whether the browser is deemed insecure + * 'update_url' - string - The url to visit to upgrade + * 'img_src' - string - An image representing the browser + * 'img_src_ssl' - string - An image (over SSL) representing the browser + */ + $response = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( ! is_array( $response ) ) + return false; + + set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); + } + + return $response; +} + +/** + * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). + */ +function wp_dashboard_empty() {} + +/** + * Displays a welcome panel to introduce users to WordPress. + * + * @since 3.3.0 + */ +function wp_welcome_panel() { + ?> +
    +

    +

    +
    +
    + +

    + + + + true ) ) ) > 1 ) ) : ?> + +

    change your theme completely' ), $themes_link ); ?>

    + +
    +
    +

    +
      + +
    • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>
    • +
    • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
    • + +
    • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>
    • +
    • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
    • +
    • ' . __( 'Add a blog post' ) . '', admin_url( 'post-new.php' ) ); ?>
    • + +
    • ' . __( 'Write your first blog post' ) . '', admin_url( 'post-new.php' ) ); ?>
    • +
    • ' . __( 'Add an About page' ) . '', admin_url( 'post-new.php?post_type=page' ) ); ?>
    • + +
    • ' . __( 'View your site' ) . '', home_url( '/' ) ); ?>
    • +
    +
    +
    +

    +
      + +
    • widgets or menus' ), + admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); + } elseif ( current_theme_supports( 'widgets' ) ) { + echo '' . __( 'Manage widgets' ) . ''; + } else { + echo '' . __( 'Manage menus' ) . ''; + } + ?>
    • + + +
    • ' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>
    • + +
    • ' . __( 'Learn more about getting started' ) . '', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?>
    • +
    +
    +
    +
    + 0) ); + + if ( $categories ) { + foreach ( $categories as $category ) { + if ( $currentcat != $category->term_id && $parent == $category->parent) { + $pad = str_repeat( '– ', $level ); + $category->name = esc_html( $category->name ); + echo "\n\t"; + wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); + } + } + } else { + return false; + } +} + +/** + * Register a setting and its sanitization callback + * + * @since 2.7.0 + * @deprecated 3.0.0 Use register_setting() + * @see register_setting() + * + * @param string $option_group A settings group name. Should correspond to a whitelisted option key name. + * Default whitelisted option key names include "general," "discussion," and "reading," among others. + * @param string $option_name The name of an option to sanitize and save. + * @param callable $sanitize_callback A callback function that sanitizes the option's value. + */ +function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'register_setting()' ); + register_setting( $option_group, $option_name, $sanitize_callback ); +} + +/** + * Unregister a setting + * + * @since 2.7.0 + * @deprecated 3.0.0 Use unregister_setting() + * @see unregister_setting() + * + * @param string $option_group + * @param string $option_name + * @param callable $sanitize_callback + */ +function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'unregister_setting()' ); + unregister_setting( $option_group, $option_name, $sanitize_callback ); +} + +/** + * Determines the language to use for CodePress syntax highlighting. + * + * @since 2.8.0 + * @deprecated 3.0.0 + * + * @param string $filename +**/ +function codepress_get_lang( $filename ) { + _deprecated_function( __FUNCTION__, '3.0.0' ); +} + +/** + * Adds JavaScript required to make CodePress work on the theme/plugin editors. + * + * @since 2.8.0 + * @deprecated 3.0.0 +**/ +function codepress_footer_js() { + _deprecated_function( __FUNCTION__, '3.0.0' ); +} + +/** + * Determine whether to use CodePress. + * + * @since 2.8.0 + * @deprecated 3.0.0 +**/ +function use_codepress() { + _deprecated_function( __FUNCTION__, '3.0.0' ); +} + +/** + * Get all user IDs. + * + * @deprecated 3.1.0 Use get_users() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return array List of user IDs. + */ +function get_author_user_ids() { + _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); + + global $wpdb; + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) ); +} + +/** + * Gets author users who can edit posts. + * + * @deprecated 3.1.0 Use get_users() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $user_id User ID. + * @return array|bool List of editable authors. False if no editable users. + */ +function get_editable_authors( $user_id ) { + _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); + + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if ( !$editable ) { + return false; + } else { + $editable = join(',', $editable); + $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" ); + } + + return apply_filters('get_editable_authors', $authors); +} + +/** + * Gets the IDs of any users who can edit posts. + * + * @deprecated 3.1.0 Use get_users() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $user_id User ID. + * @param bool $exclude_zeros Optional. Whether to exclude zeroes. Default true. + * @return array Array of editable user IDs, empty array otherwise. + */ +function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) { + _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); + + global $wpdb; + + if ( ! $user = get_userdata( $user_id ) ) + return array(); + $post_type_obj = get_post_type_object($post_type); + + if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) { + if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros ) + return array($user->ID); + else + return array(); + } + + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key); + if ( $exclude_zeros ) + $query .= " AND meta_value != '0'"; + + return $wpdb->get_col( $query ); +} + +/** + * Gets all users who are not authors. + * + * @deprecated 3.1.0 Use get_users() + * + * @global wpdb $wpdb WordPress database abstraction object. + */ +function get_nonauthor_user_ids() { + _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); + + global $wpdb; + + if ( !is_multisite() ) + $level_key = $wpdb->get_blog_prefix() . 'user_level'; + else + $level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels + + return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); +} + +if ( ! class_exists( 'WP_User_Search', false ) ) : +/** + * WordPress User Search class. + * + * @since 2.1.0 + * @deprecated 3.1.0 Use WP_User_Query + */ +class WP_User_Search { + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var mixed + */ + var $results; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var string + */ + var $search_term; + + /** + * Page number. + * + * @since 2.1.0 + * @access private + * @var int + */ + var $page; + + /** + * Role name that users have. + * + * @since 2.5.0 + * @access private + * @var string + */ + var $role; + + /** + * Raw page number. + * + * @since 2.1.0 + * @access private + * @var int|bool + */ + var $raw_page; + + /** + * Amount of users to display per page. + * + * @since 2.1.0 + * @access public + * @var int + */ + var $users_per_page = 50; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var int + */ + var $first_user; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var int + */ + var $last_user; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var string + */ + var $query_limit; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_orderby; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_from; + + /** + * {@internal Missing Description}} + * + * @since 3.0.0 + * @access private + * @var string + */ + var $query_where; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var int + */ + var $total_users_for_query = 0; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var bool + */ + var $too_many_total_users = false; + + /** + * {@internal Missing Description}} + * + * @since 2.1.0 + * @access private + * @var WP_Error + */ + var $search_errors; + + /** + * {@internal Missing Description}} + * + * @since 2.7.0 + * @access private + * @var string + */ + var $paging_text; + + /** + * PHP5 Constructor - Sets up the object properties. + * + * @since 2.1.0 + * + * @param string $search_term Search terms string. + * @param int $page Optional. Page ID. + * @param string $role Role name. + * @return WP_User_Search + */ + function __construct( $search_term = '', $page = '', $role = '' ) { + _deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' ); + + $this->search_term = wp_unslash( $search_term ); + $this->raw_page = ( '' == $page ) ? false : (int) $page; + $this->page = (int) ( '' == $page ) ? 1 : $page; + $this->role = $role; + + $this->prepare_query(); + $this->query(); + $this->do_paging(); + } + + /** + * PHP4 Constructor - Sets up the object properties. + * + * @since 2.1.0 + * + * @param string $search_term Search terms string. + * @param int $page Optional. Page ID. + * @param string $role Role name. + * @return WP_User_Search + */ + public function WP_User_Search( $search_term = '', $page = '', $role = '' ) { + self::__construct( $search_term, $page, $role ); + } + + /** + * Prepares the user search query (legacy). + * + * @since 2.1.0 + * @access public + */ + public function prepare_query() { + global $wpdb; + $this->first_user = ($this->page - 1) * $this->users_per_page; + + $this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page); + $this->query_orderby = ' ORDER BY user_login'; + + $search_sql = ''; + if ( $this->search_term ) { + $searches = array(); + $search_sql = 'AND ('; + foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) + $searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' ); + $search_sql .= implode(' OR ', $searches); + $search_sql .= ')'; + } + + $this->query_from = " FROM $wpdb->users"; + $this->query_where = " WHERE 1=1 $search_sql"; + + if ( $this->role ) { + $this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id"; + $this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); + } elseif ( is_multisite() ) { + $level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels + $this->query_from .= ", $wpdb->usermeta"; + $this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'"; + } + + do_action_ref_array( 'pre_user_search', array( &$this ) ); + } + + /** + * Executes the user search query. + * + * @since 2.1.0 + * @access public + */ + public function query() { + global $wpdb; + + $this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit); + + if ( $this->results ) + $this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit + else + $this->search_errors = new WP_Error('no_matching_users_found', __('No users found.')); + } + + /** + * Prepares variables for use in templates. + * + * @since 2.1.0 + * @access public + */ + function prepare_vars_for_template_usage() {} + + /** + * Handles paging for the user search query. + * + * @since 2.1.0 + * @access public + */ + public function do_paging() { + if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results + $args = array(); + if ( ! empty($this->search_term) ) + $args['usersearch'] = urlencode($this->search_term); + if ( ! empty($this->role) ) + $args['role'] = urlencode($this->role); + + $this->paging_text = paginate_links( array( + 'total' => ceil($this->total_users_for_query / $this->users_per_page), + 'current' => $this->page, + 'base' => 'users.php?%_%', + 'format' => 'userspage=%#%', + 'add_args' => $args + ) ); + if ( $this->paging_text ) { + $this->paging_text = sprintf( '' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), + number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ), + number_format_i18n( $this->total_users_for_query ), + $this->paging_text + ); + } + } + } + + /** + * Retrieves the user search query results. + * + * @since 2.1.0 + * @access public + * + * @return array + */ + public function get_results() { + return (array) $this->results; + } + + /** + * Displaying paging text. + * + * @see do_paging() Builds paging text. + * + * @since 2.1.0 + * @access public + */ + function page_links() { + echo $this->paging_text; + } + + /** + * Whether paging is enabled. + * + * @see do_paging() Builds paging text. + * + * @since 2.1.0 + * @access public + * + * @return bool + */ + function results_are_paged() { + if ( $this->paging_text ) + return true; + return false; + } + + /** + * Whether there are search terms. + * + * @since 2.1.0 + * @access public + * + * @return bool + */ + function is_search() { + if ( $this->search_term ) + return true; + return false; + } +} +endif; + +/** + * Retrieves editable posts from other users. + * + * @since 2.3.0 + * @deprecated 3.1.0 Use get_posts() + * @see get_posts() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $user_id User ID to not retrieve posts from. + * @param string $type Optional. Post type to retrieve. Accepts 'draft', 'pending' or 'any' (all). + * Default 'any'. + * @return array List of posts from others. + */ +function get_others_unpublished_posts( $user_id, $type = 'any' ) { + _deprecated_function( __FUNCTION__, '3.1.0' ); + + global $wpdb; + + $editable = get_editable_user_ids( $user_id ); + + if ( in_array($type, array('draft', 'pending')) ) + $type_sql = " post_status = '$type' "; + else + $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; + + $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; + + if ( !$editable ) { + $other_unpubs = ''; + } else { + $editable = join(',', $editable); + $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) ); + } + + return apply_filters('get_others_drafts', $other_unpubs); +} + +/** + * Retrieve drafts from other users. + * + * @deprecated 3.1.0 Use get_posts() + * @see get_posts() + * + * @param int $user_id User ID. + * @return array List of drafts from other users. + */ +function get_others_drafts($user_id) { + _deprecated_function( __FUNCTION__, '3.1.0' ); + + return get_others_unpublished_posts($user_id, 'draft'); +} + +/** + * Retrieve pending review posts from other users. + * + * @deprecated 3.1.0 Use get_posts() + * @see get_posts() + * + * @param int $user_id User ID. + * @return array List of posts with pending review post type from other users. + */ +function get_others_pending($user_id) { + _deprecated_function( __FUNCTION__, '3.1.0' ); + + return get_others_unpublished_posts($user_id, 'pending'); +} + +/** + * Output the QuickPress dashboard widget. + * + * @since 3.0.0 + * @deprecated 3.2.0 Use wp_dashboard_quick_press() + * @see wp_dashboard_quick_press() + */ +function wp_dashboard_quick_press_output() { + _deprecated_function( __FUNCTION__, '3.2.0', 'wp_dashboard_quick_press()' ); + wp_dashboard_quick_press(); +} + +/** + * Outputs the TinyMCE editor. + * + * @since 2.7.0 + * @deprecated 3.3.0 Use wp_editor() + * @see wp_editor() + * + * @staticvar int $num + */ +function wp_tiny_mce( $teeny = false, $settings = false ) { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); + + static $num = 1; + + if ( ! class_exists( '_WP_Editors', false ) ) + require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); + + $editor_id = 'content' . $num++; + + $set = array( + 'teeny' => $teeny, + 'tinymce' => $settings ? $settings : true, + 'quicktags' => false + ); + + $set = _WP_Editors::parse_settings($editor_id, $set); + _WP_Editors::editor_settings($editor_id, $set); +} + +/** + * Preloads TinyMCE dialogs. + * + * @deprecated 3.3.0 Use wp_editor() + * @see wp_editor() + */ +function wp_preload_dialogs() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); +} + +/** + * Prints TinyMCE editor JS. + * + * @deprecated 3.3.0 Use wp_editor() + * @see wp_editor() + */ +function wp_print_editor_js() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); +} + +/** + * Handles quicktags. + * + * @deprecated 3.3.0 Use wp_editor() + * @see wp_editor() + */ +function wp_quicktags() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); +} + +/** + * Returns the screen layout options. + * + * @since 2.8.0 + * @deprecated 3.3.0 WP_Screen::render_screen_layout() + * @see WP_Screen::render_screen_layout() + */ +function screen_layout( $screen ) { + _deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_screen_layout()' ); + + $current_screen = get_current_screen(); + + if ( ! $current_screen ) + return ''; + + ob_start(); + $current_screen->render_screen_layout(); + return ob_get_clean(); +} + +/** + * Returns the screen's per-page options. + * + * @since 2.8.0 + * @deprecated 3.3.0 Use WP_Screen::render_per_page_options() + * @see WP_Screen::render_per_page_options() + */ +function screen_options( $screen ) { + _deprecated_function( __FUNCTION__, '3.3.0', '$current_screen->render_per_page_options()' ); + + $current_screen = get_current_screen(); + + if ( ! $current_screen ) + return ''; + + ob_start(); + $current_screen->render_per_page_options(); + return ob_get_clean(); +} + +/** + * Renders the screen's help. + * + * @since 2.7.0 + * @deprecated 3.3.0 Use WP_Screen::render_screen_meta() + * @see WP_Screen::render_screen_meta() + */ +function screen_meta( $screen ) { + $current_screen = get_current_screen(); + $current_screen->render_screen_meta(); +} + +/** + * Favorite actions were deprecated in version 3.2. Use the admin bar instead. + * + * @since 2.7.0 + * @deprecated 3.2.0 Use WP_Admin_Bar + * @see WP_Admin_Bar + */ +function favorite_actions() { + _deprecated_function( __FUNCTION__, '3.2.0', 'WP_Admin_Bar' ); +} + +/** + * Handles uploading an image. + * + * @deprecated 3.3.0 Use wp_media_upload_handler() + * @see wp_media_upload_handler() + * + * @return null|string + */ +function media_upload_image() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' ); + return wp_media_upload_handler(); +} + +/** + * Handles uploading an audio file. + * + * @deprecated 3.3.0 Use wp_media_upload_handler() + * @see wp_media_upload_handler() + * + * @return null|string + */ +function media_upload_audio() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' ); + return wp_media_upload_handler(); +} + +/** + * Handles uploading a video file. + * + * @deprecated 3.3.0 Use wp_media_upload_handler() + * @see wp_media_upload_handler() + * + * @return null|string + */ +function media_upload_video() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' ); + return wp_media_upload_handler(); +} + +/** + * Handles uploading a generic file. + * + * @deprecated 3.3.0 Use wp_media_upload_handler() + * @see wp_media_upload_handler() + * + * @return null|string + */ +function media_upload_file() { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_media_upload_handler()' ); + return wp_media_upload_handler(); +} + +/** + * Handles retrieving the insert-from-URL form for an image. + * + * @deprecated 3.3.0 Use wp_media_insert_url_form() + * @see wp_media_insert_url_form() + * + * @return string + */ +function type_url_form_image() { + _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('image')" ); + return wp_media_insert_url_form( 'image' ); +} + +/** + * Handles retrieving the insert-from-URL form for an audio file. + * + * @deprecated 3.3.0 Use wp_media_insert_url_form() + * @see wp_media_insert_url_form() + * + * @return string + */ +function type_url_form_audio() { + _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('audio')" ); + return wp_media_insert_url_form( 'audio' ); +} + +/** + * Handles retrieving the insert-from-URL form for a video file. + * + * @deprecated 3.3.0 Use wp_media_insert_url_form() + * @see wp_media_insert_url_form() + * + * @return string + */ +function type_url_form_video() { + _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('video')" ); + return wp_media_insert_url_form( 'video' ); +} + +/** + * Handles retrieving the insert-from-URL form for a generic file. + * + * @deprecated 3.3.0 Use wp_media_insert_url_form() + * @see wp_media_insert_url_form() + * + * @return string + */ +function type_url_form_file() { + _deprecated_function( __FUNCTION__, '3.3.0', "wp_media_insert_url_form('file')" ); + return wp_media_insert_url_form( 'file' ); +} + +/** + * Add contextual help text for a page. + * + * Creates an 'Overview' help tab. + * + * @since 2.7.0 + * @deprecated 3.3.0 Use WP_Screen::add_help_tab() + * @see WP_Screen::add_help_tab() + * + * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. + * @param string $help The content of an 'Overview' help tab. + */ +function add_contextual_help( $screen, $help ) { + _deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' ); + + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + WP_Screen::add_old_compat_help( $screen, $help ); +} + +/** + * Get the allowed themes for the current site. + * + * @since 3.0.0 + * @deprecated 3.4.0 Use wp_get_themes() + * @see wp_get_themes() + * + * @return array $themes Array of allowed themes. + */ +function get_allowed_themes() { + _deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'allowed' => true ) )" ); + + $themes = wp_get_themes( array( 'allowed' => true ) ); + + $wp_themes = array(); + foreach ( $themes as $theme ) { + $wp_themes[ $theme->get('Name') ] = $theme; + } + + return $wp_themes; +} + +/** + * Retrieves a list of broken themes. + * + * @since 1.5.0 + * @deprecated 3.4.0 Use wp_get_themes() + * @see wp_get_themes() + * + * @return array + */ +function get_broken_themes() { + _deprecated_function( __FUNCTION__, '3.4.0', "wp_get_themes( array( 'errors' => true )" ); + + $themes = wp_get_themes( array( 'errors' => true ) ); + $broken = array(); + foreach ( $themes as $theme ) { + $name = $theme->get('Name'); + $broken[ $name ] = array( + 'Name' => $name, + 'Title' => $name, + 'Description' => $theme->errors()->get_error_message(), + ); + } + return $broken; +} + +/** + * Retrieves information on the current active theme. + * + * @since 2.0.0 + * @deprecated 3.4.0 Use wp_get_theme() + * @see wp_get_theme() + * + * @return WP_Theme + */ +function current_theme_info() { + _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); + + return wp_get_theme(); +} + +/** + * This was once used to display an 'Insert into Post' button. + * + * Now it is deprecated and stubbed. + * + * @deprecated 3.5.0 + */ +function _insert_into_post_button( $type ) { + _deprecated_function( __FUNCTION__, '3.5.0' ); +} + +/** + * This was once used to display a media button. + * + * Now it is deprecated and stubbed. + * + * @deprecated 3.5.0 + */ +function _media_button($title, $icon, $type, $id) { + _deprecated_function( __FUNCTION__, '3.5.0' ); +} + +/** + * Gets an existing post and format it for editing. + * + * @since 2.0.0 + * @deprecated 3.5.0 Use get_post() + * @see get_post() + * + * @param int $id + * @return object + */ +function get_post_to_edit( $id ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); + + return get_post( $id, OBJECT, 'edit' ); +} + +/** + * Gets the default page information to use. + * + * @since 2.5.0 + * @deprecated 3.5.0 Use get_default_post_to_edit() + * @see get_default_post_to_edit() + * + * @return WP_Post Post object containing all the default post data as attributes + */ +function get_default_page_to_edit() { + _deprecated_function( __FUNCTION__, '3.5.0', "get_default_post_to_edit( 'page' )" ); + + $page = get_default_post_to_edit(); + $page->post_type = 'page'; + return $page; +} + +/** + * This was once used to create a thumbnail from an Image given a maximum side size. + * + * @since 1.2.0 + * @deprecated 3.5.0 Use image_resize() + * @see image_resize() + * + * @param mixed $file Filename of the original image, Or attachment id. + * @param int $max_side Maximum length of a single side for the thumbnail. + * @param mixed $deprecated Never used. + * @return string Thumbnail path on success, Error string on failure. + */ +function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'image_resize()' ); + return apply_filters( 'wp_create_thumbnail', image_resize( $file, $max_side, $max_side ) ); +} + +/** + * This was once used to display a meta box for the nav menu theme locations. + * + * Deprecated in favor of a 'Manage Locations' tab added to nav menus management screen. + * + * @since 3.0.0 + * @deprecated 3.6.0 + */ +function wp_nav_menu_locations_meta_box() { + _deprecated_function( __FUNCTION__, '3.6.0' ); +} + +/** + * This was once used to kick-off the Core Updater. + * + * Deprecated in favor of instantating a Core_Upgrader instance directly, + * and calling the 'upgrade' method. + * + * @since 2.7.0 + * @deprecated 3.7.0 Use Core_Upgrader + * @see Core_Upgrader + */ +function wp_update_core($current, $feedback = '') { + _deprecated_function( __FUNCTION__, '3.7.0', 'new Core_Upgrader();' ); + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + $upgrader = new Core_Upgrader(); + return $upgrader->upgrade($current); + +} + +/** + * This was once used to kick-off the Plugin Updater. + * + * Deprecated in favor of instantating a Plugin_Upgrader instance directly, + * and calling the 'upgrade' method. + * Unused since 2.8.0. + * + * @since 2.5.0 + * @deprecated 3.7.0 Use Plugin_Upgrader + * @see Plugin_Upgrader + */ +function wp_update_plugin($plugin, $feedback = '') { + _deprecated_function( __FUNCTION__, '3.7.0', 'new Plugin_Upgrader();' ); + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + $upgrader = new Plugin_Upgrader(); + return $upgrader->upgrade($plugin); +} + +/** + * This was once used to kick-off the Theme Updater. + * + * Deprecated in favor of instantiating a Theme_Upgrader instance directly, + * and calling the 'upgrade' method. + * Unused since 2.8.0. + * + * @since 2.7.0 + * @deprecated 3.7.0 Use Theme_Upgrader + * @see Theme_Upgrader + */ +function wp_update_theme($theme, $feedback = '') { + _deprecated_function( __FUNCTION__, '3.7.0', 'new Theme_Upgrader();' ); + + if ( !empty($feedback) ) + add_filter('update_feedback', $feedback); + + include( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + $upgrader = new Theme_Upgrader(); + return $upgrader->upgrade($theme); +} + +/** + * This was once used to display attachment links. Now it is deprecated and stubbed. + * + * @since 2.0.0 + * @deprecated 3.7.0 + * + * @param int|bool $id + */ +function the_attachment_links( $id = false ) { + _deprecated_function( __FUNCTION__, '3.7.0' ); +} + +/** + * Displays a screen icon. + * + * @since 2.7.0 + * @deprecated 3.8.0 + */ +function screen_icon() { + _deprecated_function( __FUNCTION__, '3.8.0' ); + echo get_screen_icon(); +} + +/** + * Retrieves the screen icon (no longer used in 3.8+). + * + * @since 3.2.0 + * @deprecated 3.8.0 + * + * @return string An HTML comment explaining that icons are no longer used. + */ +function get_screen_icon() { + _deprecated_function( __FUNCTION__, '3.8.0' ); + return ''; +} + +/** + * Deprecated dashboard widget controls. + * + * @since 2.5.0 + * @deprecated 3.8.0 + */ +function wp_dashboard_incoming_links_output() {} + +/** + * Deprecated dashboard secondary output. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_secondary_output() {} + +/** + * Deprecated dashboard widget controls. + * + * @since 2.7.0 + * @deprecated 3.8.0 + */ +function wp_dashboard_incoming_links() {} + +/** + * Deprecated dashboard incoming links control. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_incoming_links_control() {} + +/** + * Deprecated dashboard plugins control. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_plugins() {} + +/** + * Deprecated dashboard primary control. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_primary_control() {} + +/** + * Deprecated dashboard recent comments control. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_recent_comments_control() {} + +/** + * Deprecated dashboard secondary section. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_secondary() {} + +/** + * Deprecated dashboard secondary control. + * + * @deprecated 3.8.0 + */ +function wp_dashboard_secondary_control() {} + +/** + * Display plugins text for the WordPress news widget. + * + * @since 2.5.0 + * @deprecated 4.8.0 + * + * @param string $rss The RSS feed URL. + * @param array $args Array of arguments for this RSS feed. + */ +function wp_dashboard_plugins_output( $rss, $args = array() ) { + _deprecated_function( __FUNCTION__, '4.8.0' ); + + // Plugin feeds plus link to install them + $popular = fetch_feed( $args['url']['popular'] ); + + if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) { + $plugin_slugs = array_keys( get_plugins() ); + set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS ); + } + + echo '
      '; + + foreach ( array( $popular ) as $feed ) { + if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) + continue; + + $items = $feed->get_items(0, 5); + + // Pick a random, non-installed plugin + while ( true ) { + // Abort this foreach loop iteration if there's no plugins left of this type + if ( 0 == count($items) ) + continue 2; + + $item_key = array_rand($items); + $item = $items[$item_key]; + + list($link, $frag) = explode( '#', $item->get_link() ); + + $link = esc_url($link); + if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) + $slug = $matches[1]; + else { + unset( $items[$item_key] ); + continue; + } + + // Is this random plugin's slug already installed? If so, try again. + reset( $plugin_slugs ); + foreach ( $plugin_slugs as $plugin_slug ) { + if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) { + unset( $items[$item_key] ); + continue 2; + } + } + + // If we get to this point, then the random plugin isn't installed and we can stop the while(). + break; + } + + // Eliminate some common badly formed plugin descriptions + while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) + unset($items[$item_key]); + + if ( !isset($items[$item_key]) ) + continue; + + $raw_title = $item->get_title(); + + $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; + echo '
    • ' . __( 'Popular Plugin' ) . ': ' . esc_html( $raw_title ) . + ' (' . __( 'Install' ) . ')
    • '; + + $feed->__destruct(); + unset( $feed ); + } + + echo '
    '; +} + +/** + * This was once used to move child posts to a new parent. + * + * @since 2.3.0 + * @deprecated 3.9.0 + * @access private + * + * @param int $old_ID + * @param int $new_ID + */ +function _relocate_children( $old_ID, $new_ID ) { + _deprecated_function( __FUNCTION__, '3.9.0' ); +} + +/** + * Add a top-level menu page in the 'objects' section. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @since 2.7.0 + * + * @deprecated 4.5.0 Use add_menu_page() + * @see add_menu_page() + * @global int $_wp_last_object_menu + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @param string $icon_url The url to the icon to be used for this menu. + * @return string The resulting page's hook_suffix. + */ +function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { + _deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' ); + + global $_wp_last_object_menu; + + $_wp_last_object_menu++; + + return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_object_menu); +} + +/** + * Add a top-level menu page in the 'utility' section. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @since 2.7.0 + * + * @deprecated 4.5.0 Use add_menu_page() + * @see add_menu_page() + * @global int $_wp_last_utility_menu + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @param string $icon_url The url to the icon to be used for this menu. + * @return string The resulting page's hook_suffix. + */ +function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { + _deprecated_function( __FUNCTION__, '4.5.0', 'add_menu_page()' ); + + global $_wp_last_utility_menu; + + $_wp_last_utility_menu++; + + return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_utility_menu); +} + +/** + * Disables autocomplete on the 'post' form (Add/Edit Post screens) for WebKit browsers, + * as they disregard the autocomplete setting on the editor textarea. That can break the editor + * when the user navigates to it with the browser's Back button. See #28037 + * + * Replaced with wp_page_reload_on_back_button_js() that also fixes this problem. + * + * @since 4.0.0 + * @deprecated 4.6.0 + * + * @link https://core.trac.wordpress.org/ticket/35852 + * + * @global bool $is_safari + * @global bool $is_chrome + */ +function post_form_autocomplete_off() { + global $is_safari, $is_chrome; + + _deprecated_function( __FUNCTION__, '4.6.0' ); + + if ( $is_safari || $is_chrome ) { + echo ' autocomplete="off"'; + } +} + +/** + * Display JavaScript on the page. + * + * @since 3.5.0 + * @deprecated 4.9.0 + */ +function options_permalink_add_js() { + ?> + + '', + 1 => __( 'Item added.' ), + 2 => __( 'Item deleted.' ), + 3 => __( 'Item updated.' ), + 4 => __( 'Item not added.' ), + 5 => __( 'Item not updated.' ), + 6 => __( 'Items deleted.' ), +); + +$messages['category'] = array( + 0 => '', + 1 => __( 'Category added.' ), + 2 => __( 'Category deleted.' ), + 3 => __( 'Category updated.' ), + 4 => __( 'Category not added.' ), + 5 => __( 'Category not updated.' ), + 6 => __( 'Categories deleted.' ), +); + +$messages['post_tag'] = array( + 0 => '', + 1 => __( 'Tag added.' ), + 2 => __( 'Tag deleted.' ), + 3 => __( 'Tag updated.' ), + 4 => __( 'Tag not added.' ), + 5 => __( 'Tag not updated.' ), + 6 => __( 'Tags deleted.' ), +); + +/** + * Filters the messages displayed when a tag is updated. + * + * @since 3.7.0 + * + * @param array $messages The messages to be displayed. + */ +$messages = apply_filters( 'term_updated_messages', $messages ); + +$message = false; +if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) { + if ( isset( $messages[ $taxonomy ][ $msg ] ) ) { + $message = $messages[ $taxonomy ][ $msg ]; + } elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) { + $message = $messages['_item'][ $msg ]; + } +} \ No newline at end of file diff --git a/backend/wp-admin/includes/export.php b/backend/wp-admin/includes/export.php new file mode 100644 index 0000000..f8d327b --- /dev/null +++ b/backend/wp-admin/includes/export.php @@ -0,0 +1,621 @@ + 'all', 'author' => false, 'category' => false, + 'start_date' => false, 'end_date' => false, 'status' => false, + ); + $args = wp_parse_args( $args, $defaults ); + + /** + * Fires at the beginning of an export, before any headers are sent. + * + * @since 2.3.0 + * + * @param array $args An array of export arguments. + */ + do_action( 'export_wp', $args ); + + $sitename = sanitize_key( get_bloginfo( 'name' ) ); + if ( ! empty( $sitename ) ) { + $sitename .= '.'; + } + $date = date( 'Y-m-d' ); + $wp_filename = $sitename . 'wordpress.' . $date . '.xml'; + /** + * Filters the export filename. + * + * @since 4.4.0 + * + * @param string $wp_filename The name of the file for download. + * @param string $sitename The site name. + * @param string $date Today's date, formatted. + */ + $filename = apply_filters( 'export_wp_filename', $wp_filename, $sitename, $date ); + + header( 'Content-Description: File Transfer' ); + header( 'Content-Disposition: attachment; filename=' . $filename ); + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); + + if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) { + $ptype = get_post_type_object( $args['content'] ); + if ( ! $ptype->can_export ) + $args['content'] = 'post'; + + $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] ); + } else { + $post_types = get_post_types( array( 'can_export' => true ) ); + $esses = array_fill( 0, count($post_types), '%s' ); + $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types ); + } + + if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] ); + else + $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; + + $join = ''; + if ( $args['category'] && 'post' == $args['content'] ) { + if ( $term = term_exists( $args['category'], 'category' ) ) { + $join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)"; + $where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] ); + } + } + + if ( 'post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content'] ) { + if ( $args['author'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] ); + + if ( $args['start_date'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($args['start_date']) ) ); + + if ( $args['end_date'] ) + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) ); + } + + // Grab a snapshot of post IDs, just in case it changes during the export. + $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" ); + + /* + * Get the requested terms ready, empty unless posts filtered by category + * or all content. + */ + $cats = $tags = $terms = array(); + if ( isset( $term ) && $term ) { + $cat = get_term( $term['term_id'], 'category' ); + $cats = array( $cat->term_id => $cat ); + unset( $term, $cat ); + } elseif ( 'all' == $args['content'] ) { + $categories = (array) get_categories( array( 'get' => 'all' ) ); + $tags = (array) get_tags( array( 'get' => 'all' ) ); + + $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) ); + $custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) ); + + // Put categories in order with no child going before its parent. + while ( $cat = array_shift( $categories ) ) { + if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) ) + $cats[$cat->term_id] = $cat; + else + $categories[] = $cat; + } + + // Put terms in order with no child going before its parent. + while ( $t = array_shift( $custom_terms ) ) { + if ( $t->parent == 0 || isset( $terms[$t->parent] ) ) + $terms[$t->term_id] = $t; + else + $custom_terms[] = $t; + } + + unset( $categories, $custom_taxonomies, $custom_terms ); + } + + /** + * Wrap given string in XML CDATA tag. + * + * @since 2.1.0 + * + * @param string $str String to wrap in XML CDATA tag. + * @return string + */ + function wxr_cdata( $str ) { + if ( ! seems_utf8( $str ) ) { + $str = utf8_encode( $str ); + } + // $str = ent2ncr(esc_html($str)); + $str = '', ']]]]>', $str ) . ']]>'; + + return $str; + } + + /** + * Return the URL of the site + * + * @since 2.5.0 + * + * @return string Site URL. + */ + function wxr_site_url() { + // Multisite: the base URL. + if ( is_multisite() ) + return network_home_url(); + // WordPress (single site): the blog URL. + else + return get_bloginfo_rss( 'url' ); + } + + /** + * Output a cat_name XML tag from a given category object + * + * @since 2.1.0 + * + * @param object $category Category Object + */ + function wxr_cat_name( $category ) { + if ( empty( $category->name ) ) + return; + + echo '' . wxr_cdata( $category->name ) . "\n"; + } + + /** + * Output a category_description XML tag from a given category object + * + * @since 2.1.0 + * + * @param object $category Category Object + */ + function wxr_category_description( $category ) { + if ( empty( $category->description ) ) + return; + + echo '' . wxr_cdata( $category->description ) . "\n"; + } + + /** + * Output a tag_name XML tag from a given tag object + * + * @since 2.3.0 + * + * @param object $tag Tag Object + */ + function wxr_tag_name( $tag ) { + if ( empty( $tag->name ) ) + return; + + echo '' . wxr_cdata( $tag->name ) . "\n"; + } + + /** + * Output a tag_description XML tag from a given tag object + * + * @since 2.3.0 + * + * @param object $tag Tag Object + */ + function wxr_tag_description( $tag ) { + if ( empty( $tag->description ) ) + return; + + echo '' . wxr_cdata( $tag->description ) . "\n"; + } + + /** + * Output a term_name XML tag from a given term object + * + * @since 2.9.0 + * + * @param object $term Term Object + */ + function wxr_term_name( $term ) { + if ( empty( $term->name ) ) + return; + + echo '' . wxr_cdata( $term->name ) . "\n"; + } + + /** + * Output a term_description XML tag from a given term object + * + * @since 2.9.0 + * + * @param object $term Term Object + */ + function wxr_term_description( $term ) { + if ( empty( $term->description ) ) + return; + + echo "\t\t" . wxr_cdata( $term->description ) . "\n"; + } + + /** + * Output term meta XML tags for a given term object. + * + * @since 4.6.0 + * + * @param WP_Term $term Term object. + */ + function wxr_term_meta( $term ) { + global $wpdb; + + $termmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) ); + + foreach ( $termmeta as $meta ) { + /** + * Filters whether to selectively skip term meta used for WXR exports. + * + * Returning a truthy value to the filter will skip the current meta + * object from being exported. + * + * @since 4.6.0 + * + * @param bool $skip Whether to skip the current piece of term meta. Default false. + * @param string $meta_key Current meta key. + * @param object $meta Current meta object. + */ + if ( ! apply_filters( 'wxr_export_skip_termmeta', false, $meta->meta_key, $meta ) ) { + printf( "\t\t\n\t\t\t%s\n\t\t\t%s\n\t\t\n", wxr_cdata( $meta->meta_key ), wxr_cdata( $meta->meta_value ) ); + } + } + } + + /** + * Output list of authors with posts + * + * @since 3.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $post_ids Array of post IDs to filter the query by. Optional. + */ + function wxr_authors_list( array $post_ids = null ) { + global $wpdb; + + if ( !empty( $post_ids ) ) { + $post_ids = array_map( 'absint', $post_ids ); + $and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')'; + } else { + $and = ''; + } + + $authors = array(); + $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" ); + foreach ( (array) $results as $result ) + $authors[] = get_userdata( $result->post_author ); + + $authors = array_filter( $authors ); + + foreach ( $authors as $author ) { + echo "\t"; + echo '' . intval( $author->ID ) . ''; + echo '' . wxr_cdata( $author->user_login ) . ''; + echo '' . wxr_cdata( $author->user_email ) . ''; + echo '' . wxr_cdata( $author->display_name ) . ''; + echo '' . wxr_cdata( $author->first_name ) . ''; + echo '' . wxr_cdata( $author->last_name ) . ''; + echo "\n"; + } + } + + /** + * Output all navigation menu terms + * + * @since 3.1.0 + */ + function wxr_nav_menu_terms() { + $nav_menus = wp_get_nav_menus(); + if ( empty( $nav_menus ) || ! is_array( $nav_menus ) ) + return; + + foreach ( $nav_menus as $menu ) { + echo "\t"; + echo '' . intval( $menu->term_id ) . ''; + echo 'nav_menu'; + echo '' . wxr_cdata( $menu->slug ) . ''; + wxr_term_name( $menu ); + echo "\n"; + } + } + + /** + * Output list of taxonomy terms, in XML tag format, associated with a post + * + * @since 2.3.0 + */ + function wxr_post_taxonomy() { + $post = get_post(); + + $taxonomies = get_object_taxonomies( $post->post_type ); + if ( empty( $taxonomies ) ) + return; + $terms = wp_get_object_terms( $post->ID, $taxonomies ); + + foreach ( (array) $terms as $term ) { + echo "\t\ttaxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "\n"; + } + } + + /** + * + * @param bool $return_me + * @param string $meta_key + * @return bool + */ + function wxr_filter_postmeta( $return_me, $meta_key ) { + if ( '_edit_lock' == $meta_key ) + $return_me = true; + return $return_me; + } + add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 ); + + echo '\n"; + + ?> + + + + + + + + + + + + + + + + + + + + + + <?php bloginfo_rss( 'name' ); ?> + + + + + + + + + + + + + term_id ); ?> + slug ); ?> + parent ? $cats[$c->parent]->slug : '' ); ?> + + + + + + term_id ); ?> + slug ); ?> + + + + + + term_id ); ?> + taxonomy ); ?> + slug ); ?> + parent ? $terms[$t->parent]->slug : '' ); ?> + + + + + + + +in_the_loop = true; + + // Fetch 20 posts at a time rather than loading the entire table into memory. + while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) { + $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')'; + $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" ); + + // Begin Loop. + foreach ( $posts as $post ) { + setup_postdata( $post ); + $is_sticky = is_sticky( $post->ID ) ? 1 : 0; +?> + + <?php + /** This filter is documented in wp-includes/feed.php */ + echo apply_filters( 'the_title_rss', $post->post_title ); + ?> + + + + + + post_content ) ); + ?> + post_excerpt ) ); + ?> + ID ); ?> + post_date ); ?> + post_date_gmt ); ?> + comment_status ); ?> + ping_status ); ?> + post_name ); ?> + post_status ); ?> + post_parent ); ?> + menu_order ); ?> + post_type ); ?> + post_password ); ?> + +post_type == 'attachment' ) : ?> + ID ) ); ?> + + +get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); + foreach ( $postmeta as $meta ) : + /** + * Filters whether to selectively skip post meta used for WXR exports. + * + * Returning a truthy value to the filter will skip the current meta + * object from being exported. + * + * @since 3.3.0 + * + * @param bool $skip Whether to skip the current post meta. Default false. + * @param string $meta_key Current meta key. + * @param object $meta Current meta object. + */ + if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) + continue; + ?> + + meta_key ); ?> + meta_value ); ?> + +get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) ); + $comments = array_map( 'get_comment', $_comments ); + foreach ( $comments as $c ) : ?> + + comment_ID ); ?> + comment_author ); ?> + comment_author_email ); ?> + comment_author_url ); ?> + comment_author_IP ); ?> + comment_date ); ?> + comment_date_gmt ); ?> + comment_content ) ?> + comment_approved ); ?> + comment_type ); ?> + comment_parent ); ?> + user_id ); ?> +get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) ); + foreach ( $c_meta as $meta ) : + /** + * Filters whether to selectively skip comment meta used for WXR exports. + * + * Returning a truthy value to the filter will skip the current meta + * object from being exported. + * + * @since 4.0.0 + * + * @param bool $skip Whether to skip the current comment meta. Default false. + * @param string $meta_key Current meta key. + * @param object $meta Current meta object. + */ + if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) { + continue; + } + ?> + + meta_key ); ?> + meta_value ); ?> + + + + + + + + + __( 'Theme Functions' ), + 'header.php' => __( 'Theme Header' ), + 'footer.php' => __( 'Theme Footer' ), + 'sidebar.php' => __( 'Sidebar' ), + 'comments.php' => __( 'Comments' ), + 'searchform.php' => __( 'Search Form' ), + '404.php' => __( '404 Template' ), + 'link.php' => __( 'Links Template' ), + // Archives + 'index.php' => __( 'Main Index Template' ), + 'archive.php' => __( 'Archives' ), + 'author.php' => __( 'Author Template' ), + 'taxonomy.php' => __( 'Taxonomy Template' ), + 'category.php' => __( 'Category Template' ), + 'tag.php' => __( 'Tag Template' ), + 'home.php' => __( 'Posts Page' ), + 'search.php' => __( 'Search Results' ), + 'date.php' => __( 'Date Template' ), + // Content + 'singular.php' => __( 'Singular Template' ), + 'single.php' => __( 'Single Post' ), + 'page.php' => __( 'Single Page' ), + 'front-page.php' => __( 'Homepage' ), + // Attachments + 'attachment.php' => __( 'Attachment Template' ), + 'image.php' => __( 'Image Attachment Template' ), + 'video.php' => __( 'Video Attachment Template' ), + 'audio.php' => __( 'Audio Attachment Template' ), + 'application.php' => __( 'Application Attachment Template' ), + // Embeds + 'embed.php' => __( 'Embed Template' ), + 'embed-404.php' => __( 'Embed 404 Template' ), + 'embed-content.php' => __( 'Embed Content Template' ), + 'header-embed.php' => __( 'Embed Header Template' ), + 'footer-embed.php' => __( 'Embed Footer Template' ), + // Stylesheets + 'style.css' => __( 'Stylesheet' ), + 'editor-style.css' => __( 'Visual Editor Stylesheet' ), + 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), + 'rtl.css' => __( 'RTL Stylesheet' ), + // Other + 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), + '.htaccess' => __( '.htaccess (for rewrite rules )' ), + // Deprecated files + 'wp-layout.css' => __( 'Stylesheet' ), + 'wp-comments.php' => __( 'Comments Template' ), + 'wp-comments-popup.php' => __( 'Popup Comments Template' ), + 'comments-popup.php' => __( 'Popup Comments' ), +); + +/** + * Get the description for standard WordPress theme files and other various standard + * WordPress files + * + * @since 1.5.0 + * + * @global array $wp_file_descriptions Theme file descriptions. + * @global array $allowed_files List of allowed files. + * @param string $file Filesystem path or filename + * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist. + * Appends 'Page Template' to basename of $file if the file is a page template + */ +function get_file_description( $file ) { + global $wp_file_descriptions, $allowed_files; + + $dirname = pathinfo( $file, PATHINFO_DIRNAME ); + + $file_path = $allowed_files[ $file ]; + if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $dirname ) { + return $wp_file_descriptions[ basename( $file ) ]; + } elseif ( file_exists( $file_path ) && is_file( $file_path ) ) { + $template_data = implode( '', file( $file_path ) ); + if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) { + return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) ); + } + } + + return trim( basename( $file ) ); +} + +/** + * Get the absolute filesystem path to the root of the WordPress installation + * + * @since 1.5.0 + * + * @return string Full filesystem path to the root of the WordPress installation + */ +function get_home_path() { + $home = set_url_scheme( get_option( 'home' ), 'http' ); + $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' ); + if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { + $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ + $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); + $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); + $home_path = trailingslashit( $home_path ); + } else { + $home_path = ABSPATH; + } + + return str_replace( '\\', '/', $home_path ); +} + +/** + * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep. + * The depth of the recursiveness can be controlled by the $levels param. + * + * @since 2.6.0 + * @since 4.9.0 Added the `$exclusions` parameter. + * + * @param string $folder Optional. Full path to folder. Default empty. + * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). + * @param array $exclusions Optional. List of folders and files to skip. + * @return bool|array False on failure, Else array of files + */ +function list_files( $folder = '', $levels = 100, $exclusions = array() ) { + if ( empty( $folder ) ) { + return false; + } + + $folder = trailingslashit( $folder ); + + if ( ! $levels ) { + return false; + } + + $files = array(); + + $dir = @opendir( $folder ); + if ( $dir ) { + while ( ( $file = readdir( $dir ) ) !== false ) { + // Skip current and parent folder links. + if ( in_array( $file, array( '.', '..' ), true ) ) { + continue; + } + + // Skip hidden and excluded files. + if ( '.' === $file[0] || in_array( $file, $exclusions, true ) ) { + continue; + } + + if ( is_dir( $folder . $file ) ) { + $files2 = list_files( $folder . $file, $levels - 1 ); + if ( $files2 ) { + $files = array_merge($files, $files2 ); + } else { + $files[] = $folder . $file . '/'; + } + } else { + $files[] = $folder . $file; + } + } + } + @closedir( $dir ); + + return $files; +} + +/** + * Get list of file extensions that are editable in plugins. + * + * @since 4.9.0 + * + * @param string $plugin Plugin. + * @return array File extensions. + */ +function wp_get_plugin_file_editable_extensions( $plugin ) { + + $editable_extensions = array( + 'bash', + 'conf', + 'css', + 'diff', + 'htm', + 'html', + 'http', + 'inc', + 'include', + 'js', + 'json', + 'jsx', + 'less', + 'md', + 'patch', + 'php', + 'php3', + 'php4', + 'php5', + 'php7', + 'phps', + 'phtml', + 'sass', + 'scss', + 'sh', + 'sql', + 'svg', + 'text', + 'txt', + 'xml', + 'yaml', + 'yml', + ); + + /** + * Filters file type extensions editable in the plugin editor. + * + * @since 2.8.0 + * @since 4.9.0 Adds $plugin param. + * + * @param string $plugin Plugin file. + * @param array $editable_extensions An array of editable plugin file extensions. + */ + $editable_extensions = (array) apply_filters( 'editable_extensions', $editable_extensions, $plugin ); + + return $editable_extensions; +} + +/** + * Get list of file extensions that are editable for a given theme. + * + * @param WP_Theme $theme Theme. + * @return array File extensions. + */ +function wp_get_theme_file_editable_extensions( $theme ) { + + $default_types = array( + 'bash', + 'conf', + 'css', + 'diff', + 'htm', + 'html', + 'http', + 'inc', + 'include', + 'js', + 'json', + 'jsx', + 'less', + 'md', + 'patch', + 'php', + 'php3', + 'php4', + 'php5', + 'php7', + 'phps', + 'phtml', + 'sass', + 'scss', + 'sh', + 'sql', + 'svg', + 'text', + 'txt', + 'xml', + 'yaml', + 'yml', + ); + + /** + * Filters the list of file types allowed for editing in the Theme editor. + * + * @since 4.4.0 + * + * @param array $default_types List of file types. Default types include 'php' and 'css'. + * @param WP_Theme $theme The current Theme object. + */ + $file_types = apply_filters( 'wp_theme_editor_filetypes', $default_types, $theme ); + + // Ensure that default types are still there. + return array_unique( array_merge( $file_types, $default_types ) ); +} + +/** + * Print file editor templates (for plugins and themes). + * + * @since 4.9.0 + */ +function wp_print_file_editor_templates() { + ?> + + exists() ) { + return new WP_Error( 'non_existent_theme', __( 'The requested theme does not exist.' ) ); + } + + $real_file = $theme->get_stylesheet_directory() . '/' . $file; + if ( ! wp_verify_nonce( $args['nonce'], 'edit-theme_' . $real_file . $stylesheet ) ) { + return new WP_Error( 'nonce_failure' ); + } + + if ( $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code() ) { + return new WP_Error( + 'theme_no_stylesheet', + __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() + ); + } + + $editable_extensions = wp_get_theme_file_editable_extensions( $theme ); + + $allowed_files = array(); + foreach ( $editable_extensions as $type ) { + switch ( $type ) { + case 'php': + $allowed_files = array_merge( $allowed_files, $theme->get_files( 'php', -1 ) ); + break; + case 'css': + $style_files = $theme->get_files( 'css', -1 ); + $allowed_files['style.css'] = $style_files['style.css']; + $allowed_files = array_merge( $allowed_files, $style_files ); + break; + default: + $allowed_files = array_merge( $allowed_files, $theme->get_files( $type, -1 ) ); + break; + } + } + + // Compare based on relative paths + if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) { + return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) ); + } + + $is_active = ( get_stylesheet() === $stylesheet || get_template() === $stylesheet ); + } else { + return new WP_Error( 'missing_theme_or_plugin' ); + } + + // Ensure file is real. + if ( ! is_file( $real_file ) ) { + return new WP_Error( 'file_does_not_exist', __( 'No such file exists! Double check the name and try again.' ) ); + } + + // Ensure file extension is allowed. + $extension = null; + if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) { + $extension = strtolower( $matches[1] ); + if ( ! in_array( $extension, $editable_extensions, true ) ) { + return new WP_Error( 'illegal_file_type', __( 'Files of this type are not editable.' ) ); + } + } + + $previous_content = file_get_contents( $real_file ); + + if ( ! is_writeable( $real_file ) ) { + return new WP_Error( 'file_not_writable' ); + } + + $f = fopen( $real_file, 'w+' ); + if ( false === $f ) { + return new WP_Error( 'file_not_writable' ); + } + + $written = fwrite( $f, $content ); + fclose( $f ); + if ( false === $written ) { + return new WP_Error( 'unable_to_write', __( 'Unable to write to file.' ) ); + } + if ( 'php' === $extension && function_exists( 'opcache_invalidate' ) ) { + opcache_invalidate( $real_file, true ); + } + + if ( $is_active && 'php' === $extension ) { + + $scrape_key = md5( rand() ); + $transient = 'scrape_key_' . $scrape_key; + $scrape_nonce = strval( rand() ); + set_transient( $transient, $scrape_nonce, 60 ); // It shouldn't take more than 60 seconds to make the two loopback requests. + + $cookies = wp_unslash( $_COOKIE ); + $scrape_params = array( + 'wp_scrape_key' => $scrape_key, + 'wp_scrape_nonce' => $scrape_nonce, + ); + $headers = array( + 'Cache-Control' => 'no-cache', + ); + + // Include Basic auth in loopback requests. + if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) { + $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) ); + } + + // Make sure PHP process doesn't die before loopback requests complete. + @set_time_limit( 300 ); + + // Time to wait for loopback requests to finish. + $timeout = 100; + + $needle_start = "###### wp_scraping_result_start:$scrape_key ######"; + $needle_end = "###### wp_scraping_result_end:$scrape_key ######"; + + // Attempt loopback request to editor to see if user just whitescreened themselves. + if ( $plugin ) { + $url = add_query_arg( compact( 'plugin', 'file' ), admin_url( 'plugin-editor.php' ) ); + } elseif ( isset( $stylesheet ) ) { + $url = add_query_arg( + array( + 'theme' => $stylesheet, + 'file' => $file, + ), + admin_url( 'theme-editor.php' ) + ); + } else { + $url = admin_url(); + } + $url = add_query_arg( $scrape_params, $url ); + $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) ); + $body = wp_remote_retrieve_body( $r ); + $scrape_result_position = strpos( $body, $needle_start ); + + $loopback_request_failure = array( + 'code' => 'loopback_request_failed', + 'message' => __( 'Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.' ), + ); + $json_parse_failure = array( + 'code' => 'json_parse_error', + ); + + $result = null; + if ( false === $scrape_result_position ) { + $result = $loopback_request_failure; + } else { + $error_output = substr( $body, $scrape_result_position + strlen( $needle_start ) ); + $error_output = substr( $error_output, 0, strpos( $error_output, $needle_end ) ); + $result = json_decode( trim( $error_output ), true ); + if ( empty( $result ) ) { + $result = $json_parse_failure; + } + } + + // Try making request to homepage as well to see if visitors have been whitescreened. + if ( true === $result ) { + $url = home_url( '/' ); + $url = add_query_arg( $scrape_params, $url ); + $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) ); + $body = wp_remote_retrieve_body( $r ); + $scrape_result_position = strpos( $body, $needle_start ); + + if ( false === $scrape_result_position ) { + $result = $loopback_request_failure; + } else { + $error_output = substr( $body, $scrape_result_position + strlen( $needle_start ) ); + $error_output = substr( $error_output, 0, strpos( $error_output, $needle_end ) ); + $result = json_decode( trim( $error_output ), true ); + if ( empty( $result ) ) { + $result = $json_parse_failure; + } + } + } + + delete_transient( $transient ); + + if ( true !== $result ) { + + // Roll-back file change. + file_put_contents( $real_file, $previous_content ); + if ( function_exists( 'opcache_invalidate' ) ) { + opcache_invalidate( $real_file, true ); + } + + if ( ! isset( $result['message'] ) ) { + $message = __( 'Something went wrong.' ); + } else { + $message = $result['message']; + unset( $result['message'] ); + } + return new WP_Error( 'php_error', $message, $result ); + } + } + + if ( $theme instanceof WP_Theme ) { + $theme->cache_delete(); + } + + return true; +} + + +/** + * Returns a filename of a Temporary unique file. + * Please note that the calling function must unlink() this itself. + * + * The filename is based off the passed parameter or defaults to the current unix timestamp, + * while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory. + * + * @since 2.6.0 + * + * @param string $filename Optional. Filename to base the Unique file off. Default empty. + * @param string $dir Optional. Directory to store the file in. Default empty. + * @return string a writable filename + */ +function wp_tempnam( $filename = '', $dir = '' ) { + if ( empty( $dir ) ) { + $dir = get_temp_dir(); + } + + if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) { + $filename = time(); + } + + // Use the basename of the given file without the extension as the name for the temporary directory + $temp_filename = basename( $filename ); + $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename ); + + // If the folder is falsey, use its parent directory name instead. + if ( ! $temp_filename ) { + return wp_tempnam( dirname( $filename ), $dir ); + } + + // Suffix some random data to avoid filename conflicts + $temp_filename .= '-' . wp_generate_password( 6, false ); + $temp_filename .= '.tmp'; + $temp_filename = $dir . wp_unique_filename( $dir, $temp_filename ); + + $fp = @fopen( $temp_filename, 'x' ); + if ( ! $fp && is_writable( $dir ) && file_exists( $temp_filename ) ) { + return wp_tempnam( $filename, $dir ); + } + if ( $fp ) { + fclose( $fp ); + } + + return $temp_filename; +} + +/** + * Makes sure that the file that was requested to be edited is allowed to be edited. + * + * Function will die if you are not allowed to edit the file. + * + * @since 1.5.0 + * + * @param string $file File the user is attempting to edit. + * @param array $allowed_files Optional. Array of allowed files to edit, $file must match an entry exactly. + * @return string|null + */ +function validate_file_to_edit( $file, $allowed_files = array() ) { + $code = validate_file( $file, $allowed_files ); + + if (!$code ) + return $file; + + switch ( $code ) { + case 1 : + wp_die( __( 'Sorry, that file cannot be edited.' ) ); + + // case 2 : + // wp_die( __('Sorry, can’t call files with their real path.' )); + + case 3 : + wp_die( __( 'Sorry, that file cannot be edited.' ) ); + } +} + +/** + * Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type, + * and moving the file to the appropriate directory within the uploads directory. + * + * @access private + * @since 4.0.0 + * + * @see wp_handle_upload_error + * + * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file. + * @param array|false $overrides An associative array of names => values to override default variables. Default false. + * @param string $time Time formatted in 'yyyy/mm'. + * @param string $action Expected value for $_POST['action']. + * @return array On success, returns an associative array of file attributes. On failure, returns + * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). + */ +function _wp_handle_upload( &$file, $overrides, $time, $action ) { + // The default error handler. + if ( ! function_exists( 'wp_handle_upload_error' ) ) { + function wp_handle_upload_error( &$file, $message ) { + return array( 'error' => $message ); + } + } + + /** + * Filters the data for a file before it is uploaded to WordPress. + * + * The dynamic portion of the hook name, `$action`, refers to the post action. + * + * @since 2.9.0 as 'wp_handle_upload_prefilter'. + * @since 4.0.0 Converted to a dynamic hook with `$action`. + * + * @param array $file An array of data for a single file. + */ + $file = apply_filters( "{$action}_prefilter", $file ); + + // You may define your own function and pass the name in $overrides['upload_error_handler'] + $upload_error_handler = 'wp_handle_upload_error'; + if ( isset( $overrides['upload_error_handler'] ) ) { + $upload_error_handler = $overrides['upload_error_handler']; + } + + // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully. + if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) { + return call_user_func_array( $upload_error_handler, array( &$file, $file['error'] ) ); + } + + // Install user overrides. Did we mention that this voids your warranty? + + // You may define your own function and pass the name in $overrides['unique_filename_callback'] + $unique_filename_callback = null; + if ( isset( $overrides['unique_filename_callback'] ) ) { + $unique_filename_callback = $overrides['unique_filename_callback']; + } + + /* + * This may not have orignially been intended to be overrideable, + * but historically has been. + */ + if ( isset( $overrides['upload_error_strings'] ) ) { + $upload_error_strings = $overrides['upload_error_strings']; + } else { + // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. + $upload_error_strings = array( + false, + __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ), + __( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' ), + __( 'The uploaded file was only partially uploaded.' ), + __( 'No file was uploaded.' ), + '', + __( 'Missing a temporary folder.' ), + __( 'Failed to write file to disk.' ), + __( 'File upload stopped by extension.' ) + ); + } + + // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; + $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true; + $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true; + + // If you override this, you must provide $ext and $type!! + $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; + $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false; + + // A correct form post will pass this test. + if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) { + return call_user_func_array( $upload_error_handler, array( &$file, __( 'Invalid form submission.' ) ) ); + } + // A successful upload will pass this test. It makes no sense to override this one. + if ( isset( $file['error'] ) && $file['error'] > 0 ) { + return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) ); + } + + $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] ); + // A non-empty file will pass this test. + if ( $test_size && ! ( $test_file_size > 0 ) ) { + if ( is_multisite() ) { + $error_msg = __( 'File is empty. Please upload something more substantial.' ); + } else { + $error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); + } + return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) ); + } + + // A properly uploaded file will pass this test. There should be no reason to override this one. + $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] ); + if ( ! $test_uploaded_file ) { + return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) ); + } + + // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. + if ( $test_type ) { + $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes ); + $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; + $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; + $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; + + // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect + if ( $proper_filename ) { + $file['name'] = $proper_filename; + } + if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) { + return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) ); + } + if ( ! $type ) { + $type = $file['type']; + } + } else { + $type = ''; + } + + /* + * A writable uploads dir will pass this test. Again, there's no point + * overriding this one. + */ + if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) { + return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) ); + } + + $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); + + // Move the file to the uploads dir. + $new_file = $uploads['path'] . "/$filename"; + + /** + * Filters whether to short-circuit moving the uploaded file after passing all checks. + * + * If a non-null value is passed to the filter, moving the file and any related error + * reporting will be completely skipped. + * + * @since 4.9.0 + * + * @param string $move_new_file If null (default) move the file after the upload. + * @param string $file An array of data for a single file. + * @param string $new_file Filename of the newly-uploaded file. + * @param string $type File type. + */ + $move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type ); + + if ( null === $move_new_file ) { + if ( 'wp_handle_upload' === $action ) { + $move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file ); + } else { + // use copy and unlink because rename breaks streams. + $move_new_file = @ copy( $file['tmp_name'], $new_file ); + unlink( $file['tmp_name'] ); + } + + if ( false === $move_new_file ) { + if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { + $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; + } else { + $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; + } + return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) ); + } + } + + // Set correct file permissions. + $stat = stat( dirname( $new_file )); + $perms = $stat['mode'] & 0000666; + @ chmod( $new_file, $perms ); + + // Compute the URL. + $url = $uploads['url'] . "/$filename"; + + if ( is_multisite() ) { + delete_transient( 'dirsize_cache' ); + } + + /** + * Filters the data array for the uploaded file. + * + * @since 2.1.0 + * + * @param array $upload { + * Array of upload data. + * + * @type string $file Filename of the newly-uploaded file. + * @type string $url URL of the uploaded file. + * @type string $type File type. + * } + * @param string $context The type of upload action. Values include 'upload' or 'sideload'. + */ + return apply_filters( 'wp_handle_upload', array( + 'file' => $new_file, + 'url' => $url, + 'type' => $type + ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' ); +} + +/** + * Wrapper for _wp_handle_upload(). + * + * Passes the {@see 'wp_handle_upload'} action. + * + * @since 2.0.0 + * + * @see _wp_handle_upload() + * + * @param array $file Reference to a single element of `$_FILES`. Call the function once for + * each uploaded file. + * @param array|bool $overrides Optional. An associative array of names=>values to override default + * variables. Default false. + * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. + * @return array On success, returns an associative array of file attributes. On failure, returns + * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). + */ +function wp_handle_upload( &$file, $overrides = false, $time = null ) { + /* + * $_POST['action'] must be set and its value must equal $overrides['action'] + * or this: + */ + $action = 'wp_handle_upload'; + if ( isset( $overrides['action'] ) ) { + $action = $overrides['action']; + } + + return _wp_handle_upload( $file, $overrides, $time, $action ); +} + +/** + * Wrapper for _wp_handle_upload(). + * + * Passes the {@see 'wp_handle_sideload'} action. + * + * @since 2.6.0 + * + * @see _wp_handle_upload() + * + * @param array $file An array similar to that of a PHP `$_FILES` POST array + * @param array|bool $overrides Optional. An associative array of names=>values to override default + * variables. Default false. + * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. + * @return array On success, returns an associative array of file attributes. On failure, returns + * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). + */ +function wp_handle_sideload( &$file, $overrides = false, $time = null ) { + /* + * $_POST['action'] must be set and its value must equal $overrides['action'] + * or this: + */ + $action = 'wp_handle_sideload'; + if ( isset( $overrides['action'] ) ) { + $action = $overrides['action']; + } + return _wp_handle_upload( $file, $overrides, $time, $action ); +} + + +/** + * Downloads a URL to a local temporary file using the WordPress HTTP Class. + * Please note, That the calling function must unlink() the file. + * + * @since 2.5.0 + * + * @param string $url the URL of the file to download + * @param int $timeout The timeout for the request to download the file default 300 seconds + * @return mixed WP_Error on failure, string Filename on success. + */ +function download_url( $url, $timeout = 300 ) { + //WARNING: The file is not automatically deleted, The script must unlink() the file. + if ( ! $url ) + return new WP_Error('http_no_url', __('Invalid URL Provided.')); + + $url_filename = basename( parse_url( $url, PHP_URL_PATH ) ); + + $tmpfname = wp_tempnam( $url_filename ); + if ( ! $tmpfname ) + return new WP_Error('http_no_file', __('Could not create Temporary file.')); + + $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); + + if ( is_wp_error( $response ) ) { + unlink( $tmpfname ); + return $response; + } + + if ( 200 != wp_remote_retrieve_response_code( $response ) ){ + unlink( $tmpfname ); + return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); + } + + $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); + if ( $content_md5 ) { + $md5_check = verify_file_md5( $tmpfname, $content_md5 ); + if ( is_wp_error( $md5_check ) ) { + unlink( $tmpfname ); + return $md5_check; + } + } + + return $tmpfname; +} + +/** + * Calculates and compares the MD5 of a file to its expected value. + * + * @since 3.7.0 + * + * @param string $filename The filename to check the MD5 of. + * @param string $expected_md5 The expected MD5 of the file, either a base64 encoded raw md5, or a hex-encoded md5 + * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected + */ +function verify_file_md5( $filename, $expected_md5 ) { + if ( 32 == strlen( $expected_md5 ) ) + $expected_raw_md5 = pack( 'H*', $expected_md5 ); + elseif ( 24 == strlen( $expected_md5 ) ) + $expected_raw_md5 = base64_decode( $expected_md5 ); + else + return false; // unknown format + + $file_md5 = md5_file( $filename, true ); + + if ( $file_md5 === $expected_raw_md5 ) + return true; + + return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); +} + +/** + * Unzips a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction. + * Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present. + * + * Attempts to increase the PHP Memory limit to 256M before uncompressing, + * However, The most memory required shouldn't be much larger than the Archive itself. + * + * @since 2.5.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $file Full path and filename of zip archive + * @param string $to Full path on the filesystem to extract archive to + * @return mixed WP_Error on failure, True on success + */ +function unzip_file($file, $to) { + global $wp_filesystem; + + if ( ! $wp_filesystem || !is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + // Unzip can use a lot of memory, but not this much hopefully. + wp_raise_memory_limit( 'admin' ); + + $needed_dirs = array(); + $to = trailingslashit($to); + + // Determine any parent dir's needed (of the upgrade directory) + if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist + $path = preg_split('![/\\\]!', untrailingslashit($to)); + for ( $i = count($path); $i >= 0; $i-- ) { + if ( empty($path[$i]) ) + continue; + + $dir = implode('/', array_slice($path, 0, $i+1) ); + if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter. + continue; + + if ( ! $wp_filesystem->is_dir($dir) ) + $needed_dirs[] = $dir; + else + break; // A folder exists, therefor, we dont need the check the levels below this + } + } + + /** + * Filters whether to use ZipArchive to unzip archives. + * + * @since 3.0.0 + * + * @param bool $ziparchive Whether to use ZipArchive. Default true. + */ + if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { + $result = _unzip_file_ziparchive($file, $to, $needed_dirs); + if ( true === $result ) { + return $result; + } elseif ( is_wp_error($result) ) { + if ( 'incompatible_archive' != $result->get_error_code() ) + return $result; + } + } + // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. + return _unzip_file_pclzip($file, $to, $needed_dirs); +} + +/** + * This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the ZipArchive class. + * Assumes that WP_Filesystem() has already been called and set up. + * + * @since 3.0.0 + * @see unzip_file + * @access private + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $file Full path and filename of zip archive + * @param string $to Full path on the filesystem to extract archive to + * @param array $needed_dirs A partial list of required folders needed to be created. + * @return mixed WP_Error on failure, True on success + */ +function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) { + global $wp_filesystem; + + $z = new ZipArchive(); + + $zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS ); + if ( true !== $zopen ) + return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); + + $uncompressed_size = 0; + + for ( $i = 0; $i < $z->numFiles; $i++ ) { + if ( ! $info = $z->statIndex($i) ) + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); + + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory + continue; + + // Don't extract invalid files: + if ( 0 !== validate_file( $info['name'] ) ) { + continue; + } + + $uncompressed_size += $info['size']; + + if ( '/' === substr( $info['name'], -1 ) ) { + // Directory. + $needed_dirs[] = $to . untrailingslashit( $info['name'] ); + } elseif ( '.' !== $dirname = dirname( $info['name'] ) ) { + // Path to a file. + $needed_dirs[] = $to . untrailingslashit( $dirname ); + } + } + + /* + * disk_free_space() could return false. Assume that any falsey value is an error. + * A disk that has zero free bytes has bigger problems. + * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. + */ + if ( wp_doing_cron() ) { + $available_space = @disk_free_space( WP_CONTENT_DIR ); + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); + } + + $needed_dirs = array_unique($needed_dirs); + foreach ( $needed_dirs as $dir ) { + // Check the parent folders of the folders all exist within the creation array. + if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) + continue; + if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it + continue; + + $parent_folder = dirname($dir); + while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { + $needed_dirs[] = $parent_folder; + $parent_folder = dirname($parent_folder); + } + } + asort($needed_dirs); + + // Create those directories if need be: + foreach ( $needed_dirs as $_dir ) { + // Only check to see if the Dir exists upon creation failure. Less I/O this way. + if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { + return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); + } + } + unset($needed_dirs); + + for ( $i = 0; $i < $z->numFiles; $i++ ) { + if ( ! $info = $z->statIndex($i) ) + return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); + + if ( '/' == substr($info['name'], -1) ) // directory + continue; + + if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files + continue; + + // Don't extract invalid files: + if ( 0 !== validate_file( $info['name'] ) ) { + continue; + } + + $contents = $z->getFromIndex($i); + if ( false === $contents ) + return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); + + if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) + return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); + } + + $z->close(); + + return true; +} + +/** + * This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the PclZip library. + * Assumes that WP_Filesystem() has already been called and set up. + * + * @since 3.0.0 + * @see unzip_file + * @access private + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $file Full path and filename of zip archive + * @param string $to Full path on the filesystem to extract archive to + * @param array $needed_dirs A partial list of required folders needed to be created. + * @return mixed WP_Error on failure, True on success + */ +function _unzip_file_pclzip($file, $to, $needed_dirs = array()) { + global $wp_filesystem; + + mbstring_binary_safe_encoding(); + + require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); + + $archive = new PclZip($file); + + $archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING); + + reset_mbstring_encoding(); + + // Is the archive valid? + if ( !is_array($archive_files) ) + return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); + + if ( 0 == count($archive_files) ) + return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); + + $uncompressed_size = 0; + + // Determine any children directories needed (From within the archive) + foreach ( $archive_files as $file ) { + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory + continue; + + $uncompressed_size += $file['size']; + + $needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) ); + } + + /* + * disk_free_space() could return false. Assume that any falsey value is an error. + * A disk that has zero free bytes has bigger problems. + * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. + */ + if ( wp_doing_cron() ) { + $available_space = @disk_free_space( WP_CONTENT_DIR ); + if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) + return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); + } + + $needed_dirs = array_unique($needed_dirs); + foreach ( $needed_dirs as $dir ) { + // Check the parent folders of the folders all exist within the creation array. + if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) + continue; + if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it + continue; + + $parent_folder = dirname($dir); + while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { + $needed_dirs[] = $parent_folder; + $parent_folder = dirname($parent_folder); + } + } + asort($needed_dirs); + + // Create those directories if need be: + foreach ( $needed_dirs as $_dir ) { + // Only check to see if the dir exists upon creation failure. Less I/O this way. + if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) + return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); + } + unset($needed_dirs); + + // Extract the files from the zip + foreach ( $archive_files as $file ) { + if ( $file['folder'] ) + continue; + + if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files + continue; + + // Don't extract invalid files: + if ( 0 !== validate_file( $file['filename'] ) ) { + continue; + } + + if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) + return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); + } + return true; +} + +/** + * Copies a directory from one location to another via the WordPress Filesystem Abstraction. + * Assumes that WP_Filesystem() has already been called and setup. + * + * @since 2.5.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param string $from source directory + * @param string $to destination directory + * @param array $skip_list a list of files/folders to skip copying + * @return mixed WP_Error on failure, True on success. + */ +function copy_dir($from, $to, $skip_list = array() ) { + global $wp_filesystem; + + $dirlist = $wp_filesystem->dirlist($from); + + $from = trailingslashit($from); + $to = trailingslashit($to); + + foreach ( (array) $dirlist as $filename => $fileinfo ) { + if ( in_array( $filename, $skip_list ) ) + continue; + + if ( 'f' == $fileinfo['type'] ) { + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { + // If copy failed, chmod file to 0644 and try again. + $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); + if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) + return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); + } + } elseif ( 'd' == $fileinfo['type'] ) { + if ( !$wp_filesystem->is_dir($to . $filename) ) { + if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) + return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); + } + + // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list + $sub_skip_list = array(); + foreach ( $skip_list as $skip_item ) { + if ( 0 === strpos( $skip_item, $filename . '/' ) ) + $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); + } + + $result = copy_dir($from . $filename, $to . $filename, $sub_skip_list); + if ( is_wp_error($result) ) + return $result; + } + } + return true; +} + +/** + * Initialises and connects the WordPress Filesystem Abstraction classes. + * This function will include the chosen transport and attempt connecting. + * + * Plugins may add extra transports, And force WordPress to use them by returning + * the filename via the {@see 'filesystem_method_file'} filter. + * + * @since 2.5.0 + * + * @global WP_Filesystem_Base $wp_filesystem Subclass + * + * @param array|false $args Optional. Connection args, These are passed directly to + * the `WP_Filesystem_*()` classes. Default false. + * @param string|false $context Optional. Context for get_filesystem_method(). Default false. + * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. + * @return null|bool false on failure, true on success. + */ +function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) { + global $wp_filesystem; + + require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); + + $method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership ); + + if ( ! $method ) + return false; + + if ( ! class_exists( "WP_Filesystem_$method" ) ) { + + /** + * Filters the path for a specific filesystem method class file. + * + * @since 2.6.0 + * + * @see get_filesystem_method() + * + * @param string $path Path to the specific filesystem method class file. + * @param string $method The filesystem method to use. + */ + $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); + + if ( ! file_exists($abstraction_file) ) + return; + + require_once($abstraction_file); + } + $method = "WP_Filesystem_$method"; + + $wp_filesystem = new $method($args); + + //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default. + if ( ! defined('FS_CONNECT_TIMEOUT') ) + define('FS_CONNECT_TIMEOUT', 30); + if ( ! defined('FS_TIMEOUT') ) + define('FS_TIMEOUT', 30); + + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) + return false; + + if ( !$wp_filesystem->connect() ) + return false; //There was an error connecting to the server. + + // Set the permission constants if not already set. + if ( ! defined('FS_CHMOD_DIR') ) + define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); + if ( ! defined('FS_CHMOD_FILE') ) + define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); + + return true; +} + +/** + * Determines which method to use for reading, writing, modifying, or deleting + * files on the filesystem. + * + * The priority of the transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets + * (Via Sockets class, or `fsockopen()`). Valid values for these are: 'direct', 'ssh2', + * 'ftpext' or 'ftpsockets'. + * + * The return value can be overridden by defining the `FS_METHOD` constant in `wp-config.php`, + * or filtering via {@see 'filesystem_method'}. + * + * @link https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants + * + * Plugins may define a custom transport handler, See WP_Filesystem(). + * + * @since 2.5.0 + * + * @global callable $_wp_filesystem_direct_method + * + * @param array $args Optional. Connection details. Default empty array. + * @param string $context Optional. Full path to the directory that is tested + * for being writable. Default empty. + * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. + * Default false. + * @return string The transport to use, see description for valid return values. + */ +function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_file_ownership = false ) { + $method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets' + + if ( ! $context ) { + $context = WP_CONTENT_DIR; + } + + // If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it. + if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) { + $context = dirname( $context ); + } + + $context = trailingslashit( $context ); + + if ( ! $method ) { + + $temp_file_name = $context . 'temp-write-test-' . time(); + $temp_handle = @fopen($temp_file_name, 'w'); + if ( $temp_handle ) { + + // Attempt to determine the file owner of the WordPress files, and that of newly created files + $wp_file_owner = $temp_file_owner = false; + if ( function_exists('fileowner') ) { + $wp_file_owner = @fileowner( __FILE__ ); + $temp_file_owner = @fileowner( $temp_file_name ); + } + + if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) { + // WordPress is creating files as the same owner as the WordPress files, + // this means it's safe to modify & create new files via PHP. + $method = 'direct'; + $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner'; + } elseif ( $allow_relaxed_file_ownership ) { + // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files + // safely in this directory. This mode doesn't create new files, only alter existing ones. + $method = 'direct'; + $GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership'; + } + + @fclose($temp_handle); + @unlink($temp_file_name); + } + } + + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2'; + if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; + if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread + + /** + * Filters the filesystem method to use. + * + * @since 2.6.0 + * + * @param string $method Filesystem method to return. + * @param array $args An array of connection details for the method. + * @param string $context Full path to the directory that is tested for being writable. + * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. + */ + return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership ); +} + +/** + * Displays a form to the user to request for their FTP/SSH details in order + * to connect to the filesystem. + * + * All chosen/entered details are saved, excluding the password. + * + * Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467) + * to specify an alternate FTP/SSH port. + * + * Plugins may override this form by returning true|false via the {@see 'request_filesystem_credentials'} filter. + * + * @since 2.5.0 + * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. + * + * @global string $pagenow + * + * @param string $form_post The URL to post the form to. + * @param string $type Optional. Chosen type of filesystem. Default empty. + * @param bool $error Optional. Whether the current request has failed to connect. + * Default false. + * @param string $context Optional. Full path to the directory that is tested for being + * writable. Default empty. + * @param array $extra_fields Optional. Extra `POST` fields to be checked for inclusion in + * the post. Default null. + * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. + * + * @return bool False on failure, true on success. + */ +function request_filesystem_credentials( $form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false ) { + global $pagenow; + + /** + * Filters the filesystem credentials form output. + * + * Returning anything other than an empty string will effectively short-circuit + * output of the filesystem credentials form, returning that value instead. + * + * @since 2.5.0 + * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. + * + * @param mixed $output Form output to return instead. Default empty. + * @param string $form_post The URL to post the form to. + * @param string $type Chosen type of filesystem. + * @param bool $error Whether the current request has failed to connect. + * Default false. + * @param string $context Full path to the directory that is tested for + * being writable. + * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. + * Default false. + * @param array $extra_fields Extra POST fields. + */ + $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership ); + if ( '' !== $req_cred ) + return $req_cred; + + if ( empty($type) ) { + $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); + } + + if ( 'direct' == $type ) + return true; + + if ( is_null( $extra_fields ) ) + $extra_fields = array( 'version', 'locale' ); + + $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); + + $submitted_form = wp_unslash( $_POST ); + + // Verify nonce, or unset submitted form field values on failure + if ( ! isset( $_POST['_fs_nonce'] ) || ! wp_verify_nonce( $_POST['_fs_nonce'], 'filesystem-credentials' ) ) { + unset( + $submitted_form['hostname'], + $submitted_form['username'], + $submitted_form['password'], + $submitted_form['public_key'], + $submitted_form['private_key'], + $submitted_form['connection_type'] + ); + } + + // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) + $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($submitted_form['hostname']) ? $submitted_form['hostname'] : $credentials['hostname']); + $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($submitted_form['username']) ? $submitted_form['username'] : $credentials['username']); + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($submitted_form['password']) ? $submitted_form['password'] : ''); + + // Check to see if we are setting the public/private keys for ssh + $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($submitted_form['public_key']) ? $submitted_form['public_key'] : ''); + $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($submitted_form['private_key']) ? $submitted_form['private_key'] : ''); + + // Sanitize the hostname, Some people might pass in odd-data: + $credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off + + if ( strpos($credentials['hostname'], ':') ) { + list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); + if ( ! is_numeric($credentials['port']) ) + unset($credentials['port']); + } else { + unset($credentials['port']); + } + + if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { + $credentials['connection_type'] = 'ssh'; + } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL + $credentials['connection_type'] = 'ftps'; + } elseif ( ! empty( $submitted_form['connection_type'] ) ) { + $credentials['connection_type'] = $submitted_form['connection_type']; + } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP + $credentials['connection_type'] = 'ftp'; + } + if ( ! $error && + ( + ( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) || + ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) + ) ) { + $stored_credentials = $credentials; + if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. + $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; + + unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); + if ( ! wp_installing() ) { + update_option( 'ftp_credentials', $stored_credentials ); + } + return $credentials; + } + $hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : ''; + $username = isset( $credentials['username'] ) ? $credentials['username'] : ''; + $public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : ''; + $private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : ''; + $port = isset( $credentials['port'] ) ? $credentials['port'] : ''; + $connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : ''; + + if ( $error ) { + $error_string = __('ERROR: There was an error connecting to the server, Please verify the settings are correct.'); + if ( is_wp_error($error) ) + $error_string = esc_html( $error->get_error_message() ); + echo '

    ' . $error_string . '

    '; + } + + $types = array(); + if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) + $types[ 'ftp' ] = __('FTP'); + if ( extension_loaded('ftp') ) //Only this supports FTPS + $types[ 'ftps' ] = __('FTPS (SSL)'); + if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) + $types[ 'ssh' ] = __('SSH2'); + + /** + * Filters the connection types to output to the filesystem credentials form. + * + * @since 2.9.0 + * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. + * + * @param array $types Types of connections. + * @param array $credentials Credentials to connect with. + * @param string $type Chosen filesystem method. + * @param object $error Error object. + * @param string $context Full path to the directory that is tested + * for being writable. + */ + $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context ); + +?> +
    +
    +" . __( 'Connection Information' ) . ""; +?> +

    + +
    + +
    +
    + +
    +
    + + $text ) : ?> + + +
    + +
    > + + + +

    +
    +'; +} +?> +

    + + + +

    +
    +
    + +
    +
    + +
    + array( + 'href' => array(), + 'target' => array() + ), + 'br' => array() + ); + $allowed_protocols = array( 'http', 'https' ); + $group_html = ''; + + $group_html .= '

    ' . esc_html( $group_data['group_label'] ) . '

    '; + $group_html .= '
    '; + + foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) { + $group_html .= ''; + $group_html .= ''; + + foreach ( (array) $group_item_data as $group_item_datum ) { + $value = $group_item_datum['value']; + // If it looks like a link, make it a link + if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) { + $value = '' . esc_html( $value ) . ''; + } + + $group_html .= ''; + $group_html .= ''; + $group_html .= ''; + $group_html .= ''; + } + + $group_html .= ''; + $group_html .= '
    ' . esc_html( $group_item_datum['name'] ) . '' . wp_kses( $value, $allowed_tags, $allowed_protocols ) . '
    '; + } + + $group_html .= '
    '; + + return $group_html; +} + +/** + * Generate the personal data export file. + * + * @since 4.9.6 + * + * @param int $request_id The export request ID. + */ +function wp_privacy_generate_personal_data_export_file( $request_id ) { + if ( ! class_exists( 'ZipArchive' ) ) { + wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) ); + } + + // Get the request data. + $request = wp_get_user_request_data( $request_id ); + + if ( ! $request || 'export_personal_data' !== $request->action_name ) { + wp_send_json_error( __( 'Invalid request ID when generating export file.' ) ); + } + + $email_address = $request->email; + + if ( ! is_email( $email_address ) ) { + wp_send_json_error( __( 'Invalid email address when generating export file.' ) ); + } + + // Create the exports folder if needed. + $exports_dir = wp_privacy_exports_dir(); + $exports_url = wp_privacy_exports_url(); + + $result = wp_mkdir_p( $exports_dir ); + if ( is_wp_error( $result ) ) { + wp_send_json_error( $result->get_error_message() ); + } + + // Protect export folder from browsing. + $index_pathname = $exports_dir . 'index.html'; + if ( ! file_exists( $index_pathname ) ) { + $file = fopen( $index_pathname, 'w' ); + if ( false === $file ) { + wp_send_json_error( __( 'Unable to protect export folder from browsing.' ) ); + } + fwrite( $file, 'Silence is golden.' ); + fclose( $file ); + } + + $stripped_email = str_replace( '@', '-at-', $email_address ); + $stripped_email = sanitize_title( $stripped_email ); // slugify the email address + $obscura = wp_generate_password( 32, false, false ); + $file_basename = 'wp-personal-data-file-' . $stripped_email . '-' . $obscura; + $html_report_filename = $file_basename . '.html'; + $html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename ); + $file = fopen( $html_report_pathname, 'w' ); + if ( false === $file ) { + wp_send_json_error( __( 'Unable to open export file (HTML report) for writing.' ) ); + } + + $title = sprintf( + /* translators: %s: user's e-mail address */ + __( 'Personal Data Export for %s' ), + $email_address + ); + + // Open HTML. + fwrite( $file, "\n" ); + fwrite( $file, "\n" ); + + // Head. + fwrite( $file, "\n" ); + fwrite( $file, "\n" ); + fwrite( $file, "" ); + fwrite( $file, "" ); + fwrite( $file, esc_html( $title ) ); + fwrite( $file, "" ); + fwrite( $file, "\n" ); + + // Body. + fwrite( $file, "\n" ); + + // Heading. + fwrite( $file, "

    " . esc_html__( 'Personal Data Export' ) . "

    " ); + + // And now, all the Groups. + $groups = get_post_meta( $request_id, '_export_data_grouped', true ); + + // First, build an "About" group on the fly for this report. + $about_group = array( + 'group_label' => __( 'About' ), + 'items' => array( + 'about-1' => array( + array( + 'name' => _x( 'Report generated for', 'email address' ), + 'value' => $email_address, + ), + array( + 'name' => _x( 'For site', 'website name' ), + 'value' => get_bloginfo( 'name' ), + ), + array( + 'name' => _x( 'At URL', 'website URL' ), + 'value' => get_bloginfo( 'url' ), + ), + array( + 'name' => _x( 'On', 'date/time' ), + 'value' => current_time( 'mysql' ), + ), + ), + ), + ); + + // Merge in the special about group. + $groups = array_merge( array( 'about' => $about_group ), $groups ); + + // Now, iterate over every group in $groups and have the formatter render it in HTML. + foreach ( (array) $groups as $group_id => $group_data ) { + fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data ) ); + } + + fwrite( $file, "\n" ); + + // Close HTML. + fwrite( $file, "\n" ); + fclose( $file ); + + /* + * Now, generate the ZIP. + * + * If an archive has already been generated, then remove it and reuse the + * filename, to avoid breaking any URLs that may have been previously sent + * via email. + */ + $error = false; + $archive_url = get_post_meta( $request_id, '_export_file_url', true ); + $archive_pathname = get_post_meta( $request_id, '_export_file_path', true ); + + if ( empty( $archive_pathname ) || empty( $archive_url ) ) { + $archive_filename = $file_basename . '.zip'; + $archive_pathname = $exports_dir . $archive_filename; + $archive_url = $exports_url . $archive_filename; + + update_post_meta( $request_id, '_export_file_url', $archive_url ); + update_post_meta( $request_id, '_export_file_path', wp_normalize_path( $archive_pathname ) ); + } + + if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) { + wp_delete_file( $archive_pathname ); + } + + $zip = new ZipArchive; + if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) { + if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) { + $error = __( 'Unable to add data to export file.' ); + } + + $zip->close(); + + if ( ! $error ) { + /** + * Fires right after all personal data has been written to the export file. + * + * @since 4.9.6 + * + * @param string $archive_pathname The full path to the export file on the filesystem. + * @param string $archive_url The URL of the archive file. + * @param string $html_report_pathname The full path to the personal data report on the filesystem. + * @param string $request_id The export request ID. + */ + do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname, $request_id ); + } + } else { + $error = __( 'Unable to open export file (archive) for writing.' ); + } + + // And remove the HTML file. + unlink( $html_report_pathname ); + + if ( $error ) { + wp_send_json_error( $error ); + } +} + +/** + * Send an email to the user with a link to the personal data export file + * + * @since 4.9.6 + * + * @param int $request_id The request ID for this personal data export. + * @return true|WP_Error True on success or `WP_Error` on failure. + */ +function wp_privacy_send_personal_data_export_email( $request_id ) { + // Get the request data. + $request = wp_get_user_request_data( $request_id ); + + if ( ! $request || 'export_personal_data' !== $request->action_name ) { + return new WP_Error( 'invalid', __( 'Invalid request ID when sending personal data export email.' ) ); + } + + /** This filter is documented in wp-admin/includes/file.php */ + $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); + $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); + +/* translators: Do not translate EXPIRATION, LINK, EMAIL, SITENAME, SITEURL: those are placeholders. */ +$email_text = __( +'Howdy, + +Your request for an export of personal data has been completed. You may +download your personal data by clicking on the link below. For privacy +and security, we will automatically delete the file on ###EXPIRATION###, +so please download it before then. + +###LINK### + +This email has been sent to ###EMAIL###. + +Regards, +All at ###SITENAME### +###SITEURL###' +); + + /** + * Filters the text of the email sent with a personal data export file. + * + * The following strings have a special meaning and will get replaced dynamically: + * ###EXPIRATION### The date when the URL will be automatically deleted. + * ###LINK### URL of the personal data export file for the user. + * ###EMAIL### The email we are sending to. + * ###SITENAME### The name of the site. + * ###SITEURL### The URL to the site. + * + * @since 4.9.6 + * + * @param string $email_text Text in the email. + * @param int $request_id The request ID for this personal data export. + */ + $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id ); + + $email_address = $request->email; + $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); + $site_name = is_multisite() ? get_site_option( 'site_name' ) : get_option( 'blogname' ); + $site_url = network_home_url(); + + $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); + $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); + $content = str_replace( '###EMAIL###', $email_address, $content ); + $content = str_replace( '###SITENAME###', wp_specialchars_decode( $site_name, ENT_QUOTES ), $content ); + $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content ); + + $mail_success = wp_mail( + $email_address, + sprintf( + __( '[%s] Personal Data Export' ), + wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) + ), + $content + ); + + if ( ! $mail_success ) { + return new WP_Error( 'error', __( 'Unable to send personal data export email.' ) ); + } + + return true; +} + +/** + * Intercept personal data exporter page ajax responses in order to assemble the personal data export file. + * @see wp_privacy_personal_data_export_page + * @since 4.9.6 + * + * @param array $response The response from the personal data exporter for the given page. + * @param int $exporter_index The index of the personal data exporter. Begins at 1. + * @param string $email_address The email address of the user whose personal data this is. + * @param int $page The page of personal data for this exporter. Begins at 1. + * @param int $request_id The request ID for this personal data export. + * @param bool $send_as_email Whether the final results of the export should be emailed to the user. + * @param string $exporter_key The slug (key) of the exporter. + * @return array The filtered response. + */ +function wp_privacy_process_personal_data_export_page( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) { + /* Do some simple checks on the shape of the response from the exporter. + * If the exporter response is malformed, don't attempt to consume it - let it + * pass through to generate a warning to the user by default ajax processing. + */ + if ( ! is_array( $response ) ) { + return $response; + } + + if ( ! array_key_exists( 'done', $response ) ) { + return $response; + } + + if ( ! array_key_exists( 'data', $response ) ) { + return $response; + } + + if ( ! is_array( $response['data'] ) ) { + return $response; + } + + // Get the request data. + $request = wp_get_user_request_data( $request_id ); + + if ( ! $request || 'export_personal_data' !== $request->action_name ) { + wp_send_json_error( __( 'Invalid request ID when merging exporter data.' ) ); + } + + $export_data = array(); + + // First exporter, first page? Reset the report data accumulation array. + if ( 1 === $exporter_index && 1 === $page ) { + update_post_meta( $request_id, '_export_data_raw', $export_data ); + } else { + $export_data = get_post_meta( $request_id, '_export_data_raw', true ); + } + + // Now, merge the data from the exporter response into the data we have accumulated already. + $export_data = array_merge( $export_data, $response['data'] ); + update_post_meta( $request_id, '_export_data_raw', $export_data ); + + // If we are not yet on the last page of the last exporter, return now. + $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); + $is_last_exporter = $exporter_index === count( $exporters ); + $exporter_done = $response['done']; + if ( ! $is_last_exporter || ! $exporter_done ) { + return $response; + } + + // Last exporter, last page - let's prepare the export file. + + // First we need to re-organize the raw data hierarchically in groups and items. + $groups = array(); + foreach ( (array) $export_data as $export_datum ) { + $group_id = $export_datum['group_id']; + $group_label = $export_datum['group_label']; + if ( ! array_key_exists( $group_id, $groups ) ) { + $groups[ $group_id ] = array( + 'group_label' => $group_label, + 'items' => array(), + ); + } + + $item_id = $export_datum['item_id']; + if ( ! array_key_exists( $item_id, $groups[ $group_id ]['items'] ) ) { + $groups[ $group_id ]['items'][ $item_id ] = array(); + } + + $old_item_data = $groups[ $group_id ]['items'][ $item_id ]; + $merged_item_data = array_merge( $export_datum['data'], $old_item_data ); + $groups[ $group_id ]['items'][ $item_id ] = $merged_item_data; + } + + // Then save the grouped data into the request. + delete_post_meta( $request_id, '_export_data_raw' ); + update_post_meta( $request_id, '_export_data_grouped', $groups ); + + // Generate the export file from the collected, grouped personal data. + do_action( 'wp_privacy_personal_data_export_file', $request_id ); + + // Clear the grouped data now that it is no longer needed. + delete_post_meta( $request_id, '_export_data_grouped' ); + + // If the destination is email, send it now. + if ( $send_as_email ) { + $mail_success = wp_privacy_send_personal_data_export_email( $request_id ); + if ( is_wp_error( $mail_success ) ) { + wp_send_json_error( $mail_success->get_error_message() ); + } + } else { + // Modify the response to include the URL of the export file so the browser can fetch it. + $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); + if ( ! empty( $export_file_url ) ) { + $response['url'] = $export_file_url; + } + } + + // Update the request to completed state. + _wp_privacy_completed_request( $request_id ); + + return $response; +} diff --git a/backend/wp-admin/includes/image-edit.php b/backend/wp-admin/includes/image-edit.php new file mode 100644 index 0000000..efa9865 --- /dev/null +++ b/backend/wp-admin/includes/image-edit.php @@ -0,0 +1,913 @@ + 400 ? 400 / $big : 1; + + $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); + $can_restore = false; + if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) + $can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] ); + + if ( $msg ) { + if ( isset($msg->error) ) + $note = "

    $msg->error

    "; + elseif ( isset($msg->msg) ) + $note = "

    $msg->msg

    "; + } + + ?> +
    +
    + +
    +
    +
    +

    + +
    +

    +
    + +

    + +
    + +
    + +
    + + × + + ! + , 'scale')" class="button button-primary" value="" /> +
    +
    + +
    +
    +
    + + + +
    +
    +

    +
    +

    +
    + , 'restore')" class="button button-primary" value="" /> +
    +
    +
    +
    + + + +
    +
    +

    + + +
    +

    + +


    +

    + +


    +

    +
    +
    + +
    + +
    + + : + +
    +
    + +
    + +
    + + × + +
    +
    + +
    + + + +
    +
    +

    + +

    +
    + +
    + +
    +
    + +
    +
    + + + + + + + +
    +
    +
    + + + +
    + +
    + +
    + get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { + $note_no_rotate = ''; + ?> + + + ' . __( 'Image rotation is not supported by your web host.' ) . '

    '; + ?> + + + + + + + + + + +
    + + + + + + + + +
    + +
    + +
    + + )" disabled="disabled" class="button button-primary imgedit-submit-btn" value="" /> +
    +
    + +
    +
    + +
    +stream( $mime_type ) ) ) + return false; + + return true; + } else { + _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); + + /** + * Filters the GD image resource to be streamed to the browser. + * + * @since 2.9.0 + * @deprecated 3.5.0 Use image_editor_save_pre instead. + * + * @param resource $image Image resource to be streamed. + * @param int $attachment_id The attachment post ID. + */ + $image = apply_filters( 'image_save_pre', $image, $attachment_id ); + + switch ( $mime_type ) { + case 'image/jpeg': + header( 'Content-Type: image/jpeg' ); + return imagejpeg( $image, null, 90 ); + case 'image/png': + header( 'Content-Type: image/png' ); + return imagepng( $image ); + case 'image/gif': + header( 'Content-Type: image/gif' ); + return imagegif( $image ); + default: + return false; + } + } +} + +/** + * Saves Image to File + * + * @param string $filename + * @param WP_Image_Editor $image + * @param string $mime_type + * @param int $post_id + * @return bool + */ +function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { + if ( $image instanceof WP_Image_Editor ) { + + /** This filter is documented in wp-admin/includes/image-edit.php */ + $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); + + /** + * Filters whether to skip saving the image file. + * + * Returning a non-null value will short-circuit the save method, + * returning that value instead. + * + * @since 3.5.0 + * + * @param mixed $override Value to return instead of saving. Default null. + * @param string $filename Name of the file to be saved. + * @param WP_Image_Editor $image WP_Image_Editor instance. + * @param string $mime_type Image mime type. + * @param int $post_id Post ID. + */ + $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); + + if ( null !== $saved ) + return $saved; + + return $image->save( $filename, $mime_type ); + } else { + _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); + + /** This filter is documented in wp-admin/includes/image-edit.php */ + $image = apply_filters( 'image_save_pre', $image, $post_id ); + + /** + * Filters whether to skip saving the image file. + * + * Returning a non-null value will short-circuit the save method, + * returning that value instead. + * + * @since 2.9.0 + * @deprecated 3.5.0 Use wp_save_image_editor_file instead. + * + * @param mixed $override Value to return instead of saving. Default null. + * @param string $filename Name of the file to be saved. + * @param WP_Image_Editor $image WP_Image_Editor instance. + * @param string $mime_type Image mime type. + * @param int $post_id Post ID. + */ + $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); + + if ( null !== $saved ) + return $saved; + + switch ( $mime_type ) { + case 'image/jpeg': + + /** This filter is documented in wp-includes/class-wp-image-editor.php */ + return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); + case 'image/png': + return imagepng( $image, $filename ); + case 'image/gif': + return imagegif( $image, $filename ); + default: + return false; + } + } +} + +/** + * Image preview ratio. Internal use only. + * + * @since 2.9.0 + * + * @ignore + * @param int $w Image width in pixels. + * @param int $h Image height in pixels. + * @return float|int Image preview ratio. + */ +function _image_get_preview_ratio($w, $h) { + $max = max($w, $h); + return $max > 400 ? (400 / $max) : 1; +} + +/** + * Returns an image resource. Internal use only. + * + * @since 2.9.0 + * @deprecated 3.5.0 Use WP_Image_Editor::rotate() + * @see WP_Image_Editor::rotate() + * + * @ignore + * @param resource $img Image resource. + * @param float|int $angle Image rotation angle, in degrees. + * @return resource|false GD image resource, false otherwise. + */ +function _rotate_image_resource($img, $angle) { + _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' ); + if ( function_exists('imagerotate') ) { + $rotated = imagerotate($img, $angle, 0); + if ( is_resource($rotated) ) { + imagedestroy($img); + $img = $rotated; + } + } + return $img; +} + +/** + * Flips an image resource. Internal use only. + * + * @since 2.9.0 + * @deprecated 3.5.0 Use WP_Image_Editor::flip() + * @see WP_Image_Editor::flip() + * + * @ignore + * @param resource $img Image resource. + * @param bool $horz Whether to flip horizontally. + * @param bool $vert Whether to flip vertically. + * @return resource (maybe) flipped image resource. + */ +function _flip_image_resource($img, $horz, $vert) { + _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' ); + $w = imagesx($img); + $h = imagesy($img); + $dst = wp_imagecreatetruecolor($w, $h); + if ( is_resource($dst) ) { + $sx = $vert ? ($w - 1) : 0; + $sy = $horz ? ($h - 1) : 0; + $sw = $vert ? -$w : $w; + $sh = $horz ? -$h : $h; + + if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) { + imagedestroy($img); + $img = $dst; + } + } + return $img; +} + +/** + * Crops an image resource. Internal use only. + * + * @since 2.9.0 + * + * @ignore + * @param resource $img Image resource. + * @param float $x Source point x-coordinate. + * @param float $y Source point y-cooredinate. + * @param float $w Source width. + * @param float $h Source height. + * @return resource (maybe) cropped image resource. + */ +function _crop_image_resource($img, $x, $y, $w, $h) { + $dst = wp_imagecreatetruecolor($w, $h); + if ( is_resource($dst) ) { + if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) { + imagedestroy($img); + $img = $dst; + } + } + return $img; +} + +/** + * Performs group of changes on Editor specified. + * + * @since 2.9.0 + * + * @param WP_Image_Editor $image WP_Image_Editor instance. + * @param array $changes Array of change operations. + * @return WP_Image_Editor WP_Image_Editor instance with changes applied. + */ +function image_edit_apply_changes( $image, $changes ) { + if ( is_resource( $image ) ) + _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); + + if ( !is_array($changes) ) + return $image; + + // Expand change operations. + foreach ( $changes as $key => $obj ) { + if ( isset($obj->r) ) { + $obj->type = 'rotate'; + $obj->angle = $obj->r; + unset($obj->r); + } elseif ( isset($obj->f) ) { + $obj->type = 'flip'; + $obj->axis = $obj->f; + unset($obj->f); + } elseif ( isset($obj->c) ) { + $obj->type = 'crop'; + $obj->sel = $obj->c; + unset($obj->c); + } + $changes[$key] = $obj; + } + + // Combine operations. + if ( count($changes) > 1 ) { + $filtered = array($changes[0]); + for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) { + $combined = false; + if ( $filtered[$i]->type == $changes[$j]->type ) { + switch ( $filtered[$i]->type ) { + case 'rotate': + $filtered[$i]->angle += $changes[$j]->angle; + $combined = true; + break; + case 'flip': + $filtered[$i]->axis ^= $changes[$j]->axis; + $combined = true; + break; + } + } + if ( !$combined ) + $filtered[++$i] = $changes[$j]; + } + $changes = $filtered; + unset($filtered); + } + + // Image resource before applying the changes. + if ( $image instanceof WP_Image_Editor ) { + + /** + * Filters the WP_Image_Editor instance before applying changes to the image. + * + * @since 3.5.0 + * + * @param WP_Image_Editor $image WP_Image_Editor instance. + * @param array $changes Array of change operations. + */ + $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); + } elseif ( is_resource( $image ) ) { + + /** + * Filters the GD image resource before applying changes to the image. + * + * @since 2.9.0 + * @deprecated 3.5.0 Use wp_image_editor_before_change instead. + * + * @param resource $image GD image resource. + * @param array $changes Array of change operations. + */ + $image = apply_filters( 'image_edit_before_change', $image, $changes ); + } + + foreach ( $changes as $operation ) { + switch ( $operation->type ) { + case 'rotate': + if ( $operation->angle != 0 ) { + if ( $image instanceof WP_Image_Editor ) + $image->rotate( $operation->angle ); + else + $image = _rotate_image_resource( $image, $operation->angle ); + } + break; + case 'flip': + if ( $operation->axis != 0 ) + if ( $image instanceof WP_Image_Editor ) + $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); + else + $image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); + break; + case 'crop': + $sel = $operation->sel; + + if ( $image instanceof WP_Image_Editor ) { + $size = $image->get_size(); + $w = $size['width']; + $h = $size['height']; + + $scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling + $image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); + } else { + $scale = 1 / _image_get_preview_ratio( imagesx( $image ), imagesy( $image ) ); // discard preview scaling + $image = _crop_image_resource( $image, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale ); + } + break; + } + } + + return $image; +} + + +/** + * Streams image in post to browser, along with enqueued changes + * in $_REQUEST['history'] + * + * @param int $post_id + * @return bool + */ +function stream_preview_image( $post_id ) { + $post = get_post( $post_id ); + + wp_raise_memory_limit( 'admin' ); + + $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); + + if ( is_wp_error( $img ) ) { + return false; + } + + $changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null; + if ( $changes ) + $img = image_edit_apply_changes( $img, $changes ); + + // Scale the image. + $size = $img->get_size(); + $w = $size['width']; + $h = $size['height']; + + $ratio = _image_get_preview_ratio( $w, $h ); + $w2 = max ( 1, $w * $ratio ); + $h2 = max ( 1, $h * $ratio ); + + if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) + return false; + + return wp_stream_image( $img, $post->post_mime_type, $post_id ); +} + +/** + * Restores the metadata for a given attachment. + * + * @since 2.9.0 + * + * @param int $post_id Attachment post ID. + * @return stdClass Image restoration message object. + */ +function wp_restore_image($post_id) { + $meta = wp_get_attachment_metadata($post_id); + $file = get_attached_file($post_id); + $backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); + $restored = false; + $msg = new stdClass; + + if ( !is_array($backup_sizes) ) { + $msg->error = __('Cannot load image metadata.'); + return $msg; + } + + $parts = pathinfo($file); + $suffix = time() . rand(100, 999); + $default_sizes = get_intermediate_image_sizes(); + + if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) { + $data = $backup_sizes['full-orig']; + + if ( $parts['basename'] != $data['file'] ) { + if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { + + // Delete only if it's an edited image. + if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { + wp_delete_file( $file ); + } + } elseif ( isset( $meta['width'], $meta['height'] ) ) { + $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); + } + } + + $restored_file = path_join($parts['dirname'], $data['file']); + $restored = update_attached_file($post_id, $restored_file); + + $meta['file'] = _wp_relative_upload_path( $restored_file ); + $meta['width'] = $data['width']; + $meta['height'] = $data['height']; + } + + foreach ( $default_sizes as $default_size ) { + if ( isset($backup_sizes["$default_size-orig"]) ) { + $data = $backup_sizes["$default_size-orig"]; + if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) { + if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { + + // Delete only if it's an edited image. + if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) { + $delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] ); + wp_delete_file( $delete_file ); + } + } else { + $backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size]; + } + } + + $meta['sizes'][$default_size] = $data; + } else { + unset($meta['sizes'][$default_size]); + } + } + + if ( ! wp_update_attachment_metadata( $post_id, $meta ) || + ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) { + + $msg->error = __('Cannot save image metadata.'); + return $msg; + } + + if ( !$restored ) + $msg->error = __('Image metadata is inconsistent.'); + else + $msg->msg = __('Image restored successfully.'); + + return $msg; +} + +/** + * Saves image to post along with enqueued changes + * in $_REQUEST['history'] + * + * @param int $post_id + * @return \stdClass + */ +function wp_save_image( $post_id ) { + $_wp_additional_image_sizes = wp_get_additional_image_sizes(); + + $return = new stdClass; + $success = $delete = $scaled = $nocrop = false; + $post = get_post( $post_id ); + + $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) ); + if ( is_wp_error( $img ) ) { + $return->error = esc_js( __('Unable to create new image.') ); + return $return; + } + + $fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; + $fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; + $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; + $scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; + + if ( $scale && $fwidth > 0 && $fheight > 0 ) { + $size = $img->get_size(); + $sX = $size['width']; + $sY = $size['height']; + + // Check if it has roughly the same w / h ratio. + $diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2); + if ( -0.1 < $diff && $diff < 0.1 ) { + // Scale the full size image. + if ( $img->resize( $fwidth, $fheight ) ) + $scaled = true; + } + + if ( !$scaled ) { + $return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') ); + return $return; + } + } elseif ( !empty($_REQUEST['history']) ) { + $changes = json_decode( wp_unslash($_REQUEST['history']) ); + if ( $changes ) + $img = image_edit_apply_changes($img, $changes); + } else { + $return->error = esc_js( __('Nothing to save, the image has not changed.') ); + return $return; + } + + $meta = wp_get_attachment_metadata($post_id); + $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); + + if ( !is_array($meta) ) { + $return->error = esc_js( __('Image data does not exist. Please re-upload the image.') ); + return $return; + } + + if ( !is_array($backup_sizes) ) + $backup_sizes = array(); + + // Generate new filename. + $path = get_attached_file( $post_id ); + + $basename = pathinfo( $path, PATHINFO_BASENAME ); + $dirname = pathinfo( $path, PATHINFO_DIRNAME ); + $ext = pathinfo( $path, PATHINFO_EXTENSION ); + $filename = pathinfo( $path, PATHINFO_FILENAME ); + $suffix = time() . rand(100, 999); + + if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && + isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $basename ) { + + if ( 'thumbnail' == $target ) { + $new_path = "{$dirname}/{$filename}-temp.{$ext}"; + } else { + $new_path = $path; + } + } else { + while ( true ) { + $filename = preg_replace( '/-e([0-9]+)$/', '', $filename ); + $filename .= "-e{$suffix}"; + $new_filename = "{$filename}.{$ext}"; + $new_path = "{$dirname}/$new_filename"; + if ( file_exists($new_path) ) { + $suffix++; + } else { + break; + } + } + } + + // Save the full-size file, also needed to create sub-sizes. + if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) { + $return->error = esc_js( __('Unable to save the image.') ); + return $return; + } + + if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) { + $tag = false; + if ( isset( $backup_sizes['full-orig'] ) ) { + if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) { + $tag = "full-$suffix"; + } + } else { + $tag = 'full-orig'; + } + + if ( $tag ) { + $backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $basename ); + } + $success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path ); + + $meta['file'] = _wp_relative_upload_path( $new_path ); + + $size = $img->get_size(); + $meta['width'] = $size['width']; + $meta['height'] = $size['height']; + + if ( $success && ('nothumb' == $target || 'all' == $target) ) { + $sizes = get_intermediate_image_sizes(); + if ( 'nothumb' == $target ) + $sizes = array_diff( $sizes, array('thumbnail') ); + } + + $return->fw = $meta['width']; + $return->fh = $meta['height']; + } elseif ( 'thumbnail' == $target ) { + $sizes = array( 'thumbnail' ); + $success = $delete = $nocrop = true; + } + + /* + * We need to remove any existing resized image files because + * a new crop or rotate could generate different sizes (and hence, filenames), + * keeping the new resized images from overwriting the existing image files. + * https://core.trac.wordpress.org/ticket/32171 + */ + if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && ! empty( $meta['sizes'] ) ) { + foreach ( $meta['sizes'] as $size ) { + if ( ! empty( $size['file'] ) && preg_match( '/-e[0-9]{13}-/', $size['file'] ) ) { + $delete_file = path_join( $dirname, $size['file'] ); + wp_delete_file( $delete_file ); + } + } + } + + if ( isset( $sizes ) ) { + $_sizes = array(); + + foreach ( $sizes as $size ) { + $tag = false; + if ( isset( $meta['sizes'][$size] ) ) { + if ( isset($backup_sizes["$size-orig"]) ) { + if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] ) + $tag = "$size-$suffix"; + } else { + $tag = "$size-orig"; + } + + if ( $tag ) + $backup_sizes[$tag] = $meta['sizes'][$size]; + } + + if ( isset( $_wp_additional_image_sizes[ $size ] ) ) { + $width = intval( $_wp_additional_image_sizes[ $size ]['width'] ); + $height = intval( $_wp_additional_image_sizes[ $size ]['height'] ); + $crop = ( $nocrop ) ? false : $_wp_additional_image_sizes[ $size ]['crop']; + } else { + $height = get_option( "{$size}_size_h" ); + $width = get_option( "{$size}_size_w" ); + $crop = ( $nocrop ) ? false : get_option( "{$size}_crop" ); + } + + $_sizes[ $size ] = array( 'width' => $width, 'height' => $height, 'crop' => $crop ); + } + + $meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) ); + } + + unset( $img ); + + if ( $success ) { + wp_update_attachment_metadata( $post_id, $meta ); + update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes); + + if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { + // Check if it's an image edit from attachment edit screen + if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) { + $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); + $return->thumbnail = $thumb_url[0]; + } else { + $file_url = wp_get_attachment_url($post_id); + if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) { + $return->thumbnail = path_join( dirname($file_url), $thumb['file'] ); + } else { + $return->thumbnail = "$file_url?w=128&h=128"; + } + } + } + } else { + $delete = true; + } + + if ( $delete ) { + wp_delete_file( $new_path ); + } + + $return->msg = esc_js( __('Image saved') ); + return $return; +} diff --git a/backend/wp-admin/includes/image.php b/backend/wp-admin/includes/image.php new file mode 100644 index 0000000..596aa79 --- /dev/null +++ b/backend/wp-admin/includes/image.php @@ -0,0 +1,699 @@ +crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs ); + if ( is_wp_error( $src ) ) + return $src; + + if ( ! $dst_file ) + $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); + + /* + * The directory containing the original file may no longer exist when + * using a replication plugin. + */ + wp_mkdir_p( dirname( $dst_file ) ); + + $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); + + $result = $editor->save( $dst_file ); + if ( is_wp_error( $result ) ) + return $result; + + return $dst_file; +} + +/** + * Generate post thumbnail attachment meta data. + * + * @since 2.1.0 + * + * @param int $attachment_id Attachment Id to process. + * @param string $file Filepath of the Attached image. + * @return mixed Metadata for attachment. + */ +function wp_generate_attachment_metadata( $attachment_id, $file ) { + $attachment = get_post( $attachment_id ); + + $metadata = array(); + $support = false; + $mime_type = get_post_mime_type( $attachment ); + + if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) { + $imagesize = getimagesize( $file ); + $metadata['width'] = $imagesize[0]; + $metadata['height'] = $imagesize[1]; + + // Make the file path relative to the upload dir. + $metadata['file'] = _wp_relative_upload_path($file); + + // Make thumbnails and other intermediate sizes. + $_wp_additional_image_sizes = wp_get_additional_image_sizes(); + + $sizes = array(); + foreach ( get_intermediate_image_sizes() as $s ) { + $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false ); + if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) { + // For theme-added sizes + $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); + } else { + // For default sizes set in options + $sizes[$s]['width'] = get_option( "{$s}_size_w" ); + } + + if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) { + // For theme-added sizes + $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); + } else { + // For default sizes set in options + $sizes[$s]['height'] = get_option( "{$s}_size_h" ); + } + + if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) { + // For theme-added sizes + $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; + } else { + // For default sizes set in options + $sizes[$s]['crop'] = get_option( "{$s}_crop" ); + } + } + + /** + * Filters the image sizes automatically generated when uploading an image. + * + * @since 2.9.0 + * @since 4.4.0 Added the `$metadata` argument. + * + * @param array $sizes An associative array of image sizes. + * @param array $metadata An associative array of image metadata: width, height, file. + */ + $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes, $metadata ); + + if ( $sizes ) { + $editor = wp_get_image_editor( $file ); + + if ( ! is_wp_error( $editor ) ) + $metadata['sizes'] = $editor->multi_resize( $sizes ); + } else { + $metadata['sizes'] = array(); + } + + // Fetch additional metadata from EXIF/IPTC. + $image_meta = wp_read_image_metadata( $file ); + if ( $image_meta ) + $metadata['image_meta'] = $image_meta; + + } elseif ( wp_attachment_is( 'video', $attachment ) ) { + $metadata = wp_read_video_metadata( $file ); + $support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' ); + } elseif ( wp_attachment_is( 'audio', $attachment ) ) { + $metadata = wp_read_audio_metadata( $file ); + $support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' ); + } + + if ( $support && ! empty( $metadata['image']['data'] ) ) { + // Check for existing cover. + $hash = md5( $metadata['image']['data'] ); + $posts = get_posts( array( + 'fields' => 'ids', + 'post_type' => 'attachment', + 'post_mime_type' => $metadata['image']['mime'], + 'post_status' => 'inherit', + 'posts_per_page' => 1, + 'meta_key' => '_cover_hash', + 'meta_value' => $hash + ) ); + $exists = reset( $posts ); + + if ( ! empty( $exists ) ) { + update_post_meta( $attachment_id, '_thumbnail_id', $exists ); + } else { + $ext = '.jpg'; + switch ( $metadata['image']['mime'] ) { + case 'image/gif': + $ext = '.gif'; + break; + case 'image/png': + $ext = '.png'; + break; + } + $basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext; + $uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] ); + if ( false === $uploaded['error'] ) { + $image_attachment = array( + 'post_mime_type' => $metadata['image']['mime'], + 'post_type' => 'attachment', + 'post_content' => '', + ); + /** + * Filters the parameters for the attachment thumbnail creation. + * + * @since 3.9.0 + * + * @param array $image_attachment An array of parameters to create the thumbnail. + * @param array $metadata Current attachment metadata. + * @param array $uploaded An array containing the thumbnail path and url. + */ + $image_attachment = apply_filters( 'attachment_thumbnail_args', $image_attachment, $metadata, $uploaded ); + + $sub_attachment_id = wp_insert_attachment( $image_attachment, $uploaded['file'] ); + add_post_meta( $sub_attachment_id, '_cover_hash', $hash ); + $attach_data = wp_generate_attachment_metadata( $sub_attachment_id, $uploaded['file'] ); + wp_update_attachment_metadata( $sub_attachment_id, $attach_data ); + update_post_meta( $attachment_id, '_thumbnail_id', $sub_attachment_id ); + } + } + } + // Try to create image thumbnails for PDFs + else if ( 'application/pdf' === $mime_type ) { + $fallback_sizes = array( + 'thumbnail', + 'medium', + 'large', + ); + + /** + * Filters the image sizes generated for non-image mime types. + * + * @since 4.7.0 + * + * @param array $fallback_sizes An array of image size names. + * @param array $metadata Current attachment metadata. + */ + $fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata ); + + $sizes = array(); + $_wp_additional_image_sizes = wp_get_additional_image_sizes(); + + foreach ( $fallback_sizes as $s ) { + if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) { + $sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] ); + } else { + $sizes[ $s ]['width'] = get_option( "{$s}_size_w" ); + } + + if ( isset( $_wp_additional_image_sizes[ $s ]['height'] ) ) { + $sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[ $s ]['height'] ); + } else { + $sizes[ $s ]['height'] = get_option( "{$s}_size_h" ); + } + + if ( isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ) { + $sizes[ $s ]['crop'] = $_wp_additional_image_sizes[ $s ]['crop']; + } else { + // Force thumbnails to be soft crops. + if ( 'thumbnail' !== $s ) { + $sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); + } + } + } + + // Only load PDFs in an image editor if we're processing sizes. + if ( ! empty( $sizes ) ) { + $editor = wp_get_image_editor( $file ); + + if ( ! is_wp_error( $editor ) ) { // No support for this type of file + /* + * PDFs may have the same file filename as JPEGs. + * Ensure the PDF preview image does not overwrite any JPEG images that already exist. + */ + $dirname = dirname( $file ) . '/'; + $ext = '.' . pathinfo( $file, PATHINFO_EXTENSION ); + $preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' ); + + $uploaded = $editor->save( $preview_file, 'image/jpeg' ); + unset( $editor ); + + // Resize based on the full size image, rather than the source. + if ( ! is_wp_error( $uploaded ) ) { + $editor = wp_get_image_editor( $uploaded['path'] ); + unset( $uploaded['path'] ); + + if ( ! is_wp_error( $editor ) ) { + $metadata['sizes'] = $editor->multi_resize( $sizes ); + $metadata['sizes']['full'] = $uploaded; + } + } + } + } + } + + // Remove the blob of binary data from the array. + if ( $metadata ) { + unset( $metadata['image']['data'] ); + } + + /** + * Filters the generated attachment meta data. + * + * @since 2.1.0 + * + * @param array $metadata An array of attachment meta data. + * @param int $attachment_id Current attachment ID. + */ + return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id ); +} + +/** + * Convert a fraction string to a decimal. + * + * @since 2.5.0 + * + * @param string $str + * @return int|float + */ +function wp_exif_frac2dec($str) { + @list( $n, $d ) = explode( '/', $str ); + if ( !empty($d) ) + return $n / $d; + return $str; +} + +/** + * Convert the exif date format to a unix timestamp. + * + * @since 2.5.0 + * + * @param string $str + * @return int + */ +function wp_exif_date2ts($str) { + @list( $date, $time ) = explode( ' ', trim($str) ); + @list( $y, $m, $d ) = explode( ':', $date ); + + return strtotime( "{$y}-{$m}-{$d} {$time}" ); +} + +/** + * Get extended image metadata, exif or iptc as available. + * + * Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso + * created_timestamp, focal_length, shutter_speed, and title. + * + * The IPTC metadata that is retrieved is APP13, credit, byline, created date + * and time, caption, copyright, and title. Also includes FNumber, Model, + * DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime. + * + * @todo Try other exif libraries if available. + * @since 2.5.0 + * + * @param string $file + * @return bool|array False on failure. Image metadata array on success. + */ +function wp_read_image_metadata( $file ) { + if ( ! file_exists( $file ) ) + return false; + + list( , , $sourceImageType ) = @getimagesize( $file ); + + /* + * EXIF contains a bunch of data we'll probably never need formatted in ways + * that are difficult to use. We'll normalize it and just extract the fields + * that are likely to be useful. Fractions and numbers are converted to + * floats, dates to unix timestamps, and everything else to strings. + */ + $meta = array( + 'aperture' => 0, + 'credit' => '', + 'camera' => '', + 'caption' => '', + 'created_timestamp' => 0, + 'copyright' => '', + 'focal_length' => 0, + 'iso' => 0, + 'shutter_speed' => 0, + 'title' => '', + 'orientation' => 0, + 'keywords' => array(), + ); + + $iptc = array(); + /* + * Read IPTC first, since it might contain data not available in exif such + * as caption, description etc. + */ + if ( is_callable( 'iptcparse' ) ) { + @getimagesize( $file, $info ); + + if ( ! empty( $info['APP13'] ) ) { + $iptc = @iptcparse( $info['APP13'] ); + + // Headline, "A brief synopsis of the caption." + if ( ! empty( $iptc['2#105'][0] ) ) { + $meta['title'] = trim( $iptc['2#105'][0] ); + /* + * Title, "Many use the Title field to store the filename of the image, + * though the field may be used in many ways." + */ + } elseif ( ! empty( $iptc['2#005'][0] ) ) { + $meta['title'] = trim( $iptc['2#005'][0] ); + } + + if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption + $caption = trim( $iptc['2#120'][0] ); + + mbstring_binary_safe_encoding(); + $caption_length = strlen( $caption ); + reset_mbstring_encoding(); + + if ( empty( $meta['title'] ) && $caption_length < 80 ) { + // Assume the title is stored in 2:120 if it's short. + $meta['title'] = $caption; + } + + $meta['caption'] = $caption; + } + + if ( ! empty( $iptc['2#110'][0] ) ) // credit + $meta['credit'] = trim( $iptc['2#110'][0] ); + elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline + $meta['credit'] = trim( $iptc['2#080'][0] ); + + if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) // created date and time + $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] ); + + if ( ! empty( $iptc['2#116'][0] ) ) // copyright + $meta['copyright'] = trim( $iptc['2#116'][0] ); + + if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array + $meta['keywords'] = array_values( $iptc['2#025'] ); + } + } + } + + /** + * Filters the image types to check for exif data. + * + * @since 2.5.0 + * + * @param array $image_types Image types to check for exif data. + */ + if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) { + $exif = @exif_read_data( $file ); + + if ( ! empty( $exif['ImageDescription'] ) ) { + mbstring_binary_safe_encoding(); + $description_length = strlen( $exif['ImageDescription'] ); + reset_mbstring_encoding(); + + if ( empty( $meta['title'] ) && $description_length < 80 ) { + // Assume the title is stored in ImageDescription + $meta['title'] = trim( $exif['ImageDescription'] ); + } + + if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) { + $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] ); + } + + if ( empty( $meta['caption'] ) ) { + $meta['caption'] = trim( $exif['ImageDescription'] ); + } + } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) { + $meta['caption'] = trim( $exif['Comments'] ); + } + + if ( empty( $meta['credit'] ) ) { + if ( ! empty( $exif['Artist'] ) ) { + $meta['credit'] = trim( $exif['Artist'] ); + } elseif ( ! empty($exif['Author'] ) ) { + $meta['credit'] = trim( $exif['Author'] ); + } + } + + if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) { + $meta['copyright'] = trim( $exif['Copyright'] ); + } + if ( ! empty( $exif['FNumber'] ) ) { + $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); + } + if ( ! empty( $exif['Model'] ) ) { + $meta['camera'] = trim( $exif['Model'] ); + } + if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) { + $meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] ); + } + if ( ! empty( $exif['FocalLength'] ) ) { + $meta['focal_length'] = (string) wp_exif_frac2dec( $exif['FocalLength'] ); + } + if ( ! empty( $exif['ISOSpeedRatings'] ) ) { + $meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings']; + $meta['iso'] = trim( $meta['iso'] ); + } + if ( ! empty( $exif['ExposureTime'] ) ) { + $meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] ); + } + if ( ! empty( $exif['Orientation'] ) ) { + $meta['orientation'] = $exif['Orientation']; + } + } + + foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) { + if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) { + $meta[ $key ] = utf8_encode( $meta[ $key ] ); + } + } + + foreach ( $meta['keywords'] as $key => $keyword ) { + if ( ! seems_utf8( $keyword ) ) { + $meta['keywords'][ $key ] = utf8_encode( $keyword ); + } + } + + $meta = wp_kses_post_deep( $meta ); + + /** + * Filters the array of meta data read from an image's exif data. + * + * @since 2.5.0 + * @since 4.4.0 The `$iptc` parameter was added. + * + * @param array $meta Image meta data. + * @param string $file Path to image file. + * @param int $sourceImageType Type of image. + * @param array $iptc IPTC data. + */ + return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc ); + +} + +/** + * Validate that file is an image. + * + * @since 2.5.0 + * + * @param string $path File path to test if valid image. + * @return bool True if valid image, false if not valid image. + */ +function file_is_valid_image($path) { + $size = @getimagesize($path); + return !empty($size); +} + +/** + * Validate that file is suitable for displaying within a web page. + * + * @since 2.5.0 + * + * @param string $path File path to test. + * @return bool True if suitable, false if not suitable. + */ +function file_is_displayable_image($path) { + $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP ); + + $info = @getimagesize( $path ); + if ( empty( $info ) ) { + $result = false; + } elseif ( ! in_array( $info[2], $displayable_image_types ) ) { + $result = false; + } else { + $result = true; + } + + /** + * Filters whether the current image is displayable in the browser. + * + * @since 2.5.0 + * + * @param bool $result Whether the image can be displayed. Default true. + * @param string $path Path to the image. + */ + return apply_filters( 'file_is_displayable_image', $result, $path ); +} + +/** + * Load an image resource for editing. + * + * @since 2.9.0 + * + * @param string $attachment_id Attachment ID. + * @param string $mime_type Image mime type. + * @param string $size Optional. Image size, defaults to 'full'. + * @return resource|false The resulting image resource on success, false on failure. + */ +function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) { + $filepath = _load_image_to_edit_path( $attachment_id, $size ); + if ( empty( $filepath ) ) + return false; + + switch ( $mime_type ) { + case 'image/jpeg': + $image = imagecreatefromjpeg($filepath); + break; + case 'image/png': + $image = imagecreatefrompng($filepath); + break; + case 'image/gif': + $image = imagecreatefromgif($filepath); + break; + default: + $image = false; + break; + } + if ( is_resource($image) ) { + /** + * Filters the current image being loaded for editing. + * + * @since 2.9.0 + * + * @param resource $image Current image. + * @param string $attachment_id Attachment ID. + * @param string $size Image size. + */ + $image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size ); + if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) { + imagealphablending($image, false); + imagesavealpha($image, true); + } + } + return $image; +} + +/** + * Retrieve the path or url of an attachment's attached file. + * + * If the attached file is not present on the local filesystem (usually due to replication plugins), + * then the url of the file is returned if url fopen is supported. + * + * @since 3.4.0 + * @access private + * + * @param string $attachment_id Attachment ID. + * @param string $size Optional. Image size, defaults to 'full'. + * @return string|false File path or url on success, false on failure. + */ +function _load_image_to_edit_path( $attachment_id, $size = 'full' ) { + $filepath = get_attached_file( $attachment_id ); + + if ( $filepath && file_exists( $filepath ) ) { + if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) { + /** + * Filters the path to the current image. + * + * The filter is evaluated for all image sizes except 'full'. + * + * @since 3.1.0 + * + * @param string $path Path to the current image. + * @param string $attachment_id Attachment ID. + * @param string $size Size of the image. + */ + $filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size ); + } + } elseif ( function_exists( 'fopen' ) && true == ini_get( 'allow_url_fopen' ) ) { + /** + * Filters the image URL if not in the local filesystem. + * + * The filter is only evaluated if fopen is enabled on the server. + * + * @since 3.1.0 + * + * @param string $image_url Current image URL. + * @param string $attachment_id Attachment ID. + * @param string $size Size of the image. + */ + $filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size ); + } + + /** + * Filters the returned path or URL of the current image. + * + * @since 2.9.0 + * + * @param string|bool $filepath File path or URL to current image, or false. + * @param string $attachment_id Attachment ID. + * @param string $size Size of the image. + */ + return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size ); +} + +/** + * Copy an existing image file. + * + * @since 3.4.0 + * @access private + * + * @param string $attachment_id Attachment ID. + * @return string|false New file path on success, false on failure. + */ +function _copy_image_file( $attachment_id ) { + $dst_file = $src_file = get_attached_file( $attachment_id ); + if ( ! file_exists( $src_file ) ) + $src_file = _load_image_to_edit_path( $attachment_id ); + + if ( $src_file ) { + $dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file ); + $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); + + /* + * The directory containing the original file may no longer + * exist when using a replication plugin. + */ + wp_mkdir_p( dirname( $dst_file ) ); + + if ( ! @copy( $src_file, $dst_file ) ) + $dst_file = false; + } else { + $dst_file = false; + } + + return $dst_file; +} diff --git a/backend/wp-admin/includes/import.php b/backend/wp-admin/includes/import.php new file mode 100644 index 0000000..ca12dfa --- /dev/null +++ b/backend/wp-admin/includes/import.php @@ -0,0 +1,217 @@ + __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) + ); + } + + $overrides = array( 'test_form' => false, 'test_type' => false ); + $_FILES['import']['name'] .= '.txt'; + $upload = wp_handle_upload( $_FILES['import'], $overrides ); + + if ( isset( $upload['error'] ) ) { + return $upload; + } + + // Construct the object array + $object = array( + 'post_title' => basename( $upload['file'] ), + 'post_content' => $upload['url'], + 'post_mime_type' => $upload['type'], + 'guid' => $upload['url'], + 'context' => 'import', + 'post_status' => 'private' + ); + + // Save the data + $id = wp_insert_attachment( $object, $upload['file'] ); + + /* + * Schedule a cleanup for one day from now in case of failed + * import or missing wp_import_cleanup() call. + */ + wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); + + return array( 'file' => $upload['file'], 'id' => $id ); +} + +/** + * Returns a list from WordPress.org of popular importer plugins. + * + * @since 3.5.0 + * + * @return array Importers with metadata for each. + */ +function wp_get_popular_importers() { + include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version + + $locale = get_user_locale(); + $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); + $popular_importers = get_site_transient( $cache_key ); + + if ( ! $popular_importers ) { + $url = add_query_arg( array( + 'locale' => $locale, + 'version' => $wp_version, + ), 'http://api.wordpress.org/core/importers/1.1/' ); + $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ); + + if ( wp_http_supports( array( 'ssl' ) ) ) { + $url = set_url_scheme( $url, 'https' ); + } + + $response = wp_remote_get( $url, $options ); + $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( is_array( $popular_importers ) ) { + set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS ); + } else { + $popular_importers = false; + } + } + + if ( is_array( $popular_importers ) ) { + // If the data was received as translated, return it as-is. + if ( $popular_importers['translated'] ) + return $popular_importers['importers']; + + foreach ( $popular_importers['importers'] as &$importer ) { + $importer['description'] = translate( $importer['description'] ); + if ( $importer['name'] != 'WordPress' ) + $importer['name'] = translate( $importer['name'] ); + } + return $popular_importers['importers']; + } + + return array( + // slug => name, description, plugin slug, and register_importer() slug + 'blogger' => array( + 'name' => __( 'Blogger' ), + 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), + 'plugin-slug' => 'blogger-importer', + 'importer-id' => 'blogger', + ), + 'wpcat2tag' => array( + 'name' => __( 'Categories and Tags Converter' ), + 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), + 'plugin-slug' => 'wpcat2tag-importer', + 'importer-id' => 'wp-cat2tag', + ), + 'livejournal' => array( + 'name' => __( 'LiveJournal' ), + 'description' => __( 'Import posts from LiveJournal using their API.' ), + 'plugin-slug' => 'livejournal-importer', + 'importer-id' => 'livejournal', + ), + 'movabletype' => array( + 'name' => __( 'Movable Type and TypePad' ), + 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), + 'plugin-slug' => 'movabletype-importer', + 'importer-id' => 'mt', + ), + 'opml' => array( + 'name' => __( 'Blogroll' ), + 'description' => __( 'Import links in OPML format.' ), + 'plugin-slug' => 'opml-importer', + 'importer-id' => 'opml', + ), + 'rss' => array( + 'name' => __( 'RSS' ), + 'description' => __( 'Import posts from an RSS feed.' ), + 'plugin-slug' => 'rss-importer', + 'importer-id' => 'rss', + ), + 'tumblr' => array( + 'name' => __( 'Tumblr' ), + 'description' => __( 'Import posts & media from Tumblr using their API.' ), + 'plugin-slug' => 'tumblr-importer', + 'importer-id' => 'tumblr', + ), + 'wordpress' => array( + 'name' => 'WordPress', + 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), + 'plugin-slug' => 'wordpress-importer', + 'importer-id' => 'wordpress', + ), + ); +} diff --git a/backend/wp-admin/includes/list-table.php b/backend/wp-admin/includes/list-table.php new file mode 100644 index 0000000..e4c66d1 --- /dev/null +++ b/backend/wp-admin/includes/list-table.php @@ -0,0 +1,84 @@ + 'posts', + 'WP_Media_List_Table' => 'media', + 'WP_Terms_List_Table' => 'terms', + 'WP_Users_List_Table' => 'users', + 'WP_Comments_List_Table' => 'comments', + 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ), + 'WP_Links_List_Table' => 'links', + 'WP_Plugin_Install_List_Table' => 'plugin-install', + 'WP_Themes_List_Table' => 'themes', + 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), + 'WP_Plugins_List_Table' => 'plugins', + // Network Admin + 'WP_MS_Sites_List_Table' => 'ms-sites', + 'WP_MS_Users_List_Table' => 'ms-users', + 'WP_MS_Themes_List_Table' => 'ms-themes', + ); + + if ( isset( $core_classes[ $class ] ) ) { + foreach ( (array) $core_classes[ $class ] as $required ) + require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); + + if ( isset( $args['screen'] ) ) + $args['screen'] = convert_to_screen( $args['screen'] ); + elseif ( isset( $GLOBALS['hook_suffix'] ) ) + $args['screen'] = get_current_screen(); + else + $args['screen'] = null; + + return new $class( $args ); + } + + return false; +} + +/** + * Register column headers for a particular screen. + * + * @since 2.7.0 + * + * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. + * @param array $columns An array of columns with column IDs as the keys and translated column names as the values + * @see get_column_headers(), print_column_headers(), get_hidden_columns() + */ +function register_column_headers($screen, $columns) { + new _WP_List_Table_Compat( $screen, $columns ); +} + +/** + * Prints column headers for a particular screen. + * + * @since 2.7.0 + * + * @param string|WP_Screen $screen The screen hook name or screen object. + * @param bool $with_id Whether to set the id attribute or not. + */ +function print_column_headers( $screen, $with_id = true ) { + $wp_list_table = new _WP_List_Table_Compat($screen); + + $wp_list_table->print_column_headers( $with_id ); +} diff --git a/backend/wp-admin/includes/media.php b/backend/wp-admin/includes/media.php new file mode 100644 index 0000000..aa9b7dd --- /dev/null +++ b/backend/wp-admin/includes/media.php @@ -0,0 +1,3266 @@ + __('From Computer'), // handler action suffix => tab text + 'type_url' => __('From URL'), + 'gallery' => __('Gallery'), + 'library' => __('Media Library') + ); + + /** + * Filters the available tabs in the legacy (pre-3.5.0) media popup. + * + * @since 2.5.0 + * + * @param array $_default_tabs An array of media tabs. + */ + return apply_filters( 'media_upload_tabs', $_default_tabs ); +} + +/** + * Adds the gallery tab back to the tabs array if post has image attachments + * + * @since 2.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $tabs + * @return array $tabs with gallery if post has image attachment + */ +function update_gallery_tab($tabs) { + global $wpdb; + + if ( !isset($_REQUEST['post_id']) ) { + unset($tabs['gallery']); + return $tabs; + } + + $post_id = intval($_REQUEST['post_id']); + + if ( $post_id ) + $attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) ); + + if ( empty($attachments) ) { + unset($tabs['gallery']); + return $tabs; + } + + $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); + + return $tabs; +} + +/** + * Outputs the legacy media upload tabs UI. + * + * @since 2.5.0 + * + * @global string $redir_tab + */ +function the_media_upload_tabs() { + global $redir_tab; + $tabs = media_upload_tabs(); + $default = 'type'; + + if ( !empty($tabs) ) { + echo "
      \n"; + if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) { + $current = $redir_tab; + } elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) { + $current = $_GET['tab']; + } else { + /** This filter is documented in wp-admin/media-upload.php */ + $current = apply_filters( 'media_upload_default_tab', $default ); + } + + foreach ( $tabs as $callback => $text ) { + $class = ''; + + if ( $current == $callback ) + $class = " class='current'"; + + $href = add_query_arg(array('tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false)); + $link = "$text"; + echo "\t
    • $link
    • \n"; + } + echo "
    \n"; + } +} + +/** + * Retrieves the image HTML to send to the editor. + * + * @since 2.5.0 + * + * @param int $id Image attachment id. + * @param string $caption Image caption. + * @param string $title Image title attribute. + * @param string $align Image CSS alignment property. + * @param string $url Optional. Image src URL. Default empty. + * @param bool|string $rel Optional. Value for rel attribute or whether to add a default value. Default false. + * @param string|array $size Optional. Image size. Accepts any valid image size, or an array of width + * and height values in pixels (in that order). Default 'medium'. + * @param string $alt Optional. Image alt attribute. Default empty. + * @return string The HTML output to insert into the editor. + */ +function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $rel = false, $size = 'medium', $alt = '' ) { + + $html = get_image_tag( $id, $alt, '', $align, $size ); + + if ( $rel ) { + if ( is_string( $rel ) ) { + $rel = ' rel="' . esc_attr( $rel ) . '"'; + } else { + $rel = ' rel="attachment wp-att-' . intval( $id ) . '"'; + } + } else { + $rel = ''; + } + + if ( $url ) + $html = '' . $html . ''; + + /** + * Filters the image HTML markup to send to the editor when inserting an image. + * + * @since 2.5.0 + * + * @param string $html The image HTML markup to send. + * @param int $id The attachment id. + * @param string $caption The image caption. + * @param string $title The image title. + * @param string $align The image alignment. + * @param string $url The image source URL. + * @param string|array $size Size of image. Image size or array of width and height values + * (in that order). Default 'medium'. + * @param string $alt The image alternative, or alt, text. + */ + $html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt ); + + return $html; +} + +/** + * Adds image shortcode with caption to editor + * + * @since 2.6.0 + * + * @param string $html + * @param integer $id + * @param string $caption image caption + * @param string $title image title attribute + * @param string $align image css alignment property + * @param string $url image src url + * @param string $size image size (thumbnail, medium, large, full or added with add_image_size() ) + * @param string $alt image alt attribute + * @return string + */ +function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { + + /** + * Filters the caption text. + * + * Note: If the caption text is empty, the caption shortcode will not be appended + * to the image HTML when inserted into the editor. + * + * Passing an empty value also prevents the {@see 'image_add_caption_shortcode'} + * Filters from being evaluated at the end of image_add_caption(). + * + * @since 4.1.0 + * + * @param string $caption The original caption text. + * @param int $id The attachment ID. + */ + $caption = apply_filters( 'image_add_caption_text', $caption, $id ); + + /** + * Filters whether to disable captions. + * + * Prevents image captions from being appended to image HTML when inserted into the editor. + * + * @since 2.6.0 + * + * @param bool $bool Whether to disable appending captions. Returning true to the filter + * will disable captions. Default empty string. + */ + if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) + return $html; + + $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; + + if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) + return $html; + + $width = $matches[1]; + + $caption = str_replace( array("\r\n", "\r"), "\n", $caption); + $caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); + + // Convert any remaining line breaks to
    . + $caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '
    ', $caption ); + + $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); + if ( empty($align) ) + $align = 'none'; + + $shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]'; + + /** + * Filters the image HTML markup including the caption shortcode. + * + * @since 2.6.0 + * + * @param string $shcode The image HTML markup with caption shortcode. + * @param string $html The image HTML markup. + */ + return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); +} + +/** + * Private preg_replace callback used in image_add_caption() + * + * @access private + * @since 3.4.0 + */ +function _cleanup_image_add_caption( $matches ) { + // Remove any line breaks from inside the tags. + return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); +} + +/** + * Adds image html to editor + * + * @since 2.5.0 + * + * @param string $html + */ +function media_send_to_editor($html) { +?> + + false )) { + + $time = current_time('mysql'); + if ( $post = get_post($post_id) ) { + // The post date doesn't usually matter for pages, so don't backdate this upload. + if ( 'page' !== $post->post_type && substr( $post->post_date, 0, 4 ) > 0 ) + $time = $post->post_date; + } + + $file = wp_handle_upload($_FILES[$file_id], $overrides, $time); + + if ( isset($file['error']) ) + return new WP_Error( 'upload_error', $file['error'] ); + + $name = $_FILES[$file_id]['name']; + $ext = pathinfo( $name, PATHINFO_EXTENSION ); + $name = wp_basename( $name, ".$ext" ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = sanitize_text_field( $name ); + $content = ''; + $excerpt = ''; + + if ( preg_match( '#^audio#', $type ) ) { + $meta = wp_read_audio_metadata( $file ); + + if ( ! empty( $meta['title'] ) ) { + $title = $meta['title']; + } + + if ( ! empty( $title ) ) { + + if ( ! empty( $meta['album'] ) && ! empty( $meta['artist'] ) ) { + /* translators: 1: audio track title, 2: album title, 3: artist name */ + $content .= sprintf( __( '"%1$s" from %2$s by %3$s.' ), $title, $meta['album'], $meta['artist'] ); + } elseif ( ! empty( $meta['album'] ) ) { + /* translators: 1: audio track title, 2: album title */ + $content .= sprintf( __( '"%1$s" from %2$s.' ), $title, $meta['album'] ); + } elseif ( ! empty( $meta['artist'] ) ) { + /* translators: 1: audio track title, 2: artist name */ + $content .= sprintf( __( '"%1$s" by %2$s.' ), $title, $meta['artist'] ); + } else { + /* translators: 1: audio track title */ + $content .= sprintf( __( '"%s".' ), $title ); + } + + } elseif ( ! empty( $meta['album'] ) ) { + + if ( ! empty( $meta['artist'] ) ) { + /* translators: 1: audio album title, 2: artist name */ + $content .= sprintf( __( '%1$s by %2$s.' ), $meta['album'], $meta['artist'] ); + } else { + $content .= $meta['album'] . '.'; + } + + } elseif ( ! empty( $meta['artist'] ) ) { + + $content .= $meta['artist'] . '.'; + + } + + if ( ! empty( $meta['year'] ) ) { + /* translators: Audio file track information. 1: Year of audio track release */ + $content .= ' ' . sprintf( __( 'Released: %d.' ), $meta['year'] ); + } + + if ( ! empty( $meta['track_number'] ) ) { + $track_number = explode( '/', $meta['track_number'] ); + if ( isset( $track_number[1] ) ) { + /* translators: Audio file track information. 1: Audio track number, 2: Total audio tracks */ + $content .= ' ' . sprintf( __( 'Track %1$s of %2$s.' ), number_format_i18n( $track_number[0] ), number_format_i18n( $track_number[1] ) ); + } else { + /* translators: Audio file track information. 1: Audio track number */ + $content .= ' ' . sprintf( __( 'Track %1$s.' ), number_format_i18n( $track_number[0] ) ); + } + } + + if ( ! empty( $meta['genre'] ) ) { + /* translators: Audio file genre information. 1: Audio genre name */ + $content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] ); + } + + // Use image exif/iptc data for title and caption defaults if possible. + } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) { + if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { + $title = $image_meta['title']; + } + + if ( trim( $image_meta['caption'] ) ) { + $excerpt = $image_meta['caption']; + } + } + + // Construct the attachment array + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + 'post_excerpt' => $excerpt, + ), $post_data ); + + // This should never be set as it would then overwrite an existing attachment. + unset( $attachment['ID'] ); + + // Save the data + $id = wp_insert_attachment( $attachment, $file, $post_id, true ); + if ( !is_wp_error($id) ) { + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + } + + return $id; + +} + +/** + * Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload(). + * + * @since 2.6.0 + * + * @param array $file_array Array similar to a `$_FILES` upload array. + * @param int $post_id The post ID the media is associated with. + * @param string $desc Optional. Description of the side-loaded file. Default null. + * @param array $post_data Optional. Post data to override. Default empty array. + * @return int|object The ID of the attachment or a WP_Error on failure. + */ +function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) { + $overrides = array('test_form'=>false); + + $time = current_time( 'mysql' ); + if ( $post = get_post( $post_id ) ) { + if ( substr( $post->post_date, 0, 4 ) > 0 ) + $time = $post->post_date; + } + + $file = wp_handle_sideload( $file_array, $overrides, $time ); + if ( isset($file['error']) ) + return new WP_Error( 'upload_error', $file['error'] ); + + $url = $file['url']; + $type = $file['type']; + $file = $file['file']; + $title = preg_replace('/\.[^.]+$/', '', basename($file)); + $content = ''; + + // Use image exif/iptc data for title and caption defaults if possible. + if ( $image_meta = wp_read_image_metadata( $file ) ) { + if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) + $title = $image_meta['title']; + if ( trim( $image_meta['caption'] ) ) + $content = $image_meta['caption']; + } + + if ( isset( $desc ) ) + $title = $desc; + + // Construct the attachment array. + $attachment = array_merge( array( + 'post_mime_type' => $type, + 'guid' => $url, + 'post_parent' => $post_id, + 'post_title' => $title, + 'post_content' => $content, + ), $post_data ); + + // This should never be set as it would then overwrite an existing attachment. + unset( $attachment['ID'] ); + + // Save the attachment metadata + $id = wp_insert_attachment($attachment, $file, $post_id); + if ( !is_wp_error($id) ) + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); + + return $id; +} + +/** + * Adds the iframe to display content for the media upload page + * + * @since 2.5.0 + * + * @global int $body_id + * + * @param string|callable $content_func + */ +function wp_iframe($content_func /* ... */) { + _wp_admin_html_begin(); +?> +<?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?> + + + + + class="wp-core-ui no-js"> + + + + + + $post + ) ); + + $img = ' '; + + $id_attribute = $instance === 1 ? ' id="insert-media-button"' : ''; + printf( '', + $id_attribute, + esc_attr( $editor_id ), + $img . __( 'Add Media' ) + ); + /** + * Filters the legacy (pre-3.5.0) media buttons. + * + * Use {@see 'media_buttons'} action instead. + * + * @since 2.5.0 + * @deprecated 3.5.0 Use {@see 'media_buttons'} action instead. + * + * @param string $string Media buttons context. Default empty. + */ + $legacy_filter = apply_filters( 'media_buttons_context', '' ); + + if ( $legacy_filter ) { + // #WP22559. Close if a plugin started by closing to open their own tag. + if ( 0 === stripos( trim( $legacy_filter ), '' ) ) + $legacy_filter .= ''; + echo $legacy_filter; + } +} + +/** + * + * @global int $post_ID + * @param string $type + * @param int $post_id + * @param string $tab + * @return string + */ +function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { + global $post_ID; + + if ( empty( $post_id ) ) + $post_id = $post_ID; + + $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') ); + + if ( $type && 'media' != $type ) + $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); + + if ( ! empty( $tab ) ) + $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); + + /** + * Filters the upload iframe source URL for a specific media type. + * + * The dynamic portion of the hook name, `$type`, refers to the type + * of media uploaded. + * + * @since 3.0.0 + * + * @param string $upload_iframe_src The upload iframe source URL by type. + */ + $upload_iframe_src = apply_filters( "{$type}_upload_iframe_src", $upload_iframe_src ); + + return add_query_arg('TB_iframe', true, $upload_iframe_src); +} + +/** + * Handles form submissions for the legacy media uploader. + * + * @since 2.5.0 + * + * @return mixed void|object WP_Error on failure + */ +function media_upload_form_handler() { + check_admin_referer('media-form'); + + $errors = null; + + if ( isset($_POST['send']) ) { + $keys = array_keys( $_POST['send'] ); + $send_id = (int) reset( $keys ); + } + + if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { + $post = $_post = get_post($attachment_id, ARRAY_A); + + if ( !current_user_can( 'edit_post', $attachment_id ) ) + continue; + + if ( isset($attachment['post_content']) ) + $post['post_content'] = $attachment['post_content']; + if ( isset($attachment['post_title']) ) + $post['post_title'] = $attachment['post_title']; + if ( isset($attachment['post_excerpt']) ) + $post['post_excerpt'] = $attachment['post_excerpt']; + if ( isset($attachment['menu_order']) ) + $post['menu_order'] = $attachment['menu_order']; + + if ( isset($send_id) && $attachment_id == $send_id ) { + if ( isset($attachment['post_parent']) ) + $post['post_parent'] = $attachment['post_parent']; + } + + /** + * Filters the attachment fields to be saved. + * + * @since 2.5.0 + * + * @see wp_get_attachment_metadata() + * + * @param array $post An array of post data. + * @param array $attachment An array of attachment metadata. + */ + $post = apply_filters( 'attachment_fields_to_save', $post, $attachment ); + + if ( isset($attachment['image_alt']) ) { + $image_alt = wp_unslash( $attachment['image_alt'] ); + if ( $image_alt != get_post_meta($attachment_id, '_wp_attachment_image_alt', true) ) { + $image_alt = wp_strip_all_tags( $image_alt, true ); + + // Update_meta expects slashed. + update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); + } + } + + if ( isset($post['errors']) ) { + $errors[$attachment_id] = $post['errors']; + unset($post['errors']); + } + + if ( $post != $_post ) + wp_update_post($post); + + foreach ( get_attachment_taxonomies($post) as $t ) { + if ( isset($attachment[$t]) ) + wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); + } + } + + if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?> + + $html"; + } + + /** + * Filters the HTML markup for a media item sent to the editor. + * + * @since 2.5.0 + * + * @see wp_get_attachment_metadata() + * + * @param string $html HTML markup for a media item sent to the editor. + * @param int $send_id The first key from the $_POST['send'] data. + * @param array $attachment Array of attachment metadata. + */ + $html = apply_filters( 'media_send_to_editor', $html, $send_id, $attachment ); + return media_send_to_editor($html); + } + + return $errors; +} + +/** + * Handles the process of uploading media. + * + * @since 2.5.0 + * + * @return null|string + */ +function wp_media_upload_handler() { + $errors = array(); + $id = 0; + + if ( isset($_POST['html-upload']) && !empty($_FILES) ) { + check_admin_referer('media-form'); + // Upload File button was clicked + $id = media_handle_upload('async-upload', $_REQUEST['post_id']); + unset($_FILES); + if ( is_wp_error($id) ) { + $errors['upload_error'] = $id; + $id = false; + } + } + + if ( !empty($_POST['insertonlybutton']) ) { + $src = $_POST['src']; + if ( !empty($src) && !strpos($src, '://') ) + $src = "http://$src"; + + if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) { + $title = esc_html( wp_unslash( $_POST['title'] ) ); + if ( empty( $title ) ) + $title = esc_html( basename( $src ) ); + + if ( $title && $src ) + $html = "$title"; + + $type = 'file'; + if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) + && ( 'audio' == $ext_type || 'video' == $ext_type ) ) + $type = $ext_type; + + /** + * Filters the URL sent to the editor for a specific media type. + * + * The dynamic portion of the hook name, `$type`, refers to the type + * of media being sent. + * + * @since 3.3.0 + * + * @param string $html HTML markup sent to the editor. + * @param string $src Media source URL. + * @param string $title Media title. + */ + $html = apply_filters( "{$type}_send_to_editor_url", $html, esc_url_raw( $src ), $title ); + } else { + $align = ''; + $alt = esc_attr( wp_unslash( $_POST['alt'] ) ); + if ( isset($_POST['align']) ) { + $align = esc_attr( wp_unslash( $_POST['align'] ) ); + $class = " class='align$align'"; + } + if ( !empty($src) ) + $html = "$alt"; + + /** + * Filters the image URL sent to the editor. + * + * @since 2.8.0 + * + * @param string $html HTML markup sent to the editor for an image. + * @param string $src Image source URL. + * @param string $alt Image alternate, or alt, text. + * @param string $align The image alignment. Default 'alignnone'. Possible values include + * 'alignleft', 'aligncenter', 'alignright', 'alignnone'. + */ + $html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align ); + } + + return media_send_to_editor($html); + } + + if ( isset( $_POST['save'] ) ) { + $errors['upload_notice'] = __('Saved.'); + wp_enqueue_script( 'admin-gallery' ); + return wp_iframe( 'media_upload_gallery_form', $errors ); + + } elseif ( ! empty( $_POST ) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) { + $type = 'image'; + if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) + $type = $_GET['type']; + return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id ); + } + + return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); +} + +/** + * Downloads an image from the specified URL and attaches it to a post. + * + * @since 2.6.0 + * @since 4.2.0 Introduced the `$return` parameter. + * @since 4.8.0 Introduced the 'id' option within the `$return` parameter. + * + * @param string $file The URL of the image to download. + * @param int $post_id The post ID the media is to be associated with. + * @param string $desc Optional. Description of the image. + * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'. + * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. + */ +function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { + if ( ! empty( $file ) ) { + + // Set variables for storage, fix file filename for query strings. + preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); + if ( ! $matches ) { + return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) ); + } + + $file_array = array(); + $file_array['name'] = basename( $matches[0] ); + + // Download file to temp location. + $file_array['tmp_name'] = download_url( $file ); + + // If error storing temporarily, return the error. + if ( is_wp_error( $file_array['tmp_name'] ) ) { + return $file_array['tmp_name']; + } + + // Do the validation and storage stuff. + $id = media_handle_sideload( $file_array, $post_id, $desc ); + + // If error storing permanently, unlink. + if ( is_wp_error( $id ) ) { + @unlink( $file_array['tmp_name'] ); + return $id; + // If attachment id was requested, return it early. + } elseif ( $return === 'id' ) { + return $id; + } + + $src = wp_get_attachment_url( $id ); + } + + // Finally, check to make sure the file has been saved, then return the HTML. + if ( ! empty( $src ) ) { + if ( $return === 'src' ) { + return $src; + } + + $alt = isset( $desc ) ? esc_attr( $desc ) : ''; + $html = "$alt"; + return $html; + } else { + return new WP_Error( 'image_sideload_failed' ); + } +} + +/** + * Retrieves the legacy media uploader form in an iframe. + * + * @since 2.5.0 + * + * @return string|null + */ +function media_upload_gallery() { + $errors = array(); + + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + wp_enqueue_script('admin-gallery'); + return wp_iframe( 'media_upload_gallery_form', $errors ); +} + +/** + * Retrieves the legacy media library form in an iframe. + * + * @since 2.5.0 + * + * @return string|null + */ +function media_upload_library() { + $errors = array(); + if ( !empty($_POST) ) { + $return = media_upload_form_handler(); + + if ( is_string($return) ) + return $return; + if ( is_array($return) ) + $errors = $return; + } + + return wp_iframe( 'media_upload_library_form', $errors ); +} + +/** + * Retrieve HTML for the image alignment radio buttons with the specified one checked. + * + * @since 2.7.0 + * + * @param WP_Post $post + * @param string $checked + * @return string + */ +function image_align_input_fields( $post, $checked = '' ) { + + if ( empty($checked) ) + $checked = get_user_setting('align', 'none'); + + $alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right')); + if ( !array_key_exists( (string) $checked, $alignments ) ) + $checked = 'none'; + + $out = array(); + foreach ( $alignments as $name => $label ) { + $name = esc_attr($name); + $out[] = ""; + } + return join("\n", $out); +} + +/** + * Retrieve HTML for the size radio buttons with the specified one checked. + * + * @since 2.7.0 + * + * @param WP_Post $post + * @param bool|string $check + * @return array + */ +function image_size_input_fields( $post, $check = '' ) { + /** + * Filters the names and labels of the default image sizes. + * + * @since 3.3.0 + * + * @param array $size_names Array of image sizes and their names. Default values + * include 'Thumbnail', 'Medium', 'Large', 'Full Size'. + */ + $size_names = apply_filters( 'image_size_names_choose', array( + 'thumbnail' => __( 'Thumbnail' ), + 'medium' => __( 'Medium' ), + 'large' => __( 'Large' ), + 'full' => __( 'Full Size' ) + ) ); + + if ( empty( $check ) ) { + $check = get_user_setting('imgsize', 'medium'); + } + $out = array(); + + foreach ( $size_names as $size => $label ) { + $downsize = image_downsize( $post->ID, $size ); + $checked = ''; + + // Is this size selectable? + $enabled = ( $downsize[3] || 'full' == $size ); + $css_id = "image-size-{$size}-{$post->ID}"; + + // If this size is the default but that's not available, don't select it. + if ( $size == $check ) { + if ( $enabled ) { + $checked = " checked='checked'"; + } else { + $check = ''; + } + } elseif ( ! $check && $enabled && 'thumbnail' != $size ) { + /* + * If $check is not enabled, default to the first available size + * that's bigger than a thumbnail. + */ + $check = $size; + $checked = " checked='checked'"; + } + + $html = "
    "; + + $html .= ""; + + // Only show the dimensions if that choice is available. + if ( $enabled ) { + $html .= " "; + } + $html .= '
    '; + + $out[] = $html; + } + + return array( + 'label' => __( 'Size' ), + 'input' => 'html', + 'html' => join( "\n", $out ), + ); +} + +/** + * Retrieve HTML for the Link URL buttons with the default link type as specified. + * + * @since 2.7.0 + * + * @param WP_Post $post + * @param string $url_type + * @return string + */ +function image_link_input_fields($post, $url_type = '') { + + $file = wp_get_attachment_url($post->ID); + $link = get_attachment_link($post->ID); + + if ( empty($url_type) ) + $url_type = get_user_setting('urlbutton', 'post'); + + $url = ''; + if ( $url_type == 'file' ) + $url = $file; + elseif ( $url_type == 'post' ) + $url = $link; + + return " +
    + + + +"; +} + +/** + * Output a textarea element for inputting an attachment caption. + * + * @since 3.4.0 + * + * @param WP_Post $edit_post Attachment WP_Post object. + * @return string HTML markup for the textarea element. + */ +function wp_caption_input_textarea($edit_post) { + // Post data is already escaped. + $name = "attachments[{$edit_post->ID}][post_excerpt]"; + + return ''; +} + +/** + * Retrieves the image attachment fields to edit form fields. + * + * @since 2.5.0 + * + * @param array $form_fields + * @param object $post + * @return array + */ +function image_attachment_fields_to_edit($form_fields, $post) { + return $form_fields; +} + +/** + * Retrieves the single non-image attachment fields to edit form fields. + * + * @since 2.5.0 + * + * @param array $form_fields An array of attachment form fields. + * @param WP_Post $post The WP_Post attachment object. + * @return array Filtered attachment form fields. + */ +function media_single_attachment_fields_to_edit( $form_fields, $post ) { + unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); + return $form_fields; +} + +/** + * Retrieves the post non-image attachment fields to edito form fields. + * + * @since 2.8.0 + * + * @param array $form_fields An array of attachment form fields. + * @param WP_Post $post The WP_Post attachment object. + * @return array Filtered attachment form fields. + */ +function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { + unset($form_fields['image_url']); + return $form_fields; +} + +/** + * Filters input from media_upload_form_handler() and assigns a default + * post_title from the file name if none supplied. + * + * Illustrates the use of the {@see 'attachment_fields_to_save'} filter + * which can be used to add default values to any field before saving to DB. + * + * @since 2.5.0 + * + * @param array $post The WP_Post attachment object converted to an array. + * @param array $attachment An array of attachment metadata. + * @return array Filtered attachment post object. + */ +function image_attachment_fields_to_save( $post, $attachment ) { + if ( substr( $post['post_mime_type'], 0, 5 ) == 'image' ) { + if ( strlen( trim( $post['post_title'] ) ) == 0 ) { + $attachment_url = ( isset( $post['attachment_url'] ) ) ? $post['attachment_url'] : $post['guid']; + $post['post_title'] = preg_replace( '/\.\w+$/', '', wp_basename( $attachment_url ) ); + $post['errors']['post_title']['errors'][] = __( 'Empty Title filled from filename.' ); + } + } + + return $post; +} + +/** + * Retrieves the media element HTML to send to the editor. + * + * @since 2.5.0 + * + * @param string $html + * @param integer $attachment_id + * @param array $attachment + * @return string + */ +function image_media_send_to_editor($html, $attachment_id, $attachment) { + $post = get_post($attachment_id); + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $url = $attachment['url']; + $align = !empty($attachment['align']) ? $attachment['align'] : 'none'; + $size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium'; + $alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : ''; + $rel = ( strpos( $url, 'attachment_id') || $url === get_attachment_link( $attachment_id ) ); + + return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt); + } + + return $html; +} + +/** + * Retrieves the attachment fields to edit form fields. + * + * @since 2.5.0 + * + * @param WP_Post $post + * @param array $errors + * @return array + */ +function get_attachment_fields_to_edit($post, $errors = null) { + if ( is_int($post) ) + $post = get_post($post); + if ( is_array($post) ) + $post = new WP_Post( (object) $post ); + + $image_url = wp_get_attachment_url($post->ID); + + $edit_post = sanitize_post($post, 'edit'); + + $form_fields = array( + 'post_title' => array( + 'label' => __('Title'), + 'value' => $edit_post->post_title + ), + 'image_alt' => array(), + 'post_excerpt' => array( + 'label' => __('Caption'), + 'input' => 'html', + 'html' => wp_caption_input_textarea($edit_post) + ), + 'post_content' => array( + 'label' => __('Description'), + 'value' => $edit_post->post_content, + 'input' => 'textarea' + ), + 'url' => array( + 'label' => __('Link URL'), + 'input' => 'html', + 'html' => image_link_input_fields($post, get_option('image_default_link_type')), + 'helps' => __('Enter a link URL or click above for presets.') + ), + 'menu_order' => array( + 'label' => __('Order'), + 'value' => $edit_post->menu_order + ), + 'image_url' => array( + 'label' => __('File URL'), + 'input' => 'html', + 'html' => "
    ", + 'value' => wp_get_attachment_url($post->ID), + 'helps' => __('Location of the uploaded file.') + ) + ); + + foreach ( get_attachment_taxonomies($post) as $taxonomy ) { + $t = (array) get_taxonomy($taxonomy); + if ( ! $t['public'] || ! $t['show_ui'] ) + continue; + if ( empty($t['label']) ) + $t['label'] = $taxonomy; + if ( empty($t['args']) ) + $t['args'] = array(); + + $terms = get_object_term_cache($post->ID, $taxonomy); + if ( false === $terms ) + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); + + $values = array(); + + foreach ( $terms as $term ) + $values[] = $term->slug; + $t['value'] = join(', ', $values); + + $form_fields[$taxonomy] = $t; + } + + // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default + // The recursive merge is easily traversed with array casting: foreach ( (array) $things as $thing ) + $form_fields = array_merge_recursive($form_fields, (array) $errors); + + // This was formerly in image_attachment_fields_to_edit(). + if ( substr($post->post_mime_type, 0, 5) == 'image' ) { + $alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); + if ( empty($alt) ) + $alt = ''; + + $form_fields['post_title']['required'] = true; + + $form_fields['image_alt'] = array( + 'value' => $alt, + 'label' => __('Alternative Text'), + 'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') + ); + + $form_fields['align'] = array( + 'label' => __('Alignment'), + 'input' => 'html', + 'html' => image_align_input_fields($post, get_option('image_default_align')), + ); + + $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); + + } else { + unset( $form_fields['image_alt'] ); + } + + /** + * Filters the attachment fields to edit. + * + * @since 2.5.0 + * + * @param array $form_fields An array of attachment form fields. + * @param WP_Post $post The WP_Post attachment object. + */ + $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); + + return $form_fields; +} + +/** + * Retrieve HTML for media items of post gallery. + * + * The HTML markup retrieved will be created for the progress of SWF Upload + * component. Will also create link for showing and hiding the form to modify + * the image attachment. + * + * @since 2.5.0 + * + * @global WP_Query $wp_the_query + * + * @param int $post_id Optional. Post ID. + * @param array $errors Errors for attachment, if any. + * @return string + */ +function get_media_items( $post_id, $errors ) { + $attachments = array(); + if ( $post_id ) { + $post = get_post($post_id); + if ( $post && $post->post_type == 'attachment' ) + $attachments = array($post->ID => $post); + else + $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); + } else { + if ( is_array($GLOBALS['wp_the_query']->posts) ) + foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) + $attachments[$attachment->ID] = $attachment; + } + + $output = ''; + foreach ( (array) $attachments as $id => $attachment ) { + if ( $attachment->post_status == 'trash' ) + continue; + if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) + $output .= "\n
    $item\n
    "; + } + + return $output; +} + +/** + * Retrieve HTML form for modifying the image attachment. + * + * @since 2.5.0 + * + * @global string $redir_tab + * + * @param int $attachment_id Attachment ID for modification. + * @param string|array $args Optional. Override defaults. + * @return string HTML form for attachment. + */ +function get_media_item( $attachment_id, $args = null ) { + global $redir_tab; + + if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) + $thumb_url = $thumb_url[0]; + else + $thumb_url = false; + + $post = get_post( $attachment_id ); + $current_post_id = !empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0; + + $default_args = array( + 'errors' => null, + 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, + 'delete' => true, + 'toggle' => true, + 'show_title' => true + ); + $args = wp_parse_args( $args, $default_args ); + + /** + * Filters the arguments used to retrieve an image for the edit image form. + * + * @since 3.1.0 + * + * @see get_media_item + * + * @param array $args An array of arguments. + */ + $r = apply_filters( 'get_media_item_args', $args ); + + $toggle_on = __( 'Show' ); + $toggle_off = __( 'Hide' ); + + $file = get_attached_file( $post->ID ); + $filename = esc_html( wp_basename( $file ) ); + $title = esc_attr( $post->post_title ); + + $post_mime_types = get_post_mime_types(); + $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) ); + $type = reset( $keys ); + $type_html = ""; + + $form_fields = get_attachment_fields_to_edit( $post, $r['errors'] ); + + if ( $r['toggle'] ) { + $class = empty( $r['errors'] ) ? 'startclosed' : 'startopen'; + $toggle_links = " + $toggle_on + $toggle_off"; + } else { + $class = ''; + $toggle_links = ''; + } + + $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case + $display_title = $r['show_title'] ? "
    " . wp_html_excerpt( $display_title, 60, '…' ) . "
    " : ''; + + $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); + $order = ''; + + foreach ( $form_fields as $key => $val ) { + if ( 'menu_order' == $key ) { + if ( $gallery ) + $order = ""; + else + $order = ""; + + unset( $form_fields['menu_order'] ); + break; + } + } + + $media_dims = ''; + $meta = wp_get_attachment_metadata( $post->ID ); + if ( isset( $meta['width'], $meta['height'] ) ) + $media_dims .= "{$meta['width']} × {$meta['height']} "; + + /** + * Filters the media metadata. + * + * @since 2.5.0 + * + * @param string $media_dims The HTML markup containing the media dimensions. + * @param WP_Post $post The WP_Post attachment object. + */ + $media_dims = apply_filters( 'media_meta', $media_dims, $post ); + + $image_edit_button = ''; + if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { + $nonce = wp_create_nonce( "image_editor-$post->ID" ); + $image_edit_button = " "; + } + + $attachment_url = get_permalink( $attachment_id ); + + $item = " + $type_html + $toggle_links + $order + $display_title + + + + + \n"; + + $item .= " + + + \n + \n + \n"; + + $defaults = array( + 'input' => 'text', + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + ); + + if ( $r['send'] ) { + $r['send'] = get_submit_button( __( 'Insert into Post' ), '', "send[$attachment_id]", false ); + } + + $delete = empty( $r['delete'] ) ? '' : $r['delete']; + if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { + if ( !EMPTY_TRASH_DAYS ) { + $delete = "" . __( 'Delete Permanently' ) . ''; + } elseif ( !MEDIA_TRASH ) { + $delete = "" . __( 'Delete' ) . " + "; + } else { + $delete = "" . __( 'Move to Trash' ) . " + "; + } + } else { + $delete = ''; + } + + $thumbnail = ''; + $calling_post_id = 0; + if ( isset( $_GET['post_id'] ) ) { + $calling_post_id = absint( $_GET['post_id'] ); + } elseif ( isset( $_POST ) && count( $_POST ) ) {// Like for async-upload where $_GET['post_id'] isn't set + $calling_post_id = $post->post_parent; + } + if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) + && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { + + $calling_post = get_post( $calling_post_id ); + $calling_post_type_object = get_post_type_object( $calling_post->post_type ); + + $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); + $thumbnail = "" . esc_html( $calling_post_type_object->labels->use_featured_image ) . ""; + } + + if ( ( $r['send'] || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) { + $form_fields['buttons'] = array( 'tr' => "\t\t\n" ); + } + $hidden_fields = array(); + + foreach ( $form_fields as $id => $field ) { + if ( $id[0] == '_' ) + continue; + + if ( !empty( $field['tr'] ) ) { + $item .= $field['tr']; + continue; + } + + $field = array_merge( $defaults, $field ); + $name = "attachments[$attachment_id][$id]"; + + if ( $field['input'] == 'hidden' ) { + $hidden_fields[$name] = $field['value']; + continue; + } + + $required = $field['required'] ? '*' : ''; + $required_attr = $field['required'] ? ' required' : ''; + $aria_required = $field['required'] ? " aria-required='true'" : ''; + $class = $id; + $class .= $field['required'] ? ' form-required' : ''; + + $item .= "\t\t\n\t\t\t\n\t\t\t\n\t\t\n"; + + $extra_rows = array(); + + if ( !empty( $field['errors'] ) ) + foreach ( array_unique( (array) $field['errors'] ) as $error ) + $extra_rows['error'][] = $error; + + if ( !empty( $field['extra_rows'] ) ) + foreach ( $field['extra_rows'] as $class => $rows ) + foreach ( (array) $rows as $html ) + $extra_rows[$class][] = $html; + + foreach ( $extra_rows as $class => $rows ) + foreach ( $rows as $html ) + $item .= "\t\t\n"; + } + + if ( !empty( $form_fields['_final'] ) ) + $item .= "\t\t\n"; + $item .= "\t\n"; + $item .= "\t
    +

    +

    $image_edit_button

    +
    +

    " . __('File name:') . " $filename

    +

    " . __('File type:') . " $post->post_mime_type

    +

    " . __('Upload date:') . " " . mysql2date( __( 'F j, Y' ), $post->post_date ). '

    '; + if ( !empty( $media_dims ) ) + $item .= "

    " . __('Dimensions:') . " $media_dims

    \n"; + + $item .= "

    " . sprintf( __( 'Required fields are marked %s' ), '*' ) . "

    " . $r['send'] . " $thumbnail $delete
    "; + if ( !empty( $field[ $field['input'] ] ) ) + $item .= $field[ $field['input'] ]; + elseif ( $field['input'] == 'textarea' ) { + if ( 'post_content' == $id && user_can_richedit() ) { + // Sanitize_post() skips the post_content when user_can_richedit. + $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); + } + // Post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit(). + $item .= "'; + } else { + $item .= ""; + } + if ( !empty( $field['helps'] ) ) + $item .= "

    " . join( "

    \n

    ", array_unique( (array) $field['helps'] ) ) . '

    '; + $item .= "
    $html
    {$form_fields['_final']}
    \n"; + + foreach ( $hidden_fields as $name => $value ) + $item .= "\t\n"; + + if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) { + $parent = (int) $_REQUEST['post_id']; + $parent_name = "attachments[$attachment_id][post_parent]"; + $item .= "\t\n"; + } + + return $item; +} + +/** + * @since 3.5.0 + * + * @param int $attachment_id + * @param array $args + * @return array + */ +function get_compat_media_markup( $attachment_id, $args = null ) { + $post = get_post( $attachment_id ); + + $default_args = array( + 'errors' => null, + 'in_modal' => false, + ); + + $user_can_edit = current_user_can( 'edit_post', $attachment_id ); + + $args = wp_parse_args( $args, $default_args ); + + /** This filter is documented in wp-admin/includes/media.php */ + $args = apply_filters( 'get_media_item_args', $args ); + + $form_fields = array(); + + if ( $args['in_modal'] ) { + foreach ( get_attachment_taxonomies($post) as $taxonomy ) { + $t = (array) get_taxonomy($taxonomy); + if ( ! $t['public'] || ! $t['show_ui'] ) + continue; + if ( empty($t['label']) ) + $t['label'] = $taxonomy; + if ( empty($t['args']) ) + $t['args'] = array(); + + $terms = get_object_term_cache($post->ID, $taxonomy); + if ( false === $terms ) + $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); + + $values = array(); + + foreach ( $terms as $term ) + $values[] = $term->slug; + $t['value'] = join(', ', $values); + $t['taxonomy'] = true; + + $form_fields[$taxonomy] = $t; + } + } + + // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default + // The recursive merge is easily traversed with array casting: foreach ( (array) $things as $thing ) + $form_fields = array_merge_recursive($form_fields, (array) $args['errors'] ); + + /** This filter is documented in wp-admin/includes/media.php */ + $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); + + unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], + $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], + $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); + + /** This filter is documented in wp-admin/includes/media.php */ + $media_meta = apply_filters( 'media_meta', '', $post ); + + $defaults = array( + 'input' => 'text', + 'required' => false, + 'value' => '', + 'extra_rows' => array(), + 'show_in_edit' => true, + 'show_in_modal' => true, + ); + + $hidden_fields = array(); + + $item = ''; + foreach ( $form_fields as $id => $field ) { + if ( $id[0] == '_' ) + continue; + + $name = "attachments[$attachment_id][$id]"; + $id_attr = "attachments-$attachment_id-$id"; + + if ( !empty( $field['tr'] ) ) { + $item .= $field['tr']; + continue; + } + + $field = array_merge( $defaults, $field ); + + if ( ( ! $field['show_in_edit'] && ! $args['in_modal'] ) || ( ! $field['show_in_modal'] && $args['in_modal'] ) ) + continue; + + if ( $field['input'] == 'hidden' ) { + $hidden_fields[$name] = $field['value']; + continue; + } + + $readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : ''; + $required = $field['required'] ? '*' : ''; + $required_attr = $field['required'] ? ' required' : ''; + $aria_required = $field['required'] ? " aria-required='true'" : ''; + $class = 'compat-field-' . $id; + $class .= $field['required'] ? ' form-required' : ''; + + $item .= "\t\t"; + $item .= "\t\t\t"; + $item .= "\n\t\t\t"; + + if ( !empty( $field[ $field['input'] ] ) ) + $item .= $field[ $field['input'] ]; + elseif ( $field['input'] == 'textarea' ) { + if ( 'post_content' == $id && user_can_richedit() ) { + // sanitize_post() skips the post_content when user_can_richedit. + $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); + } + $item .= "'; + } else { + $item .= ""; + } + if ( !empty( $field['helps'] ) ) + $item .= "

    " . join( "

    \n

    ", array_unique( (array) $field['helps'] ) ) . '

    '; + $item .= "\n\t\t\n"; + + $extra_rows = array(); + + if ( !empty( $field['errors'] ) ) + foreach ( array_unique( (array) $field['errors'] ) as $error ) + $extra_rows['error'][] = $error; + + if ( !empty( $field['extra_rows'] ) ) + foreach ( $field['extra_rows'] as $class => $rows ) + foreach ( (array) $rows as $html ) + $extra_rows[$class][] = $html; + + foreach ( $extra_rows as $class => $rows ) + foreach ( $rows as $html ) + $item .= "\t\t$html\n"; + } + + if ( !empty( $form_fields['_final'] ) ) + $item .= "\t\t{$form_fields['_final']}\n"; + + if ( $item ) { + $item = '

    ' . + sprintf( __( 'Required fields are marked %s' ), '*' ) . '

    + ' . $item . '
    '; + } + + foreach ( $hidden_fields as $hidden_field => $value ) { + $item .= '' . "\n"; + } + + if ( $item ) + $item = '' . $item; + + return array( + 'item' => $item, + 'meta' => $media_meta, + ); +} + +/** + * Outputs the legacy media upload header. + * + * @since 2.5.0 + */ +function media_upload_header() { + $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; + + echo ''; + if ( empty( $_GET['chromeless'] ) ) { + echo '
    '; + the_media_upload_tabs(); + echo '
    '; + } +} + +/** + * Outputs the legacy media upload form. + * + * @since 2.5.0 + * + * @global string $type + * @global string $tab + * @global bool $is_IE + * @global bool $is_opera + * + * @param array $errors + */ +function media_upload_form( $errors = null ) { + global $type, $tab, $is_IE, $is_opera; + + if ( ! _device_can_upload() ) { + echo '

    ' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the native app for your device instead.'), 'https://apps.wordpress.org/' ) . '

    '; + return; + } + + $upload_action_url = admin_url('async-upload.php'); + $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; + $_type = isset($type) ? $type : ''; + $_tab = isset($tab) ? $tab : ''; + + $max_upload_size = wp_max_upload_size(); + if ( ! $max_upload_size ) { + $max_upload_size = 0; + } +?> + +
    +
    get_error_message(); + +?>
    + $post_id, + "_wpnonce" => wp_create_nonce('media-form'), + "type" => $_type, + "tab" => $_tab, + "short" => "1", +); + +/** + * Filters the media upload post parameters. + * + * @since 3.1.0 As 'swfupload_post_params' + * @since 3.3.0 + * + * @param array $post_params An array of media upload parameters used by Plupload. + */ +$post_params = apply_filters( 'upload_post_params', $post_params ); + +/* + * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`, + * and the `flash_swf_url` and `silverlight_xap_url` are not used. + */ +$plupload_init = array( + 'browse_button' => 'plupload-browse-button', + 'container' => 'plupload-upload-ui', + 'drop_element' => 'drag-drop-area', + 'file_data_name' => 'async-upload', + 'url' => $upload_action_url, + 'filters' => array( + 'max_file_size' => $max_upload_size . 'b', + ), + 'multipart_params' => $post_params, +); + +// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos +// when enabled. See #29602. +if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && + strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { + + $plupload_init['multi_selection'] = false; +} + +/** + * Filters the default Plupload settings. + * + * @since 3.3.0 + * + * @param array $plupload_init An array of default settings used by Plupload. + */ +$plupload_init = apply_filters( 'plupload_init', $plupload_init ); + +?> + + + +
    + +
    +
    +

    +

    +

    +
    +
    + +
    + +
    + +

    + + + + +

    +
    + +
    + +

    + + +
    + + + + +

    + + + + +
    '.esc_html($id->get_error_message()).'
    '; + exit; + } +} +?> + +

    + +

    +
    + + +
    + + + +

    + + + +
    +
    + +
    +
    +
    + + + +
    + + + + + + + | + | + +
    + + + +
    + + + + + + + + +
      + $reals ) + foreach ( $reals as $real ) + if ( isset($num_posts[$_type]) ) + $num_posts[$_type] += $_num_posts[$real]; + else + $num_posts[$_type] = $_num_posts[$real]; +// If available type specified by media button clicked, filter by that type +if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { + $_GET['post_mime_type'] = $type; + list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); +} +if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) + $class = ' class="current"'; +else + $class = ''; +$type_links[] = '
    • ' . __('All Types') . ''; +foreach ( $post_mime_types as $mime_type => $label ) { + $class = ''; + + if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) + continue; + + if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) + $class = ' class="current"'; + + $type_links[] = '
    • ' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), '' . number_format_i18n( $num_posts[$mime_type] ) . '') . ''; +} +/** + * Filters the media upload mime type list items. + * + * Returned values should begin with an `
    • ` tag. + * + * @since 3.1.0 + * + * @param array $type_links An array of list items containing mime type link HTML. + */ +echo implode(' |
    • ', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . ''; +unset($type_links); +?> +
    + +
    + + add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil($wp_query->found_posts / 10), + 'current' => $q['paged'], +)); + +if ( $page_links ) + echo "
    $page_links
    "; +?> + +
    +posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; + +$arc_result = $wpdb->get_results( $arc_query ); + +$month_count = count($arc_result); +$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; + +if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> + + + + + +
    + +
    +
    +
    + +
    + + + + + + +
    + + +
    +

    + + +

    +
    + + + + + + +'; + } else { + $caption = ''; + } + + $default_align = get_option('image_default_align'); + if ( empty($default_align) ) + $default_align = 'none'; + + if ( 'image' == $default_view ) { + $view = 'image-only'; + $table_class = ''; + } else { + $view = $table_class = 'not-image'; + } + + return ' +

       

    +

    ' . sprintf( __( 'Required fields are marked %s' ), '*' ) . '

    + + + + + + + + + + + + + + + + + + ' . $caption . ' + + + + + + + + + + + + + + + + + +
    + + +
    + +

    ' . __('Link text, e.g. “Ransom Demands (PDF)”') . '

    + + +

    ' . __('Alt text for the image, e.g. “The Mona Lisa”') . '

    + + + + + + + + +
    + +
    + + + +

    ' . __('Enter a link URL or click above for presets.') . '

    + +
    + ' . get_submit_button( __( 'Insert into Post' ), '', 'insertonlybutton', false ) . ' +
    +'; + +} + +/** + * Displays the multi-file uploader message. + * + * @since 2.6.0 + * + * @global int $post_ID + */ +function media_upload_flash_bypass() { + $browser_uploader = admin_url( 'media-new.php?browser-uploader' ); + + if ( $post = get_post() ) + $browser_uploader .= '&post_id=' . intval( $post->ID ); + elseif ( ! empty( $GLOBALS['post_ID'] ) ) + $browser_uploader .= '&post_id=' . intval( $GLOBALS['post_ID'] ); + + ?> +

    + browser uploader instead.' ), $browser_uploader, '_blank' ); ?> +

    + +

    + Switch to the multi-file uploader.'); ?> +

    + '; + $end = ''; + } +?> +

    +' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '

    '; +} + +/** + * Displays the image and editor in the post editor + * + * @since 3.5.0 + * + * @param WP_Post $post A post object. + */ +function edit_form_image_editor( $post ) { + $open = isset( $_GET['image-editor'] ); + if ( $open ) + require_once ABSPATH . 'wp-admin/includes/image-edit.php'; + + $thumb_url = false; + if ( $attachment_id = intval( $post->ID ) ) + $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); + + $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); + + $att_url = wp_get_attachment_url( $post->ID ); ?> +
    + ID ) ) : + $image_edit_button = ''; + if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { + $nonce = wp_create_nonce( "image_editor-$post->ID" ); + $image_edit_button = " "; + } + ?> + +
    + + class="wp_attachment_image wp-clearfix" id="media-head-"> +

    +

    +
    + class="image-editor" id="image-editor-"> + + + $att_url ) ); + + elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ): + + wp_maybe_generate_attachment_metadata( $post ); + + $meta = wp_get_attachment_metadata( $attachment_id ); + $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0; + $h = ! empty( $meta['height'] ) ? $meta['height'] : 0; + if ( $h && $w < $meta['width'] ) { + $h = round( ( $meta['height'] * $w ) / $meta['width'] ); + } + + $attr = array( 'src' => $att_url ); + if ( ! empty( $w ) && ! empty( $h ) ) { + $attr['width'] = $w; + $attr['height'] = $h; + } + + $thumb_id = get_post_thumbnail_id( $attachment_id ); + if ( ! empty( $thumb_id ) ) { + $attr['poster'] = wp_get_attachment_url( $thumb_id ); + } + + echo wp_video_shortcode( $attr ); + + elseif ( isset( $thumb_url[0] ) ): + + ?> +
    +

    + +

    +
    + + +
    +

    +
    + +

    + + + post_mime_type, 0, 5 ) ) : ?> +

    +
    + +

    + + + 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); + $editor_args = array( + 'textarea_name' => 'content', + 'textarea_rows' => 5, + 'media_buttons' => false, + 'tinymce' => false, + 'quicktags' => $quicktags_settings, + ); + ?> + + + post_content, 'attachment_content', $editor_args ); ?> + +
    + ID ); + echo $extras['item']; + echo '' . "\n"; +} + +/** + * Displays non-editable attachment metadata in the publish meta box. + * + * @since 3.5.0 + */ +function attachment_submitbox_metadata() { + $post = get_post(); + + $file = get_attached_file( $post->ID ); + $filename = esc_html( wp_basename( $file ) ); + + $media_dims = ''; + $meta = wp_get_attachment_metadata( $post->ID ); + if ( isset( $meta['width'], $meta['height'] ) ) + $media_dims .= "{$meta['width']} × {$meta['height']} "; + /** This filter is documented in wp-admin/includes/media.php */ + $media_dims = apply_filters( 'media_meta', $media_dims, $post ); + + $att_url = wp_get_attachment_url( $post->ID ); +?> +
    + + +
    +
    + +
    +
    + ID ), $matches ) ) { + echo esc_html( strtoupper( $matches[1] ) ); + list( $mime_type ) = explode( '/', $post->post_mime_type ); + if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) { + if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) { + echo ' (' . $meta['mime_type'] . ')'; + } + } + } else { + echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); + } + ?> +
    + + +
    + +
    + post_mime_type ) ) { + $fields = array( + 'length_formatted' => __( 'Length:' ), + 'bitrate' => __( 'Bitrate:' ), + ); + + /** + * Filters the audio and video metadata fields to be shown in the publish meta box. + * + * The key for each item in the array should correspond to an attachment + * metadata key, and the value should be the desired label. + * + * @since 3.7.0 + * @since 4.9.0 Added the `$post` parameter. + * + * @param array $fields An array of the attachment metadata keys and labels. + * @param WP_Post $post WP_Post object for the current attachment. + */ + $fields = apply_filters( 'media_submitbox_misc_sections', $fields, $post ); + + foreach ( $fields as $key => $label ) { + if ( empty( $meta[ $key ] ) ) { + continue; + } + ?> +
    + +
    + __( 'Audio Format:' ), + 'codec' => __( 'Audio Codec:' ) + ); + + /** + * Filters the audio attachment metadata fields to be shown in the publish meta box. + * + * The key for each item in the array should correspond to an attachment + * metadata key, and the value should be the desired label. + * + * @since 3.7.0 + * @since 4.9.0 Added the `$post` parameter. + * + * @param array $fields An array of the attachment metadata keys and labels. + * @param WP_Post $post WP_Post object for the current attachment. + */ + $audio_fields = apply_filters( 'audio_submitbox_misc_sections', $fields, $post ); + + foreach ( $audio_fields as $key => $label ) { + if ( empty( $meta['audio'][ $key ] ) ) { + continue; + } + ?> +
    + +
    + +
    + +
    + $list ) { + if ( 'length' !== $key && ! empty( $list ) ) { + $metadata[$key] = wp_kses_post( reset( $list ) ); + // Fix bug in byte stream analysis. + if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) ) + $metadata[$key] = 'Cop' . $metadata[$key]; + } + } + break; + } + } + + if ( ! empty( $data['id3v2']['APIC'] ) ) { + $image = reset( $data['id3v2']['APIC']); + if ( ! empty( $image['data'] ) ) { + $metadata['image'] = array( + 'data' => $image['data'], + 'mime' => $image['image_mime'], + 'width' => $image['image_width'], + 'height' => $image['image_height'] + ); + } + } elseif ( ! empty( $data['comments']['picture'] ) ) { + $image = reset( $data['comments']['picture'] ); + if ( ! empty( $image['data'] ) ) { + $metadata['image'] = array( + 'data' => $image['data'], + 'mime' => $image['image_mime'] + ); + } + } +} + +/** + * Retrieve metadata from a video file's ID3 tags + * + * @since 3.6.0 + * + * @param string $file Path to file. + * @return array|bool Returns array of metadata, if found. + */ +function wp_read_video_metadata( $file ) { + if ( ! file_exists( $file ) ) { + return false; + } + + $metadata = array(); + + if ( ! defined( 'GETID3_TEMP_DIR' ) ) { + define( 'GETID3_TEMP_DIR', get_temp_dir() ); + } + + if ( ! class_exists( 'getID3', false ) ) { + require( ABSPATH . WPINC . '/ID3/getid3.php' ); + } + $id3 = new getID3(); + $data = $id3->analyze( $file ); + + if ( isset( $data['video']['lossless'] ) ) + $metadata['lossless'] = $data['video']['lossless']; + if ( ! empty( $data['video']['bitrate'] ) ) + $metadata['bitrate'] = (int) $data['video']['bitrate']; + if ( ! empty( $data['video']['bitrate_mode'] ) ) + $metadata['bitrate_mode'] = $data['video']['bitrate_mode']; + if ( ! empty( $data['filesize'] ) ) + $metadata['filesize'] = (int) $data['filesize']; + if ( ! empty( $data['mime_type'] ) ) + $metadata['mime_type'] = $data['mime_type']; + if ( ! empty( $data['playtime_seconds'] ) ) + $metadata['length'] = (int) round( $data['playtime_seconds'] ); + if ( ! empty( $data['playtime_string'] ) ) + $metadata['length_formatted'] = $data['playtime_string']; + if ( ! empty( $data['video']['resolution_x'] ) ) + $metadata['width'] = (int) $data['video']['resolution_x']; + if ( ! empty( $data['video']['resolution_y'] ) ) + $metadata['height'] = (int) $data['video']['resolution_y']; + if ( ! empty( $data['fileformat'] ) ) + $metadata['fileformat'] = $data['fileformat']; + if ( ! empty( $data['video']['dataformat'] ) ) + $metadata['dataformat'] = $data['video']['dataformat']; + if ( ! empty( $data['video']['encoder'] ) ) + $metadata['encoder'] = $data['video']['encoder']; + if ( ! empty( $data['video']['codec'] ) ) + $metadata['codec'] = $data['video']['codec']; + + if ( ! empty( $data['audio'] ) ) { + unset( $data['audio']['streams'] ); + $metadata['audio'] = $data['audio']; + } + + if ( empty( $metadata['created_timestamp'] ) ) { + $created_timestamp = wp_get_media_creation_timestamp( $data ); + + if ( $created_timestamp !== false ) { + $metadata['created_timestamp'] = $created_timestamp; + } + } + + wp_add_id3_tag_data( $metadata, $data ); + + $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; + + /** + * Filters the array of metadata retrieved from a video. + * + * In core, usually this selection is what is stored. + * More complete data can be parsed from the `$data` parameter. + * + * @since 4.9.0 + * + * @param array $metadata Filtered Video metadata. + * @param string $file Path to video file. + * @param string $file_format File format of video, as analyzed by getID3. + * @param string $data Raw metadata from getID3. + */ + return apply_filters( 'wp_read_video_metadata', $metadata, $file, $file_format, $data ); +} + +/** + * Retrieve metadata from a audio file's ID3 tags + * + * @since 3.6.0 + * + * @param string $file Path to file. + * @return array|bool Returns array of metadata, if found. + */ +function wp_read_audio_metadata( $file ) { + if ( ! file_exists( $file ) ) { + return false; + } + $metadata = array(); + + if ( ! defined( 'GETID3_TEMP_DIR' ) ) { + define( 'GETID3_TEMP_DIR', get_temp_dir() ); + } + + if ( ! class_exists( 'getID3', false ) ) { + require( ABSPATH . WPINC . '/ID3/getid3.php' ); + } + $id3 = new getID3(); + $data = $id3->analyze( $file ); + + if ( ! empty( $data['audio'] ) ) { + unset( $data['audio']['streams'] ); + $metadata = $data['audio']; + } + + if ( ! empty( $data['fileformat'] ) ) + $metadata['fileformat'] = $data['fileformat']; + if ( ! empty( $data['filesize'] ) ) + $metadata['filesize'] = (int) $data['filesize']; + if ( ! empty( $data['mime_type'] ) ) + $metadata['mime_type'] = $data['mime_type']; + if ( ! empty( $data['playtime_seconds'] ) ) + $metadata['length'] = (int) round( $data['playtime_seconds'] ); + if ( ! empty( $data['playtime_string'] ) ) + $metadata['length_formatted'] = $data['playtime_string']; + + wp_add_id3_tag_data( $metadata, $data ); + + return $metadata; +} + +/** + * Parse creation date from media metadata. + * + * The getID3 library doesn't have a standard method for getting creation dates, + * so the location of this data can vary based on the MIME type. + * + * @since 4.9.0 + * + * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt + * + * @param array $metadata The metadata returned by getID3::analyze(). + * @return int|bool A UNIX timestamp for the media's creation date if available + * or a boolean FALSE if a timestamp could not be determined. + */ +function wp_get_media_creation_timestamp( $metadata ) { + $creation_date = false; + + if ( empty( $metadata['fileformat'] ) ) { + return $creation_date; + } + + switch ( $metadata['fileformat'] ) { + case 'asf': + if ( isset( $metadata['asf']['file_properties_object']['creation_date_unix'] ) ) { + $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix']; + } + break; + + case 'matroska': + case 'webm': + if ( isset( $metadata['matroska']['comments']['creation_time']['0'] ) ) { + $creation_date = strtotime( $metadata['matroska']['comments']['creation_time']['0'] ); + } + elseif ( isset( $metadata['matroska']['info']['0']['DateUTC_unix'] ) ) { + $creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix']; + } + break; + + case 'quicktime': + case 'mp4': + if ( isset( $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'] ) ) { + $creation_date = (int) $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix']; + } + break; + } + + return $creation_date; +} + +/** + * Encapsulate logic for Attach/Detach actions + * + * @since 4.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $parent_id Attachment parent ID. + * @param string $action Optional. Attach/detach action. Accepts 'attach' or 'detach'. + * Default 'attach'. + */ +function wp_media_attach_action( $parent_id, $action = 'attach' ) { + global $wpdb; + + if ( ! $parent_id ) { + return; + } + + if ( ! current_user_can( 'edit_post', $parent_id ) ) { + wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); + } + $ids = array(); + foreach ( (array) $_REQUEST['media'] as $att_id ) { + $att_id = (int) $att_id; + + if ( ! current_user_can( 'edit_post', $att_id ) ) { + continue; + } + + $ids[] = $att_id; + } + + if ( ! empty( $ids ) ) { + $ids_string = implode( ',', $ids ); + if ( 'attach' === $action ) { + $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) ); + } else { + $result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" ); + } + + foreach ( $ids as $att_id ) { + clean_attachment_cache( $att_id ); + } + } + + if ( isset( $result ) ) { + $location = 'upload.php'; + if ( $referer = wp_get_referer() ) { + if ( false !== strpos( $referer, 'upload.php' ) ) { + $location = remove_query_arg( array( 'attached', 'detach' ), $referer ); + } + } + + $key = 'attach' === $action ? 'attached' : 'detach'; + $location = add_query_arg( array( $key => $result ), $location ); + wp_redirect( $location ); + exit; + } +} diff --git a/backend/wp-admin/includes/menu.php b/backend/wp-admin/includes/menu.php new file mode 100644 index 0000000..1c6f545 --- /dev/null +++ b/backend/wp-admin/includes/menu.php @@ -0,0 +1,345 @@ + $sub) { + foreach ($sub as $index => $data) { + if ( ! current_user_can($data[1]) ) { + unset($submenu[$parent][$index]); + $_wp_submenu_nopriv[$parent][$data[2]] = true; + } + } + unset($index, $data); + + if ( empty($submenu[$parent]) ) + unset($submenu[$parent]); +} +unset($sub, $parent); + +/* + * Loop over the top-level menu. + * Menus for which the original parent is not accessible due to lack of privileges + * will have the next submenu in line be assigned as the new menu parent. + */ +foreach ( $menu as $id => $data ) { + if ( empty($submenu[$data[2]]) ) + continue; + $subs = $submenu[$data[2]]; + $first_sub = reset( $subs ); + $old_parent = $data[2]; + $new_parent = $first_sub[2]; + /* + * If the first submenu is not the same as the assigned parent, + * make the first submenu the new parent. + */ + if ( $new_parent != $old_parent ) { + $_wp_real_parent_file[$old_parent] = $new_parent; + $menu[$id][2] = $new_parent; + + foreach ($submenu[$old_parent] as $index => $data) { + $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; + unset($submenu[$old_parent][$index]); + } + unset($submenu[$old_parent], $index); + + if ( isset($_wp_submenu_nopriv[$old_parent]) ) + $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; + } +} +unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); + +if ( is_network_admin() ) { + + /** + * Fires before the administration menu loads in the Network Admin. + * + * @since 3.1.0 + * + * @param string $context Empty context. + */ + do_action( 'network_admin_menu', '' ); +} elseif ( is_user_admin() ) { + + /** + * Fires before the administration menu loads in the User Admin. + * + * @since 3.1.0 + * + * @param string $context Empty context. + */ + do_action( 'user_admin_menu', '' ); +} else { + + /** + * Fires before the administration menu loads in the admin. + * + * @since 1.5.0 + * + * @param string $context Empty context. + */ + do_action( 'admin_menu', '' ); +} + +/* + * Remove menus that have no accessible submenus and require privileges + * that the user does not have. Run re-parent loop again. + */ +foreach ( $menu as $id => $data ) { + if ( ! current_user_can($data[1]) ) + $_wp_menu_nopriv[$data[2]] = true; + + /* + * If there is only one submenu and it is has same destination as the parent, + * remove the submenu. + */ + if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) { + $subs = $submenu[$data[2]]; + $first_sub = reset( $subs ); + if ( $data[2] == $first_sub[2] ) + unset( $submenu[$data[2]] ); + } + + // If submenu is empty... + if ( empty($submenu[$data[2]]) ) { + // And user doesn't have privs, remove menu. + if ( isset( $_wp_menu_nopriv[$data[2]] ) ) { + unset($menu[$id]); + } + } +} +unset($id, $data, $subs, $first_sub); + +/** + * + * @param string $add + * @param string $class + * @return string + */ +function add_cssclass($add, $class) { + $class = empty($class) ? $add : $class .= ' ' . $add; + return $class; +} + +/** + * + * @param array $menu + * @return array + */ +function add_menu_classes($menu) { + $first = $lastorder = false; + $i = 0; + $mc = count($menu); + foreach ( $menu as $order => $top ) { + $i++; + + if ( 0 == $order ) { // dashboard is always shown/single + $menu[0][4] = add_cssclass('menu-top-first', $top[4]); + $lastorder = 0; + continue; + } + + if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator + $first = true; + $c = $menu[$lastorder][4]; + $menu[$lastorder][4] = add_cssclass('menu-top-last', $c); + continue; + } + + if ( $first ) { + $c = $menu[$order][4]; + $menu[$order][4] = add_cssclass('menu-top-first', $c); + $first = false; + } + + if ( $mc == $i ) { // last item + $c = $menu[$order][4]; + $menu[$order][4] = add_cssclass('menu-top-last', $c); + } + + $lastorder = $order; + } + + /** + * Filters administration menus array with classes added for top-level items. + * + * @since 2.7.0 + * + * @param array $menu Associative array of administration menu items. + */ + return apply_filters( 'add_menu_classes', $menu ); +} + +uksort($menu, "strnatcasecmp"); // make it all pretty + +/** + * Filters whether to enable custom ordering of the administration menu. + * + * See the {@see 'menu_order'} filter for reordering menu items. + * + * @since 2.8.0 + * + * @param bool $custom Whether custom ordering is enabled. Default false. + */ +if ( apply_filters( 'custom_menu_order', false ) ) { + $menu_order = array(); + foreach ( $menu as $menu_item ) { + $menu_order[] = $menu_item[2]; + } + unset($menu_item); + $default_menu_order = $menu_order; + + /** + * Filters the order of administration menu items. + * + * A truthy value must first be passed to the {@see 'custom_menu_order'} filter + * for this filter to work. Use the following to enable custom menu ordering: + * + * add_filter( 'custom_menu_order', '__return_true' ); + * + * @since 2.8.0 + * + * @param array $menu_order An ordered array of menu items. + */ + $menu_order = apply_filters( 'menu_order', $menu_order ); + $menu_order = array_flip($menu_order); + $default_menu_order = array_flip($default_menu_order); + + /** + * + * @global array $menu_order + * @global array $default_menu_order + * + * @param array $a + * @param array $b + * @return int + */ + function sort_menu($a, $b) { + global $menu_order, $default_menu_order; + $a = $a[2]; + $b = $b[2]; + if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) { + return -1; + } elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) { + return 1; + } elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) { + if ( $menu_order[$a] == $menu_order[$b] ) + return 0; + return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1; + } else { + return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1; + } + } + + usort($menu, 'sort_menu'); + unset($menu_order, $default_menu_order); +} + +// Prevent adjacent separators +$prev_menu_was_separator = false; +foreach ( $menu as $id => $data ) { + if ( false === stristr( $data[4], 'wp-menu-separator' ) ) { + + // This item is not a separator, so falsey the toggler and do nothing + $prev_menu_was_separator = false; + } else { + + // The previous item was a separator, so unset this one + if ( true === $prev_menu_was_separator ) { + unset( $menu[ $id ] ); + } + + // This item is a separator, so truthy the toggler and move on + $prev_menu_was_separator = true; + } +} +unset( $id, $data, $prev_menu_was_separator ); + +// Remove the last menu item if it is a separator. +$last_menu_key = array_keys( $menu ); +$last_menu_key = array_pop( $last_menu_key ); +if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) + unset( $menu[ $last_menu_key ] ); +unset( $last_menu_key ); + +if ( !user_can_access_admin_page() ) { + + /** + * Fires when access to an admin page is denied. + * + * @since 2.5.0 + */ + do_action( 'admin_page_access_denied' ); + + wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); +} + +$menu = add_menu_classes($menu); diff --git a/backend/wp-admin/includes/meta-boxes.php b/backend/wp-admin/includes/meta-boxes.php new file mode 100644 index 0000000..a8cfd16 --- /dev/null +++ b/backend/wp-admin/includes/meta-boxes.php @@ -0,0 +1,1284 @@ +post_type; + $post_type_object = get_post_type_object($post_type); + $can_publish = current_user_can($post_type_object->cap->publish_posts); +?> +
    + +
    + + +
    + +
    + +
    +
    +post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> +post_status ) { ?>style="display:none" type="submit" name="save" id="save-post" value="" class="button" /> + +post_status && $can_publish ) { ?> + + + +
    + +
    +post_status ) { + $preview_button_text = __( 'Preview Changes' ); +} else { + $preview_button_text = __( 'Preview' ); +} + +$preview_button = sprintf( '%1$s %2$s', + $preview_button_text, + /* translators: accessibility text */ + __( '(opens in a new window)' ) +); +?> + + +
    + + +
    +
    + +
    + +
    + post_status ) { + case 'private': + _e('Privately Published'); + break; + case 'publish': + _e('Published'); + break; + case 'future': + _e('Scheduled'); + break; + case 'pending': + _e('Pending Review'); + break; + case 'draft': + case 'auto-draft': + _e('Draft'); + break; +} +?> + +post_status || 'private' == $post->post_status || $can_publish ) { ?> +post_status ) { ?>style="display:none;" class="edit-post-status hide-if-no-js" role="button"> + +
    + + + + + +
    + + +
    + +
    + post_status ) { + $post->post_password = ''; + $visibility = 'private'; + $visibility_trans = __('Private'); +} elseif ( !empty( $post->post_password ) ) { + $visibility = 'password'; + $visibility_trans = __('Password protected'); +} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) { + $visibility = 'public'; + $visibility_trans = __('Public, Sticky'); +} else { + $visibility = 'public'; + $visibility_trans = __('Public'); +} + +echo esc_html( $visibility_trans ); ?> + + + +
    + + +ID)); ?> /> + + + />
    + +ID ) ); ?> />
    + + />
    +
    + />
    + +

    + + +

    +
    + + +
    + +ID ) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date + /* translators: Post date information. 1: Date on which the post is currently scheduled to be published */ + $stamp = __('Scheduled for: %1$s'); + } elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published + /* translators: Post date information. 1: Date on which the post was published */ + $stamp = __('Published on: %1$s'); + } elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified + /* translators: Post date information. 1: Date on which the post is to be published */ + $stamp = __('Schedule for: %1$s'); + } else { // draft, 1 or more saves, date specified + /* translators: Post date information. 1: Date on which the post is to be published */ + $stamp = __('Publish on: %1$s'); + } + $date = date_i18n( $datef, strtotime( $post->post_date ) ); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); + $date = date_i18n( $datef, strtotime( current_time('mysql') ) ); +} + +if ( ! empty( $args['args']['revisions_count'] ) ) : ?> +
    + ' . number_format_i18n( $args['args']['revisions_count'] ) . '' ); + ?> + +
    + +
    + + + +
    + + +
    +
    + + +post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) : ?> +
    +

    + unpublished customization changes. You can edit, but there’s no need to publish now. It will be published automatically with those changes.' ), + esc_url( + add_query_arg( + 'changeset_uuid', + rawurlencode( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ), + admin_url( 'customize.php' ) + ) + ) + ); + ?> +

    +
    + + + +
    +
    +
    + +
    + +
    +ID ) ) { + if ( !EMPTY_TRASH_DAYS ) + $delete_text = __('Delete Permanently'); + else + $delete_text = __('Move to Trash'); + ?> + +
    + +
    + +post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) { + if ( $can_publish ) : + if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> + + + + + + + + + + + + +
    +
    +
    +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + post_date ) + ); + printf( + /* translators: Attachment information. %s: Date the attachment was uploaded */ + __( 'Uploaded on: %s' ), + '' . $date . '' + ); + ?> +
    + + +
    +
    +
    + +
    +
    + ID ) ) + if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { + echo "" . _x( 'Trash', 'verb' ) . ""; + } else { + $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; + echo "" . __( 'Delete Permanently' ) . ""; + } + ?> +
    + +
    + + + +
    +
    +
    + +
    + +post_type, 'post-formats' ) ) : + $post_formats = get_theme_support( 'post-formats' ); + + if ( is_array( $post_formats[0] ) ) : + $post_format = get_post_format( $post->ID ); + if ( !$post_format ) + $post_format = '0'; + // Add in the current one if it isn't there yet, in case the current theme doesn't support it + if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) + $post_formats[0][] = $post_format; + ?> +
    +
    + + /> + +
    /> + +
    +
    + 'post_tag' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { + $args = array(); + } else { + $args = $box['args']; + } + $r = wp_parse_args( $args, $defaults ); + $tax_name = esc_attr( $r['taxonomy'] ); + $taxonomy = get_taxonomy( $r['taxonomy'] ); + $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); + $comma = _x( ',', 'tag delimiter' ); + $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); + if ( ! is_string( $terms_to_edit ) ) { + $terms_to_edit = ''; + } +?> +
    +
    +
    + +

    +
    + +
    + +

    +

    +
    +

    labels->separate_items_with_commas; ?>

    + +

    labels->no_terms; ?>

    + +
    +
      +
      + +

      + + 'category' ); + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { + $args = array(); + } else { + $args = $box['args']; + } + $r = wp_parse_args( $args, $defaults ); + $tax_name = esc_attr( $r['taxonomy'] ); + $taxonomy = get_taxonomy( $r['taxonomy'] ); + ?> +
      + + + + +
      + "; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. + ?> +
        + ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?> +
      +
      + cap->edit_terms ) ) : ?> +
      + + labels->add_new_item ); + ?> + +

      + + + + $tax_name, + 'hide_empty' => 0, + 'name' => 'new' . $tax_name . '_parent', + 'orderby' => 'name', + 'hierarchical' => 1, + 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', + ); + + /** + * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. + * + * @since 4.4.0 + * + * @param array $parent_dropdown_args { + * Optional. Array of arguments to generate parent dropdown. + * + * @type string $taxonomy Name of the taxonomy to retrieve. + * @type bool $hide_if_empty True to skip generating markup if no + * categories are found. Default 0. + * @type string $name Value for the 'name' attribute + * of the select element. + * Default "new{$tax_name}_parent". + * @type string $orderby Which column to use for ordering + * terms. Default 'name'. + * @type bool|int $hierarchical Whether to traverse the taxonomy + * hierarchy. Default 1. + * @type string $show_option_none Text to display for the "none" option. + * Default "— {$parent} —", + * where `$parent` is 'parent_item' + * taxonomy label. + * } + */ + $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); + + wp_dropdown_categories( $parent_dropdown_args ); + ?> + + + +

      +
      + +
      + + +

      Learn more about manual excerpts.' ), + __( 'https://codex.wordpress.org/Excerpt' ) + ); +?>

      +to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; + if ('' != $post->pinged) { + $pings = '

      '. __('Already pinged:') . '

        '; + $already_pinged = explode("\n", trim($post->pinged)); + foreach ($already_pinged as $pinged_url) { + $pings .= "\n\t
      • " . esc_html($pinged_url) . "
      • "; + } + $pings .= '
      '; + } + +?> +

      + + +

      +

      +

      pingbacks, no other action necessary.' ), + __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) + ); +?>

      + +
      +
      +ID); +foreach ( $metadata as $key => $value ) { + if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) ) + unset( $metadata[ $key ] ); +} +list_meta( $metadata ); +meta_form( $post ); ?> +
      +

      use in your theme.' ), + __( 'https://codex.wordpress.org/Using_Custom_Fields' ) + ); +?>

      + + +

      +
      + + +

      + +

      + $post->ID, 'number' => 1, 'count' => true ) ); + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); + $wp_list_table->display( true ); + + if ( 1 > $total ) { + echo '

      ' . __('No comments yet.') . '

      '; + } else { + $hidden = get_hidden_meta_boxes( get_current_screen() ); + if ( ! in_array('commentsdiv', $hidden) ) { + ?> + + +

      + post_name, $post ); +?> + + + + 'authors', + 'name' => 'post_author_override', + 'selected' => empty($post->ID) ? $user_ID : $post->post_author, + 'include_selected' => true, + 'show' => 'display_name_with_login', + ) ); +} + +/** + * Display list of revisions. + * + * @since 2.6.0 + * + * @param object $post + */ +function post_revisions_meta_box( $post ) { + wp_list_post_revisions( $post ); +} + +// -- Page related Meta Boxes + +/** + * Display page attributes form fields. + * + * @since 2.7.0 + * + * @param object $post + */ +function page_attributes_meta_box($post) { + if ( is_post_type_hierarchical( $post->post_type ) ) : + $dropdown_args = array( + 'post_type' => $post->post_type, + 'exclude_tree' => $post->ID, + 'selected' => $post->post_parent, + 'name' => 'parent_id', + 'show_option_none' => __('(no parent)'), + 'sort_column' => 'menu_order, post_title', + 'echo' => 0, + ); + + /** + * Filters the arguments used to generate a Pages drop-down element. + * + * @since 3.3.0 + * + * @see wp_dropdown_pages() + * + * @param array $dropdown_args Array of arguments used to generate the pages drop-down. + * @param WP_Post $post The current post. + */ + $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); + $pages = wp_dropdown_pages( $dropdown_args ); + if ( ! empty($pages) ) : +?> +

      + + 0 && get_option( 'page_for_posts' ) != $post->ID ) : + $template = ! empty( $post->page_template ) ? $post->page_template : false; + ?> +

      + + +post_type, 'page-attributes' ) ) : ?> +

      + + +post_type && get_current_screen()->get_help_tabs() ) : ?> +

      + + + +
      +
        +
      • +
      • +
      + +
      +
        + link_id) ) + wp_link_category_checklist($link->link_id); + else + wp_link_category_checklist(); + ?> +
      +
      + + + +
      + + +
      +
      + +
      +

      +

      +

      +
      +

      +link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; + $rels = preg_split('/\s+/', $link_rel); + + if ('' != $value && in_array($value, $rels) ) { + echo ' checked="checked"'; + } + + if ('' == $value) { + if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; + if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; + if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; + if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; + } +} + +/** + * Display xfn form fields. + * + * @since 2.6.0 + * + * @param object $link + */ +function link_xfn_meta_box($link) { +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      XFN.'); ?>

      + + + + + + + + + + + + + + + + + + + +ID, '_thumbnail_id', true ); + echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); +} + +/** + * Display fields for ID3 data + * + * @since 3.9.0 + * + * @param WP_Post $post A post object. + */ +function attachment_id3_data_meta_box( $post ) { + $meta = array(); + if ( ! empty( $post->ID ) ) { + $meta = wp_get_attachment_metadata( $post->ID ); + } + + foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?> +

      +
      + +

      + using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) { + if ( got_mod_rewrite() ) { + $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); + return insert_with_markers( $htaccess_file, 'WordPress', $rules ); + } + } + + return false; +} + +/** + * Updates the IIS web.config file with the current rules if it is writable. + * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. + * + * @since 2.8.0 + * + * @global WP_Rewrite $wp_rewrite + * + * @return bool True if web.config was updated successfully + */ +function iis7_save_url_rewrite_rules(){ + if ( is_multisite() ) + return; + + global $wp_rewrite; + + $home_path = get_home_path(); + $web_config_file = $home_path . 'web.config'; + + // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP + if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) { + $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', ''); + if ( ! empty($rule) ) { + return iis7_add_rewrite_rule($web_config_file, $rule); + } else { + return iis7_delete_rewrite_rule($web_config_file); + } + } + return false; +} + +/** + * Update the "recently-edited" file for the plugin or theme editor. + * + * @since 1.5.0 + * + * @param string $file + */ +function update_recently_edited( $file ) { + $oldfiles = (array ) get_option( 'recently_edited' ); + if ( $oldfiles ) { + $oldfiles = array_reverse( $oldfiles ); + $oldfiles[] = $file; + $oldfiles = array_reverse( $oldfiles ); + $oldfiles = array_unique( $oldfiles ); + if ( 5 < count( $oldfiles )) + array_pop( $oldfiles ); + } else { + $oldfiles[] = $file; + } + update_option( 'recently_edited', $oldfiles ); +} + +/** + * Makes a tree structure for the Theme Editor's file list. + * + * @since 4.9.0 + * @access private + * + * @param array $allowed_files List of theme file paths. + * @return array Tree structure for listing theme files. + */ +function wp_make_theme_file_tree( $allowed_files ) { + $tree_list = array(); + foreach ( $allowed_files as $file_name => $absolute_filename ) { + $list = explode( '/', $file_name ); + $last_dir = &$tree_list; + foreach ( $list as $dir ) { + $last_dir =& $last_dir[ $dir ]; + } + $last_dir = $file_name; + } + return $tree_list; +} + +/** + * Outputs the formatted file list for the Theme Editor. + * + * @since 4.9.0 + * @access private + * + * @param array|string $tree List of file/folder paths, or filename. + * @param int $level The aria-level for the current iteration. + * @param int $size The aria-setsize for the current iteration. + * @param int $index The aria-posinset for the current iteration. + */ +function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) { + global $relative_file, $stylesheet; + + if ( is_array( $tree ) ) { + $index = 0; + $size = count( $tree ); + foreach ( $tree as $label => $theme_file ) : + $index++; + if ( ! is_array( $theme_file ) ) { + wp_print_theme_file_tree( $theme_file, $level, $index, $size ); + continue; + } + ?> +
    • + +
      +
    • + rawurlencode( $tree ), + 'theme' => rawurlencode( $stylesheet ), + ), + self_admin_url( 'theme-editor.php' ) + ); + ?> +
    • + + (' . esc_html( $filename ) . ')'; + } + + if ( $relative_file === $filename ) { + echo '' . $file_description . ''; + } else { + echo $file_description; + } + ?> + +
    • + $plugin_file ) : + $index++; + if ( ! is_array( $plugin_file ) ) { + wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size ); + continue; + } + ?> +
    • + +
      +
    • + rawurlencode( $tree ), + 'plugin' => rawurlencode( $plugin ), + ), + self_admin_url( 'plugin-editor.php' ) + ); + ?> +
    • + + ' . esc_html( $label ) . ''; + } else { + echo esc_html( $label ); + } + ?> + +
    • + get_error_data() && is_string( $message->get_error_data() ) ) + $message = $message->get_error_message() . ': ' . $message->get_error_data(); + else + $message = $message->get_error_message(); + } + echo "

      $message

      \n"; + wp_ob_end_flush_all(); + flush(); +} + +/** + * @since 2.8.0 + * + * @param string $content + * @return array + */ +function wp_doc_link_parse( $content ) { + if ( !is_string( $content ) || empty( $content ) ) + return array(); + + if ( !function_exists('token_get_all') ) + return array(); + + $tokens = token_get_all( $content ); + $count = count( $tokens ); + $functions = array(); + $ignore_functions = array(); + for ( $t = 0; $t < $count - 2; $t++ ) { + if ( ! is_array( $tokens[ $t ] ) ) { + continue; + } + + if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { + // If it's a function or class defined locally, there's not going to be any docs available + if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { + $ignore_functions[] = $tokens[$t][1]; + } + // Add this to our stack of unique references + $functions[] = $tokens[$t][1]; + } + } + + $functions = array_unique( $functions ); + sort( $functions ); + + /** + * Filters the list of functions and classes to be ignored from the documentation lookup. + * + * @since 2.8.0 + * + * @param array $ignore_functions Functions and classes to be ignored. + */ + $ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions ); + + $ignore_functions = array_unique( $ignore_functions ); + + $out = array(); + foreach ( $functions as $function ) { + if ( in_array( $function, $ignore_functions ) ) + continue; + $out[] = $function; + } + + return $out; +} + +/** + * Saves option for number of rows when listing posts, pages, comments, etc. + * + * @since 2.8.0 + */ +function set_screen_options() { + + if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { + check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); + + if ( !$user = wp_get_current_user() ) + return; + $option = $_POST['wp_screen_options']['option']; + $value = $_POST['wp_screen_options']['value']; + + if ( $option != sanitize_key( $option ) ) + return; + + $map_option = $option; + $type = str_replace('edit_', '', $map_option); + $type = str_replace('_per_page', '', $type); + if ( in_array( $type, get_taxonomies() ) ) + $map_option = 'edit_tags_per_page'; + elseif ( in_array( $type, get_post_types() ) ) + $map_option = 'edit_per_page'; + else + $option = str_replace('-', '_', $option); + + switch ( $map_option ) { + case 'edit_per_page': + case 'users_per_page': + case 'edit_comments_per_page': + case 'upload_per_page': + case 'edit_tags_per_page': + case 'plugins_per_page': + // Network admin + case 'sites_network_per_page': + case 'users_network_per_page': + case 'site_users_network_per_page': + case 'plugins_network_per_page': + case 'themes_network_per_page': + case 'site_themes_network_per_page': + $value = (int) $value; + if ( $value < 1 || $value > 999 ) + return; + break; + default: + + /** + * Filters a screen option value before it is set. + * + * The filter can also be used to modify non-standard [items]_per_page + * settings. See the parent function for a full list of standard options. + * + * Returning false to the filter will skip saving the current option. + * + * @since 2.8.0 + * + * @see set_screen_options() + * + * @param bool|int $value Screen option value. Default false to skip. + * @param string $option The option name. + * @param int $value The number of rows to use. + */ + $value = apply_filters( 'set-screen-option', false, $option, $value ); + + if ( false === $value ) + return; + break; + } + + update_user_meta($user->ID, $option, $value); + + $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ); + if ( isset( $_POST['mode'] ) ) { + $url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url ); + } + + wp_safe_redirect( $url ); + exit; + } +} + +/** + * Check if rewrite rule for WordPress already exists in the IIS 7+ configuration file + * + * @since 2.8.0 + * + * @return bool + * @param string $filename The file path to the configuration file + */ +function iis7_rewrite_rule_exists($filename) { + if ( ! file_exists($filename) ) + return false; + if ( ! class_exists( 'DOMDocument', false ) ) { + return false; + } + + $doc = new DOMDocument(); + if ( $doc->load($filename) === false ) + return false; + $xpath = new DOMXPath($doc); + $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); + if ( $rules->length == 0 ) + return false; + else + return true; +} + +/** + * Delete WordPress rewrite rule from web.config file if it exists there + * + * @since 2.8.0 + * + * @param string $filename Name of the configuration file + * @return bool + */ +function iis7_delete_rewrite_rule($filename) { + // If configuration file does not exist then rules also do not exist so there is nothing to delete + if ( ! file_exists($filename) ) + return true; + + if ( ! class_exists( 'DOMDocument', false ) ) { + return false; + } + + $doc = new DOMDocument(); + $doc->preserveWhiteSpace = false; + + if ( $doc -> load($filename) === false ) + return false; + $xpath = new DOMXPath($doc); + $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); + if ( $rules->length > 0 ) { + $child = $rules->item(0); + $parent = $child->parentNode; + $parent->removeChild($child); + $doc->formatOutput = true; + saveDomDocument($doc, $filename); + } + return true; +} + +/** + * Add WordPress rewrite rule to the IIS 7+ configuration file. + * + * @since 2.8.0 + * + * @param string $filename The file path to the configuration file + * @param string $rewrite_rule The XML fragment with URL Rewrite rule + * @return bool + */ +function iis7_add_rewrite_rule($filename, $rewrite_rule) { + if ( ! class_exists( 'DOMDocument', false ) ) { + return false; + } + + // If configuration file does not exist then we create one. + if ( ! file_exists($filename) ) { + $fp = fopen( $filename, 'w'); + fwrite($fp, ''); + fclose($fp); + } + + $doc = new DOMDocument(); + $doc->preserveWhiteSpace = false; + + if ( $doc->load($filename) === false ) + return false; + + $xpath = new DOMXPath($doc); + + // First check if the rule already exists as in that case there is no need to re-add it + $wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); + if ( $wordpress_rules->length > 0 ) + return true; + + // Check the XPath to the rewrite rule and create XML nodes if they do not exist + $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules'); + if ( $xmlnodes->length > 0 ) { + $rules_node = $xmlnodes->item(0); + } else { + $rules_node = $doc->createElement('rules'); + + $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite'); + if ( $xmlnodes->length > 0 ) { + $rewrite_node = $xmlnodes->item(0); + $rewrite_node->appendChild($rules_node); + } else { + $rewrite_node = $doc->createElement('rewrite'); + $rewrite_node->appendChild($rules_node); + + $xmlnodes = $xpath->query('/configuration/system.webServer'); + if ( $xmlnodes->length > 0 ) { + $system_webServer_node = $xmlnodes->item(0); + $system_webServer_node->appendChild($rewrite_node); + } else { + $system_webServer_node = $doc->createElement('system.webServer'); + $system_webServer_node->appendChild($rewrite_node); + + $xmlnodes = $xpath->query('/configuration'); + if ( $xmlnodes->length > 0 ) { + $config_node = $xmlnodes->item(0); + $config_node->appendChild($system_webServer_node); + } else { + $config_node = $doc->createElement('configuration'); + $doc->appendChild($config_node); + $config_node->appendChild($system_webServer_node); + } + } + } + } + + $rule_fragment = $doc->createDocumentFragment(); + $rule_fragment->appendXML($rewrite_rule); + $rules_node->appendChild($rule_fragment); + + $doc->encoding = "UTF-8"; + $doc->formatOutput = true; + saveDomDocument($doc, $filename); + + return true; +} + +/** + * Saves the XML document into a file + * + * @since 2.8.0 + * + * @param DOMDocument $doc + * @param string $filename + */ +function saveDomDocument($doc, $filename) { + $config = $doc->saveXML(); + $config = preg_replace("/([^\r])\n/", "$1\r\n", $config); + $fp = fopen($filename, 'w'); + fwrite($fp, $config); + fclose($fp); +} + +/** + * Display the default admin color scheme picker (Used in user-edit.php) + * + * @since 3.0.0 + * + * @global array $_wp_admin_css_colors + * + * @param int $user_id User ID. + */ +function admin_color_scheme_picker( $user_id ) { + global $_wp_admin_css_colors; + + ksort( $_wp_admin_css_colors ); + + if ( isset( $_wp_admin_css_colors['fresh'] ) ) { + // Set Default ('fresh') and Light should go first. + $_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) ); + } + + $current_color = get_user_option( 'admin_color', $user_id ); + + if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) { + $current_color = 'fresh'; + } + + ?> +
      + + $color_info ) : + + ?> +
      + /> + + + + + + colors as $html_color ) { + ?> + + + +
       
      +
      + +
      + icon_colors ) ) { + $icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors; + } elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) { + $icon_colors = $_wp_admin_css_colors['fresh']->icon_colors; + } else { + // Fall back to the default set of icon colors if the default scheme is missing. + $icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' ); + } + + echo '\n"; +} + +/** + * @since 3.3.0 + */ +function _ipad_meta() { + if ( wp_is_mobile() ) { + ?> + + sprintf( __( '%s is currently editing' ), $user->display_name ) ); + + if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) + $send['avatar_src'] = $matches[1]; + + $checked[$key] = $send; + } + } + } + + if ( ! empty( $checked ) ) + $response['wp-check-locked-posts'] = $checked; + + return $response; +} + +/** + * Check lock status on the New/Edit Post screen and refresh the lock + * + * @since 3.6.0 + * + * @param array $response The Heartbeat response. + * @param array $data The $_POST data sent. + * @param string $screen_id The screen id. + * @return array The Heartbeat response. + */ +function wp_refresh_post_lock( $response, $data, $screen_id ) { + if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) { + $received = $data['wp-refresh-post-lock']; + $send = array(); + + if ( ! $post_id = absint( $received['post_id'] ) ) + return $response; + + if ( ! current_user_can('edit_post', $post_id) ) + return $response; + + if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { + $error = array( + 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ) + ); + + if ( $avatar = get_avatar( $user->ID, 64 ) ) { + if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) + $error['avatar_src'] = $matches[1]; + } + + $send['lock_error'] = $error; + } else { + if ( $new_lock = wp_set_post_lock( $post_id ) ) + $send['new_lock'] = implode( ':', $new_lock ); + } + + $response['wp-refresh-post-lock'] = $send; + } + + return $response; +} + +/** + * Check nonce expiration on the New/Edit Post screen and refresh if needed + * + * @since 3.6.0 + * + * @param array $response The Heartbeat response. + * @param array $data The $_POST data sent. + * @param string $screen_id The screen id. + * @return array The Heartbeat response. + */ +function wp_refresh_post_nonces( $response, $data, $screen_id ) { + if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { + $received = $data['wp-refresh-post-nonces']; + $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); + + if ( ! $post_id = absint( $received['post_id'] ) ) { + return $response; + } + + if ( ! current_user_can( 'edit_post', $post_id ) ) { + return $response; + } + + $response['wp-refresh-post-nonces'] = array( + 'replace' => array( + 'getpermalinknonce' => wp_create_nonce('getpermalink'), + 'samplepermalinknonce' => wp_create_nonce('samplepermalink'), + 'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'), + '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ), + '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ), + ), + 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ), + ); + } + + return $response; +} + +/** + * Disable suspension of Heartbeat on the Add/Edit Post screens. + * + * @since 3.8.0 + * + * @global string $pagenow + * + * @param array $settings An array of Heartbeat settings. + * @return array Filtered Heartbeat settings. + */ +function wp_heartbeat_set_suspension( $settings ) { + global $pagenow; + + if ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) { + $settings['suspension'] = 'disable'; + } + + return $settings; +} + +/** + * Autosave with heartbeat + * + * @since 3.9.0 + * + * @param array $response The Heartbeat response. + * @param array $data The $_POST data sent. + * @return array The Heartbeat response. + */ +function heartbeat_autosave( $response, $data ) { + if ( ! empty( $data['wp_autosave'] ) ) { + $saved = wp_autosave( $data['wp_autosave'] ); + + if ( is_wp_error( $saved ) ) { + $response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() ); + } elseif ( empty( $saved ) ) { + $response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) ); + } else { + /* translators: draft saved date format, see https://secure.php.net/date */ + $draft_saved_date_format = __( 'g:i:s a' ); + /* translators: %s: date and time */ + $response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) ); + } + } + + return $response; +} + +/** + * Remove single-use URL parameters and create canonical link based on new URL. + * + * Remove specific query string parameters from a URL, create the canonical link, + * put it in the admin header, and change the current URL to match. + * + * @since 4.2.0 + */ +function wp_admin_canonical_url() { + $removable_query_args = wp_removable_query_args(); + + if ( empty( $removable_query_args ) ) { + return; + } + + // Ensure we're using an absolute URL. + $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + $filtered_url = remove_query_arg( $removable_query_args, $current_url ); + ?> + + + + + $hash, + 'newemail' => $value, + ); + update_option( 'adminhash', $new_admin_email ); + + $switched_locale = switch_to_locale( get_user_locale() ); + + /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ + $email_text = __( 'Howdy ###USERNAME###, + +You recently requested to have the administration email address on +your site changed. + +If this is correct, please click on the following link to change it: +###ADMIN_URL### + +You can safely ignore and delete this email if you do not want to +take this action. + +This email has been sent to ###EMAIL### + +Regards, +All at ###SITENAME### +###SITEURL###' ); + + /** + * Filters the text of the email sent when a change of site admin email address is attempted. + * + * The following strings have a special meaning and will get replaced dynamically: + * ###USERNAME### The current user's username. + * ###ADMIN_URL### The link to click on to confirm the email change. + * ###EMAIL### The proposed new site admin email address. + * ###SITENAME### The name of the site. + * ###SITEURL### The URL to the site. + * + * @since MU (3.0.0) + * @since 4.9.0 This filter is no longer Multisite specific. + * + * @param string $email_text Text in the email. + * @param array $new_admin_email { + * Data relating to the new site admin email address. + * + * @type string $hash The secure hash used in the confirmation link URL. + * @type string $newemail The proposed new site admin email address. + * } + */ + $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email ); + + $current_user = wp_get_current_user(); + $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); + $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content ); + $content = str_replace( '###EMAIL###', $value, $content ); + $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content ); + $content = str_replace( '###SITEURL###', home_url(), $content ); + + wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content ); + + if ( $switched_locale ) { + restore_previous_locale(); + } +} + +/** + * WP_Privacy_Policy_Content class. + * TODO: move this to a new file. + * + * @since 4.9.6 + */ +final class WP_Privacy_Policy_Content { + + private static $policy_content = array(); + + /** + * Constructor + * + * @since 4.9.6 + */ + private function __construct() {} + + /** + * Add content to the postbox shown when editing the privacy policy. + * + * Plugins and themes should suggest text for inclusion in the site's privacy policy. + * The suggested text should contain information about any functionality that affects user privacy, + * and will be shown in the Suggested Privacy Policy Content postbox. + * + * Intended for use from `wp_add_privacy_policy_content()`. + * + * $since 4.9.6 + * + * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy. + * @param string $policy_text The suggested content for inclusion in the policy. + */ + public static function add( $plugin_name, $policy_text ) { + if ( empty( $plugin_name ) || empty( $policy_text ) ) { + return; + } + + $data = array( + 'plugin_name' => $plugin_name, + 'policy_text' => $policy_text, + ); + + if ( ! in_array( $data, self::$policy_content, true ) ) { + self::$policy_content[] = $data; + } + } + + /** + * Quick check if any privacy info has changed. + * + * @since 4.9.6 + */ + public static function text_change_check() { + + $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); + + // The site doesn't have a privacy policy. + if ( empty( $policy_page_id ) ) { + return false; + } + + if ( ! current_user_can( 'edit_post', $policy_page_id ) ) { + return false; + } + + $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); + + // Updates are not relevant if the user has not reviewed any suggestions yet. + if ( empty( $old ) ) { + return false; + } + + $cached = get_option( '_wp_suggested_policy_text_has_changed' ); + + /* + * When this function is called before `admin_init`, `self::$policy_content` + * has not been populated yet, so use the cached result from the last + * execution instead. + */ + if ( ! did_action( 'admin_init' ) ) { + return 'changed' === $cached; + } + + $new = self::$policy_content; + + // Remove the extra values added to the meta. + foreach ( $old as $key => $data ) { + if ( ! empty( $data['removed'] ) ) { + unset( $old[ $key ] ); + continue; + } + + $old[ $key ] = array( + 'plugin_name' => $data['plugin_name'], + 'policy_text' => $data['policy_text'], + ); + } + + // Normalize the order of texts, to facilitate comparison. + sort( $old ); + sort( $new ); + + // The == operator (equal, not identical) was used intentionally. + // See http://php.net/manual/en/language.operators.array.php + if ( $new != $old ) { + // A plugin was activated or deactivated, or some policy text has changed. + // Show a notice on the relevant screens to inform the admin. + add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) ); + $state = 'changed'; + } else { + $state = 'not-changed'; + } + + // Cache the result for use before `admin_init` (see above). + if ( $cached !== $state ) { + update_option( '_wp_suggested_policy_text_has_changed', $state ); + } + + return 'changed' === $state; + } + + /** + * Output a warning when some privacy info has changed. + * + * @since 4.9.6 + */ + public static function policy_text_changed_notice() { + global $post; + + $screen = get_current_screen()->id; + + if ( 'privacy' !== $screen ) { + return; + } + + ?> +
      +

      review the guide and update your privacy policy.' ), + esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) ) + ); + ?>

      +
      + $old_data ) { + if ( ! empty( $old_data['removed'] ) ) { + // Remove the old policy text. + $update_cache = true; + continue; + } + + if ( ! empty( $old_data['updated'] ) ) { + // 'updated' is now 'added'. + $done[] = array( + 'plugin_name' => $old_data['plugin_name'], + 'policy_text' => $old_data['policy_text'], + 'added' => $old_data['updated'], + ); + $update_cache = true; + } else { + $done[] = $old_data; + } + } + + if ( $update_cache ) { + delete_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); + // Update the cache. + foreach ( $done as $data ) { + add_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content', $data ); + } + } + } + + /** + * Check for updated, added or removed privacy policy information from plugins. + * + * Caches the current info in post_meta of the policy page. + * + * @since 4.9.6 + * + * @return array The privacy policy text/informtion added by core and plugins. + */ + public static function get_suggested_policy_text() { + $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); + $checked = array(); + $time = time(); + $update_cache = false; + $new = self::$policy_content; + $old = array(); + + if ( $policy_page_id ) { + $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); + } + + // Check for no-changes and updates. + foreach ( $new as $new_key => $new_data ) { + foreach ( $old as $old_key => $old_data ) { + $found = false; + + if ( $new_data['policy_text'] === $old_data['policy_text'] ) { + // Use the new plugin name in case it was changed, translated, etc. + if ( $old_data['plugin_name'] !== $new_data['plugin_name'] ) { + $old_data['plugin_name'] = $new_data['plugin_name']; + $update_cache = true; + } + + // A plugin was re-activated. + if ( ! empty( $old_data['removed'] ) ) { + unset( $old_data['removed'] ); + $old_data['added'] = $time; + $update_cache = true; + } + + $checked[] = $old_data; + $found = true; + } elseif ( $new_data['plugin_name'] === $old_data['plugin_name'] ) { + // The info for the policy was updated. + $checked[] = array( + 'plugin_name' => $new_data['plugin_name'], + 'policy_text' => $new_data['policy_text'], + 'updated' => $time, + ); + $found = $update_cache = true; + } + + if ( $found ) { + unset( $new[ $new_key ], $old[ $old_key ] ); + continue 2; + } + } + } + + if ( ! empty( $new ) ) { + // A plugin was activated. + foreach ( $new as $new_data ) { + if ( ! empty( $new_data['plugin_name'] ) && ! empty( $new_data['policy_text'] ) ) { + $new_data['added'] = $time; + $checked[] = $new_data; + } + } + $update_cache = true; + } + + if ( ! empty( $old ) ) { + // A plugin was deactivated. + foreach ( $old as $old_data ) { + if ( ! empty( $old_data['plugin_name'] ) && ! empty( $old_data['policy_text'] ) ) { + $data = array( + 'plugin_name' => $old_data['plugin_name'], + 'policy_text' => $old_data['policy_text'], + 'removed' => $time, + ); + + $checked[] = $data; + } + } + $update_cache = true; + } + + if ( $update_cache && $policy_page_id ) { + delete_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); + // Update the cache. + foreach ( $checked as $data ) { + add_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content', $data ); + } + } + + return $checked; + } + + /** + * Add a notice with a link to the guide when editing the privacy policy page. + * + * @since 4.9.6 + * + * @param $post WP_Post The currently edited post. + */ + public static function notice( $post ) { + if ( ! ( $post instanceof WP_Post ) ) { + return; + } + + if ( ! current_user_can( 'manage_privacy_options' ) ) { + return; + } + + $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); + + if ( ! $policy_page_id || $policy_page_id != $post->ID ) { + return; + } + + ?> +
      +

      + Check out our guide%3$s for recommendations on what content to include, along with policies suggested by your plugins and theme.' ), + admin_url( 'tools.php?wp-privacy-policy-guide=1' ), + 'target="_blank"', + sprintf( + ' %s', + /* translators: accessibility text */ + __( '(opens in a new tab)' ) + ) + ); + ?> +

      +
      + ' . __( 'Introduction' ) . '' ); + $date_format = __( 'F j, Y' ); + $copy = __( 'Copy' ); + $return_to_top = '' . __( '↑ Return to Top' ) . ''; + + foreach ( $content_array as $section ) { + $class = $meta = $removed = ''; + + if ( ! empty( $section['removed'] ) ) { + $class = ' text-removed'; + $date = date_i18n( $date_format, $section['removed'] ); + $meta = sprintf( __( 'Removed %s.' ), $date ); + + $removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' ); + $removed = '

      ' . sprintf( $removed, $date ) . '

      '; + } elseif ( ! empty( $section['updated'] ) ) { + $class = ' text-updated'; + $date = date_i18n( $date_format, $section['updated'] ); + $meta = sprintf( __( 'Updated %s.' ), $date ); + } + + if ( $meta ) { + $meta = '
      ' . $meta . ''; + } + + $plugin_name = esc_html( $section['plugin_name'] ); + $toc_id = 'wp-privacy-policy-guide-' . sanitize_title( $plugin_name ); + $toc[] = sprintf( '
    • %2$s' . $meta . '
    • ', $toc_id, $plugin_name ); + + $content .= '
      '; + $content .= ' '; + /* translators: %s: plugin name */ + $content .= '

      ' . sprintf( __( 'Source: %s' ), $plugin_name ) . '

      '; + $content .= $removed; + + $content .= '
      ' . $section['policy_text'] . '
      '; + $content .= $return_to_top; + + if ( empty( $section['removed'] ) ) { + $content .= '
      '; + $content .= ''; + $content .= '
      '; + } + + $content .= "
      \n"; // End of .privacy-text-section. + } + + if ( count( $toc ) > 2 ) { + ?> +
      +

      +
        + +
      +
      + +
      +
      +   +

      +

      +

      +

      +

      +

      +
      + +
      + +
      +
      + ' . __( 'Suggested text:' ) . ' ' : ''; + $content = ''; + + // Start of the suggested privacy policy text. + $descr && $content .= + '
      '; + $content .= + '

      ' . __( 'Who we are' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should note your site URL, as well as the name of the company, organization, or individual behind it, and some accurate contact information.' ) . '

      ' . + '

      ' . __( 'The amount of information you may be required to show will vary depending on your local or national business regulations. You may, for example, be required to display a physical address, a registered address, or your company registration number.' ) . '

      '; + $content .= + /* translators: %s Site URL */ + '

      ' . $suggested_text . sprintf( __( 'Our website address is: %s.' ), get_bloginfo( 'url', 'display' ) ) . '

      ' . + + '

      ' . __( 'What personal data we collect and why we collect it' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should note what personal data you collect from users and site visitors. This may include personal data, such as name, email address, personal account preferences; transactional data, such as purchase information; and technical data, such as information about cookies.' ) . '

      ' . + '

      ' . __( 'You should also note any collection and retention of sensitive personal data, such as data concerning health.' ) . '

      ' . + '

      ' . __( 'In addition to listing what personal data you collect, you need to note why you collect it. These explanations must note either the legal basis for your data collection and retention or the active consent the user has given.' ) . '

      ' . + '

      ' . __( 'Personal data is not just created by a user’s interactions with your site. Personal data is also generated from technical processes such as contact forms, comments, cookies, analytics, and third party embeds.' ) . '

      ' . + '

      ' . __( 'By default WordPress does not collect any personal data about visitors, and only collects the data shown on the User Profile screen from registered users. However some of your plugins may collect personal data. You should add the relevant information below.' ) . '

      '; + + $content .= + '

      ' . __( 'Comments' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this subsection you should note what information is captured through comments. We have noted the data which WordPress collects by default.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection.' ) . '

      ' . + '

      ' . __( 'An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.' ) . '

      ' . + + '

      ' . __( 'Media' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this subsection you should note what information may be disclosed by users who can upload media files. All uploaded files are usually publicly accessible.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.' ) . '

      ' . + + '

      ' . __( 'Contact forms' ) . '

      '; + $descr && $content .= + '

      ' . __( 'By default, WordPress does not include a contact form. If you use a contact form plugin, use this subsection to note what personal data is captured when someone submits a contact form, and how long you keep it. For example, you may note that you keep contact form submissions for a certain period for customer service purposes, but you do not use the information submitted through them for marketing purposes.' ) . '

      '; + + $content .= + '

      ' . __( 'Cookies' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this subsection you should list the cookies your web site uses, including those set by your plugins, social media, and analytics. We have provided the cookies which WordPress installs by default.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.' ) . '

      ' . + '

      ' . __( 'If you have an account and you log in to this site, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.' ) . '

      ' . + '

      ' . __( 'When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.' ) . '

      ' . + '

      ' . __( 'If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.' ) . '

      ' . + + '

      ' . __( 'Embedded content from other websites' ) . '

      ' . + '

      ' . $suggested_text . __( 'Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.' ) . '

      ' . + '

      ' . __( 'These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracing your interaction with the embedded content if you have an account and are logged in to that website.' ) . '

      ' . + + '

      ' . __( 'Analytics' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this subsection you should note what analytics package you use, how users can opt out of analytics tracking, and a link to your analytics provider’s privacy policy, if any.' ) . '

      ' . + '

      ' . __( 'By default WordPress does not collect any analytics data. However, many web hosting accounts collect some anonymous analytics data. You may also have installed a WordPress plugin that provides analytics services. In that case, add information from that plugin here.' ) . '

      '; + + $content .= + '

      ' . __( 'Who we share your data with' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should name and list all third party providers with whom you share site data, including partners, cloud-based services, payment processors, and third party service providers, and note what data you share with them and why. Link to their own privacy policies if possible.' ) . '

      ' . + '

      ' . __( 'By default WordPress does not share any personal data with anyone.' ) . '

      '; + + $content .= + '

      ' . __( 'How long we retain your data' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should explain how long you retain personal data collected or processed by the web site. While it is your responsibility to come up with the schedule of how long you keep each dataset for and why you keep it, that information does need to be listed here. For example, you may want to say that you keep contact form entries for six months, analytics records for a year, and customer purchase records for ten years.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.' ) . '

      ' . + '

      ' . __( 'For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.' ) . '

      ' . + + '

      ' . __( 'What rights you have over your data' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should explain what rights your users have over their data and how they can invoke those rights.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.' ) . '

      ' . + + '

      ' . __( 'Where we send your data' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should list all transfers of your site data outside the European Union and describe the means by which that data is safeguarded to European data protection standards. This could include your web hosting, cloud storage, or other third party services.' ) . '

      ' . + '

      ' . __( 'European data protection law requires data about European residents which is transferred outside the European Union to be safeguarded to the same standards as if the data was in Europe. So in addition to listing where data goes, you should describe how you ensure that these standards are met either by yourself or by your third party providers, whether that is through an agreement such as Privacy Shield, model clauses in your contracts, or binding corporate rules.' ) . '

      '; + $content .= + '

      ' . $suggested_text . __( 'Visitor comments may be checked through an automated spam detection service.' ) . '

      ' . + + '

      ' . __( 'Your contact information' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should provide a contact method for privacy-specific concerns. If you are required to have a Data Protection Officer, list their name and full contact details here as well.' ) . '

      '; + + $content .= + '

      ' . __( 'Additional information' ) . '

      '; + $descr && $content .= + '

      ' . __( 'If you use your site for commercial purposes and you engage in more complex collection or processing of personal data, you should note the following information in your privacy policy in addition to the information we have already discussed.' ) . '

      '; + + $content .= + '

      ' . __( 'How we protect your data' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should explain what measures you have taken to protect your users’ data. This could include technical measures such as encryption; security measures such as two factor authentication; and measures such as staff training in data protection. If you have carried out a Privacy Impact Assessment, you can mention it here too.' ) . '

      '; + + $content .= + '

      ' . __( 'What data breach procedures we have in place' ) . '

      '; + $descr && $content .= + '

      ' . __( 'In this section you should explain what procedures you have in place to deal with data breaches, either potential or real, such as internal reporting systems, contact mechanisms, or bug bounties.' ) . '

      '; + + $content .= + '

      ' . __( 'What third parties we receive data from' ) . '

      '; + $descr && $content .= + '

      ' . __( 'If your web site receives data about users from third parties, including advertisers, this information must be included within the section of your privacy policy dealing with third party data.' ) . '

      '; + + $content .= + '

      ' . __( 'What automated decision making and/or profiling we do with user data' ) . '

      '; + $descr && $content .= + '

      ' . __( 'If your web site provides a service which includes automated decision making - for example, allowing customers to apply for credit, or aggregating their data into an advertising profile - you must note that this is taking place, and include information about how that information is used, what decisions are made with that aggregated data, and what rights users have over decisions made without human intervention.' ) . '

      '; + + $content .= + '

      ' . __( 'Industry regulatory disclosure requirements' ) . '

      '; + $descr && $content .= + '

      ' . __( 'If you are a member of a regulated industry, or if you are subject to additional privacy laws, you may be required to disclose that information here.' ) . '

      ' . + '
      '; + // End of the suggested privacy policy text. + + /** + * Filters the default content suggested for inclusion in a privacy policy. + * + * @since 4.9.6 + * + * @param $content string The default policy content. + */ + return apply_filters( 'wp_get_default_privacy_policy_content', $content ); + } + + /** + * Add the suggested privacy policy text to the policy postbox. + * + * @since 4.9.6 + */ + public static function add_suggested_content() { + $content = self::get_default_content( true ); + wp_add_privacy_policy_content( __( 'WordPress' ), $content ); + } +} diff --git a/backend/wp-admin/includes/ms-admin-filters.php b/backend/wp-admin/includes/ms-admin-filters.php new file mode 100644 index 0000000..02fbf68 --- /dev/null +++ b/backend/wp-admin/includes/ms-admin-filters.php @@ -0,0 +1,44 @@ + ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { + /* translators: 1: Maximum allowed file size in kilobytes */ + $file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ); + } + + if ( upload_is_user_over_quota( false ) ) { + $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); + } + + if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) { + wp_die( $file['error'] . ' ' . __( 'Back' ) . '' ); + } + + return $file; +} + +/** + * Delete a site. + * + * @since 3.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $blog_id Site ID. + * @param bool $drop True if site's database tables should be dropped. Default is false. + */ +function wpmu_delete_blog( $blog_id, $drop = false ) { + global $wpdb; + + $switch = false; + if ( get_current_blog_id() != $blog_id ) { + $switch = true; + switch_to_blog( $blog_id ); + } + + $blog = get_site( $blog_id ); + /** + * Fires before a site is deleted. + * + * @since MU (3.0.0) + * + * @param int $blog_id The site ID. + * @param bool $drop True if site's table should be dropped. Default is false. + */ + do_action( 'delete_blog', $blog_id, $drop ); + + $users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) ); + + // Remove users from this blog. + if ( ! empty( $users ) ) { + foreach ( $users as $user_id ) { + remove_user_from_blog( $user_id, $blog_id ); + } + } + + update_blog_status( $blog_id, 'deleted', 1 ); + + $current_network = get_network(); + + // If a full blog object is not available, do not destroy anything. + if ( $drop && ! $blog ) { + $drop = false; + } + + // Don't destroy the initial, main, or root blog. + if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) { + $drop = false; + } + + $upload_path = trim( get_option( 'upload_path' ) ); + + // If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable. + if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) { + $drop = false; + } + + if ( $drop ) { + $uploads = wp_get_upload_dir(); + + $tables = $wpdb->tables( 'blog' ); + /** + * Filters the tables to drop when the site is deleted. + * + * @since MU (3.0.0) + * + * @param array $tables The site tables to be dropped. + * @param int $blog_id The ID of the site to drop tables for. + */ + $drop_tables = apply_filters( 'wpmu_drop_tables', $tables, $blog_id ); + + foreach ( (array) $drop_tables as $table ) { + $wpdb->query( "DROP TABLE IF EXISTS `$table`" ); + } + + $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) ); + + /** + * Filters the upload base directory to delete when the site is deleted. + * + * @since MU (3.0.0) + * + * @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir() + * @param int $blog_id The site ID. + */ + $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id ); + $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); + $top_dir = $dir; + $stack = array($dir); + $index = 0; + + while ( $index < count( $stack ) ) { + // Get indexed directory from stack + $dir = $stack[$index]; + + $dh = @opendir( $dir ); + if ( $dh ) { + while ( ( $file = @readdir( $dh ) ) !== false ) { + if ( $file == '.' || $file == '..' ) + continue; + + if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) { + $stack[] = $dir . DIRECTORY_SEPARATOR . $file; + } elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) { + @unlink( $dir . DIRECTORY_SEPARATOR . $file ); + } + } + @closedir( $dh ); + } + $index++; + } + + $stack = array_reverse( $stack ); // Last added dirs are deepest + foreach ( (array) $stack as $dir ) { + if ( $dir != $top_dir) + @rmdir( $dir ); + } + + clean_blog_cache( $blog ); + } + + /** + * Fires after the site is deleted from the network. + * + * @since 4.8.0 + * + * @param int $blog_id The site ID. + * @param bool $drop True if site's tables should be dropped. Default is false. + */ + do_action( 'deleted_blog', $blog_id, $drop ); + + if ( $switch ) + restore_current_blog(); +} + +/** + * Delete a user from the network and remove from all sites. + * + * @since 3.0.0 + * + * @todo Merge with wp_delete_user() ? + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $id The user ID. + * @return bool True if the user was deleted, otherwise false. + */ +function wpmu_delete_user( $id ) { + global $wpdb; + + if ( ! is_numeric( $id ) ) { + return false; + } + + $id = (int) $id; + $user = new WP_User( $id ); + + if ( !$user->exists() ) + return false; + + // Global super-administrators are protected, and cannot be deleted. + $_super_admins = get_super_admins(); + if ( in_array( $user->user_login, $_super_admins, true ) ) { + return false; + } + + /** + * Fires before a user is deleted from the network. + * + * @since MU (3.0.0) + * + * @param int $id ID of the user about to be deleted from the network. + */ + do_action( 'wpmu_delete_user', $id ); + + $blogs = get_blogs_of_user( $id ); + + if ( ! empty( $blogs ) ) { + foreach ( $blogs as $blog ) { + switch_to_blog( $blog->userblog_id ); + remove_user_from_blog( $id, $blog->userblog_id ); + + $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); + foreach ( (array) $post_ids as $post_id ) { + wp_delete_post( $post_id ); + } + + // Clean links + $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); + + if ( $link_ids ) { + foreach ( $link_ids as $link_id ) + wp_delete_link( $link_id ); + } + + restore_current_blog(); + } + } + + $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); + foreach ( $meta as $mid ) + delete_metadata_by_mid( 'user', $mid ); + + $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); + + clean_user_cache( $user ); + + /** This action is documented in wp-admin/includes/user.php */ + do_action( 'deleted_user', $id, null ); + + return true; +} + +/** + * Check whether a site has used its allotted upload space. + * + * @since MU (3.0.0) + * + * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true. + * @return bool True if user is over upload space quota, otherwise false. + */ +function upload_is_user_over_quota( $echo = true ) { + if ( get_site_option( 'upload_space_check_disabled' ) ) + return false; + + $space_allowed = get_space_allowed(); + if ( ! is_numeric( $space_allowed ) ) { + $space_allowed = 10; // Default space allowed is 10 MB + } + $space_used = get_space_used(); + + if ( ( $space_allowed - $space_used ) < 0 ) { + if ( $echo ) + _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); + return true; + } else { + return false; + } +} + +/** + * Displays the amount of disk space used by the current site. Not used in core. + * + * @since MU (3.0.0) + */ +function display_space_usage() { + $space_allowed = get_space_allowed(); + $space_used = get_space_used(); + + $percent_used = ( $space_used / $space_allowed ) * 100; + + if ( $space_allowed > 1000 ) { + $space = number_format( $space_allowed / KB_IN_BYTES ); + /* translators: Gigabytes */ + $space .= __( 'GB' ); + } else { + $space = number_format( $space_allowed ); + /* translators: Megabytes */ + $space .= __( 'MB' ); + } + ?> + + + + + + + + + + update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) ); + + $user = new WP_User( $id ); + clean_user_cache( $user ); + + if ( $pref == 'spam' ) { + if ( $value == 1 ) { + /** + * Fires after the user is marked as a SPAM user. + * + * @since 3.0.0 + * + * @param int $id ID of the user marked as SPAM. + */ + do_action( 'make_spam_user', $id ); + } else { + /** + * Fires after the user is marked as a HAM user. Opposite of SPAM. + * + * @since 3.0.0 + * + * @param int $id ID of the user marked as HAM. + */ + do_action( 'make_ham_user', $id ); + } + } + + return $value; +} + +/** + * Cleans the user cache for a specific user. + * + * @since 3.0.0 + * + * @param int $id The user ID. + * @return bool|int The ID of the refreshed user or false if the user does not exist. + */ +function refresh_user_details( $id ) { + $id = (int) $id; + + if ( !$user = get_userdata( $id ) ) + return false; + + clean_user_cache( $user ); + + return $id; +} + +/** + * Returns the language for a language code. + * + * @since 3.0.0 + * + * @param string $code Optional. The two-letter language code. Default empty. + * @return string The language corresponding to $code if it exists. If it does not exist, + * then the first two letters of $code is returned. + */ +function format_code_lang( $code = '' ) { + $code = strtolower( substr( $code, 0, 2 ) ); + $lang_codes = array( + 'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', + 'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree', + 'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic', + 'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue', + 'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz', + 'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam', + 'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', + 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', + 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', + 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', + 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' ); + + /** + * Filters the language codes. + * + * @since MU (3.0.0) + * + * @param array $lang_codes Key/value pair of language codes where key is the short version. + * @param string $code A two-letter designation of the language. + */ + $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); + return strtr( $code, $lang_codes ); +} + +/** + * Synchronize category and post tag slugs when global terms are enabled. + * + * @since 3.0.0 + * + * @param object $term The term. + * @param string $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are + * the only taxonomies which are processed by this function; anything else + * will be returned untouched. + * @return object|array Returns `$term`, after filtering the 'slug' field with sanitize_title() + * if $taxonomy is 'category' or 'post_tag'. + */ +function sync_category_tag_slugs( $term, $taxonomy ) { + if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) { + if ( is_object( $term ) ) { + $term->slug = sanitize_title( $term->name ); + } else { + $term['slug'] = sanitize_title( $term['name'] ); + } + } + return $term; +} + +/** + * Displays an access denied message when a user tries to view a site's dashboard they + * do not have access to. + * + * @since 3.2.0 + * @access private + */ +function _access_denied_splash() { + if ( ! is_user_logged_in() || is_network_admin() ) + return; + + $blogs = get_blogs_of_user( get_current_user_id() ); + + if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) + return; + + $blog_name = get_bloginfo( 'name' ); + + if ( empty( $blogs ) ) + wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 ); + + $output = '

      ' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '

      '; + $output .= '

      ' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '

      '; + + $output .= '

      ' . __('Your Sites') . '

      '; + $output .= ''; + + foreach ( $blogs as $blog ) { + $output .= ''; + $output .= ""; + $output .= ''; + $output .= ''; + } + + $output .= '
      {$blog->blogname}' . __( 'Visit Dashboard' ) . ' | ' . + '' . __( 'View Site' ) . '
      '; + + wp_die( $output, 403 ); +} + +/** + * Checks if the current user has permissions to import new users. + * + * @since 3.0.0 + * + * @param string $permission A permission to be checked. Currently not used. + * @return bool True if the user has proper permissions, false if they do not. + */ +function check_import_new_users( $permission ) { + if ( ! current_user_can( 'manage_network_users' ) ) { + return false; + } + + return true; +} +// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too. + +/** + * Generates and displays a drop-down of available languages. + * + * @since 3.0.0 + * + * @param array $lang_files Optional. An array of the language files. Default empty array. + * @param string $current Optional. The current language code. Default empty. + */ +function mu_dropdown_languages( $lang_files = array(), $current = '' ) { + $flag = false; + $output = array(); + + foreach ( (array) $lang_files as $val ) { + $code_lang = basename( $val, '.mo' ); + + if ( $code_lang == 'en_US' ) { // American English + $flag = true; + $ae = __( 'American English' ); + $output[$ae] = ''; + } elseif ( $code_lang == 'en_GB' ) { // British English + $flag = true; + $be = __( 'British English' ); + $output[$be] = ''; + } else { + $translated = format_code_lang( $code_lang ); + $output[$translated] = ''; + } + + } + + if ( $flag === false ) // WordPress english + $output[] = '"; + + // Order by name + uksort( $output, 'strnatcasecmp' ); + + /** + * Filters the languages available in the dropdown. + * + * @since MU (3.0.0) + * + * @param array $output HTML output of the dropdown. + * @param array $lang_files Available language files. + * @param string $current The current language code. + */ + $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current ); + + echo implode( "\n\t", $output ); +} + +/** + * Displays an admin notice to upgrade all sites after a core upgrade. + * + * @since 3.0.0 + * + * @global int $wp_db_version The version number of the database. + * @global string $pagenow + * + * @return false False if the current user is not a super admin. + */ +function site_admin_notice() { + global $wp_db_version, $pagenow; + + if ( ! current_user_can( 'upgrade_network' ) ) { + return false; + } + + if ( 'upgrade.php' == $pagenow ) { + return; + } + + if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) { + echo "
      " . sprintf( __( 'Thank you for Updating! Please visit the Upgrade Network page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "
      "; + } +} + +/** + * Avoids a collision between a site slug and a permalink slug. + * + * In a subdirectory installation this will make sure that a site and a post do not use the + * same subdirectory by checking for a site with the same name as a new post. + * + * @since 3.0.0 + * + * @param array $data An array of post data. + * @param array $postarr An array of posts. Not currently used. + * @return array The new array of post data after checking for collisions. + */ +function avoid_blog_page_permalink_collision( $data, $postarr ) { + if ( is_subdomain_install() ) + return $data; + if ( $data['post_type'] != 'page' ) + return $data; + if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) + return $data; + if ( !is_main_site() ) + return $data; + + $post_name = $data['post_name']; + $c = 0; + while( $c < 10 && get_id_from_blogname( $post_name ) ) { + $post_name .= mt_rand( 1, 10 ); + $c ++; + } + if ( $post_name != $data['post_name'] ) { + $data['post_name'] = $post_name; + } + return $data; +} + +/** + * Handles the display of choosing a user's primary site. + * + * This displays the user's primary site and allows the user to choose + * which site is primary. + * + * @since 3.0.0 + */ +function choose_primary_blog() { + ?> + + + + + + +
      + 1 ) { + $found = false; + ?> + + userblog_id ); + } + } elseif ( count( $all_blogs ) == 1 ) { + $blog = reset( $all_blogs ); + echo esc_url( get_home_url( $blog->userblog_id ) ); + if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list. + update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); + } else { + echo "N/A"; + } + ?> +
      + + + +

      + + +

      + +

      + + +
      + + ID ) . '">' . $current_user->user_login . ''; ?> + + ID ) ) { + wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); + } + + if ( in_array( $delete_user->user_login, $site_admins ) ) { + wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '' . $delete_user->user_login . '' ) ); + } + ?> + + + + "; + } else { + ?> + + +
      user_login; ?> + ' . "\n"; ?> +

      ' . $delete_user->user_login . '' + ); ?>

      + $details ) { + $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) ); + if ( is_array( $blog_users ) && !empty( $blog_users ) ) { + $user_site = "{$details->blogname}"; + $user_dropdown = ''; + $user_dropdown .= "\n"; + ?> +
        +
      • +
      • +
      • +
      • +
      +

      + +
      + +

      + +

      + +
      + + + array( 'label' => __( 'Info' ), 'url' => 'site-info.php', 'cap' => 'manage_sites' ), + 'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php', 'cap' => 'manage_sites' ), + 'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php', 'cap' => 'manage_sites' ), + 'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' ) + ) ); + + // Parse arguments + $r = wp_parse_args( $args, array( + 'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0, + 'links' => $links, + 'selected' => 'site-info', + ) ); + + // Setup the links array + $screen_links = array(); + + // Loop through tabs + foreach ( $r['links'] as $link_id => $link ) { + + // Skip link if user can't access + if ( ! current_user_can( $link['cap'], $r['blog_id'] ) ) { + continue; + } + + // Link classes + $classes = array( 'nav-tab' ); + + // Selected is set by the parent OR assumed by the $pagenow global + if ( $r['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) { + $classes[] = 'nav-tab-active'; + } + + // Escape each class + $esc_classes = implode( ' ', $classes ); + + // Get the URL for this link + $url = add_query_arg( array( 'id' => $r['blog_id'] ), network_admin_url( $link['url'] ) ); + + // Add link to nav links + $screen_links[ $link_id ] = '' . esc_html( $link['label'] ) . ''; + } + + // All done! + echo ''; +} + +/** + * Returns the arguments for the help tab on the Edit Site screens. + * + * @since 4.9.0 + * + * @return array Help tab arguments. + */ +function get_site_screen_help_tab_args() { + return array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => + '

      ' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '

      ' . + '

      ' . __('Info — The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '

      ' . + '

      ' . __('Users — This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '

      ' . + '

      ' . sprintf( __('Themes — This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the Network Themes screen.' ), network_admin_url( 'themes.php' ) ) . '

      ' . + '

      ' . __('Settings — This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '

      ' + ); +} + +/** + * Returns the content for the help sidebar on the Edit Site screens. + * + * @since 4.9.0 + * + * @return string Help sidebar content. + */ +function get_site_screen_help_sidebar_content() { + return '

      ' . __('For more information:') . '

      ' . + '

      ' . __('Documentation on Site Management') . '

      ' . + '

      ' . __('Support Forums') . '

      '; +} diff --git a/backend/wp-admin/includes/nav-menu.php b/backend/wp-admin/includes/nav-menu.php new file mode 100644 index 0000000..d6acfca --- /dev/null +++ b/backend/wp-admin/includes/nav-menu.php @@ -0,0 +1,1137 @@ + $object_id, + 'post_title' => get_the_title( $object_id ), + 'post_type' => get_post_type( $object_id ), + ) + ); + echo "\n"; + } + } + } elseif ( taxonomy_exists( $object_type ) ) { + if ( isset( $request['ID'] ) ) { + $object_id = (int) $request['ID']; + if ( 'markup' == $response_format ) { + echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); + } elseif ( 'json' == $response_format ) { + $post_obj = get_term( $object_id, $object_type ); + echo wp_json_encode( + array( + 'ID' => $object_id, + 'post_title' => $post_obj->name, + 'post_type' => $object_type, + ) + ); + echo "\n"; + } + } + + } + + } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) { + if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { + $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) ); + $args = array_merge( + $args, + array( + 'no_found_rows' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'posts_per_page' => 10, + 'post_type' => $matches[2], + 's' => $query, + ) + ); + if ( isset( $post_type_obj->_default_query ) ) { + $args = array_merge( $args, (array) $post_type_obj->_default_query ); + } + $search_results_query = new WP_Query( $args ); + if ( ! $search_results_query->have_posts() ) { + return; + } + while ( $search_results_query->have_posts() ) { + $post = $search_results_query->next_post(); + if ( 'markup' == $response_format ) { + $var_by_ref = $post->ID; + echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); + } elseif ( 'json' == $response_format ) { + echo wp_json_encode( + array( + 'ID' => $post->ID, + 'post_title' => get_the_title( $post->ID ), + 'post_type' => $matches[2], + ) + ); + echo "\n"; + } + } + } elseif ( 'taxonomy' == $matches[1] ) { + $terms = get_terms( $matches[2], array( + 'name__like' => $query, + 'number' => 10, + )); + if ( empty( $terms ) || is_wp_error( $terms ) ) + return; + foreach ( (array) $terms as $term ) { + if ( 'markup' == $response_format ) { + echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); + } elseif ( 'json' == $response_format ) { + echo wp_json_encode( + array( + 'ID' => $term->term_id, + 'post_title' => $term->name, + 'post_type' => $matches[2], + ) + ); + echo "\n"; + } + } + } + } +} + +/** + * Register nav menu meta boxes and advanced menu items. + * + * @since 3.0.0 + **/ +function wp_nav_menu_setup() { + // Register meta boxes + wp_nav_menu_post_type_meta_boxes(); + add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); + wp_nav_menu_taxonomy_meta_boxes(); + + // Register advanced menu items (columns) + add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); + + // If first time editing, disable advanced items by default. + if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { + $user = wp_get_current_user(); + update_user_option($user->ID, 'managenav-menuscolumnshidden', + array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ), + true); + } +} + +/** + * Limit the amount of meta boxes to pages, posts, links, and categories for first time users. + * + * @since 3.0.0 + * + * @global array $wp_meta_boxes + **/ +function wp_initial_nav_menu_meta_boxes() { + global $wp_meta_boxes; + + if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) + return; + + $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); + $hidden_meta_boxes = array(); + + foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) { + foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) { + foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) { + if ( in_array( $box['id'], $initial_meta_boxes ) ) { + unset( $box['id'] ); + } else { + $hidden_meta_boxes[] = $box['id']; + } + } + } + } + + $user = wp_get_current_user(); + update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); +} + +/** + * Creates meta boxes for any post type menu item.. + * + * @since 3.0.0 + */ +function wp_nav_menu_post_type_meta_boxes() { + $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); + + if ( ! $post_types ) + return; + + foreach ( $post_types as $post_type ) { + /** + * Filters whether a menu items meta box will be added for the current + * object type. + * + * If a falsey value is returned instead of an object, the menu items + * meta box for the current meta box object will not be added. + * + * @since 3.0.0 + * + * @param object $meta_box_object The current object to add a menu items + * meta box for. + */ + $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); + if ( $post_type ) { + $id = $post_type->name; + // Give pages a higher priority. + $priority = ( 'page' == $post_type->name ? 'core' : 'default' ); + add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); + } + } +} + +/** + * Creates meta boxes for any taxonomy menu item. + * + * @since 3.0.0 + */ +function wp_nav_menu_taxonomy_meta_boxes() { + $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); + + if ( !$taxonomies ) + return; + + foreach ( $taxonomies as $tax ) { + /** This filter is documented in wp-admin/includes/nav-menu.php */ + $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); + if ( $tax ) { + $id = $tax->name; + add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); + } + } +} + +/** + * Check whether to disable the Menu Locations meta box submit button + * + * @since 3.6.0 + * + * @global bool $one_theme_location_no_menus to determine if no menus exist + * + * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu + * @return string Disabled attribute if at least one menu exists, false if not + */ +function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { + global $one_theme_location_no_menus; + + if ( $one_theme_location_no_menus ) + return false; + + return disabled( $nav_menu_selected_id, 0 ); +} + +/** + * Displays a meta box for the custom links menu item. + * + * @since 3.0.0 + * + * @global int $_nav_menu_placeholder + * @global int|string $nav_menu_selected_id + */ +function wp_nav_menu_item_link_meta_box() { + global $_nav_menu_placeholder, $nav_menu_selected_id; + + $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1; + + ?> +
      + + + + + +

      + + class="button submit-add-to-menu right" value="" name="add-custom-menu-item" id="submit-customlinkdiv" /> + + +

      + +
      + name; + + // Paginate browsing for large numbers of post objects. + $per_page = 50; + $pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; + $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; + + $args = array( + 'offset' => $offset, + 'order' => 'ASC', + 'orderby' => 'title', + 'posts_per_page' => $per_page, + 'post_type' => $post_type_name, + 'suppress_filters' => true, + 'update_post_term_cache' => false, + 'update_post_meta_cache' => false + ); + + if ( isset( $box['args']->_default_query ) ) + $args = array_merge($args, (array) $box['args']->_default_query ); + + // @todo transient caching of these results with proper invalidation on updating of a post of this type + $get_posts = new WP_Query; + $posts = $get_posts->query( $args ); + if ( ! $get_posts->post_count ) { + echo '

      ' . __( 'No items.' ) . '

      '; + return; + } + + $num_pages = $get_posts->max_num_pages; + + $page_links = paginate_links( array( + 'base' => add_query_arg( + array( + $post_type_name . '-tab' => 'all', + 'paged' => '%#%', + 'item-type' => 'post_type', + 'item-object' => $post_type_name, + ) + ), + 'format' => '', + 'prev_text' => '' . __( '«' ) . '', + 'next_text' => '' . __( '»' ) . '', + 'before_page_number' => '' . __( 'Page' ) . ' ', + 'total' => $num_pages, + 'current' => $pagenum + )); + + $db_fields = false; + if ( is_post_type_hierarchical( $post_type_name ) ) { + $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + } + + $walker = new Walker_Nav_Menu_Checklist( $db_fields ); + + $current_tab = 'most-recent'; + if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) { + $current_tab = $_REQUEST[$post_type_name . '-tab']; + } + + if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { + $current_tab = 'search'; + } + + $removed_args = array( + 'action', + 'customlink-tab', + 'edit-menu-item', + 'menu-item', + 'page-tab', + '_wpnonce', + ); + + ?> +
      + + +
      +
        + 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); + $most_recent = $get_posts->query( $recent_args ); + $args['walker'] = $walker; + + /** + * Filters the posts displayed in the 'Most Recent' tab of the current + * post type's menu items meta box. + * + * The dynamic portion of the hook name, `$post_type_name`, refers to the post type name. + * + * @since 4.3.0 + * @since 4.9.0 Added the `$recent_args` parameter. + * + * @param array $most_recent An array of post objects being listed. + * @param array $args An array of WP_Query arguments for the meta box. + * @param array $box Arguments passed to wp_nav_menu_item_post_type_meta_box(). + * @param array $recent_args An array of WP_Query arguments for 'Most Recent' tab. + */ + $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args ); + + echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args ); + ?> +
      +
      + + + +
      + + + +
        + front_or_home = true; + array_unshift( $posts, $front_page_obj ); + } else { + $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; + array_unshift( $posts, (object) array( + 'front_or_home' => true, + 'ID' => 0, + 'object_id' => $_nav_menu_placeholder, + 'post_content' => '', + 'post_excerpt' => '', + 'post_parent' => '', + 'post_title' => _x('Home', 'nav menu home label'), + 'post_type' => 'nav_menu_item', + 'type' => 'custom', + 'url' => home_url('/'), + ) ); + } + } + + $post_type = get_post_type_object( $post_type_name ); + + if ( $post_type->has_archive ) { + $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; + array_unshift( $posts, (object) array( + 'ID' => 0, + 'object_id' => $_nav_menu_placeholder, + 'object' => $post_type_name, + 'post_content' => '', + 'post_excerpt' => '', + 'post_title' => $post_type->labels->archives, + 'post_type' => 'nav_menu_item', + 'type' => 'post_type_archive', + 'url' => get_post_type_archive_link( $post_type_name ), + ) ); + } + + /** + * Filters the posts displayed in the 'View All' tab of the current + * post type's menu items meta box. + * + * The dynamic portion of the hook name, `$post_type_name`, refers + * to the slug of the current post type. + * + * @since 3.2.0 + * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. + * + * @see WP_Query::query() + * + * @param array $posts The posts for the current post type. + * @param array $args An array of WP_Query arguments. + * @param WP_Post_Type $post_type The current post type object for this menu item meta box. + */ + $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); + + $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args ); + + if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) { + $checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items); + + } + + echo $checkbox_items; + ?> +
      + + + +
      + +

      + + + + + + class="button submit-add-to-menu right" value="" name="add-post-type-menu-item" id="" /> + + +

      + +
      + name; + $taxonomy = get_taxonomy( $taxonomy_name ); + + // Paginate browsing for large numbers of objects. + $per_page = 50; + $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; + $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; + + $args = array( + 'child_of' => 0, + 'exclude' => '', + 'hide_empty' => false, + 'hierarchical' => 1, + 'include' => '', + 'number' => $per_page, + 'offset' => $offset, + 'order' => 'ASC', + 'orderby' => 'name', + 'pad_counts' => false, + ); + + $terms = get_terms( $taxonomy_name, $args ); + + if ( ! $terms || is_wp_error($terms) ) { + echo '

      ' . __( 'No items.' ) . '

      '; + return; + } + + $num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page ); + + $page_links = paginate_links( array( + 'base' => add_query_arg( + array( + $taxonomy_name . '-tab' => 'all', + 'paged' => '%#%', + 'item-type' => 'taxonomy', + 'item-object' => $taxonomy_name, + ) + ), + 'format' => '', + 'prev_text' => '' . __( '«' ) . '', + 'next_text' => '' . __( '»' ) . '', + 'before_page_number' => '' . __( 'Page' ) . ' ', + 'total' => $num_pages, + 'current' => $pagenum + )); + + $db_fields = false; + if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { + $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); + } + + $walker = new Walker_Nav_Menu_Checklist( $db_fields ); + + $current_tab = 'most-used'; + if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) { + $current_tab = $_REQUEST[$taxonomy_name . '-tab']; + } + + if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { + $current_tab = 'search'; + } + + $removed_args = array( + 'action', + 'customlink-tab', + 'edit-menu-item', + 'menu-item', + 'page-tab', + '_wpnonce', + ); + + ?> +
      + + +
      +
        + 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); + $args['walker'] = $walker; + echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args ); + ?> +
      +
      + +
      + + + +
        + +
      + + + +
      + +
      + $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) ); + } else { + $searched = ''; + $search_results = array(); + } + ?> +

      + + + + 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> +

      + +
        + + + +
      • get_error_message(); ?>
      • + +
      • + +
      +
      + +

      + + + + + + class="button submit-add-to-menu right" value="" name="add-taxonomy-menu-item" id="" /> + + +

      + +
      + $_item_object_data ) { + if ( + // Checkbox is not checked. + empty( $_item_object_data['menu-item-object-id'] ) && + ( + // And item type either isn't set. + ! isset( $_item_object_data['menu-item-type'] ) || + // Or URL is the default. + in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || + ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page) + // Or it *is* a custom menu item that already exists. + ! empty( $_item_object_data['menu-item-db-id'] ) + ) + ) { + // Then this potential menu item is not getting added to this menu. + continue; + } + + // If this possible menu item doesn't actually have a menu database ID yet. + if ( + empty( $_item_object_data['menu-item-db-id'] ) || + ( 0 > $_possible_db_id ) || + $_possible_db_id != $_item_object_data['menu-item-db-id'] + ) { + $_actual_db_id = 0; + } else { + $_actual_db_id = (int) $_item_object_data['menu-item-db-id']; + } + + $args = array( + 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), + 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), + 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), + 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), + 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), + 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), + 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), + 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), + 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), + 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), + 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), + 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), + 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), + ); + + $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); + + } + } + return $items_saved; +} + +/** + * Adds custom arguments to some of the meta box object types. + * + * @since 3.0.0 + * + * @access private + * + * @param object $object The post type or taxonomy meta-object. + * @return object The post type of taxonomy object. + */ +function _wp_nav_menu_meta_box_object( $object = null ) { + if ( isset( $object->name ) ) { + + if ( 'page' == $object->name ) { + $object->_default_query = array( + 'orderby' => 'menu_order title', + 'post_status' => 'publish', + ); + + // Posts should show only published items. + } elseif ( 'post' == $object->name ) { + $object->_default_query = array( + 'post_status' => 'publish', + ); + + // Categories should be in reverse chronological order. + } elseif ( 'category' == $object->name ) { + $object->_default_query = array( + 'orderby' => 'id', + 'order' => 'DESC', + ); + + // Custom post types should show only published items. + } else { + $object->_default_query = array( + 'post_status' => 'publish', + ); + } + } + + return $object; +} + +/** + * Returns the menu formatted to edit. + * + * @since 3.0.0 + * + * @param int $menu_id Optional. The ID of the menu to format. Default 0. + * @return string|WP_Error $output The menu formatted to edit or error object on failure. + */ +function wp_get_nav_menu_to_edit( $menu_id = 0 ) { + $menu = wp_get_nav_menu_object( $menu_id ); + + // If the menu exists, get its items. + if ( is_nav_menu( $menu ) ) { + $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') ); + $result = '
      ' : '">'; + $result .= '

      ' . __( 'Add menu items from the column on the left.' ) . '

      '; + $result .= '
      '; + + if ( empty($menu_items) ) + return $result . ' '; + + /** + * Filters the Walker class used when adding nav menu items. + * + * @since 3.0.0 + * + * @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'. + * @param int $menu_id ID of the menu being rendered. + */ + $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); + + if ( class_exists( $walker_class_name ) ) { + $walker = new $walker_class_name; + } else { + return new WP_Error( 'menu_walker_not_exist', + /* translators: %s: walker class name */ + sprintf( __( 'The Walker class named %s does not exist.' ), + '' . $walker_class_name . '' + ) + ); + } + + $some_pending_menu_items = $some_invalid_menu_items = false; + foreach ( (array) $menu_items as $menu_item ) { + if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) + $some_pending_menu_items = true; + if ( ! empty( $menu_item->_invalid ) ) + $some_invalid_menu_items = true; + } + + if ( $some_pending_menu_items ) { + $result .= '

      ' . __( 'Click Save Menu to make pending menu items public.' ) . '

      '; + } + + if ( $some_invalid_menu_items ) { + $result .= '

      ' . __( 'There are some invalid menu items. Please check or delete them.' ) . '

      '; + } + + $result .= ' '; + return $result; + } elseif ( is_wp_error( $menu ) ) { + return $menu; + } + +} + +/** + * Returns the columns for the nav menus page. + * + * @since 3.0.0 + * + * @return array Columns. + */ +function wp_nav_menu_manage_columns() { + return array( + '_title' => __( 'Show advanced menu properties' ), + 'cb' => '', + 'link-target' => __( 'Link Target' ), + 'title-attribute' => __( 'Title Attribute' ), + 'css-classes' => __( 'CSS Classes' ), + 'xfn' => __( 'Link Relationship (XFN)' ), + 'description' => __( 'Description' ), + ); +} + +/** + * Deletes orphaned draft menu items + * + * @access private + * @since 3.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ +function _wp_delete_orphaned_draft_menu_items() { + global $wpdb; + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); + + // Delete orphaned draft menu items. + $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) ); + + foreach ( (array) $menu_items_to_delete as $menu_item_id ) + wp_delete_post( $menu_item_id, true ); +} + +/** + * Saves nav menu items + * + * @since 3.6.0 + * + * @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu + * @param string $nav_menu_selected_title Title of the currently-selected menu + * @return array $messages The menu updated message + */ +function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { + $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); + $messages = array(); + $menu_items = array(); + // Index menu items by db ID + foreach ( $unsorted_menu_items as $_item ) + $menu_items[$_item->db_id] = $_item; + + $post_fields = array( + 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', + 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', + 'menu-item-title', 'menu-item-url', 'menu-item-description', + 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' + ); + + wp_defer_term_counting( true ); + // Loop through all the menu items' POST variables + if ( ! empty( $_POST['menu-item-db-id'] ) ) { + foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { + + // Menu item title can't be blank + if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) + continue; + + $args = array(); + foreach ( $post_fields as $field ) + $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; + + $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); + + if ( is_wp_error( $menu_item_db_id ) ) { + $messages[] = '

      ' . $menu_item_db_id->get_error_message() . '

      '; + } else { + unset( $menu_items[ $menu_item_db_id ] ); + } + } + } + + // Remove menu items from the menu that weren't in $_POST + if ( ! empty( $menu_items ) ) { + foreach ( array_keys( $menu_items ) as $menu_item_id ) { + if ( is_nav_menu_item( $menu_item_id ) ) { + wp_delete_post( $menu_item_id ); + } + } + } + + // Store 'auto-add' pages. + $auto_add = ! empty( $_POST['auto-add-pages'] ); + $nav_menu_option = (array) get_option( 'nav_menu_options' ); + if ( ! isset( $nav_menu_option['auto_add'] ) ) + $nav_menu_option['auto_add'] = array(); + if ( $auto_add ) { + if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) + $nav_menu_option['auto_add'][] = $nav_menu_selected_id; + } else { + if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) + unset( $nav_menu_option['auto_add'][$key] ); + } + // Remove nonexistent/deleted menus + $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); + update_option( 'nav_menu_options', $nav_menu_option ); + + wp_defer_term_counting( false ); + + /** This action is documented in wp-includes/nav-menu.php */ + do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); + + $messages[] = '

      ' . + /* translators: %s: nav menu title */ + sprintf( __( '%s has been updated.' ), + '' . $nav_menu_selected_title . '' + ) . '

      '; + + unset( $menu_items, $unsorted_menu_items ); + + return $messages; +} + +/** + * If a JSON blob of navigation menu data is in POST data, expand it and inject + * it into `$_POST` to avoid PHP `max_input_vars` limitations. See #14134. + * + * @ignore + * @since 4.5.3 + * @access private + */ +function _wp_expand_nav_menu_post_data() { + if ( ! isset( $_POST['nav-menu-data'] ) ) { + return; + } + + $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); + + if ( ! is_null( $data ) && $data ) { + foreach ( $data as $post_input_data ) { + // For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`), + // derive the array path keys via regex and set the value in $_POST. + preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches ); + + $array_bits = array( $matches[1] ); + + if ( isset( $matches[3] ) ) { + $array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) ); + } + + $new_post_data = array(); + + // Build the new array value from leaf to trunk. + for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) { + if ( $i == count( $array_bits ) - 1 ) { + $new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value ); + } else { + $new_post_data = array( $array_bits[ $i ] => $new_post_data ); + } + } + + $_POST = array_replace_recursive( $_POST, $new_post_data ); + } + } +} diff --git a/backend/wp-admin/includes/network.php b/backend/wp-admin/includes/network.php new file mode 100644 index 0000000..f9c5a79 --- /dev/null +++ b/backend/wp-admin/includes/network.php @@ -0,0 +1,606 @@ +prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) ); + if ( $wpdb->get_var( $sql ) ) { + return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" ); + } + return false; +} + +/** + * Allow subdomain installation + * + * @since 3.0.0 + * @return bool Whether subdomain installation is allowed + */ +function allow_subdomain_install() { + $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) ); + if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) + return false; + + return true; +} + +/** + * Allow subdirectory installation. + * + * @since 3.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return bool Whether subdirectory installation is allowed + */ +function allow_subdirectory_install() { + global $wpdb; + /** + * Filters whether to enable the subdirectory installation feature in Multisite. + * + * @since 3.0.0 + * + * @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false. + */ + if ( apply_filters( 'allow_subdirectory_install', false ) ) + return true; + + if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) + return true; + + $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" ); + if ( empty( $post ) ) + return true; + + return false; +} + +/** + * Get base domain of network. + * + * @since 3.0.0 + * @return string Base domain. + */ +function get_clean_basedomain() { + if ( $existing_domain = network_domain_check() ) + return $existing_domain; + $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) ); + if ( $slash = strpos( $domain, '/' ) ) + $domain = substr( $domain, 0, $slash ); + return $domain; +} + +/** + * Prints step 1 for Network installation process. + * + * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network + * should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo. + * + * @since 3.0.0 + * + * @global bool $is_apache + * + * @param WP_Error $errors + */ +function network_step1( $errors = false ) { + global $is_apache; + + if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { + echo '

      ' . __( 'ERROR:' ) . ' ' . sprintf( + /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */ + __( 'The constant %s cannot be defined when creating a network.' ), + 'DO_NOT_UPGRADE_GLOBAL_TABLES' + ) . '

      '; + echo ''; + include( ABSPATH . 'wp-admin/admin-footer.php' ); + die(); + } + + $active_plugins = get_option( 'active_plugins' ); + if ( ! empty( $active_plugins ) ) { + echo '

      ' . __( 'Warning:' ) . ' ' . sprintf( + /* translators: %s: Plugins screen URL */ + __( 'Please deactivate your plugins before enabling the Network feature.' ), + admin_url( 'plugins.php?plugin_status=active' ) + ) . '

      '; + echo '

      ' . __( 'Once the network is created, you may reactivate your plugins.' ) . '

      '; + echo ''; + include( ABSPATH . 'wp-admin/admin-footer.php' ); + die(); + } + + $hostname = get_clean_basedomain(); + $has_ports = strstr( $hostname, ':' ); + if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { + echo '

      ' . __( 'ERROR:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

      '; + echo '

      ' . sprintf( + /* translators: %s: port number */ + __( 'You cannot use port numbers such as %s.' ), + '' . $has_ports . '' + ) . '

      '; + echo '' . __( 'Return to Dashboard' ) . ''; + echo ''; + include( ABSPATH . 'wp-admin/admin-footer.php' ); + die(); + } + + echo '
      '; + + wp_nonce_field( 'install-network-1' ); + + $error_codes = array(); + if ( is_wp_error( $errors ) ) { + echo '

      ' . __( 'ERROR: The network could not be created.' ) . '

      '; + foreach ( $errors->get_error_messages() as $error ) + echo "

      $error

      "; + echo '
      '; + $error_codes = $errors->get_error_codes(); + } + + if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) { + $site_name = $_POST['sitename']; + } else { + /* translators: %s: Default network name */ + $site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) ); + } + + if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) { + $admin_email = $_POST['email']; + } else { + $admin_email = get_option( 'admin_email' ); + } + ?> +

      +

      +

      ' . __( 'Note:' ) . ' '; + /* translators: %s: mod_rewrite */ + printf( __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ), + 'mod_rewrite' + ); + echo '

      '; + } elseif ( $is_apache ) { + echo '

      ' . __( 'Warning:' ) . ' '; + /* translators: %s: mod_rewrite */ + printf( __( 'It looks like the Apache %s module is not installed.' ), + 'mod_rewrite' + ); + echo '

      '; + } + + if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache) + echo '

      '; + /* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */ + printf( __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ), + 'mod_rewrite', + 'https://httpd.apache.org/docs/mod/mod_rewrite.html', + 'https://www.google.com/search?q=apache+mod_rewrite' + ); + echo '

      '; + } + } + + if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?> +

      +

      +

      +

      + + + + + + + + + + +
      site1.%1$s and site2.%1$s', 'subdomain examples' ), + $hostname + ); ?>
      %1$s/site1 and %1$s/site2', 'subdirectory examples' ), + $hostname + ); ?>
      + +

      ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

      '; + + $is_www = ( 0 === strpos( $hostname, 'www.' ) ); + if ( $is_www ) : + ?> +

      +

      ' . substr( $hostname, 4 ) . '', + '' . $hostname . '', + 'www' + ); ?>

      + + + + + +
      + ' . $hostname . '' + ); ?> +
      + + +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      localhost', + 'localhost.localdomain' + ); + // Uh oh: + if ( !allow_subdirectory_install() ) + echo ' ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; + ?>
      ' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; + ?>
      ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . ''; + ?>
      + ' . $hostname . '' + ); ?> +
      + +

      + +

      +
      + +

      + +

      +
      + +
      + ' . $errors->get_error_message() . ''; + + if ( $_POST ) { + if ( allow_subdomain_install() ) + $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true; + else + $subdomain_install = false; + } else { + if ( is_multisite() ) { + $subdomain_install = is_subdomain_install(); +?> +

      +get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); +?> +

      +

      + +

      +

      +

      ' . __( 'Caution:' ) . ' '; + printf( + /* translators: 1: wp-config.php 2: .htaccess */ + __( 'We recommend you back up your existing %1$s and %2$s files.' ), + 'wp-config.php', + '.htaccess' + ); + } elseif ( file_exists( $home_path . 'web.config' ) ) { + echo '' . __( 'Caution:' ) . ' '; + printf( + /* translators: 1: wp-config.php 2: web.config */ + __( 'We recommend you back up your existing %1$s and %2$s files.' ), + 'wp-config.php', + 'web.config' + ); + } else { + echo '' . __( 'Caution:' ) . ' '; + printf( + /* translators: 1: wp-config.php */ + __( 'We recommend you back up your existing %s file.' ), + 'wp-config.php' + ); + } + ?>

      + +
        +
      1. above the line reading %3$s:' ), + 'wp-config.php', + '' . $location_of_wp_config . '', + /* + * translators: This string should only be translated if wp-config-sample.php is localized. + * You can check the localized release package or + * https://i18n.svn.wordpress.org//branches//dist/wp-config-sample.php + */ + '/* ' . __( 'That’s all, stop editing! Happy blogging.' ) . ' */' + ); ?>

        + + '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' ); + foreach ( $keys_salts as $c => $v ) { + if ( defined( $c ) ) + unset( $keys_salts[ $c ] ); + } + + if ( ! empty( $keys_salts ) ) { + $keys_salts_str = ''; + $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); + if ( is_wp_error( $from_api ) ) { + foreach ( $keys_salts as $c => $v ) { + $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );"; + } + } else { + $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) ); + foreach ( $keys_salts as $c => $v ) { + $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );"; + } + } + $num_keys_salts = count( $keys_salts ); +?> +

        + wp-config.php' + ); + } else { + printf( + /* translators: 1: wp-config.php */ + __( 'These unique authentication keys are also missing from your %s file.' ), + 'wp-config.php' + ); + } + ?> + +

        + + +
      2. + + + + + + + + + '; + if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { + $web_config_file .= ' + + + + '; + } + $web_config_file .= ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + +'; + + echo '
      3. '; + printf( + /* translators: 1: a filename like .htaccess. 2: a file path. */ + __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), + 'web.config', + '' . $home_path . '' + ); + echo '

        '; + if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) + echo '

        ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

        '; + ?> +
      4. +
      + +

      '; + printf( + /* translators: 1: a filename like .htaccess. 2: a file path. */ + __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), + '.htaccess', + '' . $home_path . '' + ); + echo '

      '; + if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) + echo '

      ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

      '; + ?> + + + + +

      + + + + + + +'; + echo '

      ' . __( 'The character encoding of your site (UTF-8 is recommended)' ) . '

      '; +} diff --git a/backend/wp-admin/includes/plugin-install.php b/backend/wp-admin/includes/plugin-install.php new file mode 100644 index 0000000..eea74f1 --- /dev/null +++ b/backend/wp-admin/includes/plugin-install.php @@ -0,0 +1,726 @@ +per_page ) ) { + $args->per_page = 24; + } + + if ( ! isset( $args->locale ) ) { + $args->locale = get_user_locale(); + } + + /** + * Filters the WordPress.org Plugin Installation API arguments. + * + * Important: An object MUST be returned to this filter. + * + * @since 2.7.0 + * + * @param object $args Plugin API arguments. + * @param string $action The type of information being requested from the Plugin Installation API. + */ + $args = apply_filters( 'plugins_api_args', $args, $action ); + + /** + * Filters the response for the current WordPress.org Plugin Installation API request. + * + * Passing a non-false value will effectively short-circuit the WordPress.org API request. + * + * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed. + * If `$action` is 'hot_tags' or 'hot_categories', an array should be passed. + * + * @since 2.7.0 + * + * @param false|object|array $result The result object or array. Default false. + * @param string $action The type of information being requested from the Plugin Installation API. + * @param object $args Plugin API arguments. + */ + $res = apply_filters( 'plugins_api', false, $action, $args ); + + if ( false === $res ) { + // include an unmodified $wp_version + include( ABSPATH . WPINC . '/version.php' ); + + $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) + $url = set_url_scheme( $url, 'https' ); + + $http_args = array( + 'timeout' => 15, + 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), + 'body' => array( + 'action' => $action, + 'request' => serialize( $args ) + ) + ); + $request = wp_remote_post( $url, $http_args ); + + if ( $ssl && is_wp_error( $request ) ) { + trigger_error( + sprintf( + /* translators: %s: support forums URL */ + __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), + __( 'https://wordpress.org/support/' ) + ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), + headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE + ); + $request = wp_remote_post( $http_url, $http_args ); + } + + if ( is_wp_error($request) ) { + $res = new WP_Error( 'plugins_api_failed', + sprintf( + /* translators: %s: support forums URL */ + __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), + __( 'https://wordpress.org/support/' ) + ), + $request->get_error_message() + ); + } else { + $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); + if ( ! is_object( $res ) && ! is_array( $res ) ) { + $res = new WP_Error( 'plugins_api_failed', + sprintf( + /* translators: %s: support forums URL */ + __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), + __( 'https://wordpress.org/support/' ) + ), + wp_remote_retrieve_body( $request ) + ); + } + } + } elseif ( !is_wp_error($res) ) { + $res->external = true; + } + + /** + * Filters the Plugin Installation API response results. + * + * @since 2.7.0 + * + * @param object|WP_Error $res Response object or WP_Error. + * @param string $action The type of information being requested from the Plugin Installation API. + * @param object $args Plugin API arguments. + */ + return apply_filters( 'plugins_api_result', $res, $action, $args ); +} + +/** + * Retrieve popular WordPress plugin tags. + * + * @since 2.7.0 + * + * @param array $args + * @return array + */ +function install_popular_tags( $args = array() ) { + $key = md5(serialize($args)); + if ( false !== ($tags = get_site_transient('poptags_' . $key) ) ) + return $tags; + + $tags = plugins_api('hot_tags', $args); + + if ( is_wp_error($tags) ) + return $tags; + + set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); + + return $tags; +} + +/** + * @since 2.7.0 + */ +function install_dashboard() { + ?> +

      WordPress Plugin Directory or upload a plugin in .zip format by clicking the button at the top of this page.' ), __( 'https://wordpress.org/plugins/' ) ); ?>

      + + + + '; +} + +/** + * Displays a search form for searching plugins. + * + * @since 2.7.0 + * @since 4.6.0 The `$type_selector` parameter was deprecated. + * + * @param bool $deprecated Not used. + */ +function install_search_form( $deprecated = true ) { + $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; + $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; + ?>
      + + + + + 'search-submit' ) ); ?> +
      +
      +

      +
      + + + + +
      +
      + +

      +
      + +

      + + + + +

      +
      + ' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '

      '; + break; + case 'install_plugins_beta' : + printf( + '

      ' . __( 'You are using a development version of WordPress. These feature plugins are also under development. Learn more.' ) . '

      ', + 'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/' + ); + break; + } + + ?> +
      + display(); ?> +
      + response ) ) { + foreach ( (array)$update_plugins->response as $file => $plugin ) { + if ( $plugin->slug === $api->slug ) { + $status = 'update_available'; + $update_file = $file; + $version = $plugin->new_version; + if ( current_user_can('update_plugins') ) + $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); + break; + } + } + } + + if ( 'install' == $status ) { + if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { + $installed_plugin = get_plugins('/' . $api->slug); + if ( empty($installed_plugin) ) { + if ( current_user_can('install_plugins') ) + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); + } else { + $key = array_keys( $installed_plugin ); + $key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers + $update_file = $api->slug . '/' . $key; + if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){ + $status = 'latest_installed'; + } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) { + $status = 'newer_installed'; + $version = $installed_plugin[ $key ]['Version']; + } else { + //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh + if ( ! $loop ) { + delete_site_transient('update_plugins'); + wp_update_plugins(); + return install_plugin_install_status($api, true); + } + } + } + } else { + // "install" & no directory with that slug + if ( current_user_can('install_plugins') ) + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); + } + } + if ( isset($_GET['from']) ) + $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); + + $file = $update_file; + return compact( 'status', 'url', 'version', 'file' ); +} + +/** + * Display plugin information in dialog box form. + * + * @since 2.7.0 + * + * @global string $tab + */ +function install_plugin_information() { + global $tab; + + if ( empty( $_REQUEST['plugin'] ) ) { + return; + } + + $api = plugins_api( 'plugin_information', array( + 'slug' => wp_unslash( $_REQUEST['plugin'] ), + 'is_ssl' => is_ssl(), + 'fields' => array( + 'banners' => true, + 'reviews' => true, + 'downloaded' => false, + 'active_installs' => true + ) + ) ); + + if ( is_wp_error( $api ) ) { + wp_die( $api ); + } + + $plugins_allowedtags = array( + 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ), + 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), + 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), + 'div' => array( 'class' => array() ), 'span' => array( 'class' => array() ), + 'p' => array(), 'br' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), + 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), + 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ), + 'blockquote' => array( 'cite' => true ), + ); + + $plugins_section_titles = array( + 'description' => _x( 'Description', 'Plugin installer section title' ), + 'installation' => _x( 'Installation', 'Plugin installer section title' ), + 'faq' => _x( 'FAQ', 'Plugin installer section title' ), + 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), + 'changelog' => _x( 'Changelog', 'Plugin installer section title' ), + 'reviews' => _x( 'Reviews', 'Plugin installer section title' ), + 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ) + ); + + // Sanitize HTML + foreach ( (array) $api->sections as $section_name => $content ) { + $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags ); + } + + foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { + if ( isset( $api->$key ) ) { + $api->$key = wp_kses( $api->$key, $plugins_allowedtags ); + } + } + + $_tab = esc_attr( $tab ); + + $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. + if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { + $section_titles = array_keys( (array) $api->sections ); + $section = reset( $section_titles ); + } + + iframe_header( __( 'Plugin Installation' ) ); + + $_with_banner = ''; + + if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { + $_with_banner = 'with-banner'; + $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; + $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; + ?> + + '; + echo "

      {$api->name}

      "; + echo "
      \n"; + + foreach ( (array) $api->sections as $section_name => $content ) { + if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { + continue; + } + + if ( isset( $plugins_section_titles[ $section_name ] ) ) { + $title = $plugins_section_titles[ $section_name ]; + } else { + $title = ucwords( str_replace( '_', ' ', $section_name ) ); + } + + $class = ( $section_name === $section ) ? ' class="current"' : ''; + $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); + $href = esc_url( $href ); + $san_section = esc_attr( $section_name ); + echo "\t$title\n"; + } + + echo "
      \n"; + + ?> +
      +
      +
        + version ) ) { ?> +
      • version; ?>
      • + author ) ) { ?> +
      • author, '_blank' ); ?>
      • + last_updated ) ) { ?> +
      • + last_updated ) ) ); + ?> +
      • + requires ) ) { ?> +
      • + + requires ); + ?> +
      • + tested ) ) { ?> +
      • tested; ?>
      • + requires_php ) ) { ?> +
      • + + requires_php ); + ?> +
      • + active_installs ) ) { ?> +
      • active_installs >= 1000000 ) { + _ex( '1+ Million', 'Active plugin installations' ); + } elseif ( 0 == $api->active_installs ) { + _ex( 'Less Than 10', 'Active plugin installations' ); + } else { + echo number_format_i18n( $api->active_installs ) . '+'; + } + ?>
      • + slug ) && empty( $api->external ) ) { ?> +
      • + homepage ) ) { ?> +
      • + donate_link ) && empty( $api->contributors ) ) { ?> +
      • + +
      + rating ) ) { ?> +

      + $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?> + + ratings ) && array_sum( (array) $api->ratings ) > 0 ) { ?> +

      +

      + ratings as $key => $ratecount ) { + // Avoid div-by-zero. + $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; + /* translators: 1: number of stars (used to determine singular/plural), 2: number of reviews */ + $aria_label = esc_attr( sprintf( _n( 'Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key ), + $key, + number_format_i18n( $ratecount ) + ) ); + ?> +
      + + + + + +
      + contributors ) ) { ?> +

      +
        + contributors as $contrib_username => $contrib_profile ) { + if ( empty( $contrib_username ) && empty( $contrib_profile ) ) { + continue; + } + if ( empty( $contrib_username ) ) { + $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile ); + } + $contrib_username = sanitize_user( $contrib_username ); + if ( empty( $contrib_profile ) ) { + echo "
      • {$contrib_username}
      • "; + } else { + echo "
      • {$contrib_username}
      • "; + } + } + ?> +
      + donate_link ) ) { ?> + + + +
      +
      + tested ) && version_compare( substr( $wp_version, 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { + echo '

      ' . __( 'Warning: This plugin has not been tested with your current version of WordPress.' ) . '

      '; + } elseif ( ! empty( $api->requires ) && version_compare( substr( $wp_version, 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { + echo '

      ' . __( 'Warning: This plugin has not been marked as compatible with your version of WordPress.' ) . '

      '; + } + + foreach ( (array) $api->sections as $section_name => $content ) { + $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); + $content = links_add_target( $content, '_blank' ); + + $san_section = esc_attr( $section_name ); + + $display = ( $section_name === $section ) ? 'block' : 'none'; + + echo "\t
      \n"; + echo $content; + echo "\t
      \n"; + } + echo "
      \n"; + echo "
      \n"; + echo "\n"; // #plugin-information-scrollable + echo "\n"; + + iframe_footer(); + exit; +} diff --git a/backend/wp-admin/includes/plugin.php b/backend/wp-admin/includes/plugin.php new file mode 100644 index 0000000..d794a8a --- /dev/null +++ b/backend/wp-admin/includes/plugin.php @@ -0,0 +1,1925 @@ + 'Plugin Name', + 'PluginURI' => 'Plugin URI', + 'Version' => 'Version', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + 'Network' => 'Network', + // Site Wide Only is deprecated in favor of Network. + '_sitewide' => 'Site Wide Only', + ); + + $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); + + // Site Wide Only is the old header for Network + if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { + /* translators: 1: Site Wide Only: true, 2: Network: true */ + _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), 'Site Wide Only: true', 'Network: true' ) ); + $plugin_data['Network'] = $plugin_data['_sitewide']; + } + $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); + unset( $plugin_data['_sitewide'] ); + + // If no text domain is defined fall back to the plugin slug. + if ( ! $plugin_data['TextDomain'] ) { + $plugin_slug = dirname( plugin_basename( $plugin_file ) ); + if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) { + $plugin_data['TextDomain'] = $plugin_slug; + } + } + + if ( $markup || $translate ) { + $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); + } else { + $plugin_data['Title'] = $plugin_data['Name']; + $plugin_data['AuthorName'] = $plugin_data['Author']; + } + + return $plugin_data; +} + +/** + * Sanitizes plugin data, optionally adds markup, optionally translates. + * + * @since 2.7.0 + * @access private + * @see get_plugin_data() + */ +function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { + + // Sanitize the plugin filename to a WP_PLUGIN_DIR relative path + $plugin_file = plugin_basename( $plugin_file ); + + // Translate fields + if ( $translate ) { + if ( $textdomain = $plugin_data['TextDomain'] ) { + if ( ! is_textdomain_loaded( $textdomain ) ) { + if ( $plugin_data['DomainPath'] ) { + load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); + } else { + load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); + } + } + } elseif ( 'hello.php' == basename( $plugin_file ) ) { + $textdomain = 'default'; + } + if ( $textdomain ) { + foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) + $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); + } + } + + // Sanitize fields + $allowed_tags = $allowed_tags_in_links = array( + 'abbr' => array( 'title' => true ), + 'acronym' => array( 'title' => true ), + 'code' => true, + 'em' => true, + 'strong' => true, + ); + $allowed_tags['a'] = array( 'href' => true, 'title' => true ); + + // Name is marked up inside tags. Don't allow these. + // Author is too, but some plugins have used here (omitting Author URI). + $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); + $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); + + $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); + $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); + + $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); + $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); + + $plugin_data['Title'] = $plugin_data['Name']; + $plugin_data['AuthorName'] = $plugin_data['Author']; + + // Apply markup + if ( $markup ) { + if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) + $plugin_data['Title'] = '' . $plugin_data['Name'] . ''; + + if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) + $plugin_data['Author'] = '' . $plugin_data['Author'] . ''; + + $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); + + if ( $plugin_data['Author'] ) + $plugin_data['Description'] .= ' ' . sprintf( __('By %s.'), $plugin_data['Author'] ) . ''; + } + + return $plugin_data; +} + +/** + * Get a list of a plugin's files. + * + * @since 2.8.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return array List of files relative to the plugin root. + */ +function get_plugin_files( $plugin ) { + $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; + $dir = dirname( $plugin_file ); + + $plugin_files = array( plugin_basename( $plugin_file ) ); + + if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) { + + /** + * Filters the array of excluded directories and files while scanning the folder. + * + * @since 4.9.0 + * + * @param array $exclusions Array of excluded directories and files. + */ + $exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); + + $list_files = list_files( $dir, 100, $exclusions ); + $list_files = array_map( 'plugin_basename', $list_files ); + + $plugin_files = array_merge( $plugin_files, $list_files ); + $plugin_files = array_values( array_unique( $plugin_files ) ); + } + + return $plugin_files; +} + +/** + * Check the plugins directory and retrieve all plugin files with plugin data. + * + * WordPress only supports plugin files in the base plugins directory + * (wp-content/plugins) and in one directory above the plugins directory + * (wp-content/plugins/my-plugin). The file it looks for has the plugin data + * and must be found in those two locations. It is recommended to keep your + * plugin files in their own directories. + * + * The file with the plugin data is the file that will be included and therefore + * needs to have the main execution for the plugin. This does not mean + * everything must be contained in the file and it is recommended that the file + * be split for maintainability. Keep everything in one file for extreme + * optimization purposes. + * + * @since 1.5.0 + * + * @param string $plugin_folder Optional. Relative path to single plugin folder. + * @return array Key is the plugin file path and the value is an array of the plugin data. + */ +function get_plugins($plugin_folder = '') { + + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) + $cache_plugins = array(); + + if ( isset($cache_plugins[ $plugin_folder ]) ) + return $cache_plugins[ $plugin_folder ]; + + $wp_plugins = array (); + $plugin_root = WP_PLUGIN_DIR; + if ( !empty($plugin_folder) ) + $plugin_root .= $plugin_folder; + + // Files in wp-content/plugins directory + $plugins_dir = @ opendir( $plugin_root); + $plugin_files = array(); + if ( $plugins_dir ) { + while (($file = readdir( $plugins_dir ) ) !== false ) { + if ( substr($file, 0, 1) == '.' ) + continue; + if ( is_dir( $plugin_root.'/'.$file ) ) { + $plugins_subdir = @ opendir( $plugin_root.'/'.$file ); + if ( $plugins_subdir ) { + while (($subfile = readdir( $plugins_subdir ) ) !== false ) { + if ( substr($subfile, 0, 1) == '.' ) + continue; + if ( substr($subfile, -4) == '.php' ) + $plugin_files[] = "$file/$subfile"; + } + closedir( $plugins_subdir ); + } + } else { + if ( substr($file, -4) == '.php' ) + $plugin_files[] = $file; + } + } + closedir( $plugins_dir ); + } + + if ( empty($plugin_files) ) + return $wp_plugins; + + foreach ( $plugin_files as $plugin_file ) { + if ( !is_readable( "$plugin_root/$plugin_file" ) ) + continue; + + $plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + + if ( empty ( $plugin_data['Name'] ) ) + continue; + + $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; + } + + uasort( $wp_plugins, '_sort_uname_callback' ); + + $cache_plugins[ $plugin_folder ] = $wp_plugins; + wp_cache_set('plugins', $cache_plugins, 'plugins'); + + return $wp_plugins; +} + +/** + * Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data. + * + * WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins). + * + * @since 3.0.0 + * @return array Key is the mu-plugin file path and the value is an array of the mu-plugin data. + */ +function get_mu_plugins() { + $wp_plugins = array(); + // Files in wp-content/mu-plugins directory + $plugin_files = array(); + + if ( ! is_dir( WPMU_PLUGIN_DIR ) ) + return $wp_plugins; + if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { + while ( ( $file = readdir( $plugins_dir ) ) !== false ) { + if ( substr( $file, -4 ) == '.php' ) + $plugin_files[] = $file; + } + } else { + return $wp_plugins; + } + + @closedir( $plugins_dir ); + + if ( empty($plugin_files) ) + return $wp_plugins; + + foreach ( $plugin_files as $plugin_file ) { + if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) + continue; + + $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + + if ( empty ( $plugin_data['Name'] ) ) + $plugin_data['Name'] = $plugin_file; + + $wp_plugins[ $plugin_file ] = $plugin_data; + } + + if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden + unset( $wp_plugins['index.php'] ); + + uasort( $wp_plugins, '_sort_uname_callback' ); + + return $wp_plugins; +} + +/** + * Callback to sort array by a 'Name' key. + * + * @since 3.1.0 + * @access private + */ +function _sort_uname_callback( $a, $b ) { + return strnatcasecmp( $a['Name'], $b['Name'] ); +} + +/** + * Check the wp-content directory and retrieve all drop-ins with any plugin data. + * + * @since 3.0.0 + * @return array Key is the file path and the value is an array of the plugin data. + */ +function get_dropins() { + $dropins = array(); + $plugin_files = array(); + + $_dropins = _get_dropins(); + + // These exist in the wp-content directory + if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) { + while ( ( $file = readdir( $plugins_dir ) ) !== false ) { + if ( isset( $_dropins[ $file ] ) ) + $plugin_files[] = $file; + } + } else { + return $dropins; + } + + @closedir( $plugins_dir ); + + if ( empty($plugin_files) ) + return $dropins; + + foreach ( $plugin_files as $plugin_file ) { + if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) + continue; + $plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. + if ( empty( $plugin_data['Name'] ) ) + $plugin_data['Name'] = $plugin_file; + $dropins[ $plugin_file ] = $plugin_data; + } + + uksort( $dropins, 'strnatcasecmp' ); + + return $dropins; +} + +/** + * Returns drop-ins that WordPress uses. + * + * Includes Multisite drop-ins only when is_multisite() + * + * @since 3.0.0 + * @return array Key is file name. The value is an array, with the first value the + * purpose of the drop-in and the second value the name of the constant that must be + * true for the drop-in to be used, or true if no constant is required. + */ +function _get_dropins() { + $dropins = array( + 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE + 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load + 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error + 'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation + 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance + 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load + ); + + if ( is_multisite() ) { + $dropins['sunrise.php' ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE + $dropins['blog-deleted.php' ] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog + $dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog + $dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog + } + + return $dropins; +} + +/** + * Check whether a plugin is active. + * + * Only plugins installed in the plugins/ folder can be active. + * + * Plugins in the mu-plugins/ folder can't be "activated," so this function will + * return false for those plugins. + * + * @since 2.5.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return bool True, if in the active plugins list. False, not in the list. + */ +function is_plugin_active( $plugin ) { + return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin ); +} + +/** + * Check whether the plugin is inactive. + * + * Reverse of is_plugin_active(). Used as a callback. + * + * @since 3.1.0 + * @see is_plugin_active() + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return bool True if inactive. False if active. + */ +function is_plugin_inactive( $plugin ) { + return ! is_plugin_active( $plugin ); +} + +/** + * Check whether the plugin is active for the entire network. + * + * Only plugins installed in the plugins/ folder can be active. + * + * Plugins in the mu-plugins/ folder can't be "activated," so this function will + * return false for those plugins. + * + * @since 3.0.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return bool True, if active for the network, otherwise false. + */ +function is_plugin_active_for_network( $plugin ) { + if ( !is_multisite() ) + return false; + + $plugins = get_site_option( 'active_sitewide_plugins'); + if ( isset($plugins[$plugin]) ) + return true; + + return false; +} + +/** + * Checks for "Network: true" in the plugin header to see if this should + * be activated only as a network wide plugin. The plugin would also work + * when Multisite is not enabled. + * + * Checks for "Site Wide Only: true" for backward compatibility. + * + * @since 3.0.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return bool True if plugin is network only, false otherwise. + */ +function is_network_only_plugin( $plugin ) { + $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); + if ( $plugin_data ) + return $plugin_data['Network']; + return false; +} + +/** + * Attempts activation of plugin in a "sandbox" and redirects on success. + * + * A plugin that is already activated will not attempt to be activated again. + * + * The way it works is by setting the redirection to the error before trying to + * include the plugin file. If the plugin fails, then the redirection will not + * be overwritten with the success message. Also, the options will not be + * updated and the activation hook will not be called on plugin error. + * + * It should be noted that in no way the below code will actually prevent errors + * within the file. The code should not be used elsewhere to replicate the + * "sandbox", which uses redirection to work. + * {@source 13 1} + * + * If any errors are found or text is outputted, then it will be captured to + * ensure that the success redirection will update the error redirection. + * + * @since 2.5.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param string $redirect Optional. URL to redirect to. + * @param bool $network_wide Optional. Whether to enable the plugin for all sites in the network + * or just the current site. Multisite only. Default false. + * @param bool $silent Optional. Whether to prevent calling activation hooks. Default false. + * @return WP_Error|null WP_Error on invalid file or null on success. + */ +function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { + $plugin = plugin_basename( trim( $plugin ) ); + + if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { + $network_wide = true; + $current = get_site_option( 'active_sitewide_plugins', array() ); + $_GET['networkwide'] = 1; // Back compat for plugins looking for this value. + } else { + $current = get_option( 'active_plugins', array() ); + } + + $valid = validate_plugin($plugin); + if ( is_wp_error($valid) ) + return $valid; + + if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { + if ( !empty($redirect) ) + wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error + ob_start(); + wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); + $_wp_plugin_file = $plugin; + include_once( WP_PLUGIN_DIR . '/' . $plugin ); + $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. + + if ( ! $silent ) { + /** + * Fires before a plugin is activated. + * + * If a plugin is silently activated (such as during an update), + * this hook does not fire. + * + * @since 2.9.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param bool $network_wide Whether to enable the plugin for all sites in the network + * or just the current site. Multisite only. Default is false. + */ + do_action( 'activate_plugin', $plugin, $network_wide ); + + /** + * Fires as a specific plugin is being activated. + * + * This hook is the "activation" hook used internally by register_activation_hook(). + * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename. + * + * If a plugin is silently activated (such as during an update), this hook does not fire. + * + * @since 2.0.0 + * + * @param bool $network_wide Whether to enable the plugin for all sites in the network + * or just the current site. Multisite only. Default is false. + */ + do_action( "activate_{$plugin}", $network_wide ); + } + + if ( $network_wide ) { + $current = get_site_option( 'active_sitewide_plugins', array() ); + $current[$plugin] = time(); + update_site_option( 'active_sitewide_plugins', $current ); + } else { + $current = get_option( 'active_plugins', array() ); + $current[] = $plugin; + sort($current); + update_option('active_plugins', $current); + } + + if ( ! $silent ) { + /** + * Fires after a plugin has been activated. + * + * If a plugin is silently activated (such as during an update), + * this hook does not fire. + * + * @since 2.9.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param bool $network_wide Whether to enable the plugin for all sites in the network + * or just the current site. Multisite only. Default is false. + */ + do_action( 'activated_plugin', $plugin, $network_wide ); + } + + if ( ob_get_length() > 0 ) { + $output = ob_get_clean(); + return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); + } + ob_end_clean(); + } + + return null; +} + +/** + * Deactivate a single plugin or multiple plugins. + * + * The deactivation hook is disabled by the plugin upgrader by using the $silent + * parameter. + * + * @since 2.5.0 + * + * @param string|array $plugins Single plugin or list of plugins to deactivate. + * @param bool $silent Prevent calling deactivation hooks. Default is false. + * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network. + * A value of null (the default) will deactivate plugins for both the site and the network. + */ +function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { + if ( is_multisite() ) + $network_current = get_site_option( 'active_sitewide_plugins', array() ); + $current = get_option( 'active_plugins', array() ); + $do_blog = $do_network = false; + + foreach ( (array) $plugins as $plugin ) { + $plugin = plugin_basename( trim( $plugin ) ); + if ( ! is_plugin_active($plugin) ) + continue; + + $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); + + if ( ! $silent ) { + /** + * Fires before a plugin is deactivated. + * + * If a plugin is silently deactivated (such as during an update), + * this hook does not fire. + * + * @since 2.9.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network + * or just the current site. Multisite only. Default is false. + */ + do_action( 'deactivate_plugin', $plugin, $network_deactivating ); + } + + if ( false !== $network_wide ) { + if ( is_plugin_active_for_network( $plugin ) ) { + $do_network = true; + unset( $network_current[ $plugin ] ); + } elseif ( $network_wide ) { + continue; + } + } + + if ( true !== $network_wide ) { + $key = array_search( $plugin, $current ); + if ( false !== $key ) { + $do_blog = true; + unset( $current[ $key ] ); + } + } + + if ( ! $silent ) { + /** + * Fires as a specific plugin is being deactivated. + * + * This hook is the "deactivation" hook used internally by register_deactivation_hook(). + * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename. + * + * If a plugin is silently deactivated (such as during an update), this hook does not fire. + * + * @since 2.0.0 + * + * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network + * or just the current site. Multisite only. Default is false. + */ + do_action( "deactivate_{$plugin}", $network_deactivating ); + + /** + * Fires after a plugin is deactivated. + * + * If a plugin is silently deactivated (such as during an update), + * this hook does not fire. + * + * @since 2.9.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network. + * or just the current site. Multisite only. Default false. + */ + do_action( 'deactivated_plugin', $plugin, $network_deactivating ); + } + } + + if ( $do_blog ) + update_option('active_plugins', $current); + if ( $do_network ) + update_site_option( 'active_sitewide_plugins', $network_current ); +} + +/** + * Activate multiple plugins. + * + * When WP_Error is returned, it does not mean that one of the plugins had + * errors. It means that one or more of the plugins file path was invalid. + * + * The execution will be halted as soon as one of the plugins has an error. + * + * @since 2.6.0 + * + * @param string|array $plugins Single plugin or list of plugins to activate. + * @param string $redirect Redirect to page after successful activation. + * @param bool $network_wide Whether to enable the plugin for all sites in the network. + * @param bool $silent Prevent calling activation hooks. Default is false. + * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. + */ +function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) { + if ( !is_array($plugins) ) + $plugins = array($plugins); + + $errors = array(); + foreach ( $plugins as $plugin ) { + if ( !empty($redirect) ) + $redirect = add_query_arg('plugin', $plugin, $redirect); + $result = activate_plugin($plugin, $redirect, $network_wide, $silent); + if ( is_wp_error($result) ) + $errors[$plugin] = $result; + } + + if ( !empty($errors) ) + return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors); + + return true; +} + +/** + * Remove directory and files of a plugin for a list of plugins. + * + * @since 2.6.0 + * + * @global WP_Filesystem_Base $wp_filesystem + * + * @param array $plugins List of plugins to delete. + * @param string $deprecated Deprecated. + * @return bool|null|WP_Error True on success, false is $plugins is empty, WP_Error on failure. + * Null if filesystem credentials are required to proceed. + */ +function delete_plugins( $plugins, $deprecated = '' ) { + global $wp_filesystem; + + if ( empty($plugins) ) + return false; + + $checked = array(); + foreach ( $plugins as $plugin ) + $checked[] = 'checked[]=' . $plugin; + + $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins'); + + ob_start(); + $credentials = request_filesystem_credentials( $url ); + $data = ob_get_clean(); + + if ( false === $credentials ) { + if ( ! empty($data) ){ + include_once( ABSPATH . 'wp-admin/admin-header.php'); + echo $data; + include( ABSPATH . 'wp-admin/admin-footer.php'); + exit; + } + return; + } + + if ( ! WP_Filesystem( $credentials ) ) { + ob_start(); + request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again. + $data = ob_get_clean(); + + if ( ! empty($data) ){ + include_once( ABSPATH . 'wp-admin/admin-header.php'); + echo $data; + include( ABSPATH . 'wp-admin/admin-footer.php'); + exit; + } + return; + } + + if ( ! is_object($wp_filesystem) ) + return new WP_Error('fs_unavailable', __('Could not access filesystem.')); + + if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) + return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors); + + // Get the base plugin folder. + $plugins_dir = $wp_filesystem->wp_plugins_dir(); + if ( empty( $plugins_dir ) ) { + return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) ); + } + + $plugins_dir = trailingslashit( $plugins_dir ); + + $plugin_translations = wp_get_installed_translations( 'plugins' ); + + $errors = array(); + + foreach ( $plugins as $plugin_file ) { + // Run Uninstall hook. + if ( is_uninstallable_plugin( $plugin_file ) ) { + uninstall_plugin($plugin_file); + } + + /** + * Fires immediately before a plugin deletion attempt. + * + * @since 4.4.0 + * + * @param string $plugin_file Plugin file name. + */ + do_action( 'delete_plugin', $plugin_file ); + + $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) ); + + // If plugin is in its own directory, recursively delete the directory. + if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder + $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); + } else { + $deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file ); + } + + /** + * Fires immediately after a plugin deletion attempt. + * + * @since 4.4.0 + * + * @param string $plugin_file Plugin file name. + * @param bool $deleted Whether the plugin deletion was successful. + */ + do_action( 'deleted_plugin', $plugin_file, $deleted ); + + if ( ! $deleted ) { + $errors[] = $plugin_file; + continue; + } + + // Remove language files, silently. + $plugin_slug = dirname( $plugin_file ); + if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) { + $translations = $plugin_translations[ $plugin_slug ]; + + foreach ( $translations as $translation => $data ) { + $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' ); + $wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' ); + } + } + } + + // Remove deleted plugins from the plugin updates list. + if ( $current = get_site_transient('update_plugins') ) { + // Don't remove the plugins that weren't deleted. + $deleted = array_diff( $plugins, $errors ); + + foreach ( $deleted as $plugin_file ) { + unset( $current->response[ $plugin_file ] ); + } + + set_site_transient( 'update_plugins', $current ); + } + + if ( ! empty( $errors ) ) { + if ( 1 === count( $errors ) ) { + /* translators: %s: plugin filename */ + $message = __( 'Could not fully remove the plugin %s.' ); + } else { + /* translators: %s: comma-separated list of plugin filenames */ + $message = __( 'Could not fully remove the plugins %s.' ); + } + + return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); + } + + return true; +} + +/** + * Validate active plugins + * + * Validate all active plugins, deactivates invalid and + * returns an array of deactivated ones. + * + * @since 2.5.0 + * @return array invalid plugins, plugin as key, error as value + */ +function validate_active_plugins() { + $plugins = get_option( 'active_plugins', array() ); + // Validate vartype: array. + if ( ! is_array( $plugins ) ) { + update_option( 'active_plugins', array() ); + $plugins = array(); + } + + if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { + $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); + $plugins = array_merge( $plugins, array_keys( $network_plugins ) ); + } + + if ( empty( $plugins ) ) + return array(); + + $invalid = array(); + + // Invalid plugins get deactivated. + foreach ( $plugins as $plugin ) { + $result = validate_plugin( $plugin ); + if ( is_wp_error( $result ) ) { + $invalid[$plugin] = $result; + deactivate_plugins( $plugin, true ); + } + } + return $invalid; +} + +/** + * Validate the plugin path. + * + * Checks that the main plugin file exists and is a valid plugin. See validate_file(). + * + * @since 2.5.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return WP_Error|int 0 on success, WP_Error on failure. + */ +function validate_plugin($plugin) { + if ( validate_file($plugin) ) + return new WP_Error('plugin_invalid', __('Invalid plugin path.')); + if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) ) + return new WP_Error('plugin_not_found', __('Plugin file does not exist.')); + + $installed_plugins = get_plugins(); + if ( ! isset($installed_plugins[$plugin]) ) + return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.')); + return 0; +} + +/** + * Whether the plugin can be uninstalled. + * + * @since 2.7.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return bool Whether plugin can be uninstalled. + */ +function is_uninstallable_plugin($plugin) { + $file = plugin_basename($plugin); + + $uninstallable_plugins = (array) get_option('uninstall_plugins'); + if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) + return true; + + return false; +} + +/** + * Uninstall a single plugin. + * + * Calls the uninstall hook, if it is available. + * + * @since 2.7.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @return true True if a plugin's uninstall.php file has been found and included. + */ +function uninstall_plugin($plugin) { + $file = plugin_basename($plugin); + + $uninstallable_plugins = (array) get_option('uninstall_plugins'); + + /** + * Fires in uninstall_plugin() immediately before the plugin is uninstalled. + * + * @since 4.5.0 + * + * @param string $plugin Path to the main plugin file from plugins directory. + * @param array $uninstallable_plugins Uninstallable plugins. + */ + do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins ); + + if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { + if ( isset( $uninstallable_plugins[$file] ) ) { + unset($uninstallable_plugins[$file]); + update_option('uninstall_plugins', $uninstallable_plugins); + } + unset($uninstallable_plugins); + + define('WP_UNINSTALL_PLUGIN', $file); + wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); + include( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ); + + return true; + } + + if ( isset( $uninstallable_plugins[$file] ) ) { + $callable = $uninstallable_plugins[$file]; + unset($uninstallable_plugins[$file]); + update_option('uninstall_plugins', $uninstallable_plugins); + unset($uninstallable_plugins); + + wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); + include( WP_PLUGIN_DIR . '/' . $file ); + + add_action( "uninstall_{$file}", $callable ); + + /** + * Fires in uninstall_plugin() once the plugin has been uninstalled. + * + * The action concatenates the 'uninstall_' prefix with the basename of the + * plugin passed to uninstall_plugin() to create a dynamically-named action. + * + * @since 2.7.0 + */ + do_action( "uninstall_{$file}" ); + } +} + +// +// Menu +// + +/** + * Add a top-level menu page. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @global array $menu + * @global array $admin_page_hooks + * @global array $_registered_pages + * @global array $_parent_pages + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only + * include lowercase alphanumeric, dashes, and underscores characters to be compatible + * with sanitize_key(). + * @param callable $function The function to be called to output the content for this page. + * @param string $icon_url The URL to the icon to be used for this menu. + * * Pass a base64-encoded SVG using a data URI, which will be colored to match + * the color scheme. This should begin with 'data:image/svg+xml;base64,'. + * * Pass the name of a Dashicons helper class to use a font icon, + * e.g. 'dashicons-chart-pie'. + * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS. + * @param int $position The position in the menu order this one should appear. + * @return string The resulting page's hook_suffix. + */ +function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { + global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; + + $menu_slug = plugin_basename( $menu_slug ); + + $admin_page_hooks[$menu_slug] = sanitize_title( $menu_title ); + + $hookname = get_plugin_page_hookname( $menu_slug, '' ); + + if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) + add_action( $hookname, $function ); + + if ( empty($icon_url) ) { + $icon_url = 'dashicons-admin-generic'; + $icon_class = 'menu-icon-generic '; + } else { + $icon_url = set_url_scheme( $icon_url ); + $icon_class = ''; + } + + $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); + + if ( null === $position ) { + $menu[] = $new_menu; + } elseif ( isset( $menu[ "$position" ] ) ) { + $position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ) , -5 ) * 0.00001; + $menu[ "$position" ] = $new_menu; + } else { + $menu[ $position ] = $new_menu; + } + + $_registered_pages[$hookname] = true; + + // No parent as top level + $_parent_pages[$menu_slug] = false; + + return $hookname; +} + +/** + * Add a submenu page. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @global array $submenu + * @global array $menu + * @global array $_wp_real_parent_file + * @global bool $_wp_submenu_nopriv + * @global array $_registered_pages + * @global array $_parent_pages + * + * @param string $parent_slug The slug name for the parent menu (or the file name of a standard + * WordPress admin page). + * @param string $page_title The text to be displayed in the title tags of the page when the menu + * is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu + * and only include lowercase alphanumeric, dashes, and underscores characters + * to be compatible with sanitize_key(). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv, + $_registered_pages, $_parent_pages; + + $menu_slug = plugin_basename( $menu_slug ); + $parent_slug = plugin_basename( $parent_slug); + + if ( isset( $_wp_real_parent_file[$parent_slug] ) ) + $parent_slug = $_wp_real_parent_file[$parent_slug]; + + if ( !current_user_can( $capability ) ) { + $_wp_submenu_nopriv[$parent_slug][$menu_slug] = true; + return false; + } + + /* + * If the parent doesn't already have a submenu, add a link to the parent + * as the first item in the submenu. If the submenu file is the same as the + * parent file someone is trying to link back to the parent manually. In + * this case, don't automatically add a link back to avoid duplication. + */ + if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) { + foreach ( (array)$menu as $parent_menu ) { + if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) + $submenu[$parent_slug][] = array_slice( $parent_menu, 0, 4 ); + } + } + + $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title ); + + $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug); + if (!empty ( $function ) && !empty ( $hookname )) + add_action( $hookname, $function ); + + $_registered_pages[$hookname] = true; + + /* + * Backward-compatibility for plugins using add_management page. + * See wp-admin/admin.php for redirect from edit.php to tools.php + */ + if ( 'tools.php' == $parent_slug ) + $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; + + // No parent as top level. + $_parent_pages[$menu_slug] = $parent_slug; + + return $hookname; +} + +/** + * Add submenu page to the Tools main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Settings main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Appearance main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Plugins main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Users/Profile main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + if ( current_user_can('edit_users') ) + $parent = 'users.php'; + else + $parent = 'profile.php'; + return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function ); +} +/** + * Add submenu page to the Dashboard main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Posts main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Media main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Links main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Pages main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Add submenu page to the Comments main menu. + * + * This function takes a capability which will be used to determine whether + * or not a page is included in the menu. + * + * The function which is hooked in to handle the output of the page must check + * that the user has the required capability as well. + * + * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected. + * @param string $menu_title The text to be used for the menu. + * @param string $capability The capability required for this menu to be displayed to the user. + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu). + * @param callable $function The function to be called to output the content for this page. + * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + */ +function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { + return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); +} + +/** + * Remove a top-level admin menu. + * + * @since 3.1.0 + * + * @global array $menu + * + * @param string $menu_slug The slug of the menu. + * @return array|bool The removed menu on success, false if not found. + */ +function remove_menu_page( $menu_slug ) { + global $menu; + + foreach ( $menu as $i => $item ) { + if ( $menu_slug == $item[2] ) { + unset( $menu[$i] ); + return $item; + } + } + + return false; +} + +/** + * Remove an admin submenu. + * + * @since 3.1.0 + * + * @global array $submenu + * + * @param string $menu_slug The slug for the parent menu. + * @param string $submenu_slug The slug of the submenu. + * @return array|bool The removed submenu on success, false if not found. + */ +function remove_submenu_page( $menu_slug, $submenu_slug ) { + global $submenu; + + if ( !isset( $submenu[$menu_slug] ) ) + return false; + + foreach ( $submenu[$menu_slug] as $i => $item ) { + if ( $submenu_slug == $item[2] ) { + unset( $submenu[$menu_slug][$i] ); + return $item; + } + } + + return false; +} + +/** + * Get the url to access a particular menu page based on the slug it was registered with. + * + * If the slug hasn't been registered properly no url will be returned + * + * @since 3.0.0 + * + * @global array $_parent_pages + * + * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) + * @param bool $echo Whether or not to echo the url - default is true + * @return string the url + */ +function menu_page_url($menu_slug, $echo = true) { + global $_parent_pages; + + if ( isset( $_parent_pages[$menu_slug] ) ) { + $parent_slug = $_parent_pages[$menu_slug]; + if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { + $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); + } else { + $url = admin_url( 'admin.php?page=' . $menu_slug ); + } + } else { + $url = ''; + } + + $url = esc_url($url); + + if ( $echo ) + echo $url; + + return $url; +} + +// +// Pluggable Menu Support -- Private +// +/** + * + * @global string $parent_file + * @global array $menu + * @global array $submenu + * @global string $pagenow + * @global string $typenow + * @global string $plugin_page + * @global array $_wp_real_parent_file + * @global array $_wp_menu_nopriv + * @global array $_wp_submenu_nopriv + */ +function get_admin_page_parent( $parent = '' ) { + global $parent_file, $menu, $submenu, $pagenow, $typenow, + $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; + + if ( !empty ( $parent ) && 'admin.php' != $parent ) { + if ( isset( $_wp_real_parent_file[$parent] ) ) + $parent = $_wp_real_parent_file[$parent]; + return $parent; + } + + if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { + foreach ( (array)$menu as $parent_menu ) { + if ( $parent_menu[2] == $plugin_page ) { + $parent_file = $plugin_page; + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + } + if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { + $parent_file = $plugin_page; + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + } + + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { + $parent_file = $pagenow; + if ( isset( $_wp_real_parent_file[$parent_file] ) ) + $parent_file = $_wp_real_parent_file[$parent_file]; + return $parent_file; + } + + foreach (array_keys( (array)$submenu ) as $parent) { + foreach ( $submenu[$parent] as $submenu_array ) { + if ( isset( $_wp_real_parent_file[$parent] ) ) + $parent = $_wp_real_parent_file[$parent]; + if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { + $parent_file = $parent; + return $parent; + } elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { + $parent_file = $parent; + return $parent; + } elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) { + $parent_file = $parent; + return $parent; + } + } + } + + if ( empty($parent_file) ) + $parent_file = ''; + return ''; +} + +/** + * + * @global string $title + * @global array $menu + * @global array $submenu + * @global string $pagenow + * @global string $plugin_page + * @global string $typenow + */ +function get_admin_page_title() { + global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow; + + if ( ! empty ( $title ) ) + return $title; + + $hook = get_plugin_page_hook( $plugin_page, $pagenow ); + + $parent = $parent1 = get_admin_page_parent(); + + if ( empty ( $parent) ) { + foreach ( (array)$menu as $menu_array ) { + if ( isset( $menu_array[3] ) ) { + if ( $menu_array[2] == $pagenow ) { + $title = $menu_array[3]; + return $menu_array[3]; + } elseif ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) { + $title = $menu_array[3]; + return $menu_array[3]; + } + } else { + $title = $menu_array[0]; + return $title; + } + } + } else { + foreach ( array_keys( $submenu ) as $parent ) { + foreach ( $submenu[$parent] as $submenu_array ) { + if ( isset( $plugin_page ) && + ( $plugin_page == $submenu_array[2] ) && + ( + ( $parent == $pagenow ) || + ( $parent == $plugin_page ) || + ( $plugin_page == $hook ) || + ( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) || + ( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow) + ) + ) { + $title = $submenu_array[3]; + return $submenu_array[3]; + } + + if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page + continue; + + if ( isset( $submenu_array[3] ) ) { + $title = $submenu_array[3]; + return $submenu_array[3]; + } else { + $title = $submenu_array[0]; + return $title; + } + } + } + if ( empty ( $title ) ) { + foreach ( $menu as $menu_array ) { + if ( isset( $plugin_page ) && + ( $plugin_page == $menu_array[2] ) && + ( $pagenow == 'admin.php' ) && + ( $parent1 == $menu_array[2] ) ) + { + $title = $menu_array[3]; + return $menu_array[3]; + } + } + } + } + + return $title; +} + +/** + * @since 2.3.0 + * + * @param string $plugin_page + * @param string $parent_page + * @return string|null + */ +function get_plugin_page_hook( $plugin_page, $parent_page ) { + $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); + if ( has_action($hook) ) + return $hook; + else + return null; +} + +/** + * + * @global array $admin_page_hooks + * @param string $plugin_page + * @param string $parent_page + */ +function get_plugin_page_hookname( $plugin_page, $parent_page ) { + global $admin_page_hooks; + + $parent = get_admin_page_parent( $parent_page ); + + $page_type = 'admin'; + if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) { + if ( isset( $admin_page_hooks[$plugin_page] ) ) { + $page_type = 'toplevel'; + } elseif ( isset( $admin_page_hooks[$parent] )) { + $page_type = $admin_page_hooks[$parent]; + } + } elseif ( isset( $admin_page_hooks[$parent] ) ) { + $page_type = $admin_page_hooks[$parent]; + } + + $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); + + return $page_type . '_page_' . $plugin_name; +} + +/** + * + * @global string $pagenow + * @global array $menu + * @global array $submenu + * @global array $_wp_menu_nopriv + * @global array $_wp_submenu_nopriv + * @global string $plugin_page + * @global array $_registered_pages + */ +function user_can_access_admin_page() { + global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv, + $plugin_page, $_registered_pages; + + $parent = get_admin_page_parent(); + + if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) + return false; + + if ( isset( $plugin_page ) ) { + if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) + return false; + + $hookname = get_plugin_page_hookname($plugin_page, $parent); + + if ( !isset($_registered_pages[$hookname]) ) + return false; + } + + if ( empty( $parent) ) { + if ( isset( $_wp_menu_nopriv[$pagenow] ) ) + return false; + if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) + return false; + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) + return false; + if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) + return false; + foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { + if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) + return false; + if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) + return false; + } + return true; + } + + if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) ) + return false; + + if ( isset( $submenu[$parent] ) ) { + foreach ( $submenu[$parent] as $submenu_array ) { + if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { + if ( current_user_can( $submenu_array[1] )) + return true; + else + return false; + } elseif ( $submenu_array[2] == $pagenow ) { + if ( current_user_can( $submenu_array[1] )) + return true; + else + return false; + } + } + } + + foreach ( $menu as $menu_array ) { + if ( $menu_array[2] == $parent) { + if ( current_user_can( $menu_array[1] )) + return true; + else + return false; + } + } + + return true; +} + +/* Whitelist functions */ + +/** + * Refreshes the value of the options whitelist available via the 'whitelist_options' hook. + * + * See the {@see 'whitelist_options'} filter. + * + * @since 2.7.0 + * + * @global array $new_whitelist_options + * + * @param array $options + * @return array + */ +function option_update_filter( $options ) { + global $new_whitelist_options; + + if ( is_array( $new_whitelist_options ) ) + $options = add_option_whitelist( $new_whitelist_options, $options ); + + return $options; +} + +/** + * Adds an array of options to the options whitelist. + * + * @since 2.7.0 + * + * @global array $whitelist_options + * + * @param array $new_options + * @param string|array $options + * @return array + */ +function add_option_whitelist( $new_options, $options = '' ) { + if ( $options == '' ) + global $whitelist_options; + else + $whitelist_options = $options; + + foreach ( $new_options as $page => $keys ) { + foreach ( $keys as $key ) { + if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) { + $whitelist_options[ $page ] = array(); + $whitelist_options[ $page ][] = $key; + } else { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if ( $pos === false ) + $whitelist_options[ $page ][] = $key; + } + } + } + + return $whitelist_options; +} + +/** + * Removes a list of options from the options whitelist. + * + * @since 2.7.0 + * + * @global array $whitelist_options + * + * @param array $del_options + * @param string|array $options + * @return array + */ +function remove_option_whitelist( $del_options, $options = '' ) { + if ( $options == '' ) + global $whitelist_options; + else + $whitelist_options = $options; + + foreach ( $del_options as $page => $keys ) { + foreach ( $keys as $key ) { + if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) { + $pos = array_search( $key, $whitelist_options[ $page ] ); + if ( $pos !== false ) + unset( $whitelist_options[ $page ][ $pos ] ); + } + } + } + + return $whitelist_options; +} + +/** + * Output nonce, action, and option_page fields for a settings page. + * + * @since 2.7.0 + * + * @param string $option_group A settings group name. This should match the group name used in register_setting(). + */ +function settings_fields($option_group) { + echo ""; + echo ''; + wp_nonce_field("$option_group-options"); +} + +/** + * Clears the Plugins cache used by get_plugins() and by default, the Plugin Update cache. + * + * @since 3.7.0 + * + * @param bool $clear_update_cache Whether to clear the Plugin updates cache + */ +function wp_clean_plugins_cache( $clear_update_cache = true ) { + if ( $clear_update_cache ) + delete_site_transient( 'update_plugins' ); + wp_cache_delete( 'plugins', 'plugins' ); +} + +/** + * Load a given plugin attempt to generate errors. + * + * @since 3.0.0 + * @since 4.4.0 Function was moved into the `wp-admin/includes/plugin.php` file. + * + * @param string $plugin Plugin file to load. + */ +function plugin_sandbox_scrape( $plugin ) { + wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); + include( WP_PLUGIN_DIR . '/' . $plugin ); +} + +/** + * Helper function for adding content to the postbox shown when editing the privacy policy. + * + * Plugins and themes should suggest text for inclusion in the site's privacy policy. + * The suggested text should contain information about any functionality that affects user privacy, + * and will be shown in the Suggested Privacy Policy Content postbox. + * + * A plugin or theme can use this function multiple times as long as it will help to better present + * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack + * can add or remove suggested content depending on the modules/extensions that are enabled. + * + * Intended for use with the `'admin_init'` action. + * + * @since 4.9.6 + * + * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy. + * @param string $policy_text The suggested content for inclusion in the policy. + * For more information see the Plugins Handbook https://developer.wordpress.org/plugins/. + */ +function wp_add_privacy_policy_content( $plugin_name, $policy_text ) { + if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { + require_once( ABSPATH . 'wp-admin/includes/misc.php' ); + } + + WP_Privacy_Policy_Content::add( $plugin_name, $policy_text ); +} diff --git a/backend/wp-admin/includes/post.php b/backend/wp-admin/includes/post.php new file mode 100644 index 0000000..7fe1b42 --- /dev/null +++ b/backend/wp-admin/includes/post.php @@ -0,0 +1,1876 @@ +cap->create_posts ) ) { + if ( 'page' == $post_data['post_type'] ) + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); + else + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); + } + + if ( isset( $post_data['content'] ) ) + $post_data['post_content'] = $post_data['content']; + + if ( isset( $post_data['excerpt'] ) ) + $post_data['post_excerpt'] = $post_data['excerpt']; + + if ( isset( $post_data['parent_id'] ) ) + $post_data['post_parent'] = (int) $post_data['parent_id']; + + if ( isset($post_data['trackback_url']) ) + $post_data['to_ping'] = $post_data['trackback_url']; + + $post_data['user_ID'] = get_current_user_id(); + + if (!empty ( $post_data['post_author_override'] ) ) { + $post_data['post_author'] = (int) $post_data['post_author_override']; + } else { + if (!empty ( $post_data['post_author'] ) ) { + $post_data['post_author'] = (int) $post_data['post_author']; + } else { + $post_data['post_author'] = (int) $post_data['user_ID']; + } + } + + if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) + && ! current_user_can( $ptype->cap->edit_others_posts ) ) { + if ( $update ) { + if ( 'page' == $post_data['post_type'] ) + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); + else + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) ); + } else { + if ( 'page' == $post_data['post_type'] ) + return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); + else + return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) ); + } + } + + if ( ! empty( $post_data['post_status'] ) ) { + $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); + + // No longer an auto-draft + if ( 'auto-draft' === $post_data['post_status'] ) { + $post_data['post_status'] = 'draft'; + } + + if ( ! get_post_status_object( $post_data['post_status'] ) ) { + unset( $post_data['post_status'] ); + } + } + + // What to do based on which button they pressed + if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) + $post_data['post_status'] = 'draft'; + if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) + $post_data['post_status'] = 'private'; + if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) + $post_data['post_status'] = 'publish'; + if ( isset($post_data['advanced']) && '' != $post_data['advanced'] ) + $post_data['post_status'] = 'draft'; + if ( isset($post_data['pending']) && '' != $post_data['pending'] ) + $post_data['post_status'] = 'pending'; + + if ( isset( $post_data['ID'] ) ) + $post_id = $post_data['ID']; + else + $post_id = false; + $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; + + if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { + $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; + } + + $published_statuses = array( 'publish', 'future' ); + + // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. + // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. + if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) ) + if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) ) + $post_data['post_status'] = 'pending'; + + if ( ! isset( $post_data['post_status'] ) ) { + $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status; + } + + if ( isset( $post_data['post_password'] ) && ! current_user_can( $ptype->cap->publish_posts ) ) { + unset( $post_data['post_password'] ); + } + + if (!isset( $post_data['comment_status'] )) + $post_data['comment_status'] = 'closed'; + + if (!isset( $post_data['ping_status'] )) + $post_data['ping_status'] = 'closed'; + + foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { + if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { + $post_data['edit_date'] = '1'; + break; + } + } + + if ( !empty( $post_data['edit_date'] ) ) { + $aa = $post_data['aa']; + $mm = $post_data['mm']; + $jj = $post_data['jj']; + $hh = $post_data['hh']; + $mn = $post_data['mn']; + $ss = $post_data['ss']; + $aa = ($aa <= 0 ) ? date('Y') : $aa; + $mm = ($mm <= 0 ) ? date('n') : $mm; + $jj = ($jj > 31 ) ? 31 : $jj; + $jj = ($jj <= 0 ) ? date('j') : $jj; + $hh = ($hh > 23 ) ? $hh -24 : $hh; + $mn = ($mn > 59 ) ? $mn -60 : $mn; + $ss = ($ss > 59 ) ? $ss -60 : $ss; + $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); + $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); + if ( !$valid_date ) { + return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); + } + $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); + } + + if ( isset( $post_data['post_category'] ) ) { + $category_object = get_taxonomy( 'category' ); + if ( ! current_user_can( $category_object->cap->assign_terms ) ) { + unset( $post_data['post_category'] ); + } + } + + return $post_data; +} + +/** + * Update an existing post with values provided in $_POST. + * + * @since 1.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $post_data Optional. + * @return int Post ID. + */ +function edit_post( $post_data = null ) { + global $wpdb; + + if ( empty($post_data) ) + $post_data = &$_POST; + + // Clear out any data in internal vars. + unset( $post_data['filter'] ); + + $post_ID = (int) $post_data['post_ID']; + $post = get_post( $post_ID ); + $post_data['post_type'] = $post->post_type; + $post_data['post_mime_type'] = $post->post_mime_type; + + if ( ! empty( $post_data['post_status'] ) ) { + $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); + + if ( 'inherit' == $post_data['post_status'] ) { + unset( $post_data['post_status'] ); + } + } + + $ptype = get_post_type_object($post_data['post_type']); + if ( !current_user_can( 'edit_post', $post_ID ) ) { + if ( 'page' == $post_data['post_type'] ) + wp_die( __('Sorry, you are not allowed to edit this page.' )); + else + wp_die( __('Sorry, you are not allowed to edit this post.' )); + } + + if ( post_type_supports( $ptype->name, 'revisions' ) ) { + $revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) ); + $revision = current( $revisions ); + + // Check if the revisions have been upgraded + if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) + _wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) ); + } + + if ( isset($post_data['visibility']) ) { + switch ( $post_data['visibility'] ) { + case 'public' : + $post_data['post_password'] = ''; + break; + case 'password' : + unset( $post_data['sticky'] ); + break; + case 'private' : + $post_data['post_status'] = 'private'; + $post_data['post_password'] = ''; + unset( $post_data['sticky'] ); + break; + } + } + + $post_data = _wp_translate_postdata( true, $post_data ); + if ( is_wp_error($post_data) ) + wp_die( $post_data->get_error_message() ); + + // Post Formats + if ( isset( $post_data['post_format'] ) ) + set_post_format( $post_ID, $post_data['post_format'] ); + + $format_meta_urls = array( 'url', 'link_url', 'quote_source_url' ); + foreach ( $format_meta_urls as $format_meta_url ) { + $keyed = '_format_' . $format_meta_url; + if ( isset( $post_data[ $keyed ] ) ) + update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) ); + } + + $format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' ); + + foreach ( $format_keys as $key ) { + $keyed = '_format_' . $key; + if ( isset( $post_data[ $keyed ] ) ) { + if ( current_user_can( 'unfiltered_html' ) ) + update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] ); + else + update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) ); + } + } + + if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) { + $id3data = wp_get_attachment_metadata( $post_ID ); + if ( ! is_array( $id3data ) ) { + $id3data = array(); + } + + foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) { + if ( isset( $post_data[ 'id3_' . $key ] ) ) { + $id3data[ $key ] = sanitize_text_field( wp_unslash( $post_data[ 'id3_' . $key ] ) ); + } + } + wp_update_attachment_metadata( $post_ID, $id3data ); + } + + // Meta Stuff + if ( isset($post_data['meta']) && $post_data['meta'] ) { + foreach ( $post_data['meta'] as $key => $value ) { + if ( !$meta = get_post_meta_by_id( $key ) ) + continue; + if ( $meta->post_id != $post_ID ) + continue; + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) + continue; + if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) + continue; + update_meta( $key, $value['key'], $value['value'] ); + } + } + + if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { + foreach ( $post_data['deletemeta'] as $key => $value ) { + if ( !$meta = get_post_meta_by_id( $key ) ) + continue; + if ( $meta->post_id != $post_ID ) + continue; + if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) + continue; + delete_meta( $key ); + } + } + + // Attachment stuff + if ( 'attachment' == $post_data['post_type'] ) { + if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { + $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); + if ( $image_alt != get_post_meta( $post_ID, '_wp_attachment_image_alt', true ) ) { + $image_alt = wp_strip_all_tags( $image_alt, true ); + // update_meta expects slashed. + update_post_meta( $post_ID, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); + } + } + + $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); + + /** This filter is documented in wp-admin/includes/media.php */ + $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); + } + + // Convert taxonomy input to term IDs, to avoid ambiguity. + if ( isset( $post_data['tax_input'] ) ) { + foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) { + // Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary. + if ( is_taxonomy_hierarchical( $taxonomy ) ) { + continue; + } + + /* + * Assume that a 'tax_input' string is a comma-separated list of term names. + * Some languages may use a character other than a comma as a delimiter, so we standardize on + * commas before parsing the list. + */ + if ( ! is_array( $terms ) ) { + $comma = _x( ',', 'tag delimiter' ); + if ( ',' !== $comma ) { + $terms = str_replace( $comma, ',', $terms ); + } + $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); + } + + $clean_terms = array(); + foreach ( $terms as $term ) { + // Empty terms are invalid input. + if ( empty( $term ) ) { + continue; + } + + $_term = get_terms( $taxonomy, array( + 'name' => $term, + 'fields' => 'ids', + 'hide_empty' => false, + ) ); + + if ( ! empty( $_term ) ) { + $clean_terms[] = intval( $_term[0] ); + } else { + // No existing term was found, so pass the string. A new term will be created. + $clean_terms[] = $term; + } + } + + $post_data['tax_input'][ $taxonomy ] = $clean_terms; + } + } + + add_meta( $post_ID ); + + update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); + + $success = wp_update_post( $post_data ); + // If the save failed, see if we can sanity check the main fields and try again + if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { + $fields = array( 'post_title', 'post_content', 'post_excerpt' ); + + foreach ( $fields as $field ) { + if ( isset( $post_data[ $field ] ) ) { + $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] ); + } + } + + wp_update_post( $post_data ); + } + + // Now that we have an ID we can fix any attachment anchor hrefs + _fix_attachment_links( $post_ID ); + + wp_set_post_lock( $post_ID ); + + if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) { + if ( ! empty( $post_data['sticky'] ) ) + stick_post( $post_ID ); + else + unstick_post( $post_ID ); + } + + return $post_ID; +} + +/** + * Process the post data for the bulk editing of posts. + * + * Updates all bulk edited posts/pages, adding (but not removing) tags and + * categories. Skips pages when they would be their own parent or child. + * + * @since 2.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal. + * @return array + */ +function bulk_edit_posts( $post_data = null ) { + global $wpdb; + + if ( empty($post_data) ) + $post_data = &$_POST; + + if ( isset($post_data['post_type']) ) + $ptype = get_post_type_object($post_data['post_type']); + else + $ptype = get_post_type_object('post'); + + if ( !current_user_can( $ptype->cap->edit_posts ) ) { + if ( 'page' == $ptype->name ) + wp_die( __('Sorry, you are not allowed to edit pages.')); + else + wp_die( __('Sorry, you are not allowed to edit posts.')); + } + + if ( -1 == $post_data['_status'] ) { + $post_data['post_status'] = null; + unset($post_data['post_status']); + } else { + $post_data['post_status'] = $post_data['_status']; + } + unset($post_data['_status']); + + if ( ! empty( $post_data['post_status'] ) ) { + $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); + + if ( 'inherit' == $post_data['post_status'] ) { + unset( $post_data['post_status'] ); + } + } + + $post_IDs = array_map( 'intval', (array) $post_data['post'] ); + + $reset = array( + 'post_author', 'post_status', 'post_password', + 'post_parent', 'page_template', 'comment_status', + 'ping_status', 'keep_private', 'tax_input', + 'post_category', 'sticky', 'post_format', + ); + + foreach ( $reset as $field ) { + if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) ) + unset($post_data[$field]); + } + + if ( isset($post_data['post_category']) ) { + if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) ) + $new_cats = array_map( 'absint', $post_data['post_category'] ); + else + unset($post_data['post_category']); + } + + $tax_input = array(); + if ( isset($post_data['tax_input'])) { + foreach ( $post_data['tax_input'] as $tax_name => $terms ) { + if ( empty($terms) ) + continue; + if ( is_taxonomy_hierarchical( $tax_name ) ) { + $tax_input[ $tax_name ] = array_map( 'absint', $terms ); + } else { + $comma = _x( ',', 'tag delimiter' ); + if ( ',' !== $comma ) + $terms = str_replace( $comma, ',', $terms ); + $tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); + } + } + } + + if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) { + $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); + $children = array(); + + for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { + $children[] = $parent; + + foreach ( $pages as $page ) { + if ( $page->ID == $parent ) { + $parent = $page->post_parent; + break; + } + } + } + } + + $updated = $skipped = $locked = array(); + $shared_post_data = $post_data; + + foreach ( $post_IDs as $post_ID ) { + // Start with fresh post data with each iteration. + $post_data = $shared_post_data; + + $post_type_object = get_post_type_object( get_post_type( $post_ID ) ); + + if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) { + $skipped[] = $post_ID; + continue; + } + + if ( wp_check_post_lock( $post_ID ) ) { + $locked[] = $post_ID; + continue; + } + + $post = get_post( $post_ID ); + $tax_names = get_object_taxonomies( $post ); + foreach ( $tax_names as $tax_name ) { + $taxonomy_obj = get_taxonomy($tax_name); + if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) + $new_terms = $tax_input[$tax_name]; + else + $new_terms = array(); + + if ( $taxonomy_obj->hierarchical ) + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') ); + else + $current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') ); + + $post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms ); + } + + if ( isset($new_cats) && in_array( 'category', $tax_names ) ) { + $cats = (array) wp_get_post_categories($post_ID); + $post_data['post_category'] = array_unique( array_merge($cats, $new_cats) ); + unset( $post_data['tax_input']['category'] ); + } + + $post_data['post_type'] = $post->post_type; + $post_data['post_mime_type'] = $post->post_mime_type; + $post_data['guid'] = $post->guid; + + foreach ( array( 'comment_status', 'ping_status', 'post_author' ) as $field ) { + if ( ! isset( $post_data[ $field ] ) ) { + $post_data[ $field ] = $post->$field; + } + } + + $post_data['ID'] = $post_ID; + $post_data['post_ID'] = $post_ID; + + $post_data = _wp_translate_postdata( true, $post_data ); + if ( is_wp_error( $post_data ) ) { + $skipped[] = $post_ID; + continue; + } + + if ( isset( $post_data['post_format'] ) ) { + set_post_format( $post_ID, $post_data['post_format'] ); + unset( $post_data['tax_input']['post_format'] ); + } + + $updated[] = wp_update_post( $post_data ); + + if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { + if ( 'sticky' == $post_data['sticky'] ) + stick_post( $post_ID ); + else + unstick_post( $post_ID ); + } + } + + return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); +} + +/** + * Default post information to use when populating the "Write Post" form. + * + * @since 2.0.0 + * + * @param string $post_type Optional. A post type string. Default 'post'. + * @param bool $create_in_db Optional. Whether to insert the post into database. Default false. + * @return WP_Post Post object containing all the default post data as attributes + */ +function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) { + $post_title = ''; + if ( !empty( $_REQUEST['post_title'] ) ) + $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] )); + + $post_content = ''; + if ( !empty( $_REQUEST['content'] ) ) + $post_content = esc_html( wp_unslash( $_REQUEST['content'] )); + + $post_excerpt = ''; + if ( !empty( $_REQUEST['excerpt'] ) ) + $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] )); + + if ( $create_in_db ) { + $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); + $post = get_post( $post_id ); + if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) + set_post_format( $post, get_option( 'default_post_format' ) ); + } else { + $post = new stdClass; + $post->ID = 0; + $post->post_author = ''; + $post->post_date = ''; + $post->post_date_gmt = ''; + $post->post_password = ''; + $post->post_name = ''; + $post->post_type = $post_type; + $post->post_status = 'draft'; + $post->to_ping = ''; + $post->pinged = ''; + $post->comment_status = get_default_comment_status( $post_type ); + $post->ping_status = get_default_comment_status( $post_type, 'pingback' ); + $post->post_pingback = get_option( 'default_pingback_flag' ); + $post->post_category = get_option( 'default_category' ); + $post->page_template = 'default'; + $post->post_parent = 0; + $post->menu_order = 0; + $post = new WP_Post( $post ); + } + + /** + * Filters the default post content initially used in the "Write Post" form. + * + * @since 1.5.0 + * + * @param string $post_content Default post content. + * @param WP_Post $post Post object. + */ + $post->post_content = apply_filters( 'default_content', $post_content, $post ); + + /** + * Filters the default post title initially used in the "Write Post" form. + * + * @since 1.5.0 + * + * @param string $post_title Default post title. + * @param WP_Post $post Post object. + */ + $post->post_title = apply_filters( 'default_title', $post_title, $post ); + + /** + * Filters the default post excerpt initially used in the "Write Post" form. + * + * @since 1.5.0 + * + * @param string $post_excerpt Default post excerpt. + * @param WP_Post $post Post object. + */ + $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); + + return $post; +} + +/** + * Determine if a post exists based on title, content, and date + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $title Post title + * @param string $content Optional post content + * @param string $date Optional post date + * @return int Post ID if post exists, 0 otherwise. + */ +function post_exists($title, $content = '', $date = '') { + global $wpdb; + + $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); + $post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); + $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); + + $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; + $args = array(); + + if ( !empty ( $date ) ) { + $query .= ' AND post_date = %s'; + $args[] = $post_date; + } + + if ( !empty ( $title ) ) { + $query .= ' AND post_title = %s'; + $args[] = $post_title; + } + + if ( !empty ( $content ) ) { + $query .= ' AND post_content = %s'; + $args[] = $post_content; + } + + if ( !empty ( $args ) ) + return (int) $wpdb->get_var( $wpdb->prepare($query, $args) ); + + return 0; +} + +/** + * Creates a new post from the "Write Post" form using $_POST information. + * + * @since 2.1.0 + * + * @global WP_User $current_user + * + * @return int|WP_Error + */ +function wp_write_post() { + if ( isset($_POST['post_type']) ) + $ptype = get_post_type_object($_POST['post_type']); + else + $ptype = get_post_type_object('post'); + + if ( !current_user_can( $ptype->cap->edit_posts ) ) { + if ( 'page' == $ptype->name ) + return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); + else + return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) ); + } + + $_POST['post_mime_type'] = ''; + + // Clear out any data in internal vars. + unset( $_POST['filter'] ); + + // Edit don't write if we have a post id. + if ( isset( $_POST['post_ID'] ) ) + return edit_post(); + + if ( isset($_POST['visibility']) ) { + switch ( $_POST['visibility'] ) { + case 'public' : + $_POST['post_password'] = ''; + break; + case 'password' : + unset( $_POST['sticky'] ); + break; + case 'private' : + $_POST['post_status'] = 'private'; + $_POST['post_password'] = ''; + unset( $_POST['sticky'] ); + break; + } + } + + $translated = _wp_translate_postdata( false ); + if ( is_wp_error($translated) ) + return $translated; + + // Create the post. + $post_ID = wp_insert_post( $_POST ); + if ( is_wp_error( $post_ID ) ) + return $post_ID; + + if ( empty($post_ID) ) + return 0; + + add_meta( $post_ID ); + + add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); + + // Now that we have an ID we can fix any attachment anchor hrefs + _fix_attachment_links( $post_ID ); + + wp_set_post_lock( $post_ID ); + + return $post_ID; +} + +/** + * Calls wp_write_post() and handles the errors. + * + * @since 2.0.0 + * + * @return int|null + */ +function write_post() { + $result = wp_write_post(); + if ( is_wp_error( $result ) ) + wp_die( $result->get_error_message() ); + else + return $result; +} + +// +// Post Meta +// + +/** + * Add post meta data defined in $_POST superglobal for post with given ID. + * + * @since 1.2.0 + * + * @param int $post_ID + * @return int|bool + */ +function add_meta( $post_ID ) { + $post_ID = (int) $post_ID; + + $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : ''; + $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : ''; + $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; + if ( is_string( $metavalue ) ) + $metavalue = trim( $metavalue ); + + if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) { + /* + * We have a key/value pair. If both the select and the input + * for the key have data, the input takes precedence. + */ + if ( '#NONE#' != $metakeyselect ) + $metakey = $metakeyselect; + + if ( $metakeyinput ) + $metakey = $metakeyinput; // default + + if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) + return false; + + $metakey = wp_slash( $metakey ); + + return add_post_meta( $post_ID, $metakey, $metavalue ); + } + + return false; +} // add_meta + +/** + * Delete post meta data by meta ID. + * + * @since 1.2.0 + * + * @param int $mid + * @return bool + */ +function delete_meta( $mid ) { + return delete_metadata_by_mid( 'post' , $mid ); +} + +/** + * Get a list of previously defined keys. + * + * @since 1.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return mixed + */ +function get_meta_keys() { + global $wpdb; + + $keys = $wpdb->get_col( " + SELECT meta_key + FROM $wpdb->postmeta + GROUP BY meta_key + ORDER BY meta_key" ); + + return $keys; +} + +/** + * Get post meta data by meta ID. + * + * @since 2.1.0 + * + * @param int $mid + * @return object|bool + */ +function get_post_meta_by_id( $mid ) { + return get_metadata_by_mid( 'post', $mid ); +} + +/** + * Get meta data for the given post ID. + * + * @since 1.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $postid + * @return mixed + */ +function has_meta( $postid ) { + global $wpdb; + + return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id + FROM $wpdb->postmeta WHERE post_id = %d + ORDER BY meta_key,meta_id", $postid), ARRAY_A ); +} + +/** + * Update post meta data by meta ID. + * + * @since 1.2.0 + * + * @param int $meta_id + * @param string $meta_key Expect Slashed + * @param string $meta_value Expect Slashed + * @return bool + */ +function update_meta( $meta_id, $meta_key, $meta_value ) { + $meta_key = wp_unslash( $meta_key ); + $meta_value = wp_unslash( $meta_value ); + + return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); +} + +// +// Private +// + +/** + * Replace hrefs of attachment anchors with up-to-date permalinks. + * + * @since 2.3.0 + * @access private + * + * @param int|object $post Post ID or post object. + * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success. + */ +function _fix_attachment_links( $post ) { + $post = get_post( $post, ARRAY_A ); + $content = $post['post_content']; + + // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) + return; + + // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) + if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) + return; + + $site_url = get_bloginfo('url'); + $site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s) + $replace = ''; + + foreach ( $link_matches[1] as $key => $value ) { + if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-') + || !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match ) + || !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) + continue; + + $quote = $url_match[1]; // the quote (single or double) + $url_id = (int) $url_match[2]; + $rel_id = (int) $rel_match[1]; + + if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false ) + continue; + + $link = $link_matches[0][$key]; + $replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link ); + + $content = str_replace( $link, $replace, $content ); + } + + if ( $replace ) { + $post['post_content'] = $content; + // Escape data pulled from DB. + $post = add_magic_quotes($post); + + return wp_update_post($post); + } +} + +/** + * Get all the possible statuses for a post_type + * + * @since 2.5.0 + * + * @param string $type The post_type you want the statuses for + * @return array As array of all the statuses for the supplied post type + */ +function get_available_post_statuses($type = 'post') { + $stati = wp_count_posts($type); + + return array_keys(get_object_vars($stati)); +} + +/** + * Run the wp query to fetch the posts for listing on the edit posts page + * + * @since 2.5.0 + * + * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. + * @return array + */ +function wp_edit_posts_query( $q = false ) { + if ( false === $q ) + $q = $_GET; + $q['m'] = isset($q['m']) ? (int) $q['m'] : 0; + $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0; + $post_stati = get_post_stati(); + + if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) ) + $post_type = $q['post_type']; + else + $post_type = 'post'; + + $avail_post_stati = get_available_post_statuses($post_type); + + if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) { + $post_status = $q['post_status']; + $perm = 'readable'; + } + + if ( isset( $q['orderby'] ) ) { + $orderby = $q['orderby']; + } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { + $orderby = 'modified'; + } + + if ( isset( $q['order'] ) ) { + $order = $q['order']; + } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { + $order = 'ASC'; + } + + $per_page = "edit_{$post_type}_per_page"; + $posts_per_page = (int) get_user_option( $per_page ); + if ( empty( $posts_per_page ) || $posts_per_page < 1 ) + $posts_per_page = 20; + + /** + * Filters the number of items per page to show for a specific 'per_page' type. + * + * The dynamic portion of the hook name, `$post_type`, refers to the post type. + * + * Some examples of filter hooks generated here include: 'edit_attachment_per_page', + * 'edit_post_per_page', 'edit_page_per_page', etc. + * + * @since 3.0.0 + * + * @param int $posts_per_page Number of posts to display per page for the given post + * type. Default 20. + */ + $posts_per_page = apply_filters( "edit_{$post_type}_per_page", $posts_per_page ); + + /** + * Filters the number of posts displayed per page when specifically listing "posts". + * + * @since 2.8.0 + * + * @param int $posts_per_page Number of posts to be displayed. Default 20. + * @param string $post_type The post type. + */ + $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type ); + + $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page'); + + // Hierarchical types require special args. + if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) { + $query['orderby'] = 'menu_order title'; + $query['order'] = 'asc'; + $query['posts_per_page'] = -1; + $query['posts_per_archive_page'] = -1; + $query['fields'] = 'id=>parent'; + } + + if ( ! empty( $q['show_sticky'] ) ) + $query['post__in'] = (array) get_option( 'sticky_posts' ); + + wp( $query ); + + return $avail_post_stati; +} + +/** + * Get all available post MIME types for a given post type. + * + * @since 2.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $type + * @return mixed + */ +function get_available_post_mime_types($type = 'attachment') { + global $wpdb; + + $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); + return $types; +} + +/** + * Get the query variables for the current attachments request. + * + * @since 4.2.0 + * + * @param array|false $q Optional. Array of query variables to use to build the query or false + * to use $_GET superglobal. Default false. + * @return array The parsed query vars. + */ +function wp_edit_attachments_query_vars( $q = false ) { + if ( false === $q ) { + $q = $_GET; + } + $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; + $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; + $q['post_type'] = 'attachment'; + $post_type = get_post_type_object( 'attachment' ); + $states = 'inherit'; + if ( current_user_can( $post_type->cap->read_private_posts ) ) { + $states .= ',private'; + } + + $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; + $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; + + $media_per_page = (int) get_user_option( 'upload_per_page' ); + if ( empty( $media_per_page ) || $media_per_page < 1 ) { + $media_per_page = 20; + } + + /** + * Filters the number of items to list per page when listing media items. + * + * @since 2.9.0 + * + * @param int $media_per_page Number of media to list. Default 20. + */ + $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); + + $post_mime_types = get_post_mime_types(); + if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) { + unset($q['post_mime_type']); + } + + foreach ( array_keys( $post_mime_types ) as $type ) { + if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { + $q['post_mime_type'] = $type; + break; + } + } + + if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) { + $q['post_parent'] = 0; + } + + if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' == $q['attachment-filter'] ) ) { + $q['author'] = get_current_user_id(); + } + + // Filter query clauses to include filenames. + if ( isset( $q['s'] ) ) { + add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); + } + + return $q; +} + +/** + * Executes a query for attachments. An array of WP_Query arguments + * can be passed in, which will override the arguments set by this function. + * + * @since 2.5.0 + * + * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. + * @return array + */ +function wp_edit_attachments_query( $q = false ) { + wp( wp_edit_attachments_query_vars( $q ) ); + + $post_mime_types = get_post_mime_types(); + $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); + + return array( $post_mime_types, $avail_post_mime_types ); +} + +/** + * Returns the list of classes to be used by a meta box. + * + * @since 2.5.0 + * + * @param string $id + * @param string $page + * @return string + */ +function postbox_classes( $id, $page ) { + if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) { + $classes = array( '' ); + } elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) { + if ( !is_array( $closed ) ) { + $classes = array( '' ); + } else { + $classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' ); + } + } else { + $classes = array( '' ); + } + + /** + * Filters the postbox classes for a specific screen and screen ID combo. + * + * The dynamic portions of the hook name, `$page` and `$id`, refer to + * the screen and screen ID, respectively. + * + * @since 3.2.0 + * + * @param array $classes An array of postbox classes. + */ + $classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes ); + return implode( ' ', $classes ); +} + +/** + * Get a sample permalink based off of the post name. + * + * @since 2.5.0 + * + * @param int $id Post ID or post object. + * @param string $title Optional. Title to override the post's current title when generating the post name. Default null. + * @param string $name Optional. Name to override the post name. Default null. + * @return array Array containing the sample permalink with placeholder for the post name, and the post name. + */ +function get_sample_permalink($id, $title = null, $name = null) { + $post = get_post( $id ); + if ( ! $post ) + return array( '', '' ); + + $ptype = get_post_type_object($post->post_type); + + $original_status = $post->post_status; + $original_date = $post->post_date; + $original_name = $post->post_name; + + // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. + if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) { + $post->post_status = 'publish'; + $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); + } + + // If the user wants to set a new name -- override the current one + // Note: if empty name is supplied -- use the title instead, see #6072 + if ( !is_null($name) ) + $post->post_name = sanitize_title($name ? $name : $title, $post->ID); + + $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); + + $post->filter = 'sample'; + + $permalink = get_permalink($post, true); + + // Replace custom post_type Token with generic pagename token for ease of use. + $permalink = str_replace("%$post->post_type%", '%pagename%', $permalink); + + // Handle page hierarchy + if ( $ptype->hierarchical ) { + $uri = get_page_uri($post); + if ( $uri ) { + $uri = untrailingslashit($uri); + $uri = strrev( stristr( strrev( $uri ), '/' ) ); + $uri = untrailingslashit($uri); + } + + /** This filter is documented in wp-admin/edit-tag-form.php */ + $uri = apply_filters( 'editable_slug', $uri, $post ); + if ( !empty($uri) ) + $uri .= '/'; + $permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink); + } + + /** This filter is documented in wp-admin/edit-tag-form.php */ + $permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) ); + $post->post_status = $original_status; + $post->post_date = $original_date; + $post->post_name = $original_name; + unset($post->filter); + + /** + * Filters the sample permalink. + * + * @since 4.4.0 + * + * @param array $permalink Array containing the sample permalink with placeholder for the post name, and the post name. + * @param int $post_id Post ID. + * @param string $title Post title. + * @param string $name Post name (slug). + * @param WP_Post $post Post object. + */ + return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post ); +} + +/** + * Returns the HTML of the sample permalink slug editor. + * + * @since 2.5.0 + * + * @param int $id Post ID or post object. + * @param string $new_title Optional. New title. Default null. + * @param string $new_slug Optional. New slug. Default null. + * @return string The HTML of the sample permalink slug editor. + */ +function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { + $post = get_post( $id ); + if ( ! $post ) + return ''; + + list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); + + $view_link = false; + $preview_target = ''; + + if ( current_user_can( 'read_post', $post->ID ) ) { + if ( 'draft' === $post->post_status || empty( $post->post_name ) ) { + $view_link = get_preview_post_link( $post ); + $preview_target = " target='wp-preview-{$post->ID}'"; + } else { + if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { + $view_link = get_permalink( $post ); + } else { + // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set + $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink ); + } + } + } + + // Permalinks without a post/page name placeholder don't have anything to edit + if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { + $return = '' . __( 'Permalink:' ) . "\n"; + + if ( false !== $view_link ) { + $display_link = urldecode( $view_link ); + $return .= '' . esc_html( $display_link ) . "\n"; + } else { + $return .= '' . $permalink . "\n"; + } + + // Encourage a pretty permalink setting + if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) { + $return .= '' . __('Change Permalinks') . "\n"; + } + } else { + if ( mb_strlen( $post_name ) > 34 ) { + $post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 ); + } else { + $post_name_abridged = $post_name; + } + + $post_name_html = '' . esc_html( $post_name_abridged ) . ''; + $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) ); + + $return = '' . __( 'Permalink:' ) . "\n"; + $return .= '' . $display_link . "\n"; + $return .= '‎'; // Fix bi-directional text display defect in RTL languages. + $return .= '\n"; + $return .= '' . esc_html( $post_name ) . "\n"; + } + + /** + * Filters the sample permalink HTML markup. + * + * @since 2.9.0 + * @since 4.4.0 Added `$post` parameter. + * + * @param string $return Sample permalink HTML markup. + * @param int $post_id Post ID. + * @param string $new_title New sample permalink title. + * @param string $new_slug New sample permalink slug. + * @param WP_Post $post Post object. + */ + $return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post ); + + return $return; +} + +/** + * Output HTML for the post thumbnail meta-box. + * + * @since 2.9.0 + * + * @param int $thumbnail_id ID of the attachment used for thumbnail + * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. + * @return string html + */ +function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { + $_wp_additional_image_sizes = wp_get_additional_image_sizes(); + + $post = get_post( $post ); + $post_type_object = get_post_type_object( $post->post_type ); + $set_thumbnail_link = '

      %s

      '; + $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); + + $content = sprintf( $set_thumbnail_link, + esc_url( $upload_iframe_src ), + '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. + esc_html( $post_type_object->labels->set_featured_image ) + ); + + if ( $thumbnail_id && get_post( $thumbnail_id ) ) { + $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); + + /** + * Filters the size used to display the post thumbnail image in the 'Featured Image' meta box. + * + * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail' + * image size is registered, which differs from the 'thumbnail' image size + * managed via the Settings > Media screen. See the `$size` parameter description + * for more information on default values. + * + * @since 4.4.0 + * + * @param string|array $size Post thumbnail image size to display in the meta box. Accepts any valid + * image size, or an array of width and height values in pixels (in that order). + * If the 'post-thumbnail' size is set, default is 'post-thumbnail'. Otherwise, + * default is an array with 266 as both the height and width values. + * @param int $thumbnail_id Post thumbnail attachment ID. + * @param WP_Post $post The post object associated with the thumbnail. + */ + $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); + + $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); + + if ( ! empty( $thumbnail_html ) ) { + $content = sprintf( $set_thumbnail_link, + esc_url( $upload_iframe_src ), + ' aria-describedby="set-post-thumbnail-desc"', + $thumbnail_html + ); + $content .= '

      ' . __( 'Click the image to edit or update' ) . '

      '; + $content .= '

      ' . esc_html( $post_type_object->labels->remove_featured_image ) . '

      '; + } + } + + $content .= ''; + + /** + * Filters the admin post thumbnail HTML markup to return. + * + * @since 2.9.0 + * @since 3.5.0 Added the `$post_id` parameter. + * @since 4.6.0 Added the `$thumbnail_id` parameter. + * + * @param string $content Admin post thumbnail HTML markup. + * @param int $post_id Post ID. + * @param int $thumbnail_id Thumbnail ID. + */ + return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id ); +} + +/** + * Check to see if the post is currently being edited by another user. + * + * @since 2.5.0 + * + * @param int $post_id ID of the post to check for editing. + * @return int|false ID of the user with lock. False if the post does not exist, post is not locked, + * the user with lock does not exist, or the post is locked by current user. + */ +function wp_check_post_lock( $post_id ) { + if ( ! $post = get_post( $post_id ) ) { + return false; + } + + if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) { + return false; + } + + $lock = explode( ':', $lock ); + $time = $lock[0]; + $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); + + if ( ! get_userdata( $user ) ) { + return false; + } + + /** This filter is documented in wp-admin/includes/ajax-actions.php */ + $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); + + if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) { + return $user; + } + + return false; +} + +/** + * Mark the post as currently being edited by the current user + * + * @since 2.5.0 + * + * @param int $post_id ID of the post being edited. + * @return array|false Array of the lock time and user ID. False if the post does not exist, or + * there is no current user. + */ +function wp_set_post_lock( $post_id ) { + if ( ! $post = get_post( $post_id ) ) { + return false; + } + + if ( 0 == ( $user_id = get_current_user_id() ) ) { + return false; + } + + $now = time(); + $lock = "$now:$user_id"; + + update_post_meta( $post->ID, '_edit_lock', $lock ); + + return array( $now, $user_id ); +} + +/** + * Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post. + * + * @since 2.8.5 + * @return none + */ +function _admin_notice_post_locked() { + if ( ! $post = get_post() ) + return; + + $user = null; + if ( $user_id = wp_check_post_lock( $post->ID ) ) + $user = get_userdata( $user_id ); + + if ( $user ) { + + /** + * Filters whether to show the post locked dialog. + * + * Returning a falsey value to the filter will short-circuit displaying the dialog. + * + * @since 3.6.0 + * + * @param bool $display Whether to display the dialog. Default true. + * @param WP_Post $post Post object. + * @param WP_User|bool $user WP_User object on success, false otherwise. + */ + if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) + return; + + $locked = true; + } else { + $locked = false; + } + + if ( $locked && ( $sendback = wp_get_referer() ) && + false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { + + $sendback_text = __('Go back'); + } else { + $sendback = admin_url( 'edit.php' ); + + if ( 'post' != $post->post_type ) + $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); + + $sendback_text = get_post_type_object( $post->post_type )->labels->all_items; + } + + $hidden = $locked ? '' : ' hidden'; + + ?> +
      +
      +
      + post_type )->public ) { + if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { + // Latest content is in autosave + $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); + $query_args['preview_id'] = $post->ID; + $query_args['preview_nonce'] = $nonce; + } + } + + $preview_link = get_preview_post_link( $post->ID, $query_args ); + + /** + * Filters whether to allow the post lock to be overridden. + * + * Returning a falsey value to the filter will disable the ability + * to override the post lock. + * + * @since 3.6.0 + * + * @param bool $override Whether to allow overriding post locks. Default true. + * @param WP_Post $post Post object. + * @param WP_User $user User object. + */ + $override = apply_filters( 'override_post_lock', true, $post, $user ); + $tab_last = $override ? '' : ' wp-tab-last'; + + ?> +
      +
      ID, 64 ); ?>
      +

      + display_name ) ); + } else { + /* translators: %s: user's display name */ + printf( __( '%s is already editing this post.' ), esc_html( $user->display_name ) ); + } + ?> +

      + +

      + + + + + + +

      +
      + +
      +
      +

      +
      + + +

      + +

      +
      + +
      +
      + ID; + $new_autosave['post_author'] = $post_author; + + // If the new autosave has the same content as the post, delete the autosave. + $post = get_post( $post_id ); + $autosave_is_different = false; + foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { + if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { + $autosave_is_different = true; + break; + } + } + + if ( ! $autosave_is_different ) { + wp_delete_post_revision( $old_autosave->ID ); + return 0; + } + + /** + * Fires before an autosave is stored. + * + * @since 4.1.0 + * + * @param array $new_autosave Post array - the autosave that is about to be saved. + */ + do_action( 'wp_creating_autosave', $new_autosave ); + + return wp_update_post( $new_autosave ); + } + + // _wp_put_post_revision() expects unescaped. + $post_data = wp_unslash( $post_data ); + + // Otherwise create the new autosave as a special post revision + return _wp_put_post_revision( $post_data, true ); +} + +/** + * Saves a draft or manually autosaves for the purpose of showing a post preview. + * + * @since 2.7.0 + * + * @return string URL to redirect to show the preview. + */ +function post_preview() { + + $post_ID = (int) $_POST['post_ID']; + $_POST['ID'] = $post_ID; + + if ( ! $post = get_post( $post_ID ) ) { + wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); + } + + if ( ! current_user_can( 'edit_post', $post->ID ) ) { + wp_die( __( 'Sorry, you are not allowed to edit this post.' ) ); + } + + $is_autosave = false; + + if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { + $saved_post_id = edit_post(); + } else { + $is_autosave = true; + + if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) + $_POST['post_status'] = 'draft'; + + $saved_post_id = wp_create_post_autosave( $post->ID ); + } + + if ( is_wp_error( $saved_post_id ) ) + wp_die( $saved_post_id->get_error_message() ); + + $query_args = array(); + + if ( $is_autosave && $saved_post_id ) { + $query_args['preview_id'] = $post->ID; + $query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID ); + + if ( isset( $_POST['post_format'] ) ) { + $query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] ); + } + + if ( isset( $_POST['_thumbnail_id'] ) ) { + $query_args['_thumbnail_id'] = ( intval( $_POST['_thumbnail_id'] ) <= 0 ) ? '-1' : intval( $_POST['_thumbnail_id'] ); + } + } + + return get_preview_post_link( $post, $query_args ); +} + +/** + * Save a post submitted with XHR + * + * Intended for use with heartbeat and autosave.js + * + * @since 3.9.0 + * + * @param array $post_data Associative array of the submitted post data. + * @return mixed The value 0 or WP_Error on failure. The saved post ID on success. + * The ID can be the draft post_id or the autosave revision post_id. + */ +function wp_autosave( $post_data ) { + // Back-compat + if ( ! defined( 'DOING_AUTOSAVE' ) ) + define( 'DOING_AUTOSAVE', true ); + + $post_id = (int) $post_data['post_id']; + $post_data['ID'] = $post_data['post_ID'] = $post_id; + + if ( false === wp_verify_nonce( $post_data['_wpnonce'], 'update-post_' . $post_id ) ) { + return new WP_Error( 'invalid_nonce', __( 'Error while saving.' ) ); + } + + $post = get_post( $post_id ); + + if ( ! current_user_can( 'edit_post', $post->ID ) ) { + return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) ); + } + + if ( 'auto-draft' == $post->post_status ) + $post_data['post_status'] = 'draft'; + + if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) + $post_data['post_category'] = explode( ',', $post_data['catslist'] ); + + if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { + // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked + return edit_post( wp_slash( $post_data ) ); + } else { + // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user. + return wp_create_post_autosave( wp_slash( $post_data ) ); + } +} + +/** + * Redirect to previous page. + * + * @param int $post_id Optional. Post ID. + */ +function redirect_post($post_id = '') { + if ( isset($_POST['save']) || isset($_POST['publish']) ) { + $status = get_post_status( $post_id ); + + if ( isset( $_POST['publish'] ) ) { + switch ( $status ) { + case 'pending': + $message = 8; + break; + case 'future': + $message = 9; + break; + default: + $message = 6; + } + } else { + $message = 'draft' == $status ? 10 : 1; + } + + $location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); + } elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { + $location = add_query_arg( 'message', 2, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { + $location = add_query_arg( 'message', 3, wp_get_referer() ); + $location = explode('#', $location); + $location = $location[0] . '#postcustom'; + } else { + $location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); + } + + /** + * Filters the post redirect destination URL. + * + * @since 2.9.0 + * + * @param string $location The destination URL. + * @param int $post_id The post ID. + */ + wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); + exit; +} diff --git a/backend/wp-admin/includes/revision.php b/backend/wp-admin/includes/revision.php new file mode 100644 index 0000000..5a765cb --- /dev/null +++ b/backend/wp-admin/includes/revision.php @@ -0,0 +1,403 @@ +post_parent !== $post->ID && $compare_from->ID !== $post->ID ) + return false; + if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) + return false; + + if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) { + $temp = $compare_from; + $compare_from = $compare_to; + $compare_to = $temp; + } + + // Add default title if title field is empty + if ( $compare_from && empty( $compare_from->post_title ) ) + $compare_from->post_title = __( '(no title)' ); + if ( empty( $compare_to->post_title ) ) + $compare_to->post_title = __( '(no title)' ); + + $return = array(); + + foreach ( _wp_post_revision_fields( $post ) as $field => $name ) { + /** + * Contextually filter a post revision field. + * + * The dynamic portion of the hook name, `$field`, corresponds to each of the post + * fields of the revision object being iterated over in a foreach statement. + * + * @since 3.6.0 + * + * @param string $compare_from->$field The current revision field to compare to or from. + * @param string $field The current revision field. + * @param WP_Post $compare_from The revision post object to compare to or from. + * @param string null The context of whether the current revision is the old + * or the new one. Values are 'to' or 'from'. + */ + $content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : ''; + + /** This filter is documented in wp-admin/includes/revision.php */ + $content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' ); + + $args = array( + 'show_split_view' => true + ); + + /** + * Filters revisions text diff options. + * + * Filters the options passed to wp_text_diff() when viewing a post revision. + * + * @since 4.1.0 + * + * @param array $args { + * Associative array of options to pass to wp_text_diff(). + * + * @type bool $show_split_view True for split view (two columns), false for + * un-split view (single column). Default true. + * } + * @param string $field The current revision field. + * @param WP_Post $compare_from The revision post to compare from. + * @param WP_Post $compare_to The revision post to compare to. + */ + $args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to ); + + $diff = wp_text_diff( $content_from, $content_to, $args ); + + if ( ! $diff && 'post_title' === $field ) { + // It's a better user experience to still show the Title, even if it didn't change. + // No, you didn't see this. + $diff = ''; + $diff .= ''; + $diff .= ''; + $diff .= '
      ' . esc_html( $compare_from->post_title ) . '' . esc_html( $compare_to->post_title ) . '
      '; + } + + if ( $diff ) { + $return[] = array( + 'id' => $field, + 'name' => $name, + 'diff' => $diff, + ); + } + } + + /** + * Filters the fields displayed in the post revision diff UI. + * + * @since 4.1.0 + * + * @param array $return Revision UI fields. Each item is an array of id, name and diff. + * @param WP_Post $compare_from The revision post to compare from. + * @param WP_Post $compare_to The revision post to compare to. + */ + return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to ); + +} + +/** + * Prepare revisions for JavaScript. + * + * @since 3.6.0 + * + * @param object|int $post The post object. Also accepts a post ID. + * @param int $selected_revision_id The selected revision ID. + * @param int $from Optional. The revision ID to compare from. + * + * @return array An associative array of revision data and related settings. + */ +function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) { + $post = get_post( $post ); + $authors = array(); + $now_gmt = time(); + + $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'check_enabled' => false ) ); + // If revisions are disabled, we only want autosaves and the current post. + if ( ! wp_revisions_enabled( $post ) ) { + foreach ( $revisions as $revision_id => $revision ) { + if ( ! wp_is_post_autosave( $revision ) ) + unset( $revisions[ $revision_id ] ); + } + $revisions = array( $post->ID => $post ) + $revisions; + } + + $show_avatars = get_option( 'show_avatars' ); + + cache_users( wp_list_pluck( $revisions, 'post_author' ) ); + + $can_restore = current_user_can( 'edit_post', $post->ID ); + $current_id = false; + + foreach ( $revisions as $revision ) { + $modified = strtotime( $revision->post_modified ); + $modified_gmt = strtotime( $revision->post_modified_gmt . ' +0000' ); + if ( $can_restore ) { + $restore_link = str_replace( '&', '&', wp_nonce_url( + add_query_arg( + array( 'revision' => $revision->ID, + 'action' => 'restore' ), + admin_url( 'revision.php' ) + ), + "restore-post_{$revision->ID}" + ) ); + } + + if ( ! isset( $authors[ $revision->post_author ] ) ) { + $authors[ $revision->post_author ] = array( + 'id' => (int) $revision->post_author, + 'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '', + 'name' => get_the_author_meta( 'display_name', $revision->post_author ), + ); + } + + $autosave = (bool) wp_is_post_autosave( $revision ); + $current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt; + if ( $current && ! empty( $current_id ) ) { + // If multiple revisions have the same post_modified_gmt, highest ID is current. + if ( $current_id < $revision->ID ) { + $revisions[ $current_id ]['current'] = false; + $current_id = $revision->ID; + } else { + $current = false; + } + } elseif ( $current ) { + $current_id = $revision->ID; + } + + $revisions_data = array( + 'id' => $revision->ID, + 'title' => get_the_title( $post->ID ), + 'author' => $authors[ $revision->post_author ], + 'date' => date_i18n( __( 'M j, Y @ H:i' ), $modified ), + 'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), $modified ), + 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ), + 'autosave' => $autosave, + 'current' => $current, + 'restoreUrl' => $can_restore ? $restore_link : false, + ); + + /** + * Filters the array of revisions used on the revisions screen. + * + * @since 4.4.0 + * + * @param array $revisions_data { + * The bootstrapped data for the revisions screen. + * + * @type int $id Revision ID. + * @type string $title Title for the revision's parent WP_Post object. + * @type int $author Revision post author ID. + * @type string $date Date the revision was modified. + * @type string $dateShort Short-form version of the date the revision was modified. + * @type string $timeAgo GMT-aware amount of time ago the revision was modified. + * @type bool $autosave Whether the revision is an autosave. + * @type bool $current Whether the revision is both not an autosave and the post + * modified date matches the revision modified date (GMT-aware). + * @type bool|false $restoreUrl URL if the revision can be restored, false otherwise. + * } + * @param WP_Post $revision The revision's WP_Post object. + * @param WP_Post $post The revision's parent WP_Post object. + */ + $revisions[ $revision->ID ] = apply_filters( 'wp_prepare_revision_for_js', $revisions_data, $revision, $post ); + } + + /** + * If we only have one revision, the initial revision is missing; This happens + * when we have an autsosave and the user has clicked 'View the Autosave' + */ + if ( 1 === sizeof( $revisions ) ) { + $revisions[ $post->ID ] = array( + 'id' => $post->ID, + 'title' => get_the_title( $post->ID ), + 'author' => $authors[ $post->post_author ], + 'date' => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ), + 'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ), + 'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ), + 'autosave' => false, + 'current' => true, + 'restoreUrl' => false, + ); + $current_id = $post->ID; + } + + /* + * If a post has been saved since the last revision (no revisioned fields + * were changed), we may not have a "current" revision. Mark the latest + * revision as "current". + */ + if ( empty( $current_id ) ) { + if ( $revisions[ $revision->ID ]['autosave'] ) { + $revision = end( $revisions ); + while ( $revision['autosave'] ) { + $revision = prev( $revisions ); + } + $current_id = $revision['id']; + } else { + $current_id = $revision->ID; + } + $revisions[ $current_id ]['current'] = true; + } + + // Now, grab the initial diff. + $compare_two_mode = is_numeric( $from ); + if ( ! $compare_two_mode ) { + $found = array_search( $selected_revision_id, array_keys( $revisions ) ); + if ( $found ) { + $from = array_keys( array_slice( $revisions, $found - 1, 1, true ) ); + $from = reset( $from ); + } else { + $from = 0; + } + } + + $from = absint( $from ); + + $diffs = array( array( + 'id' => $from . ':' . $selected_revision_id, + 'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ), + )); + + return array( + 'postId' => $post->ID, + 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), + 'revisionData' => array_values( $revisions ), + 'to' => $selected_revision_id, + 'from' => $from, + 'diffData' => $diffs, + 'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ), + 'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed + 'revisionIds' => array_keys( $revisions ), + ); +} + +/** + * Print JavaScript templates required for the revisions experience. + * + * @since 4.1.0 + * + * @global WP_Post $post The global `$post` object. + */ +function wp_print_revision_templates() { + global $post; + ?> + + + + + + + + get_charset_collate(); + +/** + * Retrieve the SQL for creating database tables. + * + * @since 3.3.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all. + * @param int $blog_id Optional. The site ID for which to retrieve SQL. Default is the current site ID. + * @return string The SQL needed to create the requested tables. + */ +function wp_get_db_schema( $scope = 'all', $blog_id = null ) { + global $wpdb; + + $charset_collate = $wpdb->get_charset_collate(); + + if ( $blog_id && $blog_id != $wpdb->blogid ) + $old_blog_id = $wpdb->set_blog_id( $blog_id ); + + // Engage multisite if in the middle of turning it on from network.php. + $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ); + + /* + * Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that. + * As of 4.2, however, we moved to utf8mb4, which uses 4 bytes per character. This means that an index which + * used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters. + */ + $max_index_length = 191; + + // Blog specific tables. + $blog_tables = "CREATE TABLE $wpdb->termmeta ( + meta_id bigint(20) unsigned NOT NULL auto_increment, + term_id bigint(20) unsigned NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY term_id (term_id), + KEY meta_key (meta_key($max_index_length)) +) $charset_collate; +CREATE TABLE $wpdb->terms ( + term_id bigint(20) unsigned NOT NULL auto_increment, + name varchar(200) NOT NULL default '', + slug varchar(200) NOT NULL default '', + term_group bigint(10) NOT NULL default 0, + PRIMARY KEY (term_id), + KEY slug (slug($max_index_length)), + KEY name (name($max_index_length)) +) $charset_collate; +CREATE TABLE $wpdb->term_taxonomy ( + term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment, + term_id bigint(20) unsigned NOT NULL default 0, + taxonomy varchar(32) NOT NULL default '', + description longtext NOT NULL, + parent bigint(20) unsigned NOT NULL default 0, + count bigint(20) NOT NULL default 0, + PRIMARY KEY (term_taxonomy_id), + UNIQUE KEY term_id_taxonomy (term_id,taxonomy), + KEY taxonomy (taxonomy) +) $charset_collate; +CREATE TABLE $wpdb->term_relationships ( + object_id bigint(20) unsigned NOT NULL default 0, + term_taxonomy_id bigint(20) unsigned NOT NULL default 0, + term_order int(11) NOT NULL default 0, + PRIMARY KEY (object_id,term_taxonomy_id), + KEY term_taxonomy_id (term_taxonomy_id) +) $charset_collate; +CREATE TABLE $wpdb->commentmeta ( + meta_id bigint(20) unsigned NOT NULL auto_increment, + comment_id bigint(20) unsigned NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY comment_id (comment_id), + KEY meta_key (meta_key($max_index_length)) +) $charset_collate; +CREATE TABLE $wpdb->comments ( + comment_ID bigint(20) unsigned NOT NULL auto_increment, + comment_post_ID bigint(20) unsigned NOT NULL default '0', + comment_author tinytext NOT NULL, + comment_author_email varchar(100) NOT NULL default '', + comment_author_url varchar(200) NOT NULL default '', + comment_author_IP varchar(100) NOT NULL default '', + comment_date datetime NOT NULL default '0000-00-00 00:00:00', + comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', + comment_content text NOT NULL, + comment_karma int(11) NOT NULL default '0', + comment_approved varchar(20) NOT NULL default '1', + comment_agent varchar(255) NOT NULL default '', + comment_type varchar(20) NOT NULL default '', + comment_parent bigint(20) unsigned NOT NULL default '0', + user_id bigint(20) unsigned NOT NULL default '0', + PRIMARY KEY (comment_ID), + KEY comment_post_ID (comment_post_ID), + KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), + KEY comment_date_gmt (comment_date_gmt), + KEY comment_parent (comment_parent), + KEY comment_author_email (comment_author_email(10)) +) $charset_collate; +CREATE TABLE $wpdb->links ( + link_id bigint(20) unsigned NOT NULL auto_increment, + link_url varchar(255) NOT NULL default '', + link_name varchar(255) NOT NULL default '', + link_image varchar(255) NOT NULL default '', + link_target varchar(25) NOT NULL default '', + link_description varchar(255) NOT NULL default '', + link_visible varchar(20) NOT NULL default 'Y', + link_owner bigint(20) unsigned NOT NULL default '1', + link_rating int(11) NOT NULL default '0', + link_updated datetime NOT NULL default '0000-00-00 00:00:00', + link_rel varchar(255) NOT NULL default '', + link_notes mediumtext NOT NULL, + link_rss varchar(255) NOT NULL default '', + PRIMARY KEY (link_id), + KEY link_visible (link_visible) +) $charset_collate; +CREATE TABLE $wpdb->options ( + option_id bigint(20) unsigned NOT NULL auto_increment, + option_name varchar(191) NOT NULL default '', + option_value longtext NOT NULL, + autoload varchar(20) NOT NULL default 'yes', + PRIMARY KEY (option_id), + UNIQUE KEY option_name (option_name) +) $charset_collate; +CREATE TABLE $wpdb->postmeta ( + meta_id bigint(20) unsigned NOT NULL auto_increment, + post_id bigint(20) unsigned NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY post_id (post_id), + KEY meta_key (meta_key($max_index_length)) +) $charset_collate; +CREATE TABLE $wpdb->posts ( + ID bigint(20) unsigned NOT NULL auto_increment, + post_author bigint(20) unsigned NOT NULL default '0', + post_date datetime NOT NULL default '0000-00-00 00:00:00', + post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', + post_content longtext NOT NULL, + post_title text NOT NULL, + post_excerpt text NOT NULL, + post_status varchar(20) NOT NULL default 'publish', + comment_status varchar(20) NOT NULL default 'open', + ping_status varchar(20) NOT NULL default 'open', + post_password varchar(255) NOT NULL default '', + post_name varchar(200) NOT NULL default '', + to_ping text NOT NULL, + pinged text NOT NULL, + post_modified datetime NOT NULL default '0000-00-00 00:00:00', + post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00', + post_content_filtered longtext NOT NULL, + post_parent bigint(20) unsigned NOT NULL default '0', + guid varchar(255) NOT NULL default '', + menu_order int(11) NOT NULL default '0', + post_type varchar(20) NOT NULL default 'post', + post_mime_type varchar(100) NOT NULL default '', + comment_count bigint(20) NOT NULL default '0', + PRIMARY KEY (ID), + KEY post_name (post_name($max_index_length)), + KEY type_status_date (post_type,post_status,post_date,ID), + KEY post_parent (post_parent), + KEY post_author (post_author) +) $charset_collate;\n"; + + // Single site users table. The multisite flavor of the users table is handled below. + $users_single_table = "CREATE TABLE $wpdb->users ( + ID bigint(20) unsigned NOT NULL auto_increment, + user_login varchar(60) NOT NULL default '', + user_pass varchar(255) NOT NULL default '', + user_nicename varchar(50) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + user_url varchar(100) NOT NULL default '', + user_registered datetime NOT NULL default '0000-00-00 00:00:00', + user_activation_key varchar(255) NOT NULL default '', + user_status int(11) NOT NULL default '0', + display_name varchar(250) NOT NULL default '', + PRIMARY KEY (ID), + KEY user_login_key (user_login), + KEY user_nicename (user_nicename), + KEY user_email (user_email) +) $charset_collate;\n"; + + // Multisite users table + $users_multi_table = "CREATE TABLE $wpdb->users ( + ID bigint(20) unsigned NOT NULL auto_increment, + user_login varchar(60) NOT NULL default '', + user_pass varchar(255) NOT NULL default '', + user_nicename varchar(50) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + user_url varchar(100) NOT NULL default '', + user_registered datetime NOT NULL default '0000-00-00 00:00:00', + user_activation_key varchar(255) NOT NULL default '', + user_status int(11) NOT NULL default '0', + display_name varchar(250) NOT NULL default '', + spam tinyint(2) NOT NULL default '0', + deleted tinyint(2) NOT NULL default '0', + PRIMARY KEY (ID), + KEY user_login_key (user_login), + KEY user_nicename (user_nicename), + KEY user_email (user_email) +) $charset_collate;\n"; + + // Usermeta. + $usermeta_table = "CREATE TABLE $wpdb->usermeta ( + umeta_id bigint(20) unsigned NOT NULL auto_increment, + user_id bigint(20) unsigned NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (umeta_id), + KEY user_id (user_id), + KEY meta_key (meta_key($max_index_length)) +) $charset_collate;\n"; + + // Global tables + if ( $is_multisite ) + $global_tables = $users_multi_table . $usermeta_table; + else + $global_tables = $users_single_table . $usermeta_table; + + // Multisite global tables. + $ms_global_tables = "CREATE TABLE $wpdb->blogs ( + blog_id bigint(20) NOT NULL auto_increment, + site_id bigint(20) NOT NULL default '0', + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + registered datetime NOT NULL default '0000-00-00 00:00:00', + last_updated datetime NOT NULL default '0000-00-00 00:00:00', + public tinyint(2) NOT NULL default '1', + archived tinyint(2) NOT NULL default '0', + mature tinyint(2) NOT NULL default '0', + spam tinyint(2) NOT NULL default '0', + deleted tinyint(2) NOT NULL default '0', + lang_id int(11) NOT NULL default '0', + PRIMARY KEY (blog_id), + KEY domain (domain(50),path(5)), + KEY lang_id (lang_id) +) $charset_collate; +CREATE TABLE $wpdb->blog_versions ( + blog_id bigint(20) NOT NULL default '0', + db_version varchar(20) NOT NULL default '', + last_updated datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (blog_id), + KEY db_version (db_version) +) $charset_collate; +CREATE TABLE $wpdb->registration_log ( + ID bigint(20) NOT NULL auto_increment, + email varchar(255) NOT NULL default '', + IP varchar(30) NOT NULL default '', + blog_id bigint(20) NOT NULL default '0', + date_registered datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (ID), + KEY IP (IP) +) $charset_collate; +CREATE TABLE $wpdb->site ( + id bigint(20) NOT NULL auto_increment, + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + PRIMARY KEY (id), + KEY domain (domain(140),path(51)) +) $charset_collate; +CREATE TABLE $wpdb->sitemeta ( + meta_id bigint(20) NOT NULL auto_increment, + site_id bigint(20) NOT NULL default '0', + meta_key varchar(255) default NULL, + meta_value longtext, + PRIMARY KEY (meta_id), + KEY meta_key (meta_key($max_index_length)), + KEY site_id (site_id) +) $charset_collate; +CREATE TABLE $wpdb->signups ( + signup_id bigint(20) NOT NULL auto_increment, + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + title longtext NOT NULL, + user_login varchar(60) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + registered datetime NOT NULL default '0000-00-00 00:00:00', + activated datetime NOT NULL default '0000-00-00 00:00:00', + active tinyint(1) NOT NULL default '0', + activation_key varchar(50) NOT NULL default '', + meta longtext, + PRIMARY KEY (signup_id), + KEY activation_key (activation_key), + KEY user_email (user_email), + KEY user_login_email (user_login,user_email), + KEY domain_path (domain(140),path(51)) +) $charset_collate;"; + + switch ( $scope ) { + case 'blog' : + $queries = $blog_tables; + break; + case 'global' : + $queries = $global_tables; + if ( $is_multisite ) + $queries .= $ms_global_tables; + break; + case 'ms_global' : + $queries = $ms_global_tables; + break; + case 'all' : + default: + $queries = $global_tables . $blog_tables; + if ( $is_multisite ) + $queries .= $ms_global_tables; + break; + } + + if ( isset( $old_blog_id ) ) + $wpdb->set_blog_id( $old_blog_id ); + + return $queries; +} + +// Populate for back compat. +$wp_queries = wp_get_db_schema( 'all' ); + +/** + * Create WordPress options and set the default values. + * + * @since 1.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global int $wp_db_version + * @global int $wp_current_db_version + */ +function populate_options() { + global $wpdb, $wp_db_version, $wp_current_db_version; + + $guessurl = wp_guess_url(); + /** + * Fires before creating WordPress options and populating their default values. + * + * @since 2.6.0 + */ + do_action( 'populate_options' ); + + if ( ini_get('safe_mode') ) { + // Safe mode can break mkdir() so use a flat structure by default. + $uploads_use_yearmonth_folders = 0; + } else { + $uploads_use_yearmonth_folders = 1; + } + + // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. + $stylesheet = $template = WP_DEFAULT_THEME; + $theme = wp_get_theme( WP_DEFAULT_THEME ); + if ( ! $theme->exists() ) { + $theme = WP_Theme::get_core_default_theme(); + } + + // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. + if ( $theme ) { + $stylesheet = $theme->get_stylesheet(); + $template = $theme->get_template(); + } + + $timezone_string = ''; + $gmt_offset = 0; + /* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) + or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php + for all timezone strings supported by PHP. + */ + $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); + if ( is_numeric( $offset_or_tz ) ) + $gmt_offset = $offset_or_tz; + elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) + $timezone_string = $offset_or_tz; + + $options = array( + 'siteurl' => $guessurl, + 'home' => $guessurl, + 'blogname' => __('My Site'), + /* translators: site tagline */ + 'blogdescription' => __('Just another WordPress site'), + 'users_can_register' => 0, + 'admin_email' => 'you@example.com', + /* translators: default start of the week. 0 = Sunday, 1 = Monday */ + 'start_of_week' => _x( '1', 'start of week' ), + 'use_balanceTags' => 0, + 'use_smilies' => 1, + 'require_name_email' => 1, + 'comments_notify' => 1, + 'posts_per_rss' => 10, + 'rss_use_excerpt' => 0, + 'mailserver_url' => 'mail.example.com', + 'mailserver_login' => 'login@example.com', + 'mailserver_pass' => 'password', + 'mailserver_port' => 110, + 'default_category' => 1, + 'default_comment_status' => 'open', + 'default_ping_status' => 'open', + 'default_pingback_flag' => 1, + 'posts_per_page' => 10, + /* translators: default date format, see https://secure.php.net/date */ + 'date_format' => __('F j, Y'), + /* translators: default time format, see https://secure.php.net/date */ + 'time_format' => __('g:i a'), + /* translators: links last updated date format, see https://secure.php.net/date */ + 'links_updated_date_format' => __('F j, Y g:i a'), + 'comment_moderation' => 0, + 'moderation_notify' => 1, + 'permalink_structure' => '', + 'rewrite_rules' => '', + 'hack_file' => 0, + 'blog_charset' => 'UTF-8', + 'moderation_keys' => '', + 'active_plugins' => array(), + 'category_base' => '', + 'ping_sites' => 'http://rpc.pingomatic.com/', + 'comment_max_links' => 2, + 'gmt_offset' => $gmt_offset, + + // 1.5 + 'default_email_category' => 1, + 'recently_edited' => '', + 'template' => $template, + 'stylesheet' => $stylesheet, + 'comment_whitelist' => 1, + 'blacklist_keys' => '', + 'comment_registration' => 0, + 'html_type' => 'text/html', + + // 1.5.1 + 'use_trackback' => 0, + + // 2.0 + 'default_role' => 'subscriber', + 'db_version' => $wp_db_version, + + // 2.0.1 + 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, + 'upload_path' => '', + + // 2.1 + 'blog_public' => '1', + 'default_link_category' => 2, + 'show_on_front' => 'posts', + + // 2.2 + 'tag_base' => '', + + // 2.5 + 'show_avatars' => '1', + 'avatar_rating' => 'G', + 'upload_url_path' => '', + 'thumbnail_size_w' => 150, + 'thumbnail_size_h' => 150, + 'thumbnail_crop' => 1, + 'medium_size_w' => 300, + 'medium_size_h' => 300, + + // 2.6 + 'avatar_default' => 'mystery', + + // 2.7 + 'large_size_w' => 1024, + 'large_size_h' => 1024, + 'image_default_link_type' => 'none', + 'image_default_size' => '', + 'image_default_align' => '', + 'close_comments_for_old_posts' => 0, + 'close_comments_days_old' => 14, + 'thread_comments' => 1, + 'thread_comments_depth' => 5, + 'page_comments' => 0, + 'comments_per_page' => 50, + 'default_comments_page' => 'newest', + 'comment_order' => 'asc', + 'sticky_posts' => array(), + 'widget_categories' => array(), + 'widget_text' => array(), + 'widget_rss' => array(), + 'uninstall_plugins' => array(), + + // 2.8 + 'timezone_string' => $timezone_string, + + // 3.0 + 'page_for_posts' => 0, + 'page_on_front' => 0, + + // 3.1 + 'default_post_format' => 0, + + // 3.5 + 'link_manager_enabled' => 0, + + // 4.3.0 + 'finished_splitting_shared_terms' => 1, + 'site_icon' => 0, + + // 4.4.0 + 'medium_large_size_w' => 768, + 'medium_large_size_h' => 0, + + // 4.9.6 + 'wp_page_for_privacy_policy' => 0, + ); + + // 3.3 + if ( ! is_multisite() ) { + $options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version + ? $wp_current_db_version : $wp_db_version; + } + + // 3.0 multisite + if ( is_multisite() ) { + /* translators: site tagline */ + $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name ); + $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; + } + + // Set autoload to no for these options + $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' ); + + $keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; + $existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); + + $insert = ''; + foreach ( $options as $option => $value ) { + if ( in_array($option, $existing_options) ) + continue; + if ( in_array($option, $fat_options) ) + $autoload = 'no'; + else + $autoload = 'yes'; + + if ( is_array($value) ) + $value = serialize($value); + if ( !empty($insert) ) + $insert .= ', '; + $insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload ); + } + + if ( !empty($insert) ) + $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); + + // In case it is set, but blank, update "home". + if ( !__get_option('home') ) update_option('home', $guessurl); + + // Delete unused options. + $unusedoptions = array( + 'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', + 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', + 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', + 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', + 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', + 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', + 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', + 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', + 'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', + 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', + 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', + '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', + 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', + 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', + 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', + 'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit' + ); + foreach ( $unusedoptions as $option ) + delete_option($option); + + // Delete obsolete magpie stuff. + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'"); + + // Clear expired transients + delete_expired_transients( true ); +} + +/** + * Execute WordPress role creation for the various WordPress versions. + * + * @since 2.0.0 + */ +function populate_roles() { + populate_roles_160(); + populate_roles_210(); + populate_roles_230(); + populate_roles_250(); + populate_roles_260(); + populate_roles_270(); + populate_roles_280(); + populate_roles_300(); +} + +/** + * Create the roles for WordPress 2.0 + * + * @since 2.0.0 + */ +function populate_roles_160() { + // Add roles + + // Dummy gettext calls to get strings in the catalog. + /* translators: user role */ + _x('Administrator', 'User role'); + /* translators: user role */ + _x('Editor', 'User role'); + /* translators: user role */ + _x('Author', 'User role'); + /* translators: user role */ + _x('Contributor', 'User role'); + /* translators: user role */ + _x('Subscriber', 'User role'); + + add_role('administrator', 'Administrator'); + add_role('editor', 'Editor'); + add_role('author', 'Author'); + add_role('contributor', 'Contributor'); + add_role('subscriber', 'Subscriber'); + + // Add caps for Administrator role + $role = get_role('administrator'); + $role->add_cap('switch_themes'); + $role->add_cap('edit_themes'); + $role->add_cap('activate_plugins'); + $role->add_cap('edit_plugins'); + $role->add_cap('edit_users'); + $role->add_cap('edit_files'); + $role->add_cap('manage_options'); + $role->add_cap('moderate_comments'); + $role->add_cap('manage_categories'); + $role->add_cap('manage_links'); + $role->add_cap('upload_files'); + $role->add_cap('import'); + $role->add_cap('unfiltered_html'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_others_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('edit_pages'); + $role->add_cap('read'); + $role->add_cap('level_10'); + $role->add_cap('level_9'); + $role->add_cap('level_8'); + $role->add_cap('level_7'); + $role->add_cap('level_6'); + $role->add_cap('level_5'); + $role->add_cap('level_4'); + $role->add_cap('level_3'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Editor role + $role = get_role('editor'); + $role->add_cap('moderate_comments'); + $role->add_cap('manage_categories'); + $role->add_cap('manage_links'); + $role->add_cap('upload_files'); + $role->add_cap('unfiltered_html'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_others_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('edit_pages'); + $role->add_cap('read'); + $role->add_cap('level_7'); + $role->add_cap('level_6'); + $role->add_cap('level_5'); + $role->add_cap('level_4'); + $role->add_cap('level_3'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Author role + $role = get_role('author'); + $role->add_cap('upload_files'); + $role->add_cap('edit_posts'); + $role->add_cap('edit_published_posts'); + $role->add_cap('publish_posts'); + $role->add_cap('read'); + $role->add_cap('level_2'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Contributor role + $role = get_role('contributor'); + $role->add_cap('edit_posts'); + $role->add_cap('read'); + $role->add_cap('level_1'); + $role->add_cap('level_0'); + + // Add caps for Subscriber role + $role = get_role('subscriber'); + $role->add_cap('read'); + $role->add_cap('level_0'); +} + +/** + * Create and modify WordPress roles for WordPress 2.1. + * + * @since 2.1.0 + */ +function populate_roles_210() { + $roles = array('administrator', 'editor'); + foreach ($roles as $role) { + $role = get_role($role); + if ( empty($role) ) + continue; + + $role->add_cap('edit_others_pages'); + $role->add_cap('edit_published_pages'); + $role->add_cap('publish_pages'); + $role->add_cap('delete_pages'); + $role->add_cap('delete_others_pages'); + $role->add_cap('delete_published_pages'); + $role->add_cap('delete_posts'); + $role->add_cap('delete_others_posts'); + $role->add_cap('delete_published_posts'); + $role->add_cap('delete_private_posts'); + $role->add_cap('edit_private_posts'); + $role->add_cap('read_private_posts'); + $role->add_cap('delete_private_pages'); + $role->add_cap('edit_private_pages'); + $role->add_cap('read_private_pages'); + } + + $role = get_role('administrator'); + if ( ! empty($role) ) { + $role->add_cap('delete_users'); + $role->add_cap('create_users'); + } + + $role = get_role('author'); + if ( ! empty($role) ) { + $role->add_cap('delete_posts'); + $role->add_cap('delete_published_posts'); + } + + $role = get_role('contributor'); + if ( ! empty($role) ) { + $role->add_cap('delete_posts'); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.3. + * + * @since 2.3.0 + */ +function populate_roles_230() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'unfiltered_upload' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.5. + * + * @since 2.5.0 + */ +function populate_roles_250() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'edit_dashboard' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.6. + * + * @since 2.6.0 + */ +function populate_roles_260() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'update_plugins' ); + $role->add_cap( 'delete_plugins' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.7. + * + * @since 2.7.0 + */ +function populate_roles_270() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'install_plugins' ); + $role->add_cap( 'update_themes' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 2.8. + * + * @since 2.8.0 + */ +function populate_roles_280() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'install_themes' ); + } +} + +/** + * Create and modify WordPress roles for WordPress 3.0. + * + * @since 3.0.0 + */ +function populate_roles_300() { + $role = get_role( 'administrator' ); + + if ( !empty( $role ) ) { + $role->add_cap( 'update_core' ); + $role->add_cap( 'list_users' ); + $role->add_cap( 'remove_users' ); + $role->add_cap( 'promote_users' ); + $role->add_cap( 'edit_theme_options' ); + $role->add_cap( 'delete_themes' ); + $role->add_cap( 'export' ); + } +} + +if ( !function_exists( 'install_network' ) ) : +/** + * Install Network. + * + * @since 3.0.0 + */ +function install_network() { + if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) + define( 'WP_INSTALLING_NETWORK', true ); + + dbDelta( wp_get_db_schema( 'global' ) ); +} +endif; + +/** + * Populate network settings. + * + * @since 3.0.0 + * + * @global wpdb $wpdb + * @global object $current_site + * @global int $wp_db_version + * @global WP_Rewrite $wp_rewrite + * + * @param int $network_id ID of network to populate. + * @param string $domain The domain name for the network (eg. "example.com"). + * @param string $email Email address for the network administrator. + * @param string $site_name The name of the network. + * @param string $path Optional. The path to append to the network's domain name. Default '/'. + * @param bool $subdomain_install Optional. Whether the network is a subdomain installation or a subdirectory installation. + * Default false, meaning the network is a subdirectory installation. + * @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful, + * so the error code must be checked) or failure. + */ +function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { + global $wpdb, $current_site, $wp_db_version, $wp_rewrite; + + $errors = new WP_Error(); + if ( '' == $domain ) + $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); + if ( '' == $site_name ) + $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); + + // Check for network collision. + $network_exists = false; + if ( is_multisite() ) { + if ( get_network( (int) $network_id ) ) { + $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); + } + } else { + if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) { + $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); + } + } + + if ( ! is_email( $email ) ) + $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); + + if ( $errors->get_error_code() ) + return $errors; + + // If a user with the provided email does not exist, default to the current user as the new network admin. + $site_user = get_user_by( 'email', $email ); + if ( false === $site_user ) { + $site_user = wp_get_current_user(); + } + + // Set up site tables. + $template = get_option( 'template' ); + $stylesheet = get_option( 'stylesheet' ); + $allowed_themes = array( $stylesheet => true ); + + if ( $template != $stylesheet ) { + $allowed_themes[ $template ] = true; + } + + if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { + $allowed_themes[ WP_DEFAULT_THEME ] = true; + } + + // If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme. + if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) { + if ( $core_default = WP_Theme::get_core_default_theme() ) { + $allowed_themes[ $core_default->get_stylesheet() ] = true; + } + } + + if ( 1 == $network_id ) { + $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) ); + $network_id = $wpdb->insert_id; + } else { + $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) ); + } + + wp_cache_delete( 'networks_have_paths', 'site-options' ); + + if ( !is_multisite() ) { + $site_admins = array( $site_user->user_login ); + $users = get_users( array( + 'fields' => array( 'user_login' ), + 'role' => 'administrator', + ) ); + if ( $users ) { + foreach ( $users as $user ) { + $site_admins[] = $user->user_login; + } + + $site_admins = array_unique( $site_admins ); + } + } else { + $site_admins = get_site_option( 'site_admins' ); + } + + /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ + $welcome_email = __( 'Howdy USERNAME, + +Your new SITE_NAME site has been successfully set up at: +BLOG_URL + +You can log in to the administrator account with the following information: + +Username: USERNAME +Password: PASSWORD +Log in here: BLOG_URLwp-login.php + +We hope you enjoy your new site. Thanks! + +--The Team @ SITE_NAME' ); + + $misc_exts = array( + // Images. + 'jpg', 'jpeg', 'png', 'gif', + // Video. + 'mov', 'avi', 'mpg', '3gp', '3g2', + // "audio". + 'midi', 'mid', + // Miscellaneous. + 'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key', + ); + $audio_exts = wp_get_audio_extensions(); + $video_exts = wp_get_video_extensions(); + $upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) ); + + $sitemeta = array( + 'site_name' => $site_name, + 'admin_email' => $email, + 'admin_user_id' => $site_user->ID, + 'registration' => 'none', + 'upload_filetypes' => implode( ' ', $upload_filetypes ), + 'blog_upload_space' => 100, + 'fileupload_maxk' => 1500, + 'site_admins' => $site_admins, + 'allowedthemes' => $allowed_themes, + 'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ), + 'wpmu_upgrade_site' => $wp_db_version, + 'welcome_email' => $welcome_email, + /* translators: %s: site link */ + 'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ), + // @todo - network admins should have a method of editing the network siteurl (used for cookie hash) + 'siteurl' => get_option( 'siteurl' ) . '/', + 'add_new_users' => '0', + 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', + 'subdomain_install' => intval( $subdomain_install ), + 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', + 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', + 'initial_db_version' => get_option( 'initial_db_version' ), + 'active_sitewide_plugins' => array(), + 'WPLANG' => get_locale(), + ); + if ( ! $subdomain_install ) + $sitemeta['illegal_names'][] = 'blog'; + + /** + * Filters meta for a network on creation. + * + * @since 3.7.0 + * + * @param array $sitemeta Associative array of network meta keys and values to be inserted. + * @param int $network_id ID of network to populate. + */ + $sitemeta = apply_filters( 'populate_network_meta', $sitemeta, $network_id ); + + $insert = ''; + foreach ( $sitemeta as $meta_key => $meta_value ) { + if ( is_array( $meta_value ) ) + $meta_value = serialize( $meta_value ); + if ( !empty( $insert ) ) + $insert .= ', '; + $insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value ); + } + $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); + + /* + * When upgrading from single to multisite, assume the current site will + * become the main site of the network. When using populate_network() + * to create another network in an existing multisite environment, skip + * these steps since the main site of the new network has not yet been + * created. + */ + if ( ! is_multisite() ) { + $current_site = new stdClass; + $current_site->domain = $domain; + $current_site->path = $path; + $current_site->site_name = ucfirst( $domain ); + $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) ); + $current_site->blog_id = $blog_id = $wpdb->insert_id; + update_user_meta( $site_user->ID, 'source_domain', $domain ); + update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); + + if ( $subdomain_install ) + $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + else + $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); + + flush_rewrite_rules(); + + if ( ! $subdomain_install ) + return true; + + $vhost_ok = false; + $errstr = ''; + $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! + $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); + if ( is_wp_error( $page ) ) + $errstr = $page->get_error_message(); + elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) + $vhost_ok = true; + + if ( ! $vhost_ok ) { + $msg = '

      ' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '

      '; + + $msg .= '

      ' . sprintf( + /* translators: %s: host name */ + __( 'The installer attempted to contact a random hostname (%s) on your domain.' ), + '' . $hostname . '' + ); + if ( ! empty ( $errstr ) ) { + /* translators: %s: error message */ + $msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '' . $errstr . '' ); + } + $msg .= '

      '; + + $msg .= '

      ' . sprintf( + /* translators: %s: asterisk symbol (*) */ + __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.' ), + '*' + ) . '

      '; + + $msg .= '

      ' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '

      '; + + return new WP_Error( 'no_wildcard_dns', $msg ); + } + } + + return true; +} diff --git a/backend/wp-admin/includes/screen.php b/backend/wp-admin/includes/screen.php new file mode 100644 index 0000000..c3c4594 --- /dev/null +++ b/backend/wp-admin/includes/screen.php @@ -0,0 +1,233 @@ + UI String + */ +function get_column_headers( $screen ) { + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + static $column_headers = array(); + + if ( ! isset( $column_headers[ $screen->id ] ) ) { + + /** + * Filters the column headers for a list table on a specific screen. + * + * The dynamic portion of the hook name, `$screen->id`, refers to the + * ID of a specific screen. For example, the screen ID for the Posts + * list table is edit-post, so the filter for that screen would be + * manage_edit-post_columns. + * + * @since 3.0.0 + * + * @param array $columns An array of column headers. Default empty. + */ + $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); + } + + return $column_headers[ $screen->id ]; +} + +/** + * Get a list of hidden columns. + * + * @since 2.7.0 + * + * @param string|WP_Screen $screen The screen you want the hidden columns for + * @return array + */ +function get_hidden_columns( $screen ) { + if ( is_string( $screen ) ) { + $screen = convert_to_screen( $screen ); + } + + $hidden = get_user_option( 'manage' . $screen->id . 'columnshidden' ); + + $use_defaults = ! is_array( $hidden ); + + if ( $use_defaults ) { + $hidden = array(); + + /** + * Filters the default list of hidden columns. + * + * @since 4.4.0 + * + * @param array $hidden An array of columns hidden by default. + * @param WP_Screen $screen WP_Screen object of the current screen. + */ + $hidden = apply_filters( 'default_hidden_columns', $hidden, $screen ); + } + + /** + * Filters the list of hidden columns. + * + * @since 4.4.0 + * @since 4.4.1 Added the `use_defaults` parameter. + * + * @param array $hidden An array of hidden columns. + * @param WP_Screen $screen WP_Screen object of the current screen. + * @param bool $use_defaults Whether to show the default columns. + */ + return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults ); +} + +/** + * Prints the meta box preferences for screen meta. + * + * @since 2.7.0 + * + * @global array $wp_meta_boxes + * + * @param WP_Screen $screen + */ +function meta_box_prefs( $screen ) { + global $wp_meta_boxes; + + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + if ( empty($wp_meta_boxes[$screen->id]) ) + return; + + $hidden = get_hidden_meta_boxes($screen); + + foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) { + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { + if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) { + continue; + } + foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { + if ( false == $box || ! $box['title'] ) + continue; + // Submit box cannot be hidden + if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) + continue; + + $widget_title = $box['title']; + + if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { + $widget_title = $box['args']['__widget_basename']; + } + + printf( + '', + esc_attr( $box['id'] ), + checked( in_array( $box['id'], $hidden ), false, false ), + $widget_title + ); + } + } + } +} + +/** + * Get Hidden Meta Boxes + * + * @since 2.7.0 + * + * @param string|WP_Screen $screen Screen identifier + * @return array Hidden Meta Boxes + */ +function get_hidden_meta_boxes( $screen ) { + if ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); + + $use_defaults = ! is_array( $hidden ); + + // Hide slug boxes by default + if ( $use_defaults ) { + $hidden = array(); + if ( 'post' == $screen->base ) { + if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) + $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); + else + $hidden = array( 'slugdiv' ); + } + + /** + * Filters the default list of hidden meta boxes. + * + * @since 3.1.0 + * + * @param array $hidden An array of meta boxes hidden by default. + * @param WP_Screen $screen WP_Screen object of the current screen. + */ + $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); + } + + /** + * Filters the list of hidden meta boxes. + * + * @since 3.3.0 + * + * @param array $hidden An array of hidden meta boxes. + * @param WP_Screen $screen WP_Screen object of the current screen. + * @param bool $use_defaults Whether to show the default meta boxes. + * Default true. + */ + return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults ); +} + +/** + * Register and configure an admin screen option + * + * @since 3.1.0 + * + * @param string $option An option name. + * @param mixed $args Option-dependent arguments. + */ +function add_screen_option( $option, $args = array() ) { + $current_screen = get_current_screen(); + + if ( ! $current_screen ) + return; + + $current_screen->add_option( $option, $args ); +} + +/** + * Get the current screen object + * + * @since 3.1.0 + * + * @global WP_Screen $current_screen + * + * @return WP_Screen|null Current screen object or null when screen not defined. + */ +function get_current_screen() { + global $current_screen; + + if ( ! isset( $current_screen ) ) + return null; + + return $current_screen; +} + +/** + * Set the current screen object + * + * @since 3.0.0 + * + * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, + * or an existing screen object. + */ +function set_current_screen( $hook_name = '' ) { + WP_Screen::get( $hook_name )->set_current_screen(); +} diff --git a/backend/wp-admin/includes/taxonomy.php b/backend/wp-admin/includes/taxonomy.php new file mode 100644 index 0000000..524cf05 --- /dev/null +++ b/backend/wp-admin/includes/taxonomy.php @@ -0,0 +1,290 @@ + $cat_name, 'category_parent' => $parent) ); +} + +/** + * Create categories for the given post. + * + * @since 2.0.0 + * + * @param array $categories List of categories to create. + * @param int $post_id Optional. The post ID. Default empty. + * @return array List of categories to create for the given post. + */ +function wp_create_categories( $categories, $post_id = '' ) { + $cat_ids = array (); + foreach ( $categories as $category ) { + if ( $id = category_exists( $category ) ) { + $cat_ids[] = $id; + } elseif ( $id = wp_create_category( $category ) ) { + $cat_ids[] = $id; + } + } + + if ( $post_id ) + wp_set_post_categories($post_id, $cat_ids); + + return $cat_ids; +} + +/** + * Updates an existing Category or creates a new Category. + * + * @since 2.0.0 + * @since 2.5.0 $wp_error parameter was added. + * @since 3.0.0 The 'taxonomy' argument was added. + * + * @param array $catarr { + * Array of arguments for inserting a new category. + * + * @type int $cat_ID Category ID. A non-zero value updates an existing category. + * Default 0. + * @type string $taxonomy Taxonomy slug. Default 'category'. + * @type string $cat_name Category name. Default empty. + * @type string $category_description Category description. Default empty. + * @type string $category_nicename Category nice (display) name. Default empty. + * @type int|string $category_parent Category parent ID. Default empty. + * } + * @param bool $wp_error Optional. Default false. + * @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure, + * depending on param $wp_error. + */ +function wp_insert_category( $catarr, $wp_error = false ) { + $cat_defaults = array( 'cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '' ); + $catarr = wp_parse_args( $catarr, $cat_defaults ); + + if ( trim( $catarr['cat_name'] ) == '' ) { + if ( ! $wp_error ) { + return 0; + } else { + return new WP_Error( 'cat_name', __( 'You did not enter a category name.' ) ); + } + } + + $catarr['cat_ID'] = (int) $catarr['cat_ID']; + + // Are we updating or creating? + $update = ! empty ( $catarr['cat_ID'] ); + + $name = $catarr['cat_name']; + $description = $catarr['category_description']; + $slug = $catarr['category_nicename']; + $parent = (int) $catarr['category_parent']; + if ( $parent < 0 ) { + $parent = 0; + } + + if ( empty( $parent ) + || ! term_exists( $parent, $catarr['taxonomy'] ) + || ( $catarr['cat_ID'] && term_is_ancestor_of( $catarr['cat_ID'], $parent, $catarr['taxonomy'] ) ) ) { + $parent = 0; + } + + $args = compact('name', 'slug', 'parent', 'description'); + + if ( $update ) { + $catarr['cat_ID'] = wp_update_term( $catarr['cat_ID'], $catarr['taxonomy'], $args ); + } else { + $catarr['cat_ID'] = wp_insert_term( $catarr['cat_name'], $catarr['taxonomy'], $args ); + } + + if ( is_wp_error( $catarr['cat_ID'] ) ) { + if ( $wp_error ) { + return $catarr['cat_ID']; + } else { + return 0; + } + } + return $catarr['cat_ID']['term_id']; +} + +/** + * Aliases wp_insert_category() with minimal args. + * + * If you want to update only some fields of an existing category, call this + * function with only the new values set inside $catarr. + * + * @since 2.0.0 + * + * @param array $catarr The 'cat_ID' value is required. All other keys are optional. + * @return int|bool The ID number of the new or updated Category on success. Zero or FALSE on failure. + */ +function wp_update_category($catarr) { + $cat_ID = (int) $catarr['cat_ID']; + + if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) + return false; + + // First, get all of the original fields + $category = get_term( $cat_ID, 'category', ARRAY_A ); + _make_cat_compat( $category ); + + // Escape data pulled from DB. + $category = wp_slash($category); + + // Merge old and new fields with new fields overwriting old ones. + $catarr = array_merge($category, $catarr); + + return wp_insert_category($catarr); +} + +// +// Tags +// + +/** + * Check whether a post tag with a given name exists. + * + * @since 2.3.0 + * + * @param int|string $tag_name + * @return mixed + */ +function tag_exists($tag_name) { + return term_exists($tag_name, 'post_tag'); +} + +/** + * Add a new tag to the database if it does not already exist. + * + * @since 2.3.0 + * + * @param int|string $tag_name + * @return array|WP_Error + */ +function wp_create_tag($tag_name) { + return wp_create_term( $tag_name, 'post_tag'); +} + +/** + * Get comma-separated list of tags available to edit. + * + * @since 2.3.0 + * + * @param int $post_id + * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. + * @return string|bool|WP_Error + */ +function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { + return get_terms_to_edit( $post_id, $taxonomy); +} + +/** + * Get comma-separated list of terms available to edit for the given post ID. + * + * @since 2.8.0 + * + * @param int $post_id + * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. + * @return string|bool|WP_Error + */ +function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { + $post_id = (int) $post_id; + if ( !$post_id ) + return false; + + $terms = get_object_term_cache( $post_id, $taxonomy ); + if ( false === $terms ) { + $terms = wp_get_object_terms( $post_id, $taxonomy ); + wp_cache_add( $post_id, wp_list_pluck( $terms, 'term_id' ), $taxonomy . '_relationships' ); + } + + if ( ! $terms ) { + return false; + } + if ( is_wp_error( $terms ) ) { + return $terms; + } + $term_names = array(); + foreach ( $terms as $term ) { + $term_names[] = $term->name; + } + + $terms_to_edit = esc_attr( join( ',', $term_names ) ); + + /** + * Filters the comma-separated list of terms available to edit. + * + * @since 2.8.0 + * + * @see get_terms_to_edit() + * + * @param array $terms_to_edit An array of terms. + * @param string $taxonomy The taxonomy for which to retrieve terms. Default 'post_tag'. + */ + $terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy ); + + return $terms_to_edit; +} + +/** + * Add a new term to the database if it does not already exist. + * + * @since 2.8.0 + * + * @param int|string $tag_name + * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. + * @return array|WP_Error + */ +function wp_create_term($tag_name, $taxonomy = 'post_tag') { + if ( $id = term_exists($tag_name, $taxonomy) ) + return $id; + + return wp_insert_term($tag_name, $taxonomy); +} diff --git a/backend/wp-admin/includes/template.php b/backend/wp-admin/includes/template.php new file mode 100644 index 0000000..0c8c863 --- /dev/null +++ b/backend/wp-admin/includes/template.php @@ -0,0 +1,2184 @@ + 'category', + 'descendants_and_self' => $descendants_and_self, + 'selected_cats' => $selected_cats, + 'popular_cats' => $popular_cats, + 'walker' => $walker, + 'checked_ontop' => $checked_ontop + ) ); +} + +/** + * Output an unordered list of checkbox input elements labelled with term names. + * + * Taxonomy-independent version of wp_category_checklist(). + * + * @since 3.0.0 + * @since 4.4.0 Introduced the `$echo` argument. + * + * @param int $post_id Optional. Post ID. Default 0. + * @param array|string $args { + * Optional. Array or string of arguments for generating a terms checklist. Default empty array. + * + * @type int $descendants_and_self ID of the category to output along with its descendants. + * Default 0. + * @type array $selected_cats List of categories to mark as checked. Default false. + * @type array $popular_cats List of categories to receive the "popular-category" class. + * Default false. + * @type object $walker Walker object to use to build the output. + * Default is a Walker_Category_Checklist instance. + * @type string $taxonomy Taxonomy to generate the checklist for. Default 'category'. + * @type bool $checked_ontop Whether to move checked items out of the hierarchy and to + * the top of the list. Default true. + * @type bool $echo Whether to echo the generated markup. False to return the markup instead + * of echoing it. Default true. + * } + */ +function wp_terms_checklist( $post_id = 0, $args = array() ) { + $defaults = array( + 'descendants_and_self' => 0, + 'selected_cats' => false, + 'popular_cats' => false, + 'walker' => null, + 'taxonomy' => 'category', + 'checked_ontop' => true, + 'echo' => true, + ); + + /** + * Filters the taxonomy terms checklist arguments. + * + * @since 3.4.0 + * + * @see wp_terms_checklist() + * + * @param array $args An array of arguments. + * @param int $post_id The post ID. + */ + $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); + + $r = wp_parse_args( $params, $defaults ); + + if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) { + $walker = new Walker_Category_Checklist; + } else { + $walker = $r['walker']; + } + + $taxonomy = $r['taxonomy']; + $descendants_and_self = (int) $r['descendants_and_self']; + + $args = array( 'taxonomy' => $taxonomy ); + + $tax = get_taxonomy( $taxonomy ); + $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); + + $args['list_only'] = ! empty( $r['list_only'] ); + + if ( is_array( $r['selected_cats'] ) ) { + $args['selected_cats'] = $r['selected_cats']; + } elseif ( $post_id ) { + $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); + } else { + $args['selected_cats'] = array(); + } + if ( is_array( $r['popular_cats'] ) ) { + $args['popular_cats'] = $r['popular_cats']; + } else { + $args['popular_cats'] = get_terms( $taxonomy, array( + 'fields' => 'ids', + 'orderby' => 'count', + 'order' => 'DESC', + 'number' => 10, + 'hierarchical' => false + ) ); + } + if ( $descendants_and_self ) { + $categories = (array) get_terms( $taxonomy, array( + 'child_of' => $descendants_and_self, + 'hierarchical' => 0, + 'hide_empty' => 0 + ) ); + $self = get_term( $descendants_and_self, $taxonomy ); + array_unshift( $categories, $self ); + } else { + $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) ); + } + + $output = ''; + + if ( $r['checked_ontop'] ) { + // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) + $checked_categories = array(); + $keys = array_keys( $categories ); + + foreach ( $keys as $k ) { + if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { + $checked_categories[] = $categories[$k]; + unset( $categories[$k] ); + } + } + + // Put checked cats on top + $output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); + } + // Then the rest of them + $output .= call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); + + if ( $r['echo'] ) { + echo $output; + } + + return $output; +} + +/** + * Retrieve a list of the most popular terms from the specified taxonomy. + * + * If the $echo argument is true then the elements for a list of checkbox + * `` elements labelled with the names of the selected terms is output. + * If the $post_ID global isn't empty then the terms associated with that + * post will be marked as checked. + * + * @since 2.5.0 + * + * @param string $taxonomy Taxonomy to retrieve terms from. + * @param int $default Not used. + * @param int $number Number of terms to retrieve. Defaults to 10. + * @param bool $echo Optionally output the list as well. Defaults to true. + * @return array List of popular term IDs. + */ +function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { + $post = get_post(); + + if ( $post && $post->ID ) + $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); + else + $checked_terms = array(); + + $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); + + $tax = get_taxonomy($taxonomy); + + $popular_ids = array(); + foreach ( (array) $terms as $term ) { + $popular_ids[] = $term->term_id; + if ( !$echo ) // Hack for Ajax use. + continue; + $id = "popular-$taxonomy-$term->term_id"; + $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : ''; + ?> + + + + 'name', 'hide_empty' => 0 ) ); + + if ( empty( $categories ) ) + return; + + foreach ( $categories as $category ) { + $cat_id = $category->term_id; + + /** This filter is documented in wp-includes/category-template.php */ + $name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) ); + $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; + echo '"; + } +} + +/** + * Adds hidden fields with the data for use in the inline editor for posts and pages. + * + * @since 2.7.0 + * + * @param WP_Post $post Post object. + */ +function get_inline_data($post) { + $post_type_object = get_post_type_object($post->post_type); + if ( ! current_user_can( 'edit_post', $post->ID ) ) + return; + + $title = esc_textarea( trim( $post->post_title ) ); + + /** This filter is documented in wp-admin/edit-tag-form.php */ + echo ' +'; +} + +/** + * Outputs the in-line comment reply-to form in the Comments list table. + * + * @since 2.7.0 + * + * @global WP_List_Table $wp_list_table + * + * @param int $position + * @param bool $checkbox + * @param string $mode + * @param bool $table_row + */ +function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { + global $wp_list_table; + /** + * Filters the in-line comment reply-to form output in the Comments + * list table. + * + * Returning a non-empty value here will short-circuit display + * of the in-line comment-reply form in the Comments list table, + * echoing the returned value instead. + * + * @since 2.7.0 + * + * @see wp_comment_reply() + * + * @param string $content The reply-to form content. + * @param array $args An array of default args. + */ + $content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) ); + + if ( ! empty($content) ) { + echo $content; + return; + } + + if ( ! $wp_list_table ) { + if ( $mode == 'single' ) { + $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); + } else { + $wp_list_table = _get_list_table('WP_Comments_List_Table'); + } + } + +?> +
      + +
      + + + +
      + + + + + + + ' . _x( 'Name', 'meta name' ) . ' + ' . __( 'Value' ) . ' + + + + + +'; //TBODY needed for list-manipulation JS + return; + } + $count = 0; +?> + + + + + + + + + + +
      + + $entry['meta_id'] = (int) $entry['meta_id']; + + $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); + + $r .= "\n\t"; + $r .= "\n\t\t"; + + $r .= "\n\t\t
      "; + $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); + $r .= "\n\t\t"; + $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); + $r .= "
      "; + $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); + $r .= ""; + + $r .= "\n\t\t\n\t"; + return $r; +} + +/** + * Prints the form in the Custom Fields meta box. + * + * @since 1.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param WP_Post $post Optional. The post being edited. + */ +function meta_form( $post = null ) { + global $wpdb; + $post = get_post( $post ); + + /** + * Filters values for the meta key dropdown in the Custom Fields meta box. + * + * Returning a non-null value will effectively short-circuit and avoid a + * potentially expensive query against postmeta. + * + * @since 4.4.0 + * + * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null. + * @param WP_Post $post The current post object. + */ + $keys = apply_filters( 'postmeta_form_keys', null, $post ); + + if ( null === $keys ) { + /** + * Filters the number of custom fields to retrieve for the drop-down + * in the Custom Fields meta box. + * + * @since 2.1.0 + * + * @param int $limit Number of custom fields to retrieve. Default 30. + */ + $limit = apply_filters( 'postmeta_form_limit', 30 ); + $sql = "SELECT DISTINCT meta_key + FROM $wpdb->postmeta + WHERE meta_key NOT BETWEEN '_' AND '_z' + HAVING meta_key NOT LIKE %s + ORDER BY meta_key + LIMIT %d"; + $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); + } + + if ( $keys ) { + natcasesort( $keys ); + $meta_key_input_id = 'metakeyselect'; + } else { + $meta_key_input_id = 'metakeyinput'; + } +?> +

      + + + + + + + + + + + + + + + + +
      + + + + + + + + + +
      +
      + 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?> +
      + +
      +post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); + + $tab_index_attribute = ''; + if ( (int) $tab_index > 0 ) + $tab_index_attribute = " tabindex=\"$tab_index\""; + + // todo: Remove this? + // echo '
      '; + + $time_adj = current_time('timestamp'); + $post_date = ($for_post) ? $post->post_date : get_comment()->comment_date; + $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); + $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); + $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); + $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); + $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj ); + $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj ); + + $cur_jj = gmdate( 'd', $time_adj ); + $cur_mm = gmdate( 'm', $time_adj ); + $cur_aa = gmdate( 'Y', $time_adj ); + $cur_hh = gmdate( 'H', $time_adj ); + $cur_mn = gmdate( 'i', $time_adj ); + + $month = ''; + + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; + + echo '
      '; + /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ + printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); + + echo '
      '; + + if ( $multi ) return; + + echo "\n\n"; + $map = array( + 'mm' => array( $mm, $cur_mm ), + 'jj' => array( $jj, $cur_jj ), + 'aa' => array( $aa, $cur_aa ), + 'hh' => array( $hh, $cur_hh ), + 'mn' => array( $mn, $cur_mn ), + ); + foreach ( $map as $timeunit => $value ) { + list( $unit, $curr ) = $value; + + echo '' . "\n"; + $cur_timeunit = 'cur_' . $timeunit; + echo '' . "\n"; + } +?> + +

      + + +

      +" . esc_html( $template ) . ""; + } +} + +/** + * Print out option HTML elements for the page parents drop-down. + * + * @since 1.5.0 + * @since 4.4.0 `$post` argument was added. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $default Optional. The default page ID to be pre-selected. Default 0. + * @param int $parent Optional. The parent page ID. Default 0. + * @param int $level Optional. Page depth level. Default 0. + * @param int|WP_Post $post Post ID or WP_Post object. + * + * @return null|false Boolean False if page has no children, otherwise print out html elements + */ +function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) { + global $wpdb; + $post = get_post( $post ); + $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); + + if ( $items ) { + foreach ( $items as $item ) { + // A page cannot be its own parent. + if ( $post && $post->ID && $item->ID == $post->ID ) + continue; + + $pad = str_repeat( ' ', $level * 3 ); + $selected = selected( $default, $item->ID, false ); + + echo "\n\t"; + parent_dropdown( $default, $item->ID, $level +1 ); + } + } else { + return false; + } +} + +/** + * Print out option html elements for role selectors. + * + * @since 2.1.0 + * + * @param string $selected Slug for the role that should be already selected. + */ +function wp_dropdown_roles( $selected = '' ) { + $r = ''; + + $editable_roles = array_reverse( get_editable_roles() ); + + foreach ( $editable_roles as $role => $details ) { + $name = translate_user_role($details['name'] ); + // preselect specified role + if ( $selected == $role ) { + $r .= "\n\t"; + } else { + $r .= "\n\t"; + } + } + + echo $r; +} + +/** + * Outputs the form used by the importers to accept the data to be imported + * + * @since 2.0.0 + * + * @param string $action The action attribute for the form. + */ +function wp_import_upload_form( $action ) { + + /** + * Filters the maximum allowed upload size for import files. + * + * @since 2.3.0 + * + * @see wp_max_upload_size() + * + * @param int $max_upload_size Allowed upload size. Default 1 MB. + */ + $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); + $size = size_format( $bytes ); + $upload_dir = wp_upload_dir(); + if ( ! empty( $upload_dir['error'] ) ) : + ?>

      +

      +
      +

      + () + + + +

      + +
      +id ) ) { + return; + } + + $page = $screen->id; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { + foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { + if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) + continue; + + // If a core box was previously added or removed by a plugin, don't add. + if ( 'core' == $priority ) { + // If core box previously deleted, don't add + if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) + return; + + /* + * If box was added with default priority, give it core priority to + * maintain sort order. + */ + if ( 'default' == $a_priority ) { + $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; + unset($wp_meta_boxes[$page][$a_context]['default'][$id]); + } + return; + } + // If no priority given and id already present, use existing priority. + if ( empty($priority) ) { + $priority = $a_priority; + /* + * Else, if we're adding to the sorted priority, we don't know the title + * or callback. Grab them from the previously added context/priority. + */ + } elseif ( 'sorted' == $priority ) { + $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; + $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; + $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; + } + // An id can be in only one priority and one context. + if ( $priority != $a_priority || $context != $a_context ) + unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); + } + } + + if ( empty($priority) ) + $priority = 'low'; + + if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) + $wp_meta_boxes[$page][$context][$priority] = array(); + + $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); +} + +/** + * Meta-Box template function + * + * @since 2.5.0 + * + * @global array $wp_meta_boxes + * + * @staticvar bool $already_sorted + * + * @param string|WP_Screen $screen Screen identifier. If you have used add_menu_page() or + * add_submenu_page() to create a new screen (and hence screen_id) + * make sure your menu slug conforms to the limits of sanitize_key() + * otherwise the 'screen' menu may not correctly render on your page. + * @param string $context box context + * @param mixed $object gets passed to the box callback function as first parameter + * @return int number of meta_boxes + */ +function do_meta_boxes( $screen, $context, $object ) { + global $wp_meta_boxes; + static $already_sorted = false; + + if ( empty( $screen ) ) + $screen = get_current_screen(); + elseif ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $page = $screen->id; + + $hidden = get_hidden_meta_boxes( $screen ); + + printf('
      ', htmlspecialchars($context)); + + // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose + if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { + foreach ( $sorted as $box_context => $ids ) { + foreach ( explode( ',', $ids ) as $id ) { + if ( $id && 'dashboard_browser_nag' !== $id ) { + add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); + } + } + } + } + + $already_sorted = true; + + $i = 0; + + if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { + foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) { + foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { + if ( false == $box || ! $box['title'] ) + continue; + $i++; + $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; + echo '
      ' . "\n"; + if ( 'dashboard_browser_nag' != $box['id'] ) { + $widget_title = $box[ 'title' ]; + + if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) { + $widget_title = $box[ 'args' ][ '__widget_basename' ]; + // Do not pass this parameter to the user callback function. + unset( $box[ 'args' ][ '__widget_basename' ] ); + } + + echo ''; + } + echo "

      {$box['title']}

      \n"; + echo '
      ' . "\n"; + call_user_func($box['callback'], $object, $box); + echo "
      \n"; + echo "
      \n"; + } + } + } + } + + echo "
      "; + + return $i; + +} + +/** + * Removes a meta box from one or more screens. + * + * @since 2.6.0 + * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. + * + * @global array $wp_meta_boxes + * + * @param string $id Meta box ID (used in the 'id' attribute for the meta box). + * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a + * post type, 'link', or 'comment'). Accepts a single screen ID, + * WP_Screen object, or array of screen IDs. + * @param string $context The context within the screen where the box is set to display. + * Contexts vary from screen to screen. Post edit screen contexts + * include 'normal', 'side', and 'advanced'. Comments screen contexts + * include 'normal' and 'side'. Menus meta boxes (accordion sections) + * all use the 'side' context. + */ +function remove_meta_box( $id, $screen, $context ) { + global $wp_meta_boxes; + + if ( empty( $screen ) ) { + $screen = get_current_screen(); + } elseif ( is_string( $screen ) ) { + $screen = convert_to_screen( $screen ); + } elseif ( is_array( $screen ) ) { + foreach ( $screen as $single_screen ) { + remove_meta_box( $id, $single_screen, $context ); + } + } + + if ( ! isset( $screen->id ) ) { + return; + } + + $page = $screen->id; + + if ( !isset($wp_meta_boxes) ) + $wp_meta_boxes = array(); + if ( !isset($wp_meta_boxes[$page]) ) + $wp_meta_boxes[$page] = array(); + if ( !isset($wp_meta_boxes[$page][$context]) ) + $wp_meta_boxes[$page][$context] = array(); + + foreach ( array('high', 'core', 'default', 'low') as $priority ) + $wp_meta_boxes[$page][$context][$priority][$id] = false; +} + +/** + * Meta Box Accordion Template Function + * + * Largely made up of abstracted code from do_meta_boxes(), this + * function serves to build meta boxes as list items for display as + * a collapsible accordion. + * + * @since 3.6.0 + * + * @uses global $wp_meta_boxes Used to retrieve registered meta boxes. + * + * @param string|object $screen The screen identifier. + * @param string $context The meta box context. + * @param mixed $object gets passed to the section callback function as first parameter. + * @return int number of meta boxes as accordion sections. + */ +function do_accordion_sections( $screen, $context, $object ) { + global $wp_meta_boxes; + + wp_enqueue_script( 'accordion' ); + + if ( empty( $screen ) ) + $screen = get_current_screen(); + elseif ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $page = $screen->id; + + $hidden = get_hidden_meta_boxes( $screen ); + ?> +
      +
        + +
      • +

        + + +

        +
        +
        + +
        +
        +
      • + +
      +
      + $id, 'title' => $title, 'callback' => $callback); +} + +/** + * Add a new field to a section of a settings page + * + * Part of the Settings API. Use this to define a settings field that will show + * as part of a settings section inside a settings page. The fields are shown using + * do_settings_fields() in do_settings-sections() + * + * The $callback argument should be the name of a function that echoes out the + * html input tags for this setting field. Use get_option() to retrieve existing + * values to show. + * + * @since 2.7.0 + * @since 4.2.0 The `$class` argument was added. + * + * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections + * + * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags. + * @param string $title Formatted title of the field. Shown as the label for the field + * during output. + * @param callable $callback Function that fills the field with the desired form inputs. The + * function should echo its output. + * @param string $page The slug-name of the settings page on which to show the section + * (general, reading, writing, ...). + * @param string $section Optional. The slug-name of the section of the settings page + * in which to show the box. Default 'default'. + * @param array $args { + * Optional. Extra arguments used when outputting the field. + * + * @type string $label_for When supplied, the setting title will be wrapped + * in a `
      + + +

      + + + + + +

      + ' . esc_html( $_GET['search'] ) . '' ); ?> +

      + + +
      + + + + + +
      + + + + + +
      + +
      + +
        + + countries->get_base_country(); + if ( 'US' === $country + && false !== strpos( + $addon->link, 'woocommerce.com/products/usps-shipping-method' + ) + ) { + continue; + } + if ( 'CA' === $country + && false !== strpos( + $addon->link, 'woocommerce.com/products/canada-post-shipping-method' + ) + ) { + continue; + } + } + ?> +
      • + + image ) ) : ?> + + +

        title ); ?>

        + + price ); ?> +

        excerpt ); ?>

        +
        +
      • + +
      + + +

      WooCommerce Extensions Catalog', 'woocommerce' ), 'https://woocommerce.com/product-category/woocommerce-extensions/' ); ?>

      + + + +
      + Storefront +

      +

      official WooCommerce theme.', 'woocommerce' ); ?>

      +

      free WordPress theme offering deep integration with WooCommerce and many of the most popular customer-facing extensions.', 'woocommerce' ); ?>

      +

      + + +

      +
      + +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-product-export.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-product-export.php new file mode 100644 index 0000000..ee67301 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-product-export.php @@ -0,0 +1,79 @@ + +
      +

      + +
      +
      +
      + +

      +

      +
      +
      + + + + + + + + + + + + + + + + +
      + + + +
      + + + +
      + + + + +
      + +
      +
      + +
      +
      +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-reports.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-reports.php new file mode 100644 index 0000000..a5ef713 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-reports.php @@ -0,0 +1,73 @@ + +
      + + 1 ) { + ?> +
        +
      • + $report ) { + $link = '' . $report['title'] . ''; + + $links[] = $link; + } + + echo implode( ' |
      • ', $links ); + + ?> +
      • +
      +
      + ' . esc_html( $report['title'] ) . ''; + } else { + echo '

      ' . esc_html( $report['title'] ) . '

      '; + } + + if ( $report['description'] ) { + echo '

      ' . $report['description'] . '

      '; + } + + if ( $report['callback'] && ( is_callable( $report['callback'] ) ) ) { + call_user_func( $report['callback'], $current_report ); + } + } + ?> +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-logs-db.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-logs-db.php new file mode 100644 index 0000000..38013c0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-logs-db.php @@ -0,0 +1,31 @@ + +
      + search_box( __( 'Search logs', 'woocommerce' ), 'log' ); ?> + display(); ?> + + + + + + +
      + + +
      +
      +

      + + + + +

      +
      +
      +
      + + +
      +
      +
      +
      +
      +
      +
      + +

      + diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php new file mode 100644 index 0000000..a1ed0b3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php @@ -0,0 +1,876 @@ +get_environment_info(); +$database = $system_status->get_database_info(); +$post_type_counts = $system_status->get_post_type_counts(); +$active_plugins = $system_status->get_active_plugins(); +$theme = $system_status->get_theme_info(); +$security = $system_status->get_security_info(); +$settings = $system_status->get_settings(); +$pages = $system_status->get_pages(); +$plugin_updates = new WC_Plugin_Updates(); +$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor' ); +?> +
      +

      + +

      +

      + + + + +

      +
      + +

      + +

      + +
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      :
      :
      :
      : + ' . esc_html( $environment['log_directory'] ) . ' '; + } else { + /* Translators: %1$s: Log directory, %2$s: Log directory constant */ + echo ' ' . sprintf( esc_html__( 'To allow logging, make %1$s writable or define a custom %2$s.', 'woocommerce' ), '' . esc_html( $environment['log_directory'] ) . '', 'WC_LOG_DIR' ) . ''; + } + ?> +
      : + ' . sprintf( esc_html__( '%1$s - There is a newer version of WordPress available (%2$s)', 'woocommerce' ), esc_html( $environment['wp_version'] ), esc_html( $latest_version ) ) . ''; + } else { + echo '' . esc_html( $environment['wp_version'] ) . ''; + } + ?> +
      :' : '–'; ?>
      : + ' . sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'woocommerce' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '' . esc_html__( 'Increasing memory allocated to PHP', 'woocommerce' ) . '' ) . ''; + } else { + echo '' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . ''; + } + ?> +
      : + + + + + +
      : + + + + + +
      :
      : + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + } else { + $css_class = 'error'; + $icon = ''; + } + ?> + + + + + + + +

      :
      : + =' ) ) { + echo '' . esc_html( $environment['php_version'] ) . ''; + } else { + $update_link = ' ' . esc_html__( 'How to update your PHP version', 'woocommerce' ) . ''; + $class = 'error'; + + if ( version_compare( $environment['php_version'], '5.4', '<' ) ) { + $notice = ' ' . __( 'WooCommerce will run under this version of PHP, however, some features such as geolocation are not compatible. Support for this version will be dropped in the next major release. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link; + } elseif ( version_compare( $environment['php_version'], '5.6', '<' ) ) { + $notice = ' ' . __( 'WooCommerce will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link; + } elseif ( version_compare( $environment['php_version'], '7.2', '<' ) ) { + $notice = __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'woocommerce' ) . $update_link; + $class = 'recommendation'; + } + + echo '' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . ''; + } + ?> +
      :
      :
      :
      :
      :' : '–'; ?>
      : + ' . sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['mysql_version_string'] ), '' . esc_html__( 'WordPress requirements', 'woocommerce' ) . '' ) . ''; + } else { + echo '' . esc_html( $environment['mysql_version_string'] ) . ''; + } + ?> +
      :
      : + ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'woocommerce' ), esc_html( $environment['default_timezone'] ) ) . ''; + } else { + echo ''; + } + ?> +
      : + '; + } else { + echo ' ' . esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s classname and link. */ + echo ' ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'woocommerce' ), 'SoapClient' ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s: classname and link. */ + echo ' ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'woocommerce' ), 'DOMDocument' ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s: classname and link. */ + echo ' ' . sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce' ), 'gzopen' ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s: classname and link. */ + echo ' ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce' ), 'mbstring' ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s: function name. */ + echo ' ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . ''; + } + ?> +
      : + '; + } else { + /* Translators: %s: function name. */ + echo ' ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . ''; + } + ?> +
      : + + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $table_data ) { ?> + + + + + + + + $table_data ) { ?> + + + + + + + +

      :
        + 20 ) { + /* Translators: %1$s: Database prefix, %2$s: Docs link. */ + echo ' ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '' . esc_html__( 'How to update your database table prefix', 'woocommerce' ) . '' ) . ''; + } else { + echo '' . esc_html( $database['database_prefix'] ) . ''; + } + ?> +
      : + ' . wp_kses_post( __( 'MaxMind GeoIP database requires at least PHP 5.4.', 'woocommerce' ) ) . ''; + } elseif ( file_exists( $database['maxmind_geoip_database'] ) ) { + echo ' ' . esc_html( $database['maxmind_geoip_database'] ) . ' '; + } else { + /* Translators: %1$s: Library url, %2$s: install path. */ + printf( ' ' . sprintf( esc_html__( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "MaxMind DB binary, gzipped" file next to "GeoLite2 Country". Please remember to uncompress GeoLite2-Country_xxxxxxxx.tar.gz and upload the GeoLite2-Country.mmdb file only.', 'woocommerce' ), 'https://dev.maxmind.com/geoip/geoip2/geolite2/', '' . esc_html( $database['maxmind_geoip_database'] ) . '' ) . '', esc_html( WC_LOG_DIR ) ); + } + ?> +
       
       
       
        + ' . esc_html__( 'Table does not exist', 'woocommerce' ) . ''; + } else { + /* Translators: %1$f: Table size, %2$f: Index size. */ + printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), esc_html( wc_format_decimal( $table_data['data'], 2 ) ), esc_html( wc_format_decimal( $table_data['index'], 2 ) ) ); + } + ?> +
        + +
      + + + + + + + + + + + + + + + +

      type ); ?> count ); ?>
      + + + + + + + + + + + + + + + + + + +

      : + + + + + Learn more about HTTPS and SSL Certificates.', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/' ) ); + ?> + + +
      + + + + + +
      + + + + + + + + ' . $plugin_name . ''; + } + + $version_string = ''; + $network_string = ''; + if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) { + if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) { + /* translators: %s: plugin latest version */ + $version_string = ' – ' . sprintf( esc_html__( '%s is available', 'woocommerce' ), $plugin['version_latest'] ) . ''; + } + + if ( false !== $plugin['network_activated'] ) { + $network_string = ' – ' . esc_html__( 'Network enabled', 'woocommerce' ) . ''; + } + } + $untested_string = ''; + if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) { + $untested_string = ' – ' . esc_html__( 'Not tested with the active version of WooCommerce', 'woocommerce' ) . ''; + } + ?> + + + + + + + +

      ()

        + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      :' : ''; ?>
      :' : ''; ?>
      ()
      + + $name ) { + $display_terms[] = strtolower( $name ) . ' (' . $slug . ')'; + } + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?> +
      + + $name ) { + $display_terms[] = strtolower( $name ) . ' (' . $slug . ')'; + } + echo implode( ', ', array_map( 'esc_html', $display_terms ) ); + ?> +
      + + + + + + + + ' . esc_html( $page['page_name'] ) . ''; + } else { + $page_name = esc_html( $page['page_name'] ); + } + + echo ''; + /* Translators: %s: page name. */ + echo ''; + } + ?> + +

      ' . wp_kses_post( $page_name ) . ':' . wc_help_tip( sprintf( esc_html__( 'The URL of your %s page (along with the Page ID).', 'woocommerce' ), $page_name ) ) . ''; + + // Page ID check. + if ( ! $page['page_set'] ) { + echo ' ' . esc_html__( 'Page not set', 'woocommerce' ) . ''; + $error = true; + } elseif ( ! $page['page_exists'] ) { + echo ' ' . esc_html__( 'Page ID is set, but the page does not exist', 'woocommerce' ) . ''; + $error = true; + } elseif ( ! $page['page_visible'] ) { + /* Translators: %s: docs link. */ + echo ' ' . wp_kses_post( sprintf( __( 'Page visibility should be public', 'woocommerce' ), 'https://codex.wordpress.org/Content_Visibility' ) ) . ''; + $error = true; + } else { + // Shortcode check. + if ( $page['shortcode_required'] ) { + if ( ! $page['shortcode_present'] ) { + echo ' ' . sprintf( esc_html__( 'Page does not contain the shortcode.', 'woocommerce' ), esc_html( $page['shortcode'] ) ) . ''; + $error = true; + } + } + } + + if ( ! $error ) { + echo '#' . absint( $page['page_id'] ) . ' - ' . esc_html( str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) ) . ''; + } + + echo '
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      :
      : + ' . sprintf( esc_html__( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . ''; + } + ?> +
      :
      : + '; + } else { + /* Translators: %s docs link. */ + echo ' – ' . wp_kses_post( sprintf( __( 'If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme', 'woocommerce' ), 'https://codex.wordpress.org/Child_Themes' ) ); + } + ?> +
      :
      : + ' . sprintf( esc_html__( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . ''; + } + ?> +
      :
      : + ' . esc_html__( 'Not declared', 'woocommerce' ) . ''; + } else { + echo ''; + } + ?> +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

      : 
        + ' . esc_html( $override['file'] ) . '', + '' . esc_html( $current_version ) . '', + esc_html( $override['core_version'] ) + ); + } else { + echo esc_html( $override['file'] ); + } + if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) { + echo ', '; + } + echo '
      '; + } + ?> +
      : 
      :  + + + + + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-tools.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-tools.php new file mode 100644 index 0000000..a1c5f72 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status-tools.php @@ -0,0 +1,28 @@ + +
      + + + + $tool ) : ?> + + + + + + +
      + +

      +
      + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status.php new file mode 100644 index 0000000..bc03988 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-page-status.php @@ -0,0 +1,48 @@ + __( 'System status', 'woocommerce' ), + 'tools' => __( 'Tools', 'woocommerce' ), + 'logs' => __( 'Logs', 'woocommerce' ), +); +$tabs = apply_filters( 'woocommerce_admin_status_tabs', $tabs ); +?> +
      + +

      + +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php new file mode 100644 index 0000000..16d5502 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-admin-settings.php @@ -0,0 +1,49 @@ + +
      +
      + +

      + +

      + + + + +

      +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php new file mode 100644 index 0000000..4affb34 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-bulk-edit-product.php @@ -0,0 +1,313 @@ + + +
      +
      + +

      + + + +
      + + +
      + +
      + + +
      + + + + + + + + +
      + + +
      + + + +
      + + +
      + + + + + + + + + + + + +
      + + +
      + + + + + + + + + + + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-email-template-preview.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-email-template-preview.php new file mode 100644 index 0000000..d2878ed --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-email-template-preview.php @@ -0,0 +1,18 @@ + + +

      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet diam a facilisis eleifend. Cras ac justo felis. Mauris faucibus, orci eu blandit fermentum, lorem nibh sollicitudin mi, sit amet interdum metus urna ut lacus.

      + +

      Phasellus quis varius augue. Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo.

      + +

      Lorem ipsum dolor

      + +

      Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo.

      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-custom.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-custom.php new file mode 100644 index 0000000..a0ef2a9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-custom.php @@ -0,0 +1,14 @@ + +
      + + +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-install.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-install.php new file mode 100644 index 0000000..0f735cc --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-install.php @@ -0,0 +1,14 @@ + +
      +

      Welcome to WooCommerce – You‘re almost ready to start selling :)', 'woocommerce' ); ?>

      +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-legacy-shipping.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-legacy-shipping.php new file mode 100644 index 0000000..19bf819 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-legacy-shipping.php @@ -0,0 +1,22 @@ + +
      + + +

      +

      They will be removed in future versions of WooCommerce. We recommend disabling these and setting up new rates within shipping zones as soon as possible.', 'woocommerce' ); ?>

      + +

      + + + + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-no-shipping-methods.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-no-shipping-methods.php new file mode 100644 index 0000000..2c0e95b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-no-shipping-methods.php @@ -0,0 +1,21 @@ + +
      + + +

      +

      +

      + +

      + + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-regenerating-thumbnails.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-regenerating-thumbnails.php new file mode 100644 index 0000000..52575c4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-regenerating-thumbnails.php @@ -0,0 +1,13 @@ + +
      + + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-secure-connection.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-secure-connection.php new file mode 100644 index 0000000..5cc99d1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-secure-connection.php @@ -0,0 +1,23 @@ + +
      + + +

      + Learn more here.', 'woocommerce' ), + 'https://docs.woocommerce.com/document/ssl-and-https/' + ) ); + ?> +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-simplify-commerce.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-simplify-commerce.php new file mode 100644 index 0000000..8664b6b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-simplify-commerce.php @@ -0,0 +1,24 @@ + +
      + + +

      The Simplify Commerce payment gateway is deprecated – Please install our new free Simplify Commerce plugin from WordPress.org. Simplify Commerce will be removed from WooCommerce core in a future update.', 'woocommerce' ); ?>

      + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-template-check.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-template-check.php new file mode 100644 index 0000000..e326a75 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-template-check.php @@ -0,0 +1,17 @@ + +
      + + +

      Your theme (%1$s) contains outdated copies of some WooCommerce template files. These files may need updating to ensure they are compatible with the current version of WooCommerce. You can see which files are affected from the system status page. If in doubt, check with the author of the theme.', 'woocommerce' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) ); ?>

      +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-theme-support.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-theme-support.php new file mode 100644 index 0000000..92bac9e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-theme-support.php @@ -0,0 +1,19 @@ + +
      + + +

      Your theme does not declare WooCommerce support – Please read our integration guide or check out our Storefront theme which is totally free to download and designed specifically for use with WooCommerce.', 'woocommerce' ), esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/', 'theme-compatibility' ) ), esc_url( self_admin_url( 'theme-install.php?theme=storefront' ) ) ); ?>

      +

      + + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-update.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-update.php new file mode 100644 index 0000000..f41c167 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-update.php @@ -0,0 +1,19 @@ + +
      +

      +

      +
      + diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updated.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updated.php new file mode 100644 index 0000000..03d81f7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updated.php @@ -0,0 +1,15 @@ + +
      + + +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updating.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updating.php new file mode 100644 index 0000000..b77d867 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-notice-updating.php @@ -0,0 +1,13 @@ + +
      +

      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-quick-edit-product.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-quick-edit-product.php new file mode 100644 index 0000000..91d4e98 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-quick-edit-product.php @@ -0,0 +1,214 @@ + + +
      +
      + +

      + + + + + + +
      + + + +
      + +
      + +
      +
      + + + +
      + +
      + + + +
      + + + +
      + + + +
      +
      + + + + + + +
      +
      + + +
      + + +
      + + + + +
      + +
      + + +
      + + +
      + +
      + + + + +
      + + + +
      + + + + + + + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/views/html-report-by-date.php b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-report-by-date.php new file mode 100644 index 0000000..297e5b4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/views/html-report-by-date.php @@ -0,0 +1,102 @@ + + +
      +
      + + +

      + +

      + +

      + + +
      + get_export_button(); ?> +
        + $name ) { + echo '
      • ' . esc_html( $name ) . '
      • '; + } + ?> +
      • + +
        +
        + $value ) { + if ( is_array( $value ) ) { + foreach ( $value as $v ) { + echo ''; + } + } else { + echo ''; + } + } + ?> + + + + + + +
        +
        +
      • +
      +
      + +
      +
      + get_chart_legend() ) : ?> +
        + + +
      • data-tip=""> + +
      • + + +
      + +
        + get_chart_widgets() as $widget ) : ?> +
      • + +

        + + +
      • + +
      +
      +
      + get_main_chart(); ?> +
      +
      + +
      + get_main_chart(); ?> +
      + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/wc-admin-functions.php b/backend/wp-content/plugins/woocommerce/includes/admin/wc-admin-functions.php new file mode 100644 index 0000000..c8f8978 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/wc-admin-functions.php @@ -0,0 +1,336 @@ +attribute_name ); + } + } + + return apply_filters( 'woocommerce_screen_ids', $screen_ids ); +} + +/** + * Create a page and store the ID in an option. + * + * @param mixed $slug Slug for the new page + * @param string $option Option name to store the page's ID + * @param string $page_title (default: '') Title for the new page + * @param string $page_content (default: '') Content for the new page + * @param int $post_parent (default: 0) Parent for the new page + * @return int page ID + */ +function wc_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { + global $wpdb; + + $option_value = get_option( $option ); + + if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { + if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { + // Valid page is already in place + return $page_object->ID; + } + } + + if ( strlen( $page_content ) > 0 ) { + // Search for an existing page with the specified page content (typically a shortcode) + $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); + } else { + // Search for an existing page with the specified page slug + $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); + } + + $valid_page_found = apply_filters( 'woocommerce_create_page_id', $valid_page_found, $slug, $page_content ); + + if ( $valid_page_found ) { + if ( $option ) { + update_option( $option, $valid_page_found ); + } + return $valid_page_found; + } + + // Search for a matching valid trashed page + if ( strlen( $page_content ) > 0 ) { + // Search for an existing page with the specified page content (typically a shortcode) + $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); + } else { + // Search for an existing page with the specified page slug + $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); + } + + if ( $trashed_page_found ) { + $page_id = $trashed_page_found; + $page_data = array( + 'ID' => $page_id, + 'post_status' => 'publish', + ); + wp_update_post( $page_data ); + } else { + $page_data = array( + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_author' => 1, + 'post_name' => $slug, + 'post_title' => $page_title, + 'post_content' => $page_content, + 'post_parent' => $post_parent, + 'comment_status' => 'closed', + ); + $page_id = wp_insert_post( $page_data ); + } + + if ( $option ) { + update_option( $option, $page_id ); + } + + return $page_id; +} + +/** + * Output admin fields. + * + * Loops though the woocommerce options array and outputs each field. + * + * @param array $options Opens array to output + */ +function woocommerce_admin_fields( $options ) { + + if ( ! class_exists( 'WC_Admin_Settings', false ) ) { + include dirname( __FILE__ ) . '/class-wc-admin-settings.php'; + } + + WC_Admin_Settings::output_fields( $options ); +} + +/** + * Update all settings which are passed. + * + * @param array $options + * @param array $data + */ +function woocommerce_update_options( $options, $data = null ) { + + if ( ! class_exists( 'WC_Admin_Settings', false ) ) { + include dirname( __FILE__ ) . '/class-wc-admin-settings.php'; + } + + WC_Admin_Settings::save_fields( $options, $data ); +} + +/** + * Get a setting from the settings API. + * + * @param mixed $option_name + * @param mixed $default + * @return string + */ +function woocommerce_settings_get_option( $option_name, $default = '' ) { + + if ( ! class_exists( 'WC_Admin_Settings', false ) ) { + include dirname( __FILE__ ) . '/class-wc-admin-settings.php'; + } + + return WC_Admin_Settings::get_option( $option_name, $default ); +} + +/** + * Save order items. Uses the CRUD. + * + * @since 2.2 + * @param int $order_id Order ID + * @param array $items Order items to save + */ +function wc_save_order_items( $order_id, $items ) { + // Allow other plugins to check change in order items before they are saved. + do_action( 'woocommerce_before_save_order_items', $order_id, $items ); + + // Line items and fees. + if ( isset( $items['order_item_id'] ) ) { + $data_keys = array( + 'line_tax' => array(), + 'line_subtotal_tax' => array(), + 'order_item_name' => null, + 'order_item_qty' => null, + 'order_item_tax_class' => null, + 'line_total' => null, + 'line_subtotal' => null, + ); + foreach ( $items['order_item_id'] as $item_id ) { + if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) { + continue; + } + + $item_data = array(); + + foreach ( $data_keys as $key => $default ) { + $item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_clean( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default; + } + + if ( '0' === $item_data['order_item_qty'] ) { + $item->delete(); + continue; + } + + $item->set_props( + array( + 'name' => $item_data['order_item_name'], + 'quantity' => $item_data['order_item_qty'], + 'tax_class' => $item_data['order_item_tax_class'], + 'total' => $item_data['line_total'], + 'subtotal' => $item_data['line_subtotal'], + 'taxes' => array( + 'total' => $item_data['line_tax'], + 'subtotal' => $item_data['line_subtotal_tax'], + ), + ) + ); + + if ( 'fee' === $item->get_type() ) { + $item->set_amount( $item_data['line_total'] ); + } + + if ( isset( $items['meta_key'][ $item_id ], $items['meta_value'][ $item_id ] ) ) { + foreach ( $items['meta_key'][ $item_id ] as $meta_id => $meta_key ) { + $meta_key = substr( wp_unslash( $meta_key ), 0, 255 ); + $meta_value = isset( $items['meta_value'][ $item_id ][ $meta_id ] ) ? wp_unslash( $items['meta_value'][ $item_id ][ $meta_id ] ) : ''; + + if ( '' === $meta_key && '' === $meta_value ) { + if ( ! strstr( $meta_id, 'new-' ) ) { + $item->delete_meta_data_by_mid( $meta_id ); + } + } elseif ( strstr( $meta_id, 'new-' ) ) { + $item->add_meta_data( $meta_key, $meta_value, false ); + } else { + $item->update_meta_data( $meta_key, $meta_value, $meta_id ); + } + } + } + + $item->save(); + } + } + + // Shipping Rows + if ( isset( $items['shipping_method_id'] ) ) { + $data_keys = array( + 'shipping_method' => null, + 'shipping_method_title' => null, + 'shipping_cost' => 0, + 'shipping_taxes' => array(), + ); + + foreach ( $items['shipping_method_id'] as $item_id ) { + if ( ! $item = WC_Order_Factory::get_order_item( absint( $item_id ) ) ) { + continue; + } + + $item_data = array(); + + foreach ( $data_keys as $key => $default ) { + $item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_clean( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default; + } + + $item->set_props( + array( + 'method_id' => $item_data['shipping_method'], + 'method_title' => $item_data['shipping_method_title'], + 'total' => $item_data['shipping_cost'], + 'taxes' => array( + 'total' => $item_data['shipping_taxes'], + ), + ) + ); + + if ( isset( $items['meta_key'][ $item_id ], $items['meta_value'][ $item_id ] ) ) { + foreach ( $items['meta_key'][ $item_id ] as $meta_id => $meta_key ) { + $meta_value = isset( $items['meta_value'][ $item_id ][ $meta_id ] ) ? wp_unslash( $items['meta_value'][ $item_id ][ $meta_id ] ) : ''; + + if ( '' === $meta_key && '' === $meta_value ) { + if ( ! strstr( $meta_id, 'new-' ) ) { + $item->delete_meta_data_by_mid( $meta_id ); + } + } elseif ( strstr( $meta_id, 'new-' ) ) { + $item->add_meta_data( $meta_key, $meta_value, false ); + } else { + $item->update_meta_data( $meta_key, $meta_value, $meta_id ); + } + } + } + + $item->save(); + } + } + + $order = wc_get_order( $order_id ); + $order->update_taxes(); + $order->calculate_totals( false ); + + // Inform other plugins that the items have been saved + do_action( 'woocommerce_saved_order_items', $order_id, $items ); +} + +/** + * Get HTML for some action buttons. Used in list tables. + * + * @since 3.3.0 + * @param array $actions Actions to output. + * @return string + */ +function wc_render_action_buttons( $actions ) { + $actions_html = ''; + + foreach ( $actions as $action ) { + if ( isset( $action['group'] ) ) { + $actions_html .= '
      ' . wc_render_action_buttons( $action['actions'] ) . '
      '; + } elseif ( isset( $action['action'], $action['url'], $action['name'] ) ) { + $actions_html .= sprintf( '%4$s', esc_attr( $action['action'] ), esc_url( $action['url'] ), esc_attr( isset( $action['title'] ) ? $action['title'] : $action['name'] ), esc_html( $action['name'] ) ); + } + } + + return $actions_html; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/admin/wc-meta-box-functions.php b/backend/wp-content/plugins/woocommerce/includes/admin/wc-meta-box-functions.php new file mode 100644 index 0000000..61c451b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/admin/wc-meta-box-functions.php @@ -0,0 +1,284 @@ +ID : $thepostid; + $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; + + switch ( $data_type ) { + case 'price': + $field['class'] .= ' wc_input_price'; + $field['value'] = wc_format_localized_price( $field['value'] ); + break; + case 'decimal': + $field['class'] .= ' wc_input_decimal'; + $field['value'] = wc_format_localized_decimal( $field['value'] ); + break; + case 'stock': + $field['class'] .= ' wc_input_stock'; + $field['value'] = wc_stock_amount( $field['value'] ); + break; + case 'url': + $field['class'] .= ' wc_input_url'; + $field['value'] = esc_url( $field['value'] ); + break; + + default: + break; + } + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

      + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + echo wc_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

      '; +} + +/** + * Output a hidden input box. + * + * @param array $field + */ +function woocommerce_wp_hidden_input( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['class'] = isset( $field['class'] ) ? $field['class'] : ''; + + echo ' '; +} + +/** + * Output a textarea input box. + * + * @param array $field + */ +function woocommerce_wp_textarea_input( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : ''; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['rows'] = isset( $field['rows'] ) ? $field['rows'] : 2; + $field['cols'] = isset( $field['cols'] ) ? $field['cols'] : 20; + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

      + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + echo wc_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

      '; +} + +/** + * Output a checkbox input box. + * + * @param array $field + */ +function woocommerce_wp_checkbox( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes'; + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + + // Custom attribute handling + $custom_attributes = array(); + + if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { + + foreach ( $field['custom_attributes'] as $attribute => $value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; + } + } + + echo '

      + '; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + echo wc_help_tip( $field['description'] ); + } + + echo ' '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '

      '; +} + +/** + * Output a select input box. + * + * @param array $field Data about the field to render. + */ +function woocommerce_wp_select( $field ) { + global $thepostid, $post; + + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; + $field = wp_parse_args( + $field, array( + 'class' => 'select short', + 'style' => '', + 'wrapper_class' => '', + 'value' => get_post_meta( $thepostid, $field['id'], true ), + 'name' => $field['id'], + 'desc_tip' => false, + 'custom_attributes' => array(), + ) + ); + + $wrapper_attributes = array( + 'class' => $field['wrapper_class'] . " form-field {$field['id']}_field", + ); + + $label_attributes = array( + 'for' => $field['id'], + ); + + $field_attributes = (array) $field['custom_attributes']; + $field_attributes['style'] = $field['style']; + $field_attributes['id'] = $field['id']; + $field_attributes['name'] = $field['name']; + $field_attributes['class'] = $field['class']; + + $tooltip = ! empty( $field['description'] ) && false !== $field['desc_tip'] ? $field['description'] : ''; + $description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : ''; + ?> +

      > + + + + + + + + +

      + ID : $thepostid; + $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; + $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; + $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; + $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; + + echo '
      ' . wp_kses_post( $field['label'] ) . ''; + + if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { + echo wc_help_tip( $field['description'] ); + } + + echo '
        '; + + foreach ( $field['options'] as $key => $value ) { + + echo '
      • +
      • '; + } + echo '
      '; + + if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { + echo '' . wp_kses_post( $field['description'] ) . ''; + } + + echo '
      '; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-authentication.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-authentication.php new file mode 100644 index 0000000..a269a6e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-authentication.php @@ -0,0 +1,606 @@ +is_request_to_rest_api() ) { + return $user_id; + } + + if ( is_ssl() ) { + return $this->perform_basic_authentication(); + } + + return $this->perform_oauth_authentication(); + } + + /** + * Check for authentication error. + * + * @param WP_Error|null|bool $error Error data. + * @return WP_Error|null|bool + */ + public function check_authentication_error( $error ) { + // Pass through other errors. + if ( ! empty( $error ) ) { + return $error; + } + + return $this->get_error(); + } + + /** + * Set authentication error. + * + * @param WP_Error $error Authentication error data. + */ + protected function set_error( $error ) { + // Reset user. + $this->user = null; + + $this->error = $error; + } + + /** + * Get authentication error. + * + * @return WP_Error|null. + */ + protected function get_error() { + return $this->error; + } + + /** + * Basic Authentication. + * + * SSL-encrypted requests are not subject to sniffing or man-in-the-middle + * attacks, so the request can be authenticated by simply looking up the user + * associated with the given consumer key and confirming the consumer secret + * provided is valid. + * + * @return int|bool + */ + private function perform_basic_authentication() { + $this->auth_method = 'basic_auth'; + $consumer_key = ''; + $consumer_secret = ''; + + // If the $_GET parameters are present, use those first. + if ( ! empty( $_GET['consumer_key'] ) && ! empty( $_GET['consumer_secret'] ) ) { + $consumer_key = $_GET['consumer_key']; // WPCS: sanitization ok. + $consumer_secret = $_GET['consumer_secret']; // WPCS: sanitization ok. + } + + // If the above is not present, we will do full basic auth. + if ( ! $consumer_key && ! empty( $_SERVER['PHP_AUTH_USER'] ) && ! empty( $_SERVER['PHP_AUTH_PW'] ) ) { + $consumer_key = $_SERVER['PHP_AUTH_USER']; // WPCS: sanitization ok. + $consumer_secret = $_SERVER['PHP_AUTH_PW']; // WPCS: sanitization ok. + } + + // Stop if don't have any key. + if ( ! $consumer_key || ! $consumer_secret ) { + return false; + } + + // Get user data. + $this->user = $this->get_user_data_by_consumer_key( $consumer_key ); + if ( empty( $this->user ) ) { + return false; + } + + // Validate user secret. + if ( ! hash_equals( $this->user->consumer_secret, $consumer_secret ) ) { // @codingStandardsIgnoreLine + $this->set_error( new WP_Error( 'woocommerce_rest_authentication_error', __( 'Consumer secret is invalid.', 'woocommerce' ), array( 'status' => 401 ) ) ); + + return false; + } + + return $this->user->user_id; + } + + /** + * Parse the Authorization header into parameters. + * + * @since 3.0.0 + * + * @param string $header Authorization header value (not including "Authorization: " prefix). + * + * @return array Map of parameter values. + */ + public function parse_header( $header ) { + if ( 'OAuth ' !== substr( $header, 0, 6 ) ) { + return array(); + } + + // From OAuth PHP library, used under MIT license. + $params = array(); + if ( preg_match_all( '/(oauth_[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches ) ) { + foreach ( $matches[1] as $i => $h ) { + $params[ $h ] = urldecode( empty( $matches[3][ $i ] ) ? $matches[4][ $i ] : $matches[3][ $i ] ); + } + if ( isset( $params['realm'] ) ) { + unset( $params['realm'] ); + } + } + + return $params; + } + + /** + * Get the authorization header. + * + * On certain systems and configurations, the Authorization header will be + * stripped out by the server or PHP. Typically this is then used to + * generate `PHP_AUTH_USER`/`PHP_AUTH_PASS` but not passed on. We use + * `getallheaders` here to try and grab it out instead. + * + * @since 3.0.0 + * + * @return string Authorization header if set. + */ + public function get_authorization_header() { + if ( ! empty( $_SERVER['HTTP_AUTHORIZATION'] ) ) { + return wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] ); // WPCS: sanitization ok. + } + + if ( function_exists( 'getallheaders' ) ) { + $headers = getallheaders(); + // Check for the authoization header case-insensitively. + foreach ( $headers as $key => $value ) { + if ( 'authorization' === strtolower( $key ) ) { + return $value; + } + } + } + + return ''; + } + + /** + * Get oAuth parameters from $_GET, $_POST or request header. + * + * @since 3.0.0 + * + * @return array|WP_Error + */ + public function get_oauth_parameters() { + $params = array_merge( $_GET, $_POST ); // WPCS: CSRF ok. + $params = wp_unslash( $params ); + $header = $this->get_authorization_header(); + + if ( ! empty( $header ) ) { + // Trim leading spaces. + $header = trim( $header ); + $header_params = $this->parse_header( $header ); + + if ( ! empty( $header_params ) ) { + $params = array_merge( $params, $header_params ); + } + } + + $param_names = array( + 'oauth_consumer_key', + 'oauth_timestamp', + 'oauth_nonce', + 'oauth_signature', + 'oauth_signature_method', + ); + + $errors = array(); + $have_one = false; + + // Check for required OAuth parameters. + foreach ( $param_names as $param_name ) { + if ( empty( $params[ $param_name ] ) ) { + $errors[] = $param_name; + } else { + $have_one = true; + } + } + + // All keys are missing, so we're probably not even trying to use OAuth. + if ( ! $have_one ) { + return array(); + } + + // If we have at least one supplied piece of data, and we have an error, + // then it's a failed authentication. + if ( ! empty( $errors ) ) { + $message = sprintf( + /* translators: %s: amount of errors */ + _n( 'Missing OAuth parameter %s', 'Missing OAuth parameters %s', count( $errors ), 'woocommerce' ), + implode( ', ', $errors ) + ); + + $this->set_error( new WP_Error( 'woocommerce_rest_authentication_missing_parameter', $message, array( 'status' => 401 ) ) ); + + return array(); + } + + return $params; + } + + /** + * Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests. + * + * This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP. + * + * This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions: + * + * 1) There is no token associated with request/responses, only consumer keys/secrets are used. + * + * 2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header, + * This is because there is no cross-OS function within PHP to get the raw Authorization header. + * + * @link http://tools.ietf.org/html/rfc5849 for the full spec. + * + * @return int|bool + */ + private function perform_oauth_authentication() { + $this->auth_method = 'oauth1'; + + $params = $this->get_oauth_parameters(); + if ( empty( $params ) ) { + return false; + } + + // Fetch WP user by consumer key. + $this->user = $this->get_user_data_by_consumer_key( $params['oauth_consumer_key'] ); + + if ( empty( $this->user ) ) { + $this->set_error( new WP_Error( 'woocommerce_rest_authentication_error', __( 'Consumer key is invalid.', 'woocommerce' ), array( 'status' => 401 ) ) ); + + return false; + } + + // Perform OAuth validation. + $signature = $this->check_oauth_signature( $this->user, $params ); + if ( is_wp_error( $signature ) ) { + $this->set_error( $signature ); + return false; + } + + $timestamp_and_nonce = $this->check_oauth_timestamp_and_nonce( $this->user, $params['oauth_timestamp'], $params['oauth_nonce'] ); + if ( is_wp_error( $timestamp_and_nonce ) ) { + $this->set_error( $timestamp_and_nonce ); + return false; + } + + return $this->user->user_id; + } + + /** + * Verify that the consumer-provided request signature matches our generated signature, + * this ensures the consumer has a valid key/secret. + * + * @param stdClass $user User data. + * @param array $params The request parameters. + * @return true|WP_Error + */ + private function check_oauth_signature( $user, $params ) { + $http_method = isset( $_SERVER['REQUEST_METHOD'] ) ? strtoupper( $_SERVER['REQUEST_METHOD'] ) : ''; // WPCS: sanitization ok. + $request_path = isset( $_SERVER['REQUEST_URI'] ) ? parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) : ''; // WPCS: sanitization ok. + $wp_base = get_home_url( null, '/', 'relative' ); + if ( substr( $request_path, 0, strlen( $wp_base ) ) === $wp_base ) { + $request_path = substr( $request_path, strlen( $wp_base ) ); + } + $base_request_uri = rawurlencode( get_home_url( null, $request_path, is_ssl() ? 'https' : 'http' ) ); + + // Get the signature provided by the consumer and remove it from the parameters prior to checking the signature. + $consumer_signature = rawurldecode( str_replace( ' ', '+', $params['oauth_signature'] ) ); + unset( $params['oauth_signature'] ); + + // Sort parameters. + if ( ! uksort( $params, 'strcmp' ) ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - failed to sort parameters.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + // Normalize parameter key/values. + $params = $this->normalize_parameters( $params ); + $query_string = implode( '%26', $this->join_with_equals_sign( $params ) ); // Join with ampersand. + $string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string; + + if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - signature method is invalid.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + $hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) ); + $secret = $user->consumer_secret . '&'; + $signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $secret, true ) ); + + if ( ! hash_equals( $signature, $consumer_signature ) ) { // @codingStandardsIgnoreLine + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - provided signature does not match.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return true; + } + + /** + * Creates an array of urlencoded strings out of each array key/value pairs. + * + * @param array $params Array of parameters to convert. + * @param array $query_params Array to extend. + * @param string $key Optional Array key to append. + * @return string Array of urlencoded strings. + */ + private function join_with_equals_sign( $params, $query_params = array(), $key = '' ) { + foreach ( $params as $param_key => $param_value ) { + if ( $key ) { + $param_key = $key . '%5B' . $param_key . '%5D'; // Handle multi-dimensional array. + } + + if ( is_array( $param_value ) ) { + $query_params = $this->join_with_equals_sign( $param_value, $query_params, $param_key ); + } else { + $string = $param_key . '=' . $param_value; // Join with equals sign. + $query_params[] = wc_rest_urlencode_rfc3986( $string ); + } + } + + return $query_params; + } + + /** + * Normalize each parameter by assuming each parameter may have already been + * encoded, so attempt to decode, and then re-encode according to RFC 3986. + * + * Note both the key and value is normalized so a filter param like: + * + * 'filter[period]' => 'week' + * + * is encoded to: + * + * 'filter%255Bperiod%255D' => 'week' + * + * This conforms to the OAuth 1.0a spec which indicates the entire query string + * should be URL encoded. + * + * @see rawurlencode() + * @param array $parameters Un-normalized parameters. + * @return array Normalized parameters. + */ + private function normalize_parameters( $parameters ) { + $keys = wc_rest_urlencode_rfc3986( array_keys( $parameters ) ); + $values = wc_rest_urlencode_rfc3986( array_values( $parameters ) ); + $parameters = array_combine( $keys, $values ); + + return $parameters; + } + + /** + * Verify that the timestamp and nonce provided with the request are valid. This prevents replay attacks where + * an attacker could attempt to re-send an intercepted request at a later time. + * + * - A timestamp is valid if it is within 15 minutes of now. + * - A nonce is valid if it has not been used within the last 15 minutes. + * + * @param stdClass $user User data. + * @param int $timestamp The unix timestamp for when the request was made. + * @param string $nonce A unique (for the given user) 32 alphanumeric string, consumer-generated. + * @return bool|WP_Error + */ + private function check_oauth_timestamp_and_nonce( $user, $timestamp, $nonce ) { + global $wpdb; + + $valid_window = 15 * 60; // 15 minute window. + + if ( ( $timestamp < time() - $valid_window ) || ( $timestamp > time() + $valid_window ) ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid timestamp.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + $used_nonces = maybe_unserialize( $user->nonces ); + + if ( empty( $used_nonces ) ) { + $used_nonces = array(); + } + + if ( in_array( $nonce, $used_nonces ) ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid nonce - nonce has already been used.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + $used_nonces[ $timestamp ] = $nonce; + + // Remove expired nonces. + foreach ( $used_nonces as $nonce_timestamp => $nonce ) { + if ( $nonce_timestamp < ( time() - $valid_window ) ) { + unset( $used_nonces[ $nonce_timestamp ] ); + } + } + + $used_nonces = maybe_serialize( $used_nonces ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'nonces' => $used_nonces ), + array( 'key_id' => $user->key_id ), + array( '%s' ), + array( '%d' ) + ); + + return true; + } + + /** + * Return the user data for the given consumer_key. + * + * @param string $consumer_key Consumer key. + * @return array + */ + private function get_user_data_by_consumer_key( $consumer_key ) { + global $wpdb; + + $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) ); + $user = $wpdb->get_row( + $wpdb->prepare( + " + SELECT key_id, user_id, permissions, consumer_key, consumer_secret, nonces + FROM {$wpdb->prefix}woocommerce_api_keys + WHERE consumer_key = %s + ", $consumer_key + ) + ); + + return $user; + } + + /** + * Check that the API keys provided have the proper key-specific permissions to either read or write API resources. + * + * @param string $method Request method. + * @return bool|WP_Error + */ + private function check_permissions( $method ) { + $permissions = $this->user->permissions; + + switch ( $method ) { + case 'HEAD': + case 'GET': + if ( 'read' !== $permissions && 'read_write' !== $permissions ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'The API key provided does not have read permissions.', 'woocommerce' ), array( 'status' => 401 ) ); + } + break; + case 'POST': + case 'PUT': + case 'PATCH': + case 'DELETE': + if ( 'write' !== $permissions && 'read_write' !== $permissions ) { + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'The API key provided does not have write permissions.', 'woocommerce' ), array( 'status' => 401 ) ); + } + break; + case 'OPTIONS': + return true; + + default: + return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Unknown request method.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return true; + } + + /** + * Updated API Key last access datetime. + */ + private function update_last_access() { + global $wpdb; + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'last_access' => current_time( 'mysql' ) ), + array( 'key_id' => $this->user->key_id ), + array( '%s' ), + array( '%d' ) + ); + } + + /** + * If the consumer_key and consumer_secret $_GET parameters are NOT provided + * and the Basic auth headers are either not present or the consumer secret does not match the consumer + * key provided, then return the correct Basic headers and an error message. + * + * @param WP_REST_Response $response Current response being served. + * @return WP_REST_Response + */ + public function send_unauthorized_headers( $response ) { + if ( is_wp_error( $this->get_error() ) && 'basic_auth' === $this->auth_method ) { + $auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'woocommerce' ); + $response->header( 'WWW-Authenticate', 'Basic realm="' . $auth_message . '"', true ); + } + + return $response; + } + + /** + * Check for user permissions and register last access. + * + * @param mixed $result Response to replace the requested version with. + * @param WP_REST_Server $server Server instance. + * @param WP_REST_Request $request Request used to generate the response. + * @return mixed + */ + public function check_user_permissions( $result, $server, $request ) { + if ( $this->user ) { + // Check API Key permissions. + $allowed = $this->check_permissions( $request->get_method() ); + if ( is_wp_error( $allowed ) ) { + return $allowed; + } + + // Register last access. + $this->update_last_access(); + } + + return $result; + } +} + +new WC_REST_Authentication(); diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-coupons-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-coupons-controller.php new file mode 100644 index 0000000..1b8c8aa --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-coupons-controller.php @@ -0,0 +1,542 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'required' => true, + 'type' => 'string', + ), + ) + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + } + + /** + * Get object. + * + * @since 3.0.0 + * @param int $id Object ID. + * @return WC_Data + */ + protected function get_object( $id ) { + return new WC_Coupon( $id ); + } + + /** + * Get formatted item data. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data instance. + * @return array + */ + protected function get_formatted_item_data( $object ) { + $data = $object->get_data(); + + $format_decimal = array( 'amount', 'minimum_amount', 'maximum_amount' ); + $format_date = array( 'date_created', 'date_modified', 'date_expires' ); + $format_null = array( 'usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], 2 ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $datetime = $data[ $key ]; + $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); + $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); + } + + // Format null values. + foreach ( $format_null as $key ) { + $data[ $key ] = $data[ $key ] ? $data[ $key ] : null; + } + + return array( + 'id' => $object->get_id(), + 'code' => $data['code'], + 'amount' => $data['amount'], + 'date_created' => $data['date_created'], + 'date_created_gmt' => $data['date_created_gmt'], + 'date_modified' => $data['date_modified'], + 'date_modified_gmt' => $data['date_modified_gmt'], + 'discount_type' => $data['discount_type'], + 'description' => $data['description'], + 'date_expires' => $data['date_expires'], + 'date_expires_gmt' => $data['date_expires_gmt'], + 'usage_count' => $data['usage_count'], + 'individual_use' => $data['individual_use'], + 'product_ids' => $data['product_ids'], + 'excluded_product_ids' => $data['excluded_product_ids'], + 'usage_limit' => $data['usage_limit'], + 'usage_limit_per_user' => $data['usage_limit_per_user'], + 'limit_usage_to_x_items' => $data['limit_usage_to_x_items'], + 'free_shipping' => $data['free_shipping'], + 'product_categories' => $data['product_categories'], + 'excluded_product_categories' => $data['excluded_product_categories'], + 'exclude_sale_items' => $data['exclude_sale_items'], + 'minimum_amount' => $data['minimum_amount'], + 'maximum_amount' => $data['maximum_amount'], + 'email_restrictions' => $data['email_restrictions'], + 'used_by' => $data['used_by'], + 'meta_data' => $data['meta_data'], + ); + } + + /** + * Prepare a single coupon output for response. + * + * @since 3.0.0 + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_object_for_response( $object, $request ) { + $data = $this->get_formatted_item_data( $object ); + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $object, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, + * refers to object type being prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); + } + + /** + * Prepare objects query. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query( $request ) { + $args = parent::prepare_objects_query( $request ); + + if ( ! empty( $request['code'] ) ) { + $id = wc_get_coupon_id_by_code( $request['code'] ); + $args['post__in'] = array( $id ); + } + + // Get only ids. + $args['fields'] = 'ids'; + + return $args; + } + + /** + * Only return writable props from schema. + * + * @param array $schema Schema. + * @return bool + */ + protected function filter_writable_props( $schema ) { + return empty( $schema['readonly'] ); + } + + /** + * Prepare a single coupon for create or update. + * + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data + */ + protected function prepare_object_for_database( $request, $creating = false ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $coupon = new WC_Coupon( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Validate required POST fields. + if ( $creating && empty( $request['code'] ) ) { + return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) ); + } + + // Handle all writable props. + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'code': + $coupon_code = wc_format_coupon_code( $value ); + $id = $coupon->get_id() ? $coupon->get_id() : 0; + $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); + + if ( $id_from_code ) { + return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $coupon->set_code( $coupon_code ); + break; + case 'meta_data': + if ( is_array( $value ) ) { + foreach ( $value as $meta ) { + $coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + break; + case 'description': + $coupon->set_description( wp_filter_post_kses( $value ) ); + break; + default: + if ( is_callable( array( $coupon, "set_{$key}" ) ) ) { + $coupon->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filters an object before it is inserted via the REST API. + * + * The dynamic portion of the hook name, `$this->post_type`, + * refers to the object type slug. + * + * @param WC_Data $coupon Object object. + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $coupon, $request, $creating ); + } + + /** + * Get the Coupon's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the object.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'amount' => array( + 'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the coupon was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the coupon was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'discount_type' => array( + 'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'fixed_cart', + 'enum' => array_keys( wc_get_coupon_types() ), + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'Coupon description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_expires' => array( + 'description' => __( "The date the coupon expires, in the site's timezone.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_expires_gmt' => array( + 'description' => __( 'The date the coupon expires, as GMT.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'usage_count' => array( + 'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'individual_use' => array( + 'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'product_ids' => array( + 'description' => __( 'List of product IDs the coupon can be used on.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'excluded_product_ids' => array( + 'description' => __( 'List of product IDs the coupon cannot be used on.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'usage_limit' => array( + 'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'usage_limit_per_user' => array( + 'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'limit_usage_to_x_items' => array( + 'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'free_shipping' => array( + 'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'product_categories' => array( + 'description' => __( 'List of category IDs the coupon applies to.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'excluded_product_categories' => array( + 'description' => __( 'List of category IDs the coupon does not apply to.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'exclude_sale_items' => array( + 'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'minimum_amount' => array( + 'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'maximum_amount' => array( + 'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email_restrictions' => array( + 'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'string', + ), + 'context' => array( 'view', 'edit' ), + ), + 'used_by' => array( + 'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ); + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['code'] = array( + 'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customer-downloads-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customer-downloads-controller.php new file mode 100644 index 0000000..3fd52f3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customer-downloads-controller.php @@ -0,0 +1,165 @@ +/downloads endpoint. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Customers controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Customer_Downloads_V1_Controller + */ +class WC_REST_Customer_Downloads_Controller extends WC_REST_Customer_Downloads_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Prepare a single download output for response. + * + * @param stdClass $download Download object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $download, $request ) { + $data = array( + 'download_id' => $download->download_id, + 'download_url' => $download->download_url, + 'product_id' => $download->product_id, + 'product_name' => $download->product_name, + 'download_name' => $download->download_name, + 'order_id' => $download->order_id, + 'order_key' => $download->order_key, + 'downloads_remaining' => '' === $download->downloads_remaining ? 'unlimited' : $download->downloads_remaining, + 'access_expires' => $download->access_expires ? wc_rest_prepare_date_response( $download->access_expires ) : 'never', + 'access_expires_gmt' => $download->access_expires ? wc_rest_prepare_date_response( get_gmt_from_date( $download->access_expires ) ) : 'never', + 'file' => $download->file, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $download, $request ) ); + + /** + * Filter customer download data returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $download Download object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_customer_download', $response, $download, $request ); + } + + /** + * Get the Customer Download's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'customer_download', + 'type' => 'object', + 'properties' => array( + 'download_id' => array( + 'description' => __( 'Download ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'download_url' => array( + 'description' => __( 'Download file URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Downloadable product ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'product_name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'download_name' => array( + 'description' => __( 'Downloadable file name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'order_id' => array( + 'description' => __( 'Order ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'order_key' => array( + 'description' => __( 'Order key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'downloads_remaining' => array( + 'description' => __( 'Number of downloads remaining.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'access_expires' => array( + 'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'access_expires_gmt' => array( + 'description' => __( 'The date when download access expires, as GMT.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'file' => array( + 'description' => __( 'File details.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customers-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customers-controller.php new file mode 100644 index 0000000..33e4f09 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-customers-controller.php @@ -0,0 +1,364 @@ +get_data(); + $format_date = array( 'date_created', 'date_modified' ); + + // Format date values. + foreach ( $format_date as $key ) { + $datetime = $data[ $key ]; + $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); + $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); + } + + return array( + 'id' => $object->get_id(), + 'date_created' => $data['date_created'], + 'date_created_gmt' => $data['date_created_gmt'], + 'date_modified' => $data['date_modified'], + 'date_modified_gmt' => $data['date_modified_gmt'], + 'email' => $data['email'], + 'first_name' => $data['first_name'], + 'last_name' => $data['last_name'], + 'role' => $data['role'], + 'username' => $data['username'], + 'billing' => $data['billing'], + 'shipping' => $data['shipping'], + 'is_paying_customer' => $data['is_paying_customer'], + 'orders_count' => $object->get_order_count(), + 'total_spent' => $object->get_total_spent(), + 'avatar_url' => $object->get_avatar_url(), + 'meta_data' => $data['meta_data'], + ); + } + + /** + * Prepare a single customer output for response. + * + * @param WP_User $user_data User object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $user_data, $request ) { + $customer = new WC_Customer( $user_data->ID ); + $data = $this->get_formatted_item_data( $customer ); + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $user_data ) ); + + /** + * Filter customer data returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_User $user_data User object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_customer', $response, $user_data, $request ); + } + + /** + * Update customer meta fields. + * + * @param WC_Customer $customer Customer data. + * @param WP_REST_Request $request Request data. + */ + protected function update_customer_meta_fields( $customer, $request ) { + parent::update_customer_meta_fields( $customer, $request ); + + // Meta data. + if ( isset( $request['meta_data'] ) ) { + if ( is_array( $request['meta_data'] ) ) { + foreach ( $request['meta_data'] as $meta ) { + $customer->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + } + } + + /** + * Get the Customer's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'customer', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the customer was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the order was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the customer was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'email' => array( + 'description' => __( 'The email address for the customer.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'first_name' => array( + 'description' => __( 'Customer first name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'last_name' => array( + 'description' => __( 'Customer last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'role' => array( + 'description' => __( 'Customer role.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'username' => array( + 'description' => __( 'Customer login name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_user', + ), + ), + 'password' => array( + 'description' => __( 'Customer password.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), + 'billing' => array( + 'description' => __( 'List of billing address data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'ISO code of the country.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Email address.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'phone' => array( + 'description' => __( 'Phone number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping' => array( + 'description' => __( 'List of shipping address data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'ISO code of the country.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'is_paying_customer' => array( + 'description' => __( 'Is the customer a paying customer?', 'woocommerce' ), + 'type' => 'bool', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'orders_count' => array( + 'description' => __( 'Quantity of orders made by the customer.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_spent' => array( + 'description' => __( 'Total amount spent.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'avatar_url' => array( + 'description' => __( 'Avatar URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-exception.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-exception.php new file mode 100644 index 0000000..8d7fd70 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-exception.php @@ -0,0 +1,16 @@ +namespace, '/' . $this->rest_base . '/network', array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'network_orders' ), + 'permission_callback' => array( $this, 'network_orders_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + } + + /** + * Retrieves the item's schema for display / public consumption purposes. + * + * @access public + * + * @return array Public item schema data. + */ + public function get_public_item_schema() { + $schema = parent::get_public_item_schema(); + + $schema['properties']['blog'] = array( + 'description' => __( 'Blog id of the record on the multisite.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ); + $schema['properties']['edit_url'] = array( + 'description' => __( 'URL to edit the order', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ); + $schema['properties']['customer'][] = array( + 'description' => __( 'Name of the customer for the order', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ); + $schema['properties']['status_name'][] = array( + 'description' => __( 'Order Status', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ); + $schema['properties']['formatted_total'][] = array( + 'description' => __( 'Order total formatted for locale', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ); + + return $schema; + } + + /** + * Does a permissions check for the proper requested blog + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool $permission + */ + public function network_orders_permissions_check( $request ) { + $blog_id = $request->get_param( 'blog_id' ); + $blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id(); + + switch_to_blog( $blog_id ); + + $permission = $this->get_items_permissions_check( $request ); + + restore_current_blog(); + + return $permission; + } + + /** + * Get a collection of orders from the requested blog id + * + * @param WP_REST_Request $request Full details about the request. + * + * @return WP_REST_Response + */ + public function network_orders( $request ) { + $blog_id = $request->get_param( 'blog_id' ); + $blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id(); + + switch_to_blog( $blog_id ); + + add_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) ); + $items = $this->get_items( $request ); + remove_filter( 'woocommerce_rest_orders_prepare_object_query', array( $this, 'network_orders_filter_args' ) ); + + foreach ( $items->data as &$current_order ) { + $order = wc_get_order( $current_order['id'] ); + + $current_order['blog'] = get_blog_details( get_current_blog_id() ); + $current_order['edit_url'] = get_admin_url( $blog_id, 'post.php?post=' . absint( $order->get_id() ) . '&action=edit' ); + /* translators: 1: first name 2: last name */ + $current_order['customer'] = trim( sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $order->get_billing_first_name(), $order->get_billing_last_name() ) ); + $current_order['status_name'] = wc_get_order_status_name( $order->get_status() ); + $current_order['formatted_total'] = $order->get_formatted_order_total(); + } + + restore_current_blog(); + + return $items; + } + + /** + * Filters the post statuses to on hold and processing for the network order query. + * + * @param array $args Query args. + * + * @return array + */ + public function network_orders_filter_args( $args ) { + $args['post_status'] = array( + 'wc-on-hold', + 'wc-processing', + ); + + return $args; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-notes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-notes-controller.php new file mode 100644 index 0000000..870c4e1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-notes-controller.php @@ -0,0 +1,182 @@ +/notes endpoint. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Order Notes controller class. + * + * @package WooCommerce/API + * @extends WC_REST_ControllerWC_REST_Order_Notes_V1_Controller + */ +class WC_REST_Order_Notes_Controller extends WC_REST_Order_Notes_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Get order notes from an order. + * + * @param WP_REST_Request $request Request data. + * + * @return array|WP_Error + */ + public function get_items( $request ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order || $this->post_type !== $order->get_type() ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $args = array( + 'post_id' => $order->get_id(), + 'approve' => 'approve', + 'type' => 'order_note', + ); + + // Allow filter by order note type. + if ( 'customer' === $request['type'] ) { + $args['meta_query'] = array( // WPCS: slow query ok. + array( + 'key' => 'is_customer_note', + 'value' => 1, + 'compare' => '=', + ), + ); + } elseif ( 'internal' === $request['type'] ) { + $args['meta_query'] = array( // WPCS: slow query ok. + array( + 'key' => 'is_customer_note', + 'compare' => 'NOT EXISTS', + ), + ); + } + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $notes = get_comments( $args ); + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $data = array(); + foreach ( $notes as $note ) { + $order_note = $this->prepare_item_for_response( $note, $request ); + $order_note = $this->prepare_response_for_collection( $order_note ); + $data[] = $order_note; + } + + return rest_ensure_response( $data ); + } + + /** + * Prepare a single order note output for response. + * + * @param WP_Comment $note Order note object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $note, $request ) { + $data = array( + 'id' => (int) $note->comment_ID, + 'date_created' => wc_rest_prepare_date_response( $note->comment_date ), + 'date_created_gmt' => wc_rest_prepare_date_response( $note->comment_date_gmt ), + 'note' => $note->comment_content, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $note ) ); + + /** + * Filter order note object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_Comment $note Order note object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_order_note', $response, $note, $request ); + } + + /** + * Get the Order Notes schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'order_note', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the order note was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'note' => array( + 'description' => __( 'Order note content.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'customer_note' => array( + 'description' => __( 'If true, the note will be shown to customers and they will be notified. If false, the note will be for admin reference only.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = array(); + $params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); + $params['type'] = array( + 'default' => 'any', + 'description' => __( 'Limit result to customers or internal notes.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array( 'any', 'customer', 'internal' ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-refunds-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-refunds-controller.php new file mode 100644 index 0000000..1df6b93 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-order-refunds-controller.php @@ -0,0 +1,583 @@ +/refunds endpoint. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Order Refunds controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Orders_Controller + */ +class WC_REST_Order_Refunds_Controller extends WC_REST_Orders_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'orders/(?P[\d]+)/refunds'; + + /** + * Post type. + * + * @var string + */ + protected $post_type = 'shop_order_refund'; + + /** + * Stores the request. + * + * @var array + */ + protected $request = array(); + + /** + * Order refunds actions. + */ + public function __construct() { + add_filter( "woocommerce_rest_{$this->post_type}_object_trashable", '__return_false' ); + } + + /** + * Register the routes for order refunds. + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => true, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Get object. + * + * @since 3.0.0 + * @param int $id Object ID. + * @return WC_Data + */ + protected function get_object( $id ) { + return wc_get_order( $id ); + } + + /** + * Get formatted item data. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data instance. + * @return array + */ + protected function get_formatted_item_data( $object ) { + $data = $object->get_data(); + $format_decimal = array( 'amount' ); + $format_date = array( 'date_created' ); + $format_line_items = array( 'line_items' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $datetime = $data[ $key ]; + $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); + $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); + } + + // Format line items. + foreach ( $format_line_items as $key ) { + $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); + } + + return array( + 'id' => $object->get_id(), + 'date_created' => $data['date_created'], + 'date_created_gmt' => $data['date_created_gmt'], + 'amount' => $data['amount'], + 'reason' => $data['reason'], + 'refunded_by' => $data['refunded_by'], + 'refunded_payment' => $data['refunded_payment'], + 'meta_data' => $data['meta_data'], + 'line_items' => $data['line_items'], + ); + } + + /** + * Prepare a single order output for response. + * + * @since 3.0.0 + * + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * + * @return WP_Error|WP_REST_Response + */ + public function prepare_object_for_response( $object, $request ) { + $this->request = $request; + $this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] ); + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order ) { + return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 ); + } + + if ( ! $object || $object->get_parent_id() !== $order->get_id() ) { + return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 ); + } + + $data = $this->get_formatted_item_data( $object ); + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $object, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, + * refers to object type being prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return array Links for the given post. + */ + protected function prepare_links( $object, $request ) { + $base = str_replace( '(?P[\d]+)', $object->get_parent_id(), $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $object->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ), + ), + ); + + return $links; + } + + /** + * Prepare objects query. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query( $request ) { + $args = parent::prepare_objects_query( $request ); + + $args['post_status'] = array_keys( wc_get_order_statuses() ); + $args['post_parent__in'] = array( absint( $request['order_id'] ) ); + + return $args; + } + + /** + * Prepares one object for create or update operation. + * + * @since 3.0.0 + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data The prepared item, or WP_Error object on failure. + */ + protected function prepare_object_for_database( $request, $creating = false ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order ) { + return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 ); + } + + if ( 0 > $request['amount'] ) { + return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 ); + } + + // Create the refund. + $refund = wc_create_refund( + array( + 'order_id' => $order->get_id(), + 'amount' => $request['amount'], + 'reason' => empty( $request['reason'] ) ? null : $request['reason'], + 'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true, + 'restock_items' => true, + ) + ); + + if ( is_wp_error( $refund ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500 ); + } + + if ( ! $refund ) { + return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 ); + } + + if ( ! empty( $request['meta_data'] ) && is_array( $request['meta_data'] ) ) { + foreach ( $request['meta_data'] as $meta ) { + $refund->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + $refund->save_meta_data(); + } + + /** + * Filters an object before it is inserted via the REST API. + * + * The dynamic portion of the hook name, `$this->post_type`, + * refers to the object type slug. + * + * @param WC_Data $coupon Object object. + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $refund, $request, $creating ); + } + + /** + * Save an object data. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @param bool $creating If is creating a new object. + * @return WC_Data|WP_Error + */ + protected function save_object( $request, $creating = false ) { + try { + $object = $this->prepare_object_for_database( $request, $creating ); + + if ( is_wp_error( $object ) ) { + return $object; + } + + return $this->get_object( $object->get_id() ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the Order's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the order refund was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'amount' => array( + 'description' => __( 'Refund amount.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'reason' => array( + 'description' => __( 'Reason for refund.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'refunded_by' => array( + 'description' => __( 'User ID of user who created the refund.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'refunded_payment' => array( + 'description' => __( 'If the payment was refunded via the API.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'line_items' => array( + 'description' => __( 'Line items data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Product ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'variation_id' => array( + 'description' => __( 'Variation ID, if applicable.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'quantity' => array( + 'description' => __( 'Quantity ordered.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tax_class' => array( + 'description' => __( 'Tax class of product.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal_tax' => array( + 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'sku' => array( + 'description' => __( 'Product SKU.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'price' => array( + 'description' => __( 'Product price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'api_refund' => array( + 'description' => __( 'When true, the payment gateway API is used to generate the refund.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'edit' ), + 'default' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + unset( $params['status'], $params['customer'], $params['product'] ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-orders-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-orders-controller.php new file mode 100644 index 0000000..20b3df8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-orders-controller.php @@ -0,0 +1,1687 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + } + + /** + * Get object. + * + * @since 3.0.0 + * @param int $id Object ID. + * @return WC_Data + */ + protected function get_object( $id ) { + return wc_get_order( $id ); + } + + /** + * Expands an order item to get its data. + * + * @param WC_Order_item $item Order item data. + * @return array + */ + protected function get_order_item_data( $item ) { + $data = $item->get_data(); + $format_decimal = array( 'subtotal', 'subtotal_tax', 'total', 'total_tax', 'tax_total', 'shipping_tax_total' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + if ( isset( $data[ $key ] ) ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); + } + } + + // Add SKU and PRICE to products. + if ( is_callable( array( $item, 'get_product' ) ) ) { + $data['sku'] = $item->get_product() ? $item->get_product()->get_sku() : null; + $data['price'] = $item->get_quantity() ? $item->get_total() / $item->get_quantity() : 0; + } + + // Format taxes. + if ( ! empty( $data['taxes']['total'] ) ) { + $taxes = array(); + + foreach ( $data['taxes']['total'] as $tax_rate_id => $tax ) { + $taxes[] = array( + 'id' => $tax_rate_id, + 'total' => $tax, + 'subtotal' => isset( $data['taxes']['subtotal'][ $tax_rate_id ] ) ? $data['taxes']['subtotal'][ $tax_rate_id ] : '', + ); + } + $data['taxes'] = $taxes; + } elseif ( isset( $data['taxes'] ) ) { + $data['taxes'] = array(); + } + + // Remove names for coupons, taxes and shipping. + if ( isset( $data['code'] ) || isset( $data['rate_code'] ) || isset( $data['method_title'] ) ) { + unset( $data['name'] ); + } + + // Remove props we don't want to expose. + unset( $data['order_id'] ); + unset( $data['type'] ); + + return $data; + } + + /** + * Get formatted item data. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data instance. + * @return array + */ + protected function get_formatted_item_data( $object ) { + $data = $object->get_data(); + $format_decimal = array( 'discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax' ); + $format_date = array( 'date_created', 'date_modified', 'date_completed', 'date_paid' ); + $format_line_items = array( 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $datetime = $data[ $key ]; + $data[ $key ] = wc_rest_prepare_date_response( $datetime, false ); + $data[ $key . '_gmt' ] = wc_rest_prepare_date_response( $datetime ); + } + + // Format the order status. + $data['status'] = 'wc-' === substr( $data['status'], 0, 3 ) ? substr( $data['status'], 3 ) : $data['status']; + + // Format line items. + foreach ( $format_line_items as $key ) { + $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); + } + + // Refunds. + $data['refunds'] = array(); + foreach ( $object->get_refunds() as $refund ) { + $data['refunds'][] = array( + 'id' => $refund->get_id(), + 'reason' => $refund->get_reason() ? $refund->get_reason() : '', + 'total' => '-' . wc_format_decimal( $refund->get_amount(), $this->request['dp'] ), + ); + } + + return array( + 'id' => $object->get_id(), + 'parent_id' => $data['parent_id'], + 'number' => $data['number'], + 'order_key' => $data['order_key'], + 'created_via' => $data['created_via'], + 'version' => $data['version'], + 'status' => $data['status'], + 'currency' => $data['currency'], + 'date_created' => $data['date_created'], + 'date_created_gmt' => $data['date_created_gmt'], + 'date_modified' => $data['date_modified'], + 'date_modified_gmt' => $data['date_modified_gmt'], + 'discount_total' => $data['discount_total'], + 'discount_tax' => $data['discount_tax'], + 'shipping_total' => $data['shipping_total'], + 'shipping_tax' => $data['shipping_tax'], + 'cart_tax' => $data['cart_tax'], + 'total' => $data['total'], + 'total_tax' => $data['total_tax'], + 'prices_include_tax' => $data['prices_include_tax'], + 'customer_id' => $data['customer_id'], + 'customer_ip_address' => $data['customer_ip_address'], + 'customer_user_agent' => $data['customer_user_agent'], + 'customer_note' => $data['customer_note'], + 'billing' => $data['billing'], + 'shipping' => $data['shipping'], + 'payment_method' => $data['payment_method'], + 'payment_method_title' => $data['payment_method_title'], + 'transaction_id' => $data['transaction_id'], + 'date_paid' => $data['date_paid'], + 'date_paid_gmt' => $data['date_paid_gmt'], + 'date_completed' => $data['date_completed'], + 'date_completed_gmt' => $data['date_completed_gmt'], + 'cart_hash' => $data['cart_hash'], + 'meta_data' => $data['meta_data'], + 'line_items' => $data['line_items'], + 'tax_lines' => $data['tax_lines'], + 'shipping_lines' => $data['shipping_lines'], + 'fee_lines' => $data['fee_lines'], + 'coupon_lines' => $data['coupon_lines'], + 'refunds' => $data['refunds'], + ); + } + + /** + * Prepare a single order output for response. + * + * @since 3.0.0 + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_object_for_response( $object, $request ) { + $this->request = $request; + $this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] ); + $data = $this->get_formatted_item_data( $object ); + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $object, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, + * refers to object type being prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return array Links for the given post. + */ + protected function prepare_links( $object, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + if ( 0 !== (int) $object->get_customer_id() ) { + $links['customer'] = array( + 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object->get_customer_id() ) ), + ); + } + + if ( 0 !== (int) $object->get_parent_id() ) { + $links['up'] = array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ), + ); + } + + return $links; + } + + /** + * Prepare objects query. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query( $request ) { + global $wpdb; + + $args = parent::prepare_objects_query( $request ); + + // Set post_status. + if ( 'any' !== $request['status'] ) { + $args['post_status'] = 'wc-' . $request['status']; + } else { + $args['post_status'] = 'any'; + } + + if ( isset( $request['customer'] ) ) { + if ( ! empty( $args['meta_query'] ) ) { + $args['meta_query'] = array(); // WPCS: slow query ok. + } + + $args['meta_query'][] = array( + 'key' => '_customer_user', + 'value' => $request['customer'], + 'type' => 'NUMERIC', + ); + } + + // Search by product. + if ( ! empty( $request['product'] ) ) { + $order_ids = $wpdb->get_col( + $wpdb->prepare( + " + SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items + WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) + AND order_item_type = 'line_item' + ", $request['product'] + ) + ); + + // Force WP_Query return empty if don't found any order. + $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); + + $args['post__in'] = $order_ids; + } + + // Search. + if ( ! empty( $args['s'] ) ) { + $order_ids = wc_order_search( $args['s'] ); + + if ( ! empty( $order_ids ) ) { + unset( $args['s'] ); + $args['post__in'] = array_merge( $order_ids, array( 0 ) ); + } + } + + /** + * Filter the query arguments for a request. + * + * Enables adding extra arguments or setting defaults for an order collection request. + * + * @param array $args Key value array of query var to query value. + * @param WP_REST_Request $request The request used. + */ + $args = apply_filters( 'woocommerce_rest_orders_prepare_object_query', $args, $request ); + + return $args; + } + + /** + * Only return writable props from schema. + * + * @param array $schema Schema. + * @return bool + */ + protected function filter_writable_props( $schema ) { + return empty( $schema['readonly'] ); + } + + /** + * Prepare a single order for create or update. + * + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data + */ + protected function prepare_object_for_database( $request, $creating = false ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $order = new WC_Order( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Handle all writable props. + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'status': + // Status change should be done later so transitions have new data. + break; + case 'billing': + case 'shipping': + $this->update_address( $order, $value, $key ); + break; + case 'line_items': + case 'shipping_lines': + case 'fee_lines': + case 'coupon_lines': + if ( is_array( $value ) ) { + foreach ( $value as $item ) { + if ( is_array( $item ) ) { + if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) { + $order->remove_item( $item['id'] ); + } else { + $this->set_item( $order, $key, $item ); + } + } + } + } + break; + case 'meta_data': + if ( is_array( $value ) ) { + foreach ( $value as $meta ) { + $order->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + break; + default: + if ( is_callable( array( $order, "set_{$key}" ) ) ) { + $order->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filters an object before it is inserted via the REST API. + * + * The dynamic portion of the hook name, `$this->post_type`, + * refers to the object type slug. + * + * @param WC_Data $order Object object. + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $order, $request, $creating ); + } + + /** + * Save an object data. + * + * @since 3.0.0 + * @throws WC_REST_Exception But all errors are validated before returning any data. + * @param WP_REST_Request $request Full details about the request. + * @param bool $creating If is creating a new object. + * @return WC_Data|WP_Error + */ + protected function save_object( $request, $creating = false ) { + try { + $object = $this->prepare_object_for_database( $request, $creating ); + + if ( is_wp_error( $object ) ) { + return $object; + } + + // Make sure gateways are loaded so hooks from gateways fire on save/create. + WC()->payment_gateways(); + + if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] ) { + // Make sure customer exists. + if ( false === get_user_by( 'id', $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + // Make sure customer is part of blog. + if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network', __( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 ); + } + } + + if ( $creating ) { + $object->set_created_via( 'rest-api' ); + $object->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) ); + $object->calculate_totals(); + } else { + // If items have changed, recalculate order totals. + if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { + $object->calculate_totals( true ); + } + } + + // Set status. + if ( ! empty( $request['status'] ) ) { + $object->set_status( $request['status'] ); + } + + $object->save(); + + // Actions for after the order is saved. + if ( true === $request['set_paid'] ) { + if ( $creating || $object->needs_payment() ) { + $object->payment_complete( $request['transaction_id'] ); + } + } + + return $this->get_object( $object->get_id() ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Update address. + * + * @param WC_Order $order Order data. + * @param array $posted Posted data. + * @param string $type Address type. + */ + protected function update_address( $order, $posted, $type = 'billing' ) { + foreach ( $posted as $key => $value ) { + if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) { + $order->{"set_{$type}_{$key}"}( $value ); + } + } + } + + /** + * Gets the product ID from the SKU or posted ID. + * + * @throws WC_REST_Exception When SKU or ID is not valid. + * @param array $posted Request data. + * @return int + */ + protected function get_product_id( $posted ) { + if ( ! empty( $posted['sku'] ) ) { + $product_id = (int) wc_get_product_id_by_sku( $posted['sku'] ); + } elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) { + $product_id = (int) $posted['product_id']; + } elseif ( ! empty( $posted['variation_id'] ) ) { + $product_id = (int) $posted['variation_id']; + } else { + throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 ); + } + return $product_id; + } + + /** + * Maybe set an item prop if the value was posted. + * + * @param WC_Order_Item $item Order item. + * @param string $prop Order property. + * @param array $posted Request data. + */ + protected function maybe_set_item_prop( $item, $prop, $posted ) { + if ( isset( $posted[ $prop ] ) ) { + $item->{"set_$prop"}( $posted[ $prop ] ); + } + } + + /** + * Maybe set item props if the values were posted. + * + * @param WC_Order_Item $item Order item data. + * @param string[] $props Properties. + * @param array $posted Request data. + */ + protected function maybe_set_item_props( $item, $props, $posted ) { + foreach ( $props as $prop ) { + $this->maybe_set_item_prop( $item, $prop, $posted ); + } + } + + /** + * Maybe set item meta if posted. + * + * @param WC_Order_Item $item Order item data. + * @param array $posted Request data. + */ + protected function maybe_set_item_meta_data( $item, $posted ) { + if ( ! empty( $posted['meta_data'] ) && is_array( $posted['meta_data'] ) ) { + foreach ( $posted['meta_data'] as $meta ) { + if ( isset( $meta['key'] ) ) { + $value = isset( $meta['value'] ) ? $meta['value'] : null; + $item->update_meta_data( $meta['key'], $value, isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + } + } + + /** + * Create or update a line item. + * + * @param array $posted Line item data. + * @param string $action 'create' to add line item or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Product + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_line_items( $posted, $action = 'create', $item = null ) { + $item = is_null( $item ) ? new WC_Order_Item_Product( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; + $product = wc_get_product( $this->get_product_id( $posted ) ); + + if ( $product !== $item->get_product() ) { + $item->set_product( $product ); + + if ( 'create' === $action ) { + $quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1; + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) ); + $item->set_total( $total ); + $item->set_subtotal( $total ); + } + } + + $this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted ); + $this->maybe_set_item_meta_data( $item, $posted ); + + return $item; + } + + /** + * Create or update an order shipping method. + * + * @param array $posted $shipping Item data. + * @param string $action 'create' to add shipping or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Shipping + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_shipping_lines( $posted, $action = 'create', $item = null ) { + $item = is_null( $item ) ? new WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; + + if ( 'create' === $action ) { + if ( empty( $posted['method_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total' ), $posted ); + $this->maybe_set_item_meta_data( $item, $posted ); + + return $item; + } + + /** + * Create or update an order fee. + * + * @param array $posted Item data. + * @param string $action 'create' to add fee or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Fee + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_fee_lines( $posted, $action = 'create', $item = null ) { + $item = is_null( $item ) ? new WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; + + if ( 'create' === $action ) { + if ( empty( $posted['name'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'name', 'tax_class', 'tax_status', 'total' ), $posted ); + $this->maybe_set_item_meta_data( $item, $posted ); + + return $item; + } + + /** + * Create or update an order coupon. + * + * @param array $posted Item data. + * @param string $action 'create' to add coupon or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Coupon + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_coupon_lines( $posted, $action = 'create', $item = null ) { + $item = is_null( $item ) ? new WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' ) : $item; + + if ( 'create' === $action ) { + if ( empty( $posted['code'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'code', 'discount' ), $posted ); + $this->maybe_set_item_meta_data( $item, $posted ); + + return $item; + } + + /** + * Wrapper method to create/update order items. + * When updating, the item ID provided is checked to ensure it is associated + * with the order. + * + * @param WC_Order $order order object. + * @param string $item_type The item type. + * @param array $posted item provided in the request body. + * @throws WC_REST_Exception If item ID is not associated with order. + */ + protected function set_item( $order, $item_type, $posted ) { + global $wpdb; + + if ( ! empty( $posted['id'] ) ) { + $action = 'update'; + } else { + $action = 'create'; + } + + $method = 'prepare_' . $item_type; + $item = null; + + // Verify provided line item ID is associated with order. + if ( 'update' === $action ) { + $item = $order->get_item( absint( $posted['id'] ), false ); + + if ( ! $item ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 ); + } + } + + // Prepare item data. + $item = $this->$method( $posted, $action, $item ); + + do_action( 'woocommerce_rest_set_order_item', $item, $posted ); + + // If creating the order, add the item to it. + if ( 'create' === $action ) { + $order->add_item( $item ); + } else { + $item->save(); + } + } + + /** + * Helper method to check if the resource ID associated with the provided item is null. + * Items can be deleted by setting the resource ID to null. + * + * @param array $item Item provided in the request body. + * @return bool True if the item resource ID is null, false otherwise. + */ + protected function item_is_null( $item ) { + $keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' ); + + foreach ( $keys as $key ) { + if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { + return true; + } + } + + return false; + } + + /** + * Get order statuses without prefixes. + * + * @return array + */ + protected function get_order_statuses() { + $order_statuses = array(); + + foreach ( array_keys( wc_get_order_statuses() ) as $status ) { + $order_statuses[] = str_replace( 'wc-', '', $status ); + } + + return $order_statuses; + } + + /** + * Get the Order's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'parent_id' => array( + 'description' => __( 'Parent order ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'number' => array( + 'description' => __( 'Order number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'order_key' => array( + 'description' => __( 'Order key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'created_via' => array( + 'description' => __( 'Shows where the order was created.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'version' => array( + 'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'status' => array( + 'description' => __( 'Order status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'pending', + 'enum' => $this->get_order_statuses(), + 'context' => array( 'view', 'edit' ), + ), + 'currency' => array( + 'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ), + 'type' => 'string', + 'default' => get_woocommerce_currency(), + 'enum' => array_keys( get_woocommerce_currencies() ), + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the order was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the order was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the order was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the order was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'discount_total' => array( + 'description' => __( 'Total discount amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'discount_tax' => array( + 'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_total' => array( + 'description' => __( 'Total shipping amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_tax' => array( + 'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'cart_tax' => array( + 'description' => __( 'Sum of line item taxes only.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Grand total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_tax' => array( + 'description' => __( 'Sum of all taxes.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'prices_include_tax' => array( + 'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_id' => array( + 'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ), + 'type' => 'integer', + 'default' => 0, + 'context' => array( 'view', 'edit' ), + ), + 'customer_ip_address' => array( + 'description' => __( "Customer's IP address.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_user_agent' => array( + 'description' => __( 'User agent of the customer.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_note' => array( + 'description' => __( 'Note left by customer during checkout.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'billing' => array( + 'description' => __( 'Billing address.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Email address.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'phone' => array( + 'description' => __( 'Phone number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping' => array( + 'description' => __( 'Shipping address.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'payment_method' => array( + 'description' => __( 'Payment method ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'payment_method_title' => array( + 'description' => __( 'Payment method title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'transaction_id' => array( + 'description' => __( 'Unique transaction ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_paid' => array( + 'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_paid_gmt' => array( + 'description' => __( 'The date the order was paid, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_completed' => array( + 'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_completed_gmt' => array( + 'description' => __( 'The date the order was completed, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'cart_hash' => array( + 'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'line_items' => array( + 'description' => __( 'Line items data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'product_id' => array( + 'description' => __( 'Product ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'variation_id' => array( + 'description' => __( 'Variation ID, if applicable.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'quantity' => array( + 'description' => __( 'Quantity ordered.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class of product.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'subtotal' => array( + 'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'subtotal_tax' => array( + 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'sku' => array( + 'description' => __( 'Product SKU.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'price' => array( + 'description' => __( 'Product price.', 'woocommerce' ), + 'type' => 'number', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'tax_lines' => array( + 'description' => __( 'Tax lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rate_code' => array( + 'description' => __( 'Tax rate code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rate_id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'Tax rate label.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'compound' => array( + 'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tax_total' => array( + 'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_tax_total' => array( + 'description' => __( 'Shipping tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ), + ), + 'shipping_lines' => array( + 'description' => __( 'Shipping lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'method_title' => array( + 'description' => __( 'Shipping method name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'method_id' => array( + 'description' => __( 'Shipping method ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ), + ), + 'fee_lines' => array( + 'description' => __( 'Fee lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Fee name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class of fee.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status of fee.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'enum' => array( 'taxable', 'none' ), + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ), + ), + 'coupon_lines' => array( + 'description' => __( 'Coupons line data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'discount' => array( + 'description' => __( 'Discount total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'discount_tax' => array( + 'description' => __( 'Discount total tax.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ), + ), + 'refunds' => array( + 'description' => __( 'List of refunds.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Refund ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'reason' => array( + 'description' => __( 'Refund reason.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Refund total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'set_paid' => array( + 'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['status'] = array( + 'default' => 'any', + 'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_merge( array( 'any' ), $this->get_order_statuses() ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['customer'] = array( + 'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['product'] = array( + 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['dp'] = array( + 'default' => wc_get_price_decimals(), + 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-payment-gateways-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-payment-gateways-controller.php new file mode 100644 index 0000000..89f6a69 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-payment-gateways-controller.php @@ -0,0 +1,466 @@ + + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\w-]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Check whether a given request has permission to view payment gateways. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check if a given request has access to read a payment gateway. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check whether a given request has permission to edit payment gateways. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'payment_gateways', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Get payment gateways. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $payment_gateways = WC()->payment_gateways->payment_gateways(); + $response = array(); + foreach ( $payment_gateways as $payment_gateway_id => $payment_gateway ) { + $payment_gateway->id = $payment_gateway_id; + $gateway = $this->prepare_item_for_response( $payment_gateway, $request ); + $gateway = $this->prepare_response_for_collection( $gateway ); + $response[] = $gateway; + } + return rest_ensure_response( $response ); + } + + /** + * Get a single payment gateway. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_item( $request ) { + $gateway = $this->get_gateway( $request ); + + if ( is_null( $gateway ) ) { + return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $gateway = $this->prepare_item_for_response( $gateway, $request ); + return rest_ensure_response( $gateway ); + } + + /** + * Update A Single Payment Method. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function update_item( $request ) { + $gateway = $this->get_gateway( $request ); + + if ( is_null( $gateway ) ) { + return new WP_Error( 'woocommerce_rest_payment_gateway_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + // Get settings. + $gateway->init_form_fields(); + $settings = $gateway->settings; + + // Update settings. + if ( isset( $request['settings'] ) ) { + $errors_found = false; + foreach ( $gateway->form_fields as $key => $field ) { + if ( isset( $request['settings'][ $key ] ) ) { + if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { + $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); + } else { + $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); + } + if ( is_wp_error( $value ) ) { + $errors_found = true; + break; + } + $settings[ $key ] = $value; + } + } + + if ( $errors_found ) { + return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); + } + } + + // Update if this method is enabled or not. + if ( isset( $request['enabled'] ) ) { + $settings['enabled'] = wc_bool_to_string( $request['enabled'] ); + $gateway->enabled = $settings['enabled']; + } + + // Update title. + if ( isset( $request['title'] ) ) { + $settings['title'] = $request['title']; + $gateway->title = $settings['title']; + } + + // Update description. + if ( isset( $request['description'] ) ) { + $settings['description'] = $request['description']; + $gateway->description = $settings['description']; + } + + // Update options. + $gateway->settings = $settings; + update_option( $gateway->get_option_key(), apply_filters( 'woocommerce_gateway_' . $gateway->id . '_settings_values', $settings, $gateway ) ); + + // Update order. + if ( isset( $request['order'] ) ) { + $order = (array) get_option( 'woocommerce_gateway_order' ); + $order[ $gateway->id ] = $request['order']; + update_option( 'woocommerce_gateway_order', $order ); + $gateway->order = absint( $request['order'] ); + } + + $gateway = $this->prepare_item_for_response( $gateway, $request ); + return rest_ensure_response( $gateway ); + } + + /** + * Get a gateway based on the current request object. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|null + */ + public function get_gateway( $request ) { + $gateway = null; + $payment_gateways = WC()->payment_gateways->payment_gateways(); + foreach ( $payment_gateways as $payment_gateway_id => $payment_gateway ) { + if ( $request['id'] !== $payment_gateway_id ) { + continue; + } + $payment_gateway->id = $payment_gateway_id; + $gateway = $payment_gateway; + } + return $gateway; + } + + /** + * Prepare a payment gateway for response. + * + * @param WC_Payment_Gateway $gateway Payment gateway object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $gateway, $request ) { + $order = (array) get_option( 'woocommerce_gateway_order' ); + $item = array( + 'id' => $gateway->id, + 'title' => $gateway->title, + 'description' => $gateway->description, + 'order' => isset( $order[ $gateway->id ] ) ? $order[ $gateway->id ] : '', + 'enabled' => ( 'yes' === $gateway->enabled ), + 'method_title' => $gateway->get_method_title(), + 'method_description' => $gateway->get_method_description(), + 'settings' => $this->get_settings( $gateway ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $item, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $gateway, $request ) ); + + /** + * Filter payment gateway objects returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WC_Payment_Gateway $gateway Payment gateway object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_payment_gateway', $response, $gateway, $request ); + } + + /** + * Return settings associated with this payment gateway. + * + * @param WC_Payment_Gateway $gateway Gateway data. + * + * @return array + */ + public function get_settings( $gateway ) { + $settings = array(); + $gateway->init_form_fields(); + foreach ( $gateway->form_fields as $id => $field ) { + // Make sure we at least have a title and type. + if ( empty( $field['title'] ) || empty( $field['type'] ) ) { + continue; + } + // Ignore 'title' settings/fields -- they are UI only. + if ( 'title' === $field['type'] ) { + continue; + } + // Ignore 'enabled' and 'description' which get included elsewhere. + if ( in_array( $id, array( 'enabled', 'description' ), true ) ) { + continue; + } + $data = array( + 'id' => $id, + 'label' => empty( $field['label'] ) ? $field['title'] : $field['label'], + 'description' => empty( $field['description'] ) ? '' : $field['description'], + 'type' => $field['type'], + 'value' => empty( $gateway->settings[ $id ] ) ? '' : $gateway->settings[ $id ], + 'default' => empty( $field['default'] ) ? '' : $field['default'], + 'tip' => empty( $field['description'] ) ? '' : $field['description'], + 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], + ); + if ( ! empty( $field['options'] ) ) { + $data['options'] = $field['options']; + } + $settings[ $id ] = $data; + } + return $settings; + } + + /** + * Prepare links for the request. + * + * @param WC_Payment_Gateway $gateway Payment gateway object. + * @param WP_REST_Request $request Request object. + * @return array + */ + protected function prepare_links( $gateway, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $gateway->id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the payment gateway schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'payment_gateway', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Payment gateway ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'title' => array( + 'description' => __( 'Payment gateway title on checkout.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'Payment gateway description on checkout.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'order' => array( + 'description' => __( 'Payment gateway sort order.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'absint', + ), + ), + 'enabled' => array( + 'description' => __( 'Payment gateway enabled status.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + ), + 'method_title' => array( + 'description' => __( 'Payment gateway method title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'method_description' => array( + 'description' => __( 'Payment gateway method description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'settings' => array( + 'description' => __( 'Payment gateway settings.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'A unique identifier for the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'type' => array( + 'description' => __( 'Type of setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Setting value.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'default' => array( + 'description' => __( 'Default value for the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tip' => array( + 'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'placeholder' => array( + 'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get any query params needed. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attribute-terms-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attribute-terms-controller.php new file mode 100644 index 0000000..6d844ec --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attribute-terms-controller.php @@ -0,0 +1,27 @@ +/terms endpoint. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Product Attribute Terms controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Product_Attribute_Terms_V1_Controller + */ +class WC_REST_Product_Attribute_Terms_Controller extends WC_REST_Product_Attribute_Terms_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attributes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attributes-controller.php new file mode 100644 index 0000000..2ab1736 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-attributes-controller.php @@ -0,0 +1,27 @@ +term_id, 'display_type' ); + + // Get category order. + $menu_order = get_woocommerce_term_meta( $item->term_id, 'order' ); + + $data = array( + 'id' => (int) $item->term_id, + 'name' => $item->name, + 'slug' => $item->slug, + 'parent' => (int) $item->parent, + 'description' => $item->description, + 'display' => $display_type ? $display_type : 'default', + 'image' => null, + 'menu_order' => (int) $menu_order, + 'count' => (int) $item->count, + ); + + // Get category image. + $image_id = get_woocommerce_term_meta( $item->term_id, 'thumbnail_id' ); + if ( $image_id ) { + $attachment = get_post( $image_id ); + + $data['image'] = array( + 'id' => (int) $image_id, + 'date_created' => wc_rest_prepare_date_response( $attachment->post_date ), + 'date_created_gmt' => wc_rest_prepare_date_response( $attachment->post_date_gmt ), + 'date_modified' => wc_rest_prepare_date_response( $attachment->post_modified ), + 'date_modified_gmt' => wc_rest_prepare_date_response( $attachment->post_modified_gmt ), + 'src' => wp_get_attachment_url( $image_id ), + 'title' => get_the_title( $attachment ), + 'alt' => get_post_meta( $image_id, '_wp_attachment_image_alt', true ), + ); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item, $request ) ); + + /** + * Filter a term item returned from the API. + * + * Allows modification of the term data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original term object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); + } + + /** + * Get the Category schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->taxonomy, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Category name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'parent' => array( + 'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'HTML description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wp_filter_post_kses', + ), + ), + 'display' => array( + 'description' => __( 'Category archive display type.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'default', + 'enum' => array( 'default', 'products', 'subcategories', 'both' ), + 'context' => array( 'view', 'edit' ), + ), + 'image' => array( + 'description' => __( 'Image data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'title' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'count' => array( + 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-reviews-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-reviews-controller.php new file mode 100644 index 0000000..47b2de9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-reviews-controller.php @@ -0,0 +1,199 @@ +/reviews. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Product Reviews Controller Class. + * + * @package WooCommerce/API + * @extends WC_REST_Product_Reviews_V1_Controller + */ +class WC_REST_Product_Reviews_Controller extends WC_REST_Product_Reviews_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'products/(?P[\d]+)/reviews'; + + /** + * Register the routes for product reviews. + */ + public function register_routes() { + parent::register_routes(); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + } + + /** + * Check if a given request has access to batch manage product reviews. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function batch_items_permissions_check( $request ) { + if ( ! wc_rest_check_post_permissions( 'product', 'batch' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Prepare a single product review output for response. + * + * @param WP_Comment $review Product review object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $review, $request ) { + $data = array( + 'id' => (int) $review->comment_ID, + 'date_created' => wc_rest_prepare_date_response( $review->comment_date ), + 'date_created_gmt' => wc_rest_prepare_date_response( $review->comment_date_gmt ), + 'review' => $review->comment_content, + 'rating' => (int) get_comment_meta( $review->comment_ID, 'rating', true ), + 'name' => $review->comment_author, + 'email' => $review->comment_author_email, + 'verified' => wc_review_is_from_verified_owner( $review->comment_ID ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $review, $request ) ); + + /** + * Filter product reviews object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_Comment $review Product review object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_product_review', $response, $review, $request ); + } + + + /** + * Bulk create, update and delete items. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array Of WP_Error or WP_REST_Response. + */ + public function batch_items( $request ) { + $items = array_filter( $request->get_params() ); + $params = $request->get_url_params(); + $product_id = $params['product_id']; + $body_params = array(); + + foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) { + if ( ! empty( $items[ $batch_type ] ) ) { + $injected_items = array(); + foreach ( $items[ $batch_type ] as $item ) { + $injected_items[] = is_array( $item ) ? array_merge( array( 'product_id' => $product_id ), $item ) : $item; + } + $body_params[ $batch_type ] = $injected_items; + } + } + + $request = new WP_REST_Request( $request->get_method() ); + $request->set_body_params( $body_params ); + + return parent::batch_items( $request ); + } + + /** + * Get the Product Review's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'product_review', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'review' => array( + 'description' => __( 'The content of the review.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the review was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'rating' => array( + 'description' => __( 'Review rating (0 to 5).', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Reviewer name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Reviewer email.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'verified' => array( + 'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-shipping-classes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-shipping-classes-controller.php new file mode 100644 index 0000000..daf3d1b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-shipping-classes-controller.php @@ -0,0 +1,27 @@ +/variations endpoints. + * + * @package WooCommerce\API + * @since 3.0.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API variations controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Products_Controller + */ +class WC_REST_Product_Variations_Controller extends WC_REST_Products_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'products/(?P[\d]+)/variations'; + + /** + * Post type. + * + * @var string + */ + protected $post_type = 'product_variation'; + + /** + * Initialize product actions (parent). + */ + public function __construct() { + add_filter( "woocommerce_rest_{$this->post_type}_query", array( $this, 'add_product_id' ), 9, 2 ); + parent::__construct(); + } + + /** + * Register the routes for products. + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the variation.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( + array( + 'default' => 'view', + ) + ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + } + + /** + * Get object. + * + * @since 3.0.0 + * @param int $id Object ID. + * @return WC_Data + */ + protected function get_object( $id ) { + return wc_get_product( $id ); + } + + /** + * Check if a given request has access to update an item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_item_permissions_check( $request ) { + $object = $this->get_object( (int) $request['id'] ); + + if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $object->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + // Check if variation belongs to the correct parent product. + if ( $object && 0 !== $object->get_parent_id() && absint( $request['product_id'] ) !== $object->get_parent_id() ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Parent product does not match current variation.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Prepare a single variation output for response. + * + * @since 3.0.0 + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_object_for_response( $object, $request ) { + $data = array( + 'id' => $object->get_id(), + 'date_created' => wc_rest_prepare_date_response( $object->get_date_created(), false ), + 'date_created_gmt' => wc_rest_prepare_date_response( $object->get_date_created() ), + 'date_modified' => wc_rest_prepare_date_response( $object->get_date_modified(), false ), + 'date_modified_gmt' => wc_rest_prepare_date_response( $object->get_date_modified() ), + 'description' => wc_format_content( $object->get_description() ), + 'permalink' => $object->get_permalink(), + 'sku' => $object->get_sku(), + 'price' => $object->get_price(), + 'regular_price' => $object->get_regular_price(), + 'sale_price' => $object->get_sale_price(), + 'date_on_sale_from' => wc_rest_prepare_date_response( $object->get_date_on_sale_from(), false ), + 'date_on_sale_from_gmt' => wc_rest_prepare_date_response( $object->get_date_on_sale_from() ), + 'date_on_sale_to' => wc_rest_prepare_date_response( $object->get_date_on_sale_to(), false ), + 'date_on_sale_to_gmt' => wc_rest_prepare_date_response( $object->get_date_on_sale_to() ), + 'on_sale' => $object->is_on_sale(), + 'visible' => $object->is_visible(), + 'purchasable' => $object->is_purchasable(), + 'virtual' => $object->is_virtual(), + 'downloadable' => $object->is_downloadable(), + 'downloads' => $this->get_downloads( $object ), + 'download_limit' => '' !== $object->get_download_limit() ? (int) $object->get_download_limit() : -1, + 'download_expiry' => '' !== $object->get_download_expiry() ? (int) $object->get_download_expiry() : -1, + 'tax_status' => $object->get_tax_status(), + 'tax_class' => $object->get_tax_class(), + 'manage_stock' => $object->managing_stock(), + 'stock_quantity' => $object->get_stock_quantity(), + 'in_stock' => $object->is_in_stock(), + 'backorders' => $object->get_backorders(), + 'backorders_allowed' => $object->backorders_allowed(), + 'backordered' => $object->is_on_backorder(), + 'weight' => $object->get_weight(), + 'dimensions' => array( + 'length' => $object->get_length(), + 'width' => $object->get_width(), + 'height' => $object->get_height(), + ), + 'shipping_class' => $object->get_shipping_class(), + 'shipping_class_id' => $object->get_shipping_class_id(), + 'image' => current( $this->get_images( $object ) ), + 'attributes' => $this->get_attributes( $object ), + 'menu_order' => $object->get_menu_order(), + 'meta_data' => $object->get_meta_data(), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $object, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, + * refers to object type being prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); + } + + /** + * Prepare objects query. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query( $request ) { + $args = parent::prepare_objects_query( $request ); + + $args['post_parent'] = $request['product_id']; + + return $args; + } + + /** + * Prepare a single variation for create or update. + * + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data + */ + protected function prepare_object_for_database( $request, $creating = false ) { + if ( isset( $request['id'] ) ) { + $variation = wc_get_product( absint( $request['id'] ) ); + } else { + $variation = new WC_Product_Variation(); + } + + // Update parent ID just once. + if ( 0 === $variation->get_parent_id() ) { + $variation->set_parent_id( absint( $request['product_id'] ) ); + } + + // Status. + if ( isset( $request['visible'] ) ) { + $variation->set_status( false === $request['visible'] ? 'private' : 'publish' ); + } + + // SKU. + if ( isset( $request['sku'] ) ) { + $variation->set_sku( wc_clean( $request['sku'] ) ); + } + + // Thumbnail. + if ( isset( $request['image'] ) ) { + if ( is_array( $request['image'] ) && ! empty( $request['image'] ) ) { + $image = $request['image']; + if ( is_array( $image ) ) { + $image['position'] = 0; + } + + $variation = $this->set_product_images( $variation, array( $image ) ); + } else { + $variation->set_image_id( '' ); + } + } + + // Virtual variation. + if ( isset( $request['virtual'] ) ) { + $variation->set_virtual( $request['virtual'] ); + } + + // Downloadable variation. + if ( isset( $request['downloadable'] ) ) { + $variation->set_downloadable( $request['downloadable'] ); + } + + // Downloads. + if ( $variation->get_downloadable() ) { + // Downloadable files. + if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) { + $variation = $this->save_downloadable_files( $variation, $request['downloads'] ); + } + + // Download limit. + if ( isset( $request['download_limit'] ) ) { + $variation->set_download_limit( $request['download_limit'] ); + } + + // Download expiry. + if ( isset( $request['download_expiry'] ) ) { + $variation->set_download_expiry( $request['download_expiry'] ); + } + } + + // Shipping data. + $variation = $this->save_product_shipping_data( $variation, $request ); + + // Stock handling. + if ( isset( $request['manage_stock'] ) ) { + if ( 'parent' === $request['manage_stock'] ) { + $variation->set_manage_stock( false ); // This just indicates the variation does not manage stock, but the parent does. + } else { + $variation->set_manage_stock( wc_string_to_bool( $request['manage_stock'] ) ); + } + } + + if ( isset( $request['in_stock'] ) ) { + $variation->set_stock_status( true === $request['in_stock'] ? 'instock' : 'outofstock' ); + } + + if ( isset( $request['backorders'] ) ) { + $variation->set_backorders( $request['backorders'] ); + } + + if ( $variation->get_manage_stock() ) { + if ( isset( $request['stock_quantity'] ) ) { + $variation->set_stock_quantity( $request['stock_quantity'] ); + } elseif ( isset( $request['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $variation->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); + $variation->set_stock_quantity( $stock_quantity ); + } + } else { + $variation->set_backorders( 'no' ); + $variation->set_stock_quantity( '' ); + } + + // Regular Price. + if ( isset( $request['regular_price'] ) ) { + $variation->set_regular_price( $request['regular_price'] ); + } + + // Sale Price. + if ( isset( $request['sale_price'] ) ) { + $variation->set_sale_price( $request['sale_price'] ); + } + + if ( isset( $request['date_on_sale_from'] ) ) { + $variation->set_date_on_sale_from( $request['date_on_sale_from'] ); + } + + if ( isset( $request['date_on_sale_from_gmt'] ) ) { + $variation->set_date_on_sale_from( $request['date_on_sale_from_gmt'] ? strtotime( $request['date_on_sale_from_gmt'] ) : null ); + } + + if ( isset( $request['date_on_sale_to'] ) ) { + $variation->set_date_on_sale_to( $request['date_on_sale_to'] ); + } + + if ( isset( $request['date_on_sale_to_gmt'] ) ) { + $variation->set_date_on_sale_to( $request['date_on_sale_to_gmt'] ? strtotime( $request['date_on_sale_to_gmt'] ) : null ); + } + + // Tax class. + if ( isset( $request['tax_class'] ) ) { + $variation->set_tax_class( $request['tax_class'] ); + } + + // Description. + if ( isset( $request['description'] ) ) { + $variation->set_description( wp_kses_post( $request['description'] ) ); + } + + // Update taxonomies. + if ( isset( $request['attributes'] ) ) { + $attributes = array(); + $parent = wc_get_product( $variation->get_parent_id() ); + $parent_attributes = $parent->get_attributes(); + + foreach ( $request['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $raw_attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $raw_attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $raw_attribute_name ) { + continue; + } + + $attribute_name = sanitize_title( $raw_attribute_name ); + + if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { + continue; + } + + $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); + $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + + if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $attribute_value, $raw_attribute_name ); // @codingStandardsIgnoreLine + + if ( $term && ! is_wp_error( $term ) ) { + $attribute_value = $term->slug; + } else { + $attribute_value = sanitize_title( $attribute_value ); + } + } + + $attributes[ $attribute_key ] = $attribute_value; + } + + $variation->set_attributes( $attributes ); + } + + // Menu order. + if ( $request['menu_order'] ) { + $variation->set_menu_order( $request['menu_order'] ); + } + + // Meta data. + if ( is_array( $request['meta_data'] ) ) { + foreach ( $request['meta_data'] as $meta ) { + $variation->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + + /** + * Filters an object before it is inserted via the REST API. + * + * The dynamic portion of the hook name, `$this->post_type`, + * refers to the object type slug. + * + * @param WC_Data $variation Object object. + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $variation, $request, $creating ); + } + + /** + * Clear caches here so in sync with any new variations. + * + * @param WC_Data $object Object data. + */ + public function clear_transients( $object ) { + wc_delete_product_transients( $object->get_parent_id() ); + wp_cache_delete( 'product-' . $object->get_parent_id(), 'products' ); + } + + /** + * Delete a variation. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error|WP_REST_Response + */ + public function delete_item( $request ) { + $force = (bool) $request['force']; + $object = $this->get_object( (int) $request['id'] ); + $result = false; + + if ( ! $object || 0 === $object->get_id() ) { + return new WP_Error( + "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( + 'status' => 404, + ) + ); + } + + $supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) ); + + /** + * Filter whether an object is trashable. + * + * Return false to disable trash support for the object. + * + * @param boolean $supports_trash Whether the object type support trashing. + * @param WC_Data $object The object being considered for trashing support. + */ + $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object ); + + if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) { + return new WP_Error( + /* translators: %s: post type */ + "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( + 'status' => rest_authorization_required_code(), + ) + ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_object_for_response( $object, $request ); + + // If we're forcing, then delete permanently. + if ( $force ) { + $object->delete( true ); + $result = 0 === $object->get_id(); + } else { + // If we don't support trashing for this type, error out. + if ( ! $supports_trash ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( + 'status' => 501, + ) + ); + } + + // Otherwise, only trash if we haven't already. + if ( is_callable( array( $object, 'get_status' ) ) ) { + if ( 'trash' === $object->get_status() ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( + 'status' => 410, + ) + ); + } + + $object->delete(); + $result = 'trash' === $object->get_status(); + } + } + + if ( ! $result ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( + 'status' => 500, + ) + ); + } + + // Delete parent product transients. + if ( 0 !== $object->get_parent_id() ) { + wc_delete_product_transients( $object->get_parent_id() ); + } + + /** + * Fires after a single object is deleted or trashed via the REST API. + * + * @param WC_Data $object The deleted or trashed object. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( "woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request ); + + return $response; + } + + /** + * Bulk create, update and delete items. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array Of WP_Error or WP_REST_Response. + */ + public function batch_items( $request ) { + $items = array_filter( $request->get_params() ); + $params = $request->get_url_params(); + $product_id = $params['product_id']; + $body_params = array(); + + foreach ( array( 'update', 'create', 'delete' ) as $batch_type ) { + if ( ! empty( $items[ $batch_type ] ) ) { + $injected_items = array(); + foreach ( $items[ $batch_type ] as $item ) { + $injected_items[] = is_array( $item ) ? array_merge( + array( + 'product_id' => $product_id, + ), $item + ) : $item; + } + $body_params[ $batch_type ] = $injected_items; + } + } + + $request = new WP_REST_Request( $request->get_method() ); + $request->set_body_params( $body_params ); + + return parent::batch_items( $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return array Links for the given post. + */ + protected function prepare_links( $object, $request ) { + $product_id = (int) $request['product_id']; + $base = str_replace( '(?P[\d]+)', $product_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $object->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $product_id ) ), + ), + ); + return $links; + } + + /** + * Get the Variation's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $weight_unit = get_option( 'woocommerce_weight_unit' ); + $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'Variation description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'permalink' => array( + 'description' => __( 'Variation URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sku' => array( + 'description' => __( 'Unique identifier.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'price' => array( + 'description' => __( 'Current variation price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'regular_price' => array( + 'description' => __( 'Variation regular price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sale_price' => array( + 'description' => __( 'Variation sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from' => array( + 'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from_gmt' => array( + 'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to' => array( + 'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to_gmt' => array( + 'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'on_sale' => array( + 'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'visible' => array( + 'description' => __( "Define if the variation is visible on the product's page.", 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'purchasable' => array( + 'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'virtual' => array( + 'description' => __( 'If the variation is virtual.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloadable' => array( + 'description' => __( 'If the variation is downloadable.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloads' => array( + 'description' => __( 'List of downloadable files.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'File MD5 hash.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'download_limit' => array( + 'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'download_expiry' => array( + 'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'taxable', + 'enum' => array( 'taxable', 'shipping', 'none' ), + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'manage_stock' => array( + 'description' => __( 'Stock management at variation level.', 'woocommerce' ), + 'type' => 'mixed', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'stock_quantity' => array( + 'description' => __( 'Stock quantity.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'in_stock' => array( + 'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'backorders' => array( + 'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'no', + 'enum' => array( 'no', 'notify', 'yes' ), + 'context' => array( 'view', 'edit' ), + ), + 'backorders_allowed' => array( + 'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'backordered' => array( + 'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'weight' => array( + /* translators: %s: weight unit */ + 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'dimensions' => array( + 'description' => __( 'Variation dimensions.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'length' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'width' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'height' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping_class' => array( + 'description' => __( 'Shipping class slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'shipping_class_id' => array( + 'description' => __( 'Shipping class ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'image' => array( + 'description' => __( 'Variation image data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'attributes' => array( + 'description' => __( 'List of attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'option' => array( + 'description' => __( 'Selected attribute term name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-products-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-products-controller.php new file mode 100644 index 0000000..1f2af73 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-products-controller.php @@ -0,0 +1,2145 @@ +post_type}_object", array( $this, 'clear_transients' ) ); + } + + /** + * Register the routes for products. + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( + array( + 'default' => 'view', + ) + ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + 'type' => 'boolean', + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + } + + /** + * Get object. + * + * @since 3.0.0 + * @param int $id Object ID. + * @return WC_Data + */ + protected function get_object( $id ) { + return wc_get_product( $id ); + } + + /** + * Prepare a single product output for response. + * + * @since 3.0.0 + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_object_for_response( $object, $request ) { + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->get_product_data( $object, $context ); + + // Add variations to variable products. + if ( $object->is_type( 'variable' ) && $object->has_child() ) { + $data['variations'] = $object->get_children(); + } + + // Add grouped products data. + if ( $object->is_type( 'grouped' ) && $object->has_child() ) { + $data['grouped_products'] = $object->get_children(); + } + + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $object, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, + * refers to object type being prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request ); + } + + /** + * Prepare objects query. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query( $request ) { + $args = parent::prepare_objects_query( $request ); + + // Set post_status. + $args['post_status'] = $request['status']; + + // Taxonomy query to filter products by type, category, + // tag, shipping class, and attribute. + $tax_query = array(); + + // Map between taxonomy name and arg's key. + $taxonomies = array( + 'product_cat' => 'category', + 'product_tag' => 'tag', + 'product_shipping_class' => 'shipping_class', + ); + + // Set tax_query for each passed arg. + foreach ( $taxonomies as $taxonomy => $key ) { + if ( ! empty( $request[ $key ] ) ) { + $tax_query[] = array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'terms' => $request[ $key ], + ); + } + } + + // Filter product type by slug. + if ( ! empty( $request['type'] ) ) { + $tax_query[] = array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $request['type'], + ); + } + + // Filter by attribute and term. + if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) { + if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) { + $tax_query[] = array( + 'taxonomy' => $request['attribute'], + 'field' => 'term_id', + 'terms' => $request['attribute_term'], + ); + } + } + + if ( ! empty( $tax_query ) ) { + $args['tax_query'] = $tax_query; // WPCS: slow query ok. + } + + // Filter featured. + if ( is_bool( $request['featured'] ) ) { + $args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'name', + 'terms' => 'featured', + 'operator' => true === $request['featured'] ? 'IN' : 'NOT IN', + ); + } + + // Filter by sku. + if ( ! empty( $request['sku'] ) ) { + $skus = explode( ',', $request['sku'] ); + // Include the current string as a SKU too. + if ( 1 < count( $skus ) ) { + $skus[] = $request['sku']; + } + + $args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok. + $args, array( + 'key' => '_sku', + 'value' => $skus, + 'compare' => 'IN', + ) + ); + } + + // Filter by tax class. + if ( ! empty( $request['tax_class'] ) ) { + $args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok. + $args, array( + 'key' => '_tax_class', + 'value' => 'standard' !== $request['tax_class'] ? $request['tax_class'] : '', + ) + ); + } + + // Price filter. + if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) { + $args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); // WPCS: slow query ok. + } + + // Filter product in stock or out of stock. + if ( is_bool( $request['in_stock'] ) ) { + $args['meta_query'] = $this->add_meta_query( // WPCS: slow query ok. + $args, array( + 'key' => '_stock_status', + 'value' => true === $request['in_stock'] ? 'instock' : 'outofstock', + ) + ); + } + + // Filter by on sale products. + if ( is_bool( $request['on_sale'] ) ) { + $on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in'; + $on_sale_ids = wc_get_product_ids_on_sale(); + + // Use 0 when there's no on sale products to avoid return all products. + $on_sale_ids = empty( $on_sale_ids ) ? array( 0 ) : $on_sale_ids; + + $args[ $on_sale_key ] += $on_sale_ids; + } + + // Force the post_type argument, since it's not a user input variable. + if ( ! empty( $request['sku'] ) ) { + $args['post_type'] = array( 'product', 'product_variation' ); + } else { + $args['post_type'] = $this->post_type; + } + + return $args; + } + + /** + * Get the downloads for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_downloads( $product ) { + $downloads = array(); + + if ( $product->is_downloadable() ) { + foreach ( $product->get_downloads() as $file_id => $file ) { + $downloads[] = array( + 'id' => $file_id, // MD5 hash. + 'name' => $file['name'], + 'file' => $file['file'], + ); + } + } + + return $downloads; + } + + /** + * Get taxonomy terms. + * + * @param WC_Product $product Product instance. + * @param string $taxonomy Taxonomy slug. + * @return array + */ + protected function get_taxonomy_terms( $product, $taxonomy = 'cat' ) { + $terms = array(); + + foreach ( wc_get_object_terms( $product->get_id(), 'product_' . $taxonomy ) as $term ) { + $terms[] = array( + 'id' => $term->term_id, + 'name' => $term->name, + 'slug' => $term->slug, + ); + } + + return $terms; + } + + /** + * Get the images for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_images( $product ) { + $images = array(); + $attachment_ids = array(); + + // Add featured image. + if ( has_post_thumbnail( $product->get_id() ) ) { + $attachment_ids[] = $product->get_image_id(); + } + + // Add gallery images. + $attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() ); + + // Build image data. + foreach ( $attachment_ids as $position => $attachment_id ) { + $attachment_post = get_post( $attachment_id ); + if ( is_null( $attachment_post ) ) { + continue; + } + + $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ); + if ( ! is_array( $attachment ) ) { + continue; + } + + $images[] = array( + 'id' => (int) $attachment_id, + 'date_created' => wc_rest_prepare_date_response( $attachment_post->post_date, false ), + 'date_created_gmt' => wc_rest_prepare_date_response( strtotime( $attachment_post->post_date_gmt ) ), + 'date_modified' => wc_rest_prepare_date_response( $attachment_post->post_modified, false ), + 'date_modified_gmt' => wc_rest_prepare_date_response( strtotime( $attachment_post->post_modified_gmt ) ), + 'src' => current( $attachment ), + 'name' => get_the_title( $attachment_id ), + 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), + 'position' => (int) $position, + ); + } + + // Set a placeholder image if the product has no images set. + if ( empty( $images ) ) { + $images[] = array( + 'id' => 0, + 'date_created' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now. + 'date_created_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ), // Default to now. + 'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ), false ), + 'date_modified_gmt' => wc_rest_prepare_date_response( current_time( 'timestamp', true ) ), + 'src' => wc_placeholder_img_src(), + 'name' => __( 'Placeholder', 'woocommerce' ), + 'alt' => __( 'Placeholder', 'woocommerce' ), + 'position' => 0, + ); + } + + return $images; + } + + /** + * Get attribute taxonomy label. + * + * @deprecated 3.0.0 + * + * @param string $name Taxonomy name. + * @return string + */ + protected function get_attribute_taxonomy_label( $name ) { + $tax = get_taxonomy( $name ); + $labels = get_taxonomy_labels( $tax ); + + return $labels->singular_name; + } + + /** + * Get product attribute taxonomy name. + * + * @since 3.0.0 + * @param string $slug Taxonomy name. + * @param WC_Product $product Product data. + * @return string + */ + protected function get_attribute_taxonomy_name( $slug, $product ) { + $attributes = $product->get_attributes(); + + if ( ! isset( $attributes[ $slug ] ) ) { + return str_replace( 'pa_', '', $slug ); + } + + $attribute = $attributes[ $slug ]; + + // Taxonomy attribute name. + if ( $attribute->is_taxonomy() ) { + $taxonomy = $attribute->get_taxonomy_object(); + return $taxonomy->attribute_label; + } + + // Custom product attribute name. + return $attribute->get_name(); + } + + /** + * Get default attributes. + * + * @param WC_Product $product Product instance. + * @return array + */ + protected function get_default_attributes( $product ) { + $default = array(); + + if ( $product->is_type( 'variable' ) ) { + foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) { + if ( 0 === strpos( $key, 'pa_' ) ) { + $default[] = array( + 'id' => wc_attribute_taxonomy_id_by_name( $key ), + 'name' => $this->get_attribute_taxonomy_name( $key, $product ), + 'option' => $value, + ); + } else { + $default[] = array( + 'id' => 0, + 'name' => $this->get_attribute_taxonomy_name( $key, $product ), + 'option' => $value, + ); + } + } + } + + return $default; + } + + /** + * Get attribute options. + * + * @param int $product_id Product ID. + * @param array $attribute Attribute data. + * @return array + */ + protected function get_attribute_options( $product_id, $attribute ) { + if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { + return wc_get_product_terms( + $product_id, $attribute['name'], array( + 'fields' => 'names', + ) + ); + } elseif ( isset( $attribute['value'] ) ) { + return array_map( 'trim', explode( '|', $attribute['value'] ) ); + } + + return array(); + } + + /** + * Get the attributes for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_attributes( $product ) { + $attributes = array(); + + if ( $product->is_type( 'variation' ) ) { + $_product = wc_get_product( $product->get_parent_id() ); + foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { + $name = str_replace( 'attribute_', '', $attribute_name ); + + if ( ! $attribute ) { + continue; + } + + // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. + if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) { + $option_term = get_term_by( 'slug', $attribute, $name ); + $attributes[] = array( + 'id' => wc_attribute_taxonomy_id_by_name( $name ), + 'name' => $this->get_attribute_taxonomy_name( $name, $_product ), + 'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute, + ); + } else { + $attributes[] = array( + 'id' => 0, + 'name' => $this->get_attribute_taxonomy_name( $name, $_product ), + 'option' => $attribute, + ); + } + } + } else { + foreach ( $product->get_attributes() as $attribute ) { + $attributes[] = array( + 'id' => $attribute['is_taxonomy'] ? wc_attribute_taxonomy_id_by_name( $attribute['name'] ) : 0, + 'name' => $this->get_attribute_taxonomy_name( $attribute['name'], $product ), + 'position' => (int) $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } + } + + return $attributes; + } + + /** + * Get product data. + * + * @param WC_Product $product Product instance. + * @param string $context Request context. + * Options: 'view' and 'edit'. + * @return array + */ + protected function get_product_data( $product, $context = 'view' ) { + $data = array( + 'id' => $product->get_id(), + 'name' => $product->get_name( $context ), + 'slug' => $product->get_slug( $context ), + 'permalink' => $product->get_permalink(), + 'date_created' => wc_rest_prepare_date_response( $product->get_date_created( $context ), false ), + 'date_created_gmt' => wc_rest_prepare_date_response( $product->get_date_created( $context ) ), + 'date_modified' => wc_rest_prepare_date_response( $product->get_date_modified( $context ), false ), + 'date_modified_gmt' => wc_rest_prepare_date_response( $product->get_date_modified( $context ) ), + 'type' => $product->get_type(), + 'status' => $product->get_status( $context ), + 'featured' => $product->is_featured(), + 'catalog_visibility' => $product->get_catalog_visibility( $context ), + 'description' => 'view' === $context ? wpautop( do_shortcode( $product->get_description() ) ) : $product->get_description( $context ), + 'short_description' => 'view' === $context ? apply_filters( 'woocommerce_short_description', $product->get_short_description() ) : $product->get_short_description( $context ), + 'sku' => $product->get_sku( $context ), + 'price' => $product->get_price( $context ), + 'regular_price' => $product->get_regular_price( $context ), + 'sale_price' => $product->get_sale_price( $context ) ? $product->get_sale_price( $context ) : '', + 'date_on_sale_from' => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ), false ), + 'date_on_sale_from_gmt' => wc_rest_prepare_date_response( $product->get_date_on_sale_from( $context ) ), + 'date_on_sale_to' => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ), false ), + 'date_on_sale_to_gmt' => wc_rest_prepare_date_response( $product->get_date_on_sale_to( $context ) ), + 'price_html' => $product->get_price_html(), + 'on_sale' => $product->is_on_sale( $context ), + 'purchasable' => $product->is_purchasable(), + 'total_sales' => $product->get_total_sales( $context ), + 'virtual' => $product->is_virtual(), + 'downloadable' => $product->is_downloadable(), + 'downloads' => $this->get_downloads( $product ), + 'download_limit' => $product->get_download_limit( $context ), + 'download_expiry' => $product->get_download_expiry( $context ), + 'external_url' => $product->is_type( 'external' ) ? $product->get_product_url( $context ) : '', + 'button_text' => $product->is_type( 'external' ) ? $product->get_button_text( $context ) : '', + 'tax_status' => $product->get_tax_status( $context ), + 'tax_class' => $product->get_tax_class( $context ), + 'manage_stock' => $product->managing_stock(), + 'stock_quantity' => $product->get_stock_quantity( $context ), + 'in_stock' => $product->is_in_stock(), + 'backorders' => $product->get_backorders( $context ), + 'backorders_allowed' => $product->backorders_allowed(), + 'backordered' => $product->is_on_backorder(), + 'sold_individually' => $product->is_sold_individually(), + 'weight' => $product->get_weight( $context ), + 'dimensions' => array( + 'length' => $product->get_length( $context ), + 'width' => $product->get_width( $context ), + 'height' => $product->get_height( $context ), + ), + 'shipping_required' => $product->needs_shipping(), + 'shipping_taxable' => $product->is_shipping_taxable(), + 'shipping_class' => $product->get_shipping_class(), + 'shipping_class_id' => $product->get_shipping_class_id( $context ), + 'reviews_allowed' => $product->get_reviews_allowed( $context ), + 'average_rating' => 'view' === $context ? wc_format_decimal( $product->get_average_rating(), 2 ) : $product->get_average_rating( $context ), + 'rating_count' => $product->get_rating_count(), + 'related_ids' => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ), + 'upsell_ids' => array_map( 'absint', $product->get_upsell_ids( $context ) ), + 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sell_ids( $context ) ), + 'parent_id' => $product->get_parent_id( $context ), + 'purchase_note' => 'view' === $context ? wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ) : $product->get_purchase_note( $context ), + 'categories' => $this->get_taxonomy_terms( $product ), + 'tags' => $this->get_taxonomy_terms( $product, 'tag' ), + 'images' => $this->get_images( $product ), + 'attributes' => $this->get_attributes( $product ), + 'default_attributes' => $this->get_default_attributes( $product ), + 'variations' => array(), + 'grouped_products' => array(), + 'menu_order' => $product->get_menu_order( $context ), + 'meta_data' => $product->get_meta_data(), + ); + + return $data; + } + + /** + * Prepare links for the request. + * + * @param WC_Data $object Object data. + * @param WP_REST_Request $request Request object. + * @return array Links for the given post. + */ + protected function prepare_links( $object, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + if ( $object->get_parent_id() ) { + $links['up'] = array( + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $object->get_parent_id() ) ), + ); + } + + return $links; + } + + /** + * Prepare a single product for create or update. + * + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data + */ + protected function prepare_object_for_database( $request, $creating = false ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + + // Type is the most important part here because we need to be using the correct class and methods. + if ( isset( $request['type'] ) ) { + $classname = WC_Product_Factory::get_classname_from_product_type( $request['type'] ); + + if ( ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + + $product = new $classname( $id ); + } elseif ( isset( $request['id'] ) ) { + $product = wc_get_product( $id ); + } else { + $product = new WC_Product_Simple(); + } + + if ( 'variation' === $product->get_type() ) { + return new WP_Error( + "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( + 'status' => 404, + ) + ); + } + + // Post title. + if ( isset( $request['name'] ) ) { + $product->set_name( wp_filter_post_kses( $request['name'] ) ); + } + + // Post content. + if ( isset( $request['description'] ) ) { + $product->set_description( wp_filter_post_kses( $request['description'] ) ); + } + + // Post excerpt. + if ( isset( $request['short_description'] ) ) { + $product->set_short_description( wp_filter_post_kses( $request['short_description'] ) ); + } + + // Post status. + if ( isset( $request['status'] ) ) { + $product->set_status( get_post_status_object( $request['status'] ) ? $request['status'] : 'draft' ); + } + + // Post slug. + if ( isset( $request['slug'] ) ) { + $product->set_slug( $request['slug'] ); + } + + // Menu order. + if ( isset( $request['menu_order'] ) ) { + $product->set_menu_order( $request['menu_order'] ); + } + + // Comment status. + if ( isset( $request['reviews_allowed'] ) ) { + $product->set_reviews_allowed( $request['reviews_allowed'] ); + } + + // Virtual. + if ( isset( $request['virtual'] ) ) { + $product->set_virtual( $request['virtual'] ); + } + + // Tax status. + if ( isset( $request['tax_status'] ) ) { + $product->set_tax_status( $request['tax_status'] ); + } + + // Tax Class. + if ( isset( $request['tax_class'] ) ) { + $product->set_tax_class( $request['tax_class'] ); + } + + // Catalog Visibility. + if ( isset( $request['catalog_visibility'] ) ) { + $product->set_catalog_visibility( $request['catalog_visibility'] ); + } + + // Purchase Note. + if ( isset( $request['purchase_note'] ) ) { + $product->set_purchase_note( wp_kses_post( wp_unslash( $request['purchase_note'] ) ) ); + } + + // Featured Product. + if ( isset( $request['featured'] ) ) { + $product->set_featured( $request['featured'] ); + } + + // Shipping data. + $product = $this->save_product_shipping_data( $product, $request ); + + // SKU. + if ( isset( $request['sku'] ) ) { + $product->set_sku( wc_clean( $request['sku'] ) ); + } + + // Attributes. + if ( isset( $request['attributes'] ) ) { + $attributes = array(); + + foreach ( $request['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = wc_clean( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( $attribute_id ) { + + if ( isset( $attribute['options'] ) ) { + $options = $attribute['options']; + + if ( ! is_array( $attribute['options'] ) ) { + // Text based attributes - Posted values are term names. + $options = explode( WC_DELIMITER, $options ); + } + + $values = array_map( 'wc_sanitize_term_text_based', $options ); + $values = array_filter( $values, 'strlen' ); + } else { + $values = array(); + } + + if ( ! empty( $values ) ) { + // Add attribute to array, but don't set values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['options'] ) ) { + // Custom attribute - Add attribute to array and set the values. + if ( is_array( $attribute['options'] ) ) { + $values = $attribute['options']; + } else { + $values = explode( WC_DELIMITER, $attribute['options'] ); + } + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } + $product->set_attributes( $attributes ); + } + + // Sales and prices. + if ( in_array( $product->get_type(), array( 'variable', 'grouped' ), true ) ) { + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + $product->set_date_on_sale_to( '' ); + $product->set_date_on_sale_from( '' ); + $product->set_price( '' ); + } else { + // Regular Price. + if ( isset( $request['regular_price'] ) ) { + $product->set_regular_price( $request['regular_price'] ); + } + + // Sale Price. + if ( isset( $request['sale_price'] ) ) { + $product->set_sale_price( $request['sale_price'] ); + } + + if ( isset( $request['date_on_sale_from'] ) ) { + $product->set_date_on_sale_from( $request['date_on_sale_from'] ); + } + + if ( isset( $request['date_on_sale_from_gmt'] ) ) { + $product->set_date_on_sale_from( $request['date_on_sale_from_gmt'] ? strtotime( $request['date_on_sale_from_gmt'] ) : null ); + } + + if ( isset( $request['date_on_sale_to'] ) ) { + $product->set_date_on_sale_to( $request['date_on_sale_to'] ); + } + + if ( isset( $request['date_on_sale_to_gmt'] ) ) { + $product->set_date_on_sale_to( $request['date_on_sale_to_gmt'] ? strtotime( $request['date_on_sale_to_gmt'] ) : null ); + } + } + + // Product parent ID for groups. + if ( isset( $request['parent_id'] ) ) { + $product->set_parent_id( $request['parent_id'] ); + } + + // Sold individually. + if ( isset( $request['sold_individually'] ) ) { + $product->set_sold_individually( $request['sold_individually'] ); + } + + // Stock status. + if ( isset( $request['in_stock'] ) ) { + $stock_status = true === $request['in_stock'] ? 'instock' : 'outofstock'; + } else { + $stock_status = $product->get_stock_status(); + } + + // Stock data. + if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) { + // Manage stock. + if ( isset( $request['manage_stock'] ) ) { + $product->set_manage_stock( $request['manage_stock'] ); + } + + // Backorders. + if ( isset( $request['backorders'] ) ) { + $product->set_backorders( $request['backorders'] ); + } + + if ( $product->is_type( 'grouped' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } elseif ( $product->is_type( 'external' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( 'instock' ); + } elseif ( $product->get_manage_stock() ) { + // Stock status is always determined by children so sync later. + if ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Stock quantity. + if ( isset( $request['stock_quantity'] ) ) { + $product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) ); + } elseif ( isset( $request['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $product->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); + $product->set_stock_quantity( wc_stock_amount( $stock_quantity ) ); + } + } else { + // Don't manage stock. + $product->set_manage_stock( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } + } elseif ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Upsells. + if ( isset( $request['upsell_ids'] ) ) { + $upsells = array(); + $ids = $request['upsell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $upsells[] = $id; + } + } + } + + $product->set_upsell_ids( $upsells ); + } + + // Cross sells. + if ( isset( $request['cross_sell_ids'] ) ) { + $crosssells = array(); + $ids = $request['cross_sell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $crosssells[] = $id; + } + } + } + + $product->set_cross_sell_ids( $crosssells ); + } + + // Product categories. + if ( isset( $request['categories'] ) && is_array( $request['categories'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['categories'] ); + } + + // Product tags. + if ( isset( $request['tags'] ) && is_array( $request['tags'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['tags'], 'tag' ); + } + + // Downloadable. + if ( isset( $request['downloadable'] ) ) { + $product->set_downloadable( $request['downloadable'] ); + } + + // Downloadable options. + if ( $product->get_downloadable() ) { + + // Downloadable files. + if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) { + $product = $this->save_downloadable_files( $product, $request['downloads'] ); + } + + // Download limit. + if ( isset( $request['download_limit'] ) ) { + $product->set_download_limit( $request['download_limit'] ); + } + + // Download expiry. + if ( isset( $request['download_expiry'] ) ) { + $product->set_download_expiry( $request['download_expiry'] ); + } + } + + // Product url and button text for external products. + if ( $product->is_type( 'external' ) ) { + if ( isset( $request['external_url'] ) ) { + $product->set_product_url( $request['external_url'] ); + } + + if ( isset( $request['button_text'] ) ) { + $product->set_button_text( $request['button_text'] ); + } + } + + // Save default attributes for variable products. + if ( $product->is_type( 'variable' ) ) { + $product = $this->save_default_attributes( $product, $request ); + } + + // Set children for a grouped product. + if ( $product->is_type( 'grouped' ) && isset( $request['grouped_products'] ) ) { + $product->set_children( $request['grouped_products'] ); + } + + // Check for featured/gallery images, upload it and set it. + if ( isset( $request['images'] ) ) { + $product = $this->set_product_images( $product, $request['images'] ); + } + + // Allow set meta_data. + if ( is_array( $request['meta_data'] ) ) { + foreach ( $request['meta_data'] as $meta ) { + $product->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + + /** + * Filters an object before it is inserted via the REST API. + * + * The dynamic portion of the hook name, `$this->post_type`, + * refers to the object type slug. + * + * @param WC_Data $product Object object. + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}_object", $product, $request, $creating ); + } + + /** + * Set product images. + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param array $images Images data. + * @return WC_Product + */ + protected function set_product_images( $product, $images ) { + $images = is_array( $images ) ? array_filter( $images ) : array(); + + if ( ! empty( $images ) ) { + $gallery = array(); + + foreach ( $images as $image ) { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images ) ) { + throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 ); + } else { + continue; + } + } + + $attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product->get_id() ); + } + + if ( ! wp_attachment_is_image( $attachment_id ) ) { + /* translators: %s: attachment id */ + throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 ); + } + + if ( isset( $image['position'] ) && 0 === absint( $image['position'] ) ) { + $product->set_image_id( $attachment_id ); + } else { + $gallery[] = $attachment_id; + } + + // Set the image alt if present. + if ( ! empty( $image['alt'] ) ) { + update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) ); + } + + // Set the image name if present. + if ( ! empty( $image['name'] ) ) { + wp_update_post( + array( + 'ID' => $attachment_id, + 'post_title' => $image['name'], + ) + ); + } + + // Set the image source if present, for future reference. + if ( ! empty( $image['src'] ) ) { + update_post_meta( $attachment_id, '_wc_attachment_source', esc_url_raw( $image['src'] ) ); + } + } + + $product->set_gallery_image_ids( $gallery ); + } else { + $product->set_image_id( '' ); + $product->set_gallery_image_ids( array() ); + } + + return $product; + } + + /** + * Save product shipping data. + * + * @param WC_Product $product Product instance. + * @param array $data Shipping data. + * @return WC_Product + */ + protected function save_product_shipping_data( $product, $data ) { + // Virtual. + if ( isset( $data['virtual'] ) && true === $data['virtual'] ) { + $product->set_weight( '' ); + $product->set_height( '' ); + $product->set_length( '' ); + $product->set_width( '' ); + } else { + if ( isset( $data['weight'] ) ) { + $product->set_weight( $data['weight'] ); + } + + // Height. + if ( isset( $data['dimensions']['height'] ) ) { + $product->set_height( $data['dimensions']['height'] ); + } + + // Width. + if ( isset( $data['dimensions']['width'] ) ) { + $product->set_width( $data['dimensions']['width'] ); + } + + // Length. + if ( isset( $data['dimensions']['length'] ) ) { + $product->set_length( $data['dimensions']['length'] ); + } + } + + // Shipping class. + if ( isset( $data['shipping_class'] ) ) { + $data_store = $product->get_data_store(); + $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); + $product->set_shipping_class_id( $shipping_class_id ); + } + + return $product; + } + + /** + * Save downloadable files. + * + * @param WC_Product $product Product instance. + * @param array $downloads Downloads data. + * @param int $deprecated Deprecated since 3.0. + * @return WC_Product + */ + protected function save_downloadable_files( $product, $downloads, $deprecated = 0 ) { + if ( $deprecated ) { + wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.' ); + } + + $files = array(); + foreach ( $downloads as $key => $file ) { + if ( empty( $file['file'] ) ) { + continue; + } + + $download = new WC_Product_Download(); + $download->set_id( $file['id'] ? $file['id'] : wp_generate_uuid4() ); + $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) ); + $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) ); + $files[] = $download; + } + $product->set_downloads( $files ); + + return $product; + } + + /** + * Save taxonomy terms. + * + * @param WC_Product $product Product instance. + * @param array $terms Terms data. + * @param string $taxonomy Taxonomy name. + * @return WC_Product + */ + protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) { + $term_ids = wp_list_pluck( $terms, 'id' ); + + if ( 'cat' === $taxonomy ) { + $product->set_category_ids( $term_ids ); + } elseif ( 'tag' === $taxonomy ) { + $product->set_tag_ids( $term_ids ); + } + + return $product; + } + + /** + * Save default attributes. + * + * @since 3.0.0 + * + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return WC_Product + */ + protected function save_default_attributes( $product, $request ) { + if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) { + + $attributes = $product->get_attributes(); + $default_attributes = array(); + + foreach ( $request['default_attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( isset( $attributes[ $attribute_name ] ) ) { + $_attribute = $attributes[ $attribute_name ]; + + if ( $_attribute['is_variation'] ) { + $value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + + if ( ! empty( $_attribute['is_taxonomy'] ) ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $value, $attribute_name ); + + if ( $term && ! is_wp_error( $term ) ) { + $value = $term->slug; + } else { + $value = sanitize_title( $value ); + } + } + + if ( $value ) { + $default_attributes[ $attribute_name ] = $value; + } + } + } + } + + $product->set_default_attributes( $default_attributes ); + } + + return $product; + } + + /** + * Clear caches here so in sync with any new variations/children. + * + * @param WC_Data $object Object data. + */ + public function clear_transients( $object ) { + wc_delete_product_transients( $object->get_id() ); + wp_cache_delete( 'product-' . $object->get_id(), 'products' ); + } + + /** + * Delete a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $force = (bool) $request['force']; + $object = $this->get_object( (int) $request['id'] ); + $result = false; + + if ( ! $object || 0 === $object->get_id() ) { + return new WP_Error( + "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( + 'status' => 404, + ) + ); + } + + if ( 'variation' === $object->get_type() ) { + return new WP_Error( + "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( + 'status' => 404, + ) + ); + } + + $supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) ); + + /** + * Filter whether an object is trashable. + * + * Return false to disable trash support for the object. + * + * @param boolean $supports_trash Whether the object type support trashing. + * @param WC_Data $object The object being considered for trashing support. + */ + $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object ); + + if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) { + return new WP_Error( + /* translators: %s: post type */ + "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( + 'status' => rest_authorization_required_code(), + ) + ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_object_for_response( $object, $request ); + + // If we're forcing, then delete permanently. + if ( $force ) { + if ( $object->is_type( 'variable' ) ) { + foreach ( $object->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->delete( true ); + } + } elseif ( $object->is_type( 'grouped' ) ) { + foreach ( $object->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->set_parent_id( 0 ); + $child->save(); + } + } + + $object->delete( true ); + $result = 0 === $object->get_id(); + } else { + // If we don't support trashing for this type, error out. + if ( ! $supports_trash ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( + 'status' => 501, + ) + ); + } + + // Otherwise, only trash if we haven't already. + if ( is_callable( array( $object, 'get_status' ) ) ) { + if ( 'trash' === $object->get_status() ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( + 'status' => 410, + ) + ); + } + + $object->delete(); + $result = 'trash' === $object->get_status(); + } + } + + if ( ! $result ) { + return new WP_Error( + /* translators: %s: post type */ + 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( + 'status' => 500, + ) + ); + } + + // Delete parent product transients. + if ( 0 !== $object->get_parent_id() ) { + wc_delete_product_transients( $object->get_parent_id() ); + } + + /** + * Fires after a single object is deleted or trashed via the REST API. + * + * @param WC_Data $object The deleted or trashed object. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( "woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request ); + + return $response; + } + + /** + * Get the Product's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $weight_unit = get_option( 'woocommerce_weight_unit' ); + $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'slug' => array( + 'description' => __( 'Product slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'permalink' => array( + 'description' => __( 'Product URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the product was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the product was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'type' => array( + 'description' => __( 'Product type.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'simple', + 'enum' => array_keys( wc_get_product_types() ), + 'context' => array( 'view', 'edit' ), + ), + 'status' => array( + 'description' => __( 'Product status (post status).', 'woocommerce' ), + 'type' => 'string', + 'default' => 'publish', + 'enum' => array_keys( get_post_statuses() ), + 'context' => array( 'view', 'edit' ), + ), + 'featured' => array( + 'description' => __( 'Featured product.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'catalog_visibility' => array( + 'description' => __( 'Catalog visibility.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'visible', + 'enum' => array( 'visible', 'catalog', 'search', 'hidden' ), + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'Product description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'short_description' => array( + 'description' => __( 'Product short description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sku' => array( + 'description' => __( 'Unique identifier.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'price' => array( + 'description' => __( 'Current product price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'regular_price' => array( + 'description' => __( 'Product regular price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sale_price' => array( + 'description' => __( 'Product sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from' => array( + 'description' => __( "Start date of sale price, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from_gmt' => array( + 'description' => __( 'Start date of sale price, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to' => array( + 'description' => __( "End date of sale price, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to_gmt' => array( + 'description' => __( 'End date of sale price, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'price_html' => array( + 'description' => __( 'Price formatted in HTML.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'on_sale' => array( + 'description' => __( 'Shows if the product is on sale.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'purchasable' => array( + 'description' => __( 'Shows if the product can be bought.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_sales' => array( + 'description' => __( 'Amount of sales.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'virtual' => array( + 'description' => __( 'If the product is virtual.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloadable' => array( + 'description' => __( 'If the product is downloadable.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloads' => array( + 'description' => __( 'List of downloadable files.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'File MD5 hash.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'download_limit' => array( + 'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'download_expiry' => array( + 'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'external_url' => array( + 'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'button_text' => array( + 'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'taxable', + 'enum' => array( 'taxable', 'shipping', 'none' ), + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'manage_stock' => array( + 'description' => __( 'Stock management at product level.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'stock_quantity' => array( + 'description' => __( 'Stock quantity.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'in_stock' => array( + 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'backorders' => array( + 'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'no', + 'enum' => array( 'no', 'notify', 'yes' ), + 'context' => array( 'view', 'edit' ), + ), + 'backorders_allowed' => array( + 'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'backordered' => array( + 'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sold_individually' => array( + 'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'weight' => array( + /* translators: %s: weight unit */ + 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'dimensions' => array( + 'description' => __( 'Product dimensions.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'length' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'width' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'height' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping_required' => array( + 'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_taxable' => array( + 'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_class' => array( + 'description' => __( 'Shipping class slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'shipping_class_id' => array( + 'description' => __( 'Shipping class ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'reviews_allowed' => array( + 'description' => __( 'Allow reviews.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'average_rating' => array( + 'description' => __( 'Reviews average rating.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rating_count' => array( + 'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'related_ids' => array( + 'description' => __( 'List of related products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'upsell_ids' => array( + 'description' => __( 'List of up-sell products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'cross_sell_ids' => array( + 'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'parent_id' => array( + 'description' => __( 'Product parent ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'purchase_note' => array( + 'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'categories' => array( + 'description' => __( 'List of categories.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Category ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Category name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'slug' => array( + 'description' => __( 'Category slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'tags' => array( + 'description' => __( 'List of tags.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tag ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Tag name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'slug' => array( + 'description' => __( 'Tag slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'images' => array( + 'description' => __( 'List of images.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the image was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the image was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'attributes' => array( + 'description' => __( 'List of attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Attribute position.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'visible' => array( + 'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'variation' => array( + 'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'options' => array( + 'description' => __( 'List of available term names of the attribute.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'string', + ), + ), + ), + ), + ), + 'default_attributes' => array( + 'description' => __( 'Defaults variation attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'option' => array( + 'description' => __( 'Selected attribute term name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'variations' => array( + 'description' => __( 'List of variations IDs.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'integer', + ), + 'readonly' => true, + ), + 'grouped_products' => array( + 'description' => __( 'List of grouped products ID.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'meta_data' => array( + 'description' => __( 'Meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Meta ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['slug'] = array( + 'description' => __( 'Limit result set to products with a specific slug.', 'woocommerce' ), + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['status'] = array( + 'default' => 'any', + 'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_merge( array( 'any' ), array_keys( get_post_statuses() ) ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['type'] = array( + 'description' => __( 'Limit result set to products assigned a specific type.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_keys( wc_get_product_types() ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['sku'] = array( + 'description' => __( 'Limit result set to products with specific SKU(s). Use commas to separate.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['featured'] = array( + 'description' => __( 'Limit result set to featured products.', 'woocommerce' ), + 'type' => 'boolean', + 'sanitize_callback' => 'wc_string_to_bool', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['category'] = array( + 'description' => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['tag'] = array( + 'description' => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['shipping_class'] = array( + 'description' => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['attribute'] = array( + 'description' => __( 'Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['attribute_term'] = array( + 'description' => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + + if ( wc_tax_enabled() ) { + $params['tax_class'] = array( + 'description' => __( 'Limit result set to products with a specific tax class.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ), + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + } + + $params['in_stock'] = array( + 'description' => __( 'Limit result set to products in stock or out of stock.', 'woocommerce' ), + 'type' => 'boolean', + 'sanitize_callback' => 'wc_string_to_bool', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['on_sale'] = array( + 'description' => __( 'Limit result set to products on sale.', 'woocommerce' ), + 'type' => 'boolean', + 'sanitize_callback' => 'wc_string_to_bool', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['min_price'] = array( + 'description' => __( 'Limit result set to products based on a minimum price.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['max_price'] = array( + 'description' => __( 'Limit result set to products based on a maximum price.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-report-sales-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-report-sales-controller.php new file mode 100644 index 0000000..f4a787e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-report-sales-controller.php @@ -0,0 +1,27 @@ +[\w-]+)'; + + /** + * Register routes. + * + * @since 3.0.0 + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'group' => array( + 'description' => __( 'Settings group ID.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/batch', array( + 'args' => array( + 'group' => array( + 'description' => __( 'Settings group ID.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\w-]+)', array( + 'args' => array( + 'group' => array( + 'description' => __( 'Settings group ID.', 'woocommerce' ), + 'type' => 'string', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Return a single setting. + * + * @since 3.0.0 + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $setting = $this->get_setting( $request['group_id'], $request['id'] ); + + if ( is_wp_error( $setting ) ) { + return $setting; + } + + $response = $this->prepare_item_for_response( $setting, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Return all settings in a group. + * + * @since 3.0.0 + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $settings = $this->get_group_settings( $request['group_id'] ); + + if ( is_wp_error( $settings ) ) { + return $settings; + } + + $data = array(); + + foreach ( $settings as $setting_obj ) { + $setting = $this->prepare_item_for_response( $setting_obj, $request ); + $setting = $this->prepare_response_for_collection( $setting ); + if ( $this->is_setting_type_valid( $setting['type'] ) ) { + $data[] = $setting; + } + } + + return rest_ensure_response( $data ); + } + + /** + * Get all settings in a group. + * + * @since 3.0.0 + * @param string $group_id Group ID. + * @return array|WP_Error + */ + public function get_group_settings( $group_id ) { + if ( empty( $group_id ) ) { + return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $settings = apply_filters( 'woocommerce_settings-' . $group_id, array() ); + + if ( empty( $settings ) ) { + return new WP_Error( 'rest_setting_setting_group_invalid', __( 'Invalid setting group.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $filtered_settings = array(); + foreach ( $settings as $setting ) { + $option_key = $setting['option_key']; + $setting = $this->filter_setting( $setting ); + $default = isset( $setting['default'] ) ? $setting['default'] : ''; + // Get the option value. + if ( is_array( $option_key ) ) { + $option = get_option( $option_key[0] ); + $setting['value'] = isset( $option[ $option_key[1] ] ) ? $option[ $option_key[1] ] : $default; + } else { + $admin_setting_value = WC_Admin_Settings::get_option( $option_key, $default ); + $setting['value'] = $admin_setting_value; + } + + if ( 'multi_select_countries' === $setting['type'] ) { + $setting['options'] = WC()->countries->get_countries(); + $setting['type'] = 'multiselect'; + } elseif ( 'single_select_country' === $setting['type'] ) { + $setting['type'] = 'select'; + $setting['options'] = $this->get_countries_and_states(); + } + + $filtered_settings[] = $setting; + } + + return $filtered_settings; + } + + /** + * Returns a list of countries and states for use in the base location setting. + * + * @since 3.0.7 + * @return array Array of states and countries. + */ + private function get_countries_and_states() { + $countries = WC()->countries->get_countries(); + if ( ! $countries ) { + return array(); + } + + $output = array(); + + foreach ( $countries as $key => $value ) { + $states = WC()->countries->get_states( $key ); + if ( $states ) { + foreach ( $states as $state_key => $state_value ) { + $output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value; + } + } else { + $output[ $key ] = $value; + } + } + + return $output; + } + + /** + * Get setting data. + * + * @since 3.0.0 + * @param string $group_id Group ID. + * @param string $setting_id Setting ID. + * @return stdClass|WP_Error + */ + public function get_setting( $group_id, $setting_id ) { + if ( empty( $setting_id ) ) { + return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $settings = $this->get_group_settings( $group_id ); + + if ( is_wp_error( $settings ) ) { + return $settings; + } + + $array_key = array_keys( wp_list_pluck( $settings, 'id' ), $setting_id ); + + if ( empty( $array_key ) ) { + return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $setting = $settings[ $array_key[0] ]; + + if ( ! $this->is_setting_type_valid( $setting['type'] ) ) { + return new WP_Error( 'rest_setting_setting_invalid', __( 'Invalid setting.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + return $setting; + } + + /** + * Bulk create, update and delete items. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return array Of WP_Error or WP_REST_Response. + */ + public function batch_items( $request ) { + // Get the request params. + $items = array_filter( $request->get_params() ); + + /* + * Since our batch settings update is group-specific and matches based on the route, + * we inject the URL parameters (containing group) into the batch items + */ + if ( ! empty( $items['update'] ) ) { + $to_update = array(); + foreach ( $items['update'] as $item ) { + $to_update[] = array_merge( $request->get_url_params(), $item ); + } + $request = new WP_REST_Request( $request->get_method() ); + $request->set_body_params( array( 'update' => $to_update ) ); + } + + return parent::batch_items( $request ); + } + + /** + * Update a single setting in a group. + * + * @since 3.0.0 + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $setting = $this->get_setting( $request['group_id'], $request['id'] ); + + if ( is_wp_error( $setting ) ) { + return $setting; + } + + if ( is_callable( array( $this, 'validate_setting_' . $setting['type'] . '_field' ) ) ) { + $value = $this->{'validate_setting_' . $setting['type'] . '_field'}( $request['value'], $setting ); + } else { + $value = $this->validate_setting_text_field( $request['value'], $setting ); + } + + if ( is_wp_error( $value ) ) { + return $value; + } + + if ( is_array( $setting['option_key'] ) ) { + $setting['value'] = $value; + $option_key = $setting['option_key']; + $prev = get_option( $option_key[0] ); + $prev[ $option_key[1] ] = $request['value']; + update_option( $option_key[0], $prev ); + } else { + $update_data = array(); + $update_data[ $setting['option_key'] ] = $value; + $setting['value'] = $value; + WC_Admin_Settings::save_fields( array( $setting ), $update_data ); + } + + $response = $this->prepare_item_for_response( $setting, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Prepare a single setting object for response. + * + * @since 3.0.0 + * @param object $item Setting object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $item, $request ) { + unset( $item['option_key'] ); + $data = $this->filter_setting( $item ); + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, empty( $request['context'] ) ? 'view' : $request['context'] ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $data['id'], $request['group_id'] ) ); + return $response; + } + + /** + * Prepare links for the request. + * + * @since 3.0.0 + * @param string $setting_id Setting ID. + * @param string $group_id Group ID. + * @return array Links for the given setting. + */ + protected function prepare_links( $setting_id, $group_id ) { + $base = str_replace( '(?P[\w-]+)', $group_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $base, $setting_id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + ); + + return $links; + } + + /** + * Makes sure the current user has access to READ the settings APIs. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full data about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Makes sure the current user has access to WRITE the settings APIs. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full data about the request. + * @return WP_Error|boolean + */ + public function update_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Filters out bad values from the settings array/filter so we + * only return known values via the API. + * + * @since 3.0.0 + * @param array $setting Settings. + * @return array + */ + public function filter_setting( $setting ) { + $setting = array_intersect_key( + $setting, + array_flip( array_filter( array_keys( $setting ), array( $this, 'allowed_setting_keys' ) ) ) + ); + + if ( empty( $setting['options'] ) ) { + unset( $setting['options'] ); + } + + if ( 'image_width' === $setting['type'] ) { + $setting = $this->cast_image_width( $setting ); + } + + return $setting; + } + + /** + * For image_width, Crop can return "0" instead of false -- so we want + * to make sure we return these consistently the same we accept them. + * + * @todo remove in 4.0 + * @since 3.0.0 + * @param array $setting Settings. + * @return array + */ + public function cast_image_width( $setting ) { + foreach ( array( 'default', 'value' ) as $key ) { + if ( isset( $setting[ $key ] ) ) { + $setting[ $key ]['width'] = intval( $setting[ $key ]['width'] ); + $setting[ $key ]['height'] = intval( $setting[ $key ]['height'] ); + $setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop']; + } + } + return $setting; + } + + /** + * Callback for allowed keys for each setting response. + * + * @since 3.0.0 + * @param string $key Key to check. + * @return boolean + */ + public function allowed_setting_keys( $key ) { + return in_array( + $key, array( + 'id', + 'label', + 'description', + 'default', + 'tip', + 'placeholder', + 'type', + 'options', + 'value', + 'option_key', + ) + ); + } + + /** + * Boolean for if a setting type is a valid supported setting type. + * + * @since 3.0.0 + * @param string $type Type. + * @return bool + */ + public function is_setting_type_valid( $type ) { + return in_array( + $type, array( + 'text', // Validates with validate_setting_text_field. + 'email', // Validates with validate_setting_text_field. + 'number', // Validates with validate_setting_text_field. + 'color', // Validates with validate_setting_text_field. + 'password', // Validates with validate_setting_text_field. + 'textarea', // Validates with validate_setting_textarea_field. + 'select', // Validates with validate_setting_select_field. + 'multiselect', // Validates with validate_setting_multiselect_field. + 'radio', // Validates with validate_setting_radio_field (-> validate_setting_select_field). + 'checkbox', // Validates with validate_setting_checkbox_field. + 'image_width', // Validates with validate_setting_image_width_field. + 'thumbnail_cropping', // Validates with validate_setting_text_field. + ) + ); + } + + /** + * Get the settings schema, conforming to JSON Schema. + * + * @since 3.0.0 + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'setting', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'A unique identifier for the setting.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Setting value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'default' => array( + 'description' => __( 'Default value for the setting.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tip' => array( + 'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'placeholder' => array( + 'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'type' => array( + 'description' => __( 'Type of setting.', 'woocommerce' ), + 'type' => 'string', + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + 'context' => array( 'view', 'edit' ), + 'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox', 'thumbnail_cropping' ), + 'readonly' => true, + ), + 'options' => array( + 'description' => __( 'Array of options (key value pairs) for inputs such as select, multiselect, and radio buttons.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-settings-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-settings-controller.php new file mode 100644 index 0000000..35d0127 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-settings-controller.php @@ -0,0 +1,232 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Get all settings groups items. + * + * @since 3.0.0 + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $groups = apply_filters( 'woocommerce_settings_groups', array() ); + if ( empty( $groups ) ) { + return new WP_Error( 'rest_setting_groups_empty', __( 'No setting groups have been registered.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $defaults = $this->group_defaults(); + $filtered_groups = array(); + foreach ( $groups as $group ) { + $sub_groups = array(); + foreach ( $groups as $_group ) { + if ( ! empty( $_group['parent_id'] ) && $group['id'] === $_group['parent_id'] ) { + $sub_groups[] = $_group['id']; + } + } + $group['sub_groups'] = $sub_groups; + + $group = wp_parse_args( $group, $defaults ); + if ( ! is_null( $group['id'] ) && ! is_null( $group['label'] ) ) { + $group_obj = $this->filter_group( $group ); + $group_data = $this->prepare_item_for_response( $group_obj, $request ); + $group_data = $this->prepare_response_for_collection( $group_data ); + + $filtered_groups[] = $group_data; + } + } + + $response = rest_ensure_response( $filtered_groups ); + return $response; + } + + /** + * Prepare links for the request. + * + * @param string $group_id Group ID. + * @return array Links for the given group. + */ + protected function prepare_links( $group_id ) { + $base = '/' . $this->namespace . '/' . $this->rest_base; + $links = array( + 'options' => array( + 'href' => rest_url( trailingslashit( $base ) . $group_id ), + ), + ); + + return $links; + } + + /** + * Prepare a report sales object for serialization. + * + * @since 3.0.0 + * @param array $item Group object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $item, $request ) { + $context = empty( $request['context'] ) ? 'view' : $request['context']; + $data = $this->add_additional_fields_to_object( $item, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item['id'] ) ); + + return $response; + } + + /** + * Filters out bad values from the groups array/filter so we + * only return known values via the API. + * + * @since 3.0.0 + * @param array $group Group. + * @return array + */ + public function filter_group( $group ) { + return array_intersect_key( + $group, + array_flip( array_filter( array_keys( $group ), array( $this, 'allowed_group_keys' ) ) ) + ); + } + + /** + * Callback for allowed keys for each group response. + * + * @since 3.0.0 + * @param string $key Key to check. + * @return boolean + */ + public function allowed_group_keys( $key ) { + return in_array( $key, array( 'id', 'label', 'description', 'parent_id', 'sub_groups' ) ); + } + + /** + * Returns default settings for groups. null means the field is required. + * + * @since 3.0.0 + * @return array + */ + protected function group_defaults() { + return array( + 'id' => null, + 'label' => null, + 'description' => '', + 'parent_id' => '', + 'sub_groups' => array(), + ); + } + + /** + * Makes sure the current user has access to READ the settings APIs. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full data about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get the groups schema, conforming to JSON Schema. + * + * @since 3.0.0 + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'setting_group', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'A unique identifier that can be used to link settings together.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'parent_id' => array( + 'description' => __( 'ID of parent grouping.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'sub_groups' => array( + 'description' => __( 'IDs for settings sub groups.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-methods-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-methods-controller.php new file mode 100644 index 0000000..ab1b8ac --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-methods-controller.php @@ -0,0 +1,231 @@ + + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\w-]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Check whether a given request has permission to view shipping methods. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'shipping_methods', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check if a given request has access to read a shipping method. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'shipping_methods', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Get shipping methods. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $wc_shipping = WC_Shipping::instance(); + $response = array(); + foreach ( $wc_shipping->get_shipping_methods() as $id => $shipping_method ) { + $method = $this->prepare_item_for_response( $shipping_method, $request ); + $method = $this->prepare_response_for_collection( $method ); + $response[] = $method; + } + return rest_ensure_response( $response ); + } + + /** + * Get a single Shipping Method. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_item( $request ) { + $wc_shipping = WC_Shipping::instance(); + $methods = $wc_shipping->get_shipping_methods(); + if ( empty( $methods[ $request['id'] ] ) ) { + return new WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $method = $methods[ $request['id'] ]; + $response = $this->prepare_item_for_response( $method, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Prepare a shipping method for response. + * + * @param WC_Shipping_Method $method Shipping method object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $method, $request ) { + $data = array( + 'id' => $method->id, + 'title' => $method->method_title, + 'description' => $method->method_description, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $method, $request ) ); + + /** + * Filter shipping methods object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WC_Shipping_Method $method Shipping method object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_shipping_method', $response, $method, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Shipping_Method $method Shipping method object. + * @param WP_REST_Request $request Request object. + * @return array + */ + protected function prepare_links( $method, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $method->id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the shipping method schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'shipping_method', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Method ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'title' => array( + 'description' => __( 'Shipping method title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'Shipping method description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get any query params needed. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-locations-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-locations-controller.php new file mode 100644 index 0000000..fb97a81 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-locations-controller.php @@ -0,0 +1,190 @@ +/locations endpoint. + * + * @package WooCommerce/API + * @since 3.0.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Shipping Zone Locations class. + * + * @package WooCommerce/API + * @extends WC_REST_Shipping_Zones_Controller_Base + */ +class WC_REST_Shipping_Zone_Locations_Controller extends WC_REST_Shipping_Zones_Controller_Base { + + /** + * Register the routes for Shipping Zone Locations. + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/locations', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique ID for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_items' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Get all Shipping Zone Locations. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_items( $request ) { + $zone = $this->get_zone( (int) $request['id'] ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $locations = $zone->get_zone_locations(); + $data = array(); + + foreach ( $locations as $location_obj ) { + $location = $this->prepare_item_for_response( $location_obj, $request ); + $location = $this->prepare_response_for_collection( $location ); + $data[] = $location; + } + + return rest_ensure_response( $data ); + } + + /** + * Update all Shipping Zone Locations. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function update_items( $request ) { + $zone = $this->get_zone( (int) $request['id'] ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + if ( 0 === $zone->get_id() ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_locations_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) ); + } + + $raw_locations = $request->get_json_params(); + $locations = array(); + + foreach ( (array) $raw_locations as $raw_location ) { + if ( empty( $raw_location['code'] ) ) { + continue; + } + + $type = ! empty( $raw_location['type'] ) ? sanitize_text_field( $raw_location['type'] ) : 'country'; + + if ( ! in_array( $type, array( 'postcode', 'state', 'country', 'continent' ), true ) ) { + continue; + } + + $locations[] = array( + 'code' => sanitize_text_field( $raw_location['code'] ), + 'type' => sanitize_text_field( $type ), + ); + } + + $zone->set_locations( $locations ); + $zone->save(); + + return $this->get_items( $request ); + } + + /** + * Prepare the Shipping Zone Location for the REST response. + * + * @param array $item Shipping Zone Location. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response + */ + public function prepare_item_for_response( $item, $request ) { + $context = empty( $request['context'] ) ? 'view' : $request['context']; + $data = $this->add_additional_fields_to_object( $item, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( (int) $request['id'] ) ); + + return $response; + } + + /** + * Prepare links for the request. + * + * @param int $zone_id Given Shipping Zone ID. + * @return array Links for the given Shipping Zone Location. + */ + protected function prepare_links( $zone_id ) { + $base = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id; + $links = array( + 'collection' => array( + 'href' => rest_url( $base . '/locations' ), + ), + 'describes' => array( + 'href' => rest_url( $base ), + ), + ); + + return $links; + } + + /** + * Get the Shipping Zone Locations schema, conforming to JSON Schema + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'shipping_zone_location', + 'type' => 'object', + 'properties' => array( + 'code' => array( + 'description' => __( 'Shipping zone location code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'type' => array( + 'description' => __( 'Shipping zone location type.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'country', + 'enum' => array( + 'postcode', + 'state', + 'country', + 'continent', + ), + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-methods-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-methods-controller.php new file mode 100644 index 0000000..c0bc3c2 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zone-methods-controller.php @@ -0,0 +1,541 @@ +/methods endpoint. + * + * @package WooCommerce/API + * @since 3.0.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Shipping Zone Methods class. + * + * @package WooCommerce/API + * @extends WC_REST_Shipping_Zones_Controller_Base + */ +class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zones_Controller_Base { + + /** + * Register the routes for Shipping Zone Methods. + */ + public function register_routes() { + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/methods', array( + 'args' => array( + 'zone_id' => array( + 'description' => __( 'Unique ID for the zone.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'method_id' => array( + 'required' => true, + 'readonly' => false, + 'description' => __( 'Shipping method ID.', 'woocommerce' ), + ), + ) + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/methods/(?P[\d]+)', array( + 'args' => array( + 'zone_id' => array( + 'description' => __( 'Unique ID for the zone.', 'woocommerce' ), + 'type' => 'integer', + ), + 'instance_id' => array( + 'description' => __( 'Unique ID for the instance.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_items_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Get a single Shipping Zone Method. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_item( $request ) { + $zone = $this->get_zone( $request['zone_id'] ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $instance_id = (int) $request['instance_id']; + $methods = $zone->get_shipping_methods(); + $method = false; + + foreach ( $methods as $method_obj ) { + if ( $instance_id === $method_obj->instance_id ) { + $method = $method_obj; + break; + } + } + + if ( false === $method ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $data = $this->prepare_item_for_response( $method, $request ); + + return rest_ensure_response( $data ); + } + + /** + * Get all Shipping Zone Methods. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_items( $request ) { + $zone = $this->get_zone( $request['zone_id'] ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $methods = $zone->get_shipping_methods(); + $data = array(); + + foreach ( $methods as $method_obj ) { + $method = $this->prepare_item_for_response( $method_obj, $request ); + $data[] = $method; + } + + return rest_ensure_response( $data ); + } + + /** + * Create a new shipping zone method instance. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function create_item( $request ) { + $method_id = $request['method_id']; + $zone = $this->get_zone( $request['zone_id'] ); + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $instance_id = $zone->add_shipping_method( $method_id ); + $methods = $zone->get_shipping_methods(); + $method = false; + foreach ( $methods as $method_obj ) { + if ( $instance_id === $method_obj->instance_id ) { + $method = $method_obj; + break; + } + } + + if ( false === $method ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( 'Resource cannot be created.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $method = $this->update_fields( $instance_id, $method, $request ); + if ( is_wp_error( $method ) ) { + return $method; + } + + $data = $this->prepare_item_for_response( $method, $request ); + return rest_ensure_response( $data ); + } + + /** + * Delete a shipping method instance. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function delete_item( $request ) { + $zone = $this->get_zone( $request['zone_id'] ); + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $instance_id = (int) $request['instance_id']; + $force = $request['force']; + + $methods = $zone->get_shipping_methods(); + $method = false; + + foreach ( $methods as $method_obj ) { + if ( $instance_id === $method_obj->instance_id ) { + $method = $method_obj; + break; + } + } + + if ( false === $method ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $method = $this->update_fields( $instance_id, $method, $request ); + if ( is_wp_error( $method ) ) { + return $method; + } + + $request->set_param( 'context', 'view' ); + $response = $this->prepare_item_for_response( $method, $request ); + + // Actually delete. + if ( $force ) { + $zone->delete_shipping_method( $instance_id ); + } else { + return new WP_Error( 'rest_trash_not_supported', __( 'Shipping methods do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + /** + * Fires after a product review is deleted via the REST API. + * + * @param object $method + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'rest_delete_product_review', $method, $response, $request ); + + return $response; + } + + /** + * Update A Single Shipping Zone Method. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function update_item( $request ) { + $zone = $this->get_zone( $request['zone_id'] ); + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $instance_id = (int) $request['instance_id']; + $methods = $zone->get_shipping_methods(); + $method = false; + + foreach ( $methods as $method_obj ) { + if ( $instance_id === $method_obj->instance_id ) { + $method = $method_obj; + break; + } + } + + if ( false === $method ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $method = $this->update_fields( $instance_id, $method, $request ); + if ( is_wp_error( $method ) ) { + return $method; + } + + $data = $this->prepare_item_for_response( $method, $request ); + return rest_ensure_response( $data ); + } + + /** + * Updates settings, order, and enabled status on create. + * + * @param int $instance_id Instance ID. + * @param WC_Shipping_Method $method Shipping method data. + * @param WP_REST_Request $request Request data. + * + * @return WC_Shipping_Method + */ + public function update_fields( $instance_id, $method, $request ) { + global $wpdb; + + // Update settings if present. + if ( isset( $request['settings'] ) ) { + $method->init_instance_settings(); + $instance_settings = $method->instance_settings; + $errors_found = false; + foreach ( $method->get_instance_form_fields() as $key => $field ) { + if ( isset( $request['settings'][ $key ] ) ) { + if ( is_callable( array( $this, 'validate_setting_' . $field['type'] . '_field' ) ) ) { + $value = $this->{'validate_setting_' . $field['type'] . '_field'}( $request['settings'][ $key ], $field ); + } else { + $value = $this->validate_setting_text_field( $request['settings'][ $key ], $field ); + } + if ( is_wp_error( $value ) ) { + $errors_found = true; + break; + } + $instance_settings[ $key ] = $value; + } + } + + if ( $errors_found ) { + return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + update_option( $method->get_instance_option_key(), apply_filters( 'woocommerce_shipping_' . $method->id . '_instance_settings_values', $instance_settings, $method ) ); + } + + // Update order. + if ( isset( $request['order'] ) ) { + $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'method_order' => absint( $request['order'] ) ), array( 'instance_id' => absint( $instance_id ) ) ); + $method->method_order = absint( $request['order'] ); + } + + // Update if this method is enabled or not. + if ( isset( $request['enabled'] ) ) { + if ( $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => $request['enabled'] ), array( 'instance_id' => absint( $instance_id ) ) ) ) { + do_action( 'woocommerce_shipping_zone_method_status_toggled', $instance_id, $method->id, $request['zone_id'], $request['enabled'] ); + $method->enabled = ( true === $request['enabled'] ? 'yes' : 'no' ); + } + } + + return $method; + } + + /** + * Prepare the Shipping Zone Method for the REST response. + * + * @param array $item Shipping Zone Method. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response + */ + public function prepare_item_for_response( $item, $request ) { + $method = array( + 'id' => $item->instance_id, + 'instance_id' => $item->instance_id, + 'title' => $item->instance_settings['title'], + 'order' => $item->method_order, + 'enabled' => ( 'yes' === $item->enabled ), + 'method_id' => $item->id, + 'method_title' => $item->method_title, + 'method_description' => $item->method_description, + 'settings' => $this->get_settings( $item ), + ); + + $context = empty( $request['context'] ) ? 'view' : $request['context']; + $data = $this->add_additional_fields_to_object( $method, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $request['zone_id'], $item->instance_id ) ); + + $response = $this->prepare_response_for_collection( $response ); + + return $response; + } + + /** + * Return settings associated with this shipping zone method instance. + * + * @param WC_Shipping_Method $item Shipping method data. + * + * @return array + */ + public function get_settings( $item ) { + $item->init_instance_settings(); + $settings = array(); + foreach ( $item->get_instance_form_fields() as $id => $field ) { + $data = array( + 'id' => $id, + 'label' => $field['title'], + 'description' => empty( $field['description'] ) ? '' : $field['description'], + 'type' => $field['type'], + 'value' => $item->instance_settings[ $id ], + 'default' => empty( $field['default'] ) ? '' : $field['default'], + 'tip' => empty( $field['description'] ) ? '' : $field['description'], + 'placeholder' => empty( $field['placeholder'] ) ? '' : $field['placeholder'], + ); + if ( ! empty( $field['options'] ) ) { + $data['options'] = $field['options']; + } + $settings[ $id ] = $data; + } + return $settings; + } + + /** + * Prepare links for the request. + * + * @param int $zone_id Given Shipping Zone ID. + * @param int $instance_id Given Shipping Zone Method Instance ID. + * @return array Links for the given Shipping Zone Method. + */ + protected function prepare_links( $zone_id, $instance_id ) { + $base = '/' . $this->namespace . '/' . $this->rest_base . '/' . $zone_id; + $links = array( + 'self' => array( + 'href' => rest_url( $base . '/methods/' . $instance_id ), + ), + 'collection' => array( + 'href' => rest_url( $base . '/methods' ), + ), + 'describes' => array( + 'href' => rest_url( $base ), + ), + ); + + return $links; + } + + /** + * Get the Shipping Zone Methods schema, conforming to JSON Schema + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'shipping_zone_method', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Shipping method instance ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'instance_id' => array( + 'description' => __( 'Shipping method instance ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'title' => array( + 'description' => __( 'Shipping method customer facing title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'order' => array( + 'description' => __( 'Shipping method sort order.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'enabled' => array( + 'description' => __( 'Shipping method enabled status.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + ), + 'method_id' => array( + 'description' => __( 'Shipping method ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'method_title' => array( + 'description' => __( 'Shipping method title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'method_description' => array( + 'description' => __( 'Shipping method description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'settings' => array( + 'description' => __( 'Shipping method settings.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'A unique identifier for the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'A human readable label for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'A human readable description for the setting used in interfaces.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'type' => array( + 'description' => __( 'Type of setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'enum' => array( 'text', 'email', 'number', 'color', 'password', 'textarea', 'select', 'multiselect', 'radio', 'image_width', 'checkbox' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Setting value.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'default' => array( + 'description' => __( 'Default value for the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tip' => array( + 'description' => __( 'Additional help text shown to the user about the setting.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'placeholder' => array( + 'description' => __( 'Placeholder text to be displayed in text inputs.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zones-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zones-controller.php new file mode 100644 index 0000000..d2d8e5b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-shipping-zones-controller.php @@ -0,0 +1,304 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'name' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Shipping zone name.', 'woocommerce' ), + ), + ) + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\d-]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique ID for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_items_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Get a single Shipping Zone. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error + */ + public function get_item( $request ) { + $zone = $this->get_zone( $request->get_param( 'id' ) ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $data = $zone->get_data(); + $data = $this->prepare_item_for_response( $data, $request ); + $data = $this->prepare_response_for_collection( $data ); + + return rest_ensure_response( $data ); + } + + /** + * Get all Shipping Zones. + * + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response + */ + public function get_items( $request ) { + $rest_of_the_world = WC_Shipping_Zones::get_zone_by( 'zone_id', 0 ); + + $zones = WC_Shipping_Zones::get_zones(); + array_unshift( $zones, $rest_of_the_world->get_data() ); + $data = array(); + + foreach ( $zones as $zone_obj ) { + $zone = $this->prepare_item_for_response( $zone_obj, $request ); + $zone = $this->prepare_response_for_collection( $zone ); + $data[] = $zone; + } + + return rest_ensure_response( $data ); + } + + /** + * Create a single Shipping Zone. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function create_item( $request ) { + $zone = new WC_Shipping_Zone( null ); + + if ( ! is_null( $request->get_param( 'name' ) ) ) { + $zone->set_zone_name( $request->get_param( 'name' ) ); + } + + if ( ! is_null( $request->get_param( 'order' ) ) ) { + $zone->set_zone_order( $request->get_param( 'order' ) ); + } + + $zone->save(); + + if ( $zone->get_id() !== 0 ) { + $request->set_param( 'id', $zone->get_id() ); + $response = $this->get_item( $request ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $zone->get_id() ) ) ); + return $response; + } else { + return new WP_Error( 'woocommerce_rest_shipping_zone_not_created', __( "Resource cannot be created. Check to make sure 'order' and 'name' are present.", 'woocommerce' ), array( 'status' => 500 ) ); + } + } + + /** + * Update a single Shipping Zone. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function update_item( $request ) { + $zone = $this->get_zone( $request->get_param( 'id' ) ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + if ( 0 === $zone->get_id() ) { + return new WP_Error( 'woocommerce_rest_shipping_zone_invalid_zone', __( 'The "locations not covered by your other zones" zone cannot be updated.', 'woocommerce' ), array( 'status' => 403 ) ); + } + + $zone_changed = false; + + if ( ! is_null( $request->get_param( 'name' ) ) ) { + $zone->set_zone_name( $request->get_param( 'name' ) ); + $zone_changed = true; + } + + if ( ! is_null( $request->get_param( 'order' ) ) ) { + $zone->set_zone_order( $request->get_param( 'order' ) ); + $zone_changed = true; + } + + if ( $zone_changed ) { + $zone->save(); + } + + return $this->get_item( $request ); + } + + /** + * Delete a single Shipping Zone. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function delete_item( $request ) { + $zone = $this->get_zone( $request->get_param( 'id' ) ); + + if ( is_wp_error( $zone ) ) { + return $zone; + } + + $force = $request['force']; + + $response = $this->get_item( $request ); + + if ( $force ) { + $zone->delete(); + } else { + return new WP_Error( 'rest_trash_not_supported', __( 'Shipping zones do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + return $response; + } + + /** + * Prepare the Shipping Zone for the REST response. + * + * @param array $item Shipping Zone. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response + */ + public function prepare_item_for_response( $item, $request ) { + $data = array( + 'id' => (int) $item['id'], + 'name' => $item['zone_name'], + 'order' => (int) $item['zone_order'], + ); + + $context = empty( $request['context'] ) ? 'view' : $request['context']; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $data['id'] ) ); + + return $response; + } + + /** + * Prepare links for the request. + * + * @param int $zone_id Given Shipping Zone ID. + * @return array Links for the given Shipping Zone. + */ + protected function prepare_links( $zone_id ) { + $base = '/' . $this->namespace . '/' . $this->rest_base; + $links = array( + 'self' => array( + 'href' => rest_url( trailingslashit( $base ) . $zone_id ), + ), + 'collection' => array( + 'href' => rest_url( $base ), + ), + 'describedby' => array( + 'href' => rest_url( trailingslashit( $base ) . $zone_id . '/locations' ), + ), + ); + + return $links; + } + + /** + * Get the Shipping Zones schema, conforming to JSON Schema + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'shipping_zone', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Shipping zone name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'order' => array( + 'description' => __( 'Shipping zone order.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-controller.php new file mode 100644 index 0000000..b8c3f1d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-controller.php @@ -0,0 +1,1076 @@ +namespace, '/' . $this->rest_base, + array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Check whether a given request has permission to view system status. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Get a system status info, by section. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $schema = $this->get_item_schema(); + $mappings = $this->get_item_mappings(); + $response = array(); + + foreach ( $mappings as $section => $values ) { + foreach ( $values as $key => $value ) { + if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) { + settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] ); + } + } + settype( $values, $schema['properties'][ $section ]['type'] ); + $response[ $section ] = $values; + } + + $response = $this->prepare_item_for_response( $response, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Get the system status schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'system_status', + 'type' => 'object', + 'properties' => array( + 'environment' => array( + 'description' => __( 'Environment.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'home_url' => array( + 'description' => __( 'Home URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'site_url' => array( + 'description' => __( 'Site URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wc_version' => array( + 'description' => __( 'WooCommerce version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'log_directory' => array( + 'description' => __( 'Log directory.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'log_directory_writable' => array( + 'description' => __( 'Is log directory writable?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wp_version' => array( + 'description' => __( 'WordPress version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wp_multisite' => array( + 'description' => __( 'Is WordPress multisite?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wp_memory_limit' => array( + 'description' => __( 'WordPress memory limit.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wp_debug_mode' => array( + 'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'wp_cron' => array( + 'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'language' => array( + 'description' => __( 'WordPress language.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'server_info' => array( + 'description' => __( 'Server info.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'php_version' => array( + 'description' => __( 'PHP version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'php_post_max_size' => array( + 'description' => __( 'PHP post max size.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'php_max_execution_time' => array( + 'description' => __( 'PHP max execution time.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'php_max_input_vars' => array( + 'description' => __( 'PHP max input vars.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'curl_version' => array( + 'description' => __( 'cURL version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'suhosin_installed' => array( + 'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'max_upload_size' => array( + 'description' => __( 'Max upload size.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'mysql_version' => array( + 'description' => __( 'MySQL version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'mysql_version_string' => array( + 'description' => __( 'MySQL version string.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'default_timezone' => array( + 'description' => __( 'Default timezone.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'fsockopen_or_curl_enabled' => array( + 'description' => __( 'Is fsockopen/cURL enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'soapclient_enabled' => array( + 'description' => __( 'Is SoapClient class enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'domdocument_enabled' => array( + 'description' => __( 'Is DomDocument class enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'gzip_enabled' => array( + 'description' => __( 'Is GZip enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'mbstring_enabled' => array( + 'description' => __( 'Is mbstring enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'remote_post_successful' => array( + 'description' => __( 'Remote POST successful?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'remote_post_response' => array( + 'description' => __( 'Remote POST response.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'remote_get_successful' => array( + 'description' => __( 'Remote GET successful?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'remote_get_response' => array( + 'description' => __( 'Remote GET response.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ), + 'database' => array( + 'description' => __( 'Database.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'wc_database_version' => array( + 'description' => __( 'WC database version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'database_prefix' => array( + 'description' => __( 'Database prefix.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'maxmind_geoip_database' => array( + 'description' => __( 'MaxMind GeoIP database.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'database_tables' => array( + 'description' => __( 'Database tables.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + ), + ), + 'active_plugins' => array( + 'description' => __( 'Active plugins.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'theme' => array( + 'description' => __( 'Theme.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'name' => array( + 'description' => __( 'Theme name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'version' => array( + 'description' => __( 'Theme version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'version_latest' => array( + 'description' => __( 'Latest version of theme.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'author_url' => array( + 'description' => __( 'Theme author URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'is_child_theme' => array( + 'description' => __( 'Is this theme a child theme?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'has_woocommerce_support' => array( + 'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'has_woocommerce_file' => array( + 'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'has_outdated_templates' => array( + 'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'overrides' => array( + 'description' => __( 'Template overrides.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'parent_name' => array( + 'description' => __( 'Parent theme name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'parent_version' => array( + 'description' => __( 'Parent theme version.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'parent_author_url' => array( + 'description' => __( 'Parent theme author URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ), + 'settings' => array( + 'description' => __( 'Settings.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'api_enabled' => array( + 'description' => __( 'REST API enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'force_ssl' => array( + 'description' => __( 'SSL forced?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'currency' => array( + 'description' => __( 'Currency.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'currency_symbol' => array( + 'description' => __( 'Currency symbol.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'currency_position' => array( + 'description' => __( 'Currency position.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'thousand_separator' => array( + 'description' => __( 'Thousand separator.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'decimal_separator' => array( + 'description' => __( 'Decimal separator.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'number_of_decimals' => array( + 'description' => __( 'Number of decimals.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'geolocation_enabled' => array( + 'description' => __( 'Geolocation enabled?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'taxonomies' => array( + 'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'product_visibility_terms' => array( + 'description' => __( 'Terms in the product visibility taxonomy.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + ), + ), + 'security' => array( + 'description' => __( 'Security.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'secure_connection' => array( + 'description' => __( 'Is the connection to your store secure?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'hide_errors' => array( + 'description' => __( 'Hide errors from visitors?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ), + 'pages' => array( + 'description' => __( 'WooCommerce pages.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Return an array of sections and the data associated with each. + * + * @return array + */ + public function get_item_mappings() { + return array( + 'environment' => $this->get_environment_info(), + 'database' => $this->get_database_info(), + 'active_plugins' => $this->get_active_plugins(), + 'theme' => $this->get_theme_info(), + 'settings' => $this->get_settings(), + 'security' => $this->get_security_info(), + 'pages' => $this->get_pages(), + ); + } + + /** + * Get array of environment information. Includes thing like software + * versions, and various server settings. + * + * @return array + */ + public function get_environment_info() { + global $wpdb; + + // Figure out cURL version, if installed. + $curl_version = ''; + if ( function_exists( 'curl_version' ) ) { + $curl_version = curl_version(); + $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; + } + + // WP memory limit. + $wp_memory_limit = wc_let_to_num( WP_MEMORY_LIMIT ); + if ( function_exists( 'memory_get_usage' ) ) { + $wp_memory_limit = max( $wp_memory_limit, wc_let_to_num( @ini_get( 'memory_limit' ) ) ); + } + + // Test POST requests. + $post_response = wp_safe_remote_post( + 'https://www.paypal.com/cgi-bin/webscr', + array( + 'timeout' => 10, + 'user-agent' => 'WooCommerce/' . WC()->version, + 'httpversion' => '1.1', + 'body' => array( + 'cmd' => '_notify-validate', + ), + ) + ); + $post_response_successful = false; + if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { + $post_response_successful = true; + } + + // Test GET requests. + $get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); + $get_response_successful = false; + if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { + $get_response_successful = true; + } + + $database_version = wc_get_server_database_version(); + + // Return all environment info. Described by JSON Schema. + return array( + 'home_url' => get_option( 'home' ), + 'site_url' => get_option( 'siteurl' ), + 'version' => WC()->version, + 'log_directory' => WC_LOG_DIR, + 'log_directory_writable' => (bool) @fopen( WC_LOG_DIR . 'test-log.log', 'a' ), + 'wp_version' => get_bloginfo( 'version' ), + 'wp_multisite' => is_multisite(), + 'wp_memory_limit' => $wp_memory_limit, + 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), + 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), + 'language' => get_locale(), + 'external_object_cache' => wp_using_ext_object_cache(), + 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '', + 'php_version' => phpversion(), + 'php_post_max_size' => wc_let_to_num( ini_get( 'post_max_size' ) ), + 'php_max_execution_time' => ini_get( 'max_execution_time' ), + 'php_max_input_vars' => ini_get( 'max_input_vars' ), + 'curl_version' => $curl_version, + 'suhosin_installed' => extension_loaded( 'suhosin' ), + 'max_upload_size' => wp_max_upload_size(), + 'mysql_version' => $database_version['number'], + 'mysql_version_string' => $database_version['string'], + 'default_timezone' => date_default_timezone_get(), + 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), + 'soapclient_enabled' => class_exists( 'SoapClient' ), + 'domdocument_enabled' => class_exists( 'DOMDocument' ), + 'gzip_enabled' => is_callable( 'gzopen' ), + 'mbstring_enabled' => extension_loaded( 'mbstring' ), + 'remote_post_successful' => $post_response_successful, + 'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ), + 'remote_get_successful' => $get_response_successful, + 'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ), + ); + } + + /** + * Add prefix to table. + * + * @param string $table Table name. + * @return stromg + */ + protected function add_db_table_prefix( $table ) { + global $wpdb; + return $wpdb->prefix . $table; + } + + /** + * Get array of database information. Version, prefix, and table existence. + * + * @return array + */ + public function get_database_info() { + global $wpdb; + + $database_table_sizes = $wpdb->get_results( + $wpdb->prepare( + "SELECT + table_name AS 'name', + round( ( data_length / 1024 / 1024 ), 2 ) 'data', + round( ( index_length / 1024 / 1024 ), 2 ) 'index' + FROM information_schema.TABLES + WHERE table_schema = %s + ORDER BY name ASC;", + DB_NAME + ) + ); + + // WC Core tables to check existence of. + $core_tables = apply_filters( + 'woocommerce_database_tables', + array( + 'woocommerce_sessions', + 'woocommerce_api_keys', + 'woocommerce_attribute_taxonomies', + 'woocommerce_downloadable_product_permissions', + 'woocommerce_order_items', + 'woocommerce_order_itemmeta', + 'woocommerce_tax_rates', + 'woocommerce_tax_rate_locations', + 'woocommerce_shipping_zones', + 'woocommerce_shipping_zone_locations', + 'woocommerce_shipping_zone_methods', + 'woocommerce_payment_tokens', + 'woocommerce_payment_tokenmeta', + 'woocommerce_log', + ) + ); + + if ( get_option( 'db_version' ) < 34370 ) { + $core_tables[] = 'woocommerce_termmeta'; + } + + /** + * Adding the prefix to the tables array, for backwards compatibility. + * + * If we changed the tables above to include the prefix, then any filters against that table could break. + */ + $core_tables = array_map( array( $this, 'add_db_table_prefix' ), $core_tables ); + + /** + * Organize WooCommerce and non-WooCommerce tables separately for display purposes later. + * + * To ensure we include all WC tables, even if they do not exist, pre-populate the WC array with all the tables. + */ + $tables = array( + 'woocommerce' => array_fill_keys( $core_tables, false ), + 'other' => array(), + ); + + $database_size = array( + 'data' => 0, + 'index' => 0, + ); + + foreach ( $database_table_sizes as $table ) { + $table_type = in_array( $table->name, $core_tables ) ? 'woocommerce' : 'other'; + + $tables[ $table_type ][ $table->name ] = array( + 'data' => $table->data, + 'index' => $table->index, + ); + + $database_size['data'] += $table->data; + $database_size['index'] += $table->index; + } + + // Return all database info. Described by JSON Schema. + return array( + 'wc_database_version' => get_option( 'woocommerce_db_version' ), + 'database_prefix' => $wpdb->prefix, + 'maxmind_geoip_database' => WC_Geolocation::get_local_database_path(), + 'database_tables' => $tables, + 'database_size' => $database_size, + ); + } + + /** + * Get array of counts of objects. Orders, products, etc. + * + * @return array + */ + public function get_post_type_counts() { + global $wpdb; + + $post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" ); + + return is_array( $post_type_counts ) ? $post_type_counts : array(); + } + + /** + * Get a list of plugins active on the site. + * + * @return array + */ + public function get_active_plugins() { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + require_once ABSPATH . 'wp-admin/includes/update.php'; + + if ( ! function_exists( 'get_plugin_updates' ) ) { + return array(); + } + + // Get both site plugins and network plugins. + $active_plugins = (array) get_option( 'active_plugins', array() ); + if ( is_multisite() ) { + $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); + $active_plugins = array_merge( $active_plugins, $network_activated_plugins ); + } + + $active_plugins_data = array(); + $available_updates = get_plugin_updates(); + + foreach ( $active_plugins as $plugin ) { + $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); + $dirname = dirname( $plugin ); + $version_latest = ''; + $slug = explode( '/', $plugin ); + $slug = explode( '.', end( $slug ) ); + $slug = $slug[0]; + + if ( 'woocommerce' !== $slug && ( strstr( $data['PluginURI'], 'woothemes.com' ) || strstr( $data['PluginURI'], 'woocommerce.com' ) ) ) { + $version_data = get_transient( md5( $plugin ) . '_version_data' ); + if ( false === $version_data ) { + $changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' ); + $cl_lines = explode( "\n", wp_remote_retrieve_body( $changelog ) ); + if ( ! empty( $cl_lines ) ) { + foreach ( $cl_lines as $line_num => $cl_line ) { + if ( preg_match( '/^[0-9]/', $cl_line ) ) { + $date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) ); + $version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) ); + $update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) ); + $version_data = array( + 'date' => $date, + 'version' => $version, + 'update' => $update, + 'changelog' => $changelog, + ); + set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS ); + break; + } + } + } + } + $version_latest = $version_data['version']; + } elseif ( isset( $available_updates[ $plugin ]->update->new_version ) ) { + $version_latest = $available_updates[ $plugin ]->update->new_version; + } + + // convert plugin data to json response format. + $active_plugins_data[] = array( + 'plugin' => $plugin, + 'name' => $data['Name'], + 'version' => $data['Version'], + 'version_latest' => $version_latest, + 'url' => $data['PluginURI'], + 'author_name' => $data['AuthorName'], + 'author_url' => esc_url_raw( $data['AuthorURI'] ), + 'network_activated' => $data['Network'], + ); + } + + return $active_plugins_data; + } + + /** + * Get info on the current active theme, info on parent theme (if presnet) + * and a list of template overrides. + * + * @return array + */ + public function get_theme_info() { + $active_theme = wp_get_theme(); + + // Get parent theme info if this theme is a child theme, otherwise + // pass empty info in the response. + if ( is_child_theme() ) { + $parent_theme = wp_get_theme( $active_theme->template ); + $parent_theme_info = array( + 'parent_name' => $parent_theme->name, + 'parent_version' => $parent_theme->version, + 'parent_version_latest' => WC_Admin_Status::get_latest_theme_version( $parent_theme ), + 'parent_author_url' => $parent_theme->{'Author URI'}, + ); + } else { + $parent_theme_info = array( + 'parent_name' => '', + 'parent_version' => '', + 'parent_version_latest' => '', + 'parent_author_url' => '', + ); + } + + /** + * Scan the theme directory for all WC templates to see if our theme + * overrides any of them. + */ + $override_files = array(); + $outdated_templates = false; + $scan_files = WC_Admin_Status::scan_template_files( WC()->plugin_path() . '/templates/' ); + foreach ( $scan_files as $file ) { + $located = apply_filters( 'wc_get_template', $file, $file, array(), WC()->template_path(), WC()->plugin_path() . '/templates/' ); + + if ( file_exists( $located ) ) { + $theme_file = $located; + } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . $file; + } elseif ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file; + } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { + $theme_file = get_template_directory() . '/' . $file; + } elseif ( file_exists( get_template_directory() . '/' . WC()->template_path() . $file ) ) { + $theme_file = get_template_directory() . '/' . WC()->template_path() . $file; + } else { + $theme_file = false; + } + + if ( ! empty( $theme_file ) ) { + $core_version = WC_Admin_Status::get_file_version( WC()->plugin_path() . '/templates/' . $file ); + $theme_version = WC_Admin_Status::get_file_version( $theme_file ); + if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { + if ( ! $outdated_templates ) { + $outdated_templates = true; + } + } + $override_files[] = array( + 'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), + 'version' => $theme_version, + 'core_version' => $core_version, + ); + } + } + + $active_theme_info = array( + 'name' => $active_theme->name, + 'version' => $active_theme->version, + 'version_latest' => WC_Admin_Status::get_latest_theme_version( $active_theme ), + 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), + 'is_child_theme' => is_child_theme(), + 'has_woocommerce_support' => current_theme_supports( 'woocommerce' ), + 'has_woocommerce_file' => ( file_exists( get_stylesheet_directory() . '/woocommerce.php' ) || file_exists( get_template_directory() . '/woocommerce.php' ) ), + 'has_outdated_templates' => $outdated_templates, + 'overrides' => $override_files, + ); + + return array_merge( $active_theme_info, $parent_theme_info ); + } + + /** + * Get some setting values for the site that are useful for debugging + * purposes. For full settings access, use the settings api. + * + * @return array + */ + public function get_settings() { + // Get a list of terms used for product/order taxonomies. + $term_response = array(); + $terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) ); + foreach ( $terms as $term ) { + $term_response[ $term->slug ] = strtolower( $term->name ); + } + + // Get a list of terms used for product visibility. + $product_visibility_terms = array(); + $terms = get_terms( 'product_visibility', array( 'hide_empty' => 0 ) ); + foreach ( $terms as $term ) { + $product_visibility_terms[ $term->slug ] = strtolower( $term->name ); + } + + // Return array of useful settings for debugging. + return array( + 'api_enabled' => 'yes' === get_option( 'woocommerce_api_enabled' ), + 'force_ssl' => 'yes' === get_option( 'woocommerce_force_ssl_checkout' ), + 'currency' => get_woocommerce_currency(), + 'currency_symbol' => get_woocommerce_currency_symbol(), + 'currency_position' => get_option( 'woocommerce_currency_pos' ), + 'thousand_separator' => wc_get_price_thousand_separator(), + 'decimal_separator' => wc_get_price_decimal_separator(), + 'number_of_decimals' => wc_get_price_decimals(), + 'geolocation_enabled' => in_array( get_option( 'woocommerce_default_customer_address' ), array( 'geolocation_ajax', 'geolocation' ) ), + 'taxonomies' => $term_response, + 'product_visibility_terms' => $product_visibility_terms, + ); + } + + /** + * Returns security tips. + * + * @return array + */ + public function get_security_info() { + $check_page = 0 < wc_get_page_id( 'shop' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : get_home_url(); + return array( + 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), + 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), + ); + } + + /** + * Returns a mini-report on WC pages and if they are configured correctly: + * Present, visible, and including the correct shortcode. + * + * @return array + */ + public function get_pages() { + // WC pages to check against. + $check_pages = array( + _x( 'Shop base', 'Page setting', 'woocommerce' ) => array( + 'option' => 'woocommerce_shop_page_id', + 'shortcode' => '', + ), + _x( 'Cart', 'Page setting', 'woocommerce' ) => array( + 'option' => 'woocommerce_cart_page_id', + 'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']', + ), + _x( 'Checkout', 'Page setting', 'woocommerce' ) => array( + 'option' => 'woocommerce_checkout_page_id', + 'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']', + ), + _x( 'My account', 'Page setting', 'woocommerce' ) => array( + 'option' => 'woocommerce_myaccount_page_id', + 'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']', + ), + _x( 'Terms and conditions', 'Page setting', 'woocommerce' ) => array( + 'option' => 'woocommerce_terms_page_id', + 'shortcode' => '', + ), + ); + + $pages_output = array(); + foreach ( $check_pages as $page_name => $values ) { + $page_id = get_option( $values['option'] ); + $page_set = false; + $page_exists = false; + $page_visible = false; + $shortcode_present = false; + $shortcode_required = false; + + // Page checks. + if ( $page_id ) { + $page_set = true; + } + if ( get_post( $page_id ) ) { + $page_exists = true; + } + if ( 'publish' === get_post_status( $page_id ) ) { + $page_visible = true; + } + + // Shortcode checks. + if ( $values['shortcode'] && get_post( $page_id ) ) { + $shortcode_required = true; + $page = get_post( $page_id ); + if ( strstr( $page->post_content, $values['shortcode'] ) ) { + $shortcode_present = true; + } + } + + // Wrap up our findings into an output array. + $pages_output[] = array( + 'page_name' => $page_name, + 'page_id' => $page_id, + 'page_set' => $page_set, + 'page_exists' => $page_exists, + 'page_visible' => $page_visible, + 'shortcode' => $values['shortcode'], + 'shortcode_required' => $shortcode_required, + 'shortcode_present' => $shortcode_present, + ); + } + + return $pages_output; + } + + /** + * Get any query params needed. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } + + /** + * Prepare the system status response + * + * @param array $system_status System status data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_item_for_response( $system_status, $request ) { + $data = $this->add_additional_fields_to_object( $system_status, $request ); + $data = $this->filter_response_by_context( $data, 'view' ); + + $response = rest_ensure_response( $data ); + + /** + * Filter the system status returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param mixed $system_status System status + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_system_status', $response, $system_status, $request ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-tools-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-tools-controller.php new file mode 100644 index 0000000..b5302f0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-system-status-tools-controller.php @@ -0,0 +1,557 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, '/' . $this->rest_base . '/(?P[\w-]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Check whether a given request has permission to view system status tools. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check whether a given request has permission to view a specific system status tool. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'system_status', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check whether a given request has permission to execute a specific system status tool. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'system_status', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * A list of available tools for use in the system status section. + * 'button' becomes 'action' in the API. + * + * @return array + */ + public function get_tools() { + $tools = array( + 'clear_transients' => array( + 'name' => __( 'WooCommerce transients', 'woocommerce' ), + 'button' => __( 'Clear transients', 'woocommerce' ), + 'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ), + ), + 'clear_expired_transients' => array( + 'name' => __( 'Expired transients', 'woocommerce' ), + 'button' => __( 'Clear transients', 'woocommerce' ), + 'desc' => __( 'This tool will clear ALL expired transients from WordPress.', 'woocommerce' ), + ), + 'delete_orphaned_variations' => array( + 'name' => __( 'Orphaned variations', 'woocommerce' ), + 'button' => __( 'Delete orphaned variations', 'woocommerce' ), + 'desc' => __( 'This tool will delete all variations which have no parent.', 'woocommerce' ), + ), + 'clear_expired_download_permissions' => array( + 'name' => __( 'Used-up download permissions', 'woocommerce' ), + 'button' => __( 'Clean up download permissions', 'woocommerce' ), + 'desc' => __( 'This tool will delete expired download permissions and permissions with 0 remaining downloads.', 'woocommerce' ), + ), + 'add_order_indexes' => array( + 'name' => __( 'Order address indexes', 'woocommerce' ), + 'button' => __( 'Index orders', 'woocommerce' ), + 'desc' => __( 'This tool will add address indexes to orders that do not have them yet. This improves order search results.', 'woocommerce' ), + ), + 'recount_terms' => array( + 'name' => __( 'Term counts', 'woocommerce' ), + 'button' => __( 'Recount terms', 'woocommerce' ), + 'desc' => __( 'This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', 'woocommerce' ), + ), + 'reset_roles' => array( + 'name' => __( 'Capabilities', 'woocommerce' ), + 'button' => __( 'Reset capabilities', 'woocommerce' ), + 'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ), + ), + 'clear_sessions' => array( + 'name' => __( 'Clear customer sessions', 'woocommerce' ), + 'button' => __( 'Clear', 'woocommerce' ), + 'desc' => sprintf( + '%1$s %2$s', + __( 'Note:', 'woocommerce' ), + __( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce' ) + ), + ), + 'install_pages' => array( + 'name' => __( 'Create default WooCommerce pages', 'woocommerce' ), + 'button' => __( 'Create pages', 'woocommerce' ), + 'desc' => sprintf( + '%1$s %2$s', + __( 'Note:', 'woocommerce' ), + __( 'This tool will install all the missing WooCommerce pages. Pages already defined and set up will not be replaced.', 'woocommerce' ) + ), + ), + 'delete_taxes' => array( + 'name' => __( 'Delete WooCommerce tax rates', 'woocommerce' ), + 'button' => __( 'Delete tax rates', 'woocommerce' ), + 'desc' => sprintf( + '%1$s %2$s', + __( 'Note:', 'woocommerce' ), + __( 'This option will delete ALL of your tax rates, use with caution. This action cannot be reversed.', 'woocommerce' ) + ), + ), + 'reset_tracking' => array( + 'name' => __( 'Reset usage tracking', 'woocommerce' ), + 'button' => __( 'Reset', 'woocommerce' ), + 'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'woocommerce' ), + ), + 'regenerate_thumbnails' => array( + 'name' => __( 'Regenerate shop thumbnails', 'woocommerce' ), + 'button' => __( 'Regenerate', 'woocommerce' ), + 'desc' => __( 'This will regenerate all shop thumbnails to match your theme and/or image settings.', 'woocommerce' ), + ), + ); + + // Jetpack does the image resizing heavy lifting so you don't have to. + if ( ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) || ! apply_filters( 'woocommerce_background_image_regeneration', true ) ) { + unset( $tools['regenerate_thumbnails'] ); + } + + return apply_filters( 'woocommerce_debug_tools', $tools ); + } + + /** + * Get a list of system status tools. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $tools = array(); + foreach ( $this->get_tools() as $id => $tool ) { + $tools[] = $this->prepare_response_for_collection( + $this->prepare_item_for_response( + array( + 'id' => $id, + 'name' => $tool['name'], + 'action' => $tool['button'], + 'description' => $tool['desc'], + ), $request + ) + ); + } + + $response = rest_ensure_response( $tools ); + return $response; + } + + /** + * Return a single tool. + * + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $tools = $this->get_tools(); + if ( empty( $tools[ $request['id'] ] ) ) { + return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + $tool = $tools[ $request['id'] ]; + return rest_ensure_response( + $this->prepare_item_for_response( + array( + 'id' => $request['id'], + 'name' => $tool['name'], + 'action' => $tool['button'], + 'description' => $tool['desc'], + ), $request + ) + ); + } + + /** + * Update (execute) a tool. + * + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $tools = $this->get_tools(); + if ( empty( $tools[ $request['id'] ] ) ) { + return new WP_Error( 'woocommerce_rest_system_status_tool_invalid_id', __( 'Invalid tool ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $tool = $tools[ $request['id'] ]; + $tool = array( + 'id' => $request['id'], + 'name' => $tool['name'], + 'action' => $tool['button'], + 'description' => $tool['desc'], + ); + + $execute_return = $this->execute_tool( $request['id'] ); + $tool = array_merge( $tool, $execute_return ); + + /** + * Fires after a WooCommerce REST system status tool has been executed. + * + * @param array $tool Details about the tool that has been executed. + * @param WP_REST_Request $request The current WP_REST_Request object. + */ + do_action( 'woocommerce_rest_insert_system_status_tool', $tool, $request ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tool, $request ); + return rest_ensure_response( $response ); + } + + /** + * Prepare a tool item for serialization. + * + * @param array $item Object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $item, $request ) { + $context = empty( $request['context'] ) ? 'view' : $request['context']; + $data = $this->add_additional_fields_to_object( $item, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item['id'] ) ); + + return $response; + } + + /** + * Get the system status tools schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'system_status_tool', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'A unique identifier for the tool.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'name' => array( + 'description' => __( 'Tool name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'action' => array( + 'description' => __( 'What running the tool will do.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'description' => array( + 'description' => __( 'Tool description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'success' => array( + 'description' => __( 'Did the tool run successfully?', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'edit' ), + ), + 'message' => array( + 'description' => __( 'Tool return message.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Prepare links for the request. + * + * @param string $id ID. + * @return array + */ + protected function prepare_links( $id ) { + $base = '/' . $this->namespace . '/' . $this->rest_base; + $links = array( + 'item' => array( + 'href' => rest_url( trailingslashit( $base ) . $id ), + 'embeddable' => true, + ), + ); + + return $links; + } + + /** + * Get any query params needed. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } + + /** + * Actually executes a tool. + * + * @param string $tool Tool. + * @return array + */ + public function execute_tool( $tool ) { + global $wpdb; + $ran = true; + switch ( $tool ) { + case 'clear_transients': + wc_delete_product_transients(); + wc_delete_shop_order_transients(); + WC_Cache_Helper::get_transient_version( 'shipping', true ); + $message = __( 'Product transients cleared', 'woocommerce' ); + break; + + case 'clear_expired_transients': + /* translators: %d: amount of expired transients */ + $message = sprintf( __( '%d transients rows cleared', 'woocommerce' ), wc_delete_expired_transients() ); + break; + + case 'delete_orphaned_variations': + // Delete orphans. + $result = absint( + $wpdb->query( + "DELETE products + FROM {$wpdb->posts} products + LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent + WHERE wp.ID IS NULL AND products.post_type = 'product_variation';" + ) + ); + /* translators: %d: amount of orphaned variations */ + $message = sprintf( __( '%d orphaned variations deleted', 'woocommerce' ), $result ); + break; + + case 'clear_expired_download_permissions': + // Delete expired download permissions and ones with 0 downloads remaining. + $result = absint( + $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE ( downloads_remaining != '' AND downloads_remaining = 0 ) OR ( access_expires IS NOT NULL AND access_expires < %s )", + date( 'Y-m-d', current_time( 'timestamp' ) ) + ) + ) + ); + /* translators: %d: amount of permissions */ + $message = sprintf( __( '%d permissions deleted', 'woocommerce' ), $result ); + break; + + case 'add_order_indexes': + /* + * Add billing and shipping address indexes containing the customer name for orders + * that don't have address indexes yet. + */ + $sql = "INSERT INTO {$wpdb->postmeta}( post_id, meta_key, meta_value ) + SELECT post_id, '%s', GROUP_CONCAT( meta_value SEPARATOR ' ' ) + FROM {$wpdb->postmeta} + WHERE meta_key IN ( '%s', '%s' ) + AND post_id IN ( SELECT DISTINCT post_id FROM {$wpdb->postmeta} + WHERE post_id NOT IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%s' ) + AND post_id IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%s' ) ) + GROUP BY post_id"; + $rows = $wpdb->query( $wpdb->prepare( $sql, '_billing_address_index', '_billing_first_name', '_billing_last_name', '_billing_address_index', '_billing_last_name' ) ); // WPCS: unprepared SQL ok. + $rows += $wpdb->query( $wpdb->prepare( $sql, '_shipping_address_index', '_shipping_first_name', '_shipping_last_name', '_shipping_address_index', '_shipping_last_name' ) ); // WPCS: unprepared SQL ok. + + /* translators: %d: amount of indexes */ + $message = sprintf( __( '%d indexes added', 'woocommerce' ), $rows ); + break; + + case 'reset_roles': + // Remove then re-add caps and roles. + WC_Install::remove_roles(); + WC_Install::create_roles(); + $message = __( 'Roles successfully reset', 'woocommerce' ); + break; + + case 'recount_terms': + $product_cats = get_terms( + 'product_cat', array( + 'hide_empty' => false, + 'fields' => 'id=>parent', + ) + ); + _wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), true, false ); + $product_tags = get_terms( + 'product_tag', array( + 'hide_empty' => false, + 'fields' => 'id=>parent', + ) + ); + _wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), true, false ); + $message = __( 'Terms successfully recounted', 'woocommerce' ); + break; + + case 'clear_sessions': + $wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" ); + $result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) ); // WPCS: unprepared SQL ok. + wp_cache_flush(); + /* translators: %d: amount of sessions */ + $message = sprintf( __( 'Deleted all active sessions, and %d saved carts.', 'woocommerce' ), absint( $result ) ); + break; + + case 'install_pages': + WC_Install::create_pages(); + $message = __( 'All missing WooCommerce pages successfully installed', 'woocommerce' ); + break; + + case 'delete_taxes': + $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates;" ); + $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations;" ); + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + $message = __( 'Tax rates successfully deleted', 'woocommerce' ); + break; + + case 'reset_tracking': + if ( ! class_exists( 'WC_Tracker' ) ) { + include_once WC_ABSPATH . 'includes/class-wc-tracker.php'; + } + WC_Tracker::opt_out_request(); + delete_option( 'woocommerce_allow_tracking' ); + WC_Admin_Notices::add_notice( 'tracking' ); + $message = __( 'Usage tracking settings successfully reset.', 'woocommerce' ); + break; + + case 'regenerate_thumbnails': + WC_Regenerate_Images::queue_image_regeneration(); + $message = __( 'Thumbnail regeneration has been scheduled to run in the background.', 'woocommerce' ); + break; + + default: + $tools = $this->get_tools(); + if ( isset( $tools[ $tool ]['callback'] ) ) { + $callback = $tools[ $tool ]['callback']; + $return = call_user_func( $callback ); + if ( is_string( $return ) ) { + $message = $return; + } elseif ( false === $return ) { + $callback_string = is_array( $callback ) ? get_class( $callback[0] ) . '::' . $callback[1] : $callback; + $ran = false; + /* translators: %s: callback string */ + $message = sprintf( __( 'There was an error calling %s', 'woocommerce' ), $callback_string ); + } else { + $message = __( 'Tool ran.', 'woocommerce' ); + } + } else { + $ran = false; + $message = __( 'There was an error calling this tool. There is no callback present.', 'woocommerce' ); + } + break; + } + + return array( + 'success' => $ran, + 'message' => $message, + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-tax-classes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-tax-classes-controller.php new file mode 100644 index 0000000..eb36a2d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-tax-classes-controller.php @@ -0,0 +1,27 @@ +/deliveries endpoint. + * + * @package WooCommerce/API + * @since 2.6.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * REST API Webhook Deliveries controller class. + * + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @package WooCommerce/API + * @extends WC_REST_Webhook_Deliveries_V1_Controller + */ +class WC_REST_Webhook_Deliveries_Controller extends WC_REST_Webhook_Deliveries_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v2'; + + /** + * Prepare a single webhook delivery output for response. + * + * @param stdClass $log Delivery log object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_item_for_response( $log, $request ) { + $data = (array) $log; + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $log ) ); + + /** + * Filter webhook delivery object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $log Delivery log object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_webhook_delivery', $response, $log, $request ); + } + + /** + * Get the Webhook's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'webhook_delivery', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'duration' => array( + 'description' => __( 'The delivery duration, in seconds.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'summary' => array( + 'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'request_url' => array( + 'description' => __( 'The URL where the webhook was delivered.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'request_headers' => array( + 'description' => __( 'Request headers.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'request_body' => array( + 'description' => __( 'Request body.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_code' => array( + 'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_message' => array( + 'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_headers' => array( + 'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'response_body' => array( + 'description' => __( 'The response body from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the webhook delivery was logged, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-webhooks-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-webhooks-controller.php new file mode 100644 index 0000000..f5cc00e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/class-wc-rest-webhooks-controller.php @@ -0,0 +1,185 @@ +post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $data = array( + 'id' => $webhook->get_id(), + 'name' => $webhook->get_name(), + 'status' => $webhook->get_status(), + 'topic' => $webhook->get_topic(), + 'resource' => $webhook->get_resource(), + 'event' => $webhook->get_event(), + 'hooks' => $webhook->get_hooks(), + 'delivery_url' => $webhook->get_delivery_url(), + 'date_created' => wc_rest_prepare_date_response( $webhook->get_date_created(), false ), + 'date_created_gmt' => wc_rest_prepare_date_response( $webhook->get_date_created() ), + 'date_modified' => wc_rest_prepare_date_response( $webhook->get_date_modified(), false ), + 'date_modified_gmt' => wc_rest_prepare_date_response( $webhook->get_date_modified() ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $webhook->get_id(), $request ) ); + + /** + * Filter webhook object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WC_Webhook $webhook Webhook object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request ); + } + + /** + * Get the default REST API version. + * + * @since 3.0.0 + * @return string + */ + protected function get_default_api_version() { + return 'wp_api_v2'; + } + + /** + * Get the Webhook's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'webhook', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'A friendly name for the webhook.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'status' => array( + 'description' => __( 'Webhook status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'active', + 'enum' => array( 'active', 'paused', 'disabled' ), + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wc_is_webhook_valid_topic', + ), + ), + 'topic' => array( + 'description' => __( 'Webhook topic.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'resource' => array( + 'description' => __( 'Webhook resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'event' => array( + 'description' => __( 'Webhook event.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'hooks' => array( + 'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'delivery_url' => array( + 'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'secret' => array( + 'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created_gmt' => array( + 'description' => __( 'The date the webhook was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified_gmt' => array( + 'description' => __( 'The date the webhook was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-coupons-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-coupons-controller.php new file mode 100644 index 0000000..3378de4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-coupons-controller.php @@ -0,0 +1,164 @@ +ID ); + $data = $coupon->get_data(); + + $format_decimal = array( 'amount', 'minimum_amount', 'maximum_amount' ); + $format_date = array( 'date_created', 'date_modified', 'date_expires' ); + $format_null = array( 'usage_limit', 'usage_limit_per_user', 'limit_usage_to_x_items' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], 2 ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $data[ $key ] = $data[ $key ] ? wc_rest_prepare_date_response( get_gmt_from_date( date( 'Y-m-d H:i:s', $data[ $key ] ) ) ) : null; + } + + // Format null values. + foreach ( $format_null as $key ) { + $data[ $key ] = $data[ $key ] ? $data[ $key ] : null; + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $post, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Prepare a single coupon for create or update. + * + * @deprecated 3.0.0 + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|stdClass $data Post object. + */ + protected function prepare_item_for_database( $request ) { + global $wpdb; + + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $coupon = new WC_Coupon( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Validate required POST fields. + if ( 'POST' === $request->get_method() && 0 === $coupon->get_id() ) { + if ( empty( $request['code'] ) ) { + return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) ); + } + } + + // Handle all writable props. + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'code' : + $coupon_code = wc_format_coupon_code( $value ); + $id = $coupon->get_id() ? $coupon->get_id() : 0; + $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); + + if ( $id_from_code ) { + return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $coupon->set_code( $coupon_code ); + break; + case 'meta_data' : + if ( is_array( $value ) ) { + foreach ( $value as $meta ) { + $coupon->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + break; + case 'description' : + $coupon->set_description( wp_filter_post_kses( $value ) ); + break; + default : + if ( is_callable( array( $coupon, "set_{$key}" ) ) ) { + $coupon->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filter the query_vars used in `get_items` for the constructed query. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for insertion. + * + * @param WC_Coupon $coupon The coupon object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $coupon, $request ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-orders-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-orders-controller.php new file mode 100644 index 0000000..8384684 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-orders-controller.php @@ -0,0 +1,306 @@ + '_customer_user', + 'value' => $request['customer'], + 'type' => 'NUMERIC', + ); + } + + // Search by product. + if ( ! empty( $request['product'] ) ) { + $order_ids = $wpdb->get_col( $wpdb->prepare( " + SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items + WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) + AND order_item_type = 'line_item' + ", $request['product'] ) ); + + // Force WP_Query return empty if don't found any order. + $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); + + $args['post__in'] = $order_ids; + } + + // Search. + if ( ! empty( $args['s'] ) ) { + $order_ids = wc_order_search( $args['s'] ); + + if ( ! empty( $order_ids ) ) { + unset( $args['s'] ); + $args['post__in'] = array_merge( $order_ids, array( 0 ) ); + } + } + + return $args; + } + + /** + * Prepare a single order output for response. + * + * @deprecated 3.0 + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $data + */ + public function prepare_item_for_response( $post, $request ) { + $this->request = $request; + $this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] ); + $statuses = wc_get_order_statuses(); + $order = wc_get_order( $post ); + $data = array_merge( array( 'id' => $order->get_id() ), $order->get_data() ); + $format_decimal = array( 'discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax' ); + $format_date = array( 'date_created', 'date_modified', 'date_completed', 'date_paid' ); + $format_line_items = array( 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $data[ $key ] = wc_format_decimal( $data[ $key ], $this->request['dp'] ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $data[ $key ] = $data[ $key ] ? wc_rest_prepare_date_response( get_gmt_from_date( date( 'Y-m-d H:i:s', $data[ $key ] ) ) ) : false; + } + + // Format the order status. + $data['status'] = 'wc-' === substr( $data['status'], 0, 3 ) ? substr( $data['status'], 3 ) : $data['status']; + + // Format line items. + foreach ( $format_line_items as $key ) { + $data[ $key ] = array_values( array_map( array( $this, 'get_order_item_data' ), $data[ $key ] ) ); + } + + // Refunds. + $data['refunds'] = array(); + foreach ( $order->get_refunds() as $refund ) { + $data['refunds'][] = array( + 'id' => $refund->get_id(), + 'refund' => $refund->get_reason() ? $refund->get_reason() : '', + 'total' => '-' . wc_format_decimal( $refund->get_amount(), $this->request['dp'] ), + ); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $order, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Prepare a single order for create. + * + * @deprecated 3.0 + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|WC_Order $data Object. + */ + protected function prepare_item_for_database( $request ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $order = new WC_Order( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Handle all writable props + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'billing' : + case 'shipping' : + $this->update_address( $order, $value, $key ); + break; + case 'line_items' : + case 'shipping_lines' : + case 'fee_lines' : + case 'coupon_lines' : + if ( is_array( $value ) ) { + foreach ( $value as $item ) { + if ( is_array( $item ) ) { + if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) { + $order->remove_item( $item['id'] ); + } else { + $this->set_item( $order, $key, $item ); + } + } + } + } + break; + case 'meta_data' : + if ( is_array( $value ) ) { + foreach ( $value as $meta ) { + $order->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' ); + } + } + break; + default : + if ( is_callable( array( $order, "set_{$key}" ) ) ) { + $order->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filter the data for the insert. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WC_Order $order The Order object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $order, $request ); + } + + /** + * Create base WC Order object. + * + * @deprecated 3.0.0 + * + * @param array $data + * @return WC_Order + */ + protected function create_base_order( $data ) { + return wc_create_order( $data ); + } + + /** + * Create order. + * + * @deprecated 3.0.0 + * + * @param WP_REST_Request $request Full details about the request. + * @return int|WP_Error + */ + protected function create_order( $request ) { + try { + // Make sure customer exists. + if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + // Make sure customer is part of blog. + if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network',__( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 ); + } + + $order = $this->prepare_item_for_database( $request ); + $order->set_created_via( 'rest-api' ); + $order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) ); + $order->calculate_totals(); + $order->save(); + + // Handle set paid. + if ( true === $request['set_paid'] ) { + $order->payment_complete( $request['transaction_id'] ); + } + + return $order->get_id(); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Update order. + * + * @deprecated 3.0.0 + * + * @param WP_REST_Request $request Full details about the request. + * @return int|WP_Error + */ + protected function update_order( $request ) { + try { + $order = $this->prepare_item_for_database( $request ); + $order->save(); + + // Handle set paid. + if ( $order->needs_payment() && true === $request['set_paid'] ) { + $order->payment_complete( $request['transaction_id'] ); + } + + // If items have changed, recalculate order totals. + if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { + $order->calculate_totals(); + } + + return $order->get_id(); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-products-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-products-controller.php new file mode 100644 index 0000000..9096cbd --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/class-wc-rest-legacy-products-controller.php @@ -0,0 +1,804 @@ + 'category', + 'product_tag' => 'tag', + 'product_shipping_class' => 'shipping_class', + ); + + // Set tax_query for each passed arg. + foreach ( $taxonomies as $taxonomy => $key ) { + if ( ! empty( $request[ $key ] ) ) { + $tax_query[] = array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'terms' => $request[ $key ], + ); + } + } + + // Filter product type by slug. + if ( ! empty( $request['type'] ) ) { + $tax_query[] = array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $request['type'], + ); + } + + // Filter by attribute and term. + if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) { + if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) { + $tax_query[] = array( + 'taxonomy' => $request['attribute'], + 'field' => 'term_id', + 'terms' => $request['attribute_term'], + ); + } + } + + if ( ! empty( $tax_query ) ) { + $args['tax_query'] = $tax_query; + } + + // Filter featured. + if ( is_bool( $request['featured'] ) ) { + $args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'name', + 'terms' => 'featured', + 'operator' => true === $request['featured'] ? 'IN' : 'NOT IN', + ); + } + + // Filter by sku. + if ( ! empty( $request['sku'] ) ) { + $skus = explode( ',', $request['sku'] ); + // Include the current string as a SKU too. + if ( 1 < count( $skus ) ) { + $skus[] = $request['sku']; + } + + $args['meta_query'] = $this->add_meta_query( $args, array( + 'key' => '_sku', + 'value' => $skus, + 'compare' => 'IN', + ) ); + } + + // Filter by tax class. + if ( ! empty( $request['tax_class'] ) ) { + $args['meta_query'] = $this->add_meta_query( $args, array( + 'key' => '_tax_class', + 'value' => 'standard' !== $request['tax_class'] ? $request['tax_class'] : '', + ) ); + } + + // Price filter. + if ( ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) ) { + $args['meta_query'] = $this->add_meta_query( $args, wc_get_min_max_price_meta_query( $request ) ); + } + + // Filter product in stock or out of stock. + if ( is_bool( $request['in_stock'] ) ) { + $args['meta_query'] = $this->add_meta_query( $args, array( + 'key' => '_stock_status', + 'value' => true === $request['in_stock'] ? 'instock' : 'outofstock', + ) ); + } + + // Filter by on sale products. + if ( is_bool( $request['on_sale'] ) ) { + $on_sale_key = $request['on_sale'] ? 'post__in' : 'post__not_in'; + $args[ $on_sale_key ] += wc_get_product_ids_on_sale(); + } + + // Force the post_type argument, since it's not a user input variable. + if ( ! empty( $request['sku'] ) ) { + $args['post_type'] = array( 'product', 'product_variation' ); + } else { + $args['post_type'] = $this->post_type; + } + + return $args; + } + + /** + * Prepare a single product output for response. + * + * @deprecated 3.0.0 + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_item_for_response( $post, $request ) { + $product = wc_get_product( $post ); + $data = $this->get_product_data( $product ); + + // Add variations to variable products. + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + $data['variations'] = $product->get_children(); + } + + // Add grouped products data. + if ( $product->is_type( 'grouped' ) && $product->has_child() ) { + $data['grouped_products'] = $product->get_children(); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $product, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Get product menu order. + * + * @deprecated 3.0.0 + * @param WC_Product $product Product instance. + * @return int + */ + protected function get_product_menu_order( $product ) { + return $product->get_menu_order(); + } + + /** + * Save product meta. + * + * @deprecated 3.0.0 + * @param WC_Product $product + * @param WP_REST_Request $request + * @return bool + * @throws WC_REST_Exception + */ + protected function save_product_meta( $product, $request ) { + $product = $this->set_product_meta( $product, $request ); + $product->save(); + + return true; + } + + /** + * Set product meta. + * + * @deprecated 3.0.0 + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return WC_Product + */ + protected function set_product_meta( $product, $request ) { + // Virtual. + if ( isset( $request['virtual'] ) ) { + $product->set_virtual( $request['virtual'] ); + } + + // Tax status. + if ( isset( $request['tax_status'] ) ) { + $product->set_tax_status( $request['tax_status'] ); + } + + // Tax Class. + if ( isset( $request['tax_class'] ) ) { + $product->set_tax_class( $request['tax_class'] ); + } + + // Catalog Visibility. + if ( isset( $request['catalog_visibility'] ) ) { + $product->set_catalog_visibility( $request['catalog_visibility'] ); + } + + // Purchase Note. + if ( isset( $request['purchase_note'] ) ) { + $product->set_purchase_note( wc_clean( $request['purchase_note'] ) ); + } + + // Featured Product. + if ( isset( $request['featured'] ) ) { + $product->set_featured( $request['featured'] ); + } + + // Shipping data. + $product = $this->save_product_shipping_data( $product, $request ); + + // SKU. + if ( isset( $request['sku'] ) ) { + $product->set_sku( wc_clean( $request['sku'] ) ); + } + + // Attributes. + if ( isset( $request['attributes'] ) ) { + $attributes = array(); + + foreach ( $request['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = wc_clean( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( $attribute_id ) { + + if ( isset( $attribute['options'] ) ) { + $options = $attribute['options']; + + if ( ! is_array( $attribute['options'] ) ) { + // Text based attributes - Posted values are term names. + $options = explode( WC_DELIMITER, $options ); + } + + $values = array_map( 'wc_sanitize_term_text_based', $options ); + $values = array_filter( $values, 'strlen' ); + } else { + $values = array(); + } + + if ( ! empty( $values ) ) { + // Add attribute to array, but don't set values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['options'] ) ) { + // Custom attribute - Add attribute to array and set the values. + if ( is_array( $attribute['options'] ) ) { + $values = $attribute['options']; + } else { + $values = explode( WC_DELIMITER, $attribute['options'] ); + } + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } + $product->set_attributes( $attributes ); + } + + // Sales and prices. + if ( in_array( $product->get_type(), array( 'variable', 'grouped' ), true ) ) { + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + $product->set_date_on_sale_to( '' ); + $product->set_date_on_sale_from( '' ); + $product->set_price( '' ); + } else { + // Regular Price. + if ( isset( $request['regular_price'] ) ) { + $product->set_regular_price( $request['regular_price'] ); + } + + // Sale Price. + if ( isset( $request['sale_price'] ) ) { + $product->set_sale_price( $request['sale_price'] ); + } + + if ( isset( $request['date_on_sale_from'] ) ) { + $product->set_date_on_sale_from( $request['date_on_sale_from'] ); + } + + if ( isset( $request['date_on_sale_to'] ) ) { + $product->set_date_on_sale_to( $request['date_on_sale_to'] ); + } + } + + // Product parent ID for groups. + if ( isset( $request['parent_id'] ) ) { + $product->set_parent_id( $request['parent_id'] ); + } + + // Sold individually. + if ( isset( $request['sold_individually'] ) ) { + $product->set_sold_individually( $request['sold_individually'] ); + } + + // Stock status. + if ( isset( $request['in_stock'] ) ) { + $stock_status = true === $request['in_stock'] ? 'instock' : 'outofstock'; + } else { + $stock_status = $product->get_stock_status(); + } + + // Stock data. + if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) { + // Manage stock. + if ( isset( $request['manage_stock'] ) ) { + $product->set_manage_stock( $request['manage_stock'] ); + } + + // Backorders. + if ( isset( $request['backorders'] ) ) { + $product->set_backorders( $request['backorders'] ); + } + + if ( $product->is_type( 'grouped' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } elseif ( $product->is_type( 'external' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( 'instock' ); + } elseif ( $product->get_manage_stock() ) { + // Stock status is always determined by children so sync later. + if ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Stock quantity. + if ( isset( $request['stock_quantity'] ) ) { + $product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) ); + } elseif ( isset( $request['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $product->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); + $product->set_stock_quantity( wc_stock_amount( $stock_quantity ) ); + } + } else { + // Don't manage stock. + $product->set_manage_stock( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } + } elseif ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Upsells. + if ( isset( $request['upsell_ids'] ) ) { + $upsells = array(); + $ids = $request['upsell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $upsells[] = $id; + } + } + } + + $product->set_upsell_ids( $upsells ); + } + + // Cross sells. + if ( isset( $request['cross_sell_ids'] ) ) { + $crosssells = array(); + $ids = $request['cross_sell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $crosssells[] = $id; + } + } + } + + $product->set_cross_sell_ids( $crosssells ); + } + + // Product categories. + if ( isset( $request['categories'] ) && is_array( $request['categories'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['categories'] ); + } + + // Product tags. + if ( isset( $request['tags'] ) && is_array( $request['tags'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['tags'], 'tag' ); + } + + // Downloadable. + if ( isset( $request['downloadable'] ) ) { + $product->set_downloadable( $request['downloadable'] ); + } + + // Downloadable options. + if ( $product->get_downloadable() ) { + + // Downloadable files. + if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) { + $product = $this->save_downloadable_files( $product, $request['downloads'] ); + } + + // Download limit. + if ( isset( $request['download_limit'] ) ) { + $product->set_download_limit( $request['download_limit'] ); + } + + // Download expiry. + if ( isset( $request['download_expiry'] ) ) { + $product->set_download_expiry( $request['download_expiry'] ); + } + } + + // Product url and button text for external products. + if ( $product->is_type( 'external' ) ) { + if ( isset( $request['external_url'] ) ) { + $product->set_product_url( $request['external_url'] ); + } + + if ( isset( $request['button_text'] ) ) { + $product->set_button_text( $request['button_text'] ); + } + } + + // Save default attributes for variable products. + if ( $product->is_type( 'variable' ) ) { + $product = $this->save_default_attributes( $product, $request ); + } + + return $product; + } + + /** + * Save variations. + * + * @deprecated 3.0.0 + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return bool + */ + protected function save_variations_data( $product, $request ) { + foreach ( $request['variations'] as $menu_order => $data ) { + $variation = new WC_Product_Variation( isset( $data['id'] ) ? absint( $data['id'] ) : 0 ); + + // Create initial name and status. + if ( ! $variation->get_slug() ) { + /* translators: 1: variation id 2: product name */ + $variation->set_name( sprintf( __( 'Variation #%1$s of %2$s', 'woocommerce' ), $variation->get_id(), $product->get_name() ) ); + $variation->set_status( isset( $data['visible'] ) && false === $data['visible'] ? 'private' : 'publish' ); + } + + // Parent ID. + $variation->set_parent_id( $product->get_id() ); + + // Menu order. + $variation->set_menu_order( $menu_order ); + + // Status. + if ( isset( $data['visible'] ) ) { + $variation->set_status( false === $data['visible'] ? 'private' : 'publish' ); + } + + // SKU. + if ( isset( $data['sku'] ) ) { + $variation->set_sku( wc_clean( $data['sku'] ) ); + } + + // Thumbnail. + if ( isset( $data['image'] ) && is_array( $data['image'] ) ) { + $image = $data['image']; + $image = current( $image ); + if ( is_array( $image ) ) { + $image['position'] = 0; + } + + $variation = $this->set_product_images( $variation, array( $image ) ); + } + + // Virtual variation. + if ( isset( $data['virtual'] ) ) { + $variation->set_virtual( $data['virtual'] ); + } + + // Downloadable variation. + if ( isset( $data['downloadable'] ) ) { + $variation->set_downloadable( $data['downloadable'] ); + } + + // Downloads. + if ( $variation->get_downloadable() ) { + // Downloadable files. + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $variation = $this->save_downloadable_files( $variation, $data['downloads'] ); + } + + // Download limit. + if ( isset( $data['download_limit'] ) ) { + $variation->set_download_limit( $data['download_limit'] ); + } + + // Download expiry. + if ( isset( $data['download_expiry'] ) ) { + $variation->set_download_expiry( $data['download_expiry'] ); + } + } + + // Shipping data. + $variation = $this->save_product_shipping_data( $variation, $data ); + + // Stock handling. + if ( isset( $data['manage_stock'] ) ) { + $variation->set_manage_stock( $data['manage_stock'] ); + } + + if ( isset( $data['in_stock'] ) ) { + $variation->set_stock_status( true === $data['in_stock'] ? 'instock' : 'outofstock' ); + } + + if ( isset( $data['backorders'] ) ) { + $variation->set_backorders( $data['backorders'] ); + } + + if ( $variation->get_manage_stock() ) { + if ( isset( $data['stock_quantity'] ) ) { + $variation->set_stock_quantity( $data['stock_quantity'] ); + } elseif ( isset( $data['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $variation->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $data['inventory_delta'] ); + $variation->set_stock_quantity( $stock_quantity ); + } + } else { + $variation->set_backorders( 'no' ); + $variation->set_stock_quantity( '' ); + } + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $variation->set_regular_price( $data['regular_price'] ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $variation->set_sale_price( $data['sale_price'] ); + } + + if ( isset( $data['date_on_sale_from'] ) ) { + $variation->set_date_on_sale_from( $data['date_on_sale_from'] ); + } + + if ( isset( $data['date_on_sale_to'] ) ) { + $variation->set_date_on_sale_to( $data['date_on_sale_to'] ); + } + + // Tax class. + if ( isset( $data['tax_class'] ) ) { + $variation->set_tax_class( $data['tax_class'] ); + } + + // Description. + if ( isset( $data['description'] ) ) { + $variation->set_description( wp_kses_post( $data['description'] ) ); + } + + // Update taxonomies. + if ( isset( $data['attributes'] ) ) { + $attributes = array(); + $parent_attributes = $product->get_attributes(); + + foreach ( $data['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { + continue; + } + + $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); + $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + + if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $attribute_value, $attribute_name ); + + if ( $term && ! is_wp_error( $term ) ) { + $attribute_value = $term->slug; + } else { + $attribute_value = sanitize_title( $attribute_value ); + } + } + + $attributes[ $attribute_key ] = $attribute_value; + } + + $variation->set_attributes( $attributes ); + } + + $variation->save(); + + do_action( 'woocommerce_rest_save_product_variation', $variation->get_id(), $menu_order, $data ); + } + + return true; + } + + /** + * Add post meta fields. + * + * @deprecated 3.0.0 + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request data. + * @return bool|WP_Error + */ + protected function add_post_meta_fields( $post, $request ) { + return $this->update_post_meta_fields( $post, $request ); + } + + /** + * Update post meta fields. + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request data. + * @return bool|WP_Error + */ + protected function update_post_meta_fields( $post, $request ) { + $product = wc_get_product( $post ); + + // Check for featured/gallery images, upload it and set it. + if ( isset( $request['images'] ) ) { + $product = $this->set_product_images( $product, $request['images'] ); + } + + // Save product meta fields. + $product = $this->set_product_meta( $product, $request ); + + // Save the product data. + $product->save(); + + // Save variations. + if ( $product->is_type( 'variable' ) ) { + if ( isset( $request['variations'] ) && is_array( $request['variations'] ) ) { + $this->save_variations_data( $product, $request ); + } + } + + // Clear caches here so in sync with any new variations/children. + wc_delete_product_transients( $product->get_id() ); + wp_cache_delete( 'product-' . $product->get_id(), 'products' ); + + return true; + } + + /** + * Delete post. + * + * @deprecated 3.0.0 + * + * @param int|WP_Post $id Post ID or WP_Post instance. + */ + protected function delete_post( $id ) { + if ( ! empty( $id->ID ) ) { + $id = $id->ID; + } elseif ( ! is_numeric( $id ) || 0 >= $id ) { + return; + } + + // Delete product attachments. + $attachments = get_posts( array( + 'post_parent' => $id, + 'post_status' => 'any', + 'post_type' => 'attachment', + ) ); + + foreach ( (array) $attachments as $attachment ) { + wp_delete_attachment( $attachment->ID, true ); + } + + // Delete product. + $product = wc_get_product( $id ); + $product->delete( true ); + } + + /** + * Get post types. + * + * @deprecated 3.0.0 + * + * @return array + */ + protected function get_post_types() { + return array( 'product', 'product_variation' ); + } + + /** + * Save product images. + * + * @deprecated 3.0.0 + * + * @param int $product_id + * @param array $images + * @throws WC_REST_Exception + */ + protected function save_product_images( $product_id, $images ) { + $product = wc_get_product( $product_id ); + + return set_product_images( $product, $images ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-authentication.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-authentication.php new file mode 100644 index 0000000..1d26ae8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-authentication.php @@ -0,0 +1,410 @@ +api->server->path ) { + return new WP_User( 0 ); + } + + try { + + if ( is_ssl() ) { + $keys = $this->perform_ssl_authentication(); + } else { + $keys = $this->perform_oauth_authentication(); + } + + // Check API key-specific permission + $this->check_api_key_permissions( $keys['permissions'] ); + + $user = $this->get_user_by_id( $keys['user_id'] ); + + $this->update_api_key_last_access( $keys['key_id'] ); + + } catch ( Exception $e ) { + $user = new WP_Error( 'woocommerce_api_authentication_error', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + + return $user; + } + + /** + * SSL-encrypted requests are not subject to sniffing or man-in-the-middle + * attacks, so the request can be authenticated by simply looking up the user + * associated with the given consumer key and confirming the consumer secret + * provided is valid + * + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_ssl_authentication() { + + $params = WC()->api->server->params['GET']; + + // Get consumer key + if ( ! empty( $_SERVER['PHP_AUTH_USER'] ) ) { + + // Should be in HTTP Auth header by default + $consumer_key = $_SERVER['PHP_AUTH_USER']; + + } elseif ( ! empty( $params['consumer_key'] ) ) { + + // Allow a query string parameter as a fallback + $consumer_key = $params['consumer_key']; + + } else { + + throw new Exception( __( 'Consumer key is missing.', 'woocommerce' ), 404 ); + } + + // Get consumer secret + if ( ! empty( $_SERVER['PHP_AUTH_PW'] ) ) { + + // Should be in HTTP Auth header by default + $consumer_secret = $_SERVER['PHP_AUTH_PW']; + + } elseif ( ! empty( $params['consumer_secret'] ) ) { + + // Allow a query string parameter as a fallback + $consumer_secret = $params['consumer_secret']; + + } else { + + throw new Exception( __( 'Consumer secret is missing.', 'woocommerce' ), 404 ); + } + + $keys = $this->get_keys_by_consumer_key( $consumer_key ); + + if ( ! $this->is_consumer_secret_valid( $keys['consumer_secret'], $consumer_secret ) ) { + throw new Exception( __( 'Consumer secret is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + /** + * Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests + * + * This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP + * + * This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions: + * + * 1) There is no token associated with request/responses, only consumer keys/secrets are used + * + * 2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header, + * This is because there is no cross-OS function within PHP to get the raw Authorization header + * + * @link http://tools.ietf.org/html/rfc5849 for the full spec + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_oauth_authentication() { + + $params = WC()->api->server->params['GET']; + + $param_names = array( 'oauth_consumer_key', 'oauth_timestamp', 'oauth_nonce', 'oauth_signature', 'oauth_signature_method' ); + + // Check for required OAuth parameters + foreach ( $param_names as $param_name ) { + + if ( empty( $params[ $param_name ] ) ) { + /* translators: %s: parameter name */ + throw new Exception( sprintf( __( '%s parameter is missing', 'woocommerce' ), $param_name ), 404 ); + } + } + + // Fetch WP user by consumer key + $keys = $this->get_keys_by_consumer_key( $params['oauth_consumer_key'] ); + + // Perform OAuth validation + $this->check_oauth_signature( $keys, $params ); + $this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] ); + + // Authentication successful, return user + return $keys; + } + + /** + * Return the keys for the given consumer key + * + * @since 2.4.0 + * @param string $consumer_key + * @return array + * @throws Exception + */ + private function get_keys_by_consumer_key( $consumer_key ) { + global $wpdb; + + $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) ); + + $keys = $wpdb->get_row( $wpdb->prepare( " + SELECT key_id, user_id, permissions, consumer_key, consumer_secret, nonces + FROM {$wpdb->prefix}woocommerce_api_keys + WHERE consumer_key = '%s' + ", $consumer_key ), ARRAY_A ); + + if ( empty( $keys ) ) { + throw new Exception( __( 'Consumer key is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + /** + * Get user by ID + * + * @since 2.4.0 + * @param int $user_id + * @return WP_User + * + * @throws Exception + */ + private function get_user_by_id( $user_id ) { + $user = get_user_by( 'id', $user_id ); + + if ( ! $user ) { + throw new Exception( __( 'API user is invalid', 'woocommerce' ), 401 ); + } + + return $user; + } + + /** + * Check if the consumer secret provided for the given user is valid + * + * @since 2.1 + * @param string $keys_consumer_secret + * @param string $consumer_secret + * @return bool + */ + private function is_consumer_secret_valid( $keys_consumer_secret, $consumer_secret ) { + return hash_equals( $keys_consumer_secret, $consumer_secret ); + } + + /** + * Verify that the consumer-provided request signature matches our generated signature, this ensures the consumer + * has a valid key/secret + * + * @param array $keys + * @param array $params the request parameters + * @throws Exception + */ + private function check_oauth_signature( $keys, $params ) { + + $http_method = strtoupper( WC()->api->server->method ); + + $base_request_uri = rawurlencode( untrailingslashit( get_woocommerce_api_url( '' ) ) . WC()->api->server->path ); + + // Get the signature provided by the consumer and remove it from the parameters prior to checking the signature + $consumer_signature = rawurldecode( str_replace( ' ', '+', $params['oauth_signature'] ) ); + unset( $params['oauth_signature'] ); + + // Remove filters and convert them from array to strings to void normalize issues + if ( isset( $params['filter'] ) ) { + $filters = $params['filter']; + unset( $params['filter'] ); + foreach ( $filters as $filter => $filter_value ) { + $params[ 'filter[' . $filter . ']' ] = $filter_value; + } + } + + // Normalize parameter key/values + $params = $this->normalize_parameters( $params ); + + // Sort parameters + if ( ! uksort( $params, 'strcmp' ) ) { + throw new Exception( __( 'Invalid signature - failed to sort parameters.', 'woocommerce' ), 401 ); + } + + // Form query string + $query_params = array(); + foreach ( $params as $param_key => $param_value ) { + + $query_params[] = $param_key . '%3D' . $param_value; // join with equals sign + } + $query_string = implode( '%26', $query_params ); // join with ampersand + + $string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string; + + if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) { + throw new Exception( __( 'Invalid signature - signature method is invalid.', 'woocommerce' ), 401 ); + } + + $hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) ); + + $signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $keys['consumer_secret'], true ) ); + + if ( ! hash_equals( $signature, $consumer_signature ) ) { + throw new Exception( __( 'Invalid signature - provided signature does not match.', 'woocommerce' ), 401 ); + } + } + + /** + * Normalize each parameter by assuming each parameter may have already been + * encoded, so attempt to decode, and then re-encode according to RFC 3986 + * + * Note both the key and value is normalized so a filter param like: + * + * 'filter[period]' => 'week' + * + * is encoded to: + * + * 'filter%5Bperiod%5D' => 'week' + * + * This conforms to the OAuth 1.0a spec which indicates the entire query string + * should be URL encoded + * + * @since 2.1 + * @see rawurlencode() + * @param array $parameters un-normalized parameters + * @return array normalized parameters + */ + private function normalize_parameters( $parameters ) { + + $normalized_parameters = array(); + + foreach ( $parameters as $key => $value ) { + + // Percent symbols (%) must be double-encoded + $key = str_replace( '%', '%25', rawurlencode( rawurldecode( $key ) ) ); + $value = str_replace( '%', '%25', rawurlencode( rawurldecode( $value ) ) ); + + $normalized_parameters[ $key ] = $value; + } + + return $normalized_parameters; + } + + /** + * Verify that the timestamp and nonce provided with the request are valid. This prevents replay attacks where + * an attacker could attempt to re-send an intercepted request at a later time. + * + * - A timestamp is valid if it is within 15 minutes of now + * - A nonce is valid if it has not been used within the last 15 minutes + * + * @param array $keys + * @param int $timestamp the unix timestamp for when the request was made + * @param string $nonce a unique (for the given user) 32 alphanumeric string, consumer-generated + * @throws Exception + */ + private function check_oauth_timestamp_and_nonce( $keys, $timestamp, $nonce ) { + global $wpdb; + + $valid_window = 15 * 60; // 15 minute window + + if ( ( $timestamp < time() - $valid_window ) || ( $timestamp > time() + $valid_window ) ) { + throw new Exception( __( 'Invalid timestamp.', 'woocommerce' ) ); + } + + $used_nonces = maybe_unserialize( $keys['nonces'] ); + + if ( empty( $used_nonces ) ) { + $used_nonces = array(); + } + + if ( in_array( $nonce, $used_nonces ) ) { + throw new Exception( __( 'Invalid nonce - nonce has already been used.', 'woocommerce' ), 401 ); + } + + $used_nonces[ $timestamp ] = $nonce; + + // Remove expired nonces + foreach ( $used_nonces as $nonce_timestamp => $nonce ) { + if ( $nonce_timestamp < ( time() - $valid_window ) ) { + unset( $used_nonces[ $nonce_timestamp ] ); + } + } + + $used_nonces = maybe_serialize( $used_nonces ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'nonces' => $used_nonces ), + array( 'key_id' => $keys['key_id'] ), + array( '%s' ), + array( '%d' ) + ); + } + + /** + * Check that the API keys provided have the proper key-specific permissions to either read or write API resources + * + * @param string $key_permissions + * @throws Exception if the permission check fails + */ + public function check_api_key_permissions( $key_permissions ) { + switch ( WC()->api->server->method ) { + + case 'HEAD': + case 'GET': + if ( 'read' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have read permissions.', 'woocommerce' ), 401 ); + } + break; + + case 'POST': + case 'PUT': + case 'PATCH': + case 'DELETE': + if ( 'write' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have write permissions.', 'woocommerce' ), 401 ); + } + break; + } + } + + /** + * Updated API Key last access datetime + * + * @since 2.4.0 + * + * @param int $key_id + */ + private function update_api_key_last_access( $key_id ) { + global $wpdb; + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'last_access' => current_time( 'mysql' ) ), + array( 'key_id' => $key_id ), + array( '%s' ), + array( '%d' ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-coupons.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-coupons.php new file mode 100644 index 0000000..244b5ef --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-coupons.php @@ -0,0 +1,247 @@ + + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET /coupons + $routes[ $this->base ] = array( + array( array( $this, 'get_coupons' ), WC_API_Server::READABLE ), + ); + + # GET /coupons/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_coupons_count' ), WC_API_Server::READABLE ), + ); + + # GET /coupons/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_coupon' ), WC_API_Server::READABLE ), + ); + + # GET /coupons/code/, note that coupon codes can contain spaces, dashes and underscores + $routes[ $this->base . '/code/(?P\w[\w\s\-]*)' ] = array( + array( array( $this, 'get_coupon_by_code' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get all coupons + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_coupons( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_coupons( $filter ); + + $coupons = array(); + + foreach ( $query->posts as $coupon_id ) { + + if ( ! $this->is_readable( $coupon_id ) ) { + continue; + } + + $coupons[] = current( $this->get_coupon( $coupon_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'coupons' => $coupons ); + } + + /** + * Get the coupon for the given ID + * + * @since 2.1 + * + * @param int $id the coupon ID + * @param string $fields fields to include in response + * + * @return array|WP_Error + * @throws WC_API_Exception + */ + public function get_coupon( $id, $fields = null ) { + $id = $this->validate_request( $id, 'shop_coupon', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $coupon = new WC_Coupon( $id ); + + if ( 0 === $coupon->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_id', __( 'Invalid coupon ID', 'woocommerce' ), 404 ); + } + + $coupon_data = array( + 'id' => $coupon->get_id(), + 'code' => $coupon->get_code(), + 'type' => $coupon->get_discount_type(), + 'created_at' => $this->server->format_datetime( $coupon->get_date_created() ? $coupon->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $coupon->get_date_modified() ? $coupon->get_date_modified()->getTimestamp() : 0 ), // API gives UTC times. + 'amount' => wc_format_decimal( $coupon->get_amount(), 2 ), + 'individual_use' => $coupon->get_individual_use(), + 'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ), + 'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ), + 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, + 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, + 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), + 'usage_count' => (int) $coupon->get_usage_count(), + 'expiry_date' => $this->server->format_datetime( $coupon->get_date_expires() ? $coupon->get_date_expires()->getTimestamp() : 0 ), // API gives UTC times. + 'enable_free_shipping' => $coupon->get_free_shipping(), + 'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ), + 'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ), + 'exclude_sale_items' => $coupon->get_exclude_sale_items(), + 'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ), + 'customer_emails' => $coupon->get_email_restrictions(), + ); + + return array( 'coupon' => apply_filters( 'woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server ) ); + } + + /** + * Get the total number of coupons + * + * @since 2.1 + * + * @param array $filter + * + * @return array|WP_Error + */ + public function get_coupons_count( $filter = array() ) { + + $query = $this->query_coupons( $filter ); + + if ( ! current_user_can( 'read_private_shop_coupons' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return array( 'count' => (int) $query->found_posts ); + } + + /** + * Get the coupon for the given code + * + * @since 2.1 + * @param string $code the coupon code + * @param string $fields fields to include in response + * @return int|WP_Error + */ + public function get_coupon_by_code( $code, $fields = null ) { + global $wpdb; + + $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1;", $code ) ); + + if ( is_null( $id ) ) { + return new WP_Error( 'woocommerce_api_invalid_coupon_code', __( 'Invalid coupon code', 'woocommerce' ), array( 'status' => 404 ) ); + } + + return $this->get_coupon( $id, $fields ); + } + + /** + * Create a coupon + * + * @param array $data + * @return array + */ + public function create_coupon( $data ) { + + return array(); + } + + /** + * Edit a coupon + * + * @param int $id the coupon ID + * @param array $data + * @return array|WP_Error + */ + public function edit_coupon( $id, $data ) { + + $id = $this->validate_request( $id, 'shop_coupon', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + return $this->get_coupon( $id ); + } + + /** + * Delete a coupon + * + * @param int $id the coupon ID + * @param bool $force true to permanently delete coupon, false to move to trash + * @return array|WP_Error + */ + public function delete_coupon( $id, $force = false ) { + + $id = $this->validate_request( $id, 'shop_coupon', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + return $this->delete( $id, 'shop_coupon', ( 'true' === $force ) ); + } + + /** + * Helper method to get coupon post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_coupons( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'shop_coupon', + 'post_status' => 'publish', + ); + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-customers.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-customers.php new file mode 100644 index 0000000..d5edb15 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-customers.php @@ -0,0 +1,481 @@ + + * GET /customers//orders + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET /customers + $routes[ $this->base ] = array( + array( array( $this, 'get_customers' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_customers_count' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_customer' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers//orders + $routes[ $this->base . '/(?P\d+)/orders' ] = array( + array( array( $this, 'get_customer_orders' ), WC_API_SERVER::READABLE ), + ); + + return $routes; + } + + /** + * Get all customers + * + * @since 2.1 + * @param array $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_customers( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_customers( $filter ); + + $customers = array(); + + foreach ( $query->get_results() as $user_id ) { + + if ( ! $this->is_readable( $user_id ) ) { + continue; + } + + $customers[] = current( $this->get_customer( $user_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'customers' => $customers ); + } + + /** + * Get the customer for the given ID + * + * @since 2.1 + * @param int $id the customer ID + * @param string $fields + * @return array|WP_Error + */ + public function get_customer( $id, $fields = null ) { + global $wpdb; + + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $customer = new WC_Customer( $id ); + $last_order = $customer->get_last_order(); + $customer_data = array( + 'id' => $customer->get_id(), + 'created_at' => $this->server->format_datetime( $customer->get_date_created() ? $customer->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'email' => $customer->get_email(), + 'first_name' => $customer->get_first_name(), + 'last_name' => $customer->get_last_name(), + 'username' => $customer->get_username(), + 'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null, + 'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->get_date_created() ? $last_order->get_date_created()->getTimestamp() : 0 ) : null, // API gives UTC times. + 'orders_count' => $customer->get_order_count(), + 'total_spent' => wc_format_decimal( $customer->get_total_spent(), 2 ), + 'avatar_url' => $customer->get_avatar_url(), + 'billing_address' => array( + 'first_name' => $customer->get_billing_first_name(), + 'last_name' => $customer->get_billing_last_name(), + 'company' => $customer->get_billing_company(), + 'address_1' => $customer->get_billing_address_1(), + 'address_2' => $customer->get_billing_address_2(), + 'city' => $customer->get_billing_city(), + 'state' => $customer->get_billing_state(), + 'postcode' => $customer->get_billing_postcode(), + 'country' => $customer->get_billing_country(), + 'email' => $customer->get_billing_email(), + 'phone' => $customer->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $customer->get_shipping_first_name(), + 'last_name' => $customer->get_shipping_last_name(), + 'company' => $customer->get_shipping_company(), + 'address_1' => $customer->get_shipping_address_1(), + 'address_2' => $customer->get_shipping_address_2(), + 'city' => $customer->get_shipping_city(), + 'state' => $customer->get_shipping_state(), + 'postcode' => $customer->get_shipping_postcode(), + 'country' => $customer->get_shipping_country(), + ), + ); + + return array( 'customer' => apply_filters( 'woocommerce_api_customer_response', $customer_data, $customer, $fields, $this->server ) ); + } + + /** + * Get the total number of customers + * + * @since 2.1 + * @param array $filter + * @return array|WP_Error + */ + public function get_customers_count( $filter = array() ) { + + $query = $this->query_customers( $filter ); + + if ( ! current_user_can( 'list_users' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return array( 'count' => count( $query->get_results() ) ); + } + + + /** + * Create a customer + * + * @param array $data + * @return array|WP_Error + */ + public function create_customer( $data ) { + + if ( ! current_user_can( 'create_users' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_create_customer', __( 'You do not have permission to create this customer', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return array(); + } + + /** + * Edit a customer + * + * @param int $id the customer ID + * @param array $data + * @return array|WP_Error + */ + public function edit_customer( $id, $data ) { + + $id = $this->validate_request( $id, 'customer', 'edit' ); + + if ( ! is_wp_error( $id ) ) { + return $id; + } + + return $this->get_customer( $id ); + } + + /** + * Delete a customer + * + * @param int $id the customer ID + * @return array|WP_Error + */ + public function delete_customer( $id ) { + + $id = $this->validate_request( $id, 'customer', 'delete' ); + + if ( ! is_wp_error( $id ) ) { + return $id; + } + + return $this->delete( $id, 'customer' ); + } + + /** + * Get the orders for a customer + * + * @since 2.1 + * @param int $id the customer ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_customer_orders( $id, $fields = null ) { + global $wpdb; + + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order_ids = wc_get_orders( array( + 'customer' => $id, + 'limit' => -1, + 'orderby' => 'date', + 'order' => 'ASC', + 'return' => 'ids', + ) ); + + if ( empty( $order_ids ) ) { + return array( 'orders' => array() ); + } + + $orders = array(); + + foreach ( $order_ids as $order_id ) { + $orders[] = current( WC()->api->WC_API_Orders->get_order( $order_id, $fields ) ); + } + + return array( 'orders' => apply_filters( 'woocommerce_api_customer_orders_response', $orders, $id, $fields, $order_ids, $this->server ) ); + } + + /** + * Helper method to get customer user objects + * + * Note that WP_User_Query does not have built-in pagination so limit & offset are used to provide limited + * pagination support + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_User_Query + */ + private function query_customers( $args = array() ) { + + // default users per page + $users_per_page = get_option( 'posts_per_page' ); + + // set base query arguments + $query_args = array( + 'fields' => 'ID', + 'role' => 'customer', + 'orderby' => 'registered', + 'number' => $users_per_page, + ); + + // search + if ( ! empty( $args['q'] ) ) { + $query_args['search'] = $args['q']; + } + + // limit number of users returned + if ( ! empty( $args['limit'] ) ) { + + $query_args['number'] = absint( $args['limit'] ); + + $users_per_page = absint( $args['limit'] ); + } + + // page + $page = ( isset( $args['page'] ) ) ? absint( $args['page'] ) : 1; + + // offset + if ( ! empty( $args['offset'] ) ) { + $query_args['offset'] = absint( $args['offset'] ); + } else { + $query_args['offset'] = $users_per_page * ( $page - 1 ); + } + + // created date + if ( ! empty( $args['created_at_min'] ) ) { + $this->created_at_min = $this->server->parse_datetime( $args['created_at_min'] ); + } + + if ( ! empty( $args['created_at_max'] ) ) { + $this->created_at_max = $this->server->parse_datetime( $args['created_at_max'] ); + } + + $query = new WP_User_Query( $query_args ); + + // helper members for pagination headers + $query->total_pages = ceil( $query->get_total() / $users_per_page ); + $query->page = $page; + + return $query; + } + + /** + * Add customer data to orders + * + * @since 2.1 + * @param $order_data + * @param $order + * @return array + */ + public function add_customer_data( $order_data, $order ) { + + if ( 0 == $order->get_user_id() ) { + + // add customer data from order + $order_data['customer'] = array( + 'id' => 0, + 'email' => $order->get_billing_email(), + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + ); + + } else { + + $order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) ); + } + + return $order_data; + } + + /** + * Modify the WP_User_Query to support filtering on the date the customer was created + * + * @since 2.1 + * @param WP_User_Query $query + */ + public function modify_user_query( $query ) { + + if ( $this->created_at_min ) { + $query->query_where .= sprintf( " AND user_registered >= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%h:%%i:%%s' )", esc_sql( $this->created_at_min ) ); + } + + if ( $this->created_at_max ) { + $query->query_where .= sprintf( " AND user_registered <= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%h:%%i:%%s' )", esc_sql( $this->created_at_max ) ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid WP_User + * 3) the current user has the proper permissions + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * @param string|int $id the customer ID + * @param string $type the request type, unused because this method overrides the parent class + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid user ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + $id = absint( $id ); + + // validate ID + if ( empty( $id ) ) { + return new WP_Error( 'woocommerce_api_invalid_customer_id', __( 'Invalid customer ID', 'woocommerce' ), array( 'status' => 404 ) ); + } + + // non-existent IDs return a valid WP_User object with the user ID = 0 + $customer = new WP_User( $id ); + + if ( 0 === $customer->ID ) { + return new WP_Error( 'woocommerce_api_invalid_customer', __( 'Invalid customer', 'woocommerce' ), array( 'status' => 404 ) ); + } + + // validate permissions + switch ( $context ) { + + case 'read': + if ( ! current_user_can( 'list_users' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_read_customer', __( 'You do not have permission to read this customer', 'woocommerce' ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! current_user_can( 'edit_users' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_edit_customer', __( 'You do not have permission to edit this customer', 'woocommerce' ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! current_user_can( 'delete_users' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_delete_customer', __( 'You do not have permission to delete this customer', 'woocommerce' ), array( 'status' => 401 ) ); + } + break; + } + + return $id; + } + + /** + * Check if the current user can read users + * + * @since 2.1 + * @see WC_API_Resource::is_readable() + * @param int|WP_Post $post unused + * @return bool true if the current user can read users, false otherwise + */ + protected function is_readable( $post ) { + + return current_user_can( 'list_users' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-json-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-json-handler.php new file mode 100644 index 0000000..adc5129 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-json-handler.php @@ -0,0 +1,79 @@ +api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ); + } + + // Check for invalid characters (only alphanumeric allowed) + if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) { + + WC()->api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ); + } + + // see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ + WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' ); + + // Prepend '/**/' to mitigate possible JSONP Flash attacks + return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')'; + } + + return json_encode( $data ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-orders.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-orders.php new file mode 100644 index 0000000..c4a391d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-orders.php @@ -0,0 +1,396 @@ + + * GET /orders//notes + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET /orders + $routes[ $this->base ] = array( + array( array( $this, 'get_orders' ), WC_API_Server::READABLE ), + ); + + # GET /orders/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_orders_count' ), WC_API_Server::READABLE ), + ); + + # GET|PUT /orders/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_order' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /orders//notes + $routes[ $this->base . '/(?P\d+)/notes' ] = array( + array( array( $this, 'get_order_notes' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get all orders + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param string $status + * @param int $page + * @return array + */ + public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $filter['page'] = $page; + + $query = $this->query_orders( $filter ); + + $orders = array(); + + foreach ( $query->posts as $order_id ) { + + if ( ! $this->is_readable( $order_id ) ) { + continue; + } + + $orders[] = current( $this->get_order( $order_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'orders' => $orders ); + } + + + /** + * Get the order for the given ID + * + * @since 2.1 + * @param int $id the order ID + * @param array $fields + * @return array|WP_Error + */ + public function get_order( $id, $fields = null ) { + + // ensure order ID is valid & user has permission to read + $id = $this->validate_request( $id, 'shop_order', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order = wc_get_order( $id ); + $order_data = array( + 'id' => $order->get_id(), + 'order_number' => $order->get_order_number(), + 'created_at' => $this->server->format_datetime( $order->get_date_created() ? $order->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $order->get_date_modified() ? $order->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'completed_at' => $this->server->format_datetime( $order->get_date_completed() ? $order->get_date_completed()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'status' => $order->get_status(), + 'currency' => $order->get_currency(), + 'total' => wc_format_decimal( $order->get_total(), 2 ), + 'subtotal' => wc_format_decimal( $this->get_order_subtotal( $order ), 2 ), + 'total_line_items_quantity' => $order->get_item_count(), + 'total_tax' => wc_format_decimal( $order->get_total_tax(), 2 ), + 'total_shipping' => wc_format_decimal( $order->get_shipping_total(), 2 ), + 'cart_tax' => wc_format_decimal( $order->get_cart_tax(), 2 ), + 'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), 2 ), + 'total_discount' => wc_format_decimal( $order->get_total_discount(), 2 ), + 'cart_discount' => wc_format_decimal( 0, 2 ), + 'order_discount' => wc_format_decimal( 0, 2 ), + 'shipping_methods' => $order->get_shipping_method(), + 'payment_details' => array( + 'method_id' => $order->get_payment_method(), + 'method_title' => $order->get_payment_method_title(), + 'paid' => ! is_null( $order->get_date_paid() ), + ), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + 'note' => $order->get_customer_note(), + 'customer_ip' => $order->get_customer_ip_address(), + 'customer_user_agent' => $order->get_customer_user_agent(), + 'customer_id' => $order->get_user_id(), + 'view_order_url' => $order->get_view_order_url(), + 'line_items' => array(), + 'shipping_lines' => array(), + 'tax_lines' => array(), + 'fee_lines' => array(), + 'coupon_lines' => array(), + ); + + // add line items + foreach ( $order->get_items() as $item_id => $item ) { + $product = $item->get_product(); + $order_data['line_items'][] = array( + 'id' => $item_id, + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ), + 'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ), + 'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ), + 'quantity' => $item->get_quantity(), + 'tax_class' => $item->get_tax_class(), + 'name' => $item->get_name(), + 'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), + 'sku' => is_object( $product ) ? $product->get_sku() : null, + ); + } + + // add shipping + foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) { + $order_data['shipping_lines'][] = array( + 'id' => $shipping_item_id, + 'method_id' => $shipping_item->get_method_id(), + 'method_title' => $shipping_item->get_name(), + 'total' => wc_format_decimal( $shipping_item->get_total(), 2 ), + ); + } + + // add taxes + foreach ( $order->get_tax_totals() as $tax_code => $tax ) { + $order_data['tax_lines'][] = array( + 'code' => $tax_code, + 'title' => $tax->label, + 'total' => wc_format_decimal( $tax->amount, 2 ), + 'compound' => (bool) $tax->is_compound, + ); + } + + // add fees + foreach ( $order->get_fees() as $fee_item_id => $fee_item ) { + $order_data['fee_lines'][] = array( + 'id' => $fee_item_id, + 'title' => $fee_item->get_name(), + 'tax_class' => $fee_item->get_tax_class(), + 'total' => wc_format_decimal( $order->get_line_total( $fee_item ), 2 ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), 2 ), + ); + } + + // add coupons + foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) { + $order_data['coupon_lines'][] = array( + 'id' => $coupon_item_id, + 'code' => $coupon_item->get_code(), + 'amount' => wc_format_decimal( $coupon_item->get_discount(), 2 ), + ); + } + + return array( 'order' => apply_filters( 'woocommerce_api_order_response', $order_data, $order, $fields, $this->server ) ); + } + + /** + * Get the total number of orders + * + * @since 2.1 + * + * @param string $status + * @param array $filter + * + * @return array|WP_Error + */ + public function get_orders_count( $status = null, $filter = array() ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $query = $this->query_orders( $filter ); + + if ( ! current_user_can( 'read_private_shop_orders' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), array( 'status' => 401 ) ); + } + + return array( 'count' => (int) $query->found_posts ); + } + + /** + * Edit an order + * + * API v1 only allows updating the status of an order + * + * @since 2.1 + * @param int $id the order ID + * @param array $data + * @return array|WP_Error + */ + public function edit_order( $id, $data ) { + + $id = $this->validate_request( $id, 'shop_order', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order = wc_get_order( $id ); + + if ( ! empty( $data['status'] ) ) { + + $order->update_status( $data['status'], isset( $data['note'] ) ? $data['note'] : '' ); + } + + return $this->get_order( $id ); + } + + /** + * Delete an order + * + * @param int $id the order ID + * @param bool $force true to permanently delete order, false to move to trash + * @return array + */ + public function delete_order( $id, $force = false ) { + + $id = $this->validate_request( $id, 'shop_order', 'delete' ); + + return $this->delete( $id, 'order', ( 'true' === $force ) ); + } + + /** + * Get the admin order notes for an order + * + * @since 2.1 + * @param int $id the order ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_order_notes( $id, $fields = null ) { + + // ensure ID is valid order ID + $id = $this->validate_request( $id, 'shop_order', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $args = array( + 'post_id' => $id, + 'approve' => 'approve', + 'type' => 'order_note', + ); + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $notes = get_comments( $args ); + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $order_notes = array(); + + foreach ( $notes as $note ) { + + $order_notes[] = array( + 'id' => $note->comment_ID, + 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), + 'note' => $note->comment_content, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), + ); + } + + return array( 'order_notes' => apply_filters( 'woocommerce_api_order_notes_response', $order_notes, $id, $fields, $notes, $this->server ) ); + } + + /** + * Helper method to get order post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_orders( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'shop_order', + 'post_status' => array_keys( wc_get_order_statuses() ), + ); + + // add status argument + if ( ! empty( $args['status'] ) ) { + + $statuses = 'wc-' . str_replace( ',', ',wc-', $args['status'] ); + $statuses = explode( ',', $statuses ); + $query_args['post_status'] = $statuses; + + unset( $args['status'] ); + + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Helper method to get the order subtotal + * + * @since 2.1 + * @param WC_Order $order + * @return float + */ + private function get_order_subtotal( $order ) { + $subtotal = 0; + + // subtotal + foreach ( $order->get_items() as $item ) { + $subtotal += $item->get_subtotal(); + } + + return $subtotal; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-products.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-products.php new file mode 100644 index 0000000..7026333 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-products.php @@ -0,0 +1,548 @@ + + * GET /products//reviews + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET /products + $routes[ $this->base ] = array( + array( array( $this, 'get_products' ), WC_API_Server::READABLE ), + ); + + # GET /products/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_products_count' ), WC_API_Server::READABLE ), + ); + + # GET /products/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_product' ), WC_API_Server::READABLE ), + ); + + # GET /products//reviews + $routes[ $this->base . '/(?P\d+)/reviews' ] = array( + array( array( $this, 'get_product_reviews' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get all products + * + * @since 2.1 + * @param string $fields + * @param string $type + * @param array $filter + * @param int $page + * @return array + */ + public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) { + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + $filter['page'] = $page; + + $query = $this->query_products( $filter ); + + $products = array(); + + foreach ( $query->posts as $product_id ) { + + if ( ! $this->is_readable( $product_id ) ) { + continue; + } + + $products[] = current( $this->get_product( $product_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'products' => $products ); + } + + /** + * Get the product for the given ID + * + * @since 2.1 + * @param int $id the product ID + * @param string $fields + * @return array|WP_Error + */ + public function get_product( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + // add data that applies to every product type + $product_data = $this->get_product_data( $product ); + + // add variations to variable products + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + $product_data['variations'] = $this->get_variation_data( $product ); + } + + // add the parent product data to an individual variation + if ( $product->is_type( 'variation' ) ) { + $product_data['parent'] = $this->get_product_data( $product->get_parent_id() ); + } + + return array( 'product' => apply_filters( 'woocommerce_api_product_response', $product_data, $product, $fields, $this->server ) ); + } + + /** + * Get the total number of orders + * + * @since 2.1 + * + * @param string $type + * @param array $filter + * + * @return array|WP_Error + */ + public function get_products_count( $type = null, $filter = array() ) { + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + if ( ! current_user_can( 'read_private_products' ) ) { + return new WP_Error( 'woocommerce_api_user_cannot_read_products_count', __( 'You do not have permission to read the products count', 'woocommerce' ), array( 'status' => 401 ) ); + } + + $query = $this->query_products( $filter ); + + return array( 'count' => (int) $query->found_posts ); + } + + /** + * Edit a product + * + * @param int $id the product ID + * @param array $data + * @return array|WP_Error + */ + public function edit_product( $id, $data ) { + + $id = $this->validate_request( $id, 'product', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + return $this->get_product( $id ); + } + + /** + * Delete a product + * + * @param int $id the product ID + * @param bool $force true to permanently delete order, false to move to trash + * @return array|WP_Error + */ + public function delete_product( $id, $force = false ) { + + $id = $this->validate_request( $id, 'product', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + return $this->delete( $id, 'product', ( 'true' === $force ) ); + } + + /** + * Get the reviews for a product + * + * @since 2.1 + * @param int $id the product ID to get reviews for + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_product_reviews( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $args = array( + 'post_id' => $id, + 'approve' => 'approve', + ); + + $comments = get_comments( $args ); + + $reviews = array(); + + foreach ( $comments as $comment ) { + + $reviews[] = array( + 'id' => $comment->comment_ID, + 'created_at' => $this->server->format_datetime( $comment->comment_date_gmt ), + 'review' => $comment->comment_content, + 'rating' => get_comment_meta( $comment->comment_ID, 'rating', true ), + 'reviewer_name' => $comment->comment_author, + 'reviewer_email' => $comment->comment_author_email, + 'verified' => wc_review_is_from_verified_owner( $comment->comment_ID ), + ); + } + + return array( 'product_reviews' => apply_filters( 'woocommerce_api_product_reviews_response', $reviews, $id, $fields, $comments, $this->server ) ); + } + + /** + * Helper method to get product post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_products( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'product', + 'post_status' => 'publish', + 'meta_query' => array(), + ); + + if ( ! empty( $args['type'] ) ) { + + $types = explode( ',', $args['type'] ); + + $query_args['tax_query'] = array( + array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $types, + ), + ); + + unset( $args['type'] ); + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Get standard product data that applies to every product type + * + * @since 2.1 + * @param WC_Product|int $product + * @return array + */ + private function get_product_data( $product ) { + if ( is_numeric( $product ) ) { + $product = wc_get_product( $product ); + } + + if ( ! is_a( $product, 'WC_Product' ) ) { + return array(); + } + + return array( + 'title' => $product->get_name(), + 'id' => $product->get_id(), + 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ), + 'type' => $product->get_type(), + 'status' => $product->get_status(), + 'downloadable' => $product->is_downloadable(), + 'virtual' => $product->is_virtual(), + 'permalink' => $product->get_permalink(), + 'sku' => $product->get_sku(), + 'price' => wc_format_decimal( $product->get_price(), 2 ), + 'regular_price' => wc_format_decimal( $product->get_regular_price(), 2 ), + 'sale_price' => $product->get_sale_price() ? wc_format_decimal( $product->get_sale_price(), 2 ) : null, + 'price_html' => $product->get_price_html(), + 'taxable' => $product->is_taxable(), + 'tax_status' => $product->get_tax_status(), + 'tax_class' => $product->get_tax_class(), + 'managing_stock' => $product->managing_stock(), + 'stock_quantity' => $product->get_stock_quantity(), + 'in_stock' => $product->is_in_stock(), + 'backorders_allowed' => $product->backorders_allowed(), + 'backordered' => $product->is_on_backorder(), + 'sold_individually' => $product->is_sold_individually(), + 'purchaseable' => $product->is_purchasable(), + 'featured' => $product->is_featured(), + 'visible' => $product->is_visible(), + 'catalog_visibility' => $product->get_catalog_visibility(), + 'on_sale' => $product->is_on_sale(), + 'weight' => $product->get_weight() ? wc_format_decimal( $product->get_weight(), 2 ) : null, + 'dimensions' => array( + 'length' => $product->get_length(), + 'width' => $product->get_width(), + 'height' => $product->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_required' => $product->needs_shipping(), + 'shipping_taxable' => $product->is_shipping_taxable(), + 'shipping_class' => $product->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $product->get_shipping_class_id() ) ? $product->get_shipping_class_id() : null, + 'description' => apply_filters( 'the_content', $product->get_description() ), + 'short_description' => apply_filters( 'woocommerce_short_description', $product->get_short_description() ), + 'reviews_allowed' => $product->get_reviews_allowed(), + 'average_rating' => wc_format_decimal( $product->get_average_rating(), 2 ), + 'rating_count' => $product->get_rating_count(), + 'related_ids' => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ), + 'upsell_ids' => array_map( 'absint', $product->get_upsell_ids() ), + 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sell_ids() ), + 'categories' => wc_get_object_terms( $product->get_id(), 'product_cat', 'name' ), + 'tags' => wc_get_object_terms( $product->get_id(), 'product_tag', 'name' ), + 'images' => $this->get_images( $product ), + 'featured_src' => wp_get_attachment_url( get_post_thumbnail_id( $product->get_id() ) ), + 'attributes' => $this->get_attributes( $product ), + 'downloads' => $this->get_downloads( $product ), + 'download_limit' => $product->get_download_limit(), + 'download_expiry' => $product->get_download_expiry(), + 'download_type' => 'standard', + 'purchase_note' => apply_filters( 'the_content', $product->get_purchase_note() ), + 'total_sales' => $product->get_total_sales(), + 'variations' => array(), + 'parent' => array(), + ); + } + + /** + * Get an individual variation's data + * + * @since 2.1 + * @param WC_Product $product + * @return array + */ + private function get_variation_data( $product ) { + $variations = array(); + + foreach ( $product->get_children() as $child_id ) { + $variation = wc_get_product( $child_id ); + + if ( ! $variation || ! $variation->exists() ) { + continue; + } + + $variations[] = array( + 'id' => $variation->get_id(), + 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ), + 'downloadable' => $variation->is_downloadable(), + 'virtual' => $variation->is_virtual(), + 'permalink' => $variation->get_permalink(), + 'sku' => $variation->get_sku(), + 'price' => wc_format_decimal( $variation->get_price(), 2 ), + 'regular_price' => wc_format_decimal( $variation->get_regular_price(), 2 ), + 'sale_price' => $variation->get_sale_price() ? wc_format_decimal( $variation->get_sale_price(), 2 ) : null, + 'taxable' => $variation->is_taxable(), + 'tax_status' => $variation->get_tax_status(), + 'tax_class' => $variation->get_tax_class(), + 'stock_quantity' => (int) $variation->get_stock_quantity(), + 'in_stock' => $variation->is_in_stock(), + 'backordered' => $variation->is_on_backorder(), + 'purchaseable' => $variation->is_purchasable(), + 'visible' => $variation->variation_is_visible(), + 'on_sale' => $variation->is_on_sale(), + 'weight' => $variation->get_weight() ? wc_format_decimal( $variation->get_weight(), 2 ) : null, + 'dimensions' => array( + 'length' => $variation->get_length(), + 'width' => $variation->get_width(), + 'height' => $variation->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_class' => $variation->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null, + 'image' => $this->get_images( $variation ), + 'attributes' => $this->get_attributes( $variation ), + 'downloads' => $this->get_downloads( $variation ), + 'download_limit' => (int) $product->get_download_limit(), + 'download_expiry' => (int) $product->get_download_expiry(), + ); + } + + return $variations; + } + + /** + * Get the images for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_images( $product ) { + $images = $attachment_ids = array(); + $product_image = $product->get_image_id(); + + // Add featured image. + if ( ! empty( $product_image ) ) { + $attachment_ids[] = $product_image; + } + + // add gallery images. + $attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() ); + + // Build image data. + foreach ( $attachment_ids as $position => $attachment_id ) { + + $attachment_post = get_post( $attachment_id ); + + if ( is_null( $attachment_post ) ) { + continue; + } + + $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ); + + if ( ! is_array( $attachment ) ) { + continue; + } + + $images[] = array( + 'id' => (int) $attachment_id, + 'created_at' => $this->server->format_datetime( $attachment_post->post_date_gmt ), + 'updated_at' => $this->server->format_datetime( $attachment_post->post_modified_gmt ), + 'src' => current( $attachment ), + 'title' => get_the_title( $attachment_id ), + 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), + 'position' => $position, + ); + } + + // Set a placeholder image if the product has no images set. + if ( empty( $images ) ) { + + $images[] = array( + 'id' => 0, + 'created_at' => $this->server->format_datetime( time() ), // default to now + 'updated_at' => $this->server->format_datetime( time() ), + 'src' => wc_placeholder_img_src(), + 'title' => __( 'Placeholder', 'woocommerce' ), + 'alt' => __( 'Placeholder', 'woocommerce' ), + 'position' => 0, + ); + } + + return $images; + } + + /** + * Get attribute options. + * + * @param int $product_id + * @param array $attribute + * @return array + */ + protected function get_attribute_options( $product_id, $attribute ) { + if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { + return wc_get_product_terms( $product_id, $attribute['name'], array( 'fields' => 'names' ) ); + } elseif ( isset( $attribute['value'] ) ) { + return array_map( 'trim', explode( '|', $attribute['value'] ) ); + } + + return array(); + } + + /** + * Get the attributes for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_attributes( $product ) { + + $attributes = array(); + + if ( $product->is_type( 'variation' ) ) { + + // variation attributes + foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { + + // taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_` + $attributes[] = array( + 'name' => ucwords( str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ) ), + 'option' => $attribute, + ); + } + } else { + + foreach ( $product->get_attributes() as $attribute ) { + $attributes[] = array( + 'name' => ucwords( str_replace( 'pa_', '', $attribute['name'] ) ), + 'position' => $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } + } + + return $attributes; + } + + /** + * Get the downloads for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_downloads( $product ) { + + $downloads = array(); + + if ( $product->is_downloadable() ) { + + foreach ( $product->get_downloads() as $file_id => $file ) { + + $downloads[] = array( + 'id' => $file_id, // do not cast as int as this is a hash + 'name' => $file['name'], + 'file' => $file['file'], + ); + } + } + + return $downloads; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-reports.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-reports.php new file mode 100644 index 0000000..527ea64 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-reports.php @@ -0,0 +1,482 @@ +base ] = array( + array( array( $this, 'get_reports' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales + $routes[ $this->base . '/sales' ] = array( + array( array( $this, 'get_sales_report' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales/top_sellers + $routes[ $this->base . '/sales/top_sellers' ] = array( + array( array( $this, 'get_top_sellers_report' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get a simple listing of available reports + * + * @since 2.1 + * @return array + */ + public function get_reports() { + + return array( 'reports' => array( 'sales', 'sales/top_sellers' ) ); + } + + /** + * Get the sales report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_sales_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + // total sales, taxes, shipping, and order count + $totals = $this->report->get_order_report_data( array( + 'data' => array( + '_order_total' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'sales', + ), + '_order_tax' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'tax', + ), + '_order_shipping_tax' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'shipping_tax', + ), + '_order_shipping' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'shipping', + ), + 'ID' => array( + 'type' => 'post_data', + 'function' => 'COUNT', + 'name' => 'order_count', + ), + ), + 'filter_range' => true, + ) ); + + // total items ordered + $total_items = absint( $this->report->get_order_report_data( array( + 'data' => array( + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_qty', + ), + ), + 'query_type' => 'get_var', + 'filter_range' => true, + ) ) ); + + // total discount used + $total_discount = $this->report->get_order_report_data( array( + 'data' => array( + 'discount_amount' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'coupon', + 'function' => 'SUM', + 'name' => 'discount_amount', + ), + ), + 'where' => array( + array( + 'key' => 'order_item_type', + 'value' => 'coupon', + 'operator' => '=', + ), + ), + 'query_type' => 'get_var', + 'filter_range' => true, + ) ); + + // new customers + $users_query = new WP_User_Query( + array( + 'fields' => array( 'user_registered' ), + 'role' => 'customer', + ) + ); + + $customers = $users_query->get_results(); + + foreach ( $customers as $key => $customer ) { + if ( strtotime( $customer->user_registered ) < $this->report->start_date || strtotime( $customer->user_registered ) > $this->report->end_date ) { + unset( $customers[ $key ] ); + } + } + + $total_customers = count( $customers ); + + // get order totals grouped by period + $orders = $this->report->get_order_report_data( array( + 'data' => array( + '_order_total' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'total_sales', + ), + '_order_shipping' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'total_shipping', + ), + '_order_tax' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'total_tax', + ), + '_order_shipping_tax' => array( + 'type' => 'meta', + 'function' => 'SUM', + 'name' => 'total_shipping_tax', + ), + 'ID' => array( + 'type' => 'post_data', + 'function' => 'COUNT', + 'name' => 'total_orders', + 'distinct' => true, + ), + 'post_date' => array( + 'type' => 'post_data', + 'function' => '', + 'name' => 'post_date', + ), + ), + 'group_by' => $this->report->group_by_query, + 'order_by' => 'post_date ASC', + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + // get order item totals grouped by period + $order_items = $this->report->get_order_report_data( array( + 'data' => array( + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_count', + ), + 'post_date' => array( + 'type' => 'post_data', + 'function' => '', + 'name' => 'post_date', + ), + ), + 'where' => array( + array( + 'key' => 'order_item_type', + 'value' => 'line_item', + 'operator' => '=', + ), + ), + 'group_by' => $this->report->group_by_query, + 'order_by' => 'post_date ASC', + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + // get discount totals grouped by period + $discounts = $this->report->get_order_report_data( array( + 'data' => array( + 'discount_amount' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'coupon', + 'function' => 'SUM', + 'name' => 'discount_amount', + ), + 'post_date' => array( + 'type' => 'post_data', + 'function' => '', + 'name' => 'post_date', + ), + ), + 'where' => array( + array( + 'key' => 'order_item_type', + 'value' => 'coupon', + 'operator' => '=', + ), + ), + 'group_by' => $this->report->group_by_query . ', order_item_name', + 'order_by' => 'post_date ASC', + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + $period_totals = array(); + + // setup period totals by ensuring each period in the interval has data + for ( $i = 0; $i <= $this->report->chart_interval; $i ++ ) { + + switch ( $this->report->chart_groupby ) { + case 'day' : + $time = date( 'Y-m-d', strtotime( "+{$i} DAY", $this->report->start_date ) ); + break; + case 'month' : + $time = date( 'Y-m', strtotime( "+{$i} MONTH", $this->report->start_date ) ); + break; + } + + // set the customer signups for each period + $customer_count = 0; + foreach ( $customers as $customer ) { + + if ( date( ( 'day' == $this->report->chart_groupby ) ? 'Y-m-d' : 'Y-m', strtotime( $customer->user_registered ) ) == $time ) { + $customer_count++; + } + } + + $period_totals[ $time ] = array( + 'sales' => wc_format_decimal( 0.00, 2 ), + 'orders' => 0, + 'items' => 0, + 'tax' => wc_format_decimal( 0.00, 2 ), + 'shipping' => wc_format_decimal( 0.00, 2 ), + 'discount' => wc_format_decimal( 0.00, 2 ), + 'customers' => $customer_count, + ); + } + + // add total sales, total order count, total tax and total shipping for each period + foreach ( $orders as $order ) { + + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['sales'] = wc_format_decimal( $order->total_sales, 2 ); + $period_totals[ $time ]['orders'] = (int) $order->total_orders; + $period_totals[ $time ]['tax'] = wc_format_decimal( $order->total_tax + $order->total_shipping_tax, 2 ); + $period_totals[ $time ]['shipping'] = wc_format_decimal( $order->total_shipping, 2 ); + } + + // add total order items for each period + foreach ( $order_items as $order_item ) { + + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order_item->post_date ) ) : date( 'Y-m', strtotime( $order_item->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['items'] = (int) $order_item->order_item_count; + } + + // add total discount for each period + foreach ( $discounts as $discount ) { + + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $discount->post_date ) ) : date( 'Y-m', strtotime( $discount->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['discount'] = wc_format_decimal( $discount->discount_amount, 2 ); + } + + $sales_data = array( + 'total_sales' => wc_format_decimal( $totals->sales, 2 ), + 'average_sales' => wc_format_decimal( $totals->sales / ( $this->report->chart_interval + 1 ), 2 ), + 'total_orders' => (int) $totals->order_count, + 'total_items' => $total_items, + 'total_tax' => wc_format_decimal( $totals->tax + $totals->shipping_tax, 2 ), + 'total_shipping' => wc_format_decimal( $totals->shipping, 2 ), + 'total_discount' => is_null( $total_discount ) ? wc_format_decimal( 0.00, 2 ) : wc_format_decimal( $total_discount, 2 ), + 'totals_grouped_by' => $this->report->chart_groupby, + 'totals' => $period_totals, + 'total_customers' => $total_customers, + ); + + return array( 'sales' => apply_filters( 'woocommerce_api_report_response', $sales_data, $this->report, $fields, $this->server ) ); + } + + /** + * Get the top sellers report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_top_sellers_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + $top_sellers = $this->report->get_order_report_data( array( + 'data' => array( + '_product_id' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => '', + 'name' => 'product_id', + ), + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_qty', + ), + ), + 'order_by' => 'order_item_qty DESC', + 'group_by' => 'product_id', + 'limit' => isset( $filter['limit'] ) ? absint( $filter['limit'] ) : 12, + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + $top_sellers_data = array(); + + foreach ( $top_sellers as $top_seller ) { + + $product = wc_get_product( $top_seller->product_id ); + + $top_sellers_data[] = array( + 'title' => $product->get_name(), + 'product_id' => $top_seller->product_id, + 'quantity' => $top_seller->order_item_qty, + ); + } + + return array( 'top_sellers' => apply_filters( 'woocommerce_api_report_response', $top_sellers_data, $this->report, $fields, $this->server ) ); + } + + /** + * Setup the report object and parse any date filtering + * + * @since 2.1 + * @param array $filter date filtering + */ + private function setup_report( $filter ) { + + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-admin-report.php' ); + + $this->report = new WC_Admin_Report(); + + if ( empty( $filter['period'] ) ) { + + // custom date range + $filter['period'] = 'custom'; + + if ( ! empty( $filter['date_min'] ) || ! empty( $filter['date_max'] ) ) { + + // overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges + $_GET['start_date'] = $this->server->parse_datetime( $filter['date_min'] ); + $_GET['end_date'] = isset( $filter['date_max'] ) ? $this->server->parse_datetime( $filter['date_max'] ) : null; + + } else { + + // default custom range to today + $_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) ); + } + } else { + + // ensure period is valid + if ( ! in_array( $filter['period'], array( 'week', 'month', 'last_month', 'year' ) ) ) { + $filter['period'] = 'week'; + } + + // TODO: change WC_Admin_Report class to use "week" instead, as it's more consistent with other periods + // allow "week" for period instead of "7day" + if ( 'week' === $filter['period'] ) { + $filter['period'] = '7day'; + } + } + + $this->report->calculate_current_range( $filter['period'] ); + } + + /** + * Verify that the current user has permission to view reports + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * @param null $id unused + * @param null $type unused + * @param null $context unused + * @return true|WP_Error + */ + protected function validate_request( $id = null, $type = null, $context = null ) { + + if ( ! current_user_can( 'view_woocommerce_reports' ) ) { + + return new WP_Error( 'woocommerce_api_user_cannot_read_report', __( 'You do not have permission to read this report', 'woocommerce' ), array( 'status' => 401 ) ); + + } else { + + return true; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-resource.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-resource.php new file mode 100644 index 0000000..d419f83 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-resource.php @@ -0,0 +1,409 @@ +server = $server; + + // automatically register routes for sub-classes + add_filter( 'woocommerce_api_endpoints', array( $this, 'register_routes' ) ); + + // remove fields from responses when requests specify certain fields + // note these are hooked at a later priority so data added via filters (e.g. customer data to the order response) + // still has the fields filtered properly + foreach ( array( 'order', 'coupon', 'customer', 'product', 'report' ) as $resource ) { + + add_filter( "woocommerce_api_{$resource}_response", array( $this, 'maybe_add_meta' ), 15, 2 ); + add_filter( "woocommerce_api_{$resource}_response", array( $this, 'filter_response_fields' ), 20, 3 ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid post object and matches the provided post type + * 3) the current user has the proper permissions to read/edit/delete the post + * + * @since 2.1 + * @param string|int $id the post ID + * @param string $type the post type, either `shop_order`, `shop_coupon`, or `product` + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid post ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + $id = absint( $id ); + + // validate ID + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}_id", sprintf( __( 'Invalid %s ID', 'woocommerce' ), $type ), array( 'status' => 404 ) ); + } + + // only custom post types have per-post type/permission checks + if ( 'customer' !== $type ) { + + $post = get_post( $id ); + + // for checking permissions, product variations are the same as the product post type + $post_type = ( 'product_variation' === $post->post_type ) ? 'product' : $post->post_type; + + // validate post type + if ( $type !== $post_type ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}", sprintf( __( 'Invalid %s', 'woocommerce' ), $resource_name ), array( 'status' => 404 ) ); + } + + // validate permissions + switch ( $context ) { + + case 'read': + if ( ! $this->is_readable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_read_{$resource_name}", sprintf( __( 'You do not have permission to read this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! $this->is_editable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_edit_{$resource_name}", sprintf( __( 'You do not have permission to edit this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! $this->is_deletable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_delete_{$resource_name}", sprintf( __( 'You do not have permission to delete this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + } + } + + return $id; + } + + /** + * Add common request arguments to argument list before WP_Query is run + * + * @since 2.1 + * @param array $base_args required arguments for the query (e.g. `post_type`, etc) + * @param array $request_args arguments provided in the request + * @return array + */ + protected function merge_query_args( $base_args, $request_args ) { + + $args = array(); + + // date + if ( ! empty( $request_args['created_at_min'] ) || ! empty( $request_args['created_at_max'] ) || ! empty( $request_args['updated_at_min'] ) || ! empty( $request_args['updated_at_max'] ) ) { + + $args['date_query'] = array(); + + // resources created after specified date + if ( ! empty( $request_args['created_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'after' => $this->server->parse_datetime( $request_args['created_at_min'] ), 'inclusive' => true ); + } + + // resources created before specified date + if ( ! empty( $request_args['created_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'before' => $this->server->parse_datetime( $request_args['created_at_max'] ), 'inclusive' => true ); + } + + // resources updated after specified date + if ( ! empty( $request_args['updated_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'after' => $this->server->parse_datetime( $request_args['updated_at_min'] ), 'inclusive' => true ); + } + + // resources updated before specified date + if ( ! empty( $request_args['updated_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'before' => $this->server->parse_datetime( $request_args['updated_at_max'] ), 'inclusive' => true ); + } + } + + // search + if ( ! empty( $request_args['q'] ) ) { + $args['s'] = $request_args['q']; + } + + // resources per response + if ( ! empty( $request_args['limit'] ) ) { + $args['posts_per_page'] = $request_args['limit']; + } + + // resource offset + if ( ! empty( $request_args['offset'] ) ) { + $args['offset'] = $request_args['offset']; + } + + // resource page + $args['paged'] = ( isset( $request_args['page'] ) ) ? absint( $request_args['page'] ) : 1; + + return array_merge( $base_args, $args ); + } + + /** + * Add meta to resources when requested by the client. Meta is added as a top-level + * `_meta` attribute (e.g. `order_meta`) as a list of key/value pairs + * + * @since 2.1 + * @param array $data the resource data + * @param object $resource the resource object (e.g WC_Order) + * @return mixed + */ + public function maybe_add_meta( $data, $resource ) { + + if ( isset( $this->server->params['GET']['filter']['meta'] ) && 'true' === $this->server->params['GET']['filter']['meta'] && is_object( $resource ) ) { + + // don't attempt to add meta more than once + if ( preg_grep( '/[a-z]+_meta/', array_keys( $data ) ) ) { + return $data; + } + + // define the top-level property name for the meta + switch ( get_class( $resource ) ) { + + case 'WC_Order': + $meta_name = 'order_meta'; + break; + + case 'WC_Coupon': + $meta_name = 'coupon_meta'; + break; + + case 'WP_User': + $meta_name = 'customer_meta'; + break; + + default: + $meta_name = 'product_meta'; + break; + } + + if ( is_a( $resource, 'WP_User' ) ) { + + // customer meta + $meta = (array) get_user_meta( $resource->ID ); + + } else { + + // coupon/order/product meta + $meta = (array) get_post_meta( $resource->get_id() ); + } + + foreach ( $meta as $meta_key => $meta_value ) { + + // don't add hidden meta by default + if ( ! is_protected_meta( $meta_key ) ) { + $data[ $meta_name ][ $meta_key ] = maybe_unserialize( $meta_value[0] ); + } + } + } + + return $data; + } + + /** + * Restrict the fields included in the response if the request specified certain only certain fields should be returned + * + * @since 2.1 + * @param array $data the response data + * @param object $resource the object that provided the response data, e.g. WC_Coupon or WC_Order + * @param array|string the requested list of fields to include in the response + * @return array response data + */ + public function filter_response_fields( $data, $resource, $fields ) { + + if ( ! is_array( $data ) || empty( $fields ) ) { + return $data; + } + + $fields = explode( ',', $fields ); + $sub_fields = array(); + + // get sub fields + foreach ( $fields as $field ) { + + if ( false !== strpos( $field, '.' ) ) { + + list( $name, $value ) = explode( '.', $field ); + + $sub_fields[ $name ] = $value; + } + } + + // iterate through top-level fields + foreach ( $data as $data_field => $data_value ) { + + // if a field has sub-fields and the top-level field has sub-fields to filter + if ( is_array( $data_value ) && in_array( $data_field, array_keys( $sub_fields ) ) ) { + + // iterate through each sub-field + foreach ( $data_value as $sub_field => $sub_field_value ) { + + // remove non-matching sub-fields + if ( ! in_array( $sub_field, $sub_fields ) ) { + unset( $data[ $data_field ][ $sub_field ] ); + } + } + } else { + + // remove non-matching top-level fields + if ( ! in_array( $data_field, $fields ) ) { + unset( $data[ $data_field ] ); + } + } + } + + return $data; + } + + /** + * Delete a given resource + * + * @since 2.1 + * @param int $id the resource ID + * @param string $type the resource post type, or `customer` + * @param bool $force true to permanently delete resource, false to move to trash (not supported for `customer`) + * @return array|WP_Error + */ + protected function delete( $id, $type, $force = false ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + if ( 'customer' === $type ) { + + $result = wp_delete_user( $id ); + + if ( $result ) { + return array( 'message' => __( 'Permanently deleted customer', 'woocommerce' ) ); + } else { + return new WP_Error( 'woocommerce_api_cannot_delete_customer', __( 'The customer cannot be deleted', 'woocommerce' ), array( 'status' => 500 ) ); + } + } else { + + // delete order/coupon/product + $result = ( $force ) ? wp_delete_post( $id, true ) : wp_trash_post( $id ); + + if ( ! $result ) { + return new WP_Error( "woocommerce_api_cannot_delete_{$resource_name}", sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), $resource_name ), array( 'status' => 500 ) ); + } + + if ( $force ) { + return array( 'message' => sprintf( __( 'Permanently deleted %s', 'woocommerce' ), $resource_name ) ); + + } else { + + $this->server->send_status( '202' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), $resource_name ) ); + } + } + } + + + /** + * Checks if the given post is readable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_readable( $post ) { + + return $this->check_permission( $post, 'read' ); + } + + /** + * Checks if the given post is editable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_editable( $post ) { + + return $this->check_permission( $post, 'edit' ); + + } + + /** + * Checks if the given post is deletable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_deletable( $post ) { + + return $this->check_permission( $post, 'delete' ); + } + + /** + * Checks the permissions for the current user given a post and context + * + * @since 2.1 + * @param WP_Post|int $post + * @param string $context the type of permission to check, either `read`, `write`, or `delete` + * @return bool true if the current user has the permissions to perform the context on the post + */ + private function check_permission( $post, $context ) { + + if ( ! is_a( $post, 'WP_Post' ) ) { + $post = get_post( $post ); + } + + if ( is_null( $post ) ) { + return false; + } + + $post_type = get_post_type_object( $post->post_type ); + + if ( 'read' === $context ) { + return current_user_can( $post_type->cap->read_private_posts, $post->ID ); + } elseif ( 'edit' === $context ) { + return current_user_can( $post_type->cap->edit_post, $post->ID ); + } elseif ( 'delete' === $context ) { + return current_user_can( $post_type->cap->delete_post, $post->ID ); + } else { + return false; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-server.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-server.php new file mode 100644 index 0000000..182d482 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-server.php @@ -0,0 +1,782 @@ + self::METHOD_GET, + 'GET' => self::METHOD_GET, + 'POST' => self::METHOD_POST, + 'PUT' => self::METHOD_PUT, + 'PATCH' => self::METHOD_PATCH, + 'DELETE' => self::METHOD_DELETE, + ); + + /** + * Requested path (relative to the API root, wp-json.php) + * + * @var string + */ + public $path = ''; + + /** + * Requested method (GET/HEAD/POST/PUT/PATCH/DELETE) + * + * @var string + */ + public $method = 'HEAD'; + + /** + * Request parameters + * + * This acts as an abstraction of the superglobals + * (GET => $_GET, POST => $_POST) + * + * @var array + */ + public $params = array( 'GET' => array(), 'POST' => array() ); + + /** + * Request headers + * + * @var array + */ + public $headers = array(); + + /** + * Request files (matches $_FILES) + * + * @var array + */ + public $files = array(); + + /** + * Request/Response handler, either JSON by default + * or XML if requested by client + * + * @var WC_API_Handler + */ + public $handler; + + + /** + * Setup class and set request/response handler + * + * @since 2.1 + * @param $path + */ + public function __construct( $path ) { + + if ( empty( $path ) ) { + if ( isset( $_SERVER['PATH_INFO'] ) ) { + $path = $_SERVER['PATH_INFO']; + } else { + $path = '/'; + } + } + + $this->path = $path; + $this->method = $_SERVER['REQUEST_METHOD']; + $this->params['GET'] = $_GET; + $this->params['POST'] = $_POST; + $this->headers = $this->get_headers( $_SERVER ); + $this->files = $_FILES; + + // Compatibility for clients that can't use PUT/PATCH/DELETE + if ( isset( $_GET['_method'] ) ) { + $this->method = strtoupper( $_GET['_method'] ); + } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { + $this->method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; + } + + // determine type of request/response and load handler, JSON by default + if ( $this->is_json_request() ) { + $handler_class = 'WC_API_JSON_Handler'; + } elseif ( $this->is_xml_request() ) { + $handler_class = 'WC_API_XML_Handler'; + } else { + $handler_class = apply_filters( 'woocommerce_api_default_response_handler', 'WC_API_JSON_Handler', $this->path, $this ); + } + + $this->handler = new $handler_class(); + } + + /** + * Check authentication for the request + * + * @since 2.1 + * @return WP_User|WP_Error WP_User object indicates successful login, WP_Error indicates unsuccessful login + */ + public function check_authentication() { + + // allow plugins to remove default authentication or add their own authentication + $user = apply_filters( 'woocommerce_api_check_authentication', null, $this ); + + // API requests run under the context of the authenticated user + if ( is_a( $user, 'WP_User' ) ) { + wp_set_current_user( $user->ID ); + } elseif ( ! is_wp_error( $user ) ) { + // WP_Errors are handled in serve_request() + $user = new WP_Error( 'woocommerce_api_authentication_error', __( 'Invalid authentication method', 'woocommerce' ), array( 'code' => 500 ) ); + } + + return $user; + } + + /** + * Convert an error to an array + * + * This iterates over all error codes and messages to change it into a flat + * array. This enables simpler client behaviour, as it is represented as a + * list in JSON rather than an object/map + * + * @since 2.1 + * @param WP_Error $error + * @return array List of associative arrays with code and message keys + */ + protected function error_to_array( $error ) { + $errors = array(); + foreach ( (array) $error->errors as $code => $messages ) { + foreach ( (array) $messages as $message ) { + $errors[] = array( 'code' => $code, 'message' => $message ); + } + } + return array( 'errors' => $errors ); + } + + /** + * Handle serving an API request + * + * Matches the current server URI to a route and runs the first matching + * callback then outputs a JSON representation of the returned value. + * + * @since 2.1 + * @uses WC_API_Server::dispatch() + */ + public function serve_request() { + + do_action( 'woocommerce_api_server_before_serve', $this ); + + $this->header( 'Content-Type', $this->handler->get_content_type(), true ); + + // the API is enabled by default + if ( ! apply_filters( 'woocommerce_api_enabled', true, $this ) || ( 'no' === get_option( 'woocommerce_api_enabled' ) ) ) { + + $this->send_status( 404 ); + + echo $this->handler->generate_response( array( 'errors' => array( 'code' => 'woocommerce_api_disabled', 'message' => 'The WooCommerce API is disabled on this site' ) ) ); + + return; + } + + $result = $this->check_authentication(); + + // if authorization check was successful, dispatch the request + if ( ! is_wp_error( $result ) ) { + $result = $this->dispatch(); + } + + // handle any dispatch errors + if ( is_wp_error( $result ) ) { + $data = $result->get_error_data(); + if ( is_array( $data ) && isset( $data['status'] ) ) { + $this->send_status( $data['status'] ); + } + + $result = $this->error_to_array( $result ); + } + + // This is a filter rather than an action, since this is designed to be + // re-entrant if needed + $served = apply_filters( 'woocommerce_api_serve_request', false, $result, $this ); + + if ( ! $served ) { + + if ( 'HEAD' === $this->method ) { + return; + } + + echo $this->handler->generate_response( $result ); + } + } + + /** + * Retrieve the route map + * + * The route map is an associative array with path regexes as the keys. The + * value is an indexed array with the callback function/method as the first + * item, and a bitmask of HTTP methods as the second item (see the class + * constants). + * + * Each route can be mapped to more than one callback by using an array of + * the indexed arrays. This allows mapping e.g. GET requests to one callback + * and POST requests to another. + * + * Note that the path regexes (array keys) must have @ escaped, as this is + * used as the delimiter with preg_match() + * + * @since 2.1 + * @return array `'/path/regex' => array( $callback, $bitmask )` or `'/path/regex' => array( array( $callback, $bitmask ), ...)` + */ + public function get_routes() { + + // index added by default + $endpoints = array( + + '/' => array( array( $this, 'get_index' ), self::READABLE ), + ); + + $endpoints = apply_filters( 'woocommerce_api_endpoints', $endpoints ); + + // Normalise the endpoints + foreach ( $endpoints as $route => &$handlers ) { + if ( count( $handlers ) <= 2 && isset( $handlers[1] ) && ! is_array( $handlers[1] ) ) { + $handlers = array( $handlers ); + } + } + + return $endpoints; + } + + /** + * Match the request to a callback and call it + * + * @since 2.1 + * @return mixed The value returned by the callback, or a WP_Error instance + */ + public function dispatch() { + + switch ( $this->method ) { + + case 'HEAD': + case 'GET': + $method = self::METHOD_GET; + break; + + case 'POST': + $method = self::METHOD_POST; + break; + + case 'PUT': + $method = self::METHOD_PUT; + break; + + case 'PATCH': + $method = self::METHOD_PATCH; + break; + + case 'DELETE': + $method = self::METHOD_DELETE; + break; + + default: + return new WP_Error( 'woocommerce_api_unsupported_method', __( 'Unsupported request method', 'woocommerce' ), array( 'status' => 400 ) ); + } + + foreach ( $this->get_routes() as $route => $handlers ) { + foreach ( $handlers as $handler ) { + $callback = $handler[0]; + $supported = isset( $handler[1] ) ? $handler[1] : self::METHOD_GET; + + if ( ! ( $supported & $method ) ) { + continue; + } + + $match = preg_match( '@^' . $route . '$@i', urldecode( $this->path ), $args ); + + if ( ! $match ) { + continue; + } + + if ( ! is_callable( $callback ) ) { + return new WP_Error( 'woocommerce_api_invalid_handler', __( 'The handler for the route is invalid', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $args = array_merge( $args, $this->params['GET'] ); + if ( $method & self::METHOD_POST ) { + $args = array_merge( $args, $this->params['POST'] ); + } + if ( $supported & self::ACCEPT_DATA ) { + $data = $this->handler->parse_body( $this->get_raw_data() ); + $args = array_merge( $args, array( 'data' => $data ) ); + } elseif ( $supported & self::ACCEPT_RAW_DATA ) { + $data = $this->get_raw_data(); + $args = array_merge( $args, array( 'data' => $data ) ); + } + + $args['_method'] = $method; + $args['_route'] = $route; + $args['_path'] = $this->path; + $args['_headers'] = $this->headers; + $args['_files'] = $this->files; + + $args = apply_filters( 'woocommerce_api_dispatch_args', $args, $callback ); + + // Allow plugins to halt the request via this filter + if ( is_wp_error( $args ) ) { + return $args; + } + + $params = $this->sort_callback_params( $callback, $args ); + if ( is_wp_error( $params ) ) { + return $params; + } + + return call_user_func_array( $callback, $params ); + } + } + + return new WP_Error( 'woocommerce_api_no_route', __( 'No route was found matching the URL and request method', 'woocommerce' ), array( 'status' => 404 ) ); + } + + /** + * Sort parameters by order specified in method declaration + * + * Takes a callback and a list of available params, then filters and sorts + * by the parameters the method actually needs, using the Reflection API + * + * @since 2.1 + * + * @param callable|array $callback the endpoint callback + * @param array $provided the provided request parameters + * + * @return array|WP_Error + */ + protected function sort_callback_params( $callback, $provided ) { + if ( is_array( $callback ) ) { + $ref_func = new ReflectionMethod( $callback[0], $callback[1] ); + } else { + $ref_func = new ReflectionFunction( $callback ); + } + + $wanted = $ref_func->getParameters(); + $ordered_parameters = array(); + + foreach ( $wanted as $param ) { + if ( isset( $provided[ $param->getName() ] ) ) { + // We have this parameters in the list to choose from + $ordered_parameters[] = is_array( $provided[ $param->getName() ] ) ? array_map( 'urldecode', $provided[ $param->getName() ] ) : urldecode( $provided[ $param->getName() ] ); + } elseif ( $param->isDefaultValueAvailable() ) { + // We don't have this parameter, but it's optional + $ordered_parameters[] = $param->getDefaultValue(); + } else { + // We don't have this parameter and it wasn't optional, abort! + return new WP_Error( 'woocommerce_api_missing_callback_param', sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param->getName() ), array( 'status' => 400 ) ); + } + } + return $ordered_parameters; + } + + /** + * Get the site index. + * + * This endpoint describes the capabilities of the site. + * + * @since 2.1 + * @return array Index entity + */ + public function get_index() { + + // General site data + $available = array( + 'store' => array( + 'name' => get_option( 'blogname' ), + 'description' => get_option( 'blogdescription' ), + 'URL' => get_option( 'siteurl' ), + 'wc_version' => WC()->version, + 'routes' => array(), + 'meta' => array( + 'timezone' => wc_timezone_string(), + 'currency' => get_woocommerce_currency(), + 'currency_format' => get_woocommerce_currency_symbol(), + 'tax_included' => wc_prices_include_tax(), + 'weight_unit' => get_option( 'woocommerce_weight_unit' ), + 'dimension_unit' => get_option( 'woocommerce_dimension_unit' ), + 'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ), + 'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ), + 'links' => array( + 'help' => 'https://woocommerce.github.io/woocommerce/rest-api/', + ), + ), + ), + ); + + // Find the available routes + foreach ( $this->get_routes() as $route => $callbacks ) { + $data = array(); + + $route = preg_replace( '#\(\?P(<\w+?>).*?\)#', '$1', $route ); + $methods = array(); + foreach ( self::$method_map as $name => $bitmask ) { + foreach ( $callbacks as $callback ) { + // Skip to the next route if any callback is hidden + if ( $callback[1] & self::HIDDEN_ENDPOINT ) { + continue 3; + } + + if ( $callback[1] & $bitmask ) { + $data['supports'][] = $name; + } + + if ( $callback[1] & self::ACCEPT_DATA ) { + $data['accepts_data'] = true; + } + + // For non-variable routes, generate links + if ( strpos( $route, '<' ) === false ) { + $data['meta'] = array( + 'self' => get_woocommerce_api_url( $route ), + ); + } + } + } + $available['store']['routes'][ $route ] = apply_filters( 'woocommerce_api_endpoints_description', $data ); + } + return apply_filters( 'woocommerce_api_index', $available ); + } + + /** + * Send a HTTP status code + * + * @since 2.1 + * @param int $code HTTP status + */ + public function send_status( $code ) { + status_header( $code ); + } + + /** + * Send a HTTP header + * + * @since 2.1 + * @param string $key Header key + * @param string $value Header value + * @param boolean $replace Should we replace the existing header? + */ + public function header( $key, $value, $replace = true ) { + header( sprintf( '%s: %s', $key, $value ), $replace ); + } + + /** + * Send a Link header + * + * @internal The $rel parameter is first, as this looks nicer when sending multiple + * + * @link http://tools.ietf.org/html/rfc5988 + * @link http://www.iana.org/assignments/link-relations/link-relations.xml + * + * @since 2.1 + * @param string $rel Link relation. Either a registered type, or an absolute URL + * @param string $link Target IRI for the link + * @param array $other Other parameters to send, as an associative array + */ + public function link_header( $rel, $link, $other = array() ) { + + $header = sprintf( '<%s>; rel="%s"', $link, esc_attr( $rel ) ); + + foreach ( $other as $key => $value ) { + + if ( 'title' == $key ) { + + $value = '"' . $value . '"'; + } + + $header .= '; ' . $key . '=' . $value; + } + + $this->header( 'Link', $header, false ); + } + + /** + * Send pagination headers for resources + * + * @since 2.1 + * @param WP_Query|WP_User_Query $query + */ + public function add_pagination_headers( $query ) { + + // WP_User_Query + if ( is_a( $query, 'WP_User_Query' ) ) { + + $page = $query->page; + $single = count( $query->get_results() ) == 1; + $total = $query->get_total(); + $total_pages = $query->total_pages; + + // WP_Query + } else { + + $page = $query->get( 'paged' ); + $single = $query->is_single(); + $total = $query->found_posts; + $total_pages = $query->max_num_pages; + } + + if ( ! $page ) { + $page = 1; + } + + $next_page = absint( $page ) + 1; + + if ( ! $single ) { + + // first/prev + if ( $page > 1 ) { + $this->link_header( 'first', $this->get_paginated_url( 1 ) ); + $this->link_header( 'prev', $this->get_paginated_url( $page -1 ) ); + } + + // next + if ( $next_page <= $total_pages ) { + $this->link_header( 'next', $this->get_paginated_url( $next_page ) ); + } + + // last + if ( $page != $total_pages ) { + $this->link_header( 'last', $this->get_paginated_url( $total_pages ) ); + } + } + + $this->header( 'X-WC-Total', $total ); + $this->header( 'X-WC-TotalPages', $total_pages ); + + do_action( 'woocommerce_api_pagination_headers', $this, $query ); + } + + /** + * Returns the request URL with the page query parameter set to the specified page + * + * @since 2.1 + * @param int $page + * @return string + */ + private function get_paginated_url( $page ) { + + // remove existing page query param + $request = remove_query_arg( 'page' ); + + // add provided page query param + $request = urldecode( add_query_arg( 'page', $page, $request ) ); + + // get the home host + $host = parse_url( get_home_url(), PHP_URL_HOST ); + + return set_url_scheme( "http://{$host}{$request}" ); + } + + /** + * Retrieve the raw request entity (body) + * + * @since 2.1 + * @return string + */ + public function get_raw_data() { + // @codingStandardsIgnoreStart + // $HTTP_RAW_POST_DATA is deprecated on PHP 5.6. + if ( function_exists( 'phpversion' ) && version_compare( phpversion(), '5.6', '>=' ) ) { + return file_get_contents( 'php://input' ); + } + + global $HTTP_RAW_POST_DATA; + + // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, + // but we can do it ourself. + if ( ! isset( $HTTP_RAW_POST_DATA ) ) { + $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); + } + + return $HTTP_RAW_POST_DATA; + // @codingStandardsIgnoreEnd + } + + /** + * Parse an RFC3339 datetime into a MySQl datetime + * + * Invalid dates default to unix epoch + * + * @since 2.1 + * @param string $datetime RFC3339 datetime + * @return string MySQl datetime (YYYY-MM-DD HH:MM:SS) + */ + public function parse_datetime( $datetime ) { + + // Strip millisecond precision (a full stop followed by one or more digits) + if ( strpos( $datetime, '.' ) !== false ) { + $datetime = preg_replace( '/\.\d+/', '', $datetime ); + } + + // default timezone to UTC + $datetime = preg_replace( '/[+-]\d+:+\d+$/', '+00:00', $datetime ); + + try { + + $datetime = new DateTime( $datetime, new DateTimeZone( 'UTC' ) ); + + } catch ( Exception $e ) { + + $datetime = new DateTime( '@0' ); + + } + + return $datetime->format( 'Y-m-d H:i:s' ); + } + + /** + * Format a unix timestamp or MySQL datetime into an RFC3339 datetime + * + * @since 2.1 + * @param int|string $timestamp unix timestamp or MySQL datetime + * @param bool $convert_to_utc + * @param bool $convert_to_gmt Use GMT timezone. + * @return string RFC3339 datetime + */ + public function format_datetime( $timestamp, $convert_to_utc = false, $convert_to_gmt = false ) { + if ( $convert_to_gmt ) { + if ( is_numeric( $timestamp ) ) { + $timestamp = date( 'Y-m-d H:i:s', $timestamp ); + } + + $timestamp = get_gmt_from_date( $timestamp ); + } + + if ( $convert_to_utc ) { + $timezone = new DateTimeZone( wc_timezone_string() ); + } else { + $timezone = new DateTimeZone( 'UTC' ); + } + + try { + + if ( is_numeric( $timestamp ) ) { + $date = new DateTime( "@{$timestamp}" ); + } else { + $date = new DateTime( $timestamp, $timezone ); + } + + // convert to UTC by adjusting the time based on the offset of the site's timezone + if ( $convert_to_utc ) { + $date->modify( -1 * $date->getOffset() . ' seconds' ); + } + } catch ( Exception $e ) { + + $date = new DateTime( '@0' ); + } + + return $date->format( 'Y-m-d\TH:i:s\Z' ); + } + + /** + * Extract headers from a PHP-style $_SERVER array + * + * @since 2.1 + * @param array $server Associative array similar to $_SERVER + * @return array Headers extracted from the input + */ + public function get_headers( $server ) { + $headers = array(); + // CONTENT_* headers are not prefixed with HTTP_ + $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true ); + + foreach ( $server as $key => $value ) { + if ( strpos( $key, 'HTTP_' ) === 0 ) { + $headers[ substr( $key, 5 ) ] = $value; + } elseif ( isset( $additional[ $key ] ) ) { + $headers[ $key ] = $value; + } + } + + return $headers; + } + + /** + * Check if the current request accepts a JSON response by checking the endpoint suffix (.json) or + * the HTTP ACCEPT header + * + * @since 2.1 + * @return bool + */ + private function is_json_request() { + + // check path + if ( false !== stripos( $this->path, '.json' ) ) { + return true; + } + + // check ACCEPT header, only 'application/json' is acceptable, see RFC 4627 + if ( isset( $this->headers['ACCEPT'] ) && 'application/json' == $this->headers['ACCEPT'] ) { + return true; + } + + return false; + } + + /** + * Check if the current request accepts an XML response by checking the endpoint suffix (.xml) or + * the HTTP ACCEPT header + * + * @since 2.1 + * @return bool + */ + private function is_xml_request() { + + // check path + if ( false !== stripos( $this->path, '.xml' ) ) { + return true; + } + + // check headers, 'application/xml' or 'text/xml' are acceptable, see RFC 2376 + if ( isset( $this->headers['ACCEPT'] ) && ( 'application/xml' == $this->headers['ACCEPT'] || 'text/xml' == $this->headers['ACCEPT'] ) ) { + return true; + } + + return false; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-xml-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-xml-handler.php new file mode 100644 index 0000000..04f47e6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/class-wc-api-xml-handler.php @@ -0,0 +1,308 @@ +xml = new XMLWriter(); + + $this->xml->openMemory(); + + $this->xml->setIndent( true ); + + $this->xml->startDocument( '1.0', 'UTF-8' ); + + $root_element = key( $data ); + + $data = $data[ $root_element ]; + + switch ( $root_element ) { + + case 'orders': + $data = array( 'order' => $data ); + break; + + case 'order_notes': + $data = array( 'order_note' => $data ); + break; + + case 'customers': + $data = array( 'customer' => $data ); + break; + + case 'coupons': + $data = array( 'coupon' => $data ); + break; + + case 'products': + $data = array( 'product' => $data ); + break; + + case 'product_reviews': + $data = array( 'product_review' => $data ); + break; + + default: + $data = apply_filters( 'woocommerce_api_xml_data', $data, $root_element ); + break; + } + + // generate xml starting with the root element and recursively generating child elements + $this->array_to_xml( $root_element, $data ); + + $this->xml->endDocument(); + + return $this->xml->outputMemory(); + } + + /** + * Convert array into XML by recursively generating child elements + * + * @since 2.1 + * @param string|array $element_key - name for element, e.g. + * @param string|array $element_value - value for element, e.g. 1234 + * @return string - generated XML + */ + private function array_to_xml( $element_key, $element_value = array() ) { + + if ( is_array( $element_value ) ) { + + // handle attributes + if ( '@attributes' === $element_key ) { + foreach ( $element_value as $attribute_key => $attribute_value ) { + + $this->xml->startAttribute( $attribute_key ); + $this->xml->text( $attribute_value ); + $this->xml->endAttribute(); + } + return; + } + + // handle multi-elements (e.g. multiple elements) + if ( is_numeric( key( $element_value ) ) ) { + + // recursively generate child elements + foreach ( $element_value as $child_element_key => $child_element_value ) { + + $this->xml->startElement( $element_key ); + + foreach ( $child_element_value as $sibling_element_key => $sibling_element_value ) { + $this->array_to_xml( $sibling_element_key, $sibling_element_value ); + } + + $this->xml->endElement(); + } + } else { + + // start root element + $this->xml->startElement( $element_key ); + + // recursively generate child elements + foreach ( $element_value as $child_element_key => $child_element_value ) { + $this->array_to_xml( $child_element_key, $child_element_value ); + } + + // end root element + $this->xml->endElement(); + } + } else { + + // handle single elements + if ( '@value' == $element_key ) { + + $this->xml->text( $element_value ); + + } else { + + // wrap element in CDATA tags if it contains illegal characters + if ( false !== strpos( $element_value, '<' ) || false !== strpos( $element_value, '>' ) ) { + + $this->xml->startElement( $element_key ); + $this->xml->writeCdata( $element_value ); + $this->xml->endElement(); + + } else { + + $this->xml->writeElement( $element_key, $element_value ); + } + } + + return; + } + } + + /** + * Adjust the sales report array format to change totals keyed with the sales date to become an + * attribute for the totals element instead + * + * @since 2.1 + * @param array $data + * @return array + */ + public function format_sales_report_data( $data ) { + + if ( ! empty( $data['totals'] ) ) { + + foreach ( $data['totals'] as $date => $totals ) { + + unset( $data['totals'][ $date ] ); + + $data['totals'][] = array_merge( array( '@attributes' => array( 'date' => $date ) ), $totals ); + } + } + + return $data; + } + + /** + * Adjust the product data to handle options for attributes without a named child element and other + * fields that have no named child elements (e.g. categories = array( 'cat1', 'cat2' ) ) + * + * Note that the parent product data for variations is also adjusted in the same manner as needed + * + * @since 2.1 + * @param array $data + * @return array + */ + public function format_product_data( $data ) { + + // handle attribute values + if ( ! empty( $data['attributes'] ) ) { + + foreach ( $data['attributes'] as $attribute_key => $attribute ) { + + if ( ! empty( $attribute['options'] ) && is_array( $attribute['options'] ) ) { + + foreach ( $attribute['options'] as $option_key => $option ) { + + unset( $data['attributes'][ $attribute_key ]['options'][ $option_key ] ); + + $data['attributes'][ $attribute_key ]['options']['option'][] = array( $option ); + } + } + } + } + + // simple arrays are fine for JSON, but XML requires a child element name, so this adjusts the data + // array to define a child element name for each field + $fields_to_fix = array( + 'related_ids' => 'related_id', + 'upsell_ids' => 'upsell_id', + 'cross_sell_ids' => 'cross_sell_id', + 'categories' => 'category', + 'tags' => 'tag', + ); + + foreach ( $fields_to_fix as $parent_field_name => $child_field_name ) { + + if ( ! empty( $data[ $parent_field_name ] ) ) { + + foreach ( $data[ $parent_field_name ] as $field_key => $field ) { + + unset( $data[ $parent_field_name ][ $field_key ] ); + + $data[ $parent_field_name ][ $child_field_name ][] = array( $field ); + } + } + } + + // handle adjusting the parent product for variations + if ( ! empty( $data['parent'] ) ) { + + // attributes + if ( ! empty( $data['parent']['attributes'] ) ) { + + foreach ( $data['parent']['attributes'] as $attribute_key => $attribute ) { + + if ( ! empty( $attribute['options'] ) && is_array( $attribute['options'] ) ) { + + foreach ( $attribute['options'] as $option_key => $option ) { + + unset( $data['parent']['attributes'][ $attribute_key ]['options'][ $option_key ] ); + + $data['parent']['attributes'][ $attribute_key ]['options']['option'][] = array( $option ); + } + } + } + } + + // fields + foreach ( $fields_to_fix as $parent_field_name => $child_field_name ) { + + if ( ! empty( $data['parent'][ $parent_field_name ] ) ) { + + foreach ( $data['parent'][ $parent_field_name ] as $field_key => $field ) { + + unset( $data['parent'][ $parent_field_name ][ $field_key ] ); + + $data['parent'][ $parent_field_name ][ $child_field_name ][] = array( $field ); + } + } + } + } + + return $data; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/interface-wc-api-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/interface-wc-api-handler.php new file mode 100644 index 0000000..464d9cb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v1/interface-wc-api-handler.php @@ -0,0 +1,48 @@ +api->server->path ) { + return new WP_User( 0 ); + } + + try { + + if ( is_ssl() ) { + $keys = $this->perform_ssl_authentication(); + } else { + $keys = $this->perform_oauth_authentication(); + } + + // Check API key-specific permission + $this->check_api_key_permissions( $keys['permissions'] ); + + $user = $this->get_user_by_id( $keys['user_id'] ); + + $this->update_api_key_last_access( $keys['key_id'] ); + + } catch ( Exception $e ) { + $user = new WP_Error( 'woocommerce_api_authentication_error', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + + return $user; + } + + /** + * SSL-encrypted requests are not subject to sniffing or man-in-the-middle + * attacks, so the request can be authenticated by simply looking up the user + * associated with the given consumer key and confirming the consumer secret + * provided is valid + * + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_ssl_authentication() { + + $params = WC()->api->server->params['GET']; + + // Get consumer key + if ( ! empty( $_SERVER['PHP_AUTH_USER'] ) ) { + + // Should be in HTTP Auth header by default + $consumer_key = $_SERVER['PHP_AUTH_USER']; + + } elseif ( ! empty( $params['consumer_key'] ) ) { + + // Allow a query string parameter as a fallback + $consumer_key = $params['consumer_key']; + + } else { + + throw new Exception( __( 'Consumer key is missing.', 'woocommerce' ), 404 ); + } + + // Get consumer secret + if ( ! empty( $_SERVER['PHP_AUTH_PW'] ) ) { + + // Should be in HTTP Auth header by default + $consumer_secret = $_SERVER['PHP_AUTH_PW']; + + } elseif ( ! empty( $params['consumer_secret'] ) ) { + + // Allow a query string parameter as a fallback + $consumer_secret = $params['consumer_secret']; + + } else { + + throw new Exception( __( 'Consumer secret is missing.', 'woocommerce' ), 404 ); + } + + $keys = $this->get_keys_by_consumer_key( $consumer_key ); + + if ( ! $this->is_consumer_secret_valid( $keys['consumer_secret'], $consumer_secret ) ) { + throw new Exception( __( 'Consumer secret is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + /** + * Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests + * + * This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP + * + * This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions: + * + * 1) There is no token associated with request/responses, only consumer keys/secrets are used + * + * 2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header, + * This is because there is no cross-OS function within PHP to get the raw Authorization header + * + * @link http://tools.ietf.org/html/rfc5849 for the full spec + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_oauth_authentication() { + + $params = WC()->api->server->params['GET']; + + $param_names = array( 'oauth_consumer_key', 'oauth_timestamp', 'oauth_nonce', 'oauth_signature', 'oauth_signature_method' ); + + // Check for required OAuth parameters + foreach ( $param_names as $param_name ) { + + if ( empty( $params[ $param_name ] ) ) { + throw new Exception( sprintf( __( '%s parameter is missing', 'woocommerce' ), $param_name ), 404 ); + } + } + + // Fetch WP user by consumer key + $keys = $this->get_keys_by_consumer_key( $params['oauth_consumer_key'] ); + + // Perform OAuth validation + $this->check_oauth_signature( $keys, $params ); + $this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] ); + + // Authentication successful, return user + return $keys; + } + + /** + * Return the keys for the given consumer key + * + * @since 2.4.0 + * @param string $consumer_key + * @return array + * @throws Exception + */ + private function get_keys_by_consumer_key( $consumer_key ) { + global $wpdb; + + $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) ); + + $keys = $wpdb->get_row( $wpdb->prepare( " + SELECT key_id, user_id, permissions, consumer_key, consumer_secret, nonces + FROM {$wpdb->prefix}woocommerce_api_keys + WHERE consumer_key = '%s' + ", $consumer_key ), ARRAY_A ); + + if ( empty( $keys ) ) { + throw new Exception( __( 'Consumer key is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + /** + * Get user by ID + * + * @since 2.4.0 + * @param int $user_id + * @return WP_User + * @throws Exception + */ + private function get_user_by_id( $user_id ) { + $user = get_user_by( 'id', $user_id ); + + if ( ! $user ) { + throw new Exception( __( 'API user is invalid', 'woocommerce' ), 401 ); + } + + return $user; + } + + /** + * Check if the consumer secret provided for the given user is valid + * + * @since 2.1 + * @param string $keys_consumer_secret + * @param string $consumer_secret + * @return bool + */ + private function is_consumer_secret_valid( $keys_consumer_secret, $consumer_secret ) { + return hash_equals( $keys_consumer_secret, $consumer_secret ); + } + + /** + * Verify that the consumer-provided request signature matches our generated signature, this ensures the consumer + * has a valid key/secret + * + * @param array $keys + * @param array $params the request parameters + * @throws Exception + */ + private function check_oauth_signature( $keys, $params ) { + + $http_method = strtoupper( WC()->api->server->method ); + + $base_request_uri = rawurlencode( untrailingslashit( get_woocommerce_api_url( '' ) ) . WC()->api->server->path ); + + // Get the signature provided by the consumer and remove it from the parameters prior to checking the signature + $consumer_signature = rawurldecode( str_replace( ' ', '+', $params['oauth_signature'] ) ); + unset( $params['oauth_signature'] ); + + // Remove filters and convert them from array to strings to void normalize issues + if ( isset( $params['filter'] ) ) { + $filters = $params['filter']; + unset( $params['filter'] ); + foreach ( $filters as $filter => $filter_value ) { + $params[ 'filter[' . $filter . ']' ] = $filter_value; + } + } + + // Normalize parameter key/values + $params = $this->normalize_parameters( $params ); + + // Sort parameters + if ( ! uksort( $params, 'strcmp' ) ) { + throw new Exception( __( 'Invalid signature - failed to sort parameters.', 'woocommerce' ), 401 ); + } + + // Form query string + $query_params = array(); + foreach ( $params as $param_key => $param_value ) { + + $query_params[] = $param_key . '%3D' . $param_value; // join with equals sign + } + $query_string = implode( '%26', $query_params ); // join with ampersand + + $string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string; + + if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) { + throw new Exception( __( 'Invalid signature - signature method is invalid.', 'woocommerce' ), 401 ); + } + + $hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) ); + + $signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $keys['consumer_secret'], true ) ); + + if ( ! hash_equals( $signature, $consumer_signature ) ) { + throw new Exception( __( 'Invalid signature - provided signature does not match.', 'woocommerce' ), 401 ); + } + } + + /** + * Normalize each parameter by assuming each parameter may have already been + * encoded, so attempt to decode, and then re-encode according to RFC 3986 + * + * Note both the key and value is normalized so a filter param like: + * + * 'filter[period]' => 'week' + * + * is encoded to: + * + * 'filter%5Bperiod%5D' => 'week' + * + * This conforms to the OAuth 1.0a spec which indicates the entire query string + * should be URL encoded + * + * @since 2.1 + * @see rawurlencode() + * @param array $parameters un-normalized parameters + * @return array normalized parameters + */ + private function normalize_parameters( $parameters ) { + + $normalized_parameters = array(); + + foreach ( $parameters as $key => $value ) { + + // Percent symbols (%) must be double-encoded + $key = str_replace( '%', '%25', rawurlencode( rawurldecode( $key ) ) ); + $value = str_replace( '%', '%25', rawurlencode( rawurldecode( $value ) ) ); + + $normalized_parameters[ $key ] = $value; + } + + return $normalized_parameters; + } + + /** + * Verify that the timestamp and nonce provided with the request are valid. This prevents replay attacks where + * an attacker could attempt to re-send an intercepted request at a later time. + * + * - A timestamp is valid if it is within 15 minutes of now + * - A nonce is valid if it has not been used within the last 15 minutes + * + * @param array $keys + * @param int $timestamp the unix timestamp for when the request was made + * @param string $nonce a unique (for the given user) 32 alphanumeric string, consumer-generated + * @throws Exception + */ + private function check_oauth_timestamp_and_nonce( $keys, $timestamp, $nonce ) { + global $wpdb; + + $valid_window = 15 * 60; // 15 minute window + + if ( ( $timestamp < time() - $valid_window ) || ( $timestamp > time() + $valid_window ) ) { + throw new Exception( __( 'Invalid timestamp.', 'woocommerce' ), 401 ); + } + + $used_nonces = maybe_unserialize( $keys['nonces'] ); + + if ( empty( $used_nonces ) ) { + $used_nonces = array(); + } + + if ( in_array( $nonce, $used_nonces ) ) { + throw new Exception( __( 'Invalid nonce - nonce has already been used.', 'woocommerce' ), 401 ); + } + + $used_nonces[ $timestamp ] = $nonce; + + // Remove expired nonces + foreach ( $used_nonces as $nonce_timestamp => $nonce ) { + if ( $nonce_timestamp < ( time() - $valid_window ) ) { + unset( $used_nonces[ $nonce_timestamp ] ); + } + } + + $used_nonces = maybe_serialize( $used_nonces ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'nonces' => $used_nonces ), + array( 'key_id' => $keys['key_id'] ), + array( '%s' ), + array( '%d' ) + ); + } + + /** + * Check that the API keys provided have the proper key-specific permissions to either read or write API resources + * + * @param string $key_permissions + * @throws Exception if the permission check fails + */ + public function check_api_key_permissions( $key_permissions ) { + switch ( WC()->api->server->method ) { + + case 'HEAD': + case 'GET': + if ( 'read' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have read permissions.', 'woocommerce' ), 401 ); + } + break; + + case 'POST': + case 'PUT': + case 'PATCH': + case 'DELETE': + if ( 'write' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have write permissions.', 'woocommerce' ), 401 ); + } + break; + } + } + + /** + * Updated API Key last access datetime + * + * @since 2.4.0 + * + * @param int $key_id + */ + private function update_api_key_last_access( $key_id ) { + global $wpdb; + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'last_access' => current_time( 'mysql' ) ), + array( 'key_id' => $key_id ), + array( '%s' ), + array( '%d' ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-coupons.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-coupons.php new file mode 100644 index 0000000..ca57fb4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-coupons.php @@ -0,0 +1,575 @@ + + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /coupons + $routes[ $this->base ] = array( + array( array( $this, 'get_coupons' ), WC_API_Server::READABLE ), + array( array( $this, 'create_coupon' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /coupons/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_coupons_count' ), WC_API_Server::READABLE ), + ); + + # GET/PUT/DELETE /coupons/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_coupon' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_coupon' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_coupon' ), WC_API_SERVER::DELETABLE ), + ); + + # GET /coupons/code/, note that coupon codes can contain spaces, dashes and underscores + $routes[ $this->base . '/code/(?P\w[\w\s\-]*)' ] = array( + array( array( $this, 'get_coupon_by_code' ), WC_API_Server::READABLE ), + ); + + # POST|PUT /coupons/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all coupons + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_coupons( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_coupons( $filter ); + + $coupons = array(); + + foreach ( $query->posts as $coupon_id ) { + + if ( ! $this->is_readable( $coupon_id ) ) { + continue; + } + + $coupons[] = current( $this->get_coupon( $coupon_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'coupons' => $coupons ); + } + + /** + * Get the coupon for the given ID + * + * @since 2.1 + * @param int $id the coupon ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_coupon( $id, $fields = null ) { + try { + + $id = $this->validate_request( $id, 'shop_coupon', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $coupon = new WC_Coupon( $id ); + + if ( 0 === $coupon->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_id', __( 'Invalid coupon ID', 'woocommerce' ), 404 ); + } + + $coupon_data = array( + 'id' => $coupon->get_id(), + 'code' => $coupon->get_code(), + 'type' => $coupon->get_discount_type(), + 'created_at' => $this->server->format_datetime( $coupon->get_date_created() ? $coupon->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $coupon->get_date_modified() ? $coupon->get_date_modified()->getTimestamp() : 0 ), // API gives UTC times. + 'amount' => wc_format_decimal( $coupon->get_amount(), 2 ), + 'individual_use' => $coupon->get_individual_use(), + 'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ), + 'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ), + 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, + 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, + 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), + 'usage_count' => (int) $coupon->get_usage_count(), + 'expiry_date' => $coupon->get_date_expires() ? $this->server->format_datetime( $coupon->get_date_expires()->getTimestamp() ) : null, // API gives UTC times. + 'enable_free_shipping' => $coupon->get_free_shipping(), + 'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ), + 'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ), + 'exclude_sale_items' => $coupon->get_exclude_sale_items(), + 'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ), + 'maximum_amount' => wc_format_decimal( $coupon->get_maximum_amount(), 2 ), + 'customer_emails' => $coupon->get_email_restrictions(), + 'description' => $coupon->get_description(), + ); + + return array( 'coupon' => apply_filters( 'woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of coupons + * + * @since 2.1 + * + * @param array $filter + * + * @return array|WP_Error + */ + public function get_coupons_count( $filter = array() ) { + try { + if ( ! current_user_can( 'read_private_shop_coupons' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), 401 ); + } + + $query = $this->query_coupons( $filter ); + + return array( 'count' => (int) $query->found_posts ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the coupon for the given code + * + * @since 2.1 + * @param string $code the coupon code + * @param string $fields fields to include in response + * @return int|WP_Error + */ + public function get_coupon_by_code( $code, $fields = null ) { + global $wpdb; + + try { + $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1;", $code ) ); + + if ( is_null( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_code', __( 'Invalid coupon code', 'woocommerce' ), 404 ); + } + + return $this->get_coupon( $id, $fields ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a coupon + * + * @since 2.2 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_coupon( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['coupon'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'coupon' ), 400 ); + } + + $data = $data['coupon']; + + // Check user permission + if ( ! current_user_can( 'publish_shop_coupons' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_coupon', __( 'You do not have permission to create coupons', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_coupon_data', $data, $this ); + + // Check if coupon code is specified + if ( ! isset( $data['code'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_code', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'code' ), 400 ); + } + + $coupon_code = wc_format_coupon_code( $data['code'] ); + $id_from_code = wc_get_coupon_id_by_code( $coupon_code ); + + if ( $id_from_code ) { + throw new WC_API_Exception( 'woocommerce_api_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), 400 ); + } + + $defaults = array( + 'type' => 'fixed_cart', + 'amount' => 0, + 'individual_use' => false, + 'product_ids' => array(), + 'exclude_product_ids' => array(), + 'usage_limit' => '', + 'usage_limit_per_user' => '', + 'limit_usage_to_x_items' => '', + 'usage_count' => '', + 'expiry_date' => '', + 'enable_free_shipping' => false, + 'product_category_ids' => array(), + 'exclude_product_category_ids' => array(), + 'exclude_sale_items' => false, + 'minimum_amount' => '', + 'maximum_amount' => '', + 'customer_emails' => array(), + 'description' => '', + ); + + $coupon_data = wp_parse_args( $data, $defaults ); + + // Validate coupon types + if ( ! in_array( wc_clean( $coupon_data['type'] ), array_keys( wc_get_coupon_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_type', sprintf( __( 'Invalid coupon type - the coupon type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_coupon_types() ) ) ), 400 ); + } + + $new_coupon = array( + 'post_title' => $coupon_code, + 'post_content' => '', + 'post_status' => 'publish', + 'post_author' => get_current_user_id(), + 'post_type' => 'shop_coupon', + 'post_excerpt' => $coupon_data['description'], + ); + + $id = wp_insert_post( $new_coupon, true ); + + if ( is_wp_error( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_coupon', $id->get_error_message(), 400 ); + } + + // Set coupon meta + update_post_meta( $id, 'discount_type', $coupon_data['type'] ); + update_post_meta( $id, 'coupon_amount', wc_format_decimal( $coupon_data['amount'] ) ); + update_post_meta( $id, 'individual_use', ( true === $coupon_data['individual_use'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'product_ids', implode( ',', array_filter( array_map( 'intval', $coupon_data['product_ids'] ) ) ) ); + update_post_meta( $id, 'exclude_product_ids', implode( ',', array_filter( array_map( 'intval', $coupon_data['exclude_product_ids'] ) ) ) ); + update_post_meta( $id, 'usage_limit', absint( $coupon_data['usage_limit'] ) ); + update_post_meta( $id, 'usage_limit_per_user', absint( $coupon_data['usage_limit_per_user'] ) ); + update_post_meta( $id, 'limit_usage_to_x_items', absint( $coupon_data['limit_usage_to_x_items'] ) ); + update_post_meta( $id, 'usage_count', absint( $coupon_data['usage_count'] ) ); + update_post_meta( $id, 'expiry_date', $this->get_coupon_expiry_date( wc_clean( $coupon_data['expiry_date'] ) ) ); + update_post_meta( $id, 'date_expires', $this->get_coupon_expiry_date( wc_clean( $coupon_data['expiry_date'] ), true ) ); + update_post_meta( $id, 'free_shipping', ( true === $coupon_data['enable_free_shipping'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'product_categories', array_filter( array_map( 'intval', $coupon_data['product_category_ids'] ) ) ); + update_post_meta( $id, 'exclude_product_categories', array_filter( array_map( 'intval', $coupon_data['exclude_product_category_ids'] ) ) ); + update_post_meta( $id, 'exclude_sale_items', ( true === $coupon_data['exclude_sale_items'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'minimum_amount', wc_format_decimal( $coupon_data['minimum_amount'] ) ); + update_post_meta( $id, 'maximum_amount', wc_format_decimal( $coupon_data['maximum_amount'] ) ); + update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $coupon_data['customer_emails'] ) ) ); + + do_action( 'woocommerce_api_create_coupon', $id, $data ); + do_action( 'woocommerce_new_coupon', $id ); + + $this->server->send_status( 201 ); + + return $this->get_coupon( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a coupon + * + * @since 2.2 + * + * @param int $id the coupon ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_coupon( $id, $data ) { + + try { + if ( ! isset( $data['coupon'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'coupon' ), 400 ); + } + + $data = $data['coupon']; + + $id = $this->validate_request( $id, 'shop_coupon', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_coupon_data', $data, $id, $this ); + + if ( isset( $data['code'] ) ) { + global $wpdb; + + $coupon_code = wc_format_coupon_code( $data['code'] ); + $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); + + if ( $id_from_code ) { + throw new WC_API_Exception( 'woocommerce_api_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), 400 ); + } + + $updated = wp_update_post( array( 'ID' => intval( $id ), 'post_title' => $coupon_code ) ); + + if ( 0 === $updated ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_update_coupon', __( 'Failed to update coupon', 'woocommerce' ), 400 ); + } + } + + if ( isset( $data['description'] ) ) { + $updated = wp_update_post( array( 'ID' => intval( $id ), 'post_excerpt' => $data['description'] ) ); + + if ( 0 === $updated ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_update_coupon', __( 'Failed to update coupon', 'woocommerce' ), 400 ); + } + } + + if ( isset( $data['type'] ) ) { + // Validate coupon types + if ( ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_coupon_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_type', sprintf( __( 'Invalid coupon type - the coupon type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_coupon_types() ) ) ), 400 ); + } + update_post_meta( $id, 'discount_type', $data['type'] ); + } + + if ( isset( $data['amount'] ) ) { + update_post_meta( $id, 'coupon_amount', wc_format_decimal( $data['amount'] ) ); + } + + if ( isset( $data['individual_use'] ) ) { + update_post_meta( $id, 'individual_use', ( true === $data['individual_use'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['product_ids'] ) ) { + update_post_meta( $id, 'product_ids', implode( ',', array_filter( array_map( 'intval', $data['product_ids'] ) ) ) ); + } + + if ( isset( $data['exclude_product_ids'] ) ) { + update_post_meta( $id, 'exclude_product_ids', implode( ',', array_filter( array_map( 'intval', $data['exclude_product_ids'] ) ) ) ); + } + + if ( isset( $data['usage_limit'] ) ) { + update_post_meta( $id, 'usage_limit', absint( $data['usage_limit'] ) ); + } + + if ( isset( $data['usage_limit_per_user'] ) ) { + update_post_meta( $id, 'usage_limit_per_user', absint( $data['usage_limit_per_user'] ) ); + } + + if ( isset( $data['limit_usage_to_x_items'] ) ) { + update_post_meta( $id, 'limit_usage_to_x_items', absint( $data['limit_usage_to_x_items'] ) ); + } + + if ( isset( $data['usage_count'] ) ) { + update_post_meta( $id, 'usage_count', absint( $data['usage_count'] ) ); + } + + if ( isset( $data['expiry_date'] ) ) { + update_post_meta( $id, 'expiry_date', $this->get_coupon_expiry_date( wc_clean( $data['expiry_date'] ) ) ); + update_post_meta( $id, 'date_expires', $this->get_coupon_expiry_date( wc_clean( $data['expiry_date'] ), true ) ); + } + + if ( isset( $data['enable_free_shipping'] ) ) { + update_post_meta( $id, 'free_shipping', ( true === $data['enable_free_shipping'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['product_category_ids'] ) ) { + update_post_meta( $id, 'product_categories', array_filter( array_map( 'intval', $data['product_category_ids'] ) ) ); + } + + if ( isset( $data['exclude_product_category_ids'] ) ) { + update_post_meta( $id, 'exclude_product_categories', array_filter( array_map( 'intval', $data['exclude_product_category_ids'] ) ) ); + } + + if ( isset( $data['exclude_sale_items'] ) ) { + update_post_meta( $id, 'exclude_sale_items', ( true === $data['exclude_sale_items'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['minimum_amount'] ) ) { + update_post_meta( $id, 'minimum_amount', wc_format_decimal( $data['minimum_amount'] ) ); + } + + if ( isset( $data['maximum_amount'] ) ) { + update_post_meta( $id, 'maximum_amount', wc_format_decimal( $data['maximum_amount'] ) ); + } + + if ( isset( $data['customer_emails'] ) ) { + update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $data['customer_emails'] ) ) ); + } + + do_action( 'woocommerce_api_edit_coupon', $id, $data ); + do_action( 'woocommerce_update_coupon', $id ); + + return $this->get_coupon( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a coupon + * + * @since 2.2 + * @param int $id the coupon ID + * @param bool $force true to permanently delete coupon, false to move to trash + * @return array|WP_Error + */ + public function delete_coupon( $id, $force = false ) { + + $id = $this->validate_request( $id, 'shop_coupon', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_coupon', $id, $this ); + + return $this->delete( $id, 'shop_coupon', ( 'true' === $force ) ); + } + + /** + * expiry_date format + * + * @since 2.3.0 + * @param string $expiry_date + * @param bool $as_timestamp (default: false) + * @return string|int + */ + protected function get_coupon_expiry_date( $expiry_date, $as_timestamp = false ) { + if ( '' != $expiry_date ) { + if ( $as_timestamp ) { + return strtotime( $expiry_date ); + } + + return date( 'Y-m-d', strtotime( $expiry_date ) ); + } + + return ''; + } + + /** + * Helper method to get coupon post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_coupons( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'shop_coupon', + 'post_status' => 'publish', + ); + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Bulk update or insert coupons + * Accepts an array with coupons in the formats supported by + * WC_API_Coupons->create_coupon() and WC_API_Coupons->edit_coupon() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['coupons'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupons_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'coupons' ), 400 ); + } + + $data = $data['coupons']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'coupons' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_coupons_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $coupons = array(); + + foreach ( $data as $_coupon ) { + $coupon_id = 0; + + // Try to get the coupon ID + if ( isset( $_coupon['id'] ) ) { + $coupon_id = intval( $_coupon['id'] ); + } + + // Coupon exists / edit coupon + if ( $coupon_id ) { + $edit = $this->edit_coupon( $coupon_id, array( 'coupon' => $_coupon ) ); + + if ( is_wp_error( $edit ) ) { + $coupons[] = array( + 'id' => $coupon_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $coupons[] = $edit['coupon']; + } + } else { + + // Coupon don't exists / create coupon + $new = $this->create_coupon( array( 'coupon' => $_coupon ) ); + + if ( is_wp_error( $new ) ) { + $coupons[] = array( + 'id' => $coupon_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $coupons[] = $new['coupon']; + } + } + } + + return array( 'coupons' => apply_filters( 'woocommerce_api_coupons_bulk_response', $coupons, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-customers.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-customers.php new file mode 100644 index 0000000..d88865b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-customers.php @@ -0,0 +1,837 @@ + + * GET /customers//orders + * + * @since 2.2 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /customers + $routes[ $this->base ] = array( + array( array( $this, 'get_customers' ), WC_API_SERVER::READABLE ), + array( array( $this, 'create_customer' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /customers/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_customers_count' ), WC_API_SERVER::READABLE ), + ); + + # GET/PUT/DELETE /customers/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_customer' ), WC_API_SERVER::READABLE ), + array( array( $this, 'edit_customer' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_customer' ), WC_API_SERVER::DELETABLE ), + ); + + # GET /customers/email/ + $routes[ $this->base . '/email/(?P.+)' ] = array( + array( array( $this, 'get_customer_by_email' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers//orders + $routes[ $this->base . '/(?P\d+)/orders' ] = array( + array( array( $this, 'get_customer_orders' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers//downloads + $routes[ $this->base . '/(?P\d+)/downloads' ] = array( + array( array( $this, 'get_customer_downloads' ), WC_API_SERVER::READABLE ), + ); + + # POST|PUT /customers/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all customers + * + * @since 2.1 + * @param array $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_customers( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_customers( $filter ); + + $customers = array(); + + foreach ( $query->get_results() as $user_id ) { + + if ( ! $this->is_readable( $user_id ) ) { + continue; + } + + $customers[] = current( $this->get_customer( $user_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'customers' => $customers ); + } + + /** + * Get the customer for the given ID + * + * @since 2.1 + * @param int $id the customer ID + * @param array $fields + * @return array|WP_Error + */ + public function get_customer( $id, $fields = null ) { + global $wpdb; + + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $customer = new WC_Customer( $id ); + $last_order = $customer->get_last_order(); + $customer_data = array( + 'id' => $customer->get_id(), + 'created_at' => $this->server->format_datetime( $customer->get_date_created() ? $customer->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'email' => $customer->get_email(), + 'first_name' => $customer->get_first_name(), + 'last_name' => $customer->get_last_name(), + 'username' => $customer->get_username(), + 'role' => $customer->get_role(), + 'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null, + 'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->get_date_created() ? $last_order->get_date_created()->getTimestamp() : 0 ) : null, // API gives UTC times. + 'orders_count' => $customer->get_order_count(), + 'total_spent' => wc_format_decimal( $customer->get_total_spent(), 2 ), + 'avatar_url' => $customer->get_avatar_url(), + 'billing_address' => array( + 'first_name' => $customer->get_billing_first_name(), + 'last_name' => $customer->get_billing_last_name(), + 'company' => $customer->get_billing_company(), + 'address_1' => $customer->get_billing_address_1(), + 'address_2' => $customer->get_billing_address_2(), + 'city' => $customer->get_billing_city(), + 'state' => $customer->get_billing_state(), + 'postcode' => $customer->get_billing_postcode(), + 'country' => $customer->get_billing_country(), + 'email' => $customer->get_billing_email(), + 'phone' => $customer->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $customer->get_shipping_first_name(), + 'last_name' => $customer->get_shipping_last_name(), + 'company' => $customer->get_shipping_company(), + 'address_1' => $customer->get_shipping_address_1(), + 'address_2' => $customer->get_shipping_address_2(), + 'city' => $customer->get_shipping_city(), + 'state' => $customer->get_shipping_state(), + 'postcode' => $customer->get_shipping_postcode(), + 'country' => $customer->get_shipping_country(), + ), + ); + + return array( 'customer' => apply_filters( 'woocommerce_api_customer_response', $customer_data, $customer, $fields, $this->server ) ); + } + + /** + * Get the customer for the given email + * + * @since 2.1 + * + * @param string $email the customer email + * @param array $fields + * + * @return array|WP_Error + */ + public function get_customer_by_email( $email, $fields = null ) { + try { + if ( is_email( $email ) ) { + $customer = get_user_by( 'email', $email ); + if ( ! is_object( $customer ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); + } + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); + } + + return $this->get_customer( $customer->ID, $fields ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of customers + * + * @since 2.1 + * + * @param array $filter + * + * @return array|WP_Error + */ + public function get_customers_count( $filter = array() ) { + try { + if ( ! current_user_can( 'list_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), 401 ); + } + + $query = $this->query_customers( $filter ); + + return array( 'count' => $query->get_total() ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get customer billing address fields. + * + * @since 2.2 + * @return array + */ + protected function get_customer_billing_address() { + $billing_address = apply_filters( 'woocommerce_api_customer_billing_address', array( + 'first_name', + 'last_name', + 'company', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + 'email', + 'phone', + ) ); + + return $billing_address; + } + + /** + * Get customer shipping address fields. + * + * @since 2.2 + * @return array + */ + protected function get_customer_shipping_address() { + $shipping_address = apply_filters( 'woocommerce_api_customer_shipping_address', array( + 'first_name', + 'last_name', + 'company', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + ) ); + + return $shipping_address; + } + + /** + * Add/Update customer data. + * + * @since 2.2 + * @param int $id the customer ID + * @param array $data + * @param WC_Customer $customer + */ + protected function update_customer_data( $id, $data, $customer ) { + + // Customer first name. + if ( isset( $data['first_name'] ) ) { + $customer->set_first_name( wc_clean( $data['first_name'] ) ); + } + + // Customer last name. + if ( isset( $data['last_name'] ) ) { + $customer->set_last_name( wc_clean( $data['last_name'] ) ); + } + + // Customer billing address. + if ( isset( $data['billing_address'] ) ) { + foreach ( $this->get_customer_billing_address() as $field ) { + if ( isset( $data['billing_address'][ $field ] ) ) { + if ( is_callable( array( $customer, "set_billing_{$field}" ) ) ) { + $customer->{"set_billing_{$field}"}( $data['billing_address'][ $field ] ); + } else { + $customer->update_meta_data( 'billing_' . $field, wc_clean( $data['billing_address'][ $field ] ) ); + } + } + } + } + + // Customer shipping address. + if ( isset( $data['shipping_address'] ) ) { + foreach ( $this->get_customer_shipping_address() as $field ) { + if ( isset( $data['shipping_address'][ $field ] ) ) { + if ( is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { + $customer->{"set_shipping_{$field}"}( $data['shipping_address'][ $field ] ); + } else { + $customer->update_meta_data( 'shipping_' . $field, wc_clean( $data['shipping_address'][ $field ] ) ); + } + } + } + } + + do_action( 'woocommerce_api_update_customer_data', $id, $data, $customer ); + } + + /** + * Create a customer + * + * @since 2.2 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_customer( $data ) { + try { + if ( ! isset( $data['customer'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'customer' ), 400 ); + } + + $data = $data['customer']; + + // Checks with can create new users. + if ( ! current_user_can( 'create_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_customer', __( 'You do not have permission to create this customer', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_customer_data', $data, $this ); + + // Checks with the email is missing. + if ( ! isset( $data['email'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_email', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'email' ), 400 ); + } + + // Create customer. + $customer = new WC_Customer; + $customer->set_username( ! empty( $data['username'] ) ? $data['username'] : '' ); + $customer->set_password( ! empty( $data['password'] ) ? $data['password'] : '' ); + $customer->set_email( $data['email'] ); + $customer->save(); + + if ( ! $customer->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_customer', __( 'This resource cannot be created.', 'woocommerce' ), 400 ); + } + + // Added customer data. + $this->update_customer_data( $customer->get_id(), $data, $customer ); + $customer->save(); + + do_action( 'woocommerce_api_create_customer', $customer->get_id(), $data ); + + $this->server->send_status( 201 ); + + return $this->get_customer( $customer->get_id() ); + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a customer + * + * @since 2.2 + * + * @param int $id the customer ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_customer( $id, $data ) { + try { + if ( ! isset( $data['customer'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'customer' ), 400 ); + } + + $data = $data['customer']; + + // Validate the customer ID. + $id = $this->validate_request( $id, 'customer', 'edit' ); + + // Return the validate error. + if ( is_wp_error( $id ) ) { + throw new WC_API_Exception( $id->get_error_code(), $id->get_error_message(), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_customer_data', $data, $this ); + + $customer = new WC_Customer( $id ); + + // Customer email. + if ( isset( $data['email'] ) ) { + $customer->set_email( $data['email'] ); + } + + // Customer password. + if ( isset( $data['password'] ) ) { + $customer->set_password( $data['password'] ); + } + + // Update customer data. + $this->update_customer_data( $customer->get_id(), $data, $customer ); + + $customer->save(); + + do_action( 'woocommerce_api_edit_customer', $customer->get_id(), $data ); + + return $this->get_customer( $customer->get_id() ); + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a customer + * + * @since 2.2 + * @param int $id the customer ID + * @return array|WP_Error + */ + public function delete_customer( $id ) { + + // Validate the customer ID. + $id = $this->validate_request( $id, 'customer', 'delete' ); + + // Return the validate error. + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_customer', $id, $this ); + + return $this->delete( $id, 'customer' ); + } + + /** + * Get the orders for a customer + * + * @since 2.1 + * @param int $id the customer ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_customer_orders( $id, $fields = null ) { + global $wpdb; + + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order_ids = wc_get_orders( array( + 'customer' => $id, + 'limit' => -1, + 'orderby' => 'date', + 'order' => 'ASC', + 'return' => 'ids', + ) ); + + if ( empty( $order_ids ) ) { + return array( 'orders' => array() ); + } + + $orders = array(); + + foreach ( $order_ids as $order_id ) { + $orders[] = current( WC()->api->WC_API_Orders->get_order( $order_id, $fields ) ); + } + + return array( 'orders' => apply_filters( 'woocommerce_api_customer_orders_response', $orders, $id, $fields, $order_ids, $this->server ) ); + } + + /** + * Get the available downloads for a customer + * + * @since 2.2 + * @param int $id the customer ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_customer_downloads( $id, $fields = null ) { + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $downloads = array(); + $_downloads = wc_get_customer_available_downloads( $id ); + + foreach ( $_downloads as $key => $download ) { + $downloads[] = array( + 'download_url' => $download['download_url'], + 'download_id' => $download['download_id'], + 'product_id' => $download['product_id'], + 'download_name' => $download['download_name'], + 'order_id' => $download['order_id'], + 'order_key' => $download['order_key'], + 'downloads_remaining' => $download['downloads_remaining'], + 'access_expires' => $download['access_expires'] ? $this->server->format_datetime( $download['access_expires'] ) : null, + 'file' => $download['file'], + ); + } + + return array( 'downloads' => apply_filters( 'woocommerce_api_customer_downloads_response', $downloads, $id, $fields, $this->server ) ); + } + + /** + * Helper method to get customer user objects + * + * Note that WP_User_Query does not have built-in pagination so limit & offset are used to provide limited + * pagination support + * + * The filter for role can only be a single role in a string. + * + * @since 2.3 + * @param array $args request arguments for filtering query + * @return WP_User_Query + */ + private function query_customers( $args = array() ) { + + // default users per page + $users_per_page = get_option( 'posts_per_page' ); + + // Set base query arguments + $query_args = array( + 'fields' => 'ID', + 'role' => 'customer', + 'orderby' => 'registered', + 'number' => $users_per_page, + ); + + // Custom Role + if ( ! empty( $args['role'] ) ) { + $query_args['role'] = $args['role']; + } + + // Search + if ( ! empty( $args['q'] ) ) { + $query_args['search'] = $args['q']; + } + + // Limit number of users returned + if ( ! empty( $args['limit'] ) ) { + if ( -1 == $args['limit'] ) { + unset( $query_args['number'] ); + } else { + $query_args['number'] = absint( $args['limit'] ); + $users_per_page = absint( $args['limit'] ); + } + } else { + $args['limit'] = $query_args['number']; + } + + // Page + $page = ( isset( $args['page'] ) ) ? absint( $args['page'] ) : 1; + + // Offset + if ( ! empty( $args['offset'] ) ) { + $query_args['offset'] = absint( $args['offset'] ); + } else { + $query_args['offset'] = $users_per_page * ( $page - 1 ); + } + + // Created date + if ( ! empty( $args['created_at_min'] ) ) { + $this->created_at_min = $this->server->parse_datetime( $args['created_at_min'] ); + } + + if ( ! empty( $args['created_at_max'] ) ) { + $this->created_at_max = $this->server->parse_datetime( $args['created_at_max'] ); + } + + // Order (ASC or DESC, ASC by default) + if ( ! empty( $args['order'] ) ) { + $query_args['order'] = $args['order']; + } + + // Order by + if ( ! empty( $args['orderby'] ) ) { + $query_args['orderby'] = $args['orderby']; + + // Allow sorting by meta value + if ( ! empty( $args['orderby_meta_key'] ) ) { + $query_args['meta_key'] = $args['orderby_meta_key']; + } + } + + $query = new WP_User_Query( $query_args ); + + // Helper members for pagination headers + $query->total_pages = ( -1 == $args['limit'] ) ? 1 : ceil( $query->get_total() / $users_per_page ); + $query->page = $page; + + return $query; + } + + /** + * Add customer data to orders + * + * @since 2.1 + * @param $order_data + * @param $order + * @return array + */ + public function add_customer_data( $order_data, $order ) { + + if ( 0 == $order->get_user_id() ) { + + // add customer data from order + $order_data['customer'] = array( + 'id' => 0, + 'email' => $order->get_billing_email(), + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + ); + + } else { + + $order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) ); + } + + return $order_data; + } + + /** + * Modify the WP_User_Query to support filtering on the date the customer was created + * + * @since 2.1 + * @param WP_User_Query $query + */ + public function modify_user_query( $query ) { + + if ( $this->created_at_min ) { + $query->query_where .= sprintf( " AND user_registered >= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%H:%%i:%%s' )", esc_sql( $this->created_at_min ) ); + } + + if ( $this->created_at_max ) { + $query->query_where .= sprintf( " AND user_registered <= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%H:%%i:%%s' )", esc_sql( $this->created_at_max ) ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid WP_User + * 3) the current user has the proper permissions + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * @param integer $id the customer ID + * @param string $type the request type, unused because this method overrides the parent class + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid user ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + try { + $id = absint( $id ); + + // validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Invalid customer ID', 'woocommerce' ), 404 ); + } + + // non-existent IDs return a valid WP_User object with the user ID = 0 + $customer = new WP_User( $id ); + + if ( 0 === $customer->ID ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer', __( 'Invalid customer', 'woocommerce' ), 404 ); + } + + // validate permissions + switch ( $context ) { + + case 'read': + if ( ! current_user_can( 'list_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_customer', __( 'You do not have permission to read this customer', 'woocommerce' ), 401 ); + } + break; + + case 'edit': + if ( ! current_user_can( 'edit_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_customer', __( 'You do not have permission to edit this customer', 'woocommerce' ), 401 ); + } + break; + + case 'delete': + if ( ! current_user_can( 'delete_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_customer', __( 'You do not have permission to delete this customer', 'woocommerce' ), 401 ); + } + break; + } + + return $id; + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Check if the current user can read users + * + * @since 2.1 + * @see WC_API_Resource::is_readable() + * @param int|WP_Post $post unused + * @return bool true if the current user can read users, false otherwise + */ + protected function is_readable( $post ) { + return current_user_can( 'list_users' ); + } + + /** + * Bulk update or insert customers + * Accepts an array with customers in the formats supported by + * WC_API_Customers->create_customer() and WC_API_Customers->edit_customer() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['customers'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customers_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'customers' ), 400 ); + } + + $data = $data['customers']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'customers' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_customers_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $customers = array(); + + foreach ( $data as $_customer ) { + $customer_id = 0; + + // Try to get the customer ID + if ( isset( $_customer['id'] ) ) { + $customer_id = intval( $_customer['id'] ); + } + + // Customer exists / edit customer + if ( $customer_id ) { + $edit = $this->edit_customer( $customer_id, array( 'customer' => $_customer ) ); + + if ( is_wp_error( $edit ) ) { + $customers[] = array( + 'id' => $customer_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $customers[] = $edit['customer']; + } + } else { + // Customer don't exists / create customer + $new = $this->create_customer( array( 'customer' => $_customer ) ); + + if ( is_wp_error( $new ) ) { + $customers[] = array( + 'id' => $customer_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $customers[] = $new['customer']; + } + } + } + + return array( 'customers' => apply_filters( 'woocommerce_api_customers_bulk_response', $customers, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-exception.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-exception.php new file mode 100644 index 0000000..834ed04 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-exception.php @@ -0,0 +1,48 @@ +error_code = $error_code; + parent::__construct( $error_message, $http_status_code ); + } + + /** + * Returns the error code + * + * @since 2.2 + * @return string + */ + public function getErrorCode() { + return $this->error_code; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-json-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-json-handler.php new file mode 100644 index 0000000..e19ac15 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-json-handler.php @@ -0,0 +1,78 @@ +api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ); + } + + // Check for invalid characters (only alphanumeric allowed) + if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) { + + WC()->api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ); + } + + // see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ + WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' ); + + // Prepend '/**/' to mitigate possible JSONP Flash attacks + return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')'; + } + + return json_encode( $data ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-orders.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-orders.php new file mode 100644 index 0000000..328f6b5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-orders.php @@ -0,0 +1,1836 @@ + + * GET /orders//notes + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET|POST /orders + $routes[ $this->base ] = array( + array( array( $this, 'get_orders' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /orders/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_orders_count' ), WC_API_Server::READABLE ), + ); + + # GET /orders/statuses + $routes[ $this->base . '/statuses' ] = array( + array( array( $this, 'get_order_statuses' ), WC_API_Server::READABLE ), + ); + + # GET|PUT|DELETE /orders/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_order' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order' ), WC_API_Server::DELETABLE ), + ); + + # GET|POST /orders//notes + $routes[ $this->base . '/(?P\d+)/notes' ] = array( + array( array( $this, 'get_order_notes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order_note' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET|PUT|DELETE /orders//notes/ + $routes[ $this->base . '/(?P\d+)/notes/(?P\d+)' ] = array( + array( array( $this, 'get_order_note' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order_note' ), WC_API_SERVER::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order_note' ), WC_API_SERVER::DELETABLE ), + ); + + # GET|POST /orders//refunds + $routes[ $this->base . '/(?P\d+)/refunds' ] = array( + array( array( $this, 'get_order_refunds' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order_refund' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET|PUT|DELETE /orders//refunds/ + $routes[ $this->base . '/(?P\d+)/refunds/(?P\d+)' ] = array( + array( array( $this, 'get_order_refund' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order_refund' ), WC_API_SERVER::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order_refund' ), WC_API_SERVER::DELETABLE ), + ); + + # POST|PUT /orders/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all orders + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param string $status + * @param int $page + * @return array + */ + public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $filter['page'] = $page; + + $query = $this->query_orders( $filter ); + + $orders = array(); + + foreach ( $query->posts as $order_id ) { + + if ( ! $this->is_readable( $order_id ) ) { + continue; + } + + $orders[] = current( $this->get_order( $order_id, $fields, $filter ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'orders' => $orders ); + } + + + /** + * Get the order for the given ID + * + * @since 2.1 + * @param int $id the order ID + * @param array $fields + * @param array $filter + * @return array|WP_Error + */ + public function get_order( $id, $fields = null, $filter = array() ) { + + // ensure order ID is valid & user has permission to read + $id = $this->validate_request( $id, $this->post_type, 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + // Get the decimal precession + $dp = ( isset( $filter['dp'] ) ? intval( $filter['dp'] ) : 2 ); + $order = wc_get_order( $id ); + $order_data = array( + 'id' => $order->get_id(), + 'order_number' => $order->get_order_number(), + 'created_at' => $this->server->format_datetime( $order->get_date_created() ? $order->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $order->get_date_modified() ? $order->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'completed_at' => $this->server->format_datetime( $order->get_date_completed() ? $order->get_date_completed()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'status' => $order->get_status(), + 'currency' => $order->get_currency(), + 'total' => wc_format_decimal( $order->get_total(), $dp ), + 'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ), + 'total_line_items_quantity' => $order->get_item_count(), + 'total_tax' => wc_format_decimal( $order->get_total_tax(), $dp ), + 'total_shipping' => wc_format_decimal( $order->get_shipping_total(), $dp ), + 'cart_tax' => wc_format_decimal( $order->get_cart_tax(), $dp ), + 'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), $dp ), + 'total_discount' => wc_format_decimal( $order->get_total_discount(), $dp ), + 'shipping_methods' => $order->get_shipping_method(), + 'payment_details' => array( + 'method_id' => $order->get_payment_method(), + 'method_title' => $order->get_payment_method_title(), + 'paid' => ! is_null( $order->get_date_paid() ), + ), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + 'note' => $order->get_customer_note(), + 'customer_ip' => $order->get_customer_ip_address(), + 'customer_user_agent' => $order->get_customer_user_agent(), + 'customer_id' => $order->get_user_id(), + 'view_order_url' => $order->get_view_order_url(), + 'line_items' => array(), + 'shipping_lines' => array(), + 'tax_lines' => array(), + 'fee_lines' => array(), + 'coupon_lines' => array(), + ); + + // add line items + foreach ( $order->get_items() as $item_id => $item ) { + $product = $item->get_product(); + $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; + $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + foreach ( $item_meta as $key => $values ) { + $item_meta[ $key ]->label = $values->display_key; + unset( $item_meta[ $key ]->display_key ); + unset( $item_meta[ $key ]->display_value ); + } + + $order_data['line_items'][] = array( + 'id' => $item_id, + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ), + 'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ), + 'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ), + 'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ), + 'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ), + 'quantity' => $item->get_quantity(), + 'tax_class' => $item->get_tax_class(), + 'name' => $item->get_name(), + 'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), + 'sku' => is_object( $product ) ? $product->get_sku() : null, + 'meta' => array_values( $item_meta ), + ); + } + + // add shipping + foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) { + $order_data['shipping_lines'][] = array( + 'id' => $shipping_item_id, + 'method_id' => $shipping_item->get_method_id(), + 'method_title' => $shipping_item->get_name(), + 'total' => wc_format_decimal( $shipping_item->get_total(), $dp ), + ); + } + + // add taxes + foreach ( $order->get_tax_totals() as $tax_code => $tax ) { + $order_data['tax_lines'][] = array( + 'id' => $tax->id, + 'rate_id' => $tax->rate_id, + 'code' => $tax_code, + 'title' => $tax->label, + 'total' => wc_format_decimal( $tax->amount, $dp ), + 'compound' => (bool) $tax->is_compound, + ); + } + + // add fees + foreach ( $order->get_fees() as $fee_item_id => $fee_item ) { + $order_data['fee_lines'][] = array( + 'id' => $fee_item_id, + 'title' => $fee_item->get_name(), + 'tax_class' => $fee_item->get_tax_class(), + 'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ), + ); + } + + // add coupons + foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) { + $order_data['coupon_lines'][] = array( + 'id' => $coupon_item_id, + 'code' => $coupon_item->get_code(), + 'amount' => wc_format_decimal( $coupon_item->get_discount(), $dp ), + ); + } + + return array( 'order' => apply_filters( 'woocommerce_api_order_response', $order_data, $order, $fields, $this->server ) ); + } + + /** + * Get the total number of orders + * + * @since 2.4 + * + * @param string $status + * @param array $filter + * + * @return array|WP_Error + */ + public function get_orders_count( $status = null, $filter = array() ) { + + try { + if ( ! current_user_can( 'read_private_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $status ) ) { + + if ( 'any' === $status ) { + + $order_statuses = array(); + + foreach ( wc_get_order_statuses() as $slug => $name ) { + $filter['status'] = str_replace( 'wc-', '', $slug ); + $query = $this->query_orders( $filter ); + $order_statuses[ str_replace( 'wc-', '', $slug ) ] = (int) $query->found_posts; + } + + return array( 'count' => $order_statuses ); + + } else { + $filter['status'] = $status; + } + } + + $query = $this->query_orders( $filter ); + + return array( 'count' => (int) $query->found_posts ); + + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a list of valid order statuses + * + * Note this requires no specific permissions other than being an authenticated + * API user. Order statuses (particularly custom statuses) could be considered + * private information which is why it's not in the API index. + * + * @since 2.1 + * @return array + */ + public function get_order_statuses() { + + $order_statuses = array(); + + foreach ( wc_get_order_statuses() as $slug => $name ) { + $order_statuses[ str_replace( 'wc-', '', $slug ) ] = $name; + } + + return array( 'order_statuses' => apply_filters( 'woocommerce_api_order_statuses_response', $order_statuses, $this ) ); + } + + /** + * Create an order + * + * @since 2.2 + * + * @param array $data raw order data + * + * @return array|WP_Error + */ + public function create_order( $data ) { + global $wpdb; + + wc_transaction_query( 'start' ); + + try { + if ( ! isset( $data['order'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order' ), 400 ); + } + + $data = $data['order']; + + // permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order', __( 'You do not have permission to create orders', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_order_data', $data, $this ); + + // default order args, note that status is checked for validity in wc_create_order() + $default_order_args = array( + 'status' => isset( $data['status'] ) ? $data['status'] : '', + 'customer_note' => isset( $data['note'] ) ? $data['note'] : null, + ); + + // if creating order for existing customer + if ( ! empty( $data['customer_id'] ) ) { + + // make sure customer exists + if ( false === get_user_by( 'id', $data['customer_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + $default_order_args['customer_id'] = $data['customer_id']; + } + + // create the pending order + $order = $this->create_base_order( $default_order_args, $data ); + + if ( is_wp_error( $order ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order', sprintf( __( 'Cannot create order: %s', 'woocommerce' ), implode( ', ', $order->get_error_messages() ) ), 400 ); + } + + // billing/shipping addresses + $this->set_order_addresses( $order, $data ); + + $lines = array( + 'line_item' => 'line_items', + 'shipping' => 'shipping_lines', + 'fee' => 'fee_lines', + 'coupon' => 'coupon_lines', + ); + + foreach ( $lines as $line_type => $line ) { + + if ( isset( $data[ $line ] ) && is_array( $data[ $line ] ) ) { + + $set_item = "set_{$line_type}"; + + foreach ( $data[ $line ] as $item ) { + + $this->$set_item( $order, $item, 'create' ); + } + } + } + + // calculate totals and set them + $order->calculate_totals(); + + // payment method (and payment_complete() if `paid` == true) + if ( isset( $data['payment_details'] ) && is_array( $data['payment_details'] ) ) { + + // method ID & title are required + if ( empty( $data['payment_details']['method_id'] ) || empty( $data['payment_details']['method_title'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_payment_details', __( 'Payment method ID and title are required', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] ); + update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] ); + + // mark as paid if set + if ( isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) { + $order->payment_complete( isset( $data['payment_details']['transaction_id'] ) ? $data['payment_details']['transaction_id'] : '' ); + } + } + + // set order currency + if ( isset( $data['currency'] ) ) { + + if ( ! array_key_exists( $data['currency'], get_woocommerce_currencies() ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_order_currency', $data['currency'] ); + } + + // set order meta + if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) { + $this->set_order_meta( $order->get_id(), $data['order_meta'] ); + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + wc_delete_shop_order_transients( $order ); + + do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this ); + do_action( 'woocommerce_new_order', $order->get_id() ); + + wc_transaction_query( 'commit' ); + + return $this->get_order( $order->get_id() ); + + } catch ( WC_Data_Exception $e ) { + wc_transaction_query( 'rollback' ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + wc_transaction_query( 'rollback' ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Creates new WC_Order. + * + * Requires a separate function for classes that extend WC_API_Orders. + * + * @since 2.3 + * + * @param $args array + * @param $data + * + * @return WC_Order + */ + protected function create_base_order( $args, $data ) { + return wc_create_order( $args ); + } + + /** + * Edit an order + * + * @since 2.2 + * + * @param int $id the order ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_order( $id, $data ) { + try { + if ( ! isset( $data['order'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order' ), 400 ); + } + + $data = $data['order']; + + $update_totals = false; + + $id = $this->validate_request( $id, $this->post_type, 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_order_data', $data, $id, $this ); + $order = wc_get_order( $id ); + + if ( empty( $order ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 ); + } + + $order_args = array( 'order_id' => $order->get_id() ); + + // Customer note. + if ( isset( $data['note'] ) ) { + $order_args['customer_note'] = $data['note']; + } + + // Customer ID. + if ( isset( $data['customer_id'] ) && $data['customer_id'] != $order->get_user_id() ) { + // Make sure customer exists. + if ( false === get_user_by( 'id', $data['customer_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_customer_user', $data['customer_id'] ); + } + + // Billing/shipping address. + $this->set_order_addresses( $order, $data ); + + $lines = array( + 'line_item' => 'line_items', + 'shipping' => 'shipping_lines', + 'fee' => 'fee_lines', + 'coupon' => 'coupon_lines', + ); + + foreach ( $lines as $line_type => $line ) { + + if ( isset( $data[ $line ] ) && is_array( $data[ $line ] ) ) { + + $update_totals = true; + + foreach ( $data[ $line ] as $item ) { + + // Item ID is always required. + if ( ! array_key_exists( 'id', $item ) ) { + $item['id'] = null; + } + + // Create item. + if ( is_null( $item['id'] ) ) { + $this->set_item( $order, $line_type, $item, 'create' ); + } elseif ( $this->item_is_null( $item ) ) { + // Delete item. + wc_delete_order_item( $item['id'] ); + } else { + // Update item. + $this->set_item( $order, $line_type, $item, 'update' ); + } + } + } + } + + // Payment method (and payment_complete() if `paid` == true and order needs payment). + if ( isset( $data['payment_details'] ) && is_array( $data['payment_details'] ) ) { + + // Method ID. + if ( isset( $data['payment_details']['method_id'] ) ) { + update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] ); + } + + // Method title. + if ( isset( $data['payment_details']['method_title'] ) ) { + update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] ); + } + + // Mark as paid if set. + if ( $order->needs_payment() && isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) { + $order->payment_complete( isset( $data['payment_details']['transaction_id'] ) ? $data['payment_details']['transaction_id'] : '' ); + } + } + + // Set order currency. + if ( isset( $data['currency'] ) ) { + if ( ! array_key_exists( $data['currency'], get_woocommerce_currencies() ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_order_currency', $data['currency'] ); + } + + // If items have changed, recalculate order totals. + if ( $update_totals ) { + $order->calculate_totals(); + } + + // Update order meta. + if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) { + $this->set_order_meta( $order->get_id(), $data['order_meta'] ); + } + + // Update the order post to set customer note/modified date. + wc_update_order( $order_args ); + + // Order status. + if ( ! empty( $data['status'] ) ) { + // Refresh the order instance. + $order = wc_get_order( $order->get_id() ); + $order->update_status( $data['status'], isset( $data['status_note'] ) ? $data['status_note'] : '', true ); + } + + wc_delete_shop_order_transients( $order ); + + do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this ); + do_action( 'woocommerce_update_order', $order->get_id() ); + + return $this->get_order( $id ); + + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete an order + * + * @param int $id the order ID + * @param bool $force true to permanently delete order, false to move to trash + * @return array|WP_Error + */ + public function delete_order( $id, $force = false ) { + + $id = $this->validate_request( $id, $this->post_type, 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + wc_delete_shop_order_transients( $id ); + + do_action( 'woocommerce_api_delete_order', $id, $this ); + + return $this->delete( $id, 'order', ( 'true' === $force ) ); + } + + /** + * Helper method to get order post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + protected function query_orders( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => $this->post_type, + 'post_status' => array_keys( wc_get_order_statuses() ), + ); + + // add status argument + if ( ! empty( $args['status'] ) ) { + + $statuses = 'wc-' . str_replace( ',', ',wc-', $args['status'] ); + $statuses = explode( ',', $statuses ); + $query_args['post_status'] = $statuses; + + unset( $args['status'] ); + + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Helper method to set/update the billing & shipping addresses for + * an order + * + * @since 2.1 + * @param \WC_Order $order + * @param array $data + */ + protected function set_order_addresses( $order, $data ) { + + $address_fields = array( + 'first_name', + 'last_name', + 'company', + 'email', + 'phone', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + ); + + $billing_address = $shipping_address = array(); + + // billing address + if ( isset( $data['billing_address'] ) && is_array( $data['billing_address'] ) ) { + + foreach ( $address_fields as $field ) { + + if ( isset( $data['billing_address'][ $field ] ) ) { + $billing_address[ $field ] = wc_clean( $data['billing_address'][ $field ] ); + } + } + + unset( $address_fields['email'] ); + unset( $address_fields['phone'] ); + } + + // shipping address + if ( isset( $data['shipping_address'] ) && is_array( $data['shipping_address'] ) ) { + + foreach ( $address_fields as $field ) { + + if ( isset( $data['shipping_address'][ $field ] ) ) { + $shipping_address[ $field ] = wc_clean( $data['shipping_address'][ $field ] ); + } + } + } + + $this->update_address( $order, $billing_address, 'billing' ); + $this->update_address( $order, $shipping_address, 'shipping' ); + + // update user meta + if ( $order->get_user_id() ) { + foreach ( $billing_address as $key => $value ) { + update_user_meta( $order->get_user_id(), 'billing_' . $key, $value ); + } + foreach ( $shipping_address as $key => $value ) { + update_user_meta( $order->get_user_id(), 'shipping_' . $key, $value ); + } + } + } + + /** + * Update address. + * + * @param WC_Order $order + * @param array $posted + * @param string $type + */ + protected function update_address( $order, $posted, $type = 'billing' ) { + foreach ( $posted as $key => $value ) { + if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) { + $order->{"set_{$type}_{$key}"}( $value ); + } + } + } + + /** + * Helper method to add/update order meta, with two restrictions: + * + * 1) Only non-protected meta (no leading underscore) can be set + * 2) Meta values must be scalar (int, string, bool) + * + * @since 2.2 + * @param int $order_id valid order ID + * @param array $order_meta order meta in array( 'meta_key' => 'meta_value' ) format + */ + protected function set_order_meta( $order_id, $order_meta ) { + + foreach ( $order_meta as $meta_key => $meta_value ) { + + if ( is_string( $meta_key ) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) { + update_post_meta( $order_id, $meta_key, $meta_value ); + } + } + } + + /** + * Helper method to check if the resource ID associated with the provided item is null + * + * Items can be deleted by setting the resource ID to null + * + * @since 2.2 + * @param array $item item provided in the request body + * @return bool true if the item resource ID is null, false otherwise + */ + protected function item_is_null( $item ) { + + $keys = array( 'product_id', 'method_id', 'title', 'code' ); + + foreach ( $keys as $key ) { + if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { + return true; + } + } + + return false; + } + + /** + * Wrapper method to create/update order items + * + * When updating, the item ID provided is checked to ensure it is associated + * with the order. + * + * @since 2.2 + * @param \WC_Order $order order + * @param string $item_type + * @param array $item item provided in the request body + * @param string $action either 'create' or 'update' + * @throws WC_API_Exception if item ID is not associated with order + */ + protected function set_item( $order, $item_type, $item, $action ) { + global $wpdb; + + $set_method = "set_{$item_type}"; + + // verify provided line item ID is associated with order + if ( 'update' === $action ) { + + $result = $wpdb->get_row( + $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d", + absint( $item['id'] ), + absint( $order->get_id() ) + ) ); + + if ( is_null( $result ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 ); + } + } + + $this->$set_method( $order, $item, $action ); + } + + /** + * Create or update a line item + * + * @since 2.2 + * @param \WC_Order $order + * @param array $item line item data + * @param string $action 'create' to add line item or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_line_item( $order, $item, $action ) { + $creating = ( 'create' === $action ); + + // product is always required + if ( ! isset( $item['product_id'] ) && ! isset( $item['sku'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_id', __( 'Product ID or SKU is required', 'woocommerce' ), 400 ); + } + + // when updating, ensure product ID provided matches + if ( 'update' === $action ) { + + $item_product_id = wc_get_order_item_meta( $item['id'], '_product_id' ); + $item_variation_id = wc_get_order_item_meta( $item['id'], '_variation_id' ); + + if ( $item['product_id'] != $item_product_id && $item['product_id'] != $item_variation_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_id', __( 'Product ID provided does not match this line item', 'woocommerce' ), 400 ); + } + } + + if ( isset( $item['product_id'] ) ) { + $product_id = $item['product_id']; + } elseif ( isset( $item['sku'] ) ) { + $product_id = wc_get_product_id_by_sku( $item['sku'] ); + } + + // variations must each have a key & value + $variation_id = 0; + if ( isset( $item['variations'] ) && is_array( $item['variations'] ) ) { + foreach ( $item['variations'] as $key => $value ) { + if ( ! $key || ! $value ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_variation', __( 'The product variation is invalid', 'woocommerce' ), 400 ); + } + } + $variation_id = $this->get_variation_id( wc_get_product( $product_id ), $item['variations'] ); + } + + $product = wc_get_product( $variation_id ? $variation_id : $product_id ); + + // must be a valid WC_Product + if ( ! is_object( $product ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product', __( 'Product is invalid.', 'woocommerce' ), 400 ); + } + + // quantity must be positive float + if ( isset( $item['quantity'] ) && floatval( $item['quantity'] ) <= 0 ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_quantity', __( 'Product quantity must be a positive float.', 'woocommerce' ), 400 ); + } + + // quantity is required when creating + if ( $creating && ! isset( $item['quantity'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_quantity', __( 'Product quantity is required.', 'woocommerce' ), 400 ); + } + + if ( $creating ) { + $line_item = new WC_Order_Item_Product(); + } else { + $line_item = new WC_Order_Item_Product( $item['id'] ); + } + + $line_item->set_product( $product ); + $line_item->set_order_id( $order->get_id() ); + + if ( isset( $item['quantity'] ) ) { + $line_item->set_quantity( $item['quantity'] ); + } + if ( isset( $item['total'] ) ) { + $line_item->set_total( floatval( $item['total'] ) ); + } elseif ( $creating ) { + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $line_item->get_quantity() ) ); + $line_item->set_total( $total ); + $line_item->set_subtotal( $total ); + } + if ( isset( $item['total_tax'] ) ) { + $line_item->set_total_tax( floatval( $item['total_tax'] ) ); + } + if ( isset( $item['subtotal'] ) ) { + $line_item->set_subtotal( floatval( $item['subtotal'] ) ); + } + if ( isset( $item['subtotal_tax'] ) ) { + $line_item->set_subtotal_tax( floatval( $item['subtotal_tax'] ) ); + } + if ( $variation_id ) { + $line_item->set_variation_id( $variation_id ); + $line_item->set_variation( $item['variations'] ); + } + + // Save or add to order. + if ( $creating ) { + $order->add_item( $line_item ); + } else { + $item_id = $line_item->save(); + + if ( ! $item_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Given a product ID & API provided variations, find the correct variation ID to use for calculation + * We can't just trust input from the API to pass a variation_id manually, otherwise you could pass + * the cheapest variation ID but provide other information so we have to look up the variation ID. + * + * @param WC_Product $product + * @param array $variations + * + * @return int returns an ID if a valid variation was found for this product + */ + function get_variation_id( $product, $variations = array() ) { + $variation_id = null; + $variations_normalized = array(); + + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + if ( isset( $variations ) && is_array( $variations ) ) { + // start by normalizing the passed variations + foreach ( $variations as $key => $value ) { + $key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); // from get_attributes in class-wc-api-products.php + $variations_normalized[ $key ] = strtolower( $value ); + } + // now search through each product child and see if our passed variations match anything + foreach ( $product->get_children() as $variation ) { + $meta = array(); + foreach ( get_post_meta( $variation ) as $key => $value ) { + $value = $value[0]; + $key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); + $meta[ $key ] = strtolower( $value ); + } + // if the variation array is a part of the $meta array, we found our match + if ( $this->array_contains( $variations_normalized, $meta ) ) { + $variation_id = $variation; + break; + } + } + } + } + + return $variation_id; + } + + /** + * Utility function to see if the meta array contains data from variations + * + * @param array $needles + * @param array $haystack + * + * @return bool + */ + protected function array_contains( $needles, $haystack ) { + foreach ( $needles as $key => $value ) { + if ( $haystack[ $key ] !== $value ) { + return false; + } + } + return true; + } + + /** + * Create or update an order shipping method + * + * @since 2.2 + * @param \WC_Order $order + * @param array $shipping item data + * @param string $action 'create' to add shipping or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_shipping( $order, $shipping, $action ) { + + // total must be a positive float + if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) { + throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 ); + } + + if ( 'create' === $action ) { + + // method ID is required + if ( ! isset( $shipping['method_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 ); + } + + $rate = new WC_Shipping_Rate( $shipping['method_id'], isset( $shipping['method_title'] ) ? $shipping['method_title'] : '', isset( $shipping['total'] ) ? floatval( $shipping['total'] ) : 0, array(), $shipping['method_id'] ); + $item = new WC_Order_Item_Shipping(); + $item->set_order_id( $order->get_id() ); + $item->set_shipping_rate( $rate ); + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Shipping( $shipping['id'] ); + + if ( isset( $shipping['method_id'] ) ) { + $item->set_method_id( $shipping['method_id'] ); + } + + if ( isset( $shipping['method_title'] ) ) { + $item->set_method_title( $shipping['method_title'] ); + } + + if ( isset( $shipping['total'] ) ) { + $item->set_total( floatval( $shipping['total'] ) ); + } + + $shipping_id = $item->save(); + + if ( ! $shipping_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_shipping', __( 'Cannot update shipping method, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Create or update an order fee + * + * @since 2.2 + * @param \WC_Order $order + * @param array $fee item data + * @param string $action 'create' to add fee or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_fee( $order, $fee, $action ) { + + if ( 'create' === $action ) { + + // fee title is required + if ( ! isset( $fee['title'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_fee_item', __( 'Fee title is required', 'woocommerce' ), 400 ); + } + + $item = new WC_Order_Item_Fee(); + $item->set_order_id( $order->get_id() ); + $item->set_name( wc_clean( $fee['title'] ) ); + $item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 ); + + // if taxable, tax class and total are required + if ( ! empty( $fee['taxable'] ) ) { + if ( ! isset( $fee['tax_class'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_fee_item', __( 'Fee tax class is required when fee is taxable.', 'woocommerce' ), 400 ); + } + + $item->set_tax_status( 'taxable' ); + $item->set_tax_class( $fee['tax_class'] ); + + if ( isset( $fee['total_tax'] ) ) { + $item->set_total_tax( isset( $fee['total_tax'] ) ? wc_format_refund_total( $fee['total_tax'] ) : 0 ); + } + + if ( isset( $fee['tax_data'] ) ) { + $item->set_total_tax( wc_format_refund_total( array_sum( $fee['tax_data'] ) ) ); + $item->set_taxes( array_map( 'wc_format_refund_total', $fee['tax_data'] ) ); + } + } + + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Fee( $fee['id'] ); + + if ( isset( $fee['title'] ) ) { + $item->set_name( wc_clean( $fee['title'] ) ); + } + + if ( isset( $fee['tax_class'] ) ) { + $item->set_tax_class( $fee['tax_class'] ); + } + + if ( isset( $fee['total'] ) ) { + $item->set_total( floatval( $fee['total'] ) ); + } + + if ( isset( $fee['total_tax'] ) ) { + $item->set_total_tax( floatval( $fee['total_tax'] ) ); + } + + $fee_id = $item->save(); + + if ( ! $fee_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_fee', __( 'Cannot update fee, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Create or update an order coupon + * + * @since 2.2 + * @param \WC_Order $order + * @param array $coupon item data + * @param string $action 'create' to add coupon or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_coupon( $order, $coupon, $action ) { + + // coupon amount must be positive float + if ( isset( $coupon['amount'] ) && floatval( $coupon['amount'] ) < 0 ) { + throw new WC_API_Exception( 'woocommerce_invalid_coupon_total', __( 'Coupon discount total must be a positive amount.', 'woocommerce' ), 400 ); + } + + if ( 'create' === $action ) { + + // coupon code is required + if ( empty( $coupon['code'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); + } + + $item = new WC_Order_Item_Coupon(); + $item->set_props( array( + 'code' => $coupon['code'], + 'discount' => isset( $coupon['amount'] ) ? floatval( $coupon['amount'] ) : 0, + 'discount_tax' => 0, + 'order_id' => $order->get_id(), + ) ); + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Coupon( $coupon['id'] ); + + if ( isset( $coupon['code'] ) ) { + $item->set_code( $coupon['code'] ); + } + + if ( isset( $coupon['amount'] ) ) { + $item->set_discount( floatval( $coupon['amount'] ) ); + } + + $coupon_id = $item->save(); + + if ( ! $coupon_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_order_coupon', __( 'Cannot update coupon, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Get the admin order notes for an order + * + * @since 2.1 + * @param string $order_id order ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_order_notes( $order_id, $fields = null ) { + + // ensure ID is valid order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $args = array( + 'post_id' => $order_id, + 'approve' => 'approve', + 'type' => 'order_note', + ); + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $notes = get_comments( $args ); + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $order_notes = array(); + + foreach ( $notes as $note ) { + + $order_notes[] = current( $this->get_order_note( $order_id, $note->comment_ID, $fields ) ); + } + + return array( 'order_notes' => apply_filters( 'woocommerce_api_order_notes_response', $order_notes, $order_id, $fields, $notes, $this->server ) ); + } + + /** + * Get an order note for the given order ID and ID + * + * @since 2.2 + * + * @param string $order_id order ID + * @param string $id order note ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_order_note( $order_id, $id, $fields = null ) { + try { + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $order_note = array( + 'id' => $note->comment_ID, + 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), + 'note' => $note->comment_content, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), + ); + + return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new order note for the given order + * + * @since 2.2 + * @param string $order_id order ID + * @param array $data raw request data + * @return WP_Error|array error or created note response data + */ + public function create_order_note( $order_id, $data ) { + try { + if ( ! isset( $data['order_note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_note' ), 400 ); + } + + $data = $data['order_note']; + + // permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order_note', __( 'You do not have permission to create order notes', 'woocommerce' ), 401 ); + } + + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $order = wc_get_order( $order_id ); + + $data = apply_filters( 'woocommerce_api_create_order_note_data', $data, $order_id, $this ); + + // note content is required + if ( ! isset( $data['note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note', __( 'Order note is required', 'woocommerce' ), 400 ); + } + + $is_customer_note = ( isset( $data['customer_note'] ) && true === $data['customer_note'] ); + + // create the note + $note_id = $order->add_order_note( $data['note'], $is_customer_note ); + + if ( ! $note_id ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce' ), 500 ); + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_order_note', $note_id, $order_id, $this ); + + return $this->get_order_note( $order->get_id(), $note_id ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit the order note + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id note ID + * @param array $data parsed request data + * @return WP_Error|array error or edited note response data + */ + public function edit_order_note( $order_id, $id, $data ) { + try { + if ( ! isset( $data['order_note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_note' ), 400 ); + } + + $data = $data['order_note']; + + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $order = wc_get_order( $order_id ); + + // Validate note ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + // Ensure note ID is valid + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + // Ensure note ID is associated with given order + if ( $note->comment_post_ID != $order->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->get_id(), $this ); + + // Note content + if ( isset( $data['note'] ) ) { + + wp_update_comment( + array( + 'comment_ID' => $note->comment_ID, + 'comment_content' => $data['note'], + ) + ); + } + + // Customer note + if ( isset( $data['customer_note'] ) ) { + + update_comment_meta( $note->comment_ID, 'is_customer_note', true === $data['customer_note'] ? 1 : 0 ); + } + + do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->get_id(), $this ); + + return $this->get_order_note( $order->get_id(), $note->comment_ID ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete order note + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id note ID + * @return WP_Error|array error or deleted message + */ + public function delete_order_note( $order_id, $id ) { + try { + $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate note ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + // Ensure note ID is valid + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + // Ensure note ID is associated with given order + if ( $note->comment_post_ID != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 ); + } + + // Force delete since trashed order notes could not be managed through comments list table + $result = wc_delete_order_note( $note->comment_ID ); + + if ( ! $result ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_order_note', __( 'This order note cannot be deleted', 'woocommerce' ), 500 ); + } + + do_action( 'woocommerce_api_delete_order_note', $note->comment_ID, $order_id, $this ); + + return array( 'message' => __( 'Permanently deleted order note', 'woocommerce' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the order refunds for an order + * + * @since 2.2 + * @param string $order_id order ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_order_refunds( $order_id, $fields = null ) { + + // Ensure ID is valid order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $refund_items = wc_get_orders( array( + 'type' => 'shop_order_refund', + 'parent' => $order_id, + 'limit' => -1, + 'return' => 'ids', + ) ); + $order_refunds = array(); + + foreach ( $refund_items as $refund_id ) { + $order_refunds[] = current( $this->get_order_refund( $order_id, $refund_id, $fields ) ); + } + + return array( 'order_refunds' => apply_filters( 'woocommerce_api_order_refunds_response', $order_refunds, $order_id, $fields, $refund_items, $this ) ); + } + + /** + * Get an order refund for the given order ID and ID + * + * @since 2.2 + * + * @param string $order_id order ID + * @param int $id + * @param string $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_order_refund( $order_id, $id, $fields = null ) { + try { + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + $order = wc_get_order( $order_id ); + $refund = wc_get_order( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + $line_items = array(); + + // Add line items + foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) { + $product = $item->get_product(); + $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; + $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + foreach ( $item_meta as $key => $values ) { + $item_meta[ $key ]->label = $values->display_key; + unset( $item_meta[ $key ]->display_key ); + unset( $item_meta[ $key ]->display_value ); + } + + $line_items[] = array( + 'id' => $item_id, + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ), + 'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ), + 'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ), + 'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ), + 'quantity' => $item->get_quantity(), + 'tax_class' => $item->get_tax_class(), + 'name' => $item->get_name(), + 'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), + 'sku' => is_object( $product ) ? $product->get_sku() : null, + 'meta' => array_values( $item_meta ), + 'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ), + ); + } + + $order_refund = array( + 'id' => $refund->get_id(), + 'created_at' => $this->server->format_datetime( $refund->get_date_created() ? $refund->get_date_created()->getTimestamp() : 0, false, false ), + 'amount' => wc_format_decimal( $refund->get_amount(), 2 ), + 'reason' => $refund->get_reason(), + 'line_items' => $line_items, + ); + + return array( 'order_refund' => apply_filters( 'woocommerce_api_order_refund_response', $order_refund, $id, $fields, $refund, $order_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new order refund for the given order + * + * @since 2.2 + * @param string $order_id order ID + * @param array $data raw request data + * @param bool $api_refund do refund using a payment gateway API + * @return WP_Error|array error or created refund response data + */ + public function create_order_refund( $order_id, $data, $api_refund = true ) { + try { + if ( ! isset( $data['order_refund'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_refund' ), 400 ); + } + + $data = $data['order_refund']; + + // Permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order_refund', __( 'You do not have permission to create order refunds', 'woocommerce' ), 401 ); + } + + $order_id = absint( $order_id ); + + if ( empty( $order_id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_create_order_refund_data', $data, $order_id, $this ); + + // Refund amount is required + if ( ! isset( $data['amount'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund', __( 'Refund amount is required.', 'woocommerce' ), 400 ); + } elseif ( 0 > $data['amount'] ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund', __( 'Refund amount must be positive.', 'woocommerce' ), 400 ); + } + + $data['order_id'] = $order_id; + $data['refund_id'] = 0; + + // Create the refund + $refund = wc_create_refund( $data ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 ); + } + + // Refund via API + if ( $api_refund ) { + if ( WC()->payment_gateways() ) { + $payment_gateways = WC()->payment_gateways->payment_gateways(); + } + + $order = wc_get_order( $order_id ); + + if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) { + $result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_amount(), $refund->get_reason() ); + + if ( is_wp_error( $result ) ) { + return $result; + } elseif ( ! $result ) { + throw new WC_API_Exception( 'woocommerce_api_create_order_refund_api_failed', __( 'An error occurred while attempting to create the refund using the payment gateway API.', 'woocommerce' ), 500 ); + } + } + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_order_refund', $refund->get_id(), $order_id, $this ); + + return $this->get_order_refund( $order_id, $refund->get_id() ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit an order refund + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id refund ID + * @param array $data parsed request data + * @return WP_Error|array error or edited refund response data + */ + public function edit_order_refund( $order_id, $id, $data ) { + try { + if ( ! isset( $data['order_refund'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_refund' ), 400 ); + } + + $data = $data['order_refund']; + + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate refund ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + // Ensure order ID is valid + $refund = get_post( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + // Ensure refund ID is associated with given order + if ( $refund->post_parent != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'The order refund ID provided is not associated with the order.', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_order_refund_data', $data, $refund->ID, $order_id, $this ); + + // Update reason + if ( isset( $data['reason'] ) ) { + $updated_refund = wp_update_post( array( 'ID' => $refund->ID, 'post_excerpt' => $data['reason'] ) ); + + if ( is_wp_error( $updated_refund ) ) { + return $updated_refund; + } + } + + // Update refund amount + if ( isset( $data['amount'] ) && 0 < $data['amount'] ) { + update_post_meta( $refund->ID, '_refund_amount', wc_format_decimal( $data['amount'] ) ); + } + + do_action( 'woocommerce_api_edit_order_refund', $refund->ID, $order_id, $this ); + + return $this->get_order_refund( $order_id, $refund->ID ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete order refund + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id refund ID + * @return WP_Error|array error or deleted message + */ + public function delete_order_refund( $order_id, $id ) { + try { + $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate refund ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + // Ensure refund ID is valid + $refund = get_post( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + // Ensure refund ID is associated with given order + if ( $refund->post_parent != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'The order refund ID provided is not associated with the order.', 'woocommerce' ), 400 ); + } + + wc_delete_shop_order_transients( $order_id ); + + do_action( 'woocommerce_api_delete_order_refund', $refund->ID, $order_id, $this ); + + return $this->delete( $refund->ID, 'refund', true ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Bulk update or insert orders + * Accepts an array with orders in the formats supported by + * WC_API_Orders->create_order() and WC_API_Orders->edit_order() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['orders'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_orders_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'orders' ), 400 ); + } + + $data = $data['orders']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'orders' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_orders_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $orders = array(); + + foreach ( $data as $_order ) { + $order_id = 0; + + // Try to get the order ID + if ( isset( $_order['id'] ) ) { + $order_id = intval( $_order['id'] ); + } + + // Order exists / edit order + if ( $order_id ) { + $edit = $this->edit_order( $order_id, array( 'order' => $_order ) ); + + if ( is_wp_error( $edit ) ) { + $orders[] = array( + 'id' => $order_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $orders[] = $edit['order']; + } + } else { + // Order don't exists / create order + $new = $this->create_order( array( 'order' => $_order ) ); + + if ( is_wp_error( $new ) ) { + $orders[] = array( + 'id' => $order_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $orders[] = $new['order']; + } + } + } + + return array( 'orders' => apply_filters( 'woocommerce_api_orders_bulk_response', $orders, $this ) ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-products.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-products.php new file mode 100644 index 0000000..59f07d4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-products.php @@ -0,0 +1,2361 @@ + + * GET /products//reviews + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /products + $routes[ $this->base ] = array( + array( array( $this, 'get_products' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /products/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_products_count' ), WC_API_Server::READABLE ), + ); + + # GET/PUT/DELETE /products/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_product' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product' ), WC_API_Server::DELETABLE ), + ); + + # GET /products//reviews + $routes[ $this->base . '/(?P\d+)/reviews' ] = array( + array( array( $this, 'get_product_reviews' ), WC_API_Server::READABLE ), + ); + + # GET /products//orders + $routes[ $this->base . '/(?P\d+)/orders' ] = array( + array( array( $this, 'get_product_orders' ), WC_API_Server::READABLE ), + ); + + # GET /products/categories + $routes[ $this->base . '/categories' ] = array( + array( array( $this, 'get_product_categories' ), WC_API_Server::READABLE ), + ); + + # GET /products/categories/ + $routes[ $this->base . '/categories/(?P\d+)' ] = array( + array( array( $this, 'get_product_category' ), WC_API_Server::READABLE ), + ); + + # GET/POST /products/attributes + $routes[ $this->base . '/attributes' ] = array( + array( array( $this, 'get_product_attributes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_attribute' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /attributes/ + $routes[ $this->base . '/attributes/(?P\d+)' ] = array( + array( array( $this, 'get_product_attribute' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_attribute' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_attribute' ), WC_API_Server::DELETABLE ), + ); + + # GET /products/sku/ + $routes[ $this->base . '/sku/(?P\w[\w\s\-]*)' ] = array( + array( array( $this, 'get_product_by_sku' ), WC_API_Server::READABLE ), + ); + + # POST|PUT /products/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all products + * + * @since 2.1 + * @param string $fields + * @param string $type + * @param array $filter + * @param int $page + * @return array + */ + public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) { + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + $filter['page'] = $page; + + $query = $this->query_products( $filter ); + + $products = array(); + + foreach ( $query->posts as $product_id ) { + + if ( ! $this->is_readable( $product_id ) ) { + continue; + } + + $products[] = current( $this->get_product( $product_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'products' => $products ); + } + + /** + * Get the product for the given ID + * + * @since 2.1 + * @param int $id the product ID + * @param string $fields + * @return array|WP_Error + */ + public function get_product( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + // add data that applies to every product type + $product_data = $this->get_product_data( $product ); + + // add variations to variable products + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + $product_data['variations'] = $this->get_variation_data( $product ); + } + + // add the parent product data to an individual variation + if ( $product->is_type( 'variation' ) && $product->get_parent_id() ) { + $_product = wc_get_product( $product->get_parent_id() ); + $product_data['parent'] = $this->get_product_data( $_product ); + } + + return array( 'product' => apply_filters( 'woocommerce_api_product_response', $product_data, $product, $fields, $this->server ) ); + } + + /** + * Get the total number of products + * + * @since 2.1 + * + * @param string $type + * @param array $filter + * + * @return array|WP_Error + */ + public function get_products_count( $type = null, $filter = array() ) { + try { + if ( ! current_user_can( 'read_private_products' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_products_count', __( 'You do not have permission to read the products count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + $query = $this->query_products( $filter ); + + return array( 'count' => (int) $query->found_posts ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product + * + * @since 2.2 + * + * @param array $data posted data + * + * @return array|WP_Error + */ + public function create_product( $data ) { + $id = 0; + + try { + if ( ! isset( $data['product'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product' ), 400 ); + } + + $data = $data['product']; + + // Check permissions + if ( ! current_user_can( 'publish_products' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product', __( 'You do not have permission to create products', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_product_data', $data, $this ); + + // Check if product title is specified + if ( ! isset( $data['title'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_title', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'title' ), 400 ); + } + + // Check product type + if ( ! isset( $data['type'] ) ) { + $data['type'] = 'simple'; + } + + // Set visible visibility when not sent + if ( ! isset( $data['catalog_visibility'] ) ) { + $data['catalog_visibility'] = 'visible'; + } + + // Validate the product type + if ( ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_product_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_type', sprintf( __( 'Invalid product type - the product type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_product_types() ) ) ), 400 ); + } + + // Enable description html tags. + $post_content = isset( $data['description'] ) ? wc_clean( $data['description'] ) : ''; + if ( $post_content && isset( $data['enable_html_description'] ) && true === $data['enable_html_description'] ) { + + $post_content = $data['description']; + } + + // Enable short description html tags. + $post_excerpt = isset( $data['short_description'] ) ? wc_clean( $data['short_description'] ) : ''; + if ( $post_excerpt && isset( $data['enable_html_short_description'] ) && true === $data['enable_html_short_description'] ) { + $post_excerpt = $data['short_description']; + } + + $classname = WC_Product_Factory::get_classname_from_product_type( $data['type'] ); + if ( ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + $product = new $classname(); + + $product->set_name( wc_clean( $data['title'] ) ); + $product->set_status( isset( $data['status'] ) ? wc_clean( $data['status'] ) : 'publish' ); + $product->set_short_description( isset( $data['short_description'] ) ? $post_excerpt : '' ); + $product->set_description( isset( $data['description'] ) ? $post_content : '' ); + + // Attempts to create the new product. + $product->save(); + $id = $product->get_id(); + + // Checks for an error in the product creation + if ( 0 >= $id ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product', $id->get_error_message(), 400 ); + } + + // Check for featured/gallery images, upload it and set it + if ( isset( $data['images'] ) ) { + $product = $this->save_product_images( $product, $data['images'] ); + } + + // Save product meta fields + $product = $this->save_product_meta( $product, $data ); + $product->save(); + + // Save variations + if ( isset( $data['type'] ) && 'variable' == $data['type'] && isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + $this->save_variations( $product, $data ); + } + + do_action( 'woocommerce_api_create_product', $id, $data ); + + // Clear cache/transients + wc_delete_product_transients( $id ); + + $this->server->send_status( 201 ); + + return $this->get_product( $id ); + } catch ( WC_Data_Exception $e ) { + $this->clear_product( $id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } catch ( WC_API_Exception $e ) { + $this->clear_product( $id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product + * + * @since 2.2 + * + * @param int $id the product ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_product( $id, $data ) { + try { + if ( ! isset( $data['product'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product' ), 400 ); + } + + $data = $data['product']; + + $id = $this->validate_request( $id, 'product', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + $data = apply_filters( 'woocommerce_api_edit_product_data', $data, $this ); + + // Product title. + if ( isset( $data['title'] ) ) { + $product->set_name( wc_clean( $data['title'] ) ); + } + + // Product name (slug). + if ( isset( $data['name'] ) ) { + $product->set_slug( wc_clean( $data['name'] ) ); + } + + // Product status. + if ( isset( $data['status'] ) ) { + $product->set_status( wc_clean( $data['status'] ) ); + } + + // Product short description. + if ( isset( $data['short_description'] ) ) { + // Enable short description html tags. + $post_excerpt = ( isset( $data['enable_html_short_description'] ) && true === $data['enable_html_short_description'] ) ? $data['short_description'] : wc_clean( $data['short_description'] ); + $product->set_short_description( $post_excerpt ); + } + + // Product description. + if ( isset( $data['description'] ) ) { + // Enable description html tags. + $post_content = ( isset( $data['enable_html_description'] ) && true === $data['enable_html_description'] ) ? $data['description'] : wc_clean( $data['description'] ); + $product->set_description( $post_content ); + } + + // Validate the product type. + if ( isset( $data['type'] ) && ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_product_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_type', sprintf( __( 'Invalid product type - the product type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_product_types() ) ) ), 400 ); + } + + // Check for featured/gallery images, upload it and set it. + if ( isset( $data['images'] ) ) { + $product = $this->save_product_images( $product, $data['images'] ); + } + + // Save product meta fields. + $product = $this->save_product_meta( $product, $data ); + + // Save variations. + if ( $product->is_type( 'variable' ) ) { + if ( isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + $this->save_variations( $product, $data ); + } else { + // Just sync variations. + $product = WC_Product_Variable::sync( $product, false ); + } + } + + $product->save(); + + do_action( 'woocommerce_api_edit_product', $id, $data ); + + // Clear cache/transients. + wc_delete_product_transients( $id ); + + return $this->get_product( $id ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product. + * + * @since 2.2 + * + * @param int $id the product ID. + * @param bool $force true to permanently delete order, false to move to trash. + * + * @return array|WP_Error + */ + public function delete_product( $id, $force = false ) { + + $id = $this->validate_request( $id, 'product', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + do_action( 'woocommerce_api_delete_product', $id, $this ); + + // If we're forcing, then delete permanently. + if ( $force ) { + if ( $product->is_type( 'variable' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->delete( true ); + } + } elseif ( $product->is_type( 'grouped' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->set_parent_id( 0 ); + $child->save(); + } + } + + $product->delete( true ); + $result = ! ( $product->get_id() > 0 ); + } else { + $product->delete(); + $result = 'trash' === $product->get_status(); + } + + if ( ! $result ) { + return new WP_Error( 'woocommerce_api_cannot_delete_product', sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), 'product' ), array( 'status' => 500 ) ); + } + + // Delete parent product transients. + if ( $parent_id = wp_get_post_parent_id( $id ) ) { + wc_delete_product_transients( $parent_id ); + } + + if ( $force ) { + return array( 'message' => sprintf( __( 'Permanently deleted %s', 'woocommerce' ), 'product' ) ); + } else { + $this->server->send_status( '202' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product' ) ); + } + } + + /** + * Get the reviews for a product + * + * @since 2.1 + * @param int $id the product ID to get reviews for + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_product_reviews( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $comments = get_approved_comments( $id ); + $reviews = array(); + + foreach ( $comments as $comment ) { + + $reviews[] = array( + 'id' => intval( $comment->comment_ID ), + 'created_at' => $this->server->format_datetime( $comment->comment_date_gmt ), + 'review' => $comment->comment_content, + 'rating' => get_comment_meta( $comment->comment_ID, 'rating', true ), + 'reviewer_name' => $comment->comment_author, + 'reviewer_email' => $comment->comment_author_email, + 'verified' => wc_review_is_from_verified_owner( $comment->comment_ID ), + ); + } + + return array( 'product_reviews' => apply_filters( 'woocommerce_api_product_reviews_response', $reviews, $id, $fields, $comments, $this->server ) ); + } + + /** + * Get the orders for a product + * + * @since 2.4.0 + * @param int $id the product ID to get orders for + * @param string fields fields to retrieve + * @param array $filter filters to include in response + * @param string $status the order status to retrieve + * @param $page $page page to retrieve + * @return array|WP_Error + */ + public function get_product_orders( $id, $fields = null, $filter = array(), $status = null, $page = 1 ) { + global $wpdb; + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order_ids = $wpdb->get_col( $wpdb->prepare( " + SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items + WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) + AND order_item_type = 'line_item' + ", $id ) ); + + if ( empty( $order_ids ) ) { + return array( 'orders' => array() ); + } + + $filter = array_merge( $filter, array( + 'in' => implode( ',', $order_ids ), + ) ); + + $orders = WC()->api->WC_API_Orders->get_orders( $fields, $filter, $status, $page ); + + return array( 'orders' => apply_filters( 'woocommerce_api_product_orders_response', $orders['orders'], $id, $filter, $fields, $this->server ) ); + } + + /** + * Get a listing of product categories + * + * @since 2.2 + * + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_categories( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_categories', __( 'You do not have permission to read product categories', 'woocommerce' ), 401 ); + } + + $product_categories = array(); + + $terms = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'ids' ) ); + + foreach ( $terms as $term_id ) { + $product_categories[] = current( $this->get_product_category( $term_id, $fields ) ); + } + + return array( 'product_categories' => apply_filters( 'woocommerce_api_product_categories_response', $product_categories, $terms, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product category for the given ID + * + * @since 2.2 + * + * @param string $id product category term ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_category( $id, $fields = null ) { + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_category_id', __( 'Invalid product category ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_categories', __( 'You do not have permission to read product categories', 'woocommerce' ), 401 ); + } + + $term = get_term( $id, 'product_cat' ); + + if ( is_wp_error( $term ) || is_null( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_category_id', __( 'A product category with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $term_id = intval( $term->term_id ); + + // Get category display type + $display_type = get_woocommerce_term_meta( $term_id, 'display_type' ); + + // Get category image + $image = ''; + if ( $image_id = get_woocommerce_term_meta( $term_id, 'thumbnail_id' ) ) { + $image = wp_get_attachment_url( $image_id ); + } + + $product_category = array( + 'id' => $term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'parent' => $term->parent, + 'description' => $term->description, + 'display' => $display_type ? $display_type : 'default', + 'image' => $image ? esc_url( $image ) : '', + 'count' => intval( $term->count ), + ); + + return array( 'product_category' => apply_filters( 'woocommerce_api_product_category_response', $product_category, $id, $fields, $term, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Helper method to get product post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_products( $args ) { + + // Set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'product', + 'post_status' => 'publish', + 'meta_query' => array(), + ); + + if ( ! empty( $args['type'] ) ) { + + $types = explode( ',', $args['type'] ); + + $query_args['tax_query'] = array( + array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $types, + ), + ); + + unset( $args['type'] ); + } + + // Filter products by category + if ( ! empty( $args['category'] ) ) { + $query_args['product_cat'] = $args['category']; + } + + // Filter by specific sku + if ( ! empty( $args['sku'] ) ) { + if ( ! is_array( $query_args['meta_query'] ) ) { + $query_args['meta_query'] = array(); + } + + $query_args['meta_query'][] = array( + 'key' => '_sku', + 'value' => $args['sku'], + 'compare' => '=', + ); + + $query_args['post_type'] = array( 'product', 'product_variation' ); + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Get standard product data that applies to every product type + * + * @since 2.1 + * @param WC_Product|int $product + * @return array + */ + private function get_product_data( $product ) { + if ( is_numeric( $product ) ) { + $product = wc_get_product( $product ); + } + + if ( ! is_a( $product, 'WC_Product' ) ) { + return array(); + } + + $prices_precision = wc_get_price_decimals(); + return array( + 'title' => $product->get_name(), + 'id' => $product->get_id(), + 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ), + 'type' => $product->get_type(), + 'status' => $product->get_status(), + 'downloadable' => $product->is_downloadable(), + 'virtual' => $product->is_virtual(), + 'permalink' => $product->get_permalink(), + 'sku' => $product->get_sku(), + 'price' => wc_format_decimal( $product->get_price(), $prices_precision ), + 'regular_price' => wc_format_decimal( $product->get_regular_price(), $prices_precision ), + 'sale_price' => $product->get_sale_price() ? wc_format_decimal( $product->get_sale_price(), $prices_precision ) : null, + 'price_html' => $product->get_price_html(), + 'taxable' => $product->is_taxable(), + 'tax_status' => $product->get_tax_status(), + 'tax_class' => $product->get_tax_class(), + 'managing_stock' => $product->managing_stock(), + 'stock_quantity' => $product->get_stock_quantity(), + 'in_stock' => $product->is_in_stock(), + 'backorders_allowed' => $product->backorders_allowed(), + 'backordered' => $product->is_on_backorder(), + 'sold_individually' => $product->is_sold_individually(), + 'purchaseable' => $product->is_purchasable(), + 'featured' => $product->is_featured(), + 'visible' => $product->is_visible(), + 'catalog_visibility' => $product->get_catalog_visibility(), + 'on_sale' => $product->is_on_sale(), + 'product_url' => $product->is_type( 'external' ) ? $product->get_product_url() : '', + 'button_text' => $product->is_type( 'external' ) ? $product->get_button_text() : '', + 'weight' => $product->get_weight() ? wc_format_decimal( $product->get_weight(), 2 ) : null, + 'dimensions' => array( + 'length' => $product->get_length(), + 'width' => $product->get_width(), + 'height' => $product->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_required' => $product->needs_shipping(), + 'shipping_taxable' => $product->is_shipping_taxable(), + 'shipping_class' => $product->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $product->get_shipping_class_id() ) ? $product->get_shipping_class_id() : null, + 'description' => wpautop( do_shortcode( $product->get_description() ) ), + 'short_description' => apply_filters( 'woocommerce_short_description', $product->get_short_description() ), + 'reviews_allowed' => $product->get_reviews_allowed(), + 'average_rating' => wc_format_decimal( $product->get_average_rating(), 2 ), + 'rating_count' => $product->get_rating_count(), + 'related_ids' => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ), + 'upsell_ids' => array_map( 'absint', $product->get_upsell_ids() ), + 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sell_ids() ), + 'parent_id' => $product->get_parent_id(), + 'categories' => wc_get_object_terms( $product->get_id(), 'product_cat', 'name' ), + 'tags' => wc_get_object_terms( $product->get_id(), 'product_tag', 'name' ), + 'images' => $this->get_images( $product ), + 'featured_src' => wp_get_attachment_url( get_post_thumbnail_id( $product->get_id() ) ), + 'attributes' => $this->get_attributes( $product ), + 'downloads' => $this->get_downloads( $product ), + 'download_limit' => $product->get_download_limit(), + 'download_expiry' => $product->get_download_expiry(), + 'download_type' => 'standard', + 'purchase_note' => wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ), + 'total_sales' => $product->get_total_sales(), + 'variations' => array(), + 'parent' => array(), + ); + } + + /** + * Get an individual variation's data + * + * @since 2.1 + * @param WC_Product $product + * @return array + */ + private function get_variation_data( $product ) { + $prices_precision = wc_get_price_decimals(); + $variations = array(); + + foreach ( $product->get_children() as $child_id ) { + + $variation = wc_get_product( $child_id ); + + if ( ! $variation || ! $variation->exists() ) { + continue; + } + + $variations[] = array( + 'id' => $variation->get_id(), + 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ), + 'downloadable' => $variation->is_downloadable(), + 'virtual' => $variation->is_virtual(), + 'permalink' => $variation->get_permalink(), + 'sku' => $variation->get_sku(), + 'price' => wc_format_decimal( $variation->get_price(), $prices_precision ), + 'regular_price' => wc_format_decimal( $variation->get_regular_price(), $prices_precision ), + 'sale_price' => $variation->get_sale_price() ? wc_format_decimal( $variation->get_sale_price(), $prices_precision ) : null, + 'taxable' => $variation->is_taxable(), + 'tax_status' => $variation->get_tax_status(), + 'tax_class' => $variation->get_tax_class(), + 'managing_stock' => $variation->managing_stock(), + 'stock_quantity' => (int) $variation->get_stock_quantity(), + 'in_stock' => $variation->is_in_stock(), + 'backordered' => $variation->is_on_backorder(), + 'purchaseable' => $variation->is_purchasable(), + 'visible' => $variation->variation_is_visible(), + 'on_sale' => $variation->is_on_sale(), + 'weight' => $variation->get_weight() ? wc_format_decimal( $variation->get_weight(), 2 ) : null, + 'dimensions' => array( + 'length' => $variation->get_length(), + 'width' => $variation->get_width(), + 'height' => $variation->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_class' => $variation->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null, + 'image' => $this->get_images( $variation ), + 'attributes' => $this->get_attributes( $variation ), + 'downloads' => $this->get_downloads( $variation ), + 'download_limit' => (int) $product->get_download_limit(), + 'download_expiry' => (int) $product->get_download_expiry(), + ); + } + + return $variations; + } + + /** + * Save default attributes. + * + * @since 3.0.0 + * @param WC_Product $product + * @param array $request + * @return WC_Product + */ + protected function save_default_attributes( $product, $request ) { + // Update default attributes options setting. + if ( isset( $request['default_attribute'] ) ) { + $request['default_attributes'] = $request['default_attribute']; + } + + if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) { + $attributes = $product->get_attributes(); + $default_attributes = array(); + + foreach ( $request['default_attributes'] as $default_attr_key => $default_attr ) { + if ( ! isset( $default_attr['name'] ) ) { + continue; + } + + $taxonomy = sanitize_title( $default_attr['name'] ); + + if ( isset( $default_attr['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $default_attr['slug'] ); + } + + if ( isset( $attributes[ $taxonomy ] ) ) { + $_attribute = $attributes[ $taxonomy ]; + + if ( $_attribute['is_variation'] ) { + $value = ''; + + if ( isset( $default_attr['option'] ) ) { + if ( $_attribute['is_taxonomy'] ) { + // Don't use wc_clean as it destroys sanitized characters. + $value = sanitize_title( trim( stripslashes( $default_attr['option'] ) ) ); + } else { + $value = wc_clean( trim( stripslashes( $default_attr['option'] ) ) ); + } + } + + if ( $value ) { + $default_attributes[ $taxonomy ] = $value; + } + } + } + } + + $product->set_default_attributes( $default_attributes ); + } + + return $product; + } + + /** + * Save product meta + * + * @since 2.2 + * @param WC_Product $product + * @param array $data + * @return WC_Product + * @throws WC_API_Exception + */ + protected function save_product_meta( $product, $data ) { + global $wpdb; + + // Virtual + if ( isset( $data['virtual'] ) ) { + $product->set_virtual( $data['virtual'] ); + } + + // Tax status + if ( isset( $data['tax_status'] ) ) { + $product->set_tax_status( wc_clean( $data['tax_status'] ) ); + } + + // Tax Class + if ( isset( $data['tax_class'] ) ) { + $product->set_tax_class( wc_clean( $data['tax_class'] ) ); + } + + // Catalog Visibility + if ( isset( $data['catalog_visibility'] ) ) { + $product->set_catalog_visibility( wc_clean( $data['catalog_visibility'] ) ); + } + + // Purchase Note + if ( isset( $data['purchase_note'] ) ) { + $product->set_purchase_note( wc_clean( $data['purchase_note'] ) ); + } + + // Featured Product + if ( isset( $data['featured'] ) ) { + $product->set_featured( $data['featured'] ); + } + + // Shipping data + $product = $this->save_product_shipping_data( $product, $data ); + + // SKU + if ( isset( $data['sku'] ) ) { + $sku = $product->get_sku(); + $new_sku = wc_clean( $data['sku'] ); + + if ( '' == $new_sku ) { + $product->set_sku( '' ); + } elseif ( $new_sku !== $sku ) { + if ( ! empty( $new_sku ) ) { + $unique_sku = wc_product_has_unique_sku( $product->get_id(), $new_sku ); + if ( ! $unique_sku ) { + throw new WC_API_Exception( 'woocommerce_api_product_sku_already_exists', __( 'The SKU already exists on another product.', 'woocommerce' ), 400 ); + } else { + $product->set_sku( $new_sku ); + } + } else { + $product->set_sku( '' ); + } + } + } + + // Attributes + if ( isset( $data['attributes'] ) ) { + $attributes = array(); + + foreach ( $data['attributes'] as $attribute ) { + $is_taxonomy = 0; + $taxonomy = 0; + + if ( ! isset( $attribute['name'] ) ) { + continue; + } + + $attribute_slug = sanitize_title( $attribute['name'] ); + + if ( isset( $attribute['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $attribute['slug'] ); + $attribute_slug = sanitize_title( $attribute['slug'] ); + } + + if ( $taxonomy ) { + $is_taxonomy = 1; + } + + if ( $is_taxonomy ) { + + $attribute_id = wc_attribute_taxonomy_id_by_name( $attribute['name'] ); + + if ( isset( $attribute['options'] ) ) { + $options = $attribute['options']; + + if ( ! is_array( $attribute['options'] ) ) { + // Text based attributes - Posted values are term names + $options = explode( WC_DELIMITER, $options ); + } + + $values = array_map( 'wc_sanitize_term_text_based', $options ); + $values = array_filter( $values, 'strlen' ); + } else { + $values = array(); + } + + // Update post terms + if ( taxonomy_exists( $taxonomy ) ) { + wp_set_object_terms( $product->get_id(), $values, $taxonomy ); + } + + if ( ! empty( $values ) ) { + // Add attribute to array, but don't set values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $taxonomy ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? absint( $attribute['position'] ) : 0 ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['options'] ) ) { + // Array based + if ( is_array( $attribute['options'] ) ) { + $values = $attribute['options']; + + // Text based, separate by pipe + } else { + $values = array_map( 'wc_clean', explode( WC_DELIMITER, $attribute['options'] ) ); + } + + // Custom attribute - Add attribute to array and set the values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute['name'] ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? absint( $attribute['position'] ) : 0 ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } + + uasort( $attributes, 'wc_product_attribute_uasort_comparison' ); + + $product->set_attributes( $attributes ); + } + + // Sales and prices. + if ( in_array( $product->get_type(), array( 'variable', 'grouped' ) ) ) { + + // Variable and grouped products have no prices. + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + $product->set_date_on_sale_to( '' ); + $product->set_date_on_sale_from( '' ); + $product->set_price( '' ); + + } else { + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $regular_price = ( '' === $data['regular_price'] ) ? '' : $data['regular_price']; + $product->set_regular_price( $regular_price ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $sale_price = ( '' === $data['sale_price'] ) ? '' : $data['sale_price']; + $product->set_sale_price( $sale_price ); + } + + if ( isset( $data['sale_price_dates_from'] ) ) { + $date_from = $data['sale_price_dates_from']; + } else { + $date_from = $product->get_date_on_sale_from() ? date( 'Y-m-d', $product->get_date_on_sale_from()->getTimestamp() ) : ''; + } + + if ( isset( $data['sale_price_dates_to'] ) ) { + $date_to = $data['sale_price_dates_to']; + } else { + $date_to = $product->get_date_on_sale_to() ? date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() ) : ''; + } + + if ( $date_to && ! $date_from ) { + $date_from = strtotime( 'NOW', current_time( 'timestamp', true ) ); + } + + $product->set_date_on_sale_to( $date_to ); + $product->set_date_on_sale_from( $date_from ); + + if ( $product->is_on_sale( 'edit' ) ) { + $product->set_price( $product->get_sale_price( 'edit' ) ); + } else { + $product->set_price( $product->get_regular_price( 'edit' ) ); + } + } + + // Product parent ID for groups + if ( isset( $data['parent_id'] ) ) { + $product->set_parent_id( absint( $data['parent_id'] ) ); + } + + // Sold Individually + if ( isset( $data['sold_individually'] ) ) { + $product->set_sold_individually( true === $data['sold_individually'] ? 'yes' : '' ); + } + + // Stock status + if ( isset( $data['in_stock'] ) ) { + $stock_status = ( true === $data['in_stock'] ) ? 'instock' : 'outofstock'; + } else { + $stock_status = $product->get_stock_status(); + + if ( '' === $stock_status ) { + $stock_status = 'instock'; + } + } + + // Stock Data + if ( 'yes' == get_option( 'woocommerce_manage_stock' ) ) { + // Manage stock + if ( isset( $data['managing_stock'] ) ) { + $managing_stock = ( true === $data['managing_stock'] ) ? 'yes' : 'no'; + $product->set_manage_stock( $managing_stock ); + } else { + $managing_stock = $product->get_manage_stock() ? 'yes' : 'no'; + } + + // Backorders + if ( isset( $data['backorders'] ) ) { + if ( 'notify' == $data['backorders'] ) { + $backorders = 'notify'; + } else { + $backorders = ( true === $data['backorders'] ) ? 'yes' : 'no'; + } + + $product->set_backorders( $backorders ); + } else { + $backorders = $product->get_backorders(); + } + + if ( $product->is_type( 'grouped' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } elseif ( $product->is_type( 'external' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( 'instock' ); + } elseif ( 'yes' == $managing_stock ) { + $product->set_backorders( $backorders ); + + // Stock status is always determined by children so sync later. + if ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Stock quantity + if ( isset( $data['stock_quantity'] ) ) { + $product->set_stock_quantity( wc_stock_amount( $data['stock_quantity'] ) ); + } + } else { + // Don't manage stock. + $product->set_manage_stock( 'no' ); + $product->set_backorders( $backorders ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } + } elseif ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Upsells + if ( isset( $data['upsell_ids'] ) ) { + $upsells = array(); + $ids = $data['upsell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $upsells[] = $id; + } + } + + $product->set_upsell_ids( $upsells ); + } else { + $product->set_upsell_ids( array() ); + } + } + + // Cross sells + if ( isset( $data['cross_sell_ids'] ) ) { + $crosssells = array(); + $ids = $data['cross_sell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $crosssells[] = $id; + } + } + + $product->set_cross_sell_ids( $crosssells ); + } else { + $product->set_cross_sell_ids( array() ); + } + } + + // Product categories + if ( isset( $data['categories'] ) && is_array( $data['categories'] ) ) { + $product->set_category_ids( $data['categories'] ); + } + + // Product tags + if ( isset( $data['tags'] ) && is_array( $data['tags'] ) ) { + $product->set_tag_ids( $data['tags'] ); + } + + // Downloadable + if ( isset( $data['downloadable'] ) ) { + $is_downloadable = ( true === $data['downloadable'] ) ? 'yes' : 'no'; + $product->set_downloadable( $is_downloadable ); + } else { + $is_downloadable = $product->get_downloadable() ? 'yes' : 'no'; + } + + // Downloadable options + if ( 'yes' == $is_downloadable ) { + + // Downloadable files + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $product = $this->save_downloadable_files( $product, $data['downloads'] ); + } + + // Download limit + if ( isset( $data['download_limit'] ) ) { + $product->set_download_limit( $data['download_limit'] ); + } + + // Download expiry + if ( isset( $data['download_expiry'] ) ) { + $product->set_download_expiry( $data['download_expiry'] ); + } + } + + // Product url + if ( $product->is_type( 'external' ) ) { + if ( isset( $data['product_url'] ) ) { + $product->set_product_url( $data['product_url'] ); + } + + if ( isset( $data['button_text'] ) ) { + $product->set_button_text( $data['button_text'] ); + } + } + + // Reviews allowed + if ( isset( $data['reviews_allowed'] ) ) { + $product->set_reviews_allowed( $data['reviews_allowed'] ); + } + + // Save default attributes for variable products. + if ( $product->is_type( 'variable' ) ) { + $product = $this->save_default_attributes( $product, $data ); + } + + // Do action for product type + do_action( 'woocommerce_api_process_product_meta_' . $product->get_type(), $product->get_id(), $data ); + + return $product; + } + + /** + * Save variations + * + * @since 2.2 + * @param WC_Product $product + * @param array $request + * + * @return true + * + * @throws WC_API_Exception + */ + protected function save_variations( $product, $request ) { + global $wpdb; + + $id = $product->get_id(); + $attributes = $product->get_attributes(); + + foreach ( $request['variations'] as $menu_order => $data ) { + $variation_id = isset( $data['id'] ) ? absint( $data['id'] ) : 0; + $variation = new WC_Product_Variation( $variation_id ); + + // Create initial name and status. + if ( ! $variation->get_slug() ) { + /* translators: 1: variation id 2: product name */ + $variation->set_name( sprintf( __( 'Variation #%1$s of %2$s', 'woocommerce' ), $variation->get_id(), $product->get_name() ) ); + $variation->set_status( isset( $data['visible'] ) && false === $data['visible'] ? 'private' : 'publish' ); + } + + // Parent ID. + $variation->set_parent_id( $product->get_id() ); + + // Menu order. + $variation->set_menu_order( $menu_order ); + + // Status. + if ( isset( $data['visible'] ) ) { + $variation->set_status( false === $data['visible'] ? 'private' : 'publish' ); + } + + // SKU. + if ( isset( $data['sku'] ) ) { + $variation->set_sku( wc_clean( $data['sku'] ) ); + } + + // Thumbnail. + if ( isset( $data['image'] ) && is_array( $data['image'] ) ) { + $image = current( $data['image'] ); + if ( is_array( $image ) ) { + $image['position'] = 0; + } + + $variation = $this->save_product_images( $variation, array( $image ) ); + } + + // Virtual variation. + if ( isset( $data['virtual'] ) ) { + $variation->set_virtual( $data['virtual'] ); + } + + // Downloadable variation. + if ( isset( $data['downloadable'] ) ) { + $is_downloadable = $data['downloadable']; + $variation->set_downloadable( $is_downloadable ); + } else { + $is_downloadable = $variation->get_downloadable(); + } + + // Downloads. + if ( $is_downloadable ) { + // Downloadable files. + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $variation = $this->save_downloadable_files( $variation, $data['downloads'] ); + } + + // Download limit. + if ( isset( $data['download_limit'] ) ) { + $variation->set_download_limit( $data['download_limit'] ); + } + + // Download expiry. + if ( isset( $data['download_expiry'] ) ) { + $variation->set_download_expiry( $data['download_expiry'] ); + } + } + + // Shipping data. + $variation = $this->save_product_shipping_data( $variation, $data ); + + // Stock handling. + $manage_stock = (bool) $variation->get_manage_stock(); + if ( isset( $data['managing_stock'] ) ) { + $manage_stock = $data['managing_stock']; + } + $variation->set_manage_stock( $manage_stock ); + + $stock_status = $variation->get_stock_status(); + if ( isset( $data['in_stock'] ) ) { + $stock_status = true === $data['in_stock'] ? 'instock' : 'outofstock'; + } + $variation->set_stock_status( $stock_status ); + + $backorders = $variation->get_backorders(); + if ( isset( $data['backorders'] ) ) { + $backorders = $data['backorders']; + } + $variation->set_backorders( $backorders ); + + if ( $manage_stock ) { + if ( isset( $data['stock_quantity'] ) ) { + $variation->set_stock_quantity( $data['stock_quantity'] ); + } + } else { + $variation->set_backorders( 'no' ); + $variation->set_stock_quantity( '' ); + } + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $variation->set_regular_price( $data['regular_price'] ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $variation->set_sale_price( $data['sale_price'] ); + } + + if ( isset( $data['sale_price_dates_from'] ) ) { + $variation->set_date_on_sale_from( $data['sale_price_dates_from'] ); + } + + if ( isset( $data['sale_price_dates_to'] ) ) { + $variation->set_date_on_sale_to( $data['sale_price_dates_to'] ); + } + + // Tax class. + if ( isset( $data['tax_class'] ) ) { + $variation->set_tax_class( $data['tax_class'] ); + } + + // Update taxonomies. + if ( isset( $data['attributes'] ) ) { + $_attributes = array(); + + foreach ( $data['attributes'] as $attribute_key => $attribute ) { + if ( ! isset( $attribute['name'] ) ) { + continue; + } + + $taxonomy = 0; + $_attribute = array(); + + if ( isset( $attribute['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $attribute['slug'] ); + } + + if ( ! $taxonomy ) { + $taxonomy = sanitize_title( $attribute['name'] ); + } + + if ( isset( $attributes[ $taxonomy ] ) ) { + $_attribute = $attributes[ $taxonomy ]; + } + + if ( isset( $_attribute['is_variation'] ) && $_attribute['is_variation'] ) { + $_attribute_key = sanitize_title( $_attribute['name'] ); + + if ( isset( $_attribute['is_taxonomy'] ) && $_attribute['is_taxonomy'] ) { + // Don't use wc_clean as it destroys sanitized characters + $_attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : ''; + } else { + $_attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + } + + $_attributes[ $_attribute_key ] = $_attribute_value; + } + } + + $variation->set_attributes( $_attributes ); + } + + $variation->save(); + + do_action( 'woocommerce_api_save_product_variation', $variation_id, $menu_order, $variation ); + } + + return true; + } + + /** + * Save product shipping data + * + * @since 2.2 + * @param WC_Product $product + * @param array $data + * @return WC_Product + */ + private function save_product_shipping_data( $product, $data ) { + if ( isset( $data['weight'] ) ) { + $product->set_weight( '' === $data['weight'] ? '' : wc_format_decimal( $data['weight'] ) ); + } + + // Product dimensions + if ( isset( $data['dimensions'] ) ) { + // Height + if ( isset( $data['dimensions']['height'] ) ) { + $product->set_height( '' === $data['dimensions']['height'] ? '' : wc_format_decimal( $data['dimensions']['height'] ) ); + } + + // Width + if ( isset( $data['dimensions']['width'] ) ) { + $product->set_width( '' === $data['dimensions']['width'] ? '' : wc_format_decimal( $data['dimensions']['width'] ) ); + } + + // Length + if ( isset( $data['dimensions']['length'] ) ) { + $product->set_length( '' === $data['dimensions']['length'] ? '' : wc_format_decimal( $data['dimensions']['length'] ) ); + } + } + + // Virtual + if ( isset( $data['virtual'] ) ) { + $virtual = ( true === $data['virtual'] ) ? 'yes' : 'no'; + + if ( 'yes' == $virtual ) { + $product->set_weight( '' ); + $product->set_height( '' ); + $product->set_length( '' ); + $product->set_width( '' ); + } + } + + // Shipping class + if ( isset( $data['shipping_class'] ) ) { + $data_store = $product->get_data_store(); + $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); + $product->set_shipping_class_id( $shipping_class_id ); + } + + return $product; + } + + /** + * Save downloadable files + * + * @since 2.2 + * @param WC_Product $product + * @param array $downloads + * @param int $deprecated Deprecated since 3.0. + * @return WC_Product + */ + private function save_downloadable_files( $product, $downloads, $deprecated = 0 ) { + if ( $deprecated ) { + wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() does not require a variation_id anymore.' ); + } + + $files = array(); + foreach ( $downloads as $key => $file ) { + if ( isset( $file['url'] ) ) { + $file['file'] = $file['url']; + } + + if ( empty( $file['file'] ) ) { + continue; + } + + $download = new WC_Product_Download(); + $download->set_id( $file['id'] ? $file['id'] : wp_generate_uuid4() ); + $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) ); + $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) ); + $files[] = $download; + } + $product->set_downloads( $files ); + + return $product; + } + + /** + * Get attribute taxonomy by slug. + * + * @since 2.2 + * @param string $slug + * @return string|null + */ + private function get_attribute_taxonomy_by_slug( $slug ) { + $taxonomy = null; + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + foreach ( $attribute_taxonomies as $key => $tax ) { + if ( $slug == $tax->attribute_name ) { + $taxonomy = 'pa_' . $tax->attribute_name; + + break; + } + } + + return $taxonomy; + } + + /** + * Get the images for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_images( $product ) { + $images = $attachment_ids = array(); + $product_image = $product->get_image_id(); + + // Add featured image. + if ( ! empty( $product_image ) ) { + $attachment_ids[] = $product_image; + } + + // Add gallery images. + $attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() ); + + // Build image data. + foreach ( $attachment_ids as $position => $attachment_id ) { + + $attachment_post = get_post( $attachment_id ); + + if ( is_null( $attachment_post ) ) { + continue; + } + + $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ); + + if ( ! is_array( $attachment ) ) { + continue; + } + + $images[] = array( + 'id' => (int) $attachment_id, + 'created_at' => $this->server->format_datetime( $attachment_post->post_date_gmt ), + 'updated_at' => $this->server->format_datetime( $attachment_post->post_modified_gmt ), + 'src' => current( $attachment ), + 'title' => get_the_title( $attachment_id ), + 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), + 'position' => (int) $position, + ); + } + + // Set a placeholder image if the product has no images set. + if ( empty( $images ) ) { + + $images[] = array( + 'id' => 0, + 'created_at' => $this->server->format_datetime( time() ), // Default to now. + 'updated_at' => $this->server->format_datetime( time() ), + 'src' => wc_placeholder_img_src(), + 'title' => __( 'Placeholder', 'woocommerce' ), + 'alt' => __( 'Placeholder', 'woocommerce' ), + 'position' => 0, + ); + } + + return $images; + } + + /** + * Save product images + * + * @since 2.2 + * + * @param WC_Product $product + * @param array $images + * + * @return WC_Product + * @throws WC_API_Exception + */ + protected function save_product_images( $product, $images ) { + if ( is_array( $images ) ) { + $gallery = array(); + + foreach ( $images as $image ) { + if ( isset( $image['position'] ) && 0 == $image['position'] ) { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = $this->upload_product_image( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 ); + } + + $attachment_id = $this->set_product_image_as_attachment( $upload, $product->get_id() ); + } + + $product->set_image_id( $attachment_id ); + } else { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = $this->upload_product_image( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 ); + } + + $gallery[] = $this->set_product_image_as_attachment( $upload, $product->get_id() ); + } else { + $gallery[] = $attachment_id; + } + } + } + + if ( ! empty( $gallery ) ) { + $product->set_gallery_image_ids( $gallery ); + } + } else { + $product->set_image_id( '' ); + $product->set_gallery_image_ids( array() ); + } + + return $product; + } + + /** + * Upload image from URL + * + * @since 2.2 + * + * @param string $image_url + * + * @return array|WP_Error + * + * @throws WC_API_Exception + */ + public function upload_product_image( $image_url ) { + $file_name = basename( current( explode( '?', $image_url ) ) ); + $parsed_url = @parse_url( $image_url ); + + // Check parsed URL + if ( ! $parsed_url || ! is_array( $parsed_url ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_image', sprintf( __( 'Invalid URL %s.', 'woocommerce' ), $image_url ), 400 ); + } + + // Ensure url is valid + $image_url = str_replace( ' ', '%20', $image_url ); + + // Get the file + $response = wp_safe_remote_get( $image_url, array( + 'timeout' => 10, + ) ); + + if ( is_wp_error( $response ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ) . ' ' . sprintf( __( 'Error: %s.', 'woocommerce' ), $response->get_error_message() ), 400 ); + } elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ), 400 ); + } + + // Ensure we have a file name and type + $wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() ); + + if ( ! $wp_filetype['type'] ) { + $headers = wp_remote_retrieve_headers( $response ); + if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) { + $disposition = end( explode( 'filename=', $headers['content-disposition'] ) ); + $disposition = sanitize_file_name( $disposition ); + $file_name = $disposition; + } elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) { + $file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] ); + } + unset( $headers ); + + // Recheck filetype + $wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() ); + + if ( ! $wp_filetype['type'] ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_image', __( 'Invalid image type.', 'woocommerce' ), 400 ); + } + } + + // Upload the file + $upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) ); + + if ( $upload['error'] ) { + throw new WC_API_Exception( 'woocommerce_api_product_image_upload_error', $upload['error'], 400 ); + } + + // Get filesize + $filesize = filesize( $upload['file'] ); + + if ( 0 == $filesize ) { + @unlink( $upload['file'] ); + unset( $upload ); + throw new WC_API_Exception( 'woocommerce_api_product_image_upload_file_error', __( 'Zero size file downloaded.', 'woocommerce' ), 400 ); + } + + unset( $response ); + + return $upload; + } + + /** + * Sets product image as attachment and returns the attachment ID. + * + * @since 2.2 + * @param array $upload + * @param int $id + * @return int + */ + protected function set_product_image_as_attachment( $upload, $id ) { + $info = wp_check_filetype( $upload['file'] ); + $title = ''; + $content = ''; + + if ( $image_meta = @wp_read_image_metadata( $upload['file'] ) ) { + if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { + $title = wc_clean( $image_meta['title'] ); + } + if ( trim( $image_meta['caption'] ) ) { + $content = wc_clean( $image_meta['caption'] ); + } + } + + $attachment = array( + 'post_mime_type' => $info['type'], + 'guid' => $upload['url'], + 'post_parent' => $id, + 'post_title' => $title, + 'post_content' => $content, + ); + + $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $id ); + if ( ! is_wp_error( $attachment_id ) ) { + wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $upload['file'] ) ); + } + + return $attachment_id; + } + + /** + * Get attribute options. + * + * @param int $product_id + * @param array $attribute + * @return array + */ + protected function get_attribute_options( $product_id, $attribute ) { + if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { + return wc_get_product_terms( $product_id, $attribute['name'], array( 'fields' => 'names' ) ); + } elseif ( isset( $attribute['value'] ) ) { + return array_map( 'trim', explode( '|', $attribute['value'] ) ); + } + + return array(); + } + + /** + * Get the attributes for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_attributes( $product ) { + + $attributes = array(); + + if ( $product->is_type( 'variation' ) ) { + + // variation attributes + foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { + + // taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_` + $attributes[] = array( + 'name' => wc_attribute_label( str_replace( 'attribute_', '', $attribute_name ) ), + 'slug' => str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ), + 'option' => $attribute, + ); + } + } else { + + foreach ( $product->get_attributes() as $attribute ) { + $attributes[] = array( + 'name' => wc_attribute_label( $attribute['name'] ), + 'slug' => str_replace( 'pa_', '', $attribute['name'] ), + 'position' => (int) $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } + } + + return $attributes; + } + + /** + * Get the downloads for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_downloads( $product ) { + + $downloads = array(); + + if ( $product->is_downloadable() ) { + + foreach ( $product->get_downloads() as $file_id => $file ) { + + $downloads[] = array( + 'id' => $file_id, // do not cast as int as this is a hash + 'name' => $file['name'], + 'file' => $file['file'], + ); + } + } + + return $downloads; + } + + /** + * Get a listing of product attributes + * + * @since 2.4.0 + * + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_attributes( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_attributes', __( 'You do not have permission to read product attributes', 'woocommerce' ), 401 ); + } + + $product_attributes = array(); + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + foreach ( $attribute_taxonomies as $attribute ) { + $product_attributes[] = array( + 'id' => intval( $attribute->attribute_id ), + 'name' => $attribute->attribute_label, + 'slug' => wc_attribute_taxonomy_name( $attribute->attribute_name ), + 'type' => $attribute->attribute_type, + 'order_by' => $attribute->attribute_orderby, + 'has_archives' => (bool) $attribute->attribute_public, + ); + } + + return array( 'product_attributes' => apply_filters( 'woocommerce_api_product_attributes_response', $product_attributes, $attribute_taxonomies, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product attribute for the given ID + * + * @since 2.4.0 + * + * @param string $id product attribute term ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_attribute( $id, $fields = null ) { + global $wpdb; + + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'Invalid product attribute ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_categories', __( 'You do not have permission to read product attributes', 'woocommerce' ), 401 ); + } + + $attribute = $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$wpdb->prefix}woocommerce_attribute_taxonomies + WHERE attribute_id = %d + ", $id ) ); + + if ( is_wp_error( $attribute ) || is_null( $attribute ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $product_attribute = array( + 'id' => intval( $attribute->attribute_id ), + 'name' => $attribute->attribute_label, + 'slug' => wc_attribute_taxonomy_name( $attribute->attribute_name ), + 'type' => $attribute->attribute_type, + 'order_by' => $attribute->attribute_orderby, + 'has_archives' => (bool) $attribute->attribute_public, + ); + + return array( 'product_attribute' => apply_filters( 'woocommerce_api_product_attribute_response', $product_attribute, $id, $fields, $attribute, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Validate attribute data. + * + * @since 2.4.0 + * @param string $name + * @param string $slug + * @param string $type + * @param string $order_by + * @param bool $new_data + * @return bool + * @throws WC_API_Exception + */ + protected function validate_attribute_data( $name, $slug, $type, $order_by, $new_data = true ) { + if ( empty( $name ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_name', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'name' ), 400 ); + } + + if ( strlen( $slug ) >= 28 ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), $slug ), 400 ); + } elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), 400 ); + } elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), 400 ); + } + + // Validate the attribute type + if ( ! in_array( wc_clean( $type ), array_keys( wc_get_attribute_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_type', sprintf( __( 'Invalid product attribute type - the product attribute type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_attribute_types() ) ) ), 400 ); + } + + // Validate the attribute order by + if ( ! in_array( wc_clean( $order_by ), array( 'menu_order', 'name', 'name_num', 'id' ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_order_by', sprintf( __( 'Invalid product attribute order_by type - the product attribute order_by type must be any of these: %s', 'woocommerce' ), implode( ', ', array( 'menu_order', 'name', 'name_num', 'id' ) ) ), 400 ); + } + + return true; + } + + /** + * Create a new product attribute + * + * @since 2.4.0 + * + * @param array $data posted data + * + * @return array|WP_Error + */ + public function create_product_attribute( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_attribute' ), 400 ); + } + + $data = $data['product_attribute']; + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_attribute', __( 'You do not have permission to create product attributes', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_product_attribute_data', $data, $this ); + + if ( ! isset( $data['name'] ) ) { + $data['name'] = ''; + } + + // Set the attribute slug + if ( ! isset( $data['slug'] ) ) { + $data['slug'] = wc_sanitize_taxonomy_name( stripslashes( $data['name'] ) ); + } else { + $data['slug'] = preg_replace( '/^pa\_/', '', wc_sanitize_taxonomy_name( stripslashes( $data['slug'] ) ) ); + } + + // Set attribute type when not sent + if ( ! isset( $data['type'] ) ) { + $data['type'] = 'select'; + } + + // Set order by when not sent + if ( ! isset( $data['order_by'] ) ) { + $data['order_by'] = 'menu_order'; + } + + // Validate the attribute data + $this->validate_attribute_data( $data['name'], $data['slug'], $data['type'], $data['order_by'], true ); + + $insert = $wpdb->insert( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( + 'attribute_label' => $data['name'], + 'attribute_name' => $data['slug'], + 'attribute_type' => $data['type'], + 'attribute_orderby' => $data['order_by'], + 'attribute_public' => isset( $data['has_archives'] ) && true === $data['has_archives'] ? 1 : 0, + ), + array( '%s', '%s', '%s', '%s', '%d' ) + ); + + // Checks for an error in the product creation + if ( is_wp_error( $insert ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_attribute', $insert->get_error_message(), 400 ); + } + + $id = $wpdb->insert_id; + + do_action( 'woocommerce_api_create_product_attribute', $id, $data ); + + // Clear transients + delete_transient( 'wc_attribute_taxonomies' ); + + $this->server->send_status( 201 ); + + return $this->get_product_attribute( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product attribute + * + * @since 2.4.0 + * + * @param int $id the attribute ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_product_attribute( $id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_attribute' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_attribute']; + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_attribute', __( 'You do not have permission to edit product attributes', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_attribute_data', $data, $this ); + $attribute = $this->get_product_attribute( $id ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $attribute_name = isset( $data['name'] ) ? $data['name'] : $attribute['product_attribute']['name']; + $attribute_type = isset( $data['type'] ) ? $data['type'] : $attribute['product_attribute']['type']; + $attribute_order_by = isset( $data['order_by'] ) ? $data['order_by'] : $attribute['product_attribute']['order_by']; + + if ( isset( $data['slug'] ) ) { + $attribute_slug = wc_sanitize_taxonomy_name( stripslashes( $data['slug'] ) ); + } else { + $attribute_slug = $attribute['product_attribute']['slug']; + } + $attribute_slug = preg_replace( '/^pa\_/', '', $attribute_slug ); + + if ( isset( $data['has_archives'] ) ) { + $attribute_public = true === $data['has_archives'] ? 1 : 0; + } else { + $attribute_public = $attribute['product_attribute']['has_archives']; + } + + // Validate the attribute data + $this->validate_attribute_data( $attribute_name, $attribute_slug, $attribute_type, $attribute_order_by, false ); + + $update = $wpdb->update( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( + 'attribute_label' => $attribute_name, + 'attribute_name' => $attribute_slug, + 'attribute_type' => $attribute_type, + 'attribute_orderby' => $attribute_order_by, + 'attribute_public' => $attribute_public, + ), + array( 'attribute_id' => $id ), + array( '%s', '%s', '%s', '%s', '%d' ), + array( '%d' ) + ); + + // Checks for an error in the product creation + if ( false === $update ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_attribute', __( 'Could not edit the attribute', 'woocommerce' ), 400 ); + } + + do_action( 'woocommerce_api_edit_product_attribute', $id, $data ); + + // Clear transients + delete_transient( 'wc_attribute_taxonomies' ); + + return $this->get_product_attribute( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product attribute + * + * @since 2.4.0 + * + * @param int $id the product attribute ID + * + * @return array|WP_Error + */ + public function delete_product_attribute( $id ) { + global $wpdb; + + try { + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_attribute', __( 'You do not have permission to delete product attributes', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + + $attribute_name = $wpdb->get_var( $wpdb->prepare( " + SELECT attribute_name + FROM {$wpdb->prefix}woocommerce_attribute_taxonomies + WHERE attribute_id = %d + ", $id ) ); + + if ( is_null( $attribute_name ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $deleted = $wpdb->delete( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( 'attribute_id' => $id ), + array( '%d' ) + ); + + if ( false === $deleted ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_attribute', __( 'Could not delete the attribute', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name( $attribute_name ); + + if ( taxonomy_exists( $taxonomy ) ) { + $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0' ); + foreach ( $terms as $term ) { + wp_delete_term( $term->term_id, $taxonomy ); + } + } + + do_action( 'woocommerce_attribute_deleted', $id, $attribute_name, $taxonomy ); + do_action( 'woocommerce_api_delete_product_attribute', $id, $this ); + + // Clear transients + delete_transient( 'wc_attribute_taxonomies' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_attribute' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get product by SKU + * + * @deprecated 2.4.0 + * + * @since 2.3.0 + * + * @param int $sku the product SKU + * @param string $fields + * + * @return array|WP_Error + */ + public function get_product_by_sku( $sku, $fields = null ) { + try { + $id = wc_get_product_id_by_sku( $sku ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_sku', __( 'Invalid product SKU', 'woocommerce' ), 404 ); + } + + return $this->get_product( $id, $fields ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Clear product + * + * @param int $product_id + */ + protected function clear_product( $product_id ) { + if ( ! is_numeric( $product_id ) || 0 >= $product_id ) { + return; + } + + // Delete product attachments + $attachments = get_children( array( + 'post_parent' => $product_id, + 'post_status' => 'any', + 'post_type' => 'attachment', + ) ); + + foreach ( (array) $attachments as $attachment ) { + wp_delete_attachment( $attachment->ID, true ); + } + + // Delete product + $product = wc_get_product( $product_id ); + $product->delete(); + } + + /** + * Bulk update or insert products + * Accepts an array with products in the formats supported by + * WC_API_Products->create_product() and WC_API_Products->edit_product() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['products'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_products_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'products' ), 400 ); + } + + $data = $data['products']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'products' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_products_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $products = array(); + + foreach ( $data as $_product ) { + $product_id = 0; + $product_sku = ''; + + // Try to get the product ID + if ( isset( $_product['id'] ) ) { + $product_id = intval( $_product['id'] ); + } + + if ( ! $product_id && isset( $_product['sku'] ) ) { + $product_sku = wc_clean( $_product['sku'] ); + $product_id = wc_get_product_id_by_sku( $product_sku ); + } + + if ( $product_id ) { + + // Product exists / edit product + $edit = $this->edit_product( $product_id, array( 'product' => $_product ) ); + + if ( is_wp_error( $edit ) ) { + $products[] = array( + 'id' => $product_id, + 'sku' => $product_sku, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $products[] = $edit['product']; + } + } else { + + // Product don't exists / create product + $new = $this->create_product( array( 'product' => $_product ) ); + + if ( is_wp_error( $new ) ) { + $products[] = array( + 'id' => $product_id, + 'sku' => $product_sku, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $products[] = $new['product']; + } + } + } + + return array( 'products' => apply_filters( 'woocommerce_api_products_bulk_response', $products, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-reports.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-reports.php new file mode 100644 index 0000000..8387a2e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-reports.php @@ -0,0 +1,329 @@ +base ] = array( + array( array( $this, 'get_reports' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales + $routes[ $this->base . '/sales' ] = array( + array( array( $this, 'get_sales_report' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales/top_sellers + $routes[ $this->base . '/sales/top_sellers' ] = array( + array( array( $this, 'get_top_sellers_report' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get a simple listing of available reports + * + * @since 2.1 + * @return array + */ + public function get_reports() { + return array( 'reports' => array( 'sales', 'sales/top_sellers' ) ); + } + + /** + * Get the sales report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_sales_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + // check for WP_Error + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + // new customers + $users_query = new WP_User_Query( + array( + 'fields' => array( 'user_registered' ), + 'role' => 'customer', + ) + ); + + $customers = $users_query->get_results(); + + foreach ( $customers as $key => $customer ) { + if ( strtotime( $customer->user_registered ) < $this->report->start_date || strtotime( $customer->user_registered ) > $this->report->end_date ) { + unset( $customers[ $key ] ); + } + } + + $total_customers = count( $customers ); + $report_data = $this->report->get_report_data(); + $period_totals = array(); + + // setup period totals by ensuring each period in the interval has data + for ( $i = 0; $i <= $this->report->chart_interval; $i ++ ) { + + switch ( $this->report->chart_groupby ) { + case 'day' : + $time = date( 'Y-m-d', strtotime( "+{$i} DAY", $this->report->start_date ) ); + break; + default : + $time = date( 'Y-m', strtotime( "+{$i} MONTH", $this->report->start_date ) ); + break; + } + + // set the customer signups for each period + $customer_count = 0; + foreach ( $customers as $customer ) { + if ( date( ( 'day' == $this->report->chart_groupby ) ? 'Y-m-d' : 'Y-m', strtotime( $customer->user_registered ) ) == $time ) { + $customer_count++; + } + } + + $period_totals[ $time ] = array( + 'sales' => wc_format_decimal( 0.00, 2 ), + 'orders' => 0, + 'items' => 0, + 'tax' => wc_format_decimal( 0.00, 2 ), + 'shipping' => wc_format_decimal( 0.00, 2 ), + 'discount' => wc_format_decimal( 0.00, 2 ), + 'customers' => $customer_count, + ); + } + + // add total sales, total order count, total tax and total shipping for each period + foreach ( $report_data->orders as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['sales'] = wc_format_decimal( $order->total_sales, 2 ); + $period_totals[ $time ]['tax'] = wc_format_decimal( $order->total_tax + $order->total_shipping_tax, 2 ); + $period_totals[ $time ]['shipping'] = wc_format_decimal( $order->total_shipping, 2 ); + } + + foreach ( $report_data->order_counts as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['orders'] = (int) $order->count; + } + + // add total order items for each period + foreach ( $report_data->order_items as $order_item ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order_item->post_date ) ) : date( 'Y-m', strtotime( $order_item->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['items'] = (int) $order_item->order_item_count; + } + + // add total discount for each period + foreach ( $report_data->coupons as $discount ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $discount->post_date ) ) : date( 'Y-m', strtotime( $discount->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['discount'] = wc_format_decimal( $discount->discount_amount, 2 ); + } + + $sales_data = array( + 'total_sales' => $report_data->total_sales, + 'net_sales' => $report_data->net_sales, + 'average_sales' => $report_data->average_sales, + 'total_orders' => $report_data->total_orders, + 'total_items' => $report_data->total_items, + 'total_tax' => wc_format_decimal( $report_data->total_tax + $report_data->total_shipping_tax, 2 ), + 'total_shipping' => $report_data->total_shipping, + 'total_refunds' => $report_data->total_refunds, + 'total_discount' => $report_data->total_coupons, + 'totals_grouped_by' => $this->report->chart_groupby, + 'totals' => $period_totals, + 'total_customers' => $total_customers, + ); + + return array( 'sales' => apply_filters( 'woocommerce_api_report_response', $sales_data, $this->report, $fields, $this->server ) ); + } + + /** + * Get the top sellers report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_top_sellers_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + $top_sellers = $this->report->get_order_report_data( array( + 'data' => array( + '_product_id' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => '', + 'name' => 'product_id', + ), + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_qty', + ), + ), + 'order_by' => 'order_item_qty DESC', + 'group_by' => 'product_id', + 'limit' => isset( $filter['limit'] ) ? absint( $filter['limit'] ) : 12, + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + $top_sellers_data = array(); + + foreach ( $top_sellers as $top_seller ) { + + $product = wc_get_product( $top_seller->product_id ); + + if ( $product ) { + $top_sellers_data[] = array( + 'title' => $product->get_name(), + 'product_id' => $top_seller->product_id, + 'quantity' => $top_seller->order_item_qty, + ); + } + } + + return array( 'top_sellers' => apply_filters( 'woocommerce_api_report_response', $top_sellers_data, $this->report, $fields, $this->server ) ); + } + + /** + * Setup the report object and parse any date filtering + * + * @since 2.1 + * @param array $filter date filtering + */ + private function setup_report( $filter ) { + + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-admin-report.php' ); + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-report-sales-by-date.php' ); + + $this->report = new WC_Report_Sales_By_Date(); + + if ( empty( $filter['period'] ) ) { + + // custom date range + $filter['period'] = 'custom'; + + if ( ! empty( $filter['date_min'] ) || ! empty( $filter['date_max'] ) ) { + + // overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges + $_GET['start_date'] = $this->server->parse_datetime( $filter['date_min'] ); + $_GET['end_date'] = isset( $filter['date_max'] ) ? $this->server->parse_datetime( $filter['date_max'] ) : null; + + } else { + + // default custom range to today + $_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) ); + } + } else { + + // ensure period is valid + if ( ! in_array( $filter['period'], array( 'week', 'month', 'last_month', 'year' ) ) ) { + $filter['period'] = 'week'; + } + + // TODO: change WC_Admin_Report class to use "week" instead, as it's more consistent with other periods + // allow "week" for period instead of "7day" + if ( 'week' === $filter['period'] ) { + $filter['period'] = '7day'; + } + } + + $this->report->calculate_current_range( $filter['period'] ); + } + + /** + * Verify that the current user has permission to view reports + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * + * @param null $id unused + * @param null $type unused + * @param null $context unused + * + * @return bool|WP_Error + */ + protected function validate_request( $id = null, $type = null, $context = null ) { + + if ( ! current_user_can( 'view_woocommerce_reports' ) ) { + + return new WP_Error( 'woocommerce_api_user_cannot_read_report', __( 'You do not have permission to read this report', 'woocommerce' ), array( 'status' => 401 ) ); + + } else { + + return true; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-resource.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-resource.php new file mode 100644 index 0000000..cd2a9ec --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-resource.php @@ -0,0 +1,466 @@ +server = $server; + + // automatically register routes for sub-classes + add_filter( 'woocommerce_api_endpoints', array( $this, 'register_routes' ) ); + + // maybe add meta to top-level resource responses + foreach ( array( 'order', 'coupon', 'customer', 'product', 'report' ) as $resource ) { + add_filter( "woocommerce_api_{$resource}_response", array( $this, 'maybe_add_meta' ), 15, 2 ); + } + + $response_names = array( + 'order', + 'coupon', + 'customer', + 'product', + 'report', + 'customer_orders', + 'customer_downloads', + 'order_note', + 'order_refund', + 'product_reviews', + 'product_category', + ); + + foreach ( $response_names as $name ) { + + /** + * Remove fields from responses when requests specify certain fields + * note these are hooked at a later priority so data added via + * filters (e.g. customer data to the order response) still has the + * fields filtered properly + */ + add_filter( "woocommerce_api_{$name}_response", array( $this, 'filter_response_fields' ), 20, 3 ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid post object and matches the provided post type + * 3) the current user has the proper permissions to read/edit/delete the post + * + * @since 2.1 + * @param string|int $id the post ID + * @param string $type the post type, either `shop_order`, `shop_coupon`, or `product` + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid post ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type || 'shop_webhook' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}_id", sprintf( __( 'Invalid %s ID', 'woocommerce' ), $type ), array( 'status' => 404 ) ); + } + + // Only custom post types have per-post type/permission checks + if ( 'customer' !== $type ) { + + $post = get_post( $id ); + + if ( null === $post ) { + return new WP_Error( "woocommerce_api_no_{$resource_name}_found", sprintf( __( 'No %1$s found with the ID equal to %2$s', 'woocommerce' ), $resource_name, $id ), array( 'status' => 404 ) ); + } + + // For checking permissions, product variations are the same as the product post type + $post_type = ( 'product_variation' === $post->post_type ) ? 'product' : $post->post_type; + + // Validate post type + if ( $type !== $post_type ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}", sprintf( __( 'Invalid %s', 'woocommerce' ), $resource_name ), array( 'status' => 404 ) ); + } + + // Validate permissions + switch ( $context ) { + + case 'read': + if ( ! $this->is_readable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_read_{$resource_name}", sprintf( __( 'You do not have permission to read this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! $this->is_editable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_edit_{$resource_name}", sprintf( __( 'You do not have permission to edit this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! $this->is_deletable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_delete_{$resource_name}", sprintf( __( 'You do not have permission to delete this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + } + } + + return $id; + } + + /** + * Add common request arguments to argument list before WP_Query is run + * + * @since 2.1 + * @param array $base_args required arguments for the query (e.g. `post_type`, etc) + * @param array $request_args arguments provided in the request + * @return array + */ + protected function merge_query_args( $base_args, $request_args ) { + + $args = array(); + + // date + if ( ! empty( $request_args['created_at_min'] ) || ! empty( $request_args['created_at_max'] ) || ! empty( $request_args['updated_at_min'] ) || ! empty( $request_args['updated_at_max'] ) ) { + + $args['date_query'] = array(); + + // resources created after specified date + if ( ! empty( $request_args['created_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'after' => $this->server->parse_datetime( $request_args['created_at_min'] ), 'inclusive' => true ); + } + + // resources created before specified date + if ( ! empty( $request_args['created_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'before' => $this->server->parse_datetime( $request_args['created_at_max'] ), 'inclusive' => true ); + } + + // resources updated after specified date + if ( ! empty( $request_args['updated_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'after' => $this->server->parse_datetime( $request_args['updated_at_min'] ), 'inclusive' => true ); + } + + // resources updated before specified date + if ( ! empty( $request_args['updated_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'before' => $this->server->parse_datetime( $request_args['updated_at_max'] ), 'inclusive' => true ); + } + } + + // search + if ( ! empty( $request_args['q'] ) ) { + $args['s'] = $request_args['q']; + } + + // resources per response + if ( ! empty( $request_args['limit'] ) ) { + $args['posts_per_page'] = $request_args['limit']; + } + + // resource offset + if ( ! empty( $request_args['offset'] ) ) { + $args['offset'] = $request_args['offset']; + } + + // order (ASC or DESC, ASC by default) + if ( ! empty( $request_args['order'] ) ) { + $args['order'] = $request_args['order']; + } + + // orderby + if ( ! empty( $request_args['orderby'] ) ) { + $args['orderby'] = $request_args['orderby']; + + // allow sorting by meta value + if ( ! empty( $request_args['orderby_meta_key'] ) ) { + $args['meta_key'] = $request_args['orderby_meta_key']; + } + } + + // allow post status change + if ( ! empty( $request_args['post_status'] ) ) { + $args['post_status'] = $request_args['post_status']; + unset( $request_args['post_status'] ); + } + + // filter by a list of post id + if ( ! empty( $request_args['in'] ) ) { + $args['post__in'] = explode( ',', $request_args['in'] ); + unset( $request_args['in'] ); + } + + // filter by a list of post id + if ( ! empty( $request_args['in'] ) ) { + $args['post__in'] = explode( ',', $request_args['in'] ); + unset( $request_args['in'] ); + } + + // resource page + $args['paged'] = ( isset( $request_args['page'] ) ) ? absint( $request_args['page'] ) : 1; + + $args = apply_filters( 'woocommerce_api_query_args', $args, $request_args ); + + return array_merge( $base_args, $args ); + } + + /** + * Add meta to resources when requested by the client. Meta is added as a top-level + * `_meta` attribute (e.g. `order_meta`) as a list of key/value pairs + * + * @since 2.1 + * @param array $data the resource data + * @param object $resource the resource object (e.g WC_Order) + * @return mixed + */ + public function maybe_add_meta( $data, $resource ) { + + if ( isset( $this->server->params['GET']['filter']['meta'] ) && 'true' === $this->server->params['GET']['filter']['meta'] && is_object( $resource ) ) { + + // don't attempt to add meta more than once + if ( preg_grep( '/[a-z]+_meta/', array_keys( $data ) ) ) { + return $data; + } + + // define the top-level property name for the meta + switch ( get_class( $resource ) ) { + + case 'WC_Order': + $meta_name = 'order_meta'; + break; + + case 'WC_Coupon': + $meta_name = 'coupon_meta'; + break; + + case 'WP_User': + $meta_name = 'customer_meta'; + break; + + default: + $meta_name = 'product_meta'; + break; + } + + if ( is_a( $resource, 'WP_User' ) ) { + + // customer meta + $meta = (array) get_user_meta( $resource->ID ); + + } else { + + // coupon/order/product meta + $meta = (array) get_post_meta( $resource->get_id() ); + } + + foreach ( $meta as $meta_key => $meta_value ) { + + // don't add hidden meta by default + if ( ! is_protected_meta( $meta_key ) ) { + $data[ $meta_name ][ $meta_key ] = maybe_unserialize( $meta_value[0] ); + } + } + } + + return $data; + } + + /** + * Restrict the fields included in the response if the request specified certain only certain fields should be returned + * + * @since 2.1 + * @param array $data the response data + * @param object $resource the object that provided the response data, e.g. WC_Coupon or WC_Order + * @param array|string the requested list of fields to include in the response + * @return array response data + */ + public function filter_response_fields( $data, $resource, $fields ) { + + if ( ! is_array( $data ) || empty( $fields ) ) { + return $data; + } + + $fields = explode( ',', $fields ); + $sub_fields = array(); + + // get sub fields + foreach ( $fields as $field ) { + + if ( false !== strpos( $field, '.' ) ) { + + list( $name, $value ) = explode( '.', $field ); + + $sub_fields[ $name ] = $value; + } + } + + // iterate through top-level fields + foreach ( $data as $data_field => $data_value ) { + + // if a field has sub-fields and the top-level field has sub-fields to filter + if ( is_array( $data_value ) && in_array( $data_field, array_keys( $sub_fields ) ) ) { + + // iterate through each sub-field + foreach ( $data_value as $sub_field => $sub_field_value ) { + + // remove non-matching sub-fields + if ( ! in_array( $sub_field, $sub_fields ) ) { + unset( $data[ $data_field ][ $sub_field ] ); + } + } + } else { + + // remove non-matching top-level fields + if ( ! in_array( $data_field, $fields ) ) { + unset( $data[ $data_field ] ); + } + } + } + + return $data; + } + + /** + * Delete a given resource + * + * @since 2.1 + * @param int $id the resource ID + * @param string $type the resource post type, or `customer` + * @param bool $force true to permanently delete resource, false to move to trash (not supported for `customer`) + * @return array|WP_Error + */ + protected function delete( $id, $type, $force = false ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + if ( 'customer' === $type ) { + + $result = wp_delete_user( $id ); + + if ( $result ) { + return array( 'message' => __( 'Permanently deleted customer', 'woocommerce' ) ); + } else { + return new WP_Error( 'woocommerce_api_cannot_delete_customer', __( 'The customer cannot be deleted', 'woocommerce' ), array( 'status' => 500 ) ); + } + } else { + + // delete order/coupon/webhook + $result = ( $force ) ? wp_delete_post( $id, true ) : wp_trash_post( $id ); + + if ( ! $result ) { + return new WP_Error( "woocommerce_api_cannot_delete_{$resource_name}", sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), $resource_name ), array( 'status' => 500 ) ); + } + + if ( $force ) { + return array( 'message' => sprintf( __( 'Permanently deleted %s', 'woocommerce' ), $resource_name ) ); + } else { + $this->server->send_status( '202' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), $resource_name ) ); + } + } + } + + + /** + * Checks if the given post is readable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_readable( $post ) { + + return $this->check_permission( $post, 'read' ); + } + + /** + * Checks if the given post is editable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_editable( $post ) { + + return $this->check_permission( $post, 'edit' ); + + } + + /** + * Checks if the given post is deletable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_deletable( $post ) { + + return $this->check_permission( $post, 'delete' ); + } + + /** + * Checks the permissions for the current user given a post and context + * + * @since 2.1 + * @param WP_Post|int $post + * @param string $context the type of permission to check, either `read`, `write`, or `delete` + * @return bool true if the current user has the permissions to perform the context on the post + */ + private function check_permission( $post, $context ) { + + if ( ! is_a( $post, 'WP_Post' ) ) { + $post = get_post( $post ); + } + + if ( is_null( $post ) ) { + return false; + } + + $post_type = get_post_type_object( $post->post_type ); + + if ( 'read' === $context ) { + return ( 'revision' !== $post->post_type && current_user_can( $post_type->cap->read_private_posts, $post->ID ) ); + } elseif ( 'edit' === $context ) { + return current_user_can( $post_type->cap->edit_post, $post->ID ); + } elseif ( 'delete' === $context ) { + return current_user_can( $post_type->cap->delete_post, $post->ID ); + } else { + return false; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-server.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-server.php new file mode 100644 index 0000000..4df7e3b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-server.php @@ -0,0 +1,775 @@ + self::METHOD_GET, + 'GET' => self::METHOD_GET, + 'POST' => self::METHOD_POST, + 'PUT' => self::METHOD_PUT, + 'PATCH' => self::METHOD_PATCH, + 'DELETE' => self::METHOD_DELETE, + ); + + /** + * Requested path (relative to the API root, wp-json.php) + * + * @var string + */ + public $path = ''; + + /** + * Requested method (GET/HEAD/POST/PUT/PATCH/DELETE) + * + * @var string + */ + public $method = 'HEAD'; + + /** + * Request parameters + * + * This acts as an abstraction of the superglobals + * (GET => $_GET, POST => $_POST) + * + * @var array + */ + public $params = array( 'GET' => array(), 'POST' => array() ); + + /** + * Request headers + * + * @var array + */ + public $headers = array(); + + /** + * Request files (matches $_FILES) + * + * @var array + */ + public $files = array(); + + /** + * Request/Response handler, either JSON by default + * or XML if requested by client + * + * @var WC_API_Handler + */ + public $handler; + + + /** + * Setup class and set request/response handler + * + * @since 2.1 + * @param $path + */ + public function __construct( $path ) { + + if ( empty( $path ) ) { + if ( isset( $_SERVER['PATH_INFO'] ) ) { + $path = $_SERVER['PATH_INFO']; + } else { + $path = '/'; + } + } + + $this->path = $path; + $this->method = $_SERVER['REQUEST_METHOD']; + $this->params['GET'] = $_GET; + $this->params['POST'] = $_POST; + $this->headers = $this->get_headers( $_SERVER ); + $this->files = $_FILES; + + // Compatibility for clients that can't use PUT/PATCH/DELETE + if ( isset( $_GET['_method'] ) ) { + $this->method = strtoupper( $_GET['_method'] ); + } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { + $this->method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; + } + + // load response handler + $handler_class = apply_filters( 'woocommerce_api_default_response_handler', 'WC_API_JSON_Handler', $this->path, $this ); + + $this->handler = new $handler_class(); + } + + /** + * Check authentication for the request + * + * @since 2.1 + * @return WP_User|WP_Error WP_User object indicates successful login, WP_Error indicates unsuccessful login + */ + public function check_authentication() { + + // allow plugins to remove default authentication or add their own authentication + $user = apply_filters( 'woocommerce_api_check_authentication', null, $this ); + + if ( is_a( $user, 'WP_User' ) ) { + + // API requests run under the context of the authenticated user + wp_set_current_user( $user->ID ); + + } elseif ( ! is_wp_error( $user ) ) { + + // WP_Errors are handled in serve_request() + $user = new WP_Error( 'woocommerce_api_authentication_error', __( 'Invalid authentication method', 'woocommerce' ), array( 'code' => 500 ) ); + + } + + return $user; + } + + /** + * Convert an error to an array + * + * This iterates over all error codes and messages to change it into a flat + * array. This enables simpler client behaviour, as it is represented as a + * list in JSON rather than an object/map + * + * @since 2.1 + * @param WP_Error $error + * @return array List of associative arrays with code and message keys + */ + protected function error_to_array( $error ) { + $errors = array(); + foreach ( (array) $error->errors as $code => $messages ) { + foreach ( (array) $messages as $message ) { + $errors[] = array( 'code' => $code, 'message' => $message ); + } + } + + return array( 'errors' => $errors ); + } + + /** + * Handle serving an API request + * + * Matches the current server URI to a route and runs the first matching + * callback then outputs a JSON representation of the returned value. + * + * @since 2.1 + * @uses WC_API_Server::dispatch() + */ + public function serve_request() { + + do_action( 'woocommerce_api_server_before_serve', $this ); + + $this->header( 'Content-Type', $this->handler->get_content_type(), true ); + + // the API is enabled by default + if ( ! apply_filters( 'woocommerce_api_enabled', true, $this ) || ( 'no' === get_option( 'woocommerce_api_enabled' ) ) ) { + + $this->send_status( 404 ); + + echo $this->handler->generate_response( array( 'errors' => array( 'code' => 'woocommerce_api_disabled', 'message' => 'The WooCommerce API is disabled on this site' ) ) ); + + return; + } + + $result = $this->check_authentication(); + + // if authorization check was successful, dispatch the request + if ( ! is_wp_error( $result ) ) { + $result = $this->dispatch(); + } + + // handle any dispatch errors + if ( is_wp_error( $result ) ) { + $data = $result->get_error_data(); + if ( is_array( $data ) && isset( $data['status'] ) ) { + $this->send_status( $data['status'] ); + } + + $result = $this->error_to_array( $result ); + } + + // This is a filter rather than an action, since this is designed to be + // re-entrant if needed + $served = apply_filters( 'woocommerce_api_serve_request', false, $result, $this ); + + if ( ! $served ) { + + if ( 'HEAD' === $this->method ) { + return; + } + + echo $this->handler->generate_response( $result ); + } + } + + /** + * Retrieve the route map + * + * The route map is an associative array with path regexes as the keys. The + * value is an indexed array with the callback function/method as the first + * item, and a bitmask of HTTP methods as the second item (see the class + * constants). + * + * Each route can be mapped to more than one callback by using an array of + * the indexed arrays. This allows mapping e.g. GET requests to one callback + * and POST requests to another. + * + * Note that the path regexes (array keys) must have @ escaped, as this is + * used as the delimiter with preg_match() + * + * @since 2.1 + * @return array `'/path/regex' => array( $callback, $bitmask )` or `'/path/regex' => array( array( $callback, $bitmask ), ...)` + */ + public function get_routes() { + + // index added by default + $endpoints = array( + + '/' => array( array( $this, 'get_index' ), self::READABLE ), + ); + + $endpoints = apply_filters( 'woocommerce_api_endpoints', $endpoints ); + + // Normalise the endpoints + foreach ( $endpoints as $route => &$handlers ) { + if ( count( $handlers ) <= 2 && isset( $handlers[1] ) && ! is_array( $handlers[1] ) ) { + $handlers = array( $handlers ); + } + } + + return $endpoints; + } + + /** + * Match the request to a callback and call it + * + * @since 2.1 + * @return mixed The value returned by the callback, or a WP_Error instance + */ + public function dispatch() { + + switch ( $this->method ) { + + case 'HEAD' : + case 'GET' : + $method = self::METHOD_GET; + break; + + case 'POST' : + $method = self::METHOD_POST; + break; + + case 'PUT' : + $method = self::METHOD_PUT; + break; + + case 'PATCH' : + $method = self::METHOD_PATCH; + break; + + case 'DELETE' : + $method = self::METHOD_DELETE; + break; + + default : + return new WP_Error( 'woocommerce_api_unsupported_method', __( 'Unsupported request method', 'woocommerce' ), array( 'status' => 400 ) ); + } + + foreach ( $this->get_routes() as $route => $handlers ) { + foreach ( $handlers as $handler ) { + $callback = $handler[0]; + $supported = isset( $handler[1] ) ? $handler[1] : self::METHOD_GET; + + if ( ! ( $supported & $method ) ) { + continue; + } + + $match = preg_match( '@^' . $route . '$@i', urldecode( $this->path ), $args ); + + if ( ! $match ) { + continue; + } + + if ( ! is_callable( $callback ) ) { + return new WP_Error( 'woocommerce_api_invalid_handler', __( 'The handler for the route is invalid', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $args = array_merge( $args, $this->params['GET'] ); + if ( $method & self::METHOD_POST ) { + $args = array_merge( $args, $this->params['POST'] ); + } + if ( $supported & self::ACCEPT_DATA ) { + $data = $this->handler->parse_body( $this->get_raw_data() ); + $args = array_merge( $args, array( 'data' => $data ) ); + } elseif ( $supported & self::ACCEPT_RAW_DATA ) { + $data = $this->get_raw_data(); + $args = array_merge( $args, array( 'data' => $data ) ); + } + + $args['_method'] = $method; + $args['_route'] = $route; + $args['_path'] = $this->path; + $args['_headers'] = $this->headers; + $args['_files'] = $this->files; + + $args = apply_filters( 'woocommerce_api_dispatch_args', $args, $callback ); + + // Allow plugins to halt the request via this filter + if ( is_wp_error( $args ) ) { + return $args; + } + + $params = $this->sort_callback_params( $callback, $args ); + if ( is_wp_error( $params ) ) { + return $params; + } + + return call_user_func_array( $callback, $params ); + } + } + + return new WP_Error( 'woocommerce_api_no_route', __( 'No route was found matching the URL and request method', 'woocommerce' ), array( 'status' => 404 ) ); + } + + /** + * urldecode deep. + * + * @since 2.2 + * @param string|array $value Data to decode with urldecode. + * @return string|array Decoded data. + */ + protected function urldecode_deep( $value ) { + if ( is_array( $value ) ) { + return array_map( array( $this, 'urldecode_deep' ), $value ); + } else { + return urldecode( $value ); + } + } + + /** + * Sort parameters by order specified in method declaration + * + * Takes a callback and a list of available params, then filters and sorts + * by the parameters the method actually needs, using the Reflection API + * + * @since 2.2 + * + * @param callable|array $callback the endpoint callback + * @param array $provided the provided request parameters + * + * @return array|WP_Error + */ + protected function sort_callback_params( $callback, $provided ) { + if ( is_array( $callback ) ) { + $ref_func = new ReflectionMethod( $callback[0], $callback[1] ); + } else { + $ref_func = new ReflectionFunction( $callback ); + } + + $wanted = $ref_func->getParameters(); + $ordered_parameters = array(); + + foreach ( $wanted as $param ) { + if ( isset( $provided[ $param->getName() ] ) ) { + // We have this parameters in the list to choose from + if ( 'data' == $param->getName() ) { + $ordered_parameters[] = $provided[ $param->getName() ]; + continue; + } + + $ordered_parameters[] = $this->urldecode_deep( $provided[ $param->getName() ] ); + } elseif ( $param->isDefaultValueAvailable() ) { + // We don't have this parameter, but it's optional + $ordered_parameters[] = $param->getDefaultValue(); + } else { + // We don't have this parameter and it wasn't optional, abort! + return new WP_Error( 'woocommerce_api_missing_callback_param', sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param->getName() ), array( 'status' => 400 ) ); + } + } + + return $ordered_parameters; + } + + /** + * Get the site index. + * + * This endpoint describes the capabilities of the site. + * + * @since 2.3 + * @return array Index entity + */ + public function get_index() { + + // General site data + $available = array( + 'store' => array( + 'name' => get_option( 'blogname' ), + 'description' => get_option( 'blogdescription' ), + 'URL' => get_option( 'siteurl' ), + 'wc_version' => WC()->version, + 'routes' => array(), + 'meta' => array( + 'timezone' => wc_timezone_string(), + 'currency' => get_woocommerce_currency(), + 'currency_format' => get_woocommerce_currency_symbol(), + 'currency_position' => get_option( 'woocommerce_currency_pos' ), + 'thousand_separator' => get_option( 'woocommerce_price_thousand_sep' ), + 'decimal_separator' => get_option( 'woocommerce_price_decimal_sep' ), + 'price_num_decimals' => wc_get_price_decimals(), + 'tax_included' => wc_prices_include_tax(), + 'weight_unit' => get_option( 'woocommerce_weight_unit' ), + 'dimension_unit' => get_option( 'woocommerce_dimension_unit' ), + 'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ), + 'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ), + 'generate_password' => ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) ), + 'links' => array( + 'help' => 'https://woocommerce.github.io/woocommerce-rest-api-docs/', + ), + ), + ), + ); + + // Find the available routes + foreach ( $this->get_routes() as $route => $callbacks ) { + $data = array(); + + $route = preg_replace( '#\(\?P(<\w+?>).*?\)#', '$1', $route ); + + foreach ( self::$method_map as $name => $bitmask ) { + foreach ( $callbacks as $callback ) { + // Skip to the next route if any callback is hidden + if ( $callback[1] & self::HIDDEN_ENDPOINT ) { + continue 3; + } + + if ( $callback[1] & $bitmask ) { + $data['supports'][] = $name; + } + + if ( $callback[1] & self::ACCEPT_DATA ) { + $data['accepts_data'] = true; + } + + // For non-variable routes, generate links + if ( strpos( $route, '<' ) === false ) { + $data['meta'] = array( + 'self' => get_woocommerce_api_url( $route ), + ); + } + } + } + + $available['store']['routes'][ $route ] = apply_filters( 'woocommerce_api_endpoints_description', $data ); + } + + return apply_filters( 'woocommerce_api_index', $available ); + } + + /** + * Send a HTTP status code + * + * @since 2.1 + * @param int $code HTTP status + */ + public function send_status( $code ) { + status_header( $code ); + } + + /** + * Send a HTTP header + * + * @since 2.1 + * @param string $key Header key + * @param string $value Header value + * @param boolean $replace Should we replace the existing header? + */ + public function header( $key, $value, $replace = true ) { + header( sprintf( '%s: %s', $key, $value ), $replace ); + } + + /** + * Send a Link header + * + * @internal The $rel parameter is first, as this looks nicer when sending multiple + * + * @link http://tools.ietf.org/html/rfc5988 + * @link http://www.iana.org/assignments/link-relations/link-relations.xml + * + * @since 2.1 + * @param string $rel Link relation. Either a registered type, or an absolute URL + * @param string $link Target IRI for the link + * @param array $other Other parameters to send, as an associative array + */ + public function link_header( $rel, $link, $other = array() ) { + + $header = sprintf( '<%s>; rel="%s"', $link, esc_attr( $rel ) ); + + foreach ( $other as $key => $value ) { + + if ( 'title' == $key ) { + + $value = '"' . $value . '"'; + } + + $header .= '; ' . $key . '=' . $value; + } + + $this->header( 'Link', $header, false ); + } + + /** + * Send pagination headers for resources + * + * @since 2.1 + * @param WP_Query|WP_User_Query|stdClass $query + */ + public function add_pagination_headers( $query ) { + + // WP_User_Query + if ( is_a( $query, 'WP_User_Query' ) ) { + + $single = count( $query->get_results() ) == 1; + $total = $query->get_total(); + + if ( $query->get( 'number' ) > 0 ) { + $page = ( $query->get( 'offset' ) / $query->get( 'number' ) ) + 1; + $total_pages = ceil( $total / $query->get( 'number' ) ); + } else { + $page = 1; + $total_pages = 1; + } + } elseif ( is_a( $query, 'stdClass' ) ) { + $page = $query->page; + $single = $query->is_single; + $total = $query->total; + $total_pages = $query->total_pages; + + // WP_Query + } else { + + $page = $query->get( 'paged' ); + $single = $query->is_single(); + $total = $query->found_posts; + $total_pages = $query->max_num_pages; + } + + if ( ! $page ) { + $page = 1; + } + + $next_page = absint( $page ) + 1; + + if ( ! $single ) { + + // first/prev + if ( $page > 1 ) { + $this->link_header( 'first', $this->get_paginated_url( 1 ) ); + $this->link_header( 'prev', $this->get_paginated_url( $page -1 ) ); + } + + // next + if ( $next_page <= $total_pages ) { + $this->link_header( 'next', $this->get_paginated_url( $next_page ) ); + } + + // last + if ( $page != $total_pages ) { + $this->link_header( 'last', $this->get_paginated_url( $total_pages ) ); + } + } + + $this->header( 'X-WC-Total', $total ); + $this->header( 'X-WC-TotalPages', $total_pages ); + + do_action( 'woocommerce_api_pagination_headers', $this, $query ); + } + + /** + * Returns the request URL with the page query parameter set to the specified page + * + * @since 2.1 + * @param int $page + * @return string + */ + private function get_paginated_url( $page ) { + + // remove existing page query param + $request = remove_query_arg( 'page' ); + + // add provided page query param + $request = urldecode( add_query_arg( 'page', $page, $request ) ); + + // get the home host + $host = parse_url( get_home_url(), PHP_URL_HOST ); + + return set_url_scheme( "http://{$host}{$request}" ); + } + + /** + * Retrieve the raw request entity (body) + * + * @since 2.1 + * @return string + */ + public function get_raw_data() { + // @codingStandardsIgnoreStart + // $HTTP_RAW_POST_DATA is deprecated on PHP 5.6. + if ( function_exists( 'phpversion' ) && version_compare( phpversion(), '5.6', '>=' ) ) { + return file_get_contents( 'php://input' ); + } + + global $HTTP_RAW_POST_DATA; + + // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, + // but we can do it ourself. + if ( ! isset( $HTTP_RAW_POST_DATA ) ) { + $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); + } + + return $HTTP_RAW_POST_DATA; + // @codingStandardsIgnoreEnd + } + + /** + * Parse an RFC3339 datetime into a MySQl datetime + * + * Invalid dates default to unix epoch + * + * @since 2.1 + * @param string $datetime RFC3339 datetime + * @return string MySQl datetime (YYYY-MM-DD HH:MM:SS) + */ + public function parse_datetime( $datetime ) { + + // Strip millisecond precision (a full stop followed by one or more digits) + if ( strpos( $datetime, '.' ) !== false ) { + $datetime = preg_replace( '/\.\d+/', '', $datetime ); + } + + // default timezone to UTC + $datetime = preg_replace( '/[+-]\d+:+\d+$/', '+00:00', $datetime ); + + try { + + $datetime = new DateTime( $datetime, new DateTimeZone( 'UTC' ) ); + + } catch ( Exception $e ) { + + $datetime = new DateTime( '@0' ); + + } + + return $datetime->format( 'Y-m-d H:i:s' ); + } + + /** + * Format a unix timestamp or MySQL datetime into an RFC3339 datetime + * + * @since 2.1 + * @param int|string $timestamp unix timestamp or MySQL datetime + * @param bool $convert_to_utc + * @param bool $convert_to_gmt Use GMT timezone. + * @return string RFC3339 datetime + */ + public function format_datetime( $timestamp, $convert_to_utc = false, $convert_to_gmt = false ) { + if ( $convert_to_gmt ) { + if ( is_numeric( $timestamp ) ) { + $timestamp = date( 'Y-m-d H:i:s', $timestamp ); + } + + $timestamp = get_gmt_from_date( $timestamp ); + } + + if ( $convert_to_utc ) { + $timezone = new DateTimeZone( wc_timezone_string() ); + } else { + $timezone = new DateTimeZone( 'UTC' ); + } + + try { + + if ( is_numeric( $timestamp ) ) { + $date = new DateTime( "@{$timestamp}" ); + } else { + $date = new DateTime( $timestamp, $timezone ); + } + + // convert to UTC by adjusting the time based on the offset of the site's timezone + if ( $convert_to_utc ) { + $date->modify( -1 * $date->getOffset() . ' seconds' ); + } + } catch ( Exception $e ) { + + $date = new DateTime( '@0' ); + } + + return $date->format( 'Y-m-d\TH:i:s\Z' ); + } + + /** + * Extract headers from a PHP-style $_SERVER array + * + * @since 2.1 + * @param array $server Associative array similar to $_SERVER + * @return array Headers extracted from the input + */ + public function get_headers( $server ) { + $headers = array(); + // CONTENT_* headers are not prefixed with HTTP_ + $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true ); + + foreach ( $server as $key => $value ) { + if ( strpos( $key, 'HTTP_' ) === 0 ) { + $headers[ substr( $key, 5 ) ] = $value; + } elseif ( isset( $additional[ $key ] ) ) { + $headers[ $key ] = $value; + } + } + + return $headers; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-webhooks.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-webhooks.php new file mode 100644 index 0000000..543caa9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/class-wc-api-webhooks.php @@ -0,0 +1,522 @@ +base ] = array( + array( array( $this, 'get_webhooks' ), WC_API_Server::READABLE ), + array( array( $this, 'create_webhook' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /webhooks/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_webhooks_count' ), WC_API_Server::READABLE ), + ); + + # GET|PUT|DELETE /webhooks/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_webhook' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_webhook' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_webhook' ), WC_API_Server::DELETABLE ), + ); + + # GET /webhooks//deliveries + $routes[ $this->base . '/(?P\d+)/deliveries' ] = array( + array( array( $this, 'get_webhook_deliveries' ), WC_API_Server::READABLE ), + ); + + # GET /webhooks//deliveries/ + $routes[ $this->base . '/(?P\d+)/deliveries/(?P\d+)' ] = array( + array( array( $this, 'get_webhook_delivery' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get all webhooks + * + * @since 2.2 + * + * @param array $fields + * @param array $filter + * @param string $status + * @param int $page + * + * @return array + */ + public function get_webhooks( $fields = null, $filter = array(), $status = null, $page = 1 ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $filter['page'] = $page; + + $query = $this->query_webhooks( $filter ); + + $webhooks = array(); + + foreach ( $query['results'] as $webhook_id ) { + $webhooks[] = current( $this->get_webhook( $webhook_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query['headers'] ); + + return array( 'webhooks' => $webhooks ); + } + + /** + * Get the webhook for the given ID + * + * @since 2.2 + * @param int $id webhook ID + * @param array $fields + * @return array|WP_Error + */ + public function get_webhook( $id, $fields = null ) { + + // ensure webhook ID is valid & user has permission to read + $id = $this->validate_request( $id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $webhook = wc_get_webhook( $id ); + + $webhook_data = array( + 'id' => $webhook->get_id(), + 'name' => $webhook->get_name(), + 'status' => $webhook->get_status(), + 'topic' => $webhook->get_topic(), + 'resource' => $webhook->get_resource(), + 'event' => $webhook->get_event(), + 'hooks' => $webhook->get_hooks(), + 'delivery_url' => $webhook->get_delivery_url(), + 'created_at' => $this->server->format_datetime( $webhook->get_date_created() ? $webhook->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $webhook->get_date_modified() ? $webhook->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. + ); + + return array( 'webhook' => apply_filters( 'woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this ) ); + } + + /** + * Get the total number of webhooks + * + * @since 2.2 + * + * @param string $status + * @param array $filter + * + * @return array|WP_Error + */ + public function get_webhooks_count( $status = null, $filter = array() ) { + try { + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_webhooks_count', __( 'You do not have permission to read the webhooks count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $query = $this->query_webhooks( $filter ); + + return array( 'count' => $query['headers']->total ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create an webhook + * + * @since 2.2 + * + * @param array $data parsed webhook data + * + * @return array|WP_Error + */ + public function create_webhook( $data ) { + + try { + if ( ! isset( $data['webhook'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_webhook_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'webhook' ), 400 ); + } + + $data = $data['webhook']; + + // permission check + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_webhooks', __( 'You do not have permission to create webhooks.', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_webhook_data', $data, $this ); + + // validate topic + if ( empty( $data['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $data['topic'] ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_topic', __( 'Webhook topic is required and must be valid.', 'woocommerce' ), 400 ); + } + + // validate delivery URL + if ( empty( $data['delivery_url'] ) || ! wc_is_valid_url( $data['delivery_url'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_url', __( 'Webhook delivery URL must be a valid URL starting with http:// or https://', 'woocommerce' ), 400 ); + } + + $webhook_data = apply_filters( 'woocommerce_new_webhook_data', array( + 'post_type' => 'shop_webhook', + 'post_status' => 'publish', + 'ping_status' => 'closed', + 'post_author' => get_current_user_id(), + 'post_password' => strlen( ( $password = uniqid( 'webhook_' ) ) ) > 20 ? substr( $password, 0, 20 ) : $password, + 'post_title' => ! empty( $data['name'] ) ? $data['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ), + ), $data, $this ); + + $webhook = new WC_Webhook(); + + $webhook->set_name( $webhook_data['post_title'] ); + $webhook->set_user_id( $webhook_data['post_author'] ); + $webhook->set_status( 'publish' === $webhook_data['post_status'] ? 'active' : 'disabled' ); + $webhook->set_topic( $data['topic'] ); + $webhook->set_delivery_url( $data['delivery_url'] ); + $webhook->set_secret( ! empty( $data['secret'] ) ? $data['secret'] : wp_generate_password( 50, true, true ) ); + $webhook->set_api_version( 'legacy_v3' ); + $webhook->save(); + + $webhook->deliver_ping(); + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_webhook', $webhook->get_id(), $this ); + + return $this->get_webhook( $webhook->get_id() ); + + } catch ( WC_API_Exception $e ) { + + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a webhook + * + * @since 2.2 + * + * @param int $id webhook ID + * @param array $data parsed webhook data + * + * @return array|WP_Error + */ + public function edit_webhook( $id, $data ) { + + try { + if ( ! isset( $data['webhook'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_webhook_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'webhook' ), 400 ); + } + + $data = $data['webhook']; + + $id = $this->validate_request( $id, 'shop_webhook', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_webhook_data', $data, $id, $this ); + + $webhook = wc_get_webhook( $id ); + + // update topic + if ( ! empty( $data['topic'] ) ) { + + if ( wc_is_webhook_valid_topic( strtolower( $data['topic'] ) ) ) { + + $webhook->set_topic( $data['topic'] ); + + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_topic', __( 'Webhook topic must be valid.', 'woocommerce' ), 400 ); + } + } + + // update delivery URL + if ( ! empty( $data['delivery_url'] ) ) { + if ( wc_is_valid_url( $data['delivery_url'] ) ) { + + $webhook->set_delivery_url( $data['delivery_url'] ); + + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_url', __( 'Webhook delivery URL must be a valid URL starting with http:// or https://', 'woocommerce' ), 400 ); + } + } + + // update secret + if ( ! empty( $data['secret'] ) ) { + $webhook->set_secret( $data['secret'] ); + } + + // update status + if ( ! empty( $data['status'] ) ) { + $webhook->set_status( $data['status'] ); + } + + // update name + if ( ! empty( $data['name'] ) ) { + $webhook->set_name( $data['name'] ); + } + + $webhook->save(); + + do_action( 'woocommerce_api_edit_webhook', $webhook->get_id(), $this ); + + return $this->get_webhook( $webhook->get_id() ); + + } catch ( WC_API_Exception $e ) { + + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a webhook + * + * @since 2.2 + * @param int $id webhook ID + * @return array|WP_Error + */ + public function delete_webhook( $id ) { + + $id = $this->validate_request( $id, 'shop_webhook', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_webhook', $id, $this ); + + $webhook = wc_get_webhook( $id ); + + return $webhook->delete( true ); + } + + /** + * Get webhooks total results + * + * @since 3.3.0 + * @param array $args Request arguments for filtering query. + * @return array + */ + private function get_webhooks_total_results( $args = array() ) { + $data_store = WC_Data_Store::load( 'webhook' ); + $args['limit'] = -1; + $args['offset'] = 0; + + return count( $data_store->search_webhooks( $args ) ); + } + + /** + * Helper method to get webhook post objects + * + * @since 2.2 + * @param array $args Request arguments for filtering query. + * @return array + */ + private function query_webhooks( $args ) { + $args = $this->merge_query_args( array(), $args ); + + $args['limit'] = isset( $args['posts_per_page'] ) ? intval( $args['posts_per_page'] ) : intval( get_option( 'posts_per_page' ) ); + + if ( empty( $args['offset'] ) ) { + $args['offset'] = 1 < $args['paged'] ? ( $args['paged'] - 1 ) * $args['limit'] : 0; + } + + $page = $args['paged']; + unset( $args['paged'], $args['posts_per_page'] ); + + if ( isset( $args['s'] ) ) { + $args['search'] = $args['s']; + unset( $args['s'] ); + } + + // Post type to webhook status. + if ( ! empty( $args['post_status'] ) ) { + $args['status'] = $args['post_status']; + unset( $args['post_status'] ); + } + + if ( ! empty( $args['post__in'] ) ) { + $args['include'] = $args['post__in']; + unset( $args['post__in'] ); + } + + if ( ! empty( $args['date_query'] ) ) { + foreach ( $args['date_query'] as $date_query ) { + if ( 'post_date_gmt' === $date_query['column'] ) { + $args['after'] = isset( $date_query['after'] ) ? $date_query['after'] : null; + $args['before'] = isset( $date_query['before'] ) ? $date_query['before'] : null; + } elseif ( 'post_modified_gmt' === $date_query['column'] ) { + $args['modified_after'] = isset( $date_query['after'] ) ? $date_query['after'] : null; + $args['modified_before'] = isset( $date_query['before'] ) ? $date_query['before'] : null; + } + } + + unset( $args['date_query'] ); + } + + // Get the webhooks. + $data_store = WC_Data_Store::load( 'webhook' ); + $results = $data_store->search_webhooks( $args ); + + // Get total items. + $headers = new stdClass; + $headers->page = $page; + $headers->total = $this->get_webhooks_total_results( $args ); + $headers->is_single = $args['limit'] > $headers->total; + $headers->total_pages = ceil( $headers->total / $args['limit'] ); + + return array( + 'results' => $results, + 'headers' => $headers, + ); + } + + /** + * Get deliveries for a webhook + * + * @since 2.2 + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @param string $webhook_id webhook ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_webhook_deliveries( $webhook_id, $fields = null ) { + + // Ensure ID is valid webhook ID + $webhook_id = $this->validate_request( $webhook_id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $webhook_id ) ) { + return $webhook_id; + } + + return array( 'webhook_deliveries' => array() ); + } + + /** + * Get the delivery log for the given webhook ID and delivery ID + * + * @since 2.2 + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @param string $webhook_id webhook ID + * @param string $id delivery log ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_webhook_delivery( $webhook_id, $id, $fields = null ) { + try { + // Validate webhook ID + $webhook_id = $this->validate_request( $webhook_id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $webhook_id ) ) { + return $webhook_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery ID.', 'woocommerce' ), 404 ); + } + + $webhook = new WC_Webhook( $webhook_id ); + + $log = 0; + + if ( ! $log ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery.', 'woocommerce' ), 400 ); + } + + return array( 'webhook_delivery' => apply_filters( 'woocommerce_api_webhook_delivery_response', array(), $id, $fields, $log, $webhook_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer. + * 2) the ID returns a valid post object and matches the provided post type. + * 3) the current user has the proper permissions to read/edit/delete the post. + * + * @since 3.3.0 + * @param string|int $id The post ID + * @param string $type The post type, either `shop_order`, `shop_coupon`, or `product`. + * @param string $context The context of the request, either `read`, `edit` or `delete`. + * @return int|WP_Error Valid post ID or WP_Error if any of the checks fails. + */ + protected function validate_request( $id, $type, $context ) { + $id = absint( $id ); + + // Validate ID. + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_api_invalid_webhook_id", sprintf( __( 'Invalid %s ID', 'woocommerce' ), $type ), array( 'status' => 404 ) ); + } + + $webhook = wc_get_webhook( $id ); + + if ( null === $webhook ) { + return new WP_Error( "woocommerce_api_no_webhook_found", sprintf( __( 'No %1$s found with the ID equal to %2$s', 'woocommerce' ), 'webhook', $id ), array( 'status' => 404 ) ); + } + + // Validate permissions. + switch ( $context ) { + + case 'read': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_read_webhook", sprintf( __( 'You do not have permission to read this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_edit_webhook", sprintf( __( 'You do not have permission to edit this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_delete_webhook", sprintf( __( 'You do not have permission to delete this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + } + + return $id; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/interface-wc-api-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/interface-wc-api-handler.php new file mode 100644 index 0000000..484f9f5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v2/interface-wc-api-handler.php @@ -0,0 +1,47 @@ +api->server->path ) { + return new WP_User( 0 ); + } + + try { + if ( is_ssl() ) { + $keys = $this->perform_ssl_authentication(); + } else { + $keys = $this->perform_oauth_authentication(); + } + + // Check API key-specific permission + $this->check_api_key_permissions( $keys['permissions'] ); + + $user = $this->get_user_by_id( $keys['user_id'] ); + + $this->update_api_key_last_access( $keys['key_id'] ); + + } catch ( Exception $e ) { + $user = new WP_Error( 'woocommerce_api_authentication_error', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + + return $user; + } + + /** + * SSL-encrypted requests are not subject to sniffing or man-in-the-middle + * attacks, so the request can be authenticated by simply looking up the user + * associated with the given consumer key and confirming the consumer secret + * provided is valid + * + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_ssl_authentication() { + $params = WC()->api->server->params['GET']; + + // if the $_GET parameters are present, use those first + if ( ! empty( $params['consumer_key'] ) && ! empty( $params['consumer_secret'] ) ) { + $keys = $this->get_keys_by_consumer_key( $params['consumer_key'] ); + + if ( ! $this->is_consumer_secret_valid( $keys['consumer_secret'], $params['consumer_secret'] ) ) { + throw new Exception( __( 'Consumer secret is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + // if the above is not present, we will do full basic auth + if ( empty( $_SERVER['PHP_AUTH_USER'] ) || empty( $_SERVER['PHP_AUTH_PW'] ) ) { + $this->exit_with_unauthorized_headers(); + } + + $keys = $this->get_keys_by_consumer_key( $_SERVER['PHP_AUTH_USER'] ); + + if ( ! $this->is_consumer_secret_valid( $keys['consumer_secret'], $_SERVER['PHP_AUTH_PW'] ) ) { + $this->exit_with_unauthorized_headers(); + } + + return $keys; + } + + /** + * If the consumer_key and consumer_secret $_GET parameters are NOT provided + * and the Basic auth headers are either not present or the consumer secret does not match the consumer + * key provided, then return the correct Basic headers and an error message. + * + * @since 2.4 + */ + private function exit_with_unauthorized_headers() { + $auth_message = __( 'WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field.', 'woocommerce' ); + header( 'WWW-Authenticate: Basic realm="' . $auth_message . '"' ); + header( 'HTTP/1.0 401 Unauthorized' ); + throw new Exception( __( 'Consumer Secret is invalid.', 'woocommerce' ), 401 ); + } + + /** + * Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests + * + * This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP + * + * This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions: + * + * 1) There is no token associated with request/responses, only consumer keys/secrets are used + * + * 2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header, + * This is because there is no cross-OS function within PHP to get the raw Authorization header + * + * @link http://tools.ietf.org/html/rfc5849 for the full spec + * @since 2.1 + * @return array + * @throws Exception + */ + private function perform_oauth_authentication() { + + $params = WC()->api->server->params['GET']; + + $param_names = array( 'oauth_consumer_key', 'oauth_timestamp', 'oauth_nonce', 'oauth_signature', 'oauth_signature_method' ); + + // Check for required OAuth parameters + foreach ( $param_names as $param_name ) { + + if ( empty( $params[ $param_name ] ) ) { + throw new Exception( sprintf( __( '%s parameter is missing', 'woocommerce' ), $param_name ), 404 ); + } + } + + // Fetch WP user by consumer key + $keys = $this->get_keys_by_consumer_key( $params['oauth_consumer_key'] ); + + // Perform OAuth validation + $this->check_oauth_signature( $keys, $params ); + $this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] ); + + // Authentication successful, return user + return $keys; + } + + /** + * Return the keys for the given consumer key + * + * @since 2.4.0 + * @param string $consumer_key + * @return array + * @throws Exception + */ + private function get_keys_by_consumer_key( $consumer_key ) { + global $wpdb; + + $consumer_key = wc_api_hash( sanitize_text_field( $consumer_key ) ); + + $keys = $wpdb->get_row( $wpdb->prepare( " + SELECT key_id, user_id, permissions, consumer_key, consumer_secret, nonces + FROM {$wpdb->prefix}woocommerce_api_keys + WHERE consumer_key = '%s' + ", $consumer_key ), ARRAY_A ); + + if ( empty( $keys ) ) { + throw new Exception( __( 'Consumer key is invalid.', 'woocommerce' ), 401 ); + } + + return $keys; + } + + /** + * Get user by ID + * + * @since 2.4.0 + * + * @param int $user_id + * + * @return WP_User + * @throws Exception + */ + private function get_user_by_id( $user_id ) { + $user = get_user_by( 'id', $user_id ); + + if ( ! $user ) { + throw new Exception( __( 'API user is invalid', 'woocommerce' ), 401 ); + } + + return $user; + } + + /** + * Check if the consumer secret provided for the given user is valid + * + * @since 2.1 + * @param string $keys_consumer_secret + * @param string $consumer_secret + * @return bool + */ + private function is_consumer_secret_valid( $keys_consumer_secret, $consumer_secret ) { + return hash_equals( $keys_consumer_secret, $consumer_secret ); + } + + /** + * Verify that the consumer-provided request signature matches our generated signature, this ensures the consumer + * has a valid key/secret + * + * @param array $keys + * @param array $params the request parameters + * @throws Exception + */ + private function check_oauth_signature( $keys, $params ) { + $http_method = strtoupper( WC()->api->server->method ); + + $server_path = WC()->api->server->path; + + // if the requested URL has a trailingslash, make sure our base URL does as well + if ( isset( $_SERVER['REDIRECT_URL'] ) && '/' === substr( $_SERVER['REDIRECT_URL'], -1 ) ) { + $server_path .= '/'; + } + + $base_request_uri = rawurlencode( untrailingslashit( get_woocommerce_api_url( '' ) ) . $server_path ); + + // Get the signature provided by the consumer and remove it from the parameters prior to checking the signature + $consumer_signature = rawurldecode( str_replace( ' ', '+', $params['oauth_signature'] ) ); + unset( $params['oauth_signature'] ); + + // Sort parameters + if ( ! uksort( $params, 'strcmp' ) ) { + throw new Exception( __( 'Invalid signature - failed to sort parameters.', 'woocommerce' ), 401 ); + } + + // Normalize parameter key/values + $params = $this->normalize_parameters( $params ); + $query_parameters = array(); + foreach ( $params as $param_key => $param_value ) { + if ( is_array( $param_value ) ) { + foreach ( $param_value as $param_key_inner => $param_value_inner ) { + $query_parameters[] = $param_key . '%255B' . $param_key_inner . '%255D%3D' . $param_value_inner; + } + } else { + $query_parameters[] = $param_key . '%3D' . $param_value; // join with equals sign + } + } + $query_string = implode( '%26', $query_parameters ); // join with ampersand + + $string_to_sign = $http_method . '&' . $base_request_uri . '&' . $query_string; + + if ( 'HMAC-SHA1' !== $params['oauth_signature_method'] && 'HMAC-SHA256' !== $params['oauth_signature_method'] ) { + throw new Exception( __( 'Invalid signature - signature method is invalid.', 'woocommerce' ), 401 ); + } + + $hash_algorithm = strtolower( str_replace( 'HMAC-', '', $params['oauth_signature_method'] ) ); + + $secret = $keys['consumer_secret'] . '&'; + $signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $secret, true ) ); + + if ( ! hash_equals( $signature, $consumer_signature ) ) { + throw new Exception( __( 'Invalid signature - provided signature does not match.', 'woocommerce' ), 401 ); + } + } + + /** + * Normalize each parameter by assuming each parameter may have already been + * encoded, so attempt to decode, and then re-encode according to RFC 3986 + * + * Note both the key and value is normalized so a filter param like: + * + * 'filter[period]' => 'week' + * + * is encoded to: + * + * 'filter%5Bperiod%5D' => 'week' + * + * This conforms to the OAuth 1.0a spec which indicates the entire query string + * should be URL encoded + * + * @since 2.1 + * @see rawurlencode() + * @param array $parameters un-normalized parameters + * @return array normalized parameters + */ + private function normalize_parameters( $parameters ) { + $keys = WC_API_Authentication::urlencode_rfc3986( array_keys( $parameters ) ); + $values = WC_API_Authentication::urlencode_rfc3986( array_values( $parameters ) ); + $parameters = array_combine( $keys, $values ); + return $parameters; + } + + /** + * Encodes a value according to RFC 3986. Supports multidimensional arrays. + * + * @since 2.4 + * @param string|array $value The value to encode + * @return string|array Encoded values + */ + public static function urlencode_rfc3986( $value ) { + if ( is_array( $value ) ) { + return array_map( array( 'WC_API_Authentication', 'urlencode_rfc3986' ), $value ); + } else { + // Percent symbols (%) must be double-encoded + return str_replace( '%', '%25', rawurlencode( rawurldecode( $value ) ) ); + } + } + + /** + * Verify that the timestamp and nonce provided with the request are valid. This prevents replay attacks where + * an attacker could attempt to re-send an intercepted request at a later time. + * + * - A timestamp is valid if it is within 15 minutes of now + * - A nonce is valid if it has not been used within the last 15 minutes + * + * @param array $keys + * @param int $timestamp the unix timestamp for when the request was made + * @param string $nonce a unique (for the given user) 32 alphanumeric string, consumer-generated + * @throws Exception + */ + private function check_oauth_timestamp_and_nonce( $keys, $timestamp, $nonce ) { + global $wpdb; + + $valid_window = 15 * 60; // 15 minute window + + if ( ( $timestamp < time() - $valid_window ) || ( $timestamp > time() + $valid_window ) ) { + throw new Exception( __( 'Invalid timestamp.', 'woocommerce' ), 401 ); + } + + $used_nonces = maybe_unserialize( $keys['nonces'] ); + + if ( empty( $used_nonces ) ) { + $used_nonces = array(); + } + + if ( in_array( $nonce, $used_nonces ) ) { + throw new Exception( __( 'Invalid nonce - nonce has already been used.', 'woocommerce' ), 401 ); + } + + $used_nonces[ $timestamp ] = $nonce; + + // Remove expired nonces + foreach ( $used_nonces as $nonce_timestamp => $nonce ) { + if ( $nonce_timestamp < ( time() - $valid_window ) ) { + unset( $used_nonces[ $nonce_timestamp ] ); + } + } + + $used_nonces = maybe_serialize( $used_nonces ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'nonces' => $used_nonces ), + array( 'key_id' => $keys['key_id'] ), + array( '%s' ), + array( '%d' ) + ); + } + + /** + * Check that the API keys provided have the proper key-specific permissions to either read or write API resources + * + * @param string $key_permissions + * @throws Exception if the permission check fails + */ + public function check_api_key_permissions( $key_permissions ) { + switch ( WC()->api->server->method ) { + + case 'HEAD': + case 'GET': + if ( 'read' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have read permissions.', 'woocommerce' ), 401 ); + } + break; + + case 'POST': + case 'PUT': + case 'PATCH': + case 'DELETE': + if ( 'write' !== $key_permissions && 'read_write' !== $key_permissions ) { + throw new Exception( __( 'The API key provided does not have write permissions.', 'woocommerce' ), 401 ); + } + break; + } + } + + /** + * Updated API Key last access datetime + * + * @since 2.4.0 + * + * @param int $key_id + */ + private function update_api_key_last_access( $key_id ) { + global $wpdb; + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + array( 'last_access' => current_time( 'mysql' ) ), + array( 'key_id' => $key_id ), + array( '%s' ), + array( '%d' ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-coupons.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-coupons.php new file mode 100644 index 0000000..43c71cb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-coupons.php @@ -0,0 +1,576 @@ + + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /coupons + $routes[ $this->base ] = array( + array( array( $this, 'get_coupons' ), WC_API_Server::READABLE ), + array( array( $this, 'create_coupon' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /coupons/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_coupons_count' ), WC_API_Server::READABLE ), + ); + + # GET/PUT/DELETE /coupons/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_coupon' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_coupon' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_coupon' ), WC_API_SERVER::DELETABLE ), + ); + + # GET /coupons/code/, note that coupon codes can contain spaces, dashes and underscores + $routes[ $this->base . '/code/(?P\w[\w\s\-]*)' ] = array( + array( array( $this, 'get_coupon_by_code' ), WC_API_Server::READABLE ), + ); + + # POST|PUT /coupons/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all coupons + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_coupons( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_coupons( $filter ); + + $coupons = array(); + + foreach ( $query->posts as $coupon_id ) { + + if ( ! $this->is_readable( $coupon_id ) ) { + continue; + } + + $coupons[] = current( $this->get_coupon( $coupon_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'coupons' => $coupons ); + } + + /** + * Get the coupon for the given ID + * + * @since 2.1 + * @param int $id the coupon ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_coupon( $id, $fields = null ) { + try { + + $id = $this->validate_request( $id, 'shop_coupon', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $coupon = new WC_Coupon( $id ); + + if ( 0 === $coupon->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_id', __( 'Invalid coupon ID', 'woocommerce' ), 404 ); + } + + $coupon_data = array( + 'id' => $coupon->get_id(), + 'code' => $coupon->get_code(), + 'type' => $coupon->get_discount_type(), + 'created_at' => $this->server->format_datetime( $coupon->get_date_created() ? $coupon->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $coupon->get_date_modified() ? $coupon->get_date_modified()->getTimestamp() : 0 ), // API gives UTC times. + 'amount' => wc_format_decimal( $coupon->get_amount(), 2 ), + 'individual_use' => $coupon->get_individual_use(), + 'product_ids' => array_map( 'absint', (array) $coupon->get_product_ids() ), + 'exclude_product_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_ids() ), + 'usage_limit' => $coupon->get_usage_limit() ? $coupon->get_usage_limit() : null, + 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, + 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), + 'usage_count' => (int) $coupon->get_usage_count(), + 'expiry_date' => $coupon->get_date_expires() ? $this->server->format_datetime( $coupon->get_date_expires()->getTimestamp() ) : null, // API gives UTC times. + 'enable_free_shipping' => $coupon->get_free_shipping(), + 'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ), + 'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ), + 'exclude_sale_items' => $coupon->get_exclude_sale_items(), + 'minimum_amount' => wc_format_decimal( $coupon->get_minimum_amount(), 2 ), + 'maximum_amount' => wc_format_decimal( $coupon->get_maximum_amount(), 2 ), + 'customer_emails' => $coupon->get_email_restrictions(), + 'description' => $coupon->get_description(), + ); + + return array( 'coupon' => apply_filters( 'woocommerce_api_coupon_response', $coupon_data, $coupon, $fields, $this->server ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of coupons + * + * @since 2.1 + * @param array $filter + * @return array|WP_Error + */ + public function get_coupons_count( $filter = array() ) { + try { + if ( ! current_user_can( 'read_private_shop_coupons' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), 401 ); + } + + $query = $this->query_coupons( $filter ); + + return array( 'count' => (int) $query->found_posts ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the coupon for the given code + * + * @since 2.1 + * @param string $code the coupon code + * @param string $fields fields to include in response + * @return int|WP_Error + */ + public function get_coupon_by_code( $code, $fields = null ) { + global $wpdb; + + try { + $id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1;", $code ) ); + + if ( is_null( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_code', __( 'Invalid coupon code', 'woocommerce' ), 404 ); + } + + return $this->get_coupon( $id, $fields ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a coupon + * + * @since 2.2 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_coupon( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['coupon'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'coupon' ), 400 ); + } + + $data = $data['coupon']; + + // Check user permission + if ( ! current_user_can( 'publish_shop_coupons' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_coupon', __( 'You do not have permission to create coupons', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_coupon_data', $data, $this ); + + // Check if coupon code is specified + if ( ! isset( $data['code'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_code', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'code' ), 400 ); + } + + $coupon_code = wc_format_coupon_code( $data['code'] ); + $id_from_code = wc_get_coupon_id_by_code( $coupon_code ); + + if ( $id_from_code ) { + throw new WC_API_Exception( 'woocommerce_api_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), 400 ); + } + + $defaults = array( + 'type' => 'fixed_cart', + 'amount' => 0, + 'individual_use' => false, + 'product_ids' => array(), + 'exclude_product_ids' => array(), + 'usage_limit' => '', + 'usage_limit_per_user' => '', + 'limit_usage_to_x_items' => '', + 'usage_count' => '', + 'expiry_date' => '', + 'enable_free_shipping' => false, + 'product_category_ids' => array(), + 'exclude_product_category_ids' => array(), + 'exclude_sale_items' => false, + 'minimum_amount' => '', + 'maximum_amount' => '', + 'customer_emails' => array(), + 'description' => '', + ); + + $coupon_data = wp_parse_args( $data, $defaults ); + + // Validate coupon types + if ( ! in_array( wc_clean( $coupon_data['type'] ), array_keys( wc_get_coupon_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_type', sprintf( __( 'Invalid coupon type - the coupon type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_coupon_types() ) ) ), 400 ); + } + + $new_coupon = array( + 'post_title' => $coupon_code, + 'post_content' => '', + 'post_status' => 'publish', + 'post_author' => get_current_user_id(), + 'post_type' => 'shop_coupon', + 'post_excerpt' => $coupon_data['description'], + ); + + $id = wp_insert_post( $new_coupon, true ); + + if ( is_wp_error( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_coupon', $id->get_error_message(), 400 ); + } + + // Set coupon meta + update_post_meta( $id, 'discount_type', $coupon_data['type'] ); + update_post_meta( $id, 'coupon_amount', wc_format_decimal( $coupon_data['amount'] ) ); + update_post_meta( $id, 'individual_use', ( true === $coupon_data['individual_use'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'product_ids', implode( ',', array_filter( array_map( 'intval', $coupon_data['product_ids'] ) ) ) ); + update_post_meta( $id, 'exclude_product_ids', implode( ',', array_filter( array_map( 'intval', $coupon_data['exclude_product_ids'] ) ) ) ); + update_post_meta( $id, 'usage_limit', absint( $coupon_data['usage_limit'] ) ); + update_post_meta( $id, 'usage_limit_per_user', absint( $coupon_data['usage_limit_per_user'] ) ); + update_post_meta( $id, 'limit_usage_to_x_items', absint( $coupon_data['limit_usage_to_x_items'] ) ); + update_post_meta( $id, 'usage_count', absint( $coupon_data['usage_count'] ) ); + update_post_meta( $id, 'expiry_date', $this->get_coupon_expiry_date( wc_clean( $coupon_data['expiry_date'] ) ) ); + update_post_meta( $id, 'date_expires', $this->get_coupon_expiry_date( wc_clean( $coupon_data['expiry_date'] ), true ) ); + update_post_meta( $id, 'free_shipping', ( true === $coupon_data['enable_free_shipping'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'product_categories', array_filter( array_map( 'intval', $coupon_data['product_category_ids'] ) ) ); + update_post_meta( $id, 'exclude_product_categories', array_filter( array_map( 'intval', $coupon_data['exclude_product_category_ids'] ) ) ); + update_post_meta( $id, 'exclude_sale_items', ( true === $coupon_data['exclude_sale_items'] ) ? 'yes' : 'no' ); + update_post_meta( $id, 'minimum_amount', wc_format_decimal( $coupon_data['minimum_amount'] ) ); + update_post_meta( $id, 'maximum_amount', wc_format_decimal( $coupon_data['maximum_amount'] ) ); + update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $coupon_data['customer_emails'] ) ) ); + + do_action( 'woocommerce_api_create_coupon', $id, $data ); + do_action( 'woocommerce_new_coupon', $id ); + + $this->server->send_status( 201 ); + + return $this->get_coupon( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a coupon + * + * @since 2.2 + * + * @param int $id the coupon ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_coupon( $id, $data ) { + + try { + if ( ! isset( $data['coupon'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupon_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'coupon' ), 400 ); + } + + $data = $data['coupon']; + + $id = $this->validate_request( $id, 'shop_coupon', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_coupon_data', $data, $id, $this ); + + if ( isset( $data['code'] ) ) { + global $wpdb; + + $coupon_code = wc_format_coupon_code( $data['code'] ); + $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); + + if ( $id_from_code ) { + throw new WC_API_Exception( 'woocommerce_api_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), 400 ); + } + + $updated = wp_update_post( array( 'ID' => intval( $id ), 'post_title' => $coupon_code ) ); + + if ( 0 === $updated ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_update_coupon', __( 'Failed to update coupon', 'woocommerce' ), 400 ); + } + } + + if ( isset( $data['description'] ) ) { + $updated = wp_update_post( array( 'ID' => intval( $id ), 'post_excerpt' => $data['description'] ) ); + + if ( 0 === $updated ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_update_coupon', __( 'Failed to update coupon', 'woocommerce' ), 400 ); + } + } + + if ( isset( $data['type'] ) ) { + // Validate coupon types + if ( ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_coupon_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_coupon_type', sprintf( __( 'Invalid coupon type - the coupon type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_coupon_types() ) ) ), 400 ); + } + update_post_meta( $id, 'discount_type', $data['type'] ); + } + + if ( isset( $data['amount'] ) ) { + update_post_meta( $id, 'coupon_amount', wc_format_decimal( $data['amount'] ) ); + } + + if ( isset( $data['individual_use'] ) ) { + update_post_meta( $id, 'individual_use', ( true === $data['individual_use'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['product_ids'] ) ) { + update_post_meta( $id, 'product_ids', implode( ',', array_filter( array_map( 'intval', $data['product_ids'] ) ) ) ); + } + + if ( isset( $data['exclude_product_ids'] ) ) { + update_post_meta( $id, 'exclude_product_ids', implode( ',', array_filter( array_map( 'intval', $data['exclude_product_ids'] ) ) ) ); + } + + if ( isset( $data['usage_limit'] ) ) { + update_post_meta( $id, 'usage_limit', absint( $data['usage_limit'] ) ); + } + + if ( isset( $data['usage_limit_per_user'] ) ) { + update_post_meta( $id, 'usage_limit_per_user', absint( $data['usage_limit_per_user'] ) ); + } + + if ( isset( $data['limit_usage_to_x_items'] ) ) { + update_post_meta( $id, 'limit_usage_to_x_items', absint( $data['limit_usage_to_x_items'] ) ); + } + + if ( isset( $data['usage_count'] ) ) { + update_post_meta( $id, 'usage_count', absint( $data['usage_count'] ) ); + } + + if ( isset( $data['expiry_date'] ) ) { + update_post_meta( $id, 'expiry_date', $this->get_coupon_expiry_date( wc_clean( $data['expiry_date'] ) ) ); + update_post_meta( $id, 'date_expires', $this->get_coupon_expiry_date( wc_clean( $data['expiry_date'] ), true ) ); + } + + if ( isset( $data['enable_free_shipping'] ) ) { + update_post_meta( $id, 'free_shipping', ( true === $data['enable_free_shipping'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['product_category_ids'] ) ) { + update_post_meta( $id, 'product_categories', array_filter( array_map( 'intval', $data['product_category_ids'] ) ) ); + } + + if ( isset( $data['exclude_product_category_ids'] ) ) { + update_post_meta( $id, 'exclude_product_categories', array_filter( array_map( 'intval', $data['exclude_product_category_ids'] ) ) ); + } + + if ( isset( $data['exclude_sale_items'] ) ) { + update_post_meta( $id, 'exclude_sale_items', ( true === $data['exclude_sale_items'] ) ? 'yes' : 'no' ); + } + + if ( isset( $data['minimum_amount'] ) ) { + update_post_meta( $id, 'minimum_amount', wc_format_decimal( $data['minimum_amount'] ) ); + } + + if ( isset( $data['maximum_amount'] ) ) { + update_post_meta( $id, 'maximum_amount', wc_format_decimal( $data['maximum_amount'] ) ); + } + + if ( isset( $data['customer_emails'] ) ) { + update_post_meta( $id, 'customer_email', array_filter( array_map( 'sanitize_email', $data['customer_emails'] ) ) ); + } + + do_action( 'woocommerce_api_edit_coupon', $id, $data ); + do_action( 'woocommerce_update_coupon', $id ); + + return $this->get_coupon( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a coupon + * + * @since 2.2 + * + * @param int $id the coupon ID + * @param bool $force true to permanently delete coupon, false to move to trash + * + * @return array|int|WP_Error + */ + public function delete_coupon( $id, $force = false ) { + + $id = $this->validate_request( $id, 'shop_coupon', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_coupon', $id, $this ); + + return $this->delete( $id, 'shop_coupon', ( 'true' === $force ) ); + } + + /** + * expiry_date format + * + * @since 2.3.0 + * @param string $expiry_date + * @param bool $as_timestamp (default: false) + * @return string|int + */ + protected function get_coupon_expiry_date( $expiry_date, $as_timestamp = false ) { + if ( '' != $expiry_date ) { + if ( $as_timestamp ) { + return strtotime( $expiry_date ); + } + + return date( 'Y-m-d', strtotime( $expiry_date ) ); + } + + return ''; + } + + /** + * Helper method to get coupon post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_coupons( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'shop_coupon', + 'post_status' => 'publish', + ); + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Bulk update or insert coupons + * Accepts an array with coupons in the formats supported by + * WC_API_Coupons->create_coupon() and WC_API_Coupons->edit_coupon() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['coupons'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_coupons_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'coupons' ), 400 ); + } + + $data = $data['coupons']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'coupons' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_coupons_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $coupons = array(); + + foreach ( $data as $_coupon ) { + $coupon_id = 0; + + // Try to get the coupon ID + if ( isset( $_coupon['id'] ) ) { + $coupon_id = intval( $_coupon['id'] ); + } + + if ( $coupon_id ) { + + // Coupon exists / edit coupon + $edit = $this->edit_coupon( $coupon_id, array( 'coupon' => $_coupon ) ); + + if ( is_wp_error( $edit ) ) { + $coupons[] = array( + 'id' => $coupon_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $coupons[] = $edit['coupon']; + } + } else { + + // Coupon don't exists / create coupon + $new = $this->create_coupon( array( 'coupon' => $_coupon ) ); + + if ( is_wp_error( $new ) ) { + $coupons[] = array( + 'id' => $coupon_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $coupons[] = $new['coupon']; + } + } + } + + return array( 'coupons' => apply_filters( 'woocommerce_api_coupons_bulk_response', $coupons, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-customers.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-customers.php new file mode 100644 index 0000000..3ae5025 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-customers.php @@ -0,0 +1,829 @@ + + * GET /customers//orders + * + * @since 2.2 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /customers + $routes[ $this->base ] = array( + array( array( $this, 'get_customers' ), WC_API_SERVER::READABLE ), + array( array( $this, 'create_customer' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /customers/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_customers_count' ), WC_API_SERVER::READABLE ), + ); + + # GET/PUT/DELETE /customers/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_customer' ), WC_API_SERVER::READABLE ), + array( array( $this, 'edit_customer' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_customer' ), WC_API_SERVER::DELETABLE ), + ); + + # GET /customers/email/ + $routes[ $this->base . '/email/(?P.+)' ] = array( + array( array( $this, 'get_customer_by_email' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers//orders + $routes[ $this->base . '/(?P\d+)/orders' ] = array( + array( array( $this, 'get_customer_orders' ), WC_API_SERVER::READABLE ), + ); + + # GET /customers//downloads + $routes[ $this->base . '/(?P\d+)/downloads' ] = array( + array( array( $this, 'get_customer_downloads' ), WC_API_SERVER::READABLE ), + ); + + # POST|PUT /customers/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all customers + * + * @since 2.1 + * @param array $fields + * @param array $filter + * @param int $page + * @return array + */ + public function get_customers( $fields = null, $filter = array(), $page = 1 ) { + + $filter['page'] = $page; + + $query = $this->query_customers( $filter ); + + $customers = array(); + + foreach ( $query->get_results() as $user_id ) { + + if ( ! $this->is_readable( $user_id ) ) { + continue; + } + + $customers[] = current( $this->get_customer( $user_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'customers' => $customers ); + } + + /** + * Get the customer for the given ID + * + * @since 2.1 + * @param int $id the customer ID + * @param array $fields + * @return array|WP_Error + */ + public function get_customer( $id, $fields = null ) { + global $wpdb; + + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $customer = new WC_Customer( $id ); + $last_order = $customer->get_last_order(); + $customer_data = array( + 'id' => $customer->get_id(), + 'created_at' => $this->server->format_datetime( $customer->get_date_created() ? $customer->get_date_created()->getTimestamp() : 0 ), // API gives UTC times. + 'last_update' => $this->server->format_datetime( $customer->get_date_modified() ? $customer->get_date_modified()->getTimestamp() : 0 ), // API gives UTC times. + 'email' => $customer->get_email(), + 'first_name' => $customer->get_first_name(), + 'last_name' => $customer->get_last_name(), + 'username' => $customer->get_username(), + 'role' => $customer->get_role(), + 'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null, + 'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->get_date_created() ? $last_order->get_date_created()->getTimestamp() : 0 ) : null, // API gives UTC times. + 'orders_count' => $customer->get_order_count(), + 'total_spent' => wc_format_decimal( $customer->get_total_spent(), 2 ), + 'avatar_url' => $customer->get_avatar_url(), + 'billing_address' => array( + 'first_name' => $customer->get_billing_first_name(), + 'last_name' => $customer->get_billing_last_name(), + 'company' => $customer->get_billing_company(), + 'address_1' => $customer->get_billing_address_1(), + 'address_2' => $customer->get_billing_address_2(), + 'city' => $customer->get_billing_city(), + 'state' => $customer->get_billing_state(), + 'postcode' => $customer->get_billing_postcode(), + 'country' => $customer->get_billing_country(), + 'email' => $customer->get_billing_email(), + 'phone' => $customer->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $customer->get_shipping_first_name(), + 'last_name' => $customer->get_shipping_last_name(), + 'company' => $customer->get_shipping_company(), + 'address_1' => $customer->get_shipping_address_1(), + 'address_2' => $customer->get_shipping_address_2(), + 'city' => $customer->get_shipping_city(), + 'state' => $customer->get_shipping_state(), + 'postcode' => $customer->get_shipping_postcode(), + 'country' => $customer->get_shipping_country(), + ), + ); + + return array( 'customer' => apply_filters( 'woocommerce_api_customer_response', $customer_data, $customer, $fields, $this->server ) ); + } + + /** + * Get the customer for the given email + * + * @since 2.1 + * + * @param string $email the customer email + * @param array $fields + * + * @return array|WP_Error + */ + public function get_customer_by_email( $email, $fields = null ) { + try { + if ( is_email( $email ) ) { + $customer = get_user_by( 'email', $email ); + if ( ! is_object( $customer ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); + } + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); + } + + return $this->get_customer( $customer->ID, $fields ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of customers + * + * @since 2.1 + * + * @param array $filter + * + * @return array|WP_Error + */ + public function get_customers_count( $filter = array() ) { + try { + if ( ! current_user_can( 'list_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), 401 ); + } + + $query = $this->query_customers( $filter ); + + return array( 'count' => $query->get_total() ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get customer billing address fields. + * + * @since 2.2 + * @return array + */ + protected function get_customer_billing_address() { + $billing_address = apply_filters( 'woocommerce_api_customer_billing_address', array( + 'first_name', + 'last_name', + 'company', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + 'email', + 'phone', + ) ); + + return $billing_address; + } + + /** + * Get customer shipping address fields. + * + * @since 2.2 + * @return array + */ + protected function get_customer_shipping_address() { + $shipping_address = apply_filters( 'woocommerce_api_customer_shipping_address', array( + 'first_name', + 'last_name', + 'company', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + ) ); + + return $shipping_address; + } + + /** + * Add/Update customer data. + * + * @since 2.2 + * @param int $id the customer ID + * @param array $data + * @param WC_Customer $customer + */ + protected function update_customer_data( $id, $data, $customer ) { + + // Customer first name. + if ( isset( $data['first_name'] ) ) { + $customer->set_first_name( wc_clean( $data['first_name'] ) ); + } + + // Customer last name. + if ( isset( $data['last_name'] ) ) { + $customer->set_last_name( wc_clean( $data['last_name'] ) ); + } + + // Customer billing address. + if ( isset( $data['billing_address'] ) ) { + foreach ( $this->get_customer_billing_address() as $field ) { + if ( isset( $data['billing_address'][ $field ] ) ) { + if ( is_callable( array( $customer, "set_billing_{$field}" ) ) ) { + $customer->{"set_billing_{$field}"}( $data['billing_address'][ $field ] ); + } else { + $customer->update_meta_data( 'billing_' . $field, wc_clean( $data['billing_address'][ $field ] ) ); + } + } + } + } + + // Customer shipping address. + if ( isset( $data['shipping_address'] ) ) { + foreach ( $this->get_customer_shipping_address() as $field ) { + if ( isset( $data['shipping_address'][ $field ] ) ) { + if ( is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { + $customer->{"set_shipping_{$field}"}( $data['shipping_address'][ $field ] ); + } else { + $customer->update_meta_data( 'shipping_' . $field, wc_clean( $data['shipping_address'][ $field ] ) ); + } + } + } + } + + do_action( 'woocommerce_api_update_customer_data', $id, $data, $customer ); + } + + /** + * Create a customer + * + * @since 2.2 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_customer( $data ) { + try { + if ( ! isset( $data['customer'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'customer' ), 400 ); + } + + $data = $data['customer']; + + // Checks with can create new users. + if ( ! current_user_can( 'create_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_customer', __( 'You do not have permission to create this customer', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_customer_data', $data, $this ); + + // Checks with the email is missing. + if ( ! isset( $data['email'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_email', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'email' ), 400 ); + } + + // Create customer. + $customer = new WC_Customer; + $customer->set_username( ! empty( $data['username'] ) ? $data['username'] : '' ); + $customer->set_password( ! empty( $data['password'] ) ? $data['password'] : '' ); + $customer->set_email( $data['email'] ); + $customer->save(); + + if ( ! $customer->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_customer', __( 'This resource cannot be created.', 'woocommerce' ), 400 ); + } + + // Added customer data. + $this->update_customer_data( $customer->get_id(), $data, $customer ); + $customer->save(); + + do_action( 'woocommerce_api_create_customer', $customer->get_id(), $data ); + + $this->server->send_status( 201 ); + + return $this->get_customer( $customer->get_id() ); + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a customer + * + * @since 2.2 + * + * @param int $id the customer ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_customer( $id, $data ) { + try { + if ( ! isset( $data['customer'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customer_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'customer' ), 400 ); + } + + $data = $data['customer']; + + // Validate the customer ID. + $id = $this->validate_request( $id, 'customer', 'edit' ); + + // Return the validate error. + if ( is_wp_error( $id ) ) { + throw new WC_API_Exception( $id->get_error_code(), $id->get_error_message(), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_customer_data', $data, $this ); + + $customer = new WC_Customer( $id ); + + // Customer email. + if ( isset( $data['email'] ) ) { + $customer->set_email( $data['email'] ); + } + + // Customer password. + if ( isset( $data['password'] ) ) { + $customer->set_password( $data['password'] ); + } + + // Update customer data. + $this->update_customer_data( $customer->get_id(), $data, $customer ); + + $customer->save(); + + do_action( 'woocommerce_api_edit_customer', $customer->get_id(), $data ); + + return $this->get_customer( $customer->get_id() ); + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a customer + * + * @since 2.2 + * @param int $id the customer ID + * @return array|WP_Error + */ + public function delete_customer( $id ) { + + // Validate the customer ID. + $id = $this->validate_request( $id, 'customer', 'delete' ); + + // Return the validate error. + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_customer', $id, $this ); + + return $this->delete( $id, 'customer' ); + } + + /** + * Get the orders for a customer + * + * @since 2.1 + * @param int $id the customer ID + * @param string $fields fields to include in response + * @param array $filter filters + * @return array|WP_Error + */ + public function get_customer_orders( $id, $fields = null, $filter = array() ) { + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $filter['customer_id'] = $id; + $orders = WC()->api->WC_API_Orders->get_orders( $fields, $filter, null, -1 ); + + return $orders; + } + + /** + * Get the available downloads for a customer + * + * @since 2.2 + * @param int $id the customer ID + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_customer_downloads( $id, $fields = null ) { + $id = $this->validate_request( $id, 'customer', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $downloads = array(); + $_downloads = wc_get_customer_available_downloads( $id ); + + foreach ( $_downloads as $key => $download ) { + $downloads[] = array( + 'download_url' => $download['download_url'], + 'download_id' => $download['download_id'], + 'product_id' => $download['product_id'], + 'download_name' => $download['download_name'], + 'order_id' => $download['order_id'], + 'order_key' => $download['order_key'], + 'downloads_remaining' => $download['downloads_remaining'], + 'access_expires' => $download['access_expires'] ? $this->server->format_datetime( $download['access_expires'] ) : null, + 'file' => $download['file'], + ); + } + + return array( 'downloads' => apply_filters( 'woocommerce_api_customer_downloads_response', $downloads, $id, $fields, $this->server ) ); + } + + /** + * Helper method to get customer user objects + * + * Note that WP_User_Query does not have built-in pagination so limit & offset are used to provide limited + * pagination support + * + * The filter for role can only be a single role in a string. + * + * @since 2.3 + * @param array $args request arguments for filtering query + * @return WP_User_Query + */ + private function query_customers( $args = array() ) { + + // default users per page + $users_per_page = get_option( 'posts_per_page' ); + + // Set base query arguments + $query_args = array( + 'fields' => 'ID', + 'role' => 'customer', + 'orderby' => 'registered', + 'number' => $users_per_page, + ); + + // Custom Role + if ( ! empty( $args['role'] ) ) { + $query_args['role'] = $args['role']; + + // Show users on all roles + if ( 'all' === $query_args['role'] ) { + unset( $query_args['role'] ); + } + } + + // Search + if ( ! empty( $args['q'] ) ) { + $query_args['search'] = $args['q']; + } + + // Limit number of users returned + if ( ! empty( $args['limit'] ) ) { + if ( -1 == $args['limit'] ) { + unset( $query_args['number'] ); + } else { + $query_args['number'] = absint( $args['limit'] ); + $users_per_page = absint( $args['limit'] ); + } + } else { + $args['limit'] = $query_args['number']; + } + + // Page + $page = ( isset( $args['page'] ) ) ? absint( $args['page'] ) : 1; + + // Offset + if ( ! empty( $args['offset'] ) ) { + $query_args['offset'] = absint( $args['offset'] ); + } else { + $query_args['offset'] = $users_per_page * ( $page - 1 ); + } + + // Created date + if ( ! empty( $args['created_at_min'] ) ) { + $this->created_at_min = $this->server->parse_datetime( $args['created_at_min'] ); + } + + if ( ! empty( $args['created_at_max'] ) ) { + $this->created_at_max = $this->server->parse_datetime( $args['created_at_max'] ); + } + + // Order (ASC or DESC, ASC by default) + if ( ! empty( $args['order'] ) ) { + $query_args['order'] = $args['order']; + } + + // Order by + if ( ! empty( $args['orderby'] ) ) { + $query_args['orderby'] = $args['orderby']; + + // Allow sorting by meta value + if ( ! empty( $args['orderby_meta_key'] ) ) { + $query_args['meta_key'] = $args['orderby_meta_key']; + } + } + + $query = new WP_User_Query( $query_args ); + + // Helper members for pagination headers + $query->total_pages = ( -1 == $args['limit'] ) ? 1 : ceil( $query->get_total() / $users_per_page ); + $query->page = $page; + + return $query; + } + + /** + * Add customer data to orders + * + * @since 2.1 + * @param $order_data + * @param $order + * @return array + */ + public function add_customer_data( $order_data, $order ) { + + if ( 0 == $order->get_user_id() ) { + + // add customer data from order + $order_data['customer'] = array( + 'id' => 0, + 'email' => $order->get_billing_email(), + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + ); + + } else { + + $order_data['customer'] = current( $this->get_customer( $order->get_user_id() ) ); + } + + return $order_data; + } + + /** + * Modify the WP_User_Query to support filtering on the date the customer was created + * + * @since 2.1 + * @param WP_User_Query $query + */ + public function modify_user_query( $query ) { + + if ( $this->created_at_min ) { + $query->query_where .= sprintf( " AND user_registered >= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%H:%%i:%%s' )", esc_sql( $this->created_at_min ) ); + } + + if ( $this->created_at_max ) { + $query->query_where .= sprintf( " AND user_registered <= STR_TO_DATE( '%s', '%%Y-%%m-%%d %%H:%%i:%%s' )", esc_sql( $this->created_at_max ) ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid WP_User + * 3) the current user has the proper permissions + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * @param integer $id the customer ID + * @param string $type the request type, unused because this method overrides the parent class + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid user ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + try { + $id = absint( $id ); + + // validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Invalid customer ID', 'woocommerce' ), 404 ); + } + + // non-existent IDs return a valid WP_User object with the user ID = 0 + $customer = new WP_User( $id ); + + if ( 0 === $customer->ID ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer', __( 'Invalid customer', 'woocommerce' ), 404 ); + } + + // validate permissions + switch ( $context ) { + + case 'read': + if ( ! current_user_can( 'list_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_customer', __( 'You do not have permission to read this customer', 'woocommerce' ), 401 ); + } + break; + + case 'edit': + if ( ! current_user_can( 'edit_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_customer', __( 'You do not have permission to edit this customer', 'woocommerce' ), 401 ); + } + break; + + case 'delete': + if ( ! current_user_can( 'delete_users' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_customer', __( 'You do not have permission to delete this customer', 'woocommerce' ), 401 ); + } + break; + } + + return $id; + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Check if the current user can read users + * + * @since 2.1 + * @see WC_API_Resource::is_readable() + * @param int|WP_Post $post unused + * @return bool true if the current user can read users, false otherwise + */ + protected function is_readable( $post ) { + return current_user_can( 'list_users' ); + } + + /** + * Bulk update or insert customers + * Accepts an array with customers in the formats supported by + * WC_API_Customers->create_customer() and WC_API_Customers->edit_customer() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['customers'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_customers_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'customers' ), 400 ); + } + + $data = $data['customers']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'customers' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_customers_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $customers = array(); + + foreach ( $data as $_customer ) { + $customer_id = 0; + + // Try to get the customer ID + if ( isset( $_customer['id'] ) ) { + $customer_id = intval( $_customer['id'] ); + } + + if ( $customer_id ) { + + // Customer exists / edit customer + $edit = $this->edit_customer( $customer_id, array( 'customer' => $_customer ) ); + + if ( is_wp_error( $edit ) ) { + $customers[] = array( + 'id' => $customer_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $customers[] = $edit['customer']; + } + } else { + + // Customer don't exists / create customer + $new = $this->create_customer( array( 'customer' => $_customer ) ); + + if ( is_wp_error( $new ) ) { + $customers[] = array( + 'id' => $customer_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $customers[] = $new['customer']; + } + } + } + + return array( 'customers' => apply_filters( 'woocommerce_api_customers_bulk_response', $customers, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-exception.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-exception.php new file mode 100644 index 0000000..834ed04 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-exception.php @@ -0,0 +1,48 @@ +error_code = $error_code; + parent::__construct( $error_message, $http_status_code ); + } + + /** + * Returns the error code + * + * @since 2.2 + * @return string + */ + public function getErrorCode() { + return $this->error_code; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-json-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-json-handler.php new file mode 100644 index 0000000..e19ac15 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-json-handler.php @@ -0,0 +1,78 @@ +api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_disabled', 'message' => __( 'JSONP support is disabled on this site', 'woocommerce' ) ) ); + } + + // Check for invalid characters (only alphanumeric allowed) + if ( preg_match( '/\W/', $_GET['_jsonp'] ) ) { + + WC()->api->server->send_status( 400 ); + + $data = array( array( 'code' => 'woocommerce_api_jsonp_callback_invalid', __( 'The JSONP callback function is invalid', 'woocommerce' ) ) ); + } + + // see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ + WC()->api->server->header( 'X-Content-Type-Options', 'nosniff' ); + + // Prepend '/**/' to mitigate possible JSONP Flash attacks + return '/**/' . $_GET['_jsonp'] . '(' . json_encode( $data ) . ')'; + } + + return json_encode( $data ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-orders.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-orders.php new file mode 100644 index 0000000..5d30676 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-orders.php @@ -0,0 +1,1885 @@ + + * GET /orders//notes + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET|POST /orders + $routes[ $this->base ] = array( + array( array( $this, 'get_orders' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /orders/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_orders_count' ), WC_API_Server::READABLE ), + ); + + # GET /orders/statuses + $routes[ $this->base . '/statuses' ] = array( + array( array( $this, 'get_order_statuses' ), WC_API_Server::READABLE ), + ); + + # GET|PUT|DELETE /orders/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_order' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order' ), WC_API_Server::DELETABLE ), + ); + + # GET|POST /orders//notes + $routes[ $this->base . '/(?P\d+)/notes' ] = array( + array( array( $this, 'get_order_notes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order_note' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET|PUT|DELETE /orders//notes/ + $routes[ $this->base . '/(?P\d+)/notes/(?P\d+)' ] = array( + array( array( $this, 'get_order_note' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order_note' ), WC_API_SERVER::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order_note' ), WC_API_SERVER::DELETABLE ), + ); + + # GET|POST /orders//refunds + $routes[ $this->base . '/(?P\d+)/refunds' ] = array( + array( array( $this, 'get_order_refunds' ), WC_API_Server::READABLE ), + array( array( $this, 'create_order_refund' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET|PUT|DELETE /orders//refunds/ + $routes[ $this->base . '/(?P\d+)/refunds/(?P\d+)' ] = array( + array( array( $this, 'get_order_refund' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_order_refund' ), WC_API_SERVER::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_order_refund' ), WC_API_SERVER::DELETABLE ), + ); + + # POST|PUT /orders/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all orders + * + * @since 2.1 + * @param string $fields + * @param array $filter + * @param string $status + * @param int $page + * @return array + */ + public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $filter['page'] = $page; + + $query = $this->query_orders( $filter ); + + $orders = array(); + + foreach ( $query->posts as $order_id ) { + + if ( ! $this->is_readable( $order_id ) ) { + continue; + } + + $orders[] = current( $this->get_order( $order_id, $fields, $filter ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'orders' => $orders ); + } + + + /** + * Get the order for the given ID. + * + * @since 2.1 + * @param int $id The order ID. + * @param array $fields Request fields. + * @param array $filter Request filters. + * @return array|WP_Error + */ + public function get_order( $id, $fields = null, $filter = array() ) { + + // Ensure order ID is valid & user has permission to read. + $id = $this->validate_request( $id, $this->post_type, 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + // Get the decimal precession. + $dp = ( isset( $filter['dp'] ) ? intval( $filter['dp'] ) : 2 ); + $order = wc_get_order( $id ); + $expand = array(); + + if ( ! empty( $filter['expand'] ) ) { + $expand = explode( ',', $filter['expand'] ); + } + + $order_data = array( + 'id' => $order->get_id(), + 'order_number' => $order->get_order_number(), + 'order_key' => $order->get_order_key(), + 'created_at' => $this->server->format_datetime( $order->get_date_created() ? $order->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $order->get_date_modified() ? $order->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'completed_at' => $this->server->format_datetime( $order->get_date_completed() ? $order->get_date_completed()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'status' => $order->get_status(), + 'currency' => $order->get_currency(), + 'total' => wc_format_decimal( $order->get_total(), $dp ), + 'subtotal' => wc_format_decimal( $order->get_subtotal(), $dp ), + 'total_line_items_quantity' => $order->get_item_count(), + 'total_tax' => wc_format_decimal( $order->get_total_tax(), $dp ), + 'total_shipping' => wc_format_decimal( $order->get_shipping_total(), $dp ), + 'cart_tax' => wc_format_decimal( $order->get_cart_tax(), $dp ), + 'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), $dp ), + 'total_discount' => wc_format_decimal( $order->get_total_discount(), $dp ), + 'shipping_methods' => $order->get_shipping_method(), + 'payment_details' => array( + 'method_id' => $order->get_payment_method(), + 'method_title' => $order->get_payment_method_title(), + 'paid' => ! is_null( $order->get_date_paid() ), + ), + 'billing_address' => array( + 'first_name' => $order->get_billing_first_name(), + 'last_name' => $order->get_billing_last_name(), + 'company' => $order->get_billing_company(), + 'address_1' => $order->get_billing_address_1(), + 'address_2' => $order->get_billing_address_2(), + 'city' => $order->get_billing_city(), + 'state' => $order->get_billing_state(), + 'postcode' => $order->get_billing_postcode(), + 'country' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'phone' => $order->get_billing_phone(), + ), + 'shipping_address' => array( + 'first_name' => $order->get_shipping_first_name(), + 'last_name' => $order->get_shipping_last_name(), + 'company' => $order->get_shipping_company(), + 'address_1' => $order->get_shipping_address_1(), + 'address_2' => $order->get_shipping_address_2(), + 'city' => $order->get_shipping_city(), + 'state' => $order->get_shipping_state(), + 'postcode' => $order->get_shipping_postcode(), + 'country' => $order->get_shipping_country(), + ), + 'note' => $order->get_customer_note(), + 'customer_ip' => $order->get_customer_ip_address(), + 'customer_user_agent' => $order->get_customer_user_agent(), + 'customer_id' => $order->get_user_id(), + 'view_order_url' => $order->get_view_order_url(), + 'line_items' => array(), + 'shipping_lines' => array(), + 'tax_lines' => array(), + 'fee_lines' => array(), + 'coupon_lines' => array(), + ); + + // Add line items. + foreach ( $order->get_items() as $item_id => $item ) { + $product = $item->get_product(); + $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; + $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + foreach ( $item_meta as $key => $values ) { + $item_meta[ $key ]->label = $values->display_key; + unset( $item_meta[ $key ]->display_key ); + unset( $item_meta[ $key ]->display_value ); + } + + $line_item = array( + 'id' => $item_id, + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ), + 'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ), + 'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ), + 'total_tax' => wc_format_decimal( $item->get_total_tax(), $dp ), + 'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ), + 'quantity' => $item->get_quantity(), + 'tax_class' => $item->get_tax_class(), + 'name' => $item->get_name(), + 'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), + 'sku' => is_object( $product ) ? $product->get_sku() : null, + 'meta' => array_values( $item_meta ), + ); + + if ( in_array( 'products', $expand ) && is_object( $product ) ) { + $_product_data = WC()->api->WC_API_Products->get_product( $product->get_id() ); + + if ( isset( $_product_data['product'] ) ) { + $line_item['product_data'] = $_product_data['product']; + } + } + + $order_data['line_items'][] = $line_item; + } + + // Add shipping. + foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) { + $order_data['shipping_lines'][] = array( + 'id' => $shipping_item_id, + 'method_id' => $shipping_item->get_method_id(), + 'method_title' => $shipping_item->get_name(), + 'total' => wc_format_decimal( $shipping_item->get_total(), $dp ), + ); + } + + // Add taxes. + foreach ( $order->get_tax_totals() as $tax_code => $tax ) { + $tax_line = array( + 'id' => $tax->id, + 'rate_id' => $tax->rate_id, + 'code' => $tax_code, + 'title' => $tax->label, + 'total' => wc_format_decimal( $tax->amount, $dp ), + 'compound' => (bool) $tax->is_compound, + ); + + if ( in_array( 'taxes', $expand ) ) { + $_rate_data = WC()->api->WC_API_Taxes->get_tax( $tax->rate_id ); + + if ( isset( $_rate_data['tax'] ) ) { + $tax_line['rate_data'] = $_rate_data['tax']; + } + } + + $order_data['tax_lines'][] = $tax_line; + } + + // Add fees. + foreach ( $order->get_fees() as $fee_item_id => $fee_item ) { + $order_data['fee_lines'][] = array( + 'id' => $fee_item_id, + 'title' => $fee_item->get_name(), + 'tax_class' => $fee_item->get_tax_class(), + 'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ), + ); + } + + // Add coupons. + foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) { + $coupon_line = array( + 'id' => $coupon_item_id, + 'code' => $coupon_item->get_code(), + 'amount' => wc_format_decimal( $coupon_item->get_discount(), $dp ), + ); + + if ( in_array( 'coupons', $expand ) ) { + $_coupon_data = WC()->api->WC_API_Coupons->get_coupon_by_code( $coupon_item->get_code() ); + + if ( ! is_wp_error( $_coupon_data ) && isset( $_coupon_data['coupon'] ) ) { + $coupon_line['coupon_data'] = $_coupon_data['coupon']; + } + } + + $order_data['coupon_lines'][] = $coupon_line; + } + + return array( 'order' => apply_filters( 'woocommerce_api_order_response', $order_data, $order, $fields, $this->server ) ); + } + + /** + * Get the total number of orders + * + * @since 2.4 + * + * @param string $status + * @param array $filter + * + * @return array|WP_Error + */ + public function get_orders_count( $status = null, $filter = array() ) { + + try { + if ( ! current_user_can( 'read_private_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $status ) ) { + + if ( 'any' === $status ) { + + $order_statuses = array(); + + foreach ( wc_get_order_statuses() as $slug => $name ) { + $filter['status'] = str_replace( 'wc-', '', $slug ); + $query = $this->query_orders( $filter ); + $order_statuses[ str_replace( 'wc-', '', $slug ) ] = (int) $query->found_posts; + } + + return array( 'count' => $order_statuses ); + + } else { + $filter['status'] = $status; + } + } + + $query = $this->query_orders( $filter ); + + return array( 'count' => (int) $query->found_posts ); + + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a list of valid order statuses + * + * Note this requires no specific permissions other than being an authenticated + * API user. Order statuses (particularly custom statuses) could be considered + * private information which is why it's not in the API index. + * + * @since 2.1 + * @return array + */ + public function get_order_statuses() { + + $order_statuses = array(); + + foreach ( wc_get_order_statuses() as $slug => $name ) { + $order_statuses[ str_replace( 'wc-', '', $slug ) ] = $name; + } + + return array( 'order_statuses' => apply_filters( 'woocommerce_api_order_statuses_response', $order_statuses, $this ) ); + } + + /** + * Create an order + * + * @since 2.2 + * + * @param array $data raw order data + * + * @return array|WP_Error + */ + public function create_order( $data ) { + global $wpdb; + + wc_transaction_query( 'start' ); + + try { + if ( ! isset( $data['order'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order' ), 400 ); + } + + $data = $data['order']; + + // permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order', __( 'You do not have permission to create orders', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_order_data', $data, $this ); + + // default order args, note that status is checked for validity in wc_create_order() + $default_order_args = array( + 'status' => isset( $data['status'] ) ? $data['status'] : '', + 'customer_note' => isset( $data['note'] ) ? $data['note'] : null, + ); + + // if creating order for existing customer + if ( ! empty( $data['customer_id'] ) ) { + + // make sure customer exists + if ( false === get_user_by( 'id', $data['customer_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + $default_order_args['customer_id'] = $data['customer_id']; + } + + // create the pending order + $order = $this->create_base_order( $default_order_args, $data ); + + if ( is_wp_error( $order ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order', sprintf( __( 'Cannot create order: %s', 'woocommerce' ), implode( ', ', $order->get_error_messages() ) ), 400 ); + } + + // billing/shipping addresses + $this->set_order_addresses( $order, $data ); + + $lines = array( + 'line_item' => 'line_items', + 'shipping' => 'shipping_lines', + 'fee' => 'fee_lines', + 'coupon' => 'coupon_lines', + ); + + foreach ( $lines as $line_type => $line ) { + + if ( isset( $data[ $line ] ) && is_array( $data[ $line ] ) ) { + + $set_item = "set_{$line_type}"; + + foreach ( $data[ $line ] as $item ) { + + $this->$set_item( $order, $item, 'create' ); + } + } + } + + // set is vat exempt + if ( isset( $data['is_vat_exempt'] ) ) { + update_post_meta( $order->get_id(), '_is_vat_exempt', $data['is_vat_exempt'] ? 'yes' : 'no' ); + } + + // calculate totals and set them + $order->calculate_totals(); + + // payment method (and payment_complete() if `paid` == true) + if ( isset( $data['payment_details'] ) && is_array( $data['payment_details'] ) ) { + + // method ID & title are required + if ( empty( $data['payment_details']['method_id'] ) || empty( $data['payment_details']['method_title'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_payment_details', __( 'Payment method ID and title are required', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] ); + update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] ); + + // mark as paid if set + if ( isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) { + $order->payment_complete( isset( $data['payment_details']['transaction_id'] ) ? $data['payment_details']['transaction_id'] : '' ); + } + } + + // set order currency + if ( isset( $data['currency'] ) ) { + + if ( ! array_key_exists( $data['currency'], get_woocommerce_currencies() ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_order_currency', $data['currency'] ); + } + + // set order meta + if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) { + $this->set_order_meta( $order->get_id(), $data['order_meta'] ); + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + wc_delete_shop_order_transients( $order ); + + do_action( 'woocommerce_api_create_order', $order->get_id(), $data, $this ); + do_action( 'woocommerce_new_order', $order->get_id() ); + + wc_transaction_query( 'commit' ); + + return $this->get_order( $order->get_id() ); + + } catch ( WC_Data_Exception $e ) { + wc_transaction_query( 'rollback' ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + wc_transaction_query( 'rollback' ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Creates new WC_Order. + * + * Requires a separate function for classes that extend WC_API_Orders. + * + * @since 2.3 + * + * @param $args array + * @param $data + * + * @return WC_Order + */ + protected function create_base_order( $args, $data ) { + return wc_create_order( $args ); + } + + /** + * Edit an order + * + * @since 2.2 + * @param int $id the order ID + * @param array $data + * @return array|WP_Error + */ + public function edit_order( $id, $data ) { + try { + if ( ! isset( $data['order'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order' ), 400 ); + } + + $data = $data['order']; + + $update_totals = false; + + $id = $this->validate_request( $id, $this->post_type, 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_order_data', $data, $id, $this ); + $order = wc_get_order( $id ); + + if ( empty( $order ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 ); + } + + $order_args = array( 'order_id' => $order->get_id() ); + + // Customer note. + if ( isset( $data['note'] ) ) { + $order_args['customer_note'] = $data['note']; + } + + // Customer ID. + if ( isset( $data['customer_id'] ) && $data['customer_id'] != $order->get_user_id() ) { + // Make sure customer exists. + if ( false === get_user_by( 'id', $data['customer_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_customer_user', $data['customer_id'] ); + } + + // Billing/shipping address. + $this->set_order_addresses( $order, $data ); + + $lines = array( + 'line_item' => 'line_items', + 'shipping' => 'shipping_lines', + 'fee' => 'fee_lines', + 'coupon' => 'coupon_lines', + ); + + foreach ( $lines as $line_type => $line ) { + + if ( isset( $data[ $line ] ) && is_array( $data[ $line ] ) ) { + + $update_totals = true; + + foreach ( $data[ $line ] as $item ) { + // Item ID is always required. + if ( ! array_key_exists( 'id', $item ) ) { + $item['id'] = null; + } + + // Create item. + if ( is_null( $item['id'] ) ) { + $this->set_item( $order, $line_type, $item, 'create' ); + } elseif ( $this->item_is_null( $item ) ) { + // Delete item. + wc_delete_order_item( $item['id'] ); + } else { + // Update item. + $this->set_item( $order, $line_type, $item, 'update' ); + } + } + } + } + + // Payment method (and payment_complete() if `paid` == true and order needs payment). + if ( isset( $data['payment_details'] ) && is_array( $data['payment_details'] ) ) { + + // Method ID. + if ( isset( $data['payment_details']['method_id'] ) ) { + update_post_meta( $order->get_id(), '_payment_method', $data['payment_details']['method_id'] ); + } + + // Method title. + if ( isset( $data['payment_details']['method_title'] ) ) { + update_post_meta( $order->get_id(), '_payment_method_title', $data['payment_details']['method_title'] ); + } + + // Mark as paid if set. + if ( $order->needs_payment() && isset( $data['payment_details']['paid'] ) && true === $data['payment_details']['paid'] ) { + $order->payment_complete( isset( $data['payment_details']['transaction_id'] ) ? $data['payment_details']['transaction_id'] : '' ); + } + } + + // Set order currency. + if ( isset( $data['currency'] ) ) { + if ( ! array_key_exists( $data['currency'], get_woocommerce_currencies() ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_order_currency', __( 'Provided order currency is invalid.', 'woocommerce' ), 400 ); + } + + update_post_meta( $order->get_id(), '_order_currency', $data['currency'] ); + } + + // If items have changed, recalculate order totals. + if ( $update_totals ) { + $order->calculate_totals(); + } + + // Update order meta. + if ( isset( $data['order_meta'] ) && is_array( $data['order_meta'] ) ) { + $this->set_order_meta( $order->get_id(), $data['order_meta'] ); + } + + // Update the order post to set customer note/modified date. + wc_update_order( $order_args ); + + // Order status. + if ( ! empty( $data['status'] ) ) { + // Refresh the order instance. + $order = wc_get_order( $order->get_id() ); + $order->update_status( $data['status'], isset( $data['status_note'] ) ? $data['status_note'] : '', true ); + } + + wc_delete_shop_order_transients( $order ); + + do_action( 'woocommerce_api_edit_order', $order->get_id(), $data, $this ); + do_action( 'woocommerce_update_order', $order->get_id() ); + + return $this->get_order( $id ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete an order + * + * @param int $id the order ID + * @param bool $force true to permanently delete order, false to move to trash + * @return array|WP_Error + */ + public function delete_order( $id, $force = false ) { + + $id = $this->validate_request( $id, $this->post_type, 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + wc_delete_shop_order_transients( $id ); + + do_action( 'woocommerce_api_delete_order', $id, $this ); + + return $this->delete( $id, 'order', ( 'true' === $force ) ); + } + + /** + * Helper method to get order post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + protected function query_orders( $args ) { + + // set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => $this->post_type, + 'post_status' => array_keys( wc_get_order_statuses() ), + ); + + // add status argument + if ( ! empty( $args['status'] ) ) { + $statuses = 'wc-' . str_replace( ',', ',wc-', $args['status'] ); + $statuses = explode( ',', $statuses ); + $query_args['post_status'] = $statuses; + + unset( $args['status'] ); + } + + if ( ! empty( $args['customer_id'] ) ) { + $query_args['meta_query'] = array( + array( + 'key' => '_customer_user', + 'value' => absint( $args['customer_id'] ), + 'compare' => '=', + ), + ); + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Helper method to set/update the billing & shipping addresses for + * an order + * + * @since 2.1 + * @param \WC_Order $order + * @param array $data + */ + protected function set_order_addresses( $order, $data ) { + + $address_fields = array( + 'first_name', + 'last_name', + 'company', + 'email', + 'phone', + 'address_1', + 'address_2', + 'city', + 'state', + 'postcode', + 'country', + ); + + $billing_address = $shipping_address = array(); + + // billing address + if ( isset( $data['billing_address'] ) && is_array( $data['billing_address'] ) ) { + + foreach ( $address_fields as $field ) { + + if ( isset( $data['billing_address'][ $field ] ) ) { + $billing_address[ $field ] = wc_clean( $data['billing_address'][ $field ] ); + } + } + + unset( $address_fields['email'] ); + unset( $address_fields['phone'] ); + } + + // shipping address + if ( isset( $data['shipping_address'] ) && is_array( $data['shipping_address'] ) ) { + + foreach ( $address_fields as $field ) { + + if ( isset( $data['shipping_address'][ $field ] ) ) { + $shipping_address[ $field ] = wc_clean( $data['shipping_address'][ $field ] ); + } + } + } + + $this->update_address( $order, $billing_address, 'billing' ); + $this->update_address( $order, $shipping_address, 'shipping' ); + + // update user meta + if ( $order->get_user_id() ) { + foreach ( $billing_address as $key => $value ) { + update_user_meta( $order->get_user_id(), 'billing_' . $key, $value ); + } + foreach ( $shipping_address as $key => $value ) { + update_user_meta( $order->get_user_id(), 'shipping_' . $key, $value ); + } + } + } + + /** + * Update address. + * + * @param WC_Order $order + * @param array $posted + * @param string $type + */ + protected function update_address( $order, $posted, $type = 'billing' ) { + foreach ( $posted as $key => $value ) { + if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) { + $order->{"set_{$type}_{$key}"}( $value ); + } + } + } + + /** + * Helper method to add/update order meta, with two restrictions: + * + * 1) Only non-protected meta (no leading underscore) can be set + * 2) Meta values must be scalar (int, string, bool) + * + * @since 2.2 + * @param int $order_id valid order ID + * @param array $order_meta order meta in array( 'meta_key' => 'meta_value' ) format + */ + protected function set_order_meta( $order_id, $order_meta ) { + + foreach ( $order_meta as $meta_key => $meta_value ) { + + if ( is_string( $meta_key ) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) { + update_post_meta( $order_id, $meta_key, $meta_value ); + } + } + } + + /** + * Helper method to check if the resource ID associated with the provided item is null + * + * Items can be deleted by setting the resource ID to null + * + * @since 2.2 + * @param array $item item provided in the request body + * @return bool true if the item resource ID is null, false otherwise + */ + protected function item_is_null( $item ) { + + $keys = array( 'product_id', 'method_id', 'title', 'code' ); + + foreach ( $keys as $key ) { + if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { + return true; + } + } + + return false; + } + + /** + * Wrapper method to create/update order items + * + * When updating, the item ID provided is checked to ensure it is associated + * with the order. + * + * @since 2.2 + * @param \WC_Order $order order + * @param string $item_type + * @param array $item item provided in the request body + * @param string $action either 'create' or 'update' + * @throws WC_API_Exception if item ID is not associated with order + */ + protected function set_item( $order, $item_type, $item, $action ) { + global $wpdb; + + $set_method = "set_{$item_type}"; + + // verify provided line item ID is associated with order + if ( 'update' === $action ) { + + $result = $wpdb->get_row( + $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d", + absint( $item['id'] ), + absint( $order->get_id() ) + ) ); + + if ( is_null( $result ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 ); + } + } + + $this->$set_method( $order, $item, $action ); + } + + /** + * Create or update a line item + * + * @since 2.2 + * @param \WC_Order $order + * @param array $item line item data + * @param string $action 'create' to add line item or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_line_item( $order, $item, $action ) { + $creating = ( 'create' === $action ); + + // product is always required + if ( ! isset( $item['product_id'] ) && ! isset( $item['sku'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_id', __( 'Product ID or SKU is required', 'woocommerce' ), 400 ); + } + + // when updating, ensure product ID provided matches + if ( 'update' === $action ) { + + $item_product_id = wc_get_order_item_meta( $item['id'], '_product_id' ); + $item_variation_id = wc_get_order_item_meta( $item['id'], '_variation_id' ); + + if ( $item['product_id'] != $item_product_id && $item['product_id'] != $item_variation_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_id', __( 'Product ID provided does not match this line item', 'woocommerce' ), 400 ); + } + } + + if ( isset( $item['product_id'] ) ) { + $product_id = $item['product_id']; + } elseif ( isset( $item['sku'] ) ) { + $product_id = wc_get_product_id_by_sku( $item['sku'] ); + } + + // variations must each have a key & value + $variation_id = 0; + if ( isset( $item['variations'] ) && is_array( $item['variations'] ) ) { + foreach ( $item['variations'] as $key => $value ) { + if ( ! $key || ! $value ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_variation', __( 'The product variation is invalid', 'woocommerce' ), 400 ); + } + } + $variation_id = $this->get_variation_id( wc_get_product( $product_id ), $item['variations'] ); + } + + $product = wc_get_product( $variation_id ? $variation_id : $product_id ); + + // must be a valid WC_Product + if ( ! is_object( $product ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product', __( 'Product is invalid.', 'woocommerce' ), 400 ); + } + + // quantity must be positive float + if ( isset( $item['quantity'] ) && floatval( $item['quantity'] ) <= 0 ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_quantity', __( 'Product quantity must be a positive float.', 'woocommerce' ), 400 ); + } + + // quantity is required when creating + if ( $creating && ! isset( $item['quantity'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_quantity', __( 'Product quantity is required.', 'woocommerce' ), 400 ); + } + + // quantity + if ( $creating ) { + $line_item = new WC_Order_Item_Product(); + } else { + $line_item = new WC_Order_Item_Product( $item['id'] ); + } + + $line_item->set_product( $product ); + $line_item->set_order_id( $order->get_id() ); + + if ( isset( $item['quantity'] ) ) { + $line_item->set_quantity( $item['quantity'] ); + } + if ( isset( $item['total'] ) ) { + $line_item->set_total( floatval( $item['total'] ) ); + } elseif ( $creating ) { + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $line_item->get_quantity() ) ); + $line_item->set_total( $total ); + $line_item->set_subtotal( $total ); + } + if ( isset( $item['total_tax'] ) ) { + $line_item->set_total_tax( floatval( $item['total_tax'] ) ); + } + if ( isset( $item['subtotal'] ) ) { + $line_item->set_subtotal( floatval( $item['subtotal'] ) ); + } + if ( isset( $item['subtotal_tax'] ) ) { + $line_item->set_subtotal_tax( floatval( $item['subtotal_tax'] ) ); + } + if ( $variation_id ) { + $line_item->set_variation_id( $variation_id ); + $line_item->set_variation( $item['variations'] ); + } + + // Save or add to order. + if ( $creating ) { + $order->add_item( $line_item ); + } else { + $item_id = $line_item->save(); + + if ( ! $item_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Given a product ID & API provided variations, find the correct variation ID to use for calculation + * We can't just trust input from the API to pass a variation_id manually, otherwise you could pass + * the cheapest variation ID but provide other information so we have to look up the variation ID. + * + * @param WC_Product $product Product instance + * @param array $variations + * + * @return int Returns an ID if a valid variation was found for this product + */ + public function get_variation_id( $product, $variations = array() ) { + $variation_id = null; + $variations_normalized = array(); + + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + if ( isset( $variations ) && is_array( $variations ) ) { + // start by normalizing the passed variations + foreach ( $variations as $key => $value ) { + $key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); // from get_attributes in class-wc-api-products.php + $variations_normalized[ $key ] = strtolower( $value ); + } + // now search through each product child and see if our passed variations match anything + foreach ( $product->get_children() as $variation ) { + $meta = array(); + foreach ( get_post_meta( $variation ) as $key => $value ) { + $value = $value[0]; + $key = str_replace( 'attribute_', '', str_replace( 'pa_', '', $key ) ); + $meta[ $key ] = strtolower( $value ); + } + // if the variation array is a part of the $meta array, we found our match + if ( $this->array_contains( $variations_normalized, $meta ) ) { + $variation_id = $variation; + break; + } + } + } + } + + return $variation_id; + } + + /** + * Utility function to see if the meta array contains data from variations + * + * @param array $needles + * @param array $haystack + * + * @return bool + */ + protected function array_contains( $needles, $haystack ) { + foreach ( $needles as $key => $value ) { + if ( $haystack[ $key ] !== $value ) { + return false; + } + } + return true; + } + + /** + * Create or update an order shipping method + * + * @since 2.2 + * @param \WC_Order $order + * @param array $shipping item data + * @param string $action 'create' to add shipping or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_shipping( $order, $shipping, $action ) { + + // total must be a positive float + if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) { + throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 ); + } + + if ( 'create' === $action ) { + + // method ID is required + if ( ! isset( $shipping['method_id'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 ); + } + + $rate = new WC_Shipping_Rate( $shipping['method_id'], isset( $shipping['method_title'] ) ? $shipping['method_title'] : '', isset( $shipping['total'] ) ? floatval( $shipping['total'] ) : 0, array(), $shipping['method_id'] ); + $item = new WC_Order_Item_Shipping(); + $item->set_order_id( $order->get_id() ); + $item->set_shipping_rate( $rate ); + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Shipping( $shipping['id'] ); + + if ( isset( $shipping['method_id'] ) ) { + $item->set_method_id( $shipping['method_id'] ); + } + + if ( isset( $shipping['method_title'] ) ) { + $item->set_method_title( $shipping['method_title'] ); + } + + if ( isset( $shipping['total'] ) ) { + $item->set_total( floatval( $shipping['total'] ) ); + } + + $shipping_id = $item->save(); + + if ( ! $shipping_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_shipping', __( 'Cannot update shipping method, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Create or update an order fee + * + * @since 2.2 + * @param \WC_Order $order + * @param array $fee item data + * @param string $action 'create' to add fee or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_fee( $order, $fee, $action ) { + + if ( 'create' === $action ) { + + // fee title is required + if ( ! isset( $fee['title'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_fee_item', __( 'Fee title is required', 'woocommerce' ), 400 ); + } + + $item = new WC_Order_Item_Fee(); + $item->set_order_id( $order->get_id() ); + $item->set_name( wc_clean( $fee['title'] ) ); + $item->set_total( isset( $fee['total'] ) ? floatval( $fee['total'] ) : 0 ); + + // if taxable, tax class and total are required + if ( ! empty( $fee['taxable'] ) ) { + if ( ! isset( $fee['tax_class'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_fee_item', __( 'Fee tax class is required when fee is taxable.', 'woocommerce' ), 400 ); + } + + $item->set_tax_status( 'taxable' ); + $item->set_tax_class( $fee['tax_class'] ); + + if ( isset( $fee['total_tax'] ) ) { + $item->set_total_tax( isset( $fee['total_tax'] ) ? wc_format_refund_total( $fee['total_tax'] ) : 0 ); + } + + if ( isset( $fee['tax_data'] ) ) { + $item->set_total_tax( wc_format_refund_total( array_sum( $fee['tax_data'] ) ) ); + $item->set_taxes( array_map( 'wc_format_refund_total', $fee['tax_data'] ) ); + } + } + + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Fee( $fee['id'] ); + + if ( isset( $fee['title'] ) ) { + $item->set_name( wc_clean( $fee['title'] ) ); + } + + if ( isset( $fee['tax_class'] ) ) { + $item->set_tax_class( $fee['tax_class'] ); + } + + if ( isset( $fee['total'] ) ) { + $item->set_total( floatval( $fee['total'] ) ); + } + + if ( isset( $fee['total_tax'] ) ) { + $item->set_total_tax( floatval( $fee['total_tax'] ) ); + } + + $fee_id = $item->save(); + + if ( ! $fee_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_fee', __( 'Cannot update fee, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Create or update an order coupon + * + * @since 2.2 + * @param \WC_Order $order + * @param array $coupon item data + * @param string $action 'create' to add coupon or 'update' to update it + * @throws WC_API_Exception invalid data, server error + */ + protected function set_coupon( $order, $coupon, $action ) { + + // coupon amount must be positive float + if ( isset( $coupon['amount'] ) && floatval( $coupon['amount'] ) < 0 ) { + throw new WC_API_Exception( 'woocommerce_invalid_coupon_total', __( 'Coupon discount total must be a positive amount.', 'woocommerce' ), 400 ); + } + + if ( 'create' === $action ) { + + // coupon code is required + if ( empty( $coupon['code'] ) ) { + throw new WC_API_Exception( 'woocommerce_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); + } + + $item = new WC_Order_Item_Coupon(); + $item->set_props( array( + 'code' => $coupon['code'], + 'discount' => isset( $coupon['amount'] ) ? floatval( $coupon['amount'] ) : 0, + 'discount_tax' => 0, + 'order_id' => $order->get_id(), + ) ); + $order->add_item( $item ); + } else { + + $item = new WC_Order_Item_Coupon( $coupon['id'] ); + + if ( isset( $coupon['code'] ) ) { + $item->set_code( $coupon['code'] ); + } + + if ( isset( $coupon['amount'] ) ) { + $item->set_discount( floatval( $coupon['amount'] ) ); + } + + $coupon_id = $item->save(); + + if ( ! $coupon_id ) { + throw new WC_API_Exception( 'woocommerce_cannot_update_order_coupon', __( 'Cannot update coupon, try again.', 'woocommerce' ), 500 ); + } + } + } + + /** + * Get the admin order notes for an order + * + * @since 2.1 + * @param string $order_id order ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_order_notes( $order_id, $fields = null ) { + + // ensure ID is valid order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $args = array( + 'post_id' => $order_id, + 'approve' => 'approve', + 'type' => 'order_note', + ); + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $notes = get_comments( $args ); + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $order_notes = array(); + + foreach ( $notes as $note ) { + + $order_notes[] = current( $this->get_order_note( $order_id, $note->comment_ID, $fields ) ); + } + + return array( 'order_notes' => apply_filters( 'woocommerce_api_order_notes_response', $order_notes, $order_id, $fields, $notes, $this->server ) ); + } + + /** + * Get an order note for the given order ID and ID + * + * @since 2.2 + * + * @param string $order_id order ID + * @param string $id order note ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_order_note( $order_id, $id, $fields = null ) { + try { + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $order_note = array( + 'id' => $note->comment_ID, + 'created_at' => $this->server->format_datetime( $note->comment_date_gmt ), + 'note' => $note->comment_content, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), + ); + + return array( 'order_note' => apply_filters( 'woocommerce_api_order_note_response', $order_note, $id, $fields, $note, $order_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new order note for the given order + * + * @since 2.2 + * @param string $order_id order ID + * @param array $data raw request data + * @return WP_Error|array error or created note response data + */ + public function create_order_note( $order_id, $data ) { + try { + if ( ! isset( $data['order_note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_note' ), 400 ); + } + + $data = $data['order_note']; + + // permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order_note', __( 'You do not have permission to create order notes', 'woocommerce' ), 401 ); + } + + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $order = wc_get_order( $order_id ); + + $data = apply_filters( 'woocommerce_api_create_order_note_data', $data, $order_id, $this ); + + // note content is required + if ( ! isset( $data['note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note', __( 'Order note is required', 'woocommerce' ), 400 ); + } + + $is_customer_note = ( isset( $data['customer_note'] ) && true === $data['customer_note'] ); + + // create the note + $note_id = $order->add_order_note( $data['note'], $is_customer_note ); + + if ( ! $note_id ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce' ), 500 ); + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_order_note', $note_id, $order_id, $this ); + + return $this->get_order_note( $order->get_id(), $note_id ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit the order note + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id note ID + * @param array $data parsed request data + * @return WP_Error|array error or edited note response data + */ + public function edit_order_note( $order_id, $id, $data ) { + try { + if ( ! isset( $data['order_note'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_note' ), 400 ); + } + + $data = $data['order_note']; + + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $order = wc_get_order( $order_id ); + + // Validate note ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + // Ensure note ID is valid + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + // Ensure note ID is associated with given order + if ( $note->comment_post_ID != $order->get_id() ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_order_note_data', $data, $note->comment_ID, $order->get_id(), $this ); + + // Note content + if ( isset( $data['note'] ) ) { + + wp_update_comment( + array( + 'comment_ID' => $note->comment_ID, + 'comment_content' => $data['note'], + ) + ); + } + + // Customer note + if ( isset( $data['customer_note'] ) ) { + + update_comment_meta( $note->comment_ID, 'is_customer_note', true === $data['customer_note'] ? 1 : 0 ); + } + + do_action( 'woocommerce_api_edit_order_note', $note->comment_ID, $order->get_id(), $this ); + + return $this->get_order_note( $order->get_id(), $note->comment_ID ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete order note + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id note ID + * @return WP_Error|array error or deleted message + */ + public function delete_order_note( $order_id, $id ) { + try { + $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate note ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'Invalid order note ID', 'woocommerce' ), 400 ); + } + + // Ensure note ID is valid + $note = get_comment( $id ); + + if ( is_null( $note ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'An order note with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + // Ensure note ID is associated with given order + if ( $note->comment_post_ID != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_note_id', __( 'The order note ID provided is not associated with the order', 'woocommerce' ), 400 ); + } + + // Force delete since trashed order notes could not be managed through comments list table + $result = wc_delete_order_note( $note->comment_ID ); + + if ( ! $result ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_order_note', __( 'This order note cannot be deleted', 'woocommerce' ), 500 ); + } + + do_action( 'woocommerce_api_delete_order_note', $note->comment_ID, $order_id, $this ); + + return array( 'message' => __( 'Permanently deleted order note', 'woocommerce' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the order refunds for an order + * + * @since 2.2 + * @param string $order_id order ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_order_refunds( $order_id, $fields = null ) { + + // Ensure ID is valid order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $refund_items = wc_get_orders( array( + 'type' => 'shop_order_refund', + 'parent' => $order_id, + 'limit' => -1, + 'return' => 'ids', + ) ); + $order_refunds = array(); + + foreach ( $refund_items as $refund_id ) { + $order_refunds[] = current( $this->get_order_refund( $order_id, $refund_id, $fields ) ); + } + + return array( 'order_refunds' => apply_filters( 'woocommerce_api_order_refunds_response', $order_refunds, $order_id, $fields, $refund_items, $this ) ); + } + + /** + * Get an order refund for the given order ID and ID + * + * @since 2.2 + * + * @param string $order_id order ID + * @param int $id + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_order_refund( $order_id, $id, $fields = null ) { + try { + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'read' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + $order = wc_get_order( $order_id ); + $refund = wc_get_order( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + $line_items = array(); + + // Add line items + foreach ( $refund->get_items( 'line_item' ) as $item_id => $item ) { + $product = $item->get_product(); + $hideprefix = ( isset( $filter['all_item_meta'] ) && 'true' === $filter['all_item_meta'] ) ? null : '_'; + $item_meta = $item->get_formatted_meta_data( $hideprefix ); + + foreach ( $item_meta as $key => $values ) { + $item_meta[ $key ]->label = $values->display_key; + unset( $item_meta[ $key ]->display_key ); + unset( $item_meta[ $key ]->display_value ); + } + + $line_items[] = array( + 'id' => $item_id, + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item ), 2 ), + 'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), 2 ), + 'total' => wc_format_decimal( $order->get_line_total( $item ), 2 ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $item ), 2 ), + 'price' => wc_format_decimal( $order->get_item_total( $item ), 2 ), + 'quantity' => $item->get_quantity(), + 'tax_class' => $item->get_tax_class(), + 'name' => $item->get_name(), + 'product_id' => $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), + 'sku' => is_object( $product ) ? $product->get_sku() : null, + 'meta' => array_values( $item_meta ), + 'refunded_item_id' => (int) $item->get_meta( 'refunded_item_id' ), + ); + } + + $order_refund = array( + 'id' => $refund->get_id(), + 'created_at' => $this->server->format_datetime( $refund->get_date_created() ? $refund->get_date_created()->getTimestamp() : 0, false, false ), + 'amount' => wc_format_decimal( $refund->get_amount(), 2 ), + 'reason' => $refund->get_reason(), + 'line_items' => $line_items, + ); + + return array( 'order_refund' => apply_filters( 'woocommerce_api_order_refund_response', $order_refund, $id, $fields, $refund, $order_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new order refund for the given order + * + * @since 2.2 + * @param string $order_id order ID + * @param array $data raw request data + * @param bool $api_refund do refund using a payment gateway API + * @return WP_Error|array error or created refund response data + */ + public function create_order_refund( $order_id, $data, $api_refund = true ) { + try { + if ( ! isset( $data['order_refund'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_refund' ), 400 ); + } + + $data = $data['order_refund']; + + // Permission check + if ( ! current_user_can( 'publish_shop_orders' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_order_refund', __( 'You do not have permission to create order refunds', 'woocommerce' ), 401 ); + } + + $order_id = absint( $order_id ); + + if ( empty( $order_id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_id', __( 'Order ID is invalid', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_create_order_refund_data', $data, $order_id, $this ); + + // Refund amount is required + if ( ! isset( $data['amount'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund', __( 'Refund amount is required.', 'woocommerce' ), 400 ); + } elseif ( 0 > $data['amount'] ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund', __( 'Refund amount must be positive.', 'woocommerce' ), 400 ); + } + + $data['order_id'] = $order_id; + $data['refund_id'] = 0; + + // Create the refund + $refund = wc_create_refund( $data ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 ); + } + + // Refund via API + if ( $api_refund ) { + if ( WC()->payment_gateways() ) { + $payment_gateways = WC()->payment_gateways->payment_gateways(); + } + + $order = wc_get_order( $order_id ); + + if ( isset( $payment_gateways[ $order->get_payment_method() ] ) && $payment_gateways[ $order->get_payment_method() ]->supports( 'refunds' ) ) { + $result = $payment_gateways[ $order->get_payment_method() ]->process_refund( $order_id, $refund->get_amount(), $refund->get_reason() ); + + if ( is_wp_error( $result ) ) { + return $result; + } elseif ( ! $result ) { + throw new WC_API_Exception( 'woocommerce_api_create_order_refund_api_failed', __( 'An error occurred while attempting to create the refund using the payment gateway API.', 'woocommerce' ), 500 ); + } + } + } + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_order_refund', $refund->get_id(), $order_id, $this ); + + return $this->get_order_refund( $order_id, $refund->get_id() ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit an order refund + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id refund ID + * @param array $data parsed request data + * @return WP_Error|array error or edited refund response data + */ + public function edit_order_refund( $order_id, $id, $data ) { + try { + if ( ! isset( $data['order_refund'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_refund' ), 400 ); + } + + $data = $data['order_refund']; + + // Validate order ID + $order_id = $this->validate_request( $order_id, $this->post_type, 'edit' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate refund ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + // Ensure order ID is valid + $refund = get_post( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + // Ensure refund ID is associated with given order + if ( $refund->post_parent != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'The order refund ID provided is not associated with the order.', 'woocommerce' ), 400 ); + } + + $data = apply_filters( 'woocommerce_api_edit_order_refund_data', $data, $refund->ID, $order_id, $this ); + + // Update reason + if ( isset( $data['reason'] ) ) { + $updated_refund = wp_update_post( array( 'ID' => $refund->ID, 'post_excerpt' => $data['reason'] ) ); + + if ( is_wp_error( $updated_refund ) ) { + return $updated_refund; + } + } + + // Update refund amount + if ( isset( $data['amount'] ) && 0 < $data['amount'] ) { + update_post_meta( $refund->ID, '_refund_amount', wc_format_decimal( $data['amount'] ) ); + } + + do_action( 'woocommerce_api_edit_order_refund', $refund->ID, $order_id, $this ); + + return $this->get_order_refund( $order_id, $refund->ID ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete order refund + * + * @since 2.2 + * @param string $order_id order ID + * @param string $id refund ID + * @return WP_Error|array error or deleted message + */ + public function delete_order_refund( $order_id, $id ) { + try { + $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' ); + + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + // Validate refund ID + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 400 ); + } + + // Ensure refund ID is valid + $refund = get_post( $id ); + + if ( ! $refund ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'An order refund with the provided ID could not be found.', 'woocommerce' ), 404 ); + } + + // Ensure refund ID is associated with given order + if ( $refund->post_parent != $order_id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_order_refund_id', __( 'The order refund ID provided is not associated with the order.', 'woocommerce' ), 400 ); + } + + wc_delete_shop_order_transients( $order_id ); + + do_action( 'woocommerce_api_delete_order_refund', $refund->ID, $order_id, $this ); + + return $this->delete( $refund->ID, 'refund', true ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Bulk update or insert orders + * Accepts an array with orders in the formats supported by + * WC_API_Orders->create_order() and WC_API_Orders->edit_order() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['orders'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_orders_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'orders' ), 400 ); + } + + $data = $data['orders']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'orders' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_orders_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $orders = array(); + + foreach ( $data as $_order ) { + $order_id = 0; + + // Try to get the order ID + if ( isset( $_order['id'] ) ) { + $order_id = intval( $_order['id'] ); + } + + if ( $order_id ) { + + // Order exists / edit order + $edit = $this->edit_order( $order_id, array( 'order' => $_order ) ); + + if ( is_wp_error( $edit ) ) { + $orders[] = array( + 'id' => $order_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $orders[] = $edit['order']; + } + } else { + + // Order don't exists / create order + $new = $this->create_order( array( 'order' => $_order ) ); + + if ( is_wp_error( $new ) ) { + $orders[] = array( + 'id' => $order_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $orders[] = $new['order']; + } + } + } + + return array( 'orders' => apply_filters( 'woocommerce_api_orders_bulk_response', $orders, $this ) ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => 400 ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-products.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-products.php new file mode 100644 index 0000000..fb66356 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-products.php @@ -0,0 +1,3380 @@ + + * GET /products//reviews + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /products + $routes[ $this->base ] = array( + array( array( $this, 'get_products' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /products/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_products_count' ), WC_API_Server::READABLE ), + ); + + # GET/PUT/DELETE /products/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_product' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product' ), WC_API_Server::DELETABLE ), + ); + + # GET /products//reviews + $routes[ $this->base . '/(?P\d+)/reviews' ] = array( + array( array( $this, 'get_product_reviews' ), WC_API_Server::READABLE ), + ); + + # GET /products//orders + $routes[ $this->base . '/(?P\d+)/orders' ] = array( + array( array( $this, 'get_product_orders' ), WC_API_Server::READABLE ), + ); + + # GET/POST /products/categories + $routes[ $this->base . '/categories' ] = array( + array( array( $this, 'get_product_categories' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_category' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /products/categories/ + $routes[ $this->base . '/categories/(?P\d+)' ] = array( + array( array( $this, 'get_product_category' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_category' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_category' ), WC_API_Server::DELETABLE ), + ); + + # GET/POST /products/tags + $routes[ $this->base . '/tags' ] = array( + array( array( $this, 'get_product_tags' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_tag' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /products/tags/ + $routes[ $this->base . '/tags/(?P\d+)' ] = array( + array( array( $this, 'get_product_tag' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_tag' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_tag' ), WC_API_Server::DELETABLE ), + ); + + # GET/POST /products/shipping_classes + $routes[ $this->base . '/shipping_classes' ] = array( + array( array( $this, 'get_product_shipping_classes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_shipping_class' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /products/shipping_classes/ + $routes[ $this->base . '/shipping_classes/(?P\d+)' ] = array( + array( array( $this, 'get_product_shipping_class' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_shipping_class' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_shipping_class' ), WC_API_Server::DELETABLE ), + ); + + # GET/POST /products/attributes + $routes[ $this->base . '/attributes' ] = array( + array( array( $this, 'get_product_attributes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_attribute' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /products/attributes/ + $routes[ $this->base . '/attributes/(?P\d+)' ] = array( + array( array( $this, 'get_product_attribute' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_attribute' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_attribute' ), WC_API_Server::DELETABLE ), + ); + + # GET/POST /products/attributes//terms + $routes[ $this->base . '/attributes/(?P\d+)/terms' ] = array( + array( array( $this, 'get_product_attribute_terms' ), WC_API_Server::READABLE ), + array( array( $this, 'create_product_attribute_term' ), WC_API_SERVER::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET/PUT/DELETE /products/attributes//terms/ + $routes[ $this->base . '/attributes/(?P\d+)/terms/(?P\d+)' ] = array( + array( array( $this, 'get_product_attribute_term' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_product_attribute_term' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_product_attribute_term' ), WC_API_Server::DELETABLE ), + ); + + # POST|PUT /products/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all products + * + * @since 2.1 + * @param string $fields + * @param string $type + * @param array $filter + * @param int $page + * @return array + */ + public function get_products( $fields = null, $type = null, $filter = array(), $page = 1 ) { + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + $filter['page'] = $page; + + $query = $this->query_products( $filter ); + + $products = array(); + + foreach ( $query->posts as $product_id ) { + + if ( ! $this->is_readable( $product_id ) ) { + continue; + } + + $products[] = current( $this->get_product( $product_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query ); + + return array( 'products' => $products ); + } + + /** + * Get the product for the given ID + * + * @since 2.1 + * @param int $id the product ID + * @param string $fields + * @return array|WP_Error + */ + public function get_product( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + // add data that applies to every product type + $product_data = $this->get_product_data( $product ); + + // add variations to variable products + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + $product_data['variations'] = $this->get_variation_data( $product ); + } + + // add the parent product data to an individual variation + if ( $product->is_type( 'variation' ) && $product->get_parent_id() ) { + $product_data['parent'] = $this->get_product_data( $product->get_parent_id() ); + } + + // Add grouped products data + if ( $product->is_type( 'grouped' ) && $product->has_child() ) { + $product_data['grouped_products'] = $this->get_grouped_products_data( $product ); + } + + if ( $product->is_type( 'simple' ) ) { + $parent_id = $product->get_parent_id(); + if ( ! empty( $parent_id ) ) { + $_product = wc_get_product( $parent_id ); + $product_data['parent'] = $this->get_product_data( $_product ); + } + } + + return array( 'product' => apply_filters( 'woocommerce_api_product_response', $product_data, $product, $fields, $this->server ) ); + } + + /** + * Get the total number of products + * + * @since 2.1 + * + * @param string $type + * @param array $filter + * + * @return array|WP_Error + */ + public function get_products_count( $type = null, $filter = array() ) { + try { + if ( ! current_user_can( 'read_private_products' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_products_count', __( 'You do not have permission to read the products count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $type ) ) { + $filter['type'] = $type; + } + + $query = $this->query_products( $filter ); + + return array( 'count' => (int) $query->found_posts ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product. + * + * @since 2.2 + * + * @param array $data posted data + * + * @return array|WP_Error + */ + public function create_product( $data ) { + $id = 0; + + try { + if ( ! isset( $data['product'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product' ), 400 ); + } + + $data = $data['product']; + + // Check permissions. + if ( ! current_user_can( 'publish_products' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product', __( 'You do not have permission to create products', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_product_data', $data, $this ); + + // Check if product title is specified. + if ( ! isset( $data['title'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_title', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'title' ), 400 ); + } + + // Check product type. + if ( ! isset( $data['type'] ) ) { + $data['type'] = 'simple'; + } + + // Set visible visibility when not sent. + if ( ! isset( $data['catalog_visibility'] ) ) { + $data['catalog_visibility'] = 'visible'; + } + + // Validate the product type. + if ( ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_product_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_type', sprintf( __( 'Invalid product type - the product type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_product_types() ) ) ), 400 ); + } + + // Enable description html tags. + $post_content = isset( $data['description'] ) ? wc_clean( $data['description'] ) : ''; + if ( $post_content && isset( $data['enable_html_description'] ) && true === $data['enable_html_description'] ) { + + $post_content = $data['description']; + } + + // Enable short description html tags. + $post_excerpt = isset( $data['short_description'] ) ? wc_clean( $data['short_description'] ) : ''; + if ( $post_excerpt && isset( $data['enable_html_short_description'] ) && true === $data['enable_html_short_description'] ) { + $post_excerpt = $data['short_description']; + } + + $classname = WC_Product_Factory::get_classname_from_product_type( $data['type'] ); + if ( ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + $product = new $classname(); + + $product->set_name( wc_clean( $data['title'] ) ); + $product->set_status( isset( $data['status'] ) ? wc_clean( $data['status'] ) : 'publish' ); + $product->set_short_description( isset( $data['short_description'] ) ? $post_excerpt : '' ); + $product->set_description( isset( $data['description'] ) ? $post_content : '' ); + $product->set_menu_order( isset( $data['menu_order'] ) ? intval( $data['menu_order'] ) : 0 ); + + if ( ! empty( $data['name'] ) ) { + $product->set_slug( sanitize_title( $data['name'] ) ); + } + + // Attempts to create the new product. + $product->save(); + $id = $product->get_id(); + + // Checks for an error in the product creation. + if ( 0 >= $id ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product', $id->get_error_message(), 400 ); + } + + // Check for featured/gallery images, upload it and set it. + if ( isset( $data['images'] ) ) { + $product = $this->save_product_images( $product, $data['images'] ); + } + + // Save product meta fields. + $product = $this->save_product_meta( $product, $data ); + $product->save(); + + // Save variations. + if ( isset( $data['type'] ) && 'variable' == $data['type'] && isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + $this->save_variations( $product, $data ); + } + + do_action( 'woocommerce_api_create_product', $id, $data ); + + // Clear cache/transients. + wc_delete_product_transients( $id ); + + $this->server->send_status( 201 ); + + return $this->get_product( $id ); + } catch ( WC_Data_Exception $e ) { + $this->clear_product( $id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } catch ( WC_API_Exception $e ) { + $this->clear_product( $id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product + * + * @since 2.2 + * + * @param int $id the product ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_product( $id, $data ) { + try { + if ( ! isset( $data['product'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product' ), 400 ); + } + + $data = $data['product']; + + $id = $this->validate_request( $id, 'product', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + $data = apply_filters( 'woocommerce_api_edit_product_data', $data, $this ); + + // Product title. + if ( isset( $data['title'] ) ) { + $product->set_name( wc_clean( $data['title'] ) ); + } + + // Product name (slug). + if ( isset( $data['name'] ) ) { + $product->set_slug( wc_clean( $data['name'] ) ); + } + + // Product status. + if ( isset( $data['status'] ) ) { + $product->set_status( wc_clean( $data['status'] ) ); + } + + // Product short description. + if ( isset( $data['short_description'] ) ) { + // Enable short description html tags. + $post_excerpt = ( isset( $data['enable_html_short_description'] ) && true === $data['enable_html_short_description'] ) ? $data['short_description'] : wc_clean( $data['short_description'] ); + $product->set_short_description( $post_excerpt ); + } + + // Product description. + if ( isset( $data['description'] ) ) { + // Enable description html tags. + $post_content = ( isset( $data['enable_html_description'] ) && true === $data['enable_html_description'] ) ? $data['description'] : wc_clean( $data['description'] ); + $product->set_description( $post_content ); + } + + // Validate the product type. + if ( isset( $data['type'] ) && ! in_array( wc_clean( $data['type'] ), array_keys( wc_get_product_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_type', sprintf( __( 'Invalid product type - the product type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_product_types() ) ) ), 400 ); + } + + // Menu order. + if ( isset( $data['menu_order'] ) ) { + $product->set_menu_order( intval( $data['menu_order'] ) ); + } + + // Check for featured/gallery images, upload it and set it. + if ( isset( $data['images'] ) ) { + $product = $this->save_product_images( $product, $data['images'] ); + } + + // Save product meta fields. + $product = $this->save_product_meta( $product, $data ); + + // Save variations. + if ( $product->is_type( 'variable' ) ) { + if ( isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + $this->save_variations( $product, $data ); + } else { + // Just sync variations. + $product = WC_Product_Variable::sync( $product, false ); + } + } + + $product->save(); + + do_action( 'woocommerce_api_edit_product', $id, $data ); + + // Clear cache/transients. + wc_delete_product_transients( $id ); + + return $this->get_product( $id ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product. + * + * @since 2.2 + * + * @param int $id the product ID. + * @param bool $force true to permanently delete order, false to move to trash. + * + * @return array|WP_Error + */ + public function delete_product( $id, $force = false ) { + + $id = $this->validate_request( $id, 'product', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $product = wc_get_product( $id ); + + do_action( 'woocommerce_api_delete_product', $id, $this ); + + // If we're forcing, then delete permanently. + if ( $force ) { + if ( $product->is_type( 'variable' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->delete( true ); + } + } elseif ( $product->is_type( 'grouped' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->set_parent_id( 0 ); + $child->save(); + } + } + + $product->delete( true ); + $result = ! ( $product->get_id() > 0 ); + } else { + $product->delete(); + $result = 'trash' === $product->get_status(); + } + + if ( ! $result ) { + return new WP_Error( 'woocommerce_api_cannot_delete_product', sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), 'product' ), array( 'status' => 500 ) ); + } + + // Delete parent product transients. + if ( $parent_id = wp_get_post_parent_id( $id ) ) { + wc_delete_product_transients( $parent_id ); + } + + if ( $force ) { + return array( 'message' => sprintf( __( 'Permanently deleted %s', 'woocommerce' ), 'product' ) ); + } else { + $this->server->send_status( '202' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product' ) ); + } + } + + /** + * Get the reviews for a product + * + * @since 2.1 + * @param int $id the product ID to get reviews for + * @param string $fields fields to include in response + * @return array|WP_Error + */ + public function get_product_reviews( $id, $fields = null ) { + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $comments = get_approved_comments( $id ); + $reviews = array(); + + foreach ( $comments as $comment ) { + + $reviews[] = array( + 'id' => intval( $comment->comment_ID ), + 'created_at' => $this->server->format_datetime( $comment->comment_date_gmt ), + 'review' => $comment->comment_content, + 'rating' => get_comment_meta( $comment->comment_ID, 'rating', true ), + 'reviewer_name' => $comment->comment_author, + 'reviewer_email' => $comment->comment_author_email, + 'verified' => wc_review_is_from_verified_owner( $comment->comment_ID ), + ); + } + + return array( 'product_reviews' => apply_filters( 'woocommerce_api_product_reviews_response', $reviews, $id, $fields, $comments, $this->server ) ); + } + + /** + * Get the orders for a product + * + * @since 2.4.0 + * @param int $id the product ID to get orders for + * @param string fields fields to retrieve + * @param array $filter filters to include in response + * @param string $status the order status to retrieve + * @param $page $page page to retrieve + * @return array|WP_Error + */ + public function get_product_orders( $id, $fields = null, $filter = array(), $status = null, $page = 1 ) { + global $wpdb; + + $id = $this->validate_request( $id, 'product', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $order_ids = $wpdb->get_col( $wpdb->prepare( " + SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items + WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) + AND order_item_type = 'line_item' + ", $id ) ); + + if ( empty( $order_ids ) ) { + return array( 'orders' => array() ); + } + + $filter = array_merge( $filter, array( + 'in' => implode( ',', $order_ids ), + ) ); + + $orders = WC()->api->WC_API_Orders->get_orders( $fields, $filter, $status, $page ); + + return array( 'orders' => apply_filters( 'woocommerce_api_product_orders_response', $orders['orders'], $id, $filter, $fields, $this->server ) ); + } + + /** + * Get a listing of product categories + * + * @since 2.2 + * + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_categories( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_categories', __( 'You do not have permission to read product categories', 'woocommerce' ), 401 ); + } + + $product_categories = array(); + + $terms = get_terms( 'product_cat', array( 'hide_empty' => false, 'fields' => 'ids' ) ); + + foreach ( $terms as $term_id ) { + $product_categories[] = current( $this->get_product_category( $term_id, $fields ) ); + } + + return array( 'product_categories' => apply_filters( 'woocommerce_api_product_categories_response', $product_categories, $terms, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product category for the given ID + * + * @since 2.2 + * + * @param string $id product category term ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_category( $id, $fields = null ) { + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_category_id', __( 'Invalid product category ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_categories', __( 'You do not have permission to read product categories', 'woocommerce' ), 401 ); + } + + $term = get_term( $id, 'product_cat' ); + + if ( is_wp_error( $term ) || is_null( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_category_id', __( 'A product category with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $term_id = intval( $term->term_id ); + + // Get category display type + $display_type = get_woocommerce_term_meta( $term_id, 'display_type' ); + + // Get category image + $image = ''; + if ( $image_id = get_woocommerce_term_meta( $term_id, 'thumbnail_id' ) ) { + $image = wp_get_attachment_url( $image_id ); + } + + $product_category = array( + 'id' => $term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'parent' => $term->parent, + 'description' => $term->description, + 'display' => $display_type ? $display_type : 'default', + 'image' => $image ? esc_url( $image ) : '', + 'count' => intval( $term->count ), + ); + + return array( 'product_category' => apply_filters( 'woocommerce_api_product_category_response', $product_category, $id, $fields, $term, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product category. + * + * @since 2.5.0 + * @param array $data Posted data + * @return array|WP_Error Product category if succeed, otherwise WP_Error + * will be returned + */ + public function create_product_category( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_category'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_category_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_category' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_category', __( 'You do not have permission to create product categories', 'woocommerce' ), 401 ); + } + + $defaults = array( + 'name' => '', + 'slug' => '', + 'description' => '', + 'parent' => 0, + 'display' => 'default', + 'image' => '', + ); + + $data = wp_parse_args( $data['product_category'], $defaults ); + $data = apply_filters( 'woocommerce_api_create_product_category_data', $data, $this ); + + // Check parent. + $data['parent'] = absint( $data['parent'] ); + if ( $data['parent'] ) { + $parent = get_term_by( 'id', $data['parent'], 'product_cat' ); + if ( ! $parent ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_category_parent', __( 'Product category parent is invalid', 'woocommerce' ), 400 ); + } + } + + // If value of image is numeric, assume value as image_id. + $image = $data['image']; + $image_id = 0; + if ( is_numeric( $image ) ) { + $image_id = absint( $image ); + } elseif ( ! empty( $image ) ) { + $upload = $this->upload_product_category_image( esc_url_raw( $image ) ); + $image_id = $this->set_product_category_image_as_attachment( $upload ); + } + + $insert = wp_insert_term( $data['name'], 'product_cat', $data ); + if ( is_wp_error( $insert ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_category', $insert->get_error_message(), 400 ); + } + + $id = $insert['term_id']; + + update_woocommerce_term_meta( $id, 'display_type', 'default' === $data['display'] ? '' : sanitize_text_field( $data['display'] ) ); + + // Check if image_id is a valid image attachment before updating the term meta. + if ( $image_id && wp_attachment_is_image( $image_id ) ) { + update_woocommerce_term_meta( $id, 'thumbnail_id', $image_id ); + } + + do_action( 'woocommerce_api_create_product_category', $id, $data ); + + $this->server->send_status( 201 ); + + return $this->get_product_category( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product category. + * + * @since 2.5.0 + * @param int $id Product category term ID + * @param array $data Posted data + * @return array|WP_Error Product category if succeed, otherwise WP_Error + * will be returned + */ + public function edit_product_category( $id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_category'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_category', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_category' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_category']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_category', __( 'You do not have permission to edit product categories', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_category_data', $data, $this ); + $category = $this->get_product_category( $id ); + + if ( is_wp_error( $category ) ) { + return $category; + } + + if ( isset( $data['image'] ) ) { + $image_id = 0; + + // If value of image is numeric, assume value as image_id. + $image = $data['image']; + if ( is_numeric( $image ) ) { + $image_id = absint( $image ); + } elseif ( ! empty( $image ) ) { + $upload = $this->upload_product_category_image( esc_url_raw( $image ) ); + $image_id = $this->set_product_category_image_as_attachment( $upload ); + } + + // In case client supplies invalid image or wants to unset category image. + if ( ! wp_attachment_is_image( $image_id ) ) { + $image_id = ''; + } + } + + $update = wp_update_term( $id, 'product_cat', $data ); + if ( is_wp_error( $update ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_catgory', __( 'Could not edit the category', 'woocommerce' ), 400 ); + } + + if ( ! empty( $data['display'] ) ) { + update_woocommerce_term_meta( $id, 'display_type', 'default' === $data['display'] ? '' : sanitize_text_field( $data['display'] ) ); + } + + if ( isset( $image_id ) ) { + update_woocommerce_term_meta( $id, 'thumbnail_id', $image_id ); + } + + do_action( 'woocommerce_api_edit_product_category', $id, $data ); + + return $this->get_product_category( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product category. + * + * @since 2.5.0 + * @param int $id Product category term ID + * @return array|WP_Error Success message if succeed, otherwise WP_Error + * will be returned + */ + public function delete_product_category( $id ) { + global $wpdb; + + try { + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_category', __( 'You do not have permission to delete product category', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + $deleted = wp_delete_term( $id, 'product_cat' ); + if ( ! $deleted || is_wp_error( $deleted ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_category', __( 'Could not delete the category', 'woocommerce' ), 401 ); + } + + // When a term is deleted, delete its meta. + if ( get_option( 'db_version' ) < 34370 ) { + $wpdb->delete( $wpdb->woocommerce_termmeta, array( 'woocommerce_term_id' => $id ), array( '%d' ) ); + } + + do_action( 'woocommerce_api_delete_product_category', $id, $this ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_category' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a listing of product tags. + * + * @since 2.5.0 + * + * @param string|null $fields Fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_tags( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_tags', __( 'You do not have permission to read product tags', 'woocommerce' ), 401 ); + } + + $product_tags = array(); + + $terms = get_terms( 'product_tag', array( 'hide_empty' => false, 'fields' => 'ids' ) ); + + foreach ( $terms as $term_id ) { + $product_tags[] = current( $this->get_product_tag( $term_id, $fields ) ); + } + + return array( 'product_tags' => apply_filters( 'woocommerce_api_product_tags_response', $product_tags, $terms, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product tag for the given ID. + * + * @since 2.5.0 + * + * @param string $id Product tag term ID + * @param string|null $fields Fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_tag( $id, $fields = null ) { + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_tag_id', __( 'Invalid product tag ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_tags', __( 'You do not have permission to read product tags', 'woocommerce' ), 401 ); + } + + $term = get_term( $id, 'product_tag' ); + + if ( is_wp_error( $term ) || is_null( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_tag_id', __( 'A product tag with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $term_id = intval( $term->term_id ); + + $tag = array( + 'id' => $term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'description' => $term->description, + 'count' => intval( $term->count ), + ); + + return array( 'product_tag' => apply_filters( 'woocommerce_api_product_tag_response', $tag, $id, $fields, $term, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product tag. + * + * @since 2.5.0 + * @param array $data Posted data + * @return array|WP_Error Product tag if succeed, otherwise WP_Error + * will be returned + */ + public function create_product_tag( $data ) { + try { + if ( ! isset( $data['product_tag'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_tag_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_tag' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_tag', __( 'You do not have permission to create product tags', 'woocommerce' ), 401 ); + } + + $defaults = array( + 'name' => '', + 'slug' => '', + 'description' => '', + ); + + $data = wp_parse_args( $data['product_tag'], $defaults ); + $data = apply_filters( 'woocommerce_api_create_product_tag_data', $data, $this ); + + $insert = wp_insert_term( $data['name'], 'product_tag', $data ); + if ( is_wp_error( $insert ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_tag', $insert->get_error_message(), 400 ); + } + $id = $insert['term_id']; + + do_action( 'woocommerce_api_create_product_tag', $id, $data ); + + $this->server->send_status( 201 ); + + return $this->get_product_tag( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product tag. + * + * @since 2.5.0 + * @param int $id Product tag term ID + * @param array $data Posted data + * @return array|WP_Error Product tag if succeed, otherwise WP_Error + * will be returned + */ + public function edit_product_tag( $id, $data ) { + try { + if ( ! isset( $data['product_tag'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_tag', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_tag' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_tag']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_tag', __( 'You do not have permission to edit product tags', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_tag_data', $data, $this ); + $tag = $this->get_product_tag( $id ); + + if ( is_wp_error( $tag ) ) { + return $tag; + } + + $update = wp_update_term( $id, 'product_tag', $data ); + if ( is_wp_error( $update ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_tag', __( 'Could not edit the tag', 'woocommerce' ), 400 ); + } + + do_action( 'woocommerce_api_edit_product_tag', $id, $data ); + + return $this->get_product_tag( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product tag. + * + * @since 2.5.0 + * @param int $id Product tag term ID + * @return array|WP_Error Success message if succeed, otherwise WP_Error + * will be returned + */ + public function delete_product_tag( $id ) { + try { + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_tag', __( 'You do not have permission to delete product tag', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + $deleted = wp_delete_term( $id, 'product_tag' ); + if ( ! $deleted || is_wp_error( $deleted ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_tag', __( 'Could not delete the tag', 'woocommerce' ), 401 ); + } + + do_action( 'woocommerce_api_delete_product_tag', $id, $this ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_tag' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Helper method to get product post objects + * + * @since 2.1 + * @param array $args request arguments for filtering query + * @return WP_Query + */ + private function query_products( $args ) { + + // Set base query arguments + $query_args = array( + 'fields' => 'ids', + 'post_type' => 'product', + 'post_status' => 'publish', + 'meta_query' => array(), + ); + + // Taxonomy query to filter products by type, category, tag, shipping class, and + // attribute. + $tax_query = array(); + + // Map between taxonomy name and arg's key. + $taxonomies_arg_map = array( + 'product_type' => 'type', + 'product_cat' => 'category', + 'product_tag' => 'tag', + 'product_shipping_class' => 'shipping_class', + ); + + // Add attribute taxonomy names into the map. + foreach ( wc_get_attribute_taxonomy_names() as $attribute_name ) { + $taxonomies_arg_map[ $attribute_name ] = $attribute_name; + } + + // Set tax_query for each passed arg. + foreach ( $taxonomies_arg_map as $tax_name => $arg ) { + if ( ! empty( $args[ $arg ] ) ) { + $terms = explode( ',', $args[ $arg ] ); + + $tax_query[] = array( + 'taxonomy' => $tax_name, + 'field' => 'slug', + 'terms' => $terms, + ); + + unset( $args[ $arg ] ); + } + } + + if ( ! empty( $tax_query ) ) { + $query_args['tax_query'] = $tax_query; + } + + // Filter by specific sku + if ( ! empty( $args['sku'] ) ) { + if ( ! is_array( $query_args['meta_query'] ) ) { + $query_args['meta_query'] = array(); + } + + $query_args['meta_query'][] = array( + 'key' => '_sku', + 'value' => $args['sku'], + 'compare' => '=', + ); + + $query_args['post_type'] = array( 'product', 'product_variation' ); + } + + $query_args = $this->merge_query_args( $query_args, $args ); + + return new WP_Query( $query_args ); + } + + /** + * Get standard product data that applies to every product type + * + * @since 2.1 + * @param WC_Product|int $product + * + * @return array + */ + private function get_product_data( $product ) { + if ( is_numeric( $product ) ) { + $product = wc_get_product( $product ); + } + + if ( ! is_a( $product, 'WC_Product' ) ) { + return array(); + } + + return array( + 'title' => $product->get_name(), + 'id' => $product->get_id(), + 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ), + 'type' => $product->get_type(), + 'status' => $product->get_status(), + 'downloadable' => $product->is_downloadable(), + 'virtual' => $product->is_virtual(), + 'permalink' => $product->get_permalink(), + 'sku' => $product->get_sku(), + 'price' => $product->get_price(), + 'regular_price' => $product->get_regular_price(), + 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : null, + 'price_html' => $product->get_price_html(), + 'taxable' => $product->is_taxable(), + 'tax_status' => $product->get_tax_status(), + 'tax_class' => $product->get_tax_class(), + 'managing_stock' => $product->managing_stock(), + 'stock_quantity' => $product->get_stock_quantity(), + 'in_stock' => $product->is_in_stock(), + 'backorders_allowed' => $product->backorders_allowed(), + 'backordered' => $product->is_on_backorder(), + 'sold_individually' => $product->is_sold_individually(), + 'purchaseable' => $product->is_purchasable(), + 'featured' => $product->is_featured(), + 'visible' => $product->is_visible(), + 'catalog_visibility' => $product->get_catalog_visibility(), + 'on_sale' => $product->is_on_sale(), + 'product_url' => $product->is_type( 'external' ) ? $product->get_product_url() : '', + 'button_text' => $product->is_type( 'external' ) ? $product->get_button_text() : '', + 'weight' => $product->get_weight() ? $product->get_weight() : null, + 'dimensions' => array( + 'length' => $product->get_length(), + 'width' => $product->get_width(), + 'height' => $product->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_required' => $product->needs_shipping(), + 'shipping_taxable' => $product->is_shipping_taxable(), + 'shipping_class' => $product->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $product->get_shipping_class_id() ) ? $product->get_shipping_class_id() : null, + 'description' => wpautop( do_shortcode( $product->get_description() ) ), + 'short_description' => apply_filters( 'woocommerce_short_description', $product->get_short_description() ), + 'reviews_allowed' => $product->get_reviews_allowed(), + 'average_rating' => wc_format_decimal( $product->get_average_rating(), 2 ), + 'rating_count' => $product->get_rating_count(), + 'related_ids' => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ), + 'upsell_ids' => array_map( 'absint', $product->get_upsell_ids() ), + 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sell_ids() ), + 'parent_id' => $product->get_parent_id(), + 'categories' => wc_get_object_terms( $product->get_id(), 'product_cat', 'name' ), + 'tags' => wc_get_object_terms( $product->get_id(), 'product_tag', 'name' ), + 'images' => $this->get_images( $product ), + 'featured_src' => wp_get_attachment_url( get_post_thumbnail_id( $product->get_id() ) ), + 'attributes' => $this->get_attributes( $product ), + 'downloads' => $this->get_downloads( $product ), + 'download_limit' => $product->get_download_limit(), + 'download_expiry' => $product->get_download_expiry(), + 'download_type' => 'standard', + 'purchase_note' => wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ), + 'total_sales' => $product->get_total_sales(), + 'variations' => array(), + 'parent' => array(), + 'grouped_products' => array(), + 'menu_order' => $this->get_product_menu_order( $product ), + ); + } + + /** + * Get product menu order. + * + * @since 2.5.3 + * @param WC_Product $product + * @return int + */ + private function get_product_menu_order( $product ) { + $menu_order = $product->get_menu_order(); + + return apply_filters( 'woocommerce_api_product_menu_order', $menu_order, $product ); + } + + /** + * Get an individual variation's data. + * + * @since 2.1 + * @param WC_Product $product + * @return array + */ + private function get_variation_data( $product ) { + $variations = array(); + + foreach ( $product->get_children() as $child_id ) { + $variation = wc_get_product( $child_id ); + + if ( ! $variation || ! $variation->exists() ) { + continue; + } + + $variations[] = array( + 'id' => $variation->get_id(), + 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ), + 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ), + 'downloadable' => $variation->is_downloadable(), + 'virtual' => $variation->is_virtual(), + 'permalink' => $variation->get_permalink(), + 'sku' => $variation->get_sku(), + 'price' => $variation->get_price(), + 'regular_price' => $variation->get_regular_price(), + 'sale_price' => $variation->get_sale_price() ? $variation->get_sale_price() : null, + 'taxable' => $variation->is_taxable(), + 'tax_status' => $variation->get_tax_status(), + 'tax_class' => $variation->get_tax_class(), + 'managing_stock' => $variation->managing_stock(), + 'stock_quantity' => $variation->get_stock_quantity(), + 'in_stock' => $variation->is_in_stock(), + 'backorders_allowed' => $variation->backorders_allowed(), + 'backordered' => $variation->is_on_backorder(), + 'purchaseable' => $variation->is_purchasable(), + 'visible' => $variation->variation_is_visible(), + 'on_sale' => $variation->is_on_sale(), + 'weight' => $variation->get_weight() ? $variation->get_weight() : null, + 'dimensions' => array( + 'length' => $variation->get_length(), + 'width' => $variation->get_width(), + 'height' => $variation->get_height(), + 'unit' => get_option( 'woocommerce_dimension_unit' ), + ), + 'shipping_class' => $variation->get_shipping_class(), + 'shipping_class_id' => ( 0 !== $variation->get_shipping_class_id() ) ? $variation->get_shipping_class_id() : null, + 'image' => $this->get_images( $variation ), + 'attributes' => $this->get_attributes( $variation ), + 'downloads' => $this->get_downloads( $variation ), + 'download_limit' => (int) $product->get_download_limit(), + 'download_expiry' => (int) $product->get_download_expiry(), + ); + } + + return $variations; + } + + /** + * Get grouped products data + * + * @since 2.5.0 + * @param WC_Product $product + * + * @return array + */ + private function get_grouped_products_data( $product ) { + $products = array(); + + foreach ( $product->get_children() as $child_id ) { + $_product = wc_get_product( $child_id ); + + if ( ! $_product || ! $_product->exists() ) { + continue; + } + + $products[] = $this->get_product_data( $_product ); + + } + + return $products; + } + + /** + * Save default attributes. + * + * @since 3.0.0 + * + * @param WC_Product $product + * @param WP_REST_Request $request + * @return WC_Product + */ + protected function save_default_attributes( $product, $request ) { + // Update default attributes options setting. + if ( isset( $request['default_attribute'] ) ) { + $request['default_attributes'] = $request['default_attribute']; + } + + if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) { + $attributes = $product->get_attributes(); + $default_attributes = array(); + + foreach ( $request['default_attributes'] as $default_attr_key => $default_attr ) { + if ( ! isset( $default_attr['name'] ) ) { + continue; + } + + $taxonomy = sanitize_title( $default_attr['name'] ); + + if ( isset( $default_attr['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $default_attr['slug'] ); + } + + if ( isset( $attributes[ $taxonomy ] ) ) { + $_attribute = $attributes[ $taxonomy ]; + + if ( $_attribute['is_variation'] ) { + $value = ''; + + if ( isset( $default_attr['option'] ) ) { + if ( $_attribute['is_taxonomy'] ) { + // Don't use wc_clean as it destroys sanitized characters + $value = sanitize_title( trim( stripslashes( $default_attr['option'] ) ) ); + } else { + $value = wc_clean( trim( stripslashes( $default_attr['option'] ) ) ); + } + } + + if ( $value ) { + $default_attributes[ $taxonomy ] = $value; + } + } + } + } + + $product->set_default_attributes( $default_attributes ); + } + + return $product; + } + + /** + * Save product meta. + * + * @since 2.2 + * @param WC_Product $product + * @param array $data + * @return WC_Product + * @throws WC_API_Exception + */ + protected function save_product_meta( $product, $data ) { + global $wpdb; + + // Virtual. + if ( isset( $data['virtual'] ) ) { + $product->set_virtual( $data['virtual'] ); + } + + // Tax status. + if ( isset( $data['tax_status'] ) ) { + $product->set_tax_status( wc_clean( $data['tax_status'] ) ); + } + + // Tax Class. + if ( isset( $data['tax_class'] ) ) { + $product->set_tax_class( wc_clean( $data['tax_class'] ) ); + } + + // Catalog Visibility. + if ( isset( $data['catalog_visibility'] ) ) { + $product->set_catalog_visibility( wc_clean( $data['catalog_visibility'] ) ); + } + + // Purchase Note. + if ( isset( $data['purchase_note'] ) ) { + $product->set_purchase_note( wc_clean( $data['purchase_note'] ) ); + } + + // Featured Product. + if ( isset( $data['featured'] ) ) { + $product->set_featured( $data['featured'] ); + } + + // Shipping data. + $product = $this->save_product_shipping_data( $product, $data ); + + // SKU. + if ( isset( $data['sku'] ) ) { + $sku = $product->get_sku(); + $new_sku = wc_clean( $data['sku'] ); + + if ( '' == $new_sku ) { + $product->set_sku( '' ); + } elseif ( $new_sku !== $sku ) { + if ( ! empty( $new_sku ) ) { + $unique_sku = wc_product_has_unique_sku( $product->get_id(), $new_sku ); + if ( ! $unique_sku ) { + throw new WC_API_Exception( 'woocommerce_api_product_sku_already_exists', __( 'The SKU already exists on another product.', 'woocommerce' ), 400 ); + } else { + $product->set_sku( $new_sku ); + } + } else { + $product->set_sku( '' ); + } + } + } + + // Attributes. + if ( isset( $data['attributes'] ) ) { + $attributes = array(); + + foreach ( $data['attributes'] as $attribute ) { + $is_taxonomy = 0; + $taxonomy = 0; + + if ( ! isset( $attribute['name'] ) ) { + continue; + } + + $attribute_slug = sanitize_title( $attribute['name'] ); + + if ( isset( $attribute['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $attribute['slug'] ); + $attribute_slug = sanitize_title( $attribute['slug'] ); + } + + if ( $taxonomy ) { + $is_taxonomy = 1; + } + + if ( $is_taxonomy ) { + + $attribute_id = wc_attribute_taxonomy_id_by_name( $attribute['name'] ); + + if ( isset( $attribute['options'] ) ) { + $options = $attribute['options']; + + if ( ! is_array( $attribute['options'] ) ) { + // Text based attributes - Posted values are term names. + $options = explode( WC_DELIMITER, $options ); + } + + $values = array_map( 'wc_sanitize_term_text_based', $options ); + $values = array_filter( $values, 'strlen' ); + } else { + $values = array(); + } + + // Update post terms + if ( taxonomy_exists( $taxonomy ) ) { + wp_set_object_terms( $product->get_id(), $values, $taxonomy ); + } + + if ( ! empty( $values ) ) { + // Add attribute to array, but don't set values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $taxonomy ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? absint( $attribute['position'] ) : 0 ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['options'] ) ) { + // Array based. + if ( is_array( $attribute['options'] ) ) { + $values = $attribute['options']; + + // Text based, separate by pipe. + } else { + $values = array_map( 'wc_clean', explode( WC_DELIMITER, $attribute['options'] ) ); + } + + // Custom attribute - Add attribute to array and set the values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute['name'] ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? absint( $attribute['position'] ) : 0 ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } + + uasort( $attributes, 'wc_product_attribute_uasort_comparison' ); + + $product->set_attributes( $attributes ); + } + + // Sales and prices. + if ( in_array( $product->get_type(), array( 'variable', 'grouped' ) ) ) { + + // Variable and grouped products have no prices. + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + $product->set_date_on_sale_to( '' ); + $product->set_date_on_sale_from( '' ); + $product->set_price( '' ); + + } else { + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $regular_price = ( '' === $data['regular_price'] ) ? '' : $data['regular_price']; + $product->set_regular_price( $regular_price ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $sale_price = ( '' === $data['sale_price'] ) ? '' : $data['sale_price']; + $product->set_sale_price( $sale_price ); + } + + if ( isset( $data['sale_price_dates_from'] ) ) { + $date_from = $data['sale_price_dates_from']; + } else { + $date_from = $product->get_date_on_sale_from() ? date( 'Y-m-d', $product->get_date_on_sale_from()->getTimestamp() ) : ''; + } + + if ( isset( $data['sale_price_dates_to'] ) ) { + $date_to = $data['sale_price_dates_to']; + } else { + $date_to = $product->get_date_on_sale_to() ? date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() ) : ''; + } + + if ( $date_to && ! $date_from ) { + $date_from = strtotime( 'NOW', current_time( 'timestamp', true ) ); + } + + $product->set_date_on_sale_to( $date_to ); + $product->set_date_on_sale_from( $date_from ); + + if ( $product->is_on_sale( 'edit' ) ) { + $product->set_price( $product->get_sale_price( 'edit' ) ); + } else { + $product->set_price( $product->get_regular_price( 'edit' ) ); + } + } + + // Product parent ID for groups. + if ( isset( $data['parent_id'] ) ) { + $product->set_parent_id( absint( $data['parent_id'] ) ); + } + + // Sold Individually. + if ( isset( $data['sold_individually'] ) ) { + $product->set_sold_individually( true === $data['sold_individually'] ? 'yes' : '' ); + } + + // Stock status. + if ( isset( $data['in_stock'] ) ) { + $stock_status = ( true === $data['in_stock'] ) ? 'instock' : 'outofstock'; + } else { + $stock_status = $product->get_stock_status(); + + if ( '' === $stock_status ) { + $stock_status = 'instock'; + } + } + + // Stock Data. + if ( 'yes' == get_option( 'woocommerce_manage_stock' ) ) { + // Manage stock. + if ( isset( $data['managing_stock'] ) ) { + $managing_stock = ( true === $data['managing_stock'] ) ? 'yes' : 'no'; + $product->set_manage_stock( $managing_stock ); + } else { + $managing_stock = $product->get_manage_stock() ? 'yes' : 'no'; + } + + // Backorders. + if ( isset( $data['backorders'] ) ) { + if ( 'notify' === $data['backorders'] ) { + $backorders = 'notify'; + } else { + $backorders = ( true === $data['backorders'] ) ? 'yes' : 'no'; + } + + $product->set_backorders( $backorders ); + } else { + $backorders = $product->get_backorders(); + } + + if ( $product->is_type( 'grouped' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } elseif ( $product->is_type( 'external' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( 'instock' ); + } elseif ( 'yes' == $managing_stock ) { + $product->set_backorders( $backorders ); + + // Stock status is always determined by children so sync later. + if ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Stock quantity. + if ( isset( $data['stock_quantity'] ) ) { + $product->set_stock_quantity( wc_stock_amount( $data['stock_quantity'] ) ); + } elseif ( isset( $data['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $product->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $data['inventory_delta'] ); + $product->set_stock_quantity( wc_stock_amount( $stock_quantity ) ); + } + } else { + // Don't manage stock. + $product->set_manage_stock( 'no' ); + $product->set_backorders( $backorders ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } + } elseif ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Upsells. + if ( isset( $data['upsell_ids'] ) ) { + $upsells = array(); + $ids = $data['upsell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $upsells[] = $id; + } + } + + $product->set_upsell_ids( $upsells ); + } else { + $product->set_upsell_ids( array() ); + } + } + + // Cross sells. + if ( isset( $data['cross_sell_ids'] ) ) { + $crosssells = array(); + $ids = $data['cross_sell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $crosssells[] = $id; + } + } + + $product->set_cross_sell_ids( $crosssells ); + } else { + $product->set_cross_sell_ids( array() ); + } + } + + // Product categories. + if ( isset( $data['categories'] ) && is_array( $data['categories'] ) ) { + $product->set_category_ids( $data['categories'] ); + } + + // Product tags. + if ( isset( $data['tags'] ) && is_array( $data['tags'] ) ) { + $product->set_tag_ids( $data['tags'] ); + } + + // Downloadable. + if ( isset( $data['downloadable'] ) ) { + $is_downloadable = ( true === $data['downloadable'] ) ? 'yes' : 'no'; + $product->set_downloadable( $is_downloadable ); + } else { + $is_downloadable = $product->get_downloadable() ? 'yes' : 'no'; + } + + // Downloadable options. + if ( 'yes' == $is_downloadable ) { + + // Downloadable files. + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $product = $this->save_downloadable_files( $product, $data['downloads'] ); + } + + // Download limit. + if ( isset( $data['download_limit'] ) ) { + $product->set_download_limit( $data['download_limit'] ); + } + + // Download expiry. + if ( isset( $data['download_expiry'] ) ) { + $product->set_download_expiry( $data['download_expiry'] ); + } + } + + // Product url. + if ( $product->is_type( 'external' ) ) { + if ( isset( $data['product_url'] ) ) { + $product->set_product_url( $data['product_url'] ); + } + + if ( isset( $data['button_text'] ) ) { + $product->set_button_text( $data['button_text'] ); + } + } + + // Reviews allowed. + if ( isset( $data['reviews_allowed'] ) ) { + $product->set_reviews_allowed( $data['reviews_allowed'] ); + } + + // Save default attributes for variable products. + if ( $product->is_type( 'variable' ) ) { + $product = $this->save_default_attributes( $product, $data ); + } + + // Do action for product type + do_action( 'woocommerce_api_process_product_meta_' . $product->get_type(), $product->get_id(), $data ); + + return $product; + } + + /** + * Save variations. + * + * @since 2.2 + * + * @param WC_Product $product + * @param array $request + * + * @return bool + * @throws WC_API_Exception + */ + protected function save_variations( $product, $request ) { + global $wpdb; + + $id = $product->get_id(); + $variations = $request['variations']; + $attributes = $product->get_attributes(); + + foreach ( $variations as $menu_order => $data ) { + $variation_id = isset( $data['id'] ) ? absint( $data['id'] ) : 0; + $variation = new WC_Product_Variation( $variation_id ); + + // Create initial name and status. + if ( ! $variation->get_slug() ) { + /* translators: 1: variation id 2: product name */ + $variation->set_name( sprintf( __( 'Variation #%1$s of %2$s', 'woocommerce' ), $variation->get_id(), $product->get_name() ) ); + $variation->set_status( isset( $data['visible'] ) && false === $data['visible'] ? 'private' : 'publish' ); + } + + // Parent ID. + $variation->set_parent_id( $product->get_id() ); + + // Menu order. + $variation->set_menu_order( $menu_order ); + + // Status. + if ( isset( $data['visible'] ) ) { + $variation->set_status( false === $data['visible'] ? 'private' : 'publish' ); + } + + // SKU. + if ( isset( $data['sku'] ) ) { + $variation->set_sku( wc_clean( $data['sku'] ) ); + } + + // Thumbnail. + if ( isset( $data['image'] ) && is_array( $data['image'] ) ) { + $image = current( $data['image'] ); + if ( is_array( $image ) ) { + $image['position'] = 0; + } + + $variation = $this->save_product_images( $variation, array( $image ) ); + } + + // Virtual variation. + if ( isset( $data['virtual'] ) ) { + $variation->set_virtual( $data['virtual'] ); + } + + // Downloadable variation. + if ( isset( $data['downloadable'] ) ) { + $is_downloadable = $data['downloadable']; + $variation->set_downloadable( $is_downloadable ); + } else { + $is_downloadable = $variation->get_downloadable(); + } + + // Downloads. + if ( $is_downloadable ) { + // Downloadable files. + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $variation = $this->save_downloadable_files( $variation, $data['downloads'] ); + } + + // Download limit. + if ( isset( $data['download_limit'] ) ) { + $variation->set_download_limit( $data['download_limit'] ); + } + + // Download expiry. + if ( isset( $data['download_expiry'] ) ) { + $variation->set_download_expiry( $data['download_expiry'] ); + } + } + + // Shipping data. + $variation = $this->save_product_shipping_data( $variation, $data ); + + // Stock handling. + $manage_stock = (bool) $variation->get_manage_stock(); + if ( isset( $data['managing_stock'] ) ) { + $manage_stock = $data['managing_stock']; + } + $variation->set_manage_stock( $manage_stock ); + + $stock_status = $variation->get_stock_status(); + if ( isset( $data['in_stock'] ) ) { + $stock_status = true === $data['in_stock'] ? 'instock' : 'outofstock'; + } + $variation->set_stock_status( $stock_status ); + + $backorders = $variation->get_backorders(); + if ( isset( $data['backorders'] ) ) { + $backorders = $data['backorders']; + } + $variation->set_backorders( $backorders ); + + if ( $manage_stock ) { + if ( isset( $data['stock_quantity'] ) ) { + $variation->set_stock_quantity( $data['stock_quantity'] ); + } elseif ( isset( $data['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $variation->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $data['inventory_delta'] ); + $variation->set_stock_quantity( $stock_quantity ); + } + } else { + $variation->set_backorders( 'no' ); + $variation->set_stock_quantity( '' ); + } + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $variation->set_regular_price( $data['regular_price'] ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $variation->set_sale_price( $data['sale_price'] ); + } + + if ( isset( $data['sale_price_dates_from'] ) ) { + $variation->set_date_on_sale_from( $data['sale_price_dates_from'] ); + } + + if ( isset( $data['sale_price_dates_to'] ) ) { + $variation->set_date_on_sale_to( $data['sale_price_dates_to'] ); + } + + // Tax class. + if ( isset( $data['tax_class'] ) ) { + $variation->set_tax_class( $data['tax_class'] ); + } + + // Description. + if ( isset( $data['description'] ) ) { + $variation->set_description( wp_kses_post( $data['description'] ) ); + } + + // Update taxonomies. + if ( isset( $data['attributes'] ) ) { + $_attributes = array(); + + foreach ( $data['attributes'] as $attribute_key => $attribute ) { + if ( ! isset( $attribute['name'] ) ) { + continue; + } + + $taxonomy = 0; + $_attribute = array(); + + if ( isset( $attribute['slug'] ) ) { + $taxonomy = $this->get_attribute_taxonomy_by_slug( $attribute['slug'] ); + } + + if ( ! $taxonomy ) { + $taxonomy = sanitize_title( $attribute['name'] ); + } + + if ( isset( $attributes[ $taxonomy ] ) ) { + $_attribute = $attributes[ $taxonomy ]; + } + + if ( isset( $_attribute['is_variation'] ) && $_attribute['is_variation'] ) { + $_attribute_key = sanitize_title( $_attribute['name'] ); + + if ( isset( $_attribute['is_taxonomy'] ) && $_attribute['is_taxonomy'] ) { + // Don't use wc_clean as it destroys sanitized characters. + $_attribute_value = isset( $attribute['option'] ) ? sanitize_title( stripslashes( $attribute['option'] ) ) : ''; + } else { + $_attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + } + + $_attributes[ $_attribute_key ] = $_attribute_value; + } + } + + $variation->set_attributes( $_attributes ); + } + + $variation->save(); + + do_action( 'woocommerce_api_save_product_variation', $variation_id, $menu_order, $variation ); + } + + return true; + } + + /** + * Save product shipping data + * + * @since 2.2 + * @param WC_Product $product + * @param array $data + * @return WC_Product + */ + private function save_product_shipping_data( $product, $data ) { + if ( isset( $data['weight'] ) ) { + $product->set_weight( '' === $data['weight'] ? '' : wc_format_decimal( $data['weight'] ) ); + } + + // Product dimensions + if ( isset( $data['dimensions'] ) ) { + // Height + if ( isset( $data['dimensions']['height'] ) ) { + $product->set_height( '' === $data['dimensions']['height'] ? '' : wc_format_decimal( $data['dimensions']['height'] ) ); + } + + // Width + if ( isset( $data['dimensions']['width'] ) ) { + $product->set_width( '' === $data['dimensions']['width'] ? '' : wc_format_decimal( $data['dimensions']['width'] ) ); + } + + // Length + if ( isset( $data['dimensions']['length'] ) ) { + $product->set_length( '' === $data['dimensions']['length'] ? '' : wc_format_decimal( $data['dimensions']['length'] ) ); + } + } + + // Virtual + if ( isset( $data['virtual'] ) ) { + $virtual = ( true === $data['virtual'] ) ? 'yes' : 'no'; + + if ( 'yes' == $virtual ) { + $product->set_weight( '' ); + $product->set_height( '' ); + $product->set_length( '' ); + $product->set_width( '' ); + } + } + + // Shipping class + if ( isset( $data['shipping_class'] ) ) { + $data_store = $product->get_data_store(); + $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); + $product->set_shipping_class_id( $shipping_class_id ); + } + + return $product; + } + + /** + * Save downloadable files + * + * @since 2.2 + * @param WC_Product $product + * @param array $downloads + * @param int $deprecated Deprecated since 3.0. + * @return WC_Product + */ + private function save_downloadable_files( $product, $downloads, $deprecated = 0 ) { + if ( $deprecated ) { + wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() does not require a variation_id anymore.' ); + } + + $files = array(); + foreach ( $downloads as $key => $file ) { + if ( isset( $file['url'] ) ) { + $file['file'] = $file['url']; + } + + if ( empty( $file['file'] ) ) { + continue; + } + + $download = new WC_Product_Download(); + $download->set_id( $file['id'] ? $file['id'] : wp_generate_uuid4() ); + $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) ); + $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) ); + $files[] = $download; + } + $product->set_downloads( $files ); + + return $product; + } + + /** + * Get attribute taxonomy by slug. + * + * @since 2.2 + * @param string $slug + * @return string|null + */ + private function get_attribute_taxonomy_by_slug( $slug ) { + $taxonomy = null; + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + foreach ( $attribute_taxonomies as $key => $tax ) { + if ( $slug == $tax->attribute_name ) { + $taxonomy = 'pa_' . $tax->attribute_name; + + break; + } + } + + return $taxonomy; + } + + /** + * Get the images for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_images( $product ) { + $images = $attachment_ids = array(); + $product_image = $product->get_image_id(); + + // Add featured image. + if ( ! empty( $product_image ) ) { + $attachment_ids[] = $product_image; + } + + // Add gallery images. + $attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() ); + + // Build image data. + foreach ( $attachment_ids as $position => $attachment_id ) { + + $attachment_post = get_post( $attachment_id ); + + if ( is_null( $attachment_post ) ) { + continue; + } + + $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ); + + if ( ! is_array( $attachment ) ) { + continue; + } + + $images[] = array( + 'id' => (int) $attachment_id, + 'created_at' => $this->server->format_datetime( $attachment_post->post_date_gmt ), + 'updated_at' => $this->server->format_datetime( $attachment_post->post_modified_gmt ), + 'src' => current( $attachment ), + 'title' => get_the_title( $attachment_id ), + 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), + 'position' => (int) $position, + ); + } + + // Set a placeholder image if the product has no images set. + if ( empty( $images ) ) { + + $images[] = array( + 'id' => 0, + 'created_at' => $this->server->format_datetime( time() ), // Default to now. + 'updated_at' => $this->server->format_datetime( time() ), + 'src' => wc_placeholder_img_src(), + 'title' => __( 'Placeholder', 'woocommerce' ), + 'alt' => __( 'Placeholder', 'woocommerce' ), + 'position' => 0, + ); + } + + return $images; + } + + /** + * Save product images. + * + * @since 2.2 + * @param WC_Product $product + * @param array $images + * @throws WC_API_Exception + * @return WC_Product + */ + protected function save_product_images( $product, $images ) { + if ( is_array( $images ) ) { + $gallery = array(); + + foreach ( $images as $image ) { + if ( isset( $image['position'] ) && 0 == $image['position'] ) { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = $this->upload_product_image( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 ); + } + + $attachment_id = $this->set_product_image_as_attachment( $upload, $product->get_id() ); + } + + $product->set_image_id( $attachment_id ); + } else { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = $this->upload_product_image( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_upload_product_image', $upload->get_error_message(), 400 ); + } + + $attachment_id = $this->set_product_image_as_attachment( $upload, $product->get_id() ); + } + + $gallery[] = $attachment_id; + } + + // Set the image alt if present. + if ( ! empty( $image['alt'] ) && $attachment_id ) { + update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) ); + } + + // Set the image title if present. + if ( ! empty( $image['title'] ) && $attachment_id ) { + wp_update_post( array( 'ID' => $attachment_id, 'post_title' => $image['title'] ) ); + } + } + + if ( ! empty( $gallery ) ) { + $product->set_gallery_image_ids( $gallery ); + } + } else { + $product->set_image_id( '' ); + $product->set_gallery_image_ids( array() ); + } + + return $product; + } + + /** + * Upload image from URL + * + * @since 2.2 + * @param string $image_url + * @return int|WP_Error attachment id + */ + public function upload_product_image( $image_url ) { + return $this->upload_image_from_url( $image_url, 'product_image' ); + } + + /** + * Upload product category image from URL. + * + * @since 2.5.0 + * @param string $image_url + * @return int|WP_Error attachment id + */ + public function upload_product_category_image( $image_url ) { + return $this->upload_image_from_url( $image_url, 'product_category_image' ); + } + + /** + * Upload image from URL. + * + * @throws WC_API_Exception + * + * @since 2.5.0 + * @param string $image_url + * @param string $upload_for + * @return array|WP_Error + */ + protected function upload_image_from_url( $image_url, $upload_for = 'product_image' ) { + $file_name = basename( current( explode( '?', $image_url ) ) ); + $parsed_url = @parse_url( $image_url ); + + // Check parsed URL. + if ( ! $parsed_url || ! is_array( $parsed_url ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_' . $upload_for, sprintf( __( 'Invalid URL %s.', 'woocommerce' ), $image_url ), 400 ); + } + + // Ensure url is valid. + $image_url = str_replace( ' ', '%20', $image_url ); + + // Get the file. + $response = wp_safe_remote_get( $image_url, array( + 'timeout' => 10, + ) ); + + if ( is_wp_error( $response ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_remote_' . $upload_for, sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ) . ' ' . sprintf( __( 'Error: %s.', 'woocommerce' ), $response->get_error_message() ), 400 ); + } elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_remote_' . $upload_for, sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ), 400 ); + } + + // Ensure we have a file name and type. + $wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() ); + + if ( ! $wp_filetype['type'] ) { + $headers = wp_remote_retrieve_headers( $response ); + if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) { + $disposition = end( explode( 'filename=', $headers['content-disposition'] ) ); + $disposition = sanitize_file_name( $disposition ); + $file_name = $disposition; + } elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) { + $file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] ); + } + unset( $headers ); + + // Recheck filetype + $wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() ); + + if ( ! $wp_filetype['type'] ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_' . $upload_for, __( 'Invalid image type.', 'woocommerce' ), 400 ); + } + } + + // Upload the file. + $upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) ); + + if ( $upload['error'] ) { + throw new WC_API_Exception( 'woocommerce_api_' . $upload_for . '_upload_error', $upload['error'], 400 ); + } + + // Get filesize. + $filesize = filesize( $upload['file'] ); + + if ( 0 == $filesize ) { + @unlink( $upload['file'] ); + unset( $upload ); + throw new WC_API_Exception( 'woocommerce_api_' . $upload_for . '_upload_file_error', __( 'Zero size file downloaded.', 'woocommerce' ), 400 ); + } + + unset( $response ); + + do_action( 'woocommerce_api_uploaded_image_from_url', $upload, $image_url, $upload_for ); + + return $upload; + } + + /** + * Sets product image as attachment and returns the attachment ID. + * + * @since 2.2 + * @param array $upload + * @param int $id + * @return int + */ + protected function set_product_image_as_attachment( $upload, $id ) { + return $this->set_uploaded_image_as_attachment( $upload, $id ); + } + + /** + * Sets uploaded category image as attachment and returns the attachment ID. + * + * @since 2.5.0 + * @param integer $upload Upload information from wp_upload_bits + * @return int Attachment ID + */ + protected function set_product_category_image_as_attachment( $upload ) { + return $this->set_uploaded_image_as_attachment( $upload ); + } + + /** + * Set uploaded image as attachment. + * + * @since 2.5.0 + * @param array $upload Upload information from wp_upload_bits + * @param int $id Post ID. Default to 0. + * @return int Attachment ID + */ + protected function set_uploaded_image_as_attachment( $upload, $id = 0 ) { + $info = wp_check_filetype( $upload['file'] ); + $title = ''; + $content = ''; + + if ( $image_meta = @wp_read_image_metadata( $upload['file'] ) ) { + if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { + $title = wc_clean( $image_meta['title'] ); + } + if ( trim( $image_meta['caption'] ) ) { + $content = wc_clean( $image_meta['caption'] ); + } + } + + $attachment = array( + 'post_mime_type' => $info['type'], + 'guid' => $upload['url'], + 'post_parent' => $id, + 'post_title' => $title, + 'post_content' => $content, + ); + + $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $id ); + if ( ! is_wp_error( $attachment_id ) ) { + wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $upload['file'] ) ); + } + + return $attachment_id; + } + + /** + * Get attribute options. + * + * @param int $product_id + * @param array $attribute + * @return array + */ + protected function get_attribute_options( $product_id, $attribute ) { + if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { + return wc_get_product_terms( $product_id, $attribute['name'], array( 'fields' => 'names' ) ); + } elseif ( isset( $attribute['value'] ) ) { + return array_map( 'trim', explode( '|', $attribute['value'] ) ); + } + + return array(); + } + + /** + * Get the attributes for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_attributes( $product ) { + + $attributes = array(); + + if ( $product->is_type( 'variation' ) ) { + + // variation attributes + foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { + + // taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_` + $attributes[] = array( + 'name' => wc_attribute_label( str_replace( 'attribute_', '', $attribute_name ), $product ), + 'slug' => str_replace( 'attribute_', '', str_replace( 'pa_', '', $attribute_name ) ), + 'option' => $attribute, + ); + } + } else { + + foreach ( $product->get_attributes() as $attribute ) { + $attributes[] = array( + 'name' => wc_attribute_label( $attribute['name'], $product ), + 'slug' => str_replace( 'pa_', '', $attribute['name'] ), + 'position' => (int) $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } + } + + return $attributes; + } + + /** + * Get the downloads for a product or product variation + * + * @since 2.1 + * @param WC_Product|WC_Product_Variation $product + * @return array + */ + private function get_downloads( $product ) { + + $downloads = array(); + + if ( $product->is_downloadable() ) { + + foreach ( $product->get_downloads() as $file_id => $file ) { + + $downloads[] = array( + 'id' => $file_id, // do not cast as int as this is a hash + 'name' => $file['name'], + 'file' => $file['file'], + ); + } + } + + return $downloads; + } + + /** + * Get a listing of product attributes + * + * @since 2.5.0 + * + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_attributes( $fields = null ) { + try { + // Permissions check. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_attributes', __( 'You do not have permission to read product attributes', 'woocommerce' ), 401 ); + } + + $product_attributes = array(); + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + foreach ( $attribute_taxonomies as $attribute ) { + $product_attributes[] = array( + 'id' => intval( $attribute->attribute_id ), + 'name' => $attribute->attribute_label, + 'slug' => wc_attribute_taxonomy_name( $attribute->attribute_name ), + 'type' => $attribute->attribute_type, + 'order_by' => $attribute->attribute_orderby, + 'has_archives' => (bool) $attribute->attribute_public, + ); + } + + return array( 'product_attributes' => apply_filters( 'woocommerce_api_product_attributes_response', $product_attributes, $attribute_taxonomies, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product attribute for the given ID + * + * @since 2.5.0 + * + * @param string $id product attribute term ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_product_attribute( $id, $fields = null ) { + global $wpdb; + + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'Invalid product attribute ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_attributes', __( 'You do not have permission to read product attributes', 'woocommerce' ), 401 ); + } + + $attribute = $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$wpdb->prefix}woocommerce_attribute_taxonomies + WHERE attribute_id = %d + ", $id ) ); + + if ( is_wp_error( $attribute ) || is_null( $attribute ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $product_attribute = array( + 'id' => intval( $attribute->attribute_id ), + 'name' => $attribute->attribute_label, + 'slug' => wc_attribute_taxonomy_name( $attribute->attribute_name ), + 'type' => $attribute->attribute_type, + 'order_by' => $attribute->attribute_orderby, + 'has_archives' => (bool) $attribute->attribute_public, + ); + + return array( 'product_attribute' => apply_filters( 'woocommerce_api_product_attribute_response', $product_attribute, $id, $fields, $attribute, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Validate attribute data. + * + * @since 2.5.0 + * @param string $name + * @param string $slug + * @param string $type + * @param string $order_by + * @param bool $new_data + * @return bool + * @throws WC_API_Exception + */ + protected function validate_attribute_data( $name, $slug, $type, $order_by, $new_data = true ) { + if ( empty( $name ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_name', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'name' ), 400 ); + } + + if ( strlen( $slug ) >= 28 ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), $slug ), 400 ); + } elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), 400 ); + } elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), 400 ); + } + + // Validate the attribute type + if ( ! in_array( wc_clean( $type ), array_keys( wc_get_attribute_types() ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_type', sprintf( __( 'Invalid product attribute type - the product attribute type must be any of these: %s', 'woocommerce' ), implode( ', ', array_keys( wc_get_attribute_types() ) ) ), 400 ); + } + + // Validate the attribute order by + if ( ! in_array( wc_clean( $order_by ), array( 'menu_order', 'name', 'name_num', 'id' ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_order_by', sprintf( __( 'Invalid product attribute order_by type - the product attribute order_by type must be any of these: %s', 'woocommerce' ), implode( ', ', array( 'menu_order', 'name', 'name_num', 'id' ) ) ), 400 ); + } + + return true; + } + + /** + * Create a new product attribute. + * + * @since 2.5.0 + * + * @param array $data Posted data. + * + * @return array|WP_Error + */ + public function create_product_attribute( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_attribute' ), 400 ); + } + + $data = $data['product_attribute']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_attribute', __( 'You do not have permission to create product attributes', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_product_attribute_data', $data, $this ); + + if ( ! isset( $data['name'] ) ) { + $data['name'] = ''; + } + + // Set the attribute slug. + if ( ! isset( $data['slug'] ) ) { + $data['slug'] = wc_sanitize_taxonomy_name( stripslashes( $data['name'] ) ); + } else { + $data['slug'] = preg_replace( '/^pa\_/', '', wc_sanitize_taxonomy_name( stripslashes( $data['slug'] ) ) ); + } + + // Set attribute type when not sent. + if ( ! isset( $data['type'] ) ) { + $data['type'] = 'select'; + } + + // Set order by when not sent. + if ( ! isset( $data['order_by'] ) ) { + $data['order_by'] = 'menu_order'; + } + + // Validate the attribute data. + $this->validate_attribute_data( $data['name'], $data['slug'], $data['type'], $data['order_by'], true ); + + $insert = $wpdb->insert( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( + 'attribute_label' => $data['name'], + 'attribute_name' => $data['slug'], + 'attribute_type' => $data['type'], + 'attribute_orderby' => $data['order_by'], + 'attribute_public' => isset( $data['has_archives'] ) && true === $data['has_archives'] ? 1 : 0, + ), + array( '%s', '%s', '%s', '%s', '%d' ) + ); + + // Checks for an error in the product creation. + if ( is_wp_error( $insert ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_attribute', $insert->get_error_message(), 400 ); + } + + $id = $wpdb->insert_id; + + do_action( 'woocommerce_api_create_product_attribute', $id, $data ); + + // Clear transients. + wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); + delete_transient( 'wc_attribute_taxonomies' ); + + $this->server->send_status( 201 ); + + return $this->get_product_attribute( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product attribute. + * + * @since 2.5.0 + * + * @param int $id the attribute ID. + * @param array $data + * + * @return array|WP_Error + */ + public function edit_product_attribute( $id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_attribute' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_attribute']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_attribute', __( 'You do not have permission to edit product attributes', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_attribute_data', $data, $this ); + $attribute = $this->get_product_attribute( $id ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $attribute_name = isset( $data['name'] ) ? $data['name'] : $attribute['product_attribute']['name']; + $attribute_type = isset( $data['type'] ) ? $data['type'] : $attribute['product_attribute']['type']; + $attribute_order_by = isset( $data['order_by'] ) ? $data['order_by'] : $attribute['product_attribute']['order_by']; + + if ( isset( $data['slug'] ) ) { + $attribute_slug = wc_sanitize_taxonomy_name( stripslashes( $data['slug'] ) ); + } else { + $attribute_slug = $attribute['product_attribute']['slug']; + } + $attribute_slug = preg_replace( '/^pa\_/', '', $attribute_slug ); + + if ( isset( $data['has_archives'] ) ) { + $attribute_public = true === $data['has_archives'] ? 1 : 0; + } else { + $attribute_public = $attribute['product_attribute']['has_archives']; + } + + // Validate the attribute data. + $this->validate_attribute_data( $attribute_name, $attribute_slug, $attribute_type, $attribute_order_by, false ); + + $update = $wpdb->update( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( + 'attribute_label' => $attribute_name, + 'attribute_name' => $attribute_slug, + 'attribute_type' => $attribute_type, + 'attribute_orderby' => $attribute_order_by, + 'attribute_public' => $attribute_public, + ), + array( 'attribute_id' => $id ), + array( '%s', '%s', '%s', '%s', '%d' ), + array( '%d' ) + ); + + // Checks for an error in the product creation. + if ( false === $update ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_attribute', __( 'Could not edit the attribute', 'woocommerce' ), 400 ); + } + + do_action( 'woocommerce_api_edit_product_attribute', $id, $data ); + + // Clear transients. + wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); + delete_transient( 'wc_attribute_taxonomies' ); + + return $this->get_product_attribute( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product attribute. + * + * @since 2.5.0 + * + * @param int $id the product attribute ID. + * + * @return array|WP_Error + */ + public function delete_product_attribute( $id ) { + global $wpdb; + + try { + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_attribute', __( 'You do not have permission to delete product attributes', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + + $attribute_name = $wpdb->get_var( $wpdb->prepare( " + SELECT attribute_name + FROM {$wpdb->prefix}woocommerce_attribute_taxonomies + WHERE attribute_id = %d + ", $id ) ); + + if ( is_null( $attribute_name ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $deleted = $wpdb->delete( + $wpdb->prefix . 'woocommerce_attribute_taxonomies', + array( 'attribute_id' => $id ), + array( '%d' ) + ); + + if ( false === $deleted ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_attribute', __( 'Could not delete the attribute', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name( $attribute_name ); + + if ( taxonomy_exists( $taxonomy ) ) { + $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0' ); + foreach ( $terms as $term ) { + wp_delete_term( $term->term_id, $taxonomy ); + } + } + + do_action( 'woocommerce_attribute_deleted', $id, $attribute_name, $taxonomy ); + do_action( 'woocommerce_api_delete_product_attribute', $id, $this ); + + // Clear transients. + wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); + delete_transient( 'wc_attribute_taxonomies' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_attribute' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a listing of product attribute terms. + * + * @since 2.5.0 + * + * @param int $attribute_id Attribute ID. + * @param string|null $fields Fields to limit response to. + * + * @return array|WP_Error + */ + public function get_product_attribute_terms( $attribute_id, $fields = null ) { + try { + // Permissions check. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_attribute_terms', __( 'You do not have permission to read product attribute terms', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name_by_id( $attribute_id ); + + if ( ! $taxonomy ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $args = array( 'hide_empty' => false ); + $orderby = wc_attribute_orderby( $taxonomy ); + + switch ( $orderby ) { + case 'name' : + $args['orderby'] = 'name'; + $args['menu_order'] = false; + break; + case 'id' : + $args['orderby'] = 'id'; + $args['order'] = 'ASC'; + $args['menu_order'] = false; + break; + case 'menu_order' : + $args['menu_order'] = 'ASC'; + break; + } + + $terms = get_terms( $taxonomy, $args ); + $attribute_terms = array(); + + foreach ( $terms as $term ) { + $attribute_terms[] = array( + 'id' => $term->term_id, + 'slug' => $term->slug, + 'name' => $term->name, + 'count' => $term->count, + ); + } + + return array( 'product_attribute_terms' => apply_filters( 'woocommerce_api_product_attribute_terms_response', $attribute_terms, $terms, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product attribute term for the given ID. + * + * @since 2.5.0 + * + * @param int $attribute_id Attribute ID. + * @param string $id Product attribute term ID. + * @param string|null $fields Fields to limit response to. + * + * @return array|WP_Error + */ + public function get_product_attribute_term( $attribute_id, $id, $fields = null ) { + global $wpdb; + + try { + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_term_id', __( 'Invalid product attribute ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_attribute_terms', __( 'You do not have permission to read product attribute terms', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name_by_id( $attribute_id ); + + if ( ! $taxonomy ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $term = get_term( $id, $taxonomy ); + + if ( is_wp_error( $term ) || is_null( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_term_id', __( 'A product attribute term with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $attribute_term = array( + 'id' => $term->term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'count' => $term->count, + ); + + return array( 'product_attribute_term' => apply_filters( 'woocommerce_api_product_attribute_response', $attribute_term, $id, $fields, $term, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product attribute term. + * + * @since 2.5.0 + * + * @param int $attribute_id Attribute ID. + * @param array $data Posted data. + * + * @return array|WP_Error + */ + public function create_product_attribute_term( $attribute_id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute_term'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_term_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_attribute_term' ), 400 ); + } + + $data = $data['product_attribute_term']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_attribute', __( 'You do not have permission to create product attributes', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name_by_id( $attribute_id ); + + if ( ! $taxonomy ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $data = apply_filters( 'woocommerce_api_create_product_attribute_term_data', $data, $this ); + + // Check if attribute term name is specified. + if ( ! isset( $data['name'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_term_name', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'name' ), 400 ); + } + + $args = array(); + + // Set the attribute term slug. + if ( isset( $data['slug'] ) ) { + $args['slug'] = sanitize_title( wp_unslash( $data['slug'] ) ); + } + + $term = wp_insert_term( $data['name'], $taxonomy, $args ); + + // Checks for an error in the term creation. + if ( is_wp_error( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_attribute', $term->get_error_message(), 400 ); + } + + $id = $term['term_id']; + + do_action( 'woocommerce_api_create_product_attribute_term', $id, $data ); + + $this->server->send_status( 201 ); + + return $this->get_product_attribute_term( $attribute_id, $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product attribute term. + * + * @since 2.5.0 + * + * @param int $attribute_id Attribute ID. + * @param int $id the attribute ID. + * @param array $data + * + * @return array|WP_Error + */ + public function edit_product_attribute_term( $attribute_id, $id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_attribute_term'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_attribute_term_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_attribute_term' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_attribute_term']; + + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_attribute', __( 'You do not have permission to edit product attributes', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name_by_id( $attribute_id ); + + if ( ! $taxonomy ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_attribute_term_data', $data, $this ); + + $args = array(); + + // Update name. + if ( isset( $data['name'] ) ) { + $args['name'] = wc_clean( wp_unslash( $data['name'] ) ); + } + + // Update slug. + if ( isset( $data['slug'] ) ) { + $args['slug'] = sanitize_title( wp_unslash( $data['slug'] ) ); + } + + $term = wp_update_term( $id, $taxonomy, $args ); + + if ( is_wp_error( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_attribute_term', $term->get_error_message(), 400 ); + } + + do_action( 'woocommerce_api_edit_product_attribute_term', $id, $data ); + + return $this->get_product_attribute_term( $attribute_id, $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product attribute term. + * + * @since 2.5.0 + * + * @param int $attribute_id Attribute ID. + * @param int $id the product attribute ID. + * + * @return array|WP_Error + */ + public function delete_product_attribute_term( $attribute_id, $id ) { + global $wpdb; + + try { + // Check permissions. + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_attribute_term', __( 'You do not have permission to delete product attribute terms', 'woocommerce' ), 401 ); + } + + $taxonomy = wc_attribute_taxonomy_name_by_id( $attribute_id ); + + if ( ! $taxonomy ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_attribute_id', __( 'A product attribute with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $id = absint( $id ); + $term = wp_delete_term( $id, $taxonomy ); + + if ( ! $term ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_attribute_term', sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), 'product_attribute_term' ), 500 ); + } elseif ( is_wp_error( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_attribute_term', $term->get_error_message(), 400 ); + } + + do_action( 'woocommerce_api_delete_product_attribute_term', $id, $this ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_attribute' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Clear product + * + * @param int $product_id + */ + protected function clear_product( $product_id ) { + if ( ! is_numeric( $product_id ) || 0 >= $product_id ) { + return; + } + + // Delete product attachments + $attachments = get_children( array( + 'post_parent' => $product_id, + 'post_status' => 'any', + 'post_type' => 'attachment', + ) ); + + foreach ( (array) $attachments as $attachment ) { + wp_delete_attachment( $attachment->ID, true ); + } + + // Delete product + $product = wc_get_product( $product_id ); + $product->delete( true ); + } + + /** + * Bulk update or insert products + * Accepts an array with products in the formats supported by + * WC_API_Products->create_product() and WC_API_Products->edit_product() + * + * @since 2.4.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + + try { + if ( ! isset( $data['products'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_products_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'products' ), 400 ); + } + + $data = $data['products']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'products' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_products_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $products = array(); + + foreach ( $data as $_product ) { + $product_id = 0; + $product_sku = ''; + + // Try to get the product ID + if ( isset( $_product['id'] ) ) { + $product_id = intval( $_product['id'] ); + } + + if ( ! $product_id && isset( $_product['sku'] ) ) { + $product_sku = wc_clean( $_product['sku'] ); + $product_id = wc_get_product_id_by_sku( $product_sku ); + } + + if ( $product_id ) { + + // Product exists / edit product + $edit = $this->edit_product( $product_id, array( 'product' => $_product ) ); + + if ( is_wp_error( $edit ) ) { + $products[] = array( + 'id' => $product_id, + 'sku' => $product_sku, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $products[] = $edit['product']; + } + } else { + + // Product don't exists / create product + $new = $this->create_product( array( 'product' => $_product ) ); + + if ( is_wp_error( $new ) ) { + $products[] = array( + 'id' => $product_id, + 'sku' => $product_sku, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $products[] = $new['product']; + } + } + } + + return array( 'products' => apply_filters( 'woocommerce_api_products_bulk_response', $products, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a listing of product shipping classes. + * + * @since 2.5.0 + * @param string|null $fields Fields to limit response to + * @return array|WP_Error List of product shipping classes if succeed, + * otherwise WP_Error will be returned + */ + public function get_product_shipping_classes( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_shipping_classes', __( 'You do not have permission to read product shipping classes', 'woocommerce' ), 401 ); + } + + $product_shipping_classes = array(); + + $terms = get_terms( 'product_shipping_class', array( 'hide_empty' => false, 'fields' => 'ids' ) ); + + foreach ( $terms as $term_id ) { + $product_shipping_classes[] = current( $this->get_product_shipping_class( $term_id, $fields ) ); + } + + return array( 'product_shipping_classes' => apply_filters( 'woocommerce_api_product_shipping_classes_response', $product_shipping_classes, $terms, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the product shipping class for the given ID. + * + * @since 2.5.0 + * @param string $id Product shipping class term ID + * @param string|null $fields Fields to limit response to + * @return array|WP_Error Product shipping class if succeed, otherwise + * WP_Error will be returned + */ + public function get_product_shipping_class( $id, $fields = null ) { + try { + $id = absint( $id ); + if ( ! $id ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_shipping_class_id', __( 'Invalid product shipping class ID', 'woocommerce' ), 400 ); + } + + // Permissions check + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_shipping_classes', __( 'You do not have permission to read product shipping classes', 'woocommerce' ), 401 ); + } + + $term = get_term( $id, 'product_shipping_class' ); + + if ( is_wp_error( $term ) || is_null( $term ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_shipping_class_id', __( 'A product shipping class with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $term_id = intval( $term->term_id ); + + $product_shipping_class = array( + 'id' => $term_id, + 'name' => $term->name, + 'slug' => $term->slug, + 'parent' => $term->parent, + 'description' => $term->description, + 'count' => intval( $term->count ), + ); + + return array( 'product_shipping_class' => apply_filters( 'woocommerce_api_product_shipping_class_response', $product_shipping_class, $id, $fields, $term, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a new product shipping class. + * + * @since 2.5.0 + * @param array $data Posted data + * @return array|WP_Error Product shipping class if succeed, otherwise + * WP_Error will be returned + */ + public function create_product_shipping_class( $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_shipping_class'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_shipping_class_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'product_shipping_class' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_product_shipping_class', __( 'You do not have permission to create product shipping classes', 'woocommerce' ), 401 ); + } + + $defaults = array( + 'name' => '', + 'slug' => '', + 'description' => '', + 'parent' => 0, + ); + + $data = wp_parse_args( $data['product_shipping_class'], $defaults ); + $data = apply_filters( 'woocommerce_api_create_product_shipping_class_data', $data, $this ); + + // Check parent. + $data['parent'] = absint( $data['parent'] ); + if ( $data['parent'] ) { + $parent = get_term_by( 'id', $data['parent'], 'product_shipping_class' ); + if ( ! $parent ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_product_shipping_class_parent', __( 'Product shipping class parent is invalid', 'woocommerce' ), 400 ); + } + } + + $insert = wp_insert_term( $data['name'], 'product_shipping_class', $data ); + if ( is_wp_error( $insert ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_product_shipping_class', $insert->get_error_message(), 400 ); + } + + $id = $insert['term_id']; + + do_action( 'woocommerce_api_create_product_shipping_class', $id, $data ); + + $this->server->send_status( 201 ); + + return $this->get_product_shipping_class( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a product shipping class. + * + * @since 2.5.0 + * @param int $id Product shipping class term ID + * @param array $data Posted data + * @return array|WP_Error Product shipping class if succeed, otherwise + * WP_Error will be returned + */ + public function edit_product_shipping_class( $id, $data ) { + global $wpdb; + + try { + if ( ! isset( $data['product_shipping_class'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_product_shipping_class', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'product_shipping_class' ), 400 ); + } + + $id = absint( $id ); + $data = $data['product_shipping_class']; + + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_product_shipping_class', __( 'You do not have permission to edit product shipping classes', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_edit_product_shipping_class_data', $data, $this ); + $shipping_class = $this->get_product_shipping_class( $id ); + + if ( is_wp_error( $shipping_class ) ) { + return $shipping_class; + } + + $update = wp_update_term( $id, 'product_shipping_class', $data ); + if ( is_wp_error( $update ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_edit_product_shipping_class', __( 'Could not edit the shipping class', 'woocommerce' ), 400 ); + } + + do_action( 'woocommerce_api_edit_product_shipping_class', $id, $data ); + + return $this->get_product_shipping_class( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a product shipping class. + * + * @since 2.5.0 + * @param int $id Product shipping class term ID + * @return array|WP_Error Success message if succeed, otherwise WP_Error + * will be returned + */ + public function delete_product_shipping_class( $id ) { + global $wpdb; + + try { + // Check permissions + if ( ! current_user_can( 'manage_product_terms' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_product_shipping_class', __( 'You do not have permission to delete product shipping classes', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + $deleted = wp_delete_term( $id, 'product_shipping_class' ); + if ( ! $deleted || is_wp_error( $deleted ) ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_product_shipping_class', __( 'Could not delete the shipping class', 'woocommerce' ), 401 ); + } + + do_action( 'woocommerce_api_delete_product_shipping_class', $id, $this ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'product_shipping_class' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-reports.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-reports.php new file mode 100644 index 0000000..552fd25 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-reports.php @@ -0,0 +1,330 @@ +base ] = array( + array( array( $this, 'get_reports' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales + $routes[ $this->base . '/sales' ] = array( + array( array( $this, 'get_sales_report' ), WC_API_Server::READABLE ), + ); + + # GET /reports/sales/top_sellers + $routes[ $this->base . '/sales/top_sellers' ] = array( + array( array( $this, 'get_top_sellers_report' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get a simple listing of available reports + * + * @since 2.1 + * @return array + */ + public function get_reports() { + return array( 'reports' => array( 'sales', 'sales/top_sellers' ) ); + } + + /** + * Get the sales report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_sales_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + // check for WP_Error + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + // new customers + $users_query = new WP_User_Query( + array( + 'fields' => array( 'user_registered' ), + 'role' => 'customer', + ) + ); + + $customers = $users_query->get_results(); + + foreach ( $customers as $key => $customer ) { + if ( strtotime( $customer->user_registered ) < $this->report->start_date || strtotime( $customer->user_registered ) > $this->report->end_date ) { + unset( $customers[ $key ] ); + } + } + + $total_customers = count( $customers ); + $report_data = $this->report->get_report_data(); + $period_totals = array(); + + // setup period totals by ensuring each period in the interval has data + for ( $i = 0; $i <= $this->report->chart_interval; $i ++ ) { + + switch ( $this->report->chart_groupby ) { + case 'day' : + $time = date( 'Y-m-d', strtotime( "+{$i} DAY", $this->report->start_date ) ); + break; + default : + $time = date( 'Y-m', strtotime( "+{$i} MONTH", $this->report->start_date ) ); + break; + } + + // set the customer signups for each period + $customer_count = 0; + foreach ( $customers as $customer ) { + if ( date( ( 'day' == $this->report->chart_groupby ) ? 'Y-m-d' : 'Y-m', strtotime( $customer->user_registered ) ) == $time ) { + $customer_count++; + } + } + + $period_totals[ $time ] = array( + 'sales' => wc_format_decimal( 0.00, 2 ), + 'orders' => 0, + 'items' => 0, + 'tax' => wc_format_decimal( 0.00, 2 ), + 'shipping' => wc_format_decimal( 0.00, 2 ), + 'discount' => wc_format_decimal( 0.00, 2 ), + 'customers' => $customer_count, + ); + } + + // add total sales, total order count, total tax and total shipping for each period + foreach ( $report_data->orders as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['sales'] = wc_format_decimal( $order->total_sales, 2 ); + $period_totals[ $time ]['tax'] = wc_format_decimal( $order->total_tax + $order->total_shipping_tax, 2 ); + $period_totals[ $time ]['shipping'] = wc_format_decimal( $order->total_shipping, 2 ); + } + + foreach ( $report_data->order_counts as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['orders'] = (int) $order->count; + } + + // add total order items for each period + foreach ( $report_data->order_items as $order_item ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order_item->post_date ) ) : date( 'Y-m', strtotime( $order_item->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['items'] = (int) $order_item->order_item_count; + } + + // add total discount for each period + foreach ( $report_data->coupons as $discount ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $discount->post_date ) ) : date( 'Y-m', strtotime( $discount->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['discount'] = wc_format_decimal( $discount->discount_amount, 2 ); + } + + $sales_data = array( + 'total_sales' => $report_data->total_sales, + 'net_sales' => $report_data->net_sales, + 'average_sales' => $report_data->average_sales, + 'total_orders' => $report_data->total_orders, + 'total_items' => $report_data->total_items, + 'total_tax' => wc_format_decimal( $report_data->total_tax + $report_data->total_shipping_tax, 2 ), + 'total_shipping' => $report_data->total_shipping, + 'total_refunds' => $report_data->total_refunds, + 'total_discount' => $report_data->total_coupons, + 'totals_grouped_by' => $this->report->chart_groupby, + 'totals' => $period_totals, + 'total_customers' => $total_customers, + ); + + return array( 'sales' => apply_filters( 'woocommerce_api_report_response', $sales_data, $this->report, $fields, $this->server ) ); + } + + /** + * Get the top sellers report + * + * @since 2.1 + * @param string $fields fields to include in response + * @param array $filter date filtering + * @return array|WP_Error + */ + public function get_top_sellers_report( $fields = null, $filter = array() ) { + + // check user permissions + $check = $this->validate_request(); + + if ( is_wp_error( $check ) ) { + return $check; + } + + // set date filtering + $this->setup_report( $filter ); + + $top_sellers = $this->report->get_order_report_data( array( + 'data' => array( + '_product_id' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => '', + 'name' => 'product_id', + ), + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_qty', + ), + ), + 'order_by' => 'order_item_qty DESC', + 'group_by' => 'product_id', + 'limit' => isset( $filter['limit'] ) ? absint( $filter['limit'] ) : 12, + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + $top_sellers_data = array(); + + foreach ( $top_sellers as $top_seller ) { + + $product = wc_get_product( $top_seller->product_id ); + + if ( $product ) { + $top_sellers_data[] = array( + 'title' => $product->get_name(), + 'product_id' => $top_seller->product_id, + 'quantity' => $top_seller->order_item_qty, + ); + } + } + + return array( 'top_sellers' => apply_filters( 'woocommerce_api_report_response', $top_sellers_data, $this->report, $fields, $this->server ) ); + } + + /** + * Setup the report object and parse any date filtering + * + * @since 2.1 + * @param array $filter date filtering + */ + private function setup_report( $filter ) { + + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-admin-report.php' ); + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-report-sales-by-date.php' ); + + $this->report = new WC_Report_Sales_By_Date(); + + if ( empty( $filter['period'] ) ) { + + // custom date range + $filter['period'] = 'custom'; + + if ( ! empty( $filter['date_min'] ) || ! empty( $filter['date_max'] ) ) { + + // overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges + $_GET['start_date'] = $this->server->parse_datetime( $filter['date_min'] ); + $_GET['end_date'] = isset( $filter['date_max'] ) ? $this->server->parse_datetime( $filter['date_max'] ) : null; + + } else { + + // default custom range to today + $_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) ); + } + } else { + + // ensure period is valid + if ( ! in_array( $filter['period'], array( 'week', 'month', 'last_month', 'year' ) ) ) { + $filter['period'] = 'week'; + } + + // TODO: change WC_Admin_Report class to use "week" instead, as it's more consistent with other periods + // allow "week" for period instead of "7day" + if ( 'week' === $filter['period'] ) { + $filter['period'] = '7day'; + } + } + + $this->report->calculate_current_range( $filter['period'] ); + } + + /** + * Verify that the current user has permission to view reports + * + * @since 2.1 + * @see WC_API_Resource::validate_request() + * + * @param null $id unused + * @param null $type unused + * @param null $context unused + * + * @return true|WP_Error + */ + protected function validate_request( $id = null, $type = null, $context = null ) { + + if ( current_user_can( 'view_woocommerce_reports' ) ) { + return true; + } + + return new WP_Error( + 'woocommerce_api_user_cannot_read_report', + __( 'You do not have permission to read this report', 'woocommerce' ), + array( 'status' => 401 ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-resource.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-resource.php new file mode 100644 index 0000000..4aface6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-resource.php @@ -0,0 +1,471 @@ +server = $server; + + // automatically register routes for sub-classes + add_filter( 'woocommerce_api_endpoints', array( $this, 'register_routes' ) ); + + // maybe add meta to top-level resource responses + foreach ( array( 'order', 'coupon', 'customer', 'product', 'report' ) as $resource ) { + add_filter( "woocommerce_api_{$resource}_response", array( $this, 'maybe_add_meta' ), 15, 2 ); + } + + $response_names = array( + 'order', + 'coupon', + 'customer', + 'product', + 'report', + 'customer_orders', + 'customer_downloads', + 'order_note', + 'order_refund', + 'product_reviews', + 'product_category', + 'tax', + 'tax_class', + ); + + foreach ( $response_names as $name ) { + + /** + * Remove fields from responses when requests specify certain fields + * note these are hooked at a later priority so data added via + * filters (e.g. customer data to the order response) still has the + * fields filtered properly + */ + add_filter( "woocommerce_api_{$name}_response", array( $this, 'filter_response_fields' ), 20, 3 ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer + * 2) the ID returns a valid post object and matches the provided post type + * 3) the current user has the proper permissions to read/edit/delete the post + * + * @since 2.1 + * @param string|int $id the post ID + * @param string $type the post type, either `shop_order`, `shop_coupon`, or `product` + * @param string $context the context of the request, either `read`, `edit` or `delete` + * @return int|WP_Error valid post ID or WP_Error if any of the checks fails + */ + protected function validate_request( $id, $type, $context ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type || 'shop_webhook' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + $id = absint( $id ); + + // Validate ID + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}_id", sprintf( __( 'Invalid %s ID', 'woocommerce' ), $type ), array( 'status' => 404 ) ); + } + + // Only custom post types have per-post type/permission checks + if ( 'customer' !== $type ) { + + $post = get_post( $id ); + + if ( null === $post ) { + return new WP_Error( "woocommerce_api_no_{$resource_name}_found", sprintf( __( 'No %1$s found with the ID equal to %2$s', 'woocommerce' ), $resource_name, $id ), array( 'status' => 404 ) ); + } + + // For checking permissions, product variations are the same as the product post type + $post_type = ( 'product_variation' === $post->post_type ) ? 'product' : $post->post_type; + + // Validate post type + if ( $type !== $post_type ) { + return new WP_Error( "woocommerce_api_invalid_{$resource_name}", sprintf( __( 'Invalid %s', 'woocommerce' ), $resource_name ), array( 'status' => 404 ) ); + } + + // Validate permissions + switch ( $context ) { + + case 'read': + if ( ! $this->is_readable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_read_{$resource_name}", sprintf( __( 'You do not have permission to read this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! $this->is_editable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_edit_{$resource_name}", sprintf( __( 'You do not have permission to edit this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! $this->is_deletable( $post ) ) { + return new WP_Error( "woocommerce_api_user_cannot_delete_{$resource_name}", sprintf( __( 'You do not have permission to delete this %s', 'woocommerce' ), $resource_name ), array( 'status' => 401 ) ); + } + break; + } + } + + return $id; + } + + /** + * Add common request arguments to argument list before WP_Query is run + * + * @since 2.1 + * @param array $base_args required arguments for the query (e.g. `post_type`, etc) + * @param array $request_args arguments provided in the request + * @return array + */ + protected function merge_query_args( $base_args, $request_args ) { + + $args = array(); + + // date + if ( ! empty( $request_args['created_at_min'] ) || ! empty( $request_args['created_at_max'] ) || ! empty( $request_args['updated_at_min'] ) || ! empty( $request_args['updated_at_max'] ) ) { + + $args['date_query'] = array(); + + // resources created after specified date + if ( ! empty( $request_args['created_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'after' => $this->server->parse_datetime( $request_args['created_at_min'] ), 'inclusive' => true ); + } + + // resources created before specified date + if ( ! empty( $request_args['created_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_date_gmt', 'before' => $this->server->parse_datetime( $request_args['created_at_max'] ), 'inclusive' => true ); + } + + // resources updated after specified date + if ( ! empty( $request_args['updated_at_min'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'after' => $this->server->parse_datetime( $request_args['updated_at_min'] ), 'inclusive' => true ); + } + + // resources updated before specified date + if ( ! empty( $request_args['updated_at_max'] ) ) { + $args['date_query'][] = array( 'column' => 'post_modified_gmt', 'before' => $this->server->parse_datetime( $request_args['updated_at_max'] ), 'inclusive' => true ); + } + } + + // search + if ( ! empty( $request_args['q'] ) ) { + $args['s'] = $request_args['q']; + } + + // resources per response + if ( ! empty( $request_args['limit'] ) ) { + $args['posts_per_page'] = $request_args['limit']; + } + + // resource offset + if ( ! empty( $request_args['offset'] ) ) { + $args['offset'] = $request_args['offset']; + } + + // order (ASC or DESC, ASC by default) + if ( ! empty( $request_args['order'] ) ) { + $args['order'] = $request_args['order']; + } + + // orderby + if ( ! empty( $request_args['orderby'] ) ) { + $args['orderby'] = $request_args['orderby']; + + // allow sorting by meta value + if ( ! empty( $request_args['orderby_meta_key'] ) ) { + $args['meta_key'] = $request_args['orderby_meta_key']; + } + } + + // allow post status change + if ( ! empty( $request_args['post_status'] ) ) { + $args['post_status'] = $request_args['post_status']; + unset( $request_args['post_status'] ); + } + + // filter by a list of post id + if ( ! empty( $request_args['in'] ) ) { + $args['post__in'] = explode( ',', $request_args['in'] ); + unset( $request_args['in'] ); + } + + // exclude by a list of post id + if ( ! empty( $request_args['not_in'] ) ) { + $args['post__not_in'] = explode( ',', $request_args['not_in'] ); + unset( $request_args['not_in'] ); + } + + // resource page + $args['paged'] = ( isset( $request_args['page'] ) ) ? absint( $request_args['page'] ) : 1; + + $args = apply_filters( 'woocommerce_api_query_args', $args, $request_args ); + + return array_merge( $base_args, $args ); + } + + /** + * Add meta to resources when requested by the client. Meta is added as a top-level + * `_meta` attribute (e.g. `order_meta`) as a list of key/value pairs + * + * @since 2.1 + * @param array $data the resource data + * @param object $resource the resource object (e.g WC_Order) + * @return mixed + */ + public function maybe_add_meta( $data, $resource ) { + + if ( isset( $this->server->params['GET']['filter']['meta'] ) && 'true' === $this->server->params['GET']['filter']['meta'] && is_object( $resource ) ) { + + // don't attempt to add meta more than once + if ( preg_grep( '/[a-z]+_meta/', array_keys( $data ) ) ) { + return $data; + } + + // define the top-level property name for the meta + switch ( get_class( $resource ) ) { + + case 'WC_Order': + $meta_name = 'order_meta'; + break; + + case 'WC_Coupon': + $meta_name = 'coupon_meta'; + break; + + case 'WP_User': + $meta_name = 'customer_meta'; + break; + + default: + $meta_name = 'product_meta'; + break; + } + + if ( is_a( $resource, 'WP_User' ) ) { + + // customer meta + $meta = (array) get_user_meta( $resource->ID ); + + } else { + + // coupon/order/product meta + $meta = (array) get_post_meta( $resource->get_id() ); + } + + foreach ( $meta as $meta_key => $meta_value ) { + + // don't add hidden meta by default + if ( ! is_protected_meta( $meta_key ) ) { + $data[ $meta_name ][ $meta_key ] = maybe_unserialize( $meta_value[0] ); + } + } + } + + return $data; + } + + /** + * Restrict the fields included in the response if the request specified certain only certain fields should be returned + * + * @since 2.1 + * @param array $data the response data + * @param object $resource the object that provided the response data, e.g. WC_Coupon or WC_Order + * @param array|string the requested list of fields to include in the response + * @return array response data + */ + public function filter_response_fields( $data, $resource, $fields ) { + + if ( ! is_array( $data ) || empty( $fields ) ) { + return $data; + } + + $fields = explode( ',', $fields ); + $sub_fields = array(); + + // get sub fields + foreach ( $fields as $field ) { + + if ( false !== strpos( $field, '.' ) ) { + + list( $name, $value ) = explode( '.', $field ); + + $sub_fields[ $name ] = $value; + } + } + + // iterate through top-level fields + foreach ( $data as $data_field => $data_value ) { + + // if a field has sub-fields and the top-level field has sub-fields to filter + if ( is_array( $data_value ) && in_array( $data_field, array_keys( $sub_fields ) ) ) { + + // iterate through each sub-field + foreach ( $data_value as $sub_field => $sub_field_value ) { + + // remove non-matching sub-fields + if ( ! in_array( $sub_field, $sub_fields ) ) { + unset( $data[ $data_field ][ $sub_field ] ); + } + } + } else { + + // remove non-matching top-level fields + if ( ! in_array( $data_field, $fields ) ) { + unset( $data[ $data_field ] ); + } + } + } + + return $data; + } + + /** + * Delete a given resource + * + * @since 2.1 + * @param int $id the resource ID + * @param string $type the resource post type, or `customer` + * @param bool $force true to permanently delete resource, false to move to trash (not supported for `customer`) + * @return array|WP_Error + */ + protected function delete( $id, $type, $force = false ) { + + if ( 'shop_order' === $type || 'shop_coupon' === $type ) { + $resource_name = str_replace( 'shop_', '', $type ); + } else { + $resource_name = $type; + } + + if ( 'customer' === $type ) { + + $result = wp_delete_user( $id ); + + if ( $result ) { + return array( 'message' => __( 'Permanently deleted customer', 'woocommerce' ) ); + } else { + return new WP_Error( 'woocommerce_api_cannot_delete_customer', __( 'The customer cannot be deleted', 'woocommerce' ), array( 'status' => 500 ) ); + } + } else { + + // delete order/coupon/product/webhook + $result = ( $force ) ? wp_delete_post( $id, true ) : wp_trash_post( $id ); + + if ( ! $result ) { + return new WP_Error( "woocommerce_api_cannot_delete_{$resource_name}", sprintf( __( 'This %s cannot be deleted', 'woocommerce' ), $resource_name ), array( 'status' => 500 ) ); + } + + if ( $force ) { + return array( 'message' => sprintf( __( 'Permanently deleted %s', 'woocommerce' ), $resource_name ) ); + + } else { + + $this->server->send_status( '202' ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), $resource_name ) ); + } + } + } + + + /** + * Checks if the given post is readable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_readable( $post ) { + + return $this->check_permission( $post, 'read' ); + } + + /** + * Checks if the given post is editable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_editable( $post ) { + + return $this->check_permission( $post, 'edit' ); + + } + + /** + * Checks if the given post is deletable by the current user + * + * @since 2.1 + * @see WC_API_Resource::check_permission() + * @param WP_Post|int $post + * @return bool + */ + protected function is_deletable( $post ) { + + return $this->check_permission( $post, 'delete' ); + } + + /** + * Checks the permissions for the current user given a post and context + * + * @since 2.1 + * @param WP_Post|int $post + * @param string $context the type of permission to check, either `read`, `write`, or `delete` + * @return bool true if the current user has the permissions to perform the context on the post + */ + private function check_permission( $post, $context ) { + $permission = false; + + if ( ! is_a( $post, 'WP_Post' ) ) { + $post = get_post( $post ); + } + + if ( is_null( $post ) ) { + return $permission; + } + + $post_type = get_post_type_object( $post->post_type ); + + if ( 'read' === $context ) { + $permission = 'revision' !== $post->post_type && current_user_can( $post_type->cap->read_private_posts, $post->ID ); + } elseif ( 'edit' === $context ) { + $permission = current_user_can( $post_type->cap->edit_post, $post->ID ); + } elseif ( 'delete' === $context ) { + $permission = current_user_can( $post_type->cap->delete_post, $post->ID ); + } + + return apply_filters( 'woocommerce_api_check_permission', $permission, $context, $post, $post_type ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-server.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-server.php new file mode 100644 index 0000000..9c22f6e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-server.php @@ -0,0 +1,777 @@ + self::METHOD_GET, + 'GET' => self::METHOD_GET, + 'POST' => self::METHOD_POST, + 'PUT' => self::METHOD_PUT, + 'PATCH' => self::METHOD_PATCH, + 'DELETE' => self::METHOD_DELETE, + ); + + /** + * Requested path (relative to the API root, wp-json.php) + * + * @var string + */ + public $path = ''; + + /** + * Requested method (GET/HEAD/POST/PUT/PATCH/DELETE) + * + * @var string + */ + public $method = 'HEAD'; + + /** + * Request parameters + * + * This acts as an abstraction of the superglobals + * (GET => $_GET, POST => $_POST) + * + * @var array + */ + public $params = array( 'GET' => array(), 'POST' => array() ); + + /** + * Request headers + * + * @var array + */ + public $headers = array(); + + /** + * Request files (matches $_FILES) + * + * @var array + */ + public $files = array(); + + /** + * Request/Response handler, either JSON by default + * or XML if requested by client + * + * @var WC_API_Handler + */ + public $handler; + + + /** + * Setup class and set request/response handler + * + * @since 2.1 + * @param $path + */ + public function __construct( $path ) { + + if ( empty( $path ) ) { + if ( isset( $_SERVER['PATH_INFO'] ) ) { + $path = $_SERVER['PATH_INFO']; + } else { + $path = '/'; + } + } + + $this->path = $path; + $this->method = $_SERVER['REQUEST_METHOD']; + $this->params['GET'] = $_GET; + $this->params['POST'] = $_POST; + $this->headers = $this->get_headers( $_SERVER ); + $this->files = $_FILES; + + // Compatibility for clients that can't use PUT/PATCH/DELETE + if ( isset( $_GET['_method'] ) ) { + $this->method = strtoupper( $_GET['_method'] ); + } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { + $this->method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; + } + + // load response handler + $handler_class = apply_filters( 'woocommerce_api_default_response_handler', 'WC_API_JSON_Handler', $this->path, $this ); + + $this->handler = new $handler_class(); + } + + /** + * Check authentication for the request + * + * @since 2.1 + * @return WP_User|WP_Error WP_User object indicates successful login, WP_Error indicates unsuccessful login + */ + public function check_authentication() { + + // allow plugins to remove default authentication or add their own authentication + $user = apply_filters( 'woocommerce_api_check_authentication', null, $this ); + + if ( is_a( $user, 'WP_User' ) ) { + + // API requests run under the context of the authenticated user + wp_set_current_user( $user->ID ); + + } elseif ( ! is_wp_error( $user ) ) { + + // WP_Errors are handled in serve_request() + $user = new WP_Error( 'woocommerce_api_authentication_error', __( 'Invalid authentication method', 'woocommerce' ), array( 'code' => 500 ) ); + + } + + return $user; + } + + /** + * Convert an error to an array + * + * This iterates over all error codes and messages to change it into a flat + * array. This enables simpler client behaviour, as it is represented as a + * list in JSON rather than an object/map + * + * @since 2.1 + * @param WP_Error $error + * @return array List of associative arrays with code and message keys + */ + protected function error_to_array( $error ) { + $errors = array(); + foreach ( (array) $error->errors as $code => $messages ) { + foreach ( (array) $messages as $message ) { + $errors[] = array( 'code' => $code, 'message' => $message ); + } + } + + return array( 'errors' => $errors ); + } + + /** + * Handle serving an API request + * + * Matches the current server URI to a route and runs the first matching + * callback then outputs a JSON representation of the returned value. + * + * @since 2.1 + * @uses WC_API_Server::dispatch() + */ + public function serve_request() { + + do_action( 'woocommerce_api_server_before_serve', $this ); + + $this->header( 'Content-Type', $this->handler->get_content_type(), true ); + + // the API is enabled by default + if ( ! apply_filters( 'woocommerce_api_enabled', true, $this ) || ( 'no' === get_option( 'woocommerce_api_enabled' ) ) ) { + + $this->send_status( 404 ); + + echo $this->handler->generate_response( array( 'errors' => array( 'code' => 'woocommerce_api_disabled', 'message' => 'The WooCommerce API is disabled on this site' ) ) ); + + return; + } + + $result = $this->check_authentication(); + + // if authorization check was successful, dispatch the request + if ( ! is_wp_error( $result ) ) { + $result = $this->dispatch(); + } + + // handle any dispatch errors + if ( is_wp_error( $result ) ) { + $data = $result->get_error_data(); + if ( is_array( $data ) && isset( $data['status'] ) ) { + $this->send_status( $data['status'] ); + } + + $result = $this->error_to_array( $result ); + } + + // This is a filter rather than an action, since this is designed to be + // re-entrant if needed + $served = apply_filters( 'woocommerce_api_serve_request', false, $result, $this ); + + if ( ! $served ) { + + if ( 'HEAD' === $this->method ) { + return; + } + + echo $this->handler->generate_response( $result ); + } + } + + /** + * Retrieve the route map + * + * The route map is an associative array with path regexes as the keys. The + * value is an indexed array with the callback function/method as the first + * item, and a bitmask of HTTP methods as the second item (see the class + * constants). + * + * Each route can be mapped to more than one callback by using an array of + * the indexed arrays. This allows mapping e.g. GET requests to one callback + * and POST requests to another. + * + * Note that the path regexes (array keys) must have @ escaped, as this is + * used as the delimiter with preg_match() + * + * @since 2.1 + * @return array `'/path/regex' => array( $callback, $bitmask )` or `'/path/regex' => array( array( $callback, $bitmask ), ...)` + */ + public function get_routes() { + + // index added by default + $endpoints = array( + + '/' => array( array( $this, 'get_index' ), self::READABLE ), + ); + + $endpoints = apply_filters( 'woocommerce_api_endpoints', $endpoints ); + + // Normalise the endpoints + foreach ( $endpoints as $route => &$handlers ) { + if ( count( $handlers ) <= 2 && isset( $handlers[1] ) && ! is_array( $handlers[1] ) ) { + $handlers = array( $handlers ); + } + } + + return $endpoints; + } + + /** + * Match the request to a callback and call it + * + * @since 2.1 + * @return mixed The value returned by the callback, or a WP_Error instance + */ + public function dispatch() { + + switch ( $this->method ) { + + case 'HEAD' : + case 'GET' : + $method = self::METHOD_GET; + break; + + case 'POST' : + $method = self::METHOD_POST; + break; + + case 'PUT' : + $method = self::METHOD_PUT; + break; + + case 'PATCH' : + $method = self::METHOD_PATCH; + break; + + case 'DELETE' : + $method = self::METHOD_DELETE; + break; + + default : + return new WP_Error( 'woocommerce_api_unsupported_method', __( 'Unsupported request method', 'woocommerce' ), array( 'status' => 400 ) ); + } + + foreach ( $this->get_routes() as $route => $handlers ) { + foreach ( $handlers as $handler ) { + $callback = $handler[0]; + $supported = isset( $handler[1] ) ? $handler[1] : self::METHOD_GET; + + if ( ! ( $supported & $method ) ) { + continue; + } + + $match = preg_match( '@^' . $route . '$@i', urldecode( $this->path ), $args ); + + if ( ! $match ) { + continue; + } + + if ( ! is_callable( $callback ) ) { + return new WP_Error( 'woocommerce_api_invalid_handler', __( 'The handler for the route is invalid', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $args = array_merge( $args, $this->params['GET'] ); + if ( $method & self::METHOD_POST ) { + $args = array_merge( $args, $this->params['POST'] ); + } + if ( $supported & self::ACCEPT_DATA ) { + $data = $this->handler->parse_body( $this->get_raw_data() ); + $args = array_merge( $args, array( 'data' => $data ) ); + } elseif ( $supported & self::ACCEPT_RAW_DATA ) { + $data = $this->get_raw_data(); + $args = array_merge( $args, array( 'data' => $data ) ); + } + + $args['_method'] = $method; + $args['_route'] = $route; + $args['_path'] = $this->path; + $args['_headers'] = $this->headers; + $args['_files'] = $this->files; + + $args = apply_filters( 'woocommerce_api_dispatch_args', $args, $callback ); + + // Allow plugins to halt the request via this filter + if ( is_wp_error( $args ) ) { + return $args; + } + + $params = $this->sort_callback_params( $callback, $args ); + if ( is_wp_error( $params ) ) { + return $params; + } + + return call_user_func_array( $callback, $params ); + } + } + + return new WP_Error( 'woocommerce_api_no_route', __( 'No route was found matching the URL and request method', 'woocommerce' ), array( 'status' => 404 ) ); + } + + /** + * urldecode deep. + * + * @since 2.2 + * @param string|array $value Data to decode with urldecode. + * + * @return string|array Decoded data. + */ + protected function urldecode_deep( $value ) { + if ( is_array( $value ) ) { + return array_map( array( $this, 'urldecode_deep' ), $value ); + } else { + return urldecode( $value ); + } + } + + /** + * Sort parameters by order specified in method declaration + * + * Takes a callback and a list of available params, then filters and sorts + * by the parameters the method actually needs, using the Reflection API + * + * @since 2.2 + * + * @param callable|array $callback the endpoint callback + * @param array $provided the provided request parameters + * + * @return array|WP_Error + */ + protected function sort_callback_params( $callback, $provided ) { + if ( is_array( $callback ) ) { + $ref_func = new ReflectionMethod( $callback[0], $callback[1] ); + } else { + $ref_func = new ReflectionFunction( $callback ); + } + + $wanted = $ref_func->getParameters(); + $ordered_parameters = array(); + + foreach ( $wanted as $param ) { + if ( isset( $provided[ $param->getName() ] ) ) { + // We have this parameters in the list to choose from + if ( 'data' == $param->getName() ) { + $ordered_parameters[] = $provided[ $param->getName() ]; + continue; + } + + $ordered_parameters[] = $this->urldecode_deep( $provided[ $param->getName() ] ); + } elseif ( $param->isDefaultValueAvailable() ) { + // We don't have this parameter, but it's optional + $ordered_parameters[] = $param->getDefaultValue(); + } else { + // We don't have this parameter and it wasn't optional, abort! + return new WP_Error( 'woocommerce_api_missing_callback_param', sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param->getName() ), array( 'status' => 400 ) ); + } + } + + return $ordered_parameters; + } + + /** + * Get the site index. + * + * This endpoint describes the capabilities of the site. + * + * @since 2.3 + * @return array Index entity + */ + public function get_index() { + + // General site data + $available = array( + 'store' => array( + 'name' => get_option( 'blogname' ), + 'description' => get_option( 'blogdescription' ), + 'URL' => get_option( 'siteurl' ), + 'wc_version' => WC()->version, + 'version' => WC_API::VERSION, + 'routes' => array(), + 'meta' => array( + 'timezone' => wc_timezone_string(), + 'currency' => get_woocommerce_currency(), + 'currency_format' => get_woocommerce_currency_symbol(), + 'currency_position' => get_option( 'woocommerce_currency_pos' ), + 'thousand_separator' => get_option( 'woocommerce_price_thousand_sep' ), + 'decimal_separator' => get_option( 'woocommerce_price_decimal_sep' ), + 'price_num_decimals' => wc_get_price_decimals(), + 'tax_included' => wc_prices_include_tax(), + 'weight_unit' => get_option( 'woocommerce_weight_unit' ), + 'dimension_unit' => get_option( 'woocommerce_dimension_unit' ), + 'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || wc_site_is_https() ), + 'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ), + 'generate_password' => ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) ), + 'links' => array( + 'help' => 'https://woocommerce.github.io/woocommerce-rest-api-docs/', + ), + ), + ), + ); + + // Find the available routes + foreach ( $this->get_routes() as $route => $callbacks ) { + $data = array(); + + $route = preg_replace( '#\(\?P(<\w+?>).*?\)#', '$1', $route ); + + foreach ( self::$method_map as $name => $bitmask ) { + foreach ( $callbacks as $callback ) { + // Skip to the next route if any callback is hidden + if ( $callback[1] & self::HIDDEN_ENDPOINT ) { + continue 3; + } + + if ( $callback[1] & $bitmask ) { + $data['supports'][] = $name; + } + + if ( $callback[1] & self::ACCEPT_DATA ) { + $data['accepts_data'] = true; + } + + // For non-variable routes, generate links + if ( strpos( $route, '<' ) === false ) { + $data['meta'] = array( + 'self' => get_woocommerce_api_url( $route ), + ); + } + } + } + + $available['store']['routes'][ $route ] = apply_filters( 'woocommerce_api_endpoints_description', $data ); + } + + return apply_filters( 'woocommerce_api_index', $available ); + } + + /** + * Send a HTTP status code + * + * @since 2.1 + * @param int $code HTTP status + */ + public function send_status( $code ) { + status_header( $code ); + } + + /** + * Send a HTTP header + * + * @since 2.1 + * @param string $key Header key + * @param string $value Header value + * @param boolean $replace Should we replace the existing header? + */ + public function header( $key, $value, $replace = true ) { + header( sprintf( '%s: %s', $key, $value ), $replace ); + } + + /** + * Send a Link header + * + * @internal The $rel parameter is first, as this looks nicer when sending multiple + * + * @link http://tools.ietf.org/html/rfc5988 + * @link http://www.iana.org/assignments/link-relations/link-relations.xml + * + * @since 2.1 + * @param string $rel Link relation. Either a registered type, or an absolute URL + * @param string $link Target IRI for the link + * @param array $other Other parameters to send, as an associative array + */ + public function link_header( $rel, $link, $other = array() ) { + + $header = sprintf( '<%s>; rel="%s"', $link, esc_attr( $rel ) ); + + foreach ( $other as $key => $value ) { + + if ( 'title' == $key ) { + + $value = '"' . $value . '"'; + } + + $header .= '; ' . $key . '=' . $value; + } + + $this->header( 'Link', $header, false ); + } + + /** + * Send pagination headers for resources + * + * @since 2.1 + * @param WP_Query|WP_User_Query|stdClass $query + */ + public function add_pagination_headers( $query ) { + + // WP_User_Query + if ( is_a( $query, 'WP_User_Query' ) ) { + + $single = count( $query->get_results() ) == 1; + $total = $query->get_total(); + + if ( $query->get( 'number' ) > 0 ) { + $page = ( $query->get( 'offset' ) / $query->get( 'number' ) ) + 1; + $total_pages = ceil( $total / $query->get( 'number' ) ); + } else { + $page = 1; + $total_pages = 1; + } + } elseif ( is_a( $query, 'stdClass' ) ) { + $page = $query->page; + $single = $query->is_single; + $total = $query->total; + $total_pages = $query->total_pages; + + // WP_Query + } else { + + $page = $query->get( 'paged' ); + $single = $query->is_single(); + $total = $query->found_posts; + $total_pages = $query->max_num_pages; + } + + if ( ! $page ) { + $page = 1; + } + + $next_page = absint( $page ) + 1; + + if ( ! $single ) { + + // first/prev + if ( $page > 1 ) { + $this->link_header( 'first', $this->get_paginated_url( 1 ) ); + $this->link_header( 'prev', $this->get_paginated_url( $page -1 ) ); + } + + // next + if ( $next_page <= $total_pages ) { + $this->link_header( 'next', $this->get_paginated_url( $next_page ) ); + } + + // last + if ( $page != $total_pages ) { + $this->link_header( 'last', $this->get_paginated_url( $total_pages ) ); + } + } + + $this->header( 'X-WC-Total', $total ); + $this->header( 'X-WC-TotalPages', $total_pages ); + + do_action( 'woocommerce_api_pagination_headers', $this, $query ); + } + + /** + * Returns the request URL with the page query parameter set to the specified page + * + * @since 2.1 + * @param int $page + * @return string + */ + private function get_paginated_url( $page ) { + + // remove existing page query param + $request = remove_query_arg( 'page' ); + + // add provided page query param + $request = urldecode( add_query_arg( 'page', $page, $request ) ); + + // get the home host + $host = parse_url( get_home_url(), PHP_URL_HOST ); + + return set_url_scheme( "http://{$host}{$request}" ); + } + + /** + * Retrieve the raw request entity (body) + * + * @since 2.1 + * @return string + */ + public function get_raw_data() { + // @codingStandardsIgnoreStart + // $HTTP_RAW_POST_DATA is deprecated on PHP 5.6. + if ( function_exists( 'phpversion' ) && version_compare( phpversion(), '5.6', '>=' ) ) { + return file_get_contents( 'php://input' ); + } + + global $HTTP_RAW_POST_DATA; + + // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, + // but we can do it ourself. + if ( ! isset( $HTTP_RAW_POST_DATA ) ) { + $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); + } + + return $HTTP_RAW_POST_DATA; + // @codingStandardsIgnoreEnd + } + + /** + * Parse an RFC3339 datetime into a MySQl datetime + * + * Invalid dates default to unix epoch + * + * @since 2.1 + * @param string $datetime RFC3339 datetime + * @return string MySQl datetime (YYYY-MM-DD HH:MM:SS) + */ + public function parse_datetime( $datetime ) { + + // Strip millisecond precision (a full stop followed by one or more digits) + if ( strpos( $datetime, '.' ) !== false ) { + $datetime = preg_replace( '/\.\d+/', '', $datetime ); + } + + // default timezone to UTC + $datetime = preg_replace( '/[+-]\d+:+\d+$/', '+00:00', $datetime ); + + try { + + $datetime = new DateTime( $datetime, new DateTimeZone( 'UTC' ) ); + + } catch ( Exception $e ) { + + $datetime = new DateTime( '@0' ); + + } + + return $datetime->format( 'Y-m-d H:i:s' ); + } + + /** + * Format a unix timestamp or MySQL datetime into an RFC3339 datetime + * + * @since 2.1 + * @param int|string $timestamp unix timestamp or MySQL datetime + * @param bool $convert_to_utc + * @param bool $convert_to_gmt Use GMT timezone. + * @return string RFC3339 datetime + */ + public function format_datetime( $timestamp, $convert_to_utc = false, $convert_to_gmt = false ) { + if ( $convert_to_gmt ) { + if ( is_numeric( $timestamp ) ) { + $timestamp = date( 'Y-m-d H:i:s', $timestamp ); + } + + $timestamp = get_gmt_from_date( $timestamp ); + } + + if ( $convert_to_utc ) { + $timezone = new DateTimeZone( wc_timezone_string() ); + } else { + $timezone = new DateTimeZone( 'UTC' ); + } + + try { + + if ( is_numeric( $timestamp ) ) { + $date = new DateTime( "@{$timestamp}" ); + } else { + $date = new DateTime( $timestamp, $timezone ); + } + + // convert to UTC by adjusting the time based on the offset of the site's timezone + if ( $convert_to_utc ) { + $date->modify( -1 * $date->getOffset() . ' seconds' ); + } + } catch ( Exception $e ) { + + $date = new DateTime( '@0' ); + } + + return $date->format( 'Y-m-d\TH:i:s\Z' ); + } + + /** + * Extract headers from a PHP-style $_SERVER array + * + * @since 2.1 + * @param array $server Associative array similar to $_SERVER + * @return array Headers extracted from the input + */ + public function get_headers( $server ) { + $headers = array(); + // CONTENT_* headers are not prefixed with HTTP_ + $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true ); + + foreach ( $server as $key => $value ) { + if ( strpos( $key, 'HTTP_' ) === 0 ) { + $headers[ substr( $key, 5 ) ] = $value; + } elseif ( isset( $additional[ $key ] ) ) { + $headers[ $key ] = $value; + } + } + + return $headers; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-taxes.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-taxes.php new file mode 100644 index 0000000..5fafe78 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-taxes.php @@ -0,0 +1,691 @@ + + * + * @since 2.1 + * @param array $routes + * @return array + */ + public function register_routes( $routes ) { + + # GET/POST /taxes + $routes[ $this->base ] = array( + array( array( $this, 'get_taxes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_tax' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /taxes/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_taxes_count' ), WC_API_Server::READABLE ), + ); + + # GET/PUT/DELETE /taxes/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_tax' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_tax' ), WC_API_SERVER::EDITABLE | WC_API_SERVER::ACCEPT_DATA ), + array( array( $this, 'delete_tax' ), WC_API_SERVER::DELETABLE ), + ); + + # GET/POST /taxes/classes + $routes[ $this->base . '/classes' ] = array( + array( array( $this, 'get_tax_classes' ), WC_API_Server::READABLE ), + array( array( $this, 'create_tax_class' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /taxes/classes/count + $routes[ $this->base . '/classes/count' ] = array( + array( array( $this, 'get_tax_classes_count' ), WC_API_Server::READABLE ), + ); + + # GET /taxes/classes/ + $routes[ $this->base . '/classes/(?P\w[\w\s\-]*)' ] = array( + array( array( $this, 'delete_tax_class' ), WC_API_SERVER::DELETABLE ), + ); + + # POST|PUT /taxes/bulk + $routes[ $this->base . '/bulk' ] = array( + array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + ); + + return $routes; + } + + /** + * Get all taxes + * + * @since 2.5.0 + * + * @param string $fields + * @param array $filter + * @param string $class + * @param int $page + * + * @return array + */ + public function get_taxes( $fields = null, $filter = array(), $class = null, $page = 1 ) { + if ( ! empty( $class ) ) { + $filter['tax_rate_class'] = $class; + } + + $filter['page'] = $page; + + $query = $this->query_tax_rates( $filter ); + + $taxes = array(); + + foreach ( $query['results'] as $tax ) { + $taxes[] = current( $this->get_tax( $tax->tax_rate_id, $fields ) ); + } + + // Set pagination headers + $this->server->add_pagination_headers( $query['headers'] ); + + return array( 'taxes' => $taxes ); + } + + /** + * Get the tax for the given ID + * + * @since 2.5.0 + * + * @param int $id The tax ID + * @param string $fields fields to include in response + * + * @return array|WP_Error + */ + public function get_tax( $id, $fields = null ) { + global $wpdb; + + try { + $id = absint( $id ); + + // Permissions check + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_tax', __( 'You do not have permission to read tax rate', 'woocommerce' ), 401 ); + } + + // Get tax rate details + $tax = WC_Tax::_get_tax_rate( $id ); + + if ( is_wp_error( $tax ) || empty( $tax ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_tax_id', __( 'A tax rate with the provided ID could not be found', 'woocommerce' ), 404 ); + } + + $tax_data = array( + 'id' => (int) $tax['tax_rate_id'], + 'country' => $tax['tax_rate_country'], + 'state' => $tax['tax_rate_state'], + 'postcode' => '', + 'city' => '', + 'rate' => $tax['tax_rate'], + 'name' => $tax['tax_rate_name'], + 'priority' => (int) $tax['tax_rate_priority'], + 'compound' => (bool) $tax['tax_rate_compound'], + 'shipping' => (bool) $tax['tax_rate_shipping'], + 'order' => (int) $tax['tax_rate_order'], + 'class' => $tax['tax_rate_class'] ? $tax['tax_rate_class'] : 'standard', + ); + + // Get locales from a tax rate + $locales = $wpdb->get_results( $wpdb->prepare( " + SELECT location_code, location_type + FROM {$wpdb->prefix}woocommerce_tax_rate_locations + WHERE tax_rate_id = %d + ", $id ) ); + + if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) { + foreach ( $locales as $locale ) { + $tax_data[ $locale->location_type ] = $locale->location_code; + } + } + + return array( 'tax' => apply_filters( 'woocommerce_api_tax_response', $tax_data, $tax, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a tax + * + * @since 2.5.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_tax( $data ) { + try { + if ( ! isset( $data['tax'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'tax' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_tax', __( 'You do not have permission to create tax rates', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_tax_data', $data['tax'], $this ); + + $tax_data = array( + 'tax_rate_country' => '', + 'tax_rate_state' => '', + 'tax_rate' => '', + 'tax_rate_name' => '', + 'tax_rate_priority' => 1, + 'tax_rate_compound' => 0, + 'tax_rate_shipping' => 1, + 'tax_rate_order' => 0, + 'tax_rate_class' => '', + ); + + foreach ( $tax_data as $key => $value ) { + $new_key = str_replace( 'tax_rate_', '', $key ); + $new_key = 'tax_rate' === $new_key ? 'rate' : $new_key; + + if ( isset( $data[ $new_key ] ) ) { + if ( in_array( $new_key, array( 'compound', 'shipping' ) ) ) { + $tax_data[ $key ] = $data[ $new_key ] ? 1 : 0; + } else { + $tax_data[ $key ] = $data[ $new_key ]; + } + } + } + + // Create tax rate + $id = WC_Tax::_insert_tax_rate( $tax_data ); + + // Add locales + if ( ! empty( $data['postcode'] ) ) { + WC_Tax::_update_tax_rate_postcodes( $id, wc_clean( $data['postcode'] ) ); + } + + if ( ! empty( $data['city'] ) ) { + WC_Tax::_update_tax_rate_cities( $id, wc_clean( $data['city'] ) ); + } + + do_action( 'woocommerce_api_create_tax', $id, $data ); + + $this->server->send_status( 201 ); + + return $this->get_tax( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a tax + * + * @since 2.5.0 + * + * @param int $id The tax ID + * @param array $data + * + * @return array|WP_Error + */ + public function edit_tax( $id, $data ) { + try { + if ( ! isset( $data['tax'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'tax' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_edit_tax', __( 'You do not have permission to edit tax rates', 'woocommerce' ), 401 ); + } + + $data = $data['tax']; + + // Get current tax rate data + $tax = $this->get_tax( $id ); + + if ( is_wp_error( $tax ) ) { + $error_data = $tax->get_error_data(); + throw new WC_API_Exception( $tax->get_error_code(), $tax->get_error_message(), $error_data['status'] ); + } + + $current_data = $tax['tax']; + $data = apply_filters( 'woocommerce_api_edit_tax_data', $data, $this ); + $tax_data = array(); + $default_fields = array( + 'tax_rate_country', + 'tax_rate_state', + 'tax_rate', + 'tax_rate_name', + 'tax_rate_priority', + 'tax_rate_compound', + 'tax_rate_shipping', + 'tax_rate_order', + 'tax_rate_class', + ); + + foreach ( $data as $key => $value ) { + $new_key = 'rate' === $key ? 'tax_rate' : 'tax_rate_' . $key; + + // Check if the key is valid + if ( ! in_array( $new_key, $default_fields ) ) { + continue; + } + + // Test new data against current data + if ( $value === $current_data[ $key ] ) { + continue; + } + + // Fix compound and shipping values + if ( in_array( $key, array( 'compound', 'shipping' ) ) ) { + $value = $value ? 1 : 0; + } + + $tax_data[ $new_key ] = $value; + } + + // Update tax rate + WC_Tax::_update_tax_rate( $id, $tax_data ); + + // Update locales + if ( ! empty( $data['postcode'] ) && $current_data['postcode'] != $data['postcode'] ) { + WC_Tax::_update_tax_rate_postcodes( $id, wc_clean( $data['postcode'] ) ); + } + + if ( ! empty( $data['city'] ) && $current_data['city'] != $data['city'] ) { + WC_Tax::_update_tax_rate_cities( $id, wc_clean( $data['city'] ) ); + } + + do_action( 'woocommerce_api_edit_tax_rate', $id, $data ); + + return $this->get_tax( $id ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a tax + * + * @since 2.5.0 + * + * @param int $id The tax ID + * + * @return array|WP_Error + */ + public function delete_tax( $id ) { + global $wpdb; + + try { + // Check permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_tax', __( 'You do not have permission to delete tax rates', 'woocommerce' ), 401 ); + } + + $id = absint( $id ); + + WC_Tax::_delete_tax_rate( $id ); + + if ( 0 === $wpdb->rows_affected ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_tax', __( 'Could not delete the tax rate', 'woocommerce' ), 401 ); + } + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'tax' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of taxes + * + * @since 2.5.0 + * + * @param string $class + * @param array $filter + * + * @return array|WP_Error + */ + public function get_taxes_count( $class = null, $filter = array() ) { + try { + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_taxes_count', __( 'You do not have permission to read the taxes count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $class ) ) { + $filter['tax_rate_class'] = $class; + } + + $query = $this->query_tax_rates( $filter, true ); + + return array( 'count' => (int) $query['headers']->total ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Helper method to get tax rates objects + * + * @since 2.5.0 + * + * @param array $args + * @param bool $count_only + * + * @return array + */ + protected function query_tax_rates( $args, $count_only = false ) { + global $wpdb; + + $results = ''; + + // Set args + $args = $this->merge_query_args( $args, array() ); + + $query = " + SELECT tax_rate_id + FROM {$wpdb->prefix}woocommerce_tax_rates + WHERE 1 = 1 + "; + + // Filter by tax class + if ( ! empty( $args['tax_rate_class'] ) ) { + $tax_rate_class = 'standard' !== $args['tax_rate_class'] ? sanitize_title( $args['tax_rate_class'] ) : ''; + $query .= " AND tax_rate_class = '$tax_rate_class'"; + } + + // Order tax rates + $order_by = ' ORDER BY tax_rate_order'; + + // Pagination + $per_page = isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : get_option( 'posts_per_page' ); + $offset = 1 < $args['paged'] ? ( $args['paged'] - 1 ) * $per_page : 0; + $pagination = sprintf( ' LIMIT %d, %d', $offset, $per_page ); + + if ( ! $count_only ) { + $results = $wpdb->get_results( $query . $order_by . $pagination ); + } + + $wpdb->get_results( $query ); + $headers = new stdClass; + $headers->page = $args['paged']; + $headers->total = (int) $wpdb->num_rows; + $headers->is_single = $per_page > $headers->total; + $headers->total_pages = ceil( $headers->total / $per_page ); + + return array( + 'results' => $results, + 'headers' => $headers, + ); + } + + /** + * Bulk update or insert taxes + * Accepts an array with taxes in the formats supported by + * WC_API_Taxes->create_tax() and WC_API_Taxes->edit_tax() + * + * @since 2.5.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function bulk( $data ) { + try { + if ( ! isset( $data['taxes'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_taxes_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'taxes' ), 400 ); + } + + $data = $data['taxes']; + $limit = apply_filters( 'woocommerce_api_bulk_limit', 100, 'taxes' ); + + // Limit bulk operation + if ( count( $data ) > $limit ) { + throw new WC_API_Exception( 'woocommerce_api_taxes_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), 413 ); + } + + $taxes = array(); + + foreach ( $data as $_tax ) { + $tax_id = 0; + + // Try to get the tax rate ID + if ( isset( $_tax['id'] ) ) { + $tax_id = intval( $_tax['id'] ); + } + + if ( $tax_id ) { + + // Tax rate exists / edit tax rate + $edit = $this->edit_tax( $tax_id, array( 'tax' => $_tax ) ); + + if ( is_wp_error( $edit ) ) { + $taxes[] = array( + 'id' => $tax_id, + 'error' => array( 'code' => $edit->get_error_code(), 'message' => $edit->get_error_message() ), + ); + } else { + $taxes[] = $edit['tax']; + } + } else { + + // Tax rate don't exists / create tax rate + $new = $this->create_tax( array( 'tax' => $_tax ) ); + + if ( is_wp_error( $new ) ) { + $taxes[] = array( + 'id' => $tax_id, + 'error' => array( 'code' => $new->get_error_code(), 'message' => $new->get_error_message() ), + ); + } else { + $taxes[] = $new['tax']; + } + } + } + + return array( 'taxes' => apply_filters( 'woocommerce_api_taxes_bulk_response', $taxes, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get all tax classes + * + * @since 2.5.0 + * + * @param string $fields + * + * @return array|WP_Error + */ + public function get_tax_classes( $fields = null ) { + try { + // Permissions check + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_tax_classes', __( 'You do not have permission to read tax classes', 'woocommerce' ), 401 ); + } + + $tax_classes = array(); + + // Add standard class + $tax_classes[] = array( + 'slug' => 'standard', + 'name' => __( 'Standard rate', 'woocommerce' ), + ); + + $classes = WC_Tax::get_tax_classes(); + + foreach ( $classes as $class ) { + $tax_classes[] = apply_filters( 'woocommerce_api_tax_class_response', array( + 'slug' => sanitize_title( $class ), + 'name' => $class, + ), $class, $fields, $this ); + } + + return array( 'tax_classes' => apply_filters( 'woocommerce_api_tax_classes_response', $tax_classes, $classes, $fields, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create a tax class. + * + * @since 2.5.0 + * + * @param array $data + * + * @return array|WP_Error + */ + public function create_tax_class( $data ) { + try { + if ( ! isset( $data['tax_class'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_tax_class_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'tax_class' ), 400 ); + } + + // Check permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_tax_class', __( 'You do not have permission to create tax classes', 'woocommerce' ), 401 ); + } + + $data = $data['tax_class']; + + if ( empty( $data['name'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_tax_class_name', sprintf( __( 'Missing parameter %s', 'woocommerce' ), 'name' ), 400 ); + } + + $name = sanitize_text_field( $data['name'] ); + $slug = sanitize_title( $name ); + $classes = WC_Tax::get_tax_classes(); + $exists = false; + + // Check if class exists. + foreach ( $classes as $key => $class ) { + if ( sanitize_title( $class ) === $slug ) { + $exists = true; + break; + } + } + + // Return error if tax class already exists. + if ( $exists ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_create_tax_class', __( 'Tax class already exists', 'woocommerce' ), 401 ); + } + + // Add the new class. + $classes[] = $name; + + update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) ); + + do_action( 'woocommerce_api_create_tax_class', $slug, $data ); + + $this->server->send_status( 201 ); + + return array( + 'tax_class' => array( + 'slug' => $slug, + 'name' => $name, + ), + ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a tax class + * + * @since 2.5.0 + * + * @param int $slug The tax class slug + * + * @return array|WP_Error + */ + public function delete_tax_class( $slug ) { + global $wpdb; + + try { + // Check permissions + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_delete_tax_class', __( 'You do not have permission to delete tax classes', 'woocommerce' ), 401 ); + } + + $slug = sanitize_title( $slug ); + $classes = WC_Tax::get_tax_classes(); + $deleted = false; + + foreach ( $classes as $key => $class ) { + if ( sanitize_title( $class ) === $slug ) { + unset( $classes[ $key ] ); + $deleted = true; + break; + } + } + + if ( ! $deleted ) { + throw new WC_API_Exception( 'woocommerce_api_cannot_delete_tax_class', __( 'Could not delete the tax class', 'woocommerce' ), 401 ); + } + + update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) ); + + // Delete tax rate locations locations from the selected class. + $wpdb->query( $wpdb->prepare( " + DELETE locations.* + FROM {$wpdb->prefix}woocommerce_tax_rate_locations AS locations + INNER JOIN + {$wpdb->prefix}woocommerce_tax_rates AS rates + ON rates.tax_rate_id = locations.tax_rate_id + WHERE rates.tax_rate_class = '%s' + ", $slug ) ); + + // Delete tax rates in the selected class. + $wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $slug ), array( '%s' ) ); + + return array( 'message' => sprintf( __( 'Deleted %s', 'woocommerce' ), 'tax_class' ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the total number of tax classes + * + * @since 2.5.0 + * + * @return array|WP_Error + */ + public function get_tax_classes_count() { + try { + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_tax_classes_count', __( 'You do not have permission to read the tax classes count', 'woocommerce' ), 401 ); + } + + $total = count( WC_Tax::get_tax_classes() ) + 1; // +1 for Standard Rate + + return array( 'count' => $total ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-webhooks.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-webhooks.php new file mode 100644 index 0000000..543caa9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/class-wc-api-webhooks.php @@ -0,0 +1,522 @@ +base ] = array( + array( array( $this, 'get_webhooks' ), WC_API_Server::READABLE ), + array( array( $this, 'create_webhook' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ), + ); + + # GET /webhooks/count + $routes[ $this->base . '/count' ] = array( + array( array( $this, 'get_webhooks_count' ), WC_API_Server::READABLE ), + ); + + # GET|PUT|DELETE /webhooks/ + $routes[ $this->base . '/(?P\d+)' ] = array( + array( array( $this, 'get_webhook' ), WC_API_Server::READABLE ), + array( array( $this, 'edit_webhook' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ), + array( array( $this, 'delete_webhook' ), WC_API_Server::DELETABLE ), + ); + + # GET /webhooks//deliveries + $routes[ $this->base . '/(?P\d+)/deliveries' ] = array( + array( array( $this, 'get_webhook_deliveries' ), WC_API_Server::READABLE ), + ); + + # GET /webhooks//deliveries/ + $routes[ $this->base . '/(?P\d+)/deliveries/(?P\d+)' ] = array( + array( array( $this, 'get_webhook_delivery' ), WC_API_Server::READABLE ), + ); + + return $routes; + } + + /** + * Get all webhooks + * + * @since 2.2 + * + * @param array $fields + * @param array $filter + * @param string $status + * @param int $page + * + * @return array + */ + public function get_webhooks( $fields = null, $filter = array(), $status = null, $page = 1 ) { + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $filter['page'] = $page; + + $query = $this->query_webhooks( $filter ); + + $webhooks = array(); + + foreach ( $query['results'] as $webhook_id ) { + $webhooks[] = current( $this->get_webhook( $webhook_id, $fields ) ); + } + + $this->server->add_pagination_headers( $query['headers'] ); + + return array( 'webhooks' => $webhooks ); + } + + /** + * Get the webhook for the given ID + * + * @since 2.2 + * @param int $id webhook ID + * @param array $fields + * @return array|WP_Error + */ + public function get_webhook( $id, $fields = null ) { + + // ensure webhook ID is valid & user has permission to read + $id = $this->validate_request( $id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $webhook = wc_get_webhook( $id ); + + $webhook_data = array( + 'id' => $webhook->get_id(), + 'name' => $webhook->get_name(), + 'status' => $webhook->get_status(), + 'topic' => $webhook->get_topic(), + 'resource' => $webhook->get_resource(), + 'event' => $webhook->get_event(), + 'hooks' => $webhook->get_hooks(), + 'delivery_url' => $webhook->get_delivery_url(), + 'created_at' => $this->server->format_datetime( $webhook->get_date_created() ? $webhook->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. + 'updated_at' => $this->server->format_datetime( $webhook->get_date_modified() ? $webhook->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. + ); + + return array( 'webhook' => apply_filters( 'woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this ) ); + } + + /** + * Get the total number of webhooks + * + * @since 2.2 + * + * @param string $status + * @param array $filter + * + * @return array|WP_Error + */ + public function get_webhooks_count( $status = null, $filter = array() ) { + try { + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_webhooks_count', __( 'You do not have permission to read the webhooks count', 'woocommerce' ), 401 ); + } + + if ( ! empty( $status ) ) { + $filter['status'] = $status; + } + + $query = $this->query_webhooks( $filter ); + + return array( 'count' => $query['headers']->total ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Create an webhook + * + * @since 2.2 + * + * @param array $data parsed webhook data + * + * @return array|WP_Error + */ + public function create_webhook( $data ) { + + try { + if ( ! isset( $data['webhook'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_webhook_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'webhook' ), 400 ); + } + + $data = $data['webhook']; + + // permission check + if ( ! current_user_can( 'manage_woocommerce' ) ) { + throw new WC_API_Exception( 'woocommerce_api_user_cannot_create_webhooks', __( 'You do not have permission to create webhooks.', 'woocommerce' ), 401 ); + } + + $data = apply_filters( 'woocommerce_api_create_webhook_data', $data, $this ); + + // validate topic + if ( empty( $data['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $data['topic'] ) ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_topic', __( 'Webhook topic is required and must be valid.', 'woocommerce' ), 400 ); + } + + // validate delivery URL + if ( empty( $data['delivery_url'] ) || ! wc_is_valid_url( $data['delivery_url'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_url', __( 'Webhook delivery URL must be a valid URL starting with http:// or https://', 'woocommerce' ), 400 ); + } + + $webhook_data = apply_filters( 'woocommerce_new_webhook_data', array( + 'post_type' => 'shop_webhook', + 'post_status' => 'publish', + 'ping_status' => 'closed', + 'post_author' => get_current_user_id(), + 'post_password' => strlen( ( $password = uniqid( 'webhook_' ) ) ) > 20 ? substr( $password, 0, 20 ) : $password, + 'post_title' => ! empty( $data['name'] ) ? $data['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ), + ), $data, $this ); + + $webhook = new WC_Webhook(); + + $webhook->set_name( $webhook_data['post_title'] ); + $webhook->set_user_id( $webhook_data['post_author'] ); + $webhook->set_status( 'publish' === $webhook_data['post_status'] ? 'active' : 'disabled' ); + $webhook->set_topic( $data['topic'] ); + $webhook->set_delivery_url( $data['delivery_url'] ); + $webhook->set_secret( ! empty( $data['secret'] ) ? $data['secret'] : wp_generate_password( 50, true, true ) ); + $webhook->set_api_version( 'legacy_v3' ); + $webhook->save(); + + $webhook->deliver_ping(); + + // HTTP 201 Created + $this->server->send_status( 201 ); + + do_action( 'woocommerce_api_create_webhook', $webhook->get_id(), $this ); + + return $this->get_webhook( $webhook->get_id() ); + + } catch ( WC_API_Exception $e ) { + + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Edit a webhook + * + * @since 2.2 + * + * @param int $id webhook ID + * @param array $data parsed webhook data + * + * @return array|WP_Error + */ + public function edit_webhook( $id, $data ) { + + try { + if ( ! isset( $data['webhook'] ) ) { + throw new WC_API_Exception( 'woocommerce_api_missing_webhook_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'webhook' ), 400 ); + } + + $data = $data['webhook']; + + $id = $this->validate_request( $id, 'shop_webhook', 'edit' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + $data = apply_filters( 'woocommerce_api_edit_webhook_data', $data, $id, $this ); + + $webhook = wc_get_webhook( $id ); + + // update topic + if ( ! empty( $data['topic'] ) ) { + + if ( wc_is_webhook_valid_topic( strtolower( $data['topic'] ) ) ) { + + $webhook->set_topic( $data['topic'] ); + + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_topic', __( 'Webhook topic must be valid.', 'woocommerce' ), 400 ); + } + } + + // update delivery URL + if ( ! empty( $data['delivery_url'] ) ) { + if ( wc_is_valid_url( $data['delivery_url'] ) ) { + + $webhook->set_delivery_url( $data['delivery_url'] ); + + } else { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_url', __( 'Webhook delivery URL must be a valid URL starting with http:// or https://', 'woocommerce' ), 400 ); + } + } + + // update secret + if ( ! empty( $data['secret'] ) ) { + $webhook->set_secret( $data['secret'] ); + } + + // update status + if ( ! empty( $data['status'] ) ) { + $webhook->set_status( $data['status'] ); + } + + // update name + if ( ! empty( $data['name'] ) ) { + $webhook->set_name( $data['name'] ); + } + + $webhook->save(); + + do_action( 'woocommerce_api_edit_webhook', $webhook->get_id(), $this ); + + return $this->get_webhook( $webhook->get_id() ); + + } catch ( WC_API_Exception $e ) { + + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a webhook + * + * @since 2.2 + * @param int $id webhook ID + * @return array|WP_Error + */ + public function delete_webhook( $id ) { + + $id = $this->validate_request( $id, 'shop_webhook', 'delete' ); + + if ( is_wp_error( $id ) ) { + return $id; + } + + do_action( 'woocommerce_api_delete_webhook', $id, $this ); + + $webhook = wc_get_webhook( $id ); + + return $webhook->delete( true ); + } + + /** + * Get webhooks total results + * + * @since 3.3.0 + * @param array $args Request arguments for filtering query. + * @return array + */ + private function get_webhooks_total_results( $args = array() ) { + $data_store = WC_Data_Store::load( 'webhook' ); + $args['limit'] = -1; + $args['offset'] = 0; + + return count( $data_store->search_webhooks( $args ) ); + } + + /** + * Helper method to get webhook post objects + * + * @since 2.2 + * @param array $args Request arguments for filtering query. + * @return array + */ + private function query_webhooks( $args ) { + $args = $this->merge_query_args( array(), $args ); + + $args['limit'] = isset( $args['posts_per_page'] ) ? intval( $args['posts_per_page'] ) : intval( get_option( 'posts_per_page' ) ); + + if ( empty( $args['offset'] ) ) { + $args['offset'] = 1 < $args['paged'] ? ( $args['paged'] - 1 ) * $args['limit'] : 0; + } + + $page = $args['paged']; + unset( $args['paged'], $args['posts_per_page'] ); + + if ( isset( $args['s'] ) ) { + $args['search'] = $args['s']; + unset( $args['s'] ); + } + + // Post type to webhook status. + if ( ! empty( $args['post_status'] ) ) { + $args['status'] = $args['post_status']; + unset( $args['post_status'] ); + } + + if ( ! empty( $args['post__in'] ) ) { + $args['include'] = $args['post__in']; + unset( $args['post__in'] ); + } + + if ( ! empty( $args['date_query'] ) ) { + foreach ( $args['date_query'] as $date_query ) { + if ( 'post_date_gmt' === $date_query['column'] ) { + $args['after'] = isset( $date_query['after'] ) ? $date_query['after'] : null; + $args['before'] = isset( $date_query['before'] ) ? $date_query['before'] : null; + } elseif ( 'post_modified_gmt' === $date_query['column'] ) { + $args['modified_after'] = isset( $date_query['after'] ) ? $date_query['after'] : null; + $args['modified_before'] = isset( $date_query['before'] ) ? $date_query['before'] : null; + } + } + + unset( $args['date_query'] ); + } + + // Get the webhooks. + $data_store = WC_Data_Store::load( 'webhook' ); + $results = $data_store->search_webhooks( $args ); + + // Get total items. + $headers = new stdClass; + $headers->page = $page; + $headers->total = $this->get_webhooks_total_results( $args ); + $headers->is_single = $args['limit'] > $headers->total; + $headers->total_pages = ceil( $headers->total / $args['limit'] ); + + return array( + 'results' => $results, + 'headers' => $headers, + ); + } + + /** + * Get deliveries for a webhook + * + * @since 2.2 + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @param string $webhook_id webhook ID + * @param string|null $fields fields to include in response + * @return array|WP_Error + */ + public function get_webhook_deliveries( $webhook_id, $fields = null ) { + + // Ensure ID is valid webhook ID + $webhook_id = $this->validate_request( $webhook_id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $webhook_id ) ) { + return $webhook_id; + } + + return array( 'webhook_deliveries' => array() ); + } + + /** + * Get the delivery log for the given webhook ID and delivery ID + * + * @since 2.2 + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @param string $webhook_id webhook ID + * @param string $id delivery log ID + * @param string|null $fields fields to limit response to + * + * @return array|WP_Error + */ + public function get_webhook_delivery( $webhook_id, $id, $fields = null ) { + try { + // Validate webhook ID + $webhook_id = $this->validate_request( $webhook_id, 'shop_webhook', 'read' ); + + if ( is_wp_error( $webhook_id ) ) { + return $webhook_id; + } + + $id = absint( $id ); + + if ( empty( $id ) ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery ID.', 'woocommerce' ), 404 ); + } + + $webhook = new WC_Webhook( $webhook_id ); + + $log = 0; + + if ( ! $log ) { + throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery.', 'woocommerce' ), 400 ); + } + + return array( 'webhook_delivery' => apply_filters( 'woocommerce_api_webhook_delivery_response', array(), $id, $fields, $log, $webhook_id, $this ) ); + } catch ( WC_API_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Validate the request by checking: + * + * 1) the ID is a valid integer. + * 2) the ID returns a valid post object and matches the provided post type. + * 3) the current user has the proper permissions to read/edit/delete the post. + * + * @since 3.3.0 + * @param string|int $id The post ID + * @param string $type The post type, either `shop_order`, `shop_coupon`, or `product`. + * @param string $context The context of the request, either `read`, `edit` or `delete`. + * @return int|WP_Error Valid post ID or WP_Error if any of the checks fails. + */ + protected function validate_request( $id, $type, $context ) { + $id = absint( $id ); + + // Validate ID. + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_api_invalid_webhook_id", sprintf( __( 'Invalid %s ID', 'woocommerce' ), $type ), array( 'status' => 404 ) ); + } + + $webhook = wc_get_webhook( $id ); + + if ( null === $webhook ) { + return new WP_Error( "woocommerce_api_no_webhook_found", sprintf( __( 'No %1$s found with the ID equal to %2$s', 'woocommerce' ), 'webhook', $id ), array( 'status' => 404 ) ); + } + + // Validate permissions. + switch ( $context ) { + + case 'read': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_read_webhook", sprintf( __( 'You do not have permission to read this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + + case 'edit': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_edit_webhook", sprintf( __( 'You do not have permission to edit this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + + case 'delete': + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return new WP_Error( "woocommerce_api_user_cannot_delete_webhook", sprintf( __( 'You do not have permission to delete this %s', 'woocommerce' ), 'webhook' ), array( 'status' => 401 ) ); + } + break; + } + + return $id; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/interface-wc-api-handler.php b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/interface-wc-api-handler.php new file mode 100644 index 0000000..484f9f5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/legacy/v3/interface-wc-api-handler.php @@ -0,0 +1,47 @@ +post_type}_query", array( $this, 'query_args' ), 10, 2 ); + } + + /** + * Register the routes for coupons. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'required' => true, + 'type' => 'string', + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Query args. + * + * @param array $args Query args + * @param WP_REST_Request $request Request data. + * @return array + */ + public function query_args( $args, $request ) { + if ( ! empty( $request['code'] ) ) { + $id = wc_get_coupon_id_by_code( $request['code'] ); + $args['post__in'] = array( $id ); + } + + return $args; + } + + /** + * Prepare a single coupon output for response. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $data + */ + public function prepare_item_for_response( $post, $request ) { + $coupon = new WC_Coupon( (int) $post->ID ); + $_data = $coupon->get_data(); + + $format_decimal = array( 'amount', 'minimum_amount', 'maximum_amount' ); + $format_date = array( 'date_created', 'date_modified' ); + $format_date_utc = array( 'date_expires' ); + $format_null = array( 'usage_limit', 'usage_limit_per_user' ); + + // Format decimal values. + foreach ( $format_decimal as $key ) { + $_data[ $key ] = wc_format_decimal( $_data[ $key ], 2 ); + } + + // Format date values. + foreach ( $format_date as $key ) { + $_data[ $key ] = $_data[ $key ] ? wc_rest_prepare_date_response( $_data[ $key ], false ) : null; + } + foreach ( $format_date_utc as $key ) { + $_data[ $key ] = $_data[ $key ] ? wc_rest_prepare_date_response( $_data[ $key ] ) : null; + } + + // Format null values. + foreach ( $format_null as $key ) { + $_data[ $key ] = $_data[ $key ] ? $_data[ $key ] : null; + } + + $data = array( + 'id' => $_data['id'], + 'code' => $_data['code'], + 'date_created' => $_data['date_created'], + 'date_modified' => $_data['date_modified'], + 'discount_type' => $_data['discount_type'], + 'description' => $_data['description'], + 'amount' => $_data['amount'], + 'expiry_date' => $_data['date_expires'], + 'usage_count' => $_data['usage_count'], + 'individual_use' => $_data['individual_use'], + 'product_ids' => $_data['product_ids'], + 'exclude_product_ids' => $_data['excluded_product_ids'], + 'usage_limit' => $_data['usage_limit'], + 'usage_limit_per_user' => $_data['usage_limit_per_user'], + 'limit_usage_to_x_items' => $_data['limit_usage_to_x_items'], + 'free_shipping' => $_data['free_shipping'], + 'product_categories' => $_data['product_categories'], + 'excluded_product_categories' => $_data['excluded_product_categories'], + 'exclude_sale_items' => $_data['exclude_sale_items'], + 'minimum_amount' => $_data['minimum_amount'], + 'maximum_amount' => $_data['maximum_amount'], + 'email_restrictions' => $_data['email_restrictions'], + 'used_by' => $_data['used_by'], + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $post, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Only return writable props from schema. + * @param array $schema + * @return bool + */ + protected function filter_writable_props( $schema ) { + return empty( $schema['readonly'] ); + } + + /** + * Prepare a single coupon for create or update. + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|stdClass $data Post object. + */ + protected function prepare_item_for_database( $request ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $coupon = new WC_Coupon( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Update to schema to make compatible with CRUD schema. + if ( $request['exclude_product_ids'] ) { + $request['excluded_product_ids'] = $request['exclude_product_ids']; + } + if ( $request['expiry_date'] ) { + $request['date_expires'] = $request['expiry_date']; + } + + // Validate required POST fields. + if ( 'POST' === $request->get_method() && 0 === $coupon->get_id() ) { + if ( empty( $request['code'] ) ) { + return new WP_Error( 'woocommerce_rest_empty_coupon_code', sprintf( __( 'The coupon code cannot be empty.', 'woocommerce' ), 'code' ), array( 'status' => 400 ) ); + } + } + + // Handle all writable props. + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'code' : + $coupon_code = wc_format_coupon_code( $value ); + $id = $coupon->get_id() ? $coupon->get_id() : 0; + $id_from_code = wc_get_coupon_id_by_code( $coupon_code, $id ); + + if ( $id_from_code ) { + return new WP_Error( 'woocommerce_rest_coupon_code_already_exists', __( 'The coupon code already exists', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $coupon->set_code( $coupon_code ); + break; + case 'description' : + $coupon->set_description( wp_filter_post_kses( $value ) ); + break; + case 'expiry_date' : + $coupon->set_date_expires( $value ); + break; + default : + if ( is_callable( array( $coupon, "set_{$key}" ) ) ) { + $coupon->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filter the query_vars used in `get_items` for the constructed query. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for insertion. + * + * @param WC_Coupon $coupon The coupon object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $coupon, $request ); + } + + /** + * Create a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $coupon_id = $this->save_coupon( $request ); + if ( is_wp_error( $coupon_id ) ) { + return $coupon_id; + } + + $post = get_post( $coupon_id ); + $this->update_additional_fields_for_object( $post, $request ); + + $this->add_post_meta_fields( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) ); + + return $response; + } + + /** + * Update a single coupon. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + try { + $post_id = (int) $request['id']; + + if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $coupon_id = $this->save_coupon( $request ); + if ( is_wp_error( $coupon_id ) ) { + return $coupon_id; + } + + $post = get_post( $coupon_id ); + $this->update_additional_fields_for_object( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + return rest_ensure_response( $response ); + + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Saves a coupon to the database. + * + * @since 3.0.0 + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|int + */ + protected function save_coupon( $request ) { + try { + $coupon = $this->prepare_item_for_database( $request ); + + if ( is_wp_error( $coupon ) ) { + return $coupon; + } + + $coupon->save(); + return $coupon->get_id(); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get the Coupon's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the object.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the coupon was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the coupon was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'Coupon description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'discount_type' => array( + 'description' => __( 'Determines the type of discount that will be applied.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'fixed_cart', + 'enum' => array_keys( wc_get_coupon_types() ), + 'context' => array( 'view', 'edit' ), + ), + 'amount' => array( + 'description' => __( 'The amount of discount. Should always be numeric, even if setting a percentage.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'expiry_date' => array( + 'description' => __( 'UTC DateTime when the coupon expires.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'usage_count' => array( + 'description' => __( 'Number of times the coupon has been used already.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'individual_use' => array( + 'description' => __( 'If true, the coupon can only be used individually. Other applied coupons will be removed from the cart.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'product_ids' => array( + 'description' => __( "List of product IDs the coupon can be used on.", 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'exclude_product_ids' => array( + 'description' => __( "List of product IDs the coupon cannot be used on.", 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'usage_limit' => array( + 'description' => __( 'How many times the coupon can be used in total.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'usage_limit_per_user' => array( + 'description' => __( 'How many times the coupon can be used per customer.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'limit_usage_to_x_items' => array( + 'description' => __( 'Max number of items in the cart the coupon can be applied to.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'free_shipping' => array( + 'description' => __( 'If true and if the free shipping method requires a coupon, this coupon will enable free shipping.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'product_categories' => array( + 'description' => __( "List of category IDs the coupon applies to.", 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'excluded_product_categories' => array( + 'description' => __( "List of category IDs the coupon does not apply to.", 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'exclude_sale_items' => array( + 'description' => __( 'If true, this coupon will not be applied to items that have sale prices.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'minimum_amount' => array( + 'description' => __( 'Minimum order amount that needs to be in the cart before coupon applies.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'maximum_amount' => array( + 'description' => __( 'Maximum order amount allowed when using the coupon.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email_restrictions' => array( + 'description' => __( 'List of email addresses that can use this coupon.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'string', + ), + 'context' => array( 'view', 'edit' ), + ), + 'used_by' => array( + 'description' => __( 'List of user IDs (or guest email addresses) that have used the coupon.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['code'] = array( + 'description' => __( 'Limit result set to resources with a specific code.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customer-downloads-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customer-downloads-controller.php new file mode 100644 index 0000000..7557161 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customer-downloads-controller.php @@ -0,0 +1,252 @@ +/downloads endpoint. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Customers controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Controller + */ +class WC_REST_Customer_Downloads_V1_Controller extends WC_REST_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'customers/(?P[\d]+)/downloads'; + + /** + * Register the routes for customers. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'customer_id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read customers. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + $customer = get_user_by( 'id', (int) $request['customer_id'] ); + + if ( ! $customer ) { + return new WP_Error( 'woocommerce_rest_customer_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + if ( ! wc_rest_check_user_permissions( 'read', $customer->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all customer downloads. + * + * @param WP_REST_Request $request + * @return array + */ + public function get_items( $request ) { + $downloads = wc_get_customer_available_downloads( (int) $request['customer_id'] ); + + $data = array(); + foreach ( $downloads as $download_data ) { + $download = $this->prepare_item_for_response( (object) $download_data, $request ); + $download = $this->prepare_response_for_collection( $download ); + $data[] = $download; + } + + return rest_ensure_response( $data ); + } + + /** + * Prepare a single download output for response. + * + * @param stdObject $download Download object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $download, $request ) { + $data = (array) $download; + $data['access_expires'] = $data['access_expires'] ? wc_rest_prepare_date_response( $data['access_expires'] ) : 'never'; + $data['downloads_remaining'] = '' === $data['downloads_remaining'] ? 'unlimited' : $data['downloads_remaining']; + + // Remove "product_name" since it's new in 3.0. + unset( $data['product_name'] ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $download, $request ) ); + + /** + * Filter customer download data returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdObject $download Download object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_customer_download', $response, $download, $request ); + } + + /** + * Prepare links for the request. + * + * @param stdClass $download Download object. + * @param WP_REST_Request $request Request object. + * @return array Links for the given customer download. + */ + protected function prepare_links( $download, $request ) { + $base = str_replace( '(?P[\d]+)', $request['customer_id'], $this->rest_base ); + $links = array( + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'product' => array( + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $download->product_id ) ), + ), + 'order' => array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $download->order_id ) ), + ), + ); + + return $links; + } + + /** + * Get the Customer Download's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'customer_download', + 'type' => 'object', + 'properties' => array( + 'download_url' => array( + 'description' => __( 'Download file URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'download_id' => array( + 'description' => __( 'Download ID (MD5).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Downloadable product ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'download_name' => array( + 'description' => __( 'Downloadable file name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'order_id' => array( + 'description' => __( 'Order ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'order_key' => array( + 'description' => __( 'Order key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'downloads_remaining' => array( + 'description' => __( 'Number of downloads remaining.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'access_expires' => array( + 'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'file' => array( + 'description' => __( 'File details.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view' ), + 'readonly' => true, + 'properties' => array( + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customers-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customers-controller.php new file mode 100644 index 0000000..551b6e8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-customers-controller.php @@ -0,0 +1,924 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'email' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'New user email address.', 'woocommerce' ), + ), + 'username' => array( + 'required' => 'no' === get_option( 'woocommerce_registration_generate_username', 'yes' ), + 'description' => __( 'New user username.', 'woocommerce' ), + 'type' => 'string', + ), + 'password' => array( + 'required' => 'no' === get_option( 'woocommerce_registration_generate_password', 'no' ), + 'description' => __( 'New user password.', 'woocommerce' ), + 'type' => 'string', + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + 'reassign' => array( + 'default' => 0, + 'type' => 'integer', + 'description' => __( 'ID to reassign posts to.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read customers. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_user_permissions( 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access create customers. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_user_permissions( 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a customer. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + $id = (int) $request['id']; + + if ( ! wc_rest_check_user_permissions( 'read', $id ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access update a customer. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function update_item_permissions_check( $request ) { + $id = (int) $request['id']; + + if ( ! wc_rest_check_user_permissions( 'edit', $id ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access delete a customer. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + $id = (int) $request['id']; + + if ( ! wc_rest_check_user_permissions( 'delete', $id ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access batch create, update and delete items. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function batch_items_permissions_check( $request ) { + if ( ! wc_rest_check_user_permissions( 'batch' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all customers. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $prepared_args = array(); + $prepared_args['exclude'] = $request['exclude']; + $prepared_args['include'] = $request['include']; + $prepared_args['order'] = $request['order']; + $prepared_args['number'] = $request['per_page']; + if ( ! empty( $request['offset'] ) ) { + $prepared_args['offset'] = $request['offset']; + } else { + $prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number']; + } + $orderby_possibles = array( + 'id' => 'ID', + 'include' => 'include', + 'name' => 'display_name', + 'registered_date' => 'registered', + ); + $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; + $prepared_args['search'] = $request['search']; + + if ( '' !== $prepared_args['search'] ) { + $prepared_args['search'] = '*' . $prepared_args['search'] . '*'; + } + + // Filter by email. + if ( ! empty( $request['email'] ) ) { + $prepared_args['search'] = $request['email']; + $prepared_args['search_columns'] = array( 'user_email' ); + } + + // Filter by role. + if ( 'all' !== $request['role'] ) { + $prepared_args['role'] = $request['role']; + } + + /** + * Filter arguments, before passing to WP_User_Query, when querying users via the REST API. + * + * @see https://developer.wordpress.org/reference/classes/wp_user_query/ + * + * @param array $prepared_args Array of arguments for WP_User_Query. + * @param WP_REST_Request $request The current request. + */ + $prepared_args = apply_filters( 'woocommerce_rest_customer_query', $prepared_args, $request ); + + $query = new WP_User_Query( $prepared_args ); + + $users = array(); + foreach ( $query->results as $user ) { + $data = $this->prepare_item_for_response( $user, $request ); + $users[] = $this->prepare_response_for_collection( $data ); + } + + $response = rest_ensure_response( $users ); + + // Store pagination values for headers then unset for count query. + $per_page = (int) $prepared_args['number']; + $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); + + $prepared_args['fields'] = 'ID'; + + $total_users = $query->get_total(); + if ( $total_users < 1 ) { + // Out-of-bounds, run the query again without LIMIT for total count. + unset( $prepared_args['number'] ); + unset( $prepared_args['offset'] ); + $count_query = new WP_User_Query( $prepared_args ); + $total_users = $count_query->get_total(); + } + $response->header( 'X-WP-Total', (int) $total_users ); + $max_pages = ceil( $total_users / $per_page ); + $response->header( 'X-WP-TotalPages', (int) $max_pages ); + + $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); + if ( $page > 1 ) { + $prev_page = $page - 1; + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + $prev_link = add_query_arg( 'page', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + if ( $max_pages > $page ) { + $next_page = $page + 1; + $next_link = add_query_arg( 'page', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } + + return $response; + } + + /** + * Create a single customer. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + try { + if ( ! empty( $request['id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_customer_exists', __( 'Cannot create existing resource.', 'woocommerce' ), 400 ); + } + + // Sets the username. + $request['username'] = ! empty( $request['username'] ) ? $request['username'] : ''; + + // Sets the password. + $request['password'] = ! empty( $request['password'] ) ? $request['password'] : ''; + + // Create customer. + $customer = new WC_Customer; + $customer->set_username( $request['username'] ); + $customer->set_password( $request['password'] ); + $customer->set_email( $request['email'] ); + $this->update_customer_meta_fields( $customer, $request ); + $customer->save(); + + if ( ! $customer->get_id() ) { + throw new WC_REST_Exception( 'woocommerce_rest_cannot_create', __( 'This resource cannot be created.', 'woocommerce' ), 400 ); + } + + $user_data = get_userdata( $customer->get_id() ); + $this->update_additional_fields_for_object( $user_data, $request ); + + /** + * Fires after a customer is created or updated via the REST API. + * + * @param WP_User $user_data Data used to create the customer. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating customer, false when updating customer. + */ + do_action( 'woocommerce_rest_insert_customer', $user_data, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $user_data, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $customer->get_id() ) ) ); + + return $response; + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get a single customer. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $user_data = get_userdata( $id ); + + if ( empty( $id ) || empty( $user_data->ID ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $customer = $this->prepare_item_for_response( $user_data, $request ); + $response = rest_ensure_response( $customer ); + + return $response; + } + + /** + * Update a single user. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + try { + $id = (int) $request['id']; + $customer = new WC_Customer( $id ); + + if ( ! $customer->get_id() ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), 400 ); + } + + if ( ! empty( $request['email'] ) && email_exists( $request['email'] ) && $request['email'] !== $customer->get_email() ) { + throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_email', __( 'Email address is invalid.', 'woocommerce' ), 400 ); + } + + if ( ! empty( $request['username'] ) && $request['username'] !== $customer->get_username() ) { + throw new WC_REST_Exception( 'woocommerce_rest_customer_invalid_argument', __( "Username isn't editable.", 'woocommerce' ), 400 ); + } + + // Customer email. + if ( isset( $request['email'] ) ) { + $customer->set_email( sanitize_email( $request['email'] ) ); + } + + // Customer password. + if ( isset( $request['password'] ) ) { + $customer->set_password( wc_clean( $request['password'] ) ); + } + + $this->update_customer_meta_fields( $customer, $request ); + $customer->save(); + + $user_data = get_userdata( $customer->get_id() ); + $this->update_additional_fields_for_object( $user_data, $request ); + + if ( ! is_user_member_of_blog( $user_data->ID ) ) { + $user_data->add_role( 'customer' ); + } + + /** + * Fires after a customer is created or updated via the REST API. + * + * @param WP_User $customer Data used to create the customer. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating customer, false when updating customer. + */ + do_action( 'woocommerce_rest_insert_customer', $user_data, $request, false ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $user_data, $request ); + $response = rest_ensure_response( $response ); + return $response; + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Delete a single customer. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $reassign = isset( $request['reassign'] ) ? absint( $request['reassign'] ) : null; + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Customers do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $user_data = get_userdata( $id ); + if ( ! $user_data ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + if ( ! empty( $reassign ) ) { + if ( $reassign === $id || ! get_userdata( $reassign ) ) { + return new WP_Error( 'woocommerce_rest_customer_invalid_reassign', __( 'Invalid resource id for reassignment.', 'woocommerce' ), array( 'status' => 400 ) ); + } + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $user_data, $request ); + + /** Include admin customer functions to get access to wp_delete_user() */ + require_once ABSPATH . 'wp-admin/includes/user.php'; + + $customer = new WC_Customer( $id ); + + if ( ! is_null( $reassign ) ) { + $result = $customer->delete_and_reassign( $reassign ); + } else { + $result = $customer->delete(); + } + + if ( ! $result ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + /** + * Fires after a customer is deleted via the REST API. + * + * @param WP_User $user_data User data. + * @param WP_REST_Response $response The response returned from the API. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'woocommerce_rest_delete_customer', $user_data, $response, $request ); + + return $response; + } + + /** + * Prepare a single customer output for response. + * + * @param WP_User $user_data User object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $user_data, $request ) { + $customer = new WC_Customer( $user_data->ID ); + $_data = $customer->get_data(); + $last_order = wc_get_customer_last_order( $customer->get_id() ); + $format_date = array( 'date_created', 'date_modified' ); + + // Format date values. + foreach ( $format_date as $key ) { + $_data[ $key ] = $_data[ $key ] ? wc_rest_prepare_date_response( $_data[ $key ] ) : null; // v1 API used UTC. + } + + $data = array( + 'id' => $_data['id'], + 'date_created' => $_data['date_created'], + 'date_modified' => $_data['date_modified'], + 'email' => $_data['email'], + 'first_name' => $_data['first_name'], + 'last_name' => $_data['last_name'], + 'username' => $_data['username'], + 'last_order' => array( + 'id' => is_object( $last_order ) ? $last_order->get_id() : null, + 'date' => is_object( $last_order ) ? wc_rest_prepare_date_response( $last_order->get_date_created() ) : null, // v1 API used UTC. + ), + 'orders_count' => $customer->get_order_count(), + 'total_spent' => $customer->get_total_spent(), + 'avatar_url' => $customer->get_avatar_url(), + 'billing' => $_data['billing'], + 'shipping' => $_data['shipping'], + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + $response = rest_ensure_response( $data ); + $response->add_links( $this->prepare_links( $user_data ) ); + + /** + * Filter customer data returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_User $user_data User object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_customer', $response, $user_data, $request ); + } + + /** + * Update customer meta fields. + * + * @param WC_Customer $customer + * @param WP_REST_Request $request + */ + protected function update_customer_meta_fields( $customer, $request ) { + $schema = $this->get_item_schema(); + + // Customer first name. + if ( isset( $request['first_name'] ) ) { + $customer->set_first_name( wc_clean( $request['first_name'] ) ); + } + + // Customer last name. + if ( isset( $request['last_name'] ) ) { + $customer->set_last_name( wc_clean( $request['last_name'] ) ); + } + + // Customer billing address. + if ( isset( $request['billing'] ) ) { + foreach ( array_keys( $schema['properties']['billing']['properties'] ) as $field ) { + if ( isset( $request['billing'][ $field ] ) && is_callable( array( $customer, "set_billing_{$field}" ) ) ) { + $customer->{"set_billing_{$field}"}( $request['billing'][ $field ] ); + } + } + } + + // Customer shipping address. + if ( isset( $request['shipping'] ) ) { + foreach ( array_keys( $schema['properties']['shipping']['properties'] ) as $field ) { + if ( isset( $request['shipping'][ $field ] ) && is_callable( array( $customer, "set_shipping_{$field}" ) ) ) { + $customer->{"set_shipping_{$field}"}( $request['shipping'][ $field ] ); + } + } + } + } + + /** + * Prepare links for the request. + * + * @param WP_User $customer Customer object. + * @return array Links for the given customer. + */ + protected function prepare_links( $customer ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $customer->ID ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the Customer's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'customer', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( 'The date the customer was created, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( 'The date the customer was last modified, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'email' => array( + 'description' => __( 'The email address for the customer.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'first_name' => array( + 'description' => __( 'Customer first name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'last_name' => array( + 'description' => __( 'Customer last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'username' => array( + 'description' => __( 'Customer login name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_user', + ), + ), + 'password' => array( + 'description' => __( 'Customer password.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), + 'last_order' => array( + 'description' => __( 'Last order data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'properties' => array( + 'id' => array( + 'description' => __( 'Last order ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date' => array( + 'description' => __( 'The date of the customer last order, as GMT.', 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + 'orders_count' => array( + 'description' => __( 'Quantity of orders made by the customer.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_spent' => array( + 'description' => __( 'Total amount spent.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'avatar_url' => array( + 'description' => __( 'Avatar URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'billing' => array( + 'description' => __( 'List of billing address data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'ISO code of the country.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Email address.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'phone' => array( + 'description' => __( 'Phone number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping' => array( + 'description' => __( 'List of shipping address data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'ISO code of the country.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get role names. + * + * @return array + */ + protected function get_role_names() { + global $wp_roles; + + return array_keys( $wp_roles->role_names ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['context']['default'] = 'view'; + + $params['exclude'] = array( + 'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['include'] = array( + 'description' => __( 'Limit result set to specific IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['order'] = array( + 'default' => 'asc', + 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), + 'enum' => array( 'asc', 'desc' ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['orderby'] = array( + 'default' => 'name', + 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), + 'enum' => array( + 'id', + 'include', + 'name', + 'registered_date', + ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['email'] = array( + 'description' => __( 'Limit result set to resources with a specific email.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['role'] = array( + 'description' => __( 'Limit result set to resources with a specific role.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'customer', + 'enum' => array_merge( array( 'all' ), $this->get_role_names() ), + 'validate_callback' => 'rest_validate_request_arg', + ); + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-notes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-notes-controller.php new file mode 100644 index 0000000..976a295 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-notes-controller.php @@ -0,0 +1,439 @@ +/notes endpoint. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Order Notes controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Controller + */ +class WC_REST_Order_Notes_V1_Controller extends WC_REST_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'orders/(?P[\d]+)/notes'; + + /** + * Post type. + * + * @var string + */ + protected $post_type = 'shop_order'; + + /** + * Register the routes for order notes. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'note' => array( + 'type' => 'string', + 'description' => __( 'Order note content.', 'woocommerce' ), + 'required' => true, + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read order notes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access create order notes. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a order note. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( $order && ! wc_rest_check_post_permissions( $this->post_type, 'read', $order->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access delete a order note. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( $order && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $order->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get order notes from an order. + * + * @param WP_REST_Request $request + * + * @return array|WP_Error + */ + public function get_items( $request ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order || $this->post_type !== $order->get_type() ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $args = array( + 'post_id' => $order->get_id(), + 'approve' => 'approve', + 'type' => 'order_note', + ); + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $notes = get_comments( $args ); + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 ); + + $data = array(); + foreach ( $notes as $note ) { + $order_note = $this->prepare_item_for_response( $note, $request ); + $order_note = $this->prepare_response_for_collection( $order_note ); + $data[] = $order_note; + } + + return rest_ensure_response( $data ); + } + + /** + * Create a single order note. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order || $this->post_type !== $order->get_type() ) { + return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + // Create the note. + $note_id = $order->add_order_note( $request['note'], $request['customer_note'] ); + + if ( ! $note_id ) { + return new WP_Error( 'woocommerce_api_cannot_create_order_note', __( 'Cannot create order note, please try again.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + $note = get_comment( $note_id ); + $this->update_additional_fields_for_object( $note, $request ); + + /** + * Fires after a order note is created or updated via the REST API. + * + * @param WP_Comment $note New order note object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( 'woocommerce_rest_insert_order_note', $note, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $note, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, str_replace( '(?P[\d]+)', $order->get_id(), $this->rest_base ), $note_id ) ) ); + + return $response; + } + + /** + * Get a single order note. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order || $this->post_type !== $order->get_type() ) { + return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $note = get_comment( $id ); + + if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $order_note = $this->prepare_item_for_response( $note, $request ); + $response = rest_ensure_response( $order_note ); + + return $response; + } + + /** + * Delete a single order note. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order || $this->post_type !== $order->get_type() ) { + return new WP_Error( 'woocommerce_rest_order_invalid_id', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $note = get_comment( $id ); + + if ( empty( $id ) || empty( $note ) || intval( $note->comment_post_ID ) !== intval( $order->get_id() ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $note, $request ); + + $result = wc_delete_order_note( $note->comment_ID ); + + if ( ! $result ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), 'order_note' ), array( 'status' => 500 ) ); + } + + /** + * Fires after a order note is deleted or trashed via the REST API. + * + * @param WP_Comment $note The deleted or trashed order note. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'woocommerce_rest_delete_order_note', $note, $response, $request ); + + return $response; + } + + /** + * Prepare a single order note output for response. + * + * @param WP_Comment $note Order note object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $note, $request ) { + $data = array( + 'id' => (int) $note->comment_ID, + 'date_created' => wc_rest_prepare_date_response( $note->comment_date_gmt ), + 'note' => $note->comment_content, + 'customer_note' => (bool) get_comment_meta( $note->comment_ID, 'is_customer_note', true ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $note ) ); + + /** + * Filter order note object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_Comment $note Order note object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_order_note', $response, $note, $request ); + } + + /** + * Prepare links for the request. + * + * @param WP_Comment $note Delivery order_note object. + * @return array Links for the given order note. + */ + protected function prepare_links( $note ) { + $order_id = (int) $note->comment_post_ID; + $base = str_replace( '(?P[\d]+)', $order_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $note->comment_ID ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order_id ) ), + ), + ); + + return $links; + } + + /** + * Get the Order Notes schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'order_note', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the order note was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'note' => array( + 'description' => __( 'Order note.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'customer_note' => array( + 'description' => __( 'Shows/define if the note is only for reference or for the customer (the user will be notified).', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-refunds-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-refunds-controller.php new file mode 100644 index 0000000..4b4bfa0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-order-refunds-controller.php @@ -0,0 +1,530 @@ +/refunds endpoint. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 2.6.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Order Refunds controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Orders_V1_Controller + */ +class WC_REST_Order_Refunds_V1_Controller extends WC_REST_Orders_V1_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'orders/(?P[\d]+)/refunds'; + + /** + * Post type. + * + * @var string + */ + protected $post_type = 'shop_order_refund'; + + /** + * Order refunds actions. + */ + public function __construct() { + add_filter( "woocommerce_rest_{$this->post_type}_trashable", '__return_false' ); + add_filter( "woocommerce_rest_{$this->post_type}_query", array( $this, 'query_args' ), 10, 2 ); + } + + /** + * Register the routes for order refunds. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'order_id' => array( + 'description' => __( 'The order ID.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => true, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Prepare a single order refund output for response. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * + * @return WP_Error|WP_REST_Response + */ + public function prepare_item_for_response( $post, $request ) { + $order = wc_get_order( (int) $request['order_id'] ); + + if ( ! $order ) { + return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 ); + } + + $refund = wc_get_order( $post ); + + if ( ! $refund || $refund->get_parent_id() !== $order->get_id() ) { + return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 ); + } + + $dp = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] ); + + $data = array( + 'id' => $refund->get_id(), + 'date_created' => wc_rest_prepare_date_response( $refund->get_date_created() ), + 'amount' => wc_format_decimal( $refund->get_amount(), $dp ), + 'reason' => $refund->get_reason(), + 'line_items' => array(), + ); + + // Add line items. + foreach ( $refund->get_items() as $item_id => $item ) { + $product = $refund->get_product_from_item( $item ); + $product_id = 0; + $variation_id = 0; + $product_sku = null; + + // Check if the product exists. + if ( is_object( $product ) ) { + $product_id = $item->get_product_id(); + $variation_id = $item->get_variation_id(); + $product_sku = $product->get_sku(); + } + + $item_meta = array(); + + $hideprefix = 'true' === $request['all_item_meta'] ? null : '_'; + + foreach ( $item->get_formatted_meta_data( $hideprefix, true ) as $meta_key => $formatted_meta ) { + $item_meta[] = array( + 'key' => $formatted_meta->key, + 'label' => $formatted_meta->display_key, + 'value' => wc_clean( $formatted_meta->display_value ), + ); + } + + $line_item = array( + 'id' => $item_id, + 'name' => $item['name'], + 'sku' => $product_sku, + 'product_id' => (int) $product_id, + 'variation_id' => (int) $variation_id, + 'quantity' => wc_stock_amount( $item['qty'] ), + 'tax_class' => ! empty( $item['tax_class'] ) ? $item['tax_class'] : '', + 'price' => wc_format_decimal( $refund->get_item_total( $item, false, false ), $dp ), + 'subtotal' => wc_format_decimal( $refund->get_line_subtotal( $item, false, false ), $dp ), + 'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ), + 'total' => wc_format_decimal( $refund->get_line_total( $item, false, false ), $dp ), + 'total_tax' => wc_format_decimal( $item['line_tax'], $dp ), + 'taxes' => array(), + 'meta' => $item_meta, + ); + + $item_line_taxes = maybe_unserialize( $item['line_tax_data'] ); + if ( isset( $item_line_taxes['total'] ) ) { + $line_tax = array(); + + foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) { + $line_tax[ $tax_rate_id ] = array( + 'id' => $tax_rate_id, + 'total' => $tax, + 'subtotal' => '', + ); + } + + foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) { + $line_tax[ $tax_rate_id ]['subtotal'] = $tax; + } + + $line_item['taxes'] = array_values( $line_tax ); + } + + $data['line_items'][] = $line_item; + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $refund, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Order_Refund $refund Comment object. + * @param WP_REST_Request $request Request object. + * @return array Links for the given order refund. + */ + protected function prepare_links( $refund, $request ) { + $order_id = $refund->get_parent_id(); + $base = str_replace( '(?P[\d]+)', $order_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $refund->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order_id ) ), + ), + ); + + return $links; + } + + /** + * Query args. + * + * @param array $args Request args. + * @param WP_REST_Request $request Request object. + * @return array + */ + public function query_args( $args, $request ) { + $args['post_status'] = array_keys( wc_get_order_statuses() ); + $args['post_parent__in'] = array( absint( $request['order_id'] ) ); + + return $args; + } + + /** + * Create a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $order_data = get_post( (int) $request['order_id'] ); + + if ( empty( $order_data ) ) { + return new WP_Error( 'woocommerce_rest_invalid_order', __( 'Order is invalid', 'woocommerce' ), 400 ); + } + + if ( 0 > $request['amount'] ) { + return new WP_Error( 'woocommerce_rest_invalid_order_refund', __( 'Refund amount must be greater than zero.', 'woocommerce' ), 400 ); + } + + // Create the refund. + $refund = wc_create_refund( array( + 'order_id' => $order_data->ID, + 'amount' => $request['amount'], + 'reason' => empty( $request['reason'] ) ? null : $request['reason'], + 'refund_payment' => is_bool( $request['api_refund'] ) ? $request['api_refund'] : true, + 'restock_items' => true, + ) ); + + if ( is_wp_error( $refund ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', $refund->get_error_message(), 500 ); + } + + if ( ! $refund ) { + return new WP_Error( 'woocommerce_rest_cannot_create_order_refund', __( 'Cannot create order refund, please try again.', 'woocommerce' ), 500 ); + } + + $post = get_post( $refund->get_id() ); + $this->update_additional_fields_for_object( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) ); + + return $response; + } + + /** + * Get the Order's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'amount' => array( + 'description' => __( 'Refund amount.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'reason' => array( + 'description' => __( 'Reason for refund.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'line_items' => array( + 'description' => __( 'Line items data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sku' => array( + 'description' => __( 'Product SKU.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Product ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'variation_id' => array( + 'description' => __( 'Variation ID, if applicable.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'quantity' => array( + 'description' => __( 'Quantity ordered.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tax_class' => array( + 'description' => __( 'Tax class of product.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'price' => array( + 'description' => __( 'Product price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal_tax' => array( + 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'meta' => array( + 'description' => __( 'Line item meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'Meta label.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['dp'] = array( + 'default' => wc_get_price_decimals(), + 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-orders-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-orders-controller.php new file mode 100644 index 0000000..804e3fb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-orders-controller.php @@ -0,0 +1,1626 @@ +post_type}_query", array( $this, 'query_args' ), 10, 2 ); + } + + /** + * Register the routes for orders. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Prepare a single order output for response. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $data + */ + public function prepare_item_for_response( $post, $request ) { + $order = wc_get_order( $post ); + $dp = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] ); + + $data = array( + 'id' => $order->get_id(), + 'parent_id' => $order->get_parent_id(), + 'status' => $order->get_status(), + 'order_key' => $order->get_order_key(), + 'number' => $order->get_order_number(), + 'currency' => $order->get_currency(), + 'version' => $order->get_version(), + 'prices_include_tax' => $order->get_prices_include_tax(), + 'date_created' => wc_rest_prepare_date_response( $order->get_date_created() ), // v1 API used UTC. + 'date_modified' => wc_rest_prepare_date_response( $order->get_date_modified() ), // v1 API used UTC. + 'customer_id' => $order->get_customer_id(), + 'discount_total' => wc_format_decimal( $order->get_total_discount(), $dp ), + 'discount_tax' => wc_format_decimal( $order->get_discount_tax(), $dp ), + 'shipping_total' => wc_format_decimal( $order->get_shipping_total(), $dp ), + 'shipping_tax' => wc_format_decimal( $order->get_shipping_tax(), $dp ), + 'cart_tax' => wc_format_decimal( $order->get_cart_tax(), $dp ), + 'total' => wc_format_decimal( $order->get_total(), $dp ), + 'total_tax' => wc_format_decimal( $order->get_total_tax(), $dp ), + 'billing' => array(), + 'shipping' => array(), + 'payment_method' => $order->get_payment_method(), + 'payment_method_title' => $order->get_payment_method_title(), + 'transaction_id' => $order->get_transaction_id(), + 'customer_ip_address' => $order->get_customer_ip_address(), + 'customer_user_agent' => $order->get_customer_user_agent(), + 'created_via' => $order->get_created_via(), + 'customer_note' => $order->get_customer_note(), + 'date_completed' => wc_rest_prepare_date_response( $order->get_date_completed(), false ), // v1 API used local time. + 'date_paid' => wc_rest_prepare_date_response( $order->get_date_paid(), false ), // v1 API used local time. + 'cart_hash' => $order->get_cart_hash(), + 'line_items' => array(), + 'tax_lines' => array(), + 'shipping_lines' => array(), + 'fee_lines' => array(), + 'coupon_lines' => array(), + 'refunds' => array(), + ); + + // Add addresses. + $data['billing'] = $order->get_address( 'billing' ); + $data['shipping'] = $order->get_address( 'shipping' ); + + // Add line items. + foreach ( $order->get_items() as $item_id => $item ) { + $product = $order->get_product_from_item( $item ); + $product_id = 0; + $variation_id = 0; + $product_sku = null; + + // Check if the product exists. + if ( is_object( $product ) ) { + $product_id = $item->get_product_id(); + $variation_id = $item->get_variation_id(); + $product_sku = $product->get_sku(); + } + + $item_meta = array(); + + $hideprefix = 'true' === $request['all_item_meta'] ? null : '_'; + + foreach ( $item->get_formatted_meta_data( $hideprefix, true ) as $meta_key => $formatted_meta ) { + $item_meta[] = array( + 'key' => $formatted_meta->key, + 'label' => $formatted_meta->display_key, + 'value' => wc_clean( $formatted_meta->display_value ), + ); + } + + $line_item = array( + 'id' => $item_id, + 'name' => $item['name'], + 'sku' => $product_sku, + 'product_id' => (int) $product_id, + 'variation_id' => (int) $variation_id, + 'quantity' => wc_stock_amount( $item['qty'] ), + 'tax_class' => ! empty( $item['tax_class'] ) ? $item['tax_class'] : '', + 'price' => wc_format_decimal( $order->get_item_total( $item, false, false ), $dp ), + 'subtotal' => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ), + 'subtotal_tax' => wc_format_decimal( $item['line_subtotal_tax'], $dp ), + 'total' => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ), + 'total_tax' => wc_format_decimal( $item['line_tax'], $dp ), + 'taxes' => array(), + 'meta' => $item_meta, + ); + + $item_line_taxes = maybe_unserialize( $item['line_tax_data'] ); + if ( isset( $item_line_taxes['total'] ) ) { + $line_tax = array(); + + foreach ( $item_line_taxes['total'] as $tax_rate_id => $tax ) { + $line_tax[ $tax_rate_id ] = array( + 'id' => $tax_rate_id, + 'total' => $tax, + 'subtotal' => '', + ); + } + + foreach ( $item_line_taxes['subtotal'] as $tax_rate_id => $tax ) { + $line_tax[ $tax_rate_id ]['subtotal'] = $tax; + } + + $line_item['taxes'] = array_values( $line_tax ); + } + + $data['line_items'][] = $line_item; + } + + // Add taxes. + foreach ( $order->get_items( 'tax' ) as $key => $tax ) { + $tax_line = array( + 'id' => $key, + 'rate_code' => $tax['name'], + 'rate_id' => $tax['rate_id'], + 'label' => isset( $tax['label'] ) ? $tax['label'] : $tax['name'], + 'compound' => (bool) $tax['compound'], + 'tax_total' => wc_format_decimal( $tax['tax_amount'], $dp ), + 'shipping_tax_total' => wc_format_decimal( $tax['shipping_tax_amount'], $dp ), + ); + + $data['tax_lines'][] = $tax_line; + } + + // Add shipping. + foreach ( $order->get_shipping_methods() as $shipping_item_id => $shipping_item ) { + $shipping_line = array( + 'id' => $shipping_item_id, + 'method_title' => $shipping_item['name'], + 'method_id' => $shipping_item['method_id'], + 'total' => wc_format_decimal( $shipping_item['cost'], $dp ), + 'total_tax' => wc_format_decimal( '', $dp ), + 'taxes' => array(), + ); + + $shipping_taxes = $shipping_item->get_taxes(); + + if ( ! empty( $shipping_taxes['total'] ) ) { + $shipping_line['total_tax'] = wc_format_decimal( array_sum( $shipping_taxes['total'] ), $dp ); + + foreach ( $shipping_taxes['total'] as $tax_rate_id => $tax ) { + $shipping_line['taxes'][] = array( + 'id' => $tax_rate_id, + 'total' => $tax, + ); + } + } + + $data['shipping_lines'][] = $shipping_line; + } + + // Add fees. + foreach ( $order->get_fees() as $fee_item_id => $fee_item ) { + $fee_line = array( + 'id' => $fee_item_id, + 'name' => $fee_item['name'], + 'tax_class' => ! empty( $fee_item['tax_class'] ) ? $fee_item['tax_class'] : '', + 'tax_status' => 'taxable', + 'total' => wc_format_decimal( $order->get_line_total( $fee_item ), $dp ), + 'total_tax' => wc_format_decimal( $order->get_line_tax( $fee_item ), $dp ), + 'taxes' => array(), + ); + + $fee_line_taxes = maybe_unserialize( $fee_item['line_tax_data'] ); + if ( isset( $fee_line_taxes['total'] ) ) { + $fee_tax = array(); + + foreach ( $fee_line_taxes['total'] as $tax_rate_id => $tax ) { + $fee_tax[ $tax_rate_id ] = array( + 'id' => $tax_rate_id, + 'total' => $tax, + 'subtotal' => '', + ); + } + + if ( isset( $fee_line_taxes['subtotal'] ) ) { + foreach ( $fee_line_taxes['subtotal'] as $tax_rate_id => $tax ) { + $fee_tax[ $tax_rate_id ]['subtotal'] = $tax; + } + } + + $fee_line['taxes'] = array_values( $fee_tax ); + } + + $data['fee_lines'][] = $fee_line; + } + + // Add coupons. + foreach ( $order->get_items( 'coupon' ) as $coupon_item_id => $coupon_item ) { + $coupon_line = array( + 'id' => $coupon_item_id, + 'code' => $coupon_item['name'], + 'discount' => wc_format_decimal( $coupon_item['discount_amount'], $dp ), + 'discount_tax' => wc_format_decimal( $coupon_item['discount_amount_tax'], $dp ), + ); + + $data['coupon_lines'][] = $coupon_line; + } + + // Add refunds. + foreach ( $order->get_refunds() as $refund ) { + $data['refunds'][] = array( + 'id' => $refund->get_id(), + 'refund' => $refund->get_reason() ? $refund->get_reason() : '', + 'total' => '-' . wc_format_decimal( $refund->get_amount(), $dp ), + ); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $order, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Order $order Order object. + * @param WP_REST_Request $request Request object. + * @return array Links for the given order. + */ + protected function prepare_links( $order, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + if ( 0 !== (int) $order->get_user_id() ) { + $links['customer'] = array( + 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $order->get_user_id() ) ), + ); + } + if ( 0 !== (int) $order->get_parent_id() ) { + $links['up'] = array( + 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order->get_parent_id() ) ), + ); + } + return $links; + } + + /** + * Query args. + * + * @param array $args + * @param WP_REST_Request $request + * @return array + */ + public function query_args( $args, $request ) { + global $wpdb; + + // Set post_status. + if ( 'any' !== $request['status'] ) { + $args['post_status'] = 'wc-' . $request['status']; + } else { + $args['post_status'] = 'any'; + } + + if ( isset( $request['customer'] ) ) { + if ( ! empty( $args['meta_query'] ) ) { + $args['meta_query'] = array(); + } + + $args['meta_query'][] = array( + 'key' => '_customer_user', + 'value' => $request['customer'], + 'type' => 'NUMERIC', + ); + } + + // Search by product. + if ( ! empty( $request['product'] ) ) { + $order_ids = $wpdb->get_col( $wpdb->prepare( " + SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items + WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) + AND order_item_type = 'line_item' + ", $request['product'] ) ); + + // Force WP_Query return empty if don't found any order. + $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); + + $args['post__in'] = $order_ids; + } + + // Search. + if ( ! empty( $args['s'] ) ) { + $order_ids = wc_order_search( $args['s'] ); + + if ( ! empty( $order_ids ) ) { + unset( $args['s'] ); + $args['post__in'] = array_merge( $order_ids, array( 0 ) ); + } + } + + return $args; + } + + /** + * Prepare a single order for create. + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|WC_Order $data Object. + */ + protected function prepare_item_for_database( $request ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + $order = new WC_Order( $id ); + $schema = $this->get_item_schema(); + $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) ); + + // Handle all writable props + foreach ( $data_keys as $key ) { + $value = $request[ $key ]; + + if ( ! is_null( $value ) ) { + switch ( $key ) { + case 'billing' : + case 'shipping' : + $this->update_address( $order, $value, $key ); + break; + case 'line_items' : + case 'shipping_lines' : + case 'fee_lines' : + case 'coupon_lines' : + if ( is_array( $value ) ) { + foreach ( $value as $item ) { + if ( is_array( $item ) ) { + if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) { + $order->remove_item( $item['id'] ); + } else { + $this->set_item( $order, $key, $item ); + } + } + } + } + break; + default : + if ( is_callable( array( $order, "set_{$key}" ) ) ) { + $order->{"set_{$key}"}( $value ); + } + break; + } + } + } + + /** + * Filter the data for the insert. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WC_Order $order The order object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $order, $request ); + } + + /** + * Create base WC Order object. + * @deprecated 3.0.0 + * @param array $data + * @return WC_Order + */ + protected function create_base_order( $data ) { + return wc_create_order( $data ); + } + + /** + * Only return writable props from schema. + * @param array $schema + * @return bool + */ + protected function filter_writable_props( $schema ) { + return empty( $schema['readonly'] ); + } + + /** + * Create order. + * + * @param WP_REST_Request $request Full details about the request. + * @return int|WP_Error + */ + protected function create_order( $request ) { + try { + // Make sure customer exists. + if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 ); + } + + // Make sure customer is part of blog. + if ( is_multisite() && ! is_user_member_of_blog( $request['customer_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id_network',__( 'Customer ID does not belong to this site.', 'woocommerce' ), 400 ); + } + + $order = $this->prepare_item_for_database( $request ); + $order->set_created_via( 'rest-api' ); + $order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) ); + $order->calculate_totals(); + $order->save(); + + // Handle set paid. + if ( true === $request['set_paid'] ) { + $order->payment_complete( $request['transaction_id'] ); + } + + return $order->get_id(); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Update order. + * + * @param WP_REST_Request $request Full details about the request. + * @return int|WP_Error + */ + protected function update_order( $request ) { + try { + $order = $this->prepare_item_for_database( $request ); + $order->save(); + + // Handle set paid. + if ( $order->needs_payment() && true === $request['set_paid'] ) { + $order->payment_complete( $request['transaction_id'] ); + } + + // If items have changed, recalculate order totals. + if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { + $order->calculate_totals( true ); + } + + return $order->get_id(); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Update address. + * + * @param WC_Order $order + * @param array $posted + * @param string $type + */ + protected function update_address( $order, $posted, $type = 'billing' ) { + foreach ( $posted as $key => $value ) { + if ( is_callable( array( $order, "set_{$type}_{$key}" ) ) ) { + $order->{"set_{$type}_{$key}"}( $value ); + } + } + } + + /** + * Gets the product ID from the SKU or posted ID. + * + * @param array $posted Request data + * + * @return int + * @throws WC_REST_Exception + */ + protected function get_product_id( $posted ) { + if ( ! empty( $posted['sku'] ) ) { + $product_id = (int) wc_get_product_id_by_sku( $posted['sku'] ); + } elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) { + $product_id = (int) $posted['product_id']; + } elseif ( ! empty( $posted['variation_id'] ) ) { + $product_id = (int) $posted['variation_id']; + } else { + throw new WC_REST_Exception( 'woocommerce_rest_required_product_reference', __( 'Product ID or SKU is required.', 'woocommerce' ), 400 ); + } + return $product_id; + } + + /** + * Maybe set an item prop if the value was posted. + * @param WC_Order_Item $item + * @param string $prop + * @param array $posted Request data. + */ + protected function maybe_set_item_prop( $item, $prop, $posted ) { + if ( isset( $posted[ $prop ] ) ) { + $item->{"set_$prop"}( $posted[ $prop ] ); + } + } + + /** + * Maybe set item props if the values were posted. + * @param WC_Order_Item $item + * @param string[] $props + * @param array $posted Request data. + */ + protected function maybe_set_item_props( $item, $props, $posted ) { + foreach ( $props as $prop ) { + $this->maybe_set_item_prop( $item, $prop, $posted ); + } + } + + /** + * Create or update a line item. + * + * @param array $posted Line item data. + * @param string $action 'create' to add line item or 'update' to update it. + * + * @return WC_Order_Item_Product + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_line_items( $posted, $action = 'create' ) { + $item = new WC_Order_Item_Product( ! empty( $posted['id'] ) ? $posted['id'] : '' ); + $product = wc_get_product( $this->get_product_id( $posted ) ); + + if ( $product !== $item->get_product() ) { + $item->set_product( $product ); + + if ( 'create' === $action ) { + $quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1; + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) ); + $item->set_total( $total ); + $item->set_subtotal( $total ); + } + } + + $this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted ); + + return $item; + } + + /** + * Create or update an order shipping method. + * + * @param $posted $shipping Item data. + * @param string $action 'create' to add shipping or 'update' to update it. + * + * @return WC_Order_Item_Shipping + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_shipping_lines( $posted, $action ) { + $item = new WC_Order_Item_Shipping( ! empty( $posted['id'] ) ? $posted['id'] : '' ); + + if ( 'create' === $action ) { + if ( empty( $posted['method_id'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_shipping_item', __( 'Shipping method ID is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'method_id', 'method_title', 'total' ), $posted ); + + return $item; + } + + /** + * Create or update an order fee. + * + * @param array $posted Item data. + * @param string $action 'create' to add fee or 'update' to update it. + * + * @return WC_Order_Item_Fee + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_fee_lines( $posted, $action ) { + $item = new WC_Order_Item_Fee( ! empty( $posted['id'] ) ? $posted['id'] : '' ); + + if ( 'create' === $action ) { + if ( empty( $posted['name'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_fee_item', __( 'Fee name is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'name', 'tax_class', 'tax_status', 'total' ), $posted ); + + return $item; + } + + /** + * Create or update an order coupon. + * + * @param array $posted Item data. + * @param string $action 'create' to add coupon or 'update' to update it. + * + * @return WC_Order_Item_Coupon + * @throws WC_REST_Exception Invalid data, server error. + */ + protected function prepare_coupon_lines( $posted, $action ) { + $item = new WC_Order_Item_Coupon( ! empty( $posted['id'] ) ? $posted['id'] : '' ); + + if ( 'create' === $action ) { + if ( empty( $posted['code'] ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_coupon_coupon', __( 'Coupon code is required.', 'woocommerce' ), 400 ); + } + } + + $this->maybe_set_item_props( $item, array( 'code', 'discount' ), $posted ); + + return $item; + } + + /** + * Wrapper method to create/update order items. + * When updating, the item ID provided is checked to ensure it is associated + * with the order. + * + * @param WC_Order $order order + * @param string $item_type + * @param array $posted item provided in the request body + * @throws WC_REST_Exception If item ID is not associated with order + */ + protected function set_item( $order, $item_type, $posted ) { + global $wpdb; + + if ( ! empty( $posted['id'] ) ) { + $action = 'update'; + } else { + $action = 'create'; + } + + $method = 'prepare_' . $item_type; + + // Verify provided line item ID is associated with order. + if ( 'update' === $action ) { + $result = $wpdb->get_row( + $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d AND order_id = %d", + absint( $posted['id'] ), + absint( $order->get_id() ) + ) ); + if ( is_null( $result ) ) { + throw new WC_REST_Exception( 'woocommerce_rest_invalid_item_id', __( 'Order item ID provided is not associated with order.', 'woocommerce' ), 400 ); + } + } + + // Prepare item data + $item = $this->$method( $posted, $action ); + + /** + * Action hook to adjust item before save. + * @since 3.0.0 + */ + do_action( 'woocommerce_rest_set_order_item', $item, $posted ); + + // Save or add to order + if ( 'create' === $action ) { + $order->add_item( $item ); + } else { + $item->save(); + } + } + + /** + * Helper method to check if the resource ID associated with the provided item is null. + * Items can be deleted by setting the resource ID to null. + * + * @param array $item Item provided in the request body. + * @return bool True if the item resource ID is null, false otherwise. + */ + protected function item_is_null( $item ) { + $keys = array( 'product_id', 'method_id', 'method_title', 'name', 'code' ); + + foreach ( $keys as $key ) { + if ( array_key_exists( $key, $item ) && is_null( $item[ $key ] ) ) { + return true; + } + } + + return false; + } + + /** + * Create a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $order_id = $this->create_order( $request ); + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $post = get_post( $order_id ); + $this->update_additional_fields_for_object( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, true ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) ); + + return $response; + } + + /** + * Update a single order. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + try { + $post_id = (int) $request['id']; + + if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $order_id = $this->update_order( $request ); + if ( is_wp_error( $order_id ) ) { + return $order_id; + } + + $post = get_post( $order_id ); + $this->update_additional_fields_for_object( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_{$this->post_type}", $post, $request, false ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + return rest_ensure_response( $response ); + + } catch ( Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Get order statuses without prefixes. + * @return array + */ + protected function get_order_statuses() { + $order_statuses = array(); + + foreach ( array_keys( wc_get_order_statuses() ) as $status ) { + $order_statuses[] = str_replace( 'wc-', '', $status ); + } + + return $order_statuses; + } + + /** + * Get the Order's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'parent_id' => array( + 'description' => __( 'Parent order ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'status' => array( + 'description' => __( 'Order status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'pending', + 'enum' => $this->get_order_statuses(), + 'context' => array( 'view', 'edit' ), + ), + 'order_key' => array( + 'description' => __( 'Order key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'number' => array( + 'description' => __( 'Order number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'currency' => array( + 'description' => __( 'Currency the order was created with, in ISO format.', 'woocommerce' ), + 'type' => 'string', + 'default' => get_woocommerce_currency(), + 'enum' => array_keys( get_woocommerce_currencies() ), + 'context' => array( 'view', 'edit' ), + ), + 'version' => array( + 'description' => __( 'Version of WooCommerce which last updated the order.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'prices_include_tax' => array( + 'description' => __( 'True the prices included tax during checkout.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the order was created, as GMT.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the order was last modified, as GMT.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_id' => array( + 'description' => __( 'User ID who owns the order. 0 for guests.', 'woocommerce' ), + 'type' => 'integer', + 'default' => 0, + 'context' => array( 'view', 'edit' ), + ), + 'discount_total' => array( + 'description' => __( 'Total discount amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'discount_tax' => array( + 'description' => __( 'Total discount tax amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_total' => array( + 'description' => __( 'Total shipping amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_tax' => array( + 'description' => __( 'Total shipping tax amount for the order.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'cart_tax' => array( + 'description' => __( 'Sum of line item taxes only.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Grand total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_tax' => array( + 'description' => __( 'Sum of all taxes.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'billing' => array( + 'description' => __( 'Billing address.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Email address.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'email', + 'context' => array( 'view', 'edit' ), + ), + 'phone' => array( + 'description' => __( 'Phone number.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping' => array( + 'description' => __( 'Shipping address.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'first_name' => array( + 'description' => __( 'First name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'last_name' => array( + 'description' => __( 'Last name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'company' => array( + 'description' => __( 'Company name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_1' => array( + 'description' => __( 'Address line 1.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'address_2' => array( + 'description' => __( 'Address line 2.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'ISO code or name of the state, province or district.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postal code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'country' => array( + 'description' => __( 'Country code in ISO 3166-1 alpha-2 format.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'payment_method' => array( + 'description' => __( 'Payment method ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'payment_method_title' => array( + 'description' => __( 'Payment method title.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'set_paid' => array( + 'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'edit' ), + ), + 'transaction_id' => array( + 'description' => __( 'Unique transaction ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'customer_ip_address' => array( + 'description' => __( "Customer's IP address.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_user_agent' => array( + 'description' => __( 'User agent of the customer.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'created_via' => array( + 'description' => __( 'Shows where the order was created.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'customer_note' => array( + 'description' => __( 'Note left by customer during checkout.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_completed' => array( + 'description' => __( "The date the order was completed, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_paid' => array( + 'description' => __( "The date the order was paid, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'cart_hash' => array( + 'description' => __( 'MD5 hash of cart items to ensure orders are not modified.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'line_items' => array( + 'description' => __( 'Line items data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sku' => array( + 'description' => __( 'Product SKU.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Product ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'variation_id' => array( + 'description' => __( 'Variation ID, if applicable.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'quantity' => array( + 'description' => __( 'Quantity ordered.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class of product.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'price' => array( + 'description' => __( 'Product price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Line subtotal (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'subtotal_tax' => array( + 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'meta' => array( + 'description' => __( 'Line item meta data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'key' => array( + 'description' => __( 'Meta key.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'Meta label.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'value' => array( + 'description' => __( 'Meta value.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ), + ), + ), + 'tax_lines' => array( + 'description' => __( 'Tax lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rate_code' => array( + 'description' => __( 'Tax rate code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rate_id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'label' => array( + 'description' => __( 'Tax rate label.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'compound' => array( + 'description' => __( 'Show if is a compound tax rate.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'tax_total' => array( + 'description' => __( 'Tax total (not including shipping taxes).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_tax_total' => array( + 'description' => __( 'Shipping tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'shipping_lines' => array( + 'description' => __( 'Shipping lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'method_title' => array( + 'description' => __( 'Shipping method name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'method_id' => array( + 'description' => __( 'Shipping method ID.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ), + ), + ), + 'fee_lines' => array( + 'description' => __( 'Fee lines data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Fee name.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class of fee.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status of fee.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'enum' => array( 'taxable', 'none' ), + ), + 'total' => array( + 'description' => __( 'Line total (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'total_tax' => array( + 'description' => __( 'Line total tax (after discounts).', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'taxes' => array( + 'description' => __( 'Line taxes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tax rate ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Tax total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'subtotal' => array( + 'description' => __( 'Tax subtotal.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ), + ), + ), + 'coupon_lines' => array( + 'description' => __( 'Coupons line data.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Item ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'code' => array( + 'description' => __( 'Coupon code.', 'woocommerce' ), + 'type' => 'mixed', + 'context' => array( 'view', 'edit' ), + ), + 'discount' => array( + 'description' => __( 'Discount total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'discount_tax' => array( + 'description' => __( 'Discount total tax.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'refunds' => array( + 'description' => __( 'List of refunds.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Refund ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'reason' => array( + 'description' => __( 'Refund reason.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total' => array( + 'description' => __( 'Refund total.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['status'] = array( + 'default' => 'any', + 'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_merge( array( 'any' ), $this->get_order_statuses() ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['customer'] = array( + 'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['product'] = array( + 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['dp'] = array( + 'default' => wc_get_price_decimals(), + 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attribute-terms-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attribute-terms-controller.php new file mode 100644 index 0000000..e11ba3d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attribute-terms-controller.php @@ -0,0 +1,240 @@ +/terms endpoint. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Product Attribute Terms controller class. + * + * @package WooCommerce/API + * @extends WC_REST_Terms_Controller + */ +class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'products/attributes/(?P[\d]+)/terms'; + + /** + * Register the routes for terms. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'attribute_id' => array( + 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'name' => array( + 'type' => 'string', + 'description' => __( 'Name for the resource.', 'woocommerce' ), + 'required' => true, + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + )); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + 'attribute_id' => array( + 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + 'args' => array( + 'attribute_id' => array( + 'description' => __( 'Unique identifier for the attribute of the terms.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Prepare a single product attribute term output for response. + * + * @param WP_Term $item Term object. + * @param WP_REST_Request $request + * @return WP_REST_Response $response + */ + public function prepare_item_for_response( $item, $request ) { + // Get term order. + $menu_order = get_woocommerce_term_meta( $item->term_id, 'order_' . $this->taxonomy ); + + $data = array( + 'id' => (int) $item->term_id, + 'name' => $item->name, + 'slug' => $item->slug, + 'description' => $item->description, + 'menu_order' => (int) $menu_order, + 'count' => (int) $item->count, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item, $request ) ); + + /** + * Filter a term item returned from the API. + * + * Allows modification of the term data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original term object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); + } + + /** + * Update term meta fields. + * + * @param WP_Term $term + * @param WP_REST_Request $request + * @return bool|WP_Error + */ + protected function update_term_meta_fields( $term, $request ) { + $id = (int) $term->term_id; + + update_woocommerce_term_meta( $id, 'order_' . $this->taxonomy, $request['menu_order'] ); + + return true; + } + + /** + * Get the Attribute Term's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'product_attribute_term', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Term name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'description' => array( + 'description' => __( 'HTML description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wp_filter_post_kses', + ), + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'count' => array( + 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attributes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attributes-controller.php new file mode 100644 index 0000000..e429065 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-attributes-controller.php @@ -0,0 +1,586 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'name' => array( + 'description' => __( 'Name for the resource.', 'woocommerce' ), + 'type' => 'string', + 'required' => true, + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + )); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => true, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Check if a given request has access to read the attributes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to create a attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'attributes', 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! $this->get_taxonomy( $request ) ) { + return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to update a attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_item_permissions_check( $request ) { + if ( ! $this->get_taxonomy( $request ) ) { + return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + if ( ! wc_rest_check_manager_permissions( 'attributes', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to delete a attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function delete_item_permissions_check( $request ) { + if ( ! $this->get_taxonomy( $request ) ) { + return new WP_Error( 'woocommerce_rest_taxonomy_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + if ( ! wc_rest_check_manager_permissions( 'attributes', 'delete' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access batch create, update and delete items. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function batch_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'attributes', 'batch' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all attributes. + * + * @param WP_REST_Request $request + * @return array + */ + public function get_items( $request ) { + $attributes = wc_get_attribute_taxonomies(); + $data = array(); + foreach ( $attributes as $attribute_obj ) { + $attribute = $this->prepare_item_for_response( $attribute_obj, $request ); + $attribute = $this->prepare_response_for_collection( $attribute ); + $data[] = $attribute; + } + + return rest_ensure_response( $data ); + } + + /** + * Create a single attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function create_item( $request ) { + global $wpdb; + + $id = wc_create_attribute( array( + 'name' => $request['name'], + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), + 'type' => ! empty( $request['type'] ) ? $request['type'] : 'select', + 'order_by' => ! empty( $request['order_by'] ) ? $request['order_by'] : 'menu_order', + 'has_archives' => true === $request['has_archives'], + ) ); + + // Checks for errors. + if ( is_wp_error( $id ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', $id->get_error_message(), array( 'status' => 400 ) ); + } + + $attribute = $this->get_attribute( $id ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $this->update_additional_fields_for_object( $attribute, $request ); + + /** + * Fires after a single product attribute is created or updated via the REST API. + * + * @param stdObject $attribute Inserted attribute object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating attribute, false when updating. + */ + do_action( 'woocommerce_rest_insert_product_attribute', $attribute, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $attribute, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( '/' . $this->namespace . '/' . $this->rest_base . '/' . $attribute->attribute_id ) ); + + return $response; + } + + /** + * Get a single attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function get_item( $request ) { + $attribute = $this->get_attribute( (int) $request['id'] ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $response = $this->prepare_item_for_response( $attribute, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Update a single term from a taxonomy. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Request|WP_Error + */ + public function update_item( $request ) { + global $wpdb; + + $id = (int) $request['id']; + $edited = wc_update_attribute( $id, array( + 'name' => $request['name'], + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), + 'type' => $request['type'], + 'order_by' => $request['order_by'], + 'has_archives' => $request['has_archives'], + ) ); + + // Checks for errors. + if ( is_wp_error( $edited ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', $edited->get_error_message(), array( 'status' => 400 ) ); + } + + $attribute = $this->get_attribute( $id ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $this->update_additional_fields_for_object( $attribute, $request ); + + /** + * Fires after a single product attribute is created or updated via the REST API. + * + * @param stdObject $attribute Inserted attribute object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating attribute, false when updating. + */ + do_action( 'woocommerce_rest_insert_product_attribute', $attribute, $request, false ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $attribute, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Delete a single attribute. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $attribute = $this->get_attribute( (int) $request['id'] ); + + if ( is_wp_error( $attribute ) ) { + return $attribute; + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $attribute, $request ); + + $deleted = wc_delete_attribute( $attribute->attribute_id ); + + if ( false === $deleted ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + /** + * Fires after a single attribute is deleted via the REST API. + * + * @param stdObject $attribute The deleted attribute. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'woocommerce_rest_delete_product_attribute', $attribute, $response, $request ); + + return $response; + } + + /** + * Prepare a single product attribute output for response. + * + * @param obj $item Term object. + * @param WP_REST_Request $request + * @return WP_REST_Response $response + */ + public function prepare_item_for_response( $item, $request ) { + $data = array( + 'id' => (int) $item->attribute_id, + 'name' => $item->attribute_label, + 'slug' => wc_attribute_taxonomy_name( $item->attribute_name ), + 'type' => $item->attribute_type, + 'order_by' => $item->attribute_orderby, + 'has_archives' => (bool) $item->attribute_public, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item ) ); + + /** + * Filter a attribute item returned from the API. + * + * Allows modification of the product attribute data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original attribute object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( 'woocommerce_rest_prepare_product_attribute', $response, $item, $request ); + } + + /** + * Prepare links for the request. + * + * @param object $attribute Attribute object. + * @return array Links for the given attribute. + */ + protected function prepare_links( $attribute ) { + $base = '/' . $this->namespace . '/' . $this->rest_base; + $links = array( + 'self' => array( + 'href' => rest_url( trailingslashit( $base ) . $attribute->attribute_id ), + ), + 'collection' => array( + 'href' => rest_url( $base ), + ), + ); + + return $links; + } + + /** + * Get the Attribute's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'product_attribute', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'type' => array( + 'description' => __( 'Type of attribute.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'select', + 'enum' => array_keys( wc_get_attribute_types() ), + 'context' => array( 'view', 'edit' ), + ), + 'order_by' => array( + 'description' => __( 'Default sort order.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'menu_order', + 'enum' => array( 'menu_order', 'name', 'name_num', 'id' ), + 'context' => array( 'view', 'edit' ), + ), + 'has_archives' => array( + 'description' => __( 'Enable/Disable attribute archives.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections + * + * @return array + */ + public function get_collection_params() { + $params = array(); + $params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); + + return $params; + } + + /** + * Get attribute name. + * + * @param WP_REST_Request $request Full details about the request. + * @return string + */ + protected function get_taxonomy( $request ) { + if ( '' !== $this->attribute ) { + return $this->attribute; + } + + if ( $request['id'] ) { + $name = wc_attribute_taxonomy_name_by_id( (int) $request['id'] ); + + $this->attribute = $name; + } + + return $this->attribute; + } + + /** + * Get attribute data. + * + * @param int $id Attribute ID. + * @return stdClass|WP_Error + */ + protected function get_attribute( $id ) { + global $wpdb; + + $attribute = $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$wpdb->prefix}woocommerce_attribute_taxonomies + WHERE attribute_id = %d + ", $id ) ); + + if ( is_wp_error( $attribute ) || is_null( $attribute ) ) { + return new WP_Error( 'woocommerce_rest_attribute_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + return $attribute; + } + + /** + * Validate attribute slug. + * + * @deprecated 3.2.0 + * @param string $slug + * @param bool $new_data + * @return bool|WP_Error + */ + protected function validate_attribute_slug( $slug, $new_data = true ) { + if ( strlen( $slug ) >= 28 ) { + return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); + } elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) { + return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); + } elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { + return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); + } + + return true; + } + + /** + * Schedule to flush rewrite rules. + * + * @deprecated 3.2.0 + * @since 3.0.0 + */ + protected function flush_rewrite_rules() { + wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-categories-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-categories-controller.php new file mode 100644 index 0000000..40e954d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-categories-controller.php @@ -0,0 +1,271 @@ +term_id, 'display_type' ); + + // Get category order. + $menu_order = get_woocommerce_term_meta( $item->term_id, 'order' ); + + $data = array( + 'id' => (int) $item->term_id, + 'name' => $item->name, + 'slug' => $item->slug, + 'parent' => (int) $item->parent, + 'description' => $item->description, + 'display' => $display_type ? $display_type : 'default', + 'image' => null, + 'menu_order' => (int) $menu_order, + 'count' => (int) $item->count, + ); + + // Get category image. + $image_id = get_woocommerce_term_meta( $item->term_id, 'thumbnail_id' ); + if ( $image_id ) { + $attachment = get_post( $image_id ); + + $data['image'] = array( + 'id' => (int) $image_id, + 'date_created' => wc_rest_prepare_date_response( $attachment->post_date_gmt ), + 'date_modified' => wc_rest_prepare_date_response( $attachment->post_modified_gmt ), + 'src' => wp_get_attachment_url( $image_id ), + 'title' => get_the_title( $attachment ), + 'alt' => get_post_meta( $image_id, '_wp_attachment_image_alt', true ), + ); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item, $request ) ); + + /** + * Filter a term item returned from the API. + * + * Allows modification of the term data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original term object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); + } + + /** + * Update term meta fields. + * + * @param WP_Term $term Term object. + * @param WP_REST_Request $request Request instance. + * @return bool|WP_Error + */ + protected function update_term_meta_fields( $term, $request ) { + $id = (int) $term->term_id; + + if ( isset( $request['display'] ) ) { + update_woocommerce_term_meta( $id, 'display_type', 'default' === $request['display'] ? '' : $request['display'] ); + } + + if ( isset( $request['menu_order'] ) ) { + update_woocommerce_term_meta( $id, 'order', $request['menu_order'] ); + } + + if ( isset( $request['image'] ) ) { + if ( empty( $request['image']['id'] ) && ! empty( $request['image']['src'] ) ) { + $upload = wc_rest_upload_image_from_url( esc_url_raw( $request['image']['src'] ) ); + + if ( is_wp_error( $upload ) ) { + return $upload; + } + + $image_id = wc_rest_set_uploaded_image_as_attachment( $upload ); + } else { + $image_id = isset( $request['image']['id'] ) ? absint( $request['image']['id'] ) : 0; + } + + // Check if image_id is a valid image attachment before updating the term meta. + if ( $image_id && wp_attachment_is_image( $image_id ) ) { + update_woocommerce_term_meta( $id, 'thumbnail_id', $image_id ); + + // Set the image alt. + if ( ! empty( $request['image']['alt'] ) ) { + update_post_meta( $image_id, '_wp_attachment_image_alt', wc_clean( $request['image']['alt'] ) ); + } + + // Set the image title. + if ( ! empty( $request['image']['title'] ) ) { + wp_update_post( array( + 'ID' => $image_id, + 'post_title' => wc_clean( $request['image']['title'] ), + ) ); + } + } else { + delete_woocommerce_term_meta( $id, 'thumbnail_id' ); + } + } + + return true; + } + + /** + * Get the Category schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->taxonomy, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Category name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'parent' => array( + 'description' => __( 'The ID for the parent of the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'HTML description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wp_filter_post_kses', + ), + ), + 'display' => array( + 'description' => __( 'Category archive display type.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'default', + 'enum' => array( 'default', 'products', 'subcategories', 'both' ), + 'context' => array( 'view', 'edit' ), + ), + 'image' => array( + 'description' => __( 'Image data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'title' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'count' => array( + 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-reviews-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-reviews-controller.php new file mode 100644 index 0000000..37237ae --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-reviews-controller.php @@ -0,0 +1,578 @@ +/reviews. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Product Reviews Controller Class. + * + * @package WooCommerce/API + * @extends WC_REST_Controller + */ +class WC_REST_Product_Reviews_V1_Controller extends WC_REST_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'products/(?P[\d]+)/reviews'; + + /** + * Register the routes for product reviews. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the variation.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'review' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Review content.', 'woocommerce' ), + ), + 'name' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Name of the reviewer.', 'woocommerce' ), + ), + 'email' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Email of the reviewer.', 'woocommerce' ), + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'product_id' => array( + 'description' => __( 'Unique identifier for the variable product.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read webhook deliveries. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_post_permissions( 'product', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + $post = get_post( (int) $request['product_id'] ); + + if ( $post && ! wc_rest_check_post_permissions( 'product', 'read', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to create a new product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function create_item_permissions_check( $request ) { + $post = get_post( (int) $request['product_id'] ); + if ( $post && ! wc_rest_check_post_permissions( 'product', 'create', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check if a given request has access to update a product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function update_item_permissions_check( $request ) { + $post = get_post( (int) $request['product_id'] ); + if ( $post && ! wc_rest_check_post_permissions( 'product', 'edit', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Check if a given request has access to delete a product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function delete_item_permissions_check( $request ) { + $post = get_post( (int) $request['product_id'] ); + if ( $post && ! wc_rest_check_post_permissions( 'product', 'delete', $post->ID ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Get all reviews from a product. + * + * @param WP_REST_Request $request + * + * @return array|WP_Error + */ + public function get_items( $request ) { + $product_id = (int) $request['product_id']; + + if ( 'product' !== get_post_type( $product_id ) ) { + return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $reviews = get_approved_comments( $product_id ); + $data = array(); + foreach ( $reviews as $review_data ) { + $review = $this->prepare_item_for_response( $review_data, $request ); + $review = $this->prepare_response_for_collection( $review ); + $data[] = $review; + } + + return rest_ensure_response( $data ); + } + + /** + * Get a single product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $product_id = (int) $request['product_id']; + + if ( 'product' !== get_post_type( $product_id ) ) { + return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $review = get_comment( $id ); + + if ( empty( $id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $delivery = $this->prepare_item_for_response( $review, $request ); + $response = rest_ensure_response( $delivery ); + + return $response; + } + + + /** + * Create a product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + $product_id = (int) $request['product_id']; + + if ( 'product' !== get_post_type( $product_id ) ) { + return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $prepared_review = $this->prepare_item_for_database( $request ); + + /** + * Filter a product review (comment) before it is inserted via the REST API. + * + * Allows modification of the comment right before it is inserted via `wp_insert_comment`. + * + * @param array $prepared_review The prepared comment data for `wp_insert_comment`. + * @param WP_REST_Request $request Request used to insert the comment. + */ + $prepared_review = apply_filters( 'rest_pre_insert_product_review', $prepared_review, $request ); + + $product_review_id = wp_insert_comment( $prepared_review ); + if ( ! $product_review_id ) { + return new WP_Error( 'rest_product_review_failed_create', __( 'Creating product review failed.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + update_comment_meta( $product_review_id, 'rating', ( ! empty( $request['rating'] ) ? $request['rating'] : '0' ) ); + + $product_review = get_comment( $product_review_id ); + $this->update_additional_fields_for_object( $product_review, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Comment $product_review Inserted object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_product_review", $product_review, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $product_review, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $base = str_replace( '(?P[\d]+)', $product_id, $this->rest_base ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $product_review_id ) ) ); + + return $response; + } + + /** + * Update a single product review. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $product_review_id = (int) $request['id']; + $product_id = (int) $request['product_id']; + + if ( 'product' !== get_post_type( $product_id ) ) { + return new WP_Error( 'woocommerce_rest_product_invalid_id', __( 'Invalid product ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $review = get_comment( $product_review_id ); + + if ( empty( $product_review_id ) || empty( $review ) || intval( $review->comment_post_ID ) !== $product_id ) { + return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $prepared_review = $this->prepare_item_for_database( $request ); + + $updated = wp_update_comment( $prepared_review ); + if ( 0 === $updated ) { + return new WP_Error( 'rest_product_review_failed_edit', __( 'Updating product review failed.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + if ( ! empty( $request['rating'] ) ) { + update_comment_meta( $product_review_id, 'rating', $request['rating'] ); + } + + $product_review = get_comment( $product_review_id ); + $this->update_additional_fields_for_object( $product_review, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Comment $comment Inserted object. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_product_review", $product_review, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $product_review, $request ); + + return rest_ensure_response( $response ); + } + + /** + * Delete a product review. + * + * @param WP_REST_Request $request Full details about the request + * + * @return bool|WP_Error|WP_REST_Response + */ + public function delete_item( $request ) { + $product_review_id = absint( is_array( $request['id'] ) ? $request['id']['id'] : $request['id'] ); + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + $product_review = get_comment( $product_review_id ); + if ( empty( $product_review_id ) || empty( $product_review->comment_ID ) || empty( $product_review->comment_post_ID ) ) { + return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + /** + * Filter whether a product review is trashable. + * + * Return false to disable trash support for the product review. + * + * @param boolean $supports_trash Whether the object supports trashing. + * @param WP_Post $product_review The object being considered for trashing support. + */ + $supports_trash = apply_filters( 'rest_product_review_trashable', ( EMPTY_TRASH_DAYS > 0 ), $product_review ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $product_review, $request ); + + if ( $force ) { + $result = wp_delete_comment( $product_review_id, true ); + } else { + if ( ! $supports_trash ) { + return new WP_Error( 'rest_trash_not_supported', __( 'The product review does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + if ( 'trash' === $product_review->comment_approved ) { + return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.', 'woocommerce' ), array( 'status' => 410 ) ); + } + + $result = wp_trash_comment( $product_review->comment_ID ); + } + + if ( ! $result ) { + return new WP_Error( 'rest_cannot_delete', __( 'The product review cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + /** + * Fires after a product review is deleted via the REST API. + * + * @param object $product_review The deleted item. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'rest_delete_product_review', $product_review, $response, $request ); + + return $response; + } + + /** + * Prepare a single product review output for response. + * + * @param WP_Comment $review Product review object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $review, $request ) { + $data = array( + 'id' => (int) $review->comment_ID, + 'date_created' => wc_rest_prepare_date_response( $review->comment_date_gmt ), + 'review' => $review->comment_content, + 'rating' => (int) get_comment_meta( $review->comment_ID, 'rating', true ), + 'name' => $review->comment_author, + 'email' => $review->comment_author_email, + 'verified' => wc_review_is_from_verified_owner( $review->comment_ID ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $review, $request ) ); + + /** + * Filter product reviews object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WP_Comment $review Product review object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_product_review', $response, $review, $request ); + } + + /** + * Prepare a single product review to be inserted into the database. + * + * @param WP_REST_Request $request Request object. + * @return array|WP_Error $prepared_review + */ + protected function prepare_item_for_database( $request ) { + $prepared_review = array( 'comment_approved' => 1, 'comment_type' => 'review' ); + + if ( isset( $request['id'] ) ) { + $prepared_review['comment_ID'] = (int) $request['id']; + } + + if ( isset( $request['review'] ) ) { + $prepared_review['comment_content'] = $request['review']; + } + + if ( isset( $request['product_id'] ) ) { + $prepared_review['comment_post_ID'] = (int) $request['product_id']; + } + + if ( isset( $request['name'] ) ) { + $prepared_review['comment_author'] = $request['name']; + } + + if ( isset( $request['email'] ) ) { + $prepared_review['comment_author_email'] = $request['email']; + } + + if ( isset( $request['date_created'] ) ) { + $prepared_review['comment_date'] = $request['date_created']; + } + + if ( isset( $request['date_created_gmt'] ) ) { + $prepared_review['comment_date_gmt'] = $request['date_created_gmt']; + } + + return apply_filters( 'rest_preprocess_product_review', $prepared_review, $request ); + } + + /** + * Prepare links for the request. + * + * @param WP_Comment $review Product review object. + * @param WP_REST_Request $request Request object. + * @return array Links for the given product review. + */ + protected function prepare_links( $review, $request ) { + $product_id = (int) $request['product_id']; + $base = str_replace( '(?P[\d]+)', $product_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $review->comment_ID ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $product_id ) ), + ), + ); + + return $links; + } + + /** + * Get the Product Review's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'product_review', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'review' => array( + 'description' => __( 'The content of the review.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the review was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + ), + 'rating' => array( + 'description' => __( 'Review rating (0 to 5).', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Reviewer name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'email' => array( + 'description' => __( 'Reviewer email.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'verified' => array( + 'description' => __( 'Shows if the reviewer bought the product or not.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-shipping-classes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-shipping-classes-controller.php new file mode 100644 index 0000000..445c109 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-shipping-classes-controller.php @@ -0,0 +1,134 @@ + (int) $item->term_id, + 'name' => $item->name, + 'slug' => $item->slug, + 'description' => $item->description, + 'count' => (int) $item->count, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item, $request ) ); + + /** + * Filter a term item returned from the API. + * + * Allows modification of the term data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original term object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); + } + + /** + * Get the Shipping Class schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->taxonomy, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Shipping class name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'description' => array( + 'description' => __( 'HTML description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wp_filter_post_kses', + ), + ), + 'count' => array( + 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-tags-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-tags-controller.php new file mode 100644 index 0000000..accdfae --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-product-tags-controller.php @@ -0,0 +1,134 @@ + (int) $item->term_id, + 'name' => $item->name, + 'slug' => $item->slug, + 'description' => $item->description, + 'count' => (int) $item->count, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $item, $request ) ); + + /** + * Filter a term item returned from the API. + * + * Allows modification of the term data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $item The original term object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request ); + } + + /** + * Get the Tag's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->taxonomy, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Tag name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_title', + ), + ), + 'description' => array( + 'description' => __( 'HTML description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wp_filter_post_kses', + ), + ), + 'count' => array( + 'description' => __( 'Number of published products for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-products-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-products-controller.php new file mode 100644 index 0000000..137ebca --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-products-controller.php @@ -0,0 +1,2638 @@ +post_type}_query", array( $this, 'query_args' ), 10, 2 ); + add_action( "woocommerce_rest_insert_{$this->post_type}", array( $this, 'clear_transients' ) ); + } + + /** + * Register the routes for products. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), + 'type' => 'boolean', + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Get post types. + * + * @return array + */ + protected function get_post_types() { + return array( 'product', 'product_variation' ); + } + + /** + * Query args. + * + * @param array $args Request args. + * @param WP_REST_Request $request Request data. + * @return array + */ + public function query_args( $args, $request ) { + // Set post_status. + $args['post_status'] = $request['status']; + + // Taxonomy query to filter products by type, category, + // tag, shipping class, and attribute. + $tax_query = array(); + + // Map between taxonomy name and arg's key. + $taxonomies = array( + 'product_cat' => 'category', + 'product_tag' => 'tag', + 'product_shipping_class' => 'shipping_class', + ); + + // Set tax_query for each passed arg. + foreach ( $taxonomies as $taxonomy => $key ) { + if ( ! empty( $request[ $key ] ) && is_array( $request[ $key ] ) ) { + $request[ $key ] = array_filter( $request[ $key ] ); + } + + if ( ! empty( $request[ $key ] ) ) { + $tax_query[] = array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'terms' => $request[ $key ], + ); + } + } + + // Filter product type by slug. + if ( ! empty( $request['type'] ) ) { + $tax_query[] = array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $request['type'], + ); + } + + // Filter by attribute and term. + if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) { + if ( in_array( $request['attribute'], wc_get_attribute_taxonomy_names(), true ) ) { + $tax_query[] = array( + 'taxonomy' => $request['attribute'], + 'field' => 'term_id', + 'terms' => $request['attribute_term'], + ); + } + } + + if ( ! empty( $tax_query ) ) { + $args['tax_query'] = $tax_query; + } + + // Filter by sku. + if ( ! empty( $request['sku'] ) ) { + $skus = explode( ',', $request['sku'] ); + // Include the current string as a SKU too. + if ( 1 < count( $skus ) ) { + $skus[] = $request['sku']; + } + + $args['meta_query'] = $this->add_meta_query( $args, array( + 'key' => '_sku', + 'value' => $skus, + 'compare' => 'IN', + ) ); + } + + // Apply all WP_Query filters again. + if ( is_array( $request['filter'] ) ) { + $args = array_merge( $args, $request['filter'] ); + unset( $args['filter'] ); + } + + // Force the post_type argument, since it's not a user input variable. + if ( ! empty( $request['sku'] ) ) { + $args['post_type'] = array( 'product', 'product_variation' ); + } else { + $args['post_type'] = $this->post_type; + } + + return $args; + } + + /** + * Get the downloads for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_downloads( $product ) { + $downloads = array(); + + if ( $product->is_downloadable() ) { + foreach ( $product->get_downloads() as $file_id => $file ) { + $downloads[] = array( + 'id' => $file_id, // MD5 hash. + 'name' => $file['name'], + 'file' => $file['file'], + ); + } + } + + return $downloads; + } + + /** + * Get taxonomy terms. + * + * @param WC_Product $product Product instance. + * @param string $taxonomy Taxonomy slug. + * @return array + */ + protected function get_taxonomy_terms( $product, $taxonomy = 'cat' ) { + $terms = array(); + + foreach ( wc_get_object_terms( $product->get_id(), 'product_' . $taxonomy ) as $term ) { + $terms[] = array( + 'id' => $term->term_id, + 'name' => $term->name, + 'slug' => $term->slug, + ); + } + + return $terms; + } + + /** + * Get the images for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_images( $product ) { + $images = array(); + $attachment_ids = array(); + + // Add featured image. + if ( has_post_thumbnail( $product->get_id() ) ) { + $attachment_ids[] = $product->get_image_id(); + } + + // Add gallery images. + $attachment_ids = array_merge( $attachment_ids, $product->get_gallery_image_ids() ); + + // Build image data. + foreach ( $attachment_ids as $position => $attachment_id ) { + $attachment_post = get_post( $attachment_id ); + if ( is_null( $attachment_post ) ) { + continue; + } + + $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ); + if ( ! is_array( $attachment ) ) { + continue; + } + + $images[] = array( + 'id' => (int) $attachment_id, + 'date_created' => wc_rest_prepare_date_response( $attachment_post->post_date_gmt ), + 'date_modified' => wc_rest_prepare_date_response( $attachment_post->post_modified_gmt ), + 'src' => current( $attachment ), + 'name' => get_the_title( $attachment_id ), + 'alt' => get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ), + 'position' => (int) $position, + ); + } + + // Set a placeholder image if the product has no images set. + if ( empty( $images ) ) { + $images[] = array( + 'id' => 0, + 'date_created' => wc_rest_prepare_date_response( current_time( 'mysql' ) ), // Default to now. + 'date_modified' => wc_rest_prepare_date_response( current_time( 'mysql' ) ), + 'src' => wc_placeholder_img_src(), + 'name' => __( 'Placeholder', 'woocommerce' ), + 'alt' => __( 'Placeholder', 'woocommerce' ), + 'position' => 0, + ); + } + + return $images; + } + + /** + * Get attribute taxonomy label. + * + * @param string $name Taxonomy name. + * @return string + */ + protected function get_attribute_taxonomy_label( $name ) { + $tax = get_taxonomy( $name ); + $labels = get_taxonomy_labels( $tax ); + + return $labels->singular_name; + } + + /** + * Get default attributes. + * + * @param WC_Product $product Product instance. + * @return array + */ + protected function get_default_attributes( $product ) { + $default = array(); + + if ( $product->is_type( 'variable' ) ) { + foreach ( array_filter( (array) $product->get_default_attributes(), 'strlen' ) as $key => $value ) { + if ( 0 === strpos( $key, 'pa_' ) ) { + $default[] = array( + 'id' => wc_attribute_taxonomy_id_by_name( $key ), + 'name' => $this->get_attribute_taxonomy_label( $key ), + 'option' => $value, + ); + } else { + $default[] = array( + 'id' => 0, + 'name' => str_replace( 'pa_', '', $key ), + 'option' => $value, + ); + } + } + } + + return $default; + } + + /** + * Get attribute options. + * + * @param int $product_id Product ID. + * @param array $attribute Attribute data. + * @return array + */ + protected function get_attribute_options( $product_id, $attribute ) { + if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) { + return wc_get_product_terms( $product_id, $attribute['name'], array( 'fields' => 'names' ) ); + } elseif ( isset( $attribute['value'] ) ) { + return array_map( 'trim', explode( '|', $attribute['value'] ) ); + } + + return array(); + } + + /** + * Get the attributes for a product or product variation. + * + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array + */ + protected function get_attributes( $product ) { + $attributes = array(); + + if ( $product->is_type( 'variation' ) ) { + // Variation attributes. + foreach ( $product->get_variation_attributes() as $attribute_name => $attribute ) { + $name = str_replace( 'attribute_', '', $attribute_name ); + + if ( ! $attribute ) { + continue; + } + + // Taxonomy-based attributes are prefixed with `pa_`, otherwise simply `attribute_`. + if ( 0 === strpos( $attribute_name, 'attribute_pa_' ) ) { + $option_term = get_term_by( 'slug', $attribute, $name ); + $attributes[] = array( + 'id' => wc_attribute_taxonomy_id_by_name( $name ), + 'name' => $this->get_attribute_taxonomy_label( $name ), + 'option' => $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $attribute, + ); + } else { + $attributes[] = array( + 'id' => 0, + 'name' => $name, + 'option' => $attribute, + ); + } + } + } else { + foreach ( $product->get_attributes() as $attribute ) { + if ( $attribute['is_taxonomy'] ) { + $attributes[] = array( + 'id' => wc_attribute_taxonomy_id_by_name( $attribute['name'] ), + 'name' => $this->get_attribute_taxonomy_label( $attribute['name'] ), + 'position' => (int) $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } else { + $attributes[] = array( + 'id' => 0, + 'name' => $attribute['name'], + 'position' => (int) $attribute['position'], + 'visible' => (bool) $attribute['is_visible'], + 'variation' => (bool) $attribute['is_variation'], + 'options' => $this->get_attribute_options( $product->get_id(), $attribute ), + ); + } + } + } + + return $attributes; + } + + /** + * Get product menu order. + * + * @deprecated 3.0.0 + * @param WC_Product $product Product instance. + * @return int + */ + protected function get_product_menu_order( $product ) { + return $product->get_menu_order(); + } + + /** + * Get product data. + * + * @param WC_Product $product Product instance. + * @return array + */ + protected function get_product_data( $product ) { + $data = array( + 'id' => $product->get_id(), + 'name' => $product->get_name(), + 'slug' => $product->get_slug(), + 'permalink' => $product->get_permalink(), + 'date_created' => wc_rest_prepare_date_response( $product->get_date_created() ), + 'date_modified' => wc_rest_prepare_date_response( $product->get_date_modified() ), + 'type' => $product->get_type(), + 'status' => $product->get_status(), + 'featured' => $product->is_featured(), + 'catalog_visibility' => $product->get_catalog_visibility(), + 'description' => wpautop( do_shortcode( $product->get_description() ) ), + 'short_description' => apply_filters( 'woocommerce_short_description', $product->get_short_description() ), + 'sku' => $product->get_sku(), + 'price' => $product->get_price(), + 'regular_price' => $product->get_regular_price(), + 'sale_price' => $product->get_sale_price() ? $product->get_sale_price() : '', + 'date_on_sale_from' => $product->get_date_on_sale_from() ? date( 'Y-m-d', $product->get_date_on_sale_from()->getTimestamp() ) : '', + 'date_on_sale_to' => $product->get_date_on_sale_to() ? date( 'Y-m-d', $product->get_date_on_sale_to()->getTimestamp() ) : '', + 'price_html' => $product->get_price_html(), + 'on_sale' => $product->is_on_sale(), + 'purchasable' => $product->is_purchasable(), + 'total_sales' => $product->get_total_sales(), + 'virtual' => $product->is_virtual(), + 'downloadable' => $product->is_downloadable(), + 'downloads' => $this->get_downloads( $product ), + 'download_limit' => $product->get_download_limit(), + 'download_expiry' => $product->get_download_expiry(), + 'download_type' => 'standard', + 'external_url' => $product->is_type( 'external' ) ? $product->get_product_url() : '', + 'button_text' => $product->is_type( 'external' ) ? $product->get_button_text() : '', + 'tax_status' => $product->get_tax_status(), + 'tax_class' => $product->get_tax_class(), + 'manage_stock' => $product->managing_stock(), + 'stock_quantity' => $product->get_stock_quantity(), + 'in_stock' => $product->is_in_stock(), + 'backorders' => $product->get_backorders(), + 'backorders_allowed' => $product->backorders_allowed(), + 'backordered' => $product->is_on_backorder(), + 'sold_individually' => $product->is_sold_individually(), + 'weight' => $product->get_weight(), + 'dimensions' => array( + 'length' => $product->get_length(), + 'width' => $product->get_width(), + 'height' => $product->get_height(), + ), + 'shipping_required' => $product->needs_shipping(), + 'shipping_taxable' => $product->is_shipping_taxable(), + 'shipping_class' => $product->get_shipping_class(), + 'shipping_class_id' => $product->get_shipping_class_id(), + 'reviews_allowed' => $product->get_reviews_allowed(), + 'average_rating' => wc_format_decimal( $product->get_average_rating(), 2 ), + 'rating_count' => $product->get_rating_count(), + 'related_ids' => array_map( 'absint', array_values( wc_get_related_products( $product->get_id() ) ) ), + 'upsell_ids' => array_map( 'absint', $product->get_upsell_ids() ), + 'cross_sell_ids' => array_map( 'absint', $product->get_cross_sell_ids() ), + 'parent_id' => $product->get_parent_id(), + 'purchase_note' => wpautop( do_shortcode( wp_kses_post( $product->get_purchase_note() ) ) ), + 'categories' => $this->get_taxonomy_terms( $product ), + 'tags' => $this->get_taxonomy_terms( $product, 'tag' ), + 'images' => $this->get_images( $product ), + 'attributes' => $this->get_attributes( $product ), + 'default_attributes' => $this->get_default_attributes( $product ), + 'variations' => array(), + 'grouped_products' => array(), + 'menu_order' => $product->get_menu_order(), + ); + + return $data; + } + + /** + * Get an individual variation's data. + * + * @param WC_Product $product Product instance. + * @return array + */ + protected function get_variation_data( $product ) { + $variations = array(); + + foreach ( $product->get_children() as $child_id ) { + $variation = wc_get_product( $child_id ); + if ( ! $variation || ! $variation->exists() ) { + continue; + } + + $variations[] = array( + 'id' => $variation->get_id(), + 'date_created' => wc_rest_prepare_date_response( $variation->get_date_created() ), + 'date_modified' => wc_rest_prepare_date_response( $variation->get_date_modified() ), + 'permalink' => $variation->get_permalink(), + 'sku' => $variation->get_sku(), + 'price' => $variation->get_price(), + 'regular_price' => $variation->get_regular_price(), + 'sale_price' => $variation->get_sale_price(), + 'date_on_sale_from' => $variation->get_date_on_sale_from() ? date( 'Y-m-d', $variation->get_date_on_sale_from()->getTimestamp() ) : '', + 'date_on_sale_to' => $variation->get_date_on_sale_to() ? date( 'Y-m-d', $variation->get_date_on_sale_to()->getTimestamp() ) : '', + 'on_sale' => $variation->is_on_sale(), + 'purchasable' => $variation->is_purchasable(), + 'visible' => $variation->is_visible(), + 'virtual' => $variation->is_virtual(), + 'downloadable' => $variation->is_downloadable(), + 'downloads' => $this->get_downloads( $variation ), + 'download_limit' => '' !== $variation->get_download_limit() ? (int) $variation->get_download_limit() : -1, + 'download_expiry' => '' !== $variation->get_download_expiry() ? (int) $variation->get_download_expiry() : -1, + 'tax_status' => $variation->get_tax_status(), + 'tax_class' => $variation->get_tax_class(), + 'manage_stock' => $variation->managing_stock(), + 'stock_quantity' => $variation->get_stock_quantity(), + 'in_stock' => $variation->is_in_stock(), + 'backorders' => $variation->get_backorders(), + 'backorders_allowed' => $variation->backorders_allowed(), + 'backordered' => $variation->is_on_backorder(), + 'weight' => $variation->get_weight(), + 'dimensions' => array( + 'length' => $variation->get_length(), + 'width' => $variation->get_width(), + 'height' => $variation->get_height(), + ), + 'shipping_class' => $variation->get_shipping_class(), + 'shipping_class_id' => $variation->get_shipping_class_id(), + 'image' => $this->get_images( $variation ), + 'attributes' => $this->get_attributes( $variation ), + ); + } + + return $variations; + } + + /** + * Prepare a single product output for response. + * + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response + */ + public function prepare_item_for_response( $post, $request ) { + $product = wc_get_product( $post ); + $data = $this->get_product_data( $product ); + + // Add variations to variable products. + if ( $product->is_type( 'variable' ) && $product->has_child() ) { + $data['variations'] = $this->get_variation_data( $product ); + } + + // Add grouped products data. + if ( $product->is_type( 'grouped' ) && $product->has_child() ) { + $data['grouped_products'] = $product->get_children(); + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $product, $request ) ); + + /** + * Filter the data for a response. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for the response. + * + * @param WP_REST_Response $response The response object. + * @param WP_Post $post Post object. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $post, $request ); + } + + /** + * Prepare links for the request. + * + * @param WC_Product $product Product object. + * @param WP_REST_Request $request Request object. + * @return array Links for the given product. + */ + protected function prepare_links( $product, $request ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $product->get_id() ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + if ( $product->get_parent_id() ) { + $links['up'] = array( + 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $product->get_parent_id() ) ), + ); + } + + return $links; + } + + /** + * Prepare a single product for create or update. + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|stdClass $data Post object. + */ + protected function prepare_item_for_database( $request ) { + $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; + + // Type is the most important part here because we need to be using the correct class and methods. + if ( isset( $request['type'] ) ) { + $classname = WC_Product_Factory::get_classname_from_product_type( $request['type'] ); + + if ( ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + + $product = new $classname( $id ); + } elseif ( isset( $request['id'] ) ) { + $product = wc_get_product( $id ); + } else { + $product = new WC_Product_Simple(); + } + + // Post title. + if ( isset( $request['name'] ) ) { + $product->set_name( wp_filter_post_kses( $request['name'] ) ); + } + + // Post content. + if ( isset( $request['description'] ) ) { + $product->set_description( wp_filter_post_kses( $request['description'] ) ); + } + + // Post excerpt. + if ( isset( $request['short_description'] ) ) { + $product->set_short_description( wp_filter_post_kses( $request['short_description'] ) ); + } + + // Post status. + if ( isset( $request['status'] ) ) { + $product->set_status( get_post_status_object( $request['status'] ) ? $request['status'] : 'draft' ); + } + + // Post slug. + if ( isset( $request['slug'] ) ) { + $product->set_slug( $request['slug'] ); + } + + // Menu order. + if ( isset( $request['menu_order'] ) ) { + $product->set_menu_order( $request['menu_order'] ); + } + + // Comment status. + if ( isset( $request['reviews_allowed'] ) ) { + $product->set_reviews_allowed( $request['reviews_allowed'] ); + } + + /** + * Filter the query_vars used in `get_items` for the constructed query. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for insertion. + * + * @param WC_Product $product An object representing a single item prepared + * for inserting or updating the database. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $product, $request ); + } + + /** + * Create a single product. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + $product_id = 0; + + try { + $product_id = $this->save_product( $request ); + $post = get_post( $product_id ); + $this->update_additional_fields_for_object( $post, $request ); + $this->update_post_meta_fields( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( 'woocommerce_rest_insert_product', $post, $request, true ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $post->ID ) ) ); + + return $response; + } catch ( WC_Data_Exception $e ) { + $this->delete_post( $product_id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + $this->delete_post( $product_id ); + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Update a single product. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $post_id = (int) $request['id']; + + if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + try { + $product_id = $this->save_product( $request ); + $post = get_post( $product_id ); + $this->update_additional_fields_for_object( $post, $request ); + $this->update_post_meta_fields( $post, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating item, false when updating. + */ + do_action( 'woocommerce_rest_insert_product', $post, $request, false ); + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + + return rest_ensure_response( $response ); + } catch ( WC_Data_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() ); + } catch ( WC_REST_Exception $e ) { + return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Saves a product to the database. + * + * @param WP_REST_Request $request Full details about the request. + * @return int + */ + public function save_product( $request ) { + $product = $this->prepare_item_for_database( $request ); + return $product->save(); + } + + /** + * Save product images. + * + * @deprecated 3.0.0 + * @param int $product_id + * @param array $images + * @throws WC_REST_Exception + */ + protected function save_product_images( $product_id, $images ) { + $product = wc_get_product( $product_id ); + + return set_product_images( $product, $images ); + } + + /** + * Set product images. + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param array $images Images data. + * @return WC_Product + */ + protected function set_product_images( $product, $images ) { + if ( is_array( $images ) ) { + $gallery = array(); + + foreach ( $images as $image ) { + $attachment_id = isset( $image['id'] ) ? absint( $image['id'] ) : 0; + + if ( 0 === $attachment_id && isset( $image['src'] ) ) { + $upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) ); + + if ( is_wp_error( $upload ) ) { + if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product->get_id(), $images ) ) { + throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 ); + } else { + continue; + } + } + + $attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product->get_id() ); + } + + if ( ! wp_attachment_is_image( $attachment_id ) ) { + throw new WC_REST_Exception( 'woocommerce_product_invalid_image_id', sprintf( __( '#%s is an invalid image ID.', 'woocommerce' ), $attachment_id ), 400 ); + } + + if ( isset( $image['position'] ) && 0 === absint( $image['position'] ) ) { + $product->set_image_id( $attachment_id ); + } else { + $gallery[] = $attachment_id; + } + + // Set the image alt if present. + if ( ! empty( $image['alt'] ) ) { + update_post_meta( $attachment_id, '_wp_attachment_image_alt', wc_clean( $image['alt'] ) ); + } + + // Set the image name if present. + if ( ! empty( $image['name'] ) ) { + wp_update_post( array( 'ID' => $attachment_id, 'post_title' => $image['name'] ) ); + } + } + + if ( ! empty( $gallery ) ) { + $product->set_gallery_image_ids( $gallery ); + } + } else { + $product->set_image_id( '' ); + $product->set_gallery_image_ids( array() ); + } + + return $product; + } + + /** + * Save product shipping data. + * + * @param WC_Product $product Product instance. + * @param array $data Shipping data. + * @return WC_Product + */ + protected function save_product_shipping_data( $product, $data ) { + // Virtual. + if ( isset( $data['virtual'] ) && true === $data['virtual'] ) { + $product->set_weight( '' ); + $product->set_height( '' ); + $product->set_length( '' ); + $product->set_width( '' ); + } else { + if ( isset( $data['weight'] ) ) { + $product->set_weight( $data['weight'] ); + } + + // Height. + if ( isset( $data['dimensions']['height'] ) ) { + $product->set_height( $data['dimensions']['height'] ); + } + + // Width. + if ( isset( $data['dimensions']['width'] ) ) { + $product->set_width( $data['dimensions']['width'] ); + } + + // Length. + if ( isset( $data['dimensions']['length'] ) ) { + $product->set_length( $data['dimensions']['length'] ); + } + } + + // Shipping class. + if ( isset( $data['shipping_class'] ) ) { + $data_store = $product->get_data_store(); + $shipping_class_id = $data_store->get_shipping_class_id_by_slug( wc_clean( $data['shipping_class'] ) ); + $product->set_shipping_class_id( $shipping_class_id ); + } + + return $product; + } + + /** + * Save downloadable files. + * + * @param WC_Product $product Product instance. + * @param array $downloads Downloads data. + * @param int $deprecated Deprecated since 3.0. + * @return WC_Product + */ + protected function save_downloadable_files( $product, $downloads, $deprecated = 0 ) { + if ( $deprecated ) { + wc_deprecated_argument( 'variation_id', '3.0', 'save_downloadable_files() not requires a variation_id anymore.' ); + } + + $files = array(); + foreach ( $downloads as $key => $file ) { + if ( empty( $file['file'] ) ) { + continue; + } + + $download = new WC_Product_Download(); + $download->set_id( $file['id'] ? $file['id'] : wp_generate_uuid4() ); + $download->set_name( $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['file'] ) ); + $download->set_file( apply_filters( 'woocommerce_file_download_path', $file['file'], $product, $key ) ); + $files[] = $download; + } + $product->set_downloads( $files ); + + return $product; + } + + /** + * Save taxonomy terms. + * + * @param WC_Product $product Product instance. + * @param array $terms Terms data. + * @param string $taxonomy Taxonomy name. + * @return WC_Product + */ + protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) { + $term_ids = wp_list_pluck( $terms, 'id' ); + + if ( 'cat' === $taxonomy ) { + $product->set_category_ids( $term_ids ); + } elseif ( 'tag' === $taxonomy ) { + $product->set_tag_ids( $term_ids ); + } + + return $product; + } + + /** + * Save default attributes. + * + * @since 3.0.0 + * + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return WC_Product + */ + protected function save_default_attributes( $product, $request ) { + if ( isset( $request['default_attributes'] ) && is_array( $request['default_attributes'] ) ) { + $attributes = $product->get_attributes(); + $default_attributes = array(); + + foreach ( $request['default_attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( isset( $attributes[ $attribute_name ] ) ) { + $_attribute = $attributes[ $attribute_name ]; + + if ( $_attribute['is_variation'] ) { + $value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + + if ( ! empty( $_attribute['is_taxonomy'] ) ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $value, $attribute_name ); + + if ( $term && ! is_wp_error( $term ) ) { + $value = $term->slug; + } else { + $value = sanitize_title( $value ); + } + } + + if ( $value ) { + $default_attributes[ $attribute_name ] = $value; + } + } + } + } + + $product->set_default_attributes( $default_attributes ); + } + + return $product; + } + + /** + * Save product meta. + * + * @deprecated 3.0.0 + * @param WC_Product $product + * @param WP_REST_Request $request + * @return bool + * @throws WC_REST_Exception + */ + protected function save_product_meta( $product, $request ) { + $product = $this->set_product_meta( $product, $request ); + $product->save(); + + return true; + } + + /** + * Set product meta. + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return WC_Product + */ + protected function set_product_meta( $product, $request ) { + // Virtual. + if ( isset( $request['virtual'] ) ) { + $product->set_virtual( $request['virtual'] ); + } + + // Tax status. + if ( isset( $request['tax_status'] ) ) { + $product->set_tax_status( $request['tax_status'] ); + } + + // Tax Class. + if ( isset( $request['tax_class'] ) ) { + $product->set_tax_class( $request['tax_class'] ); + } + + // Catalog Visibility. + if ( isset( $request['catalog_visibility'] ) ) { + $product->set_catalog_visibility( $request['catalog_visibility'] ); + } + + // Purchase Note. + if ( isset( $request['purchase_note'] ) ) { + $product->set_purchase_note( wp_kses_post( wp_unslash( $request['purchase_note'] ) ) ); + } + + // Featured Product. + if ( isset( $request['featured'] ) ) { + $product->set_featured( $request['featured'] ); + } + + // Shipping data. + $product = $this->save_product_shipping_data( $product, $request ); + + // SKU. + if ( isset( $request['sku'] ) ) { + $product->set_sku( wc_clean( $request['sku'] ) ); + } + + // Attributes. + if ( isset( $request['attributes'] ) ) { + $attributes = array(); + + foreach ( $request['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = wc_clean( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( $attribute_id ) { + + if ( isset( $attribute['options'] ) ) { + $options = $attribute['options']; + + if ( ! is_array( $attribute['options'] ) ) { + // Text based attributes - Posted values are term names. + $options = explode( WC_DELIMITER, $options ); + } + + $values = array_map( 'wc_sanitize_term_text_based', $options ); + $values = array_filter( $values, 'strlen' ); + } else { + $values = array(); + } + + if ( ! empty( $values ) ) { + // Add attribute to array, but don't set values. + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['options'] ) ) { + // Custom attribute - Add attribute to array and set the values. + if ( is_array( $attribute['options'] ) ) { + $values = $attribute['options']; + } else { + $values = explode( WC_DELIMITER, $attribute['options'] ); + } + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $values ); + $attribute_object->set_position( isset( $attribute['position'] ) ? (string) absint( $attribute['position'] ) : '0' ); + $attribute_object->set_visible( ( isset( $attribute['visible'] ) && $attribute['visible'] ) ? 1 : 0 ); + $attribute_object->set_variation( ( isset( $attribute['variation'] ) && $attribute['variation'] ) ? 1 : 0 ); + $attributes[] = $attribute_object; + } + } + $product->set_attributes( $attributes ); + } + + // Sales and prices. + if ( in_array( $product->get_type(), array( 'variable', 'grouped' ), true ) ) { + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + $product->set_date_on_sale_to( '' ); + $product->set_date_on_sale_from( '' ); + $product->set_price( '' ); + } else { + // Regular Price. + if ( isset( $request['regular_price'] ) ) { + $product->set_regular_price( $request['regular_price'] ); + } + + // Sale Price. + if ( isset( $request['sale_price'] ) ) { + $product->set_sale_price( $request['sale_price'] ); + } + + if ( isset( $request['date_on_sale_from'] ) ) { + $product->set_date_on_sale_from( $request['date_on_sale_from'] ); + } + + if ( isset( $request['date_on_sale_to'] ) ) { + $product->set_date_on_sale_to( $request['date_on_sale_to'] ); + } + } + + // Product parent ID for groups. + if ( isset( $request['parent_id'] ) ) { + $product->set_parent_id( $request['parent_id'] ); + } + + // Sold individually. + if ( isset( $request['sold_individually'] ) ) { + $product->set_sold_individually( $request['sold_individually'] ); + } + + // Stock status. + if ( isset( $request['in_stock'] ) ) { + $stock_status = true === $request['in_stock'] ? 'instock' : 'outofstock'; + } else { + $stock_status = $product->get_stock_status(); + } + + // Stock data. + if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) { + // Manage stock. + if ( isset( $request['manage_stock'] ) ) { + $product->set_manage_stock( $request['manage_stock'] ); + } + + // Backorders. + if ( isset( $request['backorders'] ) ) { + $product->set_backorders( $request['backorders'] ); + } + + if ( $product->is_type( 'grouped' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } elseif ( $product->is_type( 'external' ) ) { + $product->set_manage_stock( 'no' ); + $product->set_backorders( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( 'instock' ); + } elseif ( $product->get_manage_stock() ) { + // Stock status is always determined by children so sync later. + if ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Stock quantity. + if ( isset( $request['stock_quantity'] ) ) { + $product->set_stock_quantity( wc_stock_amount( $request['stock_quantity'] ) ); + } elseif ( isset( $request['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $product->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $request['inventory_delta'] ); + $product->set_stock_quantity( wc_stock_amount( $stock_quantity ) ); + } + } else { + // Don't manage stock. + $product->set_manage_stock( 'no' ); + $product->set_stock_quantity( '' ); + $product->set_stock_status( $stock_status ); + } + } elseif ( ! $product->is_type( 'variable' ) ) { + $product->set_stock_status( $stock_status ); + } + + // Upsells. + if ( isset( $request['upsell_ids'] ) ) { + $upsells = array(); + $ids = $request['upsell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $upsells[] = $id; + } + } + } + + $product->set_upsell_ids( $upsells ); + } + + // Cross sells. + if ( isset( $request['cross_sell_ids'] ) ) { + $crosssells = array(); + $ids = $request['cross_sell_ids']; + + if ( ! empty( $ids ) ) { + foreach ( $ids as $id ) { + if ( $id && $id > 0 ) { + $crosssells[] = $id; + } + } + } + + $product->set_cross_sell_ids( $crosssells ); + } + + // Product categories. + if ( isset( $request['categories'] ) && is_array( $request['categories'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['categories'] ); + } + + // Product tags. + if ( isset( $request['tags'] ) && is_array( $request['tags'] ) ) { + $product = $this->save_taxonomy_terms( $product, $request['tags'], 'tag' ); + } + + // Downloadable. + if ( isset( $request['downloadable'] ) ) { + $product->set_downloadable( $request['downloadable'] ); + } + + // Downloadable options. + if ( $product->get_downloadable() ) { + + // Downloadable files. + if ( isset( $request['downloads'] ) && is_array( $request['downloads'] ) ) { + $product = $this->save_downloadable_files( $product, $request['downloads'] ); + } + + // Download limit. + if ( isset( $request['download_limit'] ) ) { + $product->set_download_limit( $request['download_limit'] ); + } + + // Download expiry. + if ( isset( $request['download_expiry'] ) ) { + $product->set_download_expiry( $request['download_expiry'] ); + } + } + + // Product url and button text for external products. + if ( $product->is_type( 'external' ) ) { + if ( isset( $request['external_url'] ) ) { + $product->set_product_url( $request['external_url'] ); + } + + if ( isset( $request['button_text'] ) ) { + $product->set_button_text( $request['button_text'] ); + } + } + + // Save default attributes for variable products. + if ( $product->is_type( 'variable' ) ) { + $product = $this->save_default_attributes( $product, $request ); + } + + return $product; + } + + /** + * Save variations. + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param WP_REST_Request $request Request data. + * @return bool + */ + protected function save_variations_data( $product, $request ) { + foreach ( $request['variations'] as $menu_order => $data ) { + $variation = new WC_Product_Variation( isset( $data['id'] ) ? absint( $data['id'] ) : 0 ); + + // Create initial name and status. + if ( ! $variation->get_slug() ) { + /* translators: 1: variation id 2: product name */ + $variation->set_name( sprintf( __( 'Variation #%1$s of %2$s', 'woocommerce' ), $variation->get_id(), $product->get_name() ) ); + $variation->set_status( isset( $data['visible'] ) && false === $data['visible'] ? 'private' : 'publish' ); + } + + // Parent ID. + $variation->set_parent_id( $product->get_id() ); + + // Menu order. + $variation->set_menu_order( $menu_order ); + + // Status. + if ( isset( $data['visible'] ) ) { + $variation->set_status( false === $data['visible'] ? 'private' : 'publish' ); + } + + // SKU. + if ( isset( $data['sku'] ) ) { + $variation->set_sku( wc_clean( $data['sku'] ) ); + } + + // Thumbnail. + if ( isset( $data['image'] ) && is_array( $data['image'] ) ) { + $image = $data['image']; + $image = current( $image ); + if ( is_array( $image ) ) { + $image['position'] = 0; + } + + $variation = $this->set_product_images( $variation, array( $image ) ); + } + + // Virtual variation. + if ( isset( $data['virtual'] ) ) { + $variation->set_virtual( $data['virtual'] ); + } + + // Downloadable variation. + if ( isset( $data['downloadable'] ) ) { + $variation->set_downloadable( $data['downloadable'] ); + } + + // Downloads. + if ( $variation->get_downloadable() ) { + // Downloadable files. + if ( isset( $data['downloads'] ) && is_array( $data['downloads'] ) ) { + $variation = $this->save_downloadable_files( $variation, $data['downloads'] ); + } + + // Download limit. + if ( isset( $data['download_limit'] ) ) { + $variation->set_download_limit( $data['download_limit'] ); + } + + // Download expiry. + if ( isset( $data['download_expiry'] ) ) { + $variation->set_download_expiry( $data['download_expiry'] ); + } + } + + // Shipping data. + $variation = $this->save_product_shipping_data( $variation, $data ); + + // Stock handling. + if ( isset( $data['manage_stock'] ) ) { + $variation->set_manage_stock( $data['manage_stock'] ); + } + + if ( isset( $data['in_stock'] ) ) { + $variation->set_stock_status( true === $data['in_stock'] ? 'instock' : 'outofstock' ); + } + + if ( isset( $data['backorders'] ) ) { + $variation->set_backorders( $data['backorders'] ); + } + + if ( $variation->get_manage_stock() ) { + if ( isset( $data['stock_quantity'] ) ) { + $variation->set_stock_quantity( $data['stock_quantity'] ); + } elseif ( isset( $data['inventory_delta'] ) ) { + $stock_quantity = wc_stock_amount( $variation->get_stock_quantity() ); + $stock_quantity += wc_stock_amount( $data['inventory_delta'] ); + $variation->set_stock_quantity( $stock_quantity ); + } + } else { + $variation->set_backorders( 'no' ); + $variation->set_stock_quantity( '' ); + } + + // Regular Price. + if ( isset( $data['regular_price'] ) ) { + $variation->set_regular_price( $data['regular_price'] ); + } + + // Sale Price. + if ( isset( $data['sale_price'] ) ) { + $variation->set_sale_price( $data['sale_price'] ); + } + + if ( isset( $data['date_on_sale_from'] ) ) { + $variation->set_date_on_sale_from( $data['date_on_sale_from'] ); + } + + if ( isset( $data['date_on_sale_to'] ) ) { + $variation->set_date_on_sale_to( $data['date_on_sale_to'] ); + } + + // Tax class. + if ( isset( $data['tax_class'] ) ) { + $variation->set_tax_class( $data['tax_class'] ); + } + + // Description. + if ( isset( $data['description'] ) ) { + $variation->set_description( wp_kses_post( $data['description'] ) ); + } + + // Update taxonomies. + if ( isset( $data['attributes'] ) ) { + $attributes = array(); + $parent_attributes = $product->get_attributes(); + + foreach ( $data['attributes'] as $attribute ) { + $attribute_id = 0; + $attribute_name = ''; + + // Check ID for global attributes or name for product attributes. + if ( ! empty( $attribute['id'] ) ) { + $attribute_id = absint( $attribute['id'] ); + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } elseif ( ! empty( $attribute['name'] ) ) { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! $attribute_id && ! $attribute_name ) { + continue; + } + + if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { + continue; + } + + $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); + $attribute_value = isset( $attribute['option'] ) ? wc_clean( stripslashes( $attribute['option'] ) ) : ''; + + if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $attribute_value, $attribute_name ); + + if ( $term && ! is_wp_error( $term ) ) { + $attribute_value = $term->slug; + } else { + $attribute_value = sanitize_title( $attribute_value ); + } + } + + $attributes[ $attribute_key ] = $attribute_value; + } + + $variation->set_attributes( $attributes ); + } + + $variation->save(); + + do_action( 'woocommerce_rest_save_product_variation', $variation->get_id(), $menu_order, $data ); + } + + return true; + } + + /** + * Add post meta fields. + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request data. + * @return bool|WP_Error + */ + protected function add_post_meta_fields( $post, $request ) { + return $this->update_post_meta_fields( $post, $request ); + } + + /** + * Update post meta fields. + * + * @param WP_Post $post Post data. + * @param WP_REST_Request $request Request data. + * @return bool|WP_Error + */ + protected function update_post_meta_fields( $post, $request ) { + $product = wc_get_product( $post ); + + // Check for featured/gallery images, upload it and set it. + if ( isset( $request['images'] ) ) { + $product = $this->set_product_images( $product, $request['images'] ); + } + + // Save product meta fields. + $product = $this->set_product_meta( $product, $request ); + + // Save the product data. + $product->save(); + + // Save variations. + if ( $product->is_type( 'variable' ) ) { + if ( isset( $request['variations'] ) && is_array( $request['variations'] ) ) { + $this->save_variations_data( $product, $request ); + } + } + + // Clear caches here so in sync with any new variations/children. + wc_delete_product_transients( $product->get_id() ); + wp_cache_delete( 'product-' . $product->get_id(), 'products' ); + + return true; + } + + /** + * Clear cache/transients. + * + * @param WP_Post $post Post data. + */ + public function clear_transients( $post ) { + wc_delete_product_transients( $post->ID ); + } + + /** + * Delete post. + * + * @param int|WP_Post $id Post ID or WP_Post instance. + */ + protected function delete_post( $id ) { + if ( ! empty( $id->ID ) ) { + $id = $id->ID; + } elseif ( ! is_numeric( $id ) || 0 >= $id ) { + return; + } + + // Delete product attachments. + $attachments = get_posts( array( + 'post_parent' => $id, + 'post_status' => 'any', + 'post_type' => 'attachment', + ) ); + + foreach ( (array) $attachments as $attachment ) { + wp_delete_attachment( $attachment->ID, true ); + } + + // Delete product. + $product = wc_get_product( $id ); + $product->delete( true ); + } + + /** + * Delete a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $force = (bool) $request['force']; + $post = get_post( $id ); + $product = wc_get_product( $id ); + + if ( ! empty( $post->post_type ) && 'product_variation' === $post->post_type && 'product' === $this->post_type ) { + return new WP_Error( "woocommerce_rest_invalid_{$this->post_type}_id", __( 'To manipulate product variations you should use the /products/<product_id>/variations/<id> endpoint.', 'woocommerce' ), array( 'status' => 404 ) ); + } elseif ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $this->post_type ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid post ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $supports_trash = EMPTY_TRASH_DAYS > 0; + + /** + * Filter whether an item is trashable. + * + * Return false to disable trash support for the item. + * + * @param boolean $supports_trash Whether the item type support trashing. + * @param WP_Post $post The Post object being considered for trashing support. + */ + $supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_trashable", $supports_trash, $post ); + + if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $post, $request ); + + // If we're forcing, then delete permanently. + if ( $force ) { + if ( $product->is_type( 'variable' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->delete( true ); + } + } elseif ( $product->is_type( 'grouped' ) ) { + foreach ( $product->get_children() as $child_id ) { + $child = wc_get_product( $child_id ); + $child->set_parent_id( 0 ); + $child->save(); + } + } + + $product->delete( true ); + $result = ! ( $product->get_id() > 0 ); + } else { + // If we don't support trashing for this type, error out. + if ( ! $supports_trash ) { + /* translators: %s: post type */ + return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) ); + } + + // Otherwise, only trash if we haven't already. + if ( 'trash' === $post->post_status ) { + /* translators: %s: post type */ + return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) ); + } + + // (Note that internally this falls through to `wp_delete_post` if + // the trash is disabled.) + $product->delete(); + $result = 'trash' === $product->get_status(); + } + + if ( ! $result ) { + /* translators: %s: post type */ + return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) ); + } + + // Delete parent product transients. + if ( $parent_id = wp_get_post_parent_id( $id ) ) { + wc_delete_product_transients( $parent_id ); + } + + /** + * Fires after a single item is deleted or trashed via the REST API. + * + * @param object $post The deleted or trashed item. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( "woocommerce_rest_delete_{$this->post_type}", $post, $response, $request ); + + return $response; + } + + /** + * Get the Product's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $weight_unit = get_option( 'woocommerce_weight_unit' ); + $dimension_unit = get_option( 'woocommerce_dimension_unit' ); + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => $this->post_type, + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'slug' => array( + 'description' => __( 'Product slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'permalink' => array( + 'description' => __( 'Product URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the product was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the product was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'type' => array( + 'description' => __( 'Product type.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'simple', + 'enum' => array_keys( wc_get_product_types() ), + 'context' => array( 'view', 'edit' ), + ), + 'status' => array( + 'description' => __( 'Product status (post status).', 'woocommerce' ), + 'type' => 'string', + 'default' => 'publish', + 'enum' => array_keys( get_post_statuses() ), + 'context' => array( 'view', 'edit' ), + ), + 'featured' => array( + 'description' => __( 'Featured product.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'catalog_visibility' => array( + 'description' => __( 'Catalog visibility.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'visible', + 'enum' => array( 'visible', 'catalog', 'search', 'hidden' ), + 'context' => array( 'view', 'edit' ), + ), + 'description' => array( + 'description' => __( 'Product description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'short_description' => array( + 'description' => __( 'Product short description.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sku' => array( + 'description' => __( 'Unique identifier.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'price' => array( + 'description' => __( 'Current product price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'regular_price' => array( + 'description' => __( 'Product regular price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sale_price' => array( + 'description' => __( 'Product sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from' => array( + 'description' => __( 'Start date of sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to' => array( + 'description' => __( 'End date of sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'price_html' => array( + 'description' => __( 'Price formatted in HTML.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'on_sale' => array( + 'description' => __( 'Shows if the product is on sale.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'purchasable' => array( + 'description' => __( 'Shows if the product can be bought.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'total_sales' => array( + 'description' => __( 'Amount of sales.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'virtual' => array( + 'description' => __( 'If the product is virtual.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloadable' => array( + 'description' => __( 'If the product is downloadable.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloads' => array( + 'description' => __( 'List of downloadable files.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'File MD5 hash.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'download_limit' => array( + 'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'download_expiry' => array( + 'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ), + 'type' => 'integer', + 'default' => -1, + 'context' => array( 'view', 'edit' ), + ), + 'download_type' => array( + 'description' => __( 'Download type, this controls the schema on the front-end.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'standard', + 'enum' => array( 'standard' ), + 'context' => array( 'view', 'edit' ), + ), + 'external_url' => array( + 'description' => __( 'Product external URL. Only for external products.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'button_text' => array( + 'description' => __( 'Product external button text. Only for external products.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'taxable', + 'enum' => array( 'taxable', 'shipping', 'none' ), + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'manage_stock' => array( + 'description' => __( 'Stock management at product level.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'stock_quantity' => array( + 'description' => __( 'Stock quantity.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'in_stock' => array( + 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'backorders' => array( + 'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'no', + 'enum' => array( 'no', 'notify', 'yes' ), + 'context' => array( 'view', 'edit' ), + ), + 'backorders_allowed' => array( + 'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'backordered' => array( + 'description' => __( 'Shows if the product is on backordered.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sold_individually' => array( + 'description' => __( 'Allow one item to be bought in a single order.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'weight' => array( + /* translators: %s: weight unit */ + 'description' => sprintf( __( 'Product weight (%s).', 'woocommerce' ), $weight_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'dimensions' => array( + 'description' => __( 'Product dimensions.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'length' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product length (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'width' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product width (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'height' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Product height (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping_required' => array( + 'description' => __( 'Shows if the product need to be shipped.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_taxable' => array( + 'description' => __( 'Shows whether or not the product shipping is taxable.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'shipping_class' => array( + 'description' => __( 'Shipping class slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'shipping_class_id' => array( + 'description' => __( 'Shipping class ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'reviews_allowed' => array( + 'description' => __( 'Allow reviews.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'average_rating' => array( + 'description' => __( 'Reviews average rating.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'rating_count' => array( + 'description' => __( 'Amount of reviews that the product have.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'related_ids' => array( + 'description' => __( 'List of related products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'upsell_ids' => array( + 'description' => __( 'List of upsell products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'cross_sell_ids' => array( + 'description' => __( 'List of cross-sell products IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + ), + 'parent_id' => array( + 'description' => __( 'Product parent ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'purchase_note' => array( + 'description' => __( 'Optional note to send the customer after purchase.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'categories' => array( + 'description' => __( 'List of categories.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Category ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Category name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'slug' => array( + 'description' => __( 'Category slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'tags' => array( + 'description' => __( 'List of tags.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Tag ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Tag name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'slug' => array( + 'description' => __( 'Tag slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ), + ), + 'images' => array( + 'description' => __( 'List of images.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'attributes' => array( + 'description' => __( 'List of attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Attribute position.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'visible' => array( + 'description' => __( "Define if the attribute is visible on the \"Additional information\" tab in the product's page.", 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'variation' => array( + 'description' => __( 'Define if the attribute can be used as variation.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'options' => array( + 'description' => __( 'List of available term names of the attribute.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'default_attributes' => array( + 'description' => __( 'Defaults variation attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'option' => array( + 'description' => __( 'Selected attribute term name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'variations' => array( + 'description' => __( 'List of variations.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Variation ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the variation was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the variation was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'permalink' => array( + 'description' => __( 'Variation URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'sku' => array( + 'description' => __( 'Unique identifier.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'price' => array( + 'description' => __( 'Current variation price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'regular_price' => array( + 'description' => __( 'Variation regular price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'sale_price' => array( + 'description' => __( 'Variation sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_from' => array( + 'description' => __( 'Start date of sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'date_on_sale_to' => array( + 'description' => __( 'End date of sale price.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'on_sale' => array( + 'description' => __( 'Shows if the variation is on sale.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'purchasable' => array( + 'description' => __( 'Shows if the variation can be bought.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'visible' => array( + 'description' => __( 'If the variation is visible.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + ), + 'virtual' => array( + 'description' => __( 'If the variation is virtual.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloadable' => array( + 'description' => __( 'If the variation is downloadable.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'downloads' => array( + 'description' => __( 'List of downloadable files.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'File MD5 hash.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'File name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'file' => array( + 'description' => __( 'File URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + 'download_limit' => array( + 'description' => __( 'Number of times downloadable files can be downloaded after purchase.', 'woocommerce' ), + 'type' => 'integer', + 'default' => null, + 'context' => array( 'view', 'edit' ), + ), + 'download_expiry' => array( + 'description' => __( 'Number of days until access to downloadable files expires.', 'woocommerce' ), + 'type' => 'integer', + 'default' => null, + 'context' => array( 'view', 'edit' ), + ), + 'tax_status' => array( + 'description' => __( 'Tax status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'taxable', + 'enum' => array( 'taxable', 'shipping', 'none' ), + 'context' => array( 'view', 'edit' ), + ), + 'tax_class' => array( + 'description' => __( 'Tax class.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'manage_stock' => array( + 'description' => __( 'Stock management at variation level.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'stock_quantity' => array( + 'description' => __( 'Stock quantity.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'in_stock' => array( + 'description' => __( 'Controls whether or not the variation is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'backorders' => array( + 'description' => __( 'If managing stock, this controls if backorders are allowed.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'no', + 'enum' => array( 'no', 'notify', 'yes' ), + 'context' => array( 'view', 'edit' ), + ), + 'backorders_allowed' => array( + 'description' => __( 'Shows if backorders are allowed.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'backordered' => array( + 'description' => __( 'Shows if the variation is on backordered.', 'woocommerce' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'weight' => array( + /* translators: %s: weight unit */ + 'description' => sprintf( __( 'Variation weight (%s).', 'woocommerce' ), $weight_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'dimensions' => array( + 'description' => __( 'Variation dimensions.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'length' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation length (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'width' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation width (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'height' => array( + /* translators: %s: dimension unit */ + 'description' => sprintf( __( 'Variation height (%s).', 'woocommerce' ), $dimension_unit ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'shipping_class' => array( + 'description' => __( 'Shipping class slug.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'shipping_class_id' => array( + 'description' => __( 'Shipping class ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'image' => array( + 'description' => __( 'Variation image data.', 'woocommerce' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'id' => array( + 'description' => __( 'Image ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the image was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the image was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'src' => array( + 'description' => __( 'Image URL.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Image name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'alt' => array( + 'description' => __( 'Image alternative text.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'position' => array( + 'description' => __( 'Image position. 0 means that the image is featured.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + 'attributes' => array( + 'description' => __( 'List of attributes.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Attribute ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Attribute name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'option' => array( + 'description' => __( 'Selected attribute term name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + ), + ), + ), + ), + ), + ), + 'grouped_products' => array( + 'description' => __( 'List of grouped products ID.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'menu_order' => array( + 'description' => __( 'Menu order, used to custom sort products.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['slug'] = array( + 'description' => __( 'Limit result set to products with a specific slug.', 'woocommerce' ), + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['status'] = array( + 'default' => 'any', + 'description' => __( 'Limit result set to products assigned a specific status.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_merge( array( 'any' ), array_keys( get_post_statuses() ) ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['type'] = array( + 'description' => __( 'Limit result set to products assigned a specific type.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array_keys( wc_get_product_types() ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['category'] = array( + 'description' => __( 'Limit result set to products assigned a specific category ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['tag'] = array( + 'description' => __( 'Limit result set to products assigned a specific tag ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['shipping_class'] = array( + 'description' => __( 'Limit result set to products assigned a specific shipping class ID.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['attribute'] = array( + 'description' => __( 'Limit result set to products with a specific attribute.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['attribute_term'] = array( + 'description' => __( 'Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'wp_parse_id_list', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['sku'] = array( + 'description' => __( 'Limit result set to products with a specific SKU.', 'woocommerce' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-sales-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-sales-controller.php new file mode 100644 index 0000000..56aa185 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-sales-controller.php @@ -0,0 +1,397 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read report. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get sales reports. + * + * @param WP_REST_Request $request + * @return array|WP_Error + */ + public function get_items( $request ) { + $data = array(); + $item = $this->prepare_item_for_response( null, $request ); + $data[] = $this->prepare_response_for_collection( $item ); + + return rest_ensure_response( $data ); + } + + /** + * Prepare a report sales object for serialization. + * + * @param null $_ + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $_, $request ) { + // Set date filtering. + $filter = array( + 'period' => $request['period'], + 'date_min' => $request['date_min'], + 'date_max' => $request['date_max'], + ); + $this->setup_report( $filter ); + + // New customers. + $users_query = new WP_User_Query( + array( + 'fields' => array( 'user_registered' ), + 'role' => 'customer', + ) + ); + + $customers = $users_query->get_results(); + + foreach ( $customers as $key => $customer ) { + if ( strtotime( $customer->user_registered ) < $this->report->start_date || strtotime( $customer->user_registered ) > $this->report->end_date ) { + unset( $customers[ $key ] ); + } + } + + $total_customers = count( $customers ); + $report_data = $this->report->get_report_data(); + $period_totals = array(); + + // Setup period totals by ensuring each period in the interval has data. + for ( $i = 0; $i <= $this->report->chart_interval; $i++ ) { + + switch ( $this->report->chart_groupby ) { + case 'day' : + $time = date( 'Y-m-d', strtotime( "+{$i} DAY", $this->report->start_date ) ); + break; + default : + $time = date( 'Y-m', strtotime( "+{$i} MONTH", $this->report->start_date ) ); + break; + } + + // Set the customer signups for each period. + $customer_count = 0; + foreach ( $customers as $customer ) { + if ( date( ( 'day' == $this->report->chart_groupby ) ? 'Y-m-d' : 'Y-m', strtotime( $customer->user_registered ) ) == $time ) { + $customer_count++; + } + } + + $period_totals[ $time ] = array( + 'sales' => wc_format_decimal( 0.00, 2 ), + 'orders' => 0, + 'items' => 0, + 'tax' => wc_format_decimal( 0.00, 2 ), + 'shipping' => wc_format_decimal( 0.00, 2 ), + 'discount' => wc_format_decimal( 0.00, 2 ), + 'customers' => $customer_count, + ); + } + + // add total sales, total order count, total tax and total shipping for each period + foreach ( $report_data->orders as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['sales'] = wc_format_decimal( $order->total_sales, 2 ); + $period_totals[ $time ]['tax'] = wc_format_decimal( $order->total_tax + $order->total_shipping_tax, 2 ); + $period_totals[ $time ]['shipping'] = wc_format_decimal( $order->total_shipping, 2 ); + } + + foreach ( $report_data->order_counts as $order ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order->post_date ) ) : date( 'Y-m', strtotime( $order->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['orders'] = (int) $order->count; + } + + // Add total order items for each period. + foreach ( $report_data->order_items as $order_item ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $order_item->post_date ) ) : date( 'Y-m', strtotime( $order_item->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['items'] = (int) $order_item->order_item_count; + } + + // Add total discount for each period. + foreach ( $report_data->coupons as $discount ) { + $time = ( 'day' === $this->report->chart_groupby ) ? date( 'Y-m-d', strtotime( $discount->post_date ) ) : date( 'Y-m', strtotime( $discount->post_date ) ); + + if ( ! isset( $period_totals[ $time ] ) ) { + continue; + } + + $period_totals[ $time ]['discount'] = wc_format_decimal( $discount->discount_amount, 2 ); + } + + $sales_data = array( + 'total_sales' => $report_data->total_sales, + 'net_sales' => $report_data->net_sales, + 'average_sales' => $report_data->average_sales, + 'total_orders' => $report_data->total_orders, + 'total_items' => $report_data->total_items, + 'total_tax' => wc_format_decimal( $report_data->total_tax + $report_data->total_shipping_tax, 2 ), + 'total_shipping' => $report_data->total_shipping, + 'total_refunds' => $report_data->total_refunds, + 'total_discount' => $report_data->total_coupons, + 'totals_grouped_by' => $this->report->chart_groupby, + 'totals' => $period_totals, + 'total_customers' => $total_customers, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $sales_data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + $response->add_links( array( + 'about' => array( + 'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ), + ), + ) ); + + /** + * Filter a report sales returned from the API. + * + * Allows modification of the report sales data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $data The original report object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( 'woocommerce_rest_prepare_report_sales', $response, (object) $sales_data, $request ); + } + + /** + * Setup the report object and parse any date filtering. + * + * @param array $filter date filtering + */ + protected function setup_report( $filter ) { + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-admin-report.php' ); + include_once( WC()->plugin_path() . '/includes/admin/reports/class-wc-report-sales-by-date.php' ); + + $this->report = new WC_Report_Sales_By_Date(); + + if ( empty( $filter['period'] ) ) { + // Custom date range. + $filter['period'] = 'custom'; + + if ( ! empty( $filter['date_min'] ) || ! empty( $filter['date_max'] ) ) { + + // Overwrite _GET to make use of WC_Admin_Report::calculate_current_range() for custom date ranges. + $_GET['start_date'] = $filter['date_min']; + $_GET['end_date'] = isset( $filter['date_max'] ) ? $filter['date_max'] : null; + + } else { + + // Default custom range to today. + $_GET['start_date'] = $_GET['end_date'] = date( 'Y-m-d', current_time( 'timestamp' ) ); + } + } else { + $filter['period'] = empty( $filter['period'] ) ? 'week' : $filter['period']; + + // Change "week" period to "7day". + if ( 'week' === $filter['period'] ) { + $filter['period'] = '7day'; + } + } + + $this->report->calculate_current_range( $filter['period'] ); + } + + /** + * Get the Report's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'sales_report', + 'type' => 'object', + 'properties' => array( + 'total_sales' => array( + 'description' => __( 'Gross sales in the period.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'net_sales' => array( + 'description' => __( 'Net sales in the period.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'average_sales' => array( + 'description' => __( 'Average net daily sales.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_orders' => array( + 'description' => __( 'Total of orders placed.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_items' => array( + 'description' => __( 'Total of items purchased.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_tax' => array( + 'description' => __( 'Total charged for taxes.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_shipping' => array( + 'description' => __( 'Total charged for shipping.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_refunds' => array( + 'description' => __( 'Total of refunded orders.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'total_discount' => array( + 'description' => __( 'Total of coupons used.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'totals_grouped_by' => array( + 'description' => __( 'Group type.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'totals' => array( + 'description' => __( 'Totals.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'array', + ), + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + 'period' => array( + 'description' => __( 'Report period.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array( 'week', 'month', 'last_month', 'year' ), + 'validate_callback' => 'rest_validate_request_arg', + 'sanitize_callback' => 'sanitize_text_field', + ), + 'date_min' => array( + /* translators: %s: date format */ + 'description' => sprintf( __( 'Return sales for a specific start date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-DD' ), + 'type' => 'string', + 'format' => 'date', + 'validate_callback' => 'wc_rest_validate_reports_request_arg', + 'sanitize_callback' => 'sanitize_text_field', + ), + 'date_max' => array( + /* translators: %s: date format */ + 'description' => sprintf( __( 'Return sales for a specific end date, the date need to be in the %s format.', 'woocommerce' ), 'YYYY-MM-DD' ), + 'type' => 'string', + 'format' => 'date', + 'validate_callback' => 'wc_rest_validate_reports_request_arg', + 'sanitize_callback' => 'sanitize_text_field', + ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-top-sellers-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-top-sellers-controller.php new file mode 100644 index 0000000..de8ec7e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-report-top-sellers-controller.php @@ -0,0 +1,174 @@ + $request['period'], + 'date_min' => $request['date_min'], + 'date_max' => $request['date_max'], + ); + $this->setup_report( $filter ); + + $report_data = $this->report->get_order_report_data( array( + 'data' => array( + '_product_id' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => '', + 'name' => 'product_id', + ), + '_qty' => array( + 'type' => 'order_item_meta', + 'order_item_type' => 'line_item', + 'function' => 'SUM', + 'name' => 'order_item_qty', + ), + ), + 'order_by' => 'order_item_qty DESC', + 'group_by' => 'product_id', + 'limit' => isset( $filter['limit'] ) ? absint( $filter['limit'] ) : 12, + 'query_type' => 'get_results', + 'filter_range' => true, + ) ); + + $top_sellers = array(); + + foreach ( $report_data as $item ) { + $product = wc_get_product( $item->product_id ); + + if ( $product ) { + $top_sellers[] = array( + 'name' => $product->get_name(), + 'product_id' => (int) $item->product_id, + 'quantity' => wc_stock_amount( $item->order_item_qty ), + ); + } + } + + $data = array(); + foreach ( $top_sellers as $top_seller ) { + $item = $this->prepare_item_for_response( (object) $top_seller, $request ); + $data[] = $this->prepare_response_for_collection( $item ); + } + + return rest_ensure_response( $data ); + } + + /** + * Prepare a report sales object for serialization. + * + * @param stdClass $top_seller + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $top_seller, $request ) { + $data = array( + 'name' => $top_seller->name, + 'product_id' => $top_seller->product_id, + 'quantity' => $top_seller->quantity, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + $response->add_links( array( + 'about' => array( + 'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ), + ), + 'product' => array( + 'href' => rest_url( sprintf( '/%s/products/%s', $this->namespace, $top_seller->product_id ) ), + ), + ) ); + + /** + * Filter a report top sellers returned from the API. + * + * Allows modification of the report top sellers data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $top_seller The original report object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( 'woocommerce_rest_prepare_report_top_sellers', $response, $top_seller, $request ); + } + + /** + * Get the Report's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'top_sellers_report', + 'type' => 'object', + 'properties' => array( + 'name' => array( + 'description' => __( 'Product name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'product_id' => array( + 'description' => __( 'Product ID.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'quantity' => array( + 'description' => __( 'Total number of purchases.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-reports-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-reports-controller.php new file mode 100644 index 0000000..ed5dc97 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-reports-controller.php @@ -0,0 +1,174 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read reports. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all reports. + * + * @param WP_REST_Request $request + * @return array|WP_Error + */ + public function get_items( $request ) { + $data = array(); + $reports = array( + array( + 'slug' => 'sales', + 'description' => __( 'List of sales reports.', 'woocommerce' ), + ), + array( + 'slug' => 'top_sellers', + 'description' => __( 'List of top sellers products.', 'woocommerce' ), + ), + ); + + foreach ( $reports as $report ) { + $item = $this->prepare_item_for_response( (object) $report, $request ); + $data[] = $this->prepare_response_for_collection( $item ); + } + + return rest_ensure_response( $data ); + } + + /** + * Prepare a report object for serialization. + * + * @param stdClass $report Report data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $report, $request ) { + $data = array( + 'slug' => $report->slug, + 'description' => $report->description, + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + $response->add_links( array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $report->slug ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ), + ), + ) ); + + /** + * Filter a report returned from the API. + * + * Allows modification of the report data right before it is returned. + * + * @param WP_REST_Response $response The response object. + * @param object $report The original report object. + * @param WP_REST_Request $request Request used to generate the response. + */ + return apply_filters( 'woocommerce_rest_prepare_report', $response, $report, $request ); + } + + /** + * Get the Report's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'report', + 'type' => 'object', + 'properties' => array( + 'slug' => array( + 'description' => __( 'An alphanumeric identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'description' => array( + 'description' => __( 'A human-readable description of the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-tax-classes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-tax-classes-controller.php new file mode 100644 index 0000000..f857256 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-tax-classes-controller.php @@ -0,0 +1,364 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P\w[\w\s\-]*)', array( + 'args' => array( + 'slug' => array( + 'description' => __( 'Unique slug for the resource.', 'woocommerce' ), + 'type' => 'string', + ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read tax classes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access create tax classes. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access delete a tax. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all tax classes. + * + * @param WP_REST_Request $request + * @return array + */ + public function get_items( $request ) { + $tax_classes = array(); + + // Add standard class. + $tax_classes[] = array( + 'slug' => 'standard', + 'name' => __( 'Standard rate', 'woocommerce' ), + ); + + $classes = WC_Tax::get_tax_classes(); + + foreach ( $classes as $class ) { + $tax_classes[] = array( + 'slug' => sanitize_title( $class ), + 'name' => $class, + ); + } + + $data = array(); + foreach ( $tax_classes as $tax_class ) { + $class = $this->prepare_item_for_response( $tax_class, $request ); + $class = $this->prepare_response_for_collection( $class ); + $data[] = $class; + } + + return rest_ensure_response( $data ); + } + + /** + * Create a single tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + $exists = false; + $classes = WC_Tax::get_tax_classes(); + $tax_class = array( + 'slug' => sanitize_title( $request['name'] ), + 'name' => $request['name'], + ); + + // Check if class exists. + foreach ( $classes as $key => $class ) { + if ( sanitize_title( $class ) === $tax_class['slug'] ) { + $exists = true; + break; + } + } + + // Return error if tax class already exists. + if ( $exists ) { + return new WP_Error( 'woocommerce_rest_tax_class_exists', __( 'Cannot create existing resource.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + // Add the new class. + $classes[] = $tax_class['name']; + + update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) ); + + $this->update_additional_fields_for_object( $tax_class, $request ); + + /** + * Fires after a tax class is created or updated via the REST API. + * + * @param stdClass $tax_class Data used to create the tax class. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating tax class, false when updating tax class. + */ + do_action( 'woocommerce_rest_insert_tax_class', (object) $tax_class, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tax_class, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $tax_class['slug'] ) ) ); + + return $response; + } + + /** + * Delete a single tax class. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function delete_item( $request ) { + global $wpdb; + + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $tax_class = array( + 'slug' => sanitize_title( $request['slug'] ), + 'name' => '', + ); + $classes = WC_Tax::get_tax_classes(); + $deleted = false; + + foreach ( $classes as $key => $class ) { + if ( sanitize_title( $class ) === $tax_class['slug'] ) { + $tax_class['name'] = $class; + unset( $classes[ $key ] ); + $deleted = true; + break; + } + } + + if ( ! $deleted ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource id.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + update_option( 'woocommerce_tax_classes', implode( "\n", $classes ) ); + + // Delete tax rate locations locations from the selected class. + $wpdb->query( $wpdb->prepare( " + DELETE locations.* + FROM {$wpdb->prefix}woocommerce_tax_rate_locations AS locations + INNER JOIN + {$wpdb->prefix}woocommerce_tax_rates AS rates + ON rates.tax_rate_id = locations.tax_rate_id + WHERE rates.tax_rate_class = '%s' + ", $tax_class['slug'] ) ); + + // Delete tax rates in the selected class. + $wpdb->delete( $wpdb->prefix . 'woocommerce_tax_rates', array( 'tax_rate_class' => $tax_class['slug'] ), array( '%s' ) ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tax_class, $request ); + + /** + * Fires after a tax class is deleted via the REST API. + * + * @param stdClass $tax_class The tax data. + * @param WP_REST_Response $response The response returned from the API. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'woocommerce_rest_delete_tax', (object) $tax_class, $response, $request ); + + return $response; + } + + /** + * Prepare a single tax class output for response. + * + * @param array $tax_class Tax class data. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $tax_class, $request ) { + $data = $tax_class; + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links() ); + + /** + * Filter tax object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $tax_class Tax object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_tax', $response, (object) $tax_class, $request ); + } + + /** + * Prepare links for the request. + * + * @return array Links for the given tax class. + */ + protected function prepare_links() { + $links = array( + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the Tax Classes schema, conforming to JSON Schema + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'tax_class', + 'type' => 'object', + 'properties' => array( + 'slug' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'Tax class name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'required' => true, + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-taxes-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-taxes-controller.php new file mode 100644 index 0000000..1b8c9bd --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-taxes-controller.php @@ -0,0 +1,709 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read taxes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access create taxes. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access update a tax. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function update_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access delete a tax. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access batch create, update and delete items. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function batch_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'settings', 'batch' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all taxes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + global $wpdb; + + $prepared_args = array(); + $prepared_args['order'] = $request['order']; + $prepared_args['number'] = $request['per_page']; + if ( ! empty( $request['offset'] ) ) { + $prepared_args['offset'] = $request['offset']; + } else { + $prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number']; + } + $orderby_possibles = array( + 'id' => 'tax_rate_id', + 'order' => 'tax_rate_order', + ); + $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; + $prepared_args['class'] = $request['class']; + + /** + * Filter arguments, before passing to $wpdb->get_results(), when querying taxes via the REST API. + * + * @param array $prepared_args Array of arguments for $wpdb->get_results(). + * @param WP_REST_Request $request The current request. + */ + $prepared_args = apply_filters( 'woocommerce_rest_tax_query', $prepared_args, $request ); + + $query = " + SELECT * + FROM {$wpdb->prefix}woocommerce_tax_rates + WHERE 1 = 1 + "; + + // Filter by tax class. + if ( ! empty( $prepared_args['class'] ) ) { + $class = 'standard' !== $prepared_args['class'] ? sanitize_title( $prepared_args['class'] ) : ''; + $query .= " AND tax_rate_class = '$class'"; + } + + // Order tax rates. + $order_by = sprintf( ' ORDER BY %s', sanitize_key( $prepared_args['orderby'] ) ); + + // Pagination. + $pagination = sprintf( ' LIMIT %d, %d', $prepared_args['offset'], $prepared_args['number'] ); + + // Query taxes. + $results = $wpdb->get_results( $query . $order_by . $pagination ); + + $taxes = array(); + foreach ( $results as $tax ) { + $data = $this->prepare_item_for_response( $tax, $request ); + $taxes[] = $this->prepare_response_for_collection( $data ); + } + + $response = rest_ensure_response( $taxes ); + + // Store pagination values for headers then unset for count query. + $per_page = (int) $prepared_args['number']; + $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); + + // Query only for ids. + $wpdb->get_results( str_replace( 'SELECT *', 'SELECT tax_rate_id', $query ) ); + + // Calculate totals. + $total_taxes = (int) $wpdb->num_rows; + $response->header( 'X-WP-Total', (int) $total_taxes ); + $max_pages = ceil( $total_taxes / $per_page ); + $response->header( 'X-WP-TotalPages', (int) $max_pages ); + + $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); + if ( $page > 1 ) { + $prev_page = $page - 1; + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + $prev_link = add_query_arg( 'page', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + if ( $max_pages > $page ) { + $next_page = $page + 1; + $next_link = add_query_arg( 'page', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } + + return $response; + } + + /** + * Take tax data from the request and return the updated or newly created rate. + * + * @param WP_REST_Request $request Full details about the request. + * @param stdClass|null $current Existing tax object. + * @return object + */ + protected function create_or_update_tax( $request, $current = null ) { + $id = absint( isset( $request['id'] ) ? $request['id'] : 0 ); + $data = array(); + $fields = array( + 'tax_rate_country', + 'tax_rate_state', + 'tax_rate', + 'tax_rate_name', + 'tax_rate_priority', + 'tax_rate_compound', + 'tax_rate_shipping', + 'tax_rate_order', + 'tax_rate_class', + ); + + foreach ( $fields as $field ) { + // Keys via API differ from the stored names returned by _get_tax_rate. + $key = 'tax_rate' === $field ? 'rate' : str_replace( 'tax_rate_', '', $field ); + + // Remove data that was not posted. + if ( ! isset( $request[ $key ] ) ) { + continue; + } + + // Test new data against current data. + if ( $current && $current->$field === $request[ $key ] ) { + continue; + } + + // Add to data array. + switch ( $key ) { + case 'tax_rate_priority' : + case 'tax_rate_compound' : + case 'tax_rate_shipping' : + case 'tax_rate_order' : + $data[ $field ] = absint( $request[ $key ] ); + break; + case 'tax_rate_class' : + $data[ $field ] = 'standard' !== $request['tax_rate_class'] ? $request['tax_rate_class'] : ''; + break; + default : + $data[ $field ] = wc_clean( $request[ $key ] ); + break; + } + } + + if ( $id ) { + WC_Tax::_update_tax_rate( $id, $data ); + } else { + $id = WC_Tax::_insert_tax_rate( $data ); + } + + // Add locales. + if ( ! empty( $request['postcode'] ) ) { + WC_Tax::_update_tax_rate_postcodes( $id, wc_clean( $request['postcode'] ) ); + } + if ( ! empty( $request['city'] ) ) { + WC_Tax::_update_tax_rate_cities( $id, wc_clean( $request['city'] ) ); + } + + return WC_Tax::_get_tax_rate( $id, OBJECT ); + } + + /** + * Create a single tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + return new WP_Error( 'woocommerce_rest_tax_exists', __( 'Cannot create existing resource.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $tax = $this->create_or_update_tax( $request ); + + $this->update_additional_fields_for_object( $tax, $request ); + + /** + * Fires after a tax is created or updated via the REST API. + * + * @param stdClass $tax Data used to create the tax. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating tax, false when updating tax. + */ + do_action( 'woocommerce_rest_insert_tax', $tax, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tax, $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $tax->tax_rate_id ) ) ); + + return $response; + } + + /** + * Get a single tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT ); + + if ( empty( $id ) || empty( $tax_obj ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $tax = $this->prepare_item_for_response( $tax_obj, $request ); + $response = rest_ensure_response( $tax ); + + return $response; + } + + /** + * Update a single tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $id = (int) $request['id']; + $tax_obj = WC_Tax::_get_tax_rate( $id, OBJECT ); + + if ( empty( $id ) || empty( $tax_obj ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $tax = $this->create_or_update_tax( $request, $tax_obj ); + + $this->update_additional_fields_for_object( $tax, $request ); + + /** + * Fires after a tax is created or updated via the REST API. + * + * @param stdClass $tax Data used to create the tax. + * @param WP_REST_Request $request Request object. + * @param boolean $creating True when creating tax, false when updating tax. + */ + do_action( 'woocommerce_rest_insert_tax', $tax, $request, false ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tax, $request ); + $response = rest_ensure_response( $response ); + + return $response; + } + + /** + * Delete a single tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function delete_item( $request ) { + global $wpdb; + + $id = (int) $request['id']; + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Taxes do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $tax = WC_Tax::_get_tax_rate( $id, OBJECT ); + + if ( empty( $id ) || empty( $tax ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $tax, $request ); + + WC_Tax::_delete_tax_rate( $id ); + + if ( 0 === $wpdb->rows_affected ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'The resource cannot be deleted.', 'woocommerce' ), array( 'status' => 500 ) ); + } + + /** + * Fires after a tax is deleted via the REST API. + * + * @param stdClass $tax The tax data. + * @param WP_REST_Response $response The response returned from the API. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( 'woocommerce_rest_delete_tax', $tax, $response, $request ); + + return $response; + } + + /** + * Prepare a single tax output for response. + * + * @param stdClass $tax Tax object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $tax, $request ) { + global $wpdb; + + $id = (int) $tax->tax_rate_id; + $data = array( + 'id' => $id, + 'country' => $tax->tax_rate_country, + 'state' => $tax->tax_rate_state, + 'postcode' => '', + 'city' => '', + 'rate' => $tax->tax_rate, + 'name' => $tax->tax_rate_name, + 'priority' => (int) $tax->tax_rate_priority, + 'compound' => (bool) $tax->tax_rate_compound, + 'shipping' => (bool) $tax->tax_rate_shipping, + 'order' => (int) $tax->tax_rate_order, + 'class' => $tax->tax_rate_class ? $tax->tax_rate_class : 'standard', + ); + + // Get locales from a tax rate. + $locales = $wpdb->get_results( $wpdb->prepare( " + SELECT location_code, location_type + FROM {$wpdb->prefix}woocommerce_tax_rate_locations + WHERE tax_rate_id = %d + ", $id ) ); + + if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) { + foreach ( $locales as $locale ) { + $data[ $locale->location_type ] = $locale->location_code; + } + } + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $tax ) ); + + /** + * Filter tax object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $tax Tax object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_tax', $response, $tax, $request ); + } + + /** + * Prepare links for the request. + * + * @param stdClass $tax Tax object. + * @return array Links for the given tax. + */ + protected function prepare_links( $tax ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $tax->tax_rate_id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the Taxes schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'tax', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'country' => array( + 'description' => __( 'Country ISO 3166 code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'state' => array( + 'description' => __( 'State code.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'postcode' => array( + 'description' => __( 'Postcode / ZIP.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'city' => array( + 'description' => __( 'City name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'rate' => array( + 'description' => __( 'Tax rate.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'name' => array( + 'description' => __( 'Tax rate name.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'priority' => array( + 'description' => __( 'Tax priority.', 'woocommerce' ), + 'type' => 'integer', + 'default' => 1, + 'context' => array( 'view', 'edit' ), + ), + 'compound' => array( + 'description' => __( 'Whether or not this is a compound rate.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => false, + 'context' => array( 'view', 'edit' ), + ), + 'shipping' => array( + 'description' => __( 'Whether or not this tax rate also gets applied to shipping.', 'woocommerce' ), + 'type' => 'boolean', + 'default' => true, + 'context' => array( 'view', 'edit' ), + ), + 'order' => array( + 'description' => __( 'Indicates the order that will appear in queries.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + ), + 'class' => array( + 'description' => __( 'Tax class.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'standard', + 'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ), + 'context' => array( 'view', 'edit' ), + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + $params = array(); + $params['context'] = $this->get_context_param(); + $params['context']['default'] = 'view'; + + $params['page'] = array( + 'description' => __( 'Current page of the collection.', 'woocommerce' ), + 'type' => 'integer', + 'default' => 1, + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + 'minimum' => 1, + ); + $params['per_page'] = array( + 'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ), + 'type' => 'integer', + 'default' => 10, + 'minimum' => 1, + 'maximum' => 100, + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['order'] = array( + 'default' => 'asc', + 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), + 'enum' => array( 'asc', 'desc' ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['orderby'] = array( + 'default' => 'order', + 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), + 'enum' => array( + 'id', + 'order', + ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['class'] = array( + 'description' => __( 'Sort by tax class.', 'woocommerce' ), + 'enum' => array_merge( array( 'standard' ), WC_Tax::get_tax_class_slugs() ), + 'sanitize_callback' => 'sanitize_title', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhook-deliveries-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhook-deliveries-controller.php new file mode 100644 index 0000000..7b51ac7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhook-deliveries-controller.php @@ -0,0 +1,314 @@ +/deliveries endpoint. + * + * @author WooThemes + * @category API + * @package WooCommerce/API + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +/** + * REST API Webhook Deliveries controller class. + * + * @deprecated 3.3.0 Webhooks deliveries logs now uses logging system. + * @package WooCommerce/API + * @extends WC_REST_Controller + */ +class WC_REST_Webhook_Deliveries_V1_Controller extends WC_REST_Controller { + + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v1'; + + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'webhooks/(?P[\d]+)/deliveries'; + + /** + * Register the routes for webhook deliveries. + */ + public function register_routes() { + register_rest_route( $this->namespace, '/' . $this->rest_base, array( + 'args' => array( + 'webhook_id' => array( + 'description' => __( 'Unique identifier for the webhook.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'webhook_id' => array( + 'description' => __( 'Unique identifier for the webhook.', 'woocommerce' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read taxes. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a tax. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get all webhook deliveries. + * + * @param WP_REST_Request $request + * + * @return array|WP_Error + */ + public function get_items( $request ) { + $webhook = wc_get_webhook( (int) $request['webhook_id'] ); + + if ( empty( $webhook ) || is_null( $webhook ) ) { + return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $logs = array(); + $data = array(); + foreach ( $logs as $log ) { + $delivery = $this->prepare_item_for_response( (object) $log, $request ); + $delivery = $this->prepare_response_for_collection( $delivery ); + $data[] = $delivery; + } + + return rest_ensure_response( $data ); + } + + /** + * Get a single webhook delivery. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $webhook = wc_get_webhook( (int) $request['webhook_id'] ); + + if ( empty( $webhook ) || is_null( $webhook ) ) { + return new WP_Error( 'woocommerce_rest_webhook_invalid_id', __( 'Invalid webhook ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $log = array(); + + if ( empty( $id ) || empty( $log ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $delivery = $this->prepare_item_for_response( (object) $log, $request ); + $response = rest_ensure_response( $delivery ); + + return $response; + } + + /** + * Prepare a single webhook delivery output for response. + * + * @param stdClass $log Delivery log object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $log, $request ) { + $data = (array) $log; + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $log ) ); + + /** + * Filter webhook delivery object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param stdClass $log Delivery log object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( 'woocommerce_rest_prepare_webhook_delivery', $response, $log, $request ); + } + + /** + * Prepare links for the request. + * + * @param stdClass $log Delivery log object. + * @return array Links for the given webhook delivery. + */ + protected function prepare_links( $log ) { + $webhook_id = (int) $log->request_headers['X-WC-Webhook-ID']; + $base = str_replace( '(?P[\d]+)', $webhook_id, $this->rest_base ); + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $base, $log->id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ), + ), + 'up' => array( + 'href' => rest_url( sprintf( '/%s/webhooks/%d', $this->namespace, $webhook_id ) ), + ), + ); + + return $links; + } + + /** + * Get the Webhook's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'webhook_delivery', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'duration' => array( + 'description' => __( 'The delivery duration, in seconds.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'summary' => array( + 'description' => __( 'A friendly summary of the response including the HTTP response code, message, and body.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'request_url' => array( + 'description' => __( 'The URL where the webhook was delivered.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'request_headers' => array( + 'description' => __( 'Request headers.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'request_body' => array( + 'description' => __( 'Request body.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_code' => array( + 'description' => __( 'The HTTP response code from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_message' => array( + 'description' => __( 'The HTTP response message from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'response_headers' => array( + 'description' => __( 'Array of the response headers from the receiving server.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'response_body' => array( + 'description' => __( 'The response body from the receiving server.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view' ), + 'readonly' => true, + ), + 'date_created' => array( + 'description' => __( "The date the webhook delivery was logged, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections. + * + * @return array + */ + public function get_collection_params() { + return array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhooks-controller.php b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhooks-controller.php new file mode 100644 index 0000000..20541eb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/api/v1/class-wc-rest-webhooks-controller.php @@ -0,0 +1,766 @@ +namespace, '/' . $this->rest_base, array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + 'topic' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Webhook topic.', 'woocommerce' ), + ), + 'delivery_url' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Webhook delivery URL.', 'woocommerce' ), + ), + ) ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + ), + ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) ); + + register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'batch_items' ), + 'permission_callback' => array( $this, 'batch_items_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + 'schema' => array( $this, 'get_public_batch_schema' ), + ) ); + } + + /** + * Check whether a given request has permission to read webhooks. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access create webhooks. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function create_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'create' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access to read a webhook. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'read' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access update a webhook. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function update_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'edit' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access delete a webhook. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function delete_item_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'delete' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Check if a given request has access batch create, update and delete items. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return bool|WP_Error + */ + public function batch_items_permissions_check( $request ) { + if ( ! wc_rest_check_manager_permissions( 'webhooks', 'batch' ) ) { + return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); + } + + return true; + } + + /** + * Get the default REST API version. + * + * @since 3.0.0 + * @return string + */ + protected function get_default_api_version() { + return 'wp_api_v1'; + } + + /** + * Get all webhooks. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_items( $request ) { + $args = array(); + $args['order'] = $request['order']; + $args['orderby'] = $request['orderby']; + $args['status'] = 'all' === $request['status'] ? '' : $request['status']; + $args['include'] = implode( ',', $request['include'] ); + $args['exclude'] = implode( ',', $request['exclude'] ); + $args['limit'] = $request['per_page']; + $args['search'] = $request['search']; + $args['before'] = $request['before']; + $args['after'] = $request['after']; + + if ( empty( $request['offset'] ) ) { + $args['offset'] = 1 < $request['page'] ? ( $request['page'] - 1 ) * $args['limit'] : 0; + } + + /** + * Filter arguments, before passing to WC_Webhook_Data_Store->search_webhooks, when querying webhooks via the REST API. + * + * @param array $args Array of arguments for $wpdb->get_results(). + * @param WP_REST_Request $request The current request. + */ + $prepared_args = apply_filters( 'woocommerce_rest_webhook_query', $args, $request ); + unset( $prepared_args['page'] ); + + // Get the webhooks. + $data_store = WC_Data_Store::load( 'webhook' ); + $results = $data_store->search_webhooks( $prepared_args ); + + $webhooks = array(); + foreach ( $results as $webhook_id ) { + $data = $this->prepare_item_for_response( $webhook_id, $request ); + $webhooks[] = $this->prepare_response_for_collection( $data ); + } + + $response = rest_ensure_response( $webhooks ); + + // Store pagination values for headers then unset for count query. + $per_page = (int) $prepared_args['limit']; + $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); + + // Calculate totals. + $prepared_args['limit'] = -1; + $prepared_args['offset'] = 0; + $total_webhooks = count( $data_store->search_webhooks( $prepared_args ) ); + $response->header( 'X-WP-Total', (int) $total_webhooks ); + $max_pages = ceil( $total_webhooks / $per_page ); + $response->header( 'X-WP-TotalPages', (int) $max_pages ); + + $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) ); + if ( $page > 1 ) { + $prev_page = $page - 1; + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + $prev_link = add_query_arg( 'page', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + if ( $max_pages > $page ) { + $next_page = $page + 1; + $next_link = add_query_arg( 'page', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } + + return $response; + } + + /** + * Get a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + + if ( empty( $id ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $data = $this->prepare_item_for_response( $id, $request ); + $response = rest_ensure_response( $data ); + + return $response; + } + + /** + * Create a single webhook. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function create_item( $request ) { + if ( ! empty( $request['id'] ) ) { + /* translators: %s: post type */ + return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) ); + } + + // Validate topic. + if ( empty( $request['topic'] ) || ! wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic is required and must be valid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + // Validate delivery URL. + if ( empty( $request['delivery_url'] ) || ! wc_is_valid_url( $request['delivery_url'] ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $post = $this->prepare_item_for_database( $request ); + if ( is_wp_error( $post ) ) { + return $post; + } + + $webhook = new WC_Webhook(); + $webhook->set_name( $post->post_title ); + $webhook->set_user_id( $post->post_author ); + $webhook->set_status( 'publish' === $post->post_status ? 'active' : 'disabled' ); + $webhook->set_topic( $request['topic'] ); + $webhook->set_delivery_url( $request['delivery_url'] ); + $webhook->set_secret( ! empty( $request['secret'] ) ? $request['secret'] : wp_generate_password( 50, true, true ) ); + $webhook->set_api_version( $this->get_default_api_version() ); + $webhook->save(); + + $this->update_additional_fields_for_object( $webhook, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WC_Webhook $webhook Webhook data. + * @param WP_REST_Request $request Request object. + * @param bool $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_webhook_object", $webhook, $request, true ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $webhook->get_id(), $request ); + $response = rest_ensure_response( $response ); + $response->set_status( 201 ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $webhook->get_id() ) ) ); + + // Send ping. + $webhook->deliver_ping(); + + return $response; + } + + /** + * Update a single webhook. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response + */ + public function update_item( $request ) { + $id = (int) $request['id']; + $webhook = wc_get_webhook( $id ); + + if ( empty( $webhook ) || is_null( $webhook ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + // Update topic. + if ( ! empty( $request['topic'] ) ) { + if ( wc_is_webhook_valid_topic( strtolower( $request['topic'] ) ) ) { + $webhook->set_topic( $request['topic'] ); + } else { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_topic", __( 'Webhook topic must be valid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + } + + // Update delivery URL. + if ( ! empty( $request['delivery_url'] ) ) { + if ( wc_is_valid_url( $request['delivery_url'] ) ) { + $webhook->set_delivery_url( $request['delivery_url'] ); + } else { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_delivery_url", __( 'Webhook delivery URL must be a valid URL starting with http:// or https://.', 'woocommerce' ), array( 'status' => 400 ) ); + } + } + + // Update secret. + if ( ! empty( $request['secret'] ) ) { + $webhook->set_secret( $request['secret'] ); + } + + // Update status. + if ( ! empty( $request['status'] ) ) { + $webhook->set_status( $request['status'] ); + } + + $post = $this->prepare_item_for_database( $request ); + if ( is_wp_error( $post ) ) { + return $post; + } + + if ( isset( $post->post_title ) ) { + $webhook->set_name( $post->post_title ); + } + + $webhook->save(); + + $this->update_additional_fields_for_object( $webhook, $request ); + + /** + * Fires after a single item is created or updated via the REST API. + * + * @param WC_Webhook $webhook Webhook data. + * @param WP_REST_Request $request Request object. + * @param bool $creating True when creating item, false when updating. + */ + do_action( "woocommerce_rest_insert_webhook_object", $webhook, $request, false ); + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $webhook->get_id(), $request ); + + return rest_ensure_response( $response ); + } + + /** + * Delete a single webhook. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function delete_item( $request ) { + $id = (int) $request['id']; + $force = isset( $request['force'] ) ? (bool) $request['force'] : false; + + // We don't support trashing for this type, error out. + if ( ! $force ) { + return new WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Webhooks do not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); + } + + $webhook = wc_get_webhook( $id ); + + if ( empty( $webhook ) || is_null( $webhook ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) ); + } + + $request->set_param( 'context', 'edit' ); + $response = $this->prepare_item_for_response( $webhook, $request ); + $result = $webhook->delete( true ); + + if ( ! $result ) { + /* translators: %s: post type */ + return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) ); + } + + /** + * Fires after a single item is deleted or trashed via the REST API. + * + * @param WC_Webhook $webhook The deleted or trashed item. + * @param WP_REST_Response $response The response data. + * @param WP_REST_Request $request The request sent to the API. + */ + do_action( "woocommerce_rest_delete_webhook_object", $webhook, $response, $request ); + + return $response; + } + + /** + * Prepare a single webhook for create or update. + * + * @param WP_REST_Request $request Request object. + * @return WP_Error|stdClass $data Post object. + */ + protected function prepare_item_for_database( $request ) { + $data = new stdClass; + + // Post ID. + if ( isset( $request['id'] ) ) { + $data->ID = absint( $request['id'] ); + } + + // Validate required POST fields. + if ( 'POST' === $request->get_method() && empty( $data->ID ) ) { + $data->post_title = ! empty( $request['name'] ) ? $request['name'] : sprintf( __( 'Webhook created on %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Webhook created on date parsed by strftime', 'woocommerce' ) ) ); // @codingStandardsIgnoreLine + + // Post author. + $data->post_author = get_current_user_id(); + + // Post password. + $password = strlen( uniqid( 'webhook_' ) ); + $data->post_password = $password > 20 ? substr( $password, 0, 20 ) : $password; + + // Post status. + $data->post_status = 'publish'; + } else { + + // Allow edit post title. + if ( ! empty( $request['name'] ) ) { + $data->post_title = $request['name']; + } + } + + // Comment status. + $data->comment_status = 'closed'; + + // Ping status. + $data->ping_status = 'closed'; + + /** + * Filter the query_vars used in `get_items` for the constructed query. + * + * The dynamic portion of the hook name, $this->post_type, refers to post_type of the post being + * prepared for insertion. + * + * @param stdClass $data An object representing a single item prepared + * for inserting or updating the database. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_pre_insert_{$this->post_type}", $data, $request ); + } + + /** + * Prepare a single webhook output for response. + * + * @param int $id Webhook ID or object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response $response Response data. + */ + public function prepare_item_for_response( $id, $request ) { + $webhook = wc_get_webhook( $id ); + + if ( empty( $webhook ) || is_null( $webhook ) ) { + return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'ID is invalid.', 'woocommerce' ), array( 'status' => 400 ) ); + } + + $data = array( + 'id' => $webhook->get_id(), + 'name' => $webhook->get_name(), + 'status' => $webhook->get_status(), + 'topic' => $webhook->get_topic(), + 'resource' => $webhook->get_resource(), + 'event' => $webhook->get_event(), + 'hooks' => $webhook->get_hooks(), + 'delivery_url' => $webhook->get_delivery_url(), + 'date_created' => wc_rest_prepare_date_response( $webhook->get_date_created() ), + 'date_modified' => wc_rest_prepare_date_response( $webhook->get_date_modified() ), + ); + + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); + + // Wrap the data in a response object. + $response = rest_ensure_response( $data ); + + $response->add_links( $this->prepare_links( $webhook->get_id() ) ); + + /** + * Filter webhook object returned from the REST API. + * + * @param WP_REST_Response $response The response object. + * @param WC_Webhook $webhook Webhook object used to create response. + * @param WP_REST_Request $request Request object. + */ + return apply_filters( "woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request ); + } + + /** + * Prepare links for the request. + * + * @param int $id Webhook ID. + * @return array + */ + protected function prepare_links( $id ) { + $links = array( + 'self' => array( + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $id ) ), + ), + 'collection' => array( + 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), + ), + ); + + return $links; + } + + /** + * Get the Webhook's schema, conforming to JSON Schema. + * + * @return array + */ + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'webhook', + 'type' => 'object', + 'properties' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), + 'type' => 'integer', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'name' => array( + 'description' => __( 'A friendly name for the webhook.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'status' => array( + 'description' => __( 'Webhook status.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'active', + 'enum' => array( 'active', 'paused', 'disabled' ), + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'wc_is_webhook_valid_topic', + ), + ), + 'topic' => array( + 'description' => __( 'Webhook topic.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + ), + 'resource' => array( + 'description' => __( 'Webhook resource.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'event' => array( + 'description' => __( 'Webhook event.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'hooks' => array( + 'description' => __( 'WooCommerce action names associated with the webhook.', 'woocommerce' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ), + 'delivery_url' => array( + 'description' => __( 'The URL where the webhook payload is delivered.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'secret' => array( + 'description' => __( "Secret key used to generate a hash of the delivered webhook and provided in the request headers. This will default to a MD5 hash from the current user's ID|username if not provided.", 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), + 'date_created' => array( + 'description' => __( "The date the webhook was created, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + 'date_modified' => array( + 'description' => __( "The date the webhook was last modified, in the site's timezone.", 'woocommerce' ), + 'type' => 'date-time', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), + ), + ); + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get the query params for collections of attachments. + * + * @return array + */ + public function get_collection_params() { + $params = parent::get_collection_params(); + + $params['context']['default'] = 'view'; + + $params['after'] = array( + 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['before'] = array( + 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['exclude'] = array( + 'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['include'] = array( + 'description' => __( 'Limit result set to specific ids.', 'woocommerce' ), + 'type' => 'array', + 'items' => array( + 'type' => 'integer', + ), + 'default' => array(), + 'sanitize_callback' => 'wp_parse_id_list', + ); + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['order'] = array( + 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'desc', + 'enum' => array( 'asc', 'desc' ), + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['orderby'] = array( + 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'date', + 'enum' => array( + 'date', + 'id', + 'title', + ), + 'validate_callback' => 'rest_validate_request_arg', + ); + $params['status'] = array( + 'default' => 'all', + 'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ), + 'type' => 'string', + 'enum' => array( 'all', 'active', 'paused', 'disabled' ), + 'sanitize_callback' => 'sanitize_key', + 'validate_callback' => 'rest_validate_request_arg', + ); + + return $params; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-ajax.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-ajax.php new file mode 100644 index 0000000..b73363d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-ajax.php @@ -0,0 +1,2797 @@ +hide_errors(); + } + } + + /** + * Send headers for WC Ajax Requests. + * + * @since 2.5.0 + */ + private static function wc_ajax_headers() { + send_origin_headers(); + @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); + @header( 'X-Robots-Tag: noindex' ); + send_nosniff_header(); + wc_nocache_headers(); + status_header( 200 ); + } + + /** + * Check for WC Ajax request and fire action. + */ + public static function do_wc_ajax() { + global $wp_query; + + if ( ! empty( $_GET['wc-ajax'] ) ) { + $wp_query->set( 'wc-ajax', sanitize_text_field( wp_unslash( $_GET['wc-ajax'] ) ) ); + } + + $action = $wp_query->get( 'wc-ajax' ); + + if ( $action ) { + self::wc_ajax_headers(); + $action = sanitize_text_field( $action ); + do_action( 'wc_ajax_' . $action ); + wp_die(); + } + } + + /** + * Hook in methods - uses WordPress ajax handlers (admin-ajax). + */ + public static function add_ajax_events() { + // woocommerce_EVENT => nopriv. + $ajax_events = array( + 'get_refreshed_fragments' => true, + 'apply_coupon' => true, + 'remove_coupon' => true, + 'update_shipping_method' => true, + 'get_cart_totals' => true, + 'update_order_review' => true, + 'add_to_cart' => true, + 'remove_from_cart' => true, + 'checkout' => true, + 'get_variation' => true, + 'get_customer_location' => true, + 'feature_product' => false, + 'mark_order_status' => false, + 'get_order_details' => false, + 'add_attribute' => false, + 'add_new_attribute' => false, + 'remove_variation' => false, + 'remove_variations' => false, + 'save_attributes' => false, + 'add_variation' => false, + 'link_all_variations' => false, + 'revoke_access_to_download' => false, + 'grant_access_to_download' => false, + 'get_customer_details' => false, + 'add_order_item' => false, + 'add_order_fee' => false, + 'add_order_shipping' => false, + 'add_order_tax' => false, + 'add_coupon_discount' => false, + 'remove_order_coupon' => false, + 'remove_order_item' => false, + 'remove_order_tax' => false, + 'reduce_order_item_stock' => false, + 'increase_order_item_stock' => false, + 'add_order_item_meta' => false, + 'remove_order_item_meta' => false, + 'calc_line_taxes' => false, + 'save_order_items' => false, + 'load_order_items' => false, + 'add_order_note' => false, + 'delete_order_note' => false, + 'json_search_products' => false, + 'json_search_products_and_variations' => false, + 'json_search_downloadable_products_and_variations' => false, + 'json_search_customers' => false, + 'json_search_categories' => false, + 'term_ordering' => false, + 'product_ordering' => false, + 'refund_line_items' => false, + 'delete_refund' => false, + 'rated' => false, + 'update_api_key' => false, + 'load_variations' => false, + 'save_variations' => false, + 'bulk_edit_variations' => false, + 'tax_rates_save_changes' => false, + 'shipping_zones_save_changes' => false, + 'shipping_zone_add_method' => false, + 'shipping_zone_methods_save_changes' => false, + 'shipping_zone_methods_save_settings' => false, + 'shipping_classes_save_changes' => false, + 'toggle_gateway_enabled' => false, + ); + + foreach ( $ajax_events as $ajax_event => $nopriv ) { + add_action( 'wp_ajax_woocommerce_' . $ajax_event, array( __CLASS__, $ajax_event ) ); + + if ( $nopriv ) { + add_action( 'wp_ajax_nopriv_woocommerce_' . $ajax_event, array( __CLASS__, $ajax_event ) ); + + // WC AJAX can be used for frontend ajax requests. + add_action( 'wc_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); + } + } + } + + /** + * Get a refreshed cart fragment, including the mini cart HTML. + */ + public static function get_refreshed_fragments() { + ob_start(); + + woocommerce_mini_cart(); + + $mini_cart = ob_get_clean(); + + $data = array( + 'fragments' => apply_filters( + 'woocommerce_add_to_cart_fragments', array( + 'div.widget_shopping_cart_content' => '
      ' . $mini_cart . '
      ', + ) + ), + 'cart_hash' => apply_filters( 'woocommerce_add_to_cart_hash', WC()->cart->get_cart_for_session() ? md5( json_encode( WC()->cart->get_cart_for_session() ) ) : '', WC()->cart->get_cart_for_session() ), + ); + + wp_send_json( $data ); + } + + /** + * AJAX apply coupon on checkout page. + */ + public static function apply_coupon() { + + check_ajax_referer( 'apply-coupon', 'security' ); + + if ( ! empty( $_POST['coupon_code'] ) ) { + WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) ); + } else { + wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' ); + } + + wc_print_notices(); + wp_die(); + } + + /** + * AJAX remove coupon on cart and checkout page. + */ + public static function remove_coupon() { + check_ajax_referer( 'remove-coupon', 'security' ); + + $coupon = isset( $_POST['coupon'] ) ? wc_clean( $_POST['coupon'] ) : false; + + if ( empty( $coupon ) ) { + wc_add_notice( __( 'Sorry there was a problem removing this coupon.', 'woocommerce' ), 'error' ); + } else { + WC()->cart->remove_coupon( $coupon ); + wc_add_notice( __( 'Coupon has been removed.', 'woocommerce' ) ); + } + + wc_print_notices(); + wp_die(); + } + + /** + * AJAX update shipping method on cart page. + */ + public static function update_shipping_method() { + check_ajax_referer( 'update-shipping-method', 'security' ); + + wc_maybe_define_constant( 'WOOCOMMERCE_CART', true ); + + $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); + + if ( isset( $_POST['shipping_method'] ) && is_array( $_POST['shipping_method'] ) ) { + foreach ( $_POST['shipping_method'] as $i => $value ) { + $chosen_shipping_methods[ $i ] = wc_clean( $value ); + } + } + + WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods ); + + self::get_cart_totals(); + } + + /** + * AJAX receive updated cart_totals div. + */ + public static function get_cart_totals() { + wc_maybe_define_constant( 'WOOCOMMERCE_CART', true ); + WC()->cart->calculate_totals(); + woocommerce_cart_totals(); + wp_die(); + } + + /** + * Session has expired. + */ + private static function update_order_review_expired() { + wp_send_json( + array( + 'fragments' => apply_filters( + 'woocommerce_update_order_review_fragments', array( + 'form.woocommerce-checkout' => '
      ' . __( 'Sorry, your session has expired.', 'woocommerce' ) . ' ' . __( 'Return to shop', 'woocommerce' ) . '
      ', + ) + ), + ) + ); + } + + /** + * AJAX update order review on checkout. + */ + public static function update_order_review() { + check_ajax_referer( 'update-order-review', 'security' ); + + wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); + + if ( WC()->cart->is_empty() && ! is_customize_preview() ) { + self::update_order_review_expired(); + } + + do_action( 'woocommerce_checkout_update_order_review', $_POST['post_data'] ); + + $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); + + if ( isset( $_POST['shipping_method'] ) && is_array( $_POST['shipping_method'] ) ) { + foreach ( $_POST['shipping_method'] as $i => $value ) { + $chosen_shipping_methods[ $i ] = wc_clean( $value ); + } + } + + WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods ); + WC()->session->set( 'chosen_payment_method', empty( $_POST['payment_method'] ) ? '' : $_POST['payment_method'] ); + WC()->customer->set_props( + array( + 'billing_country' => isset( $_POST['country'] ) ? wp_unslash( $_POST['country'] ) : null, + 'billing_state' => isset( $_POST['state'] ) ? wp_unslash( $_POST['state'] ) : null, + 'billing_postcode' => isset( $_POST['postcode'] ) ? wp_unslash( $_POST['postcode'] ) : null, + 'billing_city' => isset( $_POST['city'] ) ? wp_unslash( $_POST['city'] ) : null, + 'billing_address_1' => isset( $_POST['address'] ) ? wp_unslash( $_POST['address'] ) : null, + 'billing_address_2' => isset( $_POST['address_2'] ) ? wp_unslash( $_POST['address_2'] ) : null, + ) + ); + + if ( wc_ship_to_billing_address_only() ) { + WC()->customer->set_props( + array( + 'shipping_country' => isset( $_POST['country'] ) ? wp_unslash( $_POST['country'] ) : null, + 'shipping_state' => isset( $_POST['state'] ) ? wp_unslash( $_POST['state'] ) : null, + 'shipping_postcode' => isset( $_POST['postcode'] ) ? wp_unslash( $_POST['postcode'] ) : null, + 'shipping_city' => isset( $_POST['city'] ) ? wp_unslash( $_POST['city'] ) : null, + 'shipping_address_1' => isset( $_POST['address'] ) ? wp_unslash( $_POST['address'] ) : null, + 'shipping_address_2' => isset( $_POST['address_2'] ) ? wp_unslash( $_POST['address_2'] ) : null, + ) + ); + } else { + WC()->customer->set_props( + array( + 'shipping_country' => isset( $_POST['s_country'] ) ? wp_unslash( $_POST['s_country'] ) : null, + 'shipping_state' => isset( $_POST['s_state'] ) ? wp_unslash( $_POST['s_state'] ) : null, + 'shipping_postcode' => isset( $_POST['s_postcode'] ) ? wp_unslash( $_POST['s_postcode'] ) : null, + 'shipping_city' => isset( $_POST['s_city'] ) ? wp_unslash( $_POST['s_city'] ) : null, + 'shipping_address_1' => isset( $_POST['s_address'] ) ? wp_unslash( $_POST['s_address'] ) : null, + 'shipping_address_2' => isset( $_POST['s_address_2'] ) ? wp_unslash( $_POST['s_address_2'] ) : null, + ) + ); + } + + if ( wc_string_to_bool( $_POST['has_full_address'] ) ) { + WC()->customer->set_calculated_shipping( true ); + } else { + WC()->customer->set_calculated_shipping( false ); + } + + WC()->customer->save(); + WC()->cart->calculate_totals(); + + // Get order review fragment + ob_start(); + woocommerce_order_review(); + $woocommerce_order_review = ob_get_clean(); + + // Get checkout payment fragment + ob_start(); + woocommerce_checkout_payment(); + $woocommerce_checkout_payment = ob_get_clean(); + + // Get messages if reload checkout is not true + $messages = ''; + if ( ! isset( WC()->session->reload_checkout ) ) { + ob_start(); + wc_print_notices(); + $messages = ob_get_clean(); + } + + unset( WC()->session->refresh_totals, WC()->session->reload_checkout ); + + wp_send_json( + array( + 'result' => empty( $messages ) ? 'success' : 'failure', + 'messages' => $messages, + 'reload' => isset( WC()->session->reload_checkout ) ? 'true' : 'false', + 'fragments' => apply_filters( + 'woocommerce_update_order_review_fragments', array( + '.woocommerce-checkout-review-order-table' => $woocommerce_order_review, + '.woocommerce-checkout-payment' => $woocommerce_checkout_payment, + ) + ), + ) + ); + } + + /** + * AJAX add to cart. + */ + public static function add_to_cart() { + ob_start(); + + $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_POST['product_id'] ) ); + $product = wc_get_product( $product_id ); + $quantity = empty( $_POST['quantity'] ) ? 1 : wc_stock_amount( $_POST['quantity'] ); + $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity ); + $product_status = get_post_status( $product_id ); + $variation_id = 0; + $variation = array(); + + if ( $product && 'variation' === $product->get_type() ) { + $variation_id = $product_id; + $product_id = $product->get_parent_id(); + $variation = $product->get_variation_attributes(); + } + + if ( $passed_validation && false !== WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation ) && 'publish' === $product_status ) { + + do_action( 'woocommerce_ajax_added_to_cart', $product_id ); + + if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { + wc_add_to_cart_message( array( $product_id => $quantity ), true ); + } + + // Return fragments + self::get_refreshed_fragments(); + + } else { + + // If there was an error adding to the cart, redirect to the product page to show any errors + $data = array( + 'error' => true, + 'product_url' => apply_filters( 'woocommerce_cart_redirect_after_error', get_permalink( $product_id ), $product_id ), + ); + + wp_send_json( $data ); + } + } + + /** + * AJAX remove from cart. + */ + public static function remove_from_cart() { + ob_start(); + + $cart_item_key = wc_clean( $_POST['cart_item_key'] ); + + if ( $cart_item_key && false !== WC()->cart->remove_cart_item( $cart_item_key ) ) { + self::get_refreshed_fragments(); + } else { + wp_send_json_error(); + } + } + + /** + * Process ajax checkout form. + */ + public static function checkout() { + wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); + WC()->checkout()->process_checkout(); + wp_die( 0 ); + } + + /** + * Get a matching variation based on posted attributes. + */ + public static function get_variation() { + ob_start(); + + if ( empty( $_POST['product_id'] ) || ! ( $variable_product = wc_get_product( absint( $_POST['product_id'] ) ) ) ) { + wp_die(); + } + + $data_store = WC_Data_Store::load( 'product' ); + $variation_id = $data_store->find_matching_product_variation( $variable_product, wp_unslash( $_POST ) ); + $variation = $variation_id ? $variable_product->get_available_variation( $variation_id ) : false; + wp_send_json( $variation ); + } + + /** + * Locate user via AJAX. + */ + public static function get_customer_location() { + $location_hash = WC_Cache_Helper::geolocation_ajax_get_location_hash(); + wp_send_json_success( array( 'hash' => $location_hash ) ); + } + + /** + * Toggle Featured status of a product from admin. + */ + public static function feature_product() { + if ( current_user_can( 'edit_products' ) && check_admin_referer( 'woocommerce-feature-product' ) ) { + $product = wc_get_product( absint( $_GET['product_id'] ) ); + + if ( $product ) { + $product->set_featured( ! $product->get_featured() ); + $product->save(); + } + } + + wp_safe_redirect( wp_get_referer() ? remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() ) : admin_url( 'edit.php?post_type=product' ) ); + exit; + } + + /** + * Mark an order with a status. + */ + public static function mark_order_status() { + if ( current_user_can( 'edit_shop_orders' ) && check_admin_referer( 'woocommerce-mark-order-status' ) ) { + $status = sanitize_text_field( $_GET['status'] ); + $order = wc_get_order( absint( $_GET['order_id'] ) ); + + if ( wc_is_order_status( 'wc-' . $status ) && $order ) { + // Initialize payment gateways in case order has hooked status transition actions. + wc()->payment_gateways(); + + $order->update_status( $status, '', true ); + do_action( 'woocommerce_order_edit_status', $order->get_id(), $status ); + } + } + + wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'edit.php?post_type=shop_order' ) ); + exit; + } + + /** + * Get order details. + */ + public static function get_order_details() { + check_admin_referer( 'woocommerce-preview-order', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $order = wc_get_order( absint( $_GET['order_id'] ) ); // WPCS: sanitization ok. + + if ( $order ) { + include_once 'admin/list-tables/class-wc-admin-list-table-orders.php'; + + wp_send_json_success( WC_Admin_List_Table_Orders::order_preview_get_order_details( $order ) ); + } + wp_die(); + } + + /** + * Add an attribute row. + */ + public static function add_attribute() { + ob_start(); + + check_ajax_referer( 'add-attribute', 'security' ); + + if ( ! current_user_can( 'edit_products' ) ) { + wp_die( -1 ); + } + + $i = absint( $_POST['i'] ); + $metabox_class = array(); + $attribute = new WC_Product_Attribute(); + + $attribute->set_id( wc_attribute_taxonomy_id_by_name( sanitize_text_field( $_POST['taxonomy'] ) ) ); + $attribute->set_name( sanitize_text_field( $_POST['taxonomy'] ) ); + $attribute->set_visible( apply_filters( 'woocommerce_attribute_default_visibility', 1 ) ); + $attribute->set_variation( apply_filters( 'woocommerce_attribute_default_is_variation', 0 ) ); + + if ( $attribute->is_taxonomy() ) { + $metabox_class[] = 'taxonomy'; + $metabox_class[] = $attribute->get_name(); + } + + include 'admin/meta-boxes/views/html-product-attribute.php'; + wp_die(); + } + + /** + * Add a new attribute via ajax function. + */ + public static function add_new_attribute() { + check_ajax_referer( 'add-attribute', 'security' ); + + if ( current_user_can( 'manage_product_terms' ) ) { + $taxonomy = esc_attr( $_POST['taxonomy'] ); + $term = wc_clean( $_POST['term'] ); + + if ( taxonomy_exists( $taxonomy ) ) { + + $result = wp_insert_term( $term, $taxonomy ); + + if ( is_wp_error( $result ) ) { + wp_send_json( + array( + 'error' => $result->get_error_message(), + ) + ); + } else { + $term = get_term_by( 'id', $result['term_id'], $taxonomy ); + wp_send_json( + array( + 'term_id' => $term->term_id, + 'name' => $term->name, + 'slug' => $term->slug, + ) + ); + } + } + } + wp_die( -1 ); + } + + /** + * Delete variations via ajax function. + */ + public static function remove_variations() { + check_ajax_referer( 'delete-variations', 'security' ); + + if ( current_user_can( 'edit_products' ) ) { + $variation_ids = (array) $_POST['variation_ids']; + + foreach ( $variation_ids as $variation_id ) { + if ( 'product_variation' === get_post_type( $variation_id ) ) { + $variation = wc_get_product( $variation_id ); + $variation->delete( true ); + } + } + } + + wp_die( -1 ); + } + + /** + * Save attributes via ajax. + */ + public static function save_attributes() { + check_ajax_referer( 'save-attributes', 'security' ); + + if ( ! current_user_can( 'edit_products' ) ) { + wp_die( -1 ); + } + + parse_str( $_POST['data'], $data ); + + $attributes = WC_Meta_Box_Product_Data::prepare_attributes( $data ); + $product_id = absint( $_POST['post_id'] ); + $product_type = ! empty( $_POST['product_type'] ) ? wc_clean( $_POST['product_type'] ) : 'simple'; + $classname = WC_Product_Factory::get_product_classname( $product_id, $product_type ); + $product = new $classname( $product_id ); + + $product->set_attributes( $attributes ); + $product->save(); + wp_die(); + } + + /** + * Add variation via ajax function. + */ + public static function add_variation() { + check_ajax_referer( 'add-variation', 'security' ); + + if ( ! current_user_can( 'edit_products' ) ) { + wp_die( -1 ); + } + + global $post; // Set $post global so its available, like within the admin screens. + + $product_id = intval( $_POST['post_id'] ); + $post = get_post( $product_id ); + $loop = intval( $_POST['loop'] ); + $product_object = wc_get_product( $product_id ); + $variation_object = new WC_Product_Variation(); + $variation_object->set_parent_id( $product_id ); + $variation_object->set_attributes( array_fill_keys( array_map( 'sanitize_title', array_keys( $product_object->get_variation_attributes() ) ), '' ) ); + $variation_id = $variation_object->save(); + $variation = get_post( $variation_id ); + $variation_data = array_merge( array_map( 'maybe_unserialize', get_post_custom( $variation_id ) ), wc_get_product_variation_attributes( $variation_id ) ); // kept for BW compatibility. + include 'admin/meta-boxes/views/html-variation-admin.php'; + wp_die(); + } + + /** + * Link all variations via ajax function. + */ + public static function link_all_variations() { + check_ajax_referer( 'link-variations', 'security' ); + + if ( ! current_user_can( 'edit_products' ) ) { + wp_die( -1 ); + } + + wc_maybe_define_constant( 'WC_MAX_LINKED_VARIATIONS', 49 ); + wc_set_time_limit( 0 ); + + $post_id = intval( $_POST['post_id'] ); + + if ( ! $post_id ) { + wp_die(); + } + + $product = wc_get_product( $post_id ); + $attributes = wc_list_pluck( array_filter( $product->get_attributes(), 'wc_attributes_array_filter_variation' ), 'get_slugs' ); + + if ( ! empty( $attributes ) ) { + // Get existing variations so we don't create duplicates. + $existing_variations = array_map( 'wc_get_product', $product->get_children() ); + $existing_attributes = array(); + + foreach ( $existing_variations as $existing_variation ) { + $existing_attributes[] = $existing_variation->get_attributes(); + } + + $added = 0; + $possible_attributes = array_reverse( wc_array_cartesian( $attributes ) ); + + foreach ( $possible_attributes as $possible_attribute ) { + if ( in_array( $possible_attribute, $existing_attributes ) ) { + continue; + } + $variation = new WC_Product_Variation(); + $variation->set_parent_id( $post_id ); + $variation->set_attributes( $possible_attribute ); + + do_action( 'product_variation_linked', $variation->save() ); + + if ( ( $added ++ ) > WC_MAX_LINKED_VARIATIONS ) { + break; + } + } + + echo $added; + } + + $data_store = $product->get_data_store(); + $data_store->sort_all_product_variations( $product->get_id() ); + wp_die(); + } + + /** + * Delete download permissions via ajax function. + */ + public static function revoke_access_to_download() { + check_ajax_referer( 'revoke-access', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + $download_id = $_POST['download_id']; + $product_id = intval( $_POST['product_id'] ); + $order_id = intval( $_POST['order_id'] ); + $permission_id = absint( $_POST['permission_id'] ); + $data_store = WC_Data_Store::load( 'customer-download' ); + $data_store->delete_by_id( $permission_id ); + + do_action( 'woocommerce_ajax_revoke_access_to_product_download', $download_id, $product_id, $order_id, $permission_id ); + + wp_die(); + } + + /** + * Grant download permissions via ajax function. + */ + public static function grant_access_to_download() { + + check_ajax_referer( 'grant-access', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + global $wpdb; + + $wpdb->hide_errors(); + + $order_id = intval( $_POST['order_id'] ); + $product_ids = $_POST['product_ids']; + $loop = intval( $_POST['loop'] ); + $file_counter = 0; + $order = wc_get_order( $order_id ); + + if ( ! is_array( $product_ids ) ) { + $product_ids = array( $product_ids ); + } + + foreach ( $product_ids as $product_id ) { + $product = wc_get_product( $product_id ); + $files = $product->get_downloads(); + + if ( ! $order->get_billing_email() ) { + wp_die(); + } + + if ( ! empty( $files ) ) { + foreach ( $files as $download_id => $file ) { + if ( $inserted_id = wc_downloadable_file_permission( $download_id, $product_id, $order ) ) { + $download = new WC_Customer_Download( $inserted_id ); + $loop ++; + $file_counter ++; + + if ( $file->get_name() ) { + $file_count = $file->get_name(); + } else { + $file_count = sprintf( __( 'File %d', 'woocommerce' ), $file_counter ); + } + include 'admin/meta-boxes/views/html-order-download-permission.php'; + } + } + } + } + wp_die(); + } + + /** + * Get customer details via ajax. + */ + public static function get_customer_details() { + check_ajax_referer( 'get-customer-details', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $user_id = absint( $_POST['user_id'] ); + $customer = new WC_Customer( $user_id ); + + if ( has_filter( 'woocommerce_found_customer_details' ) ) { + wc_deprecated_function( 'The woocommerce_found_customer_details filter', '3.0', 'woocommerce_ajax_get_customer_details' ); + } + + $data = $customer->get_data(); + $data['date_created'] = $data['date_created'] ? $data['date_created']->getTimestamp() : null; + $data['date_modified'] = $data['date_modified'] ? $data['date_modified']->getTimestamp() : null; + + $customer_data = apply_filters( 'woocommerce_ajax_get_customer_details', $data, $customer, $user_id ); + wp_send_json( $customer_data ); + } + + /** + * Add order item via ajax. + */ + public static function add_order_item() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $order = wc_get_order( $order_id ); + $items_to_add = wp_parse_id_list( is_array( $_POST['item_to_add'] ) ? $_POST['item_to_add'] : array( $_POST['item_to_add'] ) ); + $items = ( ! empty( $_POST['items'] ) ) ? $_POST['items'] : ''; + $added_items = array(); + + if ( ! $order ) { + throw new Exception( __( 'Invalid order', 'woocommerce' ) ); + } + + // If we passed through items it means we need to save first before adding a new one. + if ( ! empty( $items ) ) { + $save_items = array(); + parse_str( $items, $save_items ); + // Save order items. + wc_save_order_items( $order->get_id(), $save_items ); + } + + foreach ( $items_to_add as $item_to_add ) { + + if ( ! in_array( get_post_type( $item_to_add ), array( 'product', 'product_variation' ) ) ) { + continue; + } + + $item_id = $order->add_product( wc_get_product( $item_to_add ) ); + $item = apply_filters( 'woocommerce_ajax_order_item', $order->get_item( $item_id ), $item_id ); + + $added_items[ $item_id ] = $item; + + do_action( 'woocommerce_ajax_add_order_item_meta', $item_id, $item, $order ); + } + + $last_item = ! empty( $added_items ) ? end( $added_items ) : null; + wc_do_deprecated_action( 'woocommerce_ajax_added_order_items', array( is_a( $last_item, 'WC_Order_Item' ) ? $last_item->get_id() : null, $last_item, $order ), '3.4', 'woocommerce_ajax_order_items_added action instead.' ); + + do_action( 'woocommerce_ajax_order_items_added', $added_items, $order ); + + $data = get_post_meta( $order_id ); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Add order fee via ajax. + */ + public static function add_order_fee() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $amount = wc_clean( $_POST['amount'] ); + $order = wc_get_order( $order_id ); + $calculate_tax_args = array( + 'country' => strtoupper( wc_clean( $_POST['country'] ) ), + 'state' => strtoupper( wc_clean( $_POST['state'] ) ), + 'postcode' => strtoupper( wc_clean( $_POST['postcode'] ) ), + 'city' => strtoupper( wc_clean( $_POST['city'] ) ), + ); + + if ( ! $order ) { + throw new exception( __( 'Invalid order', 'woocommerce' ) ); + } + + if ( strstr( $amount, '%' ) ) { + $formatted_amount = $amount; + $percent = floatval( trim( $amount, '%' ) ); + $amount = $order->get_total() * ( $percent / 100 ); + } else { + $amount = floatval( $amount ); + $formatted_amount = wc_price( $amount, array( 'currency' => $order->get_currency() ) ); + } + + $fee = new WC_Order_Item_Fee(); + $fee->set_amount( $amount ); + $fee->set_total( $amount ); + $fee->set_name( sprintf( __( '%s fee', 'woocommerce' ), $formatted_amount ) ); + + $order->add_item( $fee ); + $order->calculate_taxes( $calculate_tax_args ); + $order->calculate_totals( false ); + $order->save(); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Add order shipping cost via ajax. + */ + public static function add_order_shipping() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $order = wc_get_order( $order_id ); + $order_taxes = $order->get_taxes(); + $shipping_methods = WC()->shipping() ? WC()->shipping->load_shipping_methods() : array(); + + // Add new shipping + $item = new WC_Order_Item_Shipping(); + $item->set_shipping_rate( new WC_Shipping_Rate() ); + $item->set_order_id( $order_id ); + $item_id = $item->save(); + + ob_start(); + include 'admin/meta-boxes/views/html-order-shipping.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Add order tax column via ajax. + */ + public static function add_order_tax() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $rate_id = absint( $_POST['rate_id'] ); + $order = wc_get_order( $order_id ); + $data = get_post_meta( $order_id ); + + // Add new tax + $item = new WC_Order_Item_Tax(); + $item->set_rate( $rate_id ); + $item->set_order_id( $order_id ); + $item->save(); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Add order discount via ajax. + */ + public static function add_coupon_discount() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $order = wc_get_order( $order_id ); + $result = $order->apply_coupon( wc_clean( $_POST['coupon'] ) ); + + if ( is_wp_error( $result ) ) { + throw new Exception( $result->get_error_message() ); + } + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Remove coupon from an order via ajax. + */ + public static function remove_order_coupon() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $order = wc_get_order( $order_id ); + + $order->remove_coupon( wc_clean( $_POST['coupon'] ) ); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Remove an order item. + */ + public static function remove_order_item() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $order_item_ids = $_POST['order_item_ids']; + $items = ( ! empty( $_POST['items'] ) ) ? $_POST['items'] : ''; + $calculate_tax_args = array( + 'country' => strtoupper( wc_clean( $_POST['country'] ) ), + 'state' => strtoupper( wc_clean( $_POST['state'] ) ), + 'postcode' => strtoupper( wc_clean( $_POST['postcode'] ) ), + 'city' => strtoupper( wc_clean( $_POST['city'] ) ), + ); + + if ( ! is_array( $order_item_ids ) && is_numeric( $order_item_ids ) ) { + $order_item_ids = array( $order_item_ids ); + } + + // If we passed through items it means we need to save first before deleting. + if ( ! empty( $items ) ) { + $save_items = array(); + parse_str( $items, $save_items ); + // Save order items + wc_save_order_items( $order_id, $save_items ); + } + + if ( sizeof( $order_item_ids ) > 0 ) { + foreach ( $order_item_ids as $id ) { + wc_delete_order_item( absint( $id ) ); + } + } + + $order = wc_get_order( $order_id ); + $order->calculate_taxes( $calculate_tax_args ); + $order->calculate_totals( false ); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Remove an order tax. + */ + public static function remove_order_tax() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + try { + $order_id = absint( $_POST['order_id'] ); + $rate_id = absint( $_POST['rate_id'] ); + + wc_delete_order_item( $rate_id ); + + $order = wc_get_order( $order_id ); + $order->calculate_totals( false ); + + ob_start(); + include 'admin/meta-boxes/views/html-order-items.php'; + + wp_send_json_success( + array( + 'html' => ob_get_clean(), + ) + ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Reduce order item stock. + */ + public static function reduce_order_item_stock() { + check_ajax_referer( 'order-item', 'security' ); + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + $order_id = absint( $_POST['order_id'] ); + $order_item_ids = isset( $_POST['order_item_ids'] ) ? $_POST['order_item_ids'] : array(); + $order_item_qty = isset( $_POST['order_item_qty'] ) ? $_POST['order_item_qty'] : array(); + $order = wc_get_order( $order_id ); + $order_items = $order->get_items(); + $return = array(); + if ( $order && ! empty( $order_items ) && sizeof( $order_item_ids ) > 0 ) { + foreach ( $order_items as $item_id => $order_item ) { + // Only reduce checked items + if ( ! in_array( $item_id, $order_item_ids ) ) { + continue; + } + $_product = $order_item->get_product(); + if ( $_product && $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) { + $stock_change = apply_filters( 'woocommerce_reduce_order_stock_quantity', $order_item_qty[ $item_id ], $item_id ); + $new_stock = wc_update_product_stock( $_product, $stock_change, 'decrease' ); + $item_name = $_product->get_formatted_name(); + $return[] = array( + 'note' => sprintf( wp_kses_post( __( '%1$s stock reduced from %2$s to %3$s.', 'woocommerce' ) ), $item_name, $new_stock + $stock_change, $new_stock ), + 'success' => true, + ); + } + } + do_action( 'woocommerce_reduce_order_stock', $order ); + + if ( empty( $return ) ) { + $return[] = array( + 'note' => wp_kses_post( __( 'No products had their stock reduced - they may not have stock management enabled.', 'woocommerce' ) ), + 'success' => false, + ); + } + + wp_send_json_success( $return ); + } + wp_send_json_error(); + } + + /** + * Increase order item stock. + */ + public static function increase_order_item_stock() { + check_ajax_referer( 'order-item', 'security' ); + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + $order_id = absint( $_POST['order_id'] ); + $order_item_ids = isset( $_POST['order_item_ids'] ) ? $_POST['order_item_ids'] : array(); + $order_item_qty = isset( $_POST['order_item_qty'] ) ? $_POST['order_item_qty'] : array(); + $order = wc_get_order( $order_id ); + $order_items = $order->get_items(); + $return = array(); + if ( $order && ! empty( $order_items ) && sizeof( $order_item_ids ) > 0 ) { + foreach ( $order_items as $item_id => $order_item ) { + // Only reduce checked items + if ( ! in_array( $item_id, $order_item_ids ) ) { + continue; + } + $_product = $order_item->get_product(); + if ( $_product && $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) { + $old_stock = $_product->get_stock_quantity(); + $stock_change = apply_filters( 'woocommerce_restore_order_stock_quantity', $order_item_qty[ $item_id ], $item_id ); + $new_quantity = wc_update_product_stock( $_product, $stock_change, 'increase' ); + $item_name = $_product->get_formatted_name(); + $return[] = array( + 'note' => sprintf( wp_kses_post( __( '%1$s stock increased from %2$s to %3$s.', 'woocommerce' ) ), $item_name, $old_stock, $new_quantity ), + 'success' => true, + ); + } + } + do_action( 'woocommerce_restore_order_stock', $order ); + if ( empty( $return ) ) { + $return[] = array( + 'note' => wp_kses_post( __( 'No products had their stock increased - they may not have stock management enabled.', 'woocommerce' ) ), + 'success' => false, + ); + } + + wp_send_json_success( $return ); + } + wp_send_json_error(); + } + + /** + * Calc line tax. + */ + public static function calc_line_taxes() { + check_ajax_referer( 'calc-totals', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $order_id = absint( $_POST['order_id'] ); + $calculate_tax_args = array( + 'country' => strtoupper( wc_clean( $_POST['country'] ) ), + 'state' => strtoupper( wc_clean( $_POST['state'] ) ), + 'postcode' => strtoupper( wc_clean( $_POST['postcode'] ) ), + 'city' => strtoupper( wc_clean( $_POST['city'] ) ), + ); + + // Parse the jQuery serialized items + $items = array(); + parse_str( $_POST['items'], $items ); + + // Save order items first + wc_save_order_items( $order_id, $items ); + + // Grab the order and recalculate taxes + $order = wc_get_order( $order_id ); + $order->calculate_taxes( $calculate_tax_args ); + $order->calculate_totals( false ); + include 'admin/meta-boxes/views/html-order-items.php'; + wp_die(); + } + + /** + * Save order items via ajax. + */ + public static function save_order_items() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + if ( isset( $_POST['order_id'], $_POST['items'] ) ) { + $order_id = absint( $_POST['order_id'] ); + + // Parse the jQuery serialized items + $items = array(); + parse_str( $_POST['items'], $items ); + + // Save order items + wc_save_order_items( $order_id, $items ); + + // Return HTML items + $order = wc_get_order( $order_id ); + include 'admin/meta-boxes/views/html-order-items.php'; + } + wp_die(); + } + + /** + * Load order items via ajax. + */ + public static function load_order_items() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + // Return HTML items + $order_id = absint( $_POST['order_id'] ); + $order = wc_get_order( $order_id ); + include 'admin/meta-boxes/views/html-order-items.php'; + wp_die(); + } + + /** + * Add order note via ajax. + */ + public static function add_order_note() { + check_ajax_referer( 'add-order-note', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $post_id = absint( $_POST['post_id'] ); + $note = wp_kses_post( trim( wp_unslash( $_POST['note'] ) ) ); + $note_type = $_POST['note_type']; + + $is_customer_note = ( 'customer' === $note_type ) ? 1 : 0; + + if ( $post_id > 0 ) { + $order = wc_get_order( $post_id ); + $comment_id = $order->add_order_note( $note, $is_customer_note, true ); + $note = wc_get_order_note( $comment_id ); + + $note_classes = array( 'note' ); + $note_classes[] = $is_customer_note ? 'customer-note' : ''; + $note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note ); + ?> +
    • +
      + content ) ) ); ?> +
      +

      + + date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?> + + added_by ) : + /* translators: %s: note author */ + printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by ); + endif; + ?> + +

      +
    • + 0 ) { + wc_delete_order_note( $note_id ); + } + wp_die(); + } + + /** + * Search for products and echo json. + * + * @param string $term (default: '') + * @param bool $include_variations in search or not + */ + public static function json_search_products( $term = '', $include_variations = false ) { + check_ajax_referer( 'search-products', 'security' ); + + $term = wc_clean( empty( $term ) ? wp_unslash( $_GET['term'] ) : $term ); + + if ( empty( $term ) ) { + wp_die(); + } + + $data_store = WC_Data_Store::load( 'product' ); + $ids = $data_store->search_products( $term, '', (bool) $include_variations ); + + if ( ! empty( $_GET['exclude'] ) ) { + $ids = array_diff( $ids, (array) $_GET['exclude'] ); + } + + if ( ! empty( $_GET['include'] ) ) { + $ids = array_intersect( $ids, (array) $_GET['include'] ); + } + + if ( ! empty( $_GET['limit'] ) ) { + $ids = array_slice( $ids, 0, absint( $_GET['limit'] ) ); + } + + $product_objects = array_filter( array_map( 'wc_get_product', $ids ), 'wc_products_array_filter_readable' ); + $products = array(); + + foreach ( $product_objects as $product_object ) { + $products[ $product_object->get_id() ] = rawurldecode( $product_object->get_formatted_name() ); + } + + wp_send_json( apply_filters( 'woocommerce_json_search_found_products', $products ) ); + } + + /** + * Search for product variations and return json. + * + * @see WC_AJAX::json_search_products() + */ + public static function json_search_products_and_variations() { + self::json_search_products( '', true ); + } + + /** + * Search for downloadable product variations and return json. + * + * @see WC_AJAX::json_search_products() + */ + public static function json_search_downloadable_products_and_variations() { + check_ajax_referer( 'search-products', 'security' ); + + $term = (string) wc_clean( wp_unslash( $_GET['term'] ) ); + $data_store = WC_Data_Store::load( 'product' ); + $ids = $data_store->search_products( $term, 'downloadable', true ); + + if ( ! empty( $_GET['exclude'] ) ) { + $ids = array_diff( $ids, (array) $_GET['exclude'] ); + } + + if ( ! empty( $_GET['include'] ) ) { + $ids = array_intersect( $ids, (array) $_GET['include'] ); + } + + if ( ! empty( $_GET['limit'] ) ) { + $ids = array_slice( $ids, 0, absint( $_GET['limit'] ) ); + } + + $product_objects = array_filter( array_map( 'wc_get_product', $ids ), 'wc_products_array_filter_readable' ); + $products = array(); + + foreach ( $product_objects as $product_object ) { + $products[ $product_object->get_id() ] = rawurldecode( $product_object->get_formatted_name() ); + } + + wp_send_json( $products ); + } + + /** + * Search for customers and return json. + */ + public static function json_search_customers() { + ob_start(); + + check_ajax_referer( 'search-customers', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $term = wc_clean( wp_unslash( $_GET['term'] ) ); + $exclude = array(); + $limit = ''; + + if ( empty( $term ) ) { + wp_die(); + } + + $ids = array(); + // Search by ID. + if ( is_numeric( $term ) ) { + $customer = new WC_Customer( intval( $term ) ); + + // Customer does not exists. + if ( 0 !== $customer->get_id() ) { + $ids = array( $customer->get_id() ); + } + } + + // Usernames can be numeric so we first check that no users was found by ID before searching for numeric username, this prevents performance issues with ID lookups. + if ( empty( $ids ) ) { + $data_store = WC_Data_Store::load( 'customer' ); + + // If search is smaller than 3 characters, limit result set to avoid + // too many rows being returned. + if ( 3 > strlen( $term ) ) { + $limit = 20; + } + $ids = $data_store->search_customers( $term, $limit ); + } + + $found_customers = array(); + + if ( ! empty( $_GET['exclude'] ) ) { + $ids = array_diff( $ids, (array) $_GET['exclude'] ); + } + + foreach ( $ids as $id ) { + $customer = new WC_Customer( $id ); + /* translators: 1: user display name 2: user ID 3: user email */ + $found_customers[ $id ] = sprintf( + esc_html__( '%1$s (#%2$s – %3$s)', 'woocommerce' ), + $customer->get_first_name() . ' ' . $customer->get_last_name(), + $customer->get_id(), + $customer->get_email() + ); + } + + wp_send_json( apply_filters( 'woocommerce_json_search_found_customers', $found_customers ) ); + } + + /** + * Search for categories and return json. + */ + public static function json_search_categories() { + ob_start(); + + check_ajax_referer( 'search-categories', 'security' ); + + if ( ! current_user_can( 'edit_products' ) ) { + wp_die( -1 ); + } + + if ( ! $search_text = wc_clean( wp_unslash( $_GET['term'] ) ) ) { + wp_die(); + } + + $found_categories = array(); + $args = array( + 'taxonomy' => array( 'product_cat' ), + 'orderby' => 'id', + 'order' => 'ASC', + 'hide_empty' => true, + 'fields' => 'all', + 'name__like' => $search_text, + ); + + if ( $terms = get_terms( $args ) ) { + foreach ( $terms as $term ) { + $term->formatted_name = ''; + + if ( $term->parent ) { + $ancestors = array_reverse( get_ancestors( $term->term_id, 'product_cat' ) ); + foreach ( $ancestors as $ancestor ) { + if ( $ancestor_term = get_term( $ancestor, 'product_cat' ) ) { + $term->formatted_name .= $ancestor_term->name . ' > '; + } + } + } + + $term->formatted_name .= $term->name . ' (' . $term->count . ')'; + $found_categories[ $term->term_id ] = $term; + } + } + + wp_send_json( apply_filters( 'woocommerce_json_search_found_categories', $found_categories ) ); + } + + /** + * Ajax request handling for categories ordering. + */ + public static function term_ordering() { + + // check permissions again and make sure we have what we need + if ( ! current_user_can( 'edit_products' ) || empty( $_POST['id'] ) ) { + wp_die( -1 ); + } + + $id = (int) $_POST['id']; + $next_id = isset( $_POST['nextid'] ) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null; + $taxonomy = isset( $_POST['thetaxonomy'] ) ? esc_attr( $_POST['thetaxonomy'] ) : null; + $term = get_term_by( 'id', $id, $taxonomy ); + + if ( ! $id || ! $term || ! $taxonomy ) { + wp_die( 0 ); + } + + wc_reorder_terms( $term, $next_id, $taxonomy ); + + $children = get_terms( $taxonomy, "child_of=$id&menu_order=ASC&hide_empty=0" ); + + if ( $term && sizeof( $children ) ) { + echo 'children'; + wp_die(); + } + } + + /** + * Ajax request handling for product ordering. + * + * Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/). + */ + public static function product_ordering() { + global $wpdb; + + if ( ! current_user_can( 'edit_products' ) || empty( $_POST['id'] ) ) { + wp_die( -1 ); + } + + $sorting_id = absint( $_POST['id'] ); + $previd = absint( isset( $_POST['previd'] ) ? $_POST['previd'] : 0 ); + $nextid = absint( isset( $_POST['nextid'] ) ? $_POST['nextid'] : 0 ); + $menu_orders = wp_list_pluck( $wpdb->get_results( "SELECT ID, menu_order FROM {$wpdb->posts} WHERE post_type = 'product' ORDER BY menu_order ASC, post_title ASC" ), 'menu_order', 'ID' ); + $index = 0; + + foreach ( $menu_orders as $id => $menu_order ) { + $id = absint( $id ); + + if ( $sorting_id === $id ) { + continue; + } + if ( $nextid === $id ) { + $index ++; + } + $index ++; + $menu_orders[ $id ] = $index; + $wpdb->update( $wpdb->posts, array( 'menu_order' => $index ), array( 'ID' => $id ) ); + + /** + * When a single product has gotten it's ordering updated. + * $id The product ID + * $index The new menu order + */ + do_action( 'woocommerce_after_single_product_ordering', $id, $index ); + } + + if ( isset( $menu_orders[ $previd ] ) ) { + $menu_orders[ $sorting_id ] = $menu_orders[ $previd ] + 1; + } elseif ( isset( $menu_orders[ $nextid ] ) ) { + $menu_orders[ $sorting_id ] = $menu_orders[ $nextid ] - 1; + } else { + $menu_orders[ $sorting_id ] = 0; + } + + $wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_orders[ $sorting_id ] ), array( 'ID' => $sorting_id ) ); + + do_action( 'woocommerce_after_product_ordering', $sorting_id, $menu_orders ); + wp_send_json( $menu_orders ); + } + + /** + * Handle a refund via the edit order screen. + * + * @throws Exception To return errors. + */ + public static function refund_line_items() { + ob_start(); + + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $order_id = absint( $_POST['order_id'] ); + $refund_amount = wc_format_decimal( sanitize_text_field( wp_unslash( $_POST['refund_amount'] ) ), wc_get_price_decimals() ); + $refunded_amount = wc_format_decimal( sanitize_text_field( wp_unslash( $_POST['refunded_amount'] ) ), wc_get_price_decimals() ); + $refund_reason = sanitize_text_field( $_POST['refund_reason'] ); + $line_item_qtys = json_decode( sanitize_text_field( wp_unslash( $_POST['line_item_qtys'] ) ), true ); + $line_item_totals = json_decode( sanitize_text_field( wp_unslash( $_POST['line_item_totals'] ) ), true ); + $line_item_tax_totals = json_decode( sanitize_text_field( wp_unslash( $_POST['line_item_tax_totals'] ) ), true ); + $api_refund = 'true' === $_POST['api_refund']; + $restock_refunded_items = 'true' === $_POST['restock_refunded_items']; + $refund = false; + $response_data = array(); + + try { + $order = wc_get_order( $order_id ); + $order_items = $order->get_items(); + $max_refund = wc_format_decimal( $order->get_total() - $order->get_total_refunded(), wc_get_price_decimals() ); + + if ( ! $refund_amount || $max_refund < $refund_amount || 0 > $refund_amount ) { + throw new exception( __( 'Invalid refund amount', 'woocommerce' ) ); + } + + if ( $refunded_amount !== wc_format_decimal( $order->get_total_refunded(), wc_get_price_decimals() ) ) { + throw new exception( __( 'Error processing refund. Please try again.', 'woocommerce' ) ); + } + + // Prepare line items which we are refunding. + $line_items = array(); + $item_ids = array_unique( array_merge( array_keys( $line_item_qtys, $line_item_totals ) ) ); + + foreach ( $item_ids as $item_id ) { + $line_items[ $item_id ] = array( + 'qty' => 0, + 'refund_total' => 0, + 'refund_tax' => array(), + ); + } + foreach ( $line_item_qtys as $item_id => $qty ) { + $line_items[ $item_id ]['qty'] = max( $qty, 0 ); + } + foreach ( $line_item_totals as $item_id => $total ) { + $line_items[ $item_id ]['refund_total'] = wc_format_decimal( $total ); + } + foreach ( $line_item_tax_totals as $item_id => $tax_totals ) { + $line_items[ $item_id ]['refund_tax'] = array_filter( array_map( 'wc_format_decimal', $tax_totals ) ); + } + + // Create the refund object. + $refund = wc_create_refund( + array( + 'amount' => $refund_amount, + 'reason' => $refund_reason, + 'order_id' => $order_id, + 'line_items' => $line_items, + 'refund_payment' => $api_refund, + 'restock_items' => $restock_refunded_items, + ) + ); + + if ( is_wp_error( $refund ) ) { + throw new Exception( $refund->get_error_message() ); + } + + if ( did_action( 'woocommerce_order_fully_refunded' ) ) { + $response_data['status'] = 'fully_refunded'; + } + + wp_send_json_success( $response_data ); + + } catch ( Exception $e ) { + wp_send_json_error( array( 'error' => $e->getMessage() ) ); + } + } + + /** + * Delete a refund. + */ + public static function delete_refund() { + check_ajax_referer( 'order-item', 'security' ); + + if ( ! current_user_can( 'edit_shop_orders' ) ) { + wp_die( -1 ); + } + + $refund_ids = array_map( 'absint', is_array( $_POST['refund_id'] ) ? $_POST['refund_id'] : array( $_POST['refund_id'] ) ); + foreach ( $refund_ids as $refund_id ) { + if ( $refund_id && 'shop_order_refund' === get_post_type( $refund_id ) ) { + $refund = wc_get_order( $refund_id ); + $order_id = $refund->get_parent_id(); + $refund->delete( true ); + do_action( 'woocommerce_refund_deleted', $refund_id, $order_id ); + } + } + wp_die(); + } + + /** + * Triggered when clicking the rating footer. + */ + public static function rated() { + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_die( -1 ); + } + update_option( 'woocommerce_admin_footer_text_rated', 1 ); + wp_die(); + } + + /** + * Create/Update API key. + */ + public static function update_api_key() { + ob_start(); + + global $wpdb; + + check_ajax_referer( 'update-api-key', 'security' ); + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_die( -1 ); + } + + try { + if ( empty( $_POST['description'] ) ) { + throw new Exception( __( 'Description is missing.', 'woocommerce' ) ); + } + if ( empty( $_POST['user'] ) ) { + throw new Exception( __( 'User is missing.', 'woocommerce' ) ); + } + if ( empty( $_POST['permissions'] ) ) { + throw new Exception( __( 'Permissions is missing.', 'woocommerce' ) ); + } + + $key_id = absint( $_POST['key_id'] ); + $description = sanitize_text_field( wp_unslash( $_POST['description'] ) ); + $permissions = ( in_array( $_POST['permissions'], array( 'read', 'write', 'read_write' ) ) ) ? sanitize_text_field( $_POST['permissions'] ) : 'read'; + $user_id = absint( $_POST['user'] ); + + if ( 0 < $key_id ) { + $data = array( + 'user_id' => $user_id, + 'description' => $description, + 'permissions' => $permissions, + ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_api_keys', + $data, + array( 'key_id' => $key_id ), + array( + '%d', + '%s', + '%s', + ), + array( '%d' ) + ); + + $data['consumer_key'] = ''; + $data['consumer_secret'] = ''; + $data['message'] = __( 'API Key updated successfully.', 'woocommerce' ); + } else { + $consumer_key = 'ck_' . wc_rand_hash(); + $consumer_secret = 'cs_' . wc_rand_hash(); + + $data = array( + 'user_id' => $user_id, + 'description' => $description, + 'permissions' => $permissions, + 'consumer_key' => wc_api_hash( $consumer_key ), + 'consumer_secret' => $consumer_secret, + 'truncated_key' => substr( $consumer_key, -7 ), + ); + + $wpdb->insert( + $wpdb->prefix . 'woocommerce_api_keys', + $data, + array( + '%d', + '%s', + '%s', + '%s', + '%s', + '%s', + ) + ); + + $key_id = $wpdb->insert_id; + $data['consumer_key'] = $consumer_key; + $data['consumer_secret'] = $consumer_secret; + $data['message'] = __( 'API Key generated successfully. Make sure to copy your new keys now as the secret key will be hidden once you leave this page.', 'woocommerce' ); + $data['revoke_url'] = '' . __( 'Revoke key', 'woocommerce' ) . ''; + } + + wp_send_json_success( $data ); + } catch ( Exception $e ) { + wp_send_json_error( array( 'message' => $e->getMessage() ) ); + } + } + + /** + * Load variations via AJAX. + */ + public static function load_variations() { + ob_start(); + + check_ajax_referer( 'load-variations', 'security' ); + + if ( ! current_user_can( 'edit_products' ) || empty( $_POST['product_id'] ) ) { + wp_die( -1 ); + } + + // Set $post global so its available, like within the admin screens + global $post; + + $loop = 0; + $product_id = absint( $_POST['product_id'] ); + $post = get_post( $product_id ); + $product_object = wc_get_product( $product_id ); + $per_page = ! empty( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : 10; + $page = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; + $variations = wc_get_products( + array( + 'status' => array( 'private', 'publish' ), + 'type' => 'variation', + 'parent' => $product_id, + 'limit' => $per_page, + 'page' => $page, + 'orderby' => array( + 'menu_order' => 'ASC', + 'ID' => 'DESC', + ), + 'return' => 'objects', + ) + ); + + if ( $variations ) { + foreach ( $variations as $variation_object ) { + $variation_id = $variation_object->get_id(); + $variation = get_post( $variation_id ); + $variation_data = array_merge( array_map( 'maybe_unserialize', get_post_custom( $variation_id ) ), wc_get_product_variation_attributes( $variation_id ) ); // kept for BW compatibility. + include 'admin/meta-boxes/views/html-variation-admin.php'; + $loop++; + } + } + wp_die(); + } + + /** + * Save variations via AJAX. + */ + public static function save_variations() { + ob_start(); + + check_ajax_referer( 'save-variations', 'security' ); + + // Check permissions again and make sure we have what we need + if ( ! current_user_can( 'edit_products' ) || empty( $_POST ) || empty( $_POST['product_id'] ) ) { + wp_die( -1 ); + } + + $product_id = absint( $_POST['product_id'] ); + WC_Admin_Meta_Boxes::$meta_box_errors = array(); + WC_Meta_Box_Product_Data::save_variations( $product_id, get_post( $product_id ) ); + + do_action( 'woocommerce_ajax_save_product_variations', $product_id ); + + if ( $errors = WC_Admin_Meta_Boxes::$meta_box_errors ) { + echo '
      '; + + foreach ( $errors as $error ) { + echo '

      ' . wp_kses_post( $error ) . '

      '; + } + + echo ''; + echo '
      '; + + delete_option( 'woocommerce_meta_box_errors' ); + } + + wp_die(); + } + + /** + * Bulk action - Toggle Enabled. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_toggle_enabled( $variations, $data ) { + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + $variation->set_status( 'private' === $variation->get_status( 'edit' ) ? 'publish' : 'private' ); + $variation->save(); + } + } + + /** + * Bulk action - Toggle Downloadable Checkbox. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_toggle_downloadable( $variations, $data ) { + self::variation_bulk_toggle( $variations, 'downloadable' ); + } + + /** + * Bulk action - Toggle Virtual Checkbox. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_toggle_virtual( $variations, $data ) { + self::variation_bulk_toggle( $variations, 'virtual' ); + } + + /** + * Bulk action - Toggle Manage Stock Checkbox. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_toggle_manage_stock( $variations, $data ) { + self::variation_bulk_toggle( $variations, 'manage_stock' ); + } + + /** + * Bulk action - Set Regular Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_regular_price( $variations, $data ) { + self::variation_bulk_set( $variations, 'regular_price', $data['value'] ); + } + + /** + * Bulk action - Set Sale Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_sale_price( $variations, $data ) { + self::variation_bulk_set( $variations, 'sale_price', $data['value'] ); + } + + /** + * Bulk action - Set Stock Status as In Stock. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_stock_status_instock( $variations, $data ) { + self::variation_bulk_set( $variations, 'stock_status', 'instock' ); + } + + /** + * Bulk action - Set Stock Status as Out of Stock. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_stock_status_outofstock( $variations, $data ) { + self::variation_bulk_set( $variations, 'stock_status', 'outofstock' ); + } + + /** + * Bulk action - Set Stock Status as On Backorder. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_stock_status_onbackorder( $variations, $data ) { + self::variation_bulk_set( $variations, 'stock_status', 'onbackorder' ); + } + + /** + * Bulk action - Set Stock. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_stock( $variations, $data ) { + if ( ! isset( $data['value'] ) ) { + return; + } + + $quantity = wc_stock_amount( wc_clean( $data['value'] ) ); + + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + if ( $variation->managing_stock() ) { + $variation->set_stock_quantity( $quantity ); + } else { + $variation->set_stock_quantity( null ); + } + $variation->save(); + } + } + + /** + * Bulk action - Set Weight. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_weight( $variations, $data ) { + self::variation_bulk_set( $variations, 'weight', $data['value'] ); + } + + /** + * Bulk action - Set Length. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_length( $variations, $data ) { + self::variation_bulk_set( $variations, 'length', $data['value'] ); + } + + /** + * Bulk action - Set Width. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_width( $variations, $data ) { + self::variation_bulk_set( $variations, 'width', $data['value'] ); + } + + /** + * Bulk action - Set Height. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_height( $variations, $data ) { + self::variation_bulk_set( $variations, 'height', $data['value'] ); + } + + /** + * Bulk action - Set Download Limit. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_download_limit( $variations, $data ) { + self::variation_bulk_set( $variations, 'download_limit', $data['value'] ); + } + + /** + * Bulk action - Set Download Expiry. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_download_expiry( $variations, $data ) { + self::variation_bulk_set( $variations, 'download_expiry', $data['value'] ); + } + + /** + * Bulk action - Delete all. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_delete_all( $variations, $data ) { + if ( isset( $data['allowed'] ) && 'true' === $data['allowed'] ) { + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + $variation->delete( true ); + } + } + } + + /** + * Bulk action - Sale Schedule. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_sale_schedule( $variations, $data ) { + if ( ! isset( $data['date_from'] ) && ! isset( $data['date_to'] ) ) { + return; + } + + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + + if ( 'false' !== $data['date_from'] ) { + $variation->set_date_on_sale_from( wc_clean( $data['date_from'] ) ); + } + + if ( 'false' !== $data['date_to'] ) { + $variation->set_date_on_sale_to( wc_clean( $data['date_to'] ) ); + } + + $variation->save(); + } + } + + /** + * Bulk action - Increase Regular Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_regular_price_increase( $variations, $data ) { + self::variation_bulk_adjust_price( $variations, 'regular_price', '+', wc_clean( $data['value'] ) ); + } + + /** + * Bulk action - Decrease Regular Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_regular_price_decrease( $variations, $data ) { + self::variation_bulk_adjust_price( $variations, 'regular_price', '-', wc_clean( $data['value'] ) ); + } + + /** + * Bulk action - Increase Sale Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_sale_price_increase( $variations, $data ) { + self::variation_bulk_adjust_price( $variations, 'sale_price', '+', wc_clean( $data['value'] ) ); + } + + /** + * Bulk action - Decrease Sale Prices. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_sale_price_decrease( $variations, $data ) { + self::variation_bulk_adjust_price( $variations, 'sale_price', '-', wc_clean( $data['value'] ) ); + } + + /** + * Bulk action - Set Price. + * + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param string $operator + or - + * @param string $field price being adjusted _regular_price or _sale_price + * @param string $value Price or Percent + */ + private static function variation_bulk_adjust_price( $variations, $field, $operator, $value ) { + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + $field_value = $variation->{"get_$field"}( 'edit' ); + + if ( '%' === substr( $value, -1 ) ) { + $percent = wc_format_decimal( substr( $value, 0, -1 ) ); + $field_value += ( ( $field_value / 100 ) * $percent ) * "{$operator}1"; + } else { + $field_value += $value * "{$operator}1"; + } + + $variation->{"set_$field"}( $field_value ); + $variation->save(); + } + } + + /** + * Bulk set convenience function. + * + * @access private + * @param array $variations + * @param string $field + * @param string $value + */ + private static function variation_bulk_set( $variations, $field, $value ) { + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + $variation->{ "set_$field" }( wc_clean( $value ) ); + $variation->save(); + } + } + + /** + * Bulk toggle convenience function. + * + * @access private + * @param array $variations + * @param string $field + */ + private static function variation_bulk_toggle( $variations, $field ) { + foreach ( $variations as $variation_id ) { + $variation = wc_get_product( $variation_id ); + $prev_value = $variation->{ "get_$field" }( 'edit' ); + $variation->{ "set_$field" }( ! $prev_value ); + $variation->save(); + } + } + + /** + * Bulk edit variations via AJAX. + * + * @uses WC_AJAX::variation_bulk_set() + * @uses WC_AJAX::variation_bulk_adjust_price() + * @uses WC_AJAX::variation_bulk_action_variable_sale_price_decrease() + * @uses WC_AJAX::variation_bulk_action_variable_sale_price_increase() + * @uses WC_AJAX::variation_bulk_action_variable_regular_price_decrease() + * @uses WC_AJAX::variation_bulk_action_variable_regular_price_increase() + * @uses WC_AJAX::variation_bulk_action_variable_sale_schedule() + * @uses WC_AJAX::variation_bulk_action_delete_all() + * @uses WC_AJAX::variation_bulk_action_variable_download_expiry() + * @uses WC_AJAX::variation_bulk_action_variable_download_limit() + * @uses WC_AJAX::variation_bulk_action_variable_height() + * @uses WC_AJAX::variation_bulk_action_variable_width() + * @uses WC_AJAX::variation_bulk_action_variable_length() + * @uses WC_AJAX::variation_bulk_action_variable_weight() + * @uses WC_AJAX::variation_bulk_action_variable_stock() + * @uses WC_AJAX::variation_bulk_action_variable_sale_price() + * @uses WC_AJAX::variation_bulk_action_variable_regular_price() + * @uses WC_AJAX::variation_bulk_action_toggle_manage_stock() + * @uses WC_AJAX::variation_bulk_action_toggle_virtual() + * @uses WC_AJAX::variation_bulk_action_toggle_downloadable() + * @uses WC_AJAX::variation_bulk_action_toggle_enabled + */ + public static function bulk_edit_variations() { + ob_start(); + + check_ajax_referer( 'bulk-edit-variations', 'security' ); + + // Check permissions again and make sure we have what we need + if ( ! current_user_can( 'edit_products' ) || empty( $_POST['product_id'] ) || empty( $_POST['bulk_action'] ) ) { + wp_die( -1 ); + } + + $product_id = absint( $_POST['product_id'] ); + $bulk_action = wc_clean( $_POST['bulk_action'] ); + $data = ! empty( $_POST['data'] ) ? array_map( 'wc_clean', $_POST['data'] ) : array(); + $variations = array(); + + if ( apply_filters( 'woocommerce_bulk_edit_variations_need_children', true ) ) { + $variations = get_posts( + array( + 'post_parent' => $product_id, + 'posts_per_page' => -1, + 'post_type' => 'product_variation', + 'fields' => 'ids', + 'post_status' => array( 'publish', 'private' ), + ) + ); + } + + if ( method_exists( __CLASS__, "variation_bulk_action_$bulk_action" ) ) { + call_user_func( array( __CLASS__, "variation_bulk_action_$bulk_action" ), $variations, $data ); + } else { + do_action( 'woocommerce_bulk_edit_variations_default', $bulk_action, $data, $product_id, $variations ); + } + + do_action( 'woocommerce_bulk_edit_variations', $bulk_action, $data, $product_id, $variations ); + WC_Product_Variable::sync( $product_id ); + wc_delete_product_transients( $product_id ); + wp_die(); + } + + /** + * Handle submissions from assets/js/settings-views-html-settings-tax.js Backbone model. + */ + public static function tax_rates_save_changes() { + if ( ! isset( $_POST['wc_tax_nonce'], $_POST['changes'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + $current_class = ! empty( $_POST['current_class'] ) ? $_POST['current_class'] : ''; // This is sanitized seven lines later. + + if ( ! wp_verify_nonce( $_POST['wc_tax_nonce'], 'wc_tax_nonce-class:' . $current_class ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + $current_class = WC_Tax::format_tax_rate_class( $current_class ); + + // Check User Caps + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + $changes = $_POST['changes']; + foreach ( $changes as $tax_rate_id => $data ) { + if ( isset( $data['deleted'] ) ) { + if ( isset( $data['newRow'] ) ) { + // So the user added and deleted a new row. + // That's fine, it's not in the database anyways. NEXT! + continue; + } + WC_Tax::_delete_tax_rate( $tax_rate_id ); + } + + $tax_rate = array_intersect_key( + $data, array( + 'tax_rate_country' => 1, + 'tax_rate_state' => 1, + 'tax_rate' => 1, + 'tax_rate_name' => 1, + 'tax_rate_priority' => 1, + 'tax_rate_compound' => 1, + 'tax_rate_shipping' => 1, + 'tax_rate_order' => 1, + ) + ); + + if ( isset( $tax_rate['tax_rate'] ) ) { + $tax_rate['tax_rate'] = wc_format_decimal( $tax_rate['tax_rate'] ); + } + + if ( isset( $data['newRow'] ) ) { + $tax_rate['tax_rate_class'] = $current_class; + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); + } elseif ( ! empty( $tax_rate ) ) { + WC_Tax::_update_tax_rate( $tax_rate_id, $tax_rate ); + } + + if ( isset( $data['postcode'] ) ) { + $postcode = array_map( 'wc_clean', $data['postcode'] ); + $postcode = array_map( 'wc_normalize_postcode', $postcode ); + WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, $postcode ); + } + if ( isset( $data['city'] ) ) { + WC_Tax::_update_tax_rate_cities( $tax_rate_id, array_map( 'wc_clean', $data['city'] ) ); + } + } + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + WC_Cache_Helper::get_transient_version( 'shipping', true ); + + wp_send_json_success( + array( + 'rates' => WC_Tax::get_rates_for_tax_class( $current_class ), + ) + ); + } + + /** + * Handle submissions from assets/js/wc-shipping-zones.js Backbone model. + */ + public static function shipping_zones_save_changes() { + if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['changes'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + if ( ! wp_verify_nonce( $_POST['wc_shipping_zones_nonce'], 'wc_shipping_zones_nonce' ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + // Check User Caps + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + $changes = $_POST['changes']; + foreach ( $changes as $zone_id => $data ) { + if ( isset( $data['deleted'] ) ) { + if ( isset( $data['newRow'] ) ) { + // So the user added and deleted a new row. + // That's fine, it's not in the database anyways. NEXT! + continue; + } + WC_Shipping_Zones::delete_zone( $zone_id ); + continue; + } + + $zone_data = array_intersect_key( + $data, array( + 'zone_id' => 1, + 'zone_order' => 1, + ) + ); + + if ( isset( $zone_data['zone_id'] ) ) { + $zone = new WC_Shipping_Zone( $zone_data['zone_id'] ); + + if ( isset( $zone_data['zone_order'] ) ) { + $zone->set_zone_order( $zone_data['zone_order'] ); + } + + $zone->save(); + } + } + + wp_send_json_success( + array( + 'zones' => WC_Shipping_Zones::get_zones( 'json' ), + ) + ); + } + + /** + * Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model. + */ + public static function shipping_zone_add_method() { + if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['zone_id'], $_POST['method_id'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + if ( ! wp_verify_nonce( $_POST['wc_shipping_zones_nonce'], 'wc_shipping_zones_nonce' ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + // Check User Caps + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + $zone_id = wc_clean( $_POST['zone_id'] ); + $zone = new WC_Shipping_Zone( $zone_id ); + $instance_id = $zone->add_shipping_method( wc_clean( $_POST['method_id'] ) ); + + wp_send_json_success( + array( + 'instance_id' => $instance_id, + 'zone_id' => $zone->get_id(), + 'zone_name' => $zone->get_zone_name(), + 'methods' => $zone->get_shipping_methods( false, 'json' ), + ) + ); + } + + /** + * Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model. + */ + public static function shipping_zone_methods_save_changes() { + if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['zone_id'], $_POST['changes'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + if ( ! wp_verify_nonce( $_POST['wc_shipping_zones_nonce'], 'wc_shipping_zones_nonce' ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + global $wpdb; + + $zone_id = wc_clean( $_POST['zone_id'] ); + $zone = new WC_Shipping_Zone( $zone_id ); + $changes = $_POST['changes']; + + if ( isset( $changes['zone_name'] ) ) { + $zone->set_zone_name( wc_clean( $changes['zone_name'] ) ); + } + + if ( isset( $changes['zone_locations'] ) ) { + $zone->clear_locations( array( 'state', 'country', 'continent' ) ); + $locations = array_filter( array_map( 'wc_clean', (array) $changes['zone_locations'] ) ); + foreach ( $locations as $location ) { + // Each posted location will be in the format type:code + $location_parts = explode( ':', $location ); + switch ( $location_parts[0] ) { + case 'state': + $zone->add_location( $location_parts[1] . ':' . $location_parts[2], 'state' ); + break; + case 'country': + $zone->add_location( $location_parts[1], 'country' ); + break; + case 'continent': + $zone->add_location( $location_parts[1], 'continent' ); + break; + } + } + } + + if ( isset( $changes['zone_postcodes'] ) ) { + $zone->clear_locations( 'postcode' ); + $postcodes = array_filter( array_map( 'strtoupper', array_map( 'wc_clean', explode( "\n", $changes['zone_postcodes'] ) ) ) ); + foreach ( $postcodes as $postcode ) { + $zone->add_location( $postcode, 'postcode' ); + } + } + + if ( isset( $changes['methods'] ) ) { + foreach ( $changes['methods'] as $instance_id => $data ) { + $method_id = $wpdb->get_var( $wpdb->prepare( "SELECT method_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE instance_id = %d", $instance_id ) ); + + if ( isset( $data['deleted'] ) ) { + $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id ); + $option_key = $shipping_method->get_instance_option_key(); + if ( $wpdb->delete( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'instance_id' => $instance_id ) ) ) { + delete_option( $option_key ); + do_action( 'woocommerce_shipping_zone_method_deleted', $instance_id, $method_id, $zone_id ); + } + continue; + } + + $method_data = array_intersect_key( + $data, array( + 'method_order' => 1, + 'enabled' => 1, + ) + ); + + if ( isset( $method_data['method_order'] ) ) { + $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'method_order' => absint( $method_data['method_order'] ) ), array( 'instance_id' => absint( $instance_id ) ) ); + } + + if ( isset( $method_data['enabled'] ) ) { + $is_enabled = absint( 'yes' === $method_data['enabled'] ); + if ( $wpdb->update( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'is_enabled' => $is_enabled ), array( 'instance_id' => absint( $instance_id ) ) ) ) { + do_action( 'woocommerce_shipping_zone_method_status_toggled', $instance_id, $method_id, $zone_id, $is_enabled ); + } + } + } + } + + $zone->save(); + + wp_send_json_success( + array( + 'zone_id' => $zone->get_id(), + 'zone_name' => $zone->get_zone_name(), + 'methods' => $zone->get_shipping_methods( false, 'json' ), + ) + ); + } + + /** + * Save method settings + */ + public static function shipping_zone_methods_save_settings() { + if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['instance_id'], $_POST['data'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + if ( ! wp_verify_nonce( $_POST['wc_shipping_zones_nonce'], 'wc_shipping_zones_nonce' ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + $instance_id = absint( $_POST['instance_id'] ); + $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id ); + $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id ); + $shipping_method->set_post_data( $_POST['data'] ); + $shipping_method->process_admin_options(); + + WC_Cache_Helper::get_transient_version( 'shipping', true ); + + wp_send_json_success( + array( + 'zone_id' => $zone->get_id(), + 'zone_name' => $zone->get_zone_name(), + 'methods' => $zone->get_shipping_methods( false, 'json' ), + 'errors' => $shipping_method->get_errors(), + ) + ); + } + + /** + * Handle submissions from assets/js/wc-shipping-classes.js Backbone model. + */ + public static function shipping_classes_save_changes() { + if ( ! isset( $_POST['wc_shipping_classes_nonce'], $_POST['changes'] ) ) { + wp_send_json_error( 'missing_fields' ); + wp_die(); + } + + if ( ! wp_verify_nonce( $_POST['wc_shipping_classes_nonce'], 'wc_shipping_classes_nonce' ) ) { + wp_send_json_error( 'bad_nonce' ); + wp_die(); + } + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + wp_send_json_error( 'missing_capabilities' ); + wp_die(); + } + + $changes = $_POST['changes']; + + foreach ( $changes as $term_id => $data ) { + $term_id = absint( $term_id ); + + if ( isset( $data['deleted'] ) ) { + if ( isset( $data['newRow'] ) ) { + // So the user added and deleted a new row. + // That's fine, it's not in the database anyways. NEXT! + continue; + } + wp_delete_term( $term_id, 'product_shipping_class' ); + continue; + } + + $update_args = array(); + + if ( isset( $data['name'] ) ) { + $update_args['name'] = wc_clean( $data['name'] ); + } + + if ( isset( $data['slug'] ) ) { + $update_args['slug'] = wc_clean( $data['slug'] ); + } + + if ( isset( $data['description'] ) ) { + $update_args['description'] = wc_clean( $data['description'] ); + } + + if ( isset( $data['newRow'] ) ) { + $update_args = array_filter( $update_args ); + if ( empty( $update_args['name'] ) ) { + continue; + } + $inserted_term = wp_insert_term( $update_args['name'], 'product_shipping_class', $update_args ); + $term_id = is_wp_error( $inserted_term ) ? 0 : $inserted_term['term_id']; + } else { + wp_update_term( $term_id, 'product_shipping_class', $update_args ); + } + + do_action( 'woocommerce_shipping_classes_save_class', $term_id, $data ); + } + + $wc_shipping = WC_Shipping::instance(); + + wp_send_json_success( + array( + 'shipping_classes' => $wc_shipping->get_shipping_classes(), + ) + ); + } + + /** + * Toggle payment gateway on or off via AJAX. + * + * @since 3.4.0 + */ + public static function toggle_gateway_enabled() { + if ( current_user_can( 'manage_woocommerce' ) && check_ajax_referer( 'woocommerce-toggle-payment-gateway-enabled', 'security' ) ) { + // Load gateways. + $payment_gateways = WC()->payment_gateways->payment_gateways(); + + // Get posted gateway. + $gateway_id = wc_clean( wp_unslash( $_POST['gateway_id'] ) ); + + foreach ( $payment_gateways as $gateway ) { + if ( ! in_array( $gateway_id, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) { + continue; + } + $enabled = $gateway->get_option( 'enabled', 'no' ); + + if ( ! wc_string_to_bool( $enabled ) ) { + if ( $gateway->needs_setup() ) { + wp_send_json_error( 'needs_setup' ); + wp_die(); + } else { + $gateway->update_option( 'enabled', 'yes' ); + } + } else { + // Disable the gateway. + $gateway->update_option( 'enabled', 'no' ); + } + + wp_send_json_success( ! wc_string_to_bool( $enabled ) ); + wp_die(); + } + } + + wp_send_json_error( 'invalid_gateway_id' ); + wp_die(); + } +} + +WC_AJAX::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-api.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-api.php new file mode 100644 index 0000000..286a1e9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-api.php @@ -0,0 +1,292 @@ +rest_api_init(); + } + + /** + * Add new query vars. + * + * @since 2.0 + * @param array $vars Query vars. + * @return string[] + */ + public function add_query_vars( $vars ) { + $vars = parent::add_query_vars( $vars ); + $vars[] = 'wc-api'; + return $vars; + } + + /** + * WC API for payment gateway IPNs, etc. + * + * @since 2.0 + */ + public static function add_endpoint() { + parent::add_endpoint(); + add_rewrite_endpoint( 'wc-api', EP_ALL ); + } + + /** + * API request - Trigger any API requests. + * + * @since 2.0 + * @version 2.4 + */ + public function handle_api_requests() { + global $wp; + + if ( ! empty( $_GET['wc-api'] ) ) { // WPCS: input var okay, CSRF ok. + $wp->query_vars['wc-api'] = sanitize_key( wp_unslash( $_GET['wc-api'] ) ); // WPCS: input var okay, CSRF ok. + } + + // wc-api endpoint requests. + if ( ! empty( $wp->query_vars['wc-api'] ) ) { + + // Buffer, we won't want any output here. + ob_start(); + + // No cache headers. + wc_nocache_headers(); + + // Clean the API request. + $api_request = strtolower( wc_clean( $wp->query_vars['wc-api'] ) ); + + // Trigger generic action before request hook. + do_action( 'woocommerce_api_request', $api_request ); + + // Is there actually something hooked into this API request? If not trigger 400 - Bad request. + status_header( has_action( 'woocommerce_api_' . $api_request ) ? 200 : 400 ); + + // Trigger an action which plugins can hook into to fulfill the request. + do_action( 'woocommerce_api_' . $api_request ); + + // Done, clear buffer and exit. + ob_end_clean(); + die( '-1' ); + } + } + + /** + * Init WP REST API. + * + * @since 2.6.0 + */ + private function rest_api_init() { + // REST API was included starting WordPress 4.4. + if ( ! class_exists( 'WP_REST_Server' ) ) { + return; + } + + $this->rest_api_includes(); + + // Init REST API routes. + add_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 ); + } + + /** + * Include REST API classes. + * + * @since 2.6.0 + */ + private function rest_api_includes() { + // Exception handler. + include_once dirname( __FILE__ ) . '/api/class-wc-rest-exception.php'; + + // Authentication. + include_once dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php'; + + // Abstract controllers. + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-controller.php'; + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-posts-controller.php'; + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-crud-controller.php'; + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php'; + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php'; + include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php'; + + // REST API v1 controllers. + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries-controller.php'; + include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php'; + + // Legacy v2 code. + include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php'; + include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php'; + include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php'; + + // REST API v2 controllers. + include_once dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-network-orders-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-reports-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-settings-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-setting-options-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zones-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-locations-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-methods-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-tax-classes-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-taxes-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-webhook-deliveries-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php'; + include_once dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php'; + } + + /** + * Register REST API routes. + * + * @since 2.6.0 + */ + public function register_rest_routes() { + // Register settings to the REST API. + $this->register_wp_admin_settings(); + + $controllers = array( + // v1 controllers. + 'WC_REST_Coupons_V1_Controller', + 'WC_REST_Customer_Downloads_V1_Controller', + 'WC_REST_Customers_V1_Controller', + 'WC_REST_Order_Notes_V1_Controller', + 'WC_REST_Order_Refunds_V1_Controller', + 'WC_REST_Orders_V1_Controller', + 'WC_REST_Product_Attribute_Terms_V1_Controller', + 'WC_REST_Product_Attributes_V1_Controller', + 'WC_REST_Product_Categories_V1_Controller', + 'WC_REST_Product_Reviews_V1_Controller', + 'WC_REST_Product_Shipping_Classes_V1_Controller', + 'WC_REST_Product_Tags_V1_Controller', + 'WC_REST_Products_V1_Controller', + 'WC_REST_Report_Sales_V1_Controller', + 'WC_REST_Report_Top_Sellers_V1_Controller', + 'WC_REST_Reports_V1_Controller', + 'WC_REST_Tax_Classes_V1_Controller', + 'WC_REST_Taxes_V1_Controller', + 'WC_REST_Webhook_Deliveries_V1_Controller', + 'WC_REST_Webhooks_V1_Controller', + + // v2 controllers. + 'WC_REST_Coupons_Controller', + 'WC_REST_Customer_Downloads_Controller', + 'WC_REST_Customers_Controller', + 'WC_REST_Network_Orders_Controller', + 'WC_REST_Order_Notes_Controller', + 'WC_REST_Order_Refunds_Controller', + 'WC_REST_Orders_Controller', + 'WC_REST_Product_Attribute_Terms_Controller', + 'WC_REST_Product_Attributes_Controller', + 'WC_REST_Product_Categories_Controller', + 'WC_REST_Product_Reviews_Controller', + 'WC_REST_Product_Shipping_Classes_Controller', + 'WC_REST_Product_Tags_Controller', + 'WC_REST_Products_Controller', + 'WC_REST_Product_Variations_Controller', + 'WC_REST_Report_Sales_Controller', + 'WC_REST_Report_Top_Sellers_Controller', + 'WC_REST_Reports_Controller', + 'WC_REST_Settings_Controller', + 'WC_REST_Setting_Options_Controller', + 'WC_REST_Shipping_Zones_Controller', + 'WC_REST_Shipping_Zone_Locations_Controller', + 'WC_REST_Shipping_Zone_Methods_Controller', + 'WC_REST_Tax_Classes_Controller', + 'WC_REST_Taxes_Controller', + 'WC_REST_Webhook_Deliveries_Controller', + 'WC_REST_Webhooks_Controller', + 'WC_REST_System_Status_Controller', + 'WC_REST_System_Status_Tools_Controller', + 'WC_REST_Shipping_Methods_Controller', + 'WC_REST_Payment_Gateways_Controller', + ); + + foreach ( $controllers as $controller ) { + $this->$controller = new $controller(); + $this->$controller->register_routes(); + } + } + + /** + * Register WC settings from WP-API to the REST API. + * + * @since 3.0.0 + */ + public function register_wp_admin_settings() { + $pages = WC_Admin_Settings::get_settings_pages(); + foreach ( $pages as $page ) { + new WC_Register_WP_Admin_Settings( $page, 'page' ); + } + + $emails = WC_Emails::instance(); + foreach ( $emails->get_emails() as $email ) { + new WC_Register_WP_Admin_Settings( $email, 'email' ); + } + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-auth.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-auth.php new file mode 100644 index 0000000..33d05a7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-auth.php @@ -0,0 +1,424 @@ + __( 'Read', 'woocommerce' ), + 'write' => __( 'Write', 'woocommerce' ), + 'read_write' => __( 'Read/Write', 'woocommerce' ), + ); + + return $permissions[ $scope ]; + } + + /** + * Return a list of permissions a scope allows. + * + * @since 2.4.0 + * @param string $scope Permission scope. + * @return array + */ + protected function get_permissions_in_scope( $scope ) { + $permissions = array(); + switch ( $scope ) { + case 'read': + $permissions[] = __( 'View coupons', 'woocommerce' ); + $permissions[] = __( 'View customers', 'woocommerce' ); + $permissions[] = __( 'View orders and sales reports', 'woocommerce' ); + $permissions[] = __( 'View products', 'woocommerce' ); + break; + case 'write': + $permissions[] = __( 'Create webhooks', 'woocommerce' ); + $permissions[] = __( 'Create coupons', 'woocommerce' ); + $permissions[] = __( 'Create customers', 'woocommerce' ); + $permissions[] = __( 'Create orders', 'woocommerce' ); + $permissions[] = __( 'Create products', 'woocommerce' ); + break; + case 'read_write': + $permissions[] = __( 'Create webhooks', 'woocommerce' ); + $permissions[] = __( 'View and manage coupons', 'woocommerce' ); + $permissions[] = __( 'View and manage customers', 'woocommerce' ); + $permissions[] = __( 'View and manage orders and sales reports', 'woocommerce' ); + $permissions[] = __( 'View and manage products', 'woocommerce' ); + break; + } + return apply_filters( 'woocommerce_api_permissions_in_scope', $permissions, $scope ); + } + + /** + * Build auth urls. + * + * @since 2.4.0 + * @param array $data Data to build URL. + * @param string $endpoint Endpoint. + * @return string + */ + protected function build_url( $data, $endpoint ) { + $url = wc_get_endpoint_url( 'wc-auth/v' . self::VERSION, $endpoint, home_url( '/' ) ); + + return add_query_arg( + array( + 'app_name' => wc_clean( $data['app_name'] ), + 'user_id' => wc_clean( $data['user_id'] ), + 'return_url' => rawurlencode( $this->get_formatted_url( $data['return_url'] ) ), + 'callback_url' => rawurlencode( $this->get_formatted_url( $data['callback_url'] ) ), + 'scope' => wc_clean( $data['scope'] ), + ), $url + ); + } + + /** + * Decode and format a URL. + * + * @param string $url URL. + * @return string + */ + protected function get_formatted_url( $url ) { + $url = urldecode( $url ); + + if ( ! strstr( $url, '://' ) ) { + $url = 'https://' . $url; + } + + return $url; + } + + /** + * Make validation. + * + * @since 2.4.0 + * @throws Exception When validate fails. + */ + protected function make_validation() { + $data = array(); + $params = array( + 'app_name', + 'user_id', + 'return_url', + 'callback_url', + 'scope', + ); + + foreach ( $params as $param ) { + if ( empty( $_REQUEST[ $param ] ) ) { // WPCS: input var ok, CSRF ok. + /* translators: %s: parameter */ + throw new Exception( sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param ) ); + } + + $data[ $param ] = wp_unslash( $_REQUEST[ $param ] ); // WPCS: input var ok, CSRF ok, sanitization ok. + } + + if ( ! in_array( $data['scope'], array( 'read', 'write', 'read_write' ), true ) ) { + /* translators: %s: scope */ + throw new Exception( sprintf( __( 'Invalid scope %s', 'woocommerce' ), wc_clean( $data['scope'] ) ) ); + } + + foreach ( array( 'return_url', 'callback_url' ) as $param ) { + $param = $this->get_formatted_url( $data[ $param ] ); + + if ( false === filter_var( $param, FILTER_VALIDATE_URL ) ) { + /* translators: %s: url */ + throw new Exception( sprintf( __( 'The %s is not a valid URL', 'woocommerce' ), $param ) ); + } + } + + $callback_url = $this->get_formatted_url( $data['callback_url'] ); + + if ( 0 !== stripos( $callback_url, 'https://' ) ) { + throw new Exception( __( 'The callback_url needs to be over SSL', 'woocommerce' ) ); + } + } + + /** + * Create keys. + * + * @since 2.4.0 + * + * @param string $app_name App name. + * @param string $app_user_id User ID. + * @param string $scope Scope. + * + * @return array + */ + protected function create_keys( $app_name, $app_user_id, $scope ) { + global $wpdb; + + $description = sprintf( + /* translators: 1: app name 2: scope 3: date 4: time */ + __( '%1$s - API %2$s (created on %3$s at %4$s).', 'woocommerce' ), + wc_clean( $app_name ), + $this->get_i18n_scope( $scope ), + date_i18n( wc_date_format() ), + date_i18n( wc_time_format() ) + ); + $user = wp_get_current_user(); + + // Created API keys. + $permissions = in_array( $scope, array( 'read', 'write', 'read_write' ), true ) ? sanitize_text_field( $scope ) : 'read'; + $consumer_key = 'ck_' . wc_rand_hash(); + $consumer_secret = 'cs_' . wc_rand_hash(); + + $wpdb->insert( + $wpdb->prefix . 'woocommerce_api_keys', + array( + 'user_id' => $user->ID, + 'description' => $description, + 'permissions' => $permissions, + 'consumer_key' => wc_api_hash( $consumer_key ), + 'consumer_secret' => $consumer_secret, + 'truncated_key' => substr( $consumer_key, -7 ), + ), + array( + '%d', + '%s', + '%s', + '%s', + '%s', + '%s', + ) + ); + + return array( + 'key_id' => $wpdb->insert_id, + 'user_id' => $app_user_id, + 'consumer_key' => $consumer_key, + 'consumer_secret' => $consumer_secret, + 'key_permissions' => $permissions, + ); + } + + /** + * Post consumer data. + * + * @since 2.4.0 + * + * @throws Exception When validation fails. + * @param array $consumer_data Consumer data. + * @param string $url URL. + * @return bool + */ + protected function post_consumer_data( $consumer_data, $url ) { + $params = array( + 'body' => wp_json_encode( $consumer_data ), + 'timeout' => 60, + 'headers' => array( + 'Content-Type' => 'application/json;charset=' . get_bloginfo( 'charset' ), + ), + ); + + $response = wp_safe_remote_post( esc_url_raw( $url ), $params ); + + if ( is_wp_error( $response ) ) { + throw new Exception( $response->get_error_message() ); + } elseif ( 200 !== intval( $response['response']['code'] ) ) { + throw new Exception( __( 'An error occurred in the request and at the time were unable to send the consumer data', 'woocommerce' ) ); + } + + return true; + } + + /** + * Handle auth requests. + * + * @since 2.4.0 + */ + public function handle_auth_requests() { + global $wp; + + if ( ! empty( $_GET['wc-auth-version'] ) ) { // WPCS: input var ok, CSRF ok. + $wp->query_vars['wc-auth-version'] = wc_clean( wp_unslash( $_GET['wc-auth-version'] ) ); // WPCS: input var ok, CSRF ok. + } + + if ( ! empty( $_GET['wc-auth-route'] ) ) { + $wp->query_vars['wc-auth-route'] = wc_clean( wp_unslash( $_GET['wc-auth-route'] ) ); // WPCS: input var ok, CSRF ok. + } + + // wc-auth endpoint requests. + if ( ! empty( $wp->query_vars['wc-auth-version'] ) && ! empty( $wp->query_vars['wc-auth-route'] ) ) { + $this->auth_endpoint( $wp->query_vars['wc-auth-route'] ); + } + } + + /** + * Auth endpoint. + * + * @since 2.4.0 + * @throws Exception When validation fails. + * @param string $route Route. + */ + protected function auth_endpoint( $route ) { + ob_start(); + + $consumer_data = array(); + + try { + if ( 'yes' !== get_option( 'woocommerce_api_enabled' ) ) { + throw new Exception( __( 'API disabled!', 'woocommerce' ) ); + } + + $route = strtolower( wc_clean( $route ) ); + $this->make_validation(); + + $data = wp_unslash( $_REQUEST ); // WPCS: input var ok, CSRF ok. + + // Login endpoint. + if ( 'login' === $route && ! is_user_logged_in() ) { + wc_get_template( + 'auth/form-login.php', array( + 'app_name' => wc_clean( $data['app_name'] ), + 'return_url' => add_query_arg( + array( + 'success' => 0, + 'user_id' => wc_clean( $data['user_id'] ), + ), $this->get_formatted_url( $data['return_url'] ) + ), + 'redirect_url' => $this->build_url( $data, 'authorize' ), + ) + ); + exit; + + } elseif ( 'login' === $route && is_user_logged_in() ) { + // Redirect with user is logged in. + wp_redirect( esc_url_raw( $this->build_url( $data, 'authorize' ) ) ); + exit; + + } elseif ( 'authorize' === $route && ! is_user_logged_in() ) { + // Redirect with user is not logged in and trying to access the authorize endpoint. + wp_redirect( esc_url_raw( $this->build_url( $data, 'login' ) ) ); + exit; + + } elseif ( 'authorize' === $route && current_user_can( 'manage_woocommerce' ) ) { + // Authorize endpoint. + wc_get_template( + 'auth/form-grant-access.php', array( + 'app_name' => wc_clean( $data['app_name'] ), + 'return_url' => add_query_arg( + array( + 'success' => 0, + 'user_id' => wc_clean( $data['user_id'] ), + ), $this->get_formatted_url( $data['return_url'] ) + ), + 'scope' => $this->get_i18n_scope( wc_clean( $data['scope'] ) ), + 'permissions' => $this->get_permissions_in_scope( wc_clean( $data['scope'] ) ), + 'granted_url' => wp_nonce_url( $this->build_url( $data, 'access_granted' ), 'wc_auth_grant_access', 'wc_auth_nonce' ), + 'logout_url' => wp_logout_url( $this->build_url( $data, 'login' ) ), + 'user' => wp_get_current_user(), + ) + ); + exit; + + } elseif ( 'access_granted' === $route && current_user_can( 'manage_woocommerce' ) ) { + // Granted access endpoint. + if ( ! isset( $_GET['wc_auth_nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['wc_auth_nonce'] ) ), 'wc_auth_grant_access' ) ) { // WPCS: input var ok. + throw new Exception( __( 'Invalid nonce verification', 'woocommerce' ) ); + } + + $consumer_data = $this->create_keys( $data['app_name'], $data['user_id'], $data['scope'] ); + $response = $this->post_consumer_data( $consumer_data, $this->get_formatted_url( $data['callback_url'] ) ); + + if ( $response ) { + wp_redirect( + esc_url_raw( + add_query_arg( + array( + 'success' => 1, + 'user_id' => wc_clean( $data['user_id'] ), + ), $this->get_formatted_url( $data['return_url'] ) + ) + ) + ); + exit; + } + } else { + throw new Exception( __( 'You do not have permission to access this page', 'woocommerce' ) ); + } + } catch ( Exception $e ) { + $this->maybe_delete_key( $consumer_data ); + + /* translators: %s: error message */ + wp_die( sprintf( esc_html__( 'Error: %s.', 'woocommerce' ), esc_html( $e->getMessage() ) ), esc_html__( 'Access denied', 'woocommerce' ), array( 'response' => 401 ) ); + } + } + + /** + * Maybe delete key. + * + * @since 2.4.0 + * + * @param array $key Key. + */ + private function maybe_delete_key( $key ) { + global $wpdb; + + if ( isset( $key['key_id'] ) ) { + $wpdb->delete( $wpdb->prefix . 'woocommerce_api_keys', array( 'key_id' => $key['key_id'] ), array( '%d' ) ); + } + } +} +new WC_Auth(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-autoloader.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-autoloader.php new file mode 100644 index 0000000..dd28741 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-autoloader.php @@ -0,0 +1,99 @@ +include_path = untrailingslashit( plugin_dir_path( WC_PLUGIN_FILE ) ) . '/includes/'; + } + + /** + * Take a class name and turn it into a file name. + * + * @param string $class Class name. + * @return string + */ + private function get_file_name_from_class( $class ) { + return 'class-' . str_replace( '_', '-', $class ) . '.php'; + } + + /** + * Include a class file. + * + * @param string $path File path. + * @return bool Successful or not. + */ + private function load_file( $path ) { + if ( $path && is_readable( $path ) ) { + include_once $path; + return true; + } + return false; + } + + /** + * Auto-load WC classes on demand to reduce memory consumption. + * + * @param string $class Class name. + */ + public function autoload( $class ) { + $class = strtolower( $class ); + + if ( 0 !== strpos( $class, 'wc_' ) ) { + return; + } + + $file = $this->get_file_name_from_class( $class ); + $path = ''; + + if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) { + $path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 18 ) . '/'; + } elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) { + $path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 11 ) . '/'; + } elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) { + $path = $this->include_path . 'shipping/' . substr( str_replace( '_', '-', $class ), 12 ) . '/'; + } elseif ( 0 === strpos( $class, 'wc_shortcode_' ) ) { + $path = $this->include_path . 'shortcodes/'; + } elseif ( 0 === strpos( $class, 'wc_meta_box' ) ) { + $path = $this->include_path . 'admin/meta-boxes/'; + } elseif ( 0 === strpos( $class, 'wc_admin' ) ) { + $path = $this->include_path . 'admin/'; + } elseif ( 0 === strpos( $class, 'wc_payment_token_' ) ) { + $path = $this->include_path . 'payment-tokens/'; + } elseif ( 0 === strpos( $class, 'wc_log_handler_' ) ) { + $path = $this->include_path . 'log-handlers/'; + } + + if ( empty( $path ) || ! $this->load_file( $path . $file ) ) { + $this->load_file( $this->include_path . $file ); + } + } +} + +new WC_Autoloader(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-background-emailer.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-background-emailer.php new file mode 100644 index 0000000..ecd1436 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-background-emailer.php @@ -0,0 +1,184 @@ +prefix = 'wp_' . get_current_blog_id(); + $this->action = 'wc_emailer'; + + // Dispatch queue after shutdown. + add_action( 'shutdown', array( $this, 'dispatch_queue' ), 100 ); + + parent::__construct(); + } + + /** + * Schedule fallback event. + */ + protected function schedule_event() { + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { + wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); + } + } + + /** + * Task + * + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param array $callback Update callback function. + * @return mixed + */ + protected function task( $callback ) { + if ( isset( $callback['filter'], $callback['args'] ) ) { + try { + WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] ); + } catch ( Exception $e ) { + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + } + } + } + return false; + } + + /** + * Finishes replying to the client, but keeps the process running for further (async) code execution. + * + * @see https://core.trac.wordpress.org/ticket/41358 . + */ + protected function close_http_connection() { + // Only 1 PHP process can access a session object at a time, close this so the next request isn't kept waiting. + // @codingStandardsIgnoreStart + if ( session_id() ) { + session_write_close(); + } + // @codingStandardsIgnoreEnd + + wc_set_time_limit( 0 ); + + // fastcgi_finish_request is the cleanest way to send the response and keep the script running, but not every server has it. + if ( is_callable( 'fastcgi_finish_request' ) ) { + fastcgi_finish_request(); + } else { + // Fallback: send headers and flush buffers. + if ( ! headers_sent() ) { + header( 'Connection: close' ); + } + @ob_end_flush(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + flush(); + } + } + + /** + * Save and run queue. + */ + public function dispatch_queue() { + if ( ! empty( $this->data ) ) { + $this->close_http_connection(); + $this->save()->dispatch(); + } + } + + /** + * Get post args + * + * @return array + */ + protected function get_post_args() { + if ( property_exists( $this, 'post_args' ) ) { + return $this->post_args; + } + + // Pass cookies through with the request so nonces function. + $cookies = array(); + + foreach ( $_COOKIE as $name => $value ) { // WPCS: input var ok. + if ( 'PHPSESSID' === $name ) { + continue; + } + $cookies[] = new WP_Http_Cookie( array( + 'name' => $name, + 'value' => $value, + ) ); + } + + return array( + 'timeout' => 0.01, + 'blocking' => false, + 'body' => $this->data, + 'cookies' => $cookies, + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), + ); + } + + /** + * Handle + * + * Pass each queue item to the task handler, while remaining + * within server memory and time limit constraints. + */ + protected function handle() { + $this->lock_process(); + + do { + $batch = $this->get_batch(); + + if ( empty( $batch->data ) ) { + break; + } + + foreach ( $batch->data as $key => $value ) { + $task = $this->task( $value ); + + if ( false !== $task ) { + $batch->data[ $key ] = $task; + } else { + unset( $batch->data[ $key ] ); + } + + // Update batch before sending more to prevent duplicate email possibility. + $this->update( $batch->key, $batch->data ); + + if ( $this->time_exceeded() || $this->memory_exceeded() ) { + // Batch limits reached. + break; + } + } + if ( empty( $batch->data ) ) { + $this->delete( $batch->key ); + } + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); + + $this->unlock_process(); + + // Start next batch or complete process. + if ( ! $this->is_queue_empty() ) { + $this->dispatch(); + } else { + $this->complete(); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-background-updater.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-background-updater.php new file mode 100644 index 0000000..3f80666 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-background-updater.php @@ -0,0 +1,135 @@ +prefix = 'wp_' . get_current_blog_id(); + $this->action = 'wc_updater'; + + parent::__construct(); + } + + /** + * Dispatch updater. + * + * Updater will still run via cron job if this fails for any reason. + */ + public function dispatch() { + $dispatched = parent::dispatch(); + $logger = wc_get_logger(); + + if ( is_wp_error( $dispatched ) ) { + $logger->error( + sprintf( 'Unable to dispatch WooCommerce updater: %s', $dispatched->get_error_message() ), + array( 'source' => 'wc_db_updates' ) + ); + } + } + + /** + * Handle cron healthcheck + * + * Restart the background process if not already running + * and data exists in the queue. + */ + public function handle_cron_healthcheck() { + if ( $this->is_process_running() ) { + // Background process already running. + return; + } + + if ( $this->is_queue_empty() ) { + // No data to process. + $this->clear_scheduled_event(); + return; + } + + $this->handle(); + } + + /** + * Schedule fallback event. + */ + protected function schedule_event() { + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { + wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); + } + } + + /** + * Is the updater running? + * + * @return boolean + */ + public function is_updating() { + return false === $this->is_queue_empty(); + } + + /** + * Task + * + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param string $callback Update callback function. + * @return string|bool + */ + protected function task( $callback ) { + wc_maybe_define_constant( 'WC_UPDATING', true ); + + $logger = wc_get_logger(); + + include_once dirname( __FILE__ ) . '/wc-update-functions.php'; + + $result = false; + + if ( is_callable( $callback ) ) { + $logger->info( sprintf( 'Running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) ); + $result = (bool) call_user_func( $callback ); + + if ( $result ) { + $logger->info( sprintf( '%s callback needs to run again', $callback ), array( 'source' => 'wc_db_updates' ) ); + } else { + $logger->info( sprintf( 'Finished running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) ); + } + } else { + $logger->notice( sprintf( 'Could not find %s callback', $callback ), array( 'source' => 'wc_db_updates' ) ); + } + + return $result ? $callback : false; + } + + /** + * Complete + * + * Override if applicable, but ensure that the below actions are + * performed, or, call parent::complete(). + */ + protected function complete() { + $logger = wc_get_logger(); + $logger->info( 'Data update complete', array( 'source' => 'wc_db_updates' ) ); + WC_Install::update_db_version(); + parent::complete(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-breadcrumb.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-breadcrumb.php new file mode 100644 index 0000000..85d126d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-breadcrumb.php @@ -0,0 +1,372 @@ +crumbs[] = array( + strip_tags( $name ), + $link, + ); + } + + /** + * Reset crumbs. + */ + public function reset() { + $this->crumbs = array(); + } + + /** + * Get the breadcrumb. + * + * @return array + */ + public function get_breadcrumb() { + return apply_filters( 'woocommerce_get_breadcrumb', $this->crumbs, $this ); + } + + /** + * Generate breadcrumb trail. + * + * @return array of breadcrumbs + */ + public function generate() { + $conditionals = array( + 'is_home', + 'is_404', + 'is_attachment', + 'is_single', + 'is_product_category', + 'is_product_tag', + 'is_shop', + 'is_page', + 'is_post_type_archive', + 'is_category', + 'is_tag', + 'is_author', + 'is_date', + 'is_tax', + ); + + if ( ( ! is_front_page() && ! ( is_post_type_archive() && intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) ) || is_paged() ) { + foreach ( $conditionals as $conditional ) { + if ( call_user_func( $conditional ) ) { + call_user_func( array( $this, 'add_crumbs_' . substr( $conditional, 3 ) ) ); + break; + } + } + + $this->search_trail(); + $this->paged_trail(); + + return $this->get_breadcrumb(); + } + + return array(); + } + + /** + * Prepend the shop page to shop breadcrumbs. + */ + private function prepend_shop_page() { + $permalinks = wc_get_permalink_structure(); + $shop_page_id = wc_get_page_id( 'shop' ); + $shop_page = get_post( $shop_page_id ); + + // If permalinks contain the shop page in the URI prepend the breadcrumb with shop. + if ( $shop_page_id && $shop_page && isset( $permalinks['product_base'] ) && strstr( $permalinks['product_base'], '/' . $shop_page->post_name ) && intval( get_option( 'page_on_front' ) ) !== $shop_page_id ) { + $this->add_crumb( get_the_title( $shop_page ), get_permalink( $shop_page ) ); + } + } + + /** + * Is home trail.. + */ + private function add_crumbs_home() { + $this->add_crumb( single_post_title( '', false ) ); + } + + /** + * 404 trail. + */ + private function add_crumbs_404() { + $this->add_crumb( __( 'Error 404', 'woocommerce' ) ); + } + + /** + * Attachment trail. + */ + private function add_crumbs_attachment() { + global $post; + + $this->add_crumbs_single( $post->post_parent, get_permalink( $post->post_parent ) ); + $this->add_crumb( get_the_title(), get_permalink() ); + } + + /** + * Single post trail. + * + * @param int $post_id Post ID. + * @param string $permalink Post permalink. + */ + private function add_crumbs_single( $post_id = 0, $permalink = '' ) { + if ( ! $post_id ) { + global $post; + } else { + $post = get_post( $post_id ); // WPCS: override ok. + } + + if ( 'product' === get_post_type( $post ) ) { + $this->prepend_shop_page(); + + $terms = wc_get_product_terms( + $post->ID, 'product_cat', apply_filters( + 'woocommerce_breadcrumb_product_terms_args', array( + 'orderby' => 'parent', + 'order' => 'DESC', + ) + ) + ); + + if ( $terms ) { + $main_term = apply_filters( 'woocommerce_breadcrumb_main_term', $terms[0], $terms ); + $this->term_ancestors( $main_term->term_id, 'product_cat' ); + $this->add_crumb( $main_term->name, get_term_link( $main_term ) ); + } + } elseif ( 'post' !== get_post_type( $post ) ) { + $post_type = get_post_type_object( get_post_type( $post ) ); + + if ( ! empty( $post_type->has_archive ) ) { + $this->add_crumb( $post_type->labels->singular_name, get_post_type_archive_link( get_post_type( $post ) ) ); + } + } else { + $cat = current( get_the_category( $post ) ); + if ( $cat ) { + $this->term_ancestors( $cat->term_id, 'category' ); + $this->add_crumb( $cat->name, get_term_link( $cat ) ); + } + } + + $this->add_crumb( get_the_title( $post ), $permalink ); + } + + /** + * Page trail. + */ + private function add_crumbs_page() { + global $post; + + if ( $post->post_parent ) { + $parent_crumbs = array(); + $parent_id = $post->post_parent; + + while ( $parent_id ) { + $page = get_post( $parent_id ); + $parent_id = $page->post_parent; + $parent_crumbs[] = array( get_the_title( $page->ID ), get_permalink( $page->ID ) ); + } + + $parent_crumbs = array_reverse( $parent_crumbs ); + + foreach ( $parent_crumbs as $crumb ) { + $this->add_crumb( $crumb[0], $crumb[1] ); + } + } + + $this->add_crumb( get_the_title(), get_permalink() ); + $this->endpoint_trail(); + } + + /** + * Product category trail. + */ + private function add_crumbs_product_category() { + $current_term = $GLOBALS['wp_query']->get_queried_object(); + + $this->prepend_shop_page(); + $this->term_ancestors( $current_term->term_id, 'product_cat' ); + $this->add_crumb( $current_term->name ); + } + + /** + * Product tag trail. + */ + private function add_crumbs_product_tag() { + $current_term = $GLOBALS['wp_query']->get_queried_object(); + + $this->prepend_shop_page(); + + /* translators: %s: product tag */ + $this->add_crumb( sprintf( __( 'Products tagged “%s”', 'woocommerce' ), $current_term->name ) ); + } + + /** + * Shop breadcrumb. + */ + private function add_crumbs_shop() { + if ( intval( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) { + return; + } + + $_name = wc_get_page_id( 'shop' ) ? get_the_title( wc_get_page_id( 'shop' ) ) : ''; + + if ( ! $_name ) { + $product_post_type = get_post_type_object( 'product' ); + $_name = $product_post_type->labels->singular_name; + } + + $this->add_crumb( $_name, get_post_type_archive_link( 'product' ) ); + } + + /** + * Post type archive trail. + */ + private function add_crumbs_post_type_archive() { + $post_type = get_post_type_object( get_post_type() ); + + if ( $post_type ) { + $this->add_crumb( $post_type->labels->singular_name, get_post_type_archive_link( get_post_type() ) ); + } + } + + /** + * Category trail. + */ + private function add_crumbs_category() { + $this_category = get_category( $GLOBALS['wp_query']->get_queried_object() ); + + if ( 0 !== intval( $this_category->parent ) ) { + $this->term_ancestors( $this_category->term_id, 'category' ); + } + + $this->add_crumb( single_cat_title( '', false ), get_category_link( $this_category->term_id ) ); + } + + /** + * Tag trail. + */ + private function add_crumbs_tag() { + $queried_object = $GLOBALS['wp_query']->get_queried_object(); + + /* translators: %s: tag name */ + $this->add_crumb( sprintf( __( 'Posts tagged “%s”', 'woocommerce' ), single_tag_title( '', false ) ), get_tag_link( $queried_object->term_id ) ); + } + + /** + * Add crumbs for date based archives. + */ + private function add_crumbs_date() { + if ( is_year() || is_month() || is_day() ) { + $this->add_crumb( get_the_time( 'Y' ), get_year_link( get_the_time( 'Y' ) ) ); + } + if ( is_month() || is_day() ) { + $this->add_crumb( get_the_time( 'F' ), get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ); + } + if ( is_day() ) { + $this->add_crumb( get_the_time( 'd' ) ); + } + } + + /** + * Add crumbs for taxonomies + */ + private function add_crumbs_tax() { + $this_term = $GLOBALS['wp_query']->get_queried_object(); + $taxonomy = get_taxonomy( $this_term->taxonomy ); + + $this->add_crumb( $taxonomy->labels->name ); + + if ( 0 !== intval( $this_term->parent ) ) { + $this->term_ancestors( $this_term->term_id, $this_term->taxonomy ); + } + + $this->add_crumb( single_term_title( '', false ), get_term_link( $this_term->term_id, $this_term->taxonomy ) ); + } + + /** + * Add a breadcrumb for author archives. + */ + private function add_crumbs_author() { + global $author; + + $userdata = get_userdata( $author ); + + /* translators: %s: author name */ + $this->add_crumb( sprintf( __( 'Author: %s', 'woocommerce' ), $userdata->display_name ) ); + } + + /** + * Add crumbs for a term. + * + * @param int $term_id Term ID. + * @param string $taxonomy Taxonomy. + */ + private function term_ancestors( $term_id, $taxonomy ) { + $ancestors = get_ancestors( $term_id, $taxonomy ); + $ancestors = array_reverse( $ancestors ); + + foreach ( $ancestors as $ancestor ) { + $ancestor = get_term( $ancestor, $taxonomy ); + + if ( ! is_wp_error( $ancestor ) && $ancestor ) { + $this->add_crumb( $ancestor->name, get_term_link( $ancestor ) ); + } + } + } + + /** + * Endpoints. + */ + private function endpoint_trail() { + $endpoint = is_wc_endpoint_url() ? WC()->query->get_current_endpoint() : ''; + $endpoint_title = $endpoint ? WC()->query->get_endpoint_title( $endpoint ) : ''; + + if ( $endpoint_title ) { + $this->add_crumb( $endpoint_title ); + } + } + + /** + * Add a breadcrumb for search results. + */ + private function search_trail() { + if ( is_search() ) { + /* translators: %s: search term */ + $this->add_crumb( sprintf( __( 'Search results for “%s”', 'woocommerce' ), get_search_query() ), remove_query_arg( 'paged' ) ); + } + } + + /** + * Add a breadcrumb for pagination. + */ + private function paged_trail() { + if ( get_query_var( 'paged' ) ) { + /* translators: %d: page number */ + $this->add_crumb( sprintf( __( 'Page %d', 'woocommerce' ), get_query_var( 'paged' ) ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-cache-helper.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-cache-helper.php new file mode 100644 index 0000000..1106643 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-cache-helper.php @@ -0,0 +1,241 @@ +get_billing_country(); + $location['state'] = $customer->get_billing_state(); + $location['postcode'] = $customer->get_billing_postcode(); + $location['city'] = $customer->get_billing_city(); + return substr( md5( implode( '', $location ) ), 0, 12 ); + } + + /** + * Prevent caching on certain pages + */ + public static function prevent_caching() { + if ( ! is_blog_installed() ) { + return; + } + $page_ids = array_filter( array( wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ) ); + + if ( is_page( $page_ids ) ) { + self::set_nocache_constants(); + nocache_headers(); + } + } + + /** + * When using geolocation via ajax, to bust cache, redirect if the location hash does not equal the querystring. + * + * This prevents caching of the wrong data for this request. + */ + public static function geolocation_ajax_redirect() { + if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && ! is_checkout() && ! is_cart() && ! is_account_page() && ! is_ajax() && empty( $_POST ) ) { // WPCS: CSRF ok, input var ok. + $location_hash = self::geolocation_ajax_get_location_hash(); + $current_hash = isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok. + if ( empty( $current_hash ) || $current_hash !== $location_hash ) { + global $wp; + + $redirect_url = trailingslashit( home_url( $wp->request ) ); + + if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { // WPCS: Input var ok. + $redirect_url = add_query_arg( wp_unslash( $_SERVER['QUERY_STRING'] ), '', $redirect_url ); // WPCS: sanitization ok, Input var ok. + } + + if ( ! get_option( 'permalink_structure' ) ) { + $redirect_url = add_query_arg( $wp->query_string, '', $redirect_url ); + } + + $redirect_url = add_query_arg( 'v', $location_hash, remove_query_arg( 'v', $redirect_url ) ); + + wp_safe_redirect( esc_url_raw( $redirect_url ), 307 ); + exit; + } + } + } + + /** + * Get transient version. + * + * When using transients with unpredictable names, e.g. those containing an md5 + * hash in the name, we need a way to invalidate them all at once. + * + * When using default WP transients we're able to do this with a DB query to + * delete transients manually. + * + * With external cache however, this isn't possible. Instead, this function is used + * to append a unique string (based on time()) to each transient. When transients + * are invalidated, the transient version will increment and data will be regenerated. + * + * Raised in issue https://github.com/woocommerce/woocommerce/issues/5777. + * Adapted from ideas in http://tollmanz.com/invalidation-schemes/. + * + * @param string $group Name for the group of transients we need to invalidate. + * @param boolean $refresh true to force a new version. + * @return string transient version based on time(), 10 digits. + */ + public static function get_transient_version( $group, $refresh = false ) { + $transient_name = $group . '-transient-version'; + $transient_value = get_transient( $transient_name ); + + if ( false === $transient_value || true === $refresh ) { + self::delete_version_transients( $transient_value ); + + $transient_value = time(); + + set_transient( $transient_name, $transient_value ); + } + return $transient_value; + } + + /** + * When the transient version increases, this is used to remove all past transients to avoid filling the DB. + * + * Note; this only works on transients appended with the transient version, and when object caching is not being used. + * + * @since 2.3.10 + * @param string $version Version of the transient to remove. + */ + public static function delete_version_transients( $version = '' ) { + if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) { + global $wpdb; + + $limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 ); + + if ( ! $limit ) { + return; + } + + $affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s ORDER BY option_id LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // WPCS: cache ok, db call ok. + + // If affected rows is equal to limit, there are more rows to delete. Delete in 10 secs. + if ( $affected === $limit ) { + wp_schedule_single_event( time() + 10, 'delete_version_transients', array( $version ) ); + } + } + } + + /** + * Set constants to prevent caching by some plugins. + * + * @param mixed $return Value to return. Previously hooked into a filter. + * @return mixed + */ + public static function set_nocache_constants( $return = true ) { + wc_maybe_define_constant( 'DONOTCACHEPAGE', true ); + wc_maybe_define_constant( 'DONOTCACHEOBJECT', true ); + wc_maybe_define_constant( 'DONOTCACHEDB', true ); + return $return; + } + + /** + * Notices function. + */ + public static function notices() { + if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { + return; + } + + $config = w3_instance( 'W3_Config' ); + $enabled = $config->get_integer( 'dbcache.enabled' ); + $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); + + if ( $enabled && ! in_array( '_wc_session_', $settings, true ) ) { + ?> +
      +

      + database caching to work with WooCommerce you must add %1$s to the "Ignored Query Strings" option in W3 Total Cache settings.', 'woocommerce' ), '_wc_session_', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); + ?> +

      +
      + cart->fees_api() which will reference this class. + * + * We suggest using the action woocommerce_cart_calculate_fees hook for adding fees. + * + * @package WooCommerce/Classes + * @version 3.2.0 + */ + +defined( 'ABSPATH' ) || exit; + +/** + * WC_Cart_Fees class. + * + * @since 3.2.0 + */ +final class WC_Cart_Fees { + + /** + * An array of fee objects. + * + * @var object[] + */ + private $fees = array(); + + /** + * Reference to cart object. + * + * @since 3.2.0 + * @var WC_Cart + */ + private $cart; + + /** + * New fees are made out of these props. + * + * @var array + */ + private $default_fee_props = array( + 'id' => '', + 'name' => '', + 'tax_class' => '', + 'taxable' => false, + 'amount' => 0, + 'total' => 0, + ); + + /** + * Constructor. Reference to the cart. + * + * @since 3.2.0 + * @throws Exception If missing WC_Cart object. + * @param WC_Cart $cart Cart object. + */ + public function __construct( &$cart ) { + if ( ! is_a( $cart, 'WC_Cart' ) ) { + throw new Exception( 'A valid WC_Cart object is required' ); + } + + $this->cart = $cart; + } + + /** + * Register methods for this object on the appropriate WordPress hooks. + */ + public function init() {} + + /** + * Add a fee. Fee IDs must be unique. + * + * @since 3.2.0 + * @param array $args Array of fee properties. + * @return object Either a fee object if added, or a WP_Error if it failed. + */ + public function add_fee( $args = array() ) { + $fee_props = (object) wp_parse_args( $args, $this->default_fee_props ); + $fee_props->name = $fee_props->name ? $fee_props->name : __( 'Fee', 'woocommerce' ); + $fee_props->tax_class = in_array( $fee_props->tax_class, array_merge( WC_Tax::get_tax_classes(), WC_Tax::get_tax_class_slugs() ), true ) ? $fee_props->tax_class : ''; + $fee_props->taxable = wc_string_to_bool( $fee_props->taxable ); + $fee_props->amount = wc_format_decimal( $fee_props->amount ); + + if ( empty( $fee_props->id ) ) { + $fee_props->id = $this->generate_id( $fee_props ); + } + + if ( array_key_exists( $fee_props->id, $this->fees ) ) { + return new WP_Error( 'fee_exists', __( 'Fee has already been added.', 'woocommerce' ) ); + } + + $this->fees[ $fee_props->id ] = $fee_props; + + return $this->fees[ $fee_props->id ]; + } + + /** + * Get fees. + * + * @return array + */ + public function get_fees() { + uasort( $this->fees, array( $this, 'sort_fees_callback' ) ); + + return $this->fees; + } + + /** + * Set fees. + * + * @param object[] $raw_fees Array of fees. + */ + public function set_fees( $raw_fees = array() ) { + $this->fees = array(); + + foreach ( $raw_fees as $raw_fee ) { + $this->add_fee( $raw_fee ); + } + } + + /** + * Remove all fees. + * + * @since 3.2.0 + */ + public function remove_all_fees() { + $this->set_fees(); + } + + /** + * Sort fees by amount. + * + * @param WC_Coupon $a Coupon object. + * @param WC_Coupon $b Coupon object. + * @return int + */ + protected function sort_fees_callback( $a, $b ) { + return ( $a->amount > $b->amount ) ? -1 : 1; + } + + /** + * Generate a unique ID for the fee being added. + * + * @param string $fee Fee object. + * @return string fee key. + */ + private function generate_id( $fee ) { + return sanitize_title( $fee->name ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-session.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-session.php new file mode 100644 index 0000000..47054f9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-session.php @@ -0,0 +1,242 @@ +cart = $cart; + } + + /** + * Register methods for this object on the appropriate WordPress hooks. + */ + public function init() { + add_action( 'wp_loaded', array( $this, 'get_cart_from_session' ) ); + add_action( 'woocommerce_cart_emptied', array( $this, 'destroy_cart_session' ) ); + add_action( 'wp', array( $this, 'maybe_set_cart_cookies' ), 99 ); + add_action( 'shutdown', array( $this, 'maybe_set_cart_cookies' ), 0 ); + add_action( 'woocommerce_add_to_cart', array( $this, 'maybe_set_cart_cookies' ) ); + add_action( 'woocommerce_after_calculate_totals', array( $this, 'set_session' ) ); + add_action( 'woocommerce_cart_loaded_from_session', array( $this, 'set_session' ) ); + add_action( 'woocommerce_removed_coupon', array( $this, 'set_session' ) ); + add_action( 'woocommerce_cart_updated', array( $this, 'persistent_cart_update' ) ); + } + + /** + * Get the cart data from the PHP session and store it in class variables. + * + * @since 3.2.0 + */ + public function get_cart_from_session() { + // Flag to indicate the stored cart should be updated. + $update_cart_session = false; + $totals = WC()->session->get( 'cart_totals', null ); + $cart = WC()->session->get( 'cart', null ); + + $this->cart->set_totals( $totals ); + $this->cart->set_applied_coupons( WC()->session->get( 'applied_coupons', array() ) ); + $this->cart->set_coupon_discount_totals( WC()->session->get( 'coupon_discount_totals', array() ) ); + $this->cart->set_coupon_discount_tax_totals( WC()->session->get( 'coupon_discount_tax_totals', array() ) ); + $this->cart->set_removed_cart_contents( WC()->session->get( 'removed_cart_contents', array() ) ); + + if ( apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) { + $saved_cart = get_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), true ); + } else { + $saved_cart = false; + } + + if ( is_null( $cart ) && $saved_cart ) { + $cart = $saved_cart['cart']; + $update_cart_session = true; + } elseif ( is_null( $cart ) ) { + $cart = array(); + } elseif ( is_array( $cart ) && $saved_cart ) { + $cart = array_merge( $saved_cart['cart'], $cart ); + $update_cart_session = true; + } + + if ( is_array( $cart ) ) { + $cart_contents = array(); + + // Prime caches to reduce future queries. + if ( is_callable( '_prime_post_caches' ) ) { + _prime_post_caches( wp_list_pluck( $cart, 'product_id' ) ); + } + + foreach ( $cart as $key => $values ) { + $product = wc_get_product( $values['variation_id'] ? $values['variation_id'] : $values['product_id'] ); + + if ( ! is_customize_preview() && 'customize-preview' === $key ) { + continue; + } + + if ( ! empty( $product ) && $product->exists() && $values['quantity'] > 0 ) { + + if ( ! $product->is_purchasable() ) { + $update_cart_session = true; + /* translators: %s: product name */ + wc_add_notice( sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'woocommerce' ), $product->get_name() ), 'error' ); + do_action( 'woocommerce_remove_cart_item_from_session', $key, $values ); + + } elseif ( ! empty( $values['data_hash'] ) && ! hash_equals( $values['data_hash'], wc_get_cart_item_data_hash( $product ) ) ) { // phpcs:ignore PHPCompatibility.PHP.NewFunctions.hash_equalsFound + $update_cart_session = true; + /* translators: %1$s: product name. %2$s product permalink */ + wc_add_notice( sprintf( __( '%1$s has been removed from your cart because it has since been modified. You can add it back to your cart here.', 'woocommerce' ), $product->get_name(), $product->get_permalink() ), 'notice' ); + do_action( 'woocommerce_remove_cart_item_from_session', $key, $values ); + + } else { + // Put session data into array. Run through filter so other plugins can load their own session data. + $session_data = array_merge( + $values, array( + 'data' => $product, + ) + ); + $cart_contents[ $key ] = apply_filters( 'woocommerce_get_cart_item_from_session', $session_data, $values, $key ); + + // Add to cart right away so the product is visible in woocommerce_get_cart_item_from_session hook. + $this->cart->set_cart_contents( $cart_contents ); + } + } + } + } + + do_action( 'woocommerce_cart_loaded_from_session', $this->cart ); + + if ( $update_cart_session || is_null( WC()->session->get( 'cart_totals', null ) ) ) { + WC()->session->set( 'cart', $this->get_cart_for_session() ); + $this->cart->calculate_totals(); + } + } + + /** + * Destroy cart session data. + * + * @since 3.2.0 + */ + public function destroy_cart_session() { + WC()->session->set( 'cart', null ); + WC()->session->set( 'cart_totals', null ); + WC()->session->set( 'applied_coupons', null ); + WC()->session->set( 'coupon_discount_totals', null ); + WC()->session->set( 'coupon_discount_tax_totals', null ); + WC()->session->set( 'removed_cart_contents', null ); + WC()->session->set( 'order_awaiting_payment', null ); + } + + /** + * Will set cart cookies if needed and when possible. + * + * @since 3.2.0 + */ + public function maybe_set_cart_cookies() { + if ( ! headers_sent() && did_action( 'wp_loaded' ) ) { + if ( ! $this->cart->is_empty() ) { + $this->set_cart_cookies( true ); + } elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { // WPCS: input var ok. + $this->set_cart_cookies( false ); + } + } + } + + /** + * Sets the php session data for the cart and coupons. + */ + public function set_session() { + WC()->session->set( 'cart', $this->get_cart_for_session() ); + WC()->session->set( 'cart_totals', $this->cart->get_totals() ); + WC()->session->set( 'applied_coupons', $this->cart->get_applied_coupons() ); + WC()->session->set( 'coupon_discount_totals', $this->cart->get_coupon_discount_totals() ); + WC()->session->set( 'coupon_discount_tax_totals', $this->cart->get_coupon_discount_tax_totals() ); + WC()->session->set( 'removed_cart_contents', $this->cart->get_removed_cart_contents() ); + + do_action( 'woocommerce_cart_updated' ); + } + + /** + * Returns the contents of the cart in an array without the 'data' element. + * + * @return array contents of the cart + */ + public function get_cart_for_session() { + $cart_session = array(); + + foreach ( $this->cart->get_cart() as $key => $values ) { + $cart_session[ $key ] = $values; + unset( $cart_session[ $key ]['data'] ); // Unset product object. + } + + return $cart_session; + } + + /** + * Save the persistent cart when the cart is updated. + */ + public function persistent_cart_update() { + if ( get_current_user_id() && apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) { + update_user_meta( + get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array( + 'cart' => $this->get_cart_for_session(), + ) + ); + } + } + + /** + * Delete the persistent cart permanently. + */ + public function persistent_cart_destroy() { + if ( get_current_user_id() && apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) { + delete_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id() ); + } + } + + /** + * Set cart hash cookie and items in cart. + * + * @access private + * @param bool $set Should cookies be set (true) or unset. + */ + private function set_cart_cookies( $set = true ) { + if ( $set ) { + wc_setcookie( 'woocommerce_items_in_cart', 1 ); + wc_setcookie( 'woocommerce_cart_hash', md5( wp_json_encode( $this->get_cart_for_session() ) ) ); + } elseif ( isset( $_COOKIE['woocommerce_items_in_cart'] ) ) { // WPCS: input var ok. + wc_setcookie( 'woocommerce_items_in_cart', 0, time() - HOUR_IN_SECONDS ); + wc_setcookie( 'woocommerce_cart_hash', '', time() - HOUR_IN_SECONDS ); + } + do_action( 'woocommerce_set_cart_cookies', $set ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php new file mode 100644 index 0000000..bb2c384 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php @@ -0,0 +1,840 @@ + 0, + 'fees_total_tax' => 0, + 'items_subtotal' => 0, + 'items_subtotal_tax' => 0, + 'items_total' => 0, + 'items_total_tax' => 0, + 'total' => 0, + 'shipping_total' => 0, + 'shipping_tax_total' => 0, + 'discounts_total' => 0, + ); + + /** + * Sets up the items provided, and calculate totals. + * + * @since 3.2.0 + * @throws Exception If missing WC_Cart object. + * @param WC_Cart $cart Cart object to calculate totals for. + */ + public function __construct( &$cart = null ) { + if ( ! is_a( $cart, 'WC_Cart' ) ) { + throw new Exception( 'A valid WC_Cart object is required' ); + } + + $this->cart = $cart; + $this->calculate_tax = wc_tax_enabled() && ! $cart->get_customer()->get_is_vat_exempt(); + $this->calculate(); + } + + /** + * Run all calculations methods on the given items in sequence. + * + * @since 3.2.0 + */ + protected function calculate() { + $this->calculate_item_totals(); + $this->calculate_shipping_totals(); + $this->calculate_fee_totals(); + $this->calculate_totals(); + } + + /** + * Get default blank set of props used per item. + * + * @since 3.2.0 + * @return array + */ + protected function get_default_item_props() { + return (object) array( + 'object' => null, + 'tax_class' => '', + 'taxable' => false, + 'quantity' => 0, + 'product' => false, + 'price_includes_tax' => false, + 'subtotal' => 0, + 'subtotal_tax' => 0, + 'total' => 0, + 'total_tax' => 0, + 'taxes' => array(), + ); + } + + /** + * Get default blank set of props used per fee. + * + * @since 3.2.0 + * @return array + */ + protected function get_default_fee_props() { + return (object) array( + 'object' => null, + 'tax_class' => '', + 'taxable' => false, + 'total_tax' => 0, + 'taxes' => array(), + ); + } + + /** + * Get default blank set of props used per shipping row. + * + * @since 3.2.0 + * @return array + */ + protected function get_default_shipping_props() { + return (object) array( + 'object' => null, + 'tax_class' => '', + 'taxable' => false, + 'total' => 0, + 'total_tax' => 0, + 'taxes' => array(), + ); + } + + /** + * Should we round at subtotal level only? + * + * @return bool + */ + protected function round_at_subtotal() { + return 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ); + } + + /** + * Handles a cart or order object passed in for calculation. Normalises data + * into the same format for use by this class. + * + * Each item is made up of the following props, in addition to those returned by get_default_item_props() for totals. + * - key: An identifier for the item (cart item key or line item ID). + * - cart_item: For carts, the cart item from the cart which may include custom data. + * - quantity: The qty for this line. + * - price: The line price in cents. + * - product: The product object this cart item is for. + * + * @since 3.2.0 + */ + protected function get_items_from_cart() { + $this->items = array(); + + foreach ( $this->cart->get_cart() as $cart_item_key => $cart_item ) { + $item = $this->get_default_item_props(); + $item->key = $cart_item_key; + $item->object = $cart_item; + $item->tax_class = $cart_item['data']->get_tax_class(); + $item->taxable = 'taxable' === $cart_item['data']->get_tax_status(); + $item->price_includes_tax = wc_prices_include_tax(); + $item->quantity = $cart_item['quantity']; + $item->price = wc_add_number_precision_deep( $cart_item['data']->get_price() * $cart_item['quantity'] ); + $item->product = $cart_item['data']; + $item->tax_rates = $this->get_item_tax_rates( $item ); + $this->items[ $cart_item_key ] = $item; + } + } + + /** + * Get item costs grouped by tax class. + * + * @since 3.2.0 + * @return array + */ + protected function get_tax_class_costs() { + $item_tax_classes = wp_list_pluck( $this->items, 'tax_class' ); + $shipping_tax_classes = wp_list_pluck( $this->shipping, 'tax_class' ); + $fee_tax_classes = wp_list_pluck( $this->fees, 'tax_class' ); + $costs = array_fill_keys( $item_tax_classes + $shipping_tax_classes + $fee_tax_classes, 0 ); + $costs['non-taxable'] = 0; + + foreach ( $this->items + $this->fees + $this->shipping as $item ) { + if ( 0 > $item->total ) { + continue; + } + if ( ! $item->taxable ) { + $costs['non-taxable'] += $item->total; + } elseif ( 'inherit' === $item->tax_class ) { + $costs[ reset( $item_tax_classes ) ] += $item->total; + } else { + $costs[ $item->tax_class ] += $item->total; + } + } + return array_filter( $costs ); + } + + /** + * Get fee objects from the cart. Normalises data + * into the same format for use by this class. + * + * @since 3.2.0 + */ + protected function get_fees_from_cart() { + $this->fees = array(); + $this->cart->calculate_fees(); + + $fee_running_total = 0; + + foreach ( $this->cart->get_fees() as $fee_key => $fee_object ) { + $fee = $this->get_default_fee_props(); + $fee->object = $fee_object; + $fee->tax_class = $fee->object->tax_class; + $fee->taxable = $fee->object->taxable; + $fee->total = wc_add_number_precision_deep( $fee->object->amount ); + + // Negative fees should not make the order total go negative. + if ( 0 > $fee->total ) { + $max_discount = round( $this->get_total( 'items_total', true ) + $fee_running_total + $this->get_total( 'shipping_total', true ) ) * -1; + + if ( $fee->total < $max_discount ) { + $fee->total = $max_discount; + } + } + + $fee_running_total += $fee->total; + + if ( $this->calculate_tax ) { + if ( 0 > $fee->total ) { + // Negative fees should have the taxes split between all items so it works as a true discount. + $tax_class_costs = $this->get_tax_class_costs(); + $total_cost = array_sum( $tax_class_costs ); + + if ( $total_cost ) { + foreach ( $tax_class_costs as $tax_class => $tax_class_cost ) { + if ( 'non-taxable' === $tax_class ) { + continue; + } + $proportion = $tax_class_cost / $total_cost; + $cart_discount_proportion = $fee->total * $proportion; + $fee->taxes = wc_array_merge_recursive_numeric( $fee->taxes, WC_Tax::calc_tax( $fee->total * $proportion, WC_Tax::get_rates( $tax_class ) ) ); + } + } + } elseif ( $fee->object->taxable ) { + $fee->taxes = WC_Tax::calc_tax( $fee->total, WC_Tax::get_rates( $fee->tax_class, $this->cart->get_customer() ), false ); + } + } + + $fee->taxes = apply_filters( 'woocommerce_cart_totals_get_fees_from_cart_taxes', $fee->taxes, $fee, $this ); + $fee->total_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $fee->taxes ) ); + + // Set totals within object. + $fee->object->total = wc_remove_number_precision_deep( $fee->total ); + $fee->object->tax_data = wc_remove_number_precision_deep( $fee->taxes ); + $fee->object->tax = wc_remove_number_precision_deep( $fee->total_tax ); + + $this->fees[ $fee_key ] = $fee; + } + } + + /** + * Get shipping methods from the cart and normalise. + * + * @since 3.2.0 + */ + protected function get_shipping_from_cart() { + $this->shipping = array(); + + if ( ! $this->cart->show_shipping() ) { + return; + } + + foreach ( $this->cart->calculate_shipping() as $key => $shipping_object ) { + $shipping_line = $this->get_default_shipping_props(); + $shipping_line->object = $shipping_object; + $shipping_line->tax_class = get_option( 'woocommerce_shipping_tax_class' ); + $shipping_line->taxable = true; + $shipping_line->total = wc_add_number_precision_deep( $shipping_object->cost ); + $shipping_line->taxes = wc_add_number_precision_deep( $shipping_object->taxes, false ); + $shipping_line->total_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $shipping_line->taxes ) ); + + $this->shipping[ $key ] = $shipping_line; + } + } + + /** + * Return array of coupon objects from the cart. Normalises data + * into the same format for use by this class. + * + * @since 3.2.0 + */ + protected function get_coupons_from_cart() { + $this->coupons = $this->cart->get_coupons(); + + foreach ( $this->coupons as $coupon ) { + switch ( $coupon->get_discount_type() ) { + case 'fixed_product': + $coupon->sort = 1; + break; + case 'percent': + $coupon->sort = 2; + break; + case 'fixed_cart': + $coupon->sort = 3; + break; + default: + $coupon->sort = 0; + break; + } + + // Allow plugins to override the default order. + $coupon->sort = apply_filters( 'woocommerce_coupon_sort', $coupon->sort, $coupon ); + } + + uasort( $this->coupons, array( $this, 'sort_coupons_callback' ) ); + } + + /** + * Sort coupons so discounts apply consistently across installs. + * + * In order of priority; + * - sort param + * - usage restriction + * - coupon value + * - ID + * + * @param WC_Coupon $a Coupon object. + * @param WC_Coupon $b Coupon object. + * @return int + */ + protected function sort_coupons_callback( $a, $b ) { + if ( $a->sort === $b->sort ) { + if ( $a->get_limit_usage_to_x_items() === $b->get_limit_usage_to_x_items() ) { + if ( $a->get_amount() === $b->get_amount() ) { + return $b->get_id() - $a->get_id(); + } + return ( $a->get_amount() < $b->get_amount() ) ? -1 : 1; + } + return ( $a->get_limit_usage_to_x_items() < $b->get_limit_usage_to_x_items() ) ? -1 : 1; + } + return ( $a->sort < $b->sort ) ? -1 : 1; + } + + /** + * Ran to remove all base taxes from an item. Used when prices include tax, and the customer is tax exempt. + * + * @since 3.2.2 + * @param object $item Item to adjust the prices of. + * @return object + */ + protected function remove_item_base_taxes( $item ) { + if ( $item->price_includes_tax && $item->taxable ) { + $base_tax_rates = WC_Tax::get_base_tax_rates( $item->product->get_tax_class( 'unfiltered' ) ); + + // Work out a new base price without the shop's base tax. + $taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true ); + + // Now we have a new item price (excluding TAX). + $item->price = round( $item->price - array_sum( $taxes ) ); + $item->price_includes_tax = false; + } + return $item; + } + + /** + * Only ran if woocommerce_adjust_non_base_location_prices is true. + * + * If the customer is outside of the base location, this removes the base + * taxes. This is off by default unless the filter is used. + * + * Uses edit context so unfiltered tax class is returned. + * + * @since 3.2.0 + * @param object $item Item to adjust the prices of. + * @return object + */ + protected function adjust_non_base_location_price( $item ) { + if ( $item->price_includes_tax && $item->taxable ) { + $base_tax_rates = WC_Tax::get_base_tax_rates( $item->product->get_tax_class( 'unfiltered' ) ); + + if ( $item->tax_rates !== $base_tax_rates ) { + // Work out a new base price without the shop's base tax. + $taxes = WC_Tax::calc_tax( $item->price, $base_tax_rates, true ); + $new_taxes = WC_Tax::calc_tax( $item->price - array_sum( $taxes ), $item->tax_rates, false ); + + // Now we have a new item price. + $item->price = round( $item->price - array_sum( $taxes ) + array_sum( $new_taxes ) ); + } + } + return $item; + } + + /** + * Get discounted price of an item with precision (in cents). + * + * @since 3.2.0 + * @param object $item_key Item to get the price of. + * @return int + */ + protected function get_discounted_price_in_cents( $item_key ) { + $item = $this->items[ $item_key ]; + $price = isset( $this->coupon_discount_totals[ $item_key ] ) ? $item->price - $this->coupon_discount_totals[ $item_key ] : $item->price; + return $price; + } + + /** + * Get tax rates for an item. Caches rates in class to avoid multiple look ups. + * + * @param object $item Item to get tax rates for. + * @return array of taxes + */ + protected function get_item_tax_rates( $item ) { + if ( ! wc_tax_enabled() ) { + return array(); + } + $tax_class = $item->product->get_tax_class(); + return isset( $this->item_tax_rates[ $tax_class ] ) ? $this->item_tax_rates[ $tax_class ] : $this->item_tax_rates[ $tax_class ] = WC_Tax::get_rates( $item->product->get_tax_class(), $this->cart->get_customer() ); + } + + /** + * Get item costs grouped by tax class. + * + * @since 3.2.0 + * @return array + */ + protected function get_item_costs_by_tax_class() { + $tax_classes = array( + 'non-taxable' => 0, + ); + + foreach ( $this->items + $this->fees + $this->shipping as $item ) { + if ( ! isset( $tax_classes[ $item->tax_class ] ) ) { + $tax_classes[ $item->tax_class ] = 0; + } + + if ( $item->taxable ) { + $tax_classes[ $item->tax_class ] += $item->total; + } else { + $tax_classes['non-taxable'] += $item->total; + } + } + + return $tax_classes; + } + + /** + * Get a single total with or without precision (in cents). + * + * @since 3.2.0 + * @param string $key Total to get. + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return int|float + */ + public function get_total( $key = 'total', $in_cents = false ) { + $totals = $this->get_totals( $in_cents ); + return isset( $totals[ $key ] ) ? $totals[ $key ] : 0; + } + + /** + * Set a single total. + * + * @since 3.2.0 + * @param string $key Total name you want to set. + * @param int $total Total to set. + */ + protected function set_total( $key = 'total', $total ) { + $this->totals[ $key ] = $total; + } + + /** + * Get all totals with or without precision (in cents). + * + * @since 3.2.0 + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return array. + */ + public function get_totals( $in_cents = false ) { + return $in_cents ? $this->totals : wc_remove_number_precision_deep( $this->totals ); + } + + /** + * Get taxes merged by type. + * + * @since 3.2.0 + * @param bool $in_cents If returned value should be in cents. + * @param array|string $types Types to merge and return. Defaults to all. + * @return array + */ + protected function get_merged_taxes( $in_cents = false, $types = array( 'items', 'fees', 'shipping' ) ) { + $items = array(); + $taxes = array(); + + if ( is_string( $types ) ) { + $types = array( $types ); + } + + foreach ( $types as $type ) { + if ( isset( $this->$type ) ) { + $items = array_merge( $items, $this->$type ); + } + } + + foreach ( $items as $item ) { + foreach ( $item->taxes as $rate_id => $rate ) { + if ( ! isset( $taxes[ $rate_id ] ) ) { + $taxes[ $rate_id ] = 0; + } + $taxes[ $rate_id ] += $this->round_line_tax( $rate ); + } + } + + return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes ); + } + + /** + * Combine item taxes into a single array, preserving keys. + * + * @since 3.2.0 + * @param array $item_taxes Taxes to combine. + * @return array + */ + protected function combine_item_taxes( $item_taxes ) { + $merged_taxes = array(); + foreach ( $item_taxes as $taxes ) { + foreach ( $taxes as $tax_id => $tax_amount ) { + if ( ! isset( $merged_taxes[ $tax_id ] ) ) { + $merged_taxes[ $tax_id ] = 0; + } + $merged_taxes[ $tax_id ] += $tax_amount; + } + } + return $merged_taxes; + } + + /* + |-------------------------------------------------------------------------- + | Calculation methods. + |-------------------------------------------------------------------------- + */ + + /** + * Calculate item totals. + * + * @since 3.2.0 + */ + protected function calculate_item_totals() { + $this->get_items_from_cart(); + $this->calculate_item_subtotals(); + $this->calculate_discounts(); + + foreach ( $this->items as $item_key => $item ) { + $item->total = $this->get_discounted_price_in_cents( $item_key ); + $item->total_tax = 0; + + if ( has_filter( 'woocommerce_get_discounted_price' ) ) { + /** + * Allow plugins to filter this price like in the legacy cart class. + * + * This is legacy and should probably be deprecated in the future. + * $item->object is the cart item object. + * $this->cart is the cart object. + */ + $item->total = wc_add_number_precision( + apply_filters( 'woocommerce_get_discounted_price', wc_remove_number_precision( $item->total ), $item->object, $this->cart ) + ); + } + + if ( $this->calculate_tax && $item->product->is_taxable() ) { + $total_taxes = WC_Tax::calc_tax( $item->total, $item->tax_rates, $item->price_includes_tax ); + $item->taxes = $total_taxes; + $item->total_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $item->taxes ) ); + + if ( $item->price_includes_tax ) { + // Use unrounded taxes so we can re-calculate from the orders screen accurately later. + $item->total = $item->total - array_sum( $item->taxes ); + } + } + + $this->cart->cart_contents[ $item_key ]['line_tax_data']['total'] = wc_remove_number_precision_deep( $item->taxes ); + $this->cart->cart_contents[ $item_key ]['line_total'] = wc_remove_number_precision( $item->total ); + $this->cart->cart_contents[ $item_key ]['line_tax'] = wc_remove_number_precision( $item->total_tax ); + } + + $this->set_total( 'items_total', array_sum( array_map( 'round', array_values( wp_list_pluck( $this->items, 'total' ) ) ) ) ); + $this->set_total( 'items_total_tax', array_sum( array_values( wp_list_pluck( $this->items, 'total_tax' ) ) ) ); + + $this->cart->set_cart_contents_total( $this->get_total( 'items_total' ) ); + $this->cart->set_cart_contents_tax( array_sum( $this->get_merged_taxes( false, 'items' ) ) ); + $this->cart->set_cart_contents_taxes( $this->get_merged_taxes( false, 'items' ) ); + } + + /** + * Subtotals are costs before discounts. + * + * To prevent rounding issues we need to work with the inclusive price where possible. + * otherwise we'll see errors such as when working with a 9.99 inc price, 20% VAT which would. + * be 8.325 leading to totals being 1p off. + * + * Pre tax coupons come off the price the customer thinks they are paying - tax is calculated. + * afterwards. + * + * e.g. $100 bike with $10 coupon = customer pays $90 and tax worked backwards from that. + * + * @since 3.2.0 + */ + protected function calculate_item_subtotals() { + foreach ( $this->items as $item_key => $item ) { + if ( $item->price_includes_tax ) { + if ( $this->cart->get_customer()->get_is_vat_exempt() ) { + $item = $this->remove_item_base_taxes( $item ); + } elseif ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) { + $item = $this->adjust_non_base_location_price( $item ); + } + } + + $item->subtotal = $item->price; + $subtotal_taxes = array(); + + if ( $this->calculate_tax && $item->product->is_taxable() ) { + $subtotal_taxes = WC_Tax::calc_tax( $item->subtotal, $item->tax_rates, $item->price_includes_tax ); + $item->subtotal_tax = array_sum( array_map( array( $this, 'round_line_tax' ), $subtotal_taxes ) ); + + if ( $item->price_includes_tax ) { + // Use unrounded taxes so we can re-calculate from the orders screen accurately later. + $item->subtotal = $item->subtotal - array_sum( $subtotal_taxes ); + } + } + + $this->cart->cart_contents[ $item_key ]['line_tax_data'] = array( 'subtotal' => wc_remove_number_precision_deep( $subtotal_taxes ) ); + $this->cart->cart_contents[ $item_key ]['line_subtotal'] = wc_remove_number_precision( $item->subtotal ); + $this->cart->cart_contents[ $item_key ]['line_subtotal_tax'] = wc_remove_number_precision( $item->subtotal_tax ); + } + $this->set_total( 'items_subtotal', array_sum( array_map( 'round', array_values( wp_list_pluck( $this->items, 'subtotal' ) ) ) ) ); + $this->set_total( 'items_subtotal_tax', array_sum( array_values( wp_list_pluck( $this->items, 'subtotal_tax' ) ) ) ); + + $this->cart->set_subtotal( $this->get_total( 'items_subtotal' ) ); + $this->cart->set_subtotal_tax( $this->get_total( 'items_subtotal_tax' ) ); + } + + /** + * Calculate COUPON based discounts which change item prices. + * + * @since 3.2.0 + * @uses WC_Discounts class. + */ + protected function calculate_discounts() { + $this->get_coupons_from_cart(); + + $discounts = new WC_Discounts( $this->cart ); + + // Set items directly so the discounts class can see any tax adjustments made thus far using subtotals. + $discounts->set_items( $this->items ); + + foreach ( $this->coupons as $coupon ) { + $discounts->apply_coupon( $coupon ); + } + + $coupon_discount_amounts = $discounts->get_discounts_by_coupon( true ); + $coupon_discount_tax_amounts = array(); + + // See how much tax was 'discounted' per item and per coupon. + if ( $this->calculate_tax ) { + foreach ( $discounts->get_discounts( true ) as $coupon_code => $coupon_discounts ) { + $coupon_discount_tax_amounts[ $coupon_code ] = 0; + + foreach ( $coupon_discounts as $item_key => $coupon_discount ) { + $item = $this->items[ $item_key ]; + + if ( $item->product->is_taxable() ) { + // Item subtotals were sent, so set 3rd param. + $item_tax = wc_round_tax_total( array_sum( WC_Tax::calc_tax( $coupon_discount, $item->tax_rates, $item->price_includes_tax ) ), 0 ); + + // Sum total tax. + $coupon_discount_tax_amounts[ $coupon_code ] += $item_tax; + + // Remove tax from discount total. + if ( $item->price_includes_tax ) { + $coupon_discount_amounts[ $coupon_code ] -= $item_tax; + } + } + } + } + } + + $this->coupon_discount_totals = (array) $discounts->get_discounts_by_item( true ); + $this->coupon_discount_tax_totals = $coupon_discount_tax_amounts; + + if ( wc_prices_include_tax() ) { + $this->set_total( 'discounts_total', array_sum( $this->coupon_discount_totals ) - array_sum( $this->coupon_discount_tax_totals ) ); + $this->set_total( 'discounts_tax_total', array_sum( $this->coupon_discount_tax_totals ) ); + } else { + $this->set_total( 'discounts_total', array_sum( $this->coupon_discount_totals ) ); + $this->set_total( 'discounts_tax_total', array_sum( $this->coupon_discount_tax_totals ) ); + } + + $this->cart->set_coupon_discount_totals( wc_remove_number_precision_deep( $coupon_discount_amounts ) ); + $this->cart->set_coupon_discount_tax_totals( wc_remove_number_precision_deep( $coupon_discount_tax_amounts ) ); + + // Add totals to cart object. Note: Discount total for cart is excl tax. + $this->cart->set_discount_total( $this->get_total( 'discounts_total' ) ); + $this->cart->set_discount_tax( $this->get_total( 'discounts_tax_total' ) ); + } + + /** + * Triggers the cart fees API, grabs the list of fees, and calculates taxes. + * + * Note: This class sets the totals for the 'object' as they are calculated. This is so that APIs like the fees API can see these totals if needed. + * + * @since 3.2.0 + */ + protected function calculate_fee_totals() { + $this->get_fees_from_cart(); + + $this->set_total( 'fees_total', array_sum( wp_list_pluck( $this->fees, 'total' ) ) ); + $this->set_total( 'fees_total_tax', array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) ); + + $this->cart->fees_api()->set_fees( wp_list_pluck( $this->fees, 'object' ) ); + $this->cart->set_fee_total( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total' ) ) ) ); + $this->cart->set_fee_tax( wc_remove_number_precision_deep( array_sum( wp_list_pluck( $this->fees, 'total_tax' ) ) ) ); + $this->cart->set_fee_taxes( wc_remove_number_precision_deep( $this->combine_item_taxes( wp_list_pluck( $this->fees, 'taxes' ) ) ) ); + } + + /** + * Calculate any shipping taxes. + * + * @since 3.2.0 + */ + protected function calculate_shipping_totals() { + $this->get_shipping_from_cart(); + $this->set_total( 'shipping_total', array_sum( wp_list_pluck( $this->shipping, 'total' ) ) ); + $this->set_total( 'shipping_tax_total', array_sum( wp_list_pluck( $this->shipping, 'total_tax' ) ) ); + + $this->cart->set_shipping_total( $this->get_total( 'shipping_total' ) ); + $this->cart->set_shipping_tax( $this->get_total( 'shipping_tax_total' ) ); + $this->cart->set_shipping_taxes( wc_remove_number_precision_deep( $this->combine_item_taxes( wp_list_pluck( $this->shipping, 'taxes' ) ) ) ); + } + + /** + * Main cart totals. + * + * @since 3.2.0 + */ + protected function calculate_totals() { + $this->set_total( 'total', round( $this->get_total( 'items_total', true ) + $this->get_total( 'fees_total', true ) + $this->get_total( 'shipping_total', true ) + array_sum( $this->get_merged_taxes( true ) ), 0 ) ); + $this->cart->set_total_tax( array_sum( $this->get_merged_taxes( false ) ) ); + + // Allow plugins to hook and alter totals before final total is calculated. + if ( has_action( 'woocommerce_calculate_totals' ) ) { + do_action( 'woocommerce_calculate_totals', $this->cart ); + } + + // Allow plugins to filter the grand total, and sum the cart totals in case of modifications. + $this->cart->set_total( max( 0, apply_filters( 'woocommerce_calculated_total', $this->get_total( 'total' ), $this->cart ) ) ); + } + + /** + * Apply rounding to an array of taxes before summing. Rounds to store DP setting, ignoring precision. + * + * @since 3.2.6 + * @param float $value Tax value. + * @return float + */ + protected function round_line_tax( $value ) { + if ( ! $this->round_at_subtotal() ) { + $value = wc_round_tax_total( $value, 0 ); + } + return $value; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-cart.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart.php new file mode 100644 index 0000000..a642609 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-cart.php @@ -0,0 +1,1969 @@ + 0, + 'subtotal_tax' => 0, + 'shipping_total' => 0, + 'shipping_tax' => 0, + 'shipping_taxes' => array(), + 'discount_total' => 0, + 'discount_tax' => 0, + 'cart_contents_total' => 0, + 'cart_contents_tax' => 0, + 'cart_contents_taxes' => array(), + 'fee_total' => 0, + 'fee_tax' => 0, + 'fee_taxes' => array(), + 'total' => 0, + 'total_tax' => 0, + ); + /** + * Store calculated totals. + * + * @var array + */ + protected $totals = array(); + + /** + * Reference to the cart session handling class. + * + * @var WC_Cart_Session + */ + protected $session; + + /** + * Reference to the cart fees API class. + * + * @var WC_Cart_Fees + */ + protected $fees_api; + + /** + * Constructor for the cart class. Loads options and hooks in the init method. + */ + public function __construct() { + $this->session = new WC_Cart_Session( $this ); + $this->fees_api = new WC_Cart_Fees( $this ); + $this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' ); + + // Register hooks for the objects. + $this->session->init(); + + add_action( 'woocommerce_add_to_cart', array( $this, 'calculate_totals' ), 20, 0 ); + add_action( 'woocommerce_applied_coupon', array( $this, 'calculate_totals' ), 20, 0 ); + add_action( 'woocommerce_cart_item_removed', array( $this, 'calculate_totals' ), 20, 0 ); + add_action( 'woocommerce_cart_item_restored', array( $this, 'calculate_totals' ), 20, 0 ); + add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_items' ), 1 ); + add_action( 'woocommerce_check_cart_items', array( $this, 'check_cart_coupons' ), 1 ); + add_action( 'woocommerce_after_checkout_validation', array( $this, 'check_customer_coupons' ), 1 ); + } + + /** + * When cloning, ensure object properties are handled. + * + * These properties store a reference to the cart, so we use new instead of clone. + */ + public function __clone() { + $this->session = clone $this->session; + $this->fees_api = clone $this->fees_api; + } + + /* + |-------------------------------------------------------------------------- + | Getters. + |-------------------------------------------------------------------------- + | + | Methods to retrieve class properties and avoid direct access. + */ + + /** + * Gets cart contents. + * + * @since 3.2.0 + * @return array of applied coupons + */ + public function get_cart_contents() { + return (array) $this->cart_contents; + } + + /** + * Return items removed from the cart. + * + * @since 3.2.0 + * @return array + */ + public function get_removed_cart_contents() { + return (array) $this->removed_cart_contents; + } + + /** + * Gets the array of applied coupon codes. + * + * @return array of applied coupons + */ + public function get_applied_coupons() { + return (array) $this->applied_coupons; + } + + /** + * Return all calculated coupon totals. + * + * @since 3.2.0 + * @return array + */ + public function get_coupon_discount_totals() { + return (array) $this->coupon_discount_totals; + } + /** + * Return all calculated coupon tax totals. + * + * @since 3.2.0 + * @return array + */ + public function get_coupon_discount_tax_totals() { + return (array) $this->coupon_discount_tax_totals; + } + + /** + * Return all calculated totals. + * + * @since 3.2.0 + * @return array + */ + public function get_totals() { + return empty( $this->totals ) ? $this->default_totals : $this->totals; + } + + /** + * Get a total. + * + * @since 3.2.0 + * @param string $key Key of element in $totals array. + * @return mixed + */ + protected function get_totals_var( $key ) { + return isset( $this->totals[ $key ] ) ? $this->totals[ $key ] : $this->default_totals[ $key ]; + } + + /** + * Get subtotal. + * + * @since 3.2.0 + * @return float + */ + public function get_subtotal() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'subtotal' ) ); + } + + /** + * Get subtotal. + * + * @since 3.2.0 + * @return float + */ + public function get_subtotal_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'subtotal_tax' ) ); + } + + /** + * Get discount_total. + * + * @since 3.2.0 + * @return float + */ + public function get_discount_total() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'discount_total' ) ); + } + + /** + * Get discount_tax. + * + * @since 3.2.0 + * @return float + */ + public function get_discount_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'discount_tax' ) ); + } + + /** + * Get shipping_total. + * + * @since 3.2.0 + * @return float + */ + public function get_shipping_total() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'shipping_total' ) ); + } + + /** + * Get shipping_tax. + * + * @since 3.2.0 + * @return float + */ + public function get_shipping_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'shipping_tax' ) ); + } + + /** + * Gets cart total. This is the total of items in the cart, but after discounts. Subtotal is before discounts. + * + * @since 3.2.0 + * @return float + */ + public function get_cart_contents_total() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'cart_contents_total' ) ); + } + + /** + * Gets cart tax amount. + * + * @since 3.2.0 + * @return float + */ + public function get_cart_contents_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'cart_contents_tax' ) ); + } + + /** + * Gets cart total after calculation. + * + * @since 3.2.0 + * @param string $context If the context is view, the value will be formatted for display. This keeps it compatible with pre-3.2 versions. + * @return float + */ + public function get_total( $context = 'view' ) { + $total = apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'total' ) ); + return 'view' === $context ? apply_filters( 'woocommerce_cart_total', wc_price( $total ) ) : $total; + } + + /** + * Get total tax amount. + * + * @since 3.2.0 + * @return float + */ + public function get_total_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'total_tax' ) ); + } + + /** + * Get total fee amount. + * + * @since 3.2.0 + * @return float + */ + public function get_fee_total() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'fee_total' ) ); + } + + /** + * Get total fee tax amount. + * + * @since 3.2.0 + * @return float + */ + public function get_fee_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'fee_tax' ) ); + } + + /** + * Get taxes. + * + * @since 3.2.0 + */ + public function get_shipping_taxes() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'shipping_taxes' ) ); + } + + /** + * Get taxes. + * + * @since 3.2.0 + */ + public function get_cart_contents_taxes() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'cart_contents_taxes' ) ); + } + + /** + * Get taxes. + * + * @since 3.2.0 + */ + public function get_fee_taxes() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, $this->get_totals_var( 'fee_taxes' ) ); + } + + /** + * Return whether or not the cart is displaying prices including tax, rather than excluding tax. + * + * @since 3.3.0 + * @return bool + */ + public function display_prices_including_tax() { + return apply_filters( 'woocommerce_cart_' . __FUNCTION__, 'incl' === $this->tax_display_cart ); + } + + /* + |-------------------------------------------------------------------------- + | Setters. + |-------------------------------------------------------------------------- + | + | Methods to set class properties and avoid direct access. + */ + + /** + * Sets the contents of the cart. + * + * @param array $value Cart array. + */ + public function set_cart_contents( $value ) { + $this->cart_contents = (array) $value; + } + + /** + * Set items removed from the cart. + * + * @since 3.2.0 + * @param array $value Item array. + */ + public function set_removed_cart_contents( $value = array() ) { + $this->removed_cart_contents = (array) $value; + } + + /** + * Sets the array of applied coupon codes. + * + * @param array $value List of applied coupon codes. + */ + public function set_applied_coupons( $value = array() ) { + $this->applied_coupons = (array) $value; + } + + /** + * Return all calculated coupon totals. + * + * @since 3.2.0 + * @param array $value Value to set. + */ + public function set_coupon_discount_totals( $value = array() ) { + $this->coupon_discount_totals = (array) $value; + } + /** + * Return all calculated coupon tax totals. + * + * @since 3.2.0 + * @param array $value Value to set. + */ + public function set_coupon_discount_tax_totals( $value = array() ) { + $this->coupon_discount_tax_totals = (array) $value; + } + + /** + * Set all calculated totals. + * + * @since 3.2.0 + * @param array $value Value to set. + */ + public function set_totals( $value = array() ) { + $this->totals = wp_parse_args( $value, $this->default_totals ); + } + + /** + * Set subtotal. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_subtotal( $value ) { + $this->totals['subtotal'] = wc_format_decimal( $value, wc_get_price_decimals() ); + } + + /** + * Set subtotal. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_subtotal_tax( $value ) { + $this->totals['subtotal_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set discount_total. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_discount_total( $value ) { + $this->totals['discount_total'] = wc_cart_round_discount( $value, wc_get_price_decimals() ); + } + + /** + * Set discount_tax. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_discount_tax( $value ) { + $this->totals['discount_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set shipping_total. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_shipping_total( $value ) { + $this->totals['shipping_total'] = wc_format_decimal( $value, wc_get_price_decimals() ); + } + + /** + * Set shipping_tax. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_shipping_tax( $value ) { + $this->totals['shipping_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set cart_contents_total. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_cart_contents_total( $value ) { + $this->totals['cart_contents_total'] = wc_format_decimal( $value, wc_get_price_decimals() ); + } + + /** + * Set cart tax amount. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_cart_contents_tax( $value ) { + $this->totals['cart_contents_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set cart total. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_total( $value ) { + $this->totals['total'] = wc_format_decimal( $value, wc_get_price_decimals() ); + } + + /** + * Set total tax amount. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_total_tax( $value ) { + $this->totals['total_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set fee amount. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_fee_total( $value ) { + $this->totals['fee_total'] = wc_format_decimal( $value, wc_get_price_decimals() ); + } + + /** + * Set fee tax. + * + * @since 3.2.0 + * @param string $value Value to set. + */ + public function set_fee_tax( $value ) { + $this->totals['fee_tax'] = wc_round_tax_total( $value ); + } + + /** + * Set taxes. + * + * @since 3.2.0 + * @param array $value Tax values. + */ + public function set_shipping_taxes( $value ) { + $this->totals['shipping_taxes'] = (array) $value; + } + + /** + * Set taxes. + * + * @since 3.2.0 + * @param array $value Tax values. + */ + public function set_cart_contents_taxes( $value ) { + $this->totals['cart_contents_taxes'] = (array) $value; + } + + /** + * Set taxes. + * + * @since 3.2.0 + * @param array $value Tax values. + */ + public function set_fee_taxes( $value ) { + $this->totals['fee_taxes'] = (array) $value; + } + + /* + |-------------------------------------------------------------------------- + | Helper methods. + |-------------------------------------------------------------------------- + */ + + /** + * Returns the cart and shipping taxes, merged. + * + * @return array merged taxes + */ + public function get_taxes() { + return apply_filters( 'woocommerce_cart_get_taxes', wc_array_merge_recursive_numeric( $this->get_shipping_taxes(), $this->get_cart_contents_taxes(), $this->get_fee_taxes() ), $this ); + } + + /** + * Returns the contents of the cart in an array. + * + * @return array contents of the cart + */ + public function get_cart() { + if ( ! did_action( 'wp_loaded' ) ) { + wc_doing_it_wrong( __FUNCTION__, __( 'Get cart should not be called before the wp_loaded action.', 'woocommerce' ), '2.3' ); + } + if ( ! did_action( 'woocommerce_cart_loaded_from_session' ) ) { + $this->session->get_cart_from_session(); + } + return array_filter( $this->get_cart_contents() ); + } + + /** + * Returns a specific item in the cart. + * + * @param string $item_key Cart item key. + * @return array Item data + */ + public function get_cart_item( $item_key ) { + return isset( $this->cart_contents[ $item_key ] ) ? $this->cart_contents[ $item_key ] : array(); + } + + /** + * Checks if the cart is empty. + * + * @return bool + */ + public function is_empty() { + return 0 === count( $this->get_cart() ); + } + + /** + * Empties the cart and optionally the persistent cart too. + * + * @param bool $clear_persistent_cart Should the persistant cart be cleared too. Defaults to true. + */ + public function empty_cart( $clear_persistent_cart = true ) { + $this->cart_contents = array(); + $this->removed_cart_contents = array(); + $this->shipping_methods = array(); + $this->coupon_discount_totals = array(); + $this->coupon_discount_tax_totals = array(); + $this->applied_coupons = array(); + $this->totals = $this->default_totals; + + if ( $clear_persistent_cart ) { + $this->session->persistent_cart_destroy(); + } + + $this->fees_api->remove_all_fees(); + + do_action( 'woocommerce_cart_emptied' ); + } + + /** + * Get number of items in the cart. + * + * @return int + */ + public function get_cart_contents_count() { + return apply_filters( 'woocommerce_cart_contents_count', array_sum( wp_list_pluck( $this->get_cart(), 'quantity' ) ) ); + } + + /** + * Get weight of items in the cart. + * + * @since 2.5.0 + * @return int + */ + public function get_cart_contents_weight() { + $weight = 0; + + foreach ( $this->get_cart() as $cart_item_key => $values ) { + if ( $values['data']->has_weight() ) { + $weight += (float) $values['data']->get_weight() * $values['quantity']; + } + } + + return apply_filters( 'woocommerce_cart_contents_weight', $weight ); + } + + /** + * Get cart items quantities - merged so we can do accurate stock checks on items across multiple lines. + * + * @return array + */ + public function get_cart_item_quantities() { + $quantities = array(); + + foreach ( $this->get_cart() as $cart_item_key => $values ) { + $product = $values['data']; + $quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $values['quantity'] : $values['quantity']; + } + + return $quantities; + } + + /** + * Check all cart items for errors. + */ + public function check_cart_items() { + $return = true; + $result = $this->check_cart_item_validity(); + + if ( is_wp_error( $result ) ) { + wc_add_notice( $result->get_error_message(), 'error' ); + $return = false; + } + + $result = $this->check_cart_item_stock(); + + if ( is_wp_error( $result ) ) { + wc_add_notice( $result->get_error_message(), 'error' ); + $return = false; + } + + return $return; + + } + + /** + * Check cart coupons for errors. + */ + public function check_cart_coupons() { + foreach ( $this->get_applied_coupons() as $code ) { + $coupon = new WC_Coupon( $code ); + + if ( ! $coupon->is_valid() ) { + $coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_INVALID_REMOVED ); + $this->remove_coupon( $code ); + } + } + } + + /** + * Looks through cart items and checks the posts are not trashed or deleted. + * + * @return bool|WP_Error + */ + public function check_cart_item_validity() { + $return = true; + + foreach ( $this->get_cart() as $cart_item_key => $values ) { + $product = $values['data']; + + if ( ! $product || ! $product->exists() || 'trash' === $product->get_status() ) { + $this->set_quantity( $cart_item_key, 0 ); + $return = new WP_Error( 'invalid', __( 'An item which is no longer available was removed from your cart.', 'woocommerce' ) ); + } + } + + return $return; + } + + /** + * Looks through the cart to check each item is in stock. If not, add an error. + * + * @return bool|WP_Error + */ + public function check_cart_item_stock() { + global $wpdb; + + $error = new WP_Error(); + $product_qty_in_cart = $this->get_cart_item_quantities(); + + foreach ( $this->get_cart() as $cart_item_key => $values ) { + $product = $values['data']; + + /** + * Check stock based on stock-status. + */ + if ( ! $product->is_in_stock() ) { + /* translators: %s: product name */ + $error->add( 'out-of-stock', sprintf( __( 'Sorry, "%s" is not in stock. Please edit your cart and try again. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name() ) ); + return $error; + } + + if ( ! $product->managing_stock() ) { + continue; + } + + /** + * Check stock based on all items in the cart. + */ + if ( ! $product->has_enough_stock( $product_qty_in_cart[ $product->get_stock_managed_by_id() ] ) ) { + /* translators: 1: product name 2: quantity in stock */ + $error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s in stock). Please edit your cart and try again. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity(), $product ) ) ); + return $error; + } + + /** + * Finally consider any held stock, from pending orders. + */ + if ( get_option( 'woocommerce_hold_stock_minutes' ) > 0 && ! $product->backorders_allowed() ) { + $order_id = isset( WC()->session->order_awaiting_payment ) ? absint( WC()->session->order_awaiting_payment ) : 0; + $held_stock = $wpdb->get_var( + $wpdb->prepare( + " + SELECT SUM( order_item_meta.meta_value ) AS held_qty + FROM {$wpdb->posts} AS posts + LEFT JOIN {$wpdb->prefix}woocommerce_order_items as order_items ON posts.ID = order_items.order_id + LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id + LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta as order_item_meta2 ON order_items.order_item_id = order_item_meta2.order_item_id + WHERE order_item_meta.meta_key = '_qty' + AND order_item_meta2.meta_key = %s AND order_item_meta2.meta_value = %d + AND posts.post_type IN ( '" . implode( "','", wc_get_order_types() ) . "' ) + AND posts.post_status = 'wc-pending' + AND posts.ID != %d;", + 'variation' === get_post_type( $product->get_stock_managed_by_id() ) ? '_variation_id' : '_product_id', + $product->get_stock_managed_by_id(), + $order_id + ) + ); // WPCS: unprepared SQL ok. + + if ( $product->get_stock_quantity() < ( $held_stock + $product_qty_in_cart[ $product->get_stock_managed_by_id() ] ) ) { + /* translators: 1: product name 2: minutes */ + $error->add( 'out-of-stock', sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order right now. Please try again in %2$d minutes or edit your cart and try again. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), get_option( 'woocommerce_hold_stock_minutes' ) ) ); + return $error; + } + } + } + + return true; + } + + /** + * Gets and formats a list of cart item data + variations for display on the frontend. + * + * @param array $cart_item Cart item object. + * @param bool $flat Should the data be returned flat or in a list. + * @return string + */ + public function get_item_data( $cart_item, $flat = false ) { + wc_deprecated_function( 'WC_Cart::get_item_data', '3.3', 'wc_get_formatted_cart_item_data' ); + + return wc_get_formatted_cart_item_data( $cart_item, $flat ); + } + + /** + * Gets cross sells based on the items in the cart. + * + * @return array cross_sells (item ids) + */ + public function get_cross_sells() { + $cross_sells = array(); + $in_cart = array(); + if ( ! $this->is_empty() ) { + foreach ( $this->get_cart() as $cart_item_key => $values ) { + if ( $values['quantity'] > 0 ) { + $cross_sells = array_merge( $values['data']->get_cross_sell_ids(), $cross_sells ); + $in_cart[] = $values['product_id']; + } + } + } + $cross_sells = array_diff( $cross_sells, $in_cart ); + return apply_filters( 'woocommerce_cart_crosssell_ids', wp_parse_id_list( $cross_sells ), $this ); + } + + /** + * Gets the url to remove an item from the cart. + * + * @param string $cart_item_key contains the id of the cart item. + * @return string url to page + */ + public function get_remove_url( $cart_item_key ) { + wc_deprecated_function( 'WC_Cart::get_remove_url', '3.3', 'wc_get_cart_remove_url' ); + + return wc_get_cart_remove_url( $cart_item_key ); + } + + /** + * Gets the url to re-add an item into the cart. + * + * @param string $cart_item_key Cart item key to undo. + * @return string url to page + */ + public function get_undo_url( $cart_item_key ) { + wc_deprecated_function( 'WC_Cart::get_undo_url', '3.3', 'wc_get_cart_undo_url' ); + + return wc_get_cart_undo_url( $cart_item_key ); + } + + /** + * Get taxes, merged by code, formatted ready for output. + * + * @return array + */ + public function get_tax_totals() { + $taxes = $this->get_taxes(); + $tax_totals = array(); + + foreach ( $taxes as $key => $tax ) { + $code = WC_Tax::get_rate_code( $key ); + + if ( $code || apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) === $key ) { + if ( ! isset( $tax_totals[ $code ] ) ) { + $tax_totals[ $code ] = new stdClass(); + $tax_totals[ $code ]->amount = 0; + } + $tax_totals[ $code ]->tax_rate_id = $key; + $tax_totals[ $code ]->is_compound = WC_Tax::is_compound( $key ); + $tax_totals[ $code ]->label = WC_Tax::get_rate_label( $key ); + $tax_totals[ $code ]->amount += wc_round_tax_total( $tax ); + $tax_totals[ $code ]->formatted_amount = wc_price( wc_round_tax_total( $tax_totals[ $code ]->amount ) ); + } + } + + if ( apply_filters( 'woocommerce_cart_hide_zero_taxes', true ) ) { + $amounts = array_filter( wp_list_pluck( $tax_totals, 'amount' ) ); + $tax_totals = array_intersect_key( $tax_totals, $amounts ); + } + + return apply_filters( 'woocommerce_cart_tax_totals', $tax_totals, $this ); + } + + /** + * Get all tax classes for items in the cart. + * + * @return array + */ + public function get_cart_item_tax_classes() { + $found_tax_classes = array(); + + foreach ( WC()->cart->get_cart() as $item ) { + if ( $item['data'] && ( $item['data']->is_taxable() || $item['data']->is_shipping_taxable() ) ) { + $found_tax_classes[] = $item['data']->get_tax_class(); + } + } + + return array_unique( $found_tax_classes ); + } + + /** + * Get all tax classes for shipping based on the items in the cart. + * + * @return array + */ + public function get_cart_item_tax_classes_for_shipping() { + $found_tax_classes = array(); + + foreach ( WC()->cart->get_cart() as $item ) { + if ( $item['data'] && ( $item['data']->is_shipping_taxable() ) ) { + $found_tax_classes[] = $item['data']->get_tax_class(); + } + } + + return array_unique( $found_tax_classes ); + } + + /** + * Determines the value that the customer spent and the subtotal + * displayed, used for things like coupon validation. + * + * Since the coupon lines are displayed based on the TAX DISPLAY value + * of cart, this is used to determine the spend. + * + * If cart totals are shown including tax, use the subtotal. + * If cart totals are shown excluding tax, use the subtotal ex tax + * (tax is shown after coupons). + * + * @since 2.6.0 + * @return string + */ + public function get_displayed_subtotal() { + return $this->display_prices_including_tax() ? $this->get_subtotal() + $this->get_subtotal_tax() : $this->get_subtotal(); + } + + /** + * Check if product is in the cart and return cart item key. + * + * Cart item key will be unique based on the item and its properties, such as variations. + * + * @param mixed $cart_id id of product to find in the cart. + * @return string cart item key + */ + public function find_product_in_cart( $cart_id = false ) { + if ( false !== $cart_id ) { + if ( is_array( $this->cart_contents ) && isset( $this->cart_contents[ $cart_id ] ) ) { + return $cart_id; + } + } + return ''; + } + + /** + * Generate a unique ID for the cart item being added. + * + * @param int $product_id - id of the product the key is being generated for. + * @param int $variation_id of the product the key is being generated for. + * @param array $variation data for the cart item. + * @param array $cart_item_data other cart item data passed which affects this items uniqueness in the cart. + * @return string cart item key + */ + public function generate_cart_id( $product_id, $variation_id = 0, $variation = array(), $cart_item_data = array() ) { + $id_parts = array( $product_id ); + + if ( $variation_id && 0 !== $variation_id ) { + $id_parts[] = $variation_id; + } + + if ( is_array( $variation ) && ! empty( $variation ) ) { + $variation_key = ''; + foreach ( $variation as $key => $value ) { + $variation_key .= trim( $key ) . trim( $value ); + } + $id_parts[] = $variation_key; + } + + if ( is_array( $cart_item_data ) && ! empty( $cart_item_data ) ) { + $cart_item_data_key = ''; + foreach ( $cart_item_data as $key => $value ) { + if ( is_array( $value ) || is_object( $value ) ) { + $value = http_build_query( $value ); + } + $cart_item_data_key .= trim( $key ) . trim( $value ); + + } + $id_parts[] = $cart_item_data_key; + } + + return apply_filters( 'woocommerce_cart_id', md5( implode( '_', $id_parts ) ), $product_id, $variation_id, $variation, $cart_item_data ); + } + + /** + * Add a product to the cart. + * + * @throws Exception Plugins can throw an exception to prevent adding to cart. + * @param int $product_id contains the id of the product to add to the cart. + * @param int $quantity contains the quantity of the item to add. + * @param int $variation_id ID of the variation being added to the cart. + * @param array $variation attribute values. + * @param array $cart_item_data extra cart item data we want to pass into the item. + * @return string|bool $cart_item_key + */ + public function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) { + try { + $product_id = absint( $product_id ); + $variation_id = absint( $variation_id ); + + // Ensure we don't add a variation to the cart directly by variation ID. + if ( 'product_variation' === get_post_type( $product_id ) ) { + $variation_id = $product_id; + $product_id = wp_get_post_parent_id( $variation_id ); + } + + $product_data = wc_get_product( $variation_id ? $variation_id : $product_id ); + $quantity = apply_filters( 'woocommerce_add_to_cart_quantity', $quantity, $product_id ); + + if ( $quantity <= 0 || ! $product_data || 'trash' === $product_data->get_status() ) { + return false; + } + + // Load cart item data - may be added by other plugins. + $cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id, $quantity ); + + // Generate a ID based on product ID, variation ID, variation data, and other cart item data. + $cart_id = $this->generate_cart_id( $product_id, $variation_id, $variation, $cart_item_data ); + + // Find the cart item key in the existing cart. + $cart_item_key = $this->find_product_in_cart( $cart_id ); + + // Force quantity to 1 if sold individually and check for existing item in cart. + if ( $product_data->is_sold_individually() ) { + $quantity = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $quantity, $product_id, $variation_id, $cart_item_data ); + $found_in_cart = apply_filters( 'woocommerce_add_to_cart_sold_individually_found_in_cart', $cart_item_key && $this->cart_contents[ $cart_item_key ]['quantity'] > 0, $product_id, $variation_id, $cart_item_data, $cart_id ); + + if ( $found_in_cart ) { + /* translators: %s: product name */ + throw new Exception( sprintf( '%s %s', wc_get_cart_url(), __( 'View cart', 'woocommerce' ), sprintf( __( 'You cannot add another "%s" to your cart.', 'woocommerce' ), $product_data->get_name() ) ) ); + } + } + + if ( ! $product_data->is_purchasable() ) { + throw new Exception( __( 'Sorry, this product cannot be purchased.', 'woocommerce' ) ); + } + + // Stock check - only check if we're managing stock and backorders are not allowed. + if ( ! $product_data->is_in_stock() ) { + /* translators: %s: product name */ + throw new Exception( sprintf( __( 'You cannot add "%s" to the cart because the product is out of stock.', 'woocommerce' ), $product_data->get_name() ) ); + } + + if ( ! $product_data->has_enough_stock( $quantity ) ) { + /* translators: 1: product name 2: quantity in stock */ + throw new Exception( sprintf( __( 'You cannot add that amount of "%1$s" to the cart because there is not enough stock (%2$s remaining).', 'woocommerce' ), $product_data->get_name(), wc_format_stock_quantity_for_display( $product_data->get_stock_quantity(), $product_data ) ) ); + } + + // Stock check - this time accounting for whats already in-cart. + if ( $product_data->managing_stock() ) { + $products_qty_in_cart = $this->get_cart_item_quantities(); + + if ( isset( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ] ) && ! $product_data->has_enough_stock( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ] + $quantity ) ) { + throw new Exception( + sprintf( + '%s %s', + wc_get_cart_url(), + __( 'View Cart', 'woocommerce' ), + /* translators: 1: quantity in stock 2: current quantity */ + sprintf( __( 'You cannot add that amount to the cart — we have %1$s in stock and you already have %2$s in your cart.', 'woocommerce' ), wc_format_stock_quantity_for_display( $product_data->get_stock_quantity(), $product_data ), wc_format_stock_quantity_for_display( $products_qty_in_cart[ $product_data->get_stock_managed_by_id() ], $product_data ) ) + ) + ); + } + } + + // If cart_item_key is set, the item is already in the cart. + if ( $cart_item_key ) { + $new_quantity = $quantity + $this->cart_contents[ $cart_item_key ]['quantity']; + $this->set_quantity( $cart_item_key, $new_quantity, false ); + } else { + $cart_item_key = $cart_id; + + // Add item after merging with $cart_item_data - hook to allow plugins to modify cart item. + $this->cart_contents[ $cart_item_key ] = apply_filters( + 'woocommerce_add_cart_item', array_merge( + $cart_item_data, array( + 'key' => $cart_item_key, + 'product_id' => $product_id, + 'variation_id' => $variation_id, + 'variation' => $variation, + 'quantity' => $quantity, + 'data' => $product_data, + 'data_hash' => wc_get_cart_item_data_hash( $product_data ), + ) + ), $cart_item_key + ); + } + + do_action( 'woocommerce_add_to_cart', $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data ); + + return $cart_item_key; + + } catch ( Exception $e ) { + if ( $e->getMessage() ) { + wc_add_notice( $e->getMessage(), 'error' ); + } + return false; + } + } + + /** + * Remove a cart item. + * + * @since 2.3.0 + * @param string $cart_item_key Cart item key to remove from the cart. + * @return bool + */ + public function remove_cart_item( $cart_item_key ) { + if ( isset( $this->cart_contents[ $cart_item_key ] ) ) { + $this->removed_cart_contents[ $cart_item_key ] = $this->cart_contents[ $cart_item_key ]; + + unset( $this->removed_cart_contents[ $cart_item_key ]['data'] ); + + do_action( 'woocommerce_remove_cart_item', $cart_item_key, $this ); + + unset( $this->cart_contents[ $cart_item_key ] ); + + do_action( 'woocommerce_cart_item_removed', $cart_item_key, $this ); + + return true; + } + return false; + } + + /** + * Restore a cart item. + * + * @param string $cart_item_key Cart item key to restore to the cart. + * @return bool + */ + public function restore_cart_item( $cart_item_key ) { + if ( isset( $this->removed_cart_contents[ $cart_item_key ] ) ) { + $restore_item = $this->removed_cart_contents[ $cart_item_key ]; + $this->cart_contents[ $cart_item_key ] = $restore_item; + $this->cart_contents[ $cart_item_key ]['data'] = wc_get_product( $restore_item['variation_id'] ? $restore_item['variation_id'] : $restore_item['product_id'] ); + + do_action( 'woocommerce_restore_cart_item', $cart_item_key, $this ); + + unset( $this->removed_cart_contents[ $cart_item_key ] ); + + do_action( 'woocommerce_cart_item_restored', $cart_item_key, $this ); + + return true; + } + return false; + } + + /** + * Set the quantity for an item in the cart. + * + * @param string $cart_item_key contains the id of the cart item. + * @param int $quantity contains the quantity of the item. + * @param bool $refresh_totals whether or not to calculate totals after setting the new qty. + * @return bool + */ + public function set_quantity( $cart_item_key, $quantity = 1, $refresh_totals = true ) { + if ( 0 === $quantity || $quantity < 0 ) { + do_action( 'woocommerce_before_cart_item_quantity_zero', $cart_item_key, $this ); + unset( $this->cart_contents[ $cart_item_key ] ); + } else { + $old_quantity = $this->cart_contents[ $cart_item_key ]['quantity']; + $this->cart_contents[ $cart_item_key ]['quantity'] = $quantity; + do_action( 'woocommerce_after_cart_item_quantity_update', $cart_item_key, $quantity, $old_quantity, $this ); + } + + if ( $refresh_totals ) { + $this->calculate_totals(); + } + + return true; + } + + /** + * Get cart's owner. + * + * @since 3.2.0 + * @return WC_Customer + */ + public function get_customer() { + return WC()->customer; + } + + /** + * Calculate totals for the items in the cart. + * + * @uses WC_Cart_Totals + */ + public function calculate_totals() { + $this->reset_totals(); + + if ( $this->is_empty() ) { + $this->session->set_session(); + return; + } + + do_action( 'woocommerce_before_calculate_totals', $this ); + + new WC_Cart_Totals( $this ); + + do_action( 'woocommerce_after_calculate_totals', $this ); + } + + /** + * Looks at the totals to see if payment is actually required. + * + * @return bool + */ + public function needs_payment() { + return apply_filters( 'woocommerce_cart_needs_payment', 0 < $this->get_total( 'edit' ), $this ); + } + + /* + * Shipping related functions. + */ + + /** + * Uses the shipping class to calculate shipping then gets the totals when its finished. + */ + public function calculate_shipping() { + $this->shipping_methods = $this->needs_shipping() ? $this->get_chosen_shipping_methods( WC()->shipping->calculate_shipping( $this->get_shipping_packages() ) ) : array(); + + $shipping_taxes = wp_list_pluck( $this->shipping_methods, 'taxes' ); + $merged_taxes = array(); + foreach ( $shipping_taxes as $taxes ) { + foreach ( $taxes as $tax_id => $tax_amount ) { + if ( ! isset( $merged_taxes[ $tax_id ] ) ) { + $merged_taxes[ $tax_id ] = 0; + } + $merged_taxes[ $tax_id ] += $tax_amount; + } + } + + $this->set_shipping_total( array_sum( wp_list_pluck( $this->shipping_methods, 'cost' ) ) ); + $this->set_shipping_tax( array_sum( $merged_taxes ) ); + $this->set_shipping_taxes( $merged_taxes ); + + return $this->shipping_methods; + } + + /** + * Given a set of packages with rates, get the chosen ones only. + * + * @since 3.2.0 + * @param array $calculated_shipping_packages Array of packages. + * @return array + */ + protected function get_chosen_shipping_methods( $calculated_shipping_packages = array() ) { + $chosen_methods = array(); + // Get chosen methods for each package to get our totals. + foreach ( $calculated_shipping_packages as $key => $package ) { + $chosen_method = wc_get_chosen_shipping_method_for_package( $key, $package ); + if ( $chosen_method ) { + $chosen_methods[ $key ] = $package['rates'][ $chosen_method ]; + } + } + return $chosen_methods; + } + + /** + * Filter items needing shipping callback. + * + * @since 3.0.0 + * @param array $item Item to check for shipping. + * @return bool + */ + protected function filter_items_needing_shipping( $item ) { + $product = $item['data']; + return $product && $product->needs_shipping(); + } + + /** + * Get only items that need shipping. + * + * @since 3.0.0 + * @return array + */ + protected function get_items_needing_shipping() { + return array_filter( $this->get_cart(), array( $this, 'filter_items_needing_shipping' ) ); + } + + /** + * Get packages to calculate shipping for. + * + * This lets us calculate costs for carts that are shipped to multiple locations. + * + * Shipping methods are responsible for looping through these packages. + * + * By default we pass the cart itself as a package - plugins can change this. + * through the filter and break it up. + * + * @since 1.5.4 + * @return array of cart items + */ + public function get_shipping_packages() { + return apply_filters( + 'woocommerce_cart_shipping_packages', + array( + array( + 'contents' => $this->get_items_needing_shipping(), + 'contents_cost' => array_sum( wp_list_pluck( $this->get_items_needing_shipping(), 'line_total' ) ), + 'applied_coupons' => $this->get_applied_coupons(), + 'user' => array( + 'ID' => get_current_user_id(), + ), + 'destination' => array( + 'country' => $this->get_customer()->get_shipping_country(), + 'state' => $this->get_customer()->get_shipping_state(), + 'postcode' => $this->get_customer()->get_shipping_postcode(), + 'city' => $this->get_customer()->get_shipping_city(), + 'address' => $this->get_customer()->get_shipping_address(), + 'address_2' => $this->get_customer()->get_shipping_address_2(), + ), + 'cart_subtotal' => $this->get_displayed_subtotal(), + ), + ) + ); + } + + /** + * Looks through the cart to see if shipping is actually required. + * + * @return bool whether or not the cart needs shipping + */ + public function needs_shipping() { + if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( true ) ) { + return false; + } + $needs_shipping = false; + + foreach ( $this->get_cart_contents() as $cart_item_key => $values ) { + if ( $values['data']->needs_shipping() ) { + $needs_shipping = true; + break; + } + } + + return apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping ); + } + + /** + * Should the shipping address form be shown. + * + * @return bool + */ + public function needs_shipping_address() { + return apply_filters( 'woocommerce_cart_needs_shipping_address', true === $this->needs_shipping() && ! wc_ship_to_billing_address_only() ); + } + + /** + * Sees if the customer has entered enough data to calc the shipping yet. + * + * @return bool + */ + public function show_shipping() { + if ( ! wc_shipping_enabled() || ! $this->get_cart_contents() ) { + return false; + } + + if ( 'yes' === get_option( 'woocommerce_shipping_cost_requires_address' ) ) { + if ( ! $this->get_customer()->has_calculated_shipping() ) { + if ( ! $this->get_customer()->get_shipping_country() || ( ! $this->get_customer()->get_shipping_state() && ! $this->get_customer()->get_shipping_postcode() ) ) { + return false; + } + } + } + + return apply_filters( 'woocommerce_cart_ready_to_calc_shipping', true ); + } + + /** + * Gets the shipping total (after calculation). + * + * @return string price or string for the shipping total + */ + public function get_cart_shipping_total() { + if ( 0 < $this->get_shipping_total() ) { + + if ( $this->display_prices_including_tax() ) { + $return = wc_price( $this->shipping_total + $this->shipping_tax_total ); + + if ( $this->shipping_tax_total > 0 && ! wc_prices_include_tax() ) { + $return .= ' ' . WC()->countries->inc_tax_or_vat() . ''; + } + + return $return; + } else { + $return = wc_price( $this->shipping_total ); + + if ( $this->shipping_tax_total > 0 && wc_prices_include_tax() ) { + $return .= ' ' . WC()->countries->ex_tax_or_vat() . ''; + } + + return $return; + } + } else { + return __( 'Free!', 'woocommerce' ); + } + } + + /** + * Check for user coupons (now that we have billing email). If a coupon is invalid, add an error. + * + * Checks two types of coupons: + * 1. Where a list of customer emails are set (limits coupon usage to those defined). + * 2. Where a usage_limit_per_user is set (limits coupon usage to a number based on user ID and email). + * + * @param array $posted Post data. + */ + public function check_customer_coupons( $posted ) { + foreach ( $this->get_applied_coupons() as $code ) { + $coupon = new WC_Coupon( $code ); + + if ( $coupon->is_valid() ) { + + // Get user and posted emails to compare. + $current_user = wp_get_current_user(); + $check_emails = array_unique( + array_filter( + array_map( + 'strtolower', array_map( + 'sanitize_email', array( + $posted['billing_email'], + $current_user->user_email, + ) + ) + ) + ) + ); + + // Limit to defined email addresses. + $restrictions = $coupon->get_email_restrictions(); + + if ( is_array( $restrictions ) && 0 < count( $restrictions ) && ! $this->is_coupon_emails_allowed( $check_emails, $restrictions ) ) { + $coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED ); + $this->remove_coupon( $code ); + } + + // Usage limits per user - check against billing and user email and user ID. + $limit_per_user = $coupon->get_usage_limit_per_user(); + + if ( 0 < $limit_per_user ) { + $used_by = $coupon->get_used_by(); + $usage_count = 0; + $user_id_matches = array( get_current_user_id() ); + + // Check usage against emails. + foreach ( $check_emails as $check_email ) { + $usage_count += count( array_keys( $used_by, $check_email, true ) ); + $user = get_user_by( 'email', $check_email ); + $user_id_matches[] = $user ? $user->ID : 0; + } + + // Check against billing emails of existing users. + $users_query = new WP_User_Query( + array( + 'fields' => 'ID', + 'meta_query' => array( + array( + 'key' => '_billing_email', + 'value' => $check_emails, + 'compare' => 'IN', + ), + ), + ) + ); // WPCS: slow query ok. + + $user_id_matches = array_unique( array_filter( array_merge( $user_id_matches, $users_query->get_results() ) ) ); + + foreach ( $user_id_matches as $user_id ) { + $usage_count += count( array_keys( $used_by, (string) $user_id, true ) ); + } + + if ( $usage_count >= $coupon->get_usage_limit_per_user() ) { + $coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_USAGE_LIMIT_REACHED ); + $this->remove_coupon( $code ); + } + } + } + } + } + + /** + * Checks if the given email address(es) matches the ones specified on the coupon. + * + * @param array $check_emails Array of customer email addresses. + * @param array $restrictions Array of allowed email addresses. + * @return bool + */ + public function is_coupon_emails_allowed( $check_emails, $restrictions ) { + + foreach ( $check_emails as $check_email ) { + // With a direct match we return true. + if ( in_array( $check_email, $restrictions, true ) ) { + return true; + } + + // Go through the allowed emails and return true if the email matches a wildcard. + foreach ( $restrictions as $restriction ) { + // Convert to PHP-regex syntax. + $regex = '/' . str_replace( '*', '(.+)?', $restriction ) . '/'; + preg_match( $regex, $check_email, $match ); + if ( ! empty( $match ) ) { + return true; + } + } + } + + // No matches, this one isn't allowed. + return false; + } + + + /** + * Returns whether or not a discount has been applied. + * + * @param string $coupon_code Coupon code to check. + * @return bool + */ + public function has_discount( $coupon_code = '' ) { + return $coupon_code ? in_array( wc_format_coupon_code( $coupon_code ), $this->applied_coupons, true ) : count( $this->applied_coupons ) > 0; + } + + /** + * Applies a coupon code passed to the method. + * + * @param string $coupon_code - The code to apply. + * @return bool True if the coupon is applied, false if it does not exist or cannot be applied. + */ + public function apply_coupon( $coupon_code ) { + // Coupons are globally disabled. + if ( ! wc_coupons_enabled() ) { + return false; + } + + // Sanitize coupon code. + $coupon_code = wc_format_coupon_code( $coupon_code ); + + // Get the coupon. + $the_coupon = new WC_Coupon( $coupon_code ); + + // Prevent adding coupons by post ID. + if ( $the_coupon->get_code() !== $coupon_code ) { + $the_coupon->set_code( $coupon_code ); + $the_coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_EXIST ); + return false; + } + + // Check it can be used with cart. + if ( ! $the_coupon->is_valid() ) { + wc_add_notice( $the_coupon->get_error_message(), 'error' ); + return false; + } + + // Check if applied. + if ( $this->has_discount( $coupon_code ) ) { + $the_coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_ALREADY_APPLIED ); + return false; + } + + // If its individual use then remove other coupons. + if ( $the_coupon->get_individual_use() ) { + $coupons_to_keep = apply_filters( 'woocommerce_apply_individual_use_coupon', array(), $the_coupon, $this->applied_coupons ); + + foreach ( $this->applied_coupons as $applied_coupon ) { + $keep_key = array_search( $applied_coupon, $coupons_to_keep, true ); + if ( false === $keep_key ) { + $this->remove_coupon( $applied_coupon ); + } else { + unset( $coupons_to_keep[ $keep_key ] ); + } + } + + if ( ! empty( $coupons_to_keep ) ) { + $this->applied_coupons += $coupons_to_keep; + } + } + + // Check to see if an individual use coupon is set. + if ( $this->applied_coupons ) { + foreach ( $this->applied_coupons as $code ) { + $coupon = new WC_Coupon( $code ); + + if ( $coupon->get_individual_use() && false === apply_filters( 'woocommerce_apply_with_individual_use_coupon', false, $the_coupon, $coupon, $this->applied_coupons ) ) { + + // Reject new coupon. + $coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY ); + + return false; + } + } + } + + $this->applied_coupons[] = $coupon_code; + + // Choose free shipping. + if ( $the_coupon->get_free_shipping() ) { + $packages = WC()->shipping->get_packages(); + $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); + + foreach ( $packages as $i => $package ) { + $chosen_shipping_methods[ $i ] = 'free_shipping'; + } + + WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods ); + } + + $the_coupon->add_coupon_message( WC_Coupon::WC_COUPON_SUCCESS ); + + do_action( 'woocommerce_applied_coupon', $coupon_code ); + + return true; + } + + /** + * Get array of applied coupon objects and codes. + * + * @param null $deprecated No longer used. + * @return array of applied coupons + */ + public function get_coupons( $deprecated = null ) { + $coupons = array(); + + if ( 'order' === $deprecated ) { + return $coupons; + } + + foreach ( $this->get_applied_coupons() as $code ) { + $coupon = new WC_Coupon( $code ); + $coupons[ $code ] = $coupon; + } + + return $coupons; + } + + /** + * Get the discount amount for a used coupon. + * + * @param string $code coupon code. + * @param bool $ex_tax inc or ex tax. + * @return float discount amount + */ + public function get_coupon_discount_amount( $code, $ex_tax = true ) { + $totals = $this->get_coupon_discount_totals(); + $discount_amount = isset( $totals[ $code ] ) ? $totals[ $code ] : 0; + + if ( ! $ex_tax ) { + $discount_amount += $this->get_coupon_discount_tax_amount( $code ); + } + + return wc_cart_round_discount( $discount_amount, wc_get_price_decimals() ); + } + + /** + * Get the discount tax amount for a used coupon (for tax inclusive prices). + * + * @param string $code coupon code. + * @return float discount amount + */ + public function get_coupon_discount_tax_amount( $code ) { + $totals = $this->get_coupon_discount_tax_totals(); + return wc_cart_round_discount( isset( $totals[ $code ] ) ? $totals[ $code ] : 0, wc_get_price_decimals() ); + } + + /** + * Remove coupons from the cart of a defined type. Type 1 is before tax, type 2 is after tax. + * + * @param null $deprecated No longer used. + */ + public function remove_coupons( $deprecated = null ) { + $this->set_coupon_discount_totals( array() ); + $this->set_coupon_discount_tax_totals( array() ); + $this->set_applied_coupons( array() ); + $this->session->set_session(); + } + + /** + * Remove a single coupon by code. + * + * @param string $coupon_code Code of the coupon to remove. + * @return bool + */ + public function remove_coupon( $coupon_code ) { + $coupon_code = wc_format_coupon_code( $coupon_code ); + $position = array_search( $coupon_code, $this->get_applied_coupons(), true ); + + if ( false !== $position ) { + unset( $this->applied_coupons[ $position ] ); + } + + WC()->session->set( 'refresh_totals', true ); + + do_action( 'woocommerce_removed_coupon', $coupon_code ); + + return true; + } + + /** + * Trigger an action so 3rd parties can add custom fees. + * + * @since 2.0.0 + */ + public function calculate_fees() { + do_action( 'woocommerce_cart_calculate_fees', $this ); + } + + /** + * Return reference to fees API. + * + * @since 3.2.0 + * @return WC_Cart_Fees + */ + public function fees_api() { + return $this->fees_api; + } + + /** + * Add additional fee to the cart. + * + * This method should be called on a callback attached to the + * woocommerce_cart_calculate_fees action during cart/checkout. Fees do not + * persist. + * + * @uses WC_Cart_Fees::add_fee + * @param string $name Unique name for the fee. Multiple fees of the same name cannot be added. + * @param float $amount Fee amount (do not enter negative amounts). + * @param bool $taxable Is the fee taxable? (default: false). + * @param string $tax_class The tax class for the fee if taxable. A blank string is standard tax class. (default: ''). + */ + public function add_fee( $name, $amount, $taxable = false, $tax_class = '' ) { + $this->fees_api()->add_fee( + array( + 'name' => $name, + 'amount' => (float) $amount, + 'taxable' => $taxable, + 'tax_class' => $tax_class, + ) + ); + } + + /** + * Return all added fees from the Fees API. + * + * @uses WC_Cart_Fees::get_fees + * @return array + */ + public function get_fees() { + $fees = $this->fees_api()->get_fees(); + + if ( property_exists( $this, 'fees' ) ) { + $fees = $fees + (array) $this->fees; + } + return $fees; + } + + /** + * Gets the total excluding taxes. + * + * @return string formatted price + */ + public function get_total_ex_tax() { + return apply_filters( 'woocommerce_cart_total_ex_tax', wc_price( max( 0, $this->get_total( 'edit' ) - $this->get_total_tax() ) ) ); + } + + /** + * Gets the cart contents total (after calculation). + * + * @return string formatted price + */ + public function get_cart_total() { + return apply_filters( 'woocommerce_cart_contents_total', wc_price( wc_prices_include_tax() ? $this->get_cart_contents_total() + $this->get_cart_contents_tax() : $this->get_cart_contents_total() ) ); + } + + /** + * Gets the sub total (after calculation). + * + * @param bool $compound whether to include compound taxes. + * @return string formatted price + */ + public function get_cart_subtotal( $compound = false ) { + /** + * If the cart has compound tax, we want to show the subtotal as cart + shipping + non-compound taxes (after discount). + */ + if ( $compound ) { + $cart_subtotal = wc_price( $this->get_cart_contents_total() + $this->get_shipping_total() + $this->get_taxes_total( false, false ) ); + + } elseif ( $this->display_prices_including_tax() ) { + $cart_subtotal = wc_price( $this->get_subtotal() + $this->get_subtotal_tax() ); + + if ( $this->get_subtotal_tax() > 0 && ! wc_prices_include_tax() ) { + $cart_subtotal .= ' ' . WC()->countries->inc_tax_or_vat() . ''; + } + } else { + $cart_subtotal = wc_price( $this->get_subtotal() ); + + if ( $this->get_subtotal_tax() > 0 && wc_prices_include_tax() ) { + $cart_subtotal .= ' ' . WC()->countries->ex_tax_or_vat() . ''; + } + } + + return apply_filters( 'woocommerce_cart_subtotal', $cart_subtotal, $compound, $this ); + } + + /** + * Get the product row price per item. + * + * @param WC_Product $product Product object. + * @return string formatted price + */ + public function get_product_price( $product ) { + if ( $this->display_prices_including_tax() ) { + $product_price = wc_get_price_including_tax( $product ); + } else { + $product_price = wc_get_price_excluding_tax( $product ); + } + return apply_filters( 'woocommerce_cart_product_price', wc_price( $product_price ), $product ); + } + + /** + * Get the product row subtotal. + * + * Gets the tax etc to avoid rounding issues. + * + * When on the checkout (review order), this will get the subtotal based on the customer's tax rate rather than the base rate. + * + * @param WC_Product $product Product object. + * @param int $quantity Quantity being purchased. + * @return string formatted price + */ + public function get_product_subtotal( $product, $quantity ) { + $price = $product->get_price(); + + if ( $product->is_taxable() ) { + + if ( $this->display_prices_including_tax() ) { + $row_price = wc_get_price_including_tax( $product, array( 'qty' => $quantity ) ); + $product_subtotal = wc_price( $row_price ); + + if ( ! wc_prices_include_tax() && $this->get_subtotal_tax() > 0 ) { + $product_subtotal .= ' ' . WC()->countries->inc_tax_or_vat() . ''; + } + } else { + $row_price = wc_get_price_excluding_tax( $product, array( 'qty' => $quantity ) ); + $product_subtotal = wc_price( $row_price ); + + if ( wc_prices_include_tax() && $this->get_subtotal_tax() > 0 ) { + $product_subtotal .= ' ' . WC()->countries->ex_tax_or_vat() . ''; + } + } + } else { + $row_price = $price * $quantity; + $product_subtotal = wc_price( $row_price ); + } + + return apply_filters( 'woocommerce_cart_product_subtotal', $product_subtotal, $product, $quantity, $this ); + } + + /** + * Gets the cart tax (after calculation). + * + * @return string formatted price + */ + public function get_cart_tax() { + $cart_total_tax = wc_round_tax_total( $this->get_cart_contents_tax() + $this->get_shipping_tax() + $this->get_fee_tax() ); + + return apply_filters( 'woocommerce_get_cart_tax', $cart_total_tax ? wc_price( $cart_total_tax ) : '' ); + } + + /** + * Get a tax amount. + * + * @param string $tax_rate_id ID of the tax rate to get taxes for. + * @return float amount + */ + public function get_tax_amount( $tax_rate_id ) { + $taxes = wc_array_merge_recursive_numeric( $this->get_cart_contents_taxes(), $this->get_fee_taxes() ); + return isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ] : 0; + } + + /** + * Get a tax amount. + * + * @param string $tax_rate_id ID of the tax rate to get taxes for. + * @return float amount + */ + public function get_shipping_tax_amount( $tax_rate_id ) { + $taxes = $this->get_shipping_taxes(); + return isset( $taxes[ $tax_rate_id ] ) ? $taxes[ $tax_rate_id ] : 0; + } + + /** + * Get tax row amounts with or without compound taxes includes. + * + * @param bool $compound True if getting compound taxes. + * @param bool $display True if getting total to display. + * @return float price + */ + public function get_taxes_total( $compound = true, $display = true ) { + $total = 0; + $taxes = $this->get_taxes(); + foreach ( $taxes as $key => $tax ) { + if ( ! $compound && WC_Tax::is_compound( $key ) ) { + continue; + } + $total += $tax; + } + if ( $display ) { + $total = wc_round_tax_total( $total ); + } + return apply_filters( 'woocommerce_cart_taxes_total', $total, $compound, $display, $this ); + } + + /** + * Gets the total discount amount. + * + * @return mixed formatted price or false if there are none + */ + public function get_total_discount() { + return apply_filters( 'woocommerce_cart_total_discount', $this->get_discount_total() ? wc_price( $this->get_discount_total() ) : false, $this ); + } + + /** + * Reset cart totals to the defaults. Useful before running calculations. + * + * @access private + */ + private function reset_totals() { + $this->totals = $this->default_totals; + $this->fees_api->remove_all_fees(); + do_action( 'woocommerce_cart_reset', $this, false ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-checkout.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-checkout.php new file mode 100644 index 0000000..dc150bf --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-checkout.php @@ -0,0 +1,1096 @@ +is_registration_enabled() ) { + remove_filter( 'woocommerce_checkout_registration_enabled', '__return_true', 0 ); + remove_filter( 'woocommerce_checkout_registration_enabled', '__return_false', 0 ); + add_filter( 'woocommerce_checkout_registration_enabled', $bool_value ? '__return_true' : '__return_false', 0 ); + } + break; + case 'enable_guest_checkout': + $bool_value = wc_string_to_bool( $value ); + + if ( $bool_value === $this->is_registration_required() ) { + remove_filter( 'woocommerce_checkout_registration_required', '__return_true', 0 ); + remove_filter( 'woocommerce_checkout_registration_required', '__return_false', 0 ); + add_filter( 'woocommerce_checkout_registration_required', $bool_value ? '__return_false' : '__return_true', 0 ); + } + break; + case 'checkout_fields': + $this->fields = $value; + break; + case 'shipping_methods': + WC()->session->set( 'chosen_shipping_methods', $value ); + break; + case 'posted': + $this->legacy_posted_data = $value; + break; + } + } + + /** + * Gets the legacy public variables for backwards compatibility. + * + * @param string $key Key. + * @return array|string + */ + public function __get( $key ) { + if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ), true ) && empty( $this->legacy_posted_data ) ) { + $this->legacy_posted_data = $this->get_posted_data(); + } + + switch ( $key ) { + case 'enable_signup': + return $this->is_registration_enabled(); + case 'enable_guest_checkout': + return ! $this->is_registration_required(); + case 'must_create_account': + return $this->is_registration_required() && ! is_user_logged_in(); + case 'checkout_fields': + return $this->get_checkout_fields(); + case 'posted': + wc_doing_it_wrong( 'WC_Checkout->posted', 'Use $_POST directly.', '3.0.0' ); + return $this->legacy_posted_data; + case 'shipping_method': + return $this->legacy_posted_data['shipping_method']; + case 'payment_method': + return $this->legacy_posted_data['payment_method']; + case 'customer_id': + return apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() ); + case 'shipping_methods': + return (array) WC()->session->get( 'chosen_shipping_methods' ); + } + } + + /** + * Cloning is forbidden. + */ + public function __clone() { + wc_doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', 'woocommerce' ), '2.1' ); + } + + /** + * Unserializing instances of this class is forbidden. + */ + public function __wakeup() { + wc_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'woocommerce' ), '2.1' ); + } + + /** + * Is registration required to checkout? + * + * @since 3.0.0 + * @return boolean + */ + public function is_registration_required() { + return apply_filters( 'woocommerce_checkout_registration_required', 'yes' !== get_option( 'woocommerce_enable_guest_checkout' ) ); + } + + /** + * Is registration enabled on the checkout page? + * + * @since 3.0.0 + * @return boolean + */ + public function is_registration_enabled() { + return apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) ); + } + + /** + * Get an array of checkout fields. + * + * @param string $fieldset to get. + * @return array + */ + public function get_checkout_fields( $fieldset = '' ) { + if ( ! is_null( $this->fields ) ) { + return $fieldset ? $this->fields[ $fieldset ] : $this->fields; + } + + $this->fields = array( + 'billing' => WC()->countries->get_address_fields( + $this->get_value( 'billing_country' ), + 'billing_' + ), + 'shipping' => WC()->countries->get_address_fields( + $this->get_value( 'shipping_country' ), + 'shipping_' + ), + 'account' => array(), + 'order' => array( + 'order_comments' => array( + 'type' => 'textarea', + 'class' => array( 'notes' ), + 'label' => __( 'Order notes', 'woocommerce' ), + 'placeholder' => esc_attr__( + 'Notes about your order, e.g. special notes for delivery.', + 'woocommerce' + ), + ), + ), + ); + + if ( 'no' === get_option( 'woocommerce_registration_generate_username' ) ) { + $this->fields['account']['account_username'] = array( + 'type' => 'text', + 'label' => __( 'Account username', 'woocommerce' ), + 'required' => true, + 'placeholder' => esc_attr__( 'Username', 'woocommerce' ), + ); + } + + if ( 'no' === get_option( 'woocommerce_registration_generate_password' ) ) { + $this->fields['account']['account_password'] = array( + 'type' => 'password', + 'label' => __( 'Create account password', 'woocommerce' ), + 'required' => true, + 'placeholder' => esc_attr__( 'Password', 'woocommerce' ), + ); + } + + $this->fields = apply_filters( 'woocommerce_checkout_fields', $this->fields ); + + return $fieldset ? $this->fields[ $fieldset ] : $this->fields; + } + + /** + * When we process the checkout, lets ensure cart items are rechecked to prevent checkout. + */ + public function check_cart_items() { + do_action( 'woocommerce_check_cart_items' ); + } + + /** + * Output the billing form. + */ + public function checkout_form_billing() { + wc_get_template( 'checkout/form-billing.php', array( 'checkout' => $this ) ); + } + + /** + * Output the shipping form. + */ + public function checkout_form_shipping() { + wc_get_template( 'checkout/form-shipping.php', array( 'checkout' => $this ) ); + } + + /** + * Create an order. Error codes: + * 520 - Cannot insert order into the database. + * 521 - Cannot get order after creation. + * 522 - Cannot update order. + * 525 - Cannot create line item. + * 526 - Cannot create fee item. + * 527 - Cannot create shipping item. + * 528 - Cannot create tax item. + * 529 - Cannot create coupon item. + * + * @throws Exception When checkout validation fails. + * @param array $data Posted data. + * @return int|WP_ERROR + */ + public function create_order( $data ) { + // Give plugins the opportunity to create an order themselves. + $order_id = apply_filters( 'woocommerce_create_order', null, $this ); + if ( $order_id ) { + return $order_id; + } + + try { + $order_id = absint( WC()->session->get( 'order_awaiting_payment' ) ); + $cart_hash = md5( wp_json_encode( wc_clean( WC()->cart->get_cart_for_session() ) ) . WC()->cart->total ); + $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); + $order = $order_id ? wc_get_order( $order_id ) : null; + + /** + * If there is an order pending payment, we can resume it here so + * long as it has not changed. If the order has changed, i.e. + * different items or cost, create a new order. We use a hash to + * detect changes which is based on cart items + order total. + */ + if ( $order && $order->has_cart_hash( $cart_hash ) && $order->has_status( array( 'pending', 'failed' ) ) ) { + // Action for 3rd parties. + do_action( 'woocommerce_resume_order', $order_id ); + + // Remove all items - we will re-add them later. + $order->remove_order_items(); + } else { + $order = new WC_Order(); + } + + foreach ( $data as $key => $value ) { + if ( is_callable( array( $order, "set_{$key}" ) ) ) { + $order->{"set_{$key}"}( $value ); + + // Store custom fields prefixed with wither shipping_ or billing_. This is for backwards compatibility with 2.6.x. + // TODO: Fix conditional to only include shipping/billing address fields in a smarter way without str(i)pos. + } elseif ( ( 0 === stripos( $key, 'billing_' ) || 0 === stripos( $key, 'shipping_' ) ) + && ! in_array( $key, array( 'shipping_method', 'shipping_total', 'shipping_tax' ), true ) ) { + $order->update_meta_data( '_' . $key, $value ); + } + } + + $order->set_created_via( 'checkout' ); + $order->set_cart_hash( $cart_hash ); + $order->set_customer_id( apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() ) ); + $order->set_currency( get_woocommerce_currency() ); + $order->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) ); + $order->set_customer_ip_address( WC_Geolocation::get_ip_address() ); + $order->set_customer_user_agent( wc_get_user_agent() ); + $order->set_customer_note( isset( $data['order_comments'] ) ? $data['order_comments'] : '' ); + $order->set_payment_method( isset( $available_gateways[ $data['payment_method'] ] ) ? $available_gateways[ $data['payment_method'] ] : $data['payment_method'] ); + $order->set_shipping_total( WC()->cart->get_shipping_total() ); + $order->set_discount_total( WC()->cart->get_discount_total() ); + $order->set_discount_tax( WC()->cart->get_discount_tax() ); + $order->set_cart_tax( WC()->cart->get_cart_contents_tax() + WC()->cart->get_fee_tax() ); + $order->set_shipping_tax( WC()->cart->get_shipping_tax() ); + $order->set_total( WC()->cart->get_total( 'edit' ) ); + $this->create_order_line_items( $order, WC()->cart ); + $this->create_order_fee_lines( $order, WC()->cart ); + $this->create_order_shipping_lines( $order, WC()->session->get( 'chosen_shipping_methods' ), WC()->shipping->get_packages() ); + $this->create_order_tax_lines( $order, WC()->cart ); + $this->create_order_coupon_lines( $order, WC()->cart ); + + /** + * Action hook to adjust order before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order', $order, $data ); + + // Save the order. + $order_id = $order->save(); + + do_action( 'woocommerce_checkout_update_order_meta', $order_id, $data ); + + return $order_id; + } catch ( Exception $e ) { + return new WP_Error( 'checkout-error', $e->getMessage() ); + } + } + + /** + * Add line items to the order. + * + * @param WC_Order $order Order instance. + * @param WC_Cart $cart Cart instance. + */ + public function create_order_line_items( &$order, $cart ) { + foreach ( $cart->get_cart() as $cart_item_key => $values ) { + /** + * Filter hook to get initial item object. + * + * @since 3.1.0 + */ + $item = apply_filters( 'woocommerce_checkout_create_order_line_item_object', new WC_Order_Item_Product(), $cart_item_key, $values, $order ); + $product = $values['data']; + $item->legacy_values = $values; // @deprecated For legacy actions. + $item->legacy_cart_item_key = $cart_item_key; // @deprecated For legacy actions. + $item->set_props( + array( + 'quantity' => $values['quantity'], + 'variation' => $values['variation'], + 'subtotal' => $values['line_subtotal'], + 'total' => $values['line_total'], + 'subtotal_tax' => $values['line_subtotal_tax'], + 'total_tax' => $values['line_tax'], + 'taxes' => $values['line_tax_data'], + ) + ); + + if ( $product ) { + $item->set_props( + array( + 'name' => $product->get_name(), + 'tax_class' => $product->get_tax_class(), + 'product_id' => $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id(), + 'variation_id' => $product->is_type( 'variation' ) ? $product->get_id() : 0, + ) + ); + } + + $item->set_backorder_meta(); + + /** + * Action hook to adjust item before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order_line_item', $item, $cart_item_key, $values, $order ); + + // Add item to order and save. + $order->add_item( $item ); + } + } + + /** + * Add fees to the order. + * + * @param WC_Order $order Order instance. + * @param WC_Cart $cart Cart instance. + */ + public function create_order_fee_lines( &$order, $cart ) { + foreach ( $cart->get_fees() as $fee_key => $fee ) { + $item = new WC_Order_Item_Fee(); + $item->legacy_fee = $fee; // @deprecated For legacy actions. + $item->legacy_fee_key = $fee_key; // @deprecated For legacy actions. + $item->set_props( + array( + 'name' => $fee->name, + 'tax_class' => $fee->taxable ? $fee->tax_class : 0, + 'amount' => $fee->amount, + 'total' => $fee->total, + 'total_tax' => $fee->tax, + 'taxes' => array( + 'total' => $fee->tax_data, + ), + ) + ); + + /** + * Action hook to adjust item before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order_fee_item', $item, $fee_key, $fee, $order ); + + // Add item to order and save. + $order->add_item( $item ); + } + } + + /** + * Add shipping lines to the order. + * + * @param WC_Order $order Order Instance. + * @param array $chosen_shipping_methods Chosen shipping methods. + * @param array $packages Packages. + */ + public function create_order_shipping_lines( &$order, $chosen_shipping_methods, $packages ) { + foreach ( $packages as $package_key => $package ) { + if ( isset( $chosen_shipping_methods[ $package_key ], $package['rates'][ $chosen_shipping_methods[ $package_key ] ] ) ) { + $shipping_rate = $package['rates'][ $chosen_shipping_methods[ $package_key ] ]; + $item = new WC_Order_Item_Shipping(); + $item->legacy_package_key = $package_key; // @deprecated For legacy actions. + $item->set_props( + array( + 'method_title' => $shipping_rate->label, + 'method_id' => $shipping_rate->method_id, + 'instance_id' => $shipping_rate->instance_id, + 'total' => wc_format_decimal( $shipping_rate->cost ), + 'taxes' => array( + 'total' => $shipping_rate->taxes, + ), + ) + ); + + foreach ( $shipping_rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } + + /** + * Action hook to adjust item before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order_shipping_item', $item, $package_key, $package, $order ); + + // Add item to order and save. + $order->add_item( $item ); + } + } + } + + /** + * Add tax lines to the order. + * + * @param WC_Order $order Order instance. + * @param WC_Cart $cart Cart instance. + */ + public function create_order_tax_lines( &$order, $cart ) { + foreach ( array_keys( $cart->get_cart_contents_taxes() + $cart->get_shipping_taxes() + $cart->get_fee_taxes() ) as $tax_rate_id ) { + if ( $tax_rate_id && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) { + $item = new WC_Order_Item_Tax(); + $item->set_props( + array( + 'rate_id' => $tax_rate_id, + 'tax_total' => $cart->get_tax_amount( $tax_rate_id ), + 'shipping_tax_total' => $cart->get_shipping_tax_amount( $tax_rate_id ), + 'rate_code' => WC_Tax::get_rate_code( $tax_rate_id ), + 'label' => WC_Tax::get_rate_label( $tax_rate_id ), + 'compound' => WC_Tax::is_compound( $tax_rate_id ), + ) + ); + + /** + * Action hook to adjust item before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order_tax_item', $item, $tax_rate_id, $order ); + + // Add item to order and save. + $order->add_item( $item ); + } + } + } + + /** + * Add coupon lines to the order. + * + * @param WC_Order $order Order instance. + * @param WC_Cart $cart Cart instance. + */ + public function create_order_coupon_lines( &$order, $cart ) { + foreach ( $cart->get_coupons() as $code => $coupon ) { + $item = new WC_Order_Item_Coupon(); + $item->set_props( + array( + 'code' => $code, + 'discount' => $cart->get_coupon_discount_amount( $code ), + 'discount_tax' => $cart->get_coupon_discount_tax_amount( $code ), + ) + ); + + // Avoid storing used_by - it's not needed and can get large. + $coupon_data = $coupon->get_data(); + unset( $coupon_data['used_by'] ); + $item->add_meta_data( 'coupon_data', $coupon_data ); + + /** + * Action hook to adjust item before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_create_order_coupon_item', $item, $code, $coupon, $order ); + + // Add item to order and save. + $order->add_item( $item ); + } + } + + /** + * See if a fieldset should be skipped. + * + * @since 3.0.0 + * @param string $fieldset_key Fieldset key. + * @param array $data Posted data. + * @return bool + */ + protected function maybe_skip_fieldset( $fieldset_key, $data ) { + if ( 'shipping' === $fieldset_key && ( ! $data['ship_to_different_address'] || ! WC()->cart->needs_shipping_address() ) ) { + return true; + } + + if ( 'account' === $fieldset_key && ( is_user_logged_in() || ( ! $this->is_registration_required() && empty( $data['createaccount'] ) ) ) ) { + return true; + } + + return false; + } + + /** + * Get posted data from the checkout form. + * + * @since 3.1.0 + * @return array of data. + */ + public function get_posted_data() { + $skipped = array(); + $data = array( + 'terms' => (int) isset( $_POST['terms'] ), // WPCS: input var ok, CSRF ok. + 'createaccount' => (int) ! empty( $_POST['createaccount'] ), // WPCS: input var ok, CSRF ok. + 'payment_method' => isset( $_POST['payment_method'] ) ? wc_clean( wp_unslash( $_POST['payment_method'] ) ) : '', // WPCS: input var ok, CSRF ok. + 'shipping_method' => isset( $_POST['shipping_method'] ) ? wc_clean( wp_unslash( $_POST['shipping_method'] ) ) : '', // WPCS: input var ok, CSRF ok. + 'ship_to_different_address' => ! empty( $_POST['ship_to_different_address'] ) && ! wc_ship_to_billing_address_only(), // WPCS: input var ok, CSRF ok. + 'woocommerce_checkout_update_totals' => isset( $_POST['woocommerce_checkout_update_totals'] ), // WPCS: input var ok, CSRF ok. + ); + foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) { + if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) { + $skipped[] = $fieldset_key; + continue; + } + + foreach ( $fieldset as $key => $field ) { + $type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' ); + + switch ( $type ) { + case 'checkbox': + $value = isset( $_POST[ $key ] ) ? 1 : ''; // WPCS: input var ok, CSRF ok. + break; + case 'multiselect': + $value = isset( $_POST[ $key ] ) ? implode( ', ', wc_clean( wp_unslash( $_POST[ $key ] ) ) ) : ''; // WPCS: input var ok, CSRF ok. + break; + case 'textarea': + $value = isset( $_POST[ $key ] ) ? wc_sanitize_textarea( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok. + break; + default: + $value = isset( $_POST[ $key ] ) ? wc_clean( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok. + break; + } + + $data[ $key ] = apply_filters( 'woocommerce_process_checkout_' . $type . '_field', apply_filters( 'woocommerce_process_checkout_field_' . $key, $value ) ); + } + } + + if ( in_array( 'shipping', $skipped, true ) && ( WC()->cart->needs_shipping_address() || wc_ship_to_billing_address_only() ) ) { + foreach ( $this->get_checkout_fields( 'shipping' ) as $key => $field ) { + $data[ $key ] = isset( $data[ 'billing_' . substr( $key, 9 ) ] ) ? $data[ 'billing_' . substr( $key, 9 ) ] : ''; + } + } + + // BW compatibility. + $this->legacy_posted_data = $data; + + return apply_filters( 'woocommerce_checkout_posted_data', $data ); + } + + /** + * Validates the posted checkout data based on field properties. + * + * @since 3.0.0 + * @param array $data An array of posted data. + * @param WP_Error $errors Validation error. + */ + protected function validate_posted_data( &$data, &$errors ) { + foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) { + if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) { + continue; + } + + foreach ( $fieldset as $key => $field ) { + if ( ! isset( $data[ $key ] ) ) { + continue; + } + $required = ! empty( $field['required'] ); + $format = array_filter( isset( $field['validate'] ) ? (array) $field['validate'] : array() ); + $field_label = isset( $field['label'] ) ? $field['label'] : ''; + + switch ( $fieldset_key ) { + case 'shipping': + /* translators: %s: field name */ + $field_label = sprintf( __( 'Shipping %s', 'woocommerce' ), $field_label ); + break; + case 'billing': + /* translators: %s: field name */ + $field_label = sprintf( __( 'Billing %s', 'woocommerce' ), $field_label ); + break; + } + + if ( in_array( 'postcode', $format, true ) ) { + $country = isset( $data[ $fieldset_key . '_country' ] ) ? $data[ $fieldset_key . '_country' ] : WC()->customer->{"get_{$fieldset_key}_country"}(); + $data[ $key ] = wc_format_postcode( $data[ $key ], $country ); + + if ( '' !== $data[ $key ] && ! WC_Validation::is_postcode( $data[ $key ], $country ) ) { + /* translators: %s: field name */ + $errors->add( 'validation', sprintf( __( '%s is not a valid postcode / ZIP.', 'woocommerce' ), '' . esc_html( $field_label ) . '' ) ); + } + } + + if ( in_array( 'phone', $format, true ) ) { + $data[ $key ] = wc_format_phone_number( $data[ $key ] ); + + if ( '' !== $data[ $key ] && ! WC_Validation::is_phone( $data[ $key ] ) ) { + /* translators: %s: phone number */ + $errors->add( 'validation', sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), '' . esc_html( $field_label ) . '' ) ); + } + } + + if ( in_array( 'email', $format, true ) && '' !== $data[ $key ] ) { + $data[ $key ] = sanitize_email( $data[ $key ] ); + + if ( ! is_email( $data[ $key ] ) ) { + /* translators: %s: email address */ + $errors->add( 'validation', sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '' . esc_html( $field_label ) . '' ) ); + continue; + } + } + + if ( '' !== $data[ $key ] && in_array( 'state', $format, true ) ) { + $country = isset( $data[ $fieldset_key . '_country' ] ) ? $data[ $fieldset_key . '_country' ] : WC()->customer->{"get_{$fieldset_key}_country"}(); + $valid_states = WC()->countries->get_states( $country ); + + if ( ! empty( $valid_states ) && is_array( $valid_states ) && count( $valid_states ) > 0 ) { + $valid_state_values = array_map( 'wc_strtoupper', array_flip( array_map( 'wc_strtoupper', $valid_states ) ) ); + $data[ $key ] = wc_strtoupper( $data[ $key ] ); + + if ( isset( $valid_state_values[ $data[ $key ] ] ) ) { + // With this part we consider state value to be valid as well, convert it to the state key for the valid_states check below. + $data[ $key ] = $valid_state_values[ $data[ $key ] ]; + } + + if ( ! in_array( $data[ $key ], $valid_state_values, true ) ) { + /* translators: 1: state field 2: valid states */ + $errors->add( 'validation', sprintf( __( '%1$s is not valid. Please enter one of the following: %2$s', 'woocommerce' ), '' . esc_html( $field_label ) . '', implode( ', ', $valid_states ) ) ); + } + } + } + + if ( $required && '' === $data[ $key ] ) { + /* translators: %s: field name */ + $errors->add( 'required-field', apply_filters( 'woocommerce_checkout_required_field_notice', sprintf( __( '%s is a required field.', 'woocommerce' ), '' . esc_html( $field_label ) . '' ), $field_label ) ); + } + } + } + } + + /** + * Validates that the checkout has enough info to proceed. + * + * @since 3.0.0 + * @param array $data An array of posted data. + * @param WP_Error $errors Validation errors. + */ + protected function validate_checkout( &$data, &$errors ) { + $this->validate_posted_data( $data, $errors ); + $this->check_cart_items(); + + if ( empty( $data['woocommerce_checkout_update_totals'] ) && empty( $data['terms'] ) && ! empty( $_POST['terms-field'] ) ) { // WPCS: input var ok, CSRF ok. + $errors->add( 'terms', __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ) ); + } + + if ( WC()->cart->needs_shipping() ) { + $shipping_country = WC()->customer->get_shipping_country(); + + if ( empty( $shipping_country ) ) { + $errors->add( 'shipping', __( 'Please enter an address to continue.', 'woocommerce' ) ); + } elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ), true ) ) { + /* translators: %s: shipping location */ + $errors->add( 'shipping', sprintf( __( 'Unfortunately we do not ship %s. Please enter an alternative shipping address.', 'woocommerce' ), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country() ) ); + } else { + $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); + + foreach ( WC()->shipping->get_packages() as $i => $package ) { + if ( ! isset( $chosen_shipping_methods[ $i ], $package['rates'][ $chosen_shipping_methods[ $i ] ] ) ) { + $errors->add( 'shipping', __( 'No shipping method has been selected. Please double check your address, or contact us if you need any help.', 'woocommerce' ) ); + } + } + } + } + + if ( WC()->cart->needs_payment() ) { + $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); + + if ( ! isset( $available_gateways[ $data['payment_method'] ] ) ) { + $errors->add( 'payment', __( 'Invalid payment method.', 'woocommerce' ) ); + } else { + $available_gateways[ $data['payment_method'] ]->validate_fields(); + } + } + + do_action( 'woocommerce_after_checkout_validation', $data, $errors ); + } + + /** + * Set address field for customer. + * + * @since 3.0.7 + * @param string $field String to update. + * @param string $key Field key. + * @param array $data Array of data to get the value from. + */ + protected function set_customer_address_fields( $field, $key, $data ) { + if ( isset( $data[ "billing_{$field}" ] ) ) { + WC()->customer->{"set_billing_{$field}"}( $data[ "billing_{$field}" ] ); + WC()->customer->{"set_shipping_{$field}"}( $data[ "billing_{$field}" ] ); + } + + if ( isset( $data[ "shipping_{$field}" ] ) ) { + WC()->customer->{"set_shipping_{$field}"}( $data[ "shipping_{$field}" ] ); + } + } + + /** + * Update customer and session data from the posted checkout data. + * + * @since 3.0.0 + * @param array $data Posted data. + */ + protected function update_session( $data ) { + // Update both shipping and billing to the passed billing address first if set. + $address_fields = array( + 'address_1', + 'address_2', + 'city', + 'postcode', + 'state', + 'country', + ); + + array_walk( $address_fields, array( $this, 'set_customer_address_fields' ), $data ); + WC()->customer->save(); + + // Update customer shipping and payment method to posted method. + $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' ); + + if ( is_array( $data['shipping_method'] ) ) { + foreach ( $data['shipping_method'] as $i => $value ) { + $chosen_shipping_methods[ $i ] = $value; + } + } + + WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods ); + WC()->session->set( 'chosen_payment_method', $data['payment_method'] ); + + // Update cart totals now we have customer address. + WC()->cart->calculate_totals(); + } + + + /** + * Process an order that does require payment. + * + * @since 3.0.0 + * @param int $order_id Order ID. + * @param string $payment_method Payment method. + */ + protected function process_order_payment( $order_id, $payment_method ) { + $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); + + if ( ! isset( $available_gateways[ $payment_method ] ) ) { + return; + } + + // Store Order ID in session so it can be re-used after payment failure. + WC()->session->set( 'order_awaiting_payment', $order_id ); + + // Process Payment. + $result = $available_gateways[ $payment_method ]->process_payment( $order_id ); + + // Redirect to success/confirmation/payment page. + if ( isset( $result['result'] ) && 'success' === $result['result'] ) { + $result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id ); + + if ( ! is_ajax() ) { + wp_redirect( $result['redirect'] ); + exit; + } + + wp_send_json( $result ); + } + } + + /** + * Process an order that doesn't require payment. + * + * @since 3.0.0 + * @param int $order_id Order ID. + */ + protected function process_order_without_payment( $order_id ) { + $order = wc_get_order( $order_id ); + $order->payment_complete(); + wc_empty_cart(); + + if ( ! is_ajax() ) { + wp_safe_redirect( + apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ) + ); + exit; + } + + wp_send_json( + array( + 'result' => 'success', + 'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ), + ) + ); + } + + /** + * Create a new customer account if needed. + * + * @throws Exception When not able to create customer. + * @param array $data Posted data. + */ + protected function process_customer( $data ) { + $customer_id = apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() ); + + if ( ! is_user_logged_in() && ( $this->is_registration_required() || ! empty( $data['createaccount'] ) ) ) { + $username = ! empty( $data['account_username'] ) ? $data['account_username'] : ''; + $password = ! empty( $data['account_password'] ) ? $data['account_password'] : ''; + $customer_id = wc_create_new_customer( $data['billing_email'], $username, $password ); + + if ( is_wp_error( $customer_id ) ) { + throw new Exception( $customer_id->get_error_message() ); + } + + wp_set_current_user( $customer_id ); + wc_set_customer_auth_cookie( $customer_id ); + + // As we are now logged in, checkout will need to refresh to show logged in data. + WC()->session->set( 'reload_checkout', true ); + + // Also, recalculate cart totals to reveal any role-based discounts that were unavailable before registering. + WC()->cart->calculate_totals(); + } + + // On multisite, ensure user exists on current site, if not add them before allowing login. + if ( $customer_id && is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() ) { + add_user_to_blog( get_current_blog_id(), $customer_id, 'customer' ); + } + + // Add customer info from other fields. + if ( $customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) ) { + $customer = new WC_Customer( $customer_id ); + + if ( ! empty( $data['billing_first_name'] ) ) { + $customer->set_first_name( $data['billing_first_name'] ); + } + + if ( ! empty( $data['billing_last_name'] ) ) { + $customer->set_last_name( $data['billing_last_name'] ); + } + + // If the display name is an email, update to the user's full name. + if ( is_email( $customer->get_display_name() ) ) { + $customer->set_display_name( $data['billing_first_name'] . ' ' . $data['billing_last_name'] ); + } + + foreach ( $data as $key => $value ) { + // Use setters where available. + if ( is_callable( array( $customer, "set_{$key}" ) ) ) { + $customer->{"set_{$key}"}( $value ); + + // Store custom fields prefixed with wither shipping_ or billing_. + } elseif ( 0 === stripos( $key, 'billing_' ) || 0 === stripos( $key, 'shipping_' ) ) { + $customer->update_meta_data( $key, $value ); + } + } + + /** + * Action hook to adjust customer before save. + * + * @since 3.0.0 + */ + do_action( 'woocommerce_checkout_update_customer', $customer, $data ); + + $customer->save(); + } + + do_action( 'woocommerce_checkout_update_user_meta', $customer_id, $data ); + } + + /** + * If checkout failed during an AJAX call, send failure response. + */ + protected function send_ajax_failure_response() { + if ( is_ajax() ) { + // Only print notices if not reloading the checkout, otherwise they're lost in the page reload. + if ( ! isset( WC()->session->reload_checkout ) ) { + ob_start(); + wc_print_notices(); + $messages = ob_get_clean(); + } + + $response = array( + 'result' => 'failure', + 'messages' => isset( $messages ) ? $messages : '', + 'refresh' => isset( WC()->session->refresh_totals ), + 'reload' => isset( WC()->session->reload_checkout ), + ); + + unset( WC()->session->refresh_totals, WC()->session->reload_checkout ); + + wp_send_json( $response ); + } + } + + /** + * Process the checkout after the confirm order button is pressed. + * + * @throws Exception When validation fails. + */ + public function process_checkout() { + try { + $nonce_value = wc_get_var( $_REQUEST['woocommerce-process-checkout-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( empty( $nonce_value ) || ! wp_verify_nonce( $nonce_value, 'woocommerce-process_checkout' ) ) { + WC()->session->set( 'refresh_totals', true ); + throw new Exception( __( 'We were unable to process your order, please try again.', 'woocommerce' ) ); + } + + wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); + wc_set_time_limit( 0 ); + + do_action( 'woocommerce_before_checkout_process' ); + + if ( WC()->cart->is_empty() ) { + /* translators: %s: shop cart url */ + throw new Exception( sprintf( __( 'Sorry, your session has expired. Return to shop', 'woocommerce' ), esc_url( wc_get_page_permalink( 'shop' ) ) ) ); + } + + do_action( 'woocommerce_checkout_process' ); + + $errors = new WP_Error(); + $posted_data = $this->get_posted_data(); + + // Update session for customer and totals. + $this->update_session( $posted_data ); + + // Validate posted data and cart items before proceeding. + $this->validate_checkout( $posted_data, $errors ); + + foreach ( $errors->get_error_messages() as $message ) { + wc_add_notice( $message, 'error' ); + } + + if ( empty( $posted_data['woocommerce_checkout_update_totals'] ) && 0 === wc_notice_count( 'error' ) ) { + $this->process_customer( $posted_data ); + $order_id = $this->create_order( $posted_data ); + $order = wc_get_order( $order_id ); + + if ( is_wp_error( $order_id ) ) { + throw new Exception( $order_id->get_error_message() ); + } + + if ( ! $order ) { + throw new Exception( __( 'Unable to create order.', 'woocommerce' ) ); + } + + do_action( 'woocommerce_checkout_order_processed', $order_id, $posted_data, $order ); + + if ( WC()->cart->needs_payment() ) { + $this->process_order_payment( $order_id, $posted_data['payment_method'] ); + } else { + $this->process_order_without_payment( $order_id ); + } + } + } catch ( Exception $e ) { + wc_add_notice( $e->getMessage(), 'error' ); + } + $this->send_ajax_failure_response(); + } + + /** + * Get a posted address field after sanitization and validation. + * + * @param string $key Field key. + * @param string $type Type of address. Available options: 'billing' or 'shipping'. + * @return string + */ + public function get_posted_address_data( $key, $type = 'billing' ) { + if ( 'billing' === $type || false === $this->legacy_posted_data['ship_to_different_address'] ) { + $return = isset( $this->legacy_posted_data[ 'billing_' . $key ] ) ? $this->legacy_posted_data[ 'billing_' . $key ] : ''; + } else { + $return = isset( $this->legacy_posted_data[ 'shipping_' . $key ] ) ? $this->legacy_posted_data[ 'shipping_' . $key ] : ''; + } + return $return; + } + + /** + * Gets the value either from the posted data, or from the users meta data. + * + * @param string $input Input key. + * @return string + */ + public function get_value( $input ) { + if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK. + return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK. + } + + $value = apply_filters( 'woocommerce_checkout_get_value', null, $input ); + + if ( null !== $value ) { + return $value; + } + + if ( is_callable( array( WC()->customer, "get_$input" ) ) ) { + $value = WC()->customer->{"get_$input"}() ? WC()->customer->{"get_$input"}() : null; + } elseif ( WC()->customer->meta_exists( $input ) ) { + $value = WC()->customer->get_meta( $input, true ); + } + + return apply_filters( 'default_checkout_' . $input, $value, $input ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-cli.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-cli.php new file mode 100644 index 0000000..0c66318 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-cli.php @@ -0,0 +1,43 @@ +includes(); + $this->hooks(); + } + + /** + * Load command files. + */ + private function includes() { + require_once dirname( __FILE__ ) . '/cli/class-wc-cli-runner.php'; + require_once dirname( __FILE__ ) . '/cli/class-wc-cli-rest-command.php'; + require_once dirname( __FILE__ ) . '/cli/class-wc-cli-tool-command.php'; + require_once dirname( __FILE__ ) . '/cli/class-wc-cli-update-command.php'; + } + + /** + * Sets up and hooks WP CLI to our CLI code. + */ + private function hooks() { + WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Runner::after_wp_load' ); + WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Tool_Command::register_commands' ); + WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Update_Command::register_commands' ); + } +} + +new WC_CLI(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-comments.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-comments.php new file mode 100644 index 0000000..54f0d7f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-comments.php @@ -0,0 +1,410 @@ +comment_post_ID ) should keep them safe since only admin and. + * shop managers can view orders anyway. + * + * The frontend view order pages get around this filter by using remove_filter('comments_clauses', array( 'WC_Comments' ,'exclude_order_comments'), 10, 1 ); + * + * @param array $clauses A compacted array of comment query clauses. + * @return array + */ + public static function exclude_order_comments( $clauses ) { + $clauses['where'] .= ( $clauses['where'] ? ' AND ' : '' ) . " comment_type != 'order_note' "; + return $clauses; + } + + /** + * Exclude order comments from feed. + * + * @deprecated 3.1 + * @param mixed $join Deprecated. + */ + public static function exclude_order_comments_from_feed_join( $join ) { + wc_deprecated_function( 'WC_Comments::exclude_order_comments_from_feed_join', '3.1' ); + } + + /** + * Exclude order comments from queries and RSS. + * + * @param string $where The WHERE clause of the query. + * @return string + */ + public static function exclude_order_comments_from_feed_where( $where ) { + return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'order_note' "; + } + + /** + * Exclude webhook comments from queries and RSS. + * + * @since 2.2 + * @param array $clauses A compacted array of comment query clauses. + * @return array + */ + public static function exclude_webhook_comments( $clauses ) { + $clauses['where'] .= ( $clauses['where'] ? ' AND ' : '' ) . " comment_type != 'webhook_delivery' "; + return $clauses; + } + + /** + * Exclude webhooks comments from feed. + * + * @deprecated 3.1 + * @param mixed $join Deprecated. + */ + public static function exclude_webhook_comments_from_feed_join( $join ) { + wc_deprecated_function( 'WC_Comments::exclude_webhook_comments_from_feed_join', '3.1' ); + } + + /** + * Exclude webhook comments from queries and RSS. + * + * @since 2.1 + * @param string $where The WHERE clause of the query. + * @return string + */ + public static function exclude_webhook_comments_from_feed_where( $where ) { + return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'webhook_delivery' "; + } + + /** + * Validate the comment ratings. + * + * @param array $comment_data Comment data. + * @return array + */ + public static function check_comment_rating( $comment_data ) { + // If posting a comment (not trackback etc) and not logged in. + if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) && empty( $_POST['rating'] ) && '' === $comment_data['comment_type'] && 'yes' === get_option( 'woocommerce_enable_review_rating' ) && 'yes' === get_option( 'woocommerce_review_rating_required' ) ) { // WPCS: input var ok, CSRF ok. + wp_die( esc_html__( 'Please rate the product.', 'woocommerce' ) ); + exit; + } + return $comment_data; + } + + /** + * Rating field for comments. + * + * @param int $comment_id Comment ID. + */ + public static function add_comment_rating( $comment_id ) { + if ( isset( $_POST['rating'], $_POST['comment_post_ID'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok. + if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok, CSRF ok, sanitization ok. + return; + } + add_comment_meta( $comment_id, 'rating', intval( $_POST['rating'] ), true ); // WPCS: input var ok, CSRF ok. + + $post_id = isset( $_POST['comment_post_ID'] ) ? absint( $_POST['comment_post_ID'] ) : 0; // WPCS: input var ok, CSRF ok. + if ( $post_id ) { + self::clear_transients( $post_id ); + } + } + } + + /** + * Modify recipient of review email. + * + * @param array $emails Emails. + * @param int $comment_id Comment ID. + * @return array + */ + public static function comment_moderation_recipients( $emails, $comment_id ) { + $comment = get_comment( $comment_id ); + + if ( $comment && 'product' === get_post_type( $comment->comment_post_ID ) ) { + $emails = array( get_option( 'admin_email' ) ); + } + + return $emails; + } + + /** + * Ensure product average rating and review count is kept up to date. + * + * @param int $post_id Post ID. + */ + public static function clear_transients( $post_id ) { + + if ( 'product' === get_post_type( $post_id ) ) { + $product = wc_get_product( $post_id ); + self::get_rating_counts_for_product( $product ); + self::get_average_rating_for_product( $product ); + self::get_review_count_for_product( $product ); + } + } + + /** + * Delete comments count cache whenever there is + * new comment or the status of a comment changes. Cache + * will be regenerated next time WC_Comments::wp_count_comments() + * is called. + */ + public static function delete_comments_count_cache() { + delete_transient( 'wc_count_comments' ); + } + + /** + * Remove order notes and webhook delivery logs from wp_count_comments(). + * + * @since 2.2 + * @param object $stats Comment stats. + * @param int $post_id Post ID. + * @return object + */ + public static function wp_count_comments( $stats, $post_id ) { + global $wpdb; + + if ( 0 === $post_id ) { + $stats = get_transient( 'wc_count_comments' ); + + if ( ! $stats ) { + $stats = array( + 'total_comments' => 0, + 'all' => 0, + ); + + $count = $wpdb->get_results( + " + SELECT comment_approved, COUNT(*) AS num_comments + FROM {$wpdb->comments} + WHERE comment_type NOT IN ('order_note', 'webhook_delivery') + GROUP BY comment_approved + ", ARRAY_A + ); + + $approved = array( + '0' => 'moderated', + '1' => 'approved', + 'spam' => 'spam', + 'trash' => 'trash', + 'post-trashed' => 'post-trashed', + ); + + foreach ( (array) $count as $row ) { + // Don't count post-trashed toward totals. + if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { + $stats['all'] += $row['num_comments']; + $stats['total_comments'] += $row['num_comments']; + } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { + $stats['total_comments'] += $row['num_comments']; + } + if ( isset( $approved[ $row['comment_approved'] ] ) ) { + $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; + } + } + + foreach ( $approved as $key ) { + if ( empty( $stats[ $key ] ) ) { + $stats[ $key ] = 0; + } + } + + $stats = (object) $stats; + set_transient( 'wc_count_comments', $stats ); + } + } + + return $stats; + } + + /** + * Make sure WP displays avatars for comments with the `review` type. + * + * @since 2.3 + * @param array $comment_types Comment types. + * @return array + */ + public static function add_avatar_for_review_comment_type( $comment_types ) { + return array_merge( $comment_types, array( 'review' ) ); + } + + /** + * Determine if a review is from a verified owner at submission. + * + * @param int $comment_id Comment ID. + * @return bool + */ + public static function add_comment_purchase_verification( $comment_id ) { + $comment = get_comment( $comment_id ); + $verified = false; + if ( 'product' === get_post_type( $comment->comment_post_ID ) ) { + $verified = wc_customer_bought_product( $comment->comment_author_email, $comment->user_id, $comment->comment_post_ID ); + add_comment_meta( $comment_id, 'verified', (int) $verified, true ); + } + return $verified; + } + + /** + * Get product rating for a product. Please note this is not cached. + * + * @since 3.0.0 + * @param WC_Product $product Product instance. + * @return float + */ + public static function get_average_rating_for_product( &$product ) { + global $wpdb; + + $count = $product->get_rating_count(); + + if ( $count ) { + $ratings = $wpdb->get_var( + $wpdb->prepare( + " + SELECT SUM(meta_value) FROM $wpdb->commentmeta + LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID + WHERE meta_key = 'rating' + AND comment_post_ID = %d + AND comment_approved = '1' + AND meta_value > 0 + ", $product->get_id() + ) + ); + $average = number_format( $ratings / $count, 2, '.', '' ); + } else { + $average = 0; + } + + $product->set_average_rating( $average ); + + $data_store = $product->get_data_store(); + $data_store->update_average_rating( $product ); + + return $average; + } + + /** + * Get product review count for a product (not replies). Please note this is not cached. + * + * @since 3.0.0 + * @param WC_Product $product Product instance. + * @return int + */ + public static function get_review_count_for_product( &$product ) { + global $wpdb; + + $count = $wpdb->get_var( + $wpdb->prepare( + " + SELECT COUNT(*) FROM $wpdb->comments + WHERE comment_parent = 0 + AND comment_post_ID = %d + AND comment_approved = '1' + ", $product->get_id() + ) + ); + + $product->set_review_count( $count ); + + $data_store = $product->get_data_store(); + $data_store->update_review_count( $product ); + + return $count; + } + + /** + * Get product rating count for a product. Please note this is not cached. + * + * @since 3.0.0 + * @param WC_Product $product Product instance. + * @return int[] + */ + public static function get_rating_counts_for_product( &$product ) { + global $wpdb; + + $counts = array(); + $raw_counts = $wpdb->get_results( + $wpdb->prepare( + " + SELECT meta_value, COUNT( * ) as meta_value_count FROM $wpdb->commentmeta + LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID + WHERE meta_key = 'rating' + AND comment_post_ID = %d + AND comment_approved = '1' + AND meta_value > 0 + GROUP BY meta_value + ", $product->get_id() + ) + ); + + foreach ( $raw_counts as $count ) { + $counts[ $count->meta_value ] = absint( $count->meta_value_count ); // WPCS: slow query ok. + } + + $product->set_rating_counts( $counts ); + + $data_store = $product->get_data_store(); + $data_store->update_rating_counts( $product ); + + return $counts; + } +} + +WC_Comments::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-countries.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-countries.php new file mode 100644 index 0000000..f5f818e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-countries.php @@ -0,0 +1,1260 @@ +get_countries(); + } elseif ( 'states' === $key ) { + return $this->get_states(); + } + } + + /** + * Get all countries. + * + * @return array + */ + public function get_countries() { + if ( empty( $this->countries ) ) { + $this->countries = apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' ); + if ( apply_filters( 'woocommerce_sort_countries', true ) ) { + asort( $this->countries ); + } + } + + return $this->countries; + } + + /** + * Get all continents. + * + * @return array + */ + public function get_continents() { + if ( empty( $this->continents ) ) { + $this->continents = apply_filters( 'woocommerce_continents', include WC()->plugin_path() . '/i18n/continents.php' ); + } + + return $this->continents; + } + + /** + * Get continent code for a country code. + * + * @since 2.6.0 + * @param string $cc Continent code. + * @return string + */ + public function get_continent_code_for_country( $cc ) { + $cc = trim( strtoupper( $cc ) ); + $continents = $this->get_continents(); + $continents_and_ccs = wp_list_pluck( $continents, 'countries' ); + foreach ( $continents_and_ccs as $continent_code => $countries ) { + if ( false !== array_search( $cc, $countries, true ) ) { + return $continent_code; + } + } + + return ''; + } + + /** + * Load the states. + */ + public function load_country_states() { + global $states; + + // States set to array() are blank i.e. the country has no use for the state field. + $states = array( + 'AF' => array(), + 'AT' => array(), + 'AX' => array(), + 'BE' => array(), + 'BH' => array(), + 'BI' => array(), + 'CZ' => array(), + 'DE' => array(), + 'DK' => array(), + 'EE' => array(), + 'FI' => array(), + 'FR' => array(), + 'GP' => array(), + 'GF' => array(), + 'IS' => array(), + 'IL' => array(), + 'IM' => array(), + 'KR' => array(), + 'KW' => array(), + 'LB' => array(), + 'LU' => array(), + 'MQ' => array(), + 'NL' => array(), + 'NO' => array(), + 'PL' => array(), + 'PT' => array(), + 'RE' => array(), + 'SG' => array(), + 'SK' => array(), + 'SI' => array(), + 'LK' => array(), + 'SE' => array(), + 'VN' => array(), + 'YT' => array(), + ); + + // Load only the state files the shop owner wants/needs. + $allowed = array_merge( $this->get_allowed_countries(), $this->get_shipping_countries() ); + + if ( ! empty( $allowed ) ) { + foreach ( $allowed as $code => $country ) { + if ( ! isset( $states[ $code ] ) && file_exists( WC()->plugin_path() . '/i18n/states/' . $code . '.php' ) ) { + include WC()->plugin_path() . '/i18n/states/' . $code . '.php'; + } + } + } + + $this->states = apply_filters( 'woocommerce_states', $states ); + } + + /** + * Get the states for a country. + * + * @param string $cc Country code. + * @return false|array of states + */ + public function get_states( $cc = null ) { + if ( empty( $this->states ) ) { + $this->load_country_states(); + } + + if ( ! is_null( $cc ) ) { + return isset( $this->states[ $cc ] ) ? $this->states[ $cc ] : false; + } else { + return $this->states; + } + } + + /** + * Get the base address (first line) for the store. + * + * @since 3.1.1 + * @return string + */ + public function get_base_address() { + $base_address = get_option( 'woocommerce_store_address', '' ); + return apply_filters( 'woocommerce_countries_base_address', $base_address ); + } + + /** + * Get the base address (second line) for the store. + * + * @since 3.1.1 + * @return string + */ + public function get_base_address_2() { + $base_address_2 = get_option( 'woocommerce_store_address_2', '' ); + return apply_filters( 'woocommerce_countries_base_address_2', $base_address_2 ); + } + + /** + * Get the base country for the store. + * + * @return string + */ + public function get_base_country() { + $default = wc_get_base_location(); + return apply_filters( 'woocommerce_countries_base_country', $default['country'] ); + } + + /** + * Get the base state for the store. + * + * @return string + */ + public function get_base_state() { + $default = wc_get_base_location(); + return apply_filters( 'woocommerce_countries_base_state', $default['state'] ); + } + + /** + * Get the base city for the store. + * + * @version 3.1.1 + * @return string + */ + public function get_base_city() { + $base_city = get_option( 'woocommerce_store_city', '' ); + return apply_filters( 'woocommerce_countries_base_city', $base_city ); + } + + /** + * Get the base postcode for the store. + * + * @since 3.1.1 + * @return string + */ + public function get_base_postcode() { + $base_postcode = get_option( 'woocommerce_store_postcode', '' ); + return apply_filters( 'woocommerce_countries_base_postcode', $base_postcode ); + } + + /** + * Get the allowed countries for the store. + * + * @return array + */ + public function get_allowed_countries() { + if ( 'all' === get_option( 'woocommerce_allowed_countries' ) ) { + return apply_filters( 'woocommerce_countries_allowed_countries', $this->countries ); + } + + if ( 'all_except' === get_option( 'woocommerce_allowed_countries' ) ) { + $except_countries = get_option( 'woocommerce_all_except_countries', array() ); + + if ( ! $except_countries ) { + return $this->countries; + } else { + $all_except_countries = $this->countries; + foreach ( $except_countries as $country ) { + unset( $all_except_countries[ $country ] ); + } + return apply_filters( 'woocommerce_countries_allowed_countries', $all_except_countries ); + } + } + + $countries = array(); + + $raw_countries = get_option( 'woocommerce_specific_allowed_countries', array() ); + + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + $countries[ $country ] = $this->countries[ $country ]; + } + } + + return apply_filters( 'woocommerce_countries_allowed_countries', $countries ); + } + + /** + * Get the countries you ship to. + * + * @return array + */ + public function get_shipping_countries() { + if ( '' === get_option( 'woocommerce_ship_to_countries' ) ) { + return $this->get_allowed_countries(); + } + + if ( 'all' === get_option( 'woocommerce_ship_to_countries' ) ) { + return $this->countries; + } + + $countries = array(); + + $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); + + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + $countries[ $country ] = $this->countries[ $country ]; + } + } + + return apply_filters( 'woocommerce_countries_shipping_countries', $countries ); + } + + /** + * Get allowed country states. + * + * @return array + */ + public function get_allowed_country_states() { + if ( get_option( 'woocommerce_allowed_countries' ) !== 'specific' ) { + return $this->states; + } + + $states = array(); + + $raw_countries = get_option( 'woocommerce_specific_allowed_countries' ); + + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + if ( isset( $this->states[ $country ] ) ) { + $states[ $country ] = $this->states[ $country ]; + } + } + } + + return apply_filters( 'woocommerce_countries_allowed_country_states', $states ); + } + + /** + * Get shipping country states. + * + * @return array + */ + public function get_shipping_country_states() { + if ( get_option( 'woocommerce_ship_to_countries' ) === '' ) { + return $this->get_allowed_country_states(); + } + + if ( get_option( 'woocommerce_ship_to_countries' ) !== 'specific' ) { + return $this->states; + } + + $states = array(); + + $raw_countries = get_option( 'woocommerce_specific_ship_to_countries' ); + + if ( $raw_countries ) { + foreach ( $raw_countries as $country ) { + if ( ! empty( $this->states[ $country ] ) ) { + $states[ $country ] = $this->states[ $country ]; + } + } + } + + return apply_filters( 'woocommerce_countries_shipping_country_states', $states ); + } + + /** + * Gets an array of countries in the EU. + * + * MC (monaco) and IM (isle of man, part of UK) also use VAT. + * + * @param string $type Type of countries to retrieve. Blank for EU member countries. eu_vat for EU VAT countries. + * @return string[] + */ + public function get_european_union_countries( $type = '' ) { + $countries = array( 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'HR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK' ); + + if ( 'eu_vat' === $type ) { + $countries[] = 'MC'; + $countries[] = 'IM'; + } + + return $countries; + } + + /** + * Gets the correct string for shipping - either 'to the' or 'to'. + * + * @param string $country_code Country code. + * @return string + */ + public function shipping_to_prefix( $country_code = '' ) { + $country_code = $country_code ? $country_code : WC()->customer->get_shipping_country(); + $countries = array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ); + $return = in_array( $country_code, $countries, true ) ? __( 'to the', 'woocommerce' ) : __( 'to', 'woocommerce' ); + + return apply_filters( 'woocommerce_countries_shipping_to_prefix', $return, $country_code ); + } + + /** + * Prefix certain countries with 'the'. + * + * @param string $country_code Country code. + * @return string + */ + public function estimated_for_prefix( $country_code = '' ) { + $country_code = $country_code ? $country_code : $this->get_base_country(); + $countries = array( 'GB', 'US', 'AE', 'CZ', 'DO', 'NL', 'PH', 'USAF' ); + $return = in_array( $country_code, $countries, true ) ? __( 'the', 'woocommerce' ) . ' ' : ''; + + return apply_filters( 'woocommerce_countries_estimated_for_prefix', $return, $country_code ); + } + + /** + * Correctly name tax in some countries VAT on the frontend. + * + * @return string + */ + public function tax_or_vat() { + $return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( 'VAT', 'woocommerce' ) : __( 'Tax', 'woocommerce' ); + + return apply_filters( 'woocommerce_countries_tax_or_vat', $return ); + } + + /** + * Include the Inc Tax label. + * + * @return string + */ + public function inc_tax_or_vat() { + $return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( '(incl. VAT)', 'woocommerce' ) : __( '(incl. tax)', 'woocommerce' ); + + return apply_filters( 'woocommerce_countries_inc_tax_or_vat', $return ); + } + + /** + * Include the Ex Tax label. + * + * @return string + */ + public function ex_tax_or_vat() { + $return = in_array( $this->get_base_country(), array_merge( $this->get_european_union_countries( 'eu_vat' ), array( 'NO' ) ), true ) ? __( '(ex. VAT)', 'woocommerce' ) : __( '(ex. tax)', 'woocommerce' ); + + return apply_filters( 'woocommerce_countries_ex_tax_or_vat', $return ); + } + + /** + * Outputs the list of countries and states for use in dropdown boxes. + * + * @param string $selected_country Selected country. + * @param string $selected_state Selected state. + * @param bool $escape If should escape HTML. + */ + public function country_dropdown_options( $selected_country = '', $selected_state = '', $escape = false ) { + if ( $this->countries ) { + foreach ( $this->countries as $key => $value ) { + $states = $this->get_states( $key ); + if ( $states ) { + echo ''; + foreach ( $states as $state_key => $state_value ) { + echo ''; // WPCS: XSS ok. + } + echo ''; + } else { + echo '' . ( $escape ? esc_js( $value ) : $value ) . ''; // WPCS: XSS ok. + } + } + } + } + + /** + * Get country address formats. + * + * These define how addresses are formatted for display in various countries. + * + * @return array + */ + public function get_address_formats() { + if ( empty( $this->address_formats ) ) { + $this->address_formats = apply_filters( + 'woocommerce_localisation_address_formats', array( + 'default' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}", + 'AU' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {state} {postcode}\n{country}", + 'AT' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'BE' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'CA' => "{company}\n{name}\n{address_1}\n{address_2}\n{city} {state} {postcode}\n{country}", + 'CH' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'CL' => "{company}\n{name}\n{address_1}\n{address_2}\n{state}\n{postcode} {city}\n{country}", + 'CN' => "{country} {postcode}\n{state}, {city}, {address_2}, {address_1}\n{company}\n{name}", + 'CZ' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'DE' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'EE' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'FI' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'DK' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'FR' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city_upper}\n{country}", + 'HK' => "{company}\n{first_name} {last_name_upper}\n{address_1}\n{address_2}\n{city_upper}\n{state_upper}\n{country}", + 'HU' => "{name}\n{company}\n{city}\n{address_1}\n{address_2}\n{postcode}\n{country}", + 'IN' => "{company}\n{name}\n{address_1}\n{address_2}\n{city} - {postcode}\n{state}, {country}", + 'IS' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'IT' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode}\n{city}\n{state_upper}\n{country}", + 'JP' => "{postcode}\n{state} {city} {address_1}\n{address_2}\n{company}\n{last_name} {first_name}\n{country}", + 'TW' => "{company}\n{last_name} {first_name}\n{address_1}\n{address_2}\n{state}, {city} {postcode}\n{country}", + 'LI' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'NL' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'NZ' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {postcode}\n{country}", + 'NO' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'PL' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'PT' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'SK' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'SI' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'ES' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}", + 'SE' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}", + 'TR' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city} {state}\n{country}", + 'US' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state_code} {postcode}\n{country}", + 'VN' => "{name}\n{company}\n{address_1}\n{city}\n{country}", + ) + ); + } + return $this->address_formats; + } + + /** + * Get country address format. + * + * @param array $args Arguments. + * @return string + */ + public function get_formatted_address( $args = array() ) { + $default_args = array( + 'first_name' => '', + 'last_name' => '', + 'company' => '', + 'address_1' => '', + 'address_2' => '', + 'city' => '', + 'state' => '', + 'postcode' => '', + 'country' => '', + ); + + $args = array_map( 'trim', wp_parse_args( $args, $default_args ) ); + $state = $args['state']; + $country = $args['country']; + + // Get all formats. + $formats = $this->get_address_formats(); + + // Get format for the address' country. + $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; + + // Handle full country name. + $full_country = ( isset( $this->countries[ $country ] ) ) ? $this->countries[ $country ] : $country; + + // Country is not needed if the same as base. + if ( $country === $this->get_base_country() && ! apply_filters( 'woocommerce_formatted_address_force_country_display', false ) ) { + $format = str_replace( '{country}', '', $format ); + } + + // Handle full state name. + $full_state = ( $country && $state && isset( $this->states[ $country ][ $state ] ) ) ? $this->states[ $country ][ $state ] : $state; + + // Substitute address parts into the string. + $replace = array_map( + 'esc_html', apply_filters( + 'woocommerce_formatted_address_replacements', array( + '{first_name}' => $args['first_name'], + '{last_name}' => $args['last_name'], + '{name}' => $args['first_name'] . ' ' . $args['last_name'], + '{company}' => $args['company'], + '{address_1}' => $args['address_1'], + '{address_2}' => $args['address_2'], + '{city}' => $args['city'], + '{state}' => $full_state, + '{postcode}' => $args['postcode'], + '{country}' => $full_country, + '{first_name_upper}' => strtoupper( $args['first_name'] ), + '{last_name_upper}' => strtoupper( $args['last_name'] ), + '{name_upper}' => strtoupper( $args['first_name'] . ' ' . $args['last_name'] ), + '{company_upper}' => strtoupper( $args['company'] ), + '{address_1_upper}' => strtoupper( $args['address_1'] ), + '{address_2_upper}' => strtoupper( $args['address_2'] ), + '{city_upper}' => strtoupper( $args['city'] ), + '{state_upper}' => strtoupper( $full_state ), + '{state_code}' => strtoupper( $state ), + '{postcode_upper}' => strtoupper( $args['postcode'] ), + '{country_upper}' => strtoupper( $full_country ), + ), $args + ) + ); + + $formatted_address = str_replace( array_keys( $replace ), $replace, $format ); + + // Clean up white space. + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); + $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); + + // Break newlines apart and remove empty lines/trim commas and white space. + $formatted_address = array_filter( array_map( array( $this, 'trim_formatted_address_line' ), explode( "\n", $formatted_address ) ) ); + + // Add html breaks. + $formatted_address = implode( '
      ', $formatted_address ); + + // We're done! + return $formatted_address; + } + + /** + * Trim white space and commas off a line. + * + * @param string $line Line. + * @return string + */ + private function trim_formatted_address_line( $line ) { + return trim( $line, ', ' ); + } + + /** + * Returns the fields we show by default. This can be filtered later on. + * + * @return array + */ + public function get_default_address_fields() { + $fields = array( + 'first_name' => array( + 'label' => __( 'First name', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-first' ), + 'autocomplete' => 'given-name', + 'priority' => 10, + ), + 'last_name' => array( + 'label' => __( 'Last name', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-last' ), + 'autocomplete' => 'family-name', + 'priority' => 20, + ), + 'company' => array( + 'label' => __( 'Company name', 'woocommerce' ), + 'class' => array( 'form-row-wide' ), + 'autocomplete' => 'organization', + 'priority' => 30, + 'required' => 'required' === get_option( 'woocommerce_checkout_company_field', 'optional' ), + ), + 'country' => array( + 'type' => 'country', + 'label' => __( 'Country', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ), + 'autocomplete' => 'country', + 'priority' => 40, + ), + 'address_1' => array( + 'label' => __( 'Street address', 'woocommerce' ), + /* translators: use local order of street name and house number. */ + 'placeholder' => esc_attr__( 'House number and street name', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-wide', 'address-field' ), + 'autocomplete' => 'address-line1', + 'priority' => 50, + ), + 'address_2' => array( + 'placeholder' => esc_attr__( 'Apartment, suite, unit etc. (optional)', 'woocommerce' ), + 'class' => array( 'form-row-wide', 'address-field' ), + 'required' => false, + 'autocomplete' => 'address-line2', + 'priority' => 60, + 'required' => 'required' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ), + ), + 'city' => array( + 'label' => __( 'Town / City', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-wide', 'address-field' ), + 'autocomplete' => 'address-level2', + 'priority' => 70, + ), + 'state' => array( + 'type' => 'state', + 'label' => __( 'State / County', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-wide', 'address-field' ), + 'validate' => array( 'state' ), + 'autocomplete' => 'address-level1', + 'priority' => 80, + ), + 'postcode' => array( + 'label' => __( 'Postcode / ZIP', 'woocommerce' ), + 'required' => true, + 'class' => array( 'form-row-wide', 'address-field' ), + 'validate' => array( 'postcode' ), + 'autocomplete' => 'postal-code', + 'priority' => 90, + ), + ); + + if ( 'hidden' === get_option( 'woocommerce_checkout_company_field', 'optional' ) ) { + unset( $fields['company'] ); + } + + $address_2_visibility = get_option( 'woocommerce_checkout_address_2_field', 'optional' ); + + if ( 'hidden' === $address_2_visibility ) { + unset( $fields['address_2'] ); + } + + if ( 'hidden' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ) ) { + unset( $fields['address_2'] ); + } + + return apply_filters( 'woocommerce_default_address_fields', $fields ); + } + + /** + * Get JS selectors for fields which are shown/hidden depending on the locale. + * + * @return array + */ + public function get_country_locale_field_selectors() { + $locale_fields = array( + 'address_1' => '#billing_address_1_field, #shipping_address_1_field', + 'address_2' => '#billing_address_2_field, #shipping_address_2_field', + 'state' => '#billing_state_field, #shipping_state_field, #calc_shipping_state_field', + 'postcode' => '#billing_postcode_field, #shipping_postcode_field, #calc_shipping_postcode_field', + 'city' => '#billing_city_field, #shipping_city_field, #calc_shipping_city_field', + ); + return apply_filters( 'woocommerce_country_locale_field_selectors', $locale_fields ); + } + + /** + * Get country locale settings. + * + * These locales override the default country selections after a country is chosen. + * + * @return array + */ + public function get_country_locale() { + if ( empty( $this->locale ) ) { + $this->locale = apply_filters( + 'woocommerce_get_country_locale', array( + 'AE' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + 'state' => array( + 'required' => false, + ), + ), + 'AF' => array( + 'state' => array( + 'required' => false, + ), + ), + 'AT' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'AU' => array( + 'city' => array( + 'label' => __( 'Suburb', 'woocommerce' ), + ), + 'postcode' => array( + 'label' => __( 'Postcode', 'woocommerce' ), + ), + 'state' => array( + 'label' => __( 'State', 'woocommerce' ), + ), + ), + 'AX' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'BD' => array( + 'postcode' => array( + 'required' => false, + ), + 'state' => array( + 'label' => __( 'District', 'woocommerce' ), + ), + ), + 'BE' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'BH' => array( + 'state' => array( + 'required' => false, + ), + ), + 'BI' => array( + 'state' => array( + 'required' => false, + ), + ), + 'BO' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + ), + 'BS' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + ), + 'CA' => array( + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'CH' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'label' => __( 'Canton', 'woocommerce' ), + 'required' => false, + ), + ), + 'CL' => array( + 'city' => array( + 'required' => true, + ), + 'postcode' => array( + 'required' => false, + ), + 'state' => array( + 'label' => __( 'Region', 'woocommerce' ), + ), + ), + 'CN' => array( + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'CO' => array( + 'postcode' => array( + 'required' => false, + ), + ), + 'CZ' => array( + 'state' => array( + 'required' => false, + ), + ), + 'DE' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'DK' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'EE' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'FI' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'FR' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'GP' => array( + 'state' => array( + 'required' => false, + ), + ), + 'GF' => array( + 'state' => array( + 'required' => false, + ), + ), + 'HK' => array( + 'postcode' => array( + 'required' => false, + ), + 'city' => array( + 'label' => __( 'Town / District', 'woocommerce' ), + ), + 'state' => array( + 'label' => __( 'Region', 'woocommerce' ), + ), + ), + 'HU' => array( + 'state' => array( + 'label' => __( 'County', 'woocommerce' ), + ), + ), + 'ID' => array( + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'IE' => array( + 'postcode' => array( + 'required' => false, + 'label' => __( 'Eircode', 'woocommerce' ), + ), + 'state' => array( + 'label' => __( 'County', 'woocommerce' ), + ), + ), + 'IS' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'IL' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'IM' => array( + 'state' => array( + 'required' => false, + ), + ), + 'IT' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => true, + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'JP' => array( + 'state' => array( + 'label' => __( 'Prefecture', 'woocommerce' ), + 'priority' => 66, + ), + 'postcode' => array( + 'priority' => 65, + ), + ), + 'KR' => array( + 'state' => array( + 'required' => false, + ), + ), + 'KW' => array( + 'state' => array( + 'required' => false, + ), + ), + 'LB' => array( + 'state' => array( + 'required' => false, + ), + ), + 'MQ' => array( + 'state' => array( + 'required' => false, + ), + ), + 'NL' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'NZ' => array( + 'postcode' => array( + 'label' => __( 'Postcode', 'woocommerce' ), + ), + 'state' => array( + 'required' => false, + 'label' => __( 'Region', 'woocommerce' ), + ), + ), + 'NO' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'NP' => array( + 'state' => array( + 'label' => __( 'State / Zone', 'woocommerce' ), + ), + 'postcode' => array( + 'required' => false, + ), + ), + 'PL' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'PT' => array( + 'state' => array( + 'required' => false, + ), + ), + 'RE' => array( + 'state' => array( + 'required' => false, + ), + ), + 'RO' => array( + 'state' => array( + 'label' => __( 'County', 'woocommerce' ), + 'required' => false, + ), + ), + 'SG' => array( + 'state' => array( + 'required' => false, + ), + ), + 'SK' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'SI' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'SR' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + ), + 'ES' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'LI' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'label' => __( 'Municipality', 'woocommerce' ), + 'required' => false, + ), + ), + 'LK' => array( + 'state' => array( + 'required' => false, + ), + ), + 'LU' => array( + 'state' => array( + 'required' => false, + ), + ), + 'MD' => array( + 'state' => array( + 'label' => __( 'Municipality / District', 'woocommerce' ), + ), + ), + 'SE' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'required' => false, + ), + ), + 'TR' => array( + 'postcode' => array( + 'priority' => 65, + ), + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'US' => array( + 'postcode' => array( + 'label' => __( 'ZIP', 'woocommerce' ), + ), + 'state' => array( + 'label' => __( 'State', 'woocommerce' ), + ), + ), + 'GB' => array( + 'postcode' => array( + 'label' => __( 'Postcode', 'woocommerce' ), + ), + 'state' => array( + 'label' => __( 'County', 'woocommerce' ), + 'required' => false, + ), + ), + 'VN' => array( + 'state' => array( + 'required' => false, + ), + 'postcode' => array( + 'priority' => 65, + 'required' => false, + 'hidden' => false, + ), + 'address_2' => array( + 'required' => false, + 'hidden' => true, + ), + ), + 'WS' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + ), + 'YT' => array( + 'state' => array( + 'required' => false, + ), + ), + 'ZA' => array( + 'state' => array( + 'label' => __( 'Province', 'woocommerce' ), + ), + ), + 'ZW' => array( + 'postcode' => array( + 'required' => false, + 'hidden' => true, + ), + ), + ) + ); + + $this->locale = array_intersect_key( $this->locale, array_merge( $this->get_allowed_countries(), $this->get_shipping_countries() ) ); + + // Default Locale Can be filtered to override fields in get_address_fields(). Countries with no specific locale will use default. + $this->locale['default'] = apply_filters( 'woocommerce_get_country_locale_default', $this->get_default_address_fields() ); + + // Filter default AND shop base locales to allow overides via a single function. These will be used when changing countries on the checkout. + if ( ! isset( $this->locale[ $this->get_base_country() ] ) ) { + $this->locale[ $this->get_base_country() ] = $this->locale['default']; + } + + $this->locale['default'] = apply_filters( 'woocommerce_get_country_locale_base', $this->locale['default'] ); + $this->locale[ $this->get_base_country() ] = apply_filters( 'woocommerce_get_country_locale_base', $this->locale[ $this->get_base_country() ] ); + } + + return $this->locale; + } + + /** + * Apply locale and get address fields. + * + * @param mixed $country Country. + * @param string $type Address type, defaults to 'billing_'. + * @return array + */ + public function get_address_fields( $country = '', $type = 'billing_' ) { + if ( ! $country ) { + $country = $this->get_base_country(); + } + + $fields = $this->get_default_address_fields(); + $locale = $this->get_country_locale(); + + if ( isset( $locale[ $country ] ) ) { + $fields = wc_array_overlay( $fields, $locale[ $country ] ); + } + + // Prepend field keys. + $address_fields = array(); + + foreach ( $fields as $key => $value ) { + if ( 'state' === $key ) { + $value['country_field'] = $type . 'country'; + } + $address_fields[ $type . $key ] = $value; + } + + // Add email and phone fields. + if ( 'billing_' === $type ) { + if ( 'hidden' !== get_option( 'woocommerce_checkout_phone_field', 'required' ) ) { + $address_fields['billing_phone'] = array( + 'label' => __( 'Phone', 'woocommerce' ), + 'required' => 'required' === get_option( 'woocommerce_checkout_phone_field', 'required' ), + 'type' => 'tel', + 'class' => array( 'form-row-wide' ), + 'validate' => array( 'phone' ), + 'autocomplete' => 'tel', + 'priority' => 100, + ); + } + $address_fields['billing_email'] = array( + 'label' => __( 'Email address', 'woocommerce' ), + 'required' => true, + 'type' => 'email', + 'class' => array( 'form-row-wide' ), + 'validate' => array( 'email' ), + 'autocomplete' => 'no' === get_option( 'woocommerce_registration_generate_username' ) ? 'email' : 'email username', + 'priority' => 110, + ); + } + + /** + * Important note on this filter: Changes to address fields can and will be overridden by + * the woocommerce_default_address_fields. The locales/default locales apply on top based + * on country selection. If you want to change things like the required status of an + * address field, filter woocommerce_default_address_fields instead. + */ + return apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-coupon.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-coupon.php new file mode 100644 index 0000000..e4d6161 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-coupon.php @@ -0,0 +1,1055 @@ + '', + 'amount' => 0, + 'date_created' => null, + 'date_modified' => null, + 'date_expires' => null, + 'discount_type' => 'fixed_cart', + 'description' => '', + 'usage_count' => 0, + 'individual_use' => false, + 'product_ids' => array(), + 'excluded_product_ids' => array(), + 'usage_limit' => 0, + 'usage_limit_per_user' => 0, + 'limit_usage_to_x_items' => null, + 'free_shipping' => false, + 'product_categories' => array(), + 'excluded_product_categories' => array(), + 'exclude_sale_items' => false, + 'minimum_amount' => '', + 'maximum_amount' => '', + 'email_restrictions' => array(), + 'used_by' => array(), + 'virtual' => false, + ); + + // Coupon message codes. + const E_WC_COUPON_INVALID_FILTERED = 100; + const E_WC_COUPON_INVALID_REMOVED = 101; + const E_WC_COUPON_NOT_YOURS_REMOVED = 102; + const E_WC_COUPON_ALREADY_APPLIED = 103; + const E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY = 104; + const E_WC_COUPON_NOT_EXIST = 105; + const E_WC_COUPON_USAGE_LIMIT_REACHED = 106; + const E_WC_COUPON_EXPIRED = 107; + const E_WC_COUPON_MIN_SPEND_LIMIT_NOT_MET = 108; + const E_WC_COUPON_NOT_APPLICABLE = 109; + const E_WC_COUPON_NOT_VALID_SALE_ITEMS = 110; + const E_WC_COUPON_PLEASE_ENTER = 111; + const E_WC_COUPON_MAX_SPEND_LIMIT_MET = 112; + const E_WC_COUPON_EXCLUDED_PRODUCTS = 113; + const E_WC_COUPON_EXCLUDED_CATEGORIES = 114; + const WC_COUPON_SUCCESS = 200; + const WC_COUPON_REMOVED = 201; + + /** + * Cache group. + * + * @var string + */ + protected $cache_group = 'coupons'; + + /** + * Coupon constructor. Loads coupon data. + * + * @param mixed $data Coupon data, object, ID or code. + */ + public function __construct( $data = '' ) { + parent::__construct( $data ); + + // If we already have a coupon object, read it again. + if ( $data instanceof WC_Coupon ) { + $this->set_id( absint( $data->get_id() ) ); + $this->read_object_from_database(); + return; + } + + // This filter allows custom coupon objects to be created on the fly. + $coupon = apply_filters( 'woocommerce_get_shop_coupon_data', false, $data ); + + if ( $coupon ) { + $this->read_manual_coupon( $data, $coupon ); + return; + } + + // Try to load coupon using ID or code. + if ( is_int( $data ) && 'shop_coupon' === get_post_type( $data ) ) { + $this->set_id( $data ); + } elseif ( ! empty( $data ) ) { + $id = wc_get_coupon_id_by_code( $data ); + // Need to support numeric strings for backwards compatibility. + if ( ! $id && 'shop_coupon' === get_post_type( $data ) ) { + $this->set_id( $data ); + } else { + $this->set_id( $id ); + $this->set_code( $data ); + } + } else { + $this->set_object_read( true ); + } + + $this->read_object_from_database(); + } + + /** + * If the object has an ID, read using the data store. + * + * @since 3.4.1 + */ + protected function read_object_from_database() { + $this->data_store = WC_Data_Store::load( 'coupon' ); + + if ( $this->get_id() > 0 ) { + $this->data_store->read( $this ); + } + } + /** + * Checks the coupon type. + * + * @param string $type Array or string of types. + * @return bool + */ + public function is_type( $type ) { + return ( $this->get_discount_type() === $type || ( is_array( $type ) && in_array( $this->get_discount_type(), $type, true ) ) ); + } + + /** + * Prefix for action and filter hooks on data. + * + * @since 3.0.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_coupon_get_'; + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + | + | Methods for getting data from the coupon object. + | + */ + + /** + * Get coupon code. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_code( $context = 'view' ) { + return $this->get_prop( 'code', $context ); + } + + /** + * Get coupon description. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_description( $context = 'view' ) { + return $this->get_prop( 'description', $context ); + } + + /** + * Get discount type. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_discount_type( $context = 'view' ) { + return $this->get_prop( 'discount_type', $context ); + } + + /** + * Get coupon amount. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return float + */ + public function get_amount( $context = 'view' ) { + return (float) $this->get_prop( 'amount', $context ); + } + + /** + * Get coupon expiration date. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|NULL object if the date is set or null if there is no date. + */ + public function get_date_expires( $context = 'view' ) { + return $this->get_prop( 'date_expires', $context ); + } + + /** + * Get date_created + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|NULL object if the date is set or null if there is no date. + */ + public function get_date_created( $context = 'view' ) { + return $this->get_prop( 'date_created', $context ); + } + + /** + * Get date_modified + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|NULL object if the date is set or null if there is no date. + */ + public function get_date_modified( $context = 'view' ) { + return $this->get_prop( 'date_modified', $context ); + } + + /** + * Get coupon usage count. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_usage_count( $context = 'view' ) { + return $this->get_prop( 'usage_count', $context ); + } + + /** + * Get the "indvidual use" checkbox status. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_individual_use( $context = 'view' ) { + return $this->get_prop( 'individual_use', $context ); + } + + /** + * Get product IDs this coupon can apply to. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_product_ids( $context = 'view' ) { + return $this->get_prop( 'product_ids', $context ); + } + + /** + * Get product IDs that this coupon should not apply to. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_excluded_product_ids( $context = 'view' ) { + return $this->get_prop( 'excluded_product_ids', $context ); + } + + /** + * Get coupon usage limit. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_usage_limit( $context = 'view' ) { + return $this->get_prop( 'usage_limit', $context ); + } + + /** + * Get coupon usage limit per customer (for a single customer) + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_usage_limit_per_user( $context = 'view' ) { + return $this->get_prop( 'usage_limit_per_user', $context ); + } + + /** + * Usage limited to certain amount of items + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer|null + */ + public function get_limit_usage_to_x_items( $context = 'view' ) { + return $this->get_prop( 'limit_usage_to_x_items', $context ); + } + + /** + * If this coupon grants free shipping or not. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_free_shipping( $context = 'view' ) { + return $this->get_prop( 'free_shipping', $context ); + } + + /** + * Get product categories this coupon can apply to. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_product_categories( $context = 'view' ) { + return $this->get_prop( 'product_categories', $context ); + } + + /** + * Get product categories this coupon cannot not apply to. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_excluded_product_categories( $context = 'view' ) { + return $this->get_prop( 'excluded_product_categories', $context ); + } + + /** + * If this coupon should exclude items on sale. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_exclude_sale_items( $context = 'view' ) { + return $this->get_prop( 'exclude_sale_items', $context ); + } + + /** + * Get minimum spend amount. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return float + */ + public function get_minimum_amount( $context = 'view' ) { + return $this->get_prop( 'minimum_amount', $context ); + } + /** + * Get maximum spend amount. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return float + */ + public function get_maximum_amount( $context = 'view' ) { + return $this->get_prop( 'maximum_amount', $context ); + } + + /** + * Get emails to check customer usage restrictions. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_email_restrictions( $context = 'view' ) { + return $this->get_prop( 'email_restrictions', $context ); + } + + /** + * Get records of all users who have used the current coupon. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_used_by( $context = 'view' ) { + return $this->get_prop( 'used_by', $context ); + } + + /** + * If the filter is added through the woocommerce_get_shop_coupon_data filter, it's virtual and not in the DB. + * + * @since 3.2.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return boolean + */ + public function get_virtual( $context = 'view' ) { + return (bool) $this->get_prop( 'virtual', $context ); + } + + /** + * Get discount amount for a cart item. + * + * @param float $discounting_amount Amount the coupon is being applied to. + * @param array|null $cart_item Cart item being discounted if applicable. + * @param boolean $single True if discounting a single qty item, false if its the line. + * @return float Amount this coupon has discounted. + */ + public function get_discount_amount( $discounting_amount, $cart_item = null, $single = false ) { + $discount = 0; + $cart_item_qty = is_null( $cart_item ) ? 1 : $cart_item['quantity']; + + if ( $this->is_type( array( 'percent' ) ) ) { + $discount = (float) $this->get_amount() * ( $discounting_amount / 100 ); + } elseif ( $this->is_type( 'fixed_cart' ) && ! is_null( $cart_item ) && WC()->cart->subtotal_ex_tax ) { + /** + * This is the most complex discount - we need to divide the discount between rows based on their price in. + * proportion to the subtotal. This is so rows with different tax rates get a fair discount, and so rows. + * with no price (free) don't get discounted. + * + * Get item discount by dividing item cost by subtotal to get a %. + * + * Uses price inc tax if prices include tax to work around https://github.com/woocommerce/woocommerce/issues/7669 and https://github.com/woocommerce/woocommerce/issues/8074. + */ + if ( wc_prices_include_tax() ) { + $discount_percent = ( wc_get_price_including_tax( $cart_item['data'] ) * $cart_item_qty ) / WC()->cart->subtotal; + } else { + $discount_percent = ( wc_get_price_excluding_tax( $cart_item['data'] ) * $cart_item_qty ) / WC()->cart->subtotal_ex_tax; + } + $discount = ( (float) $this->get_amount() * $discount_percent ) / $cart_item_qty; + + } elseif ( $this->is_type( 'fixed_product' ) ) { + $discount = min( $this->get_amount(), $discounting_amount ); + $discount = $single ? $discount : $discount * $cart_item_qty; + } + + return apply_filters( 'woocommerce_coupon_get_discount_amount', round( min( $discount, $discounting_amount ), wc_get_rounding_precision() ), $discounting_amount, $cart_item, $single, $this ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + | + | Functions for setting coupon data. These should not update anything in the + | database itself and should only change what is stored in the class + | object. + | + */ + + /** + * Set coupon code. + * + * @since 3.0.0 + * @param string $code Coupon code. + */ + public function set_code( $code ) { + $this->set_prop( 'code', wc_format_coupon_code( $code ) ); + } + + /** + * Set coupon description. + * + * @since 3.0.0 + * @param string $description Description. + */ + public function set_description( $description ) { + $this->set_prop( 'description', $description ); + } + + /** + * Set discount type. + * + * @since 3.0.0 + * @param string $discount_type Discount type. + */ + public function set_discount_type( $discount_type ) { + if ( 'percent_product' === $discount_type ) { + $discount_type = 'percent'; // Backwards compatibility. + } + if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ), true ) ) { + $this->error( 'coupon_invalid_discount_type', __( 'Invalid discount type', 'woocommerce' ) ); + } + $this->set_prop( 'discount_type', $discount_type ); + } + + /** + * Set amount. + * + * @since 3.0.0 + * @param float $amount Amount. + */ + public function set_amount( $amount ) { + $amount = wc_format_decimal( $amount ); + + if ( ! is_numeric( $amount ) ) { + $amount = 0; + } + + if ( $amount < 0 ) { + $this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) ); + } + + if ( 'percent' === $this->get_discount_type() && $amount > 100 ) { + $this->error( 'coupon_invalid_amount', __( 'Invalid discount amount', 'woocommerce' ) ); + } + + $this->set_prop( 'amount', $amount ); + } + + /** + * Set expiration date. + * + * @since 3.0.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date. + */ + public function set_date_expires( $date ) { + $this->set_date_prop( 'date_expires', $date ); + } + + /** + * Set date_created + * + * @since 3.0.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date. + */ + public function set_date_created( $date ) { + $this->set_date_prop( 'date_created', $date ); + } + + /** + * Set date_modified + * + * @since 3.0.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date. + */ + public function set_date_modified( $date ) { + $this->set_date_prop( 'date_modified', $date ); + } + + /** + * Set how many times this coupon has been used. + * + * @since 3.0.0 + * @param int $usage_count Usage count. + */ + public function set_usage_count( $usage_count ) { + $this->set_prop( 'usage_count', absint( $usage_count ) ); + } + + /** + * Set if this coupon can only be used once. + * + * @since 3.0.0 + * @param bool $is_individual_use If is for individual use. + */ + public function set_individual_use( $is_individual_use ) { + $this->set_prop( 'individual_use', (bool) $is_individual_use ); + } + + /** + * Set the product IDs this coupon can be used with. + * + * @since 3.0.0 + * @param array $product_ids Products IDs. + */ + public function set_product_ids( $product_ids ) { + $this->set_prop( 'product_ids', array_filter( wp_parse_id_list( (array) $product_ids ) ) ); + } + + /** + * Set the product IDs this coupon cannot be used with. + * + * @since 3.0.0 + * @param array $excluded_product_ids Exclude product IDs. + */ + public function set_excluded_product_ids( $excluded_product_ids ) { + $this->set_prop( 'excluded_product_ids', array_filter( wp_parse_id_list( (array) $excluded_product_ids ) ) ); + } + + /** + * Set the amount of times this coupon can be used. + * + * @since 3.0.0 + * @param int $usage_limit Usage limit. + */ + public function set_usage_limit( $usage_limit ) { + $this->set_prop( 'usage_limit', absint( $usage_limit ) ); + } + + /** + * Set the amount of times this coupon can be used per user. + * + * @since 3.0.0 + * @param int $usage_limit Usage limit. + */ + public function set_usage_limit_per_user( $usage_limit ) { + $this->set_prop( 'usage_limit_per_user', absint( $usage_limit ) ); + } + + /** + * Set usage limit to x number of items. + * + * @since 3.0.0 + * @param int|null $limit_usage_to_x_items Limit usage to X items. + */ + public function set_limit_usage_to_x_items( $limit_usage_to_x_items ) { + $this->set_prop( 'limit_usage_to_x_items', is_null( $limit_usage_to_x_items ) ? null : absint( $limit_usage_to_x_items ) ); + } + + /** + * Set if this coupon enables free shipping or not. + * + * @since 3.0.0 + * @param bool $free_shipping If grant free shipping. + */ + public function set_free_shipping( $free_shipping ) { + $this->set_prop( 'free_shipping', (bool) $free_shipping ); + } + + /** + * Set the product category IDs this coupon can be used with. + * + * @since 3.0.0 + * @param array $product_categories List of product categories. + */ + public function set_product_categories( $product_categories ) { + $this->set_prop( 'product_categories', array_filter( wp_parse_id_list( (array) $product_categories ) ) ); + } + + /** + * Set the product category IDs this coupon cannot be used with. + * + * @since 3.0.0 + * @param array $excluded_product_categories List of excluded product categories. + */ + public function set_excluded_product_categories( $excluded_product_categories ) { + $this->set_prop( 'excluded_product_categories', array_filter( wp_parse_id_list( (array) $excluded_product_categories ) ) ); + } + + /** + * Set if this coupon should excluded sale items or not. + * + * @since 3.0.0 + * @param bool $exclude_sale_items If should exclude sale items. + */ + public function set_exclude_sale_items( $exclude_sale_items ) { + $this->set_prop( 'exclude_sale_items', (bool) $exclude_sale_items ); + } + + /** + * Set the minimum spend amount. + * + * @since 3.0.0 + * @param float $amount Minium amount. + */ + public function set_minimum_amount( $amount ) { + $this->set_prop( 'minimum_amount', wc_format_decimal( $amount ) ); + } + + /** + * Set the maximum spend amount. + * + * @since 3.0.0 + * @param float $amount Maximum amount. + */ + public function set_maximum_amount( $amount ) { + $this->set_prop( 'maximum_amount', wc_format_decimal( $amount ) ); + } + + /** + * Set email restrictions. + * + * @since 3.0.0 + * @param array $emails List of emails. + */ + public function set_email_restrictions( $emails = array() ) { + $emails = array_filter( array_map( 'sanitize_email', array_map( 'strtolower', (array) $emails ) ) ); + foreach ( $emails as $email ) { + if ( ! is_email( $email ) ) { + $this->error( 'coupon_invalid_email_address', __( 'Invalid email address restriction', 'woocommerce' ) ); + } + } + $this->set_prop( 'email_restrictions', $emails ); + } + + /** + * Set which users have used this coupon. + * + * @since 3.0.0 + * @param array $used_by List of user IDs. + */ + public function set_used_by( $used_by ) { + $this->set_prop( 'used_by', array_filter( $used_by ) ); + } + + /** + * Set coupon virtual state. + * + * @param boolean $virtual Whether it is virtual or not. + * @since 3.2.0 + */ + public function set_virtual( $virtual ) { + $this->set_prop( 'virtual', (bool) $virtual ); + } + + /* + |-------------------------------------------------------------------------- + | Other Actions + |-------------------------------------------------------------------------- + */ + + /** + * Developers can programmatically return coupons. This function will read those values into our WC_Coupon class. + * + * @since 3.0.0 + * @param string $code Coupon code. + * @param array $coupon Array of coupon properties. + */ + public function read_manual_coupon( $code, $coupon ) { + foreach ( $coupon as $key => $value ) { + switch ( $key ) { + case 'excluded_product_ids': + case 'exclude_product_ids': + if ( ! is_array( $coupon[ $key ] ) ) { + wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' ); + $coupon['excluded_product_ids'] = wc_string_to_array( $value ); + } + break; + case 'exclude_product_categories': + case 'excluded_product_categories': + if ( ! is_array( $coupon[ $key ] ) ) { + wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' ); + $coupon['excluded_product_categories'] = wc_string_to_array( $value ); + } + break; + case 'product_ids': + if ( ! is_array( $coupon[ $key ] ) ) { + wc_doing_it_wrong( $key, $key . ' should be an array instead of a string.', '3.0' ); + $coupon[ $key ] = wc_string_to_array( $value ); + } + break; + case 'individual_use': + case 'free_shipping': + case 'exclude_sale_items': + if ( ! is_bool( $coupon[ $key ] ) ) { + wc_doing_it_wrong( $key, $key . ' should be true or false instead of yes or no.', '3.0' ); + $coupon[ $key ] = wc_string_to_bool( $value ); + } + break; + case 'expiry_date': + $coupon['date_expires'] = $value; + break; + } + } + $this->set_props( $coupon ); + $this->set_code( $code ); + $this->set_id( 0 ); + $this->set_virtual( true ); + } + + /** + * Increase usage count for current coupon. + * + * @param string $used_by Either user ID or billing email. + */ + public function increase_usage_count( $used_by = '' ) { + if ( $this->get_id() && $this->data_store ) { + $new_count = $this->data_store->increase_usage_count( $this, $used_by ); + + // Bypass set_prop and remove pending changes since the data store saves the count already. + $this->data['usage_count'] = $new_count; + if ( isset( $this->changes['usage_count'] ) ) { + unset( $this->changes['usage_count'] ); + } + } + } + + /** + * Decrease usage count for current coupon. + * + * @param string $used_by Either user ID or billing email. + */ + public function decrease_usage_count( $used_by = '' ) { + if ( $this->get_id() && $this->get_usage_count() > 0 && $this->data_store ) { + $new_count = $this->data_store->decrease_usage_count( $this, $used_by ); + + // Bypass set_prop and remove pending changes since the data store saves the count already. + $this->data['usage_count'] = $new_count; + if ( isset( $this->changes['usage_count'] ) ) { + unset( $this->changes['usage_count'] ); + } + } + } + + /* + |-------------------------------------------------------------------------- + | Validation & Error Handling + |-------------------------------------------------------------------------- + */ + + /** + * Returns the error_message string. + * + * @access public + * @return string + */ + public function get_error_message() { + return $this->error_message; + } + + /** + * Check if a coupon is valid for the cart. + * + * @deprecated 3.2.0 In favor of WC_Discounts->is_coupon_valid. + * @return bool + */ + public function is_valid() { + $discounts = new WC_Discounts( WC()->cart ); + $valid = $discounts->is_coupon_valid( $this ); + + if ( is_wp_error( $valid ) ) { + $this->error_message = $valid->get_error_message(); + return false; + } + + return $valid; + } + + /** + * Check if a coupon is valid. + * + * @return bool + */ + public function is_valid_for_cart() { + return apply_filters( 'woocommerce_coupon_is_valid_for_cart', $this->is_type( wc_get_cart_coupon_types() ), $this ); + } + + /** + * Check if a coupon is valid for a product. + * + * @param WC_Product $product Product instance. + * @param array $values Values. + * @return bool + */ + public function is_valid_for_product( $product, $values = array() ) { + if ( ! $this->is_type( wc_get_product_coupon_types() ) ) { + return apply_filters( 'woocommerce_coupon_is_valid_for_product', false, $product, $this, $values ); + } + + $valid = false; + $product_cats = wc_get_product_cat_ids( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ); + $product_ids = array( $product->get_id(), $product->get_parent_id() ); + + // Specific products get the discount. + if ( count( $this->get_product_ids() ) && count( array_intersect( $product_ids, $this->get_product_ids() ) ) ) { + $valid = true; + } + + // Category discounts. + if ( count( $this->get_product_categories() ) && count( array_intersect( $product_cats, $this->get_product_categories() ) ) ) { + $valid = true; + } + + // No product ids - all items discounted. + if ( ! count( $this->get_product_ids() ) && ! count( $this->get_product_categories() ) ) { + $valid = true; + } + + // Specific product IDs excluded from the discount. + if ( count( $this->get_excluded_product_ids() ) && count( array_intersect( $product_ids, $this->get_excluded_product_ids() ) ) ) { + $valid = false; + } + + // Specific categories excluded from the discount. + if ( count( $this->get_excluded_product_categories() ) && count( array_intersect( $product_cats, $this->get_excluded_product_categories() ) ) ) { + $valid = false; + } + + // Sale Items excluded from discount. + if ( $this->get_exclude_sale_items() && $product->is_on_sale() ) { + $valid = false; + } + + return apply_filters( 'woocommerce_coupon_is_valid_for_product', $valid, $product, $this, $values ); + } + + /** + * Converts one of the WC_Coupon message/error codes to a message string and. + * displays the message/error. + * + * @param int $msg_code Message/error code. + */ + public function add_coupon_message( $msg_code ) { + $msg = $msg_code < 200 ? $this->get_coupon_error( $msg_code ) : $this->get_coupon_message( $msg_code ); + + if ( ! $msg ) { + return; + } + + if ( $msg_code < 200 ) { + wc_add_notice( $msg, 'error' ); + } else { + wc_add_notice( $msg ); + } + } + + /** + * Map one of the WC_Coupon message codes to a message string. + * + * @param integer $msg_code Message code. + * @return string Message/error string. + */ + public function get_coupon_message( $msg_code ) { + switch ( $msg_code ) { + case self::WC_COUPON_SUCCESS: + $msg = __( 'Coupon code applied successfully.', 'woocommerce' ); + break; + case self::WC_COUPON_REMOVED: + $msg = __( 'Coupon code removed successfully.', 'woocommerce' ); + break; + default: + $msg = ''; + break; + } + return apply_filters( 'woocommerce_coupon_message', $msg, $msg_code, $this ); + } + + /** + * Map one of the WC_Coupon error codes to a message string. + * + * @param int $err_code Message/error code. + * @return string| Message/error string + */ + public function get_coupon_error( $err_code ) { + switch ( $err_code ) { + case self::E_WC_COUPON_INVALID_FILTERED: + $err = __( 'Coupon is not valid.', 'woocommerce' ); + break; + case self::E_WC_COUPON_NOT_EXIST: + /* translators: %s: coupon code */ + $err = sprintf( __( 'Coupon "%s" does not exist!', 'woocommerce' ), $this->get_code() ); + break; + case self::E_WC_COUPON_INVALID_REMOVED: + /* translators: %s: coupon code */ + $err = sprintf( __( 'Sorry, it seems the coupon "%s" is invalid - it has now been removed from your order.', 'woocommerce' ), $this->get_code() ); + break; + case self::E_WC_COUPON_NOT_YOURS_REMOVED: + /* translators: %s: coupon code */ + $err = sprintf( __( 'Sorry, it seems the coupon "%s" is not yours - it has now been removed from your order.', 'woocommerce' ), $this->get_code() ); + break; + case self::E_WC_COUPON_ALREADY_APPLIED: + $err = __( 'Coupon code already applied!', 'woocommerce' ); + break; + case self::E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY: + /* translators: %s: coupon code */ + $err = sprintf( __( 'Sorry, coupon "%s" has already been applied and cannot be used in conjunction with other coupons.', 'woocommerce' ), $this->get_code() ); + break; + case self::E_WC_COUPON_USAGE_LIMIT_REACHED: + $err = __( 'Coupon usage limit has been reached.', 'woocommerce' ); + break; + case self::E_WC_COUPON_EXPIRED: + $err = __( 'This coupon has expired.', 'woocommerce' ); + break; + case self::E_WC_COUPON_MIN_SPEND_LIMIT_NOT_MET: + /* translators: %s: coupon minimum amount */ + $err = sprintf( __( 'The minimum spend for this coupon is %s.', 'woocommerce' ), wc_price( $this->get_minimum_amount() ) ); + break; + case self::E_WC_COUPON_MAX_SPEND_LIMIT_MET: + /* translators: %s: coupon maximum amount */ + $err = sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $this->get_maximum_amount() ) ); + break; + case self::E_WC_COUPON_NOT_APPLICABLE: + $err = __( 'Sorry, this coupon is not applicable to your cart contents.', 'woocommerce' ); + break; + case self::E_WC_COUPON_EXCLUDED_PRODUCTS: + // Store excluded products that are in cart in $products. + $products = array(); + if ( ! WC()->cart->is_empty() ) { + foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { + if ( in_array( intval( $cart_item['product_id'] ), $this->get_excluded_product_ids(), true ) || in_array( intval( $cart_item['variation_id'] ), $this->get_excluded_product_ids(), true ) || in_array( intval( $cart_item['data']->get_parent_id() ), $this->get_excluded_product_ids(), true ) ) { + $products[] = $cart_item['data']->get_name(); + } + } + } + + /* translators: %s: products list */ + $err = sprintf( __( 'Sorry, this coupon is not applicable to the products: %s.', 'woocommerce' ), implode( ', ', $products ) ); + break; + case self::E_WC_COUPON_EXCLUDED_CATEGORIES: + // Store excluded categories that are in cart in $categories. + $categories = array(); + if ( ! WC()->cart->is_empty() ) { + foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { + $product_cats = wc_get_product_cat_ids( $cart_item['product_id'] ); + $intersect = array_intersect( $product_cats, $this->get_excluded_product_categories() ); + + if ( count( $intersect ) > 0 ) { + foreach ( $intersect as $cat_id ) { + $cat = get_term( $cat_id, 'product_cat' ); + $categories[] = $cat->name; + } + } + } + } + + /* translators: %s: categories list */ + $err = sprintf( __( 'Sorry, this coupon is not applicable to the categories: %s.', 'woocommerce' ), implode( ', ', array_unique( $categories ) ) ); + break; + case self::E_WC_COUPON_NOT_VALID_SALE_ITEMS: + $err = __( 'Sorry, this coupon is not valid for sale items.', 'woocommerce' ); + break; + default: + $err = ''; + break; + } + return apply_filters( 'woocommerce_coupon_error', $err, $err_code, $this ); + } + + /** + * Map one of the WC_Coupon error codes to an error string. + * No coupon instance will be available where a coupon does not exist, + * so this static method exists. + * + * @param int $err_code Error code. + * @return string Error string. + */ + public static function get_generic_coupon_error( $err_code ) { + switch ( $err_code ) { + case self::E_WC_COUPON_NOT_EXIST: + $err = __( 'Coupon does not exist!', 'woocommerce' ); + break; + case self::E_WC_COUPON_PLEASE_ENTER: + $err = __( 'Please enter a coupon code.', 'woocommerce' ); + break; + default: + $err = ''; + break; + } + // When using this static method, there is no $this to pass to filter. + return apply_filters( 'woocommerce_coupon_error', $err, $err_code, null ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download-log.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download-log.php new file mode 100644 index 0000000..37d6e1e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download-log.php @@ -0,0 +1,150 @@ + null, + 'permission_id' => 0, + 'user_id' => null, + 'user_ip_address' => null, + ); + + /** + * Constructor. + * + * @param int|object|array $download_log Download log ID. + */ + public function __construct( $download_log = 0 ) { + parent::__construct( $download_log ); + + if ( is_numeric( $download_log ) && $download_log > 0 ) { + $this->set_id( $download_log ); + } elseif ( $download_log instanceof self ) { + $this->set_id( $download_log->get_id() ); + } elseif ( is_object( $download_log ) && ! empty( $download_log->download_log_id ) ) { + $this->set_id( $download_log->download_log_id ); + $this->set_props( (array) $download_log ); + $this->set_object_read( true ); + } else { + $this->set_object_read( true ); + } + + $this->data_store = WC_Data_Store::load( 'customer-download-log' ); + + if ( $this->get_id() > 0 ) { + $this->data_store->read( $this ); + } + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get timestamp. + * + * @param string $context Get context. + * @return WC_DateTime|null Object if the date is set or null if there is no date. + */ + public function get_timestamp( $context = 'view' ) { + return $this->get_prop( 'timestamp', $context ); + } + + /** + * Get permission id. + * + * @param string $context Get context. + * @return integer + */ + public function get_permission_id( $context = 'view' ) { + return $this->get_prop( 'permission_id', $context ); + } + + /** + * Get user id. + * + * @param string $context Get context. + * @return integer + */ + public function get_user_id( $context = 'view' ) { + return $this->get_prop( 'user_id', $context ); + } + + /** + * Get user ip address. + * + * @param string $context Get context. + * @return string + */ + public function get_user_ip_address( $context = 'view' ) { + return $this->get_prop( 'user_ip_address', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set timestamp. + * + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + */ + public function set_timestamp( $date = null ) { + $this->set_date_prop( 'timestamp', $date ); + } + + /** + * Set permission id. + * + * @param int $value Value to set. + */ + public function set_permission_id( $value ) { + $this->set_prop( 'permission_id', absint( $value ) ); + } + + /** + * Set user id. + * + * @param int $value Value to set. + */ + public function set_user_id( $value ) { + $this->set_prop( 'user_id', absint( $value ) ); + } + + /** + * Set user ip address. + * + * @param string $value Value to set. + */ + public function set_user_ip_address( $value ) { + $this->set_prop( 'user_ip_address', $value ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download.php new file mode 100644 index 0000000..6db6d02 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer-download.php @@ -0,0 +1,433 @@ + '', + 'product_id' => 0, + 'user_id' => 0, + 'user_email' => '', + 'order_id' => 0, + 'order_key' => '', + 'downloads_remaining' => '', + 'access_granted' => null, + 'access_expires' => null, + 'download_count' => 0, + ); + + /** + * Constructor. + * + * @param int|object|array $download Download ID, instance or data. + */ + public function __construct( $download = 0 ) { + parent::__construct( $download ); + + if ( is_numeric( $download ) && $download > 0 ) { + $this->set_id( $download ); + } elseif ( $download instanceof self ) { + $this->set_id( $download->get_id() ); + } elseif ( is_object( $download ) && ! empty( $download->permission_id ) ) { + $this->set_id( $download->permission_id ); + $this->set_props( (array) $download ); + $this->set_object_read( true ); + } else { + $this->set_object_read( true ); + } + + $this->data_store = WC_Data_Store::load( 'customer-download' ); + + if ( $this->get_id() > 0 ) { + $this->data_store->read( $this ); + } + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get download id. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_download_id( $context = 'view' ) { + return $this->get_prop( 'download_id', $context ); + } + + /** + * Get product id. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_product_id( $context = 'view' ) { + return $this->get_prop( 'product_id', $context ); + } + + /** + * Get user id. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_user_id( $context = 'view' ) { + return $this->get_prop( 'user_id', $context ); + } + + /** + * Get user_email. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_user_email( $context = 'view' ) { + return $this->get_prop( 'user_email', $context ); + } + + /** + * Get order_id. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_order_id( $context = 'view' ) { + return $this->get_prop( 'order_id', $context ); + } + + /** + * Get order_key. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_order_key( $context = 'view' ) { + return $this->get_prop( 'order_key', $context ); + } + + /** + * Get downloads_remaining. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer|string + */ + public function get_downloads_remaining( $context = 'view' ) { + return $this->get_prop( 'downloads_remaining', $context ); + } + + /** + * Get access_granted. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|null Object if the date is set or null if there is no date. + */ + public function get_access_granted( $context = 'view' ) { + return $this->get_prop( 'access_granted', $context ); + } + + /** + * Get access_expires. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|null Object if the date is set or null if there is no date. + */ + public function get_access_expires( $context = 'view' ) { + return $this->get_prop( 'access_expires', $context ); + } + + /** + * Get download_count. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return integer + */ + public function get_download_count( $context = 'view' ) { + // Check for count of download logs. + $data_store = WC_Data_Store::load( 'customer-download-log' ); + $download_log_ids = $data_store->get_download_logs_for_permission( $this->get_id() ); + + $download_log_count = 0; + if ( ! empty( $download_log_ids ) ) { + $download_log_count = count( $download_log_ids ); + } + + // Check download count in prop. + $download_count_prop = $this->get_prop( 'download_count', $context ); + + // Return the larger of the two in case they differ. + // If logs are removed for some reason, we should still respect the + // count stored in the prop. + return max( $download_log_count, $download_count_prop ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set download id. + * + * @param string $value Download ID. + */ + public function set_download_id( $value ) { + $this->set_prop( 'download_id', $value ); + } + /** + * Set product id. + * + * @param int $value Product ID. + */ + public function set_product_id( $value ) { + $this->set_prop( 'product_id', absint( $value ) ); + } + + /** + * Set user id. + * + * @param int $value User ID. + */ + public function set_user_id( $value ) { + $this->set_prop( 'user_id', absint( $value ) ); + } + + /** + * Set user_email. + * + * @param int $value User email. + */ + public function set_user_email( $value ) { + $this->set_prop( 'user_email', sanitize_email( $value ) ); + } + + /** + * Set order_id. + * + * @param int $value Order ID. + */ + public function set_order_id( $value ) { + $this->set_prop( 'order_id', absint( $value ) ); + } + + /** + * Set order_key. + * + * @param string $value Order key. + */ + public function set_order_key( $value ) { + $this->set_prop( 'order_key', $value ); + } + + /** + * Set downloads_remaining. + * + * @param integer|string $value Amount of downloads remaining. + */ + public function set_downloads_remaining( $value ) { + $this->set_prop( 'downloads_remaining', '' === $value ? '' : absint( $value ) ); + } + + /** + * Set access_granted. + * + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + */ + public function set_access_granted( $date = null ) { + $this->set_date_prop( 'access_granted', $date ); + } + + /** + * Set access_expires. + * + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + */ + public function set_access_expires( $date = null ) { + $this->set_date_prop( 'access_expires', $date ); + } + + /** + * Set download_count. + * + * @param int $value Download count. + */ + public function set_download_count( $value ) { + $this->set_prop( 'download_count', absint( $value ) ); + } + + /** + * Track a download on this permission. + * + * @since 3.3.0 + * @throws Exception When permission ID is invalid. + * @param int $user_id Id of the user performing the download. + * @param string $user_ip_address IP Address of the user performing the download. + */ + public function track_download( $user_id = null, $user_ip_address = null ) { + global $wpdb; + + // Must have a permission_id to track download log. + if ( ! ( $this->get_id() > 0 ) ) { + throw new Exception( __( 'Invalid permission ID.', 'woocommerce' ) ); + } + + // Increment download count, and decrement downloads remaining. + // Use SQL to avoid possible issues with downloads in quick succession. + // If downloads_remaining is blank, leave it blank (unlimited). + // Also, ensure downloads_remaining doesn't drop below zero. + $query = $wpdb->prepare( + " +UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions +SET download_count = download_count + 1, +downloads_remaining = IF( downloads_remaining = '', '', GREATEST( 0, downloads_remaining - 1 ) ) +WHERE permission_id = %d", + $this->get_id() + ); + $wpdb->query( $query ); // WPCS: unprepared SQL ok. + + // Re-read this download from the data store to pull updated counts. + $this->data_store->read( $this ); + + // Track download in download log. + $download_log = new WC_Customer_Download_Log(); + $download_log->set_timestamp( current_time( 'timestamp', true ) ); + $download_log->set_permission_id( $this->get_id() ); + + if ( ! is_null( $user_id ) ) { + $download_log->set_user_id( $user_id ); + } + + if ( ! is_null( $user_ip_address ) ) { + $download_log->set_user_ip_address( $user_ip_address ); + } + + $download_log->save(); + } + + /* + |-------------------------------------------------------------------------- + | CRUD methods + |-------------------------------------------------------------------------- + */ + + /** + * Save data to the database. + * + * @since 3.0.0 + * @return int Item ID + */ + public function save() { + if ( $this->data_store ) { + // Trigger action before saving to the DB. Use a pointer to adjust object props before save. + do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store ); + + if ( $this->get_id() ) { + $this->data_store->update( $this ); + } else { + $this->data_store->create( $this ); + } + } + return $this->get_id(); + } + + /* + |-------------------------------------------------------------------------- + | ArrayAccess/Backwards compatibility. + |-------------------------------------------------------------------------- + */ + + /** + * OffsetGet. + * + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( is_callable( array( $this, "get_$offset" ) ) ) { + return $this->{"get_$offset"}(); + } + } + + /** + * OffsetSet. + * + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( is_callable( array( $this, "set_$offset" ) ) ) { + $this->{"set_$offset"}( $value ); + } + } + + /** + * OffsetUnset + * + * @param string $offset Offset. + */ + public function offsetUnset( $offset ) { + if ( is_callable( array( $this, "set_$offset" ) ) ) { + $this->{"set_$offset"}( '' ); + } + } + + /** + * OffsetExists. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + return in_array( $offset, array_keys( $this->data ), true ); + } + + /** + * Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past. + * + * @param string $key Key name. + * @return bool + */ + public function __isset( $key ) { + return in_array( $key, array_keys( $this->data ), true ); + } + + /** + * Magic __get method for backwards compatibility. Maps legacy vars to new getters. + * + * @param string $key Key name. + * @return mixed + */ + public function __get( $key ) { + if ( is_callable( array( $this, "get_$key" ) ) ) { + return $this->{"get_$key"}( '' ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-customer.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer.php new file mode 100644 index 0000000..658f3c3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-customer.php @@ -0,0 +1,1075 @@ + null, + 'date_modified' => null, + 'email' => '', + 'first_name' => '', + 'last_name' => '', + 'display_name' => '', + 'role' => 'customer', + 'username' => '', + 'billing' => array( + 'first_name' => '', + 'last_name' => '', + 'company' => '', + 'address_1' => '', + 'address_2' => '', + 'city' => '', + 'state' => '', + 'postcode' => '', + 'country' => '', + 'email' => '', + 'phone' => '', + ), + 'shipping' => array( + 'first_name' => '', + 'last_name' => '', + 'company' => '', + 'address_1' => '', + 'address_2' => '', + 'city' => '', + 'state' => '', + 'postcode' => '', + 'country' => '', + ), + 'is_paying_customer' => false, + ); + + /** + * Stores a password if this needs to be changed. Write-only and hidden from _data. + * + * @var string + */ + protected $password = ''; + + /** + * Stores if user is VAT exempt for this session. + * + * @var string + */ + protected $is_vat_exempt = false; + + /** + * Stores if user has calculated shipping in this session. + * + * @var string + */ + protected $calculated_shipping = false; + + /** + * Load customer data based on how WC_Customer is called. + * + * If $customer is 'new', you can build a new WC_Customer object. If it's empty, some + * data will be pulled from the session for the current user/customer. + * + * @param WC_Customer|int $data Customer ID or data. + * @param bool $is_session True if this is the customer session. + * @throws Exception If customer cannot be read/found and $data is set. + */ + public function __construct( $data = 0, $is_session = false ) { + parent::__construct( $data ); + + if ( $data instanceof WC_Customer ) { + $this->set_id( absint( $data->get_id() ) ); + } elseif ( is_numeric( $data ) ) { + $this->set_id( $data ); + } + + $this->data_store = WC_Data_Store::load( 'customer' ); + + // If we have an ID, load the user from the DB. + if ( $this->get_id() ) { + try { + $this->data_store->read( $this ); + } catch ( Exception $e ) { + $this->set_id( 0 ); + $this->set_object_read( true ); + } + } else { + $this->set_object_read( true ); + } + + // If this is a session, set or change the data store to sessions. Changes do not persist in the database. + if ( $is_session ) { + $this->data_store = WC_Data_Store::load( 'customer-session' ); + $this->data_store->read( $this ); + } + } + + /** + * Prefix for action and filter hooks on data. + * + * @since 3.0.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_customer_get_'; + } + + /** + * Delete a customer and reassign posts.. + * + * @param int $reassign Reassign posts and links to new User ID. + * @since 3.0.0 + * @return bool + */ + public function delete_and_reassign( $reassign = null ) { + if ( $this->data_store ) { + $this->data_store->delete( + $this, array( + 'force_delete' => true, + 'reassign' => $reassign, + ) + ); + $this->set_id( 0 ); + return true; + } + return false; + } + + /** + * Is customer outside base country (for tax purposes)? + * + * @return bool + */ + public function is_customer_outside_base() { + list( $country, $state ) = $this->get_taxable_address(); + if ( $country ) { + $default = wc_get_base_location(); + if ( $default['country'] !== $country ) { + return true; + } + if ( $default['state'] && $default['state'] !== $state ) { + return true; + } + } + return false; + } + + /** + * Return this customer's avatar. + * + * @since 3.0.0 + * @return string + */ + public function get_avatar_url() { + return get_avatar_url( $this->get_email() ); + } + + /** + * Get taxable address. + * + * @return array + */ + public function get_taxable_address() { + $tax_based_on = get_option( 'woocommerce_tax_based_on' ); + + // Check shipping method at this point to see if we need special handling. + if ( true === apply_filters( 'woocommerce_apply_base_tax_for_local_pickup', true ) && count( array_intersect( wc_get_chosen_shipping_method_ids(), apply_filters( 'woocommerce_local_pickup_methods', array( 'legacy_local_pickup', 'local_pickup' ) ) ) ) > 0 ) { + $tax_based_on = 'base'; + } + + if ( 'base' === $tax_based_on ) { + $country = WC()->countries->get_base_country(); + $state = WC()->countries->get_base_state(); + $postcode = WC()->countries->get_base_postcode(); + $city = WC()->countries->get_base_city(); + } elseif ( 'billing' === $tax_based_on ) { + $country = $this->get_billing_country(); + $state = $this->get_billing_state(); + $postcode = $this->get_billing_postcode(); + $city = $this->get_billing_city(); + } else { + $country = $this->get_shipping_country(); + $state = $this->get_shipping_state(); + $postcode = $this->get_shipping_postcode(); + $city = $this->get_shipping_city(); + } + + return apply_filters( 'woocommerce_customer_taxable_address', array( $country, $state, $postcode, $city ) ); + } + + /** + * Gets a customer's downloadable products. + * + * @return array Array of downloadable products + */ + public function get_downloadable_products() { + $downloads = array(); + if ( $this->get_id() ) { + $downloads = wc_get_customer_available_downloads( $this->get_id() ); + } + return apply_filters( 'woocommerce_customer_get_downloadable_products', $downloads ); + } + + /** + * Is customer VAT exempt? + * + * @return bool + */ + public function is_vat_exempt() { + return $this->get_is_vat_exempt(); + } + + /** + * Has calculated shipping? + * + * @return bool + */ + public function has_calculated_shipping() { + return $this->get_calculated_shipping(); + } + + /** + * Get if customer is VAT exempt? + * + * @since 3.0.0 + * @return bool + */ + public function get_is_vat_exempt() { + return $this->is_vat_exempt; + } + + /** + * Get password (only used when updating the user object). + * + * @return string + */ + public function get_password() { + return $this->password; + } + + /** + * Has customer calculated shipping? + * + * @return bool + */ + public function get_calculated_shipping() { + return $this->calculated_shipping; + } + + /** + * Set if customer has tax exemption. + * + * @param bool $is_vat_exempt If is vat exempt. + */ + public function set_is_vat_exempt( $is_vat_exempt ) { + $this->is_vat_exempt = wc_string_to_bool( $is_vat_exempt ); + } + + /** + * Calculated shipping? + * + * @param bool $calculated If shipping is calculated. + */ + public function set_calculated_shipping( $calculated = true ) { + $this->calculated_shipping = wc_string_to_bool( $calculated ); + } + + /** + * Set customer's password. + * + * @since 3.0.0 + * @param string $password Password. + */ + public function set_password( $password ) { + $this->password = wc_clean( $password ); + } + + /** + * Gets the customers last order. + * + * @return WC_Order|false + */ + public function get_last_order() { + return $this->data_store->get_last_order( $this ); + } + + /** + * Return the number of orders this customer has. + * + * @return integer + */ + public function get_order_count() { + return $this->data_store->get_order_count( $this ); + } + + /** + * Return how much money this customer has spent. + * + * @return float + */ + public function get_total_spent() { + return $this->data_store->get_total_spent( $this ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Return the customer's username. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_username( $context = 'view' ) { + return $this->get_prop( 'username', $context ); + } + + /** + * Return the customer's email. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_email( $context = 'view' ) { + return $this->get_prop( 'email', $context ); + } + + /** + * Return customer's first name. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_first_name( $context = 'view' ) { + return $this->get_prop( 'first_name', $context ); + } + + /** + * Return customer's last name. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_last_name( $context = 'view' ) { + return $this->get_prop( 'last_name', $context ); + } + + /** + * Return customer's display name. + * + * @since 3.1.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_display_name( $context = 'view' ) { + return $this->get_prop( 'display_name', $context ); + } + + /** + * Return customer's user role. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_role( $context = 'view' ) { + return $this->get_prop( 'role', $context ); + } + + /** + * Return the date this customer was created. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|null object if the date is set or null if there is no date. + */ + public function get_date_created( $context = 'view' ) { + return $this->get_prop( 'date_created', $context ); + } + + /** + * Return the date this customer was last updated. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return WC_DateTime|null object if the date is set or null if there is no date. + */ + public function get_date_modified( $context = 'view' ) { + return $this->get_prop( 'date_modified', $context ); + } + + /** + * Gets a prop for a getter method. + * + * @since 3.0.0 + * @param string $prop Name of prop to get. + * @param string $address billing or shipping. + * @param string $context What the value is for. Valid values are 'view' and 'edit'. What the value is for. Valid values are view and edit. + * @return mixed + */ + protected function get_address_prop( $prop, $address = 'billing', $context = 'view' ) { + $value = null; + + if ( array_key_exists( $prop, $this->data[ $address ] ) ) { + $value = isset( $this->changes[ $address ][ $prop ] ) ? $this->changes[ $address ][ $prop ] : $this->data[ $address ][ $prop ]; + + if ( 'view' === $context ) { + $value = apply_filters( $this->get_hook_prefix() . $address . '_' . $prop, $value, $this ); + } + } + return $value; + } + + /** + * Get billing. + * + * @since 3.2.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_billing( $context = 'view' ) { + return $this->get_prop( 'billing', $context ); + } + + /** + * Get billing_first_name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_first_name( $context = 'view' ) { + return $this->get_address_prop( 'first_name', 'billing', $context ); + } + + /** + * Get billing_last_name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_last_name( $context = 'view' ) { + return $this->get_address_prop( 'last_name', 'billing', $context ); + } + + /** + * Get billing_company. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_company( $context = 'view' ) { + return $this->get_address_prop( 'company', 'billing', $context ); + } + + /** + * Get billing_address_1. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_address( $context = 'view' ) { + return $this->get_billing_address_1( $context ); + } + + /** + * Get billing_address_1. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_address_1( $context = 'view' ) { + return $this->get_address_prop( 'address_1', 'billing', $context ); + } + + /** + * Get billing_address_2. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string $value + */ + public function get_billing_address_2( $context = 'view' ) { + return $this->get_address_prop( 'address_2', 'billing', $context ); + } + + /** + * Get billing_city. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string $value + */ + public function get_billing_city( $context = 'view' ) { + return $this->get_address_prop( 'city', 'billing', $context ); + } + + /** + * Get billing_state. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_state( $context = 'view' ) { + return $this->get_address_prop( 'state', 'billing', $context ); + } + + /** + * Get billing_postcode. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_postcode( $context = 'view' ) { + return $this->get_address_prop( 'postcode', 'billing', $context ); + } + + /** + * Get billing_country. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_country( $context = 'view' ) { + return $this->get_address_prop( 'country', 'billing', $context ); + } + + /** + * Get billing_email. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_email( $context = 'view' ) { + return $this->get_address_prop( 'email', 'billing', $context ); + } + + /** + * Get billing_phone. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_billing_phone( $context = 'view' ) { + return $this->get_address_prop( 'phone', 'billing', $context ); + } + + /** + * Get shipping. + * + * @since 3.2.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_shipping( $context = 'view' ) { + return $this->get_prop( 'shipping', $context ); + } + + /** + * Get shipping_first_name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_first_name( $context = 'view' ) { + return $this->get_address_prop( 'first_name', 'shipping', $context ); + } + + /** + * Get shipping_last_name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_last_name( $context = 'view' ) { + return $this->get_address_prop( 'last_name', 'shipping', $context ); + } + + /** + * Get shipping_company. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_company( $context = 'view' ) { + return $this->get_address_prop( 'company', 'shipping', $context ); + } + + /** + * Get shipping_address_1. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_address( $context = 'view' ) { + return $this->get_shipping_address_1( $context ); + } + + /** + * Get shipping_address_1. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_address_1( $context = 'view' ) { + return $this->get_address_prop( 'address_1', 'shipping', $context ); + } + + /** + * Get shipping_address_2. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_address_2( $context = 'view' ) { + return $this->get_address_prop( 'address_2', 'shipping', $context ); + } + + /** + * Get shipping_city. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_city( $context = 'view' ) { + return $this->get_address_prop( 'city', 'shipping', $context ); + } + + /** + * Get shipping_state. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_state( $context = 'view' ) { + return $this->get_address_prop( 'state', 'shipping', $context ); + } + + /** + * Get shipping_postcode. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_postcode( $context = 'view' ) { + return $this->get_address_prop( 'postcode', 'shipping', $context ); + } + + /** + * Get shipping_country. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_country( $context = 'view' ) { + return $this->get_address_prop( 'country', 'shipping', $context ); + } + + /** + * Is the user a paying customer? + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_is_paying_customer( $context = 'view' ) { + return $this->get_prop( 'is_paying_customer', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set customer's username. + * + * @since 3.0.0 + * @param string $username Username. + */ + public function set_username( $username ) { + $this->set_prop( 'username', $username ); + } + + /** + * Set customer's email. + * + * @since 3.0.0 + * @param string $value Email. + */ + public function set_email( $value ) { + if ( $value && ! is_email( $value ) ) { + $this->error( 'customer_invalid_email', __( 'Invalid email address', 'woocommerce' ) ); + } + $this->set_prop( 'email', sanitize_email( $value ) ); + } + + /** + * Set customer's first name. + * + * @since 3.0.0 + * @param string $first_name First name. + */ + public function set_first_name( $first_name ) { + $this->set_prop( 'first_name', $first_name ); + } + + /** + * Set customer's last name. + * + * @since 3.0.0 + * @param string $last_name Last name. + */ + public function set_last_name( $last_name ) { + $this->set_prop( 'last_name', $last_name ); + } + + /** + * Set customer's display name. + * + * @since 3.1.0 + * @param string $display_name Display name. + */ + public function set_display_name( $display_name ) { + /* translators: 1: first name 2: last name */ + $this->set_prop( 'display_name', is_email( $display_name ) ? sprintf( _x( '%1$s %2$s', 'display name', 'woocommerce' ), $this->get_first_name(), $this->get_last_name() ) : $display_name ); + } + + /** + * Set customer's user role(s). + * + * @since 3.0.0 + * @param mixed $role User role. + */ + public function set_role( $role ) { + global $wp_roles; + + if ( $role && ! empty( $wp_roles->roles ) && ! in_array( $role, array_keys( $wp_roles->roles ), true ) ) { + $this->error( 'customer_invalid_role', __( 'Invalid role', 'woocommerce' ) ); + } + $this->set_prop( 'role', $role ); + } + + /** + * Set the date this customer was last updated. + * + * @since 3.0.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + */ + public function set_date_created( $date = null ) { + $this->set_date_prop( 'date_created', $date ); + } + + /** + * Set the date this customer was last updated. + * + * @since 3.0.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + */ + public function set_date_modified( $date = null ) { + $this->set_date_prop( 'date_modified', $date ); + } + + /** + * Set customer address to match shop base address. + * + * @since 3.0.0 + */ + public function set_billing_address_to_base() { + $base = wc_get_customer_default_location(); + $this->set_billing_location( $base['country'], $base['state'], '', '' ); + } + + /** + * Set customer shipping address to base address. + * + * @since 3.0.0 + */ + public function set_shipping_address_to_base() { + $base = wc_get_customer_default_location(); + $this->set_shipping_location( $base['country'], $base['state'], '', '' ); + } + + /** + * Sets all address info at once. + * + * @param string $country Country. + * @param string $state State. + * @param string $postcode Postcode. + * @param string $city City. + */ + public function set_billing_location( $country, $state = '', $postcode = '', $city = '' ) { + $billing = $this->get_prop( 'billing', 'edit' ); + $billing['country'] = $country; + $billing['state'] = $state; + $billing['postcode'] = $postcode; + $billing['city'] = $city; + $this->set_prop( 'billing', $billing ); + } + + /** + * Sets all shipping info at once. + * + * @param string $country Country. + * @param string $state State. + * @param string $postcode Postcode. + * @param string $city City. + */ + public function set_shipping_location( $country, $state = '', $postcode = '', $city = '' ) { + $shipping = $this->get_prop( 'shipping', 'edit' ); + $shipping['country'] = $country; + $shipping['state'] = $state; + $shipping['postcode'] = $postcode; + $shipping['city'] = $city; + $this->set_prop( 'shipping', $shipping ); + } + + /** + * Sets a prop for a setter method. + * + * @since 3.0.0 + * @param string $prop Name of prop to set. + * @param string $address Name of address to set. billing or shipping. + * @param mixed $value Value of the prop. + */ + protected function set_address_prop( $prop, $address = 'billing', $value ) { + if ( array_key_exists( $prop, $this->data[ $address ] ) ) { + if ( true === $this->object_read ) { + if ( $value !== $this->data[ $address ][ $prop ] || ( isset( $this->changes[ $address ] ) && array_key_exists( $prop, $this->changes[ $address ] ) ) ) { + $this->changes[ $address ][ $prop ] = $value; + } + } else { + $this->data[ $address ][ $prop ] = $value; + } + } + } + + /** + * Set billing_first_name. + * + * @param string $value Billing first name. + */ + public function set_billing_first_name( $value ) { + $this->set_address_prop( 'first_name', 'billing', $value ); + } + + /** + * Set billing_last_name. + * + * @param string $value Billing last name. + */ + public function set_billing_last_name( $value ) { + $this->set_address_prop( 'last_name', 'billing', $value ); + } + + /** + * Set billing_company. + * + * @param string $value Billing company. + */ + public function set_billing_company( $value ) { + $this->set_address_prop( 'company', 'billing', $value ); + } + + /** + * Set billing_address_1. + * + * @param string $value Billing address line 1. + */ + public function set_billing_address( $value ) { + $this->set_billing_address_1( $value ); + } + + /** + * Set billing_address_1. + * + * @param string $value Billing address line 1. + */ + public function set_billing_address_1( $value ) { + $this->set_address_prop( 'address_1', 'billing', $value ); + } + + /** + * Set billing_address_2. + * + * @param string $value Billing address line 2. + */ + public function set_billing_address_2( $value ) { + $this->set_address_prop( 'address_2', 'billing', $value ); + } + + /** + * Set billing_city. + * + * @param string $value Billing city. + */ + public function set_billing_city( $value ) { + $this->set_address_prop( 'city', 'billing', $value ); + } + + /** + * Set billing_state. + * + * @param string $value Billing state. + */ + public function set_billing_state( $value ) { + $this->set_address_prop( 'state', 'billing', $value ); + } + + /** + * Set billing_postcode. + * + * @param string $value Billing postcode. + */ + public function set_billing_postcode( $value ) { + $this->set_address_prop( 'postcode', 'billing', $value ); + } + + /** + * Set billing_country. + * + * @param string $value Billing country. + */ + public function set_billing_country( $value ) { + $this->set_address_prop( 'country', 'billing', $value ); + } + + /** + * Set billing_email. + * + * @param string $value Billing email. + */ + public function set_billing_email( $value ) { + if ( $value && ! is_email( $value ) ) { + $this->error( 'customer_invalid_billing_email', __( 'Invalid billing email address', 'woocommerce' ) ); + } + $this->set_address_prop( 'email', 'billing', sanitize_email( $value ) ); + } + + /** + * Set billing_phone. + * + * @param string $value Billing phone. + */ + public function set_billing_phone( $value ) { + $this->set_address_prop( 'phone', 'billing', $value ); + } + + /** + * Set shipping_first_name. + * + * @param string $value Shipping first name. + */ + public function set_shipping_first_name( $value ) { + $this->set_address_prop( 'first_name', 'shipping', $value ); + } + + /** + * Set shipping_last_name. + * + * @param string $value Shipping last name. + */ + public function set_shipping_last_name( $value ) { + $this->set_address_prop( 'last_name', 'shipping', $value ); + } + + /** + * Set shipping_company. + * + * @param string $value Shipping company. + */ + public function set_shipping_company( $value ) { + $this->set_address_prop( 'company', 'shipping', $value ); + } + + /** + * Set shipping_address_1. + * + * @param string $value Shipping address line 1. + */ + public function set_shipping_address( $value ) { + $this->set_shipping_address_1( $value ); + } + + /** + * Set shipping_address_1. + * + * @param string $value Shipping address line 1. + */ + public function set_shipping_address_1( $value ) { + $this->set_address_prop( 'address_1', 'shipping', $value ); + } + + /** + * Set shipping_address_2. + * + * @param string $value Shipping address line 2. + */ + public function set_shipping_address_2( $value ) { + $this->set_address_prop( 'address_2', 'shipping', $value ); + } + + /** + * Set shipping_city. + * + * @param string $value Shipping city. + */ + public function set_shipping_city( $value ) { + $this->set_address_prop( 'city', 'shipping', $value ); + } + + /** + * Set shipping_state. + * + * @param string $value Shipping state. + */ + public function set_shipping_state( $value ) { + $this->set_address_prop( 'state', 'shipping', $value ); + } + + /** + * Set shipping_postcode. + * + * @param string $value Shipping postcode. + */ + public function set_shipping_postcode( $value ) { + $this->set_address_prop( 'postcode', 'shipping', $value ); + } + + /** + * Set shipping_country. + * + * @param string $value Shipping country. + */ + public function set_shipping_country( $value ) { + $this->set_address_prop( 'country', 'shipping', $value ); + } + + /** + * Set if the user a paying customer. + * + * @since 3.0.0 + * @param bool $is_paying_customer If is a paying customer. + */ + public function set_is_paying_customer( $is_paying_customer ) { + $this->set_prop( 'is_paying_customer', (bool) $is_paying_customer ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-data-exception.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-data-exception.php new file mode 100644 index 0000000..0b29c49 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-data-exception.php @@ -0,0 +1,64 @@ +error_code = $code; + $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); + + parent::__construct( $message, $http_status_code ); + } + + /** + * Returns the error code. + * + * @return string + */ + public function getErrorCode() { + return $this->error_code; + } + + /** + * Returns error data. + * + * @return array + */ + public function getErrorData() { + return $this->error_data; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-data-store.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-data-store.php new file mode 100644 index 0000000..983c12f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-data-store.php @@ -0,0 +1,206 @@ + class name. + * Example: 'product' => 'WC_Product_Data_Store_CPT' + * You can also pass something like product_ for product stores and + * that type will be used first when available, if a store is requested like + * this and doesn't exist, then the store would fall back to 'product'. + * Ran through `woocommerce_data_stores`. + * + * @var array + */ + private $stores = array( + 'coupon' => 'WC_Coupon_Data_Store_CPT', + 'customer' => 'WC_Customer_Data_Store', + 'customer-download' => 'WC_Customer_Download_Data_Store', + 'customer-download-log' => 'WC_Customer_Download_Log_Data_Store', + 'customer-session' => 'WC_Customer_Data_Store_Session', + 'order' => 'WC_Order_Data_Store_CPT', + 'order-refund' => 'WC_Order_Refund_Data_Store_CPT', + 'order-item' => 'WC_Order_Item_Data_Store', + 'order-item-coupon' => 'WC_Order_Item_Coupon_Data_Store', + 'order-item-fee' => 'WC_Order_Item_Fee_Data_Store', + 'order-item-product' => 'WC_Order_Item_Product_Data_Store', + 'order-item-shipping' => 'WC_Order_Item_Shipping_Data_Store', + 'order-item-tax' => 'WC_Order_Item_Tax_Data_Store', + 'payment-token' => 'WC_Payment_Token_Data_Store', + 'product' => 'WC_Product_Data_Store_CPT', + 'product-grouped' => 'WC_Product_Grouped_Data_Store_CPT', + 'product-variable' => 'WC_Product_Variable_Data_Store_CPT', + 'product-variation' => 'WC_Product_Variation_Data_Store_CPT', + 'shipping-zone' => 'WC_Shipping_Zone_Data_Store', + 'webhook' => 'WC_Webhook_Data_Store', + ); + + /** + * Contains the name of the current data store's class name. + * + * @var string + */ + private $current_class_name = ''; + + /** + * The object type this store works with. + * + * @var string + */ + private $object_type = ''; + + + /** + * Tells WC_Data_Store which object (coupon, product, order, etc) + * store we want to work with. + * + * @throws Exception When validation fails. + * @param string $object_type Name of object. + */ + public function __construct( $object_type ) { + $this->object_type = $object_type; + $this->stores = apply_filters( 'woocommerce_data_stores', $this->stores ); + + // If this object type can't be found, check to see if we can load one + // level up (so if product-type isn't found, we try product). + if ( ! array_key_exists( $object_type, $this->stores ) ) { + $pieces = explode( '-', $object_type ); + $object_type = $pieces[0]; + } + + if ( array_key_exists( $object_type, $this->stores ) ) { + $store = apply_filters( 'woocommerce_' . $object_type . '_data_store', $this->stores[ $object_type ] ); + if ( is_object( $store ) ) { + if ( ! $store instanceof WC_Object_Data_Store_Interface ) { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + $this->current_class_name = get_class( $store ); + $this->instance = $store; + } else { + if ( ! class_exists( $store ) ) { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + $this->current_class_name = $store; + $this->instance = new $store(); + } + } else { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + } + + /** + * Only store the object type to avoid serializing the data store instance. + * + * @return array + */ + public function __sleep() { + return array( 'object_type' ); + } + + /** + * Re-run the constructor with the object type. + */ + public function __wakeup() { + $this->__construct( $this->object_type ); + } + + /** + * Loads a data store. + * + * @param string $object_type Name of object. + * + * @since 3.0.0 + * @return WC_Data_Store + */ + public static function load( $object_type ) { + return new WC_Data_Store( $object_type ); + } + + /** + * Returns the class name of the current data store. + * + * @since 3.0.0 + * @return string + */ + public function get_current_class_name() { + return $this->current_class_name; + } + + /** + * Reads an object from the data store. + * + * @since 3.0.0 + * @param WC_Data $data WooCommerce data instance. + */ + public function read( &$data ) { + $this->instance->read( $data ); + } + + /** + * Create an object in the data store. + * + * @since 3.0.0 + * @param WC_Data $data WooCommerce data instance. + */ + public function create( &$data ) { + $this->instance->create( $data ); + } + + /** + * Update an object in the data store. + * + * @since 3.0.0 + * @param WC_Data $data WooCommerce data instance. + */ + public function update( &$data ) { + $this->instance->update( $data ); + } + + /** + * Delete an object from the data store. + * + * @since 3.0.0 + * @param WC_Data $data WooCommerce data instance. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$data, $args = array() ) { + $this->instance->delete( $data, $args ); + } + + /** + * Data stores can define additional functions (for example, coupons have + * some helper methods for increasing or decreasing usage). This passes + * through to the instance if that function exists. + * + * @since 3.0.0 + * @param string $method Method. + * @param mixed $parameters Parameters. + * @return mixed + */ + public function __call( $method, $parameters ) { + if ( is_callable( array( $this->instance, $method ) ) ) { + $object = array_shift( $parameters ); + return call_user_func_array( array( $this->instance, $method ), array_merge( array( &$object ), $parameters ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-datetime.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-datetime.php new file mode 100644 index 0000000..379eec7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-datetime.php @@ -0,0 +1,107 @@ +format( DATE_ATOM ); + } + + /** + * Set UTC offset - this is a fixed offset instead of a timezone. + * + * @param int $offset Offset. + */ + public function set_utc_offset( $offset ) { + $this->utc_offset = intval( $offset ); + } + + /** + * Get UTC offset if set, or default to the DateTime object's offset. + */ + public function getOffset() { + if ( $this->utc_offset ) { + return $this->utc_offset; + } else { + return parent::getOffset(); + } + } + + /** + * Set timezone. + * + * @param DateTimeZone $timezone DateTimeZone instance. + * @return DateTime + */ + public function setTimezone( $timezone ) { + $this->utc_offset = 0; + return parent::setTimezone( $timezone ); + } + + /** + * Missing in PHP 5.2 so just here so it can be supported consistently. + * + * @since 3.0.0 + * @return int + */ + public function getTimestamp() { + return method_exists( 'DateTime', 'getTimestamp' ) ? parent::getTimestamp() : $this->format( 'U' ); + } + + /** + * Get the timestamp with the WordPress timezone offset added or subtracted. + * + * @since 3.0.0 + * @return int + */ + public function getOffsetTimestamp() { + return $this->getTimestamp() + $this->getOffset(); + } + + /** + * Format a date based on the offset timestamp. + * + * @since 3.0.0 + * @param string $format Date format. + * @return string + */ + public function date( $format ) { + return gmdate( $format, $this->getOffsetTimestamp() ); + } + + /** + * Return a localised date based on offset timestamp. Wrapper for date_i18n function. + * + * @since 3.0.0 + * @param string $format Date format. + * @return string + */ + public function date_i18n( $format = 'Y-m-d' ) { + return date_i18n( $format, $this->getOffsetTimestamp() ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-action-hooks.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-action-hooks.php new file mode 100644 index 0000000..39bc932 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-action-hooks.php @@ -0,0 +1,191 @@ + 'old'. + * + * @var array + */ + protected $deprecated_hooks = array( + 'woocommerce_new_order_item' => array( + 'woocommerce_order_add_shipping', + 'woocommerce_order_add_coupon', + 'woocommerce_order_add_tax', + 'woocommerce_order_add_fee', + 'woocommerce_add_shipping_order_item', + 'woocommerce_add_order_item_meta', + 'woocommerce_add_order_fee_meta', + ), + 'woocommerce_update_order_item' => array( + 'woocommerce_order_edit_product', + 'woocommerce_order_update_coupon', + 'woocommerce_order_update_shipping', + 'woocommerce_order_update_fee', + 'woocommerce_order_update_tax', + ), + 'woocommerce_new_payment_token' => 'woocommerce_payment_token_created', + 'woocommerce_new_product_variation' => 'woocommerce_create_product_variation', + 'woocommerce_order_details_after_order_table_items' => 'woocommerce_order_items_table', + + 'woocommerce_settings_advanced_page_options' => array( + 'woocommerce_settings_checkout_page_options', + 'woocommerce_settings_account_page_options', + ), + 'woocommerce_settings_advanced_page_options_end' => array( + 'woocommerce_settings_checkout_page_options_end', + 'woocommerce_settings_account_page_options_end', + ), + 'woocommerce_settings_advanced_page_options_after' => array( + 'woocommerce_settings_checkout_page_options_after', + 'woocommerce_settings_account_page_options_after', + ), + ); + + /** + * Array of versions on each hook has been deprecated. + * + * @var array + */ + protected $deprecated_version = array( + 'woocommerce_order_add_shipping' => '3.0.0', + 'woocommerce_order_add_coupon' => '3.0.0', + 'woocommerce_order_add_tax' => '3.0.0', + 'woocommerce_order_add_fee' => '3.0.0', + 'woocommerce_add_shipping_order_item' => '3.0.0', + 'woocommerce_add_order_item_meta' => '3.0.0', + 'woocommerce_add_order_fee_meta' => '3.0.0', + 'woocommerce_order_edit_product' => '3.0.0', + 'woocommerce_order_update_coupon' => '3.0.0', + 'woocommerce_order_update_shipping' => '3.0.0', + 'woocommerce_order_update_fee' => '3.0.0', + 'woocommerce_order_update_tax' => '3.0.0', + 'woocommerce_payment_token_created' => '3.0.0', + 'woocommerce_create_product_variation' => '3.0.0', + 'woocommerce_order_items_table' => '3.0.0', + 'woocommerce_settings_checkout_page_options' => '3.4.0', + 'woocommerce_settings_account_page_options' => '3.4.0', + 'woocommerce_settings_checkout_page_options_end' => '3.4.0', + 'woocommerce_settings_account_page_options_end' => '3.4.0', + 'woocommerce_settings_checkout_page_options_after' => '3.4.0', + 'woocommerce_settings_account_page_options_after' => '3.4.0', + ); + + /** + * Hook into the new hook so we can handle deprecated hooks once fired. + * + * @param string $hook_name Hook name. + */ + public function hook_in( $hook_name ) { + add_action( $hook_name, array( $this, 'maybe_handle_deprecated_hook' ), -1000, 8 ); + } + + /** + * If the old hook is in-use, trigger it. + * + * @param string $new_hook New hook name. + * @param string $old_hook Old hook name. + * @param array $new_callback_args New callback args. + * @param mixed $return_value Returned value. + * @return mixed + */ + public function handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value ) { + if ( has_action( $old_hook ) ) { + $this->display_notice( $old_hook, $new_hook ); + $return_value = $this->trigger_hook( $old_hook, $new_callback_args ); + } + return $return_value; + } + + /** + * Fire off a legacy hook with it's args. + * + * @param string $old_hook Old hook name. + * @param array $new_callback_args New callback args. + * @return mixed + */ + protected function trigger_hook( $old_hook, $new_callback_args ) { + switch ( $old_hook ) { + case 'woocommerce_order_add_shipping': + case 'woocommerce_order_add_fee': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Shipping' ) || is_a( $item, 'WC_Order_Item_Fee' ) ) { + do_action( $old_hook, $order_id, $item_id, $item ); + } + break; + case 'woocommerce_order_add_coupon': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Coupon' ) ) { + do_action( $old_hook, $order_id, $item_id, $item->get_code(), $item->get_discount(), $item->get_discount_tax() ); + } + break; + case 'woocommerce_order_add_tax': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Tax' ) ) { + do_action( $old_hook, $order_id, $item_id, $item->get_rate_id(), $item->get_tax_total(), $item->get_shipping_tax_total() ); + } + break; + case 'woocommerce_add_shipping_order_item': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Shipping' ) ) { + do_action( $old_hook, $order_id, $item_id, $item->legacy_package_key ); + } + break; + case 'woocommerce_add_order_item_meta': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Product' ) ) { + do_action( $old_hook, $item_id, $item->legacy_values, $item->legacy_cart_item_key ); + } + break; + case 'woocommerce_add_order_fee_meta': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Fee' ) ) { + do_action( $old_hook, $order_id, $item_id, $item->legacy_fee, $item->legacy_fee_key ); + } + break; + case 'woocommerce_order_edit_product': + $item_id = $new_callback_args[0]; + $item = $new_callback_args[1]; + $order_id = $new_callback_args[2]; + if ( is_a( $item, 'WC_Order_Item_Product' ) ) { + do_action( $old_hook, $order_id, $item_id, $item, $item->get_product() ); + } + break; + case 'woocommerce_order_update_coupon': + case 'woocommerce_order_update_shipping': + case 'woocommerce_order_update_fee': + case 'woocommerce_order_update_tax': + if ( ! is_a( $item, 'WC_Order_Item_Product' ) ) { + do_action( $old_hook, $order_id, $item_id, $item ); + } + break; + default: + do_action_ref_array( $old_hook, $new_callback_args ); + break; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-filter-hooks.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-filter-hooks.php new file mode 100644 index 0000000..0c49887 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-deprecated-filter-hooks.php @@ -0,0 +1,157 @@ + 'old'. + * + * @var array + */ + protected $deprecated_hooks = array( + 'woocommerce_structured_data_order' => 'woocommerce_email_order_schema_markup', + 'woocommerce_add_to_cart_fragments' => 'add_to_cart_fragments', + 'woocommerce_add_to_cart_redirect' => 'add_to_cart_redirect', + 'woocommerce_product_get_width' => 'woocommerce_product_width', + 'woocommerce_product_get_height' => 'woocommerce_product_height', + 'woocommerce_product_get_length' => 'woocommerce_product_length', + 'woocommerce_product_get_weight' => 'woocommerce_product_weight', + 'woocommerce_product_get_sku' => 'woocommerce_get_sku', + 'woocommerce_product_get_price' => 'woocommerce_get_price', + 'woocommerce_product_get_regular_price' => 'woocommerce_get_regular_price', + 'woocommerce_product_get_sale_price' => 'woocommerce_get_sale_price', + 'woocommerce_product_get_tax_class' => 'woocommerce_product_tax_class', + 'woocommerce_product_get_stock_quantity' => 'woocommerce_get_stock_quantity', + 'woocommerce_product_get_attributes' => 'woocommerce_get_product_attributes', + 'woocommerce_product_get_gallery_image_ids' => 'woocommerce_product_gallery_attachment_ids', + 'woocommerce_product_get_review_count' => 'woocommerce_product_review_count', + 'woocommerce_product_get_downloads' => 'woocommerce_product_files', + 'woocommerce_order_get_currency' => 'woocommerce_get_currency', + 'woocommerce_order_get_discount_total' => 'woocommerce_order_amount_discount_total', + 'woocommerce_order_get_discount_tax' => 'woocommerce_order_amount_discount_tax', + 'woocommerce_order_get_shipping_total' => 'woocommerce_order_amount_shipping_total', + 'woocommerce_order_get_shipping_tax' => 'woocommerce_order_amount_shipping_tax', + 'woocommerce_order_get_cart_tax' => 'woocommerce_order_amount_cart_tax', + 'woocommerce_order_get_total' => 'woocommerce_order_amount_total', + 'woocommerce_order_get_total_tax' => 'woocommerce_order_amount_total_tax', + 'woocommerce_order_get_total_discount' => 'woocommerce_order_amount_total_discount', + 'woocommerce_order_get_subtotal' => 'woocommerce_order_amount_subtotal', + 'woocommerce_order_get_tax_totals' => 'woocommerce_order_tax_totals', + 'woocommerce_get_order_refund_get_amount' => 'woocommerce_refund_amount', + 'woocommerce_get_order_refund_get_reason' => 'woocommerce_refund_reason', + 'default_checkout_billing_country' => 'default_checkout_country', + 'default_checkout_billing_state' => 'default_checkout_state', + 'default_checkout_billing_postcode' => 'default_checkout_postcode', + 'woocommerce_system_status_environment_rows' => 'woocommerce_debug_posting', + 'woocommerce_credit_card_type_labels' => 'wocommerce_credit_card_type_labels', + 'woocommerce_get_script_data' => array( + 'woocommerce_params', + 'wc_geolocation_params', + 'wc_single_product_params', + 'wc_checkout_params', + 'wc_address_i18n_params', + 'wc_cart_params', + 'wc_cart_fragments_params', + 'wc_add_to_cart_params', + 'wc_add_to_cart_variation_params', + 'wc_country_select_params', + 'wc_password_strength_meter_params', + ), + 'woocommerce_settings_tabs_advanced' => 'woocommerce_settings_tabs_api', + 'woocommerce_settings_advanced' => 'woocommerce_settings_api', + ); + + /** + * Array of versions on each hook has been deprecated. + * + * @var array + */ + protected $deprecated_version = array( + 'woocommerce_email_order_schema_markup' => '3.0.0', + 'add_to_cart_fragments' => '3.0.0', + 'add_to_cart_redirect' => '3.0.0', + 'woocommerce_product_width' => '3.0.0', + 'woocommerce_product_height' => '3.0.0', + 'woocommerce_product_length' => '3.0.0', + 'woocommerce_product_weight' => '3.0.0', + 'woocommerce_get_sku' => '3.0.0', + 'woocommerce_get_price' => '3.0.0', + 'woocommerce_get_regular_price' => '3.0.0', + 'woocommerce_get_sale_price' => '3.0.0', + 'woocommerce_product_tax_class' => '3.0.0', + 'woocommerce_get_stock_quantity' => '3.0.0', + 'woocommerce_get_product_attributes' => '3.0.0', + 'woocommerce_product_gallery_attachment_ids' => '3.0.0', + 'woocommerce_product_review_count' => '3.0.0', + 'woocommerce_product_files' => '3.0.0', + 'woocommerce_get_currency' => '3.0.0', + 'woocommerce_order_amount_discount_total' => '3.0.0', + 'woocommerce_order_amount_discount_tax' => '3.0.0', + 'woocommerce_order_amount_shipping_total' => '3.0.0', + 'woocommerce_order_amount_shipping_tax' => '3.0.0', + 'woocommerce_order_amount_cart_tax' => '3.0.0', + 'woocommerce_order_amount_total' => '3.0.0', + 'woocommerce_order_amount_total_tax' => '3.0.0', + 'woocommerce_order_amount_total_discount' => '3.0.0', + 'woocommerce_order_amount_subtotal' => '3.0.0', + 'woocommerce_order_tax_totals' => '3.0.0', + 'woocommerce_refund_amount' => '3.0.0', + 'woocommerce_refund_reason' => '3.0.0', + 'default_checkout_country' => '3.0.0', + 'default_checkout_state' => '3.0.0', + 'default_checkout_postcode' => '3.0.0', + 'woocommerce_debug_posting' => '3.0.0', + 'wocommerce_credit_card_type_labels' => '3.0.0', + 'woocommerce_settings_tabs_api' => '3.4.0', + 'woocommerce_settings_api' => '3.4.0', + ); + + /** + * Hook into the new hook so we can handle deprecated hooks once fired. + * + * @param string $hook_name Hook name. + */ + public function hook_in( $hook_name ) { + add_filter( $hook_name, array( $this, 'maybe_handle_deprecated_hook' ), -1000, 8 ); + } + + /** + * If the old hook is in-use, trigger it. + * + * @param string $new_hook New hook name. + * @param string $old_hook Old hook name. + * @param array $new_callback_args New callback args. + * @param mixed $return_value Returned value. + * @return mixed + */ + public function handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value ) { + if ( has_filter( $old_hook ) ) { + $this->display_notice( $old_hook, $new_hook ); + $return_value = $this->trigger_hook( $old_hook, $new_callback_args ); + } + return $return_value; + } + + /** + * Fire off a legacy hook with it's args. + * + * @param string $old_hook Old hook name. + * @param array $new_callback_args New callback args. + * @return mixed + */ + protected function trigger_hook( $old_hook, $new_callback_args ) { + return apply_filters_ref_array( $old_hook, $new_callback_args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-discounts.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-discounts.php new file mode 100644 index 0000000..1e5abef --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-discounts.php @@ -0,0 +1,955 @@ + Item Key => Value + */ + protected $discounts = array(); + + /** + * Constructor. + * + * @param array $object Cart or order object. + */ + public function __construct( $object = array() ) { + if ( is_a( $object, 'WC_Cart' ) ) { + $this->set_items_from_cart( $object ); + } elseif ( is_a( $object, 'WC_Order' ) ) { + $this->set_items_from_order( $object ); + } + } + + /** + * Set items directly. Used by WC_Cart_Totals. + * + * @since 3.2.3 + * @param array $items Items to set. + */ + public function set_items( $items ) { + $this->items = $items; + $this->discounts = array(); + uasort( $this->items, array( $this, 'sort_by_price' ) ); + } + + /** + * Normalise cart items which will be discounted. + * + * @since 3.2.0 + * @param WC_Cart $cart Cart object. + */ + public function set_items_from_cart( $cart ) { + $this->items = array(); + $this->discounts = array(); + + if ( ! is_a( $cart, 'WC_Cart' ) ) { + return; + } + + $this->object = $cart; + + foreach ( $cart->get_cart() as $key => $cart_item ) { + $item = new stdClass(); + $item->key = $key; + $item->object = $cart_item; + $item->product = $cart_item['data']; + $item->quantity = $cart_item['quantity']; + $item->price = wc_add_number_precision_deep( $item->product->get_price() * $item->quantity ); + $this->items[ $key ] = $item; + } + + uasort( $this->items, array( $this, 'sort_by_price' ) ); + } + + /** + * Normalise order items which will be discounted. + * + * @since 3.2.0 + * @param array $order Cart object. + */ + public function set_items_from_order( $order ) { + $this->items = array(); + $this->discounts = array(); + + if ( ! is_a( $order, 'WC_Order' ) ) { + return; + } + + $this->object = $order; + + foreach ( $order->get_items() as $order_item ) { + $item = new stdClass(); + $item->key = $order_item->get_id(); + $item->object = $order_item; + $item->product = $order_item->get_product(); + $item->quantity = $order_item->get_quantity(); + $item->price = wc_add_number_precision_deep( $order_item->get_subtotal() ); + + if ( $order->get_prices_include_tax() ) { + $item->price += wc_add_number_precision_deep( $order_item->get_subtotal_tax() ); + } + + $this->items[ $order_item->get_id() ] = $item; + } + + uasort( $this->items, array( $this, 'sort_by_price' ) ); + } + + /** + * Get the object concerned. + * + * @since 3.3.2 + * @return object + */ + public function get_object() { + return $this->object; + } + + /** + * Get items. + * + * @since 3.2.0 + * @return object[] + */ + public function get_items() { + return $this->items; + } + + /** + * Get items to validate. + * + * @since 3.3.2 + * @return object[] + */ + public function get_items_to_validate() { + return apply_filters( 'woocommerce_coupon_get_items_to_validate', $this->get_items(), $this ); + } + + /** + * Get discount by key with or without precision. + * + * @since 3.2.0 + * @param string $key name of discount row to return. + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return array + */ + public function get_discount( $key, $in_cents = false ) { + $item_discount_totals = $this->get_discounts_by_item( $in_cents ); + return isset( $item_discount_totals[ $key ] ) ? $item_discount_totals[ $key ] : 0; + } + + /** + * Get all discount totals. + * + * @since 3.2.0 + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return array + */ + public function get_discounts( $in_cents = false ) { + $discounts = $this->discounts; + return $in_cents ? $discounts : wc_remove_number_precision_deep( $discounts ); + } + + /** + * Get all discount totals per item. + * + * @since 3.2.0 + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return array + */ + public function get_discounts_by_item( $in_cents = false ) { + $discounts = $this->discounts; + $item_discount_totals = (array) array_shift( $discounts ); + + foreach ( $discounts as $item_discounts ) { + foreach ( $item_discounts as $item_key => $item_discount ) { + $item_discount_totals[ $item_key ] += $item_discount; + } + } + + return $in_cents ? $item_discount_totals : wc_remove_number_precision_deep( $item_discount_totals ); + } + + /** + * Get all discount totals per coupon. + * + * @since 3.2.0 + * @param bool $in_cents Should the totals be returned in cents, or without precision. + * @return array + */ + public function get_discounts_by_coupon( $in_cents = false ) { + $coupon_discount_totals = array_map( 'array_sum', $this->discounts ); + + return $in_cents ? $coupon_discount_totals : wc_remove_number_precision_deep( $coupon_discount_totals ); + } + + /** + * Get discounted price of an item without precision. + * + * @since 3.2.0 + * @param object $item Get data for this item. + * @return float + */ + public function get_discounted_price( $item ) { + return wc_remove_number_precision_deep( $this->get_discounted_price_in_cents( $item ) ); + } + + /** + * Get discounted price of an item to precision (in cents). + * + * @since 3.2.0 + * @param object $item Get data for this item. + * @return int + */ + public function get_discounted_price_in_cents( $item ) { + return absint( round( $item->price - $this->get_discount( $item->key, true ) ) ); + } + + /** + * Apply a discount to all items using a coupon. + * + * @since 3.2.0 + * @param WC_Coupon $coupon Coupon object being applied to the items. + * @param bool $validate Set to false to skip coupon validation. + * @return bool|WP_Error True if applied or WP_Error instance in failure. + */ + public function apply_coupon( $coupon, $validate = true ) { + if ( ! is_a( $coupon, 'WC_Coupon' ) ) { + return new WP_Error( 'invalid_coupon', __( 'Invalid coupon', 'woocommerce' ) ); + } + + $is_coupon_valid = $validate ? $this->is_coupon_valid( $coupon ) : true; + + if ( is_wp_error( $is_coupon_valid ) ) { + return $is_coupon_valid; + } + + if ( ! isset( $this->discounts[ $coupon->get_code() ] ) ) { + $this->discounts[ $coupon->get_code() ] = array_fill_keys( array_keys( $this->items ), 0 ); + } + + $items_to_apply = $this->get_items_to_apply_coupon( $coupon ); + $coupon_type = $coupon->get_discount_type(); + + // Core discounts are handled here as of 3.2. + switch ( $coupon->get_discount_type() ) { + case 'percent': + $this->apply_coupon_percent( $coupon, $items_to_apply ); + break; + case 'fixed_product': + $this->apply_coupon_fixed_product( $coupon, $items_to_apply ); + break; + case 'fixed_cart': + $this->apply_coupon_fixed_cart( $coupon, $items_to_apply ); + break; + default: + $this->apply_coupon_custom( $coupon, $items_to_apply ); + break; + } + + return true; + } + + /** + * Sort by price. + * + * @since 3.2.0 + * @param array $a First element. + * @param array $b Second element. + * @return int + */ + protected function sort_by_price( $a, $b ) { + $price_1 = $a->price * $a->quantity; + $price_2 = $b->price * $b->quantity; + if ( $price_1 === $price_2 ) { + return 0; + } + return ( $price_1 < $price_2 ) ? 1 : -1; + } + + /** + * Filter out all products which have been fully discounted to 0. + * Used as array_filter callback. + * + * @since 3.2.0 + * @param object $item Get data for this item. + * @return bool + */ + protected function filter_products_with_price( $item ) { + return $this->get_discounted_price_in_cents( $item ) > 0; + } + + /** + * Get items which the coupon should be applied to. + * + * @since 3.2.0 + * @param object $coupon Coupon object. + * @return array + */ + protected function get_items_to_apply_coupon( $coupon ) { + $items_to_apply = array(); + + foreach ( $this->get_items_to_validate() as $item ) { + $item_to_apply = clone $item; // Clone the item so changes to this item do not affect the originals. + + if ( 0 === $this->get_discounted_price_in_cents( $item_to_apply ) || 0 >= $item_to_apply->quantity ) { + continue; + } + + if ( ! $coupon->is_valid_for_product( $item_to_apply->product, $item_to_apply->object ) && ! $coupon->is_valid_for_cart() ) { + continue; + } + + $items_to_apply[] = $item_to_apply; + } + return $items_to_apply; + } + + /** + * Apply percent discount to items and return an array of discounts granted. + * + * @since 3.2.0 + * @param WC_Coupon $coupon Coupon object. Passed through filters. + * @param array $items_to_apply Array of items to apply the coupon to. + * @return int Total discounted. + */ + protected function apply_coupon_percent( $coupon, $items_to_apply ) { + $total_discount = 0; + $cart_total = 0; + $limit_usage_qty = 0; + $applied_count = 0; + $adjust_final_discount = true; + + if ( null !== $coupon->get_limit_usage_to_x_items() ) { + $limit_usage_qty = $coupon->get_limit_usage_to_x_items(); + } + + $coupon_amount = $coupon->get_amount(); + + foreach ( $items_to_apply as $item ) { + // Find out how much price is available to discount for the item. + $discounted_price = $this->get_discounted_price_in_cents( $item ); + + // Get the price we actually want to discount, based on settings. + $price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price; + + // See how many and what price to apply to. + $apply_quantity = $limit_usage_qty && ( $limit_usage_qty - $applied_count ) < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity; + $apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) ); + $price_to_discount = ( $price_to_discount / $item->quantity ) * $apply_quantity; + + // Run coupon calculations. + $discount = floor( $price_to_discount * ( $coupon_amount / 100 ) ); + + if ( is_a( $this->object, 'WC_Cart' ) && has_filter( 'woocommerce_coupon_get_discount_amount' ) ) { + // Send through the legacy filter, but not as cents. + $filtered_discount = wc_add_number_precision( apply_filters( 'woocommerce_coupon_get_discount_amount', wc_remove_number_precision( $discount ), wc_remove_number_precision( $price_to_discount ), $item->object, false, $coupon ) ); + + if ( $filtered_discount !== $discount ) { + $discount = $filtered_discount; + $adjust_final_discount = false; + } + } + + $discount = wc_round_discount( min( $discounted_price, $discount ), 0 ); + $cart_total = $cart_total + $price_to_discount; + $total_discount = $total_discount + $discount; + $applied_count = $applied_count + $apply_quantity; + + // Store code and discount amount per item. + $this->discounts[ $coupon->get_code() ][ $item->key ] += $discount; + } + + // Work out how much discount would have been given to the cart as a whole and compare to what was discounted on all line items. + $cart_total_discount = wc_round_discount( $cart_total * ( $coupon_amount / 100 ), 0 ); + + if ( $total_discount < $cart_total_discount && $adjust_final_discount ) { + $total_discount += $this->apply_coupon_remainder( $coupon, $items_to_apply, $cart_total_discount - $total_discount ); + } + + return $total_discount; + } + + /** + * Apply fixed product discount to items. + * + * @since 3.2.0 + * @param WC_Coupon $coupon Coupon object. Passed through filters. + * @param array $items_to_apply Array of items to apply the coupon to. + * @param int $amount Fixed discount amount to apply in cents. Leave blank to pull from coupon. + * @return int Total discounted. + */ + protected function apply_coupon_fixed_product( $coupon, $items_to_apply, $amount = null ) { + $total_discount = 0; + $amount = $amount ? $amount : wc_add_number_precision( $coupon->get_amount() ); + $limit_usage_qty = 0; + $applied_count = 0; + + if ( null !== $coupon->get_limit_usage_to_x_items() ) { + $limit_usage_qty = $coupon->get_limit_usage_to_x_items(); + } + + foreach ( $items_to_apply as $item ) { + // Find out how much price is available to discount for the item. + $discounted_price = $this->get_discounted_price_in_cents( $item ); + + // Get the price we actually want to discount, based on settings. + $price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price; + + // Run coupon calculations. + if ( $limit_usage_qty ) { + $apply_quantity = $limit_usage_qty - $applied_count < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity; + $apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) ); + $discount = min( $amount, $item->price / $item->quantity ) * $apply_quantity; + } else { + $apply_quantity = apply_filters( 'woocommerce_coupon_get_apply_quantity', $item->quantity, $item, $coupon, $this ); + $discount = $amount * $apply_quantity; + } + + if ( is_a( $this->object, 'WC_Cart' ) && has_filter( 'woocommerce_coupon_get_discount_amount' ) ) { + // Send through the legacy filter, but not as cents. + $discount = wc_add_number_precision( apply_filters( 'woocommerce_coupon_get_discount_amount', wc_remove_number_precision( $discount ), wc_remove_number_precision( $price_to_discount ), $item->object, false, $coupon ) ); + } + + $discount = min( $discounted_price, $discount ); + $total_discount = $total_discount + $discount; + $applied_count = $applied_count + $apply_quantity; + + // Store code and discount amount per item. + $this->discounts[ $coupon->get_code() ][ $item->key ] += $discount; + } + return $total_discount; + } + + /** + * Apply fixed cart discount to items. + * + * @since 3.2.0 + * @param WC_Coupon $coupon Coupon object. Passed through filters. + * @param array $items_to_apply Array of items to apply the coupon to. + * @param int $amount Fixed discount amount to apply in cents. Leave blank to pull from coupon. + * @return int Total discounted. + */ + protected function apply_coupon_fixed_cart( $coupon, $items_to_apply, $amount = null ) { + $total_discount = 0; + $amount = $amount ? $amount : wc_add_number_precision( $coupon->get_amount() ); + $items_to_apply = array_filter( $items_to_apply, array( $this, 'filter_products_with_price' ) ); + $item_count = array_sum( wp_list_pluck( $items_to_apply, 'quantity' ) ); + + if ( ! $item_count ) { + return $total_discount; + } + + if ( ! $amount ) { + // If there is no amount we still send it through so filters are fired. + $total_discount = $this->apply_coupon_fixed_product( $coupon, $items_to_apply, 0 ); + } else { + $per_item_discount = absint( $amount / $item_count ); // round it down to the nearest cent. + + if ( $per_item_discount > 0 ) { + $total_discount = $this->apply_coupon_fixed_product( $coupon, $items_to_apply, $per_item_discount ); + + /** + * If there is still discount remaining, repeat the process. + */ + if ( $total_discount > 0 && $total_discount < $amount ) { + $total_discount += $this->apply_coupon_fixed_cart( $coupon, $items_to_apply, $amount - $total_discount ); + } + } elseif ( $amount > 0 ) { + $total_discount += $this->apply_coupon_remainder( $coupon, $items_to_apply, $amount ); + } + } + return $total_discount; + } + + /** + * Apply custom coupon discount to items. + * + * @since 3.3 + * @param WC_Coupon $coupon Coupon object. Passed through filters. + * @param array $items_to_apply Array of items to apply the coupon to. + * @return int Total discounted. + */ + protected function apply_coupon_custom( $coupon, $items_to_apply ) { + foreach ( $items_to_apply as $item ) { + $discounted_price = $this->get_discounted_price_in_cents( $item ); + $price_to_discount = wc_remove_number_precision( ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price ); + $discount = wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount / $item->quantity, $item->object, true ) ) * $item->quantity; + $discount = min( $discounted_price, $discount ); + + // Store code and discount amount per item. + $this->discounts[ $coupon->get_code() ][ $item->key ] += $discount; + } + + // Allow post-processing for custom coupon types (e.g. calculating discrepancy, etc). + $this->discounts[ $coupon->get_code() ] = apply_filters( 'woocommerce_coupon_custom_discounts_array', $this->discounts[ $coupon->get_code() ], $coupon ); + + return array_sum( $this->discounts[ $coupon->get_code() ] ); + } + + /** + * Deal with remaining fractional discounts by splitting it over items + * until the amount is expired, discounting 1 cent at a time. + * + * @since 3.2.0 + * @param WC_Coupon $coupon Coupon object if appliable. Passed through filters. + * @param array $items_to_apply Array of items to apply the coupon to. + * @param int $amount Fixed discount amount to apply. + * @return int Total discounted. + */ + protected function apply_coupon_remainder( $coupon, $items_to_apply, $amount ) { + $total_discount = 0; + + foreach ( $items_to_apply as $item ) { + for ( $i = 0; $i < $item->quantity; $i ++ ) { + // Find out how much price is available to discount for the item. + $discounted_price = $this->get_discounted_price_in_cents( $item ); + + // Get the price we actually want to discount, based on settings. + $price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price; + + // Run coupon calculations. + $discount = min( $price_to_discount, 1 ); + + // Store totals. + $total_discount += $discount; + + // Store code and discount amount per item. + $this->discounts[ $coupon->get_code() ][ $item->key ] += $discount; + + if ( $total_discount >= $amount ) { + break 2; + } + } + if ( $total_discount >= $amount ) { + break; + } + } + return $total_discount; + } + + /** + * Ensure coupon exists or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_exists( $coupon ) { + if ( ! $coupon->get_id() && ! $coupon->get_virtual() ) { + /* translators: %s: coupon code */ + throw new Exception( sprintf( __( 'Coupon "%s" does not exist!', 'woocommerce' ), $coupon->get_code() ), 105 ); + } + + return true; + } + + /** + * Ensure coupon usage limit is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_usage_limit( $coupon ) { + if ( $coupon->get_usage_limit() > 0 && $coupon->get_usage_count() >= $coupon->get_usage_limit() ) { + throw new Exception( __( 'Coupon usage limit has been reached.', 'woocommerce' ), 106 ); + } + + return true; + } + + /** + * Ensure coupon user usage limit is valid or throw exception. + * + * Per user usage limit - check here if user is logged in (against user IDs). + * Checked again for emails later on in WC_Cart::check_customer_coupons(). + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @param int $user_id User ID. + * @return bool + */ + protected function validate_coupon_user_usage_limit( $coupon, $user_id = 0 ) { + if ( empty( $user_id ) ) { + if ( $this->object instanceof WC_Order ) { + $user_id = $this->object->get_customer_id(); + } else { + $user_id = get_current_user_id(); + } + } + + if ( $coupon && $user_id && $coupon->get_usage_limit_per_user() > 0 && $coupon->get_id() && $coupon->get_data_store() ) { + $date_store = $coupon->get_data_store(); + $usage_count = $date_store->get_usage_by_user_id( $coupon, $user_id ); + if ( $usage_count >= $coupon->get_usage_limit_per_user() ) { + throw new Exception( __( 'Coupon usage limit has been reached.', 'woocommerce' ), 106 ); + } + } + + return true; + } + + /** + * Ensure coupon date is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_expiry_date( $coupon ) { + if ( $coupon->get_date_expires() && apply_filters( 'woocommerce_coupon_validate_expiry_date', current_time( 'timestamp', true ) > $coupon->get_date_expires()->getTimestamp(), $coupon, $this ) ) { + throw new Exception( __( 'This coupon has expired.', 'woocommerce' ), 107 ); + } + + return true; + } + + /** + * Ensure coupon amount is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_minimum_amount( $coupon ) { + $subtotal = wc_remove_number_precision( $this->get_object_subtotal() ); + if ( $coupon->get_minimum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_minimum_amount', $coupon->get_minimum_amount() > $subtotal, $coupon, $subtotal ) ) { + /* translators: %s: coupon minimum amount */ + throw new Exception( sprintf( __( 'The minimum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_minimum_amount() ) ), 108 ); + } + + return true; + } + + /** + * Ensure coupon amount is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_maximum_amount( $coupon ) { + $subtotal = wc_remove_number_precision( $this->get_object_subtotal() ); + if ( $coupon->get_maximum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_maximum_amount', $coupon->get_maximum_amount() < $subtotal, $coupon ) ) { + /* translators: %s: coupon maximum amount */ + throw new Exception( sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_maximum_amount() ) ), 112 ); + } + + return true; + } + + /** + * Ensure coupon is valid for products in the list is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_product_ids( $coupon ) { + if ( count( $coupon->get_product_ids() ) > 0 ) { + $valid = false; + + foreach ( $this->get_items_to_validate() as $item ) { + if ( $item->product && in_array( $item->product->get_id(), $coupon->get_product_ids(), true ) || in_array( $item->product->get_parent_id(), $coupon->get_product_ids(), true ) ) { + $valid = true; + break; + } + } + + if ( ! $valid ) { + throw new Exception( __( 'Sorry, this coupon is not applicable to selected products.', 'woocommerce' ), 109 ); + } + } + + return true; + } + + /** + * Ensure coupon is valid for product categories in the list is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_product_categories( $coupon ) { + if ( count( $coupon->get_product_categories() ) > 0 ) { + $valid = false; + + foreach ( $this->get_items_to_validate() as $item ) { + if ( $coupon->get_exclude_sale_items() && $item->product && $item->product->is_on_sale() ) { + continue; + } + + $product_cats = wc_get_product_cat_ids( $item->product->get_id() ); + + if ( $item->product->get_parent_id() ) { + $product_cats = array_merge( $product_cats, wc_get_product_cat_ids( $item->product->get_parent_id() ) ); + } + + // If we find an item with a cat in our allowed cat list, the coupon is valid. + if ( count( array_intersect( $product_cats, $coupon->get_product_categories() ) ) > 0 ) { + $valid = true; + break; + } + } + + if ( ! $valid ) { + throw new Exception( __( 'Sorry, this coupon is not applicable to selected products.', 'woocommerce' ), 109 ); + } + } + + return true; + } + + /** + * Ensure coupon is valid for sale items in the list is valid or throw exception. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_sale_items( $coupon ) { + if ( $coupon->get_exclude_sale_items() ) { + $valid = false; + + foreach ( $this->get_items_to_validate() as $item ) { + if ( $item->product && ! $item->product->is_on_sale() ) { + $valid = true; + break; + } + } + + if ( ! $valid ) { + throw new Exception( __( 'Sorry, this coupon is not valid for sale items.', 'woocommerce' ), 110 ); + } + } + + return true; + } + + /** + * All exclusion rules must pass at the same time for a product coupon to be valid. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_excluded_items( $coupon ) { + $items = $this->get_items_to_validate(); + if ( ! empty( $items ) && $coupon->is_type( wc_get_product_coupon_types() ) ) { + $valid = false; + + foreach ( $items as $item ) { + if ( $item->product && $coupon->is_valid_for_product( $item->product, $item->object ) ) { + $valid = true; + break; + } + } + + if ( ! $valid ) { + throw new Exception( __( 'Sorry, this coupon is not applicable to selected products.', 'woocommerce' ), 109 ); + } + } + + return true; + } + + /** + * Cart discounts cannot be added if non-eligible product is found. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_eligible_items( $coupon ) { + if ( ! $coupon->is_type( wc_get_product_coupon_types() ) ) { + $this->validate_coupon_excluded_product_ids( $coupon ); + $this->validate_coupon_excluded_product_categories( $coupon ); + } + + return true; + } + + /** + * Exclude products. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_excluded_product_ids( $coupon ) { + // Exclude Products. + if ( count( $coupon->get_excluded_product_ids() ) > 0 ) { + $products = array(); + + foreach ( $this->get_items_to_validate() as $item ) { + if ( $item->product && in_array( $item->product->get_id(), $coupon->get_excluded_product_ids(), true ) || in_array( $item->product->get_parent_id(), $coupon->get_excluded_product_ids(), true ) ) { + $products[] = $item->product->get_name(); + } + } + + if ( ! empty( $products ) ) { + /* translators: %s: products list */ + throw new Exception( sprintf( __( 'Sorry, this coupon is not applicable to the products: %s.', 'woocommerce' ), implode( ', ', $products ) ), 113 ); + } + } + + return true; + } + + /** + * Exclude categories from product list. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool + */ + protected function validate_coupon_excluded_product_categories( $coupon ) { + if ( count( $coupon->get_excluded_product_categories() ) > 0 ) { + $categories = array(); + + foreach ( $this->get_items_to_validate() as $item ) { + if ( ! $item->product ) { + continue; + } + + $product_cats = wc_get_product_cat_ids( $item->product->get_id() ); + + if ( $item->product->get_parent_id() ) { + $product_cats = array_merge( $product_cats, wc_get_product_cat_ids( $item->product->get_parent_id() ) ); + } + + $cat_id_list = array_intersect( $product_cats, $coupon->get_excluded_product_categories() ); + if ( count( $cat_id_list ) > 0 ) { + foreach ( $cat_id_list as $cat_id ) { + $cat = get_term( $cat_id, 'product_cat' ); + $categories[] = $cat->name; + } + } + } + + if ( ! empty( $categories ) ) { + /* translators: %s: categories list */ + throw new Exception( sprintf( __( 'Sorry, this coupon is not applicable to the categories: %s.', 'woocommerce' ), implode( ', ', array_unique( $categories ) ) ), 114 ); + } + } + + return true; + } + + /** + * Get the object subtotal + * + * @return int + */ + protected function get_object_subtotal() { + if ( is_a( $this->object, 'WC_Cart' ) ) { + return wc_add_number_precision( $this->object->get_displayed_subtotal() ); + } elseif ( is_a( $this->object, 'WC_Order' ) ) { + return wc_add_number_precision( $this->object->get_subtotal() ); + } else { + return array_sum( wp_list_pluck( $this->items, 'price' ) ); + } + } + + /** + * Check if a coupon is valid. + * + * Error Codes: + * - 100: Invalid filtered. + * - 101: Invalid removed. + * - 102: Not yours removed. + * - 103: Already applied. + * - 104: Individual use only. + * - 105: Not exists. + * - 106: Usage limit reached. + * - 107: Expired. + * - 108: Minimum spend limit not met. + * - 109: Not applicable. + * - 110: Not valid for sale items. + * - 111: Missing coupon code. + * - 112: Maximum spend limit met. + * - 113: Excluded products. + * - 114: Excluded categories. + * + * @since 3.2.0 + * @throws Exception Error message. + * @param WC_Coupon $coupon Coupon data. + * @return bool|WP_Error + */ + public function is_coupon_valid( $coupon ) { + try { + $this->validate_coupon_exists( $coupon ); + $this->validate_coupon_usage_limit( $coupon ); + $this->validate_coupon_user_usage_limit( $coupon ); + $this->validate_coupon_expiry_date( $coupon ); + $this->validate_coupon_minimum_amount( $coupon ); + $this->validate_coupon_maximum_amount( $coupon ); + $this->validate_coupon_product_ids( $coupon ); + $this->validate_coupon_product_categories( $coupon ); + $this->validate_coupon_sale_items( $coupon ); + $this->validate_coupon_excluded_items( $coupon ); + $this->validate_coupon_eligible_items( $coupon ); + + if ( ! apply_filters( 'woocommerce_coupon_is_valid', true, $coupon, $this ) ) { + throw new Exception( __( 'Coupon is not valid.', 'woocommerce' ), 100 ); + } + } catch ( Exception $e ) { + /** + * Filter the coupon error message. + * + * @param string $error_message Error message. + * @param int $error_code Error code. + * @param WC_Coupon $coupon Coupon data. + */ + $message = apply_filters( 'woocommerce_coupon_error', is_numeric( $e->getMessage() ) ? $coupon->get_coupon_error( $e->getMessage() ) : $e->getMessage(), $e->getCode(), $coupon ); + + return new WP_Error( 'invalid_coupon', $message, array( + 'status' => 400, + ) ); + } + return true; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-download-handler.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-download-handler.php new file mode 100644 index 0000000..8b1af51 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-download-handler.php @@ -0,0 +1,582 @@ +get_billing_email() : null; + + // Prepare email address hash. + $email_hash = function_exists( 'hash' ) ? hash( 'sha256', $email_address ) : sha1( $email_address ); + + if ( is_null( $email_address ) || ! hash_equals( wp_unslash( $_GET['uid'] ), $email_hash ) ) { // WPCS: input var ok, CSRF ok, sanitization ok. + self::download_error( __( 'Invalid download link.', 'woocommerce' ) ); + } + } + + $download_ids = $data_store->get_downloads( + array( + 'user_email' => sanitize_email( str_replace( ' ', '+', $email_address ) ), + 'order_key' => wc_clean( wp_unslash( $_GET['order'] ) ), // WPCS: input var ok, CSRF ok. + 'product_id' => $product_id, + 'download_id' => wc_clean( preg_replace( '/\s+/', ' ', wp_unslash( $_GET['key'] ) ) ), // WPCS: input var ok, CSRF ok, sanitization ok. + 'orderby' => 'downloads_remaining', + 'order' => 'DESC', + 'limit' => 1, + 'return' => 'ids', + ) + ); + + if ( empty( $download_ids ) ) { + self::download_error( __( 'Invalid download link.', 'woocommerce' ) ); + } + + $download = new WC_Customer_Download( current( $download_ids ) ); + + $file_path = $product->get_file_download_path( $download->get_download_id() ); + $parsed_file_path = self::parse_file_path( $file_path ); + $download_range = self::get_download_range( @filesize( $parsed_file_path['file_path'] ) ); // @codingStandardsIgnoreLine. + + self::check_order_is_valid( $download ); + if ( ! $download_range['is_range_request'] ) { + // If the remaining download count goes to 0, allow range requests to be able to finish streaming from iOS devices. + self::check_downloads_remaining( $download ); + } + self::check_download_expiry( $download ); + self::check_download_login_required( $download ); + + do_action( + 'woocommerce_download_product', + $download->get_user_email(), + $download->get_order_key(), + $download->get_product_id(), + $download->get_user_id(), + $download->get_download_id(), + $download->get_order_id() + ); + $download->save(); + + // Track the download in logs and change remaining/counts. + $current_user_id = get_current_user_id(); + $ip_address = WC_Geolocation::get_ip_address(); + if ( ! $download_range['is_range_request'] ) { + $download->track_download( $current_user_id > 0 ? $current_user_id : null, ! empty( $ip_address ) ? $ip_address : null ); + } + + self::download( $file_path, $download->get_product_id() ); + } + + /** + * Check if an order is valid for downloading from. + * + * @param WC_Customer_Download $download Download instance. + */ + private static function check_order_is_valid( $download ) { + if ( $download->get_order_id() ) { + $order = wc_get_order( $download->get_order_id() ); + + if ( $order && ! $order->is_download_permitted() ) { + self::download_error( __( 'Invalid order.', 'woocommerce' ), '', 403 ); + } + } + } + + /** + * Check if there are downloads remaining. + * + * @param WC_Customer_Download $download Download instance. + */ + private static function check_downloads_remaining( $download ) { + if ( '' !== $download->get_downloads_remaining() && 0 >= $download->get_downloads_remaining() ) { + self::download_error( __( 'Sorry, you have reached your download limit for this file', 'woocommerce' ), '', 403 ); + } + } + + /** + * Check if the download has expired. + * + * @param WC_Customer_Download $download Download instance. + */ + private static function check_download_expiry( $download ) { + if ( ! is_null( $download->get_access_expires() ) && $download->get_access_expires()->getTimestamp() < strtotime( 'midnight', current_time( 'timestamp', true ) ) ) { + self::download_error( __( 'Sorry, this download has expired', 'woocommerce' ), '', 403 ); + } + } + + /** + * Check if a download requires the user to login first. + * + * @param WC_Customer_Download $download Download instance. + */ + private static function check_download_login_required( $download ) { + if ( $download->get_user_id() && 'yes' === get_option( 'woocommerce_downloads_require_login' ) ) { + if ( ! is_user_logged_in() ) { + if ( wc_get_page_id( 'myaccount' ) ) { + wp_safe_redirect( add_query_arg( 'wc_error', rawurlencode( __( 'You must be logged in to download files.', 'woocommerce' ) ), wc_get_page_permalink( 'myaccount' ) ) ); + exit; + } else { + self::download_error( __( 'You must be logged in to download files.', 'woocommerce' ) . ' ' . __( 'Login', 'woocommerce' ) . '', __( 'Log in to Download Files', 'woocommerce' ), 403 ); + } + } elseif ( ! current_user_can( 'download_file', $download ) ) { + self::download_error( __( 'This is not your download link.', 'woocommerce' ), '', 403 ); + } + } + } + + /** + * Count download. + * + * @deprecated unknown + * @param array $download_data Download data. + */ + public static function count_download( $download_data ) {} + + /** + * Download a file - hook into init function. + * + * @param string $file_path URL to file. + * @param integer $product_id Product ID of the product being downloaded. + */ + public static function download( $file_path, $product_id ) { + if ( ! $file_path ) { + self::download_error( __( 'No file defined', 'woocommerce' ) ); + } + + $filename = basename( $file_path ); + + if ( strstr( $filename, '?' ) ) { + $filename = current( explode( '?', $filename ) ); + } + + $filename = apply_filters( 'woocommerce_file_download_filename', $filename, $product_id ); + $file_download_method = apply_filters( 'woocommerce_file_download_method', get_option( 'woocommerce_file_download_method', 'force' ), $product_id ); + + // Add action to prevent issues in IE. + add_action( 'nocache_headers', array( __CLASS__, 'ie_nocache_headers_fix' ) ); + + // Trigger download via one of the methods. + do_action( 'woocommerce_download_file_' . $file_download_method, $file_path, $filename ); + } + + /** + * Redirect to a file to start the download. + * + * @param string $file_path File path. + * @param string $filename File name. + */ + public static function download_file_redirect( $file_path, $filename = '' ) { + header( 'Location: ' . $file_path ); + exit; + } + + /** + * Parse file path and see if its remote or local. + * + * @param string $file_path File path. + * @return array + */ + public static function parse_file_path( $file_path ) { + $wp_uploads = wp_upload_dir(); + $wp_uploads_dir = $wp_uploads['basedir']; + $wp_uploads_url = $wp_uploads['baseurl']; + + /** + * Replace uploads dir, site url etc with absolute counterparts if we can. + * Note the str_replace on site_url is on purpose, so if https is forced + * via filters we can still do the string replacement on a HTTP file. + */ + $replacements = array( + $wp_uploads_url => $wp_uploads_dir, + network_site_url( '/', 'https' ) => ABSPATH, + str_replace( 'https:', 'http:', network_site_url( '/', 'http' ) ) => ABSPATH, + site_url( '/', 'https' ) => ABSPATH, + str_replace( 'https:', 'http:', site_url( '/', 'http' ) ) => ABSPATH, + ); + + $file_path = str_replace( array_keys( $replacements ), array_values( $replacements ), $file_path ); + $parsed_file_path = wp_parse_url( $file_path ); + $remote_file = true; + + // See if path needs an abspath prepended to work. + if ( file_exists( ABSPATH . $file_path ) ) { + $remote_file = false; + $file_path = ABSPATH . $file_path; + + } elseif ( '/wp-content' === substr( $file_path, 0, 11 ) ) { + $remote_file = false; + $file_path = realpath( WP_CONTENT_DIR . substr( $file_path, 11 ) ); + + // Check if we have an absolute path. + } elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ), true ) ) && isset( $parsed_file_path['path'] ) && file_exists( $parsed_file_path['path'] ) ) { + $remote_file = false; + $file_path = $parsed_file_path['path']; + } + + return array( + 'remote_file' => $remote_file, + 'file_path' => $file_path, + ); + } + + /** + * Download a file using X-Sendfile, X-Lighttpd-Sendfile, or X-Accel-Redirect if available. + * + * @param string $file_path File path. + * @param string $filename File name. + */ + public static function download_file_xsendfile( $file_path, $filename ) { + $parsed_file_path = self::parse_file_path( $file_path ); + + if ( function_exists( 'apache_get_modules' ) && in_array( 'mod_xsendfile', apache_get_modules(), true ) ) { + self::download_headers( $parsed_file_path['file_path'], $filename ); + header( 'X-Sendfile: ' . $parsed_file_path['file_path'] ); + exit; + } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'lighttpd' ) ) { + self::download_headers( $parsed_file_path['file_path'], $filename ); + header( 'X-Lighttpd-Sendfile: ' . $parsed_file_path['file_path'] ); + exit; + } elseif ( stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' ) || stristr( getenv( 'SERVER_SOFTWARE' ), 'cherokee' ) ) { + self::download_headers( $parsed_file_path['file_path'], $filename ); + $xsendfile_path = trim( preg_replace( '`^' . str_replace( '\\', '/', getcwd() ) . '`', '', $parsed_file_path['file_path'] ), '/' ); + header( "X-Accel-Redirect: /$xsendfile_path" ); + exit; + } + + // Fallback. + self::download_file_force( $file_path, $filename ); + } + + /** + * Parse the HTTP_RANGE request from iOS devices. + * Does not support multi-range requests. + * + * @param int $file_size Size of file in bytes. + * @return array { + * Information about range download request: beginning and length of + * file chunk, whether the range is valid/supported and whether the request is a range request. + * + * @type int $start Byte offset of the beginning of the range. Default 0. + * @type int $length Length of the requested file chunk in bytes. Optional. + * @type bool $is_range_valid Whether the requested range is a valid and supported range. + * @type bool $is_range_request Whether the request is a range request. + * } + */ + protected static function get_download_range( $file_size ) { + $start = 0; + $download_range = array( + 'start' => $start, + 'is_range_valid' => false, + 'is_range_request' => false, + ); + + if ( ! $file_size ) { + return $download_range; + } + + $end = $file_size - 1; + $download_range['length'] = $file_size; + + if ( isset( $_SERVER['HTTP_RANGE'] ) ) { // @codingStandardsIgnoreLine. + $http_range = sanitize_text_field( wp_unslash( $_SERVER['HTTP_RANGE'] ) ); // WPCS: input var ok. + $download_range['is_range_request'] = true; + + $c_start = $start; + $c_end = $end; + // Extract the range string. + list( , $range ) = explode( '=', $http_range, 2 ); + // Make sure the client hasn't sent us a multibyte range. + if ( strpos( $range, ',' ) !== false ) { + return $download_range; + } + + /* + * If the range starts with an '-' we start from the beginning. + * If not, we forward the file pointer + * and make sure to get the end byte if specified. + */ + if ( '-' === $range[0] ) { + // The n-number of the last bytes is requested. + $c_start = $file_size - substr( $range, 1 ); + } else { + $range = explode( '-', $range ); + $c_start = ( isset( $range[0] ) && is_numeric( $range[0] ) ) ? (int) $range[0] : 0; + $c_end = ( isset( $range[1] ) && is_numeric( $range[1] ) ) ? (int) $range[1] : $file_size; + } + + /* + * Check the range and make sure it's treated according to the specs: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html. + * End bytes can not be larger than $end. + */ + $c_end = ( $c_end > $end ) ? $end : $c_end; + // Validate the requested range and return an error if it's not correct. + if ( $c_start > $c_end || $c_start > $file_size - 1 || $c_end >= $file_size ) { + return $download_range; + } + $start = $c_start; + $end = $c_end; + $length = $end - $start + 1; + + $download_range['start'] = $start; + $download_range['length'] = $length; + $download_range['is_range_valid'] = true; + } + return $download_range; + } + + /** + * Force download - this is the default method. + * + * @param string $file_path File path. + * @param string $filename File name. + */ + public static function download_file_force( $file_path, $filename ) { + $parsed_file_path = self::parse_file_path( $file_path ); + $download_range = self::get_download_range( @filesize( $parsed_file_path['file_path'] ) ); // @codingStandardsIgnoreLine. + + self::download_headers( $parsed_file_path['file_path'], $filename, $download_range ); + + $start = isset( $download_range['start'] ) ? $download_range['start'] : 0; + $length = isset( $download_range['length'] ) ? $download_range['length'] : 0; + if ( ! self::readfile_chunked( $parsed_file_path['file_path'], $start, $length ) ) { + if ( $parsed_file_path['remote_file'] ) { + self::download_file_redirect( $file_path ); + } else { + self::download_error( __( 'File not found', 'woocommerce' ) ); + } + } + + exit; + } + + /** + * Get content type of a download. + * + * @param string $file_path File path. + * @return string + */ + private static function get_download_content_type( $file_path ) { + $file_extension = strtolower( substr( strrchr( $file_path, '.' ), 1 ) ); + $ctype = 'application/force-download'; + + foreach ( get_allowed_mime_types() as $mime => $type ) { + $mimes = explode( '|', $mime ); + if ( in_array( $file_extension, $mimes, true ) ) { + $ctype = $type; + break; + } + } + + return $ctype; + } + + /** + * Set headers for the download. + * + * @param string $file_path File path. + * @param string $filename File name. + * @param array $download_range Array containing info about range download request (see {@see get_download_range} for structure). + */ + private static function download_headers( $file_path, $filename, $download_range = array() ) { + self::check_server_config(); + self::clean_buffers(); + wc_nocache_headers(); + + header( 'X-Robots-Tag: noindex, nofollow', true ); + header( 'Content-Type: ' . self::get_download_content_type( $file_path ) ); + header( 'Content-Description: File Transfer' ); + header( 'Content-Disposition: attachment; filename="' . $filename . '";' ); + header( 'Content-Transfer-Encoding: binary' ); + + $file_size = @filesize( $file_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + if ( ! $file_size ) { + return; + } + + if ( isset( $download_range['is_range_request'] ) && true === $download_range['is_range_request'] ) { + if ( false === $download_range['is_range_valid'] ) { + header( 'HTTP/1.1 416 Requested Range Not Satisfiable' ); + header( 'Content-Range: bytes 0-' . ( $file_size - 1 ) . '/' . $file_size ); + exit; + } + + $start = $download_range['start']; + $end = $download_range['start'] + $download_range['length'] - 1; + $length = $download_range['length']; + + header( 'HTTP/1.1 206 Partial Content' ); + header( "Accept-Ranges: 0-$file_size" ); + header( "Content-Range: bytes $start-$end/$file_size" ); + header( "Content-Length: $length" ); + } else { + header( 'Content-Length: ' . $file_size ); + } + } + + /** + * Check and set certain server config variables to ensure downloads work as intended. + */ + private static function check_server_config() { + wc_set_time_limit( 0 ); + if ( function_exists( 'get_magic_quotes_runtime' ) && get_magic_quotes_runtime() && version_compare( phpversion(), '5.4', '<' ) ) { + set_magic_quotes_runtime( 0 ); // @codingStandardsIgnoreLine + } + if ( function_exists( 'apache_setenv' ) ) { + @apache_setenv( 'no-gzip', 1 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_apache_setenv + } + @ini_set( 'zlib.output_compression', 'Off' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_ini_set + @session_write_close(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.SessionFunctionsUsage.session_session_write_close + } + + /** + * Clean all output buffers. + * + * Can prevent errors, for example: transfer closed with 3 bytes remaining to read. + */ + private static function clean_buffers() { + if ( ob_get_level() ) { + $levels = ob_get_level(); + for ( $i = 0; $i < $levels; $i++ ) { + @ob_end_clean(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + } + } else { + @ob_end_clean(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + } + } + + /** + * Read file chunked. + * + * Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/. + * + * @param string $file File. + * @param int $start Byte offset/position of the beginning from which to read from the file. + * @param int $length Length of the chunk to be read from the file in bytes, 0 means full file. + * @return bool Success or fail + */ + public static function readfile_chunked( $file, $start = 0, $length = 0 ) { + if ( ! defined( 'WC_CHUNK_SIZE' ) ) { + define( 'WC_CHUNK_SIZE', 1024 * 1024 ); + } + $handle = @fopen( $file, 'r' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen + + if ( false === $handle ) { + return false; + } + + if ( ! $length ) { + $length = @filesize( $file ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + } + + $read_length = (int) WC_CHUNK_SIZE; + + if ( $length ) { + $end = $start + $length - 1; + + @fseek( $handle, $start ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + $p = @ftell( $handle ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + + while ( ! @feof( $handle ) && $p <= $end ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + // Don't run past the end of file. + if ( $p + $read_length > $end ) { + $read_length = $end - $p + 1; + } + + echo @fread( $handle, $read_length ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions.file_system_read_fread + $p = @ftell( $handle ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + + if ( ob_get_length() ) { + ob_flush(); + flush(); + } + } + } else { + while ( ! @feof( $handle ) ) { // @codingStandardsIgnoreLine. + echo @fread( $handle, $read_length ); // @codingStandardsIgnoreLine. + if ( ob_get_length() ) { + ob_flush(); + flush(); + } + } + } + + return @fclose( $handle ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fclose + } + + /** + * Filter headers for IE to fix issues over SSL. + * + * IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set. + * + * @param array $headers HTTP headers. + * @return array + */ + public static function ie_nocache_headers_fix( $headers ) { + if ( is_ssl() && ! empty( $GLOBALS['is_IE'] ) ) { + $headers['Cache-Control'] = 'private'; + unset( $headers['Pragma'] ); + } + return $headers; + } + + /** + * Die with an error message if the download fails. + * + * @param string $message Error message. + * @param string $title Error title. + * @param integer $status Error status. + */ + private static function download_error( $message, $title = '', $status = 404 ) { + if ( ! strstr( $message, '' . esc_html__( 'Go to shop', 'woocommerce' ) . ''; + } + wp_die( $message, $title, array( 'response' => $status ) ); // WPCS: XSS ok. + } +} + +WC_Download_Handler::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-emails.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-emails.php new file mode 100644 index 0000000..b1ef004 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-emails.php @@ -0,0 +1,659 @@ +push_to_queue( + array( + 'filter' => current_filter(), + 'args' => func_get_args(), + ) + ); + } else { + call_user_func_array( array( __CLASS__, 'send_transactional_email' ), func_get_args() ); + } + } + + /** + * Init the mailer instance and call the notifications for the current filter. + * + * @internal + * + * @param string $filter Filter name. + * @param array $args Email args (default: []). + */ + public static function send_queued_transactional_email( $filter = '', $args = array() ) { + if ( apply_filters( 'woocommerce_allow_send_queued_transactional_email', true, $filter, $args ) ) { + self::instance(); // Init self so emails exist. + + // Ensure gateways are loaded in case they need to insert data into the emails. + WC()->payment_gateways(); + WC()->shipping(); + + do_action_ref_array( $filter . '_notification', $args ); + } + } + + /** + * Init the mailer instance and call the notifications for the current filter. + * + * @internal + * + * @param array $args Email args (default: []). + */ + public static function send_transactional_email( $args = array() ) { + try { + $args = func_get_args(); + self::instance(); // Init self so emails exist. + do_action_ref_array( current_filter() . '_notification', $args ); + } catch ( Exception $e ) { + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + trigger_error( 'Transactional email triggered fatal error for callback ' . current_filter(), E_USER_WARNING ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + } + } + } + + /** + * Constructor for the email class hooks in all emails that can be sent. + */ + public function __construct() { + $this->init(); + + // Email Header, Footer and content hooks. + add_action( 'woocommerce_email_header', array( $this, 'email_header' ) ); + add_action( 'woocommerce_email_footer', array( $this, 'email_footer' ) ); + add_action( 'woocommerce_email_order_details', array( $this, 'order_downloads' ), 10, 4 ); + add_action( 'woocommerce_email_order_details', array( $this, 'order_details' ), 10, 4 ); + add_action( 'woocommerce_email_order_meta', array( $this, 'order_meta' ), 10, 3 ); + add_action( 'woocommerce_email_customer_details', array( $this, 'customer_details' ), 10, 3 ); + add_action( 'woocommerce_email_customer_details', array( $this, 'email_addresses' ), 20, 3 ); + + // Hooks for sending emails during store events. + add_action( 'woocommerce_low_stock_notification', array( $this, 'low_stock' ) ); + add_action( 'woocommerce_no_stock_notification', array( $this, 'no_stock' ) ); + add_action( 'woocommerce_product_on_backorder_notification', array( $this, 'backorder' ) ); + add_action( 'woocommerce_created_customer_notification', array( $this, 'customer_new_account' ), 10, 3 ); + + // Hook for replacing {site_title} in email-footer. + add_filter( 'woocommerce_email_footer_text', array( $this, 'email_footer_replace_site_title' ) ); + + // Let 3rd parties unhook the above via this hook. + do_action( 'woocommerce_email', $this ); + } + + /** + * Init email classes. + */ + public function init() { + // Include email classes. + include_once dirname( __FILE__ ) . '/emails/class-wc-email.php'; + + $this->emails['WC_Email_New_Order'] = include 'emails/class-wc-email-new-order.php'; + $this->emails['WC_Email_Cancelled_Order'] = include 'emails/class-wc-email-cancelled-order.php'; + $this->emails['WC_Email_Failed_Order'] = include 'emails/class-wc-email-failed-order.php'; + $this->emails['WC_Email_Customer_On_Hold_Order'] = include 'emails/class-wc-email-customer-on-hold-order.php'; + $this->emails['WC_Email_Customer_Processing_Order'] = include 'emails/class-wc-email-customer-processing-order.php'; + $this->emails['WC_Email_Customer_Completed_Order'] = include 'emails/class-wc-email-customer-completed-order.php'; + $this->emails['WC_Email_Customer_Refunded_Order'] = include 'emails/class-wc-email-customer-refunded-order.php'; + $this->emails['WC_Email_Customer_Invoice'] = include 'emails/class-wc-email-customer-invoice.php'; + $this->emails['WC_Email_Customer_Note'] = include 'emails/class-wc-email-customer-note.php'; + $this->emails['WC_Email_Customer_Reset_Password'] = include 'emails/class-wc-email-customer-reset-password.php'; + $this->emails['WC_Email_Customer_New_Account'] = include 'emails/class-wc-email-customer-new-account.php'; + + $this->emails = apply_filters( 'woocommerce_email_classes', $this->emails ); + + // include css inliner. + if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { + include_once dirname( __FILE__ ) . '/libraries/class-emogrifier.php'; + } + } + + /** + * Return the email classes - used in admin to load settings. + * + * @return array + */ + public function get_emails() { + return $this->emails; + } + + /** + * Get from name for email. + * + * @return string + */ + public function get_from_name() { + return wp_specialchars_decode( get_option( 'woocommerce_email_from_name' ), ENT_QUOTES ); + } + + /** + * Get from email address. + * + * @return string + */ + public function get_from_address() { + return sanitize_email( get_option( 'woocommerce_email_from_address' ) ); + } + + /** + * Get the email header. + * + * @param mixed $email_heading Heading for the email. + */ + public function email_header( $email_heading ) { + wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) ); + } + + /** + * Get the email footer. + */ + public function email_footer() { + wc_get_template( 'emails/email-footer.php' ); + } + + /** + * Filter callback to replace {site_title} in email footer + * + * @since 3.3.0 + * @param string $string Email footer text. + * @return string Email footer text with any replacements done. + */ + public function email_footer_replace_site_title( $string ) { + return str_replace( '{site_title}', $this->get_blogname(), $string ); + } + + /** + * Wraps a message in the woocommerce mail template. + * + * @param string $email_heading Heading text. + * @param string $message Email message. + * @param bool $plain_text Set true to send as plain text. Default to false. + * + * @return string + */ + public function wrap_message( $email_heading, $message, $plain_text = false ) { + // Buffer. + ob_start(); + + do_action( 'woocommerce_email_header', $email_heading, null ); + + echo wpautop( wptexturize( $message ) ); // WPCS: XSS ok. + + do_action( 'woocommerce_email_footer', null ); + + // Get contents. + $message = ob_get_clean(); + + return $message; + } + + /** + * Send the email. + * + * @param mixed $to Receiver. + * @param mixed $subject Email subject. + * @param mixed $message Message. + * @param string $headers Email headers (default: "Content-Type: text/html\r\n"). + * @param string $attachments Attachments (default: ""). + * @return bool + */ + public function send( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = '' ) { + // Send. + $email = new WC_Email(); + return $email->send( $to, $subject, $message, $headers, $attachments ); + } + + /** + * Prepare and send the customer invoice email on demand. + * + * @param int|WC_Order $order Order instance or ID. + */ + public function customer_invoice( $order ) { + $email = $this->emails['WC_Email_Customer_Invoice']; + + if ( ! is_object( $order ) ) { + $order = wc_get_order( absint( $order ) ); + } + + $email->trigger( $order->get_id(), $order ); + } + + /** + * Customer new account welcome email. + * + * @param int $customer_id Customer ID. + * @param array $new_customer_data New customer data. + * @param bool $password_generated If password is generated. + */ + public function customer_new_account( $customer_id, $new_customer_data = array(), $password_generated = false ) { + if ( ! $customer_id ) { + return; + } + + $user_pass = ! empty( $new_customer_data['user_pass'] ) ? $new_customer_data['user_pass'] : ''; + + $email = $this->emails['WC_Email_Customer_New_Account']; + $email->trigger( $customer_id, $user_pass, $password_generated ); + } + + /** + * Show the order details table + * + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + * @param string $email Email address. + */ + public function order_details( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) { + if ( $plain_text ) { + wc_get_template( + 'emails/plain/email-order-details.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + 'plain_text' => $plain_text, + 'email' => $email, + ) + ); + } else { + wc_get_template( + 'emails/email-order-details.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + 'plain_text' => $plain_text, + 'email' => $email, + ) + ); + } + } + + /** + * Show order downloads in a table. + * + * @since 3.2.0 + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + * @param string $email Email address. + */ + public function order_downloads( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) { + $show_downloads = $order->has_downloadable_item() && $order->is_download_permitted() && ! $sent_to_admin; + + if ( ! $show_downloads ) { + return; + } + + $downloads = $order->get_downloadable_items(); + $columns = apply_filters( + 'woocommerce_email_downloads_columns', array( + 'download-product' => __( 'Product', 'woocommerce' ), + 'download-expires' => __( 'Expires', 'woocommerce' ), + 'download-file' => __( 'Download', 'woocommerce' ), + ) + ); + + if ( $plain_text ) { + wc_get_template( + 'emails/plain/email-downloads.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + 'plain_text' => $plain_text, + 'email' => $email, + 'downloads' => $downloads, + 'columns' => $columns, + ) + ); + } else { + wc_get_template( + 'emails/email-downloads.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + 'plain_text' => $plain_text, + 'email' => $email, + 'downloads' => $downloads, + 'columns' => $columns, + ) + ); + } + } + + /** + * Add order meta to email templates. + * + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + */ + public function order_meta( $order, $sent_to_admin = false, $plain_text = false ) { + $fields = apply_filters( 'woocommerce_email_order_meta_fields', array(), $sent_to_admin, $order ); + + /** + * Deprecated woocommerce_email_order_meta_keys filter. + * + * @since 2.3.0 + */ + $_fields = apply_filters( 'woocommerce_email_order_meta_keys', array(), $sent_to_admin ); + + if ( $_fields ) { + foreach ( $_fields as $key => $field ) { + if ( is_numeric( $key ) ) { + $key = $field; + } + + $fields[ $key ] = array( + 'label' => wptexturize( $key ), + 'value' => wptexturize( get_post_meta( $order->get_id(), $field, true ) ), + ); + } + } + + if ( $fields ) { + + if ( $plain_text ) { + + foreach ( $fields as $field ) { + if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) { + echo $field['label'] . ': ' . $field['value'] . "\n"; // WPCS: XSS ok. + } + } + } else { + + foreach ( $fields as $field ) { + if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) { + echo '

      ' . $field['label'] . ': ' . $field['value'] . '

      '; // WPCS: XSS ok. + } + } + } + } + } + + /** + * Is customer detail field valid? + * + * @param array $field Field data to check if is valid. + * @return boolean + */ + public function customer_detail_field_is_valid( $field ) { + return isset( $field['label'] ) && ! empty( $field['value'] ); + } + + /** + * Allows developers to add additional customer details to templates. + * + * In versions prior to 3.2 this was used for notes, phone and email but this data has moved. + * + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + */ + public function customer_details( $order, $sent_to_admin = false, $plain_text = false ) { + if ( ! is_a( $order, 'WC_Order' ) ) { + return; + } + + $fields = array_filter( apply_filters( 'woocommerce_email_customer_details_fields', array(), $sent_to_admin, $order ), array( $this, 'customer_detail_field_is_valid' ) ); + + if ( ! empty( $fields ) ) { + if ( $plain_text ) { + wc_get_template( 'emails/plain/email-customer-details.php', array( 'fields' => $fields ) ); + } else { + wc_get_template( 'emails/email-customer-details.php', array( 'fields' => $fields ) ); + } + } + } + + /** + * Get the email addresses. + * + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + */ + public function email_addresses( $order, $sent_to_admin = false, $plain_text = false ) { + if ( ! is_a( $order, 'WC_Order' ) ) { + return; + } + if ( $plain_text ) { + wc_get_template( + 'emails/plain/email-addresses.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + ) + ); + } else { + wc_get_template( + 'emails/email-addresses.php', array( + 'order' => $order, + 'sent_to_admin' => $sent_to_admin, + ) + ); + } + } + + /** + * Get blog name formatted for emails. + * + * @return string + */ + private function get_blogname() { + return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + } + + /** + * Low stock notification email. + * + * @param WC_Product $product Product instance. + */ + public function low_stock( $product ) { + if ( 'no' === get_option( 'woocommerce_notify_low_stock', 'yes' ) ) { + return; + } + + $subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product low in stock', 'woocommerce' ) ); + $message = sprintf( + /* translators: 1: product name 2: items in stock */ + __( '%1$s is low in stock. There are %2$d left.', 'woocommerce' ), + html_entity_decode( strip_tags( $product->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ), + html_entity_decode( strip_tags( $product->get_stock_quantity() ) ) + ); + + wp_mail( + apply_filters( 'woocommerce_email_recipient_low_stock', get_option( 'woocommerce_stock_email_recipient' ), $product ), + apply_filters( 'woocommerce_email_subject_low_stock', $subject, $product ), + apply_filters( 'woocommerce_email_content_low_stock', $message, $product ), + apply_filters( 'woocommerce_email_headers', '', 'low_stock', $product ), + apply_filters( 'woocommerce_email_attachments', array(), 'low_stock', $product ) + ); + } + + /** + * No stock notification email. + * + * @param WC_Product $product Product instance. + */ + public function no_stock( $product ) { + if ( 'no' === get_option( 'woocommerce_notify_no_stock', 'yes' ) ) { + return; + } + + $subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product out of stock', 'woocommerce' ) ); + /* translators: %s: product name */ + $message = sprintf( __( '%s is out of stock.', 'woocommerce' ), html_entity_decode( strip_tags( $product->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ) ); + + wp_mail( + apply_filters( 'woocommerce_email_recipient_no_stock', get_option( 'woocommerce_stock_email_recipient' ), $product ), + apply_filters( 'woocommerce_email_subject_no_stock', $subject, $product ), + apply_filters( 'woocommerce_email_content_no_stock', $message, $product ), + apply_filters( 'woocommerce_email_headers', '', 'no_stock', $product ), + apply_filters( 'woocommerce_email_attachments', array(), 'no_stock', $product ) + ); + } + + /** + * Backorder notification email. + * + * @param array $args Arguments. + */ + public function backorder( $args ) { + $args = wp_parse_args( + $args, array( + 'product' => '', + 'quantity' => '', + 'order_id' => '', + ) + ); + + $order = wc_get_order( $args['order_id'] ); + if ( + ! $args['product'] || + ! is_object( $args['product'] ) || + ! $args['quantity'] || + ! $order + ) { + return; + } + + $subject = sprintf( '[%s] %s', $this->get_blogname(), __( 'Product backorder', 'woocommerce' ) ); + /* translators: 1: product quantity 2: product name 3: order number */ + $message = sprintf( __( '%1$s units of %2$s have been backordered in order #%3$s.', 'woocommerce' ), $args['quantity'], html_entity_decode( strip_tags( $args['product']->get_formatted_name() ), ENT_QUOTES, get_bloginfo( 'charset' ) ), $order->get_order_number() ); + + wp_mail( + apply_filters( 'woocommerce_email_recipient_backorder', get_option( 'woocommerce_stock_email_recipient' ), $args ), + apply_filters( 'woocommerce_email_subject_backorder', $subject, $args ), + apply_filters( 'woocommerce_email_content_backorder', $message, $args ), + apply_filters( 'woocommerce_email_headers', '', 'backorder', $args ), + apply_filters( 'woocommerce_email_attachments', array(), 'backorder', $args ) + ); + } + + /** + * Adds Schema.org markup for order in JSON-LD format. + * + * @deprecated 3.0.0 + * @see WC_Structured_Data::generate_order_data() + * + * @since 2.6.0 + * @param WC_Order $order Order instance. + * @param bool $sent_to_admin If should sent to admin. + * @param bool $plain_text If is plain text email. + */ + public function order_schema_markup( $order, $sent_to_admin = false, $plain_text = false ) { + wc_deprecated_function( 'WC_Emails::order_schema_markup', '3.0', 'WC_Structured_Data::generate_order_data' ); + + WC()->structured_data->generate_order_data( $order, $sent_to_admin, $plain_text ); + WC()->structured_data->output_structured_data(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-embed.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-embed.php new file mode 100644 index 0000000..296e89c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-embed.php @@ -0,0 +1,178 @@ +' . $_product->get_price_html() . '

      '; // WPCS: XSS ok. + + if ( ! empty( $post->post_excerpt ) ) { + ob_start(); + woocommerce_template_single_excerpt(); + $excerpt = ob_get_clean(); + } + + // Add the button. + $excerpt .= self::product_buttons(); + } + return $excerpt; + } + + /** + * Create the button to go to the product page for embedded products. + * + * @since 2.4.11 + * @return string + */ + public static function product_buttons() { + $_product = wc_get_product( get_the_ID() ); + $buttons = array(); + $button = '%s'; + + if ( $_product->is_type( 'simple' ) && $_product->is_purchasable() && $_product->is_in_stock() ) { + $buttons[] = sprintf( $button, esc_url( add_query_arg( 'add-to-cart', get_the_ID(), wc_get_cart_url() ) ), esc_html__( 'Buy now', 'woocommerce' ) ); + } + + $buttons[] = sprintf( $button, get_the_permalink(), esc_html__( 'Read more', 'woocommerce' ) ); + + return '

      ' . implode( ' ', $buttons ) . '

      '; + } + + /** + * Prints the markup for the rating stars. + * + * @since 2.4.11 + */ + public static function get_ratings() { + // Make sure we're only affecting embedded products. + if ( ! self::is_embedded_product() ) { + return; + } + + $_product = wc_get_product( get_the_ID() ); + + if ( $_product && $_product->get_average_rating() > 0 ) { + ?> +
      + get_average_rating() ) + ); + ?> +
      + + + user_login : ''; + } + + $value = sprintf( '%s:%s', wp_unslash( $user_login ), wp_unslash( $_GET['key'] ) ); + WC_Shortcode_My_Account::set_reset_password_cookie( $value ); + wp_safe_redirect( add_query_arg( 'show-reset-form', 'true', wc_lostpassword_url() ) ); + exit; + } + } + + /** + * Save and and update a billing or shipping address if the + * form was submitted through the user account page. + */ + public static function save_address() { + global $wp; + + if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { + return; + } + + if ( empty( $_POST['action'] ) || 'edit_address' !== $_POST['action'] ) { + return; + } + + wc_nocache_headers(); + + $nonce_value = wc_get_var( $_REQUEST['woocommerce-edit-address-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-edit_address' ) ) { + return; + } + + $user_id = get_current_user_id(); + + if ( $user_id <= 0 ) { + return; + } + + $load_address = isset( $wp->query_vars['edit-address'] ) ? wc_edit_address_i18n( sanitize_title( $wp->query_vars['edit-address'] ), true ) : 'billing'; + + $address = WC()->countries->get_address_fields( esc_attr( $_POST[ $load_address . '_country' ] ), $load_address . '_' ); + + foreach ( $address as $key => $field ) { + + if ( ! isset( $field['type'] ) ) { + $field['type'] = 'text'; + } + + // Get Value. + switch ( $field['type'] ) { + case 'checkbox' : + $_POST[ $key ] = (int) isset( $_POST[ $key ] ); + break; + default : + $_POST[ $key ] = isset( $_POST[ $key ] ) ? wc_clean( $_POST[ $key ] ) : ''; + break; + } + + // Hook to allow modification of value. + $_POST[ $key ] = apply_filters( 'woocommerce_process_myaccount_field_' . $key, $_POST[ $key ] ); + + // Validation: Required fields. + if ( ! empty( $field['required'] ) && empty( $_POST[ $key ] ) ) { + wc_add_notice( sprintf( __( '%s is a required field.', 'woocommerce' ), $field['label'] ), 'error' ); + } + + if ( ! empty( $_POST[ $key ] ) ) { + + // Validation rules. + if ( ! empty( $field['validate'] ) && is_array( $field['validate'] ) ) { + foreach ( $field['validate'] as $rule ) { + switch ( $rule ) { + case 'postcode' : + $_POST[ $key ] = strtoupper( str_replace( ' ', '', $_POST[ $key ] ) ); + + if ( ! WC_Validation::is_postcode( $_POST[ $key ], $_POST[ $load_address . '_country' ] ) ) { + wc_add_notice( __( 'Please enter a valid postcode / ZIP.', 'woocommerce' ), 'error' ); + } else { + $_POST[ $key ] = wc_format_postcode( $_POST[ $key ], $_POST[ $load_address . '_country' ] ); + } + break; + case 'phone' : + $_POST[ $key ] = wc_format_phone_number( $_POST[ $key ] ); + + if ( ! WC_Validation::is_phone( $_POST[ $key ] ) ) { + wc_add_notice( sprintf( __( '%s is not a valid phone number.', 'woocommerce' ), '' . $field['label'] . '' ), 'error' ); + } + break; + case 'email' : + $_POST[ $key ] = strtolower( $_POST[ $key ] ); + + if ( ! is_email( $_POST[ $key ] ) ) { + wc_add_notice( sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '' . $field['label'] . '' ), 'error' ); + } + break; + } + } + } + } + } + + do_action( 'woocommerce_after_save_address_validation', $user_id, $load_address, $address ); + + if ( 0 === wc_notice_count( 'error' ) ) { + + $customer = new WC_Customer( $user_id ); + + if ( $customer ) { + foreach ( $address as $key => $field ) { + if ( is_callable( array( $customer, "set_$key" ) ) ) { + $customer->{"set_$key"}( wc_clean( $_POST[ $key ] ) ); + } else { + $customer->update_meta_data( $key, wc_clean( $_POST[ $key ] ) ); + } + + if ( WC()->customer && is_callable( array( WC()->customer, "set_$key" ) ) ) { + WC()->customer->{"set_$key"}( wc_clean( $_POST[ $key ] ) ); + } + } + $customer->save(); + } + + wc_add_notice( __( 'Address changed successfully.', 'woocommerce' ) ); + + do_action( 'woocommerce_customer_save_address', $user_id, $load_address ); + + wp_safe_redirect( wc_get_endpoint_url( 'edit-address', '', wc_get_page_permalink( 'myaccount' ) ) ); + exit; + } + } + + /** + * Save the password/account details and redirect back to the my account page. + */ + public static function save_account_details() { + if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { + return; + } + + if ( empty( $_POST['action'] ) || 'save_account_details' !== $_POST['action'] ) { + return; + } + + wc_nocache_headers(); + + $nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) { + return; + } + + $user_id = get_current_user_id(); + + if ( $user_id <= 0 ) { + return; + } + + $account_first_name = ! empty( $_POST['account_first_name'] ) ? wc_clean( $_POST['account_first_name'] ): ''; + $account_last_name = ! empty( $_POST['account_last_name'] ) ? wc_clean( $_POST['account_last_name'] ) : ''; + $account_display_name = ! empty( $_POST['account_display_name'] ) ? wc_clean( $_POST['account_display_name'] ) : ''; + $account_email = ! empty( $_POST['account_email'] ) ? wc_clean( $_POST['account_email'] ) : ''; + $pass_cur = ! empty( $_POST['password_current'] ) ? $_POST['password_current'] : ''; + $pass1 = ! empty( $_POST['password_1'] ) ? $_POST['password_1'] : ''; + $pass2 = ! empty( $_POST['password_2'] ) ? $_POST['password_2'] : ''; + $save_pass = true; + + // Current user data. + $current_user = get_user_by( 'id', $user_id ); + $current_first_name = $current_user->first_name; + $current_last_name = $current_user->last_name; + $current_email = $current_user->user_email; + + // New user data. + $user = new stdClass(); + $user->ID = $user_id; + $user->first_name = $account_first_name; + $user->last_name = $account_last_name; + $user->display_name = $account_display_name; + + // Prevent display name to be changed to email. + if ( is_email( $account_display_name ) ) { + wc_add_notice( __( 'Display name cannot be changed to email address due to privacy concern.', 'woocommerce' ), 'error' ); + } + + // Handle required fields. + $required_fields = apply_filters( 'woocommerce_save_account_details_required_fields', array( + 'account_first_name' => __( 'First name', 'woocommerce' ), + 'account_last_name' => __( 'Last name', 'woocommerce' ), + 'account_display_name' => __( 'Display name', 'woocommerce' ), + 'account_email' => __( 'Email address', 'woocommerce' ), + ) ); + + foreach ( $required_fields as $field_key => $field_name ) { + if ( empty( $_POST[ $field_key ] ) ) { + wc_add_notice( sprintf( __( '%s is a required field.', 'woocommerce' ), '' . esc_html( $field_name ) . '' ), 'error' ); + } + } + + if ( $account_email ) { + $account_email = sanitize_email( $account_email ); + if ( ! is_email( $account_email ) ) { + wc_add_notice( __( 'Please provide a valid email address.', 'woocommerce' ), 'error' ); + } elseif ( email_exists( $account_email ) && $account_email !== $current_user->user_email ) { + wc_add_notice( __( 'This email address is already registered.', 'woocommerce' ), 'error' ); + } + $user->user_email = $account_email; + } + + if ( ! empty( $pass_cur ) && empty( $pass1 ) && empty( $pass2 ) ) { + wc_add_notice( __( 'Please fill out all password fields.', 'woocommerce' ), 'error' ); + $save_pass = false; + } elseif ( ! empty( $pass1 ) && empty( $pass_cur ) ) { + wc_add_notice( __( 'Please enter your current password.', 'woocommerce' ), 'error' ); + $save_pass = false; + } elseif ( ! empty( $pass1 ) && empty( $pass2 ) ) { + wc_add_notice( __( 'Please re-enter your password.', 'woocommerce' ), 'error' ); + $save_pass = false; + } elseif ( ( ! empty( $pass1 ) || ! empty( $pass2 ) ) && $pass1 !== $pass2 ) { + wc_add_notice( __( 'New passwords do not match.', 'woocommerce' ), 'error' ); + $save_pass = false; + } elseif ( ! empty( $pass1 ) && ! wp_check_password( $pass_cur, $current_user->user_pass, $current_user->ID ) ) { + wc_add_notice( __( 'Your current password is incorrect.', 'woocommerce' ), 'error' ); + $save_pass = false; + } + + if ( $pass1 && $save_pass ) { + $user->user_pass = $pass1; + } + + // Allow plugins to return their own errors. + $errors = new WP_Error(); + do_action_ref_array( 'woocommerce_save_account_details_errors', array( &$errors, &$user ) ); + + if ( $errors->get_error_messages() ) { + foreach ( $errors->get_error_messages() as $error ) { + wc_add_notice( $error, 'error' ); + } + } + + if ( wc_notice_count( 'error' ) === 0 ) { + wp_update_user( $user ); + + // Update customer object to keep data in sync. + $customer = new WC_Customer( $user->ID ); + + if ( $customer ) { + // Keep billing data in sync if data changed. + if ( is_email( $user->user_email ) && $current_email !== $user->user_email ) { + $customer->set_billing_email( $user->user_email ); + } + + if ( $current_first_name !== $user->first_name ) { + $customer->set_billing_first_name( $user->first_name ); + } + + if ( $current_last_name !== $user->last_name ) { + $customer->set_billing_last_name( $user->last_name ); + } + + $customer->save(); + } + + wc_add_notice( __( 'Account details changed successfully.', 'woocommerce' ) ); + + do_action( 'woocommerce_save_account_details', $user->ID ); + + wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) ); + exit; + } + } + + /** + * Process the checkout form. + */ + public static function checkout_action() { + if ( isset( $_POST['woocommerce_checkout_place_order'] ) || isset( $_POST['woocommerce_checkout_update_totals'] ) ) { + wc_nocache_headers(); + + if ( WC()->cart->is_empty() ) { + wp_redirect( wc_get_page_permalink( 'cart' ) ); + exit; + } + + wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true ); + + WC()->checkout()->process_checkout(); + } + } + + /** + * Process the pay form. + */ + public static function pay_action() { + global $wp; + + if ( isset( $_POST['woocommerce_pay'] ) ) { + wc_nocache_headers(); + + $nonce_value = wc_get_var( $_REQUEST['woocommerce-pay-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-pay' ) ) { + return; + } + + ob_start(); + + // Pay for existing order + $order_key = $_GET['key']; + $order_id = absint( $wp->query_vars['order-pay'] ); + $order = wc_get_order( $order_id ); + + if ( $order_id === $order->get_id() && $order_key === $order->get_order_key() && $order->needs_payment() ) { + + do_action( 'woocommerce_before_pay_action', $order ); + + WC()->customer->set_props( array( + 'billing_country' => $order->get_billing_country() ? $order->get_billing_country() : null, + 'billing_state' => $order->get_billing_state() ? $order->get_billing_state() : null, + 'billing_postcode' => $order->get_billing_postcode() ? $order->get_billing_postcode() : null, + 'billing_city' => $order->get_billing_city() ? $order->get_billing_city() : null, + ) ); + WC()->customer->save(); + + // Terms + if ( ! empty( $_POST['terms-field'] ) && empty( $_POST['terms'] ) ) { + wc_add_notice( __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ), 'error' ); + return; + } + + // Update payment method + if ( $order->needs_payment() ) { + $payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : false; + $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); + + if ( ! $payment_method ) { + wc_add_notice( __( 'Invalid payment method.', 'woocommerce' ), 'error' ); + return; + } + + // Update meta + update_post_meta( $order_id, '_payment_method', $payment_method ); + + if ( isset( $available_gateways[ $payment_method ] ) ) { + $payment_method_title = $available_gateways[ $payment_method ]->get_title(); + } else { + $payment_method_title = ''; + } + + update_post_meta( $order_id, '_payment_method_title', $payment_method_title ); + + // Validate + $available_gateways[ $payment_method ]->validate_fields(); + + // Process + if ( 0 === wc_notice_count( 'error' ) ) { + + $result = $available_gateways[ $payment_method ]->process_payment( $order_id ); + + // Redirect to success/confirmation/payment page + if ( 'success' === $result['result'] ) { + wp_redirect( $result['redirect'] ); + exit; + } + } + } else { + // No payment was required for order + $order->payment_complete(); + wp_safe_redirect( $order->get_checkout_order_received_url() ); + exit; + } + + do_action( 'woocommerce_after_pay_action', $order ); + + } + } + } + + /** + * Process the add payment method form. + */ + public static function add_payment_method_action() { + if ( isset( $_POST['woocommerce_add_payment_method'], $_POST['payment_method'] ) ) { + wc_nocache_headers(); + + $nonce_value = wc_get_var( $_REQUEST['woocommerce-add-payment-method-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'woocommerce-add-payment-method' ) ) { + return; + } + + ob_start(); + + $payment_method_id = wc_clean( wp_unslash( $_POST['payment_method'] ) ); + $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); + + if ( isset( $available_gateways[ $payment_method_id ] ) ) { + $gateway = $available_gateways[ $payment_method_id ]; + + if ( ! $gateway->supports( 'add_payment_method' ) && ! $gateway->supports( 'tokenization' ) ) { + wc_add_notice( __( 'Invalid payment gateway.', 'woocommerce' ), 'error' ); + return; + } + + $gateway->validate_fields(); + + if ( wc_notice_count( 'error' ) > 0 ) { + return; + } + + $result = $gateway->add_payment_method(); + + if ( 'success' === $result['result'] ) { + wc_add_notice( __( 'Payment method successfully added.', 'woocommerce' ) ); + } + + if ( 'failure' === $result['result'] ) { + wc_add_notice( __( 'Unable to add payment method to your account.', 'woocommerce' ), 'error' ); + } + + if ( ! empty( $result['redirect'] ) ) { + wp_redirect( $result['redirect'] ); + exit(); + } + } + } + } + + /** + * Process the delete payment method form. + */ + public static function delete_payment_method_action() { + global $wp; + + if ( isset( $wp->query_vars['delete-payment-method'] ) ) { + wc_nocache_headers(); + + $token_id = absint( $wp->query_vars['delete-payment-method'] ); + $token = WC_Payment_Tokens::get( $token_id ); + + if ( is_null( $token ) || get_current_user_id() !== $token->get_user_id() || false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'delete-payment-method-' . $token_id ) ) { + wc_add_notice( __( 'Invalid payment method.', 'woocommerce' ), 'error' ); + } else { + WC_Payment_Tokens::delete( $token_id ); + wc_add_notice( __( 'Payment method deleted.', 'woocommerce' ) ); + } + + wp_redirect( wc_get_account_endpoint_url( 'payment-methods' ) ); + exit(); + } + + } + + /** + * Process the delete payment method form. + */ + public static function set_default_payment_method_action() { + global $wp; + + if ( isset( $wp->query_vars['set-default-payment-method'] ) ) { + wc_nocache_headers(); + + $token_id = absint( $wp->query_vars['set-default-payment-method'] ); + $token = WC_Payment_Tokens::get( $token_id ); + + if ( is_null( $token ) || get_current_user_id() !== $token->get_user_id() || false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'set-default-payment-method-' . $token_id ) ) { + wc_add_notice( __( 'Invalid payment method.', 'woocommerce' ), 'error' ); + } else { + WC_Payment_Tokens::set_users_default( $token->get_user_id(), intval( $token_id ) ); + wc_add_notice( __( 'This payment method was successfully set as your default.', 'woocommerce' ) ); + } + + wp_redirect( wc_get_account_endpoint_url( 'payment-methods' ) ); + exit(); + } + + } + + /** + * Remove from cart/update. + */ + public static function update_cart_action() { + if ( ! ( isset( $_REQUEST['apply_coupon'] ) || isset( $_REQUEST['remove_coupon'] ) || isset( $_REQUEST['remove_item'] ) || isset( $_REQUEST['undo_item'] ) || isset( $_REQUEST['update_cart'] ) || isset( $_REQUEST['proceed'] ) ) ) { + return; + } + + wc_nocache_headers(); + + $nonce_value = wc_get_var( $_REQUEST['woocommerce-cart-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! empty( $_POST['apply_coupon'] ) && ! empty( $_POST['coupon_code'] ) ) { + WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) ); + + } elseif ( isset( $_GET['remove_coupon'] ) ) { + WC()->cart->remove_coupon( wc_clean( wp_unslash( $_GET['remove_coupon'] ) ) ); + + } elseif ( ! empty( $_GET['remove_item'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) ) { + $cart_item_key = sanitize_text_field( wp_unslash( $_GET['remove_item'] ) ); + $cart_item = WC()->cart->get_cart_item( $cart_item_key ); + + if ( $cart_item ) { + WC()->cart->remove_cart_item( $cart_item_key ); + + $product = wc_get_product( $cart_item['product_id'] ); + + $item_removed_title = apply_filters( 'woocommerce_cart_item_removed_title', $product ? sprintf( _x( '“%s”', 'Item name in quotes', 'woocommerce' ), $product->get_name() ) : __( 'Item', 'woocommerce' ), $cart_item ); + + // Don't show undo link if removed item is out of stock. + if ( $product && $product->is_in_stock() && $product->has_enough_stock( $cart_item['quantity'] ) ) { + /* Translators: %s Product title. */ + $removed_notice = sprintf( __( '%s removed.', 'woocommerce' ), $item_removed_title ); + $removed_notice .= ' ' . __( 'Undo?', 'woocommerce' ) . ''; + } else { + /* Translators: %s Product title. */ + $removed_notice = sprintf( __( '%s removed.', 'woocommerce' ), $item_removed_title ); + } + + wc_add_notice( $removed_notice ); + } + + $referer = wp_get_referer() ? remove_query_arg( array( 'remove_item', 'add-to-cart', 'added-to-cart' ), add_query_arg( 'removed_item', '1', wp_get_referer() ) ) : wc_get_cart_url(); + wp_safe_redirect( $referer ); + exit; + + } elseif ( ! empty( $_GET['undo_item'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) ) { + + // Undo Cart Item. + $cart_item_key = sanitize_text_field( wp_unslash( $_GET['undo_item'] ) ); + + WC()->cart->restore_cart_item( $cart_item_key ); + + $referer = wp_get_referer() ? remove_query_arg( array( 'undo_item', '_wpnonce' ), wp_get_referer() ) : wc_get_cart_url(); + wp_safe_redirect( $referer ); + exit; + + } + + // Update Cart - checks apply_coupon too because they are in the same form. + if ( ( ! empty( $_POST['apply_coupon'] ) || ! empty( $_POST['update_cart'] ) || ! empty( $_POST['proceed'] ) ) && wp_verify_nonce( $nonce_value, 'woocommerce-cart' ) ) { + + $cart_updated = false; + $cart_totals = isset( $_POST['cart'] ) ? wp_unslash( $_POST['cart'] ) : ''; // PHPCS: input var ok, CSRF ok, sanitization ok. + + if ( ! WC()->cart->is_empty() && is_array( $cart_totals ) ) { + foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { + + $_product = $values['data']; + + // Skip product if no updated quantity was posted. + if ( ! isset( $cart_totals[ $cart_item_key ] ) || ! isset( $cart_totals[ $cart_item_key ]['qty'] ) ) { + continue; + } + + // Sanitize. + $quantity = apply_filters( 'woocommerce_stock_amount_cart_item', wc_stock_amount( preg_replace( '/[^0-9\.]/', '', $cart_totals[ $cart_item_key ]['qty'] ) ), $cart_item_key ); + + if ( '' === $quantity || $quantity === $values['quantity'] ) { + continue; + } + + // Update cart validation. + $passed_validation = apply_filters( 'woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity ); + + // is_sold_individually. + if ( $_product->is_sold_individually() && $quantity > 1 ) { + /* Translators: %s Product title. */ + wc_add_notice( sprintf( __( 'You can only have 1 %s in your cart.', 'woocommerce' ), $_product->get_name() ), 'error' ); + $passed_validation = false; + } + + if ( $passed_validation ) { + WC()->cart->set_quantity( $cart_item_key, $quantity, false ); + $cart_updated = true; + } + } + } + + // Trigger action - let 3rd parties update the cart if they need to and update the $cart_updated variable. + $cart_updated = apply_filters( 'woocommerce_update_cart_action_cart_updated', $cart_updated ); + + if ( $cart_updated ) { + WC()->cart->calculate_totals(); + } + + if ( ! empty( $_POST['proceed'] ) ) { + wp_safe_redirect( wc_get_checkout_url() ); + exit; + } elseif ( $cart_updated ) { + wc_add_notice( __( 'Cart updated.', 'woocommerce' ) ); + $referer = remove_query_arg( array( 'remove_coupon', 'add-to-cart' ), ( wp_get_referer() ? wp_get_referer() : wc_get_cart_url() ) ); + wp_safe_redirect( $referer ); + exit; + } + } + } + + /** + * Place a previous order again. + */ + public static function order_again() { + // Nothing to do + if ( ! isset( $_GET['order_again'] ) || ! is_user_logged_in() || ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'woocommerce-order_again' ) ) { + return; + } + + wc_nocache_headers(); + + if ( apply_filters( 'woocommerce_empty_cart_when_order_again', true ) ) { + WC()->cart->empty_cart(); + } + + // Load the previous order - Stop if the order does not exist + $order = wc_get_order( absint( $_GET['order_again'] ) ); + + if ( ! $order->get_id() ) { + return; + } + + if ( ! $order->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_order_again', array( 'completed' ) ) ) ) { + return; + } + + // Make sure the user is allowed to order again. By default it check if the + // previous order belonged to the current user. + if ( ! current_user_can( 'order_again', $order->get_id() ) ) { + return; + } + + // Copy products from the order to the cart + $order_items = $order->get_items(); + foreach ( $order_items as $item ) { + // Load all product info including variation data + $product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $item->get_product_id() ); + $quantity = $item->get_quantity(); + $variation_id = $item->get_variation_id(); + $variations = array(); + $cart_item_data = apply_filters( 'woocommerce_order_again_cart_item_data', array(), $item, $order ); + + foreach ( $item->get_meta_data() as $meta ) { + if ( taxonomy_is_product_attribute( $meta->key ) ) { + $term = get_term_by( 'slug', $meta->value, $meta->key ); + $variations[ $meta->key ] = $term ? $term->name : $meta->value; + } elseif ( meta_is_product_attribute( $meta->key, $meta->value, $product_id ) ) { + $variations[ $meta->key ] = $meta->value; + } + } + + // Prevent reordering variable products if no selected variation. + if ( ! $variation_id && ( $product = $item->get_product() ) && $product->is_type( 'variable' ) ) { + continue; + } + + // Add to cart validation + if ( ! apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity, $variation_id, $variations, $cart_item_data ) ) { + continue; + } + + WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations, $cart_item_data ); + } + + do_action( 'woocommerce_ordered_again', $order->get_id() ); + + $num_items_in_cart = count( WC()->cart->get_cart() ); + $num_items_in_original_order = count( $order_items ); + + if ( $num_items_in_original_order > $num_items_in_cart ) { + wc_add_notice( + sprintf( _n( + '%d item from your previous order is currently unavailable and could not be added to your cart.', + '%d items from your previous order are currently unavailable and could not be added to your cart.', + $num_items_in_original_order - $num_items_in_cart, + 'woocommerce' + ), $num_items_in_original_order - $num_items_in_cart ), + 'error' + ); + } + + if ( $num_items_in_cart > 0 ) { + wc_add_notice( __( 'The cart has been filled with the items from your previous order.', 'woocommerce' ) ); + } + + // Redirect to cart + wp_safe_redirect( wc_get_cart_url() ); + exit; + } + + /** + * Cancel a pending order. + */ + public static function cancel_order() { + if ( + isset( $_GET['cancel_order'] ) && + isset( $_GET['order'] ) && + isset( $_GET['order_id'] ) && + ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'woocommerce-cancel_order' ) ) + ) { + wc_nocache_headers(); + + $order_key = $_GET['order']; + $order_id = absint( $_GET['order_id'] ); + $order = wc_get_order( $order_id ); + $user_can_cancel = current_user_can( 'cancel_order', $order_id ); + $order_can_cancel = $order->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ) ) ); + $redirect = $_GET['redirect']; + + if ( $order->has_status( 'cancelled' ) ) { + // Already cancelled - take no action + } elseif ( $user_can_cancel && $order_can_cancel && $order->get_id() === $order_id && $order->get_order_key() === $order_key ) { + + // Cancel the order + restore stock + WC()->session->set( 'order_awaiting_payment', false ); + $order->update_status( 'cancelled', __( 'Order cancelled by customer.', 'woocommerce' ) ); + + // Message + wc_add_notice( apply_filters( 'woocommerce_order_cancelled_notice', __( 'Your order was cancelled.', 'woocommerce' ) ), apply_filters( 'woocommerce_order_cancelled_notice_type', 'notice' ) ); + + do_action( 'woocommerce_cancelled_order', $order->get_id() ); + + } elseif ( $user_can_cancel && ! $order_can_cancel ) { + wc_add_notice( __( 'Your order can no longer be cancelled. Please contact us if you need assistance.', 'woocommerce' ), 'error' ); + } else { + wc_add_notice( __( 'Invalid order.', 'woocommerce' ), 'error' ); + } + + if ( $redirect ) { + wp_safe_redirect( $redirect ); + exit; + } + } + } + + /** + * Add to cart action. + * + * Checks for a valid request, does validation (via hooks) and then redirects if valid. + * + * @param bool $url (default: false) + */ + public static function add_to_cart_action( $url = false ) { + if ( empty( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) { + return; + } + + wc_nocache_headers(); + + $product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) ); + $was_added_to_cart = false; + $adding_to_cart = wc_get_product( $product_id ); + + if ( ! $adding_to_cart ) { + return; + } + + $add_to_cart_handler = apply_filters( 'woocommerce_add_to_cart_handler', $adding_to_cart->get_type(), $adding_to_cart ); + + if ( 'variable' === $add_to_cart_handler || 'variation' === $add_to_cart_handler ) { + $was_added_to_cart = self::add_to_cart_handler_variable( $product_id ); + } elseif ( 'grouped' === $add_to_cart_handler ) { + $was_added_to_cart = self::add_to_cart_handler_grouped( $product_id ); + } elseif ( has_action( 'woocommerce_add_to_cart_handler_' . $add_to_cart_handler ) ) { + do_action( 'woocommerce_add_to_cart_handler_' . $add_to_cart_handler, $url ); // Custom handler. + } else { + $was_added_to_cart = self::add_to_cart_handler_simple( $product_id ); + } + + // If we added the product to the cart we can now optionally do a redirect. + if ( $was_added_to_cart && 0 === wc_notice_count( 'error' ) ) { + if ( $url = apply_filters( 'woocommerce_add_to_cart_redirect', $url ) ) { + wp_safe_redirect( $url ); + exit; + } elseif ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { + wp_safe_redirect( wc_get_cart_url() ); + exit; + } + } + } + + /** + * Handle adding simple products to the cart. + * + * @since 2.4.6 Split from add_to_cart_action. + * @param int $product_id Product ID to add to the cart. + * @return bool success or not + */ + private static function add_to_cart_handler_simple( $product_id ) { + $quantity = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( $_REQUEST['quantity'] ); + $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity ); + + if ( $passed_validation && false !== WC()->cart->add_to_cart( $product_id, $quantity ) ) { + wc_add_to_cart_message( array( $product_id => $quantity ), true ); + return true; + } + return false; + } + + /** + * Handle adding grouped products to the cart. + * + * @since 2.4.6 Split from add_to_cart_action. + * @param int $product_id Product ID to add to the cart. + * @return bool success or not + */ + private static function add_to_cart_handler_grouped( $product_id ) { + $was_added_to_cart = false; + $added_to_cart = array(); + + if ( ! empty( $_REQUEST['quantity'] ) && is_array( $_REQUEST['quantity'] ) ) { + $quantity_set = false; + + foreach ( $_REQUEST['quantity'] as $item => $quantity ) { + if ( $quantity <= 0 ) { + continue; + } + $quantity_set = true; + + // Add to cart validation + $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $item, $quantity ); + + // Suppress total recalculation until finished. + remove_action( 'woocommerce_add_to_cart', array( WC()->cart, 'calculate_totals' ), 20, 0 ); + + if ( $passed_validation && false !== WC()->cart->add_to_cart( $item, $quantity ) ) { + $was_added_to_cart = true; + $added_to_cart[ $item ] = $quantity; + } + + add_action( 'woocommerce_add_to_cart', array( WC()->cart, 'calculate_totals' ), 20, 0 ); + } + + if ( ! $was_added_to_cart && ! $quantity_set ) { + wc_add_notice( __( 'Please choose the quantity of items you wish to add to your cart…', 'woocommerce' ), 'error' ); + } elseif ( $was_added_to_cart ) { + wc_add_to_cart_message( $added_to_cart ); + WC()->cart->calculate_totals(); + return true; + } + } elseif ( $product_id ) { + /* Link on product archives */ + wc_add_notice( __( 'Please choose a product to add to your cart…', 'woocommerce' ), 'error' ); + } + return false; + } + + /** + * Handle adding variable products to the cart. + * + * @since 2.4.6 Split from add_to_cart_action. + * @param int $product_id Product ID to add to the cart. + * @return bool success or not + */ + private static function add_to_cart_handler_variable( $product_id ) { + try { + $variation_id = empty( $_REQUEST['variation_id'] ) ? '' : absint( wp_unslash( $_REQUEST['variation_id'] ) ); + $quantity = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( wp_unslash( $_REQUEST['quantity'] ) ); // WPCS: sanitization ok. + $missing_attributes = array(); + $variations = array(); + $adding_to_cart = wc_get_product( $product_id ); + + if ( ! $adding_to_cart ) { + return false; + } + + // If the $product_id was in fact a variation ID, update the variables. + if ( $adding_to_cart->is_type( 'variation' ) ) { + $variation_id = $product_id; + $product_id = $adding_to_cart->get_parent_id(); + $adding_to_cart = wc_get_product( $product_id ); + + if ( ! $adding_to_cart ) { + return false; + } + } + + // Gather posted attributes. + $posted_attributes = array(); + + foreach ( $adding_to_cart->get_attributes() as $attribute ) { + if ( ! $attribute['is_variation'] ) { + continue; + } + $attribute_key = 'attribute_' . sanitize_title( $attribute['name'] ); + + if ( isset( $_REQUEST[ $attribute_key ] ) ) { + if ( $attribute['is_taxonomy'] ) { + // Don't use wc_clean as it destroys sanitized characters. + $value = sanitize_title( wp_unslash( $_REQUEST[ $attribute_key ] ) ); + } else { + $value = html_entity_decode( wc_clean( wp_unslash( $_REQUEST[ $attribute_key ] ) ), ENT_QUOTES, get_bloginfo( 'charset' ) ); // WPCS: sanitization ok. + } + + $posted_attributes[ $attribute_key ] = $value; + } + } + + // If no variation ID is set, attempt to get a variation ID from posted attributes. + if ( empty( $variation_id ) ) { + $data_store = WC_Data_Store::load( 'product' ); + $variation_id = $data_store->find_matching_product_variation( $adding_to_cart, $posted_attributes ); + } + + // Do we have a variation ID? + if ( empty( $variation_id ) ) { + throw new Exception( __( 'Please choose product options…', 'woocommerce' ) ); + } + + // Check the data we have is valid. + $variation_data = wc_get_product_variation_attributes( $variation_id ); + + foreach ( $adding_to_cart->get_attributes() as $attribute ) { + if ( ! $attribute['is_variation'] ) { + continue; + } + + // Get valid value from variation data. + $attribute_key = 'attribute_' . sanitize_title( $attribute['name'] ); + $valid_value = isset( $variation_data[ $attribute_key ] ) ? $variation_data[ $attribute_key ]: ''; + + /** + * If the attribute value was posted, check if it's valid. + * + * If no attribute was posted, only error if the variation has an 'any' attribute which requires a value. + */ + if ( isset( $posted_attributes[ $attribute_key ] ) ) { + $value = $posted_attributes[ $attribute_key ]; + + // Allow if valid or show error. + if ( $valid_value === $value ) { + $variations[ $attribute_key ] = $value; + } elseif ( '' === $valid_value && in_array( $value, $attribute->get_slugs() ) ) { + // If valid values are empty, this is an 'any' variation so get all possible values. + $variations[ $attribute_key ] = $value; + } else { + throw new Exception( sprintf( __( 'Invalid value posted for %s', 'woocommerce' ), wc_attribute_label( $attribute['name'] ) ) ); + } + } elseif ( '' === $valid_value ) { + $missing_attributes[] = wc_attribute_label( $attribute['name'] ); + } + } + if ( ! empty( $missing_attributes ) ) { + throw new Exception( sprintf( _n( '%s is a required field', '%s are required fields', count( $missing_attributes ), 'woocommerce' ), wc_format_list_of_items( $missing_attributes ) ) ); + } + } catch ( Exception $e ) { + wc_add_notice( $e->getMessage(), 'error' ); + return false; + } + + $passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity, $variation_id, $variations ); + + if ( $passed_validation && false !== WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ) ) { + wc_add_to_cart_message( array( $product_id => $quantity ), true ); + return true; + } + + return false; + } + + /** + * Process the login form. + */ + public static function process_login() { + // The global form-login.php template used `_wpnonce` in template versions < 3.3.0. + $nonce_value = wc_get_var( $_REQUEST['woocommerce-login-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! empty( $_POST['login'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-login' ) ) { + + try { + $creds = array( + 'user_login' => trim( $_POST['username'] ), + 'user_password' => $_POST['password'], + 'remember' => isset( $_POST['rememberme'] ), + ); + + $validation_error = new WP_Error(); + $validation_error = apply_filters( 'woocommerce_process_login_errors', $validation_error, $_POST['username'], $_POST['password'] ); + + if ( $validation_error->get_error_code() ) { + throw new Exception( '' . __( 'Error:', 'woocommerce' ) . ' ' . $validation_error->get_error_message() ); + } + + if ( empty( $creds['user_login'] ) ) { + throw new Exception( '' . __( 'Error:', 'woocommerce' ) . ' ' . __( 'Username is required.', 'woocommerce' ) ); + } + + // On multisite, ensure user exists on current site, if not add them before allowing login. + if ( is_multisite() ) { + $user_data = get_user_by( is_email( $creds['user_login'] ) ? 'email' : 'login', $creds['user_login'] ); + + if ( $user_data && ! is_user_member_of_blog( $user_data->ID, get_current_blog_id() ) ) { + add_user_to_blog( get_current_blog_id(), $user_data->ID, 'customer' ); + } + } + + // Perform the login + $user = wp_signon( apply_filters( 'woocommerce_login_credentials', $creds ), is_ssl() ); + + if ( is_wp_error( $user ) ) { + $message = $user->get_error_message(); + $message = str_replace( '' . esc_html( $creds['user_login'] ) . '', '' . esc_html( $creds['user_login'] ) . '', $message ); + throw new Exception( $message ); + } else { + + if ( ! empty( $_POST['redirect'] ) ) { + $redirect = $_POST['redirect']; + } elseif ( wc_get_raw_referer() ) { + $redirect = wc_get_raw_referer(); + } else { + $redirect = wc_get_page_permalink( 'myaccount' ); + } + + wp_redirect( wp_validate_redirect( apply_filters( 'woocommerce_login_redirect', remove_query_arg( 'wc_error', $redirect ), $user ), wc_get_page_permalink( 'myaccount' ) ) ); + exit; + } + } catch ( Exception $e ) { + wc_add_notice( apply_filters( 'login_errors', $e->getMessage() ), 'error' ); + do_action( 'woocommerce_login_failed' ); + } + } + } + + /** + * Handle lost password form. + */ + public static function process_lost_password() { + if ( isset( $_POST['wc_reset_password'], $_POST['user_login'] ) ) { + $nonce_value = wc_get_var( $_REQUEST['woocommerce-lost-password-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'lost_password' ) ) { + return; + } + + $success = WC_Shortcode_My_Account::retrieve_password(); + + // If successful, redirect to my account with query arg set. + if ( $success ) { + wp_redirect( add_query_arg( 'reset-link-sent', 'true', wc_get_account_endpoint_url( 'lost-password' ) ) ); + exit; + } + } + } + + /** + * Handle reset password form. + */ + public static function process_reset_password() { + $posted_fields = array( 'wc_reset_password', 'password_1', 'password_2', 'reset_key', 'reset_login' ); + + foreach ( $posted_fields as $field ) { + if ( ! isset( $_POST[ $field ] ) ) { + return; + } + $posted_fields[ $field ] = $_POST[ $field ]; + } + + $nonce_value = wc_get_var( $_REQUEST['woocommerce-reset-password-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. + + if ( ! wp_verify_nonce( $nonce_value, 'reset_password' ) ) { + return; + } + + $user = WC_Shortcode_My_Account::check_password_reset_key( $posted_fields['reset_key'], $posted_fields['reset_login'] ); + + if ( $user instanceof WP_User ) { + if ( empty( $posted_fields['password_1'] ) ) { + wc_add_notice( __( 'Please enter your password.', 'woocommerce' ), 'error' ); + } + + if ( $posted_fields['password_1'] !== $posted_fields['password_2'] ) { + wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' ); + } + + $errors = new WP_Error(); + + do_action( 'validate_password_reset', $errors, $user ); + + wc_add_wp_error_notices( $errors ); + + if ( 0 === wc_notice_count( 'error' ) ) { + WC_Shortcode_My_Account::reset_password( $user, $posted_fields['password_1'] ); + + do_action( 'woocommerce_customer_reset_password', $user ); + + wp_redirect( add_query_arg( 'password-reset', 'true', wc_get_page_permalink( 'myaccount' ) ) ); + exit; + } + } + } + + /** + * Process the registration form. + */ + public static function process_registration() { + $nonce_value = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : ''; + $nonce_value = isset( $_POST['woocommerce-register-nonce'] ) ? $_POST['woocommerce-register-nonce'] : $nonce_value; + + if ( ! empty( $_POST['register'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-register' ) ) { + $username = 'no' === get_option( 'woocommerce_registration_generate_username' ) ? $_POST['username'] : ''; + $password = 'no' === get_option( 'woocommerce_registration_generate_password' ) ? $_POST['password'] : ''; + $email = $_POST['email']; + + try { + $validation_error = new WP_Error(); + $validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $username, $password, $email ); + + if ( $validation_error->get_error_code() ) { + throw new Exception( $validation_error->get_error_message() ); + } + + $new_customer = wc_create_new_customer( sanitize_email( $email ), wc_clean( $username ), $password ); + + if ( is_wp_error( $new_customer ) ) { + throw new Exception( $new_customer->get_error_message() ); + } + + if ( apply_filters( 'woocommerce_registration_auth_new_customer', true, $new_customer ) ) { + wc_set_customer_auth_cookie( $new_customer ); + } + + if ( ! empty( $_POST['redirect'] ) ) { + $redirect = wp_sanitize_redirect( $_POST['redirect'] ); + } elseif ( wc_get_raw_referer() ) { + $redirect = wc_get_raw_referer(); + } else { + $redirect = wc_get_page_permalink( 'myaccount' ); + } + + wp_redirect( wp_validate_redirect( apply_filters( 'woocommerce_registration_redirect', $redirect ), wc_get_page_permalink( 'myaccount' ) ) ); + exit; + + } catch ( Exception $e ) { + wc_add_notice( '' . __( 'Error:', 'woocommerce' ) . ' ' . $e->getMessage(), 'error' ); + } + } + } +} + +WC_Form_Handler::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php new file mode 100644 index 0000000..6257d61 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php @@ -0,0 +1,603 @@ + array( + 'src' => self::get_asset_url( 'assets/css/woocommerce-layout.css' ), + 'deps' => '', + 'version' => WC_VERSION, + 'media' => 'all', + 'has_rtl' => true, + ), + 'woocommerce-smallscreen' => array( + 'src' => self::get_asset_url( 'assets/css/woocommerce-smallscreen.css' ), + 'deps' => 'woocommerce-layout', + 'version' => WC_VERSION, + 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')', + 'has_rtl' => true, + ), + 'woocommerce-general' => array( + 'src' => self::get_asset_url( 'assets/css/woocommerce.css' ), + 'deps' => '', + 'version' => WC_VERSION, + 'media' => 'all', + 'has_rtl' => true, + ), + ) + ); + } + + /** + * Return asset URL. + * + * @param string $path Assets path. + * @return string + */ + private static function get_asset_url( $path ) { + return apply_filters( 'woocommerce_get_asset_url', plugins_url( $path, WC_PLUGIN_FILE ), $path ); + } + + /** + * Register a script for use. + * + * @uses wp_register_script() + * @param string $handle Name of the script. Should be unique. + * @param string $path Full URL of the script, or path of the script relative to the WordPress root directory. + * @param string[] $deps An array of registered script handles this script depends on. + * @param string $version String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added. + * @param boolean $in_footer Whether to enqueue the script before instead of in the . Default 'false'. + */ + private static function register_script( $handle, $path, $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) { + self::$scripts[] = $handle; + wp_register_script( $handle, $path, $deps, $version, $in_footer ); + } + + /** + * Register and enqueue a script for use. + * + * @uses wp_enqueue_script() + * @param string $handle Name of the script. Should be unique. + * @param string $path Full URL of the script, or path of the script relative to the WordPress root directory. + * @param string[] $deps An array of registered script handles this script depends on. + * @param string $version String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added. + * @param boolean $in_footer Whether to enqueue the script before instead of in the . Default 'false'. + */ + private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) { + if ( ! in_array( $handle, self::$scripts, true ) && $path ) { + self::register_script( $handle, $path, $deps, $version, $in_footer ); + } + wp_enqueue_script( $handle ); + } + + /** + * Register a style for use. + * + * @uses wp_register_style() + * @param string $handle Name of the stylesheet. Should be unique. + * @param string $path Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. + * @param string[] $deps An array of registered stylesheet handles this stylesheet depends on. + * @param string $version String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added. + * @param string $media The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'. + * @param boolean $has_rtl If has RTL version to load too. + */ + private static function register_style( $handle, $path, $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) { + self::$styles[] = $handle; + wp_register_style( $handle, $path, $deps, $version, $media ); + + if ( $has_rtl ) { + wp_style_add_data( $handle, 'rtl', 'replace' ); + } + } + + /** + * Register and enqueue a styles for use. + * + * @uses wp_enqueue_style() + * @param string $handle Name of the stylesheet. Should be unique. + * @param string $path Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. + * @param string[] $deps An array of registered stylesheet handles this stylesheet depends on. + * @param string $version String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added. + * @param string $media The media for which this stylesheet has been defined. Accepts media types like 'all', 'print' and 'screen', or media queries like '(orientation: portrait)' and '(max-width: 640px)'. + * @param boolean $has_rtl If has RTL version to load too. + */ + private static function enqueue_style( $handle, $path = '', $deps = array(), $version = WC_VERSION, $media = 'all', $has_rtl = false ) { + if ( ! in_array( $handle, self::$styles, true ) && $path ) { + self::register_style( $handle, $path, $deps, $version, $media, $has_rtl ); + } + wp_enqueue_style( $handle ); + } + + /** + * Register all WC scripts. + */ + private static function register_scripts() { + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + $register_scripts = array( + 'flexslider' => array( + 'src' => self::get_asset_url( 'assets/js/flexslider/jquery.flexslider' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '2.7.1', + ), + 'js-cookie' => array( + 'src' => self::get_asset_url( 'assets/js/js-cookie/js.cookie' . $suffix . '.js' ), + 'deps' => array(), + 'version' => '2.1.4', + ), + 'jquery-blockui' => array( + 'src' => self::get_asset_url( 'assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '2.70', + ), + 'jquery-cookie' => array( // deprecated. + 'src' => self::get_asset_url( 'assets/js/jquery-cookie/jquery.cookie' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '1.4.1', + ), + 'jquery-payment' => array( + 'src' => self::get_asset_url( 'assets/js/jquery-payment/jquery.payment' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '3.0.0', + ), + 'photoswipe' => array( + 'src' => self::get_asset_url( 'assets/js/photoswipe/photoswipe' . $suffix . '.js' ), + 'deps' => array(), + 'version' => '4.1.1', + ), + 'photoswipe-ui-default' => array( + 'src' => self::get_asset_url( 'assets/js/photoswipe/photoswipe-ui-default' . $suffix . '.js' ), + 'deps' => array( 'photoswipe' ), + 'version' => '4.1.1', + ), + 'prettyPhoto' => array( // deprecated. + 'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '3.1.6', + ), + 'prettyPhoto-init' => array( // deprecated. + 'src' => self::get_asset_url( 'assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'prettyPhoto' ), + 'version' => WC_VERSION, + ), + 'select2' => array( + 'src' => self::get_asset_url( 'assets/js/select2/select2.full' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '4.0.3', + ), + 'selectWoo' => array( + 'src' => self::get_asset_url( 'assets/js/selectWoo/selectWoo.full' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '1.0.4', + ), + 'wc-address-i18n' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => WC_VERSION, + ), + 'wc-add-payment-method' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/add-payment-method' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'woocommerce' ), + 'version' => WC_VERSION, + ), + 'wc-cart' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/cart' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ), + 'version' => WC_VERSION, + ), + 'wc-cart-fragments' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'js-cookie' ), + 'version' => WC_VERSION, + ), + 'wc-checkout' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/checkout' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'woocommerce', 'wc-country-select', 'wc-address-i18n' ), + 'version' => WC_VERSION, + ), + 'wc-country-select' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/country-select' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => WC_VERSION, + ), + 'wc-credit-card-form' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/credit-card-form' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'jquery-payment' ), + 'version' => WC_VERSION, + ), + 'wc-add-to-cart' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => WC_VERSION, + ), + 'wc-add-to-cart-variation' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/add-to-cart-variation' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'wp-util' ), + 'version' => WC_VERSION, + ), + 'wc-geolocation' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/geolocation' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => WC_VERSION, + ), + 'wc-lost-password' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/lost-password' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'woocommerce' ), + 'version' => WC_VERSION, + ), + 'wc-password-strength-meter' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/password-strength-meter' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'password-strength-meter' ), + 'version' => WC_VERSION, + ), + 'wc-single-product' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/single-product' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => WC_VERSION, + ), + 'woocommerce' => array( + 'src' => self::get_asset_url( 'assets/js/frontend/woocommerce' . $suffix . '.js' ), + 'deps' => array( 'jquery', 'jquery-blockui', 'js-cookie' ), + 'version' => WC_VERSION, + ), + 'zoom' => array( + 'src' => self::get_asset_url( 'assets/js/zoom/jquery.zoom' . $suffix . '.js' ), + 'deps' => array( 'jquery' ), + 'version' => '1.7.21', + ), + ); + foreach ( $register_scripts as $name => $props ) { + self::register_script( $name, $props['src'], $props['deps'], $props['version'] ); + } + } + + /** + * Register all WC sty;es. + */ + private static function register_styles() { + $register_styles = array( + 'photoswipe' => array( + 'src' => self::get_asset_url( 'assets/css/photoswipe/photoswipe.css' ), + 'deps' => array(), + 'version' => WC_VERSION, + 'has_rtl' => false, + ), + 'photoswipe-default-skin' => array( + 'src' => self::get_asset_url( 'assets/css/photoswipe/default-skin/default-skin.css' ), + 'deps' => array( 'photoswipe' ), + 'version' => WC_VERSION, + 'has_rtl' => false, + ), + 'select2' => array( + 'src' => self::get_asset_url( 'assets/css/select2.css' ), + 'deps' => array(), + 'version' => WC_VERSION, + 'has_rtl' => false, + ), + 'woocommerce_prettyPhoto_css' => array( // deprecated. + 'src' => self::get_asset_url( 'assets/css/prettyPhoto.css' ), + 'deps' => array(), + 'version' => WC_VERSION, + 'has_rtl' => true, + ), + ); + foreach ( $register_styles as $name => $props ) { + self::register_style( $name, $props['src'], $props['deps'], $props['version'], 'all', $props['has_rtl'] ); + } + } + + /** + * Register/queue frontend scripts. + */ + public static function load_scripts() { + global $post; + + if ( ! did_action( 'before_woocommerce_init' ) ) { + return; + } + + self::register_scripts(); + self::register_styles(); + + if ( 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' ) ) { + self::enqueue_script( 'wc-add-to-cart' ); + } + if ( is_cart() ) { + self::enqueue_script( 'wc-cart' ); + } + if ( is_cart() || is_checkout() || is_account_page() ) { + self::enqueue_script( 'selectWoo' ); + self::enqueue_style( 'select2' ); + + // Password strength meter. Load in checkout, account login and edit account page. + if ( ( 'no' === get_option( 'woocommerce_registration_generate_password' ) && ! is_user_logged_in() ) || is_edit_account_page() || is_lost_password_page() ) { + self::enqueue_script( 'wc-password-strength-meter' ); + } + } + if ( is_checkout() ) { + self::enqueue_script( 'wc-checkout' ); + } + if ( is_add_payment_method_page() ) { + self::enqueue_script( 'wc-add-payment-method' ); + } + if ( is_lost_password_page() ) { + self::enqueue_script( 'wc-lost-password' ); + } + + // Load gallery scripts on product pages only if supported. + if ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) { + if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) { + self::enqueue_script( 'zoom' ); + } + if ( current_theme_supports( 'wc-product-gallery-slider' ) ) { + self::enqueue_script( 'flexslider' ); + } + if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) { + self::enqueue_script( 'photoswipe-ui-default' ); + self::enqueue_style( 'photoswipe-default-skin' ); + add_action( 'wp_footer', 'woocommerce_photoswipe' ); + } + self::enqueue_script( 'wc-single-product' ); + } + + if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) { + $ua = wc_get_user_agent(); // Exclude common bots from geolocation by user agent. + + if ( ! strstr( $ua, 'bot' ) && ! strstr( $ua, 'spider' ) && ! strstr( $ua, 'crawl' ) ) { + self::enqueue_script( 'wc-geolocation' ); + } + } + + // Global frontend scripts. + self::enqueue_script( 'woocommerce' ); + self::enqueue_script( 'wc-cart-fragments' ); + + // CSS Styles. + $enqueue_styles = self::get_styles(); + if ( $enqueue_styles ) { + foreach ( $enqueue_styles as $handle => $args ) { + if ( ! isset( $args['has_rtl'] ) ) { + $args['has_rtl'] = false; + } + + self::enqueue_style( $handle, $args['src'], $args['deps'], $args['version'], $args['media'], $args['has_rtl'] ); + } + } + + // Placeholder style. + wp_register_style( 'woocommerce-inline', false ); + wp_enqueue_style( 'woocommerce-inline' ); + + if ( true === wc_string_to_bool( get_option( 'woocommerce_checkout_highlight_required_fields', 'yes' ) ) ) { + wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: visible; }' ); + } else { + wp_add_inline_style( 'woocommerce-inline', '.woocommerce form .form-row .required { visibility: hidden; }' ); + } + } + + /** + * Localize a WC script once. + * + * @since 2.3.0 this needs less wp_script_is() calls due to https://core.trac.wordpress.org/ticket/28404 being added in WP 4.0. + * @param string $handle Script handle the data will be attached to. + */ + private static function localize_script( $handle ) { + if ( ! in_array( $handle, self::$wp_localize_scripts, true ) && wp_script_is( $handle ) ) { + $data = self::get_script_data( $handle ); + + if ( ! $data ) { + return; + } + + $name = str_replace( '-', '_', $handle ) . '_params'; + self::$wp_localize_scripts[] = $handle; + wp_localize_script( $handle, $name, apply_filters( $name, $data ) ); + } + } + + /** + * Return data for script handles. + * + * @param string $handle Script handle the data will be attached to. + * @return array|bool + */ + private static function get_script_data( $handle ) { + global $wp; + + switch ( $handle ) { + case 'woocommerce': + $params = array( + 'ajax_url' => WC()->ajax_url(), + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + ); + break; + case 'wc-geolocation': + $params = array( + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'home_url' => home_url(), + 'is_available' => ! ( is_cart() || is_account_page() || is_checkout() || is_customize_preview() ) ? '1' : '0', + 'hash' => isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : '', // WPCS: input var ok, CSRF ok. + ); + break; + case 'wc-single-product': + $params = array( + 'i18n_required_rating_text' => esc_attr__( 'Please select a rating', 'woocommerce' ), + 'review_rating_required' => get_option( 'woocommerce_review_rating_required' ), + 'flexslider' => apply_filters( + 'woocommerce_single_product_carousel_options', array( + 'rtl' => is_rtl(), + 'animation' => 'slide', + 'smoothHeight' => true, + 'directionNav' => false, + 'controlNav' => 'thumbnails', + 'slideshow' => false, + 'animationSpeed' => 500, + 'animationLoop' => false, // Breaks photoswipe pagination if true. + 'allowOneSlide' => false, + ) + ), + 'zoom_enabled' => apply_filters( 'woocommerce_single_product_zoom_enabled', get_theme_support( 'wc-product-gallery-zoom' ) ), + 'zoom_options' => apply_filters( 'woocommerce_single_product_zoom_options', array() ), + 'photoswipe_enabled' => apply_filters( 'woocommerce_single_product_photoswipe_enabled', get_theme_support( 'wc-product-gallery-lightbox' ) ), + 'photoswipe_options' => apply_filters( + 'woocommerce_single_product_photoswipe_options', array( + 'shareEl' => false, + 'closeOnScroll' => false, + 'history' => false, + 'hideAnimationDuration' => 0, + 'showAnimationDuration' => 0, + ) + ), + 'flexslider_enabled' => apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) ), + ); + break; + case 'wc-checkout': + $params = array( + 'ajax_url' => WC()->ajax_url(), + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'update_order_review_nonce' => wp_create_nonce( 'update-order-review' ), + 'apply_coupon_nonce' => wp_create_nonce( 'apply-coupon' ), + 'remove_coupon_nonce' => wp_create_nonce( 'remove-coupon' ), + 'option_guest_checkout' => get_option( 'woocommerce_enable_guest_checkout' ), + 'checkout_url' => WC_AJAX::get_endpoint( 'checkout' ), + 'is_checkout' => is_page( wc_get_page_id( 'checkout' ) ) && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0, + 'debug_mode' => defined( 'WP_DEBUG' ) && WP_DEBUG, + 'i18n_checkout_error' => esc_attr__( 'Error processing checkout. Please try again.', 'woocommerce' ), + ); + break; + case 'wc-address-i18n': + $params = array( + 'locale' => wp_json_encode( WC()->countries->get_country_locale() ), + 'locale_fields' => wp_json_encode( WC()->countries->get_country_locale_field_selectors() ), + 'i18n_required_text' => esc_attr__( 'required', 'woocommerce' ), + 'i18n_optional_text' => esc_html__( 'optional', 'woocommerce' ), + ); + break; + case 'wc-cart': + $params = array( + 'ajax_url' => WC()->ajax_url(), + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'update_shipping_method_nonce' => wp_create_nonce( 'update-shipping-method' ), + 'apply_coupon_nonce' => wp_create_nonce( 'apply-coupon' ), + 'remove_coupon_nonce' => wp_create_nonce( 'remove-coupon' ), + ); + break; + case 'wc-cart-fragments': + $params = array( + 'ajax_url' => WC()->ajax_url(), + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'cart_hash_key' => apply_filters( 'woocommerce_cart_hash_key', 'wc_cart_hash_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ), + 'fragment_name' => apply_filters( 'woocommerce_cart_fragment_name', 'wc_fragments_' . md5( get_current_blog_id() . '_' . get_site_url( get_current_blog_id(), '/' ) . get_template() ) ), + ); + break; + case 'wc-add-to-cart': + $params = array( + 'ajax_url' => WC()->ajax_url(), + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'i18n_view_cart' => esc_attr__( 'View cart', 'woocommerce' ), + 'cart_url' => apply_filters( 'woocommerce_add_to_cart_redirect', wc_get_cart_url() ), + 'is_cart' => is_cart(), + 'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' ), + ); + break; + case 'wc-add-to-cart-variation': + // We also need the wp.template for this script :). + wc_get_template( 'single-product/add-to-cart/variation.php' ); + + $params = array( + 'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), + 'i18n_no_matching_variations_text' => esc_attr__( 'Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce' ), + 'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your cart.', 'woocommerce' ), + 'i18n_unavailable_text' => esc_attr__( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ), + ); + break; + case 'wc-country-select': + $params = array( + 'countries' => wp_json_encode( array_merge( WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states() ) ), + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'woocommerce' ), + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'woocommerce' ), + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'woocommerce' ), + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'woocommerce' ), + 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'woocommerce' ), + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'woocommerce' ), + 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'woocommerce' ), + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'woocommerce' ), + 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'woocommerce' ), + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'woocommerce' ), + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'woocommerce' ), + ); + break; + case 'wc-password-strength-meter': + $params = array( + 'min_password_strength' => apply_filters( 'woocommerce_min_password_strength', 3 ), + 'i18n_password_error' => esc_attr__( 'Please enter a stronger password.', 'woocommerce' ), + 'i18n_password_hint' => esc_attr( wp_get_password_hint() ), + ); + break; + default: + $params = false; + } + + return apply_filters( 'woocommerce_get_script_data', $params, $handle ); + } + + /** + * Localize scripts only when enqueued. + */ + public static function localize_printed_scripts() { + foreach ( self::$scripts as $handle ) { + self::localize_script( $handle ); + } + } +} + +WC_Frontend_Scripts::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-geo-ip.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-geo-ip.php new file mode 100644 index 0000000..9aeb5af --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-geo-ip.php @@ -0,0 +1,1814 @@ +log( $level, $message, array( 'source' => 'geoip' ) ); + } + + /** + * Open geoip file. + * + * @param string $filename + * @param int $flags + */ + public function geoip_open( $filename, $flags ) { + $this->flags = $flags; + if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + $this->shmid = @shmop_open( self::GEOIP_SHM_KEY, 'a', 0, 0 ); + } else { + if ( $this->filehandle = fopen( $filename, 'rb' ) ) { + if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { + $s_array = fstat( $this->filehandle ); + $this->memory_buffer = fread( $this->filehandle, $s_array['size'] ); + } + } else { + $this->log( 'GeoIP API: Can not open ' . $filename, 'error' ); + } + } + + $this->_setup_segments(); + } + + /** + * Setup segments. + * + * @return WC_Geo_IP instance + */ + private function _setup_segments() { + $this->databaseType = self::GEOIP_COUNTRY_EDITION; + $this->record_length = self::STANDARD_RECORD_LENGTH; + + if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + $offset = @shmop_size( $this->shmid ) - 3; + + for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) { + $delim = @shmop_read( $this->shmid, $offset, 3 ); + $offset += 3; + + if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) { + $this->databaseType = ord( @shmop_read( $this->shmid, $offset, 1 ) ); + + if ( $this->databaseType >= 106 ) { + $this->databaseType -= 105; + } + + $offset++; + + if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) { + $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0; + } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) { + $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1; + } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_USERTYPE_EDITION == $this->databaseType ) + || ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType ) + || ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType ) + || ( self::GEOIP_ASNUM_EDITION == $this->databaseType ) + || ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType ) + ) { + $this->databaseSegments = 0; + $buf = @shmop_read( $this->shmid, $offset, self::SEGMENT_RECORD_LENGTH ); + + for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) { + $this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) ); + } + + if ( ( self::GEOIP_ORG_EDITION == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) + ) { + $this->record_length = self::ORG_RECORD_LENGTH; + } + } + + break; + } else { + $offset -= 4; + } + } + if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType ) + || ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_PROXY_EDITION == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION == $this->databaseType ) + ) { + $this->databaseSegments = self::GEOIP_COUNTRY_BEGIN; + } + } else { + $filepos = ftell( $this->filehandle ); + fseek( $this->filehandle, -3, SEEK_END ); + + for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) { + + $delim = fread( $this->filehandle, 3 ); + if ( ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) == $delim ) { + + $this->databaseType = ord( fread( $this->filehandle, 1 ) ); + if ( $this->databaseType >= 106 ) { + $this->databaseType -= 105; + } + + if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) { + $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0; + } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) { + $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1; + } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType ) + || ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_LOCATIONA_EDITION == $this->databaseType ) + || ( self::GEOIP_ACCURACYRADIUS_EDITION == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION_REV1 == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION_REV1_V6 == $this->databaseType ) + || ( self::GEOIP_USERTYPE_EDITION == $this->databaseType ) + || ( self::GEOIP_USERTYPE_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_ASNUM_EDITION == $this->databaseType ) + || ( self::GEOIP_ASNUM_EDITION_V6 == $this->databaseType ) + ) { + $this->databaseSegments = 0; + $buf = fread( $this->filehandle, self::SEGMENT_RECORD_LENGTH ); + + for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) { + $this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) ); + } + + if ( ( self::GEOIP_ORG_EDITION == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION == $this->databaseType ) + || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_ISP_EDITION_V6 == $this->databaseType ) + ) { + $this->record_length = self::ORG_RECORD_LENGTH; + } + } + + break; + } else { + fseek( $this->filehandle, -4, SEEK_CUR ); + } + } + + if ( ( self::GEOIP_COUNTRY_EDITION == $this->databaseType ) + || ( self::GEOIP_COUNTRY_EDITION_V6 == $this->databaseType ) + || ( self::GEOIP_PROXY_EDITION == $this->databaseType ) + || ( self::GEOIP_NETSPEED_EDITION == $this->databaseType ) + ) { + $this->databaseSegments = self::GEOIP_COUNTRY_BEGIN; + } + + fseek( $this->filehandle, $filepos, SEEK_SET ); + } + + return $this; + } + + /** + * Close geoip file. + * + * @return bool + */ + public function geoip_close() { + if ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + return true; + } + + return fclose( $this->filehandle ); + } + + /** + * Common get record. + * + * @param string $seek_country + * @return WC_Geo_IP_Record instance + */ + private function _common_get_record( $seek_country ) { + // workaround php's broken substr, strpos, etc handling with + // mbstring.func_overload and mbstring.internal_encoding + $mbExists = extension_loaded( 'mbstring' ); + if ( $mbExists ) { + $enc = mb_internal_encoding(); + mb_internal_encoding( 'ISO-8859-1' ); + } + + $record_pointer = $seek_country + ( 2 * $this->record_length - 1 ) * $this->databaseSegments; + + if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { + $record_buf = substr( $this->memory_buffer, $record_pointer, FULL_RECORD_LENGTH ); + } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + $record_buf = @shmop_read( $this->shmid, $record_pointer, FULL_RECORD_LENGTH ); + } else { + fseek( $this->filehandle, $record_pointer, SEEK_SET ); + $record_buf = fread( $this->filehandle, FULL_RECORD_LENGTH ); + } + + $record = new WC_Geo_IP_Record(); + $record_buf_pos = 0; + $char = ord( substr( $record_buf, $record_buf_pos, 1 ) ); + $record->country_code = $this->GEOIP_COUNTRY_CODES[ $char ]; + $record->country_code3 = $this->GEOIP_COUNTRY_CODES3[ $char ]; + $record->country_name = $this->GEOIP_COUNTRY_NAMES[ $char ]; + $record->continent_code = $this->GEOIP_CONTINENT_CODES[ $char ]; + $str_length = 0; + + $record_buf_pos++; + + // Get region + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + while ( 0 != $char ) { + $str_length++; + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + } + + if ( $str_length > 0 ) { + $record->region = substr( $record_buf, $record_buf_pos, $str_length ); + } + + $record_buf_pos += $str_length + 1; + $str_length = 0; + + // Get city + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + while ( 0 != $char ) { + $str_length++; + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + } + + if ( $str_length > 0 ) { + $record->city = substr( $record_buf, $record_buf_pos, $str_length ); + } + + $record_buf_pos += $str_length + 1; + $str_length = 0; + + // Get postal code + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + while ( 0 != $char ) { + $str_length++; + $char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) ); + } + + if ( $str_length > 0 ) { + $record->postal_code = substr( $record_buf, $record_buf_pos, $str_length ); + } + + $record_buf_pos += $str_length + 1; + + // Get latitude and longitude + $latitude = 0; + $longitude = 0; + for ( $j = 0; $j < 3; ++$j ) { + $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); + $latitude += ( $char << ( $j * 8 ) ); + } + + $record->latitude = ( $latitude / 10000 ) - 180; + + for ( $j = 0; $j < 3; ++$j ) { + $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); + $longitude += ( $char << ( $j * 8 ) ); + } + + $record->longitude = ( $longitude / 10000 ) - 180; + + if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) { + $metroarea_combo = 0; + if ( 'US' === $record->country_code ) { + for ( $j = 0; $j < 3; ++$j ) { + $char = ord( substr( $record_buf, $record_buf_pos++, 1 ) ); + $metroarea_combo += ( $char << ( $j * 8 ) ); + } + + $record->metro_code = $record->dma_code = floor( $metroarea_combo / 1000 ); + $record->area_code = $metroarea_combo % 1000; + } + } + + if ( $mbExists ) { + mb_internal_encoding( $enc ); + } + + return $record; + } + + /** + * Get record. + * + * @param int $ipnum + * @return WC_Geo_IP_Record instance + */ + private function _get_record( $ipnum ) { + $seek_country = $this->_geoip_seek_country( $ipnum ); + if ( $seek_country == $this->databaseSegments ) { + return null; + } + + return $this->_common_get_record( $seek_country ); + } + + /** + * Seek country IPv6. + * + * @param int $ipnum + * @return string + */ + public function _geoip_seek_country_v6( $ipnum ) { + // arrays from unpack start with offset 1 + // yet another php mystery. array_merge work around + // this broken behaviour + $v6vec = array_merge( unpack( 'C16', $ipnum ) ); + + $offset = 0; + for ( $depth = 127; $depth >= 0; --$depth ) { + if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { + $buf = $this->_safe_substr( + $this->memory_buffer, + 2 * $this->record_length * $offset, + 2 * $this->record_length + ); + } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + $buf = @shmop_read( + $this->shmid, + 2 * $this->record_length * $offset, + 2 * $this->record_length + ); + } else { + if ( 0 != fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) ) { + break; + } + + $buf = fread( $this->filehandle, 2 * $this->record_length ); + } + $x = array( 0, 0 ); + for ( $i = 0; $i < 2; ++$i ) { + for ( $j = 0; $j < $this->record_length; ++$j ) { + $x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 ); + } + } + + $bnum = 127 - $depth; + $idx = $bnum >> 3; + $b_mask = 1 << ( $bnum & 7 ^ 7 ); + if ( ( $v6vec[ $idx ] & $b_mask ) > 0 ) { + if ( $x[1] >= $this->databaseSegments ) { + return $x[1]; + } + $offset = $x[1]; + } else { + if ( $x[0] >= $this->databaseSegments ) { + return $x[0]; + } + $offset = $x[0]; + } + } + + $this->log( 'GeoIP API: Error traversing database - perhaps it is corrupt?', 'error' ); + + return false; + } + + /** + * Seek country. + * + * @param int $ipnum + * @return string + */ + private function _geoip_seek_country( $ipnum ) { + $offset = 0; + for ( $depth = 31; $depth >= 0; --$depth ) { + if ( $this->flags & self::GEOIP_MEMORY_CACHE ) { + $buf = $this->_safe_substr( + $this->memory_buffer, + 2 * $this->record_length * $offset, + 2 * $this->record_length + ); + } elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) { + $buf = @shmop_read( + $this->shmid, + 2 * $this->record_length * $offset, + 2 * $this->record_length + ); + } else { + if ( 0 != fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) ) { + break; + } + + $buf = fread( $this->filehandle, 2 * $this->record_length ); + } + + $x = array( 0, 0 ); + for ( $i = 0; $i < 2; ++$i ) { + for ( $j = 0; $j < $this->record_length; ++$j ) { + $x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 ); + } + } + if ( $ipnum & ( 1 << $depth ) ) { + if ( $x[1] >= $this->databaseSegments ) { + return $x[1]; + } + + $offset = $x[1]; + } else { + if ( $x[0] >= $this->databaseSegments ) { + return $x[0]; + } + + $offset = $x[0]; + } + } + + $this->log( 'GeoIP API: Error traversing database - perhaps it is corrupt?', 'error' ); + + return false; + } + + /** + * Record by addr. + * + * @param string $addr + * + * @return WC_Geo_IP_Record + */ + public function geoip_record_by_addr( $addr ) { + if ( null == $addr ) { + return 0; + } + + $ipnum = ip2long( $addr ); + return $this->_get_record( $ipnum ); + } + + /** + * Country ID by addr IPv6. + * + * @param string $addr + * @return int|bool + */ + public function geoip_country_id_by_addr_v6( $addr ) { + if ( ! defined( 'AF_INET6' ) ) { + $this->log( 'GEOIP (geoip_country_id_by_addr_v6): PHP was compiled with --disable-ipv6 option' ); + return false; + } + $ipnum = inet_pton( $addr ); + return $this->_geoip_seek_country_v6( $ipnum ) - self::GEOIP_COUNTRY_BEGIN; + } + + /** + * Country ID by addr. + * + * @param string $addr + * @return int + */ + public function geoip_country_id_by_addr( $addr ) { + $ipnum = ip2long( $addr ); + return $this->_geoip_seek_country( $ipnum ) - self::GEOIP_COUNTRY_BEGIN; + } + + /** + * Country code by addr IPv6. + * + * @param string $addr + * @return string + */ + public function geoip_country_code_by_addr_v6( $addr ) { + $country_id = $this->geoip_country_id_by_addr_v6( $addr ); + if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) { + return $this->GEOIP_COUNTRY_CODES[ $country_id ]; + } + + return false; + } + + /** + * Country code by addr. + * + * @param string $addr + * @return string + */ + public function geoip_country_code_by_addr( $addr ) { + if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) { + $record = $this->geoip_record_by_addr( $addr ); + if ( false !== $record ) { + return $record->country_code; + } + } else { + $country_id = $this->geoip_country_id_by_addr( $addr ); + if ( false !== $country_id && isset( $this->GEOIP_COUNTRY_CODES[ $country_id ] ) ) { + return $this->GEOIP_COUNTRY_CODES[ $country_id ]; + } + } + + return false; + } + + /** + * Encode string. + * + * @param string $string + * @param int $start + * @param int $length + * @return string + */ + private function _safe_substr( $string, $start, $length ) { + // workaround php's broken substr, strpos, etc handling with + // mbstring.func_overload and mbstring.internal_encoding + $mb_exists = extension_loaded( 'mbstring' ); + + if ( $mb_exists ) { + $enc = mb_internal_encoding(); + mb_internal_encoding( 'ISO-8859-1' ); + } + + $buf = substr( $string, $start, $length ); + + if ( $mb_exists ) { + mb_internal_encoding( $enc ); + } + + return $buf; + } +} + +/** + * Geo IP Record class. + */ +class WC_Geo_IP_Record { + + /** + * Country code. + * + * @var string + */ + public $country_code; + + /** + * 3 letters country code. + * + * @var string + */ + public $country_code3; + + /** + * Country name. + * + * @var string + */ + public $country_name; + + /** + * Region. + * + * @var string + */ + public $region; + + /** + * City. + * + * @var string + */ + public $city; + + /** + * Postal code. + * + * @var string + */ + public $postal_code; + + /** + * Latitude + * + * @var int + */ + public $latitude; + + /** + * Longitude. + * + * @var int + */ + public $longitude; + + /** + * Area code. + * + * @var int + */ + public $area_code; + + /** + * DMA Code. + * + * Metro and DMA code are the same. + * Use metro code instead. + * + * @var float + */ + public $dma_code; + + /** + * Metro code. + * + * @var float + */ + public $metro_code; + + /** + * Continent code. + * + * @var string + */ + public $continent_code; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-geolite-integration.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-geolite-integration.php new file mode 100644 index 0000000..2d97ccd --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-geolite-integration.php @@ -0,0 +1,98 @@ +database = $database; + + if ( ! class_exists( 'MaxMind\\Db\\Reader', false ) ) { + $this->require_geolite_library(); + } + } + + /** + * Get country 2-letters ISO by IP address. + * Retuns empty string when not able to find any ISO code. + * + * @param string $ip_address User IP address. + * @return string + */ + public function get_country_iso( $ip_address ) { + $iso_code = ''; + + try { + $reader = new MaxMind\Db\Reader( $this->database ); // phpcs:ignore PHPCompatibility.PHP.NewLanguageConstructs.t_ns_separatorFound + $data = $reader->get( $ip_address ); + $iso_code = $data['country']['iso_code']; + + $reader->close(); + } catch ( Exception $e ) { + $this->log( $e->getMessage(), 'warning' ); + } + + return sanitize_text_field( strtoupper( $iso_code ) ); + } + + /** + * Logging method. + * + * @param string $message Log message. + * @param string $level Log level. + * Available options: 'emergency', 'alert', + * 'critical', 'error', 'warning', 'notice', + * 'info' and 'debug'. + * Defaults to 'info'. + */ + private function log( $message, $level = 'info' ) { + if ( is_null( $this->log ) ) { + $this->log = wc_get_logger(); + } + + $this->log->log( $level, $message, array( 'source' => 'geoip' ) ); + } + + /** + * Require geolite library. + */ + private function require_geolite_library() { + require_once WC_ABSPATH . 'includes/libraries/geolite2/Reader/Decoder.php'; + require_once WC_ABSPATH . 'includes/libraries/geolite2/Reader/InvalidDatabaseException.php'; + require_once WC_ABSPATH . 'includes/libraries/geolite2/Reader/Metadata.php'; + require_once WC_ABSPATH . 'includes/libraries/geolite2/Reader/Util.php'; + require_once WC_ABSPATH . 'includes/libraries/geolite2/Reader.php'; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php new file mode 100644 index 0000000..4ef314b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php @@ -0,0 +1,378 @@ + 'http://icanhazip.com', + 'ipify' => 'http://api.ipify.org/', + 'ipecho' => 'http://ipecho.net/plain', + 'ident' => 'http://ident.me', + 'whatismyipaddress' => 'http://bot.whatismyipaddress.com', + ); + + /** + * API endpoints for geolocating an IP address + * + * @var array + */ + private static $geoip_apis = array( + 'ipinfo.io' => 'https://ipinfo.io/%s/json', + 'ip-api.com' => 'http://ip-api.com/json/%s', + ); + + /** + * Check if server supports MaxMind GeoLite2 Reader. + * + * @since 3.4.0 + * @return bool + */ + private static function supports_geolite2() { + return version_compare( PHP_VERSION, '5.4.0', '>=' ); + } + + /** + * Check if geolocation is enabled. + * + * @since 3.4.0 + * @param string $current_settings Current geolocation settings. + * @return bool + */ + private static function is_geolocation_enabled( $current_settings ) { + return in_array( $current_settings, array( 'geolocation', 'geolocation_ajax' ), true ); + } + + /** + * Prevent geolocation via MaxMind when using legacy versions of php. + * + * @since 3.4.0 + * @param string $default_customer_address current value. + * @return string + */ + public static function disable_geolocation_on_legacy_php( $default_customer_address ) { + if ( self::is_geolocation_enabled( $default_customer_address ) ) { + $default_customer_address = 'base'; + } + + return $default_customer_address; + } + + /** + * Hook in geolocation functionality. + */ + public static function init() { + if ( self::supports_geolite2() ) { + // Only download the database from MaxMind if the geolocation function is enabled, or a plugin specifically requests it. + if ( self::is_geolocation_enabled( get_option( 'woocommerce_default_customer_address' ) ) || apply_filters( 'woocommerce_geolocation_update_database_periodically', false ) ) { + add_action( 'woocommerce_geoip_updater', array( __CLASS__, 'update_database' ) ); + } + + // Trigger database update when settings are changed to enable geolocation. + add_filter( 'pre_update_option_woocommerce_default_customer_address', array( __CLASS__, 'maybe_update_database' ), 10, 2 ); + } else { + add_filter( 'pre_option_woocommerce_default_customer_address', array( __CLASS__, 'disable_geolocation_on_legacy_php' ) ); + } + } + + /** + * Maybe trigger a DB update for the first time. + * + * @param string $new_value New value. + * @param string $old_value Old value. + * @return string + */ + public static function maybe_update_database( $new_value, $old_value ) { + if ( $new_value !== $old_value && self::is_geolocation_enabled( $new_value ) ) { + self::update_database(); + } + + return $new_value; + } + + /** + * Get current user IP Address. + * + * @return string + */ + public static function get_ip_address() { + if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { // WPCS: input var ok, CSRF ok. + return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); // WPCS: input var ok, CSRF ok. + } elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // WPCS: input var ok, CSRF ok. + // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 + // Make sure we always only send through the first IP in the list which should always be the client IP. + return (string) rest_is_ip_address( trim( current( preg_split( '/[,:]/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); // WPCS: input var ok, CSRF ok. + } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) { // @codingStandardsIgnoreLine + return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // @codingStandardsIgnoreLine + } + return ''; + } + + /** + * Get user IP Address using an external service. + * This is used mainly as a fallback for users on localhost where + * get_ip_address() will be a local IP and non-geolocatable. + * + * @return string + */ + public static function get_external_ip_address() { + $external_ip_address = '0.0.0.0'; + + if ( '' !== self::get_ip_address() ) { + $transient_name = 'external_ip_address_' . self::get_ip_address(); + $external_ip_address = get_transient( $transient_name ); + } + + if ( false === $external_ip_address ) { + $external_ip_address = '0.0.0.0'; + $ip_lookup_services = apply_filters( 'woocommerce_geolocation_ip_lookup_apis', self::$ip_lookup_apis ); + $ip_lookup_services_keys = array_keys( $ip_lookup_services ); + shuffle( $ip_lookup_services_keys ); + + foreach ( $ip_lookup_services_keys as $service_name ) { + $service_endpoint = $ip_lookup_services[ $service_name ]; + $response = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) ); + + if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) { + $external_ip_address = apply_filters( 'woocommerce_geolocation_ip_lookup_api_response', wc_clean( $response['body'] ), $service_name ); + break; + } + } + + set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS ); + } + + return $external_ip_address; + } + + /** + * Geolocate an IP address. + * + * @param string $ip_address IP Address. + * @param bool $fallback If true, fallbacks to alternative IP detection (can be slower). + * @param bool $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower). + * @return array + */ + public static function geolocate_ip( $ip_address = '', $fallback = true, $api_fallback = true ) { + // Filter to allow custom geolocation of the IP address. + $country_code = apply_filters( 'woocommerce_geolocate_ip', false, $ip_address, $fallback, $api_fallback ); + + if ( false === $country_code ) { + // If GEOIP is enabled in CloudFlare, we can use that (Settings -> CloudFlare Settings -> Settings Overview). + if ( ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) { // WPCS: input var ok, CSRF ok. + $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) ); // WPCS: input var ok, CSRF ok. + } elseif ( ! empty( $_SERVER['GEOIP_COUNTRY_CODE'] ) ) { // WPCS: input var ok, CSRF ok. + // WP.com VIP has a variable available. + $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['GEOIP_COUNTRY_CODE'] ) ) ); // WPCS: input var ok, CSRF ok. + } elseif ( ! empty( $_SERVER['HTTP_X_COUNTRY_CODE'] ) ) { // WPCS: input var ok, CSRF ok. + // VIP Go has a variable available also. + $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_COUNTRY_CODE'] ) ) ); // WPCS: input var ok, CSRF ok. + } else { + $ip_address = $ip_address ? $ip_address : self::get_ip_address(); + $database = self::get_local_database_path(); + + if ( self::supports_geolite2() && file_exists( $database ) ) { + $country_code = self::geolocate_via_db( $ip_address, $database ); + } elseif ( $api_fallback ) { + $country_code = self::geolocate_via_api( $ip_address ); + } else { + $country_code = ''; + } + + if ( ! $country_code && $fallback ) { + // May be a local environment - find external IP. + return self::geolocate_ip( self::get_external_ip_address(), false, $api_fallback ); + } + } + } + + return array( + 'country' => $country_code, + 'state' => '', + ); + } + + /** + * Path to our local db. + * + * @param string $deprecated Deprecated since 3.4.0. + * @return string + */ + public static function get_local_database_path( $deprecated = '2' ) { + $upload_dir = wp_upload_dir(); + + return apply_filters( 'woocommerce_geolocation_local_database_path', $upload_dir['basedir'] . '/GeoLite2-Country.mmdb', $deprecated ); + } + + /** + * Update geoip database. + */ + public static function update_database() { + $logger = wc_get_logger(); + + if ( ! self::supports_geolite2() ) { + $logger->notice( 'Requires PHP 5.4 to be able to download MaxMind GeoLite2 database', array( 'source' => 'geolocation' ) ); + return; + } + + require_once ABSPATH . 'wp-admin/includes/file.php'; + + $upload_dir = wp_upload_dir(); + $tmp_database_path = download_url( self::GEOLITE2_DB ); + + if ( ! is_wp_error( $tmp_database_path ) ) { + try { + // GeoLite2 database name. + $database = 'GeoLite2-Country.mmdb'; + $dest_path = trailingslashit( $upload_dir['basedir'] ) . $database; + + // Extract files with PharData. Tool built into PHP since 5.3. + $file = new PharData( $tmp_database_path ); // phpcs:ignore PHPCompatibility.PHP.NewClasses.phardataFound + $file_path = trailingslashit( $file->current()->getFileName() ) . $database; + + // Extract under uploads directory. + $file->extractTo( $upload_dir['basedir'], $file_path, true ); + + // Remove old database. + @unlink( $dest_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink + + // Copy database and delete tmp directories. + @rename( trailingslashit( $upload_dir['basedir'] ) . $file_path, $dest_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_rename + @rmdir( trailingslashit( $upload_dir['basedir'] ) . $file->current()->getFileName() ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.directory_rmdir + + // Set correct file permission. + @chmod( $dest_path, 0644 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.chmod_chmod + } catch ( Exception $e ) { + $logger->notice( $e->getMessage(), array( 'source' => 'geolocation' ) ); + + // Reschedule download of DB. + wp_clear_scheduled_hook( 'woocommerce_geoip_updater' ); + wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'woocommerce_geoip_updater' ); + } + + @unlink( $tmp_database_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink + } else { + $logger->notice( + 'Unable to download GeoIP Database: ' . $tmp_database_path->get_error_message(), + array( 'source' => 'geolocation' ) + ); + } + } + + /** + * Use MAXMIND GeoLite database to geolocation the user. + * + * @param string $ip_address IP address. + * @param string $database Database path. + * @return string + */ + private static function geolocate_via_db( $ip_address, $database ) { + if ( ! class_exists( 'WC_Geolite_Integration', false ) ) { + require_once WC_ABSPATH . 'includes/class-wc-geolite-integration.php'; + } + + $geolite = new WC_Geolite_Integration( $database ); + + return $geolite->get_country_iso( $ip_address ); + } + + /** + * Use APIs to Geolocate the user. + * + * Geolocation APIs can be added through the use of the woocommerce_geolocation_geoip_apis filter. + * Provide a name=>value pair for service-slug=>endpoint. + * + * If APIs are defined, one will be chosen at random to fulfil the request. After completing, the result + * will be cached in a transient. + * + * @param string $ip_address IP address. + * @return string + */ + private static function geolocate_via_api( $ip_address ) { + $country_code = get_transient( 'geoip_' . $ip_address ); + + if ( false === $country_code ) { + $geoip_services = apply_filters( 'woocommerce_geolocation_geoip_apis', self::$geoip_apis ); + + if ( empty( $geoip_services ) ) { + return ''; + } + + $geoip_services_keys = array_keys( $geoip_services ); + + shuffle( $geoip_services_keys ); + + foreach ( $geoip_services_keys as $service_name ) { + $service_endpoint = $geoip_services[ $service_name ]; + $response = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) ); + + if ( ! is_wp_error( $response ) && $response['body'] ) { + switch ( $service_name ) { + case 'ipinfo.io': + $data = json_decode( $response['body'] ); + $country_code = isset( $data->country ) ? $data->country : ''; + break; + case 'ip-api.com': + $data = json_decode( $response['body'] ); + $country_code = isset( $data->countryCode ) ? $data->countryCode : ''; // @codingStandardsIgnoreLine + break; + default: + $country_code = apply_filters( 'woocommerce_geolocation_geoip_response_' . $service_name, '', $response['body'] ); + break; + } + + $country_code = sanitize_text_field( strtoupper( $country_code ) ); + + if ( $country_code ) { + break; + } + } + } + + set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS ); + } + + return $country_code; + } +} + +WC_Geolocation::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-https.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-https.php new file mode 100644 index 0000000..de3e6f4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-https.php @@ -0,0 +1,138 @@ + array( + 'wc_update_200_file_paths', + 'wc_update_200_permalinks', + 'wc_update_200_subcat_display', + 'wc_update_200_taxrates', + 'wc_update_200_line_items', + 'wc_update_200_images', + 'wc_update_200_db_version', + ), + '2.0.9' => array( + 'wc_update_209_brazillian_state', + 'wc_update_209_db_version', + ), + '2.1.0' => array( + 'wc_update_210_remove_pages', + 'wc_update_210_file_paths', + 'wc_update_210_db_version', + ), + '2.2.0' => array( + 'wc_update_220_shipping', + 'wc_update_220_order_status', + 'wc_update_220_variations', + 'wc_update_220_attributes', + 'wc_update_220_db_version', + ), + '2.3.0' => array( + 'wc_update_230_options', + 'wc_update_230_db_version', + ), + '2.4.0' => array( + 'wc_update_240_options', + 'wc_update_240_shipping_methods', + 'wc_update_240_api_keys', + 'wc_update_240_refunds', + 'wc_update_240_db_version', + ), + '2.4.1' => array( + 'wc_update_241_variations', + 'wc_update_241_db_version', + ), + '2.5.0' => array( + 'wc_update_250_currency', + 'wc_update_250_db_version', + ), + '2.6.0' => array( + 'wc_update_260_options', + 'wc_update_260_termmeta', + 'wc_update_260_zones', + 'wc_update_260_zone_methods', + 'wc_update_260_refunds', + 'wc_update_260_db_version', + ), + '3.0.0' => array( + 'wc_update_300_grouped_products', + 'wc_update_300_settings', + 'wc_update_300_product_visibility', + 'wc_update_300_db_version', + ), + '3.1.0' => array( + 'wc_update_310_downloadable_products', + 'wc_update_310_old_comments', + 'wc_update_310_db_version', + ), + '3.1.2' => array( + 'wc_update_312_shop_manager_capabilities', + 'wc_update_312_db_version', + ), + '3.2.0' => array( + 'wc_update_320_mexican_states', + 'wc_update_320_db_version', + ), + '3.3.0' => array( + 'wc_update_330_image_options', + 'wc_update_330_webhooks', + 'wc_update_330_product_stock_status', + 'wc_update_330_set_default_product_cat', + 'wc_update_330_clear_transients', + 'wc_update_330_set_paypal_sandbox_credentials', + 'wc_update_330_db_version', + ), + '3.4.0' => array( + 'wc_update_340_states', + 'wc_update_340_state', + 'wc_update_340_last_active', + 'wc_update_340_db_version', + ), + ); + + /** + * Background update class. + * + * @var object + */ + private static $background_updater; + + /** + * Hook in tabs. + */ + public static function init() { + add_action( 'init', array( __CLASS__, 'check_version' ), 5 ); + add_action( 'init', array( __CLASS__, 'init_background_updater' ), 5 ); + add_action( 'admin_init', array( __CLASS__, 'install_actions' ) ); + add_filter( 'plugin_action_links_' . WC_PLUGIN_BASENAME, array( __CLASS__, 'plugin_action_links' ) ); + add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); + add_filter( 'wpmu_drop_tables', array( __CLASS__, 'wpmu_drop_tables' ) ); + add_filter( 'cron_schedules', array( __CLASS__, 'cron_schedules' ) ); + add_action( 'woocommerce_plugin_background_installer', array( __CLASS__, 'background_installer' ), 10, 2 ); + add_action( 'woocommerce_theme_background_installer', array( __CLASS__, 'theme_background_installer' ), 10, 1 ); + } + + /** + * Init background updates + */ + public static function init_background_updater() { + include_once dirname( __FILE__ ) . '/class-wc-background-updater.php'; + self::$background_updater = new WC_Background_Updater(); + } + + /** + * Check WooCommerce version and run the updater is required. + * + * This check is done on all requests and runs if the versions do not match. + */ + public static function check_version() { + if ( ! defined( 'IFRAME_REQUEST' ) && version_compare( get_option( 'woocommerce_version' ), WC()->version, '<' ) ) { + self::install(); + do_action( 'woocommerce_updated' ); + } + } + + /** + * Install actions when a update button is clicked within the admin area. + * + * This function is hooked into admin_init to affect admin only. + */ + public static function install_actions() { + if ( ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok. + self::update(); + WC_Admin_Notices::add_notice( 'update' ); + } + if ( ! empty( $_GET['force_update_woocommerce'] ) ) { // WPCS: input var ok, CSRF ok. + $blog_id = get_current_blog_id(); + do_action( 'wp_' . $blog_id . '_wc_updater_cron' ); + wp_safe_redirect( admin_url( 'admin.php?page=wc-settings' ) ); + exit; + } + } + + /** + * Install WC. + */ + public static function install() { + if ( ! is_blog_installed() ) { + return; + } + + // Check if we are not already running this routine. + if ( 'yes' === get_transient( 'wc_installing' ) ) { + return; + } + + // If we made it till here nothing is running yet, lets set the transient now. + set_transient( 'wc_installing', 'yes', MINUTE_IN_SECONDS * 10 ); + wc_maybe_define_constant( 'WC_INSTALLING', true ); + + self::remove_admin_notices(); + self::create_options(); + self::create_tables(); + self::create_roles(); + self::setup_environment(); + self::create_terms(); + self::create_cron_jobs(); + self::create_files(); + self::maybe_enable_setup_wizard(); + self::update_wc_version(); + self::maybe_update_db_version(); + + delete_transient( 'wc_installing' ); + + do_action( 'woocommerce_flush_rewrite_rules' ); + do_action( 'woocommerce_installed' ); + } + + /** + * Reset any notices added to admin. + * + * @since 3.2.0 + */ + private static function remove_admin_notices() { + include_once dirname( __FILE__ ) . '/admin/class-wc-admin-notices.php'; + WC_Admin_Notices::remove_all_notices(); + } + + /** + * Setup WC environment - post types, taxonomies, endpoints. + * + * @since 3.2.0 + */ + private static function setup_environment() { + WC_Post_types::register_post_types(); + WC_Post_types::register_taxonomies(); + WC()->query->init_query_vars(); + WC()->query->add_endpoints(); + WC_API::add_endpoint(); + WC_Auth::add_endpoint(); + } + + /** + * Is this a brand new WC install? + * + * @since 3.2.0 + * @return boolean + */ + private static function is_new_install() { + return is_null( get_option( 'woocommerce_version', null ) ) && is_null( get_option( 'woocommerce_db_version', null ) ); + } + + /** + * Is a DB update needed? + * + * @since 3.2.0 + * @return boolean + */ + private static function needs_db_update() { + $current_db_version = get_option( 'woocommerce_db_version', null ); + $updates = self::get_db_update_callbacks(); + + return ! is_null( $current_db_version ) && version_compare( $current_db_version, max( array_keys( $updates ) ), '<' ); + } + + /** + * See if we need the wizard or not. + * + * @since 3.2.0 + */ + private static function maybe_enable_setup_wizard() { + if ( apply_filters( 'woocommerce_enable_setup_wizard', self::is_new_install() ) ) { + WC_Admin_Notices::add_notice( 'install' ); + set_transient( '_wc_activation_redirect', 1, 30 ); + } + } + + /** + * See if we need to show or run database updates during install. + * + * @since 3.2.0 + */ + private static function maybe_update_db_version() { + if ( self::needs_db_update() ) { + if ( apply_filters( 'woocommerce_enable_auto_update_db', false ) ) { + self::init_background_updater(); + self::update(); + } else { + WC_Admin_Notices::add_notice( 'update' ); + } + } else { + self::update_db_version(); + } + } + + /** + * Update WC version to current. + */ + private static function update_wc_version() { + delete_option( 'woocommerce_version' ); + add_option( 'woocommerce_version', WC()->version ); + } + + /** + * Get list of DB update callbacks. + * + * @since 3.0.0 + * @return array + */ + public static function get_db_update_callbacks() { + return self::$db_updates; + } + + /** + * Push all needed DB updates to the queue for processing. + */ + private static function update() { + $current_db_version = get_option( 'woocommerce_db_version' ); + $logger = wc_get_logger(); + $update_queued = false; + + foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) { + if ( version_compare( $current_db_version, $version, '<' ) ) { + foreach ( $update_callbacks as $update_callback ) { + $logger->info( + sprintf( 'Queuing %s - %s', $version, $update_callback ), + array( 'source' => 'wc_db_updates' ) + ); + self::$background_updater->push_to_queue( $update_callback ); + $update_queued = true; + } + } + } + + if ( $update_queued ) { + self::$background_updater->save()->dispatch(); + } + } + + /** + * Update DB version to current. + * + * @param string|null $version New WooCommerce DB version or null. + */ + public static function update_db_version( $version = null ) { + delete_option( 'woocommerce_db_version' ); + add_option( 'woocommerce_db_version', is_null( $version ) ? WC()->version : $version ); + } + + /** + * Add more cron schedules. + * + * @param array $schedules List of WP scheduled cron jobs. + * @return array + */ + public static function cron_schedules( $schedules ) { + $schedules['monthly'] = array( + 'interval' => 2635200, + 'display' => __( 'Monthly', 'woocommerce' ), + ); + return $schedules; + } + + /** + * Create cron jobs (clear them first). + */ + private static function create_cron_jobs() { + wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' ); + wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' ); + wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' ); + wp_clear_scheduled_hook( 'woocommerce_cleanup_personal_data' ); + wp_clear_scheduled_hook( 'woocommerce_cleanup_logs' ); + wp_clear_scheduled_hook( 'woocommerce_geoip_updater' ); + wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' ); + + $ve = get_option( 'gmt_offset' ) > 0 ? '-' : '+'; + + wp_schedule_event( strtotime( '00:00 tomorrow ' . $ve . absint( get_option( 'gmt_offset' ) ) . ' HOURS' ), 'daily', 'woocommerce_scheduled_sales' ); + + $held_duration = get_option( 'woocommerce_hold_stock_minutes', '60' ); + + if ( '' !== $held_duration ) { + wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' ); + } + + wp_schedule_event( time(), 'daily', 'woocommerce_cleanup_personal_data' ); + wp_schedule_event( time() + ( 3 * HOUR_IN_SECONDS ), 'daily', 'woocommerce_cleanup_logs' ); + wp_schedule_event( time() + ( 6 * HOUR_IN_SECONDS ), 'twicedaily', 'woocommerce_cleanup_sessions' ); + wp_schedule_event( strtotime( 'first tuesday of next month' ), 'monthly', 'woocommerce_geoip_updater' ); + wp_schedule_event( time() + 10, apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' ), 'woocommerce_tracker_send_event' ); + + // Trigger GeoLite2 database download after 5 minutes. + wp_schedule_single_event( time() + ( MINUTE_IN_SECONDS * 5 ), 'woocommerce_geoip_updater' ); + } + + /** + * Create pages that the plugin relies on, storing page IDs in variables. + */ + public static function create_pages() { + include_once dirname( __FILE__ ) . '/admin/wc-admin-functions.php'; + + $pages = apply_filters( + 'woocommerce_create_pages', array( + 'shop' => array( + 'name' => _x( 'shop', 'Page slug', 'woocommerce' ), + 'title' => _x( 'Shop', 'Page title', 'woocommerce' ), + 'content' => '', + ), + 'cart' => array( + 'name' => _x( 'cart', 'Page slug', 'woocommerce' ), + 'title' => _x( 'Cart', 'Page title', 'woocommerce' ), + 'content' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']', + ), + 'checkout' => array( + 'name' => _x( 'checkout', 'Page slug', 'woocommerce' ), + 'title' => _x( 'Checkout', 'Page title', 'woocommerce' ), + 'content' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']', + ), + 'myaccount' => array( + 'name' => _x( 'my-account', 'Page slug', 'woocommerce' ), + 'title' => _x( 'My account', 'Page title', 'woocommerce' ), + 'content' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']', + ), + ) + ); + + foreach ( $pages as $key => $page ) { + wc_create_page( esc_sql( $page['name'] ), 'woocommerce_' . $key . '_page_id', $page['title'], $page['content'], ! empty( $page['parent'] ) ? wc_get_page_id( $page['parent'] ) : '' ); + } + } + + /** + * Default options. + * + * Sets up the default options used on the settings page. + */ + private static function create_options() { + // Include settings so that we can run through defaults. + include_once dirname( __FILE__ ) . '/admin/class-wc-admin-settings.php'; + + $settings = WC_Admin_Settings::get_settings_pages(); + + foreach ( $settings as $section ) { + if ( ! method_exists( $section, 'get_settings' ) ) { + continue; + } + $subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) ); + + foreach ( $subsections as $subsection ) { + foreach ( $section->get_settings( $subsection ) as $value ) { + if ( isset( $value['default'] ) && isset( $value['id'] ) ) { + $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true; + add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) ); + } + } + } + } + + // Define other defaults if not in setting screens. + add_option( 'woocommerce_single_image_width', '600', '', 'yes' ); + add_option( 'woocommerce_thumbnail_image_width', '300', '', 'yes' ); + add_option( 'woocommerce_checkout_highlight_required_fields', 'yes', '', 'yes' ); + add_option( 'woocommerce_demo_store', 'no', '', 'no' ); + } + + /** + * Add the default terms for WC taxonomies - product types and order statuses. Modify this at your own risk. + */ + public static function create_terms() { + $taxonomies = array( + 'product_type' => array( + 'simple', + 'grouped', + 'variable', + 'external', + ), + 'product_visibility' => array( + 'exclude-from-search', + 'exclude-from-catalog', + 'featured', + 'outofstock', + 'rated-1', + 'rated-2', + 'rated-3', + 'rated-4', + 'rated-5', + ), + ); + + foreach ( $taxonomies as $taxonomy => $terms ) { + foreach ( $terms as $term ) { + if ( ! get_term_by( 'name', $term, $taxonomy ) ) { // @codingStandardsIgnoreLine. + wp_insert_term( $term, $taxonomy ); + } + } + } + + $woocommerce_default_category = (int) get_option( 'default_product_cat', 0 ); + + if ( ! $woocommerce_default_category || ! term_exists( $woocommerce_default_category, 'product_cat' ) ) { + $default_product_cat_id = 0; + $default_product_cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug', 'woocommerce' ) ); + $default_product_cat = get_term_by( 'slug', $default_product_cat_slug, 'product_cat' ); // @codingStandardsIgnoreLine. + + if ( $default_product_cat ) { + $default_product_cat_id = absint( $default_product_cat->term_taxonomy_id ); + } else { + $result = wp_insert_term( _x( 'Uncategorized', 'Default category slug', 'woocommerce' ), 'product_cat', array( 'slug' => $default_product_cat_slug ) ); + + if ( ! is_wp_error( $result ) && ! empty( $result['term_taxonomy_id'] ) ) { + $default_product_cat_id = absint( $result['term_taxonomy_id'] ); + } + } + + if ( $default_product_cat_id ) { + update_option( 'default_product_cat', $default_product_cat_id ); + } + } + } + + /** + * Set up the database tables which the plugin needs to function. + * + * Tables: + * woocommerce_attribute_taxonomies - Table for storing attribute taxonomies - these are user defined + * woocommerce_termmeta - Term meta table - sadly WordPress does not have termmeta so we need our own + * woocommerce_downloadable_product_permissions - Table for storing user and guest download permissions. + * KEY(order_id, product_id, download_id) used for organizing downloads on the My Account page + * woocommerce_order_items - Order line items are stored in a table to make them easily queryable for reports + * woocommerce_order_itemmeta - Order line item meta is stored in a table for storing extra data. + * woocommerce_tax_rates - Tax Rates are stored inside 2 tables making tax queries simple and efficient. + * woocommerce_tax_rate_locations - Each rate can be applied to more than one postcode/city hence the second table. + */ + private static function create_tables() { + global $wpdb; + + $wpdb->hide_errors(); + + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; + + /** + * Before updating with DBDELTA, remove any primary keys which could be + * modified due to schema updates. + */ + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_downloadable_product_permissions';" ) ) { + if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}woocommerce_downloadable_product_permissions` LIKE 'permission_id';" ) ) { + $wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions DROP PRIMARY KEY, ADD `permission_id` BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT;" ); + } + } + + dbDelta( self::get_schema() ); + + $index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->comments} WHERE column_name = 'comment_type' and key_name = 'woo_idx_comment_type'" ); + + if ( is_null( $index_exists ) ) { + // Add an index to the field comment_type to improve the response time of the query + // used by WC_Comments::wp_count_comments() to get the number of comments by type. + $wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" ); + } + + // Get tables data types and check it matches before adding constraint. + $download_log_columns = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}wc_download_log WHERE Field = 'permission_id'", ARRAY_A ); + $download_log_column_type = ''; + if ( isset( $download_log_columns[0]['Type'] ) ) { + $download_log_column_type = $download_log_columns[0]['Type']; + } + + $download_permissions_columns = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE Field = 'permission_id'", ARRAY_A ); + $download_permissions_column_type = ''; + if ( isset( $download_permissions_columns[0]['Type'] ) ) { + $download_permissions_column_type = $download_permissions_columns[0]['Type']; + } + + // Add constraint to download logs if the columns matches. + if ( ! empty( $download_permissions_column_type ) && ! empty( $download_log_column_type ) && $download_permissions_column_type === $download_log_column_type ) { + $wpdb->query( "ALTER TABLE {$wpdb->prefix}wc_download_log ADD FOREIGN KEY (permission_id) REFERENCES {$wpdb->prefix}woocommerce_downloadable_product_permissions(permission_id) ON DELETE CASCADE" ); + } + } + + /** + * Get Table schema. + * + * See https://github.com/woocommerce/woocommerce/wiki/Database-Description/ + * + * A note on indexes; Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that. + * As of WordPress 4.2, however, we moved to utf8mb4, which uses 4 bytes per character. This means that an index which + * used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters. + * + * Changing indexes may cause duplicate index notices in logs due to https://core.trac.wordpress.org/ticket/34870 but dropping + * indexes first causes too much load on some servers/larger DB. + * + * When adding or removing a table, make sure to update the list of tables in WC_Install::get_tables(). + * + * @return string + */ + private static function get_schema() { + global $wpdb; + + $collate = ''; + + if ( $wpdb->has_cap( 'collation' ) ) { + $collate = $wpdb->get_charset_collate(); + } + + $tables = " +CREATE TABLE {$wpdb->prefix}woocommerce_sessions ( + session_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + session_key char(32) NOT NULL, + session_value longtext NOT NULL, + session_expiry BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (session_key), + UNIQUE KEY session_id (session_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_api_keys ( + key_id BIGINT UNSIGNED NOT NULL auto_increment, + user_id BIGINT UNSIGNED NOT NULL, + description varchar(200) NULL, + permissions varchar(10) NOT NULL, + consumer_key char(64) NOT NULL, + consumer_secret char(43) NOT NULL, + nonces longtext NULL, + truncated_key char(7) NOT NULL, + last_access datetime NULL default null, + PRIMARY KEY (key_id), + KEY consumer_key (consumer_key), + KEY consumer_secret (consumer_secret) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_attribute_taxonomies ( + attribute_id BIGINT UNSIGNED NOT NULL auto_increment, + attribute_name varchar(200) NOT NULL, + attribute_label varchar(200) NULL, + attribute_type varchar(20) NOT NULL, + attribute_orderby varchar(20) NOT NULL, + attribute_public int(1) NOT NULL DEFAULT 1, + PRIMARY KEY (attribute_id), + KEY attribute_name (attribute_name(20)) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions ( + permission_id BIGINT UNSIGNED NOT NULL auto_increment, + download_id varchar(36) NOT NULL, + product_id BIGINT UNSIGNED NOT NULL, + order_id BIGINT UNSIGNED NOT NULL DEFAULT 0, + order_key varchar(200) NOT NULL, + user_email varchar(200) NOT NULL, + user_id BIGINT UNSIGNED NULL, + downloads_remaining varchar(9) NULL, + access_granted datetime NOT NULL default '0000-00-00 00:00:00', + access_expires datetime NULL default null, + download_count BIGINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (permission_id), + KEY download_order_key_product (product_id,order_id,order_key(16),download_id), + KEY download_order_product (download_id,order_id,product_id), + KEY order_id (order_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_order_items ( + order_item_id BIGINT UNSIGNED NOT NULL auto_increment, + order_item_name TEXT NOT NULL, + order_item_type varchar(200) NOT NULL DEFAULT '', + order_id BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (order_item_id), + KEY order_id (order_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_order_itemmeta ( + meta_id BIGINT UNSIGNED NOT NULL auto_increment, + order_item_id BIGINT UNSIGNED NOT NULL, + meta_key varchar(255) default NULL, + meta_value longtext NULL, + PRIMARY KEY (meta_id), + KEY order_item_id (order_item_id), + KEY meta_key (meta_key(32)) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_tax_rates ( + tax_rate_id BIGINT UNSIGNED NOT NULL auto_increment, + tax_rate_country varchar(2) NOT NULL DEFAULT '', + tax_rate_state varchar(200) NOT NULL DEFAULT '', + tax_rate varchar(8) NOT NULL DEFAULT '', + tax_rate_name varchar(200) NOT NULL DEFAULT '', + tax_rate_priority BIGINT UNSIGNED NOT NULL, + tax_rate_compound int(1) NOT NULL DEFAULT 0, + tax_rate_shipping int(1) NOT NULL DEFAULT 1, + tax_rate_order BIGINT UNSIGNED NOT NULL, + tax_rate_class varchar(200) NOT NULL DEFAULT '', + PRIMARY KEY (tax_rate_id), + KEY tax_rate_country (tax_rate_country), + KEY tax_rate_state (tax_rate_state(2)), + KEY tax_rate_class (tax_rate_class(10)), + KEY tax_rate_priority (tax_rate_priority) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations ( + location_id BIGINT UNSIGNED NOT NULL auto_increment, + location_code varchar(200) NOT NULL, + tax_rate_id BIGINT UNSIGNED NOT NULL, + location_type varchar(40) NOT NULL, + PRIMARY KEY (location_id), + KEY tax_rate_id (tax_rate_id), + KEY location_type_code (location_type(10),location_code(20)) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zones ( + zone_id BIGINT UNSIGNED NOT NULL auto_increment, + zone_name varchar(200) NOT NULL, + zone_order BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (zone_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_locations ( + location_id BIGINT UNSIGNED NOT NULL auto_increment, + zone_id BIGINT UNSIGNED NOT NULL, + location_code varchar(200) NOT NULL, + location_type varchar(40) NOT NULL, + PRIMARY KEY (location_id), + KEY location_id (location_id), + KEY location_type_code (location_type(10),location_code(20)) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods ( + zone_id BIGINT UNSIGNED NOT NULL, + instance_id BIGINT UNSIGNED NOT NULL auto_increment, + method_id varchar(200) NOT NULL, + method_order BIGINT UNSIGNED NOT NULL, + is_enabled tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (instance_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_payment_tokens ( + token_id BIGINT UNSIGNED NOT NULL auto_increment, + gateway_id varchar(200) NOT NULL, + token text NOT NULL, + user_id BIGINT UNSIGNED NOT NULL DEFAULT '0', + type varchar(200) NOT NULL, + is_default tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (token_id), + KEY user_id (user_id) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_payment_tokenmeta ( + meta_id BIGINT UNSIGNED NOT NULL auto_increment, + payment_token_id BIGINT UNSIGNED NOT NULL, + meta_key varchar(255) NULL, + meta_value longtext NULL, + PRIMARY KEY (meta_id), + KEY payment_token_id (payment_token_id), + KEY meta_key (meta_key(32)) +) $collate; +CREATE TABLE {$wpdb->prefix}woocommerce_log ( + log_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + timestamp datetime NOT NULL, + level smallint(4) NOT NULL, + source varchar(200) NOT NULL, + message longtext NOT NULL, + context longtext NULL, + PRIMARY KEY (log_id), + KEY level (level) +) $collate; +CREATE TABLE {$wpdb->prefix}wc_webhooks ( + webhook_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + status varchar(200) NOT NULL, + name text NOT NULL, + user_id BIGINT UNSIGNED NOT NULL, + delivery_url text NOT NULL, + secret text NOT NULL, + topic varchar(200) NOT NULL, + date_created datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + date_created_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + date_modified datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + date_modified_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + api_version smallint(4) NOT NULL, + failure_count smallint(10) NOT NULL DEFAULT '0', + pending_delivery tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (webhook_id), + KEY user_id (user_id) +) $collate; +CREATE TABLE {$wpdb->prefix}wc_download_log ( + download_log_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + timestamp datetime NOT NULL, + permission_id BIGINT UNSIGNED NOT NULL, + user_id BIGINT UNSIGNED NULL, + user_ip_address VARCHAR(100) NULL DEFAULT '', + PRIMARY KEY (download_log_id), + KEY permission_id (permission_id), + KEY timestamp (timestamp) +) $collate; + "; + + /** + * Term meta is only needed for old installs and is now @deprecated by WordPress term meta. + */ + if ( ! function_exists( 'get_term_meta' ) ) { + $tables .= " +CREATE TABLE {$wpdb->prefix}woocommerce_termmeta ( + meta_id BIGINT UNSIGNED NOT NULL auto_increment, + woocommerce_term_id BIGINT UNSIGNED NOT NULL, + meta_key varchar(255) default NULL, + meta_value longtext NULL, + PRIMARY KEY (meta_id), + KEY woocommerce_term_id (woocommerce_term_id), + KEY meta_key (meta_key(32)) +) $collate; + "; + } + + return $tables; + } + + /** + * Return a list of WooCommerce tables. Used to make sure all WC tables are dropped when uninstalling the plugin + * in a single site or multi site environment. + * + * @return array WC tables. + */ + public static function get_tables() { + global $wpdb; + + $tables = array( + "{$wpdb->prefix}wc_download_log", + "{$wpdb->prefix}wc_webhooks", + "{$wpdb->prefix}woocommerce_api_keys", + "{$wpdb->prefix}woocommerce_attribute_taxonomies", + "{$wpdb->prefix}woocommerce_downloadable_product_permissions", + "{$wpdb->prefix}woocommerce_log", + "{$wpdb->prefix}woocommerce_order_itemmeta", + "{$wpdb->prefix}woocommerce_order_items", + "{$wpdb->prefix}woocommerce_payment_tokenmeta", + "{$wpdb->prefix}woocommerce_payment_tokens", + "{$wpdb->prefix}woocommerce_sessions", + "{$wpdb->prefix}woocommerce_shipping_zone_locations", + "{$wpdb->prefix}woocommerce_shipping_zone_methods", + "{$wpdb->prefix}woocommerce_shipping_zones", + "{$wpdb->prefix}woocommerce_tax_rate_locations", + "{$wpdb->prefix}woocommerce_tax_rates", + ); + + if ( ! function_exists( 'get_term_meta' ) ) { + // This table is only needed for old installs and is now @deprecated by WordPress term meta. + $tables[] = "{$wpdb->prefix}woocommerce_termmeta"; + } + + /** + * Filter the list of known WooCommerce tables. + * + * If WooCommerce plugins need to add new tables, they can inject them here. + * + * @param array $tables An array of WooCommerce-specific database table names. + */ + $tables = apply_filters( 'woocommerce_install_get_tables', $tables ); + + return $tables; + } + + /** + * Drop WooCommerce tables. + * + * @return void + */ + public static function drop_tables() { + global $wpdb; + + $tables = self::get_tables(); + + foreach ( $tables as $table ) { + $wpdb->query( "DROP TABLE IF EXISTS {$table}" ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + } + } + + /** + * Uninstall tables when MU blog is deleted. + * + * @param array $tables List of tables that will be deleted by WP. + * @return string[] + */ + public static function wpmu_drop_tables( $tables ) { + return array_merge( $tables, self::get_tables() ); + } + + /** + * Create roles and capabilities. + */ + public static function create_roles() { + global $wp_roles; + + if ( ! class_exists( 'WP_Roles' ) ) { + return; + } + + if ( ! isset( $wp_roles ) ) { + $wp_roles = new WP_Roles(); // @codingStandardsIgnoreLine + } + + // Dummy gettext calls to get strings in the catalog. + /* translators: user role */ + _x( 'Customer', 'User role', 'woocommerce' ); + /* translators: user role */ + _x( 'Shop manager', 'User role', 'woocommerce' ); + + // Customer role. + add_role( + 'customer', + 'Customer', + array( + 'read' => true, + ) + ); + + // Shop manager role. + add_role( + 'shop_manager', + 'Shop manager', + array( + 'level_9' => true, + 'level_8' => true, + 'level_7' => true, + 'level_6' => true, + 'level_5' => true, + 'level_4' => true, + 'level_3' => true, + 'level_2' => true, + 'level_1' => true, + 'level_0' => true, + 'read' => true, + 'read_private_pages' => true, + 'read_private_posts' => true, + 'edit_users' => true, + 'edit_posts' => true, + 'edit_pages' => true, + 'edit_published_posts' => true, + 'edit_published_pages' => true, + 'edit_private_pages' => true, + 'edit_private_posts' => true, + 'edit_others_posts' => true, + 'edit_others_pages' => true, + 'publish_posts' => true, + 'publish_pages' => true, + 'delete_posts' => true, + 'delete_pages' => true, + 'delete_private_pages' => true, + 'delete_private_posts' => true, + 'delete_published_pages' => true, + 'delete_published_posts' => true, + 'delete_others_posts' => true, + 'delete_others_pages' => true, + 'manage_categories' => true, + 'manage_links' => true, + 'moderate_comments' => true, + 'upload_files' => true, + 'export' => true, + 'import' => true, + 'list_users' => true, + ) + ); + + $capabilities = self::get_core_capabilities(); + + foreach ( $capabilities as $cap_group ) { + foreach ( $cap_group as $cap ) { + $wp_roles->add_cap( 'shop_manager', $cap ); + $wp_roles->add_cap( 'administrator', $cap ); + } + } + } + + /** + * Get capabilities for WooCommerce - these are assigned to admin/shop manager during installation or reset. + * + * @return array + */ + private static function get_core_capabilities() { + $capabilities = array(); + + $capabilities['core'] = array( + 'manage_woocommerce', + 'view_woocommerce_reports', + ); + + $capability_types = array( 'product', 'shop_order', 'shop_coupon' ); + + foreach ( $capability_types as $capability_type ) { + + $capabilities[ $capability_type ] = array( + // Post type. + "edit_{$capability_type}", + "read_{$capability_type}", + "delete_{$capability_type}", + "edit_{$capability_type}s", + "edit_others_{$capability_type}s", + "publish_{$capability_type}s", + "read_private_{$capability_type}s", + "delete_{$capability_type}s", + "delete_private_{$capability_type}s", + "delete_published_{$capability_type}s", + "delete_others_{$capability_type}s", + "edit_private_{$capability_type}s", + "edit_published_{$capability_type}s", + + // Terms. + "manage_{$capability_type}_terms", + "edit_{$capability_type}_terms", + "delete_{$capability_type}_terms", + "assign_{$capability_type}_terms", + ); + } + + return $capabilities; + } + + /** + * Remove WooCommerce roles. + */ + public static function remove_roles() { + global $wp_roles; + + if ( ! class_exists( 'WP_Roles' ) ) { + return; + } + + if ( ! isset( $wp_roles ) ) { + $wp_roles = new WP_Roles(); // @codingStandardsIgnoreLine + } + + $capabilities = self::get_core_capabilities(); + + foreach ( $capabilities as $cap_group ) { + foreach ( $cap_group as $cap ) { + $wp_roles->remove_cap( 'shop_manager', $cap ); + $wp_roles->remove_cap( 'administrator', $cap ); + } + } + + remove_role( 'customer' ); + remove_role( 'shop_manager' ); + } + + /** + * Create files/directories. + */ + private static function create_files() { + // Bypass if filesystem is read-only and/or non-standard upload system is used. + if ( apply_filters( 'woocommerce_install_skip_create_files', false ) ) { + return; + } + + // Install files and folders for uploading files and prevent hotlinking. + $upload_dir = wp_upload_dir(); + $download_method = get_option( 'woocommerce_file_download_method', 'force' ); + + $files = array( + array( + 'base' => $upload_dir['basedir'] . '/woocommerce_uploads', + 'file' => 'index.html', + 'content' => '', + ), + array( + 'base' => WC_LOG_DIR, + 'file' => '.htaccess', + 'content' => 'deny from all', + ), + array( + 'base' => WC_LOG_DIR, + 'file' => 'index.html', + 'content' => '', + ), + ); + + if ( 'redirect' !== $download_method ) { + $files[] = array( + 'base' => $upload_dir['basedir'] . '/woocommerce_uploads', + 'file' => '.htaccess', + 'content' => 'deny from all', + ); + } + + foreach ( $files as $file ) { + if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { + $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen + if ( $file_handle ) { + fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite + fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose + } + } + } + } + + /** + * Show action links on the plugin screen. + * + * @param mixed $links Plugin Action links. + * @return array + */ + public static function plugin_action_links( $links ) { + $action_links = array( + 'settings' => '' . esc_html__( 'Settings', 'woocommerce' ) . '', + ); + + return array_merge( $action_links, $links ); + } + + /** + * Show row meta on the plugin screen. + * + * @param mixed $links Plugin Row Meta. + * @param mixed $file Plugin Base file. + * @return array + */ + public static function plugin_row_meta( $links, $file ) { + if ( WC_PLUGIN_BASENAME === $file ) { + $row_meta = array( + 'docs' => '' . esc_html__( 'Docs', 'woocommerce' ) . '', + 'apidocs' => '' . esc_html__( 'API docs', 'woocommerce' ) . '', + 'support' => '' . esc_html__( 'Premium support', 'woocommerce' ) . '', + ); + + return array_merge( $links, $row_meta ); + } + + return (array) $links; + } + + /** + * Get slug from path and associate it with the path. + * + * @param array $plugins Associative array of plugin files to paths. + * @param string $key Plugin relative path. Example: woocommerce/woocommerce.php. + */ + private static function associate_plugin_file( $plugins, $key ) { + $path = explode( '/', $key ); + $filename = end( $path ); + $plugins[ $filename ] = $key; + return $plugins; + } + + /** + * Install a plugin from .org in the background via a cron job (used by + * installer - opt in). + * + * @param string $plugin_to_install_id Plugin ID. + * @param array $plugin_to_install Plugin information. + * @throws Exception If unable to proceed with plugin installation. + * @since 2.6.0 + */ + public static function background_installer( $plugin_to_install_id, $plugin_to_install ) { + // Explicitly clear the event. + wp_clear_scheduled_hook( 'woocommerce_plugin_background_installer', func_get_args() ); + + if ( ! empty( $plugin_to_install['repo-slug'] ) ) { + require_once ABSPATH . 'wp-admin/includes/file.php'; + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + + WP_Filesystem(); + + $skin = new Automatic_Upgrader_Skin(); + $upgrader = new WP_Upgrader( $skin ); + $installed_plugins = array_reduce( array_keys( get_plugins() ), array( __CLASS__, 'associate_plugin_file' ), array() ); + $plugin_slug = $plugin_to_install['repo-slug']; + $plugin_file = isset( $plugin_to_install['file'] ) ? $plugin_to_install['file'] : $plugin_slug . '.php'; + $installed = false; + $activate = false; + + // See if the plugin is installed already. + if ( isset( $installed_plugins[ $plugin_file ] ) ) { + $installed = true; + $activate = ! is_plugin_active( $installed_plugins[ $plugin_file ] ); + } + + // Install this thing! + if ( ! $installed ) { + // Suppress feedback. + ob_start(); + + try { + $plugin_information = plugins_api( + 'plugin_information', + array( + 'slug' => $plugin_slug, + 'fields' => array( + 'short_description' => false, + 'sections' => false, + 'requires' => false, + 'rating' => false, + 'ratings' => false, + 'downloaded' => false, + 'last_updated' => false, + 'added' => false, + 'tags' => false, + 'homepage' => false, + 'donate_link' => false, + 'author_profile' => false, + 'author' => false, + ), + ) + ); + + if ( is_wp_error( $plugin_information ) ) { + throw new Exception( $plugin_information->get_error_message() ); + } + + $package = $plugin_information->download_link; + $download = $upgrader->download_package( $package ); + + if ( is_wp_error( $download ) ) { + throw new Exception( $download->get_error_message() ); + } + + $working_dir = $upgrader->unpack_package( $download, true ); + + if ( is_wp_error( $working_dir ) ) { + throw new Exception( $working_dir->get_error_message() ); + } + + $result = $upgrader->install_package( + array( + 'source' => $working_dir, + 'destination' => WP_PLUGIN_DIR, + 'clear_destination' => false, + 'abort_if_destination_exists' => false, + 'clear_working' => true, + 'hook_extra' => array( + 'type' => 'plugin', + 'action' => 'install', + ), + ) + ); + + if ( is_wp_error( $result ) ) { + throw new Exception( $result->get_error_message() ); + } + + $activate = true; + + } catch ( Exception $e ) { + WC_Admin_Notices::add_custom_notice( + $plugin_to_install_id . '_install_error', + sprintf( + // translators: 1: plugin name, 2: error message, 3: URL to install plugin manually. + __( '%1$s could not be installed (%2$s). Please install it manually by clicking here.', 'woocommerce' ), + $plugin_to_install['name'], + $e->getMessage(), + esc_url( admin_url( 'index.php?wc-install-plugin-redirect=' . $plugin_slug ) ) + ) + ); + } + + // Discard feedback. + ob_end_clean(); + } + + wp_clean_plugins_cache(); + + // Activate this thing. + if ( $activate ) { + try { + $result = activate_plugin( $installed ? $installed_plugins[ $plugin_file ] : $plugin_slug . '/' . $plugin_file ); + + if ( is_wp_error( $result ) ) { + throw new Exception( $result->get_error_message() ); + } + } catch ( Exception $e ) { + WC_Admin_Notices::add_custom_notice( + $plugin_to_install_id . '_install_error', + sprintf( + // translators: 1: plugin name, 2: URL to WP plugin page. + __( '%1$s was installed but could not be activated. Please activate it manually by clicking here.', 'woocommerce' ), + $plugin_to_install['name'], + admin_url( 'plugins.php' ) + ) + ); + } + } + } + } + + /** + * Install a theme from .org in the background via a cron job (used by installer - opt in). + * + * @param string $theme_slug Theme slug. + * @throws Exception If unable to proceed with theme installation. + * @since 3.1.0 + */ + public static function theme_background_installer( $theme_slug ) { + // Explicitly clear the event. + wp_clear_scheduled_hook( 'woocommerce_theme_background_installer', func_get_args() ); + + if ( ! empty( $theme_slug ) ) { + // Suppress feedback. + ob_start(); + + try { + $theme = wp_get_theme( $theme_slug ); + + if ( ! $theme->exists() ) { + require_once ABSPATH . 'wp-admin/includes/file.php'; + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . 'wp-admin/includes/theme.php'; + + WP_Filesystem(); + + $skin = new Automatic_Upgrader_Skin(); + $upgrader = new Theme_Upgrader( $skin ); + $api = themes_api( + 'theme_information', array( + 'slug' => $theme_slug, + 'fields' => array( 'sections' => false ), + ) + ); + $result = $upgrader->install( $api->download_link ); + + if ( is_wp_error( $result ) ) { + throw new Exception( $result->get_error_message() ); + } elseif ( is_wp_error( $skin->result ) ) { + throw new Exception( $skin->result->get_error_message() ); + } elseif ( is_null( $result ) ) { + throw new Exception( 'Unable to connect to the filesystem. Please confirm your credentials.' ); + } + } + + switch_theme( $theme_slug ); + } catch ( Exception $e ) { + WC_Admin_Notices::add_custom_notice( + $theme_slug . '_install_error', + sprintf( + // translators: 1: theme slug, 2: error message, 3: URL to install theme manually. + __( '%1$s could not be installed (%2$s). Please install it manually by clicking here.', 'woocommerce' ), + $theme_slug, + $e->getMessage(), + esc_url( admin_url( 'update.php?action=install-theme&theme=' . $theme_slug . '&_wpnonce=' . wp_create_nonce( 'install-theme_' . $theme_slug ) ) ) + ) + ); + } + + // Discard feedback. + ob_end_clean(); + } + } +} + +WC_Install::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-integrations.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-integrations.php new file mode 100644 index 0000000..3e89f67 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-integrations.php @@ -0,0 +1,51 @@ +integrations[ $load_integration->id ] = $load_integration; + } + } + + /** + * Return loaded integrations. + * + * @return array + */ + public function get_integrations() { + return $this->integrations; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-log-levels.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-log-levels.php new file mode 100644 index 0000000..e864340 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-log-levels.php @@ -0,0 +1,114 @@ + 800, + self::ALERT => 700, + self::CRITICAL => 600, + self::ERROR => 500, + self::WARNING => 400, + self::NOTICE => 300, + self::INFO => 200, + self::DEBUG => 100, + ); + + /** + * Severity integers mapped to level strings. + * + * This is the inverse of $level_severity. + * + * @var array + */ + protected static $severity_to_level = array( + 800 => self::EMERGENCY, + 700 => self::ALERT, + 600 => self::CRITICAL, + 500 => self::ERROR, + 400 => self::WARNING, + 300 => self::NOTICE, + 200 => self::INFO, + 100 => self::DEBUG, + ); + + + /** + * Validate a level string. + * + * @param string $level Log level. + * @return bool True if $level is a valid level. + */ + public static function is_valid_level( $level ) { + return array_key_exists( strtolower( $level ), self::$level_to_severity ); + } + + /** + * Translate level string to integer. + * + * @param string $level Log level, options: emergency|alert|critical|error|warning|notice|info|debug. + * @return int 100 (debug) - 800 (emergency) or 0 if not recognized + */ + public static function get_level_severity( $level ) { + if ( self::is_valid_level( $level ) ) { + $severity = self::$level_to_severity[ strtolower( $level ) ]; + } else { + $severity = 0; + } + return $severity; + } + + /** + * Translate severity integer to level string. + * + * @param int $severity Serevity level. + * @return bool|string False if not recognized. Otherwise string representation of level. + */ + public static function get_severity_level( $severity ) { + if ( array_key_exists( $severity, self::$severity_to_level ) ) { + return self::$severity_to_level[ $severity ]; + } else { + return false; + } + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-logger.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-logger.php new file mode 100644 index 0000000..c2fb5e1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-logger.php @@ -0,0 +1,293 @@ +' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '
      ', + 'WC_Log_Handler_Interface' + ), + '3.0' + ); + } + } + } + + if ( null !== $threshold ) { + $threshold = WC_Log_Levels::get_level_severity( $threshold ); + } elseif ( defined( 'WC_LOG_THRESHOLD' ) && WC_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) { + $threshold = WC_Log_Levels::get_level_severity( WC_LOG_THRESHOLD ); + } else { + $threshold = null; + } + + $this->handlers = $register_handlers; + $this->threshold = $threshold; + } + + /** + * Determine whether to handle or ignore log. + * + * @param string $level emergency|alert|critical|error|warning|notice|info|debug. + * @return bool True if the log should be handled. + */ + protected function should_handle( $level ) { + if ( null === $this->threshold ) { + return true; + } + return $this->threshold <= WC_Log_Levels::get_level_severity( $level ); + } + + /** + * Add a log entry. + * + * This is not the preferred method for adding log messages. Please use log() or any one of + * the level methods (debug(), info(), etc.). This method may be deprecated in the future. + * + * @param string $handle File handle. + * @param string $message Message to log. + * @param string $level Logging level. + * @return bool + */ + public function add( $handle, $message, $level = WC_Log_Levels::NOTICE ) { + $message = apply_filters( 'woocommerce_logger_add_message', $message, $handle ); + $this->log( $level, $message, array( + 'source' => $handle, + '_legacy' => true, + ) ); + wc_do_deprecated_action( 'woocommerce_log_add', array( $handle, $message ), '3.0', 'This action has been deprecated with no alternative.' ); + return true; + } + + /** + * Add a log entry. + * + * @param string $level One of the following: + * 'emergency': System is unusable. + * 'alert': Action must be taken immediately. + * 'critical': Critical conditions. + * 'error': Error conditions. + * 'warning': Warning conditions. + * 'notice': Normal but significant condition. + * 'info': Informational messages. + * 'debug': Debug-level messages. + * @param string $message Log message. + * @param array $context Optional. Additional information for log handlers. + */ + public function log( $level, $message, $context = array() ) { + if ( ! WC_Log_Levels::is_valid_level( $level ) ) { + /* translators: 1: WC_Logger::log 2: level */ + wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'woocommerce' ), 'WC_Logger::log', $level ), '3.0' ); + } + + if ( $this->should_handle( $level ) ) { + $timestamp = current_time( 'timestamp' ); + $message = apply_filters( 'woocommerce_logger_log_message', $message, $level, $context ); + + foreach ( $this->handlers as $handler ) { + $handler->handle( $timestamp, $level, $message, $context ); + } + } + } + + /** + * Adds an emergency level message. + * + * System is unusable. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function emergency( $message, $context = array() ) { + $this->log( WC_Log_Levels::EMERGENCY, $message, $context ); + } + + /** + * Adds an alert level message. + * + * Action must be taken immediately. + * Example: Entire website down, database unavailable, etc. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function alert( $message, $context = array() ) { + $this->log( WC_Log_Levels::ALERT, $message, $context ); + } + + /** + * Adds a critical level message. + * + * Critical conditions. + * Example: Application component unavailable, unexpected exception. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function critical( $message, $context = array() ) { + $this->log( WC_Log_Levels::CRITICAL, $message, $context ); + } + + /** + * Adds an error level message. + * + * Runtime errors that do not require immediate action but should typically be logged + * and monitored. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function error( $message, $context = array() ) { + $this->log( WC_Log_Levels::ERROR, $message, $context ); + } + + /** + * Adds a warning level message. + * + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things that are not + * necessarily wrong. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function warning( $message, $context = array() ) { + $this->log( WC_Log_Levels::WARNING, $message, $context ); + } + + /** + * Adds a notice level message. + * + * Normal but significant events. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function notice( $message, $context = array() ) { + $this->log( WC_Log_Levels::NOTICE, $message, $context ); + } + + /** + * Adds a info level message. + * + * Interesting events. + * Example: User logs in, SQL logs. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function info( $message, $context = array() ) { + $this->log( WC_Log_Levels::INFO, $message, $context ); + } + + /** + * Adds a debug level message. + * + * Detailed debug information. + * + * @see WC_Logger::log + * + * @param string $message Message to log. + * @param array $context Log context. + */ + public function debug( $message, $context = array() ) { + $this->log( WC_Log_Levels::DEBUG, $message, $context ); + } + + /** + * Clear entries for a chosen file/source. + * + * @param string $source Source/handle to clear. + * @return bool + */ + public function clear( $source = '' ) { + if ( ! $source ) { + return false; + } + foreach ( $this->handlers as $handler ) { + if ( is_callable( array( $handler, 'clear' ) ) ) { + $handler->clear( $source ); + } + } + return true; + } + + /** + * Clear all logs older than a defined number of days. Defaults to 30 days. + * + * @since 3.4.0 + */ + public function clear_expired_logs() { + $days = absint( apply_filters( 'woocommerce_logger_days_to_retain_logs', 30 ) ); + $timestamp = strtotime( "-{$days} days" ); + + foreach ( $this->handlers as $handler ) { + if ( is_callable( array( $handler, 'delete_logs_before_timestamp' ) ) ) { + $handler->delete_logs_before_timestamp( $timestamp ); + } + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-meta-data.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-meta-data.php new file mode 100644 index 0000000..8bb352b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-meta-data.php @@ -0,0 +1,117 @@ +current_data = $meta; + $this->apply_changes(); + } + + /** + * When converted to JSON. + * + * @return object + */ + public function jsonSerialize() { + return $this->get_data(); + } + + /** + * Merge changes with data and clear. + */ + public function apply_changes() { + $this->data = $this->current_data; + } + + /** + * Creates or updates a property in the metadata object. + * + * @param string $key Key to set. + * @param mixed $value Value to set. + */ + public function __set( $key, $value ) { + $this->current_data[ $key ] = $value; + } + + /** + * Checks if a given key exists in our data. This is called internally + * by `empty` and `isset`. + * + * @param string $key Key to check if set. + */ + public function __isset( $key ) { + return array_key_exists( $key, $this->current_data ); + } + + /** + * Returns the value of any property. + * + * @param string $key Key to get. + * @return mixed Property value or NULL if it does not exists + */ + public function __get( $key ) { + if ( array_key_exists( $key, $this->current_data ) ) { + return $this->current_data[ $key ]; + } + return null; + } + + /** + * Return data changes only. + * + * @return array + */ + public function get_changes() { + $changes = array(); + foreach ( $this->current_data as $id => $value ) { + if ( ! array_key_exists( $id, $this->data ) || $value !== $this->data[ $id ] ) { + $changes[ $id ] = $value; + } + } + return $changes; + } + + /** + * Return all data as an array. + * + * @return array + */ + public function get_data() { + return $this->data; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-factory.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-factory.php new file mode 100644 index 0000000..9286334 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-factory.php @@ -0,0 +1,131 @@ +get_order_type( $order_id ); + $order_type_data = wc_get_order_type( $order_type ); + if ( $order_type_data ) { + $classname = $order_type_data['class_name']; + } else { + $classname = false; + } + + // Filter classname so that the class can be overridden if extended. + $classname = apply_filters( 'woocommerce_order_class', $classname, $order_type, $order_id ); + + if ( ! class_exists( $classname ) ) { + return false; + } + + try { + return new $classname( $order_id ); + } catch ( Exception $e ) { + wc_caught_exception( $e, __FUNCTION__, func_get_args() ); + return false; + } + } + + /** + * Get order item. + * + * @param int $item_id Order item ID to get. + * @return WC_Order_Item|false if not found + */ + public static function get_order_item( $item_id = 0 ) { + if ( is_numeric( $item_id ) ) { + $item_type = WC_Data_Store::load( 'order-item' )->get_order_item_type( $item_id ); + $id = $item_id; + } elseif ( $item_id instanceof WC_Order_Item ) { + $item_type = $item_id->get_type(); + $id = $item_id->get_id(); + } elseif ( is_object( $item_id ) && ! empty( $item_id->order_item_type ) ) { + $id = $item_id->order_item_id; + $item_type = $item_id->order_item_type; + } else { + $item_type = false; + $id = false; + } + + if ( $id && $item_type ) { + $classname = false; + switch ( $item_type ) { + case 'line_item': + case 'product': + $classname = 'WC_Order_Item_Product'; + break; + case 'coupon': + $classname = 'WC_Order_Item_Coupon'; + break; + case 'fee': + $classname = 'WC_Order_Item_Fee'; + break; + case 'shipping': + $classname = 'WC_Order_Item_Shipping'; + break; + case 'tax': + $classname = 'WC_Order_Item_Tax'; + break; + } + + $classname = apply_filters( 'woocommerce_get_order_item_classname', $classname, $item_type, $id ); + + if ( $classname && class_exists( $classname ) ) { + try { + return new $classname( $id ); + } catch ( Exception $e ) { + return false; + } + } + } + return false; + } + + /** + * Get the order ID depending on what was passed. + * + * @since 3.0.0 + * @param mixed $order Order data to convert to an ID. + * @return int|bool false on failure + */ + public static function get_order_id( $order ) { + global $post; + + if ( false === $order && is_a( $post, 'WP_Post' ) && 'shop_order' === get_post_type( $post ) ) { + return absint( $post->ID ); + } elseif ( is_numeric( $order ) ) { + return $order; + } elseif ( $order instanceof WC_Abstract_Order ) { + return $order->get_id(); + } elseif ( ! empty( $order->ID ) ) { + return $order->ID; + } else { + return false; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-coupon.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-coupon.php new file mode 100644 index 0000000..3876e41 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-coupon.php @@ -0,0 +1,180 @@ + '', + 'discount' => 0, + 'discount_tax' => 0, + ); + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set order item name. + * + * @param string $value Coupon code. + */ + public function set_name( $value ) { + return $this->set_code( $value ); + } + + /** + * Set code. + * + * @param string $value Coupon code. + */ + public function set_code( $value ) { + $this->set_prop( 'code', wc_clean( $value ) ); + } + + /** + * Set discount amount. + * + * @param string $value Discount. + */ + public function set_discount( $value ) { + $this->set_prop( 'discount', wc_format_decimal( $value ) ); + } + + /** + * Set discounted tax amount. + * + * @param string $value Discount tax. + */ + public function set_discount_tax( $value ) { + $this->set_prop( 'discount_tax', wc_format_decimal( $value ) ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get order item type. + * + * @return string + */ + public function get_type() { + return 'coupon'; + } + + /** + * Get order item name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_name( $context = 'view' ) { + return $this->get_code( $context ); + } + + /** + * Get coupon code. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_code( $context = 'view' ) { + return $this->get_prop( 'code', $context ); + } + + /** + * Get discount amount. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_discount( $context = 'view' ) { + return $this->get_prop( 'discount', $context ); + } + + /** + * Get discounted tax amount. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * + * @return string + */ + public function get_discount_tax( $context = 'view' ) { + return $this->get_prop( 'discount_tax', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * OffsetGet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( 'discount_amount' === $offset ) { + $offset = 'discount'; + } elseif ( 'discount_amount_tax' === $offset ) { + $offset = 'discount_tax'; + } + return parent::offsetGet( $offset ); + } + + /** + * OffsetSet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( 'discount_amount' === $offset ) { + $offset = 'discount'; + } elseif ( 'discount_amount_tax' === $offset ) { + $offset = 'discount_tax'; + } + parent::offsetSet( $offset, $value ); + } + + /** + * OffsetExists for ArrayAccess. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + if ( in_array( $offset, array( 'discount_amount', 'discount_amount_tax' ), true ) ) { + return true; + } + return parent::offsetExists( $offset ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-fee.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-fee.php new file mode 100644 index 0000000..46d0edc --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-fee.php @@ -0,0 +1,333 @@ + '', + 'tax_status' => 'taxable', + 'amount' => '', + 'total' => '', + 'total_tax' => '', + 'taxes' => array( + 'total' => array(), + ), + ); + + /** + * Get item costs grouped by tax class. + * + * @since 3.2.0 + * @param WC_Order $order Order object. + * @return array + */ + protected function get_tax_class_costs( $order ) { + $order_item_tax_classes = $order->get_items_tax_classes(); + $costs = array_fill_keys( $order_item_tax_classes, 0 ); + $costs['non-taxable'] = 0; + + foreach ( $order->get_items( array( 'line_item', 'fee', 'shipping' ) ) as $item ) { + if ( 0 > $item->get_total() ) { + continue; + } + if ( 'taxable' !== $item->get_tax_status() ) { + $costs['non-taxable'] += $item->get_total(); + } elseif ( 'inherit' === $item->get_tax_class() ) { + $inherit_class = reset( $order_item_tax_classes ); + $costs[ $inherit_class ] += $item->get_total(); + } else { + $costs[ $item->get_tax_class() ] += $item->get_total(); + } + } + + return array_filter( $costs ); + } + /** + * Calculate item taxes. + * + * @since 3.2.0 + * @param array $calculate_tax_for Location data to get taxes for. Required. + * @return bool True if taxes were calculated. + */ + public function calculate_taxes( $calculate_tax_for = array() ) { + if ( ! isset( $calculate_tax_for['country'], $calculate_tax_for['state'], $calculate_tax_for['postcode'], $calculate_tax_for['city'] ) ) { + return false; + } + // Use regular calculation unless the fee is negative. + if ( 0 <= $this->get_total() ) { + return parent::calculate_taxes( $calculate_tax_for ); + } + + if ( wc_tax_enabled() && $this->get_order() ) { + // Apportion taxes to order items, shipping, and fees. + $order = $this->get_order(); + $tax_class_costs = $this->get_tax_class_costs( $order ); + $total_costs = array_sum( $tax_class_costs ); + $discount_taxes = array(); + if ( $total_costs ) { + foreach ( $tax_class_costs as $tax_class => $tax_class_cost ) { + if ( 'non-taxable' === $tax_class ) { + continue; + } + $proportion = $tax_class_cost / $total_costs; + $cart_discount_proportion = $this->get_total() * $proportion; + $calculate_tax_for['tax_class'] = $tax_class; + $tax_rates = WC_Tax::find_rates( $calculate_tax_for ); + $discount_taxes = wc_array_merge_recursive_numeric( $discount_taxes, WC_Tax::calc_tax( $cart_discount_proportion, $tax_rates ) ); + } + } + $this->set_taxes( array( 'total' => $discount_taxes ) ); + } else { + $this->set_taxes( false ); + } + + do_action( 'woocommerce_order_item_fee_after_calculate_taxes', $this, $calculate_tax_for ); + + return true; + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set fee amount. + * + * @param string $value Amount. + */ + public function set_amount( $value ) { + $this->set_prop( 'amount', wc_format_decimal( $value ) ); + } + + /** + * Set tax class. + * + * @param string $value Tax class. + */ + public function set_tax_class( $value ) { + if ( $value && ! in_array( $value, WC_Tax::get_tax_class_slugs(), true ) ) { + $this->error( 'order_item_fee_invalid_tax_class', __( 'Invalid tax class', 'woocommerce' ) ); + } + $this->set_prop( 'tax_class', $value ); + } + + /** + * Set tax_status. + * + * @param string $value Tax status. + */ + public function set_tax_status( $value ) { + if ( in_array( $value, array( 'taxable', 'none' ), true ) ) { + $this->set_prop( 'tax_status', $value ); + } else { + $this->set_prop( 'tax_status', 'taxable' ); + } + } + + /** + * Set total. + * + * @param string $amount Fee amount (do not enter negative amounts). + */ + public function set_total( $amount ) { + $this->set_prop( 'total', wc_format_decimal( $amount ) ); + } + + /** + * Set total tax. + * + * @param string $amount Amount. + */ + public function set_total_tax( $amount ) { + $this->set_prop( 'total_tax', wc_format_decimal( $amount ) ); + } + + /** + * Set taxes. + * + * This is an array of tax ID keys with total amount values. + * + * @param array $raw_tax_data Raw tax data. + */ + public function set_taxes( $raw_tax_data ) { + $raw_tax_data = maybe_unserialize( $raw_tax_data ); + $tax_data = array( + 'total' => array(), + ); + if ( ! empty( $raw_tax_data['total'] ) ) { + $tax_data['total'] = array_map( 'wc_format_decimal', $raw_tax_data['total'] ); + } + $this->set_prop( 'taxes', $tax_data ); + $this->set_total_tax( array_sum( $tax_data['total'] ) ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get fee amount. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_amount( $context = 'view' ) { + return $this->get_prop( 'amount', $context ); + } + + /** + * Get order item name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_name( $context = 'view' ) { + $name = $this->get_prop( 'name', $context ); + if ( 'view' === $context ) { + return $name ? $name : __( 'Fee', 'woocommerce' ); + } else { + return $name; + } + } + + /** + * Get order item type. + * + * @return string + */ + public function get_type() { + return 'fee'; + } + + /** + * Get tax class. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_tax_class( $context = 'view' ) { + return $this->get_prop( 'tax_class', $context ); + } + + /** + * Get tax status. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_tax_status( $context = 'view' ) { + return $this->get_prop( 'tax_status', $context ); + } + + /** + * Get total fee. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_total( $context = 'view' ) { + return $this->get_prop( 'total', $context ); + } + + /** + * Get total tax. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_total_tax( $context = 'view' ) { + return $this->get_prop( 'total_tax', $context ); + } + + /** + * Get fee taxes. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_taxes( $context = 'view' ) { + return $this->get_prop( 'taxes', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * OffsetGet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( 'line_total' === $offset ) { + $offset = 'total'; + } elseif ( 'line_tax' === $offset ) { + $offset = 'total_tax'; + } elseif ( 'line_tax_data' === $offset ) { + $offset = 'taxes'; + } + return parent::offsetGet( $offset ); + } + + /** + * OffsetSet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( 'line_total' === $offset ) { + $offset = 'total'; + } elseif ( 'line_tax' === $offset ) { + $offset = 'total_tax'; + } elseif ( 'line_tax_data' === $offset ) { + $offset = 'taxes'; + } + parent::offsetSet( $offset, $value ); + } + + /** + * OffsetExists for ArrayAccess + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + if ( in_array( $offset, array( 'line_total', 'line_tax', 'line_tax_data' ), true ) ) { + return true; + } + return parent::offsetExists( $offset ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-meta.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-meta.php new file mode 100644 index 0000000..5efeed8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-meta.php @@ -0,0 +1,215 @@ +legacy = true; + $this->meta = array_filter( (array) $item ); + return; + } + $this->item = $item; + $this->meta = array_filter( (array) $item['item_meta'] ); + $this->product = $product; + } + + /** + * Display meta in a formatted list. + * + * @param bool $flat Flat (default: false). + * @param bool $return Return (default: false). + * @param string $hideprefix Hide prefix (default: _). + * @param string $delimiter Delimiter used to separate items when $flat is true. + * @return string|void + */ + public function display( $flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n" ) { + $output = ''; + $formatted_meta = $this->get_formatted( $hideprefix ); + + if ( ! empty( $formatted_meta ) ) { + $meta_list = array(); + + foreach ( $formatted_meta as $meta ) { + if ( $flat ) { + $meta_list[] = wp_kses_post( $meta['label'] . ': ' . $meta['value'] ); + } else { + $meta_list[] = ' +
      ' . wp_kses_post( $meta['label'] ) . ':
      +
      ' . wp_kses_post( wpautop( make_clickable( $meta['value'] ) ) ) . '
      + '; + } + } + + if ( ! empty( $meta_list ) ) { + if ( $flat ) { + $output .= implode( $delimiter, $meta_list ); + } else { + $output .= '
      ' . implode( '', $meta_list ) . '
      '; + } + } + } + + $output = apply_filters( 'woocommerce_order_items_meta_display', $output, $this, $flat ); + + if ( $return ) { + return $output; + } else { + echo $output; // WPCS: XSS ok. + } + } + + /** + * Return an array of formatted item meta in format e.g. + * + * Returns: array( + * 'pa_size' => array( + * 'label' => 'Size', + * 'value' => 'Medium', + * ) + * ) + * + * @since 2.4 + * @param string $hideprefix exclude meta when key is prefixed with this, defaults to '_'. + * @return array + */ + public function get_formatted( $hideprefix = '_' ) { + if ( $this->legacy ) { + return $this->get_formatted_legacy( $hideprefix ); + } + + $formatted_meta = array(); + + if ( ! empty( $this->item['item_meta_array'] ) ) { + foreach ( $this->item['item_meta_array'] as $meta_id => $meta ) { + if ( '' === $meta->value || is_serialized( $meta->value ) || ( ! empty( $hideprefix ) && substr( $meta->key, 0, 1 ) === $hideprefix ) ) { + continue; + } + + $attribute_key = urldecode( str_replace( 'attribute_', '', $meta->key ) ); + $meta_value = $meta->value; + + // If this is a term slug, get the term's nice name. + if ( taxonomy_exists( $attribute_key ) ) { + $term = get_term_by( 'slug', $meta_value, $attribute_key ); + + if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) { + $meta_value = $term->name; + } + } + + $formatted_meta[ $meta_id ] = array( + 'key' => $meta->key, + 'label' => wc_attribute_label( $attribute_key, $this->product ), + 'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value, $meta, $this->item ), + ); + } + } + + return apply_filters( 'woocommerce_order_items_meta_get_formatted', $formatted_meta, $this ); + } + + /** + * Return an array of formatted item meta in format e.g. + * Handles @deprecated args. + * + * @param string $hideprefix Hide prefix. + * + * @return array + */ + public function get_formatted_legacy( $hideprefix = '_' ) { + if ( ! is_ajax() ) { + wc_deprecated_argument( 'WC_Order_Item_Meta::get_formatted', '2.4', 'Item Meta Data is being called with legacy arguments' ); + } + + $formatted_meta = array(); + + foreach ( $this->meta as $meta_key => $meta_values ) { + if ( empty( $meta_values ) || ( ! empty( $hideprefix ) && substr( $meta_key, 0, 1 ) === $hideprefix ) ) { + continue; + } + foreach ( (array) $meta_values as $meta_value ) { + // Skip serialised meta. + if ( is_serialized( $meta_value ) ) { + continue; + } + + $attribute_key = urldecode( str_replace( 'attribute_', '', $meta_key ) ); + + // If this is a term slug, get the term's nice name. + if ( taxonomy_exists( $attribute_key ) ) { + $term = get_term_by( 'slug', $meta_value, $attribute_key ); + if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) { + $meta_value = $term->name; + } + } + + // Unique key required. + $formatted_meta_key = $meta_key; + $loop = 0; + while ( isset( $formatted_meta[ $formatted_meta_key ] ) ) { + $loop ++; + $formatted_meta_key = $meta_key . '-' . $loop; + } + + $formatted_meta[ $formatted_meta_key ] = array( + 'key' => $meta_key, + 'label' => wc_attribute_label( $attribute_key, $this->product ), + 'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value ), + ); + } + } + + return $formatted_meta; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-product.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-product.php new file mode 100644 index 0000000..bf01b92 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-product.php @@ -0,0 +1,477 @@ + 0, + 'variation_id' => 0, + 'quantity' => 1, + 'tax_class' => '', + 'subtotal' => 0, + 'subtotal_tax' => 0, + 'total' => 0, + 'total_tax' => 0, + 'taxes' => array( + 'subtotal' => array(), + 'total' => array(), + ), + ); + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set quantity. + * + * @param int $value Quantity. + */ + public function set_quantity( $value ) { + $this->set_prop( 'quantity', wc_stock_amount( $value ) ); + } + + /** + * Set tax class. + * + * @param string $value Tax class. + */ + public function set_tax_class( $value ) { + if ( $value && ! in_array( $value, WC_Tax::get_tax_class_slugs(), true ) ) { + $this->error( 'order_item_product_invalid_tax_class', __( 'Invalid tax class', 'woocommerce' ) ); + } + $this->set_prop( 'tax_class', $value ); + } + + /** + * Set Product ID + * + * @param int $value Product ID. + */ + public function set_product_id( $value ) { + if ( $value > 0 && 'product' !== get_post_type( absint( $value ) ) ) { + $this->error( 'order_item_product_invalid_product_id', __( 'Invalid product ID', 'woocommerce' ) ); + } + $this->set_prop( 'product_id', absint( $value ) ); + } + + /** + * Set variation ID. + * + * @param int $value Variation ID. + */ + public function set_variation_id( $value ) { + if ( $value > 0 && 'product_variation' !== get_post_type( $value ) ) { + $this->error( 'order_item_product_invalid_variation_id', __( 'Invalid variation ID', 'woocommerce' ) ); + } + $this->set_prop( 'variation_id', absint( $value ) ); + } + + /** + * Line subtotal (before discounts). + * + * @param string $value Subtotal. + */ + public function set_subtotal( $value ) { + $value = wc_format_decimal( $value ); + + if ( ! is_numeric( $value ) ) { + $value = 0; + } + + $this->set_prop( 'subtotal', $value ); + } + + /** + * Line total (after discounts). + * + * @param string $value Total. + */ + public function set_total( $value ) { + $value = wc_format_decimal( $value ); + + if ( ! is_numeric( $value ) ) { + $value = 0; + } + + $this->set_prop( 'total', $value ); + + // Subtotal cannot be less than total. + if ( '' === $this->get_subtotal() || $this->get_subtotal() < $this->get_total() ) { + $this->set_subtotal( $value ); + } + } + + /** + * Line subtotal tax (before discounts). + * + * @param string $value Subtotal tax. + */ + public function set_subtotal_tax( $value ) { + $this->set_prop( 'subtotal_tax', wc_format_decimal( $value ) ); + } + + /** + * Line total tax (after discounts). + * + * @param string $value Total tax. + */ + public function set_total_tax( $value ) { + $this->set_prop( 'total_tax', wc_format_decimal( $value ) ); + } + + /** + * Set line taxes and totals for passed in taxes. + * + * @param array $raw_tax_data Raw tax data. + */ + public function set_taxes( $raw_tax_data ) { + $raw_tax_data = maybe_unserialize( $raw_tax_data ); + $tax_data = array( + 'total' => array(), + 'subtotal' => array(), + ); + if ( ! empty( $raw_tax_data['total'] ) && ! empty( $raw_tax_data['subtotal'] ) ) { + $tax_data['subtotal'] = array_map( 'wc_format_decimal', $raw_tax_data['subtotal'] ); + $tax_data['total'] = array_map( 'wc_format_decimal', $raw_tax_data['total'] ); + + // Subtotal cannot be less than total! + if ( array_sum( $tax_data['subtotal'] ) < array_sum( $tax_data['total'] ) ) { + $tax_data['subtotal'] = $tax_data['total']; + } + } + $this->set_prop( 'taxes', $tax_data ); + $this->set_total_tax( array_sum( $tax_data['total'] ) ); + $this->set_subtotal_tax( array_sum( $tax_data['subtotal'] ) ); + } + + /** + * Set variation data (stored as meta data - write only). + * + * @param array $data Key/Value pairs. + */ + public function set_variation( $data = array() ) { + if ( is_array( $data ) ) { + foreach ( $data as $key => $value ) { + $this->add_meta_data( str_replace( 'attribute_', '', $key ), $value, true ); + } + } + } + + /** + * Set properties based on passed in product object. + * + * @param WC_Product $product Product instance. + */ + public function set_product( $product ) { + if ( ! is_a( $product, 'WC_Product' ) ) { + $this->error( 'order_item_product_invalid_product', __( 'Invalid product', 'woocommerce' ) ); + } + if ( $product->is_type( 'variation' ) ) { + $this->set_product_id( $product->get_parent_id() ); + $this->set_variation_id( $product->get_id() ); + $this->set_variation( is_callable( array( $product, 'get_variation_attributes' ) ) ? $product->get_variation_attributes() : array() ); + } else { + $this->set_product_id( $product->get_id() ); + } + $this->set_name( $product->get_name() ); + $this->set_tax_class( $product->get_tax_class() ); + } + + /** + * Set meta data for backordered products. + */ + public function set_backorder_meta() { + $product = $this->get_product(); + if ( $product && $product->backorders_require_notification() && $product->is_on_backorder( $this->get_quantity() ) ) { + $this->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ), $this ), $this->get_quantity() - max( 0, $product->get_stock_quantity() ), true ); + } + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get order item type. + * + * @return string + */ + public function get_type() { + return 'line_item'; + } + + /** + * Get product ID. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return int + */ + public function get_product_id( $context = 'view' ) { + return $this->get_prop( 'product_id', $context ); + } + + /** + * Get variation ID. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return int + */ + public function get_variation_id( $context = 'view' ) { + return $this->get_prop( 'variation_id', $context ); + } + + /** + * Get quantity. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return int + */ + public function get_quantity( $context = 'view' ) { + return $this->get_prop( 'quantity', $context ); + } + + /** + * Get tax class. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_tax_class( $context = 'view' ) { + return $this->get_prop( 'tax_class', $context ); + } + + /** + * Get subtotal. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_subtotal( $context = 'view' ) { + return $this->get_prop( 'subtotal', $context ); + } + + /** + * Get subtotal tax. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_subtotal_tax( $context = 'view' ) { + return $this->get_prop( 'subtotal_tax', $context ); + } + + /** + * Get total. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_total( $context = 'view' ) { + return $this->get_prop( 'total', $context ); + } + + /** + * Get total tax. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_total_tax( $context = 'view' ) { + return $this->get_prop( 'total_tax', $context ); + } + + /** + * Get taxes. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return array + */ + public function get_taxes( $context = 'view' ) { + return $this->get_prop( 'taxes', $context ); + } + + /** + * Get the associated product. + * + * @return WC_Product|bool + */ + public function get_product() { + if ( $this->get_variation_id() ) { + $product = wc_get_product( $this->get_variation_id() ); + } else { + $product = wc_get_product( $this->get_product_id() ); + } + + // Backwards compatible filter from WC_Order::get_product_from_item(). + if ( has_filter( 'woocommerce_get_product_from_item' ) ) { + $product = apply_filters( 'woocommerce_get_product_from_item', $product, $this, $this->get_order() ); + } + + return apply_filters( 'woocommerce_order_item_product', $product, $this ); + } + + /** + * Get the Download URL. + * + * @param int $download_id Download ID. + * @return string + */ + public function get_item_download_url( $download_id ) { + $order = $this->get_order(); + + return $order ? add_query_arg( + array( + 'download_file' => $this->get_variation_id() ? $this->get_variation_id() : $this->get_product_id(), + 'order' => $order->get_order_key(), + 'email' => rawurlencode( $order->get_billing_email() ), + 'key' => $download_id, + ), trailingslashit( home_url() ) + ) : ''; + } + + /** + * Get any associated downloadable files. + * + * @return array + */ + public function get_item_downloads() { + $files = array(); + $product = $this->get_product(); + $order = $this->get_order(); + $product_id = $this->get_variation_id() ? $this->get_variation_id() : $this->get_product_id(); + $email_hash = function_exists( 'hash' ) ? hash( 'sha256', $order->get_billing_email() ) : sha1( $order->get_billing_email() ); + + if ( $product && $order && $product->is_downloadable() && $order->is_download_permitted() ) { + $data_store = WC_Data_Store::load( 'customer-download' ); + $customer_downloads = $data_store->get_downloads( + array( + 'user_email' => $order->get_billing_email(), + 'order_id' => $order->get_id(), + 'product_id' => $product_id, + ) + ); + foreach ( $customer_downloads as $customer_download ) { + $download_id = $customer_download->get_download_id(); + + if ( $product->has_file( $download_id ) ) { + $file = $product->get_file( $download_id ); + $files[ $download_id ] = $file->get_data(); + $files[ $download_id ]['downloads_remaining'] = $customer_download->get_downloads_remaining(); + $files[ $download_id ]['access_expires'] = $customer_download->get_access_expires(); + $files[ $download_id ]['download_url'] = add_query_arg( + array( + 'download_file' => $product_id, + 'order' => $order->get_order_key(), + 'uid' => $email_hash, + 'key' => $download_id, + ), trailingslashit( home_url() ) + ); + } + } + } + + return apply_filters( 'woocommerce_get_item_downloads', $files, $this, $order ); + } + + /** + * Get tax status. + * + * @return string + */ + public function get_tax_status() { + $product = $this->get_product(); + return $product ? $product->get_tax_status() : 'taxable'; + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * OffsetGet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( 'line_subtotal' === $offset ) { + $offset = 'subtotal'; + } elseif ( 'line_subtotal_tax' === $offset ) { + $offset = 'subtotal_tax'; + } elseif ( 'line_total' === $offset ) { + $offset = 'total'; + } elseif ( 'line_tax' === $offset ) { + $offset = 'total_tax'; + } elseif ( 'line_tax_data' === $offset ) { + $offset = 'taxes'; + } elseif ( 'qty' === $offset ) { + $offset = 'quantity'; + } + return parent::offsetGet( $offset ); + } + + /** + * OffsetSet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( 'line_subtotal' === $offset ) { + $offset = 'subtotal'; + } elseif ( 'line_subtotal_tax' === $offset ) { + $offset = 'subtotal_tax'; + } elseif ( 'line_total' === $offset ) { + $offset = 'total'; + } elseif ( 'line_tax' === $offset ) { + $offset = 'total_tax'; + } elseif ( 'line_tax_data' === $offset ) { + $offset = 'taxes'; + } elseif ( 'qty' === $offset ) { + $offset = 'quantity'; + } + parent::offsetSet( $offset, $value ); + } + + /** + * OffsetExists for ArrayAccess. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + if ( in_array( $offset, array( 'line_subtotal', 'line_subtotal_tax', 'line_total', 'line_tax', 'line_tax_data', 'item_meta_array', 'item_meta', 'qty' ), true ) ) { + return true; + } + return parent::offsetExists( $offset ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-shipping.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-shipping.php new file mode 100644 index 0000000..9e9ca8c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-shipping.php @@ -0,0 +1,311 @@ + '', + 'method_id' => '', + 'instance_id' => '', + 'total' => 0, + 'total_tax' => 0, + 'taxes' => array( + 'total' => array(), + ), + ); + + /** + * Calculate item taxes. + * + * @since 3.2.0 + * @param array $calculate_tax_for Location data to get taxes for. Required. + * @return bool True if taxes were calculated. + */ + public function calculate_taxes( $calculate_tax_for = array() ) { + if ( ! isset( $calculate_tax_for['country'], $calculate_tax_for['state'], $calculate_tax_for['postcode'], $calculate_tax_for['city'], $calculate_tax_for['tax_class'] ) ) { + return false; + } + if ( wc_tax_enabled() ) { + $tax_rates = WC_Tax::find_shipping_rates( $calculate_tax_for ); + $taxes = WC_Tax::calc_tax( $this->get_total(), $tax_rates, false ); + $this->set_taxes( array( 'total' => $taxes ) ); + } else { + $this->set_taxes( false ); + } + + do_action( 'woocommerce_order_item_shipping_after_calculate_taxes', $this, $calculate_tax_for ); + + return true; + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set order item name. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_name( $value ) { + $this->set_method_title( $value ); + } + + /** + * Set method title. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_method_title( $value ) { + $this->set_prop( 'name', wc_clean( $value ) ); + $this->set_prop( 'method_title', wc_clean( $value ) ); + } + + /** + * Set shipping method id. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_method_id( $value ) { + $this->set_prop( 'method_id', wc_clean( $value ) ); + } + + /** + * Set shipping instance id. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_instance_id( $value ) { + $this->set_prop( 'instance_id', wc_clean( $value ) ); + } + + /** + * Set total. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_total( $value ) { + $this->set_prop( 'total', wc_format_decimal( $value ) ); + } + + /** + * Set total tax. + * + * @param string $value Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + protected function set_total_tax( $value ) { + $this->set_prop( 'total_tax', wc_format_decimal( $value ) ); + } + + /** + * Set taxes. + * + * This is an array of tax ID keys with total amount values. + * + * @param array $raw_tax_data Value to set. + * @throws WC_Data_Exception May throw exception if data is invalid. + */ + public function set_taxes( $raw_tax_data ) { + $raw_tax_data = maybe_unserialize( $raw_tax_data ); + $tax_data = array( + 'total' => array(), + ); + if ( isset( $raw_tax_data['total'] ) ) { + $tax_data['total'] = array_map( 'wc_format_decimal', $raw_tax_data['total'] ); + } elseif ( ! empty( $raw_tax_data ) && is_array( $raw_tax_data ) ) { + // Older versions just used an array. + $tax_data['total'] = array_map( 'wc_format_decimal', $raw_tax_data ); + } + $this->set_prop( 'taxes', $tax_data ); + $this->set_total_tax( array_sum( $tax_data['total'] ) ); + } + + /** + * Set properties based on passed in shipping rate object. + * + * @param WC_Shipping_Rate $shipping_rate Shipping rate to set. + */ + public function set_shipping_rate( $shipping_rate ) { + $this->set_method_title( $shipping_rate->get_label() ); + $this->set_method_id( $shipping_rate->get_method_id() ); + $this->set_instance_id( $shipping_rate->get_instance_id() ); + $this->set_total( $shipping_rate->get_cost() ); + $this->set_taxes( $shipping_rate->get_taxes() ); + $this->set_meta_data( $shipping_rate->get_meta_data() ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get order item type. + * + * @return string + */ + public function get_type() { + return 'shipping'; + } + + /** + * Get order item name. + * + * @param string $context View or edit context. + * @return string + */ + public function get_name( $context = 'view' ) { + return $this->get_method_title( $context ); + } + + /** + * Get title. + * + * @param string $context View or edit context. + * @return string + */ + public function get_method_title( $context = 'view' ) { + $method_title = $this->get_prop( 'method_title', $context ); + if ( 'view' === $context ) { + return $method_title ? $method_title : __( 'Shipping', 'woocommerce' ); + } else { + return $method_title; + } + } + + /** + * Get method ID. + * + * @param string $context View or edit context. + * @return string + */ + public function get_method_id( $context = 'view' ) { + return $this->get_prop( 'method_id', $context ); + } + + /** + * Get instance ID. + * + * @param string $context View or edit context. + * @return string + */ + public function get_instance_id( $context = 'view' ) { + return $this->get_prop( 'instance_id', $context ); + } + + /** + * Get total cost. + * + * @param string $context View or edit context. + * @return string + */ + public function get_total( $context = 'view' ) { + return $this->get_prop( 'total', $context ); + } + + /** + * Get total tax. + * + * @param string $context View or edit context. + * @return string + */ + public function get_total_tax( $context = 'view' ) { + return $this->get_prop( 'total_tax', $context ); + } + + /** + * Get taxes. + * + * @param string $context View or edit context. + * @return array + */ + public function get_taxes( $context = 'view' ) { + return $this->get_prop( 'taxes', $context ); + } + + /** + * Get tax class. + * + * @param string $context View or edit context. + * @return string + */ + public function get_tax_class( $context = 'view' ) { + return get_option( 'woocommerce_shipping_tax_class' ); + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * Offset get: for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Key. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( 'cost' === $offset ) { + $offset = 'total'; + } + return parent::offsetGet( $offset ); + } + + /** + * Offset set: for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Key. + * @param mixed $value Value to set. + */ + public function offsetSet( $offset, $value ) { + if ( 'cost' === $offset ) { + $offset = 'total'; + } + parent::offsetSet( $offset, $value ); + } + + /** + * Offset exists: for ArrayAccess. + * + * @param string $offset Key. + * @return bool + */ + public function offsetExists( $offset ) { + if ( in_array( $offset, array( 'cost' ), true ) ) { + return true; + } + return parent::offsetExists( $offset ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-tax.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-tax.php new file mode 100644 index 0000000..20bcb74 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item-tax.php @@ -0,0 +1,267 @@ + '', + 'rate_id' => 0, + 'label' => '', + 'compound' => false, + 'tax_total' => 0, + 'shipping_tax_total' => 0, + ); + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set order item name. + * + * @param string $value Name. + */ + public function set_name( $value ) { + $this->set_rate_code( $value ); + } + + /** + * Set item name. + * + * @param string $value Rate code. + */ + public function set_rate_code( $value ) { + $this->set_prop( 'rate_code', wc_clean( $value ) ); + } + + /** + * Set item name. + * + * @param string $value Label. + */ + public function set_label( $value ) { + $this->set_prop( 'label', wc_clean( $value ) ); + } + + /** + * Set tax rate id. + * + * @param int $value Rate ID. + */ + public function set_rate_id( $value ) { + $this->set_prop( 'rate_id', absint( $value ) ); + } + + /** + * Set tax total. + * + * @param string $value Tax total. + */ + public function set_tax_total( $value ) { + $this->set_prop( 'tax_total', $value ? wc_format_decimal( $value ) : 0 ); + } + + /** + * Set shipping tax total. + * + * @param string $value Shipping tax total. + */ + public function set_shipping_tax_total( $value ) { + $this->set_prop( 'shipping_tax_total', $value ? wc_format_decimal( $value ) : 0 ); + } + + /** + * Set compound. + * + * @param bool $value If tax is compound. + */ + public function set_compound( $value ) { + $this->set_prop( 'compound', (bool) $value ); + } + + /** + * Set properties based on passed in tax rate by ID. + * + * @param int $tax_rate_id Tax rate ID. + */ + public function set_rate( $tax_rate_id ) { + $tax_rate = WC_Tax::_get_tax_rate( $tax_rate_id, OBJECT ); + + $this->set_rate_id( $tax_rate_id ); + $this->set_rate_code( WC_Tax::get_rate_code( $tax_rate ) ); + $this->set_label( WC_Tax::get_rate_label( $tax_rate ) ); + $this->set_compound( WC_Tax::is_compound( $tax_rate ) ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get order item type. + * + * @return string + */ + public function get_type() { + return 'tax'; + } + + /** + * Get rate code/name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_name( $context = 'view' ) { + return $this->get_rate_code( $context ); + } + + /** + * Get rate code/name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_rate_code( $context = 'view' ) { + return $this->get_prop( 'rate_code', $context ); + } + + /** + * Get label. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_label( $context = 'view' ) { + $label = $this->get_prop( 'label', $context ); + if ( 'view' === $context ) { + return $label ? $label : __( 'Tax', 'woocommerce' ); + } else { + return $label; + } + } + + /** + * Get tax rate ID. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return int + */ + public function get_rate_id( $context = 'view' ) { + return $this->get_prop( 'rate_id', $context ); + } + + /** + * Get tax_total + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_tax_total( $context = 'view' ) { + return $this->get_prop( 'tax_total', $context ); + } + + /** + * Get shipping_tax_total + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_shipping_tax_total( $context = 'view' ) { + return $this->get_prop( 'shipping_tax_total', $context ); + } + + /** + * Get compound. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_compound( $context = 'view' ) { + return $this->get_prop( 'compound', $context ); + } + + /** + * Is this a compound tax rate? + * + * @return boolean + */ + public function is_compound() { + return $this->get_compound(); + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * O for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + if ( 'tax_amount' === $offset ) { + $offset = 'tax_total'; + } elseif ( 'shipping_tax_amount' === $offset ) { + $offset = 'shipping_tax_total'; + } + return parent::offsetGet( $offset ); + } + + /** + * OffsetSet for ArrayAccess/Backwards compatibility. + * + * @deprecated Add deprecation notices in future release. + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( 'tax_amount' === $offset ) { + $offset = 'tax_total'; + } elseif ( 'shipping_tax_amount' === $offset ) { + $offset = 'shipping_tax_total'; + } + parent::offsetSet( $offset, $value ); + } + + /** + * OffsetExists for ArrayAccess. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + if ( in_array( $offset, array( 'tax_amount', 'shipping_tax_amount' ), true ) ) { + return true; + } + return parent::offsetExists( $offset ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item.php new file mode 100644 index 0000000..649ff5c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-item.php @@ -0,0 +1,409 @@ + 0, + 'name' => '', + ); + + /** + * Stores meta in cache for future reads. + * A group must be set to to enable caching. + * + * @var string + */ + protected $cache_group = 'order-items'; + + /** + * Meta type. This should match up with + * the types available at https://codex.wordpress.org/Function_Reference/add_metadata. + * WP defines 'post', 'user', 'comment', and 'term'. + * + * @var string + */ + protected $meta_type = 'order_item'; + + /** + * This is the name of this object type. + * + * @var string + */ + protected $object_type = 'order_item'; + + /** + * Constructor. + * + * @param int|object|array $item ID to load from the DB, or WC_Order_Item object. + */ + public function __construct( $item = 0 ) { + parent::__construct( $item ); + + if ( $item instanceof WC_Order_Item ) { + $this->set_id( $item->get_id() ); + } elseif ( is_numeric( $item ) && $item > 0 ) { + $this->set_id( $item ); + } else { + $this->set_object_read( true ); + } + + $type = 'line_item' === $this->get_type() ? 'product' : $this->get_type(); + $this->data_store = WC_Data_Store::load( 'order-item-' . $type ); + if ( $this->get_id() > 0 ) { + $this->data_store->read( $this ); + } + } + + /** + * Merge changes with data and clear. + * Overrides WC_Data::apply_changes. + * array_replace_recursive does not work well for order items because it merges taxes instead + * of replacing them. + * + * @since 3.2.0 + */ + public function apply_changes() { + if ( function_exists( 'array_replace' ) ) { + $this->data = array_replace( $this->data, $this->changes ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replaceFound + } else { // PHP 5.2 compatibility. + foreach ( $this->changes as $key => $change ) { + $this->data[ $key ] = $change; + } + } + $this->changes = array(); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get order ID this meta belongs to. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return int + */ + public function get_order_id( $context = 'view' ) { + return $this->get_prop( 'order_id', $context ); + } + + /** + * Get order item name. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_name( $context = 'view' ) { + return $this->get_prop( 'name', $context ); + } + + /** + * Get order item type. Overridden by child classes. + * + * @return string + */ + public function get_type() { + return ''; + } + + /** + * Get quantity. + * + * @return int + */ + public function get_quantity() { + return 1; + } + + /** + * Get tax status. + * + * @return string + */ + public function get_tax_status() { + return 'taxable'; + } + + /** + * Get tax class. + * + * @return string + */ + public function get_tax_class() { + return ''; + } + + /** + * Get parent order object. + * + * @return WC_Order + */ + public function get_order() { + return wc_get_order( $this->get_order_id() ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set order ID. + * + * @param int $value Order ID. + */ + public function set_order_id( $value ) { + $this->set_prop( 'order_id', absint( $value ) ); + } + + /** + * Set order item name. + * + * @param string $value Item name. + */ + public function set_name( $value ) { + $this->set_prop( 'name', wc_clean( $value ) ); + } + + /* + |-------------------------------------------------------------------------- + | Other Methods + |-------------------------------------------------------------------------- + */ + + /** + * Type checking. + * + * @param string|array $type Type. + * @return boolean + */ + public function is_type( $type ) { + return is_array( $type ) ? in_array( $this->get_type(), $type, true ) : $type === $this->get_type(); + } + + /** + * Calculate item taxes. + * + * @since 3.2.0 + * @param array $calculate_tax_for Location data to get taxes for. Required. + * @return bool True if taxes were calculated. + */ + public function calculate_taxes( $calculate_tax_for = array() ) { + if ( ! isset( $calculate_tax_for['country'], $calculate_tax_for['state'], $calculate_tax_for['postcode'], $calculate_tax_for['city'] ) ) { + return false; + } + if ( '0' !== $this->get_tax_class() && 'taxable' === $this->get_tax_status() && wc_tax_enabled() ) { + $calculate_tax_for['tax_class'] = $this->get_tax_class(); + $tax_rates = WC_Tax::find_rates( $calculate_tax_for ); + $taxes = WC_Tax::calc_tax( $this->get_total(), $tax_rates, false ); + + if ( method_exists( $this, 'get_subtotal' ) ) { + $subtotal_taxes = WC_Tax::calc_tax( $this->get_subtotal(), $tax_rates, false ); + $this->set_taxes( + array( + 'total' => $taxes, + 'subtotal' => $subtotal_taxes, + ) + ); + } else { + $this->set_taxes( array( 'total' => $taxes ) ); + } + } else { + $this->set_taxes( false ); + } + + do_action( 'woocommerce_order_item_after_calculate_taxes', $this, $calculate_tax_for ); + + return true; + } + + /* + |-------------------------------------------------------------------------- + | Meta Data Handling + |-------------------------------------------------------------------------- + */ + + /** + * Expands things like term slugs before return. + * + * @param string $hideprefix Meta data prefix, (default: _). + * @param bool $include_all Include all meta data, this stop skip items with values already in the product name. + * @return array + */ + public function get_formatted_meta_data( $hideprefix = '_', $include_all = false ) { + $formatted_meta = array(); + $meta_data = $this->get_meta_data(); + $hideprefix_length = ! empty( $hideprefix ) ? strlen( $hideprefix ) : 0; + $product = is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false; + $order_item_name = $this->get_name(); + + foreach ( $meta_data as $meta ) { + if ( empty( $meta->id ) || '' === $meta->value || ! is_scalar( $meta->value ) || ( $hideprefix_length && substr( $meta->key, 0, $hideprefix_length ) === $hideprefix ) ) { + continue; + } + + $meta->key = rawurldecode( (string) $meta->key ); + $meta->value = rawurldecode( (string) $meta->value ); + $attribute_key = str_replace( 'attribute_', '', $meta->key ); + $display_key = wc_attribute_label( $attribute_key, $product ); + $display_value = wp_kses_post( $meta->value ); + + if ( taxonomy_exists( $attribute_key ) ) { + $term = get_term_by( 'slug', $meta->value, $attribute_key ); + if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) { + $display_value = $term->name; + } + } + + // Skip items with values already in the product details area of the product name. + if ( ! $include_all && $product && $product->is_type( 'variation' ) && wc_is_attribute_in_product_name( $display_value, $order_item_name ) ) { + continue; + } + + $formatted_meta[ $meta->id ] = (object) array( + 'key' => $meta->key, + 'value' => $meta->value, + 'display_key' => apply_filters( 'woocommerce_order_item_display_meta_key', $display_key, $meta, $this ), + 'display_value' => wpautop( make_clickable( apply_filters( 'woocommerce_order_item_display_meta_value', $display_value, $meta, $this ) ) ), + ); + } + + return apply_filters( 'woocommerce_order_item_get_formatted_meta_data', $formatted_meta, $this ); + } + + /* + |-------------------------------------------------------------------------- + | Array Access Methods + |-------------------------------------------------------------------------- + | + | For backwards compatibility with legacy arrays. + | + */ + + /** + * OffsetSet for ArrayAccess. + * + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + if ( 'item_meta_array' === $offset ) { + foreach ( $value as $meta_id => $meta ) { + $this->update_meta_data( $meta->key, $meta->value, $meta_id ); + } + return; + } + + if ( array_key_exists( $offset, $this->data ) ) { + $setter = "set_$offset"; + if ( is_callable( array( $this, $setter ) ) ) { + $this->$setter( $value ); + } + return; + } + + $this->update_meta_data( $offset, $value ); + } + + /** + * OffsetUnset for ArrayAccess. + * + * @param string $offset Offset. + */ + public function offsetUnset( $offset ) { + $this->maybe_read_meta_data(); + + if ( 'item_meta_array' === $offset || 'item_meta' === $offset ) { + $this->meta_data = array(); + return; + } + + if ( array_key_exists( $offset, $this->data ) ) { + unset( $this->data[ $offset ] ); + } + + if ( array_key_exists( $offset, $this->changes ) ) { + unset( $this->changes[ $offset ] ); + } + + $this->delete_meta_data( $offset ); + } + + /** + * OffsetExists for ArrayAccess. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + $this->maybe_read_meta_data(); + if ( 'item_meta_array' === $offset || 'item_meta' === $offset || array_key_exists( $offset, $this->data ) ) { + return true; + } + return array_key_exists( $offset, wp_list_pluck( $this->meta_data, 'value', 'key' ) ) || array_key_exists( '_' . $offset, wp_list_pluck( $this->meta_data, 'value', 'key' ) ); + } + + /** + * OffsetGet for ArrayAccess. + * + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + $this->maybe_read_meta_data(); + + if ( 'item_meta_array' === $offset ) { + $return = array(); + + foreach ( $this->meta_data as $meta ) { + $return[ $meta->id ] = $meta; + } + + return $return; + } + + $meta_values = wp_list_pluck( $this->meta_data, 'value', 'key' ); + + if ( 'item_meta' === $offset ) { + return $meta_values; + } elseif ( 'type' === $offset ) { + return $this->get_type(); + } elseif ( array_key_exists( $offset, $this->data ) ) { + $getter = "get_$offset"; + if ( is_callable( array( $this, $getter ) ) ) { + return $this->$getter(); + } + } elseif ( array_key_exists( '_' . $offset, $meta_values ) ) { + // Item meta was expanded in previous versions, with prefixes removed. This maintains support. + return $meta_values[ '_' . $offset ]; + } elseif ( array_key_exists( $offset, $meta_values ) ) { + return $meta_values[ $offset ]; + } + + return null; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-query.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-query.php new file mode 100644 index 0000000..19ec371 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-query.php @@ -0,0 +1,87 @@ + array_keys( wc_get_order_statuses() ), + 'type' => wc_get_order_types( 'view-orders' ), + 'currency' => '', + 'version' => '', + 'prices_include_tax' => '', + 'date_created' => '', + 'date_modified' => '', + 'date_completed' => '', + 'date_paid' => '', + 'discount_total' => '', + 'discount_tax' => '', + 'shipping_total' => '', + 'shipping_tax' => '', + 'cart_tax' => '', + 'total' => '', + 'total_tax' => '', + 'customer' => '', + 'customer_id' => '', + 'order_key' => '', + 'billing_first_name' => '', + 'billing_last_name' => '', + 'billing_company' => '', + 'billing_address_1' => '', + 'billing_address_2' => '', + 'billing_city' => '', + 'billing_state' => '', + 'billing_postcode' => '', + 'billing_country' => '', + 'billing_email' => '', + 'billing_phone' => '', + 'shipping_first_name' => '', + 'shipping_last_name' => '', + 'shipping_company' => '', + 'shipping_address_1' => '', + 'shipping_address_2' => '', + 'shipping_city' => '', + 'shipping_state' => '', + 'shipping_postcode' => '', + 'shipping_country' => '', + 'payment_method' => '', + 'payment_method_title' => '', + 'transaction_id' => '', + 'customer_ip_address' => '', + 'customer_user_agent' => '', + 'created_via' => '', + 'customer_note' => '', + ) + ); + } + + /** + * Get orders matching the current query vars. + * + * @return array|object of WC_Order objects + */ + public function get_orders() { + $args = apply_filters( 'woocommerce_order_query_args', $this->get_query_vars() ); + $results = WC_Data_Store::load( 'order' )->query( $args ); + return apply_filters( 'woocommerce_order_query', $results, $args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order-refund.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-refund.php new file mode 100644 index 0000000..d5a8518 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order-refund.php @@ -0,0 +1,228 @@ + '', + 'reason' => '', + 'refunded_by' => 0, + 'refunded_payment' => false, + ); + + /** + * Get internal type (post type.) + * + * @return string + */ + public function get_type() { + return 'shop_order_refund'; + } + + /** + * Get status - always completed for refunds. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_status( $context = 'view' ) { + return 'completed'; + } + + /** + * Get a title for the new post type. + */ + public function get_post_title() { + // @codingStandardsIgnoreStart + return sprintf( __( 'Refund – %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) ); + // @codingStandardsIgnoreEnd + } + + /** + * Get refunded amount. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return int|float + */ + public function get_amount( $context = 'view' ) { + return $this->get_prop( 'amount', $context ); + } + + /** + * Get refund reason. + * + * @since 2.2 + * @param string $context What the value is for. Valid values are view and edit. + * @return int|float + */ + public function get_reason( $context = 'view' ) { + return $this->get_prop( 'reason', $context ); + } + + /** + * Get ID of user who did the refund. + * + * @since 3.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return int + */ + public function get_refunded_by( $context = 'view' ) { + return $this->get_prop( 'refunded_by', $context ); + } + + /** + * Return if the payment was refunded via API. + * + * @since 3.3 + * @param string $context What the value is for. Valid values are view and edit. + * @return bool + */ + public function get_refunded_payment( $context = 'view' ) { + return $this->get_prop( 'refunded_payment', $context ); + } + + /** + * Get formatted refunded amount. + * + * @since 2.4 + * @return string + */ + public function get_formatted_refund_amount() { + return apply_filters( 'woocommerce_formatted_refund_amount', wc_price( $this->get_amount(), array( 'currency' => $this->get_currency() ) ), $this ); + } + + /** + * Set refunded amount. + * + * @param string $value Value to set. + * @throws WC_Data_Exception Exception if the amount is invalid. + */ + public function set_amount( $value ) { + $this->set_prop( 'amount', wc_format_decimal( $value ) ); + } + + /** + * Set refund reason. + * + * @param string $value Value to set. + * @throws WC_Data_Exception Exception if the amount is invalid. + */ + public function set_reason( $value ) { + $this->set_prop( 'reason', $value ); + } + + /** + * Set refunded by. + * + * @param int $value Value to set. + * @throws WC_Data_Exception Exception if the amount is invalid. + */ + public function set_refunded_by( $value ) { + $this->set_prop( 'refunded_by', absint( $value ) ); + } + + /** + * Set if the payment was refunded via API. + * + * @since 3.3 + * @param bool $value Value to set. + */ + public function set_refunded_payment( $value ) { + $this->set_prop( 'refunded_payment', (bool) $value ); + } + + /** + * Magic __get method for backwards compatibility. + * + * @param string $key Value to get. + * @return mixed + */ + public function __get( $key ) { + wc_doing_it_wrong( $key, 'Refund properties should not be accessed directly.', '3.0' ); + /** + * Maps legacy vars to new getters. + */ + if ( 'reason' === $key ) { + return $this->get_reason(); + } elseif ( 'refund_amount' === $key ) { + return $this->get_amount(); + } + return parent::__get( $key ); + } + + /** + * Gets an refund from the database. + * + * @deprecated 3.0 + * @param int $id (default: 0). + * @return bool + */ + public function get_refund( $id = 0 ) { + wc_deprecated_function( 'get_refund', '3.0', 'read' ); + + if ( ! $id ) { + return false; + } + + $result = get_post( $id ); + + if ( $result ) { + $this->populate( $result ); + return true; + } + + return false; + } + + /** + * Get refund amount. + * + * @deprecated 3.0 + * @return int|float + */ + public function get_refund_amount() { + wc_deprecated_function( 'get_refund_amount', '3.0', 'get_amount' ); + return $this->get_amount(); + } + + /** + * Get refund reason. + * + * @deprecated 3.0 + * @return int|float + */ + public function get_refund_reason() { + wc_deprecated_function( 'get_refund_reason', '3.0', 'get_reason' ); + return $this->get_reason(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-order.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-order.php new file mode 100644 index 0000000..d5d3f14 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-order.php @@ -0,0 +1,1999 @@ + 0, + 'status' => '', + 'currency' => '', + 'version' => '', + 'prices_include_tax' => false, + 'date_created' => null, + 'date_modified' => null, + 'discount_total' => 0, + 'discount_tax' => 0, + 'shipping_total' => 0, + 'shipping_tax' => 0, + 'cart_tax' => 0, + 'total' => 0, + 'total_tax' => 0, + + // Order props. + 'customer_id' => 0, + 'order_key' => '', + 'billing' => array( + 'first_name' => '', + 'last_name' => '', + 'company' => '', + 'address_1' => '', + 'address_2' => '', + 'city' => '', + 'state' => '', + 'postcode' => '', + 'country' => '', + 'email' => '', + 'phone' => '', + ), + 'shipping' => array( + 'first_name' => '', + 'last_name' => '', + 'company' => '', + 'address_1' => '', + 'address_2' => '', + 'city' => '', + 'state' => '', + 'postcode' => '', + 'country' => '', + ), + 'payment_method' => '', + 'payment_method_title' => '', + 'transaction_id' => '', + 'customer_ip_address' => '', + 'customer_user_agent' => '', + 'created_via' => '', + 'customer_note' => '', + 'date_completed' => null, + 'date_paid' => null, + 'cart_hash' => '', + ); + + /** + * When a payment is complete this function is called. + * + * Most of the time this should mark an order as 'processing' so that admin can process/post the items. + * If the cart contains only downloadable items then the order is 'completed' since the admin needs to take no action. + * Stock levels are reduced at this point. + * Sales are also recorded for products. + * Finally, record the date of payment. + * + * @param string $transaction_id Optional transaction id to store in post meta. + * @return bool success + */ + public function payment_complete( $transaction_id = '' ) { + if ( ! $this->get_id() ) { // Order must exist. + return false; + } + + try { + wc_transaction_query( 'start' ); + + do_action( 'woocommerce_pre_payment_complete', $this->get_id() ); + + if ( WC()->session ) { + WC()->session->set( 'order_awaiting_payment', false ); + } + + if ( $this->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_payment_complete', array( 'on-hold', 'pending', 'failed', 'cancelled' ), $this ) ) ) { + if ( ! empty( $transaction_id ) ) { + $this->set_transaction_id( $transaction_id ); + } + if ( ! $this->get_date_paid( 'edit' ) ) { + $this->set_date_paid( current_time( 'timestamp', true ) ); + } + $this->set_status( apply_filters( 'woocommerce_payment_complete_order_status', $this->needs_processing() ? 'processing' : 'completed', $this->get_id(), $this ) ); + $this->save(); + + do_action( 'woocommerce_payment_complete', $this->get_id() ); + } else { + do_action( 'woocommerce_payment_complete_order_status_' . $this->get_status(), $this->get_id() ); + } + + wc_transaction_query( 'commit' ); + } catch ( Exception $e ) { + wc_transaction_query( 'rollback' ); + + $logger = wc_get_logger(); + $logger->error( + sprintf( 'Payment complete of order #%d failed!', $this->get_id() ), array( + 'order' => $this, + 'error' => $e, + ) + ); + $this->add_order_note( __( 'Payment complete event failed.', 'woocommerce' ) . ' ' . $e->getMessage() ); + + return false; + } + return true; + } + + /** + * Gets order total - formatted for display. + * + * @param string $tax_display Type of tax display. + * @param bool $display_refunded If should include refunded value. + * + * @return string + */ + public function get_formatted_order_total( $tax_display = '', $display_refunded = true ) { + $formatted_total = wc_price( $this->get_total(), array( 'currency' => $this->get_currency() ) ); + $order_total = $this->get_total(); + $total_refunded = $this->get_total_refunded(); + $tax_string = ''; + + // Tax for inclusive prices. + if ( wc_tax_enabled() && 'incl' === $tax_display ) { + $tax_string_array = array(); + $tax_totals = $this->get_tax_totals(); + + if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) { + foreach ( $tax_totals as $code => $tax ) { + $tax_amount = ( $total_refunded && $display_refunded ) ? wc_price( WC_Tax::round( $tax->amount - $this->get_total_tax_refunded_by_rate_id( $tax->rate_id ) ), array( 'currency' => $this->get_currency() ) ) : $tax->formatted_amount; + $tax_string_array[] = sprintf( '%s %s', $tax_amount, $tax->label ); + } + } elseif ( ! empty( $tax_totals ) ) { + $tax_amount = ( $total_refunded && $display_refunded ) ? $this->get_total_tax() - $this->get_total_tax_refunded() : $this->get_total_tax(); + $tax_string_array[] = sprintf( '%s %s', wc_price( $tax_amount, array( 'currency' => $this->get_currency() ) ), WC()->countries->tax_or_vat() ); + } + + if ( ! empty( $tax_string_array ) ) { + /* translators: %s: taxes */ + $tax_string = ' ' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . ''; + } + } + + if ( $total_refunded && $display_refunded ) { + $formatted_total = '' . strip_tags( $formatted_total ) . ' ' . wc_price( $order_total - $total_refunded, array( 'currency' => $this->get_currency() ) ) . $tax_string . ''; + } else { + $formatted_total .= $tax_string; + } + + /** + * Filter WooCommerce formatted order total. + * + * @param string $formatted_total Total to display. + * @param WC_Order $order Order data. + * @param string $tax_display Type of tax display. + * @param bool $display_refunded If should include refunded value. + */ + return apply_filters( 'woocommerce_get_formatted_order_total', $formatted_total, $this, $tax_display, $display_refunded ); + } + + /* + |-------------------------------------------------------------------------- + | CRUD methods + |-------------------------------------------------------------------------- + | + | Methods which create, read, update and delete orders from the database. + | Written in abstract fashion so that the way orders are stored can be + | changed more easily in the future. + | + | A save method is included for convenience (chooses update or create based + | on if the order exists yet). + | + */ + + /** + * Save data to the database. + * + * @since 3.0.0 + * @return int order ID + */ + public function save() { + try { + $this->maybe_set_user_billing_email(); + + if ( $this->data_store ) { + // Trigger action before saving to the DB. Allows you to adjust object props before save. + do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store ); + + if ( $this->get_id() ) { + $this->data_store->update( $this ); + } else { + $this->data_store->create( $this ); + } + } + + $this->save_items(); + $this->status_transition(); + } catch ( Exception $e ) { + $logger = wc_get_logger(); + $logger->error( + sprintf( 'Error saving order #%d', $this->get_id() ), array( + 'order' => $this, + 'error' => $e, + ) + ); + $this->add_order_note( __( 'Error saving order.', 'woocommerce' ) . ' ' . $e->getMessage() ); + } + + return $this->get_id(); + } + + /** + * Set order status. + * + * @since 3.0.0 + * @param string $new_status Status to change the order to. No internal wc- prefix is required. + * @param string $note Optional note to add. + * @param bool $manual_update Is this a manual order status change?. + * @return array + */ + public function set_status( $new_status, $note = '', $manual_update = false ) { + $result = parent::set_status( $new_status ); + + if ( true === $this->object_read && ! empty( $result['from'] ) && $result['from'] !== $result['to'] ) { + $this->status_transition = array( + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $result['from'], + 'to' => $result['to'], + 'note' => $note, + 'manual' => (bool) $manual_update, + ); + + $this->maybe_set_date_paid(); + $this->maybe_set_date_completed(); + } + + return $result; + } + + /** + * Maybe set date paid. + * + * Sets the date paid variable when transitioning to the payment complete + * order status. This is either processing or completed. This is not filtered + * to avoid infinite loops e.g. if loading an order via the filter. + * + * Date paid is set once in this manner - only when it is not already set. + * This ensures the data exists even if a gateway does not use the + * `payment_complete` method. + * + * @since 3.0.0 + */ + public function maybe_set_date_paid() { + if ( ! $this->get_date_paid( 'edit' ) && $this->has_status( apply_filters( 'woocommerce_payment_complete_order_status', $this->needs_processing() ? 'processing' : 'completed', $this->get_id(), $this ) ) ) { + $this->set_date_paid( current_time( 'timestamp', true ) ); + } + } + + /** + * Maybe set date completed. + * + * Sets the date completed variable when transitioning to completed status. + * + * @since 3.0.0 + */ + protected function maybe_set_date_completed() { + if ( $this->has_status( 'completed' ) ) { + $this->set_date_completed( current_time( 'timestamp', true ) ); + } + } + + /** + * Updates status of order immediately. + * + * @uses WC_Order::set_status() + * @param string $new_status Status to change the order to. No internal wc- prefix is required. + * @param string $note Optional note to add. + * @param bool $manual Is this a manual order status change?. + * @return bool + */ + public function update_status( $new_status, $note = '', $manual = false ) { + if ( ! $this->get_id() ) { // Order must exist. + return false; + } + + try { + wc_transaction_query( 'start' ); + + $this->set_status( $new_status, $note, $manual ); + $this->save(); + + wc_transaction_query( 'commit' ); + } catch ( Exception $e ) { + wc_transaction_query( 'rollback' ); + + $logger = wc_get_logger(); + $logger->error( + sprintf( 'Update status of order #%d failed!', $this->get_id() ), array( + 'order' => $this, + 'error' => $e, + ) + ); + $this->add_order_note( __( 'Update status event failed.', 'woocommerce' ) . ' ' . $e->getMessage() ); + return false; + } + return true; + } + + /** + * Handle the status transition. + */ + protected function status_transition() { + $status_transition = $this->status_transition; + + // Reset status transition variable. + $this->status_transition = false; + + if ( $status_transition ) { + try { + do_action( 'woocommerce_order_status_' . $status_transition['to'], $this->get_id(), $this ); + + if ( ! empty( $status_transition['from'] ) ) { + /* translators: 1: old order status 2: new order status */ + $transition_note = sprintf( __( 'Order status changed from %1$s to %2$s.', 'woocommerce' ), wc_get_order_status_name( $status_transition['from'] ), wc_get_order_status_name( $status_transition['to'] ) ); + + do_action( 'woocommerce_order_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); + do_action( 'woocommerce_order_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); + } else { + /* translators: %s: new order status */ + $transition_note = sprintf( __( 'Order status set to %s.', 'woocommerce' ), wc_get_order_status_name( $status_transition['to'] ) ); + } + + // Note the transition occurred. + $this->add_order_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); + } catch ( Exception $e ) { + $logger = wc_get_logger(); + $logger->error( + sprintf( 'Status transition of order #%d errored!', $this->get_id() ), array( + 'order' => $this, + 'error' => $e, + ) + ); + $this->add_order_note( __( 'Error during status transition.', 'woocommerce' ) . ' ' . $e->getMessage() ); + } + } + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + | + | Methods for getting data from the order object. + | + */ + + /** + * Get all class data in array format. + * + * @since 3.0.0 + * @return array + */ + public function get_data() { + return array_merge( + array( + 'id' => $this->get_id(), + ), + $this->data, + array( + 'number' => $this->get_order_number(), + 'meta_data' => $this->get_meta_data(), + 'line_items' => $this->get_items( 'line_item' ), + 'tax_lines' => $this->get_items( 'tax' ), + 'shipping_lines' => $this->get_items( 'shipping' ), + 'fee_lines' => $this->get_items( 'fee' ), + 'coupon_lines' => $this->get_items( 'coupon' ), + ) + ); + } + + /** + * Expands the shipping and billing information in the changes array. + */ + public function get_changes() { + $changed_props = parent::get_changes(); + $subs = array( 'shipping', 'billing' ); + foreach ( $subs as $sub ) { + if ( ! empty( $changed_props[ $sub ] ) ) { + foreach ( $changed_props[ $sub ] as $sub_prop => $value ) { + $changed_props[ $sub . '_' . $sub_prop ] = $value; + } + } + } + if ( isset( $changed_props['customer_note'] ) ) { + $changed_props['post_excerpt'] = $changed_props['customer_note']; + } + return $changed_props; + } + + /** + * Gets the order number for display (by default, order ID). + * + * @return string + */ + public function get_order_number() { + return (string) apply_filters( 'woocommerce_order_number', $this->get_id(), $this ); + } + + /** + * Get order key. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_order_key( $context = 'view' ) { + return $this->get_prop( 'order_key', $context ); + } + + /** + * Get customer_id. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return int + */ + public function get_customer_id( $context = 'view' ) { + return $this->get_prop( 'customer_id', $context ); + } + + /** + * Alias for get_customer_id(). + * + * @param string $context What the value is for. Valid values are view and edit. + * @return int + */ + public function get_user_id( $context = 'view' ) { + return $this->get_customer_id( $context ); + } + + /** + * Get the user associated with the order. False for guests. + * + * @return WP_User|false + */ + public function get_user() { + return $this->get_user_id() ? get_user_by( 'id', $this->get_user_id() ) : false; + } + + /** + * Gets a prop for a getter method. + * + * @since 3.0.0 + * @param string $prop Name of prop to get. + * @param string $address billing or shipping. + * @param string $context What the value is for. Valid values are view and edit. + * @return mixed + */ + protected function get_address_prop( $prop, $address = 'billing', $context = 'view' ) { + $value = null; + + if ( array_key_exists( $prop, $this->data[ $address ] ) ) { + $value = isset( $this->changes[ $address ][ $prop ] ) ? $this->changes[ $address ][ $prop ] : $this->data[ $address ][ $prop ]; + + if ( 'view' === $context ) { + $value = apply_filters( $this->get_hook_prefix() . $address . '_' . $prop, $value, $this ); + } + } + return $value; + } + + /** + * Get billing first name. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_first_name( $context = 'view' ) { + return $this->get_address_prop( 'first_name', 'billing', $context ); + } + + /** + * Get billing last name. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_last_name( $context = 'view' ) { + return $this->get_address_prop( 'last_name', 'billing', $context ); + } + + /** + * Get billing company. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_company( $context = 'view' ) { + return $this->get_address_prop( 'company', 'billing', $context ); + } + + /** + * Get billing address line 1. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_address_1( $context = 'view' ) { + return $this->get_address_prop( 'address_1', 'billing', $context ); + } + + /** + * Get billing address line 2. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_address_2( $context = 'view' ) { + return $this->get_address_prop( 'address_2', 'billing', $context ); + } + + /** + * Get billing city. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_city( $context = 'view' ) { + return $this->get_address_prop( 'city', 'billing', $context ); + } + + /** + * Get billing state. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_state( $context = 'view' ) { + return $this->get_address_prop( 'state', 'billing', $context ); + } + + /** + * Get billing postcode. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_postcode( $context = 'view' ) { + return $this->get_address_prop( 'postcode', 'billing', $context ); + } + + /** + * Get billing country. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_country( $context = 'view' ) { + return $this->get_address_prop( 'country', 'billing', $context ); + } + + /** + * Get billing email. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_email( $context = 'view' ) { + return $this->get_address_prop( 'email', 'billing', $context ); + } + + /** + * Get billing phone. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_billing_phone( $context = 'view' ) { + return $this->get_address_prop( 'phone', 'billing', $context ); + } + + /** + * Get shipping first name. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_first_name( $context = 'view' ) { + return $this->get_address_prop( 'first_name', 'shipping', $context ); + } + + /** + * Get shipping_last_name. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_last_name( $context = 'view' ) { + return $this->get_address_prop( 'last_name', 'shipping', $context ); + } + + /** + * Get shipping company. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_company( $context = 'view' ) { + return $this->get_address_prop( 'company', 'shipping', $context ); + } + + /** + * Get shipping address line 1. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_address_1( $context = 'view' ) { + return $this->get_address_prop( 'address_1', 'shipping', $context ); + } + + /** + * Get shipping address line 2. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_address_2( $context = 'view' ) { + return $this->get_address_prop( 'address_2', 'shipping', $context ); + } + + /** + * Get shipping city. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_city( $context = 'view' ) { + return $this->get_address_prop( 'city', 'shipping', $context ); + } + + /** + * Get shipping state. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_state( $context = 'view' ) { + return $this->get_address_prop( 'state', 'shipping', $context ); + } + + /** + * Get shipping postcode. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_postcode( $context = 'view' ) { + return $this->get_address_prop( 'postcode', 'shipping', $context ); + } + + /** + * Get shipping country. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_shipping_country( $context = 'view' ) { + return $this->get_address_prop( 'country', 'shipping', $context ); + } + + /** + * Get the payment method. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_payment_method( $context = 'view' ) { + return $this->get_prop( 'payment_method', $context ); + } + + /** + * Get payment method title. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_payment_method_title( $context = 'view' ) { + return $this->get_prop( 'payment_method_title', $context ); + } + + /** + * Get transaction d. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_transaction_id( $context = 'view' ) { + return $this->get_prop( 'transaction_id', $context ); + } + + /** + * Get customer ip address. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_customer_ip_address( $context = 'view' ) { + return $this->get_prop( 'customer_ip_address', $context ); + } + + /** + * Get customer user agent. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_customer_user_agent( $context = 'view' ) { + return $this->get_prop( 'customer_user_agent', $context ); + } + + /** + * Get created via. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_created_via( $context = 'view' ) { + return $this->get_prop( 'created_via', $context ); + } + + /** + * Get customer note. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_customer_note( $context = 'view' ) { + return $this->get_prop( 'customer_note', $context ); + } + + /** + * Get date completed. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return WC_DateTime|NULL object if the date is set or null if there is no date. + */ + public function get_date_completed( $context = 'view' ) { + return $this->get_prop( 'date_completed', $context ); + } + + /** + * Get date paid. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return WC_DateTime|NULL object if the date is set or null if there is no date. + */ + public function get_date_paid( $context = 'view' ) { + $date_paid = $this->get_prop( 'date_paid', $context ); + + if ( 'view' === $context && ! $date_paid && version_compare( $this->get_version( 'edit' ), '3.0', '<' ) && $this->has_status( apply_filters( 'woocommerce_payment_complete_order_status', $this->needs_processing() ? 'processing' : 'completed', $this->get_id(), $this ) ) ) { + // In view context, return a date if missing. + $date_paid = $this->get_date_created( 'edit' ); + } + return $date_paid; + } + + /** + * Get cart hash. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_cart_hash( $context = 'view' ) { + return $this->get_prop( 'cart_hash', $context ); + } + + /** + * Returns the requested address in raw, non-formatted way. + * Note: Merges raw data with get_prop data so changes are returned too. + * + * @since 2.4.0 + * @param string $type Billing or shipping. Anything else besides 'billing' will return shipping address. + * @return array The stored address after filter. + */ + public function get_address( $type = 'billing' ) { + return apply_filters( 'woocommerce_get_order_address', array_merge( $this->data[ $type ], $this->get_prop( $type, 'view' ) ), $type, $this ); + } + + /** + * Get a formatted shipping address for the order. + * + * @return string + */ + public function get_shipping_address_map_url() { + $address = $this->get_address( 'shipping' ); + + // Remove name and company before generate the Google Maps URL. + unset( $address['first_name'], $address['last_name'], $address['company'] ); + + $address = apply_filters( 'woocommerce_shipping_address_map_url_parts', $address, $this ); + + return apply_filters( 'woocommerce_shipping_address_map_url', 'https://maps.google.com/maps?&q=' . rawurlencode( implode( ', ', $address ) ) . '&z=16', $this ); + } + + /** + * Get a formatted billing full name. + * + * @return string + */ + public function get_formatted_billing_full_name() { + /* translators: 1: first name 2: last name */ + return sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $this->get_billing_first_name(), $this->get_billing_last_name() ); + } + + /** + * Get a formatted shipping full name. + * + * @return string + */ + public function get_formatted_shipping_full_name() { + /* translators: 1: first name 2: last name */ + return sprintf( _x( '%1$s %2$s', 'full name', 'woocommerce' ), $this->get_shipping_first_name(), $this->get_shipping_last_name() ); + } + + /** + * Get a formatted billing address for the order. + * + * @param string $empty_content Content to show if no address is present. @since 3.3.0. + * @return string + */ + public function get_formatted_billing_address( $empty_content = '' ) { + $address = apply_filters( 'woocommerce_order_formatted_billing_address', $this->get_address( 'billing' ), $this ); + $address = WC()->countries->get_formatted_address( $address ); + + return $address ? $address : $empty_content; + } + + /** + * Get a formatted shipping address for the order. + * + * @param string $empty_content Content to show if no address is present. @since 3.3.0. + * @return string + */ + public function get_formatted_shipping_address( $empty_content = '' ) { + $address = ''; + + if ( $this->has_shipping_address() ) { + $address = apply_filters( 'woocommerce_order_formatted_shipping_address', $this->get_address( 'shipping' ), $this ); + $address = WC()->countries->get_formatted_address( $address ); + } + + return $address ? $address : $empty_content; + } + + /** + * Returns true if the order has a billing address. + * + * @since 3.0.4 + * @return boolean + */ + public function has_billing_address() { + return $this->get_billing_address_1() || $this->get_billing_address_2(); + } + + /** + * Returns true if the order has a shipping address. + * + * @since 3.0.4 + * @return boolean + */ + public function has_shipping_address() { + return $this->get_shipping_address_1() || $this->get_shipping_address_2(); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + | + | Functions for setting order data. These should not update anything in the + | database itself and should only change what is stored in the class + | object. However, for backwards compatibility pre 3.0.0 some of these + | setters may handle both. + | + */ + + /** + * Sets a prop for a setter method. + * + * @since 3.0.0 + * @param string $prop Name of prop to set. + * @param string $address Name of address to set. billing or shipping. + * @param mixed $value Value of the prop. + */ + protected function set_address_prop( $prop, $address = 'billing', $value ) { + if ( array_key_exists( $prop, $this->data[ $address ] ) ) { + if ( true === $this->object_read ) { + if ( $value !== $this->data[ $address ][ $prop ] || ( isset( $this->changes[ $address ] ) && array_key_exists( $prop, $this->changes[ $address ] ) ) ) { + $this->changes[ $address ][ $prop ] = $value; + } + } else { + $this->data[ $address ][ $prop ] = $value; + } + } + } + + /** + * Set order key. + * + * @param string $value Max length 22 chars. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_order_key( $value ) { + $this->set_prop( 'order_key', substr( $value, 0, 22 ) ); + } + + /** + * Set customer id. + * + * @param int $value Customer ID. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_customer_id( $value ) { + $this->set_prop( 'customer_id', absint( $value ) ); + } + + /** + * Set billing first name. + * + * @param string $value Billing first name. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_first_name( $value ) { + $this->set_address_prop( 'first_name', 'billing', $value ); + } + + /** + * Set billing last name. + * + * @param string $value Billing last name. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_last_name( $value ) { + $this->set_address_prop( 'last_name', 'billing', $value ); + } + + /** + * Set billing company. + * + * @param string $value Billing company. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_company( $value ) { + $this->set_address_prop( 'company', 'billing', $value ); + } + + /** + * Set billing address line 1. + * + * @param string $value Billing address line 1. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_address_1( $value ) { + $this->set_address_prop( 'address_1', 'billing', $value ); + } + + /** + * Set billing address line 2. + * + * @param string $value Billing address line 2. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_address_2( $value ) { + $this->set_address_prop( 'address_2', 'billing', $value ); + } + + /** + * Set billing city. + * + * @param string $value Billing city. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_city( $value ) { + $this->set_address_prop( 'city', 'billing', $value ); + } + + /** + * Set billing state. + * + * @param string $value Billing state. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_state( $value ) { + $this->set_address_prop( 'state', 'billing', $value ); + } + + /** + * Set billing postcode. + * + * @param string $value Billing postcode. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_postcode( $value ) { + $this->set_address_prop( 'postcode', 'billing', $value ); + } + + /** + * Set billing country. + * + * @param string $value Billing country. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_country( $value ) { + $this->set_address_prop( 'country', 'billing', $value ); + } + + /** + * Maybe set empty billing email to that of the user who owns the order. + */ + protected function maybe_set_user_billing_email() { + $user = $this->get_user(); + if ( ! $this->get_billing_email() && $user ) { + try { + $this->set_billing_email( $user->user_email ); + } catch ( WC_Data_Exception $e ) { + unset( $e ); + } + } + } + + /** + * Set billing email. + * + * @param string $value Billing email. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_email( $value ) { + if ( $value && ! is_email( $value ) ) { + $this->error( 'order_invalid_billing_email', __( 'Invalid billing email address', 'woocommerce' ) ); + } + $this->set_address_prop( 'email', 'billing', sanitize_email( $value ) ); + } + + /** + * Set billing phone. + * + * @param string $value Billing phone. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_billing_phone( $value ) { + $this->set_address_prop( 'phone', 'billing', $value ); + } + + /** + * Set shipping first name. + * + * @param string $value Shipping first name. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_first_name( $value ) { + $this->set_address_prop( 'first_name', 'shipping', $value ); + } + + /** + * Set shipping last name. + * + * @param string $value Shipping last name. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_last_name( $value ) { + $this->set_address_prop( 'last_name', 'shipping', $value ); + } + + /** + * Set shipping company. + * + * @param string $value Shipping company. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_company( $value ) { + $this->set_address_prop( 'company', 'shipping', $value ); + } + + /** + * Set shipping address line 1. + * + * @param string $value Shipping address line 1. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_address_1( $value ) { + $this->set_address_prop( 'address_1', 'shipping', $value ); + } + + /** + * Set shipping address line 2. + * + * @param string $value Shipping address line 2. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_address_2( $value ) { + $this->set_address_prop( 'address_2', 'shipping', $value ); + } + + /** + * Set shipping city. + * + * @param string $value Shipping city. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_city( $value ) { + $this->set_address_prop( 'city', 'shipping', $value ); + } + + /** + * Set shipping state. + * + * @param string $value Shipping state. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_state( $value ) { + $this->set_address_prop( 'state', 'shipping', $value ); + } + + /** + * Set shipping postcode. + * + * @param string $value Shipping postcode. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_postcode( $value ) { + $this->set_address_prop( 'postcode', 'shipping', $value ); + } + + /** + * Set shipping country. + * + * @param string $value Shipping country. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_shipping_country( $value ) { + $this->set_address_prop( 'country', 'shipping', $value ); + } + + /** + * Set the payment method. + * + * @param string $payment_method Supports WC_Payment_Gateway for bw compatibility with < 3.0. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_payment_method( $payment_method = '' ) { + if ( is_object( $payment_method ) ) { + $this->set_payment_method( $payment_method->id ); + $this->set_payment_method_title( $payment_method->get_title() ); + } elseif ( '' === $payment_method ) { + $this->set_prop( 'payment_method', '' ); + $this->set_prop( 'payment_method_title', '' ); + } else { + $this->set_prop( 'payment_method', $payment_method ); + } + } + + /** + * Set payment method title. + * + * @param string $value Payment method title. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_payment_method_title( $value ) { + $this->set_prop( 'payment_method_title', $value ); + } + + /** + * Set transaction id. + * + * @param string $value Transaction id. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_transaction_id( $value ) { + $this->set_prop( 'transaction_id', $value ); + } + + /** + * Set customer ip address. + * + * @param string $value Customer ip address. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_customer_ip_address( $value ) { + $this->set_prop( 'customer_ip_address', $value ); + } + + /** + * Set customer user agent. + * + * @param string $value Customer user agent. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_customer_user_agent( $value ) { + $this->set_prop( 'customer_user_agent', $value ); + } + + /** + * Set created via. + * + * @param string $value Created via. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_created_via( $value ) { + $this->set_prop( 'created_via', $value ); + } + + /** + * Set customer note. + * + * @param string $value Customer note. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_customer_note( $value ) { + $this->set_prop( 'customer_note', $value ); + } + + /** + * Set date completed. + * + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_date_completed( $date = null ) { + $this->set_date_prop( 'date_completed', $date ); + } + + /** + * Set date paid. + * + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_date_paid( $date = null ) { + $this->set_date_prop( 'date_paid', $date ); + } + + /** + * Set cart hash. + * + * @param string $value Cart hash. + * @throws WC_Data_Exception Throws exception when invalid data is found. + */ + public function set_cart_hash( $value ) { + $this->set_prop( 'cart_hash', $value ); + } + + /* + |-------------------------------------------------------------------------- + | Conditionals + |-------------------------------------------------------------------------- + | + | Checks if a condition is true or false. + | + */ + + /** + * Check if an order key is valid. + * + * @param string $key Order key. + * @return bool + */ + public function key_is_valid( $key ) { + return $key === $this->get_order_key(); + } + + /** + * See if order matches cart_hash. + * + * @param string $cart_hash Cart hash. + * @return bool + */ + public function has_cart_hash( $cart_hash = '' ) { + return hash_equals( $this->get_cart_hash(), $cart_hash ); // @codingStandardsIgnoreLine + } + + /** + * Checks if an order can be edited, specifically for use on the Edit Order screen. + * + * @return bool + */ + public function is_editable() { + return apply_filters( 'wc_order_is_editable', in_array( $this->get_status(), array( 'pending', 'on-hold', 'auto-draft' ), true ), $this ); + } + + /** + * Returns if an order has been paid for based on the order status. + * + * @since 2.5.0 + * @return bool + */ + public function is_paid() { + return apply_filters( 'woocommerce_order_is_paid', $this->has_status( wc_get_is_paid_statuses() ), $this ); + } + + /** + * Checks if product download is permitted. + * + * @return bool + */ + public function is_download_permitted() { + return apply_filters( 'woocommerce_order_is_download_permitted', $this->has_status( 'completed' ) || ( 'yes' === get_option( 'woocommerce_downloads_grant_access_after_payment' ) && $this->has_status( 'processing' ) ), $this ); + } + + /** + * Checks if an order needs display the shipping address, based on shipping method. + * + * @return bool + */ + public function needs_shipping_address() { + if ( 'no' === get_option( 'woocommerce_calc_shipping' ) ) { + return false; + } + + $hide = apply_filters( 'woocommerce_order_hide_shipping_address', array( 'local_pickup' ), $this ); + $needs_address = false; + + foreach ( $this->get_shipping_methods() as $shipping_method ) { + // Remove any instance IDs after ":". + $shipping_method_id = current( explode( ':', $shipping_method['method_id'] ) ); + + if ( ! in_array( $shipping_method_id, $hide, true ) ) { + $needs_address = true; + break; + } + } + + return apply_filters( 'woocommerce_order_needs_shipping_address', $needs_address, $hide, $this ); + } + + /** + * Returns true if the order contains a downloadable product. + * + * @return bool + */ + public function has_downloadable_item() { + foreach ( $this->get_items() as $item ) { + if ( $item->is_type( 'line_item' ) ) { + $product = $item->get_product(); + + if ( $product && $product->has_file() ) { + return true; + } + } + } + return false; + } + + /** + * Get downloads from all line items for this order. + * + * @since 3.2.0 + * @return array + */ + public function get_downloadable_items() { + $downloads = array(); + + foreach ( $this->get_items() as $item ) { + if ( ! is_object( $item ) ) { + continue; + } + + if ( $item->is_type( 'line_item' ) ) { + $item_downloads = $item->get_item_downloads(); + $product = $item->get_product(); + if ( $product && $item_downloads ) { + foreach ( $item_downloads as $file ) { + $downloads[] = array( + 'download_url' => $file['download_url'], + 'download_id' => $file['id'], + 'product_id' => $product->get_id(), + 'product_name' => $product->get_name(), + 'product_url' => $product->is_visible() ? $product->get_permalink() : '', // Since 3.3.0. + 'download_name' => $file['name'], + 'order_id' => $this->get_id(), + 'order_key' => $this->get_order_key(), + 'downloads_remaining' => $file['downloads_remaining'], + 'access_expires' => $file['access_expires'], + 'file' => array( + 'name' => $file['name'], + 'file' => $file['file'], + ), + ); + } + } + } + } + + return apply_filters( 'woocommerce_order_get_downloadable_items', $downloads, $this ); + } + + /** + * Checks if an order needs payment, based on status and order total. + * + * @return bool + */ + public function needs_payment() { + $valid_order_statuses = apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $this ); + return apply_filters( 'woocommerce_order_needs_payment', ( $this->has_status( $valid_order_statuses ) && $this->get_total() > 0 ), $this, $valid_order_statuses ); + } + + /** + * See if the order needs processing before it can be completed. + * + * Orders which only contain virtual, downloadable items do not need admin + * intervention. + * + * Uses a transient so these calls are not repeated multiple times, and because + * once the order is processed this code/transient does not need to persist. + * + * @since 3.0.0 + * @return bool + */ + public function needs_processing() { + $transient_name = 'wc_order_' . $this->get_id() . '_needs_processing'; + $needs_processing = get_transient( $transient_name ); + + if ( false === $needs_processing ) { + $needs_processing = 0; + + if ( count( $this->get_items() ) > 0 ) { + foreach ( $this->get_items() as $item ) { + if ( $item->is_type( 'line_item' ) ) { + $product = $item->get_product(); + + if ( ! $product ) { + continue; + } + + $virtual_downloadable_item = $product->is_downloadable() && $product->is_virtual(); + + if ( apply_filters( 'woocommerce_order_item_needs_processing', ! $virtual_downloadable_item, $product, $this->get_id() ) ) { + $needs_processing = 1; + break; + } + } + } + } + + set_transient( $transient_name, $needs_processing, DAY_IN_SECONDS ); + } + + return 1 === absint( $needs_processing ); + } + + /* + |-------------------------------------------------------------------------- + | URLs and Endpoints + |-------------------------------------------------------------------------- + */ + + /** + * Generates a URL so that a customer can pay for their (unpaid - pending) order. Pass 'true' for the checkout version which doesn't offer gateway choices. + * + * @param bool $on_checkout If on checkout. + * @return string + */ + public function get_checkout_payment_url( $on_checkout = false ) { + $pay_url = wc_get_endpoint_url( 'order-pay', $this->get_id(), wc_get_page_permalink( 'checkout' ) ); + + if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || is_ssl() ) { + $pay_url = str_replace( 'http:', 'https:', $pay_url ); + } + + if ( $on_checkout ) { + $pay_url = add_query_arg( 'key', $this->get_order_key(), $pay_url ); + } else { + $pay_url = add_query_arg( + array( + 'pay_for_order' => 'true', + 'key' => $this->get_order_key(), + ), $pay_url + ); + } + + return apply_filters( 'woocommerce_get_checkout_payment_url', $pay_url, $this ); + } + + /** + * Generates a URL for the thanks page (order received). + * + * @return string + */ + public function get_checkout_order_received_url() { + $order_received_url = wc_get_endpoint_url( 'order-received', $this->get_id(), wc_get_page_permalink( 'checkout' ) ); + + if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || is_ssl() ) { + $order_received_url = str_replace( 'http:', 'https:', $order_received_url ); + } + + $order_received_url = add_query_arg( 'key', $this->get_order_key(), $order_received_url ); + + return apply_filters( 'woocommerce_get_checkout_order_received_url', $order_received_url, $this ); + } + + /** + * Generates a URL so that a customer can cancel their (unpaid - pending) order. + * + * @param string $redirect Redirect URL. + * @return string + */ + public function get_cancel_order_url( $redirect = '' ) { + return apply_filters( + 'woocommerce_get_cancel_order_url', wp_nonce_url( + add_query_arg( + array( + 'cancel_order' => 'true', + 'order' => $this->get_order_key(), + 'order_id' => $this->get_id(), + 'redirect' => $redirect, + ), $this->get_cancel_endpoint() + ), 'woocommerce-cancel_order' + ) + ); + } + + /** + * Generates a raw (unescaped) cancel-order URL for use by payment gateways. + * + * @param string $redirect Redirect URL. + * @return string The unescaped cancel-order URL. + */ + public function get_cancel_order_url_raw( $redirect = '' ) { + return apply_filters( + 'woocommerce_get_cancel_order_url_raw', add_query_arg( + array( + 'cancel_order' => 'true', + 'order' => $this->get_order_key(), + 'order_id' => $this->get_id(), + 'redirect' => $redirect, + '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ), + ), $this->get_cancel_endpoint() + ) + ); + } + + /** + * Helper method to return the cancel endpoint. + * + * @return string the cancel endpoint; either the cart page or the home page. + */ + public function get_cancel_endpoint() { + $cancel_endpoint = wc_get_page_permalink( 'cart' ); + if ( ! $cancel_endpoint ) { + $cancel_endpoint = home_url(); + } + + if ( false === strpos( $cancel_endpoint, '?' ) ) { + $cancel_endpoint = trailingslashit( $cancel_endpoint ); + } + + return $cancel_endpoint; + } + + /** + * Generates a URL to view an order from the my account page. + * + * @return string + */ + public function get_view_order_url() { + return apply_filters( 'woocommerce_get_view_order_url', wc_get_endpoint_url( 'view-order', $this->get_id(), wc_get_page_permalink( 'myaccount' ) ), $this ); + } + + /** + * Get's the URL to edit the order in the backend. + * + * @since 3.3.0 + * @return string + */ + public function get_edit_order_url() { + return apply_filters( 'woocommerce_get_edit_order_url', get_admin_url( null, 'post.php?post=' . $this->get_id() . '&action=edit' ), $this ); + } + + /* + |-------------------------------------------------------------------------- + | Order notes. + |-------------------------------------------------------------------------- + */ + + /** + * Adds a note (comment) to the order. Order must exist. + * + * @param string $note Note to add. + * @param int $is_customer_note Is this a note for the customer?. + * @param bool $added_by_user Was the note added by a user?. + * @return int Comment ID. + */ + public function add_order_note( $note, $is_customer_note = 0, $added_by_user = false ) { + if ( ! $this->get_id() ) { + return 0; + } + + if ( is_user_logged_in() && current_user_can( 'edit_shop_order', $this->get_id() ) && $added_by_user ) { + $user = get_user_by( 'id', get_current_user_id() ); + $comment_author = $user->display_name; + $comment_author_email = $user->user_email; + } else { + $comment_author = __( 'WooCommerce', 'woocommerce' ); + $comment_author_email = strtolower( __( 'WooCommerce', 'woocommerce' ) ) . '@'; + $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) ) : 'noreply.com'; // WPCS: input var ok. + $comment_author_email = sanitize_email( $comment_author_email ); + } + $commentdata = apply_filters( + 'woocommerce_new_order_note_data', + array( + 'comment_post_ID' => $this->get_id(), + 'comment_author' => $comment_author, + 'comment_author_email' => $comment_author_email, + 'comment_author_url' => '', + 'comment_content' => $note, + 'comment_agent' => 'WooCommerce', + 'comment_type' => 'order_note', + 'comment_parent' => 0, + 'comment_approved' => 1, + ), + array( + 'order_id' => $this->get_id(), + 'is_customer_note' => $is_customer_note, + ) + ); + + $comment_id = wp_insert_comment( $commentdata ); + + if ( $is_customer_note ) { + add_comment_meta( $comment_id, 'is_customer_note', 1 ); + + do_action( + 'woocommerce_new_customer_note', array( + 'order_id' => $this->get_id(), + 'customer_note' => $commentdata['comment_content'], + ) + ); + } + + return $comment_id; + } + + /** + * List order notes (public) for the customer. + * + * @return array + */ + public function get_customer_order_notes() { + $notes = array(); + $args = array( + 'post_id' => $this->get_id(), + 'approve' => 'approve', + 'type' => '', + ); + + remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) ); + + $comments = get_comments( $args ); + + foreach ( $comments as $comment ) { + if ( ! get_comment_meta( $comment->comment_ID, 'is_customer_note', true ) ) { + continue; + } + $comment->comment_content = make_clickable( $comment->comment_content ); + $notes[] = $comment; + } + + add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ) ); + + return $notes; + } + + /* + |-------------------------------------------------------------------------- + | Refunds + |-------------------------------------------------------------------------- + */ + + /** + * Get order refunds. + * + * @since 2.2 + * @return array of WC_Order_Refund objects + */ + public function get_refunds() { + $cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'refunds' . $this->get_id(); + $cached_data = wp_cache_get( $cache_key, $this->cache_group ); + + if ( false !== $cached_data ) { + return $cached_data; + } + + $this->refunds = wc_get_orders( + array( + 'type' => 'shop_order_refund', + 'parent' => $this->get_id(), + 'limit' => -1, + ) + ); + + wp_cache_set( $cache_key, $this->refunds, $this->cache_group ); + + return $this->refunds; + } + + /** + * Get amount already refunded. + * + * @since 2.2 + * @return string + */ + public function get_total_refunded() { + $cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'total_refunded' . $this->get_id(); + $cached_data = wp_cache_get( $cache_key, $this->cache_group ); + + if ( false !== $cached_data ) { + return $cached_data; + } + + $total_refunded = $this->data_store->get_total_refunded( $this ); + + wp_cache_set( $cache_key, $total_refunded, $this->cache_group ); + + return $total_refunded; + } + + /** + * Get the total tax refunded. + * + * @since 2.3 + * @return float + */ + public function get_total_tax_refunded() { + $cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'total_tax_refunded' . $this->get_id(); + $cached_data = wp_cache_get( $cache_key, $this->cache_group ); + + if ( false !== $cached_data ) { + return $cached_data; + } + + $total_refunded = $this->data_store->get_total_tax_refunded( $this ); + + wp_cache_set( $cache_key, $total_refunded, $this->cache_group ); + + return $total_refunded; + } + + /** + * Get the total shipping refunded. + * + * @since 2.4 + * @return float + */ + public function get_total_shipping_refunded() { + $cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'total_shipping_refunded' . $this->get_id(); + $cached_data = wp_cache_get( $cache_key, $this->cache_group ); + + if ( false !== $cached_data ) { + return $cached_data; + } + + $total_refunded = $this->data_store->get_total_shipping_refunded( $this ); + + wp_cache_set( $cache_key, $total_refunded, $this->cache_group ); + + return $total_refunded; + } + + /** + * Gets the count of order items of a certain type that have been refunded. + * + * @since 2.4.0 + * @param string $item_type Item type. + * @return string + */ + public function get_item_count_refunded( $item_type = '' ) { + if ( empty( $item_type ) ) { + $item_type = array( 'line_item' ); + } + if ( ! is_array( $item_type ) ) { + $item_type = array( $item_type ); + } + $count = 0; + + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( $item_type ) as $refunded_item ) { + $count += abs( $refunded_item->get_quantity() ); + } + } + + return apply_filters( 'woocommerce_get_item_count_refunded', $count, $item_type, $this ); + } + + /** + * Get the total number of items refunded. + * + * @since 2.4.0 + * + * @param string $item_type Type of the item we're checking, if not a line_item. + * @return int + */ + public function get_total_qty_refunded( $item_type = 'line_item' ) { + $qty = 0; + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( $item_type ) as $refunded_item ) { + $qty += $refunded_item->get_quantity(); + } + } + return $qty; + } + + /** + * Get the refunded amount for a line item. + * + * @param int $item_id ID of the item we're checking. + * @param string $item_type Type of the item we're checking, if not a line_item. + * @return int + */ + public function get_qty_refunded_for_item( $item_id, $item_type = 'line_item' ) { + $qty = 0; + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( $item_type ) as $refunded_item ) { + if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) { + $qty += $refunded_item->get_quantity(); + } + } + } + return $qty; + } + + /** + * Get the refunded amount for a line item. + * + * @param int $item_id ID of the item we're checking. + * @param string $item_type Type of the item we're checking, if not a line_item. + * @return int + */ + public function get_total_refunded_for_item( $item_id, $item_type = 'line_item' ) { + $total = 0; + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( $item_type ) as $refunded_item ) { + if ( absint( $refunded_item->get_meta( '_refunded_item_id' ) ) === $item_id ) { + $total += $refunded_item->get_total(); + } + } + } + return $total * -1; + } + + /** + * Get the refunded tax amount for a line item. + * + * @param int $item_id ID of the item we're checking. + * @param int $tax_id ID of the tax we're checking. + * @param string $item_type Type of the item we're checking, if not a line_item. + * @return double + */ + public function get_tax_refunded_for_item( $item_id, $tax_id, $item_type = 'line_item' ) { + $total = 0; + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( $item_type ) as $refunded_item ) { + $refunded_item_id = (int) $refunded_item->get_meta( '_refunded_item_id' ); + if ( $refunded_item_id === $item_id ) { + $taxes = $refunded_item->get_taxes(); + $total += isset( $taxes['total'][ $tax_id ] ) ? (float) $taxes['total'][ $tax_id ] : 0; + break; + } + } + } + return wc_round_tax_total( $total ) * -1; + } + + /** + * Get total tax refunded by rate ID. + * + * @param int $rate_id Rate ID. + * @return float + */ + public function get_total_tax_refunded_by_rate_id( $rate_id ) { + $total = 0; + foreach ( $this->get_refunds() as $refund ) { + foreach ( $refund->get_items( 'tax' ) as $refunded_item ) { + if ( absint( $refunded_item->get_rate_id() ) === $rate_id ) { + $total += abs( $refunded_item->get_tax_total() ) + abs( $refunded_item->get_shipping_tax_total() ); + } + } + } + + return $total; + } + + /** + * How much money is left to refund? + * + * @return string + */ + public function get_remaining_refund_amount() { + return wc_format_decimal( $this->get_total() - $this->get_total_refunded(), wc_get_price_decimals() ); + } + + /** + * How many items are left to refund? + * + * @return int + */ + public function get_remaining_refund_items() { + return absint( $this->get_item_count() - $this->get_item_count_refunded() ); + } + + /** + * Add total row for the payment method. + * + * @param array $total_rows Total rows. + * @param string $tax_display Tax to display. + */ + protected function add_order_item_totals_payment_method_row( &$total_rows, $tax_display ) { + if ( $this->get_total() > 0 && $this->get_payment_method_title() ) { + $total_rows['payment_method'] = array( + 'label' => __( 'Payment method:', 'woocommerce' ), + 'value' => $this->get_payment_method_title(), + ); + } + } + + /** + * Add total row for refunds. + * + * @param array $total_rows Total rows. + * @param string $tax_display Tax to display. + */ + protected function add_order_item_totals_refund_rows( &$total_rows, $tax_display ) { + $refunds = $this->get_refunds(); + if ( $refunds ) { + foreach ( $refunds as $id => $refund ) { + $total_rows[ 'refund_' . $id ] = array( + 'label' => $refund->get_reason() ? $refund->get_reason() : __( 'Refund', 'woocommerce' ) . ':', + 'value' => wc_price( '-' . $refund->get_amount(), array( 'currency' => $this->get_currency() ) ), + ); + } + } + } + + /** + * Get totals for display on pages and in emails. + * + * @param string $tax_display Tax to display. + * @return array + */ + public function get_order_item_totals( $tax_display = '' ) { + $tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' ); + $total_rows = array(); + + $this->add_order_item_totals_subtotal_row( $total_rows, $tax_display ); + $this->add_order_item_totals_discount_row( $total_rows, $tax_display ); + $this->add_order_item_totals_shipping_row( $total_rows, $tax_display ); + $this->add_order_item_totals_fee_rows( $total_rows, $tax_display ); + $this->add_order_item_totals_tax_rows( $total_rows, $tax_display ); + $this->add_order_item_totals_payment_method_row( $total_rows, $tax_display ); + $this->add_order_item_totals_refund_rows( $total_rows, $tax_display ); + $this->add_order_item_totals_total_row( $total_rows, $tax_display ); + + return apply_filters( 'woocommerce_get_order_item_totals', $total_rows, $this, $tax_display ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php new file mode 100644 index 0000000..751f5c7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php @@ -0,0 +1,221 @@ +init(); + } + + /** + * Load gateways and hook in functions. + */ + public function init() { + $load_gateways = array( + 'WC_Gateway_BACS', + 'WC_Gateway_Cheque', + 'WC_Gateway_COD', + 'WC_Gateway_Paypal', + ); + + /** + * Simplify Commerce is @deprecated in 2.6.0. Only load when enabled. + */ + if ( ! class_exists( 'WC_Gateway_Simplify_Commerce_Loader' ) && in_array( WC()->countries->get_base_country(), apply_filters( 'woocommerce_gateway_simplify_commerce_supported_countries', array( 'US', 'IE' ) ), true ) ) { + $simplify_options = get_option( 'woocommerce_simplify_commerce_settings', array() ); + + if ( ! empty( $simplify_options['enabled'] ) && 'yes' === $simplify_options['enabled'] ) { + if ( function_exists( 'wcs_create_renewal_order' ) ) { + $load_gateways[] = 'WC_Addons_Gateway_Simplify_Commerce'; + } else { + $load_gateways[] = 'WC_Gateway_Simplify_Commerce'; + } + } + } + + // Filter. + $load_gateways = apply_filters( 'woocommerce_payment_gateways', $load_gateways ); + + // Get sort order option. + $ordering = (array) get_option( 'woocommerce_gateway_order' ); + $order_end = 999; + + // Load gateways in order. + foreach ( $load_gateways as $gateway ) { + $load_gateway = is_string( $gateway ) ? new $gateway() : $gateway; + + if ( isset( $ordering[ $load_gateway->id ] ) && is_numeric( $ordering[ $load_gateway->id ] ) ) { + // Add in position. + $this->payment_gateways[ $ordering[ $load_gateway->id ] ] = $load_gateway; + } else { + // Add to end of the array. + $this->payment_gateways[ $order_end ] = $load_gateway; + $order_end++; + } + } + + ksort( $this->payment_gateways ); + } + + /** + * Get gateways. + * + * @return array + */ + public function payment_gateways() { + $_available_gateways = array(); + + if ( count( $this->payment_gateways ) > 0 ) { + foreach ( $this->payment_gateways as $gateway ) { + $_available_gateways[ $gateway->id ] = $gateway; + } + } + + return $_available_gateways; + } + + /** + * Get array of registered gateway ids + * + * @since 2.6.0 + * @return array of strings + */ + public function get_payment_gateway_ids() { + return wp_list_pluck( $this->payment_gateways, 'id' ); + } + + /** + * Get available gateways. + * + * @return array + */ + public function get_available_payment_gateways() { + $_available_gateways = array(); + + foreach ( $this->payment_gateways as $gateway ) { + if ( $gateway->is_available() ) { + if ( ! is_add_payment_method_page() ) { + $_available_gateways[ $gateway->id ] = $gateway; + } elseif ( $gateway->supports( 'add_payment_method' ) || $gateway->supports( 'tokenization' ) ) { + $_available_gateways[ $gateway->id ] = $gateway; + } + } + } + + return apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways ); + } + + /** + * Set the current, active gateway. + * + * @param array $gateways Available payment gateways. + */ + public function set_current_gateway( $gateways ) { + // Be on the defensive. + if ( ! is_array( $gateways ) || empty( $gateways ) ) { + return; + } + + if ( is_user_logged_in() ) { + $default_token = WC_Payment_Tokens::get_customer_default_token( get_current_user_id() ); + if ( ! is_null( $default_token ) ) { + $default_token_gateway = $default_token->get_gateway_id(); + } + } + + $current = ( isset( $default_token_gateway ) ? $default_token_gateway : WC()->session->get( 'chosen_payment_method' ) ); + + if ( $current && isset( $gateways[ $current ] ) ) { + $current_gateway = $gateways[ $current ]; + + } else { + $current_gateway = current( $gateways ); + } + + // Ensure we can make a call to set_current() without triggering an error. + if ( $current_gateway && is_callable( array( $current_gateway, 'set_current' ) ) ) { + $current_gateway->set_current(); + } + } + + /** + * Save options in admin. + */ + public function process_admin_options() { + $gateway_order = isset( $_POST['gateway_order'] ) ? wc_clean( wp_unslash( $_POST['gateway_order'] ) ) : ''; // WPCS: input var ok, CSRF ok. + $order = array(); + + if ( is_array( $gateway_order ) && count( $gateway_order ) > 0 ) { + $loop = 0; + foreach ( $gateway_order as $gateway_id ) { + $order[ esc_attr( $gateway_id ) ] = $loop; + $loop++; + } + } + + update_option( 'woocommerce_gateway_order', $order ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-tokens.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-tokens.php new file mode 100644 index 0000000..0f1ffb2 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-payment-tokens.php @@ -0,0 +1,215 @@ + '', + 'user_id' => '', + 'gateway_id' => '', + 'type' => '', + ) + ); + + $data_store = WC_Data_Store::load( 'payment-token' ); + $token_results = $data_store->get_tokens( $args ); + $tokens = array(); + + if ( ! empty( $token_results ) ) { + foreach ( $token_results as $token_result ) { + $_token = self::get( $token_result->token_id, $token_result ); + if ( ! empty( $_token ) ) { + $tokens[ $token_result->token_id ] = $_token; + } + } + } + + return $tokens; + } + + /** + * Returns an array of payment token objects associated with the passed customer ID. + * + * @since 2.6.0 + * @param int $customer_id Customer ID. + * @param string $gateway_id Optional Gateway ID for getting tokens for a specific gateway. + * @return array Array of token objects. + */ + public static function get_customer_tokens( $customer_id, $gateway_id = '' ) { + if ( $customer_id < 1 ) { + return array(); + } + + $tokens = self::get_tokens( + array( + 'user_id' => $customer_id, + 'gateway_id' => $gateway_id, + ) + ); + + return apply_filters( 'woocommerce_get_customer_payment_tokens', $tokens, $customer_id, $gateway_id ); + } + + /** + * Returns a customers default token or NULL if there is no default token. + * + * @since 2.6.0 + * @param int $customer_id Customer ID. + * @return WC_Payment_Token|null + */ + public static function get_customer_default_token( $customer_id ) { + if ( $customer_id < 1 ) { + return null; + } + + $data_store = WC_Data_Store::load( 'payment-token' ); + $token = $data_store->get_users_default_token( $customer_id ); + + if ( $token ) { + return self::get( $token->token_id, $token ); + } else { + return null; + } + } + + /** + * Returns an array of payment token objects associated with the passed order ID. + * + * @since 2.6.0 + * @param int $order_id Order ID. + * @return array Array of token objects. + */ + public static function get_order_tokens( $order_id ) { + $order = wc_get_order( $order_id ); + + if ( ! $order ) { + return array(); + } + + $token_ids = $order->get_payment_tokens(); + + if ( empty( $token_ids ) ) { + return array(); + } + + $tokens = self::get_tokens( + array( + 'token_id' => $token_ids, + ) + ); + + return apply_filters( 'woocommerce_get_order_payment_tokens', $tokens, $order_id ); + } + + /** + * Get a token object by ID. + * + * @since 2.6.0 + * + * @param int $token_id Token ID. + * @param object $token_result Token result. + * @return null|WC_Payment_Token Returns a valid payment token or null if no token can be found. + */ + public static function get( $token_id, $token_result = null ) { + $data_store = WC_Data_Store::load( 'payment-token' ); + + if ( is_null( $token_result ) ) { + $token_result = $data_store->get_token_by_id( $token_id ); + // Still empty? Token doesn't exist? Don't continue. + if ( empty( $token_result ) ) { + return null; + } + } + + $token_class = 'WC_Payment_Token_' . $token_result->type; + + if ( class_exists( $token_class ) ) { + $meta = $data_store->get_metadata( $token_id ); + $passed_meta = array(); + if ( ! empty( $meta ) ) { + foreach ( $meta as $meta_key => $meta_value ) { + $passed_meta[ $meta_key ] = $meta_value[0]; + } + } + return new $token_class( $token_id, (array) $token_result, $passed_meta ); + } + + return null; + } + + /** + * Remove a payment token from the database by ID. + * + * @since 2.6.0 + * @param WC_Payment_Token $token_id Token ID. + */ + public static function delete( $token_id ) { + $type = self::get_token_type_by_id( $token_id ); + if ( ! empty( $type ) ) { + $class = 'WC_Payment_Token_' . $type; + $token = new $class( $token_id ); + $token->delete(); + } + } + + /** + * Loops through all of a users payment tokens and sets is_default to false for all but a specific token. + * + * @since 2.6.0 + * @param int $user_id User to set a default for. + * @param int $token_id The ID of the token that should be default. + */ + public static function set_users_default( $user_id, $token_id ) { + $data_store = WC_Data_Store::load( 'payment-token' ); + $users_tokens = self::get_customer_tokens( $user_id ); + foreach ( $users_tokens as $token ) { + if ( $token_id === $token->get_id() ) { + $data_store->set_default_status( $token->get_id(), true ); + do_action( 'woocommerce_payment_token_set_default', $token_id, $token ); + } else { + $data_store->set_default_status( $token->get_id(), false ); + } + } + } + + /** + * Returns what type (credit card, echeck, etc) of token a token is by ID. + * + * @since 2.6.0 + * @param int $token_id Token ID. + * @return string Type. + */ + public static function get_token_type_by_id( $token_id ) { + $data_store = WC_Data_Store::load( 'payment-token' ); + return $data_store->get_token_type_by_id( $token_id ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-post-data.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-post-data.php new file mode 100644 index 0000000..3608519 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-post-data.php @@ -0,0 +1,537 @@ +ID, $post->post_type ) && 'product_variation' === $post->post_type ) { + $variation = wc_get_product( $post->ID ); + + if ( $variation && $variation->get_parent_id() ) { + return $variation->get_permalink(); + } + } + return $permalink; + } + + /** + * Sync products queued to sync. + */ + public static function do_deferred_product_sync() { + global $wc_deferred_product_sync; + + if ( ! empty( $wc_deferred_product_sync ) ) { + $wc_deferred_product_sync = wp_parse_id_list( $wc_deferred_product_sync ); + array_walk( $wc_deferred_product_sync, array( __CLASS__, 'deferred_product_sync' ) ); + } + } + + /** + * Sync a product. + * + * @param int $product_id Product ID. + */ + public static function deferred_product_sync( $product_id ) { + $product = wc_get_product( $product_id ); + + if ( is_callable( array( $product, 'sync' ) ) ) { + $product->sync( $product ); + } + } + + /** + * Delete transients when terms are set. + * + * @param int $object_id Object ID. + * @param mixed $terms An array of object terms. + * @param array $tt_ids An array of term taxonomy IDs. + * @param string $taxonomy Taxonomy slug. + * @param mixed $append Whether to append new terms to the old terms. + * @param array $old_tt_ids Old array of term taxonomy IDs. + */ + public static function set_object_terms( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { + foreach ( array_merge( $tt_ids, $old_tt_ids ) as $id ) { + delete_transient( 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $id ) ) ); + } + if ( in_array( get_post_type( $object_id ), array( 'product', 'product_variation' ), true ) ) { + self::delete_product_query_transients(); + } + } + + /** + * When a post status changes. + * + * @param string $new_status New status. + * @param string $old_status Old status. + * @param WP_Post $post Post data. + */ + public static function transition_post_status( $new_status, $old_status, $post ) { + if ( ( 'publish' === $new_status || 'publish' === $old_status ) && in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) { + self::delete_product_query_transients(); + } + } + + /** + * Delete product view transients when needed e.g. when post status changes, or visibility/stock status is modified. + */ + public static function delete_product_query_transients() { + // Increments the transient version to invalidate cache. + WC_Cache_Helper::get_transient_version( 'product_query', true ); + + // If not using an external caching system, we can clear the transients out manually and avoid filling our DB. + if ( ! wp_using_ext_object_cache() ) { + global $wpdb; + + $wpdb->query( + " + DELETE FROM `$wpdb->options` + WHERE `option_name` LIKE ('\_transient\_wc\_uf\_pid\_%') + OR `option_name` LIKE ('\_transient\_timeout\_wc\_uf\_pid\_%') + OR `option_name` LIKE ('\_transient\_wc\_products\_will\_display\_%') + OR `option_name` LIKE ('\_transient\_timeout\_wc\_products\_will\_display\_%') + " + ); + } + } + + /** + * Handle type changes. + * + * @since 3.0.0 + * @param WC_Product $product Product data. + * @param string $from Origin type. + * @param string $to New type. + */ + public static function product_type_changed( $product, $from, $to ) { + if ( 'variable' === $from && 'variable' !== $to ) { + // If the product is no longer variable, we should ensure all variations are removed. + $data_store = WC_Data_Store::load( 'product-variable' ); + $data_store->delete_variations( $product->get_id() ); + } + } + + /** + * When editing a term, check for product attributes. + * + * @param int $term_id Term ID. + * @param int $tt_id Term taxonomy ID. + * @param string $taxonomy Taxonomy slug. + */ + public static function edit_term( $term_id, $tt_id, $taxonomy ) { + if ( strpos( $taxonomy, 'pa_' ) === 0 ) { + self::$editing_term = get_term_by( 'id', $term_id, $taxonomy ); + } else { + self::$editing_term = null; + } + } + + /** + * When a term is edited, check for product attributes and update variations. + * + * @param int $term_id Term ID. + * @param int $tt_id Term taxonomy ID. + * @param string $taxonomy Taxonomy slug. + */ + public static function edited_term( $term_id, $tt_id, $taxonomy ) { + if ( ! is_null( self::$editing_term ) && strpos( $taxonomy, 'pa_' ) === 0 ) { + $edited_term = get_term_by( 'id', $term_id, $taxonomy ); + + if ( $edited_term->slug !== self::$editing_term->slug ) { + global $wpdb; + + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND meta_value = %s;", $edited_term->slug, 'attribute_' . sanitize_title( $taxonomy ), self::$editing_term->slug ) ); + } + } else { + self::$editing_term = null; + } + } + + /** + * Ensure floats are correctly converted to strings based on PHP locale. + * + * @param null $check Whether to allow updating metadata for the given type. + * @param int $object_id Object ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. Must be serializable if non-scalar. + * @param mixed $prev_value If specified, only update existing metadata entries with the specified value. Otherwise, update all entries. + * @return null|bool + */ + public static function update_order_item_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) { + if ( ! empty( $meta_value ) && is_float( $meta_value ) ) { + + // Convert float to string. + $meta_value = wc_float_to_string( $meta_value ); + + // Update meta value with new string. + update_metadata( 'order_item', $object_id, $meta_key, $meta_value, $prev_value ); + + return true; + } + return $check; + } + + /** + * Ensure floats are correctly converted to strings based on PHP locale. + * + * @param null $check Whether to allow updating metadata for the given type. + * @param int $object_id Object ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. Must be serializable if non-scalar. + * @param mixed $prev_value If specified, only update existing metadata entries with the specified value. Otherwise, update all entries. + * @return null|bool + */ + public static function update_post_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) { + // Delete product cache if someone uses meta directly. + if ( in_array( get_post_type( $object_id ), array( 'product', 'product_variation' ), true ) ) { + wp_cache_delete( 'product-' . $object_id, 'products' ); + } + + if ( ! empty( $meta_value ) && is_float( $meta_value ) && in_array( get_post_type( $object_id ), array_merge( wc_get_order_types(), array( 'shop_coupon', 'product', 'product_variation' ) ), true ) ) { + + // Convert float to string. + $meta_value = wc_float_to_string( $meta_value ); + + // Update meta value with new string. + update_metadata( 'post', $object_id, $meta_key, $meta_value, $prev_value ); + + return true; + } + return $check; + } + + /** + * When setting stock level, ensure the stock status is kept in sync. + * + * @param int $meta_id Meta ID. + * @param int $object_id Object ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @deprecated + */ + public static function sync_product_stock_status( $meta_id, $object_id, $meta_key, $meta_value ) {} + + /** + * Forces the order posts to have a title in a certain format (containing the date). + * Forces certain product data based on the product's type, e.g. grouped products cannot have a parent. + * + * @param array $data An array of slashed post data. + * @return array + */ + public static function wp_insert_post_data( $data ) { + if ( 'shop_order' === $data['post_type'] && isset( $data['post_date'] ) ) { + $order_title = 'Order'; + if ( $data['post_date'] ) { + $order_title .= ' – ' . date_i18n( 'F j, Y @ h:i A', strtotime( $data['post_date'] ) ); + } + $data['post_title'] = $order_title; + } elseif ( 'product' === $data['post_type'] && isset( $_POST['product-type'] ) ) { // WPCS: input var ok, CSRF ok. + $product_type = wc_clean( wp_unslash( $_POST['product-type'] ) ); // WPCS: input var ok, CSRF ok. + switch ( $product_type ) { + case 'grouped': + case 'variable': + $data['post_parent'] = 0; + break; + } + } elseif ( 'product' === $data['post_type'] && 'auto-draft' === $data['post_status'] ) { + $data['post_title'] = 'AUTO-DRAFT'; + } + + return $data; + } + + /** + * Change embed data for certain post types. + * + * @since 3.2.0 + * @param array $data The response data. + * @param WP_Post $post The post object. + * @return array + */ + public static function filter_oembed_response_data( $data, $post ) { + if ( in_array( $post->post_type, array( 'shop_order', 'shop_coupon' ), true ) ) { + return array(); + } + return $data; + } + + /** + * Removes variations etc belonging to a deleted post, and clears transients. + * + * @param mixed $id ID of post being deleted. + */ + public static function delete_post( $id ) { + if ( ! current_user_can( 'delete_posts' ) || ! $id ) { + return; + } + + $post_type = get_post_type( $id ); + + switch ( $post_type ) { + case 'product': + $data_store = WC_Data_Store::load( 'product-variable' ); + $data_store->delete_variations( $id, true ); + $parent_id = wp_get_post_parent_id( $id ); + + if ( $parent_id ) { + wc_delete_product_transients( $parent_id ); + } + break; + case 'product_variation': + wc_delete_product_transients( wp_get_post_parent_id( $id ) ); + break; + case 'shop_order': + global $wpdb; + + $refunds = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id ) ); + + if ( ! is_null( $refunds ) ) { + foreach ( $refunds as $refund ) { + wp_delete_post( $refund->ID, true ); + } + } + break; + } + } + + /** + * Trash post. + * + * @param mixed $id Post ID. + */ + public static function trash_post( $id ) { + if ( ! $id ) { + return; + } + + $post_type = get_post_type( $id ); + + // If this is an order, trash any refunds too. + if ( in_array( $post_type, wc_get_order_types( 'order-count' ), true ) ) { + global $wpdb; + + $refunds = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id ) ); + + foreach ( $refunds as $refund ) { + $wpdb->update( $wpdb->posts, array( 'post_status' => 'trash' ), array( 'ID' => $refund->ID ) ); + } + + wc_delete_shop_order_transients( $id ); + + // If this is a product, trash children variations. + } elseif ( 'product' === $post_type ) { + $data_store = WC_Data_Store::load( 'product-variable' ); + $data_store->delete_variations( $id, false ); + } + } + + /** + * Untrash post. + * + * @param mixed $id Post ID. + */ + public static function untrash_post( $id ) { + if ( ! $id ) { + return; + } + + $post_type = get_post_type( $id ); + + if ( in_array( $post_type, wc_get_order_types( 'order-count' ), true ) ) { + global $wpdb; + + $refunds = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id ) ); + + foreach ( $refunds as $refund ) { + $wpdb->update( $wpdb->posts, array( 'post_status' => 'wc-completed' ), array( 'ID' => $refund->ID ) ); + } + + wc_delete_shop_order_transients( $id ); + + } elseif ( 'product' === $post_type ) { + $data_store = WC_Data_Store::load( 'product-variable' ); + $data_store->untrash_variations( $id ); + + wc_product_force_unique_sku( $id ); + } + } + + /** + * Before deleting an order, do some cleanup. + * + * @since 3.2.0 + * @param int $order_id Order ID. + */ + public static function before_delete_order( $order_id ) { + if ( in_array( get_post_type( $order_id ), wc_get_order_types(), true ) ) { + // Clean up user. + $order = wc_get_order( $order_id ); + + // Check for `get_customer_id`, since this may be e.g. a refund order (which doesn't implement it). + $customer_id = is_callable( array( $order, 'get_customer_id' ) ) ? $order->get_customer_id() : 0; + + if ( $customer_id > 0 && 'shop_order' === $order->get_type() ) { + $customer = new WC_Customer( $customer_id ); + $order_count = $customer->get_order_count(); + $order_count --; + + if ( 0 === $order_count ) { + $customer->set_is_paying_customer( false ); + $customer->save(); + } + + // Delete order count meta. + delete_user_meta( $customer_id, '_order_count' ); + } + + // Clean up items. + self::delete_order_items( $order_id ); + self::delete_order_downloadable_permissions( $order_id ); + } + } + + /** + * Remove item meta on permanent deletion. + * + * @param int $postid Post ID. + */ + public static function delete_order_items( $postid ) { + global $wpdb; + + if ( in_array( get_post_type( $postid ), wc_get_order_types(), true ) ) { + do_action( 'woocommerce_delete_order_items', $postid ); + + $wpdb->query( + " + DELETE {$wpdb->prefix}woocommerce_order_items, {$wpdb->prefix}woocommerce_order_itemmeta + FROM {$wpdb->prefix}woocommerce_order_items + JOIN {$wpdb->prefix}woocommerce_order_itemmeta ON {$wpdb->prefix}woocommerce_order_items.order_item_id = {$wpdb->prefix}woocommerce_order_itemmeta.order_item_id + WHERE {$wpdb->prefix}woocommerce_order_items.order_id = '{$postid}'; + " + ); // WPCS: unprepared SQL ok. + + do_action( 'woocommerce_deleted_order_items', $postid ); + } + } + + /** + * Remove downloadable permissions on permanent order deletion. + * + * @param int $postid Post ID. + */ + public static function delete_order_downloadable_permissions( $postid ) { + if ( in_array( get_post_type( $postid ), wc_get_order_types(), true ) ) { + do_action( 'woocommerce_delete_order_downloadable_permissions', $postid ); + + $data_store = WC_Data_Store::load( 'customer-download' ); + $data_store->delete_by_order_id( $postid ); + + do_action( 'woocommerce_deleted_order_downloadable_permissions', $postid ); + } + } + + /** + * Update changed downloads. + * + * @deprecated 3.3.0 No action is necessary on changes to download paths since download_id is no longer based on file hash. + * @param int $product_id Product ID. + * @param int $variation_id Variation ID. Optional product variation identifier. + * @param array $downloads Newly set files. + */ + public static function process_product_file_download_paths( $product_id, $variation_id, $downloads ) { + wc_deprecated_function( __FUNCTION__, '3.3' ); + } + + /** + * Flush meta cache for CRUD objects on direct update. + * + * @param int $meta_id Meta ID. + * @param int $object_id Object ID. + * @param string $meta_key Meta key. + * @param string $meta_value Meta value. + */ + public static function flush_object_meta_cache( $meta_id, $object_id, $meta_key, $meta_value ) { + WC_Cache_Helper::incr_cache_prefix( 'object_' . $object_id ); + } + + /** + * Ensure default category gets set. + * + * @since 3.3.0 + * @param int $object_id Product ID. + * @param array $terms Terms array. + * @param array $tt_ids Term ids array. + * @param string $taxonomy Taxonomy name. + * @param bool $append Are we appending or setting terms. + */ + public static function force_default_term( $object_id, $terms, $tt_ids, $taxonomy, $append ) { + if ( ! $append && 'product_cat' === $taxonomy && empty( $tt_ids ) && 'product' === get_post_type( $object_id ) ) { + $default_term = absint( get_option( 'default_product_cat', 0 ) ); + $tt_ids = array_map( 'absint', $tt_ids ); + + if ( $default_term && ! in_array( $default_term, $tt_ids, true ) ) { + wp_set_post_terms( $object_id, array( $default_term ), 'product_cat', true ); + } + } + } +} + +WC_Post_Data::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-post-types.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-post-types.php new file mode 100644 index 0000000..09d8102 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-post-types.php @@ -0,0 +1,604 @@ + false, + 'show_ui' => false, + 'show_in_nav_menus' => false, + 'query_var' => is_admin(), + 'rewrite' => false, + 'public' => false, + ) + ) + ); + + register_taxonomy( + 'product_visibility', + apply_filters( 'woocommerce_taxonomy_objects_product_visibility', array( 'product', 'product_variation' ) ), + apply_filters( + 'woocommerce_taxonomy_args_product_visibility', array( + 'hierarchical' => false, + 'show_ui' => false, + 'show_in_nav_menus' => false, + 'query_var' => is_admin(), + 'rewrite' => false, + 'public' => false, + ) + ) + ); + + register_taxonomy( + 'product_cat', + apply_filters( 'woocommerce_taxonomy_objects_product_cat', array( 'product' ) ), + apply_filters( + 'woocommerce_taxonomy_args_product_cat', array( + 'hierarchical' => true, + 'update_count_callback' => '_wc_term_recount', + 'label' => __( 'Categories', 'woocommerce' ), + 'labels' => array( + 'name' => __( 'Product categories', 'woocommerce' ), + 'singular_name' => __( 'Category', 'woocommerce' ), + 'menu_name' => _x( 'Categories', 'Admin menu name', 'woocommerce' ), + 'search_items' => __( 'Search categories', 'woocommerce' ), + 'all_items' => __( 'All categories', 'woocommerce' ), + 'parent_item' => __( 'Parent category', 'woocommerce' ), + 'parent_item_colon' => __( 'Parent category:', 'woocommerce' ), + 'edit_item' => __( 'Edit category', 'woocommerce' ), + 'update_item' => __( 'Update category', 'woocommerce' ), + 'add_new_item' => __( 'Add new category', 'woocommerce' ), + 'new_item_name' => __( 'New category name', 'woocommerce' ), + 'not_found' => __( 'No categories found', 'woocommerce' ), + ), + 'show_ui' => true, + 'query_var' => true, + 'capabilities' => array( + 'manage_terms' => 'manage_product_terms', + 'edit_terms' => 'edit_product_terms', + 'delete_terms' => 'delete_product_terms', + 'assign_terms' => 'assign_product_terms', + ), + 'rewrite' => array( + 'slug' => $permalinks['category_rewrite_slug'], + 'with_front' => false, + 'hierarchical' => true, + ), + ) + ) + ); + + register_taxonomy( + 'product_tag', + apply_filters( 'woocommerce_taxonomy_objects_product_tag', array( 'product' ) ), + apply_filters( + 'woocommerce_taxonomy_args_product_tag', array( + 'hierarchical' => false, + 'update_count_callback' => '_wc_term_recount', + 'label' => __( 'Product tags', 'woocommerce' ), + 'labels' => array( + 'name' => __( 'Product tags', 'woocommerce' ), + 'singular_name' => __( 'Tag', 'woocommerce' ), + 'menu_name' => _x( 'Tags', 'Admin menu name', 'woocommerce' ), + 'search_items' => __( 'Search tags', 'woocommerce' ), + 'all_items' => __( 'All tags', 'woocommerce' ), + 'edit_item' => __( 'Edit tag', 'woocommerce' ), + 'update_item' => __( 'Update tag', 'woocommerce' ), + 'add_new_item' => __( 'Add new tag', 'woocommerce' ), + 'new_item_name' => __( 'New tag name', 'woocommerce' ), + 'popular_items' => __( 'Popular tags', 'woocommerce' ), + 'separate_items_with_commas' => __( 'Separate tags with commas', 'woocommerce' ), + 'add_or_remove_items' => __( 'Add or remove tags', 'woocommerce' ), + 'choose_from_most_used' => __( 'Choose from the most used tags', 'woocommerce' ), + 'not_found' => __( 'No tags found', 'woocommerce' ), + ), + 'show_ui' => true, + 'query_var' => true, + 'capabilities' => array( + 'manage_terms' => 'manage_product_terms', + 'edit_terms' => 'edit_product_terms', + 'delete_terms' => 'delete_product_terms', + 'assign_terms' => 'assign_product_terms', + ), + 'rewrite' => array( + 'slug' => $permalinks['tag_rewrite_slug'], + 'with_front' => false, + ), + ) + ) + ); + + register_taxonomy( + 'product_shipping_class', + apply_filters( 'woocommerce_taxonomy_objects_product_shipping_class', array( 'product', 'product_variation' ) ), + apply_filters( + 'woocommerce_taxonomy_args_product_shipping_class', array( + 'hierarchical' => false, + 'update_count_callback' => '_update_post_term_count', + 'label' => __( 'Shipping classes', 'woocommerce' ), + 'labels' => array( + 'name' => __( 'Product shipping classes', 'woocommerce' ), + 'singular_name' => __( 'Shipping class', 'woocommerce' ), + 'menu_name' => _x( 'Shipping classes', 'Admin menu name', 'woocommerce' ), + 'search_items' => __( 'Search shipping classes', 'woocommerce' ), + 'all_items' => __( 'All shipping classes', 'woocommerce' ), + 'parent_item' => __( 'Parent shipping class', 'woocommerce' ), + 'parent_item_colon' => __( 'Parent shipping class:', 'woocommerce' ), + 'edit_item' => __( 'Edit shipping class', 'woocommerce' ), + 'update_item' => __( 'Update shipping class', 'woocommerce' ), + 'add_new_item' => __( 'Add new shipping class', 'woocommerce' ), + 'new_item_name' => __( 'New shipping class Name', 'woocommerce' ), + ), + 'show_ui' => false, + 'show_in_quick_edit' => false, + 'show_in_nav_menus' => false, + 'query_var' => is_admin(), + 'capabilities' => array( + 'manage_terms' => 'manage_product_terms', + 'edit_terms' => 'edit_product_terms', + 'delete_terms' => 'delete_product_terms', + 'assign_terms' => 'assign_product_terms', + ), + 'rewrite' => false, + ) + ) + ); + + global $wc_product_attributes; + + $wc_product_attributes = array(); + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + if ( $attribute_taxonomies ) { + foreach ( $attribute_taxonomies as $tax ) { + $name = wc_attribute_taxonomy_name( $tax->attribute_name ); + + if ( $name ) { + $tax->attribute_public = absint( isset( $tax->attribute_public ) ? $tax->attribute_public : 1 ); + $label = ! empty( $tax->attribute_label ) ? $tax->attribute_label : $tax->attribute_name; + $wc_product_attributes[ $name ] = $tax; + $taxonomy_data = array( + 'hierarchical' => false, + 'update_count_callback' => '_update_post_term_count', + 'labels' => array( + /* translators: %s: attribute name */ + 'name' => sprintf( _x( 'Product %s', 'Product Attribute', 'woocommerce' ), $label ), + 'singular_name' => $label, + /* translators: %s: attribute name */ + 'search_items' => sprintf( __( 'Search %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'all_items' => sprintf( __( 'All %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'parent_item' => sprintf( __( 'Parent %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'parent_item_colon' => sprintf( __( 'Parent %s:', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'edit_item' => sprintf( __( 'Edit %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'update_item' => sprintf( __( 'Update %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'add_new_item' => sprintf( __( 'Add new %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'new_item_name' => sprintf( __( 'New %s', 'woocommerce' ), $label ), + /* translators: %s: attribute name */ + 'not_found' => sprintf( __( 'No "%s" found', 'woocommerce' ), $label ), + ), + 'show_ui' => true, + 'show_in_quick_edit' => false, + 'show_in_menu' => false, + 'meta_box_cb' => false, + 'query_var' => 1 === $tax->attribute_public, + 'rewrite' => false, + 'sort' => false, + 'public' => 1 === $tax->attribute_public, + 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters( 'woocommerce_attribute_show_in_nav_menus', false, $name ), + 'capabilities' => array( + 'manage_terms' => 'manage_product_terms', + 'edit_terms' => 'edit_product_terms', + 'delete_terms' => 'delete_product_terms', + 'assign_terms' => 'assign_product_terms', + ), + ); + + if ( 1 === $tax->attribute_public && sanitize_title( $tax->attribute_name ) ) { + $taxonomy_data['rewrite'] = array( + 'slug' => trailingslashit( $permalinks['attribute_rewrite_slug'] ) . sanitize_title( $tax->attribute_name ), + 'with_front' => false, + 'hierarchical' => true, + ); + } + + register_taxonomy( $name, apply_filters( "woocommerce_taxonomy_objects_{$name}", array( 'product' ) ), apply_filters( "woocommerce_taxonomy_args_{$name}", $taxonomy_data ) ); + } + } + } + + do_action( 'woocommerce_after_register_taxonomy' ); + } + + /** + * Register core post types. + */ + public static function register_post_types() { + if ( ! is_blog_installed() || post_type_exists( 'product' ) ) { + return; + } + + do_action( 'woocommerce_register_post_type' ); + + $permalinks = wc_get_permalink_structure(); + $supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', 'publicize', 'wpcom-markdown' ); + + if ( 'yes' === get_option( 'woocommerce_enable_reviews', 'yes' ) ) { + $supports[] = 'comments'; + } + + $shop_page_id = wc_get_page_id( 'shop' ); + + if ( current_theme_supports( 'woocommerce' ) ) { + $has_archive = $shop_page_id && get_post( $shop_page_id ) ? urldecode( get_page_uri( $shop_page_id ) ) : 'shop'; + } else { + $has_archive = false; + } + + // If theme support changes, we may need to flush permalinks since some are changed based on this flag. + if ( update_option( 'current_theme_supports_woocommerce', current_theme_supports( 'woocommerce' ) ? 'yes' : 'no' ) ) { + update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' ); + } + + register_post_type( + 'product', + apply_filters( + 'woocommerce_register_post_type_product', + array( + 'labels' => array( + 'name' => __( 'Products', 'woocommerce' ), + 'singular_name' => __( 'Product', 'woocommerce' ), + 'all_items' => __( 'All Products', 'woocommerce' ), + 'menu_name' => _x( 'Products', 'Admin menu name', 'woocommerce' ), + 'add_new' => __( 'Add New', 'woocommerce' ), + 'add_new_item' => __( 'Add new product', 'woocommerce' ), + 'edit' => __( 'Edit', 'woocommerce' ), + 'edit_item' => __( 'Edit product', 'woocommerce' ), + 'new_item' => __( 'New product', 'woocommerce' ), + 'view_item' => __( 'View product', 'woocommerce' ), + 'view_items' => __( 'View products', 'woocommerce' ), + 'search_items' => __( 'Search products', 'woocommerce' ), + 'not_found' => __( 'No products found', 'woocommerce' ), + 'not_found_in_trash' => __( 'No products found in trash', 'woocommerce' ), + 'parent' => __( 'Parent product', 'woocommerce' ), + 'featured_image' => __( 'Product image', 'woocommerce' ), + 'set_featured_image' => __( 'Set product image', 'woocommerce' ), + 'remove_featured_image' => __( 'Remove product image', 'woocommerce' ), + 'use_featured_image' => __( 'Use as product image', 'woocommerce' ), + 'insert_into_item' => __( 'Insert into product', 'woocommerce' ), + 'uploaded_to_this_item' => __( 'Uploaded to this product', 'woocommerce' ), + 'filter_items_list' => __( 'Filter products', 'woocommerce' ), + 'items_list_navigation' => __( 'Products navigation', 'woocommerce' ), + 'items_list' => __( 'Products list', 'woocommerce' ), + ), + 'description' => __( 'This is where you can add new products to your store.', 'woocommerce' ), + 'public' => true, + 'show_ui' => true, + 'capability_type' => 'product', + 'map_meta_cap' => true, + 'publicly_queryable' => true, + 'exclude_from_search' => false, + 'hierarchical' => false, // Hierarchical causes memory issues - WP loads all records! + 'rewrite' => $permalinks['product_rewrite_slug'] ? array( + 'slug' => $permalinks['product_rewrite_slug'], + 'with_front' => false, + 'feeds' => true, + ) : false, + 'query_var' => true, + 'supports' => $supports, + 'has_archive' => $has_archive, + 'show_in_nav_menus' => true, + 'show_in_rest' => true, + ) + ) + ); + + register_post_type( + 'product_variation', + apply_filters( + 'woocommerce_register_post_type_product_variation', + array( + 'label' => __( 'Variations', 'woocommerce' ), + 'public' => false, + 'hierarchical' => false, + 'supports' => false, + 'capability_type' => 'product', + 'rewrite' => false, + ) + ) + ); + + wc_register_order_type( + 'shop_order', + apply_filters( + 'woocommerce_register_post_type_shop_order', + array( + 'labels' => array( + 'name' => __( 'Orders', 'woocommerce' ), + 'singular_name' => _x( 'Order', 'shop_order post type singular name', 'woocommerce' ), + 'add_new' => __( 'Add order', 'woocommerce' ), + 'add_new_item' => __( 'Add new order', 'woocommerce' ), + 'edit' => __( 'Edit', 'woocommerce' ), + 'edit_item' => __( 'Edit order', 'woocommerce' ), + 'new_item' => __( 'New order', 'woocommerce' ), + 'view_item' => __( 'View order', 'woocommerce' ), + 'search_items' => __( 'Search orders', 'woocommerce' ), + 'not_found' => __( 'No orders found', 'woocommerce' ), + 'not_found_in_trash' => __( 'No orders found in trash', 'woocommerce' ), + 'parent' => __( 'Parent orders', 'woocommerce' ), + 'menu_name' => _x( 'Orders', 'Admin menu name', 'woocommerce' ), + 'filter_items_list' => __( 'Filter orders', 'woocommerce' ), + 'items_list_navigation' => __( 'Orders navigation', 'woocommerce' ), + 'items_list' => __( 'Orders list', 'woocommerce' ), + ), + 'description' => __( 'This is where store orders are stored.', 'woocommerce' ), + 'public' => false, + 'show_ui' => true, + 'capability_type' => 'shop_order', + 'map_meta_cap' => true, + 'publicly_queryable' => false, + 'exclude_from_search' => true, + 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true, + 'hierarchical' => false, + 'show_in_nav_menus' => false, + 'rewrite' => false, + 'query_var' => false, + 'supports' => array( 'title', 'comments', 'custom-fields' ), + 'has_archive' => false, + ) + ) + ); + + wc_register_order_type( + 'shop_order_refund', + apply_filters( + 'woocommerce_register_post_type_shop_order_refund', + array( + 'label' => __( 'Refunds', 'woocommerce' ), + 'capability_type' => 'shop_order', + 'public' => false, + 'hierarchical' => false, + 'supports' => false, + 'exclude_from_orders_screen' => false, + 'add_order_meta_boxes' => false, + 'exclude_from_order_count' => true, + 'exclude_from_order_views' => false, + 'exclude_from_order_reports' => false, + 'exclude_from_order_sales_reports' => true, + 'class_name' => 'WC_Order_Refund', + 'rewrite' => false, + ) + ) + ); + + if ( 'yes' === get_option( 'woocommerce_enable_coupons' ) ) { + register_post_type( + 'shop_coupon', + apply_filters( + 'woocommerce_register_post_type_shop_coupon', + array( + 'labels' => array( + 'name' => __( 'Coupons', 'woocommerce' ), + 'singular_name' => __( 'Coupon', 'woocommerce' ), + 'menu_name' => _x( 'Coupons', 'Admin menu name', 'woocommerce' ), + 'add_new' => __( 'Add coupon', 'woocommerce' ), + 'add_new_item' => __( 'Add new coupon', 'woocommerce' ), + 'edit' => __( 'Edit', 'woocommerce' ), + 'edit_item' => __( 'Edit coupon', 'woocommerce' ), + 'new_item' => __( 'New coupon', 'woocommerce' ), + 'view_item' => __( 'View coupon', 'woocommerce' ), + 'search_items' => __( 'Search coupons', 'woocommerce' ), + 'not_found' => __( 'No coupons found', 'woocommerce' ), + 'not_found_in_trash' => __( 'No coupons found in trash', 'woocommerce' ), + 'parent' => __( 'Parent coupon', 'woocommerce' ), + 'filter_items_list' => __( 'Filter coupons', 'woocommerce' ), + 'items_list_navigation' => __( 'Coupons navigation', 'woocommerce' ), + 'items_list' => __( 'Coupons list', 'woocommerce' ), + ), + 'description' => __( 'This is where you can add new coupons that customers can use in your store.', 'woocommerce' ), + 'public' => false, + 'show_ui' => true, + 'capability_type' => 'shop_coupon', + 'map_meta_cap' => true, + 'publicly_queryable' => false, + 'exclude_from_search' => true, + 'show_in_menu' => current_user_can( 'manage_woocommerce' ) ? 'woocommerce' : true, + 'hierarchical' => false, + 'rewrite' => false, + 'query_var' => false, + 'supports' => array( 'title' ), + 'show_in_nav_menus' => false, + 'show_in_admin_bar' => true, + ) + ) + ); + } + + do_action( 'woocommerce_after_register_post_type' ); + } + + /** + * Register our custom post statuses, used for order status. + */ + public static function register_post_status() { + + $order_statuses = apply_filters( + 'woocommerce_register_shop_order_post_statuses', + array( + 'wc-pending' => array( + 'label' => _x( 'Pending payment', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Pending payment (%s)', 'Pending payment (%s)', 'woocommerce' ), + ), + 'wc-processing' => array( + 'label' => _x( 'Processing', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Processing (%s)', 'Processing (%s)', 'woocommerce' ), + ), + 'wc-on-hold' => array( + 'label' => _x( 'On hold', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'On hold (%s)', 'On hold (%s)', 'woocommerce' ), + ), + 'wc-completed' => array( + 'label' => _x( 'Completed', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Completed (%s)', 'Completed (%s)', 'woocommerce' ), + ), + 'wc-cancelled' => array( + 'label' => _x( 'Cancelled', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Cancelled (%s)', 'Cancelled (%s)', 'woocommerce' ), + ), + 'wc-refunded' => array( + 'label' => _x( 'Refunded', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Refunded (%s)', 'Refunded (%s)', 'woocommerce' ), + ), + 'wc-failed' => array( + 'label' => _x( 'Failed', 'Order status', 'woocommerce' ), + 'public' => false, + 'exclude_from_search' => false, + 'show_in_admin_all_list' => true, + 'show_in_admin_status_list' => true, + /* translators: %s: number of orders */ + 'label_count' => _n_noop( 'Failed (%s)', 'Failed (%s)', 'woocommerce' ), + ), + ) + ); + + foreach ( $order_statuses as $order_status => $values ) { + register_post_status( $order_status, $values ); + } + } + + /** + * Flush rules if the event is queued. + * + * @since 3.3.0 + */ + public static function maybe_flush_rewrite_rules() { + if ( 'yes' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) { + update_option( 'woocommerce_queue_flush_rewrite_rules', 'no' ); + self::flush_rewrite_rules(); + } + } + + /** + * Flush rewrite rules. + */ + public static function flush_rewrite_rules() { + flush_rewrite_rules(); + } + + /** + * Disable Gutenberg for products. + * + * @param bool $can_edit Whether the post type can be edited or not. + * @param string $post_type The post type being checked. + * @return bool + */ + public static function gutenberg_can_edit_post_type( $can_edit, $post_type ) { + return 'product' === $post_type ? false : $can_edit; + } + + /** + * Add Product Support to Jetpack Omnisearch. + */ + public static function support_jetpack_omnisearch() { + if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) { + new Jetpack_Omnisearch_Posts( 'product' ); + } + } + + /** + * Added product for Jetpack related posts. + * + * @param array $post_types Post types. + * @return array + */ + public static function rest_api_allowed_post_types( $post_types ) { + $post_types[] = 'product'; + + return $post_types; + } +} + +WC_Post_types::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-background-process.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-background-process.php new file mode 100644 index 0000000..468b214 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-background-process.php @@ -0,0 +1,70 @@ +prefix = 'wp_' . get_current_blog_id(); + $this->action = 'wc_privacy_cleanup'; + parent::__construct(); + } + + /** + * Code to execute for each item in the queue + * + * @param string $item Queue item to iterate over. + * @return bool + */ + protected function task( $item ) { + if ( ! $item || empty( $item['task'] ) ) { + return false; + } + + $process_count = 0; + $process_limit = 20; + + switch ( $item['task'] ) { + case 'trash_pending_orders': + $process_count = WC_Privacy::trash_pending_orders( $process_limit ); + break; + case 'trash_failed_orders': + $process_count = WC_Privacy::trash_failed_orders( $process_limit ); + break; + case 'trash_cancelled_orders': + $process_count = WC_Privacy::trash_cancelled_orders( $process_limit ); + break; + case 'anonymize_completed_orders': + $process_count = WC_Privacy::anonymize_completed_orders( $process_limit ); + break; + case 'delete_inactive_accounts': + $process_count = WC_Privacy::delete_inactive_accounts( $process_limit ); + break; + } + + if ( $process_limit === $process_count ) { + // Needs to run again. + return $item; + } + + return false; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-erasers.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-erasers.php new file mode 100644 index 0000000..11cbf9a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-erasers.php @@ -0,0 +1,397 @@ + false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + + if ( ! $user instanceof WP_User ) { + return $response; + } + + $customer = new WC_Customer( $user->ID ); + + if ( ! $customer ) { + return $response; + } + + $props_to_erase = apply_filters( 'woocommerce_privacy_erase_customer_personal_data_props', array( + 'billing_first_name' => __( 'Billing First Name', 'woocommerce' ), + 'billing_last_name' => __( 'Billing Last Name', 'woocommerce' ), + 'billing_company' => __( 'Billing Company', 'woocommerce' ), + 'billing_address_1' => __( 'Billing Address 1', 'woocommerce' ), + 'billing_address_2' => __( 'Billing Address 2', 'woocommerce' ), + 'billing_city' => __( 'Billing City', 'woocommerce' ), + 'billing_postcode' => __( 'Billing Postal/Zip Code', 'woocommerce' ), + 'billing_state' => __( 'Billing State', 'woocommerce' ), + 'billing_country' => __( 'Billing Country', 'woocommerce' ), + 'billing_phone' => __( 'Phone Number', 'woocommerce' ), + 'billing_email' => __( 'Email Address', 'woocommerce' ), + 'shipping_first_name' => __( 'Shipping First Name', 'woocommerce' ), + 'shipping_last_name' => __( 'Shipping Last Name', 'woocommerce' ), + 'shipping_company' => __( 'Shipping Company', 'woocommerce' ), + 'shipping_address_1' => __( 'Shipping Address 1', 'woocommerce' ), + 'shipping_address_2' => __( 'Shipping Address 2', 'woocommerce' ), + 'shipping_city' => __( 'Shipping City', 'woocommerce' ), + 'shipping_postcode' => __( 'Shipping Postal/Zip Code', 'woocommerce' ), + 'shipping_state' => __( 'Shipping State', 'woocommerce' ), + 'shipping_country' => __( 'Shipping Country', 'woocommerce' ), + ), $customer ); + + foreach ( $props_to_erase as $prop => $label ) { + $erased = false; + + if ( is_callable( array( $customer, 'get_' . $prop ) ) && is_callable( array( $customer, 'set_' . $prop ) ) ) { + $value = $customer->{"get_$prop"}( 'edit' ); + + if ( $value ) { + $customer->{"set_$prop"}( '' ); + $erased = true; + } + } + + $erased = apply_filters( 'woocommerce_privacy_erase_customer_personal_data_prop', $erased, $prop, $customer ); + + if ( $erased ) { + /* Translators: %s Prop name. */ + $response['messages'][] = sprintf( __( 'Removed customer "%s"', 'woocommerce' ), $label ); + $response['items_removed'] = true; + } + } + + $customer->save(); + + /** + * Allow extensions to remove data for this customer and adjust the response. + * + * @since 3.4.0 + * @param array $response Array resonse data. Must include messages, num_items_removed, num_items_retained, done. + * @param WC_Order $order A customer object. + */ + return apply_filters( 'woocommerce_privacy_erase_personal_data_customer', $response, $customer ); + } + + /** + * Finds and erases data which could be used to identify a person from WooCommerce data assocated with an email address. + * + * Orders are erased in blocks of 10 to avoid timeouts. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function order_data_eraser( $email_address, $page ) { + $page = (int) $page; + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + $erasure_enabled = wc_string_to_bool( get_option( 'woocommerce_erasure_request_removes_order_data', 'no' ) ); + $response = array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + + $order_query = array( + 'limit' => 10, + 'page' => $page, + 'customer' => array( $email_address ), + ); + + if ( $user instanceof WP_User ) { + $order_query['customer'][] = (int) $user->ID; + } + + $orders = wc_get_orders( $order_query ); + + if ( 0 < count( $orders ) ) { + foreach ( $orders as $order ) { + if ( apply_filters( 'woocommerce_privacy_erase_order_personal_data', $erasure_enabled, $order ) ) { + self::remove_order_personal_data( $order ); + + /* Translators: %s Order number. */ + $response['messages'][] = sprintf( __( 'Removed personal data from order %s.', 'woocommerce' ), $order->get_order_number() ); + $response['items_removed'] = true; + } else { + /* Translators: %s Order number. */ + $response['messages'][] = sprintf( __( 'Personal data within order %s has been retained.', 'woocommerce' ), $order->get_order_number() ); + $response['items_retained'] = true; + } + } + $response['done'] = 10 > count( $orders ); + } else { + $response['done'] = true; + } + + return $response; + } + + /** + * Finds and removes customer download logs by email address. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function download_data_eraser( $email_address, $page ) { + $page = (int) $page; + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + $erasure_enabled = wc_string_to_bool( get_option( 'woocommerce_erasure_request_removes_download_data', 'no' ) ); + $response = array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + + $downloads_query = array( + 'limit' => -1, + 'page' => $page, + 'return' => 'ids', + ); + + if ( $user instanceof WP_User ) { + $downloads_query['user_id'] = (int) $user->ID; + } else { + $downloads_query['user_email'] = $email_address; + } + + $customer_download_data_store = WC_Data_Store::load( 'customer-download' ); + + // Revoke download permissions. + if ( apply_filters( 'woocommerce_privacy_erase_download_personal_data', $erasure_enabled, $email_address ) ) { + if ( $user instanceof WP_User ) { + $result = $customer_download_data_store->delete_by_user_id( (int) $user->ID ); + } else { + $result = $customer_download_data_store->delete_by_user_email( $email_address ); + } + if ( $result ) { + $response['messages'][] = __( 'Removed access to downloadable files.', 'woocommerce' ); + $response['items_removed'] = true; + } + } else { + $response['messages'][] = __( 'Customer download permissions have been retained.', 'woocommerce' ); + $response['items_retained'] = true; + } + + return $response; + } + + /** + * Remove personal data specific to WooCommerce from an order object. + * + * Note; this will hinder order processing for obvious reasons! + * + * @param WC_Order $order Order object. + */ + public static function remove_order_personal_data( $order ) { + $anonymized_data = array(); + + /** + * Allow extensions to remove their own personal data for this order first, so order data is still available. + * + * @since 3.4.0 + * @param WC_Order $order A customer object. + */ + do_action( 'woocommerce_privacy_before_remove_order_personal_data', $order ); + + /** + * Expose props and data types we'll be anonymizing. + * + * @since 3.4.0 + * @param array $props Keys are the prop names, values are the data type we'll be passing to wp_privacy_anonymize_data(). + * @param WC_Order $order A customer object. + */ + $props_to_remove = apply_filters( 'woocommerce_privacy_remove_order_personal_data_props', array( + 'customer_ip_address' => 'ip', + 'customer_user_agent' => 'text', + 'billing_first_name' => 'text', + 'billing_last_name' => 'text', + 'billing_company' => 'text', + 'billing_address_1' => 'text', + 'billing_address_2' => 'text', + 'billing_city' => 'text', + 'billing_postcode' => 'text', + 'billing_state' => 'address_state', + 'billing_country' => 'address_country', + 'billing_phone' => 'phone', + 'billing_email' => 'email', + 'shipping_first_name' => 'text', + 'shipping_last_name' => 'text', + 'shipping_company' => 'text', + 'shipping_address_1' => 'text', + 'shipping_address_2' => 'text', + 'shipping_city' => 'text', + 'shipping_postcode' => 'text', + 'shipping_state' => 'address_state', + 'shipping_country' => 'address_country', + 'customer_id' => 'numeric_id', + 'transaction_id' => 'numeric_id', + ), $order ); + + if ( ! empty( $props_to_remove ) && is_array( $props_to_remove ) ) { + foreach ( $props_to_remove as $prop => $data_type ) { + // Get the current value in edit context. + $value = $order->{"get_$prop"}( 'edit' ); + + // If the value is empty, it does not need to be anonymized. + if ( empty( $value ) || empty( $data_type ) ) { + continue; + } + + $anon_value = function_exists( 'wp_privacy_anonymize_data' ) ? wp_privacy_anonymize_data( $data_type, $value ) : ''; + + /** + * Expose a way to control the anonymized value of a prop via 3rd party code. + * + * @since 3.4.0 + * @param string $anon_value Value of this prop after anonymization. + * @param string $prop Name of the prop being removed. + * @param string $value Current value of the data. + * @param string $data_type Type of data. + * @param WC_Order $order An order object. + */ + $anonymized_data[ $prop ] = apply_filters( 'woocommerce_privacy_remove_order_personal_data_prop_value', $anon_value, $prop, $value, $data_type, $order ); + } + } + + // Set all new props and persist the new data to the database. + $order->set_props( $anonymized_data ); + + // Remove meta data. + $meta_to_remove = apply_filters( 'woocommerce_privacy_remove_order_personal_data_meta', array( + 'Payer first name' => 'text', + 'Payer last name' => 'text', + 'Payer PayPal address' => 'email', + 'Transaction ID' => 'numeric_id', + ) ); + + if ( ! empty( $meta_to_remove ) && is_array( $meta_to_remove ) ) { + foreach ( $meta_to_remove as $meta_key => $data_type ) { + $value = $order->get_meta( $meta_key ); + + // If the value is empty, it does not need to be anonymized. + if ( empty( $value ) || empty( $data_type ) ) { + continue; + } + + $anon_value = function_exists( 'wp_privacy_anonymize_data' ) ? wp_privacy_anonymize_data( $data_type, $value ) : ''; + + /** + * Expose a way to control the anonymized value of a value via 3rd party code. + * + * @since 3.4.0 + * @param string $anon_value Value of this data after anonymization. + * @param string $prop meta_key key being removed. + * @param string $value Current value of the data. + * @param string $data_type Type of data. + * @param WC_Order $order An order object. + */ + $anon_value = apply_filters( 'woocommerce_privacy_remove_order_personal_data_meta_value', $anon_value, $meta_key, $value, $data_type, $order ); + + if ( $anon_value ) { + $order->update_meta_data( $meta_key, $anon_value ); + } else { + $order->delete_meta_data( $meta_key ); + } + } + } + + $order->update_meta_data( '_anonymized', 'yes' ); + $order->save(); + + // Delete order notes which can contain PII. + $notes = wc_get_order_notes( array( + 'order_id' => $order->get_id(), + ) ); + + foreach ( $notes as $note ) { + wc_delete_order_note( $note->id ); + } + + // Add note that this event occured. + $order->add_order_note( __( 'Personal data removed.', 'woocommerce' ) ); + + /** + * Allow extensions to remove their own personal data for this order. + * + * @since 3.4.0 + * @param WC_Order $order A customer object. + */ + do_action( 'woocommerce_privacy_remove_order_personal_data', $order ); + } + + /** + * Finds and erases customer tokens by email address. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function customer_tokens_eraser( $email_address, $page ) { + $response = array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + + if ( ! $user instanceof WP_User ) { + return $response; + } + + $tokens = WC_Payment_Tokens::get_tokens( array( + 'user_id' => $user->ID, + ) ); + + if ( empty( $tokens ) ) { + return $response; + } + + foreach ( $tokens as $token ) { + WC_Payment_Tokens::delete( $token->get_id() ); + + /* Translators: %s Prop name. */ + $response['messages'][] = sprintf( __( 'Removed payment token "%d"', 'woocommerce' ), $token->get_id() ); + $response['items_removed'] = true; + } + + /** + * Allow extensions to remove data for tokens and adjust the response. + * + * @since 3.4.0 + * @param array $response Array resonse data. Must include messages, num_items_removed, num_items_retained, done. + * @param array $tokens Array of tokens. + */ + return apply_filters( 'woocommerce_privacy_erase_personal_data_tokens', $response, $tokens ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-exporters.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-exporters.php new file mode 100644 index 0000000..608c751 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy-exporters.php @@ -0,0 +1,427 @@ + 'woocommerce_customer', + 'group_label' => __( 'Customer Data', 'woocommerce' ), + 'item_id' => 'user', + 'data' => $customer_personal_data, + ); + } + } + + return array( + 'data' => $data_to_export, + 'done' => true, + ); + } + + /** + * Finds and exports data which could be used to identify a person from WooCommerce data associated with an email address. + * + * Orders are exported in blocks of 10 to avoid timeouts. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function order_data_exporter( $email_address, $page ) { + $done = false; + $page = (int) $page; + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + $data_to_export = array(); + $order_query = array( + 'limit' => 10, + 'page' => $page, + 'customer' => array( $email_address ), + ); + + if ( $user instanceof WP_User ) { + $order_query['customer'][] = (int) $user->ID; + } + + $orders = wc_get_orders( $order_query ); + + if ( 0 < count( $orders ) ) { + foreach ( $orders as $order ) { + $data_to_export[] = array( + 'group_id' => 'woocommerce_orders', + 'group_label' => __( 'Orders', 'woocommerce' ), + 'item_id' => 'order-' . $order->get_id(), + 'data' => self::get_order_personal_data( $order ), + ); + } + $done = 10 > count( $orders ); + } else { + $done = true; + } + + return array( + 'data' => $data_to_export, + 'done' => $done, + ); + } + + /** + * Finds and exports customer download logs by email address. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function download_data_exporter( $email_address, $page ) { + $done = false; + $page = (int) $page; + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + $data_to_export = array(); + $downloads_query = array( + 'limit' => 10, + 'page' => $page, + ); + + if ( $user instanceof WP_User ) { + $downloads_query['user_id'] = (int) $user->ID; + } else { + $downloads_query['user_email'] = $email_address; + } + + $customer_download_data_store = WC_Data_Store::load( 'customer-download' ); + $customer_download_log_data_store = WC_Data_Store::load( 'customer-download-log' ); + $downloads = $customer_download_data_store->get_downloads( $downloads_query ); + + if ( 0 < count( $downloads ) ) { + foreach ( $downloads as $download ) { + $data_to_export[] = array( + 'group_id' => 'woocommerce_downloads', + /* translators: This is the headline for a list of downloads purchased from the store for a given user. */ + 'group_label' => __( 'Purchased Downloads', 'woocommerce' ), + 'item_id' => 'download-' . $download->get_id(), + 'data' => self::get_download_personal_data( $download ), + ); + + $download_logs = $customer_download_log_data_store->get_download_logs_for_permission( $download->get_id() ); + + foreach ( $download_logs as $download_log ) { + $data_to_export[] = array( + 'group_id' => 'woocommerce_download_logs', + /* translators: This is the headline for a list of access logs for downloads purchased from the store for a given user. */ + 'group_label' => __( 'Access to Purchased Downloads', 'woocommerce' ), + 'item_id' => 'download-log-' . $download_log->get_id(), + 'data' => array( + array( + 'name' => __( 'Download ID', 'woocommerce' ), + 'value' => $download_log->get_permission_id(), + ), + array( + 'name' => __( 'Timestamp', 'woocommerce' ), + 'value' => $download_log->get_timestamp(), + ), + array( + 'name' => __( 'IP Address', 'woocommerce' ), + 'value' => $download_log->get_user_ip_address(), + ), + ), + ); + } + } + $done = 10 > count( $downloads ); + } else { + $done = true; + } + + return array( + 'data' => $data_to_export, + 'done' => $done, + ); + } + + /** + * Get personal data (key/value pairs) for a user object. + * + * @since 3.4.0 + * @param WP_User $user user object. + * @return array + */ + protected static function get_customer_personal_data( $user ) { + $personal_data = array(); + $customer = new WC_Customer( $user->ID ); + + if ( ! $customer ) { + return array(); + } + + $props_to_export = apply_filters( 'woocommerce_privacy_export_customer_personal_data_props', array( + 'billing_first_name' => __( 'Billing First Name', 'woocommerce' ), + 'billing_last_name' => __( 'Billing Last Name', 'woocommerce' ), + 'billing_company' => __( 'Billing Company', 'woocommerce' ), + 'billing_address_1' => __( 'Billing Address 1', 'woocommerce' ), + 'billing_address_2' => __( 'Billing Address 2', 'woocommerce' ), + 'billing_city' => __( 'Billing City', 'woocommerce' ), + 'billing_postcode' => __( 'Billing Postal/Zip Code', 'woocommerce' ), + 'billing_state' => __( 'Billing State', 'woocommerce' ), + 'billing_country' => __( 'Billing Country', 'woocommerce' ), + 'billing_phone' => __( 'Phone Number', 'woocommerce' ), + 'billing_email' => __( 'Email Address', 'woocommerce' ), + 'shipping_first_name' => __( 'Shipping First Name', 'woocommerce' ), + 'shipping_last_name' => __( 'Shipping Last Name', 'woocommerce' ), + 'shipping_company' => __( 'Shipping Company', 'woocommerce' ), + 'shipping_address_1' => __( 'Shipping Address 1', 'woocommerce' ), + 'shipping_address_2' => __( 'Shipping Address 2', 'woocommerce' ), + 'shipping_city' => __( 'Shipping City', 'woocommerce' ), + 'shipping_postcode' => __( 'Shipping Postal/Zip Code', 'woocommerce' ), + 'shipping_state' => __( 'Shipping State', 'woocommerce' ), + 'shipping_country' => __( 'Shipping Country', 'woocommerce' ), + ), $customer ); + + foreach ( $props_to_export as $prop => $description ) { + $value = ''; + + if ( is_callable( array( $customer, 'get_' . $prop ) ) ) { + $value = $customer->{"get_$prop"}( 'edit' ); + } + + $value = apply_filters( 'woocommerce_privacy_export_customer_personal_data_prop_value', $value, $prop, $customer ); + + if ( $value ) { + $personal_data[] = array( + 'name' => $description, + 'value' => $value, + ); + } + } + + /** + * Allow extensions to register their own personal data for this customer for the export. + * + * @since 3.4.0 + * @param array $personal_data Array of name value pairs. + * @param WC_Order $order A customer object. + */ + $personal_data = apply_filters( 'woocommerce_privacy_export_customer_personal_data', $personal_data, $customer ); + + return $personal_data; + } + + /** + * Get personal data (key/value pairs) for an order object. + * + * @since 3.4.0 + * @param WC_Order $order Order object. + * @return array + */ + protected static function get_order_personal_data( $order ) { + $personal_data = array(); + $props_to_export = apply_filters( 'woocommerce_privacy_export_order_personal_data_props', array( + 'order_number' => __( 'Order Number', 'woocommerce' ), + 'date_created' => __( 'Order Date', 'woocommerce' ), + 'total' => __( 'Order Total', 'woocommerce' ), + 'items' => __( 'Items Purchased', 'woocommerce' ), + 'customer_ip_address' => __( 'IP Address', 'woocommerce' ), + 'customer_user_agent' => __( 'Browser User Agent', 'woocommerce' ), + 'formatted_billing_address' => __( 'Billing Address', 'woocommerce' ), + 'formatted_shipping_address' => __( 'Shipping Address', 'woocommerce' ), + 'billing_phone' => __( 'Phone Number', 'woocommerce' ), + 'billing_email' => __( 'Email Address', 'woocommerce' ), + ), $order ); + + foreach ( $props_to_export as $prop => $name ) { + $value = ''; + + switch ( $prop ) { + case 'items': + $item_names = array(); + foreach ( $order->get_items() as $item ) { + $item_names[] = $item->get_name() . ' x ' . $item->get_quantity(); + } + $value = implode( ', ', $item_names ); + break; + case 'date_created': + $value = wc_format_datetime( $order->get_date_created(), get_option( 'date_format' ) . ', ' . get_option( 'time_format' ) ); + break; + case 'formatted_billing_address': + case 'formatted_shipping_address': + $value = preg_replace( '##i', ', ', $order->{"get_$prop"}() ); + break; + default: + if ( is_callable( array( $order, 'get_' . $prop ) ) ) { + $value = $order->{"get_$prop"}(); + } + break; + } + + $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_prop', $value, $prop, $order ); + + if ( $value ) { + $personal_data[] = array( + 'name' => $name, + 'value' => $value, + ); + } + } + + // Export meta data. + $meta_to_export = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta', array( + 'Payer first name' => __( 'Payer first name', 'woocommerce' ), + 'Payer last name' => __( 'Payer last name', 'woocommerce' ), + 'Payer PayPal address' => __( 'Payer PayPal address', 'woocommerce' ), + 'Transaction ID' => __( 'Transaction ID', 'woocommerce' ), + ) ); + + if ( ! empty( $meta_to_export ) && is_array( $meta_to_export ) ) { + foreach ( $meta_to_export as $meta_key => $name ) { + $value = apply_filters( 'woocommerce_privacy_export_order_personal_data_meta_value', $order->get_meta( $meta_key ), $meta_key, $order ); + + if ( $value ) { + $personal_data[] = array( + 'name' => $name, + 'value' => $value, + ); + } + } + } + + /** + * Allow extensions to register their own personal data for this order for the export. + * + * @since 3.4.0 + * @param array $personal_data Array of name value pairs to expose in the export. + * @param WC_Order $order An order object. + */ + $personal_data = apply_filters( 'woocommerce_privacy_export_order_personal_data', $personal_data, $order ); + + return $personal_data; + } + + /** + * Get personal data (key/value pairs) for a download object. + * + * @since 3.4.0 + * @param WC_Order $download Download object. + * @return array + */ + protected static function get_download_personal_data( $download ) { + $personal_data = array( + array( + 'name' => __( 'Download ID', 'woocommerce' ), + 'value' => $download->get_id(), + ), + array( + 'name' => __( 'Order ID', 'woocommerce' ), + 'value' => $download->get_order_id(), + ), + array( + 'name' => __( 'Product', 'woocommerce' ), + 'value' => get_the_title( $download->get_product_id() ), + ), + array( + 'name' => __( 'User email', 'woocommerce' ), + 'value' => $download->get_user_email(), + ), + array( + 'name' => __( 'Downloads remaining', 'woocommerce' ), + 'value' => $download->get_downloads_remaining(), + ), + array( + 'name' => __( 'Download count', 'woocommerce' ), + 'value' => $download->get_download_count(), + ), + array( + 'name' => __( 'Access granted', 'woocommerce' ), + 'value' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ), + ), + array( + 'name' => __( 'Access expires', 'woocommerce' ), + 'value' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null, + ), + ); + + /** + * Allow extensions to register their own personal data for this download for the export. + * + * @since 3.4.0 + * @param array $personal_data Array of name value pairs to expose in the export. + * @param WC_Order $order An order object. + */ + $personal_data = apply_filters( 'woocommerce_privacy_export_download_personal_data', $personal_data, $download ); + + return $personal_data; + } + + /** + * Finds and exports payment tokens by email address for a customer. + * + * @since 3.4.0 + * @param string $email_address The user email address. + * @param int $page Page. + * @return array An array of personal data in name value pairs + */ + public static function customer_tokens_exporter( $email_address, $page ) { + $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. + $data_to_export = array(); + + if ( ! $user instanceof WP_User ) { + return array( + 'data' => $data_to_export, + 'done' => true, + ); + } + + $tokens = WC_Payment_Tokens::get_tokens( array( + 'user_id' => $user->ID, + 'limit' => 10, + 'page' => $page, + ) ); + + if ( 0 < count( $tokens ) ) { + foreach ( $tokens as $token ) { + $data_to_export[] = array( + 'group_id' => 'woocommerce_tokens', + 'group_label' => __( 'Payment Tokens', 'woocommerce' ), + 'item_id' => 'token-' . $token->get_id(), + 'data' => array( + array( + 'name' => __( 'Token', 'woocommerce' ), + 'value' => $token->get_display_name(), + ), + ), + ); + } + $done = 10 > count( $tokens ); + } else { + $done = true; + } + + return array( + 'data' => $data_to_export, + 'done' => $done, + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy.php new file mode 100644 index 0000000..31739fe --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-privacy.php @@ -0,0 +1,353 @@ +add_exporter( 'woocommerce-customer-data', __( 'Customer Data', 'woocommerce' ), array( 'WC_Privacy_Exporters', 'customer_data_exporter' ) ); + $this->add_exporter( 'woocommerce-customer-orders', __( 'Customer Orders', 'woocommerce' ), array( 'WC_Privacy_Exporters', 'order_data_exporter' ) ); + $this->add_exporter( 'woocommerce-customer-downloads', __( 'Customer Downloads', 'woocommerce' ), array( 'WC_Privacy_Exporters', 'download_data_exporter' ) ); + $this->add_exporter( 'woocommerce-customer-tokens', __( 'Customer Payment Tokens', 'woocommerce' ), array( 'WC_Privacy_Exporters', 'customer_tokens_exporter' ) ); + + // This hook registers WooCommerce data erasers. + $this->add_eraser( 'woocommerce-customer-data', __( 'Customer Data', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'customer_data_eraser' ) ); + $this->add_eraser( 'woocommerce-customer-orders', __( 'Customer Orders', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'order_data_eraser' ) ); + $this->add_eraser( 'woocommerce-customer-downloads', __( 'Customer Downloads', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'download_data_eraser' ) ); + $this->add_eraser( 'woocommerce-customer-tokens', __( 'Customer Payment Tokens', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'customer_tokens_eraser' ) ); + + // Cleanup orders daily - this is a callback on a daily cron event. + add_action( 'woocommerce_cleanup_personal_data', array( $this, 'queue_cleanup_personal_data' ) ); + + // Handles custom anonomization types not included in core. + add_filter( 'wp_privacy_anonymize_data', array( $this, 'anonymize_custom_data_types' ), 10, 3 ); + + // When this is fired, data is removed in a given order. Called from bulk actions. + add_action( 'woocommerce_remove_order_personal_data', array( 'WC_Privacy_Erasers', 'remove_order_personal_data' ) ); + } + + /** + * Add privacy policy content for the privacy policy page. + * + * @since 3.4.0 + */ + public function get_privacy_message() { + $content = ' +
      ' . + '

      ' . + __( 'This sample language includes the basics around what personal data your store may be collecting, storing and sharing, as well as who may have access to that data. Depending on what settings are enabled and which additional plugins are used, the specific information shared by your store will vary. We recommend consulting with a lawyer when deciding what information to disclose on your privacy policy.', 'woocommerce' ) . + '

      ' . + '
      ' . + '

      ' . __( 'We collect information about you during the checkout process on our store.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'What we collect and store', 'woocommerce' ) . '

      ' . + '

      ' . __( 'While you visit our site, we’ll track:', 'woocommerce' ) . '

      ' . + '
        ' . + '
      • ' . __( 'Products you’ve viewed: we’ll use this to, for example, show you products you’ve recently viewed', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Location, IP address and browser type: we’ll use this for purposes like estimating taxes and shipping', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Shipping address: we’ll ask you to enter this so we can, for instance, estimate shipping before you place an order, and send you the order!', 'woocommerce' ) . '
      • ' . + '
      ' . + '

      ' . __( 'We’ll also use cookies to keep track of cart contents while you’re browsing our site.', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'Note: you may want to further detail your cookie policy, and link to that section from here.', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'When you purchase from us, we’ll ask you to provide information including your name, billing address, shipping address, email address, phone number, credit card/payment details and optional account information like username and password. We’ll use this information for purposes, such as, to:', 'woocommerce' ) . '

      ' . + '
        ' . + '
      • ' . __( 'Send you information about your account and order', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Respond to your requests, including refunds and complaints', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Process payments and prevent fraud', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Set up your account for our store', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Comply with any legal obligations we have, such as calculating taxes', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Improve our store offerings', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Send you marketing messages, if you choose to receive them', 'woocommerce' ) . '
      • ' . + '
      ' . + '

      ' . __( 'If you create an account, we will store your name, address, email and phone number, which will be used to populate the checkout for future orders.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'We generally store information about you for as long as we need the information for the purposes for which we collect and use it, and we are not legally required to continue to keep it. For example, we will store order information for XXX years for tax and accounting purposes. This includes your name, email address and billing and shipping addresses.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'We will also store comments or reviews, if you choose to leave them.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'Who on our team has access', 'woocommerce' ) . '

      ' . + '

      ' . __( 'Members of our team have access to the information you provide us. For example, both Administrators and Shop Managers can access:', 'woocommerce' ) . '

      ' . + '
        ' . + '
      • ' . __( 'Order information like what was purchased, when it was purchased and where it should be sent, and', 'woocommerce' ) . '
      • ' . + '
      • ' . __( 'Customer information like your name, email address, and billing and shipping information.', 'woocommerce' ) . '
      • ' . + '
      ' . + '

      ' . __( 'Our team members have access to this information to help fulfill orders, process refunds and support you.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'What we share with others', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'In this section you should list who you’re sharing data with, and for what purpose. This could include, but may not be limited to, analytics, marketing, payment gateways, shipping providers, and third party embeds.', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'We share information with third parties who help us provide our orders and store services to you; for example --', 'woocommerce' ) . '

      ' . + '

      ' . __( 'Payments', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'In this subsection you should list which third party payment processors you’re using to take payments on your store since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'woocommerce' ) . '

      ' . + '
      ' . + '

      ' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'woocommerce' ) . '

      ' . + '

      ' . __( 'Please see the PayPal Privacy Policy for more details.', 'woocommerce' ) . '

      '; + + return apply_filters( 'wc_privacy_policy_content', $content ); + } + + /** + * Spawn events for order cleanup. + */ + public function queue_cleanup_personal_data() { + self::$background_process->push_to_queue( array( 'task' => 'trash_pending_orders' ) ); + self::$background_process->push_to_queue( array( 'task' => 'trash_failed_orders' ) ); + self::$background_process->push_to_queue( array( 'task' => 'trash_cancelled_orders' ) ); + self::$background_process->push_to_queue( array( 'task' => 'anonymize_completed_orders' ) ); + self::$background_process->push_to_queue( array( 'task' => 'delete_inactive_accounts' ) ); + self::$background_process->save()->dispatch(); + } + + /** + * Handle some custom types of data and anonymize them. + * + * @param string $anonymous Anonymized string. + * @param string $type Type of data. + * @param string $data The data being anonymized. + * @return string Anonymized string. + */ + public function anonymize_custom_data_types( $anonymous, $type, $data ) { + switch ( $type ) { + case 'address_state': + case 'address_country': + $anonymous = ''; // Empty string - we don't want to store anything after removal. + break; + case 'phone': + $anonymous = preg_replace( '/\d/u', '0', $data ); + break; + case 'numeric_id': + $anonymous = 0; + break; + } + return $anonymous; + } + + /** + * Find and trash old orders. + * + * @since 3.4.0 + * @param int $limit Limit orders to process per batch. + * @return int Number of orders processed. + */ + public static function trash_pending_orders( $limit = 20 ) { + $option = wc_parse_relative_date_option( get_option( 'woocommerce_trash_pending_orders' ) ); + + if ( empty( $option['number'] ) ) { + return 0; + } + + return self::trash_orders_query( apply_filters( 'woocommerce_trash_pending_orders_query_args', array( + 'date_created' => '<' . strtotime( '-' . $option['number'] . ' ' . $option['unit'] ), + 'limit' => $limit, // Batches of 20. + 'status' => 'wc-pending', + 'type' => 'shop_order', + ) ) ); + } + + /** + * Find and trash old orders. + * + * @since 3.4.0 + * @param int $limit Limit orders to process per batch. + * @return int Number of orders processed. + */ + public static function trash_failed_orders( $limit = 20 ) { + $option = wc_parse_relative_date_option( get_option( 'woocommerce_trash_failed_orders' ) ); + + if ( empty( $option['number'] ) ) { + return 0; + } + + return self::trash_orders_query( apply_filters( 'woocommerce_trash_failed_orders_query_args', array( + 'date_created' => '<' . strtotime( '-' . $option['number'] . ' ' . $option['unit'] ), + 'limit' => $limit, // Batches of 20. + 'status' => 'wc-failed', + 'type' => 'shop_order', + ) ) ); + } + + /** + * Find and trash old orders. + * + * @since 3.4.0 + * @param int $limit Limit orders to process per batch. + * @return int Number of orders processed. + */ + public static function trash_cancelled_orders( $limit = 20 ) { + $option = wc_parse_relative_date_option( get_option( 'woocommerce_trash_cancelled_orders' ) ); + + if ( empty( $option['number'] ) ) { + return 0; + } + + return self::trash_orders_query( apply_filters( 'woocommerce_trash_cancelled_orders_query_args', array( + 'date_created' => '<' . strtotime( '-' . $option['number'] . ' ' . $option['unit'] ), + 'limit' => $limit, // Batches of 20. + 'status' => 'wc-cancelled', + 'type' => 'shop_order', + ) ) ); + } + + /** + * For a given query trash all matches. + * + * @since 3.4.0 + * @param array $query Query array to pass to wc_get_orders(). + * @return int Count of orders that were trashed. + */ + protected static function trash_orders_query( $query ) { + $orders = wc_get_orders( $query ); + $count = 0; + + if ( $orders ) { + foreach ( $orders as $order ) { + $order->delete( false ); + $count ++; + } + } + + return $count; + } + + /** + * Anonymize old completed orders. + * + * @since 3.4.0 + * @param int $limit Limit orders to process per batch. + * @return int Number of orders processed. + */ + public static function anonymize_completed_orders( $limit = 20 ) { + $option = wc_parse_relative_date_option( get_option( 'woocommerce_anonymize_completed_orders' ) ); + + if ( empty( $option['number'] ) ) { + return 0; + } + + return self::anonymize_orders_query( apply_filters( 'woocommerce_anonymize_completed_orders_query_args', array( + 'date_created' => '<' . strtotime( '-' . $option['number'] . ' ' . $option['unit'] ), + 'limit' => $limit, // Batches of 20. + 'status' => 'wc-completed', + 'anonymized' => false, + 'type' => 'shop_order', + ) ) ); + } + + /** + * For a given query, anonymize all matches. + * + * @since 3.4.0 + * @param array $query Query array to pass to wc_get_orders(). + * @return int Count of orders that were anonymized. + */ + protected static function anonymize_orders_query( $query ) { + $orders = wc_get_orders( $query ); + $count = 0; + + if ( $orders ) { + foreach ( $orders as $order ) { + WC_Privacy_Erasers::remove_order_personal_data( $order ); + $count ++; + } + } + + return $count; + } + + /** + * Delete inactive accounts. + * + * @since 3.4.0 + * @param int $limit Limit users to process per batch. + * @return int Number of users processed. + */ + public static function delete_inactive_accounts( $limit = 20 ) { + $option = wc_parse_relative_date_option( get_option( 'woocommerce_delete_inactive_accounts' ) ); + + if ( empty( $option['number'] ) ) { + return 0; + } + + return self::delete_inactive_accounts_query( strtotime( '-' . $option['number'] . ' ' . $option['unit'] ), $limit ); + } + + /** + * Delete inactive accounts. + * + * @since 3.4.0 + * @param int $timestamp Timestamp to delete customers before. + * @param int $limit Limit number of users to delete per run. + * @return int Count of customers that were deleted. + */ + protected static function delete_inactive_accounts_query( $timestamp, $limit = 20 ) { + $count = 0; + $user_query = new WP_User_Query( array( + 'fields' => 'ID', + 'number' => $limit, + 'role__in' => apply_filters( 'woocommerce_delete_inactive_account_roles', array( + 'Customer', + 'Subscriber', + ) ), + 'meta_query' => array( + 'relation' => 'AND', + array( + 'key' => 'wc_last_active', + 'value' => (string) $timestamp, + 'compare' => '<', + 'type' => 'NUMERIC', + ), + array( + 'key' => 'wc_last_active', + 'value' => '0', + 'compare' => '>', + 'type' => 'NUMERIC', + ), + ), + ) ); + + $user_ids = $user_query->get_results(); + + if ( $user_ids ) { + foreach ( $user_ids as $user_id ) { + wp_delete_user( $user_id ); + $count ++; + } + } + + return $count; + } +} + +new WC_Privacy(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-attribute.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-attribute.php new file mode 100644 index 0000000..bf68696 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-attribute.php @@ -0,0 +1,328 @@ + 0, + 'name' => '', + 'options' => array(), + 'position' => 0, + 'visible' => false, + 'variation' => false, + ); + + /** + * Return if this attribute is a taxonomy. + * + * @return boolean + */ + public function is_taxonomy() { + return 0 < $this->get_id(); + } + + /** + * Get taxonomy name if applicable. + * + * @return string + */ + public function get_taxonomy() { + return $this->is_taxonomy() ? $this->get_name() : ''; + } + + /** + * Get taxonomy object. + * + * @return array|null + */ + public function get_taxonomy_object() { + global $wc_product_attributes; + return $this->is_taxonomy() ? $wc_product_attributes[ $this->get_name() ] : null; + } + + /** + * Gets terms from the stored options. + * + * @return array|null + */ + public function get_terms() { + if ( ! $this->is_taxonomy() || ! taxonomy_exists( $this->get_name() ) ) { + return null; + } + $terms = array(); + foreach ( $this->get_options() as $option ) { + if ( is_int( $option ) ) { + $term = get_term_by( 'id', $option, $this->get_name() ); + } else { + // Term names get escaped in WP. See sanitize_term_field. + $term = get_term_by( 'name', $option, $this->get_name() ); + + if ( ! $term || is_wp_error( $term ) ) { + $new_term = wp_insert_term( $option, $this->get_name() ); + $term = is_wp_error( $new_term ) ? false : get_term_by( 'id', $new_term['term_id'], $this->get_name() ); + } + } + if ( $term && ! is_wp_error( $term ) ) { + $terms[] = $term; + } + } + return $terms; + } + + /** + * Gets slugs from the stored options, or just the string if text based. + * + * @return array + */ + public function get_slugs() { + if ( ! $this->is_taxonomy() || ! taxonomy_exists( $this->get_name() ) ) { + return $this->get_options(); + } + $terms = array(); + foreach ( $this->get_options() as $option ) { + if ( is_int( $option ) ) { + $term = get_term_by( 'id', $option, $this->get_name() ); + } else { + $term = get_term_by( 'name', $option, $this->get_name() ); + + if ( ! $term || is_wp_error( $term ) ) { + $new_term = wp_insert_term( $option, $this->get_name() ); + $term = is_wp_error( $new_term ) ? false : get_term_by( 'id', $new_term['term_id'], $this->get_name() ); + } + } + if ( $term && ! is_wp_error( $term ) ) { + $terms[] = $term->slug; + } + } + return $terms; + } + + /** + * Returns all data for this object. + * + * @return array + */ + public function get_data() { + return array_merge( + $this->data, array( + 'is_visible' => $this->get_visible() ? 1 : 0, + 'is_variation' => $this->get_variation() ? 1 : 0, + 'is_taxonomy' => $this->is_taxonomy() ? 1 : 0, + 'value' => $this->is_taxonomy() ? '' : wc_implode_text_attributes( $this->get_options() ), + ) + ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set ID (this is the attribute ID). + * + * @param int $value Attribute ID. + */ + public function set_id( $value ) { + $this->data['id'] = absint( $value ); + } + + /** + * Set name (this is the attribute name or taxonomy). + * + * @param int $value Attribute name. + */ + public function set_name( $value ) { + $this->data['name'] = $value; + } + + /** + * Set options. + * + * @param array $value Attribute options. + */ + public function set_options( $value ) { + $this->data['options'] = $value; + } + + /** + * Set position. + * + * @param int $value Attribute position. + */ + public function set_position( $value ) { + $this->data['position'] = absint( $value ); + } + + /** + * Set if visible. + * + * @param bool $value If is visible on Product's additional info tab. + */ + public function set_visible( $value ) { + $this->data['visible'] = wc_string_to_bool( $value ); + } + + /** + * Set if variation. + * + * @param bool $value If is used for variations. + */ + public function set_variation( $value ) { + $this->data['variation'] = wc_string_to_bool( $value ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get the ID. + * + * @return int + */ + public function get_id() { + return $this->data['id']; + } + + /** + * Get name. + * + * @return int + */ + public function get_name() { + return $this->data['name']; + } + + /** + * Get options. + * + * @return array + */ + public function get_options() { + return $this->data['options']; + } + + /** + * Get position. + * + * @return int + */ + public function get_position() { + return $this->data['position']; + } + + /** + * Get if visible. + * + * @return bool + */ + public function get_visible() { + return $this->data['visible']; + } + + /** + * Get if variation. + * + * @return bool + */ + public function get_variation() { + return $this->data['variation']; + } + + /* + |-------------------------------------------------------------------------- + | ArrayAccess/Backwards compatibility. + |-------------------------------------------------------------------------- + */ + + /** + * OffsetGet. + * + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + switch ( $offset ) { + case 'is_variation': + return $this->get_variation() ? 1 : 0; + case 'is_visible': + return $this->get_visible() ? 1 : 0; + case 'is_taxonomy': + return $this->is_taxonomy() ? 1 : 0; + case 'value': + return $this->is_taxonomy() ? '' : wc_implode_text_attributes( $this->get_options() ); + default: + if ( is_callable( array( $this, "get_$offset" ) ) ) { + return $this->{"get_$offset"}(); + } + break; + } + return ''; + } + + /** + * OffsetSet. + * + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + switch ( $offset ) { + case 'is_variation': + $this->set_variation( $value ); + break; + case 'is_visible': + $this->set_visible( $value ); + break; + case 'value': + $this->set_options( $value ); + break; + default: + if ( is_callable( array( $this, "set_$offset" ) ) ) { + return $this->{"set_$offset"}( $value ); + } + break; + } + } + + /** + * OffsetUnset. + * + * @param string $offset Offset. + */ + public function offsetUnset( $offset ) {} + + /** + * OffsetExists. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + return in_array( $offset, array_merge( array( 'is_variation', 'is_visible', 'is_taxonomy', 'value' ), array_keys( $this->data ) ), true ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-download.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-download.php new file mode 100644 index 0000000..d4f3db7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-download.php @@ -0,0 +1,264 @@ + '', + 'name' => '', + 'file' => '', + ); + + /** + * Returns all data for this object. + * + * @return array + */ + public function get_data() { + return $this->data; + } + + /** + * Get allowed mime types. + * + * @return array + */ + public function get_allowed_mime_types() { + return apply_filters( 'woocommerce_downloadable_file_allowed_mime_types', get_allowed_mime_types() ); + } + + /** + * Get type of file path set. + * + * @param string $file_path optional. + * @return string absolute, relative, or shortcode. + */ + public function get_type_of_file_path( $file_path = '' ) { + $file_path = $file_path ? $file_path : $this->get_file(); + if ( 0 === strpos( $file_path, 'http' ) || 0 === strpos( $file_path, '//' ) ) { + return 'absolute'; + } elseif ( '[' === substr( $file_path, 0, 1 ) && ']' === substr( $file_path, -1 ) ) { + return 'shortcode'; + } else { + return 'relative'; + } + } + + /** + * Get file type. + * + * @return string + */ + public function get_file_type() { + $type = wp_check_filetype( strtok( $this->get_file(), '?' ), $this->get_allowed_mime_types() ); + return $type['type']; + } + + /** + * Get file extension. + * + * @return string + */ + public function get_file_extension() { + $parsed_url = wp_parse_url( $this->get_file(), PHP_URL_PATH ); + return pathinfo( $parsed_url, PATHINFO_EXTENSION ); + } + + /** + * Check if file is allowed. + * + * @return boolean + */ + public function is_allowed_filetype() { + if ( 'relative' !== $this->get_type_of_file_path() ) { + return true; + } + return ! $this->get_file_extension() || in_array( $this->get_file_type(), $this->get_allowed_mime_types(), true ); + } + + /** + * Validate file exists. + * + * @return boolean + */ + public function file_exists() { + if ( 'relative' !== $this->get_type_of_file_path() ) { + return true; + } + $file_url = $this->get_file(); + if ( '..' === substr( $file_url, 0, 2 ) || '/' !== substr( $file_url, 0, 1 ) ) { + $file_url = realpath( ABSPATH . $file_url ); + } elseif ( substr( WP_CONTENT_DIR, strlen( untrailingslashit( ABSPATH ) ) ) === substr( $file_url, 0, strlen( substr( WP_CONTENT_DIR, strlen( untrailingslashit( ABSPATH ) ) ) ) ) ) { + $file_url = realpath( WP_CONTENT_DIR . substr( $file_url, 11 ) ); + } + return apply_filters( 'woocommerce_downloadable_file_exists', file_exists( $file_url ), $this->get_file() ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set ID. + * + * @param string $value Download ID. + */ + public function set_id( $value ) { + $this->data['id'] = wc_clean( $value ); + } + + /** + * Set name. + * + * @param string $value Download name. + */ + public function set_name( $value ) { + $this->data['name'] = wc_clean( $value ); + } + + /** + * Set previous_hash. + * + * @deprecated 3.3.0 No longer using filename based hashing to keep track of files. + * @param string $value Previous hash. + */ + public function set_previous_hash( $value ) { + wc_deprecated_function( __FUNCTION__, '3.3' ); + $this->data['previous_hash'] = wc_clean( $value ); + } + + /** + * Set file. + * + * @param string $value File. + */ + public function set_file( $value ) { + switch ( $this->get_type_of_file_path( $value ) ) { + case 'absolute': + $this->data['file'] = esc_url_raw( $value ); + break; + default: + $this->data['file'] = wc_clean( $value ); + break; + } + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get id. + * + * @return string + */ + public function get_id() { + return $this->data['id']; + } + + /** + * Get name. + * + * @return string + */ + public function get_name() { + return $this->data['name']; + } + + /** + * Get previous_hash. + * + * @deprecated 3.3.0 No longer using filename based hashing to keep track of files. + * @return string + */ + public function get_previous_hash() { + wc_deprecated_function( __FUNCTION__, '3.3' ); + return $this->data['previous_hash']; + } + + /** + * Get file. + * + * @return string + */ + public function get_file() { + return $this->data['file']; + } + + /* + |-------------------------------------------------------------------------- + | ArrayAccess/Backwards compatibility. + |-------------------------------------------------------------------------- + */ + + /** + * OffsetGet. + * + * @param string $offset Offset. + * @return mixed + */ + public function offsetGet( $offset ) { + switch ( $offset ) { + default: + if ( is_callable( array( $this, "get_$offset" ) ) ) { + return $this->{"get_$offset"}(); + } + break; + } + return ''; + } + + /** + * OffsetSet. + * + * @param string $offset Offset. + * @param mixed $value Value. + */ + public function offsetSet( $offset, $value ) { + switch ( $offset ) { + default: + if ( is_callable( array( $this, "set_$offset" ) ) ) { + return $this->{"set_$offset"}( $value ); + } + break; + } + } + + /** + * OffsetUnset. + * + * @param string $offset Offset. + */ + public function offsetUnset( $offset ) {} + + /** + * OffsetExists. + * + * @param string $offset Offset. + * @return bool + */ + public function offsetExists( $offset ) { + return in_array( $offset, array_keys( $this->data ), true ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-external.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-external.php new file mode 100644 index 0000000..b99f10b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-external.php @@ -0,0 +1,194 @@ + '', + 'button_text' => '', + ); + + /** + * Get internal type. + * + * @return string + */ + public function get_type() { + return 'external'; + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + | + | Methods for getting data from the product object. + */ + + /** + * Get product url. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_product_url( $context = 'view' ) { + return esc_url_raw( $this->get_prop( 'product_url', $context ) ); + } + + /** + * Get button text. + * + * @param string $context What the value is for. Valid values are 'view' and 'edit'. + * @return string + */ + public function get_button_text( $context = 'view' ) { + return $this->get_prop( 'button_text', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + | + | Functions for setting product data. These should not update anything in the + | database itself and should only change what is stored in the class + | object. + */ + + /** + * Set product URL. + * + * @since 3.0.0 + * @param string $product_url Product URL. + */ + public function set_product_url( $product_url ) { + $this->set_prop( 'product_url', htmlspecialchars_decode( $product_url ) ); + } + + /** + * Set button text. + * + * @since 3.0.0 + * @param string $button_text Button text. + */ + public function set_button_text( $button_text ) { + $this->set_prop( 'button_text', $button_text ); + } + + /** + * External products cannot be stock managed. + * + * @since 3.0.0 + * @param bool $manage_stock If manage stock. + */ + public function set_manage_stock( $manage_stock ) { + $this->set_prop( 'manage_stock', false ); + + if ( true === $manage_stock ) { + $this->error( 'product_external_invalid_manage_stock', __( 'External products cannot be stock managed.', 'woocommerce' ) ); + } + } + + /** + * External products cannot be stock managed. + * + * @since 3.0.0 + * + * @param string $stock_status Stock status. + */ + public function set_stock_status( $stock_status = '' ) { + $this->set_prop( 'stock_status', 'instock' ); + + if ( 'instock' !== $stock_status ) { + $this->error( 'product_external_invalid_stock_status', __( 'External products cannot be stock managed.', 'woocommerce' ) ); + } + } + + /** + * External products cannot be backordered. + * + * @since 3.0.0 + * @param string $backorders Options: 'yes', 'no' or 'notify'. + */ + public function set_backorders( $backorders ) { + $this->set_prop( 'backorders', 'no' ); + + if ( 'no' !== $backorders ) { + $this->error( 'product_external_invalid_backorders', __( 'External products cannot be backordered.', 'woocommerce' ) ); + } + } + + /* + |-------------------------------------------------------------------------- + | Other Actions + |-------------------------------------------------------------------------- + */ + + /** + * Returns false if the product cannot be bought. + * + * @access public + * @return bool + */ + public function is_purchasable() { + return apply_filters( 'woocommerce_is_purchasable', false, $this ); + } + + /** + * Get the add to url used mainly in loops. + * + * @access public + * @return string + */ + public function add_to_cart_url() { + return apply_filters( 'woocommerce_product_add_to_cart_url', $this->get_product_url(), $this ); + } + + /** + * Get the add to cart button text for the single page. + * + * @access public + * @return string + */ + public function single_add_to_cart_text() { + return apply_filters( 'woocommerce_product_single_add_to_cart_text', $this->get_button_text() ? $this->get_button_text() : _x( 'Buy product', 'placeholder', 'woocommerce' ), $this ); + } + + /** + * Get the add to cart button text. + * + * @access public + * @return string + */ + public function add_to_cart_text() { + return apply_filters( 'woocommerce_product_add_to_cart_text', $this->get_button_text() ? $this->get_button_text() : _x( 'Buy product', 'placeholder', 'woocommerce' ), $this ); + } + + /** + * Get the add to cart button text description - used in aria tags. + * + * @since 3.3.0 + * @return string + */ + public function add_to_cart_description() { + /* translators: %s: Product title */ + return apply_filters( 'woocommerce_product_add_to_cart_description', $this->get_button_text() ? $this->get_button_text() : sprintf( __( 'Buy “%s”', 'woocommerce' ), $this->get_name() ), $this ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-factory.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-factory.php new file mode 100644 index 0000000..8e5791d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-factory.php @@ -0,0 +1,119 @@ +get_product_id( $product_id ); + + if ( ! $product_id ) { + return false; + } + + $product_type = $this->get_product_type( $product_id ); + + // Backwards compatibility. + if ( ! empty( $deprecated ) ) { + wc_deprecated_argument( 'args', '3.0', 'Passing args to the product factory is deprecated. If you need to force a type, construct the product class directly.' ); + + if ( isset( $deprecated['product_type'] ) ) { + $product_type = $this->get_classname_from_product_type( $deprecated['product_type'] ); + } + } + + $classname = $this->get_product_classname( $product_id, $product_type ); + + try { + return new $classname( $product_id, $deprecated ); + } catch ( Exception $e ) { + return false; + } + } + + /** + * Gets a product classname and allows filtering. Returns WC_Product_Simple if the class does not exist. + * + * @since 3.0.0 + * @param int $product_id Product ID. + * @param string $product_type Product type. + * @return string + */ + public static function get_product_classname( $product_id, $product_type ) { + $classname = apply_filters( 'woocommerce_product_class', self::get_classname_from_product_type( $product_type ), $product_type, 'variation' === $product_type ? 'product_variation' : 'product', $product_id ); + + if ( ! $classname || ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + + return $classname; + } + + /** + * Get the product type for a product. + * + * @since 3.0.0 + * @param int $product_id Product ID. + * @return string|false + */ + public static function get_product_type( $product_id ) { + // Allow the overriding of the lookup in this function. Return the product type here. + $override = apply_filters( 'woocommerce_product_type_query', false, $product_id ); + if ( ! $override ) { + return WC_Data_Store::load( 'product' )->get_product_type( $product_id ); + } else { + return $override; + } + } + + /** + * Create a WC coding standards compliant class name e.g. WC_Product_Type_Class instead of WC_Product_type-class. + * + * @param string $product_type Product type. + * @return string|false + */ + public static function get_classname_from_product_type( $product_type ) { + return $product_type ? 'WC_Product_' . implode( '_', array_map( 'ucfirst', explode( '-', $product_type ) ) ) : false; + } + + /** + * Get the product ID depending on what was passed. + * + * @since 3.0.0 + * @param WC_Product|WP_Post|int|bool $product Product instance, post instance, numeric or false to use global $post. + * @return int|bool false on failure + */ + private function get_product_id( $product ) { + global $post; + + if ( false === $product && isset( $post, $post->ID ) && 'product' === get_post_type( $post->ID ) ) { + return absint( $post->ID ); + } elseif ( is_numeric( $product ) ) { + return $product; + } elseif ( $product instanceof WC_Product ) { + return $product->get_id(); + } elseif ( ! empty( $product->ID ) ) { + return $product->ID; + } else { + return false; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-grouped.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-grouped.php new file mode 100644 index 0000000..e2b19d0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-grouped.php @@ -0,0 +1,193 @@ + array(), + ); + + /** + * Get internal type. + * + * @return string + */ + public function get_type() { + return 'grouped'; + } + + /** + * Get the add to cart button text. + * + * @return string + */ + public function add_to_cart_text() { + return apply_filters( 'woocommerce_product_add_to_cart_text', __( 'View products', 'woocommerce' ), $this ); + } + + /** + * Get the add to cart button text description - used in aria tags. + * + * @since 3.3.0 + * @return string + */ + public function add_to_cart_description() { + /* translators: %s: Product title */ + return apply_filters( 'woocommerce_product_add_to_cart_description', sprintf( __( 'View products in the “%s” group', 'woocommerce' ), $this->get_name() ), $this ); + } + + /** + * Returns whether or not the product is on sale. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return bool + */ + public function is_on_sale( $context = 'view' ) { + $children = array_filter( array_map( 'wc_get_product', $this->get_children( $context ) ), 'wc_products_array_filter_visible_grouped' ); + $on_sale = false; + + foreach ( $children as $child ) { + if ( $child->is_purchasable() && ! $child->has_child() && $child->is_on_sale() ) { + $on_sale = true; + break; + } + } + + return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $on_sale, $this ) : $on_sale; + } + + /** + * Returns false if the product cannot be bought. + * + * @return bool + */ + public function is_purchasable() { + return apply_filters( 'woocommerce_is_purchasable', false, $this ); + } + + /** + * Returns the price in html format. + * + * @param string $price (default: ''). + * @return string + */ + public function get_price_html( $price = '' ) { + $tax_display_mode = get_option( 'woocommerce_tax_display_shop' ); + $child_prices = array(); + $children = array_filter( array_map( 'wc_get_product', $this->get_children() ), 'wc_products_array_filter_visible_grouped' ); + + foreach ( $children as $child ) { + if ( '' !== $child->get_price() ) { + $child_prices[] = 'incl' === $tax_display_mode ? wc_get_price_including_tax( $child ) : wc_get_price_excluding_tax( $child ); + } + } + + if ( ! empty( $child_prices ) ) { + $min_price = min( $child_prices ); + $max_price = max( $child_prices ); + } else { + $min_price = ''; + $max_price = ''; + } + + if ( '' !== $min_price ) { + if ( $min_price !== $max_price ) { + $price = wc_format_price_range( $min_price, $max_price ); + } else { + $price = wc_price( $min_price ); + } + + $is_free = 0 === $min_price && 0 === $max_price; + + if ( $is_free ) { + $price = apply_filters( 'woocommerce_grouped_free_price_html', __( 'Free!', 'woocommerce' ), $this ); + } else { + $price = apply_filters( 'woocommerce_grouped_price_html', $price . $this->get_price_suffix(), $this, $child_prices ); + } + } else { + $price = apply_filters( 'woocommerce_grouped_empty_price_html', '', $this ); + } + + return apply_filters( 'woocommerce_get_price_html', $price, $this ); + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + | + | Methods for getting data from the product object. + */ + + /** + * Return the children of this product. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return array + */ + public function get_children( $context = 'view' ) { + return $this->get_prop( 'children', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + | + | Methods for getting data from the product object. + */ + + /** + * Return the children of this product. + * + * @param array $children List of product children. + */ + public function set_children( $children ) { + $this->set_prop( 'children', array_filter( wp_parse_id_list( (array) $children ) ) ); + } + + /* + |-------------------------------------------------------------------------- + | Sync with children. + |-------------------------------------------------------------------------- + */ + + /** + * Sync a grouped product with it's children. These sync functions sync + * upwards (from child to parent) when the variation is saved. + * + * @param WC_Product|int $product Product object or ID for which you wish to sync. + * @param bool $save If true, the product object will be saved to the DB before returning it. + * @return WC_Product Synced product object. + */ + public static function sync( $product, $save = true ) { + if ( ! is_a( $product, 'WC_Product' ) ) { + $product = wc_get_product( $product ); + } + if ( is_a( $product, 'WC_Product_Grouped' ) ) { + $data_store = WC_Data_Store::load( 'product-' . $product->get_type() ); + $data_store->sync_price( $product ); + if ( $save ) { + $product->save(); + } + } + return $product; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-query.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-query.php new file mode 100644 index 0000000..d678024 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-query.php @@ -0,0 +1,78 @@ + array( 'draft', 'pending', 'private', 'publish' ), + 'type' => array_merge( array_keys( wc_get_product_types() ) ), + 'limit' => get_option( 'posts_per_page' ), + 'include' => array(), + 'date_created' => '', + 'date_modified' => '', + 'featured' => '', + 'visibility' => '', + 'sku' => '', + 'price' => '', + 'regular_price' => '', + 'sale_price' => '', + 'date_on_sale_from' => '', + 'date_on_sale_to' => '', + 'total_sales' => '', + 'tax_status' => '', + 'tax_class' => '', + 'manage_stock' => '', + 'stock_quantity' => '', + 'stock_status' => '', + 'backorders' => '', + 'sold_individually' => '', + 'weight' => '', + 'length' => '', + 'width' => '', + 'height' => '', + 'reviews_allowed' => '', + 'virtual' => '', + 'downloadable' => '', + 'category' => array(), + 'tag' => array(), + 'shipping_class' => array(), + 'download_limit' => '', + 'download_expiry' => '', + 'average_rating' => '', + 'review_count' => '', + ) + ); + } + + /** + * Get products matching the current query vars. + * + * @return array|object of WC_Product objects + */ + public function get_products() { + $args = apply_filters( 'woocommerce_product_object_query_args', $this->get_query_vars() ); + $results = WC_Data_Store::load( 'product' )->query( $args ); + return apply_filters( 'woocommerce_product_object_query', $results, $args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-simple.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-simple.php new file mode 100644 index 0000000..e736b40 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-simple.php @@ -0,0 +1,70 @@ +supports[] = 'ajax_add_to_cart'; + parent::__construct( $product ); + } + + /** + * Get internal type. + * + * @return string + */ + public function get_type() { + return 'simple'; + } + + /** + * Get the add to url used mainly in loops. + * + * @return string + */ + public function add_to_cart_url() { + $url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg( 'added-to-cart', add_query_arg( 'add-to-cart', $this->id ) ) : get_permalink( $this->id ); + + return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this ); + } + + /** + * Get the add to cart button text. + * + * @return string + */ + public function add_to_cart_text() { + $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); + + return apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this ); + } + + /** + * Get the add to cart button text description - used in aria tags. + * + * @since 3.3.0 + * @return string + */ + public function add_to_cart_description() { + /* translators: %s: Product title */ + $text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add “%s” to your cart', 'woocommerce' ) : __( 'Read more about “%s”', 'woocommerce' ); + + return apply_filters( 'woocommerce_product_add_to_cart_description', sprintf( $text, $this->get_name() ), $this ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php new file mode 100644 index 0000000..5a14815 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php @@ -0,0 +1,633 @@ +is_purchasable() ? __( 'Select options', 'woocommerce' ) : __( 'Read more', 'woocommerce' ), $this ); + } + + /** + * Get the add to cart button text description - used in aria tags. + * + * @since 3.3.0 + * @return string + */ + public function add_to_cart_description() { + /* translators: %s: Product title */ + return apply_filters( 'woocommerce_product_add_to_cart_description', sprintf( __( 'Select options for “%s”', 'woocommerce' ), $this->get_name() ), $this ); + } + + /** + * Get an array of all sale and regular prices from all variations. This is used for example when displaying the price range at variable product level or seeing if the variable product is on sale. + * + * @param bool $for_display If true, prices will be adapted for display based on the `woocommerce_tax_display_shop` setting (including or excluding taxes). + * @return array Array of RAW prices, regular prices, and sale prices with keys set to variation ID. + */ + public function get_variation_prices( $for_display = false ) { + $prices = $this->data_store->read_price_data( $this, $for_display ); + + foreach ( $prices as $price_key => $variation_prices ) { + $prices[ $price_key ] = $this->sort_variation_prices( $variation_prices ); + } + + return $prices; + } + + /** + * Get the min or max variation regular price. + * + * @param string $min_or_max Min or max price. + * @param boolean $for_display If true, prices will be adapted for display based on the `woocommerce_tax_display_shop` setting (including or excluding taxes). + * @return string + */ + public function get_variation_regular_price( $min_or_max = 'min', $for_display = false ) { + $prices = $this->get_variation_prices( $for_display ); + $price = 'min' === $min_or_max ? current( $prices['regular_price'] ) : end( $prices['regular_price'] ); + + return apply_filters( 'woocommerce_get_variation_regular_price', $price, $this, $min_or_max, $for_display ); + } + + /** + * Get the min or max variation sale price. + * + * @param string $min_or_max Min or max price. + * @param boolean $for_display If true, prices will be adapted for display based on the `woocommerce_tax_display_shop` setting (including or excluding taxes). + * @return string + */ + public function get_variation_sale_price( $min_or_max = 'min', $for_display = false ) { + $prices = $this->get_variation_prices( $for_display ); + $price = 'min' === $min_or_max ? current( $prices['sale_price'] ) : end( $prices['sale_price'] ); + + return apply_filters( 'woocommerce_get_variation_sale_price', $price, $this, $min_or_max, $for_display ); + } + + /** + * Get the min or max variation (active) price. + * + * @param string $min_or_max Min or max price. + * @param boolean $for_display If true, prices will be adapted for display based on the `woocommerce_tax_display_shop` setting (including or excluding taxes). + * @return string + */ + public function get_variation_price( $min_or_max = 'min', $for_display = false ) { + $prices = $this->get_variation_prices( $for_display ); + $price = 'min' === $min_or_max ? current( $prices['price'] ) : end( $prices['price'] ); + + return apply_filters( 'woocommerce_get_variation_price', $price, $this, $min_or_max, $for_display ); + } + + /** + * Returns the price in html format. + * + * Note: Variable prices do not show suffixes like other product types. This + * is due to some things like tax classes being set at variation level which + * could differ from the parent price. The only way to show accurate prices + * would be to load the variation and get IT's price, which adds extra + * overhead and still has edge cases where the values would be inaccurate. + * + * Additionally, ranges of prices no longer show 'striked out' sale prices + * due to the strings being very long and unclear/confusing. A single range + * is shown instead. + * + * @param string $price Price (default: ''). + * @return string + */ + public function get_price_html( $price = '' ) { + $prices = $this->get_variation_prices( true ); + + if ( empty( $prices['price'] ) ) { + $price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this ); + } else { + $min_price = current( $prices['price'] ); + $max_price = end( $prices['price'] ); + $min_reg_price = current( $prices['regular_price'] ); + $max_reg_price = end( $prices['regular_price'] ); + + if ( $min_price !== $max_price ) { + $price = wc_format_price_range( $min_price, $max_price ); + } elseif ( $this->is_on_sale() && $min_reg_price === $max_reg_price ) { + $price = wc_format_sale_price( wc_price( $max_reg_price ), wc_price( $min_price ) ); + } else { + $price = wc_price( $min_price ); + } + + $price = apply_filters( 'woocommerce_variable_price_html', $price . $this->get_price_suffix(), $this ); + } + + return apply_filters( 'woocommerce_get_price_html', $price, $this ); + } + + /** + * Get the suffix to display after prices > 0. + * + * This is skipped if the suffix + * has dynamic values such as {price_excluding_tax} for variable products. + * + * @see get_price_html for an explanation as to why. + * @param string $price Price to calculate, left blank to just use get_price(). + * @param integer $qty Quantity passed on to get_price_including_tax() or get_price_excluding_tax(). + * @return string + */ + public function get_price_suffix( $price = '', $qty = 1 ) { + $suffix = get_option( 'woocommerce_price_display_suffix' ); + + if ( strstr( $suffix, '{' ) ) { + return apply_filters( 'woocommerce_get_price_suffix', '', $this, $price, $qty ); + } else { + return parent::get_price_suffix( $price, $qty ); + } + } + + /** + * Return a products child ids. + * + * This is lazy loaded as it's not used often and does require several queries. + * + * @param bool|string $visible_only Visible only. + * @return array Children ids + */ + public function get_children( $visible_only = '' ) { + if ( is_bool( $visible_only ) ) { + wc_deprecated_argument( 'visible_only', '3.0', 'WC_Product_Variable::get_visible_children' ); + + return $visible_only ? $this->get_visible_children() : $this->get_children(); + } + + if ( null === $this->children ) { + $children = $this->data_store->read_children( $this ); + $this->set_children( $children['all'] ); + $this->set_visible_children( $children['visible'] ); + } + + return apply_filters( 'woocommerce_get_children', $this->children, $this, false ); + } + + /** + * Return a products child ids - visible only. + * + * This is lazy loaded as it's not used often and does require several queries. + * + * @since 3.0.0 + * @return array Children ids + */ + public function get_visible_children() { + if ( null === $this->visible_children ) { + $children = $this->data_store->read_children( $this ); + $this->set_children( $children['all'] ); + $this->set_visible_children( $children['visible'] ); + } + return apply_filters( 'woocommerce_get_children', $this->visible_children, $this, true ); + } + + /** + * Return an array of attributes used for variations, as well as their possible values. + * + * This is lazy loaded as it's not used often and does require several queries. + * + * @return array Attributes and their available values + */ + public function get_variation_attributes() { + if ( null === $this->variation_attributes ) { + $this->variation_attributes = $this->data_store->read_variation_attributes( $this ); + } + return $this->variation_attributes; + } + + /** + * If set, get the default attributes for a variable product. + * + * @param string $attribute_name Attribute name. + * @return string + */ + public function get_variation_default_attribute( $attribute_name ) { + $defaults = $this->get_default_attributes(); + $attribute_name = sanitize_title( $attribute_name ); + + return isset( $defaults[ $attribute_name ] ) ? $defaults[ $attribute_name ] : ''; + } + + /** + * Variable products themselves cannot be downloadable. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return bool + */ + public function get_downloadable( $context = 'view' ) { + return false; + } + + /** + * Variable products themselves cannot be virtual. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return bool + */ + public function get_virtual( $context = 'view' ) { + return false; + } + + /** + * Get an array of available variations for the current product. + * + * @return array + */ + public function get_available_variations() { + $available_variations = array(); + + foreach ( $this->get_children() as $child_id ) { + $variation = wc_get_product( $child_id ); + + // Hide out of stock variations if 'Hide out of stock items from the catalog' is checked. + if ( ! $variation || ! $variation->exists() || ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $variation->is_in_stock() ) ) { + continue; + } + + // Filter 'woocommerce_hide_invisible_variations' to optionally hide invisible variations (disabled variations and variations with empty price). + if ( apply_filters( 'woocommerce_hide_invisible_variations', true, $this->get_id(), $variation ) && ! $variation->variation_is_visible() ) { + continue; + } + + $available_variations[] = $this->get_available_variation( $variation ); + } + $available_variations = array_filter( $available_variations ); + + return $available_variations; + } + + /** + * Returns an array of data for a variation. Used in the add to cart form. + * + * @since 2.4.0 + * @param WC_Product $variation Variation product object or ID. + * @return array|bool + */ + public function get_available_variation( $variation ) { + if ( is_numeric( $variation ) ) { + $variation = wc_get_product( $variation ); + } + if ( ! $variation instanceof WC_Product_Variation ) { + return false; + } + // See if prices should be shown for each variation after selection. + $show_variation_price = apply_filters( 'woocommerce_show_variation_price', $variation->get_price() === '' || $this->get_variation_sale_price( 'min' ) !== $this->get_variation_sale_price( 'max' ) || $this->get_variation_regular_price( 'min' ) !== $this->get_variation_regular_price( 'max' ), $this, $variation ); + + return apply_filters( + 'woocommerce_available_variation', array( + 'attributes' => $variation->get_variation_attributes(), + 'availability_html' => wc_get_stock_html( $variation ), + 'backorders_allowed' => $variation->backorders_allowed(), + 'dimensions' => $variation->get_dimensions( false ), + 'dimensions_html' => wc_format_dimensions( $variation->get_dimensions( false ) ), + 'display_price' => wc_get_price_to_display( $variation ), + 'display_regular_price' => wc_get_price_to_display( $variation, array( 'price' => $variation->get_regular_price() ) ), + 'image' => wc_get_product_attachment_props( $variation->get_image_id() ), + 'image_id' => $variation->get_image_id(), + 'is_downloadable' => $variation->is_downloadable(), + 'is_in_stock' => $variation->is_in_stock(), + 'is_purchasable' => $variation->is_purchasable(), + 'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no', + 'is_virtual' => $variation->is_virtual(), + 'max_qty' => 0 < $variation->get_max_purchase_quantity() ? $variation->get_max_purchase_quantity() : '', + 'min_qty' => $variation->get_min_purchase_quantity(), + 'price_html' => $show_variation_price ? '' . $variation->get_price_html() . '' : '', + 'sku' => $variation->get_sku(), + 'variation_description' => wc_format_content( $variation->get_description() ), + 'variation_id' => $variation->get_id(), + 'variation_is_active' => $variation->variation_is_active(), + 'variation_is_visible' => $variation->variation_is_visible(), + 'weight' => $variation->get_weight(), + 'weight_html' => wc_format_weight( $variation->get_weight() ), + ), $this, $variation + ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Sets an array of variation attributes. + * + * @since 3.0.0 + * @param array $variation_attributes Attributes list. + */ + public function set_variation_attributes( $variation_attributes ) { + $this->variation_attributes = $variation_attributes; + } + + /** + * Sets an array of children for the product. + * + * @since 3.0.0 + * @param array $children Childre products. + */ + public function set_children( $children ) { + $this->children = array_filter( wp_parse_id_list( (array) $children ) ); + } + + /** + * Sets an array of visible children only. + * + * @since 3.0.0 + * @param array $visible_children List of visible children products. + */ + public function set_visible_children( $visible_children ) { + $this->visible_children = array_filter( wp_parse_id_list( (array) $visible_children ) ); + } + + /* + |-------------------------------------------------------------------------- + | CRUD methods + |-------------------------------------------------------------------------- + */ + + /** + * Ensure properties are set correctly before save. + * + * @since 3.0.0 + */ + public function validate_props() { + // Before updating, ensure stock props are all aligned. Qty and backorders are not needed if not stock managed. + if ( ! $this->get_manage_stock() ) { + $this->set_stock_quantity( '' ); + $this->set_backorders( 'no' ); + $this->data_store->sync_stock_status( $this ); + + // If we are stock managing, backorders are allowed, and we don't have stock, force on backorder status. + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' !== $this->get_backorders() ) { + $this->set_stock_status( 'onbackorder' ); + + // If we are stock managing and we don't have stock, force out of stock status. + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' === $this->get_backorders() ) { + $this->set_stock_status( 'outofstock' ); + + // If the stock level is changing and we do now have enough, force in stock status. + } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { + $this->set_stock_status( 'instock' ); + + // Otherwise revert to status the children have. + } else { + $this->set_stock_status( $this->child_is_in_stock() ? 'instock' : 'outofstock' ); + } + } + + /** + * Save data (either create or update depending on if we are working on an existing product). + * + * @since 3.0.0 + */ + public function save() { + $this->validate_props(); + if ( $this->data_store ) { + // Trigger action before saving to the DB. Allows you to adjust object props before save. + do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store ); + + // Get names before save. + $previous_name = $this->data['name']; + $new_name = $this->get_name( 'edit' ); + + if ( $this->get_id() ) { + $this->data_store->update( $this ); + } else { + $this->data_store->create( $this ); + } + + $this->data_store->sync_variation_names( $this, $previous_name, $new_name ); + $this->data_store->sync_managed_variation_stock_status( $this ); + + return $this->get_id(); + } + } + + /* + |-------------------------------------------------------------------------- + | Conditionals + |-------------------------------------------------------------------------- + */ + + /** + * Returns whether or not the product is on sale. + * + * @param string $context What the value is for. Valid values are view and edit. What the value is for. Valid values are view and edit. + * @return bool + */ + public function is_on_sale( $context = 'view' ) { + $prices = $this->get_variation_prices(); + $on_sale = $prices['regular_price'] !== $prices['sale_price'] && $prices['sale_price'] === $prices['price']; + + return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $on_sale, $this ) : $on_sale; + } + + /** + * Is a child in stock? + * + * @return boolean + */ + public function child_is_in_stock() { + return $this->data_store->child_is_in_stock( $this ); + } + + /** + * Is a child on backorder? + * + * @since 3.3.0 + * @return boolean + */ + public function child_is_on_backorder() { + return $this->data_store->child_has_stock_status( $this, 'onbackorder' ); + } + + /** + * Does a child have a weight set? + * + * @return boolean + */ + public function child_has_weight() { + $transient_name = 'wc_child_has_weight_' . $this->get_id(); + $has_weight = get_transient( $transient_name ); + + if ( false === $has_weight ) { + $has_weight = $this->data_store->child_has_weight( $this ); + set_transient( $transient_name, $has_weight, DAY_IN_SECONDS * 30 ); + } + + return (bool) $has_weight; + } + + /** + * Does a child have dimensions set? + * + * @return boolean + */ + public function child_has_dimensions() { + $transient_name = 'wc_child_has_dimensions_' . $this->get_id(); + $has_dimension = get_transient( $transient_name ); + + if ( false === $has_dimension ) { + $has_dimension = $this->data_store->child_has_dimensions( $this ); + set_transient( $transient_name, $has_dimension, DAY_IN_SECONDS * 30 ); + } + + return (bool) $has_dimension; + } + + /** + * Returns whether or not the product has dimensions set. + * + * @return bool + */ + public function has_dimensions() { + return parent::has_dimensions() || $this->child_has_dimensions(); + } + + /** + * Returns whether or not the product has weight set. + * + * @return bool + */ + public function has_weight() { + return parent::has_weight() || $this->child_has_weight(); + } + + /** + * Returns whether or not the product has additional options that need + * selecting before adding to cart. + * + * @since 3.0.0 + * @return boolean + */ + public function has_options() { + return true; + } + + /* + |-------------------------------------------------------------------------- + | Sync with child variations. + |-------------------------------------------------------------------------- + */ + + /** + * Sync a variable product with it's children. These sync functions sync + * upwards (from child to parent) when the variation is saved. + * + * @param WC_Product|int $product Product object or ID for which you wish to sync. + * @param bool $save If true, the product object will be saved to the DB before returning it. + * @return WC_Product Synced product object. + */ + public static function sync( $product, $save = true ) { + if ( ! is_a( $product, 'WC_Product' ) ) { + $product = wc_get_product( $product ); + } + if ( is_a( $product, 'WC_Product_Variable' ) ) { + $data_store = WC_Data_Store::load( 'product-' . $product->get_type() ); + $data_store->sync_price( $product ); + $data_store->sync_stock_status( $product ); + self::sync_attributes( $product ); // Legacy update of attributes. + + do_action( 'woocommerce_variable_product_sync_data', $product ); + + if ( $save ) { + $product->save(); + } + + wc_do_deprecated_action( + 'woocommerce_variable_product_sync', array( + $product->get_id(), + $product->get_visible_children(), + ), '3.0', 'woocommerce_variable_product_sync_data, woocommerce_new_product or woocommerce_update_product' + ); + } + + return $product; + } + + /** + * Sync parent stock status with the status of all children and save. + * + * @param WC_Product|int $product Product object or ID for which you wish to sync. + * @param bool $save If true, the product object will be saved to the DB before returning it. + * @return WC_Product Synced product object. + */ + public static function sync_stock_status( $product, $save = true ) { + if ( ! is_a( $product, 'WC_Product' ) ) { + $product = wc_get_product( $product ); + } + if ( is_a( $product, 'WC_Product_Variable' ) ) { + $data_store = WC_Data_Store::load( 'product-' . $product->get_type() ); + $data_store->sync_stock_status( $product ); + + if ( $save ) { + $product->save(); + } + } + + return $product; + } + + /** + * Sort an associativate array of $variation_id => $price pairs in order of min and max prices. + * + * @param array $prices Associativate array of $variation_id => $price pairs. + * @return array + */ + protected function sort_variation_prices( $prices ) { + asort( $prices ); + + return $prices; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php new file mode 100644 index 0000000..016ef91 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php @@ -0,0 +1,523 @@ + '', + 'sku' => '', + 'manage_stock' => '', + 'backorders' => '', + 'stock_quantity' => '', + 'weight' => '', + 'length' => '', + 'width' => '', + 'height' => '', + 'tax_class' => '', + 'shipping_class_id' => '', + 'image_id' => '', + 'purchase_note' => '', + ); + + /** + * Override the default constructor to set custom defaults. + * + * @param int|WC_Product|object $product Product to init. + */ + public function __construct( $product = 0 ) { + $this->data['tax_class'] = 'parent'; + parent::__construct( $product ); + } + + /** + * Prefix for action and filter hooks on data. + * + * @since 3.0.0 + * @return string + */ + protected function get_hook_prefix() { + return 'woocommerce_product_variation_get_'; + } + + /** + * Get internal type. + * + * @return string + */ + public function get_type() { + return 'variation'; + } + + /** + * If the stock level comes from another product ID. + * + * @since 3.0.0 + * @return int + */ + public function get_stock_managed_by_id() { + return 'parent' === $this->get_manage_stock() ? $this->get_parent_id() : $this->get_id(); + } + + /** + * Get the product's title. For variations this is the parent product name. + * + * @return string + */ + public function get_title() { + return apply_filters( 'woocommerce_product_title', $this->parent_data['title'], $this ); + } + + /** + * Get product name with SKU or ID. Used within admin. + * + * @return string Formatted product name + */ + public function get_formatted_name() { + if ( $this->get_sku() ) { + $identifier = $this->get_sku(); + } else { + $identifier = '#' . $this->get_id(); + } + + $formatted_variation_list = wc_get_formatted_variation( $this, true, true, true ); + + return sprintf( '%2$s (%1$s)', $identifier, $this->get_name() ) . '' . $formatted_variation_list . ''; + } + + /** + * Get variation attribute values. Keys are prefixed with attribute_, as stored. + * + * @return array of attributes and their values for this variation + */ + public function get_variation_attributes() { + $attributes = $this->get_attributes(); + $variation_attributes = array(); + foreach ( $attributes as $key => $value ) { + $variation_attributes[ 'attribute_' . $key ] = $value; + } + return $variation_attributes; + } + + /** + * Returns a single product attribute as a string. + * + * @param string $attribute to get. + * @return string + */ + public function get_attribute( $attribute ) { + $attributes = $this->get_attributes(); + $attribute = sanitize_title( $attribute ); + + if ( isset( $attributes[ $attribute ] ) ) { + $value = $attributes[ $attribute ]; + $term = taxonomy_exists( $attribute ) ? get_term_by( 'slug', $value, $attribute ) : false; + return ! is_wp_error( $term ) && $term ? $term->name : $value; + } + + $att_str = 'pa_' . $attribute; + if ( isset( $attributes[ $att_str ] ) ) { + $value = $attributes[ $att_str ]; + $term = taxonomy_exists( $att_str ) ? get_term_by( 'slug', $value, $att_str ) : false; + return ! is_wp_error( $term ) && $term ? $term->name : $value; + } + + return ''; + } + + /** + * Wrapper for get_permalink. Adds this variations attributes to the URL. + * + * @param array|null $item_object item array If a cart or order item is passed, we can get a link containing the exact attributes selected for the variation, rather than the default attributes. + * @return string + */ + public function get_permalink( $item_object = null ) { + $url = get_permalink( $this->get_parent_id() ); + + if ( ! empty( $item_object['variation'] ) ) { + $data = $item_object['variation']; + } elseif ( ! empty( $item_object['item_meta_array'] ) ) { + $data_keys = array_map( 'wc_variation_attribute_name', wp_list_pluck( $item_object['item_meta_array'], 'key' ) ); + $data_values = wp_list_pluck( $item_object['item_meta_array'], 'value' ); + $data = array_intersect_key( array_combine( $data_keys, $data_values ), $this->get_variation_attributes() ); + } else { + $data = $this->get_variation_attributes(); + } + + $data = array_filter( $data ); + + if ( empty( $data ) ) { + return $url; + } + + // Filter and encode keys and values so this is not broken by add_query_arg. + $data = array_map( 'urlencode', $data ); + $keys = array_map( 'urlencode', array_keys( $data ) ); + + return add_query_arg( array_combine( $keys, $data ), $url ); + } + + /** + * Get the add to url used mainly in loops. + * + * @return string + */ + public function add_to_cart_url() { + $url = $this->is_purchasable() ? remove_query_arg( + 'added-to-cart', add_query_arg( + array( + 'variation_id' => $this->get_id(), + 'add-to-cart' => $this->get_parent_id(), + ), $this->get_permalink() + ) + ) : $this->get_permalink(); + return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this ); + } + + /** + * Get SKU (Stock-keeping unit) - product unique ID. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_sku( $context = 'view' ) { + $value = $this->get_prop( 'sku', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'sku', $this->parent_data['sku'], $this ); + } + return $value; + } + + /** + * Returns the product's weight. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_weight( $context = 'view' ) { + $value = $this->get_prop( 'weight', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'weight', $this->parent_data['weight'], $this ); + } + return $value; + } + + /** + * Returns the product length. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_length( $context = 'view' ) { + $value = $this->get_prop( 'length', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'length', $this->parent_data['length'], $this ); + } + return $value; + } + + /** + * Returns the product width. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_width( $context = 'view' ) { + $value = $this->get_prop( 'width', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'width', $this->parent_data['width'], $this ); + } + return $value; + } + + /** + * Returns the product height. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_height( $context = 'view' ) { + $value = $this->get_prop( 'height', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'height', $this->parent_data['height'], $this ); + } + return $value; + } + + /** + * Returns the tax class. + * + * Does not use get_prop so it can handle 'parent' Inheritance correctly. + * + * @param string $context view, edit, or unfiltered. + * @return string + */ + public function get_tax_class( $context = 'view' ) { + $value = null; + + if ( array_key_exists( 'tax_class', $this->data ) ) { + $value = array_key_exists( 'tax_class', $this->changes ) ? $this->changes['tax_class'] : $this->data['tax_class']; + + if ( 'edit' !== $context && 'parent' === $value ) { + $value = $this->parent_data['tax_class']; + } + + if ( 'view' === $context ) { + $value = apply_filters( $this->get_hook_prefix() . 'tax_class', $value, $this ); + } + } + return $value; + } + + /** + * Return if product manage stock. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return boolean|string true, false, or parent. + */ + public function get_manage_stock( $context = 'view' ) { + $value = $this->get_prop( 'manage_stock', $context ); + + // Inherit value from parent. + if ( 'view' === $context && false === $value && true === wc_string_to_bool( $this->parent_data['manage_stock'] ) ) { + $value = 'parent'; + } + return $value; + } + + /** + * Returns number of items available for sale. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return int|null + */ + public function get_stock_quantity( $context = 'view' ) { + $value = $this->get_prop( 'stock_quantity', $context ); + + // Inherit value from parent. + if ( 'view' === $context && 'parent' === $this->get_manage_stock() ) { + $value = apply_filters( $this->get_hook_prefix() . 'stock_quantity', $this->parent_data['stock_quantity'], $this ); + } + return $value; + } + + /** + * Get backorders. + * + * @param string $context What the value is for. Valid values are view and edit. + * @since 3.0.0 + * @return string yes no or notify + */ + public function get_backorders( $context = 'view' ) { + $value = $this->get_prop( 'backorders', $context ); + + // Inherit value from parent. + if ( 'view' === $context && 'parent' === $this->get_manage_stock() ) { + $value = apply_filters( $this->get_hook_prefix() . 'backorders', $this->parent_data['backorders'], $this ); + } + return $value; + } + + /** + * Get main image ID. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_image_id( $context = 'view' ) { + $image_id = $this->get_prop( 'image_id', $context ); + + if ( 'view' === $context && ! $image_id ) { + $image_id = apply_filters( $this->get_hook_prefix() . 'image_id', $this->parent_data['image_id'], $this ); + } + + return $image_id; + } + + /** + * Get purchase note. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_purchase_note( $context = 'view' ) { + $value = $this->get_prop( 'purchase_note', $context ); + + // Inherit value from parent. + if ( 'view' === $context && empty( $value ) ) { + $value = apply_filters( $this->get_hook_prefix() . 'purchase_note', $this->parent_data['purchase_note'], $this ); + } + return $value; + } + + /** + * Get shipping class ID. + * + * @since 3.0.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return int + */ + public function get_shipping_class_id( $context = 'view' ) { + $shipping_class_id = $this->get_prop( 'shipping_class_id', $context ); + + if ( 'view' === $context && ! $shipping_class_id ) { + $shipping_class_id = apply_filters( $this->get_hook_prefix() . 'shipping_class_id', $this->parent_data['shipping_class_id'], $this ); + } + + return $shipping_class_id; + } + + /** + * Get catalog visibility. + * + * @param string $context What the value is for. Valid values are view and edit. + * @return string + */ + public function get_catalog_visibility( $context = 'view' ) { + return apply_filters( $this->get_hook_prefix() . 'catalog_visibility', $this->parent_data['catalog_visibility'], $this ); + } + + /* + |-------------------------------------------------------------------------- + | CRUD methods + |-------------------------------------------------------------------------- + */ + + /** + * Set the parent data array for this variation. + * + * @since 3.0.0 + * @param array $parent_data parent data array for this variation. + */ + public function set_parent_data( $parent_data ) { + $this->parent_data = $parent_data; + } + + /** + * Get the parent data array for this variation. + * + * @since 3.0.0 + * @return array + */ + public function get_parent_data() { + return $this->parent_data; + } + + /** + * Set attributes. Unlike the parent product which uses terms, variations are assigned + * specific attributes using name value pairs. + * + * @param array $raw_attributes array of raw attributes. + */ + public function set_attributes( $raw_attributes ) { + $raw_attributes = (array) $raw_attributes; + $attributes = array(); + + foreach ( $raw_attributes as $key => $value ) { + // Remove attribute prefix which meta gets stored with. + if ( 0 === strpos( $key, 'attribute_' ) ) { + $key = substr( $key, 10 ); + } + $attributes[ $key ] = $value; + } + $this->set_prop( 'attributes', $attributes ); + } + + /** + * Returns whether or not the product has any visible attributes. + * + * Variations are mapped to specific attributes unlike products, and the return + * value of ->get_attributes differs. Therefore this returns false. + * + * @return boolean + */ + public function has_attributes() { + return false; + } + + /* + |-------------------------------------------------------------------------- + | Conditionals + |-------------------------------------------------------------------------- + */ + + /** + * Returns false if the product cannot be bought. + * Override abstract method so that: i) Disabled variations are not be purchasable by admins. ii) Enabled variations are not purchasable if the parent product is not purchasable. + * + * @return bool + */ + public function is_purchasable() { + return apply_filters( 'woocommerce_variation_is_purchasable', $this->variation_is_visible() && parent::is_purchasable() && ( 'publish' === $this->parent_data['status'] || current_user_can( 'edit_post', $this->get_parent_id() ) ), $this ); + } + + /** + * Controls whether this particular variation will appear greyed-out (inactive) or not (active). + * Used by extensions to make incompatible variations appear greyed-out, etc. + * Other possible uses: prevent out-of-stock variations from being selected. + * + * @return bool + */ + public function variation_is_active() { + return apply_filters( 'woocommerce_variation_is_active', true, $this ); + } + + /** + * Checks if this particular variation is visible. Invisible variations are enabled and can be selected, but no price / stock info is displayed. + * Instead, a suitable 'unavailable' message is displayed. + * Invisible by default: Disabled variations and variations with an empty price. + * + * @return bool + */ + public function variation_is_visible() { + return apply_filters( 'woocommerce_variation_is_visible', 'publish' === get_post_status( $this->get_id() ) && '' !== $this->get_price(), $this->get_id(), $this->get_parent_id(), $this ); + } + + /** + * Return valid tax classes. Adds 'parent' to the default list of valid tax classes. + * + * @return array valid tax classes + */ + protected function get_valid_tax_classes() { + $valid_classes = WC_Tax::get_tax_class_slugs(); + $valid_classes[] = 'parent'; + + return $valid_classes; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-query.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-query.php new file mode 100644 index 0000000..e592876 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-query.php @@ -0,0 +1,896 @@ +init_query_vars(); + } + + /** + * Get any errors from querystring. + */ + public function get_errors() { + $error = ! empty( $_GET['wc_error'] ) ? sanitize_text_field( wp_unslash( $_GET['wc_error'] ) ) : ''; // WPCS: input var ok, CSRF ok. + + if ( $error && ! wc_has_notice( $error, 'error' ) ) { + wc_add_notice( $error, 'error' ); + } + } + + /** + * Init query vars by loading options. + */ + public function init_query_vars() { + // Query vars to add to WP. + $this->query_vars = array( + // Checkout actions. + 'order-pay' => get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ), + 'order-received' => get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ), + // My account actions. + 'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ), + 'view-order' => get_option( 'woocommerce_myaccount_view_order_endpoint', 'view-order' ), + 'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ), + 'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ), + 'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ), + 'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ), + 'lost-password' => get_option( 'woocommerce_myaccount_lost_password_endpoint', 'lost-password' ), + 'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ), + 'add-payment-method' => get_option( 'woocommerce_myaccount_add_payment_method_endpoint', 'add-payment-method' ), + 'delete-payment-method' => get_option( 'woocommerce_myaccount_delete_payment_method_endpoint', 'delete-payment-method' ), + 'set-default-payment-method' => get_option( 'woocommerce_myaccount_set_default_payment_method_endpoint', 'set-default-payment-method' ), + ); + } + + /** + * Get page title for an endpoint. + * + * @param string $endpoint Endpoint key. + * @return string + */ + public function get_endpoint_title( $endpoint ) { + global $wp; + + switch ( $endpoint ) { + case 'order-pay': + $title = __( 'Pay for order', 'woocommerce' ); + break; + case 'order-received': + $title = __( 'Order received', 'woocommerce' ); + break; + case 'orders': + if ( ! empty( $wp->query_vars['orders'] ) ) { + /* translators: %s: page */ + $title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) ); + } else { + $title = __( 'Orders', 'woocommerce' ); + } + break; + case 'view-order': + $order = wc_get_order( $wp->query_vars['view-order'] ); + /* translators: %s: order number */ + $title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : ''; + break; + case 'downloads': + $title = __( 'Downloads', 'woocommerce' ); + break; + case 'edit-account': + $title = __( 'Account details', 'woocommerce' ); + break; + case 'edit-address': + $title = __( 'Addresses', 'woocommerce' ); + break; + case 'payment-methods': + $title = __( 'Payment methods', 'woocommerce' ); + break; + case 'add-payment-method': + $title = __( 'Add payment method', 'woocommerce' ); + break; + case 'lost-password': + $title = __( 'Lost password', 'woocommerce' ); + break; + default: + $title = ''; + break; + } + + return apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', $title, $endpoint ); + } + + /** + * Endpoint mask describing the places the endpoint should be added. + * + * @since 2.6.2 + * @return int + */ + public function get_endpoints_mask() { + if ( 'page' === get_option( 'show_on_front' ) ) { + $page_on_front = get_option( 'page_on_front' ); + $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); + $checkout_page_id = get_option( 'woocommerce_checkout_page_id' ); + + if ( in_array( $page_on_front, array( $myaccount_page_id, $checkout_page_id ), true ) ) { + return EP_ROOT | EP_PAGES; + } + } + + return EP_PAGES; + } + + /** + * Add endpoints for query vars. + */ + public function add_endpoints() { + $mask = $this->get_endpoints_mask(); + + foreach ( $this->get_query_vars() as $key => $var ) { + if ( ! empty( $var ) ) { + add_rewrite_endpoint( $var, $mask ); + } + } + } + + /** + * Add query vars. + * + * @access public + * + * @param array $vars Query vars. + * @return array + */ + public function add_query_vars( $vars ) { + foreach ( $this->get_query_vars() as $key => $var ) { + $vars[] = $key; + } + return $vars; + } + + /** + * Get query vars. + * + * @return array + */ + public function get_query_vars() { + return apply_filters( 'woocommerce_get_query_vars', $this->query_vars ); + } + + /** + * Get query current active query var. + * + * @return string + */ + public function get_current_endpoint() { + global $wp; + + foreach ( $this->get_query_vars() as $key => $value ) { + if ( isset( $wp->query_vars[ $key ] ) ) { + return $key; + } + } + return ''; + } + + /** + * Parse the request and look for query vars - endpoints may not be supported. + */ + public function parse_request() { + global $wp; + + // Map query vars to their keys, or get them if endpoints are not supported. + foreach ( $this->get_query_vars() as $key => $var ) { + if ( isset( $_GET[ $var ] ) ) { // WPCS: input var ok, CSRF ok. + $wp->query_vars[ $key ] = sanitize_text_field( wp_unslash( $_GET[ $var ] ) ); // WPCS: input var ok, CSRF ok. + } elseif ( isset( $wp->query_vars[ $var ] ) ) { + $wp->query_vars[ $key ] = $wp->query_vars[ $var ]; + } + } + } + + /** + * Are we currently on the front page? + * + * @param WP_Query $q Query instance. + * @return bool + */ + private function is_showing_page_on_front( $q ) { + return $q->is_home() && 'page' === get_option( 'show_on_front' ); + } + + /** + * Is the front page a page we define? + * + * @param int $page_id Page ID. + * @return bool + */ + private function page_on_front_is( $page_id ) { + return absint( get_option( 'page_on_front' ) ) === absint( $page_id ); + } + + /** + * Hook into pre_get_posts to do the main product query. + * + * @param WP_Query $q Query instance. + */ + public function pre_get_posts( $q ) { + // We only want to affect the main query. + if ( ! $q->is_main_query() ) { + return; + } + + // Fix for endpoints on the homepage. + if ( $this->is_showing_page_on_front( $q ) && ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) { + $_query = wp_parse_args( $q->query ); + if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) { + $q->is_page = true; + $q->is_home = false; + $q->is_singular = true; + $q->set( 'page_id', (int) get_option( 'page_on_front' ) ); + add_filter( 'redirect_canonical', '__return_false' ); + } + } + + // When orderby is set, WordPress shows posts on the front-page. Get around that here. + if ( $this->is_showing_page_on_front( $q ) && $this->page_on_front_is( wc_get_page_id( 'shop' ) ) ) { + $_query = wp_parse_args( $q->query ); + if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) ) ) { + $q->set( 'page_id', (int) get_option( 'page_on_front' ) ); + $q->is_page = true; + $q->is_home = false; + + // WP supporting themes show post type archive. + if ( current_theme_supports( 'woocommerce' ) ) { + $q->set( 'post_type', 'product' ); + } else { + $q->is_singular = true; + } + } + } + + // Fix product feeds. + if ( $q->is_feed() && $q->is_post_type_archive( 'product' ) ) { + $q->is_comment_feed = false; + } + + // Special check for shops with the PRODUCT POST TYPE ARCHIVE on front. + if ( current_theme_supports( 'woocommerce' ) && $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) { + // This is a front-page shop. + $q->set( 'post_type', 'product' ); + $q->set( 'page_id', '' ); + + if ( isset( $q->query['paged'] ) ) { + $q->set( 'paged', $q->query['paged'] ); + } + + // Define a variable so we know this is the front page shop later on. + wc_maybe_define_constant( 'SHOP_IS_ON_FRONT', true ); + + // Get the actual WP page to avoid errors and let us use is_front_page(). + // This is hacky but works. Awaiting https://core.trac.wordpress.org/ticket/21096. + global $wp_post_types; + + $shop_page = get_post( wc_get_page_id( 'shop' ) ); + + $wp_post_types['product']->ID = $shop_page->ID; + $wp_post_types['product']->post_title = $shop_page->post_title; + $wp_post_types['product']->post_name = $shop_page->post_name; + $wp_post_types['product']->post_type = $shop_page->post_type; + $wp_post_types['product']->ancestors = get_ancestors( $shop_page->ID, $shop_page->post_type ); + + // Fix conditional Functions like is_front_page. + $q->is_singular = false; + $q->is_post_type_archive = true; + $q->is_archive = true; + $q->is_page = true; + + // Remove post type archive name from front page title tag. + add_filter( 'post_type_archive_title', '__return_empty_string', 5 ); + + // Fix WP SEO. + if ( class_exists( 'WPSEO_Meta' ) ) { + add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) ); + add_filter( 'wpseo_metakey', array( $this, 'wpseo_metakey' ) ); + } + } elseif ( ! $q->is_post_type_archive( 'product' ) && ! $q->is_tax( get_object_taxonomies( 'product' ) ) ) { + // Only apply to product categories, the product post archive, the shop page, product tags, and product attribute taxonomies. + return; + } + + $this->product_query( $q ); + } + + /** + * Pre_get_posts above may adjust the main query to add WooCommerce logic. When this query is done, we need to ensure + * all custom filters are removed. + * + * This is done here during the_posts filter. The input is not changed. + * + * @param array $posts Posts from WP Query. + * @return array + */ + public function remove_product_query_filters( $posts ) { + $this->remove_ordering_args(); + return $posts; + } + + /** + * WP SEO meta description. + * + * Hooked into wpseo_ hook already, so no need for function_exist. + * + * @return string + */ + public function wpseo_metadesc() { + return WPSEO_Meta::get_value( 'metadesc', wc_get_page_id( 'shop' ) ); + } + + /** + * WP SEO meta key. + * + * Hooked into wpseo_ hook already, so no need for function_exist. + * + * @access public + * @return string + */ + public function wpseo_metakey() { + return WPSEO_Meta::get_value( 'metakey', wc_get_page_id( 'shop' ) ); + } + + /** + * Query the products, applying sorting/ordering etc. + * This applies to the main WordPress loop. + * + * @param WP_Query $q Query instance. + */ + public function product_query( $q ) { + if ( ! is_feed() ) { + $ordering = $this->get_catalog_ordering_args(); + $q->set( 'orderby', $ordering['orderby'] ); + $q->set( 'order', $ordering['order'] ); + + if ( isset( $ordering['meta_key'] ) ) { + $q->set( 'meta_key', $ordering['meta_key'] ); + } + } + + // Query vars that affect posts shown. + $q->set( 'meta_query', $this->get_meta_query( $q->get( 'meta_query' ), true ) ); + $q->set( 'tax_query', $this->get_tax_query( $q->get( 'tax_query' ), true ) ); + $q->set( 'wc_query', 'product_query' ); + $q->set( 'post__in', array_unique( (array) apply_filters( 'loop_shop_post_in', array() ) ) ); + + // Work out how many products to query. + $q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ) ); + + // Store reference to this query. + self::$product_query = $q; + + do_action( 'woocommerce_product_query', $q, $this ); + } + + /** + * Remove the query. + */ + public function remove_product_query() { + remove_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); + } + + /** + * Remove ordering queries. + */ + public function remove_ordering_args() { + remove_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) ); + remove_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) ); + remove_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) ); + remove_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) ); + } + + /** + * Returns an array of arguments for ordering products based on the selected values. + * + * @param string $orderby Order by param. + * @param string $order Order param. + * @return array + */ + public function get_catalog_ordering_args( $orderby = '', $order = '' ) { + // Get ordering from query string unless defined. + if ( ! $orderby ) { + $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( (string) wp_unslash( $_GET['orderby'] ) ) : wc_clean( get_query_var( 'orderby' ) ); // WPCS: sanitization ok, input var ok, CSRF ok. + + if ( ! $orderby_value ) { + if ( is_search() ) { + $orderby_value = 'relevance'; + } else { + $orderby_value = apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', 'menu_order' ) ); + } + } + + // Get order + orderby args from string. + $orderby_value = explode( '-', $orderby_value ); + $orderby = esc_attr( $orderby_value[0] ); + $order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order; + } + + $orderby = strtolower( $orderby ); + $order = strtoupper( $order ); + $args = array( + 'orderby' => $orderby, + 'order' => ( 'DESC' === $order ) ? 'DESC' : 'ASC', + 'meta_key' => '', // @codingStandardsIgnoreLine + ); + + switch ( $orderby ) { + case 'menu_order': + $args['orderby'] = 'menu_order title'; + break; + case 'title': + $args['orderby'] = 'title'; + $args['order'] = ( 'DESC' === $order ) ? 'DESC' : 'ASC'; + break; + case 'relevance': + $args['orderby'] = 'relevance'; + $args['order'] = 'DESC'; + break; + case 'rand': + $args['orderby'] = 'rand'; // @codingStandardsIgnoreLine + break; + case 'date': + $args['orderby'] = 'date ID'; + $args['order'] = ( 'ASC' === $order ) ? 'ASC' : 'DESC'; + break; + case 'price': + if ( 'DESC' === $order ) { + add_filter( 'posts_clauses', array( $this, 'order_by_price_desc_post_clauses' ) ); + } else { + add_filter( 'posts_clauses', array( $this, 'order_by_price_asc_post_clauses' ) ); + } + break; + case 'popularity': + $args['meta_key'] = 'total_sales'; // @codingStandardsIgnoreLine + + // Sorting handled later though a hook. + add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) ); + break; + case 'rating': + $args['meta_key'] = '_wc_average_rating'; // @codingStandardsIgnoreLine + $args['orderby'] = array( + 'meta_value_num' => 'DESC', + 'ID' => 'ASC', + ); + break; + } + + return apply_filters( 'woocommerce_get_catalog_ordering_args', $args ); + } + + /** + * Handle numeric price sorting. + * + * @param array $args Query args. + * @return array + */ + public function order_by_price_asc_post_clauses( $args ) { + global $wpdb, $wp_query; + + if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) { + $search_within_terms = get_terms( array( + 'taxonomy' => $wp_query->queried_object->taxonomy, + 'parent' => $wp_query->queried_object->term_id, + 'fields' => 'tt_ids', + )); + $search_within_terms[] = $wp_query->queried_object->term_taxonomy_id; + $args['join'] .= " INNER JOIN ( + SELECT post_id, min( meta_value+0 ) price + FROM $wpdb->postmeta + INNER JOIN ( + SELECT $wpdb->term_relationships.object_id + FROM $wpdb->term_relationships + WHERE 1=1 + AND $wpdb->term_relationships.term_taxonomy_id IN (" . implode( ',', array_map( 'absint', $search_within_terms ) ) . ") + ) as products_within_terms ON $wpdb->postmeta.post_id = products_within_terms.object_id + WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id "; + } else { + $args['join'] .= " INNER JOIN ( SELECT post_id, min( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id "; + } + $args['orderby'] = " price_query.price ASC, $wpdb->posts.ID ASC "; + return $args; + } + + /** + * Handle numeric price sorting. + * + * @param array $args Query args. + * @return array + */ + public function order_by_price_desc_post_clauses( $args ) { + global $wpdb, $wp_query; + + if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) { + $search_within_terms = get_terms( array( + 'taxonomy' => $wp_query->queried_object->taxonomy, + 'parent' => $wp_query->queried_object->term_id, + 'fields' => 'tt_ids', + )); + $search_within_terms[] = $wp_query->queried_object->term_taxonomy_id; + $args['join'] .= " INNER JOIN ( + SELECT post_id, max( meta_value+0 ) price + FROM $wpdb->postmeta + INNER JOIN ( + SELECT $wpdb->term_relationships.object_id + FROM $wpdb->term_relationships + WHERE 1=1 + AND $wpdb->term_relationships.term_taxonomy_id IN (" . implode( ',', array_map( 'absint', $search_within_terms ) ) . ") + ) as products_within_terms ON $wpdb->postmeta.post_id = products_within_terms.object_id + WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id "; + } else { + $args['join'] .= " INNER JOIN ( SELECT post_id, max( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id "; + } + + $args['orderby'] = " price_query.price DESC, $wpdb->posts.ID DESC "; + return $args; + } + + /** + * WP Core doens't let us change the sort direction for individual orderby params - https://core.trac.wordpress.org/ticket/17065. + * + * This lets us sort by meta value desc, and have a second orderby param. + * + * @param array $args Query args. + * @return array + */ + public function order_by_popularity_post_clauses( $args ) { + global $wpdb; + $args['orderby'] = "$wpdb->postmeta.meta_value+0 DESC, $wpdb->posts.post_date DESC"; + return $args; + } + + /** + * Appends meta queries to an array. + * + * @param array $meta_query Meta query. + * @param bool $main_query If is main query. + * @return array + */ + public function get_meta_query( $meta_query = array(), $main_query = false ) { + if ( ! is_array( $meta_query ) ) { + $meta_query = array(); + } + $meta_query['price_filter'] = $this->price_filter_meta_query(); + return array_filter( apply_filters( 'woocommerce_product_query_meta_query', $meta_query, $this ) ); + } + + /** + * Appends tax queries to an array. + * + * @param array $tax_query Tax query. + * @param bool $main_query If is main query. + * @return array + */ + public function get_tax_query( $tax_query = array(), $main_query = false ) { + if ( ! is_array( $tax_query ) ) { + $tax_query = array( + 'relation' => 'AND', + ); + } + + // Layered nav filters on terms. + if ( $main_query ) { + foreach ( $this->get_layered_nav_chosen_attributes() as $taxonomy => $data ) { + $tax_query[] = array( + 'taxonomy' => $taxonomy, + 'field' => 'slug', + 'terms' => $data['terms'], + 'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN', + 'include_children' => false, + ); + } + } + + $product_visibility_terms = wc_get_product_visibility_term_ids(); + $product_visibility_not_in = array( is_search() && $main_query ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] ); + + // Hide out of stock products. + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { + $product_visibility_not_in[] = $product_visibility_terms['outofstock']; + } + + // Filter by rating. + if ( isset( $_GET['rating_filter'] ) ) { // WPCS: input var ok, CSRF ok. + $rating_filter = array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) ); // WPCS: input var ok, CSRF ok, Sanitization ok. + $rating_terms = array(); + for ( $i = 1; $i <= 5; $i ++ ) { + if ( in_array( $i, $rating_filter, true ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) { + $rating_terms[] = $product_visibility_terms[ 'rated-' . $i ]; + } + } + if ( ! empty( $rating_terms ) ) { + $tax_query[] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => $rating_terms, + 'operator' => 'IN', + 'rating_filter' => true, + ); + } + } + + if ( ! empty( $product_visibility_not_in ) ) { + $tax_query[] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => $product_visibility_not_in, + 'operator' => 'NOT IN', + ); + } + + return array_filter( apply_filters( 'woocommerce_product_query_tax_query', $tax_query, $this ) ); + } + + /** + * Return a meta query for filtering by price. + * + * @return array + */ + private function price_filter_meta_query() { + if ( isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) ) { // WPCS: input var ok, CSRF ok. + $meta_query = wc_get_min_max_price_meta_query( $_GET ); // WPCS: input var ok, CSRF ok. + $meta_query['price_filter'] = true; + + return $meta_query; + } + + return array(); + } + + /** + * Get the main query which product queries ran against. + * + * @return array + */ + public static function get_main_query() { + return self::$product_query; + } + + /** + * Get the tax query which was used by the main query. + * + * @return array + */ + public static function get_main_tax_query() { + $tax_query = isset( self::$product_query->tax_query, self::$product_query->tax_query->queries ) ? self::$product_query->tax_query->queries : array(); + + return $tax_query; + } + + /** + * Get the meta query which was used by the main query. + * + * @return array + */ + public static function get_main_meta_query() { + $args = self::$product_query->query_vars; + $meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array(); + + return $meta_query; + } + + /** + * Based on WP_Query::parse_search + */ + public static function get_main_search_query_sql() { + global $wpdb; + + $args = self::$product_query->query_vars; + $search_terms = isset( $args['search_terms'] ) ? $args['search_terms'] : array(); + $sql = array(); + + foreach ( $search_terms as $term ) { + // Terms prefixed with '-' should be excluded. + $include = '-' !== substr( $term, 0, 1 ); + + if ( $include ) { + $like_op = 'LIKE'; + $andor_op = 'OR'; + } else { + $like_op = 'NOT LIKE'; + $andor_op = 'AND'; + $term = substr( $term, 1 ); + } + + $like = '%' . $wpdb->esc_like( $term ) . '%'; + $sql[] = $wpdb->prepare( "(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like ); // unprepared SQL ok. + } + + if ( ! empty( $sql ) && ! is_user_logged_in() ) { + $sql[] = "($wpdb->posts.post_password = '')"; + } + + return implode( ' AND ', $sql ); + } + + /** + * Get an array of attributes and terms selected with the layered nav widget. + * + * @return array + */ + public static function get_layered_nav_chosen_attributes() { + if ( ! is_array( self::$_chosen_attributes ) ) { + self::$_chosen_attributes = array(); + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + if ( ! empty( $attribute_taxonomies ) ) { + foreach ( $attribute_taxonomies as $tax ) { + $attribute = wc_sanitize_taxonomy_name( $tax->attribute_name ); + $taxonomy = wc_attribute_taxonomy_name( $attribute ); + $filter_terms = ! empty( $_GET[ 'filter_' . $attribute ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ 'filter_' . $attribute ] ) ) ) : array(); // WPCS: sanitization ok, input var ok, CSRF ok. + + if ( empty( $filter_terms ) || ! taxonomy_exists( $taxonomy ) ) { + continue; + } + + $query_type = ! empty( $_GET[ 'query_type_' . $attribute ] ) && in_array( $_GET[ 'query_type_' . $attribute ], array( 'and', 'or' ), true ) ? wc_clean( wp_unslash( $_GET[ 'query_type_' . $attribute ] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok. + self::$_chosen_attributes[ $taxonomy ]['terms'] = array_map( 'sanitize_title', $filter_terms ); // Ensures correct encoding. + self::$_chosen_attributes[ $taxonomy ]['query_type'] = $query_type ? $query_type : apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' ); + } + } + } + return self::$_chosen_attributes; + } + + /** + * Remove the add-to-cart param from pagination urls. + * + * @param string $url URL. + * @return string + */ + public function remove_add_to_cart_pagination( $url ) { + return remove_query_arg( 'add-to-cart', $url ); + } + + // @codingStandardsIgnoreStart + /** + * Order by rating post clauses. + * + * @deprecated 3.0.0 + * @param array $args + * @return array + */ + public function order_by_rating_post_clauses( $args ) { + global $wpdb; + + wc_deprecated_function( 'order_by_rating_post_clauses', '3.0' ); + + $args['fields'] .= ", AVG( $wpdb->commentmeta.meta_value ) as average_rating "; + $args['where'] .= " AND ( $wpdb->commentmeta.meta_key = 'rating' OR $wpdb->commentmeta.meta_key IS null ) "; + $args['join'] .= " + LEFT OUTER JOIN $wpdb->comments ON($wpdb->posts.ID = $wpdb->comments.comment_post_ID) + LEFT JOIN $wpdb->commentmeta ON($wpdb->comments.comment_ID = $wpdb->commentmeta.comment_id) + "; + $args['orderby'] = "average_rating DESC, $wpdb->posts.post_date DESC"; + $args['groupby'] = "$wpdb->posts.ID"; + + return $args; + } + + /** + * Return a meta query for filtering by rating. + * + * @deprecated 3.0.0 Replaced with taxonomy. + * @return array + */ + public function rating_filter_meta_query() { + return array(); + } + + /** + * Returns a meta query to handle product visibility. + * + * @deprecated 3.0.0 Replaced with taxonomy. + * @param string $compare (default: 'IN') + * @return array + */ + public function visibility_meta_query( $compare = 'IN' ) { + return array(); + } + + /** + * Returns a meta query to handle product stock status. + * + * @deprecated 3.0.0 Replaced with taxonomy. + * @param string $status (default: 'instock') + * @return array + */ + public function stock_status_meta_query( $status = 'instock' ) { + return array(); + } + + /** + * Layered nav init. + * + * @deprecated 2.6.0 + */ + public function layered_nav_init() { + wc_deprecated_function( 'layered_nav_init', '2.6' ); + } + + /** + * Get an unpaginated list all product IDs (both filtered and unfiltered). Makes use of transients. + * + * @deprecated 2.6.0 due to performance concerns + */ + public function get_products_in_view() { + wc_deprecated_function( 'get_products_in_view', '2.6' ); + } + + /** + * Layered Nav post filter. + * + * @deprecated 2.6.0 due to performance concerns + * + * @param mixed $deprecated Deprecated. + */ + public function layered_nav_query( $deprecated ) { + wc_deprecated_function( 'layered_nav_query', '2.6' ); + } + + /** + * Search post excerpt. + * + * @deprecated 3.2.0 - Not needed anymore since WordPress 4.5. + */ + public function search_post_excerpt( $where = '' ) { + wc_deprecated_function( 'WC_Query::search_post_excerpt', '3.2.0', 'Excerpt added to search query by default since WordPress 4.5.' ); + return $where; + } + + /** + * Remove the posts_where filter. + * @deprecated 3.2.0 - Nothing to remove anymore because search_post_excerpt() is deprecated. + */ + public function remove_posts_where() { + wc_deprecated_function( 'WC_Query::remove_posts_where', '3.2.0', 'Nothing to remove anymore because search_post_excerpt() is deprecated.' ); + } + // @codingStandardsIgnoreEnd +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php new file mode 100644 index 0000000..c859f99 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php @@ -0,0 +1,252 @@ +prefix = 'wp_' . get_current_blog_id(); + $this->action = 'wc_regenerate_images'; + + // This is needed to prevent timeouts due to threading. See https://core.trac.wordpress.org/ticket/36534. + @putenv( 'MAGICK_THREAD_LIMIT=1' ); // @codingStandardsIgnoreLine. + + parent::__construct(); + } + + /** + * Is job running? + * + * @return boolean + */ + public function is_running() { + return $this->is_queue_empty(); + } + + /** + * Limit each task ran per batch to 1 for image regen. + * + * @return bool + */ + protected function batch_limit_exceeded() { + return true; + } + + /** + * Determines whether an attachment can have its thumbnails regenerated. + * + * Adapted from Regenerate Thumbnails by Alex Mills. + * + * @param WP_Post $attachment An attachment's post object. + * @return bool Whether the given attachment can have its thumbnails regenerated. + */ + protected function is_regeneratable( $attachment ) { + if ( 'site-icon' === get_post_meta( $attachment->ID, '_wp_attachment_context', true ) ) { + return false; + } + + if ( wp_attachment_is_image( $attachment ) ) { + return true; + } + + return false; + } + + /** + * Code to execute for each item in the queue + * + * @param mixed $item Queue item to iterate over. + * @return bool + */ + protected function task( $item ) { + if ( ! is_array( $item ) && ! isset( $item['attachment_id'] ) ) { + return false; + } + + $this->attachment_id = absint( $item['attachment_id'] ); + $attachment = get_post( $this->attachment_id ); + + if ( ! $attachment || 'attachment' !== $attachment->post_type || ! $this->is_regeneratable( $attachment ) ) { + return false; + } + + if ( ! function_exists( 'wp_crop_image' ) ) { + include ABSPATH . 'wp-admin/includes/image.php'; + } + + $log = wc_get_logger(); + + // translators: %s: ID of the attachment. + $log->info( sprintf( __( 'Regenerating images for attachment ID: %s', 'woocommerce' ), $this->attachment_id ), + array( + 'source' => 'wc-image-regeneration', + ) + ); + + $fullsizepath = get_attached_file( $this->attachment_id ); + + // Check if the file exists, if not just remove item from queue. + if ( false === $fullsizepath || is_wp_error( $fullsizepath ) || ! file_exists( $fullsizepath ) ) { + return false; + } + + $old_metadata = wp_get_attachment_metadata( $this->attachment_id ); + + // We only want to regen WC images. + add_filter( 'intermediate_image_sizes', array( $this, 'adjust_intermediate_image_sizes' ) ); + + // We only want to resize images if they do not already exist. + add_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_to_only_missing_thumbnails' ), 10, 3 ); + + // This function will generate the new image sizes. + $new_metadata = wp_generate_attachment_metadata( $this->attachment_id, $fullsizepath ); + + // Remove custom filters. + remove_filter( 'intermediate_image_sizes', array( $this, 'adjust_intermediate_image_sizes' ) ); + remove_filter( 'intermediate_image_sizes_advanced', array( $this, 'filter_image_sizes_to_only_missing_thumbnails' ), 10, 3 ); + + // If something went wrong lets just remove the item from the queue. + if ( is_wp_error( $new_metadata ) || empty( $new_metadata ) ) { + return false; + } + + if ( ! empty( $old_metadata ) && ! empty( $old_metadata['sizes'] ) && is_array( $old_metadata['sizes'] ) ) { + foreach ( $old_metadata['sizes'] as $old_size => $old_size_data ) { + if ( empty( $new_metadata['sizes'][ $old_size ] ) ) { + $new_metadata['sizes'][ $old_size ] = $old_metadata['sizes'][ $old_size ]; + } + } + // Handle legacy sizes. + if ( isset( $new_metadata['sizes']['shop_thumbnail'], $new_metadata['sizes']['woocommerce_gallery_thumbnail'] ) ) { + $new_metadata['sizes']['shop_thumbnail'] = $new_metadata['sizes']['woocommerce_gallery_thumbnail']; + } + if ( isset( $new_metadata['sizes']['shop_catalog'], $new_metadata['sizes']['woocommerce_thumbnail'] ) ) { + $new_metadata['sizes']['shop_catalog'] = $new_metadata['sizes']['woocommerce_thumbnail']; + } + if ( isset( $new_metadata['sizes']['shop_single'], $new_metadata['sizes']['woocommerce_single'] ) ) { + $new_metadata['sizes']['shop_single'] = $new_metadata['sizes']['woocommerce_single']; + } + } + + // Update the meta data with the new size values. + wp_update_attachment_metadata( $this->attachment_id, $new_metadata ); + + // We made it till the end, now lets remove the item from the queue. + return false; + } + + /** + * Filters the list of thumbnail sizes to only include those which have missing files. + * + * @param array $sizes An associative array of registered thumbnail image sizes. + * @param array $metadata An associative array of fullsize image metadata: width, height, file. + * @param int $attachment_id Attachment ID. Only passed from WP 5.0+. + * @return array An associative array of image sizes. + */ + public function filter_image_sizes_to_only_missing_thumbnails( $sizes, $metadata, $attachment_id = null ) { + $attachment_id = is_null( $attachment_id ) ? $this->attachment_id : $attachment_id; + + if ( ! $sizes || ! $attachment_id ) { + return $sizes; + } + + $fullsizepath = get_attached_file( $attachment_id ); + $editor = wp_get_image_editor( $fullsizepath ); + + if ( is_wp_error( $editor ) ) { + return $sizes; + } + + $metadata = wp_get_attachment_metadata( $attachment_id ); + + // This is based on WP_Image_Editor_GD::multi_resize() and others. + foreach ( $sizes as $size => $size_data ) { + if ( empty( $metadata['sizes'][ $size ] ) ) { + continue; + } + if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { + continue; + } + if ( ! isset( $size_data['width'] ) ) { + $size_data['width'] = null; + } + if ( ! isset( $size_data['height'] ) ) { + $size_data['height'] = null; + } + if ( ! isset( $size_data['crop'] ) ) { + $size_data['crop'] = false; + } + + list( $orig_w, $orig_h ) = getimagesize( $fullsizepath ); + + $dimensions = image_resize_dimensions( $orig_w, $orig_h, $size_data['width'], $size_data['height'], $size_data['crop'] ); + + if ( ! $dimensions || ! is_array( $dimensions ) ) { + continue; + } + + $info = pathinfo( $fullsizepath ); + $ext = $info['extension']; + $dst_w = $dimensions[4]; + $dst_h = $dimensions[5]; + $suffix = "{$dst_w}x{$dst_h}"; + $dst_rel_path = str_replace( '.' . $ext, '', $fullsizepath ); + $thumbnail = "{$dst_rel_path}-{$suffix}.{$ext}"; + + if ( $dst_w === $metadata['sizes'][ $size ]['width'] && $dst_h === $metadata['sizes'][ $size ]['height'] && file_exists( $thumbnail ) ) { + unset( $sizes[ $size ] ); + } + } + return $sizes; + } + + /** + * Returns the sizes we want to regenerate. + * + * @param array $sizes Sizes to generate. + * @return array + */ + public function adjust_intermediate_image_sizes( $sizes ) { + return apply_filters( 'woocommerce_regenerate_images_intermediate_image_sizes', array( 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail', 'woocommerce_single' ) ); + } + + /** + * This runs once the job has completed all items on the queue. + * + * @return void + */ + protected function complete() { + parent::complete(); + $log = wc_get_logger(); + $log->info( __( 'Completed product image regeneration job.', 'woocommerce' ), + array( + 'source' => 'wc-image-regeneration', + ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php new file mode 100644 index 0000000..ae9c371 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php @@ -0,0 +1,398 @@ +is_running() ) { + WC_Admin_Notices::add_notice( 'regenerating_thumbnails' ); + } else { + WC_Admin_Notices::remove_notice( 'regenerating_thumbnails' ); + } + } + + /** + * Dismiss notice and cancel jobs. + */ + public static function dismiss_regenerating_notice() { + if ( self::$background_process ) { + self::$background_process->kill_process(); + + $log = wc_get_logger(); + $log->info( + __( 'Cancelled product image regeneration job.', 'woocommerce' ), + array( + 'source' => 'wc-image-regeneration', + ) + ); + } + WC_Admin_Notices::remove_notice( 'regenerating_thumbnails' ); + } + + /** + * Regenerate images if the settings have changed since last re-generation. + * + * @return void + */ + public static function maybe_regenerate_images() { + $size_hash = md5( + wp_json_encode( + array( + wc_get_image_size( 'thumbnail' ), + wc_get_image_size( 'single' ), + wc_get_image_size( 'gallery_thumbnail' ), + ) + ) + ); + + if ( update_option( 'woocommerce_maybe_regenerate_images_hash', $size_hash ) ) { + // Size settings have changed. Trigger regen. + self::queue_image_regeneration(); + } + } + + /** + * Check if we should maybe generate a new image size if not already there. + * + * @param array $image Properties of the image. + * @param int $attachment_id Attachment ID. + * @param string|array $size Image size. + * @param bool $icon If icon or not. + * @return array + */ + public static function maybe_resize_image( $image, $attachment_id, $size, $icon ) { + if ( ! apply_filters( 'woocommerce_resize_images', true ) ) { + return $image; + } + + // Use a whitelist of sizes we want to resize. Ignore others. + if ( ! in_array( $size, apply_filters( 'woocommerce_image_sizes_to_resize', array( 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail', 'woocommerce_single', 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ), true ) ) { + return $image; + } + + // Get image metadata - we need it to proceed. + $imagemeta = wp_get_attachment_metadata( $attachment_id ); + + if ( empty( $imagemeta ) ) { + return $image; + } + + if ( ! isset( $imagemeta['sizes'], $imagemeta['sizes'][ $size ] ) || ! self::image_size_matches_settings( $imagemeta['sizes'][ $size ], $size ) ) { + return self::resize_and_return_image( $attachment_id, $image, $size, $icon ); + } + + return $image; + } + + /** + * Ensure we are dealing with the correct image attachment + * + * @param WP_Post $attachment Attachment object. + * @return boolean + */ + public static function is_regeneratable( $attachment ) { + if ( 'site-icon' === get_post_meta( $attachment->ID, '_wp_attachment_context', true ) ) { + return false; + } + + if ( wp_attachment_is_image( $attachment ) ) { + return true; + } + + return false; + } + + /** + * Only regenerate images for the requested size. + * + * @param array $sizes Array of image sizes. + * @return array + */ + public static function adjust_intermediate_image_sizes( $sizes ) { + return array( self::$regenerate_size ); + } + + /** + * Generate the thumbnail filename and dimensions for a given file. + * + * @param string $fullsizepath Path to full size image. + * @param int $thumbnail_width The width of the thumbnail. + * @param int $thumbnail_height The height of the thumbnail. + * @param bool $crop Whether to crop or not. + * @return array|false An array of the filename, thumbnail width, and thumbnail height, or false on failure to resize such as the thumbnail being larger than the fullsize image. + */ + private static function get_image( $fullsizepath, $thumbnail_width, $thumbnail_height, $crop ) { + list( $fullsize_width, $fullsize_height ) = getimagesize( $fullsizepath ); + + $dimensions = image_resize_dimensions( $fullsize_width, $fullsize_height, $thumbnail_width, $thumbnail_height, $crop ); + $editor = wp_get_image_editor( $fullsizepath ); + + if ( is_wp_error( $editor ) ) { + return false; + } + + if ( ! $dimensions || ! is_array( $dimensions ) ) { + return false; + } + + list( , , , , $dst_w, $dst_h ) = $dimensions; + $suffix = "{$dst_w}x{$dst_h}"; + $file_ext = strtolower( pathinfo( $fullsizepath, PATHINFO_EXTENSION ) ); + + return array( + 'filename' => $editor->generate_filename( $suffix, null, $file_ext ), + 'width' => $dst_w, + 'height' => $dst_h, + ); + } + + /** + * Regenerate the image according to the required size + * + * @param int $attachment_id Attachment ID. + * @param array $image Original Image. + * @param string $size Size to return for new URL. + * @param bool $icon If icon or not. + * @return string + */ + private static function resize_and_return_image( $attachment_id, $image, $size, $icon ) { + $image_size = wc_get_image_size( $size ); + $wp_uploads = wp_upload_dir( null, false ); + $wp_uploads_dir = $wp_uploads['basedir']; + $wp_uploads_url = $wp_uploads['baseurl']; + $attachment = get_post( $attachment_id ); + + if ( ! $attachment || 'attachment' !== $attachment->post_type || ! self::is_regeneratable( $attachment ) ) { + return $image; + } + + $fullsizepath = get_attached_file( $attachment_id ); + + if ( false === $fullsizepath || is_wp_error( $fullsizepath ) || ! file_exists( $fullsizepath ) ) { + return $image; + } + + if ( ! function_exists( 'wp_crop_image' ) ) { + include ABSPATH . 'wp-admin/includes/image.php'; + } + + $thumbnail = self::get_image( $fullsizepath, $image_size['width'], $image_size['height'], $image_size['crop'] ); + + // If the file is already there perhaps just load it. + if ( $thumbnail && file_exists( $thumbnail['filename'] ) ) { + $wp_uploads = wp_upload_dir( null, false ); + $wp_uploads_dir = $wp_uploads['basedir']; + $wp_uploads_url = $wp_uploads['baseurl']; + + return array( + 0 => str_replace( $wp_uploads_dir, $wp_uploads_url, $thumbnail['filename'] ), + 1 => $thumbnail['width'], + 2 => $thumbnail['height'], + ); + } + + $metadata = wp_get_attachment_metadata( $attachment_id ); + + // Make sure registered image size matches the size we're requesting. + add_image_size( $size . '_preview', $image_size['width'], $image_size['height'], $image_size['crop'] ); + + self::$regenerate_size = $size . '_preview'; + + // We only want to regen a specific image size. + add_filter( 'intermediate_image_sizes', array( __CLASS__, 'adjust_intermediate_image_sizes' ) ); + + // This function will generate the new image sizes. + $new_metadata = wp_generate_attachment_metadata( $attachment_id, $fullsizepath ); + + // Remove custom filter. + remove_filter( 'intermediate_image_sizes', array( __CLASS__, 'adjust_intermediate_image_sizes' ) ); + + // If something went wrong lets just return the original image. + if ( is_wp_error( $new_metadata ) || empty( $new_metadata ) ) { + return $image; + } + + // Since this is only a preview we should not update the actual size. That will be done later by the background job. + if ( isset( $new_metadata['sizes'][ $size . '_preview' ] ) ) { + $metadata['sizes'][ $size . '_preview' ] = $new_metadata['sizes'][ $size . '_preview' ]; + wp_update_attachment_metadata( $attachment_id, $metadata ); + } + + // Now we've done our regen, attempt to return the new size. + $new_image = image_downsize( $attachment_id, $size . '_preview' ); + + return $new_image ? $new_image : $image; + } + + /** + * Get list of images and queue them for regeneration + * + * @return void + */ + public static function queue_image_regeneration() { + global $wpdb; + // First lets cancel existing running queue to avoid running it more than once. + self::$background_process->kill_process(); + + // Now lets find all product image attachments IDs and pop them onto the queue. + $images = $wpdb->get_results( // @codingStandardsIgnoreLine + "SELECT ID + FROM $wpdb->posts + WHERE post_type = 'attachment' + AND post_mime_type LIKE 'image/%' + ORDER BY ID DESC" + ); + foreach ( $images as $image ) { + self::$background_process->push_to_queue( + array( + 'attachment_id' => $image->ID, + ) + ); + } + + // Lets dispatch the queue to start processing. + self::$background_process->save()->dispatch(); + } +} + +add_action( 'init', array( 'WC_Regenerate_Images', 'init' ) ); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-register-wp-admin-settings.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-register-wp-admin-settings.php new file mode 100644 index 0000000..822972f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-register-wp-admin-settings.php @@ -0,0 +1,180 @@ +object = $object; + + if ( 'page' === $type ) { + add_filter( 'woocommerce_settings_groups', array( $this, 'register_page_group' ) ); + add_filter( 'woocommerce_settings-' . $this->object->get_id(), array( $this, 'register_page_settings' ) ); + } elseif ( 'email' === $type ) { + add_filter( 'woocommerce_settings_groups', array( $this, 'register_email_group' ) ); + add_filter( 'woocommerce_settings-email_' . $this->object->id, array( $this, 'register_email_settings' ) ); + } + } + + /** + * Register's all of our different notification emails as sub groups + * of email settings. + * + * @since 3.0.0 + * @param array $groups Existing registered groups. + * @return array + */ + public function register_email_group( $groups ) { + $groups[] = array( + 'id' => 'email_' . $this->object->id, + 'label' => $this->object->title, + 'description' => $this->object->description, + 'parent_id' => 'email', + ); + return $groups; + } + + /** + * Registers all of the setting form fields for emails to each email type's group. + * + * @since 3.0.0 + * @param array $settings Existing registered settings. + * @return array + */ + public function register_email_settings( $settings ) { + foreach ( $this->object->form_fields as $id => $setting ) { + $setting['id'] = $id; + $setting['option_key'] = array( $this->object->get_option_key(), $id ); + $new_setting = $this->register_setting( $setting ); + if ( $new_setting ) { + $settings[] = $new_setting; + } + } + return $settings; + } + + /** + * Registers a setting group, based on admin page ID & label as parent group. + * + * @since 3.0.0 + * @param array $groups Array of previously registered groups. + * @return array + */ + public function register_page_group( $groups ) { + $groups[] = array( + 'id' => $this->object->get_id(), + 'label' => $this->object->get_label(), + ); + return $groups; + } + + /** + * Registers settings to a specific group. + * + * @since 3.0.0 + * @param array $settings Existing registered settings. + * @return array + */ + public function register_page_settings( $settings ) { + /** + * WP admin settings can be broken down into separate sections from + * a UI standpoint. This will grab all the sections associated with + * a particular setting group (like 'products') and register them + * to the REST API. + */ + $sections = $this->object->get_sections(); + if ( empty( $sections ) ) { + // Default section is just an empty string, per admin page classes. + $sections = array( '' ); + } + + foreach ( $sections as $section => $section_label ) { + $settings_from_section = $this->object->get_settings( $section ); + foreach ( $settings_from_section as $setting ) { + if ( ! isset( $setting['id'] ) ) { + continue; + } + $setting['option_key'] = $setting['id']; + $new_setting = $this->register_setting( $setting ); + if ( $new_setting ) { + $settings[] = $new_setting; + } + } + } + return $settings; + } + + /** + * Register a setting into the format expected for the Settings REST API. + * + * @since 3.0.0 + * @param array $setting Setting data. + * @return array|bool + */ + public function register_setting( $setting ) { + if ( ! isset( $setting['id'] ) ) { + return false; + } + + $description = ''; + if ( ! empty( $setting['desc'] ) ) { + $description = $setting['desc']; + } elseif ( ! empty( $setting['description'] ) ) { + $description = $setting['description']; + } + + $new_setting = array( + 'id' => $setting['id'], + 'label' => ( ! empty( $setting['title'] ) ? $setting['title'] : '' ), + 'description' => $description, + 'type' => $setting['type'], + 'option_key' => $setting['option_key'], + ); + + if ( isset( $setting['default'] ) ) { + $new_setting['default'] = $setting['default']; + } + if ( isset( $setting['options'] ) ) { + $new_setting['options'] = $setting['options']; + } + if ( isset( $setting['desc_tip'] ) ) { + if ( true === $setting['desc_tip'] ) { + $new_setting['tip'] = $description; + } elseif ( ! empty( $setting['desc_tip'] ) ) { + $new_setting['tip'] = $setting['desc_tip']; + } + } + + return $new_setting; + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php new file mode 100644 index 0000000..370177c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php @@ -0,0 +1,344 @@ +_cookie = apply_filters( 'woocommerce_cookie', 'wp_woocommerce_session_' . COOKIEHASH ); + $this->_table = $GLOBALS['wpdb']->prefix . 'woocommerce_sessions'; + } + + /** + * Init hooks and session data. + * + * @since 3.3.0 + */ + public function init() { + $cookie = $this->get_session_cookie(); + + if ( $cookie ) { + $this->_customer_id = $cookie[0]; + $this->_session_expiration = $cookie[1]; + $this->_session_expiring = $cookie[2]; + $this->_has_cookie = true; + + // Update session if its close to expiring. + if ( time() > $this->_session_expiring ) { + $this->set_session_expiration(); + $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); + } + } else { + $this->set_session_expiration(); + $this->_customer_id = $this->generate_customer_id(); + } + + $this->_data = $this->get_session_data(); + + add_action( 'woocommerce_set_cart_cookies', array( $this, 'set_customer_session_cookie' ), 10 ); + add_action( 'shutdown', array( $this, 'save_data' ), 20 ); + add_action( 'wp_logout', array( $this, 'destroy_session' ) ); + + if ( ! is_user_logged_in() ) { + add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); + } + } + + /** + * Sets the session cookie on-demand (usually after adding an item to the cart). + * + * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set. + * + * Warning: Cookies will only be set if this is called before the headers are sent. + * + * @param bool $set Should the session cookie be set. + */ + public function set_customer_session_cookie( $set ) { + if ( $set ) { + $to_hash = $this->_customer_id . '|' . $this->_session_expiration; + $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); + $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; + $this->_has_cookie = true; + + wc_setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, apply_filters( 'wc_session_use_secure_cookie', false ) ); + } + } + + /** + * Return true if the current user has an active session, i.e. a cookie to retrieve values. + * + * @return bool + */ + public function has_session() { + return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. + } + + /** + * Set session expiration. + */ + public function set_session_expiration() { + $this->_session_expiring = time() + intval( apply_filters( 'wc_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. + $this->_session_expiration = time() + intval( apply_filters( 'wc_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. + } + + /** + * Generate a unique customer ID for guests, or return user ID if logged in. + * + * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. + * + * @return string + */ + public function generate_customer_id() { + $customer_id = ''; + + if ( is_user_logged_in() ) { + $customer_id = get_current_user_id(); + } + + if ( empty( $customer_id ) ) { + require_once ABSPATH . 'wp-includes/class-phpass.php'; + $hasher = new PasswordHash( 8, false ); + $customer_id = md5( $hasher->get_random_bytes( 32 ) ); + } + + return $customer_id; + } + + /** + * Get the session cookie, if set. Otherwise return false. + * + * Session cookies without a customer ID are invalid. + * + * @return bool|array + */ + public function get_session_cookie() { + $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. + + if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { + return false; + } + + list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); + + if ( empty( $customer_id ) ) { + return false; + } + + // Validate hash. + $to_hash = $customer_id . '|' . $session_expiration; + $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); + + if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { + return false; + } + + return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); + } + + /** + * Get session data. + * + * @return array + */ + public function get_session_data() { + return $this->has_session() ? (array) $this->get_session( $this->_customer_id, array() ) : array(); + } + + /** + * Gets a cache prefix. This is used in session names so the entire cache can be invalidated with 1 function call. + * + * @return string + */ + private function get_cache_prefix() { + return WC_Cache_Helper::get_cache_prefix( WC_SESSION_CACHE_GROUP ); + } + + /** + * Save data. + */ + public function save_data() { + // Dirty if something changed - prevents saving nothing new. + if ( $this->_dirty && $this->has_session() ) { + global $wpdb; + + $wpdb->replace( // @codingStandardsIgnoreLine. + $this->_table, + array( + 'session_key' => $this->_customer_id, + 'session_value' => maybe_serialize( $this->_data ), + 'session_expiry' => $this->_session_expiration, + ), + array( + '%s', + '%s', + '%d', + ) + ); + + wp_cache_set( $this->get_cache_prefix() . $this->_customer_id, $this->_data, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() ); + $this->_dirty = false; + } + } + + /** + * Destroy all session data. + */ + public function destroy_session() { + wc_setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, apply_filters( 'wc_session_use_secure_cookie', false ) ); + + $this->delete_session( $this->_customer_id ); + + wc_empty_cart(); + + $this->_data = array(); + $this->_dirty = false; + $this->_customer_id = $this->generate_customer_id(); + } + + /** + * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. + * + * @param int $uid User ID. + * @return string + */ + public function nonce_user_logged_out( $uid ) { + return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; + } + + /** + * Cleanup session data from the database and clear caches. + */ + public function cleanup_sessions() { + global $wpdb; + + $wpdb->query( $wpdb->prepare( "DELETE FROM $this->_table WHERE session_expiry < %d", time() ) ); // @codingStandardsIgnoreLine. + + if ( class_exists( 'WC_Cache_Helper' ) ) { + WC_Cache_Helper::incr_cache_prefix( WC_SESSION_CACHE_GROUP ); + } + } + + /** + * Returns the session. + * + * @param string $customer_id Custo ID. + * @param mixed $default Default session value. + * @return string|array + */ + public function get_session( $customer_id, $default = false ) { + global $wpdb; + + if ( defined( 'WP_SETUP_CONFIG' ) ) { + return false; + } + + // Try to get it from the cache, it will return false if not present or if object cache not in use. + $value = wp_cache_get( $this->get_cache_prefix() . $customer_id, WC_SESSION_CACHE_GROUP ); + + if ( false === $value ) { + $value = $wpdb->get_var( $wpdb->prepare( "SELECT session_value FROM $this->_table WHERE session_key = %s", $customer_id ) ); // @codingStandardsIgnoreLine. + + if ( is_null( $value ) ) { + $value = $default; + } + + wp_cache_add( $this->get_cache_prefix() . $customer_id, $value, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() ); + } + + return maybe_unserialize( $value ); + } + + /** + * Delete the session from the cache and database. + * + * @param int $customer_id Customer ID. + */ + public function delete_session( $customer_id ) { + global $wpdb; + + wp_cache_delete( $this->get_cache_prefix() . $customer_id, WC_SESSION_CACHE_GROUP ); + + $wpdb->delete( // @codingStandardsIgnoreLine. + $this->_table, + array( + 'session_key' => $customer_id, + ) + ); + } + + /** + * Update the session expiry timestamp. + * + * @param string $customer_id Customer ID. + * @param int $timestamp Timestamp to expire the cookie. + */ + public function update_session_timestamp( $customer_id, $timestamp ) { + global $wpdb; + + // @codingStandardsIgnoreStart. + $wpdb->update( + $this->_table, + array( + 'session_expiry' => $timestamp, + ), + array( + 'session_key' => $customer_id, + ), + array( + '%d' + ) + ); + // @codingStandardsIgnoreEnd. + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-rate.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-rate.php new file mode 100644 index 0000000..06dc919 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-rate.php @@ -0,0 +1,252 @@ + '', + 'method_id' => '', + 'instance_id' => 0, + 'label' => '', + 'cost' => 0, + 'taxes' => array(), + ); + + /** + * Stores meta data for this rate. + * + * @since 2.6.0 + * @var array + */ + protected $meta_data = array(); + + /** + * Constructor. + * + * @param string $id Shipping rate ID. + * @param string $label Shipping rate label. + * @param integer $cost Cost. + * @param array $taxes Taxes applied to shipping rate. + * @param string $method_id Shipping method ID. + * @param int $instance_id Shipping instance ID. + */ + public function __construct( $id = '', $label = '', $cost = 0, $taxes = array(), $method_id = '', $instance_id = 0 ) { + $this->set_id( $id ); + $this->set_label( $label ); + $this->set_cost( $cost ); + $this->set_taxes( $taxes ); + $this->set_method_id( $method_id ); + $this->set_instance_id( $instance_id ); + } + + /** + * Magic methods to support direct access to props. + * + * @since 3.2.0 + * @param string $key Key. + * @return bool + */ + public function __isset( $key ) { + return isset( $this->data[ $key ] ); + } + + /** + * Magic methods to support direct access to props. + * + * @since 3.2.0 + * @param string $key Key. + * @return mixed + */ + public function __get( $key ) { + if ( is_callable( array( $this, "get_{$key}" ) ) ) { + return $this->{"get_{$key}"}(); + } elseif ( isset( $this->data[ $key ] ) ) { + return $this->data[ $key ]; + } else { + return ''; + } + } + + /** + * Magic methods to support direct access to props. + * + * @since 3.2.0 + * @param string $key Key. + * @param mixed $value Value. + */ + public function __set( $key, $value ) { + if ( is_callable( array( $this, "set_{$key}" ) ) ) { + $this->{"set_{$key}"}( $value ); + } else { + $this->data[ $key ] = $value; + } + } + + /** + * Set ID for the rate. This is usually a combination of the method and instance IDs. + * + * @since 3.2.0 + * @param string $id Shipping rate ID. + */ + public function set_id( $id ) { + $this->data['id'] = (string) $id; + } + + /** + * Set shipping method ID the rate belongs to. + * + * @since 3.2.0 + * @param string $method_id Shipping method ID. + */ + public function set_method_id( $method_id ) { + $this->data['method_id'] = (string) $method_id; + } + + /** + * Set instance ID the rate belongs to. + * + * @since 3.2.0 + * @param int $instance_id Instance ID. + */ + public function set_instance_id( $instance_id ) { + $this->data['instance_id'] = absint( $instance_id ); + } + + /** + * Set rate label. + * + * @since 3.2.0 + * @param string $label Shipping rate label. + */ + public function set_label( $label ) { + $this->data['label'] = (string) $label; + } + + /** + * Set rate cost. + * + * @todo 4.0 Prevent negative value being set. #19293 + * @since 3.2.0 + * @param string $cost Shipping rate cost. + */ + public function set_cost( $cost ) { + $this->data['cost'] = $cost; + } + + /** + * Set rate taxes. + * + * @since 3.2.0 + * @param array $taxes List of taxes applied to shipping rate. + */ + public function set_taxes( $taxes ) { + $this->data['taxes'] = ! empty( $taxes ) && is_array( $taxes ) ? $taxes : array(); + } + + /** + * Set ID for the rate. This is usually a combination of the method and instance IDs. + * + * @since 3.2.0 + * @return string + */ + public function get_id() { + return apply_filters( 'woocommerce_shipping_rate_id', $this->data['id'], $this ); + } + + /** + * Set shipping method ID the rate belongs to. + * + * @since 3.2.0 + * @return string + */ + public function get_method_id() { + return apply_filters( 'woocommerce_shipping_rate_method_id', $this->data['method_id'], $this ); + } + + /** + * Set instance ID the rate belongs to. + * + * @since 3.2.0 + * @return int + */ + public function get_instance_id() { + return apply_filters( 'woocommerce_shipping_rate_instance_id', $this->data['instance_id'], $this ); + } + + /** + * Set rate label. + * + * @return string + */ + public function get_label() { + return apply_filters( 'woocommerce_shipping_rate_label', $this->data['label'], $this ); + } + + /** + * Set rate cost. + * + * @since 3.2.0 + * @return string + */ + public function get_cost() { + return apply_filters( 'woocommerce_shipping_rate_cost', $this->data['cost'], $this ); + } + + /** + * Set rate taxes. + * + * @since 3.2.0 + * @return array + */ + public function get_taxes() { + return apply_filters( 'woocommerce_shipping_rate_taxes', $this->data['taxes'], $this ); + } + + /** + * Get shipping tax. + * + * @return array + */ + public function get_shipping_tax() { + return apply_filters( 'woocommerce_get_shipping_tax', count( $this->taxes ) > 0 && ! WC()->customer->get_is_vat_exempt() ? array_sum( $this->taxes ) : 0, $this ); + } + + /** + * Add some meta data for this rate. + * + * @since 2.6.0 + * @param string $key Key. + * @param string $value Value. + */ + public function add_meta_data( $key, $value ) { + $this->meta_data[ wc_clean( $key ) ] = wc_clean( $value ); + } + + /** + * Get all meta data for this rate. + * + * @since 2.6.0 + * @return array + */ + public function get_meta_data() { + return $this->meta_data; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zone.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zone.php new file mode 100644 index 0000000..cabfb93 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zone.php @@ -0,0 +1,445 @@ + '', + 'zone_order' => 0, + 'zone_locations' => array(), + ); + + /** + * Constructor for zones. + * + * @param int|object $zone Zone ID to load from the DB or zone object. + */ + public function __construct( $zone = null ) { + if ( is_numeric( $zone ) && ! empty( $zone ) ) { + $this->set_id( $zone ); + } elseif ( is_object( $zone ) ) { + $this->set_id( $zone->zone_id ); + } elseif ( 0 === $zone || '0' === $zone ) { + $this->set_id( 0 ); + } else { + $this->set_object_read( true ); + } + + $this->data_store = WC_Data_Store::load( 'shipping-zone' ); + if ( false === $this->get_object_read() ) { + $this->data_store->read( $this ); + } + } + + /** + * -------------------------------------------------------------------------- + * Getters + * -------------------------------------------------------------------------- + */ + + /** + * Get zone name. + * + * @param string $context View or edit context. + * @return string + */ + public function get_zone_name( $context = 'view' ) { + return $this->get_prop( 'zone_name', $context ); + } + + /** + * Get zone order. + * + * @param string $context View or edit context. + * @return int + */ + public function get_zone_order( $context = 'view' ) { + return $this->get_prop( 'zone_order', $context ); + } + + /** + * Get zone locations. + * + * @param string $context View or edit context. + * @return array of zone objects + */ + public function get_zone_locations( $context = 'view' ) { + return $this->get_prop( 'zone_locations', $context ); + } + + /** + * Return a text string representing what this zone is for. + * + * @param int $max Max locations to return. + * @param string $context View or edit context. + * @return string + */ + public function get_formatted_location( $max = 10, $context = 'view' ) { + $location_parts = array(); + $all_continents = WC()->countries->get_continents(); + $all_countries = WC()->countries->get_countries(); + $all_states = WC()->countries->get_states(); + $locations = $this->get_zone_locations( $context ); + $continents = array_filter( $locations, array( $this, 'location_is_continent' ) ); + $countries = array_filter( $locations, array( $this, 'location_is_country' ) ); + $states = array_filter( $locations, array( $this, 'location_is_state' ) ); + $postcodes = array_filter( $locations, array( $this, 'location_is_postcode' ) ); + + foreach ( $continents as $location ) { + $location_parts[] = $all_continents[ $location->code ]['name']; + } + + foreach ( $countries as $location ) { + $location_parts[] = $all_countries[ $location->code ]; + } + + foreach ( $states as $location ) { + $location_codes = explode( ':', $location->code ); + $location_parts[] = $all_states[ $location_codes[0] ][ $location_codes[1] ]; + } + + foreach ( $postcodes as $location ) { + $location_parts[] = $location->code; + } + + // Fix display of encoded characters. + $location_parts = array_map( 'html_entity_decode', $location_parts ); + + if ( count( $location_parts ) > $max ) { + $remaining = count( $location_parts ) - $max; + // @codingStandardsIgnoreStart + return sprintf( _n( '%s and %d other region', '%s and %d other regions', $remaining, 'woocommerce' ), implode( ', ', array_splice( $location_parts, 0, $max ) ), $remaining ); + // @codingStandardsIgnoreEnd + } elseif ( ! empty( $location_parts ) ) { + return implode( ', ', $location_parts ); + } else { + return __( 'Everywhere', 'woocommerce' ); + } + } + + /** + * Get shipping methods linked to this zone. + * + * @param bool $enabled_only Only return enabled methods. + * @param string $context Getting shipping methods for what context. Valid values, admin, json. + * @return array of objects + */ + public function get_shipping_methods( $enabled_only = false, $context = 'admin' ) { + if ( null === $this->get_id() ) { + return array(); + } + + $raw_methods = $this->data_store->get_methods( $this->get_id(), $enabled_only ); + $wc_shipping = WC_Shipping::instance(); + $allowed_classes = $wc_shipping->get_shipping_method_class_names(); + $methods = array(); + + foreach ( $raw_methods as $raw_method ) { + if ( in_array( $raw_method->method_id, array_keys( $allowed_classes ), true ) ) { + $class_name = $allowed_classes[ $raw_method->method_id ]; + $instance_id = $raw_method->instance_id; + + // The returned array may contain instances of shipping methods, as well + // as classes. If the "class" is an instance, just use it. If not, + // create an instance. + if ( is_object( $class_name ) ) { + $class_name_of_instance = get_class( $class_name ); + $methods[ $instance_id ] = new $class_name_of_instance( $instance_id ); + } else { + // If the class is not an object, it should be a string. It's better + // to double check, to be sure (a class must be a string, anything) + // else would be useless. + if ( is_string( $class_name ) && class_exists( $class_name ) ) { + $methods[ $instance_id ] = new $class_name( $instance_id ); + } + } + + // Let's make sure that we have an instance before setting its attributes. + if ( is_object( $methods[ $instance_id ] ) ) { + $methods[ $instance_id ]->method_order = absint( $raw_method->method_order ); + $methods[ $instance_id ]->enabled = $raw_method->is_enabled ? 'yes' : 'no'; + $methods[ $instance_id ]->has_settings = $methods[ $instance_id ]->has_settings(); + $methods[ $instance_id ]->settings_html = $methods[ $instance_id ]->supports( 'instance-settings-modal' ) ? $methods[ $instance_id ]->get_admin_options_html() : false; + $methods[ $instance_id ]->method_description = wp_kses_post( wpautop( $methods[ $instance_id ]->method_description ) ); + } + + if ( 'json' === $context ) { + // We don't want the entire object in this context, just the public props. + $methods[ $instance_id ] = (object) get_object_vars( $methods[ $instance_id ] ); + unset( $methods[ $instance_id ]->instance_form_fields, $methods[ $instance_id ]->form_fields ); + } + } + } + + uasort( $methods, 'wc_shipping_zone_method_order_uasort_comparison' ); + + return apply_filters( 'woocommerce_shipping_zone_shipping_methods', $methods, $raw_methods, $allowed_classes, $this ); + } + + /** + * -------------------------------------------------------------------------- + * Setters + * -------------------------------------------------------------------------- + */ + + /** + * Set zone name. + * + * @param string $set Value to set. + */ + public function set_zone_name( $set ) { + $this->set_prop( 'zone_name', wc_clean( $set ) ); + } + + /** + * Set zone order. Value to set. + * + * @param int $set Value to set. + */ + public function set_zone_order( $set ) { + $this->set_prop( 'zone_order', absint( $set ) ); + } + + /** + * Set zone locations. + * + * @since 3.0.0 + * @param array $locations Value to set. + */ + public function set_zone_locations( $locations ) { + if ( 0 !== $this->get_id() ) { + $this->set_prop( 'zone_locations', $locations ); + } + } + + /** + * -------------------------------------------------------------------------- + * Other + * -------------------------------------------------------------------------- + */ + + /** + * Save zone data to the database. + * + * @return int + */ + public function save() { + if ( ! $this->get_zone_name() ) { + $this->set_zone_name( $this->generate_zone_name() ); + } + if ( $this->data_store ) { + // Trigger action before saving to the DB. Allows you to adjust object props before save. + do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store ); + + if ( null === $this->get_id() ) { + $this->data_store->create( $this ); + } else { + $this->data_store->update( $this ); + } + return $this->get_id(); + } + } + + /** + * Generate a zone name based on location. + * + * @return string + */ + protected function generate_zone_name() { + $zone_name = $this->get_formatted_location(); + + if ( empty( $zone_name ) ) { + $zone_name = __( 'Zone', 'woocommerce' ); + } + + return $zone_name; + } + + /** + * Location type detection. + * + * @param object $location Location to check. + * @return boolean + */ + private function location_is_continent( $location ) { + return 'continent' === $location->type; + } + + /** + * Location type detection. + * + * @param object $location Location to check. + * @return boolean + */ + private function location_is_country( $location ) { + return 'country' === $location->type; + } + + /** + * Location type detection. + * + * @param object $location Location to check. + * @return boolean + */ + private function location_is_state( $location ) { + return 'state' === $location->type; + } + + /** + * Location type detection. + * + * @param object $location Location to check. + * @return boolean + */ + private function location_is_postcode( $location ) { + return 'postcode' === $location->type; + } + + /** + * Is passed location type valid? + * + * @param string $type Type to check. + * @return boolean + */ + public function is_valid_location_type( $type ) { + return in_array( $type, array( 'postcode', 'state', 'country', 'continent' ), true ); + } + + /** + * Add location (state or postcode) to a zone. + * + * @param string $code Location code. + * @param string $type state or postcode. + */ + public function add_location( $code, $type ) { + if ( 0 !== $this->get_id() && $this->is_valid_location_type( $type ) ) { + if ( 'postcode' === $type ) { + $code = trim( strtoupper( str_replace( chr( 226 ) . chr( 128 ) . chr( 166 ), '...', $code ) ) ); // No normalization - postcodes are matched against both normal and formatted versions to support wildcards. + } + $location = array( + 'code' => wc_clean( $code ), + 'type' => wc_clean( $type ), + ); + $zone_locations = $this->get_prop( 'zone_locations', 'edit' ); + $zone_locations[] = (object) $location; + $this->set_prop( 'zone_locations', $zone_locations ); + } + } + + + /** + * Clear all locations for this zone. + * + * @param array|string $types of location to clear. + */ + public function clear_locations( $types = array( 'postcode', 'state', 'country', 'continent' ) ) { + if ( ! is_array( $types ) ) { + $types = array( $types ); + } + $zone_locations = $this->get_prop( 'zone_locations', 'edit' ); + foreach ( $zone_locations as $key => $values ) { + if ( in_array( $values->type, $types, true ) ) { + unset( $zone_locations[ $key ] ); + } + } + $zone_locations = array_values( $zone_locations ); // reindex. + $this->set_prop( 'zone_locations', $zone_locations ); + } + + /** + * Set locations. + * + * @param array $locations Array of locations. + */ + public function set_locations( $locations = array() ) { + $this->clear_locations(); + foreach ( $locations as $location ) { + $this->add_location( $location['code'], $location['type'] ); + } + } + + /** + * Add a shipping method to this zone. + * + * @param string $type shipping method type. + * @return int new instance_id, 0 on failure + */ + public function add_shipping_method( $type ) { + if ( null === $this->get_id() ) { + $this->save(); + } + + $instance_id = 0; + $wc_shipping = WC_Shipping::instance(); + $allowed_classes = $wc_shipping->get_shipping_method_class_names(); + $count = $this->data_store->get_method_count( $this->get_id() ); + + if ( in_array( $type, array_keys( $allowed_classes ), true ) ) { + $instance_id = $this->data_store->add_method( $this->get_id(), $type, $count + 1 ); + } + + if ( $instance_id ) { + do_action( 'woocommerce_shipping_zone_method_added', $instance_id, $type, $this->get_id() ); + } + + WC_Cache_Helper::get_transient_version( 'shipping', true ); + + return $instance_id; + } + + /** + * Delete a shipping method from a zone. + * + * @param int $instance_id Shipping method instance ID. + * @return True on success, false on failure + */ + public function delete_shipping_method( $instance_id ) { + if ( null === $this->get_id() ) { + return false; + } + + // Get method details. + $method = $this->data_store->get_method( $instance_id ); + + if ( $method ) { + $this->data_store->delete_method( $instance_id ); + do_action( 'woocommerce_shipping_zone_method_deleted', $instance_id, $method->method_id, $this->get_id() ); + } + + WC_Cache_Helper::get_transient_version( 'shipping', true ); + + return true; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zones.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zones.php new file mode 100644 index 0000000..229d709 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping-zones.php @@ -0,0 +1,142 @@ +get_zones(); + $zones = array(); + + foreach ( $raw_zones as $raw_zone ) { + $zone = new WC_Shipping_Zone( $raw_zone ); + $zones[ $zone->get_id() ] = $zone->get_data(); + $zones[ $zone->get_id() ]['zone_id'] = $zone->get_id(); + $zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location(); + $zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods( false, $context ); + } + + return $zones; + } + + /** + * Get shipping zone using it's ID + * + * @since 2.6.0 + * @param int $zone_id Zone ID. + * @return WC_Shipping_Zone|bool + */ + public static function get_zone( $zone_id ) { + return self::get_zone_by( 'zone_id', $zone_id ); + } + + /** + * Get shipping zone by an ID. + * + * @since 2.6.0 + * @param string $by Get by 'zone_id' or 'instance_id'. + * @param int $id ID. + * @return WC_Shipping_Zone|bool + */ + public static function get_zone_by( $by = 'zone_id', $id = 0 ) { + $zone_id = false; + + switch ( $by ) { + case 'zone_id': + $zone_id = $id; + break; + case 'instance_id': + $data_store = WC_Data_Store::load( 'shipping-zone' ); + $zone_id = $data_store->get_zone_id_by_instance_id( $id ); + break; + } + + if ( false !== $zone_id ) { + try { + return new WC_Shipping_Zone( $zone_id ); + } catch ( Exception $e ) { + return false; + } + } + + return false; + } + + /** + * Get shipping zone using it's ID. + * + * @since 2.6.0 + * @param int $instance_id Instance ID. + * @return bool|WC_Shipping_Method + */ + public static function get_shipping_method( $instance_id ) { + $data_store = WC_Data_Store::load( 'shipping-zone' ); + $raw_shipping_method = $data_store->get_method( $instance_id ); + $wc_shipping = WC_Shipping::instance(); + $allowed_classes = $wc_shipping->get_shipping_method_class_names(); + + if ( ! empty( $raw_shipping_method ) && in_array( $raw_shipping_method->method_id, array_keys( $allowed_classes ), true ) ) { + $class_name = $allowed_classes[ $raw_shipping_method->method_id ]; + if ( is_object( $class_name ) ) { + $class_name = get_class( $class_name ); + } + return new $class_name( $raw_shipping_method->instance_id ); + } + return false; + } + + /** + * Delete a zone using it's ID + * + * @param int $zone_id Zone ID. + * @since 2.6.0 + */ + public static function delete_zone( $zone_id ) { + $zone = new WC_Shipping_Zone( $zone_id ); + $zone->delete(); + } + + /** + * Find a matching zone for a given package. + * + * @since 2.6.0 + * @uses wc_make_numeric_postcode() + * @param array $package Shipping package. + * @return WC_Shipping_Zone + */ + public static function get_zone_matching_package( $package ) { + $country = strtoupper( wc_clean( $package['destination']['country'] ) ); + $state = strtoupper( wc_clean( $package['destination']['state'] ) ); + $postcode = wc_normalize_postcode( wc_clean( $package['destination']['postcode'] ) ); + $cache_key = WC_Cache_Helper::get_cache_prefix( 'shipping_zones' ) . 'wc_shipping_zone_' . md5( sprintf( '%s+%s+%s', $country, $state, $postcode ) ); + $matching_zone_id = wp_cache_get( $cache_key, 'shipping_zones' ); + + if ( false === $matching_zone_id ) { + $data_store = WC_Data_Store::load( 'shipping-zone' ); + $matching_zone_id = $data_store->get_zone_id_from_package( $package ); + wp_cache_set( $cache_key, $matching_zone_id, 'shipping_zones' ); + } + + return new WC_Shipping_Zone( $matching_zone_id ? $matching_zone_id : 0 ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping.php new file mode 100644 index 0000000..3b93e50 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-shipping.php @@ -0,0 +1,378 @@ +cart->get_shipping_total(); + } + if ( 'shipping_taxes' === $name ) { + return wc()->cart->get_shipping_taxes(); + } + } + + /** + * Initialize shipping. + */ + public function __construct() { + $this->enabled = wc_shipping_enabled(); + + if ( $this->enabled ) { + $this->init(); + } + } + + /** + * Initialize shipping. + */ + public function init() { + do_action( 'woocommerce_shipping_init' ); + } + + /** + * Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter. + * + * @return array + */ + public function get_shipping_method_class_names() { + // Unique Method ID => Method Class name. + $shipping_methods = array( + 'flat_rate' => 'WC_Shipping_Flat_Rate', + 'free_shipping' => 'WC_Shipping_Free_Shipping', + 'local_pickup' => 'WC_Shipping_Local_Pickup', + ); + + // For backwards compatibility with 2.5.x we load any ENABLED legacy shipping methods here. + $maybe_load_legacy_methods = array( 'flat_rate', 'free_shipping', 'international_delivery', 'local_delivery', 'local_pickup' ); + + foreach ( $maybe_load_legacy_methods as $method ) { + $options = get_option( 'woocommerce_' . $method . '_settings' ); + if ( $options && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { + $shipping_methods[ 'legacy_' . $method ] = 'WC_Shipping_Legacy_' . $method; + } + } + + return apply_filters( 'woocommerce_shipping_methods', $shipping_methods ); + } + + /** + * Loads all shipping methods which are hooked in. + * If a $package is passed some methods may add themselves conditionally and zones will be used. + * + * @param array $package Package information. + * @return array + */ + public function load_shipping_methods( $package = array() ) { + if ( ! empty( $package ) ) { + $debug_mode = 'yes' === get_option( 'woocommerce_shipping_debug_mode', 'no' ); + $shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package ); + $this->shipping_methods = $shipping_zone->get_shipping_methods( true ); + + // Debug output. + if ( $debug_mode && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' ) ) { + wc_add_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' ); + } + } else { + $this->shipping_methods = array(); + } + + // For the settings in the backend, and for non-shipping zone methods, we still need to load any registered classes here. + foreach ( $this->get_shipping_method_class_names() as $method_id => $method_class ) { + $this->register_shipping_method( $method_class ); + } + + // Methods can register themselves manually through this hook if necessary. + do_action( 'woocommerce_load_shipping_methods', $package ); + + // Return loaded methods. + return $this->get_shipping_methods(); + } + + /** + * Register a shipping method. + * + * @param object|string $method Either the name of the method's class, or an instance of the method's class. + * + * @return bool|void + */ + public function register_shipping_method( $method ) { + if ( ! is_object( $method ) ) { + if ( ! class_exists( $method ) ) { + return false; + } + $method = new $method(); + } + if ( is_null( $this->shipping_methods ) ) { + $this->shipping_methods = array(); + } + $this->shipping_methods[ $method->id ] = $method; + } + + /** + * Unregister shipping methods. + */ + public function unregister_shipping_methods() { + $this->shipping_methods = null; + } + + /** + * Returns all registered shipping methods for usage. + * + * @access public + * @return array + */ + public function get_shipping_methods() { + if ( is_null( $this->shipping_methods ) ) { + $this->load_shipping_methods(); + } + return $this->shipping_methods; + } + + /** + * Get an array of shipping classes. + * + * @access public + * @return array + */ + public function get_shipping_classes() { + if ( empty( $this->shipping_classes ) ) { + $classes = get_terms( + 'product_shipping_class', array( + 'hide_empty' => '0', + 'orderby' => 'name', + ) + ); + $this->shipping_classes = ! is_wp_error( $classes ) ? $classes : array(); + } + return apply_filters( 'woocommerce_get_shipping_classes', $this->shipping_classes ); + } + + /** + * Calculate shipping for (multiple) packages of cart items. + * + * @param array $packages multi-dimensional array of cart items to calc shipping for. + * @return array Array of calculated packages. + */ + public function calculate_shipping( $packages = array() ) { + $this->packages = array(); + + if ( ! $this->enabled || empty( $packages ) ) { + return array(); + } + + // Calculate costs for passed packages. + foreach ( $packages as $package_key => $package ) { + $this->packages[ $package_key ] = $this->calculate_shipping_for_package( $package, $package_key ); + } + + /** + * Allow packages to be reorganized after calculating the shipping. + * + * This filter can be used to apply some extra manipulation after the shipping costs are calculated for the packages + * but before Woocommerce does anything with them. A good example of usage is to merge the shipping methods for multiple + * packages for marketplaces. + * + * @since 2.6.0 + * + * @param array $packages The array of packages after shipping costs are calculated. + */ + $this->packages = array_filter( (array) apply_filters( 'woocommerce_shipping_packages', $this->packages ) ); + + return $this->packages; + } + + /** + * See if package is shippable. + * + * Packages are shippable until proven otherwise e.g. after getting a shipping country. + * + * @param array $package Package of cart items. + * @return bool + */ + protected function is_package_shippable( $package ) { + + // Packages are shippable until proven otherwise. + if ( empty( $package['destination']['country'] ) ) { + return true; + } + + $allowed = array_keys( WC()->countries->get_shipping_countries() ); + return in_array( $package['destination']['country'], $allowed, true ); + } + + /** + * Calculate shipping rates for a package, + * + * Calculates each shipping methods cost. Rates are stored in the session based on the package hash to avoid re-calculation every page load. + * + * @param array $package Package of cart items. + * @param int $package_key Index of the package being calculated. Used to cache multiple package rates. + * + * @return array|bool + */ + public function calculate_shipping_for_package( $package = array(), $package_key = 0 ) { + // If shipping is disabled or the package is invalid, return false. + if ( ! $this->enabled || empty( $package ) ) { + return false; + } + + $package['rates'] = array(); + + // If the package is not shippable, e.g. trying to ship to an invalid country, do not calculate rates. + if ( $this->is_package_shippable( $package ) ) { + // Check if we need to recalculate shipping for this package. + $package_to_hash = $package; + + // Remove data objects so hashes are consistent. + foreach ( $package_to_hash['contents'] as $item_id => $item ) { + unset( $package_to_hash['contents'][ $item_id ]['data'] ); + } + + $package_hash = 'wc_ship_' . md5( wp_json_encode( $package_to_hash ) . WC_Cache_Helper::get_transient_version( 'shipping' ) ); + $session_key = 'shipping_for_package_' . $package_key; + $stored_rates = WC()->session->get( $session_key ); + + if ( ! is_array( $stored_rates ) || $package_hash !== $stored_rates['package_hash'] || 'yes' === get_option( 'woocommerce_shipping_debug_mode', 'no' ) ) { + foreach ( $this->load_shipping_methods( $package ) as $shipping_method ) { + if ( ! $shipping_method->supports( 'shipping-zones' ) || $shipping_method->get_instance_id() ) { + $package['rates'] = $package['rates'] + $shipping_method->get_rates_for_package( $package ); // + instead of array_merge maintains numeric keys + } + } + + // Filter the calculated rates. + $package['rates'] = apply_filters( 'woocommerce_package_rates', $package['rates'], $package ); + + // Store in session to avoid recalculation. + WC()->session->set( + $session_key, array( + 'package_hash' => $package_hash, + 'rates' => $package['rates'], + ) + ); + } else { + $package['rates'] = $stored_rates['rates']; + } + } + return $package; + } + + /** + * Get packages. + * + * @return array + */ + public function get_packages() { + return $this->packages; + } + + /** + * Reset shipping. + * + * Reset the totals for shipping as a whole. + */ + public function reset_shipping() { + unset( WC()->session->chosen_shipping_methods ); + $this->packages = array(); + } + + /** + * Deprecated + * + * @deprecated 2.6.0 Was previously used to determine sort order of methods, but this is now controlled by zones and thus unused. + */ + public function sort_shipping_methods() { + wc_deprecated_function( 'sort_shipping_methods', '2.6' ); + return $this->shipping_methods; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php new file mode 100644 index 0000000..5224bd1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php @@ -0,0 +1,658 @@ + __CLASS__ . '::product', + 'product_page' => __CLASS__ . '::product_page', + 'product_category' => __CLASS__ . '::product_category', + 'product_categories' => __CLASS__ . '::product_categories', + 'add_to_cart' => __CLASS__ . '::product_add_to_cart', + 'add_to_cart_url' => __CLASS__ . '::product_add_to_cart_url', + 'products' => __CLASS__ . '::products', + 'recent_products' => __CLASS__ . '::recent_products', + 'sale_products' => __CLASS__ . '::sale_products', + 'best_selling_products' => __CLASS__ . '::best_selling_products', + 'top_rated_products' => __CLASS__ . '::top_rated_products', + 'featured_products' => __CLASS__ . '::featured_products', + 'product_attribute' => __CLASS__ . '::product_attribute', + 'related_products' => __CLASS__ . '::related_products', + 'shop_messages' => __CLASS__ . '::shop_messages', + 'woocommerce_order_tracking' => __CLASS__ . '::order_tracking', + 'woocommerce_cart' => __CLASS__ . '::cart', + 'woocommerce_checkout' => __CLASS__ . '::checkout', + 'woocommerce_my_account' => __CLASS__ . '::my_account', + ); + + foreach ( $shortcodes as $shortcode => $function ) { + add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); + } + + // Alias for pre 2.1 compatibility. + add_shortcode( 'woocommerce_messages', __CLASS__ . '::shop_messages' ); + } + + /** + * Shortcode Wrapper. + * + * @param string[] $function Callback function. + * @param array $atts Attributes. Default to empty array. + * @param array $wrapper Customer wrapper data. + * + * @return string + */ + public static function shortcode_wrapper( + $function, + $atts = array(), + $wrapper = array( + 'class' => 'woocommerce', + 'before' => null, + 'after' => null, + ) + ) { + ob_start(); + + // @codingStandardsIgnoreStart + echo empty( $wrapper['before'] ) ? '
      ' : $wrapper['before']; + call_user_func( $function, $atts ); + echo empty( $wrapper['after'] ) ? '
      ' : $wrapper['after']; + // @codingStandardsIgnoreEnd + + return ob_get_clean(); + } + + /** + * Cart page shortcode. + * + * @return string + */ + public static function cart() { + return is_null( WC()->cart ) ? '' : self::shortcode_wrapper( array( 'WC_Shortcode_Cart', 'output' ) ); + } + + /** + * Checkout page shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function checkout( $atts ) { + return self::shortcode_wrapper( array( 'WC_Shortcode_Checkout', 'output' ), $atts ); + } + + /** + * Order tracking page shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function order_tracking( $atts ) { + return self::shortcode_wrapper( array( 'WC_Shortcode_Order_Tracking', 'output' ), $atts ); + } + + /** + * My account page shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function my_account( $atts ) { + return self::shortcode_wrapper( array( 'WC_Shortcode_My_Account', 'output' ), $atts ); + } + + /** + * List products in a category shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_category( $atts ) { + if ( empty( $atts['category'] ) ) { + return ''; + } + + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'menu_order title', + 'order' => 'ASC', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $shortcode = new WC_Shortcode_Products( $atts, 'product_category' ); + + return $shortcode->get_content(); + } + + /** + * List all (or limited) product categories. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_categories( $atts ) { + if ( isset( $atts['number'] ) ) { + $atts['limit'] = $atts['number']; + } + + $atts = shortcode_atts( array( + 'limit' => '-1', + 'orderby' => 'name', + 'order' => 'ASC', + 'columns' => '4', + 'hide_empty' => 1, + 'parent' => '', + 'ids' => '', + ), $atts, 'product_categories' ); + + $ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); + $hide_empty = ( true === $atts['hide_empty'] || 'true' === $atts['hide_empty'] || 1 === $atts['hide_empty'] || '1' === $atts['hide_empty'] ) ? 1 : 0; + + // Get terms and workaround WP bug with parents/pad counts. + $args = array( + 'orderby' => $atts['orderby'], + 'order' => $atts['order'], + 'hide_empty' => $hide_empty, + 'include' => $ids, + 'pad_counts' => true, + 'child_of' => $atts['parent'], + ); + + $product_categories = get_terms( 'product_cat', $args ); + + if ( '' !== $atts['parent'] ) { + $product_categories = wp_list_filter( $product_categories, array( + 'parent' => $atts['parent'], + ) ); + } + + if ( $hide_empty ) { + foreach ( $product_categories as $key => $category ) { + if ( 0 === $category->count ) { + unset( $product_categories[ $key ] ); + } + } + } + + $atts['limit'] = '-1' === $atts['limit'] ? null : intval( $atts['limit'] ); + if ( $atts['limit'] ) { + $product_categories = array_slice( $product_categories, 0, $atts['limit'] ); + } + + $columns = absint( $atts['columns'] ); + + wc_set_loop_prop( 'columns', $columns ); + wc_set_loop_prop( 'is_shortcode', true ); + + ob_start(); + + if ( $product_categories ) { + woocommerce_product_loop_start(); + + foreach ( $product_categories as $category ) { + wc_get_template( 'content-product_cat.php', array( + 'category' => $category, + ) ); + } + + woocommerce_product_loop_end(); + } + + woocommerce_reset_loop(); + + return '
      ' . ob_get_clean() . '
      '; + } + + /** + * Recent Products shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function recent_products( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'date', + 'order' => 'DESC', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $shortcode = new WC_Shortcode_Products( $atts, 'recent_products' ); + + return $shortcode->get_content(); + } + + /** + * List multiple products shortcode. + * + * @param array $atts Attributes. + * @return string + */ + public static function products( $atts ) { + $atts = (array) $atts; + $type = 'products'; + + // Allow list product based on specific cases. + if ( isset( $atts['on_sale'] ) && wc_string_to_bool( $atts['on_sale'] ) ) { + $type = 'sale_products'; + } elseif ( isset( $atts['best_selling'] ) && wc_string_to_bool( $atts['best_selling'] ) ) { + $type = 'best_selling_products'; + } elseif ( isset( $atts['top_rated'] ) && wc_string_to_bool( $atts['top_rated'] ) ) { + $type = 'top_rated_products'; + } + + $shortcode = new WC_Shortcode_Products( $atts, $type ); + + return $shortcode->get_content(); + } + + /** + * Display a single product. + * + * @param array $atts Attributes. + * @return string + */ + public static function product( $atts ) { + if ( empty( $atts ) ) { + return ''; + } + + $atts['skus'] = isset( $atts['sku'] ) ? $atts['sku'] : ''; + $atts['ids'] = isset( $atts['id'] ) ? $atts['id'] : ''; + $atts['limit'] = '1'; + $shortcode = new WC_Shortcode_Products( (array) $atts, 'product' ); + + return $shortcode->get_content(); + } + + /** + * Display a single product price + cart button. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_add_to_cart( $atts ) { + global $post; + + if ( empty( $atts ) ) { + return ''; + } + + $atts = shortcode_atts( array( + 'id' => '', + 'class' => '', + 'quantity' => '1', + 'sku' => '', + 'style' => 'border:4px solid #ccc; padding: 12px;', + 'show_price' => 'true', + ), $atts, 'product_add_to_cart' ); + + if ( ! empty( $atts['id'] ) ) { + $product_data = get_post( $atts['id'] ); + } elseif ( ! empty( $atts['sku'] ) ) { + $product_id = wc_get_product_id_by_sku( $atts['sku'] ); + $product_data = get_post( $product_id ); + } else { + return ''; + } + + $product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ), true ) ? wc_setup_product_data( $product_data ) : false; + + if ( ! $product ) { + return ''; + } + + ob_start(); + + echo '

      '; + + if ( wc_string_to_bool( $atts['show_price'] ) ) { + // @codingStandardsIgnoreStart + echo $product->get_price_html(); + // @codingStandardsIgnoreEnd + } + + woocommerce_template_loop_add_to_cart( array( + 'quantity' => $atts['quantity'], + ) ); + + echo '

      '; + + // Restore Product global in case this is shown inside a product post. + wc_setup_product_data( $post ); + + return ob_get_clean(); + } + + /** + * Get the add to cart URL for a product. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_add_to_cart_url( $atts ) { + if ( empty( $atts ) ) { + return ''; + } + + if ( isset( $atts['id'] ) ) { + $product_data = get_post( $atts['id'] ); + } elseif ( isset( $atts['sku'] ) ) { + $product_id = wc_get_product_id_by_sku( $atts['sku'] ); + $product_data = get_post( $product_id ); + } else { + return ''; + } + + $product = is_object( $product_data ) && in_array( $product_data->post_type, array( 'product', 'product_variation' ), true ) ? wc_setup_product_data( $product_data ) : false; + + if ( ! $product ) { + return ''; + } + + $_product = wc_get_product( $product_data ); + + return esc_url( $_product->add_to_cart_url() ); + } + + /** + * List all products on sale. + * + * @param array $atts Attributes. + * @return string + */ + public static function sale_products( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'title', + 'order' => 'ASC', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $shortcode = new WC_Shortcode_Products( $atts, 'sale_products' ); + + return $shortcode->get_content(); + } + + /** + * List best selling products on sale. + * + * @param array $atts Attributes. + * @return string + */ + public static function best_selling_products( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $shortcode = new WC_Shortcode_Products( $atts, 'best_selling_products' ); + + return $shortcode->get_content(); + } + + /** + * List top rated products on sale. + * + * @param array $atts Attributes. + * @return string + */ + public static function top_rated_products( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'title', + 'order' => 'ASC', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $shortcode = new WC_Shortcode_Products( $atts, 'top_rated_products' ); + + return $shortcode->get_content(); + } + + /** + * Output featured products. + * + * @param array $atts Attributes. + * @return string + */ + public static function featured_products( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'date', + 'order' => 'DESC', + 'category' => '', + 'cat_operator' => 'IN', + ), (array) $atts ); + + $atts['visibility'] = 'featured'; + + $shortcode = new WC_Shortcode_Products( $atts, 'featured_products' ); + + return $shortcode->get_content(); + } + + /** + * Show a single product page. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_page( $atts ) { + if ( empty( $atts ) ) { + return ''; + } + + if ( ! isset( $atts['id'] ) && ! isset( $atts['sku'] ) ) { + return ''; + } + + $args = array( + 'posts_per_page' => 1, + 'post_type' => 'product', + 'post_status' => 'publish', + 'ignore_sticky_posts' => 1, + 'no_found_rows' => 1, + ); + + if ( isset( $atts['sku'] ) ) { + $args['meta_query'][] = array( + 'key' => '_sku', + 'value' => sanitize_text_field( $atts['sku'] ), + 'compare' => '=', + ); + + $args['post_type'] = array( 'product', 'product_variation' ); + } + + if ( isset( $atts['id'] ) ) { + $args['p'] = absint( $atts['id'] ); + } + + // Don't render titles if desired. + if ( isset( $atts['show_title'] ) && ! $atts['show_title'] ) { + remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); + } + + // Change form action to avoid redirect. + add_filter( 'woocommerce_add_to_cart_form_action', '__return_empty_string' ); + + $single_product = new WP_Query( $args ); + + $preselected_id = '0'; + + // Check if sku is a variation. + if ( isset( $atts['sku'] ) && $single_product->have_posts() && 'product_variation' === $single_product->post->post_type ) { + + $variation = new WC_Product_Variation( $single_product->post->ID ); + $attributes = $variation->get_attributes(); + + // Set preselected id to be used by JS to provide context. + $preselected_id = $single_product->post->ID; + + // Get the parent product object. + $args = array( + 'posts_per_page' => 1, + 'post_type' => 'product', + 'post_status' => 'publish', + 'ignore_sticky_posts' => 1, + 'no_found_rows' => 1, + 'p' => $single_product->post->post_parent, + ); + + $single_product = new WP_Query( $args ); + ?> + + is_single = true; + + ob_start(); + + global $wp_query; + + // Backup query object so following loops think this is a product page. + $previous_wp_query = $wp_query; + // @codingStandardsIgnoreStart + $wp_query = $single_product; + // @codingStandardsIgnoreEnd + + wp_enqueue_script( 'wc-single-product' ); + + while ( $single_product->have_posts() ) { + $single_product->the_post() + ?> +
      + +
      + ' . ob_get_clean() . ''; + } + + /** + * Show messages. + * + * @return string + */ + public static function shop_messages() { + ob_start(); + wc_print_notices(); + return '
      ' . ob_get_clean() . '
      '; + } + + /** + * Order by rating. + * + * @deprecated 3.2.0 Use WC_Shortcode_Products::order_by_rating_post_clauses(). + * @param array $args Query args. + * @return array + */ + public static function order_by_rating_post_clauses( $args ) { + return WC_Shortcode_Products::order_by_rating_post_clauses( $args ); + } + + /** + * List products with an attribute shortcode. + * Example [product_attribute attribute="color" filter="black"]. + * + * @param array $atts Attributes. + * @return string + */ + public static function product_attribute( $atts ) { + $atts = array_merge( array( + 'limit' => '12', + 'columns' => '4', + 'orderby' => 'title', + 'order' => 'ASC', + 'attribute' => '', + 'terms' => '', + ), (array) $atts ); + + if ( empty( $atts['attribute'] ) ) { + return ''; + } + + $shortcode = new WC_Shortcode_Products( $atts, 'product_attribute' ); + + return $shortcode->get_content(); + } + + /** + * List related products. + * + * @param array $atts Attributes. + * @return string + */ + public static function related_products( $atts ) { + if ( isset( $atts['per_page'] ) ) { + $atts['limit'] = $atts['per_page']; + } + + // @codingStandardsIgnoreStart + $atts = shortcode_atts( array( + 'limit' => '4', + 'columns' => '4', + 'orderby' => 'rand', + ), $atts, 'related_products' ); + // @codingStandardsIgnoreEnd + + ob_start(); + + // Rename arg. + $atts['posts_per_page'] = absint( $atts['limit'] ); + + woocommerce_related_products( $atts ); + + return ob_get_clean(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-structured-data.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-structured-data.php new file mode 100644 index 0000000..fcd04ff --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-structured-data.php @@ -0,0 +1,476 @@ +_data ) ) { + unset( $this->_data ); + } + + $this->_data[] = $data; + + return true; + } + + /** + * Gets data. + * + * @return array + */ + public function get_data() { + return $this->_data; + } + + /** + * Structures and returns data. + * + * List of types available by default for specific request: + * + * 'product', + * 'review', + * 'breadcrumblist', + * 'website', + * 'order', + * + * @param array $types Structured data types. + * @return array + */ + public function get_structured_data( $types ) { + $data = array(); + + // Put together the values of same type of structured data. + foreach ( $this->get_data() as $value ) { + $data[ strtolower( $value['@type'] ) ][] = $value; + } + + // Wrap the multiple values of each type inside a graph... Then add context to each type. + foreach ( $data as $type => $value ) { + $data[ $type ] = count( $value ) > 1 ? array( '@graph' => $value ) : $value[0]; + $data[ $type ] = apply_filters( 'woocommerce_structured_data_context', array( '@context' => 'https://schema.org/' ), $data, $type, $value ) + $data[ $type ]; + } + + // If requested types, pick them up... Finally change the associative array to an indexed one. + $data = $types ? array_values( array_intersect_key( $data, array_flip( $types ) ) ) : array_values( $data ); + + if ( ! empty( $data ) ) { + if ( 1 < count( $data ) ) { + $data = apply_filters( 'woocommerce_structured_data_context', array( '@context' => 'https://schema.org/' ), $data, '', '' ) + array( '@graph' => $data ); + } else { + $data = $data[0]; + } + } + + return $data; + } + + /** + * Get data types for pages. + * + * @return array + */ + protected function get_data_type_for_page() { + $types = array(); + $types[] = is_shop() || is_product_category() || is_product() ? 'product' : ''; + $types[] = is_shop() && is_front_page() ? 'website' : ''; + $types[] = is_product() ? 'review' : ''; + $types[] = ! is_shop() ? 'breadcrumblist' : ''; + $types[] = 'order'; + + return array_filter( apply_filters( 'woocommerce_structured_data_type_for_page', $types ) ); + } + + /** + * Makes sure email structured data only outputs on non-plain text versions. + * + * @param WP_Order $order Order data. + * @param bool $sent_to_admin Send to admin (default: false). + * @param bool $plain_text Plain text email (default: false). + */ + public function output_email_structured_data( $order, $sent_to_admin = false, $plain_text = false ) { + if ( $plain_text ) { + return; + } + echo '
      '; + $this->output_structured_data(); + echo '
      '; + } + + /** + * Sanitizes, encodes and outputs structured data. + * + * Hooked into `wp_footer` action hook. + * Hooked into `woocommerce_email_order_details` action hook. + */ + public function output_structured_data() { + $types = $this->get_data_type_for_page(); + $data = wc_clean( $this->get_structured_data( $types ) ); + + if ( $data ) { + echo ''; + } + } + + /* + |-------------------------------------------------------------------------- + | Generators + |-------------------------------------------------------------------------- + | + | Methods for generating specific structured data types: + | + | - Product + | - Review + | - BreadcrumbList + | - WebSite + | - Order + | + | The generated data is stored into `$this->_data`. + | See the methods above for handling `$this->_data`. + | + */ + + /** + * Generates Product structured data. + * + * Hooked into `woocommerce_single_product_summary` action hook. + * Hooked into `woocommerce_shop_loop` action hook. + * + * @param WC_Product $product Product data (default: null). + */ + public function generate_product_data( $product = null ) { + if ( ! is_object( $product ) ) { + global $product; + } + + if ( ! is_a( $product, 'WC_Product' ) ) { + return; + } + + $shop_name = get_bloginfo( 'name' ); + $shop_url = home_url(); + $currency = get_woocommerce_currency(); + + $markup = array( + '@type' => 'Product', + '@id' => get_permalink( $product->get_id() ), + 'name' => $product->get_name(), + ); + + if ( apply_filters( 'woocommerce_structured_data_product_limit', is_product_taxonomy() || is_shop() ) ) { + $markup['url'] = $markup['@id']; + + $this->set_data( apply_filters( 'woocommerce_structured_data_product_limited', $markup, $product ) ); + return; + } + + $markup['image'] = wp_get_attachment_url( $product->get_image_id() ); + $markup['description'] = wpautop( do_shortcode( $product->get_short_description() ? $product->get_short_description() : $product->get_description() ) ); + $markup['sku'] = $product->get_sku(); + + if ( '' !== $product->get_price() ) { + if ( $product->is_type( 'variable' ) ) { + $lowest = $product->get_variation_price( 'min', false ); + $highest = $product->get_variation_price( 'max', false ); + + if ( $lowest === $highest ) { + $markup_offer = array( + '@type' => 'Offer', + 'price' => wc_format_decimal( $lowest, wc_get_price_decimals() ), + 'priceSpecification' => array( + 'price' => wc_format_decimal( $lowest, wc_get_price_decimals() ), + 'priceCurrency' => $currency, + 'valueAddedTaxIncluded' => wc_prices_include_tax() ? 'true' : 'false', + ), + ); + } else { + $markup_offer = array( + '@type' => 'AggregateOffer', + 'lowPrice' => wc_format_decimal( $lowest, wc_get_price_decimals() ), + 'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ), + ); + } + } else { + $markup_offer = array( + '@type' => 'Offer', + 'price' => wc_format_decimal( $product->get_price(), wc_get_price_decimals() ), + 'priceSpecification' => array( + 'price' => wc_format_decimal( $product->get_price(), wc_get_price_decimals() ), + 'priceCurrency' => $currency, + 'valueAddedTaxIncluded' => wc_prices_include_tax() ? 'true' : 'false', + ), + ); + } + + $markup_offer += array( + 'priceCurrency' => $currency, + 'availability' => 'https://schema.org/' . ( $product->is_in_stock() ? 'InStock' : 'OutOfStock' ), + 'url' => $markup['@id'], + 'seller' => array( + '@type' => 'Organization', + 'name' => $shop_name, + 'url' => $shop_url, + ), + ); + + $markup['offers'] = array( apply_filters( 'woocommerce_structured_data_product_offer', $markup_offer, $product ) ); + } + + if ( $product->get_review_count() && 'yes' === get_option( 'woocommerce_enable_review_rating' ) ) { + $markup['aggregateRating'] = array( + '@type' => 'AggregateRating', + 'ratingValue' => $product->get_average_rating(), + 'reviewCount' => $product->get_review_count(), + ); + } + + $this->set_data( apply_filters( 'woocommerce_structured_data_product', $markup, $product ) ); + } + + /** + * Generates Review structured data. + * + * Hooked into `woocommerce_review_meta` action hook. + * + * @param WP_Comment $comment Comment data. + */ + public function generate_review_data( $comment ) { + $markup = array(); + $markup['@type'] = 'Review'; + $markup['@id'] = get_comment_link( $comment->comment_ID ); + $markup['datePublished'] = get_comment_date( 'c', $comment->comment_ID ); + $markup['description'] = get_comment_text( $comment->comment_ID ); + $markup['itemReviewed'] = array( + '@type' => 'Product', + 'name' => get_the_title( $comment->comment_post_ID ), + ); + + // Skip replies unless they have a rating. + $rating = get_comment_meta( $comment->comment_ID, 'rating', true ); + + if ( $rating ) { + $markup['reviewRating'] = array( + '@type' => 'rating', + 'ratingValue' => $rating, + ); + } elseif ( $comment->comment_parent ) { + return; + } + + $markup['author'] = array( + '@type' => 'Person', + 'name' => get_comment_author( $comment->comment_ID ), + ); + + $this->set_data( apply_filters( 'woocommerce_structured_data_review', $markup, $comment ) ); + } + + /** + * Generates BreadcrumbList structured data. + * + * Hooked into `woocommerce_breadcrumb` action hook. + * + * @param WC_Breadcrumb $breadcrumbs Breadcrumb data. + */ + public function generate_breadcrumblist_data( $breadcrumbs ) { + $crumbs = $breadcrumbs->get_breadcrumb(); + + if ( empty( $crumbs ) || ! is_array( $crumbs ) ) { + return; + } + + $markup = array(); + $markup['@type'] = 'BreadcrumbList'; + $markup['itemListElement'] = array(); + + foreach ( $crumbs as $key => $crumb ) { + $markup['itemListElement'][ $key ] = array( + '@type' => 'ListItem', + 'position' => $key + 1, + 'item' => array( + 'name' => $crumb[0], + ), + ); + + if ( ! empty( $crumb[1] ) && count( $crumbs ) !== $key + 1 ) { + $markup['itemListElement'][ $key ]['item'] += array( '@id' => $crumb[1] ); + } + } + + $this->set_data( apply_filters( 'woocommerce_structured_data_breadcrumblist', $markup, $breadcrumbs ) ); + } + + /** + * Generates WebSite structured data. + * + * Hooked into `woocommerce_before_main_content` action hook. + */ + public function generate_website_data() { + $markup = array(); + $markup['@type'] = 'WebSite'; + $markup['name'] = get_bloginfo( 'name' ); + $markup['url'] = home_url(); + $markup['potentialAction'] = array( + '@type' => 'SearchAction', + 'target' => home_url( '?s={search_term_string}&post_type=product' ), + 'query-input' => 'required name=search_term_string', + ); + + $this->set_data( apply_filters( 'woocommerce_structured_data_website', $markup ) ); + } + + /** + * Generates Order structured data. + * + * Hooked into `woocommerce_email_order_details` action hook. + * + * @param WP_Order $order Order data. + * @param bool $sent_to_admin Send to admin (default: false). + * @param bool $plain_text Plain text email (default: false). + */ + public function generate_order_data( $order, $sent_to_admin = false, $plain_text = false ) { + if ( $plain_text || ! is_a( $order, 'WC_Order' ) ) { + return; + } + + $shop_name = get_bloginfo( 'name' ); + $shop_url = home_url(); + $order_url = $sent_to_admin ? $order->get_edit_order_url() : $order->get_view_order_url(); + $order_statuses = array( + 'pending' => 'https://schema.org/OrderPaymentDue', + 'processing' => 'https://schema.org/OrderProcessing', + 'on-hold' => 'https://schema.org/OrderProblem', + 'completed' => 'https://schema.org/OrderDelivered', + 'cancelled' => 'https://schema.org/OrderCancelled', + 'refunded' => 'https://schema.org/OrderReturned', + 'failed' => 'https://schema.org/OrderProblem', + ); + + $markup_offers = array(); + foreach ( $order->get_items() as $item ) { + if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { + continue; + } + + $product = $order->get_product_from_item( $item ); + $product_exists = is_object( $product ); + $is_visible = $product_exists && $product->is_visible(); + + $markup_offers[] = array( + '@type' => 'Offer', + 'price' => $order->get_line_subtotal( $item ), + 'priceCurrency' => $order->get_currency(), + 'priceSpecification' => array( + 'price' => $order->get_line_subtotal( $item ), + 'priceCurrency' => $order->get_currency(), + 'eligibleQuantity' => array( + '@type' => 'QuantitativeValue', + 'value' => apply_filters( 'woocommerce_email_order_item_quantity', $item['qty'], $item ), + ), + ), + 'itemOffered' => array( + '@type' => 'Product', + 'name' => apply_filters( 'woocommerce_order_item_name', $item['name'], $item, $is_visible ), + 'sku' => $product_exists ? $product->get_sku() : '', + 'image' => $product_exists ? wp_get_attachment_image_url( $product->get_image_id() ) : '', + 'url' => $is_visible ? get_permalink( $product->get_id() ) : get_home_url(), + ), + 'seller' => array( + '@type' => 'Organization', + 'name' => $shop_name, + 'url' => $shop_url, + ), + ); + } + + $markup = array(); + $markup['@type'] = 'Order'; + $markup['url'] = $order_url; + $markup['orderStatus'] = isset( $order_statuses[ $order->get_status() ] ) ? $order_statuses[ $order->get_status() ] : ''; + $markup['orderNumber'] = $order->get_order_number(); + $markup['orderDate'] = $order->get_date_created()->format( 'c' ); + $markup['acceptedOffer'] = $markup_offers; + $markup['discount'] = $order->get_total_discount(); + $markup['discountCurrency'] = $order->get_currency(); + $markup['price'] = $order->get_total(); + $markup['priceCurrency'] = $order->get_currency(); + $markup['priceSpecification'] = array( + 'price' => $order->get_total(), + 'priceCurrency' => $order->get_currency(), + 'valueAddedTaxIncluded' => 'true', + ); + $markup['billingAddress'] = array( + '@type' => 'PostalAddress', + 'name' => $order->get_formatted_billing_full_name(), + 'streetAddress' => $order->get_billing_address_1(), + 'postalCode' => $order->get_billing_postcode(), + 'addressLocality' => $order->get_billing_city(), + 'addressRegion' => $order->get_billing_state(), + 'addressCountry' => $order->get_billing_country(), + 'email' => $order->get_billing_email(), + 'telephone' => $order->get_billing_phone(), + ); + $markup['customer'] = array( + '@type' => 'Person', + 'name' => $order->get_formatted_billing_full_name(), + ); + $markup['merchant'] = array( + '@type' => 'Organization', + 'name' => $shop_name, + 'url' => $shop_url, + ); + $markup['potentialAction'] = array( + '@type' => 'ViewAction', + 'name' => 'View Order', + 'url' => $order_url, + 'target' => $order_url, + ); + + $this->set_data( apply_filters( 'woocommerce_structured_data_order', $markup, $sent_to_admin, $order ), true ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-tax.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-tax.php new file mode 100644 index 0000000..273e8ed --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-tax.php @@ -0,0 +1,1031 @@ +query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_class = %s;", $removed_tax_class ) ); + $wpdb->query( "DELETE locations FROM {$wpdb->prefix}woocommerce_tax_rate_locations locations LEFT JOIN {$wpdb->prefix}woocommerce_tax_rates rates ON rates.tax_rate_id = locations.tax_rate_id WHERE rates.tax_rate_id IS NULL;" ); + } + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + } + } + + /** + * Calculate tax for a line. + * + * @param float $price Price to calc tax on. + * @param array $rates Rates to apply. + * @param boolean $price_includes_tax Whether the passed price has taxes included. + * @param boolean $deprecated Whether to suppress any rounding from taking place. No longer used here. + * @return array Array of rates + prices after tax. + */ + public static function calc_tax( $price, $rates, $price_includes_tax = false, $deprecated = false ) { + if ( $price_includes_tax ) { + $taxes = self::calc_inclusive_tax( $price, $rates ); + } else { + $taxes = self::calc_exclusive_tax( $price, $rates ); + } + return apply_filters( 'woocommerce_calc_tax', $taxes, $price, $rates, $price_includes_tax, $deprecated ); + } + + /** + * Calculate the shipping tax using a passed array of rates. + * + * @param float Price + * @param array Taxation Rate + * @return array + */ + public static function calc_shipping_tax( $price, $rates ) { + $taxes = self::calc_exclusive_tax( $price, $rates ); + return apply_filters( 'woocommerce_calc_shipping_tax', $taxes, $price, $rates ); + } + + /** + * Round to precision. + * + * Filter example: to return rounding to .5 cents you'd use: + * + * function euro_5cent_rounding( $in ) { + * return round( $in / 5, 2 ) * 5; + * } + * add_filter( 'woocommerce_tax_round', 'euro_5cent_rounding' ); + * + * @param float|int $in + * + * @return float + */ + public static function round( $in ) { + return apply_filters( 'woocommerce_tax_round', round( $in, wc_get_rounding_precision() ), $in ); + } + + /** + * Calc tax from inclusive price. + * + * @param float $price Price to calculate tax for. + * @param array $rates Array of tax rates. + * @return array + */ + public static function calc_inclusive_tax( $price, $rates ) { + $taxes = array(); + $compound_rates = array(); + $regular_rates = array(); + + // Index array so taxes are output in correct order and see what compound/regular rates we have to calculate. + foreach ( $rates as $key => $rate ) { + $taxes[ $key ] = 0; + + if ( 'yes' === $rate['compound'] ) { + $compound_rates[ $key ] = $rate['rate']; + } else { + $regular_rates[ $key ] = $rate['rate']; + } + } + + $compound_rates = array_reverse( $compound_rates, true ); // Working backwards. + + $non_compound_price = $price; + + foreach ( $compound_rates as $key => $compound_rate ) { + $tax_amount = apply_filters( 'woocommerce_price_inc_tax_amount', $non_compound_price - ( $non_compound_price / ( 1 + ( $compound_rate / 100 ) ) ), $key, $rates[ $key ], $price ); + $taxes[ $key ] += $tax_amount; + $non_compound_price = $non_compound_price - $tax_amount; + } + + // Regular taxes. + $regular_tax_rate = 1 + ( array_sum( $regular_rates ) / 100 ); + + foreach ( $regular_rates as $key => $regular_rate ) { + $the_rate = ( $regular_rate / 100 ) / $regular_tax_rate; + $net_price = $price - ( $the_rate * $non_compound_price ); + $tax_amount = apply_filters( 'woocommerce_price_inc_tax_amount', $price - $net_price, $key, $rates[ $key ], $price ); + $taxes[ $key ] += $tax_amount; + } + + return $taxes; + } + + /** + * Calc tax from exclusive price. + * + * @param float $price Price to calculate tax for. + * @param array $rates Array of tax rates. + * @return array + */ + public static function calc_exclusive_tax( $price, $rates ) { + $taxes = array(); + + if ( ! empty( $rates ) ) { + foreach ( $rates as $key => $rate ) { + if ( 'yes' === $rate['compound'] ) { + continue; + } + + $tax_amount = $price * ( $rate['rate'] / 100 ); + $tax_amount = apply_filters( 'woocommerce_price_ex_tax_amount', $tax_amount, $key, $rate, $price ); // ADVANCED: Allow third parties to modify this rate. + + if ( ! isset( $taxes[ $key ] ) ) { + $taxes[ $key ] = $tax_amount; + } else { + $taxes[ $key ] += $tax_amount; + } + } + + $pre_compound_total = array_sum( $taxes ); + + // Compound taxes. + foreach ( $rates as $key => $rate ) { + if ( 'no' === $rate['compound'] ) { + continue; + } + $the_price_inc_tax = $price + ( $pre_compound_total ); + $tax_amount = $the_price_inc_tax * ( $rate['rate'] / 100 ); + $tax_amount = apply_filters( 'woocommerce_price_ex_tax_amount', $tax_amount, $key, $rate, $price, $the_price_inc_tax, $pre_compound_total ); // ADVANCED: Allow third parties to modify this rate. + + if ( ! isset( $taxes[ $key ] ) ) { + $taxes[ $key ] = $tax_amount; + } else { + $taxes[ $key ] += $tax_amount; + } + + $pre_compound_total = array_sum( $taxes ); + } + } + + return $taxes; + } + + /** + * Searches for all matching country/state/postcode tax rates. + * + * @param array $args + * @return array + */ + public static function find_rates( $args = array() ) { + $args = wp_parse_args( $args, array( + 'country' => '', + 'state' => '', + 'city' => '', + 'postcode' => '', + 'tax_class' => '', + ) ); + + extract( $args, EXTR_SKIP ); + + if ( ! $country ) { + return array(); + } + + $postcode = wc_normalize_postcode( wc_clean( $postcode ) ); + $cache_key = WC_Cache_Helper::get_cache_prefix( 'taxes' ) . 'wc_tax_rates_' . md5( sprintf( '%s+%s+%s+%s+%s', $country, $state, $city, $postcode, $tax_class ) ); + $matched_tax_rates = wp_cache_get( $cache_key, 'taxes' ); + + if ( false === $matched_tax_rates ) { + $matched_tax_rates = self::get_matched_tax_rates( $country, $state, $postcode, $city, $tax_class ); + wp_cache_set( $cache_key, $matched_tax_rates, 'taxes' ); + } + + return apply_filters( 'woocommerce_find_rates', $matched_tax_rates, $args ); + } + + /** + * Searches for all matching country/state/postcode tax rates. + * + * @param array $args + * @return array + */ + public static function find_shipping_rates( $args = array() ) { + $rates = self::find_rates( $args ); + $shipping_rates = array(); + + if ( is_array( $rates ) ) { + foreach ( $rates as $key => $rate ) { + if ( 'yes' === $rate['shipping'] ) { + $shipping_rates[ $key ] = $rate; + } + } + } + + return $shipping_rates; + } + + /** + * Does the sort comparison. Compares (in this order): + * - Priority + * - Country + * - State + * - Number of postcodes + * - Number of cities + * - ID + * + * @param object $rate1 First rate to compare. + * @param object $rate2 Second rate to compare. + * @return int + */ + private static function sort_rates_callback( $rate1, $rate2 ) { + if ( $rate1->tax_rate_priority !== $rate2->tax_rate_priority ) { + return $rate1->tax_rate_priority < $rate2->tax_rate_priority ? -1 : 1; // ASC + } + + if ( $rate1->tax_rate_country !== $rate2->tax_rate_country ) { + if ( '' === $rate1->tax_rate_country ) { + return 1; + } + if ( '' === $rate2->tax_rate_country ) { + return -1; + } + return strcmp( $rate1->tax_rate_country, $rate2->tax_rate_country ) > 0 ? 1 : -1; + } + + if ( $rate1->tax_rate_state !== $rate2->tax_rate_state ) { + if ( '' === $rate1->tax_rate_state ) { + return 1; + } + if ( '' === $rate2->tax_rate_state ) { + return -1; + } + return strcmp( $rate1->tax_rate_state, $rate2->tax_rate_state ) > 0 ? 1 : -1; + } + + if ( isset( $rate1->postcode_count, $rate2->postcode_count ) && $rate1->postcode_count !== $rate2->postcode_count ) { + return $rate1->postcode_count < $rate2->postcode_count ? 1 : -1; + } + + if ( isset( $rate1->city_count, $rate2->city_count ) && $rate1->city_count !== $rate2->city_count ) { + return $rate1->city_count < $rate2->city_count ? 1 : -1; + } + + return $rate1->tax_rate_id < $rate2->tax_rate_id ? -1 : 1; + } + + /** + * Logical sort order for tax rates based on the following in order of priority. + * + * @param array $rates Rates to be sorted. + * @return array + */ + private static function sort_rates( $rates ) { + uasort( $rates, __CLASS__ . '::sort_rates_callback' ); + $i = 0; + foreach ( $rates as $key => $rate ) { + $rates[ $key ]->tax_rate_order = $i++; + } + return $rates; + } + + /** + * Loop through a set of tax rates and get the matching rates (1 per priority). + * + * @param string $country Country code to match against. + * @param string $state State code to match against. + * @param string $postcode Postcode to match against. + * @param string $city City to match against. + * @param string $tax_class Tax class to match against. + * @return array + */ + private static function get_matched_tax_rates( $country, $state, $postcode, $city, $tax_class ) { + global $wpdb; + + // Query criteria - these will be ANDed. + $criteria = array(); + $criteria[] = $wpdb->prepare( "tax_rate_country IN ( %s, '' )", strtoupper( $country ) ); + $criteria[] = $wpdb->prepare( "tax_rate_state IN ( %s, '' )", strtoupper( $state ) ); + $criteria[] = $wpdb->prepare( 'tax_rate_class = %s', sanitize_title( $tax_class ) ); + + // Pre-query postcode ranges for PHP based matching. + $postcode_search = wc_get_wildcard_postcodes( $postcode, $country ); + $postcode_ranges = $wpdb->get_results( "SELECT tax_rate_id, location_code FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE location_type = 'postcode' AND location_code LIKE '%...%';" ); + + if ( $postcode_ranges ) { + $matches = wc_postcode_location_matcher( $postcode, $postcode_ranges, 'tax_rate_id', 'location_code', $country ); + if ( ! empty( $matches ) ) { + foreach ( $matches as $matched_postcodes ) { + $postcode_search = array_merge( $postcode_search, $matched_postcodes ); + } + } + } + + $postcode_search = array_unique( $postcode_search ); + + /** + * Location matching criteria - ORed + * Needs to match: + * - rates with no postcodes and cities + * - rates with a matching postcode and city + * - rates with matching postcode, no city + * - rates with matching city, no postcode + */ + $locations_criteria = array(); + $locations_criteria[] = 'locations.location_type IS NULL'; + $locations_criteria[] = " + locations.location_type = 'postcode' AND locations.location_code IN ('" . implode( "','", array_map( 'esc_sql', $postcode_search ) ) . "') + AND ( + ( locations2.location_type = 'city' AND locations2.location_code = '" . esc_sql( strtoupper( $city ) ) . "' ) + OR NOT EXISTS ( + SELECT sub.tax_rate_id FROM {$wpdb->prefix}woocommerce_tax_rate_locations as sub + WHERE sub.location_type = 'city' + AND sub.tax_rate_id = tax_rates.tax_rate_id + ) + ) + "; + $locations_criteria[] = " + locations.location_type = 'city' AND locations.location_code = '" . esc_sql( strtoupper( $city ) ) . "' + AND NOT EXISTS ( + SELECT sub.tax_rate_id FROM {$wpdb->prefix}woocommerce_tax_rate_locations as sub + WHERE sub.location_type = 'postcode' + AND sub.tax_rate_id = tax_rates.tax_rate_id + ) + "; + $criteria[] = '( ( ' . implode( ' ) OR ( ', $locations_criteria ) . ' ) )'; + + $found_rates = $wpdb->get_results( " + SELECT tax_rates.*, COUNT( locations.location_id ) as postcode_count, COUNT( locations2.location_id ) as city_count + FROM {$wpdb->prefix}woocommerce_tax_rates as tax_rates + LEFT OUTER JOIN {$wpdb->prefix}woocommerce_tax_rate_locations as locations ON tax_rates.tax_rate_id = locations.tax_rate_id + LEFT OUTER JOIN {$wpdb->prefix}woocommerce_tax_rate_locations as locations2 ON tax_rates.tax_rate_id = locations2.tax_rate_id + WHERE 1=1 AND " . implode( ' AND ', $criteria ) . " + GROUP BY tax_rates.tax_rate_id + ORDER BY tax_rates.tax_rate_priority + " ); + + $found_rates = self::sort_rates( $found_rates ); + $matched_tax_rates = array(); + $found_priority = array(); + + foreach ( $found_rates as $found_rate ) { + if ( in_array( $found_rate->tax_rate_priority, $found_priority, true ) ) { + continue; + } + + $matched_tax_rates[ $found_rate->tax_rate_id ] = array( + 'rate' => $found_rate->tax_rate, + 'label' => $found_rate->tax_rate_name, + 'shipping' => $found_rate->tax_rate_shipping ? 'yes' : 'no', + 'compound' => $found_rate->tax_rate_compound ? 'yes' : 'no', + ); + + $found_priority[] = $found_rate->tax_rate_priority; + } + + return apply_filters( 'woocommerce_matched_tax_rates', $matched_tax_rates, $country, $state, $postcode, $city, $tax_class ); + } + + /** + * Get the customer tax location based on their status and the current page. + * + * Used by get_rates(), get_shipping_rates(). + * + * @param $tax_class string Optional, passed to the filter for advanced tax setups. + * @param object $customer Override the customer object to get their location. + * @return array + */ + public static function get_tax_location( $tax_class = '', $customer = null ) { + $location = array(); + + if ( is_null( $customer ) && ! empty( WC()->customer ) ) { + $customer = WC()->customer; + } + + if ( ! empty( $customer ) ) { + $location = $customer->get_taxable_address(); + } elseif ( wc_prices_include_tax() || 'base' === get_option( 'woocommerce_default_customer_address' ) || 'base' === get_option( 'woocommerce_tax_based_on' ) ) { + $location = array( + WC()->countries->get_base_country(), + WC()->countries->get_base_state(), + WC()->countries->get_base_postcode(), + WC()->countries->get_base_city(), + ); + } + + return apply_filters( 'woocommerce_get_tax_location', $location, $tax_class, $customer ); + } + + /** + * Get's an array of matching rates for a tax class. + * + * @param string $tax_class Tax class to get rates for. + * @param object $customer Override the customer object to get their location. + * @return array + */ + public static function get_rates( $tax_class = '', $customer = null ) { + $tax_class = sanitize_title( $tax_class ); + $location = self::get_tax_location( $tax_class, $customer ); + $matched_tax_rates = array(); + + if ( sizeof( $location ) === 4 ) { + list( $country, $state, $postcode, $city ) = $location; + + $matched_tax_rates = self::find_rates( array( + 'country' => $country, + 'state' => $state, + 'postcode' => $postcode, + 'city' => $city, + 'tax_class' => $tax_class, + ) ); + } + + return apply_filters( 'woocommerce_matched_rates', $matched_tax_rates, $tax_class ); + } + + /** + * Get's an array of matching rates for the shop's base country. + * + * @param string Tax Class + * @return array + */ + public static function get_base_tax_rates( $tax_class = '' ) { + return apply_filters( 'woocommerce_base_tax_rates', self::find_rates( array( + 'country' => WC()->countries->get_base_country(), + 'state' => WC()->countries->get_base_state(), + 'postcode' => WC()->countries->get_base_postcode(), + 'city' => WC()->countries->get_base_city(), + 'tax_class' => $tax_class, + ) ), $tax_class ); + } + + /** + * Alias for get_base_tax_rates(). + * + * @deprecated 2.3 + * @param string Tax Class + * @return array + */ + public static function get_shop_base_rate( $tax_class = '' ) { + return self::get_base_tax_rates( $tax_class ); + } + + /** + * Gets an array of matching shipping tax rates for a given class. + * + * @param string $tax_class Tax class to get rates for. + * @param object $customer Override the customer object to get their location. + * @return mixed + */ + public static function get_shipping_tax_rates( $tax_class = null, $customer = null ) { + // See if we have an explicitly set shipping tax class + $shipping_tax_class = get_option( 'woocommerce_shipping_tax_class' ); + + if ( 'inherit' !== $shipping_tax_class ) { + $tax_class = $shipping_tax_class; + } + + $location = self::get_tax_location( $tax_class, $customer ); + $matched_tax_rates = array(); + + if ( sizeof( $location ) === 4 ) { + list( $country, $state, $postcode, $city ) = $location; + + if ( ! is_null( $tax_class ) ) { + // This will be per item shipping + $matched_tax_rates = self::find_shipping_rates( array( + 'country' => $country, + 'state' => $state, + 'postcode' => $postcode, + 'city' => $city, + 'tax_class' => $tax_class, + ) ); + + } elseif ( WC()->cart->get_cart() ) { + + // This will be per order shipping - loop through the order and find the highest tax class rate + $cart_tax_classes = WC()->cart->get_cart_item_tax_classes_for_shipping(); + + // No tax classes = no taxable items. + if ( empty( $cart_tax_classes ) ) { + return array(); + } + + // If multiple classes are found, use the first one found unless a standard rate item is found. This will be the first listed in the 'additional tax class' section. + if ( sizeof( $cart_tax_classes ) > 1 && ! in_array( '', $cart_tax_classes ) ) { + $tax_classes = self::get_tax_class_slugs(); + + foreach ( $tax_classes as $tax_class ) { + if ( in_array( $tax_class, $cart_tax_classes ) ) { + $matched_tax_rates = self::find_shipping_rates( array( + 'country' => $country, + 'state' => $state, + 'postcode' => $postcode, + 'city' => $city, + 'tax_class' => $tax_class, + ) ); + break; + } + } + + // If a single tax class is found, use it + } elseif ( sizeof( $cart_tax_classes ) == 1 ) { + $matched_tax_rates = self::find_shipping_rates( array( + 'country' => $country, + 'state' => $state, + 'postcode' => $postcode, + 'city' => $city, + 'tax_class' => $cart_tax_classes[0], + ) ); + } + } + + // Get standard rate if no taxes were found + if ( ! sizeof( $matched_tax_rates ) ) { + $matched_tax_rates = self::find_shipping_rates( array( + 'country' => $country, + 'state' => $state, + 'postcode' => $postcode, + 'city' => $city, + ) ); + } + } + + return $matched_tax_rates; + } + + /** + * Return true/false depending on if a rate is a compound rate. + * + * @param mixed $key_or_rate Tax rate ID, or the db row itself in object format + * @return bool + */ + public static function is_compound( $key_or_rate ) { + global $wpdb; + + if ( is_object( $key_or_rate ) ) { + $key = $key_or_rate->tax_rate_id; + $compound = $key_or_rate->tax_rate_compound; + } else { + $key = $key_or_rate; + $compound = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ); + } + + return (bool) apply_filters( 'woocommerce_rate_compound', $compound, $key ); + } + + /** + * Return a given rates label. + * + * @param mixed $key_or_rate Tax rate ID, or the db row itself in object format + * @return string + */ + public static function get_rate_label( $key_or_rate ) { + global $wpdb; + + if ( is_object( $key_or_rate ) ) { + $key = $key_or_rate->tax_rate_id; + $rate_name = $key_or_rate->tax_rate_name; + } else { + $key = $key_or_rate; + $rate_name = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate_name FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ); + } + + if ( ! $rate_name ) { + $rate_name = WC()->countries->tax_or_vat(); + } + + return apply_filters( 'woocommerce_rate_label', $rate_name, $key ); + } + + /** + * Return a given rates percent. + * + * @param mixed $key_or_rate Tax rate ID, or the db row itself in object format + * @return string + */ + public static function get_rate_percent( $key_or_rate ) { + global $wpdb; + + if ( is_object( $key_or_rate ) ) { + $key = $key_or_rate->tax_rate_id; + $tax_rate = $key_or_rate->tax_rate; + } else { + $key = $key_or_rate; + $tax_rate = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ); + } + + return apply_filters( 'woocommerce_rate_percent', floatval( $tax_rate ) . '%', $key ); + } + + /** + * Get a rates code. Code is made up of COUNTRY-STATE-NAME-Priority. E.g GB-VAT-1, US-AL-TAX-1. + * + * @access public + * @param mixed $key_or_rate Tax rate ID, or the db row itself in object format + * @return string + */ + public static function get_rate_code( $key_or_rate ) { + global $wpdb; + + if ( is_object( $key_or_rate ) ) { + $key = $key_or_rate->tax_rate_id; + $rate = $key_or_rate; + } else { + $key = $key_or_rate; + $rate = $wpdb->get_row( $wpdb->prepare( "SELECT tax_rate_country, tax_rate_state, tax_rate_name, tax_rate_priority FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) ); + } + + $code_string = ''; + + if ( null !== $rate ) { + $code = array(); + $code[] = $rate->tax_rate_country; + $code[] = $rate->tax_rate_state; + $code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX'; + $code[] = absint( $rate->tax_rate_priority ); + $code_string = strtoupper( implode( '-', array_filter( $code ) ) ); + } + + return apply_filters( 'woocommerce_rate_code', $code_string, $key ); + } + + /** + * Round tax lines and return the sum. + * + * @param array + * @return float + */ + public static function get_tax_total( $taxes ) { + return array_sum( array_map( array( __CLASS__, 'round' ), $taxes ) ); + } + + /** + * Get store tax classes. + * + * @return array Array of class names ("Reduced rate", "Zero rate", etc). + */ + public static function get_tax_classes() { + return array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ), array( __CLASS__, 'is_valid_tax_class' ) ); + } + + /** + * Filter out invalid tax classes. + * + * @param string $tax_class Tax class name. + * @return boolean + */ + private static function is_valid_tax_class( $tax_class ) { + return ! empty( $tax_class ) && sanitize_title( $tax_class ); + } + + /** + * Get store tax classes as slugs. + * + * @since 3.0.0 + * @return array Array of class slugs ("reduced-rate", "zero-rate", etc). + */ + public static function get_tax_class_slugs() { + return array_filter( array_map( 'sanitize_title', self::get_tax_classes() ) ); + } + + /** + * format the city. + * @param string $city + * @return string + */ + private static function format_tax_rate_city( $city ) { + return strtoupper( trim( $city ) ); + } + + /** + * format the state. + * @param string $state + * @return string + */ + private static function format_tax_rate_state( $state ) { + $state = strtoupper( $state ); + return ( '*' === $state ) ? '' : $state; + } + + /** + * format the country. + * @param string $country + * @return string + */ + private static function format_tax_rate_country( $country ) { + $country = strtoupper( $country ); + return ( '*' === $country ) ? '' : $country; + } + + /** + * format the tax rate name. + * @param string $name + * @return string + */ + private static function format_tax_rate_name( $name ) { + return $name ? $name : __( 'Tax', 'woocommerce' ); + } + + /** + * format the rate. + * @param double $rate + * @return string + */ + private static function format_tax_rate( $rate ) { + return number_format( (double) $rate, 4, '.', '' ); + } + + /** + * format the priority. + * @param string $priority + * @return int + */ + private static function format_tax_rate_priority( $priority ) { + return absint( $priority ); + } + + /** + * format the class. + * @param string $class + * @return string + */ + public static function format_tax_rate_class( $class ) { + $class = sanitize_title( $class ); + $classes = self::get_tax_class_slugs(); + if ( ! in_array( $class, $classes ) ) { + $class = ''; + } + return ( 'standard' === $class ) ? '' : $class; + } + + /** + * Prepare and format tax rate for DB insertion. + * @param array $tax_rate + * @return array + */ + private static function prepare_tax_rate( $tax_rate ) { + foreach ( $tax_rate as $key => $value ) { + if ( method_exists( __CLASS__, 'format_' . $key ) ) { + if ( 'tax_rate_state' === $key ) { + $tax_rate[ $key ] = call_user_func( array( __CLASS__, 'format_' . $key ), sanitize_key( $value ) ); + } else { + $tax_rate[ $key ] = call_user_func( array( __CLASS__, 'format_' . $key ), $value ); + } + } + } + return $tax_rate; + } + + /** + * Insert a new tax rate. + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param array $tax_rate + * + * @return int tax rate id + */ + public static function _insert_tax_rate( $tax_rate ) { + global $wpdb; + + $wpdb->insert( $wpdb->prefix . 'woocommerce_tax_rates', self::prepare_tax_rate( $tax_rate ) ); + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + + do_action( 'woocommerce_tax_rate_added', $wpdb->insert_id, $tax_rate ); + + return $wpdb->insert_id; + } + + /** + * Get tax rate. + * + * Internal use only. + * + * @since 2.5.0 + * @access private + * + * @param int $tax_rate_id + * @param string $output_type + * + * @return array|object + */ + public static function _get_tax_rate( $tax_rate_id, $output_type = ARRAY_A ) { + global $wpdb; + + return $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$wpdb->prefix}woocommerce_tax_rates + WHERE tax_rate_id = %d + ", $tax_rate_id ), $output_type ); + } + + /** + * Update a tax rate. + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param int $tax_rate_id + * @param array $tax_rate + */ + public static function _update_tax_rate( $tax_rate_id, $tax_rate ) { + global $wpdb; + + $tax_rate_id = absint( $tax_rate_id ); + + $wpdb->update( + $wpdb->prefix . "woocommerce_tax_rates", + self::prepare_tax_rate( $tax_rate ), + array( + 'tax_rate_id' => $tax_rate_id, + ) + ); + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + + do_action( 'woocommerce_tax_rate_updated', $tax_rate_id, $tax_rate ); + } + + /** + * Delete a tax rate from the database. + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param int $tax_rate_id + */ + public static function _delete_tax_rate( $tax_rate_id ) { + global $wpdb; + + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) ); + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) ); + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + + do_action( 'woocommerce_tax_rate_deleted', $tax_rate_id ); + } + + /** + * Update postcodes for a tax rate in the DB. + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param int $tax_rate_id + * @param string $postcodes String of postcodes separated by ; characters + */ + public static function _update_tax_rate_postcodes( $tax_rate_id, $postcodes ) { + if ( ! is_array( $postcodes ) ) { + $postcodes = explode( ';', $postcodes ); + } + // No normalization - postcodes are matched against both normal and formatted versions to support wildcards. + foreach ( $postcodes as $key => $postcode ) { + $postcodes[ $key ] = strtoupper( trim( str_replace( chr( 226 ) . chr( 128 ) . chr( 166 ), '...', $postcode ) ) ); + } + self::_update_tax_rate_locations( $tax_rate_id, array_diff( array_filter( $postcodes ), array( '*' ) ), 'postcode' ); + } + + /** + * Update cities for a tax rate in the DB. + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param int $tax_rate_id + * @param string $cities + */ + public static function _update_tax_rate_cities( $tax_rate_id, $cities ) { + if ( ! is_array( $cities ) ) { + $cities = explode( ';', $cities ); + } + $cities = array_filter( array_diff( array_map( array( __CLASS__, 'format_tax_rate_city' ), $cities ), array( '*' ) ) ); + + self::_update_tax_rate_locations( $tax_rate_id, $cities, 'city' ); + } + + /** + * Updates locations (postcode and city). + * + * Internal use only. + * + * @since 2.3.0 + * @access private + * + * @param int $tax_rate_id + * @param array $values + * @param string $type + */ + private static function _update_tax_rate_locations( $tax_rate_id, $values, $type ) { + global $wpdb; + + $tax_rate_id = absint( $tax_rate_id ); + + $wpdb->query( + $wpdb->prepare( " + DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d AND location_type = %s; + ", $tax_rate_id, $type + ) + ); + + if ( sizeof( $values ) > 0 ) { + $sql = "( '" . implode( "', $tax_rate_id, '" . esc_sql( $type ) . "' ),( '", array_map( 'esc_sql', $values ) ) . "', $tax_rate_id, '" . esc_sql( $type ) . "' )"; + + $wpdb->query( " + INSERT INTO {$wpdb->prefix}woocommerce_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES $sql; + " ); + } + + WC_Cache_Helper::incr_cache_prefix( 'taxes' ); + } + + /** + * Used by admin settings page. + * + * @param string $tax_class + * + * @return array|null|object + */ + public static function get_rates_for_tax_class( $tax_class ) { + global $wpdb; + + // Get all the rates and locations. Snagging all at once should significantly cut down on the number of queries. + $rates = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}woocommerce_tax_rates` WHERE `tax_rate_class` = %s;", sanitize_title( $tax_class ) ) ); + $locations = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}woocommerce_tax_rate_locations`" ); + + if ( ! empty( $rates ) ) { + // Set the rates keys equal to their ids. + $rates = array_combine( wp_list_pluck( $rates, 'tax_rate_id' ), $rates ); + } + + // Drop the locations into the rates array. + foreach ( $locations as $location ) { + // Don't set them for unexistent rates. + if ( ! isset( $rates[ $location->tax_rate_id ] ) ) { + continue; + } + // If the rate exists, initialize the array before appending to it. + if ( ! isset( $rates[ $location->tax_rate_id ]->{$location->location_type} ) ) { + $rates[ $location->tax_rate_id ]->{$location->location_type} = array(); + } + $rates[ $location->tax_rate_id ]->{$location->location_type}[] = $location->location_code; + } + + foreach ( $rates as $rate_id => $rate ) { + $rates[ $rate_id ]->postcode_count = isset( $rates[ $rate_id ]->postcode ) ? count( $rates[ $rate_id ]->postcode ) : 0; + $rates[ $rate_id ]->city_count = isset( $rates[ $rate_id ]->city ) ? count( $rates[ $rate_id ]->city ) : 0; + } + + $rates = self::sort_rates( $rates ); + + return $rates; + } +} +WC_Tax::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-template-loader.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-template-loader.php new file mode 100644 index 0000000..67243f5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-template-loader.php @@ -0,0 +1,542 @@ +plugin_path() . '/templates/' . $default_file; + } + } + + return $template; + } + + /** + * Get the default filename for a template. + * + * @since 3.0.0 + * @return string + */ + private static function get_template_loader_default_file() { + if ( is_singular( 'product' ) ) { + $default_file = 'single-product.php'; + } elseif ( is_product_taxonomy() ) { + $object = get_queried_object(); + + if ( is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) { + $default_file = 'taxonomy-' . $object->taxonomy . '.php'; + } else { + $default_file = 'archive-product.php'; + } + } elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) { + $default_file = self::$theme_support ? 'archive-product.php' : ''; + } else { + $default_file = ''; + } + return $default_file; + } + + /** + * Get an array of filenames to search for a given template. + * + * @since 3.0.0 + * @param string $default_file The default file name. + * @return string[] + */ + private static function get_template_loader_files( $default_file ) { + $templates = apply_filters( 'woocommerce_template_loader_files', array(), $default_file ); + $templates[] = 'woocommerce.php'; + + if ( is_page_template() ) { + $templates[] = get_page_template_slug(); + } + + if ( is_singular( 'product' ) ) { + $object = get_queried_object(); + $name_decoded = urldecode( $object->post_name ); + if ( $name_decoded !== $object->post_name ) { + $templates[] = "single-product-{$name_decoded}.php"; + } + $templates[] = "single-product-{$object->post_name}.php"; + } + + if ( is_product_taxonomy() ) { + $object = get_queried_object(); + $templates[] = 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php'; + $templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '-' . $object->slug . '.php'; + $templates[] = 'taxonomy-' . $object->taxonomy . '.php'; + $templates[] = WC()->template_path() . 'taxonomy-' . $object->taxonomy . '.php'; + } + + $templates[] = $default_file; + $templates[] = WC()->template_path() . $default_file; + + return array_unique( $templates ); + } + + /** + * Load comments template. + * + * @param string $template template to load. + * @return string + */ + public static function comments_template_loader( $template ) { + if ( get_post_type() !== 'product' ) { + return $template; + } + + $check_dirs = array( + trailingslashit( get_stylesheet_directory() ) . WC()->template_path(), + trailingslashit( get_template_directory() ) . WC()->template_path(), + trailingslashit( get_stylesheet_directory() ), + trailingslashit( get_template_directory() ), + trailingslashit( WC()->plugin_path() ) . 'templates/', + ); + + if ( WC_TEMPLATE_DEBUG_MODE ) { + $check_dirs = array( array_pop( $check_dirs ) ); + } + + foreach ( $check_dirs as $dir ) { + if ( file_exists( trailingslashit( $dir ) . 'single-product-reviews.php' ) ) { + return trailingslashit( $dir ) . 'single-product-reviews.php'; + } + } + } + + /** + * Unsupported theme compatibility methods. + */ + + /** + * Hook in methods to enhance the unsupported theme experience on pages. + * + * @since 3.3.0 + */ + public static function unsupported_theme_init() { + if ( 0 < self::$shop_page_id ) { + if ( is_product_taxonomy() ) { + self::unsupported_theme_tax_archive_init(); + } elseif ( is_product() ) { + self::unsupported_theme_product_page_init(); + } else { + self::unsupported_theme_shop_page_init(); + } + } + } + + /** + * Hook in methods to enhance the unsupported theme experience on the Shop page. + * + * @since 3.3.0 + */ + private static function unsupported_theme_shop_page_init() { + add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ), 10 ); + add_filter( 'the_title', array( __CLASS__, 'unsupported_theme_title_filter' ), 10, 2 ); + add_filter( 'comments_number', '__return_empty_string' ); + } + + /** + * Hook in methods to enhance the unsupported theme experience on Product pages. + * + * @since 3.3.0 + */ + private static function unsupported_theme_product_page_init() { + add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_product_content_filter' ), 10 ); + add_filter( 'post_thumbnail_html', array( __CLASS__, 'unsupported_theme_single_featured_image_filter' ) ); + add_filter( 'woocommerce_product_tabs', array( __CLASS__, 'unsupported_theme_remove_review_tab' ) ); + remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); + remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); + add_theme_support( 'wc-product-gallery-zoom' ); + add_theme_support( 'wc-product-gallery-lightbox' ); + add_theme_support( 'wc-product-gallery-slider' ); + } + + /** + * Enhance the unsupported theme experience on Product Category and Attribute pages by rendering + * those pages using the single template and shortcode-based content. To do this we make a dummy + * post and set a shortcode as the post content. This approach is adapted from bbPress. + * + * @since 3.3.0 + */ + private static function unsupported_theme_tax_archive_init() { + global $wp_query, $post; + + $queried_object = get_queried_object(); + $args = self::get_current_shop_view_args(); + $shortcode_args = array( + 'page' => $args->page, + 'columns' => $args->columns, + 'rows' => $args->rows, + 'orderby' => '', + 'order' => '', + 'paginate' => true, + 'cache' => false, + ); + + if ( is_product_category() ) { + $shortcode_args['category'] = sanitize_title( $queried_object->slug ); + } elseif ( taxonomy_is_product_attribute( $queried_object->taxonomy ) ) { + $shortcode_args['attribute'] = sanitize_title( $queried_object->taxonomy ); + $shortcode_args['terms'] = sanitize_title( $queried_object->slug ); + } elseif ( is_product_tag() ) { + $shortcode_args['tag'] = sanitize_title( $queried_object->slug ); + } else { + // Default theme archive for all other taxonomies. + return; + } + + // Description handling. + if ( ! empty( $queried_object->description ) && ( empty( $_GET['product-page'] ) || 1 === absint( $_GET['product-page'] ) ) ) { // WPCS: input var ok, CSRF ok. + $prefix = '
      ' . wc_format_content( $queried_object->description ) . '
      '; // WPCS: XSS ok. + } else { + $prefix = ''; + } + + add_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) ); + $shortcode = new WC_Shortcode_Products( $shortcode_args ); + remove_filter( 'woocommerce_shortcode_products_query', array( __CLASS__, 'unsupported_archive_layered_nav_compatibility' ) ); + $shop_page = get_post( self::$shop_page_id ); + + $dummy_post_properties = array( + 'ID' => 0, + 'post_status' => 'publish', + 'post_author' => $shop_page->post_author, + 'post_parent' => 0, + 'post_type' => 'page', + 'post_date' => $shop_page->post_date, + 'post_date_gmt' => $shop_page->post_date_gmt, + 'post_modified' => $shop_page->post_modified, + 'post_modified_gmt' => $shop_page->post_modified_gmt, + 'post_content' => $prefix . $shortcode->get_content(), + 'post_title' => wc_clean( $queried_object->name ), + 'post_excerpt' => '', + 'post_content_filtered' => '', + 'post_mime_type' => '', + 'post_password' => '', + 'post_name' => $queried_object->slug, + 'guid' => '', + 'menu_order' => 0, + 'pinged' => '', + 'to_ping' => '', + 'ping_status' => '', + 'comment_status' => 'closed', + 'comment_count' => 0, + 'filter' => 'raw', + ); + + // Set the $post global. + $post = new WP_Post( (object) $dummy_post_properties ); // @codingStandardsIgnoreLine. + + // Copy the new post global into the main $wp_query. + $wp_query->post = $post; + $wp_query->posts = array( $post ); + + // Prevent comments form from appearing. + $wp_query->post_count = 1; + $wp_query->is_404 = false; + $wp_query->is_page = true; + $wp_query->is_single = true; + $wp_query->is_archive = false; + $wp_query->is_tax = true; + $wp_query->max_num_pages = 0; + + // Prepare everything for rendering. + setup_postdata( $post ); + remove_all_filters( 'the_content' ); + remove_all_filters( 'the_excerpt' ); + add_filter( 'template_include', array( __CLASS__, 'force_single_template_filter' ) ); + } + + /** + * Add layered nav args to WP_Query args generated by the 'products' shortcode. + * + * @since 3.3.4 + * @param array $query WP_Query args. + * @return array + */ + public static function unsupported_archive_layered_nav_compatibility( $query ) { + foreach ( WC()->query->get_layered_nav_chosen_attributes() as $taxonomy => $data ) { + $query['tax_query'][] = array( + 'taxonomy' => $taxonomy, + 'field' => 'slug', + 'terms' => $data['terms'], + 'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN', + 'include_children' => false, + ); + } + return $query; + } + + /** + * Force the loading of one of the single templates instead of whatever template was about to be loaded. + * + * @since 3.3.0 + * @param string $template Path to template. + * @return string + */ + public static function force_single_template_filter( $template ) { + $possible_templates = array( + 'page', + 'single', + 'singular', + 'index', + ); + + foreach ( $possible_templates as $possible_template ) { + $path = get_query_template( $possible_template ); + if ( $path ) { + return $path; + } + } + + return $template; + } + + /** + * Get information about the current shop page view. + * + * @since 3.3.0 + * @return array + */ + private static function get_current_shop_view_args() { + return (object) array( + 'page' => absint( max( 1, absint( get_query_var( 'paged' ) ) ) ), + 'columns' => wc_get_default_products_per_row(), + 'rows' => wc_get_default_product_rows_per_page(), + ); + } + + /** + * Filter the title and insert WooCommerce content on the shop page. + * + * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. + * + * @since 3.3.0 + * @param string $title Existing title. + * @param int $id ID of the post being filtered. + * @return string + */ + public static function unsupported_theme_title_filter( $title, $id ) { + if ( self::$theme_support || ! $id !== self::$shop_page_id ) { + return $title; + } + + if ( is_page( self::$shop_page_id ) || ( is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === self::$shop_page_id ) ) { + $args = self::get_current_shop_view_args(); + $title_suffix = array(); + + if ( $args->page > 1 ) { + /* translators: %d: Page number. */ + $title_suffix[] = sprintf( esc_html__( 'Page %d', 'woocommerce' ), $args->page ); + } + + if ( $title_suffix ) { + $title = $title . ' – ' . implode( ', ', $title_suffix ); + } + } + return $title; + } + + /** + * Filter the content and insert WooCommerce content on the shop page. + * + * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. + * + * @since 3.3.0 + * @param string $content Existing post content. + * @return string + */ + public static function unsupported_theme_shop_content_filter( $content ) { + global $wp_query; + + if ( self::$theme_support || ! is_main_query() || ! in_the_loop() ) { + return $content; + } + + self::$in_content_filter = true; + + // Remove the filter we're in to avoid nested calls. + remove_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ) ); + + // Unsupported theme shop page. + if ( is_page( self::$shop_page_id ) ) { + $args = self::get_current_shop_view_args(); + $shortcode = new WC_Shortcode_Products( + array_merge( + wc()->query->get_catalog_ordering_args(), + array( + 'page' => $args->page, + 'columns' => $args->columns, + 'rows' => $args->rows, + 'orderby' => '', + 'order' => '', + 'paginate' => true, + 'cache' => false, + ) + ), + 'products' ); + + // Allow queries to run e.g. layered nav. + add_action( 'pre_get_posts', array( wc()->query, 'product_query' ) ); + + $content = $content . $shortcode->get_content(); + + // Remove actions and self to avoid nested calls. + remove_action( 'pre_get_posts', array( wc()->query, 'product_query' ) ); + WC()->query->remove_ordering_args(); + } + + self::$in_content_filter = false; + + return $content; + } + + /** + * Filter the content and insert WooCommerce content on the shop page. + * + * For non-WC themes, this will setup the main shop page to be shortcode based to improve default appearance. + * + * @since 3.3.0 + * @param string $content Existing post content. + * @return string + */ + public static function unsupported_theme_product_content_filter( $content ) { + global $wp_query; + + if ( self::$theme_support || ! is_main_query() || ! in_the_loop() ) { + return $content; + } + + self::$in_content_filter = true; + + // Remove the filter we're in to avoid nested calls. + remove_filter( 'the_content', array( __CLASS__, 'unsupported_theme_product_content_filter' ) ); + + if ( is_product() ) { + $content = do_shortcode( '[product_page id="' . get_the_ID() . '" show_title=0]' ); + } + + self::$in_content_filter = false; + + return $content; + } + + /** + * Are we filtering content for unsupported themes? + * + * @since 3.3.2 + * @return bool + */ + public static function in_content_filter() { + return (bool) self::$in_content_filter; + } + + /** + * Prevent the main featured image on product pages because there will be another featured image + * in the gallery. + * + * @since 3.3.0 + * @param string $html Img element HTML. + * @return string + */ + public static function unsupported_theme_single_featured_image_filter( $html ) { + if ( self::in_content_filter() || ! is_product() || ! is_main_query() ) { + return $html; + } + + return ''; + } + + /** + * Remove the Review tab and just use the regular comment form. + * + * @param array $tabs Tab info. + * @return array + */ + public static function unsupported_theme_remove_review_tab( $tabs ) { + unset( $tabs['reviews'] ); + return $tabs; + } +} + +add_action( 'init', array( 'WC_Template_Loader', 'init' ) ); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-tracker.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-tracker.php new file mode 100644 index 0000000..bd34004 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-tracker.php @@ -0,0 +1,514 @@ + apply_filters( 'woocommerce_tracker_last_send_interval', strtotime( '-1 week' ) ) ) { + return; + } + } else { + // Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links. + $last_send = self::get_last_send_time(); + if ( $last_send && $last_send > strtotime( '-1 hours' ) ) { + return; + } + } + + // Update time first before sending to ensure it is set. + update_option( 'woocommerce_tracker_last_send', time() ); + + $params = self::get_tracking_data(); + wp_safe_remote_post( self::$api_url, array( + 'method' => 'POST', + 'timeout' => 45, + 'redirection' => 5, + 'httpversion' => '1.0', + 'blocking' => false, + 'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ), + 'body' => wp_json_encode( $params ), + 'cookies' => array(), + ) ); + } + + /** + * Get the last time tracking data was sent. + * + * @return int|bool + */ + private static function get_last_send_time() { + return apply_filters( 'woocommerce_tracker_last_send_time', get_option( 'woocommerce_tracker_last_send', false ) ); + } + + /** + * Get all the tracking data. + * + * @return array + */ + private static function get_tracking_data() { + $data = array(); + + // General site info. + $data['url'] = home_url(); + $data['email'] = apply_filters( 'woocommerce_tracker_admin_email', get_option( 'admin_email' ) ); + $data['theme'] = self::get_theme_info(); + + // WordPress Info. + $data['wp'] = self::get_wordpress_info(); + + // Server Info. + $data['server'] = self::get_server_info(); + + // Plugin info. + $all_plugins = self::get_all_plugins(); + $data['active_plugins'] = $all_plugins['active_plugins']; + $data['inactive_plugins'] = $all_plugins['inactive_plugins']; + + // Jetpack & WooCommerce Connect. + $data['jetpack_version'] = defined( 'JETPACK__VERSION' ) ? JETPACK__VERSION : 'none'; + $data['jetpack_connected'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_active' ) && Jetpack::is_active() ) ? 'yes' : 'no'; + $data['jetpack_is_staging'] = ( class_exists( 'Jetpack' ) && is_callable( 'Jetpack::is_staging_site' ) && Jetpack::is_staging_site() ) ? 'yes' : 'no'; + $data['connect_installed'] = class_exists( 'WC_Connect_Loader' ) ? 'yes' : 'no'; + $data['connect_active'] = ( class_exists( 'WC_Connect_Loader' ) && wp_next_scheduled( 'wc_connect_fetch_service_schemas' ) ) ? 'yes' : 'no'; + + // Store count info. + $data['users'] = self::get_user_counts(); + $data['products'] = self::get_product_counts(); + $data['orders'] = self::get_orders(); + + // Payment gateway info. + $data['gateways'] = self::get_active_payment_gateways(); + + // Shipping method info. + $data['shipping_methods'] = self::get_active_shipping_methods(); + + // Get all WooCommerce options info. + $data['settings'] = self::get_all_woocommerce_options_values(); + + // Template overrides. + $data['template_overrides'] = self::get_all_template_overrides(); + + // Template overrides. + $data['admin_user_agents'] = self::get_admin_user_agents(); + + return apply_filters( 'woocommerce_tracker_data', $data ); + } + + /** + * Get the current theme info, theme name and version. + * + * @return array + */ + public static function get_theme_info() { + $theme_data = wp_get_theme(); + $theme_child_theme = wc_bool_to_string( is_child_theme() ); + $theme_wc_support = wc_bool_to_string( current_theme_supports( 'woocommerce' ) ); + + return array( + 'name' => $theme_data->Name, // @phpcs:ignore + 'version' => $theme_data->Version, // @phpcs:ignore + 'child_theme' => $theme_child_theme, + 'wc_support' => $theme_wc_support, + ); + } + + /** + * Get WordPress related data. + * + * @return array + */ + private static function get_wordpress_info() { + $wp_data = array(); + + $memory = wc_let_to_num( WP_MEMORY_LIMIT ); + + if ( function_exists( 'memory_get_usage' ) ) { + $system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) ); + $memory = max( $memory, $system_memory ); + } + + $wp_data['memory_limit'] = size_format( $memory ); + $wp_data['debug_mode'] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No'; + $wp_data['locale'] = get_locale(); + $wp_data['version'] = get_bloginfo( 'version' ); + $wp_data['multisite'] = is_multisite() ? 'Yes' : 'No'; + + return $wp_data; + } + + /** + * Get server related info. + * + * @return array + */ + private static function get_server_info() { + $server_data = array(); + + if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) { + $server_data['software'] = $_SERVER['SERVER_SOFTWARE']; // @phpcs:ignore + } + + if ( function_exists( 'phpversion' ) ) { + $server_data['php_version'] = phpversion(); + } + + if ( function_exists( 'ini_get' ) ) { + $server_data['php_post_max_size'] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) ); + $server_data['php_time_limt'] = ini_get( 'max_execution_time' ); + $server_data['php_max_input_vars'] = ini_get( 'max_input_vars' ); + $server_data['php_suhosin'] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No'; + } + + $database_version = wc_get_server_database_version(); + $server_data['mysql_version'] = $database_version['number']; + + $server_data['php_max_upload_size'] = size_format( wp_max_upload_size() ); + $server_data['php_default_timezone'] = date_default_timezone_get(); + $server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No'; + $server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No'; + $server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No'; + + return $server_data; + } + + /** + * Get all plugins grouped into activated or not. + * + * @return array + */ + private static function get_all_plugins() { + // Ensure get_plugins function is loaded. + if ( ! function_exists( 'get_plugins' ) ) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + + $plugins = get_plugins(); + $active_plugins_keys = get_option( 'active_plugins', array() ); + $active_plugins = array(); + + foreach ( $plugins as $k => $v ) { + // Take care of formatting the data how we want it. + $formatted = array(); + $formatted['name'] = strip_tags( $v['Name'] ); + if ( isset( $v['Version'] ) ) { + $formatted['version'] = strip_tags( $v['Version'] ); + } + if ( isset( $v['Author'] ) ) { + $formatted['author'] = strip_tags( $v['Author'] ); + } + if ( isset( $v['Network'] ) ) { + $formatted['network'] = strip_tags( $v['Network'] ); + } + if ( isset( $v['PluginURI'] ) ) { + $formatted['plugin_uri'] = strip_tags( $v['PluginURI'] ); + } + if ( in_array( $k, $active_plugins_keys ) ) { + // Remove active plugins from list so we can show active and inactive separately. + unset( $plugins[ $k ] ); + $active_plugins[ $k ] = $formatted; + } else { + $plugins[ $k ] = $formatted; + } + } + + return array( + 'active_plugins' => $active_plugins, + 'inactive_plugins' => $plugins, + ); + } + + /** + * Get user totals based on user role. + * + * @return array + */ + private static function get_user_counts() { + $user_count = array(); + $user_count_data = count_users(); + $user_count['total'] = $user_count_data['total_users']; + + // Get user count based on user role. + foreach ( $user_count_data['avail_roles'] as $role => $count ) { + $user_count[ $role ] = $count; + } + + return $user_count; + } + + /** + * Get product totals based on product type. + * + * @return array + */ + private static function get_product_counts() { + $product_count = array(); + $product_count_data = wp_count_posts( 'product' ); + $product_count['total'] = $product_count_data->publish; + + $product_statuses = get_terms( 'product_type', array( 'hide_empty' => 0 ) ); + foreach ( $product_statuses as $product_status ) { + $product_count[ $product_status->name ] = $product_status->count; + } + + return $product_count; + } + + /** + * Get order counts + * + * @return array + */ + private static function get_order_counts() { + $order_count = array(); + $order_count_data = wp_count_posts( 'shop_order' ); + foreach ( wc_get_order_statuses() as $status_slug => $status_name ) { + $order_count[ $status_slug ] = $order_count_data->{ $status_slug }; + } + return $order_count; + } + + /** + * Combine all order data. + * + * @return array + */ + private static function get_orders() { + $order_dates = self::get_order_dates(); + $order_counts = self::get_order_counts(); + $order_totals = self::get_order_totals(); + + return array_merge( $order_dates, $order_counts, $order_totals ); + } + + /** + * Get a list of all active payment gateways. + * + * @return array + */ + private static function get_active_payment_gateways() { + $active_gateways = array(); + $gateways = WC()->payment_gateways->payment_gateways(); + foreach ( $gateways as $id => $gateway ) { + if ( isset( $gateway->enabled ) && 'yes' === $gateway->enabled ) { + $active_gateways[ $id ] = array( + 'title' => $gateway->title, + 'supports' => $gateway->supports, + ); + } + } + + return $active_gateways; + } + + /** + * Get a list of all active shipping methods. + * + * @return array + */ + private static function get_active_shipping_methods() { + $active_methods = array(); + $shipping_methods = WC()->shipping->get_shipping_methods(); + foreach ( $shipping_methods as $id => $shipping_method ) { + if ( isset( $shipping_method->enabled ) && 'yes' === $shipping_method->enabled ) { + $active_methods[ $id ] = array( + 'title' => $shipping_method->title, + 'tax_status' => $shipping_method->tax_status, + ); + } + } + + return $active_methods; + } + + /** + * Get all options starting with woocommerce_ prefix. + * + * @return array + */ + private static function get_all_woocommerce_options_values() { + return array( + 'version' => WC()->version, + 'currency' => get_woocommerce_currency(), + 'base_location' => WC()->countries->get_base_country(), + 'selling_locations' => WC()->countries->get_allowed_countries(), + 'api_enabled' => get_option( 'woocommerce_api_enabled' ), + 'weight_unit' => get_option( 'woocommerce_weight_unit' ), + 'dimension_unit' => get_option( 'woocommerce_dimension_unit' ), + 'download_method' => get_option( 'woocommerce_file_download_method' ), + 'download_require_login' => get_option( 'woocommerce_downloads_require_login' ), + 'calc_taxes' => get_option( 'woocommerce_calc_taxes' ), + 'coupons_enabled' => get_option( 'woocommerce_enable_coupons' ), + 'guest_checkout' => get_option( 'woocommerce_enable_guest_checkout' ), + 'secure_checkout' => get_option( 'woocommerce_force_ssl_checkout' ), + 'enable_signup_and_login_from_checkout' => get_option( 'woocommerce_enable_signup_and_login_from_checkout' ), + 'enable_myaccount_registration' => get_option( 'woocommerce_enable_myaccount_registration' ), + 'registration_generate_username' => get_option( 'woocommerce_registration_generate_username' ), + 'registration_generate_password' => get_option( 'woocommerce_registration_generate_password' ), + ); + } + + /** + * Look for any template override and return filenames. + * + * @return array + */ + private static function get_all_template_overrides() { + $override_data = array(); + $template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) ); + $scanned_files = array(); + + require_once( WC()->plugin_path() . '/includes/admin/class-wc-admin-status.php' ); + + foreach ( $template_paths as $plugin_name => $template_path ) { + $scanned_files[ $plugin_name ] = WC_Admin_Status::scan_template_files( $template_path ); + } + + foreach ( $scanned_files as $plugin_name => $files ) { + foreach ( $files as $file ) { + if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . $file; + } elseif ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . $file ) ) { + $theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file; + } elseif ( file_exists( get_template_directory() . '/' . $file ) ) { + $theme_file = get_template_directory() . '/' . $file; + } elseif ( file_exists( get_template_directory() . '/' . WC()->template_path() . $file ) ) { + $theme_file = get_template_directory() . '/' . WC()->template_path() . $file; + } else { + $theme_file = false; + } + + if ( false !== $theme_file ) { + $override_data[] = basename( $theme_file ); + } + } + } + return $override_data; + } + + /** + * When an admin user logs in, there user agent is tracked in user meta and collected here. + * + * @return array + */ + private static function get_admin_user_agents() { + return array_filter( (array) get_option( 'woocommerce_tracker_ua', array() ) ); + } + + /** + * Get order totals + * + * @return array + */ + private static function get_order_totals() { + global $wpdb; + + $gross_total = $wpdb->get_var( " + SELECT + SUM( order_meta.meta_value ) AS 'gross_total' + FROM {$wpdb->prefix}posts AS orders + LEFT JOIN {$wpdb->prefix}postmeta AS order_meta ON order_meta.post_id = orders.ID + WHERE order_meta.meta_key = '_order_total' + AND orders.post_status = 'wc-completed' + GROUP BY order_meta.meta_key + " ); + + if ( is_null( $gross_total ) ) { + $gross_total = 0; + } + + return array( + 'gross' => $gross_total, + ); + } + + /** + * Get last order date + * + * @return string + */ + private static function get_order_dates() { + global $wpdb; + + $min_max = $wpdb->get_row( " + SELECT + MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last' + FROM {$wpdb->prefix}posts + WHERE post_type = 'shop_order' + AND post_status = 'wc-completed' + ", ARRAY_A ); + + if ( is_null( $min_max ) ) { + $min_max = array( + 'first' => '-', + 'last' => '-', + ); + } + + return $min_max; + } + + /** + * Make a request when opting out of tracker usage. + * + * @return void + */ + public static function opt_out_request() { + $body = array( + 'event' => 'opt-out', + 'email' => apply_filters( 'woocommerce_tracker_admin_email', get_option( 'admin_email' ) ), + 'url' => home_url(), + ); + wp_safe_remote_post( self::$api_url . 'event/', array( + 'method' => 'POST', + 'redirection' => 5, + 'httpversion' => '1.0', + 'blocking' => false, + 'headers' => array( 'user-agent' => 'WooCommerceTracker/' . md5( esc_url_raw( home_url( '/' ) ) ) . ';' ), + 'body' => wp_json_encode( $body ), + 'cookies' => array(), + ) ); + } +} + +WC_Tracker::init(); diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-validation.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-validation.php new file mode 100644 index 0000000..2dce534 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-validation.php @@ -0,0 +1,176 @@ + 0 ) { + return false; + } + + switch ( $country ) { + case 'AT': + $valid = (bool) preg_match( '/^([0-9]{4})$/', $postcode ); + break; + case 'BR': + $valid = (bool) preg_match( '/^([0-9]{5})([-])?([0-9]{3})$/', $postcode ); + break; + case 'CH': + $valid = (bool) preg_match( '/^([0-9]{4})$/i', $postcode ); + break; + case 'DE': + $valid = (bool) preg_match( '/^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$/', $postcode ); + break; + case 'ES': + case 'FR': + $valid = (bool) preg_match( '/^([0-9]{5})$/i', $postcode ); + break; + case 'GB': + $valid = self::is_gb_postcode( $postcode ); + break; + case 'JP': + $valid = (bool) preg_match( '/^([0-9]{3})([-])([0-9]{4})$/', $postcode ); + break; + case 'PT': + $valid = (bool) preg_match( '/^([0-9]{4})([-])([0-9]{3})$/', $postcode ); + break; + case 'US': + $valid = (bool) preg_match( '/^([0-9]{5})(-[0-9]{4})?$/i', $postcode ); + break; + case 'CA': + // CA Postal codes cannot contain D,F,I,O,Q,U and cannot start with W or Z. https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes. + $valid = (bool) preg_match( '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])([\ ])?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/i', $postcode ); + break; + case 'PL': + $valid = (bool) preg_match( '/^([0-9]{2})([-])([0-9]{3})$/', $postcode ); + break; + case 'CZ': + case 'SK': + $valid = (bool) preg_match( '/^([0-9]{3})(\s?)([0-9]{2})$/', $postcode ); + break; + + default: + $valid = true; + break; + } + + return apply_filters( 'woocommerce_validate_postcode', $valid, $postcode, $country ); + } + + /** + * Check if is a GB postcode. + * + * @param string $to_check A postcode. + * @return bool + */ + public static function is_gb_postcode( $to_check ) { + + // Permitted letters depend upon their position in the postcode. + // https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation. + $alpha1 = '[abcdefghijklmnoprstuwyz]'; // Character 1. + $alpha2 = '[abcdefghklmnopqrstuvwxy]'; // Character 2. + $alpha3 = '[abcdefghjkpstuw]'; // Character 3 == ABCDEFGHJKPSTUW. + $alpha4 = '[abehmnprvwxy]'; // Character 4 == ABEHMNPRVWXY. + $alpha5 = '[abdefghjlnpqrstuwxyz]'; // Character 5 != CIKMOV. + + $pcexp = array(); + + // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA. + $pcexp[0] = '/^(' . $alpha1 . '{1}' . $alpha2 . '{0,1}[0-9]{1,2})([0-9]{1}' . $alpha5 . '{2})$/'; + + // Expression for postcodes: ANA NAA. + $pcexp[1] = '/^(' . $alpha1 . '{1}[0-9]{1}' . $alpha3 . '{1})([0-9]{1}' . $alpha5 . '{2})$/'; + + // Expression for postcodes: AANA NAA. + $pcexp[2] = '/^(' . $alpha1 . '{1}' . $alpha2 . '[0-9]{1}' . $alpha4 . ')([0-9]{1}' . $alpha5 . '{2})$/'; + + // Exception for the special postcode GIR 0AA. + $pcexp[3] = '/^(gir)(0aa)$/'; + + // Standard BFPO numbers. + $pcexp[4] = '/^(bfpo)([0-9]{1,4})$/'; + + // c/o BFPO numbers. + $pcexp[5] = '/^(bfpo)(c\/o[0-9]{1,3})$/'; + + // Load up the string to check, converting into lowercase and removing spaces. + $postcode = strtolower( $to_check ); + $postcode = str_replace( ' ', '', $postcode ); + + // Assume we are not going to find a valid postcode. + $valid = false; + + // Check the string against the six types of postcodes. + foreach ( $pcexp as $regexp ) { + if ( preg_match( $regexp, $postcode, $matches ) ) { + // Remember that we have found that the code is valid and break from loop. + $valid = true; + break; + } + } + + return $valid; + } + + /** + * Format the postcode according to the country and length of the postcode. + * + * @param string $postcode Postcode to format. + * @param string $country Country to format the postcode for. + * @return string Formatted postcode. + */ + public static function format_postcode( $postcode, $country ) { + return wc_format_postcode( $postcode, $country ); + } + + /** + * Format a given phone number. + * + * @param mixed $tel Phone number to format. + * @return string + */ + public static function format_phone( $tel ) { + return wc_format_phone_number( $tel ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-wc-webhook.php b/backend/wp-content/plugins/woocommerce/includes/class-wc-webhook.php new file mode 100644 index 0000000..bf4cf9d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-wc-webhook.php @@ -0,0 +1,943 @@ + null, + 'date_modified' => null, + 'status' => 'disabled', + 'delivery_url' => '', + 'secret' => '', + 'name' => '', + 'topic' => '', + 'hooks' => '', + 'resource' => '', + 'event' => '', + 'failure_count' => 0, + 'user_id' => 0, + 'api_version' => 2, + 'pending_delivery' => false, + ); + + /** + * Load webhook data based on how WC_Webhook is called. + * + * @param WC_Webhook|int $data Webhook ID or data. + * @throws Exception If webhook cannot be read/found and $data is set. + */ + public function __construct( $data = 0 ) { + parent::__construct( $data ); + + if ( $data instanceof WC_Webhook ) { + $this->set_id( absint( $data->get_id() ) ); + } elseif ( is_numeric( $data ) ) { + $this->set_id( $data ); + } + + $this->data_store = WC_Data_Store::load( 'webhook' ); + + // If we have an ID, load the user from the DB. + if ( $this->get_id() ) { + try { + $this->data_store->read( $this ); + } catch ( Exception $e ) { + $this->set_id( 0 ); + $this->set_object_read( true ); + } + } else { + $this->set_object_read( true ); + } + } + + /** + * Enqueue the hooks associated with the webhook. + * + * @since 2.2.0 + */ + public function enqueue() { + $hooks = $this->get_hooks(); + $url = $this->get_delivery_url(); + + if ( is_array( $hooks ) && ! empty( $url ) ) { + foreach ( $hooks as $hook ) { + add_action( $hook, array( $this, 'process' ) ); + } + } + } + + /** + * Process the webhook for delivery by verifying that it should be delivered. + * and scheduling the delivery (in the background by default, or immediately). + * + * @since 2.2.0 + * @param mixed $arg The first argument provided from the associated hooks. + */ + public function process( $arg ) { + + // Verify that webhook should be processed for delivery. + if ( ! $this->should_deliver( $arg ) ) { + return; + } + + /** + * Process webhook delivery. + * + * @since 3.3.0 + * @hooked wc_webhook_process_delivery - 10 + */ + do_action( 'woocommerce_webhook_process_delivery', $this, $arg ); + } + + /** + * Helper to check if the webhook should be delivered, as some hooks. + * (like `wp_trash_post`) will fire for every post type, not just ours. + * + * @since 2.2.0 + * @param mixed $arg First hook argument. + * @return bool True if webhook should be delivered, false otherwise. + */ + private function should_deliver( $arg ) { + $should_deliver = true; + $current_action = current_action(); + + // Only active webhooks can be delivered. + if ( 'active' !== $this->get_status() ) { + $should_deliver = false; + } elseif ( in_array( $current_action, array( 'delete_post', 'wp_trash_post', 'untrashed_post' ), true ) ) { + // Only deliver deleted/restored event for coupons, orders, and products. + if ( isset( $GLOBALS['post_type'] ) && ! in_array( $GLOBALS['post_type'], array( 'shop_coupon', 'shop_order', 'product' ), true ) ) { + $should_deliver = false; + } + + // Check if is delivering for the correct resource. + if ( isset( $GLOBALS['post_type'] ) && str_replace( 'shop_', '', $GLOBALS['post_type'] ) !== $this->get_resource() ) { + $should_deliver = false; + } + } elseif ( 'delete_user' === $current_action ) { + $user = get_userdata( absint( $arg ) ); + + // Only deliver deleted customer event for users with customer role. + if ( ! $user || ! in_array( 'customer', (array) $user->roles, true ) ) { + $should_deliver = false; + } + } elseif ( 'order' === $this->get_resource() && ! in_array( get_post_type( absint( $arg ) ), wc_get_order_types( 'order-webhooks' ), true ) ) { + // Only if the custom order type has chosen to exclude order webhooks from triggering along with its own webhooks. + $should_deliver = false; + + } elseif ( 0 === strpos( $current_action, 'woocommerce_process_shop' ) || 0 === strpos( $current_action, 'woocommerce_process_product' ) ) { + // The `woocommerce_process_shop_*` and `woocommerce_process_product_*` hooks + // fire for create and update of products and orders, so check the post + // creation date to determine the actual event. + $resource = get_post( absint( $arg ) ); + + // Drafts don't have post_date_gmt so calculate it here. + $gmt_date = get_gmt_from_date( $resource->post_date ); + + // A resource is considered created when the hook is executed within 10 seconds of the post creation date. + $resource_created = ( ( time() - 10 ) <= strtotime( $gmt_date ) ); + + if ( 'created' === $this->get_event() && ! $resource_created ) { + $should_deliver = false; + } elseif ( 'updated' === $this->get_event() && $resource_created ) { + $should_deliver = false; + } + } + + /* + * Let other plugins intercept deliver for some messages queue like rabbit/zeromq. + */ + return apply_filters( 'woocommerce_webhook_should_deliver', $should_deliver, $this, $arg ); + } + + /** + * Deliver the webhook payload using wp_safe_remote_request(). + * + * @since 2.2.0 + * @param mixed $arg First hook argument. + */ + public function deliver( $arg ) { + $start_time = microtime( true ); + $payload = $this->build_payload( $arg ); + + // Setup request args. + $http_args = array( + 'method' => 'POST', + 'timeout' => MINUTE_IN_SECONDS, + 'redirection' => 0, + 'httpversion' => '1.0', + 'blocking' => true, + 'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version'] ), + 'body' => trim( wp_json_encode( $payload ) ), + 'headers' => array( + 'Content-Type' => 'application/json', + ), + 'cookies' => array(), + ); + + $http_args = apply_filters( 'woocommerce_webhook_http_args', $http_args, $arg, $this->get_id() ); + + // Add custom headers. + $delivery_id = $this->get_new_delivery_id(); + $http_args['headers']['X-WC-Webhook-Source'] = home_url( '/' ); // Since 2.6.0. + $http_args['headers']['X-WC-Webhook-Topic'] = $this->get_topic(); + $http_args['headers']['X-WC-Webhook-Resource'] = $this->get_resource(); + $http_args['headers']['X-WC-Webhook-Event'] = $this->get_event(); + $http_args['headers']['X-WC-Webhook-Signature'] = $this->generate_signature( $http_args['body'] ); + $http_args['headers']['X-WC-Webhook-ID'] = $this->get_id(); + $http_args['headers']['X-WC-Webhook-Delivery-ID'] = $delivery_id; + + // Webhook away! + $response = wp_safe_remote_request( $this->get_delivery_url(), $http_args ); + + $duration = round( microtime( true ) - $start_time, 5 ); + + $this->log_delivery( $delivery_id, $http_args, $response, $duration ); + + do_action( 'woocommerce_webhook_delivery', $http_args, $response, $duration, $arg, $this->get_id() ); + } + + /** + * Get Legacy API payload. + * + * @since 3.0.0 + * @param string $resource Resource type. + * @param int $resource_id Resource ID. + * @param string $event Event type. + * @return array + */ + private function get_legacy_api_payload( $resource, $resource_id, $event ) { + // Include & load API classes. + WC()->api->includes(); + WC()->api->register_resources( new WC_API_Server( '/' ) ); + + switch ( $resource ) { + case 'coupon': + $payload = WC()->api->WC_API_Coupons->get_coupon( $resource_id ); + break; + + case 'customer': + $payload = WC()->api->WC_API_Customers->get_customer( $resource_id ); + break; + + case 'order': + $payload = WC()->api->WC_API_Orders->get_order( $resource_id, null, apply_filters( 'woocommerce_webhook_order_payload_filters', array() ) ); + break; + + case 'product': + // Bulk and quick edit action hooks return a product object instead of an ID. + if ( 'updated' === $event && is_a( $resource_id, 'WC_Product' ) ) { + $resource_id = $resource_id->get_id(); + } + $payload = WC()->api->WC_API_Products->get_product( $resource_id ); + break; + + // Custom topics include the first hook argument. + case 'action': + $payload = array( + 'action' => current( $this->get_hooks() ), + 'arg' => $resource_id, + ); + break; + + default: + $payload = array(); + break; + } + + return $payload; + } + + /** + * Get WP API integration payload. + * + * @since 3.0.0 + * @param string $resource Resource type. + * @param int $resource_id Resource ID. + * @param string $event Event type. + * @return array + */ + private function get_wp_api_payload( $resource, $resource_id, $event ) { + $version_suffix = 'wp_api_v1' === $this->get_api_version() ? '_V1' : ''; + + switch ( $resource ) { + case 'coupon': + case 'customer': + case 'order': + case 'product': + $class = 'WC_REST_' . ucfirst( $resource ) . 's' . $version_suffix . '_Controller'; + $request = new WP_REST_Request( 'GET' ); + $controller = new $class(); + + // Bulk and quick edit action hooks return a product object instead of an ID. + if ( 'product' === $resource && 'updated' === $event && is_a( $resource_id, 'WC_Product' ) ) { + $resource_id = $resource_id->get_id(); + } + + $request->set_param( 'id', $resource_id ); + $result = $controller->get_item( $request ); + $payload = isset( $result->data ) ? $result->data : array(); + break; + + // Custom topics include the first hook argument. + case 'action': + $payload = array( + 'action' => current( $this->get_hooks() ), + 'arg' => $resource_id, + ); + break; + + default: + $payload = array(); + break; + } + + return $payload; + } + + /** + * Build the payload data for the webhook. + * + * @since 2.2.0 + * @param mixed $resource_id First hook argument, typically the resource ID. + * @return mixed Payload data. + */ + public function build_payload( $resource_id ) { + // Build the payload with the same user context as the user who created + // the webhook -- this avoids permission errors as background processing + // runs with no user context. + $current_user = get_current_user_id(); + wp_set_current_user( $this->get_user_id() ); + + $resource = $this->get_resource(); + $event = $this->get_event(); + + // If a resource has been deleted, just include the ID. + if ( 'deleted' === $event ) { + $payload = array( + 'id' => $resource_id, + ); + } else { + if ( in_array( $this->get_api_version(), array( 'wp_api_v1', 'wp_api_v2' ), true ) ) { + $payload = $this->get_wp_api_payload( $resource, $resource_id, $event ); + } else { + $payload = $this->get_legacy_api_payload( $resource, $resource_id, $event ); + } + } + + // Restore the current user. + wp_set_current_user( $current_user ); + + return apply_filters( 'woocommerce_webhook_payload', $payload, $resource, $resource_id, $this->get_id() ); + } + + /** + * Generate a base64-encoded HMAC-SHA256 signature of the payload body so the. + * recipient can verify the authenticity of the webhook. Note that the signature. + * is calculated after the body has already been encoded (JSON by default). + * + * @since 2.2.0 + * @param string $payload Payload data to hash. + * @return string + */ + public function generate_signature( $payload ) { + $hash_algo = apply_filters( 'woocommerce_webhook_hash_algorithm', 'sha256', $payload, $this->get_id() ); + + return base64_encode( hash_hmac( $hash_algo, $payload, $this->get_secret(), true ) ); + } + + /** + * Generate a new unique hash as a delivery id based on current time and wehbook id. + * Return the hash for inclusion in the webhook request. + * + * @since 2.2.0 + * @return string + */ + public function get_new_delivery_id() { + // Since we no longer use comments to store delivery logs, we generate a unique hash instead based on current time and webhook ID. + return wp_hash( $this->get_id() . strtotime( 'now' ) ); + } + + /** + * Log the delivery request/response. + * + * @since 2.2.0 + * @param string $delivery_id Previously created hash. + * @param array $request Request data. + * @param array|WP_Error $response Response data. + * @param float $duration Request duration. + */ + public function log_delivery( $delivery_id, $request, $response, $duration ) { + $logger = wc_get_logger(); + $message = array( + 'Webhook Delivery' => array( + 'Delivery ID' => $delivery_id, + 'Date' => date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( 'now' ), true ), + 'URL' => $this->get_delivery_url(), + 'Duration' => $duration, + 'Request' => array( + 'Method' => $request['method'], + 'Headers' => array_merge( + array( + 'User-Agent' => $request['user-agent'], + ), + $request['headers'] + ), + ), + 'Body' => wp_slash( $request['body'] ), + ), + ); + + // Parse response. + if ( is_wp_error( $response ) ) { + $response_code = $response->get_error_code(); + $response_message = $response->get_error_message(); + $response_headers = array(); + $response_body = ''; + } else { + $response_code = wp_remote_retrieve_response_code( $response ); + $response_message = wp_remote_retrieve_response_message( $response ); + $response_headers = wp_remote_retrieve_headers( $response ); + $response_body = wp_remote_retrieve_body( $response ); + } + + $message['Webhook Delivery']['Response'] = array( + 'Code' => $response_code, + 'Message' => $response_message, + 'Headers' => $response_headers, + 'Body' => $response_body, + ); + + if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { + $message['Webhook Delivery']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.'; + $message['Webhook Delivery']['Response']['Body'] = 'Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.'; + } + + $logger->info( + wc_print_r( $message, true ), array( + 'source' => 'webhooks-delivery', + ) + ); + + // Track failures. + if ( intval( $response_code ) >= 200 && intval( $response_code ) < 300 ) { + $this->set_failure_count( 0 ); + $this->save(); + } else { + $this->failed_delivery(); + } + } + + /** + * Track consecutive delivery failures and automatically disable the webhook. + * if more than 5 consecutive failures occur. A failure is defined as a. + * non-2xx response. + * + * @since 2.2.0 + */ + private function failed_delivery() { + $failures = $this->get_failure_count(); + + if ( $failures > apply_filters( 'woocommerce_max_webhook_delivery_failures', 5 ) ) { + $this->set_status( 'disabled' ); + + do_action( 'woocommerce_webhook_disabled_due_delivery_failures', $this->get_id() ); + } else { + $this->set_failure_count( ++$failures ); + } + + $this->save(); + } + + /** + * Get the delivery logs for this webhook. + * + * @since 3.3.0 + * @return string + */ + public function get_delivery_logs() { + return esc_url( add_query_arg( 'log_file', wc_get_log_file_name( 'webhooks-delivery' ), admin_url( 'admin.php?page=wc-status&tab=logs' ) ) ); + } + + /** + * Get the delivery log specified by the ID. The delivery log includes: + * + * + duration + * + summary + * + request method/url + * + request headers/body + * + response code/message/headers/body + * + * @since 2.2 + * @deprecated 3.3.0 + * @param int $delivery_id Delivery ID. + * @return void + */ + public function get_delivery_log( $delivery_id ) { + wc_deprecated_function( 'WC_Webhook::get_delivery_log', '3.3' ); + } + + /** + * Send a test ping to the delivery URL, sent when the webhook is first created. + * + * @since 2.2.0 + * @return bool|WP_Error + */ + public function deliver_ping() { + $args = array( + 'user-agent' => sprintf( 'WooCommerce/%s Hookshot (WordPress/%s)', WC_VERSION, $GLOBALS['wp_version'] ), + 'body' => 'webhook_id=' . $this->get_id(), + ); + + $test = wp_safe_remote_post( $this->get_delivery_url(), $args ); + $response_code = wp_remote_retrieve_response_code( $test ); + + if ( is_wp_error( $test ) ) { + /* translators: error message */ + return new WP_Error( 'error', sprintf( __( 'Error: Delivery URL cannot be reached: %s', 'woocommerce' ), $test->get_error_message() ) ); + } + + if ( 200 !== $response_code ) { + /* translators: error message */ + return new WP_Error( 'error', sprintf( __( 'Error: Delivery URL returned response code: %s', 'woocommerce' ), absint( $response_code ) ) ); + } + + $this->set_pending_delivery( false ); + $this->save(); + + return true; + } + + /* + |-------------------------------------------------------------------------- + | Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get the friendly name for the webhook. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string + */ + public function get_name( $context = 'view' ) { + return apply_filters( 'woocommerce_webhook_name', $this->get_prop( 'name', $context ), $this->get_id() ); + } + + /** + * Get the webhook status. + * + * - 'active' - delivers payload. + * - 'paused' - does not deliver payload, paused by admin. + * - 'disabled' - does not delivery payload, paused automatically due to consecutive failures. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string status + */ + public function get_status( $context = 'view' ) { + return apply_filters( 'woocommerce_webhook_status', $this->get_prop( 'status', $context ), $this->get_id() ); + } + + /** + * Get webhopk created date. + * + * @since 3.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return WC_DateTime|null Object if the date is set or null if there is no date. + */ + public function get_date_created( $context = 'view' ) { + return $this->get_prop( 'date_created', $context ); + } + + /** + * Get webhopk modified date. + * + * @since 3.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return WC_DateTime|null Object if the date is set or null if there is no date. + */ + public function get_date_modified( $context = 'view' ) { + return $this->get_prop( 'date_modified', $context ); + } + + /** + * Get the secret used for generating the HMAC-SHA256 signature. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string + */ + public function get_secret( $context = 'view' ) { + return apply_filters( 'woocommerce_webhook_secret', $this->get_prop( 'secret', $context ), $this->get_id() ); + } + + /** + * Get the webhook topic, e.g. `order.created`. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string + */ + public function get_topic( $context = 'view' ) { + return apply_filters( 'woocommerce_webhook_topic', $this->get_prop( 'topic', $context ), $this->get_id() ); + } + + /** + * Get the delivery URL. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string + */ + public function get_delivery_url( $context = 'view' ) { + return apply_filters( 'woocommerce_webhook_delivery_url', $this->get_prop( 'delivery_url', $context ), $this->get_id() ); + } + + /** + * Get the user ID for this webhook. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return int + */ + public function get_user_id( $context = 'view' ) { + return $this->get_prop( 'user_id', $context ); + } + + /** + * API version. + * + * @since 3.0.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return string + */ + public function get_api_version( $context = 'view' ) { + $version = $this->get_prop( 'api_version', $context ); + + return 0 < $version ? 'wp_api_v' . $version : 'legacy_v3'; + } + + /** + * Get the failure count. + * + * @since 2.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return int + */ + public function get_failure_count( $context = 'view' ) { + return $this->get_prop( 'failure_count', $context ); + } + + /** + * Get pending delivery. + * + * @since 3.2.0 + * @param string $context What the value is for. + * Valid values are 'view' and 'edit'. + * @return bool + */ + public function get_pending_delivery( $context = 'view' ) { + return $this->get_prop( 'pending_delivery', $context ); + } + + /* + |-------------------------------------------------------------------------- + | Setters + |-------------------------------------------------------------------------- + */ + + /** + * Set webhook name. + * + * @since 3.2.0 + * @param string $name Webhook name. + */ + public function set_name( $name ) { + $this->set_prop( 'name', $name ); + } + + /** + * Set webhook created date. + * + * @since 3.2.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. + * If the DateTime string has no timezone or offset, + * WordPress site timezone will be assumed. + * Null if their is no date. + */ + public function set_date_created( $date = null ) { + $this->set_date_prop( 'date_created', $date ); + } + + /** + * Set webhook modified date. + * + * @since 3.2.0 + * @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. + * If the DateTime string has no timezone or offset, + * WordPress site timezone will be assumed. + * Null if their is no date. + */ + public function set_date_modified( $date = null ) { + $this->set_date_prop( 'date_modified', $date ); + } + + /** + * Set status. + * + * @since 3.2.0 + * @param string $status Status. + */ + public function set_status( $status ) { + if ( ! array_key_exists( $status, wc_get_webhook_statuses() ) ) { + $status = 'disabled'; + } + + $this->set_prop( 'status', $status ); + } + + /** + * Set the secret used for generating the HMAC-SHA256 signature. + * + * @since 2.2.0 + * @param string $secret Secret. + */ + public function set_secret( $secret ) { + $this->set_prop( 'secret', $secret ); + } + + /** + * Set the webhook topic and associated hooks. + * The topic resource & event are also saved separately. + * + * @since 2.2.0 + * @param string $topic Webhook topic. + */ + public function set_topic( $topic ) { + $topic = wc_clean( $topic ); + + if ( ! wc_is_webhook_valid_topic( $topic ) ) { + $topic = ''; + } + + $this->set_prop( 'topic', $topic ); + } + + /** + * Set the delivery URL. + * + * @since 2.2.0 + * @param string $url Delivery URL. + */ + public function set_delivery_url( $url ) { + $this->set_prop( 'delivery_url', esc_url_raw( $url, array( 'http', 'https' ) ) ); + } + + /** + * Set user ID. + * + * @since 3.2.0 + * @param int $user_id User ID. + */ + public function set_user_id( $user_id ) { + $this->set_prop( 'user_id', (int) $user_id ); + } + + /** + * Set API version. + * + * @since 3.0.0 + * @param int|string $version REST API version. + */ + public function set_api_version( $version ) { + if ( ! is_numeric( $version ) ) { + $version = $this->data_store->get_api_version_number( $version ); + } + + $this->set_prop( 'api_version', (int) $version ); + } + + /** + * Set pending delivery. + * + * @since 3.2.0 + * @param bool $pending_delivery Set true if is pending for delivery. + */ + public function set_pending_delivery( $pending_delivery ) { + $this->set_prop( 'pending_delivery', (bool) $pending_delivery ); + } + + /** + * Set failure count. + * + * @since 3.2.0 + * @param bool $failure_count Total of failures. + */ + public function set_failure_count( $failure_count ) { + $this->set_prop( 'failure_count', intval( $failure_count ) ); + } + + /* + |-------------------------------------------------------------------------- + | Non-CRUD Getters + |-------------------------------------------------------------------------- + */ + + /** + * Get the associated hook names for a topic. + * + * @since 2.2.0 + * @param string $topic Topic name. + * @return array + */ + private function get_topic_hooks( $topic ) { + $topic_hooks = array( + 'coupon.created' => array( + 'woocommerce_process_shop_coupon_meta', + 'woocommerce_new_coupon', + ), + 'coupon.updated' => array( + 'woocommerce_process_shop_coupon_meta', + 'woocommerce_update_coupon', + ), + 'coupon.deleted' => array( + 'wp_trash_post', + ), + 'coupon.restored' => array( + 'untrashed_post', + ), + 'customer.created' => array( + 'user_register', + 'woocommerce_created_customer', + 'woocommerce_new_customer', + ), + 'customer.updated' => array( + 'profile_update', + 'woocommerce_update_customer', + ), + 'customer.deleted' => array( + 'delete_user', + ), + 'order.created' => array( + 'woocommerce_process_shop_order_meta', + 'woocommerce_new_order', + ), + 'order.updated' => array( + 'woocommerce_process_shop_order_meta', + 'woocommerce_update_order', + ), + 'order.deleted' => array( + 'wp_trash_post', + ), + 'order.restored' => array( + 'untrashed_post', + ), + 'product.created' => array( + 'woocommerce_process_product_meta', + 'woocommerce_new_product', + 'woocommerce_new_product_variation', + ), + 'product.updated' => array( + 'woocommerce_process_product_meta', + 'woocommerce_update_product', + 'woocommerce_update_product_variation', + ), + 'product.deleted' => array( + 'wp_trash_post', + ), + 'product.restored' => array( + 'untrashed_post', + ), + ); + + $topic_hooks = apply_filters( 'woocommerce_webhook_topic_hooks', $topic_hooks, $this ); + + return isset( $topic_hooks[ $topic ] ) ? $topic_hooks[ $topic ] : array(); + } + + /** + * Get the hook names for the webhook. + * + * @since 2.2.0 + * @return array + */ + public function get_hooks() { + if ( 'action' === $this->get_resource() ) { + $hooks = array( $this->get_event() ); + } else { + $hooks = $this->get_topic_hooks( $this->get_topic() ); + } + + return apply_filters( 'woocommerce_webhook_hooks', $hooks, $this->get_id() ); + } + + /** + * Get the resource for the webhook, e.g. `order`. + * + * @since 2.2.0 + * @return string + */ + public function get_resource() { + $topic = explode( '.', $this->get_topic() ); + + return apply_filters( 'woocommerce_webhook_resource', $topic[0], $this->get_id() ); + } + + /** + * Get the event for the webhook, e.g. `created`. + * + * @since 2.2.0 + * @return string + */ + public function get_event() { + $topic = explode( '.', $this->get_topic() ); + + return apply_filters( 'woocommerce_webhook_event', isset( $topic[1] ) ? $topic[1] : '', $this->get_id() ); + } + + /** + * Get the webhook i18n status. + * + * @return string + */ + public function get_i18n_status() { + $status = $this->get_status(); + $statuses = wc_get_webhook_statuses(); + + return isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/class-woocommerce.php b/backend/wp-content/plugins/woocommerce/includes/class-woocommerce.php new file mode 100644 index 0000000..a3f850f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/class-woocommerce.php @@ -0,0 +1,687 @@ +$key(); + } + } + + /** + * WooCommerce Constructor. + */ + public function __construct() { + $this->define_constants(); + $this->includes(); + $this->init_hooks(); + + do_action( 'woocommerce_loaded' ); + } + + /** + * Hook into actions and filters. + * + * @since 2.3 + */ + private function init_hooks() { + register_activation_hook( WC_PLUGIN_FILE, array( 'WC_Install', 'install' ) ); + register_shutdown_function( array( $this, 'log_errors' ) ); + add_action( 'after_setup_theme', array( $this, 'setup_environment' ) ); + add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 ); + add_action( 'init', array( $this, 'init' ), 0 ); + add_action( 'init', array( 'WC_Shortcodes', 'init' ) ); + add_action( 'init', array( 'WC_Emails', 'init_transactional_emails' ) ); + add_action( 'init', array( $this, 'wpdb_table_fix' ), 0 ); + add_action( 'init', array( $this, 'add_image_sizes' ) ); + add_action( 'switch_blog', array( $this, 'wpdb_table_fix' ), 0 ); + } + + /** + * Ensures fatal errors are logged so they can be picked up in the status report. + * + * @since 3.2.0 + */ + public function log_errors() { + $error = error_get_last(); + if ( E_ERROR === $error['type'] ) { + $logger = wc_get_logger(); + $logger->critical( + $error['message'] . PHP_EOL, + array( + 'source' => 'fatal-errors', + ) + ); + } + } + + /** + * Define WC Constants. + */ + private function define_constants() { + $upload_dir = wp_upload_dir( null, false ); + + $this->define( 'WC_ABSPATH', dirname( WC_PLUGIN_FILE ) . '/' ); + $this->define( 'WC_PLUGIN_BASENAME', plugin_basename( WC_PLUGIN_FILE ) ); + $this->define( 'WC_VERSION', $this->version ); + $this->define( 'WOOCOMMERCE_VERSION', $this->version ); + $this->define( 'WC_ROUNDING_PRECISION', 6 ); + $this->define( 'WC_DISCOUNT_ROUNDING_MODE', 2 ); + $this->define( 'WC_TAX_ROUNDING_MODE', 'yes' === get_option( 'woocommerce_prices_include_tax', 'no' ) ? 2 : 1 ); + $this->define( 'WC_DELIMITER', '|' ); + $this->define( 'WC_LOG_DIR', $upload_dir['basedir'] . '/wc-logs/' ); + $this->define( 'WC_SESSION_CACHE_GROUP', 'wc_session_id' ); + $this->define( 'WC_TEMPLATE_DEBUG_MODE', false ); + } + + /** + * Define constant if not already set. + * + * @param string $name Constant name. + * @param string|bool $value Constant value. + */ + private function define( $name, $value ) { + if ( ! defined( $name ) ) { + define( $name, $value ); + } + } + + /** + * What type of request is this? + * + * @param string $type admin, ajax, cron or frontend. + * @return bool + */ + private function is_request( $type ) { + switch ( $type ) { + case 'admin': + return is_admin(); + case 'ajax': + return defined( 'DOING_AJAX' ); + case 'cron': + return defined( 'DOING_CRON' ); + case 'frontend': + return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ); + } + } + + /** + * Include required core files used in admin and on the frontend. + */ + public function includes() { + /** + * Class autoloader. + */ + include_once WC_ABSPATH . 'includes/class-wc-autoloader.php'; + + /** + * Interfaces. + */ + include_once WC_ABSPATH . 'includes/interfaces/class-wc-abstract-order-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-coupon-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-customer-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-customer-download-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-customer-download-log-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-object-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-order-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-order-item-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-order-item-product-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-order-item-type-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-order-refund-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-payment-token-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-product-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-product-variable-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-shipping-zone-data-store-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-logger-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-log-handler-interface.php'; + include_once WC_ABSPATH . 'includes/interfaces/class-wc-webhooks-data-store-interface.php'; + + /** + * Abstract classes. + */ + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-data.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-object-query.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-payment-token.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-product.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-order.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-settings-api.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-shipping-method.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-payment-gateway.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-integration.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-log-handler.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-deprecated-hooks.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-session.php'; + include_once WC_ABSPATH . 'includes/abstracts/abstract-wc-privacy.php'; + + /** + * Core classes. + */ + include_once WC_ABSPATH . 'includes/wc-core-functions.php'; + include_once WC_ABSPATH . 'includes/class-wc-datetime.php'; + include_once WC_ABSPATH . 'includes/class-wc-post-types.php'; + include_once WC_ABSPATH . 'includes/class-wc-install.php'; + include_once WC_ABSPATH . 'includes/class-wc-geolocation.php'; + include_once WC_ABSPATH . 'includes/class-wc-download-handler.php'; + include_once WC_ABSPATH . 'includes/class-wc-comments.php'; + include_once WC_ABSPATH . 'includes/class-wc-post-data.php'; + include_once WC_ABSPATH . 'includes/class-wc-ajax.php'; + include_once WC_ABSPATH . 'includes/class-wc-emails.php'; + include_once WC_ABSPATH . 'includes/class-wc-data-exception.php'; + include_once WC_ABSPATH . 'includes/class-wc-query.php'; + include_once WC_ABSPATH . 'includes/class-wc-meta-data.php'; + include_once WC_ABSPATH . 'includes/class-wc-order-factory.php'; + include_once WC_ABSPATH . 'includes/class-wc-order-query.php'; + include_once WC_ABSPATH . 'includes/class-wc-product-factory.php'; + include_once WC_ABSPATH . 'includes/class-wc-product-query.php'; + include_once WC_ABSPATH . 'includes/class-wc-payment-tokens.php'; + include_once WC_ABSPATH . 'includes/class-wc-shipping-zone.php'; + include_once WC_ABSPATH . 'includes/gateways/class-wc-payment-gateway-cc.php'; + include_once WC_ABSPATH . 'includes/gateways/class-wc-payment-gateway-echeck.php'; + include_once WC_ABSPATH . 'includes/class-wc-countries.php'; + include_once WC_ABSPATH . 'includes/class-wc-integrations.php'; + include_once WC_ABSPATH . 'includes/class-wc-cache-helper.php'; + include_once WC_ABSPATH . 'includes/class-wc-https.php'; + include_once WC_ABSPATH . 'includes/class-wc-deprecated-action-hooks.php'; + include_once WC_ABSPATH . 'includes/class-wc-deprecated-filter-hooks.php'; + include_once WC_ABSPATH . 'includes/class-wc-background-emailer.php'; + include_once WC_ABSPATH . 'includes/class-wc-discounts.php'; + include_once WC_ABSPATH . 'includes/class-wc-cart-totals.php'; + include_once WC_ABSPATH . 'includes/customizer/class-wc-shop-customizer.php'; + include_once WC_ABSPATH . 'includes/class-wc-regenerate-images.php'; + include_once WC_ABSPATH . 'includes/class-wc-privacy.php'; + include_once WC_ABSPATH . 'includes/class-wc-structured-data.php'; + include_once WC_ABSPATH . 'includes/class-wc-shortcodes.php'; + include_once WC_ABSPATH . 'includes/class-wc-logger.php'; + + /** + * Data stores - used to store and retrieve CRUD object data from the database. + */ + include_once WC_ABSPATH . 'includes/class-wc-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-data-store-wp.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-coupon-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-product-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-product-grouped-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-product-variable-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-product-variation-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/abstract-wc-order-item-type-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-coupon-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-fee-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-product-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-shipping-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-item-tax-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-payment-token-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-customer-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-customer-data-store-session.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-customer-download-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-customer-download-log-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-shipping-zone-data-store.php'; + include_once WC_ABSPATH . 'includes/data-stores/abstract-wc-order-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-order-refund-data-store-cpt.php'; + include_once WC_ABSPATH . 'includes/data-stores/class-wc-webhook-data-store.php'; + + /** + * REST API. + */ + include_once WC_ABSPATH . 'includes/legacy/class-wc-legacy-api.php'; + include_once WC_ABSPATH . 'includes/class-wc-api.php'; + include_once WC_ABSPATH . 'includes/class-wc-auth.php'; + include_once WC_ABSPATH . 'includes/class-wc-register-wp-admin-settings.php'; + + if ( defined( 'WP_CLI' ) && WP_CLI ) { + include_once WC_ABSPATH . 'includes/class-wc-cli.php'; + } + + if ( $this->is_request( 'admin' ) ) { + include_once WC_ABSPATH . 'includes/admin/class-wc-admin.php'; + } + + if ( $this->is_request( 'frontend' ) ) { + $this->frontend_includes(); + } + + if ( $this->is_request( 'cron' ) && 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) { + include_once WC_ABSPATH . 'includes/class-wc-tracker.php'; + } + + $this->theme_support_includes(); + $this->query = new WC_Query(); + $this->api = new WC_API(); + } + + /** + * Include classes for theme support. + * + * @since 3.3.0 + */ + private function theme_support_includes() { + if ( wc_is_active_theme( array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) { + switch ( get_template() ) { + case 'twentyten': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-ten.php'; + break; + case 'twentyeleven': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-eleven.php'; + break; + case 'twentytwelve': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-twelve.php'; + break; + case 'twentythirteen': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-thirteen.php'; + break; + case 'twentyfourteen': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-fourteen.php'; + break; + case 'twentyfifteen': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-fifteen.php'; + break; + case 'twentysixteen': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-sixteen.php'; + break; + case 'twentyseventeen': + include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-seventeen.php'; + break; + } + } + } + + /** + * Include required frontend files. + */ + public function frontend_includes() { + include_once WC_ABSPATH . 'includes/wc-cart-functions.php'; + include_once WC_ABSPATH . 'includes/wc-notice-functions.php'; + include_once WC_ABSPATH . 'includes/wc-template-hooks.php'; + include_once WC_ABSPATH . 'includes/class-wc-template-loader.php'; + include_once WC_ABSPATH . 'includes/class-wc-frontend-scripts.php'; + include_once WC_ABSPATH . 'includes/class-wc-form-handler.php'; + include_once WC_ABSPATH . 'includes/class-wc-cart.php'; + include_once WC_ABSPATH . 'includes/class-wc-tax.php'; + include_once WC_ABSPATH . 'includes/class-wc-shipping-zones.php'; + include_once WC_ABSPATH . 'includes/class-wc-customer.php'; + include_once WC_ABSPATH . 'includes/class-wc-embed.php'; + include_once WC_ABSPATH . 'includes/class-wc-session-handler.php'; + } + + /** + * Function used to Init WooCommerce Template Functions - This makes them pluggable by plugins and themes. + */ + public function include_template_functions() { + include_once WC_ABSPATH . 'includes/wc-template-functions.php'; + } + + /** + * Init WooCommerce when WordPress Initialises. + */ + public function init() { + // Before init action. + do_action( 'before_woocommerce_init' ); + + // Set up localisation. + $this->load_plugin_textdomain(); + + // Load class instances. + $this->product_factory = new WC_Product_Factory(); + $this->order_factory = new WC_Order_Factory(); + $this->countries = new WC_Countries(); + $this->integrations = new WC_Integrations(); + $this->structured_data = new WC_Structured_Data(); + $this->deprecated_hook_handlers['actions'] = new WC_Deprecated_Action_Hooks(); + $this->deprecated_hook_handlers['filters'] = new WC_Deprecated_Filter_Hooks(); + + // Classes/actions loaded for the frontend and for ajax requests. + if ( $this->is_request( 'frontend' ) ) { + // Session class, handles session data for users - can be overwritten if custom handler is needed. + $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); + $this->session = new $session_class(); + $this->session->init(); + + $this->cart = new WC_Cart(); + $this->customer = new WC_Customer( get_current_user_id(), true ); + + // Customer should be saved during shutdown. + add_action( 'shutdown', array( $this->customer, 'save' ), 10 ); + } + + $this->load_webhooks(); + + // Init action. + do_action( 'woocommerce_init' ); + } + + /** + * Load Localisation files. + * + * Note: the first-loaded translation file overrides any following ones if the same translation is present. + * + * Locales found in: + * - WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo + * - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo + */ + public function load_plugin_textdomain() { + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); + $locale = apply_filters( 'plugin_locale', $locale, 'woocommerce' ); + + unload_textdomain( 'woocommerce' ); + load_textdomain( 'woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo' ); + load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( WC_PLUGIN_FILE ) ) . '/i18n/languages' ); + } + + /** + * Ensure theme and server variable compatibility and setup image sizes. + */ + public function setup_environment() { + /* @deprecated 2.2 Use WC()->template_path() instead. */ + $this->define( 'WC_TEMPLATE_PATH', $this->template_path() ); + + $this->add_thumbnail_support(); + } + + /** + * Ensure post thumbnail support is turned on. + */ + private function add_thumbnail_support() { + if ( ! current_theme_supports( 'post-thumbnails' ) ) { + add_theme_support( 'post-thumbnails' ); + } + add_post_type_support( 'product', 'thumbnail' ); + } + + /** + * Add WC Image sizes to WP. + * + * As of 3.3, image sizes can be registered via themes using add_theme_support for woocommerce + * and defining an array of args. If these are not defined, we will use defaults. This is + * handled in wc_get_image_size function. + * + * 3.3 sizes: + * + * woocommerce_thumbnail - Used in product listings. We assume these work for a 3 column grid layout. + * woocommerce_single - Used on single product pages for the main image. + * + * @since 2.3 + */ + public function add_image_sizes() { + $thumbnail = wc_get_image_size( 'thumbnail' ); + $single = wc_get_image_size( 'single' ); + $gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' ); + + add_image_size( 'woocommerce_thumbnail', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] ); + add_image_size( 'woocommerce_single', $single['width'], $single['height'], $single['crop'] ); + add_image_size( 'woocommerce_gallery_thumbnail', $gallery_thumbnail['width'], $gallery_thumbnail['height'], $gallery_thumbnail['crop'] ); + + // Registered for bw compat. @todo remove in 4.0. + add_image_size( 'shop_catalog', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] ); + add_image_size( 'shop_single', $single['width'], $single['height'], $single['crop'] ); + add_image_size( 'shop_thumbnail', $gallery_thumbnail['width'], $gallery_thumbnail['height'], $gallery_thumbnail['crop'] ); + } + + /** + * Get the plugin url. + * + * @return string + */ + public function plugin_url() { + return untrailingslashit( plugins_url( '/', WC_PLUGIN_FILE ) ); + } + + /** + * Get the plugin path. + * + * @return string + */ + public function plugin_path() { + return untrailingslashit( plugin_dir_path( WC_PLUGIN_FILE ) ); + } + + /** + * Get the template path. + * + * @return string + */ + public function template_path() { + return apply_filters( 'woocommerce_template_path', 'woocommerce/' ); + } + + /** + * Get Ajax URL. + * + * @return string + */ + public function ajax_url() { + return admin_url( 'admin-ajax.php', 'relative' ); + } + + /** + * Return the WC API URL for a given request. + * + * @param string $request Requested endpoint. + * @param bool|null $ssl If should use SSL, null if should auto detect. Default: null. + * @return string + */ + public function api_request_url( $request, $ssl = null ) { + if ( is_null( $ssl ) ) { + $scheme = wp_parse_url( home_url(), PHP_URL_SCHEME ); + } elseif ( $ssl ) { + $scheme = 'https'; + } else { + $scheme = 'http'; + } + + if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) { + $api_request_url = trailingslashit( home_url( '/index.php/wc-api/' . $request, $scheme ) ); + } elseif ( get_option( 'permalink_structure' ) ) { + $api_request_url = trailingslashit( home_url( '/wc-api/' . $request, $scheme ) ); + } else { + $api_request_url = add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) ); + } + + return esc_url_raw( apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl ) ); + } + + /** + * Load & enqueue active webhooks. + * + * @since 2.2 + */ + private function load_webhooks() { + + if ( ! is_blog_installed() ) { + return; + } + + wc_load_webhooks(); + } + + /** + * WooCommerce Payment Token Meta API and Term/Order item Meta - set table names. + */ + public function wpdb_table_fix() { + global $wpdb; + $wpdb->payment_tokenmeta = $wpdb->prefix . 'woocommerce_payment_tokenmeta'; + $wpdb->order_itemmeta = $wpdb->prefix . 'woocommerce_order_itemmeta'; + $wpdb->tables[] = 'woocommerce_payment_tokenmeta'; + $wpdb->tables[] = 'woocommerce_order_itemmeta'; + + if ( get_option( 'db_version' ) < 34370 ) { + $wpdb->woocommerce_termmeta = $wpdb->prefix . 'woocommerce_termmeta'; + $wpdb->tables[] = 'woocommerce_termmeta'; + } + } + + /** + * Get Checkout Class. + * + * @return WC_Checkout + */ + public function checkout() { + return WC_Checkout::instance(); + } + + /** + * Get gateways class. + * + * @return WC_Payment_Gateways + */ + public function payment_gateways() { + return WC_Payment_Gateways::instance(); + } + + /** + * Get shipping class. + * + * @return WC_Shipping + */ + public function shipping() { + return WC_Shipping::instance(); + } + + /** + * Email Class. + * + * @return WC_Emails + */ + public function mailer() { + return WC_Emails::instance(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-rest-command.php b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-rest-command.php new file mode 100644 index 0000000..2b0a218 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-rest-command.php @@ -0,0 +1,458 @@ + desc). + * + * @var array + */ + private $supported_ids = array(); + + /** + * Sets up REST Command. + * + * @param string $name Name of endpoint object (comes from schema). + * @param string $route Path to route of this endpoint. + * @param array $schema Schema object. + */ + public function __construct( $name, $route, $schema ) { + $this->name = $name; + + preg_match_all( '#\([^\)]+\)#', $route, $matches ); + $first_match = $matches[0]; + $resource_id = ! empty( $matches[0] ) ? array_pop( $matches[0] ) : null; + $this->route = rtrim( $route ); + $this->schema = $schema; + + $this->resource_identifier = $resource_id; + if ( in_array( $name, $this->routes_with_parent_id, true ) ) { + $is_singular = substr( $this->route, - strlen( $resource_id ) ) === $resource_id; + if ( ! $is_singular ) { + $this->resource_identifier = $first_match[0]; + } + } + } + + /** + * Passes supported ID arguments (things like product_id, order_id, etc) that we should look for in addition to id. + * + * @param array $supported_ids List of supported IDs. + */ + public function set_supported_ids( $supported_ids = array() ) { + $this->supported_ids = $supported_ids; + } + + /** + * Returns an ID of supported ID arguments (things like product_id, order_id, etc) that we should look for in addition to id. + * + * @return array + */ + public function get_supported_ids() { + return $this->supported_ids; + } + + /** + * Create a new item. + * + * @subcommand create + * + * @param array $args WP-CLI positional arguments. + * @param array $assoc_args WP-CLI associative arguments. + */ + public function create_item( $args, $assoc_args ) { + $assoc_args = self::decode_json( $assoc_args ); + list( $status, $body ) = $this->do_request( 'POST', $this->get_filled_route( $args ), $assoc_args ); + if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { + WP_CLI::line( $body['id'] ); + } else { + WP_CLI::success( "Created {$this->name} {$body['id']}." ); + } + } + + /** + * Delete an existing item. + * + * @subcommand delete + * + * @param array $args WP-CLI positional arguments. + * @param array $assoc_args WP-CLI associative arguments. + */ + public function delete_item( $args, $assoc_args ) { + list( $status, $body ) = $this->do_request( 'DELETE', $this->get_filled_route( $args ), $assoc_args ); + if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { + WP_CLI::line( $body['id'] ); + } else { + if ( empty( $assoc_args['force'] ) ) { + WP_CLI::success( __( 'Trashed', 'woocommerce' ) . " {$this->name} {$body['id']}" ); + } else { + WP_CLI::success( __( 'Deleted', 'woocommerce' ) . " {$this->name} {$body['id']}." ); + } + } + } + + /** + * Get a single item. + * + * @subcommand get + * + * @param array $args WP-CLI positional arguments. + * @param array $assoc_args WP-CLI associative arguments. + */ + public function get_item( $args, $assoc_args ) { + $route = $this->get_filled_route( $args ); + list( $status, $body, $headers ) = $this->do_request( 'GET', $route, $assoc_args ); + + if ( ! empty( $assoc_args['fields'] ) ) { + $body = self::limit_item_to_fields( $body, $assoc_args['fields'] ); + } + + if ( empty( $assoc_args['format'] ) ) { + $assoc_args['format'] = 'table'; + } + + if ( 'headers' === $assoc_args['format'] ) { + echo wp_json_encode( $headers ); + } elseif ( 'body' === $assoc_args['format'] ) { + echo wp_json_encode( $body ); + } elseif ( 'envelope' === $assoc_args['format'] ) { + echo wp_json_encode( + array( + 'body' => $body, + 'headers' => $headers, + 'status' => $status, + ) + ); + } else { + $formatter = $this->get_formatter( $assoc_args ); + $formatter->display_item( $body ); + } + } + + /** + * List all items. + * + * @subcommand list + * + * @param array $args WP-CLI positional arguments. + * @param array $assoc_args WP-CLI associative arguments. + */ + public function list_items( $args, $assoc_args ) { + if ( ! empty( $assoc_args['format'] ) && 'count' === $assoc_args['format'] ) { + $method = 'HEAD'; + } else { + $method = 'GET'; + } + + if ( ! isset( $assoc_args['per_page'] ) || empty( $assoc_args['per_page'] ) ) { + $assoc_args['per_page'] = '100'; + } + + list( $status, $body, $headers ) = $this->do_request( $method, $this->get_filled_route( $args ), $assoc_args ); + if ( ! empty( $assoc_args['format'] ) && 'ids' === $assoc_args['format'] ) { + $items = array_column( $body, 'id' ); + } else { + $items = $body; + } + + if ( ! empty( $assoc_args['fields'] ) ) { + foreach ( $items as $key => $item ) { + $items[ $key ] = self::limit_item_to_fields( $item, $assoc_args['fields'] ); + } + } + + if ( empty( $assoc_args['format'] ) ) { + $assoc_args['format'] = 'table'; + } + + if ( ! empty( $assoc_args['format'] ) && 'count' === $assoc_args['format'] ) { + echo (int) $headers['X-WP-Total']; + } elseif ( 'headers' === $assoc_args['format'] ) { + echo wp_json_encode( $headers ); + } elseif ( 'body' === $assoc_args['format'] ) { + echo wp_json_encode( $body ); + } elseif ( 'envelope' === $assoc_args['format'] ) { + echo wp_json_encode( + array( + 'body' => $body, + 'headers' => $headers, + 'status' => $status, + 'api_url' => $this->api_url, + ) + ); + } else { + $formatter = $this->get_formatter( $assoc_args ); + $formatter->display_items( $items ); + } + } + + /** + * Update an existing item. + * + * @subcommand update + * + * @param array $args WP-CLI positional arguments. + * @param array $assoc_args WP-CLI associative arguments. + */ + public function update_item( $args, $assoc_args ) { + $assoc_args = self::decode_json( $assoc_args ); + list( $status, $body ) = $this->do_request( 'POST', $this->get_filled_route( $args ), $assoc_args ); + if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { + WP_CLI::line( $body['id'] ); + } else { + WP_CLI::success( __( 'Updated', 'woocommerce' ) . " {$this->name} {$body['id']}." ); + } + } + + /** + * Do a REST Request + * + * @param string $method Request method. Examples: 'POST', 'PUT', 'DELETE' or 'GET'. + * @param string $route Resource route. + * @param array $assoc_args Associative arguments passed to the originating WP-CLI command. + * + * @return array + */ + private function do_request( $method, $route, $assoc_args ) { + wc_maybe_define_constant( 'REST_REQUEST', true ); + + $request = new WP_REST_Request( $method, $route ); + if ( in_array( $method, array( 'POST', 'PUT' ), true ) ) { + $request->set_body_params( $assoc_args ); + } else { + foreach ( $assoc_args as $key => $value ) { + $request->set_param( $key, $value ); + } + } + if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { + $original_queries = is_array( $GLOBALS['wpdb']->queries ) ? array_keys( $GLOBALS['wpdb']->queries ) : array(); + } + $response = rest_do_request( $request ); + if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { + $performed_queries = array(); + foreach ( (array) $GLOBALS['wpdb']->queries as $key => $query ) { + if ( in_array( $key, $original_queries, true ) ) { + continue; + } + $performed_queries[] = $query; + } + usort( + $performed_queries, function( $a, $b ) { + if ( $a[1] === $b[1] ) { + return 0; + } + return ( $a[1] > $b[1] ) ? -1 : 1; + } + ); + + $query_count = count( $performed_queries ); + $query_total_time = 0; + foreach ( $performed_queries as $query ) { + $query_total_time += $query[1]; + } + $slow_query_message = ''; + if ( $performed_queries && 'wc' === WP_CLI::get_config( 'debug' ) ) { + $slow_query_message .= '. Ordered by slowness, the queries are:' . PHP_EOL; + foreach ( $performed_queries as $i => $query ) { + $i++; + $bits = explode( ', ', $query[2] ); + $backtrace = implode( ', ', array_slice( $bits, 13 ) ); + $seconds = round( $query[1], 6 ); + $slow_query_message .= <<as_error(); + + if ( $error ) { + // For authentication errors (status 401), include a reminder to set the --user flag. + // WP_CLI::error will only return the first message from WP_Error, so we will pass a string containing both instead. + if ( 401 === $response->get_status() ) { + $errors = $error->get_error_messages(); + $errors[] = __( 'Make sure to include the --user flag with an account that has permissions for this action.', 'woocommerce' ) . ' {"status":401}'; + $error = implode( "\n", $errors ); + } + WP_CLI::error( $error ); + } + return array( $response->get_status(), $response->get_data(), $response->get_headers() ); + } + + /** + * Get Formatter object based on supplied parameters. + * + * @param array $assoc_args Parameters passed to command. Determines formatting. + * @return \WP_CLI\Formatter + */ + protected function get_formatter( &$assoc_args ) { + if ( ! empty( $assoc_args['fields'] ) ) { + if ( is_string( $assoc_args['fields'] ) ) { + $fields = explode( ',', $assoc_args['fields'] ); + } else { + $fields = $assoc_args['fields']; + } + } else { + if ( ! empty( $assoc_args['context'] ) ) { + $fields = $this->get_context_fields( $assoc_args['context'] ); + } else { + $fields = $this->get_context_fields( 'view' ); + } + } + return new \WP_CLI\Formatter( $assoc_args, $fields ); + } + + /** + * Get a list of fields present in a given context + * + * @param string $context Scope under which the request is made. Determines fields present in response. + * @return array + */ + private function get_context_fields( $context ) { + $fields = array(); + foreach ( $this->schema['properties'] as $key => $args ) { + if ( empty( $args['context'] ) || in_array( $context, $args['context'], true ) ) { + $fields[] = $key; + } + } + return $fields; + } + + /** + * Get the route for this resource + * + * @param array $args Positional arguments passed to the originating WP-CLI command. + * @return string + */ + private function get_filled_route( $args = array() ) { + $supported_id_matched = false; + $route = $this->route; + + foreach ( $this->get_supported_ids() as $id_name => $id_desc ) { + if ( 'id' !== $id_name && strpos( $route, '<' . $id_name . '>' ) !== false && ! empty( $args ) ) { + $route = str_replace( '(?P<' . $id_name . '>[\d]+)', $args[0], $route ); + $supported_id_matched = true; + } + } + + if ( ! empty( $args ) ) { + $id_replacement = $supported_id_matched && ! empty( $args[1] ) ? $args[1] : $args[0]; + $route = str_replace( array( '(?P[\d]+)', '(?P[\w-]+)' ), $id_replacement, $route ); + } + + return rtrim( $route ); + } + + /** + * Reduce an item to specific fields. + * + * @param array $item Item to reduce. + * @param array $fields Fields to keep. + * @return array + */ + private static function limit_item_to_fields( $item, $fields ) { + if ( empty( $fields ) ) { + return $item; + } + if ( is_string( $fields ) ) { + $fields = explode( ',', $fields ); + } + foreach ( $item as $i => $field ) { + if ( ! in_array( $i, $fields, true ) ) { + unset( $item[ $i ] ); + } + } + return $item; + } + + /** + * JSON can be passed in some more complicated objects, like the payment gateway settings array. + * This function decodes the json (if present) and tries to get it's value. + * + * @param array $arr Array that will be scanned for JSON encoded values. + * + * @return array + */ + protected function decode_json( $arr ) { + foreach ( $arr as $key => $value ) { + if ( '[' === substr( $value, 0, 1 ) || '{' === substr( $value, 0, 1 ) ) { + $arr[ $key ] = json_decode( $value, true ); + } else { + continue; + } + } + return $arr; + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-runner.php b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-runner.php new file mode 100644 index 0000000..a4194b8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-runner.php @@ -0,0 +1,261 @@ +[\w-]+)', + 'settings/(?P[\w-]+)/batch', + 'settings/(?P[\w-]+)/(?P[\w-]+)', + 'system_status', + 'system_status/tools', + 'system_status/tools/(?P[\w-]+)', + 'reports', + 'reports/sales', + 'reports/top_sellers', + ); + + /** + * The version of the REST API we should target to + * generate commands. + * + * @var string + */ + private static $target_rest_version = 'v2'; + + /** + * Register's all endpoints as commands once WP and WC have all loaded. + */ + public static function after_wp_load() { + global $wp_rest_server; + $wp_rest_server = new WP_REST_Server(); + do_action( 'rest_api_init', $wp_rest_server ); + + $request = new WP_REST_Request( 'GET', '/' ); + $request->set_param( 'context', 'help' ); + $response = $wp_rest_server->dispatch( $request ); + $response_data = $response->get_data(); + if ( empty( $response_data ) ) { + return; + } + + // Loop through all of our endpoints and register any valid WC endpoints. + foreach ( $response_data['routes'] as $route => $route_data ) { + // Only register endpoints for WC and our target version. + if ( substr( $route, 0, 4 + strlen( self::$target_rest_version ) ) !== '/wc/' . self::$target_rest_version ) { + continue; + } + + // Only register endpoints with schemas. + if ( empty( $route_data['schema']['title'] ) ) { + /* translators: %s: Route to a given WC-API endpoint */ + WP_CLI::debug( sprintf( __( 'No schema title found for %s, skipping REST command registration.', 'woocommerce' ), $route ), 'wc' ); + continue; + } + // Ignore batch endpoints. + if ( 'batch' === $route_data['schema']['title'] ) { + continue; + } + // Disable specific endpoints. + $route_pieces = explode( '/', $route ); + $endpoint_piece = str_replace( '/wc/' . $route_pieces[2] . '/', '', $route ); + if ( in_array( $endpoint_piece, self::$disabled_endpoints, true ) ) { + continue; + } + + self::register_route_commands( new WC_CLI_REST_Command( $route_data['schema']['title'], $route, $route_data['schema'] ), $route, $route_data ); + } + } + + /** + * Generates command information and tells WP CLI about all + * commands available from a route. + * + * @param string $rest_command WC-API command. + * @param string $route Path to route endpoint. + * @param array $route_data Command data. + * @param array $command_args WP-CLI command arguments. + */ + private static function register_route_commands( $rest_command, $route, $route_data, $command_args = array() ) { + // Define IDs that we are looking for in the routes (in addition to id) + // so that we can pass it to the rest command, and use it here to generate documentation. + $supported_ids = array( + 'product_id' => __( 'Product ID.', 'woocommerce' ), + 'customer_id' => __( 'Customer ID.', 'woocommerce' ), + 'order_id' => __( 'Order ID.', 'woocommerce' ), + 'refund_id' => __( 'Refund ID.', 'woocommerce' ), + 'attribute_id' => __( 'Attribute ID.', 'woocommerce' ), + 'zone_id' => __( 'Zone ID.', 'woocommerce' ), + 'id' => __( 'ID.', 'woocommerce' ), + ); + $rest_command->set_supported_ids( $supported_ids ); + $positional_args = array_keys( $supported_ids ); + + $parent = "wc {$route_data['schema']['title']}"; + $supported_commands = array(); + + // Get a list of supported commands for each route. + foreach ( $route_data['endpoints'] as $endpoint ) { + preg_match_all( '#\([^\)]+\)#', $route, $matches ); + $resource_id = ! empty( $matches[0] ) ? array_pop( $matches[0] ) : null; + $trimmed_route = rtrim( $route ); + $is_singular = substr( $trimmed_route, - strlen( $resource_id ) ) === $resource_id; + + // List a collection. + if ( array( 'GET' ) === $endpoint['methods'] && ! $is_singular ) { + $supported_commands['list'] = ! empty( $endpoint['args'] ) ? $endpoint['args'] : array(); + } + // Create a specific resource. + if ( array( 'POST' ) === $endpoint['methods'] && ! $is_singular ) { + $supported_commands['create'] = ! empty( $endpoint['args'] ) ? $endpoint['args'] : array(); + } + // Get a specific resource. + if ( array( 'GET' ) === $endpoint['methods'] && $is_singular ) { + $supported_commands['get'] = ! empty( $endpoint['args'] ) ? $endpoint['args'] : array(); + } + // Update a specific resource. + if ( in_array( 'POST', $endpoint['methods'], true ) && $is_singular ) { + $supported_commands['update'] = ! empty( $endpoint['args'] ) ? $endpoint['args'] : array(); + } + // Delete a specific resource. + if ( array( 'DELETE' ) === $endpoint['methods'] && $is_singular ) { + $supported_commands['delete'] = ! empty( $endpoint['args'] ) ? $endpoint['args'] : array(); + } + } + + foreach ( $supported_commands as $command => $endpoint_args ) { + $synopsis = array(); + $arg_regs = array(); + $ids = array(); + + foreach ( $supported_ids as $id_name => $id_desc ) { + if ( strpos( $route, '<' . $id_name . '>' ) !== false ) { + $synopsis[] = array( + 'name' => $id_name, + 'type' => 'positional', + 'description' => $id_desc, + 'optional' => false, + ); + $ids[] = $id_name; + } + } + if ( in_array( $command, array( 'delete', 'get', 'update' ), true ) && ! in_array( 'id', $ids, true ) ) { + $synopsis[] = array( + 'name' => 'id', + 'type' => 'positional', + 'description' => __( 'The id for the resource.', 'woocommerce' ), + 'optional' => false, + ); + } + + foreach ( $endpoint_args as $name => $args ) { + if ( ! in_array( $name, $positional_args, true ) || strpos( $route, '<' . $id_name . '>' ) === false ) { + $arg_regs[] = array( + 'name' => $name, + 'type' => 'assoc', + 'description' => ! empty( $args['description'] ) ? $args['description'] : '', + 'optional' => empty( $args['required'] ), + ); + } + } + + foreach ( $arg_regs as $arg_reg ) { + $synopsis[] = $arg_reg; + } + + if ( in_array( $command, array( 'list', 'get' ), true ) ) { + $synopsis[] = array( + 'name' => 'fields', + 'type' => 'assoc', + 'description' => __( 'Limit response to specific fields. Defaults to all fields.', 'woocommerce' ), + 'optional' => true, + ); + $synopsis[] = array( + 'name' => 'field', + 'type' => 'assoc', + 'description' => __( 'Get the value of an individual field.', 'woocommerce' ), + 'optional' => true, + ); + $synopsis[] = array( + 'name' => 'format', + 'type' => 'assoc', + 'description' => __( 'Render response in a particular format.', 'woocommerce' ), + 'optional' => true, + 'default' => 'table', + 'options' => array( + 'table', + 'json', + 'csv', + 'ids', + 'yaml', + 'count', + 'headers', + 'body', + 'envelope', + ), + ); + } + + if ( in_array( $command, array( 'create', 'update', 'delete' ), true ) ) { + $synopsis[] = array( + 'name' => 'porcelain', + 'type' => 'flag', + 'description' => __( 'Output just the id when the operation is successful.', 'woocommerce' ), + 'optional' => true, + ); + } + + $methods = array( + 'list' => 'list_items', + 'create' => 'create_item', + 'delete' => 'delete_item', + 'get' => 'get_item', + 'update' => 'update_item', + ); + + $before_invoke = null; + if ( empty( $command_args['when'] ) && \WP_CLI::get_config( 'debug' ) ) { + $before_invoke = function() { + wc_maybe_define_constant( 'SAVEQUERIES', true ); + }; + } + + WP_CLI::add_command( + "{$parent} {$command}", + array( $rest_command, $methods[ $command ] ), + array( + 'synopsis' => $synopsis, + 'when' => ! empty( $command_args['when'] ) ? $command_args['when'] : '', + 'before_invoke' => $before_invoke, + ) + ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-tool-command.php b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-tool-command.php new file mode 100644 index 0000000..c3b5433 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-tool-command.php @@ -0,0 +1,105 @@ +dispatch( $request ); + $response_data = $response->get_data(); + if ( empty( $response_data ) ) { + return; + } + + $parent = 'wc tool'; + $supported_commands = array( 'list', 'run' ); + foreach ( $supported_commands as $command ) { + $synopsis = array(); + if ( 'run' === $command ) { + $synopsis[] = array( + 'name' => 'id', + 'type' => 'positional', + 'description' => __( 'The id for the resource.', 'woocommerce' ), + 'optional' => false, + ); + $method = 'update_item'; + $route = '/wc/v2/system_status/tools/(?P[\w-]+)'; + } elseif ( 'list' === $command ) { + $synopsis[] = array( + 'name' => 'fields', + 'type' => 'assoc', + 'description' => __( 'Limit response to specific fields. Defaults to all fields.', 'woocommerce' ), + 'optional' => true, + ); + $synopsis[] = array( + 'name' => 'field', + 'type' => 'assoc', + 'description' => __( 'Get the value of an individual field.', 'woocommerce' ), + 'optional' => true, + ); + $synopsis[] = array( + 'name' => 'format', + 'type' => 'assoc', + 'description' => __( 'Render response in a particular format.', 'woocommerce' ), + 'optional' => true, + 'default' => 'table', + 'options' => array( + 'table', + 'json', + 'csv', + 'ids', + 'yaml', + 'count', + 'headers', + 'body', + 'envelope', + ), + ); + $method = 'list_items'; + $route = '/wc/v2/system_status/tools'; + } + + $before_invoke = null; + if ( empty( $command_args['when'] ) && WP_CLI::get_config( 'debug' ) ) { + $before_invoke = function() { + wc_maybe_define_constant( 'SAVEQUERIES', true ); + }; + } + + $rest_command = new WC_CLI_REST_Command( 'system_status_tool', $route, $response_data['schema'] ); + + WP_CLI::add_command( + "{$parent} {$command}", array( $rest_command, $method ), array( + 'synopsis' => $synopsis, + 'when' => ! empty( $command_args['when'] ) ? $command_args['when'] : '', + 'before_invoke' => $before_invoke, + ) + ); + } + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-update-command.php b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-update-command.php new file mode 100644 index 0000000..3c0c188 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/cli/class-wc-cli-update-command.php @@ -0,0 +1,56 @@ +hide_errors(); + + include_once WC_ABSPATH . 'includes/class-wc-install.php'; + include_once WC_ABSPATH . 'includes/wc-update-functions.php'; + + $current_db_version = get_option( 'woocommerce_db_version' ); + $update_count = 0; + + foreach ( WC_Install::get_db_update_callbacks() as $version => $update_callbacks ) { + if ( version_compare( $current_db_version, $version, '<' ) ) { + foreach ( $update_callbacks as $update_callback ) { + /* translators: %s: DB update callback key */ + WP_CLI::log( sprintf( __( 'Calling update function: %s', 'woocommerce' ), $update_callback ) ); + call_user_func( $update_callback ); + $update_count ++; + } + } + } + + WC_Admin_Notices::remove_notice( 'update' ); + /* translators: 1: Number of database updates performed 2: Database version number */ + WP_CLI::success( sprintf( __( '%1$d updates complete. Database version is %2$s', 'woocommerce' ), absint( $update_count ), get_option( 'woocommerce_db_version' ) ) ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/customizer/class-wc-customizer-control-cropping.php b/backend/wp-content/plugins/woocommerce/includes/customizer/class-wc-customizer-control-cropping.php new file mode 100644 index 0000000..675f698 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/customizer/class-wc-customizer-control-cropping.php @@ -0,0 +1,64 @@ +choices ) ) { + return; + } + + $value = $this->value( 'cropping' ); + $custom_width = $this->value( 'custom_width' ); + $custom_height = $this->value( 'custom_height' ); + ?> + + + label ); ?> + + + description ) ) : ?> + description ); ?> + + +
        + choices as $key => $radio ) : ?> +
      • + link( 'cropping' ); ?> /> + + + + + link( 'custom_width' ); ?> /> : link( 'custom_height' ); ?> /> + + +
      • + +
      + add_panel( 'woocommerce', array( + 'priority' => 200, + 'capability' => 'manage_woocommerce', + 'theme_supports' => '', + 'title' => __( 'WooCommerce', 'woocommerce' ), + ) ); + + $this->add_store_notice_section( $wp_customize ); + $this->add_product_catalog_section( $wp_customize ); + $this->add_product_images_section( $wp_customize ); + $this->add_checkout_section( $wp_customize ); + } + + /** + * Frontend CSS styles. + */ + public function add_frontend_scripts() { + if ( ! is_customize_preview() || ! is_store_notice_showing() ) { + return; + } + + $css = '.woocommerce-store-notice, p.demo_store { display: block !important; }'; + wp_add_inline_style( 'customize-preview', $css ); + } + + /** + * CSS styles to improve our form. + */ + public function add_styles() { + ?> + + + + __( 'Default sorting (custom ordering + name)', 'woocommerce' ), + 'popularity' => __( 'Popularity (sales)', 'woocommerce' ), + 'rating' => __( 'Average rating', 'woocommerce' ), + 'date' => __( 'Sort by most recent', 'woocommerce' ), + 'price' => __( 'Sort by price (asc)', 'woocommerce' ), + 'price-desc' => __( 'Sort by price (desc)', 'woocommerce' ), + ) ); + + return array_key_exists( $value, $options ) ? $value : 'menu_order'; + } + + /** + * Store notice section. + * + * @param WP_Customize_Manager $wp_customize Theme Customizer object. + */ + private function add_store_notice_section( $wp_customize ) { + $wp_customize->add_section( + 'woocommerce_store_notice', + array( + 'title' => __( 'Store Notice', 'woocommerce' ), + 'priority' => 10, + 'panel' => 'woocommerce', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_demo_store', + array( + 'default' => 'no', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wc_bool_to_string', + 'sanitize_js_callback' => 'wc_string_to_bool', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_demo_store_notice', + array( + 'default' => __( 'This is a demo store for testing purposes — no orders shall be fulfilled.', 'woocommerce' ), + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wp_kses_post', + 'transport' => 'postMessage', + ) + ); + + $wp_customize->add_control( + 'woocommerce_demo_store_notice', + array( + 'label' => __( 'Store notice', 'woocommerce' ), + 'description' => __( 'If enabled, this text will be shown site-wide. You can use it to show events or promotions to visitors!', 'woocommerce' ), + 'section' => 'woocommerce_store_notice', + 'settings' => 'woocommerce_demo_store_notice', + 'type' => 'textarea', + ) + ); + + $wp_customize->add_control( + 'woocommerce_demo_store', + array( + 'label' => __( 'Enable store notice', 'woocommerce' ), + 'section' => 'woocommerce_store_notice', + 'settings' => 'woocommerce_demo_store', + 'type' => 'checkbox', + ) + ); + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( + 'woocommerce_demo_store_notice', array( + 'selector' => '.woocommerce-store-notice', + 'container_inclusive' => true, + 'render_callback' => 'woocommerce_demo_store', + ) + ); + } + } + + /** + * Product catalog section. + * + * @param WP_Customize_Manager $wp_customize Theme Customizer object. + */ + public function add_product_catalog_section( $wp_customize ) { + $wp_customize->add_section( + 'woocommerce_product_catalog', + array( + 'title' => __( 'Product Catalog', 'woocommerce' ), + 'priority' => 10, + 'panel' => 'woocommerce', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_shop_page_display', + array( + 'default' => '', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => array( $this, 'sanitize_archive_display' ), + ) + ); + + $wp_customize->add_control( + 'woocommerce_shop_page_display', + array( + 'label' => __( 'Shop page display', 'woocommerce' ), + 'description' => __( 'Choose what to display on the main shop page.', 'woocommerce' ), + 'section' => 'woocommerce_product_catalog', + 'settings' => 'woocommerce_shop_page_display', + 'type' => 'select', + 'choices' => array( + '' => __( 'Show products', 'woocommerce' ), + 'subcategories' => __( 'Show categories', 'woocommerce' ), + 'both' => __( 'Show categories & products', 'woocommerce' ), + ), + ) + ); + + $wp_customize->add_setting( + 'woocommerce_category_archive_display', + array( + 'default' => '', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => array( $this, 'sanitize_archive_display' ), + ) + ); + + $wp_customize->add_control( + 'woocommerce_category_archive_display', + array( + 'label' => __( 'Category display', 'woocommerce' ), + 'description' => __( 'Choose what to display on product category pages.', 'woocommerce' ), + 'section' => 'woocommerce_product_catalog', + 'settings' => 'woocommerce_category_archive_display', + 'type' => 'select', + 'choices' => array( + '' => __( 'Show products', 'woocommerce' ), + 'subcategories' => __( 'Show subcategories', 'woocommerce' ), + 'both' => __( 'Show subcategories & products', 'woocommerce' ), + ), + ) + ); + + $wp_customize->add_setting( + 'woocommerce_default_catalog_orderby', + array( + 'default' => 'menu_order', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => array( $this, 'sanitize_default_catalog_orderby' ), + ) + ); + + $wp_customize->add_control( + 'woocommerce_default_catalog_orderby', + array( + 'label' => __( 'Default product sorting', 'woocommerce' ), + 'description' => __( 'How should products be sorted in the catalog by default?', 'woocommerce' ), + 'section' => 'woocommerce_product_catalog', + 'settings' => 'woocommerce_default_catalog_orderby', + 'type' => 'select', + 'choices' => apply_filters( 'woocommerce_default_catalog_orderby_options', array( + 'menu_order' => __( 'Default sorting (custom ordering + name)', 'woocommerce' ), + 'popularity' => __( 'Popularity (sales)', 'woocommerce' ), + 'rating' => __( 'Average rating', 'woocommerce' ), + 'date' => __( 'Sort by most recent', 'woocommerce' ), + 'price' => __( 'Sort by price (asc)', 'woocommerce' ), + 'price-desc' => __( 'Sort by price (desc)', 'woocommerce' ), + ) ), + ) + ); + + // The following settings should be hidden if the theme is declaring the values. + if ( has_filter( 'loop_shop_columns' ) ) { + return; + } + + $wp_customize->add_setting( + 'woocommerce_catalog_columns', + array( + 'default' => 4, + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + + $wp_customize->add_control( + 'woocommerce_catalog_columns', + array( + 'label' => __( 'Products per row', 'woocommerce' ), + 'description' => __( 'How many products should be shown per row?', 'woocommerce' ), + 'section' => 'woocommerce_product_catalog', + 'settings' => 'woocommerce_catalog_columns', + 'type' => 'number', + 'input_attrs' => array( + 'min' => wc_get_theme_support( 'product_grid::min_columns', 1 ), + 'max' => wc_get_theme_support( 'product_grid::max_columns', '' ), + 'step' => 1, + ), + ) + ); + + // Only add this setting if something else isn't managing the number of products per page. + if ( ! has_filter( 'loop_shop_per_page' ) ) { + $wp_customize->add_setting( + 'woocommerce_catalog_rows', + array( + 'default' => 4, + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + } + + $wp_customize->add_control( + 'woocommerce_catalog_rows', + array( + 'label' => __( 'Rows per page', 'woocommerce' ), + 'description' => __( 'How many rows of products should be shown per page?', 'woocommerce' ), + 'section' => 'woocommerce_product_catalog', + 'settings' => 'woocommerce_catalog_rows', + 'type' => 'number', + 'input_attrs' => array( + 'min' => wc_get_theme_support( 'product_grid::min_rows', 1 ), + 'max' => wc_get_theme_support( 'product_grid::max_rows', '' ), + 'step' => 1, + ), + ) + ); + } + + /** + * Product images section. + * + * @param WP_Customize_Manager $wp_customize Theme Customizer object. + */ + private function add_product_images_section( $wp_customize ) { + if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { + $regen_description = ''; // Nothing to report; Jetpack will handle magically. + } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && ! is_multisite() ) { + $regen_description = __( 'After publishing your changes, new image sizes will be generated automatically.', 'woocommerce' ); + } elseif ( apply_filters( 'woocommerce_background_image_regeneration', true ) && is_multisite() ) { + /* translators: 1: tools URL 2: regen thumbs url */ + $regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you regenerate thumbnails. You can do this from the tools section in WooCommerce or by using a plugin such as Regenerate Thumbnails.', 'woocommerce' ), admin_url( 'admin.php?page=wc-status&tab=tools' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' ); + } else { + /* translators: %s: regen thumbs url */ + $regen_description = sprintf( __( 'After publishing your changes, new image sizes may not be shown until you Regenerate Thumbnails.', 'woocommerce' ), 'https://en-gb.wordpress.org/plugins/regenerate-thumbnails/' ); + } + + $wp_customize->add_section( + 'woocommerce_product_images', + array( + 'title' => __( 'Product Images', 'woocommerce' ), + 'description' => $regen_description, + 'priority' => 20, + 'panel' => 'woocommerce', + ) + ); + + if ( ! wc_get_theme_support( 'single_image_width' ) ) { + $wp_customize->add_setting( + 'woocommerce_single_image_width', + array( + 'default' => 600, + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + + $wp_customize->add_control( + 'woocommerce_single_image_width', + array( + 'label' => __( 'Main image width', 'woocommerce' ), + 'description' => __( 'Image size used for the main image on single product pages. These images will remain uncropped.', 'woocommerce' ), + 'section' => 'woocommerce_product_images', + 'settings' => 'woocommerce_single_image_width', + 'type' => 'number', + 'input_attrs' => array( + 'min' => 0, + 'step' => 1, + ), + ) + ); + } + + if ( ! wc_get_theme_support( 'thumbnail_image_width' ) ) { + $wp_customize->add_setting( + 'woocommerce_thumbnail_image_width', + array( + 'default' => 300, + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + + $wp_customize->add_control( + 'woocommerce_thumbnail_image_width', + array( + 'label' => __( 'Thumbnail width', 'woocommerce' ), + 'description' => __( 'Image size used for products in the catalog.', 'woocommerce' ), + 'section' => 'woocommerce_product_images', + 'settings' => 'woocommerce_thumbnail_image_width', + 'type' => 'number', + 'input_attrs' => array( + 'min' => 0, + 'step' => 1, + ), + ) + ); + } + + include_once WC_ABSPATH . 'includes/customizer/class-wc-customizer-control-cropping.php'; + + $wp_customize->add_setting( + 'woocommerce_thumbnail_cropping', + array( + 'default' => '1:1', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wc_clean', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_thumbnail_cropping_custom_width', + array( + 'default' => '4', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_thumbnail_cropping_custom_height', + array( + 'default' => '3', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'absint', + 'sanitize_js_callback' => 'absint', + ) + ); + + $wp_customize->add_control( + new WC_Customizer_Control_Cropping( + $wp_customize, + 'woocommerce_thumbnail_cropping', + array( + 'section' => 'woocommerce_product_images', + 'settings' => array( + 'cropping' => 'woocommerce_thumbnail_cropping', + 'custom_width' => 'woocommerce_thumbnail_cropping_custom_width', + 'custom_height' => 'woocommerce_thumbnail_cropping_custom_height', + ), + 'label' => __( 'Thumbnail cropping', 'woocommerce' ), + 'choices' => array( + '1:1' => array( + 'label' => __( '1:1', 'woocommerce' ), + 'description' => __( 'Images will be cropped into a square', 'woocommerce' ), + ), + 'custom' => array( + 'label' => __( 'Custom', 'woocommerce' ), + 'description' => __( 'Images will be cropped to a custom aspect ratio', 'woocommerce' ), + ), + 'uncropped' => array( + 'label' => __( 'Uncropped', 'woocommerce' ), + 'description' => __( 'Images will display using the aspect ratio in which they were uploaded', 'woocommerce' ), + ), + ), + ) + ) + ); + } + + /** + * Checkout section. + * + * @param WP_Customize_Manager $wp_customize Theme Customizer object. + */ + public function add_checkout_section( $wp_customize ) { + $wp_customize->add_section( + 'woocommerce_checkout', + array( + 'title' => __( 'Checkout', 'woocommerce' ), + 'priority' => 20, + 'panel' => 'woocommerce', + 'description' => __( 'These options let you change the appearance of the WooCommerce checkout.', 'woocommerce' ), + ) + ); + + // Checkout field controls. + $fields = array( + 'company' => __( 'Company name', 'woocommerce' ), + 'address_2' => __( 'Address line 2', 'woocommerce' ), + 'phone' => __( 'Phone', 'woocommerce' ), + ); + foreach ( $fields as $field => $label ) { + $wp_customize->add_setting( + 'woocommerce_checkout_' . $field . '_field', + array( + 'default' => 'phone' === $field ? 'required' : 'optional', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => array( $this, 'sanitize_checkout_field_display' ), + ) + ); + $wp_customize->add_control( + 'woocommerce_checkout_' . $field . '_field', + array( + /* Translators: %s field name. */ + 'label' => sprintf( __( '%s field', 'woocommerce' ), $label ), + 'section' => 'woocommerce_checkout', + 'settings' => 'woocommerce_checkout_' . $field . '_field', + 'type' => 'select', + 'choices' => array( + 'hidden' => __( 'Hidden', 'woocommerce' ), + 'optional' => __( 'Optional', 'woocommerce' ), + 'required' => __( 'Required', 'woocommerce' ), + ), + ) + ); + } + + // Register settings. + $wp_customize->add_setting( + 'woocommerce_checkout_highlight_required_fields', + array( + 'default' => 'yes', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wc_bool_to_string', + 'sanitize_js_callback' => 'wc_string_to_bool', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_checkout_terms_and_conditions_checkbox_text', + array( + /* translators: %s terms and conditions page name and link */ + 'default' => sprintf( __( 'I have read and agree to the website %s', 'woocommerce' ), '[terms]' ), + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wp_kses_post', + 'transport' => 'postMessage', + ) + ); + + $wp_customize->add_setting( + 'woocommerce_checkout_privacy_policy_text', + array( + /* translators: %s privacy policy page name and link */ + 'default' => sprintf( __( 'Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our %s.', 'woocommerce' ), '[privacy_policy]' ), + 'type' => 'option', + 'capability' => 'manage_woocommerce', + 'sanitize_callback' => 'wp_kses_post', + 'transport' => 'postMessage', + ) + ); + + // Register controls. + $wp_customize->add_control( + 'woocommerce_checkout_highlight_required_fields', + array( + 'label' => __( 'Highlight required fields with an asterisk', 'woocommerce' ), + 'section' => 'woocommerce_checkout', + 'settings' => 'woocommerce_checkout_highlight_required_fields', + 'type' => 'checkbox', + ) + ); + + $choose_pages = array( + 'wp_page_for_privacy_policy' => __( 'Privacy policy', 'woocommerce' ), + 'woocommerce_terms_page_id' => __( 'Terms and conditions', 'woocommerce' ), + ); + $pages = get_pages( array( + 'post_type' => 'page', + 'post_status' => 'publish,private,draft', + 'child_of' => 0, + 'parent' => -1, + 'exclude' => array( + wc_get_page_id( 'cart' ), + wc_get_page_id( 'checkout' ), + wc_get_page_id( 'myaccount' ), + ), + 'sort_order' => 'asc', + 'sort_column' => 'post_title', + ) ); + $page_choices = array( '' => __( 'No page set', 'woocommerce' ) ) + array_combine( array_map( 'strval', wp_list_pluck( $pages, 'ID' ) ), wp_list_pluck( $pages, 'post_title' ) ); + + foreach ( $choose_pages as $id => $name ) { + $wp_customize->add_setting( + $id, + array( + 'default' => '', + 'type' => 'option', + 'capability' => 'manage_woocommerce', + ) + ); + $wp_customize->add_control( + $id, + array( + /* Translators: %s: page name. */ + 'label' => sprintf( __( '%s page', 'woocommerce' ), $name ), + 'section' => 'woocommerce_checkout', + 'settings' => $id, + 'type' => 'select', + 'choices' => $page_choices, + ) + ); + } + + $wp_customize->add_control( + 'woocommerce_checkout_privacy_policy_text', + array( + 'label' => __( 'Privacy policy', 'woocommerce' ), + 'description' => __( 'Optionally add some text about your store privacy policy to show during checkout.', 'woocommerce' ), + 'section' => 'woocommerce_checkout', + 'settings' => 'woocommerce_checkout_privacy_policy_text', + 'active_callback' => 'wc_privacy_policy_page_id', + 'type' => 'textarea', + ) + ); + + $wp_customize->add_control( + 'woocommerce_checkout_terms_and_conditions_checkbox_text', + array( + 'label' => __( 'Terms and conditions', 'woocommerce' ), + 'description' => __( 'Optionally add some text for the terms checkbox that customers must accept.', 'woocommerce' ), + 'section' => 'woocommerce_checkout', + 'settings' => 'woocommerce_checkout_terms_and_conditions_checkbox_text', + 'active_callback' => 'wc_terms_and_conditions_page_id', + 'type' => 'text', + ) + ); + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( + 'woocommerce_checkout_privacy_policy_text', array( + 'selector' => '.woocommerce-privacy-policy-text', + 'container_inclusive' => true, + 'render_callback' => 'wc_checkout_privacy_policy_text', + ) + ); + $wp_customize->selective_refresh->add_partial( + 'woocommerce_checkout_terms_and_conditions_checkbox_text', array( + 'selector' => '.woocommerce-terms-and-conditions-checkbox-text', + 'container_inclusive' => false, + 'render_callback' => 'wc_terms_and_conditions_checkbox_text', + ) + ); + } + } + + /** + * Sanitize field display. + * + * @param string $value '', 'subcategories', or 'both'. + * @return string + */ + public function sanitize_checkout_field_display( $value ) { + $options = array( 'hidden', 'optional', 'required' ); + return in_array( $value, $options, true ) ? $value : ''; + } +} + +new WC_Shop_Customizer(); diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php new file mode 100644 index 0000000..f4dffe6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-data-store-cpt.php @@ -0,0 +1,388 @@ +set_version( WC_VERSION ); + $order->set_date_created( current_time( 'timestamp', true ) ); + $order->set_currency( $order->get_currency() ? $order->get_currency() : get_woocommerce_currency() ); + + $id = wp_insert_post( + apply_filters( + 'woocommerce_new_order_data', + array( + 'post_date' => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getTimestamp() ), + 'post_type' => $order->get_type( 'edit' ), + 'post_status' => 'wc-' . ( $order->get_status( 'edit' ) ? $order->get_status( 'edit' ) : apply_filters( 'woocommerce_default_order_status', 'pending' ) ), + 'ping_status' => 'closed', + 'post_author' => 1, + 'post_title' => $this->get_post_title(), + 'post_password' => uniqid( 'order_' ), + 'post_parent' => $order->get_parent_id( 'edit' ), + 'post_excerpt' => $this->get_post_excerpt( $order ), + ) + ), true + ); + + if ( $id && ! is_wp_error( $id ) ) { + $order->set_id( $id ); + $this->update_post_meta( $order ); + $order->save_meta_data(); + $order->apply_changes(); + $this->clear_caches( $order ); + } + } + + /** + * Method to read an order from the database. + * + * @param WC_Data $order Order object. + * + * @throws Exception If passed order is invalid. + */ + public function read( &$order ) { + $order->set_defaults(); + $post_object = get_post( $order->get_id() ); + + if ( ! $order->get_id() || ! $post_object || ! in_array( $post_object->post_type, wc_get_order_types(), true ) ) { + throw new Exception( __( 'Invalid order.', 'woocommerce' ) ); + } + + $order->set_props( + array( + 'parent_id' => $post_object->post_parent, + 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null, + 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null, + 'status' => $post_object->post_status, + ) + ); + + $this->read_order_data( $order, $post_object ); + $order->read_meta_data(); + $order->set_object_read( true ); + + /** + * In older versions, discounts may have been stored differently. + * Update them now so if the object is saved, the correct values are + * stored. @todo When meta is flattened, handle this during migration. + */ + if ( version_compare( $order->get_version( 'edit' ), '2.3.7', '<' ) && $order->get_prices_include_tax( 'edit' ) ) { + $order->set_discount_total( (double) get_post_meta( $order->get_id(), '_cart_discount', true ) - (double) get_post_meta( $order->get_id(), '_cart_discount_tax', true ) ); + } + } + + /** + * Method to update an order in the database. + * + * @param WC_Order $order Order object. + */ + public function update( &$order ) { + $order->save_meta_data(); + $order->set_version( WC_VERSION ); + + if ( null === $order->get_date_created( 'edit' ) ) { + $order->set_date_created( current_time( 'timestamp', true ) ); + } + + $changes = $order->get_changes(); + + // Only update the post when the post data changes. + if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'parent_id', 'post_excerpt' ), array_keys( $changes ) ) ) { + $post_data = array( + 'post_date' => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getTimestamp() ), + 'post_status' => 'wc-' . ( $order->get_status( 'edit' ) ? $order->get_status( 'edit' ) : apply_filters( 'woocommerce_default_order_status', 'pending' ) ), + 'post_parent' => $order->get_parent_id(), + 'post_excerpt' => $this->get_post_excerpt( $order ), + 'post_modified' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $order->get_date_modified( 'edit' )->getOffsetTimestamp() ) : current_time( 'mysql' ), + 'post_modified_gmt' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $order->get_date_modified( 'edit' )->getTimestamp() ) : current_time( 'mysql', 1 ), + ); + + /** + * When updating this object, to prevent infinite loops, use $wpdb + * to update data, since wp_update_post spawns more calls to the + * save_post action. + * + * This ensures hooks are fired by either WP itself (admin screen save), + * or an update purely from CRUD. + */ + if ( doing_action( 'save_post' ) ) { + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $order->get_id() ) ); + clean_post_cache( $order->get_id() ); + } else { + wp_update_post( array_merge( array( 'ID' => $order->get_id() ), $post_data ) ); + } + $order->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. + } + $this->update_post_meta( $order ); + $order->apply_changes(); + $this->clear_caches( $order ); + } + + /** + * Method to delete an order from the database. + * + * @param WC_Order $order Order object. + * @param array $args Array of args to pass to the delete method. + * + * @return void + */ + public function delete( &$order, $args = array() ) { + $id = $order->get_id(); + $args = wp_parse_args( + $args, + array( + 'force_delete' => false, + ) + ); + + if ( ! $id ) { + return; + } + + if ( $args['force_delete'] ) { + wp_delete_post( $id ); + $order->set_id( 0 ); + do_action( 'woocommerce_delete_order', $id ); + } else { + wp_trash_post( $id ); + $order->set_status( 'trash' ); + do_action( 'woocommerce_trash_order', $id ); + } + } + + /* + |-------------------------------------------------------------------------- + | Additional Methods + |-------------------------------------------------------------------------- + */ + + /** + * Excerpt for post. + * + * @param WC_order $order Order object. + * @return string + */ + protected function get_post_excerpt( $order ) { + return ''; + } + + /** + * Get a title for the new post type. + * + * @return string + */ + protected function get_post_title() { + // @codingStandardsIgnoreStart + /* translators: %s: Order date */ + return sprintf( __( 'Order – %s', 'woocommerce' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) ); + // @codingStandardsIgnoreEnd + } + + /** + * Read order data. Can be overridden by child classes to load other props. + * + * @param WC_Order $order Order object. + * @param object $post_object Post object. + * @since 3.0.0 + */ + protected function read_order_data( &$order, $post_object ) { + $id = $order->get_id(); + + $order->set_props( + array( + 'currency' => get_post_meta( $id, '_order_currency', true ), + 'discount_total' => get_post_meta( $id, '_cart_discount', true ), + 'discount_tax' => get_post_meta( $id, '_cart_discount_tax', true ), + 'shipping_total' => get_post_meta( $id, '_order_shipping', true ), + 'shipping_tax' => get_post_meta( $id, '_order_shipping_tax', true ), + 'cart_tax' => get_post_meta( $id, '_order_tax', true ), + 'total' => get_post_meta( $id, '_order_total', true ), + 'version' => get_post_meta( $id, '_order_version', true ), + 'prices_include_tax' => metadata_exists( 'post', $id, '_prices_include_tax' ) ? 'yes' === get_post_meta( $id, '_prices_include_tax', true ) : 'yes' === get_option( 'woocommerce_prices_include_tax' ), + ) + ); + + // Gets extra data associated with the order if needed. + foreach ( $order->get_extra_data_keys() as $key ) { + $function = 'set_' . $key; + if ( is_callable( array( $order, $function ) ) ) { + $order->{$function}( get_post_meta( $order->get_id(), '_' . $key, true ) ); + } + } + } + + /** + * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. + * + * @param WC_Order $order Order object. + * @since 3.0.0 + */ + protected function update_post_meta( &$order ) { + $updated_props = array(); + $meta_key_to_props = array( + '_order_currency' => 'currency', + '_cart_discount' => 'discount_total', + '_cart_discount_tax' => 'discount_tax', + '_order_shipping' => 'shipping_total', + '_order_shipping_tax' => 'shipping_tax', + '_order_tax' => 'cart_tax', + '_order_total' => 'total', + '_order_version' => 'version', + '_prices_include_tax' => 'prices_include_tax', + ); + + $props_to_update = $this->get_props_to_update( $order, $meta_key_to_props ); + + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $order->{"get_$prop"}( 'edit' ); + + if ( 'prices_include_tax' === $prop ) { + $value = $value ? 'yes' : 'no'; + } + + if ( update_post_meta( $order->get_id(), $meta_key, $value ) ) { + $updated_props[] = $prop; + } + } + + do_action( 'woocommerce_order_object_updated_props', $order, $updated_props ); + } + + /** + * Clear any caches. + * + * @param WC_Order $order Order object. + * @since 3.0.0 + */ + protected function clear_caches( &$order ) { + clean_post_cache( $order->get_id() ); + wc_delete_shop_order_transients( $order ); + wp_cache_delete( 'order-items-' . $order->get_id(), 'orders' ); + } + + /** + * Read order items of a specific type from the database for this order. + * + * @param WC_Order $order Order object. + * @param string $type Order item type. + * @return array + */ + public function read_items( $order, $type ) { + global $wpdb; + + // Get from cache if available. + $items = wp_cache_get( 'order-items-' . $order->get_id(), 'orders' ); + + if ( false === $items ) { + $items = $wpdb->get_results( + $wpdb->prepare( "SELECT order_item_type, order_item_id, order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d ORDER BY order_item_id;", $order->get_id() ) + ); + foreach ( $items as $item ) { + wp_cache_set( 'item-' . $item->order_item_id, $item, 'order-items' ); + } + wp_cache_set( 'order-items-' . $order->get_id(), $items, 'orders' ); + } + + $items = wp_list_filter( $items, array( 'order_item_type' => $type ) ); + + if ( ! empty( $items ) ) { + $items = array_map( array( 'WC_Order_Factory', 'get_order_item' ), array_combine( wp_list_pluck( $items, 'order_item_id' ), $items ) ); + } else { + $items = array(); + } + + return $items; + } + + /** + * Remove all line items (products, coupons, shipping, taxes) from the order. + * + * @param WC_Order $order Order object. + * @param string $type Order item type. Default null. + */ + public function delete_items( $order, $type = null ) { + global $wpdb; + if ( ! empty( $type ) ) { + $wpdb->query( $wpdb->prepare( "DELETE FROM itemmeta USING {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id AND items.order_id = %d AND items.order_item_type = %s", $order->get_id(), $type ) ); + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s", $order->get_id(), $type ) ); + } else { + $wpdb->query( $wpdb->prepare( "DELETE FROM itemmeta USING {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id and items.order_id = %d", $order->get_id() ) ); + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d", $order->get_id() ) ); + } + $this->clear_caches( $order ); + } + + /** + * Get token ids for an order. + * + * @param WC_Order $order Order object. + * @return array + */ + public function get_payment_token_ids( $order ) { + $token_ids = array_filter( (array) get_post_meta( $order->get_id(), '_payment_tokens', true ) ); + return $token_ids; + } + + /** + * Update token ids for an order. + * + * @param WC_Order $order Order object. + * @param array $token_ids Payment token ids. + */ + public function update_payment_token_ids( $order, $token_ids ) { + update_post_meta( $order->get_id(), '_payment_tokens', $token_ids ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php new file mode 100644 index 0000000..99beda7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/abstract-wc-order-item-type-data-store.php @@ -0,0 +1,163 @@ +insert( + $wpdb->prefix . 'woocommerce_order_items', array( + 'order_item_name' => $item->get_name(), + 'order_item_type' => $item->get_type(), + 'order_id' => $item->get_order_id(), + ) + ); + $item->set_id( $wpdb->insert_id ); + $this->save_item_data( $item ); + $item->save_meta_data(); + $item->apply_changes(); + $this->clear_cache( $item ); + + do_action( 'woocommerce_new_order_item', $item->get_id(), $item, $item->get_order_id() ); + } + + /** + * Update a order item in the database. + * + * @since 3.0.0 + * @param WC_Order_Item $item Order item object. + */ + public function update( &$item ) { + global $wpdb; + + $changes = $item->get_changes(); + + if ( array_intersect( array( 'name', 'order_id' ), array_keys( $changes ) ) ) { + $wpdb->update( + $wpdb->prefix . 'woocommerce_order_items', array( + 'order_item_name' => $item->get_name(), + 'order_item_type' => $item->get_type(), + 'order_id' => $item->get_order_id(), + ), array( 'order_item_id' => $item->get_id() ) + ); + } + + $this->save_item_data( $item ); + $item->save_meta_data(); + $item->apply_changes(); + $this->clear_cache( $item ); + + do_action( 'woocommerce_update_order_item', $item->get_id(), $item, $item->get_order_id() ); + } + + /** + * Remove an order item from the database. + * + * @since 3.0.0 + * @param WC_Order_Item $item Order item object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$item, $args = array() ) { + if ( $item->get_id() ) { + global $wpdb; + do_action( 'woocommerce_before_delete_order_item', $item->get_id() ); + $wpdb->delete( $wpdb->prefix . 'woocommerce_order_items', array( 'order_item_id' => $item->get_id() ) ); + $wpdb->delete( $wpdb->prefix . 'woocommerce_order_itemmeta', array( 'order_item_id' => $item->get_id() ) ); + do_action( 'woocommerce_delete_order_item', $item->get_id() ); + $this->clear_cache( $item ); + } + } + + /** + * Read a order item from the database. + * + * @since 3.0.0 + * + * @param WC_Order_Item $item Order item object. + * + * @throws Exception If invalid order item. + */ + public function read( &$item ) { + global $wpdb; + + $item->set_defaults(); + + // Get from cache if available. + $data = wp_cache_get( 'item-' . $item->get_id(), 'order-items' ); + + if ( false === $data ) { + $data = $wpdb->get_row( $wpdb->prepare( "SELECT order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d LIMIT 1;", $item->get_id() ) ); + wp_cache_set( 'item-' . $item->get_id(), $data, 'order-items' ); + } + + if ( ! $data ) { + throw new Exception( __( 'Invalid order item.', 'woocommerce' ) ); + } + + $item->set_props( + array( + 'order_id' => $data->order_id, + 'name' => $data->order_item_name, + ) + ); + $item->read_meta_data(); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $item->get_id() will be set. + * + * @since 3.0.0 + * @param WC_Order_Item $item Order item object. + */ + public function save_item_data( &$item ) {} + + /** + * Clear meta cache. + * + * @param WC_Order_Item $item Order item object. + */ + public function clear_cache( &$item ) { + wp_cache_delete( 'item-' . $item->get_id(), 'order-items' ); + wp_cache_delete( 'order-items-' . $item->get_order_id(), 'orders' ); + wp_cache_delete( $item->get_id(), $this->meta_type . '_meta' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php new file mode 100644 index 0000000..026f6b5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-coupon-data-store-cpt.php @@ -0,0 +1,398 @@ +set_date_created( current_time( 'timestamp', true ) ); + + $coupon_id = wp_insert_post( + apply_filters( + 'woocommerce_new_coupon_data', + array( + 'post_type' => 'shop_coupon', + 'post_status' => 'publish', + 'post_author' => get_current_user_id(), + 'post_title' => $coupon->get_code( 'edit' ), + 'post_content' => '', + 'post_excerpt' => $coupon->get_description( 'edit' ), + 'post_date' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created()->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created()->getTimestamp() ), + ) + ), true + ); + + if ( $coupon_id ) { + $coupon->set_id( $coupon_id ); + $this->update_post_meta( $coupon ); + $coupon->save_meta_data(); + $coupon->apply_changes(); + do_action( 'woocommerce_new_coupon', $coupon_id ); + } + } + + /** + * Method to read a coupon. + * + * @since 3.0.0 + * + * @param WC_Coupon $coupon Coupon object. + * + * @throws Exception If invalid coupon. + */ + public function read( &$coupon ) { + $coupon->set_defaults(); + + $post_object = get_post( $coupon->get_id() ); + + if ( ! $coupon->get_id() || ! $post_object || 'shop_coupon' !== $post_object->post_type ) { + throw new Exception( __( 'Invalid coupon.', 'woocommerce' ) ); + } + + $coupon_id = $coupon->get_id(); + $coupon->set_props( + array( + 'code' => $post_object->post_title, + 'description' => $post_object->post_excerpt, + 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null, + 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null, + 'date_expires' => metadata_exists( 'post', $coupon_id, 'date_expires' ) ? get_post_meta( $coupon_id, 'date_expires', true ) : get_post_meta( $coupon_id, 'expiry_date', true ), + 'discount_type' => get_post_meta( $coupon_id, 'discount_type', true ), + 'amount' => get_post_meta( $coupon_id, 'coupon_amount', true ), + 'usage_count' => get_post_meta( $coupon_id, 'usage_count', true ), + 'individual_use' => 'yes' === get_post_meta( $coupon_id, 'individual_use', true ), + 'product_ids' => array_filter( (array) explode( ',', get_post_meta( $coupon_id, 'product_ids', true ) ) ), + 'excluded_product_ids' => array_filter( (array) explode( ',', get_post_meta( $coupon_id, 'exclude_product_ids', true ) ) ), + 'usage_limit' => get_post_meta( $coupon_id, 'usage_limit', true ), + 'usage_limit_per_user' => get_post_meta( $coupon_id, 'usage_limit_per_user', true ), + 'limit_usage_to_x_items' => 0 < get_post_meta( $coupon_id, 'limit_usage_to_x_items', true ) ? get_post_meta( $coupon_id, 'limit_usage_to_x_items', true ) : null, + 'free_shipping' => 'yes' === get_post_meta( $coupon_id, 'free_shipping', true ), + 'product_categories' => array_filter( (array) get_post_meta( $coupon_id, 'product_categories', true ) ), + 'excluded_product_categories' => array_filter( (array) get_post_meta( $coupon_id, 'exclude_product_categories', true ) ), + 'exclude_sale_items' => 'yes' === get_post_meta( $coupon_id, 'exclude_sale_items', true ), + 'minimum_amount' => get_post_meta( $coupon_id, 'minimum_amount', true ), + 'maximum_amount' => get_post_meta( $coupon_id, 'maximum_amount', true ), + 'email_restrictions' => array_filter( (array) get_post_meta( $coupon_id, 'customer_email', true ) ), + 'used_by' => array_filter( (array) get_post_meta( $coupon_id, '_used_by' ) ), + ) + ); + $coupon->read_meta_data(); + $coupon->set_object_read( true ); + do_action( 'woocommerce_coupon_loaded', $coupon ); + } + + /** + * Updates a coupon in the database. + * + * @since 3.0.0 + * @param WC_Coupon $coupon Coupon object. + */ + public function update( &$coupon ) { + $coupon->save_meta_data(); + $changes = $coupon->get_changes(); + + if ( array_intersect( array( 'code', 'description', 'date_created', 'date_modified' ), array_keys( $changes ) ) ) { + $post_data = array( + 'post_title' => $coupon->get_code( 'edit' ), + 'post_excerpt' => $coupon->get_description( 'edit' ), + 'post_date' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $coupon->get_date_created( 'edit' )->getTimestamp() ), + 'post_modified' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $coupon->get_date_modified( 'edit' )->getOffsetTimestamp() ) : current_time( 'mysql' ), + 'post_modified_gmt' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $coupon->get_date_modified( 'edit' )->getTimestamp() ) : current_time( 'mysql', 1 ), + ); + + /** + * When updating this object, to prevent infinite loops, use $wpdb + * to update data, since wp_update_post spawns more calls to the + * save_post action. + * + * This ensures hooks are fired by either WP itself (admin screen save), + * or an update purely from CRUD. + */ + if ( doing_action( 'save_post' ) ) { + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $coupon->get_id() ) ); + clean_post_cache( $coupon->get_id() ); + } else { + wp_update_post( array_merge( array( 'ID' => $coupon->get_id() ), $post_data ) ); + } + $coupon->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. + } + $this->update_post_meta( $coupon ); + $coupon->apply_changes(); + do_action( 'woocommerce_update_coupon', $coupon->get_id() ); + } + + /** + * Deletes a coupon from the database. + * + * @since 3.0.0 + * + * @param WC_Coupon $coupon Coupon object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$coupon, $args = array() ) { + $args = wp_parse_args( + $args, array( + 'force_delete' => false, + ) + ); + + $id = $coupon->get_id(); + + if ( ! $id ) { + return; + } + + if ( $args['force_delete'] ) { + wp_delete_post( $id ); + + wp_cache_delete( WC_Cache_Helper::get_cache_prefix( 'coupons' ) . 'coupon_id_from_code_' . $coupon->get_code(), 'coupons' ); + + $coupon->set_id( 0 ); + do_action( 'woocommerce_delete_coupon', $id ); + } else { + wp_trash_post( $id ); + do_action( 'woocommerce_trash_coupon', $id ); + } + } + + /** + * Helper method that updates all the post meta for a coupon based on it's settings in the WC_Coupon class. + * + * @param WC_Coupon $coupon Coupon object. + * @since 3.0.0 + */ + private function update_post_meta( &$coupon ) { + $updated_props = array(); + $meta_key_to_props = array( + 'discount_type' => 'discount_type', + 'coupon_amount' => 'amount', + 'individual_use' => 'individual_use', + 'product_ids' => 'product_ids', + 'exclude_product_ids' => 'excluded_product_ids', + 'usage_limit' => 'usage_limit', + 'usage_limit_per_user' => 'usage_limit_per_user', + 'limit_usage_to_x_items' => 'limit_usage_to_x_items', + 'usage_count' => 'usage_count', + 'date_expires' => 'date_expires', + 'free_shipping' => 'free_shipping', + 'product_categories' => 'product_categories', + 'exclude_product_categories' => 'excluded_product_categories', + 'exclude_sale_items' => 'exclude_sale_items', + 'minimum_amount' => 'minimum_amount', + 'maximum_amount' => 'maximum_amount', + 'customer_email' => 'email_restrictions', + ); + + $props_to_update = $this->get_props_to_update( $coupon, $meta_key_to_props ); + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $coupon->{"get_$prop"}( 'edit' ); + switch ( $prop ) { + case 'individual_use': + case 'free_shipping': + case 'exclude_sale_items': + $updated = update_post_meta( $coupon->get_id(), $meta_key, wc_bool_to_string( $value ) ); + break; + case 'product_ids': + case 'excluded_product_ids': + $updated = update_post_meta( $coupon->get_id(), $meta_key, implode( ',', array_filter( array_map( 'intval', $value ) ) ) ); + break; + case 'product_categories': + case 'excluded_product_categories': + $updated = update_post_meta( $coupon->get_id(), $meta_key, array_filter( array_map( 'intval', $value ) ) ); + break; + case 'email_restrictions': + $updated = update_post_meta( $coupon->get_id(), $meta_key, array_filter( array_map( 'sanitize_email', $value ) ) ); + break; + case 'date_expires': + $updated = update_post_meta( $coupon->get_id(), $meta_key, ( $value ? $value->getTimestamp() : null ) ); + update_post_meta( $coupon->get_id(), 'expiry_date', ( $value ? $value->date( 'Y-m-d' ) : '' ) ); // Update the old meta key for backwards compatibility. + break; + default: + $updated = update_post_meta( $coupon->get_id(), $meta_key, $value ); + break; + } + if ( $updated ) { + $updated_props[] = $prop; + } + } + + do_action( 'woocommerce_coupon_object_updated_props', $coupon, $updated_props ); + } + + /** + * Increase usage count for current coupon. + * + * @since 3.0.0 + * @param WC_Coupon $coupon Coupon object. + * @param string $used_by Either user ID or billing email. + * @return int New usage count. + */ + public function increase_usage_count( &$coupon, $used_by = '' ) { + $new_count = $this->update_usage_count_meta( $coupon, 'increase' ); + if ( $used_by ) { + add_post_meta( $coupon->get_id(), '_used_by', strtolower( $used_by ) ); + $coupon->set_used_by( (array) get_post_meta( $coupon->get_id(), '_used_by' ) ); + } + return $new_count; + } + + /** + * Decrease usage count for current coupon. + * + * @since 3.0.0 + * @param WC_Coupon $coupon Coupon object. + * @param string $used_by Either user ID or billing email. + * @return int New usage count. + */ + public function decrease_usage_count( &$coupon, $used_by = '' ) { + global $wpdb; + $new_count = $this->update_usage_count_meta( $coupon, 'decrease' ); + if ( $used_by ) { + /** + * We're doing this the long way because `delete_post_meta( $id, $key, $value )` deletes. + * all instances where the key and value match, and we only want to delete one. + */ + $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_used_by' AND meta_value = %s AND post_id = %d LIMIT 1;", $used_by, $coupon->get_id() ) ); + if ( $meta_id ) { + delete_metadata_by_mid( 'post', $meta_id ); + $coupon->set_used_by( (array) get_post_meta( $coupon->get_id(), '_used_by' ) ); + } + } + return $new_count; + } + + /** + * Increase or decrease the usage count for a coupon by 1. + * + * @since 3.0.0 + * @param WC_Coupon $coupon Coupon object. + * @param string $operation 'increase' or 'decrease'. + * @return int New usage count + */ + private function update_usage_count_meta( &$coupon, $operation = 'increase' ) { + global $wpdb; + $id = $coupon->get_id(); + $operator = ( 'increase' === $operation ) ? '+' : '-'; + + add_post_meta( $id, 'usage_count', $coupon->get_usage_count( 'edit' ), true ); + $wpdb->query( + $wpdb->prepare( + "UPDATE $wpdb->postmeta SET meta_value = meta_value {$operator} 1 WHERE meta_key = 'usage_count' AND post_id = %d;", // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + $id + ) + ); + + // Get the latest value direct from the DB, instead of possibly the WP meta cache. + return (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'usage_count' AND post_id = %d;", $id ) ); + } + + /** + * Get the number of uses for a coupon by user ID. + * + * @since 3.0.0 + * @param WC_Coupon $coupon Coupon object. + * @param id $user_id User ID. + * @return int + */ + public function get_usage_by_user_id( &$coupon, $user_id ) { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( meta_id ) FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_used_by' AND meta_value = %d;", $coupon->get_id(), $user_id ) ); + } + + /** + * Return a coupon code for a specific ID. + * + * @since 3.0.0 + * @param int $id Coupon ID. + * @return string Coupon Code + */ + public function get_code_by_id( $id ) { + global $wpdb; + return $wpdb->get_var( + $wpdb->prepare( + "SELECT post_title + FROM $wpdb->posts + WHERE ID = %d + AND post_type = 'shop_coupon' + AND post_status = 'publish'", + $id + ) + ); + } + + /** + * Return an array of IDs for for a specific coupon code. + * Can return multiple to check for existence. + * + * @since 3.0.0 + * @param string $code Coupon code. + * @return array Array of IDs. + */ + public function get_ids_by_code( $code ) { + global $wpdb; + return $wpdb->get_col( + $wpdb->prepare( + "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'shop_coupon' AND post_status = 'publish' ORDER BY post_date DESC", + $code + ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php new file mode 100644 index 0000000..adaa2ac --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php @@ -0,0 +1,197 @@ +save_to_session( $customer ); + } + + /** + * Simply update the session. + * + * @param WC_Customer $customer Customer object. + */ + public function update( &$customer ) { + $this->save_to_session( $customer ); + } + + /** + * Saves all customer data to the session. + * + * @param WC_Customer $customer Customer object. + */ + public function save_to_session( $customer ) { + $data = array(); + foreach ( $this->session_keys as $session_key ) { + $function_key = $session_key; + if ( 'billing_' === substr( $session_key, 0, 8 ) ) { + $session_key = str_replace( 'billing_', '', $session_key ); + } + $data[ $session_key ] = (string) $customer->{"get_$function_key"}( 'edit' ); + } + WC()->session->set( 'customer', $data ); + } + + /** + * Read customer data from the session unless the user has logged in, in + * which case the stored ID will differ from the actual ID. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + */ + public function read( &$customer ) { + $data = (array) WC()->session->get( 'customer' ); + + /** + * There is a valid session if $data is not empty, and the ID matches the logged in user ID. + * + * If the user object has been updated since the session was created (based on date_modified) we should not load the session - data should be reloaded. + */ + if ( isset( $data['id'], $data['date_modified'] ) && $data['id'] === (string) $customer->get_id() && $data['date_modified'] === (string) $customer->get_date_modified( 'edit' ) ) { + foreach ( $this->session_keys as $session_key ) { + if ( in_array( $session_key, array( 'id', 'date_modified' ), true ) ) { + continue; + } + $function_key = $session_key; + if ( 'billing_' === substr( $session_key, 0, 8 ) ) { + $session_key = str_replace( 'billing_', '', $session_key ); + } + if ( ! empty( $data[ $session_key ] ) && is_callable( array( $customer, "set_{$function_key}" ) ) ) { + $customer->{"set_{$function_key}"}( wp_unslash( $data[ $session_key ] ) ); + } + } + } + $this->set_defaults( $customer ); + $customer->set_object_read( true ); + } + + /** + * Load default values if props are unset. + * + * @param WC_Customer $customer Customer object. + */ + protected function set_defaults( &$customer ) { + try { + $default = wc_get_customer_default_location(); + + if ( ! $customer->get_billing_country() ) { + $customer->set_billing_country( $default['country'] ); + } + + if ( ! $customer->get_shipping_country() ) { + $customer->set_shipping_country( $customer->get_billing_country() ); + } + + if ( ! $customer->get_billing_state() ) { + $customer->set_billing_state( $default['state'] ); + } + + if ( ! $customer->get_shipping_state() ) { + $customer->set_shipping_state( $customer->get_billing_state() ); + } + + if ( ! $customer->get_billing_email() && is_user_logged_in() ) { + $current_user = wp_get_current_user(); + $customer->set_billing_email( $current_user->user_email ); + } + } catch ( WC_Data_Exception $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch + } + } + + /** + * Deletes a customer from the database. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$customer, $args = array() ) { + WC()->session->set( 'customer', null ); + } + + /** + * Gets the customers last order. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return WC_Order|false + */ + public function get_last_order( &$customer ) { + return false; + } + + /** + * Return the number of orders this customer has. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return integer + */ + public function get_order_count( &$customer ) { + return 0; + } + + /** + * Return how much money this customer has spent. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return float + */ + public function get_total_spent( &$customer ) { + return 0; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php new file mode 100644 index 0000000..d907e61 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php @@ -0,0 +1,479 @@ +prefix ? $wpdb->prefix : 'wp_'; + + return ! in_array( $meta->meta_key, $this->internal_meta_keys, true ) + && 0 !== strpos( $meta->meta_key, '_woocommerce_persistent_cart' ) + && 0 !== strpos( $meta->meta_key, 'closedpostboxes_' ) + && 0 !== strpos( $meta->meta_key, 'metaboxhidden_' ) + && 0 !== strpos( $meta->meta_key, 'manageedit-' ) + && ! strstr( $meta->meta_key, $table_prefix ) + && 0 !== stripos( $meta->meta_key, 'wp_' ); + } + + /** + * Method to create a new customer in the database. + * + * @since 3.0.0 + * + * @param WC_Customer $customer Customer object. + * + * @throws WC_Data_Exception If unable to create new customer. + */ + public function create( &$customer ) { + $id = wc_create_new_customer( $customer->get_email(), $customer->get_username(), $customer->get_password() ); + + if ( is_wp_error( $id ) ) { + throw new WC_Data_Exception( $id->get_error_code(), $id->get_error_message() ); + } + + $customer->set_id( $id ); + $this->update_user_meta( $customer ); + + // Prevent wp_update_user calls in the same request and customer trigger the 'Notice of Password Changed' email. + $customer->set_password( '' ); + + wp_update_user( + apply_filters( + 'woocommerce_update_customer_args', array( + 'ID' => $customer->get_id(), + 'role' => $customer->get_role(), + 'display_name' => $customer->get_display_name(), + ), $customer + ) + ); + $wp_user = new WP_User( $customer->get_id() ); + $customer->set_date_created( $wp_user->user_registered ); + $customer->set_date_modified( get_user_meta( $customer->get_id(), 'last_update', true ) ); + $customer->save_meta_data(); + $customer->apply_changes(); + do_action( 'woocommerce_new_customer', $customer->get_id() ); + } + + /** + * Method to read a customer object. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @throws Exception If invalid customer. + */ + public function read( &$customer ) { + $user_object = $customer->get_id() ? get_user_by( 'id', $customer->get_id() ) : false; + + // User object is required. + if ( ! $user_object || empty( $user_object->ID ) ) { + throw new Exception( __( 'Invalid customer.', 'woocommerce' ) ); + } + + // Only users on this site should be read. + if ( is_multisite() && ! is_user_member_of_blog( $customer->get_id() ) ) { + throw new Exception( __( 'Invalid customer.', 'woocommerce' ) ); + } + + $customer_id = $customer->get_id(); + + // Load meta but exclude deprecated props. + $user_meta = array_diff_key( + array_map( 'wc_flatten_meta_callback', get_user_meta( $customer_id ) ), + array_flip( array( 'country', 'state', 'postcode', 'city', 'address', 'address_2', 'default', 'location' ) ) + ); + + $customer->set_props( $user_meta ); + $customer->set_props( + array( + 'is_paying_customer' => get_user_meta( $customer_id, 'paying_customer', true ), + 'email' => $user_object->user_email, + 'username' => $user_object->user_login, + 'display_name' => $user_object->display_name, + 'date_created' => $user_object->user_registered, // Mysql string in local format. + 'date_modified' => get_user_meta( $customer_id, 'last_update', true ), + 'role' => ! empty( $user_object->roles[0] ) ? $user_object->roles[0] : 'customer', + ) + ); + $customer->read_meta_data(); + $customer->set_object_read( true ); + do_action( 'woocommerce_customer_loaded', $customer ); + } + + /** + * Updates a customer in the database. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + */ + public function update( &$customer ) { + wp_update_user( + apply_filters( + 'woocommerce_update_customer_args', array( + 'ID' => $customer->get_id(), + 'user_email' => $customer->get_email(), + 'display_name' => $customer->get_display_name(), + ), $customer + ) + ); + + // Only update password if a new one was set with set_password. + if ( $customer->get_password() ) { + wp_update_user( + array( + 'ID' => $customer->get_id(), + 'user_pass' => $customer->get_password(), + ) + ); + $customer->set_password( '' ); + } + + $this->update_user_meta( $customer ); + $customer->set_date_modified( get_user_meta( $customer->get_id(), 'last_update', true ) ); + $customer->save_meta_data(); + $customer->apply_changes(); + do_action( 'woocommerce_update_customer', $customer->get_id() ); + } + + /** + * Deletes a customer from the database. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$customer, $args = array() ) { + if ( ! $customer->get_id() ) { + return; + } + + $args = wp_parse_args( + $args, array( + 'reassign' => 0, + ) + ); + + $id = $customer->get_id(); + wp_delete_user( $id, $args['reassign'] ); + + do_action( 'woocommerce_delete_customer', $id ); + } + + /** + * Helper method that updates all the meta for a customer. Used for update & create. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + */ + private function update_user_meta( $customer ) { + $updated_props = array(); + $changed_props = $customer->get_changes(); + + $meta_key_to_props = array( + 'paying_customer' => 'is_paying_customer', + 'first_name' => 'first_name', + 'last_name' => 'last_name', + ); + + foreach ( $meta_key_to_props as $meta_key => $prop ) { + if ( ! array_key_exists( $prop, $changed_props ) ) { + continue; + } + + if ( update_user_meta( $customer->get_id(), $meta_key, $customer->{"get_$prop"}( 'edit' ) ) ) { + $updated_props[] = $prop; + } + } + + $billing_address_props = array( + 'billing_first_name' => 'billing_first_name', + 'billing_last_name' => 'billing_last_name', + 'billing_company' => 'billing_company', + 'billing_address_1' => 'billing_address_1', + 'billing_address_2' => 'billing_address_2', + 'billing_city' => 'billing_city', + 'billing_state' => 'billing_state', + 'billing_postcode' => 'billing_postcode', + 'billing_country' => 'billing_country', + 'billing_email' => 'billing_email', + 'billing_phone' => 'billing_phone', + ); + + foreach ( $billing_address_props as $meta_key => $prop ) { + $prop_key = substr( $prop, 8 ); + + if ( ! isset( $changed_props['billing'] ) || ! array_key_exists( $prop_key, $changed_props['billing'] ) ) { + continue; + } + + if ( update_user_meta( $customer->get_id(), $meta_key, $customer->{"get_$prop"}( 'edit' ) ) ) { + $updated_props[] = $prop; + } + } + + $shipping_address_props = array( + 'shipping_first_name' => 'shipping_first_name', + 'shipping_last_name' => 'shipping_last_name', + 'shipping_company' => 'shipping_company', + 'shipping_address_1' => 'shipping_address_1', + 'shipping_address_2' => 'shipping_address_2', + 'shipping_city' => 'shipping_city', + 'shipping_state' => 'shipping_state', + 'shipping_postcode' => 'shipping_postcode', + 'shipping_country' => 'shipping_country', + ); + + foreach ( $shipping_address_props as $meta_key => $prop ) { + $prop_key = substr( $prop, 9 ); + + if ( ! isset( $changed_props['shipping'] ) || ! array_key_exists( $prop_key, $changed_props['shipping'] ) ) { + continue; + } + + if ( update_user_meta( $customer->get_id(), $meta_key, $customer->{"get_$prop"}( 'edit' ) ) ) { + $updated_props[] = $prop; + } + } + + do_action( 'woocommerce_customer_object_updated_props', $customer, $updated_props ); + } + + /** + * Gets the customers last order. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return WC_Order|false + */ + public function get_last_order( &$customer ) { + global $wpdb; + + $last_order = $wpdb->get_var( + // phpcs:disable WordPress.WP.PreparedSQL.NotPrepared + "SELECT posts.ID + FROM $wpdb->posts AS posts + LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id + WHERE meta.meta_key = '_customer_user' + AND meta.meta_value = '" . esc_sql( $customer->get_id() ) . "' + AND posts.post_type = 'shop_order' + AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' ) + ORDER BY posts.ID DESC" + // phpcs:enable + ); + + if ( ! $last_order ) { + return false; + } + + return wc_get_order( absint( $last_order ) ); + } + + /** + * Return the number of orders this customer has. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return integer + */ + public function get_order_count( &$customer ) { + $count = get_user_meta( $customer->get_id(), '_order_count', true ); + + if ( '' === $count ) { + global $wpdb; + + $count = $wpdb->get_var( + // phpcs:disable WordPress.WP.PreparedSQL.NotPrepared + "SELECT COUNT(*) + FROM $wpdb->posts as posts + LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id + WHERE meta.meta_key = '_customer_user' + AND posts.post_type = 'shop_order' + AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' ) + AND meta_value = '" . esc_sql( $customer->get_id() ) . "'" + // phpcs:enable + ); + update_user_meta( $customer->get_id(), '_order_count', $count ); + } + + return absint( $count ); + } + + /** + * Return how much money this customer has spent. + * + * @since 3.0.0 + * @param WC_Customer $customer Customer object. + * @return float + */ + public function get_total_spent( &$customer ) { + $spent = apply_filters( + 'woocommerce_customer_get_total_spent', + get_user_meta( $customer->get_id(), '_money_spent', true ), + $customer + ); + + if ( '' === $spent ) { + global $wpdb; + + $statuses = array_map( 'esc_sql', wc_get_is_paid_statuses() ); + $spent = $wpdb->get_var( + // phpcs:disable WordPress.WP.PreparedSQL.NotPrepared + apply_filters( + 'woocommerce_customer_get_total_spent_query', + "SELECT SUM(meta2.meta_value) + FROM $wpdb->posts as posts + LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id + LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id + WHERE meta.meta_key = '_customer_user' + AND meta.meta_value = '" . esc_sql( $customer->get_id() ) . "' + AND posts.post_type = 'shop_order' + AND posts.post_status IN ( 'wc-" . implode( "','wc-", $statuses ) . "' ) + AND meta2.meta_key = '_order_total'", + $customer + ) + // phpcs:enable + ); + + if ( ! $spent ) { + $spent = 0; + } + update_user_meta( $customer->get_id(), '_money_spent', $spent ); + } + + return wc_format_decimal( $spent, 2 ); + } + + /** + * Search customers and return customer IDs. + * + * @param string $term Search term. + * @param int|string $limit Limit search results. + * @since 3.0.7 + * + * @return array + */ + public function search_customers( $term, $limit = '' ) { + $results = apply_filters( 'woocommerce_customer_pre_search_customers', false, $term, $limit ); + if ( is_array( $results ) ) { + return $results; + } + + $query = new WP_User_Query( + apply_filters( + 'woocommerce_customer_search_customers', array( + 'search' => '*' . esc_attr( $term ) . '*', + 'search_columns' => array( 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name' ), + 'fields' => 'ID', + 'number' => $limit, + ), $term, $limit, 'main_query' + ) + ); + + $query2 = new WP_User_Query( + apply_filters( + 'woocommerce_customer_search_customers', array( + 'fields' => 'ID', + 'number' => $limit, + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'first_name', + 'value' => $term, + 'compare' => 'LIKE', + ), + array( + 'key' => 'last_name', + 'value' => $term, + 'compare' => 'LIKE', + ), + ), + ), $term, $limit, 'meta_query' + ) + ); + + $results = wp_parse_id_list( array_merge( (array) $query->get_results(), (array) $query2->get_results() ) ); + + if ( $limit && count( $results ) > $limit ) { + $results = array_slice( $results, 0, $limit ); + } + + return $results; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-data-store.php new file mode 100644 index 0000000..bd4ac73 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-data-store.php @@ -0,0 +1,446 @@ +get_access_granted( 'edit' ) ) ) { + $download->set_access_granted( current_time( 'timestamp', true ) ); + } + + $data = array( + 'download_id' => $download->get_download_id( 'edit' ), + 'product_id' => $download->get_product_id( 'edit' ), + 'user_id' => $download->get_user_id( 'edit' ), + 'user_email' => $download->get_user_email( 'edit' ), + 'order_id' => $download->get_order_id( 'edit' ), + 'order_key' => $download->get_order_key( 'edit' ), + 'downloads_remaining' => $download->get_downloads_remaining( 'edit' ), + 'access_granted' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ), + 'download_count' => $download->get_download_count( 'edit' ), + 'access_expires' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null, + ); + + $format = array( + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%d', + '%s', + ); + + $result = $wpdb->insert( + $wpdb->prefix . 'woocommerce_downloadable_product_permissions', + apply_filters( 'woocommerce_downloadable_file_permission_data', $data ), + apply_filters( 'woocommerce_downloadable_file_permission_format', $format, $data ) + ); + + do_action( 'woocommerce_grant_product_download_access', $data ); + + if ( $result ) { + $download->set_id( $wpdb->insert_id ); + $download->apply_changes(); + } + } + + /** + * Method to read a download permission from the database. + * + * @param WC_Customer_Download $download WC_Customer_Download object. + * + * @throws Exception Throw exception if invalid download is passed. + */ + public function read( &$download ) { + global $wpdb; + + if ( ! $download->get_id() ) { + throw new Exception( __( 'Invalid download.', 'woocommerce' ) ); + } + + $download->set_defaults(); + $raw_download = $wpdb->get_row( + $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE permission_id = %d", + $download->get_id() + ) + ); + + if ( ! $raw_download ) { + throw new Exception( __( 'Invalid download.', 'woocommerce' ) ); + } + + $download->set_props( + array( + 'download_id' => $raw_download->download_id, + 'product_id' => $raw_download->product_id, + 'user_id' => $raw_download->user_id, + 'user_email' => $raw_download->user_email, + 'order_id' => $raw_download->order_id, + 'order_key' => $raw_download->order_key, + 'downloads_remaining' => $raw_download->downloads_remaining, + 'access_granted' => strtotime( $raw_download->access_granted ), + 'download_count' => $raw_download->download_count, + 'access_expires' => is_null( $raw_download->access_expires ) ? null : strtotime( $raw_download->access_expires ), + ) + ); + $download->set_object_read( true ); + } + + /** + * Method to update a download in the database. + * + * @param WC_Customer_Download $download WC_Customer_Download object. + */ + public function update( &$download ) { + global $wpdb; + + $data = array( + 'download_id' => $download->get_download_id( 'edit' ), + 'product_id' => $download->get_product_id( 'edit' ), + 'user_id' => $download->get_user_id( 'edit' ), + 'user_email' => $download->get_user_email( 'edit' ), + 'order_id' => $download->get_order_id( 'edit' ), + 'order_key' => $download->get_order_key( 'edit' ), + 'downloads_remaining' => $download->get_downloads_remaining( 'edit' ), + 'access_granted' => date( 'Y-m-d', $download->get_access_granted( 'edit' )->getTimestamp() ), + 'download_count' => $download->get_download_count( 'edit' ), + 'access_expires' => ! is_null( $download->get_access_expires( 'edit' ) ) ? date( 'Y-m-d', $download->get_access_expires( 'edit' )->getTimestamp() ) : null, + ); + + $format = array( + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%s', + '%d', + '%s', + ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_downloadable_product_permissions', + $data, + array( + 'permission_id' => $download->get_id(), + ), + $format + ); + $download->apply_changes(); + } + + /** + * Method to delete a download permission from the database. + * + * @param WC_Customer_Download $download WC_Customer_Download object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$download, $args = array() ) { + global $wpdb; + + $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE permission_id = %d", + $download->get_id() + ) + ); + + $download->set_id( 0 ); + } + + /** + * Method to delete a download permission from the database by ID. + * + * @param int $id permission_id of the download to be deleted. + */ + public function delete_by_id( $id ) { + global $wpdb; + $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE permission_id = %d", + $id + ) + ); + } + + /** + * Method to delete a download permission from the database by order ID. + * + * @param int $id Order ID of the downloads that will be deleted. + */ + public function delete_by_order_id( $id ) { + global $wpdb; + $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE order_id = %d", + $id + ) + ); + } + + /** + * Method to delete a download permission from the database by download ID. + * + * @param int $id download_id of the downloads that will be deleted. + */ + public function delete_by_download_id( $id ) { + global $wpdb; + $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE download_id = %s", + $id + ) + ); + } + + /** + * Method to delete a download permission from the database by user ID. + * + * @since 3.4.0 + * @param int $id user ID of the downloads that will be deleted. + * @return bool True if deleted rows. + */ + public function delete_by_user_id( $id ) { + global $wpdb; + return (bool) $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE user_id = %d", + $id + ) + ); + } + + /** + * Method to delete a download permission from the database by user email. + * + * @since 3.4.0 + * @param string $email email of the downloads that will be deleted. + * @return bool True if deleted rows. + */ + public function delete_by_user_email( $email ) { + global $wpdb; + return (bool) $wpdb->query( + $wpdb->prepare( + "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions + WHERE user_email = %s", + $email + ) + ); + } + + /** + * Get a download object. + * + * @param array $data From the DB. + * @return WC_Customer_Download + */ + private function get_download( $data ) { + return new WC_Customer_Download( $data ); + } + + /** + * Get array of download ids by specified args. + * + * @param array $args Arguments to filter downloads. $args['return'] accepts the following values: 'objects' (default), 'ids' or a comma separeted list of fields (for example: 'order_id,user_id,user_email'). + * @return array Can be an array of permission_ids, an array of WC_Customer_Download objects or an array of arrays containing specified fields depending on the value of $args['return']. + */ + public function get_downloads( $args = array() ) { + global $wpdb; + + $args = wp_parse_args( + $args, array( + 'user_email' => '', + 'user_id' => '', + 'order_id' => '', + 'order_key' => '', + 'product_id' => '', + 'download_id' => '', + 'orderby' => 'permission_id', + 'order' => 'ASC', + 'limit' => -1, + 'page' => 1, + 'return' => 'objects', + ) + ); + + $valid_fields = array( 'permission_id', 'download_id', 'product_id', 'order_id', 'order_key', 'user_email', 'user_id', 'downloads_remaining', 'access_granted', 'access_expires', 'download_count' ); + $get_results_output = ARRAY_A; + + if ( 'ids' === $args['return'] ) { + $fields = 'permission_id'; + } elseif ( 'objects' === $args['return'] ) { + $fields = '*'; + $get_results_output = OBJECT; + } else { + $fields = explode( ',', (string) $args['return'] ); + $fields = implode( ', ', array_intersect( $fields, $valid_fields ) ); + } + + $query = array(); + $query[] = "SELECT {$fields} FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE 1=1"; + + if ( $args['user_email'] ) { + $query[] = $wpdb->prepare( 'AND user_email = %s', sanitize_email( $args['user_email'] ) ); + } + + if ( $args['user_id'] ) { + $query[] = $wpdb->prepare( 'AND user_id = %d', absint( $args['user_id'] ) ); + } + + if ( $args['order_id'] ) { + $query[] = $wpdb->prepare( 'AND order_id = %d', $args['order_id'] ); + } + + if ( $args['order_key'] ) { + $query[] = $wpdb->prepare( 'AND order_key = %s', $args['order_key'] ); + } + + if ( $args['product_id'] ) { + $query[] = $wpdb->prepare( 'AND product_id = %d', $args['product_id'] ); + } + + if ( $args['download_id'] ) { + $query[] = $wpdb->prepare( 'AND download_id = %s', $args['download_id'] ); + } + + $orderby = in_array( $args['orderby'], $valid_fields, true ) ? $args['orderby'] : 'permission_id'; + $order = 'DESC' === strtoupper( $args['order'] ) ? 'DESC' : 'ASC'; + $orderby_sql = sanitize_sql_orderby( "{$orderby} {$order}" ); + $query[] = "ORDER BY {$orderby_sql}"; + + if ( 0 < $args['limit'] ) { + $query[] = $wpdb->prepare( 'LIMIT %d, %d', absint( $args['limit'] ) * absint( $args['page'] - 1 ), absint( $args['limit'] ) ); + } + + // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + $results = $wpdb->get_results( implode( ' ', $query ), $get_results_output ); + + switch ( $args['return'] ) { + case 'ids': + return wp_list_pluck( $results, 'permission_id' ); + case 'objects': + return array_map( array( $this, 'get_download' ), $results ); + default: + return $results; + } + } + + /** + * Update download ids if the hash changes. + * + * @deprecated 3.3.0 Download id is now a static UUID and should not be changed based on file hash. + * + * @param int $product_id Product ID. + * @param string $old_id Old download_id. + * @param string $new_id New download_id. + */ + public function update_download_id( $product_id, $old_id, $new_id ) { + global $wpdb; + + wc_deprecated_function( __METHOD__, '3.3' ); + + $wpdb->update( + $wpdb->prefix . 'woocommerce_downloadable_product_permissions', + array( + 'download_id' => $new_id, + ), + array( + 'download_id' => $old_id, + 'product_id' => $product_id, + ) + ); + } + + /** + * Get a customers downloads. + * + * @param int $customer_id Customer ID. + * @return array + */ + public function get_downloads_for_customer( $customer_id ) { + global $wpdb; + + return $wpdb->get_results( + $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions as permissions + WHERE user_id = %d + AND permissions.order_id > 0 + AND + ( + permissions.downloads_remaining > 0 + OR permissions.downloads_remaining = '' + ) + AND + ( + permissions.access_expires IS NULL + OR permissions.access_expires >= %s + OR permissions.access_expires = '0000-00-00 00:00:00' + ) + ORDER BY permissions.order_id, permissions.product_id, permissions.permission_id;", + $customer_id, + date( 'Y-m-d', current_time( 'timestamp' ) ) + ) + ); + } + + /** + * Update user prop for downloads based on order id. + * + * @param int $order_id Order ID. + * @param int $customer_id Customer ID. + * @param string $email Customer email address. + */ + public function update_user_by_order_id( $order_id, $customer_id, $email ) { + global $wpdb; + $wpdb->update( + $wpdb->prefix . 'woocommerce_downloadable_product_permissions', + array( + 'user_id' => $customer_id, + 'user_email' => $email, + ), + array( + 'order_id' => $order_id, + ), + array( + '%d', + '%s', + ), + array( + '%d', + ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-log-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-log-data-store.php new file mode 100644 index 0000000..4cfea11 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-download-log-data-store.php @@ -0,0 +1,236 @@ +get_timestamp( 'edit' ) ) ) { + $download_log->set_timestamp( current_time( 'timestamp', true ) ); + } + + $data = array( + 'timestamp' => date( 'Y-m-d H:i:s', $download_log->get_timestamp( 'edit' )->getTimestamp() ), + 'permission_id' => $download_log->get_permission_id( 'edit' ), + 'user_id' => $download_log->get_user_id( 'edit' ), + 'user_ip_address' => $download_log->get_user_ip_address( 'edit' ), + ); + + $format = array( + '%s', + '%s', + '%s', + '%s', + ); + + $result = $wpdb->insert( + $wpdb->prefix . self::get_table_name(), + apply_filters( 'woocommerce_downloadable_product_download_log_insert_data', $data ), + apply_filters( 'woocommerce_downloadable_product_download_log_insert_format', $format, $data ) + ); + + do_action( 'woocommerce_downloadable_product_download_log_insert', $data ); + + if ( $result ) { + $download_log->set_id( $wpdb->insert_id ); + $download_log->apply_changes(); + } else { + wp_die( esc_html__( 'Unable to insert download log entry in database.', 'woocommerce' ) ); + } + } + + /** + * Method to read a download log from the database. + * + * @param WC_Customer_Download_Log $download_log Download log object. + * @throws Exception Exception when read is not possible. + */ + public function read( &$download_log ) { + global $wpdb; + + $download_log->set_defaults(); + + // Ensure we have an id to pull from the DB. + if ( ! $download_log->get_id() ) { + throw new Exception( __( 'Invalid download log: no ID.', 'woocommerce' ) ); + } + + $table = $wpdb->prefix . self::get_table_name(); + + // Query the DB for the download log. + $raw_download_log = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table} WHERE download_log_id = %d", $download_log->get_id() ) ); // WPCS: unprepared SQL ok. + + if ( ! $raw_download_log ) { + throw new Exception( __( 'Invalid download log: not found.', 'woocommerce' ) ); + } + + $download_log->set_props( + array( + 'timestamp' => strtotime( $raw_download_log->timestamp ), + 'permission_id' => $raw_download_log->permission_id, + 'user_id' => $raw_download_log->user_id, + 'user_ip_address' => $raw_download_log->user_ip_address, + ) + ); + + $download_log->set_object_read( true ); + } + + /** + * Method to update a download log in the database. + * + * @param WC_Customer_Download_Log $download_log Download log object. + */ + public function update( &$download_log ) { + global $wpdb; + + $data = array( + 'timestamp' => date( 'Y-m-d H:i:s', $download_log->get_timestamp( 'edit' )->getTimestamp() ), + 'permission_id' => $download_log->get_permission_id( 'edit' ), + 'user_id' => $download_log->get_user_id( 'edit' ), + 'user_ip_address' => $download_log->get_user_ip_address( 'edit' ), + ); + + $format = array( + '%s', + '%s', + '%s', + '%s', + ); + + $wpdb->update( + $wpdb->prefix . self::get_table_name(), + $data, + array( + 'download_log_id' => $download_log->get_id(), + ), + $format + ); + $download_log->apply_changes(); + } + + /** + * Get a download log object. + * + * @param array $data From the DB. + * @return WC_Customer_Download_Log + */ + private function get_download_log( $data ) { + return new WC_Customer_Download_Log( $data ); + } + + /** + * Get array of download log ids by specified args. + * + * @param array $args Arguments to define download logs to retrieve. + * @return array + */ + public function get_download_logs( $args = array() ) { + global $wpdb; + + $args = wp_parse_args( $args, array( + 'permission_id' => '', + 'user_id' => '', + 'user_ip_address' => '', + 'orderby' => 'download_log_id', + 'order' => 'DESC', + 'limit' => -1, + 'page' => 1, + 'return' => 'objects', + ) ); + + $query = array(); + $table = $wpdb->prefix . self::get_table_name(); + $query[] = "SELECT * FROM {$table} WHERE 1=1"; + + if ( $args['permission_id'] ) { + $query[] = $wpdb->prepare( 'AND permission_id = %d', $args['permission_id'] ); + } + + if ( $args['user_id'] ) { + $query[] = $wpdb->prepare( 'AND user_id = %d', $args['user_id'] ); + } + + if ( $args['user_ip_address'] ) { + $query[] = $wpdb->prepare( 'AND user_ip_address = %s', $args['user_ip_address'] ); + } + + $allowed_orders = array( 'download_log_id', 'timestamp', 'permission_id', 'user_id' ); + $order = in_array( $args['order'], $allowed_orders, true ) ? $args['order'] : 'download_log_id'; + $orderby = 'DESC' === strtoupper( $args['orderby'] ) ? 'DESC' : 'ASC'; + $orderby_sql = sanitize_sql_orderby( "{$order} {$orderby}" ); + $query[] = "ORDER BY {$orderby_sql}"; + + if ( 0 < $args['limit'] ) { + $query[] = $wpdb->prepare( 'LIMIT %d, %d', absint( $args['limit'] ) * absint( $args['page'] - 1 ), absint( $args['limit'] ) ); + } + + $raw_download_logs = $wpdb->get_results( implode( ' ', $query ) ); // WPCS: unprepared SQL ok. + + switch ( $args['return'] ) { + case 'ids': + return wp_list_pluck( $raw_download_logs, 'download_log_id' ); + default: + return array_map( array( $this, 'get_download_log' ), $raw_download_logs ); + } + } + + /** + * Get download logs for a given download permission. + * + * @param int $permission_id Permission to get logs for. + * @return array + */ + public function get_download_logs_for_permission( $permission_id ) { + // If no permission_id is passed, return an empty array. + if ( empty( $permission_id ) ) { + return array(); + } + + return $this->get_download_logs( + array( + 'permission_id' => $permission_id, + ) + ); + } + + /** + * Method to delete download logs for a given permission ID. + * + * @since 3.4.0 + * @param int $id download_id of the downloads that will be deleted. + */ + public function delete_by_permission_id( $id ) { + global $wpdb; + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE permission_id = %d", $id ) ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php new file mode 100644 index 0000000..f257477 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-data-store-wp.php @@ -0,0 +1,492 @@ +get_id(); + } + $terms = get_the_terms( $object_id, $taxonomy ); + if ( false === $terms || is_wp_error( $terms ) ) { + return array(); + } + return wp_list_pluck( $terms, 'term_id' ); + } + + /** + * Returns an array of meta for an object. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data object. + * @return array + */ + public function read_meta( &$object ) { + global $wpdb; + $db_info = $this->get_db_info(); + $raw_meta_data = $wpdb->get_results( + $wpdb->prepare( + // phpcs:disable WordPress.WP.PreparedSQL.NotPrepared + "SELECT {$db_info['meta_id_field']} as meta_id, meta_key, meta_value + FROM {$db_info['table']} + WHERE {$db_info['object_id_field']} = %d + ORDER BY {$db_info['meta_id_field']}", + // phpcs:enable + $object->get_id() + ) + ); + + $this->internal_meta_keys = array_merge( array_map( array( $this, 'prefix_key' ), $object->get_data_keys() ), $this->internal_meta_keys ); + $meta_data = array_filter( $raw_meta_data, array( $this, 'exclude_internal_meta_keys' ) ); + return apply_filters( "woocommerce_data_store_wp_{$this->meta_type}_read_meta", $meta_data, $object, $this ); + } + + /** + * Deletes meta based on meta ID. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data object. + * @param stdClass $meta (containing at least ->id). + */ + public function delete_meta( &$object, $meta ) { + delete_metadata_by_mid( $this->meta_type, $meta->id ); + } + + /** + * Add new piece of meta. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data object. + * @param stdClass $meta (containing ->key and ->value). + * @return int meta ID + */ + public function add_meta( &$object, $meta ) { + return add_metadata( $this->meta_type, $object->get_id(), $meta->key, is_string( $meta->value ) ? wp_slash( $meta->value ) : $meta->value, false ); + } + + /** + * Update meta. + * + * @since 3.0.0 + * @param WC_Data $object WC_Data object. + * @param stdClass $meta (containing ->id, ->key and ->value). + */ + public function update_meta( &$object, $meta ) { + update_metadata_by_mid( $this->meta_type, $meta->id, $meta->value, $meta->key ); + } + + /** + * Table structure is slightly different between meta types, this function will return what we need to know. + * + * @since 3.0.0 + * @return array Array elements: table, object_id_field, meta_id_field + */ + protected function get_db_info() { + global $wpdb; + + $meta_id_field = 'meta_id'; // for some reason users calls this umeta_id so we need to track this as well. + $table = $wpdb->prefix; + + // If we are dealing with a type of metadata that is not a core type, the table should be prefixed. + if ( ! in_array( $this->meta_type, array( 'post', 'user', 'comment', 'term' ), true ) ) { + $table .= 'woocommerce_'; + } + + $table .= $this->meta_type . 'meta'; + $object_id_field = $this->meta_type . '_id'; + + // Figure out our field names. + if ( 'user' === $this->meta_type ) { + $meta_id_field = 'umeta_id'; + $table = $wpdb->usermeta; + } + + if ( ! empty( $this->object_id_field_for_meta ) ) { + $object_id_field = $this->object_id_field_for_meta; + } + + return array( + 'table' => $table, + 'object_id_field' => $object_id_field, + 'meta_id_field' => $meta_id_field, + ); + } + + /** + * Internal meta keys we don't want exposed as part of meta_data. This is in + * addition to all data props with _ prefix. + * + * @since 2.6.0 + * + * @param string $key Prefix to be added to meta keys. + * @return string + */ + protected function prefix_key( $key ) { + return '_' === substr( $key, 0, 1 ) ? $key : '_' . $key; + } + + /** + * Callback to remove unwanted meta data. + * + * @param object $meta Meta object to check if it should be excluded or not. + * @return bool + */ + protected function exclude_internal_meta_keys( $meta ) { + return ! in_array( $meta->meta_key, $this->internal_meta_keys, true ) && 0 !== stripos( $meta->meta_key, 'wp_' ); + } + + /** + * Gets a list of props and meta keys that need updated based on change state + * or if they are present in the database or not. + * + * @param WC_Data $object The WP_Data object (WC_Coupon for coupons, etc). + * @param array $meta_key_to_props A mapping of meta keys => prop names. + * @param string $meta_type The internal WP meta type (post, user, etc). + * @return array A mapping of meta keys => prop names, filtered by ones that should be updated. + */ + protected function get_props_to_update( $object, $meta_key_to_props, $meta_type = 'post' ) { + $props_to_update = array(); + $changed_props = $object->get_changes(); + + // Props should be updated if they are a part of the $changed array or don't exist yet. + foreach ( $meta_key_to_props as $meta_key => $prop ) { + if ( array_key_exists( $prop, $changed_props ) || ! metadata_exists( $meta_type, $object->get_id(), $meta_key ) ) { + $props_to_update[ $meta_key ] = $prop; + } + } + + return $props_to_update; + } + + /** + * Get valid WP_Query args from a WC_Object_Query's query variables. + * + * @since 3.1.0 + * @param array $query_vars query vars from a WC_Object_Query. + * @return array + */ + protected function get_wp_query_args( $query_vars ) { + + $skipped_values = array( '', array(), null ); + $wp_query_args = array( + 'errors' => array(), + 'meta_query' => array(), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_query + ); + + foreach ( $query_vars as $key => $value ) { + if ( in_array( $value, $skipped_values, true ) || 'meta_query' === $key ) { + continue; + } + + // Build meta queries out of vars that are stored in internal meta keys. + if ( in_array( '_' . $key, $this->internal_meta_keys, true ) ) { + $wp_query_args['meta_query'][] = array( + 'key' => '_' . $key, + 'value' => $value, + 'compare' => is_array( $value ) ? 'IN' : '=', + ); + } else { // Other vars get mapped to wp_query args or just left alone. + $key_mapping = array( + 'parent' => 'post_parent', + 'parent_exclude' => 'post_parent__not_in', + 'exclude' => 'post__not_in', + 'limit' => 'posts_per_page', + 'type' => 'post_type', + 'return' => 'fields', + ); + + if ( isset( $key_mapping[ $key ] ) ) { + $wp_query_args[ $key_mapping[ $key ] ] = $value; + } else { + $wp_query_args[ $key ] = $value; + } + } + } + + return apply_filters( 'woocommerce_get_wp_query_args', $wp_query_args, $query_vars ); + } + + /** + * Map a valid date query var to WP_Query arguments. + * Valid date formats: YYYY-MM-DD or timestamp, possibly combined with an operator from $valid_operators. + * Also accepts a WC_DateTime object. + * + * @since 3.2.0 + * @param mixed $query_var A valid date format. + * @param string $key meta or db column key. + * @param array $wp_query_args WP_Query args. + * @return array Modified $wp_query_args + */ + public function parse_date_for_wp_query( $query_var, $key, $wp_query_args = array() ) { + $query_parse_regex = '/([^.<>]*)(>=|<=|>|<|\.\.\.)([^.<>]+)/'; + $valid_operators = array( '>', '>=', '=', '<=', '<', '...' ); + + // YYYY-MM-DD queries have 'day' precision. Timestamp/WC_DateTime queries have 'second' precision. + $precision = 'second'; + + $dates = array(); + $operator = '='; + + try { + // Specific time query with a WC_DateTime. + if ( is_a( $query_var, 'WC_DateTime' ) ) { + $dates[] = $query_var; + } elseif ( is_numeric( $query_var ) ) { // Specific time query with a timestamp. + $dates[] = new WC_DateTime( "@{$query_var}", new DateTimeZone( 'UTC' ) ); + } elseif ( preg_match( $query_parse_regex, $query_var, $sections ) ) { // Query with operators and possible range of dates. + if ( ! empty( $sections[1] ) ) { + $dates[] = is_numeric( $sections[1] ) ? new WC_DateTime( "@{$sections[1]}", new DateTimeZone( 'UTC' ) ) : wc_string_to_datetime( $sections[1] ); + } + + $operator = in_array( $sections[2], $valid_operators, true ) ? $sections[2] : ''; + $dates[] = is_numeric( $sections[3] ) ? new WC_DateTime( "@{$sections[3]}", new DateTimeZone( 'UTC' ) ) : wc_string_to_datetime( $sections[3] ); + + if ( ! is_numeric( $sections[1] ) && ! is_numeric( $sections[3] ) ) { + $precision = 'day'; + } + } else { // Specific time query with a string. + $dates[] = wc_string_to_datetime( $query_var ); + $precision = 'day'; + } + } catch ( Exception $e ) { + return $wp_query_args; + } + + // Check for valid inputs. + if ( ! $operator || empty( $dates ) || ( '...' === $operator && count( $dates ) < 2 ) ) { + return $wp_query_args; + } + + // Build date query for 'post_date' or 'post_modified' keys. + if ( 'post_date' === $key || 'post_modified' === $key ) { + if ( ! isset( $wp_query_args['date_query'] ) ) { + $wp_query_args['date_query'] = array(); + } + + $query_arg = array( + 'column' => 'day' === $precision ? $key : $key . '_gmt', + 'inclusive' => '>' !== $operator && '<' !== $operator, + ); + + // Add 'before'/'after' query args. + $comparisons = array(); + if ( '>' === $operator || '>=' === $operator || '...' === $operator ) { + $comparisons[] = 'after'; + } + if ( '<' === $operator || '<=' === $operator || '...' === $operator ) { + $comparisons[] = 'before'; + } + + foreach ( $comparisons as $index => $comparison ) { + if ( 'day' === $precision ) { + /** + * WordPress doesn't generate the correct SQL for inclusive day queries with both a 'before' and + * 'after' string query, so we have to use the array format in 'day' precision. + * + * @see https://core.trac.wordpress.org/ticket/29908 + */ + $query_arg[ $comparison ]['year'] = $dates[ $index ]->date( 'Y' ); + $query_arg[ $comparison ]['month'] = $dates[ $index ]->date( 'n' ); + $query_arg[ $comparison ]['day'] = $dates[ $index ]->date( 'j' ); + } else { + /** + * WordPress doesn't support 'hour'/'second'/'minute' in array format 'before'/'after' queries, + * so we have to use a string query. + */ + $query_arg[ $comparison ] = gmdate( 'm/d/Y H:i:s', $dates[ $index ]->getTimestamp() ); + } + } + + if ( empty( $comparisons ) ) { + $query_arg['year'] = $dates[0]->date( 'Y' ); + $query_arg['month'] = $dates[0]->date( 'n' ); + $query_arg['day'] = $dates[0]->date( 'j' ); + if ( 'second' === $precision ) { + $query_arg['hour'] = $dates[0]->date( 'H' ); + $query_arg['minute'] = $dates[0]->date( 'i' ); + $query_arg['second'] = $dates[0]->date( 's' ); + } + } + $wp_query_args['date_query'][] = $query_arg; + return $wp_query_args; + } + + // Build meta query for unrecognized keys. + if ( ! isset( $wp_query_args['meta_query'] ) ) { + $wp_query_args['meta_query'] = array(); // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_query + } + + // Meta dates are stored as timestamps in the db. + // Check against beginning/end-of-day timestamps when using 'day' precision. + if ( 'day' === $precision ) { + $start_timestamp = strtotime( gmdate( 'm/d/Y 00:00:00', $dates[0]->getTimestamp() ) ); + $end_timestamp = '...' !== $operator ? ( $start_timestamp + DAY_IN_SECONDS ) : strtotime( gmdate( 'm/d/Y 00:00:00', $dates[1]->getTimestamp() ) ); + switch ( $operator ) { + case '>': + case '<=': + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $end_timestamp, + 'compare' => $operator, + ); + break; + case '<': + case '>=': + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $start_timestamp, + 'compare' => $operator, + ); + break; + default: + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $start_timestamp, + 'compare' => '>=', + ); + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $end_timestamp, + 'compare' => '<=', + ); + } + } else { + if ( '...' !== $operator ) { + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $dates[0]->getTimestamp(), + 'compare' => $operator, + ); + } else { + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $dates[0]->getTimestamp(), + 'compare' => '>=', + ); + $wp_query_args['meta_query'][] = array( + 'key' => $key, + 'value' => $dates[1]->getTimestamp(), + 'compare' => '<=', + ); + } + } + + return $wp_query_args; + } + + /** + * Return list of internal meta keys. + * + * @since 3.2.0 + * @return array + */ + public function get_internal_meta_keys() { + return $this->internal_meta_keys; + } + + /** + * Check if the terms are suitable for searching. + * + * Uses an array of stopwords (terms) that are excluded from the separate + * term matching when searching for posts. The list of English stopwords is + * the approximate search engines list, and is translatable. + * + * @since 3.4.0 + * @param array $terms Terms to check. + * @return array Terms that are not stopwords. + */ + protected function get_valid_search_terms( $terms ) { + $valid_terms = array(); + $stopwords = $this->get_search_stopwords(); + + foreach ( $terms as $term ) { + // keep before/after spaces when term is for exact match, otherwise trim quotes and spaces. + if ( preg_match( '/^".+"$/', $term ) ) { + $term = trim( $term, "\"'" ); + } else { + $term = trim( $term, "\"' " ); + } + + // Avoid single A-Z and single dashes. + if ( empty( $term ) || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) ) { + continue; + } + + if ( in_array( wc_strtolower( $term ), $stopwords, true ) ) { + continue; + } + + $valid_terms[] = $term; + } + + return $valid_terms; + } + + /** + * Retrieve stopwords used when parsing search terms. + * + * @since 3.4.0 + * @return array Stopwords. + */ + protected function get_search_stopwords() { + // Translators: This is a comma-separated list of very common words that should be excluded from a search, like a, an, and the. These are usually called "stopwords". You should not simply translate these individual words into your language. Instead, look for and provide commonly accepted stopwords in your language. + $stopwords = array_map( 'wc_strtolower', array_map( 'trim', explode( + ',', _x( + 'about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www', + 'Comma-separated list of search stopwords in your language', + 'woocommerce' + ) + ) ) ); + + return apply_filters( 'wp_search_stopwords', $stopwords ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php new file mode 100644 index 0000000..2cc5b7e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php @@ -0,0 +1,773 @@ +set_order_key( 'wc_' . apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ) ); + parent::create( $order ); + do_action( 'woocommerce_new_order', $order->get_id() ); + } + + /** + * Read order data. Can be overridden by child classes to load other props. + * + * @param WC_Order $order Order object. + * @param object $post_object Post object. + * @since 3.0.0 + */ + protected function read_order_data( &$order, $post_object ) { + parent::read_order_data( $order, $post_object ); + $id = $order->get_id(); + $date_completed = get_post_meta( $id, '_date_completed', true ); + $date_paid = get_post_meta( $id, '_date_paid', true ); + + if ( ! $date_completed ) { + $date_completed = get_post_meta( $id, '_completed_date', true ); + } + + if ( ! $date_paid ) { + $date_paid = get_post_meta( $id, '_paid_date', true ); + } + + $order->set_props( + array( + 'order_key' => get_post_meta( $id, '_order_key', true ), + 'customer_id' => get_post_meta( $id, '_customer_user', true ), + 'billing_first_name' => get_post_meta( $id, '_billing_first_name', true ), + 'billing_last_name' => get_post_meta( $id, '_billing_last_name', true ), + 'billing_company' => get_post_meta( $id, '_billing_company', true ), + 'billing_address_1' => get_post_meta( $id, '_billing_address_1', true ), + 'billing_address_2' => get_post_meta( $id, '_billing_address_2', true ), + 'billing_city' => get_post_meta( $id, '_billing_city', true ), + 'billing_state' => get_post_meta( $id, '_billing_state', true ), + 'billing_postcode' => get_post_meta( $id, '_billing_postcode', true ), + 'billing_country' => get_post_meta( $id, '_billing_country', true ), + 'billing_email' => get_post_meta( $id, '_billing_email', true ), + 'billing_phone' => get_post_meta( $id, '_billing_phone', true ), + 'shipping_first_name' => get_post_meta( $id, '_shipping_first_name', true ), + 'shipping_last_name' => get_post_meta( $id, '_shipping_last_name', true ), + 'shipping_company' => get_post_meta( $id, '_shipping_company', true ), + 'shipping_address_1' => get_post_meta( $id, '_shipping_address_1', true ), + 'shipping_address_2' => get_post_meta( $id, '_shipping_address_2', true ), + 'shipping_city' => get_post_meta( $id, '_shipping_city', true ), + 'shipping_state' => get_post_meta( $id, '_shipping_state', true ), + 'shipping_postcode' => get_post_meta( $id, '_shipping_postcode', true ), + 'shipping_country' => get_post_meta( $id, '_shipping_country', true ), + 'payment_method' => get_post_meta( $id, '_payment_method', true ), + 'payment_method_title' => get_post_meta( $id, '_payment_method_title', true ), + 'transaction_id' => get_post_meta( $id, '_transaction_id', true ), + 'customer_ip_address' => get_post_meta( $id, '_customer_ip_address', true ), + 'customer_user_agent' => get_post_meta( $id, '_customer_user_agent', true ), + 'created_via' => get_post_meta( $id, '_created_via', true ), + 'date_completed' => $date_completed, + 'date_paid' => $date_paid, + 'cart_hash' => get_post_meta( $id, '_cart_hash', true ), + 'customer_note' => $post_object->post_excerpt, + ) + ); + } + + /** + * Method to update an order in the database. + * + * @param WC_Order $order Order object. + */ + public function update( &$order ) { + // Before updating, ensure date paid is set if missing. + if ( ! $order->get_date_paid( 'edit' ) && version_compare( $order->get_version( 'edit' ), '3.0', '<' ) && $order->has_status( apply_filters( 'woocommerce_payment_complete_order_status', $order->needs_processing() ? 'processing' : 'completed', $order->get_id(), $order ) ) ) { + $order->set_date_paid( $order->get_date_created( 'edit' ) ); + } + + // Update the order. + parent::update( $order ); + + do_action( 'woocommerce_update_order', $order->get_id() ); + } + + /** + * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. + * + * @param WC_Order $order Order object. + * @since 3.0.0 + */ + protected function update_post_meta( &$order ) { + $updated_props = array(); + $id = $order->get_id(); + $meta_key_to_props = array( + '_order_key' => 'order_key', + '_customer_user' => 'customer_id', + '_payment_method' => 'payment_method', + '_payment_method_title' => 'payment_method_title', + '_transaction_id' => 'transaction_id', + '_customer_ip_address' => 'customer_ip_address', + '_customer_user_agent' => 'customer_user_agent', + '_created_via' => 'created_via', + '_date_completed' => 'date_completed', + '_date_paid' => 'date_paid', + '_cart_hash' => 'cart_hash', + ); + + $props_to_update = $this->get_props_to_update( $order, $meta_key_to_props ); + + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $order->{"get_$prop"}( 'edit' ); + + if ( 'date_paid' === $prop ) { + // In 3.0.x we store this as a UTC timestamp. + update_post_meta( $id, $meta_key, ! is_null( $value ) ? $value->getTimestamp() : '' ); + + // In 2.6.x date_paid was stored as _paid_date in local mysql format. + update_post_meta( $id, '_paid_date', ! is_null( $value ) ? $value->date( 'Y-m-d H:i:s' ) : '' ); + + } elseif ( 'date_completed' === $prop ) { + // In 3.0.x we store this as a UTC timestamp. + update_post_meta( $id, $meta_key, ! is_null( $value ) ? $value->getTimestamp() : '' ); + + // In 2.6.x date_paid was stored as _paid_date in local mysql format. + update_post_meta( $id, '_completed_date', ! is_null( $value ) ? $value->date( 'Y-m-d H:i:s' ) : '' ); + + } else { + update_post_meta( $id, $meta_key, $value ); + } + + $updated_props[] = $prop; + } + + $address_props = array( + 'billing' => array( + '_billing_first_name' => 'billing_first_name', + '_billing_last_name' => 'billing_last_name', + '_billing_company' => 'billing_company', + '_billing_address_1' => 'billing_address_1', + '_billing_address_2' => 'billing_address_2', + '_billing_city' => 'billing_city', + '_billing_state' => 'billing_state', + '_billing_postcode' => 'billing_postcode', + '_billing_country' => 'billing_country', + '_billing_email' => 'billing_email', + '_billing_phone' => 'billing_phone', + ), + 'shipping' => array( + '_shipping_first_name' => 'shipping_first_name', + '_shipping_last_name' => 'shipping_last_name', + '_shipping_company' => 'shipping_company', + '_shipping_address_1' => 'shipping_address_1', + '_shipping_address_2' => 'shipping_address_2', + '_shipping_city' => 'shipping_city', + '_shipping_state' => 'shipping_state', + '_shipping_postcode' => 'shipping_postcode', + '_shipping_country' => 'shipping_country', + ), + ); + + foreach ( $address_props as $props_key => $props ) { + $props_to_update = $this->get_props_to_update( $order, $props ); + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $order->{"get_$prop"}( 'edit' ); + update_post_meta( $id, $meta_key, $value ); + $updated_props[] = $prop; + $updated_props[] = $props_key; + } + } + + parent::update_post_meta( $order ); + + // If address changed, store concatenated version to make searches faster. + if ( in_array( 'billing', $updated_props, true ) || ! metadata_exists( 'post', $id, '_billing_address_index' ) ) { + update_post_meta( $id, '_billing_address_index', implode( ' ', $order->get_address( 'billing' ) ) ); + } + if ( in_array( 'shipping', $updated_props, true ) || ! metadata_exists( 'post', $id, '_shipping_address_index' ) ) { + update_post_meta( $id, '_shipping_address_index', implode( ' ', $order->get_address( 'shipping' ) ) ); + } + + // If customer changed, update any downloadable permissions. + if ( in_array( 'customer_id', $updated_props, true ) || in_array( 'billing_email', $updated_props, true ) ) { + $data_store = WC_Data_Store::load( 'customer-download' ); + $data_store->update_user_by_order_id( $id, $order->get_customer_id(), $order->get_billing_email() ); + } + + // Mark user account as active. + if ( in_array( 'customer_id', $updated_props, true ) ) { + wc_update_user_last_active( $order->get_customer_id() ); + } + + do_action( 'woocommerce_order_object_updated_props', $order, $updated_props ); + } + + /** + * Excerpt for post. + * + * @param WC_Order $order Order object. + * @return string + */ + protected function get_post_excerpt( $order ) { + return $order->get_customer_note(); + } + + /** + * Get amount already refunded. + * + * @param WC_Order $order Order object. + * @return float + */ + public function get_total_refunded( $order ) { + global $wpdb; + + $total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM( postmeta.meta_value ) + FROM $wpdb->postmeta AS postmeta + INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) + WHERE postmeta.meta_key = '_refund_amount' + AND postmeta.post_id = posts.ID", + $order->get_id() + ) + ); + + return floatval( $total ); + } + + /** + * Get the total tax refunded. + * + * @param WC_Order $order Order object. + * @return float + */ + public function get_total_tax_refunded( $order ) { + global $wpdb; + + $total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM( order_itemmeta.meta_value ) + FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta + INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) + INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'tax' ) + WHERE order_itemmeta.order_item_id = order_items.order_item_id + AND order_itemmeta.meta_key IN ('tax_amount', 'shipping_tax_amount')", + $order->get_id() + ) + ); + + return abs( $total ); + } + + /** + * Get the total shipping refunded. + * + * @param WC_Order $order Order object. + * @return float + */ + public function get_total_shipping_refunded( $order ) { + global $wpdb; + + $total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM( order_itemmeta.meta_value ) + FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta + INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) + INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' ) + WHERE order_itemmeta.order_item_id = order_items.order_item_id + AND order_itemmeta.meta_key IN ('cost')", + $order->get_id() + ) + ); + + return abs( $total ); + } + + /** + * Finds an Order ID based on an order key. + * + * @param string $order_key An order key has generated by. + * @return int The ID of an order, or 0 if the order could not be found + */ + public function get_order_id_by_order_key( $order_key ) { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = '_order_key' AND meta_value = %s", $order_key ) ); + } + + /** + * Return count of orders with a specific status. + * + * @param string $status Order status. Function wc_get_order_statuses() returns a list of valid statuses. + * @return int + */ + public function get_order_count( $status ) { + global $wpdb; + return absint( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_status = %s", $status ) ) ); + } + + /** + * Get all orders matching the passed in args. + * + * @deprecated 3.1.0 - Use wc_get_orders instead. + * @see wc_get_orders() + * + * @param array $args List of args passed to wc_get_orders(). + * + * @return array|object + */ + public function get_orders( $args = array() ) { + wc_deprecated_function( 'WC_Order_Data_Store_CPT::get_orders', '3.1.0', 'Use wc_get_orders instead.' ); + return wc_get_orders( $args ); + } + + /** + * Generate meta query for wc_get_orders. + * + * @param array $values List of customers ids or emails. + * @param string $relation 'or' or 'and' relation used to build the WP meta_query. + * @return array + */ + private function get_orders_generate_customer_meta_query( $values, $relation = 'or' ) { + $meta_query = array( + 'relation' => strtoupper( $relation ), + 'customer_emails' => array( + 'key' => '_billing_email', + 'value' => array(), + 'compare' => 'IN', + ), + 'customer_ids' => array( + 'key' => '_customer_user', + 'value' => array(), + 'compare' => 'IN', + ), + ); + foreach ( $values as $value ) { + if ( is_array( $value ) ) { + $query_part = $this->get_orders_generate_customer_meta_query( $value, 'and' ); + if ( is_wp_error( $query_part ) ) { + return $query_part; + } + $meta_query[] = $query_part; + } elseif ( is_email( $value ) ) { + $meta_query['customer_emails']['value'][] = sanitize_email( $value ); + } elseif ( is_numeric( $value ) ) { + $meta_query['customer_ids']['value'][] = strval( absint( $value ) ); + } else { + return new WP_Error( 'woocommerce_query_invalid', __( 'Invalid customer query.', 'woocommerce' ), $values ); + } + } + + if ( empty( $meta_query['customer_emails']['value'] ) ) { + unset( $meta_query['customer_emails'] ); + unset( $meta_query['relation'] ); + } + + if ( empty( $meta_query['customer_ids']['value'] ) ) { + unset( $meta_query['customer_ids'] ); + unset( $meta_query['relation'] ); + } + + return $meta_query; + } + + /** + * Get unpaid orders after a certain date, + * + * @param int $date Timestamp. + * @return array + */ + public function get_unpaid_orders( $date ) { + global $wpdb; + + $unpaid_orders = $wpdb->get_col( + $wpdb->prepare( + // @codingStandardsIgnoreStart + "SELECT posts.ID + FROM {$wpdb->posts} AS posts + WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "') + AND posts.post_status = 'wc-pending' + AND posts.post_modified < %s", + // @codingStandardsIgnoreEnd + date( 'Y-m-d H:i:s', absint( $date ) ) + ) + ); + + return $unpaid_orders; + } + + /** + * Search order data for a term and return ids. + * + * @param string $term Searched term. + * @return array of ids + */ + public function search_orders( $term ) { + global $wpdb; + + /** + * Searches on meta data can be slow - this lets you choose what fields to search. + * 3.0.0 added _billing_address and _shipping_address meta which contains all address data to make this faster. + * This however won't work on older orders unless updated, so search a few others (expand this using the filter if needed). + * + * @var array + */ + $search_fields = array_map( + 'wc_clean', apply_filters( + 'woocommerce_shop_order_search_fields', array( + '_billing_address_index', + '_shipping_address_index', + '_billing_last_name', + '_billing_email', + ) + ) + ); + $order_ids = array(); + + if ( is_numeric( $term ) ) { + $order_ids[] = absint( $term ); + } + + if ( ! empty( $search_fields ) ) { + $order_ids = array_unique( + array_merge( + $order_ids, + $wpdb->get_col( + $wpdb->prepare( + "SELECT DISTINCT p1.post_id FROM {$wpdb->postmeta} p1 WHERE p1.meta_value LIKE %s AND p1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', $search_fields ) ) . "')", // @codingStandardsIgnoreLine + '%' . $wpdb->esc_like( wc_clean( $term ) ) . '%' + ) + ), + $wpdb->get_col( + $wpdb->prepare( + "SELECT order_id + FROM {$wpdb->prefix}woocommerce_order_items as order_items + WHERE order_item_name LIKE %s", + '%' . $wpdb->esc_like( wc_clean( $term ) ) . '%' + ) + ) + ) + ); + } + + return apply_filters( 'woocommerce_shop_order_search_results', $order_ids, $term, $search_fields ); + } + + /** + * Gets information about whether permissions were generated yet. + * + * @param WC_Order|int $order Order ID or order object. + * @return bool + */ + public function get_download_permissions_granted( $order ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + return wc_string_to_bool( get_post_meta( $order_id, '_download_permissions_granted', true ) ); + } + + /** + * Stores information about whether permissions were generated yet. + * + * @param WC_Order|int $order Order ID or order object. + * @param bool $set True or false. + */ + public function set_download_permissions_granted( $order, $set ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + update_post_meta( $order_id, '_download_permissions_granted', wc_bool_to_string( $set ) ); + } + + /** + * Gets information about whether sales were recorded. + * + * @param WC_Order|int $order Order ID or order object. + * @return bool + */ + public function get_recorded_sales( $order ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + return wc_string_to_bool( get_post_meta( $order_id, '_recorded_sales', true ) ); + } + + /** + * Stores information about whether sales were recorded. + * + * @param WC_Order|int $order Order ID or order object. + * @param bool $set True or false. + */ + public function set_recorded_sales( $order, $set ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + update_post_meta( $order_id, '_recorded_sales', wc_bool_to_string( $set ) ); + } + + /** + * Gets information about whether coupon counts were updated. + * + * @param WC_Order|int $order Order ID or order object. + * @return bool + */ + public function get_recorded_coupon_usage_counts( $order ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + return wc_string_to_bool( get_post_meta( $order_id, '_recorded_coupon_usage_counts', true ) ); + } + + /** + * Stores information about whether coupon counts were updated. + * + * @param WC_Order|int $order Order ID or order object. + * @param bool $set True or false. + */ + public function set_recorded_coupon_usage_counts( $order, $set ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + update_post_meta( $order_id, '_recorded_coupon_usage_counts', wc_bool_to_string( $set ) ); + } + + /** + * Gets information about whether stock was reduced. + * + * @param WC_Order|int $order Order ID or order object. + * @return bool + */ + public function get_stock_reduced( $order ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + return wc_string_to_bool( get_post_meta( $order_id, '_order_stock_reduced', true ) ); + } + + /** + * Stores information about whether stock was reduced. + * + * @param WC_Order|int $order Order ID or order object. + * @param bool $set True or false. + */ + public function set_stock_reduced( $order, $set ) { + $order_id = WC_Order_Factory::get_order_id( $order ); + update_post_meta( $order_id, '_order_stock_reduced', wc_bool_to_string( $set ) ); + } + + /** + * Get the order type based on Order ID. + * + * @since 3.0.0 + * @param int $order_id Order ID. + * @return string + */ + public function get_order_type( $order_id ) { + return get_post_type( $order_id ); + } + + /** + * Get valid WP_Query args from a WC_Order_Query's query variables. + * + * @since 3.1.0 + * @param array $query_vars query vars from a WC_Order_Query. + * @return array + */ + protected function get_wp_query_args( $query_vars ) { + + // Map query vars to ones that get_wp_query_args or WP_Query recognize. + $key_mapping = array( + 'customer_id' => 'customer_user', + 'status' => 'post_status', + 'currency' => 'order_currency', + 'version' => 'order_version', + 'discount_total' => 'cart_discount', + 'discount_tax' => 'cart_discount_tax', + 'shipping_total' => 'order_shipping', + 'shipping_tax' => 'order_shipping_tax', + 'cart_tax' => 'order_tax', + 'total' => 'order_total', + 'page' => 'paged', + ); + + foreach ( $key_mapping as $query_key => $db_key ) { + if ( isset( $query_vars[ $query_key ] ) ) { + $query_vars[ $db_key ] = $query_vars[ $query_key ]; + unset( $query_vars[ $query_key ] ); + } + } + + // Add the 'wc-' prefix to status if needed. + if ( ! empty( $query_vars['post_status'] ) ) { + if ( is_array( $query_vars['post_status'] ) ) { + foreach ( $query_vars['post_status'] as &$status ) { + $status = wc_is_order_status( 'wc-' . $status ) ? 'wc-' . $status : $status; + } + } else { + $query_vars['post_status'] = wc_is_order_status( 'wc-' . $query_vars['post_status'] ) ? 'wc-' . $query_vars['post_status'] : $query_vars['post_status']; + } + } + + $wp_query_args = parent::get_wp_query_args( $query_vars ); + + if ( ! isset( $wp_query_args['date_query'] ) ) { + $wp_query_args['date_query'] = array(); + } + if ( ! isset( $wp_query_args['meta_query'] ) ) { + $wp_query_args['meta_query'] = array(); + } + + $date_queries = array( + 'date_created' => 'post_date', + 'date_modified' => 'post_modified', + 'date_completed' => '_date_completed', + 'date_paid' => '_date_paid', + ); + foreach ( $date_queries as $query_var_key => $db_key ) { + if ( isset( $query_vars[ $query_var_key ] ) && '' !== $query_vars[ $query_var_key ] ) { + + // Remove any existing meta queries for the same keys to prevent conflicts. + $existing_queries = wp_list_pluck( $wp_query_args['meta_query'], 'key', true ); + $meta_query_index = array_search( $db_key, $existing_queries, true ); + if ( false !== $meta_query_index ) { + unset( $wp_query_args['meta_query'][ $meta_query_index ] ); + } + + $wp_query_args = $this->parse_date_for_wp_query( $query_vars[ $query_var_key ], $db_key, $wp_query_args ); + } + } + + if ( isset( $query_vars['customer'] ) && '' !== $query_vars['customer'] && array() !== $query_vars['customer'] ) { + $values = is_array( $query_vars['customer'] ) ? $query_vars['customer'] : array( $query_vars['customer'] ); + $customer_query = $this->get_orders_generate_customer_meta_query( $values ); + if ( is_wp_error( $customer_query ) ) { + $wp_query_args['errors'][] = $customer_query; + } else { + $wp_query_args['meta_query'][] = $customer_query; + } + } + + if ( isset( $query_vars['anonymized'] ) ) { + if ( $query_vars['anonymized'] ) { + $wp_query_args['meta_query'][] = array( + 'key' => '_anonymized', + 'value' => 'yes', + ); + } else { + $wp_query_args['meta_query'][] = array( + 'key' => '_anonymized', + 'compare' => 'NOT EXISTS', + ); + } + } + + if ( ! isset( $query_vars['paginate'] ) || ! $query_vars['paginate'] ) { + $wp_query_args['no_found_rows'] = true; + } + + return apply_filters( 'woocommerce_order_data_store_cpt_get_orders_query', $wp_query_args, $query_vars, $this ); + } + + /** + * Query for Orders matching specific criteria. + * + * @since 3.1.0 + * + * @param array $query_vars query vars from a WC_Order_Query. + * + * @return array|object + */ + public function query( $query_vars ) { + $args = $this->get_wp_query_args( $query_vars ); + + if ( ! empty( $args['errors'] ) ) { + $query = (object) array( + 'posts' => array(), + 'found_posts' => 0, + 'max_num_pages' => 0, + ); + } else { + $query = new WP_Query( $args ); + } + + $orders = ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) ? $query->posts : array_filter( array_map( 'wc_get_order', $query->posts ) ); + + if ( isset( $query_vars['paginate'] ) && $query_vars['paginate'] ) { + return (object) array( + 'orders' => $orders, + 'total' => $query->found_posts, + 'max_num_pages' => $query->max_num_pages, + ); + } + + return $orders; + } + + /** + * Return the order type of a given item which belongs to WC_Order. + * + * @since 3.2.0 + * @param WC_Order $order Order Object. + * @param int $order_item_id Order item id. + * @return string Order Item type + */ + public function get_order_item_type( $order, $order_item_id ) { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d and order_item_id = %d;", $order->get_id(), $order_item_id ) ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-coupon-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-coupon-data-store.php new file mode 100644 index 0000000..01eeb9d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-coupon-data-store.php @@ -0,0 +1,62 @@ +get_id(); + $item->set_props( + array( + 'discount' => get_metadata( 'order_item', $id, 'discount_amount', true ), + 'discount_tax' => get_metadata( 'order_item', $id, 'discount_amount_tax', true ), + ) + ); + $item->set_object_read( true ); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $item->get_id() will be set. + * + * @since 3.0.0 + * @param WC_Order_Item_Coupon $item Coupon order item. + */ + public function save_item_data( &$item ) { + $id = $item->get_id(); + $save_values = array( + 'discount_amount' => $item->get_discount( 'edit' ), + 'discount_amount_tax' => $item->get_discount_tax( 'edit' ), + ); + foreach ( $save_values as $key => $value ) { + update_metadata( 'order_item', $id, $key, $value ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-data-store.php new file mode 100644 index 0000000..be4ea1a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-data-store.php @@ -0,0 +1,155 @@ +insert( + $wpdb->prefix . 'woocommerce_order_items', + array( + 'order_item_name' => $item['order_item_name'], + 'order_item_type' => $item['order_item_type'], + 'order_id' => $order_id, + ), + array( + '%s', + '%s', + '%d', + ) + ); + + return absint( $wpdb->insert_id ); + } + + /** + * Update an order item. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @param array $item order_item_name or order_item_type. + * @return boolean + */ + public function update_order_item( $item_id, $item ) { + global $wpdb; + return $wpdb->update( $wpdb->prefix . 'woocommerce_order_items', $item, array( 'order_item_id' => $item_id ) ); + } + + /** + * Delete an order item. + * + * @since 3.0.0 + * @param int $item_id Item ID. + */ + public function delete_order_item( $item_id ) { + global $wpdb; + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d", $item_id ) ); + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d", $item_id ) ); + } + + /** + * Update term meta. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param string $prev_value (default: ''). + * @return bool + */ + public function update_metadata( $item_id, $meta_key, $meta_value, $prev_value = '' ) { + return update_metadata( 'order_item', $item_id, $meta_key, is_string( $meta_value ) ? wp_slash( $meta_value ) : $meta_value, $prev_value ); + } + + /** + * Add term meta. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param bool $unique (default: false). + * @return int New row ID or 0 + */ + public function add_metadata( $item_id, $meta_key, $meta_value, $unique = false ) { + return add_metadata( 'order_item', $item_id, $meta_key, is_string( $meta_value ) ? wp_slash( $meta_value ) : $meta_value, $unique ); + } + + /** + * Delete term meta. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @param string $meta_key Meta key. + * @param string $meta_value (default: ''). + * @param bool $delete_all (default: false). + * @return bool + */ + public function delete_metadata( $item_id, $meta_key, $meta_value = '', $delete_all = false ) { + return delete_metadata( 'order_item', $item_id, $meta_key, is_string( $meta_value ) ? wp_slash( $meta_value ) : $meta_value, $delete_all ); + } + + /** + * Get term meta. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @param string $key Meta key. + * @param bool $single (default: true). + * @return mixed + */ + public function get_metadata( $item_id, $key, $single = true ) { + return get_metadata( 'order_item', $item_id, $key, $single ); + } + + /** + * Get order ID by order item ID. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @return int + */ + public function get_order_id_by_order_item_id( $item_id ) { + global $wpdb; + return (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT order_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d", + $item_id + ) + ); + } + + /** + * Get the order item type based on Item ID. + * + * @since 3.0.0 + * @param int $item_id Item ID. + * @return string + */ + public function get_order_item_type( $item_id ) { + global $wpdb; + $item_data = $wpdb->get_row( $wpdb->prepare( "SELECT order_item_type FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d LIMIT 1;", $item_id ) ); + return $item_data->order_item_type; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-fee-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-fee-data-store.php new file mode 100644 index 0000000..2222d06 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-fee-data-store.php @@ -0,0 +1,69 @@ +get_id(); + $item->set_props( + array( + 'amount' => get_metadata( 'order_item', $id, '_fee_amount', true ), + 'tax_class' => get_metadata( 'order_item', $id, '_tax_class', true ), + 'tax_status' => get_metadata( 'order_item', $id, '_tax_status', true ), + 'total' => get_metadata( 'order_item', $id, '_line_total', true ), + 'taxes' => get_metadata( 'order_item', $id, '_line_tax_data', true ), + ) + ); + $item->set_object_read( true ); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $id will be set. + * + * @since 3.0.0 + * @param WC_Order_Item_Fee $item Fee order item object. + */ + public function save_item_data( &$item ) { + $id = $item->get_id(); + $save_values = array( + '_fee_amount' => $item->get_amount( 'edit' ), + '_tax_class' => $item->get_tax_class( 'edit' ), + '_tax_status' => $item->get_tax_status( 'edit' ), + '_line_total' => $item->get_total( 'edit' ), + '_line_tax' => $item->get_total_tax( 'edit' ), + '_line_tax_data' => $item->get_taxes( 'edit' ), + ); + foreach ( $save_values as $key => $value ) { + update_metadata( 'order_item', $id, $key, $value ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-product-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-product-data-store.php new file mode 100644 index 0000000..2f78691 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-product-data-store.php @@ -0,0 +1,97 @@ +get_id(); + $item->set_props( + array( + 'product_id' => get_metadata( 'order_item', $id, '_product_id', true ), + 'variation_id' => get_metadata( 'order_item', $id, '_variation_id', true ), + 'quantity' => get_metadata( 'order_item', $id, '_qty', true ), + 'tax_class' => get_metadata( 'order_item', $id, '_tax_class', true ), + 'subtotal' => get_metadata( 'order_item', $id, '_line_subtotal', true ), + 'total' => get_metadata( 'order_item', $id, '_line_total', true ), + 'taxes' => get_metadata( 'order_item', $id, '_line_tax_data', true ), + ) + ); + $item->set_object_read( true ); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $id will be set. + * + * @since 3.0.0 + * @param WC_Order_Item_Product $item Product order item object. + */ + public function save_item_data( &$item ) { + $id = $item->get_id(); + $changes = $item->get_changes(); + $meta_key_to_props = array( + '_product_id' => 'product_id', + '_variation_id' => 'variation_id', + '_qty' => 'quantity', + '_tax_class' => 'tax_class', + '_line_subtotal' => 'subtotal', + '_line_subtotal_tax' => 'subtotal_tax', + '_line_total' => 'total', + '_line_tax' => 'total_tax', + '_line_tax_data' => 'taxes', + ); + $props_to_update = $this->get_props_to_update( $item, $meta_key_to_props, 'order_item' ); + + foreach ( $props_to_update as $meta_key => $prop ) { + update_metadata( 'order_item', $id, $meta_key, $item->{"get_$prop"}( 'edit' ) ); + } + } + + /** + * Get a list of download IDs for a specific item from an order. + * + * @since 3.0.0 + * @param WC_Order_Item_Product $item Product order item object. + * @param WC_Order $order Order object. + * @return array + */ + public function get_download_ids( $item, $order ) { + global $wpdb; + return $wpdb->get_col( + $wpdb->prepare( + "SELECT download_id FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE user_email = %s AND order_key = %s AND product_id = %d ORDER BY permission_id", + $order->get_billing_email(), + $order->get_order_key(), + $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id() + ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-shipping-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-shipping-data-store.php new file mode 100644 index 0000000..e09545d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-shipping-data-store.php @@ -0,0 +1,78 @@ +get_id(); + $item->set_props( + array( + 'method_id' => get_metadata( 'order_item', $id, 'method_id', true ), + 'instance_id' => get_metadata( 'order_item', $id, 'instance_id', true ), + 'total' => get_metadata( 'order_item', $id, 'cost', true ), + 'taxes' => get_metadata( 'order_item', $id, 'taxes', true ), + ) + ); + + // BW compat. + if ( '' === $item->get_instance_id() && strstr( $item->get_method_id(), ':' ) ) { + $legacy_method_id = explode( ':', $item->get_method_id() ); + $item->set_method_id( $legacy_method_id[0] ); + $item->set_instance_id( $legacy_method_id[1] ); + } + + $item->set_object_read( true ); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $id will be set. + * + * @since 3.0.0 + * @param WC_Order_Item_Shipping $item Item to save. + */ + public function save_item_data( &$item ) { + $id = $item->get_id(); + $changes = $item->get_changes(); + $meta_key_to_props = array( + 'method_id' => 'method_id', + 'instance_id' => 'instance_id', + 'cost' => 'total', + 'total_tax' => 'total_tax', + 'taxes' => 'taxes', + ); + $props_to_update = $this->get_props_to_update( $item, $meta_key_to_props, 'order_item' ); + + foreach ( $props_to_update as $meta_key => $prop ) { + update_metadata( 'order_item', $id, $meta_key, $item->{"get_$prop"}( 'edit' ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-tax-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-tax-data-store.php new file mode 100644 index 0000000..6a9793d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-item-tax-data-store.php @@ -0,0 +1,72 @@ +get_id(); + $item->set_props( + array( + 'rate_id' => get_metadata( 'order_item', $id, 'rate_id', true ), + 'label' => get_metadata( 'order_item', $id, 'label', true ), + 'compound' => get_metadata( 'order_item', $id, 'compound', true ), + 'tax_total' => get_metadata( 'order_item', $id, 'tax_amount', true ), + 'shipping_tax_total' => get_metadata( 'order_item', $id, 'shipping_tax_amount', true ), + ) + ); + $item->set_object_read( true ); + } + + /** + * Saves an item's data to the database / item meta. + * Ran after both create and update, so $id will be set. + * + * @since 3.0.0 + * @param WC_Order_Item_Tax $item Tax order item object. + */ + public function save_item_data( &$item ) { + $id = $item->get_id(); + $changes = $item->get_changes(); + $meta_key_to_props = array( + 'rate_id' => 'rate_id', + 'label' => 'label', + 'compound' => 'compound', + 'tax_amount' => 'tax_total', + 'shipping_tax_amount' => 'shipping_tax_total', + ); + $props_to_update = $this->get_props_to_update( $item, $meta_key_to_props, 'order_item' ); + + foreach ( $props_to_update as $meta_key => $prop ) { + update_metadata( 'order_item', $id, $meta_key, $item->{"get_$prop"}( 'edit' ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-refund-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-refund-data-store-cpt.php new file mode 100644 index 0000000..04cc170 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-refund-data-store-cpt.php @@ -0,0 +1,119 @@ +get_id(); + + if ( ! $id ) { + return; + } + + wp_delete_post( $id ); + $order->set_id( 0 ); + do_action( 'woocommerce_delete_order_refund', $id ); + } + + /** + * Read refund data. Can be overridden by child classes to load other props. + * + * @param WC_Order $refund Refund object. + * @param object $post_object Post object. + * @since 3.0.0 + */ + protected function read_order_data( &$refund, $post_object ) { + parent::read_order_data( $refund, $post_object ); + $id = $refund->get_id(); + $refund->set_props( + array( + 'amount' => get_post_meta( $id, '_refund_amount', true ), + 'refunded_by' => metadata_exists( 'post', $id, '_refunded_by' ) ? get_post_meta( $id, '_refunded_by', true ) : absint( $post_object->post_author ), + 'refunded_payment' => wc_string_to_bool( get_post_meta( $id, '_refunded_payment', true ) ), + 'reason' => metadata_exists( 'post', $id, '_refund_reason' ) ? get_post_meta( $id, '_refund_reason', true ): $post_object->post_excerpt, + ) + ); + } + + /** + * Helper method that updates all the post meta for an order based on it's settings in the WC_Order class. + * + * @param WC_Order $refund Refund object. + * @since 3.0.0 + */ + protected function update_post_meta( &$refund ) { + parent::update_post_meta( $refund ); + + $updated_props = array(); + $meta_key_to_props = array( + '_refund_amount' => 'amount', + '_refunded_by' => 'refunded_by', + '_refunded_payment' => 'refunded_payment', + '_refund_reason' => 'reason', + ); + + $props_to_update = $this->get_props_to_update( $refund, $meta_key_to_props ); + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $refund->{"get_$prop"}( 'edit' ); + update_post_meta( $refund->get_id(), $meta_key, $value ); + $updated_props[] = $prop; + } + + do_action( 'woocommerce_order_refund_object_updated_props', $refund, $updated_props ); + } + + /** + * Get a title for the new post type. + * + * @return string + */ + protected function get_post_title() { + return sprintf( + /* translators: %s: Order date */ + __( 'Refund – %s', 'woocommerce' ), + strftime( _x( '%b %d, %Y @ %I:%M %p', 'Order date parsed by strftime', 'woocommerce' ) ) // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.UnorderedPlaceholdersText + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-payment-token-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-payment-token-data-store.php new file mode 100644 index 0000000..e6aee03 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-payment-token-data-store.php @@ -0,0 +1,371 @@ +validate() ) { + throw new Exception( __( 'Invalid or missing payment token fields.', 'woocommerce' ) ); + } + + global $wpdb; + if ( ! $token->is_default() && $token->get_user_id() > 0 ) { + $default_token = WC_Payment_Tokens::get_customer_default_token( $token->get_user_id() ); + if ( is_null( $default_token ) ) { + $token->set_default( true ); + } + } + + $payment_token_data = array( + 'gateway_id' => $token->get_gateway_id( 'edit' ), + 'token' => $token->get_token( 'edit' ), + 'user_id' => $token->get_user_id( 'edit' ), + 'type' => $token->get_type( 'edit' ), + ); + + $wpdb->insert( $wpdb->prefix . 'woocommerce_payment_tokens', $payment_token_data ); + $token_id = $wpdb->insert_id; + $token->set_id( $token_id ); + $this->save_extra_data( $token, true ); + $token->save_meta_data(); + $token->apply_changes(); + + // Make sure all other tokens are not set to default. + if ( $token->is_default() && $token->get_user_id() > 0 ) { + WC_Payment_Tokens::set_users_default( $token->get_user_id(), $token_id ); + } + + do_action( 'woocommerce_new_payment_token', $token_id ); + } + + /** + * Update a payment token. + * + * @since 3.0.0 + * + * @param WC_Payment_Token $token Payment token object. + * + * @throws Exception Throw exception if invalid or missing payment token fields. + */ + public function update( &$token ) { + if ( false === $token->validate() ) { + throw new Exception( __( 'Invalid or missing payment token fields.', 'woocommerce' ) ); + } + + global $wpdb; + + $updated_props = array(); + $core_props = array( 'gateway_id', 'token', 'user_id', 'type' ); + $changed_props = array_keys( $token->get_changes() ); + + foreach ( $changed_props as $prop ) { + if ( ! in_array( $prop, $core_props, true ) ) { + continue; + } + $updated_props[] = $prop; + $payment_token_data[ $prop ] = $token->{'get_' . $prop}( 'edit' ); + } + + if ( ! empty( $payment_token_data ) ) { + $wpdb->update( + $wpdb->prefix . 'woocommerce_payment_tokens', + $payment_token_data, + array( 'token_id' => $token->get_id( 'edit' ) ) + ); + } + + $updated_extra_props = $this->save_extra_data( $token ); + $updated_props = array_merge( $updated_props, $updated_extra_props ); + $token->save_meta_data(); + $token->apply_changes(); + + // Make sure all other tokens are not set to default. + if ( $token->is_default() && $token->get_user_id() > 0 ) { + WC_Payment_Tokens::set_users_default( $token->get_user_id(), $token->get_id() ); + } + + do_action( 'woocommerce_payment_token_object_updated_props', $token, $updated_props ); + do_action( 'woocommerce_payment_token_updated', $token->get_id() ); + } + + /** + * Remove a payment token from the database. + * + * @since 3.0.0 + * @param WC_Payment_Token $token Payment token object. + * @param bool $force_delete Unused param. + */ + public function delete( &$token, $force_delete = false ) { + global $wpdb; + $wpdb->delete( $wpdb->prefix . 'woocommerce_payment_tokens', array( 'token_id' => $token->get_id() ), array( '%d' ) ); + $wpdb->delete( $wpdb->prefix . 'woocommerce_payment_tokenmeta', array( 'payment_token_id' => $token->get_id() ), array( '%d' ) ); + do_action( 'woocommerce_payment_token_deleted', $token->get_id(), $token ); + } + + /** + * Read a token from the database. + * + * @since 3.0.0 + * + * @param WC_Payment_Token $token Payment token object. + * + * @throws Exception Throw exception if invalid payment token. + */ + public function read( &$token ) { + global $wpdb; + + $data = $wpdb->get_row( + $wpdb->prepare( + "SELECT token, user_id, gateway_id, is_default FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token_id = %d LIMIT 1", + $token->get_id() + ) + ); + + if ( $data ) { + $token->set_props( + array( + 'token' => $data->token, + 'user_id' => $data->user_id, + 'gateway_id' => $data->gateway_id, + 'default' => $data->is_default, + ) + ); + $this->read_extra_data( $token ); + $token->read_meta_data(); + $token->set_object_read( true ); + do_action( 'woocommerce_payment_token_loaded', $token ); + } else { + throw new Exception( __( 'Invalid payment token.', 'woocommerce' ) ); + } + } + + /** + * Read extra data associated with the token (like last4 digits of a card for expiry dates). + * + * @param WC_Payment_Token $token Payment token object. + * @since 3.0.0 + */ + protected function read_extra_data( &$token ) { + foreach ( $token->get_extra_data_keys() as $key ) { + $function = 'set_' . $key; + if ( is_callable( array( $token, $function ) ) ) { + $token->{$function}( get_metadata( 'payment_token', $token->get_id(), $key, true ) ); + } + } + } + + /** + * Saves extra token data as meta. + * + * @since 3.0.0 + * @param WC_Payment_Token $token Payment token object. + * @param bool $force By default, only changed props are updated. When this param is true all props are updated. + * @return array List of updated props. + */ + protected function save_extra_data( &$token, $force = false ) { + if ( $this->extra_data_saved ) { + return array(); + } + + $updated_props = array(); + $extra_data_keys = $token->get_extra_data_keys(); + $meta_key_to_props = ! empty( $extra_data_keys ) ? array_combine( $extra_data_keys, $extra_data_keys ) : array(); + $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $token, $meta_key_to_props ); + + foreach ( $extra_data_keys as $key ) { + if ( ! array_key_exists( $key, $props_to_update ) ) { + continue; + } + $function = 'get_' . $key; + if ( is_callable( array( $token, $function ) ) ) { + if ( update_metadata( 'payment_token', $token->get_id(), $key, $token->{$function}( 'edit' ) ) ) { + $updated_props[] = $key; + } + } + } + + return $updated_props; + } + + /** + * Returns an array of objects (stdObject) matching specific token criteria. + * Accepts token_id, user_id, gateway_id, and type. + * Each object should contain the fields token_id, gateway_id, token, user_id, type, is_default. + * + * @since 3.0.0 + * @param array $args List of accepted args: token_id, gateway_id, user_id, type. + * @return array + */ + public function get_tokens( $args ) { + global $wpdb; + $args = wp_parse_args( + $args, array( + 'token_id' => '', + 'user_id' => '', + 'gateway_id' => '', + 'type' => '', + ) + ); + + $sql = "SELECT * FROM {$wpdb->prefix}woocommerce_payment_tokens"; + $where = array( '1=1' ); + + if ( $args['token_id'] ) { + $token_ids = array_map( 'absint', is_array( $args['token_id'] ) ? $args['token_id'] : array( $args['token_id'] ) ); + $where[] = "token_id IN ('" . implode( "','", array_map( 'esc_sql', $token_ids ) ) . "')"; + } + + if ( $args['user_id'] ) { + $where[] = $wpdb->prepare( 'user_id = %d', absint( $args['user_id'] ) ); + } + + if ( $args['gateway_id'] ) { + $gateway_ids = array( $args['gateway_id'] ); + } else { + $gateways = WC_Payment_Gateways::instance(); + $gateway_ids = $gateways->get_payment_gateway_ids(); + } + + $page = isset( $args['page'] ) ? absint( $args['page'] ) : 1; + $posts_per_page = isset( $args['limit'] ) ? absint( $args['limit'] ) : get_option( 'posts_per_page' ); + + $pgstrt = absint( ( $page - 1 ) * $posts_per_page ) . ', '; + $limits = 'LIMIT ' . $pgstrt . $posts_per_page; + + $gateway_ids[] = ''; + $where[] = "gateway_id IN ('" . implode( "','", array_map( 'esc_sql', $gateway_ids ) ) . "')"; + + if ( $args['type'] ) { + $where[] = $wpdb->prepare( 'type = %s', $args['type'] ); + } + + // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + $token_results = $wpdb->get_results( $sql . ' WHERE ' . implode( ' AND ', $where ) . ' ' . $limits ); + + return $token_results; + } + + /** + * Returns an stdObject of a token for a user's default token. + * Should contain the fields token_id, gateway_id, token, user_id, type, is_default. + * + * @since 3.0.0 + * @param id $user_id User ID. + * @return object + */ + public function get_users_default_token( $user_id ) { + global $wpdb; + return $wpdb->get_row( + $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE user_id = %d AND is_default = 1", + $user_id + ) + ); + } + + /** + * Returns an stdObject of a token. + * Should contain the fields token_id, gateway_id, token, user_id, type, is_default. + * + * @since 3.0.0 + * @param id $token_id Token ID. + * @return object + */ + public function get_token_by_id( $token_id ) { + global $wpdb; + return $wpdb->get_row( + $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token_id = %d", + $token_id + ) + ); + } + + /** + * Returns metadata for a specific payment token. + * + * @since 3.0.0 + * @param id $token_id Token ID. + * @return array + */ + public function get_metadata( $token_id ) { + return get_metadata( 'payment_token', $token_id ); + } + + /** + * Get a token's type by ID. + * + * @since 3.0.0 + * @param id $token_id Token ID. + * @return string + */ + public function get_token_type_by_id( $token_id ) { + global $wpdb; + return $wpdb->get_var( + $wpdb->prepare( + "SELECT type FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE token_id = %d", + $token_id + ) + ); + } + + /** + * Update's a tokens default status in the database. Used for quickly + * looping through tokens and setting their statuses instead of creating a bunch + * of objects. + * + * @since 3.0.0 + * + * @param id $token_id Token ID. + * @param bool $status Whether given payment token is the default payment token or not. + * + * @return void + */ + public function set_default_status( $token_id, $status = true ) { + global $wpdb; + $wpdb->update( + $wpdb->prefix . 'woocommerce_payment_tokens', + array( 'is_default' => $status ), + array( + 'token_id' => $token_id, + ) + ); + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php new file mode 100644 index 0000000..ef96e39 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php @@ -0,0 +1,1757 @@ +get_date_created( 'edit' ) ) { + $product->set_date_created( current_time( 'timestamp', true ) ); + } + + $id = wp_insert_post( + apply_filters( + 'woocommerce_new_product_data', array( + 'post_type' => 'product', + 'post_status' => $product->get_status() ? $product->get_status() : 'publish', + 'post_author' => get_current_user_id(), + 'post_title' => $product->get_name() ? $product->get_name() : __( 'Product', 'woocommerce' ), + 'post_content' => $product->get_description(), + 'post_excerpt' => $product->get_short_description(), + 'post_parent' => $product->get_parent_id(), + 'comment_status' => $product->get_reviews_allowed() ? 'open' : 'closed', + 'ping_status' => 'closed', + 'menu_order' => $product->get_menu_order(), + 'post_date' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getTimestamp() ), + 'post_name' => $product->get_slug( 'edit' ), + ) + ), true + ); + + if ( $id && ! is_wp_error( $id ) ) { + $product->set_id( $id ); + + $this->update_post_meta( $product, true ); + $this->update_terms( $product, true ); + $this->update_visibility( $product, true ); + $this->update_attributes( $product, true ); + $this->update_version_and_type( $product ); + $this->handle_updated_props( $product ); + + $product->save_meta_data(); + $product->apply_changes(); + + $this->clear_caches( $product ); + + do_action( 'woocommerce_new_product', $id ); + } + } + + /** + * Method to read a product from the database. + * + * @param WC_Product $product Product object. + * @throws Exception If invalid product. + */ + public function read( &$product ) { + $product->set_defaults(); + $post_object = get_post( $product->get_id() ); + + if ( ! $product->get_id() || ! $post_object || 'product' !== $post_object->post_type ) { + throw new Exception( __( 'Invalid product.', 'woocommerce' ) ); + } + + $product->set_props( + array( + 'name' => $post_object->post_title, + 'slug' => $post_object->post_name, + 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null, + 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null, + 'status' => $post_object->post_status, + 'description' => $post_object->post_content, + 'short_description' => $post_object->post_excerpt, + 'parent_id' => $post_object->post_parent, + 'menu_order' => $post_object->menu_order, + 'reviews_allowed' => 'open' === $post_object->comment_status, + ) + ); + + $this->read_attributes( $product ); + $this->read_downloads( $product ); + $this->read_visibility( $product ); + $this->read_product_data( $product ); + $this->read_extra_data( $product ); + $product->set_object_read( true ); + } + + /** + * Method to update a product in the database. + * + * @param WC_Product $product Product object. + */ + public function update( &$product ) { + $product->save_meta_data(); + $changes = $product->get_changes(); + + // Only update the post when the post data changes. + if ( array_intersect( array( 'description', 'short_description', 'name', 'parent_id', 'reviews_allowed', 'status', 'menu_order', 'date_created', 'date_modified', 'slug' ), array_keys( $changes ) ) ) { + $post_data = array( + 'post_content' => $product->get_description( 'edit' ), + 'post_excerpt' => $product->get_short_description( 'edit' ), + 'post_title' => $product->get_name( 'edit' ), + 'post_parent' => $product->get_parent_id( 'edit' ), + 'comment_status' => $product->get_reviews_allowed( 'edit' ) ? 'open' : 'closed', + 'post_status' => $product->get_status( 'edit' ) ? $product->get_status( 'edit' ) : 'publish', + 'menu_order' => $product->get_menu_order( 'edit' ), + 'post_name' => $product->get_slug( 'edit' ), + 'post_type' => 'product', + ); + if ( $product->get_date_created( 'edit' ) ) { + $post_data['post_date'] = gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getOffsetTimestamp() ); + $post_data['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getTimestamp() ); + } + if ( isset( $changes['date_modified'] ) && $product->get_date_modified( 'edit' ) ) { + $post_data['post_modified'] = gmdate( 'Y-m-d H:i:s', $product->get_date_modified( 'edit' )->getOffsetTimestamp() ); + $post_data['post_modified_gmt'] = gmdate( 'Y-m-d H:i:s', $product->get_date_modified( 'edit' )->getTimestamp() ); + } else { + $post_data['post_modified'] = current_time( 'mysql' ); + $post_data['post_modified_gmt'] = current_time( 'mysql', 1 ); + } + + /** + * When updating this object, to prevent infinite loops, use $wpdb + * to update data, since wp_update_post spawns more calls to the + * save_post action. + * + * This ensures hooks are fired by either WP itself (admin screen save), + * or an update purely from CRUD. + */ + if ( doing_action( 'save_post' ) ) { + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $product->get_id() ) ); + clean_post_cache( $product->get_id() ); + } else { + wp_update_post( array_merge( array( 'ID' => $product->get_id() ), $post_data ) ); + } + $product->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. + + } else { // Only update post modified time to record this save event. + $GLOBALS['wpdb']->update( + $GLOBALS['wpdb']->posts, + array( + 'post_modified' => current_time( 'mysql' ), + 'post_modified_gmt' => current_time( 'mysql', 1 ), + ), + array( + 'ID' => $product->get_id(), + ) + ); + clean_post_cache( $product->get_id() ); + } + + $this->update_post_meta( $product ); + $this->update_terms( $product ); + $this->update_visibility( $product ); + $this->update_attributes( $product ); + $this->update_version_and_type( $product ); + $this->handle_updated_props( $product ); + + $product->apply_changes(); + + $this->clear_caches( $product ); + + do_action( 'woocommerce_update_product', $product->get_id() ); + } + + /** + * Method to delete a product from the database. + * + * @param WC_Product $product Product object. + * @param array $args Array of args to pass to the delete method. + */ + public function delete( &$product, $args = array() ) { + $id = $product->get_id(); + $post_type = $product->is_type( 'variation' ) ? 'product_variation' : 'product'; + + $args = wp_parse_args( + $args, array( + 'force_delete' => false, + ) + ); + + if ( ! $id ) { + return; + } + + if ( $args['force_delete'] ) { + do_action( 'woocommerce_before_delete_' . $post_type, $id ); + wp_delete_post( $id ); + $product->set_id( 0 ); + do_action( 'woocommerce_delete_' . $post_type, $id ); + } else { + wp_trash_post( $id ); + $product->set_status( 'trash' ); + do_action( 'woocommerce_trash_' . $post_type, $id ); + } + } + + /* + |-------------------------------------------------------------------------- + | Additional Methods + |-------------------------------------------------------------------------- + */ + + /** + * Read product data. Can be overridden by child classes to load other props. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function read_product_data( &$product ) { + $id = $product->get_id(); + $review_count = get_post_meta( $id, '_wc_review_count', true ); + $rating_counts = get_post_meta( $id, '_wc_rating_count', true ); + $average_rating = get_post_meta( $id, '_wc_average_rating', true ); + + if ( '' === $review_count ) { + WC_Comments::get_review_count_for_product( $product ); + } else { + $product->set_review_count( $review_count ); + } + + if ( '' === $rating_counts ) { + WC_Comments::get_rating_counts_for_product( $product ); + } else { + $product->set_rating_counts( $rating_counts ); + } + + if ( '' === $average_rating ) { + WC_Comments::get_average_rating_for_product( $product ); + } else { + $product->set_average_rating( $average_rating ); + } + + $product->set_props( + array( + 'sku' => get_post_meta( $id, '_sku', true ), + 'regular_price' => get_post_meta( $id, '_regular_price', true ), + 'sale_price' => get_post_meta( $id, '_sale_price', true ), + 'price' => get_post_meta( $id, '_price', true ), + 'date_on_sale_from' => get_post_meta( $id, '_sale_price_dates_from', true ), + 'date_on_sale_to' => get_post_meta( $id, '_sale_price_dates_to', true ), + 'total_sales' => get_post_meta( $id, 'total_sales', true ), + 'tax_status' => get_post_meta( $id, '_tax_status', true ), + 'tax_class' => get_post_meta( $id, '_tax_class', true ), + 'manage_stock' => get_post_meta( $id, '_manage_stock', true ), + 'stock_quantity' => get_post_meta( $id, '_stock', true ), + 'stock_status' => get_post_meta( $id, '_stock_status', true ), + 'backorders' => get_post_meta( $id, '_backorders', true ), + 'sold_individually' => get_post_meta( $id, '_sold_individually', true ), + 'weight' => get_post_meta( $id, '_weight', true ), + 'length' => get_post_meta( $id, '_length', true ), + 'width' => get_post_meta( $id, '_width', true ), + 'height' => get_post_meta( $id, '_height', true ), + 'upsell_ids' => get_post_meta( $id, '_upsell_ids', true ), + 'cross_sell_ids' => get_post_meta( $id, '_crosssell_ids', true ), + 'purchase_note' => get_post_meta( $id, '_purchase_note', true ), + 'default_attributes' => get_post_meta( $id, '_default_attributes', true ), + 'category_ids' => $this->get_term_ids( $product, 'product_cat' ), + 'tag_ids' => $this->get_term_ids( $product, 'product_tag' ), + 'shipping_class_id' => current( $this->get_term_ids( $product, 'product_shipping_class' ) ), + 'virtual' => get_post_meta( $id, '_virtual', true ), + 'downloadable' => get_post_meta( $id, '_downloadable', true ), + 'gallery_image_ids' => array_filter( explode( ',', get_post_meta( $id, '_product_image_gallery', true ) ) ), + 'download_limit' => get_post_meta( $id, '_download_limit', true ), + 'download_expiry' => get_post_meta( $id, '_download_expiry', true ), + 'image_id' => get_post_thumbnail_id( $id ), + ) + ); + + // Handle sale dates on the fly in case of missed cron schedule. + if ( $product->is_type( 'simple' ) && $product->is_on_sale( 'edit' ) && $product->get_sale_price( 'edit' ) !== $product->get_price( 'edit' ) ) { + update_post_meta( $product->get_id(), '_price', $product->get_sale_price( 'edit' ) ); + $product->set_price( $product->get_sale_price( 'edit' ) ); + } + } + + /** + * Read extra data associated with the product, like button text or product URL for external products. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function read_extra_data( &$product ) { + foreach ( $product->get_extra_data_keys() as $key ) { + $function = 'set_' . $key; + if ( is_callable( array( $product, $function ) ) ) { + $product->{$function}( get_post_meta( $product->get_id(), '_' . $key, true ) ); + } + } + } + + /** + * Convert visibility terms to props. + * Catalog visibility valid values are 'visible', 'catalog', 'search', and 'hidden'. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function read_visibility( &$product ) { + $terms = get_the_terms( $product->get_id(), 'product_visibility' ); + $term_names = is_array( $terms ) ? wp_list_pluck( $terms, 'name' ) : array(); + $featured = in_array( 'featured', $term_names, true ); + $exclude_search = in_array( 'exclude-from-search', $term_names, true ); + $exclude_catalog = in_array( 'exclude-from-catalog', $term_names, true ); + + if ( $exclude_search && $exclude_catalog ) { + $catalog_visibility = 'hidden'; + } elseif ( $exclude_search ) { + $catalog_visibility = 'catalog'; + } elseif ( $exclude_catalog ) { + $catalog_visibility = 'search'; + } else { + $catalog_visibility = 'visible'; + } + + $product->set_props( + array( + 'featured' => $featured, + 'catalog_visibility' => $catalog_visibility, + ) + ); + } + + /** + * Read attributes from post meta. + * + * @param WC_Product $product Product object. + */ + protected function read_attributes( &$product ) { + $meta_attributes = get_post_meta( $product->get_id(), '_product_attributes', true ); + + if ( ! empty( $meta_attributes ) && is_array( $meta_attributes ) ) { + $attributes = array(); + foreach ( $meta_attributes as $meta_attribute_key => $meta_attribute_value ) { + $meta_value = array_merge( + array( + 'name' => '', + 'value' => '', + 'position' => 0, + 'is_visible' => 0, + 'is_variation' => 0, + 'is_taxonomy' => 0, + ), (array) $meta_attribute_value + ); + + // Check if is a taxonomy attribute. + if ( ! empty( $meta_value['is_taxonomy'] ) ) { + if ( ! taxonomy_exists( $meta_value['name'] ) ) { + continue; + } + $id = wc_attribute_taxonomy_id_by_name( $meta_value['name'] ); + $options = wc_get_object_terms( $product->get_id(), $meta_value['name'], 'term_id' ); + } else { + $id = 0; + $options = wc_get_text_attributes( $meta_value['value'] ); + } + + $attribute = new WC_Product_Attribute(); + $attribute->set_id( $id ); + $attribute->set_name( $meta_value['name'] ); + $attribute->set_options( $options ); + $attribute->set_position( $meta_value['position'] ); + $attribute->set_visible( $meta_value['is_visible'] ); + $attribute->set_variation( $meta_value['is_variation'] ); + $attributes[] = $attribute; + } + $product->set_attributes( $attributes ); + } + } + + /** + * Read downloads from post meta. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function read_downloads( &$product ) { + $meta_values = array_filter( (array) get_post_meta( $product->get_id(), '_downloadable_files', true ) ); + + if ( $meta_values ) { + $downloads = array(); + foreach ( $meta_values as $key => $value ) { + if ( ! isset( $value['name'], $value['file'] ) ) { + continue; + } + $download = new WC_Product_Download(); + $download->set_id( $key ); + $download->set_name( $value['name'] ? $value['name'] : wc_get_filename_from_url( $value['file'] ) ); + $download->set_file( apply_filters( 'woocommerce_file_download_path', $value['file'], $product, $key ) ); + $downloads[] = $download; + } + $product->set_downloads( $downloads ); + } + } + + /** + * Helper method that updates all the post meta for a product based on it's settings in the WC_Product class. + * + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + * @since 3.0.0 + */ + protected function update_post_meta( &$product, $force = false ) { + $meta_key_to_props = array( + '_sku' => 'sku', + '_regular_price' => 'regular_price', + '_sale_price' => 'sale_price', + '_sale_price_dates_from' => 'date_on_sale_from', + '_sale_price_dates_to' => 'date_on_sale_to', + 'total_sales' => 'total_sales', + '_tax_status' => 'tax_status', + '_tax_class' => 'tax_class', + '_manage_stock' => 'manage_stock', + '_backorders' => 'backorders', + '_sold_individually' => 'sold_individually', + '_weight' => 'weight', + '_length' => 'length', + '_width' => 'width', + '_height' => 'height', + '_upsell_ids' => 'upsell_ids', + '_crosssell_ids' => 'cross_sell_ids', + '_purchase_note' => 'purchase_note', + '_default_attributes' => 'default_attributes', + '_virtual' => 'virtual', + '_downloadable' => 'downloadable', + '_product_image_gallery' => 'gallery_image_ids', + '_download_limit' => 'download_limit', + '_download_expiry' => 'download_expiry', + '_thumbnail_id' => 'image_id', + '_stock' => 'stock_quantity', + '_stock_status' => 'stock_status', + '_wc_average_rating' => 'average_rating', + '_wc_rating_count' => 'rating_counts', + '_wc_review_count' => 'review_count', + ); + + // Make sure to take extra data (like product url or text for external products) into account. + $extra_data_keys = $product->get_extra_data_keys(); + + foreach ( $extra_data_keys as $key ) { + $meta_key_to_props[ '_' . $key ] = $key; + } + + $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props ); + + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $product->{"get_$prop"}( 'edit' ); + $value = is_string( $value ) ? wp_slash( $value ) : $value; + switch ( $prop ) { + case 'virtual': + case 'downloadable': + case 'manage_stock': + case 'sold_individually': + $updated = update_post_meta( $product->get_id(), $meta_key, wc_bool_to_string( $value ) ); + break; + case 'gallery_image_ids': + $updated = update_post_meta( $product->get_id(), $meta_key, implode( ',', $value ) ); + break; + case 'image_id': + if ( ! empty( $value ) ) { + set_post_thumbnail( $product->get_id(), $value ); + } else { + delete_post_meta( $product->get_id(), '_thumbnail_id' ); + } + $updated = true; + break; + case 'date_on_sale_from': + case 'date_on_sale_to': + $updated = update_post_meta( $product->get_id(), $meta_key, $value ? $value->getTimestamp() : '' ); + break; + default: + $updated = update_post_meta( $product->get_id(), $meta_key, $value ); + break; + } + if ( $updated ) { + $this->updated_props[] = $prop; + } + } + + // Update extra data associated with the product like button text or product URL for external products. + if ( ! $this->extra_data_saved ) { + foreach ( $extra_data_keys as $key ) { + if ( ! array_key_exists( '_' . $key, $props_to_update ) ) { + continue; + } + $function = 'get_' . $key; + if ( is_callable( array( $product, $function ) ) ) { + $value = $product->{$function}( 'edit' ); + $value = is_string( $value ) ? wp_slash( $value ) : $value; + + if ( update_post_meta( $product->get_id(), '_' . $key, $value ) ) { + $this->updated_props[] = $key; + } + } + } + } + + if ( $this->update_downloads( $product, $force ) ) { + $this->updated_props[] = 'downloads'; + } + } + + /** + * Handle updated meta props after updating meta data. + * + * @since 3.0.0 + * @param WC_Product $product Product Object. + */ + protected function handle_updated_props( &$product ) { + if ( in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) ) { + if ( $product->get_sale_price( 'edit' ) >= $product->get_regular_price( 'edit' ) ) { + update_post_meta( $product->get_id(), '_sale_price', '' ); + $product->set_sale_price( '' ); + } + } + if ( in_array( 'date_on_sale_from', $this->updated_props, true ) || in_array( 'date_on_sale_to', $this->updated_props, true ) || in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) || in_array( 'product_type', $this->updated_props, true ) ) { + if ( $product->is_on_sale( 'edit' ) ) { + update_post_meta( $product->get_id(), '_price', $product->get_sale_price( 'edit' ) ); + $product->set_price( $product->get_sale_price( 'edit' ) ); + } else { + update_post_meta( $product->get_id(), '_price', $product->get_regular_price( 'edit' ) ); + $product->set_price( $product->get_regular_price( 'edit' ) ); + } + } + + if ( in_array( 'stock_quantity', $this->updated_props, true ) ) { + if ( $product->is_type( 'variation' ) ) { + do_action( 'woocommerce_variation_set_stock', $product ); + } else { + do_action( 'woocommerce_product_set_stock', $product ); + } + } + + if ( in_array( 'stock_status', $this->updated_props, true ) ) { + if ( $product->is_type( 'variation' ) ) { + do_action( 'woocommerce_variation_set_stock_status', $product->get_id(), $product->get_stock_status(), $product ); + } else { + do_action( 'woocommerce_product_set_stock_status', $product->get_id(), $product->get_stock_status(), $product ); + } + } + + // Trigger action so 3rd parties can deal with updated props. + do_action( 'woocommerce_product_object_updated_props', $product, $this->updated_props ); + + // After handling, we can reset the props array. + $this->updated_props = array(); + } + + /** + * For all stored terms in all taxonomies, save them to the DB. + * + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + * @since 3.0.0 + */ + protected function update_terms( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_key_exists( 'category_ids', $changes ) ) { + $categories = $product->get_category_ids( 'edit' ); + + if ( empty( $categories ) && get_option( 'default_product_cat', 0 ) ) { + $categories = array( get_option( 'default_product_cat', 0 ) ); + } + + wp_set_post_terms( $product->get_id(), $categories, 'product_cat', false ); + } + if ( $force || array_key_exists( 'tag_ids', $changes ) ) { + wp_set_post_terms( $product->get_id(), $product->get_tag_ids( 'edit' ), 'product_tag', false ); + } + if ( $force || array_key_exists( 'shipping_class_id', $changes ) ) { + wp_set_post_terms( $product->get_id(), array( $product->get_shipping_class_id( 'edit' ) ), 'product_shipping_class', false ); + } + } + + /** + * Update visibility terms based on props. + * + * @since 3.0.0 + * + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + */ + protected function update_visibility( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_intersect( array( 'featured', 'stock_status', 'average_rating', 'catalog_visibility' ), array_keys( $changes ) ) ) { + $terms = array(); + + if ( $product->get_featured() ) { + $terms[] = 'featured'; + } + + if ( 'outofstock' === $product->get_stock_status() ) { + $terms[] = 'outofstock'; + } + + $rating = min( 5, round( $product->get_average_rating(), 0 ) ); + + if ( $rating > 0 ) { + $terms[] = 'rated-' . $rating; + } + + switch ( $product->get_catalog_visibility() ) { + case 'hidden': + $terms[] = 'exclude-from-search'; + $terms[] = 'exclude-from-catalog'; + break; + case 'catalog': + $terms[] = 'exclude-from-search'; + break; + case 'search': + $terms[] = 'exclude-from-catalog'; + break; + } + + if ( ! is_wp_error( wp_set_post_terms( $product->get_id(), $terms, 'product_visibility', false ) ) ) { + delete_transient( 'wc_featured_products' ); + do_action( 'woocommerce_product_set_visibility', $product->get_id(), $product->get_catalog_visibility() ); + } + } + } + + /** + * Update attributes which are a mix of terms and meta data. + * + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + * @since 3.0.0 + */ + protected function update_attributes( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_key_exists( 'attributes', $changes ) ) { + $attributes = $product->get_attributes(); + $meta_values = array(); + + if ( $attributes ) { + foreach ( $attributes as $attribute_key => $attribute ) { + $value = ''; + + delete_transient( 'wc_layered_nav_counts_' . $attribute_key ); + + if ( is_null( $attribute ) ) { + if ( taxonomy_exists( $attribute_key ) ) { + // Handle attributes that have been unset. + wp_set_object_terms( $product->get_id(), array(), $attribute_key ); + } + continue; + + } elseif ( $attribute->is_taxonomy() ) { + wp_set_object_terms( $product->get_id(), wp_list_pluck( $attribute->get_terms(), 'term_id' ), $attribute->get_name() ); + } else { + $value = wc_implode_text_attributes( $attribute->get_options() ); + } + + // Store in format WC uses in meta. + $meta_values[ $attribute_key ] = array( + 'name' => $attribute->get_name(), + 'value' => $value, + 'position' => $attribute->get_position(), + 'is_visible' => $attribute->get_visible() ? 1 : 0, + 'is_variation' => $attribute->get_variation() ? 1 : 0, + 'is_taxonomy' => $attribute->is_taxonomy() ? 1 : 0, + ); + } + } + update_post_meta( $product->get_id(), '_product_attributes', $meta_values ); + } + } + + /** + * Update downloads. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + * @return bool If updated or not. + */ + protected function update_downloads( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_key_exists( 'downloads', $changes ) ) { + $downloads = $product->get_downloads(); + $meta_values = array(); + + if ( $downloads ) { + foreach ( $downloads as $key => $download ) { + // Store in format WC uses in meta. + $meta_values[ $key ] = $download->get_data(); + } + } + + if ( $product->is_type( 'variation' ) ) { + do_action( 'woocommerce_process_product_file_download_paths', $product->get_parent_id(), $product->get_id(), $downloads ); + } else { + do_action( 'woocommerce_process_product_file_download_paths', $product->get_id(), 0, $downloads ); + } + + return update_post_meta( $product->get_id(), '_downloadable_files', $meta_values ); + } + return false; + } + + /** + * Make sure we store the product type and version (to track data changes). + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function update_version_and_type( &$product ) { + $old_type = WC_Product_Factory::get_product_type( $product->get_id() ); + $new_type = $product->get_type(); + + wp_set_object_terms( $product->get_id(), $new_type, 'product_type' ); + update_post_meta( $product->get_id(), '_product_version', WC_VERSION ); + + // Action for the transition. + if ( $old_type !== $new_type ) { + $this->updated_props[] = 'product_type'; + do_action( 'woocommerce_product_type_changed', $product, $old_type, $new_type ); + } + } + + /** + * Clear any caches. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function clear_caches( &$product ) { + wc_delete_product_transients( $product->get_id() ); + WC_Cache_Helper::incr_cache_prefix( 'product_' . $product->get_id() ); + } + + /* + |-------------------------------------------------------------------------- + | wc-product-functions.php methods + |-------------------------------------------------------------------------- + */ + + /** + * Returns an array of on sale products, as an array of objects with an + * ID and parent_id present. Example: $return[0]->id, $return[0]->parent_id. + * + * @return array + * @since 3.0.0 + */ + public function get_on_sale_products() { + global $wpdb; + + $decimals = absint( wc_get_price_decimals() ); + $exclude_term_ids = array(); + $outofstock_join = ''; + $outofstock_where = ''; + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $product_visibility_term_ids['outofstock'] ) { + $exclude_term_ids[] = $product_visibility_term_ids['outofstock']; + } + + if ( count( $exclude_term_ids ) ) { + $outofstock_join = " LEFT JOIN ( SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( " . implode( ',', array_map( 'absint', $exclude_term_ids ) ) . ' ) ) AS exclude_join ON exclude_join.object_id = id'; + $outofstock_where = ' AND exclude_join.object_id IS NULL'; + } + + return $wpdb->get_results( + // phpcs:disable WordPress.WP.PreparedSQL.NotPrepared + $wpdb->prepare( + "SELECT post.ID as id, post.post_parent as parent_id FROM `$wpdb->posts` AS post + LEFT JOIN `$wpdb->postmeta` AS meta ON post.ID = meta.post_id + LEFT JOIN `$wpdb->postmeta` AS meta2 ON post.ID = meta2.post_id + $outofstock_join + WHERE post.post_type IN ( 'product', 'product_variation' ) + AND post.post_status = 'publish' + AND meta.meta_key = '_sale_price' + AND meta2.meta_key = '_price' + AND CAST( meta.meta_value AS DECIMAL ) >= 0 + AND CAST( meta.meta_value AS CHAR ) != '' + AND CAST( meta.meta_value AS DECIMAL( 10, %d ) ) = CAST( meta2.meta_value AS DECIMAL( 10, %d ) ) + $outofstock_where + GROUP BY post.ID", + $decimals, + $decimals + ) + // phpcs:enable + ); + } + + /** + * Returns a list of product IDs ( id as key => parent as value) that are + * featured. Uses get_posts instead of wc_get_products since we want + * some extra meta queries and ALL products (posts_per_page = -1). + * + * @return array + * @since 3.0.0 + */ + public function get_featured_product_ids() { + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + + return get_posts( + array( + 'post_type' => array( 'product', 'product_variation' ), + 'posts_per_page' => -1, + 'post_status' => 'publish', + // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_tax_query + 'tax_query' => array( + 'relation' => 'AND', + array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => array( $product_visibility_term_ids['featured'] ), + ), + array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => array( $product_visibility_term_ids['exclude-from-catalog'] ), + 'operator' => 'NOT IN', + ), + ), + 'fields' => 'id=>parent', + ) + ); + } + + /** + * Check if product sku is found for any other product IDs. + * + * @since 3.0.0 + * @param int $product_id Product ID. + * @param string $sku Will be slashed to work around https://core.trac.wordpress.org/ticket/27421. + * @return bool + */ + public function is_existing_sku( $product_id, $sku ) { + global $wpdb; + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + return $wpdb->get_var( + $wpdb->prepare( + "SELECT $wpdb->posts.ID + FROM $wpdb->posts + LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id ) + WHERE $wpdb->posts.post_type IN ( 'product', 'product_variation' ) + AND $wpdb->posts.post_status != 'trash' + AND $wpdb->postmeta.meta_key = '_sku' AND $wpdb->postmeta.meta_value = %s + AND $wpdb->postmeta.post_id <> %d + LIMIT 1", + wp_slash( $sku ), $product_id + ) + ); + } + + /** + * Return product ID based on SKU. + * + * @since 3.0.0 + * @param string $sku Product SKU. + * @return int + */ + public function get_product_id_by_sku( $sku ) { + global $wpdb; + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $id = $wpdb->get_var( + $wpdb->prepare( + "SELECT posts.ID + FROM $wpdb->posts AS posts + LEFT JOIN $wpdb->postmeta AS postmeta ON ( posts.ID = postmeta.post_id ) + WHERE posts.post_type IN ( 'product', 'product_variation' ) + AND posts.post_status != 'trash' + AND postmeta.meta_key = '_sku' + AND postmeta.meta_value = %s + LIMIT 1", + $sku + ) + ); + + return (int) apply_filters( 'woocommerce_get_product_id_by_sku', $id, $sku ); + } + + /** + * Returns an array of IDs of products that have sales starting soon. + * + * @since 3.0.0 + * @return array + */ + public function get_starting_sales() { + global $wpdb; + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + return $wpdb->get_col( + $wpdb->prepare( + "SELECT postmeta.post_id FROM {$wpdb->postmeta} as postmeta + LEFT JOIN {$wpdb->postmeta} as postmeta_2 ON postmeta.post_id = postmeta_2.post_id + LEFT JOIN {$wpdb->postmeta} as postmeta_3 ON postmeta.post_id = postmeta_3.post_id + WHERE postmeta.meta_key = '_sale_price_dates_from' + AND postmeta_2.meta_key = '_price' + AND postmeta_3.meta_key = '_sale_price' + AND postmeta.meta_value > 0 + AND postmeta.meta_value < %s + AND postmeta_2.meta_value != postmeta_3.meta_value", + current_time( 'timestamp', true ) + ) + ); + } + + /** + * Returns an array of IDs of products that have sales which are due to end. + * + * @since 3.0.0 + * @return array + */ + public function get_ending_sales() { + global $wpdb; + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + return $wpdb->get_col( + $wpdb->prepare( + "SELECT postmeta.post_id FROM {$wpdb->postmeta} as postmeta + LEFT JOIN {$wpdb->postmeta} as postmeta_2 ON postmeta.post_id = postmeta_2.post_id + LEFT JOIN {$wpdb->postmeta} as postmeta_3 ON postmeta.post_id = postmeta_3.post_id + WHERE postmeta.meta_key = '_sale_price_dates_to' + AND postmeta_2.meta_key = '_price' + AND postmeta_3.meta_key = '_regular_price' + AND postmeta.meta_value > 0 + AND postmeta.meta_value < %s + AND postmeta_2.meta_value != postmeta_3.meta_value", + current_time( 'timestamp', true ) + ) + ); + } + + /** + * Find a matching (enabled) variation within a variable product. + * + * @since 3.0.0 + * @param WC_Product $product Variable product. + * @param array $match_attributes Array of attributes we want to try to match. + * @return int Matching variation ID or 0. + */ + public function find_matching_product_variation( $product, $match_attributes = array() ) { + $query_args = array( + 'post_parent' => $product->get_id(), + 'post_type' => 'product_variation', + 'orderby' => 'menu_order', + 'order' => 'ASC', + 'fields' => 'ids', + 'post_status' => 'publish', + 'numberposts' => 1, + 'meta_query' => array(), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_query + ); + + // Allow large queries in case user has many variations or attributes. + $GLOBALS['wpdb']->query( 'SET SESSION SQL_BIG_SELECTS=1' ); + + foreach ( $product->get_attributes() as $attribute ) { + if ( ! $attribute->get_variation() ) { + continue; + } + + $attribute_field_name = 'attribute_' . sanitize_title( $attribute->get_name() ); + + if ( ! isset( $match_attributes[ $attribute_field_name ] ) ) { + return 0; + } + + // Note not wc_clean here to prevent removal of entities. + $value = $match_attributes[ $attribute_field_name ]; + + $query_args['meta_query'][] = array( + 'relation' => 'OR', + array( + 'key' => $attribute_field_name, + 'value' => array( '', $value ), + 'compare' => 'IN', + ), + array( + 'key' => $attribute_field_name, + 'compare' => 'NOT EXISTS', + ), + ); + } + + $variations = get_posts( $query_args ); + + if ( $variations && ! is_wp_error( $variations ) ) { + return current( $variations ); + } elseif ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.4.0', '<' ) ) { + /** + * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute. + * Fallback is here because there are cases where data will be 'synced' but the product version will remain the same. + */ + return ( array_map( 'sanitize_title', $match_attributes ) === $match_attributes ) ? 0 : $this->find_matching_product_variation( $product, array_map( 'sanitize_title', $match_attributes ) ); + } + + return 0; + } + + /** + * Make sure all variations have a sort order set so they can be reordered correctly. + * + * @param int $parent_id Product ID. + */ + public function sort_all_product_variations( $parent_id ) { + global $wpdb; + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $ids = $wpdb->get_col( + $wpdb->prepare( + "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product_variation' AND post_parent = %d AND post_status = 'publish' ORDER BY menu_order ASC, ID ASC", + $parent_id + ) + ); + $index = 1; + + foreach ( $ids as $id ) { + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->update( $wpdb->posts, array( 'menu_order' => ( $index++ ) ), array( 'ID' => absint( $id ) ) ); + } + } + + /** + * Return a list of related products (using data like categories and IDs). + * + * @since 3.0.0 + * @param array $cats_array List of categories IDs. + * @param array $tags_array List of tags IDs. + * @param array $exclude_ids Excluded IDs. + * @param int $limit Limit of results. + * @param int $product_id Product ID. + * @return array + */ + public function get_related_products( $cats_array, $tags_array, $exclude_ids, $limit, $product_id ) { + global $wpdb; + + $args = array( + 'categories' => $cats_array, + 'tags' => $tags_array, + 'exclude_ids' => $exclude_ids, + 'limit' => $limit + 10, + ); + + $related_product_query = (array) apply_filters( 'woocommerce_product_related_posts_query', $this->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id, $args ); + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery, WordPress.WP.PreparedSQL.NotPrepared + return $wpdb->get_col( implode( ' ', $related_product_query ) ); + } + + /** + * Builds the related posts query. + * + * @since 3.0.0 + * + * @param array $cats_array List of categories IDs. + * @param array $tags_array List of tags IDs. + * @param array $exclude_ids Excluded IDs. + * @param int $limit Limit of results. + * + * @return array + */ + public function get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit ) { + global $wpdb; + + $include_term_ids = array_merge( $cats_array, $tags_array ); + $exclude_term_ids = array(); + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + + if ( $product_visibility_term_ids['exclude-from-catalog'] ) { + $exclude_term_ids[] = $product_visibility_term_ids['exclude-from-catalog']; + } + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $product_visibility_term_ids['outofstock'] ) { + $exclude_term_ids[] = $product_visibility_term_ids['outofstock']; + } + + $query = array( + 'fields' => " + SELECT DISTINCT ID FROM {$wpdb->posts} p + ", + 'join' => '', + 'where' => " + WHERE 1=1 + AND p.post_status = 'publish' + AND p.post_type = 'product' + + ", + 'limits' => ' + LIMIT ' . absint( $limit ) . ' + ', + ); + + if ( count( $exclude_term_ids ) ) { + $query['join'] .= " LEFT JOIN ( SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( " . implode( ',', array_map( 'absint', $exclude_term_ids ) ) . ' ) ) AS exclude_join ON exclude_join.object_id = p.ID'; + $query['where'] .= ' AND exclude_join.object_id IS NULL'; + } + + if ( count( $include_term_ids ) ) { + $query['join'] .= " INNER JOIN ( SELECT object_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->term_taxonomy} using( term_taxonomy_id ) WHERE term_id IN ( " . implode( ',', array_map( 'absint', $include_term_ids ) ) . ' ) ) AS include_join ON include_join.object_id = p.ID'; + } + + if ( count( $exclude_ids ) ) { + $query['where'] .= ' AND p.ID NOT IN ( ' . implode( ',', array_map( 'absint', $exclude_ids ) ) . ' )'; + } + + return $query; + } + + /** + * Update a product's stock amount directly. + * + * Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues). + * + * @since 3.0.0 this supports set, increase and decrease. + * @param int $product_id_with_stock Product ID. + * @param int|null $stock_quantity Stock quantity. + * @param string $operation Set, increase and decrease. + */ + public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' ) { + global $wpdb; + add_post_meta( $product_id_with_stock, '_stock', 0, true ); + + // Update stock in DB directly. + switch ( $operation ) { + case 'increase': + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = meta_value + %f WHERE post_id = %d AND meta_key='_stock'", $stock_quantity, $product_id_with_stock + ) + ); + break; + case 'decrease': + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = meta_value - %f WHERE post_id = %d AND meta_key='_stock'", $stock_quantity, $product_id_with_stock + ) + ); + break; + default: + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='_stock'", $stock_quantity, $product_id_with_stock + ) + ); + break; + } + + wp_cache_delete( $product_id_with_stock, 'post_meta' ); + } + + /** + * Update a product's sale count directly. + * + * Uses queries rather than update_post_meta so we can do this in one query for performance. + * + * @since 3.0.0 this supports set, increase and decrease. + * @param int $product_id Product ID. + * @param int|null $quantity Quantity. + * @param string $operation set, increase and decrease. + */ + public function update_product_sales( $product_id, $quantity = null, $operation = 'set' ) { + global $wpdb; + add_post_meta( $product_id, 'total_sales', 0, true ); + + // Update stock in DB directly. + switch ( $operation ) { + case 'increase': + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = meta_value + %f WHERE post_id = %d AND meta_key='total_sales'", $quantity, $product_id + ) + ); + break; + case 'decrease': + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = meta_value - %f WHERE post_id = %d AND meta_key='total_sales'", $quantity, $product_id + ) + ); + break; + default: + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} SET meta_value = %f WHERE post_id = %d AND meta_key='total_sales'", $quantity, $product_id + ) + ); + break; + } + + wp_cache_delete( $product_id, 'post_meta' ); + } + + /** + * Update a products average rating meta. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function update_average_rating( $product ) { + update_post_meta( $product->get_id(), '_wc_average_rating', $product->get_average_rating( 'edit' ) ); + self::update_visibility( $product, true ); + } + + /** + * Update a products review count meta. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function update_review_count( $product ) { + update_post_meta( $product->get_id(), '_wc_review_count', $product->get_review_count( 'edit' ) ); + } + + /** + * Update a products rating counts. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function update_rating_counts( $product ) { + update_post_meta( $product->get_id(), '_wc_rating_count', $product->get_rating_counts( 'edit' ) ); + } + + /** + * Get shipping class ID by slug. + * + * @since 3.0.0 + * @param string $slug Product shipping class slug. + * @return int|false + */ + public function get_shipping_class_id_by_slug( $slug ) { + $shipping_class_term = get_term_by( 'slug', $slug, 'product_shipping_class' ); + if ( $shipping_class_term ) { + return $shipping_class_term->term_id; + } else { + return false; + } + } + + /** + * Returns an array of products. + * + * @param array $args Args to pass to WC_Product_Query(). + * @return array|object + * @see wc_get_products + */ + public function get_products( $args = array() ) { + $query = new WC_Product_Query( $args ); + return $query->get_products(); + } + + /** + * Search product data for a term and return ids. + * + * @param string $term Search term. + * @param string $type Type of product. + * @param bool $include_variations Include variations in search or not. + * @param bool $all_statuses Should we search all statuses or limit to published. + * @return array of ids + */ + public function search_products( $term, $type = '', $include_variations = false, $all_statuses = false ) { + global $wpdb; + + $post_types = $include_variations ? array( 'product', 'product_variation' ) : array( 'product' ); + $post_statuses = current_user_can( 'edit_private_products' ) ? array( 'private', 'publish' ) : array( 'publish' ); + $type_join = ''; + $type_where = ''; + $status_where = ''; + $term = wc_strtolower( $term ); + + // See if search term contains OR keywords. + if ( strstr( $term, ' or ' ) ) { + $term_groups = explode( ' or ', $term ); + } else { + $term_groups = array( $term ); + } + + $search_where = ''; + $search_queries = array(); + + foreach ( $term_groups as $term_group ) { + // Parse search terms. + if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $term_group, $matches ) ) { + $search_terms = $this->get_valid_search_terms( $matches[0] ); + $count = count( $search_terms ); + + // if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence. + if ( 9 < $count || 0 === $count ) { + $search_terms = array( $term_group ); + } + } else { + $search_terms = array( $term_group ); + } + + $term_group_query = ''; + $searchand = ''; + + foreach ( $search_terms as $search_term ) { + $like = '%' . $wpdb->esc_like( $search_term ) . '%'; + $term_group_query .= $wpdb->prepare( " {$searchand} ( ( posts.post_title LIKE %s) OR ( posts.post_excerpt LIKE %s) OR ( posts.post_content LIKE %s ) OR ( postmeta.meta_key = '_sku' AND postmeta.meta_value LIKE %s ) )", $like, $like, $like, $like ); // @codingStandardsIgnoreLine. + $searchand = ' AND '; + } + + if ( $term_group_query ) { + $search_queries[] = $term_group_query; + } + } + + if ( $search_queries ) { + $search_where = 'AND (' . implode( ') OR (', $search_queries ) . ')'; + } + + if ( $type && in_array( $type, array( 'virtual', 'downloadable' ), true ) ) { + $type_join = " LEFT JOIN {$wpdb->postmeta} postmeta_type ON posts.ID = postmeta_type.post_id "; + $type_where = " AND ( postmeta_type.meta_key = '_{$type}' AND postmeta_type.meta_value = 'yes' ) "; + } + + if ( ! $all_statuses ) { + $status_where = " AND posts.post_status IN ('" . implode( "','", $post_statuses ) . "') "; + } + + // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery + $search_results = $wpdb->get_results( + // phpcs:disable + "SELECT DISTINCT posts.ID as product_id, posts.post_parent as parent_id FROM {$wpdb->posts} posts + LEFT JOIN {$wpdb->postmeta} postmeta ON posts.ID = postmeta.post_id + $type_join + WHERE posts.post_type IN ('" . implode( "','", $post_types ) . "') + $search_where + $status_where + $type_where + ORDER BY posts.post_parent ASC, posts.post_title ASC" + // phpcs:enable + ); + + $product_ids = wp_parse_id_list( array_merge( wp_list_pluck( $search_results, 'product_id' ), wp_list_pluck( $search_results, 'parent_id' ) ) ); + + if ( is_numeric( $term ) ) { + $post_id = absint( $term ); + $post_type = get_post_type( $post_id ); + + if ( 'product_variation' === $post_type && $include_variations ) { + $product_ids[] = $post_id; + } elseif ( 'product' === $post_type ) { + $product_ids[] = $post_id; + } + + $product_ids[] = wp_get_post_parent_id( $post_id ); + } + + return wp_parse_id_list( $product_ids ); + } + + /** + * Get the product type based on product ID. + * + * @since 3.0.0 + * @param int $product_id Product ID. + * @return bool|string + */ + public function get_product_type( $product_id ) { + $post_type = get_post_type( $product_id ); + if ( 'product_variation' === $post_type ) { + return 'variation'; + } elseif ( 'product' === $post_type ) { + $terms = get_the_terms( $product_id, 'product_type' ); + return ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple'; + } else { + return false; + } + } + + /** + * Add ability to get products by 'reviews_allowed' in WC_Product_Query. + * + * @since 3.2.0 + * @param string $where Where clause. + * @param WP_Query $wp_query WP_Query instance. + * @return string + */ + public function reviews_allowed_query_where( $where, $wp_query ) { + global $wpdb; + + if ( isset( $wp_query->query_vars['reviews_allowed'] ) && is_bool( $wp_query->query_vars['reviews_allowed'] ) ) { + if ( $wp_query->query_vars['reviews_allowed'] ) { + $where .= " AND $wpdb->posts.comment_status = 'open'"; + } else { + $where .= " AND $wpdb->posts.comment_status = 'closed'"; + } + } + + return $where; + } + + /** + * Get valid WP_Query args from a WC_Product_Query's query variables. + * + * @since 3.2.0 + * @param array $query_vars Query vars from a WC_Product_Query. + * @return array + */ + protected function get_wp_query_args( $query_vars ) { + + // Map query vars to ones that get_wp_query_args or WP_Query recognize. + $key_mapping = array( + 'status' => 'post_status', + 'page' => 'paged', + 'include' => 'post__in', + 'stock_quantity' => 'stock', + 'average_rating' => 'wc_average_rating', + 'review_count' => 'wc_review_count', + ); + foreach ( $key_mapping as $query_key => $db_key ) { + if ( isset( $query_vars[ $query_key ] ) ) { + $query_vars[ $db_key ] = $query_vars[ $query_key ]; + unset( $query_vars[ $query_key ] ); + } + } + + // Map boolean queries that are stored as 'yes'/'no' in the DB to 'yes' or 'no'. + $boolean_queries = array( + 'virtual', + 'downloadable', + 'sold_individually', + 'manage_stock', + ); + foreach ( $boolean_queries as $boolean_query ) { + if ( isset( $query_vars[ $boolean_query ] ) && '' !== $query_vars[ $boolean_query ] ) { + $query_vars[ $boolean_query ] = $query_vars[ $boolean_query ] ? 'yes' : 'no'; + } + } + + // These queries cannot be auto-generated so we have to remove them and build them manually. + $manual_queries = array( + 'sku' => '', + 'featured' => '', + 'visibility' => '', + ); + foreach ( $manual_queries as $key => $manual_query ) { + if ( isset( $query_vars[ $key ] ) ) { + $manual_queries[ $key ] = $query_vars[ $key ]; + unset( $query_vars[ $key ] ); + } + } + + $wp_query_args = parent::get_wp_query_args( $query_vars ); + + if ( ! isset( $wp_query_args['date_query'] ) ) { + $wp_query_args['date_query'] = array(); + } + if ( ! isset( $wp_query_args['meta_query'] ) ) { + // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_query + $wp_query_args['meta_query'] = array(); + } + + // Handle product types. + if ( 'variation' === $query_vars['type'] ) { + $wp_query_args['post_type'] = 'product_variation'; + } elseif ( is_array( $query_vars['type'] ) && in_array( 'variation', $query_vars['type'], true ) ) { + $wp_query_args['post_type'] = array( 'product_variation', 'product' ); + $wp_query_args['tax_query'][] = array( + 'relation' => 'OR', + array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $query_vars['type'], + ), + array( + 'taxonomy' => 'product_type', + 'field' => 'id', + 'operator' => 'NOT EXISTS', + ), + ); + } else { + $wp_query_args['post_type'] = 'product'; + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_type', + 'field' => 'slug', + 'terms' => $query_vars['type'], + ); + } + + // Handle product categories. + if ( ! empty( $query_vars['category'] ) ) { + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_cat', + 'field' => 'slug', + 'terms' => $query_vars['category'], + ); + } + + // Handle product tags. + if ( ! empty( $query_vars['tag'] ) ) { + unset( $wp_query_args['tag'] ); + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_tag', + 'field' => 'slug', + 'terms' => $query_vars['tag'], + ); + } + + // Handle shipping classes. + if ( ! empty( $query_vars['shipping_class'] ) ) { + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_shipping_class', + 'field' => 'slug', + 'terms' => $query_vars['shipping_class'], + ); + } + + // Handle total_sales. + // This query doesn't get auto-generated since the meta key doesn't have the underscore prefix. + if ( isset( $query_vars['total_sales'] ) && '' !== $query_vars['total_sales'] ) { + $wp_query_args['meta_query'][] = array( + 'key' => 'total_sales', + 'value' => absint( $query_vars['total_sales'] ), + 'compare' => '=', + ); + } + + // Handle SKU. + if ( $manual_queries['sku'] ) { + $wp_query_args['meta_query'][] = array( + 'key' => '_sku', + 'value' => $manual_queries['sku'], + 'compare' => 'LIKE', + ); + } + + // Handle featured. + if ( '' !== $manual_queries['featured'] ) { + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + if ( $manual_queries['featured'] ) { + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => array( $product_visibility_term_ids['featured'] ), + ); + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => array( $product_visibility_term_ids['exclude-from-catalog'] ), + 'operator' => 'NOT IN', + ); + } else { + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => array( $product_visibility_term_ids['featured'] ), + 'operator' => 'NOT IN', + ); + } + } + + // Handle visibility. + if ( $manual_queries['visibility'] ) { + switch ( $manual_queries['visibility'] ) { + case 'search': + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'slug', + 'terms' => array( 'exclude-from-search' ), + 'operator' => 'NOT IN', + ); + break; + case 'catalog': + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'slug', + 'terms' => array( 'exclude-from-catalog' ), + 'operator' => 'NOT IN', + ); + break; + case 'visible': + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'slug', + 'terms' => array( 'exclude-from-catalog', 'exclude-from-search' ), + 'operator' => 'NOT IN', + ); + break; + case 'hidden': + $wp_query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'slug', + 'terms' => array( 'exclude-from-catalog', 'exclude-from-search' ), + 'operator' => 'AND', + ); + break; + } + } + + // Handle date queries. + $date_queries = array( + 'date_created' => 'post_date', + 'date_modified' => 'post_modified', + 'date_on_sale_from' => '_sale_price_dates_from', + 'date_on_sale_to' => '_sale_price_dates_to', + ); + foreach ( $date_queries as $query_var_key => $db_key ) { + if ( isset( $query_vars[ $query_var_key ] ) && '' !== $query_vars[ $query_var_key ] ) { + + // Remove any existing meta queries for the same keys to prevent conflicts. + $existing_queries = wp_list_pluck( $wp_query_args['meta_query'], 'key', true ); + foreach ( $existing_queries as $query_index => $query_contents ) { + unset( $wp_query_args['meta_query'][ $query_index ] ); + } + + $wp_query_args = $this->parse_date_for_wp_query( $query_vars[ $query_var_key ], $db_key, $wp_query_args ); + } + } + + // Handle paginate. + if ( ! isset( $query_vars['paginate'] ) || ! $query_vars['paginate'] ) { + $wp_query_args['no_found_rows'] = true; + } + + // Handle reviews_allowed. + if ( isset( $query_vars['reviews_allowed'] ) && is_bool( $query_vars['reviews_allowed'] ) ) { + add_filter( 'posts_where', array( $this, 'reviews_allowed_query_where' ), 10, 2 ); + } + + return apply_filters( 'woocommerce_product_data_store_cpt_get_products_query', $wp_query_args, $query_vars, $this ); + } + + /** + * Query for Products matching specific criteria. + * + * @since 3.2.0 + * + * @param array $query_vars Query vars from a WC_Product_Query. + * + * @return array|object + */ + public function query( $query_vars ) { + $args = $this->get_wp_query_args( $query_vars ); + + if ( ! empty( $args['errors'] ) ) { + $query = (object) array( + 'posts' => array(), + 'found_posts' => 0, + 'max_num_pages' => 0, + ); + } else { + $query = new WP_Query( $args ); + } + + if ( isset( $query_vars['return'] ) && 'objects' === $query_vars['return'] && ! empty( $query->posts ) ) { + // Prime caches before grabbing objects. + update_post_caches( $query->posts, array( 'product', 'product_variation' ) ); + } + + $products = ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) ? $query->posts : array_filter( array_map( 'wc_get_product', $query->posts ) ); + + if ( isset( $query_vars['paginate'] ) && $query_vars['paginate'] ) { + return (object) array( + 'products' => $products, + 'total' => $query->found_posts, + 'max_num_pages' => $query->max_num_pages, + ); + } + + return $products; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.php new file mode 100644 index 0000000..393663c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.php @@ -0,0 +1,88 @@ + 'children', + ); + + $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props ); + + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $product->{"get_$prop"}( 'edit' ); + $updated = update_post_meta( $product->get_id(), $meta_key, $value ); + if ( $updated ) { + $this->updated_props[] = $prop; + } + } + + parent::update_post_meta( $product, $force ); + } + + /** + * Handle updated meta props after updating meta data. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + protected function handle_updated_props( &$product ) { + if ( in_array( 'children', $this->updated_props, true ) ) { + $this->update_prices_from_children( $product ); + } + parent::handle_updated_props( $product ); + } + + /** + * Sync grouped product prices with children. + * + * @since 3.0.0 + * @param WC_Product|int $product Product object or product ID. + */ + public function sync_price( &$product ) { + $this->update_prices_from_children( $product ); + } + + /** + * Loop over child products and update the grouped product prices. + * + * @param WC_Product $product Product object. + */ + protected function update_prices_from_children( &$product ) { + $child_prices = array(); + foreach ( $product->get_children( 'edit' ) as $child_id ) { + $child = wc_get_product( $child_id ); + if ( $child ) { + $child_prices[] = $child->get_price(); + } + } + $child_prices = array_filter( $child_prices ); + delete_post_meta( $product->get_id(), '_price' ); + + if ( ! empty( $child_prices ) ) { + add_post_meta( $product->get_id(), '_price', min( $child_prices ) ); + add_post_meta( $product->get_id(), '_price', max( $child_prices ) ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php new file mode 100644 index 0000000..951a0dc --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.php @@ -0,0 +1,611 @@ +get_id(), '_product_attributes', true ); + + if ( ! empty( $meta_attributes ) && is_array( $meta_attributes ) ) { + $attributes = array(); + $force_update = false; + foreach ( $meta_attributes as $meta_attribute_key => $meta_attribute_value ) { + $meta_value = array_merge( + array( + 'name' => '', + 'value' => '', + 'position' => 0, + 'is_visible' => 0, + 'is_variation' => 0, + 'is_taxonomy' => 0, + ), (array) $meta_attribute_value + ); + + // Maintain data integrity. 4.9 changed sanitization functions - update the values here so variations function correctly. + if ( $meta_value['is_variation'] && strstr( $meta_value['name'], '/' ) && sanitize_title( $meta_value['name'] ) !== $meta_attribute_key ) { + global $wpdb; + + $old_slug = 'attribute_' . $meta_attribute_key; + $new_slug = 'attribute_' . sanitize_title( $meta_value['name'] ); + $old_meta_rows = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s;", $old_slug ) ); // WPCS: db call ok, cache ok. + + if ( $old_meta_rows ) { + foreach ( $old_meta_rows as $old_meta_row ) { + update_post_meta( $old_meta_row->post_id, $new_slug, $old_meta_row->meta_value ); + } + } + + $force_update = true; + } + + // Check if is a taxonomy attribute. + if ( ! empty( $meta_value['is_taxonomy'] ) ) { + if ( ! taxonomy_exists( $meta_value['name'] ) ) { + continue; + } + $id = wc_attribute_taxonomy_id_by_name( $meta_value['name'] ); + $options = wc_get_object_terms( $product->get_id(), $meta_value['name'], 'term_id' ); + } else { + $id = 0; + $options = wc_get_text_attributes( $meta_value['value'] ); + } + + $attribute = new WC_Product_Attribute(); + $attribute->set_id( $id ); + $attribute->set_name( $meta_value['name'] ); + $attribute->set_options( $options ); + $attribute->set_position( $meta_value['position'] ); + $attribute->set_visible( $meta_value['is_visible'] ); + $attribute->set_variation( $meta_value['is_variation'] ); + $attributes[] = $attribute; + } + $product->set_attributes( $attributes ); + + if ( $force_update ) { + $this->update_attributes( $product, true ); + } + } + } + + /** + * Read product data. + * + * @since 3.0.0 + * + * @param WC_Product $product Product object. + */ + protected function read_product_data( &$product ) { + parent::read_product_data( $product ); + + // Make sure data which does not apply to variables is unset. + $product->set_regular_price( '' ); + $product->set_sale_price( '' ); + } + + /** + * Loads variation child IDs. + * + * @param WC_Product $product Product object. + * @param bool $force_read True to bypass the transient. + * @return array + */ + public function read_children( &$product, $force_read = false ) { + $children_transient_name = 'wc_product_children_' . $product->get_id(); + $children = get_transient( $children_transient_name ); + + if ( empty( $children ) || ! is_array( $children ) || ! isset( $children['all'] ) || ! isset( $children['visible'] ) || $force_read ) { + $all_args = array( + 'post_parent' => $product->get_id(), + 'post_type' => 'product_variation', + 'orderby' => array( + 'menu_order' => 'ASC', + 'ID' => 'ASC', + ), + 'fields' => 'ids', + 'post_status' => array( 'publish', 'private' ), + 'numberposts' => -1, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_numberposts + ); + + $visible_only_args = $all_args; + $visible_only_args['post_status'] = 'publish'; + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { + $visible_only_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'name', + 'terms' => 'outofstock', + 'operator' => 'NOT IN', + ); + } + $children['all'] = get_posts( apply_filters( 'woocommerce_variable_children_args', $all_args, $product, false ) ); + $children['visible'] = get_posts( apply_filters( 'woocommerce_variable_children_args', $visible_only_args, $product, true ) ); + + set_transient( $children_transient_name, $children, DAY_IN_SECONDS * 30 ); + } + + $children['all'] = wp_parse_id_list( (array) $children['all'] ); + $children['visible'] = wp_parse_id_list( (array) $children['visible'] ); + + return $children; + } + + /** + * Loads an array of attributes used for variations, as well as their possible values. + * + * @param WC_Product $product Product object. + * @return array + */ + public function read_variation_attributes( &$product ) { + global $wpdb; + + $variation_attributes = array(); + $attributes = $product->get_attributes(); + $child_ids = $product->get_children(); + $cache_key = WC_Cache_Helper::get_cache_prefix( 'products' ) . 'product_variation_attributes_' . $product->get_id(); + $cache_group = 'products'; + $cached_data = wp_cache_get( $cache_key, $cache_group ); + + if ( false !== $cached_data ) { + return $cached_data; + } + + if ( ! empty( $child_ids ) && ! empty( $attributes ) ) { + foreach ( $attributes as $attribute ) { + if ( empty( $attribute['is_variation'] ) ) { + continue; + } + + // Get possible values for this attribute, for only visible variations. + $values = array_unique( + $wpdb->get_col( + $wpdb->prepare( + "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN (" . implode( ',', array_map( 'absint', $child_ids ) ) . ')', // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + wc_variation_attribute_name( $attribute['name'] ) + ) + ) + ); + + // Empty value indicates that all options for given attribute are available. + if ( in_array( null, $values, true ) || in_array( '', $values, true ) || empty( $values ) ) { + $values = $attribute['is_taxonomy'] ? wc_get_object_terms( $product->get_id(), $attribute['name'], 'slug' ) : wc_get_text_attributes( $attribute['value'] ); + // Get custom attributes (non taxonomy) as defined. + } elseif ( ! $attribute['is_taxonomy'] ) { + $text_attributes = wc_get_text_attributes( $attribute['value'] ); + $assigned_text_attributes = $values; + $values = array(); + + // Pre 2.4 handling where 'slugs' were saved instead of the full text attribute. + if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.4.0', '<' ) ) { + $assigned_text_attributes = array_map( 'sanitize_title', $assigned_text_attributes ); + foreach ( $text_attributes as $text_attribute ) { + if ( in_array( sanitize_title( $text_attribute ), $assigned_text_attributes, true ) ) { + $values[] = $text_attribute; + } + } + } else { + foreach ( $text_attributes as $text_attribute ) { + if ( in_array( $text_attribute, $assigned_text_attributes, true ) ) { + $values[] = $text_attribute; + } + } + } + } + $variation_attributes[ $attribute['name'] ] = array_unique( $values ); + } + } + + wp_cache_set( $cache_key, $variation_attributes, $cache_group ); + + return $variation_attributes; + } + + /** + * Get an array of all sale and regular prices from all variations. This is used for example when displaying the price range at variable product level or seeing if the variable product is on sale. + * + * Can be filtered by plugins which modify costs, but otherwise will include the raw meta costs unlike get_price() which runs costs through the woocommerce_get_price filter. + * This is to ensure modified prices are not cached, unless intended. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $for_display If true, prices will be adapted for display based on the `woocommerce_tax_display_shop` setting (including or excluding taxes). + * @return array of prices + */ + public function read_price_data( &$product, $for_display = false ) { + + /** + * Transient name for storing prices for this product (note: Max transient length is 45) + * + * @since 2.5.0 a single transient is used per product for all prices, rather than many transients per product. + */ + $transient_name = 'wc_var_prices_' . $product->get_id(); + + $price_hash = $this->get_price_hash( $product, $for_display ); + + /** + * $this->prices_array is an array of values which may have been modified from what is stored in transients - this may not match $transient_cached_prices_array. + * If the value has already been generated, we don't need to grab the values again so just return them. They are already filtered. + */ + if ( empty( $this->prices_array[ $price_hash ] ) ) { + $transient_cached_prices_array = array_filter( (array) json_decode( strval( get_transient( $transient_name ) ), true ) ); + + // If the product version has changed since the transient was last saved, reset the transient cache. + if ( empty( $transient_cached_prices_array['version'] ) || WC_Cache_Helper::get_transient_version( 'product' ) !== $transient_cached_prices_array['version'] ) { + $transient_cached_prices_array = array( 'version' => WC_Cache_Helper::get_transient_version( 'product' ) ); + } + + // If the prices are not stored for this hash, generate them and add to the transient. + if ( empty( $transient_cached_prices_array[ $price_hash ] ) ) { + $prices = array(); + $regular_prices = array(); + $sale_prices = array(); + $variation_ids = $product->get_visible_children(); + foreach ( $variation_ids as $variation_id ) { + $variation = wc_get_product( $variation_id ); + + if ( $variation ) { + $price = apply_filters( 'woocommerce_variation_prices_price', $variation->get_price( 'edit' ), $variation, $product ); + $regular_price = apply_filters( 'woocommerce_variation_prices_regular_price', $variation->get_regular_price( 'edit' ), $variation, $product ); + $sale_price = apply_filters( 'woocommerce_variation_prices_sale_price', $variation->get_sale_price( 'edit' ), $variation, $product ); + + // Skip empty prices. + if ( '' === $price ) { + continue; + } + + // If sale price does not equal price, the product is not yet on sale. + if ( $sale_price === $regular_price || $sale_price !== $price ) { + $sale_price = $regular_price; + } + + // If we are getting prices for display, we need to account for taxes. + if ( $for_display ) { + if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) { + $price = '' === $price ? '' : wc_get_price_including_tax( + $variation, array( + 'qty' => 1, + 'price' => $price, + ) + ); + $regular_price = '' === $regular_price ? '' : wc_get_price_including_tax( + $variation, array( + 'qty' => 1, + 'price' => $regular_price, + ) + ); + $sale_price = '' === $sale_price ? '' : wc_get_price_including_tax( + $variation, array( + 'qty' => 1, + 'price' => $sale_price, + ) + ); + } else { + $price = '' === $price ? '' : wc_get_price_excluding_tax( + $variation, array( + 'qty' => 1, + 'price' => $price, + ) + ); + $regular_price = '' === $regular_price ? '' : wc_get_price_excluding_tax( + $variation, array( + 'qty' => 1, + 'price' => $regular_price, + ) + ); + $sale_price = '' === $sale_price ? '' : wc_get_price_excluding_tax( + $variation, array( + 'qty' => 1, + 'price' => $sale_price, + ) + ); + } + } + + $prices[ $variation_id ] = wc_format_decimal( $price, wc_get_price_decimals() ); + $regular_prices[ $variation_id ] = wc_format_decimal( $regular_price, wc_get_price_decimals() ); + $sale_prices[ $variation_id ] = wc_format_decimal( $sale_price . '.00', wc_get_price_decimals() ); + } + } + + $transient_cached_prices_array[ $price_hash ] = array( + 'price' => $prices, + 'regular_price' => $regular_prices, + 'sale_price' => $sale_prices, + ); + + set_transient( $transient_name, wp_json_encode( $transient_cached_prices_array ), DAY_IN_SECONDS * 30 ); + } + + /** + * Give plugins one last chance to filter the variation prices array which has been generated and store locally to the class. + * This value may differ from the transient cache. It is filtered once before storing locally. + */ + $this->prices_array[ $price_hash ] = apply_filters( 'woocommerce_variation_prices', $transient_cached_prices_array[ $price_hash ], $product, $for_display ); + } + return $this->prices_array[ $price_hash ]; + } + + /** + * Create unique cache key based on the tax location (affects displayed/cached prices), product version and active price filters. + * DEVELOPERS should filter this hash if offering conditional pricing to keep it unique. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $for_display If taxes should be calculated or not. + * @return string + */ + protected function get_price_hash( &$product, $for_display = false ) { + global $wp_filter; + + $price_hash = $for_display && wc_tax_enabled() ? array( get_option( 'woocommerce_tax_display_shop', 'excl' ), WC_Tax::get_rates() ) : array( false ); + $filter_names = array( 'woocommerce_variation_prices_price', 'woocommerce_variation_prices_regular_price', 'woocommerce_variation_prices_sale_price' ); + + foreach ( $filter_names as $filter_name ) { + if ( ! empty( $wp_filter[ $filter_name ] ) ) { + $price_hash[ $filter_name ] = array(); + + foreach ( $wp_filter[ $filter_name ] as $priority => $callbacks ) { + $price_hash[ $filter_name ][] = array_values( wp_list_pluck( $callbacks, 'function' ) ); + } + } + } + + $price_hash[] = WC_Cache_Helper::get_transient_version( 'product' ); + $price_hash = md5( + wp_json_encode( + apply_filters( 'woocommerce_get_variation_prices_hash', $price_hash, $product, $for_display ) + ) + ); + + return $price_hash; + } + + /** + * Does a child have a weight set? + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @return boolean + */ + public function child_has_weight( $product ) { + global $wpdb; + $children = $product->get_visible_children(); + return $children ? null !== $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_weight' AND meta_value > 0 AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )' ) : false; // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + } + + /** + * Does a child have dimensions set? + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @return boolean + */ + public function child_has_dimensions( $product ) { + global $wpdb; + $children = $product->get_visible_children(); + return $children ? null !== $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_length', '_width', '_height' ) AND meta_value > 0 AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )' ) : false; // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + } + + /** + * Is a child in stock? + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @return boolean + */ + public function child_is_in_stock( $product ) { + return $this->child_has_stock_status( $product, 'instock' ); + } + + /** + * Does a child have a stock status? + * + * @since 3.3.0 + * @param WC_Product $product Product object. + * @param string $status 'instock', 'outofstock', or 'onbackorder'. + * @return boolean + */ + public function child_has_stock_status( $product, $status ) { + global $wpdb; + + $children = $product->get_children(); + + if ( $children ) { + $children_with_status = $wpdb->get_var( + $wpdb->prepare( + "SELECT COUNT( post_id ) FROM $wpdb->postmeta WHERE meta_key = '_stock_status' AND meta_value = %s AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )', // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + $status + ) + ); + } else { + $children_with_status = 0; + } + + return (bool) $children_with_status; + } + + /** + * Syncs all variation names if the parent name is changed. + * + * @param WC_Product $product Product object. + * @param string $previous_name Variation previous name. + * @param string $new_name Variation new name. + * @since 3.0.0 + */ + public function sync_variation_names( &$product, $previous_name = '', $new_name = '' ) { + if ( $new_name !== $previous_name ) { + global $wpdb; + + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->posts} + SET post_title = REPLACE( post_title, %s, %s ) + WHERE post_type = 'product_variation' + AND post_parent = %d", + $previous_name ? $previous_name : 'AUTO-DRAFT', + $new_name, + $product->get_id() + ) + ); + } + } + + /** + * Stock managed at the parent level - update children being managed by this product. + * This sync function syncs downwards (from parent to child) when the variable product is saved. + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + public function sync_managed_variation_stock_status( &$product ) { + global $wpdb; + + if ( $product->get_manage_stock() ) { + $status = $product->get_stock_status(); + $children = $product->get_children(); + $managed_children = $children ? array_unique( $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_manage_stock' AND meta_value != 'yes' AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )' ) ) : array(); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + $changed = false; + foreach ( $managed_children as $managed_child ) { + if ( update_post_meta( $managed_child, '_stock_status', $status ) ) { + $changed = true; + } + } + if ( $changed ) { + $children = $this->read_children( $product, true ); + $product->set_children( $children['all'] ); + $product->set_visible_children( $children['visible'] ); + } + } + } + + /** + * Sync variable product prices with children. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function sync_price( &$product ) { + global $wpdb; + + $children = $product->get_visible_children(); + $prices = $children ? array_unique( $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_price' AND post_id IN ( " . implode( ',', array_map( 'absint', $children ) ) . ' )' ) ) : array(); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + + delete_post_meta( $product->get_id(), '_price' ); + + if ( $prices ) { + sort( $prices ); + // To allow sorting and filtering by multiple values, we have no choice but to store child prices in this manner. + foreach ( $prices as $price ) { + if ( is_null( $price ) || '' === $price ) { + continue; + } + add_post_meta( $product->get_id(), '_price', $price, false ); + } + } + } + + /** + * Sync variable product stock status with children. + * Change does not persist unless saved by caller. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function sync_stock_status( &$product ) { + if ( $product->child_is_in_stock() ) { + $product->set_stock_status( 'instock' ); + } elseif ( $product->child_is_on_backorder() ) { + $product->set_stock_status( 'onbackorder' ); + } else { + $product->set_stock_status( 'outofstock' ); + } + } + + /** + * Delete variations of a product. + * + * @since 3.0.0 + * @param int $product_id Product ID. + * @param bool $force_delete False to trash. + */ + public function delete_variations( $product_id, $force_delete = false ) { + if ( ! is_numeric( $product_id ) || 0 >= $product_id ) { + return; + } + + $variation_ids = wp_parse_id_list( + get_posts( + array( + 'post_parent' => $product_id, + 'post_type' => 'product_variation', + 'fields' => 'ids', + 'post_status' => array( 'any', 'trash', 'auto-draft' ), + 'numberposts' => -1, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_numberposts + ) + ) + ); + + if ( ! empty( $variation_ids ) ) { + foreach ( $variation_ids as $variation_id ) { + if ( $force_delete ) { + wp_delete_post( $variation_id, true ); + } else { + wp_trash_post( $variation_id ); + } + } + } + + delete_transient( 'wc_product_children_' . $product_id ); + } + + /** + * Untrash variations. + * + * @param int $product_id Product ID. + */ + public function untrash_variations( $product_id ) { + $variation_ids = wp_parse_id_list( + get_posts( + array( + 'post_parent' => $product_id, + 'post_type' => 'product_variation', + 'fields' => 'ids', + 'post_status' => 'trash', + 'numberposts' => -1, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_numberposts + ) + ) + ); + + if ( ! empty( $variation_ids ) ) { + foreach ( $variation_ids as $variation_id ) { + wp_untrash_post( $variation_id ); + } + } + + delete_transient( 'wc_product_children_' . $product_id ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php new file mode 100644 index 0000000..e98d178 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-variation-data-store-cpt.php @@ -0,0 +1,470 @@ +meta_key, $this->internal_meta_keys, true ) && 0 !== stripos( $meta->meta_key, 'attribute_' ) && 0 !== stripos( $meta->meta_key, 'wp_' ); + } + + /* + |-------------------------------------------------------------------------- + | CRUD Methods + |-------------------------------------------------------------------------- + */ + + /** + * Reads a product from the database and sets its data to the class. + * + * @since 3.0.0 + * @param WC_Product $product Product object. $product Product object. + */ + public function read( &$product ) { + $product->set_defaults(); + + if ( ! $product->get_id() ) { + return; + } + + $post_object = get_post( $product->get_id() ); + + if ( ! $post_object || ! in_array( $post_object->post_type, array( 'product', 'product_variation' ), true ) ) { + return; + } + + $product->set_props( + array( + 'name' => $post_object->post_title, + 'slug' => $post_object->post_name, + 'date_created' => 0 < $post_object->post_date_gmt ? wc_string_to_timestamp( $post_object->post_date_gmt ) : null, + 'date_modified' => 0 < $post_object->post_modified_gmt ? wc_string_to_timestamp( $post_object->post_modified_gmt ) : null, + 'status' => $post_object->post_status, + 'menu_order' => $post_object->menu_order, + 'reviews_allowed' => 'open' === $post_object->comment_status, + 'parent_id' => $post_object->post_parent, + ) + ); + + // The post parent is not a valid variable product so we should prevent this. + if ( $product->get_parent_id( 'edit' ) && 'product' !== get_post_type( $product->get_parent_id( 'edit' ) ) ) { + $product->set_parent_id( 0 ); + } + + $this->read_downloads( $product ); + $this->read_product_data( $product ); + $this->read_extra_data( $product ); + $product->set_attributes( wc_get_product_variation_attributes( $product->get_id() ) ); + + /** + * If a variation title is not in sync with the parent e.g. saved prior to 3.0, or if the parent title has changed, detect here and update. + */ + $new_title = $this->generate_product_title( $product ); + + if ( $post_object->post_title !== $new_title ) { + $product->set_name( $new_title ); + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, array( 'post_title' => $new_title ), array( 'ID' => $product->get_id() ) ); + clean_post_cache( $product->get_id() ); + } + + // Set object_read true once all data is read. + $product->set_object_read( true ); + } + + /** + * Create a new product. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function create( &$product ) { + if ( ! $product->get_date_created() ) { + $product->set_date_created( current_time( 'timestamp', true ) ); + } + + $new_title = $this->generate_product_title( $product ); + + if ( $product->get_name( 'edit' ) !== $new_title ) { + $product->set_name( $new_title ); + } + + // The post parent is not a valid variable product so we should prevent this. + if ( $product->get_parent_id( 'edit' ) && 'product' !== get_post_type( $product->get_parent_id( 'edit' ) ) ) { + $product->set_parent_id( 0 ); + } + + $id = wp_insert_post( + apply_filters( + 'woocommerce_new_product_variation_data', array( + 'post_type' => 'product_variation', + 'post_status' => $product->get_status() ? $product->get_status() : 'publish', + 'post_author' => get_current_user_id(), + 'post_title' => $product->get_name( 'edit' ), + 'post_content' => '', + 'post_parent' => $product->get_parent_id(), + 'comment_status' => 'closed', + 'ping_status' => 'closed', + 'menu_order' => $product->get_menu_order(), + 'post_date' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getTimestamp() ), + 'post_name' => $product->get_slug( 'edit' ), + ) + ), true + ); + + if ( $id && ! is_wp_error( $id ) ) { + $product->set_id( $id ); + + $this->update_post_meta( $product, true ); + $this->update_terms( $product, true ); + $this->update_visibility( $product, true ); + $this->update_attributes( $product, true ); + $this->handle_updated_props( $product ); + + $product->save_meta_data(); + $product->apply_changes(); + + $this->update_version_and_type( $product ); + + $this->clear_caches( $product ); + + do_action( 'woocommerce_new_product_variation', $id ); + } + } + + /** + * Updates an existing product. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + */ + public function update( &$product ) { + $product->save_meta_data(); + + if ( ! $product->get_date_created() ) { + $product->set_date_created( current_time( 'timestamp', true ) ); + } + + $new_title = $this->generate_product_title( $product ); + + if ( $product->get_name( 'edit' ) !== $new_title ) { + $product->set_name( $new_title ); + } + + // The post parent is not a valid variable product so we should prevent this. + if ( $product->get_parent_id( 'edit' ) && 'product' !== get_post_type( $product->get_parent_id( 'edit' ) ) ) { + $product->set_parent_id( 0 ); + } + + $changes = $product->get_changes(); + + // Only update the post when the post data changes. + if ( array_intersect( array( 'name', 'parent_id', 'status', 'menu_order', 'date_created', 'date_modified' ), array_keys( $changes ) ) ) { + $post_data = array( + 'post_title' => $product->get_name( 'edit' ), + 'post_parent' => $product->get_parent_id( 'edit' ), + 'comment_status' => 'closed', + 'post_status' => $product->get_status( 'edit' ) ? $product->get_status( 'edit' ) : 'publish', + 'menu_order' => $product->get_menu_order( 'edit' ), + 'post_date' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getOffsetTimestamp() ), + 'post_date_gmt' => gmdate( 'Y-m-d H:i:s', $product->get_date_created( 'edit' )->getTimestamp() ), + 'post_modified' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $product->get_date_modified( 'edit' )->getOffsetTimestamp() ) : current_time( 'mysql' ), + 'post_modified_gmt' => isset( $changes['date_modified'] ) ? gmdate( 'Y-m-d H:i:s', $product->get_date_modified( 'edit' )->getTimestamp() ) : current_time( 'mysql', 1 ), + 'post_type' => 'product_variation', + 'post_name' => $product->get_slug( 'edit' ), + ); + + /** + * When updating this object, to prevent infinite loops, use $wpdb + * to update data, since wp_update_post spawns more calls to the + * save_post action. + * + * This ensures hooks are fired by either WP itself (admin screen save), + * or an update purely from CRUD. + */ + if ( doing_action( 'save_post' ) ) { + $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $product->get_id() ) ); + clean_post_cache( $product->get_id() ); + } else { + wp_update_post( array_merge( array( 'ID' => $product->get_id() ), $post_data ) ); + } + $product->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook. + + } else { // Only update post modified time to record this save event. + $GLOBALS['wpdb']->update( + $GLOBALS['wpdb']->posts, + array( + 'post_modified' => current_time( 'mysql' ), + 'post_modified_gmt' => current_time( 'mysql', 1 ), + ), + array( + 'ID' => $product->get_id(), + ) + ); + clean_post_cache( $product->get_id() ); + } + + $this->update_post_meta( $product ); + $this->update_terms( $product ); + $this->update_visibility( $product, true ); + $this->update_attributes( $product ); + $this->handle_updated_props( $product ); + + $product->apply_changes(); + + $this->update_version_and_type( $product ); + + $this->clear_caches( $product ); + + do_action( 'woocommerce_update_product_variation', $product->get_id() ); + } + + /* + |-------------------------------------------------------------------------- + | Additional Methods + |-------------------------------------------------------------------------- + */ + + /** + * Generates a title with attribute information for a variation. + * Products will get a title of the form "Name - Value, Value" or just "Name". + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @return string + */ + protected function generate_product_title( $product ) { + $attributes = (array) $product->get_attributes(); + + // Do not include attributes if the product has 3+ attributes. + $should_include_attributes = count( $attributes ) < 3; + + // Do not include attributes if an attribute name has 2+ words and the + // product has multiple attributes. + if ( $should_include_attributes && 1 < count( $attributes ) ) { + foreach ( $attributes as $name => $value ) { + if ( false !== strpos( $name, '-' ) ) { + $should_include_attributes = false; + break; + } + } + } + + $should_include_attributes = apply_filters( 'woocommerce_product_variation_title_include_attributes', $should_include_attributes, $product ); + $separator = apply_filters( 'woocommerce_product_variation_title_attributes_separator', ' - ', $product ); + $title_base = get_post_field( 'post_title', $product->get_parent_id() ); + $title_suffix = $should_include_attributes ? wc_get_formatted_variation( $product, true, false ) : ''; + + return apply_filters( 'woocommerce_product_variation_title', $title_suffix ? $title_base . $separator . $title_suffix : $title_base, $product, $title_base, $title_suffix ); + } + + /** + * Make sure we store the product version (to track data changes). + * + * @param WC_Product $product Product object. + * @since 3.0.0 + */ + protected function update_version_and_type( &$product ) { + wp_set_object_terms( $product->get_id(), '', 'product_type' ); + update_post_meta( $product->get_id(), '_product_version', WC_VERSION ); + } + + /** + * Read post data. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @throws WC_Data_Exception If WC_Product::set_tax_status() is called with an invalid tax status. + */ + protected function read_product_data( &$product ) { + $id = $product->get_id(); + + $product->set_props( + array( + 'description' => get_post_meta( $id, '_variation_description', true ), + 'regular_price' => get_post_meta( $id, '_regular_price', true ), + 'sale_price' => get_post_meta( $id, '_sale_price', true ), + 'date_on_sale_from' => get_post_meta( $id, '_sale_price_dates_from', true ), + 'date_on_sale_to' => get_post_meta( $id, '_sale_price_dates_to', true ), + 'manage_stock' => get_post_meta( $id, '_manage_stock', true ), + 'stock_status' => get_post_meta( $id, '_stock_status', true ), + 'shipping_class_id' => current( $this->get_term_ids( $id, 'product_shipping_class' ) ), + 'virtual' => get_post_meta( $id, '_virtual', true ), + 'downloadable' => get_post_meta( $id, '_downloadable', true ), + 'gallery_image_ids' => array_filter( explode( ',', get_post_meta( $id, '_product_image_gallery', true ) ) ), + 'download_limit' => get_post_meta( $id, '_download_limit', true ), + 'download_expiry' => get_post_meta( $id, '_download_expiry', true ), + 'image_id' => get_post_thumbnail_id( $id ), + 'backorders' => get_post_meta( $id, '_backorders', true ), + 'sku' => get_post_meta( $id, '_sku', true ), + 'stock_quantity' => get_post_meta( $id, '_stock', true ), + 'weight' => get_post_meta( $id, '_weight', true ), + 'length' => get_post_meta( $id, '_length', true ), + 'width' => get_post_meta( $id, '_width', true ), + 'height' => get_post_meta( $id, '_height', true ), + 'tax_class' => ! metadata_exists( 'post', $id, '_tax_class' ) ? 'parent' : get_post_meta( $id, '_tax_class', true ), + ) + ); + + if ( $product->is_on_sale( 'edit' ) ) { + $product->set_price( $product->get_sale_price( 'edit' ) ); + } else { + $product->set_price( $product->get_regular_price( 'edit' ) ); + } + + $parent_object = get_post( $product->get_parent_id() ); + $terms = get_the_terms( $product->get_parent_id(), 'product_visibility' ); + $term_names = is_array( $terms ) ? wp_list_pluck( $terms, 'name' ) : array(); + $exclude_search = in_array( 'exclude-from-search', $term_names, true ); + $exclude_catalog = in_array( 'exclude-from-catalog', $term_names, true ); + + if ( $exclude_search && $exclude_catalog ) { + $catalog_visibility = 'hidden'; + } elseif ( $exclude_search ) { + $catalog_visibility = 'catalog'; + } elseif ( $exclude_catalog ) { + $catalog_visibility = 'search'; + } else { + $catalog_visibility = 'visible'; + } + + $product->set_parent_data( + array( + 'title' => $parent_object ? $parent_object->post_title : '', + 'status' => $parent_object ? $parent_object->post_status : '', + 'sku' => get_post_meta( $product->get_parent_id(), '_sku', true ), + 'manage_stock' => get_post_meta( $product->get_parent_id(), '_manage_stock', true ), + 'backorders' => get_post_meta( $product->get_parent_id(), '_backorders', true ), + 'stock_quantity' => wc_stock_amount( get_post_meta( $product->get_parent_id(), '_stock', true ) ), + 'weight' => get_post_meta( $product->get_parent_id(), '_weight', true ), + 'length' => get_post_meta( $product->get_parent_id(), '_length', true ), + 'width' => get_post_meta( $product->get_parent_id(), '_width', true ), + 'height' => get_post_meta( $product->get_parent_id(), '_height', true ), + 'tax_class' => get_post_meta( $product->get_parent_id(), '_tax_class', true ), + 'shipping_class_id' => absint( current( $this->get_term_ids( $product->get_parent_id(), 'product_shipping_class' ) ) ), + 'image_id' => get_post_thumbnail_id( $product->get_parent_id() ), + 'purchase_note' => get_post_meta( $product->get_parent_id(), '_purchase_note', true ), + 'catalog_visibility' => $catalog_visibility, + ) + ); + + // Pull data from the parent when there is no user-facing way to set props. + $product->set_sold_individually( get_post_meta( $product->get_parent_id(), '_sold_individually', true ) ); + $product->set_tax_status( get_post_meta( $product->get_parent_id(), '_tax_status', true ) ); + $product->set_cross_sell_ids( get_post_meta( $product->get_parent_id(), '_crosssell_ids', true ) ); + } + + /** + * For all stored terms in all taxonomies, save them to the DB. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + */ + protected function update_terms( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_key_exists( 'shipping_class_id', $changes ) ) { + wp_set_post_terms( $product->get_id(), array( $product->get_shipping_class_id( 'edit' ) ), 'product_shipping_class', false ); + } + } + + /** + * Update visibility terms based on props. + * + * @since 3.0.0 + * + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + */ + protected function update_visibility( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_intersect( array( 'stock_status' ), array_keys( $changes ) ) ) { + $terms = array(); + + if ( 'outofstock' === $product->get_stock_status() ) { + $terms[] = 'outofstock'; + } + + wp_set_post_terms( $product->get_id(), $terms, 'product_visibility', false ); + } + } + + /** + * Update attribute meta values. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + */ + protected function update_attributes( &$product, $force = false ) { + $changes = $product->get_changes(); + + if ( $force || array_key_exists( 'attributes', $changes ) ) { + global $wpdb; + $attributes = $product->get_attributes(); + $updated_attribute_keys = array(); + foreach ( $attributes as $key => $value ) { + update_post_meta( $product->get_id(), 'attribute_' . $key, $value ); + $updated_attribute_keys[] = 'attribute_' . $key; + } + + // Remove old taxonomies attributes so data is kept up to date - first get attribute key names. + $delete_attribute_keys = $wpdb->get_col( + $wpdb->prepare( + "SELECT meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE %s AND meta_key NOT IN ( '" . implode( "','", array_map( 'esc_sql', $updated_attribute_keys ) ) . "' ) AND post_id = %d", // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration + $wpdb->esc_like( 'attribute_' ) . '%', + $product->get_id() + ) + ); + + foreach ( $delete_attribute_keys as $key ) { + delete_post_meta( $product->get_id(), $key ); + } + } + } + + /** + * Helper method that updates all the post meta for a product based on it's settings in the WC_Product class. + * + * @since 3.0.0 + * @param WC_Product $product Product object. + * @param bool $force Force update. Used during create. + */ + public function update_post_meta( &$product, $force = false ) { + $meta_key_to_props = array( + '_variation_description' => 'description', + ); + + $props_to_update = $force ? $meta_key_to_props : $this->get_props_to_update( $product, $meta_key_to_props ); + + foreach ( $props_to_update as $meta_key => $prop ) { + $value = $product->{"get_$prop"}( 'edit' ); + $updated = update_post_meta( $product->get_id(), $meta_key, $value ); + if ( $updated ) { + $this->updated_props[] = $prop; + } + } + + parent::update_post_meta( $product, $force ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-shipping-zone-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-shipping-zone-data-store.php new file mode 100644 index 0000000..c6b9f8e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-shipping-zone-data-store.php @@ -0,0 +1,328 @@ +insert( + $wpdb->prefix . 'woocommerce_shipping_zones', array( + 'zone_name' => $zone->get_zone_name(), + 'zone_order' => $zone->get_zone_order(), + ) + ); + $zone->set_id( $wpdb->insert_id ); + $zone->save_meta_data(); + $this->save_locations( $zone ); + $zone->apply_changes(); + WC_Cache_Helper::incr_cache_prefix( 'shipping_zones' ); + WC_Cache_Helper::get_transient_version( 'shipping', true ); + } + + /** + * Update zone in the database. + * + * @since 3.0.0 + * @param WC_Shipping_Zone $zone Shipping zone object. + */ + public function update( &$zone ) { + global $wpdb; + if ( $zone->get_id() ) { + $wpdb->update( + $wpdb->prefix . 'woocommerce_shipping_zones', array( + 'zone_name' => $zone->get_zone_name(), + 'zone_order' => $zone->get_zone_order(), + ), array( 'zone_id' => $zone->get_id() ) + ); + } + $zone->save_meta_data(); + $this->save_locations( $zone ); + $zone->apply_changes(); + WC_Cache_Helper::incr_cache_prefix( 'shipping_zones' ); + WC_Cache_Helper::get_transient_version( 'shipping', true ); + } + + /** + * Method to read a shipping zone from the database. + * + * @since 3.0.0 + * @param WC_Shipping_Zone $zone Shipping zone object. + * @throws Exception If invalid data store. + */ + public function read( &$zone ) { + global $wpdb; + + $zone_data = false; + + if ( 0 !== $zone->get_id() || '0' !== $zone->get_id() ) { + $zone_data = $wpdb->get_row( + $wpdb->prepare( + "SELECT zone_name, zone_order FROM {$wpdb->prefix}woocommerce_shipping_zones WHERE zone_id = %d LIMIT 1", + $zone->get_id() + ) + ); + } + + if ( 0 === $zone->get_id() || '0' === $zone->get_id() ) { + $this->read_zone_locations( $zone ); + $zone->set_zone_name( __( 'Locations not covered by your other zones', 'woocommerce' ) ); + $zone->read_meta_data(); + $zone->set_object_read( true ); + do_action( 'woocommerce_shipping_zone_loaded', $zone ); + } elseif ( $zone_data ) { + $zone->set_zone_name( $zone_data->zone_name ); + $zone->set_zone_order( $zone_data->zone_order ); + $this->read_zone_locations( $zone ); + $zone->read_meta_data(); + $zone->set_object_read( true ); + do_action( 'woocommerce_shipping_zone_loaded', $zone ); + } else { + throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); + } + } + + /** + * Deletes a shipping zone from the database. + * + * @since 3.0.0 + * @param WC_Shipping_Zone $zone Shipping zone object. + * @param array $args Array of args to pass to the delete method. + * @return void + */ + public function delete( &$zone, $args = array() ) { + if ( $zone->get_id() ) { + global $wpdb; + $wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zone_methods', array( 'zone_id' => $zone->get_id() ) ); + $wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zone_locations', array( 'zone_id' => $zone->get_id() ) ); + $wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zones', array( 'zone_id' => $zone->get_id() ) ); + WC_Cache_Helper::incr_cache_prefix( 'shipping_zones' ); + $id = $zone->get_id(); + $zone->set_id( null ); + WC_Cache_Helper::incr_cache_prefix( 'shipping_zones' ); + WC_Cache_Helper::get_transient_version( 'shipping', true ); + do_action( 'woocommerce_delete_shipping_zone', $id ); + } + } + + /** + * Get a list of shipping methods for a specific zone. + * + * @since 3.0.0 + * @param int $zone_id Zone ID. + * @param bool $enabled_only True to request enabled methods only. + * @return array Array of objects containing method_id, method_order, instance_id, is_enabled + */ + public function get_methods( $zone_id, $enabled_only ) { + global $wpdb; + + if ( $enabled_only ) { + $raw_methods_sql = "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d AND is_enabled = 1"; + } else { + $raw_methods_sql = "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d"; + } + + return $wpdb->get_results( $wpdb->prepare( $raw_methods_sql, $zone_id ) ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + } + + /** + * Get count of methods for a zone. + * + * @since 3.0.0 + * @param int $zone_id Zone ID. + * @return int Method Count + */ + public function get_method_count( $zone_id ) { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d", $zone_id ) ); + } + + /** + * Add a shipping method to a zone. + * + * @since 3.0.0 + * @param int $zone_id Zone ID. + * @param string $type Method Type/ID. + * @param int $order Method Order. + * @return int Instance ID + */ + public function add_method( $zone_id, $type, $order ) { + global $wpdb; + $wpdb->insert( + $wpdb->prefix . 'woocommerce_shipping_zone_methods', + array( + 'method_id' => $type, + 'zone_id' => $zone_id, + 'method_order' => $order, + ), + array( + '%s', + '%d', + '%d', + ) + ); + return $wpdb->insert_id; + } + + /** + * Delete a method instance. + * + * @since 3.0.0 + * @param int $instance_id Instance ID. + */ + public function delete_method( $instance_id ) { + global $wpdb; + $wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zone_methods', array( 'instance_id' => $instance_id ) ); + do_action( 'woocommerce_delete_shipping_zone_method', $instance_id ); + } + + /** + * Get a shipping zone method instance. + * + * @since 3.0.0 + * @param int $instance_id Instance ID. + * @return object + */ + public function get_method( $instance_id ) { + global $wpdb; + return $wpdb->get_row( $wpdb->prepare( "SELECT zone_id, method_id, instance_id, method_order, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE instance_id = %d LIMIT 1;", $instance_id ) ); + } + + /** + * Find a matching zone ID for a given package. + * + * @since 3.0.0 + * @param object $package Package information. + * @return int + */ + public function get_zone_id_from_package( $package ) { + global $wpdb; + + $country = strtoupper( wc_clean( $package['destination']['country'] ) ); + $state = strtoupper( wc_clean( $package['destination']['state'] ) ); + $continent = strtoupper( wc_clean( WC()->countries->get_continent_code_for_country( $country ) ) ); + $postcode = wc_normalize_postcode( wc_clean( $package['destination']['postcode'] ) ); + + // Work out criteria for our zone search. + $criteria = array(); + $criteria[] = $wpdb->prepare( "( ( location_type = 'country' AND location_code = %s )", $country ); + $criteria[] = $wpdb->prepare( "OR ( location_type = 'state' AND location_code = %s )", $country . ':' . $state ); + $criteria[] = $wpdb->prepare( "OR ( location_type = 'continent' AND location_code = %s )", $continent ); + $criteria[] = 'OR ( location_type IS NULL ) )'; + + // Postcode range and wildcard matching. + $postcode_locations = $wpdb->get_results( "SELECT zone_id, location_code FROM {$wpdb->prefix}woocommerce_shipping_zone_locations WHERE location_type = 'postcode';" ); + + if ( $postcode_locations ) { + $zone_ids_with_postcode_rules = array_map( 'absint', wp_list_pluck( $postcode_locations, 'zone_id' ) ); + $matches = wc_postcode_location_matcher( $postcode, $postcode_locations, 'zone_id', 'location_code', $country ); + $do_not_match = array_unique( array_diff( $zone_ids_with_postcode_rules, array_keys( $matches ) ) ); + + if ( ! empty( $do_not_match ) ) { + $criteria[] = 'AND zones.zone_id NOT IN (' . implode( ',', $do_not_match ) . ')'; + } + } + + // Get matching zones. + return $wpdb->get_var( + "SELECT zones.zone_id FROM {$wpdb->prefix}woocommerce_shipping_zones as zones + LEFT OUTER JOIN {$wpdb->prefix}woocommerce_shipping_zone_locations as locations ON zones.zone_id = locations.zone_id AND location_type != 'postcode' + WHERE " . implode( ' ', $criteria ) // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared + . ' ORDER BY zone_order ASC, zone_id ASC LIMIT 1' + ); + } + + /** + * Return an ordered list of zones. + * + * @since 3.0.0 + * @return array An array of objects containing a zone_id, zone_name, and zone_order. + */ + public function get_zones() { + global $wpdb; + return $wpdb->get_results( "SELECT zone_id, zone_name, zone_order FROM {$wpdb->prefix}woocommerce_shipping_zones order by zone_order ASC, zone_id ASC;" ); + } + + + /** + * Return a zone ID from an instance ID. + * + * @since 3.0.0 + * @param int $id Instnace ID. + * @return int + */ + public function get_zone_id_by_instance_id( $id ) { + global $wpdb; + return $wpdb->get_var( $wpdb->prepare( "SELECT zone_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods as methods WHERE methods.instance_id = %d LIMIT 1;", $id ) ); + } + + /** + * Read location data from the database. + * + * @param WC_Shipping_Zone $zone Shipping zone object. + */ + private function read_zone_locations( &$zone ) { + global $wpdb; + + $locations = $wpdb->get_results( + $wpdb->prepare( + "SELECT location_code, location_type FROM {$wpdb->prefix}woocommerce_shipping_zone_locations WHERE zone_id = %d", + $zone->get_id() + ) + ); + + if ( $locations ) { + foreach ( $locations as $location ) { + $zone->add_location( $location->location_code, $location->location_type ); + } + } + } + + /** + * Save locations to the DB. + * This function clears old locations, then re-inserts new if any changes are found. + * + * @since 3.0.0 + * + * @param WC_Shipping_Zone $zone Shipping zone object. + * + * @return bool|void + */ + private function save_locations( &$zone ) { + $changed_props = array_keys( $zone->get_changes() ); + if ( ! in_array( 'zone_locations', $changed_props, true ) ) { + return false; + } + + global $wpdb; + $wpdb->delete( $wpdb->prefix . 'woocommerce_shipping_zone_locations', array( 'zone_id' => $zone->get_id() ) ); + + foreach ( $zone->get_zone_locations( 'edit' ) as $location ) { + $wpdb->insert( + $wpdb->prefix . 'woocommerce_shipping_zone_locations', array( + 'zone_id' => $zone->get_id(), + 'location_code' => $location->code, + 'location_type' => $location->type, + ) + ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-webhook-data-store.php b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-webhook-data-store.php new file mode 100644 index 0000000..fd3a53b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/data-stores/class-wc-webhook-data-store.php @@ -0,0 +1,352 @@ +get_changes(); + if ( isset( $changes['date_created'] ) ) { + $date_created = $webhook->get_date_created()->date( 'Y-m-d H:i:s' ); + $date_created_gmt = gmdate( 'Y-m-d H:i:s', $webhook->get_date_created()->getTimestamp() ); + } else { + $date_created = current_time( 'mysql' ); + $date_created_gmt = current_time( 'mysql', 1 ); + $webhook->set_date_created( $date_created ); + } + + // Pending delivery by default if not set while creating a new webhook. + if ( ! isset( $changes['pending_delivery'] ) ) { + $webhook->set_pending_delivery( true ); + } + + $data = array( + 'status' => $webhook->get_status( 'edit' ), + 'name' => $webhook->get_name( 'edit' ), + 'user_id' => $webhook->get_user_id( 'edit' ), + 'delivery_url' => $webhook->get_delivery_url( 'edit' ), + 'secret' => $webhook->get_secret( 'edit' ), + 'topic' => $webhook->get_topic( 'edit' ), + 'date_created' => $date_created, + 'date_created_gmt' => $date_created_gmt, + 'api_version' => $this->get_api_version_number( $webhook->get_api_version( 'edit' ) ), + 'failure_count' => $webhook->get_failure_count( 'edit' ), + 'pending_delivery' => $webhook->get_pending_delivery( 'edit' ), + ); + + $wpdb->insert( $wpdb->prefix . 'wc_webhooks', $data ); // WPCS: DB call ok. + + $webhook_id = $wpdb->insert_id; + $webhook->set_id( $webhook_id ); + $webhook->apply_changes(); + + delete_transient( 'woocommerce_webhook_ids' ); + WC_Cache_Helper::incr_cache_prefix( 'webhooks' ); + do_action( 'woocommerce_new_webhook', $webhook_id ); + } + + /** + * Read a webhook from the database. + * + * @since 3.3.0 + * @param WC_Webhook $webhook Webhook instance. + * @throws Exception When webhook is invalid. + */ + public function read( &$webhook ) { + global $wpdb; + + $data = wp_cache_get( $webhook->get_id(), 'webhooks' ); + + if ( false === $data ) { + $data = $wpdb->get_row( $wpdb->prepare( "SELECT webhook_id, status, name, user_id, delivery_url, secret, topic, date_created, date_modified, api_version, failure_count, pending_delivery FROM {$wpdb->prefix}wc_webhooks WHERE webhook_id = %d LIMIT 1;", $webhook->get_id() ), ARRAY_A ); // WPCS: cache ok, DB call ok. + + wp_cache_add( $webhook->get_id(), $data, 'webhooks' ); + } + + if ( is_array( $data ) ) { + $webhook->set_props( + array( + 'id' => $data['webhook_id'], + 'status' => $data['status'], + 'name' => $data['name'], + 'user_id' => $data['user_id'], + 'delivery_url' => $data['delivery_url'], + 'secret' => $data['secret'], + 'topic' => $data['topic'], + 'date_created' => '0000-00-00 00:00:00' === $data['date_created'] ? null : $data['date_created'], + 'date_modified' => '0000-00-00 00:00:00' === $data['date_modified'] ? null : $data['date_modified'], + 'api_version' => $data['api_version'], + 'failure_count' => $data['failure_count'], + 'pending_delivery' => $data['pending_delivery'], + ) + ); + $webhook->set_object_read( true ); + + do_action( 'woocommerce_webhook_loaded', $webhook ); + } else { + throw new Exception( __( 'Invalid webhook.', 'woocommerce' ) ); + } + } + + /** + * Update a webhook. + * + * @since 3.3.0 + * @param WC_Webhook $webhook Webhook instance. + */ + public function update( &$webhook ) { + global $wpdb; + + $changes = $webhook->get_changes(); + $trigger = isset( $changes['delivery_url'] ); + + if ( isset( $changes['date_modified'] ) ) { + $date_modified = $webhook->get_date_modified()->date( 'Y-m-d H:i:s' ); + $date_modified_gmt = gmdate( 'Y-m-d H:i:s', $webhook->get_date_modified()->getTimestamp() ); + } else { + $date_modified = current_time( 'mysql' ); + $date_modified_gmt = current_time( 'mysql', 1 ); + $webhook->set_date_modified( $date_modified ); + } + + $data = array( + 'status' => $webhook->get_status( 'edit' ), + 'name' => $webhook->get_name( 'edit' ), + 'user_id' => $webhook->get_user_id( 'edit' ), + 'delivery_url' => $webhook->get_delivery_url( 'edit' ), + 'secret' => $webhook->get_secret( 'edit' ), + 'topic' => $webhook->get_topic( 'edit' ), + 'date_modified' => $date_modified, + 'date_modified_gmt' => $date_modified_gmt, + 'api_version' => $this->get_api_version_number( $webhook->get_api_version( 'edit' ) ), + 'failure_count' => $webhook->get_failure_count( 'edit' ), + 'pending_delivery' => $webhook->get_pending_delivery( 'edit' ), + ); + + $wpdb->update( + $wpdb->prefix . 'wc_webhooks', + $data, + array( + 'webhook_id' => $webhook->get_id( 'edit' ), + ) + ); // WPCS: DB call ok. + + $webhook->apply_changes(); + + wp_cache_delete( $webhook->get_id(), 'webhooks' ); + WC_Cache_Helper::incr_cache_prefix( 'webhooks' ); + + if ( 'active' === $webhook->get_status() && ( $trigger || $webhook->get_pending_delivery() ) ) { + $webhook->deliver_ping(); + } + + do_action( 'woocommerce_webhook_updated', $webhook->get_id() ); + } + + /** + * Remove a webhook from the database. + * + * @since 3.3.0 + * @param WC_Webhook $webhook Webhook instance. + * @param bool $force_delete Skip trash bin forcing to delete. + */ + public function delete( &$webhook, $force_delete = false ) { + global $wpdb; + + $wpdb->delete( + $wpdb->prefix . 'wc_webhooks', + array( + 'webhook_id' => $webhook->get_id(), + ), + array( '%d' ) + ); // WPCS: cache ok, DB call ok. + + delete_transient( 'woocommerce_webhook_ids' ); + WC_Cache_Helper::incr_cache_prefix( 'webhooks' ); + do_action( 'woocommerce_webhook_deleted', $webhook->get_id(), $webhook ); + } + + /** + * Get API version number. + * + * @since 3.3.0 + * @param string $api_version REST API version. + * @return int + */ + public function get_api_version_number( $api_version ) { + return 'legacy_v3' === $api_version ? -1 : intval( substr( $api_version, -1 ) ); + } + + /** + * Get all webhooks IDs. + * + * @since 3.3.0 + * @return int[] + */ + public function get_webhooks_ids() { + global $wpdb; + + $ids = get_transient( 'woocommerce_webhook_ids' ); + + if ( false === $ids ) { + $results = $wpdb->get_results( "SELECT webhook_id FROM {$wpdb->prefix}wc_webhooks" ); // WPCS: cache ok, DB call ok. + $ids = array_map( 'intval', wp_list_pluck( $results, 'webhook_id' ) ); + + set_transient( 'woocommerce_webhook_ids', $ids ); + } + + return $ids; + } + + /** + * Search webhooks. + * + * @param array $args Search arguments. + * @return array + */ + public function search_webhooks( $args ) { + global $wpdb; + + $args = wp_parse_args( + $args, array( + 'limit' => 10, + 'offset' => 0, + 'order' => 'DESC', + 'orderby' => 'id', + ) + ); + + // Map post statuses. + $statuses = array( + 'publish' => 'active', + 'draft' => 'paused', + 'pending' => 'disabled', + ); + + // Map orderby to support a few post keys. + $orderby_mapping = array( + 'ID' => 'webhook_id', + 'id' => 'webhook_id', + 'name' => 'name', + 'title' => 'name', + 'post_title' => 'name', + 'post_name' => 'name', + 'date_created' => 'date_created_gmt', + 'date' => 'date_created_gmt', + 'post_date' => 'date_created_gmt', + 'date_modified' => 'date_modified_gmt', + 'modified' => 'date_modified_gmt', + 'post_modified' => 'date_modified_gmt', + ); + $orderby = isset( $orderby_mapping[ $args['orderby'] ] ) ? $orderby_mapping[ $args['orderby'] ] : 'webhook_id'; + + $limit = -1 < $args['limit'] ? sprintf( 'LIMIT %d', $args['limit'] ) : ''; + $offset = 0 < $args['offset'] ? sprintf( 'OFFSET %d', $args['offset'] ) : ''; + $status = ! empty( $args['status'] ) ? "AND `status` = '" . sanitize_key( isset( $statuses[ $args['status'] ] ) ? $statuses[ $args['status'] ] : $args['status'] ) . "'" : ''; + $search = ! empty( $args['search'] ) ? "AND `name` LIKE '%" . $wpdb->esc_like( sanitize_text_field( $args['search'] ) ) . "%'" : ''; + $include = ''; + $exclude = ''; + $date_created = ''; + $date_modified = ''; + + if ( ! empty( $args['include'] ) ) { + $args['include'] = implode( ',', wp_parse_id_list( $args['include'] ) ); + $include = 'AND webhook_id IN (' . $args['include'] . ')'; + } + + if ( ! empty( $args['exclude'] ) ) { + $args['exclude'] = implode( ',', wp_parse_id_list( $args['exclude'] ) ); + $exclude = 'AND webhook_id NOT IN (' . $args['exclude'] . ')'; + } + + if ( ! empty( $args['after'] ) || ! empty( $args['before'] ) ) { + $args['after'] = empty( $args['after'] ) ? '0000-00-00' : $args['after']; + $args['before'] = empty( $args['before'] ) ? current_time( 'mysql', 1 ) : $args['before']; + + $date_created = "AND `date_created_gmt` BETWEEN STR_TO_DATE('" . $args['after'] . "', '%Y-%m-%d %H:%i:%s') and STR_TO_DATE('" . $args['before'] . "', '%Y-%m-%d %H:%i:%s')"; + } + + if ( ! empty( $args['modified_after'] ) || ! empty( $args['modified_before'] ) ) { + $args['modified_after'] = empty( $args['modified_after'] ) ? '0000-00-00' : $args['modified_after']; + $args['modified_before'] = empty( $args['modified_before'] ) ? current_time( 'mysql', 1 ) : $args['modified_before']; + + $date_modified = "AND `date_modified_gmt` BETWEEN STR_TO_DATE('" . $args['modified_after'] . "', '%Y-%m-%d %H:%i:%s') and STR_TO_DATE('" . $args['modified_before'] . "', '%Y-%m-%d %H:%i:%s')"; + } + + $order = "ORDER BY {$orderby} " . strtoupper( sanitize_key( $args['order'] ) ); + + // Check for cache. + $cache_key = WC_Cache_Helper::get_cache_prefix( 'webhooks' ) . 'search_webhooks' . md5( implode( ',', $args ) ); + $ids = wp_cache_get( $cache_key, 'webhook_search_results' ); + + if ( false !== $ids ) { + return $ids; + } + + $query = trim( + "SELECT webhook_id + FROM {$wpdb->prefix}wc_webhooks + WHERE 1=1 + {$status} + {$search} + {$include} + {$exclude} + {$date_created} + {$date_modified} + {$order} + {$limit} + {$offset}" + ); + + $results = $wpdb->get_results( $query ); // WPCS: cache ok, DB call ok, unprepared SQL ok. + + $ids = wp_list_pluck( $results, 'webhook_id' ); + wp_cache_set( $cache_key, $ids, 'webhook_search_results' ); + + return $ids; + } + + /** + * Get total webhook counts by status. + * + * @return array + */ + public function get_count_webhooks_by_status() { + $statuses = array_keys( wc_get_webhook_statuses() ); + $counts = array(); + + foreach ( $statuses as $status ) { + $count = count( + $this->search_webhooks( + array( + 'limit' => -1, + 'status' => $status, + ) + ) + ); + + $counts[ $status ] = $count; + } + + return $counts; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-cancelled-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-cancelled-order.php new file mode 100644 index 0000000..fc61471 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-cancelled-order.php @@ -0,0 +1,186 @@ +id = 'cancelled_order'; + $this->title = __( 'Cancelled order', 'woocommerce' ); + $this->description = __( 'Cancelled order emails are sent to chosen recipient(s) when orders have been marked cancelled (if they were previously processing or on-hold).', 'woocommerce' ); + $this->template_html = 'emails/admin-cancelled-order.php'; + $this->template_plain = 'emails/plain/admin-cancelled-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_processing_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_on-hold_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + + // Other settings. + $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) ); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( '[{site_title}] Cancelled order ({order_number})', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Cancelled order', 'woocommerce' ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'recipient' => array( + 'title' => __( 'Recipient(s)', 'woocommerce' ), + 'type' => 'text', + /* translators: %s: admin email */ + 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '' . esc_attr( get_option( 'admin_email' ) ) . '' ), + 'placeholder' => '', + 'default' => '', + 'desc_tip' => true, + ), + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_Cancelled_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-completed-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-completed-order.php new file mode 100644 index 0000000..87a2fac --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-completed-order.php @@ -0,0 +1,175 @@ +id = 'customer_completed_order'; + $this->customer_email = true; + $this->title = __( 'Completed order', 'woocommerce' ); + $this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' ); + $this->template_html = 'emails/customer-completed-order.php'; + $this->template_plain = 'emails/plain/customer-completed-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->recipient = $this->object->get_billing_email(); + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Your {site_title} order from {order_date} is complete', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Your order is complete', 'woocommerce' ); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_Customer_Completed_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php new file mode 100644 index 0000000..ee332af --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php @@ -0,0 +1,230 @@ +id = 'customer_invoice'; + $this->customer_email = true; + $this->title = __( 'Customer invoice / Order details', 'woocommerce' ); + $this->description = __( 'Customer invoice emails can be sent to customers containing their order information and payment links.', 'woocommerce' ); + $this->template_html = 'emails/customer-invoice.php'; + $this->template_plain = 'emails/plain/customer-invoice.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Call parent constructor. + parent::__construct(); + + $this->manual = true; + } + + /** + * Get email subject. + * + * @param bool $paid Whether the order has been paid or not. + * @since 3.1.0 + * @return string + */ + public function get_default_subject( $paid = false ) { + if ( $paid ) { + return __( 'Your {site_title} order from {order_date}', 'woocommerce' ); + } else { + return __( 'Invoice for order {order_number}', 'woocommerce' ); + } + } + + /** + * Get email heading. + * + * @param bool $paid Whether the order has been paid or not. + * @since 3.1.0 + * @return string + */ + public function get_default_heading( $paid = false ) { + if ( $paid ) { + return __( 'Your order details', 'woocommerce' ); + } else { + return __( 'Invoice for order {order_number}', 'woocommerce' ); + } + } + + /** + * Get email subject. + * + * @access public + * @return string + */ + public function get_subject() { + if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) { + $subject = $this->get_option( 'subject_paid', $this->get_default_subject( true ) ); + + return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $subject ), $this->object ); + } + + $subject = $this->get_option( 'subject', $this->get_default_subject() ); + return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $subject ), $this->object ); + } + + /** + * Get email heading. + * + * @access public + * @return string + */ + public function get_heading() { + if ( $this->object->has_status( wc_get_is_paid_statuses() ) ) { + $heading = $this->get_option( 'heading_paid', $this->get_default_heading( true ) ); + return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $heading ), $this->object ); + } + + $heading = $this->get_option( 'heading', $this->get_default_heading() ); + return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $heading ), $this->object ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->recipient = $this->object->get_billing_email(); + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'subject_paid' => array( + 'title' => __( 'Subject (paid)', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject( true ), + 'default' => '', + ), + 'heading_paid' => array( + 'title' => __( 'Email heading (paid)', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading( true ), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_Customer_Invoice(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-new-account.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-new-account.php new file mode 100644 index 0000000..413321f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-new-account.php @@ -0,0 +1,161 @@ +id = 'customer_new_account'; + $this->customer_email = true; + $this->title = __( 'New account', 'woocommerce' ); + $this->description = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account pages.', 'woocommerce' ); + $this->template_html = 'emails/customer-new-account.php'; + $this->template_plain = 'emails/plain/customer-new-account.php'; + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Your account on {site_title}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Welcome to {site_title}', 'woocommerce' ); + } + + /** + * Trigger. + * + * @param int $user_id User ID. + * @param string $user_pass User password. + * @param bool $password_generated Whether the password was generated automatically or not. + */ + public function trigger( $user_id, $user_pass = '', $password_generated = false ) { + $this->setup_locale(); + + if ( $user_id ) { + $this->object = new WP_User( $user_id ); + + $this->user_pass = $user_pass; + $this->user_login = stripslashes( $this->object->user_login ); + $this->user_email = stripslashes( $this->object->user_email ); + $this->recipient = $this->user_email; + $this->password_generated = $password_generated; + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'email_heading' => $this->get_heading(), + 'user_login' => $this->user_login, + 'user_pass' => $this->user_pass, + 'blogname' => $this->get_blogname(), + 'password_generated' => $this->password_generated, + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'email_heading' => $this->get_heading(), + 'user_login' => $this->user_login, + 'user_pass' => $this->user_pass, + 'blogname' => $this->get_blogname(), + 'password_generated' => $this->password_generated, + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + } + +endif; + +return new WC_Email_Customer_New_Account(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-note.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-note.php new file mode 100644 index 0000000..30af000 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-note.php @@ -0,0 +1,155 @@ +id = 'customer_note'; + $this->customer_email = true; + $this->title = __( 'Customer note', 'woocommerce' ); + $this->description = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' ); + $this->template_html = 'emails/customer-note.php'; + $this->template_plain = 'emails/plain/customer-note.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers. + add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Note added to your {site_title} order from {order_date}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'A note has been added to your order', 'woocommerce' ); + } + + /** + * Trigger. + * + * @param array $args Email arguments. + */ + public function trigger( $args ) { + $this->setup_locale(); + + if ( ! empty( $args ) ) { + $defaults = array( + 'order_id' => '', + 'customer_note' => '', + ); + + $args = wp_parse_args( $args, $defaults ); + + $order_id = $args['order_id']; + $customer_note = $args['customer_note']; + + if ( $order_id ) { + $this->object = wc_get_order( $order_id ); + + if ( $this->object ) { + $this->recipient = $this->object->get_billing_email(); + $this->customer_note = $customer_note; + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + } + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'customer_note' => $this->customer_note, + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'customer_note' => $this->customer_note, + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + } + +endif; + +return new WC_Email_Customer_Note(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-on-hold-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-on-hold-order.php new file mode 100644 index 0000000..1a379a1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-on-hold-order.php @@ -0,0 +1,136 @@ +id = 'customer_on_hold_order'; + $this->customer_email = true; + $this->title = __( 'Order on-hold', 'woocommerce' ); + $this->description = __( 'This is an order notification sent to customers containing order details after an order is placed on-hold.', 'woocommerce' ); + $this->template_html = 'emails/customer-on-hold-order.php'; + $this->template_plain = 'emails/plain/customer-on-hold-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Your {site_title} order receipt from {order_date}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Thank you for your order', 'woocommerce' ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->recipient = $this->object->get_billing_email(); + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + } + +endif; + +return new WC_Email_Customer_On_Hold_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-processing-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-processing-order.php new file mode 100644 index 0000000..d6649a5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-processing-order.php @@ -0,0 +1,138 @@ +id = 'customer_processing_order'; + $this->customer_email = true; + + $this->title = __( 'Processing order', 'woocommerce' ); + $this->description = __( 'This is an order notification sent to customers containing order details after payment.', 'woocommerce' ); + $this->template_html = 'emails/customer-processing-order.php'; + $this->template_plain = 'emails/plain/customer-processing-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Your {site_title} order receipt from {order_date}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Thank you for your order', 'woocommerce' ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->recipient = $this->object->get_billing_email(); + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + } + +endif; + +return new WC_Email_Customer_Processing_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php new file mode 100644 index 0000000..f43b257 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php @@ -0,0 +1,285 @@ +customer_email = true; + $this->id = 'customer_refunded_order'; + $this->title = __( 'Refunded order', 'woocommerce' ); + $this->description = __( 'Order refunded emails are sent to customers when their orders are refunded.', 'woocommerce' ); + $this->template_html = 'emails/customer-refunded-order.php'; + $this->template_plain = 'emails/plain/customer-refunded-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10, 2 ); + add_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger_partial' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @param bool $partial Whether it is a partial refund or a full refund. + * @since 3.1.0 + * @return string + */ + public function get_default_subject( $partial = false ) { + if ( $partial ) { + return __( 'Your {site_title} order from {order_date} has been partially refunded', 'woocommerce' ); + } else { + return __( 'Your {site_title} order from {order_date} has been refunded', 'woocommerce' ); + } + } + + /** + * Get email heading. + * + * @param bool $partial Whether it is a partial refund or a full refund. + * @since 3.1.0 + * @return string + */ + public function get_default_heading( $partial = false ) { + if ( $partial ) { + return __( 'Your order has been partially refunded', 'woocommerce' ); + } else { + return __( 'Order {order_number} details', 'woocommerce' ); + } + } + + /** + * Get email subject. + * + * @access public + * @return string + */ + public function get_subject() { + if ( $this->partial_refund ) { + $subject = $this->get_option( 'subject_partial', $this->get_default_subject( true ) ); + } else { + $subject = $this->get_option( 'subject_full', $this->get_default_subject() ); + } + return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object ); + } + + /** + * Get email heading. + * + * @access public + * @return string + */ + public function get_heading() { + if ( $this->partial_refund ) { + $heading = $this->get_option( 'heading_partial', $this->get_default_heading( true ) ); + } else { + $heading = $this->get_option( 'heading_full', $this->get_default_heading() ); + } + return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $heading ), $this->object ); + } + + /** + * Set email strings. + * + * @param bool $partial_refund Whether it is a partial refund or a full refund. + * @deprecated 3.1.0 Unused. + */ + public function set_email_strings( $partial_refund = false ) {} + + /** + * Full refund notification. + * + * @param int $order_id Order ID. + * @param int $refund_id Refund ID. + */ + public function trigger_full( $order_id, $refund_id = null ) { + $this->trigger( $order_id, false, $refund_id ); + } + + /** + * Partial refund notification. + * + * @param int $order_id Order ID. + * @param int $refund_id Refund ID. + */ + public function trigger_partial( $order_id, $refund_id = null ) { + $this->trigger( $order_id, true, $refund_id ); + } + + /** + * Trigger. + * + * @param int $order_id Order ID. + * @param bool $partial_refund Whether it is a partial refund or a full refund. + * @param int $refund_id Refund ID. + */ + public function trigger( $order_id, $partial_refund = false, $refund_id = null ) { + $this->setup_locale(); + $this->partial_refund = $partial_refund; + $this->id = $this->partial_refund ? 'customer_partially_refunded_order' : 'customer_refunded_order'; + + if ( $order_id ) { + $this->object = wc_get_order( $order_id ); + $this->recipient = $this->object->get_billing_email(); + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( ! empty( $refund_id ) ) { + $this->refund = wc_get_order( $refund_id ); + } else { + $this->refund = false; + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'refund' => $this->refund, + 'partial_refund' => $this->partial_refund, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'refund' => $this->refund, + 'partial_refund' => $this->partial_refund, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'subject_full' => array( + 'title' => __( 'Full refund subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'subject_partial' => array( + 'title' => __( 'Partial refund subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject( true ), + 'default' => '', + ), + 'heading_full' => array( + 'title' => __( 'Full refund email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'heading_partial' => array( + 'title' => __( 'Partial refund email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading( true ), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_Customer_Refunded_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-reset-password.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-reset-password.php new file mode 100644 index 0000000..a5d2057 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-reset-password.php @@ -0,0 +1,165 @@ +id = 'customer_reset_password'; + $this->customer_email = true; + + $this->title = __( 'Reset password', 'woocommerce' ); + $this->description = __( 'Customer "reset password" emails are sent when customers reset their passwords.', 'woocommerce' ); + + $this->template_html = 'emails/customer-reset-password.php'; + $this->template_plain = 'emails/plain/customer-reset-password.php'; + + // Trigger. + add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( 'Password reset for {site_title}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Password reset instructions', 'woocommerce' ); + } + + /** + * Trigger. + * + * @param string $user_login User login. + * @param string $reset_key Password reset key. + */ + public function trigger( $user_login = '', $reset_key = '' ) { + $this->setup_locale(); + + if ( $user_login && $reset_key ) { + $this->object = get_user_by( 'login', $user_login ); + $this->user_id = $this->object->ID; + $this->user_login = $user_login; + $this->reset_key = $reset_key; + $this->user_email = stripslashes( $this->object->user_email ); + $this->recipient = $this->user_email; + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'email_heading' => $this->get_heading(), + 'user_id' => $this->user_id, + 'user_login' => $this->user_login, + 'reset_key' => $this->reset_key, + 'blogname' => $this->get_blogname(), + 'sent_to_admin' => false, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'email_heading' => $this->get_heading(), + 'user_id' => $this->user_id, + 'user_login' => $this->user_login, + 'reset_key' => $this->reset_key, + 'blogname' => $this->get_blogname(), + 'sent_to_admin' => false, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + } + +endif; + +return new WC_Email_Customer_Reset_Password(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-failed-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-failed-order.php new file mode 100644 index 0000000..b8f7f76 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-failed-order.php @@ -0,0 +1,186 @@ +id = 'failed_order'; + $this->title = __( 'Failed order', 'woocommerce' ); + $this->description = __( 'Failed order emails are sent to chosen recipient(s) when orders have been marked failed (if they were previously processing or on-hold).', 'woocommerce' ); + $this->template_html = 'emails/admin-failed-order.php'; + $this->template_plain = 'emails/plain/admin-failed-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_pending_to_failed_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_on-hold_to_failed_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + + // Other settings. + $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) ); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( '[{site_title}] Failed order ({order_number})', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'Failed order', 'woocommerce' ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'recipient' => array( + 'title' => __( 'Recipient(s)', 'woocommerce' ), + 'type' => 'text', + /* translators: %s: WP admin email */ + 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '' . esc_attr( get_option( 'admin_email' ) ) . '' ), + 'placeholder' => '', + 'default' => '', + 'desc_tip' => true, + ), + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_Failed_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-new-order.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-new-order.php new file mode 100644 index 0000000..9654051 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email-new-order.php @@ -0,0 +1,191 @@ +id = 'new_order'; + $this->title = __( 'New order', 'woocommerce' ); + $this->description = __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'woocommerce' ); + $this->template_html = 'emails/admin-new-order.php'; + $this->template_plain = 'emails/plain/admin-new-order.php'; + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + '{order_date}' => '', + '{order_number}' => '', + ); + + // Triggers for this email. + add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'trigger' ), 10, 2 ); + add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 ); + + // Call parent constructor. + parent::__construct(); + + // Other settings. + $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) ); + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return __( '[{site_title}] New customer order ({order_number}) - {order_date}', 'woocommerce' ); + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return __( 'New customer order', 'woocommerce' ); + } + + /** + * Trigger the sending of this email. + * + * @param int $order_id The order ID. + * @param WC_Order|false $order Order object. + */ + public function trigger( $order_id, $order = false ) { + $this->setup_locale(); + + if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { + $order = wc_get_order( $order_id ); + } + + if ( is_a( $order, 'WC_Order' ) ) { + $this->object = $order; + $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); + $this->placeholders['{order_number}'] = $this->object->get_order_number(); + } + + if ( $this->is_enabled() && $this->get_recipient() ) { + $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); + } + + $this->restore_locale(); + } + + /** + * Get content html. + * + * @access public + * @return string + */ + public function get_content_html() { + return wc_get_template_html( + $this->template_html, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => false, + 'email' => $this, + ) + ); + } + + /** + * Get content plain. + * + * @access public + * @return string + */ + public function get_content_plain() { + return wc_get_template_html( + $this->template_plain, array( + 'order' => $this->object, + 'email_heading' => $this->get_heading(), + 'sent_to_admin' => true, + 'plain_text' => true, + 'email' => $this, + ) + ); + } + + /** + * Initialise settings form fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'recipient' => array( + 'title' => __( 'Recipient(s)', 'woocommerce' ), + 'type' => 'text', + /* translators: %s: WP admin email */ + 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '' . esc_attr( get_option( 'admin_email' ) ) . '' ), + 'placeholder' => '', + 'default' => '', + 'desc_tip' => true, + ), + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '{site_title}, {order_date}, {order_number}' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + } + +endif; + +return new WC_Email_New_Order(); diff --git a/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php new file mode 100644 index 0000000..c7d72fa --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php @@ -0,0 +1,1002 @@ +', // Greater-than. + '<', // Less-than. + '&', // Ampersand. + '&', // Ampersand. + '(c)', // Copyright. + '(tm)', // Trademark. + '(R)', // Registered. + '--', // mdash. + '-', // ndash. + '*', // Bullet. + '£', // Pound sign. + 'EUR', // Euro sign. € ?. + '$', // Dollar sign. + '', // Unknown/unhandled entities. + ' ', // Runs of spaces, post-handling. + ); + + /** + * Strings to find/replace in subjects/headings. + * + * @var array + */ + protected $placeholders = array(); + + /** + * Strings to find in subjects/headings. + * + * @deprecated 3.2.0 in favour of placeholders + * @var array + */ + public $find = array(); + + /** + * Strings to replace in subjects/headings. + * + * @deprecated 3.2.0 in favour of placeholders + * @var array + */ + public $replace = array(); + + /** + * Constructor. + */ + public function __construct() { + // Find/replace. + if ( empty( $this->placeholders ) ) { + $this->placeholders = array( + '{site_title}' => $this->get_blogname(), + ); + } + + // Init settings. + $this->init_form_fields(); + $this->init_settings(); + + // Default template base if not declared in child constructor. + if ( is_null( $this->template_base ) ) { + $this->template_base = WC()->plugin_path() . '/templates/'; + } + + $this->email_type = $this->get_option( 'email_type' ); + $this->enabled = $this->get_option( 'enabled' ); + + add_action( 'phpmailer_init', array( $this, 'handle_multipart' ) ); + add_action( 'woocommerce_update_options_email_' . $this->id, array( $this, 'process_admin_options' ) ); + } + + /** + * Handle multipart mail. + * + * @param PHPMailer $mailer PHPMailer object. + * @return PHPMailer + */ + public function handle_multipart( $mailer ) { + if ( $this->sending && 'multipart' === $this->get_email_type() ) { + $mailer->AltBody = wordwrap( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + preg_replace( $this->plain_search, $this->plain_replace, strip_tags( $this->get_content_plain() ) ) + ); + $this->sending = false; + } + return $mailer; + } + + /** + * Format email string. + * + * @param mixed $string Text to replace placeholders in. + * @return string + */ + public function format_string( $string ) { + $find = array_keys( $this->placeholders ); + $replace = array_values( $this->placeholders ); + + // If using legacy find replace, add those to our find/replace arrays first. @todo deprecate in 4.0.0. + $find = array_merge( (array) $this->find, $find ); + $replace = array_merge( (array) $this->replace, $replace ); + + // Take care of blogname which is no longer defined as a valid placeholder. + $find[] = '{blogname}'; + $replace[] = $this->get_blogname(); + + // If using the older style filters for find and replace, ensure the array is associative and then pass through filters. @todo deprecate in 4.0.0. + if ( has_filter( 'woocommerce_email_format_string_replace' ) || has_filter( 'woocommerce_email_format_string_find' ) ) { + $legacy_find = $this->find; + $legacy_replace = $this->replace; + + foreach ( $this->placeholders as $find => $replace ) { + $legacy_key = sanitize_title( str_replace( '_', '-', trim( $find, '{}' ) ) ); + $legacy_find[ $legacy_key ] = $find; + $legacy_replace[ $legacy_key ] = $replace; + } + + $string = str_replace( apply_filters( 'woocommerce_email_format_string_find', $legacy_find, $this ), apply_filters( 'woocommerce_email_format_string_replace', $legacy_replace, $this ), $string ); + } + + /** + * Filter for main find/replace. + * + * @since 3.2.0 + */ + return apply_filters( 'woocommerce_email_format_string', str_replace( $find, $replace, $string ), $this ); + } + + /** + * Set the locale to the store locale for customer emails to make sure emails are in the store language. + */ + public function setup_locale() { + if ( $this->is_customer_email() && apply_filters( 'woocommerce_email_setup_locale', true ) ) { + wc_switch_to_site_locale(); + } + } + + /** + * Restore the locale to the default locale. Use after finished with setup_locale. + */ + public function restore_locale() { + if ( $this->is_customer_email() && apply_filters( 'woocommerce_email_restore_locale', true ) ) { + wc_restore_locale(); + } + } + + /** + * Get email subject. + * + * @since 3.1.0 + * @return string + */ + public function get_default_subject() { + return $this->subject; + } + + /** + * Get email heading. + * + * @since 3.1.0 + * @return string + */ + public function get_default_heading() { + return $this->heading; + } + + /** + * Get email subject. + * + * @return string + */ + public function get_subject() { + return apply_filters( 'woocommerce_email_subject_' . $this->id, $this->format_string( $this->get_option( 'subject', $this->get_default_subject() ) ), $this->object ); + } + + /** + * Get email heading. + * + * @return string + */ + public function get_heading() { + return apply_filters( 'woocommerce_email_heading_' . $this->id, $this->format_string( $this->get_option( 'heading', $this->get_default_heading() ) ), $this->object ); + } + + /** + * Get valid recipients. + * + * @return string + */ + public function get_recipient() { + $recipient = apply_filters( 'woocommerce_email_recipient_' . $this->id, $this->recipient, $this->object ); + $recipients = array_map( 'trim', explode( ',', $recipient ) ); + $recipients = array_filter( $recipients, 'is_email' ); + return implode( ', ', $recipients ); + } + + /** + * Get email headers. + * + * @return string + */ + public function get_headers() { + $header = 'Content-Type: ' . $this->get_content_type() . "\r\n"; + + if ( 'new_order' === $this->id && $this->object && $this->object->get_billing_email() && ( $this->object->get_billing_first_name() || $this->object->get_billing_last_name() ) ) { + $header .= 'Reply-to: ' . $this->object->get_billing_first_name() . ' ' . $this->object->get_billing_last_name() . ' <' . $this->object->get_billing_email() . ">\r\n"; + } + + return apply_filters( 'woocommerce_email_headers', $header, $this->id, $this->object ); + } + + /** + * Get email attachments. + * + * @return array + */ + public function get_attachments() { + return apply_filters( 'woocommerce_email_attachments', array(), $this->id, $this->object ); + } + + /** + * Return email type. + * + * @return string + */ + public function get_email_type() { + return $this->email_type && class_exists( 'DOMDocument' ) ? $this->email_type : 'plain'; + } + + /** + * Get email content type. + * + * @return string + */ + public function get_content_type() { + switch ( $this->get_email_type() ) { + case 'html': + return 'text/html'; + case 'multipart': + return 'multipart/alternative'; + default: + return 'text/plain'; + } + } + + /** + * Return the email's title + * + * @return string + */ + public function get_title() { + return apply_filters( 'woocommerce_email_title', $this->title, $this ); + } + + /** + * Return the email's description + * + * @return string + */ + public function get_description() { + return apply_filters( 'woocommerce_email_description', $this->description, $this ); + } + + /** + * Proxy to parent's get_option and attempt to localize the result using gettext. + * + * @param string $key Option key. + * @param mixed $empty_value Value to use when option is empty. + * @return string + */ + public function get_option( $key, $empty_value = null ) { + $value = parent::get_option( $key, $empty_value ); + return apply_filters( 'woocommerce_email_get_option', $value, $this, $value, $key, $empty_value ); + } + + /** + * Checks if this email is enabled and will be sent. + * + * @return bool + */ + public function is_enabled() { + return apply_filters( 'woocommerce_email_enabled_' . $this->id, 'yes' === $this->enabled, $this->object ); + } + + /** + * Checks if this email is manually sent + * + * @return bool + */ + public function is_manual() { + return $this->manual; + } + + /** + * Checks if this email is customer focussed. + * + * @return bool + */ + public function is_customer_email() { + return $this->customer_email; + } + + /** + * Get WordPress blog name. + * + * @return string + */ + public function get_blogname() { + return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + } + + /** + * Get email content. + * + * @return string + */ + public function get_content() { + $this->sending = true; + + if ( 'plain' === $this->get_email_type() ) { + $email_content = preg_replace( $this->plain_search, $this->plain_replace, strip_tags( $this->get_content_plain() ) ); + } else { + $email_content = $this->get_content_html(); + } + + return wordwrap( $email_content, 70 ); + } + + /** + * Apply inline styles to dynamic content. + * + * @param string|null $content Content that will receive inline styles. + * @return string + */ + public function style_inline( $content ) { + // make sure we only inline CSS for html emails. + if ( in_array( $this->get_content_type(), array( 'text/html', 'multipart/alternative' ), true ) && class_exists( 'DOMDocument' ) ) { + ob_start(); + wc_get_template( 'emails/email-styles.php' ); + $css = apply_filters( 'woocommerce_email_styles', ob_get_clean() ); + + // apply CSS styles inline for picky email clients. + try { + $emogrifier = new Emogrifier( $content, $css ); + $content = $emogrifier->emogrify(); + } catch ( Exception $e ) { + $logger = wc_get_logger(); + $logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) ); + } + } + return $content; + } + + /** + * Get the email content in plain text format. + * + * @return string + */ + public function get_content_plain() { + return ''; } + + /** + * Get the email content in HTML format. + * + * @return string + */ + public function get_content_html() { + return ''; } + + /** + * Get the from name for outgoing emails. + * + * @return string + */ + public function get_from_name() { + $from_name = apply_filters( 'woocommerce_email_from_name', get_option( 'woocommerce_email_from_name' ), $this ); + return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); + } + + /** + * Get the from address for outgoing emails. + * + * @return string + */ + public function get_from_address() { + $from_address = apply_filters( 'woocommerce_email_from_address', get_option( 'woocommerce_email_from_address' ), $this ); + return sanitize_email( $from_address ); + } + + /** + * Send an email. + * + * @param string $to Email to. + * @param string $subject Email subject. + * @param string $message Email message. + * @param string $headers Email headers. + * @param array $attachments Email attachments. + * @return bool success + */ + public function send( $to, $subject, $message, $headers, $attachments ) { + add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); + add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); + add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); + + $message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) ); + $return = wp_mail( $to, $subject, $message, $headers, $attachments ); + + remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); + remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); + remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); + + return $return; + } + + /** + * Initialise Settings Form Fields - these are generic email options most will use. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable this email notification', 'woocommerce' ), + 'default' => 'yes', + ), + 'subject' => array( + 'title' => __( 'Subject', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '' . implode( ', ', array_keys( $this->placeholders ) ) . '' ), + 'placeholder' => $this->get_default_subject(), + 'default' => '', + ), + 'heading' => array( + 'title' => __( 'Email heading', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + /* translators: %s: list of placeholders */ + 'description' => sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '' . implode( ', ', array_keys( $this->placeholders ) ) . '' ), + 'placeholder' => $this->get_default_heading(), + 'default' => '', + ), + 'email_type' => array( + 'title' => __( 'Email type', 'woocommerce' ), + 'type' => 'select', + 'description' => __( 'Choose which format of email to send.', 'woocommerce' ), + 'default' => 'html', + 'class' => 'email_type wc-enhanced-select', + 'options' => $this->get_email_type_options(), + 'desc_tip' => true, + ), + ); + } + + /** + * Email type options. + * + * @return array + */ + public function get_email_type_options() { + $types = array( 'plain' => __( 'Plain text', 'woocommerce' ) ); + + if ( class_exists( 'DOMDocument' ) ) { + $types['html'] = __( 'HTML', 'woocommerce' ); + $types['multipart'] = __( 'Multipart', 'woocommerce' ); + } + + return $types; + } + + /** + * Admin Panel Options Processing. + */ + public function process_admin_options() { + // Save regular options. + parent::process_admin_options(); + + $post_data = $this->get_post_data(); + + // Save templates. + if ( isset( $post_data['template_html_code'] ) ) { + $this->save_template( $post_data['template_html_code'], $this->template_html ); + } + if ( isset( $post_data['template_plain_code'] ) ) { + $this->save_template( $post_data['template_plain_code'], $this->template_plain ); + } + } + + /** + * Get template. + * + * @param string $type Template type. Can be either 'template_html' or 'template_plain'. + * @return string + */ + public function get_template( $type ) { + $type = basename( $type ); + + if ( 'template_html' === $type ) { + return $this->template_html; + } elseif ( 'template_plain' === $type ) { + return $this->template_plain; + } + return ''; + } + + /** + * Save the email templates. + * + * @since 2.4.0 + * @param string $template_code Template code. + * @param string $template_path Template path. + */ + protected function save_template( $template_code, $template_path ) { + if ( current_user_can( 'edit_themes' ) && ! empty( $template_code ) && ! empty( $template_path ) ) { + $saved = false; + $file = get_stylesheet_directory() . '/' . WC()->template_path() . $template_path; + $code = wp_unslash( $template_code ); + + if ( is_writeable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writeable + $f = fopen( $file, 'w+' ); + + if ( false !== $f ) { + fwrite( $f, $code ); + fclose( $f ); + $saved = true; + } + } + + if ( ! $saved ) { + $redirect = add_query_arg( 'wc_error', urlencode( __( 'Could not write to template file.', 'woocommerce' ) ) ); + wp_safe_redirect( $redirect ); + exit; + } + } + } + + /** + * Get the template file in the current theme. + * + * @param string $template Template name. + * + * @return string + */ + public function get_theme_template_file( $template ) { + return get_stylesheet_directory() . '/' . apply_filters( 'woocommerce_template_directory', 'woocommerce', $template ) . '/' . $template; + } + + /** + * Move template action. + * + * @param string $template_type Template type. + */ + protected function move_template_action( $template_type ) { + $template = $this->get_template( $template_type ); + if ( ! empty( $template ) ) { + $theme_file = $this->get_theme_template_file( $template ); + + if ( wp_mkdir_p( dirname( $theme_file ) ) && ! file_exists( $theme_file ) ) { + + // Locate template file. + $core_file = $this->template_base . $template; + $template_file = apply_filters( 'woocommerce_locate_core_template', $core_file, $template, $this->template_base, $this->id ); + + // Copy template file. + copy( $template_file, $theme_file ); + + /** + * Action hook fired after copying email template file. + * + * @param string $template_type The copied template type + * @param string $email The email object + */ + do_action( 'woocommerce_copy_email_template', $template_type, $this ); + + ?> +
      +

      +
      + get_template( $template_type ); + + if ( $template ) { + if ( ! empty( $template ) ) { + $theme_file = $this->get_theme_template_file( $template ); + + if ( file_exists( $theme_file ) ) { + unlink( $theme_file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink + + /** + * Action hook fired after deleting template file. + * + * @param string $template The deleted template type + * @param string $email The email object + */ + do_action( 'woocommerce_delete_email_template', $template_type, $this ); + ?> +
      +

      +
      + template_html ) || ! empty( $this->template_plain ) ) + && ( ! empty( $_GET['move_template'] ) || ! empty( $_GET['delete_template'] ) ) + && 'GET' === $_SERVER['REQUEST_METHOD'] // phpcs:ignore WordPress.VIP.ValidatedSanitizedInput.InputNotValidated + ) { + if ( empty( $_GET['_wc_email_nonce'] ) || ! wp_verify_nonce( wc_clean( wp_unslash( $_GET['_wc_email_nonce'] ) ), 'woocommerce_email_template_nonce' ) ) { + wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) ); + } + + if ( ! current_user_can( 'edit_themes' ) ) { + wp_die( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) ); + } + + if ( ! empty( $_GET['move_template'] ) ) { + $this->move_template_action( wc_clean( wp_unslash( $_GET['move_template'] ) ) ); + } + + if ( ! empty( $_GET['delete_template'] ) ) { + $this->delete_template_action( wc_clean( wp_unslash( $_GET['delete_template'] ) ) ); + } + } + } + + /** + * Admin Options. + * + * Setup the email settings screen. + * Override this in your email. + * + * @since 1.0.0 + */ + public function admin_options() { + // Do admin actions. + $this->admin_actions(); + ?> +

      get_title() ); ?>

      + + get_description() ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?> + + + + + generate_settings_html(); ?> +
      + + + + template_html ) || ! empty( $this->template_plain ) ) ) { + ?> +
      + __( 'HTML template', 'woocommerce' ), + 'template_plain' => __( 'Plain text template', 'woocommerce' ), + ); + + foreach ( $templates as $template_type => $title ) : + $template = $this->get_template( $template_type ); + + if ( empty( $template ) ) { + continue; + } + + $local_file = $this->get_theme_template_file( $template ); + $core_file = $this->template_base . $template; + $template_file = apply_filters( 'woocommerce_locate_core_template', $core_file, $template, $this->template_base, $this->id ); + $template_dir = apply_filters( 'woocommerce_template_directory', 'woocommerce', $template ); + ?> +
      +

      + + +

      + + + + + + + + + ' . esc_html( trailingslashit( basename( get_stylesheet_directory() ) ) . $template_dir . '/' . $template ) . '' ); + ?> +

      + + + +

      + + + + + + + + + ' . esc_html( plugin_basename( $template_file ) ) . '', '' . esc_html( trailingslashit( basename( get_stylesheet_directory() ) ) . $template_dir . '/' . $template ) . '' ); + ?> +

      + + + +

      + +
      + +
      + + column_names = $this->get_default_column_names(); + } + + /** + * Get file path to export to. + * + * @return string + */ + protected function get_file_path() { + $upload_dir = wp_upload_dir(); + return trailingslashit( $upload_dir['basedir'] ) . $this->get_filename(); + } + + /** + * Get the file contents. + * + * @since 3.1.0 + * @return string + */ + public function get_file() { + $file = ''; + if ( @file_exists( $this->get_file_path() ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + $file = @file_get_contents( $this->get_file_path() ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.WP.AlternativeFunctions.file_system_read_file_get_contents + } else { + @file_put_contents( $this->get_file_path(), '' ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_file_put_contents, Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents + @chmod( $this->get_file_path(), 0664 ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.chmod_chmod, WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents, Generic.PHP.NoSilencedErrors.Discouraged + } + return $file; + } + + /** + * Serve the file and remove once sent to the client. + * + * @since 3.1.0 + */ + public function export() { + $this->send_headers(); + $this->send_content( $this->get_file() ); + @unlink( $this->get_file_path() ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink, Generic.PHP.NoSilencedErrors.Discouraged + die(); + } + + /** + * Generate the CSV file. + * + * @since 3.1.0 + */ + public function generate_file() { + if ( 1 === $this->get_page() ) { + @unlink( $this->get_file_path() ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink, Generic.PHP.NoSilencedErrors.Discouraged, + } + $this->prepare_data_to_export(); + $this->write_csv_data( $this->get_csv_data() ); + } + + /** + * Write data to the file. + * + * @since 3.1.0 + * @param string $data Data. + */ + protected function write_csv_data( $data ) { + $file = $this->get_file(); + + // Add columns when finished. + if ( 100 === $this->get_percent_complete() ) { + $file = chr( 239 ) . chr( 187 ) . chr( 191 ) . $this->export_column_headers() . $file; + } + + $file .= $data; + @file_put_contents( $this->get_file_path(), $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_file_put_contents, Generic.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents + } + + /** + * Get page. + * + * @since 3.1.0 + * @return int + */ + public function get_page() { + return $this->page; + } + + /** + * Set page. + * + * @since 3.1.0 + * @param int $page Page Nr. + */ + public function set_page( $page ) { + $this->page = absint( $page ); + } + + /** + * Get count of records exported. + * + * @since 3.1.0 + * @return int + */ + public function get_total_exported() { + return ( ( $this->get_page() - 1 ) * $this->get_limit() ) + $this->exported_row_count; + } + + /** + * Get total % complete. + * + * @since 3.1.0 + * @return int + */ + public function get_percent_complete() { + return $this->total_rows ? floor( ( $this->get_total_exported() / $this->total_rows ) * 100 ) : 100; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/export/abstract-wc-csv-exporter.php b/backend/wp-content/plugins/woocommerce/includes/export/abstract-wc-csv-exporter.php new file mode 100644 index 0000000..3ac3d9e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/export/abstract-wc-csv-exporter.php @@ -0,0 +1,488 @@ +export_type}_export_column_names", $this->column_names, $this ); + } + + /** + * Set column names. + * + * @since 3.1.0 + * @param array $column_names Column names array. + */ + public function set_column_names( $column_names ) { + $this->column_names = array(); + + foreach ( $column_names as $column_id => $column_name ) { + $this->column_names[ wc_clean( $column_id ) ] = wc_clean( $column_name ); + } + } + + /** + * Return an array of columns to export. + * + * @since 3.1.0 + * @return array + */ + public function get_columns_to_export() { + return $this->columns_to_export; + } + + /** + * Set columns to export. + * + * @since 3.1.0 + * @param array $columns Columns array. + */ + public function set_columns_to_export( $columns ) { + $this->columns_to_export = array_map( 'wc_clean', $columns ); + } + + /** + * See if a column is to be exported or not. + * + * @since 3.1.0 + * @param string $column_id ID of the column being exported. + * @return boolean + */ + public function is_column_exporting( $column_id ) { + $column_id = strstr( $column_id, ':' ) ? current( explode( ':', $column_id ) ) : $column_id; + $columns_to_export = $this->get_columns_to_export(); + + if ( empty( $columns_to_export ) ) { + return true; + } + + if ( in_array( $column_id, $columns_to_export, true ) || 'meta' === $column_id ) { + return true; + } + + return false; + } + + /** + * Return default columns. + * + * @since 3.1.0 + * @return array + */ + public function get_default_column_names() { + return array(); + } + + /** + * Do the export. + * + * @since 3.1.0 + */ + public function export() { + $this->prepare_data_to_export(); + $this->send_headers(); + $this->send_content( chr( 239 ) . chr( 187 ) . chr( 191 ) . $this->export_column_headers() . $this->get_csv_data() ); + die(); + } + + /** + * Set the export headers. + * + * @since 3.1.0 + */ + public function send_headers() { + if ( function_exists( 'gc_enable' ) ) { + gc_enable(); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.gc_enableFound + } + if ( function_exists( 'apache_setenv' ) ) { + @apache_setenv( 'no-gzip', 1 ); // @codingStandardsIgnoreLine + } + @ini_set( 'zlib.output_compression', 'Off' ); // @codingStandardsIgnoreLine + @ini_set( 'output_buffering', 'Off' ); // @codingStandardsIgnoreLine + @ini_set( 'output_handler', '' ); // @codingStandardsIgnoreLine + ignore_user_abort( true ); + wc_set_time_limit( 0 ); + wc_nocache_headers(); + header( 'Content-Type: text/csv; charset=utf-8' ); + header( 'Content-Disposition: attachment; filename=' . $this->get_filename() ); + header( 'Pragma: no-cache' ); + header( 'Expires: 0' ); + } + + /** + * Set filename to export to. + * + * @param string $filename Filename to export to. + */ + public function set_filename( $filename ) { + $this->filename = sanitize_file_name( str_replace( '.csv', '', $filename ) . '.csv' ); + } + + /** + * Generate and return a filename. + * + * @return string + */ + public function get_filename() { + return sanitize_file_name( apply_filters( "woocommerce_{$this->export_type}_export_get_filename", $this->filename ) ); + } + + /** + * Set the export content. + * + * @since 3.1.0 + * @param string $csv_data All CSV content. + */ + public function send_content( $csv_data ) { + echo $csv_data; // @codingStandardsIgnoreLine + } + + /** + * Get CSV data for this export. + * + * @since 3.1.0 + * @return string + */ + protected function get_csv_data() { + return $this->export_rows(); + } + + /** + * Export column headers in CSV format. + * + * @since 3.1.0 + * @return string + */ + protected function export_column_headers() { + $columns = $this->get_column_names(); + $export_row = array(); + $buffer = fopen( 'php://output', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen + ob_start(); + + foreach ( $columns as $column_id => $column_name ) { + if ( ! $this->is_column_exporting( $column_id ) ) { + continue; + } + $export_row[] = $this->format_data( $column_name ); + } + + $this->fputcsv( $buffer, $export_row ); + + return ob_get_clean(); + } + + /** + * Get data that will be exported. + * + * @since 3.1.0 + * @return array + */ + protected function get_data_to_export() { + return $this->row_data; + } + + /** + * Export rows in CSV format. + * + * @since 3.1.0 + * @return array + */ + protected function export_rows() { + $data = $this->get_data_to_export(); + $buffer = fopen( 'php://output', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen + ob_start(); + + array_walk( $data, array( $this, 'export_row' ), $buffer ); + + return apply_filters( "woocommerce_{$this->export_type}_export_rows", ob_get_clean(), $this ); + } + + /** + * Export rows to an array ready for the CSV. + * + * @since 3.1.0 + * @param array $row_data Data to export. + * @param string $key Column being exported. + * @param resource $buffer Output buffer. + */ + protected function export_row( $row_data, $key, $buffer ) { + $columns = $this->get_column_names(); + $export_row = array(); + + foreach ( $columns as $column_id => $column_name ) { + if ( ! $this->is_column_exporting( $column_id ) ) { + continue; + } + if ( isset( $row_data[ $column_id ] ) ) { + $export_row[] = $this->format_data( $row_data[ $column_id ] ); + } else { + $export_row[] = ''; + } + } + + $this->fputcsv( $buffer, $export_row ); + + ++ $this->exported_row_count; + } + + /** + * Get batch limit. + * + * @since 3.1.0 + * @return int + */ + public function get_limit() { + return apply_filters( "woocommerce_{$this->export_type}_export_batch_limit", $this->limit, $this ); + } + + /** + * Set batch limit. + * + * @since 3.1.0 + * @param int $limit Limit to export. + */ + public function set_limit( $limit ) { + $this->limit = absint( $limit ); + } + + /** + * Get count of records exported. + * + * @since 3.1.0 + * @return int + */ + public function get_total_exported() { + return $this->exported_row_count; + } + + /** + * Escape a string to be used in a CSV context + * + * Malicious input can inject formulas into CSV files, opening up the possibility + * for phishing attacks and disclosure of sensitive information. + * + * Additionally, Excel exposes the ability to launch arbitrary commands through + * the DDE protocol. + * + * @see http://www.contextis.com/resources/blog/comma-separated-vulnerabilities/ + * @see https://hackerone.com/reports/72785 + * + * @since 3.1.0 + * @param string $data CSV field to escape. + * @return string + */ + public function escape_data( $data ) { + $active_content_triggers = array( '=', '+', '-', '@' ); + + if ( in_array( mb_substr( $data, 0, 1 ), $active_content_triggers, true ) ) { + $data = "'" . $data . "'"; + } + + return $data; + } + + /** + * Format and escape data ready for the CSV file. + * + * @since 3.1.0 + * @param string $data Data to format. + * @return string + */ + public function format_data( $data ) { + if ( ! is_scalar( $data ) ) { + if ( is_a( $data, 'WC_Datetime' ) ) { + $data = $data->date( 'Y-m-d G:i:s' ); + } else { + $data = ''; // Not supported. + } + } elseif ( is_bool( $data ) ) { + $data = $data ? 1 : 0; + } + + $use_mb = function_exists( 'mb_convert_encoding' ); + $data = (string) urldecode( $data ); + + if ( $use_mb ) { + $encoding = mb_detect_encoding( $data, 'UTF-8, ISO-8859-1', true ); + $data = 'UTF-8' === $encoding ? $data : utf8_encode( $data ); + } + + return $this->escape_data( $data ); + } + + /** + * Format term ids to names. + * + * @since 3.1.0 + * @param array $term_ids Term IDs to format. + * @param string $taxonomy Taxonomy name. + * @return array + */ + public function format_term_ids( $term_ids, $taxonomy ) { + $term_ids = wp_parse_id_list( $term_ids ); + + if ( ! count( $term_ids ) ) { + return ''; + } + + $formatted_terms = array(); + + if ( is_taxonomy_hierarchical( $taxonomy ) ) { + foreach ( $term_ids as $term_id ) { + $formatted_term = array(); + $ancestor_ids = array_reverse( get_ancestors( $term_id, $taxonomy ) ); + + foreach ( $ancestor_ids as $ancestor_id ) { + $term = get_term( $ancestor_id, $taxonomy ); + if ( $term && ! is_wp_error( $term ) ) { + $formatted_term[] = $term->name; + } + } + + $term = get_term( $term_id, $taxonomy ); + + if ( $term && ! is_wp_error( $term ) ) { + $formatted_term[] = $term->name; + } + + $formatted_terms[] = implode( ' > ', $formatted_term ); + } + } else { + foreach ( $term_ids as $term_id ) { + $term = get_term( $term_id, $taxonomy ); + + if ( $term && ! is_wp_error( $term ) ) { + $formatted_terms[] = $term->name; + } + } + } + + return $this->implode_values( $formatted_terms ); + } + + /** + * Implode CSV cell values using commas by default, and wrapping values + * which contain the separator. + * + * @since 3.2.0 + * @param array $values Values to implode. + * @return string + */ + protected function implode_values( $values ) { + $values_to_implode = array(); + + foreach ( $values as $value ) { + $value = (string) is_scalar( $value ) ? $value : ''; + $values_to_implode[] = str_replace( ',', '\\,', $value ); + } + + return implode( ', ', $values_to_implode ); + } + + /** + * Write to the CSV file, ensuring escaping works across versions of + * PHP. + * + * PHP 5.5.4 uses '\' as the default escape character. This is not RFC-4180 compliant. + * \0 disables the escape character. + * + * @see https://bugs.php.net/bug.php?id=43225 + * @see https://bugs.php.net/bug.php?id=50686 + * @see https://github.com/woocommerce/woocommerce/issues/19514 + * @since 3.4.0 + * @param resource $buffer Resource we are writing to. + * @param array $export_row Row to export. + */ + protected function fputcsv( $buffer, $export_row ) { + if ( version_compare( PHP_VERSION, '5.5.4', '<' ) ) { + ob_start(); + $temp = fopen( 'php://output', 'w' ); // @codingStandardsIgnoreLine + fputcsv( $temp, $export_row, ",", '"' ); // @codingStandardsIgnoreLine + fclose( $temp ); // @codingStandardsIgnoreLine + $row = ob_get_clean(); + $row = str_replace( '\\"', '\\""', $row ); + fwrite( $buffer, $row ); // @codingStandardsIgnoreLine + } else { + fputcsv( $buffer, $export_row, ",", '"', "\0" ); // @codingStandardsIgnoreLine + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php b/backend/wp-content/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php new file mode 100644 index 0000000..c9f3f0e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/export/class-wc-product-csv-exporter.php @@ -0,0 +1,606 @@ +set_product_types_to_export( array_merge( array_keys( wc_get_product_types() ), array( 'variation' ) ) ); + } + + /** + * Should meta be exported? + * + * @since 3.1.0 + * @param bool $enable_meta_export Should meta be exported. + */ + public function enable_meta_export( $enable_meta_export ) { + $this->enable_meta_export = (bool) $enable_meta_export; + } + + /** + * Product types to export. + * + * @since 3.1.0 + * @param array $product_types_to_export List of types to export. + */ + public function set_product_types_to_export( $product_types_to_export ) { + $this->product_types_to_export = array_map( 'wc_clean', $product_types_to_export ); + } + + /** + * Return an array of columns to export. + * + * @since 3.1.0 + * @return array + */ + public function get_default_column_names() { + return apply_filters( "woocommerce_product_export_{$this->export_type}_default_columns", array( + 'id' => __( 'ID', 'woocommerce' ), + 'type' => __( 'Type', 'woocommerce' ), + 'sku' => __( 'SKU', 'woocommerce' ), + 'name' => __( 'Name', 'woocommerce' ), + 'published' => __( 'Published', 'woocommerce' ), + 'featured' => __( 'Is featured?', 'woocommerce' ), + 'catalog_visibility' => __( 'Visibility in catalog', 'woocommerce' ), + 'short_description' => __( 'Short description', 'woocommerce' ), + 'description' => __( 'Description', 'woocommerce' ), + 'date_on_sale_from' => __( 'Date sale price starts', 'woocommerce' ), + 'date_on_sale_to' => __( 'Date sale price ends', 'woocommerce' ), + 'tax_status' => __( 'Tax status', 'woocommerce' ), + 'tax_class' => __( 'Tax class', 'woocommerce' ), + 'stock_status' => __( 'In stock?', 'woocommerce' ), + 'stock' => __( 'Stock', 'woocommerce' ), + 'backorders' => __( 'Backorders allowed?', 'woocommerce' ), + 'sold_individually' => __( 'Sold individually?', 'woocommerce' ), + /* translators: %s: weight */ + 'weight' => sprintf( __( 'Weight (%s)', 'woocommerce' ), get_option( 'woocommerce_weight_unit' ) ), + /* translators: %s: length */ + 'length' => sprintf( __( 'Length (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + /* translators: %s: width */ + 'width' => sprintf( __( 'Width (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + /* translators: %s: Height */ + 'height' => sprintf( __( 'Height (%s)', 'woocommerce' ), get_option( 'woocommerce_dimension_unit' ) ), + 'reviews_allowed' => __( 'Allow customer reviews?', 'woocommerce' ), + 'purchase_note' => __( 'Purchase note', 'woocommerce' ), + 'sale_price' => __( 'Sale price', 'woocommerce' ), + 'regular_price' => __( 'Regular price', 'woocommerce' ), + 'category_ids' => __( 'Categories', 'woocommerce' ), + 'tag_ids' => __( 'Tags', 'woocommerce' ), + 'shipping_class_id' => __( 'Shipping class', 'woocommerce' ), + 'images' => __( 'Images', 'woocommerce' ), + 'download_limit' => __( 'Download limit', 'woocommerce' ), + 'download_expiry' => __( 'Download expiry days', 'woocommerce' ), + 'parent_id' => __( 'Parent', 'woocommerce' ), + 'grouped_products' => __( 'Grouped products', 'woocommerce' ), + 'upsell_ids' => __( 'Upsells', 'woocommerce' ), + 'cross_sell_ids' => __( 'Cross-sells', 'woocommerce' ), + 'product_url' => __( 'External URL', 'woocommerce' ), + 'button_text' => __( 'Button text', 'woocommerce' ), + 'menu_order' => __( 'Position', 'woocommerce' ), + ) ); + } + + /** + * Prepare data for export. + * + * @since 3.1.0 + */ + public function prepare_data_to_export() { + $columns = $this->get_column_names(); + $args = apply_filters( "woocommerce_product_export_{$this->export_type}_query_args", array( + 'status' => array( 'private', 'publish', 'draft', 'future', 'pending' ), + 'type' => $this->product_types_to_export, + 'limit' => $this->get_limit(), + 'page' => $this->get_page(), + 'orderby' => array( + 'ID' => 'ASC', + ), + 'return' => 'objects', + 'paginate' => true, + ) ); + $products = wc_get_products( $args ); + + $this->total_rows = $products->total; + $this->row_data = array(); + + foreach ( $products->products as $product ) { + $row = array(); + foreach ( $columns as $column_id => $column_name ) { + $column_id = strstr( $column_id, ':' ) ? current( explode( ':', $column_id ) ) : $column_id; + $value = ''; + + // Skip some columns if dynamically handled later or if we're being selective. + if ( in_array( $column_id, array( 'downloads', 'attributes', 'meta' ), true ) || ! $this->is_column_exporting( $column_id ) ) { + continue; + } + + if ( has_filter( "woocommerce_product_export_{$this->export_type}_column_{$column_id}" ) ) { + // Filter for 3rd parties. + $value = apply_filters( "woocommerce_product_export_{$this->export_type}_column_{$column_id}", '', $product, $column_id ); + + } elseif ( is_callable( array( $this, "get_column_value_{$column_id}" ) ) ) { + // Handle special columns which don't map 1:1 to product data. + $value = $this->{"get_column_value_{$column_id}"}( $product ); + + } elseif ( is_callable( array( $product, "get_{$column_id}" ) ) ) { + // Default and custom handling. + $value = $product->{"get_{$column_id}"}( 'edit' ); + } + + $row[ $column_id ] = $value; + } + + $this->prepare_downloads_for_export( $product, $row ); + $this->prepare_attributes_for_export( $product, $row ); + $this->prepare_meta_for_export( $product, $row ); + + $this->row_data[] = apply_filters( 'woocommerce_product_export_row_data', $row, $product ); + } + } + + /** + * Get published value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return int + */ + protected function get_column_value_published( $product ) { + $statuses = array( + 'draft' => -1, + 'private' => 0, + 'publish' => 1, + ); + + $status = $product->get_status( 'edit' ); + + return isset( $statuses[ $status ] ) ? $statuses[ $status ] : -1; + } + + /** + * Get formatted sale price. + * + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_sale_price( $product ) { + return wc_format_localized_price( $product->get_sale_price( 'view' ) ); + } + + /** + * Get formatted regular price. + * + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_regular_price( $product ) { + return wc_format_localized_price( $product->get_regular_price() ); + } + + /** + * Get product_cat value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_category_ids( $product ) { + $term_ids = $product->get_category_ids( 'edit' ); + return $this->format_term_ids( $term_ids, 'product_cat' ); + } + + /** + * Get product_tag value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_tag_ids( $product ) { + $term_ids = $product->get_tag_ids( 'edit' ); + return $this->format_term_ids( $term_ids, 'product_tag' ); + } + + /** + * Get product_shipping_class value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_shipping_class_id( $product ) { + $term_ids = $product->get_shipping_class_id( 'edit' ); + return $this->format_term_ids( $term_ids, 'product_shipping_class' ); + } + + /** + * Get images value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_images( $product ) { + $image_ids = array_merge( array( $product->get_image_id( 'edit' ) ), $product->get_gallery_image_ids( 'edit' ) ); + $images = array(); + + foreach ( $image_ids as $image_id ) { + $image = wp_get_attachment_image_src( $image_id, 'full' ); + + if ( $image ) { + $images[] = $image[0]; + } + } + + return $this->implode_values( $images ); + } + + /** + * Prepare linked products for export. + * + * @since 3.1.0 + * @param int[] $linked_products Array of linked product ids. + * @return string + */ + protected function prepare_linked_products_for_export( $linked_products ) { + $product_list = array(); + + foreach ( $linked_products as $linked_product ) { + if ( $linked_product->get_sku() ) { + $product_list[] = $linked_product->get_sku(); + } else { + $product_list[] = 'id:' . $linked_product->get_id(); + } + } + + return $this->implode_values( $product_list ); + } + + /** + * Get cross_sell_ids value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_cross_sell_ids( $product ) { + return $this->prepare_linked_products_for_export( array_filter( array_map( 'wc_get_product', (array) $product->get_cross_sell_ids( 'edit' ) ) ) ); + } + + /** + * Get upsell_ids value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_upsell_ids( $product ) { + return $this->prepare_linked_products_for_export( array_filter( array_map( 'wc_get_product', (array) $product->get_upsell_ids( 'edit' ) ) ) ); + } + + /** + * Get parent_id value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_parent_id( $product ) { + if ( $product->get_parent_id( 'edit' ) ) { + $parent = wc_get_product( $product->get_parent_id( 'edit' ) ); + if ( ! $parent ) { + return ''; + } + + return $parent->get_sku( 'edit' ) ? $parent->get_sku( 'edit' ) : 'id:' . $parent->get_id(); + } + return ''; + } + + /** + * Get grouped_products value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_grouped_products( $product ) { + if ( 'grouped' !== $product->get_type() ) { + return ''; + } + + $grouped_products = array(); + $child_ids = $product->get_children( 'edit' ); + foreach ( $child_ids as $child_id ) { + $child = wc_get_product( $child_id ); + if ( ! $child ) { + continue; + } + + $grouped_products[] = $child->get_sku( 'edit' ) ? $child->get_sku( 'edit' ) : 'id:' . $child_id; + } + return $this->implode_values( $grouped_products ); + } + + /** + * Get download_limit value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_download_limit( $product ) { + return $product->is_downloadable() && $product->get_download_limit( 'edit' ) ? $product->get_download_limit( 'edit' ) : ''; + } + + /** + * Get download_expiry value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_download_expiry( $product ) { + return $product->is_downloadable() && $product->get_download_expiry( 'edit' ) ? $product->get_download_expiry( 'edit' ) : ''; + } + + /** + * Get stock value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_stock( $product ) { + $manage_stock = $product->get_manage_stock( 'edit' ); + $stock_quantity = $product->get_stock_quantity( 'edit' ); + + if ( $product->is_type( 'variation' && 'parent' === $manage_stock ) ) { + return 'parent'; + } elseif ( $manage_stock ) { + return $stock_quantity; + } else { + return ''; + } + } + + /** + * Get stock status value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_stock_status( $product ) { + $status = $product->get_stock_status( 'edit' ); + + if ( 'onbackorder' === $status ) { + return 'backorder'; + } + + return 'instock' === $status ? 1 : 0; + } + + /** + * Get backorders. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_backorders( $product ) { + $backorders = $product->get_backorders( 'edit' ); + + switch ( $backorders ) { + case 'notify': + return 'notify'; + default: + return wc_string_to_bool( $backorders ) ? 1 : 0; + } + } + + /** + * Get type value. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @return string + */ + protected function get_column_value_type( $product ) { + $types = array(); + $types[] = $product->get_type(); + + if ( $product->is_downloadable() ) { + $types[] = 'downloadable'; + } + + if ( $product->is_virtual() ) { + $types[] = 'virtual'; + } + + return $this->implode_values( $types ); + } + + /** + * Export downloads. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @param array $row Row being exported. + */ + protected function prepare_downloads_for_export( $product, &$row ) { + if ( $product->is_downloadable() && $this->is_column_exporting( 'downloads' ) ) { + $downloads = $product->get_downloads( 'edit' ); + + if ( $downloads ) { + $i = 1; + foreach ( $downloads as $download ) { + /* translators: %s: download number */ + $this->column_names[ 'downloads:name' . $i ] = sprintf( __( 'Download %d name', 'woocommerce' ), $i ); + /* translators: %s: download number */ + $this->column_names[ 'downloads:url' . $i ] = sprintf( __( 'Download %d URL', 'woocommerce' ), $i ); + $row[ 'downloads:name' . $i ] = $download->get_name(); + $row[ 'downloads:url' . $i ] = $download->get_file(); + $i++; + } + } + } + } + + /** + * Export attributes data. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @param array $row Row being exported. + */ + protected function prepare_attributes_for_export( $product, &$row ) { + if ( $this->is_column_exporting( 'attributes' ) ) { + $attributes = $product->get_attributes(); + $default_attributes = $product->get_default_attributes(); + + if ( count( $attributes ) ) { + $i = 1; + foreach ( $attributes as $attribute_name => $attribute ) { + /* translators: %s: attribute number */ + $this->column_names[ 'attributes:name' . $i ] = sprintf( __( 'Attribute %d name', 'woocommerce' ), $i ); + /* translators: %s: attribute number */ + $this->column_names[ 'attributes:value' . $i ] = sprintf( __( 'Attribute %d value(s)', 'woocommerce' ), $i ); + /* translators: %s: attribute number */ + $this->column_names[ 'attributes:visible' . $i ] = sprintf( __( 'Attribute %d visible', 'woocommerce' ), $i ); + /* translators: %s: attribute number */ + $this->column_names[ 'attributes:taxonomy' . $i ] = sprintf( __( 'Attribute %d global', 'woocommerce' ), $i ); + + if ( is_a( $attribute, 'WC_Product_Attribute' ) ) { + $row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute->get_name(), $product ); + + if ( $attribute->is_taxonomy() ) { + $terms = $attribute->get_terms(); + $values = array(); + + foreach ( $terms as $term ) { + $values[] = $term->name; + } + + $row[ 'attributes:value' . $i ] = $this->implode_values( $values ); + $row[ 'attributes:taxonomy' . $i ] = 1; + } else { + $row[ 'attributes:value' . $i ] = $this->implode_values( $attribute->get_options() ); + $row[ 'attributes:taxonomy' . $i ] = 0; + } + + $row[ 'attributes:visible' . $i ] = $attribute->get_visible(); + } else { + $row[ 'attributes:name' . $i ] = wc_attribute_label( $attribute_name, $product ); + + if ( 0 === strpos( $attribute_name, 'pa_' ) ) { + $option_term = get_term_by( 'slug', $attribute, $attribute_name ); // @codingStandardsIgnoreLine. + $row[ 'attributes:value' . $i ] = $option_term && ! is_wp_error( $option_term ) ? str_replace( ',', '\\,', $option_term->name ) : $attribute; + $row[ 'attributes:taxonomy' . $i ] = 1; + } else { + $row[ 'attributes:value' . $i ] = $attribute; + $row[ 'attributes:taxonomy' . $i ] = 0; + } + + $row[ 'attributes:visible' . $i ] = ''; + } + + if ( $product->is_type( 'variable' ) && isset( $default_attributes[ sanitize_title( $attribute_name ) ] ) ) { + /* translators: %s: attribute number */ + $this->column_names[ 'attributes:default' . $i ] = sprintf( __( 'Attribute %d default', 'woocommerce' ), $i ); + $default_value = $default_attributes[ sanitize_title( $attribute_name ) ]; + + if ( 0 === strpos( $attribute_name, 'pa_' ) ) { + $option_term = get_term_by( 'slug', $default_value, $attribute_name ); // @codingStandardsIgnoreLine. + $row[ 'attributes:default' . $i ] = $option_term && ! is_wp_error( $option_term ) ? $option_term->name : $default_value; + } else { + $row[ 'attributes:default' . $i ] = $default_value; + } + } + $i++; + } + } + } + } + + /** + * Export meta data. + * + * @since 3.1.0 + * @param WC_Product $product Product being exported. + * @param array $row Row data. + */ + protected function prepare_meta_for_export( $product, &$row ) { + if ( $this->enable_meta_export ) { + $meta_data = $product->get_meta_data(); + + if ( count( $meta_data ) ) { + $meta_keys_to_skip = apply_filters( 'woocommerce_product_export_skip_meta_keys', array(), $product ); + + $i = 1; + foreach ( $meta_data as $meta ) { + if ( in_array( $meta->key, $meta_keys_to_skip, true ) ) { + continue; + } + + // Allow 3rd parties to process the meta, e.g. to transform non-scalar values to scalar. + $meta_value = apply_filters( 'woocommerce_product_export_meta_value', $meta->value, $meta, $product, $row ); + + if ( ! is_scalar( $meta_value ) ) { + continue; + } + + $column_key = 'meta:' . esc_attr( $meta->key ); + /* translators: %s: meta data name */ + $this->column_names[ $column_key ] = sprintf( __( 'Meta: %s', 'woocommerce' ), $meta->key ); + $row[ $column_key ] = $meta_value; + $i ++; + } + } + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php b/backend/wp-content/plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php new file mode 100644 index 0000000..12afbc7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php @@ -0,0 +1,441 @@ +id = 'bacs'; + $this->icon = apply_filters( 'woocommerce_bacs_icon', '' ); + $this->has_fields = false; + $this->method_title = __( 'Direct bank transfer', 'woocommerce' ); + $this->method_description = __( 'Take payments in person via BACS. More commonly known as direct bank/wire transfer', 'woocommerce' ); + + // Load the settings. + $this->init_form_fields(); + $this->init_settings(); + + // Define user set variables. + $this->title = $this->get_option( 'title' ); + $this->description = $this->get_option( 'description' ); + $this->instructions = $this->get_option( 'instructions' ); + + // BACS account fields shown on the thanks page and in emails. + $this->account_details = get_option( + 'woocommerce_bacs_accounts', + array( + array( + 'account_name' => $this->get_option( 'account_name' ), + 'account_number' => $this->get_option( 'account_number' ), + 'sort_code' => $this->get_option( 'sort_code' ), + 'bank_name' => $this->get_option( 'bank_name' ), + 'iban' => $this->get_option( 'iban' ), + 'bic' => $this->get_option( 'bic' ), + ), + ) + ); + + // Actions. + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'save_account_details' ) ); + add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) ); + + // Customer Emails. + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + } + + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { + + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable bank transfer', 'woocommerce' ), + 'default' => 'no', + ), + 'title' => array( + 'title' => __( 'Title', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), + 'default' => __( 'Direct bank transfer', 'woocommerce' ), + 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Description', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ), + 'default' => __( 'Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account.', 'woocommerce' ), + 'desc_tip' => true, + ), + 'instructions' => array( + 'title' => __( 'Instructions', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Instructions that will be added to the thank you page and emails.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + 'account_details' => array( + 'type' => 'account_details', + ), + ); + + } + + /** + * Generate account details html. + * + * @return string + */ + public function generate_account_details_html() { + + ob_start(); + + $country = WC()->countries->get_base_country(); + $locale = $this->get_country_locale(); + + // Get sortcode label in the $locale array and use appropriate one. + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'woocommerce' ); + + ?> + + + +
      + + + + + + + + + + + + + + account_details ) { + foreach ( $this->account_details as $account ) { + $i++; + + echo ' + + + + + + + + '; + } + } + ?> + + + + + + +
       
      +
      + + + + $name ) { + if ( ! isset( $account_names[ $i ] ) ) { + continue; + } + + $accounts[] = array( + 'account_name' => $account_names[ $i ], + 'account_number' => $account_numbers[ $i ], + 'bank_name' => $bank_names[ $i ], + 'sort_code' => $sort_codes[ $i ], + 'iban' => $ibans[ $i ], + 'bic' => $bics[ $i ], + ); + } + } + // phpcs:enable + + update_option( 'woocommerce_bacs_accounts', $accounts ); + } + + /** + * Output for the order received page. + * + * @param int $order_id Order ID. + */ + public function thankyou_page( $order_id ) { + + if ( $this->instructions ) { + echo wp_kses_post( wpautop( wptexturize( wp_kses_post( $this->instructions ) ) ) ); + } + $this->bank_details( $order_id ); + + } + + /** + * Add content to the WC emails. + * + * @param WC_Order $order Order object. + * @param bool $sent_to_admin Sent to admin. + * @param bool $plain_text Email format: plain text or HTML. + */ + public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { + + if ( ! $sent_to_admin && 'bacs' === $order->get_payment_method() && $order->has_status( 'on-hold' ) ) { + if ( $this->instructions ) { + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); + } + $this->bank_details( $order->get_id() ); + } + + } + + /** + * Get bank details and place into a list format. + * + * @param int $order_id Order ID. + */ + private function bank_details( $order_id = '' ) { + + if ( empty( $this->account_details ) ) { + return; + } + + // Get order and store in $order. + $order = wc_get_order( $order_id ); + + // Get the order country and country $locale. + $country = $order->get_billing_country(); + $locale = $this->get_country_locale(); + + // Get sortcode label in the $locale array and use appropriate one. + $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'woocommerce' ); + + $bacs_accounts = apply_filters( 'woocommerce_bacs_accounts', $this->account_details ); + + if ( ! empty( $bacs_accounts ) ) { + $account_html = ''; + $has_details = false; + + foreach ( $bacs_accounts as $bacs_account ) { + $bacs_account = (object) $bacs_account; + + if ( $bacs_account->account_name ) { + $account_html .= '' . PHP_EOL; + } + + $account_html .= '
        ' . PHP_EOL; + + // BACS account fields shown on the thanks page and in emails. + $account_fields = apply_filters( + 'woocommerce_bacs_account_fields', array( + 'bank_name' => array( + 'label' => __( 'Bank', 'woocommerce' ), + 'value' => $bacs_account->bank_name, + ), + 'account_number' => array( + 'label' => __( 'Account number', 'woocommerce' ), + 'value' => $bacs_account->account_number, + ), + 'sort_code' => array( + 'label' => $sortcode, + 'value' => $bacs_account->sort_code, + ), + 'iban' => array( + 'label' => __( 'IBAN', 'woocommerce' ), + 'value' => $bacs_account->iban, + ), + 'bic' => array( + 'label' => __( 'BIC', 'woocommerce' ), + 'value' => $bacs_account->bic, + ), + ), $order_id + ); + + foreach ( $account_fields as $field_key => $field ) { + if ( ! empty( $field['value'] ) ) { + $account_html .= '
      • ' . wp_kses_post( $field['label'] ) . ': ' . wp_kses_post( wptexturize( $field['value'] ) ) . '
      • ' . PHP_EOL; + $has_details = true; + } + } + + $account_html .= '
      '; + } + + if ( $has_details ) { + echo '

      ' . esc_html__( 'Our bank details', 'woocommerce' ) . '

      ' . wp_kses_post( PHP_EOL . $account_html ) . '
      '; + } + } + + } + + /** + * Process the payment and return the result. + * + * @param int $order_id Order ID. + * @return array + */ + public function process_payment( $order_id ) { + + $order = wc_get_order( $order_id ); + + if ( $order->get_total() > 0 ) { + // Mark as on-hold (we're awaiting the payment). + $order->update_status( apply_filters( 'woocommerce_bacs_process_payment_order_status', 'on-hold', $order ), __( 'Awaiting BACS payment', 'woocommerce' ) ); + } else { + $order->payment_complete(); + } + + // Reduce stock levels. + wc_reduce_stock_levels( $order_id ); + + // Remove cart. + WC()->cart->empty_cart(); + + // Return thankyou redirect. + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + + } + + /** + * Get country locale if localized. + * + * @return array + */ + public function get_country_locale() { + + if ( empty( $this->locale ) ) { + + // Locale information to be used - only those that are not 'Sort Code'. + $this->locale = apply_filters( + 'woocommerce_get_bacs_locale', array( + 'AU' => array( + 'sortcode' => array( + 'label' => __( 'BSB', 'woocommerce' ), + ), + ), + 'CA' => array( + 'sortcode' => array( + 'label' => __( 'Bank transit number', 'woocommerce' ), + ), + ), + 'IN' => array( + 'sortcode' => array( + 'label' => __( 'IFSC', 'woocommerce' ), + ), + ), + 'IT' => array( + 'sortcode' => array( + 'label' => __( 'Branch sort', 'woocommerce' ), + ), + ), + 'NZ' => array( + 'sortcode' => array( + 'label' => __( 'Bank code', 'woocommerce' ), + ), + ), + 'SE' => array( + 'sortcode' => array( + 'label' => __( 'Bank code', 'woocommerce' ), + ), + ), + 'US' => array( + 'sortcode' => array( + 'label' => __( 'Routing number', 'woocommerce' ), + ), + ), + 'ZA' => array( + 'sortcode' => array( + 'label' => __( 'Branch code', 'woocommerce' ), + ), + ), + ) + ); + + } + + return $this->locale; + + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/cheque/class-wc-gateway-cheque.php b/backend/wp-content/plugins/woocommerce/includes/gateways/cheque/class-wc-gateway-cheque.php new file mode 100644 index 0000000..7c5a1a9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/cheque/class-wc-gateway-cheque.php @@ -0,0 +1,139 @@ +id = 'cheque'; + $this->icon = apply_filters( 'woocommerce_cheque_icon', '' ); + $this->has_fields = false; + $this->method_title = _x( 'Check payments', 'Check payment method', 'woocommerce' ); + $this->method_description = __( 'Take payments in person via checks. This offline gateway can also be useful to test purchases.', 'woocommerce' ); + + // Load the settings. + $this->init_form_fields(); + $this->init_settings(); + + // Define user set variables. + $this->title = $this->get_option( 'title' ); + $this->description = $this->get_option( 'description' ); + $this->instructions = $this->get_option( 'instructions' ); + + // Actions. + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); + add_action( 'woocommerce_thankyou_cheque', array( $this, 'thankyou_page' ) ); + + // Customer Emails. + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + } + + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { + + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable check payments', 'woocommerce' ), + 'default' => 'no', + ), + 'title' => array( + 'title' => __( 'Title', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), + 'default' => _x( 'Check payments', 'Check payment method', 'woocommerce' ), + 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Description', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ), + 'default' => __( 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'woocommerce' ), + 'desc_tip' => true, + ), + 'instructions' => array( + 'title' => __( 'Instructions', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Instructions that will be added to the thank you page and emails.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + ); + } + + /** + * Output for the order received page. + */ + public function thankyou_page() { + if ( $this->instructions ) { + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); + } + } + + /** + * Add content to the WC emails. + * + * @access public + * @param WC_Order $order Order object. + * @param bool $sent_to_admin Sent to admin. + * @param bool $plain_text Email format: plain text or HTML. + */ + public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { + if ( $this->instructions && ! $sent_to_admin && 'cheque' === $order->get_payment_method() && $order->has_status( 'on-hold' ) ) { + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); + } + } + + /** + * Process the payment and return the result. + * + * @param int $order_id Order ID. + * @return array + */ + public function process_payment( $order_id ) { + + $order = wc_get_order( $order_id ); + + if ( $order->get_total() > 0 ) { + // Mark as on-hold (we're awaiting the cheque). + $order->update_status( 'on-hold', _x( 'Awaiting check payment', 'Check payment method', 'woocommerce' ) ); + } else { + $order->payment_complete(); + } + + // Reduce stock levels. + wc_reduce_stock_levels( $order_id ); + + // Remove cart. + WC()->cart->empty_cart(); + + // Return thankyou redirect. + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-cc.php b/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-cc.php new file mode 100644 index 0000000..22fe83b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-cc.php @@ -0,0 +1,99 @@ +supports( 'tokenization' ) && is_checkout() ) { + $this->tokenization_script(); + $this->saved_payment_methods(); + $this->form(); + $this->save_payment_method_checkbox(); + } else { + $this->form(); + } + } + + /** + * Output field name HTML + * + * Gateways which support tokenization do not require names - we don't want the data to post to the server. + * + * @since 2.6.0 + * @param string $name Field name. + * @return string + */ + public function field_name( $name ) { + return $this->supports( 'tokenization' ) ? '' : ' name="' . esc_attr( $this->id . '-' . $name ) . '" '; + } + + /** + * Outputs fields for entering credit card information. + * + * @since 2.6.0 + */ + public function form() { + wp_enqueue_script( 'wc-credit-card-form' ); + + $fields = array(); + + $cvc_field = '

      + + field_name( 'card-cvc' ) . ' style="width:100px" /> +

      '; + + $default_fields = array( + 'card-number-field' => '

      + + field_name( 'card-number' ) . ' /> +

      ', + 'card-expiry-field' => '

      + + field_name( 'card-expiry' ) . ' /> +

      ', + ); + + if ( ! $this->supports( 'credit_card_form_cvc_on_saved_method' ) ) { + $default_fields['card-cvc-field'] = $cvc_field; + } + + $fields = wp_parse_args( $fields, apply_filters( 'woocommerce_credit_card_form_fields', $default_fields, $this->id ) ); + ?> + +
      + id ); ?> + + id ); ?> +
      +
      + supports( 'credit_card_form_cvc_on_saved_method' ) ) { + echo '
      ' . $cvc_field . '
      '; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-echeck.php b/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-echeck.php new file mode 100644 index 0000000..69a5648 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/class-wc-payment-gateway-echeck.php @@ -0,0 +1,71 @@ +supports( 'tokenization' ) && is_checkout() ) { + $this->tokenization_script(); + $this->saved_payment_methods(); + $this->form(); + $this->save_payment_method_checkbox(); + } else { + $this->form(); + } + } + + /** + * Outputs fields for entering eCheck information. + * + * @since 2.6.0 + */ + public function form() { + $fields = array(); + + $default_fields = array( + 'routing-number' => '

      + + +

      ', + 'account-number' => '

      + + +

      ', + ); + + $fields = wp_parse_args( $fields, apply_filters( 'woocommerce_echeck_form_fields', $default_fields, $this->id ) ); + ?> + +
      + id ); ?> + + id ); ?> +
      +
      + setup_properties(); + + // Load the settings. + $this->init_form_fields(); + $this->init_settings(); + + // Get settings. + $this->title = $this->get_option( 'title' ); + $this->description = $this->get_option( 'description' ); + $this->instructions = $this->get_option( 'instructions' ); + $this->enable_for_methods = $this->get_option( 'enable_for_methods', array() ); + $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes'; + + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); + add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) ); + add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'change_payment_complete_order_status' ), 10, 3 ); + + // Customer Emails. + add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); + } + + /** + * Setup general properties for the gateway. + */ + protected function setup_properties() { + $this->id = 'cod'; + $this->icon = apply_filters( 'woocommerce_cod_icon', '' ); + $this->method_title = __( 'Cash on delivery', 'woocommerce' ); + $this->method_description = __( 'Have your customers pay with cash (or by other means) upon delivery.', 'woocommerce' ); + $this->has_fields = false; + } + + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { + + $options = array(); + $data_store = WC_Data_Store::load( 'shipping-zone' ); + $raw_zones = $data_store->get_zones(); + + foreach ( $raw_zones as $raw_zone ) { + $zones[] = new WC_Shipping_Zone( $raw_zone ); + } + + $zones[] = new WC_Shipping_Zone( 0 ); + + foreach ( WC()->shipping()->load_shipping_methods() as $method ) { + + $options[ $method->get_method_title() ] = array(); + + // Translators: %1$s shipping method name. + $options[ $method->get_method_title() ][ $method->id ] = sprintf( __( 'Any "%1$s" method', 'woocommerce' ), $method->get_method_title() ); + + foreach ( $zones as $zone ) { + + $shipping_method_instances = $zone->get_shipping_methods(); + + foreach ( $shipping_method_instances as $shipping_method_instance_id => $shipping_method_instance ) { + + if ( $shipping_method_instance->id !== $method->id ) { + continue; + } + + $option_id = $shipping_method_instance->get_rate_id(); + + // Translators: %1$s shipping method title, %2$s shipping method id. + $option_instance_title = sprintf( __( '%1$s (#%2$s)', 'woocommerce' ), $shipping_method_instance->get_title(), $shipping_method_instance_id ); + + // Translators: %1$s zone name, %2$s shipping method instance name. + $option_title = sprintf( __( '%1$s – %2$s', 'woocommerce' ), $zone->get_id() ? $zone->get_zone_name() : __( 'Other locations', 'woocommerce' ), $option_instance_title ); + + $options[ $method->get_method_title() ][ $option_id ] = $option_title; + } + } + } + + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'label' => __( 'Enable cash on delivery', 'woocommerce' ), + 'type' => 'checkbox', + 'description' => '', + 'default' => 'no', + ), + 'title' => array( + 'title' => __( 'Title', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ), + 'default' => __( 'Cash on delivery', 'woocommerce' ), + 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Description', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Payment method description that the customer will see on your website.', 'woocommerce' ), + 'default' => __( 'Pay with cash upon delivery.', 'woocommerce' ), + 'desc_tip' => true, + ), + 'instructions' => array( + 'title' => __( 'Instructions', 'woocommerce' ), + 'type' => 'textarea', + 'description' => __( 'Instructions that will be added to the thank you page.', 'woocommerce' ), + 'default' => __( 'Pay with cash upon delivery.', 'woocommerce' ), + 'desc_tip' => true, + ), + 'enable_for_methods' => array( + 'title' => __( 'Enable for shipping methods', 'woocommerce' ), + 'type' => 'multiselect', + 'class' => 'wc-enhanced-select', + 'css' => 'width: 400px;', + 'default' => '', + 'description' => __( 'If COD is only available for certain methods, set it up here. Leave blank to enable for all methods.', 'woocommerce' ), + 'options' => $options, + 'desc_tip' => true, + 'custom_attributes' => array( + 'data-placeholder' => __( 'Select shipping methods', 'woocommerce' ), + ), + ), + 'enable_for_virtual' => array( + 'title' => __( 'Accept for virtual orders', 'woocommerce' ), + 'label' => __( 'Accept COD if the order is virtual', 'woocommerce' ), + 'type' => 'checkbox', + 'default' => 'yes', + ), + ); + } + + /** + * Check If The Gateway Is Available For Use. + * + * @return bool + */ + public function is_available() { + $order = null; + $needs_shipping = false; + + // Test if shipping is needed first. + if ( WC()->cart && WC()->cart->needs_shipping() ) { + $needs_shipping = true; + } elseif ( is_page( wc_get_page_id( 'checkout' ) ) && 0 < get_query_var( 'order-pay' ) ) { + $order_id = absint( get_query_var( 'order-pay' ) ); + $order = wc_get_order( $order_id ); + + // Test if order needs shipping. + if ( 0 < count( $order->get_items() ) ) { + foreach ( $order->get_items() as $item ) { + $_product = $item->get_product(); + if ( $_product && $_product->needs_shipping() ) { + $needs_shipping = true; + break; + } + } + } + } elseif ( WC()->cart && WC()->cart->needs_shipping() ) { + $needs_shipping = true; + } + + $needs_shipping = apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping ); + + // Virtual order, with virtual disabled. + if ( ! $this->enable_for_virtual && ! $needs_shipping ) { + return false; + } + + // Only apply if all packages are being shipped via chosen method, or order is virtual. + if ( ! empty( $this->enable_for_methods ) && $needs_shipping ) { + $canonical_rate_ids = array(); + $order_shipping_items = is_object( $order ) ? $order->get_shipping_methods() : false; + $chosen_shipping_methods_session = WC()->session->get( 'chosen_shipping_methods' ); + + if ( $order_shipping_items ) { + $canonical_rate_ids = $this->get_canonical_order_shipping_item_rate_ids( $order_shipping_items ); + } else { + $canonical_rate_ids = $this->get_canonical_package_rate_ids( $chosen_shipping_methods_session ); + } + + if ( ! count( $this->get_matching_rates( $canonical_rate_ids ) ) ) { + return false; + } + } + + return parent::is_available(); + } + + /** + * Converts the chosen rate IDs generated by Shipping Methods to a canonical 'method_id:instance_id' format. + * + * @since 3.4.0 + * + * @param array $order_shipping_items Array of WC_Order_Item_Shipping objects. + * @return array $canonical_rate_ids Rate IDs in a canonical format. + */ + private function get_canonical_order_shipping_item_rate_ids( $order_shipping_items ) { + + $canonical_rate_ids = array(); + + foreach ( $order_shipping_items as $order_shipping_item ) { + $canonical_rate_ids[] = $order_shipping_item->get_method_id() . ':' . $order_shipping_item->get_instance_id(); + } + + return $canonical_rate_ids; + } + + /** + * Converts the chosen rate IDs generated by Shipping Methods to a canonical 'method_id:instance_id' format. + * + * @since 3.4.0 + * + * @param array $chosen_package_rate_ids Rate IDs as generated by shipping methods. Can be anything if a shipping method doesn't honor WC conventions. + * @return array $canonical_rate_ids Rate IDs in a canonical format. + */ + private function get_canonical_package_rate_ids( $chosen_package_rate_ids ) { + + $shipping_packages = WC()->shipping->get_packages(); + $canonical_rate_ids = array(); + + if ( ! empty( $chosen_package_rate_ids ) && is_array( $chosen_package_rate_ids ) ) { + foreach ( $chosen_package_rate_ids as $package_key => $chosen_package_rate_id ) { + if ( ! empty( $shipping_packages[ $package_key ]['rates'][ $chosen_package_rate_id ] ) ) { + $chosen_rate = $shipping_packages[ $package_key ]['rates'][ $chosen_package_rate_id ]; + $canonical_rate_ids[] = $chosen_rate->get_method_id() . ':' . $chosen_rate->get_instance_id(); + } + } + } + + return $canonical_rate_ids; + } + + /** + * Indicates whether a rate exists in an array of canonically-formatted rate IDs that activates this gateway. + * + * @since 3.4.0 + * + * @param array $rate_ids Rate ids to check. + * @return boolean + */ + private function get_matching_rates( $rate_ids ) { + // First, match entries in 'method_id:instance_id' format. Then, match entries in 'method_id' format by stripping off the instance ID from the candidates. + return array_unique( array_merge( array_intersect( $this->enable_for_methods, $rate_ids ), array_intersect( $this->enable_for_methods, array_unique( array_map( 'wc_get_string_before_colon', $rate_ids ) ) ) ) ); + } + + /** + * Process the payment and return the result. + * + * @param int $order_id Order ID. + * @return array + */ + public function process_payment( $order_id ) { + $order = wc_get_order( $order_id ); + + if ( $order->get_total() > 0 ) { + // Mark as processing or on-hold (payment won't be taken until delivery). + $order->update_status( apply_filters( 'woocommerce_cod_process_payment_order_status', $order->has_downloadable_item() ? 'on-hold' : 'processing', $order ), __( 'Payment to be made upon delivery.', 'woocommerce' ) ); + } else { + $order->payment_complete(); + } + + // Reduce stock levels. + wc_reduce_stock_levels( $order_id ); + + // Remove cart. + WC()->cart->empty_cart(); + + // Return thankyou redirect. + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + } + + /** + * Output for the order received page. + */ + public function thankyou_page() { + if ( $this->instructions ) { + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) ); + } + } + + /** + * Change payment complete order status to completed for COD orders. + * + * @since 3.1.0 + * @param string $status Current order status. + * @param int $order_id Order ID. + * @param WC_Order|false $order Order object. + * @return string + */ + public function change_payment_complete_order_status( $status, $order_id = 0, $order = false ) { + if ( $order && 'cod' === $order->get_payment_method() ) { + $status = 'completed'; + } + return $status; + } + + /** + * Add content to the WC emails. + * + * @access public + * @param WC_Order $order Order object. + * @param bool $sent_to_admin Sent to admin. + * @param bool $plain_text Email format: plain text or HTML. + */ + public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { + if ( $this->instructions && ! $sent_to_admin && $this->id === $order->get_payment_method() ) { + echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/images/paypal.png b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/images/paypal.png new file mode 100644 index 0000000..f2e57a2 Binary files /dev/null and b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/images/paypal.png differ diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.js b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.js new file mode 100644 index 0000000..705d0aa --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.js @@ -0,0 +1,46 @@ +jQuery( function( $ ) { + 'use strict'; + + /** + * Object to handle PayPal admin functions. + */ + var wc_paypal_admin = { + isTestMode: function() { + return $( '#woocommerce_paypal_testmode' ).is( ':checked' ); + }, + + /** + * Initialize. + */ + init: function() { + $( document.body ).on( 'change', '#woocommerce_paypal_testmode', function() { + var test_api_username = $( '#woocommerce_paypal_sandbox_api_username' ).parents( 'tr' ).eq( 0 ), + test_api_password = $( '#woocommerce_paypal_sandbox_api_password' ).parents( 'tr' ).eq( 0 ), + test_api_signature = $( '#woocommerce_paypal_sandbox_api_signature' ).parents( 'tr' ).eq( 0 ), + live_api_username = $( '#woocommerce_paypal_api_username' ).parents( 'tr' ).eq( 0 ), + live_api_password = $( '#woocommerce_paypal_api_password' ).parents( 'tr' ).eq( 0 ), + live_api_signature = $( '#woocommerce_paypal_api_signature' ).parents( 'tr' ).eq( 0 ); + + if ( $( this ).is( ':checked' ) ) { + test_api_username.show(); + test_api_password.show(); + test_api_signature.show(); + live_api_username.hide(); + live_api_password.hide(); + live_api_signature.hide(); + } else { + test_api_username.hide(); + test_api_password.hide(); + test_api_signature.hide(); + live_api_username.show(); + live_api_password.show(); + live_api_signature.show(); + } + } ); + + $( '#woocommerce_paypal_testmode' ).change(); + } + }; + + wc_paypal_admin.init(); +}); diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.min.js b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.min.js new file mode 100644 index 0000000..24ad802 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/js/paypal-admin.min.js @@ -0,0 +1 @@ +jQuery(function($){'use strict';var wc_paypal_admin={isTestMode:function(){return $('#woocommerce_paypal_testmode').is(':checked')},init:function(){$(document.body).on('change','#woocommerce_paypal_testmode',function(){var test_api_username=$('#woocommerce_paypal_sandbox_api_username').parents('tr').eq(0),test_api_password=$('#woocommerce_paypal_sandbox_api_password').parents('tr').eq(0),test_api_signature=$('#woocommerce_paypal_sandbox_api_signature').parents('tr').eq(0),live_api_username=$('#woocommerce_paypal_api_username').parents('tr').eq(0),live_api_password=$('#woocommerce_paypal_api_password').parents('tr').eq(0),live_api_signature=$('#woocommerce_paypal_api_signature').parents('tr').eq(0);if($(this).is(':checked')){test_api_username.show();test_api_password.show();test_api_signature.show();live_api_username.hide();live_api_password.hide();live_api_signature.hide()}else{test_api_username.hide();test_api_password.hide();test_api_signature.hide();live_api_username.show();live_api_password.show();live_api_signature.show()}});$('#woocommerce_paypal_testmode').change()}};wc_paypal_admin.init()}) \ No newline at end of file diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php new file mode 100644 index 0000000..9118f7c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/class-wc-gateway-paypal.php @@ -0,0 +1,448 @@ +id = 'paypal'; + $this->has_fields = false; + $this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' ); + $this->method_title = __( 'PayPal', 'woocommerce' ); + /* translators: %s: Link to WC system status page */ + $this->method_description = __( 'PayPal Standard redirects customers to PayPal to enter their payment information.', 'woocommerce' ); + $this->supports = array( + 'products', + 'refunds', + ); + + // Load the settings. + $this->init_form_fields(); + $this->init_settings(); + + // Define user set variables. + $this->title = $this->get_option( 'title' ); + $this->description = $this->get_option( 'description' ); + $this->testmode = 'yes' === $this->get_option( 'testmode', 'no' ); + $this->debug = 'yes' === $this->get_option( 'debug', 'no' ); + $this->email = $this->get_option( 'email' ); + $this->receiver_email = $this->get_option( 'receiver_email', $this->email ); + $this->identity_token = $this->get_option( 'identity_token' ); + self::$log_enabled = $this->debug; + + if ( $this->testmode ) { + /* translators: %s: Link to PayPal sandbox testing guide page */ + $this->description .= ' ' . sprintf( __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the PayPal Sandbox Testing Guide for more details.', 'woocommerce' ), 'https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/' ); + $this->description = trim( $this->description ); + } + + add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); + add_action( 'woocommerce_order_status_on-hold_to_processing', array( $this, 'capture_payment' ) ); + add_action( 'woocommerce_order_status_on-hold_to_completed', array( $this, 'capture_payment' ) ); + + if ( ! $this->is_valid_for_use() ) { + $this->enabled = 'no'; + } else { + include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-ipn-handler.php'; + new WC_Gateway_Paypal_IPN_Handler( $this->testmode, $this->receiver_email ); + + if ( $this->identity_token ) { + include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-pdt-handler.php'; + new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token ); + } + } + } + + /** + * Return whether or not this gateway still requires setup to function. + * + * When this gateway is toggled on via AJAX, if this returns true a + * redirect will occur to the settings page instead. + * + * @since 3.4.0 + * @return bool + */ + public function needs_setup() { + return ! is_email( $this->email ); + } + + /** + * Logging method. + * + * @param string $message Log message. + * @param string $level Optional. Default 'info'. Possible values: + * emergency|alert|critical|error|warning|notice|info|debug. + */ + public static function log( $message, $level = 'info' ) { + if ( self::$log_enabled ) { + if ( empty( self::$log ) ) { + self::$log = wc_get_logger(); + } + self::$log->log( $level, $message, array( 'source' => 'paypal' ) ); + } + } + + /** + * Processes and saves options. + * If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out. + * + * @return bool was anything saved? + */ + public function process_admin_options() { + $saved = parent::process_admin_options(); + + // Maybe clear logs. + if ( 'yes' !== $this->get_option( 'debug', 'no' ) ) { + if ( empty( self::$log ) ) { + self::$log = wc_get_logger(); + } + self::$log->clear( 'paypal' ); + } + + return $saved; + } + + /** + * Get gateway icon. + * + * @return string + */ + public function get_icon() { + $icon_html = ''; + $icon = (array) $this->get_icon_image( WC()->countries->get_base_country() ); + + foreach ( $icon as $i ) { + $icon_html .= '' . esc_attr__( 'PayPal acceptance mark', 'woocommerce' ) . ''; + } + + $icon_html .= sprintf( '' . esc_attr__( 'What is PayPal?', 'woocommerce' ) . '', esc_url( $this->get_icon_url( WC()->countries->get_base_country() ) ) ); + + return apply_filters( 'woocommerce_gateway_icon', $icon_html, $this->id ); + } + + /** + * Get the link for an icon based on country. + * + * @param string $country Country two letter code. + * @return string + */ + protected function get_icon_url( $country ) { + $url = 'https://www.paypal.com/' . strtolower( $country ); + $home_counties = array( 'BE', 'CZ', 'DK', 'HU', 'IT', 'JP', 'NL', 'NO', 'ES', 'SE', 'TR', 'IN' ); + $countries = array( 'DZ', 'AU', 'BH', 'BQ', 'BW', 'CA', 'CN', 'CW', 'FI', 'FR', 'DE', 'GR', 'HK', 'ID', 'JO', 'KE', 'KW', 'LU', 'MY', 'MA', 'OM', 'PH', 'PL', 'PT', 'QA', 'IE', 'RU', 'BL', 'SX', 'MF', 'SA', 'SG', 'SK', 'KR', 'SS', 'TW', 'TH', 'AE', 'GB', 'US', 'VN' ); + + if ( in_array( $country, $home_counties, true ) ) { + return $url . '/webapps/mpp/home'; + } elseif ( in_array( $country, $countries, true ) ) { + return $url . '/webapps/mpp/paypal-popup'; + } else { + return $url . '/cgi-bin/webscr?cmd=xpt/Marketing/general/WIPaypal-outside'; + } + } + + /** + * Get PayPal images for a country. + * + * @param string $country Country code. + * @return array of image URLs + */ + protected function get_icon_image( $country ) { + switch ( $country ) { + case 'US': + case 'NZ': + case 'CZ': + case 'HU': + case 'MY': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo/AM_mc_vs_dc_ae.jpg'; + break; + case 'TR': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo-center/logo_paypal_odeme_secenekleri.jpg'; + break; + case 'GB': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/Logo/AM_mc_vs_ms_ae_UK.png'; + break; + case 'MX': + $icon = array( + 'https://www.paypal.com/es_XC/Marketing/i/banner/paypal_visa_mastercard_amex.png', + 'https://www.paypal.com/es_XC/Marketing/i/banner/paypal_debit_card_275x60.gif', + ); + break; + case 'FR': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo-center/logo_paypal_moyens_paiement_fr.jpg'; + break; + case 'AU': + $icon = 'https://www.paypalobjects.com/webstatic/en_AU/mktg/logo/Solutions-graphics-1-184x80.jpg'; + break; + case 'DK': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo-center/logo_PayPal_betalingsmuligheder_dk.jpg'; + break; + case 'RU': + $icon = 'https://www.paypalobjects.com/webstatic/ru_RU/mktg/business/pages/logo-center/AM_mc_vs_dc_ae.jpg'; + break; + case 'NO': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo-center/banner_pl_just_pp_319x110.jpg'; + break; + case 'CA': + $icon = 'https://www.paypalobjects.com/webstatic/en_CA/mktg/logo-image/AM_mc_vs_dc_ae.jpg'; + break; + case 'HK': + $icon = 'https://www.paypalobjects.com/webstatic/en_HK/mktg/logo/AM_mc_vs_dc_ae.jpg'; + break; + case 'SG': + $icon = 'https://www.paypalobjects.com/webstatic/en_SG/mktg/Logos/AM_mc_vs_dc_ae.jpg'; + break; + case 'TW': + $icon = 'https://www.paypalobjects.com/webstatic/en_TW/mktg/logos/AM_mc_vs_dc_ae.jpg'; + break; + case 'TH': + $icon = 'https://www.paypalobjects.com/webstatic/en_TH/mktg/Logos/AM_mc_vs_dc_ae.jpg'; + break; + case 'JP': + $icon = 'https://www.paypal.com/ja_JP/JP/i/bnr/horizontal_solution_4_jcb.gif'; + break; + case 'IN': + $icon = 'https://www.paypalobjects.com/webstatic/mktg/logo/AM_mc_vs_dc_ae.jpg'; + break; + default: + $icon = WC_HTTPS::force_https_url( WC()->plugin_url() . '/includes/gateways/paypal/assets/images/paypal.png' ); + break; + } + return apply_filters( 'woocommerce_paypal_icon', $icon ); + } + + /** + * Check if this gateway is enabled and available in the user's country. + * + * @return bool + */ + public function is_valid_for_use() { + return in_array( + get_woocommerce_currency(), + apply_filters( + 'woocommerce_paypal_supported_currencies', + array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) + ), + true + ); + } + + /** + * Admin Panel Options. + * - Options for bits like 'title' and availability on a country-by-country basis. + * + * @since 1.0.0 + */ + public function admin_options() { + if ( $this->is_valid_for_use() ) { + parent::admin_options(); + } else { + ?> +
      +

      + : +

      +
      + form_fields = include 'includes/settings-paypal.php'; + } + + /** + * Get the transaction URL. + * + * @param WC_Order $order Order object. + * @return string + */ + public function get_transaction_url( $order ) { + if ( $this->testmode ) { + $this->view_transaction_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s'; + } else { + $this->view_transaction_url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=%s'; + } + return parent::get_transaction_url( $order ); + } + + /** + * Process the payment and return the result. + * + * @param int $order_id Order ID. + * @return array + */ + public function process_payment( $order_id ) { + include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-request.php'; + + $order = wc_get_order( $order_id ); + $paypal_request = new WC_Gateway_Paypal_Request( $this ); + + return array( + 'result' => 'success', + 'redirect' => $paypal_request->get_request_url( $order, $this->testmode ), + ); + } + + /** + * Can the order be refunded via PayPal? + * + * @param WC_Order $order Order object. + * @return bool + */ + public function can_refund_order( $order ) { + $has_api_creds = false; + + if ( $this->testmode ) { + $has_api_creds = $this->get_option( 'sandbox_api_username' ) && $this->get_option( 'sandbox_api_password' ) && $this->get_option( 'sandbox_api_signature' ); + } else { + $has_api_creds = $this->get_option( 'api_username' ) && $this->get_option( 'api_password' ) && $this->get_option( 'api_signature' ); + } + + return $order && $order->get_transaction_id() && $has_api_creds; + } + + /** + * Init the API class and set the username/password etc. + */ + protected function init_api() { + include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-api-handler.php'; + + WC_Gateway_Paypal_API_Handler::$api_username = $this->testmode ? $this->get_option( 'sandbox_api_username' ) : $this->get_option( 'api_username' ); + WC_Gateway_Paypal_API_Handler::$api_password = $this->testmode ? $this->get_option( 'sandbox_api_password' ) : $this->get_option( 'api_password' ); + WC_Gateway_Paypal_API_Handler::$api_signature = $this->testmode ? $this->get_option( 'sandbox_api_signature' ) : $this->get_option( 'api_signature' ); + WC_Gateway_Paypal_API_Handler::$sandbox = $this->testmode; + } + + /** + * Process a refund if supported. + * + * @param int $order_id Order ID. + * @param float $amount Refund amount. + * @param string $reason Refund reason. + * @return bool|WP_Error + */ + public function process_refund( $order_id, $amount = null, $reason = '' ) { + $order = wc_get_order( $order_id ); + + if ( ! $this->can_refund_order( $order ) ) { + return new WP_Error( 'error', __( 'Refund failed.', 'woocommerce' ) ); + } + + $this->init_api(); + + $result = WC_Gateway_Paypal_API_Handler::refund_transaction( $order, $amount, $reason ); + + if ( is_wp_error( $result ) ) { + $this->log( 'Refund Failed: ' . $result->get_error_message(), 'error' ); + return new WP_Error( 'error', $result->get_error_message() ); + } + + $this->log( 'Refund Result: ' . wc_print_r( $result, true ) ); + + switch ( strtolower( $result->ACK ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + case 'success': + case 'successwithwarning': + $order->add_order_note( + /* translators: 1: Refund amount, 2: Refund ID */ + sprintf( __( 'Refunded %1$s - Refund ID: %2$s', 'woocommerce' ), $result->GROSSREFUNDAMT, $result->REFUNDTRANSACTIONID ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + ); + return true; + } + + return isset( $result->L_LONGMESSAGE0 ) ? new WP_Error( 'error', $result->L_LONGMESSAGE0 ) : false; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + } + + /** + * Capture payment when the order is changed from on-hold to complete or processing + * + * @param int $order_id Order ID. + */ + public function capture_payment( $order_id ) { + $order = wc_get_order( $order_id ); + + if ( 'paypal' === $order->get_payment_method() && 'pending' === get_post_meta( $order->get_id(), '_paypal_status', true ) && $order->get_transaction_id() ) { + $this->init_api(); + $result = WC_Gateway_Paypal_API_Handler::do_capture( $order ); + + if ( is_wp_error( $result ) ) { + $this->log( 'Capture Failed: ' . $result->get_error_message(), 'error' ); + /* translators: %s: Paypal gateway error message */ + $order->add_order_note( sprintf( __( 'Payment could not captured: %s', 'woocommerce' ), $result->get_error_message() ) ); + return; + } + + $this->log( 'Capture Result: ' . wc_print_r( $result, true ) ); + + // phpcs:disable WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar + if ( ! empty( $result->PAYMENTSTATUS ) ) { + switch ( $result->PAYMENTSTATUS ) { + case 'Completed': + /* translators: 1: Amount, 2: Authorization ID, 3: Transaction ID */ + $order->add_order_note( sprintf( __( 'Payment of %1$s was captured - Auth ID: %2$s, Transaction ID: %3$s', 'woocommerce' ), $result->AMT, $result->AUTHORIZATIONID, $result->TRANSACTIONID ) ); + update_post_meta( $order->get_id(), '_paypal_status', $result->PAYMENTSTATUS ); + update_post_meta( $order->get_id(), '_transaction_id', $result->TRANSACTIONID ); + break; + default: + /* translators: 1: Authorization ID, 2: Payment status */ + $order->add_order_note( sprintf( __( 'Payment could not captured - Auth ID: %1$s, Status: %2$s', 'woocommerce' ), $result->AUTHORIZATIONID, $result->PAYMENTSTATUS ) ); + break; + } + } + // phpcs:enable + } + } + + /** + * Load admin scripts. + * + * @since 3.3.0 + */ + public function admin_scripts() { + $screen = get_current_screen(); + $screen_id = $screen ? $screen->id : ''; + + if ( 'woocommerce_page_wc-settings' !== $screen_id ) { + return; + } + + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + + wp_enqueue_script( 'woocommerce_paypal_admin', WC()->plugin_url() . '/includes/gateways/paypal/assets/js/paypal-admin' . $suffix . '.js', array(), WC_VERSION, true ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-api-handler.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-api-handler.php new file mode 100644 index 0000000..445e250 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-api-handler.php @@ -0,0 +1,202 @@ + '84.0', + 'SIGNATURE' => self::$api_signature, + 'USER' => self::$api_username, + 'PWD' => self::$api_password, + 'METHOD' => 'DoCapture', + 'AUTHORIZATIONID' => $order->get_transaction_id(), + 'AMT' => number_format( is_null( $amount ) ? $order->get_total() : $amount, 2, '.', '' ), + 'CURRENCYCODE' => $order->get_currency(), + 'COMPLETETYPE' => 'Complete', + ); + return apply_filters( 'woocommerce_paypal_capture_request', $request, $order, $amount ); + } + + /** + * Get refund request args. + * + * @param WC_Order $order Order object. + * @param float $amount Refund amount. + * @param string $reason Refund reason. + * @return array + */ + public static function get_refund_request( $order, $amount = null, $reason = '' ) { + $request = array( + 'VERSION' => '84.0', + 'SIGNATURE' => self::$api_signature, + 'USER' => self::$api_username, + 'PWD' => self::$api_password, + 'METHOD' => 'RefundTransaction', + 'TRANSACTIONID' => $order->get_transaction_id(), + 'NOTE' => html_entity_decode( wc_trim_string( $reason, 255 ), ENT_NOQUOTES, 'UTF-8' ), + 'REFUNDTYPE' => 'Full', + ); + if ( ! is_null( $amount ) ) { + $request['AMT'] = number_format( $amount, 2, '.', '' ); + $request['CURRENCYCODE'] = $order->get_currency(); + $request['REFUNDTYPE'] = 'Partial'; + } + return apply_filters( 'woocommerce_paypal_refund_request', $request, $order, $amount, $reason ); + } + + /** + * Capture an authorization. + * + * @param WC_Order $order Order object. + * @param float $amount Amount. + * @return object Either an object of name value pairs for a success, or a WP_ERROR object. + */ + public static function do_capture( $order, $amount = null ) { + $raw_response = wp_safe_remote_post( + self::$sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', + array( + 'method' => 'POST', + 'body' => self::get_capture_request( $order, $amount ), + 'timeout' => 70, + 'user-agent' => 'WooCommerce/' . WC()->version, + 'httpversion' => '1.1', + ) + ); + + WC_Gateway_Paypal::log( 'DoCapture Response: ' . wc_print_r( $raw_response, true ) ); + + if ( empty( $raw_response['body'] ) ) { + return new WP_Error( 'paypal-api', 'Empty Response' ); + } elseif ( is_wp_error( $raw_response ) ) { + return $raw_response; + } + + parse_str( $raw_response['body'], $response ); + + return (object) $response; + } + + /** + * Refund an order via PayPal. + * + * @param WC_Order $order Order object. + * @param float $amount Refund amount. + * @param string $reason Refund reason. + * @return object Either an object of name value pairs for a success, or a WP_ERROR object. + */ + public static function refund_transaction( $order, $amount = null, $reason = '' ) { + $raw_response = wp_safe_remote_post( + self::$sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', + array( + 'method' => 'POST', + 'body' => self::get_refund_request( $order, $amount, $reason ), + 'timeout' => 70, + 'user-agent' => 'WooCommerce/' . WC()->version, + 'httpversion' => '1.1', + ) + ); + + WC_Gateway_Paypal::log( 'Refund Response: ' . wc_print_r( $raw_response, true ) ); + + if ( empty( $raw_response['body'] ) ) { + return new WP_Error( 'paypal-api', 'Empty Response' ); + } elseif ( is_wp_error( $raw_response ) ) { + return $raw_response; + } + + parse_str( $raw_response['body'], $response ); + + return (object) $response; + } +} + +/** + * Here for backwards compatibility. + * + * @since 3.0.0 + */ +class WC_Gateway_Paypal_Refund extends WC_Gateway_Paypal_API_Handler { + /** + * Get refund request args. Proxy to WC_Gateway_Paypal_API_Handler::get_refund_request(). + * + * @param WC_Order $order Order object. + * @param float $amount Refund amount. + * @param string $reason Refund reason. + * + * @return array + */ + public static function get_request( $order, $amount = null, $reason = '' ) { + return self::get_refund_request( $order, $amount, $reason ); + } + + /** + * Process an order refund. + * + * @param WC_Order $order Order object. + * @param float $amount Refund amount. + * @param string $reason Refund reason. + * @param bool $sandbox Whether to use sandbox mode or not. + * @return object Either an object of name value pairs for a success, or a WP_ERROR object. + */ + public static function refund_order( $order, $amount = null, $reason = '', $sandbox = false ) { + if ( $sandbox ) { + self::$sandbox = $sandbox; + } + $result = self::refund_transaction( $order, $amount, $reason ); + if ( is_wp_error( $result ) ) { + return $result; + } else { + return (array) $result; + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php new file mode 100644 index 0000000..151404d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-ipn-handler.php @@ -0,0 +1,378 @@ +receiver_email = $receiver_email; + $this->sandbox = $sandbox; + } + + /** + * Check for PayPal IPN Response. + */ + public function check_response() { + if ( ! empty( $_POST ) && $this->validate_ipn() ) { // WPCS: CSRF ok. + $posted = wp_unslash( $_POST ); // WPCS: CSRF ok, input var ok. + + // @codingStandardsIgnoreStart + do_action( 'valid-paypal-standard-ipn-request', $posted ); + // @codingStandardsIgnoreEnd + exit; + } + + wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) ); + } + + /** + * There was a valid response. + * + * @param array $posted Post data after wp_unslash. + */ + public function valid_response( $posted ) { + $order = ! empty( $posted['custom'] ) ? $this->get_paypal_order( $posted['custom'] ) : false; + + if ( $order ) { + + // Lowercase returned variables. + $posted['payment_status'] = strtolower( $posted['payment_status'] ); + + WC_Gateway_Paypal::log( 'Found order #' . $order->get_id() ); + WC_Gateway_Paypal::log( 'Payment status: ' . $posted['payment_status'] ); + + if ( method_exists( $this, 'payment_status_' . $posted['payment_status'] ) ) { + call_user_func( array( $this, 'payment_status_' . $posted['payment_status'] ), $order, $posted ); + } + } + } + + /** + * Check PayPal IPN validity. + */ + public function validate_ipn() { + WC_Gateway_Paypal::log( 'Checking IPN response is valid' ); + + // Get received values from post data. + $validate_ipn = wp_unslash( $_POST ); // WPCS: CSRF ok, input var ok. + $validate_ipn['cmd'] = '_notify-validate'; + + // Send back post vars to paypal. + $params = array( + 'body' => $validate_ipn, + 'timeout' => 60, + 'httpversion' => '1.1', + 'compress' => false, + 'decompress' => false, + 'user-agent' => 'WooCommerce/' . WC()->version, + ); + + // Post back to get a response. + $response = wp_safe_remote_post( $this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); + + WC_Gateway_Paypal::log( 'IPN Response: ' . wc_print_r( $response, true ) ); + + // Check to see if the request was valid. + if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { + WC_Gateway_Paypal::log( 'Received valid response from PayPal IPN' ); + return true; + } + + WC_Gateway_Paypal::log( 'Received invalid response from PayPal IPN' ); + + if ( is_wp_error( $response ) ) { + WC_Gateway_Paypal::log( 'Error response: ' . $response->get_error_message() ); + } + + return false; + } + + /** + * Check for a valid transaction type. + * + * @param string $txn_type Transaction type. + */ + protected function validate_transaction_type( $txn_type ) { + $accepted_types = array( 'cart', 'instant', 'express_checkout', 'web_accept', 'masspay', 'send_money', 'paypal_here' ); + + if ( ! in_array( strtolower( $txn_type ), $accepted_types, true ) ) { + WC_Gateway_Paypal::log( 'Aborting, Invalid type:' . $txn_type ); + exit; + } + } + + /** + * Check currency from IPN matches the order. + * + * @param WC_Order $order Order object. + * @param string $currency Currency code. + */ + protected function validate_currency( $order, $currency ) { + if ( $order->get_currency() !== $currency ) { + WC_Gateway_Paypal::log( 'Payment error: Currencies do not match (sent "' . $order->get_currency() . '" | returned "' . $currency . '")' ); + + /* translators: %s: currency code. */ + $order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'woocommerce' ), $currency ) ); + exit; + } + } + + /** + * Check payment amount from IPN matches the order. + * + * @param WC_Order $order Order object. + * @param int $amount Amount to validate. + */ + protected function validate_amount( $order, $amount ) { + if ( number_format( $order->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { + WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (gross ' . $amount . ')' ); + + /* translators: %s: Amount. */ + $order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'woocommerce' ), $amount ) ); + exit; + } + } + + /** + * Check receiver email from PayPal. If the receiver email in the IPN is different than what is stored in. + * WooCommerce -> Settings -> Checkout -> PayPal, it will log an error about it. + * + * @param WC_Order $order Order object. + * @param string $receiver_email Email to validate. + */ + protected function validate_receiver_email( $order, $receiver_email ) { + if ( strcasecmp( trim( $receiver_email ), trim( $this->receiver_email ) ) !== 0 ) { + WC_Gateway_Paypal::log( "IPN Response is for another account: {$receiver_email}. Your email is {$this->receiver_email}" ); + + /* translators: %s: email address . */ + $order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'woocommerce' ), $receiver_email ) ); + exit; + } + } + + /** + * Handle a completed payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_completed( $order, $posted ) { + if ( $order->has_status( wc_get_is_paid_statuses() ) ) { + WC_Gateway_Paypal::log( 'Aborting, Order #' . $order->get_id() . ' is already complete.' ); + exit; + } + + $this->validate_transaction_type( $posted['txn_type'] ); + $this->validate_currency( $order, $posted['mc_currency'] ); + $this->validate_amount( $order, $posted['mc_gross'] ); + $this->validate_receiver_email( $order, $posted['receiver_email'] ); + $this->save_paypal_meta_data( $order, $posted ); + + if ( 'completed' === $posted['payment_status'] ) { + if ( $order->has_status( 'cancelled' ) ) { + $this->payment_status_paid_cancelled_order( $order, $posted ); + } + + $this->payment_complete( $order, ( ! empty( $posted['txn_id'] ) ? wc_clean( $posted['txn_id'] ) : '' ), __( 'IPN payment completed', 'woocommerce' ) ); + + if ( ! empty( $posted['mc_fee'] ) ) { + // Log paypal transaction fee. + update_post_meta( $order->get_id(), 'PayPal Transaction Fee', wc_clean( $posted['mc_fee'] ) ); + } + } else { + if ( 'authorization' === $posted['pending_reason'] ) { + $this->payment_on_hold( $order, __( 'Payment authorized. Change payment status to processing or complete to capture funds.', 'woocommerce' ) ); + } else { + /* translators: %s: pending reason. */ + $this->payment_on_hold( $order, sprintf( __( 'Payment pending (%s).', 'woocommerce' ), $posted['pending_reason'] ) ); + } + } + } + + /** + * Handle a pending payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_pending( $order, $posted ) { + $this->payment_status_completed( $order, $posted ); + } + + /** + * Handle a failed payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_failed( $order, $posted ) { + /* translators: %s: payment status. */ + $order->update_status( 'failed', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) ); + } + + /** + * Handle a denied payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_denied( $order, $posted ) { + $this->payment_status_failed( $order, $posted ); + } + + /** + * Handle an expired payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_expired( $order, $posted ) { + $this->payment_status_failed( $order, $posted ); + } + + /** + * Handle a voided payment. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_voided( $order, $posted ) { + $this->payment_status_failed( $order, $posted ); + } + + /** + * When a user cancelled order is marked paid. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_paid_cancelled_order( $order, $posted ) { + $this->send_ipn_email_notification( + /* translators: %s: order link. */ + sprintf( __( 'Payment for cancelled order %s received', 'woocommerce' ), '' . $order->get_order_number() . '' ), + /* translators: %s: order ID. */ + sprintf( __( 'Order #%s has been marked paid by PayPal IPN, but was previously cancelled. Admin handling required.', 'woocommerce' ), $order->get_order_number() ) + ); + } + + /** + * Handle a refunded order. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_refunded( $order, $posted ) { + // Only handle full refunds, not partial. + if ( $order->get_total() === wc_format_decimal( $posted['mc_gross'] * -1 ) ) { + + /* translators: %s: payment status. */ + $order->update_status( 'refunded', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), strtolower( $posted['payment_status'] ) ) ); + + $this->send_ipn_email_notification( + /* translators: %s: order link. */ + sprintf( __( 'Payment for order %s refunded', 'woocommerce' ), '' . $order->get_order_number() . '' ), + /* translators: %1$s: order ID, %2$s: reason code. */ + sprintf( __( 'Order #%1$s has been marked as refunded - PayPal reason code: %2$s', 'woocommerce' ), $order->get_order_number(), $posted['reason_code'] ) + ); + } + } + + /** + * Handle a reversal. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_reversed( $order, $posted ) { + /* translators: %s: payment status. */ + $order->update_status( 'on-hold', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) ); + + $this->send_ipn_email_notification( + /* translators: %s: order link. */ + sprintf( __( 'Payment for order %s reversed', 'woocommerce' ), '' . $order->get_order_number() . '' ), + /* translators: %1$s: order ID, %2$s: reason code. */ + sprintf( __( 'Order #%1$s has been marked on-hold due to a reversal - PayPal reason code: %2$s', 'woocommerce' ), $order->get_order_number(), wc_clean( $posted['reason_code'] ) ) + ); + } + + /** + * Handle a cancelled reversal. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function payment_status_canceled_reversal( $order, $posted ) { + $this->send_ipn_email_notification( + /* translators: %s: order link. */ + sprintf( __( 'Reversal cancelled for order #%s', 'woocommerce' ), $order->get_order_number() ), + /* translators: %1$s: order ID, %2$s: order link. */ + sprintf( __( 'Order #%1$s has had a reversal cancelled. Please check the status of payment and update the order status accordingly here: %2$s', 'woocommerce' ), $order->get_order_number(), esc_url( $order->get_edit_order_url() ) ) + ); + } + + /** + * Save important data from the IPN to the order. + * + * @param WC_Order $order Order object. + * @param array $posted Posted data. + */ + protected function save_paypal_meta_data( $order, $posted ) { + if ( ! empty( $posted['payment_type'] ) ) { + update_post_meta( $order->get_id(), 'Payment type', wc_clean( $posted['payment_type'] ) ); + } + if ( ! empty( $posted['txn_id'] ) ) { + update_post_meta( $order->get_id(), '_transaction_id', wc_clean( $posted['txn_id'] ) ); + } + if ( ! empty( $posted['payment_status'] ) ) { + update_post_meta( $order->get_id(), '_paypal_status', wc_clean( $posted['payment_status'] ) ); + } + } + + /** + * Send a notification to the user handling orders. + * + * @param string $subject Email subject. + * @param string $message Email message. + */ + protected function send_ipn_email_notification( $subject, $message ) { + $new_order_settings = get_option( 'woocommerce_new_order_settings', array() ); + $mailer = WC()->mailer(); + $message = $mailer->wrap_message( $subject, $message ); + + $woocommerce_paypal_settings = get_option( 'woocommerce_paypal_settings' ); + if ( ! empty( $woocommerce_paypal_settings['ipn_notification'] ) && 'no' === $woocommerce_paypal_settings['ipn_notification'] ) { + return; + } + + $mailer->send( ! empty( $new_order_settings['recipient'] ) ? $new_order_settings['recipient'] : get_option( 'admin_email' ), strip_tags( $subject ), $message ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php new file mode 100644 index 0000000..051d071 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-pdt-handler.php @@ -0,0 +1,136 @@ +identity_token = $identity_token; + $this->sandbox = $sandbox; + } + + /** + * Validate a PDT transaction to ensure its authentic. + * + * @param string $transaction TX ID. + * @return bool|array False or result array if successful and valid. + */ + protected function validate_transaction( $transaction ) { + $pdt = array( + 'body' => array( + 'cmd' => '_notify-synch', + 'tx' => $transaction, + 'at' => $this->identity_token, + ), + 'timeout' => 60, + 'httpversion' => '1.1', + 'user-agent' => 'WooCommerce/' . WC_VERSION, + ); + + // Post back to get a response. + $response = wp_safe_remote_post( $this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $pdt ); + + if ( is_wp_error( $response ) || strpos( $response['body'], 'SUCCESS' ) !== 0 ) { + return false; + } + + // Parse transaction result data. + $transaction_result = array_map( 'wc_clean', array_map( 'urldecode', explode( "\n", $response['body'] ) ) ); + $transaction_results = array(); + + foreach ( $transaction_result as $line ) { + $line = explode( '=', $line ); + $transaction_results[ $line[0] ] = isset( $line[1] ) ? $line[1] : ''; + } + + if ( ! empty( $transaction_results['charset'] ) && function_exists( 'iconv' ) ) { + foreach ( $transaction_results as $key => $value ) { + $transaction_results[ $key ] = iconv( $transaction_results['charset'], 'utf-8', $value ); + } + } + + return $transaction_results; + } + + /** + * Check Response for PDT. + */ + public function check_response() { + if ( empty( $_REQUEST['cm'] ) || empty( $_REQUEST['tx'] ) || empty( $_REQUEST['st'] ) ) { // WPCS: Input var ok, CSRF ok, sanitization ok. + return; + } + + $order_id = wc_clean( wp_unslash( $_REQUEST['cm'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok. + $status = wc_clean( strtolower( wp_unslash( $_REQUEST['st'] ) ) ); // WPCS: input var ok, CSRF ok, sanitization ok. + $amount = wc_clean( wp_unslash( $_REQUEST['amt'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok. + $transaction = wc_clean( wp_unslash( $_REQUEST['tx'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok. + $order = $this->get_paypal_order( $order_id ); + + if ( ! $order || ! $order->has_status( 'pending' ) ) { + return false; + } + + $transaction_result = $this->validate_transaction( $transaction ); + + if ( $transaction_result ) { + WC_Gateway_Paypal::log( 'PDT Transaction Status: ' . wc_print_r( $status, true ) ); + + update_post_meta( $order->get_id(), '_paypal_status', $status ); + update_post_meta( $order->get_id(), '_transaction_id', $transaction ); + + if ( 'completed' === $status ) { + if ( $order->get_total() !== $amount ) { + WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (amt ' . $amount . ')', 'error' ); + /* translators: 1: Payment amount */ + $this->payment_on_hold( $order, sprintf( __( 'Validation error: PayPal amounts do not match (amt %s).', 'woocommerce' ), $amount ) ); + } else { + $this->payment_complete( $order, $transaction, __( 'PDT payment completed', 'woocommerce' ) ); + + // Log paypal transaction fee and payment type. + if ( ! empty( $transaction_result['mc_fee'] ) ) { + update_post_meta( $order->get_id(), 'PayPal Transaction Fee', $transaction_result['mc_fee'] ); + } + if ( ! empty( $transaction_result['payment_type'] ) ) { + update_post_meta( $order->get_id(), 'Payment type', $transaction_result['payment_type'] ); + } + } + } else { + if ( 'authorization' === $transaction_result['pending_reason'] ) { + $this->payment_on_hold( $order, __( 'Payment authorized. Change payment status to processing or complete to capture funds.', 'woocommerce' ) ); + } else { + /* translators: 1: Pending reason */ + $this->payment_on_hold( $order, sprintf( __( 'Payment pending (%s).', 'woocommerce' ), $transaction_result['pending_reason'] ) ); + } + } + } else { + WC_Gateway_Paypal::log( 'Received invalid response from PayPal PDT' ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php new file mode 100644 index 0000000..d22ece3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-request.php @@ -0,0 +1,552 @@ +gateway = $gateway; + $this->notify_url = WC()->api_request_url( 'WC_Gateway_Paypal' ); + } + + /** + * Get the PayPal request URL for an order. + * + * @param WC_Order $order Order object. + * @param bool $sandbox Whether to use sandbox mode or not. + * @return string + */ + public function get_request_url( $order, $sandbox = false ) { + $this->endpoint = $sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; + $paypal_args = $this->get_paypal_args( $order ); + $mask = array( + 'first_name' => '***', + 'last_name' => '***', + 'address1' => '***', + 'address2' => '***', + 'city' => '***', + 'state' => '***', + 'zip' => '***', + 'country' => '***', + 'email' => '***@***', + 'night_phone_a' => '***', + 'night_phone_b' => '***', + 'night_phone_c' => '***', + ); + + WC_Gateway_Paypal::log( 'PayPal Request Args for order ' . $order->get_order_number() . ': ' . wc_print_r( array_merge( $paypal_args, array_intersect_key( $mask, $paypal_args ) ), true ) ); + + return $this->endpoint . http_build_query( $paypal_args, '', '&' ); + } + + /** + * Limit length of an arg. + * + * @param string $string Argument to limit. + * @param integer $limit Limit size in characters. + * @return string + */ + protected function limit_length( $string, $limit = 127 ) { + // As the output is to be used in http_build_query which applies URL encoding, the string needs to be + // cut as if it was URL-encoded, but returned non-encoded (it will be encoded by http_build_query later). + $url_encoded_str = rawurlencode( $string ); + + if ( strlen( $url_encoded_str ) > $limit ) { + $string = rawurldecode( substr( $url_encoded_str, 0, $limit - 3 ) . '...' ); + } + return $string; + } + + /** + * Get transaction args for paypal request, except for line item args. + * + * @param WC_Order $order Order object. + * @return array + */ + protected function get_transaction_args( $order ) { + return array_merge( + array( + 'cmd' => '_cart', + 'business' => $this->gateway->get_option( 'email' ), + 'no_note' => 1, + 'currency_code' => get_woocommerce_currency(), + 'charset' => 'utf-8', + 'rm' => is_ssl() ? 2 : 1, + 'upload' => 1, + 'return' => esc_url_raw( add_query_arg( 'utm_nooverride', '1', $this->gateway->get_return_url( $order ) ) ), + 'cancel_return' => esc_url_raw( $order->get_cancel_order_url_raw() ), + 'page_style' => $this->gateway->get_option( 'page_style' ), + 'image_url' => esc_url_raw( $this->gateway->get_option( 'image_url' ) ), + 'paymentaction' => $this->gateway->get_option( 'paymentaction' ), + 'bn' => 'WooThemes_Cart', + 'invoice' => $this->limit_length( $this->gateway->get_option( 'invoice_prefix' ) . $order->get_order_number(), 127 ), + 'custom' => wp_json_encode( + array( + 'order_id' => $order->get_id(), + 'order_key' => $order->get_order_key(), + ) + ), + 'notify_url' => $this->limit_length( $this->notify_url, 255 ), + 'first_name' => $this->limit_length( $order->get_billing_first_name(), 32 ), + 'last_name' => $this->limit_length( $order->get_billing_last_name(), 64 ), + 'address1' => $this->limit_length( $order->get_billing_address_1(), 100 ), + 'address2' => $this->limit_length( $order->get_billing_address_2(), 100 ), + 'city' => $this->limit_length( $order->get_billing_city(), 40 ), + 'state' => $this->get_paypal_state( $order->get_billing_country(), $order->get_billing_state() ), + 'zip' => $this->limit_length( wc_format_postcode( $order->get_billing_postcode(), $order->get_billing_country() ), 32 ), + 'country' => $this->limit_length( $order->get_billing_country(), 2 ), + 'email' => $this->limit_length( $order->get_billing_email() ), + ), + $this->get_phone_number_args( $order ), + $this->get_shipping_args( $order ) + ); + } + + /** + * If the default request with line items is too long, generate a new one with only one line item. + * + * If URL is longer than 2,083 chars, ignore line items and send cart to Paypal as a single item. + * One item's name can only be 127 characters long, so the URL should not be longer than limit. + * URL character limit via: + * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. + * + * @param WC_Order $order Order to be sent to Paypal. + * @param array $paypal_args Arguments sent to Paypal in the request. + * @return array + */ + protected function fix_request_length( $order, $paypal_args ) { + $max_paypal_length = 2083; + $query_candidate = http_build_query( $paypal_args, '', '&' ); + + if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { + return $paypal_args; + } + + return apply_filters( + 'woocommerce_paypal_args', array_merge( + $this->get_transaction_args( $order ), + $this->get_line_item_args( $order, true ) + ), $order + ); + + } + + /** + * Get PayPal Args for passing to PP. + * + * @param WC_Order $order Order object. + * @return array + */ + protected function get_paypal_args( $order ) { + WC_Gateway_Paypal::log( 'Generating payment form for order ' . $order->get_order_number() . '. Notify URL: ' . $this->notify_url ); + + $paypal_args = apply_filters( + 'woocommerce_paypal_args', array_merge( + $this->get_transaction_args( $order ), + $this->get_line_item_args( $order ) + ), $order + ); + + return $this->fix_request_length( $order, $paypal_args ); + } + + /** + * Get phone number args for paypal request. + * + * @param WC_Order $order Order object. + * @return array + */ + protected function get_phone_number_args( $order ) { + if ( in_array( $order->get_billing_country(), array( 'US', 'CA' ), true ) ) { + $phone_number = str_replace( array( '(', '-', ' ', ')', '.' ), '', $order->get_billing_phone() ); + $phone_number = ltrim( $phone_number, '+1' ); + $phone_args = array( + 'night_phone_a' => substr( $phone_number, 0, 3 ), + 'night_phone_b' => substr( $phone_number, 3, 3 ), + 'night_phone_c' => substr( $phone_number, 6, 4 ), + ); + } else { + $phone_args = array( + 'night_phone_b' => $order->get_billing_phone(), + ); + } + return $phone_args; + } + + /** + * Get shipping args for paypal request. + * + * @param WC_Order $order Order object. + * @return array + */ + protected function get_shipping_args( $order ) { + $shipping_args = array(); + + if ( 'yes' === $this->gateway->get_option( 'send_shipping' ) ) { + $shipping_args['address_override'] = $this->gateway->get_option( 'address_override' ) === 'yes' ? 1 : 0; + $shipping_args['no_shipping'] = 0; + + // If we are sending shipping, send shipping address instead of billing. + $shipping_args['first_name'] = $this->limit_length( $order->get_shipping_first_name(), 32 ); + $shipping_args['last_name'] = $this->limit_length( $order->get_shipping_last_name(), 64 ); + $shipping_args['address1'] = $this->limit_length( $order->get_shipping_address_1(), 100 ); + $shipping_args['address2'] = $this->limit_length( $order->get_shipping_address_2(), 100 ); + $shipping_args['city'] = $this->limit_length( $order->get_shipping_city(), 40 ); + $shipping_args['state'] = $this->get_paypal_state( $order->get_shipping_country(), $order->get_shipping_state() ); + $shipping_args['country'] = $this->limit_length( $order->get_shipping_country(), 2 ); + $shipping_args['zip'] = $this->limit_length( wc_format_postcode( $order->get_shipping_postcode(), $order->get_shipping_country() ), 32 ); + } else { + $shipping_args['no_shipping'] = 1; + } + + return $shipping_args; + } + + /** + * Get shipping cost line item args for paypal request. + * + * @param WC_Order $order Order object. + * @param bool $force_one_line_item Whether one line item was forced by validation or URL length. + * @return array + */ + protected function get_shipping_cost_line_item( $order, $force_one_line_item ) { + $line_item_args = array(); + $shipping_total = $order->get_shipping_total(); + if ( $force_one_line_item ) { + $shipping_total += $order->get_shipping_tax(); + } + + // Add shipping costs. Paypal ignores anything over 5 digits (999.99 is the max). + // We also check that shipping is not the **only** cost as PayPal won't allow payment + // if the items have no cost. + if ( $order->get_shipping_total() > 0 && $order->get_shipping_total() < 999.99 && $this->number_format( $order->get_shipping_total() + $order->get_shipping_tax(), $order ) !== $this->number_format( $order->get_total(), $order ) ) { + $line_item_args['shipping_1'] = $this->number_format( $shipping_total, $order ); + } elseif ( $order->get_shipping_total() > 0 ) { + /* translators: %s: Order shipping method */ + $this->add_line_item( sprintf( __( 'Shipping via %s', 'woocommerce' ), $order->get_shipping_method() ), 1, $this->number_format( $shipping_total, $order ) ); + } + + return $line_item_args; + } + + /** + * Get line item args for paypal request as a single line item. + * + * @param WC_Order $order Order object. + * @return array + */ + protected function get_line_item_args_single_item( $order ) { + $this->delete_line_items(); + + $all_items_name = $this->get_order_item_names( $order ); + $this->add_line_item( $all_items_name ? $all_items_name : __( 'Order', 'woocommerce' ), 1, $this->number_format( $order->get_total() - $this->round( $order->get_shipping_total() + $order->get_shipping_tax(), $order ), $order ), $order->get_order_number() ); + $line_item_args = $this->get_shipping_cost_line_item( $order, true ); + + return array_merge( $line_item_args, $this->get_line_items() ); + } + + /** + * Get line item args for paypal request. + * + * @param WC_Order $order Order object. + * @param bool $force_one_line_item Create only one item for this order. + * @return array + */ + protected function get_line_item_args( $order, $force_one_line_item = false ) { + if ( wc_tax_enabled() && wc_prices_include_tax() || ! $this->line_items_valid( $order ) ) { + $force_one_line_item = true; + } + + $line_item_args = array(); + if ( $force_one_line_item ) { + /** + * Send order as a single item. + * + * For shipping, we longer use shipping_1 because paypal ignores it if *any* shipping rules are within paypal, and paypal ignores anything over 5 digits (999.99 is the max). + */ + $line_item_args = $this->get_line_item_args_single_item( $order ); + } else { + /** + * Passing a line item per product if supported. + */ + $this->prepare_line_items( $order ); + $line_item_args['tax_cart'] = $this->number_format( $order->get_total_tax(), $order ); + + if ( $order->get_total_discount() > 0 ) { + $line_item_args['discount_amount_cart'] = $this->number_format( $this->round( $order->get_total_discount(), $order ), $order ); + } + + $line_item_args = array_merge( $line_item_args, $this->get_shipping_cost_line_item( $order, false ) ); + $line_item_args = array_merge( $line_item_args, $this->get_line_items() ); + + } + + return $line_item_args; + } + + /** + * Get order item names as a string. + * + * @param WC_Order $order Order object. + * @return string + */ + protected function get_order_item_names( $order ) { + $item_names = array(); + + foreach ( $order->get_items() as $item ) { + $item_name = $item->get_name(); + $item_meta = strip_tags( + wc_display_item_meta( + $item, array( + 'before' => '', + 'separator' => ', ', + 'after' => '', + 'echo' => false, + 'autop' => false, + ) + ) + ); + + if ( $item_meta ) { + $item_name .= ' (' . $item_meta . ')'; + } + + $item_names[] = $item_name . ' x ' . $item->get_quantity(); + } + + return apply_filters( 'woocommerce_paypal_get_order_item_names', implode( ', ', $item_names ), $order ); + } + + /** + * Get order item names as a string. + * + * @param WC_Order $order Order object. + * @param WC_Order_Item $item Order item object. + * @return string + */ + protected function get_order_item_name( $order, $item ) { + $item_name = $item->get_name(); + $item_meta = strip_tags( + wc_display_item_meta( + $item, array( + 'before' => '', + 'separator' => ', ', + 'after' => '', + 'echo' => false, + 'autop' => false, + ) + ) + ); + + if ( $item_meta ) { + $item_name .= ' (' . $item_meta . ')'; + } + + return apply_filters( 'woocommerce_paypal_get_order_item_name', $item_name, $order, $item ); + } + + /** + * Return all line items. + */ + protected function get_line_items() { + return $this->line_items; + } + + /** + * Remove all line items. + */ + protected function delete_line_items() { + $this->line_items = array(); + } + + /** + * Check if the order has valid line items to use for PayPal request. + * + * The line items are invalid in case of mismatch in totals or if any amount < 0. + * + * @param WC_Order $order Order to be examined. + * @return bool + */ + protected function line_items_valid( $order ) { + $negative_item_amount = false; + $calculated_total = 0; + + // Products. + foreach ( $order->get_items( array( 'line_item', 'fee' ) ) as $item ) { + if ( 'fee' === $item['type'] ) { + $item_line_total = $this->number_format( $item['line_total'], $order ); + $calculated_total += $item_line_total; + } else { + $item_line_total = $this->number_format( $order->get_item_subtotal( $item, false ), $order ); + $calculated_total += $item_line_total * $item->get_quantity(); + } + + if ( $item_line_total < 0 ) { + $negative_item_amount = true; + } + } + $mismatched_totals = $this->number_format( $calculated_total + $order->get_total_tax() + $this->round( $order->get_shipping_total(), $order ) - $this->round( $order->get_total_discount(), $order ), $order ) !== $this->number_format( $order->get_total(), $order ); + return ! $negative_item_amount && ! $mismatched_totals; + } + + /** + * Get line items to send to paypal. + * + * @param WC_Order $order Order object. + */ + protected function prepare_line_items( $order ) { + $this->delete_line_items(); + + // Products. + foreach ( $order->get_items( array( 'line_item', 'fee' ) ) as $item ) { + if ( 'fee' === $item['type'] ) { + $item_line_total = $this->number_format( $item['line_total'], $order ); + $this->add_line_item( $item->get_name(), 1, $item_line_total ); + } else { + $product = $item->get_product(); + $sku = $product ? $product->get_sku() : ''; + $item_line_total = $this->number_format( $order->get_item_subtotal( $item, false ), $order ); + $this->add_line_item( $this->get_order_item_name( $order, $item ), $item->get_quantity(), $item_line_total, $sku ); + } + } + } + + /** + * Add PayPal Line Item. + * + * @param string $item_name Item name. + * @param int $quantity Item quantity. + * @param float $amount Amount. + * @param string $item_number Item number. + */ + protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { + $index = ( count( $this->line_items ) / 4 ) + 1; + + $item = apply_filters( + 'woocommerce_paypal_line_item', array( + 'item_name' => html_entity_decode( wc_trim_string( $item_name ? $item_name : __( 'Item', 'woocommerce' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), + 'quantity' => (int) $quantity, + 'amount' => wc_float_to_string( (float) $amount ), + 'item_number' => $item_number, + ), $item_name, $quantity, $amount, $item_number + ); + + $this->line_items[ 'item_name_' . $index ] = $this->limit_length( $item['item_name'], 127 ); + $this->line_items[ 'quantity_' . $index ] = $item['quantity']; + $this->line_items[ 'amount_' . $index ] = $item['amount']; + $this->line_items[ 'item_number_' . $index ] = $this->limit_length( $item['item_number'], 127 ); + } + + /** + * Get the state to send to paypal. + * + * @param string $cc Country two letter code. + * @param string $state State code. + * @return string + */ + protected function get_paypal_state( $cc, $state ) { + if ( 'US' === $cc ) { + return $state; + } + + $states = WC()->countries->get_states( $cc ); + + if ( isset( $states[ $state ] ) ) { + return $states[ $state ]; + } + + return $state; + } + + /** + * Check if currency has decimals. + * + * @param string $currency Currency to check. + * @return bool + */ + protected function currency_has_decimals( $currency ) { + if ( in_array( $currency, array( 'HUF', 'JPY', 'TWD' ), true ) ) { + return false; + } + + return true; + } + + /** + * Round prices. + * + * @param double $price Price to round. + * @param WC_Order $order Order object. + * @return double + */ + protected function round( $price, $order ) { + $precision = 2; + + if ( ! $this->currency_has_decimals( $order->get_currency() ) ) { + $precision = 0; + } + + return round( $price, $precision ); + } + + /** + * Format prices. + * + * @param float|int $price Price to format. + * @param WC_Order $order Order object. + * @return string + */ + protected function number_format( $price, $order ) { + $decimals = 2; + + if ( ! $this->currency_has_decimals( $order->get_currency() ) ) { + $decimals = 0; + } + + return number_format( $price, $decimals, '.', '' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php new file mode 100644 index 0000000..48b158d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/class-wc-gateway-paypal-response.php @@ -0,0 +1,82 @@ +order_id; + $order_key = $custom->order_key; + } else { + // Nothing was found. + WC_Gateway_Paypal::log( 'Order ID and key were not found in "custom".', 'error' ); + return false; + } + + $order = wc_get_order( $order_id ); + + if ( ! $order ) { + // We have an invalid $order_id, probably because invoice_prefix has changed. + $order_id = wc_get_order_id_by_order_key( $order_key ); + $order = wc_get_order( $order_id ); + } + + if ( ! $order || $order->get_order_key() !== $order_key ) { + WC_Gateway_Paypal::log( 'Order Keys do not match.', 'error' ); + return false; + } + + return $order; + } + + /** + * Complete order, add transaction ID and note. + * + * @param WC_Order $order Order object. + * @param string $txn_id Transaction ID. + * @param string $note Payment note. + */ + protected function payment_complete( $order, $txn_id = '', $note = '' ) { + $order->add_order_note( $note ); + $order->payment_complete( $txn_id ); + WC()->cart->empty_cart(); + } + + /** + * Hold order and add note. + * + * @param WC_Order $order Order object. + * @param string $reason Reason why the payment is on hold. + */ + protected function payment_on_hold( $order, $reason = '' ) { + $order->update_status( 'on-hold', $reason ); + wc_reduce_stock_levels( $order->get_id() ); + WC()->cart->empty_cart(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php new file mode 100644 index 0000000..5026979 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/paypal/includes/settings-paypal.php @@ -0,0 +1,186 @@ + array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable PayPal Standard', 'woocommerce' ), + 'default' => 'no', + ), + 'title' => array( + 'title' => __( 'Title', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), + 'default' => __( 'PayPal', 'woocommerce' ), + 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Description', 'woocommerce' ), + 'type' => 'text', + 'desc_tip' => true, + 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce' ), + 'default' => __( "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account.", 'woocommerce' ), + ), + 'email' => array( + 'title' => __( 'PayPal email', 'woocommerce' ), + 'type' => 'email', + 'description' => __( 'Please enter your PayPal email address; this is needed in order to take payment.', 'woocommerce' ), + 'default' => get_option( 'admin_email' ), + 'desc_tip' => true, + 'placeholder' => 'you@youremail.com', + ), + 'advanced' => array( + 'title' => __( 'Advanced options', 'woocommerce' ), + 'type' => 'title', + 'description' => '', + ), + 'testmode' => array( + 'title' => __( 'PayPal sandbox', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable PayPal sandbox', 'woocommerce' ), + 'default' => 'no', + /* translators: %s: URL */ + 'description' => sprintf( __( 'PayPal sandbox can be used to test payments. Sign up for a developer account.', 'woocommerce' ), 'https://developer.paypal.com/' ), + ), + 'debug' => array( + 'title' => __( 'Debug log', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable logging', 'woocommerce' ), + 'default' => 'no', + /* translators: %s: URL */ + 'description' => sprintf( __( 'Log PayPal events, such as IPN requests, inside %s Note: this may log personal information. We recommend using this for debugging purposes only and deleting the logs when finished.', 'woocommerce' ), '' . WC_Log_Handler_File::get_log_file_path( 'paypal' ) . '' ), + ), + 'ipn_notification' => array( + 'title' => __( 'IPN Email Notifications', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable IPN email notifications', 'woocommerce' ), + 'default' => 'yes', + 'description' => __( 'Send notifications when an IPN is received from PayPal indicating refunds, chargebacks and cancellations.', 'woocommerce' ), + ), + 'receiver_email' => array( + 'title' => __( 'Receiver email', 'woocommerce' ), + 'type' => 'email', + 'description' => __( 'If your main PayPal email differs from the PayPal email entered above, input your main receiver email for your PayPal account here. This is used to validate IPN requests.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => 'you@youremail.com', + ), + 'identity_token' => array( + 'title' => __( 'PayPal identity token', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Optionally enable "Payment Data Transfer" (Profile > Profile and Settings > My Selling Tools > Website Preferences) and then copy your identity token here. This will allow payments to be verified without the need for PayPal IPN.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => '', + ), + 'invoice_prefix' => array( + 'title' => __( 'Invoice prefix', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'woocommerce' ), + 'default' => 'WC-', + 'desc_tip' => true, + ), + 'send_shipping' => array( + 'title' => __( 'Shipping details', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Send shipping details to PayPal instead of billing.', 'woocommerce' ), + 'description' => __( 'PayPal allows us to send one address. If you are using PayPal for shipping labels you may prefer to send the shipping address rather than billing. Turning this option off may prevent PayPal Seller protection from applying.', 'woocommerce' ), + 'default' => 'yes', + ), + 'address_override' => array( + 'title' => __( 'Address override', 'woocommerce' ), + 'type' => 'checkbox', + 'label' => __( 'Enable "address_override" to prevent address information from being changed.', 'woocommerce' ), + 'description' => __( 'PayPal verifies addresses therefore this setting can cause errors (we recommend keeping it disabled).', 'woocommerce' ), + 'default' => 'no', + ), + 'paymentaction' => array( + 'title' => __( 'Payment action', 'woocommerce' ), + 'type' => 'select', + 'class' => 'wc-enhanced-select', + 'description' => __( 'Choose whether you wish to capture funds immediately or authorize payment only.', 'woocommerce' ), + 'default' => 'sale', + 'desc_tip' => true, + 'options' => array( + 'sale' => __( 'Capture', 'woocommerce' ), + 'authorization' => __( 'Authorize', 'woocommerce' ), + ), + ), + 'page_style' => array( + 'title' => __( 'Page style', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Optionally enter the name of the page style you wish to use. These are defined within your PayPal account. This affects classic PayPal checkout screens.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'image_url' => array( + 'title' => __( 'Image url', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Optionally enter the URL to a 150x50px image displayed as your logo in the upper left corner of the PayPal checkout pages.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'api_details' => array( + 'title' => __( 'API credentials', 'woocommerce' ), + 'type' => 'title', + /* translators: %s: URL */ + 'description' => sprintf( __( 'Enter your PayPal API credentials to process refunds via PayPal. Learn how to access your PayPal API Credentials.', 'woocommerce' ), 'https://developer.paypal.com/webapps/developer/docs/classic/api/apiCredentials/#create-an-api-signature' ), + ), + 'api_username' => array( + 'title' => __( 'Live API username', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'api_password' => array( + 'title' => __( 'Live API password', 'woocommerce' ), + 'type' => 'password', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'api_signature' => array( + 'title' => __( 'Live API signature', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'sandbox_api_username' => array( + 'title' => __( 'Sandbox API username', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'sandbox_api_password' => array( + 'title' => __( 'Sandbox API password', 'woocommerce' ), + 'type' => 'password', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), + 'sandbox_api_signature' => array( + 'title' => __( 'Sandbox API signature', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API credentials from PayPal.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + 'placeholder' => __( 'Optional', 'woocommerce' ), + ), +); diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/cards.png b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/cards.png new file mode 100644 index 0000000..c4091a4 Binary files /dev/null and b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/cards.png differ diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/logo.png b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/logo.png new file mode 100644 index 0000000..47e0653 Binary files /dev/null and b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/images/logo.png differ diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js new file mode 100644 index 0000000..88aafb4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js @@ -0,0 +1,118 @@ +/*global Simplify_commerce_params, SimplifyCommerce */ +(function ( $ ) { + + // Form handler + function simplifyFormHandler() { + var $form = $( 'form.checkout, form#order_review, form#add_payment_method' ); + + if ( ( $( '#payment_method_simplify_commerce' ).is( ':checked' ) && 'new' === $( 'input[name="wc-simplify_commerce-payment-token"]:checked' ).val() ) || ( '1' === $( '#woocommerce_add_payment_method' ).val() ) ) { + + if ( 0 === $( 'input.simplify-token' ).length ) { + + $form.block({ + message: null, + overlayCSS: { + background: '#fff', + opacity: 0.6 + } + }); + + var card = $( '#simplify_commerce-card-number' ).val(), + cvc = $( '#simplify_commerce-card-cvc' ).val(), + expiry = $.payment.cardExpiryVal( $( '#simplify_commerce-card-expiry' ).val() ), + address1 = $form.find( '#billing_address_1' ).val() || '', + address2 = $form.find( '#billing_address_2' ).val() || '', + addressCountry = $form.find( '#billing_country' ).val() || '', + addressState = $form.find( '#billing_state' ).val() || '', + addressCity = $form.find( '#billing_city' ).val() || '', + addressZip = $form.find( '#billing_postcode' ).val() || ''; + + addressZip = addressZip.replace( /-/g, '' ); + card = card.replace( /\s/g, '' ); + + SimplifyCommerce.generateToken({ + key: Simplify_commerce_params.key, + card: { + number: card, + cvc: cvc, + expMonth: expiry.month, + expYear: ( expiry.year - 2000 ), + addressLine1: address1, + addressLine2: address2, + addressCountry: addressCountry, + addressState: addressState, + addressZip: addressZip, + addressCity: addressCity + } + }, simplifyResponseHandler ); + + // Prevent the form from submitting + return false; + } + } + + return true; + } + + // Handle Simplify response + function simplifyResponseHandler( data ) { + + var $form = $( 'form.checkout, form#order_review, form#add_payment_method' ), + ccForm = $( '#wc-simplify_commerce-cc-form' ); + + if ( data.error ) { + + // Show the errors on the form + $( '.woocommerce-error, .simplify-token', ccForm ).remove(); + $form.unblock(); + + // Show any validation errors + if ( 'validation' === data.error.code ) { + var fieldErrors = data.error.fieldErrors, + fieldErrorsLength = fieldErrors.length, + errorList = ''; + + for ( var i = 0; i < fieldErrorsLength; i++ ) { + errorList += '
    • ' + Simplify_commerce_params[ fieldErrors[i].field ] + ' ' + Simplify_commerce_params.is_invalid + ' - ' + fieldErrors[i].message + '.
    • '; + } + + ccForm.prepend( '
        ' + errorList + '
      ' ); + } + + } else { + + // Insert the token into the form so it gets submitted to the server + ccForm.append( '' ); + $form.submit(); + } + } + + $( function () { + + $( document.body ).on( 'checkout_error', function () { + $( '.simplify-token' ).remove(); + }); + + /* Checkout Form */ + $( 'form.checkout' ).on( 'checkout_place_order_simplify_commerce', function () { + return simplifyFormHandler(); + }); + + /* Pay Page Form */ + $( 'form#order_review' ).on( 'submit', function () { + return simplifyFormHandler(); + }); + + /* Pay Page Form */ + $( 'form#add_payment_method' ).on( 'submit', function () { + return simplifyFormHandler(); + }); + + /* Both Forms */ + $( 'form.checkout, form#order_review, form#add_payment_method' ).on( 'change', '#wc-simplify_commerce-cc-form input', function() { + $( '.simplify-token' ).remove(); + }); + + }); + +}( jQuery ) ); diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.min.js b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.min.js new file mode 100644 index 0000000..9491d4a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/assets/js/simplify-commerce.min.js @@ -0,0 +1 @@ +!function(e){function r(){var r=e("form.checkout, form#order_review, form#add_payment_method");if((e("#payment_method_simplify_commerce").is(":checked")&&"new"===e('input[name="wc-simplify_commerce-payment-token"]:checked').val()||"1"===e("#woocommerce_add_payment_method").val())&&0===e("input.simplify-token").length){r.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var i=e("#simplify_commerce-card-number").val(),m=e("#simplify_commerce-card-cvc").val(),c=e.payment.cardExpiryVal(e("#simplify_commerce-card-expiry").val()),n=r.find("#billing_address_1").val()||"",a=r.find("#billing_address_2").val()||"",t=r.find("#billing_country").val()||"",d=r.find("#billing_state").val()||"",l=r.find("#billing_city").val()||"",f=r.find("#billing_postcode").val()||"";return f=f.replace(/-/g,""),i=i.replace(/\s/g,""),SimplifyCommerce.generateToken({key:Simplify_commerce_params.key,card:{number:i,cvc:m,expMonth:c.month,expYear:c.year-2e3,addressLine1:n,addressLine2:a,addressCountry:t,addressState:d,addressZip:f,addressCity:l}},o),!1}return!0}function o(r){var o=e("form.checkout, form#order_review, form#add_payment_method"),i=e("#wc-simplify_commerce-cc-form");if(r.error){if(e(".woocommerce-error, .simplify-token",i).remove(),o.unblock(),"validation"===r.error.code){for(var m=r.error.fieldErrors,c=m.length,n="",a=0;a"+Simplify_commerce_params[m[a].field]+" "+Simplify_commerce_params.is_invalid+" - "+m[a].message+".";i.prepend('
        '+n+"
      ")}}else i.append(''),o.submit()}e(function(){e(document.body).on("checkout_error",function(){e(".simplify-token").remove()}),e("form.checkout").on("checkout_place_order_simplify_commerce",function(){return r()}),e("form#order_review").on("submit",function(){return r()}),e("form#add_payment_method").on("submit",function(){return r()}),e("form.checkout, form#order_review, form#add_payment_method").on("change","#wc-simplify_commerce-cc-form input",function(){e(".simplify-token").remove()})})}(jQuery); \ No newline at end of file diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php new file mode 100644 index 0000000..f39fc00 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-addons-gateway-simplify-commerce.php @@ -0,0 +1,522 @@ +id, array( $this, 'scheduled_subscription_payment' ), 10, 2 ); + add_action( 'woocommerce_subscription_failing_payment_method_updated_' . $this->id, array( $this, 'update_failing_payment_method' ), 10, 2 ); + + add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 ); + + // Allow store managers to manually set Simplify as the payment method on a subscription + add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 ); + add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 ); + } + + if ( class_exists( 'WC_Pre_Orders_Order' ) ) { + add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) ); + } + + add_filter( 'woocommerce_simplify_commerce_hosted_args', array( $this, 'hosted_payment_args' ), 10, 2 ); + add_action( 'woocommerce_api_wc_addons_gateway_simplify_commerce', array( $this, 'return_handler' ) ); + } + + /** + * Hosted payment args. + * + * @param array $args + * @param int $order_id + * @return array + */ + public function hosted_payment_args( $args, $order_id ) { + if ( ( $this->order_contains_subscription( $order_id ) ) || ( $this->order_contains_pre_order( $order_id ) && WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) ) { + $args['operation'] = 'create.token'; + } + + $args['redirect-url'] = WC()->api_request_url( 'WC_Addons_Gateway_Simplify_Commerce' ); + + return $args; + } + + /** + * Check if order contains subscriptions. + * + * @param int $order_id + * @return bool + */ + protected function order_contains_subscription( $order_id ) { + return function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ); + } + + /** + * Check if order contains pre-orders. + * + * @param int $order_id + * @return bool + */ + protected function order_contains_pre_order( $order_id ) { + return class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id ); + } + + /** + * Process the subscription. + * + * @param WC_Order $order + * @param string $cart_token + * @uses Simplify_ApiException + * @uses Simplify_BadRequestException + * @return array + * @throws Exception + */ + protected function process_subscription( $order, $cart_token = '' ) { + try { + if ( empty( $cart_token ) ) { + $error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' ); + + if ( 'yes' == $this->sandbox ) { + $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' ); + } + + throw new Simplify_ApiException( $error_msg ); + } + + // Create customer + $customer = Simplify_Customer::createCustomer( + array( + 'token' => $cart_token, + 'email' => $order->get_billing_email(), + 'name' => trim( $order->get_formatted_billing_full_name() ), + 'reference' => $order->get_id(), + ) + ); + + if ( is_object( $customer ) && '' != $customer->id ) { + $this->save_subscription_meta( $order->get_id(), $customer->id ); + } else { + $error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' ); + + throw new Simplify_ApiException( $error_msg ); + } + + $payment_response = $this->process_subscription_payment( $order, $order->get_total() ); + + if ( is_wp_error( $payment_response ) ) { + throw new Exception( $payment_response->get_error_message() ); + } else { + // Remove cart + WC()->cart->empty_cart(); + + // Return thank you page redirect + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + } + } catch ( Simplify_ApiException $e ) { + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + foreach ( $e->getFieldErrors() as $error ) { + wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' ); + } + } else { + wc_add_notice( $e->getMessage(), 'error' ); + } + + return array( + 'result' => 'fail', + 'redirect' => '', + ); + } + } + + /** + * Store the customer and card IDs on the order and subscriptions in the order. + * + * @param int $order_id + * @param string $customer_id + */ + protected function save_subscription_meta( $order_id, $customer_id ) { + + $customer_id = wc_clean( $customer_id ); + + update_post_meta( $order_id, '_simplify_customer_id', $customer_id ); + + // Also store it on the subscriptions being purchased in the order + foreach ( wcs_get_subscriptions_for_order( $order_id ) as $subscription ) { + update_post_meta( $subscription->id, '_simplify_customer_id', $customer_id ); + } + } + + /** + * Process the pre-order. + * + * @param WC_Order $order + * @param string $cart_token + * @uses Simplify_ApiException + * @uses Simplify_BadRequestException + * @return array + */ + protected function process_pre_order( $order, $cart_token = '' ) { + if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order->get_id() ) ) { + + try { + if ( $order->get_total() * 100 < 50 ) { + $error_msg = __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' ); + + throw new Simplify_ApiException( $error_msg ); + } + + if ( empty( $cart_token ) ) { + $error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' ); + + if ( 'yes' == $this->sandbox ) { + $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' ); + } + + throw new Simplify_ApiException( $error_msg ); + } + + // Create customer + $customer = Simplify_Customer::createCustomer( + array( + 'token' => $cart_token, + 'email' => $order->get_billing_email(), + 'name' => trim( $order->get_formatted_billing_full_name() ), + 'reference' => $order->get_id(), + ) + ); + + if ( is_object( $customer ) && '' != $customer->id ) { + $customer_id = wc_clean( $customer->id ); + + // Store the customer ID in the order + update_post_meta( $order->get_id(), '_simplify_customer_id', $customer_id ); + } else { + $error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' ); + + throw new Simplify_ApiException( $error_msg ); + } + + // Reduce stock levels + wc_reduce_stock_levels( $order->get_id() ); + + // Remove cart + WC()->cart->empty_cart(); + + // Is pre ordered! + WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order ); + + // Return thank you page redirect + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + + } catch ( Simplify_ApiException $e ) { + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + foreach ( $e->getFieldErrors() as $error ) { + wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' ); + } + } else { + wc_add_notice( $e->getMessage(), 'error' ); + } + + return array( + 'result' => 'fail', + 'redirect' => '', + ); + } + } else { + return parent::process_standard_payments( $order, $cart_token ); + } + } + + /** + * Process the payment. + * + * @param int $order_id + * @return array + */ + public function process_payment( $order_id ) { + $cart_token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : ''; + $order = wc_get_order( $order_id ); + + // Processing subscription + if ( 'standard' == $this->mode && ( $this->order_contains_subscription( $order->get_id() ) || ( function_exists( 'wcs_is_subscription' ) && wcs_is_subscription( $order_id ) ) ) ) { + return $this->process_subscription( $order, $cart_token ); + + } elseif ( 'standard' == $this->mode && $this->order_contains_pre_order( $order->get_id() ) ) { + // Processing pre-order. + return $this->process_pre_order( $order, $cart_token ); + } else { + // Processing regular product. + return parent::process_payment( $order_id ); + } + } + + /** + * process_subscription_payment function. + * + * @param WC_order $order + * @param int $amount (default: 0) + * @uses Simplify_BadRequestException + * @return bool|WP_Error + */ + public function process_subscription_payment( $order, $amount = 0 ) { + if ( 0 == $amount ) { + // Payment complete + $order->payment_complete(); + + return true; + } + + if ( $amount * 100 < 50 ) { + return new WP_Error( 'simplify_error', __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' ) ); + } + + $customer_id = get_post_meta( $order->get_id(), '_simplify_customer_id', true ); + + if ( ! $customer_id ) { + return new WP_Error( 'simplify_error', __( 'Customer not found.', 'woocommerce' ) ); + } + + try { + // Charge the customer + $payment = Simplify_Payment::createPayment( + array( + 'amount' => $amount * 100, // In cents. + 'customer' => $customer_id, + 'description' => sprintf( __( '%1$s - Order #%2$s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ), + 'currency' => strtoupper( get_woocommerce_currency() ), + 'reference' => $order->get_id(), + ) + ); + + } catch ( Exception $e ) { + + $error_message = $e->getMessage(); + + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + $error_message = ''; + foreach ( $e->getFieldErrors() as $error ) { + $error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')'; + } + } + + $order->add_order_note( sprintf( __( 'Simplify payment error: %s.', 'woocommerce' ), $error_message ) ); + + return new WP_Error( 'simplify_payment_declined', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + + if ( 'APPROVED' == $payment->paymentStatus ) { + // Payment complete + $order->payment_complete( $payment->id ); + + // Add order note + $order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) ); + + return true; + } else { + $order->add_order_note( __( 'Simplify payment declined', 'woocommerce' ) ); + + return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - please try another card.', 'woocommerce' ) ); + } + } + + /** + * scheduled_subscription_payment function. + * + * @param float $amount_to_charge The amount to charge. + * @param WC_Order $renewal_order A WC_Order object created to record the renewal payment. + */ + public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) { + $result = $this->process_subscription_payment( $renewal_order, $amount_to_charge ); + + if ( is_wp_error( $result ) ) { + $renewal_order->update_status( 'failed', sprintf( __( 'Simplify Transaction Failed (%s)', 'woocommerce' ), $result->get_error_message() ) ); + } + } + + /** + * Update the customer_id for a subscription after using Simplify to complete a payment to make up for. + * an automatic renewal payment which previously failed. + * + * @param WC_Subscription $subscription The subscription for which the failing payment method relates. + * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment). + */ + public function update_failing_payment_method( $subscription, $renewal_order ) { + update_post_meta( $subscription->id, '_simplify_customer_id', get_post_meta( $renewal_order->get_id(), '_simplify_customer_id', true ) ); + } + + /** + * Include the payment meta data required to process automatic recurring payments so that store managers can. + * manually set up automatic recurring payments for a customer via the Edit Subscription screen in Subscriptions v2.0+. + * + * @since 2.4 + * @param array $payment_meta associative array of meta data required for automatic payments + * @param WC_Subscription $subscription An instance of a subscription object + * @return array + */ + public function add_subscription_payment_meta( $payment_meta, $subscription ) { + + $payment_meta[ $this->id ] = array( + 'post_meta' => array( + '_simplify_customer_id' => array( + 'value' => get_post_meta( $subscription->id, '_simplify_customer_id', true ), + 'label' => 'Simplify Customer ID', + ), + ), + ); + + return $payment_meta; + } + + /** + * Validate the payment meta data required to process automatic recurring payments so that store managers can. + * manually set up automatic recurring payments for a customer via the Edit Subscription screen in Subscriptions 2.0+. + * + * @since 2.4 + * @param string $payment_method_id The ID of the payment method to validate + * @param array $payment_meta associative array of meta data required for automatic payments + * @throws Exception + */ + public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { + if ( $this->id === $payment_method_id ) { + if ( ! isset( $payment_meta['post_meta']['_simplify_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_simplify_customer_id']['value'] ) ) { + throw new Exception( 'A "_simplify_customer_id" value is required.' ); + } + } + } + + /** + * Don't transfer customer meta to resubscribe orders. + * + * @access public + * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription + * @return void + */ + public function delete_resubscribe_meta( $resubscribe_order ) { + delete_post_meta( $resubscribe_order->get_id(), '_simplify_customer_id' ); + } + + /** + * Process a pre-order payment when the pre-order is released. + * + * @param WC_Order $order + * @return WP_Error|null + */ + public function process_pre_order_release_payment( $order ) { + + try { + $order_items = $order->get_items(); + $order_item = array_shift( $order_items ); + /* translators: 1: site name 2: product name 3: order number */ + $pre_order_name = sprintf( + __( '%1$s - Pre-order for "%2$s" (Order #%3$s)', 'woocommerce' ), + esc_html( get_bloginfo( 'name', 'display' ) ), + $order_item['name'], + $order->get_order_number() + ); + + $customer_id = get_post_meta( $order->get_id(), '_simplify_customer_id', true ); + + if ( ! $customer_id ) { + return new WP_Error( 'simplify_error', __( 'Customer not found.', 'woocommerce' ) ); + } + + // Charge the customer + $payment = Simplify_Payment::createPayment( + array( + 'amount' => $order->get_total() * 100, // In cents. + 'customer' => $customer_id, + 'description' => trim( substr( $pre_order_name, 0, 1024 ) ), + 'currency' => strtoupper( get_woocommerce_currency() ), + 'reference' => $order->get_id(), + ) + ); + + if ( 'APPROVED' == $payment->paymentStatus ) { + // Payment complete + $order->payment_complete( $payment->id ); + + // Add order note + $order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) ); + } else { + return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - the customer need to try another card.', 'woocommerce' ) ); + } + } catch ( Exception $e ) { + $order_note = sprintf( __( 'Simplify Transaction Failed (%s)', 'woocommerce' ), $e->getMessage() ); + + // Mark order as failed if not already set, + // otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times + if ( 'failed' != $order->get_status() ) { + $order->update_status( 'failed', $order_note ); + } else { + $order->add_order_note( $order_note ); + } + } + } + + /** + * Return handler for Hosted Payments. + */ + public function return_handler() { + if ( ! isset( $_REQUEST['cardToken'] ) ) { + parent::return_handler(); + } + + @ob_clean(); + header( 'HTTP/1.1 200 OK' ); + + $redirect_url = wc_get_page_permalink( 'cart' ); + + if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['amount'] ) ) { + $cart_token = $_REQUEST['cardToken']; + $amount = absint( $_REQUEST['amount'] ); + $order_id = absint( $_REQUEST['reference'] ); + $order = wc_get_order( $order_id ); + $order_total = absint( $order->get_total() * 100 ); + + if ( $amount === $order_total ) { + if ( $this->order_contains_subscription( $order->get_id() ) ) { + $response = $this->process_subscription( $order, $cart_token ); + } elseif ( $this->order_contains_pre_order( $order->get_id() ) ) { + $response = $this->process_pre_order( $order, $cart_token ); + } else { + $response = parent::process_standard_payments( $order, $cart_token ); + } + + if ( 'success' == $response['result'] ) { + $redirect_url = $response['redirect']; + } else { + $order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) ); + } + + wp_redirect( $redirect_url ); + exit(); + } + } + + wp_redirect( $redirect_url ); + exit(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php new file mode 100644 index 0000000..0dfbd29 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/class-wc-gateway-simplify-commerce.php @@ -0,0 +1,777 @@ +id = 'simplify_commerce'; + $this->method_title = __( 'Simplify Commerce', 'woocommerce' ); + $this->method_description = __( 'Take payments via Simplify Commerce - uses simplify.js to create card tokens and the Simplify Commerce SDK. Requires SSL when sandbox is disabled.', 'woocommerce' ); + $this->new_method_label = __( 'Use a new card', 'woocommerce' ); + $this->has_fields = true; + $this->supports = array( + 'subscriptions', + 'products', + 'subscription_cancellation', + 'subscription_reactivation', + 'subscription_suspension', + 'subscription_amount_changes', + 'subscription_payment_method_change', // Subscriptions 1.n compatibility + 'subscription_payment_method_change_customer', + 'subscription_payment_method_change_admin', + 'subscription_date_changes', + 'multiple_subscriptions', + 'default_credit_card_form', + 'tokenization', + 'refunds', + 'pre-orders', + ); + $this->view_transaction_url = 'https://www.simplify.com/commerce/app#/payment/%s'; + + // Load the form fields + $this->init_form_fields(); + + // Load the settings. + $this->init_settings(); + + // Get setting values + $this->title = $this->get_option( 'title' ); + $this->description = $this->get_option( 'description' ); + $this->enabled = $this->get_option( 'enabled' ); + $this->mode = $this->get_option( 'mode', 'standard' ); + $this->modal_color = $this->get_option( 'modal_color', '#a46497' ); + $this->sandbox = $this->get_option( 'sandbox' ); + $this->public_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' ); + $this->private_key = ( 'no' === $this->sandbox ) ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' ); + + $this->init_simplify_sdk(); + + // Hooks + add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); + add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); + add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) ); + add_action( 'woocommerce_api_wc_gateway_simplify_commerce', array( $this, 'return_handler' ) ); + } + + /** + * Init Simplify SDK. + */ + protected function init_simplify_sdk() { + // Include lib + require_once dirname( __FILE__ ) . '/includes/Simplify.php'; + + Simplify::$publicKey = $this->public_key; + Simplify::$privateKey = $this->private_key; + Simplify::$userAgent = 'WooCommerce/' . WC()->version; + } + + /** + * Admin Panel Options. + * - Options for bits like 'title' and availability on a country-by-country basis. + */ + public function admin_options() { + ?> +

      + + public_key ) ) : ?> +
      + +

      +

      + +

      + +
      + +

      + + + checks(); ?> + + + generate_settings_html(); ?> + +
      + enabled ) { + return; + } + + if ( version_compare( phpversion(), '5.3', '<' ) ) { + + // PHP Version + echo '

      ' . sprintf( __( 'Simplify Commerce Error: Simplify commerce requires PHP 5.3 and above. You are using version %s.', 'woocommerce' ), phpversion() ) . '

      '; + + } elseif ( ! $this->public_key || ! $this->private_key ) { + + // Check required fields + echo '

      ' . __( 'Simplify Commerce Error: Please enter your public and private keys', 'woocommerce' ) . '

      '; + + } elseif ( 'standard' == $this->mode && ! wc_checkout_is_https() ) { + + // Show message when using standard mode and no SSL on the checkout page + echo '

      ' . sprintf( __( 'Simplify Commerce is enabled, but the force SSL option is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Simplify Commerce will only work in sandbox mode.', 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '

      '; + + } + } + + /** + * Check if this gateway is enabled. + * + * @return bool + */ + public function is_available() { + if ( 'yes' !== $this->enabled ) { + return false; + } + + if ( 'standard' === $this->mode && 'yes' !== $this->sandbox && ! wc_checkout_is_https() ) { + return false; + } + + if ( ! $this->public_key || ! $this->private_key ) { + return false; + } + + return true; + } + + /** + * Initialise Gateway Settings Form Fields. + */ + public function init_form_fields() { + $this->form_fields = array( + 'enabled' => array( + 'title' => __( 'Enable/Disable', 'woocommerce' ), + 'label' => __( 'Enable Simplify Commerce', 'woocommerce' ), + 'type' => 'checkbox', + 'description' => '', + 'default' => 'no', + ), + 'title' => array( + 'title' => __( 'Title', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), + 'default' => __( 'Credit card', 'woocommerce' ), + 'desc_tip' => true, + ), + 'description' => array( + 'title' => __( 'Description', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce' ), + 'default' => 'Pay with your credit card via Simplify Commerce by MasterCard.', + 'desc_tip' => true, + ), + 'mode' => array( + 'title' => __( 'Payment mode', 'woocommerce' ), + 'label' => __( 'Enable Hosted Payments', 'woocommerce' ), + 'type' => 'select', + 'description' => sprintf( __( 'Standard will display the credit card fields on your store (SSL required). %1$s Hosted Payments will display a Simplify Commerce modal dialog on your store (if SSL) or will redirect the customer to Simplify Commerce hosted page (if not SSL). %1$s Note: Hosted Payments need a new API Key pair with the hosted payments flag selected. %2$sFor more details check the Simplify Commerce docs%3$s.', 'woocommerce' ), '
      ', '', '' ), + 'default' => 'standard', + 'options' => array( + 'standard' => __( 'Standard', 'woocommerce' ), + 'hosted' => __( 'Hosted Payments', 'woocommerce' ), + ), + ), + 'modal_color' => array( + 'title' => __( 'Modal color', 'woocommerce' ), + 'type' => 'color', + 'description' => __( 'Set the color of the buttons and titles on the modal dialog.', 'woocommerce' ), + 'default' => '#a46497', + 'desc_tip' => true, + ), + 'sandbox' => array( + 'title' => __( 'Sandbox', 'woocommerce' ), + 'label' => __( 'Enable sandbox mode', 'woocommerce' ), + 'type' => 'checkbox', + 'description' => __( 'Place the payment gateway in sandbox mode using sandbox API keys (real payments will not be taken).', 'woocommerce' ), + 'default' => 'yes', + ), + 'sandbox_public_key' => array( + 'title' => __( 'Sandbox public key', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + 'sandbox_private_key' => array( + 'title' => __( 'Sandbox private key', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + 'public_key' => array( + 'title' => __( 'Public key', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + 'private_key' => array( + 'title' => __( 'Private key', 'woocommerce' ), + 'type' => 'text', + 'description' => __( 'Get your API keys from your Simplify account: Settings > API Keys.', 'woocommerce' ), + 'default' => '', + 'desc_tip' => true, + ), + ); + } + + /** + * Payment form on checkout page. + */ + public function payment_fields() { + $description = $this->get_description(); + + if ( 'yes' == $this->sandbox ) { + $description .= ' ' . sprintf( __( 'TEST MODE ENABLED. Use a test card: %s', 'woocommerce' ), 'https://www.simplify.com/commerce/docs/tutorial/index#testing' ); + } + + if ( $description ) { + echo wpautop( wptexturize( trim( $description ) ) ); + } + + if ( 'standard' == $this->mode ) { + parent::payment_fields(); + } + } + + /** + * Outputs scripts used for simplify payment. + */ + public function payment_scripts() { + $load_scripts = false; + + if ( is_checkout() ) { + $load_scripts = true; + } + if ( $this->is_available() ) { + $load_scripts = true; + } + + if ( false === $load_scripts ) { + return; + } + + wp_enqueue_script( 'simplify-commerce', 'https://www.simplify.com/commerce/v1/simplify.js', array( 'jquery' ), WC_VERSION, true ); + wp_enqueue_script( 'wc-simplify-commerce', WC()->plugin_url() . '/includes/gateways/simplify-commerce/assets/js/simplify-commerce.js', array( 'simplify-commerce', 'wc-credit-card-form' ), WC_VERSION, true ); + wp_localize_script( + 'wc-simplify-commerce', 'Simplify_commerce_params', array( + 'key' => $this->public_key, + 'card.number' => __( 'Card number', 'woocommerce' ), + 'card.expMonth' => __( 'Expiry month', 'woocommerce' ), + 'card.expYear' => __( 'Expiry year', 'woocommerce' ), + 'is_invalid' => __( 'is invalid', 'woocommerce' ), + 'mode' => $this->mode, + 'is_ssl' => is_ssl(), + ) + ); + } + + public function add_payment_method() { + if ( empty( $_POST['simplify_token'] ) ) { + wc_add_notice( __( 'There was a problem adding this card.', 'woocommerce' ), 'error' ); + return; + } + + $cart_token = wc_clean( $_POST['simplify_token'] ); + $customer_token = $this->get_users_token(); + $current_user = wp_get_current_user(); + $customer_info = array( + 'email' => $current_user->user_email, + 'name' => $current_user->display_name, + ); + + $token = $this->save_token( $customer_token, $cart_token, $customer_info ); + if ( is_null( $token ) ) { + wc_add_notice( __( 'There was a problem adding this card.', 'woocommerce' ), 'error' ); + return; + } + + return array( + 'result' => 'success', + 'redirect' => wc_get_endpoint_url( 'payment-methods' ), + ); + } + + /** + * Actually saves a customer token to the database. + * + * @param WC_Payment_Token $customer_token Payment Token + * @param string $cart_token CC Token + * @param array $customer_info 'email', 'name' + * + * @return null|WC_Payment_Token|WC_Payment_Token_CC + */ + public function save_token( $customer_token, $cart_token, $customer_info ) { + if ( ! is_null( $customer_token ) ) { + $customer = Simplify_Customer::findCustomer( $customer_token->get_token() ); + $updates = array( 'token' => $cart_token ); + $customer->setAll( $updates ); + $customer->updateCustomer(); + $customer = Simplify_Customer::findCustomer( $customer_token->get_token() ); // get updated customer with new set card + $token = $customer_token; + } else { + $customer = Simplify_Customer::createCustomer( + array( + 'token' => $cart_token, + 'email' => $customer_info['email'], + 'name' => $customer_info['name'], + ) + ); + $token = new WC_Payment_Token_CC(); + $token->set_token( $customer->id ); + } + + // If we were able to create an save our card, save the data on our side too + if ( is_object( $customer ) && '' != $customer->id ) { + $customer_properties = $customer->getProperties(); + $card = $customer_properties['card']; + $token->set_gateway_id( $this->id ); + $token->set_card_type( strtolower( $card->type ) ); + $token->set_last4( $card->last4 ); + $expiry_month = ( 1 === strlen( $card->expMonth ) ? '0' . $card->expMonth : $card->expMonth ); + $token->set_expiry_month( $expiry_month ); + $token->set_expiry_year( '20' . $card->expYear ); + if ( is_user_logged_in() ) { + $token->set_user_id( get_current_user_id() ); + } + $token->save(); + return $token; + } + + return null; + } + + /** + * Process customer: updating or creating a new customer/saved CC + * + * @param WC_Order $order Order object + * @param WC_Payment_Token $customer_token Payment Token + * @param string $cart_token CC Token + */ + protected function process_customer( $order, $customer_token = null, $cart_token = '' ) { + // Are we saving a new payment method? + if ( is_user_logged_in() && isset( $_POST['wc-simplify_commerce-new-payment-method'] ) && true === (bool) $_POST['wc-simplify_commerce-new-payment-method'] ) { + $customer_info = array( + 'email' => $order->get_billing_email(), + 'name' => trim( $order->get_formatted_billing_full_name() ), + ); + $token = $this->save_token( $customer_token, $cart_token, $customer_info ); + if ( ! is_null( $token ) ) { + $order->add_payment_token( $token ); + } + } + } + + /** + * Process standard payments. + * + * @param WC_Order $order + * @param string $cart_token + * @param string $customer_token + * + * @return array + * @uses Simplify_ApiException + * @uses Simplify_BadRequestException + */ + protected function process_standard_payments( $order, $cart_token = '', $customer_token = '' ) { + try { + + if ( empty( $cart_token ) && empty( $customer_token ) ) { + $error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' ); + + if ( 'yes' == $this->sandbox ) { + $error_msg .= ' ' . __( 'Developers: Please make sure that you are including jQuery and there are no JavaScript errors on the page.', 'woocommerce' ); + } + + throw new Simplify_ApiException( $error_msg ); + } + + // We need to figure out if we want to charge the card token (new unsaved token, no customer, etc) + // or the customer token (just saved method, previously saved method) + $pass_tokens = array(); + + if ( ! empty( $cart_token ) ) { + $pass_tokens['token'] = $cart_token; + } + + if ( ! empty( $customer_token ) ) { + $pass_tokens['customer'] = $customer_token; + // Use the customer token only, since we already saved the (one time use) card token to the customer + if ( isset( $_POST['wc-simplify_commerce-new-payment-method'] ) && true === (bool) $_POST['wc-simplify_commerce-new-payment-method'] ) { + unset( $pass_tokens['token'] ); + } + } + + // Did we create an account and save a payment method? We might need to use the customer token instead of the card token + if ( isset( $_POST['createaccount'] ) && true === (bool) $_POST['createaccount'] && empty( $customer_token ) ) { + $user_token = $this->get_users_token(); + if ( ! is_null( $user_token ) ) { + $pass_tokens['customer'] = $user_token->get_token(); + unset( $pass_tokens['token'] ); + } + } + + $payment_response = $this->do_payment( $order, $order->get_total(), $pass_tokens ); + + if ( is_wp_error( $payment_response ) ) { + throw new Simplify_ApiException( $payment_response->get_error_message() ); + } else { + // Remove cart + WC()->cart->empty_cart(); + + // Return thank you page redirect + return array( + 'result' => 'success', + 'redirect' => $this->get_return_url( $order ), + ); + } + } catch ( Simplify_ApiException $e ) { + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + foreach ( $e->getFieldErrors() as $error ) { + wc_add_notice( $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')', 'error' ); + } + } else { + wc_add_notice( $e->getMessage(), 'error' ); + } + + return array( + 'result' => 'fail', + 'redirect' => '', + ); + } + } + + /** + * do payment function. + * + * @param WC_order $order + * @param int $amount (default: 0) + * @param array $token + * + * @return bool|WP_Error + * @uses Simplify_BadRequestException + */ + public function do_payment( $order, $amount = 0, $token = array() ) { + if ( $amount * 100 < 50 ) { + return new WP_Error( 'simplify_error', __( 'Sorry, the minimum allowed order total is 0.50 to use this payment method.', 'woocommerce' ) ); + } + + try { + // Charge the customer + $data = array( + 'amount' => $amount * 100, // In cents. + 'description' => sprintf( __( '%1$s - Order #%2$s', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order->get_order_number() ), + 'currency' => strtoupper( get_woocommerce_currency() ), + 'reference' => $order->get_id(), + ); + + $data = array_merge( $data, $token ); + $payment = Simplify_Payment::createPayment( $data ); + + } catch ( Exception $e ) { + + $error_message = $e->getMessage(); + + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + $error_message = ''; + foreach ( $e->getFieldErrors() as $error ) { + $error_message .= ' ' . $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')'; + } + } + + $order->add_order_note( sprintf( __( 'Simplify payment error: %s.', 'woocommerce' ), $error_message ) ); + + return new WP_Error( 'simplify_payment_declined', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + + if ( 'APPROVED' == $payment->paymentStatus ) { + // Payment complete + $order->payment_complete( $payment->id ); + + // Add order note + $order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment->id, $payment->authCode ) ); + + return true; + } else { + $order->add_order_note( __( 'Simplify payment declined', 'woocommerce' ) ); + + return new WP_Error( 'simplify_payment_declined', __( 'Payment was declined - please try another card.', 'woocommerce' ) ); + } + } + + /** + * Process standard payments. + * + * @param WC_Order $order + * @return array + */ + protected function process_hosted_payments( $order ) { + return array( + 'result' => 'success', + 'redirect' => $order->get_checkout_payment_url( true ), + ); + } + + protected function get_users_token() { + $customer_token = null; + if ( is_user_logged_in() ) { + $tokens = WC_Payment_Tokens::get_customer_tokens( get_current_user_id() ); + foreach ( $tokens as $token ) { + if ( $token->get_gateway_id() === $this->id ) { + $customer_token = $token; + break; + } + } + } + return $customer_token; + } + + /** + * Process the payment. + * + * @param int $order_id + * + * @return array|void + */ + public function process_payment( $order_id ) { + $order = wc_get_order( $order_id ); + + // Payment/CC form is hosted on Simplify + if ( 'hosted' === $this->mode ) { + return $this->process_hosted_payments( $order ); + } + + // New CC info was entered + if ( isset( $_POST['simplify_token'] ) ) { + $cart_token = wc_clean( $_POST['simplify_token'] ); + $customer_token = $this->get_users_token(); + $customer_token_value = ( ! is_null( $customer_token ) ? $customer_token->get_token() : '' ); + $this->process_customer( $order, $customer_token, $cart_token ); + return $this->process_standard_payments( $order, $cart_token, $customer_token_value ); + } + + // Possibly Create (or update) customer/save payment token, use an existing token, and then process the payment + if ( isset( $_POST['wc-simplify_commerce-payment-token'] ) && 'new' !== $_POST['wc-simplify_commerce-payment-token'] ) { + $token_id = wc_clean( $_POST['wc-simplify_commerce-payment-token'] ); + $token = WC_Payment_Tokens::get( $token_id ); + if ( $token->get_user_id() !== get_current_user_id() ) { + wc_add_notice( __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' ), 'error' ); + return; + } + $this->process_customer( $order, $token ); + return $this->process_standard_payments( $order, '', $token->get_token() ); + } + } + + /** + * Hosted payment args. + * + * @param WC_Order $order + * + * @return array + */ + protected function get_hosted_payments_args( $order ) { + $args = apply_filters( + 'woocommerce_simplify_commerce_hosted_args', array( + 'sc-key' => $this->public_key, + 'amount' => $order->get_total() * 100, + 'reference' => $order->get_id(), + 'name' => esc_html( get_bloginfo( 'name', 'display' ) ), + 'description' => sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ), + 'receipt' => 'false', + 'color' => $this->modal_color, + 'redirect-url' => WC()->api_request_url( 'WC_Gateway_Simplify_Commerce' ), + 'address' => $order->get_billing_address_1() . ' ' . $order->get_billing_address_2(), + 'address-city' => $order->get_billing_city(), + 'address-state' => $order->get_billing_state(), + 'address-zip' => $order->get_billing_postcode(), + 'address-country' => $order->get_billing_country(), + 'operation' => 'create.token', + ), $order->get_id() + ); + + return $args; + } + + /** + * Receipt page. + * + * @param int $order_id + */ + public function receipt_page( $order_id ) { + $order = wc_get_order( $order_id ); + + echo '

      ' . __( 'Thank you for your order, please click the button below to pay with credit card using Simplify Commerce by MasterCard.', 'woocommerce' ) . '

      '; + + $args = $this->get_hosted_payments_args( $order ); + $button_args = array(); + foreach ( $args as $key => $value ) { + $button_args[] = 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; + } + + echo ' + ' . __( 'Cancel order & restore cart', 'woocommerce' ) . ' + '; + } + + /** + * Return handler for Hosted Payments. + */ + public function return_handler() { + @ob_clean(); + header( 'HTTP/1.1 200 OK' ); + + if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['paymentId'] ) && isset( $_REQUEST['signature'] ) ) { + $signature = strtoupper( md5( $_REQUEST['amount'] . $_REQUEST['reference'] . $_REQUEST['paymentId'] . $_REQUEST['paymentDate'] . $_REQUEST['paymentStatus'] . $this->private_key ) ); + $order_id = absint( $_REQUEST['reference'] ); + $order = wc_get_order( $order_id ); + + if ( hash_equals( $signature, $_REQUEST['signature'] ) ) { + $order_complete = $this->process_order_status( $order, $_REQUEST['paymentId'], $_REQUEST['paymentStatus'], $_REQUEST['paymentDate'] ); + + if ( ! $order_complete ) { + $order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) ); + } + + wp_redirect( $this->get_return_url( $order ) ); + exit(); + } + } + + wp_redirect( wc_get_page_permalink( 'cart' ) ); + exit(); + } + + /** + * Process the order status. + * + * @param WC_Order $order + * @param string $payment_id + * @param string $status + * @param string $auth_code + * + * @return bool + */ + public function process_order_status( $order, $payment_id, $status, $auth_code ) { + if ( 'APPROVED' == $status ) { + // Payment complete + $order->payment_complete( $payment_id ); + + // Add order note + $order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %1$s, Auth Code: %2$s)', 'woocommerce' ), $payment_id, $auth_code ) ); + + // Remove cart + WC()->cart->empty_cart(); + + return true; + } + + return false; + } + + /** + * Process refunds. + * WooCommerce 2.2 or later. + * + * @param int $order_id + * @param float $amount + * @param string $reason + * @uses Simplify_ApiException + * @uses Simplify_BadRequestException + * @return bool|WP_Error + */ + public function process_refund( $order_id, $amount = null, $reason = '' ) { + try { + $payment_id = get_post_meta( $order_id, '_transaction_id', true ); + + $refund = Simplify_Refund::createRefund( + array( + 'amount' => $amount * 100, // In cents. + 'payment' => $payment_id, + 'reason' => $reason, + 'reference' => $order_id, + ) + ); + + if ( 'APPROVED' == $refund->paymentStatus ) { + return true; + } else { + throw new Simplify_ApiException( __( 'Refund was declined.', 'woocommerce' ) ); + } + } catch ( Simplify_ApiException $e ) { + if ( $e instanceof Simplify_BadRequestException && $e->hasFieldErrors() && $e->getFieldErrors() ) { + foreach ( $e->getFieldErrors() as $error ) { + return new WP_Error( 'simplify_refund_error', $error->getFieldName() . ': "' . $error->getMessage() . '" (' . $error->getErrorCode() . ')' ); + } + } else { + return new WP_Error( 'simplify_refund_error', $e->getMessage() ); + } + } + + return false; + } + + /** + * Get gateway icon. + * + * @access public + * @return string + */ + public function get_icon() { + $icon = 'Visa'; + $icon .= 'MasterCard'; + $icon .= 'Discover'; + $icon .= 'Amex'; + $icon .= 'JCB'; + + return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify.php new file mode 100644 index 0000000..d0c4859 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify.php @@ -0,0 +1,88 @@ +setAll($hash); + } + + /** + * Creates an OAuth access token + * @param $code - the authorisation code returned from the GET on /oauth/authorize + * @param $redirect_uri = this must be the redirect_uri set in the apps configuration + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + */ + public static function create($code, $redirect_uri, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 3); + + $props = 'code='.$code.'&redirect_uri='.$redirect_uri.'&grant_type=authorization_code'; + $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); + + return new Simplify_AccessToken($resp); + } + + /** + * Refreshes the current token. The access_token and refresh_token values will be updated. + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + * @throws InvalidArgumentException + */ + public function refresh($authentication = null) { + $args = func_get_args(); + + $refresh_token = $this->refresh_token; + if (empty($refresh_token)){ + throw new InvalidArgumentException('Cannot refresh access token; refresh token is invalid'); + } + + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $props = 'refresh_token='.$refresh_token.'&grant_type=refresh_token'; + $resp = Simplify_AccessToken::sendRequest($props, "token", $authentication); + + $this->setAll($resp); + + return $this; + } + + /** + *

      Revokes a token from further use. + * @param $authentication - Authentication information to access the API. If not value is passed the global key Simplify::$publicKey and Simplify::$privateKey are used + * @return Simplify_AccessToken + * @throws InvalidArgumentException + */ + public function revoke($authentication = null) { + $args = func_get_args(); + + $access_token = $this->access_token; + if (empty($access_token)){ + throw new InvalidArgumentException('Cannot revoke access token; access token is invalid'); + } + + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $props = 'token='.$access_token.''; + + Simplify_AccessToken::sendRequest($props, "revoke", $authentication); + + $this->access_token = null; + $this->refresh_token = null; + $this->redirect_uri = null; + + return $this; + } + + private static function sendRequest($props, $context, $authentication){ + + $url = Simplify_Constants::OAUTH_BASE_URL.'/'.$context; + $http = new Simplify_HTTP(); + $resp = $http->oauthRequest($url, $props, $authentication); + + return $resp; + } + + /** + * @ignore + */ + static public function getClazz() { + return "AccessToken"; + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php new file mode 100644 index 0000000..c787b6c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authentication.php @@ -0,0 +1,74 @@ +accessToken = $accessToken; + } + + function __construct2($publicKey, $privateKey) { + $this->publicKey = $publicKey; + $this->privateKey = $privateKey; + } + + function __construct3($publicKey, $privateKey, $accessToken) { + $this->publicKey = $publicKey; + $this->privateKey = $privateKey; + $this->accessToken = $accessToken; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php new file mode 100644 index 0000000..69704b5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Authorization.php @@ -0,0 +1,142 @@ + + *

      amount
      Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD required
      + *
      card.addressCity
      City of the cardholder. [max length: 50, min length: 2]
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
      + *
      card.addressLine1
      Address of the cardholder. [max length: 255]
      + *
      card.addressLine2
      Address of the cardholder if needed. [max length: 255]
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
      + *
      card.name
      Name as it appears on the card. [max length: 50, min length: 2]
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13] required
      + *
      currency
      Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
      + *
      customer
      ID of customer. If specified, card on file of customer will be used.
      + *
      description
      Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
      + *
      reference
      Custom reference field to be used with outside systems.
      + *
      replayId
      An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier, and if one is found we will attempt to return an identical response of the original request. [max length: 50, min length: 1]
      + *
      statementDescription.name
      Merchant name required
      + *
      statementDescription.phoneNumber
      Merchant contact phone number.
      + *
      token
      If specified, card associated with card token will be used. [max length: 255]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Authorization a Authorization object. + */ + static public function createAuthorization($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Authorization(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Authorization object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteAuthorization($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Authorization objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in pagination of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount id description paymentDate.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Authorization objects and the total + * number of Authorization objects available for the given criteria. + * @see ResourceList + */ + static public function listAuthorization($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Authorization(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Authorization object from the API + * + * @param string id the id of the Authorization object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Authorization a Authorization object + */ + static public function findAuthorization($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Authorization(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "Authorization"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php new file mode 100644 index 0000000..0cd0f0c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/CardToken.php @@ -0,0 +1,94 @@ + + *
      callback
      The URL callback for the cardtoken
      + *
      card.addressCity
      City of the cardholder. [max length: 50, min length: 2]
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
      + *
      card.addressLine1
      Address of the cardholder. [max length: 255]
      + *
      card.addressLine2
      Address of the cardholder if needed. [max length: 255]
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
      + *
      card.name
      Name as appears on the card. [max length: 50, min length: 2]
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13] required
      + *
      key
      Key used to create the card token.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return CardToken a CardToken object. + */ + static public function createCardToken($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_CardToken(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + + /** + * Retrieve a Simplify_CardToken object from the API + * + * @param string id the id of the CardToken object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return CardToken a CardToken object + */ + static public function findCardToken($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_CardToken(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "CardToken"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php new file mode 100644 index 0000000..78fca9c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Chargeback.php @@ -0,0 +1,86 @@ + + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Chargeback objects and the total + * number of Chargeback objects available for the given criteria. + * @see ResourceList + */ + static public function listChargeback($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Chargeback(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Chargeback object from the API + * + * @param string id the id of the Chargeback object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Chargeback a Chargeback object + */ + static public function findChargeback($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Chargeback(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "Chargeback"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Constants.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Constants.php new file mode 100644 index 0000000..c2174da --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Constants.php @@ -0,0 +1,58 @@ + + *
      amountOff
      Amount off of the price of the product in the smallest units of the currency of the merchant. While this field is optional, you must provide either amountOff or percentOff for a coupon. Example: 100 = $1.00USD [min value: 1]
      + *
      couponCode
      Code that identifies the coupon to be used. [min length: 2] required
      + *
      description
      A brief section that describes the coupon.
      + *
      durationInMonths
      DEPRECATED - Duration in months that the coupon will be applied after it has first been selected. [min value: 1, max value: 9999]
      + *
      endDate
      Last date of the coupon in UTC millis that the coupon can be applied to a subscription. This ends at 23:59:59 of the merchant timezone.
      + *
      maxRedemptions
      Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
      + *
      numTimesApplied
      The number of times a coupon will be applied on a customer's subscription. [min value: 1, max value: 9999]
      + *
      percentOff
      Percentage off of the price of the product. While this field is optional, you must provide either amountOff or percentOff for a coupon. The percent off is a whole number. [min value: 1, max value: 100]
      + *
      startDate
      First date of the coupon in UTC millis that the coupon can be applied to a subscription. This starts at midnight of the merchant timezone. required
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object. + */ + static public function createCoupon($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Coupon(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Coupon object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteCoupon($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Coupon objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated maxRedemptions timesRedeemed id startDate endDate percentOff couponCode durationInMonths numTimesApplied amountOff.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Coupon objects and the total + * number of Coupon objects available for the given criteria. + * @see ResourceList + */ + static public function listCoupon($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Coupon(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Coupon object from the API + * + * @param string id the id of the Coupon object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object + */ + static public function findCoupon($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Coupon(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Coupon object. + * + * The properties that can be updated: + *
      + *
      endDate
      The ending date in UTC millis for the coupon. This must be after the starting date of the coupon.
      + *
      maxRedemptions
      Maximum number of redemptions allowed for the coupon. A redemption is defined as when the coupon is applied to the subscription for the first time. [min value: 1]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Coupon a Coupon object. + */ + public function updateCoupon($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Coupon"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Customer.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Customer.php new file mode 100644 index 0000000..6bbcf52 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Customer.php @@ -0,0 +1,184 @@ + + *
      card.addressCity
      City of the cardholder. required
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
      + *
      card.addressLine1
      Address of the cardholder required
      + *
      card.addressLine2
      Address of the cardholder if needed. required
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123 required
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 required
      + *
      card.id
      ID of card. Unused during customer create.
      + *
      card.name
      Name as appears on the card. required
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13]
      + *
      email
      Email address of the customer required
      + *
      name
      Customer name [min length: 2] required
      + *
      reference
      Reference field for external applications use.
      + *
      subscriptions.amount
      Amount of payment in the smallest unit of your currency. Example: 100 = $1.00USD
      + *
      subscriptions.billingCycle
      How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
      + *
      subscriptions.billingCycleLimit
      The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
      + *
      subscriptions.coupon
      Coupon associated with the subscription for the customer.
      + *
      subscriptions.currency
      Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
      + *
      subscriptions.customer
      The customer ID to create the subscription for. Do not supply this when creating a customer.
      + *
      subscriptions.frequency
      Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
      + *
      subscriptions.frequencyPeriod
      Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
      + *
      subscriptions.name
      Name describing subscription
      + *
      subscriptions.plan
      The plan ID that the subscription should be created from.
      + *
      subscriptions.quantity
      Quantity of the plan for the subscription. [min value: 1]
      + *
      subscriptions.renewalReminderLeadDays
      If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
      + *
      token
      If specified, card associated with card token will be used
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object. + */ + static public function createCustomer($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Customer(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Customer object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteCustomer($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Customer objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated id name email reference.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Customer objects and the total + * number of Customer objects available for the given criteria. + * @see ResourceList + */ + static public function listCustomer($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Customer(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Customer object from the API + * + * @param string id the id of the Customer object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object + */ + static public function findCustomer($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Customer(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Customer object. + * + * The properties that can be updated: + *
      + *
      card.addressCity
      City of the cardholder. required
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. required
      + *
      card.addressLine1
      Address of the cardholder. required
      + *
      card.addressLine2
      Address of the cardholder if needed. required
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. required
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. required
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123 required
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 required
      + *
      card.id
      ID of card. If present, card details for the customer will not be updated. If not present, the customer will be updated with the supplied card details.
      + *
      card.name
      Name as appears on the card. required
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13]
      + *
      email
      Email address of the customer required
      + *
      name
      Customer name [min length: 2] required
      + *
      reference
      Reference field for external applications use.
      + *
      token
      If specified, card associated with card token will be added to the customer
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Customer a Customer object. + */ + public function updateCustomer($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Customer"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php new file mode 100644 index 0000000..7c6d66a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Deposit.php @@ -0,0 +1,86 @@ + + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: amount dateCreated depositDate.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Deposit objects and the total + * number of Deposit objects available for the given criteria. + * @see ResourceList + */ + static public function listDeposit($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Deposit(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Deposit object from the API + * + * @param string id the id of the Deposit object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Deposit a Deposit object + */ + static public function findDeposit($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Deposit(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "Deposit"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Event.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Event.php new file mode 100644 index 0000000..bdb682e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Event.php @@ -0,0 +1,68 @@ +payload
      The raw JWS payload.
      required + *
      url
      The URL for the webhook. If present it must match the URL registered for the webhook.
      + * @param $authentication Object that contains the API public and private keys. If null the values of the static + * Simplify::$publicKey and Simplify::$privateKey will be used. + * @return Payments_Event an Event object. + * @throws InvalidArgumentException + */ + static public function createEvent($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $paymentsApi = new Simplify_PaymentsApi(); + + $jsonObject = $paymentsApi->jwsDecode($hash, $authentication); + + if ($jsonObject['event'] == null) { + throw new InvalidArgumentException("Incorrect data in webhook event"); + } + + return $paymentsApi->convertFromHashToObject($jsonObject['event'], self::getClazz()); + } + + /** + * @ignore + */ + static public function getClazz() { + return "Event"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php new file mode 100644 index 0000000..2e890eb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Exceptions.php @@ -0,0 +1,294 @@ +status = $status; + $this->errorCode = null; + $this->reference = null; + + if ($errorData != null) { + + $this->reference = $errorData['reference']; + $this->errorData = $errorData; + + $error = $errorData['error']; + if ($error != null) { + + $m = $error['message']; + if ($m != null) { + $this->message = $m; + } + + $this->errorCode = $error['code']; + } + } + } + + /** + * Returns a map of all error data returned by the API. + * @return array a map containing API error data. + */ + function getErrorData() { + return $this->errorData; + } + + /** + * Returns the HTTP status for the request. + * @return string HTTP status code (or null if there is no status). + */ + function getStatus() { + return $this->status; + } + + /** + * Returns unique reference for the API error. + * @return string a reference (or null if there is no reference). + */ + function getReference() { + return $this->reference; + } + + /** + * Returns an code for the API error. + * @return string the error code. + */ + function getErrorCode() { + return $this->errorCode; + } + + /** + * Returns a description of the error. + * @return string Description of the error. + */ + function describe() { + return get_class($this) . ": \"" + . $this->getMessage() . "\" (status: " + . $this->getStatus() . ", error code: " + . $this->getErrorCode() . ", reference: " + . $this->getReference() . ")"; + } + +} + + +/** + * Exception raised when there are communication problems contacting the API. + */ +class Simplify_ApiConnectionException extends Simplify_ApiException { + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } +} + +/** + * Exception raised where there are problems authenticating a request. + */ +class Simplify_AuthenticationException extends Simplify_ApiException { + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } +} + +/** + * Exception raised when the API request contains errors. + */ +class Simplify_BadRequestException extends Simplify_ApiException { + + protected $fieldErrors; + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + + $fieldErrors = array(); + + if ($errorData != null) { + $error = $errorData['error']; + if ($error != null) { + $fieldErrors = $error['fieldErrors']; + if ($fieldErrors != null) { + $this->fieldErrors = array(); + foreach ($fieldErrors as $fieldError) { + array_push($this->fieldErrors, new Simplify_FieldError($fieldError)); + } + } + } + } + } + + /** + * Returns a boolean indicating whether there are any field errors. + * @return boolean true if there are field errors; false otherwise. + */ + function hasFieldErrors() { + return count($this->fieldErrors) > 0; + } + + /** + * Returns a list containing all field errors. + * @return array list of field errors. + */ + function getFieldErrors() { + return $this->fieldErrors; + } + + /** + * Returns a description of the error. + * @return string description of the error. + */ + function describe() { + $s = parent::describe(); + foreach ($this->getFieldErrors() as $fieldError) { + $s = $s . "\n" . (string) $fieldError; + } + return $s . "\n"; + } + +} + +/** + * Represents a single error in a field of a request sent to the API. + */ +class Simplify_FieldError { + + protected $field; + protected $code; + protected $message; + + /** + * @ignore + */ + function __construct($errorData) { + + $this->field = $errorData['field']; + $this->code = $errorData['code']; + $this->message = $errorData['message']; + } + + /** + * Returns the name of the field with the error. + * @return string the field name. + */ + function getFieldName() { + return $this->field; + } + + /** + * Returns the code for the error. + * @return string the error code. + */ + function getErrorCode() { + return $this->code; + } + + /** + * Returns a description of the error. + * @return string description of the error. + */ + function getMessage() { + return $this->message; + } + + + function __toString() { + return "Field error: " . $this->getFieldName() . "\"" . $this->getMessage() . "\" (" . $this->getErrorCode() . ")"; + } + +} + +/** + * Exception when a requested object cannot be found. + */ +class Simplify_ObjectNotFoundException extends Simplify_ApiException { + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } +} + +/** + * Exception when a request was not allowed. + */ +class Simplify_NotAllowedException extends Simplify_ApiException { + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } +} + +/** + * Exception when there was a system error processing a request. + */ +class Simplify_SystemException extends Simplify_ApiException { + + /** + * @ignore + */ + function __construct($message, $status = null, $errorData = null) { + parent::__construct($message, $status, $errorData); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php new file mode 100644 index 0000000..d0fea2a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/FraudCheck.php @@ -0,0 +1,122 @@ + + *
      amount
      Amount of the transaction to be checked for fraud (in the smallest unit of your currency). Example: 100 = $1.00USD
      + *
      card.addressCity
      City of the cardholder. [max length: 50, min length: 2]
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
      + *
      card.addressLine1
      Address of the cardholder. [max length: 255]
      + *
      card.addressLine2
      Address of the cardholder if needed. [max length: 255]
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 characters in length and only contains numbers or letters. [max length: 9, min length: 3]
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
      + *
      card.name
      Name as it appears on the card. [max length: 50, min length: 2]
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13] required
      + *
      currency
      Currency code (ISO-4217) for the transaction to be checked for fraud.
      + *
      description
      - Description of the fraud check.
      + *
      mode
      Fraud check mode. “simple†only does an AVS and CVC check; “advanced†does a complete fraud check, running the input against the set up rules. [valid values: simple, advanced, full] required
      + *
      sessionId
      Session ID usd during data collection. [max length: 255]
      + *
      token
      Description
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return FraudCheck a FraudCheck object. + */ + static public function createFraudCheck($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_FraudCheck(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + + /** + * Retrieve Simplify_FraudCheck objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Allows for ascending or descending sorting of the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: .
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of FraudCheck objects and the total + * number of FraudCheck objects available for the given criteria. + * @see ResourceList + */ + static public function listFraudCheck($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_FraudCheck(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_FraudCheck object from the API + * + * @param string id the id of the FraudCheck object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return FraudCheck a FraudCheck object + */ + static public function findFraudCheck($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_FraudCheck(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "FraudCheck"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Http.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Http.php new file mode 100644 index 0000000..e0925a1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Http.php @@ -0,0 +1,411 @@ + self::POST, + "put" => self::PUT, + "get" => self::GET, + "delete" => self::DELETE); + + private function request($url, $method, $authentication, $payload = '') + { + if ($authentication->publicKey == null) { + throw new InvalidArgumentException('Must have a valid public key to connect to the API'); + } + + if ($authentication->privateKey == null) { + throw new InvalidArgumentException('Must have a valid API key to connect to the API'); + } + + if (!array_key_exists(strtolower($method), self::$_validMethods)) { + throw new InvalidArgumentException('Invalid method: '.strtolower($method)); + } + + $method = self::$_validMethods[strtolower($method)]; + + $curl = curl_init(); + + $options = array(); + + $options[CURLOPT_URL] = $url; + $options[CURLOPT_CUSTOMREQUEST] = $method; + $options[CURLOPT_RETURNTRANSFER] = true; + $options[CURLOPT_FAILONERROR] = false; + + $signature = $this->jwsEncode($authentication, $url, $payload, $method == self::POST || $method == self::PUT); + + if ($method == self::POST || $method == self::PUT) { + $headers = array( + 'Content-type: application/json' + ); + $options[CURLOPT_POSTFIELDS] = $signature; + } else { + $headers = array( + 'Authorization: JWS ' . $signature + ); + } + + array_push($headers, 'Accept: application/json'); + $user_agent = 'PHP-SDK/' . Simplify_Constants::VERSION; + if (Simplify::$userAgent != null) { + $user_agent = $user_agent . ' ' . Simplify::$userAgent; + } + array_push($headers, 'User-Agent: ' . $user_agent); + + $options[CURLOPT_HTTPHEADER] = $headers; + + curl_setopt_array($curl, $options); + + $data = curl_exec($curl); + $errno = curl_errno($curl); + $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + if ($data == false || $errno != CURLE_OK) { + throw new Simplify_ApiConnectionException(curl_error($curl)); + } + + $object = json_decode($data, true); + //'typ' => self::JWS_TYPE, + $response = array('status' => $status, 'object' => $object); + + return $response; + curl_close($curl); + } + + /** + * Handles Simplify API requests + * + * @param $url + * @param $method + * @param $authentication + * @param string $payload + * @return mixed + * @throws Simplify_AuthenticationException + * @throws Simplify_ObjectNotFoundException + * @throws Simplify_BadRequestException + * @throws Simplify_NotAllowedException + * @throws Simplify_SystemException + */ + public function apiRequest($url, $method, $authentication, $payload = ''){ + + $response = $this->request($url, $method, $authentication, $payload); + + $status = $response['status']; + $object = $response['object']; + + if ($status == self::HTTP_SUCCESS) { + return $object; + } + + if ($status == self::HTTP_REDIRECTED) { + throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); + } else if ($status == self::HTTP_BAD_REQUEST) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } else if ($status == self::HTTP_UNAUTHORIZED) { + throw new Simplify_AuthenticationException("You are not authorized to make this request. Are you using the correct API keys?", $status, $object); + } else if ($status == self::HTTP_NOT_FOUND) { + throw new Simplify_ObjectNotFoundException("Object not found", $status, $object); + } else if ($status == self::HTTP_NOT_ALLOWED) { + throw new Simplify_NotAllowedException("Operation not allowed", $status, $object); + } else if ($status < 500) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } + throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); + } + + /** + * Handles Simplify OAuth requests + * + * @param $url + * @param $payload + * @param $authentication + * @return mixed + * @throws Simplify_AuthenticationException + * @throws Simplify_ObjectNotFoundException + * @throws Simplify_BadRequestException + * @throws Simplify_NotAllowedException + * @throws Simplify_SystemException + */ + public function oauthRequest($url, $payload, $authentication){ + + $response = $this->request($url, Simplify_HTTP::POST, $authentication, $payload); + + $status = $response['status']; + $object = $response['object']; + + if ($status == self::HTTP_SUCCESS) { + return $object; + } + + $error = $object['error']; + $error_description = $object['error_description']; + + if ($status == self::HTTP_REDIRECTED) { + throw new Simplify_BadRequestException("Unexpected response code returned from the API, have you got the correct URL?", $status, $object); + } else if ($status == self::HTTP_BAD_REQUEST) { + + if ( $error == 'invalid_request'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Error during OAuth request', $error, $error_description)); + }else if ($error == 'unsupported_grant_type'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unsupported grant type in OAuth request', $error, $error_description)); + }else if ($error == 'invalid_scope'){ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Invalid scope in OAuth request', $error, $error_description)); + }else{ + throw new Simplify_BadRequestException("", $status, $this->buildOauthError('Unknown OAuth error', $error, $error_description)); + } + + //TODO: build BadRequestException error JSON + + } else if ($status == self::HTTP_UNAUTHORIZED){ + + if ($error == 'access_denied'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Access denied for OAuth request', $error, $error_description)); + }else if ($error == 'invalid_client'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Invalid client ID in OAuth request', $error, $error_description)); + }else if ($error == 'unauthorized_client'){ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unauthorized client in OAuth request', $error, $error_description)); + }else{ + throw new Simplify_AuthenticationException("", $status, $this->buildOauthError('Unknown authentication error', $error, $error_description)); + } + + } else if ($status < 500) { + throw new Simplify_BadRequestException("Bad request", $status, $object); + } + throw new Simplify_SystemException("An unexpected error has been raised. Looks like there's something wrong at our end." , $status, $object); + } + + public function jwsDecode($authentication, $hash) + { + if ($authentication->publicKey == null) { + throw new InvalidArgumentException('Must have a valid public key to connect to the API'); + } + + if ($authentication->privateKey == null) { + throw new InvalidArgumentException('Must have a valid API key to connect to the API'); + } + + if (!isset($hash['payload'])) { + throw new InvalidArgumentException('Event data is Missing payload'); + } + $payload = trim($hash['payload']); + + + try { + $parts = explode('.', $payload); + if (count($parts) != 3) { + $this->jwsAuthError("Incorrectly formatted JWS message"); + } + + $headerStr = $this->jwsUrlSafeDecode64($parts[0]); + $bodyStr = $this->jwsUrlSafeDecode64($parts[1]); + $sigStr = $parts[2]; + + $url = null; + if (isset($hash['url'])) { + $url = $hash['url']; + } + $this->jwsVerifyHeader($headerStr, $url, $authentication->publicKey); + + $msg = $parts[0] . "." . $parts[1]; + if (!$this->jwsVerifySignature($authentication->privateKey, $msg, $sigStr)) { + $this->jwsAuthError("JWS signature does not match"); + } + + return $bodyStr; + + } catch (ApiException $e) { + throw $e; + } catch (Exception $e) { + $this->jwsAuthError("Exception during JWS decoding: " . $e); + } + } + + private function jwsEncode($authentication, $url, $payload, $hasPayload) + { + // TODO - better seeding of RNG + $jws_hdr = array('typ' => self::JWS_TYPE, + 'alg' => self::JWS_ALGORITHM, + 'kid' => $authentication->publicKey, + self::JWS_HDR_URI => $url, + self::JWS_HDR_TIMESTAMP => sprintf("%u000", round(microtime(true))), + self::JWS_HDR_NONCE => sprintf("%u", mt_rand()), + ); + + // add oauth token if provided + if ( !empty($authentication->accessToken) ){ + $jws_hdr[self::JWS_HDR_TOKEN] = $authentication->accessToken; + } + + $header = $this->jwsUrlSafeEncode64(json_encode($jws_hdr)); + + if ($hasPayload) { + $payload = $this->jwsUrlSafeEncode64($payload); + } else { + $payload = ''; + } + + $msg = $header . "." . $payload; + return $msg . "." . $this->jwsSign($authentication->privateKey, $msg); + } + + private function jwsSign($privateKey, $msg) { + $decodedPrivateKey = $this->jwsUrlSafeDecode64($privateKey); + $sig = hash_hmac('sha256', $msg, $decodedPrivateKey, true); + + return $this->jwsUrlSafeEncode64($sig); + } + + private function jwsVerifyHeader($header, $url, $publicKey) { + + $hdr = json_decode($header, true); + + if (count($hdr) != self::JWS_NUM_HEADERS) { + $this->jwsAuthError("Incorrect number of JWS header parameters - found " . count($hdr) . " required " . self::JWS_NUM_HEADERS); + } + + if ($hdr['alg'] != self::JWS_ALGORITHM) { + $this->jwsAuthError("Incorrect algorithm - found " . $hdr['alg'] . " required " . self::WS_ALGORITHM); + } + + if ($hdr['typ'] != self::JWS_TYPE) { + $this->jwsAuthError("Incorrect type - found " . $hdr['typ'] . " required " . self::JWS_TYPE); + } + + if ($hdr['kid'] == null) { + $this->jwsAuthError("Missing Key ID"); + } + + if ($hdr['kid'] != $publicKey) { + if ($this->isLiveKey($publicKey)) { + $this->jwsAuthError("Invalid Key ID"); + } + } + + if ($hdr[self::JWS_HDR_URI] == null) { + $this->jwsAuthError("Missing URI"); + } + + if ($url != null && $hdr[self::JWS_HDR_URI] != $url) { + $this->jwsAuthError("Incorrect URL - found " . $hdr[self::JWS_HDR_URI] . " required " . $url); + } + + + if ($hdr[self::JWS_HDR_TIMESTAMP] == null) { + $this->jwsAuthError("Missing timestamp"); + } + + if (!$this->jwsVerifyTimestamp($hdr[self::JWS_HDR_TIMESTAMP])) { + $this->jwsAuthError("Invalid timestamp"); + } + + if ($hdr[self::JWS_HDR_NONCE] == null) { + $this->jwsAuthError("Missing nonce"); + } + + if ($hdr[self::JWS_HDR_UNAME] == null) { + $this->jwsAuthError("Missing username"); + } + } + + + private function jwsVerifySignature($privateKey, $msg, $expectedSig) { + return $this->jwsSign($privateKey, $msg) == $expectedSig; + } + + private function jwsAuthError($reason) { + throw new Simplify_AuthenticationException("JWS authentication failure: " . $reason); + } + + private function jwsVerifyTimestamp($ts) { + $now = round(microtime(true)); // Seconds + return abs($now - $ts / 1000) < self::JWS_MAX_TIMESTAMP_DIFF; + } + + private function isLiveKey($k) { + return strpos($k, "lvpb") === 0; + } + + private function jwsUrlSafeEncode64($s) { + return str_replace(array('+', '/', '='), + array('-', '_', ''), + base64_encode($s)); + } + + private function jwsUrlSafeDecode64($s) { + + switch (strlen($s) % 4) { + case 0: break; + case 2: $s = $s . "=="; + break; + case 3: $s = $s . "="; + break; + default: throw new InvalidArgumentException('incorrectly formatted JWS payload'); + } + return base64_decode(str_replace(array('-', '_'), array('+', '/'), $s)); + } + + private function buildOauthError($msg, $error, $error_description){ + + return array( + 'error' => array( + 'code' => 'oauth_error', + 'message' => $msg.', error code: '.$error.', description: '.$error_description.'' + ) + ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php new file mode 100644 index 0000000..afdbcc5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Invoice.php @@ -0,0 +1,228 @@ + + *
      billingAddress.city
      Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
      + *
      billingAddress.country
      Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
      + *
      billingAddress.line1
      Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.line2
      Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.name
      Billing address name of the location where the goods or services were supplied. Will use the customer name if not provided. [max length: 255]
      + *
      billingAddress.state
      Billing address state of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.zip
      Billing address zip of the location where the goods or services were supplied. [max length: 32]
      + *
      businessAddress.city
      Address city of the business that is sending the invoice. [max length: 255, min length: 2]
      + *
      businessAddress.country
      Address country of the business that is sending the invoice. [max length: 2, min length: 2]
      + *
      businessAddress.line1
      Address line 1 of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.line2
      Address line 2 of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.name
      The name of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.state
      Address state of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.zip
      Address zip of the business that is sending the invoice. [max length: 32]
      + *
      currency
      Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3, default: USD]
      + *
      customer
      The customer ID of the customer we are invoicing. This is optional if invoiceToCopy or a name and email are provided
      + *
      customerTaxNo
      The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
      + *
      discountRate
      The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
      + *
      dueDate
      The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
      + *
      email
      The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
      + *
      invoiceId
      User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
      + *
      invoiceToCopy
      The id of an existing invoice to be copied. This is optional if customer or a name and email are provided
      + *
      items.amount
      Amount of the invoice item (the smallest unit of your currency). Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
      + *
      items.description
      The description of the invoice item. [max length: 1024]
      + *
      items.invoice
      The ID of the invoice this item belongs to.
      + *
      items.product
      The product this invoice item refers to.
      + *
      items.quantity
      Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
      + *
      items.reference
      User defined reference field. [max length: 255]
      + *
      items.tax
      The tax ID of the tax charge in the invoice item.
      + *
      lateFee
      The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
      + *
      memo
      A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
      + *
      name
      The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
      + *
      note
      This field can be used to store a note that is not displayed to the customer. [max length: 4000]
      + *
      reference
      User defined reference field. [max length: 255]
      + *
      shippingAddress.city
      Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
      + *
      shippingAddress.country
      Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
      + *
      shippingAddress.line1
      Address line 1 of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.line2
      Address line 2 of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.name
      Address name of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.state
      Address state of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.zip
      Address zip of the location where the goods or services were supplied. [max length: 32]
      + *
      suppliedDate
      The date on which the goods or services were supplied.
      + *
      taxNo
      The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
      + *
      type
      The type of invoice. One of WEB or MOBILE. [valid values: WEB, MOBILE, default: WEB]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object. + */ + static public function createInvoice($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Invoice(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Invoice object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteInvoice($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Invoice objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id invoiceDate dueDate datePaid customer status dateCreated.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Invoice objects and the total + * number of Invoice objects available for the given criteria. + * @see ResourceList + */ + static public function listInvoice($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Invoice(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Invoice object from the API + * + * @param string id the id of the Invoice object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object + */ + static public function findInvoice($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Invoice(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Invoice object. + * + * The properties that can be updated: + *
      + *
      billingAddress.city
      Billing address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
      + *
      billingAddress.country
      Billing address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
      + *
      billingAddress.line1
      Billing address line 1 of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.line2
      Billing address line 2 of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.name
      Billing address name of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.state
      Billing address state of the location where the goods or services were supplied. [max length: 255]
      + *
      billingAddress.zip
      Billing address zip of the location where the goods or services were supplied. [max length: 32]
      + *
      businessAddress.city
      Business address city of the business that is sending the invoice. [max length: 255, min length: 2]
      + *
      businessAddress.country
      Business address country of the business that is sending the invoice. [max length: 2, min length: 2]
      + *
      businessAddress.line1
      Business address line 1 of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.line2
      Business address line 2 of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.name
      Business address name of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.state
      Business address state of the business that is sending the invoice. [max length: 255]
      + *
      businessAddress.zip
      Business address zip of the business that is sending the invoice. [max length: 32]
      + *
      currency
      Currency code (ISO-4217). Must match the currency associated with your account. [max length: 3, min length: 3]
      + *
      customerTaxNo
      The tax number or VAT id of the person to whom the goods or services were supplied. [max length: 255]
      + *
      datePaid
      This is the date the invoice was PAID in UTC millis.
      + *
      discountRate
      The discount percent as a decimal e.g. 12.5. This is used to calculate the discount amount which is subtracted from the total amount due before any tax is applied. [max length: 6]
      + *
      dueDate
      The date invoice payment is due. If a late fee is provided this will be added to the invoice total is the due date has past.
      + *
      email
      The email of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email.
      + *
      invoiceId
      User defined invoice id. If not provided the system will generate a numeric id. [max length: 255]
      + *
      items.amount
      Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
      + *
      items.description
      The description of the invoice item. [max length: 1024]
      + *
      items.invoice
      The ID of the invoice this item belongs to.
      + *
      items.product
      The Id of the product this item refers to.
      + *
      items.quantity
      Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
      + *
      items.reference
      User defined reference field. [max length: 255]
      + *
      items.tax
      The tax ID of the tax charge in the invoice item.
      + *
      lateFee
      The late fee amount that will be added to the invoice total is the due date is past due. Value provided must be in the smallest unit of your currency. Example: 100 = $1.00USD [max value: 9999900]
      + *
      memo
      A memo that is displayed to the customer on the invoice payment screen. [max length: 4000]
      + *
      name
      The name of the customer we are invoicing. This is optional if customer or invoiceToCopy is provided. A new customer will be created using the the name and email. [max length: 50, min length: 2]
      + *
      note
      This field can be used to store a note that is not displayed to the customer. [max length: 4000]
      + *
      payment
      The ID of the payment. Use this ID to query the /payment API. [max length: 255]
      + *
      reference
      User defined reference field. [max length: 255]
      + *
      shippingAddress.city
      Address city of the location where the goods or services were supplied. [max length: 255, min length: 2]
      + *
      shippingAddress.country
      Address country of the location where the goods or services were supplied. [max length: 2, min length: 2]
      + *
      shippingAddress.line1
      Address line 1 of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.line2
      Address line 2 of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.name
      Address name of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.state
      Address state of the location where the goods or services were supplied. [max length: 255]
      + *
      shippingAddress.zip
      Address zip of the location where the goods or services were supplied. [max length: 32]
      + *
      status
      New status of the invoice.
      + *
      suppliedDate
      The date on which the goods or services were supplied.
      + *
      taxNo
      The tax number or VAT id of the person who supplied the goods or services. [max length: 255]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Invoice a Invoice object. + */ + public function updateInvoice($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Invoice"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php new file mode 100644 index 0000000..9c7d9b8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/InvoiceItem.php @@ -0,0 +1,128 @@ + + *
      amount
      Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: -9999900, max value: 9999900] required
      + *
      description
      Individual items of an invoice [max length: 1024]
      + *
      invoice
      The ID of the invoice this item belongs to.
      + *
      product
      Product ID this item relates to.
      + *
      quantity
      Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1]
      + *
      reference
      User defined reference field. [max length: 255]
      + *
      tax
      The tax ID of the tax charge in the invoice item.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object. + */ + static public function createInvoiceItem($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_InvoiceItem(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_InvoiceItem object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteInvoiceItem($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve a Simplify_InvoiceItem object from the API + * + * @param string id the id of the InvoiceItem object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object + */ + static public function findInvoiceItem($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_InvoiceItem(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_InvoiceItem object. + * + * The properties that can be updated: + *
      + *
      amount
      Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1]
      + *
      description
      Individual items of an invoice
      + *
      quantity
      Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999]
      + *
      reference
      User defined reference field.
      + *
      tax
      The tax ID of the tax charge in the invoice item.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return InvoiceItem a InvoiceItem object. + */ + public function updateInvoiceItem($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "InvoiceItem"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Object.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Object.php new file mode 100644 index 0000000..f7fc4e4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Object.php @@ -0,0 +1,90 @@ +properties)) { + return $this->properties[$key]; + } else { + return null; + } + } + + /** + * @ignore + * + * @param string $key + * @param mixed $value + */ + public function __set($key, $value) { + $this->properties[$key] = $value; + } + + /** + * Updates the object's properties with the values in the specified map. + * @param $hash array Map of values to set. + */ + public function setAll($hash) { + foreach ($hash as $key => $value) { + $this->$key = $value; + } + } + + /** + * @ignore + */ + public function __toString() { + return json_encode($this->properties); + } + + /** + * Returns the object's properties as a map. + * @return array map of properties. + */ + public function getProperties() { + return $this->properties; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Payment.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Payment.php new file mode 100644 index 0000000..44f6169 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Payment.php @@ -0,0 +1,145 @@ + + *
      amount
      Amount of the payment (in the smallest unit of your currency). Example: 100 = $1.00USD
      + *
      authorization
      The ID of the authorization being used to capture the payment.
      + *
      card.addressCity
      City of the cardholder. [max length: 50, min length: 2]
      + *
      card.addressCountry
      Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2]
      + *
      card.addressLine1
      Address of the cardholder. [max length: 255]
      + *
      card.addressLine2
      Address of the cardholder if needed. [max length: 255]
      + *
      card.addressState
      State of residence of the cardholder. For the US, this is a 2-digit USPS code. [max length: 255, min length: 2]
      + *
      card.addressZip
      Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 9, min length: 3]
      + *
      card.cvc
      CVC security code of the card. This is the code on the back of the card. Example: 123
      + *
      card.expMonth
      Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] required
      + *
      card.expYear
      Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] required
      + *
      card.name
      Name as it appears on the card. [max length: 50, min length: 2]
      + *
      card.number
      Card number as it appears on the card. [max length: 19, min length: 13] required
      + *
      currency
      Currency code (ISO-4217) for the transaction. Must match the currency associated with your account. [default: USD] required
      + *
      customer
      ID of customer. If specified, card on file of customer will be used.
      + *
      description
      Free form text field to be used as a description of the payment. This field is echoed back with the payment on any find or list operations. [max length: 1024]
      + *
      invoice
      ID of invoice for which this payment is being made.
      + *
      reference
      Custom reference field to be used with outside systems.
      + *
      replayId
      An identifier that can be sent to uniquely identify a payment request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your payments. If supplied, we will check for a payment on your account that matches this identifier. If found will attempt to return an identical response of the original request. [max length: 50, min length: 1]
      + *
      statementDescription.name
      Merchant name. required
      + *
      statementDescription.phoneNumber
      Merchant contact phone number.
      + *
      token
      If specified, card associated with card token will be used. [max length: 255]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object. + */ + static public function createPayment($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Payment(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + + /** + * Retrieve Simplify_Payment objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated createdBy amount id description paymentDate.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Payment objects and the total + * number of Payment objects available for the given criteria. + * @see ResourceList + */ + static public function listPayment($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Payment(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Payment object from the API + * + * @param string id the id of the Payment object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object + */ + static public function findPayment($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Payment(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Payment object. + * + * The properties that can be updated: + *
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Payment a Payment object. + */ + public function updatePayment($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Payment"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php new file mode 100644 index 0000000..c6f2a89 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/PaymentsApi.php @@ -0,0 +1,358 @@ + 'POST', + 'delete' => 'DELETE', + 'list' => 'GET', + 'show' => 'GET', + 'update' => 'PUT' + ); + + /** + * @ignore + * + * @param object $object + * @param object $authentication + * + * @return mixed + */ + static public function createObject($object, $authentication = null) + { + $paymentsApi = new Simplify_PaymentsApi(); + + $jsonObject = $paymentsApi->execute("create", $object, $authentication); + + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + + return $o; + } + + /** + * @ignore + * + * @param object $object + * @param object $authentication + * + * @return mixed + */ + static public function findObject($object, $authentication = null) + { + $paymentsApi = new Simplify_PaymentsApi(); + + $jsonObject = $paymentsApi->execute("show", $object, $authentication); + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + + return $o; + } + + /** + * @ignore + * + * @param object $object + * @param object $authentication + * + * @return mixed + */ + static public function updateObject($object, $authentication = null) { + $paymentsApi = new Simplify_PaymentsApi(); + + $jsonObject = $paymentsApi->execute("update", $object, $authentication); + $o = $paymentsApi->convertFromHashToObject($jsonObject, $object->getClazz()); + + return $o; + } + + /** + * @ignore + * + * @param object $object + * @param object $authentication + * + * @return mixed + */ + static public function deleteObject($object, $authentication = null) { + $paymentsApi = new Simplify_PaymentsApi(); + + $jsonObject = $paymentsApi->execute("delete", $object, $authentication); + + return $jsonObject; + } + + /** + * @ignore + * + * @param object $object + * @param array $criteria + * @param object $authentication + * + * @return Simplify_ResourceList + */ + static public function listObject($object, $criteria = null, $authentication = null) { + if ($criteria != null) { + if (isset($criteria['max'])) { + $object->max = $criteria['max']; + } + if (isset($criteria['offset'])) { + $object->offset = $criteria['offset']; + } + if (isset($criteria['sorting'])) { + $object->sorting = $criteria['sorting']; + } + if (isset($criteria['filter'])) { + $object->filter = $criteria['filter']; + } + } + + $paymentsApi = new Simplify_PaymentsApi(); + $jsonObject = $paymentsApi->execute("list", $object, $authentication); + + $ret = new Simplify_ResourceList(); + if (array_key_exists('list', $jsonObject) & is_array($jsonObject['list'])) { + foreach ($jsonObject['list'] as $obj) { + array_push($ret->list, $paymentsApi->convertFromHashToObject($obj, $object->getClazz())); + } + $ret->total = $jsonObject['total']; + } + + return $ret; + } + + /** + * @ignore + * + * @param array $from + * @param string $toClazz + * + * @return mixed + */ + public function convertFromHashToObject($from, $toClazz) + { + $clazz = 'stdClass'; + $toClazz = "Simplify_" . $toClazz; + if ("stdClass" != $toClazz && class_exists("{$toClazz}", false)) { + $clazz = "{$toClazz}"; + } + $object = new $clazz(); + + foreach ($from as $key => $value) { + if (is_array($value) && count(array_keys($value))) { + $newClazz = "Simplify_" . ucfirst($key); + if (!class_exists($newClazz, false)) { + $newClazz = 'stdClass'; + } + + $object->$key = $this->convertFromHashToObject($value, $newClazz); + } else { + $object->$key = $value; + } + } + + return $object; + } + + /** + * @ignore + * + * @param string $publicKey + * @param string $action + * @param object $object + * + * @return string + */ + public function getUrl($publicKey, $action, $object) + { + $url = $this->fixUrl(Simplify::$apiBaseSandboxUrl); + if ($this->isLiveKey($publicKey)) { + $url = $this->fixUrl(Simplify::$apiBaseLiveUrl); + } + $url = $this->fixUrl($url) . urlencode(lcfirst($object->getClazz())) . '/'; + + $queryParams = array(); + if ($action == "show") { + $url .= urlencode($object->id); + } elseif ($action == "list") { + $queryParams = array_merge($queryParams, array('max' => $object->max, 'offset' => $object->offset)); + if (is_array($object->filter) && count(array_keys($object->filter))) { + foreach ($object->filter as $key => $value) { + $queryParams["filter[$key]"] = $value; + } + } + if (is_array($object->sorting) && count(array_keys($object->sorting))) { + foreach ($object->sorting as $key => $value) { + $queryParams["sorting[$key]"] = $value; + } + } + $query = http_build_query($queryParams); + if ($query != '') { + if (strpos($url, '?', strlen($url)) === false) $url .= '?'; + $url .= $query; + } + + } elseif ($action == "delete") { + $url .= urlencode($object->id); + } elseif ($action == "update") { + $url .= urlencode($object->id); + } elseif ($action == "create") { + } + return $url; + } + + /** + * @ignore + * + * @param string $action + * + * @return string + */ + public function getMethod($action) + { + if (array_key_exists(strtolower($action), self::$methodMap)) { + return self::$methodMap[strtolower($action)]; + } + return 'GET'; + } + + /** + * @ignore + * + * @param string $action + * @param object $object + * @param object $authentication + * + * @return mixed + */ + private function execute($action, $object, $authentication) + { + $http = new Simplify_HTTP(); + + return $http->apiRequest($this->getUrl($authentication->publicKey, $action, $object), $this->getMethod($action), + $authentication, json_encode($object->getProperties())); + } + + /** + * @ignore + * + * @param string $hash + * @param object $authentication + * + * @return mixed + */ + public function jwsDecode($hash, $authentication) + { + $http = new Simplify_HTTP(); + + $data = $http->jwsDecode($authentication, $hash); + + return json_decode($data, true); + } + + /** + * @ignore + * + * @param string $url + * + * @return string + */ + private function fixUrl($url) + { + if ($this->endsWith($url, '/')) { + return $url; + } + return $url . '/'; + } + + /** + * @ignore + * + * @param string $k + * + * @return bool + */ + private function isLiveKey($k) { + return strpos($k, "lvpb") === 0; + } + + /** + * @ignore + * + * @param string $s + * @param string $c + * + * @return bool + */ + private function endsWith($s, $c) + { + return substr($s, -strlen($c)) == $c; + } + + /** + * Helper function to build the Authentication object for backwards compatibility. + * An array of all the arguments passed to one of the API functions is checked against what + * we expect to received. If it's greater, then we're assuming that the user is using the older way of + * passing the keys. i.e as two separate strings. We take those two string and create the Authentication object + * + * @ignore + * @param $authentication + * @param $args + * @param $expectedArgCount + * @return Simplify_Authentication + */ + static function buildAuthenticationObject($authentication = null, $args, $expectedArgCount){ + + if(sizeof($args) > $expectedArgCount) { + $authentication = new Simplify_Authentication($args[$expectedArgCount-1], $args[$expectedArgCount]); + } + + if ($authentication == null){ + $authentication = new Simplify_Authentication(); + } + + // check that the keys have been set, if not use the global keys + if ( empty($authentication->publicKey)){ + $authentication->publicKey = Simplify::$publicKey; + } + if ( empty($authentication->privateKey)){ + $authentication->privateKey = Simplify::$privateKey; + } + + return $authentication; + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Plan.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Plan.php new file mode 100644 index 0000000..8f11103 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Plan.php @@ -0,0 +1,151 @@ + + *
      amount
      Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00USD required
      + *
      billingCycle
      How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
      + *
      billingCycleLimit
      The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
      + *
      currency
      Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] required
      + *
      frequency
      Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] required
      + *
      frequencyPeriod
      Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1, default: 1] required
      + *
      name
      Name of the plan [max length: 50, min length: 2] required
      + *
      renewalReminderLeadDays
      If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
      + *
      trialPeriod
      Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] required
      + *
      trialPeriodQuantity
      Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1]
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object. + */ + static public function createPlan($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Plan(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Plan object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deletePlan($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Plan objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated amount frequency name id.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Plan objects and the total + * number of Plan objects available for the given criteria. + * @see ResourceList + */ + static public function listPlan($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Plan(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Plan object from the API + * + * @param string id the id of the Plan object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object + */ + static public function findPlan($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Plan(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Plan object. + * + * The properties that can be updated: + *
      + *
      name
      Name of the plan. [min length: 2] required
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Plan a Plan object. + */ + public function updatePlan($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Plan"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Refund.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Refund.php new file mode 100644 index 0000000..46c22ec --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Refund.php @@ -0,0 +1,112 @@ + + *
      amount
      Amount of the refund in the smallest unit of your currency. Example: 100 = $1.00USD [min value: 1] required
      + *
      payment
      ID of the payment for the refund required
      + *
      reason
      Reason for the refund
      + *
      reference
      Custom reference field to be used with outside systems.
      + *
      replayId
      An identifier that can be sent to uniquely identify a refund request to facilitate retries due to I/O related issues. This identifier must be unique for your account (sandbox or live) across all of your refunds. If supplied, we will check for a refund on your account that matches this identifier. If found we will return an identical response to that of the original request. [max length: 50, min length: 1]
      + *
      statementDescription.name
      Merchant name. required
      + *
      statementDescription.phoneNumber
      Merchant contact phone number.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Refund a Refund object. + */ + static public function createRefund($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Refund(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + + /** + * Retrieve Simplify_Refund objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id amount description dateCreated paymentDate.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Refund objects and the total + * number of Refund objects available for the given criteria. + * @see ResourceList + */ + static public function listRefund($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Refund(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Refund object from the API + * + * @param string id the id of the Refund object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Refund a Refund object + */ + static public function findRefund($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Refund(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "Refund"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php new file mode 100644 index 0000000..7c31002 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/ResourceList.php @@ -0,0 +1,48 @@ +() methods. + */ +class Simplify_ResourceList { + + /** + * @var array $list the list of domain objects. + */ + public $list = array(); + + /** + * @var int $total the total number of object available. + */ + public $total = 0; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php new file mode 100644 index 0000000..91d3300 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Subscription.php @@ -0,0 +1,164 @@ + + *
      amount
      Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
      + *
      billingCycle
      How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
      + *
      billingCycleLimit
      The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
      + *
      coupon
      Coupon ID associated with the subscription
      + *
      currency
      Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
      + *
      customer
      Customer that is enrolling in the subscription.
      + *
      frequency
      Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
      + *
      frequencyPeriod
      Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
      + *
      name
      Name describing subscription
      + *
      plan
      The ID of the plan that should be used for the subscription.
      + *
      quantity
      Quantity of the plan for the subscription. [min value: 1]
      + *
      renewalReminderLeadDays
      If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object. + */ + static public function createSubscription($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Subscription(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Subscription object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteSubscription($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Subscription objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id plan.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Subscription objects and the total + * number of Subscription objects available for the given criteria. + * @see ResourceList + */ + static public function listSubscription($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Subscription(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Subscription object from the API + * + * @param string id the id of the Subscription object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object + */ + static public function findSubscription($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Subscription(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Subscription object. + * + * The properties that can be updated: + *
      + *
      amount
      Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00USD
      + *
      billingCycle
      How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
      + *
      billingCycleLimit
      The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
      + *
      coupon
      Coupon being assigned to this subscription
      + *
      currency
      Currency code (ISO-4217). Must match the currency associated with your account. [default: USD]
      + *
      frequency
      Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
      + *
      frequencyPeriod
      Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1]
      + *
      name
      Name describing subscription
      + *
      plan
      Plan that should be used for the subscription.
      + *
      prorate
      Whether to prorate existing subscription. [default: true] required
      + *
      quantity
      Quantity of the plan for the subscription. [min value: 1]
      + *
      renewalReminderLeadDays
      If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Subscription a Subscription object. + */ + public function updateSubscription($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Subscription"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Tax.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Tax.php new file mode 100644 index 0000000..0e504af --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Tax.php @@ -0,0 +1,124 @@ + + *
      label
      The label of the tax object. [max length: 255] required
      + *
      rate
      The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] required
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Tax a Tax object. + */ + static public function createTax($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Tax(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Tax object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteTax($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Tax objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: id label.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Tax objects and the total + * number of Tax objects available for the given criteria. + * @see ResourceList + */ + static public function listTax($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Tax(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Tax object from the API + * + * @param string id the id of the Tax object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Tax a Tax object + */ + static public function findTax($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Tax(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + /** + * @ignore + */ + public function getClazz() { + return "Tax"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php new file mode 100644 index 0000000..29cd218 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/TransactionReview.php @@ -0,0 +1,141 @@ + + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object. + */ + static public function createTransactionReview($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_TransactionReview(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_TransactionReview object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteTransactionReview($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_TransactionReview objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Allows for ascending or descending sorting of the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Filters to apply to the list. [min value: 0, default: 0]
      + *
      sorting
      Used in paging of the list. This is the start offset of the page. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated status.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of TransactionReview objects and the total + * number of TransactionReview objects available for the given criteria. + * @see ResourceList + */ + static public function listTransactionReview($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_TransactionReview(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_TransactionReview object from the API + * + * @param string id the id of the TransactionReview object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object + */ + static public function findTransactionReview($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_TransactionReview(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_TransactionReview object. + * + * The properties that can be updated: + *
      + *
      status
      Status of the transaction review.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return TransactionReview a TransactionReview object. + */ + public function updateTransactionReview($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "TransactionReview"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php new file mode 100644 index 0000000..efb80f4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php @@ -0,0 +1,142 @@ + + *
      url
      Endpoint URL required
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object. + */ + static public function createWebhook($hash, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $instance = new Simplify_Webhook(); + $instance->setAll($hash); + + $object = Simplify_PaymentsApi::createObject($instance, $authentication); + return $object; + } + + + /** + * Deletes an Simplify_Webhook object. + * + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * + * @return true + */ + public function deleteWebhook($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $obj = Simplify_PaymentsApi::deleteObject($this, $authentication); + $this->properties = null; + return true; + } + + + /** + * Retrieve Simplify_Webhook objects. + * @param array criteria a map of parameters; valid keys are:
      + *
      filter
      Filters to apply to the list.
      + *
      max
      Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
      + *
      offset
      Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
      + *
      sorting
      Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either asc for ascending or desc for descending). Sortable properties are: dateCreated.
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return ResourceList a ResourceList object that holds the list of Webhook objects and the total + * number of Webhook objects available for the given criteria. + * @see ResourceList + */ + static public function listWebhook($criteria = null, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Webhook(); + $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication); + + return $list; + } + + + /** + * Retrieve a Simplify_Webhook object from the API + * + * @param string id the id of the Webhook object to retrieve + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object + */ + static public function findWebhook($id, $authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2); + + $val = new Simplify_Webhook(); + $val->id = $id; + + $obj = Simplify_PaymentsApi::findObject($val, $authentication); + + return $obj; + } + + + /** + * Updates an Simplify_Webhook object. + * + * The properties that can be updated: + *
      + *
      url
      Endpoint URL required
      + * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object. + * @return Webhook a Webhook object. + */ + public function updateWebhook($authentication = null) { + + $args = func_get_args(); + $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1); + + $object = Simplify_PaymentsApi::updateObject($this, $authentication); + return $object; + } + + /** + * @ignore + */ + public function getClazz() { + return "Webhook"; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/import/abstract-wc-product-importer.php b/backend/wp-content/plugins/woocommerce/includes/import/abstract-wc-product-importer.php new file mode 100644 index 0000000..6eb0e56 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/import/abstract-wc-product-importer.php @@ -0,0 +1,781 @@ +raw_keys; + } + + /** + * Get file mapped headers. + * + * @return array + */ + public function get_mapped_keys() { + return ! empty( $this->mapped_keys ) ? $this->mapped_keys : $this->raw_keys; + } + + /** + * Get raw data. + * + * @return array + */ + public function get_raw_data() { + return $this->raw_data; + } + + /** + * Get parsed data. + * + * @return array + */ + public function get_parsed_data() { + return apply_filters( 'woocommerce_product_importer_parsed_data', $this->parsed_data, $this->get_raw_data() ); + } + + /** + * Get importer parameters. + * + * @return array + */ + public function get_params() { + return $this->params; + } + + /** + * Get file pointer position from the last read. + * + * @return int + */ + public function get_file_position() { + return $this->file_position; + } + + /** + * Get file pointer position as a percentage of file size. + * + * @return int + */ + public function get_percent_complete() { + $size = filesize( $this->file ); + if ( ! $size ) { + return 0; + } + + return absint( min( round( ( $this->file_position / $size ) * 100 ), 100 ) ); + } + + /** + * Prepare a single product for create or update. + * + * @param array $data Item data. + * @return WC_Product|WP_Error + */ + protected function get_product_object( $data ) { + $id = isset( $data['id'] ) ? absint( $data['id'] ) : 0; + + // Type is the most important part here because we need to be using the correct class and methods. + if ( isset( $data['type'] ) ) { + $types = array_keys( wc_get_product_types() ); + $types[] = 'variation'; + + if ( ! in_array( $data['type'], $types, true ) ) { + return new WP_Error( 'woocommerce_product_importer_invalid_type', __( 'Invalid product type.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + $classname = WC_Product_Factory::get_classname_from_product_type( $data['type'] ); + + if ( ! class_exists( $classname ) ) { + $classname = 'WC_Product_Simple'; + } + + $product = new $classname( $id ); + } elseif ( ! empty( $data['id'] ) ) { + $product = wc_get_product( $id ); + + if ( ! $product ) { + return new WP_Error( + 'woocommerce_product_csv_importer_invalid_id', + /* translators: %d: product ID */ + sprintf( __( 'Invalid product ID %d.', 'woocommerce' ), $id ), + array( + 'id' => $id, + 'status' => 401, + ) + ); + } + } else { + $product = new WC_Product_Simple( $id ); + } + + return apply_filters( 'woocommerce_product_import_get_product_object', $product, $data ); + } + + /** + * Process a single item and save. + * + * @throws Exception If item cannot be processed. + * @param array $data Raw CSV data. + * @return array|WC_Error + */ + protected function process_item( $data ) { + try { + do_action( 'woocommerce_product_import_before_process_item', $data ); + + // Get product ID from SKU if created during the importation. + if ( empty( $data['id'] ) && ! empty( $data['sku'] ) ) { + $product_id = wc_get_product_id_by_sku( $data['sku'] ); + + if ( $product_id ) { + $data['id'] = $product_id; + } + } + + $object = $this->get_product_object( $data ); + $updating = false; + + if ( is_wp_error( $object ) ) { + return $object; + } + + if ( $object->get_id() && 'importing' !== $object->get_status() ) { + $updating = true; + } + + if ( 'external' === $object->get_type() ) { + unset( $data['manage_stock'], $data['stock_status'], $data['backorders'] ); + } + + if ( 'importing' === $object->get_status() ) { + $object->set_status( 'publish' ); + $object->set_slug( '' ); + } + + $result = $object->set_props( array_diff_key( $data, array_flip( array( 'meta_data', 'raw_image_id', 'raw_gallery_image_ids', 'raw_attributes' ) ) ) ); + + if ( is_wp_error( $result ) ) { + throw new Exception( $result->get_error_message() ); + } + + if ( 'variation' === $object->get_type() ) { + $this->set_variation_data( $object, $data ); + } else { + $this->set_product_data( $object, $data ); + } + + $this->set_image_data( $object, $data ); + $this->set_meta_data( $object, $data ); + + $object = apply_filters( 'woocommerce_product_import_pre_insert_product_object', $object, $data ); + $object->save(); + + do_action( 'woocommerce_product_import_inserted_product_object', $object, $data ); + + return array( + 'id' => $object->get_id(), + 'updated' => $updating, + ); + } catch ( Exception $e ) { + return new WP_Error( 'woocommerce_product_importer_error', $e->getMessage(), array( 'status' => $e->getCode() ) ); + } + } + + /** + * Convert raw image URLs to IDs and set. + * + * @param WC_Product $product Product instance. + * @param array $data Item data. + */ + protected function set_image_data( &$product, $data ) { + // Image URLs need converting to IDs before inserting. + if ( isset( $data['raw_image_id'] ) ) { + $product->set_image_id( $this->get_attachment_id_from_url( $data['raw_image_id'], $product->get_id() ) ); + } + + // Gallery image URLs need converting to IDs before inserting. + if ( isset( $data['raw_gallery_image_ids'] ) ) { + $gallery_image_ids = array(); + + foreach ( $data['raw_gallery_image_ids'] as $image_id ) { + $gallery_image_ids[] = $this->get_attachment_id_from_url( $image_id, $product->get_id() ); + } + $product->set_gallery_image_ids( $gallery_image_ids ); + } + } + + /** + * Append meta data. + * + * @param WC_Product $product Product instance. + * @param array $data Item data. + */ + protected function set_meta_data( &$product, $data ) { + if ( isset( $data['meta_data'] ) ) { + foreach ( $data['meta_data'] as $meta ) { + $product->update_meta_data( $meta['key'], $meta['value'] ); + } + } + } + + /** + * Set product data. + * + * @param WC_Product $product Product instance. + * @param array $data Item data. + * @throws Exception If data cannot be set. + */ + protected function set_product_data( &$product, $data ) { + if ( isset( $data['raw_attributes'] ) ) { + $attributes = array(); + $default_attributes = array(); + $existing_attributes = $product->get_attributes(); + + foreach ( $data['raw_attributes'] as $position => $attribute ) { + $attribute_id = 0; + + // Get ID if is a global attribute. + if ( ! empty( $attribute['taxonomy'] ) ) { + $attribute_id = $this->get_attribute_taxonomy_id( $attribute['name'] ); + } + + // Set attribute visibility. + if ( isset( $attribute['visible'] ) ) { + $is_visible = $attribute['visible']; + } else { + $is_visible = 1; + } + + // Get name. + $attribute_name = $attribute_id ? wc_attribute_taxonomy_name_by_id( $attribute_id ) : $attribute['name']; + + // Set if is a variation attribute based on existing attributes if possible so updates via CSV do not change this. + $is_variation = 0; + + if ( $existing_attributes ) { + foreach ( $existing_attributes as $existing_attribute ) { + if ( $existing_attribute->get_name() === $attribute_name ) { + $is_variation = $existing_attribute->get_variation(); + break; + } + } + } + + if ( $attribute_id ) { + if ( isset( $attribute['value'] ) ) { + $options = array_map( 'wc_sanitize_term_text_based', $attribute['value'] ); + $options = array_filter( $options, 'strlen' ); + } else { + $options = array(); + } + + // Check for default attributes and set "is_variation". + if ( ! empty( $attribute['default'] ) && in_array( $attribute['default'], $options, true ) ) { + $default_term = get_term_by( 'name', $attribute['default'], $attribute_name ); + + if ( $default_term && ! is_wp_error( $default_term ) ) { + $default = $default_term->slug; + } else { + $default = sanitize_title( $attribute['default'] ); + } + + $default_attributes[ $attribute_name ] = $default; + $is_variation = 1; + } + + if ( ! empty( $options ) ) { + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_id( $attribute_id ); + $attribute_object->set_name( $attribute_name ); + $attribute_object->set_options( $options ); + $attribute_object->set_position( $position ); + $attribute_object->set_visible( $is_visible ); + $attribute_object->set_variation( $is_variation ); + $attributes[] = $attribute_object; + } + } elseif ( isset( $attribute['value'] ) ) { + // Check for default attributes and set "is_variation". + if ( ! empty( $attribute['default'] ) && in_array( $attribute['default'], $attribute['value'], true ) ) { + $default_attributes[ sanitize_title( $attribute['name'] ) ] = $attribute['default']; + $is_variation = 1; + } + + $attribute_object = new WC_Product_Attribute(); + $attribute_object->set_name( $attribute['name'] ); + $attribute_object->set_options( $attribute['value'] ); + $attribute_object->set_position( $position ); + $attribute_object->set_visible( $is_visible ); + $attribute_object->set_variation( $is_variation ); + $attributes[] = $attribute_object; + } + } + + $product->set_attributes( $attributes ); + + // Set variable default attributes. + if ( $product->is_type( 'variable' ) ) { + $product->set_default_attributes( $default_attributes ); + } + } + } + + /** + * Set variation data. + * + * @param WC_Product $variation Product instance. + * @param array $data Item data. + * @return WC_Product|WP_Error + * @throws Exception If data cannot be set. + */ + protected function set_variation_data( &$variation, $data ) { + $parent = false; + + // Check if parent exist. + if ( isset( $data['parent_id'] ) ) { + $parent = wc_get_product( $data['parent_id'] ); + + if ( $parent ) { + $variation->set_parent_id( $parent->get_id() ); + } + } + + // Stop if parent does not exists. + if ( ! $parent ) { + return new WP_Error( 'woocommerce_product_importer_missing_variation_parent_id', __( 'Variation cannot be imported: Missing parent ID or parent does not exist yet.', 'woocommerce' ), array( 'status' => 401 ) ); + } + + if ( isset( $data['raw_attributes'] ) ) { + $attributes = array(); + $parent_attributes = $this->get_variation_parent_attributes( $data['raw_attributes'], $parent ); + + foreach ( $data['raw_attributes'] as $attribute ) { + $attribute_id = 0; + + // Get ID if is a global attribute. + if ( ! empty( $attribute['taxonomy'] ) ) { + $attribute_id = $this->get_attribute_taxonomy_id( $attribute['name'] ); + } + + if ( $attribute_id ) { + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } else { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + if ( ! isset( $parent_attributes[ $attribute_name ] ) || ! $parent_attributes[ $attribute_name ]->get_variation() ) { + continue; + } + + $attribute_key = sanitize_title( $parent_attributes[ $attribute_name ]->get_name() ); + $attribute_value = isset( $attribute['value'] ) ? current( $attribute['value'] ) : ''; + + if ( $parent_attributes[ $attribute_name ]->is_taxonomy() ) { + // If dealing with a taxonomy, we need to get the slug from the name posted to the API. + $term = get_term_by( 'name', $attribute_value, $attribute_name ); + + if ( $term && ! is_wp_error( $term ) ) { + $attribute_value = $term->slug; + } else { + $attribute_value = sanitize_title( $attribute_value ); + } + } + + $attributes[ $attribute_key ] = $attribute_value; + } + + $variation->set_attributes( $attributes ); + } + } + + /** + * Get variation parent attributes and set "is_variation". + * + * @param array $attributes Attributes list. + * @param WC_Product $parent Parent product data. + * @return array + */ + protected function get_variation_parent_attributes( $attributes, $parent ) { + $parent_attributes = $parent->get_attributes(); + $require_save = false; + + foreach ( $attributes as $attribute ) { + $attribute_id = 0; + + // Get ID if is a global attribute. + if ( ! empty( $attribute['taxonomy'] ) ) { + $attribute_id = $this->get_attribute_taxonomy_id( $attribute['name'] ); + } + + if ( $attribute_id ) { + $attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id ); + } else { + $attribute_name = sanitize_title( $attribute['name'] ); + } + + // Check if attribute handle variations. + if ( isset( $parent_attributes[ $attribute_name ] ) && ! $parent_attributes[ $attribute_name ]->get_variation() ) { + // Re-create the attribute to CRUD save and generate again. + $parent_attributes[ $attribute_name ] = clone $parent_attributes[ $attribute_name ]; + $parent_attributes[ $attribute_name ]->set_variation( 1 ); + + $require_save = true; + } + } + + // Save variation attributes. + if ( $require_save ) { + $parent->set_attributes( array_values( $parent_attributes ) ); + $parent->save(); + } + + return $parent_attributes; + } + + /** + * Get attachment ID. + * + * @param string $url Attachment URL. + * @param int $product_id Product ID. + * @return int + * @throws Exception If attachment cannot be loaded. + */ + public function get_attachment_id_from_url( $url, $product_id ) { + if ( empty( $url ) ) { + return 0; + } + + $id = 0; + $upload_dir = wp_upload_dir( null, false ); + $base_url = $upload_dir['baseurl'] . '/'; + + // Check first if attachment is inside the WordPress uploads directory, or we're given a filename only. + if ( false !== strpos( $url, $base_url ) || false === strpos( $url, '://' ) ) { + // Search for yyyy/mm/slug.extension or slug.extension - remove the base URL. + $file = str_replace( $base_url, '', $url ); + $args = array( + 'post_type' => 'attachment', + 'post_status' => 'any', + 'fields' => 'ids', + 'meta_query' => array( // @codingStandardsIgnoreLine. + 'relation' => 'OR', + array( + 'key' => '_wp_attached_file', + 'value' => '^' . $file, + 'compare' => 'REGEXP', + ), + array( + 'key' => '_wp_attached_file', + 'value' => '/' . $file, + 'compare' => 'LIKE', + ), + array( + 'key' => '_wc_attachment_source', + 'value' => '/' . $file, + 'compare' => 'LIKE', + ), + ), + ); + } else { + // This is an external URL, so compare to source. + $args = array( + 'post_type' => 'attachment', + 'post_status' => 'any', + 'fields' => 'ids', + 'meta_query' => array( // @codingStandardsIgnoreLine. + array( + 'value' => $url, + 'key' => '_wc_attachment_source', + ), + ), + ); + } + + $ids = get_posts( $args ); // @codingStandardsIgnoreLine. + + if ( $ids ) { + $id = current( $ids ); + } + + // Upload if attachment does not exists. + if ( ! $id && stristr( $url, '://' ) ) { + $upload = wc_rest_upload_image_from_url( $url ); + + if ( is_wp_error( $upload ) ) { + throw new Exception( $upload->get_error_message(), 400 ); + } + + $id = wc_rest_set_uploaded_image_as_attachment( $upload, $product_id ); + + if ( ! wp_attachment_is_image( $id ) ) { + /* translators: %s: image URL */ + throw new Exception( sprintf( __( 'Not able to attach "%s".', 'woocommerce' ), $url ), 400 ); + } + + // Save attachment source for future reference. + update_post_meta( $id, '_wc_attachment_source', $url ); + } + + if ( ! $id ) { + /* translators: %s: image URL */ + throw new Exception( sprintf( __( 'Unable to use image "%s".', 'woocommerce' ), $url ), 400 ); + } + + return $id; + } + + /** + * Get attribute taxonomy ID from the imported data. + * If does not exists register a new attribute. + * + * @param string $raw_name Attribute name. + * @return int + * @throws Exception If taxonomy cannot be loaded. + */ + public function get_attribute_taxonomy_id( $raw_name ) { + global $wpdb, $wc_product_attributes; + + // These are exported as labels, so convert the label to a name if possible first. + $attribute_labels = wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name' ); + $attribute_name = array_search( $raw_name, $attribute_labels, true ); + + if ( ! $attribute_name ) { + $attribute_name = wc_sanitize_taxonomy_name( $raw_name ); + } + + $attribute_id = wc_attribute_taxonomy_id_by_name( $attribute_name ); + + // Get the ID from the name. + if ( $attribute_id ) { + return $attribute_id; + } + + // If the attribute does not exist, create it. + $attribute_id = wc_create_attribute( array( + 'name' => $raw_name, + 'slug' => $attribute_name, + 'type' => 'select', + 'order_by' => 'menu_order', + 'has_archives' => false, + ) ); + + if ( is_wp_error( $attribute_id ) ) { + throw new Exception( $attribute_id->get_error_message(), 400 ); + } + + // Register as taxonomy while importing. + $taxonomy_name = wc_attribute_taxonomy_name( $attribute_name ); + register_taxonomy( + $taxonomy_name, + apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ), + apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array( + 'labels' => array( + 'name' => $raw_name, + ), + 'hierarchical' => true, + 'show_ui' => false, + 'query_var' => true, + 'rewrite' => false, + ) ) + ); + + // Set product attributes global. + $wc_product_attributes = array(); + + foreach ( wc_get_attribute_taxonomies() as $taxonomy ) { + $wc_product_attributes[ wc_attribute_taxonomy_name( $taxonomy->attribute_name ) ] = $taxonomy; + } + + return $attribute_id; + } + + /** + * Memory exceeded + * + * Ensures the batch process never exceeds 90% + * of the maximum WordPress memory. + * + * @return bool + */ + protected function memory_exceeded() { + $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory + $current_memory = memory_get_usage( true ); + $return = false; + if ( $current_memory >= $memory_limit ) { + $return = true; + } + return apply_filters( 'woocommerce_product_importer_memory_exceeded', $return ); + } + + /** + * Get memory limit + * + * @return int + */ + protected function get_memory_limit() { + if ( function_exists( 'ini_get' ) ) { + $memory_limit = ini_get( 'memory_limit' ); + } else { + // Sensible default. + $memory_limit = '128M'; + } + + if ( ! $memory_limit || -1 === intval( $memory_limit ) ) { + // Unlimited, set to 32GB. + $memory_limit = '32000M'; + } + return intval( $memory_limit ) * 1024 * 1024; + } + + /** + * Time exceeded. + * + * Ensures the batch never exceeds a sensible time limit. + * A timeout limit of 30s is common on shared hosting. + * + * @return bool + */ + protected function time_exceeded() { + $finish = $this->start_time + apply_filters( 'woocommerce_product_importer_default_time_limit', 20 ); // 20 seconds + $return = false; + if ( time() >= $finish ) { + $return = true; + } + return apply_filters( 'woocommerce_product_importer_time_exceeded', $return ); + } + + /** + * Explode CSV cell values using commas by default, and handling escaped + * separators. + * + * @since 3.2.0 + * @param string $value Value to explode. + * @return array + */ + protected function explode_values( $value ) { + $value = str_replace( '\\,', '::separator::', $value ); + $values = explode( ',', $value ); + $values = array_map( array( $this, 'explode_values_formatter' ), $values ); + + return $values; + } + + /** + * Remove formatting and trim each value. + * + * @since 3.2.0 + * @param string $value Value to format. + * @return string + */ + protected function explode_values_formatter( $value ) { + return trim( str_replace( '::separator::', ',', $value ) ); + } + + /** + * The exporter prepends a ' to fields that start with a - which causes + * issues with negative numbers. This removes the ' if the input is still a valid + * number after removal. + * + * @since 3.3.0 + * @param string $value A numeric string that may or may not have ' prepended. + * @return string + */ + protected function unescape_negative_number( $value ) { + if ( 0 === strpos( $value, "'-" ) ) { + $unescaped = trim( $value, "'" ); + if ( is_numeric( $unescaped ) ) { + return $unescaped; + } + } + return $value; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/import/class-wc-product-csv-importer.php b/backend/wp-content/plugins/woocommerce/includes/import/class-wc-product-csv-importer.php new file mode 100644 index 0000000..ade2e75 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/import/class-wc-product-csv-importer.php @@ -0,0 +1,953 @@ + 0, // File pointer start. + 'end_pos' => -1, // File pointer end. + 'lines' => -1, // Max lines to read. + 'mapping' => array(), // Column mapping. csv_heading => schema_heading. + 'parse' => false, // Whether to sanitize and format data. + 'update_existing' => false, // Whether to update existing items. + 'delimiter' => ',', // CSV delimiter. + 'prevent_timeouts' => true, // Check memory and time usage and abort if reaching limit. + 'enclosure' => '"', // The character used to wrap text in the CSV. + 'escape' => "\0", // PHP uses '\' as the default escape character. This is not RFC-4180 compliant. This disables the escape character. + ); + + $this->params = wp_parse_args( $params, $default_args ); + $this->file = $file; + + if ( isset( $this->params['mapping']['from'], $this->params['mapping']['to'] ) ) { + $this->params['mapping'] = array_combine( $this->params['mapping']['from'], $this->params['mapping']['to'] ); + } + + $this->read_file(); + } + + /** + * Read file. + */ + protected function read_file() { + $handle = fopen( $this->file, 'r' ); // @codingStandardsIgnoreLine. + + if ( false !== $handle ) { + $this->raw_keys = version_compare( PHP_VERSION, '5.3', '>=' ) ? fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'], $this->params['escape'] ) : fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'] ); // @codingStandardsIgnoreLine + + // Remove BOM signature from the first item. + if ( isset( $this->raw_keys[0] ) ) { + $this->raw_keys[0] = $this->remove_utf8_bom( $this->raw_keys[0] ); + } + + if ( 0 !== $this->params['start_pos'] ) { + fseek( $handle, (int) $this->params['start_pos'] ); + } + + while ( 1 ) { + $row = version_compare( PHP_VERSION, '5.3', '>=' ) ? fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'], $this->params['escape'] ) : fgetcsv( $handle, 0, $this->params['delimiter'], $this->params['enclosure'] ); // @codingStandardsIgnoreLine + + if ( false !== $row ) { + $this->raw_data[] = $row; + $this->file_positions[ count( $this->raw_data ) ] = ftell( $handle ); + + if ( ( $this->params['end_pos'] > 0 && ftell( $handle ) >= $this->params['end_pos'] ) || 0 === --$this->params['lines'] ) { + break; + } + } else { + break; + } + } + + $this->file_position = ftell( $handle ); + } + + if ( ! empty( $this->params['mapping'] ) ) { + $this->set_mapped_keys(); + } + + if ( $this->params['parse'] ) { + $this->set_parsed_data(); + } + } + + /** + * Remove UTF-8 BOM signature. + * + * @param string $string String to handle. + * @return string + */ + protected function remove_utf8_bom( $string ) { + if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) { + $string = substr( $string, 3 ); + } + + return $string; + } + + /** + * Set file mapped keys. + */ + protected function set_mapped_keys() { + $mapping = $this->params['mapping']; + + foreach ( $this->raw_keys as $key ) { + $this->mapped_keys[] = isset( $mapping[ $key ] ) ? $mapping[ $key ] : $key; + } + } + + /** + * Parse relative field and return product ID. + * + * Handles `id:xx` and SKUs. + * + * If mapping to an id: and the product ID does not exist, this link is not + * valid. + * + * If mapping to a SKU and the product ID does not exist, a temporary object + * will be created so it can be updated later. + * + * @param string $value Field value. + * @return int|string + */ + public function parse_relative_field( $value ) { + global $wpdb; + + if ( empty( $value ) ) { + return ''; + } + + // IDs are prefixed with id:. + if ( preg_match( '/^id:(\d+)$/', $value, $matches ) ) { + $id = intval( $matches[1] ); + + // If original_id is found, use that instead of the given ID since a new placeholder must have been created already. + $original_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_original_id' AND meta_value = %s;", $id ) ); // WPCS: db call ok, cache ok. + + if ( $original_id ) { + return absint( $original_id ); + } + + // See if the given ID maps to a valid product allready. + $existing_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation' ) AND ID = %d;", $id ) ); // WPCS: db call ok, cache ok. + + if ( $existing_id ) { + return absint( $existing_id ); + } + + // If we're not updating existing posts, we may need a placeholder product to map to. + if ( ! $this->params['update_existing'] ) { + $product = new WC_Product_Simple(); + $product->set_name( 'Import placeholder for ' . $id ); + $product->set_status( 'importing' ); + $product->add_meta_data( '_original_id', $id, true ); + $id = $product->save(); + } + + return $id; + } + + $id = wc_get_product_id_by_sku( $value ); + + if ( $id ) { + return $id; + } + + try { + $product = new WC_Product_Simple(); + $product->set_name( 'Import placeholder for ' . $value ); + $product->set_status( 'importing' ); + $product->set_sku( $value ); + $id = $product->save(); + + if ( $id && ! is_wp_error( $id ) ) { + return $id; + } + } catch ( Exception $e ) { + return ''; + } + + return ''; + } + + /** + * Parse the ID field. + * + * If we're not doing an update, create a placeholder product so mapping works + * for rows following this one. + * + * @param string $value Field value. + * @return int + */ + public function parse_id_field( $value ) { + global $wpdb; + + $id = absint( $value ); + + if ( ! $id ) { + return 0; + } + + // See if this maps to an ID placeholder already. + $original_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_original_id' AND meta_value = %s;", $id ) ); // WPCS: db call ok, cache ok. + + if ( $original_id ) { + return absint( $original_id ); + } + + // Not updating? Make sure we have a new placeholder for this ID. + if ( ! $this->params['update_existing'] ) { + $mapped_keys = $this->get_mapped_keys(); + $sku_column_index = absint( array_search( 'sku', $mapped_keys, true ) ); + $row_sku = isset( $this->raw_data[ $this->parsing_raw_data_index ][ $sku_column_index ] ) ? $this->raw_data[ $this->parsing_raw_data_index ][ $sku_column_index ] : ''; + $id_from_sku = $row_sku ? wc_get_product_id_by_sku( $row_sku ) : ''; + + // If row has a SKU, make sure placeholder was not made already. + if ( $id_from_sku ) { + return $id_from_sku; + } + + $product = new WC_Product_Simple(); + $product->set_name( 'Import placeholder for ' . $id ); + $product->set_status( 'importing' ); + $product->add_meta_data( '_original_id', $id, true ); + + // If row has a SKU, make sure placeholder has it too. + if ( $row_sku ) { + $product->set_sku( $row_sku ); + } + $id = $product->save(); + } + + return $id && ! is_wp_error( $id ) ? $id : 0; + } + + /** + * Parse relative comma-delineated field and return product ID. + * + * @param string $value Field value. + * @return array + */ + public function parse_relative_comma_field( $value ) { + if ( empty( $value ) ) { + return array(); + } + + return array_filter( array_map( array( $this, 'parse_relative_field' ), $this->explode_values( $value ) ) ); + } + + /** + * Parse a comma-delineated field from a CSV. + * + * @param string $value Field value. + * @return array + */ + public function parse_comma_field( $value ) { + if ( empty( $value ) && '0' !== $value ) { + return array(); + } + + return array_map( 'wc_clean', $this->explode_values( $value ) ); + } + + /** + * Parse a field that is generally '1' or '0' but can be something else. + * + * @param string $value Field value. + * @return bool|string + */ + public function parse_bool_field( $value ) { + if ( '0' === $value ) { + return false; + } + + if ( '1' === $value ) { + return true; + } + + // Don't return explicit true or false for empty fields or values like 'notify'. + return wc_clean( $value ); + } + + /** + * Parse a float value field. + * + * @param string $value Field value. + * @return float|string + */ + public function parse_float_field( $value ) { + if ( '' === $value ) { + return $value; + } + + // Remove the ' prepended to fields that start with - if needed. + $value = $this->unescape_negative_number( $value ); + + return floatval( $value ); + } + + /** + * Parse the stock qty field. + * + * @param string $value Field value. + * @return float|string + */ + public function parse_stock_quantity_field( $value ) { + if ( '' === $value ) { + return $value; + } + + // Remove the ' prepended to fields that start with - if needed. + $value = $this->unescape_negative_number( $value ); + + return wc_stock_amount( $value ); + } + + /** + * Parse a category field from a CSV. + * Categories are separated by commas and subcategories are "parent > subcategory". + * + * @param string $value Field value. + * @return array of arrays with "parent" and "name" keys. + */ + public function parse_categories_field( $value ) { + if ( empty( $value ) ) { + return array(); + } + + $row_terms = $this->explode_values( $value ); + $categories = array(); + + foreach ( $row_terms as $row_term ) { + $parent = null; + $_terms = array_map( 'trim', explode( '>', $row_term ) ); + $total = count( $_terms ); + + foreach ( $_terms as $index => $_term ) { + // Check if category exists. Parent must be empty string or null if doesn't exists. + // @codingStandardsIgnoreStart + $term = term_exists( $_term, 'product_cat', $parent ); + // @codingStandardsIgnoreEnd + + if ( is_array( $term ) ) { + $term_id = $term['term_id']; + } else { + $term = wp_insert_term( $_term, 'product_cat', array( 'parent' => intval( $parent ) ) ); + + if ( is_wp_error( $term ) ) { + break; // We cannot continue if the term cannot be inserted. + } + + $term_id = $term['term_id']; + } + + // Only requires assign the last category. + if ( ( 1 + $index ) === $total ) { + $categories[] = $term_id; + } else { + // Store parent to be able to insert or query categories based in parent ID. + $parent = $term_id; + } + } + } + + return $categories; + } + + /** + * Parse a tag field from a CSV. + * + * @param string $value Field value. + * @return array + */ + public function parse_tags_field( $value ) { + if ( empty( $value ) ) { + return array(); + } + + $names = $this->explode_values( $value ); + $tags = array(); + + foreach ( $names as $name ) { + $term = get_term_by( 'name', $name, 'product_tag' ); + + if ( ! $term || is_wp_error( $term ) ) { + $term = (object) wp_insert_term( $name, 'product_tag' ); + } + + if ( ! is_wp_error( $term ) ) { + $tags[] = $term->term_id; + } + } + + return $tags; + } + + /** + * Parse a shipping class field from a CSV. + * + * @param string $value Field value. + * @return int + */ + public function parse_shipping_class_field( $value ) { + if ( empty( $value ) ) { + return 0; + } + + $term = get_term_by( 'name', $value, 'product_shipping_class' ); + + if ( ! $term || is_wp_error( $term ) ) { + $term = (object) wp_insert_term( $value, 'product_shipping_class' ); + } + + if ( is_wp_error( $term ) ) { + return 0; + } + + return $term->term_id; + } + + /** + * Parse images list from a CSV. Images can be filenames or URLs. + * + * @param string $value Field value. + * @return array + */ + public function parse_images_field( $value ) { + if ( empty( $value ) ) { + return array(); + } + + $images = array(); + + foreach ( $this->explode_values( $value ) as $image ) { + if ( stristr( $image, '://' ) ) { + $images[] = esc_url_raw( $image ); + } else { + $images[] = sanitize_file_name( $image ); + } + } + + return $images; + } + + /** + * Parse dates from a CSV. + * Dates requires the format YYYY-MM-DD and time is optional. + * + * @param string $value Field value. + * @return string|null + */ + public function parse_date_field( $value ) { + if ( empty( $value ) ) { + return null; + } + + if ( preg_match( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])([ 01-9:]*)$/', $value ) ) { + // Don't include the time if the field had time in it. + return current( explode( ' ', $value ) ); + } + + return null; + } + + /** + * Parse backorders from a CSV. + * + * @param string $value Field value. + * @return string + */ + public function parse_backorders_field( $value ) { + if ( empty( $value ) ) { + return 'no'; + } + + $value = $this->parse_bool_field( $value ); + + if ( 'notify' === $value ) { + return 'notify'; + } elseif ( is_bool( $value ) ) { + return $value ? 'yes' : 'no'; + } + + return 'no'; + } + + /** + * Just skip current field. + * + * By default is applied wc_clean() to all not listed fields + * in self::get_formating_callback(), use this method to skip any formating. + * + * @param string $value Field value. + * @return string + */ + public function parse_skip_field( $value ) { + return $value; + } + + /** + * Parse download file urls, we should allow shortcodes here. + * + * Allow shortcodes if present, othersiwe esc_url the value. + * + * @param string $value Field value. + * @return string + */ + public function parse_download_file_field( $value ) { + // Absolute file paths. + if ( 0 === strpos( $value, 'http' ) ) { + return esc_url_raw( $value ); + } + // Relative and shortcode paths. + return wc_clean( $value ); + } + + /** + * Parse an int value field + * + * @param int $value field value. + * @return int + */ + public function parse_int_field( $value ) { + // Remove the ' prepended to fields that start with - if needed. + $value = $this->unescape_negative_number( $value ); + + return intval( $value ); + } + + /** + * Get formatting callback. + * + * @return array + */ + protected function get_formating_callback() { + + /** + * Columns not mentioned here will get parsed with 'wc_clean'. + * column_name => callback. + */ + $data_formatting = array( + 'id' => array( $this, 'parse_id_field' ), + 'type' => array( $this, 'parse_comma_field' ), + 'published' => array( $this, 'parse_float_field' ), + 'featured' => array( $this, 'parse_bool_field' ), + 'date_on_sale_from' => array( $this, 'parse_date_field' ), + 'date_on_sale_to' => array( $this, 'parse_date_field' ), + 'name' => array( $this, 'parse_skip_field' ), + 'short_description' => array( $this, 'parse_skip_field' ), + 'description' => array( $this, 'parse_skip_field' ), + 'manage_stock' => array( $this, 'parse_bool_field' ), + 'backorders' => array( $this, 'parse_backorders_field' ), + 'stock_status' => array( $this, 'parse_bool_field' ), + 'sold_individually' => array( $this, 'parse_bool_field' ), + 'width' => array( $this, 'parse_float_field' ), + 'length' => array( $this, 'parse_float_field' ), + 'height' => array( $this, 'parse_float_field' ), + 'weight' => array( $this, 'parse_float_field' ), + 'reviews_allowed' => array( $this, 'parse_bool_field' ), + 'purchase_note' => 'wp_filter_post_kses', + 'price' => 'wc_format_decimal', + 'regular_price' => 'wc_format_decimal', + 'stock_quantity' => array( $this, 'parse_stock_quantity_field' ), + 'category_ids' => array( $this, 'parse_categories_field' ), + 'tag_ids' => array( $this, 'parse_tags_field' ), + 'shipping_class_id' => array( $this, 'parse_shipping_class_field' ), + 'images' => array( $this, 'parse_images_field' ), + 'parent_id' => array( $this, 'parse_relative_field' ), + 'grouped_products' => array( $this, 'parse_relative_comma_field' ), + 'upsell_ids' => array( $this, 'parse_relative_comma_field' ), + 'cross_sell_ids' => array( $this, 'parse_relative_comma_field' ), + 'download_limit' => array( $this, 'parse_int_field' ), + 'download_expiry' => array( $this, 'parse_int_field' ), + 'product_url' => 'esc_url_raw', + 'menu_order' => 'intval', + ); + + /** + * Match special column names. + */ + $regex_match_data_formatting = array( + '/attributes:value*/' => array( $this, 'parse_comma_field' ), + '/attributes:visible*/' => array( $this, 'parse_bool_field' ), + '/attributes:taxonomy*/' => array( $this, 'parse_bool_field' ), + '/downloads:url*/' => array( $this, 'parse_download_file_field' ), + '/meta:*/' => 'wp_kses_post', // Allow some HTML in meta fields. + ); + + $callbacks = array(); + + // Figure out the parse function for each column. + foreach ( $this->get_mapped_keys() as $index => $heading ) { + $callback = 'wc_clean'; + + if ( isset( $data_formatting[ $heading ] ) ) { + $callback = $data_formatting[ $heading ]; + } else { + foreach ( $regex_match_data_formatting as $regex => $callback ) { + if ( preg_match( $regex, $heading ) ) { + $callback = $callback; + break; + } + } + } + + $callbacks[] = $callback; + } + + return apply_filters( 'woocommerce_product_importer_formatting_callbacks', $callbacks, $this ); + } + + /** + * Check if strings starts with determined word. + * + * @param string $haystack Complete sentence. + * @param string $needle Excerpt. + * @return bool + */ + protected function starts_with( $haystack, $needle ) { + return substr( $haystack, 0, strlen( $needle ) ) === $needle; + } + + /** + * Expand special and internal data into the correct formats for the product CRUD. + * + * @param array $data Data to import. + * @return array + */ + protected function expand_data( $data ) { + $data = apply_filters( 'woocommerce_product_importer_pre_expand_data', $data ); + + // Images field maps to image and gallery id fields. + if ( isset( $data['images'] ) ) { + $images = $data['images']; + $data['raw_image_id'] = array_shift( $images ); + + if ( ! empty( $images ) ) { + $data['raw_gallery_image_ids'] = $images; + } + unset( $data['images'] ); + } + + // Type, virtual and downloadable are all stored in the same column. + if ( isset( $data['type'] ) ) { + $data['type'] = array_map( 'strtolower', $data['type'] ); + $data['virtual'] = in_array( 'virtual', $data['type'], true ); + $data['downloadable'] = in_array( 'downloadable', $data['type'], true ); + + // Convert type to string. + $data['type'] = current( array_diff( $data['type'], array( 'virtual', 'downloadable' ) ) ); + } + + // Status is mapped from a special published field. + if ( isset( $data['published'] ) ) { + $statuses = array( + -1 => 'draft', + 0 => 'private', + 1 => 'publish', + ); + $data['status'] = isset( $statuses[ $data['published'] ] ) ? $statuses[ $data['published'] ] : -1; + + unset( $data['published'] ); + } + + if ( isset( $data['stock_quantity'] ) ) { + if ( '' === $data['stock_quantity'] ) { + $data['manage_stock'] = false; + $data['stock_status'] = isset( $data['stock_status'] ) ? $data['stock_status'] : true; + } else { + $data['manage_stock'] = true; + } + } + + // Stock is bool or 'backorder'. + if ( isset( $data['stock_status'] ) ) { + if ( 'backorder' === $data['stock_status'] ) { + $data['stock_status'] = 'onbackorder'; + } else { + $data['stock_status'] = $data['stock_status'] ? 'instock' : 'outofstock'; + } + } + + // Prepare grouped products. + if ( isset( $data['grouped_products'] ) ) { + $data['children'] = $data['grouped_products']; + unset( $data['grouped_products'] ); + } + + // Handle special column names which span multiple columns. + $attributes = array(); + $downloads = array(); + $meta_data = array(); + + foreach ( $data as $key => $value ) { + if ( $this->starts_with( $key, 'attributes:name' ) ) { + if ( ! empty( $value ) ) { + $attributes[ str_replace( 'attributes:name', '', $key ) ]['name'] = $value; + } + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'attributes:value' ) ) { + $attributes[ str_replace( 'attributes:value', '', $key ) ]['value'] = $value; + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'attributes:taxonomy' ) ) { + $attributes[ str_replace( 'attributes:taxonomy', '', $key ) ]['taxonomy'] = wc_string_to_bool( $value ); + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'attributes:visible' ) ) { + $attributes[ str_replace( 'attributes:visible', '', $key ) ]['visible'] = wc_string_to_bool( $value ); + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'attributes:default' ) ) { + if ( ! empty( $value ) ) { + $attributes[ str_replace( 'attributes:default', '', $key ) ]['default'] = $value; + } + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'downloads:name' ) ) { + if ( ! empty( $value ) ) { + $downloads[ str_replace( 'downloads:name', '', $key ) ]['name'] = $value; + } + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'downloads:url' ) ) { + if ( ! empty( $value ) ) { + $downloads[ str_replace( 'downloads:url', '', $key ) ]['url'] = $value; + } + unset( $data[ $key ] ); + + } elseif ( $this->starts_with( $key, 'meta:' ) ) { + $meta_data[] = array( + 'key' => str_replace( 'meta:', '', $key ), + 'value' => $value, + ); + unset( $data[ $key ] ); + } + } + + if ( ! empty( $attributes ) ) { + // Remove empty attributes and clear indexes. + foreach ( $attributes as $attribute ) { + if ( empty( $attribute['name'] ) ) { + continue; + } + + $data['raw_attributes'][] = $attribute; + } + } + + if ( ! empty( $downloads ) ) { + $data['downloads'] = array(); + + foreach ( $downloads as $key => $file ) { + if ( empty( $file['url'] ) ) { + continue; + } + + $data['downloads'][] = array( + 'name' => $file['name'] ? $file['name'] : wc_get_filename_from_url( $file['url'] ), + 'file' => $file['url'], + ); + } + } + + if ( ! empty( $meta_data ) ) { + $data['meta_data'] = $meta_data; + } + + return $data; + } + + /** + * Map and format raw data to known fields. + */ + protected function set_parsed_data() { + $parse_functions = $this->get_formating_callback(); + $mapped_keys = $this->get_mapped_keys(); + $use_mb = function_exists( 'mb_convert_encoding' ); + + // Parse the data. + foreach ( $this->raw_data as $row_index => $row ) { + // Skip empty rows. + if ( ! count( array_filter( $row ) ) ) { + continue; + } + + $this->parsing_raw_data_index = $row_index; + + $data = array(); + + do_action( 'woocommerce_product_importer_before_set_parsed_data', $row, $mapped_keys ); + + foreach ( $row as $id => $value ) { + // Skip ignored columns. + if ( empty( $mapped_keys[ $id ] ) ) { + continue; + } + + // Convert UTF8. + if ( $use_mb ) { + $encoding = mb_detect_encoding( $value, mb_detect_order(), true ); + if ( $encoding ) { + $value = mb_convert_encoding( $value, 'UTF-8', $encoding ); + } else { + $value = mb_convert_encoding( $value, 'UTF-8', 'UTF-8' ); + } + } else { + $value = wp_check_invalid_utf8( $value, true ); + } + + $data[ $mapped_keys[ $id ] ] = call_user_func( $parse_functions[ $id ], $value ); + } + + $this->parsed_data[] = apply_filters( 'woocommerce_product_importer_parsed_data', $this->expand_data( $data ), $this ); + } + } + + /** + * Get a string to identify the row from parsed data. + * + * @param array $parsed_data Parsed data. + * @return string + */ + protected function get_row_id( $parsed_data ) { + $id = isset( $parsed_data['id'] ) ? absint( $parsed_data['id'] ) : 0; + $sku = isset( $parsed_data['sku'] ) ? esc_attr( $parsed_data['sku'] ) : ''; + $name = isset( $parsed_data['name'] ) ? esc_attr( $parsed_data['name'] ) : ''; + $row_data = array(); + + if ( $name ) { + $row_data[] = $name; + } + if ( $id ) { + /* translators: %d: product ID */ + $row_data[] = sprintf( __( 'ID %d', 'woocommerce' ), $id ); + } + if ( $sku ) { + /* translators: %s: product SKU */ + $row_data[] = sprintf( __( 'SKU %s', 'woocommerce' ), $sku ); + } + + return implode( ', ', $row_data ); + } + + /** + * Process importer. + * + * Do not import products with IDs or SKUs that already exist if option + * update existing is false, and likewise, if updating products, do not + * process rows which do not exist if an ID/SKU is provided. + * + * @return array + */ + public function import() { + $this->start_time = time(); + $index = 0; + $update_existing = $this->params['update_existing']; + $data = array( + 'imported' => array(), + 'failed' => array(), + 'updated' => array(), + 'skipped' => array(), + ); + + foreach ( $this->parsed_data as $parsed_data_key => $parsed_data ) { + do_action( 'woocommerce_product_import_before_import', $parsed_data ); + + $id = isset( $parsed_data['id'] ) ? absint( $parsed_data['id'] ) : 0; + $sku = isset( $parsed_data['sku'] ) ? esc_attr( $parsed_data['sku'] ) : ''; + $id_exists = false; + $sku_exists = false; + + if ( $id ) { + $product = wc_get_product( $id ); + $id_exists = $product && 'importing' !== $product->get_status(); + } + + if ( $sku ) { + $id_from_sku = wc_get_product_id_by_sku( $sku ); + $product = $id_from_sku ? wc_get_product( $id_from_sku ) : false; + $sku_exists = $product && 'importing' !== $product->get_status(); + } + + if ( $id_exists && ! $update_existing ) { + $data['skipped'][] = new WP_Error( 'woocommerce_product_importer_error', __( 'A product with this ID already exists.', 'woocommerce' ), array( + 'id' => $id, + 'row' => $this->get_row_id( $parsed_data ), + ) ); + continue; + } + + if ( $sku_exists && ! $update_existing ) { + $data['skipped'][] = new WP_Error( 'woocommerce_product_importer_error', __( 'A product with this SKU already exists.', 'woocommerce' ), array( + 'sku' => $sku, + 'row' => $this->get_row_id( $parsed_data ), + ) ); + continue; + } + + if ( $update_existing && ( $id || $sku ) && ! $id_exists && ! $sku_exists ) { + $data['skipped'][] = new WP_Error( 'woocommerce_product_importer_error', __( 'No matching product exists to update.', 'woocommerce' ), array( + 'id' => $id, + 'sku' => $sku, + 'row' => $this->get_row_id( $parsed_data ), + ) ); + continue; + } + + $result = $this->process_item( $parsed_data ); + + if ( is_wp_error( $result ) ) { + $result->add_data( array( 'row' => $this->get_row_id( $parsed_data ) ) ); + $data['failed'][] = $result; + } elseif ( $result['updated'] ) { + $data['updated'][] = $result['id']; + } else { + $data['imported'][] = $result['id']; + } + + $index ++; + + if ( $this->params['prevent_timeouts'] && ( $this->time_exceeded() || $this->memory_exceeded() ) ) { + $this->file_position = $this->file_positions[ $index ]; + break; + } + } + + return $data; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-abstract-order-data-store-interface.php b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-abstract-order-data-store-interface.php new file mode 100644 index 0000000..5688361 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-abstract-order-data-store-interface.php @@ -0,0 +1,54 @@ + [], 'failed' => []] + * + * @return array + */ + public function import(); + + /** + * Get file raw keys. + * + * CSV - Headers. + * XML - Element names. + * JSON - Keys + * + * @return array + */ + public function get_raw_keys(); + + /** + * Get file mapped headers. + * + * @return array + */ + public function get_mapped_keys(); + + /** + * Get raw data. + * + * @return array + */ + public function get_raw_data(); + + /** + * Get parsed data. + * + * @return array + */ + public function get_parsed_data(); + + /** + * Get file pointer position from the last read. + * + * @return int + */ + public function get_file_position(); + + /** + * Get file pointer position as a percentage of file size. + * + * @return int + */ + public function get_percent_complete(); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-log-handler-interface.php b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-log-handler-interface.php new file mode 100644 index 0000000..c8b3dd8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-log-handler-interface.php @@ -0,0 +1,33 @@ +id). + * @return array + */ + public function delete_meta( &$data, $meta ); + + /** + * Add new piece of meta. + * + * @param WC_Data $data Data object. + * @param object $meta Meta object (containing ->key and ->value). + * @return int meta ID + */ + public function add_meta( &$data, $meta ); + + /** + * Update meta. + * + * @param WC_Data $data Data object. + * @param object $meta Meta object (containing ->id, ->key and ->value). + */ + public function update_meta( &$data, $meta ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-data-store-interface.php b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-data-store-interface.php new file mode 100644 index 0000000..a49219e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-data-store-interface.php @@ -0,0 +1,141 @@ +get_id() will be set. + * + * @param WC_Order_Item $item Item object. + */ + public function save_item_data( &$item ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-refund-data-store-interface.php b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-refund-data-store-interface.php new file mode 100644 index 0000000..30961be --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-order-refund-data-store-interface.php @@ -0,0 +1,21 @@ +id, $return[0]->parent_id. + * + * @return array + */ + public function get_on_sale_products(); + + /** + * Returns a list of product IDs ( id as key => parent as value) that are + * featured. Uses get_posts instead of wc_get_products since we want + * some extra meta queries and ALL products (posts_per_page = -1). + * + * @return array + */ + public function get_featured_product_ids(); + + /** + * Check if product sku is found for any other product IDs. + * + * @param int $product_id Product ID. + * @param string $sku SKU. + * @return bool + */ + public function is_existing_sku( $product_id, $sku ); + + /** + * Return product ID based on SKU. + * + * @param string $sku SKU. + * @return int + */ + public function get_product_id_by_sku( $sku ); + + /** + * Returns an array of IDs of products that have sales starting soon. + * + * @return array + */ + public function get_starting_sales(); + + /** + * Returns an array of IDs of products that have sales which are due to end. + * + * @return array + */ + public function get_ending_sales(); + + /** + * Find a matching (enabled) variation within a variable product. + * + * @param WC_Product $product Variable product object. + * @param array $match_attributes Array of attributes we want to try to match. + * @return int Matching variation ID or 0. + */ + public function find_matching_product_variation( $product, $match_attributes = array() ); + + /** + * Make sure all variations have a sort order set so they can be reordered correctly. + * + * @param int $parent_id Parent ID. + */ + public function sort_all_product_variations( $parent_id ); + + /** + * Return a list of related products (using data like categories and IDs). + * + * @param array $cats_array List of categories IDs. + * @param array $tags_array List of tags IDs. + * @param array $exclude_ids Excluded IDs. + * @param int $limit Limit of results. + * @param int $product_id Product ID. + * @return array + */ + public function get_related_products( $cats_array, $tags_array, $exclude_ids, $limit, $product_id ); + + /** + * Update a product's stock amount directly. + * + * Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues). + * + * @param int $product_id_with_stock Product ID. + * @param int|null $stock_quantity Stock quantity to update to. + * @param string $operation Either set, increase or decrease. + */ + public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' ); + + /** + * Update a product's sale count directly. + * + * Uses queries rather than update_post_meta so we can do this in one query for performance. + * + * @param int $product_id Product ID. + * @param int|null $quantity Stock quantity to use for update. + * @param string $operation Either set, increase or decrease. + */ + public function update_product_sales( $product_id, $quantity = null, $operation = 'set' ); + + /** + * Get shipping class ID by slug. + * + * @param string $slug Shipping class slug. + * @return int|false + */ + public function get_shipping_class_id_by_slug( $slug ); + + /** + * Returns an array of products. + * + * @param array $args @see wc_get_products. + * @return array + */ + public function get_products( $args = array() ); + + /** + * Get the product type based on product ID. + * + * @param int $product_id Product ID. + * @return bool|string + */ + public function get_product_type( $product_id ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-product-variable-data-store-interface.php b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-product-variable-data-store-interface.php new file mode 100644 index 0000000..3a62ac8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/interfaces/class-wc-product-variable-data-store-interface.php @@ -0,0 +1,83 @@ +set_props( array( + 'code' => $code, + 'discount' => $discount, + 'discount_tax' => $discount_tax, + 'order_id' => $this->get_id(), + ) ); + $item->save(); + $this->add_item( $item ); + wc_do_deprecated_action( 'woocommerce_order_add_coupon', array( $this->get_id(), $item->get_id(), $code, $discount, $discount_tax ), '3.0', 'woocommerce_new_order_item action instead.' ); + return $item->get_id(); + } + + /** + * Add a tax row to the order. + * @param int $tax_rate_id + * @param int $tax_amount amount of tax. + * @param int $shipping_tax_amount shipping amount. + * @return int order item ID + * @throws WC_Data_Exception + */ + public function add_tax( $tax_rate_id, $tax_amount = 0, $shipping_tax_amount = 0 ) { + wc_deprecated_function( 'WC_Order::add_tax', '3.0', 'a new WC_Order_Item_Tax object and add to order with WC_Order::add_item()' ); + + $item = new WC_Order_Item_Tax(); + $item->set_props( array( + 'rate_id' => $tax_rate_id, + 'tax_total' => $tax_amount, + 'shipping_tax_total' => $shipping_tax_amount, + ) ); + $item->set_rate( $tax_rate_id ); + $item->set_order_id( $this->get_id() ); + $item->save(); + $this->add_item( $item ); + wc_do_deprecated_action( 'woocommerce_order_add_tax', array( $this->get_id(), $item->get_id(), $tax_rate_id, $tax_amount, $shipping_tax_amount ), '3.0', 'woocommerce_new_order_item action instead.' ); + return $item->get_id(); + } + + /** + * Add a shipping row to the order. + * @param WC_Shipping_Rate shipping_rate + * @return int order item ID + * @throws WC_Data_Exception + */ + public function add_shipping( $shipping_rate ) { + wc_deprecated_function( 'WC_Order::add_shipping', '3.0', 'a new WC_Order_Item_Shipping object and add to order with WC_Order::add_item()' ); + + $item = new WC_Order_Item_Shipping(); + $item->set_props( array( + 'method_title' => $shipping_rate->label, + 'method_id' => $shipping_rate->id, + 'total' => wc_format_decimal( $shipping_rate->cost ), + 'taxes' => $shipping_rate->taxes, + 'order_id' => $this->get_id(), + ) ); + foreach ( $shipping_rate->get_meta_data() as $key => $value ) { + $item->add_meta_data( $key, $value, true ); + } + $item->save(); + $this->add_item( $item ); + wc_do_deprecated_action( 'woocommerce_order_add_shipping', array( $this->get_id(), $item->get_id(), $shipping_rate ), '3.0', 'woocommerce_new_order_item action instead.' ); + return $item->get_id(); + } + + /** + * Add a fee to the order. + * Order must be saved prior to adding items. + * + * Fee is an amount of money charged for a particular piece of work + * or for a particular right or service, and not supposed to be negative. + * + * @throws WC_Data_Exception + * @param object $fee Fee data. + * @return int Updated order item ID. + */ + public function add_fee( $fee ) { + wc_deprecated_function( 'WC_Order::add_fee', '3.0', 'a new WC_Order_Item_Fee object and add to order with WC_Order::add_item()' ); + + $item = new WC_Order_Item_Fee(); + $item->set_props( array( + 'name' => $fee->name, + 'tax_class' => $fee->taxable ? $fee->tax_class : 0, + 'total' => $fee->amount, + 'total_tax' => $fee->tax, + 'taxes' => array( + 'total' => $fee->tax_data, + ), + 'order_id' => $this->get_id(), + ) ); + $item->save(); + $this->add_item( $item ); + wc_do_deprecated_action( 'woocommerce_order_add_fee', array( $this->get_id(), $item->get_id(), $fee ), '3.0', 'woocommerce_new_order_item action instead.' ); + return $item->get_id(); + } + + /** + * Update a line item for the order. + * + * Note this does not update order totals. + * + * @param object|int $item order item ID or item object. + * @param WC_Product $product + * @param array $args data to update. + * @return int updated order item ID + * @throws WC_Data_Exception + */ + public function update_product( $item, $product, $args ) { + wc_deprecated_function( 'WC_Order::update_product', '3.0', 'an interaction with the WC_Order_Item_Product class' ); + if ( is_numeric( $item ) ) { + $item = $this->get_item( $item ); + } + if ( ! is_object( $item ) || ! $item->is_type( 'line_item' ) ) { + return false; + } + if ( ! $this->get_id() ) { + $this->save(); // Order must exist + } + + // BW compatibility with old args + if ( isset( $args['totals'] ) ) { + foreach ( $args['totals'] as $key => $value ) { + if ( 'tax' === $key ) { + $args['total_tax'] = $value; + } elseif ( 'tax_data' === $key ) { + $args['taxes'] = $value; + } else { + $args[ $key ] = $value; + } + } + } + + // Handle qty if set. + if ( isset( $args['qty'] ) ) { + if ( $product->backorders_require_notification() && $product->is_on_backorder( $args['qty'] ) ) { + $item->add_meta_data( apply_filters( 'woocommerce_backordered_item_meta_name', __( 'Backordered', 'woocommerce' ), $item ), $args['qty'] - max( 0, $product->get_stock_quantity() ), true ); + } + $args['subtotal'] = $args['subtotal'] ? $args['subtotal'] : wc_get_price_excluding_tax( $product, array( 'qty' => $args['qty'] ) ); + $args['total'] = $args['total'] ? $args['total'] : wc_get_price_excluding_tax( $product, array( 'qty' => $args['qty'] ) ); + } + + $item->set_order_id( $this->get_id() ); + $item->set_props( $args ); + $item->save(); + do_action( 'woocommerce_order_edit_product', $this->get_id(), $item->get_id(), $args, $product ); + + return $item->get_id(); + } + + /** + * Update coupon for order. Note this does not update order totals. + * @param object|int $item + * @param array $args + * @return int updated order item ID + * @throws WC_Data_Exception + */ + public function update_coupon( $item, $args ) { + wc_deprecated_function( 'WC_Order::update_coupon', '3.0', 'an interaction with the WC_Order_Item_Coupon class' ); + if ( is_numeric( $item ) ) { + $item = $this->get_item( $item ); + } + if ( ! is_object( $item ) || ! $item->is_type( 'coupon' ) ) { + return false; + } + if ( ! $this->get_id() ) { + $this->save(); // Order must exist + } + + // BW compatibility for old args + if ( isset( $args['discount_amount'] ) ) { + $args['discount'] = $args['discount_amount']; + } + if ( isset( $args['discount_amount_tax'] ) ) { + $args['discount_tax'] = $args['discount_amount_tax']; + } + + $item->set_order_id( $this->get_id() ); + $item->set_props( $args ); + $item->save(); + + do_action( 'woocommerce_order_update_coupon', $this->get_id(), $item->get_id(), $args ); + + return $item->get_id(); + } + + /** + * Update shipping method for order. + * + * Note this does not update the order total. + * + * @param object|int $item + * @param array $args + * @return int updated order item ID + * @throws WC_Data_Exception + */ + public function update_shipping( $item, $args ) { + wc_deprecated_function( 'WC_Order::update_shipping', '3.0', 'an interaction with the WC_Order_Item_Shipping class' ); + if ( is_numeric( $item ) ) { + $item = $this->get_item( $item ); + } + if ( ! is_object( $item ) || ! $item->is_type( 'shipping' ) ) { + return false; + } + if ( ! $this->get_id() ) { + $this->save(); // Order must exist + } + + // BW compatibility for old args + if ( isset( $args['cost'] ) ) { + $args['total'] = $args['cost']; + } + + $item->set_order_id( $this->get_id() ); + $item->set_props( $args ); + $item->save(); + $this->calculate_shipping(); + + do_action( 'woocommerce_order_update_shipping', $this->get_id(), $item->get_id(), $args ); + + return $item->get_id(); + } + + /** + * Update fee for order. + * + * Note this does not update order totals. + * + * @param object|int $item + * @param array $args + * @return int updated order item ID + * @throws WC_Data_Exception + */ + public function update_fee( $item, $args ) { + wc_deprecated_function( 'WC_Order::update_fee', '3.0', 'an interaction with the WC_Order_Item_Fee class' ); + if ( is_numeric( $item ) ) { + $item = $this->get_item( $item ); + } + if ( ! is_object( $item ) || ! $item->is_type( 'fee' ) ) { + return false; + } + if ( ! $this->get_id() ) { + $this->save(); // Order must exist + } + + $item->set_order_id( $this->get_id() ); + $item->set_props( $args ); + $item->save(); + + do_action( 'woocommerce_order_update_fee', $this->get_id(), $item->get_id(), $args ); + + return $item->get_id(); + } + + /** + * Update tax line on order. + * Note this does not update order totals. + * + * @since 3.0 + * @param object|int $item + * @param array $args + * @return int updated order item ID + * @throws WC_Data_Exception + */ + public function update_tax( $item, $args ) { + wc_deprecated_function( 'WC_Order::update_tax', '3.0', 'an interaction with the WC_Order_Item_Tax class' ); + if ( is_numeric( $item ) ) { + $item = $this->get_item( $item ); + } + if ( ! is_object( $item ) || ! $item->is_type( 'tax' ) ) { + return false; + } + if ( ! $this->get_id() ) { + $this->save(); // Order must exist + } + + $item->set_order_id( $this->get_id() ); + $item->set_props( $args ); + $item->save(); + + do_action( 'woocommerce_order_update_tax', $this->get_id(), $item->get_id(), $args ); + + return $item->get_id(); + } + + /** + * Get a product (either product or variation). + * @deprecated Add deprecation notices in future release. Replaced with $item->get_product() + * @param object $item + * @return WC_Product|bool + */ + public function get_product_from_item( $item ) { + if ( is_callable( array( $item, 'get_product' ) ) ) { + $product = $item->get_product(); + } else { + $product = false; + } + return apply_filters( 'woocommerce_get_product_from_item', $product, $item, $this ); + } + + /** + * Set the customer address. + * @param array $address Address data. + * @param string $type billing or shipping. + */ + public function set_address( $address, $type = 'billing' ) { + foreach ( $address as $key => $value ) { + update_post_meta( $this->get_id(), "_{$type}_" . $key, $value ); + if ( is_callable( array( $this, "set_{$type}_{$key}" ) ) ) { + $this->{"set_{$type}_{$key}"}( $value ); + } + } + } + + /** + * Set an order total. + * @param float $amount + * @param string $total_type + * @return bool + */ + public function legacy_set_total( $amount, $total_type = 'total' ) { + if ( ! in_array( $total_type, array( 'shipping', 'tax', 'shipping_tax', 'total', 'cart_discount', 'cart_discount_tax' ) ) ) { + return false; + } + + switch ( $total_type ) { + case 'total' : + $amount = wc_format_decimal( $amount, wc_get_price_decimals() ); + $this->set_total( $amount ); + update_post_meta( $this->get_id(), '_order_total', $amount ); + break; + case 'cart_discount' : + $amount = wc_format_decimal( $amount ); + $this->set_discount_total( $amount ); + update_post_meta( $this->get_id(), '_cart_discount', $amount ); + break; + case 'cart_discount_tax' : + $amount = wc_format_decimal( $amount ); + $this->set_discount_tax( $amount ); + update_post_meta( $this->get_id(), '_cart_discount_tax', $amount ); + break; + case 'shipping' : + $amount = wc_format_decimal( $amount ); + $this->set_shipping_total( $amount ); + update_post_meta( $this->get_id(), '_order_shipping', $amount ); + break; + case 'shipping_tax' : + $amount = wc_format_decimal( $amount ); + $this->set_shipping_tax( $amount ); + update_post_meta( $this->get_id(), '_order_shipping_tax', $amount ); + break; + case 'tax' : + $amount = wc_format_decimal( $amount ); + $this->set_cart_tax( $amount ); + update_post_meta( $this->get_id(), '_order_tax', $amount ); + break; + } + + return true; + } + + /** + * Magic __isset method for backwards compatibility. Handles legacy properties which could be accessed directly in the past. + * + * @param string $key + * @return bool + */ + public function __isset( $key ) { + $legacy_props = array( 'completed_date', 'id', 'order_type', 'post', 'status', 'post_status', 'customer_note', 'customer_message', 'user_id', 'customer_user', 'prices_include_tax', 'tax_display_cart', 'display_totals_ex_tax', 'display_cart_ex_tax', 'order_date', 'modified_date', 'cart_discount', 'cart_discount_tax', 'order_shipping', 'order_shipping_tax', 'order_total', 'order_tax', 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_address_1', 'billing_address_2', 'billing_city', 'billing_state', 'billing_postcode', 'billing_country', 'billing_phone', 'billing_email', 'shipping_first_name', 'shipping_last_name', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode', 'shipping_country', 'customer_ip_address', 'customer_user_agent', 'payment_method_title', 'payment_method', 'order_currency' ); + return $this->get_id() ? ( in_array( $key, $legacy_props ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) ) : false; + } + + /** + * Magic __get method for backwards compatibility. + * + * @param string $key + * @return mixed + */ + public function __get( $key ) { + wc_doing_it_wrong( $key, 'Order properties should not be accessed directly.', '3.0' ); + + if ( 'completed_date' === $key ) { + return $this->get_date_completed() ? gmdate( 'Y-m-d H:i:s', $this->get_date_completed()->getOffsetTimestamp() ) : ''; + } elseif ( 'paid_date' === $key ) { + return $this->get_date_paid() ? gmdate( 'Y-m-d H:i:s', $this->get_date_paid()->getOffsetTimestamp() ) : ''; + } elseif ( 'modified_date' === $key ) { + return $this->get_date_modified() ? gmdate( 'Y-m-d H:i:s', $this->get_date_modified()->getOffsetTimestamp() ) : ''; + } elseif ( 'order_date' === $key ) { + return $this->get_date_created() ? gmdate( 'Y-m-d H:i:s', $this->get_date_created()->getOffsetTimestamp() ) : ''; + } elseif ( 'id' === $key ) { + return $this->get_id(); + } elseif ( 'post' === $key ) { + return get_post( $this->get_id() ); + } elseif ( 'status' === $key ) { + return $this->get_status(); + } elseif ( 'post_status' === $key ) { + return get_post_status( $this->get_id() ); + } elseif ( 'customer_message' === $key || 'customer_note' === $key ) { + return $this->get_customer_note(); + } elseif ( in_array( $key, array( 'user_id', 'customer_user' ) ) ) { + return $this->get_customer_id(); + } elseif ( 'tax_display_cart' === $key ) { + return get_option( 'woocommerce_tax_display_cart' ); + } elseif ( 'display_totals_ex_tax' === $key ) { + return 'excl' === get_option( 'woocommerce_tax_display_cart' ); + } elseif ( 'display_cart_ex_tax' === $key ) { + return 'excl' === get_option( 'woocommerce_tax_display_cart' ); + } elseif ( 'cart_discount' === $key ) { + return $this->get_total_discount(); + } elseif ( 'cart_discount_tax' === $key ) { + return $this->get_discount_tax(); + } elseif ( 'order_tax' === $key ) { + return $this->get_cart_tax(); + } elseif ( 'order_shipping_tax' === $key ) { + return $this->get_shipping_tax(); + } elseif ( 'order_shipping' === $key ) { + return $this->get_shipping_total(); + } elseif ( 'order_total' === $key ) { + return $this->get_total(); + } elseif ( 'order_type' === $key ) { + return $this->get_type(); + } elseif ( 'order_currency' === $key ) { + return $this->get_currency(); + } elseif ( 'order_version' === $key ) { + return $this->get_version(); + } elseif ( is_callable( array( $this, "get_{$key}" ) ) ) { + return $this->{"get_{$key}"}(); + } else { + return get_post_meta( $this->get_id(), '_' . $key, true ); + } + } + + /** + * has_meta function for order items. This is different to the WC_Data + * version and should be removed in future versions. + * + * @deprecated + * + * @param int $order_item_id + * + * @return array of meta data. + */ + public function has_meta( $order_item_id ) { + global $wpdb; + + wc_deprecated_function( 'WC_Order::has_meta( $order_item_id )', '3.0', 'WC_Order_item::get_meta_data' ); + + return $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value, meta_id, order_item_id + FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d + ORDER BY meta_id", absint( $order_item_id ) ), ARRAY_A ); + } + + /** + * Display meta data belonging to an item. + * @param array $item + */ + public function display_item_meta( $item ) { + wc_deprecated_function( 'WC_Order::display_item_meta', '3.0', 'wc_display_item_meta' ); + $product = $item->get_product(); + $item_meta = new WC_Order_Item_Meta( $item, $product ); + $item_meta->display(); + } + + /** + * Display download links for an order item. + * @param array $item + */ + public function display_item_downloads( $item ) { + wc_deprecated_function( 'WC_Order::display_item_downloads', '3.0', 'wc_display_item_downloads' ); + $product = $item->get_product(); + + if ( $product && $product->exists() && $product->is_downloadable() && $this->is_download_permitted() ) { + $download_files = $this->get_item_downloads( $item ); + $i = 0; + $links = array(); + + foreach ( $download_files as $download_id => $file ) { + $i++; + /* translators: 1: current item count */ + $prefix = count( $download_files ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' ); + $links[] = '' . $prefix . ': ' . esc_html( $file['name'] ) . '' . "\n"; + } + + echo '
      ' . implode( '
      ', $links ); + } + } + + /** + * Get the Download URL. + * + * @param int $product_id + * @param int $download_id + * @return string + */ + public function get_download_url( $product_id, $download_id ) { + wc_deprecated_function( 'WC_Order::get_download_url', '3.0', 'WC_Order_Item_Product::get_item_download_url' ); + return add_query_arg( array( + 'download_file' => $product_id, + 'order' => $this->get_order_key(), + 'email' => urlencode( $this->get_billing_email() ), + 'key' => $download_id, + ), trailingslashit( home_url() ) ); + } + + /** + * Get the downloadable files for an item in this order. + * + * @param array $item + * @return array + */ + public function get_item_downloads( $item ) { + wc_deprecated_function( 'WC_Order::get_item_downloads', '3.0', 'WC_Order_Item_Product::get_item_downloads' ); + + if ( ! $item instanceof WC_Order_Item ) { + if ( ! empty( $item['variation_id'] ) ) { + $product_id = $item['variation_id']; + } elseif ( ! empty( $item['product_id'] ) ) { + $product_id = $item['product_id']; + } else { + return array(); + } + + // Create a 'virtual' order item to allow retrieving item downloads when + // an array of product_id is passed instead of actual order item. + $item = new WC_Order_Item_Product(); + $item->set_product( wc_get_product( $product_id ) ); + $item->set_order_id( $this->get_id() ); + } + + return $item->get_item_downloads(); + } + + /** + * Gets shipping total. Alias of WC_Order::get_shipping_total(). + * @deprecated 3.0.0 since this is an alias only. + * @return float + */ + public function get_total_shipping() { + return $this->get_shipping_total(); + } + + /** + * Get order item meta. + * @deprecated 3.0.0 + * @param mixed $order_item_id + * @param string $key (default: '') + * @param bool $single (default: false) + * @return array|string + */ + public function get_item_meta( $order_item_id, $key = '', $single = false ) { + wc_deprecated_function( 'WC_Order::get_item_meta', '3.0', 'wc_get_order_item_meta' ); + return get_metadata( 'order_item', $order_item_id, $key, $single ); + } + + /** + * Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta(). + * + * @param mixed $order_item_id + * @return array of objects + */ + public function get_item_meta_array( $order_item_id ) { + wc_deprecated_function( 'WC_Order::get_item_meta_array', '3.0', 'WC_Order_Item::get_meta_data() (note the format has changed)' ); + $item = $this->get_item( $order_item_id ); + $meta_data = $item->get_meta_data(); + $item_meta_array = array(); + + foreach ( $meta_data as $meta ) { + $item_meta_array[ $meta->id ] = $meta; + } + + return $item_meta_array; + } + + /** + * Expand item meta into the $item array. + * @deprecated 3.0.0 Item meta no longer expanded due to new order item + * classes. This function now does nothing to avoid data breakage. + * @param array $item before expansion. + * @return array + */ + public function expand_item_meta( $item ) { + wc_deprecated_function( 'WC_Order::expand_item_meta', '3.0' ); + return $item; + } + + /** + * Load the order object. Called from the constructor. + * @deprecated 3.0.0 Logic moved to constructor + * @param int|object|WC_Order $order Order to init. + */ + protected function init( $order ) { + wc_deprecated_function( 'WC_Order::init', '3.0', 'Logic moved to constructor' ); + if ( is_numeric( $order ) ) { + $this->set_id( $order ); + } elseif ( $order instanceof WC_Order ) { + $this->set_id( absint( $order->get_id() ) ); + } elseif ( isset( $order->ID ) ) { + $this->set_id( absint( $order->ID ) ); + } + $this->set_object_read( false ); + $this->data_store->read( $this ); + } + + /** + * Gets an order from the database. + * @deprecated 3.0 + * @param int $id (default: 0). + * @return bool + */ + public function get_order( $id = 0 ) { + wc_deprecated_function( 'WC_Order::get_order', '3.0' ); + + if ( ! $id ) { + return false; + } + + $result = get_post( $id ); + + if ( $result ) { + $this->populate( $result ); + return true; + } + + return false; + } + + /** + * Populates an order from the loaded post data. + * @deprecated 3.0 + * @param mixed $result + */ + public function populate( $result ) { + wc_deprecated_function( 'WC_Order::populate', '3.0' ); + $this->set_id( $result->ID ); + $this->set_object_read( false ); + $this->data_store->read( $this ); + } + + /** + * Cancel the order and restore the cart (before payment). + * @deprecated 3.0.0 Moved to event handler. + * @param string $note (default: '') Optional note to add. + */ + public function cancel_order( $note = '' ) { + wc_deprecated_function( 'WC_Order::cancel_order', '3.0', 'WC_Order::update_status' ); + WC()->session->set( 'order_awaiting_payment', false ); + $this->update_status( 'cancelled', $note ); + } + + /** + * Record sales. + * @deprecated 3.0.0 + */ + public function record_product_sales() { + wc_deprecated_function( 'WC_Order::record_product_sales', '3.0', 'wc_update_total_sales_counts' ); + wc_update_total_sales_counts( $this->get_id() ); + } + + /** + * Increase applied coupon counts. + * @deprecated 3.0.0 + */ + public function increase_coupon_usage_counts() { + wc_deprecated_function( 'WC_Order::increase_coupon_usage_counts', '3.0', 'wc_update_coupon_usage_counts' ); + wc_update_coupon_usage_counts( $this->get_id() ); + } + + /** + * Decrease applied coupon counts. + * @deprecated 3.0.0 + */ + public function decrease_coupon_usage_counts() { + wc_deprecated_function( 'WC_Order::decrease_coupon_usage_counts', '3.0', 'wc_update_coupon_usage_counts' ); + wc_update_coupon_usage_counts( $this->get_id() ); + } + + /** + * Reduce stock levels for all line items in the order. + * @deprecated 3.0.0 + */ + public function reduce_order_stock() { + wc_deprecated_function( 'WC_Order::reduce_order_stock', '3.0', 'wc_reduce_stock_levels' ); + wc_reduce_stock_levels( $this->get_id() ); + } + + /** + * Send the stock notifications. + * @deprecated 3.0.0 No longer needs to be called directly. + * + * @param $product + * @param $new_stock + * @param $qty_ordered + */ + public function send_stock_notifications( $product, $new_stock, $qty_ordered ) { + wc_deprecated_function( 'WC_Order::send_stock_notifications', '3.0' ); + } + + /** + * Output items for display in html emails. + * @deprecated 3.0.0 Moved to template functions. + * @param array $args Items args. + * @return string + */ + public function email_order_items_table( $args = array() ) { + wc_deprecated_function( 'WC_Order::email_order_items_table', '3.0', 'wc_get_email_order_items' ); + return wc_get_email_order_items( $this, $args ); + } + + /** + * Get currency. + * @deprecated 3.0.0 + */ + public function get_order_currency() { + wc_deprecated_function( 'WC_Order::get_order_currency', '3.0', 'WC_Order::get_currency' ); + return apply_filters( 'woocommerce_get_order_currency', $this->get_currency(), $this ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-payment-token.php b/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-payment-token.php new file mode 100644 index 0000000..d1316d1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-payment-token.php @@ -0,0 +1,70 @@ +read, ->update or ->create + * directly on the object. + * + * @version 3.0.0 + * @package WooCommerce/Classes + * @category Class + * @author WooCommerce + */ +abstract class WC_Legacy_Payment_Token extends WC_Data { + + /** + * Sets the type of this payment token (CC, eCheck, or something else). + * + * @param string Payment Token Type (CC, eCheck) + */ + public function set_type( $type ) { + wc_deprecated_function( 'WC_Payment_Token::set_type', '3.0.0', 'Type cannot be overwritten.' ); + } + + /** + * Read a token by ID. + * @deprecated 3.0.0 - Init a token class with an ID. + * + * @param int $token_id + */ + public function read( $token_id ) { + wc_deprecated_function( 'WC_Payment_Token::read', '3.0.0', 'a new token class initialized with an ID.' ); + $this->set_id( $token_id ); + $data_store = WC_Data_Store::load( 'payment-token' ); + $data_store->read( $this ); + } + + /** + * Update a token. + * @deprecated 3.0.0 - Use ::save instead. + */ + public function update() { + wc_deprecated_function( 'WC_Payment_Token::update', '3.0.0', 'WC_Payment_Token::save instead.' ); + $data_store = WC_Data_Store::load( 'payment-token' ); + try { + $data_store->update( $this ); + } catch ( Exception $e ) { + return false; + } + } + + /** + * Create a token. + * @deprecated 3.0.0 - Use ::save instead. + */ + public function create() { + wc_deprecated_function( 'WC_Payment_Token::create', '3.0.0', 'WC_Payment_Token::save instead.' ); + $data_store = WC_Data_Store::load( 'payment-token' ); + try { + $data_store->create( $this ); + } catch ( Exception $e ) { + return false; + } + } + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-product.php b/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-product.php new file mode 100644 index 0000000..15b7ba0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/abstract-wc-legacy-product.php @@ -0,0 +1,689 @@ +is_type( 'variation' ) ) { + $valid = array_merge( $valid, array( + 'variation_id', + 'variation_data', + 'variation_has_stock', + 'variation_shipping_class_id', + 'variation_has_sku', + 'variation_has_length', + 'variation_has_width', + 'variation_has_height', + 'variation_has_weight', + 'variation_has_tax_class', + 'variation_has_downloadable_files', + ) ); + } + return in_array( $key, array_merge( $valid, array_keys( $this->data ) ) ) || metadata_exists( 'post', $this->get_id(), '_' . $key ) || metadata_exists( 'post', $this->get_parent_id(), '_' . $key ); + } + + /** + * Magic __get method for backwards compatibility. Maps legacy vars to new getters. + * + * @param string $key Key name. + * @return mixed + */ + public function __get( $key ) { + + if ( 'post_type' === $key ) { + return $this->post_type; + } + + wc_doing_it_wrong( $key, __( 'Product properties should not be accessed directly.', 'woocommerce' ), '3.0' ); + + switch ( $key ) { + case 'id' : + $value = $this->is_type( 'variation' ) ? $this->get_parent_id() : $this->get_id(); + break; + case 'product_type' : + $value = $this->get_type(); + break; + case 'product_attributes' : + $value = isset( $this->data['attributes'] ) ? $this->data['attributes'] : ''; + break; + case 'visibility' : + $value = $this->get_catalog_visibility(); + break; + case 'sale_price_dates_from' : + return $this->get_date_on_sale_from() ? $this->get_date_on_sale_from()->getTimestamp() : ''; + break; + case 'sale_price_dates_to' : + return $this->get_date_on_sale_to() ? $this->get_date_on_sale_to()->getTimestamp() : ''; + break; + case 'post' : + $value = get_post( $this->get_id() ); + break; + case 'download_type' : + return 'standard'; + break; + case 'product_image_gallery' : + $value = $this->get_gallery_image_ids(); + break; + case 'variation_shipping_class' : + case 'shipping_class' : + $value = $this->get_shipping_class(); + break; + case 'total_stock' : + $value = $this->get_total_stock(); + break; + case 'downloadable' : + case 'virtual' : + case 'manage_stock' : + case 'featured' : + case 'sold_individually' : + $value = $this->{"get_$key"}() ? 'yes' : 'no'; + break; + case 'crosssell_ids' : + $value = $this->get_cross_sell_ids(); + break; + case 'upsell_ids' : + $value = $this->get_upsell_ids(); + break; + case 'parent' : + $value = wc_get_product( $this->get_parent_id() ); + break; + case 'variation_id' : + $value = $this->is_type( 'variation' ) ? $this->get_id() : ''; + break; + case 'variation_data' : + $value = $this->is_type( 'variation' ) ? wc_get_product_variation_attributes( $this->get_id() ) : ''; + break; + case 'variation_has_stock' : + $value = $this->is_type( 'variation' ) ? $this->managing_stock() : ''; + break; + case 'variation_shipping_class_id' : + $value = $this->is_type( 'variation' ) ? $this->get_shipping_class_id() : ''; + break; + case 'variation_has_sku' : + case 'variation_has_length' : + case 'variation_has_width' : + case 'variation_has_height' : + case 'variation_has_weight' : + case 'variation_has_tax_class' : + case 'variation_has_downloadable_files' : + $value = true; // These were deprecated in 2.2 and simply returned true in 2.6.x. + break; + default : + if ( in_array( $key, array_keys( $this->data ) ) ) { + $value = $this->{"get_$key"}(); + } else { + $value = get_post_meta( $this->id, '_' . $key, true ); + } + break; + } + return $value; + } + + /** + * If set, get the default attributes for a variable product. + * + * @deprecated 3.0.0 + * @return array + */ + public function get_variation_default_attributes() { + wc_deprecated_function( 'WC_Product_Variable::get_variation_default_attributes', '3.0', 'WC_Product::get_default_attributes' ); + return apply_filters( 'woocommerce_product_default_attributes', $this->get_default_attributes(), $this ); + } + + /** + * Returns the gallery attachment ids. + * + * @deprecated 3.0.0 + * @return array + */ + public function get_gallery_attachment_ids() { + wc_deprecated_function( 'WC_Product::get_gallery_attachment_ids', '3.0', 'WC_Product::get_gallery_image_ids' ); + return $this->get_gallery_image_ids(); + } + + /** + * Set stock level of the product. + * + * @deprecated 3.0.0 + * + * @param int $amount + * @param string $mode + * + * @return int + */ + public function set_stock( $amount = null, $mode = 'set' ) { + wc_deprecated_function( 'WC_Product::set_stock', '3.0', 'wc_update_product_stock' ); + return wc_update_product_stock( $this, $amount, $mode ); + } + + /** + * Reduce stock level of the product. + * + * @deprecated 3.0.0 + * @param int $amount Amount to reduce by. Default: 1 + * @return int new stock level + */ + public function reduce_stock( $amount = 1 ) { + wc_deprecated_function( 'WC_Product::reduce_stock', '3.0', 'wc_update_product_stock' ); + return wc_update_product_stock( $this, $amount, 'decrease' ); + } + + /** + * Increase stock level of the product. + * + * @deprecated 3.0.0 + * @param int $amount Amount to increase by. Default 1. + * @return int new stock level + */ + public function increase_stock( $amount = 1 ) { + wc_deprecated_function( 'WC_Product::increase_stock', '3.0', 'wc_update_product_stock' ); + return wc_update_product_stock( $this, $amount, 'increase' ); + } + + /** + * Check if the stock status needs changing. + * + * @deprecated 3.0.0 Sync is done automatically on read/save, so calling this should not be needed any more. + */ + public function check_stock_status() { + wc_deprecated_function( 'WC_Product::check_stock_status', '3.0' ); + } + + /** + * Get and return related products. + * @deprecated 3.0.0 Use wc_get_related_products instead. + * + * @param int $limit + * + * @return array + */ + public function get_related( $limit = 5 ) { + wc_deprecated_function( 'WC_Product::get_related', '3.0', 'wc_get_related_products' ); + return wc_get_related_products( $this->get_id(), $limit ); + } + + /** + * Retrieves related product terms. + * @deprecated 3.0.0 Use wc_get_product_term_ids instead. + * + * @param $term + * + * @return array + */ + protected function get_related_terms( $term ) { + wc_deprecated_function( 'WC_Product::get_related_terms', '3.0', 'wc_get_product_term_ids' ); + return array_merge( array( 0 ), wc_get_product_term_ids( $this->get_id(), $term ) ); + } + + /** + * Builds the related posts query. + * @deprecated 3.0.0 Use Product Data Store get_related_products_query instead. + * + * @param $cats_array + * @param $tags_array + * @param $exclude_ids + * @param $limit + */ + protected function build_related_query( $cats_array, $tags_array, $exclude_ids, $limit ) { + wc_deprecated_function( 'WC_Product::build_related_query', '3.0', 'Product Data Store get_related_products_query' ); + $data_store = WC_Data_Store::load( 'product' ); + return $data_store->get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit ); + } + + /** + * Returns the child product. + * @deprecated 3.0.0 Use wc_get_product instead. + * @param mixed $child_id + * @return WC_Product|WC_Product|WC_Product_variation + */ + public function get_child( $child_id ) { + wc_deprecated_function( 'WC_Product::get_child', '3.0', 'wc_get_product' ); + return wc_get_product( $child_id ); + } + + /** + * Functions for getting parts of a price, in html, used by get_price_html. + * + * @deprecated 3.0.0 + * @return string + */ + public function get_price_html_from_text() { + wc_deprecated_function( 'WC_Product::get_price_html_from_text', '3.0', 'wc_get_price_html_from_text' ); + return wc_get_price_html_from_text(); + } + + /** + * Functions for getting parts of a price, in html, used by get_price_html. + * + * @deprecated 3.0.0 Use wc_format_sale_price instead. + * @param string $from String or float to wrap with 'from' text + * @param mixed $to String or float to wrap with 'to' text + * @return string + */ + public function get_price_html_from_to( $from, $to ) { + wc_deprecated_function( 'WC_Product::get_price_html_from_to', '3.0', 'wc_format_sale_price' ); + return apply_filters( 'woocommerce_get_price_html_from_to', wc_format_sale_price( $from, $to ), $from, $to, $this ); + } + + /** + * Lists a table of attributes for the product page. + * @deprecated 3.0.0 Use wc_display_product_attributes instead. + */ + public function list_attributes() { + wc_deprecated_function( 'WC_Product::list_attributes', '3.0', 'wc_display_product_attributes' ); + wc_display_product_attributes( $this ); + } + + /** + * Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes. + * + * @deprecated 3.0.0 Use wc_get_price_including_tax instead. + * @param int $qty + * @param string $price to calculate, left blank to just use get_price() + * @return string + */ + public function get_price_including_tax( $qty = 1, $price = '' ) { + wc_deprecated_function( 'WC_Product::get_price_including_tax', '3.0', 'wc_get_price_including_tax' ); + return wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); + } + + /** + * Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting. + * + * @deprecated 3.0.0 Use wc_get_price_to_display instead. + * @param string $price to calculate, left blank to just use get_price() + * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax() + * @return string + */ + public function get_display_price( $price = '', $qty = 1 ) { + wc_deprecated_function( 'WC_Product::get_display_price', '3.0', 'wc_get_price_to_display' ); + return wc_get_price_to_display( $this, array( 'qty' => $qty, 'price' => $price ) ); + } + + /** + * Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting. + * Uses store base tax rates. Can work for a specific $qty for more accurate taxes. + * + * @deprecated 3.0.0 Use wc_get_price_excluding_tax instead. + * @param int $qty + * @param string $price to calculate, left blank to just use get_price() + * @return string + */ + public function get_price_excluding_tax( $qty = 1, $price = '' ) { + wc_deprecated_function( 'WC_Product::get_price_excluding_tax', '3.0', 'wc_get_price_excluding_tax' ); + return wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ); + } + + /** + * Adjust a products price dynamically. + * + * @deprecated 3.0.0 + * @param mixed $price + */ + public function adjust_price( $price ) { + wc_deprecated_function( 'WC_Product::adjust_price', '3.0', 'WC_Product::set_price / WC_Product::get_price' ); + $this->data['price'] = $this->data['price'] + $price; + } + + /** + * Returns the product categories. + * + * @deprecated 3.0.0 + * @param string $sep (default: ', '). + * @param string $before (default: ''). + * @param string $after (default: ''). + * @return string + */ + public function get_categories( $sep = ', ', $before = '', $after = '' ) { + wc_deprecated_function( 'WC_Product::get_categories', '3.0', 'wc_get_product_category_list' ); + return wc_get_product_category_list( $this->get_id(), $sep, $before, $after ); + } + + /** + * Returns the product tags. + * + * @deprecated 3.0.0 + * @param string $sep (default: ', '). + * @param string $before (default: ''). + * @param string $after (default: ''). + * @return array + */ + public function get_tags( $sep = ', ', $before = '', $after = '' ) { + wc_deprecated_function( 'WC_Product::get_tags', '3.0', 'wc_get_product_tag_list' ); + return wc_get_product_tag_list( $this->get_id(), $sep, $before, $after ); + } + + /** + * Get the product's post data. + * + * @deprecated 3.0.0 + * @return WP_Post + */ + public function get_post_data() { + wc_deprecated_function( 'WC_Product::get_post_data', '3.0', 'get_post' ); + + // In order to keep backwards compatibility it's required to use the parent data for variations. + if ( $this->is_type( 'variation' ) ) { + $post_data = get_post( $this->get_parent_id() ); + } else { + $post_data = get_post( $this->get_id() ); + } + + return $post_data; + } + + /** + * Get the parent of the post. + * + * @deprecated 3.0.0 + * @return int + */ + public function get_parent() { + wc_deprecated_function( 'WC_Product::get_parent', '3.0', 'WC_Product::get_parent_id' ); + return apply_filters( 'woocommerce_product_parent', absint( $this->get_post_data()->post_parent ), $this ); + } + + /** + * Returns the upsell product ids. + * + * @deprecated 3.0.0 + * @return array + */ + public function get_upsells() { + wc_deprecated_function( 'WC_Product::get_upsells', '3.0', 'WC_Product::get_upsell_ids' ); + return apply_filters( 'woocommerce_product_upsell_ids', $this->get_upsell_ids(), $this ); + } + + /** + * Returns the cross sell product ids. + * + * @deprecated 3.0.0 + * @return array + */ + public function get_cross_sells() { + wc_deprecated_function( 'WC_Product::get_cross_sells', '3.0', 'WC_Product::get_cross_sell_ids' ); + return apply_filters( 'woocommerce_product_crosssell_ids', $this->get_cross_sell_ids(), $this ); + } + + /** + * Check if variable product has default attributes set. + * + * @deprecated 3.0.0 + * @return bool + */ + public function has_default_attributes() { + wc_deprecated_function( 'WC_Product_Variable::has_default_attributes', '3.0', 'a check against WC_Product::get_default_attributes directly' ); + if ( ! $this->get_default_attributes() ) { + return true; + } + return false; + } + + /** + * Get variation ID. + * + * @deprecated 3.0.0 + * @return int + */ + public function get_variation_id() { + wc_deprecated_function( 'WC_Product::get_variation_id', '3.0', 'WC_Product::get_id(). It will always be the variation ID if this is a variation.' ); + return $this->get_id(); + } + + /** + * Get product variation description. + * + * @deprecated 3.0.0 + * @return string + */ + public function get_variation_description() { + wc_deprecated_function( 'WC_Product::get_variation_description', '3.0', 'WC_Product::get_description()' ); + return $this->get_description(); + } + + /** + * Check if all variation's attributes are set. + * + * @deprecated 3.0.0 + * @return boolean + */ + public function has_all_attributes_set() { + wc_deprecated_function( 'WC_Product::has_all_attributes_set', '3.0', 'an array filter on get_variation_attributes for a quick solution.' ); + $set = true; + + // undefined attributes have null strings as array values + foreach ( $this->get_variation_attributes() as $att ) { + if ( ! $att ) { + $set = false; + break; + } + } + return $set; + } + + /** + * Returns whether or not the variations parent is visible. + * + * @deprecated 3.0.0 + * @return bool + */ + public function parent_is_visible() { + wc_deprecated_function( 'WC_Product::parent_is_visible', '3.0' ); + return $this->is_visible(); + } + + /** + * Get total stock - This is the stock of parent and children combined. + * + * @deprecated 3.0.0 + * @return int + */ + public function get_total_stock() { + wc_deprecated_function( 'WC_Product::get_total_stock', '3.0', 'get_stock_quantity on each child. Beware of performance issues in doing so.' ); + if ( sizeof( $this->get_children() ) > 0 ) { + $total_stock = max( 0, $this->get_stock_quantity() ); + + foreach ( $this->get_children() as $child_id ) { + if ( 'yes' === get_post_meta( $child_id, '_manage_stock', true ) ) { + $stock = get_post_meta( $child_id, '_stock', true ); + $total_stock += max( 0, wc_stock_amount( $stock ) ); + } + } + } else { + $total_stock = $this->get_stock_quantity(); + } + return wc_stock_amount( $total_stock ); + } + + /** + * Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names. + * + * @deprecated 3.0.0 + * + * @param bool $flat + * + * @return string + */ + public function get_formatted_variation_attributes( $flat = false ) { + wc_deprecated_function( 'WC_Product::get_formatted_variation_attributes', '3.0', 'wc_get_formatted_variation' ); + return wc_get_formatted_variation( $this, $flat ); + } + + /** + * Sync variable product prices with the children lowest/highest prices. + * + * @deprecated 3.0.0 not used in core. + * + * @param int $product_id + */ + public function variable_product_sync( $product_id = 0 ) { + wc_deprecated_function( 'WC_Product::variable_product_sync', '3.0' ); + if ( empty( $product_id ) ) { + $product_id = $this->get_id(); + } + + // Sync prices with children + if ( is_callable( array( __CLASS__, 'sync' ) ) ) { + self::sync( $product_id ); + } + } + + /** + * Sync the variable product's attributes with the variations. + * + * @param $product + * @param bool $children + */ + public static function sync_attributes( $product, $children = false ) { + if ( ! is_a( $product, 'WC_Product' ) ) { + $product = wc_get_product( $product ); + } + + /** + * Pre 2.4 handling where 'slugs' were saved instead of the full text attribute. + * Attempt to get full version of the text attribute from the parent and UPDATE meta. + */ + if ( version_compare( get_post_meta( $product->get_id(), '_product_version', true ), '2.4.0', '<' ) ) { + $parent_attributes = array_filter( (array) get_post_meta( $product->get_id(), '_product_attributes', true ) ); + + if ( ! $children ) { + $children = $product->get_children( 'edit' ); + } + + foreach ( $children as $child_id ) { + $all_meta = get_post_meta( $child_id ); + + foreach ( $all_meta as $name => $value ) { + if ( 0 !== strpos( $name, 'attribute_' ) ) { + continue; + } + if ( sanitize_title( $value[0] ) === $value[0] ) { + foreach ( $parent_attributes as $attribute ) { + if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) { + continue; + } + $text_attributes = wc_get_text_attributes( $attribute['value'] ); + foreach ( $text_attributes as $text_attribute ) { + if ( sanitize_title( $text_attribute ) === $value[0] ) { + update_post_meta( $child_id, $name, $text_attribute ); + break; + } + } + } + } + } + } + } + } + + /** + * Match a variation to a given set of attributes using a WP_Query. + * @deprecated 3.0.0 in favour of Product data store's find_matching_product_variation. + * + * @param array $match_attributes + */ + public function get_matching_variation( $match_attributes = array() ) { + wc_deprecated_function( 'WC_Product::get_matching_variation', '3.0', 'Product data store find_matching_product_variation' ); + $data_store = WC_Data_Store::load( 'product' ); + return $data_store->find_matching_product_variation( $this, $match_attributes ); + } + + /** + * Returns whether or not we are showing dimensions on the product page. + * @deprecated 3.0.0 Unused. + * @return bool + */ + public function enable_dimensions_display() { + wc_deprecated_function( 'WC_Product::enable_dimensions_display', '3.0' ); + return apply_filters( 'wc_product_enable_dimensions_display', true ) && ( $this->has_dimensions() || $this->has_weight() || $this->child_has_weight() || $this->child_has_dimensions() ); + } + + /** + * Returns the product rating in html format. + * + * @deprecated 3.0.0 + * @param string $rating (default: '') + * @return string + */ + public function get_rating_html( $rating = null ) { + wc_deprecated_function( 'WC_Product::get_rating_html', '3.0', 'wc_get_rating_html' ); + return wc_get_rating_html( $rating ); + } + + /** + * Sync product rating. Can be called statically. + * + * @deprecated 3.0.0 + * @param int $post_id + */ + public static function sync_average_rating( $post_id ) { + wc_deprecated_function( 'WC_Product::sync_average_rating', '3.0', 'WC_Comments::get_average_rating_for_product or leave to CRUD.' ); + $average = WC_Comments::get_average_rating_for_product( wc_get_product( $post_id ) ); + update_post_meta( $post_id, '_wc_average_rating', $average ); + } + + /** + * Sync product rating count. Can be called statically. + * + * @deprecated 3.0.0 + * @param int $post_id + */ + public static function sync_rating_count( $post_id ) { + wc_deprecated_function( 'WC_Product::sync_rating_count', '3.0', 'WC_Comments::get_rating_counts_for_product or leave to CRUD.' ); + $counts = WC_Comments::get_rating_counts_for_product( wc_get_product( $post_id ) ); + update_post_meta( $post_id, '_wc_rating_count', $counts ); + } + + /** + * Same as get_downloads in CRUD. + * + * @deprecated 3.0.0 + * @return array + */ + public function get_files() { + wc_deprecated_function( 'WC_Product::get_files', '3.0', 'WC_Product::get_downloads' ); + return $this->get_downloads(); + } + + /** + * @deprecated 3.0.0 Sync is taken care of during save - no need to call this directly. + */ + public function grouped_product_sync() { + wc_deprecated_function( 'WC_Product::grouped_product_sync', '3.0' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-api.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-api.php new file mode 100644 index 0000000..2c1000d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-api.php @@ -0,0 +1,275 @@ +query_vars['wc-api-version'] = $_GET['wc-api-version']; + } + + if ( ! empty( $_GET['wc-api-route'] ) ) { + $wp->query_vars['wc-api-route'] = $_GET['wc-api-route']; + } + + // REST API request. + if ( ! empty( $wp->query_vars['wc-api-version'] ) && ! empty( $wp->query_vars['wc-api-route'] ) ) { + + wc_maybe_define_constant( 'WC_API_REQUEST', true ); + wc_maybe_define_constant( 'WC_API_REQUEST_VERSION', absint( $wp->query_vars['wc-api-version'] ) ); + + // Legacy v1 API request. + if ( 1 === WC_API_REQUEST_VERSION ) { + $this->handle_v1_rest_api_request(); + } elseif ( 2 === WC_API_REQUEST_VERSION ) { + $this->handle_v2_rest_api_request(); + } else { + $this->includes(); + + $this->server = new WC_API_Server( $wp->query_vars['wc-api-route'] ); + + // load API resource classes. + $this->register_resources( $this->server ); + + // Fire off the request. + $this->server->serve_request(); + } + + exit; + } + } + + /** + * Include required files for REST API request. + * + * @since 2.1 + * @deprecated 2.6.0 + */ + public function includes() { + + // API server / response handlers. + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-exception.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-server.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/interface-wc-api-handler.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-json-handler.php' ); + + // Authentication. + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-authentication.php' ); + $this->authentication = new WC_API_Authentication(); + + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-resource.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-coupons.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-customers.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-orders.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-products.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-reports.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-taxes.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v3/class-wc-api-webhooks.php' ); + + // Allow plugins to load other response handlers or resource classes. + do_action( 'woocommerce_api_loaded' ); + } + + /** + * Register available API resources. + * + * @since 2.1 + * @deprecated 2.6.0 + * @param WC_API_Server $server the REST server. + */ + public function register_resources( $server ) { + + $api_classes = apply_filters( 'woocommerce_api_classes', + array( + 'WC_API_Coupons', + 'WC_API_Customers', + 'WC_API_Orders', + 'WC_API_Products', + 'WC_API_Reports', + 'WC_API_Taxes', + 'WC_API_Webhooks', + ) + ); + + foreach ( $api_classes as $api_class ) { + $this->$api_class = new $api_class( $server ); + } + } + + + /** + * Handle legacy v1 REST API requests. + * + * @since 2.2 + * @deprecated 2.6.0 + */ + private function handle_v1_rest_api_request() { + + // Include legacy required files for v1 REST API request. + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-server.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/interface-wc-api-handler.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-json-handler.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-xml-handler.php' ); + + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-authentication.php' ); + $this->authentication = new WC_API_Authentication(); + + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-resource.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-coupons.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-customers.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-orders.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-products.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v1/class-wc-api-reports.php' ); + + // Allow plugins to load other response handlers or resource classes. + do_action( 'woocommerce_api_loaded' ); + + $this->server = new WC_API_Server( $GLOBALS['wp']->query_vars['wc-api-route'] ); + + // Register available resources for legacy v1 REST API request. + $api_classes = apply_filters( 'woocommerce_api_classes', + array( + 'WC_API_Customers', + 'WC_API_Orders', + 'WC_API_Products', + 'WC_API_Coupons', + 'WC_API_Reports', + ) + ); + + foreach ( $api_classes as $api_class ) { + $this->$api_class = new $api_class( $this->server ); + } + + // Fire off the request. + $this->server->serve_request(); + } + + /** + * Handle legacy v2 REST API requests. + * + * @since 2.4 + * @deprecated 2.6.0 + */ + private function handle_v2_rest_api_request() { + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-exception.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-server.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/interface-wc-api-handler.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-json-handler.php' ); + + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-authentication.php' ); + $this->authentication = new WC_API_Authentication(); + + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-resource.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-coupons.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-customers.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-orders.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-products.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-reports.php' ); + include_once( dirname( __FILE__ ) . '/../api/legacy/v2/class-wc-api-webhooks.php' ); + + // allow plugins to load other response handlers or resource classes. + do_action( 'woocommerce_api_loaded' ); + + $this->server = new WC_API_Server( $GLOBALS['wp']->query_vars['wc-api-route'] ); + + // Register available resources for legacy v2 REST API request. + $api_classes = apply_filters( 'woocommerce_api_classes', + array( + 'WC_API_Customers', + 'WC_API_Orders', + 'WC_API_Products', + 'WC_API_Coupons', + 'WC_API_Reports', + 'WC_API_Webhooks', + ) + ); + + foreach ( $api_classes as $api_class ) { + $this->$api_class = new $api_class( $this->server ); + } + + // Fire off the request. + $this->server->serve_request(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-cart.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-cart.php new file mode 100644 index 0000000..9c87ea0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-cart.php @@ -0,0 +1,406 @@ + 0, + 'total' => 0, + 'subtotal' => 0, + 'subtotal_ex_tax' => 0, + 'tax_total' => 0, + 'taxes' => array(), + 'shipping_taxes' => array(), + 'discount_cart' => 0, + 'discount_cart_tax' => 0, + 'shipping_total' => 0, + 'shipping_tax_total' => 0, + 'coupon_discount_amounts' => array(), + 'coupon_discount_tax_amounts' => array(), + 'fee_total' => 0, + 'fees' => array(), + ); + + /** + * Contains an array of coupon usage counts after they have been applied. + * + * @deprecated 3.2.0 + * @var array + */ + public $coupon_applied_count = array(); + + /** + * Map legacy variables. + * + * @param string $name Property name. + * @param mixed $value Value to set. + */ + public function __isset( $name ) { + if ( array_key_exists( $name, $this->cart_session_data ) || 'fees' === $name ) { + return true; + } + return false; + } + + /** + * Magic getters. + * + * @param string $name Property name. + * @return mixed + */ + public function &__get( $name ) { + $value = ''; + + switch ( $name ) { + case 'dp' : + $value = wc_get_price_decimals(); + break; + case 'prices_include_tax' : + $value = wc_prices_include_tax(); + break; + case 'round_at_subtotal' : + $value = 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ); + break; + case 'cart_contents_total' : + $value = $this->get_cart_contents_total(); + break; + case 'total' : + $value = $this->get_total( 'edit' ); + break; + case 'subtotal' : + $value = $this->get_subtotal() + $this->get_subtotal_tax(); + break; + case 'subtotal_ex_tax' : + $value = $this->get_subtotal(); + break; + case 'tax_total' : + $value = $this->get_fee_tax() + $this->get_cart_contents_tax(); + break; + case 'fee_total' : + $value = $this->get_fee_total(); + break; + case 'discount_cart' : + $value = $this->get_discount_total(); + break; + case 'discount_cart_tax' : + $value = $this->get_discount_tax(); + break; + case 'shipping_total' : + $value = $this->get_shipping_total(); + break; + case 'shipping_tax_total' : + $value = $this->get_shipping_tax(); + break; + case 'display_totals_ex_tax' : + case 'display_cart_ex_tax' : + $value = ! $this->display_prices_including_tax(); + break; + case 'cart_contents_weight' : + $value = $this->get_cart_contents_weight(); + break; + case 'cart_contents_count' : + $value = $this->get_cart_contents_count(); + break; + case 'coupons' : + $value = $this->get_coupons(); + break; + + // Arrays returned by reference to allow modification without notices. TODO: Remove in 4.0. + case 'taxes' : + wc_deprecated_function( 'WC_Cart->taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_cart_contents_taxes()', 'WC_Cart::set_cart_contents_taxes()' ) ); + $value = &$this->totals[ 'cart_contents_taxes' ]; + break; + case 'shipping_taxes' : + wc_deprecated_function( 'WC_Cart->shipping_taxes', '3.2', sprintf( 'getters (%s) and setters (%s)', 'WC_Cart::get_shipping_taxes()', 'WC_Cart::set_shipping_taxes()' ) ); + $value = &$this->totals[ 'shipping_taxes' ]; + break; + case 'coupon_discount_amounts' : + $value = &$this->coupon_discount_totals; + break; + case 'coupon_discount_tax_amounts' : + $value = &$this->coupon_discount_tax_totals; + break; + case 'fees' : + wc_deprecated_function( 'WC_Cart->fees', '3.2', sprintf( 'the fees API (%s)', 'WC_Cart::get_fees' ) ); + + // Grab fees from the new API. + $new_fees = $this->fees_api()->get_fees(); + + // Add new fees to the legacy prop so it can be adjusted via legacy property. + $this->fees = $new_fees; + + // Return by reference. + $value = &$this->fees; + break; + // Deprecated args. TODO: Remove in 4.0. + case 'tax' : + wc_deprecated_argument( 'WC_Cart->tax', '2.3', 'Use WC_Tax directly' ); + $this->tax = new WC_Tax(); + $value = $this->tax; + break; + case 'discount_total': + wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' ); + $value = 0; + break; + } + return $value; + } + + /** + * Map legacy variables to setters. + * + * @param string $name Property name. + * @param mixed $value Value to set. + */ + public function __set( $name, $value ) { + switch ( $name ) { + case 'cart_contents_total' : + $this->set_cart_contents_total( $value ); + break; + case 'total' : + $this->set_total( $value ); + break; + case 'subtotal' : + $this->set_subtotal( $value ); + break; + case 'subtotal_ex_tax' : + $this->set_subtotal( $value ); + break; + case 'tax_total' : + $this->set_cart_contents_tax( $value ); + $this->set_fee_tax( 0 ); + break; + case 'taxes' : + $this->set_cart_contents_taxes( $value ); + break; + case 'shipping_taxes' : + $this->set_shipping_taxes( $value ); + break; + case 'fee_total' : + $this->set_fee_total( $value ); + break; + case 'discount_cart' : + $this->set_discount_total( $value ); + break; + case 'discount_cart_tax' : + $this->set_discount_tax( $value ); + break; + case 'shipping_total' : + $this->set_shipping_total( $value ); + break; + case 'shipping_tax_total' : + $this->set_shipping_tax( $value ); + break; + case 'coupon_discount_amounts' : + $this->set_coupon_discount_totals( $value ); + break; + case 'coupon_discount_tax_amounts' : + $this->set_coupon_discount_tax_totals( $value ); + break; + case 'fees' : + wc_deprecated_function( 'WC_Cart->fees', '3.2', sprintf( 'the fees API (%s)', 'WC_Cart::add_fee' ) ); + $this->fees = $value; + break; + default : + $this->$name = $value; + break; + } + } + + /** + * Methods moved to session class in 3.2.0. + */ + public function get_cart_from_session() { $this->session->get_cart_from_session(); } + public function maybe_set_cart_cookies() { $this->session->maybe_set_cart_cookies(); } + public function set_session() { $this->session->set_session(); } + public function get_cart_for_session() { return $this->session->get_cart_for_session(); } + public function persistent_cart_update() { $this->session->persistent_cart_update(); } + public function persistent_cart_destroy() { $this->session->persistent_cart_destroy(); } + + /** + * Get the total of all cart discounts. + * + * @return float + */ + public function get_cart_discount_total() { + return $this->get_discount_total(); + } + + /** + * Get the total of all cart tax discounts (used for discounts on tax inclusive prices). + * + * @return float + */ + public function get_cart_discount_tax_total() { + return $this->get_discount_tax(); + } + + /** + * Renamed for consistency. + * + * @param string $coupon_code + * @return bool True if the coupon is applied, false if it does not exist or cannot be applied. + */ + public function add_discount( $coupon_code ) { + return $this->apply_coupon( $coupon_code ); + } + /** + * Remove taxes. + * + * @deprecated 3.2.0 Taxes are never calculated if customer is tax except making this function unused. + */ + public function remove_taxes() { + wc_deprecated_function( 'WC_Cart::remove_taxes', '3.2', '' ); + } + /** + * Init. + * + * @deprecated 3.2.0 Session is loaded via hooks rather than directly. + */ + public function init() { + wc_deprecated_function( 'WC_Cart::init', '3.2', '' ); + $this->get_cart_from_session(); + } + + /** + * Function to apply discounts to a product and get the discounted price (before tax is applied). + * + * @deprecated Calculation and coupon logic is handled in WC_Cart_Totals. + * @param mixed $values Cart item. + * @param mixed $price Price of item. + * @param bool $add_totals Legacy. + * @return float price + */ + public function get_discounted_price( $values, $price, $add_totals = false ) { + wc_deprecated_function( 'WC_Cart::get_discounted_price', '3.2', '' ); + + $cart_item_key = $values['key']; + $cart_item = $this->cart_contents[ $cart_item_key ]; + + return $cart_item['line_total']; + } + + /** + * Gets the url to the cart page. + * + * @deprecated 2.5.0 in favor to wc_get_cart_url() + * @return string url to page + */ + public function get_cart_url() { + wc_deprecated_function( 'WC_Cart::get_cart_url', '2.5', 'wc_get_cart_url' ); + return wc_get_cart_url(); + } + + /** + * Gets the url to the checkout page. + * + * @deprecated 2.5.0 in favor to wc_get_checkout_url() + * @return string url to page + */ + public function get_checkout_url() { + wc_deprecated_function( 'WC_Cart::get_checkout_url', '2.5', 'wc_get_checkout_url' ); + return wc_get_checkout_url(); + } + + /** + * Sees if we need a shipping address. + * + * @deprecated 2.5.0 in favor to wc_ship_to_billing_address_only() + * @return bool + */ + public function ship_to_billing_address_only() { + wc_deprecated_function( 'WC_Cart::ship_to_billing_address_only', '2.5', 'wc_ship_to_billing_address_only' ); + return wc_ship_to_billing_address_only(); + } + + /** + * Coupons enabled function. Filterable. + * + * @deprecated 2.5.0 in favor to wc_coupons_enabled() + * @return bool + */ + public function coupons_enabled() { + return wc_coupons_enabled(); + } + + /** + * Gets the total (product) discount amount - these are applied before tax. + * + * @deprecated Order discounts (after tax) removed in 2.3 so multiple methods for discounts are no longer required. + * @return mixed formatted price or false if there are none. + */ + public function get_discounts_before_tax() { + wc_deprecated_function( 'get_discounts_before_tax', '2.3', 'get_total_discount' ); + if ( $this->get_cart_discount_total() ) { + $discounts_before_tax = wc_price( $this->get_cart_discount_total() ); + } else { + $discounts_before_tax = false; + } + return apply_filters( 'woocommerce_cart_discounts_before_tax', $discounts_before_tax, $this ); + } + + /** + * Get the total of all order discounts (after tax discounts). + * + * @deprecated Order discounts (after tax) removed in 2.3. + * @return int + */ + public function get_order_discount_total() { + wc_deprecated_function( 'get_order_discount_total', '2.3' ); + return 0; + } + + /** + * Function to apply cart discounts after tax. + * + * @deprecated Coupons can not be applied after tax. + * @param $values + * @param $price + */ + public function apply_cart_discounts_after_tax( $values, $price ) { + wc_deprecated_function( 'apply_cart_discounts_after_tax', '2.3' ); + } + + /** + * Function to apply product discounts after tax. + * + * @deprecated Coupons can not be applied after tax. + * + * @param $values + * @param $price + */ + public function apply_product_discounts_after_tax( $values, $price ) { + wc_deprecated_function( 'apply_product_discounts_after_tax', '2.3' ); + } + + /** + * Gets the order discount amount - these are applied after tax. + * + * @deprecated Coupons can not be applied after tax. + */ + public function get_discounts_after_tax() { + wc_deprecated_function( 'get_discounts_after_tax', '2.3' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-coupon.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-coupon.php new file mode 100644 index 0000000..cad0fc1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-coupon.php @@ -0,0 +1,204 @@ +get_id(); + break; + case 'exists' : + $value = $this->get_id() > 0; + break; + case 'coupon_custom_fields' : + $legacy_custom_fields = array(); + $custom_fields = $this->get_id() ? $this->get_meta_data() : array(); + if ( ! empty( $custom_fields ) ) { + foreach ( $custom_fields as $cf_value ) { + // legacy only supports 1 key + $legacy_custom_fields[ $cf_value->key ][0] = $cf_value->value; + } + } + $value = $legacy_custom_fields; + break; + case 'type' : + case 'discount_type' : + $value = $this->get_discount_type(); + break; + case 'amount' : + case 'coupon_amount' : + $value = $this->get_amount(); + break; + case 'code' : + $value = $this->get_code(); + break; + case 'individual_use' : + $value = ( true === $this->get_individual_use() ) ? 'yes' : 'no'; + break; + case 'product_ids' : + $value = $this->get_product_ids(); + break; + case 'exclude_product_ids' : + $value = $this->get_excluded_product_ids(); + break; + case 'usage_limit' : + $value = $this->get_usage_limit(); + break; + case 'usage_limit_per_user' : + $value = $this->get_usage_limit_per_user(); + break; + case 'limit_usage_to_x_items' : + $value = $this->get_limit_usage_to_x_items(); + break; + case 'usage_count' : + $value = $this->get_usage_count(); + break; + case 'expiry_date' : + $value = ( $this->get_date_expires() ? $this->get_date_expires()->date( 'Y-m-d' ) : '' ); + break; + case 'product_categories' : + $value = $this->get_product_categories(); + break; + case 'exclude_product_categories' : + $value = $this->get_excluded_product_categories(); + break; + case 'minimum_amount' : + $value = $this->get_minimum_amount(); + break; + case 'maximum_amount' : + $value = $this->get_maximum_amount(); + break; + case 'customer_email' : + $value = $this->get_email_restrictions(); + break; + default : + $value = ''; + break; + } + + return $value; + } + + /** + * Format loaded data as array. + * @param string|array $array + * @return array + */ + public function format_array( $array ) { + wc_deprecated_function( 'WC_Coupon::format_array', '3.0' ); + if ( ! is_array( $array ) ) { + if ( is_serialized( $array ) ) { + $array = maybe_unserialize( $array ); + } else { + $array = explode( ',', $array ); + } + } + return array_filter( array_map( 'trim', array_map( 'strtolower', $array ) ) ); + } + + + /** + * Check if coupon needs applying before tax. + * + * @return bool + */ + public function apply_before_tax() { + wc_deprecated_function( 'WC_Coupon::apply_before_tax', '3.0' ); + return true; + } + + /** + * Check if a coupon enables free shipping. + * + * @return bool + */ + public function enable_free_shipping() { + wc_deprecated_function( 'WC_Coupon::enable_free_shipping', '3.0', 'WC_Coupon::get_free_shipping' ); + return $this->get_free_shipping(); + } + + /** + * Check if a coupon excludes sale items. + * + * @return bool + */ + public function exclude_sale_items() { + wc_deprecated_function( 'WC_Coupon::exclude_sale_items', '3.0', 'WC_Coupon::get_exclude_sale_items' ); + return $this->get_exclude_sale_items(); + } + + /** + * Increase usage count for current coupon. + * + * @param string $used_by Either user ID or billing email + */ + public function inc_usage_count( $used_by = '' ) { + $this->increase_usage_count( $used_by ); + } + + /** + * Decrease usage count for current coupon. + * + * @param string $used_by Either user ID or billing email + */ + public function dcr_usage_count( $used_by = '' ) { + $this->decrease_usage_count( $used_by ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-customer.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-customer.php new file mode 100644 index 0000000..5ad3d95 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-customer.php @@ -0,0 +1,286 @@ +filter_legacy_key( $key ); + return in_array( $key, $legacy_keys ); + } + + /** + * __get function. + * @param string $key + * @return string + */ + public function __get( $key ) { + wc_doing_it_wrong( $key, 'Customer properties should not be accessed directly.', '3.0' ); + $key = $this->filter_legacy_key( $key ); + if ( in_array( $key, array( 'country', 'state', 'postcode', 'city', 'address_1', 'address', 'address_2' ) ) ) { + $key = 'billing_' . $key; + } + return is_callable( array( $this, "get_{$key}" ) ) ? $this->{"get_{$key}"}() : ''; + } + + /** + * __set function. + * + * @param string $key + * @param mixed $value + */ + public function __set( $key, $value ) { + wc_doing_it_wrong( $key, 'Customer properties should not be set directly.', '3.0' ); + $key = $this->filter_legacy_key( $key ); + + if ( is_callable( array( $this, "set_{$key}" ) ) ) { + $this->{"set_{$key}"}( $value ); + } + } + + /** + * Address and shipping_address are aliased, so we want to get the 'real' key name. + * For all other keys, we can just return it. + * @since 3.0.0 + * @param string $key + * @return string + */ + private function filter_legacy_key( $key ) { + if ( 'address' === $key ) { + $key = 'address_1'; + } + if ( 'shipping_address' === $key ) { + $key = 'shipping_address_1'; + } + + return $key; + } + + /** + * Sets session data for the location. + * + * @param string $country + * @param string $state + * @param string $postcode (default: '') + * @param string $city (default: '') + */ + public function set_location( $country, $state, $postcode = '', $city = '' ) { + $this->set_billing_location( $country, $state, $postcode, $city ); + $this->set_shipping_location( $country, $state, $postcode, $city ); + } + + /** + * Get default country for a customer. + * @return string + */ + public function get_default_country() { + wc_deprecated_function( 'WC_Customer::get_default_country', '3.0', 'wc_get_customer_default_location' ); + $default = wc_get_customer_default_location(); + return $default['country']; + } + + /** + * Get default state for a customer. + * @return string + */ + public function get_default_state() { + wc_deprecated_function( 'WC_Customer::get_default_state', '3.0', 'wc_get_customer_default_location' ); + $default = wc_get_customer_default_location(); + return $default['state']; + } + + /** + * Set customer address to match shop base address. + */ + public function set_to_base() { + wc_deprecated_function( 'WC_Customer::set_to_base', '3.0', 'WC_Customer::set_billing_address_to_base' ); + $this->set_billing_address_to_base(); + } + + /** + * Set customer shipping address to base address. + */ + public function set_shipping_to_base() { + wc_deprecated_function( 'WC_Customer::set_shipping_to_base', '3.0', 'WC_Customer::set_shipping_address_to_base' ); + $this->set_shipping_address_to_base(); + } + + /** + * Calculated shipping. + * @param boolean $calculated + */ + public function calculated_shipping( $calculated = true ) { + wc_deprecated_function( 'WC_Customer::calculated_shipping', '3.0', 'WC_Customer::set_calculated_shipping' ); + $this->set_calculated_shipping( $calculated ); + } + + /** + * Set default data for a customer. + */ + public function set_default_data() { + wc_deprecated_function( 'WC_Customer::set_default_data', '3.0' ); + } + + /** + * Save data function. + */ + public function save_data() { + $this->save(); + } + + /** + * Is the user a paying customer? + * + * @param int $user_id + * + * @return bool + */ + function is_paying_customer( $user_id = '' ) { + wc_deprecated_function( 'WC_Customer::is_paying_customer', '3.0', 'WC_Customer::get_is_paying_customer' ); + if ( ! empty( $user_id ) ) { + $user_id = get_current_user_id(); + } + return '1' === get_user_meta( $user_id, 'paying_customer', true ); + } + + /** + * Legacy get address. + */ + function get_address() { + wc_deprecated_function( 'WC_Customer::get_address', '3.0', 'WC_Customer::get_billing_address_1' ); + return $this->get_billing_address_1(); + } + + /** + * Legacy get address 2. + */ + function get_address_2() { + wc_deprecated_function( 'WC_Customer::get_address_2', '3.0', 'WC_Customer::get_billing_address_2' ); + return $this->get_billing_address_2(); + } + + /** + * Legacy get country. + */ + function get_country() { + wc_deprecated_function( 'WC_Customer::get_country', '3.0', 'WC_Customer::get_billing_country' ); + return $this->get_billing_country(); + } + + /** + * Legacy get state. + */ + function get_state() { + wc_deprecated_function( 'WC_Customer::get_state', '3.0', 'WC_Customer::get_billing_state' ); + return $this->get_billing_state(); + } + + /** + * Legacy get postcode. + */ + function get_postcode() { + wc_deprecated_function( 'WC_Customer::get_postcode', '3.0', 'WC_Customer::get_billing_postcode' ); + return $this->get_billing_postcode(); + } + + /** + * Legacy get city. + */ + function get_city() { + wc_deprecated_function( 'WC_Customer::get_city', '3.0', 'WC_Customer::get_billing_city' ); + return $this->get_billing_city(); + } + + /** + * Legacy set country. + * + * @param string $country + */ + function set_country( $country ) { + wc_deprecated_function( 'WC_Customer::set_country', '3.0', 'WC_Customer::set_billing_country' ); + $this->set_billing_country( $country ); + } + + /** + * Legacy set state. + * + * @param string $state + */ + function set_state( $state ) { + wc_deprecated_function( 'WC_Customer::set_state', '3.0', 'WC_Customer::set_billing_state' ); + $this->set_billing_state( $state ); + } + + /** + * Legacy set postcode. + * + * @param string $postcode + */ + function set_postcode( $postcode ) { + wc_deprecated_function( 'WC_Customer::set_postcode', '3.0', 'WC_Customer::set_billing_postcode' ); + $this->set_billing_postcode( $postcode ); + } + + /** + * Legacy set city. + * + * @param string $city + */ + function set_city( $city ) { + wc_deprecated_function( 'WC_Customer::set_city', '3.0', 'WC_Customer::set_billing_city' ); + $this->set_billing_city( $city ); + } + + /** + * Legacy set address. + * + * @param string $address + */ + function set_address( $address ) { + wc_deprecated_function( 'WC_Customer::set_address', '3.0', 'WC_Customer::set_billing_address' ); + $this->set_billing_address( $address ); + } + + /** + * Legacy set address. + * + * @param string $address + */ + function set_address_2( $address ) { + wc_deprecated_function( 'WC_Customer::set_address_2', '3.0', 'WC_Customer::set_billing_address_2' ); + $this->set_billing_address_2( $address ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-shipping-zone.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-shipping-zone.php new file mode 100644 index 0000000..aa06337 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-shipping-zone.php @@ -0,0 +1,68 @@ +get_id(); + } + + /** + * Read a shipping zone by ID. + * @deprecated 3.0.0 - Init a shipping zone with an ID. + * + * @param int $zone_id + */ + public function read( $zone_id ) { + wc_deprecated_function( 'WC_Shipping_Zone::read', '3.0', 'a shipping zone initialized with an ID.' ); + $this->set_id( $zone_id ); + $data_store = WC_Data_Store::load( 'shipping-zone' ); + $data_store->read( $this ); + } + + /** + * Update a zone. + * @deprecated 3.0.0 - Use ::save instead. + */ + public function update() { + wc_deprecated_function( 'WC_Shipping_Zone::update', '3.0', 'WC_Shipping_Zone::save instead.' ); + $data_store = WC_Data_Store::load( 'shipping-zone' ); + try { + $data_store->update( $this ); + } catch ( Exception $e ) { + return false; + } + } + + /** + * Create a zone. + * @deprecated 3.0.0 - Use ::save instead. + */ + public function create() { + wc_deprecated_function( 'WC_Shipping_Zone::create', '3.0', 'WC_Shipping_Zone::save instead.' ); + $data_store = WC_Data_Store::load( 'shipping-zone' ); + try { + $data_store->create( $this ); + } catch ( Exception $e ) { + return false; + } + } + + +} diff --git a/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-webhook.php b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-webhook.php new file mode 100644 index 0000000..e18000e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/legacy/class-wc-legacy-webhook.php @@ -0,0 +1,129 @@ +get_id(); + break; + case 'status' : + $value = $this->get_status(); + break; + case 'post_data' : + $value = null; + break; + case 'delivery_url' : + $value = $this->get_delivery_url(); + break; + case 'secret' : + $value = $this->get_secret(); + break; + case 'topic' : + $value = $this->get_topic(); + break; + case 'hooks' : + $value = $this->get_hooks(); + break; + case 'resource' : + $value = $this->get_resource(); + break; + case 'event' : + $value = $this->get_event(); + break; + case 'failure_count' : + $value = $this->get_failure_count(); + break; + case 'api_version' : + $value = $this->get_api_version(); + break; + + default : + $value = ''; + break; + } // End switch(). + + return $value; + } + + /** + * Get the post data for the webhook. + * + * @deprecated 3.2.0 + * @since 2.2 + * @return null|WP_Post + */ + public function get_post_data() { + wc_deprecated_function( 'WC_Webhook::get_post_data', '3.2' ); + + return null; + } + + /** + * Update the webhook status. + * + * @deprecated 3.2.0 + * @since 2.2.0 + * @param string $status Status to set. + */ + public function update_status( $status ) { + wc_deprecated_function( 'WC_Webhook::update_status', '3.2', 'WC_Webhook::set_status' ); + + $this->set_status( $status ); + $this->save(); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php b/backend/wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php new file mode 100644 index 0000000..490c258 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php @@ -0,0 +1,1555 @@ + + * @author Roman Ožana + * @author Sander Kruger + */ +// @codingStandardsIgnoreFile +class Emogrifier +{ + /** + * @var int + */ + const CACHE_KEY_CSS = 0; + + /** + * @var int + */ + const CACHE_KEY_SELECTOR = 1; + + /** + * @var int + */ + const CACHE_KEY_XPATH = 2; + + /** + * @var int + */ + const CACHE_KEY_CSS_DECLARATIONS_BLOCK = 3; + + /** + * @var int + */ + const CACHE_KEY_COMBINED_STYLES = 4; + + /** + * for calculating nth-of-type and nth-child selectors + * + * @var int + */ + const INDEX = 0; + + /** + * for calculating nth-of-type and nth-child selectors + * + * @var int + */ + const MULTIPLIER = 1; + + /** + * @var string + */ + const ID_ATTRIBUTE_MATCHER = '/(\\w+)?\\#([\\w\\-]+)/'; + + /** + * @var string + */ + const CLASS_ATTRIBUTE_MATCHER = '/(\\w+|[\\*\\]])?((\\.[\\w\\-]+)+)/'; + + /** + * @var string + */ + const CONTENT_TYPE_META_TAG = ''; + + /** + * @var string + */ + const DEFAULT_DOCUMENT_TYPE = ''; + + /** + * @var string + */ + private $html = ''; + + /** + * @var string + */ + private $css = ''; + + /** + * @var bool[] + */ + private $excludedSelectors = array(); + + /** + * @var string[] + */ + private $unprocessableHtmlTags = array( 'wbr' ); + + /** + * @var bool[] + */ + private $allowedMediaTypes = array( 'all' => true, 'screen' => true, 'print' => true ); + + /** + * @var mixed[] + */ + private $caches = array( + self::CACHE_KEY_CSS => array(), + self::CACHE_KEY_SELECTOR => array(), + self::CACHE_KEY_XPATH => array(), + self::CACHE_KEY_CSS_DECLARATIONS_BLOCK => array(), + self::CACHE_KEY_COMBINED_STYLES => array(), + ); + + /** + * the visited nodes with the XPath paths as array keys + * + * @var \DOMElement[] + */ + private $visitedNodes = array(); + + /** + * the styles to apply to the nodes with the XPath paths as array keys for the outer array + * and the attribute names/values as key/value pairs for the inner array + * + * @var string[][] + */ + private $styleAttributesForNodes = array(); + + /** + * Determines whether the "style" attributes of tags in the the HTML passed to this class should be preserved. + * If set to false, the value of the style attributes will be discarded. + * + * @var bool + */ + private $isInlineStyleAttributesParsingEnabled = true; + + /** + * Determines whether the + post_type ) || ! in_array( $the_post->post_type, array( 'product', 'product_variation' ), true ) ) { + return; + } + + $GLOBALS['product'] = wc_get_product( $the_post ); + + return $GLOBALS['product']; +} +add_action( 'the_post', 'wc_setup_product_data' ); + +/** + * Sets up the woocommerce_loop global from the passed args or from the main query. + * + * @since 3.3.0 + * @param array $args Args to pass into the global. + */ +function wc_setup_loop( $args = array() ) { + $default_args = array( + 'loop' => 0, + 'columns' => wc_get_default_products_per_row(), + 'name' => '', + 'is_shortcode' => false, + 'is_paginated' => true, + 'is_search' => false, + 'is_filtered' => false, + 'total' => 0, + 'total_pages' => 0, + 'per_page' => 0, + 'current_page' => 1, + ); + + // If this is a main WC query, use global args as defaults. + if ( $GLOBALS['wp_query']->get( 'wc_query' ) ) { + $default_args = array_merge( $default_args, array( + 'is_search' => $GLOBALS['wp_query']->is_search(), + 'is_filtered' => is_filtered(), + 'total' => $GLOBALS['wp_query']->found_posts, + 'total_pages' => $GLOBALS['wp_query']->max_num_pages, + 'per_page' => $GLOBALS['wp_query']->get( 'posts_per_page' ), + 'current_page' => max( 1, $GLOBALS['wp_query']->get( 'paged', 1 ) ), + ) ); + } + + // Merge any existing values. + if ( isset( $GLOBALS['woocommerce_loop'] ) ) { + $default_args = array_merge( $default_args, $GLOBALS['woocommerce_loop'] ); + } + + $GLOBALS['woocommerce_loop'] = wp_parse_args( $args, $default_args ); +} +add_action( 'woocommerce_before_shop_loop', 'wc_setup_loop' ); + +/** + * Resets the woocommerce_loop global. + * + * @since 3.3.0 + */ +function wc_reset_loop() { + unset( $GLOBALS['woocommerce_loop'] ); +} +add_action( 'woocommerce_after_shop_loop', 'woocommerce_reset_loop', 999 ); + +/** + * Gets a property from the woocommerce_loop global. + * + * @since 3.3.0 + * @param string $prop Prop to get. + * @param string $default Default if the prop does not exist. + * @return mixed + */ +function wc_get_loop_prop( $prop, $default = '' ) { + wc_setup_loop(); // Ensure shop loop is setup. + + return isset( $GLOBALS['woocommerce_loop'], $GLOBALS['woocommerce_loop'][ $prop ] ) ? $GLOBALS['woocommerce_loop'][ $prop ] : $default; +} + +/** + * Sets a property in the woocommerce_loop global. + * + * @since 3.3.0 + * @param string $prop Prop to set. + * @param string $value Value to set. + */ +function wc_set_loop_prop( $prop, $value = '' ) { + if ( ! isset( $GLOBALS['woocommerce_loop'] ) ) { + wc_setup_loop(); + } + $GLOBALS['woocommerce_loop'][ $prop ] = $value; +} + +/** + * Should the WooCommerce loop be displayed? + * + * This will return true if we have posts (products) or if we have subcats to display. + * + * @since 3.4.0 + * @return bool + */ +function woocommerce_product_loop() { + return have_posts() || 'products' !== woocommerce_get_loop_display_mode(); +} + +/** + * Output generator tag to aid debugging. + * + * @access public + * + * @param string $gen Generator. + * @param string $type Type. + * + * @return string + */ +function wc_generator_tag( $gen, $type ) { + switch ( $type ) { + case 'html': + $gen .= "\n" . ''; + break; + case 'xhtml': + $gen .= "\n" . ''; + break; + } + return $gen; +} + +/** + * Add body classes for WC pages. + * + * @param array $classes Body Classes. + * @return array + */ +function wc_body_class( $classes ) { + $classes = (array) $classes; + + if ( is_woocommerce() ) { + + $classes[] = 'woocommerce'; + $classes[] = 'woocommerce-page'; + + } elseif ( is_checkout() ) { + + $classes[] = 'woocommerce-checkout'; + $classes[] = 'woocommerce-page'; + + } elseif ( is_cart() ) { + + $classes[] = 'woocommerce-cart'; + $classes[] = 'woocommerce-page'; + + } elseif ( is_account_page() ) { + + $classes[] = 'woocommerce-account'; + $classes[] = 'woocommerce-page'; + + } + + if ( is_store_notice_showing() ) { + $classes[] = 'woocommerce-demo-store'; + } + + foreach ( WC()->query->get_query_vars() as $key => $value ) { + if ( is_wc_endpoint_url( $key ) ) { + $classes[] = 'woocommerce-' . sanitize_html_class( $key ); + } + } + + $classes[] = 'woocommerce-no-js'; + + add_action( 'wp_footer', 'wc_no_js' ); + + return array_unique( $classes ); +} + +/** + * NO JS handling. + * + * @since 3.4.0 + */ +function wc_no_js() { + ?> + + $max_columns ) { + $columns = $max_columns; + update_option( 'woocommerce_catalog_columns', $columns ); + } + + if ( has_filter( 'loop_shop_columns' ) ) { // Legacy filter handling. + $columns = apply_filters( 'loop_shop_columns', $columns ); + } + + $columns = absint( $columns ); + + return max( 1, $columns ); +} + +/** + * Get the default rows setting - this is how many product rows will be shown in loops. + * + * @since 3.3.0 + * @return int + */ +function wc_get_default_product_rows_per_page() { + $rows = absint( get_option( 'woocommerce_catalog_rows', 4 ) ); + $product_grid = wc_get_theme_support( 'product_grid' ); + $min_rows = isset( $product_grid['min_rows'] ) ? absint( $product_grid['min_rows'] ) : 0; + $max_rows = isset( $product_grid['max_rows'] ) ? absint( $product_grid['max_rows'] ) : 0; + + if ( $min_rows && $rows < $min_rows ) { + $rows = $min_rows; + update_option( 'woocommerce_catalog_rows', $rows ); + } elseif ( $max_rows && $rows > $max_rows ) { + $rows = $max_rows; + update_option( 'woocommerce_catalog_rows', $rows ); + } + + return $rows; +} + +/** + * Reset the product grid settings when a new theme is activated. + * + * @since 3.3.0 + */ +function wc_reset_product_grid_settings() { + $product_grid = wc_get_theme_support( 'product_grid' ); + + if ( ! empty( $product_grid['default_rows'] ) ) { + update_option( 'woocommerce_catalog_rows', absint( $product_grid['default_rows'] ) ); + } + + if ( ! empty( $product_grid['default_columns'] ) ) { + update_option( 'woocommerce_catalog_columns', absint( $product_grid['default_columns'] ) ); + } +} +add_action( 'after_switch_theme', 'wc_reset_product_grid_settings' ); + +/** + * Get classname for woocommerce loops. + * + * @since 2.6.0 + * @return string + */ +function wc_get_loop_class() { + $loop_index = wc_get_loop_prop( 'loop', 0 ); + $columns = absint( max( 1, wc_get_loop_prop( 'columns', wc_get_default_products_per_row() ) ) ); + + $loop_index ++; + wc_set_loop_prop( 'loop', $loop_index ); + + if ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) { + return 'first'; + } elseif ( 0 === $loop_index % $columns ) { + return 'last'; + } else { + return ''; + } +} + + +/** + * Get the classes for the product cat div. + * + * @since 2.4.0 + * + * @param string|array $class One or more classes to add to the class list. + * @param object $category object Optional. + * + * @return array + */ +function wc_get_product_cat_class( $class = '', $category = null ) { + $classes = is_array( $class ) ? $class : array_map( 'trim', explode( ' ', $class ) ); + $classes[] = 'product-category'; + $classes[] = 'product'; + $classes[] = wc_get_loop_class(); + $classes = apply_filters( 'product_cat_class', $classes, $class, $category ); + + return array_unique( array_filter( $classes ) ); +} + +/** + * Adds extra post classes for products. + * + * @since 2.1.0 + * @param array $classes Current classes. + * @param string|array $class Additional class. + * @param int $post_id Post ID. + * @return array + */ +function wc_product_post_class( $classes, $class = '', $post_id = '' ) { + if ( ! $post_id || ! in_array( get_post_type( $post_id ), array( 'product', 'product_variation' ), true ) ) { + return $classes; + } + + $product = wc_get_product( $post_id ); + + if ( $product ) { + $classes[] = 'product'; + $classes[] = wc_get_loop_class(); + $classes[] = $product->get_stock_status(); + + if ( $product->is_on_sale() ) { + $classes[] = 'sale'; + } + if ( $product->is_featured() ) { + $classes[] = 'featured'; + } + if ( $product->is_downloadable() ) { + $classes[] = 'downloadable'; + } + if ( $product->is_virtual() ) { + $classes[] = 'virtual'; + } + if ( $product->is_sold_individually() ) { + $classes[] = 'sold-individually'; + } + if ( $product->is_taxable() ) { + $classes[] = 'taxable'; + } + if ( $product->is_shipping_taxable() ) { + $classes[] = 'shipping-taxable'; + } + if ( $product->is_purchasable() ) { + $classes[] = 'purchasable'; + } + if ( $product->get_type() ) { + $classes[] = 'product-type-' . $product->get_type(); + } + if ( $product->is_type( 'variable' ) ) { + if ( ! $product->get_default_attributes() ) { + $classes[] = 'has-default-attributes'; + } + } + } + + $key = array_search( 'hentry', $classes, true ); + if ( false !== $key ) { + unset( $classes[ $key ] ); + } + + return $classes; +} + +/** + * Get product taxonomy HTML classes. + * + * @since 3.4.0 + * @param array $term_ids Array of terms IDs or objects. + * @param string $taxonomy Taxonomy. + * @return array + */ +function wc_get_product_taxonomy_class( $term_ids, $taxonomy ) { + $classes = array(); + + foreach ( $term_ids as $term_id ) { + $term = get_term( $term_id, $taxonomy ); + + if ( empty( $term->slug ) ) { + continue; + } + + $term_class = sanitize_html_class( $term->slug, $term->term_id ); + if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { + $term_class = $term->term_id; + } + + // 'post_tag' uses the 'tag' prefix for backward compatibility. + if ( 'post_tag' === $taxonomy ) { + $classes[] = 'tag-' . $term_class; + } else { + $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); + } + } + + return $classes; +} + +/** + * Retrieves the classes for the post div as an array. + * + * This method is clone from WordPress's get_post_class(), allowing removing taxonomies. + * + * @since 3.4.0 + * @param string|array $class One or more classes to add to the class list. + * @param int|WP_Post|WC_Product $product_id Product ID or product object. + * @return array + */ +function wc_get_product_class( $class = '', $product_id = null ) { + if ( is_a( $product_id, 'WC_Product' ) ) { + $product = $product_id; + $product_id = $product_id->get_id(); + $post = get_post( $product_id ); + } else { + $post = get_post( $product_id ); + $product = wc_get_product( $post->ID ); + } + + $classes = array(); + + if ( $class ) { + if ( ! is_array( $class ) ) { + $class = preg_split( '#\s+#', $class ); + } + $classes = array_map( 'esc_attr', $class ); + } else { + // Ensure that we always coerce class to being an array. + $class = array(); + } + + if ( ! $post || ! $product ) { + return $classes; + } + + $classes[] = 'post-' . $post->ID; + if ( ! is_admin() ) { + $classes[] = $post->post_type; + } + $classes[] = 'type-' . $post->post_type; + $classes[] = 'status-' . $post->post_status; + + // Post format. + if ( post_type_supports( $post->post_type, 'post-formats' ) ) { + $post_format = get_post_format( $post->ID ); + + if ( $post_format && ! is_wp_error( $post_format ) ) { + $classes[] = 'format-' . sanitize_html_class( $post_format ); + } else { + $classes[] = 'format-standard'; + } + } + + // Post requires password. + $post_password_required = post_password_required( $post->ID ); + if ( $post_password_required ) { + $classes[] = 'post-password-required'; + } elseif ( ! empty( $post->post_password ) ) { + $classes[] = 'post-password-protected'; + } + + // Post thumbnails. + if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) { + $classes[] = 'has-post-thumbnail'; + } + + // Sticky for Sticky Posts. + if ( is_sticky( $post->ID ) ) { + if ( is_home() && ! is_paged() ) { + $classes[] = 'sticky'; + } elseif ( is_admin() ) { + $classes[] = 'status-sticky'; + } + } + + // Hentry for hAtom compliance. + $classes[] = 'hentry'; + + // Include attributes and any extra taxonomy. + if ( apply_filters( 'woocommerce_get_product_class_include_taxonomies', false ) ) { + $taxonomies = get_taxonomies( array( 'public' => true ) ); + foreach ( (array) $taxonomies as $taxonomy ) { + if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) && in_array( $taxonomy, array( 'product_cat', 'product_tag' ), true ) ) { + $classes = array_merge( $classes, wc_get_product_taxonomy_class( (array) get_the_terms( $post->ID, $taxonomy ), $taxonomy ) ); + } + } + } + // Categories. + $classes = array_merge( $classes, wc_get_product_taxonomy_class( $product->get_category_ids(), 'product_cat' ) ); + + // Tags. + $classes = array_merge( $classes, wc_get_product_taxonomy_class( $product->get_tag_ids(), 'product_tag' ) ); + + return array_filter( array_unique( apply_filters( 'post_class', $classes, $class, $post->ID ) ) ); +} + +/** + * Display the classes for the product div. + * + * @since 3.4.0 + * @param string|array $class One or more classes to add to the class list. + * @param int|WP_Post|WC_Product $product_id Product ID or product object. + */ +function wc_product_class( $class = '', $product_id = null ) { + echo 'class="' . esc_attr( join( ' ', wc_get_product_class( $class, $product_id ) ) ) . '"'; +} + +/** + * Outputs hidden form inputs for each query string variable. + * + * @since 3.0.0 + * @param string|array $values Name value pairs, or a URL to parse. + * @param array $exclude Keys to exclude. + * @param string $current_key Current key we are outputting. + * @param bool $return Whether to return. + * @return string + */ +function wc_query_string_form_fields( $values = null, $exclude = array(), $current_key = '', $return = false ) { + if ( is_null( $values ) ) { + $values = $_GET; // WPCS: input var ok, CSRF ok. + } elseif ( is_string( $values ) ) { + $url_parts = wp_parse_url( $values ); + $values = array(); + + if ( ! empty( $url_parts['query'] ) ) { + parse_str( $url_parts['query'], $values ); + } + } + $html = ''; + + foreach ( $values as $key => $value ) { + if ( in_array( $key, $exclude, true ) ) { + continue; + } + if ( $current_key ) { + $key = $current_key . '[' . $key . ']'; + } + if ( is_array( $value ) ) { + $html .= wc_query_string_form_fields( $value, $exclude, $key, true ); + } else { + $html .= ''; + } + } + + if ( $return ) { + return $html; + } else { + echo $html; // WPCS: XSS ok. + } +} + +/** + * Get the terms and conditons page ID. + * + * @since 3.4.0 + * @return int + */ +function wc_terms_and_conditions_page_id() { + $page_id = wc_get_page_id( 'terms' ); + return apply_filters( 'woocommerce_terms_and_conditions_page_id', 0 < $page_id ? absint( $page_id ) : 0 ); +} + +/** + * Get the privacy policy page ID. + * + * @since 3.4.0 + * @return int + */ +function wc_privacy_policy_page_id() { + $page_id = get_option( 'wp_page_for_privacy_policy', 0 ); + return apply_filters( 'woocommerce_privacy_policy_page_id', 0 < $page_id ? absint( $page_id ) : 0 ); +} + +/** + * See if the checkbox is enabled or not based on the existance of the terms page and checkbox text. + * + * @since 3.4.0 + * @return bool + */ +function wc_terms_and_conditions_checkbox_enabled() { + $page_id = wc_terms_and_conditions_page_id(); + $page = $page_id ? get_post( $page_id ) : false; + return $page && wc_get_terms_and_conditions_checkbox_text(); +} + +/** + * Get the terms and conditons checkbox text, if set. + * + * @since 3.4.0 + * @return string + */ +function wc_get_terms_and_conditions_checkbox_text() { + /* translators: %s terms and conditions page name and link */ + return trim( apply_filters( 'woocommerce_get_terms_and_conditions_checkbox_text', get_option( 'woocommerce_checkout_terms_and_conditions_checkbox_text', sprintf( __( 'I have read and agree to the website %s', 'woocommerce' ), '[terms]' ) ) ) ); +} + +/** + * Get the privacy policy text, if set. + * + * @since 3.4.0 + * @param string $type Type of policy to load. Valid values include registration and checkout. + * @return string + */ +function wc_get_privacy_policy_text( $type = '' ) { + $text = ''; + + switch ( $type ) { + case 'checkout': + /* translators: %s privacy policy page name and link */ + $text = get_option( 'woocommerce_checkout_privacy_policy_text', sprintf( __( 'Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our %s.', 'woocommerce' ), '[privacy_policy]' ) ); + break; + case 'registration': + /* translators: %s privacy policy page name and link */ + $text = get_option( 'woocommerce_registration_privacy_policy_text', sprintf( __( 'Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our %s.', 'woocommerce' ), '[privacy_policy]' ) ); + break; + } + + return trim( apply_filters( 'woocommerce_get_privacy_policy_text', $text, $type ) ); +} + +/** + * Output t&c checkbox text. + * + * @since 3.4.0 + */ +function wc_terms_and_conditions_checkbox_text() { + $text = wc_get_terms_and_conditions_checkbox_text(); + + if ( ! $text ) { + return; + } + + echo wp_kses_post( wc_replace_policy_page_link_placeholders( $text ) ); +} + +/** + * Output t&c page's content (if set). The page can be set from checkout settings. + * + * @since 3.4.0 + */ +function wc_terms_and_conditions_page_content() { + $terms_page_id = wc_terms_and_conditions_page_id(); + + if ( ! $terms_page_id ) { + return; + } + + $page = get_post( $terms_page_id ); + + if ( $page && 'publish' === $page->post_status && $page->post_content && ! has_shortcode( $page->post_content, 'woocommerce_checkout' ) ) { + echo ''; + } +} + +/** + * Render privacy policy text on the checkout. + * + * @since 3.4.0 + */ +function wc_checkout_privacy_policy_text() { + echo '
      '; + wc_privacy_policy_text( 'checkout' ); + echo '
      '; +} + +/** + * Render privacy policy text on the register forms. + * + * @since 3.4.0 + */ +function wc_registration_privacy_policy_text() { + echo '
      '; + wc_privacy_policy_text( 'registration' ); + echo '
      '; +} + +/** + * Output privacy policy text. This is custom text which can be added via the customizer/privacy settings section. + * + * Loads the relevant policy for the current page unless a specific policy text is required. + * + * @since 3.4.0 + * @param string $type Type of policy to load. Valid values include registration and checkout. + */ +function wc_privacy_policy_text( $type = 'checkout' ) { + if ( ! wc_privacy_policy_page_id() ) { + return; + } + echo wp_kses_post( wpautop( wc_replace_policy_page_link_placeholders( wc_get_privacy_policy_text( $type ) ) ) ); +} + +/** + * Replaces placeholders with links to WooCommerce policy pages. + * + * @since 3.4.0 + * @param string $text Text to find/replace within. + * @return string + */ +function wc_replace_policy_page_link_placeholders( $text ) { + $privacy_page_id = wc_privacy_policy_page_id(); + $terms_page_id = wc_terms_and_conditions_page_id(); + $privacy_link = $privacy_page_id ? '' . __( 'privacy policy', 'woocommerce' ) . '' : __( 'privacy policy', 'woocommerce' ); + $terms_link = $terms_page_id ? '' . __( 'terms and conditions', 'woocommerce' ) . '' : __( 'terms and conditions', 'woocommerce' ); + + $find_replace = array( + '[terms]' => $terms_link, + '[privacy_policy]' => $privacy_link, + ); + + return str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); +} + +/** + * Template pages + */ + +if ( ! function_exists( 'woocommerce_content' ) ) { + + /** + * Output WooCommerce content. + * + * This function is only used in the optional 'woocommerce.php' template. + * which people can add to their themes to add basic woocommerce support. + * without hooks or modifying core templates. + */ + function woocommerce_content() { + + if ( is_singular( 'product' ) ) { + + while ( have_posts() ) : + the_post(); + wc_get_template_part( 'content', 'single-product' ); + endwhile; + + } else { + ?> + + + +

      + + + + + + + + + + + + + + + + + + + + + + + + + + + ' . wp_kses_post( $notice ) . ' ' . esc_html__( 'Dismiss', 'woocommerce' ) . '

      ', $notice ); // WPCS: XSS ok. + } +} + +/** + * Loop + */ + +if ( ! function_exists( 'woocommerce_page_title' ) ) { + + /** + * Page Title function. + * + * @param bool $echo Should echo title. + * @return string + */ + function woocommerce_page_title( $echo = true ) { + + if ( is_search() ) { + /* translators: %s: search query */ + $page_title = sprintf( __( 'Search results: “%s”', 'woocommerce' ), get_search_query() ); + + if ( get_query_var( 'paged' ) ) { + /* translators: %s: page number */ + $page_title .= sprintf( __( ' – Page %s', 'woocommerce' ), get_query_var( 'paged' ) ); + } + } elseif ( is_tax() ) { + + $page_title = single_term_title( '', false ); + + } else { + + $shop_page_id = wc_get_page_id( 'shop' ); + $page_title = get_the_title( $shop_page_id ); + + } + + $page_title = apply_filters( 'woocommerce_page_title', $page_title ); + + if ( $echo ) { + echo $page_title; // WPCS: XSS ok. + } else { + return $page_title; + } + } +} + +if ( ! function_exists( 'woocommerce_product_loop_start' ) ) { + + /** + * Output the start of a product loop. By default this is a UL. + * + * @param bool $echo Should echo?. + * @return string + */ + function woocommerce_product_loop_start( $echo = true ) { + ob_start(); + + wc_set_loop_prop( 'loop', 0 ); + + wc_get_template( 'loop/loop-start.php' ); + + $loop_start = apply_filters( 'woocommerce_product_loop_start', ob_get_clean() ); + + if ( $echo ) { + echo $loop_start; // WPCS: XSS ok. + } else { + return $loop_start; + } + } +} + +if ( ! function_exists( 'woocommerce_product_loop_end' ) ) { + + /** + * Output the end of a product loop. By default this is a UL. + * + * @param bool $echo Should echo?. + * @return string + */ + function woocommerce_product_loop_end( $echo = true ) { + ob_start(); + + wc_get_template( 'loop/loop-end.php' ); + + $loop_end = apply_filters( 'woocommerce_product_loop_end', ob_get_clean() ); + + if ( $echo ) { + echo $loop_end; // WPCS: XSS ok. + } else { + return $loop_end; + } + } +} +if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) { + + /** + * Show the product title in the product loop. By default this is an H2. + */ + function woocommerce_template_loop_product_title() { + echo '

      ' . get_the_title() . '

      '; + } +} +if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) { + + /** + * Show the subcategory title in the product loop. + * + * @param object $category Category object. + */ + function woocommerce_template_loop_category_title( $category ) { + ?> +

      + name ); + + if ( $category->count > 0 ) { + echo apply_filters( 'woocommerce_subcategory_count_html', ' (' . esc_html( $category->count ) . ')', $category ); // WPCS: XSS ok. + } + ?> +

      + '; + } +} + +if ( ! function_exists( 'woocommerce_template_loop_product_link_close' ) ) { + /** + * Insert the opening anchor tag for products in the loop. + */ + function woocommerce_template_loop_product_link_close() { + echo ''; + } +} + +if ( ! function_exists( 'woocommerce_template_loop_category_link_open' ) ) { + /** + * Insert the opening anchor tag for categories in the loop. + * + * @param int|object|string $category Category ID, Object or String. + */ + function woocommerce_template_loop_category_link_open( $category ) { + echo ''; + } +} + +if ( ! function_exists( 'woocommerce_template_loop_category_link_close' ) ) { + /** + * Insert the closing anchor tag for categories in the loop. + */ + function woocommerce_template_loop_category_link_close() { + echo ''; + } +} + +if ( ! function_exists( 'woocommerce_taxonomy_archive_description' ) ) { + + /** + * Show an archive description on taxonomy archives. + */ + function woocommerce_taxonomy_archive_description() { + if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) { + $term = get_queried_object(); + + if ( $term && ! empty( $term->description ) ) { + echo '
      ' . wc_format_content( $term->description ) . '
      '; // WPCS: XSS ok. + } + } + } +} +if ( ! function_exists( 'woocommerce_product_archive_description' ) ) { + + /** + * Show a shop page description on product archives. + */ + function woocommerce_product_archive_description() { + // Don't display the description on search results page. + if ( is_search() ) { + return; + } + + if ( is_post_type_archive( 'product' ) && in_array( absint( get_query_var( 'paged' ) ), array( 0, 1 ), true ) ) { + $shop_page = get_post( wc_get_page_id( 'shop' ) ); + if ( $shop_page ) { + $description = wc_format_content( $shop_page->post_content ); + if ( $description ) { + echo '
      ' . $description . '
      '; // WPCS: XSS ok. + } + } + } + } +} + +if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) { + + /** + * Get the add to cart template for the loop. + * + * @param array $args Arguments. + */ + function woocommerce_template_loop_add_to_cart( $args = array() ) { + global $product; + + if ( $product ) { + $defaults = array( + 'quantity' => 1, + 'class' => implode( ' ', array_filter( array( + 'button', + 'product_type_' . $product->get_type(), + $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', + $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', + ) ) ), + 'attributes' => array( + 'data-product_id' => $product->get_id(), + 'data-product_sku' => $product->get_sku(), + 'aria-label' => $product->add_to_cart_description(), + 'rel' => 'nofollow', + ), + ); + + $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); + + if ( isset( $args['attributes']['aria-label'] ) ) { + $args['attributes']['aria-label'] = strip_tags( $args['attributes']['aria-label'] ); + } + + wc_get_template( 'loop/add-to-cart.php', $args ); + } + } +} + +if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) { + + /** + * Get the product thumbnail for the loop. + */ + function woocommerce_template_loop_product_thumbnail() { + echo woocommerce_get_product_thumbnail(); // WPCS: XSS ok. + } +} +if ( ! function_exists( 'woocommerce_template_loop_price' ) ) { + + /** + * Get the product price for the loop. + */ + function woocommerce_template_loop_price() { + wc_get_template( 'loop/price.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_loop_rating' ) ) { + + /** + * Display the average rating in the loop. + */ + function woocommerce_template_loop_rating() { + wc_get_template( 'loop/rating.php' ); + } +} +if ( ! function_exists( 'woocommerce_show_product_loop_sale_flash' ) ) { + + /** + * Get the sale flash for the loop. + */ + function woocommerce_show_product_loop_sale_flash() { + wc_get_template( 'loop/sale-flash.php' ); + } +} + +if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) { + + /** + * Get the product thumbnail, or the placeholder if not set. + * + * @param string $size (default: 'woocommerce_thumbnail'). + * @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0). + * @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0). + * @return string + */ + function woocommerce_get_product_thumbnail( $size = 'woocommerce_thumbnail', $deprecated1 = 0, $deprecated2 = 0 ) { + global $product; + + $image_size = apply_filters( 'single_product_archive_thumbnail_size', $size ); + + return $product ? $product->get_image( $image_size ) : ''; + } +} + +if ( ! function_exists( 'woocommerce_result_count' ) ) { + + /** + * Output the result count text (Showing x - x of x results). + */ + function woocommerce_result_count() { + if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { + return; + } + $args = array( + 'total' => wc_get_loop_prop( 'total' ), + 'per_page' => wc_get_loop_prop( 'per_page' ), + 'current' => wc_get_loop_prop( 'current_page' ), + ); + + wc_get_template( 'loop/result-count.php', $args ); + } +} + +if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) { + + /** + * Output the product sorting options. + */ + function woocommerce_catalog_ordering() { + if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { + return; + } + $show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); + $catalog_orderby_options = apply_filters( 'woocommerce_catalog_orderby', array( + 'menu_order' => __( 'Default sorting', 'woocommerce' ), + 'popularity' => __( 'Sort by popularity', 'woocommerce' ), + 'rating' => __( 'Sort by average rating', 'woocommerce' ), + 'date' => __( 'Sort by newness', 'woocommerce' ), + 'price' => __( 'Sort by price: low to high', 'woocommerce' ), + 'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ), + ) ); + + $default_orderby = wc_get_loop_prop( 'is_search' ) ? 'relevance' : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', '' ) ); + $orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby; // WPCS: sanitization ok, input var ok, CSRF ok. + + if ( wc_get_loop_prop( 'is_search' ) ) { + $catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options ); + + unset( $catalog_orderby_options['menu_order'] ); + } + + if ( ! $show_default_orderby ) { + unset( $catalog_orderby_options['menu_order'] ); + } + + if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) { + unset( $catalog_orderby_options['rating'] ); + } + + if ( ! array_key_exists( $orderby, $catalog_orderby_options ) ) { + $orderby = current( array_keys( $catalog_orderby_options ) ); + } + + wc_get_template( 'loop/orderby.php', array( + 'catalog_orderby_options' => $catalog_orderby_options, + 'orderby' => $orderby, + 'show_default_orderby' => $show_default_orderby, + ) ); + } +} + +if ( ! function_exists( 'woocommerce_pagination' ) ) { + + /** + * Output the pagination. + */ + function woocommerce_pagination() { + if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { + return; + } + + $args = array( + 'total' => wc_get_loop_prop( 'total_pages' ), + 'current' => wc_get_loop_prop( 'current_page' ), + 'base' => esc_url_raw( add_query_arg( 'product-page', '%#%', false ) ), + 'format' => '?product-page=%#%', + ); + + if ( ! wc_get_loop_prop( 'is_shortcode' ) ) { + $args['format'] = ''; + $args['base'] = esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) ); + } + + wc_get_template( 'loop/pagination.php', $args ); + } +} + +/** + * Single Product + */ + +if ( ! function_exists( 'woocommerce_show_product_images' ) ) { + + /** + * Output the product image before the single product summary. + */ + function woocommerce_show_product_images() { + wc_get_template( 'single-product/product-image.php' ); + } +} +if ( ! function_exists( 'woocommerce_show_product_thumbnails' ) ) { + + /** + * Output the product thumbnails. + */ + function woocommerce_show_product_thumbnails() { + wc_get_template( 'single-product/product-thumbnails.php' ); + } +} + +/** + * Get HTML for a gallery image. + * + * Woocommerce_gallery_thumbnail_size, woocommerce_gallery_image_size and woocommerce_gallery_full_size accept name based image sizes, or an array of width/height values. + * + * @since 3.3.2 + * @param int $attachment_id Attachment ID. + * @param bool $main_image Is this the main image or a thumbnail?. + * @return string + */ +function wc_get_gallery_image_html( $attachment_id, $main_image = false ) { + $flexslider = (bool) apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) ); + $gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' ); + $thumbnail_size = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) ); + $image_size = apply_filters( 'woocommerce_gallery_image_size', $flexslider || $main_image ? 'woocommerce_single' : $thumbnail_size ); + $full_size = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) ); + $thumbnail_src = wp_get_attachment_image_src( $attachment_id, $thumbnail_size ); + $full_src = wp_get_attachment_image_src( $attachment_id, $full_size ); + $image = wp_get_attachment_image( $attachment_id, $image_size, false, array( + 'title' => get_post_field( 'post_title', $attachment_id ), + 'data-caption' => get_post_field( 'post_excerpt', $attachment_id ), + 'data-src' => $full_src[0], + 'data-large_image' => $full_src[0], + 'data-large_image_width' => $full_src[1], + 'data-large_image_height' => $full_src[2], + 'class' => $main_image ? 'wp-post-image' : '', + ) ); + + return ''; +} + +if ( ! function_exists( 'woocommerce_output_product_data_tabs' ) ) { + + /** + * Output the product tabs. + */ + function woocommerce_output_product_data_tabs() { + wc_get_template( 'single-product/tabs/tabs.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_single_title' ) ) { + + /** + * Output the product title. + */ + function woocommerce_template_single_title() { + wc_get_template( 'single-product/title.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_single_rating' ) ) { + + /** + * Output the product rating. + */ + function woocommerce_template_single_rating() { + if ( post_type_supports( 'product', 'comments' ) ) { + wc_get_template( 'single-product/rating.php' ); + } + } +} +if ( ! function_exists( 'woocommerce_template_single_price' ) ) { + + /** + * Output the product price. + */ + function woocommerce_template_single_price() { + wc_get_template( 'single-product/price.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_single_excerpt' ) ) { + + /** + * Output the product short description (excerpt). + */ + function woocommerce_template_single_excerpt() { + wc_get_template( 'single-product/short-description.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_single_meta' ) ) { + + /** + * Output the product meta. + */ + function woocommerce_template_single_meta() { + wc_get_template( 'single-product/meta.php' ); + } +} +if ( ! function_exists( 'woocommerce_template_single_sharing' ) ) { + + /** + * Output the product sharing. + */ + function woocommerce_template_single_sharing() { + wc_get_template( 'single-product/share.php' ); + } +} +if ( ! function_exists( 'woocommerce_show_product_sale_flash' ) ) { + + /** + * Output the product sale flash. + */ + function woocommerce_show_product_sale_flash() { + wc_get_template( 'single-product/sale-flash.php' ); + } +} + +if ( ! function_exists( 'woocommerce_template_single_add_to_cart' ) ) { + + /** + * Trigger the single product add to cart action. + */ + function woocommerce_template_single_add_to_cart() { + global $product; + do_action( 'woocommerce_' . $product->get_type() . '_add_to_cart' ); + } +} +if ( ! function_exists( 'woocommerce_simple_add_to_cart' ) ) { + + /** + * Output the simple product add to cart area. + */ + function woocommerce_simple_add_to_cart() { + wc_get_template( 'single-product/add-to-cart/simple.php' ); + } +} +if ( ! function_exists( 'woocommerce_grouped_add_to_cart' ) ) { + + /** + * Output the grouped product add to cart area. + */ + function woocommerce_grouped_add_to_cart() { + global $product; + + $products = array_filter( array_map( 'wc_get_product', $product->get_children() ), 'wc_products_array_filter_visible_grouped' ); + + if ( $products ) { + wc_get_template( 'single-product/add-to-cart/grouped.php', array( + 'grouped_product' => $product, + 'grouped_products' => $products, + 'quantites_required' => false, + ) ); + } + } +} +if ( ! function_exists( 'woocommerce_variable_add_to_cart' ) ) { + + /** + * Output the variable product add to cart area. + */ + function woocommerce_variable_add_to_cart() { + global $product; + + // Enqueue variation scripts. + wp_enqueue_script( 'wc-add-to-cart-variation' ); + + // Get Available variations? + $get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product ); + + // Load the template. + wc_get_template( 'single-product/add-to-cart/variable.php', array( + 'available_variations' => $get_variations ? $product->get_available_variations() : false, + 'attributes' => $product->get_variation_attributes(), + 'selected_attributes' => $product->get_default_attributes(), + ) ); + } +} +if ( ! function_exists( 'woocommerce_external_add_to_cart' ) ) { + + /** + * Output the external product add to cart area. + */ + function woocommerce_external_add_to_cart() { + global $product; + + if ( ! $product->add_to_cart_url() ) { + return; + } + + wc_get_template( 'single-product/add-to-cart/external.php', array( + 'product_url' => $product->add_to_cart_url(), + 'button_text' => $product->single_add_to_cart_text(), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_quantity_input' ) ) { + + /** + * Output the quantity input for add to cart forms. + * + * @param array $args Args for the input. + * @param WC_Product|null $product Product. + * @param boolean $echo Whether to return or echo|string. + * + * @return string + */ + function woocommerce_quantity_input( $args = array(), $product = null, $echo = true ) { + if ( is_null( $product ) ) { + $product = $GLOBALS['product']; + } + + $defaults = array( + 'input_id' => uniqid( 'quantity_' ), + 'input_name' => 'quantity', + 'input_value' => '1', + 'max_value' => apply_filters( 'woocommerce_quantity_input_max', -1, $product ), + 'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $product ), + 'step' => apply_filters( 'woocommerce_quantity_input_step', 1, $product ), + 'pattern' => apply_filters( 'woocommerce_quantity_input_pattern', has_filter( 'woocommerce_stock_amount', 'intval' ) ? '[0-9]*' : '' ), + 'inputmode' => apply_filters( 'woocommerce_quantity_input_inputmode', has_filter( 'woocommerce_stock_amount', 'intval' ) ? 'numeric' : '' ), + ); + + $args = apply_filters( 'woocommerce_quantity_input_args', wp_parse_args( $args, $defaults ), $product ); + + // Apply sanity to min/max args - min cannot be lower than 0. + $args['min_value'] = max( $args['min_value'], 0 ); + $args['max_value'] = 0 < $args['max_value'] ? $args['max_value'] : ''; + + // Max cannot be lower than min if defined. + if ( '' !== $args['max_value'] && $args['max_value'] < $args['min_value'] ) { + $args['max_value'] = $args['min_value']; + } + + ob_start(); + + wc_get_template( 'global/quantity-input.php', $args ); + + if ( $echo ) { + echo ob_get_clean(); // WPCS: XSS ok. + } else { + return ob_get_clean(); + } + } +} + +if ( ! function_exists( 'woocommerce_product_description_tab' ) ) { + + /** + * Output the description tab content. + */ + function woocommerce_product_description_tab() { + wc_get_template( 'single-product/tabs/description.php' ); + } +} +if ( ! function_exists( 'woocommerce_product_additional_information_tab' ) ) { + + /** + * Output the attributes tab content. + */ + function woocommerce_product_additional_information_tab() { + wc_get_template( 'single-product/tabs/additional-information.php' ); + } +} +if ( ! function_exists( 'woocommerce_default_product_tabs' ) ) { + + /** + * Add default product tabs to product pages. + * + * @param array $tabs Array of tabs. + * @return array + */ + function woocommerce_default_product_tabs( $tabs = array() ) { + global $product, $post; + + // Description tab - shows product content. + if ( $post->post_content ) { + $tabs['description'] = array( + 'title' => __( 'Description', 'woocommerce' ), + 'priority' => 10, + 'callback' => 'woocommerce_product_description_tab', + ); + } + + // Additional information tab - shows attributes. + if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) { + $tabs['additional_information'] = array( + 'title' => __( 'Additional information', 'woocommerce' ), + 'priority' => 20, + 'callback' => 'woocommerce_product_additional_information_tab', + ); + } + + // Reviews tab - shows comments. + if ( comments_open() ) { + $tabs['reviews'] = array( + /* translators: %s: reviews count */ + 'title' => sprintf( __( 'Reviews (%d)', 'woocommerce' ), $product->get_review_count() ), + 'priority' => 30, + 'callback' => 'comments_template', + ); + } + + return $tabs; + } +} + +if ( ! function_exists( 'woocommerce_sort_product_tabs' ) ) { + + /** + * Sort tabs by priority. + * + * @param array $tabs Array of tabs. + * @return array + */ + function woocommerce_sort_product_tabs( $tabs = array() ) { + + // Make sure the $tabs parameter is an array. + if ( ! is_array( $tabs ) ) { + trigger_error( 'Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array.' ); // @codingStandardsIgnoreLine + $tabs = array(); + } + + // Re-order tabs by priority. + if ( ! function_exists( '_sort_priority_callback' ) ) { + /** + * Sort Priority Callback Function + * + * @param array $a Comparison A. + * @param array $b Comparison B. + * @return bool + */ + function _sort_priority_callback( $a, $b ) { + if ( ! isset( $a['priority'], $b['priority'] ) || $a['priority'] === $b['priority'] ) { + return 0; + } + return ( $a['priority'] < $b['priority'] ) ? -1 : 1; + } + } + + uasort( $tabs, '_sort_priority_callback' ); + + return $tabs; + } +} + +if ( ! function_exists( 'woocommerce_comments' ) ) { + + /** + * Output the Review comments template. + * + * @param WP_Comment $comment Comment object. + * @param array $args Arguments. + * @param int $depth Depth. + */ + function woocommerce_comments( $comment, $args, $depth ) { + $GLOBALS['comment'] = $comment; // WPCS: override ok. + wc_get_template( 'single-product/review.php', array( + 'comment' => $comment, + 'args' => $args, + 'depth' => $depth, + ) ); + } +} + +if ( ! function_exists( 'woocommerce_review_display_gravatar' ) ) { + /** + * Display the review authors gravatar + * + * @param array $comment WP_Comment. + * @return void + */ + function woocommerce_review_display_gravatar( $comment ) { + echo get_avatar( $comment, apply_filters( 'woocommerce_review_gravatar_size', '60' ), '' ); + } +} + +if ( ! function_exists( 'woocommerce_review_display_rating' ) ) { + /** + * Display the reviewers star rating + * + * @return void + */ + function woocommerce_review_display_rating() { + if ( post_type_supports( 'product', 'comments' ) ) { + wc_get_template( 'single-product/review-rating.php' ); + } + } +} + +if ( ! function_exists( 'woocommerce_review_display_meta' ) ) { + /** + * Display the review authors meta (name, verified owner, review date) + * + * @return void + */ + function woocommerce_review_display_meta() { + wc_get_template( 'single-product/review-meta.php' ); + } +} + +if ( ! function_exists( 'woocommerce_review_display_comment_text' ) ) { + + /** + * Display the review content. + */ + function woocommerce_review_display_comment_text() { + echo '
      '; + comment_text(); + echo '
      '; + } +} + +if ( ! function_exists( 'woocommerce_output_related_products' ) ) { + + /** + * Output the related products. + */ + function woocommerce_output_related_products() { + + $args = array( + 'posts_per_page' => 4, + 'columns' => 4, + 'orderby' => 'rand', // @codingStandardsIgnoreLine. + ); + + woocommerce_related_products( apply_filters( 'woocommerce_output_related_products_args', $args ) ); + } +} + +if ( ! function_exists( 'woocommerce_related_products' ) ) { + + /** + * Output the related products. + * + * @param array $args Provided arguments. + */ + function woocommerce_related_products( $args = array() ) { + global $product; + + if ( ! $product ) { + return; + } + + $defaults = array( + 'posts_per_page' => 2, + 'columns' => 2, + 'orderby' => 'rand', // @codingStandardsIgnoreLine. + 'order' => 'desc', + ); + + $args = wp_parse_args( $args, $defaults ); + + // Get visible related products then sort them at random. + $args['related_products'] = array_filter( array_map( 'wc_get_product', wc_get_related_products( $product->get_id(), $args['posts_per_page'], $product->get_upsell_ids() ) ), 'wc_products_array_filter_visible' ); + + // Handle orderby. + $args['related_products'] = wc_products_array_orderby( $args['related_products'], $args['orderby'], $args['order'] ); + + // Set global loop values. + wc_set_loop_prop( 'name', 'related' ); + wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_related_products_columns', $args['columns'] ) ); + + wc_get_template( 'single-product/related.php', $args ); + } +} + +if ( ! function_exists( 'woocommerce_upsell_display' ) ) { + + /** + * Output product up sells. + * + * @param int $limit (default: -1). + * @param int $columns (default: 4). + * @param string $orderby Supported values - rand, title, ID, date, modified, menu_order, price. + * @param string $order Sort direction. + */ + function woocommerce_upsell_display( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' ) { + global $product; + + if ( ! $product ) { + return; + } + + // Handle the legacy filter which controlled posts per page etc. + $args = apply_filters( 'woocommerce_upsell_display_args', array( + 'posts_per_page' => $limit, + 'orderby' => $orderby, + 'columns' => $columns, + ) ); + wc_set_loop_prop( 'name', 'up-sells' ); + wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_upsells_columns', isset( $args['columns'] ) ? $args['columns'] : $columns ) ); + + $orderby = apply_filters( 'woocommerce_upsells_orderby', isset( $args['orderby'] ) ? $args['orderby'] : $orderby ); + $limit = apply_filters( 'woocommerce_upsells_total', isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : $limit ); + + // Get visible upsells then sort them at random, then limit result set. + $upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), $orderby, $order ); + $upsells = $limit > 0 ? array_slice( $upsells, 0, $limit ) : $upsells; + + wc_get_template( 'single-product/up-sells.php', array( + 'upsells' => $upsells, + + // Not used now, but used in previous version of up-sells.php. + 'posts_per_page' => $limit, + 'orderby' => $orderby, + 'columns' => $columns, + ) ); + } +} + +/** Cart */ + +if ( ! function_exists( 'woocommerce_shipping_calculator' ) ) { + + /** + * Output the cart shipping calculator. + */ + function woocommerce_shipping_calculator() { + wc_get_template( 'cart/shipping-calculator.php' ); + } +} + +if ( ! function_exists( 'woocommerce_cart_totals' ) ) { + + /** + * Output the cart totals. + */ + function woocommerce_cart_totals() { + if ( is_checkout() ) { + return; + } + wc_get_template( 'cart/cart-totals.php' ); + } +} + +if ( ! function_exists( 'woocommerce_cross_sell_display' ) ) { + + /** + * Output the cart cross-sells. + * + * @param int $limit (default: 2). + * @param int $columns (default: 2). + * @param string $orderby (default: 'rand'). + * @param string $order (default: 'desc'). + */ + function woocommerce_cross_sell_display( $limit = 2, $columns = 2, $orderby = 'rand', $order = 'desc' ) { + if ( is_checkout() ) { + return; + } + // Get visible cross sells then sort them at random. + $cross_sells = array_filter( array_map( 'wc_get_product', WC()->cart->get_cross_sells() ), 'wc_products_array_filter_visible' ); + + wc_set_loop_prop( 'name', 'cross-sells' ); + wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_cross_sells_columns', $columns ) ); + + // Handle orderby and limit results. + $orderby = apply_filters( 'woocommerce_cross_sells_orderby', $orderby ); + $order = apply_filters( 'woocommerce_cross_sells_order', $order ); + $cross_sells = wc_products_array_orderby( $cross_sells, $orderby, $order ); + $limit = apply_filters( 'woocommerce_cross_sells_total', $limit ); + $cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells; + + wc_get_template( 'cart/cross-sells.php', array( + 'cross_sells' => $cross_sells, + + // Not used now, but used in previous version of up-sells.php. + 'posts_per_page' => $limit, + 'orderby' => $orderby, + 'columns' => $columns, + ) ); + } +} + +if ( ! function_exists( 'woocommerce_button_proceed_to_checkout' ) ) { + + /** + * Output the proceed to checkout button. + */ + function woocommerce_button_proceed_to_checkout() { + wc_get_template( 'cart/proceed-to-checkout-button.php' ); + } +} + +if ( ! function_exists( 'woocommerce_widget_shopping_cart_button_view_cart' ) ) { + + /** + * Output the view cart button. + */ + function woocommerce_widget_shopping_cart_button_view_cart() { + echo '' . esc_html__( 'View cart', 'woocommerce' ) . ''; + } +} + +if ( ! function_exists( 'woocommerce_widget_shopping_cart_proceed_to_checkout' ) ) { + + /** + * Output the proceed to checkout button. + */ + function woocommerce_widget_shopping_cart_proceed_to_checkout() { + echo '' . esc_html__( 'Checkout', 'woocommerce' ) . ''; + } +} + +/** Mini-Cart */ + +if ( ! function_exists( 'woocommerce_mini_cart' ) ) { + + /** + * Output the Mini-cart - used by cart widget. + * + * @param array $args Arguments. + */ + function woocommerce_mini_cart( $args = array() ) { + + $defaults = array( + 'list_class' => '', + ); + + $args = wp_parse_args( $args, $defaults ); + + wc_get_template( 'cart/mini-cart.php', $args ); + } +} + +/** Login */ + +if ( ! function_exists( 'woocommerce_login_form' ) ) { + + /** + * Output the WooCommerce Login Form. + * + * @param array $args Arguments. + */ + function woocommerce_login_form( $args = array() ) { + + $defaults = array( + 'message' => '', + 'redirect' => '', + 'hidden' => false, + ); + + $args = wp_parse_args( $args, $defaults ); + + wc_get_template( 'global/form-login.php', $args ); + } +} + +if ( ! function_exists( 'woocommerce_checkout_login_form' ) ) { + + /** + * Output the WooCommerce Checkout Login Form. + */ + function woocommerce_checkout_login_form() { + wc_get_template( 'checkout/form-login.php', array( + 'checkout' => WC()->checkout(), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_breadcrumb' ) ) { + + /** + * Output the WooCommerce Breadcrumb. + * + * @param array $args Arguments. + */ + function woocommerce_breadcrumb( $args = array() ) { + $args = wp_parse_args( $args, apply_filters( 'woocommerce_breadcrumb_defaults', array( + 'delimiter' => ' / ', + 'wrap_before' => '', + 'before' => '', + 'after' => '', + 'home' => _x( 'Home', 'breadcrumb', 'woocommerce' ), + ) ) ); + + $breadcrumbs = new WC_Breadcrumb(); + + if ( ! empty( $args['home'] ) ) { + $breadcrumbs->add_crumb( $args['home'], apply_filters( 'woocommerce_breadcrumb_home_url', home_url() ) ); + } + + $args['breadcrumb'] = $breadcrumbs->generate(); + + /** + * WooCommerce Breadcrumb hook + * + * @hooked WC_Structured_Data::generate_breadcrumblist_data() - 10 + */ + do_action( 'woocommerce_breadcrumb', $breadcrumbs, $args ); + + wc_get_template( 'global/breadcrumb.php', $args ); + } +} + +if ( ! function_exists( 'woocommerce_order_review' ) ) { + + /** + * Output the Order review table for the checkout. + * + * @param bool $deprecated Deprecated param. + */ + function woocommerce_order_review( $deprecated = false ) { + wc_get_template( 'checkout/review-order.php', array( + 'checkout' => WC()->checkout(), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_checkout_payment' ) ) { + + /** + * Output the Payment Methods on the checkout. + */ + function woocommerce_checkout_payment() { + if ( WC()->cart->needs_payment() ) { + $available_gateways = WC()->payment_gateways()->get_available_payment_gateways(); + WC()->payment_gateways()->set_current_gateway( $available_gateways ); + } else { + $available_gateways = array(); + } + + wc_get_template( 'checkout/payment.php', array( + 'checkout' => WC()->checkout(), + 'available_gateways' => $available_gateways, + 'order_button_text' => apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) ), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_checkout_coupon_form' ) ) { + + /** + * Output the Coupon form for the checkout. + */ + function woocommerce_checkout_coupon_form() { + wc_get_template( 'checkout/form-coupon.php', array( + 'checkout' => WC()->checkout(), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_products_will_display' ) ) { + + /** + * Check if we will be showing products or not (and not sub-categories only). + * + * @return bool + */ + function woocommerce_products_will_display() { + $display_type = woocommerce_get_loop_display_mode(); + + return 0 < wc_get_loop_prop( 'total', 0 ) && 'subcategories' !== $display_type; + } +} + +if ( ! function_exists( 'woocommerce_get_loop_display_mode' ) ) { + + /** + * See what is going to display in the loop. + * + * @since 3.3.0 + * @return string Either products, subcategories, or both, based on current page. + */ + function woocommerce_get_loop_display_mode() { + // Only return products when filtering things. + if ( 1 < wc_get_loop_prop( 'current_page' ) || wc_get_loop_prop( 'is_search' ) || wc_get_loop_prop( 'is_filtered' ) ) { + return 'products'; + } + + $parent_id = 0; + $display_type = ''; + + if ( is_shop() ) { + $display_type = get_option( 'woocommerce_shop_page_display', '' ); + } elseif ( is_product_category() ) { + $parent_id = get_queried_object_id(); + $display_type = get_woocommerce_term_meta( $parent_id, 'display_type', true ); + $display_type = '' === $display_type ? get_option( 'woocommerce_category_archive_display', '' ) : $display_type; + } + + // Ensure valid value. + if ( '' === $display_type || ! in_array( $display_type, array( 'products', 'subcategories', 'both' ), true ) ) { + $display_type = 'products'; + } + + // If we're showing categories, ensure we actually have something to show. + if ( in_array( $display_type, array( 'subcategories', 'both' ), true ) ) { + $subcategories = woocommerce_get_product_subcategories( $parent_id ); + + if ( empty( $subcategories ) ) { + $display_type = 'products'; + } + } + + return $display_type; + } +} + +if ( ! function_exists( 'woocommerce_maybe_show_product_subcategories' ) ) { + + /** + * Maybe display categories before, or instead of, a product loop. + * + * @since 3.3.0 + * @param string $loop_html HTML. + * @return string + */ + function woocommerce_maybe_show_product_subcategories( $loop_html = '' ) { + if ( wc_get_loop_prop( 'is_shortcode' ) && ! WC_Template_Loader::in_content_filter() ) { + return $loop_html; + } + + $display_type = woocommerce_get_loop_display_mode(); + + // If displaying categories, append to the loop. + if ( 'subcategories' === $display_type || 'both' === $display_type ) { + ob_start(); + woocommerce_output_product_categories( array( + 'parent_id' => is_product_category() ? get_queried_object_id() : 0, + ) ); + $loop_html .= ob_get_clean(); + + if ( 'subcategories' === $display_type ) { + wc_set_loop_prop( 'total', 0 ); + + // This removes pagination and products from display for themes not using wc_get_loop_prop in their product loops. @todo Remove in future major version. + global $wp_query; + + if ( $wp_query->is_main_query() ) { + $wp_query->post_count = 0; + $wp_query->max_num_pages = 0; + } + } + } + + return $loop_html; + } +} + +if ( ! function_exists( 'woocommerce_product_subcategories' ) ) { + /** + * This is a legacy function which used to check if we needed to display subcats and then output them. It was called by templates. + * + * From 3.3 onwards this is all handled via hooks and the woocommerce_maybe_show_product_subcategories function. + * + * Since some templates have not updated compatibility, to avoid showing incorrect categories this function has been deprecated and will + * return nothing. Replace usage with woocommerce_output_product_categories to render the category list manually. + * + * This is a legacy function which also checks if things should display. + * Themes no longer need to call these functions. It's all done via hooks. + * + * @deprecated 3.3.1 @todo Add a notice in a future version. + * @param array $args Arguments. + * @return null|boolean + */ + function woocommerce_product_subcategories( $args = array() ) { + $defaults = array( + 'before' => '', + 'after' => '', + 'force_display' => false, + ); + + $args = wp_parse_args( $args, $defaults ); + + if ( $args['force_display'] ) { + // We can still render if display is forced. + woocommerce_output_product_categories( array( + 'before' => $args['before'], + 'after' => $args['after'], + 'parent_id' => is_product_category() ? get_queried_object_id() : 0, + ) ); + return true; + } else { + // Output nothing. woocommerce_maybe_show_product_subcategories will handle the output of cats. + $display_type = woocommerce_get_loop_display_mode(); + + if ( 'subcategories' === $display_type ) { + // This removes pagination and products from display for themes not using wc_get_loop_prop in their product loops. @todo Remove in future major version. + global $wp_query; + + if ( $wp_query->is_main_query() ) { + $wp_query->post_count = 0; + $wp_query->max_num_pages = 0; + } + } + + return 'subcategories' === $display_type || 'both' === $display_type; + } + } +} + +if ( ! function_exists( 'woocommerce_output_product_categories' ) ) { + /** + * Display product sub categories as thumbnails. + * + * This is a replacement for woocommerce_product_subcategories which also does some logic + * based on the loop. This function however just outputs when called. + * + * @since 3.3.1 + * @param array $args Arguments. + * @return boolean + */ + function woocommerce_output_product_categories( $args = array() ) { + $args = wp_parse_args( $args, array( + 'before' => apply_filters( 'woocommerce_before_output_product_categories', '' ), + 'after' => apply_filters( 'woocommerce_after_output_product_categories', '' ), + 'parent_id' => 0, + ) ); + + $product_categories = woocommerce_get_product_subcategories( $args['parent_id'] ); + + if ( ! $product_categories ) { + return false; + } + + echo $args['before']; // WPCS: XSS ok. + + foreach ( $product_categories as $category ) { + wc_get_template( 'content-product_cat.php', array( + 'category' => $category, + ) ); + } + + echo $args['after']; // WPCS: XSS ok. + + return true; + } +} + +if ( ! function_exists( 'woocommerce_get_product_subcategories' ) ) { + /** + * Get (and cache) product subcategories. + * + * @param int $parent_id Get subcategories of this ID. + * @return array + */ + function woocommerce_get_product_subcategories( $parent_id = 0 ) { + $parent_id = absint( $parent_id ); + $product_categories = wp_cache_get( 'product-category-hierarchy-' . $parent_id, 'product_cat' ); + + if ( false === $product_categories ) { + // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( https://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work. + $product_categories = get_categories( apply_filters( 'woocommerce_product_subcategories_args', array( + 'parent' => $parent_id, + 'menu_order' => 'ASC', + 'hide_empty' => 0, + 'hierarchical' => 1, + 'taxonomy' => 'product_cat', + 'pad_counts' => 1, + ) ) ); + + wp_cache_set( 'product-category-hierarchy-' . $parent_id, $product_categories, 'product_cat' ); + } + + if ( apply_filters( 'woocommerce_product_subcategories_hide_empty', true ) ) { + $product_categories = wp_list_filter( $product_categories, array( 'count' => 0 ), 'NOT' ); + } + + return $product_categories; + } +} + +if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) { + + /** + * Show subcategory thumbnails. + * + * @param mixed $category Category. + */ + function woocommerce_subcategory_thumbnail( $category ) { + $small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' ); + $dimensions = wc_get_image_size( $small_thumbnail_size ); + $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true ); + + if ( $thumbnail_id ) { + $image = wp_get_attachment_image_src( $thumbnail_id, $small_thumbnail_size ); + $image = $image[0]; + $image_srcset = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $thumbnail_id, $small_thumbnail_size ) : false; + $image_sizes = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $thumbnail_id, $small_thumbnail_size ) : false; + } else { + $image = wc_placeholder_img_src(); + $image_srcset = false; + $image_sizes = false; + } + + if ( $image ) { + // Prevent esc_url from breaking spaces in urls for image embeds. + // Ref: https://core.trac.wordpress.org/ticket/23605. + $image = str_replace( ' ', '%20', $image ); + + // Add responsive image markup if available. + if ( $image_srcset && $image_sizes ) { + echo '' . esc_attr( $category->name ) . ''; + } else { + echo '' . esc_attr( $category->name ) . ''; + } + } + } +} + +if ( ! function_exists( 'woocommerce_order_details_table' ) ) { + + /** + * Displays order details in a table. + * + * @param mixed $order_id Order ID. + */ + function woocommerce_order_details_table( $order_id ) { + if ( ! $order_id ) { + return; + } + + wc_get_template( 'order/order-details.php', array( + 'order_id' => $order_id, + ) ); + } +} + +if ( ! function_exists( 'woocommerce_order_downloads_table' ) ) { + + /** + * Displays order downloads in a table. + * + * @since 3.2.0 + * @param array $downloads Downloads. + */ + function woocommerce_order_downloads_table( $downloads ) { + if ( ! $downloads ) { + return; + } + wc_get_template( 'order/order-downloads.php', array( + 'downloads' => $downloads, + ) ); + } +} + +if ( ! function_exists( 'woocommerce_order_again_button' ) ) { + + /** + * Display an 'order again' button on the view order page. + * + * @param object $order Order. + */ + function woocommerce_order_again_button( $order ) { + if ( ! $order || ! $order->has_status( apply_filters( 'woocommerce_valid_order_statuses_for_order_again', array( 'completed' ) ) ) || ! is_user_logged_in() ) { + return; + } + + wc_get_template( 'order/order-again.php', array( + 'order' => $order, + ) ); + } +} + +/** Forms */ + +if ( ! function_exists( 'woocommerce_form_field' ) ) { + + /** + * Outputs a checkout/address form field. + * + * @param string $key Key. + * @param mixed $args Arguments. + * @param string $value (default: null). + * @return string + */ + function woocommerce_form_field( $key, $args, $value = null ) { + $defaults = array( + 'type' => 'text', + 'label' => '', + 'description' => '', + 'placeholder' => '', + 'maxlength' => false, + 'required' => false, + 'autocomplete' => false, + 'id' => $key, + 'class' => array(), + 'label_class' => array(), + 'input_class' => array(), + 'return' => false, + 'options' => array(), + 'custom_attributes' => array(), + 'validate' => array(), + 'default' => '', + 'autofocus' => '', + 'priority' => '', + ); + + $args = wp_parse_args( $args, $defaults ); + $args = apply_filters( 'woocommerce_form_field_args', $args, $key, $value ); + + if ( $args['required'] ) { + $args['class'][] = 'validate-required'; + $required = ' *'; + } else { + $required = ' (' . esc_html__( 'optional', 'woocommerce' ) . ')'; + } + + if ( is_string( $args['label_class'] ) ) { + $args['label_class'] = array( $args['label_class'] ); + } + + if ( is_null( $value ) ) { + $value = $args['default']; + } + + // Custom attribute handling. + $custom_attributes = array(); + $args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' ); + + if ( $args['maxlength'] ) { + $args['custom_attributes']['maxlength'] = absint( $args['maxlength'] ); + } + + if ( ! empty( $args['autocomplete'] ) ) { + $args['custom_attributes']['autocomplete'] = $args['autocomplete']; + } + + if ( true === $args['autofocus'] ) { + $args['custom_attributes']['autofocus'] = 'autofocus'; + } + + if ( $args['description'] ) { + $args['custom_attributes']['aria-describedby'] = $args['id'] . '-description'; + } + + if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) { + foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) { + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; + } + } + + if ( ! empty( $args['validate'] ) ) { + foreach ( $args['validate'] as $validate ) { + $args['class'][] = 'validate-' . $validate; + } + } + + $field = ''; + $label_id = $args['id']; + $sort = $args['priority'] ? $args['priority'] : ''; + $field_container = '

      %3$s

      '; + + switch ( $args['type'] ) { + case 'country': + $countries = 'shipping_country' === $key ? WC()->countries->get_shipping_countries() : WC()->countries->get_allowed_countries(); + + if ( 1 === count( $countries ) ) { + + $field .= '' . current( array_values( $countries ) ) . ''; + + $field .= ''; + + } else { + + $field = ''; + + $field .= ''; + + } + + break; + case 'state': + /* Get country this state field is representing */ + $for_country = isset( $args['country'] ) ? $args['country'] : WC()->checkout->get_value( 'billing_state' === $key ? 'billing_country' : 'shipping_country' ); + $states = WC()->countries->get_states( $for_country ); + + if ( is_array( $states ) && empty( $states ) ) { + + $field_container = ''; + + $field .= ''; + + } elseif ( ! is_null( $for_country ) && is_array( $states ) ) { + + $field .= ''; + + } else { + + $field .= ''; + + } + + break; + case 'textarea': + $field .= ''; + + break; + case 'checkbox': + $field = ''; + + break; + case 'text': + case 'password': + case 'datetime': + case 'datetime-local': + case 'date': + case 'month': + case 'time': + case 'week': + case 'number': + case 'email': + case 'url': + case 'tel': + $field .= ''; + + break; + case 'select': + $field = ''; + $options = ''; + + if ( ! empty( $args['options'] ) ) { + foreach ( $args['options'] as $option_key => $option_text ) { + if ( '' === $option_key ) { + // If we have a blank option, select2 needs a placeholder. + if ( empty( $args['placeholder'] ) ) { + $args['placeholder'] = $option_text ? $option_text : __( 'Choose an option', 'woocommerce' ); + } + $custom_attributes[] = 'data-allow_clear="true"'; + } + $options .= ''; + } + + $field .= ''; + } + + break; + case 'radio': + $label_id = current( array_keys( $args['options'] ) ); + + if ( ! empty( $args['options'] ) ) { + foreach ( $args['options'] as $option_key => $option_text ) { + $field .= ''; + $field .= ''; + } + } + + break; + } + + if ( ! empty( $field ) ) { + $field_html = ''; + + if ( $args['label'] && 'checkbox' !== $args['type'] ) { + $field_html .= ''; + } + + $field_html .= '' . $field; + + if ( $args['description'] ) { + $field_html .= ''; + } + + $field_html .= ''; + + $container_class = esc_attr( implode( ' ', $args['class'] ) ); + $container_id = esc_attr( $args['id'] ) . '_field'; + $field = sprintf( $field_container, $container_class, $container_id, $field_html ); + } + + /** + * Filter by type. + */ + $field = apply_filters( 'woocommerce_form_field_' . $args['type'], $field, $key, $args, $value ); + + /** + * General filter on form fields. + * + * @since 3.4.0 + */ + $field = apply_filters( 'woocommerce_form_field', $field, $key, $args, $value ); + + if ( $args['return'] ) { + return $field; + } else { + echo $field; // WPCS: XSS ok. + } + } +} + +if ( ! function_exists( 'get_product_search_form' ) ) { + + /** + * Display product search form. + * + * Will first attempt to locate the product-searchform.php file in either the child or. + * the parent, then load it. If it doesn't exist, then the default search form. + * will be displayed. + * + * The default searchform uses html5. + * + * @param bool $echo (default: true). + * @return string + */ + function get_product_search_form( $echo = true ) { + global $product_search_form_index; + + ob_start(); + + if ( empty( $product_search_form_index ) ) { + $product_search_form_index = 0; + } + + do_action( 'pre_get_product_search_form' ); + + wc_get_template( 'product-searchform.php', array( + 'index' => $product_search_form_index++, + ) ); + + $form = apply_filters( 'get_product_search_form', ob_get_clean() ); + + if ( $echo ) { + echo $form; // WPCS: XSS ok. + } else { + return $form; + } + } +} + +if ( ! function_exists( 'woocommerce_output_auth_header' ) ) { + + /** + * Output the Auth header. + */ + function woocommerce_output_auth_header() { + wc_get_template( 'auth/header.php' ); + } +} + +if ( ! function_exists( 'woocommerce_output_auth_footer' ) ) { + + /** + * Output the Auth footer. + */ + function woocommerce_output_auth_footer() { + wc_get_template( 'auth/footer.php' ); + } +} + +if ( ! function_exists( 'woocommerce_single_variation' ) ) { + + /** + * Output placeholders for the single variation. + */ + function woocommerce_single_variation() { + echo '
      '; + } +} + +if ( ! function_exists( 'woocommerce_single_variation_add_to_cart_button' ) ) { + + /** + * Output the add to cart button for variations. + */ + function woocommerce_single_variation_add_to_cart_button() { + wc_get_template( 'single-product/add-to-cart/variation-add-to-cart-button.php' ); + } +} + +if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) { + + /** + * Output a list of variation attributes for use in the cart forms. + * + * @param array $args Arguments. + * @since 2.4.0 + */ + function wc_dropdown_variation_attribute_options( $args = array() ) { + $args = wp_parse_args( apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ), array( + 'options' => false, + 'attribute' => false, + 'product' => false, + 'selected' => false, + 'name' => '', + 'id' => '', + 'class' => '', + 'show_option_none' => __( 'Choose an option', 'woocommerce' ), + ) ); + + // Get selected value. + if ( false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product ) { + $selected_key = 'attribute_' . sanitize_title( $args['attribute'] ); + $args['selected'] = isset( $_REQUEST[ $selected_key ] ) ? wc_clean( urldecode( wp_unslash( $_REQUEST[ $selected_key ] ) ) ) : $args['product']->get_variation_default_attribute( $args['attribute'] ); // WPCS: input var ok, CSRF ok, sanitization ok. + } + + $options = $args['options']; + $product = $args['product']; + $attribute = $args['attribute']; + $name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute ); + $id = $args['id'] ? $args['id'] : sanitize_title( $attribute ); + $class = $args['class']; + $show_option_none = (bool) $args['show_option_none']; + $show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options. + + if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) { + $attributes = $product->get_variation_attributes(); + $options = $attributes[ $attribute ]; + } + + $html = ''; + + echo apply_filters( 'woocommerce_dropdown_variation_attribute_options_html', $html, $args ); // WPCS: XSS ok. + } +} + +if ( ! function_exists( 'woocommerce_account_content' ) ) { + + /** + * My Account content output. + */ + function woocommerce_account_content() { + global $wp; + + if ( ! empty( $wp->query_vars ) ) { + foreach ( $wp->query_vars as $key => $value ) { + // Ignore pagename param. + if ( 'pagename' === $key ) { + continue; + } + + if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) { + do_action( 'woocommerce_account_' . $key . '_endpoint', $value ); + return; + } + } + } + + // No endpoint found? Default to dashboard. + wc_get_template( 'myaccount/dashboard.php', array( + 'current_user' => get_user_by( 'id', get_current_user_id() ), + ) ); + } +} + +if ( ! function_exists( 'woocommerce_account_navigation' ) ) { + + /** + * My Account navigation template. + */ + function woocommerce_account_navigation() { + wc_get_template( 'myaccount/navigation.php' ); + } +} + +if ( ! function_exists( 'woocommerce_account_orders' ) ) { + + /** + * My Account > Orders template. + * + * @param int $current_page Current page number. + */ + function woocommerce_account_orders( $current_page ) { + $current_page = empty( $current_page ) ? 1 : absint( $current_page ); + $customer_orders = wc_get_orders( apply_filters( 'woocommerce_my_account_my_orders_query', array( + 'customer' => get_current_user_id(), + 'page' => $current_page, + 'paginate' => true, + ) ) ); + + wc_get_template( + 'myaccount/orders.php', + array( + 'current_page' => absint( $current_page ), + 'customer_orders' => $customer_orders, + 'has_orders' => 0 < $customer_orders->total, + ) + ); + } +} + +if ( ! function_exists( 'woocommerce_account_view_order' ) ) { + + /** + * My Account > View order template. + * + * @param int $order_id Order ID. + */ + function woocommerce_account_view_order( $order_id ) { + WC_Shortcode_My_Account::view_order( absint( $order_id ) ); + } +} + +if ( ! function_exists( 'woocommerce_account_downloads' ) ) { + + /** + * My Account > Downloads template. + */ + function woocommerce_account_downloads() { + wc_get_template( 'myaccount/downloads.php' ); + } +} + +if ( ! function_exists( 'woocommerce_account_edit_address' ) ) { + + /** + * My Account > Edit address template. + * + * @param string $type Address type. + */ + function woocommerce_account_edit_address( $type ) { + $type = wc_edit_address_i18n( sanitize_title( $type ), true ); + + WC_Shortcode_My_Account::edit_address( $type ); + } +} + +if ( ! function_exists( 'woocommerce_account_payment_methods' ) ) { + + /** + * My Account > Downloads template. + */ + function woocommerce_account_payment_methods() { + wc_get_template( 'myaccount/payment-methods.php' ); + } +} + +if ( ! function_exists( 'woocommerce_account_add_payment_method' ) ) { + + /** + * My Account > Add payment method template. + */ + function woocommerce_account_add_payment_method() { + WC_Shortcode_My_Account::add_payment_method(); + } +} + +if ( ! function_exists( 'woocommerce_account_edit_account' ) ) { + + /** + * My Account > Edit account template. + */ + function woocommerce_account_edit_account() { + WC_Shortcode_My_Account::edit_account(); + } +} + +if ( ! function_exists( 'wc_no_products_found' ) ) { + + /** + * Handles the loop when no products were found/no product exist. + */ + function wc_no_products_found() { + wc_get_template( 'loop/no-products-found.php' ); + } +} + + +if ( ! function_exists( 'wc_get_email_order_items' ) ) { + /** + * Get HTML for the order items to be shown in emails. + * + * @param WC_Order $order Order object. + * @param array $args Arguments. + * + * @since 3.0.0 + * @return string + */ + function wc_get_email_order_items( $order, $args = array() ) { + ob_start(); + + $defaults = array( + 'show_sku' => false, + 'show_image' => false, + 'image_size' => array( 32, 32 ), + 'plain_text' => false, + 'sent_to_admin' => false, + ); + + $args = wp_parse_args( $args, $defaults ); + $template = $args['plain_text'] ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php'; + + wc_get_template( $template, apply_filters( 'woocommerce_email_order_items_args', array( + 'order' => $order, + 'items' => $order->get_items(), + 'show_download_links' => $order->is_download_permitted() && ! $args['sent_to_admin'], + 'show_sku' => $args['show_sku'], + 'show_purchase_note' => $order->is_paid() && ! $args['sent_to_admin'], + 'show_image' => $args['show_image'], + 'image_size' => $args['image_size'], + 'plain_text' => $args['plain_text'], + 'sent_to_admin' => $args['sent_to_admin'], + ) ) ); + + return apply_filters( 'woocommerce_email_order_items_table', ob_get_clean(), $order ); + } +} + +if ( ! function_exists( 'wc_display_item_meta' ) ) { + /** + * Display item meta data. + * + * @since 3.0.0 + * @param WC_Order_Item $item Order Item. + * @param array $args Arguments. + * @return string|void + */ + function wc_display_item_meta( $item, $args = array() ) { + $strings = array(); + $html = ''; + $args = wp_parse_args( $args, array( + 'before' => '
      • ', + 'after' => '
      ', + 'separator' => '
    • ', + 'echo' => true, + 'autop' => false, + ) ); + + foreach ( $item->get_formatted_meta_data() as $meta_id => $meta ) { + $value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( $meta->display_value ) ) ); + $strings[] = '' . wp_kses_post( $meta->display_key ) . ': ' . $value; + } + + if ( $strings ) { + $html = $args['before'] . implode( $args['separator'], $strings ) . $args['after']; + } + + $html = apply_filters( 'woocommerce_display_item_meta', $html, $item, $args ); + + if ( $args['echo'] ) { + echo $html; // WPCS: XSS ok. + } else { + return $html; + } + } +} + +if ( ! function_exists( 'wc_display_item_downloads' ) ) { + /** + * Display item download links. + * + * @since 3.0.0 + * @param WC_Order_Item $item Order Item. + * @param array $args Arguments. + * @return string|void + */ + function wc_display_item_downloads( $item, $args = array() ) { + $strings = array(); + $html = ''; + $args = wp_parse_args( $args, array( + 'before' => '
      • ', + 'after' => '
      ', + 'separator' => '
    • ', + 'echo' => true, + 'show_url' => false, + ) ); + + $downloads = is_object( $item ) && $item->is_type( 'line_item' ) ? $item->get_item_downloads() : array(); + + if ( $downloads ) { + $i = 0; + foreach ( $downloads as $file ) { + $i ++; + + if ( $args['show_url'] ) { + $strings[] = '' . esc_html( $file['name'] ) . ': ' . esc_html( $file['download_url'] ); + } else { + /* translators: %d: downloads count */ + $prefix = count( $downloads ) > 1 ? sprintf( __( 'Download %d', 'woocommerce' ), $i ) : __( 'Download', 'woocommerce' ); + $strings[] = '' . $prefix . ': ' . esc_html( $file['name'] ) . ''; + } + } + } + + if ( $strings ) { + $html = $args['before'] . implode( $args['separator'], $strings ) . $args['after']; + } + + $html = apply_filters( 'woocommerce_display_item_downloads', $html, $item, $args ); + + if ( $args['echo'] ) { + echo $html; // WPCS: XSS ok. + } else { + return $html; + } + } +} + +if ( ! function_exists( 'woocommerce_photoswipe' ) ) { + + /** + * Get the shop sidebar template. + */ + function woocommerce_photoswipe() { + if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) { + wc_get_template( 'single-product/photoswipe.php' ); + } + } +} + +/** + * Outputs a list of product attributes for a product. + * + * @since 3.0.0 + * @param WC_Product $product Product Object. + */ +function wc_display_product_attributes( $product ) { + wc_get_template( 'single-product/product-attributes.php', array( + 'product' => $product, + 'attributes' => array_filter( $product->get_attributes(), 'wc_attributes_array_filter_visible' ), + 'display_dimensions' => apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ), + ) ); +} + +/** + * Get HTML to show product stock. + * + * @since 3.0.0 + * @param WC_Product $product Product Object. + * @return string + */ +function wc_get_stock_html( $product ) { + $html = ''; + $availability = $product->get_availability(); + + if ( ! empty( $availability['availability'] ) ) { + ob_start(); + + wc_get_template( 'single-product/stock.php', array( + 'product' => $product, + 'class' => $availability['class'], + 'availability' => $availability['availability'], + ) ); + + $html = ob_get_clean(); + } + + if ( has_filter( 'woocommerce_stock_html' ) ) { + wc_deprecated_function( 'The woocommerce_stock_html filter', '', 'woocommerce_get_stock_html' ); + $html = apply_filters( 'woocommerce_stock_html', $html, $availability['availability'], $product ); + } + + return apply_filters( 'woocommerce_get_stock_html', $html, $product ); +} + +/** + * Get HTML for ratings. + * + * @since 3.0.0 + * @param float $rating Rating being shown. + * @param int $count Total number of ratings. + * @return string + */ +function wc_get_rating_html( $rating, $count = 0 ) { + if ( 0 < $rating ) { + $html = '
      '; + $html .= wc_get_star_rating_html( $rating, $count ); + $html .= '
      '; + } else { + $html = ''; + } + + return apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count ); +} + +/** + * Get HTML for star rating. + * + * @since 3.1.0 + * @param float $rating Rating being shown. + * @param int $count Total number of ratings. + * @return string + */ +function wc_get_star_rating_html( $rating, $count = 0 ) { + $html = ''; + + if ( 0 < $count ) { + /* translators: 1: rating 2: rating count */ + $html .= sprintf( _n( 'Rated %1$s out of 5 based on %2$s customer rating', 'Rated %1$s out of 5 based on %2$s customer ratings', $count, 'woocommerce' ), '' . esc_html( $rating ) . '', '' . esc_html( $count ) . '' ); + } else { + /* translators: %s: rating */ + $html .= sprintf( esc_html__( 'Rated %s out of 5', 'woocommerce' ), '' . esc_html( $rating ) . '' ); + } + + $html .= ''; + + return apply_filters( 'woocommerce_get_star_rating_html', $html, $rating, $count ); +} + +/** + * Returns a 'from' prefix if you want to show where prices start at. + * + * @since 3.0.0 + * @return string + */ +function wc_get_price_html_from_text() { + return apply_filters( 'woocommerce_get_price_html_from_text', '' . _x( 'From:', 'min_price', 'woocommerce' ) . ' ' ); +} + +/** + * Get logout endpoint. + * + * @since 2.6.9 + * + * @param string $redirect Redirect URL. + * + * @return string + */ +function wc_logout_url( $redirect = '' ) { + $logout_endpoint = get_option( 'woocommerce_logout_endpoint' ); + $redirect = $redirect ? $redirect : wc_get_page_permalink( 'myaccount' ); + + if ( $logout_endpoint ) { + return wp_nonce_url( wc_get_endpoint_url( 'customer-logout', '', $redirect ), 'customer-logout' ); + } else { + return wp_logout_url( $redirect ); + } +} + +/** + * Show notice if cart is empty. + * + * @since 3.1.0 + */ +function wc_empty_cart_message() { + echo '

      ' . wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) ) . '

      '; +} + +/** + * Disable search engines indexing core, dynamic, cart/checkout pages. + * + * @since 3.2.0 + */ +function wc_page_noindex() { + if ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) || is_page( wc_get_page_id( 'myaccount' ) ) ) { + wp_no_robots(); + } +} +add_action( 'wp_head', 'wc_page_noindex' ); + +/** + * Get a slug identifying the current theme. + * + * @since 3.3.0 + * @return string + */ +function wc_get_theme_slug_for_templates() { + return apply_filters( 'woocommerce_theme_slug_for_templates', get_option( 'template' ) ); +} + +/** + * Gets and formats a list of cart item data + variations for display on the frontend. + * + * @since 3.3.0 + * @param array $cart_item Cart item object. + * @param bool $flat Should the data be returned flat or in a list. + * @return string + */ +function wc_get_formatted_cart_item_data( $cart_item, $flat = false ) { + $item_data = array(); + + // Variation values are shown only if they are not found in the title as of 3.0. + // This is because variation titles display the attributes. + if ( $cart_item['data']->is_type( 'variation' ) && is_array( $cart_item['variation'] ) ) { + foreach ( $cart_item['variation'] as $name => $value ) { + $taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) ); + + if ( taxonomy_exists( $taxonomy ) ) { + // If this is a term slug, get the term's nice name. + $term = get_term_by( 'slug', $value, $taxonomy ); + if ( ! is_wp_error( $term ) && $term && $term->name ) { + $value = $term->name; + } + $label = wc_attribute_label( $taxonomy ); + } else { + // If this is a custom option slug, get the options name. + $value = apply_filters( 'woocommerce_variation_option_name', $value ); + $label = wc_attribute_label( str_replace( 'attribute_', '', $name ), $cart_item['data'] ); + } + + // Check the nicename against the title. + if ( '' === $value || wc_is_attribute_in_product_name( $value, $cart_item['data']->get_name() ) ) { + continue; + } + + $item_data[] = array( + 'key' => $label, + 'value' => $value, + ); + } + } + + // Filter item data to allow 3rd parties to add more to the array. + $item_data = apply_filters( 'woocommerce_get_item_data', $item_data, $cart_item ); + + // Format item data ready to display. + foreach ( $item_data as $key => $data ) { + // Set hidden to true to not display meta on cart. + if ( ! empty( $data['hidden'] ) ) { + unset( $item_data[ $key ] ); + continue; + } + $item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name']; + $item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value']; + } + + // Output flat or in list format. + if ( count( $item_data ) > 0 ) { + ob_start(); + + if ( $flat ) { + foreach ( $item_data as $data ) { + echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . "\n"; + } + } else { + wc_get_template( 'cart/cart-item-data.php', array( 'item_data' => $item_data ) ); + } + + return ob_get_clean(); + } + + return ''; +} + +/** + * Gets the url to remove an item from the cart. + * + * @since 3.3.0 + * @param string $cart_item_key contains the id of the cart item. + * @return string url to page + */ +function wc_get_cart_remove_url( $cart_item_key ) { + $cart_page_url = wc_get_page_permalink( 'cart' ); + return apply_filters( 'woocommerce_get_remove_url', $cart_page_url ? wp_nonce_url( add_query_arg( 'remove_item', $cart_item_key, $cart_page_url ), 'woocommerce-cart' ) : '' ); +} + +/** + * Gets the url to re-add an item into the cart. + * + * @since 3.3.0 + * @param string $cart_item_key Cart item key to undo. + * @return string url to page + */ +function wc_get_cart_undo_url( $cart_item_key ) { + $cart_page_url = wc_get_page_permalink( 'cart' ); + + $query_args = array( + 'undo_item' => $cart_item_key, + ); + + return apply_filters( 'woocommerce_get_undo_url', $cart_page_url ? wp_nonce_url( add_query_arg( $query_args, $cart_page_url ), 'woocommerce-cart' ) : '', $cart_item_key ); +} + +/** + * Products RSS Feed. + * + * @deprecated 2.6 + */ +function wc_products_rss_feed() { + wc_deprecated_function( 'wc_products_rss_feed', '2.6' ); +} + +if ( ! function_exists( 'woocommerce_reset_loop' ) ) { + + /** + * Reset the loop's index and columns when we're done outputting a product loop. + * + * @deprecated 3.3 + */ + function woocommerce_reset_loop() { + wc_reset_loop(); + } +} + +if ( ! function_exists( 'woocommerce_product_reviews_tab' ) ) { + /** + * Output the reviews tab content. + * + * @deprecated 2.4.0 Unused. + */ + function woocommerce_product_reviews_tab() { + wc_deprecated_function( 'woocommerce_product_reviews_tab', '2.4' ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/wc-template-hooks.php b/backend/wp-content/plugins/woocommerce/includes/wc-template-hooks.php new file mode 100644 index 0000000..fea838d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/wc-template-hooks.php @@ -0,0 +1,290 @@ +slug' : $args['fields']; + $terms = get_terms( $taxonomy, $args ); + } + } else { + $terms = _wc_get_cached_product_terms( $product_id, $taxonomy, $args ); + } + + return apply_filters( 'woocommerce_get_product_terms', $terms, $product_id, $taxonomy, $args ); +} + +/** + * Sort by name (numeric). + * + * @param WP_Post $a First item to compare. + * @param WP_Post $b Second item to compare. + * @return int + */ +function _wc_get_product_terms_name_num_usort_callback( $a, $b ) { + $a_name = (float) $a->name; + $b_name = (float) $b->name; + + if ( abs( $a_name - $b_name ) < 0.001 ) { + return 0; + } + + return ( $a_name < $b_name ) ? -1 : 1; +} + +/** + * Sort by parent. + * + * @param WP_Post $a First item to compare. + * @param WP_Post $b Second item to compare. + * @return int + */ +function _wc_get_product_terms_parent_usort_callback( $a, $b ) { + if ( $a->parent === $b->parent ) { + return 0; + } + return ( $a->parent < $b->parent ) ? 1 : -1; +} + +/** + * WooCommerce Dropdown categories. + * + * @param array $args Args to control display of dropdown. + */ +function wc_product_dropdown_categories( $args = array() ) { + global $wp_query; + + $args = wp_parse_args( + $args, array( + 'pad_counts' => 1, + 'show_count' => 1, + 'hierarchical' => 1, + 'hide_empty' => 1, + 'show_uncategorized' => 1, + 'orderby' => 'name', + 'selected' => isset( $wp_query->query_vars['product_cat'] ) ? $wp_query->query_vars['product_cat'] : '', + 'menu_order' => false, + 'show_option_none' => __( 'Select a category', 'woocommerce' ), + 'option_none_value' => '', + 'value_field' => 'slug', + 'taxonomy' => 'product_cat', + 'name' => 'product_cat', + 'class' => 'dropdown_product_cat', + ) + ); + + if ( 'order' === $args['orderby'] ) { + $args['menu_order'] = 'asc'; + $args['orderby'] = 'name'; + } + + wp_dropdown_categories( $args ); +} + +/** + * Custom walker for Product Categories. + * + * Previously used by wc_product_dropdown_categories, but wp_dropdown_categories has been fixed in core. + * + * @return mixed + */ +function wc_walk_category_dropdown_tree() { + $args = func_get_args(); + + if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) { + include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php'; + } + + // The user's options are the third parameter. + if ( empty( $args[2]['walker'] ) || ! is_a( $args[2]['walker'], 'Walker' ) ) { + $walker = new WC_Product_Cat_Dropdown_Walker(); + } else { + $walker = $args[2]['walker']; + } + + return call_user_func_array( array( &$walker, 'walk' ), $args ); +} + +/** + * When a term is split, ensure meta data maintained. + * + * @param int $old_term_id Old term ID. + * @param int $new_term_id New term ID. + * @param string $term_taxonomy_id Term taxonomy ID. + * @param string $taxonomy Taxonomy. + */ +function wc_taxonomy_metadata_update_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { + global $wpdb; + + if ( get_option( 'db_version' ) < 34370 ) { + if ( 'product_cat' === $taxonomy || taxonomy_is_product_attribute( $taxonomy ) ) { + $old_meta_data = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM {$wpdb->prefix}woocommerce_termmeta WHERE woocommerce_term_id = %d;", $old_term_id ) ); + + // Copy across to split term. + if ( $old_meta_data ) { + foreach ( $old_meta_data as $meta_data ) { + $wpdb->insert( + "{$wpdb->prefix}woocommerce_termmeta", + array( + 'woocommerce_term_id' => $new_term_id, + 'meta_key' => $meta_data->meta_key, // WPCS: slow query ok. + 'meta_value' => $meta_data->meta_value, // WPCS: slow query ok. + ) + ); + } + } + } + } +} +add_action( 'split_shared_term', 'wc_taxonomy_metadata_update_content_for_split_terms', 10, 4 ); + +/** + * Migrate data from WC term meta to WP term meta. + * + * When the database is updated to support term meta, migrate WC term meta data across. + * We do this when the new version is >= 34370, and the old version is < 34370 (34370 is when term meta table was added). + * + * @param string $wp_db_version The new $wp_db_version. + * @param string $wp_current_db_version The old (current) $wp_db_version. + */ +function wc_taxonomy_metadata_migrate_data( $wp_db_version, $wp_current_db_version ) { + if ( $wp_db_version >= 34370 && $wp_current_db_version < 34370 ) { + global $wpdb; + if ( $wpdb->query( "INSERT INTO {$wpdb->termmeta} ( term_id, meta_key, meta_value ) SELECT woocommerce_term_id, meta_key, meta_value FROM {$wpdb->prefix}woocommerce_termmeta;" ) ) { + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_termmeta" ); + } + } +} +add_action( 'wp_upgrade', 'wc_taxonomy_metadata_migrate_data', 10, 2 ); + +/** + * WooCommerce Term Meta API. + * + * WC tables for storing term meta are @deprecated from WordPress 4.4 since 4.4 has its own table. + * This function serves as a wrapper, using the new table if present, or falling back to the WC table. + * + * @param int $term_id Term ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param string $prev_value Previous value. (default: ''). + * @return bool + */ +function update_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { + return function_exists( 'update_term_meta' ) ? update_term_meta( $term_id, $meta_key, $meta_value, $prev_value ) : update_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $prev_value ); +} + +/** + * WooCommerce Term Meta API. + * + * WC tables for storing term meta are @deprecated from WordPress 4.4 since 4.4 has its own table. + * This function serves as a wrapper, using the new table if present, or falling back to the WC table. + * + * @param int $term_id Term ID. + * @param string $meta_key Meta key. + * @param mixed $meta_value Meta value. + * @param bool $unique Make meta key unique. (default: false). + * @return bool + */ +function add_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { + return function_exists( 'add_term_meta' ) ? add_term_meta( $term_id, $meta_key, $meta_value, $unique ) : add_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $unique ); +} + +/** + * WooCommerce Term Meta API + * + * WC tables for storing term meta are @deprecated from WordPress 4.4 since 4.4 has its own table. + * This function serves as a wrapper, using the new table if present, or falling back to the WC table. + * + * @param int $term_id Term ID. + * @param string $meta_key Meta key. + * @param string $meta_value Meta value (default: ''). + * @param bool $deprecated Deprecated param (default: false). + * @return bool + */ +function delete_woocommerce_term_meta( $term_id, $meta_key, $meta_value = '', $deprecated = false ) { + return function_exists( 'delete_term_meta' ) ? delete_term_meta( $term_id, $meta_key, $meta_value ) : delete_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value ); +} + +/** + * WooCommerce Term Meta API + * + * WC tables for storing term meta are @deprecated from WordPress 4.4 since 4.4 has its own table. + * This function serves as a wrapper, using the new table if present, or falling back to the WC table. + * + * @param int $term_id Term ID. + * @param string $key Meta key. + * @param bool $single Whether to return a single value. (default: true). + * @return mixed + */ +function get_woocommerce_term_meta( $term_id, $key, $single = true ) { + return function_exists( 'get_term_meta' ) ? get_term_meta( $term_id, $key, $single ) : get_metadata( 'woocommerce_term', $term_id, $key, $single ); +} + +/** + * Move a term before the a given element of its hierarchy level. + * + * @param int $the_term Term ID. + * @param int $next_id The id of the next sibling element in save hierarchy level. + * @param string $taxonomy Taxnomy. + * @param int $index Term index (default: 0). + * @param mixed $terms List of terms. (default: null). + * @return int + */ +function wc_reorder_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) { + if ( ! $terms ) { + $terms = get_terms( $taxonomy, 'menu_order=ASC&hide_empty=0&parent=0' ); + } + if ( empty( $terms ) ) { + return $index; + } + + $id = intval( $the_term->term_id ); + + $term_in_level = false; // Flag: is our term to order in this level of terms. + + foreach ( $terms as $term ) { + $term_id = intval( $term->term_id ); + + if ( $term_id === $id ) { // Our term to order, we skip. + $term_in_level = true; + continue; // Our term to order, we skip. + } + // the nextid of our term to order, lets move our term here. + if ( null !== $next_id && $term_id === $next_id ) { + $index++; + $index = wc_set_term_order( $id, $index, $taxonomy, true ); + } + + // Set order. + $index++; + $index = wc_set_term_order( $term_id, $index, $taxonomy ); + + /** + * After a term has had it's order set. + */ + do_action( 'woocommerce_after_set_term_order', $term, $index, $taxonomy ); + + // If that term has children we walk through them. + $children = get_terms( $taxonomy, "parent={$term_id}&menu_order=ASC&hide_empty=0" ); + if ( ! empty( $children ) ) { + $index = wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $children ); + } + } + + // No nextid meaning our term is in last position. + if ( $term_in_level && null === $next_id ) { + $index = wc_set_term_order( $id, $index + 1, $taxonomy, true ); + } + + return $index; +} + +/** + * Set the sort order of a term. + * + * @param int $term_id Term ID. + * @param int $index Index. + * @param string $taxonomy Taxonomy. + * @param bool $recursive Recursive (default: false). + * @return int + */ +function wc_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) { + + $term_id = (int) $term_id; + $index = (int) $index; + + // Meta name. + if ( taxonomy_is_product_attribute( $taxonomy ) ) { + $meta_name = 'order_' . esc_attr( $taxonomy ); + } else { + $meta_name = 'order'; + } + + update_woocommerce_term_meta( $term_id, $meta_name, $index ); + + if ( ! $recursive ) { + return $index; + } + + $children = get_terms( $taxonomy, "parent=$term_id&menu_order=ASC&hide_empty=0" ); + + foreach ( $children as $term ) { + $index++; + $index = wc_set_term_order( $term->term_id, $index, $taxonomy, true ); + } + + clean_term_cache( $term_id, $taxonomy ); + + return $index; +} + +/** + * Add term ordering to get_terms. + * + * It enables the support a 'menu_order' parameter to get_terms for the product_cat taxonomy. + * By default it is 'ASC'. It accepts 'DESC' too. + * + * To disable it, set it ot false (or 0). + * + * @param array $clauses Clauses. + * @param array $taxonomies Taxonomies. + * @param array $args Arguments. + * @return array + */ +function wc_terms_clauses( $clauses, $taxonomies, $args ) { + global $wpdb; + + // No sorting when menu_order is false. + if ( isset( $args['menu_order'] ) && ( false === $args['menu_order'] || 'false' === $args['menu_order'] ) ) { + return $clauses; + } + + // No sorting when orderby is non default. + if ( isset( $args['orderby'] ) && 'name' !== $args['orderby'] ) { + return $clauses; + } + + // No sorting in admin when sorting by a column. + if ( is_admin() && isset( $_GET['orderby'] ) ) { // WPCS: input var ok, CSRF ok. + return $clauses; + } + + // No need to filter counts. + if ( strpos( 'COUNT(*)', $clauses['fields'] ) !== false ) { + return $clauses; + } + + // WordPress should give us the taxonomies asked when calling the get_terms function. Only apply to categories and pa_ attributes. + $found = false; + + foreach ( (array) $taxonomies as $taxonomy ) { + if ( taxonomy_is_product_attribute( $taxonomy ) || in_array( $taxonomy, apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ), true ) ) { + $found = true; + break; + } + } + + if ( ! $found ) { + return $clauses; + } + + // Meta name. + if ( ! empty( $taxonomies[0] ) && taxonomy_is_product_attribute( $taxonomies[0] ) ) { + $meta_name = 'order_' . esc_attr( $taxonomies[0] ); + } else { + $meta_name = 'order'; + } + + // Query fields. + $clauses['fields'] = $clauses['fields'] . ', tm.meta_value'; + + // Query join. + if ( get_option( 'db_version' ) < 34370 ) { + $clauses['join'] .= " LEFT JOIN {$wpdb->woocommerce_termmeta} AS tm ON (t.term_id = tm.woocommerce_term_id AND tm.meta_key = '" . esc_sql( $meta_name ) . "') "; + } else { + $clauses['join'] .= " LEFT JOIN {$wpdb->termmeta} AS tm ON (t.term_id = tm.term_id AND tm.meta_key = '" . esc_sql( $meta_name ) . "') "; + } + + // Default to ASC. + if ( ! isset( $args['menu_order'] ) || ! in_array( strtoupper( $args['menu_order'] ), array( 'ASC', 'DESC' ), true ) ) { + $args['menu_order'] = 'ASC'; + } + + $order = 'ORDER BY tm.meta_value+0 ' . $args['menu_order']; + + if ( $clauses['orderby'] ) { + $clauses['orderby'] = str_replace( 'ORDER BY', $order . ',', $clauses['orderby'] ); + } else { + $clauses['orderby'] = $order; + } + + // Grouping. + if ( strstr( $clauses['fields'], 'tr.object_id' ) ) { + $clauses['orderby'] = ' GROUP BY t.term_id, tr.object_id ' . $clauses['orderby']; + } else { + $clauses['orderby'] = ' GROUP BY t.term_id ' . $clauses['orderby']; + } + + return $clauses; +} + +add_filter( 'terms_clauses', 'wc_terms_clauses', 99, 3 ); + +/** + * Function for recounting product terms, ignoring hidden products. + * + * @param array $terms List of terms. + * @param string $taxonomy Taxonomy. + * @param bool $callback Callback. + * @param bool $terms_are_term_taxonomy_ids If terms are from term_taxonomy_id column. + */ +function _wc_term_recount( $terms, $taxonomy, $callback = true, $terms_are_term_taxonomy_ids = true ) { + global $wpdb; + + // Standard callback. + if ( $callback ) { + _update_post_term_count( $terms, $taxonomy ); + } + + $exclude_term_ids = array(); + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + + if ( $product_visibility_term_ids['exclude-from-catalog'] ) { + $exclude_term_ids[] = $product_visibility_term_ids['exclude-from-catalog']; + } + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $product_visibility_term_ids['outofstock'] ) { + $exclude_term_ids[] = $product_visibility_term_ids['outofstock']; + } + + $query = array( + 'fields' => " + SELECT COUNT( DISTINCT ID ) FROM {$wpdb->posts} p + ", + 'join' => '', + 'where' => " + WHERE 1=1 + AND p.post_status = 'publish' + AND p.post_type = 'product' + + ", + ); + + if ( count( $exclude_term_ids ) ) { + $query['join'] .= " LEFT JOIN ( SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN ( " . implode( ',', array_map( 'absint', $exclude_term_ids ) ) . ' ) ) AS exclude_join ON exclude_join.object_id = p.ID'; + $query['where'] .= ' AND exclude_join.object_id IS NULL'; + } + + // Pre-process term taxonomy ids. + if ( ! $terms_are_term_taxonomy_ids ) { + // We passed in an array of TERMS in format id=>parent. + $terms = array_filter( (array) array_keys( $terms ) ); + } else { + // If we have term taxonomy IDs we need to get the term ID. + $term_taxonomy_ids = $terms; + $terms = array(); + foreach ( $term_taxonomy_ids as $term_taxonomy_id ) { + $term = get_term_by( 'term_taxonomy_id', $term_taxonomy_id, $taxonomy->name ); + $terms[] = $term->term_id; + } + } + + // Exit if we have no terms to count. + if ( empty( $terms ) ) { + return; + } + + // Ancestors need counting. + if ( is_taxonomy_hierarchical( $taxonomy->name ) ) { + foreach ( $terms as $term_id ) { + $terms = array_merge( $terms, get_ancestors( $term_id, $taxonomy->name ) ); + } + } + + // Unique terms only. + $terms = array_unique( $terms ); + + // Count the terms. + foreach ( $terms as $term_id ) { + $terms_to_count = array( absint( $term_id ) ); + + if ( is_taxonomy_hierarchical( $taxonomy->name ) ) { + // We need to get the $term's hierarchy so we can count its children too. + $children = get_term_children( $term_id, $taxonomy->name ); + + if ( $children && ! is_wp_error( $children ) ) { + $terms_to_count = array_unique( array_map( 'absint', array_merge( $terms_to_count, $children ) ) ); + } + } + + // Generate term query. + $term_query = $query; + $term_query['join'] .= " INNER JOIN ( SELECT object_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->term_taxonomy} using( term_taxonomy_id ) WHERE term_id IN ( " . implode( ',', array_map( 'absint', $terms_to_count ) ) . ' ) ) AS include_join ON include_join.object_id = p.ID'; + + // Get the count. + $count = $wpdb->get_var( implode( ' ', $term_query ) ); // WPCS: unprepared SQL ok. + + // Update the count. + update_woocommerce_term_meta( $term_id, 'product_count_' . $taxonomy->name, absint( $count ) ); + } + + delete_transient( 'wc_term_counts' ); +} + +/** + * Recount terms after the stock amount changes. + * + * @param int $product_id Product ID. + */ +function wc_recount_after_stock_change( $product_id ) { + if ( 'yes' !== get_option( 'woocommerce_hide_out_of_stock_items' ) ) { + return; + } + + $product_terms = get_the_terms( $product_id, 'product_cat' ); + + if ( $product_terms ) { + $product_cats = array(); + + foreach ( $product_terms as $term ) { + $product_cats[ $term->term_id ] = $term->parent; + } + + _wc_term_recount( $product_cats, get_taxonomy( 'product_cat' ), false, false ); + } + + $product_terms = get_the_terms( $product_id, 'product_tag' ); + + if ( $product_terms ) { + $product_tags = array(); + + foreach ( $product_terms as $term ) { + $product_tags[ $term->term_id ] = $term->parent; + } + + _wc_term_recount( $product_tags, get_taxonomy( 'product_tag' ), false, false ); + } +} +add_action( 'woocommerce_product_set_stock_status', 'wc_recount_after_stock_change' ); + + +/** + * Overrides the original term count for product categories and tags with the product count. + * that takes catalog visibility into account. + * + * @param array $terms List of terms. + * @param string|array $taxonomies Single taxonomy or list of taxonomies. + * @return array + */ +function wc_change_term_counts( $terms, $taxonomies ) { + if ( is_admin() || is_ajax() ) { + return $terms; + } + + if ( ! isset( $taxonomies[0] ) || ! in_array( $taxonomies[0], apply_filters( 'woocommerce_change_term_counts', array( 'product_cat', 'product_tag' ) ), true ) ) { + return $terms; + } + + $o_term_counts = get_transient( 'wc_term_counts' ); + $term_counts = $o_term_counts; + + foreach ( $terms as &$term ) { + if ( is_object( $term ) ) { + $term_counts[ $term->term_id ] = isset( $term_counts[ $term->term_id ] ) ? $term_counts[ $term->term_id ] : get_woocommerce_term_meta( $term->term_id, 'product_count_' . $taxonomies[0], true ); + + if ( '' !== $term_counts[ $term->term_id ] ) { + $term->count = absint( $term_counts[ $term->term_id ] ); + } + } + } + + // Update transient. + if ( $term_counts !== $o_term_counts ) { + set_transient( 'wc_term_counts', $term_counts, DAY_IN_SECONDS * 30 ); + } + + return $terms; +} +add_filter( 'get_terms', 'wc_change_term_counts', 10, 2 ); + +/** + * Return products in a given term, and cache value. + * + * To keep in sync, product_count will be cleared on "set_object_terms". + * + * @param int $term_id Term ID. + * @param string $taxonomy Taxonomy. + * @return array + */ +function wc_get_term_product_ids( $term_id, $taxonomy ) { + $product_ids = get_woocommerce_term_meta( $term_id, 'product_ids', true ); + + if ( false === $product_ids || ! is_array( $product_ids ) ) { + $product_ids = get_objects_in_term( $term_id, $taxonomy ); + update_woocommerce_term_meta( $term_id, 'product_ids', $product_ids ); + } + + return $product_ids; +} + +/** + * When a post is updated and terms recounted (called by _update_post_term_count), clear the ids. + * + * @param int $object_id Object ID. + * @param array $terms An array of object terms. + * @param array $tt_ids An array of term taxonomy IDs. + * @param string $taxonomy Taxonomy slug. + * @param bool $append Whether to append new terms to the old terms. + * @param array $old_tt_ids Old array of term taxonomy IDs. + */ +function wc_clear_term_product_ids( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { + foreach ( $old_tt_ids as $term_id ) { + delete_woocommerce_term_meta( $term_id, 'product_ids' ); + } + foreach ( $tt_ids as $term_id ) { + delete_woocommerce_term_meta( $term_id, 'product_ids' ); + } +} +add_action( 'set_object_terms', 'wc_clear_term_product_ids', 10, 6 ); + +/** + * Get full list of product visibilty term ids. + * + * @since 3.0.0 + * @return int[] + */ +function wc_get_product_visibility_term_ids() { + if ( ! taxonomy_exists( 'product_visibility' ) ) { + wc_doing_it_wrong( __FUNCTION__, 'wc_get_product_visibility_term_ids should not be called before taxonomies are registered (woocommerce_after_register_post_type action).', '3.1' ); + return array(); + } + return array_map( + 'absint', wp_parse_args( + wp_list_pluck( + get_terms( + array( + 'taxonomy' => 'product_visibility', + 'hide_empty' => false, + ) + ), + 'term_taxonomy_id', + 'name' + ), + array( + 'exclude-from-catalog' => 0, + 'exclude-from-search' => 0, + 'featured' => 0, + 'outofstock' => 0, + 'rated-1' => 0, + 'rated-2' => 0, + 'rated-3' => 0, + 'rated-4' => 0, + 'rated-5' => 0, + ) + ) + ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/wc-update-functions.php b/backend/wp-content/plugins/woocommerce/includes/wc-update-functions.php new file mode 100644 index 0000000..3d32c0e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/wc-update-functions.php @@ -0,0 +1,1804 @@ +get_results( "SELECT meta_value, meta_id, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_file_path' AND meta_value != '';" ); + + if ( $existing_file_paths ) { + + foreach ( $existing_file_paths as $existing_file_path ) { + + $old_file_path = trim( $existing_file_path->meta_value ); + + if ( ! empty( $old_file_path ) ) { + $file_paths = serialize( array( md5( $old_file_path ) => $old_file_path ) ); + + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = '_file_paths', meta_value = %s WHERE meta_id = %d", $file_paths, $existing_file_path->meta_id ) ); + + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}woocommerce_downloadable_product_permissions SET download_id = %s WHERE product_id = %d", md5( $old_file_path ), $existing_file_path->post_id ) ); + + } + } + } +} + +/** + * Update permalinks for 2.0 + * + * @return void + */ +function wc_update_200_permalinks() { + // Setup default permalinks if shop page is defined. + $permalinks = get_option( 'woocommerce_permalinks' ); + $shop_page_id = wc_get_page_id( 'shop' ); + + if ( empty( $permalinks ) && $shop_page_id > 0 ) { + + $base_slug = $shop_page_id > 0 && get_post( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop'; + + $category_base = get_option( 'woocommerce_prepend_shop_page_to_urls' ) == 'yes' ? trailingslashit( $base_slug ) : ''; + $category_slug = get_option( 'woocommerce_product_category_slug' ) ? get_option( 'woocommerce_product_category_slug' ) : _x( 'product-category', 'slug', 'woocommerce' ); + $tag_slug = get_option( 'woocommerce_product_tag_slug' ) ? get_option( 'woocommerce_product_tag_slug' ) : _x( 'product-tag', 'slug', 'woocommerce' ); + + if ( 'yes' == get_option( 'woocommerce_prepend_shop_page_to_products' ) ) { + $product_base = trailingslashit( $base_slug ); + } else { + $product_slug = get_option( 'woocommerce_product_slug' ); + if ( false !== $product_slug && ! empty( $product_slug ) ) { + $product_base = trailingslashit( $product_slug ); + } else { + $product_base = trailingslashit( _x( 'product', 'slug', 'woocommerce' ) ); + } + } + + if ( get_option( 'woocommerce_prepend_category_to_products' ) == 'yes' ) { + $product_base .= trailingslashit( '%product_cat%' ); + } + + $permalinks = array( + 'product_base' => untrailingslashit( $product_base ), + 'category_base' => untrailingslashit( $category_base . $category_slug ), + 'attribute_base' => untrailingslashit( $category_base ), + 'tag_base' => untrailingslashit( $category_base . $tag_slug ), + ); + + update_option( 'woocommerce_permalinks', $permalinks ); + } +} + +/** + * Update sub-category display options for 2.0 + * + * @return void + */ +function wc_update_200_subcat_display() { + // Update subcat display settings. + if ( get_option( 'woocommerce_shop_show_subcategories' ) == 'yes' ) { + if ( get_option( 'woocommerce_hide_products_when_showing_subcategories' ) == 'yes' ) { + update_option( 'woocommerce_shop_page_display', 'subcategories' ); + } else { + update_option( 'woocommerce_shop_page_display', 'both' ); + } + } + + if ( get_option( 'woocommerce_show_subcategories' ) == 'yes' ) { + if ( get_option( 'woocommerce_hide_products_when_showing_subcategories' ) == 'yes' ) { + update_option( 'woocommerce_category_archive_display', 'subcategories' ); + } else { + update_option( 'woocommerce_category_archive_display', 'both' ); + } + } +} + +/** + * Update tax rates for 2.0 + * + * @return void + */ +function wc_update_200_taxrates() { + global $wpdb; + + // Update tax rates. + $loop = 0; + $tax_rates = get_option( 'woocommerce_tax_rates' ); + + if ( $tax_rates ) { + foreach ( $tax_rates as $tax_rate ) { + + foreach ( $tax_rate['countries'] as $country => $states ) { + + $states = array_reverse( $states ); + + foreach ( $states as $state ) { + + if ( '*' == $state ) { + $state = ''; + } + + $wpdb->insert( + $wpdb->prefix . 'woocommerce_tax_rates', + array( + 'tax_rate_country' => $country, + 'tax_rate_state' => $state, + 'tax_rate' => $tax_rate['rate'], + 'tax_rate_name' => $tax_rate['label'], + 'tax_rate_priority' => 1, + 'tax_rate_compound' => ( 'yes' === $tax_rate['compound'] ) ? 1 : 0, + 'tax_rate_shipping' => ( 'yes' === $tax_rate['shipping'] ) ? 1 : 0, + 'tax_rate_order' => $loop, + 'tax_rate_class' => $tax_rate['class'], + ) + ); + + $loop++; + } + } + } + } + + $local_tax_rates = get_option( 'woocommerce_local_tax_rates' ); + + if ( $local_tax_rates ) { + foreach ( $local_tax_rates as $tax_rate ) { + + $location_type = ( 'postcode' === $tax_rate['location_type'] ) ? 'postcode' : 'city'; + + if ( '*' == $tax_rate['state'] ) { + $tax_rate['state'] = ''; + } + + $wpdb->insert( + $wpdb->prefix . 'woocommerce_tax_rates', + array( + 'tax_rate_country' => $tax_rate['country'], + 'tax_rate_state' => $tax_rate['state'], + 'tax_rate' => $tax_rate['rate'], + 'tax_rate_name' => $tax_rate['label'], + 'tax_rate_priority' => 2, + 'tax_rate_compound' => ( 'yes' === $tax_rate['compound'] ) ? 1 : 0, + 'tax_rate_shipping' => ( 'yes' === $tax_rate['shipping'] ) ? 1 : 0, + 'tax_rate_order' => $loop, + 'tax_rate_class' => $tax_rate['class'], + ) + ); + + $tax_rate_id = $wpdb->insert_id; + + if ( $tax_rate['locations'] ) { + foreach ( $tax_rate['locations'] as $location ) { + + $wpdb->insert( + $wpdb->prefix . 'woocommerce_tax_rate_locations', + array( + 'location_code' => $location, + 'tax_rate_id' => $tax_rate_id, + 'location_type' => $location_type, + ) + ); + + } + } + + $loop++; + } + } + + update_option( 'woocommerce_tax_rates_backup', $tax_rates ); + update_option( 'woocommerce_local_tax_rates_backup', $local_tax_rates ); + delete_option( 'woocommerce_tax_rates' ); + delete_option( 'woocommerce_local_tax_rates' ); +} + +/** + * Update order item line items for 2.0 + * + * @return void + */ +function wc_update_200_line_items() { + global $wpdb; + + // Now its time for the massive update to line items - move them to the new DB tables. + // Reverse with UPDATE `wpwc_postmeta` SET meta_key = '_order_items' WHERE meta_key = '_order_items_old'. + $order_item_rows = $wpdb->get_results( + "SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_order_items'" + ); + + foreach ( $order_item_rows as $order_item_row ) { + + $order_items = (array) maybe_unserialize( $order_item_row->meta_value ); + + foreach ( $order_items as $order_item ) { + + if ( ! isset( $order_item['line_total'] ) && isset( $order_item['taxrate'] ) && isset( $order_item['cost'] ) ) { + $order_item['line_tax'] = number_format( ( $order_item['cost'] * $order_item['qty'] ) * ( $order_item['taxrate'] / 100 ), 2, '.', '' ); + $order_item['line_total'] = $order_item['cost'] * $order_item['qty']; + $order_item['line_subtotal_tax'] = $order_item['line_tax']; + $order_item['line_subtotal'] = $order_item['line_total']; + } + + $order_item['line_tax'] = isset( $order_item['line_tax'] ) ? $order_item['line_tax'] : 0; + $order_item['line_total'] = isset( $order_item['line_total'] ) ? $order_item['line_total'] : 0; + $order_item['line_subtotal_tax'] = isset( $order_item['line_subtotal_tax'] ) ? $order_item['line_subtotal_tax'] : 0; + $order_item['line_subtotal'] = isset( $order_item['line_subtotal'] ) ? $order_item['line_subtotal'] : 0; + + $item_id = wc_add_order_item( + $order_item_row->post_id, + array( + 'order_item_name' => $order_item['name'], + 'order_item_type' => 'line_item', + ) + ); + + // Add line item meta. + if ( $item_id ) { + wc_add_order_item_meta( $item_id, '_qty', absint( $order_item['qty'] ) ); + wc_add_order_item_meta( $item_id, '_tax_class', $order_item['tax_class'] ); + wc_add_order_item_meta( $item_id, '_product_id', $order_item['id'] ); + wc_add_order_item_meta( $item_id, '_variation_id', $order_item['variation_id'] ); + wc_add_order_item_meta( $item_id, '_line_subtotal', wc_format_decimal( $order_item['line_subtotal'] ) ); + wc_add_order_item_meta( $item_id, '_line_subtotal_tax', wc_format_decimal( $order_item['line_subtotal_tax'] ) ); + wc_add_order_item_meta( $item_id, '_line_total', wc_format_decimal( $order_item['line_total'] ) ); + wc_add_order_item_meta( $item_id, '_line_tax', wc_format_decimal( $order_item['line_tax'] ) ); + + $meta_rows = array(); + + // Insert meta. + if ( ! empty( $order_item['item_meta'] ) ) { + foreach ( $order_item['item_meta'] as $key => $meta ) { + // Backwards compatibility. + if ( is_array( $meta ) && isset( $meta['meta_name'] ) ) { + $meta_rows[] = '(' . $item_id . ',"' . esc_sql( $meta['meta_name'] ) . '","' . esc_sql( $meta['meta_value'] ) . '")'; + } else { + $meta_rows[] = '(' . $item_id . ',"' . esc_sql( $key ) . '","' . esc_sql( $meta ) . '")'; + } + } + } + + // Insert meta rows at once. + if ( count( $meta_rows ) > 0 ) { + $wpdb->query( + $wpdb->prepare( + "INSERT INTO {$wpdb->prefix}woocommerce_order_itemmeta ( order_item_id, meta_key, meta_value ) + VALUES " . implode( ',', $meta_rows ) . ';', // @codingStandardsIgnoreLine + $order_item_row->post_id + ) + ); + } + + // Delete from DB (rename). + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} + SET meta_key = '_order_items_old' + WHERE meta_key = '_order_items' + AND post_id = %d", + $order_item_row->post_id + ) + ); + } + + unset( $meta_rows, $item_id, $order_item ); + } + } + + // Do the same kind of update for order_taxes - move to lines. + // Reverse with UPDATE `wpwc_postmeta` SET meta_key = '_order_taxes' WHERE meta_key = '_order_taxes_old'. + $order_tax_rows = $wpdb->get_results( + "SELECT meta_value, post_id FROM {$wpdb->postmeta} + WHERE meta_key = '_order_taxes'" + ); + + foreach ( $order_tax_rows as $order_tax_row ) { + + $order_taxes = (array) maybe_unserialize( $order_tax_row->meta_value ); + + if ( ! empty( $order_taxes ) ) { + foreach ( $order_taxes as $order_tax ) { + + if ( ! isset( $order_tax['label'] ) || ! isset( $order_tax['cart_tax'] ) || ! isset( $order_tax['shipping_tax'] ) ) { + continue; + } + + $item_id = wc_add_order_item( + $order_tax_row->post_id, array( + 'order_item_name' => $order_tax['label'], + 'order_item_type' => 'tax', + ) + ); + + // Add line item meta. + if ( $item_id ) { + wc_add_order_item_meta( $item_id, 'compound', absint( isset( $order_tax['compound'] ) ? $order_tax['compound'] : 0 ) ); + wc_add_order_item_meta( $item_id, 'tax_amount', wc_clean( $order_tax['cart_tax'] ) ); + wc_add_order_item_meta( $item_id, 'shipping_tax_amount', wc_clean( $order_tax['shipping_tax'] ) ); + } + + // Delete from DB (rename). + $wpdb->query( + $wpdb->prepare( + "UPDATE {$wpdb->postmeta} + SET meta_key = '_order_taxes_old' + WHERE meta_key = '_order_taxes' + AND post_id = %d", + $order_tax_row->post_id + ) + ); + + unset( $tax_amount ); + } + } + } +} + +/** + * Update image settings for 2.0 + * + * @return void + */ +function wc_update_200_images() { + // Grab the pre 2.0 Image options and use to populate the new image options settings, + // cleaning up afterwards like nice people do. + foreach ( array( 'catalog', 'single', 'thumbnail' ) as $value ) { + + $old_settings = array_filter( + array( + 'width' => get_option( 'woocommerce_' . $value . '_image_width' ), + 'height' => get_option( 'woocommerce_' . $value . '_image_height' ), + 'crop' => get_option( 'woocommerce_' . $value . '_image_crop' ), + ) + ); + + if ( ! empty( $old_settings ) && update_option( 'shop_' . $value . '_image_size', $old_settings ) ) { + + delete_option( 'woocommerce_' . $value . '_image_width' ); + delete_option( 'woocommerce_' . $value . '_image_height' ); + delete_option( 'woocommerce_' . $value . '_image_crop' ); + + } + } +} + +/** + * Update DB version for 2.0 + * + * @return void + */ +function wc_update_200_db_version() { + WC_Install::update_db_version( '2.0.0' ); +} + +/** + * Update Brazilian States for 2.0.9 + * + * @return void + */ +function wc_update_209_brazillian_state() { + global $wpdb; + + // Update brazillian state codes. + $wpdb->update( + $wpdb->postmeta, + array( + 'meta_value' => 'BA', + ), + array( + 'meta_key' => '_billing_state', + 'meta_value' => 'BH', + ) + ); + $wpdb->update( + $wpdb->postmeta, + array( + 'meta_value' => 'BA', + ), + array( + 'meta_key' => '_shipping_state', + 'meta_value' => 'BH', + ) + ); + $wpdb->update( + $wpdb->usermeta, + array( + 'meta_value' => 'BA', + ), + array( + 'meta_key' => 'billing_state', + 'meta_value' => 'BH', + ) + ); + $wpdb->update( + $wpdb->usermeta, + array( + 'meta_value' => 'BA', + ), + array( + 'meta_key' => 'shipping_state', + 'meta_value' => 'BH', + ) + ); +} + +/** + * Update DB version for 2.0.9 + * + * @return void + */ +function wc_update_209_db_version() { + WC_Install::update_db_version( '2.0.9' ); +} + +/** + * Remove pages for 2.1 + * + * @return void + */ +function wc_update_210_remove_pages() { + // Pages no longer used. + wp_trash_post( get_option( 'woocommerce_pay_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_thanks_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_view_order_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_change_password_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_edit_address_page_id' ) ); + wp_trash_post( get_option( 'woocommerce_lost_password_page_id' ) ); +} + +/** + * Update file paths to support multiple files for 2.1 + * + * @return void + */ +function wc_update_210_file_paths() { + global $wpdb; + + // Upgrade file paths to support multiple file paths + names etc. + $existing_file_paths = $wpdb->get_results( "SELECT meta_value, meta_id FROM {$wpdb->postmeta} WHERE meta_key = '_file_paths' AND meta_value != '';" ); + + if ( $existing_file_paths ) { + + foreach ( $existing_file_paths as $existing_file_path ) { + + $needs_update = false; + $new_value = array(); + $value = maybe_unserialize( trim( $existing_file_path->meta_value ) ); + + if ( $value ) { + foreach ( $value as $key => $file ) { + if ( ! is_array( $file ) ) { + $needs_update = true; + $new_value[ $key ] = array( + 'file' => $file, + 'name' => wc_get_filename_from_url( $file ), + ); + } else { + $new_value[ $key ] = $file; + } + } + if ( $needs_update ) { + $new_value = serialize( $new_value ); + + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = %s, meta_value = %s WHERE meta_id = %d", '_downloadable_files', $new_value, $existing_file_path->meta_id ) ); + } + } + } + } +} + +/** + * Update DB version for 2.1 + * + * @return void + */ +function wc_update_210_db_version() { + WC_Install::update_db_version( '2.1.0' ); +} + +/** + * Update shipping options for 2.2 + * + * @return void + */ +function wc_update_220_shipping() { + $woocommerce_ship_to_destination = 'shipping'; + + if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'yes' ) { + $woocommerce_ship_to_destination = 'billing_only'; + } elseif ( get_option( 'woocommerce_ship_to_billing' ) === 'yes' ) { + $woocommerce_ship_to_destination = 'billing'; + } + + add_option( 'woocommerce_ship_to_destination', $woocommerce_ship_to_destination, '', 'no' ); +} + +/** + * Update order statuses for 2.2 + * + * @return void + */ +function wc_update_220_order_status() { + global $wpdb; + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-pending' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'pending%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-processing' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'processing%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-on-hold' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'on-hold%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-completed' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'completed%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-cancelled' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'cancelled%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-refunded' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'refunded%';" + ); + $wpdb->query( + "UPDATE {$wpdb->posts} as posts + LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_id + LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) + LEFT JOIN {$wpdb->terms} AS term USING( term_id ) + SET posts.post_status = 'wc-failed' + WHERE posts.post_type = 'shop_order' + AND posts.post_status = 'publish' + AND tax.taxonomy = 'shop_order_status' + AND term.slug LIKE 'failed%';" + ); +} + +/** + * Update variations for 2.2 + * + * @return void + */ +function wc_update_220_variations() { + global $wpdb; + // Update variations which manage stock. + $update_variations = $wpdb->get_results( + "SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent FROM {$wpdb->posts} as posts + LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock' + LEFT OUTER JOIN {$wpdb->postmeta} as postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = '_manage_stock' + WHERE posts.post_type = 'product_variation' + AND postmeta.meta_value IS NOT NULL + AND postmeta.meta_value != '' + AND postmeta2.meta_value IS NULL" + ); + + foreach ( $update_variations as $variation ) { + $parent_backorders = get_post_meta( $variation->variation_parent, '_backorders', true ); + add_post_meta( $variation->variation_id, '_manage_stock', 'yes', true ); + add_post_meta( $variation->variation_id, '_backorders', $parent_backorders ? $parent_backorders : 'no', true ); + } +} + +/** + * Update attributes for 2.2 + * + * @return void + */ +function wc_update_220_attributes() { + global $wpdb; + // Update taxonomy names with correct sanitized names. + $attribute_taxonomies = $wpdb->get_results( 'SELECT attribute_name, attribute_id FROM ' . $wpdb->prefix . 'woocommerce_attribute_taxonomies' ); + + foreach ( $attribute_taxonomies as $attribute_taxonomy ) { + $sanitized_attribute_name = wc_sanitize_taxonomy_name( $attribute_taxonomy->attribute_name ); + if ( $sanitized_attribute_name !== $attribute_taxonomy->attribute_name ) { + if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT 1=1 FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $sanitized_attribute_name ) ) ) { + // Update attribute. + $wpdb->update( + "{$wpdb->prefix}woocommerce_attribute_taxonomies", + array( + 'attribute_name' => $sanitized_attribute_name, + ), + array( + 'attribute_id' => $attribute_taxonomy->attribute_id, + ) + ); + + // Update terms. + $wpdb->update( + $wpdb->term_taxonomy, + array( 'taxonomy' => wc_attribute_taxonomy_name( $sanitized_attribute_name ) ), + array( 'taxonomy' => 'pa_' . $attribute_taxonomy->attribute_name ) + ); + } + } + } +} + +/** + * Update DB version for 2.2 + * + * @return void + */ +function wc_update_220_db_version() { + WC_Install::update_db_version( '2.2.0' ); +} + +/** + * Update options for 2.3 + * + * @return void + */ +function wc_update_230_options() { + // _money_spent and _order_count may be out of sync - clear them + delete_metadata( 'user', 0, '_money_spent', '', true ); + delete_metadata( 'user', 0, '_order_count', '', true ); + + // To prevent taxes being hidden when using a default 'no address' in a store with tax inc prices, set the woocommerce_default_customer_address to use the store base address by default. + if ( '' === get_option( 'woocommerce_default_customer_address', false ) && wc_prices_include_tax() ) { + update_option( 'woocommerce_default_customer_address', 'base' ); + } +} + +/** + * Update DB version for 2.3 + * + * @return void + */ +function wc_update_230_db_version() { + WC_Install::update_db_version( '2.3.0' ); +} + +/** + * Update calc discount options for 2.4 + * + * @return void + */ +function wc_update_240_options() { + /** + * Coupon discount calculations. + * Maintain the old coupon logic for upgrades. + */ + update_option( 'woocommerce_calc_discounts_sequentially', 'yes' ); +} + +/** + * Update shipping methods for 2.4 + * + * @return void + */ +function wc_update_240_shipping_methods() { + /** + * Flat Rate Shipping. + * Update legacy options to new math based options. + */ + $shipping_methods = array( + 'woocommerce_flat_rates' => new WC_Shipping_Legacy_Flat_Rate(), + 'woocommerce_international_delivery_flat_rates' => new WC_Shipping_Legacy_International_Delivery(), + ); + foreach ( $shipping_methods as $flat_rate_option_key => $shipping_method ) { + // Stop this running more than once if routine is repeated. + if ( version_compare( $shipping_method->get_option( 'version', 0 ), '2.4.0', '<' ) ) { + $has_classes = count( WC()->shipping->get_shipping_classes() ) > 0; + $cost_key = $has_classes ? 'no_class_cost' : 'cost'; + $min_fee = $shipping_method->get_option( 'minimum_fee' ); + $math_cost_strings = array( + 'cost' => array(), + 'no_class_cost' => array(), + ); + + $math_cost_strings[ $cost_key ][] = $shipping_method->get_option( 'cost' ); + $fee = $shipping_method->get_option( 'fee' ); + + if ( $fee ) { + $math_cost_strings[ $cost_key ][] = strstr( $fee, '%' ) ? '[fee percent="' . str_replace( '%', '', $fee ) . '" min="' . esc_attr( $min_fee ) . '"]' : $fee; + } + + foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) { + $rate_key = 'class_cost_' . $shipping_class->slug; + $math_cost_strings[ $rate_key ] = $math_cost_strings['no_class_cost']; + } + + $flat_rates = array_filter( (array) get_option( $flat_rate_option_key, array() ) ); + + if ( $flat_rates ) { + foreach ( $flat_rates as $shipping_class => $rate ) { + $rate_key = 'class_cost_' . $shipping_class; + if ( $rate['cost'] || $rate['fee'] ) { + $math_cost_strings[ $rate_key ][] = $rate['cost']; + $math_cost_strings[ $rate_key ][] = strstr( $rate['fee'], '%' ) ? '[fee percent="' . str_replace( '%', '', $rate['fee'] ) . '" min="' . esc_attr( $min_fee ) . '"]' : $rate['fee']; + } + } + } + + if ( 'item' === $shipping_method->type ) { + foreach ( $math_cost_strings as $key => $math_cost_string ) { + $math_cost_strings[ $key ] = array_filter( array_map( 'trim', $math_cost_strings[ $key ] ) ); + if ( ! empty( $math_cost_strings[ $key ] ) ) { + $last_key = max( 0, count( $math_cost_strings[ $key ] ) - 1 ); + $math_cost_strings[ $key ][0] = '( ' . $math_cost_strings[ $key ][0]; + $math_cost_strings[ $key ][ $last_key ] .= ' ) * [qty]'; + } + } + } + + $math_cost_strings['cost'][] = $shipping_method->get_option( 'cost_per_order' ); + + // Save settings. + foreach ( $math_cost_strings as $option_id => $math_cost_string ) { + $shipping_method->settings[ $option_id ] = implode( ' + ', array_filter( $math_cost_string ) ); + } + + $shipping_method->settings['version'] = '2.4.0'; + $shipping_method->settings['type'] = 'item' === $shipping_method->settings['type'] ? 'class' : $shipping_method->settings['type']; + + update_option( $shipping_method->plugin_id . $shipping_method->id . '_settings', $shipping_method->settings ); + } + } +} + +/** + * Update API keys for 2.4 + * + * @return void + */ +function wc_update_240_api_keys() { + global $wpdb; + /** + * Update the old user API keys to the new Apps keys. + */ + $api_users = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'woocommerce_api_consumer_key'" ); + $apps_keys = array(); + + // Get user data. + foreach ( $api_users as $_user ) { + $user = get_userdata( $_user->user_id ); + $apps_keys[] = array( + 'user_id' => $user->ID, + 'permissions' => $user->woocommerce_api_key_permissions, + 'consumer_key' => wc_api_hash( $user->woocommerce_api_consumer_key ), + 'consumer_secret' => $user->woocommerce_api_consumer_secret, + 'truncated_key' => substr( $user->woocommerce_api_consumer_secret, -7 ), + ); + } + + if ( ! empty( $apps_keys ) ) { + // Create new apps. + foreach ( $apps_keys as $app ) { + $wpdb->insert( + $wpdb->prefix . 'woocommerce_api_keys', + $app, + array( + '%d', + '%s', + '%s', + '%s', + '%s', + ) + ); + } + + // Delete old user keys from usermeta. + foreach ( $api_users as $_user ) { + $user_id = intval( $_user->user_id ); + delete_user_meta( $user_id, 'woocommerce_api_consumer_key' ); + delete_user_meta( $user_id, 'woocommerce_api_consumer_secret' ); + delete_user_meta( $user_id, 'woocommerce_api_key_permissions' ); + } + } +} + +/** + * Update webhooks for 2.4 + * + * @return void + */ +function wc_update_240_webhooks() { + /** + * Webhooks. + * Make sure order.update webhooks get the woocommerce_order_edit_status hook. + */ + $order_update_webhooks = get_posts( + array( + 'posts_per_page' => -1, + 'post_type' => 'shop_webhook', + 'meta_key' => '_topic', + 'meta_value' => 'order.updated', + ) + ); + foreach ( $order_update_webhooks as $order_update_webhook ) { + $webhook = new WC_Webhook( $order_update_webhook->ID ); + $webhook->set_topic( 'order.updated' ); + } +} + +/** + * Update refunds for 2.4 + * + * @return void + */ +function wc_update_240_refunds() { + global $wpdb; + /** + * Refunds for full refunded orders. + * Update fully refunded orders to ensure they have a refund line item so reports add up. + */ + $refunded_orders = get_posts( + array( + 'posts_per_page' => -1, + 'post_type' => 'shop_order', + 'post_status' => array( 'wc-refunded' ), + ) + ); + + // Ensure emails are disabled during this update routine. + remove_all_actions( 'woocommerce_order_status_refunded_notification' ); + remove_all_actions( 'woocommerce_order_partially_refunded_notification' ); + remove_action( 'woocommerce_order_status_refunded', array( 'WC_Emails', 'send_transactional_email' ) ); + remove_action( 'woocommerce_order_partially_refunded', array( 'WC_Emails', 'send_transactional_email' ) ); + + foreach ( $refunded_orders as $refunded_order ) { + $order_total = get_post_meta( $refunded_order->ID, '_order_total', true ); + $refunded_total = $wpdb->get_var( + $wpdb->prepare( + "SELECT SUM( postmeta.meta_value ) + FROM $wpdb->postmeta AS postmeta + INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d ) + WHERE postmeta.meta_key = '_refund_amount' + AND postmeta.post_id = posts.ID", + $refunded_order->ID + ) + ); + + if ( $order_total > $refunded_total ) { + wc_create_refund( + array( + 'amount' => $order_total - $refunded_total, + 'reason' => __( 'Order fully refunded', 'woocommerce' ), + 'order_id' => $refunded_order->ID, + 'line_items' => array(), + 'date' => $refunded_order->post_modified, + ) + ); + } + } + + wc_delete_shop_order_transients(); +} + +/** + * Update DB version for 2.4 + * + * @return void + */ +function wc_update_240_db_version() { + WC_Install::update_db_version( '2.4.0' ); +} + +/** + * Update variations for 2.4.1 + * + * @return void + */ +function wc_update_241_variations() { + global $wpdb; + + // Select variations that don't have any _stock_status implemented on WooCommerce 2.2. + $update_variations = $wpdb->get_results( + "SELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent + FROM {$wpdb->posts} as posts + LEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock_status' + WHERE posts.post_type = 'product_variation' + AND postmeta.meta_value IS NULL" + ); + + foreach ( $update_variations as $variation ) { + // Get the parent _stock_status. + $parent_stock_status = get_post_meta( $variation->variation_parent, '_stock_status', true ); + + // Set the _stock_status. + add_post_meta( $variation->variation_id, '_stock_status', $parent_stock_status ? $parent_stock_status : 'instock', true ); + + // Delete old product children array. + delete_transient( 'wc_product_children_' . $variation->variation_parent ); + } + + // Invalidate old transients such as wc_var_price. + WC_Cache_Helper::get_transient_version( 'product', true ); +} + +/** + * Update DB version for 2.4.1 + * + * @return void + */ +function wc_update_241_db_version() { + WC_Install::update_db_version( '2.4.1' ); +} + +/** + * Update currency settings for 2.5 + * + * @return void + */ +function wc_update_250_currency() { + global $wpdb; + // Fix currency settings for LAK currency. + $current_currency = get_option( 'woocommerce_currency' ); + + if ( 'KIP' === $current_currency ) { + update_option( 'woocommerce_currency', 'LAK' ); + } + + // Update LAK currency code. + $wpdb->update( + $wpdb->postmeta, + array( + 'meta_value' => 'LAK', + ), + array( + 'meta_key' => '_order_currency', + 'meta_value' => 'KIP', + ) + ); +} + +/** + * Update DB version for 2.5 + * + * @return void + */ +function wc_update_250_db_version() { + WC_Install::update_db_version( '2.5.0' ); +} + +/** + * Update ship to countries options for 2.6 + * + * @return void + */ +function wc_update_260_options() { + // woocommerce_calc_shipping option has been removed in 2.6. + if ( 'no' === get_option( 'woocommerce_calc_shipping' ) ) { + update_option( 'woocommerce_ship_to_countries', 'disabled' ); + } + + WC_Admin_Notices::add_notice( 'legacy_shipping' ); +} + +/** + * Update term meta for 2.6 + * + * @return void + */ +function wc_update_260_termmeta() { + global $wpdb; + /** + * Migrate term meta to WordPress tables. + */ + if ( get_option( 'db_version' ) >= 34370 && $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_termmeta';" ) ) { + if ( $wpdb->query( "INSERT INTO {$wpdb->termmeta} ( term_id, meta_key, meta_value ) SELECT woocommerce_term_id, meta_key, meta_value FROM {$wpdb->prefix}woocommerce_termmeta;" ) ) { + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_termmeta" ); + wp_cache_flush(); + } + } +} + +/** + * Update zones for 2.6 + * + * @return void + */ +function wc_update_260_zones() { + global $wpdb; + /** + * Old (table rate) shipping zones to new core shipping zones migration. + * zone_enabled and zone_type are no longer used, but it's safe to leave them be. + */ + if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}woocommerce_shipping_zones` LIKE 'zone_enabled';" ) ) { + $wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_shipping_zones CHANGE `zone_type` `zone_type` VARCHAR(40) NOT NULL DEFAULT '';" ); + $wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_shipping_zones CHANGE `zone_enabled` `zone_enabled` INT(1) NOT NULL DEFAULT 1;" ); + } +} + +/** + * Update zone methods for 2.6 + * + * @return void + */ +function wc_update_260_zone_methods() { + global $wpdb; + + /** + * Shipping zones in WC 2.6.0 use a table named woocommerce_shipping_zone_methods. + * Migrate the old data out of woocommerce_shipping_zone_shipping_methods into the new table and port over any known options (used by table rates and flat rate boxes). + */ + if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_shipping_zone_shipping_methods';" ) ) { + $old_methods = $wpdb->get_results( "SELECT zone_id, shipping_method_type, shipping_method_order, shipping_method_id FROM {$wpdb->prefix}woocommerce_shipping_zone_shipping_methods;" ); + + if ( $old_methods ) { + $max_new_id = $wpdb->get_var( "SELECT MAX(instance_id) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods" ); + $max_old_id = $wpdb->get_var( "SELECT MAX(shipping_method_id) FROM {$wpdb->prefix}woocommerce_shipping_zone_shipping_methods" ); + + // Avoid ID conflicts. + $wpdb->query( $wpdb->prepare( "ALTER TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods AUTO_INCREMENT = %d;", max( $max_new_id, $max_old_id ) + 1 ) ); + + // Store changes. + $changes = array(); + + // Move data. + foreach ( $old_methods as $old_method ) { + $wpdb->insert( + $wpdb->prefix . 'woocommerce_shipping_zone_methods', array( + 'zone_id' => $old_method->zone_id, + 'method_id' => $old_method->shipping_method_type, + 'method_order' => $old_method->shipping_method_order, + ) + ); + + $new_instance_id = $wpdb->insert_id; + + // Move main settings. + $older_settings_key = 'woocommerce_' . $old_method->shipping_method_type . '-' . $old_method->shipping_method_id . '_settings'; + $old_settings_key = 'woocommerce_' . $old_method->shipping_method_type . '_' . $old_method->shipping_method_id . '_settings'; + add_option( 'woocommerce_' . $old_method->shipping_method_type . '_' . $new_instance_id . '_settings', get_option( $old_settings_key, get_option( $older_settings_key ) ) ); + + // Handling for table rate and flat rate box shipping. + if ( 'table_rate' === $old_method->shipping_method_type ) { + // Move priority settings. + add_option( 'woocommerce_table_rate_default_priority_' . $new_instance_id, get_option( 'woocommerce_table_rate_default_priority_' . $old_method->shipping_method_id ) ); + add_option( 'woocommerce_table_rate_priorities_' . $new_instance_id, get_option( 'woocommerce_table_rate_priorities_' . $old_method->shipping_method_id ) ); + + // Move rates. + $wpdb->update( + $wpdb->prefix . 'woocommerce_shipping_table_rates', + array( + 'shipping_method_id' => $new_instance_id, + ), + array( + 'shipping_method_id' => $old_method->shipping_method_id, + ) + ); + } elseif ( 'flat_rate_boxes' === $old_method->shipping_method_type ) { + $wpdb->update( + $wpdb->prefix . 'woocommerce_shipping_flat_rate_boxes', + array( + 'shipping_method_id' => $new_instance_id, + ), + array( + 'shipping_method_id' => $old_method->shipping_method_id, + ) + ); + } + + $changes[ $old_method->shipping_method_id ] = $new_instance_id; + } + + // $changes contains keys (old method ids) and values (new instance ids) if extra processing is needed in plugins. + // Store this to an option so extensions can pick it up later, then fire an action. + update_option( 'woocommerce_updated_instance_ids', $changes ); + do_action( 'woocommerce_updated_instance_ids', $changes ); + } + } + + // Change ranges used to ... + $wpdb->query( "UPDATE {$wpdb->prefix}woocommerce_shipping_zone_locations SET location_code = REPLACE( location_code, '-', '...' );" ); +} + +/** + * Update refunds for 2.6 + * + * @return void + */ +function wc_update_260_refunds() { + global $wpdb; + /** + * Refund item qty should be negative. + */ + $wpdb->query( + "UPDATE {$wpdb->prefix}woocommerce_order_itemmeta as item_meta + LEFT JOIN {$wpdb->prefix}woocommerce_order_items as items ON item_meta.order_item_id = items.order_item_id + LEFT JOIN {$wpdb->posts} as posts ON items.order_id = posts.ID + SET item_meta.meta_value = item_meta.meta_value * -1 + WHERE item_meta.meta_value > 0 AND item_meta.meta_key = '_qty' AND posts.post_type = 'shop_order_refund'" + ); +} + +/** + * Update DB version for 2.6 + * + * @return void + */ +function wc_update_260_db_version() { + WC_Install::update_db_version( '2.6.0' ); +} + +/** + * Update webhooks for 3.0 + * + * @return void + */ +function wc_update_300_webhooks() { + /** + * Make sure product.update webhooks get the woocommerce_product_quick_edit_save + * and woocommerce_product_bulk_edit_save hooks. + */ + $product_update_webhooks = get_posts( + array( + 'posts_per_page' => -1, + 'post_type' => 'shop_webhook', + 'meta_key' => '_topic', + 'meta_value' => 'product.updated', + ) + ); + foreach ( $product_update_webhooks as $product_update_webhook ) { + $webhook = new WC_Webhook( $product_update_webhook->ID ); + $webhook->set_topic( 'product.updated' ); + } +} + +/** + * Add an index to the field comment_type to improve the response time of the query + * used by WC_Comments::wp_count_comments() to get the number of comments by type. + */ +function wc_update_300_comment_type_index() { + global $wpdb; + + $index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->comments} WHERE column_name = 'comment_type' and key_name = 'woo_idx_comment_type'" ); + + if ( is_null( $index_exists ) ) { + // Add an index to the field comment_type to improve the response time of the query + // used by WC_Comments::wp_count_comments() to get the number of comments by type. + $wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" ); + } +} + +/** + * Update grouped products for 3.0 + * + * @return void + */ +function wc_update_300_grouped_products() { + global $wpdb; + $parents = $wpdb->get_col( "SELECT DISTINCT( post_parent ) FROM {$wpdb->posts} WHERE post_parent > 0 AND post_type = 'product';" ); + foreach ( $parents as $parent_id ) { + $parent = wc_get_product( $parent_id ); + if ( $parent && $parent->is_type( 'grouped' ) ) { + $children_ids = get_posts( + array( + 'post_parent' => $parent_id, + 'posts_per_page' => -1, + 'post_type' => 'product', + 'fields' => 'ids', + ) + ); + update_post_meta( $parent_id, '_children', $children_ids ); + + // Update children to remove the parent. + $wpdb->update( + $wpdb->posts, + array( + 'post_parent' => 0, + ), + array( + 'post_parent' => $parent_id, + ) + ); + } + } +} + +/** + * Update shipping tax classes for 3.0 + * + * @return void + */ +function wc_update_300_settings() { + $woocommerce_shipping_tax_class = get_option( 'woocommerce_shipping_tax_class' ); + if ( '' === $woocommerce_shipping_tax_class ) { + update_option( 'woocommerce_shipping_tax_class', 'inherit' ); + } elseif ( 'standard' === $woocommerce_shipping_tax_class ) { + update_option( 'woocommerce_shipping_tax_class', '' ); + } +} + +/** + * Convert meta values into term for product visibility. + */ +function wc_update_300_product_visibility() { + global $wpdb; + + WC_Install::create_terms(); + + $featured_term = get_term_by( 'name', 'featured', 'product_visibility' ); + + if ( $featured_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_featured' AND meta_value = 'yes';", $featured_term->term_taxonomy_id ) ); + } + + $exclude_search_term = get_term_by( 'name', 'exclude-from-search', 'product_visibility' ); + + if ( $exclude_search_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_visibility' AND meta_value IN ('hidden', 'catalog');", $exclude_search_term->term_taxonomy_id ) ); + } + + $exclude_catalog_term = get_term_by( 'name', 'exclude-from-catalog', 'product_visibility' ); + + if ( $exclude_catalog_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_visibility' AND meta_value IN ('hidden', 'search');", $exclude_catalog_term->term_taxonomy_id ) ); + } + + $outofstock_term = get_term_by( 'name', 'outofstock', 'product_visibility' ); + + if ( $outofstock_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_stock_status' AND meta_value = 'outofstock';", $outofstock_term->term_taxonomy_id ) ); + } + + $rating_term = get_term_by( 'name', 'rated-1', 'product_visibility' ); + + if ( $rating_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 1;", $rating_term->term_taxonomy_id ) ); + } + + $rating_term = get_term_by( 'name', 'rated-2', 'product_visibility' ); + + if ( $rating_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 2;", $rating_term->term_taxonomy_id ) ); + } + + $rating_term = get_term_by( 'name', 'rated-3', 'product_visibility' ); + + if ( $rating_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 3;", $rating_term->term_taxonomy_id ) ); + } + + $rating_term = get_term_by( 'name', 'rated-4', 'product_visibility' ); + + if ( $rating_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 4;", $rating_term->term_taxonomy_id ) ); + } + + $rating_term = get_term_by( 'name', 'rated-5', 'product_visibility' ); + + if ( $rating_term ) { + $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO {$wpdb->term_relationships} SELECT post_id, %d, 0 FROM {$wpdb->postmeta} WHERE meta_key = '_wc_average_rating' AND ROUND( meta_value ) = 5;", $rating_term->term_taxonomy_id ) ); + } +} + +/** + * Update DB Version. + */ +function wc_update_300_db_version() { + WC_Install::update_db_version( '3.0.0' ); +} + +/** + * Add an index to the downloadable product permissions table to improve performance of update_user_by_order_id. + */ +function wc_update_310_downloadable_products() { + global $wpdb; + + $index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE column_name = 'order_id' and key_name = 'order_id'" ); + + if ( is_null( $index_exists ) ) { + $wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions ADD INDEX order_id (order_id)" ); + } +} + +/** + * Find old order notes and ensure they have the correct type for exclusion. + */ +function wc_update_310_old_comments() { + global $wpdb; + + $wpdb->query( "UPDATE $wpdb->comments comments LEFT JOIN $wpdb->posts as posts ON comments.comment_post_ID = posts.ID SET comment_type = 'order_note' WHERE posts.post_type = 'shop_order' AND comment_type = '';" ); +} + +/** + * Update DB Version. + */ +function wc_update_310_db_version() { + WC_Install::update_db_version( '3.1.0' ); +} + +/** + * Update shop_manager capabilities. + */ +function wc_update_312_shop_manager_capabilities() { + $role = get_role( 'shop_manager' ); + $role->remove_cap( 'unfiltered_html' ); +} + +/** + * Update DB Version. + */ +function wc_update_312_db_version() { + WC_Install::update_db_version( '3.1.2' ); +} + +/** + * Update state codes for Mexico. + */ +function wc_update_320_mexican_states() { + global $wpdb; + + $mx_states = array( + 'Distrito Federal' => 'CMX', + 'Jalisco' => 'JAL', + 'Nuevo Leon' => 'NLE', + 'Aguascalientes' => 'AGS', + 'Baja California' => 'BCN', + 'Baja California Sur' => 'BCS', + 'Campeche' => 'CAM', + 'Chiapas' => 'CHP', + 'Chihuahua' => 'CHH', + 'Coahuila' => 'COA', + 'Colima' => 'COL', + 'Durango' => 'DGO', + 'Guanajuato' => 'GTO', + 'Guerrero' => 'GRO', + 'Hidalgo' => 'HGO', + 'Estado de Mexico' => 'MEX', + 'Michoacan' => 'MIC', + 'Morelos' => 'MOR', + 'Nayarit' => 'NAY', + 'Oaxaca' => 'OAX', + 'Puebla' => 'PUE', + 'Queretaro' => 'QRO', + 'Quintana Roo' => 'ROO', + 'San Luis Potosi' => 'SLP', + 'Sinaloa' => 'SIN', + 'Sonora' => 'SON', + 'Tabasco' => 'TAB', + 'Tamaulipas' => 'TMP', + 'Tlaxcala' => 'TLA', + 'Veracruz' => 'VER', + 'Yucatan' => 'YUC', + 'Zacatecas' => 'ZAC', + ); + + foreach ( $mx_states as $old => $new ) { + $wpdb->query( + $wpdb->prepare( + "UPDATE $wpdb->postmeta + SET meta_value = %s + WHERE meta_key IN ( '_billing_state', '_shipping_state' ) + AND meta_value = %s", + $new, $old + ) + ); + $wpdb->update( + "{$wpdb->prefix}woocommerce_shipping_zone_locations", + array( + 'location_code' => 'MX:' . $new, + ), + array( + 'location_code' => 'MX:' . $old, + ) + ); + $wpdb->update( + "{$wpdb->prefix}woocommerce_tax_rates", + array( + 'tax_rate_state' => strtoupper( $new ), + ), + array( + 'tax_rate_state' => strtoupper( $old ), + ) + ); + } +} + +/** + * Update DB Version. + */ +function wc_update_320_db_version() { + WC_Install::update_db_version( '3.2.0' ); +} + +/** + * Update image settings to use new aspect ratios and widths. + */ +function wc_update_330_image_options() { + $old_thumbnail_size = get_option( 'shop_catalog_image_size', array() ); + $old_single_size = get_option( 'shop_single_image_size', array() ); + + if ( ! empty( $old_thumbnail_size['width'] ) ) { + $width = absint( $old_thumbnail_size['width'] ); + $height = absint( $old_thumbnail_size['height'] ); + $hard_crop = ! empty( $old_thumbnail_size['crop'] ); + + if ( ! $width ) { + $width = 300; + } + + if ( ! $height ) { + $height = $width; + } + + update_option( 'woocommerce_thumbnail_image_width', $width ); + + // Calculate cropping mode from old image options. + if ( ! $hard_crop ) { + update_option( 'woocommerce_thumbnail_cropping', 'uncropped' ); + } elseif ( $width === $height ) { + update_option( 'woocommerce_thumbnail_cropping', '1:1' ); + } else { + $ratio = $width / $height; + $fraction = wc_decimal_to_fraction( $ratio ); + + if ( $fraction ) { + update_option( 'woocommerce_thumbnail_cropping', 'custom' ); + update_option( 'woocommerce_thumbnail_cropping_custom_width', $fraction[0] ); + update_option( 'woocommerce_thumbnail_cropping_custom_height', $fraction[1] ); + } + } + } + + // Single is uncropped. + if ( ! empty( $old_single_size['width'] ) ) { + update_option( 'woocommerce_single_image_width', absint( $old_single_size['width'] ) ); + } +} + +/** + * Migrate webhooks from post type to CRUD. + */ +function wc_update_330_webhooks() { + register_post_type( 'shop_webhook' ); + + // Map statuses from post_type to Webhooks CRUD. + $statuses = array( + 'publish' => 'active', + 'draft' => 'paused', + 'pending' => 'disabled', + ); + + $posts = get_posts( array( + 'posts_per_page' => -1, + 'post_type' => 'shop_webhook', + 'post_status' => 'any', + ) ); + + foreach ( $posts as $post ) { + $webhook = new WC_Webhook(); + $webhook->set_name( $post->post_title ); + $webhook->set_status( isset( $statuses[ $post->post_status ] ) ? $statuses[ $post->post_status ] : 'disabled' ); + $webhook->set_delivery_url( get_post_meta( $post->ID, '_delivery_url', true ) ); + $webhook->set_secret( get_post_meta( $post->ID, '_secret', true ) ); + $webhook->set_topic( get_post_meta( $post->ID, '_topic', true ) ); + $webhook->set_api_version( get_post_meta( $post->ID, '_api_version', true ) ); + $webhook->set_user_id( $post->post_author ); + $webhook->set_pending_delivery( false ); + $webhook->save(); + + wp_delete_post( $post->ID, true ); + } + + unregister_post_type( 'shop_webhook' ); +} + +/** + * Assign default cat to all products with no cats. + */ +function wc_update_330_set_default_product_cat() { + global $wpdb; + + $default_category = get_option( 'default_product_cat', 0 ); + + if ( $default_category ) { + $result = $wpdb->query( $wpdb->prepare( " + INSERT INTO {$wpdb->term_relationships} (object_id, term_taxonomy_id) + SELECT DISTINCT posts.ID, %s FROM {$wpdb->posts} posts + LEFT JOIN + ( + SELECT object_id FROM {$wpdb->term_relationships} term_relationships + LEFT JOIN {$wpdb->term_taxonomy} term_taxonomy ON term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id + WHERE term_taxonomy.taxonomy = 'product_cat' + ) AS tax_query + ON posts.ID = tax_query.object_id + WHERE posts.post_type = 'product' + AND tax_query.object_id IS NULL + ", $default_category ) ); + wp_cache_flush(); + delete_transient( 'wc_term_counts' ); + wp_update_term_count_now( array( $default_category ), 'product_cat' ); + } +} + +/** + * Update product stock status to use the new onbackorder status. + */ +function wc_update_330_product_stock_status() { + global $wpdb; + + if ( 'yes' !== get_option( 'woocommerce_manage_stock' ) ) { + return; + } + + $min_stock_amount = (int) get_option( 'woocommerce_notify_no_stock_amount', 0 ); + + // Get all products that have stock management enabled, stock less than or equal to min stock amount, and backorders enabled. + $post_ids = $wpdb->get_col( $wpdb->prepare( " + SELECT t1.post_id FROM $wpdb->postmeta t1 + INNER JOIN $wpdb->postmeta t2 + ON t1.post_id = t2.post_id + AND t1.meta_key = '_manage_stock' AND t1.meta_value = 'yes' + AND t2.meta_key = '_stock' AND t2.meta_value <= %d + INNER JOIN $wpdb->postmeta t3 + ON t2.post_id = t3.post_id + AND t3.meta_key = '_backorders' AND ( t3.meta_value = 'yes' OR t3.meta_value = 'notify' ) + ", $min_stock_amount ) ); // WPCS: db call ok, unprepared SQL ok, cache ok. + + if ( empty( $post_ids ) ) { + return; + } + + $post_ids = array_map( 'absint', $post_ids ); + + // Set the status to onbackorder for those products. + $wpdb->query( " + UPDATE $wpdb->postmeta + SET meta_value = 'onbackorder' + WHERE meta_key = '_stock_status' AND post_id IN ( " . implode( ',', $post_ids ) . ' ) + ' ); // WPCS: db call ok, unprepared SQL ok, cache ok. +} + +/** + * Clear addons page transients + */ +function wc_update_330_clear_transients() { + delete_transient( 'wc_addons_sections' ); + delete_transient( 'wc_addons_featured' ); +} + +/** + * Set PayPal's sandbox credentials. + */ +function wc_update_330_set_paypal_sandbox_credentials() { + + $paypal_settings = get_option( 'woocommerce_paypal_settings' ); + + if ( isset( $paypal_settings['testmode'] ) && 'yes' === $paypal_settings['testmode'] ) { + foreach ( array( 'api_username', 'api_password', 'api_signature' ) as $credential ) { + if ( ! empty( $paypal_settings[ $credential ] ) ) { + $paypal_settings[ 'sandbox_' . $credential ] = $paypal_settings[ $credential ]; + } + } + + update_option( 'woocommerce_paypal_settings', $paypal_settings ); + } +} + +/** + * Update DB Version. + */ +function wc_update_330_db_version() { + WC_Install::update_db_version( '3.3.0' ); +} + +/** + * Update state codes for Ireland and BD. + */ +function wc_update_340_states() { + $country_states = array( + 'IE' => array( + 'CK' => 'CO', + 'DN' => 'D', + 'GY' => 'G', + 'TY' => 'TA', + ), + 'BD' => array( + 'BAG' => 'BD-05', + 'BAN' => 'BD-01', + 'BAR' => 'BD-02', + 'BARI' => 'BD-06', + 'BHO' => 'BD-07', + 'BOG' => 'BD-03', + 'BRA' => 'BD-04', + 'CHA' => 'BD-09', + 'CHI' => 'BD-10', + 'CHU' => 'BD-12', + 'COX' => 'BD-11', + 'COM' => 'BD-08', + 'DHA' => 'BD-13', + 'DIN' => 'BD-14', + 'FAR' => 'BD-15', + 'FEN' => 'BD-16', + 'GAI' => 'BD-19', + 'GAZI' => 'BD-18', + 'GOP' => 'BD-17', + 'HAB' => 'BD-20', + 'JAM' => 'BD-21', + 'JES' => 'BD-22', + 'JHA' => 'BD-25', + 'JHE' => 'BD-23', + 'JOY' => 'BD-24', + 'KHA' => 'BD-29', + 'KHU' => 'BD-27', + 'KIS' => 'BD-26', + 'KUR' => 'BD-28', + 'KUS' => 'BD-30', + 'LAK' => 'BD-31', + 'LAL' => 'BD-32', + 'MAD' => 'BD-36', + 'MAG' => 'BD-37', + 'MAN' => 'BD-33', + 'MEH' => 'BD-39', + 'MOU' => 'BD-38', + 'MUN' => 'BD-35', + 'MYM' => 'BD-34', + 'NAO' => 'BD-48', + 'NAR' => 'BD-43', + 'NARG' => 'BD-40', + 'NARD' => 'BD-42', + 'NAT' => 'BD-44', + 'NAW' => 'BD-45', + 'NET' => 'BD-41', + 'NIL' => 'BD-46', + 'NOA' => 'BD-47', + 'PAB' => 'BD-49', + 'PAN' => 'BD-52', + 'PAT' => 'BD-51', + 'PIR' => 'BD-50', + 'RAJB' => 'BD-53', + 'RAJ' => 'BD-54', + 'RAN' => 'BD-56', + 'RANP' => 'BD-55', + 'SAT' => 'BD-58', + 'SHA' => 'BD-57', + 'SIR' => 'BD-59', + 'SUN' => 'BD-61', + 'SYL' => 'BD-60', + 'TAN' => 'BD-63', + 'THA' => 'BD-64', + ), + ); + + update_option( 'woocommerce_update_340_states', $country_states ); +} + +/** + * Update next state in the queue. + * + * @return bool True to run again, false if completed. + */ +function wc_update_340_state() { + global $wpdb; + + $country_states = array_filter( (array) get_option( 'woocommerce_update_340_states', array() ) ); + + if ( empty( $country_states ) ) { + return false; + } + + foreach ( $country_states as $country => $states ) { + foreach ( $states as $old => $new ) { + $wpdb->query( + $wpdb->prepare( + "UPDATE $wpdb->postmeta + SET meta_value = %s + WHERE meta_key IN ( '_billing_state', '_shipping_state' ) + AND meta_value = %s", + $new, $old + ) + ); + $wpdb->update( + "{$wpdb->prefix}woocommerce_shipping_zone_locations", + array( + 'location_code' => $country . ':' . $new, + ), + array( + 'location_code' => $country . ':' . $old, + ) + ); + $wpdb->update( + "{$wpdb->prefix}woocommerce_tax_rates", + array( + 'tax_rate_state' => strtoupper( $new ), + ), + array( + 'tax_rate_state' => strtoupper( $old ), + ) + ); + unset( $country_states[ $country ][ $old ] ); + + if ( empty( $country_states[ $country ] ) ) { + unset( $country_states[ $country ] ); + } + break 2; + } + } + + if ( ! empty( $country_states ) ) { + return update_option( 'woocommerce_update_340_states', $country_states ); + } + + delete_option( 'woocommerce_update_340_states' ); + + return false; +} + +/** + * Set last active prop for users. + */ +function wc_update_340_last_active() { + global $wpdb; + // @codingStandardsIgnoreStart. + $wpdb->query( + $wpdb->prepare( " + INSERT INTO {$wpdb->usermeta} (user_id, meta_key, meta_value) + SELECT DISTINCT users.ID, 'wc_last_active', %s + FROM {$wpdb->users} as users + LEFT OUTER JOIN {$wpdb->usermeta} AS usermeta ON users.ID = usermeta.user_id AND usermeta.meta_key = 'wc_last_active' + WHERE usermeta.meta_value IS NULL + ", + (string) strtotime( date( 'Y-m-d', current_time( 'timestamp', true ) ) ) + ) + ); + // @codingStandardsIgnoreEnd. +} + +/** + * Update DB Version. + */ +function wc_update_340_db_version() { + WC_Install::update_db_version( '3.4.0' ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/wc-user-functions.php b/backend/wp-content/plugins/woocommerce/includes/wc-user-functions.php new file mode 100644 index 0000000..c0a7dcd --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/wc-user-functions.php @@ -0,0 +1,724 @@ +get_error_code() ) { + return $errors; + } + + $new_customer_data = apply_filters( + 'woocommerce_new_customer_data', array( + 'user_login' => $username, + 'user_pass' => $password, + 'user_email' => $email, + 'role' => 'customer', + ) + ); + + $customer_id = wp_insert_user( $new_customer_data ); + + if ( is_wp_error( $customer_id ) ) { + return new WP_Error( 'registration-error', '' . __( 'Error:', 'woocommerce' ) . ' ' . __( 'Couldn’t register you… please contact us if you continue to have problems.', 'woocommerce' ) ); + } + + do_action( 'woocommerce_created_customer', $customer_id, $new_customer_data, $password_generated ); + + return $customer_id; + } +} + +/** + * Login a customer (set auth cookie and set global user object). + * + * @param int $customer_id Customer ID. + */ +function wc_set_customer_auth_cookie( $customer_id ) { + global $current_user; + + $current_user = get_user_by( 'id', $customer_id ); // WPCS: override ok. + + wp_set_auth_cookie( $customer_id, true ); +} + +/** + * Get past orders (by email) and update them. + * + * @param int $customer_id Customer ID. + * @return int + */ +function wc_update_new_customer_past_orders( $customer_id ) { + $linked = 0; + $complete = 0; + $customer = get_user_by( 'id', absint( $customer_id ) ); + $customer_orders = wc_get_orders( + array( + 'limit' => -1, + 'customer' => array( array( 0, $customer->user_email ) ), + 'return' => 'ids', + ) + ); + + if ( ! empty( $customer_orders ) ) { + foreach ( $customer_orders as $order_id ) { + $order = wc_get_order( $order_id ); + if ( ! $order ) { + continue; + } + + $order->set_customer_id( $customer->ID ); + $order->save(); + + if ( $order->has_downloadable_item() ) { + $data_store = WC_Data_Store::load( 'customer-download' ); + $data_store->delete_by_order_id( $order->get_id() ); + wc_downloadable_product_permissions( $order->get_id(), true ); + } + + do_action( 'woocommerce_update_new_customer_past_order', $order_id, $customer ); + + if ( get_post_status( $order_id ) === 'wc-completed' ) { + $complete++; + } + + $linked++; + } + } + + if ( $complete ) { + update_user_meta( $customer_id, 'paying_customer', 1 ); + update_user_meta( $customer_id, '_order_count', '' ); + update_user_meta( $customer_id, '_money_spent', '' ); + } + + return $linked; +} + +/** + * Order Status completed - This is a paying customer. + * + * @param int $order_id Order ID. + */ +function wc_paying_customer( $order_id ) { + $order = wc_get_order( $order_id ); + $customer_id = $order->get_customer_id(); + + if ( $customer_id > 0 && 'shop_order_refund' !== $order->get_type() ) { + $customer = new WC_Customer( $customer_id ); + $customer->set_is_paying_customer( true ); + $customer->save(); + } +} +add_action( 'woocommerce_order_status_completed', 'wc_paying_customer' ); + +/** + * Checks if a user (by email or ID or both) has bought an item. + * + * @param string $customer_email Customer email to check. + * @param int $user_id User ID to check. + * @param int $product_id Product ID to check. + * @return bool + */ +function wc_customer_bought_product( $customer_email, $user_id, $product_id ) { + global $wpdb; + + $result = apply_filters( 'woocommerce_pre_customer_bought_product', null, $customer_email, $user_id, $product_id ); + + if ( null !== $result ) { + return $result; + } + + $transient_name = 'wc_cbp_' . md5( $customer_email . $user_id . WC_Cache_Helper::get_transient_version( 'orders' ) ); + $result = get_transient( $transient_name ); + + if ( false === $result ) { + $customer_data = array( $user_id ); + + if ( $user_id ) { + $user = get_user_by( 'id', $user_id ); + + if ( isset( $user->user_email ) ) { + $customer_data[] = $user->user_email; + } + } + + if ( is_email( $customer_email ) ) { + $customer_data[] = $customer_email; + } + + $customer_data = array_map( 'esc_sql', array_filter( array_unique( $customer_data ) ) ); + $statuses = array_map( 'esc_sql', wc_get_is_paid_statuses() ); + + if ( count( $customer_data ) === 0 ) { + return false; + } + + $result = $wpdb->get_col( + " + SELECT im.meta_value FROM {$wpdb->posts} AS p + INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id + INNER JOIN {$wpdb->prefix}woocommerce_order_items AS i ON p.ID = i.order_id + INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS im ON i.order_item_id = im.order_item_id + WHERE p.post_status IN ( 'wc-" . implode( "','wc-", $statuses ) . "' ) + AND pm.meta_key IN ( '_billing_email', '_customer_user' ) + AND im.meta_key IN ( '_product_id', '_variation_id' ) + AND im.meta_value != 0 + AND pm.meta_value IN ( '" . implode( "','", $customer_data ) . "' ) + " + ); // WPCS: unprepared SQL ok. + $result = array_map( 'absint', $result ); + + set_transient( $transient_name, $result, DAY_IN_SECONDS * 30 ); + } + return in_array( absint( $product_id ), $result, true ); +} + +/** + * Checks if a user has a certain capability. + * + * @param array $allcaps All capabilities. + * @param array $caps Capabilities. + * @param array $args Arguments. + * @return bool + */ +function wc_customer_has_capability( $allcaps, $caps, $args ) { + if ( isset( $caps[0] ) ) { + switch ( $caps[0] ) { + case 'view_order': + $user_id = intval( $args[1] ); + $order = wc_get_order( $args[2] ); + + if ( $order && $user_id === $order->get_user_id() ) { + $allcaps['view_order'] = true; + } + break; + case 'pay_for_order': + $user_id = intval( $args[1] ); + $order_id = isset( $args[2] ) ? $args[2] : null; + + // When no order ID, we assume it's a new order + // and thus, customer can pay for it. + if ( ! $order_id ) { + $allcaps['pay_for_order'] = true; + break; + } + + $order = wc_get_order( $order_id ); + + if ( $order && ( $user_id === $order->get_user_id() || ! $order->get_user_id() ) ) { + $allcaps['pay_for_order'] = true; + } + break; + case 'order_again': + $user_id = intval( $args[1] ); + $order = wc_get_order( $args[2] ); + + if ( $order && $user_id === $order->get_user_id() ) { + $allcaps['order_again'] = true; + } + break; + case 'cancel_order': + $user_id = intval( $args[1] ); + $order = wc_get_order( $args[2] ); + + if ( $order && $user_id === $order->get_user_id() ) { + $allcaps['cancel_order'] = true; + } + break; + case 'download_file': + $user_id = intval( $args[1] ); + $download = $args[2]; + + if ( $download && $user_id === $download->get_user_id() ) { + $allcaps['download_file'] = true; + } + break; + } + } + return $allcaps; +} +add_filter( 'user_has_cap', 'wc_customer_has_capability', 10, 3 ); + +/** + * Modify the list of editable roles to prevent non-admin adding admin users. + * + * @param array $roles Roles. + * @return array + */ +function wc_modify_editable_roles( $roles ) { + if ( ! current_user_can( 'administrator' ) ) { + unset( $roles['administrator'] ); + } + return $roles; +} +add_filter( 'editable_roles', 'wc_modify_editable_roles' ); + +/** + * Modify capabilities to prevent non-admin users editing admin users. + * + * $args[0] will be the user being edited in this case. + * + * @param array $caps Array of caps. + * @param string $cap Name of the cap we are checking. + * @param int $user_id ID of the user being checked against. + * @param array $args Arguments. + * @return array + */ +function wc_modify_map_meta_cap( $caps, $cap, $user_id, $args ) { + switch ( $cap ) { + case 'edit_user': + case 'remove_user': + case 'promote_user': + case 'delete_user': + if ( ! isset( $args[0] ) || $args[0] === $user_id ) { + break; + } else { + if ( user_can( $args[0], 'administrator' ) && ! current_user_can( 'administrator' ) ) { + $caps[] = 'do_not_allow'; + } + } + break; + } + return $caps; +} +add_filter( 'map_meta_cap', 'wc_modify_map_meta_cap', 10, 4 ); + +/** + * Get customer download permissions from the database. + * + * @param int $customer_id Customer/User ID. + * @return array + */ +function wc_get_customer_download_permissions( $customer_id ) { + $data_store = WC_Data_Store::load( 'customer-download' ); + return apply_filters( 'woocommerce_permission_list', $data_store->get_downloads_for_customer( $customer_id ), $customer_id ); +} + +/** + * Get customer available downloads. + * + * @param int $customer_id Customer/User ID. + * @return array + */ +function wc_get_customer_available_downloads( $customer_id ) { + $downloads = array(); + $_product = null; + $order = null; + $file_number = 0; + + // Get results from valid orders only. + $results = wc_get_customer_download_permissions( $customer_id ); + + if ( $results ) { + foreach ( $results as $result ) { + $order_id = intval( $result->order_id ); + + if ( ! $order || $order->get_id() !== $order_id ) { + // New order. + $order = wc_get_order( $order_id ); + $_product = null; + } + + // Make sure the order exists for this download. + if ( ! $order ) { + continue; + } + + // Check if downloads are permitted. + if ( ! $order->is_download_permitted() ) { + continue; + } + + $product_id = intval( $result->product_id ); + + if ( ! $_product || $_product->get_id() !== $product_id ) { + // New product. + $file_number = 0; + $_product = wc_get_product( $product_id ); + } + + // Check product exists and has the file. + if ( ! $_product || ! $_product->exists() || ! $_product->has_file( $result->download_id ) ) { + continue; + } + + $download_file = $_product->get_file( $result->download_id ); + + // Download name will be 'Product Name' for products with a single downloadable file, and 'Product Name - File X' for products with multiple files. + $download_name = apply_filters( + 'woocommerce_downloadable_product_name', + $download_file['name'], + $_product, + $result->download_id, + $file_number + ); + + $downloads[] = array( + 'download_url' => add_query_arg( + array( + 'download_file' => $product_id, + 'order' => $result->order_key, + 'email' => rawurlencode( $result->user_email ), + 'key' => $result->download_id, + ), + home_url( '/' ) + ), + 'download_id' => $result->download_id, + 'product_id' => $_product->get_id(), + 'product_name' => $_product->get_name(), + 'product_url' => $_product->is_visible() ? $_product->get_permalink() : '', // Since 3.3.0. + 'download_name' => $download_name, + 'order_id' => $order->get_id(), + 'order_key' => $order->get_order_key(), + 'downloads_remaining' => $result->downloads_remaining, + 'access_expires' => $result->access_expires, + 'file' => array( + 'name' => $download_file->get_name(), + 'file' => $download_file->get_file(), + ), + ); + + $file_number++; + } + } + + return apply_filters( 'woocommerce_customer_available_downloads', $downloads, $customer_id ); +} + +/** + * Get total spent by customer. + * + * @param int $user_id User ID. + * @return string + */ +function wc_get_customer_total_spent( $user_id ) { + $customer = new WC_Customer( $user_id ); + return $customer->get_total_spent(); +} + +/** + * Get total orders by customer. + * + * @param int $user_id User ID. + * @return int + */ +function wc_get_customer_order_count( $user_id ) { + $customer = new WC_Customer( $user_id ); + return $customer->get_order_count(); +} + +/** + * Reset _customer_user on orders when a user is deleted. + * + * @param int $user_id User ID. + */ +function wc_reset_order_customer_id_on_deleted_user( $user_id ) { + global $wpdb; + + $wpdb->update( + $wpdb->postmeta, array( 'meta_value' => 0 ), array( + 'meta_key' => '_customer_user', + 'meta_value' => $user_id, + ) + ); // WPCS: slow query ok. +} + +add_action( 'deleted_user', 'wc_reset_order_customer_id_on_deleted_user' ); + +/** + * Get review verification status. + * + * @param int $comment_id Comment ID. + * @return bool + */ +function wc_review_is_from_verified_owner( $comment_id ) { + $verified = get_comment_meta( $comment_id, 'verified', true ); + + // If no "verified" meta is present, generate it (if this is a product review). + if ( '' === $verified ) { + $verified = WC_Comments::add_comment_purchase_verification( $comment_id ); + } + + return (bool) $verified; +} + +/** + * Disable author archives for customers. + * + * @since 2.5.0 + */ +function wc_disable_author_archives_for_customers() { + global $author; + + if ( is_author() ) { + $user = get_user_by( 'id', $author ); + + if ( user_can( $user, 'customer' ) && ! user_can( $user, 'edit_posts' ) ) { + wp_redirect( wc_get_page_permalink( 'shop' ) ); + } + } +} + +add_action( 'template_redirect', 'wc_disable_author_archives_for_customers' ); + +/** + * Hooks into the `profile_update` hook to set the user last updated timestamp. + * + * @since 2.6.0 + * @param int $user_id The user that was updated. + * @param array $old The profile fields pre-change. + */ +function wc_update_profile_last_update_time( $user_id, $old ) { + wc_set_user_last_update_time( $user_id ); +} + +add_action( 'profile_update', 'wc_update_profile_last_update_time', 10, 2 ); + +/** + * Hooks into the update user meta function to set the user last updated timestamp. + * + * @since 2.6.0 + * @param int $meta_id ID of the meta object that was changed. + * @param int $user_id The user that was updated. + * @param string $meta_key Name of the meta key that was changed. + * @param string $_meta_value Value of the meta that was changed. + */ +function wc_meta_update_last_update_time( $meta_id, $user_id, $meta_key, $_meta_value ) { + $keys_to_track = apply_filters( 'woocommerce_user_last_update_fields', array( 'first_name', 'last_name' ) ); + $update_time = false; + if ( in_array( $meta_key, $keys_to_track, true ) ) { + $update_time = true; + } + if ( 'billing_' === substr( $meta_key, 0, 8 ) ) { + $update_time = true; + } + if ( 'shipping_' === substr( $meta_key, 0, 9 ) ) { + $update_time = true; + } + + if ( $update_time ) { + wc_set_user_last_update_time( $user_id ); + } +} + +add_action( 'update_user_meta', 'wc_meta_update_last_update_time', 10, 4 ); + +/** + * Sets a user's "last update" time to the current timestamp. + * + * @since 2.6.0 + * @param int $user_id The user to set a timestamp for. + */ +function wc_set_user_last_update_time( $user_id ) { + update_user_meta( $user_id, 'last_update', gmdate( 'U' ) ); +} + +/** + * Get customer saved payment methods list. + * + * @since 2.6.0 + * @param int $customer_id Customer ID. + * @return array + */ +function wc_get_customer_saved_methods_list( $customer_id ) { + return apply_filters( 'woocommerce_saved_payment_methods_list', array(), $customer_id ); +} + +/** + * Get info about customer's last order. + * + * @since 2.6.0 + * @param int $customer_id Customer ID. + * @return WC_Order|bool Order object if successful or false. + */ +function wc_get_customer_last_order( $customer_id ) { + $customer = new WC_Customer( $customer_id ); + + return $customer->get_last_order(); +} + +/** + * Add support for searching by display_name. + * + * @since 3.2.0 + * @param array $search_columns Column names. + * @return array + */ +function wc_user_search_columns( $search_columns ) { + $search_columns[] = 'display_name'; + return $search_columns; +} +add_filter( 'user_search_columns', 'wc_user_search_columns' ); + +/** + * When a user is deleted in WordPress, delete corresponding WooCommerce data. + * + * @param int $user_id User ID being deleted. + */ +function wc_delete_user_data( $user_id ) { + global $wpdb; + + // Clean up sessions. + $wpdb->delete( + $wpdb->prefix . 'woocommerce_sessions', + array( + 'session_key' => $user_id, + ) + ); + + // Revoke API keys. + $wpdb->delete( + $wpdb->prefix . 'woocommerce_api_keys', + array( + 'user_id' => $user_id, + ) + ); + + // Clean up payment tokens. + $payment_tokens = WC_Payment_Tokens::get_customer_tokens( $user_id ); + + foreach ( $payment_tokens as $payment_token ) { + $payment_token->delete(); + } +} +add_action( 'delete_user', 'wc_delete_user_data' ); + +/** + * Store user agents. Used for tracker. + * + * @since 3.0.0 + * @param string $user_login User login. + * @param int|object $user User. + */ +function wc_maybe_store_user_agent( $user_login, $user ) { + if ( 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) && user_can( $user, 'manage_woocommerce' ) ) { + $admin_user_agents = array_filter( (array) get_option( 'woocommerce_tracker_ua', array() ) ); + $admin_user_agents[] = wc_get_user_agent(); + update_option( 'woocommerce_tracker_ua', array_unique( $admin_user_agents ) ); + } +} +add_action( 'wp_login', 'wc_maybe_store_user_agent', 10, 2 ); + +/** + * Update logic triggered on login. + * + * @since 3.4.0 + * @param string $user_login User login. + * @param object $user User. + */ +function wc_user_logged_in( $user_login, $user ) { + wc_update_user_last_active( $user->ID ); +} +add_action( 'wp_login', 'wc_user_logged_in', 10, 2 ); + +/** + * Update when the user was last active. + * + * @since 3.4.0 + */ +function wc_current_user_is_active() { + if ( ! is_user_logged_in() ) { + return; + } + wc_update_user_last_active( get_current_user_id() ); +} +add_action( 'wp', 'wc_current_user_is_active', 10 ); + +/** + * Set the user last active timestamp to now. + * + * @since 3.4.0 + * @param int $user_id User ID to mark active. + */ +function wc_update_user_last_active( $user_id ) { + if ( ! $user_id ) { + return; + } + update_user_meta( $user_id, 'wc_last_active', (string) strtotime( date( 'Y-m-d', current_time( 'timestamp', true ) ) ) ); +} diff --git a/backend/wp-content/plugins/woocommerce/includes/wc-webhook-functions.php b/backend/wp-content/plugins/woocommerce/includes/wc-webhook-functions.php new file mode 100644 index 0000000..01b160d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/wc-webhook-functions.php @@ -0,0 +1,123 @@ +get_id(), $arg ) ); + } else { + // Deliver immediately. + $webhook->deliver( $arg ); + } +} +add_action( 'woocommerce_webhook_process_delivery', 'wc_webhook_process_delivery', 10, 2 ); + +/** + * Wrapper function to execute the `woocommerce_deliver_webhook_async` cron. + * hook, see WC_Webhook::process(). + * + * @since 2.2.0 + * @param int $webhook_id Webhook ID to deliver. + * @param mixed $arg Hook argument. + */ +function wc_deliver_webhook_async( $webhook_id, $arg ) { + $webhook = new WC_Webhook( $webhook_id ); + $webhook->deliver( $arg ); +} +add_action( 'woocommerce_deliver_webhook_async', 'wc_deliver_webhook_async', 10, 2 ); + +/** + * Check if the given topic is a valid webhook topic, a topic is valid if: + * + * + starts with `action.woocommerce_` or `action.wc_`. + * + it has a valid resource & event. + * + * @since 2.2.0 + * @param string $topic Webhook topic. + * @return bool + */ +function wc_is_webhook_valid_topic( $topic ) { + + // Custom topics are prefixed with woocommerce_ or wc_ are valid. + if ( 0 === strpos( $topic, 'action.woocommerce_' ) || 0 === strpos( $topic, 'action.wc_' ) ) { + return true; + } + + $data = explode( '.', $topic ); + + if ( ! isset( $data[0] ) || ! isset( $data[1] ) ) { + return false; + } + + $valid_resources = apply_filters( 'woocommerce_valid_webhook_resources', array( 'coupon', 'customer', 'order', 'product' ) ); + $valid_events = apply_filters( 'woocommerce_valid_webhook_events', array( 'created', 'updated', 'deleted', 'restored' ) ); + + if ( in_array( $data[0], $valid_resources, true ) && in_array( $data[1], $valid_events, true ) ) { + return true; + } + + return false; +} + +/** + * Get Webhook statuses. + * + * @since 2.3.0 + * @return array + */ +function wc_get_webhook_statuses() { + return apply_filters( 'woocommerce_webhook_statuses', array( + 'active' => __( 'Active', 'woocommerce' ), + 'paused' => __( 'Paused', 'woocommerce' ), + 'disabled' => __( 'Disabled', 'woocommerce' ), + ) ); +} + +/** + * Load webhooks. + * + * @since 3.3.0 + * @return bool + */ +function wc_load_webhooks() { + $data_store = WC_Data_Store::load( 'webhook' ); + $webhooks = $data_store->get_webhooks_ids(); + $loaded = false; + + foreach ( $webhooks as $webhook_id ) { + $webhook = new WC_Webhook( $webhook_id ); + $webhook->enqueue(); + $loaded = true; + } + + return $loaded; +} + +/** + * Get webhook. + * + * @param int|WC_Webhook $id Webhook ID or object. + * @return WC_Webhook|null + */ +function wc_get_webhook( $id ) { + $webhook = new WC_Webhook( $id ); + + return 0 !== $webhook->get_id() ? $webhook : null; +} diff --git a/backend/wp-content/plugins/woocommerce/includes/wc-widget-functions.php b/backend/wp-content/plugins/woocommerce/includes/wc-widget-functions.php new file mode 100644 index 0000000..2972680 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/wc-widget-functions.php @@ -0,0 +1,52 @@ +widget_cssclass = 'woocommerce widget_shopping_cart'; + $this->widget_description = __( 'Display the customer shopping cart.', 'woocommerce' ); + $this->widget_id = 'woocommerce_widget_cart'; + $this->widget_name = __( 'Cart', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Cart', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'hide_if_empty' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide if cart is empty', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + if ( apply_filters( 'woocommerce_widget_cart_is_hidden', is_cart() || is_checkout() ) ) { + return; + } + + $hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1; + + $this->widget_start( $args, $instance ); + + if ( $hide_if_empty ) { + echo '
      '; + } + + // Insert cart widget placeholder - code in woocommerce.js will update this on page load. + echo '
      '; + + if ( $hide_if_empty ) { + echo '
      '; + } + + $this->widget_end( $args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php new file mode 100644 index 0000000..1f9d1df --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php @@ -0,0 +1,111 @@ +widget_cssclass = 'woocommerce widget_layered_nav_filters'; + $this->widget_description = __( 'Display a list of active product filters.', 'woocommerce' ); + $this->widget_id = 'woocommerce_layered_nav_filters'; + $this->widget_name = __( 'Active Product Filters', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Active filters', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + if ( ! is_shop() && ! is_product_taxonomy() ) { + return; + } + + $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); + $min_price = isset( $_GET['min_price'] ) ? wc_clean( wp_unslash( $_GET['min_price'] ) ) : 0; // WPCS: input var ok, CSRF ok. + $max_price = isset( $_GET['max_price'] ) ? wc_clean( wp_unslash( $_GET['max_price'] ) ) : 0; // WPCS: input var ok, CSRF ok. + $rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) ) : array(); // WPCS: sanitization ok, input var ok, CSRF ok. + $base_link = $this->get_current_page_url(); + + if ( 0 < count( $_chosen_attributes ) || 0 < $min_price || 0 < $max_price || ! empty( $rating_filter ) ) { + + $this->widget_start( $args, $instance ); + + echo '
        '; + + // Attributes. + if ( ! empty( $_chosen_attributes ) ) { + foreach ( $_chosen_attributes as $taxonomy => $data ) { + foreach ( $data['terms'] as $term_slug ) { + $term = get_term_by( 'slug', $term_slug, $taxonomy ); + if ( ! $term ) { + continue; + } + + $filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) ); + $current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array(); // WPCS: input var ok, CSRF ok. + $current_filter = array_map( 'sanitize_title', $current_filter ); + $new_filter = array_diff( $current_filter, array( $term_slug ) ); + + $link = remove_query_arg( array( 'add-to-cart', $filter_name ), $base_link ); + + if ( count( $new_filter ) > 0 ) { + $link = add_query_arg( $filter_name, implode( ',', $new_filter ), $link ); + } + + echo '
      • ' . esc_html( $term->name ) . '
      • '; + } + } + } + + if ( $min_price ) { + $link = remove_query_arg( 'min_price', $base_link ); + /* translators: %s: minimum price */ + echo '
      • ' . sprintf( __( 'Min %s', 'woocommerce' ), wc_price( $min_price ) ) . '
      • '; // WPCS: XSS ok. + } + + if ( $max_price ) { + $link = remove_query_arg( 'max_price', $base_link ); + /* translators: %s: maximum price */ + echo '
      • ' . sprintf( __( 'Max %s', 'woocommerce' ), wc_price( $max_price ) ) . '
      • '; // WPCS: XSS ok. + } + + if ( ! empty( $rating_filter ) ) { + foreach ( $rating_filter as $rating ) { + $link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) ); + $link = $link_ratings ? add_query_arg( 'rating_filter', $link_ratings ) : remove_query_arg( 'rating_filter', $base_link ); + + /* translators: %s: rating */ + echo '
      • ' . sprintf( esc_html__( 'Rated %s out of 5', 'woocommerce' ), esc_html( $rating ) ) . '
      • '; + } + } + + echo '
      '; + + $this->widget_end( $args ); + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav.php new file mode 100644 index 0000000..d2dbf7d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav.php @@ -0,0 +1,479 @@ +widget_cssclass = 'woocommerce widget_layered_nav woocommerce-widget-layered-nav'; + $this->widget_description = __( 'Display a list of attributes to filter products in your store.', 'woocommerce' ); + $this->widget_id = 'woocommerce_layered_nav'; + $this->widget_name = __( 'Filter Products by Attribute', 'woocommerce' ); + parent::__construct(); + } + + /** + * Updates a particular instance of a widget. + * + * @see WP_Widget->update + * + * @param array $new_instance New Instance. + * @param array $old_instance Old Instance. + * + * @return array + */ + public function update( $new_instance, $old_instance ) { + $this->init_settings(); + return parent::update( $new_instance, $old_instance ); + } + + /** + * Outputs the settings update form. + * + * @see WP_Widget->form + * + * @param array $instance Instance. + */ + public function form( $instance ) { + $this->init_settings(); + parent::form( $instance ); + } + + /** + * Init settings after post types are registered. + */ + public function init_settings() { + $attribute_array = array(); + $attribute_taxonomies = wc_get_attribute_taxonomies(); + + if ( ! empty( $attribute_taxonomies ) ) { + foreach ( $attribute_taxonomies as $tax ) { + if ( taxonomy_exists( wc_attribute_taxonomy_name( $tax->attribute_name ) ) ) { + $attribute_array[ $tax->attribute_name ] = $tax->attribute_name; + } + } + } + + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Filter by', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'attribute' => array( + 'type' => 'select', + 'std' => '', + 'label' => __( 'Attribute', 'woocommerce' ), + 'options' => $attribute_array, + ), + 'display_type' => array( + 'type' => 'select', + 'std' => 'list', + 'label' => __( 'Display type', 'woocommerce' ), + 'options' => array( + 'list' => __( 'List', 'woocommerce' ), + 'dropdown' => __( 'Dropdown', 'woocommerce' ), + ), + ), + 'query_type' => array( + 'type' => 'select', + 'std' => 'and', + 'label' => __( 'Query type', 'woocommerce' ), + 'options' => array( + 'and' => __( 'AND', 'woocommerce' ), + 'or' => __( 'OR', 'woocommerce' ), + ), + ), + ); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Instance. + */ + public function widget( $args, $instance ) { + if ( ! is_shop() && ! is_product_taxonomy() ) { + return; + } + + $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); + $taxonomy = isset( $instance['attribute'] ) ? wc_attribute_taxonomy_name( $instance['attribute'] ) : $this->settings['attribute']['std']; + $query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : $this->settings['query_type']['std']; + $display_type = isset( $instance['display_type'] ) ? $instance['display_type'] : $this->settings['display_type']['std']; + + if ( ! taxonomy_exists( $taxonomy ) ) { + return; + } + + $get_terms_args = array( 'hide_empty' => '1' ); + + $orderby = wc_attribute_orderby( $taxonomy ); + + switch ( $orderby ) { + case 'name': + $get_terms_args['orderby'] = 'name'; + $get_terms_args['menu_order'] = false; + break; + case 'id': + $get_terms_args['orderby'] = 'id'; + $get_terms_args['order'] = 'ASC'; + $get_terms_args['menu_order'] = false; + break; + case 'menu_order': + $get_terms_args['menu_order'] = 'ASC'; + break; + } + + $terms = get_terms( $taxonomy, $get_terms_args ); + + if ( 0 === count( $terms ) ) { + return; + } + + switch ( $orderby ) { + case 'name_num': + usort( $terms, '_wc_get_product_terms_name_num_usort_callback' ); + break; + case 'parent': + usort( $terms, '_wc_get_product_terms_parent_usort_callback' ); + break; + } + + ob_start(); + + $this->widget_start( $args, $instance ); + + if ( 'dropdown' === $display_type ) { + wp_enqueue_script( 'selectWoo' ); + wp_enqueue_style( 'select2' ); + $found = $this->layered_nav_dropdown( $terms, $taxonomy, $query_type ); + } else { + $found = $this->layered_nav_list( $terms, $taxonomy, $query_type ); + } + + $this->widget_end( $args ); + + // Force found when option is selected - do not force found on taxonomy attributes. + if ( ! is_tax() && is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) ) { + $found = true; + } + + if ( ! $found ) { + ob_end_clean(); + } else { + echo ob_get_clean(); // @codingStandardsIgnoreLine + } + } + + /** + * Return the currently viewed taxonomy name. + * + * @return string + */ + protected function get_current_taxonomy() { + return is_tax() ? get_queried_object()->taxonomy : ''; + } + + /** + * Return the currently viewed term ID. + * + * @return int + */ + protected function get_current_term_id() { + return absint( is_tax() ? get_queried_object()->term_id : 0 ); + } + + /** + * Return the currently viewed term slug. + * + * @return int + */ + protected function get_current_term_slug() { + return absint( is_tax() ? get_queried_object()->slug : 0 ); + } + + /** + * Show dropdown layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return bool Will nav display? + */ + protected function layered_nav_dropdown( $terms, $taxonomy, $query_type ) { + global $wp; + $found = false; + + if ( $taxonomy !== $this->get_current_taxonomy() ) { + $term_counts = $this->get_filtered_term_product_counts( wp_list_pluck( $terms, 'term_id' ), $taxonomy, $query_type ); + $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); + $taxonomy_filter_name = str_replace( 'pa_', '', $taxonomy ); + $taxonomy_label = wc_attribute_label( $taxonomy ); + + /* translators: %s: taxonomy name */ + $any_label = apply_filters( 'woocommerce_layered_nav_any_label', sprintf( __( 'Any %s', 'woocommerce' ), $taxonomy_label ), $taxonomy_label, $taxonomy ); + $multiple = 'or' === $query_type; + $current_values = isset( $_chosen_attributes[ $taxonomy ]['terms'] ) ? $_chosen_attributes[ $taxonomy ]['terms'] : array(); + + if ( '' === get_option( 'permalink_structure' ) ) { + $form_action = remove_query_arg( array( 'page', 'paged' ), add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); + } else { + $form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) ); + } + + echo '
      '; + echo ''; + + if ( $multiple ) { + echo ''; + } + + if ( 'or' === $query_type ) { + echo ''; + } + + echo ''; + echo wc_query_string_form_fields( null, array( 'filter_' . $taxonomy_filter_name, 'query_type_' . $taxonomy_filter_name ), '', true ); // @codingStandardsIgnoreLine + echo '
      '; + + wc_enqueue_js( + " + // Update value on change. + jQuery( '.dropdown_layered_nav_" . esc_js( $taxonomy_filter_name ) . "' ).change( function() { + var slug = jQuery( this ).val(); + jQuery( ':input[name=\"filter_" . esc_js( $taxonomy_filter_name ) . "\"]' ).val( slug ); + + // Submit form on change if standard dropdown. + if ( ! jQuery( this ).attr( 'multiple' ) ) { + jQuery( this ).closest( 'form' ).submit(); + } + }); + + // Use Select2 enhancement if possible + if ( jQuery().selectWoo ) { + var wc_layered_nav_select = function() { + jQuery( '.dropdown_layered_nav_" . esc_js( $taxonomy_filter_name ) . "' ).selectWoo( { + placeholder: '" . esc_js( $any_label ) . "', + minimumResultsForSearch: 5, + width: '100%', + allowClear: " . ( $multiple ? 'false' : 'true' ) . ", + language: { + noResults: function() { + return '" . esc_js( _x( 'No matches found', 'enhanced select', 'woocommerce' ) ) . "'; + } + } + } ); + }; + wc_layered_nav_select(); + } + " + ); + } + + return $found; + } + + /** + * Count products within certain terms, taking the main WP query into consideration. + * + * This query allows counts to be generated based on the viewed products, not all products. + * + * @param array $term_ids Term IDs. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return array + */ + protected function get_filtered_term_product_counts( $term_ids, $taxonomy, $query_type ) { + global $wpdb; + + $tax_query = WC_Query::get_main_tax_query(); + $meta_query = WC_Query::get_main_meta_query(); + + if ( 'or' === $query_type ) { + foreach ( $tax_query as $key => $query ) { + if ( is_array( $query ) && $taxonomy === $query['taxonomy'] ) { + unset( $tax_query[ $key ] ); + } + } + } + + $meta_query = new WP_Meta_Query( $meta_query ); + $tax_query = new WP_Tax_Query( $tax_query ); + $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' ); + $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' ); + + // Generate query. + $query = array(); + $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, terms.term_id as term_count_id"; + $query['from'] = "FROM {$wpdb->posts}"; + $query['join'] = " + INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id + INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id ) + INNER JOIN {$wpdb->terms} AS terms USING( term_id ) + " . $tax_query_sql['join'] . $meta_query_sql['join']; + + $query['where'] = " + WHERE {$wpdb->posts}.post_type IN ( 'product' ) + AND {$wpdb->posts}.post_status = 'publish'" + . $tax_query_sql['where'] . $meta_query_sql['where'] . + 'AND terms.term_id IN (' . implode( ',', array_map( 'absint', $term_ids ) ) . ')'; + + $search = WC_Query::get_main_search_query_sql(); + if ( $search ) { + $query['where'] .= ' AND ' . $search; + } + + $query['group_by'] = 'GROUP BY terms.term_id'; + $query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query ); + $query = implode( ' ', $query ); + + // We have a query - let's see if cached results of this query already exist. + $query_hash = md5( $query ); + + // Maybe store a transient of the count values. + $cache = apply_filters( 'woocommerce_layered_nav_count_maybe_cache', true ); + if ( true === $cache ) { + $cached_counts = (array) get_transient( 'wc_layered_nav_counts_' . $taxonomy ); + } else { + $cached_counts = array(); + } + + if ( ! isset( $cached_counts[ $query_hash ] ) ) { + $results = $wpdb->get_results( $query, ARRAY_A ); // @codingStandardsIgnoreLine + $counts = array_map( 'absint', wp_list_pluck( $results, 'term_count', 'term_count_id' ) ); + $cached_counts[ $query_hash ] = $counts; + if ( true === $cache ) { + set_transient( 'wc_layered_nav_counts_' . $taxonomy, $cached_counts, DAY_IN_SECONDS ); + } + } + + return array_map( 'absint', (array) $cached_counts[ $query_hash ] ); + } + + /** + * Show list based layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return bool Will nav display? + */ + protected function layered_nav_list( $terms, $taxonomy, $query_type ) { + // List display. + echo '
        '; + + $term_counts = $this->get_filtered_term_product_counts( wp_list_pluck( $terms, 'term_id' ), $taxonomy, $query_type ); + $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); + $found = false; + + foreach ( $terms as $term ) { + $current_values = isset( $_chosen_attributes[ $taxonomy ]['terms'] ) ? $_chosen_attributes[ $taxonomy ]['terms'] : array(); + $option_is_set = in_array( $term->slug, $current_values, true ); + $count = isset( $term_counts[ $term->term_id ] ) ? $term_counts[ $term->term_id ] : 0; + + // Skip the term for the current archive. + if ( $this->get_current_term_id() === $term->term_id ) { + continue; + } + + // Only show options with count > 0. + if ( 0 < $count ) { + $found = true; + } elseif ( 0 === $count && ! $option_is_set ) { + continue; + } + + $filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) ); + $current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array(); // WPCS: input var ok, CSRF ok. + $current_filter = array_map( 'sanitize_title', $current_filter ); + + if ( ! in_array( $term->slug, $current_filter, true ) ) { + $current_filter[] = $term->slug; + } + + $link = remove_query_arg( $filter_name, $this->get_current_page_url() ); + + // Add current filters to URL. + foreach ( $current_filter as $key => $value ) { + // Exclude query arg for current term archive term. + if ( $value === $this->get_current_term_slug() ) { + unset( $current_filter[ $key ] ); + } + + // Exclude self so filter can be unset on click. + if ( $option_is_set && $value === $term->slug ) { + unset( $current_filter[ $key ] ); + } + } + + if ( ! empty( $current_filter ) ) { + asort( $current_filter ); + $link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link ); + + // Add Query type Arg to URL. + if ( 'or' === $query_type && ! ( 1 === count( $current_filter ) && $option_is_set ) ) { + $link = add_query_arg( 'query_type_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) ), 'or', $link ); + } + $link = str_replace( '%2C', ',', $link ); + } + + if ( $count > 0 || $option_is_set ) { + $link = esc_url( apply_filters( 'woocommerce_layered_nav_link', $link, $term, $taxonomy ) ); + $term_html = '' . esc_html( $term->name ) . ''; + } else { + $link = false; + $term_html = '' . esc_html( $term->name ) . ''; + } + + $term_html .= ' ' . apply_filters( 'woocommerce_layered_nav_count', '(' . absint( $count ) . ')', $count, $term ); + + echo '
      • '; + echo wp_kses_post( apply_filters( 'woocommerce_layered_nav_term_html', $term_html, $term, $link, $count ) ); + echo '
      • '; + } + + echo '
      '; + + return $found; + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-price-filter.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-price-filter.php new file mode 100644 index 0000000..4f97040 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-price-filter.php @@ -0,0 +1,161 @@ +widget_cssclass = 'woocommerce widget_price_filter'; + $this->widget_description = __( 'Display a slider to filter products in your store by price.', 'woocommerce' ); + $this->widget_id = 'woocommerce_price_filter'; + $this->widget_name = __( 'Filter Products by Price', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Filter by price', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + ); + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' ); + wp_register_script( 'wc-jquery-ui-touchpunch', WC()->plugin_url() . '/assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch' . $suffix . '.js', array( 'jquery-ui-slider' ), WC_VERSION, true ); + wp_register_script( 'wc-price-slider', WC()->plugin_url() . '/assets/js/frontend/price-slider' . $suffix . '.js', array( 'jquery-ui-slider', 'wc-jquery-ui-touchpunch', 'accounting' ), WC_VERSION, true ); + wp_localize_script( + 'wc-price-slider', 'woocommerce_price_slider_params', array( + 'currency_format_num_decimals' => 0, + 'currency_format_symbol' => get_woocommerce_currency_symbol(), + 'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ), + 'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ), + 'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ), + ) + ); + + if ( is_customize_preview() ) { + wp_enqueue_script( 'wc-price-slider' ); + } + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + global $wp; + + if ( ! is_shop() && ! is_product_taxonomy() ) { + return; + } + + if ( ! wc()->query->get_main_query()->post_count ) { + return; + } + + wp_enqueue_script( 'wc-price-slider' ); + + // Find min and max price in current result set. + $prices = $this->get_filtered_price(); + $min = floor( $prices->min_price ); + $max = ceil( $prices->max_price ); + + if ( $min === $max ) { + return; + } + + $this->widget_start( $args, $instance ); + + if ( '' === get_option( 'permalink_structure' ) ) { + $form_action = remove_query_arg( array( 'page', 'paged', 'product-page' ), add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); + } else { + $form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) ); + } + + $min_price = isset( $_GET['min_price'] ) ? wc_clean( wp_unslash( $_GET['min_price'] ) ) : apply_filters( 'woocommerce_price_filter_widget_min_amount', $min ); // WPCS: input var ok, CSRF ok. + $max_price = isset( $_GET['max_price'] ) ? wc_clean( wp_unslash( $_GET['max_price'] ) ) : apply_filters( 'woocommerce_price_filter_widget_max_amount', $max ); // WPCS: input var ok, CSRF ok. + + echo '
      +
      + +
      + + + + + ' . wc_query_string_form_fields( null, array( 'min_price', 'max_price' ), '', true ) . ' +
      +
      +
      +
      '; // WPCS: XSS ok. + + $this->widget_end( $args ); + } + + /** + * Get filtered min price for current products. + * + * @return int + */ + protected function get_filtered_price() { + global $wpdb; + + $args = wc()->query->get_main_query()->query_vars; + $tax_query = isset( $args['tax_query'] ) ? $args['tax_query'] : array(); + $meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array(); + + if ( ! is_post_type_archive( 'product' ) && ! empty( $args['taxonomy'] ) && ! empty( $args['term'] ) ) { + $tax_query[] = array( + 'taxonomy' => $args['taxonomy'], + 'terms' => array( $args['term'] ), + 'field' => 'slug', + ); + } + + foreach ( $meta_query + $tax_query as $key => $query ) { + if ( ! empty( $query['price_filter'] ) || ! empty( $query['rating_filter'] ) ) { + unset( $meta_query[ $key ] ); + } + } + + $meta_query = new WP_Meta_Query( $meta_query ); + $tax_query = new WP_Tax_Query( $tax_query ); + + $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' ); + $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' ); + + $sql = "SELECT min( FLOOR( price_meta.meta_value ) ) as min_price, max( CEILING( price_meta.meta_value ) ) as max_price FROM {$wpdb->posts} "; + $sql .= " LEFT JOIN {$wpdb->postmeta} as price_meta ON {$wpdb->posts}.ID = price_meta.post_id " . $tax_query_sql['join'] . $meta_query_sql['join']; + $sql .= " WHERE {$wpdb->posts}.post_type IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_post_type', array( 'product' ) ) ) ) . "') + AND {$wpdb->posts}.post_status = 'publish' + AND price_meta.meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "') + AND price_meta.meta_value > '' "; + $sql .= $tax_query_sql['where'] . $meta_query_sql['where']; + + $search = WC_Query::get_main_search_query_sql(); + if ( $search ) { + $sql .= ' AND ' . $search; + } + + return $wpdb->get_row( $sql ); // WPCS: unprepared SQL ok. + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-categories.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-categories.php new file mode 100644 index 0000000..b90816d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-categories.php @@ -0,0 +1,272 @@ +widget_cssclass = 'woocommerce widget_product_categories'; + $this->widget_description = __( 'A list or dropdown of product categories.', 'woocommerce' ); + $this->widget_id = 'woocommerce_product_categories'; + $this->widget_name = __( 'Product Categories', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Product categories', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'orderby' => array( + 'type' => 'select', + 'std' => 'name', + 'label' => __( 'Order by', 'woocommerce' ), + 'options' => array( + 'order' => __( 'Category order', 'woocommerce' ), + 'name' => __( 'Name', 'woocommerce' ), + ), + ), + 'dropdown' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Show as dropdown', 'woocommerce' ), + ), + 'count' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Show product counts', 'woocommerce' ), + ), + 'hierarchical' => array( + 'type' => 'checkbox', + 'std' => 1, + 'label' => __( 'Show hierarchy', 'woocommerce' ), + ), + 'show_children_only' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Only show children of the current category', 'woocommerce' ), + ), + 'hide_empty' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide empty categories', 'woocommerce' ), + ), + 'max_depth' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Maximum depth', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Widget arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + global $wp_query, $post; + + $count = isset( $instance['count'] ) ? $instance['count'] : $this->settings['count']['std']; + $hierarchical = isset( $instance['hierarchical'] ) ? $instance['hierarchical'] : $this->settings['hierarchical']['std']; + $show_children_only = isset( $instance['show_children_only'] ) ? $instance['show_children_only'] : $this->settings['show_children_only']['std']; + $dropdown = isset( $instance['dropdown'] ) ? $instance['dropdown'] : $this->settings['dropdown']['std']; + $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : $this->settings['orderby']['std']; + $hide_empty = isset( $instance['hide_empty'] ) ? $instance['hide_empty'] : $this->settings['hide_empty']['std']; + $dropdown_args = array( + 'hide_empty' => $hide_empty, + ); + $list_args = array( + 'show_count' => $count, + 'hierarchical' => $hierarchical, + 'taxonomy' => 'product_cat', + 'hide_empty' => $hide_empty, + ); + $max_depth = absint( isset( $instance['max_depth'] ) ? $instance['max_depth'] : $this->settings['max_depth']['std'] ); + + $list_args['menu_order'] = false; + $dropdown_args['depth'] = $max_depth; + $list_args['depth'] = $max_depth; + + if ( 'order' === $orderby ) { + $list_args['menu_order'] = 'asc'; + } else { + $list_args['orderby'] = 'title'; + } + + $this->current_cat = false; + $this->cat_ancestors = array(); + + if ( is_tax( 'product_cat' ) ) { + $this->current_cat = $wp_query->queried_object; + $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + + } elseif ( is_singular( 'product' ) ) { + $terms = wc_get_product_terms( + $post->ID, 'product_cat', apply_filters( + 'woocommerce_product_categories_widget_product_terms_args', array( + 'orderby' => 'parent', + 'order' => 'DESC', + ) + ) + ); + + if ( $terms ) { + $main_term = apply_filters( 'woocommerce_product_categories_widget_main_term', $terms[0], $terms ); + $this->current_cat = $main_term; + $this->cat_ancestors = get_ancestors( $main_term->term_id, 'product_cat' ); + } + } + + // Show Siblings and Children Only. + if ( $show_children_only && $this->current_cat ) { + if ( $hierarchical ) { + $include = array_merge( + $this->cat_ancestors, + array( $this->current_cat->term_id ), + get_terms( + 'product_cat', + array( + 'fields' => 'ids', + 'parent' => 0, + 'hierarchical' => true, + 'hide_empty' => false, + ) + ), + get_terms( + 'product_cat', + array( + 'fields' => 'ids', + 'parent' => $this->current_cat->term_id, + 'hierarchical' => true, + 'hide_empty' => false, + ) + ) + ); + // Gather siblings of ancestors. + if ( $this->cat_ancestors ) { + foreach ( $this->cat_ancestors as $ancestor ) { + $include = array_merge( + $include, get_terms( + 'product_cat', + array( + 'fields' => 'ids', + 'parent' => $ancestor, + 'hierarchical' => false, + 'hide_empty' => false, + ) + ) + ); + } + } + } else { + // Direct children. + $include = get_terms( + 'product_cat', + array( + 'fields' => 'ids', + 'parent' => $this->current_cat->term_id, + 'hierarchical' => true, + 'hide_empty' => false, + ) + ); + } + + $list_args['include'] = implode( ',', $include ); + $dropdown_args['include'] = $list_args['include']; + + if ( empty( $include ) ) { + return; + } + } elseif ( $show_children_only ) { + $dropdown_args['depth'] = 1; + $dropdown_args['child_of'] = 0; + $dropdown_args['hierarchical'] = 1; + $list_args['depth'] = 1; + $list_args['child_of'] = 0; + $list_args['hierarchical'] = 1; + } + + $this->widget_start( $args, $instance ); + + if ( $dropdown ) { + wc_product_dropdown_categories( + apply_filters( + 'woocommerce_product_categories_widget_dropdown_args', wp_parse_args( + $dropdown_args, array( + 'show_count' => $count, + 'hierarchical' => $hierarchical, + 'show_uncategorized' => 0, + 'orderby' => $orderby, + 'selected' => $this->current_cat ? $this->current_cat->slug : '', + ) + ) + ) + ); + wc_enqueue_js( + " + jQuery( '.dropdown_product_cat' ).change( function() { + if ( jQuery(this).val() != '' ) { + var this_page = ''; + var home_url = '" . esc_js( home_url( '/' ) ) . "'; + if ( home_url.indexOf( '?' ) > 0 ) { + this_page = home_url + '&product_cat=' + jQuery(this).val(); + } else { + this_page = home_url + '?product_cat=' + jQuery(this).val(); + } + location.href = this_page; + } + }); + " + ); + } else { + include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-list-walker.php'; + + $list_args['walker'] = new WC_Product_Cat_List_Walker(); + $list_args['title_li'] = ''; + $list_args['pad_counts'] = 1; + $list_args['show_option_none'] = __( 'No product categories exist.', 'woocommerce' ); + $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; + $list_args['current_category_ancestors'] = $this->cat_ancestors; + $list_args['max_depth'] = $max_depth; + + echo '
        '; + + wp_list_categories( apply_filters( 'woocommerce_product_categories_widget_args', $list_args ) ); + + echo '
      '; + } + + $this->widget_end( $args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-search.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-search.php new file mode 100644 index 0000000..2df1192 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-search.php @@ -0,0 +1,50 @@ +widget_cssclass = 'woocommerce widget_product_search'; + $this->widget_description = __( 'A search form for your store.', 'woocommerce' ); + $this->widget_id = 'woocommerce_product_search'; + $this->widget_name = __( 'Product Search', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Title', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + $this->widget_start( $args, $instance ); + + get_product_search_form(); + + $this->widget_end( $args ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-tag-cloud.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-tag-cloud.php new file mode 100644 index 0000000..d934366 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-product-tag-cloud.php @@ -0,0 +1,120 @@ +widget_cssclass = 'woocommerce widget_product_tag_cloud'; + $this->widget_description = __( 'A cloud of your most used product tags.', 'woocommerce' ); + $this->widget_id = 'woocommerce_product_tag_cloud'; + $this->widget_name = __( 'Product Tag Cloud', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Product tags', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + $current_taxonomy = $this->get_current_taxonomy( $instance ); + + if ( empty( $instance['title'] ) ) { + $taxonomy = get_taxonomy( $current_taxonomy ); + $instance['title'] = $taxonomy->labels->name; + } + + $this->widget_start( $args, $instance ); + + echo '
      '; + + wp_tag_cloud( + apply_filters( + 'woocommerce_product_tag_cloud_widget_args', array( + 'taxonomy' => $current_taxonomy, + 'topic_count_text_callback' => array( $this, 'topic_count_text' ), + ) + ) + ); + + echo '
      '; + + $this->widget_end( $args ); + } + + /** + * Return the taxonomy being displayed. + * + * @param object $instance Widget instance. + * @return string + */ + public function get_current_taxonomy( $instance ) { + return 'product_tag'; + } + + /** + * Returns topic count text. + * + * @since 3.4.0 + * @param int $count Count text. + * @return string + */ + public function topic_count_text( $count ) { + /* translators: %s: product count */ + return sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) ); + } + + // Ignore whole block to avoid warnings about PSR2.Methods.MethodDeclaration.Underscore violation. + // @codingStandardsIgnoreStart + /** + * Return the taxonomy being displayed. + * + * @deprecated 3.4.0 + * @param object $instance Widget instance. + * @return string + */ + public function _get_current_taxonomy( $instance ) { + wc_deprecated_function( '_get_current_taxonomy', '3.4.0', 'WC_Widget_Product_Tag_Cloud->get_current_taxonomy' ); + return $this->get_current_taxonomy( $instance ); + } + + /** + * Returns topic count text. + * + * @deprecated 3.4.0 + * @since 2.6.0 + * @param int $count Count text. + * @return string + */ + public function _topic_count_text( $count ) { + wc_deprecated_function( '_topic_count_text', '3.4.0', 'WC_Widget_Product_Tag_Cloud->topic_count_text' ); + return $this->topic_count_text( $count ); + } + // @codingStandardsIgnoreEnd +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-products.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-products.php new file mode 100644 index 0000000..d3e5334 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-products.php @@ -0,0 +1,213 @@ +widget_cssclass = 'woocommerce widget_products'; + $this->widget_description = __( "A list of your store's products.", 'woocommerce' ); + $this->widget_id = 'woocommerce_products'; + $this->widget_name = __( 'Products', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Products', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'number' => array( + 'type' => 'number', + 'step' => 1, + 'min' => 1, + 'max' => '', + 'std' => 5, + 'label' => __( 'Number of products to show', 'woocommerce' ), + ), + 'show' => array( + 'type' => 'select', + 'std' => '', + 'label' => __( 'Show', 'woocommerce' ), + 'options' => array( + '' => __( 'All products', 'woocommerce' ), + 'featured' => __( 'Featured products', 'woocommerce' ), + 'onsale' => __( 'On-sale products', 'woocommerce' ), + ), + ), + 'orderby' => array( + 'type' => 'select', + 'std' => 'date', + 'label' => __( 'Order by', 'woocommerce' ), + 'options' => array( + 'date' => __( 'Date', 'woocommerce' ), + 'price' => __( 'Price', 'woocommerce' ), + 'rand' => __( 'Random', 'woocommerce' ), + 'sales' => __( 'Sales', 'woocommerce' ), + ), + ), + 'order' => array( + 'type' => 'select', + 'std' => 'desc', + 'label' => _x( 'Order', 'Sorting order', 'woocommerce' ), + 'options' => array( + 'asc' => __( 'ASC', 'woocommerce' ), + 'desc' => __( 'DESC', 'woocommerce' ), + ), + ), + 'hide_free' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide free products', 'woocommerce' ), + ), + 'show_hidden' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Show hidden products', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Query the products and return them. + * + * @param array $args Arguments. + * @param array $instance Widget instance. + * @return WP_Query + */ + public function get_products( $args, $instance ) { + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; + $show = ! empty( $instance['show'] ) ? sanitize_title( $instance['show'] ) : $this->settings['show']['std']; + $orderby = ! empty( $instance['orderby'] ) ? sanitize_title( $instance['orderby'] ) : $this->settings['orderby']['std']; + $order = ! empty( $instance['order'] ) ? sanitize_title( $instance['order'] ) : $this->settings['order']['std']; + $product_visibility_term_ids = wc_get_product_visibility_term_ids(); + + $query_args = array( + 'posts_per_page' => $number, + 'post_status' => 'publish', + 'post_type' => 'product', + 'no_found_rows' => 1, + 'order' => $order, + 'meta_query' => array(), + 'tax_query' => array( + 'relation' => 'AND', + ), + ); // WPCS: slow query ok. + + if ( empty( $instance['show_hidden'] ) ) { + $query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => is_search() ? $product_visibility_term_ids['exclude-from-search'] : $product_visibility_term_ids['exclude-from-catalog'], + 'operator' => 'NOT IN', + ); + $query_args['post_parent'] = 0; + } + + if ( ! empty( $instance['hide_free'] ) ) { + $query_args['meta_query'][] = array( + 'key' => '_price', + 'value' => 0, + 'compare' => '>', + 'type' => 'DECIMAL', + ); + } + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { + $query_args['tax_query'] = array( + array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => $product_visibility_term_ids['outofstock'], + 'operator' => 'NOT IN', + ), + ); // WPCS: slow query ok. + } + + switch ( $show ) { + case 'featured': + $query_args['tax_query'][] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => $product_visibility_term_ids['featured'], + ); + break; + case 'onsale': + $product_ids_on_sale = wc_get_product_ids_on_sale(); + $product_ids_on_sale[] = 0; + $query_args['post__in'] = $product_ids_on_sale; + break; + } + + switch ( $orderby ) { + case 'price': + $query_args['meta_key'] = '_price'; // WPCS: slow query ok. + $query_args['orderby'] = 'meta_value_num'; + break; + case 'rand': + $query_args['orderby'] = 'rand'; + break; + case 'sales': + $query_args['meta_key'] = 'total_sales'; // WPCS: slow query ok. + $query_args['orderby'] = 'meta_value_num'; + break; + default: + $query_args['orderby'] = 'date'; + } + + return new WP_Query( apply_filters( 'woocommerce_products_widget_query_args', $query_args ) ); + } + + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + $products = $this->get_products( $args, $instance ); + if ( $products && $products->have_posts() ) { + $this->widget_start( $args, $instance ); + + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '
        ' ) ); + + $template_args = array( + 'widget_id' => $args['widget_id'], + 'show_rating' => true, + ); + + while ( $products->have_posts() ) { + $products->the_post(); + wc_get_template( 'content-widget-product.php', $template_args ); + } + + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '
      ' ) ); + + $this->widget_end( $args ); + } + + wp_reset_postdata(); + + echo $this->cache_widget( $args, ob_get_clean() ); // WPCS: XSS ok. + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-rating-filter.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-rating-filter.php new file mode 100644 index 0000000..b9601cc --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-rating-filter.php @@ -0,0 +1,139 @@ +widget_cssclass = 'woocommerce widget_rating_filter'; + $this->widget_description = __( 'Display a list of star ratings to filter products in your store.', 'woocommerce' ); + $this->widget_id = 'woocommerce_rating_filter'; + $this->widget_name = __( 'Filter Products by Rating', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Average rating', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + ); + parent::__construct(); + } + + /** + * Count products after other filters have occurred by adjusting the main query. + * + * @param int $rating Rating. + * @return int + */ + protected function get_filtered_product_count( $rating ) { + global $wpdb; + + $tax_query = WC_Query::get_main_tax_query(); + $meta_query = WC_Query::get_main_meta_query(); + + // Unset current rating filter. + foreach ( $tax_query as $key => $query ) { + if ( ! empty( $query['rating_filter'] ) ) { + unset( $tax_query[ $key ] ); + break; + } + } + + // Set new rating filter. + $product_visibility_terms = wc_get_product_visibility_term_ids(); + $tax_query[] = array( + 'taxonomy' => 'product_visibility', + 'field' => 'term_taxonomy_id', + 'terms' => $product_visibility_terms[ 'rated-' . $rating ], + 'operator' => 'IN', + 'rating_filter' => true, + ); + + $meta_query = new WP_Meta_Query( $meta_query ); + $tax_query = new WP_Tax_Query( $tax_query ); + $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' ); + $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' ); + + $sql = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) FROM {$wpdb->posts} "; + $sql .= $tax_query_sql['join'] . $meta_query_sql['join']; + $sql .= " WHERE {$wpdb->posts}.post_type = 'product' AND {$wpdb->posts}.post_status = 'publish' "; + $sql .= $tax_query_sql['where'] . $meta_query_sql['where']; + + $search = WC_Query::get_main_search_query_sql(); + if ( $search ) { + $sql .= ' AND ' . $search; + } + + return absint( $wpdb->get_var( $sql ) ); // WPCS: unprepared SQL ok. + } + + /** + * Widget function. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + if ( ! is_shop() && ! is_product_taxonomy() ) { + return; + } + + if ( ! wc()->query->get_main_query()->post_count ) { + return; + } + + ob_start(); + + $found = false; + $rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) ) : array(); // WPCS: input var ok, CSRF ok, sanitization ok. + + $this->widget_start( $args, $instance ); + + echo '
        '; + + for ( $rating = 5; $rating >= 1; $rating-- ) { + $count = $this->get_filtered_product_count( $rating ); + if ( empty( $count ) ) { + continue; + } + $found = true; + $link = $this->get_current_page_url(); + + if ( in_array( $rating, $rating_filter, true ) ) { + $link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) ); + } else { + $link_ratings = implode( ',', array_merge( $rating_filter, array( $rating ) ) ); + } + + $class = in_array( $rating, $rating_filter, true ) ? 'wc-layered-nav-rating chosen' : 'wc-layered-nav-rating'; + $link = apply_filters( 'woocommerce_rating_filter_link', $link_ratings ? add_query_arg( 'rating_filter', $link_ratings ) : remove_query_arg( 'rating_filter' ) ); + $rating_html = wc_get_star_rating_html( $rating ); + $count_html = esc_html( apply_filters( 'woocommerce_rating_filter_count', "({$count})", $count, $rating ) ); + + printf( '
      • %s %s
      • ', esc_attr( $class ), esc_url( $link ), $rating_html, $count_html ); // WPCS: XSS ok. + } + + echo '
      '; + + $this->widget_end( $args ); + + if ( ! $found ) { + ob_end_clean(); + } else { + echo ob_get_clean(); // WPCS: XSS ok. + } + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recent-reviews.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recent-reviews.php new file mode 100644 index 0000000..c609610 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recent-reviews.php @@ -0,0 +1,94 @@ +widget_cssclass = 'woocommerce widget_recent_reviews'; + $this->widget_description = __( 'Display a list of recent reviews from your store.', 'woocommerce' ); + $this->widget_id = 'woocommerce_recent_reviews'; + $this->widget_name = __( 'Recent Product Reviews', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Recent reviews', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'number' => array( + 'type' => 'number', + 'step' => 1, + 'min' => 1, + 'max' => '', + 'std' => 10, + 'label' => __( 'Number of reviews to show', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + global $comments, $comment; + + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; + $comments = get_comments( + array( + 'number' => $number, + 'status' => 'approve', + 'post_status' => 'publish', + 'post_type' => 'product', + 'parent' => 0, + ) + ); // WPCS: override ok. + + if ( $comments ) { + $this->widget_start( $args, $instance ); + + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_review_list', '
        ' ) ); + + foreach ( (array) $comments as $comment ) { + wc_get_template( 'content-widget-reviews.php', array( + 'comment' => $comment, + 'product' => wc_get_product( $comment->comment_post_ID ), + ) ); + } + + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_review_list', '
      ' ) ); + + $this->widget_end( $args ); + + } + + $content = ob_get_clean(); + + echo $content; // WPCS: XSS ok. + + $this->cache_widget( $args, $content ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recently-viewed.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recently-viewed.php new file mode 100644 index 0000000..e5a8db3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-recently-viewed.php @@ -0,0 +1,110 @@ +widget_cssclass = 'woocommerce widget_recently_viewed_products'; + $this->widget_description = __( "Display a list of a customer's recently viewed products.", 'woocommerce' ); + $this->widget_id = 'woocommerce_recently_viewed_products'; + $this->widget_name = __( 'Recent Viewed Products', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Recently Viewed Products', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'number' => array( + 'type' => 'number', + 'step' => 1, + 'min' => 1, + 'max' => 15, + 'std' => 10, + 'label' => __( 'Number of products to show', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + $viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array(); // @codingStandardsIgnoreLine + $viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) ); + + if ( empty( $viewed_products ) ) { + return; + } + + ob_start(); + + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; + + $query_args = array( + 'posts_per_page' => $number, + 'no_found_rows' => 1, + 'post_status' => 'publish', + 'post_type' => 'product', + 'post__in' => $viewed_products, + 'orderby' => 'post__in', + ); + + if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { + $query_args['tax_query'] = array( + array( + 'taxonomy' => 'product_visibility', + 'field' => 'name', + 'terms' => 'outofstock', + 'operator' => 'NOT IN', + ), + ); // WPCS: slow query ok. + } + + $r = new WP_Query( apply_filters( 'woocommerce_recently_viewed_products_widget_query_args', $query_args ) ); + + if ( $r->have_posts() ) { + + $this->widget_start( $args, $instance ); + + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '
        ' ) ); + + $template_args = array( + 'widget_id' => $args['widget_id'], + ); + + while ( $r->have_posts() ) { + $r->the_post(); + wc_get_template( 'content-widget-product.php', $template_args ); + } + + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '
      ' ) ); + + $this->widget_end( $args ); + } + + wp_reset_postdata(); + + $content = ob_get_clean(); + + echo $content; // WPCS: XSS ok. + } +} diff --git a/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-top-rated-products.php b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-top-rated-products.php new file mode 100644 index 0000000..1717e6a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-top-rated-products.php @@ -0,0 +1,104 @@ +widget_cssclass = 'woocommerce widget_top_rated_products'; + $this->widget_description = __( "A list of your store's top-rated products.", 'woocommerce' ); + $this->widget_id = 'woocommerce_top_rated_products'; + $this->widget_name = __( 'Products by Rating', 'woocommerce' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Top rated products', 'woocommerce' ), + 'label' => __( 'Title', 'woocommerce' ), + ), + 'number' => array( + 'type' => 'number', + 'step' => 1, + 'min' => 1, + 'max' => '', + 'std' => 5, + 'label' => __( 'Number of products to show', 'woocommerce' ), + ), + ); + + parent::__construct(); + } + + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget( $args, $instance ) { + + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; + + $query_args = array( + 'posts_per_page' => $number, + 'no_found_rows' => 1, + 'post_status' => 'publish', + 'post_type' => 'product', + 'meta_key' => '_wc_average_rating', + 'orderby' => 'meta_value_num', + 'order' => 'DESC', + 'meta_query' => WC()->query->get_meta_query(), + 'tax_query' => WC()->query->get_tax_query(), + ); // WPCS: slow query ok. + + $r = new WP_Query( $query_args ); + + if ( $r->have_posts() ) { + + $this->widget_start( $args, $instance ); + + echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '
        ' ) ); + + $template_args = array( + 'widget_id' => $args['widget_id'], + 'show_rating' => true, + ); + + while ( $r->have_posts() ) { + $r->the_post(); + wc_get_template( 'content-widget-product.php', $template_args ); + } + + echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '
      ' ) ); + + $this->widget_end( $args ); + } + + wp_reset_postdata(); + + $content = ob_get_clean(); + + echo $content; // WPCS: XSS ok. + + $this->cache_widget( $args, $content ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/license.txt b/backend/wp-content/plugins/woocommerce/license.txt new file mode 100644 index 0000000..ca286f1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/license.txt @@ -0,0 +1,710 @@ +WooCommerce - eCommerce for WordPress + +Copyright 2015 by the contributors + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +This program incorporates work covered by the following copyright and +permission notices: + + Jigoshop is Copyright (c) 2011 Jigowatt Ltd. + http://jigowatt.com - http://jigoshop.com + + Jigoshop is released under the GPL + +and + + WooCommerce - eCommerce for WordPress + + WooCommerce is Copyright (c) 2015 WooThemes + + WooCommerce is released under the GPL + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright © 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright © + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright © + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/backend/wp-content/plugins/woocommerce/readme.txt b/backend/wp-content/plugins/woocommerce/readme.txt new file mode 100644 index 0000000..92a8753 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/readme.txt @@ -0,0 +1,396 @@ +=== WooCommerce === +Contributors: automattic, mikejolley, jameskoster, claudiosanches, claudiulodro, kloon, rodrigosprimo, jshreve, coderkevin +Tags: ecommerce, e-commerce, store, sales, sell, shop, cart, checkout, downloadable, downloads, paypal, storefront, woo commerce +Requires at least: 4.7 +Tested up to: 4.9 +Stable tag: 3.4.2 +License: GPLv3 +License URI: https://www.gnu.org/licenses/gpl-3.0.html + +WooCommerce is a powerful, extendable eCommerce plugin that helps you sell anything. Beautifully. + +== Description == + +WooCommerce is a free eCommerce plugin that allows you to sell anything, beautifully. Built to integrate seamlessly with WordPress, WooCommerce is the world’s favorite eCommerce solution that gives both store owners and developers complete control. + +With endless flexibility and access to hundreds of free and premium WordPress extensions, WooCommerce now powers 30% of all online stores -- more than any other platform. + +[youtube https://www.youtube.com/watch?v=1KahlicghaE] + += Sell anything, anywhere = +With WooCommerce, you can sell both physical and digital goods in all shapes and sizes, offer product variations, multiple configurations, and instant downloads to shoppers, and even sell affiliate goods from online marketplaces. + +With premium extensions, you can offer bookings, memberships, and recurring subscriptions. Perhaps you’d like to sell monthly subscriptions for physical goods, or offer your members a discount on digital downloads? It’s all possible. + += Ship wherever you like = +Offer free shipping, flat rate shipping, or make real-time calculations. Limit your shipments to specific countries, or open your store up to the world. Shipping is highly configurable, and WooCommerce even supports drop shipping. + += Extensive payment options = +WooCommerce comes bundled with the ability to accept major credit cards, PayPal, BACS (bank transfers), and cash on delivery. Need additional options? More than 140 region-specific gateways integrate with WooCommerce, including popular choices like Stripe, Authorize.Net, and Amazon Payments. + += You control it all -- forever = +WooCommerce gives you complete control of your store, from taxes to stock levels to customer accounts. Add and remove extensions, change your design, and switch settings as you please. It’s all under your control. + +One of the biggest risks of using a hosted eCommerce platform is what happens to your store if the provider closes up shop. With WooCommerce, you have complete control, so there’s never any reason to worry. Your data belongs to you -- and it’s kept secure, thanks to regular audits by industry leaders. + += Define your style with Storefront = + +[Storefront](https://woocommerce.com/storefront/) is a free WordPress theme available to any WooCommerce store. Along with deep WooCommerce integration, Storefront prioritizes speed and uptime while eliminating theme and plugin conflicts during major updates. + +Define your style even further by customizing Storefront to your liking or choosing from one of our several [Storefront child themes](https://woocommerce.com/product-category/themes/storefront-child-theme-themes/). It’s all up to you, and all open source. + += Built with developers in mind = + +Extendable, adaptable, and open source -- WooCommerce was created with developers in mind. With its strong, robust framework, you can scale your client’s store all the way from basic to high-end (infinity and beyond). + +Built with a REST API, WooCommerce can integrate with virtually any service. Your store’s data can be accessed anywhere, anytime, 100% securely. WooCommerce allows developers to easily create, modify, and grow a store that meets their specifications. + +No matter the size of the store you want to build, WooCommerce will scale to meet your requirements. With a growing collection of more than 300 extensions, you can enhance each store’s features to meet your client’s unique needs -- or even create your own solution. + +If security is a concern, rest easy. WooCommerce is audited by a dedicated team of developers working around the clock to identify and patch any and all discovered bugs. + +We also support WooCommerce and all its extensions with comprehensive, easily-accessible documentation. With our docs, you’ll learn how to create the exact site your client needs. + += Extensions galore = + +WordPress.org is home to some amazing extensions for WooCommerce, including: + +- [Google Analytics](https://wordpress.org/plugins/woocommerce-google-analytics-integration/) +- [Delivery Notes](https://wordpress.org/plugins/woocommerce-delivery-notes/) +- [PDF Invoices and Packing Slips](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/) +- [Affiliates Integration Light](https://wordpress.org/plugins/affiliates-woocommerce-light/) +- [New Product Badges](https://wordpress.org/plugins/woocommerce-new-product-badge/) + +Keen to see them all? Search WordPress.org for ‘WooCommerce’ to dive in. + +If you’re looking for something endorsed and maintained by the developers who built WooCommerce, there are a plethora of premium eCommerce extensions, the most popular of which include: + +- [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) +- [WooCommerce Memberships](https://woocommerce.com/products/woocommerce-memberships/) +- [WooCommerce Bookings](https://woocommerce.com/products/woocommerce-bookings/) +- [Dynamic Pricing](https://woocommerce.com/products/dynamic-pricing/) +- [Table Rate Shipping](https://woocommerce.com/products/table-rate-shipping/) +- [Product CSV Import Suite](https://woocommerce.com/products/product-csv-import-suite/) + +And there’s plenty more where they came from. Visit our [extensions page](https://woocommerce.com/product-category/woocommerce-extensions/) to find out everything you’re capable of and all that's possible with premium WooCommerce extensions. + += Join our growing community = + +When you download WooCommerce, you join a community of more than a million store owners, developers, and WordPress enthusiasts. We're one of the fastest-growing open source communities online, and no matter your skill level we'd love to have you! + +If you’re interested in contributing to WooCommerce we’ve got more than 350 contributors, and there’s always room for more. Head over to the [WooCommerce GitHub Repository](https://github.com/woocommerce/woocommerce) to find out how you can pitch in. + +Want to add a new language to WooCommerce? Swell! You can contribute via [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/woocommerce). + +And, finally, consider joining or spearheading a WooCommerce Meetup locally, more about those [here](https://woocommerce.com/woocommerce/meetups/). + +== Installation == + += Minimum Requirements = + +* PHP version 5.2.4 or greater (PHP 7.2 or greater is recommended) +* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended) + +Visit the [WooCommerce server requirements documentation](https://docs.woocommerce.com/document/server-requirements/) for a detailed list of server requirements. + += Automatic installation = + +Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t need to leave your web browser. To do an automatic install of WooCommerce, log in to your WordPress dashboard, navigate to the Plugins menu and click Add New. + +In the search field type “WooCommerce†and click Search Plugins. Once you’ve found our eCommerce plugin you can view details about it such as the point release, rating and description. Most importantly of course, you can install it by simply clicking “Install Nowâ€. + += Manual installation = + +The manual installation method involves downloading our eCommerce plugin and uploading it to your webserver via your favourite FTP application. The WordPress codex contains [instructions on how to do this here](https://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). + += Updating = + +Automatic updates should work like a charm; as always though, ensure you backup your site just in case. + +If on the off-chance you do encounter issues with the shop/category pages after an update you simply need to flush the permalinks by going to WordPress > Settings > Permalinks and hitting 'save'. That should return things to normal. + += Sample data = + +WooCommerce comes with some sample data you can use to see how products look; import sample_products.xml via the [WordPress importer](https://wordpress.org/plugins/wordpress-importer/). You can also use the core [CSV importer](https://docs.woocommerce.com/document/product-csv-importer-exporter/) or our [CSV Import Suite plugin](https://woocommerce.com/products/product-csv-import-suite/) to import sample_products.csv. + +== Frequently Asked Questions == + += Where can I find WooCommerce documentation and user guides? = + +For help setting up and configuring WooCommerce please refer to our [user guide](https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/) + +For extending or theming WooCommerce, see our [codex](https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/). + += Where can I get support or talk to other users? = + +If you get stuck, you can ask for help in the [WooCommerce Plugin Forum](https://wordpress.org/support/plugin/woocommerce). + +For help with premium extensions from WooCommerce.com, use [our helpdesk](https://woocommerce.com/my-account/tickets/). + += Will WooCommerce work with my theme? = + +Yes; WooCommerce will work with any theme, but may require some styling to make it match nicely. Please see our [codex](https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/) for help. If you're looking for a theme with built in WooCommerce integration we recommend [Storefront](https://woocommerce.com/storefront/). + += Where can I request new features, eCommerce themes and extensions? = + +You can vote on and request new features and extensions in our [WooIdeas board](http://ideas.woocommerce.com/forums/133476-woocommerce) + += Where can I report bugs or contribute to the project? = + +Bugs can be reported either in our support forum or preferably on the [WooCommerce GitHub repository](https://github.com/woocommerce/woocommerce/issues). + += Where can I find the REST API documentation? = + +You can find the documentation of our REST API on the [WooCommerce REST API Docs](https://woocommerce.github.io/woocommerce-rest-api-docs/). + += WooCommerce is awesome! Can I contribute? = + +Yes you can! Join in on our [GitHub repository](https://github.com/woocommerce/woocommerce/) :) + +== Screenshots == + +1. The WooCommerce settings panel. +2. WooCommerce products admin. +3. Product data panel. +4. WooCommerce sales reports. +5. A single product page. +6. A product archive (grid). + +== Changelog == + += 3.4.2 - 2018-06-05 = +* Fix - Flexslider gallery fixes for RTL sites, and for variation image switching. #20328 ##20321 +* Fix - Allow forms to be submitted when the password strength library fails to load. #20362 +* Fix - Personal data exporter: Do not export a customer data group containing no data. #20347 +* Fix - Fix navigation notification in settings when clicking save. #20335 +* Fix - Show discount amount for free shipping coupons. #20334 +* Fix - Fixed cache clearing for category children for sites running object caching. #20308 +* Fix - Use correct escaping on select2 placeholders. #20364 +* Fix - Order by price clauses when searching within terms. #20391 +* Fix - Clear needs_processing transient when adding a product to an order. #20390 +* Enhancement - Permission_id constraint checks on install. #20366 +* Dev - Added order to "woocommerce_order_is_vat_exempt" filter arguments. #20365 +* Localization - Disable states for Bahrain. #20363 +* Localization - Disable states for Luxemberg. #20389 + += 3.4.1 - 2018-05-29 = +* Fix - Fix webhook admin filtering URLs. #20236 +* Fix - Add missing wp_unslash calls to product data meta box to prevent quote characters being escaped on save. #20235 +* Fix - Display price filter widget in LTR mode on RTL sites. #20221 +* Fix - Refactor WC_Coupon constructor to allow for passing in coupon objects. #20193 +* Fix - Path field in advanced CSV importer was broken due to an esc_url call. #20191 +* Fix - Prevent shipping method instances trying to save settings on non-instance screens. #20217 +* Fix - Wrapper function to get full mysql version string with mariadb handling. #20231 +* Fix - woocommerce_pagination had some extra white space. #20214 +* Fix - If a file size cannot be read, ignore range headers to prevent offsite downloads being 0kb. #20205 +* Fix - Allow HTML when using `wc_attribute_label()`. #20202 +* Fix - Update address-i18n.js to prevent appending multiple "(optional)" labels. #20195 +* Fix - Check plugin properties exist when listening to auto_update_plugin hook. #20234 +* Fix - Add extra checks in `get_canonical_package_rate_ids` to prevent notices. #20237 +* Fix - Fix infinite loop with importing tax rates. #20253 +* Fix - Echo attribute label for "empty" default option. #20256 +* Fix - Fix download sample tax rates URL format. #20272 +* Fix - Product properties should not be accessed directly PHP notice when calling `wc_get_product_attachment_props`. #20282 +* Fix - If flexslider is disabled, gallery images also need to trigger photoswipe on click. #20290 +* Fix - Product import file uploads on windows servers. #20273 +* Fix - Fix variation attribute selection via the cart page/query string. #20293 +* Fix - Add greater specificity to required styling in 2017 theme. #20296 +* Enhancement - Export legacy paypal meta data in personal data exporter. #20200 +* Enhancement - Improve performance of `wc_update_340_states` update routine to help prevent timeouts. #20241 +* Dev - Remove red styling for PHP notice if using > 5.6. #20294 +* Dev - Add an action hook after printing the cart item name. #20190 +* Localization - Use "payment tokens" terminology in exports. #20197 + += 3.4.0 - 2018-05-23 = +* Feature - GDPR: Tools to export WooCommerce data using the new export functionality in WordPress 4.9.6. #19330 +* Feature - GDPR: Tools to bulk anonymize order data in admin. #19330 +* Feature - GDPR: Tools to turn off company/address-2/phone checkout fields to avoid unnecessary data collection, and a toggle to choose how required fields are presented. This is available via the Customizer. #19637 +* Feature - GDPR: Tools in the Customizer to change the terms and conditions checkbox label on the checkout. #19637 +* Feature - GDPR: Tools to define a privacy policy for the account page and checkout page in "account privacy" settings and within the Customizer. #19747 +* Feature - GDPR: Tools to automatically clean up and remove order personal data after a set time period. #19743 +* Feature - GDPR: Added privacy snippet which works with the new privacy page functionality in WordPress 4.9.6. #19749 +* Feature - Added a new order widget to the dashboard (on multisite) so you can see your orders across multiple stores on the same WordPress network. #17598 +* Feature - Added "display name" input on the My Account page. #19078 +* Feature - Product search improvements including stopword support and support for searching for multiple products at the same time. #19096 +* Feature - Cash on Delivery gateway can be enabled/disabled for specific shipping methods instead of only method types. #19221 +* Feature - Add wildcard email support for coupons. #19331 +* Feature - Added support for the GeoLite2 library as a replacement for the deprecated MaxMind GeoIP library. #19419 +* Feature - Added tool for cleaning up download permissions table. #19922 +* Tweak - GDPR: Improved appearance of checkout field 'descriptions' (if used) to make them more useful for privacy notices. #19637 +* Tweak - GDPR: Improved related data cleanup when deleting users/orders. #19330 +* Tweak - GDPR: Notice about HTTPS as a requirement in admin if missing. #19756 +* Tweak - GDPR: Improved the checkout (payments) settings screen, moved page options to a new "advanced" section, and made an "Accounts and Privacy" section. #19703 +* Tweak - GDPR: Hash customer email address in download URLs to protect privacy. #18957 +* Tweak - GDPR: Add highlight to T&C checkbox if not checked to show it needs to be checked. #19177 +* Tweak - GDPR: Automatically purge old logs after 30 days. #19920 +* Tweak - GDPR: Only log Webhook body if WP_DEBUG is enabled. #19914 +* Tweak - GDPR: Store less PII in PayPal standard. #19914 +* Tweak - Only show admin notices on WooCommerce screens/plugins/dashboard. #19772 +* Tweak - Standardize stock update messages in admin and correctly log who performed the action. When an order note is added after modifying stock manually, update order notes display via AJAX. #18080 +* Tweak - Rollback if payment complete or update status fails to prevent partial order updates on failure. #18175 +* Tweak - Made the system status tool which purges user carts also purge persistent carts. #18492 +* Tweak - Display whether or not external object cache is enabled in system status report. #18595 +* Tweak - Display zero value when using shipping classes. #18624 +* Tweak - Fixed settings table styling on mobile. #18655 +* Tweak - Updated Flexslider to version 2.7.0. #18779 +* Tweak - Enable screen options for list screens. #18817 +* Tweak - Don't call WC_Install::install() on downgrades. #18818 +* Tweak - Remove user login from reset password link to protect personally identifying info. #18820 +* Tweak - Added a function to return a list of custom tables to aid with cleanup. #18831 +* Tweak - Enable going backwards in the setup wizard. #18921 +* Tweak - Make sure terms page exists and isn’t trashed before using it. #18993 +* Tweak - Toggle when clicking anywhere in toggle row during setup wizard. #19035 +* Tweak - Use `read_product` permissions instead of `edit_product` for ajax product search. #19087 +* Tweak - Add `priceSpecification` property with `valueAddedTaxIncluded` to product structured data. #19091 +* Tweak - Importer remembers mappings across imports. #19110 +* Tweak - Made coupon total displayed in cart more consistent. #19166 +* Tweak - Remove forced CSS line-heights to improve text input displays across different browsers. #19174 +* Tweak - When loading default attributes/variation, if there is no longer a match, reset the form and hide the notice #19190 +* Tweak - Removed admin product type column from core and made it into a free feature plugin. #19192 +* Tweak - Use `woocommerce-no-js` class to hide JavaScript-only forms and content. #19199 +* Tweak - Activate plugins during installation process even if directory doesn't match slug. #19200 +* Tweak - Allow category and attribute ids in the `products` shortcode instead of only slugs. #19204 +* Tweak - Invalidate cart items when important props like product type are updated. #19255 +* Tweak - Don't use mysql functions directly on system status page to prevent errors if they are disabled. #19281 +* Tweak - Replaces `have_posts` with `woocommerce_product_loop` which looks to see if there are products, or if the loop is going to be showing something else. #19288 +* Tweak - Delete widget options and order notes on uninstall. #19371 +* Tweak - Add unique names to all nonces in template fields and forms. #19387 +* Tweak - Enable using the tab key to select elements in selectWoo dropdowns. #19416 +* Tweak - Added autocomplete attributes to form elements for better autocomplete support. #19426 +* Tweak - Removed PayPal line item limit and ensured URLs are shorter than maximum length. #19493 +* Tweak - Disable Gutenberg editor on products posts. #19543 +* Tweak - Improvements around UI and wording of store setup step in setup wizard, a revamped extras step, and other improvements. +* Tweak - Only push images to lightbox if an image is found. #19568 +* Tweak - Added and improved notices around old PHP versions and disabled geolocation on PHP 5.4 or lower. #19573 +* Tweak - The `manage_stock` field in the product API can return a `mixed` type instead of `boolean` for variations. #19598 +* Tweak - Link product import/export to WordPress import/export capabilities. #19602 +* Tweak - Use ` ` to separate asterisks in required fields to prevent awkward line breaks. #19610 +* Tweak - Load meta box input values using CRUD and edit context. #19670 +* Tweak - Scroll to notices on cart/checkout for better mobile visibility. #19699 +* Tweak - Add filter to coupon URL on "Edit order" screen. #19777 +* Tweak - Throw error if order can't be loaded on checkout. #19802 +* Tweak - Remove deprecated freegeoip service from geolocation. #19841 +* Tweak - Allow arrays of query vars in wc_get_orders and wc_get_products. #19848 +* Tweak - Invalidate fragment cache on theme switch. +* Tweak - Include select tags when saving payment details temporarily in checkout.js. #19854 +* Tweak - Update - Include pending products in export. #19928 +* Tweak - Deprecate woocommerce_ajax_added_order_items action in favor of more useful action. #19933 +* Tweak - Enable touch-to-zoom on touch devices to make photoswipe more easily accessible. #20002 +* Tweak - Wizard: List out all plugins to be installed upon proceeding to the next step, with a highlight on hover indicating relevant settings. #19952 +* Tweak - Hide/show password strength meter instead of removing/inserting password strength meter. #20006 +* Tweak - Added support for HTTP_RANGE requests (used by iOS devices) to Force download method. #19984 +* Tweak - Replaced protocol-relative URLs for thumbnails in the cart and mini-cart with protocol-specific URLs to prevent problems with URLs that include port section. #19934 +* Tweak - In CSV exports, wrap cell in ' rather than just prepending to escape values. #20041 +* Tweak - Add JS listeners for reloading/reinitializing order items in edit-order page. #20082 +* Fix - Properly set orderby and order when calling WC_Customer_Download_Data_Store::get_downloads(). #1862 +* Fix - Set maxlength for order item meta key to avoid values disappearing if too long. #18918 +* Fix - Remove hardcoded /wp-content check for downloads. #18961 +* Fix - Made get_on_sale_products respect the setting to hide outofstock products. #18984 +* Fix - Prevent shortcode [product_page] redirecting to the actual product's page after add to cart. #19043 +* Fix - Make the "main term" logic match for both the breadcrumb and product categories widget. #19044 +* Fix - Check parent status too when seeing if variation is purchasable. #19045 +* Fix - Fix uppercasing of accented characters. #19086 +* Fix - Do not allow updating parent ID from variations after created. #19097 +* Fix - Ensure coupon amount is not empty to prevent non-numeric value errors. #19098 +* Fix - Ensure shop archive works correctly when `paged=1` is in the URL. #19104 +* Fix - Ensure orders created with `woocommerce_adjust_non_base_location_prices` filter active have the same cost on frontend and admin. #19109 +* Fix - Handling in the CLI to prevent `Resource does not exist` errors when using commands of a certain format. #19123 +* Fix - Use subtotal when calculating discounts in admin/orders to ensure prices are the same as on the frontend. #19159 +* Fix - Use `kses` to process download names to prevent escaped HTML displaying in emails. +* Fix - Remove translation from Thailand state file to prevent PayPal errors around unsupported characters. #19219 +* Fix - Fix auto-select variation URLs with special characters in them. #19283 +* Fix - Introduced `wc_round_discount` and improved consistency of discount rounding. #19291 +* Fix - Only add schema for ratings to structured data when ratings are enabled. #19310 +* Fix - Prevent default state applying unless the country was also unset in JS state/country inputs. #19338 +* Fix - Escape quantity labels correctly to prevent broken html. #19375 +* Fix - Delete orphaned variations after product import. #19378 +* Fix - Ensure API credentials exist before defining PayPal refund support. #19380 +* Fix - Force word-wrapping in the log viewer to prevent layout-breaking long lines. #19503 +* Fix - Removes permission checks that were preventing webhooks from displaying properly when no post object existed. #19508 +* Fix - Empty cart after completing PayPal payment. #19509 +* Fix - Strip tags on aria-labels in Add to Cart template to prevent broken HTML. #19522 +* Fix - Update post_modified date when saving products and variations but no other product data. #19595 +* Fix - Clear comment count transient when cleaning product transients to prevent incorrect comment count displays. #19664 +* Fix - Load gateways before order is saved/email is triggered to ensure all information gets sent/processed. #19667 +* Fix - Clear shipping transient when saving shipping method on zones screen. #19668 +* Fix - Handle escape characters for fputcsv to work around PHP standards issues. #19678 +* Fix - Cast post IDs to integers in admin meta boxes. #19710 +* Fix - Fix CSV unescaping of negative numbers in download expiry/limit columns. #19732 +* Fix - Don't load unsupported theme functionality if shop page ID is -1. #19822 +* Fix - Select and display "Downloadable" option in product admin filter when selected. #19876 +* Fix - Add sort handle column when adding new tags. #19875 +* Fix - More thorough CSV importer cleanup. #19877 +* Fix - Fix gallery switching when image is the same #19878 +* Fix - Ensure coupon amount is always returns as a float value #19889 +* Fix - No update available message after activating subscription that has a valid update. #19831 +* Fix - Include scheduled products in CSV export. #19907 +* Fix - Generator tag actions should be filters. #19946 +* Fix - WC API should not try to create a product image when creating a product variation if an empty image is passed. #19971 +* Fix - Force settings API settings to autoload by default. #19998 +* Fix - Cart html5 validation events when using keyboard. #20001 +* Fix - Don't show stock status fields in external product quick-edit. #20005 +* Fix - Prevent an infinite loop if 2 grouped products are linked. #20020 +* Fix - Switch stock_status when manage stock gets changed to prevent being out of stock if stock quantity is > 0. #20021 +* Fix - When duplicating variation, set the date to null. #20083 +* Fix - Fix rounding of line items for orders to match cart. #20086 +* Fix - Remove hardcoded border in email template. #20090 +* Fix - Prevent autofocus on checkout. #20123 +* Fix - Recalc taxes if address changes in API. #20137 +* Dev - Made wc_query_string_form_fields handle strings. #20162 +* Dev - Added refunded_payment prop to orders for determining if payment was refunded via API. #18196 +* Dev - Added extra params to `woocommerce_order_get_downloadable_items`. #18408 +* Dev - Store shipping method ID and instance ID in separate fields instead of both in one serialized field. #18483 +* Dev - Add `woocommerce_rest_insert_system_status_tool` hook that fires after executing a REST system status tool. #18505 +* Dev - Gallery meta box is now powered by CRUD. #18511 +* Dev - Refactor woocommerce_wp_select so it could be used for a multiselect. #18536 +* Dev - Added ability to declare sanitize_callback in settings API. #18554 +* Dev - Added support for additional HTML5 input types for settings/checkout forms. #18594 +* Dev - Made 'woocommerce_email_downloads_column_' hook format aware. #18600 +* Dev - Add missing `woocommerce_update_options__` actions for settings pages that override save method. #18609 +* Dev - Allow default value for single_select_country and multi_select_countries. #18754 #18756 +* Dev - Added `grouped_form` class to grouped product `form` element. #18786 +* Dev - Mini cart item link now respects value of $product_permalink. #18979 +* Dev - Added `woocommerce_coupon_get_items_to_validate` filter to enable excluding products from coupon validation. #19002 +* Dev - Added `woocommerce_persistent_cart_enabled` filter. #19027 +* Dev - Added `woocommerce_admin_order_item_coupon_url` filter. #19777 +* Dev - Replaced calls to `exit` with `wp_die` in the ajax methods to enable unit testing of those methods. +* Dev - Introduce `woocommerce_coupon_custom_discounts_array` filter to allow post processing on custom coupons. #19148 +* Dev - Move jQuery UI styles into WooCommerce assets folder and load them from there. #19173 +* Dev - Added `woocommerce_coupon_validate_expiry_date` filter to enable modifying the coupon expiry date check. #19228 +* Dev - Added `woocommerce_shipping_calculator_enable_state` filter to enable disabling state section in shipping calculator. #19241 +* Dev - Added `woocommerce_bacs_process_payment_order_status` filter allowing plugins to change the order status to the BACS gateway. #19311 +* Dev - Added `woocommerce_coupon_sort` filter to allow plugins to override the default coupon apply order. #19339 +* Dev - Added `woocommerce_before_output_product_categories` and `woocommerce_after_output_product_categories` filters. #19363 +* Dev - Added general `woocommerce_form_field` filter to make it easier to filter all of the form fields. #19388 +* Dev - Added `woocommerce_install_get_tables` filter to enable plugins to register new, WooCommerce-specific tables. $19436 +* Dev - Use `get_variation_price` method in structured data to grab min/max so filters are ran. #19527 +* Dev - Added `woocommerce_helper_suppress_connect_notice` filter to enable suppressing the admin WordPress.com connection message. #19599 +* Dev - Moved all photoswipe styles to `photoswipe.css` to make it easy to dequeue all the photoswipe styles. #19673 +* Dev - Slash meta values before updating values in the data stores. #19675 +* Dev - New wc_selected method to handle array key conversion to int. #19705 +* Performance - Optimized saving of orders. Adds a transient for needs_processing, and only saves changes when saving order items. #18538 +* Performance - Refactored the SQL query for `WC_Customer_Download_Data_Store::get_downloads()` to fetch available downloads faster. #18559 +* Performance - Split the layered nav counts into multiple transient records by taxonomy and added a filter to allow bypassing caching. #19225 +* Performance - Removed duplicate `SET SESSION SQL_BIG_SELECTS=1` queries. #19502 +* Performance - Avoid storing coupon `_used_by` data to prevent database bloat. #19669 +* Performance - Introduced new wc_get_product_class() and wc_product_class() functions. #19639 +* Performance - Series of tweaks aimed at reducing the number of queries performed #19918 +* Template - Update cart coupon button from input to button type. #19059 +* Template - Added `woocommerce-form-register` class to registration form. #19486 +* Template - Added escaping to publish date. #19530 +* Template - Added a template file for recent product reviews. #19711 +* Template - Made add to cart templates more consistent between product types. #19666 +* Localization - Switched Georgian Lari symbol to new UTF symbol. #19603 +* Localization - Use ISO county codes for Irish states. #19658 +* Localization - Use ISO county codes for BD states. #19744 +* Localization - LR-Liberia states. #19709 +* Localization - Update ZA tax rate. #19909 +* Localization - Various spelling, grammar fixes, and phrasing improvements. +* Localization - Fix missing Bahrain country code. #20061 + +[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt). + +== Upgrade Notice == + += 3.0 = +3.0 is a major update. Make a full site backup, update your theme and extensions, and [review update best practices](https://docs.woocommerce.com/document/how-to-update-your-site) before upgrading. diff --git a/backend/wp-content/plugins/woocommerce/sample-data/sample_products.csv b/backend/wp-content/plugins/woocommerce/sample-data/sample_products.csv new file mode 100644 index 0000000..dfb25e8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/sample-data/sample_products.csv @@ -0,0 +1,26 @@ +ID,Type,SKU,Name,Published,"Is featured?","Visibility in catalog","Short description",Description,"Date sale price starts","Date sale price ends","Tax status","Tax class","In stock?",Stock,"Backorders allowed?","Sold individually?","Weight (lbs)","Length (in)","Width (in)","Height (in)","Allow customer reviews?","Purchase note","Sale price","Regular price",Categories,Tags,"Shipping class",Images,"Download limit","Download expiry days",Parent,"Grouped products",Upsells,Cross-sells,"External URL","Button text",Position,"Attribute 1 name","Attribute 1 value(s)","Attribute 1 visible","Attribute 1 global","Attribute 2 name","Attribute 2 value(s)","Attribute 2 visible","Attribute 2 global","Meta: _wpcom_is_markdown","Download 1 name","Download 1 URL","Download 2 name","Download 2 URL" +44,variable,woo-vneck-tee,"V-Neck T-Shirt",1,1,visible,"This is a variable product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.5,24,1,2,1,,,,"Clothing > Tshirts",,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vneck-tee-2.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-green-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-blue-1.jpg",,,,,,,,,0,Color,"Blue, Green, Red",1,1,Size,"Large, Medium, Small",1,1,1,,,, +45,variable,woo-hoodie,Hoodie,1,0,visible,"This is a variable product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,1.5,10,8,3,1,,,,"Clothing > Hoodies",,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-2.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-blue-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-green-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg",,,,,,,,,0,Color,"Blue, Green, Red",1,1,Logo,"Yes, No",1,0,1,,,, +46,simple,woo-hoodie-with-logo,"Hoodie with Logo",1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,2,10,6,3,1,,,45,"Clothing > Hoodies",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg,,,,,,,,,0,Color,Blue,1,1,,,,,1,,,, +47,simple,woo-tshirt,T-Shirt,1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.8,8,6,1,1,,,18,"Clothing > Tshirts",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/tshirt-2.jpg,,,,,,,,,0,Color,Gray,1,1,,,,,1,,,, +48,simple,woo-beanie,Beanie,1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.2,4,5,.5,1,,18,20,"Clothing > Accessories",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-2.jpg,,,,,,,,,0,Color,Red,1,1,,,,,1,,,, +58,simple,woo-belt,Belt,1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,1.2,12,2,1.5,1,,55,65,"Clothing > Accessories",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/belt-2.jpg,,,,,,,,,0,,,,,,,,,1,,,, +60,simple,woo-cap,Cap,1,1,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,0.6,8,6.5,4,1,,16,18,"Clothing > Accessories",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/cap-2.jpg,,,,,,,,,0,Color,Yellow,1,1,,,,,1,,,, +62,simple,woo-sunglasses,Sunglasses,1,1,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.2,4,1.4,1,1,,,90,"Clothing > Accessories",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/sunglasses-2.jpg,,,,,,,,,0,,,,,,,,,1,,,, +64,simple,woo-hoodie-with-pocket,"Hoodie with Pocket",1,1,hidden,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,3,10,8,2,1,,35,45,"Clothing > Hoodies",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-pocket-2.jpg,,,,,,,,,0,Color,Gray,1,1,,,,,1,,,, +66,simple,woo-hoodie-with-zipper,"Hoodie with Zipper",1,1,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,2,8,6,2,1,,,45,"Clothing > Hoodies",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-zipper-2.jpg,,,,,,,,,0,,,,,,,,,1,,,, +68,simple,woo-long-sleeve-tee,"Long Sleeve Tee",1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,1,7,5,1,1,,,25,"Clothing > Tshirts",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/long-sleeve-tee-2.jpg,,,,,,,,,0,Color,Green,1,1,,,,,1,,,, +70,simple,woo-polo,Polo,1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.8,6,5,1,1,,,20,"Clothing > Tshirts",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/polo-2.jpg,,,,,,,,,0,Color,Blue,1,1,,,,,1,,,, +73,"simple, downloadable, virtual",woo-album,Album,1,0,visible,"This is a simple, virtual product.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,1,,,15,Music,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/album-1.jpg,1,1,,,,,,,0,,,,,,,,,1,"Single 1",https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/single.jpg,"Single 2",https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/album.jpg +75,"simple, downloadable, virtual",woo-single,Single,1,0,visible,"This is a simple, virtual product.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,1,,2,3,Music,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/single-1.jpg,1,1,,,,,,,0,,,,,,,,,1,Single,https://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2017/08/single.jpg,, +76,variation,woo-vneck-tee-red,"V-Neck T-Shirt - Red",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,20,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vneck-tee-2.jpg,,,woo-vneck-tee,,,,,,0,Color,Red,,1,Size,,,1,,,,, +77,variation,woo-vneck-tee-green,"V-Neck T-Shirt - Green",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,20,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-green-1.jpg,,,woo-vneck-tee,,,,,,0,Color,Green,,1,Size,,,1,,,,, +78,variation,woo-vneck-tee-blue,"V-Neck T-Shirt - Blue",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,15,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/vnech-tee-blue-1.jpg,,,woo-vneck-tee,,,,,,0,Color,Blue,,1,Size,,,1,,,,, +79,variation,woo-hoodie-red,"Hoodie - Red, No",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,42,45,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-2.jpg,,,woo-hoodie,,,,,,1,Color,Red,,1,Logo,No,,0,,,,, +80,variation,woo-hoodie-green,"Hoodie - Green, No",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,45,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-green-1.jpg,,,woo-hoodie,,,,,,2,Color,Green,,1,Logo,No,,0,,,,, +81,variation,woo-hoodie-blue,"Hoodie - Blue, No",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,45,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-blue-1.jpg,,,woo-hoodie,,,,,,3,Color,Blue,,1,Logo,No,,0,,,,, +83,simple,Woo-tshirt-logo,"T-Shirt with Logo",1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.5,10,12,.5,1,,,18,"Clothing > Tshirts",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/t-shirt-with-logo-1.jpg,,,,,,,,,0,Color,Gray,1,1,,,,,1,,,, +85,simple,Woo-beanie-logo,"Beanie with Logo",1,0,visible,"This is a simple product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,.2,6,4,1,1,,18,20,"Clothing > Accessories",,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-with-logo-1.jpg,,,,,,,,,0,Color,Red,1,1,,,,,1,,,, +87,grouped,logo-collection,"Logo Collection",1,0,visible,"This is a grouped product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,,,,,1,,,,Clothing,,,"https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/beanie-with-logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/t-shirt-with-logo-1.jpg, https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg",,,,"woo-hoodie-with-logo, woo-tshirt, woo-beanie",,,,,0,,,,,,,,,1,,,, +89,external,wp-pennant,"WordPress Pennant",1,0,visible,"This is an external product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",,,taxable,,1,,0,0,,,,,1,,,11.05,Decor,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/pennant-1.jpg,,,,,,,https://mercantile.wordpress.org/product/wordpress-pennant/,"Buy on the WordPress swag store!",0,,,,,,,,,1,,,, +90,variation,woo-hoodie-blue-logo,"Hoodie - Blue, Yes",1,0,visible,,"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.",,,taxable,,1,,0,0,,,,,0,,,45,,,,https://woocommercecore.mystagingwebsite.com/wp-content/uploads/2017/12/hoodie-with-logo-2.jpg,,,woo-hoodie,,,,,,0,Color,Blue,,1,Logo,Yes,,0,,,,, diff --git a/backend/wp-content/plugins/woocommerce/sample-data/sample_products.xml b/backend/wp-content/plugins/woocommerce/sample-data/sample_products.xml new file mode 100644 index 0000000..2781b92 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/sample-data/sample_products.xml @@ -0,0 +1,3164 @@ + + + + + + + + + + + + + + + + + + + + + + + WooCommerce Videos + https://woocommercecore.mystagingwebsite.com + Just another WordPress site + Thu, 11 Jan 2018 16:36:21 +0000 + en-US + 1.2 + https://woocommercecore.mystagingwebsite.com + https://woocommercecore.mystagingwebsite.com + + 1 + + + +118514079 + + V-Neck T-Shirt + https://woocommercecore.mystagingwebsite.com/product/v-neck-t-shirt/ + Fri, 15 Dec 2017 03:56:33 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=import-placeholder-for-woo-vneck-tee + + + + 44 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hoodie + https://woocommercecore.mystagingwebsite.com/product/hoodie/ + Fri, 15 Dec 2017 03:56:34 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=import-placeholder-for-woo-hoodie + + + + 45 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hoodie with Logo + https://woocommercecore.mystagingwebsite.com/product/hoodie-with-logo/ + Fri, 15 Dec 2017 03:56:34 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=import-placeholder-for-woo-hoodie-with-logo + + + + 46 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + T-Shirt + https://woocommercecore.mystagingwebsite.com/product/t-shirt/ + Fri, 15 Dec 2017 03:56:34 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=import-placeholder-for-woo-tshirt + + + + 47 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Beanie + https://woocommercecore.mystagingwebsite.com/product/beanie/ + Fri, 15 Dec 2017 03:56:34 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=import-placeholder-for-woo-beanie + + + + 48 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Belt + https://woocommercecore.mystagingwebsite.com/product/belt/ + Fri, 15 Dec 2017 03:56:41 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=belt + + + + 58 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cap + https://woocommercecore.mystagingwebsite.com/product/cap/ + Fri, 15 Dec 2017 03:56:42 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=cap + + + + 60 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sunglasses + https://woocommercecore.mystagingwebsite.com/product/sunglasses/ + Fri, 15 Dec 2017 03:56:43 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=sunglasses + + + + 62 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hoodie with Pocket + https://woocommercecore.mystagingwebsite.com/product/hoodie-with-pocket/ + Fri, 15 Dec 2017 03:56:45 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=hoodie-with-pocket + + + + 64 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hoodie with Zipper + https://woocommercecore.mystagingwebsite.com/product/hoodie-with-zipper/ + Fri, 15 Dec 2017 03:56:45 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=hoodie-with-zipper + + + + 66 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Long Sleeve Tee + https://woocommercecore.mystagingwebsite.com/product/long-sleeve-tee/ + Fri, 15 Dec 2017 03:56:46 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=long-sleeve-tee + + + + 68 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Polo + https://woocommercecore.mystagingwebsite.com/product/polo/ + Fri, 15 Dec 2017 03:56:47 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=polo + + + + 70 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Album + https://woocommercecore.mystagingwebsite.com/product/album/ + Fri, 15 Dec 2017 03:56:49 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=album + + + + 73 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Single + https://woocommercecore.mystagingwebsite.com/product/single/ + Fri, 15 Dec 2017 03:56:49 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=single + + + + 75 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 35 + + + + + + + + + + 0 + 7 + + + + + + + + + + + + + + + + + + + + + + + + T-Shirt with Logo + https://woocommercecore.mystagingwebsite.com/product/t-shirt-with-logo/ + Fri, 15 Dec 2017 03:56:52 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=t-shirt-with-logo + + + + 83 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Beanie with Logo + https://woocommercecore.mystagingwebsite.com/product/beanie-with-logo/ + Fri, 15 Dec 2017 03:56:53 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=beanie-with-logo + + + + 85 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Logo Collection + https://woocommercecore.mystagingwebsite.com/product/logo-collection/ + Fri, 15 Dec 2017 03:56:54 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=logo-collection + + + + 87 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WordPress Pennant + https://woocommercecore.mystagingwebsite.com/product/wordpress-pennant/ + Fri, 15 Dec 2017 03:57:20 +0000 + + https://woocommercecore.mystagingwebsite.com/?product=wordpress-pennant + + + + 89 + + + + + + + 0 + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/sample-data/sample_tax_rates.csv b/backend/wp-content/plugins/woocommerce/sample-data/sample_tax_rates.csv new file mode 100644 index 0000000..02038b5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/sample-data/sample_tax_rates.csv @@ -0,0 +1,6 @@ +Country Code,State Code,ZIP/Postcode,City,Rate %,Tax Name,Priority,Compound,Shipping,Tax Class +GB,*,*,*,20.0000,VAT,1,1,1, +GB,*,*,*,5.0000,VAT,1,1,1,reduced-rate +GB,*,*,*,0.0000,VAT,1,1,1,zero-rate +US,*,*,*,10.0000,US,1,1,1, +US,AL,12345; 123456,*,2.0000,US AL,2,1,1, \ No newline at end of file diff --git a/backend/wp-content/plugins/woocommerce/templates/archive-product.php b/backend/wp-content/plugins/woocommerce/templates/archive-product.php new file mode 100644 index 0000000..41b6c89 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/archive-product.php @@ -0,0 +1,107 @@ + +
      + +

      + + + +
      + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/auth/form-grant-access.php b/backend/wp-content/plugins/woocommerce/templates/auth/form-grant-access.php new file mode 100644 index 0000000..1a58595 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/auth/form-grant-access.php @@ -0,0 +1,47 @@ + + + + +

      + + + +

      ' . esc_html( $app_name ) . '', '' . esc_html( $scope ) . '' ); ?>

      + +
        + +
      • + +
      + +
      + ID, 70 ); ?> +

      display_name ) ); ?> +

      + +

      + + +

      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/auth/form-login.php b/backend/wp-content/plugins/woocommerce/templates/auth/form-login.php new file mode 100644 index 0000000..8aa5330 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/auth/form-login.php @@ -0,0 +1,54 @@ + + +

      + +

      + + + +

      + cancel and return to %1$s', 'woocommerce' ), esc_html( wc_clean( $app_name ) ), esc_url( $return_url ) ) ); + ?> +

      + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/auth/header.php b/backend/wp-content/plugins/woocommerce/templates/auth/header.php new file mode 100644 index 0000000..fdbc648 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/auth/header.php @@ -0,0 +1,35 @@ + +> + + + + + <?php _e( 'Application authentication request', 'woocommerce' ); ?> + + + + +

      WooCommerce

      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cart-empty.php b/backend/wp-content/plugins/woocommerce/templates/cart/cart-empty.php new file mode 100644 index 0000000..d0a3791 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cart-empty.php @@ -0,0 +1,36 @@ + 0 ) : ?> +

      + + + +

      + diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cart-item-data.php b/backend/wp-content/plugins/woocommerce/templates/cart/cart-item-data.php new file mode 100644 index 0000000..98f3296 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cart-item-data.php @@ -0,0 +1,27 @@ + +
      + +
      :
      +
      + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cart-shipping.php b/backend/wp-content/plugins/woocommerce/templates/cart/cart-shipping.php new file mode 100644 index 0000000..c3a8844 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cart-shipping.php @@ -0,0 +1,67 @@ + + + + + +
        + +
      • + + ', + $index, sanitize_title( $method->id ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ), wc_cart_totals_shipping_method_label( $method ) ); + + do_action( 'woocommerce_after_shipping_rate', $method, $index ); + ?> +
      • + +
      + + ', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) ); + do_action( 'woocommerce_after_shipping_rate', $method, $index ); + ?> + customer->has_calculated_shipping() ) : ?> + + + + + + + ' . esc_html( $package_details ) . '

      '; ?> + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cart-totals.php b/backend/wp-content/plugins/woocommerce/templates/cart/cart-totals.php new file mode 100644 index 0000000..517c803 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cart-totals.php @@ -0,0 +1,106 @@ + +
      + + + +

      + + + + + + + + + cart->get_coupons() as $code => $coupon ) : ?> + + + + + + + cart->needs_shipping() && WC()->cart->show_shipping() ) : ?> + + + + + + + + cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) : ?> + + + + + + + + + cart->get_fees() as $fee ) : ?> + + + + + + + cart->display_prices_including_tax() ) : + $taxable_address = WC()->customer->get_taxable_address(); + $estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() + ? sprintf( ' ' . __( '(estimated for %s)', 'woocommerce' ) . '', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] ) + : ''; + + if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?> + cart->get_tax_totals() as $code => $tax ) : ?> + + + + + + + + + + + + + + + + + + + + + + +
      name ); ?>
      label ) . $estimated_text; ?>formatted_amount ); ?>
      countries->tax_or_vat() ) . $estimated_text; ?>
      + +
      + +
      + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cart.php b/backend/wp-content/plugins/woocommerce/templates/cart/cart.php new file mode 100644 index 0000000..1d5cb22 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cart.php @@ -0,0 +1,169 @@ + + +
      + + + + + + + + + + + + + + + + + cart->get_cart() as $cart_item_key => $cart_item ) { + $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); + $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); + + if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { + $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
        
      + ×', + esc_url( wc_get_cart_remove_url( $cart_item_key ) ), + __( 'Remove this item', 'woocommerce' ), + esc_attr( $product_id ), + esc_attr( $_product->get_sku() ) + ), $cart_item_key ); + ?> + + get_image(), $cart_item, $cart_item_key ); + + if ( ! $product_permalink ) { + echo wp_kses_post( $thumbnail ); + } else { + printf( '%s', esc_url( $product_permalink ), wp_kses_post( $thumbnail ) ); + } + ?> + + get_name(), $cart_item, $cart_item_key ) . ' ' ); + } else { + echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '%s', esc_url( $product_permalink ), $_product->get_name() ), $cart_item, $cart_item_key ) ); + } + + do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key ); + + // Meta data. + echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok. + + // Backorder notification. + if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { + echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '

      ' . esc_html__( 'Available on backorder', 'woocommerce' ) . '

      ' ) ); + } + ?> +
      + cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. + ?> + + is_sold_individually() ) { + $product_quantity = sprintf( '1 ', $cart_item_key ); + } else { + $product_quantity = woocommerce_quantity_input( array( + 'input_name' => "cart[{$cart_item_key}][qty]", + 'input_value' => $cart_item['quantity'], + 'max_value' => $_product->get_max_purchase_quantity(), + 'min_value' => '0', + 'product_name' => $_product->get_name(), + ), $_product, false ); + } + + echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok. + ?> + + cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. + ?> +
      + + +
      + + +
      + + + + + + + +
      + +
      + +
      + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/cross-sells.php b/backend/wp-content/plugins/woocommerce/templates/cart/cross-sells.php new file mode 100644 index 0000000..8a0376a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/cross-sells.php @@ -0,0 +1,48 @@ + + +
      + +

      + + + + + + get_id() ); + + setup_postdata( $GLOBALS['post'] =& $post_object ); + + wc_get_template_part( 'content', 'product' ); ?> + + + + + +
      + + + +cart->is_empty() ) : ?> + +
        + cart->get_cart() as $cart_item_key => $cart_item ) { + $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); + $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); + + if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { + $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ); + $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); + $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); + $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); + ?> +
      • + ×', + esc_url( wc_get_cart_remove_url( $cart_item_key ) ), + __( 'Remove this item', 'woocommerce' ), + esc_attr( $product_id ), + esc_attr( $cart_item_key ), + esc_attr( $_product->get_sku() ) + ), $cart_item_key ); + ?> + + + + + + + + + + ' . sprintf( '%s × %s', $cart_item['quantity'], $product_price ) . '', $cart_item, $cart_item_key ); ?> +
      • + +
      + +

      : cart->get_cart_subtotal(); ?>

      + + + +

      + + + +

      + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/proceed-to-checkout-button.php b/backend/wp-content/plugins/woocommerce/templates/cart/proceed-to-checkout-button.php new file mode 100644 index 0000000..3306991 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/proceed-to-checkout-button.php @@ -0,0 +1,28 @@ + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/cart/shipping-calculator.php b/backend/wp-content/plugins/woocommerce/templates/cart/shipping-calculator.php new file mode 100644 index 0000000..87635a9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/cart/shipping-calculator.php @@ -0,0 +1,102 @@ +cart->needs_shipping() ) { + return; +} + +wp_enqueue_script( 'wc-country-select' ); + +do_action( 'woocommerce_before_shipping_calculator' ); ?> + +
      + +

      + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/cart-errors.php b/backend/wp-content/plugins/woocommerce/templates/checkout/cart-errors.php new file mode 100644 index 0000000..a50eef6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/cart-errors.php @@ -0,0 +1,31 @@ + + + + +

      + + + +

      diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-billing.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-billing.php new file mode 100644 index 0000000..1f5cbfc --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-billing.php @@ -0,0 +1,82 @@ + +
      + cart->needs_shipping() ) : ?> + +

      + + + +

      + + + + + +
      + get_checkout_fields( 'billing' ); + + foreach ( $fields as $key => $field ) { + if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) { + $field['country'] = $checkout->get_value( $field['country_field'] ); + } + woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); + } + ?> +
      + + +
      + +is_registration_enabled() ) : ?> + + diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-checkout.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-checkout.php new file mode 100644 index 0000000..1249303 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-checkout.php @@ -0,0 +1,67 @@ +is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) { + echo apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ); + return; +} + +?> + +
      + + get_checkout_fields() ) : ?> + + + +
      +
      + +
      + +
      + +
      +
      + + + + + +

      + + + +
      + +
      + + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-coupon.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-coupon.php new file mode 100644 index 0000000..cd16ee3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-coupon.php @@ -0,0 +1,42 @@ +cart->applied_coupons ) ) { // @codingStandardsIgnoreLine. + return; +} + +?> +
      + ' . __( 'Click here to enter your code', 'woocommerce' ) . '' ), 'notice' ); ?> +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-login.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-login.php new file mode 100644 index 0000000..1ed162b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-login.php @@ -0,0 +1,36 @@ + + + __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.', 'woocommerce' ), + 'redirect' => wc_get_page_permalink( 'checkout' ), + 'hidden' => true, + ) +); diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-pay.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-pay.php new file mode 100644 index 0000000..112dc5d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-pay.php @@ -0,0 +1,98 @@ +get_order_item_totals(); +?> +
      + + + + + + + + + + + get_items() ) > 0 ) : ?> + get_items() as $item_id => $item ) : ?> + + + + + + + + + + + + + + + + + + + +
      + get_name() ), $item, false ); // @codingStandardsIgnoreLine + + do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, false ); + + wc_display_item_meta( $item ); + + do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, false ); + ?> + ' . sprintf( '× %s', esc_html( $item->get_quantity() ) ) . '', $item ); ?>get_formatted_line_subtotal( $item ); ?>
      + +
      + needs_payment() ) : ?> +
        + $gateway ) ); + } + } else { + echo '
      • ' . apply_filters( 'woocommerce_no_available_payment_methods_message', __( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) ) . '
      • '; // @codingStandardsIgnoreLine + } + ?> +
      + +
      + + + + + + + ' . esc_html( $order_button_text ) . '' ); // @codingStandardsIgnoreLine ?> + + + + +
      +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/form-shipping.php b/backend/wp-content/plugins/woocommerce/templates/checkout/form-shipping.php new file mode 100644 index 0000000..e5867f6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/form-shipping.php @@ -0,0 +1,76 @@ + +
      + cart->needs_shipping_address() ) : ?> + +

      + +

      + +
      + + + +
      + get_checkout_fields( 'shipping' ); + + foreach ( $fields as $key => $field ) { + if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) { + $field['country'] = $checkout->get_value( $field['country_field'] ); + } + woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); + } + ?> +
      + + + +
      + + +
      +
      + + + + + cart->needs_shipping() || wc_ship_to_billing_address_only() ) : ?> + +

      + + + +
      + get_checkout_fields( 'order' ) as $key => $field ) : ?> + get_value( $key ) ); ?> + +
      + + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/order-receipt.php b/backend/wp-content/plugins/woocommerce/templates/checkout/order-receipt.php new file mode 100644 index 0000000..e7d351c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/order-receipt.php @@ -0,0 +1,47 @@ + + +
        +
      • + + get_order_number() ); ?> +
      • +
      • + + get_date_created() ) ); ?> +
      • +
      • + + get_formatted_order_total() ); ?> +
      • + get_payment_method_title() ) : ?> +
      • + + get_payment_method_title() ); ?> +
      • + +
      + +get_payment_method(), $order->get_id() ); ?> + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/payment-method.php b/backend/wp-content/plugins/woocommerce/templates/checkout/payment-method.php new file mode 100644 index 0000000..dead8df --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/payment-method.php @@ -0,0 +1,34 @@ + +
    • + chosen, true ); ?> data-order_button_text="order_button_text ); ?>" /> + + + has_fields() || $gateway->get_description() ) : ?> +
      chosen ) : ?>style="display:none;"> + payment_fields(); ?> +
      + +
    • diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/payment.php b/backend/wp-content/plugins/woocommerce/templates/checkout/payment.php new file mode 100644 index 0000000..9d6c795 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/payment.php @@ -0,0 +1,58 @@ + +
      + cart->needs_payment() ) : ?> +
        + $gateway ) ); + } + } else { + echo '
      • ' . apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_billing_country() ? esc_html__( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) : esc_html__( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) ) . '
      • '; // @codingStandardsIgnoreLine + } + ?> +
      + +
      + + + + + + + ' . esc_html( $order_button_text ) . '' ); // @codingStandardsIgnoreLine ?> + + + + +
      +
      + + + + + + + + + + cart->get_cart() as $cart_item_key => $cart_item ) { + $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); + + if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) { + ?> + + + + + + + + + + + + + + cart->get_coupons() as $code => $coupon ) : ?> + + + + + + + cart->needs_shipping() && WC()->cart->show_shipping() ) : ?> + + + + + + + + + + cart->get_fees() as $fee ) : ?> + + + + + + + cart->display_prices_including_tax() ) : ?> + + cart->get_tax_totals() as $code => $tax ) : ?> + + + + + + + + + + + + + + + + + + + + + + + +
      + get_name(), $cart_item, $cart_item_key ) . ' '; ?> + ' . sprintf( '× %s', $cart_item['quantity'] ) . '', $cart_item, $cart_item_key ); ?> + + + cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?> +
      name ); ?>
      label ); ?>formatted_amount ); ?>
      countries->tax_or_vat() ); ?>
      diff --git a/backend/wp-content/plugins/woocommerce/templates/checkout/terms.php b/backend/wp-content/plugins/woocommerce/templates/checkout/terms.php new file mode 100644 index 0000000..744e9a9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/checkout/terms.php @@ -0,0 +1,40 @@ + +
      + + + +

      + + +

      + +
      + + +
      + + + + has_status( 'failed' ) ) : ?> + +

      + +

      + + + + +

      + + + +

      + +
        + +
      • + + get_order_number(); ?> +
      • + +
      • + + get_date_created() ); ?> +
      • + + get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?> + + + +
      • + + get_formatted_order_total(); ?> +
      • + + get_payment_method_title() ) : ?> +
      • + + get_payment_method_title() ); ?> +
      • + + +
      + + + + get_payment_method(), $order->get_id() ); ?> + get_id() ); ?> + + + +

      + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/content-product.php b/backend/wp-content/plugins/woocommerce/templates/content-product.php new file mode 100644 index 0000000..36ffa70 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/content-product.php @@ -0,0 +1,67 @@ +is_visible() ) { + return; +} +?> +
    • > + +
    • diff --git a/backend/wp-content/plugins/woocommerce/templates/content-product_cat.php b/backend/wp-content/plugins/woocommerce/templates/content-product_cat.php new file mode 100644 index 0000000..c4e3d9a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/content-product_cat.php @@ -0,0 +1,57 @@ + +
    • > + +
    • diff --git a/backend/wp-content/plugins/woocommerce/templates/content-single-product.php b/backend/wp-content/plugins/woocommerce/templates/content-single-product.php new file mode 100644 index 0000000..7dcb357 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/content-single-product.php @@ -0,0 +1,74 @@ + +
      > + + + +
      + +
      + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/content-widget-product.php b/backend/wp-content/plugins/woocommerce/templates/content-widget-product.php new file mode 100644 index 0000000..25b82c0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/content-widget-product.php @@ -0,0 +1,39 @@ + +
    • + + + + get_image(); ?> + get_name(); ?> + + + + get_average_rating() ); ?> + + + get_price_html(); ?> + + +
    • diff --git a/backend/wp-content/plugins/woocommerce/templates/content-widget-reviews.php b/backend/wp-content/plugins/woocommerce/templates/content-widget-reviews.php new file mode 100644 index 0000000..eff0769 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/content-widget-reviews.php @@ -0,0 +1,34 @@ + +
    • + + + + get_image(); ?> + get_name(); ?> + + + comment_ID, 'rating', true ) ) );?> + + comment_ID ) ); ?> + + +
    • diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/admin-cancelled-order.php b/backend/wp-content/plugins/woocommerce/templates/emails/admin-cancelled-order.php new file mode 100644 index 0000000..e50e172 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/admin-cancelled-order.php @@ -0,0 +1,54 @@ + + +

      get_order_number(), $order->get_formatted_billing_full_name() ); ?>

      + + + +

      get_order_number(), $order->get_formatted_billing_full_name() ); ?>

      + + + +

      get_formatted_billing_full_name() ); ?>

      + + + +

      + + + +has_status( 'pending' ) ) : ?> +

      + array( + 'href' => array(), + ), + ) + ), + esc_html( get_bloginfo( 'name', 'display' ) ), + '' . esc_html__( 'Pay for this order', 'woocommerce' ) . '' + ); + ?> +

      + + + + + + +

      ' . esc_html( $user_login ) . '' ); ?>

      + + + +

      ' . esc_html( $user_pass ) . '' ); ?>

      + + + +

      + + + +

      + +
      + +

      + + + +

      + + + +

      + + + +

      + + + + + +

      +

      +

      +

      +

      + + +

      +

      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-addresses.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-addresses.php new file mode 100644 index 0000000..2cce13d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-addresses.php @@ -0,0 +1,48 @@ + + + + needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?> + + + +
      +

      + +
      + get_formatted_billing_address() ) ? $address : __( 'N/A', 'woocommerce' ); ?> + get_billing_phone() ) : ?> +
      get_billing_phone() ); ?> + + get_billing_email() ) : ?> +

      get_billing_email() ); ?>

      + +
      +
      +

      + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-customer-details.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-customer-details.php new file mode 100644 index 0000000..acce35d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-customer-details.php @@ -0,0 +1,35 @@ + + +
      +

      +
        + +
      • :
      • + +
      +
      + diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-downloads.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-downloads.php new file mode 100644 index 0000000..a5fcff7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-downloads.php @@ -0,0 +1,68 @@ +

      + + + + + $column_name ) : ?> + + + + + + + + $column_name ) : ?> + + + + +
      + + + + + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-footer.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-footer.php new file mode 100644 index 0000000..5266ddd --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-footer.php @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-header.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-header.php new file mode 100644 index 0000000..78984b5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-header.php @@ -0,0 +1,66 @@ + + +> + + + <?php echo get_bloginfo( 'name', 'display' ); ?> + + ="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> +
      + + + "};for(h=d.mapColors(f),h.push({text:b.translate("No color"),color:"transparent"}),j='
      +
      + ' . get_bloginfo( 'name', 'display' ) . '

      '; + } + ?> +
      + + + + + + ":/^(UL|OL)$/.test(n.nodeName)&&(r="
    • "+a+"
    • "),(i=Au(t))&&t.schema.isValidChild(n.nodeName.toLowerCase(),i.toLowerCase())?(r=a,r=t.dom.createHTML(i,t.settings.forced_root_block_attrs,r)):r||(r='
      '),t.dom.setHTML(n,r),t.fire("SetContent",o)):("raw"!==o.format&&(r=jc({validate:t.validate},t.schema).serialize(t.parser.parse(r,{isRootContent:!0,insert:!0}))),o.content=Lt.trim(r),t.dom.setHTML(n,o.content),o.no_events||t.fire("SetContent",o)),o.content);var t,n,r,o,i,a})},UC=di.DOM,qC=function(e){return A.from(e).each(function(e){return e.destroy()})},VC=function(e){if(!e.removed){var t=e._selectionOverrides,n=e.editorUpload,r=e.getBody(),o=e.getElement();r&&e.save(),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&o&&UC.remove(o.nextSibling),!e.inline&&r&&(i=e,UC.setStyle(i.id,"display",i.orgDisplay)),qv(e),e.editorManager.remove(e),UC.remove(e.getContainer()),qC(t),qC(n),e.destroy()}var i},HC=function(e,t){var n,r,o,i=e.selection,a=e.dom;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),qC(i),qC(a)),(r=(n=e).formElement)&&(r._mceOldSubmit&&(r.submit=r._mceOldSubmit,r._mceOldSubmit=null),UC.unbind(r,"submit reset",n.formEventDelegate)),(o=e).contentAreaContainer=o.formElement=o.container=o.editorContainer=null,o.bodyElement=o.contentDocument=o.contentWindow=null,o.iframeElement=o.targetElm=null,o.selection&&(o.selection=o.selection.win=o.selection.dom=o.selection.dom.doc=null),e.destroyed=!0):e.remove())},jC=di.DOM,$C=Lt.extend,WC=Lt.each,KC=Lt.resolve,XC=ge.ie,YC=function(e,t,n){var r,o,i,a,u,s,c,l=this,f=l.documentBaseUrl=n.documentBaseURL,d=n.baseURI;r=l,o=e,i=f,a=n.defaultSettings,u=t,c={id:o,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:i,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",entity_encoding:"named",url_converter:(s=r).convertURL,url_converter_scope:s,ie7_compat:!0},t=sl(nl,c,a,u),l.settings=t,Ci.language=t.language||"en",Ci.languageLoad=t.language_load,Ci.baseURL=n.baseURL,l.id=e,l.setDirty(!1),l.plugins={},l.documentBaseURI=new PC(t.document_base_url,{base_uri:d}),l.baseURI=d,l.contentCSS=[],l.contentStyles=[],l.shortcuts=new tp(l),l.loadedCSS={},l.editorCommands=new Mm(l),l.suffix=n.suffix,l.editorManager=n,l.inline=t.inline,l.buttons={},l.menuItems={},t.cache_suffix&&(ge.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),!1===t.override_viewport&&(ge.overrideViewPort=!1),n.fire("SetupEditor",{editor:l}),l.execCallback("setup",l),l.$=en.overrideDefaults(function(){return{context:l.inline?l.getBody():l.getDoc(),element:l.getBody()}})};$C(YC.prototype={render:function(){AC(this)},focus:function(e){fp(this,e)},hasFocus:function(){return dp(this)},execCallback:function(e){for(var t=[],n=1;n=n.x&&o.x+o.w<=n.w+n.x&&o.y>=n.y&&o.y+o.h<=n.h+n.y)return r[i];return null},intersect:function(e,t){var n,r,o,i;return n=Rx(e.x,t.x),r=Rx(e.y,t.y),o=Ax(e.x+e.w,t.x+t.w),i=Ax(e.y+e.h,t.y+t.h),o-n<0||i-r<0?null:Dx(n,r,o-n,i-r)},clamp:function(e,t,n){var r,o,i,a,u,s,c,l,f,d;return u=e.x,s=e.y,c=e.x+e.w,l=e.y+e.h,f=t.x+t.w,d=t.y+t.h,r=Rx(0,t.x-u),o=Rx(0,t.y-s),i=Rx(0,c-f),a=Rx(0,l-d),u+=r,s+=o,n&&(c+=r,l+=o,u-=i,s-=a),Dx(u,s,(c-=i)-u,(l-=a)-s)},create:Dx,fromClientRect:function(e){return Dx(e.left,e.top,e.width,e.height)}},Px={},Lx={add:function(e,t){Px[e.toLowerCase()]=t},has:function(e){return!!Px[e.toLowerCase()]},get:function(e){var t=e.toLowerCase(),n=Px.hasOwnProperty(t)?Px[t]:null;if(null===n)throw new Error("Could not find module for type: "+e);return n},create:function(e,t){var n;if("string"==typeof e?(t=t||{}).type=e:e=(t=e).type,e=e.toLowerCase(),!(n=Px[e]))throw new Error("Could not find control by type: "+e);return(n=new n(t)).type=e,n}},Ix=Lt.each,Mx=Lt.extend,Fx=function(){};Fx.extend=Sx=function(n){var e,t,r,o=this.prototype,i=function(){var e,t,n;if(!kx&&(this.init&&this.init.apply(this,arguments),t=this.Mixins))for(e=t.length;e--;)(n=t[e]).init&&n.init.apply(this,arguments)},a=function(){return this},u=function(n,r){return function(){var e,t=this._super;return this._super=o[n],e=r.apply(this,arguments),this._super=t,e}};for(t in kx=!0,e=new this,kx=!1,n.Mixins&&(Ix(n.Mixins,function(e){for(var t in e)"init"!==t&&(n[t]=e[t])}),o.Mixins&&(n.Mixins=o.Mixins.concat(n.Mixins))),n.Methods&&Ix(n.Methods.split(","),function(e){n[e]=a}),n.Properties&&Ix(n.Properties.split(","),function(e){var t="_"+e;n[e]=function(e){return e!==undefined?(this[t]=e,this):this[t]}}),n.Statics&&Ix(n.Statics,function(e,t){i[t]=e}),n.Defaults&&o.Defaults&&(n.Defaults=Mx({},o.Defaults,n.Defaults)),n)"function"==typeof(r=n[t])&&o[t]?e[t]=u(t,r):e[t]=r;return i.prototype=e,(i.constructor=i).extend=Sx,i};var zx=Math.min,Ux=Math.max,qx=Math.round,Vx=function(e,n){var r,o,t,i;if(n=n||'"',null===e)return"null";if("string"==(t=typeof e))return o="\bb\tt\nn\ff\rr\"\"''\\\\",n+e.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=o.indexOf(t))+1?"\\"+o.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e)})+n;if("object"===t){if(e.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(e)){for(r=0,o="[";r'; + h += ' '; + + return h; +} + +function updateColor(img_id, form_element_id) { + document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value; +} + +function setBrowserDisabled(id, state) { + var img = document.getElementById(id); + var lnk = document.getElementById(id + "_link"); + + if (lnk) { + if (state) { + lnk.setAttribute("realhref", lnk.getAttribute("href")); + lnk.removeAttribute("href"); + tinyMCEPopup.dom.addClass(img, 'disabled'); + } else { + if (lnk.getAttribute("realhref")) { + lnk.setAttribute("href", lnk.getAttribute("realhref")); + } + + tinyMCEPopup.dom.removeClass(img, 'disabled'); + } + } +} + +function getBrowserHTML(id, target_form_element, type, prefix) { + var option = prefix + "_" + type + "_browser_callback", cb, html; + + cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback")); + + if (!cb) { + return ""; + } + + html = ""; + html += ''; + html += ' '; + + return html; +} + +function openBrowser(img_id, target_form_element, type, option) { + var img = document.getElementById(img_id); + + if (img.className != "mceButtonDisabled") { + tinyMCEPopup.openBrowser(target_form_element, type, option); + } +} + +function selectByValue(form_obj, field_name, value, add_custom, ignore_case) { + if (!form_obj || !form_obj.elements[field_name]) { + return; + } + + if (!value) { + value = ""; + } + + var sel = form_obj.elements[field_name]; + + var found = false; + for (var i = 0; i < sel.options.length; i++) { + var option = sel.options[i]; + + if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) { + option.selected = true; + found = true; + } else { + option.selected = false; + } + } + + if (!found && add_custom && value != '') { + var option = new Option(value, value); + option.selected = true; + sel.options[sel.options.length] = option; + sel.selectedIndex = sel.options.length - 1; + } + + return found; +} + +function getSelectValue(form_obj, field_name) { + var elm = form_obj.elements[field_name]; + + if (elm == null || elm.options == null || elm.selectedIndex === -1) { + return ""; + } + + return elm.options[elm.selectedIndex].value; +} + +function addSelectValue(form_obj, field_name, name, value) { + var s = form_obj.elements[field_name]; + var o = new Option(name, value); + s.options[s.options.length] = o; +} + +function addClassesToList(list_id, specific_option) { + // Setup class droplist + var styleSelectElm = document.getElementById(list_id); + var styles = tinyMCEPopup.getParam('theme_advanced_styles', false); + styles = tinyMCEPopup.getParam(specific_option, styles); + + if (styles) { + var stylesAr = styles.split(';'); + + for (var i = 0; i < stylesAr.length; i++) { + if (stylesAr != "") { + var key, value; + + key = stylesAr[i].split('=')[0]; + value = stylesAr[i].split('=')[1]; + + styleSelectElm.options[styleSelectElm.length] = new Option(key, value); + } + } + } else { + /*tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) { + styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']); + });*/ + } +} + +function isVisible(element_id) { + var elm = document.getElementById(element_id); + + return elm && elm.style.display != "none"; +} + +function convertRGBToHex(col) { + var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); + + var rgb = col.replace(re, "$1,$2,$3").split(','); + if (rgb.length == 3) { + r = parseInt(rgb[0]).toString(16); + g = parseInt(rgb[1]).toString(16); + b = parseInt(rgb[2]).toString(16); + + r = r.length == 1 ? '0' + r : r; + g = g.length == 1 ? '0' + g : g; + b = b.length == 1 ? '0' + b : b; + + return "#" + r + g + b; + } + + return col; +} + +function convertHexToRGB(col) { + if (col.indexOf('#') != -1) { + col = col.replace(new RegExp('[^0-9A-F]', 'gi'), ''); + + r = parseInt(col.substring(0, 2), 16); + g = parseInt(col.substring(2, 4), 16); + b = parseInt(col.substring(4, 6), 16); + + return "rgb(" + r + "," + g + "," + b + ")"; + } + + return col; +} + +function trimSize(size) { + return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2'); +} + +function getCSSSize(size) { + size = trimSize(size); + + if (size == "") { + return ""; + } + + // Add px + if (/^[0-9]+$/.test(size)) { + size += 'px'; + } + // Sanity check, IE doesn't like broken values + else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size))) { + return ""; + } + + return size; +} + +function getStyle(elm, attrib, style) { + var val = tinyMCEPopup.dom.getAttrib(elm, attrib); + + if (val != '') { + return '' + val; + } + + if (typeof (style) == 'undefined') { + style = attrib; + } + + return tinyMCEPopup.dom.getStyle(elm, style); +} diff --git a/backend/wp-includes/js/tinymce/utils/mctabs.js b/backend/wp-includes/js/tinymce/utils/mctabs.js new file mode 100644 index 0000000..a04519b --- /dev/null +++ b/backend/wp-includes/js/tinymce/utils/mctabs.js @@ -0,0 +1,168 @@ +/** + * mctabs.js + * + * Released under LGPL License. + * Copyright (c) 1999-2017 Ephox Corp. All rights reserved + * + * License: http://www.tinymce.com/license + * Contributing: http://www.tinymce.com/contributing + */ + +/*jshint globals: tinyMCEPopup */ + +function MCTabs() { + this.settings = []; + this.onChange = tinyMCEPopup.editor.windowManager.createInstance('tinymce.util.Dispatcher'); +} + +MCTabs.prototype.init = function (settings) { + this.settings = settings; +}; + +MCTabs.prototype.getParam = function (name, default_value) { + var value = null; + + value = (typeof (this.settings[name]) == "undefined") ? default_value : this.settings[name]; + + // Fix bool values + if (value == "true" || value == "false") { + return (value == "true"); + } + + return value; +}; + +MCTabs.prototype.showTab = function (tab) { + tab.className = 'current'; + tab.setAttribute("aria-selected", true); + tab.setAttribute("aria-expanded", true); + tab.tabIndex = 0; +}; + +MCTabs.prototype.hideTab = function (tab) { + var t = this; + + tab.className = ''; + tab.setAttribute("aria-selected", false); + tab.setAttribute("aria-expanded", false); + tab.tabIndex = -1; +}; + +MCTabs.prototype.showPanel = function (panel) { + panel.className = 'current'; + panel.setAttribute("aria-hidden", false); +}; + +MCTabs.prototype.hidePanel = function (panel) { + panel.className = 'panel'; + panel.setAttribute("aria-hidden", true); +}; + +MCTabs.prototype.getPanelForTab = function (tabElm) { + return tinyMCEPopup.dom.getAttrib(tabElm, "aria-controls"); +}; + +MCTabs.prototype.displayTab = function (tab_id, panel_id, avoid_focus) { + var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i, t = this; + + tabElm = document.getElementById(tab_id); + + if (panel_id === undefined) { + panel_id = t.getPanelForTab(tabElm); + } + + panelElm = document.getElementById(panel_id); + panelContainerElm = panelElm ? panelElm.parentNode : null; + tabContainerElm = tabElm ? tabElm.parentNode : null; + selectionClass = t.getParam('selection_class', 'current'); + + if (tabElm && tabContainerElm) { + nodes = tabContainerElm.childNodes; + + // Hide all other tabs + for (i = 0; i < nodes.length; i++) { + if (nodes[i].nodeName == "LI") { + t.hideTab(nodes[i]); + } + } + + // Show selected tab + t.showTab(tabElm); + } + + if (panelElm && panelContainerElm) { + nodes = panelContainerElm.childNodes; + + // Hide all other panels + for (i = 0; i < nodes.length; i++) { + if (nodes[i].nodeName == "DIV") { + t.hidePanel(nodes[i]); + } + } + + if (!avoid_focus) { + tabElm.focus(); + } + + // Show selected panel + t.showPanel(panelElm); + } +}; + +MCTabs.prototype.getAnchor = function () { + var pos, url = document.location.href; + + if ((pos = url.lastIndexOf('#')) != -1) { + return url.substring(pos + 1); + } + + return ""; +}; + + +//Global instance +var mcTabs = new MCTabs(); + +tinyMCEPopup.onInit.add(function () { + var tinymce = tinyMCEPopup.getWin().tinymce, dom = tinyMCEPopup.dom, each = tinymce.each; + + each(dom.select('div.tabs'), function (tabContainerElm) { + //var keyNav; + + dom.setAttrib(tabContainerElm, "role", "tablist"); + + var items = tinyMCEPopup.dom.select('li', tabContainerElm); + var action = function (id) { + mcTabs.displayTab(id, mcTabs.getPanelForTab(id)); + mcTabs.onChange.dispatch(id); + }; + + each(items, function (item) { + dom.setAttrib(item, 'role', 'tab'); + dom.bind(item, 'click', function (evt) { + action(item.id); + }); + }); + + dom.bind(dom.getRoot(), 'keydown', function (evt) { + if (evt.keyCode === 9 && evt.ctrlKey && !evt.altKey) { // Tab + //keyNav.moveFocus(evt.shiftKey ? -1 : 1); + tinymce.dom.Event.cancel(evt); + } + }); + + each(dom.select('a', tabContainerElm), function (a) { + dom.setAttrib(a, 'tabindex', '-1'); + }); + + /*keyNav = tinyMCEPopup.editor.windowManager.createInstance('tinymce.ui.KeyboardNavigation', { + root: tabContainerElm, + items: items, + onAction: action, + actOnFocus: true, + enableLeftRight: true, + enableUpDown: true + }, tinyMCEPopup.dom);*/ + } +); +}); \ No newline at end of file diff --git a/backend/wp-includes/js/tinymce/utils/validate.js b/backend/wp-includes/js/tinymce/utils/validate.js new file mode 100644 index 0000000..5600666 --- /dev/null +++ b/backend/wp-includes/js/tinymce/utils/validate.js @@ -0,0 +1,267 @@ +/** + * validate.js + * + * Released under LGPL License. + * Copyright (c) 1999-2017 Ephox Corp. All rights reserved + * + * License: http://www.tinymce.com/license + * Contributing: http://www.tinymce.com/contributing + */ + +/** + // String validation: + + if (!Validator.isEmail('myemail')) + alert('Invalid email.'); + + // Form validation: + + var f = document.forms['myform']; + + if (!Validator.isEmail(f.myemail)) + alert('Invalid email.'); +*/ + +var Validator = { + isEmail : function (s) { + return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$'); + }, + + isAbsUrl : function (s) { + return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$'); + }, + + isSize : function (s) { + return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$'); + }, + + isId : function (s) { + return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$'); + }, + + isEmpty : function (s) { + var nl, i; + + if (s.nodeName == 'SELECT' && s.selectedIndex < 1) { + return true; + } + + if (s.type == 'checkbox' && !s.checked) { + return true; + } + + if (s.type == 'radio') { + for (i = 0, nl = s.form.elements; i < nl.length; i++) { + if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked) { + return false; + } + } + + return true; + } + + return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s); + }, + + isNumber : function (s, d) { + return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$')); + }, + + test : function (s, p) { + s = s.nodeType == 1 ? s.value : s; + + return s == '' || new RegExp(p).test(s); + } +}; + +var AutoValidator = { + settings : { + id_cls : 'id', + int_cls : 'int', + url_cls : 'url', + number_cls : 'number', + email_cls : 'email', + size_cls : 'size', + required_cls : 'required', + invalid_cls : 'invalid', + min_cls : 'min', + max_cls : 'max' + }, + + init : function (s) { + var n; + + for (n in s) { + this.settings[n] = s[n]; + } + }, + + validate : function (f) { + var i, nl, s = this.settings, c = 0; + + nl = this.tags(f, 'label'); + for (i = 0; i < nl.length; i++) { + this.removeClass(nl[i], s.invalid_cls); + nl[i].setAttribute('aria-invalid', false); + } + + c += this.validateElms(f, 'input'); + c += this.validateElms(f, 'select'); + c += this.validateElms(f, 'textarea'); + + return c == 3; + }, + + invalidate : function (n) { + this.mark(n.form, n); + }, + + getErrorMessages : function (f) { + var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor; + nl = this.tags(f, "label"); + for (i = 0; i < nl.length; i++) { + if (this.hasClass(nl[i], s.invalid_cls)) { + field = document.getElementById(nl[i].getAttribute("for")); + values = { field: nl[i].textContent }; + if (this.hasClass(field, s.min_cls, true)) { + message = ed.getLang('invalid_data_min'); + values.min = this.getNum(field, s.min_cls); + } else if (this.hasClass(field, s.number_cls)) { + message = ed.getLang('invalid_data_number'); + } else if (this.hasClass(field, s.size_cls)) { + message = ed.getLang('invalid_data_size'); + } else { + message = ed.getLang('invalid_data'); + } + + message = message.replace(/{\#([^}]+)\}/g, function (a, b) { + return values[b] || '{#' + b + '}'; + }); + messages.push(message); + } + } + return messages; + }, + + reset : function (e) { + var t = ['label', 'input', 'select', 'textarea']; + var i, j, nl, s = this.settings; + + if (e == null) { + return; + } + + for (i = 0; i < t.length; i++) { + nl = this.tags(e.form ? e.form : e, t[i]); + for (j = 0; j < nl.length; j++) { + this.removeClass(nl[j], s.invalid_cls); + nl[j].setAttribute('aria-invalid', false); + } + } + }, + + validateElms : function (f, e) { + var nl, i, n, s = this.settings, st = true, va = Validator, v; + + nl = this.tags(f, e); + for (i = 0; i < nl.length; i++) { + n = nl[i]; + + this.removeClass(n, s.invalid_cls); + + if (this.hasClass(n, s.required_cls) && va.isEmpty(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.number_cls) && !va.isNumber(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.email_cls) && !va.isEmail(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.size_cls) && !va.isSize(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.id_cls) && !va.isId(n)) { + st = this.mark(f, n); + } + + if (this.hasClass(n, s.min_cls, true)) { + v = this.getNum(n, s.min_cls); + + if (isNaN(v) || parseInt(n.value) < parseInt(v)) { + st = this.mark(f, n); + } + } + + if (this.hasClass(n, s.max_cls, true)) { + v = this.getNum(n, s.max_cls); + + if (isNaN(v) || parseInt(n.value) > parseInt(v)) { + st = this.mark(f, n); + } + } + } + + return st; + }, + + hasClass : function (n, c, d) { + return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className); + }, + + getNum : function (n, c) { + c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0]; + c = c.replace(/[^0-9]/g, ''); + + return c; + }, + + addClass : function (n, c, b) { + var o = this.removeClass(n, c); + n.className = b ? c + (o !== '' ? (' ' + o) : '') : (o !== '' ? (o + ' ') : '') + c; + }, + + removeClass : function (n, c) { + c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' '); + return n.className = c !== ' ' ? c : ''; + }, + + tags : function (f, s) { + return f.getElementsByTagName(s); + }, + + mark : function (f, n) { + var s = this.settings; + + this.addClass(n, s.invalid_cls); + n.setAttribute('aria-invalid', 'true'); + this.markLabels(f, n, s.invalid_cls); + + return false; + }, + + markLabels : function (f, n, ic) { + var nl, i; + + nl = this.tags(f, "label"); + for (i = 0; i < nl.length; i++) { + if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id) { + this.addClass(nl[i], ic); + } + } + + return null; + } +}; diff --git a/backend/wp-includes/js/tinymce/wp-tinymce.js.gz b/backend/wp-includes/js/tinymce/wp-tinymce.js.gz new file mode 100644 index 0000000..baeb497 Binary files /dev/null and b/backend/wp-includes/js/tinymce/wp-tinymce.js.gz differ diff --git a/backend/wp-includes/js/tinymce/wp-tinymce.php b/backend/wp-includes/js/tinymce/wp-tinymce.php new file mode 100644 index 0000000..ea58e68 --- /dev/null +++ b/backend/wp-includes/js/tinymce/wp-tinymce.php @@ -0,0 +1,39 @@ + tags or HTMLImage nodes. + * "emojify" a generic text or DOM Element. + * + * @overloads + * + * String replacement for `innerHTML` or server side operations + * twemoji.parse(string); + * twemoji.parse(string, Function); + * twemoji.parse(string, Object); + * + * HTMLElement tree parsing for safer operations over existing DOM + * twemoji.parse(HTMLElement); + * twemoji.parse(HTMLElement, Function); + * twemoji.parse(HTMLElement, Object); + * + * @param string|HTMLElement the source to parse and enrich with emoji. + * + * string replace emoji matches with tags. + * Mainly used to inject emoji via `innerHTML` + * It does **not** parse the string or validate it, + * it simply replaces found emoji with a tag. + * NOTE: be sure this won't affect security. + * + * HTMLElement walk through the DOM tree and find emoji + * that are inside **text node only** (nodeType === 3) + * Mainly used to put emoji in already generated DOM + * without compromising surrounding nodes and + * **avoiding** the usage of `innerHTML`. + * NOTE: Using DOM elements instead of strings should + * improve security without compromising too much + * performance compared with a less safe `innerHTML`. + * + * @param Function|Object [optional] + * either the callback that will be invoked or an object + * with all properties to use per each found emoji. + * + * Function if specified, this will be invoked per each emoji + * that has been found through the RegExp except + * those follwed by the invariant \uFE0E ("as text"). + * Once invoked, parameters will be: + * + * iconId:string the lower case HEX code point + * i.e. "1f4a9" + * + * options:Object all info for this parsing operation + * + * variant:char the optional \uFE0F ("as image") + * variant, in case this info + * is anyhow meaningful. + * By default this is ignored. + * + * If such callback will return a falsy value instead + * of a valid `src` to use for the image, nothing will + * actually change for that specific emoji. + * + * + * Object if specified, an object containing the following properties + * + * callback Function the callback to invoke per each found emoji. + * base string the base url, by default twemoji.base + * ext string the image extension, by default twemoji.ext + * size string the assets size, by default twemoji.size + * + * @example + * + * twemoji.parse("I \u2764\uFE0F emoji!"); + * // I â¤ï¸ emoji! + * + * + * twemoji.parse("I \u2764\uFE0F emoji!", function(iconId, options) { + * return '/assets/' + iconId + '.gif'; + * }); + * // I â¤ï¸ emoji! + * + * + * twemoji.parse("I \u2764\uFE0F emoji!", { + * size: 72, + * callback: function(iconId, options) { + * return '/assets/' + options.size + '/' + iconId + options.ext; + * } + * }); + * // I â¤ï¸ emoji! + * + */ + parse: parse, + + /** + * Given a string, invokes the callback argument + * per each emoji found in such string. + * This is the most raw version used by + * the .parse(string) method itself. + * + * @param string generic string to parse + * @param Function a generic callback that will be + * invoked to replace the content. + * This calback wil receive standard + * String.prototype.replace(str, callback) + * arguments such: + * callback( + * rawText, // the emoji match + * ); + * + * and others commonly received via replace. + */ + replace: replace, + + /** + * Simplify string tests against emoji. + * + * @param string some text that might contain emoji + * @return boolean true if any emoji was found, false otherwise. + * + * @example + * + * if (twemoji.test(someContent)) { + * console.log("emoji All The Things!"); + * } + */ + test: test + }, + + // used to escape HTML special chars in attributes + escaper = { + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' + }, + + // RegExp based on emoji's official Unicode standards + // http://www.unicode.org/Public/UNIDATA/EmojiSources.txt + re = /\ud83d[\udc68-\udc69](?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)(?:\ufe0f|\ud83c[\udffb-\udfff])\u200d[\u2640\u2642]\ufe0f|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|(?:\u002a)\ufe0f?\u20e3|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca-\udfcc]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd74\udd75\udd7a\udd90\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddd1-\udddd]|[\u261d\u26f7\u26f9\u270a-\u270d])(?:\ud83c[\udffb-\udfff]|)|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\u0023\u20e3|\u0030\u20e3|\u0031\u20e3|\u0032\u20e3|\u0033\u20e3|\u0034\u20e3|\u0035\u20e3|\u0036\u20e3|\u0037\u20e3|\u0038\u20e3|\u0039\u20e3|\ud800\udc00|\ud83c[\udc04\udccf\udd70\udd71\udd7e\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude02\ude1a\ude2f\ude32-\ude3a\ude50\ude51\udf00-\udf21\udf24-\udf84\udf86-\udf93\udf96\udf97\udf99-\udf9b\udf9e-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcd-\udff0\udff3-\udff5\udff7-\udfff]|\ud83d[\udc00-\udc41\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfd\udcff-\udd3d\udd49-\udd4e\udd50-\udd67\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda4\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\udecb\udecd-\uded2\udee0-\udee5\udee9\udeeb\udeec\udef0\udef3-\udef8]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd4c\udd50-\udd6b\udd80-\udd97\uddc0\uddd0\uddde-\udde6]|[\u00a9\u00ae\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26ce\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2705\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299\ue50a]|(?:\u2639)(?:\ufe0f|(?!\ufe0e))/g, + + // avoid runtime RegExp creation for not so smart, + // not JIT based, and old browsers / engines + UFE0Fg = /\uFE0F/g, + + // avoid using a string literal like '\u200D' here because minifiers expand it inline + U200D = String.fromCharCode(0x200D), + + // used to find HTML special chars in attributes + rescaper = /[&<>'"]/g, + + // nodes with type 1 which should **not** be parsed + shouldntBeParsed = /^(?:iframe|noframes|noscript|script|select|style|textarea)$/, + + // just a private shortcut + fromCharCode = String.fromCharCode; + + return twemoji; + + + ///////////////////////// + // private functions // + // declaration // + ///////////////////////// + + /** + * Shortcut to create text nodes + * @param string text used to create DOM text node + * @return Node a DOM node with that text + */ + function createText(text, clean) { + return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text); + } + + /** + * Utility function to escape html attribute text + * @param string text use in HTML attribute + * @return string text encoded to use in HTML attribute + */ + function escapeHTML(s) { + return s.replace(rescaper, replacer); + } + + /** + * Default callback used to generate emoji src + * based on Twitter CDN + * @param string the emoji codepoint string + * @param string the default size to use, i.e. "36x36" + * @return string the image source to use + */ + function defaultImageSrcGenerator(icon, options) { + return ''.concat(options.base, options.size, '/', icon, options.ext); + } + + /** + * Given a generic DOM nodeType 1, walk through all children + * and store every nodeType 3 (#text) found in the tree. + * @param Element a DOM Element with probably some text in it + * @param Array the list of previously discovered text nodes + * @return Array same list with new discovered nodes, if any + */ + function grabAllTextNodes(node, allText) { + var + childNodes = node.childNodes, + length = childNodes.length, + subnode, + nodeType; + while (length--) { + subnode = childNodes[length]; + nodeType = subnode.nodeType; + // parse emoji only in text nodes + if (nodeType === 3) { + // collect them to process emoji later + allText.push(subnode); + } + // ignore all nodes that are not type 1, that are svg, or that + // should not be parsed as script, style, and others + else if (nodeType === 1 && !('ownerSVGElement' in subnode) && + !shouldntBeParsed.test(subnode.nodeName.toLowerCase())) { + grabAllTextNodes(subnode, allText); + } + } + return allText; + } + + /** + * Used to both remove the possible variant + * and to convert utf16 into code points. + * If there is a zero-width-joiner (U+200D), leave the variants in. + * @param string the raw text of the emoji match + * @return string the code point + */ + function grabTheRightIcon(rawText) { + // if variant is present as \uFE0F + return toCodePoint(rawText.indexOf(U200D) < 0 ? + rawText.replace(UFE0Fg, '') : + rawText + ); + } + + /** + * DOM version of the same logic / parser: + * emojify all found sub-text nodes placing images node instead. + * @param Element generic DOM node with some text in some child node + * @param Object options containing info about how to parse + * + * .callback Function the callback to invoke per each found emoji. + * .base string the base url, by default twemoji.base + * .ext string the image extension, by default twemoji.ext + * .size string the assets size, by default twemoji.size + * + * @return Element same generic node with emoji in place, if any. + */ + function parseNode(node, options) { + var + allText = grabAllTextNodes(node, []), + length = allText.length, + attrib, + attrname, + modified, + fragment, + subnode, + text, + match, + i, + index, + img, + rawText, + iconId, + src; + while (length--) { + modified = false; + fragment = document.createDocumentFragment(); + subnode = allText[length]; + text = subnode.nodeValue; + i = 0; + while ((match = re.exec(text))) { + index = match.index; + if (index !== i) { + fragment.appendChild( + createText(text.slice(i, index), true) + ); + } + rawText = match[0]; + iconId = grabTheRightIcon(rawText); + i = index + rawText.length; + src = options.callback(iconId, options); + if (src) { + img = new Image(); + img.onerror = options.onerror; + img.setAttribute('draggable', 'false'); + attrib = options.attributes(rawText, iconId); + for (attrname in attrib) { + if ( + attrib.hasOwnProperty(attrname) && + // don't allow any handlers to be set + don't allow overrides + attrname.indexOf('on') !== 0 && + !img.hasAttribute(attrname) + ) { + img.setAttribute(attrname, attrib[attrname]); + } + } + img.className = options.className; + img.alt = rawText; + img.src = src; + modified = true; + fragment.appendChild(img); + } + if (!img) fragment.appendChild(createText(rawText, false)); + img = null; + } + // is there actually anything to replace in here ? + if (modified) { + // any text left to be added ? + if (i < text.length) { + fragment.appendChild( + createText(text.slice(i), true) + ); + } + // replace the text node only, leave intact + // anything else surrounding such text + subnode.parentNode.replaceChild(fragment, subnode); + } + } + return node; + } + + /** + * String/HTML version of the same logic / parser: + * emojify a generic text placing images tags instead of surrogates pair. + * @param string generic string with possibly some emoji in it + * @param Object options containing info about how to parse + * + * .callback Function the callback to invoke per each found emoji. + * .base string the base url, by default twemoji.base + * .ext string the image extension, by default twemoji.ext + * .size string the assets size, by default twemoji.size + * + * @return the string with replacing all found and parsed emoji + */ + function parseString(str, options) { + return replace(str, function (rawText) { + var + ret = rawText, + iconId = grabTheRightIcon(rawText), + src = options.callback(iconId, options), + attrib, + attrname; + if (src) { + // recycle the match string replacing the emoji + // with its image counter part + ret = ''); + } + return ret; + }); + } + + /** + * Function used to actually replace HTML special chars + * @param string HTML special char + * @return string encoded HTML special char + */ + function replacer(m) { + return escaper[m]; + } + + /** + * Default options.attribute callback + * @return null + */ + function returnNull() { + return null; + } + + /** + * Given a generic value, creates its squared counterpart if it's a number. + * As example, number 36 will return '36x36'. + * @param any a generic value. + * @return any a string representing asset size, i.e. "36x36" + * only in case the value was a number. + * Returns initial value otherwise. + */ + function toSizeSquaredAsset(value) { + return typeof value === 'number' ? + value + 'x' + value : + value; + } + + + ///////////////////////// + // exported functions // + // declaration // + ///////////////////////// + + function fromCodePoint(codepoint) { + var code = typeof codepoint === 'string' ? + parseInt(codepoint, 16) : codepoint; + if (code < 0x10000) { + return fromCharCode(code); + } + code -= 0x10000; + return fromCharCode( + 0xD800 + (code >> 10), + 0xDC00 + (code & 0x3FF) + ); + } + + function parse(what, how) { + if (!how || typeof how === 'function') { + how = {callback: how}; + } + // if first argument is string, inject html tags + // otherwise use the DOM tree and parse text nodes only + return (typeof what === 'string' ? parseString : parseNode)(what, { + callback: how.callback || defaultImageSrcGenerator, + attributes: typeof how.attributes === 'function' ? how.attributes : returnNull, + base: typeof how.base === 'string' ? how.base : twemoji.base, + ext: how.ext || twemoji.ext, + size: how.folder || toSizeSquaredAsset(how.size || twemoji.size), + className: how.className || twemoji.className, + onerror: how.onerror || twemoji.onerror + }); + } + + function replace(text, callback) { + return String(text).replace(re, callback); + } + + function test(text) { + // IE6 needs a reset before too + re.lastIndex = 0; + var result = re.test(text); + re.lastIndex = 0; + return result; + } + + function toCodePoint(unicodeSurrogates, sep) { + var + r = [], + c = 0, + p = 0, + i = 0; + while (i < unicodeSurrogates.length) { + c = unicodeSurrogates.charCodeAt(i++); + if (p) { + r.push((0x10000 + ((p - 0xD800) << 10) + (c - 0xDC00)).toString(16)); + p = 0; + } else if (0xD800 <= c && c <= 0xDBFF) { + p = c; + } else { + r.push(c.toString(16)); + } + } + return r.join(sep || '-'); + } + +}()); \ No newline at end of file diff --git a/backend/wp-includes/js/twemoji.min.js b/backend/wp-includes/js/twemoji.min.js new file mode 100644 index 0000000..db46c19 --- /dev/null +++ b/backend/wp-includes/js/twemoji.min.js @@ -0,0 +1 @@ +var twemoji=function(){"use strict";function a(a,b){return document.createTextNode(b?a.replace(s,""):a)}function b(a){return a.replace(u,h)}function c(a,b){return"".concat(b.base,b.size,"/",a,b.ext)}function d(a,b){for(var c,e,f=a.childNodes,g=f.length;g--;)c=f[g],e=c.nodeType,3===e?b.push(c):1!==e||"ownerSVGElement"in c||v.test(c.nodeName.toLowerCase())||d(c,b);return b}function e(a){return o(a.indexOf(t)<0?a.replace(s,""):a)}function f(b,c){for(var f,g,h,i,j,k,l,m,n,o,p,q,s,t=d(b,[]),u=t.length;u--;){for(h=!1,i=document.createDocumentFragment(),j=t[u],k=j.nodeValue,m=0;l=r.exec(k);){if(n=l.index,n!==m&&i.appendChild(a(k.slice(m,n),!0)),p=l[0],q=e(p),m=n+p.length,s=c.callback(q,c)){o=new Image,o.onerror=c.onerror,o.setAttribute("draggable","false"),f=c.attributes(p,q);for(g in f)f.hasOwnProperty(g)&&0!==g.indexOf("on")&&!o.hasAttribute(g)&&o.setAttribute(g,f[g]);o.className=c.className,o.alt=p,o.src=s,h=!0,i.appendChild(o)}o||i.appendChild(a(p,!1)),o=null}h&&(m")}return g})}function h(a){return q[a]}function i(){return null}function j(a){return"number"==typeof a?a+"x"+a:a}function k(a){var b="string"==typeof a?parseInt(a,16):a;return b<65536?w(b):(b-=65536,w(55296+(b>>10),56320+(1023&b)))}function l(a,b){return b&&"function"!=typeof b||(b={callback:b}),("string"==typeof a?g:f)(a,{callback:b.callback||c,attributes:"function"==typeof b.attributes?b.attributes:i,base:"string"==typeof b.base?b.base:p.base,ext:b.ext||p.ext,size:b.folder||j(b.size||p.size),className:b.className||p.className,onerror:b.onerror||p.onerror})}function m(a,b){return String(a).replace(r,b)}function n(a){r.lastIndex=0;var b=r.test(a);return r.lastIndex=0,b}function o(a,b){for(var c=[],d=0,e=0,f=0;f":">","'":"'",'"':"""},r=/\ud83d[\udc68-\udc69](?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)(?:\ufe0f|\ud83c[\udffb-\udfff])\u200d[\u2640\u2642]\ufe0f|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f|(?:\u002a)\ufe0f?\u20e3|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca-\udfcc]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd74\udd75\udd7a\udd90\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddd1-\udddd]|[\u261d\u26f7\u26f9\u270a-\u270d])(?:\ud83c[\udffb-\udfff]|)|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\u0023\u20e3|\u0030\u20e3|\u0031\u20e3|\u0032\u20e3|\u0033\u20e3|\u0034\u20e3|\u0035\u20e3|\u0036\u20e3|\u0037\u20e3|\u0038\u20e3|\u0039\u20e3|\ud800\udc00|\ud83c[\udc04\udccf\udd70\udd71\udd7e\udd7f\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude02\ude1a\ude2f\ude32-\ude3a\ude50\ude51\udf00-\udf21\udf24-\udf84\udf86-\udf93\udf96\udf97\udf99-\udf9b\udf9e-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcd-\udff0\udff3-\udff5\udff7-\udfff]|\ud83d[\udc00-\udc41\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfd\udcff-\udd3d\udd49-\udd4e\udd50-\udd67\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda4\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\udecb\udecd-\uded2\udee0-\udee5\udee9\udeeb\udeec\udef0\udef3-\udef8]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd4c\udd50-\udd6b\udd80-\udd97\uddc0\uddd0\uddde-\udde6]|[\u00a9\u00ae\u203c\u2049\u2122\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26ce\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2705\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2728\u2733\u2734\u2744\u2747\u274c\u274e\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27a1\u27b0\u27bf\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299\ue50a]|(?:\u2639)(?:\ufe0f|(?!\ufe0e))/g,s=/\uFE0F/g,t=String.fromCharCode(8205),u=/[&<>'"]/g,v=/^(?:iframe|noframes|noscript|script|select|style|textarea)$/,w=String.fromCharCode;return p}(); \ No newline at end of file diff --git a/backend/wp-includes/js/underscore.min.js b/backend/wp-includes/js/underscore.min.js new file mode 100644 index 0000000..3c3eec0 --- /dev/null +++ b/backend/wp-includes/js/underscore.min.js @@ -0,0 +1,5 @@ +// Underscore.js 1.8.3 +// http://underscorejs.org +// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); diff --git a/backend/wp-includes/js/utils.js b/backend/wp-includes/js/utils.js new file mode 100644 index 0000000..48e078e --- /dev/null +++ b/backend/wp-includes/js/utils.js @@ -0,0 +1,198 @@ +/* global userSettings */ +/* exported getUserSetting, setUserSetting, deleteUserSetting */ +// utility functions + +var wpCookies = { +// The following functions are from Cookie.js class in TinyMCE 3, Moxiecode, used under LGPL. + + each: function( obj, cb, scope ) { + var n, l; + + if ( ! obj ) { + return 0; + } + + scope = scope || obj; + + if ( typeof( obj.length ) !== 'undefined' ) { + for ( n = 0, l = obj.length; n < l; n++ ) { + if ( cb.call( scope, obj[n], n, obj ) === false ) { + return 0; + } + } + } else { + for ( n in obj ) { + if ( obj.hasOwnProperty(n) ) { + if ( cb.call( scope, obj[n], n, obj ) === false ) { + return 0; + } + } + } + } + return 1; + }, + + /** + * Get a multi-values cookie. + * Returns a JS object with the name: 'value' pairs. + */ + getHash: function( name ) { + var cookie = this.get( name ), values; + + if ( cookie ) { + this.each( cookie.split('&'), function( pair ) { + pair = pair.split('='); + values = values || {}; + values[pair[0]] = pair[1]; + }); + } + + return values; + }, + + /** + * Set a multi-values cookie. + * + * 'values_obj' is the JS object that is stored. It is encoded as URI in wpCookies.set(). + */ + setHash: function( name, values_obj, expires, path, domain, secure ) { + var str = ''; + + this.each( values_obj, function( val, key ) { + str += ( ! str ? '' : '&' ) + key + '=' + val; + }); + + this.set( name, str, expires, path, domain, secure ); + }, + + /** + * Get a cookie. + */ + get: function( name ) { + var e, b, + cookie = document.cookie, + p = name + '='; + + if ( ! cookie ) { + return; + } + + b = cookie.indexOf( '; ' + p ); + + if ( b === -1 ) { + b = cookie.indexOf(p); + + if ( b !== 0 ) { + return null; + } + } else { + b += 2; + } + + e = cookie.indexOf( ';', b ); + + if ( e === -1 ) { + e = cookie.length; + } + + return decodeURIComponent( cookie.substring( b + p.length, e ) ); + }, + + /** + * Set a cookie. + * + * The 'expires' arg can be either a JS Date() object set to the expiration date (back-compat) + * or the number of seconds until expiration + */ + set: function( name, value, expires, path, domain, secure ) { + var d = new Date(); + + if ( typeof( expires ) === 'object' && expires.toGMTString ) { + expires = expires.toGMTString(); + } else if ( parseInt( expires, 10 ) ) { + d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // time must be in milliseconds + expires = d.toGMTString(); + } else { + expires = ''; + } + + document.cookie = name + '=' + encodeURIComponent( value ) + + ( expires ? '; expires=' + expires : '' ) + + ( path ? '; path=' + path : '' ) + + ( domain ? '; domain=' + domain : '' ) + + ( secure ? '; secure' : '' ); + }, + + /** + * Remove a cookie. + * + * This is done by setting it to an empty value and setting the expiration time in the past. + */ + remove: function( name, path, domain, secure ) { + this.set( name, '', -1000, path, domain, secure ); + } +}; + +// Returns the value as string. Second arg or empty string is returned when value is not set. +function getUserSetting( name, def ) { + var settings = getAllUserSettings(); + + if ( settings.hasOwnProperty( name ) ) { + return settings[name]; + } + + if ( typeof def !== 'undefined' ) { + return def; + } + + return ''; +} + +// Both name and value must be only ASCII letters, numbers or underscore +// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. +// The value is converted and stored as string. +function setUserSetting( name, value, _del ) { + if ( 'object' !== typeof userSettings ) { + return false; + } + + var uid = userSettings.uid, + settings = wpCookies.getHash( 'wp-settings-' + uid ), + path = userSettings.url, + secure = !! userSettings.secure; + + name = name.toString().replace( /[^A-Za-z0-9_-]/g, '' ); + + if ( typeof value === 'number' ) { + value = parseInt( value, 10 ); + } else { + value = value.toString().replace( /[^A-Za-z0-9_-]/g, '' ); + } + + settings = settings || {}; + + if ( _del ) { + delete settings[name]; + } else { + settings[name] = value; + } + + wpCookies.setHash( 'wp-settings-' + uid, settings, 31536000, path, '', secure ); + wpCookies.set( 'wp-settings-time-' + uid, userSettings.time, 31536000, path, '', secure ); + + return name; +} + +function deleteUserSetting( name ) { + return setUserSetting( name, '', 1 ); +} + +// Returns all settings as js object. +function getAllUserSettings() { + if ( 'object' !== typeof userSettings ) { + return {}; + } + + return wpCookies.getHash( 'wp-settings-' + userSettings.uid ) || {}; +} + diff --git a/backend/wp-includes/js/utils.min.js b/backend/wp-includes/js/utils.min.js new file mode 100644 index 0000000..a8d1a7e --- /dev/null +++ b/backend/wp-includes/js/utils.min.js @@ -0,0 +1 @@ +function getUserSetting(a,b){var c=getAllUserSettings();return c.hasOwnProperty(a)?c[a]:"undefined"!=typeof b?b:""}function setUserSetting(a,b,c){if("object"!=typeof userSettings)return!1;var d=userSettings.uid,e=wpCookies.getHash("wp-settings-"+d),f=userSettings.url,g=!!userSettings.secure;return a=a.toString().replace(/[^A-Za-z0-9_-]/g,""),b="number"==typeof b?parseInt(b,10):b.toString().replace(/[^A-Za-z0-9_-]/g,""),e=e||{},c?delete e[a]:e[a]=b,wpCookies.setHash("wp-settings-"+d,e,31536e3,f,"",g),wpCookies.set("wp-settings-time-"+d,userSettings.time,31536e3,f,"",g),a}function deleteUserSetting(a){return setUserSetting(a,"",1)}function getAllUserSettings(){return"object"!=typeof userSettings?{}:wpCookies.getHash("wp-settings-"+userSettings.uid)||{}}var wpCookies={each:function(a,b,c){var d,e;if(!a)return 0;if(c=c||a,"undefined"!=typeof a.length){for(d=0,e=a.length;d' ).html( message ).text(); + + /* + * Safari 10+VoiceOver don't announce repeated, identical strings. We use + * a `no-break space` to force them to think identical strings are different. + * See ticket #36853. + */ + if ( previousMessage === message ) { + message = message + '\u00A0'; + } + + previousMessage = message; + + if ( $containerAssertive && 'assertive' === ariaLive ) { + $containerAssertive.text( message ); + } else if ( $containerPolite ) { + $containerPolite.text( message ); + } + } + + /** + * Build the live regions markup. + * + * @since 4.3.0 + * + * @param {String} ariaLive Optional. Value for the 'aria-live' attribute, default 'polite'. + * + * @return {Object} $container The ARIA live region jQuery object. + */ + function addContainer( ariaLive ) { + ariaLive = ariaLive || 'polite'; + + var $container = $( '
      ', { + 'id': 'wp-a11y-speak-' + ariaLive, + 'aria-live': ariaLive, + 'aria-relevant': 'additions text', + 'aria-atomic': 'true', + 'class': 'screen-reader-text wp-a11y-speak-region' + }); + + $( document.body ).append( $container ); + return $container; + } + + /** + * Clear the live regions. + * + * @since 4.3.0 + */ + function clear() { + $( '.wp-a11y-speak-region' ).text( '' ); + } + + /** + * Initialize wp.a11y and define ARIA live notification area. + * + * @since 4.2.0 + * @since 4.3.0 Added the assertive live region. + */ + $( document ).ready( function() { + $containerPolite = $( '#wp-a11y-speak-polite' ); + $containerAssertive = $( '#wp-a11y-speak-assertive' ); + + if ( ! $containerPolite.length ) { + $containerPolite = addContainer( 'polite' ); + } + + if ( ! $containerAssertive.length ) { + $containerAssertive = addContainer( 'assertive' ); + } + }); + + /** @namespace wp.a11y */ + wp.a11y = wp.a11y || {}; + wp.a11y.speak = speak; + +}( window.wp, window.jQuery )); diff --git a/backend/wp-includes/js/wp-a11y.min.js b/backend/wp-includes/js/wp-a11y.min.js new file mode 100644 index 0000000..3796ce1 --- /dev/null +++ b/backend/wp-includes/js/wp-a11y.min.js @@ -0,0 +1 @@ +window.wp=window.wp||{},function(a,b){"use strict";function c(a,c){e(),a=b("

      ").html(a).text(),h===a&&(a+="\xa0"),h=a,g&&"assertive"===c?g.text(a):f&&f.text(a)}function d(a){a=a||"polite";var c=b("

      ",{id:"wp-a11y-speak-"+a,"aria-live":a,"aria-relevant":"additions text","aria-atomic":"true","class":"screen-reader-text wp-a11y-speak-region"});return b(document.body).append(c),c}function e(){b(".wp-a11y-speak-region").text("")}var f,g,h="";b(document).ready(function(){f=b("#wp-a11y-speak-polite"),g=b("#wp-a11y-speak-assertive"),f.length||(f=d("polite")),g.length||(g=d("assertive"))}),a.a11y=a.a11y||{},a.a11y.speak=c}(window.wp,window.jQuery); \ No newline at end of file diff --git a/backend/wp-includes/js/wp-ajax-response.js b/backend/wp-includes/js/wp-ajax-response.js new file mode 100644 index 0000000..363a08b --- /dev/null +++ b/backend/wp-includes/js/wp-ajax-response.js @@ -0,0 +1,64 @@ +var wpAjax = jQuery.extend( { + unserialize: function( s ) { + var r = {}, q, pp, i, p; + if ( !s ) { return r; } + q = s.split('?'); if ( q[1] ) { s = q[1]; } + pp = s.split('&'); + for ( i in pp ) { + if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; } + p = pp[i].split('='); + r[p[0]] = p[1]; + } + return r; + }, + parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission + var parsed = {}, re = jQuery('#' + r).empty(), err = ''; + + if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { + parsed.responses = []; + parsed.errors = false; + jQuery('response', x).each( function() { + var th = jQuery(this), child = jQuery(this.firstChild), response; + response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') }; + response.data = jQuery( 'response_data', child ).text(); + response.supplemental = {}; + if ( !jQuery( 'supplemental', child ).children().each( function() { + response.supplemental[this.nodeName] = jQuery(this).text(); + } ).length ) { response.supplemental = false; } + response.errors = []; + if ( !jQuery('wp_error', child).each( function() { + var code = jQuery(this).attr('code'), anError, errorData, formField; + anError = { code: code, message: this.firstChild.nodeValue, data: false }; + errorData = jQuery('wp_error_data[code="' + code + '"]', x); + if ( errorData ) { anError.data = errorData.get(); } + formField = jQuery( 'form-field', errorData ).text(); + if ( formField ) { code = formField; } + if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); } + err += '

      ' + anError.message + '

      '; + response.errors.push( anError ); + parsed.errors = true; + } ).length ) { response.errors = false; } + parsed.responses.push( response ); + } ); + if ( err.length ) { re.html( '
      ' + err + '
      ' ); } + return parsed; + } + if ( isNaN(x) ) { return !re.html('

      ' + x + '

      '); } + x = parseInt(x,10); + if ( -1 == x ) { return !re.html('

      ' + wpAjax.noPerm + '

      '); } + else if ( 0 === x ) { return !re.html('

      ' + wpAjax.broken + '

      '); } + return true; + }, + invalidateForm: function ( selector ) { + return jQuery( selector ).addClass( 'form-invalid' ).find('input').one( 'change wp-check-valid-field', function() { jQuery(this).closest('.form-invalid').removeClass( 'form-invalid' ); } ); + }, + validateForm: function( selector ) { + selector = jQuery( selector ); + return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() === ''; } ) ).length; + } +}, wpAjax || { noPerm: 'Sorry, you are not allowed to do that.', broken: 'Something went wrong.' } ); + +// Basic form validation +jQuery(document).ready( function($){ + $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); +}); diff --git a/backend/wp-includes/js/wp-ajax-response.min.js b/backend/wp-includes/js/wp-ajax-response.min.js new file mode 100644 index 0000000..13bcc1d --- /dev/null +++ b/backend/wp-includes/js/wp-ajax-response.min.js @@ -0,0 +1 @@ +var wpAjax=jQuery.extend({unserialize:function(a){var b,c,d,e,f={};if(!a)return f;b=a.split("?"),b[1]&&(a=b[1]),c=a.split("&");for(d in c)jQuery.isFunction(c.hasOwnProperty)&&!c.hasOwnProperty(d)||(e=c[d].split("="),f[e[0]]=e[1]);return f},parseAjaxResponse:function(a,b,c){var d={},e=jQuery("#"+b).empty(),f="";return a&&"object"==typeof a&&a.getElementsByTagName("wp_ajax")?(d.responses=[],d.errors=!1,jQuery("response",a).each(function(){var b,e=jQuery(this),g=jQuery(this.firstChild);b={action:e.attr("action"),what:g.get(0).nodeName,id:g.attr("id"),oldId:g.attr("old_id"),position:g.attr("position")},b.data=jQuery("response_data",g).text(),b.supplemental={},jQuery("supplemental",g).children().each(function(){b.supplemental[this.nodeName]=jQuery(this).text()}).length||(b.supplemental=!1),b.errors=[],jQuery("wp_error",g).each(function(){var e,g,h,i=jQuery(this).attr("code");e={code:i,message:this.firstChild.nodeValue,data:!1},g=jQuery('wp_error_data[code="'+i+'"]',a),g&&(e.data=g.get()),h=jQuery("form-field",g).text(),h&&(i=h),c&&wpAjax.invalidateForm(jQuery("#"+c+' :input[name="'+i+'"]').parents(".form-field:first")),f+="

      "+e.message+"

      ",b.errors.push(e),d.errors=!0}).length||(b.errors=!1),d.responses.push(b)}),f.length&&e.html('
      '+f+"
      "),d):isNaN(a)?!e.html('

      '+a+"

      "):(a=parseInt(a,10),-1==a?!e.html('

      '+wpAjax.noPerm+"

      "):0!==a||!e.html('

      '+wpAjax.broken+"

      "))},invalidateForm:function(a){return jQuery(a).addClass("form-invalid").find("input").one("change wp-check-valid-field",function(){jQuery(this).closest(".form-invalid").removeClass("form-invalid")})},validateForm:function(a){return a=jQuery(a),!wpAjax.invalidateForm(a.find(".form-required").filter(function(){return""===jQuery("input:visible",this).val()})).length}},wpAjax||{noPerm:"Sorry, you are not allowed to do that.",broken:"Something went wrong."});jQuery(document).ready(function(a){a("form.validate").submit(function(){return wpAjax.validateForm(a(this))})}); \ No newline at end of file diff --git a/backend/wp-includes/js/wp-api.js b/backend/wp-includes/js/wp-api.js new file mode 100644 index 0000000..5c8a906 --- /dev/null +++ b/backend/wp-includes/js/wp-api.js @@ -0,0 +1,1541 @@ +(function( window, undefined ) { + + 'use strict'; + + /** + * Initialise the WP_API. + */ + function WP_API() { + /** @namespace wp.api.models */ + this.models = {}; + /** @namespace wp.api.collections */ + this.collections = {}; + /** @namespace wp.api.views */ + this.views = {}; + } + + /** @namespace wp */ + window.wp = window.wp || {}; + /** @namespace wp.api */ + wp.api = wp.api || new WP_API(); + wp.api.versionString = wp.api.versionString || 'wp/v2/'; + + // Alias _includes to _.contains, ensuring it is available if lodash is used. + if ( ! _.isFunction( _.includes ) && _.isFunction( _.contains ) ) { + _.includes = _.contains; + } + +})( window ); + +(function( window, undefined ) { + + 'use strict'; + + var pad, r; + + /** @namespace wp */ + window.wp = window.wp || {}; + /** @namespace wp.api */ + wp.api = wp.api || {}; + /** @namespace wp.api.utils */ + wp.api.utils = wp.api.utils || {}; + + /** + * Determine model based on API route. + * + * @param {string} route The API route. + * + * @return {Backbone Model} The model found at given route. Undefined if not found. + */ + wp.api.getModelByRoute = function( route ) { + return _.find( wp.api.models, function( model ) { + return model.prototype.route && route === model.prototype.route.index; + } ); + }; + + /** + * Determine collection based on API route. + * + * @param {string} route The API route. + * + * @return {Backbone Model} The collection found at given route. Undefined if not found. + */ + wp.api.getCollectionByRoute = function( route ) { + return _.find( wp.api.collections, function( collection ) { + return collection.prototype.route && route === collection.prototype.route.index; + } ); + }; + + + /** + * ECMAScript 5 shim, adapted from MDN. + * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString + */ + if ( ! Date.prototype.toISOString ) { + pad = function( number ) { + r = String( number ); + if ( 1 === r.length ) { + r = '0' + r; + } + + return r; + }; + + Date.prototype.toISOString = function() { + return this.getUTCFullYear() + + '-' + pad( this.getUTCMonth() + 1 ) + + '-' + pad( this.getUTCDate() ) + + 'T' + pad( this.getUTCHours() ) + + ':' + pad( this.getUTCMinutes() ) + + ':' + pad( this.getUTCSeconds() ) + + '.' + String( ( this.getUTCMilliseconds() / 1000 ).toFixed( 3 ) ).slice( 2, 5 ) + + 'Z'; + }; + } + + /** + * Parse date into ISO8601 format. + * + * @param {Date} date. + */ + wp.api.utils.parseISO8601 = function( date ) { + var timestamp, struct, i, k, + minutesOffset = 0, + numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ]; + + // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string + // before falling back to any implementation-specific date parsing, so that’s what we do, even if native + // implementations could be faster. + // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm + if ( ( struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec( date ) ) ) { + + // Avoid NaN timestamps caused by “undefined†values being passed to Date.UTC. + for ( i = 0; ( k = numericKeys[i] ); ++i ) { + struct[k] = +struct[k] || 0; + } + + // Allow undefined days and months. + struct[2] = ( +struct[2] || 1 ) - 1; + struct[3] = +struct[3] || 1; + + if ( 'Z' !== struct[8] && undefined !== struct[9] ) { + minutesOffset = struct[10] * 60 + struct[11]; + + if ( '+' === struct[9] ) { + minutesOffset = 0 - minutesOffset; + } + } + + timestamp = Date.UTC( struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7] ); + } else { + timestamp = Date.parse ? Date.parse( date ) : NaN; + } + + return timestamp; + }; + + /** + * Helper function for getting the root URL. + * @return {[type]} [description] + */ + wp.api.utils.getRootUrl = function() { + return window.location.origin ? + window.location.origin + '/' : + window.location.protocol + '/' + window.location.host + '/'; + }; + + /** + * Helper for capitalizing strings. + */ + wp.api.utils.capitalize = function( str ) { + if ( _.isUndefined( str ) ) { + return str; + } + return str.charAt( 0 ).toUpperCase() + str.slice( 1 ); + }; + + /** + * Helper function that capitalizes the first word and camel cases any words starting + * after dashes, removing the dashes. + */ + wp.api.utils.capitalizeAndCamelCaseDashes = function( str ) { + if ( _.isUndefined( str ) ) { + return str; + } + str = wp.api.utils.capitalize( str ); + + return wp.api.utils.camelCaseDashes( str ); + }; + + /** + * Helper function to camel case the letter after dashes, removing the dashes. + */ + wp.api.utils.camelCaseDashes = function( str ) { + return str.replace( /-([a-z])/g, function( g ) { + return g[ 1 ].toUpperCase(); + } ); + }; + + /** + * Extract a route part based on negative index. + * + * @param {string} route The endpoint route. + * @param {int} part The number of parts from the end of the route to retrieve. Default 1. + * Example route `/a/b/c`: part 1 is `c`, part 2 is `b`, part 3 is `a`. + * @param {string} [versionString] Version string, defaults to `wp.api.versionString`. + * @param {boolean} [reverse] Whether to reverse the order when extracting the route part. Optional, default false. + */ + wp.api.utils.extractRoutePart = function( route, part, versionString, reverse ) { + var routeParts; + + part = part || 1; + versionString = versionString || wp.api.versionString; + + // Remove versions string from route to avoid returning it. + if ( 0 === route.indexOf( '/' + versionString ) ) { + route = route.substr( versionString.length + 1 ); + } + + routeParts = route.split( '/' ); + if ( reverse ) { + routeParts = routeParts.reverse(); + } + if ( _.isUndefined( routeParts[ --part ] ) ) { + return ''; + } + return routeParts[ part ]; + }; + + /** + * Extract a parent name from a passed route. + * + * @param {string} route The route to extract a name from. + */ + wp.api.utils.extractParentName = function( route ) { + var name, + lastSlash = route.lastIndexOf( '_id>[\\d]+)/' ); + + if ( lastSlash < 0 ) { + return ''; + } + name = route.substr( 0, lastSlash - 1 ); + name = name.split( '/' ); + name.pop(); + name = name.pop(); + return name; + }; + + /** + * Add args and options to a model prototype from a route's endpoints. + * + * @param {array} routeEndpoints Array of route endpoints. + * @param {Object} modelInstance An instance of the model (or collection) + * to add the args to. + */ + wp.api.utils.decorateFromRoute = function( routeEndpoints, modelInstance ) { + + /** + * Build the args based on route endpoint data. + */ + _.each( routeEndpoints, function( routeEndpoint ) { + + // Add post and edit endpoints as model args. + if ( _.includes( routeEndpoint.methods, 'POST' ) || _.includes( routeEndpoint.methods, 'PUT' ) ) { + + // Add any non empty args, merging them into the args object. + if ( ! _.isEmpty( routeEndpoint.args ) ) { + + // Set as default if no args yet. + if ( _.isEmpty( modelInstance.prototype.args ) ) { + modelInstance.prototype.args = routeEndpoint.args; + } else { + + // We already have args, merge these new args in. + modelInstance.prototype.args = _.extend( modelInstance.prototype.args, routeEndpoint.args ); + } + } + } else { + + // Add GET method as model options. + if ( _.includes( routeEndpoint.methods, 'GET' ) ) { + + // Add any non empty args, merging them into the defaults object. + if ( ! _.isEmpty( routeEndpoint.args ) ) { + + // Set as default if no defaults yet. + if ( _.isEmpty( modelInstance.prototype.options ) ) { + modelInstance.prototype.options = routeEndpoint.args; + } else { + + // We already have options, merge these new args in. + modelInstance.prototype.options = _.extend( modelInstance.prototype.options, routeEndpoint.args ); + } + } + + } + } + + } ); + + }; + + /** + * Add mixins and helpers to models depending on their defaults. + * + * @param {Backbone Model} model The model to attach helpers and mixins to. + * @param {string} modelClassName The classname of the constructed model. + * @param {Object} loadingObjects An object containing the models and collections we are building. + */ + wp.api.utils.addMixinsAndHelpers = function( model, modelClassName, loadingObjects ) { + + var hasDate = false, + + /** + * Array of parseable dates. + * + * @type {string[]}. + */ + parseableDates = [ 'date', 'modified', 'date_gmt', 'modified_gmt' ], + + /** + * Mixin for all content that is time stamped. + * + * This mixin converts between mysql timestamps and JavaScript Dates when syncing a model + * to or from the server. For example, a date stored as `2015-12-27T21:22:24` on the server + * gets expanded to `Sun Dec 27 2015 14:22:24 GMT-0700 (MST)` when the model is fetched. + * + * @type {{toJSON: toJSON, parse: parse}}. + */ + TimeStampedMixin = { + + /** + * Prepare a JavaScript Date for transmitting to the server. + * + * This helper function accepts a field and Date object. It converts the passed Date + * to an ISO string and sets that on the model field. + * + * @param {Date} date A JavaScript date object. WordPress expects dates in UTC. + * @param {string} field The date field to set. One of 'date', 'date_gmt', 'date_modified' + * or 'date_modified_gmt'. Optional, defaults to 'date'. + */ + setDate: function( date, field ) { + var theField = field || 'date'; + + // Don't alter non parsable date fields. + if ( _.indexOf( parseableDates, theField ) < 0 ) { + return false; + } + + this.set( theField, date.toISOString() ); + }, + + /** + * Get a JavaScript Date from the passed field. + * + * WordPress returns 'date' and 'date_modified' in the timezone of the server as well as + * UTC dates as 'date_gmt' and 'date_modified_gmt'. Draft posts do not include UTC dates. + * + * @param {string} field The date field to set. One of 'date', 'date_gmt', 'date_modified' + * or 'date_modified_gmt'. Optional, defaults to 'date'. + */ + getDate: function( field ) { + var theField = field || 'date', + theISODate = this.get( theField ); + + // Only get date fields and non null values. + if ( _.indexOf( parseableDates, theField ) < 0 || _.isNull( theISODate ) ) { + return false; + } + + return new Date( wp.api.utils.parseISO8601( theISODate ) ); + } + }, + + /** + * Build a helper function to retrieve related model. + * + * @param {string} parentModel The parent model. + * @param {int} modelId The model ID if the object to request + * @param {string} modelName The model name to use when constructing the model. + * @param {string} embedSourcePoint Where to check the embedds object for _embed data. + * @param {string} embedCheckField Which model field to check to see if the model has data. + * + * @return {Deferred.promise} A promise which resolves to the constructed model. + */ + buildModelGetter = function( parentModel, modelId, modelName, embedSourcePoint, embedCheckField ) { + var getModel, embeddeds, attributes, deferred; + + deferred = jQuery.Deferred(); + embeddeds = parentModel.get( '_embedded' ) || {}; + + // Verify that we have a valid object id. + if ( ! _.isNumber( modelId ) || 0 === modelId ) { + deferred.reject(); + return deferred; + } + + // If we have embedded object data, use that when constructing the getModel. + if ( embeddeds[ embedSourcePoint ] ) { + attributes = _.findWhere( embeddeds[ embedSourcePoint ], { id: modelId } ); + } + + // Otherwise use the modelId. + if ( ! attributes ) { + attributes = { id: modelId }; + } + + // Create the new getModel model. + getModel = new wp.api.models[ modelName ]( attributes ); + + if ( ! getModel.get( embedCheckField ) ) { + getModel.fetch( { + success: function( getModel ) { + deferred.resolve( getModel ); + }, + error: function( getModel, response ) { + deferred.reject( response ); + } + } ); + } else { + // Resolve with the embedded model. + deferred.resolve( getModel ); + } + + // Return a promise. + return deferred.promise(); + }, + + /** + * Build a helper to retrieve a collection. + * + * @param {string} parentModel The parent model. + * @param {string} collectionName The name to use when constructing the collection. + * @param {string} embedSourcePoint Where to check the embedds object for _embed data. + * @param {string} embedIndex An addiitonal optional index for the _embed data. + * + * @return {Deferred.promise} A promise which resolves to the constructed collection. + */ + buildCollectionGetter = function( parentModel, collectionName, embedSourcePoint, embedIndex ) { + /** + * Returns a promise that resolves to the requested collection + * + * Uses the embedded data if available, otherwises fetches the + * data from the server. + * + * @return {Deferred.promise} promise Resolves to a wp.api.collections[ collectionName ] + * collection. + */ + var postId, embeddeds, getObjects, + classProperties = '', + properties = '', + deferred = jQuery.Deferred(); + + postId = parentModel.get( 'id' ); + embeddeds = parentModel.get( '_embedded' ) || {}; + + // Verify that we have a valid post id. + if ( ! _.isNumber( postId ) || 0 === postId ) { + deferred.reject(); + return deferred; + } + + // If we have embedded getObjects data, use that when constructing the getObjects. + if ( ! _.isUndefined( embedSourcePoint ) && ! _.isUndefined( embeddeds[ embedSourcePoint ] ) ) { + + // Some embeds also include an index offset, check for that. + if ( _.isUndefined( embedIndex ) ) { + + // Use the embed source point directly. + properties = embeddeds[ embedSourcePoint ]; + } else { + + // Add the index to the embed source point. + properties = embeddeds[ embedSourcePoint ][ embedIndex ]; + } + } else { + + // Otherwise use the postId. + classProperties = { parent: postId }; + } + + // Create the new getObjects collection. + getObjects = new wp.api.collections[ collectionName ]( properties, classProperties ); + + // If we didn’t have embedded getObjects, fetch the getObjects data. + if ( _.isUndefined( getObjects.models[0] ) ) { + getObjects.fetch( { + success: function( getObjects ) { + + // Add a helper 'parent_post' attribute onto the model. + setHelperParentPost( getObjects, postId ); + deferred.resolve( getObjects ); + }, + error: function( getModel, response ) { + deferred.reject( response ); + } + } ); + } else { + + // Add a helper 'parent_post' attribute onto the model. + setHelperParentPost( getObjects, postId ); + deferred.resolve( getObjects ); + } + + // Return a promise. + return deferred.promise(); + + }, + + /** + * Set the model post parent. + */ + setHelperParentPost = function( collection, postId ) { + + // Attach post_parent id to the collection. + _.each( collection.models, function( model ) { + model.set( 'parent_post', postId ); + } ); + }, + + /** + * Add a helper function to handle post Meta. + */ + MetaMixin = { + + /** + * Get meta by key for a post. + * + * @param {string} key The meta key. + * + * @return {object} The post meta value. + */ + getMeta: function( key ) { + var metas = this.get( 'meta' ); + return metas[ key ]; + }, + + /** + * Get all meta key/values for a post. + * + * @return {object} The post metas, as a key value pair object. + */ + getMetas: function() { + return this.get( 'meta' ); + }, + + /** + * Set a group of meta key/values for a post. + * + * @param {object} meta The post meta to set, as key/value pairs. + */ + setMetas: function( meta ) { + var metas = this.get( 'meta' ); + _.extend( metas, meta ); + this.set( 'meta', metas ); + }, + + /** + * Set a single meta value for a post, by key. + * + * @param {string} key The meta key. + * @param {object} value The meta value. + */ + setMeta: function( key, value ) { + var metas = this.get( 'meta' ); + metas[ key ] = value; + this.set( 'meta', metas ); + } + }, + + /** + * Add a helper function to handle post Revisions. + */ + RevisionsMixin = { + getRevisions: function() { + return buildCollectionGetter( this, 'PostRevisions' ); + } + }, + + /** + * Add a helper function to handle post Tags. + */ + TagsMixin = { + + /** + * Get the tags for a post. + * + * @return {Deferred.promise} promise Resolves to an array of tags. + */ + getTags: function() { + var tagIds = this.get( 'tags' ), + tags = new wp.api.collections.Tags(); + + // Resolve with an empty array if no tags. + if ( _.isEmpty( tagIds ) ) { + return jQuery.Deferred().resolve( [] ); + } + + return tags.fetch( { data: { include: tagIds } } ); + }, + + /** + * Set the tags for a post. + * + * Accepts an array of tag slugs, or a Tags collection. + * + * @param {array|Backbone.Collection} tags The tags to set on the post. + * + */ + setTags: function( tags ) { + var allTags, newTag, + self = this, + newTags = []; + + if ( _.isString( tags ) ) { + return false; + } + + // If this is an array of slugs, build a collection. + if ( _.isArray( tags ) ) { + + // Get all the tags. + allTags = new wp.api.collections.Tags(); + allTags.fetch( { + data: { per_page: 100 }, + success: function( alltags ) { + + // Find the passed tags and set them up. + _.each( tags, function( tag ) { + newTag = new wp.api.models.Tag( alltags.findWhere( { slug: tag } ) ); + + // Tie the new tag to the post. + newTag.set( 'parent_post', self.get( 'id' ) ); + + // Add the new tag to the collection. + newTags.push( newTag ); + } ); + tags = new wp.api.collections.Tags( newTags ); + self.setTagsWithCollection( tags ); + } + } ); + + } else { + this.setTagsWithCollection( tags ); + } + }, + + /** + * Set the tags for a post. + * + * Accepts a Tags collection. + * + * @param {array|Backbone.Collection} tags The tags to set on the post. + * + */ + setTagsWithCollection: function( tags ) { + + // Pluck out the category ids. + this.set( 'tags', tags.pluck( 'id' ) ); + return this.save(); + } + }, + + /** + * Add a helper function to handle post Categories. + */ + CategoriesMixin = { + + /** + * Get a the categories for a post. + * + * @return {Deferred.promise} promise Resolves to an array of categories. + */ + getCategories: function() { + var categoryIds = this.get( 'categories' ), + categories = new wp.api.collections.Categories(); + + // Resolve with an empty array if no categories. + if ( _.isEmpty( categoryIds ) ) { + return jQuery.Deferred().resolve( [] ); + } + + return categories.fetch( { data: { include: categoryIds } } ); + }, + + /** + * Set the categories for a post. + * + * Accepts an array of category slugs, or a Categories collection. + * + * @param {array|Backbone.Collection} categories The categories to set on the post. + * + */ + setCategories: function( categories ) { + var allCategories, newCategory, + self = this, + newCategories = []; + + if ( _.isString( categories ) ) { + return false; + } + + // If this is an array of slugs, build a collection. + if ( _.isArray( categories ) ) { + + // Get all the categories. + allCategories = new wp.api.collections.Categories(); + allCategories.fetch( { + data: { per_page: 100 }, + success: function( allcats ) { + + // Find the passed categories and set them up. + _.each( categories, function( category ) { + newCategory = new wp.api.models.Category( allcats.findWhere( { slug: category } ) ); + + // Tie the new category to the post. + newCategory.set( 'parent_post', self.get( 'id' ) ); + + // Add the new category to the collection. + newCategories.push( newCategory ); + } ); + categories = new wp.api.collections.Categories( newCategories ); + self.setCategoriesWithCollection( categories ); + } + } ); + + } else { + this.setCategoriesWithCollection( categories ); + } + + }, + + /** + * Set the categories for a post. + * + * Accepts Categories collection. + * + * @param {array|Backbone.Collection} categories The categories to set on the post. + * + */ + setCategoriesWithCollection: function( categories ) { + + // Pluck out the category ids. + this.set( 'categories', categories.pluck( 'id' ) ); + return this.save(); + } + }, + + /** + * Add a helper function to retrieve the author user model. + */ + AuthorMixin = { + getAuthorUser: function() { + return buildModelGetter( this, this.get( 'author' ), 'User', 'author', 'name' ); + } + }, + + /** + * Add a helper function to retrieve the featured media. + */ + FeaturedMediaMixin = { + getFeaturedMedia: function() { + return buildModelGetter( this, this.get( 'featured_media' ), 'Media', 'wp:featuredmedia', 'source_url' ); + } + }; + + // Exit if we don't have valid model defaults. + if ( _.isUndefined( model.prototype.args ) ) { + return model; + } + + // Go thru the parsable date fields, if our model contains any of them it gets the TimeStampedMixin. + _.each( parseableDates, function( theDateKey ) { + if ( ! _.isUndefined( model.prototype.args[ theDateKey ] ) ) { + hasDate = true; + } + } ); + + // Add the TimeStampedMixin for models that contain a date field. + if ( hasDate ) { + model = model.extend( TimeStampedMixin ); + } + + // Add the AuthorMixin for models that contain an author. + if ( ! _.isUndefined( model.prototype.args.author ) ) { + model = model.extend( AuthorMixin ); + } + + // Add the FeaturedMediaMixin for models that contain a featured_media. + if ( ! _.isUndefined( model.prototype.args.featured_media ) ) { + model = model.extend( FeaturedMediaMixin ); + } + + // Add the CategoriesMixin for models that support categories collections. + if ( ! _.isUndefined( model.prototype.args.categories ) ) { + model = model.extend( CategoriesMixin ); + } + + // Add the MetaMixin for models that support meta. + if ( ! _.isUndefined( model.prototype.args.meta ) ) { + model = model.extend( MetaMixin ); + } + + // Add the TagsMixin for models that support tags collections. + if ( ! _.isUndefined( model.prototype.args.tags ) ) { + model = model.extend( TagsMixin ); + } + + // Add the RevisionsMixin for models that support revisions collections. + if ( ! _.isUndefined( loadingObjects.collections[ modelClassName + 'Revisions' ] ) ) { + model = model.extend( RevisionsMixin ); + } + + return model; + }; + +})( window ); + +/* global wpApiSettings:false */ + +// Suppress warning about parse function's unused "options" argument: +/* jshint unused:false */ +(function() { + + 'use strict'; + + var wpApiSettings = window.wpApiSettings || {}, + trashableTypes = [ 'Comment', 'Media', 'Comment', 'Post', 'Page', 'Status', 'Taxonomy', 'Type' ]; + + /** + * Backbone base model for all models. + */ + wp.api.WPApiBaseModel = Backbone.Model.extend( + /** @lends WPApiBaseModel.prototype */ + { + + // Initialize the model. + initialize: function() { + + /** + * Types that don't support trashing require passing ?force=true to delete. + * + */ + if ( -1 === _.indexOf( trashableTypes, this.name ) ) { + this.requireForceForDelete = true; + } + }, + + /** + * Set nonce header before every Backbone sync. + * + * @param {string} method. + * @param {Backbone.Model} model. + * @param {{beforeSend}, *} options. + * @returns {*}. + */ + sync: function( method, model, options ) { + var beforeSend; + + options = options || {}; + + // Remove date_gmt if null. + if ( _.isNull( model.get( 'date_gmt' ) ) ) { + model.unset( 'date_gmt' ); + } + + // Remove slug if empty. + if ( _.isEmpty( model.get( 'slug' ) ) ) { + model.unset( 'slug' ); + } + + if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) { + beforeSend = options.beforeSend; + + // @todo enable option for jsonp endpoints + // options.dataType = 'jsonp'; + + // Include the nonce with requests. + options.beforeSend = function( xhr ) { + xhr.setRequestHeader( 'X-WP-Nonce', model.nonce() ); + + if ( beforeSend ) { + return beforeSend.apply( this, arguments ); + } + }; + + // Update the nonce when a new nonce is returned with the response. + options.complete = function( xhr ) { + var returnedNonce = xhr.getResponseHeader( 'X-WP-Nonce' ); + + if ( returnedNonce && _.isFunction( model.nonce ) && model.nonce() !== returnedNonce ) { + model.endpointModel.set( 'nonce', returnedNonce ); + } + }; + } + + // Add '?force=true' to use delete method when required. + if ( this.requireForceForDelete && 'delete' === method ) { + model.url = model.url() + '?force=true'; + } + return Backbone.sync( method, model, options ); + }, + + /** + * Save is only allowed when the PUT OR POST methods are available for the endpoint. + */ + save: function( attrs, options ) { + + // Do we have the put method, then execute the save. + if ( _.includes( this.methods, 'PUT' ) || _.includes( this.methods, 'POST' ) ) { + + // Proxy the call to the original save function. + return Backbone.Model.prototype.save.call( this, attrs, options ); + } else { + + // Otherwise bail, disallowing action. + return false; + } + }, + + /** + * Delete is only allowed when the DELETE method is available for the endpoint. + */ + destroy: function( options ) { + + // Do we have the DELETE method, then execute the destroy. + if ( _.includes( this.methods, 'DELETE' ) ) { + + // Proxy the call to the original save function. + return Backbone.Model.prototype.destroy.call( this, options ); + } else { + + // Otherwise bail, disallowing action. + return false; + } + } + + } + ); + + /** + * API Schema model. Contains meta information about the API. + */ + wp.api.models.Schema = wp.api.WPApiBaseModel.extend( + /** @lends Schema.prototype */ + { + defaults: { + _links: {}, + namespace: null, + routes: {} + }, + + initialize: function( attributes, options ) { + var model = this; + options = options || {}; + + wp.api.WPApiBaseModel.prototype.initialize.call( model, attributes, options ); + + model.apiRoot = options.apiRoot || wpApiSettings.root; + model.versionString = options.versionString || wpApiSettings.versionString; + }, + + url: function() { + return this.apiRoot + this.versionString; + } + } + ); +})(); + +( function() { + + 'use strict'; + + var wpApiSettings = window.wpApiSettings || {}; + + /** + * Contains basic collection functionality such as pagination. + */ + wp.api.WPApiBaseCollection = Backbone.Collection.extend( + /** @lends BaseCollection.prototype */ + { + + /** + * Setup default state. + */ + initialize: function( models, options ) { + this.state = { + data: {}, + currentPage: null, + totalPages: null, + totalObjects: null + }; + if ( _.isUndefined( options ) ) { + this.parent = ''; + } else { + this.parent = options.parent; + } + }, + + /** + * Extend Backbone.Collection.sync to add nince and pagination support. + * + * Set nonce header before every Backbone sync. + * + * @param {string} method. + * @param {Backbone.Model} model. + * @param {{success}, *} options. + * @returns {*}. + */ + sync: function( method, model, options ) { + var beforeSend, success, + self = this; + + options = options || {}; + + if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) { + beforeSend = options.beforeSend; + + // Include the nonce with requests. + options.beforeSend = function( xhr ) { + xhr.setRequestHeader( 'X-WP-Nonce', model.nonce() ); + + if ( beforeSend ) { + return beforeSend.apply( self, arguments ); + } + }; + + // Update the nonce when a new nonce is returned with the response. + options.complete = function( xhr ) { + var returnedNonce = xhr.getResponseHeader( 'X-WP-Nonce' ); + + if ( returnedNonce && _.isFunction( model.nonce ) && model.nonce() !== returnedNonce ) { + model.endpointModel.set( 'nonce', returnedNonce ); + } + }; + } + + // When reading, add pagination data. + if ( 'read' === method ) { + if ( options.data ) { + self.state.data = _.clone( options.data ); + + delete self.state.data.page; + } else { + self.state.data = options.data = {}; + } + + if ( 'undefined' === typeof options.data.page ) { + self.state.currentPage = null; + self.state.totalPages = null; + self.state.totalObjects = null; + } else { + self.state.currentPage = options.data.page - 1; + } + + success = options.success; + options.success = function( data, textStatus, request ) { + if ( ! _.isUndefined( request ) ) { + self.state.totalPages = parseInt( request.getResponseHeader( 'x-wp-totalpages' ), 10 ); + self.state.totalObjects = parseInt( request.getResponseHeader( 'x-wp-total' ), 10 ); + } + + if ( null === self.state.currentPage ) { + self.state.currentPage = 1; + } else { + self.state.currentPage++; + } + + if ( success ) { + return success.apply( this, arguments ); + } + }; + } + + // Continue by calling Bacckbone's sync. + return Backbone.sync( method, model, options ); + }, + + /** + * Fetches the next page of objects if a new page exists. + * + * @param {data: {page}} options. + * @returns {*}. + */ + more: function( options ) { + options = options || {}; + options.data = options.data || {}; + + _.extend( options.data, this.state.data ); + + if ( 'undefined' === typeof options.data.page ) { + if ( ! this.hasMore() ) { + return false; + } + + if ( null === this.state.currentPage || this.state.currentPage <= 1 ) { + options.data.page = 2; + } else { + options.data.page = this.state.currentPage + 1; + } + } + + return this.fetch( options ); + }, + + /** + * Returns true if there are more pages of objects available. + * + * @returns null|boolean. + */ + hasMore: function() { + if ( null === this.state.totalPages || + null === this.state.totalObjects || + null === this.state.currentPage ) { + return null; + } else { + return ( this.state.currentPage < this.state.totalPages ); + } + } + } + ); + +} )(); + +( function() { + + 'use strict'; + + var Endpoint, initializedDeferreds = {}, + wpApiSettings = window.wpApiSettings || {}; + + /** @namespace wp */ + window.wp = window.wp || {}; + + /** @namespace wp.api */ + wp.api = wp.api || {}; + + // If wpApiSettings is unavailable, try the default. + if ( _.isEmpty( wpApiSettings ) ) { + wpApiSettings.root = window.location.origin + '/wp-json/'; + } + + Endpoint = Backbone.Model.extend(/** @lends Endpoint.prototype */{ + defaults: { + apiRoot: wpApiSettings.root, + versionString: wp.api.versionString, + nonce: null, + schema: null, + models: {}, + collections: {} + }, + + /** + * Initialize the Endpoint model. + */ + initialize: function() { + var model = this, deferred; + + Backbone.Model.prototype.initialize.apply( model, arguments ); + + deferred = jQuery.Deferred(); + model.schemaConstructed = deferred.promise(); + + model.schemaModel = new wp.api.models.Schema( null, { + apiRoot: model.get( 'apiRoot' ), + versionString: model.get( 'versionString' ), + nonce: model.get( 'nonce' ) + } ); + + // When the model loads, resolve the promise. + model.schemaModel.once( 'change', function() { + model.constructFromSchema(); + deferred.resolve( model ); + } ); + + if ( model.get( 'schema' ) ) { + + // Use schema supplied as model attribute. + model.schemaModel.set( model.schemaModel.parse( model.get( 'schema' ) ) ); + } else if ( + ! _.isUndefined( sessionStorage ) && + ( _.isUndefined( wpApiSettings.cacheSchema ) || wpApiSettings.cacheSchema ) && + sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) ) + ) { + + // Used a cached copy of the schema model if available. + model.schemaModel.set( model.schemaModel.parse( JSON.parse( sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) ) ) ) ); + } else { + model.schemaModel.fetch( { + /** + * When the server returns the schema model data, store the data in a sessionCache so we don't + * have to retrieve it again for this session. Then, construct the models and collections based + * on the schema model data. + * + * @callback + */ + success: function( newSchemaModel ) { + + // Store a copy of the schema model in the session cache if available. + if ( ! _.isUndefined( sessionStorage ) && ( _.isUndefined( wpApiSettings.cacheSchema ) || wpApiSettings.cacheSchema ) ) { + try { + sessionStorage.setItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ), JSON.stringify( newSchemaModel ) ); + } catch ( error ) { + + // Fail silently, fixes errors in safari private mode. + } + } + }, + + // Log the error condition. + error: function( err ) { + window.console.log( err ); + } + } ); + } + }, + + constructFromSchema: function() { + var routeModel = this, modelRoutes, collectionRoutes, schemaRoot, loadingObjects, + + /** + * Set up the model and collection name mapping options. As the schema is built, the + * model and collection names will be adjusted if they are found in the mapping object. + * + * Localizing a variable wpApiSettings.mapping will over-ride the default mapping options. + * + */ + mapping = wpApiSettings.mapping || { + models: { + 'Categories': 'Category', + 'Comments': 'Comment', + 'Pages': 'Page', + 'PagesMeta': 'PageMeta', + 'PagesRevisions': 'PageRevision', + 'Posts': 'Post', + 'PostsCategories': 'PostCategory', + 'PostsRevisions': 'PostRevision', + 'PostsTags': 'PostTag', + 'Schema': 'Schema', + 'Statuses': 'Status', + 'Tags': 'Tag', + 'Taxonomies': 'Taxonomy', + 'Types': 'Type', + 'Users': 'User' + }, + collections: { + 'PagesMeta': 'PageMeta', + 'PagesRevisions': 'PageRevisions', + 'PostsCategories': 'PostCategories', + 'PostsMeta': 'PostMeta', + 'PostsRevisions': 'PostRevisions', + 'PostsTags': 'PostTags' + } + }, + + modelEndpoints = routeModel.get( 'modelEndpoints' ), + modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' ); + + /** + * Iterate thru the routes, picking up models and collections to build. Builds two arrays, + * one for models and one for collections. + */ + modelRoutes = []; + collectionRoutes = []; + schemaRoot = routeModel.get( 'apiRoot' ).replace( wp.api.utils.getRootUrl(), '' ); + loadingObjects = {}; + + /** + * Tracking objects for models and collections. + */ + loadingObjects.models = {}; + loadingObjects.collections = {}; + + _.each( routeModel.schemaModel.get( 'routes' ), function( route, index ) { + + // Skip the schema root if included in the schema. + if ( index !== routeModel.get( ' versionString' ) && + index !== schemaRoot && + index !== ( '/' + routeModel.get( 'versionString' ).slice( 0, -1 ) ) + ) { + + // Single items end with a regex, or a special case word. + if ( modelRegex.test( index ) ) { + modelRoutes.push( { index: index, route: route } ); + } else { + + // Collections end in a name. + collectionRoutes.push( { index: index, route: route } ); + } + } + } ); + + /** + * Construct the models. + * + * Base the class name on the route endpoint. + */ + _.each( modelRoutes, function( modelRoute ) { + + // Extract the name and any parent from the route. + var modelClassName, + routeName = wp.api.utils.extractRoutePart( modelRoute.index, 2, routeModel.get( 'versionString' ), true ), + parentName = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), false ), + routeEnd = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), true ); + + // Clear the parent part of the rouite if its actually the version string. + if ( parentName === routeModel.get( 'versionString' ) ) { + parentName = ''; + } + + // Handle the special case of the 'me' route. + if ( 'me' === routeEnd ) { + routeName = 'me'; + } + + // If the model has a parent in its route, add that to its class name. + if ( '' !== parentName && parentName !== routeName ) { + modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); + modelClassName = mapping.models[ modelClassName ] || modelClassName; + loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { + + // Return a constructed url based on the parent and id. + url: function() { + var url = + routeModel.get( 'apiRoot' ) + + routeModel.get( 'versionString' ) + + parentName + '/' + + ( ( _.isUndefined( this.get( 'parent' ) ) || 0 === this.get( 'parent' ) ) ? + ( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) : + this.get( 'parent' ) + '/' ) + + routeName; + + if ( ! _.isUndefined( this.get( 'id' ) ) ) { + url += '/' + this.get( 'id' ); + } + return url; + }, + + // Track nonces on the Endpoint 'routeModel'. + nonce: function() { + return routeModel.get( 'nonce' ); + }, + + endpointModel: routeModel, + + // Include a reference to the original route object. + route: modelRoute, + + // Include a reference to the original class name. + name: modelClassName, + + // Include the array of route methods for easy reference. + methods: modelRoute.route.methods, + + // Include the array of route endpoints for easy reference. + endpoints: modelRoute.route.endpoints + } ); + } else { + + // This is a model without a parent in its route + modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); + modelClassName = mapping.models[ modelClassName ] || modelClassName; + loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { + + // Function that returns a constructed url based on the id. + url: function() { + var url = routeModel.get( 'apiRoot' ) + + routeModel.get( 'versionString' ) + + ( ( 'me' === routeName ) ? 'users/me' : routeName ); + + if ( ! _.isUndefined( this.get( 'id' ) ) ) { + url += '/' + this.get( 'id' ); + } + return url; + }, + + // Track nonces at the Endpoint level. + nonce: function() { + return routeModel.get( 'nonce' ); + }, + + endpointModel: routeModel, + + // Include a reference to the original route object. + route: modelRoute, + + // Include a reference to the original class name. + name: modelClassName, + + // Include the array of route methods for easy reference. + methods: modelRoute.route.methods, + + // Include the array of route endpoints for easy reference. + endpoints: modelRoute.route.endpoints + } ); + } + + // Add defaults to the new model, pulled form the endpoint. + wp.api.utils.decorateFromRoute( + modelRoute.route.endpoints, + loadingObjects.models[ modelClassName ], + routeModel.get( 'versionString' ) + ); + + } ); + + /** + * Construct the collections. + * + * Base the class name on the route endpoint. + */ + _.each( collectionRoutes, function( collectionRoute ) { + + // Extract the name and any parent from the route. + var collectionClassName, modelClassName, + routeName = collectionRoute.index.slice( collectionRoute.index.lastIndexOf( '/' ) + 1 ), + parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 1, routeModel.get( 'versionString' ), false ); + + // If the collection has a parent in its route, add that to its class name. + if ( '' !== parentName && parentName !== routeName && routeModel.get( 'versionString' ) !== parentName ) { + + collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); + modelClassName = mapping.models[ collectionClassName ] || collectionClassName; + collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName; + loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( { + + // Function that returns a constructed url passed on the parent. + url: function() { + return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + + parentName + '/' + this.parent + '/' + + routeName; + }, + + // Specify the model that this collection contains. + model: function( attrs, options ) { + return new loadingObjects.models[ modelClassName ]( attrs, options ); + }, + + // Track nonces at the Endpoint level. + nonce: function() { + return routeModel.get( 'nonce' ); + }, + + endpointModel: routeModel, + + // Include a reference to the original class name. + name: collectionClassName, + + // Include a reference to the original route object. + route: collectionRoute, + + // Include the array of route methods for easy reference. + methods: collectionRoute.route.methods + } ); + } else { + + // This is a collection without a parent in its route. + collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); + modelClassName = mapping.models[ collectionClassName ] || collectionClassName; + collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName; + loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( { + + // For the url of a root level collection, use a string. + url: function() { + return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName; + }, + + // Specify the model that this collection contains. + model: function( attrs, options ) { + return new loadingObjects.models[ modelClassName ]( attrs, options ); + }, + + // Track nonces at the Endpoint level. + nonce: function() { + return routeModel.get( 'nonce' ); + }, + + endpointModel: routeModel, + + // Include a reference to the original class name. + name: collectionClassName, + + // Include a reference to the original route object. + route: collectionRoute, + + // Include the array of route methods for easy reference. + methods: collectionRoute.route.methods + } ); + } + + // Add defaults to the new model, pulled form the endpoint. + wp.api.utils.decorateFromRoute( collectionRoute.route.endpoints, loadingObjects.collections[ collectionClassName ] ); + } ); + + // Add mixins and helpers for each of the models. + _.each( loadingObjects.models, function( model, index ) { + loadingObjects.models[ index ] = wp.api.utils.addMixinsAndHelpers( model, index, loadingObjects ); + } ); + + // Set the routeModel models and collections. + routeModel.set( 'models', loadingObjects.models ); + routeModel.set( 'collections', loadingObjects.collections ); + + } + + } ); + + wp.api.endpoints = new Backbone.Collection(); + + /** + * Initialize the wp-api, optionally passing the API root. + * + * @param {object} [args] + * @param {string} [args.nonce] The nonce. Optional, defaults to wpApiSettings.nonce. + * @param {string} [args.apiRoot] The api root. Optional, defaults to wpApiSettings.root. + * @param {string} [args.versionString] The version string. Optional, defaults to wpApiSettings.root. + * @param {object} [args.schema] The schema. Optional, will be fetched from API if not provided. + */ + wp.api.init = function( args ) { + var endpoint, attributes = {}, deferred, promise; + + args = args || {}; + attributes.nonce = _.isString( args.nonce ) ? args.nonce : ( wpApiSettings.nonce || '' ); + attributes.apiRoot = args.apiRoot || wpApiSettings.root || '/wp-json'; + attributes.versionString = args.versionString || wpApiSettings.versionString || 'wp/v2/'; + attributes.schema = args.schema || null; + attributes.modelEndpoints = args.modelEndpoints || [ 'me', 'settings' ]; + if ( ! attributes.schema && attributes.apiRoot === wpApiSettings.root && attributes.versionString === wpApiSettings.versionString ) { + attributes.schema = wpApiSettings.schema; + } + + if ( ! initializedDeferreds[ attributes.apiRoot + attributes.versionString ] ) { + + // Look for an existing copy of this endpoint + endpoint = wp.api.endpoints.findWhere( { 'apiRoot': attributes.apiRoot, 'versionString': attributes.versionString } ); + if ( ! endpoint ) { + endpoint = new Endpoint( attributes ); + } + deferred = jQuery.Deferred(); + promise = deferred.promise(); + + endpoint.schemaConstructed.done( function( resolvedEndpoint ) { + wp.api.endpoints.add( resolvedEndpoint ); + + // Map the default endpoints, extending any already present items (including Schema model). + wp.api.models = _.extend( wp.api.models, resolvedEndpoint.get( 'models' ) ); + wp.api.collections = _.extend( wp.api.collections, resolvedEndpoint.get( 'collections' ) ); + deferred.resolve( resolvedEndpoint ); + } ); + initializedDeferreds[ attributes.apiRoot + attributes.versionString ] = promise; + } + return initializedDeferreds[ attributes.apiRoot + attributes.versionString ]; + }; + + /** + * Construct the default endpoints and add to an endpoints collection. + */ + + // The wp.api.init function returns a promise that will resolve with the endpoint once it is ready. + wp.api.loadPromise = wp.api.init(); + +} )(); diff --git a/backend/wp-includes/js/wp-api.min.js b/backend/wp-includes/js/wp-api.min.js new file mode 100644 index 0000000..d371139 --- /dev/null +++ b/backend/wp-includes/js/wp-api.min.js @@ -0,0 +1 @@ +!function(a,b){"use strict";function c(){this.models={},this.collections={},this.views={}}a.wp=a.wp||{},wp.api=wp.api||new c,wp.api.versionString=wp.api.versionString||"wp/v2/",!_.isFunction(_.includes)&&_.isFunction(_.contains)&&(_.includes=_.contains)}(window),function(a,b){"use strict";var c,d;a.wp=a.wp||{},wp.api=wp.api||{},wp.api.utils=wp.api.utils||{},wp.api.getModelByRoute=function(a){return _.find(wp.api.models,function(b){return b.prototype.route&&a===b.prototype.route.index})},wp.api.getCollectionByRoute=function(a){return _.find(wp.api.collections,function(b){return b.prototype.route&&a===b.prototype.route.index})},Date.prototype.toISOString||(c=function(a){return d=String(a),1===d.length&&(d="0"+d),d},Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+c(this.getUTCMonth()+1)+"-"+c(this.getUTCDate())+"T"+c(this.getUTCHours())+":"+c(this.getUTCMinutes())+":"+c(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}),wp.api.utils.parseISO8601=function(a){var c,d,e,f,g=0,h=[1,4,5,6,7,10,11];if(d=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(a)){for(e=0;f=h[e];++e)d[f]=+d[f]||0;d[2]=(+d[2]||1)-1,d[3]=+d[3]||1,"Z"!==d[8]&&b!==d[9]&&(g=60*d[10]+d[11],"+"===d[9]&&(g=0-g)),c=Date.UTC(d[1],d[2],d[3],d[4],d[5]+g,d[6],d[7])}else c=Date.parse?Date.parse(a):NaN;return c},wp.api.utils.getRootUrl=function(){return a.location.origin?a.location.origin+"/":a.location.protocol+"/"+a.location.host+"/"},wp.api.utils.capitalize=function(a){return _.isUndefined(a)?a:a.charAt(0).toUpperCase()+a.slice(1)},wp.api.utils.capitalizeAndCamelCaseDashes=function(a){return _.isUndefined(a)?a:(a=wp.api.utils.capitalize(a),wp.api.utils.camelCaseDashes(a))},wp.api.utils.camelCaseDashes=function(a){return a.replace(/-([a-z])/g,function(a){return a[1].toUpperCase()})},wp.api.utils.extractRoutePart=function(a,b,c,d){var e;return b=b||1,c=c||wp.api.versionString,0===a.indexOf("/"+c)&&(a=a.substr(c.length+1)),e=a.split("/"),d&&(e=e.reverse()),_.isUndefined(e[--b])?"":e[b]},wp.api.utils.extractParentName=function(a){var b,c=a.lastIndexOf("_id>[\\d]+)/");return c<0?"":(b=a.substr(0,c-1),b=b.split("/"),b.pop(),b=b.pop())},wp.api.utils.decorateFromRoute=function(a,b){_.each(a,function(a){_.includes(a.methods,"POST")||_.includes(a.methods,"PUT")?_.isEmpty(a.args)||(_.isEmpty(b.prototype.args)?b.prototype.args=a.args:b.prototype.args=_.extend(b.prototype.args,a.args)):_.includes(a.methods,"GET")&&(_.isEmpty(a.args)||(_.isEmpty(b.prototype.options)?b.prototype.options=a.args:b.prototype.options=_.extend(b.prototype.options,a.args)))})},wp.api.utils.addMixinsAndHelpers=function(a,b,c){var d=!1,e=["date","modified","date_gmt","modified_gmt"],f={setDate:function(a,b){var c=b||"date";return!(_.indexOf(e,c)<0)&&void this.set(c,a.toISOString())},getDate:function(a){var b=a||"date",c=this.get(b);return!(_.indexOf(e,b)<0||_.isNull(c))&&new Date(wp.api.utils.parseISO8601(c))}},g=function(a,b,c,d,e){var f,g,h,i;return i=jQuery.Deferred(),g=a.get("_embedded")||{},_.isNumber(b)&&0!==b?(g[d]&&(h=_.findWhere(g[d],{id:b})),h||(h={id:b}),f=new wp.api.models[c](h),f.get(e)?i.resolve(f):f.fetch({success:function(a){i.resolve(a)},error:function(a,b){i.reject(b)}}),i.promise()):(i.reject(),i)},h=function(a,b,c,d){var e,f,g,h="",j="",k=jQuery.Deferred();return e=a.get("id"),f=a.get("_embedded")||{},_.isNumber(e)&&0!==e?(_.isUndefined(c)||_.isUndefined(f[c])?h={parent:e}:j=_.isUndefined(d)?f[c]:f[c][d],g=new wp.api.collections[b](j,h),_.isUndefined(g.models[0])?g.fetch({success:function(a){i(a,e),k.resolve(a)},error:function(a,b){k.reject(b)}}):(i(g,e),k.resolve(g)),k.promise()):(k.reject(),k)},i=function(a,b){_.each(a.models,function(a){a.set("parent_post",b)})},j={getMeta:function(a){var b=this.get("meta");return b[a]},getMetas:function(){return this.get("meta")},setMetas:function(a){var b=this.get("meta");_.extend(b,a),this.set("meta",b)},setMeta:function(a,b){var c=this.get("meta");c[a]=b,this.set("meta",c)}},k={getRevisions:function(){return h(this,"PostRevisions")}},l={getTags:function(){var a=this.get("tags"),b=new wp.api.collections.Tags;return _.isEmpty(a)?jQuery.Deferred().resolve([]):b.fetch({data:{include:a}})},setTags:function(a){var b,c,d=this,e=[];return!_.isString(a)&&void(_.isArray(a)?(b=new wp.api.collections.Tags,b.fetch({data:{per_page:100},success:function(b){_.each(a,function(a){c=new wp.api.models.Tag(b.findWhere({slug:a})),c.set("parent_post",d.get("id")),e.push(c)}),a=new wp.api.collections.Tags(e),d.setTagsWithCollection(a)}})):this.setTagsWithCollection(a))},setTagsWithCollection:function(a){return this.set("tags",a.pluck("id")),this.save()}},m={getCategories:function(){var a=this.get("categories"),b=new wp.api.collections.Categories;return _.isEmpty(a)?jQuery.Deferred().resolve([]):b.fetch({data:{include:a}})},setCategories:function(a){var b,c,d=this,e=[];return!_.isString(a)&&void(_.isArray(a)?(b=new wp.api.collections.Categories,b.fetch({data:{per_page:100},success:function(b){_.each(a,function(a){c=new wp.api.models.Category(b.findWhere({slug:a})),c.set("parent_post",d.get("id")),e.push(c)}),a=new wp.api.collections.Categories(e),d.setCategoriesWithCollection(a)}})):this.setCategoriesWithCollection(a))},setCategoriesWithCollection:function(a){return this.set("categories",a.pluck("id")),this.save()}},n={getAuthorUser:function(){return g(this,this.get("author"),"User","author","name")}},o={getFeaturedMedia:function(){return g(this,this.get("featured_media"),"Media","wp:featuredmedia","source_url")}};return _.isUndefined(a.prototype.args)?a:(_.each(e,function(b){_.isUndefined(a.prototype.args[b])||(d=!0)}),d&&(a=a.extend(f)),_.isUndefined(a.prototype.args.author)||(a=a.extend(n)),_.isUndefined(a.prototype.args.featured_media)||(a=a.extend(o)),_.isUndefined(a.prototype.args.categories)||(a=a.extend(m)),_.isUndefined(a.prototype.args.meta)||(a=a.extend(j)),_.isUndefined(a.prototype.args.tags)||(a=a.extend(l)),_.isUndefined(c.collections[b+"Revisions"])||(a=a.extend(k)),a)}}(window),function(){"use strict";var a=window.wpApiSettings||{},b=["Comment","Media","Comment","Post","Page","Status","Taxonomy","Type"];wp.api.WPApiBaseModel=Backbone.Model.extend({initialize:function(){-1===_.indexOf(b,this.name)&&(this.requireForceForDelete=!0)},sync:function(a,b,c){var d;return c=c||{},_.isNull(b.get("date_gmt"))&&b.unset("date_gmt"),_.isEmpty(b.get("slug"))&&b.unset("slug"),_.isFunction(b.nonce)&&!_.isEmpty(b.nonce())&&(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",b.nonce()),d)return d.apply(this,arguments)},c.complete=function(a){var c=a.getResponseHeader("X-WP-Nonce");c&&_.isFunction(b.nonce)&&b.nonce()!==c&&b.endpointModel.set("nonce",c)}),this.requireForceForDelete&&"delete"===a&&(b.url=b.url()+"?force=true"),Backbone.sync(a,b,c)},save:function(a,b){return!(!_.includes(this.methods,"PUT")&&!_.includes(this.methods,"POST"))&&Backbone.Model.prototype.save.call(this,a,b)},destroy:function(a){return!!_.includes(this.methods,"DELETE")&&Backbone.Model.prototype.destroy.call(this,a)}}),wp.api.models.Schema=wp.api.WPApiBaseModel.extend({defaults:{_links:{},namespace:null,routes:{}},initialize:function(b,c){var d=this;c=c||{},wp.api.WPApiBaseModel.prototype.initialize.call(d,b,c),d.apiRoot=c.apiRoot||a.root,d.versionString=c.versionString||a.versionString},url:function(){return this.apiRoot+this.versionString}})}(),function(){"use strict";window.wpApiSettings||{};wp.api.WPApiBaseCollection=Backbone.Collection.extend({initialize:function(a,b){this.state={data:{},currentPage:null,totalPages:null,totalObjects:null},_.isUndefined(b)?this.parent="":this.parent=b.parent},sync:function(a,b,c){var d,e,f=this;return c=c||{},_.isFunction(b.nonce)&&!_.isEmpty(b.nonce())&&(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",b.nonce()),d)return d.apply(f,arguments)},c.complete=function(a){var c=a.getResponseHeader("X-WP-Nonce");c&&_.isFunction(b.nonce)&&b.nonce()!==c&&b.endpointModel.set("nonce",c)}),"read"===a&&(c.data?(f.state.data=_.clone(c.data),delete f.state.data.page):f.state.data=c.data={},"undefined"==typeof c.data.page?(f.state.currentPage=null,f.state.totalPages=null,f.state.totalObjects=null):f.state.currentPage=c.data.page-1,e=c.success,c.success=function(a,b,c){if(_.isUndefined(c)||(f.state.totalPages=parseInt(c.getResponseHeader("x-wp-totalpages"),10),f.state.totalObjects=parseInt(c.getResponseHeader("x-wp-total"),10)),null===f.state.currentPage?f.state.currentPage=1:f.state.currentPage++,e)return e.apply(this,arguments)}),Backbone.sync(a,b,c)},more:function(a){if(a=a||{},a.data=a.data||{},_.extend(a.data,this.state.data),"undefined"==typeof a.data.page){if(!this.hasMore())return!1;null===this.state.currentPage||this.state.currentPage<=1?a.data.page=2:a.data.page=this.state.currentPage+1}return this.fetch(a)},hasMore:function(){return null===this.state.totalPages||null===this.state.totalObjects||null===this.state.currentPage?null:this.state.currentPage').attr( 'title', noframe.text() ); + frame.on( 'load', function() { + var height, body; + + loaded = true; + // Remove the spinner to avoid unnecessary CPU/GPU usage. + form.removeClass( 'loading' ); + + try { + body = $(this).contents().find('body'); + height = body.height(); + } catch(e) { + wrap.addClass('fallback'); + parent.css( 'max-height', '' ); + form.remove(); + noframe.focus(); + return; + } + + if ( height ) { + if ( body && body.hasClass('interim-login-success') ) + hide(); + else + parent.css( 'max-height', height + 40 + 'px' ); + } else if ( ! body || ! body.length ) { + // Catch "silent" iframe origin exceptions in WebKit after another page is loaded in the iframe + wrap.addClass('fallback'); + parent.css( 'max-height', '' ); + form.remove(); + noframe.focus(); + } + }).attr( 'src', form.data('src') ); + + form.append( frame ); + } + + $( 'body' ).addClass( 'modal-open' ); + wrap.removeClass('hidden'); + + if ( frame ) { + frame.focus(); + // WebKit doesn't throw an error if the iframe fails to load because of "X-Frame-Options: DENY" header. + // Wait for 10 sec. and switch to the fallback text. + setTimeout( function() { + if ( ! loaded ) { + wrap.addClass('fallback'); + form.remove(); + noframe.focus(); + } + }, 10000 ); + } else { + noframe.focus(); + } + } + + function hide() { + $(window).off( 'beforeunload.wp-auth-check' ); + + // When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces + if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) && + typeof wp !== 'undefined' && wp.heartbeat ) { + + $(document).off( 'heartbeat-tick.wp-auth-check' ); + wp.heartbeat.connectNow(); + } + + wrap.fadeOut( 200, function() { + wrap.addClass('hidden').css('display', ''); + $('#wp-auth-check-frame').remove(); + $( 'body' ).removeClass( 'modal-open' ); + }); + } + + function schedule() { + var interval = parseInt( window.authcheckL10n.interval, 10 ) || 180; // in seconds, default 3 min. + next = ( new Date() ).getTime() + ( interval * 1000 ); + } + + $( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) { + if ( 'wp-auth-check' in data ) { + schedule(); + if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) { + show(); + } else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) { + hide(); + } + } + }).on( 'heartbeat-send.wp-auth-check', function( e, data ) { + if ( ( new Date() ).getTime() > next ) { + data['wp-auth-check'] = true; + } + }).ready( function() { + schedule(); + wrap = $('#wp-auth-check-wrap'); + wrap.find('.wp-auth-check-close').on( 'click', function() { + hide(); + }); + }); + +}(jQuery)); diff --git a/backend/wp-includes/js/wp-auth-check.min.js b/backend/wp-includes/js/wp-auth-check.min.js new file mode 100644 index 0000000..9a80b3e --- /dev/null +++ b/backend/wp-includes/js/wp-auth-check.min.js @@ -0,0 +1 @@ +!function(a){function b(){var b,d=a("#wp-auth-check"),f=a("#wp-auth-check-form"),g=e.find(".wp-auth-fallback-expired"),h=!1;f.length&&(a(window).on("beforeunload.wp-auth-check",function(a){a.originalEvent.returnValue=window.authcheckL10n.beforeunload}),b=a('"},i=function(a){var b='';return a.poster&&(b+=''),b+=""},j=function(a,b){return b?b(a):'"},k=function(a,b){return b?b(a):'"},l=function(a){return''},m=function(m,n){var o=a.extend({},n);if(!o.source1&&(a.extend(o,c.htmlToData(b.getScripts(m),o.embed)),!o.source1))return"";if(o.source2||(o.source2=""),o.poster||(o.poster=""),o.source1=m.convertURL(o.source1,"source"),o.source2=m.convertURL(o.source2,"source"),o.source1mime=d.guess(o.source1),o.source2mime=d.guess(o.source2),o.poster=m.convertURL(o.poster,"poster"),a.each(f.urlPatterns,function(a){var b,c,d=a.regex.exec(o.source1);if(d){for(c=a.url,b=0;d[b];b++)c=c.replace("$"+b,function(){return d[b]});o.source1=c,o.type=a.type,o.allowFullscreen=a.allowFullscreen,o.width=o.width||a.w,o.height=o.height||a.h}}),o.embed)return e.updateHtml(o.embed,o,!0);var p=g.getVideoScriptMatch(b.getScripts(m),o.source1);p&&(o.type="script",o.width=p.width,o.height=p.height);var q=b.getAudioTemplateCallback(m),r=b.getVideoTemplateCallback(m);return o.width=o.width||300,o.height=o.height||150,a.each(o,function(a,b){o[b]=m.dom.encode(a)}),"iframe"===o.type?h(o):"application/x-shockwave-flash"===o.source1mime?i(o):o.source1mime.indexOf("audio")!==-1?j(o,q):"script"===o.type?l(o):k(o,r)};return{dataToHtml:m}}),g("i",["q","g","r"],function(a,b,c){var d={},e=function(b,c,e){return new a(function(a,f){var g=function(e){return e.html&&(d[b.source1]=e),a({url:b.source1,html:e.html?e.html:c(b)})};d[b.source1]?g(d[b.source1]):e({url:b.source1},g,f)})},f=function(b,c){return new a(function(a){a({html:c(b),url:b.source1})})},g=function(a){return function(b){return c.dataToHtml(a,b)}},h=function(a,c){var d=b.getUrlResolver(a);return d?e(c,g(a),d):f(c,g(a))},i=function(a){return d.hasOwnProperty(a)};return{getEmbedHtml:h,isCached:i}}),g("o",[],function(){var a=function(a,b){a.state.set("oldVal",a.value()),b.state.set("oldVal",b.value())},b=function(a,b){var c=a.find("#width")[0],d=a.find("#height")[0],e=a.find("#constrain")[0];c&&d&&e&&b(c,d,e.checked())},c=function(b,c,d){var e=b.state.get("oldVal"),f=c.state.get("oldVal"),g=b.value(),h=c.value();d&&e&&f&&g&&h&&(g!==e?(h=Math.round(g/e*h),isNaN(h)||c.value(h)):(g=Math.round(h/f*g),isNaN(g)||b.value(g))),a(b,c)},d=function(c){b(c,a)},e=function(a){b(a,c)},f=function(a){var b=function(){a(function(a){e(a)})};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:b,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:b,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}};return{createUi:f,syncSize:d,updateSize:e}}),g("9",["f","b","g","h","i","j","e","o"],function(a,b,c,d,e,f,g,h){var i=a.ie&&a.ie<=8?"onChange":"onInput",j=function(a){return function(b){var c=b&&b.msg?"Media embed handler error: "+b.msg:"Media embed handler threw unknown error.";a.notificationManager.open({type:"error",text:c})}},k=function(a){var b=a.selection.getNode(),e=b.getAttribute("data-ephox-embed-iri");return e?{source1:e,"data-ephox-embed-iri":e,width:f.getMaxWidth(b),height:f.getMaxHeight(b)}:b.getAttribute("data-mce-object")?d.htmlToData(c.getScripts(a),a.serializer.serialize(b,{selection:!0})):{}},l=function(a){var b=a.selection.getNode();if(b.getAttribute("data-mce-object")||b.getAttribute("data-ephox-embed-iri"))return a.selection.getContent()},m=function(a,e){return function(f){var g=f.html,i=a.find("#embed")[0],j=b.extend(d.htmlToData(c.getScripts(e),g),{source1:f.url});a.fromJSON(j),i&&(i.value(g),h.updateSize(a))}},n=function(a,b){var c,d,e=a.dom.select("img[data-mce-object]");for(c=0;c=0;d--)b[c]===e[d]&&e.splice(d,1);a.selection.select(e[0])},o=function(a,b){var c=a.dom.select("img[data-mce-object]");a.insertContent(b),n(a,c),a.nodeChanged()},p=function(a,b){var c=a.toJSON();c.embed=g.updateHtml(c.embed,c),c.embed&&e.isCached(c.source1)?o(b,c.embed):e.getEmbedHtml(b,c).then(function(a){o(b,a.html)})["catch"](j(b))},q=function(a,c){b.each(c,function(b,c){a.find("#"+c).value(b)})},r=function(a){var f,n,o=[{name:"source1",type:"filepicker",filetype:"media",size:40,autofocus:!0,label:"Source",onpaste:function(){setTimeout(function(){e.getEmbedHtml(a,f.toJSON()).then(m(f,a))["catch"](j(a))},1)},onchange:function(b){e.getEmbedHtml(a,f.toJSON()).then(m(f,a))["catch"](j(a)),q(f,b.meta)},onbeforecall:function(a){a.meta=f.toJSON()}}],r=[],s=function(a){a(f),n=f.toJSON(),f.find("#embed").value(g.updateHtml(n.embed,n))};if(c.hasAltSource(a)&&r.push({name:"source2",type:"filepicker",filetype:"media",size:40,label:"Alternative source"}),c.hasPoster(a)&&r.push({name:"poster",type:"filepicker",filetype:"image",size:40,label:"Poster"}),c.hasDimensions(a)){var t=h.createUi(s);o.push(t)}n=k(a);var u={id:"mcemediasource",type:"textbox",flex:1,name:"embed",value:l(a),multiline:!0,rows:5,label:"Source"},v=function(){n=b.extend({},d.htmlToData(c.getScripts(a),this.value())),this.parent().parent().fromJSON(n)};u[i]=v,f=a.windowManager.open({title:"Insert/edit media",data:n,bodyType:"tabpanel",body:[{title:"General",type:"form",items:o},{title:"Embed",type:"container",layout:"flex",direction:"column",align:"stretch",padding:10,spacing:10,items:[{type:"label",text:"Paste your embed code below:",forId:"mcemediasource"},u]},{title:"Advanced",type:"form",items:r}],onSubmit:function(){h.updateSize(f),p(f,a)}}),h.syncSize(f)};return{showDialog:r}}),g("2",["9"],function(a){var b=function(b){var c=function(){a.showDialog(b)};return{showDialog:c}};return{get:b}}),g("3",["9"],function(a){var b=function(b){var c=function(){a.showDialog(b)};b.addCommand("mceMedia",c)};return{register:b}}),g("a",["8"],function(a){return a("tinymce.html.Node")}),g("d",["l","m","k","b","g"],function(a,b,c,d,e){var f=function(d,f){if(e.shouldFilterHtml(d)===!1)return f;var g,h=new c;return new a({validate:!1,allow_conditional_comments:!1,special:"script,noscript",comment:function(a){h.comment(a)},cdata:function(a){h.cdata(a)},text:function(a,b){h.text(a,b)},start:function(a,b,c){if(g=!0,"script"!==a&&"noscript"!==a){for(var e=0;e]*>","gi")});var g=e.schema.getBoolAttrs();b.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "),function(a){g[a]={}}),e.parser.addNodeFilter("iframe,video,audio,object,embed,script",c.placeHolderConverter(e)),e.serializer.addAttributeFilter("data-mce-object",function(b,c){for(var f,g,h,i,j,k,l,m,n=b.length;n--;)if(f=b[n],f.parent){for(l=f.attr(c),g=new a(l,1),"audio"!==l&&"script"!==l&&(m=f.attr("class"),m&&m.indexOf("mce-preview-object")!==-1?g.attr({width:f.firstChild.attr("width"),height:f.firstChild.attr("height")}):g.attr({width:f.attr("width"),height:f.attr("height")})),g.attr({style:f.attr("style")}),i=f.attributes,h=i.length;h--;){var o=i[h].name;0===o.indexOf("data-mce-p-")&&g.attr(o.substr(11),i[h].value)}"script"===l&&g.attr("type","text/javascript"),j=f.attr("data-mce-html"),j&&(k=new a("#text",3),k.raw=!0,k.value=d.sanitize(e,unescape(j)),g.append(k)),f.replace(g)}})}),e.on("setContent",function(){e.$("span.mce-preview-object").each(function(a,b){var c=e.$(b);0===c.find("span.mce-shim",b).length&&c.append('')})})};return{setup:e}}),g("5",[],function(){var a=function(a){a.on("ResolveName",function(a){var b;1===a.target.nodeType&&(b=a.target.getAttribute("data-mce-object"))&&(a.name=b)})};return{setup:a}}),g("6",["e"],function(a){var b=function(b){b.on("click keyup",function(){var a=b.selection.getNode();a&&b.dom.hasClass(a,"mce-preview-object")&&b.dom.getAttrib(a,"data-mce-selected")&&a.setAttribute("data-mce-selected","2")}),b.on("ObjectSelected",function(a){var b=a.target.getAttribute("data-mce-object");"audio"!==b&&"script"!==b||a.preventDefault()}),b.on("objectResized",function(b){var c,d=b.target;d.getAttribute("data-mce-object")&&(c=d.getAttribute("data-mce-html"),c&&(c=unescape(c),d.setAttribute("data-mce-html",escape(a.updateHtml(c,{width:b.width,height:b.height})))))})};return{setup:b}}),g("7",[],function(){var a=function(a){a.addButton("media",{tooltip:"Insert/edit media",cmd:"mceMedia",stateSelector:["img[data-mce-object]","span[data-mce-object]","div[data-ephox-embed-iri]"]}),a.addMenuItem("media",{icon:"media",text:"Media",cmd:"mceMedia",context:"insert",prependToContext:!0})};return{register:a}}),g("0",["1","2","3","4","5","6","7"],function(a,b,c,d,e,f,g){return a.add("media",function(a){return c.register(a),g.register(a),e.setup(a),d.setup(a),f.setup(a),b.get(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/nonbreaking/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/nonbreaking/plugin.min.js new file mode 100644 index 0000000..c9effc2 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/nonbreaking/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i ':" ";c.insertContent(a(e,d)),c.dom.setAttrib(c.dom.select("span.mce-nbsp"),"data-mce-bogus","1")};return{insertNbsp:c}}),g("2",["6"],function(a){var b=function(b){b.addCommand("mceNonBreaking",function(){a.insertNbsp(b,1)})};return{register:b}}),g("7",[],function(){var a=function(a){var b=a.getParam("nonbreaking_force_tab",0);return"boolean"==typeof tabs?b===!0?3:0:b};return{getKeyboardSpaces:a}}),g("3",["7","6"],function(a,b){var c=function(c){var d=a.getKeyboardSpaces(c);d>0&&c.on("keydown",function(a){if(9===a.keyCode){if(a.shiftKey)return;a.preventDefault(),b.insertNbsp(c,d)}})};return{setup:c}}),g("4",[],function(){var a=function(a){a.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),a.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"})};return{register:a}}),g("0",["1","2","3","4"],function(a,b,c,d){return a.add("nonbreaking",function(a){b.register(a),d.register(a),c.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/noneditable/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/noneditable/plugin.min.js new file mode 100644 index 0000000..5d639f5 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/noneditable/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0?b.charAt(f-1):"";if('"'===g)return d;if(">"===g){var h=b.lastIndexOf("<",f);if(h!==-1){var i=b.substring(h,f);if(i.indexOf('contenteditable="false"')!==-1)return d}}return''+a.dom.encode("string"==typeof e[1]?e[1]:e[0])+""}},e=function(a,c,e){var f=c.length,g=e.content;if("raw"!==e.format){for(;f--;)g=g.replace(c[f],d(a,g,b.getNonEditableClass(a)));e.content=g}},f=function(d){var f,g,h="contenteditable";f=" "+a.trim(b.getEditableClass(d))+" ",g=" "+a.trim(b.getNonEditableClass(d))+" ";var i=c(f),j=c(g),k=b.getNonEditableRegExps(d);d.on("PreInit",function(){k.length>0&&d.on("BeforeSetContent",function(a){e(d,k,a)}),d.parser.addAttributeFilter("class",function(a){for(var b,c=a.length;c--;)b=a[c],i(b)?b.attr(h,"true"):j(b)&&b.attr(h,"false")}),d.serializer.addAttributeFilter(h,function(a){for(var b,c=a.length;c--;)b=a[c],(i(b)||j(b))&&(k.length>0&&b.attr("data-mce-content")?(b.name="#text",b.type=3,b.raw=!0,b.value=b.attr("data-mce-content")):b.attr(h,null))})})};return{setup:f}}),g("0",["1","2"],function(a,b){return a.add("noneditable",function(a){b.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/pagebreak/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/pagebreak/plugin.min.js new file mode 100644 index 0000000..e7da9ce --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/pagebreak/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i")},b=function(a){return a.getParam("pagebreak_split_block",!1)};return{getSeparatorHtml:a,shouldSplitBlock:b}}),g("4",["1","8"],function(a,b){var c=function(){return"mce-pagebreak"},d=function(){return''},e=function(a){var c=b.getSeparatorHtml(a),e=new RegExp(c.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(a){return"\\"+a}),"gi");a.on("BeforeSetContent",function(a){a.content=a.content.replace(e,d())}),a.on("PreInit",function(){a.serializer.addNodeFilter("img",function(d){for(var e,f,g=d.length;g--;)if(e=d[g],f=e.attr("class"),f&&f.indexOf("mce-pagebreak")!==-1){var h=e.parent;if(a.schema.getBlockElements()[h.name]&&b.shouldSplitBlock(a)){h.type=3,h.value=c,h.raw=!0,e.remove();continue}e.type=3,e.value=c,e.raw=!0}})})};return{setup:e,getPlaceholderHtml:d,getPageBreakClass:c}}),g("3",["4"],function(a){var b=function(b){b.addCommand("mcePageBreak",function(){b.settings.pagebreak_split_block?b.insertContent("

      "+a.getPlaceholderHtml()+"

      "):b.insertContent(a.getPlaceholderHtml())})};return{register:b}}),g("5",["4"],function(a){var b=function(b){b.on("ResolveName",function(c){"IMG"===c.target.nodeName&&b.dom.hasClass(c.target,a.getPageBreakClass())&&(c.name="pagebreak")})};return{setup:b}}),g("6",[],function(){var a=function(a){a.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),a.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"})};return{register:a}}),g("0",["1","2","3","4","5","6"],function(a,b,c,d,e,f){return b.add("pagebreak",function(a){c.register(a),f.register(a),d.setup(a),e.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/paste/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/paste/plugin.min.js new file mode 100644 index 0000000..31cfc1d --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/paste/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i",c=function(a){return b+a},d=function(a){return a.replace(b,"")},e=function(a){return a.indexOf(b)!==-1};return{mark:c,unmark:d,isMarked:e,internalHtmlMime:function(){return a}}}),g("x",["c"],function(a){return a("tinymce.html.Entities")}),g("o",["j","x"],function(a,b){var c=function(a){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(a)},d=function(a){return a.replace(/\r?\n/g,"
      ")},e=function(a,c){var d,e=[],f="<"+a;if("object"==typeof c){for(d in c)c.hasOwnProperty(d)&&e.push(d+'="'+b.encodeAllRaw(c[d])+'"');e.length&&(f+=" "+e.join(" "))}return f+">"},f=function(b,c,d){var f=b.split(/\n\n/),g=e(c,d),h="",i=a.map(f,function(a){return a.split(/\n/).join("
      ")}),j=function(a){return g+a+h};return 1===i.length?i[0]:a.map(i,j).join("")},g=function(a,b,c){return b?f(a,b,c):d(a)};return{isPlainText:c,convert:g,toBRs:d,toBlockElements:f}}),g("p",["j","h"],function(a,b){return function(c){var d,e="%MCEPASTEBIN%",f=function(){function a(a){var b,c,e,f=a.startContainer;if(b=a.getClientRects(),b.length)return b[0];if(a.collapsed&&1===f.nodeType){for(e=f.childNodes[d.startOffset];e&&3===e.nodeType&&!e.data.length;)e=e.nextSibling;if(e)return"BR"===e.tagName&&(c=h.doc.createTextNode("\ufeff"),e.parentNode.insertBefore(c,e),a=h.createRng(),a.setStartBefore(c),a.setEndAfter(c),b=a.getClientRects(),h.remove(c)),b.length?b[0]:void 0}}var f,g,h=c.dom,i=c.getBody(),j=c.dom.getViewPort(c.getWin()),k=j.y,l=20;if(d=c.selection.getRng(),c.inline&&(g=c.selection.getScrollContainer(),g&&g.scrollTop>0&&(k=g.scrollTop)),d.getClientRects){var m=a(d);if(m)l=k+(m.top-h.getPos(i).y);else{l=k;var n=d.startContainer;n&&(3===n.nodeType&&n.parentNode!==i&&(n=n.parentNode),1===n.nodeType&&(l=h.getPos(n,g||i).y))}}f=c.dom.add(c.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: absolute; top: "+l+"px; width: 10px; height: 10px; overflow: hidden; opacity: 0"},e),(b.ie||b.gecko)&&h.setStyle(f,"left","rtl"===h.getStyle(i,"direction",!0)?65535:-65535),h.bind(f,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),f.focus(),c.selection.select(f,!0)},g=function(){if(h()){for(var a;a=c.dom.get("mcepastebin");)c.dom.remove(a),c.dom.unbind(a);d&&c.selection.setRng(d)}d=null},h=function(){return c.dom.get("mcepastebin")},i=function(){var b,d,e,f,g,h=function(a,b){a.appendChild(b),c.dom.remove(b,!0)};for(d=a.grep(c.getBody().childNodes,function(a){return"mcepastebin"===a.id}),b=d.shift(),a.each(d,function(a){h(b,a)}),f=c.dom.select("div[id=mcepastebin]",b),e=f.length-1;e>=0;e--)g=c.dom.create("div"),b.insertBefore(g,f[e]),h(g,f[e]);return b?b.innerHTML:""},j=function(){return d},k=function(a){return a===e},l=function(a){return a&&"mcepastebin"===a.id},m=function(){var a=h();return l(a)&&k(a.innerHTML)};return{create:f,remove:g,getEl:h,getHtml:i,getLastRng:j,isDefault:m,isDefaultContent:k}}}),g("y",["c"],function(a){return a("tinymce.html.DomParser")}),g("z",["c"],function(a){return a("tinymce.html.Node")}),g("10",["c"],function(a){return a("tinymce.html.Schema")}),g("11",["c"],function(a){return a("tinymce.html.Serializer")}),g("s",["g","y","10","j"],function(a,b,c,d){function e(a,b){return d.each(b,function(b){a=b.constructor===RegExp?a.replace(b,""):a.replace(b[0],b[1])}),a}function f(a){function f(a){var b=a.name,c=a;if("br"===b)return void(i+="\n");if(j[b]&&(i+=" "),k[b])return void(i+=" ");if(3===a.type&&(i+=a.value),!a.shortEnded&&(a=a.firstChild))do f(a);while(a=a.next);l[b]&&c.next&&(i+="\n","p"===b&&(i+="\n"))}var g=new c,h=new b({},g),i="",j=g.getShortEndedElements(),k=d.makeMap("script noscript style textarea video audio iframe object"," "),l=g.getBlockElements();return a=e(a,[//g]),f(h.parse(a)),i}function g(a){function b(a,b,c){return b||c?"\xa0":" "}return a=e(a,[/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/|/g,[/( ?)\u00a0<\/span>( ?)/g,b],/
      /g,/
      $/i])}function h(a){var b=0;return function(){return a+b++}}var i=function(){return a.userAgent.indexOf(" Edge/")!==-1};return{filter:e,innerText:f,trimHtml:g,createIdGenerator:h,isMsEdge:i}}),g("v",["y","z","10","11","j","m","s"],function(a,b,c,d,e,f,g){function h(a){return/1&&g.attr("start",""+f),a.wrap(g)),a.name="li",i>k&&h&&h.lastChild.append(g),k=i,e(a),d(a,/^\u00a0+/),d(a,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),d(a,/^\u00a0+/)}for(var g,h,k=1,l=[],m=a.firstChild;"undefined"!=typeof m&&null!==m;)if(l.push(m),m=m.walk(),null!==m)for(;"undefined"!=typeof m&&m.parent!==a;)m=m.walk();for(var n=0;n/gi,/]+id="?docs-internal-[^>]*>/gi,//gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/([\s\u00a0]*)<\/span>/gi,function(a,b){return b.length>0?b.replace(/./," ").slice(Math.floor(b.length/2)).split("").join("\xa0"):""}]]);var m=f.getWordValidElements(b),n=new c({valid_elements:m,valid_children:"-li[p]"});e.each(n.elements,function(a){a.attributes["class"]||(a.attributes["class"]={},a.attributesOrder.push("class")),a.attributes.style||(a.attributes.style={},a.attributesOrder.push("style"))});var o=new a({},n);o.addAttributeFilter("style",function(a){for(var c,d=a.length;d--;)c=a[d],c.attr("style",l(b,j,c,c.attr("style"))),"span"===c.name&&c.parent&&!c.attributes.length&&c.unwrap()}),o.addAttributeFilter("class",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(c)&&b.remove(),b.attr("class",null)}),o.addNodeFilter("del",function(a){for(var b=a.length;b--;)a[b].remove()}),o.addNodeFilter("a",function(a){for(var b,c,d,e=a.length;e--;)if(b=a[e],c=b.attr("href"),d=b.attr("name"),c&&c.indexOf("#_msocom_")!==-1)b.remove();else if(c&&0===c.indexOf("file://")&&(c=c.split("#")[1],c&&(c="#"+c)),c||d){if(d&&!/^_?(?:toc|edn|ftn)/i.test(d)){b.unwrap();continue}b.attr({href:c,name:d})}else b.unwrap()});var p=o.parse(h);return f.shouldConvertWordFakeLists(b)&&k(p),h=new d({validate:b.settings.validate},n).serialize(p)},n=function(a,b){return f.shouldUseDefaultFilters(a)?m(a,b):b};return{preProcess:n,isWordContent:h}}),g("q",["l","v"],function(a,b){var c=function(a,b){return{content:a,cancelled:b}},d=function(b,d,e,f){var g=b.dom.create("div",{style:"display:none"},d),h=a.firePastePostProcess(b,g,e,f);return c(h.node.innerHTML,h.isDefaultPrevented())},e=function(b,e,f,g){var h=a.firePastePreProcess(b,e,f,g);return b.hasEventListeners("PastePostProcess")&&!h.isDefaultPrevented()?d(b,h.content,f,g):c(h.content,h.isDefaultPrevented())},f=function(a,c,d){var f=b.isWordContent(c),g=f?b.preProcess(a,c):c;return e(a,g,d,f)};return{process:f}}),g("r",["j","m"],function(a,b){var c=function(a){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(a)},d=function(a){return c(a)&&/.(gif|jpe?g|png)$/.test(a)},e=function(a,b,c){return a.undoManager.extra(function(){c(a,b)},function(){a.insertContent('')}),!0},f=function(a,b,c){return a.undoManager.extra(function(){c(a,b)},function(){a.execCommand("mceInsertLink",!1,b)}),!0},g=function(a,b,d){return!(a.selection.isCollapsed()!==!1||!c(b))&&f(a,b,d)},h=function(a,b,c){return!!d(b)&&e(a,b,c)},i=function(a,c){return a.insertContent(c,{merge:b.shouldMergeFormats(a),paste:!0}),!0},j=function(b,c){a.each([g,h,i],function(a){return a(b,c,i)!==!0})},k=function(a,c){b.isSmartPasteEnabled(a)===!1?i(a,c):j(a,c)};return{isImageUrl:d,isAbsoluteUrl:c,insertContent:k}}),g("6",["f","g","d","h","i","j","k","l","m","n","o","p","q","r","s"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){return function(p){function q(a,b){var c=b?b:j.isMarked(a),d=m.process(p,j.unmark(a),c);d.cancelled===!1&&n.insertContent(p,d.content)}function r(a){a=p.dom.encode(a).replace(/\r\n/g,"\n"),a=k.convert(a,p.settings.forced_root_block,p.settings.forced_root_block_attrs),q(a,!1)}function s(a){var b={};if(a){if(a.getData){var c=a.getData("Text");c&&c.length>0&&c.indexOf(I)===-1&&(b["text/plain"]=c)}if(a.types)for(var d=0;d',!1)}else q('',!1)}function z(a,b){function d(d){var e,f,g,h=!1;if(d)for(e=0;e0}function C(a){return g.metaKeyPressed(a)&&86===a.keyCode||a.shiftKey&&45===a.keyCode}function D(){function a(a,b,c,d){var e,f;return B(a,"text/html")?e=a["text/html"]:(e=H.getHtml(),d=d?d:j.isMarked(e),H.isDefaultContent(e)&&(c=!0)),e=o.trimHtml(e),H.remove(),f=d===!1&&k.isPlainText(e),e.length&&!f||(c=!0),c&&(e=B(a,"text/plain")&&f?a["text/plain"]:o.innerText(e)),H.isDefaultContent(e)?void(b||p.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.")):void(c?r(e):q(e,d))}p.on("keydown",function(a){function c(a){C(a)&&!a.isDefaultPrevented()&&H.remove()}if(C(a)&&!a.isDefaultPrevented()){if(E=a.shiftKey&&86===a.keyCode,E&&d.webkit&&b.userAgent.indexOf("Version/")!==-1)return;if(a.stopImmediatePropagation(),G=(new Date).getTime(),d.ie&&E)return a.preventDefault(),void h.firePaste(p,!0);H.remove(),H.create(),p.once("keyup",c),p.once("paste",function(){p.off("keyup",c)})}});var c=function(){return H.getLastRng()||p.selection.getRng()};p.on("paste",function(b){var f=(new Date).getTime(),g=t(b),h=(new Date).getTime()-f,i=(new Date).getTime()-G-h<1e3,k="text"===F.pasteFormat||E,l=B(g,j.internalHtmlMime());return E=!1,b.isDefaultPrevented()||A(b)?void H.remove():!u(g)&&z(b,c())?void H.remove():(i||b.preventDefault(),!d.ie||i&&!b.ieFake||B(g,"text/html")||(H.create(),p.dom.bind(H.getEl(),"paste",function(a){a.stopPropagation()}),p.getDoc().execCommand("Paste",!1,null),g["text/html"]=H.getHtml()),void(B(g,"text/html")?(b.preventDefault(),l||(l=j.isMarked(g["text/html"])),a(g,i,k,l)):e.setEditorTimeout(p,function(){a(g,i,k,l)},0)))})}var E,F=this,G=0,H=new l(p),I="data:text/mce-internal,",J=o.createIdGenerator("mceclip");F.pasteFormat=i.isPasteAsTextEnabled(p)?"text":"html",F.pasteHtml=q,F.pasteText=r,F.pasteImageData=z,F.getDataTransferItems=s,F.hasHtmlOrText=u,F.hasContentType=B,p.on("preInit",function(){D(),p.parser.addNodeFilter("img",function(a,b,c){function e(a){return a.data&&a.data.paste===!0}function f(a){a.attr("data-mce-object")||j===d.transparentSrc||a.remove()}function g(a){return 0===a.indexOf("webkit-fake-url")}function h(a){return 0===a.indexOf("data:")}if(!p.settings.paste_data_images&&e(c))for(var i=a.length;i--;){var j=a[i].attributes.map.src;j&&(g(j)?f(a[i]):!p.settings.allow_html_data_urls&&h(j)&&f(a[i]))}})})}}),h("t",setTimeout),g("7",["t","h","n","s"],function(a,b,c,d){var e=function(){},f=function(a){return b.iOS===!1&&void 0!==a&&"function"==typeof a.setData&&d.isMsEdge()!==!0},g=function(a,b,d){if(!f(a))return!1;try{return a.clearData(),a.setData("text/html",b),a.setData("text/plain",d),a.setData(c.internalHtmlMime(),b),!0}catch(a){return!1}},h=function(a,b,c,d){g(a.clipboardData,b.html,b.text)?(a.preventDefault(),d()):c(b.html,d)},i=function(b){return function(d,e){var f=c.mark(d),g=b.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),h=b.dom.create("div",{contenteditable:"true"},f);b.dom.setStyles(g,{position:"fixed",left:"-3000px",width:"1000px",overflow:"hidden"}),g.appendChild(h),b.dom.add(b.getBody(),g);var i=b.selection.getRng();h.focus();var j=b.dom.createRng();j.selectNodeContents(h),b.selection.setRng(j),a(function(){g.parentNode.removeChild(g),b.selection.setRng(i),e()},0)}},j=function(a){return{html:a.selection.getContent({contextual:!0}),text:a.selection.getContent({format:"text"})}},k=function(b){return function(c){b.selection.isCollapsed()===!1&&h(c,j(b),i(b),function(){a(function(){b.execCommand("Delete")},0)})}},l=function(a){return function(b){a.selection.isCollapsed()===!1&&h(b,j(a),i(a),e)}},m=function(a){a.on("cut",k(a)),a.on("copy",l(a))};return{register:m}}),g("u",["c"],function(a){return a("tinymce.dom.RangeUtils")}),g("8",["u","i","m","n","s"],function(a,b,c,d,e){var f=function(b,c){return a.getCaretRangeFromPoint(c.clientX,c.clientY,b.getDoc())},g=function(a){var b=a["text/plain"];return!!b&&0===b.indexOf("file://")},h=function(a,b){a.focus(),a.selection.setRng(b)},i=function(a,i,j){c.shouldBlockDrop(a)&&a.on("dragend dragover draggesture dragdrop drop drag",function(a){a.preventDefault(),a.stopPropagation()}),c.shouldPasteDataImages(a)||a.on("drop",function(a){var b=a.dataTransfer;b&&b.files&&b.files.length>0&&a.preventDefault()}),a.on("drop",function(k){var l,m;if(m=f(a,k),!k.isDefaultPrevented()&&!j.get()){l=i.getDataTransferItems(k.dataTransfer);var n=i.hasContentType(l,d.internalHtmlMime());if((i.hasHtmlOrText(l)&&!g(l)||!i.pasteImageData(k,m))&&m&&c.shouldFilterDrop(a)){var o=l["mce-internal"]||l["text/html"]||l["text/plain"];o&&(k.preventDefault(),b.setEditorTimeout(a,function(){a.undoManager.transact(function(){l["mce-internal"]&&a.execCommand("Delete"),h(a,m),o=e.trimHtml(o),l["text/html"]?i.pasteHtml(o,n):i.pasteText(o)})}))}}}),a.on("dragstart",function(a){j.set(!0)}),a.on("dragover dragend",function(b){c.shouldPasteDataImages(a)&&j.get()===!1&&(b.preventDefault(),h(a,f(a,b))),"dragend"===b.type&&j.set(!1)})};return{setup:i}}),g("9",["m"],function(a){var b=function(b){var c=b.plugins.paste,d=a.getPreProcess(b);d&&b.on("PastePreProcess",function(a){d.call(c,c,a)});var e=a.getPostProcess(b);e&&b.on("PastePostProcess",function(a){e.call(c,c,a)})};return{setup:b}}),g("a",["h","j","m","s","v"],function(a,b,c,d,e){function f(a,b){a.on("PastePreProcess",function(c){c.content=b(a,c.content,c.internal,c.wordContent)})}function g(a,b){a.on("PastePostProcess",function(c){b(a,c.node)})}function h(a,c){if(!e.isWordContent(c))return c;var f=[];b.each(a.schema.getBlockElements(),function(a,b){f.push(b)});var g=new RegExp("(?:
       [\\s\\r\\n]+|
      )*(<\\/?("+f.join("|")+")[^>]*>)(?:
       [\\s\\r\\n]+|
      )*","g");return c=d.filter(c,[[g,"$1"]]),c=d.filter(c,[[/

      /g,"

      "],[/
      /g," "],[/

      /g,"
      "]])}function i(a,b,d,e){if(e||d)return b;var f=c.getWebkitStyles(a);if(c.shouldRemoveWebKitStyles(a)===!1||"all"===f)return b;if(f&&(f=f.split(/[, ]/)),f){var g=a.dom,h=a.selection.getNode();b=b.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(a,b,c,d){var e=g.parseStyle(g.decode(c),"span"),i={};if("none"===f)return b+d;for(var j=0;j]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return b=b.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(a,b,c,d){return b+' style="'+c+'"'+d})}function j(a,b){a.$("a",b).find("font,u").each(function(b,c){a.dom.remove(c,!0)})}var k=function(b){a.webkit&&f(b,i),a.ie&&(f(b,h),g(b,j))};return{setup:k}}),h("12",Array),h("13",Error),g("w",["12","13"],function(a,b){var c=function(){},d=function(a,b){return function(){return a(b.apply(null,arguments))}},e=function(a){return function(){return a}},f=function(a){return a},g=function(a,b){return a===b},h=function(b){for(var c=new a(arguments.length-1),d=1;d',g&&(e+='"),a.each(c.contentCSS,function(a){e+=''});var h=c.settings.body_id||"tinymce";h.indexOf("=")!==-1&&(h=c.getParam("body_id","","hash"),h=h[c.id]||h);var i=c.settings.body_class||"";i.indexOf("=")!==-1&&(i=c.getParam("body_class","","hash"),i=i[c.id]||"");var j=' ',k=c.settings.directionality?' dir="'+c.settings.directionality+'"':"";return d=""+e+'"+c.getContent()+j+""},d=function(a,b,d){var e=c(a);if(d)b.src="data:text/html;charset=utf-8,"+encodeURIComponent(e);else{var f=b.contentWindow.document;f.open(),f.write(e),f.close()}};return{getPreviewHtml:c,injectIframeContent:d}}),g("5",["6","7","8","9"],function(a,b,c,d){var e=function(b){var e=!a.ie,f='",g=c.getPreviewDialogWidth(b),h=c.getPreviewDialogHeight(b);b.windowManager.open({title:"Preview",width:g,height:h,html:f,buttons:{text:"Close",onclick:function(a){a.control.parent().parent().close()}},onPostRender:function(a){var c=a.control.getEl("body").firstChild;d.injectIframeContent(b,c,e)}})};return{open:e}}),g("2",["5"],function(a){var b=function(b){b.addCommand("mcePreview",function(){a.open(b)})};return{register:b}}),g("3",[],function(){var a=function(a){a.addButton("preview",{title:"Preview",cmd:"mcePreview"}),a.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})};return{register:a}}),g("0",["1","2","3"],function(a,b,c){return a.add("preview",function(a){b.register(a),c.register(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/print/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/print/plugin.min.js new file mode 100644 index 0000000..6192028 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/print/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0){var d=a[b];if(!d)throw"Invalid capture group";c+=a[0].indexOf(d),a[0]=d}return[c,c+a[0].length,[a[0]]]}function h(b){var c;if(3===b.nodeType)return b.data;if(o[b.nodeName]&&!n[b.nodeName])return"";if(c="",a(b))return"\n";if((n[b.nodeName]||p[b.nodeName])&&(c+="\n"),b=b.firstChild)do c+=h(b);while(b=b.nextSibling);return c}function i(b,c,d){var e,f,g,h,i=[],j=0,k=b,l=c.shift(),m=0;a:for(;;){if((n[k.nodeName]||p[k.nodeName]||a(k))&&j++,3===k.nodeType&&(!f&&k.length+j>=l[1]?(f=k,h=l[1]-j):e&&i.push(k),!e&&k.length+j>l[0]&&(e=k,g=l[0]-j),j+=k.length),e&&f){if(k=d({startNode:e,startNodeIndex:g,endNode:f,endNodeIndex:h,innerNodes:i,match:l[2],matchIndex:m}),j-=f.length-h,e=null,f=null,i=[],l=c.shift(),m++,!l)break}else if(o[k.nodeName]&&!n[k.nodeName]||!k.firstChild){if(k.nextSibling){k=k.nextSibling;continue}}else if(!a(k)){k=k.firstChild;continue}for(;;){if(k.nextSibling){k=k.nextSibling;break}if(k.parentNode===b)break a;k=k.parentNode}}}function j(a){var b;if("function"!=typeof a){var c=a.nodeType?a:m.createElement(a);b=function(a,b){var d=c.cloneNode(!1);return d.setAttribute("data-mce-index",b),a&&d.appendChild(m.createTextNode(a)),d}}else b=a;return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex;if(f===g){var i=f;e=i.parentNode,a.startNodeIndex>0&&(c=m.createTextNode(i.data.substring(0,a.startNodeIndex)),e.insertBefore(c,i));var j=b(a.match[0],h);return e.insertBefore(j,i),a.endNodeIndex0},m=function(b,d,f,g,i){var m,n,q,r,s,t,u=d.get();for(g=g!==!1,q=b.getBody(),n=a.grep(a.toArray(q.getElementsByTagName("span")),l),m=0;md.get()&&n[m].setAttribute("data-mce-index",s-1)}return d.set(u),g?(t=o(b,d),j(b,d)):(t=p(b,d),k(b,d)),!i&&t},n=function(b,d,f){var g,h,i,j;for(h=a.toArray(b.getBody().getElementsByTagName("span")),g=0;g0},p=function(a,b){return f(a,b.get()-1).length>0};return{done:n,find:i,next:j,prev:k,replace:m,hasNext:o,hasPrev:p}}),g("3",["7"],function(a){var b=function(b,c){var d=function(d){return a.done(b,c,d)},e=function(d,e,f){return a.find(b,c,d,e,f)},f=function(){return a.next(b,c)},g=function(){return a.prev(b,c)},h=function(d,e,f){return a.replace(b,c,d,e,f)};return{done:d,find:e,next:f,prev:g,replace:h}};return{get:b}}),g("8",["9","7"],function(a,b){var c=function(c,d){function e(){i.statusbar.find("#next").disabled(b.hasNext(c,d)===!1),i.statusbar.find("#prev").disabled(b.hasPrev(c,d)===!1)}function f(){c.windowManager.alert("Could not find the specified string.",function(){i.find("#find")[0].focus()})}var g,h={};c.undoManager.add(),g=a.trim(c.selection.getContent({format:"text"}));var i=c.windowManager.open({layout:"flex",pack:"center",align:"center",onClose:function(){c.focus(),b.done(c,d),c.undoManager.add()},onSubmit:function(a){var g,j,k,l;return a.preventDefault(),j=i.find("#case").checked(),l=i.find("#words").checked(),k=i.find("#find").value(),k.length?h.text===k&&h.caseState===j&&h.wholeWord===l?b.hasNext(c,d)?(b.next(c,d),void e()):void f():(g=b.find(c,d,k,j,l),g||f(),i.statusbar.items().slice(1).disabled(0===g),e(),void(h={text:k,caseState:j,wholeWord:l})):(b.done(c,d,!1),void i.statusbar.items().slice(1).disabled(!0))},buttons:[{text:"Find",subtype:"primary",onclick:function(){i.submit()}},{text:"Replace",disabled:!0,onclick:function(){b.replace(c,d,i.find("#replace").value())||(i.statusbar.items().slice(1).disabled(!0),d.set(-1),h={})}},{text:"Replace all",disabled:!0,onclick:function(){b.replace(c,d,i.find("#replace").value(),!0,!0),i.statusbar.items().slice(1).disabled(!0),h={}}},{type:"spacer",flex:1},{text:"Prev",name:"prev",disabled:!0,onclick:function(){b.prev(c,d),e()}},{text:"Next",name:"next",disabled:!0,onclick:function(){b.next(c,d),e()}}],title:"Find and replace",items:{type:"form",padding:20,labelGap:30,spacing:10,items:[{type:"textbox",name:"find",size:40,label:"Find",value:g},{type:"textbox",name:"replace",size:40,label:"Replace with"},{type:"checkbox",name:"case",text:"Match case",label:" "},{type:"checkbox",name:"words",text:"Whole words",label:" "}]}})};return{open:c}}),g("4",["8"],function(a){var b=function(b,c){b.addCommand("SearchReplace",function(){a.open(b,c)})};return{register:b}}),g("5",["8"],function(a){var b=function(b,c){return function(){a.open(b,c)}},c=function(a,c){a.addMenuItem("searchreplace",{text:"Find and replace",shortcut:"Meta+F",onclick:b(a,c),separator:"before",context:"edit"}),a.addButton("searchreplace",{tooltip:"Find and replace",onclick:b(a,c)}),a.shortcuts.add("Meta+F","",b(a,c))};return{register:c}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return b.add("searchreplace",function(b){var f=a(-1);return d.register(b,f),e.register(b,f),c.get(b,f)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/spellchecker/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/spellchecker/plugin.min.js new file mode 100644 index 0000000..74c5544 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/spellchecker/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g");return a.getParam("spellchecker_wordchar_pattern",b)};return{getLanguages:a,getLanguage:b,getRpcUrl:c,getSpellcheckerCallback:d,getSpellcheckerWordcharPattern:e}}),g("c",["9"],function(a){return a("tinymce.util.Tools")}),g("g",["9"],function(a){return a("tinymce.util.URI")}),g("h",["9"],function(a){return a("tinymce.util.XHR")}),g("i",[],function(){var a=function(a){return a.fire("SpellcheckStart")},b=function(a){return a.fire("SpellcheckEnd")};return{fireSpellcheckStart:a,fireSpellcheckEnd:b}}),g("j",[],function(){function a(a){return a&&1===a.nodeType&&"false"===a.contentEditable}return function(b,c){function d(a,b){if(!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";return{start:a.index,end:a.index+a[0].length,text:a[0],data:b}}function e(b){var c;if(3===b.nodeType)return b.data;if(z[b.nodeName]&&!y[b.nodeName])return"";if(a(b))return"\n";if(c="",(y[b.nodeName]||A[b.nodeName])&&(c+="\n"),b=b.firstChild)do c+=e(b);while(b=b.nextSibling);return c}function f(b,c,d){var e,f,g,h,i,j=[],k=0,l=b,m=0;c=c.slice(0),c.sort(function(a,b){return a.start-b.start}),i=c.shift();a:for(;;){if((y[l.nodeName]||A[l.nodeName]||a(l))&&k++,3===l.nodeType&&(!f&&l.length+k>=i.end?(f=l,h=i.end-k):e&&j.push(l),!e&&l.length+k>i.start&&(e=l,g=i.start-k),k+=l.length),e&&f){if(l=d({startNode:e,startNodeIndex:g,endNode:f,endNodeIndex:h,innerNodes:j,match:i.text,matchIndex:m}),k-=f.length-h,e=null,f=null,j=[],i=c.shift(),m++,!i)break}else if(z[l.nodeName]&&!y[l.nodeName]||!l.firstChild){if(l.nextSibling){l=l.nextSibling;continue}}else if(!a(l)){l=l.firstChild;continue}for(;;){if(l.nextSibling){l=l.nextSibling;break}if(l.parentNode===b)break a;l=l.parentNode}}}function g(a){function b(b,c){var d=B[c];d.stencil||(d.stencil=a(d));var e=d.stencil.cloneNode(!1);return e.setAttribute("data-mce-index",c),b&&e.appendChild(C.doc.createTextNode(b)),e}return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex,i=C.doc;if(f===g){var j=f;e=j.parentNode,a.startNodeIndex>0&&(c=i.createTextNode(j.data.substring(0,a.startNodeIndex)),e.insertBefore(c,j));var k=b(a.match,h);return e.insertBefore(k,j),a.endNodeIndex0&&d.insertNode(c.dom.doc.createTextNode(b)),d}function v(){return B.splice(0,B.length),p(),this}var w,x,y,z,A,B=[],C=c.dom;return y=c.schema.getBlockElements(),z=c.schema.getWhiteSpaceElements(),A=c.schema.getShortEndedElements(),x=e(b),{text:x,matches:B,each:m,filter:l,reset:v,matchFromElement:q,elementFromMatch:r,find:o,add:s,wrap:n,unwrap:p,replace:u,rangeFromMatch:t,indexOf:k}}}),g("b",["c","g","h","i","6","j"],function(a,b,c,d,e,f){var g=function(a,b){if(!b.get()){var c=new f(a.getBody(),a);b.set(c)}return b.get()},h=function(a){for(var b in a)return!1;return!0},i=function(d,f,g){return function(h,i,j,k){var l={method:h,lang:g.get()},m="";l["addToDictionary"===h?"word":"text"]=i,a.each(l,function(a,b){m&&(m+="&"),m+=b+"="+encodeURIComponent(a)}),c.send({url:new b(f).toAbsolute(e.getRpcUrl(d)),type:"post",content_type:"application/x-www-form-urlencoded",data:m,success:function(a){if(a=JSON.parse(a))a.error?k(a.error):j(a);else{var b=d.translate("Server response wasn't proper JSON.");k(b)}},error:function(){var a=d.translate("The spelling service was not found: (")+e.getRpcUrl(d)+d.translate(")");k(a)}})}},j=function(a,b,c,d,f,g,h){var j=e.getSpellcheckerCallback(a),k=j?j:i(a,b,c);k.call(a.plugins.spellchecker,d,f,g,h)},k=function(a,b,c,d,e,f){if(!o(a,c,d)){var h=function(b){a.notificationManager.open({text:b,type:"error"}),a.setProgressState(!1),o(a,c,d)},i=function(b){r(a,c,d,e,b)};a.setProgressState(!0),j(a,b,f,"spellcheck",g(a,d).text,i,h),a.focus()}},l=function(a,b,c){a.dom.select("span.mce-spellchecker-word").length||o(a,b,c)},m=function(a,b,c,d,e,f){a.setProgressState(!0),j(a,b,"addToDictionary",e,function(){a.setProgressState(!1),a.dom.remove(f,!0),l(a,c,d)},function(b){a.notificationManager.open({text:b,type:"error"}),a.setProgressState(!1)})},n=function(b,c,d,e,f,g){b.selection.collapse(),g?a.each(b.dom.select("span.mce-spellchecker-word"),function(a){a.getAttribute("data-mce-word")===e&&b.dom.remove(a,!0)}):b.dom.remove(f,!0),l(b,c,d)},o=function(a,b,c){if(g(a,c).reset(),c.set(null),b.get())return b.set(!1),d.fireSpellcheckEnd(a),!0},p=function(a){var b=a.getAttribute("data-mce-index");return"number"==typeof b?""+b:b},q=function(b,c){var d,e=[];if(d=a.toArray(b.getBody().getElementsByTagName("span")),d.length)for(var f=0;f1&&(m.type="splitbutton",m.menu=k,m.onshow=e(a),m.onselect=function(a){i.set(a.control.settings.data)}),a.addButton("spellchecker",m),a.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:l,selectable:!0,onPostRender:function(){var b=this;b.active(g.get()),a.on("SpellcheckStart SpellcheckEnd",function(){b.active(g.get())})}})};return{register:g}}),h("d",document),g("e",["9"],function(a){return a("tinymce.dom.DOMUtils")}),g("f",["9"],function(a){return a("tinymce.ui.Factory")}),g("8",["d","e","f","c","6","b"],function(a,b,c,d,e,f){var g,h=function(e,h,i,j,k,l,m){var n=[],o=i.get().suggestions[l];d.each(o,function(a){n.push({text:a,onclick:function(){e.insertContent(e.dom.encode(a)),e.dom.remove(m),f.checkIfFinished(e,j,k)}})}),n.push({text:"-"});var p=i.get().hasDictionarySupport;p&&n.push({text:"Add to Dictionary",onclick:function(){f.addToDictionary(e,h,j,k,l,m)}}),n.push.apply(n,[{text:"Ignore",onclick:function(){f.ignoreWord(e,j,k,l,m)}},{text:"Ignore all",onclick:function(){f.ignoreWord(e,j,k,l,m,!0)}}]),g=c.create("menu",{items:n,context:"contextmenu",onautohide:function(a){a.target.className.indexOf("spellchecker")!==-1&&a.preventDefault()},onhide:function(){g.remove(),g=null}}),g.renderTo(a.body);var q=b.DOM.getPos(e.getContentAreaContainer()),r=e.dom.getPos(m[0]),s=e.dom.getRoot();"BODY"===s.nodeName?(r.x-=s.ownerDocument.documentElement.scrollLeft||s.scrollLeft,r.y-=s.ownerDocument.documentElement.scrollTop||s.scrollTop):(r.x-=s.scrollLeft,r.y-=s.scrollTop),q.x+=r.x,q.y+=r.y,g.moveTo(q.x,q.y+m[0].offsetHeight)},i=function(a,b,c,d,e){a.on("click",function(g){var i=g.target;if("mce-spellchecker-word"===i.className){g.preventDefault();var j=f.findSpansByIndex(a,f.getElmIndex(i));if(j.length>0){var k=a.dom.createRng();k.setStartBefore(j[0]),k.setEndAfter(j[j.length-1]),a.selection.setRng(k),h(a,b,c,d,e,i.getAttribute("data-mce-word"),j)}}})};return{setup:i}}),g("0",["1","2","3","4","5","6","7","8"],function(a,b,c,d,e,f,g,h){return b.add("spellchecker",function(b,i){if(c.hasProPlugin(b)===!1){var j=a(!1),k=a(f.getLanguage(b)),l=a(null),m=a({});return g.register(b,i,j,l,k,m),h.setup(b,i,m,j,l),e.register(b,i,j,l,m,k),d.get(b,j,m,l,i)}}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/tabfocus/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/tabfocus/plugin.min.js new file mode 100644 index 0000000..235125e --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/tabfocus/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0){for(o=l+1;o=0;o--)if(e(m[o]))return m[o];return null}var l,m,n,o;if(!(j.keyCode!==g.TAB||j.ctrlKey||j.altKey||j.metaKey||j.isDefaultPrevented())&&(n=f.explode(h.getTabFocus(b)),1===n.length&&(n[1]=n[0],n[0]=":prev"),m=j.shiftKey?":prev"===n[0]?k(-1):i.get(n[0]):":next"===n[1]?k(1):i.get(n[1]))){var p=c.get(m.id||m.name);m.id&&p?p.focus():e.setTimeout(function(){d.webkit||a.focus(),m.focus()},10),j.preventDefault()}}b.on("init",function(){b.inline&&i.setAttrib(b.getBody(),"tabIndex",null),b.on("keyup",j),d.gecko?b.on("keypress keydown",k):b.on("keydown",k)})};return{setup:k}}),g("0",["1","2"],function(a,b){return a.add("tabfocus",function(a){b.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/table/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/table/plugin.min.js new file mode 100644 index 0000000..119cbb3 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/table/plugin.min.js @@ -0,0 +1,5 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("v",["n"],function(a){var b=function(c,d){var e=function(a,e){return b(c+a,d+e)};return{left:a.constant(c),top:a.constant(d),translate:e}};return b}),g("5v",[],function(){return"undefined"!=typeof window?window:Function("return this;")()}),g("58",["5v"],function(a){var b=function(b,c){for(var d=void 0!==c?c:a,e=0;e0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("24",["2a","2b"],function(a,b){return{immutable:a,immutableBag:b}}),g("7",["12","1","13","14","q","s"],function(a,b,c,d,e,f){var g=function(b,c,d){if(!(a.isString(d)||a.isBoolean(d)||a.isNumber(d)))throw f.error("Invalid call to Attr.set. Key ",c,":: Value ",d,":: Element ",b),new e("Attribute value was not simple");b.setAttribute(c,d+"")},h=function(a,b,c){g(a.dom(),b,c)},i=function(a,b){var d=a.dom();c.each(b,function(a,b){g(d,b,a)})},j=function(a,b){var c=a.dom().getAttribute(b);return null===c?void 0:c},k=function(a,b){var c=a.dom();return!(!c||!c.hasAttribute)&&c.hasAttribute(b)},l=function(a,b){a.dom().removeAttribute(b)},m=function(a){var b=a.dom().attributes;return void 0===b||null===b||0===b.length},n=function(a){return b.foldl(a.dom().attributes,function(a,b){return a[b.name]=b.value,a},{})},o=function(a,b,c){k(a,c)&&!k(b,c)&&h(b,c,j(a,c))},p=function(a,c,e){d.isElement(a)&&d.isElement(c)&&b.each(e,function(b){o(a,c,b)})};return{clone:n,set:h,setAll:i,get:j,has:k,remove:l,hasNone:m,transfer:p}}),g("2x",[],function(){var a=function(a){return void 0!==a.style};return{isSupported:a}}),h("2z",window),g("1u",["12","1","13","2","7","1t","6","14","2x","2y","q","s","2z"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(b,c,d){if(!a.isString(d))throw l.error("Invalid call to CSS.set. Property ",c,":: Value ",d,":: Element ",b),new k("CSS value must be a string: "+d);i.isSupported(b)&&b.style.setProperty(c,d)},o=function(a,b){i.isSupported(a)&&a.style.removeProperty(b)},p=function(a,b,c){var d=a.dom();n(d,b,c)},q=function(a,b){var d=a.dom();c.each(b,function(a,b){n(d,b,a)})},r=function(a,b){var d=a.dom();c.each(b,function(a,b){a.fold(function(){o(d,b)},function(a){n(d,b,a)})})},s=function(a,b){var c=a.dom(),d=m.getComputedStyle(c),e=d.getPropertyValue(b),g=""!==e||f.inBody(a)?e:t(c,b);return null===g?void 0:g},t=function(a,b){return i.isSupported(a)?a.style.getPropertyValue(b):""},u=function(a,b){var c=a.dom(),e=t(c,b);return d.from(e).filter(function(a){return a.length>0})},v=function(a){var b={},c=a.dom();if(i.isSupported(c))for(var d=0;dd?b-d:0;return e};return{set:g,get:h,getOuter:i,aggregate:j,max:k}}}),g("2c",["1t","1u","4e"],function(a,b,c){var d=c("height",function(b){return a.inBody(b)?b.dom().getBoundingClientRect().height:b.dom().offsetHeight}),e=function(a,b){d.set(a,b)},f=function(a){return d.get(a)},g=function(a){return d.getOuter(a)},h=function(a,c){var e=["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"],f=d.max(a,c,e);b.set(a,"max-height",f+"px")};return{set:e,get:f,getOuter:g,setMax:h}}),g("2d",["1u","4e"],function(a,b){var c=b("width",function(a){return a.dom().offsetWidth}),d=function(a,b){c.set(a,b)},e=function(a){return c.get(a)},f=function(a){return c.getOuter(a)},g=function(b,d){var e=["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"],f=c.max(b,d,e);a.set(b,"max-width",f+"px")};return{set:d,get:e,getOuter:f,setMax:g}}),g("11",["1","n","24","2c","u","2d"],function(a,b,c,d,e,f){var g=c.immutable("row","y"),h=c.immutable("col","x"),i=function(a){var b=e.absolute(a);return b.left()+f.getOuter(a)},j=function(a){return e.absolute(a).left()},k=function(a,b){return h(a,j(b))},l=function(a,b){return h(a,i(b))},m=function(a){return e.absolute(a).top()},n=function(a,b){return g(a,m(b))},o=function(a,b){return g(a,m(b)+d.getOuter(b))},p=function(b,c,d){if(0===d.length)return[];var e=a.map(d.slice(1),function(a,c){return a.map(function(a){return b(c,a)})}),f=d[d.length-1].map(function(a){return c(d.length-1,a)});return e.concat([f])},q=function(a,b){return-a},r={delta:b.identity,positions:b.curry(p,n,o),edge:m},s={delta:b.identity,edge:j,positions:b.curry(p,k,l)},t={delta:q,edge:i,positions:b.curry(p,l,k)};return{height:r,rtl:t,ltr:s}}),g("w",["11"],function(a){return{ltr:a.ltr,rtl:a.rtl}}),g("4",["w"],function(a){return function(b){var c=function(c){return b(c).isRtl()?a.rtl:a.ltr},d=function(a,b){return c(b).delta(a,b)},e=function(a,b){return c(b).positions(a,b)},f=function(a){return c(a).edge(a)};return{delta:d,edge:f,positions:e}}}),g("x",["1","24"],function(a,b){return function(c){var d=b.immutable.apply(null,c),e=[],f=function(a){if(void 0===a)throw"Event bind error: undefined handler";e.push(a)},g=function(b){e=a.filter(e,function(a){return a!==b})},h=function(){var b=d.apply(null,arguments);a.each(e,function(a){a(b)})};return{bind:f,unbind:g,trigger:h}}}),g("y",["13"],function(a){var b=function(b){var c=a.map(b,function(a){return{bind:a.bind,unbind:a.unbind}}),d=a.map(b,function(a){return a.trigger});return{registry:c,trigger:d}};return{create:b}}),g("4f",[],function(){var a=function(){return f(function(a,b,c,d,e){return a()})},b=function(a){return f(function(b,c,d,e,f){return c(a)})},c=function(a,b){return f(function(c,d,e,f,g){return e(a,b)})},d=function(a,b,c){return f(function(d,e,f,g,h){return g(a,b,c)})},e=function(a,b){return f(function(c,d,e,f,g){return g(a,b)})},f=function(a){return{fold:a}};return{none:a,only:b,left:c,middle:d,right:e}}),h("2m",Math),g("2e",["1","n","4f","2m"],function(a,b,c,d){var e=function(a,b){return 0===a.length?c.none():1===a.length?c.only(0):0===b?c.left(0,1):b===a.length-1?c.right(b-1,b):b>0&&b=0){var c=d.max(h.minCellWidth(),i[b]-g);return k(i.slice(0,a)).concat([g,c-i[b]]).concat(k(i.slice(b+1)))}var e=d.max(h.minCellWidth(),i[a]+g),f=i[a]-e;return k(i.slice(0,a)).concat([e-i[a],f]).concat(k(i.slice(b+1)))},o=n,p=function(a,b,c){return n(b,c)},q=function(a,b){if(g>=0)return k(i.slice(0,b)).concat([g]);var c=d.max(h.minCellWidth(),i[b]+g);return k(i.slice(0,b)).concat([c-i[b]])};return j.fold(l,m,o,p,q)};return{determine:f}}),g("38",["24"],function(a){var b=a.immutable("width","height"),c=a.immutable("rows","columns"),d=a.immutable("row","column"),e=a.immutable("x","y"),f=a.immutable("element","rowspan","colspan"),g=a.immutable("element","rowspan","colspan","isNew"),h=a.immutable("element","rowspan","colspan","row","column"),i=a.immutable("element","cells","section"),j=a.immutable("element","isNew"),k=a.immutable("element","cells","section","isNew"),l=a.immutable("cells","section"),m=a.immutable("details","section"),n=a.immutable("startRow","startCol","finishRow","finishCol");return{dimensions:b,grid:c,address:d,coords:e,extended:h,detail:f,detailnew:g,rowdata:i,elementnew:j,rowdatanew:k,rowcells:l,rowdetails:m,bounds:n}}),g("34",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("26",["12","1","n","2","24","34","1w","6"],function(a,b,c,d,e,f,g,h){var i=function(a){return h.fromDom(a.dom().ownerDocument)},j=function(a){var b=i(a);return h.fromDom(b.dom().documentElement)},k=function(a){var b=a.dom(),c=b.ownerDocument.defaultView;return h.fromDom(c)},l=function(a){var b=a.dom();return d.from(b.parentNode).map(h.fromDom)},m=function(a){return l(a).bind(function(c){var d=u(c);return b.findIndex(d,function(b){return g.eq(a,b)})})},n=function(b,d){for(var e=a.isFunction(d)?d:c.constant(!1),f=b.dom(),g=[];null!==f.parentNode&&void 0!==f.parentNode;){var i=f.parentNode,j=h.fromDom(i);if(g.push(j),e(j)===!0)break;f=i}return g},o=function(a){var c=function(c){return b.filter(c,function(b){return!g.eq(a,b)})};return l(a).map(u).map(c).getOr([])},p=function(a){var b=a.dom();return d.from(b.offsetParent).map(h.fromDom)},q=function(a){var b=a.dom();return d.from(b.previousSibling).map(h.fromDom)},r=function(a){var b=a.dom();return d.from(b.nextSibling).map(h.fromDom)},s=function(a){return b.reverse(f.toArray(a,q))},t=function(a){return f.toArray(a,r)},u=function(a){var c=a.dom();return b.map(c.childNodes,h.fromDom)},v=function(a,b){var c=a.dom().childNodes;return d.from(c[b]).map(h.fromDom)},w=function(a){return v(a,0)},x=function(a){return v(a,a.dom().childNodes.length-1)},y=function(a,b){return a.dom().childNodes.length},z=e.immutable("element","offset"),A=function(a,b){var c=u(a);return c.length>0&&b0?c.some(e[0]):c.none()},i=function(b,c){var d=a.bind(b.all(),function(a){return a.cells()});return a.filter(d,c)},j=function(c){var g={},h=[],i=0,j=0;a.each(c,function(b,c){var k=[];a.each(b.cells(),function(a,b){for(var h=0;void 0!==g[f(c,h)];)h++;for(var l=d.extended(a.element(),a.rowspan(),a.colspan(),c,h),m=0;m=e.length-1)return b.none();var g=e[f].fold(function(){var b=a.reverse(e.slice(0,f));return c.findMap(b,function(a,b){return a.map(function(a){return{value:a,delta:b+1}})})},function(a){return b.some({value:a,delta:0})}),h=e[f+1].fold(function(){var a=e.slice(f+1);return c.findMap(a,function(a,b){return a.map(function(a){return{value:a,delta:b+1}})})},function(a){return b.some({value:a,delta:1})});return g.bind(function(a){return h.map(function(b){var c=b.delta+a.delta;return d.abs(b.value-a.value)/c})})};return{repeat:e,range:f,unique:g,deduce:h}}),g("4g",["1","n","2","2g","4h"],function(a,b,c,d,e){var f=function(c){var f=c.grid(),h=e.range(0,f.columns()),i=e.range(0,f.rows());return a.map(h,function(e){var f=function(){return a.bind(i,function(a){return d.getAt(c,a,e).filter(function(a){return a.column()===e}).fold(b.constant([]),function(a){return[a]})})},h=function(a){return 1===a.colspan()},j=function(){return d.getAt(c,0,e)};return g(f,h,j)})},g=function(b,d,e){var f=b(),g=a.find(f,d),h=g.orThunk(function(){return c.from(f[0]).orThunk(e)});return h.map(function(a){return a.element()})},h=function(c){var f=c.grid(),h=e.range(0,f.rows()),i=e.range(0,f.columns());return a.map(h,function(e){var f=function(){return a.bind(i,function(a){return d.getAt(c,e,a).filter(function(a){return a.row()===e}).fold(b.constant([]),function(a){return[a]})})},h=function(a){return 1===a.rowspan()},j=function(){return d.getAt(c,e,0)};return g(f,h,j)})};return{columns:f,rows:h}}),g("2j",["n","2","2y","1a","14","7","1u","2c","2d","2m","33"],function(a,b,c,d,e,f,g,h,i,j,k){var l=/(\d+(\.\d+)?)(\w|%)*/,m=/(\d+(\.\d+)?)%/,n=/(\d+(\.\d+)?)px|em/,o=function(a,b){g.set(a,"width",b+"px")},p=function(a,b){g.set(a,"width",b+"%")},q=function(a,b){g.set(a,"height",b+"px")},r=function(a,b){return g.getRaw(a,b).getOrThunk(function(){return g.get(a,b)})},s=function(a){return r(a,"height")},t=function(a,b,c,e){var f=d.table(a).map(function(a){var d=c(a);return j.floor(b/100*d)}).getOr(b);return e(a,f),f},u=function(a,b,d,f){var g=k(a,10);return c.endsWith(a,"%")&&"table"!==e.name(b)?t(b,g,d,f):g},v=function(a){var b=s(a);return b?u(b,a,h.get,q):h.get(a)},w=function(a,b,c){var d=c(a),e=x(a,b);return d/e},x=function(a,b){return f.has(a,b)?k(f.get(a,b),10):1},y=function(a){var c=g.getRaw(a,"width");return c.fold(function(){return b.from(f.get(a,"width"))},function(a){return b.some(a)})},z=function(a,b){return a/b.pixelWidth()*100},A=function(a,b,c){if(m.test(b)){var d=m.exec(b);return parseFloat(d[1],10)}var e=i.get(a),f=k(e,10);return z(f,c)},B=function(a,b){var c=y(a);return c.fold(function(){var c=i.get(a),d=k(c,10);return z(d,b)},function(c){return A(a,c,b)})},C=function(a,b){return a/100*b.pixelWidth()},D=function(a,b,c){if(n.test(b)){var d=n.exec(b);return k(d[1],10)}if(m.test(b)){var e=m.exec(b),f=parseFloat(e[1],10);return C(f,c)}var g=i.get(a);return k(g,10)},E=function(a,b){var c=y(a);return c.fold(function(){var b=i.get(a),c=k(b,10);return c},function(c){return D(a,c,b)})},F=function(a){return w(a,"rowspan",v)},G=function(c){var d=y(c);return d.bind(function(c){if(l.test(c)){var d=l.exec(c);return b.some({width:a.constant(d[1]),unit:a.constant(d[3])})}return b.none()})},H=function(a,b,c){g.set(a,"width",b+c)};return{percentageBasedSizeRegex:a.constant(m),pixelBasedSizeRegex:a.constant(n),setPixelWidth:o,setPercentageWidth:p,setHeight:q,getPixelWidth:E,getPercentageWidth:B,getGenericWidth:G,setGenericWidth:H,getHeight:F,getRawWidth:y}}),g("2l",["n","7","1u","33"],function(a,b,c,d){var e=function(a,c){return b.has(a,c)&&d(b.get(a,c),10)>1},f=function(a){return e(a,"colspan")},g=function(a){return e(a,"rowspan")},h=function(a,b){return d(c.get(a,b),10)};return{hasColspan:f,hasRowspan:g,minWidth:a.constant(10),minHeight:a.constant(10),getInt:h}}),g("2h",["1","n","4g","2j","2l","4h","1u"],function(a,b,c,d,e,f,g){var h=function(a,b,c){return g.getRaw(a,b).fold(function(){return c(a)+"px"},function(a){return a})},i=function(a){return h(a,"width",d.getPixelWidth)},j=function(a){return h(a,"height",d.getHeight)},k=function(d,g,h,i,j){var k=c.columns(d),l=a.map(k,function(a){return a.map(g.edge)});return a.map(k,function(a,c){var d=a.filter(b.not(e.hasColspan));return d.fold(function(){var a=f.deduce(l,c);return i(a)},function(a){return h(a,j)})})},l=function(a){return a.map(function(a){return a+"px"}).getOr("")},m=function(a,b){return k(a,b,i,l)},n=function(a,b,c){return k(a,b,d.getPercentageWidth,function(a){return a.fold(function(){return c.minCellWidth()},function(a){return a/c.pixelWidth()*100})},c)},o=function(a,b,c){return k(a,b,d.getPixelWidth,function(a){return a.getOrThunk(c.minCellWidth)},c)},p=function(d,g,h,i){var j=c.rows(d),k=a.map(j,function(a){return a.map(g.edge)});return a.map(j,function(a,c){var d=a.filter(b.not(e.hasRowspan));return d.fold(function(){var a=f.deduce(k,c);return i(a)},function(a){return h(a)})})},q=function(a,b){return p(a,b,d.getHeight,function(a){return a.getOrThunk(e.minHeight)})},r=function(a,b){return p(a,b,j,l)};return{getRawWidths:m,getPixelWidths:o,getPercentageWidths:n,getPixelHeights:q,getRawHeights:r}}),g("2i",["1","n","2g","33"],function(a,b,c,d){var e=function(a,b,c){for(var d=0,e=a;e0&&e.setElementWidth(b,l)};return{adjustWidth:n,adjustHeight:o,adjustWidthTo:p}}),g("4u",["1","n","13","12","4b","q"],function(a,b,c,d,e,f){var g=function(a,b){return h(a,b,{validate:d.isFunction,label:"function"})},h=function(b,d,g){if(0===d.length)throw new f("You must specify at least one required field.");return e.validateStrArr("required",d),e.checkDupes(d),function(f){var h=c.keys(f),i=a.forall(d,function(b){return a.contains(h,b)});i||e.reqMessage(d,h),b(d,h);var j=a.filter(d,function(a){return!g.validate(f[a],a)});return j.length>0&&e.invalidTypeMessage(j,g.label),f}},i=function(b,c){var d=a.filter(c,function(c){return!a.contains(b,c)});d.length>0&&e.unsuppMessage(d)},j=b.noop;return{exactly:b.curry(g,i),ensure:b.curry(g,j),ensureWith:b.curry(h,j)}}),g("5e",["4u"],function(a){var b=a.exactly(["compare","extract","mutate","sink"]),c=a.exactly(["element","start","stop","destroy"]),d=a.exactly(["forceDrop","drop","move","delayDrop"]);return{mode:b,sink:c,api:d}}),g("4m",[],function(){var a=function(a){var b=a.replace(/\./g,"-"),c=function(a){return b+"-"+a};return{resolve:c}};return{css:a}}),g("5x",["4m"],function(a){var b=a.css("ephox-dragster");return{resolve:b.resolve}}),g("4w",["12","p","q"],function(a,b,c){var d=function(a,b){return b},e=function(b,c){var d=a.isObject(b)&&a.isObject(c);return d?g(b,c):c},f=function(a){return function(){for(var d=new b(arguments.length),e=0;e0?b.set(d,e,g.join(" ")):b.remove(d,e)};return{read:c,add:d,remove:e}}),g("4o",["1","5i"],function(a,b){var c=function(a){return void 0!==a.dom().classList},d=function(a){return b.read(a,"class")},e=function(a,c){return b.add(a,"class",c)},f=function(a,c){return b.remove(a,"class",c)},g=function(b,c){a.contains(d(b),c)?f(b,c):e(b,c)};return{get:d,add:e,remove:f,toggle:g,supports:c}}),g("2w",["4n","7","4o"],function(a,b,c){var d=function(a,b){c.supports(a)?a.dom().classList.add(b):c.add(a,b)},e=function(a){var d=c.supports(a)?a.dom().classList:c.get(a);0===d.length&&b.remove(a,"class")},f=function(a,b){if(c.supports(a)){var d=a.dom().classList;d.remove(b)}else c.remove(a,b);e(a)},g=function(a,b){return c.supports(a)?a.dom().classList.toggle(b):c.toggle(a,b)},h=function(b,d){var e=c.supports(b),f=b.dom().classList,g=function(){e?f.remove(d):c.remove(b,d)},h=function(){e?f.add(d):c.add(b,d)};return a(g,h,i(b,d))},i=function(a,b){return c.supports(a)&&a.dom().classList.contains(b)};return{add:d,remove:f,toggle:g,toggler:h,has:i}}),g("1o",["26"],function(a){var b=function(b,c){var d=a.parent(b);d.each(function(a){a.dom().insertBefore(c.dom(),b.dom())})},c=function(c,d){var f=a.nextSibling(c);f.fold(function(){var b=a.parent(c);b.each(function(a){e(a,d)})},function(a){b(a,d)})},d=function(b,c){var d=a.firstChild(b);d.fold(function(){e(b,c)},function(a){b.dom().insertBefore(c.dom(),a.dom())})},e=function(a,b){a.dom().appendChild(b.dom())},f=function(c,d,f){a.child(c,f).fold(function(){e(c,d)},function(a){b(a,d)})},g=function(a,c){b(a,c),e(c,a)};return{before:b,after:c,prepend:d,append:e,appendAt:f,wrap:g}}),g("36",["1","1o"],function(a,b){var c=function(c,d){a.each(d,function(a){b.before(c,a)})},d=function(c,d){a.each(d,function(a,e){var f=0===e?c:d[e-1];b.after(f,a)})},e=function(c,d){a.each(d.slice().reverse(),function(a){b.prepend(c,a)})},f=function(c,d){a.each(d,function(a){b.append(c,a)})};return{before:c,after:d,prepend:e,append:f}}),g("1p",["1","36","26"],function(a,b,c){var d=function(b){b.dom().textContent="",a.each(c.children(b),function(a){e(a)})},e=function(a){var b=a.dom();null!==b.parentNode&&b.parentNode.removeChild(b)},f=function(a){var d=c.children(a);d.length>0&&b.before(a,d),e(a)};return{empty:d,remove:e,unwrap:f}}),g("5f",["5x","4w","2w","1u","6","1p"],function(a,b,c,d,e,f){return function(g){var h=b.merge({layerClass:a.resolve("blocker")},g),i=e.fromTag("div");d.setAll(i,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),c.add(i,a.resolve("blocker")),c.add(i,h.layerClass);var j=function(){return i},k=function(){f.remove(i)};return{element:j,destroy:k}}}),g("4p",["n","6"],function(a,b){var c=function(b,c,d,e,f,g,h){return{target:a.constant(b),x:a.constant(c),y:a.constant(d),stop:e,prevent:f,kill:g,raw:a.constant(h)}},d=function(d,e){return function(f){if(d(f)){var g=b.fromDom(f.target),h=function(){f.stopPropagation()},i=function(){f.preventDefault()},j=a.compose(i,h),k=c(g,f.clientX,f.clientY,h,i,j,f);e(k)}}},e=function(b,c,e,f,g){var i=d(e,f);return b.dom().addEventListener(c,i,g),{unbind:a.curry(h,b,c,i,g)}},f=function(a,b,c,d){return e(a,b,c,d,!1)},g=function(a,b,c,d){return e(a,b,c,d,!0)},h=function(a,b,c,d){a.dom().removeEventListener(b,c,d)};return{bind:f,capture:g}}),g("2u",["n","4p"],function(a,b){var c=a.constant(!0),d=function(a,d,e){return b.bind(a,d,c,e)},e=function(a,d,e){return b.capture(a,d,c,e)};return{bind:d,capture:e}}),g("4i",["5e","5f","2","v","2u","1o","1p"],function(a,b,c,d,e,f,g){var h=function(a,b){return d(b.left()-a.left(),b.top()-a.top())},i=function(a){return c.some(d(a.x(),a.y()))},j=function(a,b){a.mutate(b.left(),b.top())},k=function(c,d){var h=b(d),i=e.bind(h.element(),"mousedown",c.forceDrop),j=e.bind(h.element(),"mouseup",c.drop),k=e.bind(h.element(),"mousemove",c.move),l=e.bind(h.element(),"mouseout",c.delayDrop),m=function(){h.destroy(),j.unbind(),k.unbind(),l.unbind(),i.unbind()},n=function(a){f.append(a,h.element())},o=function(){g.remove(h.element())};return a.sink({element:h.element,start:n,stop:o,destroy:m})};return a.mode({compare:h,extract:i,sink:k,mutate:j})}),g("5y",["2","x","y"],function(a,b,c){return function(){var d=a.none(),e=function(){d=a.none()},f=function(b,c){var e=d.map(function(a){return b.compare(a,c)});return d=a.some(c),e},g=function(a,b){var c=b.extract(a);c.each(function(a){var c=f(b,a);c.each(function(a){h.trigger.move(a)})})},h=c.create({move:b(["info"])});return{onEvent:g,reset:e,events:h.registry}}}),g("5z",["n"],function(a){return function(b){var c=function(a,b){};return{onEvent:c,reset:a.noop}}}),g("5g",["5y","5z"],function(a,b){return function(){var c=b(),d=a(),e=c,f=function(){e.reset(),e=d},g=function(){e.reset(),e=c},h=function(a,b){e.onEvent(a,b)},i=function(){return e===d};return{on:f,off:g,isOn:i,onEvent:h,events:d.events}}}),h("60",clearTimeout),h("61",setTimeout),g("5h",["60","61"],function(a,b){var c=function(c,d){var e=null,f=null,g=function(){null!==e&&(a(e),e=null,f=null)},h=function(){f=arguments,null===e&&(e=b(function(){c.apply(null,f),e=null,f=null},d))};return{cancel:g,throttle:h}},d=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var a=arguments;null===e&&(e=b(function(){c.apply(null,a),e=null,a=null},d))};return{cancel:f,throttle:g}},e=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var f=arguments;null!==e&&a(e),e=b(function(){c.apply(null,f),e=null,f=null},d)};return{cancel:f,throttle:g}};return{adaptable:c,first:d,last:e}}),g("4j",["5e","5g","5h","x","y","p"],function(a,b,c,d,e,f){var g=function(g,h,i){var j=!1,k=e.create({start:d([]),stop:d([])}),l=b(),m=function(){t.stop(),l.isOn()&&(l.off(),k.trigger.stop())},n=c.last(m,200),o=function(a){t.start(a),l.on(),k.trigger.start()},p=function(a,b){n.cancel(),l.onEvent(a,h)};l.events.move.bind(function(a){h.mutate(g,a.info())});var q=function(){j=!0},r=function(){j=!1},s=function(a){return function(){var b=f.prototype.slice.call(arguments,0);if(j)return a.apply(null,b)}},t=h.sink(a.api({forceDrop:m,drop:s(m),move:s(p),delayDrop:s(n.throttle)}),i),u=function(){t.destroy()};return{element:t.element,go:o,on:q,off:r,destroy:u,events:k.registry}};return{setup:g}}),g("2n",["4i","4j","p"],function(a,b,c){var d=function(c,d){var e=void 0!==d?d:{},f=void 0!==e.mode?e.mode:a;return b.setup(c,f,d)};return{transform:d}}),g("4k",["x","y"],function(a,b){return function(){var c=b.create({drag:a(["xDelta","yDelta"])}),d=function(a,b){c.trigger.drag(a,b)};return{mutate:d,events:c.registry}}}),g("2o",["2","x","y","4k"],function(a,b,c,d){return function(){var e=c.create({drag:b(["xDelta","yDelta","target"])}),f=a.none(),g=d();g.events.drag.bind(function(a){f.each(function(b){e.trigger.drag(a.xDelta(),a.yDelta(),b)})});var h=function(b){f=a.some(b)},i=function(){return f};return{assign:h,get:i,mutate:g.mutate,events:e.registry}}}),g("4l",["7","1u","6"],function(a,b,c){var d=function(d,e,f,g,h){var i=c.fromTag("div");return b.setAll(i,{position:"absolute",left:e-g/2+"px",top:f+"px",height:h+"px",width:g+"px"}),a.set(i,"data-column",d),i},e=function(d,e,f,g,h){var i=c.fromTag("div");return b.setAll(i,{position:"absolute",left:e+"px",top:f-h/2+"px",height:h+"px",width:g+"px"}),a.set(i,"data-row",d),i};return{col:d,row:e}}),g("2q",["4m"],function(a){var b=a.css("ephox-snooker");return{resolve:b.resolve}}),g("2p",["1","4g","2f","2g","4l","2q","1o","1p","2w","1u","8","2c","u","2d"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=f.resolve("resizer-bar"),p=f.resolve("resizer-rows"),q=f.resolve("resizer-cols"),r=7,s=function(b){var c=k.descendants(b.parent(),"."+o);a.each(c,h.remove)},t=function(b,c,d){var e=b.origin();a.each(c,function(a,c){a.each(function(a){var c=d(e,a);i.add(c,o),g.append(b.parent(),c)})})},u=function(a,b,c,d){t(a,b,function(a,b){var f=e.col(b.col(),b.x()-a.left(),c.top()-a.top(),r,d);return i.add(f,q),f})},v=function(a,b,c,d){t(a,b,function(a,b){var f=e.row(b.row(),c.left()-a.left(),b.y()-a.top(),d,r);return i.add(f,p),f})},w=function(a,b,c,d,e,f){var g=m.absolute(b),h=c.length>0?e.positions(c,b):[];v(a,h,g,n.getOuter(b));var i=d.length>0?f.positions(d,b):[];u(a,i,g,l.getOuter(b))},x=function(a,e,f,g){s(a,e);var h=c.fromTable(e),i=d.generate(h),j=b.rows(i),k=b.columns(i);w(a,e,j,k,f,g)},y=function(b,c){var d=k.descendants(b.parent(),"."+o);a.each(d,c)},z=function(a){y(a,function(a){j.set(a,"display","none")})},A=function(a){y(a,function(a){j.set(a,"display","block")})},B=function(a){return i.has(a,p)},C=function(a){return i.has(a,q)};return{refresh:x,hide:z,show:A,destroy:s,isRowBar:B,isColBar:C}}),g("30",["1h"],function(a){var b=function(b){return a.first(b).isSome()},c=function(b,c,d){return a.ancestor(b,c,d).isSome()},d=function(b,c){return a.sibling(b,c).isSome()},e=function(b,c){return a.child(b,c).isSome()},f=function(b,c){return a.descendant(b,c).isSome()},g=function(b,c,d){return a.closest(b,c,d).isSome()};return{any:b,ancestor:c,sibling:d,child:e,descendant:f,closest:g}}),g("10",["2n","n","2","x","y","2o","2p","2q","2l","1w","2u","1t","14","7","2w","1u","30","1h","33"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){var t=h.resolve("resizer-bar-dragging");return function(h,u,v){var w=f(),x=a.transform(w,{}),y=c.none(),z=function(a,b){return c.from(n.get(a,b))};w.events.drag.bind(function(a){z(a.target(),"data-row").each(function(b){var c=i.getInt(a.target(),"top");p.set(a.target(),"top",c+a.yDelta()+"px")}),z(a.target(),"data-column").each(function(b){var c=i.getInt(a.target(),"left");p.set(a.target(),"left",c+a.xDelta()+"px")})});var A=function(a,b){var c=i.getInt(a,b),d=s(n.get(a,"data-initial-"+b),10);return c-d};x.events.stop.bind(function(){w.get().each(function(a){y.each(function(b){z(a,"data-row").each(function(c){var d=A(a,"top");n.remove(a,"data-initial-top"),H.trigger.adjustHeight(b,d,s(c,10))}),z(a,"data-column").each(function(c){var d=A(a,"left");n.remove(a,"data-initial-left"),H.trigger.adjustWidth(b,d,s(c,10))}),g.refresh(h,b,v,u)})})});var B=function(a,b){H.trigger.startAdjust(),w.assign(a),n.set(a,"data-initial-"+b,s(p.get(a,b),10)),o.add(a,t),p.set(a,"opacity","0.2"),x.go(h.parent())},C=k.bind(h.parent(),"mousedown",function(a){g.isRowBar(a.target())&&B(a.target(),"top"),g.isColBar(a.target())&&B(a.target(),"left")}),D=function(a){return j.eq(a,h.view())},E=k.bind(h.view(),"mouseover",function(a){"table"===m.name(a.target())||q.ancestor(a.target(),"table",D)?(y="table"===m.name(a.target())?c.some(a.target()):r.ancestor(a.target(),"table",D),y.each(function(a){g.refresh(h,a,v,u)})):l.inBody(a.target())&&g.destroy(h)}),F=function(){C.unbind(),E.unbind(),x.destroy(),g.destroy(h)},G=function(a){g.refresh(h,a,v,u)},H=e.create({adjustHeight:d(["table","delta","row"]),adjustWidth:d(["table","delta","column"]),startAdjust:d([])});return{destroy:F,refresh:G,on:x.on,off:x.off,hideBars:b.curry(g.hide,h),showBars:b.curry(g.show,h),events:H.registry}}}),g("5",["x","y","z","10","11"],function(a,b,c,d,e){return function(f,g){var h=e.height,i=d(f,g,h),j=b.create({beforeResize:a(["table"]),afterResize:a(["table"]),startDrag:a([])});return i.events.adjustHeight.bind(function(a){j.trigger.beforeResize(a.table());var b=h.delta(a.delta(),a.table());c.adjustHeight(a.table(),b,a.row(),h),j.trigger.afterResize(a.table())}),i.events.startAdjust.bind(function(a){j.trigger.startDrag()}),i.events.adjustWidth.bind(function(a){j.trigger.beforeResize(a.table());var b=g.delta(a.delta(),a.table());c.adjustWidth(a.table(),b,a.column(),g),j.trigger.afterResize(a.table())}),{on:i.on,off:i.off,hideBars:i.hideBars,showBars:i.showBars,destroy:i.destroy,events:j.registry}}}),h("17",tinymce.util.Tools.resolve),g("9",["17"],function(a){return a("tinymce.PluginManager")}),g("a",["17"],function(a){return a("tinymce.util.Tools")}),g("18",["1","13","24","2f","2g","35","7","1u","6","1o","1p","16"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=c.immutable("minRow","minCol","maxRow","maxCol"),n=function(a,c){var d=a.grid().columns(),e=a.grid().rows(),f=e,g=d,h=0,i=0;return b.each(a.access(),function(a){if(c(a)){var b=a.row(),d=b+a.rowspan()-1,e=a.column(),j=e+a.colspan()-1;bh&&(h=d),ei&&(i=j)}}),m(f,g,h,i)},o=function(a,b,c){var d=a[c].element(),e=i.fromTag("td");j.append(e,i.fromTag("br"));var f=b?j.append:j.prepend;f(d,e)},p=function(a,b,c,d){for(var f=b.grid().columns(),g=b.grid().rows(),h=0;hc.maxRow()||jc.maxCol())){var k=e.getAt(b,h,j).filter(d).isNone();k?o(a,i,h):i=!0}},q=function(b,c){var d=a.filter(f.firstLayer(b,"tr"),function(a){return 0===a.dom().childElementCount});a.each(d,k.remove),c.minCol()!==c.maxCol()&&c.minRow()!==c.maxRow()||a.each(f.firstLayer(b,"th,td"),function(a){g.remove(a,"rowspan"),g.remove(a,"colspan")}),g.remove(b,"width"),g.remove(b,"height"),h.remove(b,"width"),h.remove(b,"height")},r=function(b,c){var g=function(a){return l.is(a.element(),c)},h=d.fromTable(b),i=e.generate(h),j=n(i,g),m="th:not("+c+"),td:not("+c+")",o=f.filterFirstLayer(b,"th,td",function(a){return l.is(a,m)});return a.each(o,k.remove),p(h,i,j,g),q(b,j),b};return{extract:r}}),g("1b",["7","6","1o","36","1p","26"],function(a,b,c,d,e,f){var g=function(a,c){return b.fromDom(a.dom().cloneNode(c))},h=function(a){return g(a,!1)},i=function(a){return g(a,!0)},j=function(c,d){var e=b.fromTag(d),f=a.clone(c);return a.setAll(e,f),e},k=function(a,b){var c=j(a,b),e=f.children(i(a));return d.append(c,e),c},l=function(a,b){var g=j(a,b);c.before(a,g);var h=f.children(a);return d.append(g,h),e.remove(a),g};return{shallow:h,shallowAs:j,deep:i,copy:k,mutate:l}}),g("46",["2s","2","q"],function(a,b,c){return function(d,e){var f=function(a){if(!d(a))throw new c("Can only get "+e+" value of a "+e+" node");return j(a).getOr("")},g=function(a){try{return h(a)}catch(a){return b.none()}},h=function(a){return d(a)?b.from(a.dom().nodeValue):b.none()},i=a.detect().browser,j=i.isIE()&&10===i.version.major?g:h,k=function(a,b){if(!d(a))throw new c("Can only set raw "+e+" value of a "+e+" node");a.dom().nodeValue=b};return{get:f,getOption:j,set:k}}}),g("25",["14","46"],function(a,b){var c=b(a.isText,"text"),d=function(a){return c.get(a)},e=function(a){return c.getOption(a)},f=function(a,b){c.set(a,b)};return{get:d,getOption:e,set:f}}),g("37",["1","14","25","26"],function(a,b,c,d){var e=function(a){return"img"===b.name(a)?1:c.getOption(a).fold(function(){return d.children(a).length},function(a){return a.length})},f=function(a,b){return e(a)===b},g=function(a,b){return 0===b},h="\xa0",i=function(a){return c.getOption(a).filter(function(a){return 0!==a.trim().length||a.indexOf(h)>-1}).isSome()},j=["img","br"],k=function(c){var d=i(c);return d||a.contains(j,b.name(c))};return{getEnd:e,isEnd:f,isStart:g,isCursorPosition:k}}),g("1x",["2","31","26","37"],function(a,b,c,d){var e=function(a){return b.descendant(a,d.isCursorPosition)},f=function(a){return g(a,d.isCursorPosition)},g=function(b,d){var e=function(b){for(var f=c.children(b),g=f.length-1;g>=0;g--){var h=f[g];if(d(h))return a.some(h);var i=e(h);if(i.isSome())return i}return a.none()};return e(b)};return{first:e,last:f}}),g("19",["1","13","1w","1o","1b","6","14","7","1u","8","26","1x"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=function(){var a=f.fromTag("td");return d.append(a,f.fromTag("br")),a},n=function(a,c,d){var f=e.copy(a,c);return b.each(d,function(a,b){null===a?h.remove(f,b):h.set(f,b,a)}),f},o=function(a){return a},p=function(a){return function(){return f.fromTag("tr",a.dom())}},q=function(b,f,g){var h=l.first(b);return h.map(function(h){var i=g.join(","),k=j.ancestors(h,i,function(a){return c.eq(a,b)});return a.foldr(k,function(a,b){var c=e.shallow(b);return d.append(a,c),c},f)}).getOr(f)},r=function(a,b,c){var e=function(b){var e=k.owner(b.element()),h=f.fromTag(g.name(b.element()),e.dom()),j=c.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),l=j.length>0?q(b.element(),h,j):h;return d.append(l,f.fromTag("br")),i.copy(b.element(),h),i.remove(h,"height"),1!==b.colspan()&&i.remove(b.element(),"width"),a(b.element(),h),h};return{row:p(b),cell:e,replace:n,gap:m}},s=function(a){return{row:p(a),cell:m,replace:o,gap:m}};return{cellOperations:r,paste:s}}),g("1c",["1","6","26","t"],function(a,b,c,d){var e=function(a,e){var f=e||d,g=f.createElement("div");return g.innerHTML=a,c.children(b.fromDom(g))},f=function(c,d){return a.map(c,function(a){return b.fromTag(a,d)})},g=function(c,d){return a.map(c,function(a){return b.fromText(a,d)})},h=function(c){return a.map(c,b.fromDom)};return{fromHtml:e,fromTags:f,fromText:g,fromDom:h}}),g("62",[],function(){return["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"]}),g("5j",["62","1","n","7","1w","1u","6","1o","36","14","15","31","1p","8","1h","25","26"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){return function(){var r=function(a){return g.fromDom(a.dom().cloneNode(!1))},s=function(c){return!!j.isElement(c)&&("body"===j.name(c)||b.contains(a,j.name(c)))},t=function(a){return!!j.isElement(a)&&b.contains(["br","img","hr","input"],j.name(a))},u=function(a,b){return a.dom().compareDocumentPosition(b.dom())},v=function(a,b){var c=d.clone(a);d.setAll(b,c)};return{up:c.constant({selector:o.ancestor,closest:o.closest,predicate:l.ancestor,all:q.parents}),down:c.constant({selector:n.descendants,predicate:k.descendants}),styles:c.constant({get:f.get,getRaw:f.getRaw,set:f.set,remove:f.remove}),attrs:c.constant({get:d.get,set:d.set,remove:d.remove,copyTo:v}),insert:c.constant({before:h.before,after:h.after,afterAll:i.after,append:h.append,appendAll:i.append,prepend:h.prepend,wrap:h.wrap}),remove:c.constant({unwrap:m.unwrap,remove:m.remove}),create:c.constant({nu:g.fromTag,clone:r,text:g.fromText}),query:c.constant({comparePosition:u,prevSibling:q.prevSibling,nextSibling:q.nextSibling}),property:c.constant({children:q.children,name:j.name,parent:q.parent,isText:j.isText,isComment:j.isComment,isElement:j.isElement,getText:p.get,setText:p.set,isBoundary:s, +isEmptyTag:t}),eq:e.eq,is:e.is}}}),g("63",["1","n","2","24"],function(a,b,c,d){var e=d.immutable("left","right"),f=function(c,d,e){var f=c.property().children(d),g=a.findIndex(f,b.curry(c.eq,e));return g.map(function(a){return{before:b.constant(f.slice(0,a)),after:b.constant(f.slice(a+1))}})},g=function(a,b,c){return f(a,b,c).map(function(c){var d=a.create().clone(b);return a.insert().appendAll(d,c.after()),a.insert().after(b,d),e(b,d)})},h=function(a,b,c){return f(a,b,c).map(function(d){var f=a.create().clone(b);return a.insert().appendAll(f,d.before().concat([c])),a.insert().appendAll(b,d.after()),a.insert().before(b,f),e(f,b)})},i=function(a,b,e,f){var g=d.immutable("first","second","splits"),h=function(b,d,i){var j=g(b,c.none(),i);return e(b)?g(b,d,i):a.property().parent(b).bind(function(d){return f(a,d,b).map(function(a){var b=[{first:a.left,second:a.right}],f=e(d)?d:a.left();return h(f,c.some(a.right()),i.concat(b))}).getOr(j)})};return h(b,c.none(),[])};return{breakToLeft:h,breakToRight:g,breakPath:i}}),g("64",["1","n","2"],function(a,b,c){var d=function(a,b,c,d){var e=c[0],f=c.slice(1);return d(a,b,e,f)},e=function(a,b,e){return e.length>0?d(a,b,e,f):c.none()},f=function(b,c,d,e){var f=c(b,d);return a.foldr(e,function(a,d){var e=c(b,d);return g(b,a,e)},f)},g=function(a,c,d){return c.bind(function(c){return d.filter(b.curry(a.eq,c))})};return{oneAll:e}}),g("65",["1","n","2","2m"],function(a,b,c,d){var e=function(a,c){return b.curry(a.eq,c)},f=function(b,f,g,h){var i=b.property().children(f);if(b.eq(f,g[0]))return c.some([g[0]]);if(b.eq(f,h[0]))return c.some([h[0]]);var j=function(c){var d=a.reverse(c),g=a.findIndex(d,e(b,f)).getOr(-1),h=g=a.startCol()&&e<=a.finishRow()&&f>=a.startRow()},e=function(a,b){return b.column()>=a.startCol()&&b.column()+b.colspan()-1<=a.finishCol()&&b.row()>=a.startRow()&&b.row()+b.rowspan()-1<=a.finishRow()},f=function(d,f){for(var g=!0,h=a.curry(e,f),i=f.startRow();i<=f.finishRow();i++)for(var j=f.startCol();j<=f.finishCol();j++)g=g&&c.getAt(d,i,j).exists(h);return g?b.some(f):b.none()};return{inSelection:d,isWithin:e,isRectangular:f}}),g("4s",["38","2g","5l","1w","2m"],function(a,b,c,d,e){var f=function(b,c){return a.bounds(e.min(b.row(),c.row()),e.min(b.column(),c.column()),e.max(b.row()+b.rowspan()-1,c.row()+c.rowspan()-1),e.max(b.column()+b.colspan()-1,c.column()+c.colspan()-1))},g=function(a,c,e){var g=b.findItem(a,c,d.eq),h=b.findItem(a,e,d.eq);return g.bind(function(a){return h.map(function(b){return f(a,b)})})},h=function(a,b,d){return g(a,b,d).bind(function(b){return c.isRectangular(a,b)})};return{getAnyBox:g,getBox:h}}),g("4r",["1","n","2g","5l","4s","1w"],function(a,b,c,d,e,f){var g=function(a,b,d,e){return c.findItem(a,b,f.eq).bind(function(b){var f=d>0?b.row()+b.rowspan()-1:b.row(),g=e>0?b.column()+b.colspan()-1:b.column(),h=c.getAt(a,f+d,g+e);return h.map(function(a){return a.element()})})},h=function(f,g,h){return e.getAnyBox(f,g,h).map(function(e){var g=c.filterItems(f,b.curry(d.inSelection,e));return a.map(g,function(a){return a.element()})})},i=function(a,b){var d=function(a,b){return f.contains(b,a)};return c.findItem(a,b,d).bind(function(a){return a.element()})};return{moveBy:g,intercepts:h,parentCell:i}}),g("47",["1a","2f","2g","4r","4s","1w"],function(a,b,c,d,e,f){var g=function(b,c,e){return a.table(b).bind(function(a){var f=k(a);return d.moveBy(f,b,c,e)})},h=function(a,b,c){var e=k(a);return d.intercepts(e,b,c)},i=function(a,b,c,e,g){var h=k(a),i=f.eq(a,c)?b:d.parentCell(h,b),j=f.eq(a,g)?e:d.parentCell(h,e);return d.intercepts(h,i,j)},j=function(a,b,c){var d=k(a);return e.getBox(d,b,c)},k=function(a){var d=b.fromTable(a);return c.generate(d)};return{moveBy:g,intercepts:h,nestedIntercepts:i,getBox:j}}),g("43",["1","n","2","4q","47","1w","8","1h","16"],function(a,b,c,d,e,f,g,h,i){var j=function(a,b){return h.ancestor(a,"table")},k=function(a,b,g){return f.eq(a,b)?c.some([a]):j(a,g).bind(function(c){return j(b,g).bind(function(i){return f.eq(c,i)?e.intercepts(c,a,b):f.contains(c,i)?e.nestedIntercepts(c,a,c,b,i):f.contains(i,c)?e.nestedIntercepts(i,a,c,b,i):d.ancestors(a,b).shared().bind(function(d){return h.closest(d,"table",g).bind(function(d){return e.nestedIntercepts(d,a,c,b,i)})})})})},l=function(a,b){var d=g.descendants(a,b);return d.length>0?c.some(d):c.none()},m=function(b,c){return a.find(b,function(a){return i.is(a,c)})},n=function(a,c,e){return h.descendant(a,c).bind(function(c){return h.descendant(a,e).bind(function(a){return d.sharedOne(j,[c,a]).map(function(d){return{first:b.constant(c),last:b.constant(a),table:b.constant(d)}})})})},o=function(a,c){return h.ancestor(a,"table").bind(function(d){return h.descendant(d,c).bind(function(c){return k(c,a).map(function(d){return{boxes:b.constant(d),start:b.constant(c),finish:b.constant(a)}})})})},p=function(a,b,c,d,f){return m(a,f).bind(function(a){return e.moveBy(a,b,c).bind(function(a){return o(a,d)})})};return{identify:k,retrieve:l,shiftSelection:p,getEdges:n}}),g("28",["43","2","47","1w","1h"],function(a,b,c,d,e){var f=function(b,c){return a.retrieve(b,c)},g=function(f,g,h){return a.getEdges(f,g,h).bind(function(a){var g=function(a){return d.eq(f,a)},h=e.ancestor(a.first(),"thead,tfoot,tbody,table",g),i=e.ancestor(a.last(),"thead,tfoot,tbody,table",g);return h.bind(function(e){return i.bind(function(f){return d.eq(e,f)?c.getBox(a.table(),a.first(),a.last()):b.none()})})})};return{retrieve:f,retrieveBox:g}}),g("j",["n"],function(a){var b="data-mce-selected",c="td["+b+"],th["+b+"]",d="["+b+"]",e="data-mce-first-selected",f="td["+e+"],th["+e+"]",g="data-mce-last-selected",h="td["+g+"],th["+g+"]";return{selected:a.constant(b),selectedSelector:a.constant(c),attributeSelector:a.constant(d),firstSelected:a.constant(e),firstSelectedSelector:a.constant(f),lastSelected:a.constant(g),lastSelectedSelector:a.constant(h)}}),g("3a",["1","13","12","p","q","s"],function(a,b,c,d,e,f){var g=function(g){if(!c.isArray(g))throw new e("cases must be an array");if(0===g.length)throw new e("there must be at least one case");var h=[],i={};return a.each(g,function(j,k){var l=b.keys(j);if(1!==l.length)throw new e("one and only one name per case");var m=l[0],n=j[m];if(void 0!==i[m])throw new e("duplicate key detected:"+m);if("cata"===m)throw new e("cannot have a case named cata (sorry)");if(!c.isArray(n))throw new e("case arguments must be an array");h.push(m),i[m]=function(){var c=arguments.length;if(c!==n.length)throw new e("Wrong number of arguments to case "+m+". Expected "+n.length+" ("+n+"), got "+c);for(var i=new d(c),j=0;j1||e.has(a,"colspan")&&parseInt(e.get(a,"colspan"),10)>1},g=h(a,c);return g.length>0&&b.forall(g,f)?d.some(g):d.none()},j=function(b,e){return g.cata(e.get(),d.none,function(e,g){return 0===e.length?d.none():a.retrieveBox(b,f.firstSelectedSelector(),f.lastSelectedSelector()).bind(function(a){return e.length>1?d.some({bounds:c.constant(a),cells:c.constant(e)}):d.none()})},d.none)};return{mergable:j,unmergable:i,selection:h}}),g("1d",["n","2","24","39"],function(a,b,c,d){var e=function(c){return{element:a.constant(c),mergable:b.none,unmergable:b.none,selection:a.constant([c])}},f=function(b,c,e){return{element:a.constant(e),mergable:a.constant(d.mergable(c,b)),unmergable:a.constant(d.unmergable(e,b)),selection:a.constant(d.selection(e,b))}},g=function(a){return e(a)},h=c.immutable("element","clipboard","generators"),i=function(c,e,f,g,h){return{element:a.constant(f),mergable:b.none,unmergable:b.none,selection:a.constant(d.selection(f,c)),clipboard:a.constant(g),generators:a.constant(h)}};return{noMenu:e,forMenu:f,notCell:g,paste:h,pasteRows:i}}),g("b",["1","n","2","18","19","1a","1b","6","1c","14","1d","j","1e"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(a){return f.table(a[0]).map(g.deep).map(function(a){return[d.extract(a,l.attributeSelector())]})},o=function(a,b){return a.selection.serializer.serialize(b.dom(),{})},p=function(d,g,l,p){d.on("BeforeGetContent",function(c){var e=function(b){c.preventDefault(),n(b).each(function(b){c.content=a.map(b,function(a){return o(d,a)}).join("")})};c.selection===!0&&m.cata(g.get(),b.noop,e,b.noop)}),d.on("BeforeSetContent",function(b){if(b.selection===!0&&b.paste===!0){var g=c.from(d.dom.getParent(d.selection.getStart(),"th,td"));g.each(function(c){var g=h.fromDom(c),m=f.table(g);m.bind(function(c){var f=a.filter(i.fromHtml(b.content),function(a){return"meta"!==j.name(a)});if(1===f.length&&"table"===j.name(f[0])){b.preventDefault();var m=h.fromDom(d.getDoc()),n=e.paste(m),o=k.paste(g,f[0],n);l.pasteCells(c,o).each(function(a){d.selection.setRng(a),d.focus(),p.clear(c)})}})})}})};return{registerEvents:p}}),g("3b",["7","1u","6","1o","36"],function(a,b,c,d,e){var f=function(){return c.fromTag("table")},g=function(){return c.fromTag("tbody")},h=function(){return c.fromTag("tr")},i=function(){return c.fromTag("th")},j=function(){return c.fromTag("td")},k=function(k,l,m,n){var o=f();b.setAll(o,{"border-collapse":"collapse",width:"100%"}),a.set(o,"border","1");var p=g();d.append(o,p);for(var q=[],r=0;r0?n(a,b):o(b)},q=[],r=[],s=[];return a.each(h,function(a){switch(a.section()){case"thead":q.push(a);break;case"tbody":r.push(a);break;case"tfoot":s.push(a)}}),p(q,"thead"),p(r,"tbody"),p(s,"tfoot"),{newRows:b.constant(l),newCells:b.constant(m)}},m=function(b){var c=a.map(b,function(b){var c=h.shallow(b.element());return a.each(b.cells(),function(a){var b=h.deep(a.element());k(b,"colspan",a.colspan(),1),k(b,"rowspan",a.rowspan(),1),e.append(c,b)}),c});return c};return{render:l,copy:m}}),g("3f",["1","4w","n","2","44","38","1a","2f","3h","2g","3l","11","2p","1w","26"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=function(a,b){return i.toGrid(a,b,!1)},q=function(b,c){var d=function(a){var b=e.findMap(a,function(a){return o.parent(a.element()).map(function(a){var b=o.parent(a).isNone();return f.elementnew(a,b)})});return b.getOrThunk(function(){return f.elementnew(c.row(),!0)})};return a.map(b,function(a){var b=d(a.details());return f.rowdatanew(b.element(),a.details(),a.section(),b.isNew())})},r=function(a,b){var c=i.toDetails(a,n.eq);return q(c,b)},s=function(b,c){var d=a.flatten(a.map(b.all(),function(a){return a.cells()}));return a.find(d,function(a){return n.eq(c,a.element())})},t=function(a,b,e,f,g){return function(i,o,q,s,t){var u=h.fromTable(o),v=j.generate(u),w=b(v,q).map(function(b){var d=p(v,s),e=a(d,b,n.eq,g(s)),f=r(e.grid(),s);return{grid:c.constant(f),cursor:e.cursor}});return w.fold(function(){return d.none()},function(a){var b=k.render(o,a.grid());return e(o,a.grid(),t),f(o),m.refresh(i,o,l.height,t),d.some({cursor:a.cursor,newRows:b.newRows,newCells:b.newCells})})}},u=function(a,b){return g.cell(b.element()).bind(function(b){return s(a,b)})},v=function(a,c){return g.cell(c.element()).bind(function(d){return s(a,d).map(function(a){return b.merge(a,{generators:c.generators,clipboard:c.clipboard})})})},w=function(c,f){var h=a.map(f.selection(),function(a){return g.cell(a).bind(function(a){return s(c,a)})}),i=e.cat(h);return i.length>0?d.some(b.merge({cells:i},{generators:f.generators,clipboard:f.clipboard})):d.none()},x=function(a,b){return b.mergable()},y=function(a,b){return b.unmergable()},z=function(b,c){var f=a.map(c.selection(),function(a){return g.cell(a).bind(function(a){return s(b,a)})}),h=e.cat(f);return h.length>0?d.some(h):d.none()};return{run:t,toDetailList:r,onCell:u,onCells:z,onPaste:v,onPasteRows:w,onMergable:x,onUnmergable:y}}),g("5n",["n","2"],function(a,b){var c=function(d){var e=function(a){return d===a},f=function(a){return c(d)},g=function(a){return c(d)},h=function(a){return c(a(d))},i=function(a){a(d)},j=function(a){return a(d)},k=function(a,b){return b(d)},l=function(a){return a(d)},m=function(a){return a(d)},n=function(){return b.some(d)};return{is:e,isValue:a.constant(!0),isError:a.constant(!1),getOr:a.constant(d),getOrThunk:a.constant(d),getOrDie:a.constant(d),or:f,orThunk:g,fold:k,map:h,each:i,bind:j,exists:l,forall:m,toOption:n}},d=function(c){var e=function(a){return a()},f=function(){return a.die(c)()},g=function(a){return a},h=function(a){return a()},i=function(a){return d(c)},j=function(a){return d(c)},k=function(a,b){return a(c)};return{is:a.constant(!1),isValue:a.constant(!1),isError:a.constant(!0),getOr:a.identity,getOrThunk:e,getOrDie:f,or:g,orThunk:h,fold:k,map:i,each:a.noop,bind:j,exists:a.constant(!1),forall:a.constant(!0),toOption:b.none}};return{value:c,error:d}}),g("4y",["1","n","5n","38","3e","4h","p","q","2m"],function(a,b,c,d,e,f,g,h,i){var j=function(a,d,f){if(a.row()>=d.length||a.column()>e.cellLength(d[0]))return c.error("invalid start address out of table bounds, row: "+a.row()+", column: "+a.column());var g=d.slice(a.row()),h=g[0].cells().slice(a.column()),i=e.cellLength(f[0]),j=f.length;return c.value({rowDelta:b.constant(g.length-j),colDelta:b.constant(h.length-i)})},k=function(a,c){var d=e.cellLength(a[0]),f=e.cellLength(c[0]);return{rowDelta:b.constant(0),colDelta:b.constant(d-f)}},l=function(b,c){return a.map(b,function(){return d.elementnew(c.cell(),!0)})},m=function(a,b,c){return a.concat(f.repeat(b,function(b){return e.setCells(a[a.length-1],l(a[a.length-1].cells(),c))}))},n=function(b,c,d){return a.map(b,function(a){return e.setCells(a,a.cells().concat(l(f.range(0,c),d)))})},o=function(a,c,d){var e=c.colDelta()<0?n:b.identity,f=c.rowDelta()<0?m:b.identity,g=e(a,i.abs(c.colDelta()),d),h=f(g,i.abs(c.rowDelta()),d);return h};return{measure:j,measureWidth:k,tailor:o}}),g("3i",["1","2","38","3e"],function(a,b,c,d){var e=function(a,b,e,f){if(0===a.length)return a;for(var g=b.startRow();g<=b.finishRow();g++)for(var h=b.startCol();h<=b.finishCol();h++)d.mutateCell(a[g],h,c.elementnew(f(),!1));return a},f=function(a,b,e,f){for(var g=!0,h=0;h0&&f1&&d.cellLength(i)>1&&(e>0&&h(d.getCellElement(i,e-1))||e0&&h(d.getCellElement(b[c-1],e))||c0&&d0&&e0})},i=function(a,b,c){return a.slice(0,b).concat(a.slice(c+1))};return{insertRowAt:d,insertColumnAt:e,splitCellIntoColumns:f,splitCellIntoRows:g,deleteRowsAt:i,deleteColumnsAt:h}}),g("3k",["1","38","3e"],function(a,b,c){var d=function(d,e,f,g){var h=function(b){return a.exists(e,function(a){return f(b.element(),a.element())})};return a.map(d,function(a){return c.mapCells(a,function(a){return h(a)?b.elementnew(g(a.element(),f),!0):a})})},e=function(a,b,d,e){return void 0!==c.getCellElement(a[b],d)&&b>0&&e(c.getCellElement(a[b-1],d),c.getCellElement(a[b],d))},f=function(a,b,d){return b>0&&d(c.getCellElement(a,b-1),c.getCellElement(a,b))},g=function(b,g,h,i){var j=a.bind(b,function(a,d){var i=e(b,d,g,h)||f(a,g,h);return i?[]:[c.getCell(a,g)]});return d(b,j,h,i)},h=function(b,c,g,h){var i=b[c],j=a.bind(i.cells(),function(a,d){var h=e(b,c,d,g)||f(i,d,g);return h?[]:[a]});return d(b,j,g,h)};return{replaceColumn:g,replaceRow:h}}),g("1k",["1","n","2","24","3c","38","3d","1a","2f","3e","3f","3g","3h","2g","3i","3j","3k","z","1p"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){var t=function(a){var b=h.cells(a);0===b.length&&s.remove(a)},u=d.immutable("grid","cursor"),v=function(a,b,c){return w(a,b,c).orThunk(function(){return w(a,0,0)})},w=function(a,b,d){return c.from(a[b]).bind(function(a){return c.from(a.cells()[d]).bind(function(a){return c.from(a.element())})})},x=function(a,b,c){return u(a,w(a,b,c))},y=function(b){return a.foldl(b,function(b,c){return a.exists(b,function(a){return a.row()===c.row()})?b:b.concat([c])},[]).sort(function(a,b){return a.row()-b.row()})},z=function(b){return a.foldl(b,function(b,c){return a.exists(b,function(a){return a.column()===c.column()})?b:b.concat([c])},[]).sort(function(a,b){return a.column()-b.column()})},A=function(a,b,c,d){var e=b.row(),f=b.row(),g=p.insertRowAt(a,f,e,c,d.getOrInit);return x(g,f,b.column())},B=function(b,c,d,e){var f=c[0].row(),g=c[0].row(),h=y(c),i=a.foldl(h,function(a,b){return p.insertRowAt(a,g,f,d,e.getOrInit)},b);return x(i,g,c[0].column())},C=function(a,b,c,d){var e=b.row(),f=b.row()+b.rowspan(),g=p.insertRowAt(a,f,e,c,d.getOrInit);return x(g,f,b.column())},D=function(b,c,d,e){var f=y(c),g=f[f.length-1].row(),h=f[f.length-1].row()+f[f.length-1].rowspan(),i=a.foldl(f,function(a,b){return p.insertRowAt(a,h,g,d,e.getOrInit)},b);return x(i,h,c[0].column())},E=function(a,b,c,d){var e=b.column(),f=b.column(),g=p.insertColumnAt(a,f,e,c,d.getOrInit);return x(g,b.row(),f)},F=function(b,c,d,e){var f=z(c),g=f[0].column(),h=f[0].column(),i=a.foldl(f,function(a,b){return p.insertColumnAt(a,h,g,d,e.getOrInit)},b);return x(i,c[0].row(),h)},G=function(a,b,c,d){var e=b.column(),f=b.column()+b.colspan(),g=p.insertColumnAt(a,f,e,c,d.getOrInit);return x(g,b.row(),f)},H=function(b,c,d,e){var f=c[c.length-1].column(),g=c[c.length-1].column()+c[c.length-1].colspan(),h=z(c),i=a.foldl(h,function(a,b){return p.insertColumnAt(a,g,f,d,e.getOrInit)},b);return x(i,c[0].row(),g)},I=function(a,b,c,d){var e=q.replaceRow(a,b.row(),c,d.replaceOrInit);return x(e,b.row(),b.column())},J=function(a,b,c,d){var e=q.replaceColumn(a,b.column(),c,d.replaceOrInit);return x(e,b.row(),b.column())},K=function(a,b,c,d){var e=q.replaceRow(a,b.row(),c,d.replaceOrInit);return x(e,b.row(),b.column())},L=function(a,b,c,d){var e=q.replaceColumn(a,b.column(),c,d.replaceOrInit);return x(e,b.row(),b.column())},M=function(a,b,c,d){var e=p.splitCellIntoColumns(a,b.row(),b.column(),c,d.getOrInit);return x(e,b.row(),b.column())},N=function(a,b,c,d){var e=p.splitCellIntoRows(a,b.row(),b.column(),c,d.getOrInit);return x(e,b.row(),b.column())},O=function(a,b,c,d){var e=z(b),f=p.deleteColumnsAt(a,e[0].column(),e[e.length-1].column()),g=v(f,b[0].row(),b[0].column());return u(f,g)},P=function(a,b,c,d){var e=y(b),f=p.deleteRowsAt(a,e[0].row(),e[e.length-1].row()),g=v(f,b[0].row(),b[0].column());return u(f,g)},Q=function(a,d,e,f){var h=d.cells();g.merge(h);var i=o.merge(a,d.bounds(),e,b.constant(h[0]));return u(i,c.from(h[0]))},R=function(b,d,e,f){var g=a.foldr(d,function(a,b){return o.unmerge(a,b,e,f.combine(b))},b);return u(g,c.from(d[0]))},S=function(a,b,d,e){var g=function(a,b){var c=i.fromTable(a),d=n.generate(c);return m.toGrid(d,b,!0)},h=g(b.clipboard(),b.generators()),j=f.address(b.row(),b.column()),k=l.merge(j,a,h,b.generators(),d);return k.fold(function(){return u(a,c.some(b.element()))},function(a){var c=v(a,b.row(),b.column());return u(a,c)})},T=function(a,b,c){var d=i.fromPastedRows(a,c),e=n.generate(d);return m.toGrid(e,b,!0)},U=function(a,b,c,d){var e=a[b.cells[0].row()],f=b.cells[0].row(),g=T(b.clipboard(),b.generators(),e),h=l.insert(f,a,g,b.generators(),c),i=v(h,b.cells[0].row(),b.cells[0].column());return u(h,i)},V=function(a,b,c,d){var e=a[b.cells[0].row()],f=b.cells[b.cells.length-1].row()+b.cells[b.cells.length-1].rowspan(),g=T(b.clipboard(),b.generators(),e),h=l.insert(f,a,g,b.generators(),c),i=v(h,b.cells[0].row(),b.cells[0].column()); +return u(h,i)},W=r.adjustWidthTo;return{insertRowBefore:k.run(A,k.onCell,b.noop,b.noop,e.modification),insertRowsBefore:k.run(B,k.onCells,b.noop,b.noop,e.modification),insertRowAfter:k.run(C,k.onCell,b.noop,b.noop,e.modification),insertRowsAfter:k.run(D,k.onCells,b.noop,b.noop,e.modification),insertColumnBefore:k.run(E,k.onCell,W,b.noop,e.modification),insertColumnsBefore:k.run(F,k.onCells,W,b.noop,e.modification),insertColumnAfter:k.run(G,k.onCell,W,b.noop,e.modification),insertColumnsAfter:k.run(H,k.onCells,W,b.noop,e.modification),splitCellIntoColumns:k.run(M,k.onCell,W,b.noop,e.modification),splitCellIntoRows:k.run(N,k.onCell,b.noop,b.noop,e.modification),eraseColumns:k.run(O,k.onCells,W,t,e.modification),eraseRows:k.run(P,k.onCells,b.noop,t,e.modification),makeColumnHeader:k.run(J,k.onCell,b.noop,b.noop,e.transform("row","th")),unmakeColumnHeader:k.run(L,k.onCell,b.noop,b.noop,e.transform(null,"td")),makeRowHeader:k.run(I,k.onCell,b.noop,b.noop,e.transform("col","th")),unmakeRowHeader:k.run(K,k.onCell,b.noop,b.noop,e.transform(null,"td")),mergeCells:k.run(Q,k.onMergable,b.noop,b.noop,e.merging),unmergeCells:k.run(R,k.onUnmergable,W,b.noop,e.merging),pasteCells:k.run(S,k.onPaste,W,b.noop,e.modification),pasteRowsBefore:k.run(U,k.onPasteRows,b.noop,b.noop,e.modification),pasteRowsAfter:k.run(V,k.onPasteRows,b.noop,b.noop,e.modification)}}),g("1l",["1w","6"],function(a,b){var c=function(a){return b.fromDom(a.getBody())},d=function(b){return function(d){return a.eq(d,c(b))}},e=function(a){return a?a.replace(/px$/,""):""},f=function(a){return/^[0-9]+$/.test(a)&&(a+="px"),a};return{getBody:c,getIsRoot:d,addSizeSuffix:f,removePxSuffix:e}}),g("1m",["1u"],function(a){var b=function(a,b){return function(d){return"rtl"===c(d)?b:a}},c=function(b){return"rtl"===a.get(b,"direction")?"rtl":"ltr"};return{onDirection:b,getDirection:c}}),g("g",["n","1m"],function(a,b){var c={isRtl:a.constant(!1)},d={isRtl:a.constant(!0)},e=function(a){var e=b.getDirection(a);return"rtl"===e?d:c};return{directionAt:e}}),g("d",["1","n","2","1i","4","19","1j","1k","6","14","7","8","1l","g"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){return function(o,p){var q,r=function(a){return"table"===j.name(m.getBody(a))},s=function(a){var b=g.getGridSize(a);return r(o)===!1||b.rows()>1},t=function(a){var b=g.getGridSize(a);return r(o)===!1||b.columns()>1},u=function(a){return o.fire("newrow",{node:a.dom()}),a.dom()},v=function(a){return o.fire("newcell",{node:a.dom()}),a.dom()};o.settings.table_clone_elements!==!1&&("string"==typeof o.settings.table_clone_elements?q=o.settings.table_clone_elements.split(/[ ,]/):Array.isArray(o.settings.table_clone_elements)&&(q=o.settings.table_clone_elements));var w=c.from(q),x=function(b,d,g,h){return function(j,m){var p=l.descendants(j,"td[data-mce-style],th[data-mce-style]");a.each(p,function(a){k.remove(a,"data-mce-style")});var q=h(),r=i.fromDom(o.getDoc()),s=e(n.directionAt),t=f.cellOperations(g,r,w);return d(j)?b(q,j,m,t,s).bind(function(b){return a.each(b.newRows(),function(a){u(a)}),a.each(b.newCells(),function(a){v(a)}),b.cursor().map(function(a){var b=o.dom.createRng();return b.setStart(a.dom(),0),b.setEnd(a.dom(),0),b})}):c.none()}},y=x(h.eraseRows,s,b.noop,p),z=x(h.eraseColumns,t,b.noop,p),A=x(h.insertRowsBefore,b.always,b.noop,p),B=x(h.insertRowsAfter,b.always,b.noop,p),C=x(h.insertColumnsBefore,b.always,d.halve,p),D=x(h.insertColumnsAfter,b.always,d.halve,p),E=x(h.mergeCells,b.always,b.noop,p),F=x(h.unmergeCells,b.always,b.noop,p),G=x(h.pasteRowsBefore,b.always,b.noop,p),H=x(h.pasteRowsAfter,b.always,b.noop,p),I=x(h.pasteCells,b.always,b.noop,p);return{deleteRow:y,deleteColumn:z,insertRowsBefore:A,insertRowsAfter:B,insertColumnsBefore:C,insertColumnsAfter:D,mergeCells:E,unmergeCells:F,pasteRowsBefore:G,pasteRowsAfter:H,pasteCells:I}}}),g("1n",["2f","3f","3h","2g","3l"],function(a,b,c,d,e){var f=function(f,g,h){var i=a.fromTable(f),j=d.generate(i),k=b.onCells(j,g);return k.map(function(a){var d=c.toGrid(j,h,!1),f=d.slice(a[0].row(),a[a.length-1].row()+a[a.length-1].rowspan()),g=b.toDetailList(f,h);return e.copy(g)})};return{copyRows:f}}),g("3m",["17"],function(a){return a("tinymce.Env")}),g("3n",["a"],function(a){var b=function(a,b,c){var d,e=a.select("td,th",b),f=function(b,d){for(var e=0;e',c.insertBefore(h,c.firstChild)),e.unApplyAlign(a,c),i.align&&e.applyAlign(a,c,i.align),a.focus(),a.addVisual()})},l=function(b,c){var d,e,f,h,j,l=b.dom,m={};c===!0?(d=l.getParent(b.selection.getStart(),"table"),d&&(m=i(b,d))):(e={label:"Cols",name:"cols"},f={label:"Rows",name:"rows"}),b.settings.table_class_list&&(m["class"]&&(m["class"]=m["class"].replace(/\s*mce\-item\-table\s*/g,"")),h={name:"class",type:"listbox",label:"Class",values:g.buildListItems(b.settings.table_class_list,function(a){a.value&&(a.textStyle=function(){return b.formatter.getCssText({block:"table",classes:[a.value]})})})}),j={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:b.settings.table_appearance_options!==!1?[e,f,{label:"Width",name:"width",onchange:a.curry(g.updateStyleField,b)},{label:"Height",name:"height",onchange:a.curry(g.updateStyleField,b)},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"}]:[e,f,{label:"Width",name:"width",onchange:a.curry(g.updateStyleField,b)},{label:"Height",name:"height",onchange:a.curry(g.updateStyleField,b)}]},{label:"Alignment",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},h]},b.settings.table_advtab!==!1?b.windowManager.open({title:"Table properties",data:m,bodyType:"tabpanel",body:[{title:"General",type:"form",items:j},g.createStyleForm(b)],onsubmit:a.curry(k,b,d)}):b.windowManager.open({title:"Table properties",data:m,body:j,onsubmit:a.curry(k,b,d)})};return{open:l}}),g("1r",["n","a","3n","1l","3o"],function(a,b,c,d,e){function f(a,f,g){function i(a,b,c){c&&l.setAttrib(a,b,c)}function j(a,b,c){c&&l.setStyle(a,b,c)}var k,l=a.dom;e.updateStyleField(a,g),k=g.control.rootControl.toJSON(),a.undoManager.transact(function(){b.each(f,function(b){i(b,"scope",k.scope),i(b,"style",k.style),i(b,"class",k["class"]),j(b,"height",d.addSizeSuffix(k.height)),k.type!==b.parentNode.nodeName.toLowerCase()&&h(a.dom,b,k.type),1===f.length&&c.unApplyAlign(a,b),k.align&&c.applyAlign(a,b,k.align)}),a.focus()})}var g=function(a,c){var d=a.dom,f={height:d.getStyle(c,"height")||d.getAttrib(c,"height"),scope:d.getAttrib(c,"scope"),"class":d.getAttrib(c,"class")};return f.type=c.parentNode.nodeName.toLowerCase(),b.each("left center right".split(" "),function(b){a.formatter.matchNode(c,"align"+b)&&(f.align=b)}),a.settings.table_row_advtab!==!1&&b.extend(f,e.extractAdvancedStyles(d,c)),f},h=function(a,b,c){var d=a.getParent(b,"table"),e=b.parentNode,f=a.select(c,d)[0];f||(f=a.create(c),d.firstChild?"CAPTION"===d.firstChild.nodeName?a.insertAfter(f,d.firstChild):d.insertBefore(f,d.firstChild):d.appendChild(f)),f.appendChild(b),e.hasChildNodes()||a.remove(e)},i=function(c){var d,h,i,j,k,l,m=c.dom,n=[];d=c.dom.getParent(c.selection.getStart(),"table"),h=c.dom.getParent(c.selection.getStart(),"td,th"),b.each(d.rows,function(a){b.each(a.cells,function(b){if(m.getAttrib(b,"data-mce-selected")||b==h)return n.push(a),!1})}),i=n[0],i&&(k=n.length>1?{height:"",scope:"","class":"",align:"",type:i.parentNode.nodeName.toLowerCase()}:g(c,i),c.settings.table_row_class_list&&(j={name:"class",type:"listbox",label:"Class",values:e.buildListItems(c.settings.table_row_class_list,function(a){a.value&&(a.textStyle=function(){return c.formatter.getCssText({block:"tr",classes:[a.value]})})})}),l={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"Header",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},j]},c.settings.table_row_advtab!==!1?c.windowManager.open({title:"Row properties",data:k,bodyType:"tabpanel",body:[{title:"General",type:"form",items:l},e.createStyleForm(m)],onsubmit:a.curry(f,c,n)}):c.windowManager.open({title:"Row properties",data:k,body:l,onsubmit:a.curry(f,c,n)}))};return{open:i}}),g("1s",["n","a","3n","1l","3o"],function(a,b,c,d,e){var f=function(a,c){var d=a.dom,f={width:d.getStyle(c,"width")||d.getAttrib(c,"width"),height:d.getStyle(c,"height")||d.getAttrib(c,"height"),scope:d.getAttrib(c,"scope"),"class":d.getAttrib(c,"class")};return f.type=c.nodeName.toLowerCase(),b.each("left center right".split(" "),function(b){a.formatter.matchNode(c,"align"+b)&&(f.align=b)}),b.each("top middle bottom".split(" "),function(b){a.formatter.matchNode(c,"valign"+b)&&(f.valign=b)}),a.settings.table_cell_advtab!==!1&&b.extend(f,e.extractAdvancedStyles(d,c)),f},g=function(a,e,f){function g(a,b,c){c&&j.setAttrib(a,b,c)}function h(a,b,c){c&&j.setStyle(a,b,c)}var i,j=a.dom;i=f.control.rootControl.toJSON(),a.undoManager.transact(function(){b.each(e,function(b){g(b,"scope",i.scope),g(b,"style",i.style),g(b,"class",i["class"]),h(b,"width",d.addSizeSuffix(i.width)),h(b,"height",d.addSizeSuffix(i.height)),i.type&&b.nodeName.toLowerCase()!==i.type&&(b=j.rename(b,i.type)),1===e.length&&(c.unApplyAlign(a,b),c.unApplyVAlign(a,b)),i.align&&c.applyAlign(a,b,i.align),i.valign&&c.applyVAlign(a,b,i.valign)}),a.focus()})},h=function(b){var c,d,h,i=[];if(i=b.dom.select("td[data-mce-selected],th[data-mce-selected]"),c=b.dom.getParent(b.selection.getStart(),"td,th"),!i.length&&c&&i.push(c),c=c||i[0]){d=i.length>1?{width:"",height:"",scope:"","class":"",align:"",style:"",type:c.nodeName.toLowerCase()}:f(b,c),b.settings.table_cell_class_list&&(h={name:"class",type:"listbox",label:"Class",values:e.buildListItems(b.settings.table_cell_class_list,function(a){a.value&&(a.textStyle=function(){return b.formatter.getCssText({block:"td",classes:[a.value]})})})});var j={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",layout:"grid",columns:2,labelGapCalc:!1,padding:0,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width",onchange:a.curry(e.updateStyleField,b)},{label:"Height",name:"height",onchange:a.curry(e.updateStyleField,b)},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},h]};b.settings.table_cell_advtab!==!1?b.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:d,body:[{title:"General",type:"form",items:j},e.createStyleForm(b)],onsubmit:a.curry(g,b,i)}):b.windowManager.open({title:"Cell properties",data:d,body:j,onsubmit:a.curry(g,b,i)})}};return{open:h}}),g("e",["1","n","2","1n","19","1a","1o","1p","1b","6","a","1l","1d","1q","1r","1s"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=k.each,r=c.none(),s=function(){return r.fold(function(){},function(b){return a.map(b,function(a){return a.dom()})})},t=function(b){var d=a.map(b,j.fromDom);r=c.from(d)},u=function(k,s,t,u){var v=l.getIsRoot(k),w=function(){var a=j.fromDom(k.dom.getParent(k.selection.getStart(),"th,td")),c=f.table(a,v);c.filter(b.not(v)).each(function(a){var b=j.fromText("");g.after(a,b),h.remove(a);var c=k.dom.createRng();c.setStart(b.dom(),0),c.setEnd(b.dom(),0),k.selection.setRng(c)})},x=function(){return j.fromDom(k.dom.getParent(k.selection.getStart(),"th,td"))},y=function(a){return f.table(a,v)},z=function(a){var b=x(),c=y(b);c.each(function(c){var d=m.forMenu(u,c,b);a(c,d).each(function(a){k.selection.setRng(a),k.focus(),t.clear(c)})})},A=function(a){var f=x(),g=y(f);return g.bind(function(a){var g=j.fromDom(k.getDoc()),h=m.forMenu(u,a,f),i=e.cellOperations(b.noop,g,c.none());return d.copyRows(a,h,i)})},B=function(b){r.each(function(c){var d=a.map(c,function(a){return i.deep(a)}),f=x(),g=y(f);g.bind(function(a){var c=j.fromDom(k.getDoc()),g=e.paste(c),h=m.pasteRows(u,a,f,d,g);b(a,h).each(function(b){k.selection.setRng(b),k.focus(),t.clear(a)})})})};q({mceTableSplitCells:function(){z(s.unmergeCells)},mceTableMergeCells:function(){z(s.mergeCells)},mceTableInsertRowBefore:function(){z(s.insertRowsBefore)},mceTableInsertRowAfter:function(){z(s.insertRowsAfter)},mceTableInsertColBefore:function(){z(s.insertColumnsBefore)},mceTableInsertColAfter:function(){z(s.insertColumnsAfter)},mceTableDeleteCol:function(){z(s.deleteColumn)},mceTableDeleteRow:function(){z(s.deleteRow)},mceTableCutRow:function(a){r=A(),z(s.deleteRow)},mceTableCopyRow:function(a){r=A()},mceTablePasteRowBefore:function(a){B(s.pasteRowsBefore)},mceTablePasteRowAfter:function(a){B(s.pasteRowsAfter)},mceTableDelete:w},function(a,b){k.addCommand(b,a)}),q({mceInsertTable:b.curry(n.open,k),mceTableProps:b.curry(n.open,k,!0),mceTableRowProps:b.curry(o.open,k),mceTableCellProps:b.curry(p.open,k)},function(a,b){k.addCommand(b,function(b,c){a(c)})})};return{registerCommands:u,getClipboardRows:s,setClipboardRows:t}}),g("f",["3","1o","1p","1t","6","1u","1l"],function(a,b,c,d,e,f,g){var h=function(){var a=e.fromTag("div");return f.setAll(a,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),b.append(d.body(),a),a},i=function(b,c){return b.inline?a.body(g.getBody(b),h()):a.only(e.fromDom(b.getDoc()))},j=function(a,b){a.inline&&c.remove(b.parent())};return{get:i,remove:j}}),g("3p",[],function(){var a=function(a){return e(function(b,c,d,e){return b(a)})},b=function(a){return e(function(b,c,d,e){return c(a)})},c=function(a,b){return e(function(c,d,e,f){return e(a,b)})},d=function(a){return e(function(b,c,d,e){return e(a)})},e=function(a){return{fold:a}};return{none:a,first:b,middle:c,last:d}}),g("1v",["1","n","3p","1a","1w"],function(a,b,c,d,e){var f=function(c,f){return d.table(c,f).bind(function(f){var g=d.cells(f),h=a.findIndex(g,function(a){return e.eq(c,a)});return h.map(function(a){return{index:b.constant(a),all:b.constant(g)}})})},g=function(a,b){var d=f(a,b);return d.fold(function(){return c.none(a)},function(b){return b.index()+1=0?c.middle(a,b.all()[b.index()-1]):c.first(a)})};return{next:g,prev:h}}),g("3q",["3a","n"],function(a,b){var c=a.generate([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),d=function(a,b,c,d){return a.fold(b,c,d)},e=function(a){return a.fold(b.identity,b.identity,b.identity)};return{before:c.before,on:c.on,after:c.after,cata:d,getStart:e}}),g("1y",["3a","24","6","26","3q"],function(a,b,c,d,e){var f=a.generate([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),g=b.immutable("start","soffset","finish","foffset"),h=function(a){return f.exact(a.start(),a.soffset(),a.finish(),a.foffset())},i=function(a){return a.match({domRange:function(a){return c.fromDom(a.startContainer)},relative:function(a,b){return e.getStart(a)},exact:function(a,b,c,d){return a}})},j=function(a){var b=i(a);return d.defaultView(b)};return{domRange:f.domRange,relative:f.relative,exact:f.exact,exactFromRange:h,range:g,getWin:j}}),g("3r",["1w","6","26"],function(a,b,c){var d=function(a,b,d,e){var f=c.owner(a),g=f.dom().createRange();return g.setStart(a.dom(),b),g.setEnd(d.dom(),e),g},e=function(a,c,e,f){var g=d(a,c,e,f);return b.fromDom(g.commonAncestorContainer)},f=function(b,c,e,f){var g=d(b,c,e,f),h=a.eq(b,e)&&c===f;return g.collapsed&&!h};return{after:f,commonAncestorContainer:e}}),g("3s",["1","6","t"],function(a,b,c){var d=function(d,e){var f=e||c,g=f.createDocumentFragment();return a.each(d,function(a){g.appendChild(a.dom())}),b.fromDom(g)};return{fromElements:d}}),g("3t",["n","2","1w","6"],function(a,b,c,d){var e=function(a,b){var c=a.document.createRange();return f(c,b),c},f=function(a,b){a.selectNodeContents(b.dom())},g=function(a,b){return b.compareBoundaryPoints(a.END_TO_START,a)<1&&b.compareBoundaryPoints(a.START_TO_END,a)>-1},h=function(a){return a.document.createRange()},i=function(a,b){b.fold(function(b){a.setStartBefore(b.dom())},function(b,c){a.setStart(b.dom(),c)},function(b){a.setStartAfter(b.dom())})},j=function(a,b){b.fold(function(b){a.setEndBefore(b.dom())},function(b,c){a.setEnd(b.dom(),c)},function(b){a.setEndAfter(b.dom())})},k=function(a,b){o(a),a.insertNode(b.dom())},l=function(a,b,d,e){return c.eq(a,d)&&b===e},m=function(a,b,c){var d=a.document.createRange();return i(d,b),j(d,c),d},n=function(a,b,c,d,e){var f=a.document.createRange();return f.setStart(b.dom(),c),f.setEnd(d.dom(),e),f},o=function(a){a.deleteContents()},p=function(a){var b=a.cloneContents();return d.fromDom(b)},q=function(b){return{left:a.constant(b.left),top:a.constant(b.top),right:a.constant(b.right),bottom:a.constant(b.bottom),width:a.constant(b.width),height:a.constant(b.height)}},r=function(a){var c=a.getClientRects(),d=c.length>0?c[0]:a.getBoundingClientRect();return d.width>0||d.height>0?b.some(d).map(q):b.none()},s=function(a){var c=a.getBoundingClientRect();return c.width>0||c.height>0?b.some(c).map(q):b.none()},t=function(a){return a.toString()};return{create:h,replaceWith:k,selectNodeContents:e,selectNodeContentsUsing:f,isCollapsed:l,relativeToNative:m,exactToNative:n,deleteContents:o,cloneFragment:p,getFirstRect:r,getBounds:s,isWithin:g,toString:t}}),g("27",["3a","n","2","2v","6","3t"],function(a,b,c,d,e,f){var g=a.generate([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),h=function(a,b,c){return b(e.fromDom(c.startContainer),c.startOffset,e.fromDom(c.endContainer),c.endOffset)},i=function(a,e){return e.match({domRange:function(a){return{ltr:b.constant(a),rtl:c.none}},relative:function(b,e){return{ltr:d.cached(function(){return f.relativeToNative(a,b,e)}),rtl:d.cached(function(){return c.some(f.relativeToNative(a,e,b))})}},exact:function(b,e,g,h){return{ltr:d.cached(function(){return f.exactToNative(a,b,e,g,h)}),rtl:d.cached(function(){return c.some(f.exactToNative(a,g,h,b,e))})}}})},j=function(a,b){var c=b.ltr();if(c.collapsed){var d=b.rtl().filter(function(a){return a.collapsed===!1});return d.map(function(a){return g.rtl(e.fromDom(a.endContainer),a.endOffset,e.fromDom(a.startContainer),a.startOffset)}).getOrThunk(function(){return h(a,g.ltr,c)})}return h(a,g.ltr,c)},k=function(a,b){var c=i(a,b);return j(a,c)},l=function(a,b){var c=k(a,b);return c.match({ltr:function(b,c,d,e){var f=a.document.createRange();return f.setStart(b.dom(),c),f.setEnd(d.dom(),e),f},rtl:function(b,c,d,e){var f=a.document.createRange();return f.setStart(d.dom(),e),f.setEnd(b.dom(),c),f}})};return{ltr:g.ltr,rtl:g.rtl,diagnose:k,asLtrRange:l}}),g("5o",["2m"],function(a){var b=function(b,c,d,e,f){if(0===f)return 0;if(c===e)return f-1;for(var g=e,h=1;hi.bottom);else{if(dg)return h-1;g=j}}return 0},c=function(a,b,c){return b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom};return{inRect:c,searchForPoint:b}}),g("5p",["2","44","25","5o","2m"],function(a,b,c,d,e){var f=function(a,b,e,f,g){var h=function(c){var d=a.dom().createRange();return d.setStart(b.dom(),c),d.collapse(!0),d},i=function(a){var b=h(a);return b.getBoundingClientRect()},j=c.get(b).length,k=d.searchForPoint(i,e,f,g.right,j);return h(k)},g=function(c,e,g,h){var i=c.dom().createRange();i.selectNode(e.dom());var j=i.getClientRects(),k=b.findMap(j,function(b){return d.inRect(b,g,h)?a.some(b):a.none()});return k.map(function(a){return f(c,e,g,h,a)})};return{locate:g}}),g("4z",["2","44","14","26","5o","5p","2m"],function(a,b,c,d,e,f,g){var h=function(c,f,g,h){var j=c.dom().createRange(),k=d.children(f);return b.findMap(k,function(b){return j.selectNode(b.dom()),e.inRect(j.getBoundingClientRect(),g,h)?i(c,b,g,h):a.none()})},i=function(a,b,d,e){var g=c.isText(b)?f.locate:h;return g(a,b,d,e)},j=function(a,b,c,d){var e=a.dom().createRange();e.selectNode(b.dom());var f=e.getBoundingClientRect(),h=g.max(f.left,g.min(f.right,c)),j=g.max(f.top,g.min(f.bottom,d));return i(a,b,h,j)};return{locate:j}}),g("50",["2","26","1x"],function(a,b,c){var d=!0,e=!1,f=function(a,b){return b-a.left0){var d=b.getRangeAt(0),e=b.getRangeAt(b.rangeCount-1);return a.some(f.range(c.fromDom(d.startContainer),d.startOffset,c.fromDom(e.endContainer),e.endOffset))}return a.none()},t=function(d){var e=c.fromDom(d.anchorNode),g=c.fromDom(d.focusNode);return b.after(e,d.anchorOffset,g,d.focusOffset)?a.some(f.range(c.fromDom(d.anchorNode),d.anchorOffset,c.fromDom(d.focusNode),d.focusOffset)):s(d)},u=function(a,b){var c=g.selectNodeContents(a,b);l(a,c)},v=function(a,b){var d=g.selectNodeContents(a,b);return f.range(c.fromDom(d.startContainer),d.startOffset,c.fromDom(d.endContainer),d.endOffset)},w=function(b){var c=b.getSelection();return c.rangeCount>0?t(c):a.none()},x=function(a){return w(a).map(function(a){return f.exact(a.start(),a.soffset(),a.finish(),a.foffset())})},y=function(a,b){var c=h.asLtrRange(a,b);return g.getFirstRect(c)},z=function(a,b){var c=h.asLtrRange(a,b);return g.getBounds(c)},A=function(a,b,c){return i.fromPoint(a,b,c)},B=function(a,b){var c=h.asLtrRange(a,b);return g.toString(c)},C=function(a){var b=a.getSelection();b.removeAllRanges()},D=function(a,b){var c=h.asLtrRange(a,b);return g.cloneFragment(c)},E=function(a,b,c){var e=h.asLtrRange(a,b),f=d.fromElements(c,a.document);g.replaceWith(e,f)},F=function(a,b){var c=h.asLtrRange(a,b);g.deleteContents(c)};return{setExact:p,getExact:w,get:x,setRelative:q,toNative:r,setToElement:u,clear:C,clone:D,replace:E,deleteAt:F,forElement:v,getFirstRect:y,getBounds:z,getAtPoint:A,findWithin:n,getAsString:B}}),g("20",["17"],function(a){return a("tinymce.util.VK")}),g("h",["1","2","1v","1a","1w","6","14","8","1h","1x","1y","1z","20","1l","1d"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=function(a,b,d,e){return t(a,b,c.next(d),e)},q=function(a,b,d,e){return t(a,b,c.prev(d),e)},r=function(a,b){var c=k.exact(b,0,b,0);return l.toNative(c)},s=function(b,c){var d=h.descendants(c,"tr");return a.last(d).bind(function(a){return i.descendant(a,"td,th").map(function(a){return r(b,a)})})},t=function(a,c,e,f,g){return e.fold(b.none,b.none,function(b,c){return j.first(c).map(function(b){return r(a,b)})},function(b){return d.table(b,c).bind(function(c){var d=o.noMenu(b);return a.undoManager.transact(function(){f.insertRowsAfter(c,d)}),s(a,c)})})},u=["table","li","dl"],v=function(b,c,h,i){if(b.keyCode===m.TAB){var j=n.getBody(c),k=function(b){var c=g.name(b);return e.eq(b,j)||a.contains(u,c)},l=c.selection.getRng();if(l.collapsed){var o=f.fromDom(l.startContainer);d.cell(o,k).each(function(a){b.preventDefault();var d=b.shiftKey?q:p,e=d(c,k,a,h,i);e.each(function(a){c.selection.setRng(a)})})}}};return{handle:v}}),g("3x",["24"],function(a){var b=a.immutable("selection","kill"); +return{response:b}}),g("23",[],function(){var a=function(a){return function(b){return b===a}},b=a(38),c=a(40),d=function(a){return a>=37&&a<=40};return{ltr:{isBackward:a(37),isForward:a(39)},rtl:{isBackward:a(39),isForward:a(37)},isUp:b,isDown:c,isNavigation:d}}),g("51",["n","6","3q","27"],function(a,b,c,d){var e=function(c,e){var f=d.asLtrRange(c,e);return{start:a.constant(b.fromDom(f.startContainer)),soffset:a.constant(f.startOffset),finish:a.constant(b.fromDom(f.endContainer)),foffset:a.constant(f.endOffset)}},f=function(b,d,e,f){return{start:a.constant(c.on(b,d)),finish:a.constant(c.on(e,f))}};return{convertToRange:e,makeSitus:f}}),g("3y",["51","n","13","2","6","1y","3q","1z"],function(a,b,c,d,e,f,g,h){return function(i){var j=function(a,b){return d.from(i.document.elementFromPoint(a,b)).map(e.fromDom)},k=function(a){return a.dom().getBoundingClientRect()},l=function(a,d,e,g){var j=f.exact(a,d,e,g);return h.getFirstRect(i,j).map(function(a){return c.map(a,b.apply)})},m=function(){return h.get(i).map(function(b){return a.convertToRange(i,b)})},n=function(b){var c=f.relative(b.start(),b.finish());return a.convertToRange(i,c)},o=function(a,c){return h.getAtPoint(i,a,c).map(function(a){return{start:b.constant(g.on(a.start(),a.soffset())),finish:b.constant(g.on(a.finish(),a.foffset()))}})},p=function(){h.clear(i)},q=function(a){h.setToElement(i,a)},r=function(a){h.setExact(i,a.start(),a.soffset(),a.finish(),a.foffset())},s=function(a,b){h.setRelative(i,a,b)},t=function(){return i.innerHeight},u=function(){return i.scrollY},v=function(a,b){i.scrollBy(a,b)};return{elementFromPoint:j,getRect:k,getRangedRect:l,getSelection:m,fromSitus:n,situsFromPoint:o,clearSelection:p,setSelection:r,setRelativeSelection:s,selectContents:q,getInnerHeight:t,getScrollY:u,scrollBy:v}}});g("3z",["3x","43","51","n","2","1w","1h","37","1y","3q"],function(a,b,c,d,e,f,g,h,i,j){var k=function(a,b,c,d,h,i,j){return f.eq(c,h)&&d===i?e.none():g.closest(c,"td,th",b).bind(function(c){return g.closest(h,"td,th",b).bind(function(d){return l(a,b,c,d,j)})})},l=function(d,g,i,j,k){if(!f.eq(i,j)){var l=b.identify(i,j,g).getOr([]);if(l.length>0)return k(d,l,i,j),e.some(a.response(e.some(c.makeSitus(i,0,i,h.getEnd(i))),!0))}return e.none()},m=function(a,c,d,e,f){var g=function(a){return f.clear(d),f.selectRange(d,a.boxes(),a.start(),a.finish()),a.boxes()};return b.shiftSelection(e,a,c,f.firstSelectedSelector(),f.lastSelectedSelector()).map(g)};return{sync:k,detect:l,update:m}});g("5q",["24"],function(a){var b=a.immutableBag(["left","top","right","bottom"],[]),c=function(a,c){return b({left:a.left(),top:a.top()+c,right:a.right(),bottom:a.bottom()+c})},d=function(a,c){return b({left:a.left(),top:a.top()-c,right:a.right(),bottom:a.bottom()-c})},e=function(a,c){var d=a.bottom()-a.top();return b({left:a.left(),top:c-d,right:a.right(),bottom:c})},f=function(a,c){var d=a.bottom()-a.top();return b({left:a.left(),top:c,right:a.right(),bottom:c+d})},g=function(a,c,d){return b({left:a.left()+c,top:a.top()+d,right:a.right()+c,bottom:a.bottom()+d})},h=function(a){return a.top()},i=function(a){return a.bottom()},j=function(a){return"("+a.left()+", "+a.top()+") -> ("+a.right()+", "+a.bottom()+")"};return{nu:b,moveUp:d,moveDown:c,moveBottomTo:e,moveTopTo:f,getTop:h,getBottom:i,translate:g,toString:j}}),g("5r",["5q","2","14","37"],function(a,b,c,d){var e=function(a,c,e){return e>=0&&e0?a.getRangedRect(c,e-1,c,e):b.none()},f=function(b){return a.nu({left:b.left,top:b.top,right:b.right,bottom:b.bottom})},g=function(a,c){return b.some(a.getRect(c))},h=function(a,d,h){return c.isElement(d)?g(a,d,h).map(f):c.isText(d)?e(a,d,h).map(f):b.none()},i=function(a,e){return c.isElement(e)?g(a,e).map(f):c.isText(e)?a.getRangedRect(e,0,e,d.getEnd(e)).map(f):b.none()};return{getBoxAt:h,getEntireBox:i}}),g("67",["1","2","24"],function(a,b,c){var d=c.immutable("item","mode"),e=function(a,b,c,e){var g=void 0!==e?e:f;return a.property().parent(b).map(function(a){return d(a,g)})},f=function(a,b,c,e){var f=void 0!==e?e:g;return c.sibling(a,b).map(function(a){return d(a,f)})},g=function(a,b,c,e){var f=void 0!==e?e:g,h=a.property().children(b),i=c.first(h);return i.map(function(a){return d(a,f)})},h=[{current:e,next:f,fallback:b.none()},{current:f,next:g,fallback:b.some(e)},{current:g,next:g,fallback:b.some(f)}],i=function(b,c,d,e,f){var g=void 0!==f?f:h,j=a.find(g,function(a){return a.current===d});return j.bind(function(a){return a.current(b,c,e,a.next).orThunk(function(){return a.fallback.bind(function(a){return i(b,c,a,e)})})})};return{backtrack:e,sidestep:f,advance:g,go:i}}),g("68",["2"],function(a){var b=function(){var b=function(a,b){return a.query().prevSibling(b)},c=function(b){return b.length>0?a.some(b[b.length-1]):a.none()};return{sibling:b,first:c}},c=function(){var b=function(a,b){return a.query().nextSibling(b)},c=function(b){return b.length>0?a.some(b[0]):a.none()};return{sibling:b,first:c}};return{left:b,right:c}}),g("66",["2","67","68"],function(a,b,c){var d=function(c,e,f,g,h,i){var j=b.go(c,e,g,h);return j.bind(function(b){return i(b.item())?a.none():f(b.item())?a.some(b.item()):d(c,b.item(),f,b.mode(),h,i)})},e=function(a,e,f,g){return d(a,e,f,b.sidestep,c.left(),g)},f=function(a,e,f,g){return d(a,e,f,b.sidestep,c.right(),g)};return{left:e,right:f}}),g("5s",["n","66","67","68"],function(a,b,c,d){var e=function(a,b){return 0===a.property().children(b).length},f=function(b,c,d){return h(b,c,a.curry(e,b),d)},g=function(b,c,d){return i(b,c,a.curry(e,b),d)},h=function(a,c,d,e){return b.left(a,c,d,e)},i=function(a,c,d,e){return b.right(a,c,d,e)},j=function(){return{left:d.left,right:d.right}},k=function(a,b,d,e,f){return c.go(a,b,d,e,f)};return{before:f,after:g,seekLeft:h,seekRight:i,walkers:j,walk:k,backtrack:c.backtrack,sidestep:c.sidestep,advance:c.advance}}),g("56",["5j","5s"],function(a,b){var c=a(),d=function(a,d,e){return b.gather(c,a,d,e)},e=function(a,d){return b.before(c,a,d)},f=function(a,d){return b.after(c,a,d)},g=function(a,d,e){return b.seekLeft(c,a,d,e)},h=function(a,d,e){return b.seekRight(c,a,d,e)},i=function(){return b.walkers()},j=function(a,d,e,f){return b.walk(c,a,d,e,f)};return{gather:d,before:e,after:f,seekLeft:g,seekRight:h,walkers:i,walk:j}}),g("54",["5q","5r","3a","n","2","56","4v","14","31","2m"],function(a,b,c,d,e,f,g,h,i,j){var k=5,l=100,m=c.generate([{none:[]},{retry:["caret"]}]),n=function(a,b){return a.left()b.right()},o=function(a,c,e){return i.closest(c,g.isBlock).fold(d.constant(!1),function(c){return b.getEntireBox(a,c).exists(function(a){return n(e,a)})})},p=function(b,c,d,e,f){var g=a.moveDown(f,k);return j.abs(d.bottom()-e.bottom())<1?m.retry(g):d.top()>f.bottom()?m.retry(g):d.top()===f.bottom()?m.retry(a.moveDown(f,1)):o(b,c,f)?m.retry(a.translate(g,k,0)):m.none()},q=function(b,c,d,e,f){var g=a.moveUp(f,k);return j.abs(d.top()-e.top())<1?m.retry(g):d.bottom()c.getInnerHeight()?e.some(a.point(b)-c.getInnerHeight()):a.point(b)<0?e.some(-a.point(b)):e.none()},z=function(a,b,c){var d=a.move(c,k),e=v(b,a,c,d,l).getOr(d);return y(a,e,b).fold(function(){return b.situsFromPoint(e.left(),a.point(e))},function(c){return b.scrollBy(0,c),b.situsFromPoint(e.left(),a.point(e)-c)})};return{tryUp:d.curry(z,r),tryDown:d.curry(z,s),ieTryUp:x,ieTryDown:w,getJumpSize:d.constant(k)}}),g("55",["3a","4q","1w","1h","37"],function(a,b,c,d,e){var f=a.generate([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),g=function(a,b,c){var d=a.getRect(b),e=a.getRect(c);return e.right>d.left&&e.left1||1===e.length&&!c.eq(i,b))&&(h.selectRange(f,e,i,b),d.selectContents(b))})})},m=function(){i.each(j)};return{mousedown:k,mouseover:l,mouseup:m}}}),g("42",["54","55","56","26","3q"],function(a,b,c,d,e){return{down:{traverse:d.nextSibling,gather:c.after,relative:e.before,otherRetry:a.tryDown,ieRetry:a.ieTryDown,failure:b.adt.failedDown},up:{traverse:d.prevSibling,gather:c.before,relative:e.before,otherRetry:a.tryUp,ieRetry:a.ieTryUp,failure:b.adt.failedUp}}}),g("21",["3x","23","3y","3z","40","41","42","43","n","2","44","24","3q"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=l.immutable("rows","cols"),o=function(a,b,d,e){var g=c(a),h=f(g,b,d,e);return{mousedown:h.mousedown,mouseover:h.mouseover,mouseup:h.mouseup}},p=function(f,l,o,p){var q=c(f),r=function(){return p.clear(l),j.none()},s=function(c,f,s,t,u,v){var w=c.raw().which,x=c.raw().shiftKey===!0,y=h.retrieve(l,p.selectedSelector()).fold(function(){return b.isDown(w)&&x?i.curry(e.select,q,l,o,g.down,t,f,p.selectRange):b.isUp(w)&&x?i.curry(e.select,q,l,o,g.up,t,f,p.selectRange):b.isDown(w)?i.curry(e.navigate,q,o,g.down,t,f):b.isUp(w)?i.curry(e.navigate,q,o,g.up,t,f):j.none},function(c){var e=function(e){return function(){var f=k.findMap(e,function(a){return d.update(a.rows(),a.cols(),l,c,p)});return f.fold(function(){return h.getEdges(l,p.firstSelectedSelector(),p.lastSelectedSelector()).map(function(c){var d=b.isDown(w)||v.isForward(w)?m.after:m.before;return q.setRelativeSelection(m.on(c.first(),0),d(c.table())),p.clear(l),a.response(j.none(),!0)})},function(b){return j.some(a.response(j.none(),!0))})}};return b.isDown(w)&&x?e([n(1,0)]):b.isUp(w)&&x?e([n(-1,0)]):v.isBackward(w)&&x?e([n(0,-1),n(-1,0)]):v.isForward(w)&&x?e([n(0,1),n(1,0)]):b.isNavigation(w)&&x===!1?r:j.none});return y()},t=function(a,c,e,f,g){return h.retrieve(l,p.selectedSelector()).fold(function(){var h=a.raw().which,i=a.raw().shiftKey===!0;return i===!1?j.none():b.isNavigation(h)?d.sync(l,o,c,e,f,g,p.selectRange):j.none()},j.none)};return{keydown:s,keyup:t}};return{mouse:o,keyboard:p}}),g("57",["1","2w","4o","p"],function(a,b,c,d){var e=function(c,d){a.each(d,function(a){b.add(c,a)})},f=function(c,d){a.each(d,function(a){b.remove(c,a)})},g=function(c,d){a.each(d,function(a){b.toggle(c,a)})},h=function(c,d){return a.forall(d,function(a){return b.has(c,a)})},i=function(c,d){return a.exists(d,function(a){return b.has(c,a)})},j=function(a){for(var b=a.dom().classList,c=new d(b.length),e=0;e"):s.dom.add(s.getBody(),"br"))});var d=s.selection.getRng(),e=i.fromDom(s.selection.getStart()),f=i.fromDom(d.startContainer),g=i.fromDom(d.endContainer),h=q.directionAt(e).isRtl()?c.rtl:c.ltr;A.keydown(b,f,d.startOffset,g,d.endOffset,h).each(function(a){B(b,a)}),t().each(function(a){a.showBars()})},G=function(a){var b=i.fromDom(a.target),c=function(){a.stopPropagation()},e=function(){a.preventDefault()},f=d.compose(e,c);return{target:d.constant(b),x:d.constant(a.x),y:d.constant(a.y),stop:c,prevent:e,kill:f,raw:d.constant(a)}},H=function(a){return 0===a.button},I=function(a){return void 0===a.buttons||0!==(1&a.buttons)},J=function(a){H(a)&&z.mousedown(G(a))},K=function(a){I(a)&&z.mouseover(G(a))},L=function(a){H&&z.mouseup(G(a))};s.on("mousedown",J),s.on("mouseover",K),s.on("mouseup",L),s.on("keyup",C),s.on("keydown",F),s.on("nodechange",y),v=e.some(u({mousedown:J,mouseover:K,mouseup:L,keyup:C,keydown:F}))});var x=function(){v.each(function(a){})};return{clear:w.clear,destroy:x}}}),g("k",["28","1l","j","1e"],function(a,b,c,d){return function(e){var f=function(){var f=b.getBody(e);return a.retrieve(f,c.selectedSelector()).fold(function(){return void 0===e.selection.getStart()?d.none():d.single(e.selection)},function(a){return d.multiple(a)})};return{get:f}}}),g("l",["n","a","1q"],function(a,b,c){var d=b.each,e=function(b){function e(a){return function(){b.execCommand(a)}}var f=[];d("inserttable tableprops deletetable | cell row column".split(" "),function(a){"|"==a?f.push({text:"-"}):f.push(b.menuItems[a])}),b.addButton("table",{type:"menubutton",title:"Table",menu:f}),b.addButton("tableprops",{title:"Table properties",onclick:a.curry(c.open,b,!0),icon:"table"}),b.addButton("tabledelete",{title:"Delete table",onclick:e("mceTableDelete")}),b.addButton("tablecellprops",{title:"Cell properties",onclick:e("mceTableCellProps")}),b.addButton("tablemergecells",{title:"Merge cells",onclick:e("mceTableMergeCells")}),b.addButton("tablesplitcells",{title:"Split cell",onclick:e("mceTableSplitCells")}),b.addButton("tableinsertrowbefore",{title:"Insert row before",onclick:e("mceTableInsertRowBefore")}),b.addButton("tableinsertrowafter",{title:"Insert row after",onclick:e("mceTableInsertRowAfter")}),b.addButton("tabledeleterow",{title:"Delete row",onclick:e("mceTableDeleteRow")}),b.addButton("tablerowprops",{title:"Row properties",onclick:e("mceTableRowProps")}),b.addButton("tablecutrow",{title:"Cut row",onclick:e("mceTableCutRow")}),b.addButton("tablecopyrow",{title:"Copy row",onclick:e("mceTableCopyRow")}),b.addButton("tablepasterowbefore",{title:"Paste row before",onclick:e("mceTablePasteRowBefore")}),b.addButton("tablepasterowafter",{title:"Paste row after",onclick:e("mceTablePasteRowAfter")}),b.addButton("tableinsertcolbefore",{title:"Insert column before",onclick:e("mceTableInsertColBefore")}),b.addButton("tableinsertcolafter",{title:"Insert column after",onclick:e("mceTableInsertColAfter")}),b.addButton("tabledeletecol",{title:"Delete column",onclick:e("mceTableDeleteCol")})},f=function(a){var b=function(b){var c=a.dom.is(b,"table")&&a.getBody().contains(b);return c},c=a.settings.table_toolbar;""!==c&&c!==!1&&(c||(c="tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"),a.addContextToolbar(b,c))};return{addButtons:e,addToolbars:f}}),g("m",["n","1","2","1a","6","c","1d","1q"],function(a,b,c,d,e,f,g,h){var i=function(i,j){function k(a){return function(){i.execCommand(a)}}var l=c.none(),m=[],n=[],o=[],p=[],q=function(a){a.disabled(!0)},r=function(a){a.disabled(!1)},s=function(){var a=this;m.push(a),l.fold(function(){q(a)},function(b){r(a)})},t=function(){var a=this;n.push(a),l.fold(function(){q(a)},function(b){r(a)})},u=function(){var a=this;o.push(a),l.fold(function(){q(a)},function(b){a.disabled(b.mergable().isNone())})},v=function(){var a=this;p.push(a),l.fold(function(){q(a)},function(b){a.disabled(b.unmergable().isNone())})},w=function(){l.fold(function(){b.each(m,q),b.each(n,q),b.each(o,q),b.each(p,q)},function(a){b.each(m,r),b.each(n,r),b.each(o,function(b){b.disabled(a.mergable().isNone())}),b.each(p,function(b){b.disabled(a.unmergable().isNone())})})};i.on("init",function(){i.on("nodechange",function(a){var b=c.from(i.dom.getParent(i.selection.getStart(),"th,td"));l=b.bind(function(a){var b=e.fromDom(a),c=d.table(b);return c.map(function(a){return g.forMenu(j,a,b)})}),w()})});var x=function(){var a="";a='
      + + + + + +
      +

      +
      + +
      + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/order/order-details.php b/backend/wp-content/plugins/woocommerce/templates/order/order-details.php new file mode 100644 index 0000000..b3c3d5a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/order-details.php @@ -0,0 +1,97 @@ +get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) ); +$show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) ); +$show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id(); +$downloads = $order->get_downloadable_items(); +$show_downloads = $order->has_downloadable_item() && $order->is_download_permitted(); + +if ( $show_downloads ) { + wc_get_template( 'order/order-downloads.php', array( 'downloads' => $downloads, 'show_title' => true ) ); +} +?> +
      + + +

      + +
      + + + + + + + + + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-styles.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-styles.php new file mode 100644 index 0000000..152ec46 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-styles.php @@ -0,0 +1,210 @@ + +#wrapper { + background-color: ; + margin: 0; + padding: 70px 0 70px 0; + -webkit-text-size-adjust: none !important; + width: 100%; +} + +#template_container { + box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; + background-color: ; + border: 1px solid ; + border-radius: 3px !important; +} + +#template_header { + background-color: ; + border-radius: 3px 3px 0 0 !important; + color: ; + border-bottom: 0; + font-weight: bold; + line-height: 100%; + vertical-align: middle; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; +} + +#template_header h1, +#template_header h1 a { + color: ; +} + +#template_footer td { + padding: 0; + -webkit-border-radius: 6px; +} + +#template_footer #credit { + border:0; + color: ; + font-family: Arial; + font-size:12px; + line-height:125%; + text-align:center; + padding: 0 48px 48px 48px; +} + +#body_content { + background-color: ; +} + +#body_content table td { + padding: 48px 48px 0; +} + +#body_content table td td { + padding: 12px; +} + +#body_content table td th { + padding: 12px; +} + +#body_content td ul.wc-item-meta { + font-size: small; + margin: 1em 0 0; + padding: 0; + list-style: none; +} + +#body_content td ul.wc-item-meta li { + margin: 0.5em 0 0; + padding: 0; +} + +#body_content td ul.wc-item-meta li p { + margin: 0; +} + +#body_content p { + margin: 0 0 16px; +} + +#body_content_inner { + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 14px; + line-height: 150%; + text-align: ; +} + +.td { + color: ; + border: 1px solid ; + vertical-align: middle; +} + +.address { + padding:12px 12px 0; + color: ; + border: 1px solid ; +} + +.text { + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; +} + +.link { + color: ; +} + +#header_wrapper { + padding: 36px 48px; + display: block; +} + +h1 { + color: ; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 30px; + font-weight: 300; + line-height: 150%; + margin: 0; + text-align: ; + text-shadow: 0 1px 0 ; +} + +h2 { + color: ; + display: block; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 18px; + font-weight: bold; + line-height: 130%; + margin: 0 0 18px; + text-align: ; +} + +h3 { + color: ; + display: block; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 16px; + font-weight: bold; + line-height: 130%; + margin: 16px 0 8px; + text-align: ; +} + +a { + color: ; + font-weight: normal; + text-decoration: underline; +} + +img { + border: none; + display: inline-block; + font-size: 14px; + font-weight: bold; + height: auto; + outline: none; + text-decoration: none; + text-transform: capitalize; + vertical-align: middle; + margin-: 10px; +} +get_order_number(), $order->get_formatted_billing_full_name() ) . "\n\n"; + +echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_details() Shows the order details table. + * @hooked WC_Structured_Data::generate_order_data() Generates structured data. + * @hooked WC_Structured_Data::output_structured_data() Outputs structured data. + * @since 2.5.0 + */ +do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_meta() Shows order meta data. + */ +do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); + +/** + * @hooked WC_Emails::customer_details() Shows customer details + * @hooked WC_Emails::email_address() Shows email address + */ +do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-failed-order.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-failed-order.php new file mode 100644 index 0000000..0a0ad01 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-failed-order.php @@ -0,0 +1,52 @@ +get_order_number(), $order->get_formatted_billing_full_name() ) . "\n\n"; + +echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_details() Shows the order details table. + * @hooked WC_Structured_Data::generate_order_data() Generates structured data. + * @hooked WC_Structured_Data::output_structured_data() Outputs structured data. + * @since 2.5.0 + */ +do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_meta() Shows order meta data. + */ +do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); + +/** + * @hooked WC_Emails::customer_details() Shows customer details + * @hooked WC_Emails::email_address() Shows email address + */ +do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-new-order.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-new-order.php new file mode 100644 index 0000000..cc920b8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/admin-new-order.php @@ -0,0 +1,52 @@ +get_formatted_billing_full_name() ) . "\n\n"; + +echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_details() Shows the order details table. + * @hooked WC_Structured_Data::generate_order_data() Generates structured data. + * @hooked WC_Structured_Data::output_structured_data() Outputs structured data. + * @since 2.5.0 + */ +do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * @hooked WC_Emails::order_meta() Shows order meta data. + */ +do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); + +/** + * @hooked WC_Emails::customer_details() Shows customer details + * @hooked WC_Emails::email_address() Shows email address + */ +do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-completed-order.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-completed-order.php new file mode 100644 index 0000000..e6b5abe --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-completed-order.php @@ -0,0 +1,52 @@ +has_status( 'pending' ) ) { + + echo sprintf( + /* translators: %1s item is the name of the site, %2s is a html link */ + esc_html__( 'An order has been created for you on %1$s. %2$s', 'woocommerce' ), + esc_html( get_bloginfo( 'name', 'display' ) ), + esc_url( $order->get_checkout_payment_url() ) + ) . "\n\n"; +} + +echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * Hook for the woocommerce_email_order_details. + * + * @hooked WC_Emails::order_details() Shows the order details table. + * @hooked WC_Structured_Data::generate_order_data() Generates structured data. + * @hooked WC_Structured_Data::output_structured_data() Outputs structured data. + * @since 2.5.0 + */ +do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +/** + * Hook for the woocommerce_email_order_meta. + * + * @hooked WC_Emails::order_meta() Shows order meta data. + */ +do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); + +/** + * Hook for woocommerce_email_customer_details + * + * @hooked WC_Emails::customer_details() Shows customer details + * @hooked WC_Emails::email_address() Shows email address + */ +do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo wp_kses_post( apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-new-account.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-new-account.php new file mode 100644 index 0000000..82180ab --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-new-account.php @@ -0,0 +1,35 @@ +' . $user_login . '' ) . "\n\n"; + +if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) { + echo sprintf( __( 'Your password is %s.', 'woocommerce' ), '' . $user_pass . '' ) . "\n\n"; +} + +echo sprintf( __( 'You can access your account area to view your orders and change your password here: %s.', 'woocommerce' ), wc_get_page_permalink( 'myaccount' ) ) . "\n\n"; + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-note.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-note.php new file mode 100644 index 0000000..e4b2aff --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/customer-note.php @@ -0,0 +1,60 @@ + $reset_key, 'id' => $user_id ), wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) ) ) ) . "\r\n"; + +echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; + +echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-addresses.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-addresses.php new file mode 100644 index 0000000..d460c99 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-addresses.php @@ -0,0 +1,40 @@ +#i', "\n", $order->get_formatted_billing_address() ) . "\n"; // WPCS: XSS ok. + +if ( $order->get_billing_phone() ) { + echo $order->get_billing_phone() . "\n"; // WPCS: XSS ok. +} + +if ( $order->get_billing_email() ) { + echo $order->get_billing_email() . "\n"; // WPCS: XSS ok. +} + +if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() ) { + $shipping = $order->get_formatted_shipping_address(); + + if ( $shipping ) { + echo "\n" . esc_html( wc_strtoupper( __( 'Shipping address', 'woocommerce' ) ) ) . "\n\n"; + echo preg_replace( '##i', "\n", $shipping ) . "\n"; // WPCS: XSS ok. + } +} diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-customer-details.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-customer-details.php new file mode 100644 index 0000000..2671ac1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-customer-details.php @@ -0,0 +1,28 @@ + $column_name ) { + echo wp_kses_post( $column_name ) . ': '; + + if ( has_action( 'woocommerce_email_downloads_column_' . $column_id ) ) { + do_action( 'woocommerce_email_downloads_column_' . $column_id, $download, $plain_text ); + } else { + switch ( $column_id ) { + case 'download-product': + echo esc_html( $download['product_name'] ); + break; + case 'download-file': + echo esc_html( $download['download_name'] ) . ' - ' . esc_url( $download['download_url'] ); + break; + case 'download-expires': + if ( ! empty( $download['access_expires'] ) ) { + echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $download['access_expires'] ) ) ); + } else { + esc_html_e( 'Never', 'woocommerce' ); + } + break; + } + } + echo "\n"; + } + echo "\n"; +} +echo '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='; +echo "\n\n"; diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-details.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-details.php new file mode 100644 index 0000000..a07880c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-details.php @@ -0,0 +1,54 @@ +get_order_number() ) ) ) . "\n"; +echo wc_format_datetime( $order->get_date_created() ) . "\n"; // WPCS: XSS ok. +echo "\n" . wc_get_email_order_items( $order, array( // WPCS: XSS ok. + 'show_sku' => $sent_to_admin, + 'show_image' => false, + 'image_size' => array( 32, 32 ), + 'plain_text' => true, + 'sent_to_admin' => $sent_to_admin, +) ); + +echo "==========\n\n"; + +$totals = $order->get_order_item_totals(); + +if ( $totals ) { + foreach ( $totals as $total ) { + echo wp_kses_post( $total['label'] . "\t " . $total['value'] ) . "\n"; + } +} + +if ( $order->get_customer_note() ) { + echo esc_html__( 'Note:', 'woocommerce' ) . "\t " . wp_kses_post( wptexturize( $order->get_customer_note() ) ) . "\n"; +} + +if ( $sent_to_admin ) { + /* translators: %s: Order link. */ + echo "\n" . sprintf( esc_html__( 'View order: %s', 'woocommerce' ), esc_url( $order->get_edit_order_url() ) ) . "\n"; +} + +do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email ); diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-items.php b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-items.php new file mode 100644 index 0000000..1cdd926 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/plain/email-order-items.php @@ -0,0 +1,51 @@ + $item ) : + if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { + $product = $item->get_product(); + echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false ); + if ( $show_sku && $product->get_sku() ) { + echo ' (#' . $product->get_sku() . ')'; + } + echo ' X ' . apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); + echo ' = ' . $order->get_formatted_line_subtotal( $item ) . "\n"; + + // allow other plugins to add additional product information here + do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text ); + echo strip_tags( wc_display_item_meta( $item, array( + 'before' => "\n- ", + 'separator' => "\n- ", + 'after' => "", + 'echo' => false, + 'autop' => false, + ) ) ); + + // allow other plugins to add additional product information here + do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text ); + } + // Note + if ( $show_purchase_note && is_object( $product ) && ( $purchase_note = $product->get_purchase_note() ) ) { + echo "\n" . do_shortcode( wp_kses_post( $purchase_note ) ); + } + echo "\n\n"; +endforeach; diff --git a/backend/wp-content/plugins/woocommerce/templates/global/breadcrumb.php b/backend/wp-content/plugins/woocommerce/templates/global/breadcrumb.php new file mode 100644 index 0000000..ab98be1 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/global/breadcrumb.php @@ -0,0 +1,47 @@ + $crumb ) { + + echo $before; + + if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) { + echo '' . esc_html( $crumb[0] ) . ''; + } else { + echo esc_html( $crumb[0] ); + } + + echo $after; + + if ( sizeof( $breadcrumb ) !== $key + 1 ) { + echo $delimiter; + } + } + + echo $wrap_after; + +} diff --git a/backend/wp-content/plugins/woocommerce/templates/global/form-login.php b/backend/wp-content/plugins/woocommerce/templates/global/form-login.php new file mode 100644 index 0000000..3dc9918 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/global/form-login.php @@ -0,0 +1,62 @@ + +> + + + + + +

      + + +

      +

      + + +

      +
      + + + +

      + + + + +

      +

      + +

      + +
      + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/global/quantity-input.php b/backend/wp-content/plugins/woocommerce/templates/global/quantity-input.php new file mode 100644 index 0000000..f5333e8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/global/quantity-input.php @@ -0,0 +1,48 @@ + + + +
      + + +
      + '; + break; + case 'twentyeleven' : + echo ''; + get_sidebar( 'shop' ); + echo ''; + break; + case 'twentytwelve' : + echo ''; + break; + case 'twentythirteen' : + echo ''; + break; + case 'twentyfourteen' : + echo ''; + get_sidebar( 'content' ); + break; + case 'twentyfifteen' : + echo ''; + break; + case 'twentysixteen' : + echo ''; + break; + default : + echo ''; + break; +} diff --git a/backend/wp-content/plugins/woocommerce/templates/global/wrapper-start.php b/backend/wp-content/plugins/woocommerce/templates/global/wrapper-start.php new file mode 100644 index 0000000..3b0d787 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/global/wrapper-start.php @@ -0,0 +1,50 @@ +
      '; + break; + case 'twentyeleven' : + echo '
      '; + break; + case 'twentytwelve' : + echo '
      '; + break; + case 'twentythirteen' : + echo '
      '; + break; + case 'twentyfourteen' : + echo '
      '; + break; + case 'twentyfifteen' : + echo '
      '; + break; + case 'twentysixteen' : + echo '
      '; + break; + default : + echo '
      '; + break; +} diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/add-to-cart.php b/backend/wp-content/plugins/woocommerce/templates/loop/add-to-cart.php new file mode 100644 index 0000000..67182c6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/add-to-cart.php @@ -0,0 +1,33 @@ +%s', + esc_url( $product->add_to_cart_url() ), + esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ), + esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ), + isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '', + esc_html( $product->add_to_cart_text() ) + ), +$product, $args ); diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/loop-end.php b/backend/wp-content/plugins/woocommerce/templates/loop/loop-end.php new file mode 100644 index 0000000..7d4e229 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/loop-end.php @@ -0,0 +1,23 @@ + + diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/loop-start.php b/backend/wp-content/plugins/woocommerce/templates/loop/loop-start.php new file mode 100644 index 0000000..34bbd5b --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/loop-start.php @@ -0,0 +1,23 @@ + +
        diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/no-products-found.php b/backend/wp-content/plugins/woocommerce/templates/loop/no-products-found.php new file mode 100644 index 0000000..5f64034 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/no-products-found.php @@ -0,0 +1,24 @@ + +

        diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/orderby.php b/backend/wp-content/plugins/woocommerce/templates/loop/orderby.php new file mode 100644 index 0000000..5ffb058 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/orderby.php @@ -0,0 +1,32 @@ + +
        + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/pagination.php b/backend/wp-content/plugins/woocommerce/templates/loop/pagination.php new file mode 100644 index 0000000..a3b3225 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/pagination.php @@ -0,0 +1,46 @@ + + diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/price.php b/backend/wp-content/plugins/woocommerce/templates/loop/price.php new file mode 100644 index 0000000..9b498eb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/price.php @@ -0,0 +1,28 @@ + + +get_price_html() ) : ?> + + diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/rating.php b/backend/wp-content/plugins/woocommerce/templates/loop/rating.php new file mode 100644 index 0000000..2e34f06 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/rating.php @@ -0,0 +1,29 @@ +get_average_rating() ); diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/result-count.php b/backend/wp-content/plugins/woocommerce/templates/loop/result-count.php new file mode 100644 index 0000000..620ef71 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/result-count.php @@ -0,0 +1,37 @@ + +

        + +

        diff --git a/backend/wp-content/plugins/woocommerce/templates/loop/sale-flash.php b/backend/wp-content/plugins/woocommerce/templates/loop/sale-flash.php new file mode 100644 index 0000000..ff812e6 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/loop/sale-flash.php @@ -0,0 +1,32 @@ + +is_on_sale() ) : ?> + + ' . esc_html__( 'Sale!', 'woocommerce' ) . '', $post, $product ); ?> + + + +

        Log out)', 'woocommerce' ), + '' . esc_html( $current_user->display_name ) . '', + esc_url( wc_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) + ); +?>

        + +

        recent orders, manage your shipping and billing addresses, and edit your password and account details.', 'woocommerce' ), + esc_url( wc_get_endpoint_url( 'orders' ) ), + esc_url( wc_get_endpoint_url( 'edit-address' ) ), + esc_url( wc_get_endpoint_url( 'edit-account' ) ) + ); +?>

        + +customer->get_downloadable_products(); +$has_downloads = (bool) $downloads; + +do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?> + + + + + + + + + + +
        + + + + +
        + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-add-payment-method.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-add-payment-method.php new file mode 100644 index 0000000..20a4de2 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-add-payment-method.php @@ -0,0 +1,59 @@ +payment_gateways->get_available_payment_gateways(); + +if ( $available_gateways ) : ?> +
        +
        +
          + set_current(); + } + + foreach ( $available_gateways as $gateway ) { + ?> +
        • + chosen, true ); ?> /> + + has_fields() || $gateway->get_description() ) { + echo ''; + } + ?> +
        • + +
        + +
        + + + +
        +
        + + +

        + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-account.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-account.php new file mode 100644 index 0000000..d3bcdd7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-account.php @@ -0,0 +1,76 @@ + + + + + + +

        + + +

        +

        + + +

        +
        + +

        + + +

        +
        + +

        + + +

        + +
        + + +

        + + +

        +

        + + +

        +

        + + +

        +
        +
        + + + +

        + + + +

        + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-address.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-address.php new file mode 100644 index 0000000..6122d2a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-edit-address.php @@ -0,0 +1,59 @@ + + + + + + +
        + +

        + +
        + + +
        + $field ) { + if ( isset( $field['country_field'], $address[ $field['country_field'] ] ) ) { + $field['country'] = wc_get_post_data_by_key( $field['country_field'], $address[ $field['country_field'] ]['value'] ); + } + woocommerce_form_field( $key, $field, wc_get_post_data_by_key( $key, $field['value'] ) ); + } + ?> +
        + + + +

        + + + +

        +
        + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-login.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-login.php new file mode 100644 index 0000000..c995f64 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-login.php @@ -0,0 +1,119 @@ + + + + + + + + +
        + +
        + + + +

        + + + + + +

        + + +

        +

        + + +

        + + + +

        + + + +

        +

        + +

        + + + + + + + +
        + +
        + +

        + +
        + + + + + +

        + + +

        + + + +

        + + +

        + + + +

        + + +

        + + + + + +

        + + +

        + + + + + +
        + +
        + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-lost-password.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-lost-password.php new file mode 100644 index 0000000..d953490 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-lost-password.php @@ -0,0 +1,42 @@ + + +
        + +

        + +

        + + +

        + +
        + + + +

        + + +

        + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/form-reset-password.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-reset-password.php new file mode 100644 index 0000000..6039ac4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/form-reset-password.php @@ -0,0 +1,49 @@ + + +
        + +

        + +

        + + +

        +

        + + +

        + + + + +
        + + + +

        + + +

        + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/lost-password-confirmation.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/lost-password-confirmation.php new file mode 100644 index 0000000..ed39bf8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/lost-password-confirmation.php @@ -0,0 +1,27 @@ + + +

        diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/my-account.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-account.php new file mode 100644 index 0000000..ec40977 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-account.php @@ -0,0 +1,39 @@ + + +
        + +
        diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/my-address.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-address.php new file mode 100644 index 0000000..6ef25a8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-address.php @@ -0,0 +1,65 @@ + __( 'Billing address', 'woocommerce' ), + 'shipping' => __( 'Shipping address', 'woocommerce' ), + ), $customer_id ); +} else { + $get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array( + 'billing' => __( 'Billing address', 'woocommerce' ), + ), $customer_id ); +} + +$oldcol = 1; +$col = 1; +?> + +

        + +

        + + +
        + + + $title ) : ?> + +
        +
        +

        + +
        +
        +
        + + + + +
        +customer->get_downloadable_products() ) : ?> + + + +

        + +
          + +
        • + ' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . ' ', $download ); + } + + echo apply_filters( 'woocommerce_available_download_link', '' . $download['download_name'] . '', $download ); + + do_action( 'woocommerce_available_download_end', $download ); + ?> +
        • + +
        + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/my-orders.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-orders.php new file mode 100644 index 0000000..e1add6a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/my-orders.php @@ -0,0 +1,87 @@ + __( 'Order', 'woocommerce' ), + 'order-date' => __( 'Date', 'woocommerce' ), + 'order-status' => __( 'Status', 'woocommerce' ), + 'order-total' => __( 'Total', 'woocommerce' ), + 'order-actions' => ' ', +) ); + +$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array( + 'numberposts' => $order_count, + 'meta_key' => '_customer_user', + 'meta_value' => get_current_user_id(), + 'post_type' => wc_get_order_types( 'view-orders' ), + 'post_status' => array_keys( wc_get_order_statuses() ), +) ) ); + +if ( $customer_orders ) : ?> + +

        + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-order-details.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-order-details.php new file mode 100644 index 0000000..93f10bb --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-order-details.php @@ -0,0 +1,89 @@ + + +

      + get_edit_order_url() ) . '">'; + $after = ''; + } else { + $before = ''; + $after = ''; + } + /* translators: %s: Order ID. */ + echo wp_kses_post( $before . sprintf( __( 'Order #%s', 'woocommerce' ) . $after . ' ()', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) ); + ?> +

      + +
      + + + + + + + + + + $sent_to_admin, + 'show_image' => false, + 'image_size' => array( 32, 32 ), + 'plain_text' => $plain_text, + 'sent_to_admin' => $sent_to_admin, + ) ); + ?> + + + get_order_item_totals(); + + if ( $totals ) { + $i = 0; + foreach ( $totals as $total ) { + $i++; + ?> + + + + + get_customer_note() ) { + ?> + + + + + + +
      get_customer_note() ) ); ?>
      +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/emails/email-order-items.php b/backend/wp-content/plugins/woocommerce/templates/emails/email-order-items.php new file mode 100644 index 0000000..4473a56 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/emails/email-order-items.php @@ -0,0 +1,88 @@ + $item ) : + $product = $item->get_product(); + $sku = ''; + $purchase_note = ''; + $image = ''; + + if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { + continue; + } + + if ( is_object( $product ) ) { + $sku = $product->get_sku(); + $purchase_note = $product->get_purchase_note(); + $image = $product->get_image( $image_size ); + } + + ?> +
      + get_name(), $item, false ) ); + + // SKU. + if ( $show_sku && $sku ) { + echo wp_kses_post( ' (#' . $sku . ')' ); + } + + // allow other plugins to add additional product information here. + do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text ); + + wc_display_item_meta( $item ); + + // allow other plugins to add additional product information here. + do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text ); + + ?> + + get_quantity(), $item ) ); ?> + + get_formatted_line_subtotal( $item ) ); ?> +
      + +
      + + + + $column_name ) : ?> + + + + + + + get_item_count(); + ?> + + $column_name ) : ?> + + + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/navigation.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/navigation.php new file mode 100644 index 0000000..72e91b2 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/navigation.php @@ -0,0 +1,36 @@ + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/orders.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/orders.php new file mode 100644 index 0000000..45309c0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/orders.php @@ -0,0 +1,107 @@ + + + + + + + + $column_name ) : ?> + + + + + + + orders as $customer_order ) : + $order = wc_get_order( $customer_order ); + $item_count = $order->get_item_count(); + ?> + + $column_name ) : ?> + + + + + + + + + + max_num_pages ) : ?> +
      + + + + + max_num_pages ) !== $current_page ) : ?> + + +
      + + + +
      + + + + +
      + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/payment-methods.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/payment-methods.php new file mode 100644 index 0000000..56bcd92 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/payment-methods.php @@ -0,0 +1,81 @@ + + + + + + + + $column_name ) : ?> + + + + + $methods ) : ?> + + + $column_name ) : ?> + + + + + + + + + +

      + + + + + +payment_gateways->get_available_payment_gateways() ) : ?> + + diff --git a/backend/wp-content/plugins/woocommerce/templates/myaccount/view-order.php b/backend/wp-content/plugins/woocommerce/templates/myaccount/view-order.php new file mode 100644 index 0000000..aeacc9e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/myaccount/view-order.php @@ -0,0 +1,56 @@ + +

      ' . $order->get_order_number() . '', + '' . wc_format_datetime( $order->get_date_created() ) . '', + '' . wc_get_order_status_name( $order->get_status() ) . '' + ); +?>

      + +get_customer_order_notes() ) : ?> +

      +
        + +
      1. +
        +
        +

        comment_date ) ); ?>

        +
        + comment_content ) ); ?> +
        +
        +
        +
        +
        +
      2. + +
      + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/notices/error.php b/backend/wp-content/plugins/woocommerce/templates/notices/error.php new file mode 100644 index 0000000..1b86a0f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/notices/error.php @@ -0,0 +1,32 @@ + + diff --git a/backend/wp-content/plugins/woocommerce/templates/notices/notice.php b/backend/wp-content/plugins/woocommerce/templates/notices/notice.php new file mode 100644 index 0000000..fe92bbe --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/notices/notice.php @@ -0,0 +1,31 @@ + + + +
      + diff --git a/backend/wp-content/plugins/woocommerce/templates/notices/success.php b/backend/wp-content/plugins/woocommerce/templates/notices/success.php new file mode 100644 index 0000000..a36f862 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/notices/success.php @@ -0,0 +1,31 @@ + + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/order/form-tracking.php b/backend/wp-content/plugins/woocommerce/templates/order/form-tracking.php new file mode 100644 index 0000000..20d34e3 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/form-tracking.php @@ -0,0 +1,34 @@ + + +
      + +

      + +

      +

      +
      + +

      + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/order/order-again.php b/backend/wp-content/plugins/woocommerce/templates/order/order-again.php new file mode 100644 index 0000000..a7ba7a7 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/order-again.php @@ -0,0 +1,26 @@ + + +

      + +

      diff --git a/backend/wp-content/plugins/woocommerce/templates/order/order-details-customer.php b/backend/wp-content/plugins/woocommerce/templates/order/order-details-customer.php new file mode 100644 index 0000000..0a45e6d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/order-details-customer.php @@ -0,0 +1,62 @@ +needs_shipping_address(); +?> +
      + + + +
      +
      + + + +

      + +
      + get_formatted_billing_address( __( 'N/A', 'woocommerce' ) ) ); ?> + + get_billing_phone() ) : ?> +

      get_billing_phone() ); ?>

      + + + get_billing_email() ) : ?> + + +
      + + + +
      + +
      +

      +
      + get_formatted_shipping_address( __( 'N/A', 'woocommerce' ) ) ); ?> +
      +
      + +
      + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/order/order-details-item.php b/backend/wp-content/plugins/woocommerce/templates/order/order-details-item.php new file mode 100644 index 0000000..5d78bec --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/order-details-item.php @@ -0,0 +1,59 @@ + +
      + is_visible(); + $product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order ); + + echo apply_filters( 'woocommerce_order_item_name', $product_permalink ? sprintf( '%s', $product_permalink, $item->get_name() ) : $item->get_name(), $item, $is_visible ); + echo apply_filters( 'woocommerce_order_item_quantity_html', ' ' . sprintf( '× %s', $item->get_quantity() ) . '', $item ); + + do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, false ); + + wc_display_item_meta( $item ); + + do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, false ); + ?> + + get_formatted_line_subtotal( $item ); ?> +
      + + + + + + + + + + $item ) { + $product = $item->get_product(); + + wc_get_template( 'order/order-details-item.php', array( + 'order' => $order, + 'item_id' => $item_id, + 'item' => $item, + 'show_purchase_note' => $show_purchase_note, + 'purchase_note' => $product ? $product->get_purchase_note() : '', + 'product' => $product, + ) ); + } + + do_action( 'woocommerce_order_details_after_order_table_items', $order ); + ?> + + + + get_order_item_totals() as $key => $total ) { + ?> + + + + + + get_customer_note() ) : ?> + + + + + + +
      get_customer_note() ); ?>
      + + + + + $order ) ); +} diff --git a/backend/wp-content/plugins/woocommerce/templates/order/order-downloads.php b/backend/wp-content/plugins/woocommerce/templates/order/order-downloads.php new file mode 100644 index 0000000..50ff7db --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/order-downloads.php @@ -0,0 +1,74 @@ + +
      + +

      + + + + + + $column_name ) : ?> + + + + + + + + $column_name ) : ?> + + + + +
      + ' . esc_html( $download['product_name'] ) . ''; + } else { + echo esc_html( $download['product_name'] ); + } + break; + case 'download-file': + echo '' . esc_html( $download['download_name'] ) . ''; + break; + case 'download-remaining': + echo is_numeric( $download['downloads_remaining'] ) ? esc_html( $download['downloads_remaining'] ) : esc_html__( '∞', 'woocommerce' ); + break; + case 'download-expires': + if ( ! empty( $download['access_expires'] ) ) { + echo ''; + } else { + esc_html_e( 'Never', 'woocommerce' ); + } + break; + } + } + ?> +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/order/tracking.php b/backend/wp-content/plugins/woocommerce/templates/order/tracking.php new file mode 100644 index 0000000..cba04ea --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/order/tracking.php @@ -0,0 +1,54 @@ + + +

      ' . $order->get_order_number() . '', + '' . wc_format_datetime( $order->get_date_created() ) . '', + '' . wc_get_order_status_name( $order->get_status() ) . '' + ) ) ); +?>

      + +get_customer_order_notes() ) : ?> +

      +
        + +
      1. +
        +
        +

        comment_date ) ); ?>

        +
        + comment_content ) ); ?> +
        +
        +
        +
        +
        +
      2. + +
      + + +get_id() ); ?> diff --git a/backend/wp-content/plugins/woocommerce/templates/product-searchform.php b/backend/wp-content/plugins/woocommerce/templates/product-searchform.php new file mode 100644 index 0000000..50e5285 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/product-searchform.php @@ -0,0 +1,29 @@ + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product-reviews.php b/backend/wp-content/plugins/woocommerce/templates/single-product-reviews.php new file mode 100644 index 0000000..ec48ad8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product-reviews.php @@ -0,0 +1,116 @@ + +
      +
      +

      get_review_count() ) ) { + /* translators: 1: reviews count 2: product name */ + printf( esc_html( _n( '%1$s review for %2$s', '%1$s reviews for %2$s', $count, 'woocommerce' ) ), esc_html( $count ), '' . get_the_title() . '' ); + } else { + _e( 'Reviews', 'woocommerce' ); + } + ?>

      + + + +
        + 'woocommerce_comments' ) ) ); ?> +
      + + 1 && get_option( 'page_comments' ) ) : + echo ''; + endif; ?> + + + +

      + + +
      + + get_id() ) ) : ?> + +
      +
      + have_comments() ? __( 'Add a review', 'woocommerce' ) : sprintf( __( 'Be the first to review “%s”', 'woocommerce' ), get_the_title() ), + 'title_reply_to' => __( 'Leave a Reply to %s', 'woocommerce' ), + 'title_reply_before' => '', + 'title_reply_after' => '', + 'comment_notes_after' => '', + 'fields' => array( + 'author' => '

      ' . ' ' . + '

      ', + 'email' => '', + ), + 'label_submit' => __( 'Submit', 'woocommerce' ), + 'logged_in_as' => '', + 'comment_field' => '', + ); + + if ( $account_page_url = wc_get_page_permalink( 'myaccount' ) ) { + $comment_form['must_log_in'] = ''; + } + + if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) { + $comment_form['comment_field'] = '
      '; + } + + $comment_form['comment_field'] .= '

      '; + + comment_form( apply_filters( 'woocommerce_product_review_comment_form_args', $comment_form ) ); + ?> +
      +
      + + + +

      + + + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product.php b/backend/wp-content/plugins/woocommerce/templates/single-product.php new file mode 100644 index 0000000..f8b35da --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product.php @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + +
      + + + + + + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/grouped.php b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/grouped.php new file mode 100644 index 0000000..0408fd8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/grouped.php @@ -0,0 +1,110 @@ + + +
      + + + get_id() ); + $quantites_required = $quantites_required || ( $grouped_product_child->is_purchasable() && ! $grouped_product_child->has_options() ); + $post = $post_object; // WPCS: override ok. + setup_postdata( $post ); + + echo ''; + + // Output columns for each product. + foreach ( $grouped_product_columns as $column_id ) { + do_action( 'woocommerce_grouped_product_list_before_' . $column_id, $grouped_product_child ); + + switch ( $column_id ) { + case 'quantity': + ob_start(); + + if ( ! $grouped_product_child->is_purchasable() || $grouped_product_child->has_options() || ! $grouped_product_child->is_in_stock() ) { + woocommerce_template_loop_add_to_cart(); + } elseif ( $grouped_product_child->is_sold_individually() ) { + echo ''; + } else { + do_action( 'woocommerce_before_add_to_cart_quantity' ); + + woocommerce_quantity_input( array( + 'input_name' => 'quantity[' . $grouped_product_child->get_id() . ']', + 'input_value' => isset( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ? wc_stock_amount( wc_clean( wp_unslash( $_POST['quantity'][ $grouped_product_child->get_id() ] ) ) ) : 0, // WPCS: CSRF ok, input var okay, sanitization ok. + 'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $grouped_product_child ), + 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $grouped_product_child->get_max_purchase_quantity(), $grouped_product_child ), + ) ); + + do_action( 'woocommerce_after_add_to_cart_quantity' ); + } + + $value = ob_get_clean(); + break; + case 'label': + $value = ''; + break; + case 'price': + $value = $grouped_product_child->get_price_html() . wc_get_stock_html( $grouped_product_child ); + break; + default: + $value = ''; + break; + } + + echo ''; // WPCS: XSS ok. + + do_action( 'woocommerce_grouped_product_list_after_' . $column_id, $grouped_product_child ); + } + + echo ''; + } + $post = $previous_post; // WPCS: override ok. + setup_postdata( $post ); + ?> + +
      ' . apply_filters( 'woocommerce_grouped_product_list_column_' . $column_id, $value, $grouped_product_child ) . '
      + + + + + + + + + + + + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple.php b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple.php new file mode 100644 index 0000000..bc4cfc0 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/simple.php @@ -0,0 +1,54 @@ +is_purchasable() ) { + return; +} + +echo wc_get_stock_html( $product ); // WPCS: XSS ok. + +if ( $product->is_in_stock() ) : ?> + + + +
      + + + apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), + 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), + 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. + ) ); + + do_action( 'woocommerce_after_add_to_cart_quantity' ); + ?> + + + + +
      + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variable.php b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variable.php new file mode 100644 index 0000000..852a3a5 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variable.php @@ -0,0 +1,80 @@ + + +
      + + + +

      + + + + $options ) : ?> + + + + + + +
      + $options, + 'attribute' => $attribute_name, + 'product' => $product, + ) ); + echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '' . esc_html__( 'Clear', 'woocommerce' ) . '' ) ) : ''; + ?> +
      + +
      + +
      + + + +
      + + +
      + + + apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), + 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), + 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. + ) ); + + do_action( 'woocommerce_after_add_to_cart_quantity' ); + ?> + + + + + + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variation.php b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variation.php new file mode 100644 index 0000000..3e4ae71 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/add-to-cart/variation.php @@ -0,0 +1,24 @@ + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/meta.php b/backend/wp-content/plugins/woocommerce/templates/single-product/meta.php new file mode 100644 index 0000000..a12ab1f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/meta.php @@ -0,0 +1,41 @@ + +
      + + + + get_sku() || $product->is_type( 'variable' ) ) ) : ?> + + get_sku() ) ? $sku : esc_html__( 'N/A', 'woocommerce' ); ?> + + + + get_id(), ', ', '' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '' ); ?> + + get_id(), ', ', '' . _n( 'Tag:', 'Tags:', count( $product->get_tag_ids() ), 'woocommerce' ) . ' ', '' ); ?> + + + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/photoswipe.php b/backend/wp-content/plugins/woocommerce/templates/single-product/photoswipe.php new file mode 100644 index 0000000..a92f6aa --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/photoswipe.php @@ -0,0 +1,57 @@ + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/price.php b/backend/wp-content/plugins/woocommerce/templates/single-product/price.php new file mode 100644 index 0000000..3dfc17a --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/price.php @@ -0,0 +1,26 @@ + +

      get_price_html(); ?>

      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/product-attributes.php b/backend/wp-content/plugins/woocommerce/templates/single-product/product-attributes.php new file mode 100644 index 0000000..f047da9 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/product-attributes.php @@ -0,0 +1,71 @@ + + + has_weight() ) : ?> + + + + + + + has_dimensions() ) : ?> + + + + + + + + + + + + +
      get_weight() ) ); ?>
      get_dimensions( false ) ) ); ?>
      get_name() ); ?>is_taxonomy() ) { + $attribute_taxonomy = $attribute->get_taxonomy_object(); + $attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'all' ) ); + + foreach ( $attribute_values as $attribute_value ) { + $value_name = esc_html( $attribute_value->name ); + + if ( $attribute_taxonomy->attribute_public ) { + $values[] = ''; + } else { + $values[] = $value_name; + } + } + } else { + $values = $attribute->get_options(); + + foreach ( $values as &$value ) { + $value = make_clickable( esc_html( $value ) ); + } + } + + echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values ); + ?>
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/product-image.php b/backend/wp-content/plugins/woocommerce/templates/single-product/product-image.php new file mode 100644 index 0000000..f410108 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/product-image.php @@ -0,0 +1,53 @@ +get_image_id(); +$wrapper_classes = apply_filters( 'woocommerce_single_product_image_gallery_classes', array( + 'woocommerce-product-gallery', + 'woocommerce-product-gallery--' . ( has_post_thumbnail() ? 'with-images' : 'without-images' ), + 'woocommerce-product-gallery--columns-' . absint( $columns ), + 'images', +) ); +?> +
      +
      '; + } + + echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id ); + + do_action( 'woocommerce_product_thumbnails' ); + ?> + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/product-thumbnails.php b/backend/wp-content/plugins/woocommerce/templates/single-product/product-thumbnails.php new file mode 100644 index 0000000..b3e06a4 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/product-thumbnails.php @@ -0,0 +1,34 @@ +get_gallery_image_ids(); + +if ( $attachment_ids && has_post_thumbnail() ) { + foreach ( $attachment_ids as $attachment_id ) { + echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id ); + } +} diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/rating.php b/backend/wp-content/plugins/woocommerce/templates/single-product/rating.php new file mode 100644 index 0000000..df55e56 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/rating.php @@ -0,0 +1,40 @@ +get_rating_count(); +$review_count = $product->get_review_count(); +$average = $product->get_average_rating(); + +if ( $rating_count > 0 ) : ?> + + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/related.php b/backend/wp-content/plugins/woocommerce/templates/single-product/related.php new file mode 100644 index 0000000..aa0992f --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/related.php @@ -0,0 +1,48 @@ + + + + +comment_ID ); + +if ( '0' === $comment->comment_approved ) { ?> + +

      + + + +

      + + + +

      + + (' . esc_attr__( 'verified owner', 'woocommerce' ) . ') '; + } + + ?> + +

      + +comment_ID, 'rating', true ) ); + +if ( $rating && 'yes' === get_option( 'woocommerce_enable_review_rating' ) ) { + echo wc_get_rating_html( $rating ); +} diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/review.php b/backend/wp-content/plugins/woocommerce/templates/single-product/review.php new file mode 100644 index 0000000..596b92d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/review.php @@ -0,0 +1,68 @@ + +
    • id="li-comment-"> + +
      + + + +
      + + + +
      +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php b/backend/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php new file mode 100644 index 0000000..2ca8ae8 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/sale-flash.php @@ -0,0 +1,32 @@ + +is_on_sale() ) : ?> + + ' . esc_html__( 'Sale!', 'woocommerce' ) . '', $post, $product ); ?> + + + +post_excerpt ); + +if ( ! $short_description ) { + return; +} + +?> +
      + +
      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/stock.php b/backend/wp-content/plugins/woocommerce/templates/single-product/stock.php new file mode 100644 index 0000000..4a45929 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/stock.php @@ -0,0 +1,24 @@ + +

      diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/additional-information.php b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/additional-information.php new file mode 100644 index 0000000..e682eea --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/additional-information.php @@ -0,0 +1,33 @@ + + + +

      + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/description.php b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/description.php new file mode 100644 index 0000000..08bb56d --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/description.php @@ -0,0 +1,33 @@ + + + +

      + + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php new file mode 100644 index 0000000..5d5217c --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php @@ -0,0 +1,48 @@ + + +
      +
        + $tab ) : ?> + + +
      + $tab ) : ?> +
      + +
      + +
      + + diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/title.php b/backend/wp-content/plugins/woocommerce/templates/single-product/title.php new file mode 100644 index 0000000..93e5150 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/title.php @@ -0,0 +1,23 @@ +', '' ); diff --git a/backend/wp-content/plugins/woocommerce/templates/single-product/up-sells.php b/backend/wp-content/plugins/woocommerce/templates/single-product/up-sells.php new file mode 100644 index 0000000..baaa90e --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/templates/single-product/up-sells.php @@ -0,0 +1,48 @@ + + +
      + +

      + + + + + + get_id() ); + + setup_postdata( $GLOBALS['post'] =& $post_object ); + + wc_get_template_part( 'content', 'product' ); ?> + + + + + +
      + +get_var( "SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_attribute_taxonomies';" ) ) { + $wc_attributes = array_filter( (array) $wpdb->get_col( "SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies;" ) ); + } else { + $wc_attributes = array(); + } + + // Tables. + WC_Install::drop_tables(); + + // Delete options. + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';" ); + $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'widget\_woocommerce\_%';" ); + + // Delete usermeta. + $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'woocommerce\_%';" ); + + // Delete posts + data. + $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" ); + $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); + + $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type IN ( 'order_note' );" ); + $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); + + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_items" ); + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_itemmeta" ); + + // Delete terms if > WP 4.2 (term splitting was added in 4.2). + if ( version_compare( $wp_version, '4.2', '>=' ) ) { + // Delete term taxonomies. + foreach ( array( 'product_cat', 'product_tag', 'product_shipping_class', 'product_type' ) as $taxonomy ) { + $wpdb->delete( + $wpdb->term_taxonomy, + array( + 'taxonomy' => $taxonomy, + ) + ); + } + + // Delete term attributes. + foreach ( $wc_attributes as $taxonomy ) { + $wpdb->delete( + $wpdb->term_taxonomy, + array( + 'taxonomy' => 'pa_' . $taxonomy, + ) + ); + } + + // Delete orphan relationships. + $wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" ); + + // Delete orphan terms. + $wpdb->query( "DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;" ); + + // Delete orphan term meta. + if ( ! empty( $wpdb->termmeta ) ) { + $wpdb->query( "DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;" ); + } + } + + // Clear any cached data that has been removed. + wp_cache_flush(); +} diff --git a/backend/wp-content/plugins/woocommerce/woocommerce.php b/backend/wp-content/plugins/woocommerce/woocommerce.php new file mode 100644 index 0000000..a46ed43 --- /dev/null +++ b/backend/wp-content/plugins/woocommerce/woocommerce.php @@ -0,0 +1,42 @@ + + +
      +
      + +
      + + +
      +

      + + +
      +
      + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/archive.php b/backend/wp-content/themes/twentyfifteen/archive.php new file mode 100644 index 0000000..bb6021e --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/archive.php @@ -0,0 +1,64 @@ + + +
      +
      + + + + + + __( 'Previous page', 'twentyfifteen' ), + 'next_text' => __( 'Next page', 'twentyfifteen' ), + 'before_page_number' => '' . __( 'Page', 'twentyfifteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'content', 'none' ); + + endif; + ?> + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/author-bio.php b/backend/wp-content/themes/twentyfifteen/author-bio.php new file mode 100644 index 0000000..839df91 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/author-bio.php @@ -0,0 +1,39 @@ + + +
      +

      +
      + +
      + +
      +

      + +

      + + +

      + +
      +
      diff --git a/backend/wp-content/themes/twentyfifteen/comments.php b/backend/wp-content/themes/twentyfifteen/comments.php new file mode 100644 index 0000000..6b97ec3 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/comments.php @@ -0,0 +1,74 @@ + + +
      + + +

      + +

      + + + +
        + 'ol', + 'short_ping' => true, + 'avatar_size' => 56, + ) ); + ?> +
      + + + + + + +

      + + + + +
      diff --git a/backend/wp-content/themes/twentyfifteen/content-link.php b/backend/wp-content/themes/twentyfifteen/content-link.php new file mode 100644 index 0000000..2beb1f7 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/content-link.php @@ -0,0 +1,60 @@ + + + diff --git a/backend/wp-content/themes/twentyfifteen/content-none.php b/backend/wp-content/themes/twentyfifteen/content-none.php new file mode 100644 index 0000000..f1d59be --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/content-none.php @@ -0,0 +1,37 @@ + + +
      + + +
      + + + +

      Get started here.', 'twentyfifteen' ), esc_url( admin_url( 'post-new.php' ) ) ); ?>

      + + + +

      + + + + +

      + + + + +
      +
      diff --git a/backend/wp-content/themes/twentyfifteen/content-page.php b/backend/wp-content/themes/twentyfifteen/content-page.php new file mode 100644 index 0000000..7d37daa --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/content-page.php @@ -0,0 +1,37 @@ + + +
      > + + +
      + ', '' ); ?> +
      + +
      + + '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentyfifteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + + ', '' ); ?> + +
      diff --git a/backend/wp-content/themes/twentyfifteen/content-search.php b/backend/wp-content/themes/twentyfifteen/content-search.php new file mode 100644 index 0000000..33e2d99 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/content-search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/wp-content/themes/twentyfifteen/content.php b/backend/wp-content/themes/twentyfifteen/content.php new file mode 100644 index 0000000..2475600 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/content.php @@ -0,0 +1,60 @@ + + +
      > + + +
      + ', '' ); + else : + the_title( sprintf( '

      ', esc_url( get_permalink() ) ), '

      ' ); + endif; + ?> +
      + +
      + ', '', false ) + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentyfifteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + + + +
      + + ', '' ); ?> +
      + +
      diff --git a/backend/wp-content/themes/twentyfifteen/css/editor-style.css b/backend/wp-content/themes/twentyfifteen/css/editor-style.css new file mode 100644 index 0000000..b3cdd0f --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/css/editor-style.css @@ -0,0 +1,482 @@ +/* +Theme Name: Twenty Fifteen +Description: Used to style the TinyMCE editor. +*/ + + +/** + * Table of Contents: + * + * 1.0 - Body + * 2.0 - Typography + * 3.0 - Elements + * 4.0 - Alignment + * 5.0 - Caption + * 6.0 - Galleries + * 7.0 - Audio / Video + * 8.0 - RTL + */ + + +/** + * 1.0 Body + */ + +body { + color: #333; + font-family: "Noto Serif", serif; + font-weight: 400; + font-size: 17px; + line-height: 1.6471; + margin: 20px 40px; + max-width: 660px; + vertical-align: baseline; +} + + +/** + * 2.0 Typography + */ + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + font-weight: 700; + margin: 56px 0 28px; +} + +h1 { + font-size: 35px; + line-height: 1.2308; +} + +h2 { + font-size: 29px; + line-height: 1.2069; +} + +h3 { + font-size: 24px; + line-height: 1.1667; +} + +h4 { + font-size: 20px; + line-height: 1.4; +} + +h5, +h6 { + font-size: 17px; + letter-spacing: 0.1em; + line-height: 1.2353; + text-transform: uppercase; +} + +h1:first-child, +h2:first-child, +h3:first-child, +h4:first-child, +h5:first-child, +h6:first-child { + margin-top: 0; +} + +p { + margin: 0 0 28px; +} + +b, +strong { + font-weight: 700; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + border-left: 4px solid #707070; + color: #707070; + font-size: 20px; + font-style: italic; + line-height: 1.8182; + margin: 0 0 35px -21px; + padding-left: 17px; +} + +blockquote > blockquote { + margin-left: 0; +} + +blockquote p { + margin-bottom: 35px; +} + +blockquote > p:last-child { + margin-bottom: 0; +} + +blockquote cite, +blockquote small { + color: #333; + font-family: "Noto Sans", sans-serif; + font-size: 17px; + line-height: 1.6471; +} + +blockquote em, +blockquote i, +blockquote cite { + font-style: normal; +} + +blockquote strong, +blockquote b { + font-weight: 400; +} + +address { + font-style: italic; + margin: 0 0 28px; +} + +code, +kbd, +tt, +var, +samp, +pre { + font-family: Inconsolata, monospace; +} + +pre { + background-color: #fcfcfc; + border: 1px solid #eaeaea; + font-size: 17px; + line-height: 1.2353; + margin-bottom: 28px; + max-width: 100%; + overflow: auto; + padding: 14px; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +abbr[title] { + border-bottom: 1px dotted #eaeaea; + cursor: help; +} + +mark, +ins { + background-color: #fff9c0; + text-decoration: none; +} + +sup, +sub { + font-size: 75%; + height: 0; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + bottom: 1ex; +} + +sub { + top: .5ex; +} + +small { + font-size: 75%; +} + +big { + font-size: 125%; +} + + +/** + * 3.0 Elements + */ + +hr { + background-color: #eaeaea; + border: 0; + height: 1px; + margin-bottom: 28px; +} + +ul, +ol { + margin: 0 0 28px 0; + padding: 0; +} + +ul { + list-style: disc; +} + +ol { + list-style: decimal; +} + +li > ul, +li > ol { + margin: 0 0 0 23px; +} + +blockquote > ul, +blockquote > ol { + margin-left: 28px; +} + +dl { + margin: 0 0 28px; +} + +dt { + font-weight: bold; +} + +dd { + margin: 0 0 28px; +} + +table, +th, +td, +.mce-item-table, +.mce-item-table th, +.mce-item-table td { + border: 1px solid #eaeaea; +} + +table a { + color: #333; +} + +table, +.mce-item-table { + border-collapse: separate; + border-spacing: 0; + border-width: 1px 0 0 1px; + margin: 0 0 28px; + width: 100%; +} + +table th, +.mce-item-table th, +table caption { + border-width: 0 1px 1px 0; + font-family: "Noto Serif", serif; + font-size: 17px; + font-weight: 700; + padding: 7px; + text-align: left; + vertical-align: baseline; +} + +table td, +.mce-item-table td { + border-width: 0 1px 1px 0; + font-family: "Noto Serif", serif; + font-size: 17px; + padding: 7px; + vertical-align: baseline; +} + +img { + border: 0; + height: auto; + max-width: 100%; + vertical-align: middle; +} + +figure { + margin: 0; +} + +del { + opacity: 0.8; +} + +a { + border-bottom: 1px solid #333; + color: #333; + text-decoration: none; +} + + +/** + * 4.0 Alignment + */ + +.alignleft { + float: left; + margin: 7px 28px 28px 0; +} + +.alignright { + float: right; + margin: 7px 0 28px 28px; +} + +.aligncenter { + clear: both; + display: block; + margin: 7px auto; +} + + +/** + * 5.0 Caption + */ + +.wp-caption { + background: transparent; + border: none; + color: #707070; + font-family: "Noto Sans", sans-serif; + margin: 0 0 28px 0; + max-width: 100%; + padding: 0; + text-align: inherit; +} + +.wp-caption.alignleft { + margin: 7px 28px 21px 0; +} + +.wp-caption.alignright { + margin: 7px 0 21px 28px; +} + +.wp-caption.aligncenter { + margin: 7px auto; +} + +.wp-caption .wp-caption-text, +.wp-caption-dd { + font-size: 14px; + line-height: 1.5; + padding: 7px 0; +} + + +/** + * 6.0 Galleries + */ + +.gallery-item { + display: inline-block; + padding: 1.79104477%; + text-align: center; + vertical-align: top; + width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-columns-3 .gallery-item { + max-width: 33.33%; +} + +.gallery-columns-4 .gallery-item { + max-width: 25%; +} + +.gallery-columns-5 .gallery-item { + max-width: 20%; +} + +.gallery-columns-6 .gallery-item { + max-width: 16.66%; +} + +.gallery-columns-7 .gallery-item { + max-width: 14.28%; +} + +.gallery-columns-8 .gallery-item { + max-width: 12.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 11.11%; +} + +.gallery .gallery-caption { + color: #707070; + display: block; + font-family: "Noto Sans", sans-serif; + font-size: 14px; + line-height: 1.5; + padding: 7px 0; +} + +.gallery-columns-6 .gallery-caption, +.gallery-columns-7 .gallery-caption, +.gallery-columns-8 .gallery-caption, +.gallery-columns-9 .gallery-caption { + display: none; +} + + +/** + * 7.0 Audio / Video + */ + +.mce-content-body .wpview-wrap { + margin-bottom: 32px; +} + +.mce-content-body .wp-audio-playlist { + margin: 0; +} + + +/** + * 8.0 RTL + */ + +body.rtl { + font-family: Arial, Tahoma, sans-serif; +} + +.rtl blockquote { + border-left: none; + border-right: 4px solid #707070; + margin: 0 -21px 35px 0; + padding-left: 0; + padding-right: 17px; +} + +.rtl blockquote > blockquote { + margin-left: auto; + margin-right: 0; +} + +.rtl li > ul, +.rtl li > ol { + margin: 0 23px 0 0; +} + +.rtl table th, +.rtl table caption { + text-align: right; +} diff --git a/backend/wp-content/themes/twentyfifteen/css/ie.css b/backend/wp-content/themes/twentyfifteen/css/ie.css new file mode 100644 index 0000000..74ead6a --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/css/ie.css @@ -0,0 +1,948 @@ +/* +Theme Name: Twenty Fifteen +Description: Global Styles for older IE versions (previous to IE9). +*/ + +body, +button, +input, +select, +textarea { + font-size: 19px; + line-height: 1.6842; +} + +button, +input { + line-height: normal; +} + +p, +address, +pre, +hr, +ul, +ol, +dl, +dd, +table { + margin-bottom: 1.6842em; +} + +ul, +ol { + margin-left: 0; +} + +li > ul, +li > ol, +blockquote > ul, +blockquote > ol { + margin-left: 1.3333em; +} + +blockquote { + border-color: inherit; + border-style: solid; + border-width: 0 0 0 4px; + font-size: 22px; + line-height: 1.8182; + margin-bottom: 1.8182em; + margin-left: -1.0909em; + padding-left: 0.9091em; +} + +blockquote > blockquote { + margin-left: 0; +} + +blockquote p { + margin-bottom: 1.8182em; +} + +blockquote cite, +blockquote small { + font-size: 19px; + line-height: 1.6842; +} + +pre { + line-height: 1.2632; +} + +.entry-content img, +.entry-summary img, +.page-content img, +.comment-content img, +.widget img { + max-width: 660px; +} + +img.size-full, +img.size-large, +img.header-image, +img.wp-post-image, +img[class*="align"], +img[class*="wp-image-"], +img[class*="attachment-"] { + height: auto; + width: auto; /* Prevent stretching of full-size and large-size images with height and width attributes in IE8 */ +} + +button, +input[type="button"], +input[type="reset"], +input[type="submit"], +.post-password-form input[type="submit"], +.widecolumn #submit, +.widecolumn .mu_register input[type="submit"] { + font-size: 16px; + padding: 0.8125em 1.625em; +} + +input[type="text"], +input[type="email"], +input[type="url"], +input[type="password"], +input[type="search"], +textarea { + padding: 0.5278em; +} + +.main-navigation { + font-size: 16px; + line-height: 1.5; + margin: 9.0909%; +} + +.main-navigation ul ul { + border-bottom: 0; + border-top: 0; + margin-left: 1em; +} + +.main-navigation a { + padding: 0.75em 0; +} + +.main-navigation .menu-item-has-children > a { + padding-right: 48px; +} + +.main-navigation .menu-item-description { + font-size: 13px; + line-height: 1.8462; + margin-top: 0; +} + +.social-navigation { + margin: 9.0909%; + max-width: 660px; + padding-top: 0; +} + +.social-navigation ul { + margin-bottom: -1.2632em; +} + +.social-navigation a { + width: 2.5263em; + height: 2.5263em; +} + +.secondary-toggle { + margin-top: -32px; + right: 7.6897%; + width: 64px; + height: 64px; +} + +.secondary-toggle:before { + line-height: 64px; +} + +.post-password-form label, +.post-navigation .meta-nav, +.comment-navigation, +.image-navigation, +.author-heading, +.author-bio, +.entry-footer, +.page-links a, +.page-links span, +.comment-metadata, +.pingback .edit-link, +.comment-list .reply, +.comment-notes, +.comment-awaiting-moderation, +.logged-in-as, +.comment-form label, +.form-allowed-tags, +.site-info, +.wp-caption-text, +.gallery-caption, +.entry-caption, +.widecolumn label, +.widecolumn .mu_register label { + font-size: 16px; +} + +.post-navigation .post-title { + font-size: 24px; + line-height: 1.1667; +} + +.pagination .nav-links { + min-height: 3.3684em; +} + +.pagination .page-numbers { + line-height: 3.3684em; + padding: 0 0.8421em; +} + +.pagination .prev, +.pagination .next { + padding: 0; + width: 64px; + height: 64px; +} + +.pagination .prev:before, +.pagination .next:before { + line-height: 64px; + width: 64px; + height: 64px; +} + +.image-navigation a { + display: block; + margin-bottom: 2em; +} + +.image-navigation .nav-previous, +.comment-navigation .nav-previous { + float: left; + width: 50%; +} +.image-navigation .nav-next, +.comment-navigation .nav-next { + float: right; + text-align: right; + width: 50%; +} + +.image-navigation .nav-previous a:before, +.image-navigation .nav-next a:after, +.comment-navigation .nav-previous a:before, +.comment-navigation .nav-next a:after { + font-size: 24px; + top: -1px; +} + +blockquote.alignleft, +.wp-caption.alignleft, +img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; +} + +blockquote.alignright, +.wp-caption.alignright, +img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; +} + +blockquote.aligncenter, +.wp-caption.aligncenter, +img.aligncenter { + margin-top: 0.4211em; + margin-bottom: 1.6842em; +} + +.site-header { + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + padding: 0; +} + +.secondary { + background-color: #fff; + margin: 0 auto; + max-width: 807px; + padding: 0; +} + +.site-main { + padding: 7.6923% 0; +} + +.site-content { + margin: 0 auto; + max-width: 954px; +} + +.site-branding { + background-color: inherit; + margin: 0 auto; + max-width: 954px; + padding: 0; +} + +.site-title { + font-size: 32px; + line-height: 1.25; + margin: 7.6897% 7.6897% 0; +} + +.site-description { + background-color: inherit; + display: block; + filter: alpha(opacity=70); + font-size: 16px; + margin: 0.5em 7.6897% 7.6897%; +} + +.sidebar { + position: static !important; +} + +.widget-area { + clear: both; + margin: 9.0909% 9.0909% 0; + max-width: 660px; +} + +.widget { + font-size: 16px; + margin: 0 0 11.1111%; +} + +.widget p, +.widget address, +.widget hr, +.widget ul, +.widget ol, +.widget dl, +.widget dd, +.widget table, +.widget pre { + margin-bottom: 1.5em; +} + +.widget li > ul, +.widget li > ol { + margin-bottom: 0; +} + +.widget blockquote { + font-size: 19px; + line-height: 1.6842; + margin-bottom: 1.6842em; + margin-left: -1.2632em; + padding-left: 1.0526em; +} + +.widget blockquote > blockquote { + margin-left: 0; +} + +.widget blockquote p { + margin-bottom: 1.6842em; +} + +.widget blockquote cite, +.widget blockquote small { + font-size: 16px; + line-height: 1.5; +} + +.widget pre { + line-height: 1.5; + padding: 0.75em; +} + +.widget button, +.widget input, +.widget select, +.widget textarea { + line-height: 1.5; +} + +.widget button, +.widget input { + line-height: normal; +} + +.widget button, +.widget input[type="button"], +.widget input[type="reset"], +.widget input[type="submit"] { + font-size: 16px; + padding: 0.8125em 1.625em; +} + +.widget input[type="text"], +.widget input[type="email"], +.widget input[type="url"], +.widget input[type="password"], +.widget input[type="search"], +.widget textarea { + padding: 0.75em; +} + +.widget-title { + margin: 0 0 1.5em; +} + +.widget_calendar td, +.widget_calendar th { + line-height: 2.9375; +} + +.widget_calendar caption { + margin: 0 0 1.5em; +} + +.widget_archive li, +.widget_categories li, +.widget_links li, +.widget_meta li, +.widget_nav_menu li, +.widget_pages li, +.widget_recent_comments li, +.widget_recent_entries li { + padding: 0.7188em 0; +} + +.widget_categories .children, +.widget_nav_menu .sub-menu, +.widget_pages .children { + margin: 0.7188em 0 0 1em; + padding-top: 0.7188em; +} + +.widget_rss li { + margin-bottom: 1.5em; +} + +.widget_rss .rss-date, +.widget_rss cite { + font-size: 13px; + line-height: 1.8462; +} + +.widget .wp-caption-text, +.widget .gallery-caption { + line-height: 1.5; + padding: 0.5em 0; +} + +.hentry, +.page-header, +.page-content { + margin: 0 7.6923%; +} + +.hentry + .hentry, +.page-header + .hentry, +.page-header + .page-content { + margin-top: 7.6923%; +} + +.post-thumbnail { + margin-bottom: 2.9474em; +} + +.entry-header { + padding: 0 9.0909%; +} + +.entry-title, +.widecolumn h2 { + font-size: 39px; + line-height: 1.2308; + margin-bottom: 1.2308em; +} + +.entry-content, +.entry-summary { + padding: 0 9.0909% 9.0909%; +} + +.entry-content h1, +.entry-summary h1, +.page-content h1, +.comment-content h1 { + font-size: 39px; + line-height: 1.2308; + margin-top: 1.641em; + margin-bottom: 0.8205em; +} + +.entry-content h2, +.entry-summary h2, +.page-content h2, +.comment-content h2 { + font-size: 32px; + line-height: 1.25; + margin-top: 2em; + margin-bottom: 1em; +} + +.entry-content h3, +.entry-summary h3, +.page-content h3, +.comment-content h3 { + font-size: 27px; + line-height: 1.1852; + margin-top: 2.3704em; + margin-bottom: 1.1852em; +} + +.entry-content h4, +.entry-summary h4, +.page-content h4, +.comment-content h4 { + font-size: 22px; + line-height: 1.4545; + margin-top: 2.9091em; + margin-bottom: 1.4545em; +} + +.entry-content h5, +.entry-content h6, +.entry-summary h5, +.entry-summary h6, +.page-content h5, +.page-content h6, +.comment-content h5, +.comment-content h6 { + font-size: 19px; + line-height: 1.2632; + margin-top: 3.3684em; + margin-bottom: 1.6842em; +} + +.entry-content .more-link:after { + font-size: 24px; + top: 3px; +} + +.author-info { + margin: 0 9.0909%; + padding: 9.0909% 0; +} + +.author-info .avatar { + margin: 0 1.6842em 1.6842em 0; + width: 56px; + height: 56px; +} + +.author-link:after { + font-size: 24px; + top: 0; +} + +.entry-footer { + padding: 4.5454% 9.0909%; +} + +.posted-on:before, +.byline:before, +.cat-links:before, +.tags-links:before, +.comments-link:before, +.entry-format:before, +.edit-link:before, +.full-size-link:before { + top: 4px; +} + +.updated { + display: none; +} + +.updated.published { + display: inline; +} + +.page-header { + border-color: inherit; + border-style: solid; + border-width: 0 0 0 7px; + padding: 3.8461% 7.6923%; +} + +.page-title, +.taxonomy-description { + margin-left: -7px; +} + +.taxonomy-description { + padding-top: 0.4211em; +} + +.page-title, +.comments-title, +.comment-reply-title, +.post-navigation .post-title { + font-size: 27px; + line-height: 1.1852; +} + +.page-content { + padding: 7.6923%; +} + +.page-links { + margin-bottom: 1.4736em; +} + +.page-links a, +.page-links > span { + margin: 0 0.25em 0.25em 0; +} + +.format-aside .entry-title, +.format-image .entry-title, +.format-video .entry-title, +.format-quote .entry-title, +.format-gallery .entry-title, +.format-status .entry-title, +.format-link .entry-title, +.format-audio .entry-title, +.format-chat .entry-title { + font-size: 22px; + line-height: 1.4545; + margin-bottom: 32px; +} + +.format-link .entry-title a:after { + top: 0.125em; +} + +.comments-title { + margin-bottom: 1.4545em; +} + +.comment-list article, +.comment-list .pingback, +.comment-list .trackback { + padding: 1.6842em 0; +} + +.comment-list + .comment-respond, +.comment-navigation + .comment-respond { + padding-top: 1.6842em; +} + +.comment-list .children > li { + padding-left: 1.4737em; +} + +.comment-meta { + position: relative; +} + +.comment-author { + margin-bottom: 0; + padding-left: 4.6315em; +} + +.comment-author .avatar { + margin: 0; + position: absolute; + top: 3px; + left: 0; + width: 56px; + height: 56px; +} + +.comment-metadata { + line-height: 2; + padding-left: 5.5em; +} + +.comment-metadata .edit-link:before, +.pingback .edit-link:before { + top: 8px; +} + +.bypostauthor > article .fn:after { + top: 8px; + left: 6px; +} + +.comment-content ul, +.comment-content ol { + margin: 0 0 1.6842em 0; +} + +.comment-content li > ul, +.comment-content li > ol, +.comment-content blockquote > ul, +.comment-content blockquote > ol { + margin-left: 1.3333em; +} + +.comment-list .reply a { + padding: 0.4375em 0.875em; +} + +.comment-form, +.no-comments { + padding-top: 1.6842em; +} + +.comment-reply-title small a:before { + top: -1px; +} + +.comment-list .reply { + margin-top: 0; +} + +.site-footer { + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + margin: 0 auto; + max-width: 806px; + padding: 0; +} + +.site-info { + margin: 4.5454% 9.0909%; +} + +.post-navigation { + border-top: 0; + margin: 7.6923% 7.6923% 0; +} + +.post-navigation a { + padding: 4.5454% 9.0909%; +} + +.pagination { + border-top: 0; + margin: 7.6923% 7.6923% 0; + padding: 0; +} + +.pagination .page-numbers { + display: inline-block; +} + +.pagination .meta-nav { + display: none; +} + +.image-navigation { + padding: 0 9.0909%; +} + +.comments-area { + border-top: 0; + margin: 7.6923% 7.6923% 0; +} + +embed, +iframe, +object, +video { + margin-bottom: 1.6842em; +} + +.wp-audio-shortcode, +.wp-video, +.wp-playlist.wp-audio-playlist { + font-size: 19px; + margin-bottom: 1.6842em; +} + +.wp-caption, +.gallery { + margin-bottom: 1.6842em; +} + +.wp-caption-text, +.gallery-caption { + padding: 0.5em 0; +} + +.widecolumn { + margin: 7.6923%; +} + +.widecolumn .mu_alert { + margin-bottom: 1.6842em; +} + +.widecolumn p { + margin: 1.6842em 0; +} + +.widecolumn p + h2 { + margin-top: 1.641em; +} + +.widecolumn #key, +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #blogname, +.widecolumn .mu_register #user_name { + font-size: 19px; +} + +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #user_name { + margin: 0 0 0.421em; +} + + +/** + * RTL + */ + +.rtl ul, +.rtl ol { + margin-right: 0; + margin-left: auto; +} + +.rtl li > ul, +.rtl li > ol, +.rtl blockquote > ul, +.rtl blockquote > ol { + margin-right: 1.3333em; + margin-left: auto; +} + +.rtl blockquote { + border-width: 0 4px 0 0; + margin-right: -1.0909em; + margin-left: auto; + padding-right: 0.9091em; + padding-left: 0; +} + +.rtl blockquote > blockquote { + margin-right: 0; + margin-left: auto; +} + +.rtl .main-navigation ul ul { + margin-right: 1em; + margin-left: auto; +} + +.rtl .main-navigation .menu-item-has-children > a { + padding-right: 0; + padding-left: 48px; +} + +.rtl .secondary-toggle { + right: auto; + left: 7.6897%; +} + +.rtl .image-navigation .nav-previous, +.rtl .comment-navigation .nav-previous { + float: right; +} + +.rtl .image-navigation .nav-next, +.rtl .comment-navigation .nav-next { + float: left; + text-align: left; +} + +.rtl blockquote.alignright, +.rtl .wp-caption.alignright, +.rtl img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; +} + +.rtl blockquote.alignleft, +.rtl .wp-caption.alignleft, +.rtl img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; +} + +.rtl .widget blockquote { + margin-right: -1.2632em; + margin-left: auto; + padding-right: 1.0526em; + padding-left: 0; +} + +.rtl .widget blockquote > blockquote { + margin-right: 0; + margin-left: auto; +} + +.rtl .widget_categories .children, +.rtl .widget_nav_menu .sub-menu, +.rtl .widget_pages .children { + margin: 0.7188em 1em 0 0; +} + +.rtl .page-links a, +.rtl .page-links > span { + margin: 0 0 0.25em 0.25em; +} + +.rtl .author-info .avatar { + margin: 0 0 1.6842em 1.6842em; +} + +.rtl .page-header { + border-width: 0 7px 0 0; +} + +.rtl .page-title, +.rtl .taxonomy-description { + margin-right: -7px; + margin-left: auto; +} + +.rtl .comment-list .children > li { + padding-right: 1.4737em; + padding-left: 0; +} + +.rtl .comment-author { + padding-right: 4.6315em; + padding-left: 0; +} + +.rtl .comment-author .avatar { + right: 0; + left: auto; +} + +.rtl .comment-content ul, +.rtl .comment-content ol { + margin-right: 0; + margin-left: auto; +} + +.rtl .comment-content li > ul, +.rtl .comment-content li > ol, +.rtl .comment-content blockquote > ul, +.rtl .comment-content blockquote > ol { + margin-right: 1.3333em; + margin-left: auto; +} + +.rtl .comment-metadata { + padding-right: 5.5em; + padding-left: 0; +} + +.rtl .bypostauthor > article .fn:after { + right: 6px; + left: auto; +} diff --git a/backend/wp-content/themes/twentyfifteen/css/ie7.css b/backend/wp-content/themes/twentyfifteen/css/ie7.css new file mode 100644 index 0000000..6f8cd43 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/css/ie7.css @@ -0,0 +1,89 @@ +/* +Theme Name: Twenty Fifteen +Description: IE7 specific style. +*/ + +.screen-reader-text { + clip: rect(1px 1px 1px 1px); +} + +.secondary-toggle { + color: #333; + font-size: 16px; + line-height: 60px; + width: auto; +} + +.pagination .prev, +.pagination .next { + font-size: 16px; + font-weight: 700; + line-height: 64px; + padding: 0 19px; + width: auto; +} + +.image-navigation, +.comment-navigation { + width: 662px; +} + +.post-navigation { + text-align: left; +} + +.site-main { + text-align: center; +} + +.hentry { + margin-bottom: 7.6923%; + text-align: left; + width: 808px; +} + +.page-header { + margin-bottom: 7.6923%; + text-align: left; +} + +.comments-area { + text-align: left; +} + +.comment-list, +.comment-navigation { + margin-bottom: 1.6471em; +} + +.gallery-columns-2 .gallery-item { + max-width: 48%; +} + +.gallery-columns-3 .gallery-item { + max-width: 31%; +} + +.gallery-columns-4 .gallery-item { + max-width: 22%; +} + +.gallery-columns-5 .gallery-item { + max-width: 17%; +} + +.gallery-columns-6 .gallery-item { + max-width: 13.5%; +} + +.gallery-columns-7 .gallery-item { + max-width: 11%; +} + +.gallery-columns-8 .gallery-item { + max-width: 9.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 8%; +} diff --git a/backend/wp-content/themes/twentyfifteen/footer.php b/backend/wp-content/themes/twentyfifteen/footer.php new file mode 100644 index 0000000..6447da0 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/footer.php @@ -0,0 +1,41 @@ + + + + +
      +
      + + ' ); + } + ?> + + + +
      +
      + + + + + + + diff --git a/backend/wp-content/themes/twentyfifteen/functions.php b/backend/wp-content/themes/twentyfifteen/functions.php new file mode 100644 index 0000000..b616192 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/functions.php @@ -0,0 +1,427 @@ + tag in the document head, and expect WordPress to + * provide it for us. + */ + add_theme_support( 'title-tag' ); + + /* + * Enable support for Post Thumbnails on posts and pages. + * + * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails + */ + add_theme_support( 'post-thumbnails' ); + set_post_thumbnail_size( 825, 510, true ); + + // This theme uses wp_nav_menu() in two locations. + register_nav_menus( array( + 'primary' => __( 'Primary Menu', 'twentyfifteen' ), + 'social' => __( 'Social Links Menu', 'twentyfifteen' ), + ) ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( 'html5', array( + 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' + ) ); + + /* + * Enable support for Post Formats. + * + * See: https://codex.wordpress.org/Post_Formats + */ + add_theme_support( 'post-formats', array( + 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat' + ) ); + + /* + * Enable support for custom logo. + * + * @since Twenty Fifteen 1.5 + */ + add_theme_support( 'custom-logo', array( + 'height' => 248, + 'width' => 248, + 'flex-height' => true, + ) ); + + $color_scheme = twentyfifteen_get_color_scheme(); + $default_color = trim( $color_scheme[0], '#' ); + + // Setup the WordPress core custom background feature. + + /** + * Filter Twenty Fifteen custom-header support arguments. + * + * @since Twenty Fifteen 1.0 + * + * @param array $args { + * An array of custom-header support arguments. + * + * @type string $default-color Default color of the header. + * @type string $default-attachment Default attachment of the header. + * } + */ + add_theme_support( 'custom-background', apply_filters( 'twentyfifteen_custom_background_args', array( + 'default-color' => $default_color, + 'default-attachment' => 'fixed', + ) ) ); + + /* + * This theme styles the visual editor to resemble the theme style, + * specifically font, colors, icons, and column width. + */ + add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentyfifteen_fonts_url() ) ); + + // Indicate widget sidebars can use selective refresh in the Customizer. + add_theme_support( 'customize-selective-refresh-widgets' ); +} +endif; // twentyfifteen_setup +add_action( 'after_setup_theme', 'twentyfifteen_setup' ); + +/** + * Register widget area. + * + * @since Twenty Fifteen 1.0 + * + * @link https://codex.wordpress.org/Function_Reference/register_sidebar + */ +function twentyfifteen_widgets_init() { + register_sidebar( array( + 'name' => __( 'Widget Area', 'twentyfifteen' ), + 'id' => 'sidebar-1', + 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ), + 'before_widget' => '', + 'before_title' => '

      ', + 'after_title' => '

      ', + ) ); +} +add_action( 'widgets_init', 'twentyfifteen_widgets_init' ); + +if ( ! function_exists( 'twentyfifteen_fonts_url' ) ) : +/** + * Register Google fonts for Twenty Fifteen. + * + * @since Twenty Fifteen 1.0 + * + * @return string Google fonts URL for the theme. + */ +function twentyfifteen_fonts_url() { + $fonts_url = ''; + $fonts = array(); + $subsets = 'latin,latin-ext'; + + /* + * Translators: If there are characters in your language that are not supported + * by Noto Sans, translate this to 'off'. Do not translate into your own language. + */ + if ( 'off' !== _x( 'on', 'Noto Sans font: on or off', 'twentyfifteen' ) ) { + $fonts[] = 'Noto Sans:400italic,700italic,400,700'; + } + + /* + * Translators: If there are characters in your language that are not supported + * by Noto Serif, translate this to 'off'. Do not translate into your own language. + */ + if ( 'off' !== _x( 'on', 'Noto Serif font: on or off', 'twentyfifteen' ) ) { + $fonts[] = 'Noto Serif:400italic,700italic,400,700'; + } + + /* + * Translators: If there are characters in your language that are not supported + * by Inconsolata, translate this to 'off'. Do not translate into your own language. + */ + if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentyfifteen' ) ) { + $fonts[] = 'Inconsolata:400,700'; + } + + /* + * Translators: To add an additional character subset specific to your language, + * translate this to 'greek', 'cyrillic', 'devanagari' or 'vietnamese'. Do not translate into your own language. + */ + $subset = _x( 'no-subset', 'Add new subset (greek, cyrillic, devanagari, vietnamese)', 'twentyfifteen' ); + + if ( 'cyrillic' == $subset ) { + $subsets .= ',cyrillic,cyrillic-ext'; + } elseif ( 'greek' == $subset ) { + $subsets .= ',greek,greek-ext'; + } elseif ( 'devanagari' == $subset ) { + $subsets .= ',devanagari'; + } elseif ( 'vietnamese' == $subset ) { + $subsets .= ',vietnamese'; + } + + if ( $fonts ) { + $fonts_url = add_query_arg( array( + 'family' => urlencode( implode( '|', $fonts ) ), + 'subset' => urlencode( $subsets ), + ), 'https://fonts.googleapis.com/css' ); + } + + return $fonts_url; +} +endif; + +/** + * JavaScript Detection. + * + * Adds a `js` class to the root `` element when JavaScript is detected. + * + * @since Twenty Fifteen 1.1 + */ +function twentyfifteen_javascript_detection() { + echo "\n"; +} +add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 ); + +/** + * Enqueue scripts and styles. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_scripts() { + // Add custom fonts, used in the main stylesheet. + wp_enqueue_style( 'twentyfifteen-fonts', twentyfifteen_fonts_url(), array(), null ); + + // Add Genericons, used in the main stylesheet. + wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.2' ); + + // Load our main stylesheet. + wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri() ); + + // Load the Internet Explorer specific stylesheet. + wp_enqueue_style( 'twentyfifteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfifteen-style' ), '20141010' ); + wp_style_add_data( 'twentyfifteen-ie', 'conditional', 'lt IE 9' ); + + // Load the Internet Explorer 7 specific stylesheet. + wp_enqueue_style( 'twentyfifteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentyfifteen-style' ), '20141010' ); + wp_style_add_data( 'twentyfifteen-ie7', 'conditional', 'lt IE 8' ); + + wp_enqueue_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141010', true ); + + if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { + wp_enqueue_script( 'comment-reply' ); + } + + if ( is_singular() && wp_attachment_is_image() ) { + wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141010' ); + } + + wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true ); + wp_localize_script( 'twentyfifteen-script', 'screenReaderText', array( + 'expand' => '' . __( 'expand child menu', 'twentyfifteen' ) . '', + 'collapse' => '' . __( 'collapse child menu', 'twentyfifteen' ) . '', + ) ); +} +add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' ); + +/** + * Add preconnect for Google Fonts. + * + * @since Twenty Fifteen 1.7 + * + * @param array $urls URLs to print for resource hints. + * @param string $relation_type The relation type the URLs are printed. + * @return array URLs to print for resource hints. + */ +function twentyfifteen_resource_hints( $urls, $relation_type ) { + if ( wp_style_is( 'twentyfifteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) { + if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { + $urls[] = array( + 'href' => 'https://fonts.gstatic.com', + 'crossorigin', + ); + } else { + $urls[] = 'https://fonts.gstatic.com'; + } + } + + return $urls; +} +add_filter( 'wp_resource_hints', 'twentyfifteen_resource_hints', 10, 2 ); + +/** + * Add featured image as background image to post navigation elements. + * + * @since Twenty Fifteen 1.0 + * + * @see wp_add_inline_style() + */ +function twentyfifteen_post_nav_background() { + if ( ! is_single() ) { + return; + } + + $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); + $next = get_adjacent_post( false, '', false ); + $css = ''; + + if ( is_attachment() && 'attachment' == $previous->post_type ) { + return; + } + + if ( $previous && has_post_thumbnail( $previous->ID ) ) { + $prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'post-thumbnail' ); + $css .= ' + .post-navigation .nav-previous { background-image: url(' . esc_url( $prevthumb[0] ) . '); } + .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; } + .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); } + '; + } + + if ( $next && has_post_thumbnail( $next->ID ) ) { + $nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'post-thumbnail' ); + $css .= ' + .post-navigation .nav-next { background-image: url(' . esc_url( $nextthumb[0] ) . '); border-top: 0; } + .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; } + .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); } + '; + } + + wp_add_inline_style( 'twentyfifteen-style', $css ); +} +add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' ); + +/** + * Display descriptions in main navigation. + * + * @since Twenty Fifteen 1.0 + * + * @param string $item_output The menu item output. + * @param WP_Post $item Menu item object. + * @param int $depth Depth of the menu. + * @param array $args wp_nav_menu() arguments. + * @return string Menu item with possible description. + */ +function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { + if ( 'primary' == $args->theme_location && $item->description ) { + $item_output = str_replace( $args->link_after . '', '' . $args->link_after . '', $item_output ); + } + + return $item_output; +} +add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 ); + +/** + * Add a `screen-reader-text` class to the search form's submit button. + * + * @since Twenty Fifteen 1.0 + * + * @param string $html Search form HTML. + * @return string Modified search form HTML. + */ +function twentyfifteen_search_form_modify( $html ) { + return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html ); +} +add_filter( 'get_search_form', 'twentyfifteen_search_form_modify' ); + +/** + * Modifies tag cloud widget arguments to display all tags in the same font size + * and use list format for better accessibility. + * + * @since Twenty Fifteen 1.9 + * + * @param array $args Arguments for tag cloud widget. + * @return array The filtered arguments for tag cloud widget. + */ +function twentyfifteen_widget_tag_cloud_args( $args ) { + $args['largest'] = 22; + $args['smallest'] = 8; + $args['unit'] = 'pt'; + $args['format'] = 'list'; + + return $args; +} +add_filter( 'widget_tag_cloud_args', 'twentyfifteen_widget_tag_cloud_args' ); + + +/** + * Implement the Custom Header feature. + * + * @since Twenty Fifteen 1.0 + */ +require get_template_directory() . '/inc/custom-header.php'; + +/** + * Custom template tags for this theme. + * + * @since Twenty Fifteen 1.0 + */ +require get_template_directory() . '/inc/template-tags.php'; + +/** + * Customizer additions. + * + * @since Twenty Fifteen 1.0 + */ +require get_template_directory() . '/inc/customizer.php'; diff --git a/backend/wp-content/themes/twentyfifteen/genericons/COPYING.txt b/backend/wp-content/themes/twentyfifteen/genericons/COPYING.txt new file mode 100644 index 0000000..aece214 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/genericons/COPYING.txt @@ -0,0 +1,9 @@ +Genericons 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. + +The fonts are distributed 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. + +As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. + +This license does not convey any intellectual property rights to third party trademarks that may be included in the icon font; such marks remain subject to all rights and guidelines of use of their owner. \ No newline at end of file diff --git a/backend/wp-content/themes/twentyfifteen/genericons/Genericons.eot b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.eot new file mode 100644 index 0000000..b5f8647 Binary files /dev/null and b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.eot differ diff --git a/backend/wp-content/themes/twentyfifteen/genericons/Genericons.svg b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.svg new file mode 100644 index 0000000..f813110 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.svg @@ -0,0 +1,543 @@ + + + + + +Created by FontForge 20120731 at Fri Oct 3 09:39:07 2014 + By Joen +Created by Joen with FontForge 2.0 (http://fontforge.sf.net) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/themes/twentyfifteen/genericons/Genericons.ttf b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.ttf new file mode 100644 index 0000000..1f160dd Binary files /dev/null and b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.ttf differ diff --git a/backend/wp-content/themes/twentyfifteen/genericons/Genericons.woff b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.woff new file mode 100644 index 0000000..973e033 Binary files /dev/null and b/backend/wp-content/themes/twentyfifteen/genericons/Genericons.woff differ diff --git a/backend/wp-content/themes/twentyfifteen/genericons/LICENSE.txt b/backend/wp-content/themes/twentyfifteen/genericons/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/genericons/LICENSE.txt @@ -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. + + + Copyright (C) + + 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. + + , 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. diff --git a/backend/wp-content/themes/twentyfifteen/genericons/README.md b/backend/wp-content/themes/twentyfifteen/genericons/README.md new file mode 100644 index 0000000..faf8f60 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/genericons/README.md @@ -0,0 +1,152 @@ +## Genericons + +Genericons are vector icons embedded in a webfont designed to be clean and simple keeping with a generic aesthetic. + +Use genericons for instant HiDPI, to change icon colors on the fly, or even with CSS effects such as drop-shadows or gradients! + + +### Usage + +To use it, place the `font` folder in your stylesheet directory and enqueue the genericons.css file. Now you can create an icon like this: + +``` +.my-icon:before { + content: '\f101'; + font: normal 16px/1 'Genericons'; + display: inline-block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +``` + +This will output a comment icon before every element with the class "my-icon". The `content: '\f101';` part of this CSS is easily copied from the helper tool at http://genericons.com/, or `example.html` in the `font` directory. + +You can also use the bundled example.css if you'd rather insert the icons using HTML tags. + + +### Notes + +**Photoshop mockups** + +The `Genericons.ttf` file found in the `font` directory can be placed in your system fonts folder and used Photoshop or other graphics apps if you like. + +If you're using Genericons in your Photoshop mockups, please remember to delete the old version of the font from Font Book, and grab the new one from the zip file. This also affects using it in your webdesigns: if you have an old version of the font installed locally, that's the font that'll be used in your website as well, so if you're missing icons, check for old versions of the font on your system. + +**Pixel grid** + +Genericons has been designed for a 16x16px grid. That means it'll look sharp at font-size: 16px exactly. It'll also be crisp at multiples thereof, such as 32px or 64px. It'll look reasonably crisp at in-between font sizes such as 24px or 48px, but not quite as crisp as 16 or 32. Please don't set the font-size to 17px, though, that'll just look terrible blurry. + +**Antialiasing** + +If you keep intact the `-webkit-font-smoothing: antialiased;` and `-moz-osx-font-smoothing: grayscale;` CSS properties. That'll make the icons look their best possible, in Firefox and WebKit based browsers. + +**optimizeLegibility** + +Note: On Android browsers with version 4.2, 4.3, and probably later, Genericons will simply not show up if you're using the CSS property "text-rendering" set to "optimizeLegibility. + +**Updates** + +We don't often update icons, but do very carefully when we get good feedback suggesting improvements. Please be mindful if you upgrade, and check that the updated icons behave as you intended. + + +### Changelog + +**3.2** + +A number of new icons and a couple of quick updates. + +* New: Activity +* New: HTML anchor +* New: Bug +* New: Download +* New: Handset +* New: Microphone +* New: Minus +* New: Plus +* New: Move +* New: Rating stars, empty, half, full +* New: Shuffle +* New: video camera +* New: Spotify +* New: Twitch +* Update: Fixed geometry in Edit icon +* Update: Updated Foursquare icon + +Twitch and Spotify mark the last social icons that will be added to Genericons. +Future social icons will have to happen in a separate font. + +**3.1** + +Genericons is now generated using a commandline tool called FontCustom. This makes it far easier to add new icons to the font, but the switch means the download zip now has a different layout, fonts have different filenames, there's now no .otf font included (but the .ttf should suffice), and the font now has slightly different metrics. I've taken great care to ensure this new version should work as a drop-in replacement, but please be mindful and test carefully if you choose to upgrade. + +* Per feedback, the baked-in 16px width and height has been removed from the helper CSS. It wasn't really necessary (the glyph itself has these dimensions naturally), and it caused some headaches. +* Base64 encoding is now included by default in the helper CSS. This makes it drop-in easy to get Genericons working in Firefox even when using a CDN. +* Title attribute on website tool. +* New: Website. +* New: Ellipsis. +* New: Foursquare. +* New: X-post. +* New: Sitemap. +* New: Hierarchy. +* New: Paintbrush. +* Updated: Show and Hide icons were updated for clarity. + +**3.0.3** + +Bunch of updates mostly. + +* Two new icons, Dropbox and Fullscreen. +* Updates to all icons containing an exclamation mark. +* Updates to Image and Quote. +* Nicer "Share" icon. +* Bigger default Linkedin icon. + +**3.0.2** + +A slew of new stuff and updates. + +* Social icons: Skype, Digg, Reddit, Stumbleupon, Pocket. +* New generic icons: heart, lock and print. +* New editing icons: code, bold, italic, image +* New interaction icons: subscribe, unsubscribe, subscribed, reply all, reply, flag. +* The hyperlink icon has been updated to be clearer, chunkier. +* The "home" icon has been updated for style, size and clarity. +* The email icon has been updated for style and clarity, and to fit with the new subscribe icons. +* The document icon has been updated for style. +* The "pin" icon has been updated for style and clarity. +* The Twitter icon has been scaled down to fit with the other social icons. + +**3.0.1** + +Mostly maintenance. + +* Fixed an issue with the example page that showed an old "top" icon instead of the actual NEW "refresh" icon. +* Added inverse Google+ and Path. +* Replaced tabs with spaces in the helper CSS. +* Changed the Genericons.com copy/paste tool to serve span's instead of div's for casual icon insertion. It's being converted to "inline-block" anyway. + +**3.0** + +Mainly maintenance and a few new icons. + +* Fast forward, rewind, PollDaddy, Notice, Info, Help, Portfolio +* Updated the feed icon. It's a bit smaller now for consistency, the previous one was rather big. +* So, the previous version numbering, 2.09, wasn't very PHP version compare friendly. So from now on it'll be 3.0, 3.1 etc. Props Ipstenu. +* Genericons.com now has a mini release blog. +* The CSS has prettier formatting, props Konstantin Obenland. + +**2.09** + +Updated Facebook icon to new version. Updated Instagram logo to use new one-color version. Updated Google+ icon to use same radius as Instagram and Facebook. Added a bunch of new icons, cog, unapprove, cart, media player buttons, tablet, send to tablet. + +**2.06** + +Included Base64 encoded version. This is necessary for Genericons to work with CDNs in Firefox. Firefox blocks fonts linked from a different domain. A CDN (typically s.example.com) usually puts the font on a subdomain, and is hence blocked in Firefox. + +**2.05** + +Added a bunch of new icons, including upload to cloud, download to cloud, many more. + +**2.0** + +Initial public release diff --git a/backend/wp-content/themes/twentyfifteen/genericons/genericons.css b/backend/wp-content/themes/twentyfifteen/genericons/genericons.css new file mode 100644 index 0000000..36f02a3 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/genericons/genericons.css @@ -0,0 +1,209 @@ +/** + + Genericons + +*/ + + +/* IE8 and below use EOT and allow cross-site embedding. + IE9 uses WOFF which is base64 encoded to allow cross-site embedding. + So unfortunately, IE9 will throw a console error, but it'll still work. + When the font is base64 encoded, cross-site embedding works in Firefox */ + +@font-face { + font-family: 'Genericons'; + src: url('Genericons.eot'); +} + +@font-face { + font-family: 'Genericons'; + src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAADgYAA0AAAAAWDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAA3/AAAABoAAAAcbOWpBk9TLzIAAAGUAAAARQAAAGBVb3cYY21hcAAAAngAAACUAAABqq7WqvhjdnQgAAADDAAAAAQAAAAEAEQFEWdhc3AAADf0AAAACAAAAAj//wADZ2x5ZgAABEAAADAqAABJ0A3bTddoZWFkAAABMAAAACkAAAA2B8ZTM2hoZWEAAAFcAAAAGAAAACQQuQgFaG10eAAAAdwAAACZAAABNGKqU2Vsb2NhAAADEAAAAS4AAAEuB9f1Nm1heHAAAAF0AAAAIAAAACAA6AEZbmFtZQAANGwAAAFRAAAChXCWuFJwb3N0AAA1wAAAAjEAAAXmlxz2knjaY2BkYGAA4rplZ/Tj+W2+MnBzMIDAhRBmaWSag4EDQjGBKADj7gZyAAAAeNpjYGRg4GAAgh1gEsRmZEAFLAAWNADXAAEAAACWAOgAEAAAAAAAAgAAAAEAAQAAAEAALgAAAAB42mNg4WBg/MLAysDAasw6k4GBUQ5CM19nSGMSYmBgYmDjZIADAQSTISDNNYXhwEeGr+IcIO4ODogwI5ISBQZGAOtvCU0AAAB42kVPuxXCQAyTL+GRmmVoKdgA6FNRMoObdAyRnj3o6NkGLOl4+N75I381AUeUTPoNASSyoWVUBMYUYkmt/KOQVdG79IceFtwj8QpN4JxI+vL4LrYUTlL294GNerLNcGfiRMu6gfhOGMbSzTOz30lv9SbvMoe+TRfHFld08b4wQ/Mhk6ocD8rtKzrHrV/49A34cy/9BURAKJ4AAAB42t2NPw8BQRTEZ+/E2Xi7NlHIJsI1hGgodVqdVqfVqZRqH8QXvL25eq0/USh8AL/kzWReJhkAOV43hMKDW0rqmVu4Jh/BpY+tdNDBh2ndoabnnGtuueeR52YQI1AhILhQ1iDoWHLJDXc88NQgxl5ujS2sMjNZyUImMhYvfTFSdC/v3R+oNj4llSXJvgv4e+6zoCcQAEQFEQAAACwALAAsAFoAhADMAPIBAAEcAUYBlAHOAggCsgNMA6QD4AQSBMIFXAWoBgQGdgcIByoHageOB8gIJgkeCn4LOgvIDH4Myg2YDeoOLA5oDtIO9A8QDy4PeA+aD+AQNhCgEN4RFBFSEZwR9hJgEoISpBLuEwwTKBNEE3ITihPOFAYUWBSYFMgU3BT4FT4VTBViFaAVzhY6FmYWlhaoFsIW2hbuFwQXEhcgFzYXlBfEGAIYNhh4GLIY2hj8GSoZhBnAGfAaBhoUGioaQBpOGn4awBr4GyobgBuWG6wb3hwCHCwccByqHOgdFh02HWodmh3MHgQeHh5GHowfpB/OH9wf6B/2IAQgWCCOIOYhdiGuIfAiciKOIrQi6CL2IyojRCN2I5QjviQIJJAkxCToAAB42oV8CWBU1dX/PW+dyT57Mkkms2RmAkkmyazZCEPYE3ZCWALKJkhYI7IorT4XFERwQdEiAtaK1l0roMUln3WtSktBPltrP7CLyx9b21o/hczlf+59MyGA+jF579333n3vbuf+zu+cex5EICMIERbK04hIVBJ6BkhN87OqRL4IP6PIf2x+VhQwSZ4R2WWZXX5WVaCv+Vlg1yMmj8nvMXlGCG5aDvfSy+Vppx8bIb1HCFEEIhCFyBp/bzbJJxbiIAQ8No9s88TkmMcGuPkxbcKjQCTSRwQtpYkESErDFDmLj8pa+t9Zwg8UNyIA5lHxh++1YFluyVwgSO5yocBMwvFowKtYxRr4Kcw7fJjuoZfQPYcPw1vHduw4tkMl567MYzn6Du9gNwgWr4GmaoqGr3WQYjIY6yqz5lk8JNwiREOCN0+wukC0yTESdoHNmif4vCGIxmVNIN9iY/FAHzqwb/3o0ev36YezZ4nw8ye3d0amrRs2fXtnJzamTxM1DcgZrT8TO4jfzk3upb2d26cPWzct0rn9ye2sPgIxDOw/7DuTB7BKbGM/Cd/Vp/UREXsFMAWajHuBAJ5Tvmcb9g+wawprm0CIUcC+1s7gWQp/eI8/h32ZixmtimqSTSGIReNuu6zd1nOW9Nx2ElpOytqG1ytSn2rCvRWvb9hz8iQfA3xKYWPAxhXrY80Dnykcj8G5pAdwTDef2tK9Q8gkKNaajfOWU5uB7OgekCQCqyevSxGJsnG120xYo1g8ZmKDiicOG9bNFHVg/+MddwDTLZCwsVv2MMsWFA9B1qHuzmTP7p5kZ3dvZ/ch+vWhus4GfkElhzZSbd7uwD2NHaBN7OmZSLWOxnsCu+eBtvEEHqi28dChjaAl10wvwjyU5wHMw3qO9KqsbgXEh+0N87pVggk8CQ9rtH7BhyPk87J6xSOK1r1jR7dGk3S/Blv2nKT8HE+TPKFgk9klmoRe7eQeQTt3uqMbMEVEyIybjKW6mASw8sDFxikYj0WDmCzAZIsQiwaCLDcfe03Kjzc1xWe1t0PBjAULZnTVtPonjpbx9hnchIL4rbtujc1q7+7G+zM/p32fz+yq6blx1OWHRmMR2M6oASWPrOMzyyWYbVZBkVQlgELBimlRsOAWIRAMQZ6gBoKKGhLzIQ9wcjgUm9UlOxQ1TwhBMCQFB+N1u8MlOVxKwmq32qxKMFAewNqaWwRxDdgh68RLN7YteYHSe30+CLpiMxeMH1tbskQxGvMtUl64eUHiqptvvioxf2goK6sg32CUlpTUjpkwf2YsmmsPjR46yikYS73xUimnyGhyisZSpzcXFIc7MWp+M/h899DUC0vabnzphIGwPf16y8P0rTOvhFV3ofSrKcPnOhVLeXjC/E1T916RXzHm0joQZXOd3wvg9deZFEGomNSQKMlevWfK5vkTwn6zEurKypMLYtVSrq+4UFCznWZQCl31Hil3kGtwXpapfGJdVqFbibx8Bhoe3sIbh53IgIoQ3qcGYiKliC1hkiSTCPGHE4KoENXuj5sT5bILzIgrZkecJALBHGDd6xIccckhAMtUnhAsXsVnt7RIiUAVuCWCsEcQ9wgDPonsP+R56k90U/cH4phd7xbSU/RYXmPX6fuvXPZjePyTgiT9G+2Rl4w+8L/N9tKg8iiMu9p5pvFV+s+aV+GrW7Y+4dbci36t7B2/Zcmga+hBehXsgg1g+dnP6Bd0I12I2xc/+xlYtElQBTe20SNv9u5dBh29oVDxvfTXwubkw/Q369+D+PharTMMHzRc2u0qjXTkeJRiKIV/T6OHjtvHhMAJ8YJ9dJ/Q6G5pLb/mTu2Cl2OBvFDWXYB4XIV4/BFpwBNFtSPgSpLP7bdHwjjlUbwwgYchKF8MrxJ2yYES2iJEwnZHPJEHalzV2pcL1bO0p39L6TZ6mJ6tqpr24B1D173k87vraq99ZMKM9hnhW+CWj7MaF2xqn7Al8uNl1o6GFUrtqgnFtiXH3jt0/+phD8mBUXXitpVqbtE7N8qVYvinlyzofPSd7EGVbZsWNA5JFCWTS7y5en0J6g9VI8F+dPAhSls8Q1BHRByJgA8VSCnCIirN8wCC/g3ycujfKlv3yeOXXHLnjCpKU1XshoqIcIYgdL4JUm9OcwL+lRW/dM2IU7Qv1bCjW8Y7HNuxXPkTLNfN8EFkioGVEW2RsCfKQPTyckVpN4zNp2/Q3j/9yVE95pJr2hLdTqc6Z2FF1GmUvqFH+g6KY6EGhOjc6WPipYoo0r+Z/NVeUTASRJ9M2yyIzB6ykKzg2GA3s0HxeXFGF5jjgJILCoRRdrPBbgFLPNEixqIMCAwIHZGwI1Du80qKGo6E40MhbldURQWLiDgSd9jPXfPjUKti3ByLim2wDMZ9uW3Y6n2vfXr1Afrcl9u2fUn/ePo9eu0oMXDL9ZLwzb9W/Rl8kwSpIM+iOgqt4JDNcp6kChMawbiCfnbfLfTs4THFRf5lPq/NkmetqgX/09d0WPOt1o0TA0t9PrxoqxR88pCvD/5B1fDtzx24+tPX9q0etu1LGMdLT+WdohsWSqX399WEZEV4ODXMI+3t2w05Sk5d3ahIYWhmzCv4De7skvxCW3ZDJyxc1fXgClkQocwrykLfPYIJZqiC1w1ZmYtqReXNO1MN3bD6w8NM1lHXk2t5/+YjykfIUhxJnOhe1cRknGEqWLAbAy3gcIkOuwKsh1CIgngB0VUBNuRIrJhocbFDnA4JQW9IxX5PcNCOJDxehZ1GPCibQrN5rOXgPde86/S4nWWeH79ty6u/enJzz/Qh2TYNclRIPTftpqLGD7Qp4yyjfPFSj1XsRQJ2ls9KprZk2RLtaoNgTqDAnW821LT/YubUvTenHrj2r5N0yRQaYSr89VqxpcHTXA5TpN/uXvLUPFFIdt8+aW9vKubxCPZFk6ZdLkBhbm1hRWkwKBcASRfRh8+X2Mcuumx2fWlWaUGJtdBmjI5uuvX5Vc/Xbps/dRibG1w3IrAqLyE/MpM6nR0FmeplooaqCCkIXoqyaQcqEgSPOeixtSh4T7AJc+gBaHtImHzZ4qmJjiqo6pQL6MHJnZWjB+dm04OSBGOzbW5PTaS1fMrmxQ1AxP+5ef7YtnnV4+tqx4fO7BTMS9b5I+7ieOq/xevnbDWV+IqLLdmJpU+s5GOppcfSgnOyeQAapKc940oWpAwh8CGpsdrxAq+moMY89gKbirVOcByzmXSEYCCAlMBBv71hxGSY1Dp8yuRhUtPDm8KT670F9BsAMBiyvA3ekcMykKEPwmkiFvV9Im6c2Ng8fkJT48S+DfDmUweKKoOFqzx09f4DcKjS5hxUemkHnYGd+RgqqsmooyaxGrskfWoHggLO0mAgYQkJvGcZDmN/svlqZlKG9casSMjUPPYXZNlaZKlu7e+f3DY3Wj31qh0HFi54yju2wDvnbrX0p1KefeuiqTMCzXmOqxeueWH+yBve+vGcx25eMTY41ayqolVQffZpaxPl45bd84s/G0hi/qa9++ds+PiVXcub5yTpR/UbtscfuVp42uhZEr310NIpke3/1bDg9ueh7sDlz1zXFpq86qZ7J9093+YszJmYVWgy+u56cdX43fdtXT89rOuUjB5ekOE2BUKegM0MxhMWFzDNwhol6o2yO+wIYZCIB4JpzYKiw5gt0v4Ep1xMtjBfGWAnOQLkQl6T5hx3bWsvGVOydfJVv7l9ctMVu95bvfbI7msmDupebC6RBZMgy3kjRmu9PZc92F0/acclsQ5/Tnada/Tw+KxYgcHYY3HI++mpXQNZDP2cfs3eP3j9AnDG2pceAvHurifuWplMXPKj2+9uu+XoYEOexZDMstpME6+a9+zNk5uX3DZt+zd3x7piNbvWDW6dPuLq9srJFgv1T52/eSI4YO3hfrIikL3CXHWuvBcnVz7n4AXIswvK00fZCjO++oo+8lXqynRC3sv2X6XP8KjrbsK5shdPJBFtBR9qkiAKC9LWBP4sZocZoQ1TeMmsbABrQQ4aZnem7l+2wjt5tvWqjo3XPT3zSF3U2jy2vmeVoWBTcuSNKjHQh2iKDqGDoAxuuwbKOpZdufpeg5X+lj4/kf7z6adn31sKT7A2ZGy5fMSGi+afUVAImjB7+vgeuNWpIAOn/FzAfR9n0gTgA6IpFTiXvbqFg+iKgMtA2YSKCsWGkeCYyRfjjUpIw+HndLqpoLp53KabV8+Zs2zDpZcMb42+0d3eHqo2qRptop/Q6K6qKmf5DPq3uN1eVtbQeN0GYU3Kl0zOmrklowsy+OEg1WTIxfUnbqXA7o4XYI34bHRz/oN1syO4x00ol5WoPkrBam+CcHwghIhl9NWTzJxDM+Hv5s2n6OenNpvp39tjMom1t8e09O58FKHkpP5U30mRjGpEYw3tuKaRKfaItD/zTDufWmcBVFDOkm3kTrKD/ITcTx4gD5FHmGWJTbDVKuzPqtSh/aLUKaqV7RQbAxTsTiUfQPEGobYGAsHaQCygd28gGA3yGRiI4cUodkGsNh6L10VZn8fCCX7Uf0OhNgHxsANq7XW19ojd0f+zsa2W/Vkd1jo7mOSEERx+2ZYAk1/1J4KqEYKyP6aqOOr8n4B/QnqPh1SrqcKUagURUJxFdlWA8/4J0J8Z1bzwMmYXXgYB+t+RfhHgq8D1SWpd6swn4Eq98RDcTT/+RBj92WefQaUgf0I/Fhofkv4lS7RaUAWQ2DOsUIEVmX4Dvh9odXYOHGWvT9dU5PfxAPgQPijBUUkWQAYBT9nGHuMvYPuj2dm0Ot1CUX8jK4NlwydgIn3vlZ0wgz6y85W9f1yRehmir9w3YdeuXZiasfOVB/644nxZtaCee5l8wmQVWWEB2otubua1IClH01FA/eCwSwmcMlw/IKYisA4FhqmYA21CC2eDCiP1iKy10TrGd8rZJf5onIFwCBT9gnAOmJHmBLji4dmYWYBvYzfZOVNKIhquQY7XyJ3wlD2RPhUgXJ7QqRJ7JWK4hGUGA+ZEHK8nFElBuDfbJYkcYCyUkUN6FyOhnI8e3U2PL1++0Gra96P14N4wtn3lu3dNL0+GsEeNIgz72WuLHwTXPLf/cvrh7eLgwZ1brlzbMWvuU9e0Z3d3LKJfLb9ySEuWYefyFf/T1OJoD23cFOu02CIFVbHSqlmBQNRgMBcVVIaLndFqc7FDVirLKmpCY3LRJjTa7CMDgVFWm2w2Fnsr7JVdHq9fFDo3tkam1eTYzJMWra0vHxYxFRvNjg2PdEy/fRrdcAo2LWqavuPt1eNvmOeMj1m9ih58+GH62ei23OkzoPpZk/k++tnba6/7EEI6B9abyShwmg3fY1izcin9/d13nR07Jq/BNmP7u6tGbVoTxrZmCdC+rOnWDZHqa+5OZQ2/qX71YF+Jt/2ap+YKS19pGW9talmy9Efrf+XyTJnT9XF7pNoaHDJ33rTiyjI1O8/hGD1ocIfH4bEIQo7TXNzm97eYkN7WVwpQNrbU5RGg0ufrCFo9TotkLCpzz6wdtjRkyhl5ycpYtKPaYM+rGVKe2NA88apYfs7yB/tu/ubdm25cc+S+pVb38q2T76FPrt+wqtT5P3t2wfKf3Pc7lyTk3PIB/dPuffR3H17fL78G1FQkm3SRK8mtun+SkekYkmlQfZwGodgwz18ZuGR2hjIsMslG6ybBU0osLdcopR6IhlCKOOnkHAJ5khhPcwrGQ60utMviiDIZtqtR+z13FroSbmehu7nK77AUOiyWaZ7yeKk7N7z4jnfWLHx47ZSgoaA0mPBGNtzaNsSSV5yFU1xQwNBomnXP3Nj4sfeDAew5ZeXDWiIWn2XY2urC8mGV3j8f+tmBl5oc4REL6l0tcUu0oCw8tLO2aoakZZi8QKZZSpJDLomEZ7a0Bkrt9praSkt+a4k7UT1kZHD4dT2dYf/QznkxeygSCddY3ZV2VSqyhKqcan52npovIXlJLrlhVMfDyetOz3NFwoMToXJRNucb8wfXTq65du9WcVFTT/TK1bMbLD5HcsWgWZdOG1Hhx7I3Im7E1evIIuxxF07qPDmExqcpz4AzmadcQjyB6tYlYj/HQ4ov6A3kYTZwiWWghiSc/C0i2kLybrVo7MgZI5qceWWVy1auW3X59KTZjGrEYLK6/dHS6IqOkWaLZ8Tw+gKoV6zJoTPGTxlalyWUt0zpmj11mMUiFUSi7aOmjh5TUlwkmpxFRuNJ1dE4qDR7zPCRjzz89E/v3TDbqQ4ScwaHp825YdvB+TM3T01Y5NxcVaH/T1DtDrfL5yrNNgtFrpxcKPRW5pVXi8+m/ibI2ZJsqR6+dOS467vaqrz5BoRYJb+wItJeXT138rjGqpzst43uJSseeuCN2ROuaHILeSVFWYTzr1uxb65EmRxErsPesavc0RxkIiahmmdMVERbmhk5KI7AvICBgT/Mw2xte5qo9N9HosV0rXWATrSmOUz/fVuG3sTVYREYf8P+hVctnzjuig+fR/ptGl7Xtf7uSVvXtY2a//JD21dPraKLmry+IU0dU5Z0utzlbktBNNE1v3Kwp8RRVBP1eYuc9fVTp63atmRZfUMi1jVj4+yWeq+npfXyCdWhQqfDVlJWFff64tHp6w78ZMUqsXXxFQv33zC+MW/Isl0v/GF1x7QrNk66e31XXXtO1dTV2x96ef4c+uuOy2cMaa4IFjsdFqPRnI/vCHnL3e6WkM1eXl4dCtcitXIGB41tm7toRGswUGI1mzyu8NDBVXabxxOrLSxCm659/LiaoaEQtweQ5RGF8dQoYyg4P3XrBvdKJbIuzrlCQiWYuFbiHc88/0hU0IpWNHuwyM629liSsSCaHHbl6FmDtd66FfOSoCKieWaOKjAYYG+sXSLFdeUGT1DfY+7u9oraCkG75IFvNsumak9Jx84p0/b6A+26ifIebFUj6mruLQySWjKUjEG7bDPWMo7V0octikQHxwqwlmmr117OzDOFnfnj3DxR7ajjWJJ7Xqx2CayOOHNFKcSrMJd51GLVfWuAGpvzyIydh/ksCGgOuQXtItYVaPUE/aLdwc5dIL2VP9iV3/nCoc581+D8+tvuoP9oDYWGDQuFWmHE7NbW2a2Cp7JhUHXZ1NSWx8D36KP0o8cepx89+ij4Uh9X1EwrrRrUKFfjQAyt3lcfyrvydfolPU6/fH1NQWll0dqpdVNLDv51tmw226ChcEpd25IlbTUT60R6evyfniqZFo7PjouGfFdlfmdnfqUrvx6UUCsW39qq70OhIWW1gxqCQ1KLu/cvXXagu/vA8QPdwn01JeOGlDcIHaGWUHUy9XSiqzhcd9kLGydO3Pj8ZWjPRob5pq6tDswzwtv27Bx5zKC6JXctqR4faqbX5MytCMVns/nJUFNFqSE+ksDxYA4uZsaLfDlIGIIKRF+K4N3msKmyJ2MzBmOOhH5Tmmz32701ALPvnzNSmx0HtWZEjfzmli1vSfcjLVJn754zZ/dsWHI/XpaOzLb7bSEvLZv1k5mxrh+POHLYU1PjgU82vfTKpqXV1x7p2jVr5s6u39WGjrHrRK8jW5tBuc4n5Rn7gS+Q6f4HtkSGfJetkzkg4UIjIeFQkOln1sbQUPhDoL3bT/9A/+Dvbg/AEtnUMKLBJKt8yeKIvnx2hK1RpPaxDPRD8PMHdkilPl+pRHSf4cvIDVv7168chBhFkzEnYTNCzCHcBj2pL+h2WC5YKKYFCyxP/VPIp9tTX0APvR2u2J36MvXlbrWVvksPQnnqBfDR5+m7EIUx9CP6sLiX/hHGQvTMt/S9xavpq9CyejFvu0DIWWUktt1FRvK2q6KAqpiZRCrkgW6xMWue8Uec32ztKGFGxsiMJZ1VMkuLe2094RaQ35jRaI3OlGXFWlTjOm2QVboub7A721qWX9ZcIZz0yk5LaoWtVP6301pa9pG1WBRcouSy0H8W+3zFMDTbXqCS+fMppS1Wq63CZhYMtKEgV5TVygrZ5qiqKqErf2Evc5v7DIqMclKY58wz7Mq1+rzFwWJPjoXjFFt7YmttA63ZAQtN5HsXltIrSRzrBJRavl7H1pHQmHUg1xEjQi/z7TGLF7OnNE2T0BxGZoQcISNLWLLC2FIO97IZIbPIKuFUSBFKxHe6GaApmEwRtobXzs5JZv2Ky2EZ8ad9xhnrgLmM9ZVVxCY8kywmNB5NYh24QH5x1aoX6Rn6MT3z0sqVL8Fda96/r6vrvvfX7KJf79wJWX+EwV30GZWsfEnPxLKj3YIPvnRmZdfO458f39m1k35N38LsEqGz6H93wST4gy4fWCfC13lNeO5lOGq3iqxXPawzpW6+UqwxL8DJPZLG14fp5yf3MM605yTrk3PtyibFpEr3PSJnjNhwszBnni5W3B5PjxcbKh8rLCKj0jmNmyZgZ7fH+rgFLeI+1etE5h9I4t6paGfYFNK0M5iNZUixvbA/4KSE3YdezHl+XVxkMGnEutSi5a+KjEclLHqJniaoDUfQICqBuh+qqoRlKaFIibrsSV4GYdahw81drd9ZY+lXIBhUrFFxTqgInsEqCW4H2qeHvqvyhOT013VgTEAxykYlaUIdN5zhacQmprdM2pNOR3Az/VBPZ549FyrAasyP39MASvQ87B7faPqY2Qvku5oCMT0ggc+PaTBNvVq9GtvjRoQDB6DB0CJAAtSAN5+vf6qQsIeHIuzCn4SyWamT5U2NQW+OtV745jmhbL+/O7C/0GwufC51Yn8A036hnufy15TmGUORKdKL+1MnnvP79xe1thbuF8owecDf3T83Oc4XkBLsOxVQS7MoiHK3ZEZ2R9BqQQRDDYXYh4aG6d4X0vMH6iFr58q+lesPf3V4PdsBNvgfKzN3cOrseuFeeCd9c/16kvG3p8viLb2gOJIuKg+sdkvMY5NN8I+LykyN6n+nQdDEldR0Ubn023O1MvA+FgfEe5SQCu6L6zfTfrAeotZvZwn/R3UUcm6FI/V/1IvrNwKVBqK8T3KxTqWIbtUstoJBW9AIcayKaATe8UZgnuU4mhpx7kQVOO9C/JThDJUX0q+Q93x1GVXg9GWQA4Mhxw9r6Nbxr3/w2jh6K1wx/vVly16fmCLMbXeSvjqPY6uMT1J50erVi+E0nF68enVfJVwJqydMnTKB3kq34hFe3aM/cFKIcXQ+r84sxsXHZx0Bb5CtJyms7kgrE8xiTUDQ4oBggjUEbYkM3vs5c8QGJXS+KZEiDzynnBQA5vKW3P3zXdsv6Vj2ejus+X3oujPkOo028mbd/b9vp7bwasB73bc9sow3raVn6Mk9yxBy4DlP0Z6Twgm6l7Vp4nbvlAlw5QfwMX8DvMEauDf1Lm/4191LeBNf7Zm7nIMxCAy09DgU7H/mxsP6GQGVUS8kNdpLezVI8h0k5QvONZYnvXbL1wXOf4eB9PWKSa2vt69XE5N8JybVC841lofJqJbWKxbEsxiLHrJVGmJ+fcVNZT3IsAqRSo70O3Mj534y0QFH07GnPQYINEwhOM+mAV/TwUfPofDMCEX7EXTxrzfFTRABj5mN8wYoRd6wgxjZfLXgH8jFoBJafpD6qf8gLRfGPfecdC09kPoMxtHnBAe0geBIfcawRecLGnZtFp/tCLxB5gRHra9pfUQTccIoDDApc7ineqGXJs/xY8YXjNyfYgT8M3kYi0jhT8TfaUzz8KRetmNVJRLvv16lF58zkDzGdIwCm90OHIoaQfWjPGIf9fZpNClqqSfmClNTe7W5ybkajMf0XAVL79OgF1vO7vXN5fdy2a00f8K3syE2ZkKoVOQ5jPYgDCVT/ElWFegdiDc5OLc5g+ZxMJ6oUO4zhVGNOQFPsiBQBT4zM45QzQLR11DazpLDdPdvj8A2mAwlb6w4S2Y/9AX9hO5/ctXeVfgnZ0JRfgvzD4tkxRv0L/QpesWRJ6Edir54aHafxvNx3U5krMdZ9RXsDSeP/3GhPuE2KU7RFmQW/VOzGDwW9d3KvOiVU7891bq42eHwCd9UrrpiVSX9Xz7vfh+lf4sIs0ZpcxK+5LTueun9UWPHjjp9hM8qiLE1ECwvs25iQ2yI6LyGoQLaLglub3IkQ1BD9PUwaLA7WOODakgQOI1SvCwajv66nf7q1ekPbW0EtAoCsS3jWfATbmi+tsOQV6//dCa7Dr6pC77ijZVQlB4/FupoArQm/PEhJ4UytjDz+LGFM9kFKA+X0lree3osG48Rq8xEiOWBl3F6nFZ2Nw8V83n7A8L4XOM0mQeGcQTXWKpn4qRVOG80dmRhYSntaobtVzNsYDFggjaxZ9WkNNl6jTazM4FsZPMC7lCYbOSRQj32EMFTZVgfi5rRhChgxRfYxXKuOWZOokvokkkzd8K+G1988UZ8s0qYNllzFG/APZOOrtkFWSnni2B4kQWqMTyby/BMPsGmEJIJHyQcMucl9IR2Qj4xN0Vgr9aLY4UyaiD9XIoU4WCx8WJHA/mG6BtwRyPTbSmuCgdwBgsZhO8I4qzOY35uhwkHkTWBeUAcHlMZChiP3jCh6MOf/yxon9aM8P/+4ZtPPTZ/vbyp/rJRf05plvfHTFr45Ap2TSnF809DqzaOfIb+o4qetm9+A8Rbd4GdTrj8jUdG4/OW90f98vI1h7eVgoI3aYrZJCK2VdJ4a9i01FhMY7qeDH9YJ7D2cUn0p3OcQfOkD5/rIzyQkCHNVCFpYH2mcjuzjM1yzg/SB3BI6fVLc3q+CPX0P7BdoxZYIz2UTqzqG46CwYbhn7t7enb3yA/QMsq8pHtSJ/Vjyzx2F8WHHuphWc7jJirnswxfeJjewJkp87g8NJXwCO3n5iMicfqqyIPzBk5Gwl7FdUr63RmmnNCZMknjjvmCoz8dWaszZV39yFzxeLgSQrMRybPPxPII+7jyGPgH6cBRFqOaUUM0qZsDfJ/EyrH7OAj8CdAfpPphn06MJU6bmUbS33qGW5QswJcROkbEicps0RJuz+rqMBpvgrQfi/uYuH9ywOKlqh7a2Lq2KvTiFXtOFkqE22U7yjwbD0WqL9twck9LK5+bmgqqnI41tlsZ/w6yiREMRIeylUERablyoL39s7Yj7bSBnoA3oa3ts/ZjbTP2niV75V3tR/EWjKEN4Ga3juFZW2rHXiAMkIHpLpnRKPVc/4t6RWS9Qtyn+Dv57/KTXNcIWHjMAxKBL6hlOkxn4b/05/IT1EItnTBdg+ncD4kT7HeKpj+Dcx7JLZJaiUynP2cRvjB9OrXIT3TSn+OznfAFt+WTCqsHY3RMQQJCRKo3haymV2a6WEBqk+T5GJYkWT6sixGzcS+BkMSfxhQ2JlO9/bERIlaPRbqiBIs8VLmPyyHgDMWq6fdQttkkzdxL8wRZ4+HexCiyymuMlDEJOEMEPaib8/gCdiJrysX2n48EUbJrUOckuCVIMvYe2xIRm2/geWSAPfh950I/mUplUn3ahYn+4PJMdPn3pHjXCNwPwn0ZrM4XrcpnkIXhmKw7ZPhe940wRwnznvXxaxILztHSs13EW2kc4e9n+BW44P0RpnBtvtiAcsQYM4ThXFEae5GWKZCzMuYFzJSJFh4zjM8VvJ+ZuGd1H0LGD85wpljHYqbP5fQRPFZBYQQwBIKIz/AG8UMfDvJNn91xltzx2U0KBw7uCdePqXfupf/5RSn9N+SW/gKyGU0k+rxX0lYcw+c0ADC0GggCLuhHAQmrx8KaAeWGtxYbpwdTK8qhjVUdo0t1UBCwajp2AXPbMD2CB7d74yFHpSuNEeewp7wfe/R6fF/p6ShNkqmDPqznl8zhSIfO7yhT4N9CMF5l5B48E1va8qhcXyMQI0bgpGWR+8z+ZO6I1B9mCQE6S2AjRHHecY8cKvB9/MZ5Pqx8piZKeXAK7nwx/l0AMKjFPGcZy2bDcpWaYrORvZvF1+nzNj3mJj7iTEM0IatNSzOrWyCa4BaLwk2LZEZ0+4gYDof7DjN/FBMlTZfnM1ha4s4EszQFRMs96lx1LqniKyuqX1EtapARxaAlEJSDzH5MBBNyPCEmHIjKCYdod/gdqh3Hmgu3PazObaS/qWm2b3l7qLPl7S22plr6m8ZPDYZPG6Gutsm25e1h1mFv32pvqoU6dplu4vArnLrV3lxzLqf+gtzsJL6huUbP+qn+4lvfwheXcewmF/gYrGjPn/dVCXAnvwpxv5Ux4AQoF35fIoU3n9qyaYNwaEwf4anUyDEXfWySOrzl1OYxqZEbNrGjcGjDRfyh+JxeKc/YFQiobPaz6S7r3CGlHxgLQhgmTGgklB79qj6532E6mM3uc7Ki8yiTzhLZ1Yyql4kO1Yxb93MunpN9laN/mdP/vUcG5/VwKBFvnmbFkwzeD1h/yORFMmRh4ql/Y6OXmOIKov/bFDLg2xQsLf1tigg8eN7wvZhLBmCu7gRPY10adLFzDAiAp/UZi/tvMqDLqypyPGLvV9C6YpjLMdV4XjGe9G9AcUIaXIX+IoFXG6d+pmj+lQ/2v6hliseHsN2s9f3VuFDuLBfKnZRZpIux+N4IMrcL5U5YrKP9Xtqr7b1I4MK8mL52Bi00rcfOK8/x3V9PMc560RdUqYG89YKCzhw+z448r4zId5ehr1zjrHLw5WoGtOxXCpEYj+j6nvLhFX9Hx13P/Wz2TQsripyFRdERxc53TeaRU76vTkJD4+RVyWGXPDe6oKDEV1LsHVxdNazBW2q1VUfT3xnoNq8u1eynotwwRwXH3BPUjcPmhhMX5GUZjSxvCkdeIsxhz/Iy5kPdzJ+R8YMwpmMmdnwigoZBxIJb0Oe3oGUXKWZJhVGNFHt5J3TQ/3e8Ukt93sl9kVrnUDyTeV24H5NnTKf5mo6Kc+db5Sq2ksEs0BbBXgaJFnChtsbKrx/bFLzxhZfHPvDA2Jef31jRPBZF9rKRv3rzvpbBI++9d+TglvveenUk9zMsghPqTsWNM1j/0oz5v0RQLaKDObSDwtLj9AjUHD8iHTl+5MhxqDnT/Q2Qb+SGbcihG7ZBA7y5jb5J39wGb9KyFom0MJuM26dpP1ARW/0xCjFUtGjFXRQQHTsXwK47iRREFZGHgqvnvO4xpt91F63MYYR583CHVPZcDu7T73f6XlyP0h+uh+2Hy0/9XyVr5DvKLPuBMi2o/oPqD5XaB6/Nojv2d/1QySg+r3WxTAxF0zIqox7Dck1GgQUtmIKowpg/zSRwrycDYJGgHtrR9uLCsxyP5STzjtJeLsLsYz16bEfbOKrp5+l4CR3X83iM+MC3yhe8i3zH8+d8DyLrk4wu8vLgKNFnCvMAC44eEhfyUSvb21eOGr2sJdLg8zVEWpaN5leA95SMM49ZpGwT+1MDMI7zo2zmpYE0iPMSWby2J8iX6oF7RhhwSxqbWA31q1JklT9SxMy8FFePUvqThPatiZ6e8lmXhrWB3In7Gi4cUhbg6MbOkT0x/tmiwg3hPr7ffArspzazVVLkHdJ5Y6jpkbWapn/fwHSxPB3bUECcPP7Yw1FSUW08BMXnYa44BqGVUKQnfaiTFn+1cuW8Scvn/eVXdDKQ6xfOrKu7fM32y+a+q2ijRv5k8Y15atFNK+9/Rnh+yOjW0lLaQo+Nn3QbSfvRiZxZH/aJEdWTiFh8CY88Q/tSq6DJCnZA85IbVFxzpn3eGucW2QyDWD9nAkvAFGSBpZxdwP60PkbB7T3LsVLS6UrfO0KyNzUX3ExAjP1x44w3GEkOj9+24Qii7reYPBb24QSTtkEAumdY9RsBTXpNN25A+5aPme5uAd3FrH2rcSKM53KaGFMsPeN4YSMMGmdRGjczmLNNO19Pmsl/na/DHEFFHcrDR4OJGiEfaoShqmMolEGgBvKl4FBwJIJDhUBQdeBfvsgy4SnqugTCM8+YyBfK8BomyiAfEmoZqIl8Q7ASTxwJfKHkUGtkhYWfOmrkoQIS56ECPi2pmFXENzryUeouVJF5opglm1wCeQ2SbUq+r6iwPloRBJBlR64l1x8oHu4szHXIeaUOZ6RQzK0xFNoq8setlqweyWZoHt+sFOSE7O6RrqXz338qUOv21biUkuza9vJEbrDYa/F4jKXZ1vb4YDkvO1TgLMvzObPcTkNhKFinlDbmDwpWocFoAIOcJYPT9aMPNklZ2cPdWWqewZBvzW0OCvmWEXVeo8FjqKktExwl4Ypyk+CRBl+kuP8jKRZk2H0Tfv90VqTIYLGJpXF3QjX78qxOH2Sp/qzmuKwKdl+2scIp2p1Ge/b6dsEkZwnGLF9ps8dmNRlM4L8ZcgwGRTWLDrnINjjfXOINOEzmrITVYs8xFagWi5xvslgLnc3O2opKt6vSaTRPrC1oNWWZchzloQVT76Bnny3PuWVoa31JQaxFzjaquebiItXutch1xoJsydI4bERZl+wwORWuQ/eKbnWulPFBXsTj+/m875c33PDLG0Rx4EE6cQM/DvhLf1PI/C69DNVR5g3kG03sFfv9NXhiYHOFxEwg9iLq9yXZM1KSr2XhdeQa/KqB9CW5HyeZXucSOH9hl/V3DvQBVJBaUq9/C65HLiEn8+jfhKe//jEhY4sPgfSl8vSEl9LEDpGmkX/pfZY0jmK2cGPg6pu6d/B0n74WKbSnA0ZGrfE+yPRGtyb5vGtHMuQLdbY6qH30ju4HvWtG4QU7z7s/Q5iVftvi/P9XIK1LMos7mW/kgejapI8wA15EBU75FZGBBLOccKMkkwLOw/Q0x7cExwCN5OrrIUYRbWIItkh8xdTnDUIsGFDyQWGxXA7d3VgG51w0BD7DAv/t94MfeJSf+Os4tiNODySdXf5x/m5/vqDl+zGV70xqT8cCgZhf1agDaWeuvzsA5aJsGz1l42kaG9feHYc2LenMx8z6U92Y6nImU//Bh/wxQgZ+pzmCjCMdZDZZyNeM0jGBLZBgQYEeU/8VFmPLhnfABf6J4LnRZl4fPGZAvT/y54Kj2j/U7bH0sI9qPIsaL51kqznpJAuiSeli0Jc2084/zNHHnQvCg0iqPkqfj1zrBV977MG0nODpg3tOQkZsUJLoRyf3pNXK6fYBxnB7RnYE7JOTalLp5etpRF+XjxgFEdmugy2PZuas/Kivp1XMFuiqszqTpMf+OppHBuBPX4iSV8dahL4TApceNAenr97GXGLsXPhpegVPgBU4p+7EOeXhay0OHh2QcIHD5ItFYgM62Rax+UwtkOlmmd61mD5IF9IHF9816vXVmpbuO01b/Tr9sd5Nh2c+9ut3Hp3ZtsgC/9EePNcLD2o023KZmEo3WkjLBCETUB50j1cl+57aXAqsrUMgGmRLfOVBpf+COREI+nRvWDQRMPFa4k2X4G4RWFwcOytQ7TY//wSVO8vyBJUvEryX6501PxANXD+Lfr3zJ/Q/M2/AkwUzPXnvsbu9pffj6WWPfwHSF49fhsldJSltZ2rIrH9t6nrijqaKLb/kiwrD2hbTs1v5+5LHH1t3y+Z1jx/Tz7YCLB7bilkmzT0Mgn7tenwVvvJ6/YyePdzVqf1887zlka7krFsmZHxd2oC1bMGTRgtZ0116bN4zniJxxsDGkDIEgH4OwLiNPWLyVgHJQivB6lDtxCG/df99R+gV9Cn6lzdWCKT7pUUQPiRGIpSseANKYDJsO/LF8Zeeof+YwuvwBspCI/9/Nkp53BnnipxEWxMRRWDu1YAQjLjAHZcm7enpmRidGXmh1/rVM2fJM19Zex3vQ/ExUeuZKJCJPZGZUUomFRykXw6iX0LBICg4uPngwXRMs4gtHbimJpP0mtq5b9QdGQ8Od3yaBqbVdJ8M2HMCldkz6vRd1yH9XMZO4P2dnfluTv+xcAGGt8yXzoi1nmL9zb/ZI7xuRraKBqJHFv345xFRifHIBY9E1tKtULUW7ejoOqiiW9ceFZ5Ivf9+6njq+Pup94Un5E/oT35H93z4Icz7nYhmCP1R6ka4ha4VfgQ3Zv5PgUwZmXgITzGgCT/gJUePork/4MH0YtzA+uUPfFrklbzwHUczVbz4ZbSC1Q8Wp2P3uK1mR4ZfyfxPRpQutprNcdrDo82Z3KmBIMIyuwvhhN3BfNYKH9Oz3OzqZoPBE7PGDJp+wx591beP6GeUcWMOZFwtA0n/hyxN18zv0q9TnoYLvz8MoCE/47uiNvkn5QEP/2KAfy4QcTvsCd0cKfcNuByWHHZLmC0k6zf457L9dzLf9w/85EhcYfeYzB/T3//0ydqyImHwjo1gfNN2RemgQRvp/qeferZ+UKnRt/Wen0Kgp0RzBApr7qRXH/77oeLyunJDYM+bv4S564ou/IiJl3JmsbuwsCj75gpj1OExlK3L+2JQaa1j0rS6/CbXoGz/+OEFaBkGChPO6Z0JQ6W3PJxVOXFM3oD+EHnEaBGTaB//Txb4grvoy7ANWwIldJdQsqvvUmUIraYPfP4XSpSFp8/ApZ/B4/LjtBqOsg2OnXmJDmckQ3orNVyceWbH0aMca9L+ovQa8kCLkqlg3ag5L/qSmzNs9vErfP//ATHKtuMAAHjajZA9TgMxEIWfyY9EhBBFDuAKhSKON0m10EUKUgRt+vx4ky3wRruOktByFlpKuAT0nICOO/DWsUBICFhrPd+8Gc+MDeAYDxDYfxe4DSzQwEvgA9TxFriCU3EeuIqG2Aau4UTcB65Tf2amqB7S2/pTJQs08RT4AEd4DVzBFd4DV9EU08A1SHEXuE79EQPkMJjAcZ9DYood9xEy+pa0QcrYkjSkZsmlzbFgXKILBU3bYobjWiFGhysJuclnrkJBT1E11M+AQW4mzszldCdHmbFyk7qlHGbWDbN8YWRXadlaOreKO52EalKqqkiUNY6nL/14hsVTzHyzgqKxJk9nmSVf+/ukWOOGjpmna9rfrhDz/6nqPtJDGxHz2szXpD6LfZs1ll/d6fTakW53ddT/x6hjHywYzvyTa99BeVtOhrHJizSzUutIaa3l3zU/ABw5cLgAAAB42l3SZ5MVVRSF4fuOBEmCiZyDiInb5+zTPYOkgWEIEpUgQUkShpyVoCA5Jy3/LlBz3/ED/WVVdVU/1XvVanW1Bp83rdbRd0Hr/ee/wbdddPEBwxjOCEbyIaMYzRjGMo6PGM8EPuYTPuUzPmcik5jMFKYyjenMYCazmM0c5jKP+SzgCxbyJYv4iq/5hm/5jsW0qUhkgkJNQzc9LOF7lrKM5axgJb2sYjV9rKGftaxjPRv4gY1sYjNb2Mo2fuQntrODneziZ3azh73s4xd+ZT8HOMghDvMbRzjKMY4zwAlOcorTnOEs5zjPBS5yictc4Xf+4CrXuM4N/uQvbnKLv7nNHe5yj/s84CGPeMwTnvKM57zgJa94zT/8O/LymYH+qt02KzOZ2QyzmLXZmN1mz2AmvaSX9JJe0kt6SS/pJb005FV6lV6lV+lVepVepVfpVXqVXtJLekkv6SW9pJc6Xvau7F3Zu7J3Ze/K3pXbQ981Zuc/Qid0Qid0Qid0Qid04n+nc0/YT9hP2E/YT9hP2E/YT9hP2E/YT9hP2E/YT9hP2E/YT9hPJL2kl/SyXtbLelkv62W9rJf1sl7WC73QC73QC73QC73QC73QK3pFr+gVvaJX9Ipe0St6Ra/Wq/VqvVqv1qv1ar1ar9ar9Rq9Rq/Ra/QavUav6XjFnRV3VtxZcWfFnRV3VtpD3zVmt9lj9pqrzNVmn7nG7O+kuyzusrjL4i6LuyzusrjLUjVvAQpVcTgAAAAAAAAB//8AAnjaY2BgYGQAgjO2i86D6AshzNIwGgBAmQUAAAA=) format('woff'), + url('Genericons.ttf') format('truetype'), + url('Genericons.svg#genericonsregular') format('svg'); + font-weight: normal; + font-style: normal; +} + +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: "Genericons"; + src: url("./Genericons.svg#Genericons") format("svg"); + } +} + + +/** + * All Genericons + */ + +.genericon { + font-size: 16px; + vertical-align: top; + text-align: center; + -moz-transition: color .1s ease-in 0; + -webkit-transition: color .1s ease-in 0; + display: inline-block; + font-family: "Genericons"; + font-style: normal; + font-weight: normal; + font-variant: normal; + line-height: 1; + text-decoration: inherit; + text-transform: none; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + speak: none; +} + + +/** + * Individual icons + */ + +.genericon-404:before { content: "\f423"; } +.genericon-activity:before { content: "\f508"; } +.genericon-anchor:before { content: "\f509"; } +.genericon-aside:before { content: "\f101"; } +.genericon-attachment:before { content: "\f416"; } +.genericon-audio:before { content: "\f109"; } +.genericon-bold:before { content: "\f471"; } +.genericon-book:before { content: "\f444"; } +.genericon-bug:before { content: "\f50a"; } +.genericon-cart:before { content: "\f447"; } +.genericon-category:before { content: "\f301"; } +.genericon-chat:before { content: "\f108"; } +.genericon-checkmark:before { content: "\f418"; } +.genericon-close:before { content: "\f405"; } +.genericon-close-alt:before { content: "\f406"; } +.genericon-cloud:before { content: "\f426"; } +.genericon-cloud-download:before { content: "\f440"; } +.genericon-cloud-upload:before { content: "\f441"; } +.genericon-code:before { content: "\f462"; } +.genericon-codepen:before { content: "\f216"; } +.genericon-cog:before { content: "\f445"; } +.genericon-collapse:before { content: "\f432"; } +.genericon-comment:before { content: "\f300"; } +.genericon-day:before { content: "\f305"; } +.genericon-digg:before { content: "\f221"; } +.genericon-document:before { content: "\f443"; } +.genericon-dot:before { content: "\f428"; } +.genericon-downarrow:before { content: "\f502"; } +.genericon-download:before { content: "\f50b"; } +.genericon-draggable:before { content: "\f436"; } +.genericon-dribbble:before { content: "\f201"; } +.genericon-dropbox:before { content: "\f225"; } +.genericon-dropdown:before { content: "\f433"; } +.genericon-dropdown-left:before { content: "\f434"; } +.genericon-edit:before { content: "\f411"; } +.genericon-ellipsis:before { content: "\f476"; } +.genericon-expand:before { content: "\f431"; } +.genericon-external:before { content: "\f442"; } +.genericon-facebook:before { content: "\f203"; } +.genericon-facebook-alt:before { content: "\f204"; } +.genericon-fastforward:before { content: "\f458"; } +.genericon-feed:before { content: "\f413"; } +.genericon-flag:before { content: "\f468"; } +.genericon-flickr:before { content: "\f211"; } +.genericon-foursquare:before { content: "\f226"; } +.genericon-fullscreen:before { content: "\f474"; } +.genericon-gallery:before { content: "\f103"; } +.genericon-github:before { content: "\f200"; } +.genericon-googleplus:before { content: "\f206"; } +.genericon-googleplus-alt:before { content: "\f218"; } +.genericon-handset:before { content: "\f50c"; } +.genericon-heart:before { content: "\f461"; } +.genericon-help:before { content: "\f457"; } +.genericon-hide:before { content: "\f404"; } +.genericon-hierarchy:before { content: "\f505"; } +.genericon-home:before { content: "\f409"; } +.genericon-image:before { content: "\f102"; } +.genericon-info:before { content: "\f455"; } +.genericon-instagram:before { content: "\f215"; } +.genericon-italic:before { content: "\f472"; } +.genericon-key:before { content: "\f427"; } +.genericon-leftarrow:before { content: "\f503"; } +.genericon-link:before { content: "\f107"; } +.genericon-linkedin:before { content: "\f207"; } +.genericon-linkedin-alt:before { content: "\f208"; } +.genericon-location:before { content: "\f417"; } +.genericon-lock:before { content: "\f470"; } +.genericon-mail:before { content: "\f410"; } +.genericon-maximize:before { content: "\f422"; } +.genericon-menu:before { content: "\f419"; } +.genericon-microphone:before { content: "\f50d"; } +.genericon-minimize:before { content: "\f421"; } +.genericon-minus:before { content: "\f50e"; } +.genericon-month:before { content: "\f307"; } +.genericon-move:before { content: "\f50f"; } +.genericon-next:before { content: "\f429"; } +.genericon-notice:before { content: "\f456"; } +.genericon-paintbrush:before { content: "\f506"; } +.genericon-path:before { content: "\f219"; } +.genericon-pause:before { content: "\f448"; } +.genericon-phone:before { content: "\f437"; } +.genericon-picture:before { content: "\f473"; } +.genericon-pinned:before { content: "\f308"; } +.genericon-pinterest:before { content: "\f209"; } +.genericon-pinterest-alt:before { content: "\f210"; } +.genericon-play:before { content: "\f452"; } +.genericon-plugin:before { content: "\f439"; } +.genericon-plus:before { content: "\f510"; } +.genericon-pocket:before { content: "\f224"; } +.genericon-polldaddy:before { content: "\f217"; } +.genericon-portfolio:before { content: "\f460"; } +.genericon-previous:before { content: "\f430"; } +.genericon-print:before { content: "\f469"; } +.genericon-quote:before { content: "\f106"; } +.genericon-rating-empty:before { content: "\f511"; } +.genericon-rating-full:before { content: "\f512"; } +.genericon-rating-half:before { content: "\f513"; } +.genericon-reddit:before { content: "\f222"; } +.genericon-refresh:before { content: "\f420"; } +.genericon-reply:before { content: "\f412"; } +.genericon-reply-alt:before { content: "\f466"; } +.genericon-reply-single:before { content: "\f467"; } +.genericon-rewind:before { content: "\f459"; } +.genericon-rightarrow:before { content: "\f501"; } +.genericon-search:before { content: "\f400"; } +.genericon-send-to-phone:before { content: "\f438"; } +.genericon-send-to-tablet:before { content: "\f454"; } +.genericon-share:before { content: "\f415"; } +.genericon-show:before { content: "\f403"; } +.genericon-shuffle:before { content: "\f514"; } +.genericon-sitemap:before { content: "\f507"; } +.genericon-skip-ahead:before { content: "\f451"; } +.genericon-skip-back:before { content: "\f450"; } +.genericon-skype:before { content: "\f220"; } +.genericon-spam:before { content: "\f424"; } +.genericon-spotify:before { content: "\f515"; } +.genericon-standard:before { content: "\f100"; } +.genericon-star:before { content: "\f408"; } +.genericon-status:before { content: "\f105"; } +.genericon-stop:before { content: "\f449"; } +.genericon-stumbleupon:before { content: "\f223"; } +.genericon-subscribe:before { content: "\f463"; } +.genericon-subscribed:before { content: "\f465"; } +.genericon-summary:before { content: "\f425"; } +.genericon-tablet:before { content: "\f453"; } +.genericon-tag:before { content: "\f302"; } +.genericon-time:before { content: "\f303"; } +.genericon-top:before { content: "\f435"; } +.genericon-trash:before { content: "\f407"; } +.genericon-tumblr:before { content: "\f214"; } +.genericon-twitch:before { content: "\f516"; } +.genericon-twitter:before { content: "\f202"; } +.genericon-unapprove:before { content: "\f446"; } +.genericon-unsubscribe:before { content: "\f464"; } +.genericon-unzoom:before { content: "\f401"; } +.genericon-uparrow:before { content: "\f500"; } +.genericon-user:before { content: "\f304"; } +.genericon-video:before { content: "\f104"; } +.genericon-videocamera:before { content: "\f517"; } +.genericon-vimeo:before { content: "\f212"; } +.genericon-warning:before { content: "\f414"; } +.genericon-website:before { content: "\f475"; } +.genericon-week:before { content: "\f306"; } +.genericon-wordpress:before { content: "\f205"; } +.genericon-xpost:before { content: "\f504"; } +.genericon-youtube:before { content: "\f213"; } +.genericon-zoom:before { content: "\f402"; } diff --git a/backend/wp-content/themes/twentyfifteen/header.php b/backend/wp-content/themes/twentyfifteen/header.php new file mode 100644 index 0000000..28de34e --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/header.php @@ -0,0 +1,52 @@ + + class="no-js"> + + + + + + + + + +> +
      + + + + +
      diff --git a/backend/wp-content/themes/twentyfifteen/image.php b/backend/wp-content/themes/twentyfifteen/image.php new file mode 100644 index 0000000..5a471d4 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/image.php @@ -0,0 +1,94 @@ + + +
      +
      + + + +
      > + + + +
      + ', '' ); ?> +
      + +
      + +
      + + + +
      + +
      + + +
      + + '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentyfifteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + +
      + + ', '' ); ?> +
      + +
      + + _x( 'Published in%title', 'Parent post link', 'twentyfifteen' ), + ) ); + + // End the loop. + endwhile; + ?> + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/inc/back-compat.php b/backend/wp-content/themes/twentyfifteen/inc/back-compat.php new file mode 100644 index 0000000..73cd44d --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/inc/back-compat.php @@ -0,0 +1,63 @@ +

      %s

      ', $message ); +} + +/** + * Prevent the Customizer from being loaded on WordPress versions prior to 4.1. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_customize() { + wp_die( sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ), '', array( + 'back_link' => true, + ) ); +} +add_action( 'load-customize.php', 'twentyfifteen_customize' ); + +/** + * Prevent the Theme Preview from being loaded on WordPress versions prior to 4.1. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_preview() { + if ( isset( $_GET['preview'] ) ) { + wp_die( sprintf( __( 'Twenty Fifteen requires at least WordPress version 4.1. You are running version %s. Please upgrade and try again.', 'twentyfifteen' ), $GLOBALS['wp_version'] ) ); + } +} +add_action( 'template_redirect', 'twentyfifteen_preview' ); diff --git a/backend/wp-content/themes/twentyfifteen/inc/custom-header.php b/backend/wp-content/themes/twentyfifteen/inc/custom-header.php new file mode 100644 index 0000000..10d0ef1 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/inc/custom-header.php @@ -0,0 +1,370 @@ + $default_text_color, + 'width' => 954, + 'height' => 1300, + 'wp-head-callback' => 'twentyfifteen_header_style', + ) ) ); +} +add_action( 'after_setup_theme', 'twentyfifteen_custom_header_setup' ); + +/** + * Convert HEX to RGB. + * + * @since Twenty Fifteen 1.0 + * + * @param string $color The original color, in 3- or 6-digit hexadecimal form. + * @return array Array containing RGB (red, green, and blue) values for the given + * HEX code, empty array otherwise. + */ +function twentyfifteen_hex2rgb( $color ) { + $color = trim( $color, '#' ); + + if ( strlen( $color ) == 3 ) { + $r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) ); + $g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) ); + $b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) ); + } else if ( strlen( $color ) == 6 ) { + $r = hexdec( substr( $color, 0, 2 ) ); + $g = hexdec( substr( $color, 2, 2 ) ); + $b = hexdec( substr( $color, 4, 2 ) ); + } else { + return array(); + } + + return array( 'red' => $r, 'green' => $g, 'blue' => $b ); +} + +if ( ! function_exists( 'twentyfifteen_header_style' ) ) : +/** + * Styles the header image and text displayed on the blog. + * + * @since Twenty Fifteen 1.0 + * + * @see twentyfifteen_custom_header_setup() + */ +function twentyfifteen_header_style() { + $header_image = get_header_image(); + + // If no custom options for text are set, let's bail. + if ( empty( $header_image ) && display_header_text() ) { + return; + } + + // If we get this far, we have custom styles. Let's do this. + ?> + + get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( 'blogname', array( + 'selector' => '.site-title a', + 'container_inclusive' => false, + 'render_callback' => 'twentyfifteen_customize_partial_blogname', + ) ); + $wp_customize->selective_refresh->add_partial( 'blogdescription', array( + 'selector' => '.site-description', + 'container_inclusive' => false, + 'render_callback' => 'twentyfifteen_customize_partial_blogdescription', + ) ); + } + + // Add color scheme setting and control. + $wp_customize->add_setting( 'color_scheme', array( + 'default' => 'default', + 'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( 'color_scheme', array( + 'label' => __( 'Base Color Scheme', 'twentyfifteen' ), + 'section' => 'colors', + 'type' => 'select', + 'choices' => twentyfifteen_get_color_scheme_choices(), + 'priority' => 1, + ) ); + + // Add custom header and sidebar text color setting and control. + $wp_customize->add_setting( 'sidebar_textcolor', array( + 'default' => $color_scheme[4], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sidebar_textcolor', array( + 'label' => __( 'Header and Sidebar Text Color', 'twentyfifteen' ), + 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ), + 'section' => 'colors', + ) ) ); + + // Remove the core header textcolor control, as it shares the sidebar text color. + $wp_customize->remove_control( 'header_textcolor' ); + + // Add custom header and sidebar background color setting and control. + $wp_customize->add_setting( 'header_background_color', array( + 'default' => $color_scheme[1], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background_color', array( + 'label' => __( 'Header and Sidebar Background Color', 'twentyfifteen' ), + 'description' => __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ), + 'section' => 'colors', + ) ) ); + + // Add an additional description to the header image section. + $wp_customize->get_section( 'header_image' )->description = __( 'Applied to the header on small screens and the sidebar on wide screens.', 'twentyfifteen' ); +} +add_action( 'customize_register', 'twentyfifteen_customize_register', 11 ); + +/** + * Render the site title for the selective refresh partial. + * + * @since Twenty Fifteen 1.5 + * @see twentyfifteen_customize_register() + * + * @return void + */ +function twentyfifteen_customize_partial_blogname() { + bloginfo( 'name' ); +} + +/** + * Render the site tagline for the selective refresh partial. + * + * @since Twenty Fifteen 1.5 + * @see twentyfifteen_customize_register() + * + * @return void + */ +function twentyfifteen_customize_partial_blogdescription() { + bloginfo( 'description' ); +} + +/** + * Register color schemes for Twenty Fifteen. + * + * Can be filtered with {@see 'twentyfifteen_color_schemes'}. + * + * The order of colors in a colors array: + * 1. Main Background Color. + * 2. Sidebar Background Color. + * 3. Box Background Color. + * 4. Main Text and Link Color. + * 5. Sidebar Text and Link Color. + * 6. Meta Box Background Color. + * + * @since Twenty Fifteen 1.0 + * + * @return array An associative array of color scheme options. + */ +function twentyfifteen_get_color_schemes() { + /** + * Filter the color schemes registered for use with Twenty Fifteen. + * + * The default schemes include 'default', 'dark', 'yellow', 'pink', 'purple', and 'blue'. + * + * @since Twenty Fifteen 1.0 + * + * @param array $schemes { + * Associative array of color schemes data. + * + * @type array $slug { + * Associative array of information for setting up the color scheme. + * + * @type string $label Color scheme label. + * @type array $colors HEX codes for default colors prepended with a hash symbol ('#'). + * Colors are defined in the following order: Main background, sidebar + * background, box background, main text and link, sidebar text and link, + * meta box background. + * } + * } + */ + return apply_filters( 'twentyfifteen_color_schemes', array( + 'default' => array( + 'label' => __( 'Default', 'twentyfifteen' ), + 'colors' => array( + '#f1f1f1', + '#ffffff', + '#ffffff', + '#333333', + '#333333', + '#f7f7f7', + ), + ), + 'dark' => array( + 'label' => __( 'Dark', 'twentyfifteen' ), + 'colors' => array( + '#111111', + '#202020', + '#202020', + '#bebebe', + '#bebebe', + '#1b1b1b', + ), + ), + 'yellow' => array( + 'label' => __( 'Yellow', 'twentyfifteen' ), + 'colors' => array( + '#f4ca16', + '#ffdf00', + '#ffffff', + '#111111', + '#111111', + '#f1f1f1', + ), + ), + 'pink' => array( + 'label' => __( 'Pink', 'twentyfifteen' ), + 'colors' => array( + '#ffe5d1', + '#e53b51', + '#ffffff', + '#352712', + '#ffffff', + '#f1f1f1', + ), + ), + 'purple' => array( + 'label' => __( 'Purple', 'twentyfifteen' ), + 'colors' => array( + '#674970', + '#2e2256', + '#ffffff', + '#2e2256', + '#ffffff', + '#f1f1f1', + ), + ), + 'blue' => array( + 'label' => __( 'Blue', 'twentyfifteen' ), + 'colors' => array( + '#e9f2f9', + '#55c3dc', + '#ffffff', + '#22313f', + '#ffffff', + '#f1f1f1', + ), + ), + ) ); +} + +if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) : +/** + * Get the current Twenty Fifteen color scheme. + * + * @since Twenty Fifteen 1.0 + * + * @return array An associative array of either the current or default color scheme hex values. + */ +function twentyfifteen_get_color_scheme() { + $color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); + $color_schemes = twentyfifteen_get_color_schemes(); + + if ( array_key_exists( $color_scheme_option, $color_schemes ) ) { + return $color_schemes[ $color_scheme_option ]['colors']; + } + + return $color_schemes['default']['colors']; +} +endif; // twentyfifteen_get_color_scheme + +if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) : +/** + * Returns an array of color scheme choices registered for Twenty Fifteen. + * + * @since Twenty Fifteen 1.0 + * + * @return array Array of color schemes. + */ +function twentyfifteen_get_color_scheme_choices() { + $color_schemes = twentyfifteen_get_color_schemes(); + $color_scheme_control_options = array(); + + foreach ( $color_schemes as $color_scheme => $value ) { + $color_scheme_control_options[ $color_scheme ] = $value['label']; + } + + return $color_scheme_control_options; +} +endif; // twentyfifteen_get_color_scheme_choices + +if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) : +/** + * Sanitization callback for color schemes. + * + * @since Twenty Fifteen 1.0 + * + * @param string $value Color scheme name value. + * @return string Color scheme name. + */ +function twentyfifteen_sanitize_color_scheme( $value ) { + $color_schemes = twentyfifteen_get_color_scheme_choices(); + + if ( ! array_key_exists( $value, $color_schemes ) ) { + $value = 'default'; + } + + return $value; +} +endif; // twentyfifteen_sanitize_color_scheme + +/** + * Enqueues front-end CSS for color scheme. + * + * @since Twenty Fifteen 1.0 + * + * @see wp_add_inline_style() + */ +function twentyfifteen_color_scheme_css() { + $color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); + + // Don't do anything if the default color scheme is selected. + if ( 'default' === $color_scheme_option ) { + return; + } + + $color_scheme = twentyfifteen_get_color_scheme(); + + // Convert main and sidebar text hex color to rgba. + $color_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[3] ); + $color_sidebar_textcolor_rgb = twentyfifteen_hex2rgb( $color_scheme[4] ); + $colors = array( + 'background_color' => $color_scheme[0], + 'header_background_color' => $color_scheme[1], + 'box_background_color' => $color_scheme[2], + 'textcolor' => $color_scheme[3], + 'secondary_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_textcolor_rgb ), + 'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_textcolor_rgb ), + 'border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_textcolor_rgb ), + 'sidebar_textcolor' => $color_scheme[4], + 'sidebar_border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.1)', $color_sidebar_textcolor_rgb ), + 'sidebar_border_focus_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.3)', $color_sidebar_textcolor_rgb ), + 'secondary_sidebar_textcolor' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.7)', $color_sidebar_textcolor_rgb ), + 'meta_box_background_color' => $color_scheme[5], + ); + + $color_scheme_css = twentyfifteen_get_color_scheme_css( $colors ); + + wp_add_inline_style( 'twentyfifteen-style', $color_scheme_css ); +} +add_action( 'wp_enqueue_scripts', 'twentyfifteen_color_scheme_css' ); + +/** + * Binds JS listener to make Customizer color_scheme control. + * + * Passes color scheme data as colorScheme global. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_customize_control_js() { + wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20141216', true ); + wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() ); +} +add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' ); + +/** + * Binds JS handlers to make the Customizer preview reload changes asynchronously. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_customize_preview_js() { + wp_enqueue_script( 'twentyfifteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20141216', true ); +} +add_action( 'customize_preview_init', 'twentyfifteen_customize_preview_js' ); + +/** + * Returns CSS for the color schemes. + * + * @since Twenty Fifteen 1.0 + * + * @param array $colors Color scheme colors. + * @return string Color scheme CSS. + */ +function twentyfifteen_get_color_scheme_css( $colors ) { + $colors = wp_parse_args( $colors, array( + 'background_color' => '', + 'header_background_color' => '', + 'box_background_color' => '', + 'textcolor' => '', + 'secondary_textcolor' => '', + 'border_color' => '', + 'border_focus_color' => '', + 'sidebar_textcolor' => '', + 'sidebar_border_color' => '', + 'sidebar_border_focus_color' => '', + 'secondary_sidebar_textcolor' => '', + 'meta_box_background_color' => '', + ) ); + + $css = << a, + .author-description a, + .taxonomy-description a, + .textwidget a, + .entry-footer a:hover, + .comment-metadata a:hover, + .pingback .edit-link a:hover, + .comment-list .reply a:hover, + .site-info a:hover { + border-color: {$colors['textcolor']}; + } + + /* Secondary Text Color */ + button:hover, + button:focus, + input[type="button"]:hover, + input[type="button"]:focus, + input[type="reset"]:hover, + input[type="reset"]:focus, + input[type="submit"]:hover, + input[type="submit"]:focus, + .pagination .prev:hover, + .pagination .prev:focus, + .pagination .next:hover, + .pagination .next:focus, + .widget_calendar tbody a:hover, + .widget_calendar tbody a:focus, + .page-links a:hover, + .page-links a:focus { + background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + background-color: {$colors['secondary_textcolor']}; + } + + /* Secondary Text Color */ + blockquote, + a:hover, + a:focus, + .main-navigation .menu-item-description, + .post-navigation .meta-nav, + .post-navigation a:hover .post-title, + .post-navigation a:focus .post-title, + .image-navigation, + .image-navigation a, + .comment-navigation, + .comment-navigation a, + .widget, + .author-heading, + .entry-footer, + .entry-footer a, + .taxonomy-description, + .page-links > .page-links-title, + .entry-caption, + .comment-author, + .comment-metadata, + .comment-metadata a, + .pingback .edit-link, + .pingback .edit-link a, + .post-password-form label, + .comment-form label, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .form-allowed-tags, + .no-comments, + .site-info, + .site-info a, + .wp-caption-text, + .gallery-caption, + .comment-list .reply a, + .widecolumn label, + .widecolumn .mu_register label { + color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + color: {$colors['secondary_textcolor']}; + } + + /* Secondary Text Color */ + blockquote, + .logged-in-as a:hover, + .comment-author a:hover { + border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['secondary_textcolor']}; + } + + /* Border Color */ + hr, + .dropdown-toggle:hover, + .dropdown-toggle:focus { + background-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + background-color: {$colors['border_color']}; + } + + /* Border Color */ + pre, + abbr[title], + table, + th, + td, + input, + textarea, + .main-navigation ul, + .main-navigation li, + .post-navigation, + .post-navigation div + div, + .pagination, + .comment-navigation, + .widget li, + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children, + .site-header, + .site-footer, + .hentry + .hentry, + .author-info, + .entry-content .page-links a, + .page-links > span, + .page-header, + .comments-area, + .comment-list + .comment-respond, + .comment-list article, + .comment-list .pingback, + .comment-list .trackback, + .comment-list .reply a, + .no-comments { + border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['border_color']}; + } + + /* Border Focus Color */ + a:focus, + button:focus, + input:focus { + outline-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + outline-color: {$colors['border_focus_color']}; + } + + input:focus, + textarea:focus { + border-color: {$colors['textcolor']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['border_focus_color']}; + } + + /* Sidebar Link Color */ + .secondary-toggle:before { + color: {$colors['sidebar_textcolor']}; + } + + .site-title a, + .site-description { + color: {$colors['sidebar_textcolor']}; + } + + /* Sidebar Text Color */ + .site-title a:hover, + .site-title a:focus { + color: {$colors['secondary_sidebar_textcolor']}; + } + + /* Sidebar Border Color */ + .secondary-toggle { + border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['sidebar_border_color']}; + } + + /* Sidebar Border Focus Color */ + .secondary-toggle:hover, + .secondary-toggle:focus { + border-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['sidebar_border_focus_color']}; + } + + .site-title a { + outline-color: {$colors['sidebar_textcolor']}; /* Fallback for IE7 and IE8 */ + outline-color: {$colors['sidebar_border_focus_color']}; + } + + /* Meta Background Color */ + .entry-footer { + background-color: {$colors['meta_box_background_color']}; + } + + @media screen and (min-width: 38.75em) { + /* Main Text Color */ + .page-header { + border-color: {$colors['textcolor']}; + } + } + + @media screen and (min-width: 59.6875em) { + /* Make sure its transparent on desktop */ + .site-header, + .secondary { + background-color: transparent; + } + + /* Sidebar Background Color */ + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"], + .widget_calendar tbody a, + .widget_calendar tbody a:hover, + .widget_calendar tbody a:focus { + color: {$colors['header_background_color']}; + } + + /* Sidebar Link Color */ + .secondary a, + .dropdown-toggle:after, + .widget-title, + .widget blockquote cite, + .widget blockquote small { + color: {$colors['sidebar_textcolor']}; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"], + .widget_calendar tbody a { + background-color: {$colors['sidebar_textcolor']}; + } + + .textwidget a { + border-color: {$colors['sidebar_textcolor']}; + } + + /* Sidebar Text Color */ + .secondary a:hover, + .secondary a:focus, + .main-navigation .menu-item-description, + .widget, + .widget blockquote, + .widget .wp-caption-text, + .widget .gallery-caption { + color: {$colors['secondary_sidebar_textcolor']}; + } + + .widget button:hover, + .widget button:focus, + .widget input[type="button"]:hover, + .widget input[type="button"]:focus, + .widget input[type="reset"]:hover, + .widget input[type="reset"]:focus, + .widget input[type="submit"]:hover, + .widget input[type="submit"]:focus, + .widget_calendar tbody a:hover, + .widget_calendar tbody a:focus { + background-color: {$colors['secondary_sidebar_textcolor']}; + } + + .widget blockquote { + border-color: {$colors['secondary_sidebar_textcolor']}; + } + + /* Sidebar Border Color */ + .main-navigation ul, + .main-navigation li, + .widget input, + .widget textarea, + .widget table, + .widget th, + .widget td, + .widget pre, + .widget li, + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children, + .widget abbr[title] { + border-color: {$colors['sidebar_border_color']}; + } + + .dropdown-toggle:hover, + .dropdown-toggle:focus, + .widget hr { + background-color: {$colors['sidebar_border_color']}; + } + + .widget input:focus, + .widget textarea:focus { + border-color: {$colors['sidebar_border_focus_color']}; + } + + .sidebar a:focus, + .dropdown-toggle:focus { + outline-color: {$colors['sidebar_border_focus_color']}; + } + } +CSS; + + return $css; +} + +/** + * Output an Underscore template for generating CSS for the color scheme. + * + * The template generates the css dynamically for instant display in the Customizer + * preview. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_color_scheme_css_template() { + $colors = array( + 'background_color' => '{{ data.background_color }}', + 'header_background_color' => '{{ data.header_background_color }}', + 'box_background_color' => '{{ data.box_background_color }}', + 'textcolor' => '{{ data.textcolor }}', + 'secondary_textcolor' => '{{ data.secondary_textcolor }}', + 'border_color' => '{{ data.border_color }}', + 'border_focus_color' => '{{ data.border_focus_color }}', + 'sidebar_textcolor' => '{{ data.sidebar_textcolor }}', + 'sidebar_border_color' => '{{ data.sidebar_border_color }}', + 'sidebar_border_focus_color' => '{{ data.sidebar_border_focus_color }}', + 'secondary_sidebar_textcolor' => '{{ data.secondary_sidebar_textcolor }}', + 'meta_box_background_color' => '{{ data.meta_box_background_color }}', + ); + ?> + + 1 && get_option( 'page_comments' ) ) : + ?> +
      + + %s', __( 'Featured', 'twentyfifteen' ) ); + } + + $format = get_post_format(); + if ( current_theme_supports( 'post-formats', $format ) ) { + printf( '%1$s%3$s', + sprintf( '%s ', _x( 'Format', 'Used before post format.', 'twentyfifteen' ) ), + esc_url( get_post_format_link( $format ) ), + get_post_format_string( $format ) + ); + } + + if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) { + $time_string = ''; + + if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { + $time_string = ''; + } + + $time_string = sprintf( $time_string, + esc_attr( get_the_date( 'c' ) ), + get_the_date(), + esc_attr( get_the_modified_date( 'c' ) ), + get_the_modified_date() + ); + + printf( '%1$s %3$s', + _x( 'Posted on', 'Used before publish date.', 'twentyfifteen' ), + esc_url( get_permalink() ), + $time_string + ); + } + + if ( 'post' == get_post_type() ) { + if ( is_singular() || is_multi_author() ) { + printf( '', + _x( 'Author', 'Used before post author name.', 'twentyfifteen' ), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + get_the_author() + ); + } + + $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) ); + if ( $categories_list && twentyfifteen_categorized_blog() ) { + printf( '%1$s %2$s', + _x( 'Categories', 'Used before category names.', 'twentyfifteen' ), + $categories_list + ); + } + + $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfifteen' ) ); + if ( $tags_list && ! is_wp_error( $tags_list ) ) { + printf( '%1$s %2$s', + _x( 'Tags', 'Used before tag names.', 'twentyfifteen' ), + $tags_list + ); + } + } + + if ( is_attachment() && wp_attachment_is_image() ) { + // Retrieve attachment metadata. + $metadata = wp_get_attachment_metadata(); + + printf( '%1$s %3$s × %4$s', + _x( 'Full size', 'Used before full size attachment link.', 'twentyfifteen' ), + esc_url( wp_get_attachment_url() ), + $metadata['width'], + $metadata['height'] + ); + } + + if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo ''; + /* translators: %s: post title */ + comments_popup_link( sprintf( __( 'Leave a comment on %s', 'twentyfifteen' ), get_the_title() ) ); + echo ''; + } +} +endif; + +/** + * Determine whether blog/site has more than one category. + * + * @since Twenty Fifteen 1.0 + * + * @return bool True of there is more than one category, false otherwise. + */ +function twentyfifteen_categorized_blog() { + if ( false === ( $all_the_cool_cats = get_transient( 'twentyfifteen_categories' ) ) ) { + // Create an array of all the categories that are attached to posts. + $all_the_cool_cats = get_categories( array( + 'fields' => 'ids', + 'hide_empty' => 1, + + // We only need to know if there is more than one category. + 'number' => 2, + ) ); + + // Count the number of categories that are attached to the posts. + $all_the_cool_cats = count( $all_the_cool_cats ); + + set_transient( 'twentyfifteen_categories', $all_the_cool_cats ); + } + + if ( $all_the_cool_cats > 1 || is_preview() ) { + // This blog has more than 1 category so twentyfifteen_categorized_blog should return true. + return true; + } else { + // This blog has only 1 category so twentyfifteen_categorized_blog should return false. + return false; + } +} + +/** + * Flush out the transients used in {@see twentyfifteen_categorized_blog()}. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_category_transient_flusher() { + // Like, beat it. Dig? + delete_transient( 'twentyfifteen_categories' ); +} +add_action( 'edit_category', 'twentyfifteen_category_transient_flusher' ); +add_action( 'save_post', 'twentyfifteen_category_transient_flusher' ); + +if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : +/** + * Display an optional post thumbnail. + * + * Wraps the post thumbnail in an anchor element on index views, or a div + * element when on single views. + * + * @since Twenty Fifteen 1.0 + */ +function twentyfifteen_post_thumbnail() { + if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { + return; + } + + if ( is_singular() ) : + ?> + +
      + +
      + + + + + + %2$s', + esc_url( get_permalink( get_the_ID() ) ), + /* translators: %s: Name of current post */ + sprintf( __( 'Continue reading %s', 'twentyfifteen' ), '' . get_the_title( get_the_ID() ) . '' ) + ); + return ' … ' . $link; +} +add_filter( 'excerpt_more', 'twentyfifteen_excerpt_more' ); +endif; + +if ( ! function_exists( 'twentyfifteen_the_custom_logo' ) ) : +/** + * Displays the optional custom logo. + * + * Does nothing if the custom logo is not available. + * + * @since Twenty Fifteen 1.5 + */ +function twentyfifteen_the_custom_logo() { + if ( function_exists( 'the_custom_logo' ) ) { + the_custom_logo(); + } +} +endif; diff --git a/backend/wp-content/themes/twentyfifteen/index.php b/backend/wp-content/themes/twentyfifteen/index.php new file mode 100644 index 0000000..db77651 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/index.php @@ -0,0 +1,61 @@ + + +
      +
      + + + + +
      +

      +
      + + + __( 'Previous page', 'twentyfifteen' ), + 'next_text' => __( 'Next page', 'twentyfifteen' ), + 'before_page_number' => '' . __( 'Page', 'twentyfifteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'content', 'none' ); + + endif; + ?> + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/js/color-scheme-control.js b/backend/wp-content/themes/twentyfifteen/js/color-scheme-control.js new file mode 100644 index 0000000..3563239 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/js/color-scheme-control.js @@ -0,0 +1,78 @@ +/* global colorScheme, Color */ +/** + * Add a listener to the Color Scheme control to update other color controls to new values/defaults. + * Also trigger an update of the Color Scheme CSS when a color is changed. + */ + +( function( api ) { + var cssTemplate = wp.template( 'twentyfifteen-color-scheme' ), + colorSchemeKeys = [ + 'background_color', + 'header_background_color', + 'box_background_color', + 'textcolor', + 'sidebar_textcolor', + 'meta_box_background_color' + ], + colorSettings = [ + 'background_color', + 'header_background_color', + 'sidebar_textcolor' + ]; + + api.controlConstructor.select = api.Control.extend( { + ready: function() { + if ( 'color_scheme' === this.id ) { + this.setting.bind( 'change', function( value ) { + // Update Background Color. + api( 'background_color' ).set( colorScheme[value].colors[0] ); + api.control( 'background_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', colorScheme[value].colors[0] ) + .wpColorPicker( 'defaultColor', colorScheme[value].colors[0] ); + + // Update Header/Sidebar Background Color. + api( 'header_background_color' ).set( colorScheme[value].colors[1] ); + api.control( 'header_background_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', colorScheme[value].colors[1] ) + .wpColorPicker( 'defaultColor', colorScheme[value].colors[1] ); + + // Update Header/Sidebar Text Color. + api( 'sidebar_textcolor' ).set( colorScheme[value].colors[4] ); + api.control( 'sidebar_textcolor' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', colorScheme[value].colors[4] ) + .wpColorPicker( 'defaultColor', colorScheme[value].colors[4] ); + } ); + } + } + } ); + + // Generate the CSS for the current Color Scheme. + function updateCSS() { + var scheme = api( 'color_scheme' )(), css, + colors = _.object( colorSchemeKeys, colorScheme[ scheme ].colors ); + + // Merge in color scheme overrides. + _.each( colorSettings, function( setting ) { + colors[ setting ] = api( setting )(); + }); + + // Add additional colors. + colors.secondary_textcolor = Color( colors.textcolor ).toCSS( 'rgba', 0.7 ); + colors.border_color = Color( colors.textcolor ).toCSS( 'rgba', 0.1 ); + colors.border_focus_color = Color( colors.textcolor ).toCSS( 'rgba', 0.3 ); + colors.secondary_sidebar_textcolor = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.7 ); + colors.sidebar_border_color = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.1 ); + colors.sidebar_border_focus_color = Color( colors.sidebar_textcolor ).toCSS( 'rgba', 0.3 ); + + css = cssTemplate( colors ); + + api.previewer.send( 'update-color-scheme-css', css ); + } + + // Update the CSS whenever a color setting is changed. + _.each( colorSettings, function( setting ) { + api( setting, function( setting ) { + setting.bind( updateCSS ); + } ); + } ); +} )( wp.customize ); diff --git a/backend/wp-content/themes/twentyfifteen/js/customize-preview.js b/backend/wp-content/themes/twentyfifteen/js/customize-preview.js new file mode 100644 index 0000000..58ca269 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/js/customize-preview.js @@ -0,0 +1,35 @@ +/** + * Live-update changed settings in real time in the Customizer preview. + */ + +( function( $ ) { + var $style = $( '#twentyfifteen-color-scheme-css' ), + api = wp.customize; + + if ( ! $style.length ) { + $style = $( 'head' ).append( '"; +c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| +"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:"3.7.0",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f); +if(g)return a.createDocumentFragment();for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) && + document.getElementById && window.addEventListener ) { + + window.addEventListener( 'hashchange', function() { + var element = document.getElementById( location.hash.substring( 1 ) ); + + if ( element ) { + if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.nodeName ) ) { + element.tabIndex = -1; + } + + element.focus(); + } + }, false ); + } +} )(); diff --git a/backend/wp-content/themes/twentyfifteen/page.php b/backend/wp-content/themes/twentyfifteen/page.php new file mode 100644 index 0000000..5c7a0b0 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/page.php @@ -0,0 +1,38 @@ + + +
      +
      + + + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/readme.txt b/backend/wp-content/themes/twentyfifteen/readme.txt new file mode 100644 index 0000000..8231e09 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/readme.txt @@ -0,0 +1,111 @@ +=== Twenty Fifteen === +Contributors: the WordPress team +Requires at least: WordPress 4.1 +Tested up to: WordPress 5.0-trunk +Version: 2.0 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Tags: blog, two-columns, left-sidebar, accessibility-ready, custom-background, custom-colors, custom-header, custom-logo, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready + +== Description == +Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer. + +* Mobile-first, Responsive Layout +* Custom Colors +* Custom Header +* Social Links +* Menu Description +* Post Formats +* The GPL v2.0 or later license. :) Use it to make something cool. + +For more information about Twenty Fifteen please go to https://codex.wordpress.org/Twenty_Fifteen. + +== Installation == + +1. In your admin panel, go to Appearance -> Themes and click the 'Add New' button. +2. Type in Twenty Fifteen in the search form and press the 'Enter' key on your keyboard. +3. Click on the 'Activate' button to use your new theme right away. +4. Go to https://codex.wordpress.org/Twenty_Fifteen for a guide on how to customize this theme. +5. Navigate to Appearance > Customize in your admin panel and customize to taste. + +== Copyright == + +Twenty Fifteen WordPress Theme, Copyright 2014-2018 WordPress.org & Automattic.com +Twenty Fifteen is distributed under the terms of the GNU GPL + +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. + +Twenty Fifteen Theme bundles the following third-party resources: + +HTML5 Shiv v3.7.0, Copyright 2014 Alexander Farkas +Licenses: MIT/GPL2 +Source: https://github.com/aFarkas/html5shiv + +Genericons icon font, Copyright 2013-2017 Automattic.com +License: GNU GPL, Version 2 (or later) +Source: http://www.genericons.com + +== Changelog == + += 2.0 = +* Released: May 17, 2018 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_2.0 + += 1.9 = +* Released: November 14, 2017 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.9 + += 1.8 = +* Released: June 8, 2017 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.8 + += 1.7 = +* Released: December 6, 2016 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.7 + += 1.6 = +* Released: August 15, 2016 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.6 + += 1.5 = +* Released: April 12, 2016 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.5 + += 1.4 = +* Released: December 8, 2015 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.4 + += 1.3 = +* Released: August 18, 2015 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.3 + += 1.2 = +* Released: May 6, 2015 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.2 + += 1.1 = +* Released: April 23, 2015 + +https://codex.wordpress.org/Twenty_Fifteen_Theme_Changelog#Version_1.1 + += 1.0 = +* Released: December 18, 2014 + +Initial release diff --git a/backend/wp-content/themes/twentyfifteen/rtl.css b/backend/wp-content/themes/twentyfifteen/rtl.css new file mode 100644 index 0000000..4a7397f --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/rtl.css @@ -0,0 +1,848 @@ +/* +Theme Name: Twenty Fifteen +Description: Adds support for languages written in a Right To Left (RTL) direction. +It's easy, just a matter of overwriting all the horizontal positioning attributes +of your CSS stylesheet in a separate stylesheet file named rtl.css. + +See: https://codex.wordpress.org/Right_to_Left_Language_Support +*/ + +/** + * Table of Contents: + * + * 1.0 - Reset + * 2.0 - Typography + * 3.0 - Elements + * 4.0 - Forms + * 5.0 - Navigations + * 6.0 - Accessibility + * 7.0 - Alignments + * 8.0 - Header + * 9.0 - Widgets + * 10.0 - Content + * 10.1 - Posts and pages + * 10.2 - Comments + * 11.0 - Media Queries + * 11.1 - Mobile Large + * 11.2 - Tablet Small + * 11.3 - Tablet Large + * 11.4 - Desktop Small + * 11.5 - Desktop Medium + * 11.6 - Desktop Large + * 11.7 - Desktop X-Large + */ + + +/** + * 1.0 Reset + */ + +body { + direction: rtl; + unicode-bidi: embed; +} + +caption, +th, +td { + text-align: right; +} + + +/** + * 2.0 Typography + */ + +body, +button, +input[type="button"], +input[type="reset"], +input[type="submit"], +input, +select, +textarea, +blockquote cite, +blockquote small, +.post-password-form label, +.main-navigation .menu-item-description, +.post-navigation .meta-nav, +.post-navigation .post-title, +.pagination, +.image-navigation, +.comment-navigation, +.site-title, +.site-description, +.widget-title, +.widget_calendar caption, +.widget_rss .rss-date, +.widget_rss cite, +.author-heading, +.entry-footer, +.page-title, +.page-links, +.entry-caption, +.comments-title, +.comment-reply-title, +.comment-metadata, +.pingback .edit-link, +.comment-list .reply a, +.comment-form label, +.comment-notes, +.comment-awaiting-moderation, +.logged-in-as, +.form-allowed-tags, +.no-comments, +.wp-caption-text, +.gallery-caption { + font-family: Arial, Tahoma, sans-serif; +} + +::-webkit-input-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +:-moz-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +::-moz-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +:-ms-input-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +blockquote { + border-right: 4px solid rgba(51, 51, 51, 0.7); + border-left: 0; + padding-right: 0.7778em; + padding-left: 0; +} + + +/** + * 3.0 Elements + */ + +ul, +ol { + margin: 0 1.3333em 1.6em 0; +} + +caption, +th, +td { + text-align: right; +} + + +/** + * 4.0 Forms + */ + +.post-password-form input[type="submit"] { + right: auto; + left: 0; +} + + +/** + * 5.0 Navigations + */ + +.main-navigation ul ul { + margin-right: 0.8em; + margin-left: auto; +} + +.main-navigation .menu-item-has-children > a { + padding-right: 0; + padding-left: 48px; +} + +.dropdown-toggle { + right: auto; + left: 0; +} + +.dropdown-toggle:after { + right: -1px; + left: auto; +} + +.social-navigation li { + float: right; +} + +.social-navigation a:before { + right: 0; + left: auto; +} + +.secondary-toggle { + right: auto; + left: 0; +} + +.post-navigation .has-post-thumbnail a:before { + right: 0; + left: auto; +} + +.pagination .prev { + right: 0; + left: auto; +} + +.pagination .prev:before { + content: "\f429"; + right: -1px; + left: auto; +} + +.pagination .next { + right: auto; + left: 0; +} + +.pagination .next:before { + content: "\f430"; + right: auto; + left: -1px; +} + +.image-navigation .nav-previous a:before, +.comment-navigation .nav-previous a:before { + content: "\f429"; + margin-right: auto; + margin-left: 0.2em; +} + +.image-navigation .nav-next a:after, +.comment-navigation .nav-next a:after { + content: "\f430"; + margin-right: 0.2em; + margin-left: auto; +} + + +/** + * 6.0 Accessibility + */ + +.screen-reader-text:hover, +.screen-reader-text:focus { + right: 5px; + left: auto; +} + + +/** + * 7.0 Alignments + */ + +.alignright { + float: right; +} + +.alignleft { + float: left; +} + +.aligncenter { + margin-right: auto; + margin-left: auto; +} + +blockquote.alignright, +.wp-caption.alignright, +img.alignright { + margin: 0.4em 0 1.6em 1.6em; +} + +blockquote.alignleft, +.wp-caption.alignleft, +img.alignleft { + margin: 0.4em 1.6em 1.6em 0; +} + + +/** + * 8.0 Header + */ + +.site-branding { + padding-right: 0; + padding-left: 60px; +} + + +/** + * 9.0 Widgets + */ + +.widget_categories .children, +.widget_nav_menu .sub-menu, +.widget_pages .children { + margin: 0.7667em 0.8em 0 0; +} + +.textwidget ul, +.textwidget ol { + margin-left: 0; + margin-right: 1.6em; +} + +/** + * 10.0 Content + */ + +/** + * 10.1 Posts and pages + */ + +.entry-content .more-link:after { + content: "\f430"; +} + +.author-link:after { + content: "\f430"; +} + +.author-info .avatar { + float: right; + margin: 0 0 1.6em 1.6em; +} + +.posted-on:before, +.byline:before, +.cat-links:before, +.tags-links:before, +.comments-link:before, +.entry-format:before, +.edit-link:before, +.full-size-link:before { + margin-right: auto; + margin-left: 2px; +} + +.posted-on, +.byline, +.cat-links, +.tags-links, +.comments-link, +.entry-format, +.full-size-link { + margin-right: auto; + margin-left: 1em; +} + +.page-links a, +.page-links > span { + margin: 0 0 0.3333em 0.3333em; +} + +.page-links > .page-links-title { + padding-right: 0; + padding-left: 0.5em; +} + +.type-attachment .entry-header { + clear: left; +} + +.format-link .entry-title a:after { + -webkit-transform: scaleX(-1); + -moz-transform: scaleX(-1); + -ms-transform: scaleX(-1); + -o-transform: scaleX(-1); + transform: scaleX(-1); +} + + +/** + * 10.2 Comments + */ + +.comment-list .children > li { + padding-right: 0.8em; + padding-left: 0; +} + +.comment-author .avatar { + float: right; + margin-right: 0; + margin-left: 0.4em; +} + +.bypostauthor > article .fn:after { + right: 3px; + left: auto; +} + +.comment-metadata .edit-link { + margin-right: 1em; + margin-left: auto; +} + +.pingback .edit-link { + margin-right: 1em; + margin-left: auto; +} + +.comment-content ul, +.comment-content ol { + margin: 0 1.3333em 1.6em 0; +} + +.comment-reply-title small a { + float: left; +} + +.comment-form #wp-comment-cookies-consent { + margin: 0 0 0 10px; +} + +/** + * 11.0 Media Queries + */ + + +/** + * 11.1 Mobile Large 620px + */ + +@media screen and (min-width: 38.75em) { + ul, + ol { + margin-right: 0; + margin-left: auto; + } + + li > ul, + li > ol, + blockquote > ul, + blockquote > ol { + margin-right: 1.3333em; + margin-left: auto; + } + + blockquote { + margin-right: -1em; + margin-left: auto; + } + + blockquote > blockquote { + margin-right: 0; + margin-left: auto; + } + + .page-header { + border-color: inherit; + border-left: none; + border-style: solid; + border-width: 0 7px 0 0; + } + + .page-title, + .taxonomy-description { + margin-right: -7px; + margin-left: auto; + } + + .comment-content ul, + .comment-content ol { + margin-right: 0; + margin-left: auto; + } + + .comment-content li > ul, + .comment-content li > ol, + .comment-content blockquote > ul, + .comment-content blockquote > ol { + margin-right: 1.3333em; + margin-left: auto; + } +} + + +/** + * 11.2 Tablet Small 740px + */ + +@media screen and (min-width: 46.25em) { + blockquote { + margin-right: -1.05em; + margin-left: auto; + padding-right: 0.85em; + padding-left: 0; + } + + .main-navigation ul ul { + margin-right: 1em; + margin-left: auto; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4118em 0 1.6471em 1.6471em; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4118em 1.6471em 1.6471em 0; + } + + .site-branding { + padding-right: 0; + padding-left: 66px; + } + + .widget blockquote { + margin-right: -1.2353em; + margin-left: auto; + padding-right: 1em; + padding-left: 0; + } + + .widget blockquote > blockquote { + margin-right: 0; + margin-left: auto; + } + + .widget blockquote.alignright, + .widget .wp-caption.alignright, + .widget img.alignright { + margin: 0.5em 0 1.5em 1.5em; + } + + .widget blockquote.alignleft, + .widget .wp-caption.alignleft, + .widget img.alignleft { + margin: 0.5em 1.5em 1.5em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.9643em 1em 0 0; + } + + .page-links a, + .page-links > span { + margin: 0 0 0.2857em 0.2857em; + } + + .author-info .avatar { + margin: 0 0 1.6471em 1.6471em; + } + + .comment-list .children > li { + padding-right: 1.2353em; + padding-left: 0; + } + + .comment-author .avatar { + margin-left: 1.64705em; + } + + .bypostauthor > article .fn:after { + right: 6px; + left: auto; + } +} + + +/** + * 11.3 Tablet Large 880px + */ + +@media screen and (min-width: 55em) { + blockquote { + margin-right: -1.0909em; + margin-left: auto; + padding-right: 0.9091em; + padding-left: 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; + } + + .site-branding { + padding-right: 0; + padding-left: 74px; + } + + .widget blockquote { + margin-right: -1.2632em; + margin-left: auto; + padding-right: 1.0526em; + padding-left: 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.7188em 1em 0 0; + } + + .page-links a, + .page-links > span { + margin: 0 0 0.25em 0.25em; + } + + .author-info .avatar { + margin: 0 0 1.6842em 1.6842em; + } + + .comment-list .children > li { + padding-right: 1.4737em; + padding-left: 0; + } + + .comment-author .avatar { + margin-left: 1.6842em; + } +} + + +/** + * 11.4 Desktop Small 955px + */ + +@media screen and (min-width: 59.6875em) { + body:before { + right: 0; + left: auto; + } + + .sidebar { + float: right; + margin-right: auto; + margin-left: -100%; + } + + .site-content { + float: right; + margin-right: 29.4118%; + margin-left: auto; + } + + blockquote { + margin-right: -1.3333em; + margin-left: auto; + padding-right: 1.1111em; + padding-left: 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 0; + padding-left: 30px; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4em 0 1.6em 1.6em; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4em 1.6em 1.6em 0; + } + + .widget blockquote { + margin-right: -1.5em; + margin-left: auto; + padding-right: 1.1667em; + padding-left: 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4583em 1em 0 0; + } + + .page-links a, + .page-links > span { + margin: 0 0 0.3333em 0.3333em; + } + + .author-info .avatar { + margin: 0 0 1.5em 1.5em; + } + + .comment-list .children > li { + padding-right: 0.8em; + padding-left: 0; + } + + .comment-author .avatar { + margin-left: 0.8em; + } + + .bypostauthor > article .fn:after { + right: 3px; + left: auto; + } + + .site-branding { + padding: 0; + } + + .site-footer { + float: right; + margin: 0 35.2941% 0 0; + } +} + + +/** + * 11.5 Desktop Medium 1100px + */ + +@media screen and (min-width: 68.75em) { + blockquote { + margin-right: -1.05em; + margin-left: auto; + padding-right: 0.85em; + padding-left: 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 0; + padding-left: 34px; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4118em 0 1.6471em 1.6471em; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4118em 1.6471em 1.6471em 0; + } + + .widget blockquote { + padding-right: 1.2143em; + padding-left: 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4643em 1em 0 0; + } + + .page-links a, + .page-links > span { + margin: 0 0 0.2857em 0.2857em; + } + + .author-info .avatar { + margin: 0 0 1.6471em 1.6471em; + } + + .comment-list .children > li { + padding-right: 1.1667em; + padding-left: 0; + } + + .comment-author .avatar { + margin-left: 1.64705em; + } + + .bypostauthor > article .fn:after { + right: 6px; + left: auto; + } +} + + +/** + * 11.6 Desktop Large 1240px + */ + +@media screen and (min-width: 77.5em) { + blockquote { + margin-right: -1.0909em; + margin-left: auto; + padding-right: 0.9091em; + padding-left: 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 0; + padding-left: 38px; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; + } + + .widget blockquote { + padding-right: 1.25em; + padding-left: 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4688em 1em 0 0; + } + + .page-links a, + .page-links > span { + margin: 0 0 0.25em 0.25em; + } + + .author-info .avatar { + margin: 0 0 1.6842em 1.6842em; + } + + .comment-list .children > li { + padding-right: 1.4737em; + padding-left: 0; + } + + .comment-author .avatar { + margin-left: 1.64705em; + } +} + + +/** + * 11.7 Desktop X-Large 1403px + */ + +@media screen and (min-width: 87.6875em) { + body:before { + width: -webkit-calc(50% - 289px); + width: calc(50% - 289px); + } +} diff --git a/backend/wp-content/themes/twentyfifteen/screenshot.png b/backend/wp-content/themes/twentyfifteen/screenshot.png new file mode 100644 index 0000000..d00b443 Binary files /dev/null and b/backend/wp-content/themes/twentyfifteen/screenshot.png differ diff --git a/backend/wp-content/themes/twentyfifteen/search.php b/backend/wp-content/themes/twentyfifteen/search.php new file mode 100644 index 0000000..3352841 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/search.php @@ -0,0 +1,53 @@ + + +
      +
      + + + + + + + + __( 'Previous page', 'twentyfifteen' ), + 'next_text' => __( 'Next page', 'twentyfifteen' ), + 'before_page_number' => '' . __( 'Page', 'twentyfifteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'content', 'none' ); + + endif; + ?> + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/sidebar.php b/backend/wp-content/themes/twentyfifteen/sidebar.php new file mode 100644 index 0000000..02308ef --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/sidebar.php @@ -0,0 +1,47 @@ + +
      + + + + + + + + + + + + + +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/single.php b/backend/wp-content/themes/twentyfifteen/single.php new file mode 100644 index 0000000..fda8b5e --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/single.php @@ -0,0 +1,48 @@ + + +
      +
      + + ' ' . + '' . __( 'Next post:', 'twentyfifteen' ) . ' ' . + '%title', + 'prev_text' => ' ' . + '' . __( 'Previous post:', 'twentyfifteen' ) . ' ' . + '%title', + ) ); + + // End the loop. + endwhile; + ?> + +
      +
      + + diff --git a/backend/wp-content/themes/twentyfifteen/style.css b/backend/wp-content/themes/twentyfifteen/style.css new file mode 100644 index 0000000..e36ffa5 --- /dev/null +++ b/backend/wp-content/themes/twentyfifteen/style.css @@ -0,0 +1,6087 @@ +/* +Theme Name: Twenty Fifteen +Theme URI: https://wordpress.org/themes/twentyfifteen/ +Author: the WordPress team +Author URI: https://wordpress.org/ +Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer. +Version: 2.0 +License: GNU General Public License v2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Tags: blog, two-columns, left-sidebar, accessibility-ready, custom-background, custom-colors, custom-header, custom-logo, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready +Text Domain: twentyfifteen + +This theme, like WordPress, is licensed under the GPL. +Use it to make something cool, have fun, and share what you've learned with others. +*/ + + +/** + * Table of Contents + * + * 1.0 - Reset + * 2.0 - Genericons + * 3.0 - Typography + * 4.0 - Elements + * 5.0 - Forms + * 6.0 - Navigations + * 6.1 - Links + * 6.2 - Menus + * 7.0 - Accessibility + * 8.0 - Alignments + * 9.0 - Clearings + * 10.0 - Header + * 11.0 - Widgets + * 12.0 - Content + * 12.1 - Posts and pages + * 12.2 - Post Formats + * 12.3 - Comments + * 13.0 - Footer + * 14.0 - Media + * 14.1 - Captions + * 14.2 - Galleries + * 15.0 - Multisite + * 16.0 - Media Queries + * 16.1 - Mobile Large + * 16.2 - Tablet Small + * 16.3 - Tablet Large + * 16.4 - Desktop Small + * 16.5 - Desktop Medium + * 16.6 - Desktop Large + * 16.7 - Desktop X-Large + * 17.0 - Print + */ + + +/** + * 1.0 - Reset + * + * Resetting and rebuilding styles have been helped along thanks to the fine + * work of Eric Meyer, Nicolas Gallagher, Jonathan Neal, and Blueprint. + */ + +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { + border: 0; + font-family: inherit; + font-size: 100%; + font-style: inherit; + font-weight: inherit; + margin: 0; + outline: 0; + padding: 0; + vertical-align: baseline; +} + +html { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + font-size: 62.5%; + overflow-y: scroll; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +*, +*:before, +*:after { + -webkit-box-sizing: inherit; + -moz-box-sizing: inherit; + box-sizing: inherit; +} + +body { + background: #f1f1f1; +} + +article, +aside, +details, +figcaption, +figure, +footer, +header, +main, +nav, +section { + display: block; +} + +ol, +ul { + list-style: none; +} + +table { + border-collapse: separate; + border-spacing: 0; +} + +caption, +th, +td { + font-weight: normal; + text-align: left; +} + +fieldset { + min-width: inherit; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; +} + +blockquote, +q { + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; + quotes: none; +} + +a:focus { + outline: 2px solid #c1c1c1; + outline: 2px solid rgba(51, 51, 51, 0.3); +} + +a:hover, +a:active { + outline: 0; +} + +a img { + border: 0; +} + + +/** + * 2.0 - Genericons + */ + +.social-navigation a:before, +.secondary-toggle:before, +.dropdown-toggle:after, +.bypostauthor > article .fn:after, +.comment-reply-title small a:before, +.comment-navigation .nav-next a:after, +.comment-navigation .nav-previous a:before, +.posted-on:before, +.byline:before, +.cat-links:before, +.tags-links:before, +.comments-link:before, +.entry-format:before, +.edit-link:before, +.full-size-link:before, +.pagination .prev:before, +.pagination .next:before, +.image-navigation a:before, +.image-navigation a:after, +.format-link .entry-title a:after, +.entry-content .more-link:after, +.entry-summary .more-link:after, +.author-link:after { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + display: inline-block; + font-family: "Genericons"; + font-size: 16px; + font-style: normal; + font-weight: normal; + font-variant: normal; + line-height: 1; + speak: none; + text-align: center; + text-decoration: inherit; + text-transform: none; + vertical-align: top; +} + + +/** + * 3.0 Typography + */ + +body, +button, +input, +select, +textarea { + color: #333; + font-family: "Noto Serif", serif; + font-size: 15px; + font-size: 1.5rem; + line-height: 1.6; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + font-weight: 700; +} + +p { + margin-bottom: 1.6em; +} + +b, +strong { + font-weight: 700; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + border-left: 4px solid #707070; + border-left: 4px solid rgba(51, 51, 51, 0.7); + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-size: 18px; + font-size: 1.8rem; + font-style: italic; + line-height: 1.6667; + margin-bottom: 1.6667em; + padding-left: 0.7778em; +} + +blockquote p { + margin-bottom: 1.6667em; +} + +blockquote > p:last-child { + margin-bottom: 0; +} + +blockquote cite, +blockquote small { + color: #333; + font-size: 15px; + font-size: 1.5rem; + font-family: "Noto Sans", sans-serif; + line-height: 1.6; +} + +blockquote em, +blockquote i, +blockquote cite { + font-style: normal; +} + +blockquote strong, +blockquote b { + font-weight: 400; +} + +address { + font-style: italic; + margin: 0 0 1.6em; +} + +code, +kbd, +tt, +var, +samp, +pre { + font-family: Inconsolata, monospace; + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +pre { + background-color: transparent; + background-color: rgba(0, 0, 0, 0.01); + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); + line-height: 1.2; + margin-bottom: 1.6em; + max-width: 100%; + overflow: auto; + padding: 0.8em; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +abbr[title] { + border-bottom: 1px dotted #eaeaea; + border-bottom: 1px dotted rgba(51, 51, 51, 0.1); + cursor: help; +} + +mark, +ins { + background-color: #fff9c0; + text-decoration: none; +} + +sup, +sub { + font-size: 75%; + height: 0; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + bottom: 1ex; +} + +sub { + top: .5ex; +} + +small { + font-size: 75%; +} + +big { + font-size: 125%; +} + + +/** + * 4.0 Elements + */ + +hr { + background-color: #eaeaea; + background-color: rgba(51, 51, 51, 0.1); + border: 0; + height: 1px; + margin-bottom: 1.6em; +} + +ul, +ol { + margin: 0 0 1.6em 1.3333em; +} + +ul { + list-style: disc; +} + +ol { + list-style: decimal; +} + +li > ul, +li > ol { + margin-bottom: 0; +} + +dl { + margin-bottom: 1.6em; +} + +dt { + font-weight: bold; +} + +dd { + margin-bottom: 1.6em; +} + +table, +th, +td { + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); +} + +table { + border-collapse: separate; + border-spacing: 0; + border-width: 1px 0 0 1px; + margin: 0 0 1.6em; + table-layout: fixed; /* Prevents HTML tables from becoming too wide */ + width: 100%; +} + +caption, +th, +td { + font-weight: normal; + text-align: left; +} + +th { + border-width: 0 1px 1px 0; + font-weight: 700; +} + +td { + border-width: 0 1px 1px 0; +} + +th, td { + padding: 0.4em; +} + +img { + -ms-interpolation-mode: bicubic; + border: 0; + height: auto; + max-width: 100%; + vertical-align: middle; +} + +figure { + margin: 0; +} + +del { + opacity: 0.8; +} + +/* Placeholder text color -- selectors need to be separate to work. */ + +::-webkit-input-placeholder { + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; +} + +:-moz-placeholder { + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; +} + +::-moz-placeholder { + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + opacity: 1; /* Since FF19 lowers the opacity of the placeholder by default */ +} + +:-ms-input-placeholder { + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; +} + + +/** + * 5.0 Forms + */ + +button, +input, +select, +textarea { + background-color: #f7f7f7; + border-radius: 0; + font-size: 16px; + font-size: 1.6rem; + line-height: 1.5; + margin: 0; + max-width: 100%; + vertical-align: baseline; +} + +button, +input { + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; + line-height: normal; +} + +input, +textarea { + background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0)); /* Removing the inner shadow on iOS inputs */ + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + +input:focus, +textarea:focus { + background-color: #fff; + border: 1px solid #c1c1c1; + border: 1px solid rgba(51, 51, 51, 0.3); + color: #333; +} + +input:focus, +select:focus { + outline: 2px solid #c1c1c1; + outline: 2px solid rgba(51, 51, 51, 0.3); +} + +button[disabled], +input[disabled], +select[disabled], +textarea[disabled] { + cursor: default; + opacity: .5; +} + +button, +input[type="button"], +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; + background-color: #333; + border: 0; + color: #fff; + cursor: pointer; + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 700; + padding: 0.7917em 1.5em; + text-transform: uppercase; +} + +button:hover, +input[type="button"]:hover, +input[type="reset"]:hover, +input[type="submit"]:hover, +button:focus, +input[type="button"]:focus, +input[type="reset"]:focus, +input[type="submit"]:focus { + background-color: #707070; + background-color: rgba(51, 51, 51, 0.7); + outline: 0; +} + +input[type="search"] { + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +input[type="text"], +input[type="email"], +input[type="url"], +input[type="password"], +input[type="search"], +textarea { + padding: 0.375em; + width: 100%; +} + +textarea { + overflow: auto; + vertical-align: top; +} + +input[type="text"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="password"]:focus, +input[type="search"]:focus, +textarea:focus { + outline: 0; +} + +.post-password-form { + position: relative; +} + +.post-password-form label { + color: #707070; + color: rgba(51, 51, 51, 0.7); + display: block; + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 700; + letter-spacing: 0.04em; + line-height: 1.5; + text-transform: uppercase; +} + +.post-password-form input[type="submit"] { + padding: 0.7917em; + position: absolute; + right: 0; + bottom: 0; +} + +input[type="checkbox"], +input[type="radio"] { + padding: 0; +} + +.search-form input[type="submit"], +.widget .search-form input[type="submit"] { + padding: 0; +} + + +/** + * 6.0 Navigations + */ + + +/** + * 6.1 Links + */ + +a { + color: #333; + text-decoration: none; +} + +a:hover, +a:focus { + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + + +/** + * 6.2 Menus + */ + +.main-navigation a { + display: block; + padding: 0.8em 0; + position: relative; + text-decoration: none; +} + +.main-navigation ul { + list-style: none; + margin: 0; +} + +.main-navigation ul ul { + display: none; + margin-left: 0.8em; +} + +.main-navigation ul .toggled-on { + display: block; +} + +.main-navigation li { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + position: relative; +} + +.main-navigation .current-menu-item > a, +.main-navigation .current-menu-ancestor > a { + font-weight: 700; +} + +.main-navigation .nav-menu > ul > li:first-child, +.main-navigation .nav-menu > li:first-child { + border-top: 0; +} + +.main-navigation .menu-item-has-children > a { + padding-right: 48px; +} + +.main-navigation .menu-item-description { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 400; + line-height: 1.5; + margin-top: 0.5em; +} + +.no-js .main-navigation ul ul { + display: block; +} + +.dropdown-toggle { + background-color: transparent; + border: 0; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + content: ""; + height: 42px; + padding: 0; + position: absolute; + text-transform: lowercase; /* Stop screen readers to read the text as capital letters */ + top: 3px; + right: 0; + width: 42px; +} + +.dropdown-toggle:after { + color: #333; + content: "\f431"; + font-size: 24px; + line-height: 42px; + position: relative; + top: 0; + left: 1px; + width: 42px; +} + +.dropdown-toggle:hover, +.dropdown-toggle:focus { + background-color: #eaeaea; + background-color: rgba(51, 51, 51, 0.1); +} + +.dropdown-toggle:focus { + outline: 1px solid #c1c1c1; + outline: 1px solid rgba(51, 51, 51, 0.3); +} + +.dropdown-toggle.toggle-on:after { + content: "\f432"; +} + +.social-navigation { + margin: 9.0909% 0; +} + +.social-navigation ul { + list-style: none; + margin: 0 0 -1.6em 0; +} + +.social-navigation li { + float: left; +} + +.social-navigation a { + display: block; + height: 3.2em; + position: relative; + width: 3.2em; +} + +.social-navigation a:before { + content: "\f415"; + font-size: 24px; + position: absolute; + top: 0; + left: 0; +} + +.social-navigation a[href*="codepen.io"]:before { + content: "\f216"; +} + +.social-navigation a[href*="digg.com"]:before { + content: "\f221"; +} + +.social-navigation a[href*="dribbble.com"]:before { + content: "\f201"; +} + +.social-navigation a[href*="dropbox.com"]:before { + content: "\f225"; +} + +.social-navigation a[href*="facebook.com"]:before { + content: "\f203"; +} + +.social-navigation a[href*="flickr.com"]:before { + content: "\f211"; +} + +.social-navigation a[href*="foursquare.com"]:before { + content: "\f226"; +} + +.social-navigation a[href*="plus.google.com"]:before { + content: "\f206"; +} + +.social-navigation a[href*="github.com"]:before { + content: "\f200"; +} + +.social-navigation a[href*="instagram.com"]:before { + content: "\f215"; +} + +.social-navigation a[href*="linkedin.com"]:before { + content: "\f208"; +} + +.social-navigation a[href*="pinterest.com"]:before { + content: "\f210"; +} + +.social-navigation a[href*="getpocket.com"]:before { + content: "\f224"; +} + +.social-navigation a[href*="polldaddy.com"]:before { + content: "\f217"; +} + +.social-navigation a[href*="reddit.com"]:before { + content: "\f222"; +} + +.social-navigation a[href*="stumbleupon.com"]:before { + content: "\f223"; +} + +.social-navigation a[href*="tumblr.com"]:before { + content: "\f214"; +} + +.social-navigation a[href*="twitter.com"]:before { + content: "\f202"; +} + +.social-navigation a[href*="vimeo.com"]:before { + content: "\f212"; +} + +.social-navigation a[href*="wordpress.com"]:before, +.social-navigation a[href*="wordpress.org"]:before { + content: "\f205"; +} + +.social-navigation a[href*="youtube.com"]:before { + content: "\f213"; +} + +.social-navigation a[href*="mailto:"]:before { + content: "\f410"; +} + +.social-navigation a[href*="spotify.com"]:before { + content: "\f515"; +} + +.social-navigation a[href*="twitch.tv"]:before { + content: "\f516"; +} + +.social-navigation a[href$="/feed/"]:before { + content: "\f413"; +} + +.social-navigation a[href*="path.com"]:before { + content: "\f219"; +} + +.social-navigation a[href*="skype.com"]:before { + content: "\f220"; +} + +.secondary-toggle { + background-color: transparent; + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); + height: 42px; + overflow: hidden; + padding: 0; + position: absolute; + top: 50%; + right: 0; + text-align: center; + -webkit-transform: translateY(-50%); + -ms-transform: translateY(-50%); + transform: translateY(-50%); + width: 42px; +} + +.secondary-toggle:before { + color: #333; + content: "\f419"; + line-height: 40px; + width: 40px; +} + +.secondary-toggle:hover, +.secondary-toggle:focus { + background-color: transparent; + border: 1px solid #c1c1c1; + border: 1px solid rgba(51, 51, 51, 0.3); + outline: 0; +} + +.secondary-toggle.toggled-on:before { + content: "\f405"; + font-size: 32px; + position: relative; + top: 1px; + left: -1px; +} + +.post-navigation { + background-color: #fff; + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + font-weight: 700; +} + +.post-navigation a { + display: block; + padding: 3.8461% 7.6923%; +} + +.post-navigation span { + display: block; +} + +.post-navigation .meta-nav { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + letter-spacing: 0.04em; + line-height: 1.5; + position: relative; + text-transform: uppercase; + z-index: 2; +} + +.post-navigation .post-title { + font-family: "Noto Serif", serif; + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + position: relative; + z-index: 2; +} + +.post-navigation .nav-next, +.post-navigation .nav-previous { + background-position: center; + background-size: cover; + position: relative; +} + +.post-navigation a:before { + content: ""; + display: block; + height: 100%; + position: absolute; + top: 0; + left: 0; + width: 100%; + z-index: 1; +} + +.post-navigation a:hover:before, +.post-navigation a:focus:before { + opacity: 0.5; +} + +.post-navigation .meta-nav { + opacity: 0.8; +} + +.post-navigation div + div { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); +} + +.pagination { + background-color: #fff; + border-top: 1px solid rgba(51, 51, 51, 0.1); + font-family: "Noto Sans", sans-serif; +} + +.pagination .nav-links { + min-height: 3.2em; + position: relative; + text-align: center; +} + +/* reset screen-reader-text */ +.pagination .current .screen-reader-text { + position: static !important; +} + +.pagination .page-numbers { + display: none; + line-height: 3.2em; + padding: 0 0.6667em; +} + +.pagination .page-numbers.current { + text-transform: uppercase; +} + +.pagination .current { + display: inline-block; + font-weight: 700; +} + +.pagination .prev, +.pagination .next { + -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3); + background-color: #333; + color: #fff; + display: inline-block; + height: 48px; + overflow: hidden; + padding: 0; + position: absolute; + width: 48px; +} + +.pagination .prev:before, +.pagination .next:before { + font-size: 32px; + height: 48px; + line-height: 48px; + position: relative; + width: 48px; +} + +.pagination .prev:hover, +.pagination .prev:focus, +.pagination .next:hover, +.pagination .next:focus { + background-color: #707070; + background-color: rgba(51, 51, 51, 0.7); +} + +.pagination .prev { + left: 0; +} + +.pagination .prev:before { + content: "\f430"; + left: -1px; +} + +.pagination .next { + right: 0; +} + +.pagination .next:before { + content: "\f429"; + right: -1px; +} + +.image-navigation, +.comment-navigation { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-size: 12px; + font-size: 1.2rem; + font-family: "Noto Sans", sans-serif; + font-weight: 700; + line-height: 1.5; + text-transform: uppercase; +} + +.image-navigation a, +.comment-navigation a { + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + +.image-navigation a:hover, +.image-navigation a:focus, +.comment-navigation a:hover, +.comment-navigation a:focus { + color: #333; +} + +.image-navigation .nav-previous:not(:empty), +.image-navigation .nav-next:not(:empty), +.comment-navigation .nav-previous:not(:empty), +.comment-navigation .nav-next:not(:empty) { + display: inline-block; +} + +.image-navigation .nav-previous:not(:empty) + .nav-next:not(:empty):before, +.comment-navigation .nav-previous:not(:empty) + .nav-next:not(:empty):before { + content: "\2215"; + font-weight: 400; + margin: 0 0.7em; +} + +.image-navigation .nav-previous a:before, +.comment-navigation .nav-previous a:before { + content: "\f430"; + margin-right: 0.2em; + position: relative; +} + +.image-navigation .nav-next a:after, +.comment-navigation .nav-next a:after { + content: "\f429"; + margin-left: 0.2em; + position: relative; +} + +.comment-navigation { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + border-bottom: 1px solid #eaeaea; + border-bottom: 1px solid rgba(51, 51, 51, 0.1); + padding: 2em 0; +} + +.comments-title + .comment-navigation { + border-bottom: 0; +} + +.image-navigation { + padding: 0 7.6923%; +} + +.image-navigation .nav-previous:not(:empty), +.image-navigation .nav-next:not(:empty) { + margin-bottom: 2em; +} + + +/** + * 7.0 Accessibility + */ + +/* Text meant only for screen readers */ +.says, +.screen-reader-text { + clip: rect(1px, 1px, 1px, 1px); + height: 1px; + overflow: hidden; + position: absolute !important; + width: 1px; +} + +/* must have higher specificity than alternative color schemes inline styles */ +.site .skip-link { + background-color: #f1f1f1; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2); + color: #21759b; + display: block; + font: bold 14px/normal "Noto Sans", sans-serif; + left: -9999em; + outline: none; + padding: 15px 23px 14px; + text-decoration: none; + text-transform: none; + top: -9999em; +} + +.logged-in .site .skip-link { + box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); + font: bold 14px/normal "Open Sans", sans-serif; +} + +.site .skip-link:focus { + clip: auto; + height: auto; + left: 6px; + top: 7px; + width: auto; + z-index: 100000; +} + + +/** + * 8.0 Alignments + */ + +.alignleft { + display: inline; + float: left; +} + +.alignright { + display: inline; + float: right; +} + +.aligncenter { + display: block; + margin-right: auto; + margin-left: auto; +} + +blockquote.alignleft, +.wp-caption.alignleft, +img.alignleft { + margin: 0.4em 1.6em 1.6em 0; +} + +blockquote.alignright, +.wp-caption.alignright, +img.alignright { + margin: 0.4em 0 1.6em 1.6em; +} + +blockquote.aligncenter, +.wp-caption.aligncenter, +img.aligncenter { + clear: both; + margin-top: 0.4em; + margin-bottom: 1.6em; +} + +.wp-caption.alignleft, +.wp-caption.alignright, +.wp-caption.aligncenter { + margin-bottom: 1.2em; +} + + +/** + * 9.0 Clearings + */ + +.clear:before, +.clear:after, +.site:before, +.site:after, +.entry-content:before, +.entry-content:after, +.comment-content:before, +.comment-content:after, +.site-content:before, +.site-content:after, +.nav-links:before, +.nav-links:after, +.comment-navigation:before, +.comment-navigation:after, +.social-navigation ul:before, +.social-navigation ul:after, +.textwidget:before, +.textwidget:after { + content: ""; + display: table; +} + +.clear:after, +.site:after, +.entry-content:after, +.comment-content:after, +.site-content:after, +.nav-links:after, +.comment-navigation:after, +.social-navigation ul:after, +.textwidget:after { + clear: both; +} + + +/** + * 10.0 Header + */ + +.site-header { + background-color: #fff; + border-bottom: 1px solid rgba(51, 51, 51, 0.1); + padding: 7.6923%; +} + +.site-branding { + min-height: 2em; + padding-right: 60px; + position: relative; +} + +.site-title { + font-family: "Noto Sans", sans-serif; + font-size: 22px; + font-size: 2.2rem; + font-weight: 700; + line-height: 1.3636; + margin-bottom: 0; +} + +.custom-logo { + max-height: 84px; + width: auto; +} + +.wp-custom-logo .site-title { + margin-top: 0.545454545em; +} + +.site-description { + display: none; + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 400; + line-height: 1.5; + margin: 0.5em 0 0; + opacity: 0.7; +} + + +/** + * 11.0 Widgets + */ + +.widget { + color: #707070; + color: rgba(51, 51, 51, 0.7); + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + margin: 0 auto 9.09090%; + width: 100%; + word-wrap: break-word; +} + +.widget pre { + line-height: 1.2; +} + +.widget button, +.widget input, +.widget select, +.widget textarea { + font-size: 16px; + font-size: 1.6rem; + line-height: 1.5; +} + +.widget button, +.widget input { + line-height: normal; +} + +.widget button, +.widget input[type="button"], +.widget input[type="reset"], +.widget input[type="submit"] { + font-size: 12px; + font-size: 1.2rem; + padding: 0.7917em 1.5833em; +} + +.widget input[type="text"], +.widget input[type="email"], +.widget input[type="url"], +.widget input[type="password"], +.widget input[type="search"], +.widget textarea { + padding: 0.375em; +} + +.widget-title { + color: #333; + font-family: "Noto Sans", sans-serif; + margin: 0 0 1.6em; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.widget > :last-child { + margin-bottom: 0; +} + +.widget_calendar table { + margin: 0; +} + +.widget_calendar td, +.widget_calendar th { + line-height: 2.3333; + text-align: center; + padding: 0; +} + +.widget_calendar caption { + font-family: "Noto Serif", serif; + font-weight: 700; + margin: 0 0 1.6em; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.widget_calendar tbody a { + -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3); + background-color: #333; + color: #fff; + display: block; + font-weight: 700; +} + +.widget_calendar tbody a:hover, +.widget_calendar tbody a:focus { + background-color: #707070; + background-color: rgba(51, 51, 51, 0.7); + color: #fff; +} + +.widget_archive a, +.widget_categories a, +.widget_links a, +.widget_meta a, +.widget_nav_menu a, +.widget_pages a, +.widget_recent_comments a, +.widget_recent_entries a { + border: 0; +} + +.widget_archive ul, +.widget_categories ul, +.widget_links ul, +.widget_meta ul, +.widget_nav_menu ul, +.widget_pages ul, +.widget_recent_comments ul, +.widget_recent_entries ul { + list-style: none; + margin: 0; +} + +.widget_archive li, +.widget_categories li, +.widget_links li, +.widget_meta li, +.widget_nav_menu li, +.widget_pages li, +.widget_recent_comments li, +.widget_recent_entries li { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + padding: 0.7667em 0; +} + +.widget_archive li:first-child, +.widget_categories li:first-child, +.widget_links li:first-child, +.widget_meta li:first-child, +.widget_nav_menu li:first-child, +.widget_pages li:first-child, +.widget_recent_comments li:first-child, +.widget_recent_entries li:first-child { + border-top: 0; + padding-top: 0; +} + +.widget_archive li:last-child, +.widget_categories li:last-child, +.widget_links li:last-child, +.widget_meta li:last-child, +.widget_nav_menu li:last-child, +.widget_pages li:last-child, +.widget_recent_comments li:last-child, +.widget_recent_entries li:last-child { + padding-bottom: 0; +} + +.widget_categories .children, +.widget_nav_menu .sub-menu, +.widget_pages .children { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + margin: 0.7667em 0 0 0.8em; + padding-top: 0.7667em; +} + +.widget_recent_entries .post-date { + display: block; +} + +.widget_rss ul { + list-style: none; + margin: 0; +} + +.widget_rss li { + margin-bottom: 1.6em; +} + +.widget_rss ul:last-child, +.widget_rss li:last-child { + margin-bottom: 0; +} + +.widget_rss .rsswidget { + border: 0; + font-weight: 700; +} + +.widget_rss .rsswidget img { + margin-top: -4px; +} + +.widget_rss .rss-date, +.widget_rss cite { + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-style: normal; + display: block; + line-height: 2; + opacity: 0.8; +} + +.textwidget > :last-child { + margin-bottom: 0; +} + +.textwidget a { + border-bottom: 1px solid #333; +} + +.textwidget a:hover, +.textwidget a:focus { + border-bottom: 0; +} + +.textwidget ul, +.textwidget ol { + margin-left: 1.6em; +} + +.tagcloud ul { + list-style-type: none; +} + +.tagcloud ul li { + display: inline-block; +} + +/** + * 12.0 Content + */ + +.secondary { + background-color: #fff; + display: none; + padding: 0 7.6923%; +} + +.secondary.toggled-on { + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + display: block; +} + +.widget-area { + margin: 9.09090% auto 0; +} + +.site-footer { + background-color: #fff; + border-top: 1px solid rgba(51, 51, 51, 0.1); + padding: 3.84615% 7.6923%; +} + + +/** + * 12.1 Posts and pages + */ + +.hentry { + background-color: #fff; + padding-top: 7.6923%; + position: relative; +} + +.hentry.has-post-thumbnail { + padding-top: 0; +} + +.hentry.sticky:not(.has-post-thumbnail) { + padding-top: -webkit-calc(7.6923% + 24px); + padding-top: calc(7.6923% + 24px); +} + +.hentry + .hentry { + border-top: 1px solid rgba(51, 51, 51, 0.1); +} + +.post-thumbnail { + border: 0; + display: block; + margin-bottom: 2.4em; +} +.post-thumbnail img { + display: block; + margin: 0 auto; +} + +a.post-thumbnail:hover, +a.post-thumbnail:focus { + opacity: 0.85; +} + +.entry-header { + padding: 0 7.6923%; +} + +.entry-title { + font-size: 26px; + font-size: 2.6rem; + line-height: 1.1538; + margin-bottom: 0.9231em; +} + +.entry-content, +.entry-summary { + padding: 0 7.6923% 7.6923%; +} + +.entry-content > :last-child, +.entry-summary > :last-child { + margin-bottom: 0; +} + +.entry-content, +.entry-summary, +.page-content, +.comment-content { + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + word-wrap: break-word; +} + +.entry-content h1, +.entry-summary h1, +.page-content h1, +.comment-content h1 { + font-size: 26px; + font-size: 2.6rem; + line-height: 1.1538; + margin-top: 1.8462em; + margin-bottom: 0.9231em; +} + +.entry-content h2, +.entry-summary h2, +.page-content h2, +.comment-content h2 { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.3636; + margin-top: 2.1818em; + margin-bottom: 1.0909em; +} + +.entry-content h3, +.entry-summary h3, +.page-content h3, +.comment-content h3 { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + margin-top: 2.6667em; + margin-bottom: 1.3333em; +} + +.entry-content h4, +.entry-content h5, +.entry-content h6, +.entry-summary h4, +.entry-summary h5, +.entry-summary h6, +.page-content h4, +.page-content h5, +.page-content h6, +.comment-content h4, +.comment-content h5, +.comment-content h6 { + font-size: 15px; + font-size: 1.5rem; + line-height: 1.2; + margin-top: 3.2em; + margin-bottom: 1.6em; +} + +.entry-content h5, +.entry-content h6, +.entry-summary h5, +.entry-summary h6, +.page-content h5, +.page-content h6, +.comment-content h5, +.comment-content h6 { + letter-spacing: 0.1em; + text-transform: uppercase; +} + +.entry-content > h1:first-child, +.entry-content > h2:first-child, +.entry-content > h3:first-child, +.entry-content > h4:first-child, +.entry-content > h5:first-child, +.entry-content > h6:first-child, +.entry-summary > h1:first-child, +.entry-summary > h2:first-child, +.entry-summary > h3:first-child, +.entry-summary > h4:first-child, +.entry-summary > h5:first-child, +.entry-summary > h6:first-child, +.page-content > h1:first-child, +.page-content > h2:first-child, +.page-content > h3:first-child, +.page-content > h4:first-child, +.page-content > h5:first-child, +.page-content > h6:first-child, +.comment-content > h1:first-child, +.comment-content > h2:first-child, +.comment-content > h3:first-child, +.comment-content > h4:first-child, +.comment-content > h5:first-child, +.comment-content > h6:first-child { + margin-top: 0; +} + +.entry-content a, +.entry-summary a, +.page-content a, +.comment-content a, +.pingback .comment-body > a { + border-bottom: 1px solid #333; +} + +.entry-content a:hover, +.entry-content a:focus, +.entry-summary a:hover, +.entry-summary a:focus, +.page-content a:hover, +.page-content a:focus, +.comment-content a:hover, +.comment-content a:focus, +.pingback .comment-body > a:hover, +.pingback .comment-body > a:focus { + border-bottom: 0; +} + +.entry-content a img, +.entry-summary a img, +.page-content a img, +.comment-content a img { + display: block; +} + +.entry-content .more-link, +.entry-summary .more-link:after { + white-space: nowrap; +} + +.entry-content .more-link:after, +.entry-summary .more-link:after { + content: "\f429"; + font-size: 16px; + position: relative; + top: 5px; +} + +.author-info { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + margin: 0 7.6923%; + padding: 7.6923% 0; +} + +.author-info .avatar { + float: left; + height: 36px; + margin: 0 1.6em 1.6em 0; + width: 36px; +} + +.author-heading { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + letter-spacing: 0.04em; + margin-bottom: 1.5em; + text-transform: uppercase; +} + +.author-title { + clear: none; +} + +.author-bio { + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + overflow: hidden; + padding-bottom: 1px; +} + +.author-description { + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + word-wrap: break-word; +} + +.author-description a { + border-bottom: 1px solid #333; +} + +.author-description a:hover, +.author-description a:focus { + border-bottom: 0; +} + +.author-description > :last-child { + margin-bottom: 0; +} + +.author-link { + white-space: nowrap; +} + +.author-link:after { + content: "\f429"; + position: relative; + top: 1px; +} + +.entry-footer { + background-color: #f7f7f7; + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + padding: 3.8461% 7.6923%; +} + +.entry-footer a { + border-bottom: 1px solid transparent; + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + +.entry-footer a:hover { + border-bottom: 1px solid #333; +} + +.entry-footer a:hover, +.entry-footer a:focus { + color: #333; +} + +.sticky-post { + background-color: #333; + color: #fff; + font-weight: 700; + letter-spacing: 0.04em; + padding: 0.25em 0.5em; + position: absolute; + top: 0; + text-transform: uppercase; +} + +.updated:not(.published) { + display: none; +} + +.sticky .posted-on { + display: none; +} + +.posted-on:before, +.byline:before, +.cat-links:before, +.tags-links:before, +.comments-link:before, +.entry-format:before, +.edit-link:before, +.full-size-link:before { + margin-right: 2px; + position: relative; +} + +.posted-on, +.byline, +.cat-links, +.tags-links, +.comments-link, +.entry-format, +.full-size-link { + margin-right: 1em; +} + +.format-aside .entry-format:before { + content: "\f101"; +} + +.format-image .entry-format:before { + content: "\f473"; +} + +.format-gallery .entry-format:before { + content: "\f103"; +} + +.format-video .entry-format:before { + content: "\f104"; +} + +.format-status .entry-format:before { + content: "\f105"; +} + +.format-quote .entry-format:before { + content: "\f106"; +} + +.format-link .entry-format:before { + content: "\f107"; +} + +.format-chat .entry-format:before { + content: "\f108"; +} + +.format-audio .entry-format:before { + content: "\f109"; +} + +.posted-on:before { + content: "\f307"; +} + +.byline:before { + content: "\f304"; +} + +.cat-links:before { + content: "\f301"; +} + +.tags-links:before { + content: "\f302"; +} + +.comments-link:before { + content: "\f300"; +} + +.full-size-link:before { + content: "\f402"; +} + +.edit-link:before { + content: "\f411"; +} + +.comments-link, +.edit-link { + white-space: nowrap; +} + +.page-header { + background-color: #fff; + border-bottom: 1px solid rgba(51, 51, 51, 0.1); + padding: 7.6923%; +} + +.page-title { + font-family: "Noto Serif", serif; + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; +} + +.taxonomy-description { + color: #707070; + color: rgba(51, 51, 51, 0.7); + padding-top: 0.4em; +} + +.taxonomy-description a { + border-bottom: 1px solid #333; +} + +.taxonomy-description a:hover, +.taxonomy-description a:focus { + border-bottom: 0; +} + +.taxonomy-description > :last-child { + margin-bottom: 0; +} + +.page-content { + background-color: #fff; + padding: 7.6923%; +} + +.page-content > :last-child { + margin-bottom: 0; +} + +.page-links { + clear: both; + font-family: "Noto Sans", sans-serif; + margin-bottom: 1.3333em; +} + +.page-links a, +.page-links > span { + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); + display: inline-block; + font-size: 12px; + font-size: 1.2rem; + height: 2em; + line-height: 2; + margin: 0 0.3333em 0.3333em 0; + text-align: center; + width: 2em; +} + +.page-links a { + -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3); + background-color: #333; + border-color: #333; + color: #fff; +} + +.page-links a:hover, +.page-links a:focus { + background-color: #707070; + background-color: rgba(51, 51, 51, 0.7); + border-color: transparent; + color: #fff; +} + +.page-links > .page-links-title { + border: 0; + color: #707070; + color: rgba(51, 51, 51, 0.7); + height: auto; + margin: 0; + padding-right: 0.5em; + width: auto; +} + +.entry-attachment { + margin-bottom: 1.6em; +} + +.type-attachment .entry-title { + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + word-wrap: break-word; +} + +.entry-caption { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; + line-height: 1.5; + padding-top: 0.5em; + word-wrap: break-word; +} + +.entry-caption > :last-child { + margin-bottom: 0; +} + + +/** + * 12.2 Post Formats + */ + +.format-aside .entry-title, +.format-image .entry-title, +.format-video .entry-title, +.format-quote .entry-title, +.format-gallery .entry-title, +.format-status .entry-title, +.format-link .entry-title, +.format-audio .entry-title, +.format-chat .entry-title { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + margin-bottom: 1.3333em; +} + +.format-link .entry-title a:after { + content: "\f442"; + font-size: 24px; + height: 24px; + position: relative; + top: 0; + width: 24px; +} + +.blog .format-status .entry-title, +.archive .format-status .entry-title { + display: none; +} + + +/** + * 12.3 Comments + */ + +.comments-area { + background-color: #fff; + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + padding: 7.6923%; +} + +.comments-area > :last-child { + margin-bottom: 0; +} + +.comment-list + .comment-respond { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); +} + +.comment-list + .comment-respond, +.comment-navigation + .comment-respond { + padding-top: 1.6em; +} + +.comments-title, +.comment-reply-title { + font-family: "Noto Serif", serif; + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; +} + +.comments-title { + margin-bottom: 1.3333em; +} + +.comment-list { + list-style: none; + margin: 0; +} + +.comment-list article, +.comment-list .pingback, +.comment-list .trackback { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + padding: 1.6em 0; +} + +.comment-list .children { + list-style: none; + margin: 0; +} + +.comment-list .children > li { + padding-left: 0.8em; +} + +.comment-author { + color: #707070; + color: rgba(51, 51, 51, 0.7); + margin-bottom: 0.4em; +} + +.comment-author a:hover { + border-bottom: 1px solid #707070; + border-bottom: 1px solid rgba(51, 51, 51, 0.7); +} + +.comment-author .avatar { + float: left; + height: 24px; + margin-right: 0.8em; + width: 24px; +} + +.bypostauthor > article .fn:after { + content: "\f304"; + position: relative; + top: 5px; + left: 3px; +} + +.comment-metadata, +.pingback .edit-link { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; +} + +.comment-metadata a, +.pingback .edit-link a { + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + +.comment-metadata a:hover, +.pingback .edit-link a:hover { + border-bottom: 1px solid #333; +} + +.comment-metadata a:hover, +.comment-metadata a:focus, +.pingback .edit-link a:hover, +.pingback .edit-link a:focus { + color: #333; +} + +.comment-metadata { + margin-bottom: 1.6em; +} + +.comment-metadata .edit-link { + margin-left: 1em; +} + +.pingback .edit-link { + margin-left: 1em; +} + +.pingback .edit-link:before { + top: 5px; +} + +.comment-content ul, +.comment-content ol { + margin: 0 0 1.6em 1.3333em; +} + +.comment-content li > ul, +.comment-content li > ol { + margin-bottom: 0; +} + +.comment-content > :last-child { + margin-bottom: 0; +} + +.comment-list .reply { + font-size: 12px; + font-size: 1.2rem; +} + +.comment-list .reply a { + border: 1px solid #eaeaea; + border: 1px solid rgba(51, 51, 51, 0.1); + color: #707070; + color: rgba(51, 51, 51, 0.7); + display: inline-block; + font-family: "Noto Sans", sans-serif; + font-weight: 700; + line-height: 1; + margin-top: 2em; + padding: 0.4167em 0.8333em; + text-transform: uppercase; +} + +.comment-list .reply a:hover, +.comment-list .reply a:focus { + border-color: #333; + color: #333; + outline: 0; +} + +.comment-form { + padding-top: 1.6em; +} + +.comment-form label { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 700; + display: block; + letter-spacing: 0.04em; + line-height: 1.5; + text-transform: uppercase; +} + +.comment-form input[type="text"], +.comment-form input[type="email"], +.comment-form input[type="url"], +.comment-form input[type="submit"] { + width: 100%; +} + +.comment-notes, +.comment-awaiting-moderation, +.logged-in-as, +.form-allowed-tags { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + margin-bottom: 2em; +} + +.logged-in-as a:hover { + border-bottom: 1px solid #333; +} + +.no-comments { + border-top: 1px solid #eaeaea; + border-top: 1px solid rgba(51, 51, 51, 0.1); + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-weight: 700; + padding-top: 1.6em; +} + +.comment-navigation + .no-comments { + border-top: 0; +} + +.form-allowed-tags code { + font-family: Inconsolata, monospace; +} + +.form-submit { + margin-bottom: 0; +} + +.required { + color: #c0392b; +} + +.comment-reply-title small { + font-size: 100%; +} + +.comment-reply-title small a { + border: 0; + float: right; + height: 32px; + overflow: hidden; + width: 26px; +} + +.comment-reply-title small a:before { + content: "\f405"; + font-size: 32px; + position: relative; + top: -3px; +} + +.comment-form #wp-comment-cookies-consent { + margin: 0 10px 0 0; +} + +.comment-form .comment-form-cookies-consent label { + display: inline; + font-size: 12px; + font-size: 1.2rem; + font-weight: normal; + letter-spacing: 0; + text-transform: none; +} + +/** + * 13.0 Footer + */ + +.site-info { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; +} + +.site-info a { + border-bottom: 1px solid transparent; + color: #707070; + color: rgba(51, 51, 51, 0.7); +} + +.site-info a:hover { + border-bottom: 1px solid #333; +} + +.site-info a:hover, +.site-info a:focus { + color: #333; +} + +.site-info span[role=separator] { + padding: 0 0.25em 0 0.5em; +} + +.site-info span[role=separator]::before { + content: '\002f'; +} + +/** + * 14.0 Media + */ + +.site .avatar { + border-radius: 50%; +} + +.page-content img.wp-smiley, +.entry-content img.wp-smiley, +.comment-content img.wp-smiley { + border: none; + margin-top: 0; + margin-bottom: 0; + padding: 0; +} + +audio, +canvas { + display: inline-block; +} + +embed, +iframe, +object, +video { + margin-bottom: 1.6em; + max-width: 100%; + vertical-align: middle; +} + +p > embed, +p > iframe, +p > object, +p > video { + margin-bottom: 0; +} + +.wp-audio-shortcode, +.wp-video, +.wp-playlist.wp-audio-playlist { + font-size: 15px; + font-size: 1.5rem; + margin-top: 0; + margin-bottom: 1.6em; +} + +.wp-playlist.wp-playlist { + padding-bottom: 0; +} + +.wp-playlist .wp-playlist-tracks { + margin-top: 0; +} + +.wp-playlist-item .wp-playlist-caption { + border-bottom: 0; + padding: 10px 0; +} + +.wp-playlist-item .wp-playlist-item-length { + top: 10px; +} + + +/** + * 14.1 Captions + */ + +.wp-caption { + margin-bottom: 1.6em; + max-width: 100%; +} + +.wp-caption img[class*="wp-image-"] { + display: block; + margin: 0; +} + +.wp-caption-text { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + padding: 0.5em 0; +} + + +/** + * 14.2 Galleries + */ + +.gallery { + margin-bottom: 1.6em; +} + +.gallery-item { + display: inline-block; + padding: 1.79104477%; + text-align: center; + vertical-align: top; + width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-columns-3 .gallery-item { + max-width: 33.33%; +} + +.gallery-columns-4 .gallery-item { + max-width: 25%; +} + +.gallery-columns-5 .gallery-item { + max-width: 20%; +} + +.gallery-columns-6 .gallery-item { + max-width: 16.66%; +} + +.gallery-columns-7 .gallery-item { + max-width: 14.28%; +} + +.gallery-columns-8 .gallery-item { + max-width: 12.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 11.11%; +} + +.gallery-icon img { + margin: 0 auto; +} + +.gallery-caption { + color: #707070; + color: rgba(51, 51, 51, 0.7); + display: block; + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + padding: 0.5em 0; +} + +.gallery-columns-6 .gallery-caption, +.gallery-columns-7 .gallery-caption, +.gallery-columns-8 .gallery-caption, +.gallery-columns-9 .gallery-caption { + display: none; +} + + +/** + * 15.0 Multisite + */ + +.widecolumn { + background-color: #fff; + padding: 7.6923%; +} + +.widecolumn .mu_register { + width: auto; +} + +.widecolumn .mu_alert { + margin-bottom: 1.6em; +} + +.widecolumn form, +.widecolumn .mu_register form { + margin-top: 0; +} + +.widecolumn h2 { + font-size: 26px; + font-size: 2.6rem; + line-height: 1.1538; + margin-bottom: 0.9231em; +} + +.widecolumn p { + margin: 1.6em 0; +} + +.widecolumn p + h2 { + margin-top: 1.8462em; +} + +.widecolumn label, +.widecolumn .mu_register label { + color: #707070; + color: rgba(51, 51, 51, 0.7); + font-family: "Noto Sans", sans-serif; + font-size: 12px; + font-size: 1.2rem; + font-weight: 700; + letter-spacing: 0.04em; + line-height: 1.5; + text-transform: uppercase; +} + +.widecolumn .mu_register label { + margin: 2em 0 0; +} + +.widecolumn #key, +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #blogname, +.widecolumn .mu_register #user_name { + font-size: 16px; + font-size: 1.6rem; + width: 100%; +} + +.widecolumn .mu_register #blogname { + margin: 0; +} + +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #user_name { + margin: 0 0 0.375em; +} + +.widecolumn #submit, +.widecolumn .mu_register input[type="submit"] { + font-size: 12px; + font-size: 1.2rem; + margin: 0; + width: 100%; +} + +.widecolumn .mu_register .prefix_address, +.widecolumn .mu_register .suffix_address { + font-size: inherit; +} + +.widecolumn .mu_register > :last-child, +.widecolumn form > :last-child { + margin-bottom: 0; +} + + +/** + * 16.0 Media Queries + */ + +/* + * Does the same thing as , + * but in the future W3C standard way. -ms- prefix is required for IE10+ to + * render responsive styling in Windows 8 "snapped" views; IE10+ does not honor + * the meta tag. See https://core.trac.wordpress.org/ticket/25888. + */ +@-ms-viewport { + width: device-width; +} + +@viewport { + width: device-width; +} + +/** + * 16.1 Mobile Large 620px + */ + +@media screen and (min-width: 38.75em) { + ul, + ol { + margin-left: 0; + } + + li > ul, + li > ol, + blockquote > ul, + blockquote > ol { + margin-left: 1.3333em; + } + + blockquote { + margin-left: -1em; + } + + blockquote > blockquote { + margin-left: 0; + } + + .site-branding { + min-height: 3.2em; + } + + .site-title { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.0909; + } + + .site-description { + display: block; + } + + .secondary { + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 7.6923% 7.6923% 0; + padding: 7.6923% 7.6923% 0; + } + + .main-navigation { + margin-bottom: 11.1111%; + } + + .main-navigation ul { + border-top: 1px solid rgba(51, 51, 51, 0.1); + border-bottom: 1px solid rgba(51, 51, 51, 0.1); + } + + .main-navigation ul ul { + border-top: 0; + border-bottom: 0; + } + + .social-navigation { + margin-bottom: 11.1111%; + } + + .social-navigation { + margin-top: 0; + } + + .widget-area { + margin-top: 0; + } + + .widget { + margin-bottom: 11.1111%; + } + + .site-main { + padding: 7.6923% 0; + } + + .hentry.sticky:not(.has-post-thumbnail) { + padding-top: inherit; + } + + .hentry, + .page-header, + .page-content { + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 0 7.6923%; + } + + .hentry + .hentry, + .page-header + .hentry, + .page-header + .page-content { + margin-top: 7.6923%; + } + + .hentry + .hentry { + border-top: 0; + } + + .post-thumbnail { + margin-bottom: 2.4em; + } + + .entry-header { + padding: 0 9.0909%; + } + + .entry-content, + .entry-summary { + padding: 0 9.0909% 9.0909%; + } + + .entry-footer { + padding: 4.5454% 9.0909%; + } + + .page-header { + border-bottom: 0; + border-left: 7px solid #333; + padding: 3.8461% 7.6923%; + } + + .page-title, + .taxonomy-description { + margin-left: -7px; + } + + .page-content { + padding: 9.0909%; + } + + .site-footer { + border-top: 0; + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 0 7.6923%; + padding: 3.84615% 7.6923%; + } + + .post-navigation { + border-top: 0; + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 7.6923% 7.6923% 0; + } + + .post-navigation a { + padding: 4.5454% 9.0909%; + } + + .pagination { + border-top: 0; + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 7.6923% 7.6923% 0; + padding: 0; + } + + /* restore screen-reader-text */ + .pagination .current .screen-reader-text { + position: absolute !important; + } + + .pagination .page-numbers { + display: inline-block; + } + + .image-navigation { + padding: 0 9.0909%; + } + + .comments-area { + border-top: 0; + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 7.6923% 7.6923% 0; + } + + .comment-content ul, + .comment-content ol { + margin-left: 0; + } + + .comment-content li > ul, + .comment-content li > ol, + .comment-content blockquote > ul, + .comment-content blockquote > ol { + margin-left: 1.3333em; + } + + .widecolumn { + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + margin: 7.6923%; + } +} + + +/** + * 16.2 Tablet Small 740px + */ + +@media screen and (min-width: 46.25em) { + body, + button, + input, + select, + textarea { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.6471; + } + + button, + input { + line-height: normal; + } + + p, + address, + pre, + hr, + ul, + ol, + dl, + dd, + table { + margin-bottom: 1.6471em; + } + + blockquote { + font-size: 20px; + font-size: 2rem; + line-height: 1.75; + margin-bottom: 1.75em; + margin-left: -1.05em; + padding-left: 0.85em; + } + + blockquote p { + margin-bottom: 1.75em; + } + + blockquote cite, + blockquote small { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.6471; + } + + pre { + line-height: 1.2353; + } + + button, + input[type="button"], + input[type="reset"], + input[type="submit"], + .post-password-form input[type="submit"], + .widecolumn #submit, + .widecolumn .mu_register input[type="submit"] { + font-size: 14px; + font-size: 1.4rem; + padding: 0.8214em 1.6429em; + } + + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + textarea { + padding: 0.5em; + } + + .main-navigation { + font-size: 14px; + font-size: 1.4rem; + line-height: 1.5; + } + + .main-navigation a { + padding: 1em 0; + } + + .main-navigation ul ul { + margin-left: 1em; + } + + .main-navigation .menu-item-description { + font-size: 14px; + font-size: 1.4rem; + line-height: 1.5; + } + + .social-navigation ul { + margin-bottom: -1.4706em; + } + + .social-navigation a { + height: 2.8824em; + width: 2.8824em; + } + + .secondary-toggle { + height: 56px; + width: 56px; + } + + .secondary-toggle:before { + line-height: 54px; + width: 54px; + } + + .post-password-form label, + .post-navigation .meta-nav, + .image-navigation, + .comment-navigation, + .author-heading, + .author-bio, + .entry-footer, + .page-links a, + .page-links span, + .comment-metadata, + .pingback .edit-link, + .comment-list .reply, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .comment-form label, + .comment-form .comment-form-cookies-consent label, + .form-allowed-tags, + .site-info, + .wp-caption-text, + .gallery-caption, + .entry-caption, + .widecolumn label, + .widecolumn .mu_register label { + font-size: 14px; + font-size: 1.4rem; + } + + .pagination .nav-links { + min-height: 3.2941em; + } + + .pagination .page-numbers { + line-height: 3.2941em; + padding: 0 0.8235em; + } + + .pagination .prev, + .pagination .next { + height: 56px; + padding: 0; + width: 56px; + } + + .pagination .prev:before, + .pagination .next:before { + height: 56px; + line-height: 56px; + width: 56px; + } + + .image-navigation .nav-previous a:before, + .image-navigation .nav-next a:after, + .comment-navigation .nav-previous a:before, + .comment-navigation .nav-next a:after { + top: 2px; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4118em 1.6471em 1.6471em 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4118em 0 1.6471em 1.6471em; + } + + blockquote.aligncenter, + .wp-caption.aligncenter, + img.aligncenter { + margin-top: 0.4118em; + margin-bottom: 1.6471em; + } + + .wp-caption.alignleft, + .wp-caption.alignright, + .wp-caption.aligncenter { + margin-bottom: 1.2353em; + } + + .site-branding { + min-height: 3.7059em; + padding-right: 66px; + } + + .site-title { + font-size: 29px; + font-size: 2.9rem; + line-height: 1.2069; + } + + .custom-logo { + max-height: 105px; + } + + .wp-custom-logo .site-title { + margin-top: 0.482758621em; + } + + .site-description { + font-size: 14px; + font-size: 1.4rem; + } + + .widget { + font-size: 14px; + font-size: 1.4rem; + line-height: 1.5; + } + + .widget p, + .widget address, + .widget hr, + .widget ul, + .widget ol, + .widget dl, + .widget dd, + .widget table, + .widget pre { + margin-bottom: 1.5em; + } + + .widget li > ul, + .widget li > ol { + margin-bottom: 0; + } + + .widget blockquote { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.6471; + margin-bottom: 1.6471em; + margin-left: -1.2353em; + padding-left: 1em; + } + + .widget blockquote p { + margin-bottom: 1.6471em; + } + + .widget blockquote cite, + .widget blockquote small { + font-size: 14px; + font-size: 1.4rem; + line-height: 1.5; + } + + .widget blockquote > blockquote { + margin-left: 0; + } + + .widget pre { + line-height: 1.5; + padding: 0.75em; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + line-height: 1.75; + } + + .widget button, + .widget input { + line-height: normal; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + font-size: 14px; + font-size: 1.4rem; + padding: 0.8214em 1.6429em; + } + + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget textarea { + padding: 0.5625em; + } + + .widget blockquote.alignleft, + .widget .wp-caption.alignleft, + .widget img.alignleft { + margin: 0.5em 1.5em 1.5em 0; + } + + .widget blockquote.alignright, + .widget .wp-caption.alignright, + .widget img.alignright { + margin: 0.5em 0 1.5em 1.5em; + } + + .widget blockquote.aligncenter, + .widget .wp-caption.aligncenter, + .widget img.aligncenter { + margin-top: 0.5em; + margin-bottom: 1.5em; + } + + .widget .wp-caption.alignleft, + .widget .wp-caption.alignright, + .widget .wp-caption.aligncenter { + margin-bottom: 1em; + } + + .widget-title { + margin: 0 0 1.5em; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 2.9286; + } + + .widget_calendar caption { + margin: 0 0 1.5em; + } + + .widget_archive li, + .widget_categories li, + .widget_links li, + .widget_meta li, + .widget_nav_menu li, + .widget_pages li, + .widget_recent_comments li, + .widget_recent_entries li { + padding: 0.9643em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.9643em 0 0 1em; + padding-top: 0.9643em; + } + + .widget_rss li { + margin-bottom: 1.5em; + } + + .widget_rss .rss-date, + .widget_rss cite { + line-height: 1.75; + } + + .post-thumbnail { + margin-bottom: 3em; + } + + .entry-title, + .widecolumn h2 { + font-size: 35px; + font-size: 3.5rem; + line-height: 1.2; + margin-bottom: 1.2em; + } + + .entry-content h1, + .entry-summary h1, + .page-content h1, + .comment-content h1 { + font-size: 35px; + font-size: 3.5rem; + line-height: 1.2; + margin-top: 1.6em; + margin-bottom: 0.8em; + } + + .entry-content h2, + .entry-summary h2, + .page-content h2, + .comment-content h2 { + font-size: 29px; + font-size: 2.9rem; + line-height: 1.2069; + margin-top: 1.931em; + margin-bottom: 0.9655em; + } + + .entry-content h3, + .entry-summary h3, + .page-content h3, + .comment-content h3 { + font-size: 24px; + font-size: 2.4rem; + line-height: 1.1667; + margin-top: 2.3333em; + margin-bottom: 1.1667em; + } + + .entry-content h4, + .entry-summary h4, + .page-content h4, + .comment-content h4 { + font-size: 20px; + font-size: 2rem; + line-height: 1.4; + margin-top: 2.8em; + margin-bottom: 1.4em; + } + + .entry-content h5, + .entry-content h6, + .entry-summary h5, + .entry-summary h6, + .page-content h5, + .page-content h6, + .comment-content h5, + .comment-content h6 { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.2353; + margin-top: 3.2941em; + margin-bottom: 1.6471em; + } + + .entry-content .more-link:after, + .entry-summary .more-link:after { + font-size: 24px; + top: 2px; + } + + .author-info { + margin: 0 9.0909%; + padding: 9.0909% 0; + } + + .author-info .avatar { + height: 42px; + margin: 0 1.6471em 1.6471em 0; + width: 42px; + } + + .author-link:after { + top: 3px; + } + + .posted-on:before, + .byline:before, + .cat-links:before, + .tags-links:before, + .comments-link:before, + .entry-format:before, + .edit-link:before, + .full-size-link:before { + top: 3px; + } + + .taxonomy-description { + padding-top: 0.4118em; + } + + .page-title, + .comments-title, + .comment-reply-title, + .post-navigation .post-title { + font-size: 24px; + font-size: 2.4rem; + line-height: 1.1667; + } + + .page-links { + margin-bottom: 1.4117em; + } + + .page-links a, + .page-links > span { + margin: 0 0.2857em 0.2857em 0; + } + + .entry-attachment { + margin-bottom: 1.6471em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 20px; + font-size: 2rem; + line-height: 1.4; + margin-bottom: 1.4em; + } + + .format-link .entry-title a:after { + top: 0.0833em; + } + + .comments-title { + margin-bottom: 1.4em; + } + + .comment-list article, + .comment-list .pingback, + .comment-list .trackback { + padding: 1.6471em 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 1.6471em; + } + + .comment-list .children > li { + padding-left: 1.2353em; + } + + .comment-meta { + position: relative; + } + + .comment-author { + margin-bottom: 0; + } + + .comment-author .avatar { + height: 42px; + margin-right: 1.64705em; + position: relative; + top: 5px; + width: 42px; + } + + .comment-metadata .edit-link:before { + top: 2px; + } + + .pingback .edit-link:before { + top: 6px; + } + + .bypostauthor > article .fn:after { + top: 7px; + left: 6px; + } + + .comment-content ul, + .comment-content ol { + margin-bottom: 1.6471em; + } + + .comment-list .reply a { + padding: 0.4286em 0.8571em; + } + + .comment-form, + .no-comments { + padding-top: 1.6471em; + } + + .comment-reply-title small a:before { + top: -1px; + } + + embed, + iframe, + object, + video { + margin-bottom: 1.6471em; + } + + .wp-audio-shortcode, + .wp-video, + .wp-playlist.wp-audio-playlist { + font-size: 17px; + font-size: 1.7rem; + margin-bottom: 1.6471em; + } + + .wp-caption, + .gallery { + margin-bottom: 1.6471em; + } + + .widecolumn .mu_alert { + margin-bottom: 1.6471em; + } + + .widecolumn p { + margin: 1.6471em 0; + } + + .widecolumn p + h2 { + margin-top: 1.6em; + } + + .widecolumn #key, + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #blogname, + .widecolumn .mu_register #user_name { + font-size: 17px; + font-size: 1.7rem; + line-height: normal; + } + + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #user_name { + margin: 0 0 0.4117em; + } +} + + +/** + * 16.3 Tablet Large 880px + */ + +@media screen and (min-width: 55em) { + body, + button, + input, + select, + textarea { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.6842; + } + + button, + input { + line-height: normal; + } + + p, + address, + pre, + hr, + ul, + ol, + dl, + dd, + table { + margin-bottom: 1.6842em; + } + + blockquote { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.8182; + margin-bottom: 1.8182em; + margin-left: -1.0909em; + padding-left: 0.9091em; + } + + blockquote p { + margin-bottom: 1.8182em; + } + + blockquote cite, + blockquote small { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.6842; + } + + pre { + line-height: 1.2632; + } + + button, + input[type="button"], + input[type="reset"], + input[type="submit"], + .post-password-form input[type="submit"], + .widecolumn #submit, + .widecolumn .mu_register input[type="submit"] { + font-size: 16px; + font-size: 1.6rem; + padding: 0.8125em 1.625em; + } + + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + textarea { + padding: 0.5278em; + } + + .main-navigation { + font-size: 16px; + font-size: 1.6rem; + line-height: 1.5; + } + + .main-navigation a { + padding: 0.75em 0; + } + + .main-navigation .menu-item-description { + font-size: 16px; + font-size: 1.6rem; + line-height: 1.5; + } + + .social-navigation ul { + margin-bottom: -1.2632em; + } + + .social-navigation a { + height: 2.5263em; + width: 2.5263em; + } + + .secondary-toggle { + height: 64px; + width: 64px; + } + + .secondary-toggle:before { + line-height: 62px; + width: 62px; + } + + .post-password-form label, + .post-navigation .meta-nav, + .comment-navigation, + .image-navigation, + .author-heading, + .author-bio, + .entry-footer, + .page-links a, + .page-links span, + .comment-metadata, + .pingback .edit-link, + .comment-list .reply, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .comment-form label, + .comment-form .comment-form-cookies-consent label, + .form-allowed-tags, + .site-info, + .wp-caption-text, + .gallery-caption, + .entry-caption, + .widecolumn label, + .widecolumn .mu_register label { + font-size: 16px; + font-size: 1.6rem; + } + + .pagination .nav-links { + min-height: 3.3684em; + } + + .pagination .page-numbers { + line-height: 3.3684em; + padding: 0 0.8421em; + } + + .pagination .prev, + .pagination .next { + height: 64px; + padding: 0; + width: 64px; + } + + .pagination .prev:before, + .pagination .next:before { + height: 64px; + line-height: 64px; + width: 64px; + } + + .image-navigation .nav-previous a:before, + .image-navigation .nav-next a:after, + .comment-navigation .nav-previous a:before, + .comment-navigation .nav-next a:after { + font-size: 24px; + top: -1px; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; + } + + blockquote.aligncenter, + .wp-caption.aligncenter, + img.aligncenter { + margin-top: 0.4211em; + margin-bottom: 1.6842em; + } + + .wp-caption.alignleft, + .wp-caption.alignright, + .wp-caption.aligncenter { + margin-bottom: 1.2632em; + } + + .site-branding { + min-height: 3.7895em; + padding-right: 74px; + } + + .site-title { + font-size: 32px; + font-size: 3.2rem; + line-height: 1.25; + } + + .custom-logo { + max-height: 104px; + } + + .wp-custom-logo .site-title { + margin-top: 0.5em; + } + + .site-description { + font-size: 16px; + font-size: 1.6rem; + } + + .widget { + font-size: 16px; + font-size: 1.6rem; + } + + .widget blockquote { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.6842; + margin-bottom: 1.6842em; + margin-left: -1.2632em; + padding-left: 1.0526em; + } + + .widget blockquote p { + margin-bottom: 1.6842em; + } + + .widget blockquote cite, + .widget blockquote small { + font-size: 16px; + font-size: 1.6rem; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + line-height: 1.5; + } + + .widget button, + .widget input { + line-height: normal; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + font-size: 16px; + font-size: 1.6rem; + padding: 0.8125em 1.625em; + } + + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget textarea { + padding: 0.75em; + } + + .widget .wp-caption-text, + .widget .gallery-caption { + line-height: 1.5; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 2.9375; + } + + .widget_archive li, + .widget_categories li, + .widget_links li, + .widget_meta li, + .widget_nav_menu li, + .widget_pages li, + .widget_recent_comments li, + .widget_recent_entries li { + padding: 0.7188em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.7188em 0 0 1em; + padding-top: 0.7188em; + } + + .widget_rss .rss-date, + .widget_rss cite { + font-size: 13px; + font-size: 1.3rem; + line-height: 1.8462; + } + + .post-thumbnail { + margin-bottom: 2.9474em; + } + + .entry-title, + .widecolumn h2 { + font-size: 39px; + font-size: 3.9rem; + line-height: 1.2308; + margin-bottom: 1.2308em; + } + + .entry-content h1, + .entry-summary h1, + .page-content h1, + .comment-content h1 { + font-size: 39px; + font-size: 3.9rem; + line-height: 1.2308; + margin-top: 1.641em; + margin-bottom: 0.8205em; + } + + .entry-content h2, + .entry-summary h2, + .page-content h2, + .comment-content h2 { + font-size: 32px; + font-size: 3.2rem; + line-height: 1.25; + margin-top: 2em; + margin-bottom: 1em; + } + + .entry-content h3, + .entry-summary h3, + .page-content h3, + .comment-content h3 { + font-size: 27px; + font-size: 2.7rem; + line-height: 1.1852; + margin-top: 2.3704em; + margin-bottom: 1.1852em; + } + + .entry-content h4, + .entry-summary h4, + .page-content h4, + .comment-content h4 { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.4545; + margin-top: 2.9091em; + margin-bottom: 1.4545em; + } + + .entry-content h5, + .entry-content h6, + .entry-summary h5, + .entry-summary h6, + .page-content h5, + .page-content h6, + .comment-content h5, + .comment-content h6 { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.2632; + margin-top: 3.3684em; + margin-bottom: 1.6842em; + } + + .entry-content .more-link:after, + .entry-summary .more-link:after { + top: 3px; + } + + .author-info .avatar { + height: 56px; + margin: 0 1.6842em 1.6842em 0; + width: 56px; + } + + .author-link:after { + font-size: 24px; + top: 0; + } + + .posted-on:before, + .byline:before, + .cat-links:before, + .tags-links:before, + .comments-link:before, + .entry-format:before, + .edit-link:before, + .full-size-link:before { + top: 4px; + } + + .taxonomy-description { + padding-top: 0.4211em; + } + + .page-title, + .comments-title, + .comment-reply-title, + .post-navigation .post-title { + font-size: 27px; + font-size: 2.7rem; + line-height: 1.1852; + } + + .page-links { + margin-bottom: 1.4736em; + } + + .page-links a, + .page-links > span { + margin: 0 0.25em 0.25em 0; + } + + .entry-attachment { + margin-bottom: 1.6842em + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.4545; + margin-bottom: 1.4545em; + } + + .format-link .entry-title a:after { + top: 0.125em; + } + + .comments-title { + margin-bottom: 1.4545em; + } + + .comment-list article, + .comment-list .pingback, + .comment-list .trackback { + padding: 1.6842em 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 1.6842em; + } + + .comment-list .children > li { + padding-left: 1.4737em; + } + + .comment-author .avatar { + height: 56px; + margin-right: 1.6842em; + top: 3px; + width: 56px; + } + + .comment-metadata { + line-height: 2; + } + + .comment-metadata .edit-link:before { + top: 8px; + } + + .pingback .edit-link:before { + top: 8px; + } + + .bypostauthor > article .fn:after { + top: 8px; + } + + .comment-content ul, + .comment-content ol { + margin-bottom: 1.6842em; + } + + .comment-list .reply a { + padding: 0.4375em 0.875em; + } + + .comment-form, + .no-comments { + padding-top: 1.6842em; + } + + embed, + iframe, + object, + video { + margin-bottom: 1.6842em; + } + + .wp-audio-shortcode, + .wp-video, + .wp-playlist.wp-audio-playlist { + font-size: 19px; + font-size: 1.9rem; + margin-bottom: 1.6842em; + } + + .wp-caption, + .gallery { + margin-bottom: 1.6842em; + } + + .widecolumn .mu_alert { + margin-bottom: 1.6842em; + } + + .widecolumn p { + margin: 1.6842em 0; + } + + .widecolumn p + h2 { + margin-top: 1.641em; + } + + .widecolumn #key, + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #blogname, + .widecolumn .mu_register #user_name { + font-size: 19px; + font-size: 1.9rem; + } + + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #user_name { + margin: 0 0 0.421em; + } +} + + +/** + * 16.4 Desktop Small 955px + */ + +@media screen and (min-width: 59.6875em) { + body:before { + background-color: #fff; + box-shadow: 0 0 1px rgba(0, 0, 0, 0.15); + content: ""; + display: block; + height: 100%; + min-height: 100%; + position: fixed; + top: 0; + left: 0; + width: 29.4118%; + z-index: 0; /* Fixes flashing bug with scrolling on Safari */ + } + + .site { + margin: 0 auto; + max-width: 1403px; + } + + .sidebar { + float: left; + margin-right: -100%; + max-width: 413px; + position: relative; + width: 29.4118%; + } + + .secondary { + background-color: transparent; + box-shadow: none; + display: block; + margin: 0; + padding: 0; + } + + .site-main { + padding: 8.3333% 0; + } + + .site-content { + display: block; + float: left; + margin-left: 29.4118%; + width: 70.5882%; + } + + body { + font-size: 15px; + font-size: 1.5rem; + line-height: 1.6; + } + + p, + address, + pre, + hr, + ul, + ol, + dl, + dd, + table { + margin-bottom: 1.6em; + } + + blockquote { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.6667; + margin-bottom: 1.6667em; + margin-left: -1.3333em; + padding-left: 1.1111em; + } + + blockquote cite, + blockquote small { + font-size: 15px; + font-size: 1.5rem; + line-height: 1.6; + } + + pre { + line-height: 1.2; + } + + button, + input, + select, + textarea { + font-size: 16px; + font-size: 1.6rem; + line-height: 1.5; + } + + button, + input { + line-height: normal; + } + + button, + input[type="button"], + input[type="reset"], + input[type="submit"], + .post-password-form input[type="submit"], + .widecolumn #submit, + .widecolumn .mu_register input[type="submit"] { + font-size: 12px; + font-size: 1.2rem; + padding: 0.7917em 1.5833em; + } + + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + textarea { + padding: 0.375em; + } + + .main-navigation { + font-size: 12px; + font-size: 1.2rem; + margin: 0 20% 20%; + } + + .main-navigation a { + padding: 0.5em 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 30px; + } + + .main-navigation .menu-item-description { + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + } + + .dropdown-toggle { + height: 24px; + width: 24px; + } + + .dropdown-toggle:after { + font-size: 16px; + line-height: 24px; + width: 24px; + } + + .social-navigation { + margin: 0 20% 20%; + } + + .social-navigation ul { + margin-bottom: -1.6em; + } + + .social-navigation li { + width: 25%; + } + + .social-navigation a { + height: 3.2em; + } + + .secondary-toggle { + display: none; + } + + .post-password-form label, + .post-navigation .meta-nav, + .comment-navigation, + .image-navigation, + .author-heading, + .author-bio, + .entry-footer, + .page-links a, + .page-links span, + .comment-metadata, + .pingback .edit-link, + .comment-list .reply, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .comment-form label, + .comment-form .comment-form-cookies-consent label, + .form-allowed-tags, + .site-info, + .wp-caption-text, + .gallery-caption, + .entry-caption, + .widecolumn label, + .widecolumn .mu_register label { + font-size: 12px; + font-size: 1.2rem; + } + + .post-navigation { + margin: 8.3333% 8.3333% 0; + } + + .post-navigation a { + padding: 5% 10%; + } + + .pagination { + margin: 8.333% 8.333% 0; + } + + .pagination .nav-links { + min-height: 3.2em; + } + + .pagination .page-numbers { + line-height: 3.2em; + padding: 0 0.8em; + } + + .pagination .prev, + .pagination .next { + height: 48px; + padding: 0; + width: 48px; + } + + .pagination .prev:before, + .pagination .next:before { + height: 48px; + line-height: 48px; + width: 48px; + } + + .image-navigation .nav-previous a:before, + .image-navigation .nav-next a:after, + .comment-navigation .nav-previous a:before, + .comment-navigation .nav-next a:after { + font-size: 16px; + top: 0; + } + + .image-navigation { + padding: 0 10%; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4em 1.6em 1.6em 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4em 0 1.6em 1.6em; + } + + blockquote.aligncenter, + .wp-caption.aligncenter, + img.aligncenter { + clear: both; + margin-top: 0.4em; + margin-bottom: 1.6em; + } + + .wp-caption.alignleft, + .wp-caption.alignright, + .wp-caption.aligncenter { + margin-bottom: 1.2em; + } + + .site-header { + background-color: transparent; + border-bottom: 0; + margin: 20% 0; + padding: 0 20%; + } + + .site-branding { + min-height: 0; + padding: 0; + } + + .site-title { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.3636; + } + + .custom-logo { + max-height: none; + } + + .wp-custom-logo .site-title { + margin-top: 0.545454545em; + } + + .site-description { + font-size: 12px; + font-size: 1.2rem; + } + + .widget { + font-size: 12px; + font-size: 1.2rem; + margin: 0 0 20%; + padding: 0 20%; + } + + .widget blockquote { + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + margin-bottom: 1.5em; + margin-left: -1.5em; + padding-left: 1.1667em; + } + + .widget blockquote p { + margin-bottom: 1.5em; + } + + .widget blockquote cite, + .widget blockquote small { + font-size: 12px; + font-size: 1.2rem; + } + + .widget pre { + padding: 0.5em; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + font-size: 12px; + font-size: 1.2rem; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + font-size: 12px; + font-size: 1.2rem; + padding: 0.5417em 1.0833em; + } + + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget textarea { + padding: 0.4583em; + } + + .widget .wp-caption-text, + .widget .gallery-caption { + font-size: 12px; + font-size: 1.2rem; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 1.9167; + } + + .widget_archive li, + .widget_categories li, + .widget_links li, + .widget_meta li, + .widget_nav_menu li, + .widget_pages li, + .widget_recent_comments li, + .widget_recent_entries li { + padding: 0.4583em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4583em 0 0 1em; + padding-top: 0.4583em; + } + + .widget_rss .rss-date, + .widget_rss cite { + font-size: 12px; + font-size: 1.2rem; + line-height: 1.5; + } + + .hentry, + .page-header, + .page-content { + margin: 0 8.3333%; + } + + .hentry { + padding-top: 8.3333%; + } + + .hentry + .hentry, + .page-header + .hentry, + .page-header + .page-content { + margin-top: 8.3333%; + } + + .post-thumbnail { + margin-bottom: 2.4em; + } + + .entry-header { + padding: 0 10%; + } + + .entry-title, + .widecolumn h2 { + font-size: 31px; + font-size: 3.1rem; + line-height: 1.1613; + margin-bottom: 1.1613em; + } + + .entry-content, + .entry-summary { + padding: 0 10% 10%; + } + + .entry-content h1, + .entry-summary h1, + .page-content h1, + .comment-content h1 { + font-size: 31px; + font-size: 3.1rem; + line-height: 1.1613; + margin-top: 1.5484em; + margin-bottom: 0.7742em; + } + + .entry-content h2, + .entry-summary h2, + .page-content h2, + .comment-content h2 { + font-size: 26px; + font-size: 2.6rem; + line-height: 1.3846; + margin-top: 1.8462em; + margin-bottom: 0.9231em; + } + + .entry-content h3, + .entry-summary h3, + .page-content h3, + .comment-content h3 { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.3636; + margin-top: 2.1818em; + margin-bottom: 1.0909em; + } + + .entry-content h4, + .entry-summary h4, + .page-content h4, + .comment-content h4 { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + margin-top: 2.6667em; + margin-bottom: 1.3333em; + } + + .entry-content h5, + .entry-content h6, + .entry-summary h5, + .entry-summary h6, + .page-content h5, + .page-content h6, + .comment-content h5, + .comment-content h6 { + font-size: 15px; + font-size: 1.5rem; + line-height: 1.2; + margin-top: 3.2em; + margin-bottom: 1.6em; + } + + .entry-content .more-link:after, + .entry-summary .more-link:after { + font-size: 16px; + top: 5px; + } + + .author-info { + margin: 0 10%; + padding: 10% 0; + } + + .author-info .avatar { + height: 36px; + margin: 0 1.5em 1.5em 0; + width: 36px; + } + + .author-link:after { + font-size: 16px; + top: 1px; + } + + .entry-footer { + padding: 5% 10%; + } + + .posted-on:before, + .byline:before, + .cat-links:before, + .tags-links:before, + .comments-link:before, + .entry-format:before, + .edit-link:before, + .full-size-link:before { + top: 0; + } + + .page-header { + padding: 4.1666% 8.3333%; + } + + .page-content { + padding: 8.3333%; + } + + .taxonomy-description { + padding-top: 0.4em; + } + + .page-title, + .comments-title, + .comment-reply-title, + .post-navigation .post-title { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + } + + .page-links { + margin-bottom: 1.3333em; + } + + .page-links a, + .page-links > span { + margin: 0 0.3333em 0.3333em 0; + } + + .entry-attachment { + margin-bottom: 1.6em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 18px; + font-size: 1.8rem; + line-height: 1.3333; + margin-bottom: 1.3333em; + } + + .format-link .entry-title a:after { + top: 0; + } + + .comments-area { + margin: 8.3333% 8.3333% 0; + padding: 8.3333%; + } + + .comments-title { + margin-bottom: 1.3333em; + } + + .comment-list article, + .comment-list .pingback, + .comment-list .trackback { + padding: 1.6em 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 1.6em; + } + + .comment-list .children > li { + padding-left: 0.8em; + } + + .comment-author { + margin-bottom: 0.4em; + } + + .comment-author .avatar { + height: 24px; + margin-right: 0.8em; + top: 0; + width: 24px; + } + + .comment-metadata .edit-link:before { + top: 3px; + } + + .pingback .edit-link:before { + top: 5px; + } + + .bypostauthor > article .fn:after { + top: 5px; + left: 3px; + } + + .comment-content ul, + .comment-content ol { + margin-bottom: 2em; + } + + .comment-list .reply a { + padding: 0.4167em 0.8333em; + } + + .comment-form, + .no-comments { + padding-top: 1.6em; + } + + .comment-reply-title small a:before { + top: -3px; + } + + .site-footer { + float: left; + margin: 0 0 0 35.2941%; + padding: 0; + width: 58.8235%; + } + + .site-info { + padding: 5% 10%; + } + + embed, + iframe, + object, + video { + margin-bottom: 1.6em; + } + + .wp-audio-shortcode, + .wp-video, + .wp-playlist.wp-audio-playlist { + font-size: 15px; + font-size: 1.5rem; + margin-bottom: 1.6em; + } + + .wp-caption, + .gallery { + margin-bottom: 1.6em; + } + + .widecolumn { + margin: 8.3333%; + padding: 8.3333%; + } + + .widecolumn .mu_alert { + margin-bottom: 1.6em; + } + + .widecolumn p { + margin: 1.6em 0; + } + + .widecolumn p + h2 { + margin-top: 1.5484em; + } + + .widecolumn #key, + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #blogname, + .widecolumn .mu_register #user_name { + font-size: 16px; + font-size: 1.6rem; + } + + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #user_name { + margin: 0 0 0.375em; + } +} + + +/** + * 16.5 Desktop Medium 1100px + */ + +@media screen and (min-width: 68.75em) { + body, + button, + input, + select, + textarea { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.6471; + } + + button, + input { + line-height: normal; + } + + p, + address, + pre, + hr, + ul, + ol, + dl, + dd, + table { + margin-bottom: 1.6471em; + } + + blockquote { + font-size: 20px; + font-size: 2rem; + line-height: 1.75; + margin-bottom: 1.75em; + margin-left: -1.05em; + padding-left: 0.85em; + } + + blockquote p { + margin-bottom: 1.75em; + } + + blockquote cite, + blockquote small { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.6471; + } + + pre { + line-height: 1.2353; + } + + button, + input[type="button"], + input[type="reset"], + input[type="submit"], + .post-password-form input[type="submit"], + .widecolumn #submit, + .widecolumn .mu_register input[type="submit"] { + font-size: 14px; + font-size: 1.4rem; + padding: 0.8214em 1.5714em; + } + + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + textarea { + padding: 0.5em; + } + + .main-navigation { + font-size: 14px; + font-size: 1.4rem; + } + + .main-navigation a { + padding: 0.4643em 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 34px; + } + + .main-navigation .menu-item-description { + line-height: 1.4583; + margin-top: 0.25em; + } + + .dropdown-toggle { + height: 28px; + width: 28px; + } + + .dropdown-toggle:after { + line-height: 28px; + width: 28px; + } + + .social-navigation ul { + margin-bottom: -1.4706em; + } + + .social-navigation li { + width: 20%; + } + + .social-navigation a { + height: 2.8824em; + } + + .post-password-form label, + .post-navigation .meta-nav, + .comment-navigation, + .image-navigation, + .author-heading, + .author-bio, + .entry-footer, + .page-links a, + .page-links span, + .comment-metadata, + .pingback .edit-link, + .comment-list .reply, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .comment-form label, + .comment-form .comment-form-cookies-consent label, + .form-allowed-tags, + .site-info, + .wp-caption-text, + .gallery-caption, + .entry-caption, + .widecolumn label, + .widecolumn .mu_register label { + font-size: 14px; + font-size: 1.4rem; + } + + .pagination .nav-links { + min-height: 3.2941em; + } + + .pagination .page-numbers { + line-height: 3.2941em; + padding: 0 0.8235em; + } + + .pagination .prev, + .pagination .next { + height: 56px; + padding: 0; + width: 56px; + } + + .pagination .prev:before, + .pagination .next:before { + height: 56px; + line-height: 56px; + width: 56px; + } + + .image-navigation .nav-previous a:before, + .image-navigation .nav-next a:after, + .comment-navigation .nav-previous a:before, + .comment-navigation .nav-next a:after { + top: 2px; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4118em 1.6471em 1.6471em 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4118em 0 1.6471em 1.6471em; + } + + blockquote.aligncenter, + .wp-caption.aligncenter, + img.aligncenter { + margin-top: 0.4118em; + margin-bottom: 1.6471em; + } + + .wp-caption.alignleft, + .wp-caption.alignright, + .wp-caption.aligncenter { + margin-bottom: 1.2353em; + } + + .site-title { + font-size: 24px; + font-size: 2.4rem; + line-height: 1.1667; + } + + .wp-custom-logo .site-title { + margin-top: 0.583333333em; + } + + .site-description { + font-size: 14px; + font-size: 1.4rem; + } + + .widget { + font-size: 14px; + font-size: 1.4rem; + } + + .widget blockquote { + font-size: 14px; + font-size: 1.4rem; + padding-left: 1.2143em; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + font-size: 14px; + font-size: 1.4rem; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + font-size: 12px; + font-size: 1.2rem; + padding: 0.75em 1.5em; + } + + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget textarea { + padding: 0.5em; + } + + .widget .wp-caption-text, + .widget .gallery-caption { + line-height: 1.4583; + padding: 0.5833em 0; + } + + .widget_calendar caption { + margin: 0 0 1.9286em; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 1.9286; + } + + .widget_archive li, + .widget_categories li, + .widget_links li, + .widget_meta li, + .widget_nav_menu li, + .widget_pages li, + .widget_recent_comments li, + .widget_recent_entries li { + padding: 0.4643em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4643em 0 0 1em; + padding-top: 0.4643em; + } + + .widget_rss .rss-date, + .widget_rss cite { + line-height: 1.75; + } + + .post-thumbnail { + margin-bottom: 2.4706em; + } + + .entry-title, + .widecolumn h2 { + font-size: 35px; + font-size: 3.5rem; + line-height: 1.2; + margin-bottom: 1.2em; + } + + .entry-content h1, + .entry-summary h1, + .page-content h1, + .comment-content h1 { + font-size: 35px; + font-size: 3.5rem; + line-height: 1.2; + margin-top: 1.6em; + margin-bottom: 0.8em; + } + + .entry-content h2, + .entry-summary h2, + .page-content h2, + .comment-content h2 { + font-size: 29px; + font-size: 2.9rem; + line-height: 1.2069; + margin-top: 1.931em; + margin-bottom: 0.9655em; + } + + .entry-content h3, + .entry-summary h3, + .page-content h3, + .comment-content h3 { + font-size: 24px; + font-size: 2.4rem; + line-height: 1.1667; + margin-top: 2.3333em; + margin-bottom: 1.1667em; + } + + .entry-content h4, + .entry-summary h4, + .page-content h4, + .comment-content h4 { + font-size: 20px; + font-size: 2rem; + line-height: 1.4; + margin-top: 2.8em; + margin-bottom: 1.4em; + } + + .entry-content h5, + .entry-content h6, + .entry-summary h5, + .entry-summary h6, + .page-content h5, + .page-content h6, + .comment-content h5, + .comment-content h6 { + font-size: 17px; + font-size: 1.7rem; + line-height: 1.2353; + margin-top: 3.2941em; + margin-bottom: 1.6471em; + } + + .entry-content .more-link:after, + .entry-summary .more-link:after { + font-size: 24px; + top: 2px; + } + + .author-info .avatar { + height: 42px; + margin: 0 1.6471em 1.6471em 0; + width: 42px; + } + + .author-link:after { + top: 3px; + } + + .posted-on:before, + .byline:before, + .cat-links:before, + .tags-links:before, + .comments-link:before, + .entry-format:before, + .edit-link:before, + .full-size-link:before { + top: 3px; + } + + .taxonomy-description { + padding-top: 0.4118em; + } + + .page-title, + .comments-title, + .comment-reply-title, + .post-navigation .post-title { + font-size: 24px; + font-size: 2.4rem; + line-height: 1.1667; + } + + .page-links { + margin-bottom: 1.4117em; + } + + .page-links a, + .page-links > span { + margin: 0 0.2857em 0.2857em 0; + } + + .entry-attachment { + margin-bottom: 1.6471em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 20px; + font-size: 2rem; + line-height: 1.4; + margin-bottom: 1.4em; + } + + .format-link .entry-title a:after { + top: 0.0833em; + } + + .comments-title { + margin-bottom: 1.4em; + } + + .comment-list article, + .comment-list .pingback, + .comment-list .trackback { + padding: 1.6471em 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 1.6471em; + } + + .comment-list .children > li { + padding-left: 1.1667em; + } + + .comment-author { + margin-bottom: 0; + } + + .comment-author .avatar { + height: 42px; + margin-right: 1.64705em; + top: 5px; + width: 42px; + } + + .bypostauthor > article .fn:after { + top: 7px; + left: 6px; + } + + .comment-metadata .edit-link:before { + top: 6px; + } + + .pingback .edit-link:before { + top: 6px; + } + + .comment-content ul, + .comment-content ol { + margin-bottom: 1.6471em; + } + + .comment-list .reply a { + padding: 0.4286em 0.8571em; + } + + .comment-form, + .no-comments { + padding-top: 1.6471em; + } + + .comment-reply-title small a:before { + top: -1px; + } + + embed, + iframe, + object, + video { + margin-bottom: 1.6471em; + } + + .wp-audio-shortcode, + .wp-video, + .wp-playlist.wp-audio-playlist { + font-size: 17px; + font-size: 1.7rem; + margin-bottom: 1.6471em; + } + + .wp-caption, + .gallery { + margin-bottom: 1.6471em; + } + + .widecolumn .mu_alert { + margin-bottom: 1.6471em; + } + + .widecolumn p { + margin: 1.6471em 0; + } + + .widecolumn p + h2 { + margin-top: 1.6em; + } + + .widecolumn #key, + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #blogname, + .widecolumn .mu_register #user_name { + font-size: 17px; + font-size: 1.7rem; + } + + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #user_name { + margin: 0 0 0.4117em; + } +} + + +/** + * 16.6 Desktop Large 1240px + */ + +@media screen and (min-width: 77.5em) { + body, + button, + input, + select, + textarea { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.6842; + } + + button, + input { + line-height: normal; + } + + p, + address, + pre, + hr, + ul, + ol, + dl, + dd, + table { + margin-bottom: 1.6842em; + } + + blockquote { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.8182; + margin-bottom: 1.8182em; + margin-left: -1.0909em; + padding-left: 0.9091em; + } + + blockquote p { + margin-bottom: 1.8182em; + } + + blockquote cite, + blockquote small { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.6842; + } + + pre { + line-height: 1.2632; + } + + button, + input[type="button"], + input[type="reset"], + input[type="submit"], + .post-password-form input[type="submit"], + .widecolumn #submit, + .widecolumn .mu_register input[type="submit"] { + font-size: 16px; + font-size: 1.6rem; + padding: 0.8125em 1.625em; + } + + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + textarea { + padding: 0.5278em; + } + + .main-navigation { + font-size: 16px; + font-size: 1.6rem; + } + + .main-navigation a { + padding: 0.5em 0; + } + + .main-navigation .menu-item-has-children > a { + padding-right: 38px; + } + + .main-navigation .menu-item-description { + font-size: 13px; + font-size: 1.3rem; + line-height: 1.5385; + margin-top: 0.3077em; + } + + .dropdown-toggle { + height: 32px; + top: 4px; + width: 32px; + } + + .dropdown-toggle:after { + line-height: 32px; + width: 32px; + } + + .social-navigation ul { + margin-bottom: -1.2632em; + } + + .social-navigation a { + height: 2.5263em; + } + + .post-password-form label, + .post-navigation .meta-nav, + .comment-navigation, + .image-navigation, + .author-heading, + .author-bio, + .entry-footer, + .page-links a, + .page-links span, + .comment-metadata, + .pingback .edit-link, + .comment-list .reply, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .comment-form label, + .comment-form .comment-form-cookies-consent label, + .form-allowed-tags, + .site-info, + .wp-caption-text, + .gallery-caption, + .entry-caption, + .widecolumn label, + .widecolumn .mu_register label { + font-size: 16px; + font-size: 1.6rem; + } + + .pagination .nav-links { + min-height: 3.3684em; + } + + .pagination .page-numbers { + line-height: 3.3684em; + padding: 0 0.8421em; + } + + .pagination .prev, + .pagination .next { + height: 64px; + padding: 0; + width: 64px; + } + + .pagination .prev:before, + .pagination .next:before { + height: 64px; + line-height: 64px; + width: 64px; + } + + .image-navigation .nav-previous a:before, + .image-navigation .nav-next a:after, + .comment-navigation .nav-previous a:before, + .comment-navigation .nav-next a:after { + font-size: 24px; + top: -1px; + } + + blockquote.alignleft, + .wp-caption.alignleft, + img.alignleft { + margin: 0.4211em 1.6842em 1.6842em 0; + } + + blockquote.alignright, + .wp-caption.alignright, + img.alignright { + margin: 0.4211em 0 1.6842em 1.6842em; + } + + blockquote.aligncenter, + .wp-caption.aligncenter, + img.aligncenter { + margin-top: 0.4211em; + margin-bottom: 1.6842em; + } + + .wp-caption.alignleft, + .wp-caption.alignright, + .wp-caption.aligncenter { + margin-bottom: 1.2632em; + } + + .site-title { + font-size: 27px; + font-size: 2.7rem; + line-height: 1.1852; + } + + .wp-custom-logo .site-title { + margin-top: 0.592592593em; + } + + .site-description { + font-size: 16px; + font-size: 1.6rem; + } + + .widget { + font-size: 16px; + font-size: 1.6rem; + } + + .widget blockquote { + font-size: 16px; + font-size: 1.6rem; + padding-left: 1.25em; + } + + .widget blockquote cite, + .widget blockquote small { + font-size: 13px; + font-size: 1.3rem; + line-height: 1.8462; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + font-size: 16px; + font-size: 1.6rem; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + font-size: 13px; + font-size: 1.3rem; + padding: 0.8462em 1.6923em; + } + + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget textarea { + padding: 0.5em; + } + + .widget .wp-caption-text, + .widget .gallery-caption { + font-size: 13px; + font-size: 1.3rem; + line-height: 1.5385; + padding: 0.6154em 0; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 1.9375; + } + + .widget_calendar caption { + margin: 0 0 1.5em; + } + + .widget_archive li, + .widget_categories li, + .widget_links li, + .widget_meta li, + .widget_nav_menu li, + .widget_pages li, + .widget_recent_comments li, + .widget_recent_entries li { + padding: 0.4688em 0; + } + + .widget_categories .children, + .widget_nav_menu .sub-menu, + .widget_pages .children { + margin: 0.4688em 0 0 1em; + padding-top: 0.4688em; + } + + .widget_rss .rss-date, + .widget_rss cite { + font-size: 13px; + font-size: 1.3rem; + line-height: 1.8462; + } + + .post-thumbnail { + margin-bottom: 2.9474em; + } + + .entry-title, + .widecolumn h2 { + font-size: 39px; + font-size: 3.9rem; + line-height: 1.2308; + margin-bottom: 1.2308em; + } + + .entry-content h1, + .entry-summary h1, + .page-content h1, + .comment-content h1 { + font-size: 39px; + font-size: 3.9rem; + line-height: 1.2308; + margin-top: 1.641em; + margin-bottom: 0.8205em; + } + + .entry-content h2, + .entry-summary h2, + .page-content h2, + .comment-content h2 { + font-size: 32px; + font-size: 3.2rem; + line-height: 1.25; + margin-top: 2em; + margin-bottom: 1em; + } + + .entry-content h3, + .entry-summary h3, + .page-content h3, + .comment-content h3 { + font-size: 27px; + font-size: 2.7rem; + line-height: 1.1852; + margin-top: 2.3704em; + margin-bottom: 1.1852em; + } + + .entry-content h4, + .entry-summary h4, + .page-content h4, + .comment-content h4 { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.4545; + margin-top: 2.9091em; + margin-bottom: 1.4545em; + } + + .entry-content h5, + .entry-content h6, + .entry-summary h5, + .entry-summary h6, + .page-content h5, + .page-content h6, + .comment-content h5, + .comment-content h6 { + font-size: 19px; + font-size: 1.9rem; + line-height: 1.2632; + margin-top: 3.3684em; + margin-bottom: 1.6842em; + } + + .entry-content .more-link:after, + .entry-summary .more-link:after { + top: 3px; + } + + .author-info .avatar { + height: 56px; + margin: 0 1.6842em 1.6842em 0; + width: 56px; + } + + .author-link:after { + font-size: 24px; + top: 0; + } + + .posted-on:before, + .byline:before, + .cat-links:before, + .tags-links:before, + .comments-link:before, + .entry-format:before, + .edit-link:before, + .full-size-link:before { + top: 4px; + } + + .taxonomy-description { + padding-top: 0.4211em; + } + + .page-title, + .comments-title, + .comment-reply-title, + .post-navigation .post-title { + font-size: 27px; + font-size: 2.7rem; + line-height: 1.1852; + } + + .page-links { + margin-bottom: 1.4736em; + } + + .page-links a, + .page-links > span { + margin: 0 0.25em 0.25em 0; + } + + .entry-attachment { + margin-bottom: 1.6842em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 22px; + font-size: 2.2rem; + line-height: 1.4545; + margin-bottom: 1.4545em; + } + + .format-link .entry-title a:after { + top: 3px; + } + + .comments-title { + margin-bottom: 1.4545em; + } + + .comment-list article, + .comment-list .pingback, + .comment-list .trackback { + padding: 1.6842em 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 1.6842em; + } + + .comment-list .children > li { + padding-left: 1.4737em; + } + + .comment-author .avatar { + height: 56px; + margin-right: 1.6842em; + top: 3px; + width: 56px; + } + + .bypostauthor > article .fn:after { + top: 8px; + } + + .comment-metadata .edit-link:before { + top: 8px; + } + + .pingback .edit-link:before { + top: 8px; + } + + .comment-content ul, + .comment-content ol { + margin-bottom: 1.6842em; + } + + .comment-list .reply a { + padding: 0.4375em 0.875em; + } + + .comment-form, + .no-comments { + padding-top: 1.6842em; + } + + embed, + iframe, + object, + video { + margin-bottom: 1.6842em; + } + + .wp-audio-shortcode, + .wp-video, + .wp-playlist.wp-audio-playlist { + font-size: 19px; + font-size: 1.9rem; + margin-bottom: 1.6842em; + } + + .wp-caption, + .gallery { + margin-bottom: 1.6842em; + } + + .widecolumn .mu_alert { + margin-bottom: 1.6842em; + } + + .widecolumn p { + margin: 1.6842em 0; + } + + .widecolumn p + h2 { + margin-top: 1.641em; + } + + .widecolumn #key, + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #blogname, + .widecolumn .mu_register #user_name { + font-size: 19px; + font-size: 1.9rem; + } + + .widecolumn .mu_register #blog_title, + .widecolumn .mu_register #user_email, + .widecolumn .mu_register #user_name { + margin: 0 0 0.421em; + } +} + + +/** + * 16.7 Desktop X-Large 1403px + */ + +@media screen and (min-width: 87.6875em) { + body:before { + width: -webkit-calc(50% - 289px); + width: calc(50% - 289px); + } +} + + +/** + * 17.0 Print + */ + +@media print { + body { + background: none !important; /* Brute force since user agents all print differently. */ + font-size: 11.25pt; + } + + .secondary-toggle, + .navigation, + .page-links, + .edit-link, + #reply-title, + .comment-form, + .comment-edit-link, + .comment-list .reply a, + button, + input, + textarea, + select, + .widecolumn form, + .widecolumn .mu_register form { + display: none; + } + + .site-header, + .site-footer, + .hentry, + .entry-footer, + .page-header, + .page-content, + .comments-area, + .widecolumn { + background: none !important; /* Make sure color schemes dont't affect to print */ + } + + body, + blockquote, + blockquote cite, + blockquote small, + label, + a, + .site-title a, + .site-description, + .post-title, + .author-heading, + .entry-footer, + .entry-footer a, + .taxonomy-description, + .entry-caption, + .comment-author, + .comment-metadata, + .comment-metadata a, + .comment-notes, + .comment-awaiting-moderation, + .no-comments, + .site-info, + .site-info a, + .wp-caption-text, + .gallery-caption { + color: #000 !important; /* Make sure color schemes don't affect to print */ + } + + pre, + abbr[title], + table, + th, + td, + .site-header, + .site-footer, + .hentry + .hentry, + .author-info, + .page-header, + .comments-area, + .comment-list + .comment-respond, + .comment-list article, + .comment-list .pingback, + .comment-list .trackback, + .no-comments { + border-color: #eaeaea !important; /* Make sure color schemes don't affect to print */ + } + + .site { + margin: 0 7.6923%; + } + + .sidebar { + position: relative !important; /* Make sure sticky sidebar doesn't affect to print */ + } + + .site-branding { + padding: 0; + } + + .site-header { + padding: 7.6923% 0; + } + + .site-description { + display: block; + } + + .hentry + .hentry { + margin-top: 7.6923%; + } + + .hentry.has-post-thumbnail { + padding-top: 7.6923%; + } + + .sticky-post { + background: #000 !important; + color: #fff !important; + } + + .entry-header, + .entry-footer { + padding: 0; + } + + .entry-content, + .entry-summary { + padding: 0 0 7.6923%; + } + + .post-thumbnail img { + margin: 0; + } + + .author-info { + margin: 0; + } + + .page-content { + padding: 7.6923% 0 0; + } + + .page-header { + padding: 3.84615% 0; + } + + .comments-area { + border: 0; + padding: 7.6923% 0 0; + } + + .site-footer { + margin-top: 7.6923%; + padding: 3.84615% 0; + } + + .widecolumn { + margin: 7.6923% 0 0; + padding: 0; + } +} diff --git a/backend/wp-content/themes/twentyseventeen/404.php b/backend/wp-content/themes/twentyseventeen/404.php new file mode 100644 index 0000000..4a6d113 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/404.php @@ -0,0 +1,34 @@ + + +
      +
      +
      + +
      + +
      +

      + + + +
      +
      +
      +
      +
      + + Themes and click the 'Add New' button. +2. Type in Twenty Seventeen in the search form and press the 'Enter' key on your keyboard. +3. Click on the 'Activate' button to use your new theme right away. +4. Go to https://codex.wordpress.org/Twenty_Seventeen for a guide on how to customize this theme. +5. Navigate to Appearance > Customize in your admin panel and customize to taste. + +== Copyright == + +Twenty Seventeen WordPress Theme, Copyright 2016 WordPress.org +Twenty Seventeen is distributed under the terms of the GNU GPL + +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. + +Twenty Seventeen bundles the following third-party resources: + +HTML5 Shiv, Copyright 2014 Alexander Farkas +Licenses: MIT/GPL2 +Source: https://github.com/aFarkas/html5shiv + +jQuery scrollTo, Copyright 2007-2015 Ariel Flesler +License: MIT +Source: https://github.com/flesler/jquery.scrollTo + +normalize.css, Copyright 2012-2016 Nicolas Gallagher and Jonathan Neal +License: MIT +Source: https://necolas.github.io/normalize.css/ + +Font Awesome icons, Copyright Dave Gandy +License: SIL Open Font License, version 1.1. +Source: http://fontawesome.io/ + +Bundled header image, Copyright Alvin Engler +License: CC0 1.0 Universal (CC0 1.0) +Source: https://unsplash.com/@englr?photo=bIhpiQA009k + +== Changelog == + += 1.6 = +* Released: May 17, 2018 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.6 + += 1.5 = +* Released: April 4, 2018 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.5 + += 1.4 = +* Released: November 14, 2017 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.4 + += 1.3 = +* Released: June 8, 2017 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.3 + += 1.2 = +* Released: April 18, 2017 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.2 + += 1.1 = +* Released: January 6, 2017 + +https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.1 + += 1.0 = +* Released: December 6, 2016 + +Initial release diff --git a/backend/wp-content/themes/twentyseventeen/archive.php b/backend/wp-content/themes/twentyseventeen/archive.php new file mode 100644 index 0000000..6f9e03c --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/archive.php @@ -0,0 +1,61 @@ + + +
      + + + + + +
      +
      + + + twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '' . __( 'Previous page', 'twentyseventeen' ) . '', + 'next_text' => '' . __( 'Next page', 'twentyseventeen' ) . '' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), + 'before_page_number' => '' . __( 'Page', 'twentyseventeen' ) . ' ', + ) ); + + else : + + get_template_part( 'template-parts/post/content', 'none' ); + + endif; ?> + +
      +
      + +
      + + .comment-body > .comment-meta > .comment-author .avatar { + border-color: #eee; +} + +.colors-dark input[type="text"]:focus, +.colors-dark input[type="email"]:focus, +.colors-dark input[type="url"]:focus, +.colors-dark input[type="password"]:focus, +.colors-dark input[type="search"]:focus, +.colors-dark input[type="number"]:focus, +.colors-dark input[type="tel"]:focus, +.colors-dark input[type="range"]:focus, +.colors-dark input[type="date"]:focus, +.colors-dark input[type="month"]:focus, +.colors-dark input[type="week"]:focus, +.colors-dark input[type="time"]:focus, +.colors-dark input[type="datetime"]:focus, +.colors-dark input[type="datetime-local"]:focus, +.colors-dark input[type="color"]:focus, +.colors-dark textarea:focus, +.colors-dark button.secondary, +.colors-dark input[type="reset"], +.colors-dark input[type="button"].secondary, +.colors-dark input[type="reset"].secondary, +.colors-dark input[type="submit"].secondary, +.colors-dark a, +.colors-dark .site-title, +.colors-dark .site-title a, +.colors-dark .navigation-top a, +.colors-dark .dropdown-toggle, +.colors-dark .menu-toggle, +.colors-dark .page .panel-content .entry-title, +.colors-dark .page-title, +.colors-dark.page:not(.twentyseventeen-front-page) .entry-title, +.colors-dark .page-links a .page-number, +.colors-dark .comment-metadata a.comment-edit-link, +.colors-dark .comment-reply-link .icon, +.colors-dark h2.widget-title, +.colors-dark mark, +.colors-dark .post-navigation a:focus .icon, +.colors-dark .post-navigation a:hover .icon, +.colors-dark.blog .entry-meta a.post-edit-link, +.colors-dark.archive .entry-meta a.post-edit-link, +.colors-dark.search .entry-meta a.post-edit-link, +.colors-custom .twentyseventeen-panel .recent-posts .entry-header .edit-link { + color: #ddd; +} + +.colors-dark h2, +.colors-dark blockquote, +.colors-dark input[type="text"], +.colors-dark input[type="email"], +.colors-dark input[type="url"], +.colors-dark input[type="password"], +.colors-dark input[type="search"], +.colors-dark input[type="number"], +.colors-dark input[type="tel"], +.colors-dark input[type="range"], +.colors-dark input[type="date"], +.colors-dark input[type="month"], +.colors-dark input[type="week"], +.colors-dark input[type="time"], +.colors-dark input[type="datetime"], +.colors-dark input[type="datetime-local"], +.colors-dark input[type="color"], +.colors-dark textarea, +.colors-dark .navigation-top .current-menu-item > a, +.colors-dark .navigation-top .current_page_item > a, +.colors-dark .entry-content blockquote.alignleft, +.colors-dark .entry-content blockquote.alignright, +.colors-dark .taxonomy-description, +.colors-dark .site-info a, +.colors-dark .wp-caption { + color: #ccc; +} + +.colors-dark abbr, +.colors-dark acronym { + border-bottom-color: #ccc; +} + +.colors-dark h5, +.main-navigation a:hover, +.colors-dark .entry-meta, +.colors-dark .entry-meta a, +.colors-dark .nav-subtitle, +.colors-dark .comment-metadata, +.colors-dark .comment-metadata a, +.colors-dark .no-comments, +.colors-dark .comment-awaiting-moderation, +.colors-dark .page-numbers.current, +.colors-dark .page-links .page-number, +.colors-dark .site-description { + color: #bbb; +} + +.colors-dark button:hover, +.colors-dark button:focus, +.colors-dark input[type="button"]:hover, +.colors-dark input[type="button"]:focus, +.colors-dark input[type="submit"]:hover, +.colors-dark input[type="submit"]:focus, +.colors-dark .prev.page-numbers:focus, +.colors-dark .prev.page-numbers:hover, +.colors-dark .next.page-numbers:focus, +.colors-dark .next.page-numbers:hover, +.colors-dark .entry-footer .edit-link a.post-edit-link:focus, +.colors-dark .entry-footer .edit-link a.post-edit-link:hover { + background: #bbb; +} + +.colors-dark .social-navigation a:hover, +.colors-dark .social-navigation a:focus { + background: #999; + color: #222; +} + +.colors-dark .entry-footer .cat-links .icon, +.colors-dark .entry-footer .tags-links .icon { + color: #666; +} + +.colors-dark button.secondary:hover, +.colors-dark button.secondary:focus, +.colors-dark input[type="reset"]:hover, +.colors-dark input[type="reset"]:focus, +.colors-dark input[type="button"].secondary:hover, +.colors-dark input[type="button"].secondary:focus, +.colors-dark input[type="reset"].secondary:hover, +.colors-dark input[type="reset"].secondary:focus, +.colors-dark input[type="submit"].secondary:hover, +.colors-dark input[type="submit"].secondary:focus, +.colors-dark .social-navigation a, +.colors-dark hr { + background: #555; +} + +.colors-dark input[type="text"], +.colors-dark input[type="email"], +.colors-dark input[type="url"], +.colors-dark input[type="password"], +.colors-dark input[type="search"], +.colors-dark input[type="number"], +.colors-dark input[type="tel"], +.colors-dark input[type="range"], +.colors-dark input[type="date"], +.colors-dark input[type="month"], +.colors-dark input[type="week"], +.colors-dark input[type="time"], +.colors-dark input[type="datetime"], +.colors-dark input[type="datetime-local"], +.colors-dark input[type="color"], +.colors-dark textarea, +.colors-dark select, +.colors-dark fieldset, +.colors-dark .widget .tagcloud a:hover, +.colors-dark .widget .tagcloud a:focus, +.colors-dark .widget.widget_tag_cloud a:hover, +.colors-dark .widget.widget_tag_cloud a:focus, +.colors-dark .wp_widget_tag_cloud a:hover, +.colors-dark .wp_widget_tag_cloud a:focus { + border-color: #555; +} + +.colors-dark button.secondary, +.colors-dark input[type="reset"], +.colors-dark input[type="button"].secondary, +.colors-dark input[type="reset"].secondary, +.colors-dark input[type="submit"].secondary, +.colors-dark .prev.page-numbers, +.colors-dark .next.page-numbers { + background-color: #444; +} + +.colors-dark .widget .tagcloud a, +.colors-dark .widget.widget_tag_cloud a, +.colors-dark .wp_widget_tag_cloud a { + border-color: #444; +} + +.colors-dark.twentyseventeen-front-page article:not(.has-post-thumbnail):not(:first-child), +.colors-dark .widget ul li { + border-top-color: #444; +} + +.colors-dark .widget ul li { + border-bottom-color: #444; +} + +.colors-dark pre, +.colors-dark mark, +.colors-dark ins, +.colors-dark input[type="text"], +.colors-dark input[type="email"], +.colors-dark input[type="url"], +.colors-dark input[type="password"], +.colors-dark input[type="search"], +.colors-dark input[type="number"], +.colors-dark input[type="tel"], +.colors-dark input[type="range"], +.colors-dark input[type="date"], +.colors-dark input[type="month"], +.colors-dark input[type="week"], +.colors-dark input[type="time"], +.colors-dark input[type="datetime"], +.colors-dark input[type="datetime-local"], +.colors-dark input[type="color"], +.colors-dark textarea, +.colors-dark select, +.colors-dark fieldset { + background: #333; +} + +.colors-dark tr, +.colors-dark thead th { + border-color: #333; +} + +.colors-dark .navigation-top, +.colors-dark .main-navigation > div > ul, +.colors-dark .pagination, +.colors-dark .comment-navigation, +.colors-dark .entry-footer, +.colors-dark .site-footer { + border-top-color: #333; +} + +.colors-dark .single-featured-image-header, +.colors-dark .navigation-top, +.colors-dark .main-navigation li, +.colors-dark .entry-footer, +.colors-dark #comments { + border-bottom-color: #333; +} + +.colors-dark .site-header, +.colors-dark .single-featured-image-header { + background-color: #262626; +} + +.colors-dark button, +.colors-dark input[type="button"], +.colors-dark input[type="submit"], +.colors-dark .prev.page-numbers:focus, +.colors-dark .prev.page-numbers:hover, +.colors-dark .next.page-numbers:focus, +.colors-dark .next.page-numbers:hover { + color: #222; +} + +body.colors-dark, +.colors-dark .site-content-contain, +.colors-dark .navigation-top, +.colors-dark .main-navigation ul { + background: #222; +} + +.colors-dark .entry-title a, +.colors-dark .entry-meta a, +.colors-dark.blog .entry-meta a.post-edit-link, +.colors-dark.archive .entry-meta a.post-edit-link, +.colors-dark.search .entry-meta a.post-edit-link, +.colors-dark .page-links a, +.colors-dark .page-links a .page-number, +.colors-dark .entry-footer a, +.colors-dark .entry-footer .cat-links a, +.colors-dark .entry-footer .tags-links a, +.colors-dark .edit-link a, +.colors-dark .post-navigation a, +.colors-dark .logged-in-as a, +.colors-dark .comment-navigation a, +.colors-dark .comment-metadata a, +.colors-dark .comment-metadata a.comment-edit-link, +.colors-dark .comment-reply-link, +.colors-dark a .nav-title, +.colors-dark .pagination a, +.colors-dark .comments-pagination a, +.colors-dark .widget .widget-title a, +.colors-dark .widget ul li a, +.colors-dark .site-footer .widget-area ul li a, +.colors-dark .site-info a { + -webkit-box-shadow: inset 0 -1px 0 rgba(34, 34, 34, 1); /* Equivalant to #222 */ + box-shadow: inset 0 -1px 0 rgba(34, 34, 34, 1); /* Equivalant to #222 */ +} + +/* Fixes linked images */ +.colors-dark .entry-content a img, +.colors-dark .comment-content a img, +.colors-dark .widget a img { + -webkit-box-shadow: 0 0 0 8px #222; + box-shadow: 0 0 0 8px #222; +} + +.colors-dark .entry-footer .edit-link a.post-edit-link { + color: #000; +} + +.colors-dark .menu-toggle, +.colors-dark .menu-toggle:hover, +.colors-dark .menu-toggle:focus, +.colors-dark .dropdown-toggle, +.colors-dark .dropdown-toggle:hover, +.colors-dark .dropdown-toggle:focus, +.colors-dark .menu-scroll-down, +.colors-dark .menu-scroll-down:hover, +.colors-dark .menu-scroll-down:focus { + background-color: transparent; +} + +.colors-dark .gallery-item a, +.colors-dark .gallery-item a:hover, +.colors-dark .gallery-item a:focus, +.colors-dark .widget .tagcloud a, +.colors-dark .widget .tagcloud a:focus, +.colors-dark .widget .tagcloud a:hover, +.colors-dark .widget.widget_tag_cloud a, +.colors-dark .widget.widget_tag_cloud a:focus, +.colors-dark .widget.widget_tag_cloud a:hover, +.colors-dark .wp_widget_tag_cloud a, +.colors-dark .wp_widget_tag_cloud a:focus, +.colors-dark .wp_widget_tag_cloud a:hover, +.colors-dark .entry-footer .edit-link a.post-edit-link:focus, +.colors-dark .entry-footer .edit-link a.post-edit-link:hover { + -webkit-box-shadow: none; + box-shadow: none; +} + +@media screen and (min-width: 48em) { + + .colors-dark .nav-links .nav-previous .nav-title .icon, + .colors-dark .nav-links .nav-next .nav-title .icon { + color: #eee; + } + + .colors-dark .main-navigation li li:hover, + .colors-dark .main-navigation li li.focus { + background: #999; + } + + .colors-dark .menu-scroll-down { + color: #999; + } + + .colors-dark .main-navigation ul ul { + border-color: #333; + background: #222; + } + + .colors-dark .main-navigation ul li.menu-item-has-children:before, + .colors-dark .main-navigation ul li.page_item_has_children:before { + border-bottom-color: #333; + } + + .main-navigation ul li.menu-item-has-children:after, + .main-navigation ul li.page_item_has_children:after { + border-bottom-color: #222; + } + + .colors-dark .main-navigation li li.focus > a, + .colors-dark .main-navigation li li:focus > a, + .colors-dark .main-navigation li li:hover > a, + .colors-dark .main-navigation li li a:hover, + .colors-dark .main-navigation li li a:focus, + .colors-dark .main-navigation li li.current_page_item a:hover, + .colors-dark .main-navigation li li.current-menu-item a:hover, + .colors-dark .main-navigation li li.current_page_item a:focus, + .colors-dark .main-navigation li li.current-menu-item a:focus { + color: #222; + } + +} diff --git a/backend/wp-content/themes/twentyseventeen/assets/css/editor-style.css b/backend/wp-content/themes/twentyseventeen/assets/css/editor-style.css new file mode 100644 index 0000000..5c11373 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/css/editor-style.css @@ -0,0 +1,600 @@ +/* +Theme Name: Twenty Seventeen +Description: Used to style the TinyMCE editor. +*/ + + +/** + * Table of Contents: + * + * 1.0 - Body + * 2.0 - Typography + * 3.0 - Elements + * 4.0 - Alignment + * 5.0 - Caption + * 6.0 - Galleries + * 7.0 - Media Elements + * 8.0 - RTL + */ + +/** + * 1.0 - Body + */ + +body { + background-color: #fff; + color: #333; + margin: 20px 40px; + max-width: 580px; +} + +/** + * 2.0 - Typography + */ + +body, +button, +input, +select, +textarea { + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; + font-size: 16px; + font-size: 1rem; + font-weight: 400; + line-height: 1.66; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + line-height: 1.4; + margin: 0 0 0.75em; + padding: 1.5em 0 0; +} + +h1:first-child, +h2:first-child, +h3:first-child, +h4:first-child, +h5:first-child, +h6:first-child { + padding-top: 0; +} + +h1 { + font-size: 24px; + font-size: 1.5rem; + font-weight: 300; +} + +h2 { + color: #666; + font-size: 20px; + font-size: 1.25rem; + font-weight: 300; +} + +h3 { + color: #333; + font-size: 18px; + font-size: 1.125rem; + font-weight: 300; +} + +h4 { + color: #333; + font-size: 16px; + font-size: 1rem; + font-weight: 800; +} + +h5 { + color: #767676; + font-size: 13px; + font-size: 0.8125rem; + font-weight: 800; + letter-spacing: 0.15em; + text-transform: uppercase; +} + +h6 { + color: #333; + font-size: 15px; + font-size: 0.9375rem; + font-weight: 800; +} + +p { + margin: 0 0 1.5em; + padding: 0; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + color: #666; + font-size: 18px; + font-size: 1.125rem; + font-style: italic; + line-height: 1.7; + margin: 0; + overflow: hidden; + padding: 0; +} + +blockquote.alignleft, +blockquote.alignright { + font-size: 14px; + font-size: 0.875rem; + width: 34%; +} + +address { + margin: 0 0 1.5em; +} + +pre { + background: #eee; + font-family: "Courier 10 Pitch", Courier, monospace; + font-size: 15px; + font-size: 0.9375rem; + line-height: 1.6; + margin-bottom: 1.6em; + max-width: 100%; + overflow: auto; + padding: 1.6em; +} + +code, +kbd, +tt, +var { + font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; + font-size: 15px; + font-size: 0.9375rem; +} + +abbr, +acronym { + border-bottom: 1px dotted #666; + cursor: help; +} + +mark, +ins { + background: #eee; + text-decoration: none; +} + +big { + font-size: 125%; +} + +blockquote, +q { + quotes: "" ""; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; +} + +/* Typography for Thai Font */ + +html[lang="th"] h1, +html[lang="th"] h2, +html[lang="th"] h3, +html[lang="th"] h4, +html[lang="th"] h5, +html[lang="th"] h6 { + letter-spacing: 0; + line-height: 1.65; +} + +html[lang="th"] body, +html[lang="th"] button, +html[lang="th"] input, +html[lang="th"] select, +html[lang="th"] textarea { + line-height: 1.8; +} + +/** + * 3.0 - Elements + */ + +hr { + background-color: #bbb; + border: 0; + height: 1px; + margin-bottom: 1.5em; +} + +ul, +ol { + margin: 0 0 1.5em; + padding: 0; +} + +ul { + list-style: disc; +} + +ol { + counter-reset: item; +} + +ol li { + display: block; + position: relative; +} + +ol li:before { + content: counter(item); + counter-increment: item; + font-weight: 800; + left: -1.5em; + position: absolute; +} + +li > ul, +li > ol { + margin-bottom: 0; + margin-left: 1.5em; +} + +dt { + font-weight: 700; +} + +dd { + margin: 0 1.5em 1.5em; +} + +table { + border-collapse: collapse; + margin: 0 0 1.5em; + width: 100%; +} + +thead th { + border-bottom: 2px solid #bbb; + padding-bottom: 0.5em; +} + +th { + padding: 0.4em; + text-align: left; +} + +tr { + border-bottom: 1px solid #eee; +} + +td { + padding: 0.4em; +} + +th:first-child, +td:first-child { + padding-left: 0; +} + +th:last-child, +td:last-child { + padding-right: 0; +} + +a { + -webkit-box-shadow: inset 0 -1px 0 rgba(15, 15, 15, 1); + box-shadow: inset 0 -1px 0 rgba(15, 15, 15, 1); + color: #222; + text-decoration: none; + -webkit-transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out, -webkit-box-shadow 130ms ease-in-out; +} + +a:focus { + outline: thin dotted; +} + +a:hover, +a:focus { + color: #000; + -webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1); + box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1); +} + +/* Fixes linked images */ + +a img { + background: #fff; + -webkit-box-shadow: 0 0 0 6px #fff; + box-shadow: 0 0 0 6px #fff; +} + +/** + * 4.0 - Alignment + */ + +img { + height: auto; /* Make sure images are scaled correctly. */ + width: inherit; /* Make images fill their parent's space. Solves IE8. */ + max-width: 100%; /* Adhere to container width. */ +} + +embed, +iframe, +object { + margin-bottom: 1.5em; + max-width: 100%; +} + +/** + * 5.0 - Caption + */ + +.wp-caption { + color: #666; + font-size: 13px; + font-size: 0.8125rem; + font-style: italic; + margin-bottom: 1.5em; + max-width: 100%; +} + +.wp-caption img[class*="wp-image-"] { + display: block; + margin-left: auto; + margin-right: auto; +} + +.wp-caption .wp-caption-text { + margin: 0.8075em 0; +} + +/** + * 6.0 - Galleries + */ + +.gallery { + margin-bottom: 1.5em; +} + +.gallery-item { + display: inline-block; + text-align: center; + vertical-align: top; + width: 100%; +} + +.gallery-item a, +.gallery-item a:hover, +.gallery-item a:focus { + -webkit-box-shadow: none; + box-shadow: none; + background: none; + display: inline-block; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-columns-3 .gallery-item { + max-width: 33.33%; +} + +.gallery-columns-4 .gallery-item { + max-width: 25%; +} + +.gallery-columns-5 .gallery-item { + max-width: 20%; +} + +.gallery-columns-6 .gallery-item { + max-width: 16.66%; +} + +.gallery-columns-7 .gallery-item { + max-width: 14.28%; +} + +.gallery-columns-8 .gallery-item { + max-width: 12.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 11.11%; +} + +.gallery-caption { + display: block; +} + +/** + * 7.0 - Media Elements + */ + +.mejs-container { + margin-bottom: 1.5em; +} + +/* Audio Player */ + +.mejs-controls a.mejs-horizontal-volume-slider, +.mejs-controls a.mejs-horizontal-volume-slider:focus, +.mejs-controls a.mejs-horizontal-volume-slider:hover { + background: transparent; + border: 0; +} + +/* Playlist Color Overrides: Light */ + +.wp-playlist-light { + border-color: #eee; + color: #222; +} + +.wp-playlist-light .wp-playlist-current-item .wp-playlist-item-album { + color: #333; +} + +.wp-playlist-light .wp-playlist-current-item .wp-playlist-item-artist { + color: #767676; +} + +.wp-playlist-light .wp-playlist-item { + border-bottom: 1px dotted #eee; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; +} + +.wp-playlist-light .wp-playlist-item:hover, +.wp-playlist-light .wp-playlist-item:focus { + border-bottom-color: rgba(0, 0, 0, 0); + background-color: #767676; + color: #fff; +} + +.wp-playlist-light a.wp-playlist-caption:hover, +.wp-playlist-light .wp-playlist-item:hover a, +.wp-playlist-light .wp-playlist-item:focus a { + color: #fff; +} + +/* Playlist Color Overrides: Dark */ + +.wp-playlist-dark { + background: #222; + border-color: #333; +} + +.wp-playlist-dark .mejs-container .mejs-controls { + background-color: #333; +} + +.wp-playlist-dark .wp-playlist-caption { + color: #fff; +} + +.wp-playlist-dark .wp-playlist-current-item .wp-playlist-item-album { + color: #eee; +} + +.wp-playlist-dark .wp-playlist-current-item .wp-playlist-item-artist { + color: #aaa; +} + +.wp-playlist-dark .wp-playlist-playing { + background-color: #333; +} + +.wp-playlist-dark .wp-playlist-item { + border-bottom: 1px dotted #555; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; +} + +.wp-playlist-dark .wp-playlist-item:hover, +.wp-playlist-dark .wp-playlist-item:focus { + border-bottom-color: rgba(0, 0, 0, 0); + background-color: #aaa; + color: #222; +} + +.wp-playlist-dark a.wp-playlist-caption:hover, +.wp-playlist-dark .wp-playlist-item:hover a, +.wp-playlist-dark .wp-playlist-item:focus a { + color: #222; +} + +/* Playlist Style Overrides */ + +.wp-playlist { + padding: 0.625em 0.625em 0.3125em; +} + +.wp-playlist-current-item .wp-playlist-item-title { + font-weight: 700; +} + +.wp-playlist-current-item .wp-playlist-item-album { + font-style: normal; +} + +.wp-playlist-current-item .wp-playlist-item-artist { + font-size: 10px; + font-size: 0.625rem; + font-weight: 800; + letter-spacing: 0.1818em; + text-transform: uppercase; +} + +.wp-playlist-item { + padding: 0 0.3125em; + cursor: pointer; +} + +.wp-playlist-item:last-of-type { + border-bottom: none; +} + +.wp-playlist-item a { + padding: 0.3125em 0; + border-bottom: none; +} + +.wp-playlist-item a, +.wp-playlist-item a:focus, +.wp-playlist-item a:hover { + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; +} + +.wp-playlist-item-length { + top: 5px; +} + +/** + * 8.0 - RTL + */ + +.rtl th { + text-align: right; +} + +.rtl ol { + counter-reset: item; +} + +.rtl ol li:before { + left: auto; + right: -1.5em; +} + +.rtl li > ul, +.rtl li > ol { + margin-left: 0; + margin-right: 1.5em; +} + +.rtl .mejs-offscreen { + right: -10000px; +} diff --git a/backend/wp-content/themes/twentyseventeen/assets/css/ie8.css b/backend/wp-content/themes/twentyseventeen/assets/css/ie8.css new file mode 100644 index 0000000..bf45c26 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/css/ie8.css @@ -0,0 +1,225 @@ +/* +Theme Name: Twenty Seventeen +Description: IE8 specific style. +*/ + +body { + font-size: 16px; +} + +h1 { + font-size: 30px; + font-size: 1.875rem; +} + +h2, +.page .panel-content .recent-posts .entry-title { + font-size: 26px; + font-size: 1.625rem; +} + +h3 { + font-size: 22px; + font-size: 1.375rem; +} + +h4 { + font-size: 18px; + font-size: 1.125rem; +} + +h5 { + font-size: 13px; + font-size: 0.8125rem; +} + +h6 { + font-size: 16px; + font-size: 1rem; +} + +img { + width: inherit; /* Make images fill their parent's space. */ +} + +/* Fixes linked images */ +.entry-content a img, +.widget a img { + filter: progid:DXImageTransform.Microsoft.DropShadow(OffX=0, OffY=5, Color=#ffffff); +} + +/* Layout */ + +.site-content { + padding: 6.5em 0 0; +} + +/* Site Branding */ + +.custom-header { + overflow: hidden; +} + +.has-header-image.twentyseventeen-front-page .custom-header, +.has-header-image.home.blog .custom-header { + display: block; +} + +.custom-header-media { + background-position: bottom center; +} + +.site-branding { + padding: 45px 0; +} + +.has-header-image.twentyseventeen-front-page .site-branding, +.has-header-image.home.blog .site-branding { + bottom: 0; + display: block; + left: 0; + height: auto; + padding-top: 0; + position: absolute; + width: 100%; +} + +.has-header-image .custom-header-media img { + left: 0; + top: 0; +} + +.site-title { + font-size: 36px; + font-weight: 700; +} + +.site-description { + font-size: 16px; +} + +/* Main Navigation */ + +.navigation-top { + background: #fff; + position: relative; + z-index: 10; +} + +.menu-toggle { + width: 150px; +} + +.main-navigation ul#top-menu { + margin-bottom: -1px; + padding: 0; +} + +.no-svg .dropdown-toggle { + padding: 0.25em 0 0; +} + +.no-svg .dropdown-toggle.toggled-on { + padding: 0.75em 0 0; +} + +.dropdown-toggle .svg-fallback.icon-angle-down { + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=-1, M12=1.2246467991473532e-16, M21=-1.2246467991473532e-16, M22=-1, SizingMethod='auto expand')"; +} + +.dropdown-toggle.toggled-on .svg-fallback.icon-angle-down { + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, SizingMethod='auto expand')"; +} + +/* Front Page */ + +.twentyseventeen-front-page.has-header-image .custom-header, +.blog.home.has-header-image .custom-header, +.panel-image { + height: 800px; + max-height: 800px; + padding-top: 0; +} + +.twentyseventeen-front-page .custom-header-media, +.blog.home .custom-header-media { + background-position: center center; +} + +.twentyseventeen-front-page.has-header-image .site-branding, +.home.blog.has-header-image .site-branding { + bottom: 20px; + position: absolute; + width: 100%; +} + +.page .panel-content .entry-title, +.page-title, +.page .entry-title { + font-size: 14px; + font-size: 0.875rem; + font-weight: 700; + letter-spacing: 0.14em; + text-transform: uppercase; +} + +/* Posts */ + +.blog .site-main > article, +.archive .site-main > article, +.search .site-main > article { + padding-bottom: 4em; +} + +time.updated { + display: none; +} + +time.published { + display: inline-block; +} + +.blog .entry-title { + padding-top: 0; +} + +.single-post .entry-title, +.page .entry-title, +.entry-meta + .entry-title { + font-size: 26px; + font-weight: 400; + letter-spacing: normal; + padding-top: 0; + text-transform: none; +} + +.entry-footer .cat-links, +.entry-footer .tags-links { + padding-left: 0; +} + +.comment-author .avatar { + z-index: -1; +} + +ol.children .children { + padding-left: 2em; +} + +/* RTL Styles */ + +.rtl .has-header-image.twentyseventeen-front-page .site-branding, +.rtl .has-header-image.home.blog .site-branding { + left: auto; + right: 0; +} + +.rtl .entry-footer .cat-links, +.rtl .entry-footer .tags-links { + padding-right: 0; +} + +.rtl ol.children .children { + padding-left: 0; + padding-right: 2em; +} diff --git a/backend/wp-content/themes/twentyseventeen/assets/css/ie9.css b/backend/wp-content/themes/twentyseventeen/assets/css/ie9.css new file mode 100644 index 0000000..9f8f766 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/css/ie9.css @@ -0,0 +1,43 @@ +/* +Theme Name: Twenty Seventeen +Description: IE9 specific styles. +*/ + +.has-header-image.twentyseventeen-front-page .custom-header, +.has-header-video.twentyseventeen-front-page .custom-header, +.has-header-image.home.blog .custom-header, +.has-header-video.home.blog .custom-header { + height: 300px; +} + +.has-header-image .custom-header-media img, +.has-header-video .custom-header-media video, +.has-header-video .custom-header-media iframe { + min-width: 100%; +} + +@media screen and (min-width: 30em) { + + .has-header-image.twentyseventeen-front-page .custom-header, + .has-header-video.twentyseventeen-front-page .custom-header, + .has-header-image.home.blog .custom-header, + .has-header-video.home.blog .custom-header, + .twentyseventeen-front-page.has-header-image .custom-header-media, + .home.blog.has-header-image .custom-header-media, + .panel-image { + height: 700px; + } +} + +@media screen and (min-width: 48em) { + + .has-header-image.twentyseventeen-front-page .custom-header, + .has-header-video.twentyseventeen-front-page .custom-header, + .has-header-image.home.blog .custom-header, + .has-header-video.home.blog .custom-header, + .twentyseventeen-front-page.has-header-image .custom-header-media, + .home.blog.has-header-image .custom-header-media, + .panel-image { + height: 1000px; + } +} diff --git a/backend/wp-content/themes/twentyseventeen/assets/images/coffee.jpg b/backend/wp-content/themes/twentyseventeen/assets/images/coffee.jpg new file mode 100644 index 0000000..13847cd Binary files /dev/null and b/backend/wp-content/themes/twentyseventeen/assets/images/coffee.jpg differ diff --git a/backend/wp-content/themes/twentyseventeen/assets/images/espresso.jpg b/backend/wp-content/themes/twentyseventeen/assets/images/espresso.jpg new file mode 100644 index 0000000..7514c96 Binary files /dev/null and b/backend/wp-content/themes/twentyseventeen/assets/images/espresso.jpg differ diff --git a/backend/wp-content/themes/twentyseventeen/assets/images/header.jpg b/backend/wp-content/themes/twentyseventeen/assets/images/header.jpg new file mode 100644 index 0000000..a3fd3e7 Binary files /dev/null and b/backend/wp-content/themes/twentyseventeen/assets/images/header.jpg differ diff --git a/backend/wp-content/themes/twentyseventeen/assets/images/sandwich.jpg b/backend/wp-content/themes/twentyseventeen/assets/images/sandwich.jpg new file mode 100644 index 0000000..6baddbf Binary files /dev/null and b/backend/wp-content/themes/twentyseventeen/assets/images/sandwich.jpg differ diff --git a/backend/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg b/backend/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg new file mode 100644 index 0000000..d5f9ade --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/images/svg-icons.svg @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/themes/twentyseventeen/assets/js/customize-controls.js b/backend/wp-content/themes/twentyseventeen/assets/js/customize-controls.js new file mode 100644 index 0000000..e6f6037 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/js/customize-controls.js @@ -0,0 +1,36 @@ +/** + * Scripts within the customizer controls window. + * + * Contextually shows the color hue control and informs the preview + * when users open or close the front page sections section. + */ + +(function() { + wp.customize.bind( 'ready', function() { + + // Only show the color hue control when there's a custom color scheme. + wp.customize( 'colorscheme', function( setting ) { + wp.customize.control( 'colorscheme_hue', function( control ) { + var visibility = function() { + if ( 'custom' === setting.get() ) { + control.container.slideDown( 180 ); + } else { + control.container.slideUp( 180 ); + } + }; + + visibility(); + setting.bind( visibility ); + }); + }); + + // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly. + wp.customize.section( 'theme_options', function( section ) { + section.expanded.bind( function( isExpanding ) { + + // Value of isExpanding will = true if you're entering the section, false if you're leaving it. + wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding }); + } ); + } ); + }); +})( jQuery ); diff --git a/backend/wp-content/themes/twentyseventeen/assets/js/customize-preview.js b/backend/wp-content/themes/twentyseventeen/assets/js/customize-preview.js new file mode 100644 index 0000000..dba7b79 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/js/customize-preview.js @@ -0,0 +1,150 @@ +/** + * File customize-preview.js. + * + * Instantly live-update customizer settings in the preview for improved user experience. + */ + +(function( $ ) { + + // Collect information from customize-controls.js about which panels are opening. + wp.customize.bind( 'preview-ready', function() { + + // Initially hide the theme option placeholders on load + $( '.panel-placeholder' ).hide(); + + wp.customize.preview.bind( 'section-highlight', function( data ) { + + // Only on the front page. + if ( ! $( 'body' ).hasClass( 'twentyseventeen-front-page' ) ) { + return; + } + + // When the section is expanded, show and scroll to the content placeholders, exposing the edit links. + if ( true === data.expanded ) { + $( 'body' ).addClass( 'highlight-front-sections' ); + $( '.panel-placeholder' ).slideDown( 200, function() { + $.scrollTo( $( '#panel1' ), { + duration: 600, + offset: { 'top': -70 } // Account for sticky menu. + }); + }); + + // If we've left the panel, hide the placeholders and scroll back to the top. + } else { + $( 'body' ).removeClass( 'highlight-front-sections' ); + // Don't change scroll when leaving - it's likely to have unintended consequences. + $( '.panel-placeholder' ).slideUp( 200 ); + } + }); + }); + + // Site title and description. + wp.customize( 'blogname', function( value ) { + value.bind( function( to ) { + $( '.site-title a' ).text( to ); + }); + }); + wp.customize( 'blogdescription', function( value ) { + value.bind( function( to ) { + $( '.site-description' ).text( to ); + }); + }); + + // Header text color. + wp.customize( 'header_textcolor', function( value ) { + value.bind( function( to ) { + if ( 'blank' === to ) { + $( '.site-title, .site-description' ).css({ + clip: 'rect(1px, 1px, 1px, 1px)', + position: 'absolute' + }); + // Add class for different logo styles if title and description are hidden. + $( 'body' ).addClass( 'title-tagline-hidden' ); + } else { + + // Check if the text color has been removed and use default colors in theme stylesheet. + if ( ! to.length ) { + $( '#twentyseventeen-custom-header-styles' ).remove(); + } + $( '.site-title, .site-description' ).css({ + clip: 'auto', + position: 'relative' + }); + $( '.site-branding, .site-branding a, .site-description, .site-description a' ).css({ + color: to + }); + // Add class for different logo styles if title and description are visible. + $( 'body' ).removeClass( 'title-tagline-hidden' ); + } + }); + }); + + // Color scheme. + wp.customize( 'colorscheme', function( value ) { + value.bind( function( to ) { + + // Update color body class. + $( 'body' ) + .removeClass( 'colors-light colors-dark colors-custom' ) + .addClass( 'colors-' + to ); + }); + }); + + // Custom color hue. + wp.customize( 'colorscheme_hue', function( value ) { + value.bind( function( to ) { + + // Update custom color CSS. + var style = $( '#custom-theme-colors' ), + hue = style.data( 'hue' ), + css = style.html(); + + // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed. + css = css.split( hue + ',' ).join( to + ',' ); + style.html( css ).data( 'hue', to ); + }); + }); + + // Page layouts. + wp.customize( 'page_layout', function( value ) { + value.bind( function( to ) { + if ( 'one-column' === to ) { + $( 'body' ).addClass( 'page-one-column' ).removeClass( 'page-two-column' ); + } else { + $( 'body' ).removeClass( 'page-one-column' ).addClass( 'page-two-column' ); + } + } ); + } ); + + // Whether a header image is available. + function hasHeaderImage() { + var image = wp.customize( 'header_image' )(); + return '' !== image && 'remove-header' !== image; + } + + // Whether a header video is available. + function hasHeaderVideo() { + var externalVideo = wp.customize( 'external_header_video' )(), + video = wp.customize( 'header_video' )(); + + return '' !== externalVideo || ( 0 !== video && '' !== video ); + } + + // Toggle a body class if a custom header exists. + $.each( [ 'external_header_video', 'header_image', 'header_video' ], function( index, settingId ) { + wp.customize( settingId, function( setting ) { + setting.bind(function() { + if ( hasHeaderImage() ) { + $( document.body ).addClass( 'has-header-image' ); + } else { + $( document.body ).removeClass( 'has-header-image' ); + } + + if ( ! hasHeaderVideo() ) { + $( document.body ).removeClass( 'has-header-video' ); + } + } ); + } ); + } ); + +} )( jQuery ); diff --git a/backend/wp-content/themes/twentyseventeen/assets/js/global.js b/backend/wp-content/themes/twentyseventeen/assets/js/global.js new file mode 100644 index 0000000..6e2f429 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/js/global.js @@ -0,0 +1,249 @@ +/* global twentyseventeenScreenReaderText */ +(function( $ ) { + + // Variables and DOM Caching. + var $body = $( 'body' ), + $customHeader = $body.find( '.custom-header' ), + $branding = $customHeader.find( '.site-branding' ), + $navigation = $body.find( '.navigation-top' ), + $navWrap = $navigation.find( '.wrap' ), + $navMenuItem = $navigation.find( '.menu-item' ), + $menuToggle = $navigation.find( '.menu-toggle' ), + $menuScrollDown = $body.find( '.menu-scroll-down' ), + $sidebar = $body.find( '#secondary' ), + $entryContent = $body.find( '.entry-content' ), + $formatQuote = $body.find( '.format-quote blockquote' ), + isFrontPage = $body.hasClass( 'twentyseventeen-front-page' ) || $body.hasClass( 'home blog' ), + navigationFixedClass = 'site-navigation-fixed', + navigationHeight, + navigationOuterHeight, + navPadding, + navMenuItemHeight, + idealNavHeight, + navIsNotTooTall, + headerOffset, + menuTop = 0, + resizeTimer; + + // Ensure the sticky navigation doesn't cover current focused links. + $( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]', '.site-content-contain' ).filter( ':visible' ).focus( function() { + if ( $navigation.hasClass( 'site-navigation-fixed' ) ) { + var windowScrollTop = $( window ).scrollTop(), + fixedNavHeight = $navigation.height(), + itemScrollTop = $( this ).offset().top, + offsetDiff = itemScrollTop - windowScrollTop; + + // Account for Admin bar. + if ( $( '#wpadminbar' ).length ) { + offsetDiff -= $( '#wpadminbar' ).height(); + } + + if ( offsetDiff < fixedNavHeight ) { + $( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 0 ); + } + } + }); + + // Set properties of navigation. + function setNavProps() { + navigationHeight = $navigation.height(); + navigationOuterHeight = $navigation.outerHeight(); + navPadding = parseFloat( $navWrap.css( 'padding-top' ) ) * 2; + navMenuItemHeight = $navMenuItem.outerHeight() * 2; + idealNavHeight = navPadding + navMenuItemHeight; + navIsNotTooTall = navigationHeight <= idealNavHeight; + } + + // Make navigation 'stick'. + function adjustScrollClass() { + + // Make sure we're not on a mobile screen. + if ( 'none' === $menuToggle.css( 'display' ) ) { + + // Make sure the nav isn't taller than two rows. + if ( navIsNotTooTall ) { + + // When there's a custom header image or video, the header offset includes the height of the navigation. + if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) { + headerOffset = $customHeader.innerHeight() - navigationOuterHeight; + } else { + headerOffset = $customHeader.innerHeight(); + } + + // If the scroll is more than the custom header, set the fixed class. + if ( $( window ).scrollTop() >= headerOffset ) { + $navigation.addClass( navigationFixedClass ); + } else { + $navigation.removeClass( navigationFixedClass ); + } + + } else { + + // Remove 'fixed' class if nav is taller than two rows. + $navigation.removeClass( navigationFixedClass ); + } + } + } + + // Set margins of branding in header. + function adjustHeaderHeight() { + if ( 'none' === $menuToggle.css( 'display' ) ) { + + // The margin should be applied to different elements on front-page or home vs interior pages. + if ( isFrontPage ) { + $branding.css( 'margin-bottom', navigationOuterHeight ); + } else { + $customHeader.css( 'margin-bottom', navigationOuterHeight ); + } + + } else { + $customHeader.css( 'margin-bottom', '0' ); + $branding.css( 'margin-bottom', '0' ); + } + } + + // Set icon for quotes. + function setQuotesIcon() { + $( twentyseventeenScreenReaderText.quote ).prependTo( $formatQuote ); + } + + // Add 'below-entry-meta' class to elements. + function belowEntryMetaClass( param ) { + var sidebarPos, sidebarPosBottom; + + if ( ! $body.hasClass( 'has-sidebar' ) || ( + $body.hasClass( 'search' ) || + $body.hasClass( 'single-attachment' ) || + $body.hasClass( 'error404' ) || + $body.hasClass( 'twentyseventeen-front-page' ) + ) ) { + return; + } + + sidebarPos = $sidebar.offset(); + sidebarPosBottom = sidebarPos.top + ( $sidebar.height() + 28 ); + + $entryContent.find( param ).each( function() { + var $element = $( this ), + elementPos = $element.offset(), + elementPosTop = elementPos.top; + + // Add 'below-entry-meta' to elements below the entry meta. + if ( elementPosTop > sidebarPosBottom ) { + $element.addClass( 'below-entry-meta' ); + } else { + $element.removeClass( 'below-entry-meta' ); + } + }); + } + + /* + * Test if inline SVGs are supported. + * @link https://github.com/Modernizr/Modernizr/ + */ + function supportsInlineSVG() { + var div = document.createElement( 'div' ); + div.innerHTML = ''; + return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI ); + } + + /** + * Test if an iOS device. + */ + function checkiOS() { + return /iPad|iPhone|iPod/.test(navigator.userAgent) && ! window.MSStream; + } + + /* + * Test if background-attachment: fixed is supported. + * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed + */ + function supportsFixedBackground() { + var el = document.createElement('div'), + isSupported; + + try { + if ( ! ( 'backgroundAttachment' in el.style ) || checkiOS() ) { + return false; + } + el.style.backgroundAttachment = 'fixed'; + isSupported = ( 'fixed' === el.style.backgroundAttachment ); + return isSupported; + } + catch (e) { + return false; + } + } + + // Fire on document ready. + $( document ).ready( function() { + + // If navigation menu is present on page, setNavProps and adjustScrollClass. + if ( $navigation.length ) { + setNavProps(); + adjustScrollClass(); + } + + // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event. + if ( $menuScrollDown.length ) { + + if ( $( 'body' ).hasClass( 'admin-bar' ) ) { + menuTop -= 32; + } + if ( $( 'body' ).hasClass( 'blog' ) ) { + menuTop -= 30; // The div for latest posts has no space above content, add some to account for this. + } + if ( ! $navigation.length ) { + navigationOuterHeight = 0; + } + + $menuScrollDown.click( function( e ) { + e.preventDefault(); + $( window ).scrollTo( '#primary', { + duration: 600, + offset: { top: menuTop - navigationOuterHeight } + }); + }); + } + + adjustHeaderHeight(); + setQuotesIcon(); + if ( true === supportsInlineSVG() ) { + document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' ); + } + + if ( true === supportsFixedBackground() ) { + document.documentElement.className += ' background-fixed'; + } + }); + + // If navigation menu is present on page, adjust it on scroll and screen resize. + if ( $navigation.length ) { + + // On scroll, we want to stick/unstick the navigation. + $( window ).on( 'scroll', function() { + adjustScrollClass(); + adjustHeaderHeight(); + }); + + // Also want to make sure the navigation is where it should be on resize. + $( window ).resize( function() { + setNavProps(); + setTimeout( adjustScrollClass, 500 ); + }); + } + + $( window ).resize( function() { + clearTimeout( resizeTimer ); + resizeTimer = setTimeout( function() { + belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); + }, 300 ); + setTimeout( adjustHeaderHeight, 1000 ); + }); + + // Add header video class after the video is loaded. + $( document ).on( 'wp-custom-header-video-loaded', function() { + $body.addClass( 'has-header-video' ); + }); + +})( jQuery ); diff --git a/backend/wp-content/themes/twentyseventeen/assets/js/html5.js b/backend/wp-content/themes/twentyseventeen/assets/js/html5.js new file mode 100644 index 0000000..9c1f049 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/js/html5.js @@ -0,0 +1,326 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +;(function(window, document) { +/*jshint evil:true */ + /** version */ + var version = '3.7.3'; + + /** Preset options */ + var options = window.html5 || {}; + + /** Used to skip problem elements */ + var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; + + /** Not all elements can be cloned in IE **/ + var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; + + /** Detect whether the browser supports default html5 styles */ + var supportsHtml5Styles; + + /** Name of the expando, to work with multiple documents or to re-shiv one document */ + var expando = '_html5shiv'; + + /** The id for the the documents expando */ + var expanID = 0; + + /** Cached data for each document */ + var expandoData = {}; + + /** Detect whether the browser supports unknown elements */ + var supportsUnknownElements; + + (function() { + try { + var a = document.createElement('a'); + a.innerHTML = ''; + //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles + supportsHtml5Styles = ('hidden' in a); + + supportsUnknownElements = a.childNodes.length == 1 || (function() { + // assign a false positive if unable to shiv + (document.createElement)('a'); + var frag = document.createDocumentFragment(); + return ( + typeof frag.cloneNode == 'undefined' || + typeof frag.createDocumentFragment == 'undefined' || + typeof frag.createElement == 'undefined' + ); + }()); + } catch(e) { + // assign a false positive if detection fails => unable to shiv + supportsHtml5Styles = true; + supportsUnknownElements = true; + } + + }()); + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a style sheet with the given CSS text and adds it to the document. + * @private + * @param {Document} ownerDocument The document. + * @param {String} cssText The CSS text. + * @returns {StyleSheet} The style element. + */ + function addStyleSheet(ownerDocument, cssText) { + var p = ownerDocument.createElement('p'), + parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; + + p.innerHTML = 'x'; + return parent.insertBefore(p.lastChild, parent.firstChild); + } + + /** + * Returns the value of `html5.elements` as an array. + * @private + * @returns {Array} An array of shived element node names. + */ + function getElements() { + var elements = html5.elements; + return typeof elements == 'string' ? elements.split(' ') : elements; + } + + /** + * Extends the built-in list of html5 elements + * @memberOf html5 + * @param {String|Array} newElements whitespace separated list or array of new element names to shiv + * @param {Document} ownerDocument The context document. + */ + function addElements(newElements, ownerDocument) { + var elements = html5.elements; + if(typeof elements != 'string'){ + elements = elements.join(' '); + } + if(typeof newElements != 'string'){ + newElements = newElements.join(' '); + } + html5.elements = elements +' '+ newElements; + shivDocument(ownerDocument); + } + + /** + * Returns the data associated to the given document + * @private + * @param {Document} ownerDocument The document. + * @returns {Object} An object of data. + */ + function getExpandoData(ownerDocument) { + var data = expandoData[ownerDocument[expando]]; + if (!data) { + data = {}; + expanID++; + ownerDocument[expando] = expanID; + expandoData[expanID] = data; + } + return data; + } + + /** + * returns a shived element for the given nodeName and document + * @memberOf html5 + * @param {String} nodeName name of the element + * @param {Document|DocumentFragment} ownerDocument The context document. + * @returns {Object} The shived element. + */ + function createElement(nodeName, ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createElement(nodeName); + } + if (!data) { + data = getExpandoData(ownerDocument); + } + var node; + + if (data.cache[nodeName]) { + node = data.cache[nodeName].cloneNode(); + } else if (saveClones.test(nodeName)) { + node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); + } else { + node = data.createElem(nodeName); + } + + // Avoid adding some elements to fragments in IE < 9 because + // * Attributes like `name` or `type` cannot be set/changed once an element + // is inserted into a document/fragment + // * Link elements with `src` attributes that are inaccessible, as with + // a 403 response, will cause the tab/window to crash + // * Script elements appended to fragments will execute when their `src` + // or `text` property is set + return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; + } + + /** + * returns a shived DocumentFragment for the given document + * @memberOf html5 + * @param {Document} ownerDocument The context document. + * @returns {Object} The shived DocumentFragment. + */ + function createDocumentFragment(ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createDocumentFragment(); + } + data = data || getExpandoData(ownerDocument); + var clone = data.frag.cloneNode(), + i = 0, + elems = getElements(), + l = elems.length; + for(;igmailcom | http://flesler.blogspot.com + * Licensed under MIT + * http://flesler.blogspot.com/2007/10/jqueryscrollto.html + * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + // AMD + define( ['jquery'], factory ); + } else if (typeof module !== 'undefined' && module.exports) { + // CommonJS + module.exports = factory( require( 'jquery' ) ); + } else { + // Global + factory( jQuery ); + } +})(function($) { + 'use strict'; + + var $scrollTo = $.scrollTo = function(target, duration, settings) { + return $( window ).scrollTo( target, duration, settings ); + }; + + $scrollTo.defaults = { + axis:'xy', + duration: 0, + limit:true + }; + + function isWin(elem) { + return ! elem.nodeName || + $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) !== -1; + } + + $.fn.scrollTo = function(target, duration, settings) { + if (typeof duration === 'object') { + settings = duration; + duration = 0; + } + if (typeof settings === 'function') { + settings = { onAfter:settings }; + } + if (target === 'max') { + target = 9e9; + } + + settings = $.extend( {}, $scrollTo.defaults, settings ); + // Speed is still recognized for backwards compatibility + duration = duration || settings.duration; + // Make sure the settings are given right + var queue = settings.queue && settings.axis.length > 1; + if (queue) { + // Let's keep the overall duration + duration /= 2; + } + settings.offset = both( settings.offset ); + settings.over = both( settings.over ); + + return this.each(function() { + // Null target yields nothing, just like jQuery does + if (target === null) { return; } + + var win = isWin( this ), + elem = win ? this.contentWindow || window : this, + $elem = $( elem ), + targ = target, + attr = {}, + toff; + + switch (typeof targ) { + // A number will pass the regex + case 'number': + case 'string': + if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test( targ )) { + targ = both( targ ); + // We are done + break; + } + // Relative/Absolute selector + targ = win ? $( targ ) : $( targ, elem ); + /* falls through */ + case 'object': + if (targ.length === 0) { return; } + // DOMElement / jQuery + if (targ.is || targ.style) { + // Get the real position of the target + toff = (targ = $( targ )).offset(); + } + } + + var offset = $.isFunction( settings.offset ) && settings.offset( elem, targ ) || settings.offset; + + $.each(settings.axis.split( '' ), function(i, axis) { + var Pos = axis === 'x' ? 'Left' : 'Top', + pos = Pos.toLowerCase(), + key = 'scroll' + Pos, + prev = $elem[key](), + max = $scrollTo.max( elem, axis ); + + if (toff) {// jQuery / DOMElement + attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]); + + // If it's a dom element, reduce the margin + if (settings.margin) { + attr[key] -= parseInt( targ.css( 'margin' + Pos ), 10 ) || 0; + attr[key] -= parseInt( targ.css( 'border' + Pos + 'Width' ), 10 ) || 0; + } + + attr[key] += offset[pos] || 0; + + if (settings.over[pos]) { + // Scroll to a fraction of its width/height + attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos]; + } + } else { + var val = targ[pos]; + // Handle percentage values + attr[key] = val.slice && val.slice( -1 ) === '%' ? + parseFloat( val ) / 100 * max + : val; + } + + // Number or 'number' + if (settings.limit && /^\d+$/.test( attr[key] )) { + // Check the limits + attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); + } + + // Don't waste time animating, if there's no need. + if ( ! i && settings.axis.length > 1) { + if (prev === attr[key]) { + // No animation needed + attr = {}; + } else if (queue) { + // Intermediate animation + animate( settings.onAfterFirst ); + // Don't animate this axis again in the next iteration. + attr = {}; + } + } + }); + + animate( settings.onAfter ); + + function animate(callback) { + var opts = $.extend({}, settings, { + // The queue setting conflicts with animate() + // Force it to always be true + queue: true, + duration: duration, + complete: callback && function() { + callback.call( elem, targ, settings ); + } + }); + $elem.animate( attr, opts ); + } + }); + }; + + // Max scrolling position, works on quirks mode + // It only fails (not too badly) on IE, quirks mode. + $scrollTo.max = function(elem, axis) { + var Dim = axis === 'x' ? 'Width' : 'Height', + scroll = 'scroll' + Dim; + + if ( ! isWin( elem )) { + return elem[scroll] - $( elem )[Dim.toLowerCase()](); } + + var size = 'client' + Dim, + doc = elem.ownerDocument || elem.document, + html = doc.documentElement, + body = doc.body; + + return Math.max( html[scroll], body[scroll] ) - Math.min( html[size], body[size] ); + }; + + function both(val) { + return $.isFunction( val ) || $.isPlainObject( val ) ? val : { top:val, left:val }; + } + + // Add special hooks so that window scroll properties can be animated + $.Tween.propHooks.scrollLeft = $.Tween.propHooks.scrollTop = { + get: function(t) { + return $( t.elem )[t.prop](); + }, + set: function(t) { + var curr = this.get( t ); + // If interrupt is true and user scrolled, stop animating + if (t.options.interrupt && t._last && t._last !== curr) { + return $( t.elem ).stop(); + } + var next = Math.round( t.now ); + // Don't waste CPU + // Browsers don't render floating point scroll + if (curr !== next) { + $( t.elem )[t.prop](next); + t._last = this.get( t ); + } + } + }; + + // AMD requirement + return $scrollTo; +}); diff --git a/backend/wp-content/themes/twentyseventeen/assets/js/navigation.js b/backend/wp-content/themes/twentyseventeen/assets/js/navigation.js new file mode 100644 index 0000000..f0fd652 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/assets/js/navigation.js @@ -0,0 +1,109 @@ +/* global twentyseventeenScreenReaderText */ +/** + * Theme functions file. + * + * Contains handlers for navigation and widget area. + */ + +(function( $ ) { + var masthead, menuToggle, siteNavContain, siteNavigation; + + function initMainNavigation( container ) { + + // Add dropdown toggle that displays child menu items. + var dropdownToggle = $( ' + diff --git a/backend/wp-content/themes/twentyseventeen/sidebar.php b/backend/wp-content/themes/twentyseventeen/sidebar.php new file mode 100644 index 0000000..1fc3a17 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/sidebar.php @@ -0,0 +1,20 @@ + + + diff --git a/backend/wp-content/themes/twentyseventeen/single.php b/backend/wp-content/themes/twentyseventeen/single.php new file mode 100644 index 0000000..f44f486 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/single.php @@ -0,0 +1,43 @@ + + +
      +
      +
      + + '' . __( 'Previous Post', 'twentyseventeen' ) . ' ' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '%title', + 'next_text' => '' . __( 'Next Post', 'twentyseventeen' ) . ' %title' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '', + ) ); + + endwhile; // End of the loop. + ?> + +
      +
      + +
      + +>> TABLE OF CONTENTS: +---------------------------------------------------------------- +1.0 Normalize +2.0 Accessibility +3.0 Alignments +4.0 Clearings +5.0 Typography +6.0 Forms +7.0 Formatting +8.0 Lists +9.0 Tables +10.0 Links +11.0 Featured Image Hover +12.0 Navigation +13.0 Layout + 13.1 Header + 13.2 Front Page + 13.3 Regular Content + 13.4 Posts + 13.5 Pages + 13.6 Footer +14.0 Comments +15.0 Widgets +16.0 Media + 16.1 Galleries +17.0 Customizer +18.0 SVGs Fallbacks +19.0 Media Queries +20.0 Print +--------------------------------------------------------------*/ + +/*-------------------------------------------------------------- +1.0 Normalize +Styles based on Normalize v5.0.0 @link https://github.com/necolas/normalize.css +--------------------------------------------------------------*/ + +html { + font-family: sans-serif; + line-height: 1.15; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} + +body { + margin: 0; +} + +article, +aside, +footer, +header, +nav, +section { + display: block; +} + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +figcaption, +figure, +main { + display: block; +} + +figure { + margin: 1em 0; +} + +hr { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; + overflow: visible; +} + +pre { + font-family: monospace, monospace; + font-size: 1em; +} + +a { + background-color: transparent; + -webkit-text-decoration-skip: objects; +} + +a:active, +a:hover { + outline-width: 0; +} + +abbr[title] { + border-bottom: 1px #767676 dotted; + text-decoration: none; +} + +b, +strong { + font-weight: inherit; +} + +b, +strong { + font-weight: 700; +} + +code, +kbd, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +dfn { + font-style: italic; +} + +mark { + background-color: #eee; + color: #222; +} + +small { + font-size: 80%; +} + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + bottom: -0.25em; +} + +sup { + top: -0.5em; +} + +audio, +video { + display: inline-block; +} + +audio:not([controls]) { + display: none; + height: 0; +} + +img { + border-style: none; +} + +svg:not(:root) { + overflow: hidden; +} + +button, +input, +optgroup, +select, +textarea { + font-family: sans-serif; + font-size: 100%; + line-height: 1.15; + margin: 0; +} + +button, +input { + overflow: visible; +} + +button, +select { + text-transform: none; +} + +button, +html [type="button"], +[type="reset"], +[type="submit"] { + -webkit-appearance: button; +} + +button::-moz-focus-inner, +[type="button"]::-moz-focus-inner, +[type="reset"]::-moz-focus-inner, +[type="submit"]::-moz-focus-inner { + border-style: none; + padding: 0; +} + +button:-moz-focusring, +[type="button"]:-moz-focusring, +[type="reset"]:-moz-focusring, +[type="submit"]:-moz-focusring { + outline: 1px dotted ButtonText; +} + +fieldset { + border: 1px solid #bbb; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +legend { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + color: inherit; + display: table; + max-width: 100%; + padding: 0; + white-space: normal; +} + +progress { + display: inline-block; + vertical-align: baseline; +} + +textarea { + overflow: auto; +} + +[type="checkbox"], +[type="radio"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0; +} + +[type="number"]::-webkit-inner-spin-button, +[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +[type="search"] { + -webkit-appearance: textfield; + outline-offset: -2px; +} + +[type="search"]::-webkit-search-cancel-button, +[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +::-webkit-file-upload-button { + -webkit-appearance: button; + font: inherit; +} + +details, +menu { + display: block; +} + +summary { + display: list-item; +} + +canvas { + display: inline-block; +} + +template { + display: none; +} + +[hidden] { + display: none; +} + +/*-------------------------------------------------------------- +2.0 Accessibility +--------------------------------------------------------------*/ + +/* Text meant only for screen readers. */ + +.screen-reader-text { + clip: rect(1px, 1px, 1px, 1px); + height: 1px; + overflow: hidden; + position: absolute !important; + width: 1px; + word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */ +} + +.screen-reader-text:focus { + background-color: #f1f1f1; + -webkit-border-radius: 3px; + border-radius: 3px; + -webkit-box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); + box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); + clip: auto !important; + color: #21759b; + display: block; + font-size: 14px; + font-size: 0.875rem; + font-weight: 700; + height: auto; + left: 5px; + line-height: normal; + padding: 15px 23px 14px; + text-decoration: none; + top: 5px; + width: auto; + z-index: 100000; /* Above WP toolbar. */ +} + +/*-------------------------------------------------------------- +3.0 Alignments +--------------------------------------------------------------*/ + +.alignleft { + display: inline; + float: left; + margin-right: 1.5em; +} + +.alignright { + display: inline; + float: right; + margin-left: 1.5em; +} + +.aligncenter { + clear: both; + display: block; + margin-left: auto; + margin-right: auto; +} + +/*-------------------------------------------------------------- +4.0 Clearings +--------------------------------------------------------------*/ + +.clear:before, +.clear:after, +.entry-content:before, +.entry-content:after, +.entry-footer:before, +.entry-footer:after, +.comment-content:before, +.comment-content:after, +.site-header:before, +.site-header:after, +.site-content:before, +.site-content:after, +.site-footer:before, +.site-footer:after, +.nav-links:before, +.nav-links:after, +.pagination:before, +.pagination:after, +.comment-author:before, +.comment-author:after, +.widget-area:before, +.widget-area:after, +.widget:before, +.widget:after, +.comment-meta:before, +.comment-meta:after { + content: ""; + display: table; + table-layout: fixed; +} + +.clear:after, +.entry-content:after, +.entry-footer:after, +.comment-content:after, +.site-header:after, +.site-content:after, +.site-footer:after, +.nav-links:after, +.pagination:after, +.comment-author:after, +.widget-area:after, +.widget:after, +.comment-meta:after { + clear: both; +} + +/*-------------------------------------------------------------- +5.0 Typography +--------------------------------------------------------------*/ + +body, +button, +input, +select, +textarea { + color: #333; + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; + font-size: 15px; + font-size: 0.9375rem; + font-weight: 400; + line-height: 1.66; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + line-height: 1.4; + margin: 0 0 0.75em; + padding: 1.5em 0 0; +} + +h1:first-child, +h2:first-child, +h3:first-child, +h4:first-child, +h5:first-child, +h6:first-child { + padding-top: 0; +} + +h1 { + font-size: 24px; + font-size: 1.5rem; + font-weight: 300; +} + +h2, +.home.blog .entry-title { + color: #666; + font-size: 20px; + font-size: 1.25rem; + font-weight: 300; +} + +h3 { + color: #333; + font-size: 18px; + font-size: 1.125rem; + font-weight: 300; +} + +h4 { + color: #333; + font-size: 16px; + font-size: 1rem; + font-weight: 800; +} + +h5 { + color: #767676; + font-size: 13px; + font-size: 0.8125rem; + font-weight: 800; + letter-spacing: 0.15em; + text-transform: uppercase; +} + +h6 { + color: #333; + font-size: 15px; + font-size: 0.9375rem; + font-weight: 800; +} + +p { + margin: 0 0 1.5em; + padding: 0; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + color: #666; + font-size: 18px; + font-size: 1.125rem; + font-style: italic; + line-height: 1.7; + margin: 0; + overflow: hidden; + padding: 0; +} + +blockquote cite { + display: block; + font-style: normal; + font-weight: 600; + margin-top: 0.5em; +} + +address { + margin: 0 0 1.5em; +} + +pre { + background: #eee; + font-family: "Courier 10 Pitch", Courier, monospace; + font-size: 15px; + font-size: 0.9375rem; + line-height: 1.6; + margin-bottom: 1.6em; + max-width: 100%; + overflow: auto; + padding: 1.6em; +} + +code, +kbd, +tt, +var { + font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; + font-size: 15px; + font-size: 0.9375rem; +} + +abbr, +acronym { + border-bottom: 1px dotted #666; + cursor: help; +} + +mark, +ins { + background: #eee; + text-decoration: none; +} + +big { + font-size: 125%; +} + +blockquote { + quotes: "" ""; +} + +q { + quotes: "“" "â€" "‘" "’"; +} + +blockquote:before, +blockquote:after { + content: ""; +} + +:focus { + outline: none; +} + +/* Typography for Arabic Font */ + +html[lang="ar"] body, +html[lang="ar"] button, +html[lang="ar"] input, +html[lang="ar"] select, +html[lang="ar"] textarea, +html[lang="ary"] body, +html[lang="ary"] button, +html[lang="ary"] input, +html[lang="ary"] select, +html[lang="ary"] textarea, +html[lang="azb"] body, +html[lang="azb"] button, +html[lang="azb"] input, +html[lang="azb"] select, +html[lang="azb"] textarea, +html[lang="fa-IR"] body, +html[lang="fa-IR"] button, +html[lang="fa-IR"] input, +html[lang="fa-IR"] select, +html[lang="fa-IR"] textarea, +html[lang="haz"] body, +html[lang="haz"] button, +html[lang="haz"] input, +html[lang="haz"] select, +html[lang="haz"] textarea, +html[lang="ps"] body, +html[lang="ps"] button, +html[lang="ps"] input, +html[lang="ps"] select, +html[lang="ps"] textarea, +html[lang="ur"] body, +html[lang="ur"] button, +html[lang="ur"] input, +html[lang="ur"] select, +html[lang="ur"] textarea { + font-family: Tahoma, Arial, sans-serif; +} + +html[lang="ar"] h1, +html[lang="ar"] h2, +html[lang="ar"] h3, +html[lang="ar"] h4, +html[lang="ar"] h5, +html[lang="ar"] h6, +html[lang="ary"] h1, +html[lang="ary"] h2, +html[lang="ary"] h3, +html[lang="ary"] h4, +html[lang="ary"] h5, +html[lang="ary"] h6, +html[lang="azb"] h1, +html[lang="azb"] h2, +html[lang="azb"] h3, +html[lang="azb"] h4, +html[lang="azb"] h5, +html[lang="azb"] h6, +html[lang="fa-IR"] h1, +html[lang="fa-IR"] h2, +html[lang="fa-IR"] h3, +html[lang="fa-IR"] h4, +html[lang="fa-IR"] h5, +html[lang="fa-IR"] h6, +html[lang="haz"] h1, +html[lang="haz"] h2, +html[lang="haz"] h3, +html[lang="haz"] h4, +html[lang="haz"] h5, +html[lang="haz"] h6, +html[lang="ps"] h1, +html[lang="ps"] h2, +html[lang="ps"] h3, +html[lang="ps"] h4, +html[lang="ps"] h5, +html[lang="ps"] h6, +html[lang="ur"] h1, +html[lang="ur"] h2, +html[lang="ur"] h3, +html[lang="ur"] h4, +html[lang="ur"] h5, +html[lang="ur"] h6 { + font-weight: 700; +} + +/* Typography for Chinese Font */ + +html[lang^="zh-"] body, +html[lang^="zh-"] button, +html[lang^="zh-"] input, +html[lang^="zh-"] select, +html[lang^="zh-"] textarea { + font-family: "PingFang TC", "Helvetica Neue", Helvetica, STHeitiTC-Light, Arial, sans-serif; +} + +html[lang="zh-CN"] body, +html[lang="zh-CN"] button, +html[lang="zh-CN"] input, +html[lang="zh-CN"] select, +html[lang="zh-CN"] textarea { + font-family: "PingFang SC", "Helvetica Neue", Helvetica, STHeitiSC-Light, Arial, sans-serif; +} + +html[lang^="zh-"] h1, +html[lang^="zh-"] h2, +html[lang^="zh-"] h3, +html[lang^="zh-"] h4, +html[lang^="zh-"] h5, +html[lang^="zh-"] h6 { + font-weight: 700; +} + +/* Typography for Cyrillic Font */ + +html[lang="bg-BG"] body, +html[lang="bg-BG"] button, +html[lang="bg-BG"] input, +html[lang="bg-BG"] select, +html[lang="bg-BG"] textarea, +html[lang="ru-RU"] body, +html[lang="ru-RU"] button, +html[lang="ru-RU"] input, +html[lang="ru-RU"] select, +html[lang="ru-RU"] textarea, +html[lang="uk"] body, +html[lang="uk"] button, +html[lang="uk"] input, +html[lang="uk"] select, +html[lang="uk"] textarea { + font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif; +} + +html[lang="bg-BG"] h1, +html[lang="bg-BG"] h2, +html[lang="bg-BG"] h3, +html[lang="bg-BG"] h4, +html[lang="bg-BG"] h5, +html[lang="bg-BG"] h6, +html[lang="ru-RU"] h1, +html[lang="ru-RU"] h2, +html[lang="ru-RU"] h3, +html[lang="ru-RU"] h4, +html[lang="ru-RU"] h5, +html[lang="ru-RU"] h6, +html[lang="uk"] h1, +html[lang="uk"] h2, +html[lang="uk"] h3, +html[lang="uk"] h4, +html[lang="uk"] h5, +html[lang="uk"] h6 { + font-weight: 700; + line-height: 1.2; +} + +/* Typography for Devanagari Font */ + +html[lang="bn-BD"] body, +html[lang="bn-BD"] button, +html[lang="bn-BD"] input, +html[lang="bn-BD"] select, +html[lang="bn-BD"] textarea, +html[lang="hi-IN"] body, +html[lang="hi-IN"] button, +html[lang="hi-IN"] input, +html[lang="hi-IN"] select, +html[lang="hi-IN"] textarea, +html[lang="mr-IN"] body, +html[lang="mr-IN"] button, +html[lang="mr-IN"] input, +html[lang="mr-IN"] select, +html[lang="mr-IN"] textarea { + font-family: Arial, sans-serif; +} + +html[lang="bn-BD"] h1, +html[lang="bn-BD"] h2, +html[lang="bn-BD"] h3, +html[lang="bn-BD"] h4, +html[lang="bn-BD"] h5, +html[lang="bn-BD"] h6, +html[lang="hi-IN"] h1, +html[lang="hi-IN"] h2, +html[lang="hi-IN"] h3, +html[lang="hi-IN"] h4, +html[lang="hi-IN"] h5, +html[lang="hi-IN"] h6, +html[lang="mr-IN"] h1, +html[lang="mr-IN"] h2, +html[lang="mr-IN"] h3, +html[lang="mr-IN"] h4, +html[lang="mr-IN"] h5, +html[lang="mr-IN"] h6 { + font-weight: 700; +} + +/* Typography for Greek Font */ + +html[lang="el"] body, +html[lang="el"] button, +html[lang="el"] input, +html[lang="el"] select, +html[lang="el"] textarea { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +html[lang="el"] h1, +html[lang="el"] h2, +html[lang="el"] h3, +html[lang="el"] h4, +html[lang="el"] h5, +html[lang="el"] h6 { + font-weight: 700; + line-height: 1.3; +} + +/* Typography for Gujarati Font */ + +html[lang="gu-IN"] body, +html[lang="gu-IN"] button, +html[lang="gu-IN"] input, +html[lang="gu-IN"] select, +html[lang="gu-IN"] textarea { + font-family: Arial, sans-serif; +} + +html[lang="gu-IN"] h1, +html[lang="gu-IN"] h2, +html[lang="gu-IN"] h3, +html[lang="gu-IN"] h4, +html[lang="gu-IN"] h5, +html[lang="gu-IN"] h6 { + font-weight: 700; +} + +/* Typography for Hebrew Font */ + +html[lang="he-IL"] body, +html[lang="he-IL"] button, +html[lang="he-IL"] input, +html[lang="he-IL"] select, +html[lang="he-IL"] textarea { + font-family: "Arial Hebrew", Arial, sans-serif; +} + +html[lang="he-IL"] h1, +html[lang="he-IL"] h2, +html[lang="he-IL"] h3, +html[lang="he-IL"] h4, +html[lang="he-IL"] h5, +html[lang="he-IL"] h6 { + font-weight: 700; +} + +/* Typography for Japanese Font */ + +html[lang="ja"] body, +html[lang="ja"] button, +html[lang="ja"] input, +html[lang="ja"] select, +html[lang="ja"] textarea { + font-family: "Hiragino Kaku Gothic Pro", Meiryo, sans-serif; +} + +html[lang="ja"] h1, +html[lang="ja"] h2, +html[lang="ja"] h3, +html[lang="ja"] h4, +html[lang="ja"] h5, +html[lang="ja"] h6 { + font-weight: 700; +} + +/* Typography for Korean font */ + +html[lang="ko-KR"] body, +html[lang="ko-KR"] button, +html[lang="ko-KR"] input, +html[lang="ko-KR"] select, +html[lang="ko-KR"] textarea { + font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Nanum Gothic", Dotum, sans-serif; +} + +html[lang="ko-KR"] h1, +html[lang="ko-KR"] h2, +html[lang="ko-KR"] h3, +html[lang="ko-KR"] h4, +html[lang="ko-KR"] h5, +html[lang="ko-KR"] h6 { + font-weight: 600; +} + +/* Typography for Thai Font */ + +html[lang="th"] h1, +html[lang="th"] h2, +html[lang="th"] h3, +html[lang="th"] h4, +html[lang="th"] h5, +html[lang="th"] h6 { + line-height: 1.65; + font-family: "Sukhumvit Set", "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +html[lang="th"] body, +html[lang="th"] button, +html[lang="th"] input, +html[lang="th"] select, +html[lang="th"] textarea { + line-height: 1.8; + font-family: "Sukhumvit Set", "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +/* Remove letter-spacing for all non-latin alphabets */ + +html[lang="ar"] *, +html[lang="ary"] *, +html[lang="azb"] *, +html[lang="haz"] *, +html[lang="ps"] *, +html[lang^="zh-"] *, +html[lang="bg-BG"] *, +html[lang="ru-RU"] *, +html[lang="uk"] *, +html[lang="bn-BD"] *, +html[lang="hi-IN"] *, +html[lang="mr-IN"] *, +html[lang="el"] *, +html[lang="gu-IN"] *, +html[lang="he-IL"] *, +html[lang="ja"] *, +html[lang="ko-KR"] *, +html[lang="th"] * { + letter-spacing: 0 !important; +} + +/*-------------------------------------------------------------- +6.0 Forms +--------------------------------------------------------------*/ + +label { + color: #333; + display: block; + font-weight: 800; + margin-bottom: 0.5em; +} + +fieldset { + margin-bottom: 1em; +} + +input[type="text"], +input[type="email"], +input[type="url"], +input[type="password"], +input[type="search"], +input[type="number"], +input[type="tel"], +input[type="range"], +input[type="date"], +input[type="month"], +input[type="week"], +input[type="time"], +input[type="datetime"], +input[type="datetime-local"], +input[type="color"], +textarea { + color: #666; + background: #fff; + background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0)); + border: 1px solid #bbb; + -webkit-border-radius: 3px; + border-radius: 3px; + display: block; + padding: 0.7em; + width: 100%; +} + +input[type="text"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="password"]:focus, +input[type="search"]:focus, +input[type="number"]:focus, +input[type="tel"]:focus, +input[type="range"]:focus, +input[type="date"]:focus, +input[type="month"]:focus, +input[type="week"]:focus, +input[type="time"]:focus, +input[type="datetime"]:focus, +input[type="datetime-local"]:focus, +input[type="color"]:focus, +textarea:focus { + color: #222; + border-color: #333; +} + +select { + border: 1px solid #bbb; + -webkit-border-radius: 3px; + border-radius: 3px; + height: 3em; + max-width: 100%; +} + +input[type="radio"], +input[type="checkbox"] { + margin-right: 0.5em; +} + +input[type="radio"] + label, +input[type="checkbox"] + label { + font-weight: 400; +} + +button, +input[type="button"], +input[type="submit"] { + background-color: #222; + border: 0; + -webkit-border-radius: 2px; + border-radius: 2px; + -webkit-box-shadow: none; + box-shadow: none; + color: #fff; + cursor: pointer; + display: inline-block; + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + line-height: 1; + padding: 1em 2em; + text-shadow: none; + -webkit-transition: background 0.2s; + transition: background 0.2s; +} + +input + button, +input + input[type="button"], +input + input[type="submit"] { + padding: 0.75em 2em; +} + +button.secondary, +input[type="reset"], +input[type="button"].secondary, +input[type="reset"].secondary, +input[type="submit"].secondary { + background-color: #ddd; + color: #222; +} + +button:hover, +button:focus, +input[type="button"]:hover, +input[type="button"]:focus, +input[type="submit"]:hover, +input[type="submit"]:focus { + background: #767676; +} + +button.secondary:hover, +button.secondary:focus, +input[type="reset"]:hover, +input[type="reset"]:focus, +input[type="button"].secondary:hover, +input[type="button"].secondary:focus, +input[type="reset"].secondary:hover, +input[type="reset"].secondary:focus, +input[type="submit"].secondary:hover, +input[type="submit"].secondary:focus { + background: #bbb; +} + +/* Placeholder text color -- selectors need to be separate to work. */ +::-webkit-input-placeholder { + color: #333; + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; +} + +:-moz-placeholder { + color: #333; + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; +} + +::-moz-placeholder { + color: #333; + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; + opacity: 1; + /* Since FF19 lowers the opacity of the placeholder by default */ +} + +:-ms-input-placeholder { + color: #333; + font-family: "Libre Franklin", "Helvetica Neue", helvetica, arial, sans-serif; +} + +/*-------------------------------------------------------------- +7.0 Formatting +--------------------------------------------------------------*/ + +hr { + background-color: #bbb; + border: 0; + height: 1px; + margin-bottom: 1.5em; +} + +/*-------------------------------------------------------------- +8.0 Lists +--------------------------------------------------------------*/ + +ul, +ol { + margin: 0 0 1.5em; + padding: 0; +} + +ul { + list-style: disc; +} + +ol { + list-style: decimal; +} + +li > ul, +li > ol { + margin-bottom: 0; + margin-left: 1.5em; +} + +dt { + font-weight: 700; +} + +dd { + margin: 0 1.5em 1.5em; +} + +/*-------------------------------------------------------------- +9.0 Tables +--------------------------------------------------------------*/ + +table { + border-collapse: collapse; + margin: 0 0 1.5em; + width: 100%; +} + +thead th { + border-bottom: 2px solid #bbb; + padding-bottom: 0.5em; +} + +th { + padding: 0.4em; + text-align: left; +} + +tr { + border-bottom: 1px solid #eee; +} + +td { + padding: 0.4em; +} + +th:first-child, +td:first-child { + padding-left: 0; +} + +th:last-child, +td:last-child { + padding-right: 0; +} + +/*-------------------------------------------------------------- +10.0 Links +--------------------------------------------------------------*/ + +a { + color: #222; + text-decoration: none; +} + +a:focus { + outline: thin dotted; +} + +a:hover, +a:active { + color: #000; + outline: 0; +} + +/* Hover effects */ + +.entry-content a, +.entry-summary a, +.comment-content a, +.widget a, +.site-footer .widget-area a, +.posts-navigation a, +.widget_authors a strong { + -webkit-box-shadow: inset 0 -1px 0 rgba(15, 15, 15, 1); + box-shadow: inset 0 -1px 0 rgba(15, 15, 15, 1); + -webkit-transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out, -webkit-box-shadow 130ms ease-in-out; +} + +.entry-title a, +.entry-meta a, +.page-links a, +.page-links a .page-number, +.entry-footer a, +.entry-footer .cat-links a, +.entry-footer .tags-links a, +.edit-link a, +.post-navigation a, +.logged-in-as a, +.comment-navigation a, +.comment-metadata a, +.comment-metadata a.comment-edit-link, +.comment-reply-link, +a .nav-title, +.pagination a, +.comments-pagination a, +.site-info a, +.widget .widget-title a, +.widget ul li a, +.site-footer .widget-area ul li a, +.site-footer .widget-area ul li a { + -webkit-box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 1); + box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 1); + text-decoration: none; + -webkit-transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, -webkit-box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out; + transition: color 80ms ease-in, box-shadow 130ms ease-in-out, -webkit-box-shadow 130ms ease-in-out; +} + +.entry-content a:focus, +.entry-content a:hover, +.entry-summary a:focus, +.entry-summary a:hover, +.comment-content a:focus, +.comment-content a:hover, +.widget a:focus, +.widget a:hover, +.site-footer .widget-area a:focus, +.site-footer .widget-area a:hover, +.posts-navigation a:focus, +.posts-navigation a:hover, +.comment-metadata a:focus, +.comment-metadata a:hover, +.comment-metadata a.comment-edit-link:focus, +.comment-metadata a.comment-edit-link:hover, +.comment-reply-link:focus, +.comment-reply-link:hover, +.widget_authors a:focus strong, +.widget_authors a:hover strong, +.entry-title a:focus, +.entry-title a:hover, +.entry-meta a:focus, +.entry-meta a:hover, +.page-links a:focus .page-number, +.page-links a:hover .page-number, +.entry-footer a:focus, +.entry-footer a:hover, +.entry-footer .cat-links a:focus, +.entry-footer .cat-links a:hover, +.entry-footer .tags-links a:focus, +.entry-footer .tags-links a:hover, +.post-navigation a:focus, +.post-navigation a:hover, +.pagination a:not(.prev):not(.next):focus, +.pagination a:not(.prev):not(.next):hover, +.comments-pagination a:not(.prev):not(.next):focus, +.comments-pagination a:not(.prev):not(.next):hover, +.logged-in-as a:focus, +.logged-in-as a:hover, +a:focus .nav-title, +a:hover .nav-title, +.edit-link a:focus, +.edit-link a:hover, +.site-info a:focus, +.site-info a:hover, +.widget .widget-title a:focus, +.widget .widget-title a:hover, +.widget ul li a:focus, +.widget ul li a:hover { + color: #000; + -webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1); + box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), 0 3px 0 rgba(0, 0, 0, 1); +} + +/* Fixes linked images */ +.entry-content a img, +.comment-content a img, +.widget a img { + -webkit-box-shadow: 0 0 0 8px #fff; + box-shadow: 0 0 0 8px #fff; +} + +.post-navigation a:focus .icon, +.post-navigation a:hover .icon { + color: #222; +} + +/*-------------------------------------------------------------- +11.0 Featured Image Hover +--------------------------------------------------------------*/ + +.post-thumbnail { + margin-bottom: 1em; +} + +.post-thumbnail a img { + -webkit-backface-visibility: hidden; + -webkit-transition: opacity 0.2s; + transition: opacity 0.2s; +} + +.post-thumbnail a:hover img, +.post-thumbnail a:focus img { + opacity: 0.7; +} + +/*-------------------------------------------------------------- +12.0 Navigation +--------------------------------------------------------------*/ + +.navigation-top { + background: #fff; + border-bottom: 1px solid #eee; + border-top: 1px solid #eee; + font-size: 16px; + font-size: 1rem; + position: relative; +} + +.navigation-top .wrap { + max-width: 1000px; + padding: 0; +} + +.navigation-top a { + color: #222; + font-weight: 600; + -webkit-transition: color 0.2s; + transition: color 0.2s; +} + +.navigation-top .current-menu-item > a, +.navigation-top .current_page_item > a { + color: #767676; +} + +.main-navigation { + clear: both; + display: block; +} + +.main-navigation ul { + background: #fff; + list-style: none; + margin: 0; + padding: 0 1.5em; + text-align: left; +} + +/* Hide the menu on small screens when JavaScript is available. + * It only works with JavaScript. + */ + +.js .main-navigation ul, +.main-navigation .menu-item-has-children > a > .icon, +.main-navigation .page_item_has_children > a > .icon, +.main-navigation ul a > .icon { + display: none; +} + +.main-navigation > div > ul { + border-top: 1px solid #eee; + padding: 0.75em 1.695em; +} + +.js .main-navigation.toggled-on > div > ul { + display: block; +} + +.main-navigation ul ul { + padding: 0 0 0 1.5em; +} + +.main-navigation ul ul.toggled-on { + display: block; +} + +.main-navigation ul ul a { + letter-spacing: 0; + padding: 0.4em 0; + position: relative; + text-transform: none; +} + +.main-navigation li { + border-bottom: 1px solid #eee; + position: relative; +} + +.main-navigation li li, +.main-navigation li:last-child { + border: 0; +} + +.main-navigation a { + display: block; + padding: 0.5em 0; + text-decoration: none; +} + +.main-navigation a:hover { + color: #767676; +} + +/* Menu toggle */ + +.menu-toggle { + background-color: transparent; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; + color: #222; + display: none; + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + line-height: 1.5; + margin: 1px auto 2px; + padding: 1em; + text-shadow: none; +} + +/* Display the menu toggle when JavaScript is available. */ + +.js .menu-toggle { + display: block; +} + +.main-navigation.toggled-on ul.nav-menu { + display: block; +} + +.menu-toggle:hover, +.menu-toggle:focus { + background-color: transparent; + -webkit-box-shadow: none; + box-shadow: none; +} + +.menu-toggle:focus { + outline: thin solid; +} + +.menu-toggle .icon { + margin-right: 0.5em; + top: -2px; +} + +.toggled-on .menu-toggle .icon-bars, +.menu-toggle .icon-close { + display: none; +} + +.toggled-on .menu-toggle .icon-close { + display: inline-block; +} + +/* Dropdown Toggle */ + +.dropdown-toggle { + background-color: transparent; + border: 0; + -webkit-box-shadow: none; + box-shadow: none; + color: #222; + display: block; + font-size: 16px; + right: -0.5em; + line-height: 1.5; + margin: 0 auto; + padding: 0.5em; + position: absolute; + text-shadow: none; + top: 0; +} + +.dropdown-toggle:hover, +.dropdown-toggle:focus { + background: transparent; +} + +.dropdown-toggle:focus { + outline: thin dotted; +} + +.dropdown-toggle.toggled-on .icon { + -ms-transform: rotate(-180deg); /* IE 9 */ + -webkit-transform: rotate(-180deg); /* Chrome, Safari, Opera */ + transform: rotate(-180deg); +} + +/* Scroll down arrow */ + +.site-header .menu-scroll-down { + display: none; +} + +/*-------------------------------------------------------------- +13.0 Layout +--------------------------------------------------------------*/ + +html { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +*, +*:before, +*:after { + /* Inherit box-sizing to make it easier to change the property for components that leverage other behavior; see http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */ + -webkit-box-sizing: inherit; + -moz-box-sizing: inherit; + box-sizing: inherit; +} + +body { + background: #fff; + /* Fallback for when there is no custom background color defined. */ +} + +#page { + position: relative; + word-wrap: break-word; +} + +.wrap { + margin-left: auto; + margin-right: auto; + max-width: 700px; + padding-left: 2em; + padding-right: 2em; +} + +.wrap:after { + clear: both; + content: ""; + display: block; +} + +/*-------------------------------------------------------------- +13.1 Header +--------------------------------------------------------------*/ + +#masthead .wrap { + position: relative; +} + +.site-header { + background-color: #fafafa; + position: relative; +} + +/* Site branding */ + +.site-branding { + padding: 1em 0; + position: relative; + -webkit-transition: margin-bottom 0.2s; + transition: margin-bottom 0.2s; + z-index: 3; +} + +.site-branding a { + text-decoration: none; + -webkit-transition: opacity 0.2s; + transition: opacity 0.2s; +} + +.site-branding a:hover, +.site-branding a:focus { + opacity: 0.7; +} + +.site-title { + clear: none; + font-size: 24px; + font-size: 1.5rem; + font-weight: 800; + line-height: 1.25; + letter-spacing: 0.08em; + margin: 0; + padding: 0; + text-transform: uppercase; +} + +.site-title, +.site-title a { + color: #222; + opacity: 1; /* Prevent opacity from changing during selective refreshes in the customize preview */ +} + +body.has-header-image .site-title, +body.has-header-video .site-title, +body.has-header-image .site-title a, +body.has-header-video .site-title a { + color: #fff; +} + +.site-description { + color: #666; + font-size: 13px; + font-size: 0.8125rem; + margin-bottom: 0; +} + +body.has-header-image .site-description, +body.has-header-video .site-description { + color: #fff; + opacity: 0.8; +} + +.custom-logo-link { + display: inline-block; + padding-right: 1em; + vertical-align: middle; + width: auto; +} + +.custom-logo-link img { + display: inline-block; + max-height: 80px; + width: auto; +} + +body.home.title-tagline-hidden.has-header-image .custom-logo-link img, +body.home.title-tagline-hidden.has-header-video .custom-logo-link img { + max-height: 200px; + max-width: 100%; +} + +.custom-logo-link a:hover, +.custom-logo-link a:focus { + opacity: 0.9; +} + +body:not(.title-tagline-hidden) .site-branding-text { + display: inline-block; + vertical-align: middle; +} + +.custom-header { + position: relative; +} + +.has-header-image.twentyseventeen-front-page .custom-header, +.has-header-video.twentyseventeen-front-page .custom-header, +.has-header-image.home.blog .custom-header, +.has-header-video.home.blog .custom-header { + display: table; + height: 300px; + height: 75vh; + width: 100%; +} + +.custom-header-media { + bottom: 0; + left: 0; + overflow: hidden; + position: absolute; + right: 0; + top: 0; + width: 100%; +} + +.custom-header-media:before { + /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#000000+0,000000+100&0+0,0.3+75 */ + background: -moz-linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 75%, rgba(0, 0, 0, 0.3) 100%); /* FF3.6-15 */ + background: -webkit-linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 75%, rgba(0, 0, 0, 0.3) 100%); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 75%, rgba(0, 0, 0, 0.3) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#00000000", endColorstr="#4d000000", GradientType=0); /* IE6-9 */ + bottom: 0; + content: ""; + display: block; + height: 100%; + left: 0; + position: absolute; + right: 0; + z-index: 2; +} + +.has-header-image .custom-header-media img, +.has-header-video .custom-header-media video, +.has-header-video .custom-header-media iframe { + position: fixed; + height: auto; + left: 50%; + max-width: 1000%; + min-height: 100%; + min-width: 100%; + min-width: 100vw; /* vw prevents 1px gap on left that 100% has */ + width: auto; + top: 50%; + padding-bottom: 1px; /* Prevent header from extending beyond the footer */ + -ms-transform: translateX(-50%) translateY(-50%); + -moz-transform: translateX(-50%) translateY(-50%); + -webkit-transform: translateX(-50%) translateY(-50%); + transform: translateX(-50%) translateY(-50%); +} + +.wp-custom-header .wp-custom-header-video-button { /* Specificity prevents .color-dark button overrides */ + background-color: rgba(34, 34, 34, 0.5); + border: 1px solid rgba(255, 255, 255, 0.6); + color: rgba(255, 255, 255, 0.6); + height: 45px; + overflow: hidden; + padding: 0; + position: fixed; + right: 30px; + top: 30px; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + width: 45px; +} + +.wp-custom-header .wp-custom-header-video-button:hover, +.wp-custom-header .wp-custom-header-video-button:focus { /* Specificity prevents .color-dark button overrides */ + border-color: rgba(255, 255, 255, 0.8); + background-color: rgba(34, 34, 34, 0.8); + color: #fff; +} + +.admin-bar .wp-custom-header-video-button { + top: 62px; +} + +.has-header-image:not(.twentyseventeen-front-page):not(.home) .custom-header-media img { + bottom: 0; + position: absolute; + top: auto; + -ms-transform: translateX(-50%) translateY(0); + -moz-transform: translateX(-50%) translateY(0); + -webkit-transform: translateX(-50%) translateY(0); + transform: translateX(-50%) translateY(0); +} + +/* For browsers that support 'object-fit' */ +@supports ( object-fit: cover ) { + .has-header-image .custom-header-media img, + .has-header-video .custom-header-media video, + .has-header-video .custom-header-media iframe, + .has-header-image:not(.twentyseventeen-front-page):not(.home) .custom-header-media img { + height: 100%; + left: 0; + -o-object-fit: cover; + object-fit: cover; + top: 0; + -ms-transform: none; + -moz-transform: none; + -webkit-transform: none; + transform: none; + width: 100%; + } +} + +/* Hides div in Customizer preview when header images or videos change. */ + +body:not(.has-header-image):not(.has-header-video) .custom-header-media { + display: none; +} + +.has-header-image.twentyseventeen-front-page .site-branding, +.has-header-video.twentyseventeen-front-page .site-branding, +.has-header-image.home.blog .site-branding, +.has-header-video.home.blog .site-branding { + display: table-cell; + height: 100%; + vertical-align: bottom; +} + +/*-------------------------------------------------------------- +13.2 Front Page +--------------------------------------------------------------*/ + +.twentyseventeen-front-page .site-content { + padding: 0; +} + +.twentyseventeen-panel { + overflow: hidden; + position: relative; +} + +.panel-image { + background-position: center center; + background-repeat: no-repeat; + -webkit-background-size: cover; + background-size: cover; + position: relative; +} + +.panel-image:before { + /* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#000000+0,000000+100&0+0,0.3+100 */ /* FF3.6-15 */ + background: -webkit-linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%); /* Chrome10-25,Safari5.1-6 */ + background: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.3))); + background: -webkit-linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%); + background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#00000000", endColorstr="#4d000000", GradientType=0); /* IE6-9 */ + bottom: 0; + content: ""; + left: 0; + right: 0; + position: absolute; + top: 100px; +} + +.twentyseventeen-front-page article:not(.has-post-thumbnail):not(:first-child) { + border-top: 1px solid #ddd; +} + +.panel-content { + position: relative; +} + +.panel-content .wrap { + padding-bottom: 0.5em; + padding-top: 1.75em; +} + +/* Panel edit link */ + +.twentyseventeen-panel .edit-link { + display: block; + margin: 0.3em 0 0; +} + +.twentyseventeen-panel .entry-header .edit-link { + font-size: 14px; + font-size: 0.875rem; +} + +/* Front Page - Recent Posts */ + +.twentyseventeen-front-page .panel-content .recent-posts article { + border: 0; + color: #333; + margin-bottom: 3em; +} + +.recent-posts .entry-header { + margin-bottom: 1.2em; +} + +.page .panel-content .recent-posts .entry-title { + font-size: 20px; + font-size: 1.25rem; + font-weight: 300; + letter-spacing: 0; + text-transform: none; +} + +.twentyseventeen-panel .recent-posts .entry-header .edit-link { + color: #222; + display: inline-block; + font-size: 11px; + font-size: 0.6875rem; + margin-left: 1em; +} + +/*-------------------------------------------------------------- +13.3 Regular Content +--------------------------------------------------------------*/ + +.site-content-contain { + background-color: #fff; + position: relative; +} + +.site-content { + padding: 2.5em 0 0; +} + +/*-------------------------------------------------------------- +13.4 Posts +--------------------------------------------------------------*/ + +/* Post Landing Page */ + +.sticky { + position: relative; +} + +.post:not(.sticky) .icon-thumb-tack { + display: none; +} + +.sticky .icon-thumb-tack { + display: block; + height: 18px; + left: -1.5em; + position: absolute; + top: 1.65em; + width: 20px; +} + +.page .panel-content .entry-title, +.page-title, +body.page:not(.twentyseventeen-front-page) .entry-title { + color: #222; + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + letter-spacing: 0.14em; + text-transform: uppercase; +} + +.entry-header .entry-title { + margin-bottom: 0.25em; +} + +.entry-title a { + color: #333; + text-decoration: none; + margin-left: -2px; +} + +.entry-title:not(:first-child) { + padding-top: 0; +} + +.entry-meta { + color: #767676; + font-size: 11px; + font-size: 0.6875rem; + font-weight: 800; + letter-spacing: 0.1818em; + padding-bottom: 0.25em; + text-transform: uppercase; +} + +.entry-meta a { + color: #767676; +} + +.byline, +.updated:not(.published) { + display: none; +} + +.single .byline, +.group-blog .byline { + display: inline; +} + +.pagination, +.comments-pagination { + border-top: 1px solid #eee; + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + padding: 2em 0 3em; + text-align: center; +} + +.pagination .icon, +.comments-pagination .icon { + width: 0.666666666em; + height: 0.666666666em; +} + +.comments-pagination { + border: 0; +} + +.page-numbers { + display: none; + padding: 0.5em 0.75em; +} + +.page-numbers.current { + color: #767676; + display: inline-block; +} + +.page-numbers.current .screen-reader-text { + clip: auto; + height: auto; + overflow: auto; + position: relative !important; + width: auto; +} + +.prev.page-numbers, +.next.page-numbers { + background-color: #ddd; + -webkit-border-radius: 2px; + border-radius: 2px; + display: inline-block; + font-size: 24px; + font-size: 1.5rem; + line-height: 1; + padding: 0.25em 0.5em 0.4em; +} + +.prev.page-numbers, +.next.page-numbers { + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; +} + +.prev.page-numbers:focus, +.prev.page-numbers:hover, +.next.page-numbers:focus, +.next.page-numbers:hover { + background-color: #767676; + color: #fff; +} + +.prev.page-numbers { + float: left; +} + +.next.page-numbers { + float: right; +} + +/* Aligned blockquotes */ + +.entry-content blockquote.alignleft, +.entry-content blockquote.alignright { + color: #666; + font-size: 13px; + font-size: 0.8125rem; + width: 48%; +} + +/* Blog landing, search, archives */ + +.blog .site-main > article, +.archive .site-main > article, +.search .site-main > article { + padding-bottom: 2em; +} + +body:not(.twentyseventeen-front-page) .entry-header { + padding: 1em 0; +} + +body:not(.twentyseventeen-front-page) .entry-header, +body:not(.twentyseventeen-front-page) .entry-content, +body:not(.twentyseventeen-front-page) #comments { + margin-left: auto; + margin-right: auto; +} + +body:not(.twentyseventeen-front-page) .entry-header { + padding-top: 0; +} + +.blog .entry-meta a.post-edit-link, +.archive .entry-meta a.post-edit-link, +.search .entry-meta a.post-edit-link { + color: #222; + display: inline-block; + margin-left: 1em; + white-space: nowrap; +} + +.search .page .entry-meta a.post-edit-link { + margin-left: 0; + white-space: nowrap; +} + +.taxonomy-description { + color: #666; + font-size: 13px; + font-size: 0.8125rem; +} + +/* More tag */ + +.entry-content .more-link:before { + content: ""; + display: block; + margin-top: 1.5em; +} + +/* Single Post */ + +.single-post:not(.has-sidebar) #primary, +.page.page-one-column:not(.twentyseventeen-front-page) #primary, +.archive.page-one-column:not(.has-sidebar) .page-header, +.archive.page-one-column:not(.has-sidebar) #primary { + margin-left: auto; + margin-right: auto; + max-width: 740px; +} + +.single-featured-image-header { + background-color: #fafafa; + border-bottom: 1px solid #eee; +} + +.single-featured-image-header img { + display: block; + margin: auto; +} + +.page-links { + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + padding: 2em 0 3em; +} + +.page-links .page-number { + color: #767676; + display: inline-block; + padding: 0.5em 1em; +} + +.page-links a { + display: inline-block; +} + +.page-links a .page-number { + color: #222; +} + +/* Entry footer */ + +.entry-footer { + border-bottom: 1px solid #eee; + border-top: 1px solid #eee; + margin-top: 2em; + padding: 2em 0; +} + +.entry-footer .cat-links, +.entry-footer .tags-links { + display: block; + font-size: 11px; + font-size: 0.6875rem; + font-weight: 800; + letter-spacing: 0.1818em; + padding-left: 2.5em; + position: relative; + text-transform: uppercase; +} + +.entry-footer .cat-links + .tags-links { + margin-top: 1em; +} + +.entry-footer .cat-links a, +.entry-footer .tags-links a { + color: #333; +} + +.entry-footer .cat-links .icon, +.entry-footer .tags-links .icon { + color: #767676; + left: 0; + margin-right: 0.5em; + position: absolute; + top: 2px; +} + +.entry-footer .edit-link { + display: inline-block; +} + +.entry-footer .edit-link a.post-edit-link { + background-color: #222; + -webkit-border-radius: 2px; + border-radius: 2px; + -webkit-box-shadow: none; + box-shadow: none; + color: #fff; + display: inline-block; + font-size: 14px; + font-size: 0.875rem; + font-weight: 800; + margin-top: 2em; + padding: 0.7em 2em; + -webkit-transition: background-color 0.2s ease-in-out; + transition: background-color 0.2s ease-in-out; + white-space: nowrap; +} + +.entry-footer .edit-link a.post-edit-link:hover, +.entry-footer .edit-link a.post-edit-link:focus { + background-color: #767676; +} + +/* Post Formats */ + +.blog .format-status .entry-title, +.archive .format-status .entry-title, +.blog .format-aside .entry-title, +.archive .format-aside .entry-title { + display: none; +} + +.format-quote blockquote { + color: #333; + font-size: 20px; + font-size: 1.25rem; + font-weight: 300; + overflow: visible; + position: relative; +} + +.format-quote blockquote .icon { + display: block; + height: 20px; + left: -1.25em; + position: absolute; + top: 0.4em; + -webkit-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + transform: scale(-1, 1); + width: 20px; +} + +/* Post Navigation */ + +.post-navigation { + font-weight: 800; + margin: 3em 0; +} + +.post-navigation .nav-links { + padding: 1em 0; +} + +.nav-subtitle { + background: transparent; + color: #767676; + display: block; + font-size: 11px; + font-size: 0.6875rem; + letter-spacing: 0.1818em; + margin-bottom: 1em; + text-transform: uppercase; +} + +.nav-title { + color: #333; + font-size: 15px; + font-size: 0.9375rem; +} + +.post-navigation .nav-next { + margin-top: 1.5em; +} + +.nav-links .nav-previous .nav-title .nav-title-icon-wrapper { + margin-right: 0.5em; +} + +.nav-links .nav-next .nav-title .nav-title-icon-wrapper { + margin-left: 0.5em; +} + +/*-------------------------------------------------------------- +13.5 Pages +--------------------------------------------------------------*/ + +.page-header { + padding-bottom: 2em; +} + +.page .entry-header .edit-link { + font-size: 14px; + font-size: 0.875rem; +} + +.search .page .entry-header .edit-link { + font-size: 11px; + font-size: 0.6875rem; +} + +.page-links { + clear: both; + margin: 0 0 1.5em; +} + +.page:not(.home) #content { + padding-bottom: 1.5em; +} + +/* 404 page */ + +.error404 .page-content { + padding-bottom: 4em; +} + +.error404 .page-content .search-form, +.search .page-content .search-form { + margin-bottom: 3em; +} + +/*-------------------------------------------------------------- +13.6 Footer +--------------------------------------------------------------*/ + +.site-footer { + border-top: 1px solid #eee; +} + +.site-footer .wrap { + padding-bottom: 1.5em; + padding-top: 2em; +} + +/* Footer widgets */ + +.site-footer .widget-area { + padding-bottom: 2em; + padding-top: 2em; +} + +/* Social nav */ + +.social-navigation { + font-size: 16px; + font-size: 1rem; + margin-bottom: 1em; +} + +.social-navigation ul { + list-style: none; + margin-bottom: 0; + margin-left: 0; +} + +.social-navigation li { + display: inline; +} + +.social-navigation a { + background-color: #767676; + -webkit-border-radius: 40px; + border-radius: 40px; + color: #fff; + display: inline-block; + height: 40px; + margin: 0 1em 0.5em 0; + text-align: center; + width: 40px; +} + +.social-navigation a:hover, +.social-navigation a:focus { + background-color: #333; +} + +.social-navigation .icon { + height: 16px; + top: 12px; + width: 16px; + vertical-align: top; +} + +/* Site info */ + +.site-info { + font-size: 14px; + font-size: 0.875rem; + margin-bottom: 1em; +} + +.site-info a { + color: #666; +} + +.site-info .sep { + margin: 0; + display: block; + visibility: hidden; + height: 0; + width: 100%; +} + +.site-info span[role=separator] { + padding: 0 0.2em 0 0.4em; +} + +.site-info span[role=separator]::before { + content: '\002f'; +} + +/*-------------------------------------------------------------- +14.0 Comments +--------------------------------------------------------------*/ + +#comments { + clear: both; + padding: 2em 0 0.5em; +} + +.comments-title { + font-size: 20px; + font-size: 1.25rem; + margin-bottom: 1.5em; +} + +.comment-list, +.comment-list .children { + list-style: none; + margin: 0; + padding: 0; +} + +.comment-list li:before { + display: none; +} + +.comment-body { + margin-left: 65px; +} + +.comment-author { + font-size: 16px; + font-size: 1rem; + margin-bottom: 0.4em; + position: relative; + z-index: 2; +} + +.comment-author .avatar { + height: 50px; + left: -65px; + position: absolute; + width: 50px; +} + +.comment-author .says { + display: none; +} + +.comment-meta { + margin-bottom: 1.5em; +} + +.comment-metadata { + color: #767676; + font-size: 10px; + font-size: 0.625rem; + font-weight: 800; + letter-spacing: 0.1818em; + text-transform: uppercase; +} + +.comment-metadata a { + color: #767676; +} + +.comment-metadata a.comment-edit-link { + color: #222; + margin-left: 1em; +} + +.comment-body { + color: #333; + font-size: 14px; + font-size: 0.875rem; + margin-bottom: 4em; +} + +.comment-reply-link { + font-weight: 800; + position: relative; +} + +.comment-reply-link .icon { + color: #222; + left: -2em; + height: 1em; + position: absolute; + top: 0; + width: 1em; +} + +.children .comment-author .avatar { + height: 30px; + left: -45px; + width: 30px; +} + +.bypostauthor > .comment-body > .comment-meta > .comment-author .avatar { + border: 1px solid #333; + padding: 2px; +} + +.no-comments, +.comment-awaiting-moderation { + color: #767676; + font-size: 14px; + font-size: 0.875rem; + font-style: italic; +} + +.comments-pagination { + margin: 2em 0 3em; +} + +.form-submit { + text-align: right; +} + +.comment-form #wp-comment-cookies-consent { + margin: 0 10px 0 0; +} + +.comment-form .comment-form-cookies-consent label { + display: inline; +} + +/*-------------------------------------------------------------- +15.0 Widgets +--------------------------------------------------------------*/ + +#secondary { + padding: 1em 0 2em; +} + +.widget { + padding-bottom: 3em; +} + +h2.widget-title { + color: #222; + font-size: 13px; + font-size: 0.8125rem; + font-weight: 800; + letter-spacing: 0.1818em; + margin-bottom: 1.5em; + text-transform: uppercase; +} + +.widget-title a { + color: inherit; +} + +/* widget forms */ + +.widget select { + width: 100%; +} + + +/* widget lists */ + +.widget ul { + list-style: none; + margin: 0; +} + +.widget ul li, +.widget ol li { + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; + padding: 0.5em 0; +} + +.widget:not(.widget_tag_cloud) ul li + li { + margin-top: -1px; +} + +.widget ul li ul { + margin: 0 0 -1px; + padding: 0; + position: relative; +} + +.widget ul li li { + border: 0; + padding-left: 24px; + padding-left: 1.5rem; +} + +/* Widget lists of links */ + +.widget_top-posts ul li ul, +.widget_rss_links ul li ul, +.widget-grofile ul.grofile-links li ul, +.widget_pages ul li ul, +.widget_meta ul li ul { + bottom: 0; +} + +.widget_nav_menu ul li li, +.widget_top-posts ul li, +.widget_top-posts ul li li, +.widget_rss_links ul li, +.widget_rss_links ul li li, +.widget-grofile ul.grofile-links li, +.widget-grofile ul.grofile-links li li { + padding-bottom: 0.25em; + padding-top: 0.25em; +} + +.widget_rss ul li { + padding-bottom: 1em; + padding-top: 1em; +} + +/* Widget markup */ + +.widget .post-date, +.widget .rss-date { + font-size: 0.81em; +} + +/* Text widget */ + +.widget_text { + word-wrap: break-word; +} + +.widget_text ul { + list-style: disc; + margin: 0 0 1.5em 1.5em; +} + +.widget_text ol { + list-style: decimal; +} + +.widget_text ul li, +.widget_text ol li { + border: none; +} + +.widget_text ul li:last-child, +.widget_text ol li:last-child { + padding-bottom: 0; +} + +.widget_text ul li ul { + margin: 0 0 0 1.5em; +} + +.widget_text ul li li { + padding-left: 0; + padding-right: 0; +} + +.widget_text ol li { + list-style-position: inside; +} + +.widget_text ol li + li { + margin-top: -1px; +} + +/* RSS Widget */ + +.widget_rss .widget-title .rsswidget:first-child { + float: right; +} + +.widget_rss .widget-title .rsswidget:first-child:hover { + background-color: transparent; +} + +.widget_rss .widget-title .rsswidget:first-child img { + display: block; +} + +.widget_rss ul li { + padding: 2.125em 0; +} + +.widget_rss ul li:first-child { + border-top: none; + padding-top: 0; +} + +.widget_rss li .rsswidget { + font-size: 22px; + font-size: 1.375rem; + font-weight: 300; + line-height: 1.4; +} + +.widget_rss .rss-date, +.widget_rss li cite { + color: #767676; + display: block; + font-size: 10px; + font-size: 0.625rem; + font-style: normal; + font-weight: 800; + letter-spacing: 0.18em; + line-height: 1.5; + text-transform: uppercase; +} + +.widget_rss .rss-date { + margin: 0.5em 0 1.5em; + padding: 0; +} + +.widget_rss .rssSummary { + margin-bottom: 0.5em; +} + +/* Contact Info Widget */ + +.widget_contact_info .contact-map { + margin-bottom: 0.5em; +} + +/* Gravatar */ + +.widget-grofile h4 { + font-size: 16px; + font-size: 1rem; + margin-bottom: 0; +} + +/* Recent Comments */ + +.widget_recent_comments table, +.widget_recent_comments th, +.widget_recent_comments td { + border: 0; +} + +/* Recent Posts widget */ + +.widget_recent_entries .post-date { + display: block; +} + +/* Search */ + +.search-form { + position: relative; +} + +.search-form .search-submit { + bottom: 3px; + padding: 0.5em 1em; + position: absolute; + right: 3px; + top: 3px; +} + +.search-form .search-submit .icon { + height: 24px; + top: -2px; + width: 24px; +} + +/* Tag cloud widget */ + +.tagcloud ul li { + float: left; + border-top: 0; + border-bottom: 0; + padding: 0; + margin: 4px 4px 0 0; +} + +.tagcloud, +.widget_tag_cloud, +.wp_widget_tag_cloud { + line-height: 1.5; +} + +.widget .tagcloud a, +.widget.widget_tag_cloud a, +.wp_widget_tag_cloud a { + border: 1px solid #ddd; + -webkit-box-shadow: none; + box-shadow: none; + display: block; + padding: 4px 10px 5px; + position: relative; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + width: auto; + word-wrap: break-word; + z-index: 0; +} + +.widget .tagcloud a:hover, +.widget .tagcloud a:focus, +.widget.widget_tag_cloud a:hover, +.widget.widget_tag_cloud a:focus, +.wp_widget_tag_cloud a:hover, +.wp_widget_tag_cloud a:focus { + border-color: #bbb; + -webkit-box-shadow: none; + box-shadow: none; + text-decoration: none; +} + +/* Calendar widget */ + +.widget_calendar th, +.widget_calendar td { + text-align: center; +} + +.widget_calendar tfoot td { + border: 0; +} + +/* Gallery widget */ + +.gallery-columns-5 .gallery-caption, +.gallery-columns-6 .gallery-caption, +.gallery-columns-7 .gallery-caption, +.gallery-columns-8 .gallery-caption, +.gallery-columns-9 .gallery-caption { + display: none; +} + +/*-------------------------------------------------------------- +16.0 Media +--------------------------------------------------------------*/ + +img, +video { + height: auto; /* Make sure images are scaled correctly. */ + max-width: 100%; /* Adhere to container width. */ +} + +img.alignleft, +img.alignright { + float: none; + margin: 0; +} + +.page-content .wp-smiley, +.entry-content .wp-smiley, +.comment-content .wp-smiley { + border: none; + margin-bottom: 0; + margin-top: 0; + padding: 0; +} + +/* Make sure embeds and iframes fit their containers. */ + +embed, +iframe, +object { + margin-bottom: 1.5em; + max-width: 100%; +} + +/* Remove bottom on embeds that wrapped in paragraphs via wpautop. */ + +p > embed:only-child, +p > iframe:only-child, +p > object:only-child { + margin-bottom: 0; +} + +.wp-caption, +.gallery-caption { + color: #666; + font-size: 13px; + font-size: 0.8125rem; + font-style: italic; + margin-bottom: 1.5em; + max-width: 100%; +} + +.wp-caption img[class*="wp-image-"] { + display: block; + margin-left: auto; + margin-right: auto; +} + +.wp-caption .wp-caption-text { + margin: 0.8075em 0; +} + +/* Media Elements */ + +.mejs-container { + margin-bottom: 1.5em; +} + +/* Audio Player */ + +.mejs-controls a.mejs-horizontal-volume-slider, +.mejs-controls a.mejs-horizontal-volume-slider:focus, +.mejs-controls a.mejs-horizontal-volume-slider:hover { + background: transparent; + border: 0; +} + +/* Playlist Color Overrides: Light */ + +.site-content .wp-playlist-light { + border-color: #eee; + color: #222; +} + +.site-content .wp-playlist-light .wp-playlist-current-item .wp-playlist-item-album { + color: #333; +} + +.site-content .wp-playlist-light .wp-playlist-current-item .wp-playlist-item-artist { + color: #767676; +} + +.site-content .wp-playlist-light .wp-playlist-item { + border-bottom: 1px dotted #eee; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; +} + +.site-content .wp-playlist-light .wp-playlist-item:hover, +.site-content .wp-playlist-light .wp-playlist-item:focus { + border-bottom-color: rgba(0, 0, 0, 0); + background-color: #767676; + color: #fff; +} + +.site-content .wp-playlist-light a.wp-playlist-caption:hover, +.site-content .wp-playlist-light .wp-playlist-item:hover a, +.site-content .wp-playlist-light .wp-playlist-item:focus a { + color: #fff; +} + +/* Playlist Color Overrides: Dark */ + +.site-content .wp-playlist-dark { + background: #222; + border-color: #333; +} + +.site-content .wp-playlist-dark .mejs-container .mejs-controls { + background-color: #333; +} + +.site-content .wp-playlist-dark .wp-playlist-caption { + color: #fff; +} + +.site-content .wp-playlist-dark .wp-playlist-current-item .wp-playlist-item-album { + color: #eee; +} + +.site-content .wp-playlist-dark .wp-playlist-current-item .wp-playlist-item-artist { + color: #aaa; +} + +.site-content .wp-playlist-dark .wp-playlist-playing { + background-color: #333; +} + +.site-content .wp-playlist-dark .wp-playlist-item { + border-bottom: 1px dotted #555; + -webkit-transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; + transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.3s ease-in-out; +} + +.site-content .wp-playlist-dark .wp-playlist-item:hover, +.site-content .wp-playlist-dark .wp-playlist-item:focus { + border-bottom-color: rgba(0, 0, 0, 0); + background-color: #aaa; + color: #222; +} + +.site-content .wp-playlist-dark a.wp-playlist-caption:hover, +.site-content .wp-playlist-dark .wp-playlist-item:hover a, +.site-content .wp-playlist-dark .wp-playlist-item:focus a { + color: #222; +} + +/* Playlist Style Overrides */ + +.site-content .wp-playlist { + padding: 0.625em 0.625em 0.3125em; +} + +.site-content .wp-playlist-current-item .wp-playlist-item-title { + font-weight: 700; +} + +.site-content .wp-playlist-current-item .wp-playlist-item-album { + font-style: normal; +} + +.site-content .wp-playlist-current-item .wp-playlist-item-artist { + font-size: 10px; + font-size: 0.625rem; + font-weight: 800; + letter-spacing: 0.1818em; + text-transform: uppercase; +} + +.site-content .wp-playlist-item { + padding: 0 0.3125em; + cursor: pointer; +} + +.site-content .wp-playlist-item:last-of-type { + border-bottom: none; +} + +.site-content .wp-playlist-item a { + padding: 0.3125em 0; + border-bottom: none; +} + +.site-content .wp-playlist-item a, +.site-content .wp-playlist-item a:focus, +.site-content .wp-playlist-item a:hover { + -webkit-box-shadow: none; + box-shadow: none; + background: transparent; +} + +.site-content .wp-playlist-item-length { + top: 5px; +} + +/* SVG Icons base styles */ + +.icon { + display: inline-block; + fill: currentColor; + height: 1em; + position: relative; /* Align more nicely with capital letters */ + top: -0.0625em; + vertical-align: middle; + width: 1em; +} + +/*-------------------------------------------------------------- +16.1 Galleries +--------------------------------------------------------------*/ + +.gallery-item { + display: inline-block; + text-align: left; + vertical-align: top; + margin: 0 0 1.5em; + padding: 0 1em 0 0; + width: 50%; +} + +.gallery-columns-1 .gallery-item { + width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-item a, +.gallery-item a:hover, +.gallery-item a:focus, +.widget-area .gallery-item a, +.widget-area .gallery-item a:hover, +.widget-area .gallery-item a:focus { + -webkit-box-shadow: none; + box-shadow: none; + background: none; + display: inline-block; + max-width: 100%; +} + +.gallery-item a img { + display: block; + -webkit-transition: -webkit-filter 0.2s ease-in; + transition: -webkit-filter 0.2s ease-in; + transition: filter 0.2s ease-in; + transition: filter 0.2s ease-in, -webkit-filter 0.2s ease-in; + -webkit-backface-visibility: hidden; + backface-visibility: hidden; +} + +.gallery-item a:hover img, +.gallery-item a:focus img { + -webkit-filter: opacity(60%); + filter: opacity(60%); +} + +.gallery-caption { + display: block; + text-align: left; + padding: 0 10px 0 0; + margin-bottom: 0; +} + +/*-------------------------------------------------------------- +17.0 Customizer +--------------------------------------------------------------*/ + +.highlight-front-sections.twentyseventeen-customizer.twentyseventeen-front-page .twentyseventeen-panel:after { + border: 2px dashed #0085ba; /* Matches visible edit shortcuts. */ + bottom: 1em; + content: ""; + display: block; + left: 1em; + position: absolute; + right: 1em; + top: 1em; + z-index: 1; +} + +.highlight-front-sections.twentyseventeen-customizer.twentyseventeen-front-page .twentyseventeen-panel .panel-content { + z-index: 2; /* Prevent :after from preventing interactions within the section */ +} + +/* Used for placeholder text */ +.twentyseventeen-customizer.twentyseventeen-front-page .twentyseventeen-panel .twentyseventeen-panel-title { + display: block; + font-size: 14px; + font-size: 0.875rem; + font-weight: 700; + letter-spacing: 1px; + padding: 3em; + text-transform: uppercase; + text-align: center; +} + +/* Show borders on the custom page panels only when the front page sections are being edited */ +.highlight-front-sections.twentyseventeen-customizer.twentyseventeen-front-page .twentyseventeen-panel:nth-of-type(1):after { + border: none; +} + +.twentyseventeen-front-page.twentyseventeen-customizer #primary article.panel-placeholder { + border: 0; +} + +/* Add some space around the visual edit shortcut buttons. */ +.twentyseventeen-panel > .customize-partial-edit-shortcut > button { + top: 30px; + left: 30px; +} + +/* Ensure that placeholder icons are visible. */ +.twentyseventeen-panel .customize-partial-edit-shortcut-hidden:before { + visibility: visible; +} + +/*-------------------------------------------------------------- +18.0 SVGs Fallbacks +--------------------------------------------------------------*/ + +.svg-fallback { + display: none; +} + +.no-svg .svg-fallback { + display: inline-block; +} + +.no-svg .dropdown-toggle { + padding: 0.5em 0 0; + right: 0; + text-align: center; + width: 2em; +} + +.no-svg .dropdown-toggle .svg-fallback.icon-angle-down { + font-size: 20px; + font-size: 1.25rem; + font-weight: 400; + line-height: 1; + -webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */ + -ms-transform: rotate(180deg); /* IE 9 */ + transform: rotate(180deg); +} + +.no-svg .dropdown-toggle.toggled-on .svg-fallback.icon-angle-down { + -webkit-transform: rotate(0); /* Chrome, Safari, Opera */ + -ms-transform: rotate(0); /* IE 9 */ + transform: rotate(0); +} + +.no-svg .dropdown-toggle .svg-fallback.icon-angle-down:before { + content: "\005E"; +} + +/* Social Menu fallbacks */ + +.no-svg .social-navigation a { + background: transparent; + color: #222; + height: auto; + width: auto; +} + +/* Show screen reader text in some cases */ + +.no-svg .next.page-numbers .screen-reader-text, +.no-svg .prev.page-numbers .screen-reader-text, +.no-svg .social-navigation li a .screen-reader-text, +.no-svg .search-submit .screen-reader-text { + clip: auto; + font-size: 16px; + font-size: 1rem; + font-weight: 400; + height: auto; + position: relative !important; /* overrides previous !important styles */ + width: auto; +} + +/*-------------------------------------------------------------- +19.0 Media Queries +--------------------------------------------------------------*/ + +/* Adjust positioning of edit shortcuts, override style in customize-preview.css */ +@media screen and (min-width: 20em) { + + body.customize-partial-edit-shortcuts-shown .site-header .site-title { + padding-left: 0; + } +} + +@media screen and (min-width: 30em) { + + /* Typography */ + + body, + button, + input, + select, + textarea { + font-size: 18px; + font-size: 1.125rem; + } + + h1 { + font-size: 30px; + font-size: 1.875rem; + } + + h2, + .home.blog .entry-title, + .page .panel-content .recent-posts .entry-title { + font-size: 26px; + font-size: 1.625rem; + } + + h3 { + font-size: 22px; + font-size: 1.375rem; + } + + h4 { + font-size: 18px; + font-size: 1.125rem; + } + + h5 { + font-size: 13px; + font-size: 0.8125rem; + } + + h6 { + font-size: 16px; + font-size: 1rem; + } + + .entry-content blockquote.alignleft, + .entry-content blockquote.alignright { + font-size: 14px; + font-size: 0.875rem; + } + + /* Fix image alignment */ + img.alignleft { + float: left; + margin-right: 1.5em; + } + + img.alignright { + float: right; + margin-left: 1.5em; + } + + /* Site Branding */ + + .site-branding { + padding: 3em 0; + } + + /* Front Page */ + + .panel-content .wrap { + padding-bottom: 2em; + padding-top: 3.5em; + } + + .page-one-column .panel-content .wrap { + max-width: 740px; + } + + .panel-content .entry-header { + margin-bottom: 4.5em; + } + + .panel-content .recent-posts .entry-header { + margin-bottom: 0; + } + + /* Blog Index, Archive, Search */ + + .taxonomy-description { + font-size: 14px; + font-size: 0.875rem; + } + + .page-numbers.current { + font-size: 16px; + font-size: 1rem; + } + + /* Site Footer */ + + .site-footer { + font-size: 16px; + font-size: 1rem; + } + + /* Gallery Columns */ + + .gallery-item { + max-width: 25%; + } + + .gallery-columns-1 .gallery-item { + max-width: 100%; + } + + .gallery-columns-2 .gallery-item { + max-width: 50%; + } + + .gallery-columns-3 .gallery-item { + max-width: 33.33%; + } + + .gallery-columns-4 .gallery-item { + max-width: 25%; + } +} + +@media screen and (min-width: 48em) { + + /* Typography */ + + body, + button, + input, + select, + textarea { + font-size: 16px; + font-size: 1rem; + line-height: 1.5; + } + + .entry-content blockquote.alignleft, + .entry-content blockquote.alignright { + font-size: 13px; + font-size: 0.8125rem; + } + + /* Layout */ + + .wrap { + max-width: 1000px; + padding-left: 3em; + padding-right: 3em; + } + + .has-sidebar:not(.error404) #primary { + float: left; + width: 58%; + } + + .has-sidebar #secondary { + float: right; + padding-top: 0; + width: 36%; + } + + .error404 #primary { + float: none; + } + + /* Site Branding */ + + .site-branding { + margin-bottom: 0; + } + + .has-header-image.twentyseventeen-front-page .site-branding, + .has-header-video.twentyseventeen-front-page .site-branding, + .has-header-image.home.blog .site-branding, + .has-header-video.home.blog .site-branding { + bottom: 0; + display: block; + left: 0; + height: auto; + padding-top: 0; + position: absolute; + width: 100%; + } + + .has-header-image.twentyseventeen-front-page .custom-header, + .has-header-video.twentyseventeen-front-page .custom-header, + .has-header-image.home.blog .custom-header, + .has-header-video.home.blog .custom-header { + display: block; + height: auto; + } + + .custom-header-media { + height: 165px; + position: relative; + } + + .twentyseventeen-front-page.has-header-image .custom-header-media, + .twentyseventeen-front-page.has-header-video .custom-header-media, + .home.blog.has-header-image .custom-header-media, + .home.blog.has-header-video .custom-header-media { + height: 0; + position: relative; + } + + .has-header-image:not(.twentyseventeen-front-page):not(.home) .custom-header-media, + .has-header-video:not(.twentyseventeen-front-page):not(.home) .custom-header-media { + bottom: 0; + height: auto; + left: 0; + position: absolute; + right: 0; + top: 0; + } + + .custom-logo-link { + padding-right: 2em; + } + + .custom-logo-link img, + body.home.title-tagline-hidden.has-header-image .custom-logo-link img, + body.home.title-tagline-hidden.has-header-video .custom-logo-link img { + max-width: 350px; + } + + .title-tagline-hidden.home.has-header-image .custom-logo-link img, + .title-tagline-hidden.home.has-header-video .custom-logo-link img { + max-height: 200px; + } + + .site-title { + font-size: 36px; + font-size: 2.25rem; + } + + .site-description { + font-size: 16px; + font-size: 1rem; + } + + /* Navigation */ + + .navigation-top { + bottom: 0; + font-size: 14px; + font-size: 0.875rem; + left: 0; + position: absolute; + right: 0; + width: 100%; + z-index: 3; + } + + .navigation-top .wrap { + max-width: 1000px; + /* The font size is 14px here and we need 50px padding in ems */ + padding: 0.75em 3.4166666666667em; + } + + .navigation-top nav { + margin-left: -1.25em; + } + + .site-navigation-fixed.navigation-top { + bottom: auto; + position: fixed; + left: 0; + right: 0; + top: 0; + width: 100%; + z-index: 7; + } + + .admin-bar .site-navigation-fixed.navigation-top { + top: 32px; + } + + /* Main Navigation */ + + .js .menu-toggle, + .js .dropdown-toggle { + display: none; + } + + .main-navigation { + width: auto; + } + + .js .main-navigation ul, + .js .main-navigation ul ul, + .js .main-navigation > div > ul { + display: block; + } + + .main-navigation ul { + background: transparent; + padding: 0; + } + + .main-navigation > div > ul { + border: 0; + margin-bottom: 0; + padding: 0; + } + + .main-navigation li { + border: 0; + display: inline-block; + } + + .main-navigation li li { + display: block; + } + + .main-navigation a { + padding: 1em 1.25em; + } + + .main-navigation ul ul { + background: #fff; + border: 1px solid #bbb; + left: -999em; + padding: 0; + position: absolute; + top: 100%; + z-index: 99999; + } + + .main-navigation ul li.menu-item-has-children:before, + .main-navigation ul li.menu-item-has-children:after, + .main-navigation ul li.page_item_has_children:before, + .main-navigation ul li.page_item_has_children:after { + border-style: solid; + border-width: 0 6px 6px; + content: ""; + display: none; + height: 0; + position: absolute; + right: 1em; + bottom: -1px; + width: 0; + z-index: 100000; + } + + .main-navigation ul li.menu-item-has-children.focus:before, + .main-navigation ul li.menu-item-has-children:hover:before, + .main-navigation ul li.menu-item-has-children.focus:after, + .main-navigation ul li.menu-item-has-children:hover:after, + .main-navigation ul li.page_item_has_children.focus:before, + .main-navigation ul li.page_item_has_children:hover:before, + .main-navigation ul li.page_item_has_children.focus:after, + .main-navigation ul li.page_item_has_children:hover:after { + display: block; + } + + .main-navigation ul li.menu-item-has-children:before, + .main-navigation ul li.page_item_has_children:before { + border-color: transparent transparent #bbb; + bottom: 0; + } + + .main-navigation ul li.menu-item-has-children:after, + .main-navigation ul li.page_item_has_children:after { + border-color: transparent transparent #fff; + } + + .main-navigation ul ul li:hover > ul, + .main-navigation ul ul li.focus > ul { + left: 100%; + right: auto; + } + + .main-navigation ul ul a { + padding: 0.75em 1.25em; + width: 16em; + } + + .main-navigation li li { + -webkit-transition: background-color 0.2s ease-in-out; + transition: background-color 0.2s ease-in-out; + } + + .main-navigation li li:hover, + .main-navigation li li.focus { + background: #767676; + } + + .main-navigation li li a { + -webkit-transition: color 0.3s ease-in-out; + transition: color 0.3s ease-in-out; + } + + .main-navigation li li.focus > a, + .main-navigation li li:focus > a, + .main-navigation li li:hover > a, + .main-navigation li li a:hover, + .main-navigation li li a:focus, + .main-navigation li li.current_page_item a:hover, + .main-navigation li li.current-menu-item a:hover, + .main-navigation li li.current_page_item a:focus, + .main-navigation li li.current-menu-item a:focus { + color: #fff; + } + + .main-navigation ul li:hover > ul, + .main-navigation ul li.focus > ul { + left: 0.5em; + right: auto; + } + + .main-navigation .menu-item-has-children > a > .icon, + .main-navigation .page_item_has_children > a > .icon { + display: inline; + left: 5px; + position: relative; + top: -1px; + } + + .main-navigation ul ul .menu-item-has-children > a > .icon, + .main-navigation ul ul .page_item_has_children > a > .icon { + margin-top: -9px; + left: auto; + position: absolute; + right: 1em; + top: 50%; + -webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */ + -ms-transform: rotate(-90deg); /* IE 9 */ + transform: rotate(-90deg); + } + + .main-navigation ul ul ul { + left: -999em; + margin-top: -1px; + top: 0; + } + + .main-navigation ul ul li.menu-item-has-children.focus:before, + .main-navigation ul ul li.menu-item-has-children:hover:before, + .main-navigation ul ul li.menu-item-has-children.focus:after, + .main-navigation ul ul li.menu-item-has-children:hover:after, + .main-navigation ul ul li.page_item_has_children.focus:before, + .main-navigation ul ul li.page_item_has_children:hover:before, + .main-navigation ul ul li.page_item_has_children.focus:after, + .main-navigation ul ul li.page_item_has_children:hover:after { + display: none; + } + + .site-header .site-navigation-fixed .menu-scroll-down { + display: none; + } + + /* Scroll down arrow */ + + .site-header .menu-scroll-down { + display: block; + padding: 1em; + position: absolute; + right: 0; + } + + .site-header .menu-scroll-down .icon { + -webkit-transform: rotate(90deg); /* Chrome, Safari, Opera */ + -ms-transform: rotate(90deg); /* IE 9 */ + transform: rotate(90deg); + } + + .site-header .menu-scroll-down { + color: #fff; + top: 2em; + } + + .site-header .navigation-top .menu-scroll-down { + color: #767676; + top: 0.7em; + } + + .menu-scroll-down:focus { + outline: thin dotted; + } + + .menu-scroll-down .icon { + height: 18px; + width: 18px; + } + + /* Front Page */ + + .twentyseventeen-front-page.has-header-image .site-branding, + .twentyseventeen-front-page.has-header-video .site-branding, + .home.blog.has-header-image .site-branding, + .home.blog.has-header-video .site-branding { + margin-bottom: 70px; + } + + .twentyseventeen-front-page.has-header-image .custom-header-media, + .twentyseventeen-front-page.has-header-video .custom-header-media, + .home.blog.has-header-image .custom-header-media, + .home.blog.has-header-video .custom-header-media { + height: 1200px; + height: 100vh; + max-height: 100%; + overflow: hidden; + } + + .twentyseventeen-front-page.has-header-image .custom-header-media:before, + .twentyseventeen-front-page.has-header-video .custom-header-media:before, + .home.blog.has-header-image .custom-header-media:before, + .home.blog.has-header-video .custom-header-media:before { + height: 33%; + } + + .admin-bar.twentyseventeen-front-page.has-header-image .custom-header-media, + .admin-bar.twentyseventeen-front-page.has-header-video .custom-header-media, + .admin-bar.home.blog.has-header-image .custom-header-media, + .admin-bar.home.blog.has-header-video .custom-header-media { + height: calc(100vh - 32px); + } + + .panel-content .wrap { + padding-bottom: 4.5em; + padding-top: 6em; + } + + .panel-image { + height: 100vh; + max-height: 1200px; + } + + /* With panel images 100% of the screen height, we're going to fix the background image where supported to create a parallax-like effect. */ + .background-fixed .panel-image { + background-attachment: fixed; + } + + .page-two-column .panel-content .entry-header { + float: left; + width: 36%; + } + + .page-two-column .panel-content .entry-content { + float: right; + width: 58%; + } + + /* Front Page - Recent Posts */ + + .page-two-column .panel-content .recent-posts { + clear: right; + float: right; + width: 58%; + } + + .panel-content .recent-posts article { + margin-bottom: 4em; + } + + .panel-content .recent-posts .entry-header, + .page-two-column #primary .panel-content .recent-posts .entry-header, + .panel-content .recent-posts .entry-content, + .page-two-column #primary .panel-content .recent-posts .entry-content { + float: none; + width: 100%; + } + + .panel-content .recent-posts .entry-header { + margin-bottom: 1.5em; + } + + .page .panel-content .recent-posts .entry-title { + font-size: 26px; + font-size: 1.625rem; + } + + /* Posts */ + + .site-content { + padding: 5.5em 0 0; + } + + .single-post .entry-title, + .page .entry-title { + font-size: 26px; + font-size: 1.625rem; + } + + .comments-pagination, + .post-navigation { + clear: both; + } + + .post-navigation .nav-previous { + float: left; + width: 50%; + } + + .post-navigation .nav-next { + float: right; + text-align: right; + width: 50%; + } + + .nav-next, + .post-navigation .nav-next { + margin-top: 0; + } + + /* Blog, archive, search */ + + .sticky .icon-thumb-tack { + height: 23px; + left: -2.5em; + top: 1.5em; + width: 32px; + } + + body:not(.has-sidebar):not(.page-one-column) .page-header, + body.has-sidebar.error404 #primary .page-header, + body.page-two-column:not(.archive) #primary .entry-header, + body.page-two-column.archive:not(.has-sidebar) #primary .page-header { + float: left; + width: 36%; + } + + .blog:not(.has-sidebar) #primary article, + .archive:not(.page-one-column):not(.has-sidebar) #primary article, + .search:not(.has-sidebar) #primary article, + .error404:not(.has-sidebar) #primary .page-content, + .error404.has-sidebar #primary .page-content, + body.page-two-column:not(.archive) #primary .entry-content, + body.page-two-column #comments { + float: right; + width: 58%; + } + + .blog .site-main > article, + .archive .site-main > article, + .search .site-main > article { + padding-bottom: 4em; + } + + .navigation.pagination { + clear: both; + float: right; + width: 58%; + } + + .has-sidebar .navigation.pagination, + .archive.page-one-column:not(.has-sidebar) .navigation.pagination { + float: none; + width: 100%; + } + + .entry-footer { + display: table; + width: 100%; + } + + .entry-footer .cat-tags-links { + display: table-cell; + vertical-align: middle; + width: 100%; + } + + .entry-footer .edit-link { + display: table-cell; + text-align: right; + vertical-align: middle; + } + + .entry-footer .edit-link a.post-edit-link { + margin-top: 0; + margin-left: 1em; + } + + /* Entry content */ + + /* without sidebar */ + + :not(.has-sidebar) .entry-content blockquote.alignleft { + margin-left: -17.5%; + width: 48%; + } + + :not(.has-sidebar) .entry-content blockquote.alignright { + margin-right: -17.5%; + width: 48%; + } + + /* with sidebar */ + + .has-sidebar .entry-content blockquote.alignleft { + margin-left: 0; + width: 34%; + } + + .has-sidebar .entry-content blockquote.alignright { + margin-right: 0; + width: 34%; + } + + .has-sidebar #primary .entry-content blockquote.alignright.below-entry-meta { + margin-right: -72.5%; + width: 62%; + } + + /* blog and archive */ + + .blog:not(.has-sidebar) .entry-content blockquote.alignleft, + .twentyseventeen-front-page.page-two-column .entry-content blockquote.alignleft, + .archive:not(.has-sidebar) .entry-content blockquote.alignleft, + .page-two-column .entry-content blockquote.alignleft { + margin-left: -72.5%; + width: 62%; + } + + .blog:not(.has-sidebar) .entry-content blockquote.alignright, + .twentyseventeen-front-page.page-two-column .entry-content blockquote.alignright, + .archive:not(.has-sidebar) .entry-content blockquote.alignright, + .page-two-column .entry-content blockquote.alignright { + margin-right: 0; + width: 36%; + } + + /* Post formats */ + + .format-quote blockquote .icon { + left: -1.5em; + } + + /* Pages */ + + .page.page-one-column .entry-header, + .twentyseventeen-front-page.page-one-column .entry-header, + .archive.page-one-column:not(.has-sidebar) .page-header { + margin-bottom: 4em; + } + + .page:not(.home) #content { + padding-bottom: 3.25em; + } + + /* 404 page */ + + .error404 .page-content { + padding-bottom: 9em; + } + + /* Comments */ + + #comments { + padding-top: 5em; + } + + .comments-title { + margin-bottom: 2.5em; + } + + ol.children .children { + padding-left: 2em; + } + + /* Posts pagination */ + + .nav-links .nav-title { + position: relative; + } + + .nav-title-icon-wrapper { + position: absolute; + text-align: center; + width: 2em; + } + + .nav-links .nav-previous .nav-title .nav-title-icon-wrapper { + left: -2em; + } + + .nav-links .nav-next .nav-title .nav-title-icon-wrapper { + right: -2em; + } + + /* Secondary */ + + #secondary { + font-size: 14px; + font-size: 0.875rem; + line-height: 1.6; + } + + /* Widgets */ + + h2.widget-title { + font-size: 11px; + font-size: 0.6875rem; + margin-bottom: 2em; + } + + /* Footer */ + + .site-footer { + font-size: 14px; + font-size: 0.875rem; + line-height: 1.6; + margin-top: 3em; + } + + .site-footer .widget-column.footer-widget-1 { + float: left; + width: 36%; + } + + .site-footer .widget-column.footer-widget-2 { + float: right; + width: 58%; + } + + .social-navigation { + clear: left; + float: left; + margin-bottom: 0; + width: 36%; + } + + .site-info { + float: left; + padding: 0.7em 0 0; + width: 58%; + } + + .social-navigation + .site-info { + margin-left: 6%; + } + + .site-info .sep { + margin: 0 0.5em; + display: inline; + visibility: visible; + height: auto; + width: auto; + } + + /* Gallery Columns */ + + .gallery-columns-5 .gallery-item { + max-width: 20%; + } + + .gallery-columns-6 .gallery-item { + max-width: 16.66%; + } + + .gallery-columns-7 .gallery-item { + max-width: 14.28%; + } + + .gallery-columns-8 .gallery-item { + max-width: 12.5%; + } + + .gallery-columns-9 .gallery-item { + max-width: 11.11%; + } +} + +@media screen and ( min-width: 67em ) { + + /* Layout */ + + /* Navigation */ + .navigation-top .wrap { + padding: 0.75em 2em; + } + + .navigation-top nav { + margin-left: 0; + } + + /* Sticky posts */ + + .sticky .icon-thumb-tack { + font-size: 32px; + font-size: 2rem; + height: 22px; + left: -1.25em; + top: 0.75em; + width: 32px; + } + + /* Pagination */ + + .page-numbers { + display: inline-block; + } + + .page-numbers.current { + font-size: 15px; + font-size: 0.9375rem; + } + + .page-numbers.current .screen-reader-text { + clip: rect(1px, 1px, 1px, 1px); + height: 1px; + overflow: hidden; + position: absolute !important; + width: 1px; + } + + /* Comments */ + + .comment-body { + margin-left: 0; + } +} + +@media screen and ( min-width: 79em ) { + + .has-sidebar .entry-content blockquote.alignleft { + margin-left: -20%; + } + + .blog:not(.has-sidebar) .entry-content blockquote.alignright, + .archive:not(.has-sidebar) .entry-content blockquote.alignright, + .page-two-column .entry-content blockquote.alignright, + .twentyseventeen-front-page .entry-content blockquote.alignright { + margin-right: -20%; + } +} + +@media screen and ( max-width: 48.875em ) and ( min-width: 48em ) { + + .admin-bar .site-navigation-fixed.navigation-top, + .admin-bar .site-navigation-hidden.navigation-top { + top: 46px; + } +} + +/*-------------------------------------------------------------- +20.0 Print +--------------------------------------------------------------*/ + +@media print { + + /* Hide elements */ + + form, + button, + input, + select, + textarea, + .navigation-top, + .social-navigation, + #secondary, + .content-bottom-widgets, + .header-image, + .panel-image-prop, + .icon-thumb-tack, + .page-links, + .edit-link, + .post-navigation, + .pagination.navigation, + .comments-pagination, + .comment-respond, + .comment-edit-link, + .comment-reply-link, + .comment-metadata .edit-link, + .pingback .edit-link, + .site-footer aside.widget-area, + .site-info { + display: none !important; + } + + .entry-footer, + #comments, + .site-footer, + .single-featured-image-header { + border: 0; + } + + /* Font sizes */ + + body { + font-size: 12pt; + } + + h1 { + font-size: 24pt; + } + + h2 { + font-size: 22pt; + } + + h3 { + font-size: 17pt; + } + + h4 { + font-size: 12pt; + } + + h5 { + font-size: 11pt; + } + + h6 { + font-size: 12pt; + } + + .page .panel-content .entry-title, + .page-title, + body.page:not(.twentyseventeen-front-page) .entry-title { + font-size: 10pt; + } + + /* Layout */ + + .wrap { + padding-left: 5% !important; + padding-right: 5% !important; + max-width: none; + } + + /* Site Branding */ + + .site-header { + background: transparent; + padding: 0; + } + + .custom-header-media { + padding: 0; + } + + .twentyseventeen-front-page.has-header-image .site-branding, + .twentyseventeen-front-page.has-header-video .site-branding, + .home.blog.has-header-image .site-branding, + .home.blog.has-header-video .site-branding { + position: relative; + } + + .site-branding { + margin-top: 0; + margin-bottom: 1.75em !important; /* override styles added by JavaScript */ + } + + .site-title { + font-size: 25pt; + } + + .site-description { + font-size: 12pt; + opacity: 1; + } + + /* Posts */ + + .single-featured-image-header { + background: transparent; + } + + .entry-meta { + font-size: 9pt; + } + + /* Colors */ + + body, + .site { + background: none !important; /* Brute force since user agents all print differently. */ + } + + body, + a, + .site-title a, + .twentyseventeen-front-page.has-header-image .site-title, + .twentyseventeen-front-page.has-header-video .site-title, + .twentyseventeen-front-page.has-header-image .site-title a, + .twentyseventeen-front-page.has-header-video .site-title a { + color: #222 !important; /* Make sure color schemes don't affect to print */ + } + + h2, + h5, + blockquote, + .site-description, + .twentyseventeen-front-page.has-header-image .site-description, + .twentyseventeen-front-page.has-header-video .site-description, + .entry-meta, + .entry-meta a { + color: #777 !important; /* Make sure color schemes don't affect to print */ + } + + .entry-content blockquote.alignleft, + .entry-content blockquote.alignright { + font-size: 11pt; + width: 34%; + } + + .site-footer { + padding: 0; + } +} diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/footer/footer-widgets.php b/backend/wp-content/themes/twentyseventeen/template-parts/footer/footer-widgets.php new file mode 100644 index 0000000..1a4c288 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/footer/footer-widgets.php @@ -0,0 +1,32 @@ + + + + + + + diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/footer/site-info.php b/backend/wp-content/themes/twentyseventeen/template-parts/footer/site-info.php new file mode 100644 index 0000000..2f528ef --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/footer/site-info.php @@ -0,0 +1,21 @@ + +
      + ' ); + } + ?> + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/header/header-image.php b/backend/wp-content/themes/twentyseventeen/template-parts/header/header-image.php new file mode 100644 index 0000000..390debc --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/header/header-image.php @@ -0,0 +1,20 @@ + +
      + +
      + +
      + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php b/backend/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php new file mode 100644 index 0000000..27979e2 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/header/site-branding.php @@ -0,0 +1,38 @@ + +
      +
      + + + +
      + +

      + +

      + + + +

      + +
      + + + 'arrow-right' ) ); ?> + + +
      +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php b/backend/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php new file mode 100644 index 0000000..2c2115e --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php @@ -0,0 +1,29 @@ + + diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page-panels.php b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page-panels.php new file mode 100644 index 0000000..79e1194 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page-panels.php @@ -0,0 +1,79 @@ + + +
      > + + ID ), 'twentyseventeen-featured-image' ); + + // Calculate aspect ratio: h / w * 100%. + $ratio = $thumbnail[2] / $thumbnail[1] * 100; + ?> + +
      +
      +
      + + + +
      +
      +
      + ', '' ); ?> + + + +
      + +
      + "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + ?> +
      + + + + 3, + 'post_status' => 'publish', + 'ignore_sticky_posts' => true, + 'no_found_rows' => true, + ) ); + ?> + + have_posts() ) : ?> + +
      + + have_posts() ) : $recent_posts->the_post(); + get_template_part( 'template-parts/post/content', 'excerpt' ); + endwhile; + wp_reset_postdata(); + ?> +
      + + + +
      +
      + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page.php b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page.php new file mode 100644 index 0000000..84a0d7e --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-front-page.php @@ -0,0 +1,49 @@ + +
      > + + ID ), 'twentyseventeen-featured-image' ); + + // Calculate aspect ratio: h / w * 100%. + $ratio = $thumbnail[2] / $thumbnail[1] * 100; + ?> + +
      +
      +
      + + + +
      +
      +
      + ', '' ); ?> + + + +
      + +
      + "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + ?> +
      + +
      +
      + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/page/content-page.php b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-page.php new file mode 100644 index 0000000..4c470ac --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/page/content-page.php @@ -0,0 +1,30 @@ + + +
      > +
      + ', '' ); ?> + +
      +
      + '', + ) ); + ?> +
      +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php new file mode 100644 index 0000000..63cf2e5 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php @@ -0,0 +1,105 @@ + + +
      > + 'thumb-tack' ) ); + } + ?> +
      + '; + if ( is_single() ) { + twentyseventeen_posted_on(); + } else { + echo twentyseventeen_time_link(); + twentyseventeen_edit_link(); + }; + echo ''; + }; + + if ( is_single() ) { + the_title( '

      ', '

      ' ); + } elseif ( is_front_page() && is_home() ) { + the_title( '

      ', '

      ' ); + } else { + the_title( '

      ', '

      ' ); + } + ?> +
      + + + + +
      + + + +
      + + +
      + + '; + echo $audio_html; + echo '
      '; + } + }; + + }; + + if ( is_single() || empty( $audio ) ) { + + /* translators: %s: Name of current post */ + the_content( sprintf( + __( 'Continue reading "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + ) ); + + }; + ?> + + + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php new file mode 100644 index 0000000..a552fba --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php @@ -0,0 +1,46 @@ + + + diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php new file mode 100644 index 0000000..f5934e1 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php @@ -0,0 +1,92 @@ + + +
      > + 'thumb-tack' ) ); + } + ?> +
      + '; + if ( is_single() ) { + twentyseventeen_posted_on(); + } else { + echo twentyseventeen_time_link(); + twentyseventeen_edit_link(); + }; + echo ''; + }; + + if ( is_single() ) { + the_title( '

      ', '

      ' ); + } elseif ( is_front_page() && is_home() ) { + the_title( '

      ', '

      ' ); + } else { + the_title( '

      ', '

      ' ); + } + ?> +
      + + +
      + + + +
      + + +
      + + '; + echo get_post_gallery(); + echo '
      '; + }; + + }; + + if ( is_single() || ! get_post_gallery() ) { + + /* translators: %s: Name of current post */ + the_content( sprintf( + __( 'Continue reading "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + ) ); + + }; + ?> + + + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-image.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-image.php new file mode 100644 index 0000000..91c6545 --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-image.php @@ -0,0 +1,81 @@ + + +
      > + 'thumb-tack' ) ); + } + ?> +
      + '; + if ( is_single() ) { + twentyseventeen_posted_on(); + } else { + echo twentyseventeen_time_link(); + twentyseventeen_edit_link(); + }; + echo ''; + }; + + if ( is_single() ) { + the_title( '

      ', '

      ' ); + } elseif ( is_front_page() && is_home() ) { + the_title( '

      ', '

      ' ); + } else { + the_title( '

      ', '

      ' ); + } + ?> +
      + + +
      + + + +
      + + +
      + + "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + ) ); + + }; + ?> + +
      + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-none.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-none.php new file mode 100644 index 0000000..c42941b --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-none.php @@ -0,0 +1,33 @@ + + +
      + +
      + + +

      Get started here.', 'twentyseventeen' ), esc_url( admin_url( 'post-new.php' ) ) ); ?>

      + + + +

      + +
      +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content-video.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-video.php new file mode 100644 index 0000000..dad681f --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content-video.php @@ -0,0 +1,103 @@ + + +
      > + 'thumb-tack' ) ); + } + ?> +
      + '; + if ( is_single() ) { + twentyseventeen_posted_on(); + } else { + echo twentyseventeen_time_link(); + twentyseventeen_edit_link(); + } + echo ''; + }; + + if ( is_single() ) { + the_title( '

      ', '

      ' ); + } elseif ( is_front_page() && is_home() ) { + the_title( '

      ', '

      ' ); + } else { + the_title( '

      ', '

      ' ); + } + ?> +
      + + + + +
      + + + +
      + + +
      + + '; + echo $video_html; + echo '
      '; + } + }; + + }; + + if ( is_single() || empty( $video ) ) { + + /* translators: %s: Name of current post */ + the_content( sprintf( + __( 'Continue reading "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + ) ); + }; + ?> + + + + + +
      diff --git a/backend/wp-content/themes/twentyseventeen/template-parts/post/content.php b/backend/wp-content/themes/twentyseventeen/template-parts/post/content.php new file mode 100644 index 0000000..90c3a4d --- /dev/null +++ b/backend/wp-content/themes/twentyseventeen/template-parts/post/content.php @@ -0,0 +1,75 @@ + + +
      > + 'thumb-tack' ) ); + endif; + ?> +
      + '; + if ( is_single() ) { + twentyseventeen_posted_on(); + } else { + echo twentyseventeen_time_link(); + twentyseventeen_edit_link(); + }; + echo ''; + }; + + if ( is_single() ) { + the_title( '

      ', '

      ' ); + } elseif ( is_front_page() && is_home() ) { + the_title( '

      ', '

      ' ); + } else { + the_title( '

      ', '

      ' ); + } + ?> +
      + + +
      + + + +
      + + +
      + "%s"', 'twentyseventeen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + ) ); + ?> +
      + + + +
      diff --git a/backend/wp-content/themes/twentysixteen/404.php b/backend/wp-content/themes/twentysixteen/404.php new file mode 100644 index 0000000..59907be --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/404.php @@ -0,0 +1,34 @@ + + +
      +
      + +
      + + +
      +

      + + +
      +
      + +
      + + + +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/archive.php b/backend/wp-content/themes/twentysixteen/archive.php new file mode 100644 index 0000000..bdd2967 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/archive.php @@ -0,0 +1,65 @@ + + +
      +
      + + + + + + __( 'Previous page', 'twentysixteen' ), + 'next_text' => __( 'Next page', 'twentysixteen' ), + 'before_page_number' => '' . __( 'Page', 'twentysixteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'template-parts/content', 'none' ); + + endif; + ?> + +
      +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/comments.php b/backend/wp-content/themes/twentysixteen/comments.php new file mode 100644 index 0000000..7ff5b32 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/comments.php @@ -0,0 +1,79 @@ + + +
      + + +

      + +

      + + + +
        + 'ol', + 'short_ping' => true, + 'avatar_size' => 42, + ) ); + ?> +
      + + + + + + +

      + + + '

      ', + 'title_reply_after' => '

      ', + ) ); + ?> + +
      diff --git a/backend/wp-content/themes/twentysixteen/css/editor-style.css b/backend/wp-content/themes/twentysixteen/css/editor-style.css new file mode 100644 index 0000000..3055195 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/css/editor-style.css @@ -0,0 +1,547 @@ +/* +Theme Name: Twenty Sixteen +Description: Used to style the TinyMCE editor. +*/ + + +/** + * Table of Contents: + * + * 1.0 - Body + * 2.0 - Typography + * 3.0 - Elements + * 4.0 - Alignment + * 5.0 - Caption + * 6.0 - Galleries + * 7.0 - Audio / Video + * 8.0 - RTL + */ + + +/** + * 1.0 - Body + */ + +body { + color: #1a1a1a; + font-family: Merriweather, Georgia, serif; + font-size: 16px; + font-weight: 400; + line-height: 1.75; + margin: 20px 40px; + max-width: 600px; + vertical-align: baseline; +} + +body.post-type-page { + max-width: 840px; +} + + +/** + * 2.0 - Typography + */ + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + font-weight: 900; + margin: 56px 0 28px; +} + +h1 { + font-size: 33px; + line-height: 1.2727272727; +} + +h2 { + font-size: 28px; + line-height: 1.25; +} + +h3 { + font-size: 23px; + line-height: 1.2173913043; +} + +h4, +h5, +h6 { + font-size: 19px; + line-height: 1.1052631579; +} + +h4 { + letter-spacing: 0.13333em; + text-transform: uppercase; +} + +h6 { + font-style: italic; +} + +h1:first-child, +h2:first-child, +h3:first-child, +h4:first-child, +h5:first-child, +h6:first-child { + margin-top: 0; +} + +p { + margin: 0 0 28px; +} + +b, +strong { + font-weight: 700; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + border-left: 4px solid #1a1a1a; + color: #686868; + font-size: 19px; + font-style: italic; + line-height: 1.4736842105; + margin-bottom: 28px; + overflow: hidden; + padding: 0 0 0 24px; +} + +blockquote:not(.alignleft):not(.alignright) { + margin-left: -28px; +} + +blockquote blockquote:not(.alignleft):not(.alignright) { + margin-left: 0; +} + +blockquote:before, +blockquote:after { + content: ""; + display: table; +} + +blockquote:after { + clear: both; +} + +blockquote > :last-child { + margin-bottom: 0; +} + +blockquote cite, +blockquote small { + color: #1a1a1a; + font-size: 16px; + line-height: 1.75; +} + +blockquote em, +blockquote i, +blockquote cite { + font-style: normal; +} + +blockquote strong, +blockquote b { + font-weight: 400; +} + +blockquote.alignleft, +blockquote.alignright { + border: 0 solid #1a1a1a; + border-top-width: 4px; + padding: 18px 0 0; + width: -webkit-calc(50% - 14px); + width: calc(50% - 14px); +} + +address { + font-style: italic; + margin: 0 0 28px; +} + +code, +kbd, +tt, +var, +samp, +pre { + font-family: Inconsolata, monospace; +} + +pre { + border: 1px solid #d1d1d1; + font-size: 16px; + line-height: 1.3125; + margin: 0 0 28px; + max-width: 100%; + overflow: auto; + padding: 14px; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +code { + background-color: #d1d1d1; + padding: 2px 4px; +} + +abbr[title] { + border-bottom: 1px dotted #d1d1d1; + cursor: help; +} + +mark, +ins { + background: #007acc; + color: #fff; + padding: 2px 4px; + text-decoration: none; +} + +sup, +sub { + font-size: 75%; + height: 0; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sub { + top: -6px; +} + +sup { + bottom: -3px; +} + +small { + font-size: 80%; +} + +big { + font-size: 125%; +} + + +/** + * 3.0 - Elements + */ + +hr { + background-color: #d1d1d1; + border: 0; + height: 1px; + margin-bottom: 28px; +} + +ul, +ol { + margin: 0 0 28px 0; + padding: 0; +} + +ul { + list-style: disc; +} + +ol { + list-style: decimal; +} + +li > ul, +li > ol { + margin-bottom: 0; +} + +li > ul, +blockquote > ul { + margin-left: 20px; +} + +li > ol, +blockquote > ol { + margin-left: 24px; +} + +dl { + margin: 0 0 28px; +} + +dt { + font-weight: bold; +} + +dd { + margin: 0 0 28px; +} + +table, +th, +td, +.mce-item-table, +.mce-item-table th, +.mce-item-table td { + border: 1px solid #d1d1d1; +} + +table a { + color: #007acc; +} + +table, +.mce-item-table { + border-collapse: separate; + border-spacing: 0; + border-width: 1px 0 0 1px; + margin: 0 0 28px; + width: 100%; +} + +table th, +.mce-item-table th, +table caption { + border-width: 0 1px 1px 0; + font-size: 16px; + font-weight: 700; + padding: 7px; + text-align: left; + vertical-align: baseline; +} + +table td, +.mce-item-table td { + border-width: 0 1px 1px 0; + font-size: 16px; + padding: 7px; + vertical-align: baseline; +} + +img { + border: 0; + height: auto; + max-width: 100%; + vertical-align: middle; +} + +a img { + display: block; +} + +figure { + margin: 0; +} + +del { + opacity: 0.8; +} + +a { + box-shadow: 0 1px 0 0 currentColor; + color: #007acc; + text-decoration: none; +} + +fieldset { + border: 1px solid #d1d1d1; + margin: 0 0 28px; + padding: 14px; +} + + +/** + * 4.0 - Alignment + */ + +.alignleft { + float: left; + margin: 6px 28px 28px 0; +} + +.alignright { + float: right; + margin: 6px 0 28px 28px; +} + +.aligncenter { + clear: both; + display: block; + margin: 0 auto 28px; +} + + +/** + * 5.0 - Caption + */ + +.wp-caption { + background: transparent; + border: none; + margin-bottom: 28px; + max-width: 100%; + padding: 0; + text-align: inherit; +} + +.wp-caption-text, +.wp-caption-dd { + color: #686868; + font-size: 13px; + font-style: italic; + line-height: 1.6153846154; + padding-top: 7px; +} + + +/** + * 6.0 - Galleries + */ + +.mce-content-body .wpview-wrap { + margin-bottom: 28px; +} + +.gallery { + margin: 0 -1.1666667%; + padding: 0; +} + +.gallery .gallery-item { + display: inline-block; + max-width: 33.33%; + padding: 0 1.1400652% 2.2801304%; + text-align: center; + vertical-align: top; + width: 100%; +} + +.gallery-columns-1 .gallery-item { + max-width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-columns-4 .gallery-item { + max-width: 25%; +} + +.gallery-columns-5 .gallery-item { + max-width: 20%; +} + +.gallery-columns-6 .gallery-item { + max-width: 16.66%; +} + +.gallery-columns-7 .gallery-item { + max-width: 14.28%; +} + +.gallery-columns-8 .gallery-item { + max-width: 12.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 11.11%; +} + +.gallery .gallery-caption { + font-size: 13px; + margin: 0; +} + +.gallery-columns-6 .gallery-caption, +.gallery-columns-7 .gallery-caption, +.gallery-columns-8 .gallery-caption, +.gallery-columns-9 .gallery-caption { + display: none; +} + + +/** + * 7.0 - Audio / Video + */ + +.wp-audio-shortcode a, +.wp-playlist a { + box-shadow: none; +} + +.mce-content-body .wp-audio-playlist { + margin: 0; + padding-bottom: 0; +} + +.mce-content-body .wp-playlist-tracks { + margin-top: 0; +} + +.mce-content-body .wp-playlist-item { + padding: 10px 0; +} + +.mce-content-body .wp-playlist-item-length { + top: 10px; +} + + +/** + * 8.0 - RTL + */ + +.rtl blockquote { + border: 0 solid #1a1a1a; + border-right-width: 4px; +} + +.rtl blockquote.alignleft, +.rtl blockquote.alignright { + border: 0 solid #1a1a1a; + border-top-width: 4px; +} + +.rtl blockquote:not(.alignleft):not(.alignright) { + margin-right: -28px; + padding: 0 24px 0 0; +} + +.rtl blockquote blockquote:not(.alignleft):not(.alignright) { + margin-right: 0; + margin-left: auto; +} + +.rtl li > ul, +.rtl blockquote > ul { + margin-right: 20px; + margin-left: auto; +} + +.rtl li > ol, +.rtl blockquote > ol { + margin-right: 24px; + margin-left: auto; +} + +.rtl table th, +.rtl .mce-item-table th, +.rtl table caption { + text-align: right; +} diff --git a/backend/wp-content/themes/twentysixteen/css/ie.css b/backend/wp-content/themes/twentysixteen/css/ie.css new file mode 100644 index 0000000..6aa093a --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/css/ie.css @@ -0,0 +1,48 @@ +/* +Theme Name: Twenty Sixteen +Description: Global Styles for older IE versions (previous to IE10). +*/ + +.site-header-main:before, +.site-header-main:after, +.site-footer:before, +.site-footer:after { + content: ""; + display: table; +} + +.site-header-main:after, +.site-footer:after { + clear: both; +} + +@media screen and (min-width: 56.875em) { + .site-branding, + .site-info { + float: left; + } + + .site-header-menu, + .site-footer .social-navigation { + float: right; + } + + .site-footer .social-navigation { + margin-left: 7px; + } + + .rtl .site-branding, + .rtl .site-info { + float: right; + } + + .rtl .site-header-menu, + .rtl .site-footer .social-navigation { + float: left; + } + + .rtl .site-footer .social-navigation { + margin-right: 7px; + margin-left: 0; + } +} diff --git a/backend/wp-content/themes/twentysixteen/css/ie7.css b/backend/wp-content/themes/twentysixteen/css/ie7.css new file mode 100644 index 0000000..6f9ec28 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/css/ie7.css @@ -0,0 +1,176 @@ +/* +Theme Name: Twenty Sixteen +Description: IE7 specific style. +*/ + +.site-inner { + max-width: 656px; +} + +.post-navigation, +.pagination, +.image-navigation, +.entry-header, +.entry-summary, +.entry-content, +.entry-footer, +.page-header, +.page-content, +.post-thumbnail, +.content-bottom-widgets, +.comments-area { + margin-right: 28px; + margin-left: 28px; + max-width: 100%; +} + +.site-header, +.sidebar, +.site-footer, +.widecolumn { + padding-right: 28px; + padding-left: 28px; +} + +.search-submit { + height: auto; + margin-top: 28px; + padding: 15px 0 8px; + position: relative; + width: auto; +} + +.search-submit .screen-reader-text { + height: auto; + position: relative !important; + width: auto; +} + +.image-navigation .nav-previous, +.image-navigation .nav-next, +.comment-navigation .nav-previous, +.comment-navigation .nav-next { + *display: inline; + zoom: 1; +} + +.image-navigation .nav-previous + .nav-next, +.comment-navigation .nav-previous + .nav-next { + margin-left: 14px; +} + +.pagination .nav-links { + padding: 0; +} + +.pagination .page-numbers { + line-height: 1; + margin: -4px 14px 0; + padding: 18px 0; +} + +.pagination .prev, +.pagination .next { + display: inline-block; + font-size: 16px; + font-weight: 700; + height: auto; + left: 0; + line-height: 1; + margin: 0; + padding: 18px 14px; + position: relative; + right: 0; + text-transform: none; + width: auto; +} + +.dropdown-toggle { + display: none; +} + +.main-navigation ul ul { + display: block; +} + +.social-navigation { + margin-top: 1.75em; +} + +.social-navigation a { + height: auto; + padding: 3px 7px; + width: auto; +} + +.social-navigation .screen-reader-text { + height: auto; + position: relative !important; + width: auto; +} + +.site-header-main { + overflow : hidden; + zoom : 1; +} + +.entry-footer > span { + margin-right: 14px; +} + +.site-info .site-title { + font-size: 13px; + margin-right: 14px; +} + +.gallery-item { + max-width: 30%; +} + +.gallery-columns-1 .gallery-item { + max-width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 46%; +} + +.gallery-columns-4 .gallery-item { + max-width: 22%; +} + +.gallery-columns-5 .gallery-item { + max-width: 17%; +} + +.gallery-columns-6 .gallery-item { + max-width: 13.5%; +} + +.gallery-columns-7 .gallery-item { + max-width: 11%; +} + +.gallery-columns-8 .gallery-item { + max-width: 9.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 8%; +} + +.rtl .image-navigation .nav-previous + .nav-next, +.rtl .comment-navigation .nav-previous + .nav-next { + margin-right: 14px; + margin-left: 0; +} + +.rtl .entry-footer > span { + margin-right: 14px; + margin-left: 0; +} + +.rtl .site-info .site-title { + margin-right: 0; + margin-left: 14px; +} diff --git a/backend/wp-content/themes/twentysixteen/css/ie8.css b/backend/wp-content/themes/twentysixteen/css/ie8.css new file mode 100644 index 0000000..1b07fe8 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/css/ie8.css @@ -0,0 +1,222 @@ +/* +Theme Name: Twenty Sixteen +Description: IE8 specific style. +*/ + +code { + background-color: transparent; + padding: 0; +} + +.entry-content a, +.entry-summary a, +.taxonomy-description a, +.logged-in-as a, +.comment-content a, +.pingback .comment-body > a, +.textwidget a, +.entry-footer a:hover, +.site-info a:hover { + text-decoration: underline; +} + +.entry-content a:hover, +.entry-content a:focus, +.entry-summary a:hover, +.entry-summary a:focus, +.taxonomy-description a:hover, +.taxonomy-description a:focus, +.logged-in-as a:hover, +.logged-in-as a:focus, +.comment-content a:hover, +.comment-content a:focus, +.pingback .comment-body > a:hover, +.pingback .comment-body > a:focus, +.textwidget a:hover, +.textwidget a:focus, +.entry-content .wp-audio-shortcode a, +.entry-content .wp-playlist a, +.page-links a { + text-decoration: none; +} + +.site { + margin: 21px; +} + +.site-inner { + max-width: 710px; +} + +.site-header { + padding-top: 3.9375em; + padding-bottom: 3.9375em; +} + +.site-branding { + float: left; + margin-top: 1.3125em; + margin-bottom: 1.3125em; +} + +.site-title { + font-size: 28px; + line-height: 1.25; +} + +.site-description { + display: block; +} + +.menu-toggle { + float: right; + font-size: 16px; + margin: 1.3125em 0; + padding: 0.8125em 0.875em 0.6875em; +} + +.site-header-menu { + clear: both; + margin: 0; + padding: 1.3125em 0; +} + +.site-header .main-navigation + .social-navigation { + margin-top: 2.625em; +} + +.header-image { + margin: 1.3125em 0; +} + +.site-main { + margin-bottom: 5.25em; +} + +.post-navigation { + margin-bottom: 5.25em; +} + +.post-navigation .post-title { + font-size: 28px; + line-height: 1.25; +} + +.pagination { + margin: 0 7.6923% 4.421052632em; +} + +.pagination .nav-links:before, +.pagination .nav-links:after { + display: none; +} + +/* restore screen-reader-text */ +.pagination .current .screen-reader-text { + position: absolute !important; +} + +.pagination .page-numbers { + display: inline-block; + font-weight: 400; +} + +.image-navigation .nav-previous, +.image-navigation .nav-next, +.comment-navigation .nav-previous, +.comment-navigation .nav-next { + display: inline-block; +} + +.image-navigation .nav-previous + .nav-next:before, +.comment-navigation .nav-previous + .nav-next:before { + content: "\002f"; + display: inline-block; + filter: alpha(opacity=70); + padding: 0 0.538461538em; +} + +.site-main > article { + margin-bottom: 5.25em; +} + +.entry-title { + font-size: 33px; + line-height: 1.2727272727; + margin-bottom: 0.8484848485em; +} + +.entry-content blockquote.alignleft, +.entry-content blockquote.alignright { + border-width: 4px 0 0 0; + padding: 0.9473684211em 0 0; + width: 50%; +} + +.entry-footer > span:after { + content: "\002f"; + display: inline-block; + filter: alpha(opacity=70); + padding: 0 0.538461538em; +} + +.updated { + display: none; +} + +.updated.published { + display: inline; +} + +.comment-author { + margin-bottom: 0; +} + +.comment-author .avatar { + height: 42px; + position: relative; + top: 0.25em; + width: 42px; +} + +.comment-list .children > li { + padding-left: 1.75em; +} + +.comment-list + .comment-respond, +.comment-navigation + .comment-respond { + padding-top: 3.5em; +} + +.comment-reply-link { + margin-top: 0; +} + +.comments-area, +.widget, +.content-bottom-widgets .widget-area { + margin-bottom: 5.25em; +} + +.sidebar, +.widecolumn { + margin-bottom: 5.25em; +} + +.site-footer .main-navigation, +.site-footer .social-navigation { + display: none; +} + +.rtl .site-branding { + float: right; +} + +.rtl .menu-toggle { + float: left; +} + +.rtl .comment-list .children > li { + padding-right: 1.75em; + padding-left: 0; +} diff --git a/backend/wp-content/themes/twentysixteen/footer.php b/backend/wp-content/themes/twentysixteen/footer.php new file mode 100644 index 0000000..baa8209 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/footer.php @@ -0,0 +1,66 @@ + + + + +
      + + + + + + + + +
      + + + ' ); + } + ?> + + + +
      +
      + + + + + + diff --git a/backend/wp-content/themes/twentysixteen/functions.php b/backend/wp-content/themes/twentysixteen/functions.php new file mode 100644 index 0000000..d6e58e1 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/functions.php @@ -0,0 +1,434 @@ + tag in the document head, and expect WordPress to + * provide it for us. + */ + add_theme_support( 'title-tag' ); + + /* + * Enable support for custom logo. + * + * @since Twenty Sixteen 1.2 + */ + add_theme_support( 'custom-logo', array( + 'height' => 240, + 'width' => 240, + 'flex-height' => true, + ) ); + + /* + * Enable support for Post Thumbnails on posts and pages. + * + * @link https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails + */ + add_theme_support( 'post-thumbnails' ); + set_post_thumbnail_size( 1200, 9999 ); + + // This theme uses wp_nav_menu() in two locations. + register_nav_menus( array( + 'primary' => __( 'Primary Menu', 'twentysixteen' ), + 'social' => __( 'Social Links Menu', 'twentysixteen' ), + ) ); + + /* + * Switch default core markup for search form, comment form, and comments + * to output valid HTML5. + */ + add_theme_support( 'html5', array( + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ) ); + + /* + * Enable support for Post Formats. + * + * See: https://codex.wordpress.org/Post_Formats + */ + add_theme_support( 'post-formats', array( + 'aside', + 'image', + 'video', + 'quote', + 'link', + 'gallery', + 'status', + 'audio', + 'chat', + ) ); + + /* + * This theme styles the visual editor to resemble the theme style, + * specifically font, colors, icons, and column width. + */ + add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) ); + + // Indicate widget sidebars can use selective refresh in the Customizer. + add_theme_support( 'customize-selective-refresh-widgets' ); +} +endif; // twentysixteen_setup +add_action( 'after_setup_theme', 'twentysixteen_setup' ); + +/** + * Sets the content width in pixels, based on the theme's design and stylesheet. + * + * Priority 0 to make it available to lower priority callbacks. + * + * @global int $content_width + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_content_width() { + $GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 840 ); +} +add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 ); + +/** + * Registers a widget area. + * + * @link https://developer.wordpress.org/reference/functions/register_sidebar/ + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_widgets_init() { + register_sidebar( array( + 'name' => __( 'Sidebar', 'twentysixteen' ), + 'id' => 'sidebar-1', + 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ), + 'before_widget' => '
      ', + 'after_widget' => '
      ', + 'before_title' => '

      ', + 'after_title' => '

      ', + ) ); + + register_sidebar( array( + 'name' => __( 'Content Bottom 1', 'twentysixteen' ), + 'id' => 'sidebar-2', + 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), + 'before_widget' => '
      ', + 'after_widget' => '
      ', + 'before_title' => '

      ', + 'after_title' => '

      ', + ) ); + + register_sidebar( array( + 'name' => __( 'Content Bottom 2', 'twentysixteen' ), + 'id' => 'sidebar-3', + 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), + 'before_widget' => '
      ', + 'after_widget' => '
      ', + 'before_title' => '

      ', + 'after_title' => '

      ', + ) ); +} +add_action( 'widgets_init', 'twentysixteen_widgets_init' ); + +if ( ! function_exists( 'twentysixteen_fonts_url' ) ) : +/** + * Register Google fonts for Twenty Sixteen. + * + * Create your own twentysixteen_fonts_url() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @return string Google fonts URL for the theme. + */ +function twentysixteen_fonts_url() { + $fonts_url = ''; + $fonts = array(); + $subsets = 'latin,latin-ext'; + + /* translators: If there are characters in your language that are not supported by Merriweather, translate this to 'off'. Do not translate into your own language. */ + if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'twentysixteen' ) ) { + $fonts[] = 'Merriweather:400,700,900,400italic,700italic,900italic'; + } + + /* translators: If there are characters in your language that are not supported by Montserrat, translate this to 'off'. Do not translate into your own language. */ + if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'twentysixteen' ) ) { + $fonts[] = 'Montserrat:400,700'; + } + + /* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */ + if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentysixteen' ) ) { + $fonts[] = 'Inconsolata:400'; + } + + if ( $fonts ) { + $fonts_url = add_query_arg( array( + 'family' => urlencode( implode( '|', $fonts ) ), + 'subset' => urlencode( $subsets ), + ), 'https://fonts.googleapis.com/css' ); + } + + return $fonts_url; +} +endif; + +/** + * Handles JavaScript detection. + * + * Adds a `js` class to the root `` element when JavaScript is detected. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_javascript_detection() { + echo "\n"; +} +add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 ); + +/** + * Enqueues scripts and styles. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_scripts() { + // Add custom fonts, used in the main stylesheet. + wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null ); + + // Add Genericons, used in the main stylesheet. + wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.4.1' ); + + // Theme stylesheet. + wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri() ); + + // Load the Internet Explorer specific stylesheet. + wp_enqueue_style( 'twentysixteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentysixteen-style' ), '20160816' ); + wp_style_add_data( 'twentysixteen-ie', 'conditional', 'lt IE 10' ); + + // Load the Internet Explorer 8 specific stylesheet. + wp_enqueue_style( 'twentysixteen-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'twentysixteen-style' ), '20160816' ); + wp_style_add_data( 'twentysixteen-ie8', 'conditional', 'lt IE 9' ); + + // Load the Internet Explorer 7 specific stylesheet. + wp_enqueue_style( 'twentysixteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentysixteen-style' ), '20160816' ); + wp_style_add_data( 'twentysixteen-ie7', 'conditional', 'lt IE 8' ); + + // Load the html5 shiv. + wp_enqueue_script( 'twentysixteen-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' ); + wp_script_add_data( 'twentysixteen-html5', 'conditional', 'lt IE 9' ); + + wp_enqueue_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20160816', true ); + + if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { + wp_enqueue_script( 'comment-reply' ); + } + + if ( is_singular() && wp_attachment_is_image() ) { + wp_enqueue_script( 'twentysixteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20160816' ); + } + + wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160816', true ); + + wp_localize_script( 'twentysixteen-script', 'screenReaderText', array( + 'expand' => __( 'expand child menu', 'twentysixteen' ), + 'collapse' => __( 'collapse child menu', 'twentysixteen' ), + ) ); +} +add_action( 'wp_enqueue_scripts', 'twentysixteen_scripts' ); + +/** + * Adds custom classes to the array of body classes. + * + * @since Twenty Sixteen 1.0 + * + * @param array $classes Classes for the body element. + * @return array (Maybe) filtered body classes. + */ +function twentysixteen_body_classes( $classes ) { + // Adds a class of custom-background-image to sites with a custom background image. + if ( get_background_image() ) { + $classes[] = 'custom-background-image'; + } + + // Adds a class of group-blog to sites with more than 1 published author. + if ( is_multi_author() ) { + $classes[] = 'group-blog'; + } + + // Adds a class of no-sidebar to sites without active sidebar. + if ( ! is_active_sidebar( 'sidebar-1' ) ) { + $classes[] = 'no-sidebar'; + } + + // Adds a class of hfeed to non-singular pages. + if ( ! is_singular() ) { + $classes[] = 'hfeed'; + } + + return $classes; +} +add_filter( 'body_class', 'twentysixteen_body_classes' ); + +/** + * Converts a HEX value to RGB. + * + * @since Twenty Sixteen 1.0 + * + * @param string $color The original color, in 3- or 6-digit hexadecimal form. + * @return array Array containing RGB (red, green, and blue) values for the given + * HEX code, empty array otherwise. + */ +function twentysixteen_hex2rgb( $color ) { + $color = trim( $color, '#' ); + + if ( strlen( $color ) === 3 ) { + $r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) ); + $g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) ); + $b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) ); + } else if ( strlen( $color ) === 6 ) { + $r = hexdec( substr( $color, 0, 2 ) ); + $g = hexdec( substr( $color, 2, 2 ) ); + $b = hexdec( substr( $color, 4, 2 ) ); + } else { + return array(); + } + + return array( 'red' => $r, 'green' => $g, 'blue' => $b ); +} + +/** + * Custom template tags for this theme. + */ +require get_template_directory() . '/inc/template-tags.php'; + +/** + * Customizer additions. + */ +require get_template_directory() . '/inc/customizer.php'; + +/** + * Add custom image sizes attribute to enhance responsive image functionality + * for content images + * + * @since Twenty Sixteen 1.0 + * + * @param string $sizes A source size value for use in a 'sizes' attribute. + * @param array $size Image size. Accepts an array of width and height + * values in pixels (in that order). + * @return string A source size value for use in a content image 'sizes' attribute. + */ +function twentysixteen_content_image_sizes_attr( $sizes, $size ) { + $width = $size[0]; + + if ( 840 <= $width ) { + $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px'; + } + + if ( 'page' === get_post_type() ) { + if ( 840 > $width ) { + $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; + } + } else { + if ( 840 > $width && 600 <= $width ) { + $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px'; + } elseif ( 600 > $width ) { + $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; + } + } + + return $sizes; +} +add_filter( 'wp_calculate_image_sizes', 'twentysixteen_content_image_sizes_attr', 10 , 2 ); + +/** + * Add custom image sizes attribute to enhance responsive image functionality + * for post thumbnails + * + * @since Twenty Sixteen 1.0 + * + * @param array $attr Attributes for the image markup. + * @param int $attachment Image attachment ID. + * @param array $size Registered image size or flat array of height and width dimensions. + * @return array The filtered attributes for the image markup. + */ +function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { + if ( 'post-thumbnail' === $size ) { + if ( is_active_sidebar( 'sidebar-1' ) ) { + $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px'; + } else { + $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px'; + } + } + return $attr; +} +add_filter( 'wp_get_attachment_image_attributes', 'twentysixteen_post_thumbnail_sizes_attr', 10 , 3 ); + +/** + * Modifies tag cloud widget arguments to display all tags in the same font size + * and use list format for better accessibility. + * + * @since Twenty Sixteen 1.1 + * + * @param array $args Arguments for tag cloud widget. + * @return array The filtered arguments for tag cloud widget. + */ +function twentysixteen_widget_tag_cloud_args( $args ) { + $args['largest'] = 1; + $args['smallest'] = 1; + $args['unit'] = 'em'; + $args['format'] = 'list'; + + return $args; +} +add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' ); diff --git a/backend/wp-content/themes/twentysixteen/genericons/COPYING.txt b/backend/wp-content/themes/twentysixteen/genericons/COPYING.txt new file mode 100644 index 0000000..aece214 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/genericons/COPYING.txt @@ -0,0 +1,9 @@ +Genericons 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. + +The fonts are distributed 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. + +As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. + +This license does not convey any intellectual property rights to third party trademarks that may be included in the icon font; such marks remain subject to all rights and guidelines of use of their owner. \ No newline at end of file diff --git a/backend/wp-content/themes/twentysixteen/genericons/Genericons.eot b/backend/wp-content/themes/twentysixteen/genericons/Genericons.eot new file mode 100644 index 0000000..7322565 Binary files /dev/null and b/backend/wp-content/themes/twentysixteen/genericons/Genericons.eot differ diff --git a/backend/wp-content/themes/twentysixteen/genericons/Genericons.svg b/backend/wp-content/themes/twentysixteen/genericons/Genericons.svg new file mode 100644 index 0000000..4740685 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/genericons/Genericons.svg @@ -0,0 +1,537 @@ + + + + + +Created by FontForge 20150618 at Fri Sep 18 10:24:13 2015 + By Joen Asmussen +Copyright (c) 2015, Joen Asmussen + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/wp-content/themes/twentysixteen/genericons/Genericons.ttf b/backend/wp-content/themes/twentysixteen/genericons/Genericons.ttf new file mode 100644 index 0000000..0174438 Binary files /dev/null and b/backend/wp-content/themes/twentysixteen/genericons/Genericons.ttf differ diff --git a/backend/wp-content/themes/twentysixteen/genericons/Genericons.woff b/backend/wp-content/themes/twentysixteen/genericons/Genericons.woff new file mode 100644 index 0000000..0e7212a Binary files /dev/null and b/backend/wp-content/themes/twentysixteen/genericons/Genericons.woff differ diff --git a/backend/wp-content/themes/twentysixteen/genericons/LICENSE.txt b/backend/wp-content/themes/twentysixteen/genericons/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/genericons/LICENSE.txt @@ -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. + + + Copyright (C) + + 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. + + , 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. diff --git a/backend/wp-content/themes/twentysixteen/genericons/README.md b/backend/wp-content/themes/twentysixteen/genericons/README.md new file mode 100644 index 0000000..4aa8cc0 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/genericons/README.md @@ -0,0 +1,218 @@ +# Genericons + +Genericons are vector icons embedded in a webfont designed to be clean and simple keeping with a generic aesthetic. + +Use genericons for instant HiDPI, to change icon colors on the fly, or even with CSS effects such as drop-shadows or gradients! + + +## Usage + +To use it, place the `genericons` folder in your stylesheet directory and enqueue the genericons.css file. Now you can create an icon like this: + +``` +.my-icon:before { + content: '\f101'; + font: normal 16px/1 'Genericons'; + display: inline-block; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +``` + +This will output a comment icon before every element with the class "my-icon". The `content: '\f101';` part of this CSS is easily copied from the helper tool at http://genericons.com/, or `example.html` in the `font` directory. + +You can also use the bundled example.css if you'd rather insert the icons using HTML tags. + + +## Building your own Genericons + +In the `source` directory, you'll find all Genericons source icons in SVG format. This will allow you to bake your own flavor of Genericons using a tool such as FontCustom (http://fontcustom.com) or Fontello (http://fontello.com). Perhaps you need more logos than are available in the base Genericons package? Just add those logos and bake your own expanded set. Maybe you need just a few of the icons Genericons provides, but would like to trim the fat? Remove the ones you won't need! + + +### FontCustom instructions + +FontCustom is a powerful commandline tool which which bakes icon fonts from the SVG source files. It's the tool Genericons is built on, and it provides highly accurate and perfectly crisp icons, *provided all SVGs have the same pixel height*. + +It's not that hard to use, and once it's installed you'll never think of icon-fonts the same way again. Seriously, you should try it. Icon fonts for everyone! + +1. Install FontCustom. Follow the instructions on the website: http://fontcustom.com/ +2. In the `source` directory from the Genericons download, open the file called `fontcustom.yml` in a text editor. Customize the `font_name` and `css_selector`. +3. Open a terminal. Browse to the `source` directory. Type `fontcustom compile`. + +You'll now receive a brand new subdirectory called `fontcustom-webfont`. Inside here you'll find your very own flavor of Genericons, with only the icons you want, including a handy example page that'll help you copy/paste the necessary glyphs or CSS values. + +*Please note*: In the source directory, there's a hidden file called `.fontcustom-manifest.json`. This file is auto-generated by the FontCustom tool, and holds codepoints (unicode addresses) for every glyph, so its address doesn't change when you add or remove icons. If you feel the need to "start fresh" with the unicode addresses, you should delete this file. + + +### Fontello instructions + +Fontello is very easy to use. Just drop the SVG files of the icons you want onto their website and download the font. The downside is that Fontello seems to ignore the 16px pixelgrid, so you'll end up with fuzzy icons. Buyer beware. + + +## Notes + +**Photoshop mockups** + +The `Genericons.ttf` file can be placed in your system fonts folder and used Photoshop or other graphics apps if you like. + +If you're using Genericons in your Photoshop mockups, please remember to delete the old version of the font from Font Book, and grab the new one from the zip file. This also affects using it in your webdesigns: if you have an old version of the font installed locally, that's the font that'll be used in your website as well, so if you're missing icons, check for old versions of the font on your system. + +**Pixel grid** + +Genericons has been designed for a 16x16px grid. That means it'll look sharp at font-size: 16px exactly. It'll also be crisp at multiples thereof, such as 32px or 64px. It'll look reasonably crisp at in-between font sizes such as 24px or 48px, but not quite as crisp as 16 or 32. Please don't set the font-size to 17px, though, that'll just look terrible blurry. + +**Antialiasing** + +If you keep intact the `-webkit-font-smoothing: antialiased;` and `-moz-osx-font-smoothing: grayscale;` CSS properties. That'll make the icons look their best possible, in Firefox and WebKit based browsers. + +**optimizeLegibility** + +Note: On Android browsers with version 4.2, 4.3, and probably later, Genericons will simply not show up if you're using the CSS property "text-rendering" set to "optimizeLegibility. + +**Updates** + +We don't often update icons, but do very carefully when we get good feedback suggesting improvements. Please be mindful if you upgrade, and check that the updated icons behave as you intended. + +**Base64 encoding** + +By default, Genericons ships with a stylesheet that includes a base64 encoded version of the font. This is to sidestep issues with cross-origin requests for fonts, that happen when a stylesheet loads a font that's stored on a different domain or subdomain. This is very common when using caching plugins. + +Base64 encoding comes with a 25% filesize overhead compared to just loading the WOFF file directly. If you know that you won't be loading fonts across domains, or have the ability to edit your server config files to allow it, you can get slightly faster performance by loading Genericons without the base64 encoding. Simply edit `genericons.css` and edit the `@font-face` declaration to match this: + +``` +@font-face { + font-family: 'Genericons'; + src: url('Genericons.woff') format('woff'), + url('Genericons.ttf') format('truetype'), + url('Genericons.svg#genericonsregular') format('svg'); + font-weight: normal; + font-style: normal; +} +``` + + + +## Changelog + +**3.4.1** + +* IE8 support restored. + +**3.4** + +* Updated: Update Google Plus icon to new geometric version. This also *retires* the "alt" version, so *please be mindful if you choose to update, make sure you use the `f206` glyph, not the `f218` glyph, as it no longer exists! +* New: Added helper rotation classes to the base CSS, thanks to geminorum. Apply `genericon-rotate-90` to rotate 90 degrees, -180, -270. Or `genericon-flip-horizontal` or -vertical. + +*Again, it is important if you choose to update to this version, make sure you're not using `genericon-googleplus-alt` or unicode character `f218`, as that has been retired! Use `genericon-googleplus` and glyph `f206` instead!* + +**3.3.1** + +Security Hardening: Remove Genericons example.html file. Please visit genericons.com instead. + +**3.3** + +The Open Source release. + +You can now build your own flavors of Genericons with all the SVGs provided. + + +**3.2** + +A number of new icons and a couple of quick updates. + +* New: Activity +* New: HTML anchor +* New: Bug +* New: Download +* New: Handset +* New: Microphone +* New: Minus +* New: Plus +* New: Move +* New: Rating stars, empty, half, full +* New: Shuffle +* New: video camera +* New: Spotify +* New: Twitch +* Update: Fixed geometry in Edit icon +* Update: Updated Foursquare icon +* IE8 bugfix, slipstreamed into this. + +Twitch and Spotify mark the last social icons that will be added to Genericons. +Future social icons will have to happen in a separate font. + +**3.1** + +Genericons is now generated using a commandline tool called FontCustom. This makes it far easier to add new icons to the font, but the switch means the download zip now has a different layout, fonts have different filenames, there's now no .otf font included (but the .ttf should suffice), and the font now has slightly different metrics. I've taken great care to ensure this new version should work as a drop-in replacement, but please be mindful and test carefully if you choose to upgrade. + +* Per feedback, the baked-in 16px width and height has been removed from the helper CSS. It wasn't really necessary (the glyph itself has these dimensions naturally), and it caused some headaches. +* Base64 encoding is now included by default in the helper CSS. This makes it drop-in easy to get Genericons working in Firefox even when using a CDN. +* Title attribute on website tool. +* New: Website. +* New: Ellipsis. +* New: Foursquare. +* New: X-post. +* New: Sitemap. +* New: Hierarchy. +* New: Paintbrush. +* Updated: Show and Hide icons were updated for clarity. + +**3.0.3** + +Bunch of updates mostly. + +* Two new icons, Dropbox and Fullscreen. +* Updates to all icons containing an exclamation mark. +* Updates to Image and Quote. +* Nicer "Share" icon. +* Bigger default Linkedin icon. + +**3.0.2** + +A slew of new stuff and updates. + +* Social icons: Skype, Digg, Reddit, Stumbleupon, Pocket. +* New generic icons: heart, lock and print. +* New editing icons: code, bold, italic, image +* New interaction icons: subscribe, unsubscribe, subscribed, reply all, reply, flag. +* The hyperlink icon has been updated to be clearer, chunkier. +* The "home" icon has been updated for style, size and clarity. +* The email icon has been updated for style and clarity, and to fit with the new subscribe icons. +* The document icon has been updated for style. +* The "pin" icon has been updated for style and clarity. +* The Twitter icon has been scaled down to fit with the other social icons. + +**3.0.1** + +Mostly maintenance. + +* Fixed an issue with the example page that showed an old "top" icon instead of the actual NEW "refresh" icon. +* Added inverse Google+ and Path. +* Replaced tabs with spaces in the helper CSS. +* Changed the Genericons.com copy/paste tool to serve span's instead of div's for casual icon insertion. It's being converted to "inline-block" anyway. + +**3.0** + +Mainly maintenance and a few new icons. + +* Fast forward, rewind, PollDaddy, Notice, Info, Help, Portfolio +* Updated the feed icon. It's a bit smaller now for consistency, the previous one was rather big. +* So, the previous version numbering, 2.09, wasn't very PHP version compare friendly. So from now on it'll be 3.0, 3.1 etc. Props Ipstenu. +* Genericons.com now has a mini release blog. +* The CSS has prettier formatting, props Konstantin Obenland. + +**2.09** + +Updated Facebook icon to new version. Updated Instagram logo to use new one-color version. Updated Google+ icon to use same radius as Instagram and Facebook. Added a bunch of new icons, cog, unapprove, cart, media player buttons, tablet, send to tablet. + +**2.06** + +Included Base64 encoded version. This is necessary for Genericons to work with CDNs in Firefox. Firefox blocks fonts linked from a different domain. A CDN (typically s.example.com) usually puts the font on a subdomain, and is hence blocked in Firefox. + +**2.05** + +Added a bunch of new icons, including upload to cloud, download to cloud, many more. + +**2.0** + +Initial public release diff --git a/backend/wp-content/themes/twentysixteen/genericons/genericons.css b/backend/wp-content/themes/twentysixteen/genericons/genericons.css new file mode 100644 index 0000000..87cf754 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/genericons/genericons.css @@ -0,0 +1,263 @@ +/** + + Genericons + +*/ + + +/* IE8 and below use EOT and allow cross-site embedding. + IE9 uses WOFF which is base64 encoded to allow cross-site embedding. + So unfortunately, IE9 will throw a console error, but it'll still work. + When the font is base64 encoded, cross-site embedding works in Firefox */ +@font-face { + font-family: "Genericons"; + src: url("./Genericons.eot"); + src: url("./Genericons.eot?") format("embedded-opentype"); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "Genericons"; + src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAADakAA0AAAAAVqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAA2iAAAABoAAAAcdeu6KE9TLzIAAAGgAAAARQAAAGBkLHXFY21hcAAAAogAAACWAAABsqlys6FjdnQgAAADIAAAAAQAAAAEAEQFEWdhc3AAADaAAAAACAAAAAj//wADZ2x5ZgAABFQAAC7AAABIkKrsSc5oZWFkAAABMAAAAC8AAAA2C2BCV2hoZWEAAAFgAAAAHQAAACQQuAgGaG10eAAAAegAAACfAAABOFjwU3Jsb2NhAAADJAAAATAAAAEwy4vdrm1heHAAAAGAAAAAIAAAACAA6QEZbmFtZQAAMxQAAAE5AAACN1KGf59wb3N0AAA0UAAAAjAAAAXo9iKXv3jaY2BkYGAAYqUtWvLx/DZfGbg5GEDgkmLVWhj9/ycDAwcbWJyDgQlEAQABJgkgAHjaY2BkYOBgAIIdHAz/fwLZbAyMDKiAFQBE7gLWAAAAAAEAAACXAOgAEAAAAAAAAgAAAAEAAQAAAEAALgAAAAB42mNgYf/MOIGBlYGB1Zh1JgMDoxyEZr7OkMYkxMDAxMDKzAADjAIMCBCQ5prC0MCg8FWcA8TdwQFVg6REgYERAPvTCMQAAAB42i1PsRXCUAg8SAprl7FN4QZqb2WZGRjAIVLrHj4be4ews7OJHAd54cMBd+Af7JHmt3RPYAOHAYFweFhmYE4jlj+uVb8nshCzd/qVeNUCLysG8lgwrojfSW/pcTK6o7rWX82En6HJwIEv+wbi28IwpndxRu/JaJGStHRDq5EB+OKCNumZLlSVl2TnOFVtl9nR5t7woR0QzVT+D7cKLeIAeNpjYGBgZoBgGQZGBhBYA+QxgvksDBOAtAIQsoDoj5yfOD9JflL7zPGF84vkF80vll88v0R+yfxS9lX8/3+wCoZPDJ8EPil8ZvjC8EXgi8IXgy8OXwK+JHwp+Mrw////x/wsfHx8HHxMvJo8Rjw6PGo8CjxSPCI8fDwc3PVQ2/ECRjYGuDJGJiDBhK4A4pXhDABtHClYAAAARAURAAAALAAsACwALABaAIQAzADyAQABHAFGAZQBzgIIArIDTAOkA+AEEgTCBRYFYgW+BjAGwgbkByQHSAeCB+AI2Ao4CowLGgvQDBwM6g08DX4Nug4kDkYOYg6ADsoO7A8yD4gP8hAwEGYQpBDuEUgRshHUEfYSQBJeEnoSlhLEEtwTIBNYE6oT6hQaFC4UShSQFJ4UtBTyFSAVjBW4FegV+hYUFiwWQBZWFmQWchaIFuYXFhdUF4gXyhgEGCwYThh8GNYZEhlCGVgZZhl8GZIZoBnQGhIaShp8GtIa6Br+GzAbVBt+G8Ib/Bw6HGgciBy8HOwdHh1WHXAdmB3eHvYfIB8uHzofSB9WH6of4CA4IMghACFCIcQh4CIGIjoiSCJ8IpYiyCLmIxAjWiPwJCQkSHja1Xx5YFTVvf/53nUm++zJJJnMkpkJJJkss5GFMIQ9w04IS0BZRSJLMIIo1l4XFETQFkVFBKwVrbuWpRaXPOtalZaCPKu1D2yf28NX21qfQubk9z3nzoSAS//+Mbn3nnvuuWc/n+/n+z3fCxHIaEKEJfJMIhKVhJ4GUtP8jCqRz+ufVuQ/NT8jChgkT4ssWmbRz6gK9DU/Ayw+bPKY/B6TZ7TgpuVwN71Unnnm0dHS24QQRSACUYis8XyzST6xEAch4LF5ZJsnKkc9NsDDj2ETXgUikT4iaClNJEBSGoZIP74qa+l//YRfKB5EAEyj4g/ztWBZbslcIEjucqHATOpjkYBXsYo18DNYeOQI3UMvonuOHIHXj+/YcXyHSs7FLGQp+o7sYA8IFq+BpmqKhtk6SDEZinWVWfMsHlLfIkRCgjdPsLpAtMlRUu8CmzVP8HlDEInJmkC+wcbihT54cN/6cePW79Mv/f1E+MUT2zvCM68cOWt7Rwc2pk8TNQ3IWW0gEbuI3yxI7KW9HdtnjbxyZrhj+xPbWX0EYhjcf9h3Jg9gldjBfhLm1af1ERF7BTAEmoxngQDeU35mB/YPsDiFtU0gxChgX2tn8S6FP3zG38O+zMWEVkU1yaYQRCMxt13WblvTT9bcdgpaTsnahlcqUp9owt0Vr2zYc+oUHwN8S2FjwMYV62PNA5+pPhaFc0EP4JhuPr2la4eQCVCsNRvnLac3A9nRNShIBFZPXpciEmHjareZsEbRWNTEBhVvHDasmyniwP7HJ+4AhlsgbmOP7PUsWVA8DFmHuzoSa3avSXR09XZ0HaZfHa7raOARKjm8kWoLdwfuamwHbcqaNVOo1t54V2D3QtA2nsQL1TYePrwRtMTaWUWYhvI0gGlYz5FeldWtgPiwvfW8bpVgAk/cwxqtR/hwhHxeVq9YWNG6duzo0miCHtBgy55TlN/jbYIHFGwyi6IJ6NVO7RG0c7c7ugBDRITMuMlYqovNAFYeuNg4BWPRSBCDBRhsEaKRQJCl5mOvSfmxpqbY3GQSCmYvXjy7s6bVP2WcjI/P4iEUxG7ddWt0brKrC5/P+Yz2fTans2bNjWMvPTwOi8B2Vhtw5pEr+cpyCWabVVAkVQngpGDFtChYcIsQCIYgT1ADQUUNifmQB7g4HIrN6pIdiponhCAYkoJDMd7ucEkOlxK32q02qxIMlAewtuYWQVwLdsg6+fyNbcufpfRunw+CruicxZMm1JYsV4zGfIuUV9+8OH7VzTdfFV80IpSVVZBvMErLS2rHT140JxrJtYfGjRjrFIyl3liplFNkNDlFY6nTmwuKwx0fu6gZfL67aOrZ5W03Pn/SQNiZfrXlIfr62RfrVXeh9JvpoxY4FUt5/eRFm2bsvTy/YvzFdSDK5jq/F8DrrzMpglAxtSFekt2zZ/rmRZPr/WYl1JmVJxdEq6VcX3GhoGY7zaAUuoZ5pNwhrqF5WabyKXVZhW4l/MJZaHhoC28cdiIDKkJ4nxqIiZQittSTBJlKiL8+LogKUe3+mDleLrvAjLhidsRIPBDMAda9LsERkxwCsETlccHiVXx2S4sUD1SBWyIIewRxjzDgk8iBw54n/0w3db0rjt/1ViE9TY/nNXaeue+KFT+Cxz4uSNCP6Bp5+biD/9dsLw0qj8DEq51nG1+if695Cb68Zevjbs19yW+VvZO2LB9yLT1Er4JdsAEsP/85/ZxupEvw+PznPweLNhWq4MY2evS13r0roL03FCq+m/5W2Jx4iP5u/dsQm1SrddTDuw0Xd7lKw+05HqUYSuGfM+nhE/bxIXBCrGAf3Sc0ultay6/9qXZB5lggL5R1FyAeVyEef0Aa8EZR7Qi4kuRz++3helzyOL0wgJfhOL8YXsXtkgNnaIsQrrc7YvE8UGOqllwpVM/Vnvo9pdvoEdpfVTXzgZ+MuPJ5n99dV/vjhyfPTs6uvwVu+TCrcfGm5OQt4R+tsLY3rFJquycX25Yff/vwfT0jH5QDY+vEbavV3KI3b5QrxfqfXbS445E3s4dUtm1a3Dg8XpRILPfm6vUlKD9UjQQH0MGHKG3xDEcZEXbEAz4UIKUIiyg0zwMI+hHk5dCPKlv3yZOWX/TT2VWUpqrYAxUR4SxB6HwNpN6c5jj8Iyt28drRp2lfqmFHl4xPOLZjufLHWK6b4YPIBAMrI9IiYU+Ugejl5YrSbpiQT1+lvX/+s6N6/EXXtsW7nE51/pKKiNMofU2P9h0SJ0ANCJEFs8bHShVRpB+Z/NVeUTASRJ9M2yyIzB6yhKzi2GA3s0HxeXFFF5hjgDMXFKjHuZsNdgtYYvEWMRphQGBA6AjXOwLlPq+kqPXh+tgIiNkVVVHBIiKOxBz2c3F+HGpVjJmjEbENVsDEL7aN7Nn38idXH6T7v9i27Qv6pzNv0x+PFQO3XC8JX/+j+y/gmypIBXkW1VFoBYdslvMkVZjcCMZV9NN7b6H9R8YXF/lX+Lw2S561qhb8T13bbs23WjdOCVzm82GkrVLwycO/OvSeqmHu+w9e/cnL+3pGbvsCJvLSU3mn6YYlUul9fTUhWREeSo30SHv7dkOOklNXNzZcGJoT9Qp+gzu7JL/Qlt3QAUu6Ox9YJQsilHlFWei7SzDBbFXwuiErE6lWVN68M9XQBT3vH2FzXSC3wj9Rlm4ldWQ4G0W73q8hITOh1ZARh5FBLM5+Me7xh20+my/qi4ajYeE9IZAbGLPkmh3T1723++JF9797+do3WncKVqO9oMjucpWblz66ZMmjS0d2j48VSXS/uE9nVJIWDE/fcc2SMYGLd7+3bu37uy+ePPEeyFVzDdmqURIXP/rbRxeXx8Y0Fb3Nk2M9RZ13Kc8jJzFjXTkjCTJxx4YX4R/FPkZF2FQHFYWyxxz02FoUfCbYhPn0ILQ9KExbumxGvL0KqjrkAnpoWkfluKG52fSQJMGEbJvbUxNuLZ++eVkDEPG/bl40oW1h9aS62kmhszsF8/Ir/WF3cSz1n+L187eaSnzFxZbs+GWPr2ZcKT0/Gct0k+ZBKzC91Bg/saCYDoEPiYTVjhG8moIa9dgLbCrWOs672mbSVyVbeCiGHfSbG0ZPg6mto6ZPGyk1PbSpftowbwH9GgAMhixvg3fMyMwy1ZfkGSIW9X0sbpzS2DxpclPjlL4N8NqTB4sqg4XdHtpz4CAcrrQ5h5Re3E5nY2c+isJhGsqFqazGLkkf9kBQwJURDMQtbALEWKWsrD/ZGsFVEULemYdJkQSpeewvyOeJLNWt++MT2xZEqmdctePgksVPeicUeOffqZb+TMqzb71kxuxAc57j6iVrn1005obXfzT/0ZtXTQjOMKuqaBVUn33munj5xBV3/fIvBhJftGnvgfkbPnxx18rm+Qn6wbAN22MPXy08ZfQsj9x6+LLp4e3/0bD49l9B3cFLn76uLTSt+6a7p965yOYszJmSVWgy+u54rnvS7nu3rp9Vr+N4RvYtzvCJAiFPwGYGY3ELn8/AGiXqjbI77AgbEI8Fgmk0x6nD2CRS7TinOWxuYboywE5yBMiFXCIt5+/YliwZX7J12lW/u31a0+W73u5Zd3T3tVOGdC0zl8iCSZDlvNHjtN41Sx/oGjZ1x0XRdn9Odp1r3KjY3GiBwbjG4pAP0NO7BjMH+hn9iuU/dP1icEaTlx0G8c7Ox+9YnYhfdM3td7bdcmyoIc9iSGRZbaYpVy185uZpzctvm7n96zujndGaXVcObZ01+upk5TSLhfpnLNo8BRyw7sgAQRDIXmGBukDei4srn/PeAuS2BeXpq2yF2V9+SR/+MnVFOiDvZecv03d41eUlUW9Xc4gXbyQR+bkP0TuIkwWpYhx/FrPDjCITQxhlVjaAtSAHlaGfpu5bsco7bZ71qvaN1z0152hdxNo8YdiabkPBpsSYG1VioA/SFB1Oh0AZ3HYtlLWvuKLnboOV/p7+agr9+1NPzbu7FB5nbcjoT/mIDd9af0ZBIag27OnjZ+CanoKsl/J7Ac99nL0SgHeJplTgWvbqWgUqEw47kw9xEwoHnDaMeEZNvihvVFwaBb+gs0wF1c0TN93cM3/+ig0XXzSqNfJqVzIZqjapGm2iH9PIrqoqZ/ls+lHMbi8ra2i8boOwNuVLJObO2cKm52D8cJBqjsEX1J+4lQK7O1aANeKr0c05B9bNHkb2b8J5WQlepRSs9iaojw2GELGMvnSKqVBIzf/XvPk0/ez0ZjP932RUJtFkMqqlT+ejCCWn9Lf6TolkbCMqSKg7NY1JsVekA5l3knxp9QOooPSTbeSnZAe5h9xH7icPkoeZNodNsNUq7M+q1KHOoNQpqpWdFBsDFOxOJR9A8QahtgYCwdpANKB3byAYCfIVGIhiZAS7IFobi8bqIqzPo/VxftV/I6A2DrF6B9Ta62rtYbtj4GdjRy37szqsdXYwyXEjOPyyLQ4mv+qPB1UjBGV/VFVx1Pk/Af+E9BkvqVZThSnVCiLgdBZZrADn/RNgIDGKVuEFTC68AAIM5JHOCDArcH2cujJ19mNwpV59EO6kH34sjPv000+hUpA/ph8KjQ9K/5AlWi2oAkjsHVaowIpM54D5A63OzoFjLPt0TUX+HC+AL+GLEhyTZAFkEPCWHew1ngE7H8vOptXpFop6jqwMlgzfgCn07Rd3wmz68M4X9/5pVeoFiLx47+Rdu3ZhaPbOF+//06rz56oF5dwL5GM2V5GJFaCO5uaqVQsSYVTXBJQPDrsUV9I8AjEVgXUEMEzFFKiHWTgDUxiRRmStjdQhVQuUsyj+aoyBcAgUPUI4B8whIRjggocnY1Qcc2MP2T0TSiIqi0GO1w6XiLfsjfStAPXlOINQiAVZlojhEpYZDJjjMYyPK5KCcG+2SxI5yJgfI2T0Dkb8OAc8tpueWLlyidW075r14N4wIbn6rTtmlSdC2KNGEUb+/OVlD4Brodt/KX3/dnHo0I4tV6xrn7vgyWuT2V3tl9AvV14xvCXLsHPlqv9qanEkQxs3RTsstnBBVbS0am4gEDEYzEUFlfXFzki1udghK5VlFTWh8bmohxlt9jGBwFirTTYbi70V9spOj9cvCh0bW8Mza3Js5qmXrBtWPjJsKjaaHRsebp91+0y64TRsuqRp1o43eibdsNAZG9/TTQ899BD9dFxb7qzZUP2MyXwv/fSNdde9DyGdd+rNZLQzzUDvMqxdfRn945139E8Yn9dgm739re6xm9bWY1uzBEiuaLp1Q7j62jtTWaNuGtYz1FfiTV775ALhshdbJlmbWpZfds3637g80+d3fpgMV1uDwxcsnFlcWaZm5zkc44YMbfc4PBZByHGai9v8/haTXYFhlQKUTSh1eQSo9Pnag1aP0yIZi8rcc2pHXhYy5Yy5aHU00l5tsOfVDC+Pb2ieclU0P2flA303f/3WTTeuPXrvZVb3yq3T7qJPrN/QXer8rz27YOU99/7BJQk5t7xL/7x7H/3D+9f//8R1mT73Y3W4ej25BG9cuAjy5BAqSKY8A858HnIJsTiKJ5eI+ngspPiC3kAeJgOXWAZqSMLF0iK6RIe8Wy2aMGb26CZnXlnlitVXdl86K2E2I+waTFa3P1IaWdU+xmzxjB41rACGKdbEiNmTpo+oyxLKW6Z3zpsx0mKRCsKR5NgZ48aXFBeJJmeR0XhKdTQOKc0eP2rMww899bO7N8xzqkPEnKH1M+ffsO3QojmbZ8Qtcm6uqtD/EVS7w+3yuUqzzUKRKycXCr2VeeXV4jOpjwQ5W5It1aMuGzPx+s62Km++ASFJyS+sCCerqxdMm9hYlZP9htG9fNWD9786b/LlTW4hr6QoKz2GiEFXIAYNIddh79hVbgwNMqiRUCwy5iaivseUAtlmBWapCgz+YRqmD9rTgn3gORITJpusg2SINS3zB57bMnQgpo4Mw6QbDiy5auWUiZe//yukq6ZRdZ3r75y69cq2sYteeHB7z4wqekmT1ze8qX368g6Xu9xtKYjEOxdVDvWUOIpqIj5vkXPYsBkzu7ctXzGsIR7tnL1xXsswr6el9dLJ1aFCp8NWUlYV8/pikVlXHrxnVbfYuuzyJQdumNSYN3zFrmff62mfefnGqXeu76xL5lTN6Nn+4AuL5tPftl86e3hzRbDY6bAYjeZ8zCPkLXe7W0I2e3l5dai+FqmIMzhkQtuCS0a3BgMlVrPJ46ofMbTKbvN4orWFRagDJSdNrBkRCnH+jKyIKMzuGGESHXFX1wbwrFQiS+EcJSRUgomjOO94Zp1Gwe6ptyuaPVhkZ0cymmCsgSZGXjFu7lCtt27VwgSoiACeOWMLDAbYG01KpLiu3OAJ6mdM3ZWsqK0QtIvu/3qzbKr2lLTvnD5zrz+Q1Cn927BVDas93KIVJLVkBBmPesxmrGUMq6UPWwSJAY4VYC3TWqK9nKkzCrvzxzidV+0oE1iQWwesdgmsjhgzlyjEqzCzbsRi1e0/gBKO866MXoTpLCimHHILYgXrCtQSgn7R7mD3LpBezx/qyu949nBHvmto/rDbfkL/1hoKjRwZCrXC6HmtrfNaBU9lw5DqshmpLY+C75FH6AePPkY/eOQR8KU+rKiZWVo1pFGuxoEYUb1vWCjvilfoF/QE/eKVtQWllUXrZtTNKDn03/Nks9kGDYXT69qWL2+rmVIn0jOT/vxkycz62LyYaMh3VeZ3dORXuvKHgRJqxeJbW/VzKDS8rHZIQ3B4alnXgctWHOzqOnjiYJdwb03JxOHlDUJ7qCVUnUg9Fe8srq9b+uzGKVM2/mop6n/hkb4Z66oDC43whj07Rx4/pG75HcurJ4Wa6bU5CypCsXlsfSK/Znq6RnwkjuPBjDBM7RX5loUwHDw23VzOu81hU2VPRscKRh1x/aE0ze63e2sA5t03f4w2LwZqzega+bUtW16X7kMaoc7bPX/+7nmw/D6Mlo7Os/ttIS8tm3vPnGjnj0YfPeKpqfHAx5uef3HTZdU/Ptq5a+6cnZ1/qA0dZ/FEryPbP8B5nU/KM3ybb+Lo+jrbxkF+yPZyHBB3IamOOxRkxpn9GyTW7wWSXX76Hn3P35UMwHLZ1DC6wSSr3Kx+VN/iOcrs6Kl9LAF9H/z8hR1Sqc9XKhHdrvUCcqnWgT0WByFG0WTMiduMEHUIt8Ga1Od0O6wULBTDggVWpv4u5NPtqc9hDb0dLt+d+iL1xW61lb5FD0F56lnw0V/RtyAC4+kH9CFxL/0TTIDI2W/o28t66EvQ0rOMt10ghCpzsO0uMoa3XRUFNU9iKoQKeaBrOEwcMr6F65vtb8TNyLCYcqGzMKaZcMuiBxVo+dXZjdbIHFlWrEU1rjMGWaVX5g11Z1vL8suaK4RTXtlpSa2ylcr/dFpLyz6wFouCS5RcFvr3Yp+vGEZk2wtUsmgRpbTFarVV2MyCgTYU5IqyWlkh2xxVVSV09S/tZW5zn0GRcZ4U5jnzDLtyrT5vcbDYk2PhOMX2R9h+0GDtb9BmCPnezY/0bgfHOgFnLd9TYnsdqPw5PDaPGBZ6xd5+wjRETJ7i8jylIRPW+klmLmHJCmPHOdwqZYTMRqCESyFFKBHf7GKApmAwRdg+U5Ldk8weC5+HZcSftmtm2DQza+q7f4hNeCdZTKhsmcQ6cIH8XHf3c/Qs/ZCefX716ufhjrXv3NvZee87a3fRr3buhKw/wdBO+rRKVj+vJ2LJkefji8+fXd2588RnJ3Z27qRf0dcxuUToXPqfnTAV3tPnB9aJ8L1IE957GY7arSLrVQ/rTKmL72ZqTGs+tUfS+B4m/ezUnn7siD2nCBncrmxSTKp0W53JEw3b8LAw45c+rbj+mh4vNlQ+VlhYRqFzBg9NwM5ORvu4xiniOdXrRKYcSODZqWhn2RLStLOYjCVIsbNwIOCkhD2HXkx5fl1cZChpxLrUoqasioxHxS16iZ4mqK0PowJRAnU/VFUJy1JC4RJ1xRO8DMK0KYebmya/s8bSb0AwqFij4pxQETyNVRLcDtTnDn9X5QnJGajr4H3rYpwblaQJZdwohqdhm5g+MmFPOowc1Wb6oZ7OvHtuO5vVmF+/pwGU6GnYM37Q9DVzFsh3NQWi+qY5Xx8zYaZ6tXo1tseNCAcOQB2tRYA4qAFvPt+jUyFurx+BsAt/Fsrmpk6VNzUGvTnWYcLX+4WyA/6uwIFCs7lwf+rkgQCG/cIwnspfU5pnDIWnS88dSJ3c7/cfKGptLTwglGHwoL9rYG1ynC8gJdh3KqCUZjv15W7JjOyOIM9HBEMJhdhHNGq6+9n0+oFhkLVzdd/q9Ue+PLKenQAb/LfVmSe4dHY9eze8mX64fv2AfTpdFm/pBcWRdFGoXtgtUY9NNsHfvlVmauxAngZBE1dT07fKpd+cq5VhsG2cr7cSUsFtVza2FeOJMjj6gXqIOIw4UGzpCv+mOkomIb6S+jf14vKNQKWBKO+QXKxTKaJbNdv/Z9AWNEIMqyIagXe8EZi2FUNVI8aNjgLnXYifMpyl8hL6JfKeL5dSBc4shRwYCjl+WEu3Tnrl3Zcn0lvh8kmvrFjxypQUYWauU/SlhRxbZXyTypf09CyDM3BmWU9PXyVcAT2TZ0yfTG+lW/EKL+3RXzglRDk6n1dn5ofh46uOgDcIjDWyuiOtjDNLeByCFgcE46whqEtk8N7PmSM2KK7zTYkUeWC/ckoAWMBbcucvdm2/qH3FK0lY+8fQdWfJdRpt5M268//eSG3h1YC3u257eAVvWsuaEaf2rEDIgf2eoj2nhJN0L2vTlO3e6ZPhinfhQ54DvMoauDf1Fm/4V13LeRNfWrNgJQdjEBho6b4S2P/M7IX1MwIKo15IaLSX9mqQ4CdIyBfcayxNen+R29HPz8NA+nrFhNbX29eriQl+EhPqBfcaS8PmqJaWKxbEsyjzcLFVGqJ+ziLsKutBhlWIVHJ4wPgZPveTiQ44mo49ySgg0DCB4OxPA76mg4+eQuGJEYoOIOjiX2+KqyACXjMH5w1QirxhBzGy9WrBP5CLQSW0/BD1U/8hWi5M3L9f+jE9mPoUJtL9ggPaQHCkPmXYovMFDbs2i692BN4gMxqj1Ne0PqKJuGAUBpiUGahTvdBLE+f4MeMLRu6TZAT8M3kYi0jhT8TfGQxzF5pedmJVJRLvv16lF98zkDzGdIwCW90OHIoaQfXjfMQ+6u3TaELUUo8vEGak9moLEgs0mIThBQqW3qdBL7acPetbwJ/lskdp/oS5syE2Ztx8VOQ5jPYgDCVS/E1WFegdjDc5uLY5g+a+Gp6IUO4z1aMYcwLeZEGgCnxmphyhmAWi7zm09ZMjdPfvj8I2mAYlr67qJ/Me/Jx+TA880b23G//kjLvE72HREZGsepX+lT5JLz/6BCSh6PMH5/VpPB2X7f3fADEo6ovYG07uo+JCecJ1UlyiLcgsBpZmMXgs6luVeZErZnxzunVZs8PhE76u7L68u5L+H193f4zQj8LC3LHa/LgvMbNrmPTO2AkTxp45ylcVRNmeAQ5MZp/BhtgQ1nkNQwXUXeJc3+RIhqCG6Oth0GB3sMYH1ZAgcBqleJnHFv1tkv7mpVkPbm0E1AoC0S2TmIMOHqi+JmH4S9d/MofFg2/G4i95YyWcSo8dD7U3AWoT/tjwU0IZ28h47PiSOSwCyutLaS3vPd3fivsxVWa8mPLAyzg9Liu7m7sz+bwDTkt8rXGazJ2XOIJrLLRmytRuXDcauzLXpZR2NcP2qxk2MD8lQZuypntqmmy9TJvZnUA2snUBP1HY3Mgjhbp/HIKnyrA+GjGjClHAii+wi+VccsyZSpfT5VPn7IR9Nz733I2Ys0qYNFl7DB/AXVOPrd0FWSnnc2B4jjlTMTxbwPBMPsmWEJIJH8QdMucl9KR2Uj65IEVgr9aLY4Vz1EAGuBQpwsFi48WuBvI10Q82k3GZ4pHionAQZ7CQIZhHEFd1HrMLO0w4iKwJzALi8JjKcIJxDwMTTn34y18E7ZOa0f4/PnTz6UcXrZc3DVs69i8pzfLO+KlLnljF4pRSvP8k1L1xzNP0b1X0jH3zqyDeugvsdPKlrz48Dt+3vDP215euPbKtFBR8SFNMJxGxrZLGW8OWpcb87tL1ZPjDOoG1j89EfzrFWVRP+vC9PsKd3RjSzBASBtZnKtczy9gq5/wgfQGHlN7vM6fXizCM/gu2a9QCa6UH04HuvlE4Mdgw/H33mjW718j30zLEJyLsSZ3Sry0L2VOcPvTwGpbkPG6icj7L8IW7kg1emTL3HUNVCa+QPLceEYnTsSJ3IBu8GAnLisuUdN4ZphzXmTJJ4475gqs/7f2pM2Vd/Mhc8Hi4EEK1Ecmzz8TSCPu48Bj8B2nnRuZHmRFDNKGrA/ycwMqx5zgI/A3QX6T6ZZ9OjCVOm5lE0nM9yzVK5oTKCB0j4kRlumgJ12d1cRiJNUHajsVtTNw+OWizT1UPb2xdVxV67vI9pwolwvWyHWWejYfD1Us3nNrT0srXpqaCKqf9Ye1Wxr+DbGEEA5ERbCdNRFquHEwmP207mqQN9CS8Bm1tnyaPt83e20/2yruSx/ARjKcN4GaPjuNdW2rHXiAMkIHJLpnRKPVc/4t6RWS9Qtym+Af5f+UnuKwRsPCoByQCn1PLLJjFXFTpL+THqYVaOmCWBrO4HRIX2B8UTX8H1zySWyS1EplFf8G8UGHWLGqRH++gv8B3O+BzrssnFFYPxuiYgASEiFRvCllNr8xksYDUJsHTMSxJsHRYFyMm41YCIYE/jQlsDKZ6B3wJRKwe88bEGSxyd9o+Pg8BVyhWTX+Gc5st0syzNE+QNe6STIwiq7zGSBmbAWeJoDsecx5fwG5kTfm2/ucjQZzZNShz4lwTJBl9jx3xsM03+D48SB/8vnthgEylMqE+7cLAgAN0xgP6e0K8awRuB+G2DFbnb+1iZ5CF4ZisG2T4WbeNMEMJs5718TiJObNo6dUu4qM0jvD8GX4FLsg/zASuzRcdVI4YZYownCtKYxlpmQI5K2NWwEyZqOExxfhcwQeYituv2xAydnCGM8U6FjN5Lqev4LEKCiOAIRBEfIc3iF/6cJBv+vQn/eQnn96kcODglnD9mnrzbvqvX5bSf0Ju6S8hm9FEoq97Ja3FMXxOAwBDq8Eg4IIBFJCwesz1FnDe8NZi43SHX0U5vLGqfVypDgoCVk3HLmBmGyZH8OJ2bzzsqHSlMeIc9pQPYI9ej+8rPe1JSDJ10If1/JI5HOnQ+R1lCtxfn/EqI7fgmdjWlkfl8hqBGDECFy3zLmf6JzNHpN6bKwToXIGNEMV1xy1yKMD38Qfn2bDymZgo5c4cePJFue86MKjFNP2MZbNhuUpNsdXI8gaUm/q6TY+5iY84kxBNyGrTs5nVLRCJc41F4apFIjN1+4hYX1/fd4TZo9hU0vT5fBZLi/80zjRNAdFyj7pAXUCq+M6K6ldUixpkRDFoCQTlINMf48G4HIuLcQeictwh2h1+h2rHseaT216vLmikv6tptm95Y4Sz5Y0ttqZa+rvGTwyGTxqhrrbJtuWNkdaRb9xqb6qFOhZNN3H4FU7fam+uOZdSzyA3O4E5NNfoST/RM771dcy4jGM3ucDGYEV9/rwvH4Ab+VWI+fnOaRyUC7+BkOo3n96yaYNweHwf4aHUmPHf+iAidWTL6c3jU2M2bGJX4fCGb/GH4nNypTyjVyCgstXPlrusc4eUfmEsCGGYsEkj4ezRY/XF/SaTwWx1n5srOo8y6SyRxWZEvUx0qGbceoBz8ZTsyxH965GBbxIyOK+7D4n48AwrnmTwftD+QyYtkiELm576dyB6iSkuIAa+nyCDvp/A0tLfT4jAHbwN34u5ZBDm6kbwNNalQRc7x4AAeEZfsXj+OgO6vKoixyOWv4LaFcNcjqnG84rxpH+DihPS4CoMFAm82rj0M0XzL1Gw/0UtUzy+hO1mrR+oxoXzznLhvJMym3TI1zy2MDK3C+edsExH+720V9v7rQlXz4vpSzJooWk5dl55ju/+wodx1m995ZMazFsvKOjskfP0yPPKCH93GfrONa4qB9+uZkDLfqUQjnIPqO8pH170t7ffsf/n825aUlHkLCyKjC52vmUyj5n+fXUSGhqndSdGXrR/XEFBia+k2Du0umpkg7fUaquOpH3hdZ1Xn9Xsp+K8YYYKjrknqRuHzQ0nL0jLEhpZ2hSOvESYwZ6lZcyHupk9I2MHYUzHTOz4RhgVg7AFj6DPb0HNLlzMggqjGimWeQe00/85UamlPuvgtkitYwTeybwu3I7JE6bDvO7/xPrkKtvYTgbTQFsEexnEW8CF0horv35CU/DGZ1+YcP/9E1741caK5gk4ZZeO+c1r97YMHXP33WOGttz7+ktj2Jwgl8BJdafixhWsfw3F7F8iqBbRwQzaQeGyE/Qo1Jw4Kh09cfToCag52/U1kK/lhm3IoRu2QQO8to2+Rl/bBq/RshaJtDCdjOunaTtQEdv9MQpRFLSoxX3LgTjKtTREubBJNxIpiCqsnX0oqges7lEm33UTrcxhhFnz8IRU9lwKbtMfMPp+ux6lP1wP2w+Xn/p3JWvkO8os+4EyLSj+g+oPldoHL8+lOw50/lDJOH1e7mSJGIqm56iMcgzLNRkF5rRgCqIIY/Y0k8CtngyARYJyaEfbc0v6OR7LCWYdpb18CrMPyujxHW0Tqabfp/0ldFzP4z7Vg3OVL8iLfMf752wPIuuTjCzycgdl0Weq5w4WHD0kPsnHrk4mV48dt6Il3ODzNYRbVozjMcB7SsaVxzRSdogDoUEYx/lRNrPSQBrEeYnMv9kT5Fv1wC0jDLgljS2shmHdKdLtDxcxNS/FxaPE51EfSW6Nr1lTPvfiem0wd+K2hguHlDkEurFzZE+Uf1qncEW4j583nwb76c1slxR5h3TeGGq6J6rG6SbTNwQiz8I2FBAn99f1cJRUVBt3QfF5mCmOQWglFOlBH8qkZV+uXr1w6sqFf/0NnQbk+iVz6uouXbt96YK3FG3smHuW3ZinFt20+r6nhV8NH9daWkpb6PFJU28jaTs6kTP7wz4xrHriYYsv7pFna19oFTRRwS6oXnKFikvOtM1b49wim2EQ6+eMYwmYgswRk7MLOJCWxzhxe/s5Vko6Xel7U0j0phaAm00QI/ezZv3KeIOR5HB/ZxuOIMp+i8ljYR8asNk2BEC3DKt+I6BKr+nKDWjf8DHTzS2gm5i1bzROhPFeThNjiqVnDC9shEHjLErjagYztmnny0kz+Y/zZZgjqKgjuLtlMF4j5EONMEJ1jIAyCNRAvhQcAY54cIQQCKoO/MsXWSK8RVkXR3jmCeP5QhnGYaAM8iGuloEazzcEK/HGEccMJYdaIyvMXdNRI48QkDiPEPBtScWkIuboyMdZd6GIzBPFLNnkEsjLkGhT8n1FhcMiFUEAWXbkWnL9geJRzsJch5xX6nCGC8XcGkOhrSJ/Yo9k9Ug2Q/OkZqUgJ2R3j3FdtuidJwO1bl+NSynJrk2Wx3ODxV6Lx2MszbYmY0PlvOxQgbMsz+fMcjsNhaFgnVLamD8kWIUKowEMcpYMTtc1726SsrJHubPUPIMh35rbHBTyLaPrvEaDx1BTWyY4Suoryk2CRxr6LcH9L0mxIMPum/zHp7LCRQaLTSyNueOq2ZdndfogS/VnNcdkVbD7so0VTtHuNNqz1ycFk5wlGLN8pc0em9VkMIH/ZsgxGBTVLDrkItvQfHOJN+AwmbPiVos9x1SgWixyvsliLXQ2O2srKt2uSqfRPKW2oNWUZcpxlIcWz/gJ7X+mPOeWEa3DSgqiLXK2Uc01Fxepdq9FrjMWZEuWxpGjyzplh8mpcBm6V3SrC6SMDfJbPH6Az/t+fcMNv75BFAdfpJM38Ougv7SfJLO79DJUxzlvIF9rYq84YK/BGwNbKyRqArEXUb8vwd6REnwvC+ORa/BYA+lLcDtOIr3PJXD+wqL1PAfbACpILRmmf6+sey4hJ/Po3y2nv5YxIWOLDYd0VHl6wUtpYodI08i/Ru4njWOZLtwYuPqmrh083KfvRQrJtMPI2LXeB5jc6NIkn3fdGIZ8oY5WB7WP29H1gHftWIyw87QHMoRZGdAtzv/2PS1LMps7me+4gejSpI8wBV5EAU55jMhAgmlOeFCSCQHnYXqY41ucY4BGcvX9EKOIOjEEWyS+Y+rzBiEaDCj5oDBfLodubiyDcyYaAp9igf/0+8EP3MtP/G0M2xGjBxPOTv9Ef5c/X9Dy/RjKdya0p6KBQNSvatSBtDPX3xWAclG2jZu+8QyNTkx2xaBNSzjzMbH+VheGOp2J1L/wJX+UkMHfEo4mE0k7mUeW8D2jtE9gC8SZU6DHNBDDfGzZ8A6KiHLlf2C0mdUHrxlQH/D8ueCqDgx1Mpoe9rGN/Sjx0kG2m5MOMiealD4N+tJq2vmX+fq484nwAJKqD9L3Y9Z5wZeMPpCeJ3j7wJ5TkJk2OJPoB6f2pMXKmeQgZTiZmTsC9skpNaH08v00ou/Lh42CiGzXwbZHM2tWfsS3plXMFmh3v84k6fH/Hsc9A/Cnb0TJPdEWoe+kwGcPqoOzerYxkxi7F36W3sETYBWuqZ/imvLwvRYH9w6Iu8BhYh7XgzrZFrb5TC2Q6WaZ3rGMPkCX0AeW3TH2lR5NS/edpvW8Qn+kd9OROY/+9s1H5rRdYoF/aQ+c64UHNJptWSqm0o0W0nOCkMk4H3SLVyX75tdcCqytwyESZFt85UFlIMIcDwR9ujUsEg+YeC3xoUtwtwjML47dFah2m98bCOreoI48QeWbBG/neucuCkQC18+lX+28h/5rzg14s3iOJ+9t9rS39D68XfrY5yB9/thSDO4qSWk7U8Pn/mNT5+M/aarY8mu+qTCybRnt38rzS5x49MpbNl/52HH9bivAsgmtmGTqgiMg6HHXY1aY5fX6He0/0tmh/WLzwpXhzsTcWyZnbF3aoL1swZNGC1nTTXps3TOeInHGwMaQMgSAAQ7AuI09bPJWAclCLcHqUO3EIb9+371H6eX0SfrXV1cJpOv5S6D+sBgOU7LqVSiBabDt6Ocnnn+a/m06r8OrOBca+f8FUcr9zjhX5CTaGg8rAjOvBoRg2AXumDR1z5o1UyJzws/2Wr98up88/aW11/EOFB8XtTVTBDJlTXhOhJKpBYfoF0PoF1AwBAoObT50KO3TLGJLB++pySS9p3buO2pHxoLDDZ+mwWE13SeDzpxAZc6MOn1XPKTfy+gJvL+zM9+Z6T/mLsDwltnSGbHWQ6y/+TduhNfNyHbRQPTIoh//PCIKMe654JHIOroVqtahHh25Eqro1nXHhMdT77yTOpE68U7qHeFx+WN6zx/onvffh4V/EFENodekboRb6DrhGrgx8917poyMP4SnGFCFH5TJsWOo7g96Mb0ZN7h++YPfFnklL8zjWKaK386MVrD6wbK07x7X1ezI8CuZ/cmIs4vtZnOc9nBvczbv1EAQYZk9hfq43cFs1gof036udnWxweCBueOHzLphj77r20f0O8q4MQcyLpaBpP/TkKZrF3Xq8ZSH4cLv9arJBLLoO7029Z3hgId9i8x2j+3hWJhv3NnjulJSnv5M2Wp31PNHkqPebhl4xp+EM0/s4njohol/27r1b3Q/vZ3uZyGxy+LKN+bn/Z3+NXb1xNEmk6nI6cz95SU//uKiXK2kPLiJPvPIuFunjA6HyhSn0vPLn0OgK8epuWrCd9Dr3+l7JBEO5Lvlx359GGZfXaRqg7OGiby4s8vykRcX5qlbTWaTIbvYbHPlOpsacj6qcTVYJ8/GEk3NJZGs3GDbqFxwRvxh57xZYduYQDg3MCWZc15fidybtIjNdh//TwL4ZrzoyzARWxxn7y6hZFffxcpwWk3v/+yvlChLzpyFiz+Fx+THaDUcYwccP/s8HcUIiPR6apQ45+yOY8c4DqVtSen95cHaJhPPusJznmcmV3XYyuQx/Pz/AAfdhq542o2QsWrDMBCGfyVOSjOUDn4AdSlJiY1sMCTZ0hQHQqcM6RyMahsSKVj2EChd+wgd+wZ9s7xDz4pKl0IrkO7T3a+73wZwhU8wnNcNHhwzDPDiuIMLvDvu4hYnxx4G7M5xD9fsyXGf8q+kZN4l3e7tq5YZfDw77tDcN8ddPOLDsQef+Y574Cxx3Kd8gQU0DjiiQokcBWpwDJFhRDGGQIQEY+IV6SQU0RwGezR0GpvBQh+OVZkXNR9mIx6LKBnzlZaKz82+MUaSZGmV0k7JqJOit1hKJasy04p4TcWcmu6wJRHWMm92W4LUimsbK1JIayskYxwz2r81PlciTBBgSvv7M5BqVae6yiWPQ8Fn/McAXaJJMA1a8/9wu7FFQ2Vtf4mwE0IbW2fYyMqUWnEholAIwf/u+QXtVlqxAAAAeNpt0meTFVUUheH7DhkJEgQJgpIFhdvn7NM9gxKGCZKzKGZyUHJGySAgSq7i5wrFfYdPdFXX+tRP9V61Wl2tt8//rdbh1vueV29eWl2tYXQxjOGMYCSjGM0YxvIB4xjPBCbyIZOYzBSm8hHTmM7HzGAms5jNJ8xhLp/yGfOYzwIWsojFLOFzlrKML/iS5aygTUUiExRqGrrpYSVf8TWrWM0a1tLLOvroZ4BBvmE9G9jIJjazha1sYzs72MkudvMte/iO79nLD/zIT/zML/zKb+xjPwc4yCEOc4SjHOM4v/MHJzjJKU5zhrOc4zwXuMglLnOFq/zJX1zjOje4yS1uc4e73ONv7vOAh/zDI/7lPx7zhKc84zkveDnqwsljg1W7bVZmMrMZZjFrszG7zZ63mfSSXtJLekkv6SW9pJf00pBX6VV6lV6lV+lVepVepVfpVXpJL+klvaSX9JJe6njZu7J3Ze/K3pW9K3tXbg9915id/wid0Amd0Amd0Amd0Il3TueesJ+wn7CfsJ+wn7CfsJ+wn7CfsJ+wn7CfsJ+wn7CfsJ+wn0h6SS/pZb2sl/WyXtbLelkv62W9rBd6oRd6oRd6oRd6oRd6oVf0il7RK3pFr+gVvaJX9IperVfr1Xq1Xq1X69V6tV6tV+s1eo1eo9foNXqNXtPxijsr7qy4s+LOijsr7qy0h75rzG6zx+w115l9Zr85YA520l0Wd1ncZXGXxV0Wd1ncZama1x+EcTsAAAAB//8AAnjaY2BgYGQAgosrjpwF0ZcUq9bCaABTzgdAAAA=") format("woff"), + url("./Genericons.ttf") format("truetype"), + url("./Genericons.svg#Genericons") format("svg"); + font-weight: normal; + font-style: normal; +} + +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: "Genericons"; + src: url("./Genericons.svg#Genericons") format("svg"); + } +} + + +/** + * All Genericons + */ + +.genericon { + font-size: 16px; + vertical-align: top; + text-align: center; + -moz-transition: color .1s ease-in 0; + -webkit-transition: color .1s ease-in 0; + display: inline-block; + font-family: "Genericons"; + font-style: normal; + font-weight: normal; + font-variant: normal; + line-height: 1; + text-decoration: inherit; + text-transform: none; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + speak: none; +} + + +/** + * Helper classes + */ + +.genericon-rotate-90 { + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + transform: rotate(90deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); +} + +.genericon-rotate-180 { + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -ms-transform: rotate(180deg); + -o-transform: rotate(180deg); + transform: rotate(180deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); +} + +.genericon-rotate-270 { + -webkit-transform: rotate(270deg); + -moz-transform: rotate(270deg); + -ms-transform: rotate(270deg); + -o-transform: rotate(270deg); + transform: rotate(270deg); + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); +} + +.genericon-flip-horizontal { + -webkit-transform: scale(-1, 1); + -moz-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + -o-transform: scale(-1, 1); + transform: scale(-1, 1); +} + +.genericon-flip-vertical { + -webkit-transform: scale(1, -1); + -moz-transform: scale(1, -1); + -ms-transform: scale(1, -1); + -o-transform: scale(1, -1); + transform: scale(1, -1); +} + + +/** + * Individual icons + */ + +.genericon-404:before { content: "\f423"; } +.genericon-activity:before { content: "\f508"; } +.genericon-anchor:before { content: "\f509"; } +.genericon-aside:before { content: "\f101"; } +.genericon-attachment:before { content: "\f416"; } +.genericon-audio:before { content: "\f109"; } +.genericon-bold:before { content: "\f471"; } +.genericon-book:before { content: "\f444"; } +.genericon-bug:before { content: "\f50a"; } +.genericon-cart:before { content: "\f447"; } +.genericon-category:before { content: "\f301"; } +.genericon-chat:before { content: "\f108"; } +.genericon-checkmark:before { content: "\f418"; } +.genericon-close:before { content: "\f405"; } +.genericon-close-alt:before { content: "\f406"; } +.genericon-cloud:before { content: "\f426"; } +.genericon-cloud-download:before { content: "\f440"; } +.genericon-cloud-upload:before { content: "\f441"; } +.genericon-code:before { content: "\f462"; } +.genericon-codepen:before { content: "\f216"; } +.genericon-cog:before { content: "\f445"; } +.genericon-collapse:before { content: "\f432"; } +.genericon-comment:before { content: "\f300"; } +.genericon-day:before { content: "\f305"; } +.genericon-digg:before { content: "\f221"; } +.genericon-document:before { content: "\f443"; } +.genericon-dot:before { content: "\f428"; } +.genericon-downarrow:before { content: "\f502"; } +.genericon-download:before { content: "\f50b"; } +.genericon-draggable:before { content: "\f436"; } +.genericon-dribbble:before { content: "\f201"; } +.genericon-dropbox:before { content: "\f225"; } +.genericon-dropdown:before { content: "\f433"; } +.genericon-dropdown-left:before { content: "\f434"; } +.genericon-edit:before { content: "\f411"; } +.genericon-ellipsis:before { content: "\f476"; } +.genericon-expand:before { content: "\f431"; } +.genericon-external:before { content: "\f442"; } +.genericon-facebook:before { content: "\f203"; } +.genericon-facebook-alt:before { content: "\f204"; } +.genericon-fastforward:before { content: "\f458"; } +.genericon-feed:before { content: "\f413"; } +.genericon-flag:before { content: "\f468"; } +.genericon-flickr:before { content: "\f211"; } +.genericon-foursquare:before { content: "\f226"; } +.genericon-fullscreen:before { content: "\f474"; } +.genericon-gallery:before { content: "\f103"; } +.genericon-github:before { content: "\f200"; } +.genericon-googleplus:before { content: "\f206"; } +.genericon-googleplus-alt:before { content: "\f218"; } +.genericon-handset:before { content: "\f50c"; } +.genericon-heart:before { content: "\f461"; } +.genericon-help:before { content: "\f457"; } +.genericon-hide:before { content: "\f404"; } +.genericon-hierarchy:before { content: "\f505"; } +.genericon-home:before { content: "\f409"; } +.genericon-image:before { content: "\f102"; } +.genericon-info:before { content: "\f455"; } +.genericon-instagram:before { content: "\f215"; } +.genericon-italic:before { content: "\f472"; } +.genericon-key:before { content: "\f427"; } +.genericon-leftarrow:before { content: "\f503"; } +.genericon-link:before { content: "\f107"; } +.genericon-linkedin:before { content: "\f207"; } +.genericon-linkedin-alt:before { content: "\f208"; } +.genericon-location:before { content: "\f417"; } +.genericon-lock:before { content: "\f470"; } +.genericon-mail:before { content: "\f410"; } +.genericon-maximize:before { content: "\f422"; } +.genericon-menu:before { content: "\f419"; } +.genericon-microphone:before { content: "\f50d"; } +.genericon-minimize:before { content: "\f421"; } +.genericon-minus:before { content: "\f50e"; } +.genericon-month:before { content: "\f307"; } +.genericon-move:before { content: "\f50f"; } +.genericon-next:before { content: "\f429"; } +.genericon-notice:before { content: "\f456"; } +.genericon-paintbrush:before { content: "\f506"; } +.genericon-path:before { content: "\f219"; } +.genericon-pause:before { content: "\f448"; } +.genericon-phone:before { content: "\f437"; } +.genericon-picture:before { content: "\f473"; } +.genericon-pinned:before { content: "\f308"; } +.genericon-pinterest:before { content: "\f209"; } +.genericon-pinterest-alt:before { content: "\f210"; } +.genericon-play:before { content: "\f452"; } +.genericon-plugin:before { content: "\f439"; } +.genericon-plus:before { content: "\f510"; } +.genericon-pocket:before { content: "\f224"; } +.genericon-polldaddy:before { content: "\f217"; } +.genericon-portfolio:before { content: "\f460"; } +.genericon-previous:before { content: "\f430"; } +.genericon-print:before { content: "\f469"; } +.genericon-quote:before { content: "\f106"; } +.genericon-rating-empty:before { content: "\f511"; } +.genericon-rating-full:before { content: "\f512"; } +.genericon-rating-half:before { content: "\f513"; } +.genericon-reddit:before { content: "\f222"; } +.genericon-refresh:before { content: "\f420"; } +.genericon-reply:before { content: "\f412"; } +.genericon-reply-alt:before { content: "\f466"; } +.genericon-reply-single:before { content: "\f467"; } +.genericon-rewind:before { content: "\f459"; } +.genericon-rightarrow:before { content: "\f501"; } +.genericon-search:before { content: "\f400"; } +.genericon-send-to-phone:before { content: "\f438"; } +.genericon-send-to-tablet:before { content: "\f454"; } +.genericon-share:before { content: "\f415"; } +.genericon-show:before { content: "\f403"; } +.genericon-shuffle:before { content: "\f514"; } +.genericon-sitemap:before { content: "\f507"; } +.genericon-skip-ahead:before { content: "\f451"; } +.genericon-skip-back:before { content: "\f450"; } +.genericon-skype:before { content: "\f220"; } +.genericon-spam:before { content: "\f424"; } +.genericon-spotify:before { content: "\f515"; } +.genericon-standard:before { content: "\f100"; } +.genericon-star:before { content: "\f408"; } +.genericon-status:before { content: "\f105"; } +.genericon-stop:before { content: "\f449"; } +.genericon-stumbleupon:before { content: "\f223"; } +.genericon-subscribe:before { content: "\f463"; } +.genericon-subscribed:before { content: "\f465"; } +.genericon-summary:before { content: "\f425"; } +.genericon-tablet:before { content: "\f453"; } +.genericon-tag:before { content: "\f302"; } +.genericon-time:before { content: "\f303"; } +.genericon-top:before { content: "\f435"; } +.genericon-trash:before { content: "\f407"; } +.genericon-tumblr:before { content: "\f214"; } +.genericon-twitch:before { content: "\f516"; } +.genericon-twitter:before { content: "\f202"; } +.genericon-unapprove:before { content: "\f446"; } +.genericon-unsubscribe:before { content: "\f464"; } +.genericon-unzoom:before { content: "\f401"; } +.genericon-uparrow:before { content: "\f500"; } +.genericon-user:before { content: "\f304"; } +.genericon-video:before { content: "\f104"; } +.genericon-videocamera:before { content: "\f517"; } +.genericon-vimeo:before { content: "\f212"; } +.genericon-warning:before { content: "\f414"; } +.genericon-website:before { content: "\f475"; } +.genericon-week:before { content: "\f306"; } +.genericon-wordpress:before { content: "\f205"; } +.genericon-xpost:before { content: "\f504"; } +.genericon-youtube:before { content: "\f213"; } +.genericon-zoom:before { content: "\f402"; } + + + + diff --git a/backend/wp-content/themes/twentysixteen/header.php b/backend/wp-content/themes/twentysixteen/header.php new file mode 100644 index 0000000..d230c4f --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/header.php @@ -0,0 +1,99 @@ + + class="no-js"> + + + + + + + + + + +> +
      +
      + + + + +
      diff --git a/backend/wp-content/themes/twentysixteen/image.php b/backend/wp-content/themes/twentysixteen/image.php new file mode 100644 index 0000000..434b0b0 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/image.php @@ -0,0 +1,112 @@ + + +
      +
      + + + +
      > + + + +
      + ', '' ); ?> +
      + +
      + +
      + + + + +
      + + '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + +
      + + %1$s %3$s × %4$s', + esc_html_x( 'Full size', 'Used before full size attachment link.', 'twentysixteen' ), + esc_url( wp_get_attachment_url() ), + absint( $metadata['width'] ), + absint( $metadata['height'] ) + ); + } + ?> + "%s"', 'twentysixteen' ), + get_the_title() + ), + '', + '' + ); + ?> +
      +
      + + _x( 'Published in%title', 'Parent post link', 'twentysixteen' ), + ) ); + // End the loop. + endwhile; + ?> + +
      +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/inc/back-compat.php b/backend/wp-content/themes/twentysixteen/inc/back-compat.php new file mode 100644 index 0000000..7ed4240 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/inc/back-compat.php @@ -0,0 +1,71 @@ +

      %s

      ', $message ); +} + +/** + * Prevents the Customizer from being loaded on WordPress versions prior to 4.4. + * + * @since Twenty Sixteen 1.0 + * + * @global string $wp_version WordPress version. + */ +function twentysixteen_customize() { + wp_die( sprintf( __( 'Twenty Sixteen requires at least WordPress version 4.4. You are running version %s. Please upgrade and try again.', 'twentysixteen' ), $GLOBALS['wp_version'] ), '', array( + 'back_link' => true, + ) ); +} +add_action( 'load-customize.php', 'twentysixteen_customize' ); + +/** + * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.4. + * + * @since Twenty Sixteen 1.0 + * + * @global string $wp_version WordPress version. + */ +function twentysixteen_preview() { + if ( isset( $_GET['preview'] ) ) { + wp_die( sprintf( __( 'Twenty Sixteen requires at least WordPress version 4.4. You are running version %s. Please upgrade and try again.', 'twentysixteen' ), $GLOBALS['wp_version'] ) ); + } +} +add_action( 'template_redirect', 'twentysixteen_preview' ); diff --git a/backend/wp-content/themes/twentysixteen/inc/customizer.php b/backend/wp-content/themes/twentysixteen/inc/customizer.php new file mode 100644 index 0000000..62eb1b0 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/inc/customizer.php @@ -0,0 +1,1193 @@ + $default_background_color, + ) ) ); + + /** + * Filter the arguments used when adding 'custom-header' support in Twenty Sixteen. + * + * @since Twenty Sixteen 1.0 + * + * @param array $args { + * An array of custom-header support arguments. + * + * @type string $default-text-color Default color of the header text. + * @type int $width Width in pixels of the custom header image. Default 1200. + * @type int $height Height in pixels of the custom header image. Default 280. + * @type bool $flex-height Whether to allow flexible-height header images. Default true. + * @type callable $wp-head-callback Callback function used to style the header image and text + * displayed on the blog. + * } + */ + add_theme_support( 'custom-header', apply_filters( 'twentysixteen_custom_header_args', array( + 'default-text-color' => $default_text_color, + 'width' => 1200, + 'height' => 280, + 'flex-height' => true, + 'wp-head-callback' => 'twentysixteen_header_style', + ) ) ); +} +add_action( 'after_setup_theme', 'twentysixteen_custom_header_and_background' ); + +if ( ! function_exists( 'twentysixteen_header_style' ) ) : +/** + * Styles the header text displayed on the site. + * + * Create your own twentysixteen_header_style() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @see twentysixteen_custom_header_and_background(). + */ +function twentysixteen_header_style() { + // If the header text option is untouched, let's bail. + if ( display_header_text() ) { + return; + } + + // If the header text has been hidden. + ?> + + get_setting( 'blogname' )->transport = 'postMessage'; + $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; + + if ( isset( $wp_customize->selective_refresh ) ) { + $wp_customize->selective_refresh->add_partial( 'blogname', array( + 'selector' => '.site-title a', + 'container_inclusive' => false, + 'render_callback' => 'twentysixteen_customize_partial_blogname', + ) ); + $wp_customize->selective_refresh->add_partial( 'blogdescription', array( + 'selector' => '.site-description', + 'container_inclusive' => false, + 'render_callback' => 'twentysixteen_customize_partial_blogdescription', + ) ); + } + + // Add color scheme setting and control. + $wp_customize->add_setting( 'color_scheme', array( + 'default' => 'default', + 'sanitize_callback' => 'twentysixteen_sanitize_color_scheme', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( 'color_scheme', array( + 'label' => __( 'Base Color Scheme', 'twentysixteen' ), + 'section' => 'colors', + 'type' => 'select', + 'choices' => twentysixteen_get_color_scheme_choices(), + 'priority' => 1, + ) ); + + // Add page background color setting and control. + $wp_customize->add_setting( 'page_background_color', array( + 'default' => $color_scheme[1], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'page_background_color', array( + 'label' => __( 'Page Background Color', 'twentysixteen' ), + 'section' => 'colors', + ) ) ); + + // Remove the core header textcolor control, as it shares the main text color. + $wp_customize->remove_control( 'header_textcolor' ); + + // Add link color setting and control. + $wp_customize->add_setting( 'link_color', array( + 'default' => $color_scheme[2], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array( + 'label' => __( 'Link Color', 'twentysixteen' ), + 'section' => 'colors', + ) ) ); + + // Add main text color setting and control. + $wp_customize->add_setting( 'main_text_color', array( + 'default' => $color_scheme[3], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'main_text_color', array( + 'label' => __( 'Main Text Color', 'twentysixteen' ), + 'section' => 'colors', + ) ) ); + + // Add secondary text color setting and control. + $wp_customize->add_setting( 'secondary_text_color', array( + 'default' => $color_scheme[4], + 'sanitize_callback' => 'sanitize_hex_color', + 'transport' => 'postMessage', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_text_color', array( + 'label' => __( 'Secondary Text Color', 'twentysixteen' ), + 'section' => 'colors', + ) ) ); +} +add_action( 'customize_register', 'twentysixteen_customize_register', 11 ); + +/** + * Render the site title for the selective refresh partial. + * + * @since Twenty Sixteen 1.2 + * @see twentysixteen_customize_register() + * + * @return void + */ +function twentysixteen_customize_partial_blogname() { + bloginfo( 'name' ); +} + +/** + * Render the site tagline for the selective refresh partial. + * + * @since Twenty Sixteen 1.2 + * @see twentysixteen_customize_register() + * + * @return void + */ +function twentysixteen_customize_partial_blogdescription() { + bloginfo( 'description' ); +} + +/** + * Registers color schemes for Twenty Sixteen. + * + * Can be filtered with {@see 'twentysixteen_color_schemes'}. + * + * The order of colors in a colors array: + * 1. Main Background Color. + * 2. Page Background Color. + * 3. Link Color. + * 4. Main Text Color. + * 5. Secondary Text Color. + * + * @since Twenty Sixteen 1.0 + * + * @return array An associative array of color scheme options. + */ +function twentysixteen_get_color_schemes() { + /** + * Filter the color schemes registered for use with Twenty Sixteen. + * + * The default schemes include 'default', 'dark', 'gray', 'red', and 'yellow'. + * + * @since Twenty Sixteen 1.0 + * + * @param array $schemes { + * Associative array of color schemes data. + * + * @type array $slug { + * Associative array of information for setting up the color scheme. + * + * @type string $label Color scheme label. + * @type array $colors HEX codes for default colors prepended with a hash symbol ('#'). + * Colors are defined in the following order: Main background, page + * background, link, main text, secondary text. + * } + * } + */ + return apply_filters( 'twentysixteen_color_schemes', array( + 'default' => array( + 'label' => __( 'Default', 'twentysixteen' ), + 'colors' => array( + '#1a1a1a', + '#ffffff', + '#007acc', + '#1a1a1a', + '#686868', + ), + ), + 'dark' => array( + 'label' => __( 'Dark', 'twentysixteen' ), + 'colors' => array( + '#262626', + '#1a1a1a', + '#9adffd', + '#e5e5e5', + '#c1c1c1', + ), + ), + 'gray' => array( + 'label' => __( 'Gray', 'twentysixteen' ), + 'colors' => array( + '#616a73', + '#4d545c', + '#c7c7c7', + '#f2f2f2', + '#f2f2f2', + ), + ), + 'red' => array( + 'label' => __( 'Red', 'twentysixteen' ), + 'colors' => array( + '#ffffff', + '#ff675f', + '#640c1f', + '#402b30', + '#402b30', + ), + ), + 'yellow' => array( + 'label' => __( 'Yellow', 'twentysixteen' ), + 'colors' => array( + '#3b3721', + '#ffef8e', + '#774e24', + '#3b3721', + '#5b4d3e', + ), + ), + ) ); +} + +if ( ! function_exists( 'twentysixteen_get_color_scheme' ) ) : +/** + * Retrieves the current Twenty Sixteen color scheme. + * + * Create your own twentysixteen_get_color_scheme() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @return array An associative array of either the current or default color scheme HEX values. + */ +function twentysixteen_get_color_scheme() { + $color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); + $color_schemes = twentysixteen_get_color_schemes(); + + if ( array_key_exists( $color_scheme_option, $color_schemes ) ) { + return $color_schemes[ $color_scheme_option ]['colors']; + } + + return $color_schemes['default']['colors']; +} +endif; // twentysixteen_get_color_scheme + +if ( ! function_exists( 'twentysixteen_get_color_scheme_choices' ) ) : +/** + * Retrieves an array of color scheme choices registered for Twenty Sixteen. + * + * Create your own twentysixteen_get_color_scheme_choices() function to override + * in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @return array Array of color schemes. + */ +function twentysixteen_get_color_scheme_choices() { + $color_schemes = twentysixteen_get_color_schemes(); + $color_scheme_control_options = array(); + + foreach ( $color_schemes as $color_scheme => $value ) { + $color_scheme_control_options[ $color_scheme ] = $value['label']; + } + + return $color_scheme_control_options; +} +endif; // twentysixteen_get_color_scheme_choices + + +if ( ! function_exists( 'twentysixteen_sanitize_color_scheme' ) ) : +/** + * Handles sanitization for Twenty Sixteen color schemes. + * + * Create your own twentysixteen_sanitize_color_scheme() function to override + * in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @param string $value Color scheme name value. + * @return string Color scheme name. + */ +function twentysixteen_sanitize_color_scheme( $value ) { + $color_schemes = twentysixteen_get_color_scheme_choices(); + + if ( ! array_key_exists( $value, $color_schemes ) ) { + return 'default'; + } + + return $value; +} +endif; // twentysixteen_sanitize_color_scheme + +/** + * Enqueues front-end CSS for color scheme. + * + * @since Twenty Sixteen 1.0 + * + * @see wp_add_inline_style() + */ +function twentysixteen_color_scheme_css() { + $color_scheme_option = get_theme_mod( 'color_scheme', 'default' ); + + // Don't do anything if the default color scheme is selected. + if ( 'default' === $color_scheme_option ) { + return; + } + + $color_scheme = twentysixteen_get_color_scheme(); + + // Convert main text hex color to rgba. + $color_textcolor_rgb = twentysixteen_hex2rgb( $color_scheme[3] ); + + // If the rgba values are empty return early. + if ( empty( $color_textcolor_rgb ) ) { + return; + } + + // If we get this far, we have a custom color scheme. + $colors = array( + 'background_color' => $color_scheme[0], + 'page_background_color' => $color_scheme[1], + 'link_color' => $color_scheme[2], + 'main_text_color' => $color_scheme[3], + 'secondary_text_color' => $color_scheme[4], + 'border_color' => vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.2)', $color_textcolor_rgb ), + + ); + + $color_scheme_css = twentysixteen_get_color_scheme_css( $colors ); + + wp_add_inline_style( 'twentysixteen-style', $color_scheme_css ); +} +add_action( 'wp_enqueue_scripts', 'twentysixteen_color_scheme_css' ); + +/** + * Binds the JS listener to make Customizer color_scheme control. + * + * Passes color scheme data as colorScheme global. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_customize_control_js() { + wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), '20160816', true ); + wp_localize_script( 'color-scheme-control', 'colorScheme', twentysixteen_get_color_schemes() ); +} +add_action( 'customize_controls_enqueue_scripts', 'twentysixteen_customize_control_js' ); + +/** + * Binds JS handlers to make the Customizer preview reload changes asynchronously. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_customize_preview_js() { + wp_enqueue_script( 'twentysixteen-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20160816', true ); +} +add_action( 'customize_preview_init', 'twentysixteen_customize_preview_js' ); + +/** + * Returns CSS for the color schemes. + * + * @since Twenty Sixteen 1.0 + * + * @param array $colors Color scheme colors. + * @return string Color scheme CSS. + */ +function twentysixteen_get_color_scheme_css( $colors ) { + $colors = wp_parse_args( $colors, array( + 'background_color' => '', + 'page_background_color' => '', + 'link_color' => '', + 'main_text_color' => '', + 'secondary_text_color' => '', + 'border_color' => '', + ) ); + + return << .page-links-title, + .comment-author, + .comment-reply-title small a:hover, + .comment-reply-title small a:focus { + color: {$colors['main_text_color']}; + } + + blockquote, + .menu-toggle.toggled-on, + .menu-toggle.toggled-on:hover, + .menu-toggle.toggled-on:focus, + .post-navigation, + .post-navigation div + div, + .pagination, + .widget, + .page-header, + .page-links a, + .comments-title, + .comment-reply-title { + border-color: {$colors['main_text_color']}; + } + + button, + button[disabled]:hover, + button[disabled]:focus, + input[type="button"], + input[type="button"][disabled]:hover, + input[type="button"][disabled]:focus, + input[type="reset"], + input[type="reset"][disabled]:hover, + input[type="reset"][disabled]:focus, + input[type="submit"], + input[type="submit"][disabled]:hover, + input[type="submit"][disabled]:focus, + .menu-toggle.toggled-on, + .menu-toggle.toggled-on:hover, + .menu-toggle.toggled-on:focus, + .pagination:before, + .pagination:after, + .pagination .prev, + .pagination .next, + .page-links a { + background-color: {$colors['main_text_color']}; + } + + /* Secondary Text Color */ + + /** + * IE8 and earlier will drop any block with CSS3 selectors. + * Do not combine these styles with the next block. + */ + body:not(.search-results) .entry-summary { + color: {$colors['secondary_text_color']}; + } + + blockquote, + .post-password-form label, + a:hover, + a:focus, + a:active, + .post-navigation .meta-nav, + .image-navigation, + .comment-navigation, + .widget_recent_entries .post-date, + .widget_rss .rss-date, + .widget_rss cite, + .site-description, + .author-bio, + .entry-footer, + .entry-footer a, + .sticky-post, + .taxonomy-description, + .entry-caption, + .comment-metadata, + .pingback .edit-link, + .comment-metadata a, + .pingback .comment-edit-link, + .comment-form label, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .form-allowed-tags, + .site-info, + .site-info a, + .wp-caption .wp-caption-text, + .gallery-caption, + .widecolumn label, + .widecolumn .mu_register label { + color: {$colors['secondary_text_color']}; + } + + .widget_calendar tbody a:hover, + .widget_calendar tbody a:focus { + background-color: {$colors['secondary_text_color']}; + } + + /* Border Color */ + fieldset, + pre, + abbr, + acronym, + table, + th, + td, + input[type="date"], + input[type="time"], + input[type="datetime-local"], + input[type="week"], + input[type="month"], + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + input[type="tel"], + input[type="number"], + textarea, + .main-navigation li, + .main-navigation .primary-menu, + .menu-toggle, + .dropdown-toggle:after, + .social-navigation a, + .image-navigation, + .comment-navigation, + .tagcloud a, + .entry-content, + .entry-summary, + .page-links a, + .page-links > span, + .comment-list article, + .comment-list .pingback, + .comment-list .trackback, + .comment-reply-link, + .no-comments, + .widecolumn .mu_register .mu_alert { + border-color: {$colors['main_text_color']}; /* Fallback for IE7 and IE8 */ + border-color: {$colors['border_color']}; + } + + hr, + code { + background-color: {$colors['main_text_color']}; /* Fallback for IE7 and IE8 */ + background-color: {$colors['border_color']}; + } + + @media screen and (min-width: 56.875em) { + .main-navigation li:hover > a, + .main-navigation li.focus > a { + color: {$colors['link_color']}; + } + + .main-navigation ul ul, + .main-navigation ul ul li { + border-color: {$colors['border_color']}; + } + + .main-navigation ul ul:before { + border-top-color: {$colors['border_color']}; + border-bottom-color: {$colors['border_color']}; + } + + .main-navigation ul ul li { + background-color: {$colors['page_background_color']}; + } + + .main-navigation ul ul:after { + border-top-color: {$colors['page_background_color']}; + border-bottom-color: {$colors['page_background_color']}; + } + } + +CSS; +} + + +/** + * Outputs an Underscore template for generating CSS for the color scheme. + * + * The template generates the css dynamically for instant display in the + * Customizer preview. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_color_scheme_css_template() { + $colors = array( + 'background_color' => '{{ data.background_color }}', + 'page_background_color' => '{{ data.page_background_color }}', + 'link_color' => '{{ data.link_color }}', + 'main_text_color' => '{{ data.main_text_color }}', + 'secondary_text_color' => '{{ data.secondary_text_color }}', + 'border_color' => '{{ data.border_color }}', + ); + ?> + + a, + .main-navigation li.focus > a { + color: %1$s; + } + } + '; + + wp_add_inline_style( 'twentysixteen-style', sprintf( $css, $link_color ) ); +} +add_action( 'wp_enqueue_scripts', 'twentysixteen_link_color_css', 11 ); + +/** + * Enqueues front-end CSS for the main text color. + * + * @since Twenty Sixteen 1.0 + * + * @see wp_add_inline_style() + */ +function twentysixteen_main_text_color_css() { + $color_scheme = twentysixteen_get_color_scheme(); + $default_color = $color_scheme[3]; + $main_text_color = get_theme_mod( 'main_text_color', $default_color ); + + // Don't do anything if the current color is the default. + if ( $main_text_color === $default_color ) { + return; + } + + // Convert main text hex color to rgba. + $main_text_color_rgb = twentysixteen_hex2rgb( $main_text_color ); + + // If the rgba values are empty return early. + if ( empty( $main_text_color_rgb ) ) { + return; + } + + // If we get this far, we have a custom color scheme. + $border_color = vsprintf( 'rgba( %1$s, %2$s, %3$s, 0.2)', $main_text_color_rgb ); + + $css = ' + /* Custom Main Text Color */ + body, + blockquote cite, + blockquote small, + .main-navigation a, + .menu-toggle, + .dropdown-toggle, + .social-navigation a, + .post-navigation a, + .pagination a:hover, + .pagination a:focus, + .widget-title a, + .site-branding .site-title a, + .entry-title a, + .page-links > .page-links-title, + .comment-author, + .comment-reply-title small a:hover, + .comment-reply-title small a:focus { + color: %1$s + } + + blockquote, + .menu-toggle.toggled-on, + .menu-toggle.toggled-on:hover, + .menu-toggle.toggled-on:focus, + .post-navigation, + .post-navigation div + div, + .pagination, + .widget, + .page-header, + .page-links a, + .comments-title, + .comment-reply-title { + border-color: %1$s; + } + + button, + button[disabled]:hover, + button[disabled]:focus, + input[type="button"], + input[type="button"][disabled]:hover, + input[type="button"][disabled]:focus, + input[type="reset"], + input[type="reset"][disabled]:hover, + input[type="reset"][disabled]:focus, + input[type="submit"], + input[type="submit"][disabled]:hover, + input[type="submit"][disabled]:focus, + .menu-toggle.toggled-on, + .menu-toggle.toggled-on:hover, + .menu-toggle.toggled-on:focus, + .pagination:before, + .pagination:after, + .pagination .prev, + .pagination .next, + .page-links a { + background-color: %1$s; + } + + /* Border Color */ + fieldset, + pre, + abbr, + acronym, + table, + th, + td, + input[type="date"], + input[type="time"], + input[type="datetime-local"], + input[type="week"], + input[type="month"], + input[type="text"], + input[type="email"], + input[type="url"], + input[type="password"], + input[type="search"], + input[type="tel"], + input[type="number"], + textarea, + .main-navigation li, + .main-navigation .primary-menu, + .menu-toggle, + .dropdown-toggle:after, + .social-navigation a, + .image-navigation, + .comment-navigation, + .tagcloud a, + .entry-content, + .entry-summary, + .page-links a, + .page-links > span, + .comment-list article, + .comment-list .pingback, + .comment-list .trackback, + .comment-reply-link, + .no-comments, + .widecolumn .mu_register .mu_alert { + border-color: %1$s; /* Fallback for IE7 and IE8 */ + border-color: %2$s; + } + + hr, + code { + background-color: %1$s; /* Fallback for IE7 and IE8 */ + background-color: %2$s; + } + + @media screen and (min-width: 56.875em) { + .main-navigation ul ul, + .main-navigation ul ul li { + border-color: %2$s; + } + + .main-navigation ul ul:before { + border-top-color: %2$s; + border-bottom-color: %2$s; + } + } + '; + + wp_add_inline_style( 'twentysixteen-style', sprintf( $css, $main_text_color, $border_color ) ); +} +add_action( 'wp_enqueue_scripts', 'twentysixteen_main_text_color_css', 11 ); + +/** + * Enqueues front-end CSS for the secondary text color. + * + * @since Twenty Sixteen 1.0 + * + * @see wp_add_inline_style() + */ +function twentysixteen_secondary_text_color_css() { + $color_scheme = twentysixteen_get_color_scheme(); + $default_color = $color_scheme[4]; + $secondary_text_color = get_theme_mod( 'secondary_text_color', $default_color ); + + // Don't do anything if the current color is the default. + if ( $secondary_text_color === $default_color ) { + return; + } + + $css = ' + /* Custom Secondary Text Color */ + + /** + * IE8 and earlier will drop any block with CSS3 selectors. + * Do not combine these styles with the next block. + */ + body:not(.search-results) .entry-summary { + color: %1$s; + } + + blockquote, + .post-password-form label, + a:hover, + a:focus, + a:active, + .post-navigation .meta-nav, + .image-navigation, + .comment-navigation, + .widget_recent_entries .post-date, + .widget_rss .rss-date, + .widget_rss cite, + .site-description, + .author-bio, + .entry-footer, + .entry-footer a, + .sticky-post, + .taxonomy-description, + .entry-caption, + .comment-metadata, + .pingback .edit-link, + .comment-metadata a, + .pingback .comment-edit-link, + .comment-form label, + .comment-notes, + .comment-awaiting-moderation, + .logged-in-as, + .form-allowed-tags, + .site-info, + .site-info a, + .wp-caption .wp-caption-text, + .gallery-caption, + .widecolumn label, + .widecolumn .mu_register label { + color: %1$s; + } + + .widget_calendar tbody a:hover, + .widget_calendar tbody a:focus { + background-color: %1$s; + } + '; + + wp_add_inline_style( 'twentysixteen-style', sprintf( $css, $secondary_text_color ) ); +} +add_action( 'wp_enqueue_scripts', 'twentysixteen_secondary_text_color_css', 11 ); diff --git a/backend/wp-content/themes/twentysixteen/inc/template-tags.php b/backend/wp-content/themes/twentysixteen/inc/template-tags.php new file mode 100644 index 0000000..9b8f1f3 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/inc/template-tags.php @@ -0,0 +1,254 @@ +%1$s%2$s %4$s', + get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ), + _x( 'Author', 'Used before post author name.', 'twentysixteen' ), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + get_the_author() + ); + } + + if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) { + twentysixteen_entry_date(); + } + + $format = get_post_format(); + if ( current_theme_supports( 'post-formats', $format ) ) { + printf( '%1$s%3$s', + sprintf( '%s ', _x( 'Format', 'Used before post format.', 'twentysixteen' ) ), + esc_url( get_post_format_link( $format ) ), + get_post_format_string( $format ) + ); + } + + if ( 'post' === get_post_type() ) { + twentysixteen_entry_taxonomies(); + } + + if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo ''; + comments_popup_link( sprintf( __( 'Leave a comment on %s', 'twentysixteen' ), get_the_title() ) ); + echo ''; + } +} +endif; + +if ( ! function_exists( 'twentysixteen_entry_date' ) ) : +/** + * Prints HTML with date information for current post. + * + * Create your own twentysixteen_entry_date() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_entry_date() { + $time_string = ''; + + if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { + $time_string = ''; + } + + $time_string = sprintf( $time_string, + esc_attr( get_the_date( 'c' ) ), + get_the_date(), + esc_attr( get_the_modified_date( 'c' ) ), + get_the_modified_date() + ); + + printf( '%1$s %3$s', + _x( 'Posted on', 'Used before publish date.', 'twentysixteen' ), + esc_url( get_permalink() ), + $time_string + ); +} +endif; + +if ( ! function_exists( 'twentysixteen_entry_taxonomies' ) ) : +/** + * Prints HTML with category and tags for current post. + * + * Create your own twentysixteen_entry_taxonomies() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_entry_taxonomies() { + $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) ); + if ( $categories_list && twentysixteen_categorized_blog() ) { + printf( '%1$s %2$s', + _x( 'Categories', 'Used before category names.', 'twentysixteen' ), + $categories_list + ); + } + + $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) ); + if ( $tags_list && ! is_wp_error( $tags_list ) ) { + printf( '%1$s %2$s', + _x( 'Tags', 'Used before tag names.', 'twentysixteen' ), + $tags_list + ); + } +} +endif; + +if ( ! function_exists( 'twentysixteen_post_thumbnail' ) ) : +/** + * Displays an optional post thumbnail. + * + * Wraps the post thumbnail in an anchor element on index views, or a div + * element when on single views. + * + * Create your own twentysixteen_post_thumbnail() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_post_thumbnail() { + if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { + return; + } + + if ( is_singular() ) : + ?> + +
      + +
      + + + + + + +
      + +
      + %2$s', + esc_url( get_permalink( get_the_ID() ) ), + /* translators: %s: Name of current post */ + sprintf( __( 'Continue reading "%s"', 'twentysixteen' ), get_the_title( get_the_ID() ) ) + ); + return ' … ' . $link; +} +add_filter( 'excerpt_more', 'twentysixteen_excerpt_more' ); +endif; + +if ( ! function_exists( 'twentysixteen_categorized_blog' ) ) : +/** + * Determines whether blog/site has more than one category. + * + * Create your own twentysixteen_categorized_blog() function to override in a child theme. + * + * @since Twenty Sixteen 1.0 + * + * @return bool True if there is more than one category, false otherwise. + */ +function twentysixteen_categorized_blog() { + if ( false === ( $all_the_cool_cats = get_transient( 'twentysixteen_categories' ) ) ) { + // Create an array of all the categories that are attached to posts. + $all_the_cool_cats = get_categories( array( + 'fields' => 'ids', + // We only need to know if there is more than one category. + 'number' => 2, + ) ); + + // Count the number of categories that are attached to the posts. + $all_the_cool_cats = count( $all_the_cool_cats ); + + set_transient( 'twentysixteen_categories', $all_the_cool_cats ); + } + + if ( $all_the_cool_cats > 1 || is_preview() ) { + // This blog has more than 1 category so twentysixteen_categorized_blog should return true. + return true; + } else { + // This blog has only 1 category so twentysixteen_categorized_blog should return false. + return false; + } +} +endif; + +/** + * Flushes out the transients used in twentysixteen_categorized_blog(). + * + * @since Twenty Sixteen 1.0 + */ +function twentysixteen_category_transient_flusher() { + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + return; + } + // Like, beat it. Dig? + delete_transient( 'twentysixteen_categories' ); +} +add_action( 'edit_category', 'twentysixteen_category_transient_flusher' ); +add_action( 'save_post', 'twentysixteen_category_transient_flusher' ); + +if ( ! function_exists( 'twentysixteen_the_custom_logo' ) ) : +/** + * Displays the optional custom logo. + * + * Does nothing if the custom logo is not available. + * + * @since Twenty Sixteen 1.2 + */ +function twentysixteen_the_custom_logo() { + if ( function_exists( 'the_custom_logo' ) ) { + the_custom_logo(); + } +} +endif; diff --git a/backend/wp-content/themes/twentysixteen/index.php b/backend/wp-content/themes/twentysixteen/index.php new file mode 100644 index 0000000..3f621ab --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/index.php @@ -0,0 +1,62 @@ + + +
      +
      + + + + +
      +

      +
      + + + __( 'Previous page', 'twentysixteen' ), + 'next_text' => __( 'Next page', 'twentysixteen' ), + 'before_page_number' => '' . __( 'Page', 'twentysixteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'template-parts/content', 'none' ); + + endif; + ?> + +
      +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/js/color-scheme-control.js b/backend/wp-content/themes/twentysixteen/js/color-scheme-control.js new file mode 100644 index 0000000..e65b5bd --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/js/color-scheme-control.js @@ -0,0 +1,96 @@ +/* global colorScheme, Color */ +/** + * Add a listener to the Color Scheme control to update other color controls to new values/defaults. + * Also trigger an update of the Color Scheme CSS when a color is changed. + */ + +( function( api ) { + var cssTemplate = wp.template( 'twentysixteen-color-scheme' ), + colorSchemeKeys = [ + 'background_color', + 'page_background_color', + 'link_color', + 'main_text_color', + 'secondary_text_color' + ], + colorSettings = [ + 'background_color', + 'page_background_color', + 'link_color', + 'main_text_color', + 'secondary_text_color' + ]; + + api.controlConstructor.select = api.Control.extend( { + ready: function() { + if ( 'color_scheme' === this.id ) { + this.setting.bind( 'change', function( value ) { + var colors = colorScheme[value].colors; + + // Update Background Color. + var color = colors[0]; + api( 'background_color' ).set( color ); + api.control( 'background_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', color ) + .wpColorPicker( 'defaultColor', color ); + + // Update Page Background Color. + color = colors[1]; + api( 'page_background_color' ).set( color ); + api.control( 'page_background_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', color ) + .wpColorPicker( 'defaultColor', color ); + + // Update Link Color. + color = colors[2]; + api( 'link_color' ).set( color ); + api.control( 'link_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', color ) + .wpColorPicker( 'defaultColor', color ); + + // Update Main Text Color. + color = colors[3]; + api( 'main_text_color' ).set( color ); + api.control( 'main_text_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', color ) + .wpColorPicker( 'defaultColor', color ); + + // Update Secondary Text Color. + color = colors[4]; + api( 'secondary_text_color' ).set( color ); + api.control( 'secondary_text_color' ).container.find( '.color-picker-hex' ) + .data( 'data-default-color', color ) + .wpColorPicker( 'defaultColor', color ); + } ); + } + } + } ); + + // Generate the CSS for the current Color Scheme. + function updateCSS() { + var scheme = api( 'color_scheme' )(), + css, + colors = _.object( colorSchemeKeys, colorScheme[ scheme ].colors ); + + // Merge in color scheme overrides. + _.each( colorSettings, function( setting ) { + colors[ setting ] = api( setting )(); + } ); + + // Add additional color. + // jscs:disable + colors.border_color = Color( colors.main_text_color ).toCSS( 'rgba', 0.2 ); + // jscs:enable + + css = cssTemplate( colors ); + + api.previewer.send( 'update-color-scheme-css', css ); + } + + // Update the CSS whenever a color setting is changed. + _.each( colorSettings, function( setting ) { + api( setting, function( setting ) { + setting.bind( updateCSS ); + } ); + } ); +} )( wp.customize ); diff --git a/backend/wp-content/themes/twentysixteen/js/customize-preview.js b/backend/wp-content/themes/twentysixteen/js/customize-preview.js new file mode 100644 index 0000000..fc99333 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/js/customize-preview.js @@ -0,0 +1,41 @@ +/** + * Live-update changed settings in real time in the Customizer preview. + */ + +( function( $ ) { + var style = $( '#twentysixteen-color-scheme-css' ), + api = wp.customize; + + if ( ! style.length ) { + style = $( 'head' ).append( ''; + return parent.insertBefore(p.lastChild, parent.firstChild); + } + + /** + * Returns the value of `html5.elements` as an array. + * @private + * @returns {Array} An array of shived element node names. + */ + function getElements() { + var elements = html5.elements; + return typeof elements == 'string' ? elements.split(' ') : elements; + } + + /** + * Extends the built-in list of html5 elements + * @memberOf html5 + * @param {String|Array} newElements whitespace separated list or array of new element names to shiv + * @param {Document} ownerDocument The context document. + */ + function addElements(newElements, ownerDocument) { + var elements = html5.elements; + if(typeof elements != 'string'){ + elements = elements.join(' '); + } + if(typeof newElements != 'string'){ + newElements = newElements.join(' '); + } + html5.elements = elements +' '+ newElements; + shivDocument(ownerDocument); + } + + /** + * Returns the data associated to the given document + * @private + * @param {Document} ownerDocument The document. + * @returns {Object} An object of data. + */ + function getExpandoData(ownerDocument) { + var data = expandoData[ownerDocument[expando]]; + if (!data) { + data = {}; + expanID++; + ownerDocument[expando] = expanID; + expandoData[expanID] = data; + } + return data; + } + + /** + * returns a shived element for the given nodeName and document + * @memberOf html5 + * @param {String} nodeName name of the element + * @param {Document|DocumentFragment} ownerDocument The context document. + * @returns {Object} The shived element. + */ + function createElement(nodeName, ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createElement(nodeName); + } + if (!data) { + data = getExpandoData(ownerDocument); + } + var node; + + if (data.cache[nodeName]) { + node = data.cache[nodeName].cloneNode(); + } else if (saveClones.test(nodeName)) { + node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); + } else { + node = data.createElem(nodeName); + } + + // Avoid adding some elements to fragments in IE < 9 because + // * Attributes like `name` or `type` cannot be set/changed once an element + // is inserted into a document/fragment + // * Link elements with `src` attributes that are inaccessible, as with + // a 403 response, will cause the tab/window to crash + // * Script elements appended to fragments will execute when their `src` + // or `text` property is set + return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; + } + + /** + * returns a shived DocumentFragment for the given document + * @memberOf html5 + * @param {Document} ownerDocument The context document. + * @returns {Object} The shived DocumentFragment. + */ + function createDocumentFragment(ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createDocumentFragment(); + } + data = data || getExpandoData(ownerDocument); + var clone = data.frag.cloneNode(), + i = 0, + elems = getElements(), + l = elems.length; + for(;i -1, + isOpera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, + isIE = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; + + if ( ( isWebkit || isOpera || isIE ) && document.getElementById && window.addEventListener ) { + window.addEventListener( 'hashchange', function() { + var id = location.hash.substring( 1 ), + element; + + if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { + return; + } + + element = document.getElementById( id ); + + if ( element ) { + if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { + element.tabIndex = -1; + } + + element.focus(); + + // Repositions the window on jump-to-anchor to account for admin bar and border height. + window.scrollBy( 0, -53 ); + } + }, false ); + } +} )(); diff --git a/backend/wp-content/themes/twentysixteen/page.php b/backend/wp-content/themes/twentysixteen/page.php new file mode 100644 index 0000000..315a3da --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/page.php @@ -0,0 +1,41 @@ + + +
      +
      + + +
      + + + +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/readme.txt b/backend/wp-content/themes/twentysixteen/readme.txt new file mode 100644 index 0000000..9c0cf09 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/readme.txt @@ -0,0 +1,91 @@ +=== Twenty Sixteen === +Contributors: the WordPress team +Requires at least: WordPress 4.4 +Tested up to: WordPress 5.0-trunk +Version: 1.5 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Tags: one-column, two-columns, right-sidebar, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, flexible-header, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready, blog + +== Description == +Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere. + +* Mobile-first, Responsive Layout +* Custom Colors +* Custom Header +* Social Links +* Post Formats +* The GPL v2.0 or later license. :) Use it to make something cool. + +For more information about Twenty Sixteen please go to https://codex.wordpress.org/Twenty_Sixteen. + +== Installation == + +1. In your admin panel, go to Appearance -> Themes and click the 'Add New' button. +2. Type in Twenty Sixteen in the search form and press the 'Enter' key on your keyboard. +3. Click on the 'Activate' button to use your new theme right away. +4. Go to https://codex.wordpress.org/Twenty_Sixteen for a guide on how to customize this theme. +5. Navigate to Appearance > Customize in your admin panel and customize to taste. + +== Copyright == + +Twenty Sixteen WordPress Theme, Copyright 2014-2018 WordPress.org +Twenty Sixteen is distributed under the terms of the GNU GPL + +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. + +Twenty Sixteen Theme bundles the following third-party resources: + +HTML5 Shiv v3.7.0, Copyright 2014 Alexander Farkas +Licenses: MIT/GPL2 +Source: https://github.com/aFarkas/html5shiv + +Genericons icon font, Copyright 2013-2017 Automattic.com +License: GNU GPL, Version 2 (or later) +Source: http://www.genericons.com + +Image used in screenshot.png: A photo by Austin Schmid (https://unsplash.com/schmidy/), licensed under Creative Commons Zero(http://creativecommons.org/publicdomain/zero/1.0/) + +== Changelog == + += 1.5 = +* Released: May 17, 2018 + +https://codex.wordpress.org/Twenty_Sixteen_Theme_Changelog#Version_1.5 + += 1.4 = +* Released: November 14, 2017 + +https://codex.wordpress.org/Twenty_Sixteen_Theme_Changelog#Version_1.4 + += 1.3 = +* Released: August 16, 2016 + +https://codex.wordpress.org/Twenty_Sixteen_Theme_Changelog#Version_1.3 + += 1.2 = +* Released: April 12, 2016 + +https://codex.wordpress.org/Twenty_Sixteen_Theme_Changelog#Version_1.2 + += 1.1 = +* Released: January 6, 2016 + +https://codex.wordpress.org/Twenty_Sixteen_Theme_Changelog#Version_1.1 + += 1.0 = +* Released: December 8, 2015 + +Initial release + +== Notes == + +Only the default and dark color schemes are accessibility ready. diff --git a/backend/wp-content/themes/twentysixteen/rtl.css b/backend/wp-content/themes/twentysixteen/rtl.css new file mode 100644 index 0000000..48ece28 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/rtl.css @@ -0,0 +1,756 @@ +/* +Theme Name: Twenty Sixteen +Description: Adds support for languages written in a Right To Left (RTL) direction. +It's easy, just a matter of overwriting all the horizontal positioning attributes +of your CSS stylesheet in a separate stylesheet file named rtl.css. + +See: https://codex.wordpress.org/Right_to_Left_Language_Support +*/ + +/** + * Table of Contents: + * + * 1.0 - Normalize + * 2.0 - Typography + * 3.0 - Elements + * 4.0 - Forms + * 5.0 - Navigations + * 6.0 - Accessibility + * 7.0 - Widgets + * 8.0 - Content + * 8.1 - Header + * 8.2 - Posts and pages + * 8.3 - Comments + * 8.4 - Footer + * 9.0 - Multisites + * 10.0 - Media Queries + * 10.1 - >= 710px + * 10.2 - >= 910px + * 10.3 - >= 985px + * 10.4 - >= 1200px + */ + + +/** + * 1.0 - Normalize + */ + +body { + direction: rtl; + unicode-bidi: embed; +} + +input[type="checkbox"], +input[type="radio"] { + margin-right: auto; + margin-left: 0.4375em; +} + + +/** + * 2.0 - Typography + */ + +body, +button, +button[disabled]:hover, +button[disabled]:focus, +input[type="button"], +input[type="button"][disabled]:hover, +input[type="button"][disabled]:focus, +input[type="reset"], +input[type="reset"][disabled]:hover, +input[type="reset"][disabled]:focus, +input[type="submit"], +input[type="submit"][disabled]:hover, +input[type="submit"][disabled]:focus, +input, +select, +textarea, +.post-password-form label, +.main-navigation, +.post-navigation, +.post-navigation .post-title, +.pagination, +.image-navigation, +.comment-navigation, +.site .skip-link, +.logged-in .site .skip-link, +.widget .widget-title, +.widget_recent_entries .post-date, +.widget_rss .rss-date, +.widget_rss cite, +.tagcloud a, +.site-title, +.entry-title, +.entry-footer, +.sticky-post, +.page-title, +.page-links, +.comments-title, +.comment-reply-title, +.comment-metadata, +.pingback .edit-link, +.comment-reply-link, +.comment-form label, +.no-comments, +.required, +.site-footer .site-title, +.site-footer .site-title:after, +.widecolumn label, +.widecolumn .mu_register label, +.site-footer span[role=separator] { + font-family: Arial, Tahoma, sans-serif; +} + +::-webkit-input-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +:-moz-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +::-moz-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +:-ms-input-placeholder { + font-family: Arial, Tahoma, sans-serif; +} + +blockquote { + border-right-width: 4px; + border-left-width: 0; + padding-right: 1.263157895em; + padding-left: 0; +} + +.entry-content h1, +.entry-content h2, +.entry-content h3, +.entry-content h4, +.entry-content h5, +.entry-content h6, +.entry-summary h1, +.entry-summary h2, +.entry-summary h3, +.entry-summary h4, +.entry-summary h5, +.entry-summary h6, +.comment-content h1, +.comment-content h2, +.comment-content h3, +.comment-content h4, +.comment-content h5, +.comment-content h6, +.textwidget h1, +.textwidget h2, +.textwidget h3, +.textwidget h4, +.textwidget h5, +.textwidget h6, +.entry-content .author-title, +.widget_calendar caption, +.widecolumn h2 { + font-weight: 700; +} + + +/** + * 3.0 - Elements + */ + +ul, +ol { + margin: 0 1.25em 1.75em 0; +} + +ol { + margin-right: 1.5em; + margin-left: 0; +} + +caption, +th, +td { + text-align: right; +} + + +/** + * 4.0 - Forms + */ + +input[type="search"].search-field { + border-radius: 0 2px 2px 0; +} + +.search-submit:before { + left: 1px; +} + +.search-submit { + border-radius: 2px 0 0 2px; + left: 0; + right: auto; +} + + +/** + * 5.0 - Navigation + */ + +.main-navigation ul ul { + margin-right: 0.875em; + margin-left: auto; +} + +.main-navigation .menu-item-has-children > a { + margin-right: auto; + margin-left: 56px; +} + +.dropdown-toggle { + left: 0; + right: auto; +} + +.dropdown-toggle:after { + border-right-width: 1px; + border-left-width: 0; + left: auto; + right: 1px; +} + +.social-navigation li { + float: right; + margin: 0 0 0.4375em 0.4375em; +} + +.pagination:before { + left: 0; + right: auto; +} + +.pagination:after { + left: 54px; + right: auto; +} + +.pagination .nav-links { + padding-right: 0; + padding-left: 106px; +} + +.pagination .nav-links:before { + content: "\f430"; + left: -1px; + right: auto; +} + +.pagination .nav-links:after { + content: "\f429"; + left: 55px; + right: auto; +} + +.pagination .page-numbers { + margin: 0 -0.7368421053em 0 0.7368421053em; +} + +.pagination .prev, +.pagination .next { + margin: 0; +} + +.pagination .prev { + left: 54px; + right: auto; +} + +.pagination .prev:before { + content: "\f429"; + left: auto; + right: -1px; +} + +.pagination .next { + left: 0; + right: auto; +} + +.pagination .next:before { + content: "\f430"; + left: -1px; + right: auto; +} + +.comment-navigation { + margin-right: 0; + margin-left: 0; +} + + +/** + * 6.0 - Accessibility + */ + +.site .skip-link { + left: auto; + right: -9999em; +} + +.site .skip-link:focus { + left: auto; + right: 6px; +} + + +/** + * 7.0 - Widgets + */ + +.tagcloud a { + margin-right: 0; + margin-left: 0.1875em; +} + +.tagcloud ul { + margin-right: 0; +} + + +/** + * 8.0 - Content + */ + + +/** + * 8.1 - Header + */ + +.site-branding { + margin-right: 0; + margin-left: auto; +} + + +/** + * 8.2 - Posts and pages + */ + +.author-avatar .avatar { + float: right; + margin-right: 0; + margin-left: 1.75em; +} + +.entry-footer .avatar { + margin-right: 0; + margin-left: 0.5384615385em; +} + +.page-links a, +.page-links > span { + margin-right: auto; + margin-left: 0.3076923077em; +} + +.page-links > .page-links-title { + padding-right: 0; + padding-left: 0.6153846154em; +} + +body:not(.search-results) .entry-summary .alignright { + margin: 0.2631578947em 0 1.4736842105em 1.4736842105em; +} + +body:not(.search-results) .entry-summary .alignleft { + margin: 0.2631578947em 1.4736842105em 1.4736842105em 0; +} + + +/** + * 8.3 - Comments + */ + +.comment-list .children > li { + padding-right: 0.875em; + padding-left: 0; +} + +.comment-author .avatar { + float: right; + margin-right: auto; + margin-left: 0.875em; +} + +.bypostauthor > article .fn:after { + left: auto; + right: 3px; +} + +.comment-content ul, +.comment-content ol { + margin: 0 1.25em 1.5em 0; +} + +.comment-reply-title small a { + float: left; +} + +.comment-form #wp-comment-cookies-consent { + margin: 0 0 0 10px; +} + +.comment-form .comment-form-cookies-consent label { + font-family: Arial, Tahoma, sans-serif; +} + +/** + * 9.0 - Multisites + */ + +.widecolumn .mu_register label { + margin-right: 0; + margin-left: 0.7692307692em; +} + + +/** + * 10.0 - Media Queries + */ + + +/** + * 10.1 - >= 710px + */ + +@media screen and (min-width: 44.375em) { + .pagination { + margin: 0 7.6923% 4.421052632em 23.0769%; + } + + .entry-header, + .post-thumbnail, + .entry-content, + .entry-summary, + .entry-footer, + .comments-area, + .image-navigation, + .post-navigation, + .page-header, + .page-content, + .content-bottom-widgets { + margin-right: 7.6923%; + margin-left: 23.0769%; + } + + .entry-content blockquote:not(.alignright):not(.alignleft), + .entry-summary blockquote, + .comment-content blockquote { + margin-right: -1.473684211em; + margin-left: auto; + } + + .entry-content blockquote blockquote:not(.alignright):not(.alignleft), + .entry-summary blockquote blockquote, + .comment-content blockquote blockquote { + margin-right: 0; + margin-left: auto; + } + + .entry-content ul, + .entry-summary ul, + .comment-content ul, + .entry-content ol, + .entry-summary ol, + .comment-content ol { + margin-right: 0; + margin-left: auto; + } + + .entry-content li > ul, + .entry-summary li > ul, + .comment-content li > ul, + .entry-content blockquote > ul, + .entry-summary blockquote > ul, + .comment-content blockquote > ul { + margin-right: 1.25em; + margin-left: auto; + } + + .entry-content li > ol, + .entry-summary li > ol, + .comment-content li > ol, + .entry-content blockquote > ol, + .entry-summary blockquote > ol, + .comment-content blockquote > ol { + margin-right: 1.5em; + margin-left: auto; + } + + .comment-list .children > li { + padding-right: 1.75em; + padding-left: 0; + } + + .sidebar, + .widecolumn { + padding-right: 7.6923%; + padding-left: 23.0769%; + } + + body:not(.search-results) .entry-summary li > ul, + body:not(.search-results) .entry-summary blockquote > ul { + margin-right: 1.157894737em; + margin-left: auto; + } + + body:not(.search-results) .entry-summary li > ol, + body:not(.search-results) .entry-summary blockquote > ol { + margin-right: 1.473684211em; + margin-left: auto; + } +} + + +/** + * 10.2 - >= 910px + */ + +@media screen and (min-width: 56.875em) { + .main-navigation .primary-menu > li { + float: right; + } + + .main-navigation ul ul { + left: auto; + margin: 0; + right: -999em; + } + + .main-navigation ul ul:before { + left: 9px; + right: auto; + } + + .main-navigation ul ul:after { + left: 11px; + right: auto; + } + + .main-navigation li:hover > ul, + .main-navigation li.focus > ul { + left: 0; + right: auto; + } + + .main-navigation ul ul li:hover > ul, + .main-navigation ul ul li.focus > ul { + left: 100%; + right: auto; + } + + .main-navigation .menu-item-has-children > a { + margin: 0; + padding-right: 0.875em; + padding-left: 2.25em; + } + + .main-navigation .menu-item-has-children > a:after { + left: 0.625em; + right: auto; + } + + .main-navigation ul ul .menu-item-has-children > a { + padding-right: 0.875em; + padding-left: 2.0625em; + } + + .main-navigation ul ul .menu-item-has-children > a:after { + left: 0.5625em; + right: auto; + top: 0.8125em; + -webkit-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); + -ms-transform: rotate(-90deg); + transform: rotate(-90deg); + } + + .content-area { + float: right; + margin-right: auto; + margin-left: -100%; + } + + .entry-header, + .post-thumbnail, + .entry-content, + .entry-summary, + .entry-footer, + .comments-area, + .image-navigation, + .post-navigation, + .pagination, + .page-header, + .page-content, + .content-bottom-widgets { + margin-right: 0; + margin-left: 0; + } + + .sidebar { + float: right; + margin-right: 75%; + margin-left: auto; + padding: 0; + } + + .widget blockquote { + padding-right: 1.0625em; + padding-left: 0; + } + + .widget .alignright { + margin: 0.2307692308em 0 1.6153846154em 1.6153846154em; + } + + .widget .alignleft { + margin: 0.2307692308em 1.6153846154em 1.6153846154em 0; + } + + .tagcloud a { + margin: 0 0 0.5384615385em 0.2307692308em; + } + + .content-bottom-widgets .widget-area:nth-child(1):nth-last-child(2), + .content-bottom-widgets .widget-area:nth-child(2):nth-last-child(1) { + float: right; + margin-right: auto; + margin-left: 7.1428571%; + } + + .content-bottom-widgets .widget-area:nth-child(2):nth-last-child(1):last-of-type { + margin-right: auto; + margin-left: 0; + } + + .site-info { + margin: 0.538461538em 0 0.538461538em auto; + } + + .no-sidebar .entry-header, + .no-sidebar .entry-content, + .no-sidebar .entry-summary, + .no-sidebar .entry-footer, + .no-sidebar .comments-area, + .no-sidebar .image-navigation, + .no-sidebar .post-navigation, + .no-sidebar .pagination, + .no-sidebar .page-header, + .no-sidebar .page-content, + .no-sidebar .content-bottom-widgets { + margin-right: 15%; + margin-left: 15%; + } + + .no-sidebar .post-thumbnail { + margin-right: 0; + margin-left: 0; + } + + .widecolumn { + padding-right: 15%; + padding-left: 15%; + } +} + + +/** + * 10.3 - >= 985px + */ + +@media screen and (min-width: 61.5625em) { + body:not(.search-results) article:not(.type-page) .entry-content { + float: left; + } + + body:not(.search-results) article:not(.type-page) .entry-content > blockquote.alignleft.below-entry-meta { + margin-right: 1.473684211em; + margin-left: 0; + width: -webkit-calc(50% - 0.736842105em); + width: calc(50% - 0.736842105em);; + } + + body:not(.search-results) article:not(.type-page) .entry-content > blockquote.alignright.below-entry-meta { + margin-right: -40%; + margin-left: 1.473684211em; + width: -webkit-calc(60% - 1.4736842105em); + width: calc(60% - 1.4736842105em); + } + + body:not(.search-results) article:not(.type-page) img.below-entry-meta, + body:not(.search-results) article:not(.type-page) figure.below-entry-meta { + margin-right: -40%; + margin-left: 0; + } + + body:not(.search-results) article:not(.type-page) .entry-footer { + float: right; + } + + body.no-sidebar:not(.search-results) article:not(.type-page) .entry-content { + float: right; + margin-right: 34.99999999%; + margin-left: -100%; + } + + body.no-sidebar:not(.search-results) article:not(.type-page) .entry-footer { + margin-right: 15%; + margin-left: -100%; + } +} + + +/** + * 10.4 - >= 1200px + */ + +@media screen and (min-width: 75em) { + body:not(.search-results) .entry-summary li > ul, + body:not(.search-results) .entry-summary blockquote > ul { + margin-right: 0.956521739em; + margin-left: auto; + } + + body:not(.search-results) .entry-summary li > ol, + body:not(.search-results) .entry-summary blockquote > ol { + margin-right: 1.52173913em; + margin-left: auto; + } + + body:not(.search-results) .entry-summary blockquote { + padding-right: 1.347826087em; + padding-left: 0; + } + + body:not(.search-results) .entry-summary blockquote:not(.alignright):not(.alignleft) { + margin-right: -1.52173913em; + margin-left: auto; + } + + body:not(.search-results) .entry-summary blockquote blockquote:not(.alignright):not(.alignleft) { + margin-right: 0; + margin-left: auto; + } + + body:not(.search-results) .entry-summary .alignright { + margin: 0.2608695652em 0 1.5217391304em 1.5217391304em; + } + + body:not(.search-results) .entry-summary .alignleft { + margin: 0.2608695652em 1.5217391304em 1.5217391304em 0; + } +} diff --git a/backend/wp-content/themes/twentysixteen/screenshot.png b/backend/wp-content/themes/twentysixteen/screenshot.png new file mode 100644 index 0000000..e4f2b25 Binary files /dev/null and b/backend/wp-content/themes/twentysixteen/screenshot.png differ diff --git a/backend/wp-content/themes/twentysixteen/search.php b/backend/wp-content/themes/twentysixteen/search.php new file mode 100644 index 0000000..4180b5f --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/search.php @@ -0,0 +1,53 @@ + + +
      +
      + + + + + + __( 'Previous page', 'twentysixteen' ), + 'next_text' => __( 'Next page', 'twentysixteen' ), + 'before_page_number' => '' . __( 'Page', 'twentysixteen' ) . ' ', + ) ); + + // If no content, include the "No posts found" template. + else : + get_template_part( 'template-parts/content', 'none' ); + + endif; + ?> + +
      +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/searchform.php b/backend/wp-content/themes/twentysixteen/searchform.php new file mode 100644 index 0000000..c2f83af --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/searchform.php @@ -0,0 +1,17 @@ + + + diff --git a/backend/wp-content/themes/twentysixteen/sidebar-content-bottom.php b/backend/wp-content/themes/twentysixteen/sidebar-content-bottom.php new file mode 100644 index 0000000..d561eb7 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/sidebar-content-bottom.php @@ -0,0 +1,28 @@ + + diff --git a/backend/wp-content/themes/twentysixteen/sidebar.php b/backend/wp-content/themes/twentysixteen/sidebar.php new file mode 100644 index 0000000..d4d893e --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/sidebar.php @@ -0,0 +1,15 @@ + + + + + diff --git a/backend/wp-content/themes/twentysixteen/single.php b/backend/wp-content/themes/twentysixteen/single.php new file mode 100644 index 0000000..07e0df2 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/single.php @@ -0,0 +1,54 @@ + + +
      +
      + _x( 'Published in%title', 'Parent post link', 'twentysixteen' ), + ) ); + } elseif ( is_singular( 'post' ) ) { + // Previous/next post navigation. + the_post_navigation( array( + 'next_text' => ' ' . + '' . __( 'Next post:', 'twentysixteen' ) . ' ' . + '%title', + 'prev_text' => ' ' . + '' . __( 'Previous post:', 'twentysixteen' ) . ' ' . + '%title', + ) ); + } + + // End of the loop. + endwhile; + ?> + +
      + + + +
      + + + diff --git a/backend/wp-content/themes/twentysixteen/style.css b/backend/wp-content/themes/twentysixteen/style.css new file mode 100644 index 0000000..aacb880 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/style.css @@ -0,0 +1,4008 @@ +/* +Theme Name: Twenty Sixteen +Theme URI: https://wordpress.org/themes/twentysixteen/ +Author: the WordPress team +Author URI: https://wordpress.org/ +Description: Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly for blogs and websites. It has custom color options with beautiful default color schemes, a harmonious fluid grid using a mobile-first approach, and impeccable polish in every detail. Twenty Sixteen will make your WordPress look beautiful everywhere. +Version: 1.5 +License: GNU General Public License v2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Tags: one-column, two-columns, right-sidebar, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, flexible-header, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready, blog +Text Domain: twentysixteen + +This theme, like WordPress, is licensed under the GPL. +Use it to make something cool, have fun, and share what you've learned with others. +*/ + + +/** + * Table of Contents + * + * 1.0 - Normalize + * 2.0 - Genericons + * 3.0 - Typography + * 4.0 - Elements + * 5.0 - Forms + * 6.0 - Navigation + * 6.1 - Links + * 6.2 - Menus + * 7.0 - Accessibility + * 8.0 - Alignments + * 9.0 - Clearings + * 10.0 - Widgets + * 11.0 - Content + * 11.1 - Header + * 11.2 - Posts and pages + * 11.3 - Post Formats + * 11.4 - Comments + * 11.5 - Sidebar + * 11.6 - Footer + * 12.0 - Media + * 12.1 - Captions + * 12.2 - Galleries + * 13.0 - Multisite + * 14.0 - Media Queries + * 14.1 - >= 710px + * 14.2 - >= 783px + * 14.3 - >= 910px + * 14.4 - >= 985px + * 14.5 - >= 1200px + * 15.0 - Print + */ + + +/** + * 1.0 - Normalize + * + * Normalizing styles have been helped along thanks to the fine work of + * Nicolas Gallagher and Jonathan Neal http://necolas.github.com/normalize.css/ + */ + +html { + font-family: sans-serif; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} + +body { + margin: 0; +} + +article, +aside, +details, +figcaption, +figure, +footer, +header, +main, +menu, +nav, +section, +summary { + display: block; +} + +audio, +canvas, +progress, +video { + display: inline-block; + vertical-align: baseline; +} + +audio:not([controls]) { + display: none; + height: 0; +} + +[hidden], +template { + display: none; +} + +a { + background-color: transparent; +} + +abbr[title] { + border-bottom: 1px dotted; +} + +b, +strong { + font-weight: 700; +} + +small { + font-size: 80%; +} + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +img { + border: 0; +} + +svg:not(:root) { + overflow: hidden; +} + +figure { + margin: 0; +} + +hr { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +code, +kbd, +pre, +samp { + font-size: 1em; +} + +button, +input, +optgroup, +select, +textarea { + color: inherit; + font: inherit; + margin: 0; +} + +select { + text-transform: none; +} + +button { + overflow: visible; +} + +button, +input, +select, +textarea { + max-width: 100%; +} + +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; + cursor: pointer; +} + +button[disabled], +html input[disabled] { + cursor: default; + opacity: .5; +} + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +input[type="checkbox"], +input[type="radio"] { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + margin-right: 0.4375em; + padding: 0; +} + +input[type="date"]::-webkit-inner-spin-button, +input[type="date"]::-webkit-outer-spin-button, +input[type="time"]::-webkit-inner-spin-button, +input[type="time"]::-webkit-outer-spin-button, +input[type="datetime-local"]::-webkit-inner-spin-button, +input[type="datetime-local"]::-webkit-outer-spin-button, +input[type="week"]::-webkit-inner-spin-button, +input[type="week"]::-webkit-outer-spin-button, +input[type="month"]::-webkit-inner-spin-button, +input[type="month"]::-webkit-outer-spin-button, +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +input[type="search"] { + -webkit-appearance: textfield; +} + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +fieldset { + border: 1px solid #d1d1d1; + margin: 0 0 1.75em; + min-width: inherit; + padding: 0.875em; +} + +fieldset > :last-child { + margin-bottom: 0; +} + +legend { + border: 0; + padding: 0; +} + +textarea { + overflow: auto; + vertical-align: top; +} + +optgroup { + font-weight: bold; +} + + +/** + * 2.0 - Genericons + */ + +.menu-item-has-children a:after, +.social-navigation a:before, +.dropdown-toggle:after, +.bypostauthor > article .fn:after, +.comment-reply-title small a:before, +.pagination .prev:before, +.pagination .next:before, +.pagination .nav-links:before, +.pagination .nav-links:after, +.search-submit:before { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + display: inline-block; + font-family: "Genericons"; + font-size: 16px; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: 1; + speak: none; + text-align: center; + text-decoration: inherit; + text-transform: none; + vertical-align: top; +} + + +/** + * 3.0 - Typography + */ + +body, +button, +input, +select, +textarea { + color: #1a1a1a; + font-family: Merriweather, Georgia, serif; + font-size: 16px; + font-size: 1rem; + line-height: 1.75; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + clear: both; + font-weight: 700; + margin: 0; + text-rendering: optimizeLegibility; +} + +p { + margin: 0 0 1.75em; +} + +dfn, +cite, +em, +i { + font-style: italic; +} + +blockquote { + border: 0 solid #1a1a1a; + border-left-width: 4px; + color: #686868; + font-size: 19px; + font-size: 1.1875rem; + font-style: italic; + line-height: 1.4736842105; + margin: 0 0 1.4736842105em; + overflow: hidden; + padding: 0 0 0 1.263157895em; +} + +blockquote, +q { + quotes: none; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; +} + +blockquote p { + margin-bottom: 1.4736842105em; +} + +blockquote cite, +blockquote small { + color: #1a1a1a; + display: block; + font-size: 16px; + font-size: 1rem; + line-height: 1.75; +} + +blockquote cite:before, +blockquote small:before { + content: "\2014\00a0"; +} + +blockquote em, +blockquote i, +blockquote cite { + font-style: normal; +} + +blockquote strong, +blockquote b { + font-weight: 400; +} + +blockquote > :last-child { + margin-bottom: 0; +} + +address { + font-style: italic; + margin: 0 0 1.75em; +} + +code, +kbd, +tt, +var, +samp, +pre { + font-family: Inconsolata, monospace; +} + +pre { + border: 1px solid #d1d1d1; + font-size: 16px; + font-size: 1rem; + line-height: 1.3125; + margin: 0 0 1.75em; + max-width: 100%; + overflow: auto; + padding: 1.75em; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +code { + background-color: #d1d1d1; + padding: 0.125em 0.25em; +} + +abbr, +acronym { + border-bottom: 1px dotted #d1d1d1; + cursor: help; +} + +mark, +ins { + background: #007acc; + color: #fff; + padding: 0.125em 0.25em; + text-decoration: none; +} + +big { + font-size: 125%; +} + + +/** + * 4.0 - Elements + */ + +html { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +*, +*:before, +*:after { + /* Inherit box-sizing to make it easier to change the property for components that leverage other behavior; see http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */ + -webkit-box-sizing: inherit; + -moz-box-sizing: inherit; + box-sizing: inherit; +} + +body { + background: #1a1a1a; + /* Fallback for when there is no custom background color defined. */ +} + +hr { + background-color: #d1d1d1; + border: 0; + height: 1px; + margin: 0 0 1.75em; +} + +ul, +ol { + margin: 0 0 1.75em 1.25em; + padding: 0; +} + +ul { + list-style: disc; +} + +ol { + list-style: decimal; + margin-left: 1.5em; +} + +li > ul, +li > ol { + margin-bottom: 0; +} + +dl { + margin: 0 0 1.75em; +} + +dt { + font-weight: 700; +} + +dd { + margin: 0 0 1.75em; +} + +img { + height: auto; + /* Make sure images are scaled correctly. */ + max-width: 100%; + /* Adhere to container width. */ + vertical-align: middle; +} + +del { + opacity: 0.8; +} + +table, +th, +td { + border: 1px solid #d1d1d1; +} + +table { + border-collapse: separate; + border-spacing: 0; + border-width: 1px 0 0 1px; + margin: 0 0 1.75em; + table-layout: fixed; + /* Prevents HTML tables from becoming too wide */ + width: 100%; +} + +caption, +th, +td { + font-weight: normal; + text-align: left; +} + +th { + border-width: 0 1px 1px 0; + font-weight: 700; +} + +td { + border-width: 0 1px 1px 0; +} + +th, +td { + padding: 0.4375em; +} + +/* Placeholder text color -- selectors need to be separate to work. */ +::-webkit-input-placeholder { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; +} + +:-moz-placeholder { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; +} + +::-moz-placeholder { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; + opacity: 1; + /* Since FF19 lowers the opacity of the placeholder by default */ +} + +:-ms-input-placeholder { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; +} + + +/** + * 5.0 - Forms + */ + +input { + line-height: normal; +} + +button, +button[disabled]:hover, +button[disabled]:focus, +input[type="button"], +input[type="button"][disabled]:hover, +input[type="button"][disabled]:focus, +input[type="reset"], +input[type="reset"][disabled]:hover, +input[type="reset"][disabled]:focus, +input[type="submit"], +input[type="submit"][disabled]:hover, +input[type="submit"][disabled]:focus { + background: #1a1a1a; + border: 0; + border-radius: 2px; + color: #fff; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-weight: 700; + letter-spacing: 0.046875em; + line-height: 1; + padding: 0.84375em 0.875em 0.78125em; + text-transform: uppercase; +} + +button:hover, +button:focus, +input[type="button"]:hover, +input[type="button"]:focus, +input[type="reset"]:hover, +input[type="reset"]:focus, +input[type="submit"]:hover, +input[type="submit"]:focus { + background: #007acc; +} + +button:focus, +input[type="button"]:focus, +input[type="reset"]:focus, +input[type="submit"]:focus { + outline: thin dotted; + outline-offset: -4px; +} + +input[type="date"], +input[type="time"], +input[type="datetime-local"], +input[type="week"], +input[type="month"], +input[type="text"], +input[type="email"], +input[type="url"], +input[type="password"], +input[type="search"], +input[type="tel"], +input[type="number"], +textarea { + background: #f7f7f7; + background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0)); + border: 1px solid #d1d1d1; + border-radius: 2px; + color: #686868; + padding: 0.625em 0.4375em; + width: 100%; +} + +input[type="date"]:focus, +input[type="time"]:focus, +input[type="datetime-local"]:focus, +input[type="week"]:focus, +input[type="month"]:focus, +input[type="text"]:focus, +input[type="email"]:focus, +input[type="url"]:focus, +input[type="password"]:focus, +input[type="search"]:focus, +input[type="tel"]:focus, +input[type="number"]:focus, +textarea:focus { + background-color: #fff; + border-color: #007acc; + color: #1a1a1a; + outline: 0; +} + +.post-password-form { + margin-bottom: 1.75em; +} + +.post-password-form label { + color: #686868; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + letter-spacing: 0.076923077em; + line-height: 1.6153846154; + margin-bottom: 1.75em; + text-transform: uppercase; +} + +.post-password-form input[type="password"] { + margin-top: 0.4375em; +} + +.post-password-form > :last-child { + margin-bottom: 0; +} + +.search-form { + position: relative; +} + +input[type="search"].search-field { + border-radius: 2px 0 0 2px; + width: -webkit-calc(100% - 42px); + width: calc(100% - 42px); +} + +.search-submit:before { + content: "\f400"; + font-size: 24px; + left: 2px; + line-height: 42px; + position: relative; + width: 40px; +} + +.search-submit { + border-radius: 0 2px 2px 0; + bottom: 0; + overflow: hidden; + padding: 0; + position: absolute; + right: 0; + top: 0; + width: 42px; +} + + +/** + * 6.0 - Navigation + */ + +/** + * 6.1 - Links + */ + +a { + color: #007acc; + text-decoration: none; +} + +a:hover, +a:focus, +a:active { + color: #686868; +} + +a:focus { + outline: thin dotted; +} + +a:hover, +a:active { + outline: 0; +} + +.entry-content a, +.entry-summary a, +.taxonomy-description a, +.logged-in-as a, +.comment-content a, +.pingback .comment-body > a, +.textwidget a, +.entry-footer a:hover, +.site-info a:hover { + box-shadow: 0 1px 0 0 currentColor; +} + +.entry-content a:hover, +.entry-content a:focus, +.entry-summary a:hover, +.entry-summary a:focus, +.taxonomy-description a:hover, +.taxonomy-description a:focus, +.logged-in-as a:hover, +.logged-in-as a:focus, +.comment-content a:hover, +.comment-content a:focus, +.pingback .comment-body > a:hover, +.pingback .comment-body > a:focus, +.textwidget a:hover, +.textwidget a:focus { + box-shadow: none; +} + + +/** + * 6.2 - Menus + */ + +.site-header-menu { + display: none; + -webkit-flex: 0 1 100%; + -ms-flex: 0 1 100%; + flex: 0 1 100%; + margin: 0.875em 0; +} + +.site-header-menu.toggled-on, +.no-js .site-header-menu { + display: block; +} + +.main-navigation { + font-family: Montserrat, "Helvetica Neue", sans-serif; +} + +.site-footer .main-navigation { + margin-bottom: 1.75em; +} + +.main-navigation ul { + list-style: none; + margin: 0; +} + +.main-navigation li { + border-top: 1px solid #d1d1d1; + position: relative; +} + +.main-navigation a { + color: #1a1a1a; + display: block; + line-height: 1.3125; + outline-offset: -1px; + padding: 0.84375em 0; +} + +.main-navigation a:hover, +.main-navigation a:focus { + color: #007acc; +} + +.main-navigation .current-menu-item > a, +.main-navigation .current-menu-ancestor > a { + font-weight: 700; +} + +.main-navigation ul ul { + display: none; + margin-left: 0.875em; +} + +.no-js .main-navigation ul ul { + display: block; +} + +.main-navigation ul .toggled-on { + display: block; +} + +.main-navigation .primary-menu { + border-bottom: 1px solid #d1d1d1; +} + +.main-navigation .menu-item-has-children > a { + margin-right: 56px; +} + +.dropdown-toggle { + background-color: transparent; + border: 0; + border-radius: 0; + color: #1a1a1a; + content: ""; + height: 48px; + padding: 0; + position: absolute; + right: 0; + text-transform: none; + top: 0; + width: 48px; +} + +.dropdown-toggle:after { + border: 0 solid #d1d1d1; + border-left-width: 1px; + content: "\f431"; + font-size: 24px; + left: 1px; + position: relative; + width: 48px; +} + +.dropdown-toggle:hover, +.dropdown-toggle:focus { + background-color: transparent; + color: #007acc; +} + +.dropdown-toggle:focus { + outline: thin dotted; + outline-offset: -1px; +} + +.dropdown-toggle:focus:after { + border-color: transparent; +} + +.dropdown-toggle.toggled-on:after { + content: "\f432"; +} + +.site-header .main-navigation + .social-navigation { + margin-top: 1.75em; +} + +.site-footer .social-navigation { + margin-bottom: 1.75em; +} + +.social-navigation ul { + list-style: none; + margin: 0 0 -0.4375em; +} + +.social-navigation li { + float: left; + margin: 0 0.4375em 0.4375em 0; +} + +.social-navigation a { + border: 1px solid #d1d1d1; + border-radius: 50%; + color: #1a1a1a; + display: block; + height: 35px; + position: relative; + width: 35px; +} + +.social-navigation a:before { + content: "\f415"; + height: 33px; + line-height: 33px; + text-align: center; + width: 33px; +} + +.social-navigation a:hover:before, +.social-navigation a:focus:before { + color: #007acc; +} + +.social-navigation a[href*="codepen.io"]:before { + content: "\f216"; +} + +.social-navigation a[href*="digg.com"]:before { + content: "\f221"; +} + +.social-navigation a[href*="dribbble.com"]:before { + content: "\f201"; +} + +.social-navigation a[href*="dropbox.com"]:before { + content: "\f225"; +} + +.social-navigation a[href*="facebook.com"]:before { + content: "\f203"; +} + +.social-navigation a[href*="flickr.com"]:before { + content: "\f211"; +} + +.social-navigation a[href*="foursquare.com"]:before { + content: "\f226"; +} + +.social-navigation a[href*="plus.google.com"]:before { + content: "\f206"; +} + +.social-navigation a[href*="github.com"]:before { + content: "\f200"; +} + +.social-navigation a[href*="instagram.com"]:before { + content: "\f215"; +} + +.social-navigation a[href*="linkedin.com"]:before { + content: "\f208"; +} + +.social-navigation a[href*="path.com"]:before { + content: "\f219"; +} + +.social-navigation a[href*="pinterest.com"]:before { + content: "\f210"; +} + +.social-navigation a[href*="getpocket.com"]:before { + content: "\f224"; +} + +.social-navigation a[href*="polldaddy.com"]:before { + content: "\f217"; +} + +.social-navigation a[href*="reddit.com"]:before { + content: "\f222"; +} + +.social-navigation a[href*="skype.com"]:before { + content: "\f220"; +} + +.social-navigation a[href*="stumbleupon.com"]:before { + content: "\f223"; +} + +.social-navigation a[href*="tumblr.com"]:before { + content: "\f214"; +} + +.social-navigation a[href*="twitter.com"]:before { + content: "\f202"; +} + +.social-navigation a[href*="vimeo.com"]:before { + content: "\f212"; +} + +.social-navigation a[href*="wordpress.com"]:before, +.social-navigation a[href*="wordpress.org"]:before { + content: "\f205"; +} + +.social-navigation a[href*="youtube.com"]:before { + content: "\f213"; +} + +.social-navigation a[href^="mailto:"]:before { + content: "\f410"; +} + +.social-navigation a[href*="spotify.com"]:before { + content: "\f515"; +} + +.social-navigation a[href*="twitch.tv"]:before { + content: "\f516"; +} + +.social-navigation a[href$="/feed/"]:before { + content: "\f413"; +} + +.post-navigation { + border-top: 4px solid #1a1a1a; + border-bottom: 4px solid #1a1a1a; + clear: both; + font-family: Montserrat, "Helvetica Neue", sans-serif; + margin: 0 7.6923% 3.5em; +} + +.post-navigation a { + color: #1a1a1a; + display: block; + padding: 1.75em 0; +} + +.post-navigation span { + display: block; +} + +.post-navigation .meta-nav { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + letter-spacing: 0.076923077em; + line-height: 1.6153846154; + margin-bottom: 0.5384615385em; + text-transform: uppercase; +} + +.post-navigation .post-title { + display: inline; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 23px; + font-size: 1.4375rem; + font-weight: 700; + line-height: 1.2173913043; + text-rendering: optimizeLegibility; +} + +.post-navigation a:hover .post-title, +.post-navigation a:focus .post-title { + color: #007acc; +} + +.post-navigation div + div { + border-top: 4px solid #1a1a1a; +} + +.pagination { + border-top: 4px solid #1a1a1a; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 19px; + font-size: 1.1875rem; + margin: 0 7.6923% 2.947368421em; + min-height: 56px; + position: relative; +} + +.pagination:before, +.pagination:after { + background-color: #1a1a1a; + content: ""; + height: 52px; + position: absolute; + top:0; + width: 52px; + z-index: 0; +} + +.pagination:before { + right: 0; +} + +.pagination:after { + right: 54px; +} + +.pagination a:hover, +.pagination a:focus { + color: #1a1a1a; +} + +.pagination .nav-links { + padding-right: 106px; + position: relative; +} + +.pagination .nav-links:before, +.pagination .nav-links:after { + color: #fff; + font-size: 32px; + line-height: 51px; + opacity: 0.3; + position: absolute; + width: 52px; + z-index: 1; +} + +.pagination .nav-links:before { + content: "\f429"; + right: -1px; +} + +.pagination .nav-links:after { + content: "\f430"; + right: 55px; +} + +/* reset screen-reader-text */ +.pagination .current .screen-reader-text { + position: static !important; +} + +.pagination .page-numbers { + display: none; + letter-spacing: 0.013157895em; + line-height: 1; + margin: 0 0.7368421053em 0 -0.7368421053em; + padding: 0.8157894737em 0.7368421053em 0.3947368421em; + text-transform: uppercase; +} + +.pagination .current { + display: inline-block; + font-weight: 700; +} + +.pagination .prev, +.pagination .next { + background-color: #1a1a1a; + color: #fff; + display: inline-block; + height: 52px; + margin: 0; + overflow: hidden; + padding: 0; + position: absolute; + top: 0; + width: 52px; + z-index: 2; +} + +.pagination .prev:before, +.pagination .next:before { + font-size: 32px; + height: 53px; + line-height: 52px; + position: relative; + width: 53px; +} + +.pagination .prev:hover, +.pagination .prev:focus, +.pagination .next:hover, +.pagination .next:focus { + background-color: #007acc; + color: #fff; +} + +.pagination .prev:focus, +.pagination .next:focus { + outline: 0; +} + +.pagination .prev { + right: 54px; +} + +.pagination .prev:before { + content: "\f430"; + left: -1px; + top: -1px; +} + +.pagination .next { + right: 0; +} + +.pagination .next:before { + content: "\f429"; + right: -1px; + top: -1px; +} + +.image-navigation, +.comment-navigation { + border-top: 1px solid #d1d1d1; + border-bottom: 1px solid #d1d1d1; + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin: 0 7.6923% 2.1538461538em; + padding: 1.0769230769em 0; +} + +.comment-navigation { + margin-right: 0; + margin-left: 0; +} + +.comments-title + .comment-navigation { + border-bottom: 0; + margin-bottom: 0; +} + +.image-navigation .nav-previous:not(:empty), +.image-navigation .nav-next:not(:empty), +.comment-navigation .nav-previous:not(:empty), +.comment-navigation .nav-next:not(:empty) { + display: inline-block; +} + +.image-navigation .nav-previous:not(:empty) + .nav-next:not(:empty):before, +.comment-navigation .nav-previous:not(:empty) + .nav-next:not(:empty):before { + content: "\002f"; + display: inline-block; + opacity: 0.7; + padding: 0 0.538461538em; +} + + +/** + * 7.0 - Accessibility + */ + +/* Text meant only for screen readers */ +.says, +.screen-reader-text { + clip: rect(1px, 1px, 1px, 1px); + height: 1px; + overflow: hidden; + position: absolute !important; + width: 1px; + /* many screen reader and browser combinations announce broken words as they would appear visually */ + word-wrap: normal !important; +} + +/* must have higher specificity than alternative color schemes inline styles */ +.site .skip-link { + background-color: #f1f1f1; + box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2); + color: #21759b; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 14px; + font-weight: 700; + left: -9999em; + outline: none; + padding: 15px 23px 14px; + text-decoration: none; + text-transform: none; + top: -9999em; +} + +.logged-in .site .skip-link { + box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.2); + font-family: "Open Sans", sans-serif; +} + +.site .skip-link:focus { + clip: auto; + height: auto; + left: 6px; + top: 7px; + width: auto; + z-index: 100000; +} + + +/** + * 8.0 - Alignments + */ + +.alignleft { + float: left; + margin: 0.375em 1.75em 1.75em 0; +} + +.alignright { + float: right; + margin: 0.375em 0 1.75em 1.75em; +} + +.aligncenter { + clear: both; + display: block; + margin: 0 auto 1.75em; +} + +blockquote.alignleft { + margin: 0.3157894737em 1.4736842105em 1.473684211em 0; +} + +blockquote.alignright { + margin: 0.3157894737em 0 1.473684211em 1.4736842105em; +} + +blockquote.aligncenter { + margin-bottom: 1.473684211em; +} + + +/** + * 9.0 - Clearings + */ + +.clear:before, +.clear:after, +blockquote:before, +blockquote:after, +.entry-content:before, +.entry-content:after, +.entry-summary:before, +.entry-summary:after, +.comment-content:before, +.comment-content:after, +.site-content:before, +.site-content:after, +.site-main > article:before, +.site-main > article:after, +.primary-menu:before, +.primary-menu:after, +.social-links-menu:before, +.social-links-menu:after, +.textwidget:before, +.textwidget:after, +.content-bottom-widgets:before, +.content-bottom-widgets:after { + content: ""; + display: table; +} + +.clear:after, +blockquote:after, +.entry-content:after, +.entry-summary:after, +.comment-content:after, +.site-content:after, +.site-main > article:after, +.primary-menu:after, +.social-links-menu:after, +.textwidget:after, +.content-bottom-widgets:after { + clear: both; +} + + +/** + * 10.0 - Widgets + */ + +.widget { + border-top: 4px solid #1a1a1a; + margin-bottom: 3.5em; + padding-top: 1.75em; +} + +.widget-area > :last-child, +.widget > :last-child { + margin-bottom: 0; +} + +.widget .widget-title { + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 16px; + font-size: 1rem; + letter-spacing: 0.046875em; + line-height: 1.3125; + margin: 0 0 1.75em; + text-transform: uppercase; +} + +.widget .widget-title:empty { + margin-bottom: 0; +} + +.widget-title a { + color: #1a1a1a; +} + +/* Calendar widget */ +.widget.widget_calendar table { + margin: 0; +} + +.widget_calendar td, +.widget_calendar th { + line-height: 2.5625; + padding: 0; + text-align: center; +} + +.widget_calendar caption { + font-weight: 900; + margin-bottom: 1.75em; +} + +.widget_calendar tbody a { + background-color: #007acc; + color: #fff; + display: block; + font-weight: 700; +} + +.widget_calendar tbody a:hover, +.widget_calendar tbody a:focus { + background-color: #686868; + color: #fff; +} + +/* Recent Posts widget */ +.widget_recent_entries .post-date { + color: #686868; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.615384615; + margin-bottom: 0.538461538em; +} + +.widget_recent_entries li:last-child .post-date { + margin-bottom: 0; +} + +/* RSS widget */ +.widget_rss .rsswidget img { + margin-top: -0.375em; +} + +.widget_rss .rss-date, +.widget_rss cite { + color: #686868; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + font-style: normal; + line-height: 1.615384615; + margin-bottom: 0.538461538em; +} + +.widget_rss .rssSummary:last-child { + margin-bottom: 2.1538461538em; +} + +.widget_rss li:last-child :last-child { + margin-bottom: 0; +} + +/* Tag Cloud widget */ +.tagcloud a { + border: 1px solid #d1d1d1; + border-radius: 2px; + display: inline-block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + line-height: 1; + margin: 0 0.1875em 0.4375em 0; + padding: 0.5625em 0.4375em 0.5em; +} + +.tagcloud ul { + list-style-type: none; + margin-left: 0; +} + +.tagcloud ul li { + display: inline-block; +} + +.tagcloud a:hover, +.tagcloud a:focus { + border-color: #007acc; + color: #007acc; + outline: 0; +} + + +/** + * 11.0 - Content + */ + +.site { + background-color: #fff; +} + +.site-inner { + margin: 0 auto; + max-width: 1320px; + position: relative; +} + +.site-content { + word-wrap: break-word; +} + +/* Do not show the outline on the skip link target. */ +#content[tabindex="-1"]:focus { + outline: 0; +} + +.site-main { + margin-bottom: 3.5em; +} + +.site-main > :last-child { + margin-bottom: 0; +} + + +/** + * 11.1 - Header + */ + +.site-header { + padding: 2.625em 7.6923%; +} + +.site-header-main { + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; +} + +.site-branding { + margin: 0.875em auto 0.875em 0; + /* Avoid overflowing wide custom logo in small screens in Firefox and IEs */ + max-width: 100%; + min-width: 0; + overflow: hidden; +} + +.custom-logo-link { + display: block; +} + +.custom-logo { + max-width: 180px; +} + +.site-title { + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 23px; + font-size: 1.4375rem; + font-weight: 700; + line-height: 1.2173913043; + margin: 0; +} + +.site-branding .site-title a { + color: #1a1a1a; +} + +.site-branding .site-title a:hover, +.site-branding .site-title a:focus { + color: #007acc; +} + +.wp-custom-logo .site-title { + margin-top: 0.608695652em; +} + +.site-description { + color: #686868; + display: none; + font-size: 13px; + font-size: 0.8125rem; + font-weight: 400; + line-height: 1.0769230769; + margin: 0.538461538em 0 0; +} + +.menu-toggle { + background-color: transparent; + border: 1px solid #d1d1d1; + color: #1a1a1a; + font-size: 13px; + font-size: 0.8125rem; + margin: 1.076923077em 0; + padding: 0.769230769em; +} + +.no-js .menu-toggle { + display: none; +} + +.menu-toggle:hover, +.menu-toggle:focus { + background-color: transparent; + border-color: #007acc; + color: #007acc; +} + +.menu-toggle.toggled-on, +.menu-toggle.toggled-on:hover, +.menu-toggle.toggled-on:focus { + background-color: #1a1a1a; + border-color: #1a1a1a; + color: #fff; +} + +.menu-toggle:focus { + outline: 0; +} + +.menu-toggle.toggled-on:focus { + outline: thin dotted; +} + +.header-image { + clear: both; + margin: 0.875em 0; +} + +.header-image a { + display: block; +} + +.header-image a:hover img, +.header-image a:focus img { + opacity: 0.85; +} + +/** + * 11.2 - Posts and pages + */ + +.site-main > article { + margin-bottom: 3.5em; + position: relative; +} + +.entry-header, +.entry-summary, +.entry-content, +.entry-footer, +.page-content { + margin-right: 7.6923%; + margin-left: 7.6923%; +} + +.entry-title { + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 28px; + font-size: 1.75rem; + font-weight: 700; + line-height: 1.25; + margin-bottom: 1em; +} + +.entry-title a { + color: #1a1a1a; +} + +.entry-title a:hover, +.entry-title a:focus { + color: #007acc; +} + +.post-thumbnail { + display: block; + margin: 0 7.6923% 1.75em; +} + +.post-thumbnail img { + display: block; +} + +.no-sidebar .post-thumbnail img { + margin: 0 auto; +} + +a.post-thumbnail:hover, +a.post-thumbnail:focus { + opacity: 0.85; +} + +.entry-content, +.entry-summary { + border-color: #d1d1d1; +} + +.entry-content h1, +.entry-summary h1, +.comment-content h1, +.textwidget h1 { + font-size: 28px; + font-size: 1.75rem; + line-height: 1.25; + margin-top: 2em; + margin-bottom: 1em; +} + +.entry-content h2, +.entry-summary h2, +.comment-content h2, +.textwidget h2 { + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.2173913043; + margin-top: 2.4347826087em; + margin-bottom: 1.2173913043em; +} + +.entry-content h3, +.entry-summary h3, +.comment-content h3, +.textwidget h3 { + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.1052631579; + margin-top: 2.9473684211em; + margin-bottom: 1.4736842105em; +} + +.entry-content h4, +.entry-content h5, +.entry-content h6, +.entry-summary h4, +.entry-summary h5, +.entry-summary h6, +.comment-content h4, +.comment-content h5, +.comment-content h6, +.textwidget h4, +.textwidget h5, +.textwidget h6 { + font-size: 16px; + font-size: 1rem; + line-height: 1.3125; + margin-top: 3.5em; + margin-bottom: 1.75em; +} + +.entry-content h4, +.entry-summary h4, +.comment-content h4, +.textwidget h4 { + letter-spacing: 0.140625em; + text-transform: uppercase; +} + +.entry-content h6, +.entry-summary h6, +.comment-content h6, +.textwidget h6 { + font-style: italic; +} + +.entry-content h1, +.entry-content h2, +.entry-content h3, +.entry-content h4, +.entry-content h5, +.entry-content h6, +.entry-summary h1, +.entry-summary h2, +.entry-summary h3, +.entry-summary h4, +.entry-summary h5, +.entry-summary h6, +.comment-content h1, +.comment-content h2, +.comment-content h3, +.comment-content h4, +.comment-content h5, +.comment-content h6, +.textwidget h1, +.textwidget h2, +.textwidget h3, +.textwidget h4, +.textwidget h5, +.textwidget h6 { + font-weight: 900; +} + +.entry-content h1:first-child, +.entry-content h2:first-child, +.entry-content h3:first-child, +.entry-content h4:first-child, +.entry-content h5:first-child, +.entry-content h6:first-child, +.entry-summary h1:first-child, +.entry-summary h2:first-child, +.entry-summary h3:first-child, +.entry-summary h4:first-child, +.entry-summary h5:first-child, +.entry-summary h6:first-child, +.comment-content h1:first-child, +.comment-content h2:first-child, +.comment-content h3:first-child, +.comment-content h4:first-child, +.comment-content h5:first-child, +.comment-content h6:first-child, +.textwidget h1:first-child, +.textwidget h2:first-child, +.textwidget h3:first-child, +.textwidget h4:first-child, +.textwidget h5:first-child, +.textwidget h6:first-child { + margin-top: 0; +} + +.post-navigation .post-title, +.entry-title, +.comments-title { + -webkit-hyphens: auto; + -moz-hyphens: auto; + -ms-hyphens: auto; + hyphens: auto; +} + +body:not(.search-results) .entry-summary { + color: #686868; + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.4736842105; + margin-bottom: 1.4736842105em; +} + +body:not(.search-results) .entry-header + .entry-summary { + margin-top: -0.736842105em; +} + +body:not(.search-results) .entry-summary p, +body:not(.search-results) .entry-summary address, +body:not(.search-results) .entry-summary hr, +body:not(.search-results) .entry-summary ul, +body:not(.search-results) .entry-summary ol, +body:not(.search-results) .entry-summary dl, +body:not(.search-results) .entry-summary dd, +body:not(.search-results) .entry-summary table { + margin-bottom: 1.4736842105em; +} + +body:not(.search-results) .entry-summary li > ul, +body:not(.search-results) .entry-summary li > ol { + margin-bottom: 0; +} + +body:not(.search-results) .entry-summary th, +body:not(.search-results) .entry-summary td { + padding: 0.3684210526em; +} + +body:not(.search-results) .entry-summary fieldset { + margin-bottom: 1.4736842105em; + padding: 0.3684210526em; +} + +body:not(.search-results) .entry-summary blockquote { + border-color: currentColor; +} + +body:not(.search-results) .entry-summary blockquote > :last-child { + margin-bottom: 0; +} + +body:not(.search-results) .entry-summary .alignleft { + margin: 0.2631578947em 1.4736842105em 1.4736842105em 0; +} + +body:not(.search-results) .entry-summary .alignright { + margin: 0.2631578947em 0 1.4736842105em 1.4736842105em; +} + +body:not(.search-results) .entry-summary .aligncenter { + margin-bottom: 1.4736842105em; +} + +.entry-content > :last-child, +.entry-summary > :last-child, +body:not(.search-results) .entry-summary > :last-child, +.page-content > :last-child, +.comment-content > :last-child, +.textwidget > :last-child { + margin-bottom: 0; +} + +.more-link { + white-space: nowrap; +} + +.author-info { + border-color: inherit; + border-style: solid; + border-width: 1px 0 1px 0; + clear: both; + padding-top: 1.75em; + padding-bottom: 1.75em; +} + +.author-avatar .avatar { + float: left; + height: 42px; + margin: 0 1.75em 1.75em 0; + width: 42px; +} + +.author-description > :last-child { + margin-bottom: 0; +} + +.entry-content .author-title { + clear: none; + font-size: 16px; + font-size: 1rem; + font-weight: 900; + line-height: 1.75; + margin: 0; +} + +.author-bio { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-bottom: 1.6153846154em; + overflow: hidden; +} + +.author-link { + white-space: nowrap; +} + +.entry-footer { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-top: 2.1538461538em; +} + +.entry-footer:empty { + margin: 0; +} + +.entry-footer a { + color: #686868; +} + +.entry-footer a:hover, +.entry-footer a:focus { + color: #007acc; +} + +.entry-footer > span:not(:last-child):after { + content: "\002f"; + display: inline-block; + opacity: 0.7; + padding: 0 0.538461538em; +} + +.entry-footer .avatar { + height: 21px; + margin: -0.1538461538em 0.5384615385em 0 0; + width: 21px; +} + +.sticky-post { + color: #686868; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + letter-spacing: 0.076923077em; + line-height: 1.6153846154; + margin-bottom: 0.5384615385em; + text-transform: uppercase; +} + +/** + * IE8 and earlier will drop any block with CSS3 selectors. + * Do not combine these styles with the next block. + */ +.updated:not(.published) { + display: none; +} + +.sticky .posted-on, +.byline { + display: none; +} + +.single .byline, +.group-blog .byline { + display: inline; +} + +.page-header { + border-top: 4px solid #1a1a1a; + margin: 0 7.6923% 3.5em; + padding-top: 1.75em; +} + +body.error404 .page-header, +body.search-no-results .page-header { + border-top: 0; + padding-top: 0; +} + +.page-title { + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.2173913043; +} + +.taxonomy-description { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; +} + +.taxonomy-description p { + margin: 0.5384615385em 0 1.6153846154em; +} + +.taxonomy-description > :last-child { + margin-bottom: 0; +} + +.page-links { + clear: both; + font-family: Montserrat, "Helvetica Neue", sans-serif; + margin: 0 0 1.75em; +} + +.page-links a, +.page-links > span { + border: 1px solid #d1d1d1; + border-radius: 2px; + display: inline-block; + font-size: 13px; + font-size: 0.8125rem; + height: 1.8461538462em; + line-height: 1.6923076923em; + margin-right: 0.3076923077em; + text-align: center; + width: 1.8461538462em; +} + +.page-links a { + background-color: #1a1a1a; + border-color: #1a1a1a; + color: #fff; +} + +.page-links a:hover, +.page-links a:focus { + background-color: #007acc; + border-color: transparent; + color: #fff; +} + +.page-links > .page-links-title { + border: 0; + color: #1a1a1a; + height: auto; + margin: 0; + padding-right: 0.6153846154em; + width: auto; +} + +.entry-attachment { + margin-bottom: 1.75em; +} + +.entry-caption { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + font-style: italic; + line-height: 1.6153846154; + padding-top: 1.0769230769em; +} + +.entry-caption > :last-child { + margin-bottom: 0; +} + +.content-bottom-widgets { + margin: 0 7.6923%; +} + +.content-bottom-widgets .widget-area { + margin-bottom: 3.5em; +} + + +/** + * 11.3 - Post Formats + */ + +.format-aside .entry-title, +.format-image .entry-title, +.format-video .entry-title, +.format-quote .entry-title, +.format-gallery .entry-title, +.format-status .entry-title, +.format-link .entry-title, +.format-audio .entry-title, +.format-chat .entry-title { + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.473684211; + margin-bottom: 1.473684211em; +} + +.blog .format-status .entry-title, +.archive .format-status .entry-title { + display: none; +} + + +/** + * 11.4 - Comments + */ + +.comments-area { + margin: 0 7.6923% 3.5em; +} + +.comment-list + .comment-respond, +.comment-navigation + .comment-respond { + padding-top: 1.75em; +} + +.comments-title, +.comment-reply-title { + border-top: 4px solid #1a1a1a; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 23px; + font-size: 1.4375rem; + font-weight: 700; + line-height: 1.3125; + padding-top: 1.217391304em; +} + +.comments-title { + margin-bottom: 1.217391304em; +} + +.comment-list { + list-style: none; + margin: 0; +} + +.comment-list article, +.comment-list .pingback, +.comment-list .trackback { + border-top: 1px solid #d1d1d1; + padding: 1.75em 0; +} + +.comment-list .children { + list-style: none; + margin: 0; +} + +.comment-list .children > li { + padding-left: 0.875em; +} + +.comment-author { + color: #1a1a1a; + margin-bottom: 0.4375em; +} + +.comment-author .avatar { + float: left; + height: 28px; + margin-right: 0.875em; + position: relative; + width: 28px; +} + +.bypostauthor > article .fn:after { + content: "\f304"; + left: 3px; + position: relative; + top: 5px; +} + +.comment-metadata, +.pingback .edit-link { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; +} + +.comment-metadata { + margin-bottom: 2.1538461538em; +} + +.comment-metadata a, +.pingback .comment-edit-link { + color: #686868; +} + +.comment-metadata a:hover, +.comment-metadata a:focus, +.pingback .comment-edit-link:hover, +.pingback .comment-edit-link:focus { + color: #007acc; +} + +.comment-metadata .edit-link, +.pingback .edit-link { + display: inline-block; +} + +.comment-metadata .edit-link:before, +.pingback .edit-link:before { + content: "\002f"; + display: inline-block; + opacity: 0.7; + padding: 0 0.538461538em; +} + +.comment-content ul, +.comment-content ol { + margin: 0 0 1.5em 1.25em; +} + +.comment-content li > ul, +.comment-content li > ol { + margin-bottom: 0; +} + +.comment-reply-link { + border: 1px solid #d1d1d1; + border-radius: 2px; + color: #007acc; + display: inline-block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1; + margin-top: 2.1538461538em; + padding: 0.5384615385em 0.5384615385em 0.4615384615em; +} + +.comment-reply-link:hover, +.comment-reply-link:focus { + border-color: currentColor; + color: #007acc; + outline: 0; +} + +.comment-form { + padding-top: 1.75em; +} + +.comment-form label { + color: #686868; + display: block; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + letter-spacing: 0.076923077em; + line-height: 1.6153846154; + margin-bottom: 0.5384615385em; + text-transform: uppercase; +} + +.comment-list .comment-form { + padding-bottom: 1.75em; +} + +.comment-notes, +.comment-awaiting-moderation, +.logged-in-as, +.form-allowed-tags { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-bottom: 2.1538461538em; +} + +.no-comments { + border-top: 1px solid #d1d1d1; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-weight: 700; + margin: 0; + padding-top: 1.75em; +} + +.comment-navigation + .no-comments { + border-top: 0; + padding-top: 0; +} + +.form-allowed-tags code { + font-family: Inconsolata, monospace; +} + +.form-submit { + margin-bottom: 0; +} + +.required { + color: #007acc; + font-family: Merriweather, Georgia, serif; +} + +.comment-reply-title small { + font-size: 100%; +} + +.comment-reply-title small a { + border: 0; + float: right; + height: 32px; + overflow: hidden; + width: 26px; +} + +.comment-reply-title small a:hover, +.comment-reply-title small a:focus { + color: #1a1a1a; +} + +.comment-reply-title small a:before { + content: "\f405"; + font-size: 32px; + position: relative; + top: -5px; +} + +.comment-form #wp-comment-cookies-consent { + margin: 0 10px 0 0; +} + +.comment-form .comment-form-cookies-consent label { + display: inline; + font-family: Merriweather, Georgia, serif; + letter-spacing: 0; + text-transform: none; +} + +/** + * 11.5 - Sidebar + */ + +.sidebar { + margin-bottom: 3.5em; + padding: 0 7.6923%; +} + + +/** + * 11.6 - Footer + */ + +.site-footer { + padding: 0 7.6923% 1.75em; +} + +.site-info { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; +} + +.site-info a { + color: #686868; +} + +.site-info a:hover, +.site-info a:focus { + color: #007acc; +} + +.site-footer .site-title { + font-family: inherit; + font-size: inherit; + font-weight: 400; +} + +.site-footer .site-title:after { + content: "\002f"; + display: inline-block; + font-family: Montserrat, sans-serif; + opacity: 0.7; + padding: 0 0.307692308em 0 0.538461538em; +} + +.site-footer span[role=separator] { + font-family: Montserrat, sans-serif; + opacity: 0.7; + padding: 0 0.307692308em 0 0.538461538em; +} + +.site-footer span[role=separator]::before { + content: '\002f'; +} + + +/** + * 12.0 - Media + */ + +.site .avatar { + border-radius: 50%; +} + +.entry-content .wp-smiley, +.entry-summary .wp-smiley, +.comment-content .wp-smiley, +.textwidget .wp-smiley { + border: none; + margin-top: 0; + margin-bottom: 0; + padding: 0; +} + +.entry-content a img, +.entry-summary a img, +.comment-content a img, +.textwidget a img { + display: block; +} + +/* Make sure embeds and iframes fit their containers. */ +embed, +iframe, +object, +video { + margin-bottom: 1.75em; + max-width: 100%; + vertical-align: middle; +} + +p > embed, +p > iframe, +p > object, +p > video { + margin-bottom: 0; +} + +.entry-content .wp-audio-shortcode a, +.entry-content .wp-playlist a { + box-shadow: none; +} + +.wp-audio-shortcode, +.wp-video, +.wp-playlist.wp-audio-playlist { + margin-top: 0; + margin-bottom: 1.75em; +} + +.wp-playlist.wp-audio-playlist { + padding-bottom: 0; +} + +.wp-playlist .wp-playlist-tracks { + margin-top: 0; +} + +.wp-playlist-item .wp-playlist-caption { + border-bottom: 0; + padding: 0.7142857143em 0; +} + +.wp-playlist-item .wp-playlist-item-length { + top: 0.7142857143em; +} + + +/** + * 12.1 - Captions + */ + +.wp-caption { + margin-bottom: 1.75em; + max-width: 100%; +} + +.wp-caption img[class*="wp-image-"] { + display: block; + margin: 0; +} + +.wp-caption .wp-caption-text { + color: #686868; + font-size: 13px; + font-size: 0.8125rem; + font-style: italic; + line-height: 1.6153846154; + padding-top: 0.5384615385em; +} + + +/** + * 12.2 - Galleries + */ + +.gallery { + margin: 0 -1.1666667% 1.75em; +} + +.gallery-item { + display: inline-block; + max-width: 33.33%; + padding: 0 1.1400652% 2.2801304%; + text-align: center; + vertical-align: top; + width: 100%; +} + +.gallery-columns-1 .gallery-item { + max-width: 100%; +} + +.gallery-columns-2 .gallery-item { + max-width: 50%; +} + +.gallery-columns-4 .gallery-item { + max-width: 25%; +} + +.gallery-columns-5 .gallery-item { + max-width: 20%; +} + +.gallery-columns-6 .gallery-item { + max-width: 16.66%; +} + +.gallery-columns-7 .gallery-item { + max-width: 14.28%; +} + +.gallery-columns-8 .gallery-item { + max-width: 12.5%; +} + +.gallery-columns-9 .gallery-item { + max-width: 11.11%; +} + +.gallery-icon img { + margin: 0 auto; +} + +.gallery-caption { + color: #686868; + display: block; + font-size: 13px; + font-size: 0.8125rem; + font-style: italic; + line-height: 1.6153846154; + padding-top: 0.5384615385em; +} + +.gallery-columns-6 .gallery-caption, +.gallery-columns-7 .gallery-caption, +.gallery-columns-8 .gallery-caption, +.gallery-columns-9 .gallery-caption { + display: none; +} + + +/** + * 13.0 - Multisites + */ + +.widecolumn { + margin-bottom: 3.5em; + padding: 0 7.6923%; +} + +.widecolumn .mu_register { + width: auto; +} + +.widecolumn .mu_register .mu_alert { + background: transparent; + border-color: #d1d1d1; + color: inherit; + margin-bottom: 3.5em; + padding: 1.75em; +} + +.widecolumn form, +.widecolumn .mu_register form { + margin-top: 0; +} + +.widecolumn h2 { + font-size: 23px; + font-size: 1.4375rem; + font-weight: 900; + line-height: 1.2173913043; + margin-bottom: 1.2173913043em; +} + +.widecolumn p { + margin: 1.75em 0; +} + +.widecolumn p + h2 { + margin-top: 2.4347826087em; +} + +.widecolumn label, +.widecolumn .mu_register label { + color: #686868; + font-family: Montserrat, "Helvetica Neue", sans-serif; + font-size: 13px; + font-size: 0.8125rem; + font-weight: 400; + letter-spacing: 0.076923077em; + line-height: 1.6153846154; + text-transform: uppercase; +} + +.widecolumn .mu_register label { + margin: 2.1538461538em 0.7692307692em 0.5384615385em 0; +} + +.widecolumn .mu_register label strong { + font-weight: 400; +} + +.widecolumn #key, +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #blogname, +.widecolumn .mu_register #user_name { + font-size: 16px; + font-size: 1rem; + width: 100%; +} + +.widecolumn .mu_register #blogname { + margin: 0; +} + +.widecolumn .mu_register #blog_title, +.widecolumn .mu_register #user_email, +.widecolumn .mu_register #user_name { + margin: 0 0 0.375em; +} + +.widecolumn #submit, +.widecolumn .mu_register input[type="submit"] { + font-size: 16px; + font-size: 1rem; + margin: 0; + width: auto; +} + +.widecolumn .mu_register .prefix_address, +.widecolumn .mu_register .suffix_address { + font-size: inherit; +} + +.widecolumn .mu_register > :last-child, +.widecolumn form > :last-child { + margin-bottom: 0; +} + + +/** + * 14.0 - Media Queries + */ + +/** + * Does the same thing as , + * but in the future W3C standard way. -ms- prefix is required for IE10+ to + * render responsive styling in Windows 8 "snapped" views; IE10+ does not honor + * the meta tag. See https://core.trac.wordpress.org/ticket/25888. + */ +@-ms-viewport { + width: device-width; +} + +@viewport { + width: device-width; +} + + +/** + * 14.1 - >= 710px + */ + +@media screen and (min-width: 44.375em) { + body:not(.custom-background-image):before, + body:not(.custom-background-image):after { + background: inherit; + content: ""; + display: block; + height: 21px; + left: 0; + position: fixed; + width: 100%; + z-index: 99; + } + + body:not(.custom-background-image):before { + top: 0; + } + + body:not(.custom-background-image).admin-bar:before { + top: 46px; + } + + body:not(.custom-background-image):after { + bottom: 0; + } + + .site { + margin: 21px; + } + + .site-main { + margin-bottom: 5.25em; + } + + .site-header { + padding: 3.9375em 7.6923%; + } + + .site-branding { + margin-top: 1.3125em; + margin-bottom: 1.3125em; + } + + .custom-logo { + max-width: 210px; + } + + .site-title { + font-size: 28px; + font-size: 1.75rem; + line-height: 1.25; + } + + .wp-custom-logo .site-title { + margin-top: 0.5em; + } + + .site-description { + display: block; + } + + .menu-toggle { + font-size: 16px; + font-size: 1.0rem; + margin: 1.3125em 0; + padding: 0.8125em 0.875em 0.6875em; + } + + .site-header-menu { + margin: 1.3125em 0; + } + + .site-header .main-navigation + .social-navigation { + margin-top: 2.625em; + } + + .header-image { + margin: 1.3125em 0; + } + + .pagination { + margin: 0 23.0769% 4.421052632em 7.6923% + } + + .post-navigation { + margin-bottom: 5.25em; + } + + .post-navigation .post-title { + font-size: 28px; + font-size: 1.75rem; + line-height: 1.25; + } + + /* restore screen-reader-text */ + .pagination .current .screen-reader-text { + position: absolute !important; + } + + .pagination .page-numbers { + display: inline-block; + } + + .site-main > article { + margin-bottom: 5.25em; + } + + .entry-header, + .post-thumbnail, + .entry-content, + .entry-summary, + .entry-footer, + .comments-area, + .image-navigation, + .post-navigation, + .page-header, + .page-content, + .content-bottom-widgets { + margin-right: 23.0769%; + } + + .entry-title { + font-size: 33px; + font-size: 2.0625rem; + line-height: 1.2727272727; + margin-bottom: 0.8484848485em; + } + + .entry-content blockquote.alignleft, + .entry-content blockquote.alignright { + border-width: 4px 0 0 0; + padding: 0.9473684211em 0 0; + width: -webkit-calc(50% - 0.736842105em); + width: calc(50% - 0.736842105em); + } + + .entry-content blockquote:not(.alignleft):not(.alignright), + .entry-summary blockquote, + .comment-content blockquote { + margin-left: -1.473684211em; + } + + .entry-content blockquote blockquote:not(.alignleft):not(.alignright), + .entry-summary blockquote blockquote, + .comment-content blockquote blockquote { + margin-left: 0; + } + + .entry-content ul, + .entry-summary ul, + .comment-content ul, + .entry-content ol, + .entry-summary ol, + .comment-content ol { + margin-left: 0; + } + + .entry-content li > ul, + .entry-summary li > ul, + .comment-content li > ul, + .entry-content blockquote > ul, + .entry-summary blockquote > ul, + .comment-content blockquote > ul { + margin-left: 1.25em; + } + + .entry-content li > ol, + .entry-summary li > ol, + .comment-content li > ol, + .entry-content blockquote > ol, + .entry-summary blockquote > ol, + .comment-content blockquote > ol { + margin-left: 1.5em; + } + + .comment-author { + margin-bottom: 0; + } + + .comment-author .avatar { + height: 42px; + position: relative; + top: 0.25em; + width: 42px; + } + + .comment-list .children > li { + padding-left: 1.75em; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 3.5em; + } + + .comments-area, + .widget, + .content-bottom-widgets .widget-area { + margin-bottom: 5.25em; + } + + .sidebar, + .widecolumn { + margin-bottom: 5.25em; + padding-right: 23.0769%; + } + + body:not(.search-results) .entry-summary li > ul, + body:not(.search-results) .entry-summary blockquote > ul { + margin-left: 1.157894737em; + } + + body:not(.search-results) .entry-summary li > ol, + body:not(.search-results) .entry-summary blockquote > ol { + margin-left: 1.473684211em; + } +} + + +/** + * 14.2 - >= 783px + */ + +@media screen and (min-width: 48.9375em) { + body:not(.custom-background-image).admin-bar:before { + top: 32px; + } +} + + +/** + * 14.3 - >= 910px + */ + +@media screen and (min-width: 56.875em) { + .site-header { + padding-right: 4.5455%; + padding-left: 4.5455%; + } + + .site-header-main { + -webkit-align-items: flex-start; + -ms-flex-align: start; + align-items: flex-start; + } + + .wp-custom-logo .site-header-main { + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + } + + .site-header-menu { + display: block; + -webkit-flex: 0 1 auto; + -ms-flex: 0 1 auto; + flex: 0 1 auto; + } + + .main-navigation { + margin: 0 -0.875em; + } + + .main-navigation .primary-menu, + .main-navigation .primary-menu > li { + border: 0; + } + + .main-navigation .primary-menu > li { + float: left; + } + + .main-navigation a { + outline-offset: -8px; + padding: 0.65625em 0.875em; + white-space: nowrap; + } + + .main-navigation li:hover > a, + .main-navigation li.focus > a { + color: #007acc; + } + + .main-navigation ul ul { + border-bottom: 1px solid #d1d1d1; + display: block; + left: -999em; + margin: 0; + position: absolute; + z-index: 99999; + } + + .main-navigation ul ul ul { + top: -1px; + } + + .main-navigation ul ul ul:before, + .main-navigation ul ul ul:after { + border: 0; + } + + .main-navigation ul ul li { + background-color: #fff; + border: 1px solid #d1d1d1; + border-bottom-width: 0; + } + + .main-navigation ul ul a { + white-space: normal; + width: 12.6875em; + } + + .main-navigation ul ul:before, + .main-navigation ul ul:after { + border-style: solid; + content: ""; + position: absolute; + } + + .main-navigation ul ul:before { + border-color: #d1d1d1 transparent; + border-width: 0 10px 10px; + right: 9px; + top: -9px; + } + + .main-navigation ul ul:after { + border-color: #fff transparent; + border-width: 0 8px 8px; + right: 11px; + top: -7px; + } + + .main-navigation li:hover > ul, + .main-navigation li.focus > ul { + left: auto; + right: 0; + } + + .main-navigation ul ul li:hover > ul, + .main-navigation ul ul li.focus > ul { + left: auto; + right: 100%; + } + + .main-navigation .menu-item-has-children > a { + margin: 0; + padding-right: 2.25em; + } + + .main-navigation .menu-item-has-children > a:after { + content: "\f431"; + position: absolute; + right: 0.625em; + top: 0.8125em; + } + + .main-navigation ul ul .menu-item-has-children > a { + padding-right: 2.0625em; + } + + .main-navigation ul ul .menu-item-has-children > a:after { + right: 0.5625em; + top: 0.875em; + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + transform: rotate(90deg); + } + + .dropdown-toggle, + .main-navigation ul .dropdown-toggle.toggled-on, + .menu-toggle, + .site-header .social-navigation, + .site-footer .main-navigation { + display: none; + } + + .site-content { + padding: 0 4.5455%; + } + + .content-area { + float: left; + margin-right: -100%; + width: 70%; + } + + .entry-header, + .post-thumbnail, + .entry-content, + .entry-summary, + .entry-footer, + .comments-area, + .image-navigation, + .post-navigation, + .pagination, + .page-header, + .page-content, + .content-bottom-widgets { + margin-right: 0; + margin-left: 0; + } + + .sidebar { + float: left; + margin-left: 75%; + padding: 0; + width: 25%; + } + + .widget { + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-bottom: 3.230769231em; + padding-top: 1.615384615em; + } + + .widget .widget-title { + margin-bottom: 1.3125em; + } + + .widget p, + .widget address, + .widget hr, + .widget ul, + .widget ol, + .widget dl, + .widget dd, + .widget table { + margin-bottom: 1.6153846154em; + } + + .widget li > ul, + .widget li > ol { + margin-bottom: 0; + } + + .widget blockquote { + font-size: 16px; + font-size: 1rem; + line-height: 1.3125; + margin-bottom: 1.3125em; + padding-left: 1.0625em; + } + + .widget blockquote cite, + .widget blockquote small { + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + } + + .widget th, + .widget td { + padding: 0.5384615385em; + } + + .widget pre { + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-bottom: 1.6153846154em; + padding: 0.5384615385em; + } + + .widget fieldset { + margin-bottom: 1.6153846154em; + padding: 0.5384615385em; + } + + .widget button, + .widget input, + .widget select, + .widget textarea { + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + } + + .widget button, + .widget input[type="button"], + .widget input[type="reset"], + .widget input[type="submit"] { + line-height: 1; + padding: 0.846153846em; + } + + .widget input[type="date"], + .widget input[type="time"], + .widget input[type="datetime-local"], + .widget input[type="week"], + .widget input[type="month"], + .widget input[type="text"], + .widget input[type="email"], + .widget input[type="url"], + .widget input[type="password"], + .widget input[type="search"], + .widget input[type="tel"], + .widget input[type="number"], + .widget textarea { + padding: 0.4615384615em 0.5384615385em; + } + + .widget h1 { + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.2173913043; + margin-bottom: 0.9130434783em; + } + + .widget h2 { + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.1052631579; + margin-bottom: 1.1052631579em; + } + + .widget h3 { + font-size: 16px; + font-size: 1rem; + line-height: 1.3125; + margin-bottom: 1.3125em; + } + + .widget h4, + .widget h5, + .widget h6 { + font-size: 13px; + font-size: 0.8125rem; + line-height: 1.6153846154; + margin-bottom: 0.9130434783em; + } + + .widget .alignleft { + margin: 0.2307692308em 1.6153846154em 1.6153846154em 0; + } + + .widget .alignright { + margin: 0.2307692308em 0 1.6153846154em 1.6153846154em; + } + + .widget .aligncenter { + margin-bottom: 1.6153846154em; + } + + .widget_calendar td, + .widget_calendar th { + line-height: 2.6923076923; + padding: 0; + } + + .widget_rss .rssSummary:last-child { + margin-bottom: 1.615384615em; + } + + .widget input[type="search"].search-field { + width: -webkit-calc(100% - 35px); + width: calc(100% - 35px); + } + + .widget .search-submit:before { + font-size: 16px; + left: 1px; + line-height: 35px; + width: 34px; + } + + .widget button.search-submit { + padding: 0; + width: 35px; + } + + .tagcloud a { + margin: 0 0.2307692308em 0.5384615385em 0; + padding: 0.5384615385em 0.4615384615em 0.4615384615em; + } + + .textwidget h1 { + margin-top: 1.8260869565em; + } + + .textwidget h2 { + margin-top: 2.2105263158em; + } + + .textwidget h3 { + margin-top: 2.625em; + } + + .textwidget h4 { + letter-spacing: 0.153846154em; + } + + .textwidget h4, + .textwidget h5, + .textwidget h6 { + margin-top: 3.2307692308em; + } + + .content-bottom-widgets .widget-area:nth-child(1):nth-last-child(2), + .content-bottom-widgets .widget-area:nth-child(2):nth-last-child(1) { + float: left; + margin-right: 7.1428571%; + width: 46.42857145%; + } + + .content-bottom-widgets .widget-area:nth-child(2):nth-last-child(1):last-of-type { + margin-right: 0; + } + + .site-footer { + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + padding: 0 4.5455% 3.5em; + } + + .site-footer .social-navigation { + margin: 0; + -webkit-order: 2; + -ms-flex-order: 2; + order: 2; + } + + .site-info { + margin: 0.538461538em auto 0.538461538em 0; + -webkit-order: 1; + -ms-flex-order: 1; + order: 1; + } + + .no-sidebar .content-area { + float: none; + margin: 0; + width: 100%; + } + + .no-sidebar .entry-header, + .no-sidebar .entry-content, + .no-sidebar .entry-summary, + .no-sidebar .entry-footer, + .no-sidebar .comments-area, + .no-sidebar .image-navigation, + .no-sidebar .post-navigation, + .no-sidebar .pagination, + .no-sidebar .page-header, + .no-sidebar .page-content, + .no-sidebar .content-bottom-widgets { + margin-right: 15%; + margin-left: 15%; + } + + .widecolumn { + padding-right: 15%; + padding-left: 15%; + } +} + + +/** + * 14.4 - >= 985px + */ + +@media screen and (min-width: 61.5625em) { + .site-main { + margin-bottom: 7.0em; + } + + .site-header { + padding: 5.25em 4.5455%; + } + + .site-branding, + .site-header-menu, + .header-image { + margin-top: 1.75em; + margin-bottom: 1.75em; + } + + .custom-logo { + max-width: 240px; + } + + .image-navigation { + margin-bottom: 3.230769231em; + } + + .post-navigation { + margin-bottom: 7.0em; + } + + .pagination { + margin-bottom: 5.894736842em; + } + + .widget { + margin-bottom: 4.307692308em; + } + + .site-main > article { + margin-bottom: 7.0em; + } + + .entry-title { + font-size: 40px; + font-size: 2.5rem; + line-height: 1.225; + margin-bottom: 1.05em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 23px; + font-size: 1.4375em; + line-height: 1.304347826; + margin-bottom: 1.826086957em; + } + + .post-thumbnail { + margin-bottom: 2.625em; + } + + .entry-content h1, + .entry-summary h1, + .comment-content h1 { + font-size: 33px; + font-size: 2.0625rem; + line-height: 1.2727272727; + margin-top: 1.696969697em; + margin-bottom: 0.8484848485em; + } + + .entry-content h2, + .entry-summary h2, + .comment-content h2 { + font-size: 28px; + font-size: 1.75rem; + line-height: 1.25; + margin-top: 2em; + margin-bottom: 1em; + } + + .entry-content h3, + .entry-summary h3, + .comment-content h3 { + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.2173913043; + margin-top: 2.4347826087em; + margin-bottom: 1.2173913043em; + } + + .entry-content h4, + .entry-summary h4, + .entry-intro h4, + .comment-content h4 { + letter-spacing: 0.131578947em; + } + + .entry-content h4, + .entry-content h5, + .entry-content h6, + .entry-summary h4, + .entry-summary h5, + .entry-summary h6, + .comment-content h4, + .comment-content h5, + .comment-content h6 { + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.1052631579; + margin-top: 2.9473684211em; + margin-bottom: 1.473684211em; + } + + .author-info { + border-bottom-width: 0; + padding-bottom: 0; + } + + .comment-list + .comment-respond, + .comment-navigation + .comment-respond { + padding-top: 5.25em; + } + + .comments-area, + .sidebar, + .content-bottom-widgets .widget-area, + .widecolumn { + margin-bottom: 7.0em; + } + + body:not(.search-results) .entry-summary { + margin-bottom: 2.210526316em; + } + + body:not(.search-results) .entry-header + .entry-summary { + margin-top: -1.105263158em; + } + + body:not(.search-results) article:not(.type-page) .entry-content { + float: right; + width: 71.42857144%; + } + + body:not(.search-results) article:not(.type-page) .entry-content > blockquote.alignleft.below-entry-meta { + margin-left: -40%; + width: -webkit-calc(60% - 1.4736842105em); + width: calc(60% - 1.4736842105em); + } + + body:not(.search-results) article:not(.type-page) img.below-entry-meta, + body:not(.search-results) article:not(.type-page) figure.below-entry-meta { + clear: both; + display: block; + float: none; + margin-right: 0; + margin-left: -40%; + max-width: 140%; + } + + body:not(.search-results) article:not(.type-page) figure.below-entry-meta img.below-entry-meta, + body:not(.search-results) article:not(.type-page) table figure.below-entry-meta, + body:not(.search-results) article:not(.type-page) table img.below-entry-meta { + margin: 0; + max-width: 100%; + } + + body:not(.search-results) article:not(.type-page) .entry-footer { + float: left; + margin-top: 0.1538461538em; + width: 21.42857143%; + } + + body:not(.search-results) article:not(.type-page) .entry-footer > span:not(:last-child):after { + display: none; + } + + .single .byline, + .full-size-link, + body:not(.search-results).group-blog .byline, + body:not(.search-results) .entry-format, + body:not(.search-results) .cat-links, + body:not(.search-results) .tags-links, + body:not(.search-results) article:not(.sticky) .posted-on, + body:not(.search-results) article:not(.type-page) .comments-link, + body:not(.search-results) article:not(.type-page) .entry-footer .edit-link { + display: block; + margin-bottom: 0.5384615385em; + } + + body:not(.search-results) article:not(.type-page) .entry-footer > span:last-child { + margin-bottom: 0; + } + + body:not(.search-results) article:not(.type-page) .entry-footer .avatar { + display: block; + height: auto; + margin: 0 0 0.5384615385em; + width: 49px; + } + + body.no-sidebar:not(.search-results) article:not(.type-page) .entry-content { + float: left; + margin-right: -100%; + margin-left: 34.99999999%; + width: 50.00000001%; + } + + body.no-sidebar:not(.search-results) article:not(.type-page) .entry-footer { + margin-right: -100%; + margin-left: 15%; + width: 15%; + } +} + + +/** + * 14.5 - >= 1200px + */ + +@media screen and (min-width: 75em) { + body:not(.search-results) .entry-summary { + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.5217391304; + margin-bottom: 1.826086957em; + } + + body:not(.search-results) .entry-header + .entry-summary { + margin-top: -0.913043478em; + } + + body:not(.search-results) .entry-summary p, + body:not(.search-results) .entry-summary address, + body:not(.search-results) .entry-summary hr, + body:not(.search-results) .entry-summary ul, + body:not(.search-results) .entry-summary ol, + body:not(.search-results) .entry-summary dl, + body:not(.search-results) .entry-summary dd, + body:not(.search-results) .entry-summary table { + margin-bottom: 1.5217391304em; + } + + body:not(.search-results) .entry-summary li > ul, + body:not(.search-results) .entry-summary blockquote > ul { + margin-left: 0.956521739em; + } + + body:not(.search-results) .entry-summary li > ol, + body:not(.search-results) .entry-summary blockquote > ol { + margin-left: 1.52173913em; + } + + body:not(.search-results) .entry-summary blockquote { + font-size: 23px; + font-size: 1.4375rem; + line-height: 1.5217391304; + margin: 0 0 1.5217391304em; + padding-left: 1.347826087em; + } + + body:not(.search-results) .entry-summary blockquote:not(.alignleft):not(.alignright) { + margin-left: -1.52173913em; + } + + body:not(.search-results) .entry-summary blockquote blockquote:not(.alignleft):not(.alignright) { + margin-left: 0; + } + + body:not(.search-results) .entry-summary blockquote cite, + body:not(.search-results) .entry-summary blockquote small { + font-size: 19px; + font-size: 1.1875rem; + line-height: 1.8421052632; + } + + body:not(.search-results) .entry-summary th, + body:not(.search-results) .entry-summary td { + padding: 0.3043478261em; + } + + body:not(.search-results) .entry-summary pre { + font-size: 16px; + font-size: 1rem; + line-height: 1.75; + margin-bottom: 1.75em; + padding: 1.75em; + } + + body:not(.search-results) .entry-summary fieldset { + margin-bottom: 1.5217391304em; + padding: 0.3043478261em; + } + + body:not(.search-results) .entry-summary h1 { + margin-top: 2.121212121em; + margin-bottom: 1.060606061em; + } + + body:not(.search-results) .entry-summary h2 { + margin-top: 2.5em; + margin-bottom: 1.25em; + } + + body:not(.search-results) .entry-summary h3 { + margin-top: 3.043478261em; + margin-bottom: 1.52173913em; + } + + body:not(.search-results) .entry-summary h4, + body:not(.search-results) .entry-summary h5, + body:not(.search-results) .entry-summary h6 { + margin-top: 3.684210526em; + margin-bottom: 1.842105263em; + } + + body:not(.search-results) .entry-summary h1:first-child, + body:not(.search-results) .entry-summary h2:first-child, + body:not(.search-results) .entry-summary h3:first-child, + body:not(.search-results) .entry-summary h4:first-child, + body:not(.search-results) .entry-summary h5:first-child, + body:not(.search-results) .entry-summary h6:first-child { + margin-top: 0; + } + + body:not(.search-results) .entry-summary .alignleft { + margin: 0.2608695652em 1.5217391304em 1.5217391304em 0; + } + + body:not(.search-results) .entry-summary .alignright { + margin: 0.2608695652em 0 1.5217391304em 1.5217391304em; + } + + body:not(.search-results) .entry-summary .aligncenter { + margin-bottom: 1.5217391304em; + } +} + + +/** + * 15.0 - Print + */ + +@media print { + form, + button, + input, + select, + textarea, + .navigation, + .main-navigation, + .social-navigation, + .sidebar, + .content-bottom-widgets, + .header-image, + .page-links, + .edit-link, + .comment-respond, + .comment-edit-link, + .comment-reply-link, + .comment-metadata .edit-link, + .pingback .edit-link { + display: none; + } + + body, + blockquote cite, + blockquote small, + pre, + .entry-content h4, + .entry-content h5, + .entry-content h6, + .entry-summary h4, + .entry-summary h5, + .entry-summary h6, + .comment-content h4, + .comment-content h5, + .comment-content h6, + .entry-content .author-title { + font-size: 12pt; + } + + blockquote { + font-size: 14.25pt; + } + + .site-title, + .page-title, + .comments-title, + .entry-content h2, + .entry-summary h2, + .comment-content h2, + .widecolumn h2 { + font-size: 17.25pt; + } + + .site-description { + display: block; + } + + .entry-title { + font-size: 24.75pt; + line-height: 1.2727272727; + margin-bottom: 1.696969697em; + } + + .format-aside .entry-title, + .format-image .entry-title, + .format-video .entry-title, + .format-quote .entry-title, + .format-gallery .entry-title, + .format-status .entry-title, + .format-link .entry-title, + .format-audio .entry-title, + .format-chat .entry-title { + font-size: 17.25pt; + line-height: 1.304347826; + margin-bottom: 1.826086957em; + } + + .entry-content h1, + .entry-summary h1, + .comment-content h1 { + font-size: 21pt; + } + + .entry-content h3, + .entry-summary h3, + .comment-content h3, + body:not(.search-results) .entry-summary { + font-size: 14.25pt; + } + + .site-description, + .author-bio, + .entry-footer, + .sticky-post, + .taxonomy-description, + .entry-caption, + .comment-metadata, + .comment-notes, + .comment-awaiting-moderation, + .site-info, + .wp-caption .wp-caption-text, + .gallery-caption { + font-size: 9.75pt; + } + + body, + .site { + background: none !important; /* Brute force since user agents all print differently. */ + } + + body, + blockquote cite, + blockquote small, + .site-branding .site-title a, + .entry-title a, + .comment-author { + color: #1a1a1a !important; /* Make sure color schemes don't affect to print */ + } + + blockquote, + .page-header, + .comments-title { + border-color: #1a1a1a !important; /* Make sure color schemes don't affect to print */ + } + + blockquote, + .site-description, + body:not(.search-results) .entry-summary, + body:not(.search-results) .entry-summary blockquote, + .author-bio, + .entry-footer, + .entry-footer a, + .sticky-post, + .taxonomy-description, + .entry-caption, + .comment-author, + .comment-metadata a, + .comment-notes, + .comment-awaiting-moderation, + .site-info, + .site-info a, + .wp-caption .wp-caption-text, + .gallery-caption { + color: #686868 !important; /* Make sure color schemes don't affect to print */ + } + + code, + hr { + background-color: #d1d1d1 !important; /* Make sure color schemes don't affect to print */ + } + + pre, + abbr, + acronym, + table, + th, + td, + .author-info, + .comment-list article, + .comment-list .pingback, + .comment-list .trackback, + .no-comments { + border-color: #d1d1d1 !important; /* Make sure color schemes don't affect to print */ + } + + a { + color: #007acc !important; /* Make sure color schemes don't affect to print */ + } + + .entry-content a, + .entry-summary a, + .taxonomy-description a, + .comment-content a, + .pingback .comment-body > a { + box-shadow: none; + border-bottom: 1px solid #007acc !important; /* Make sure color schemes don't affect to print */ + } + + .site { + margin: 5%; + } + + .site-inner { + max-width: none; + } + + .site-header { + padding: 0 0 1.75em; + } + + .site-branding { + margin-top: 0; + margin-bottom: 1.75em; + } + + .site-main { + margin-bottom: 3.5em; + } + + .entry-header, + .entry-footer, + .page-header, + .page-content, + .entry-content, + .entry-summary, + .post-thumbnail, + .comments-area { + margin-right: 0; + margin-left: 0; + } + + .post-thumbnail, + .site-main > article { + margin-bottom: 3.5em; + } + + .entry-content blockquote.alignleft, + .entry-content blockquote.alignright { + border-width: 4px 0 0 0; + padding: 0.9473684211em 0 0; + width: -webkit-calc(50% - 0.736842105em); + width: calc(50% - 0.736842105em); + } + + body:not(.search-results) .entry-header + .entry-summary { + margin-top: -1.473684211em; + } + + .site-footer, + .widecolumn { + padding: 0; + } +} diff --git a/backend/wp-content/themes/twentysixteen/template-parts/biography.php b/backend/wp-content/themes/twentysixteen/template-parts/biography.php new file mode 100644 index 0000000..9e2e5b8 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/biography.php @@ -0,0 +1,37 @@ + + +
      +
      + +
      + +
      +

      + +

      + + +

      +
      +
      diff --git a/backend/wp-content/themes/twentysixteen/template-parts/content-none.php b/backend/wp-content/themes/twentysixteen/template-parts/content-none.php new file mode 100644 index 0000000..b6b7e7c --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/content-none.php @@ -0,0 +1,33 @@ + + +
      + + +
      + + +

      Get started here.', 'twentysixteen' ), esc_url( admin_url( 'post-new.php' ) ) ); ?>

      + + + +

      + + + + +

      + + + +
      +
      diff --git a/backend/wp-content/themes/twentysixteen/template-parts/content-page.php b/backend/wp-content/themes/twentysixteen/template-parts/content-page.php new file mode 100644 index 0000000..2b57d2b --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/content-page.php @@ -0,0 +1,45 @@ + + +
      > +
      + ', '' ); ?> +
      + + + +
      + '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + + "%s"', 'twentysixteen' ), + get_the_title() + ), + '
      ', + '
      ' + ); + ?> + +
      diff --git a/backend/wp-content/themes/twentysixteen/template-parts/content-search.php b/backend/wp-content/themes/twentysixteen/template-parts/content-search.php new file mode 100644 index 0000000..c4667c6 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/content-search.php @@ -0,0 +1,53 @@ + + +
      > +
      + ', esc_url( get_permalink() ) ), '' ); ?> +
      + + + + + + + +
      + + "%s"', 'twentysixteen' ), + get_the_title() + ), + '', + '' + ); + ?> +
      + + + + "%s"', 'twentysixteen' ), + get_the_title() + ), + '
      ', + '
      ' + ); + ?> + + +
      + diff --git a/backend/wp-content/themes/twentysixteen/template-parts/content-single.php b/backend/wp-content/themes/twentysixteen/template-parts/content-single.php new file mode 100644 index 0000000..241f528 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/content-single.php @@ -0,0 +1,53 @@ + + +
      > +
      + ', '' ); ?> +
      + + + + + +
      + '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', + 'separator' => ', ', + ) ); + + if ( '' !== get_the_author_meta( 'description' ) ) { + get_template_part( 'template-parts/biography' ); + } + ?> +
      + +
      + + "%s"', 'twentysixteen' ), + get_the_title() + ), + '', + '' + ); + ?> +
      +
      diff --git a/backend/wp-content/themes/twentysixteen/template-parts/content.php b/backend/wp-content/themes/twentysixteen/template-parts/content.php new file mode 100644 index 0000000..22b0ea4 --- /dev/null +++ b/backend/wp-content/themes/twentysixteen/template-parts/content.php @@ -0,0 +1,57 @@ + + +
      > +
      + + + + + ', esc_url( get_permalink() ) ), '' ); ?> +
      + + + + + +
      + "%s"', 'twentysixteen' ), + get_the_title() + ) ); + + wp_link_pages( array( + 'before' => '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '' . __( 'Page', 'twentysixteen' ) . ' %', + 'separator' => ', ', + ) ); + ?> +
      + +
      + + "%s"', 'twentysixteen' ), + get_the_title() + ), + '', + '' + ); + ?> +
      +
      diff --git a/backend/wp-content/uploads/wc-logs/.htaccess b/backend/wp-content/uploads/wc-logs/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/backend/wp-content/uploads/wc-logs/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/backend/wp-content/uploads/wc-logs/index.html b/backend/wp-content/uploads/wc-logs/index.html new file mode 100644 index 0000000..e69de29 diff --git a/backend/wp-content/uploads/woocommerce_uploads/.htaccess b/backend/wp-content/uploads/woocommerce_uploads/.htaccess new file mode 100644 index 0000000..3418e55 --- /dev/null +++ b/backend/wp-content/uploads/woocommerce_uploads/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/backend/wp-content/uploads/woocommerce_uploads/index.html b/backend/wp-content/uploads/woocommerce_uploads/index.html new file mode 100644 index 0000000..e69de29 diff --git a/backend/wp-cron.php b/backend/wp-cron.php new file mode 100644 index 0000000..da526d2 --- /dev/null +++ b/backend/wp-cron.php @@ -0,0 +1,138 @@ +get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", '_transient_doing_cron' ) ); + if ( is_object( $row ) ) + $value = $row->option_value; + } + + return $value; +} + +if ( false === $crons = _get_cron_array() ) + die(); + +$keys = array_keys( $crons ); +$gmt_time = microtime( true ); + +if ( isset($keys[0]) && $keys[0] > $gmt_time ) + die(); + + +// The cron lock: a unix timestamp from when the cron was spawned. +$doing_cron_transient = get_transient( 'doing_cron' ); + +// Use global $doing_wp_cron lock otherwise use the GET lock. If no lock, trying grabbing a new lock. +if ( empty( $doing_wp_cron ) ) { + if ( empty( $_GET[ 'doing_wp_cron' ] ) ) { + // Called from external script/job. Try setting a lock. + if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) + return; + $doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) ); + set_transient( 'doing_cron', $doing_wp_cron ); + } else { + $doing_wp_cron = $_GET[ 'doing_wp_cron' ]; + } +} + +/* + * The cron lock (a unix timestamp set when the cron was spawned), + * must match $doing_wp_cron (the "key"). + */ +if ( $doing_cron_transient != $doing_wp_cron ) + return; + +foreach ( $crons as $timestamp => $cronhooks ) { + if ( $timestamp > $gmt_time ) + break; + + foreach ( $cronhooks as $hook => $keys ) { + + foreach ( $keys as $k => $v ) { + + $schedule = $v['schedule']; + + if ( $schedule != false ) { + $new_args = array($timestamp, $schedule, $hook, $v['args']); + call_user_func_array('wp_reschedule_event', $new_args); + } + + wp_unschedule_event( $timestamp, $hook, $v['args'] ); + + /** + * Fires scheduled events. + * + * @ignore + * @since 2.1.0 + * + * @param string $hook Name of the hook that was scheduled to be fired. + * @param array $args The arguments to be passed to the hook. + */ + do_action_ref_array( $hook, $v['args'] ); + + // If the hook ran too long and another cron process stole the lock, quit. + if ( _get_cron_lock() != $doing_wp_cron ) + return; + } + } +} + +if ( _get_cron_lock() == $doing_wp_cron ) + delete_transient( 'doing_cron' ); + +die(); diff --git a/backend/wp-includes/ID3/getid3.lib.php b/backend/wp-includes/ID3/getid3.lib.php new file mode 100644 index 0000000..1931bb3 --- /dev/null +++ b/backend/wp-includes/ID3/getid3.lib.php @@ -0,0 +1,1436 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// // +// getid3.lib.php - part of getID3() // +// See readme.txt for more details // +// /// +///////////////////////////////////////////////////////////////// + + +class getid3_lib +{ + + public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') { + $returnstring = ''; + for ($i = 0; $i < strlen($string); $i++) { + if ($hex) { + $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT); + } else { + $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '¤'); + } + if ($spaces) { + $returnstring .= ' '; + } + } + if (!empty($htmlencoding)) { + if ($htmlencoding === true) { + $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean + } + $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding); + } + return $returnstring; + } + + public static function trunc($floatnumber) { + // truncates a floating-point number at the decimal point + // returns int (if possible, otherwise float) + if ($floatnumber >= 1) { + $truncatednumber = floor($floatnumber); + } elseif ($floatnumber <= -1) { + $truncatednumber = ceil($floatnumber); + } else { + $truncatednumber = 0; + } + if (self::intValueSupported($truncatednumber)) { + $truncatednumber = (int) $truncatednumber; + } + return $truncatednumber; + } + + + public static function safe_inc(&$variable, $increment=1) { + if (isset($variable)) { + $variable += $increment; + } else { + $variable = $increment; + } + return true; + } + + public static function CastAsInt($floatnum) { + // convert to float if not already + $floatnum = (float) $floatnum; + + // convert a float to type int, only if possible + if (self::trunc($floatnum) == $floatnum) { + // it's not floating point + if (self::intValueSupported($floatnum)) { + // it's within int range + $floatnum = (int) $floatnum; + } + } + return $floatnum; + } + + public static function intValueSupported($num) { + // check if integers are 64-bit + static $hasINT64 = null; + if ($hasINT64 === null) { // 10x faster than is_null() + $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1 + if (!$hasINT64 && !defined('PHP_INT_MIN')) { + define('PHP_INT_MIN', ~PHP_INT_MAX); + } + } + // if integers are 64-bit - no other check required + if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) { + return true; + } + return false; + } + + public static function DecimalizeFraction($fraction) { + list($numerator, $denominator) = explode('/', $fraction); + return $numerator / ($denominator ? $denominator : 1); + } + + + public static function DecimalBinary2Float($binarynumerator) { + $numerator = self::Bin2Dec($binarynumerator); + $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator))); + return ($numerator / $denominator); + } + + + public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) { + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html + if (strpos($binarypointnumber, '.') === false) { + $binarypointnumber = '0.'.$binarypointnumber; + } elseif ($binarypointnumber{0} == '.') { + $binarypointnumber = '0'.$binarypointnumber; + } + $exponent = 0; + while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) { + if (substr($binarypointnumber, 1, 1) == '.') { + $exponent--; + $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3); + } else { + $pointpos = strpos($binarypointnumber, '.'); + $exponent += ($pointpos - 1); + $binarypointnumber = str_replace('.', '', $binarypointnumber); + $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1); + } + } + $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT); + return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent); + } + + + public static function Float2BinaryDecimal($floatvalue) { + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html + $maxbits = 128; // to how many bits of precision should the calculations be taken? + $intpart = self::trunc($floatvalue); + $floatpart = abs($floatvalue - $intpart); + $pointbitstring = ''; + while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) { + $floatpart *= 2; + $pointbitstring .= (string) self::trunc($floatpart); + $floatpart -= self::trunc($floatpart); + } + $binarypointnumber = decbin($intpart).'.'.$pointbitstring; + return $binarypointnumber; + } + + + public static function Float2String($floatvalue, $bits) { + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html + switch ($bits) { + case 32: + $exponentbits = 8; + $fractionbits = 23; + break; + + case 64: + $exponentbits = 11; + $fractionbits = 52; + break; + + default: + return false; + break; + } + if ($floatvalue >= 0) { + $signbit = '0'; + } else { + $signbit = '1'; + } + $normalizedbinary = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits); + $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent + $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT); + $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT); + + return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false); + } + + + public static function LittleEndian2Float($byteword) { + return self::BigEndian2Float(strrev($byteword)); + } + + + public static function BigEndian2Float($byteword) { + // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic + // http://www.psc.edu/general/software/packages/ieee/ieee.html + // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html + + $bitword = self::BigEndian2Bin($byteword); + if (!$bitword) { + return 0; + } + $signbit = $bitword{0}; + + switch (strlen($byteword) * 8) { + case 32: + $exponentbits = 8; + $fractionbits = 23; + break; + + case 64: + $exponentbits = 11; + $fractionbits = 52; + break; + + case 80: + // 80-bit Apple SANE format + // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ + $exponentstring = substr($bitword, 1, 15); + $isnormalized = intval($bitword{16}); + $fractionstring = substr($bitword, 17, 63); + $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383); + $fraction = $isnormalized + self::DecimalBinary2Float($fractionstring); + $floatvalue = $exponent * $fraction; + if ($signbit == '1') { + $floatvalue *= -1; + } + return $floatvalue; + break; + + default: + return false; + break; + } + $exponentstring = substr($bitword, 1, $exponentbits); + $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits); + $exponent = self::Bin2Dec($exponentstring); + $fraction = self::Bin2Dec($fractionstring); + + if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) { + // Not a Number + $floatvalue = false; + } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) { + if ($signbit == '1') { + $floatvalue = '-infinity'; + } else { + $floatvalue = '+infinity'; + } + } elseif (($exponent == 0) && ($fraction == 0)) { + if ($signbit == '1') { + $floatvalue = -0; + } else { + $floatvalue = 0; + } + $floatvalue = ($signbit ? 0 : -0); + } elseif (($exponent == 0) && ($fraction != 0)) { + // These are 'unnormalized' values + $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring); + if ($signbit == '1') { + $floatvalue *= -1; + } + } elseif ($exponent != 0) { + $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring)); + if ($signbit == '1') { + $floatvalue *= -1; + } + } + return (float) $floatvalue; + } + + + public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) { + $intvalue = 0; + $bytewordlen = strlen($byteword); + if ($bytewordlen == 0) { + return false; + } + for ($i = 0; $i < $bytewordlen; $i++) { + if ($synchsafe) { // disregard MSB, effectively 7-bit bytes + //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems + $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7); + } else { + $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i)); + } + } + if ($signed && !$synchsafe) { + // synchsafe ints are not allowed to be signed + if ($bytewordlen <= PHP_INT_SIZE) { + $signMaskBit = 0x80 << (8 * ($bytewordlen - 1)); + if ($intvalue & $signMaskBit) { + $intvalue = 0 - ($intvalue & ($signMaskBit - 1)); + } + } else { + throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()'); + } + } + return self::CastAsInt($intvalue); + } + + + public static function LittleEndian2Int($byteword, $signed=false) { + return self::BigEndian2Int(strrev($byteword), false, $signed); + } + + public static function LittleEndian2Bin($byteword) { + return self::BigEndian2Bin(strrev($byteword)); + } + + public static function BigEndian2Bin($byteword) { + $binvalue = ''; + $bytewordlen = strlen($byteword); + for ($i = 0; $i < $bytewordlen; $i++) { + $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT); + } + return $binvalue; + } + + + public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) { + if ($number < 0) { + throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers'); + } + $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF); + $intstring = ''; + if ($signed) { + if ($minbytes > PHP_INT_SIZE) { + throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()'); + } + $number = $number & (0x80 << (8 * ($minbytes - 1))); + } + while ($number != 0) { + $quotient = ($number / ($maskbyte + 1)); + $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring; + $number = floor($quotient); + } + return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT); + } + + + public static function Dec2Bin($number) { + while ($number >= 256) { + $bytes[] = (($number / 256) - (floor($number / 256))) * 256; + $number = floor($number / 256); + } + $bytes[] = $number; + $binstring = ''; + for ($i = 0; $i < count($bytes); $i++) { + $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring; + } + return $binstring; + } + + + public static function Bin2Dec($binstring, $signed=false) { + $signmult = 1; + if ($signed) { + if ($binstring{0} == '1') { + $signmult = -1; + } + $binstring = substr($binstring, 1); + } + $decvalue = 0; + for ($i = 0; $i < strlen($binstring); $i++) { + $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i); + } + return self::CastAsInt($decvalue * $signmult); + } + + + public static function Bin2String($binstring) { + // return 'hi' for input of '0110100001101001' + $string = ''; + $binstringreversed = strrev($binstring); + for ($i = 0; $i < strlen($binstringreversed); $i += 8) { + $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string; + } + return $string; + } + + + public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) { + $intstring = ''; + while ($number > 0) { + if ($synchsafe) { + $intstring = $intstring.chr($number & 127); + $number >>= 7; + } else { + $intstring = $intstring.chr($number & 255); + $number >>= 8; + } + } + return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT); + } + + + public static function array_merge_clobber($array1, $array2) { + // written by kcØhireability*com + // taken from http://www.php.net/manual/en/function.array-merge-recursive.php + if (!is_array($array1) || !is_array($array2)) { + return false; + } + $newarray = $array1; + foreach ($array2 as $key => $val) { + if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) { + $newarray[$key] = self::array_merge_clobber($newarray[$key], $val); + } else { + $newarray[$key] = $val; + } + } + return $newarray; + } + + + public static function array_merge_noclobber($array1, $array2) { + if (!is_array($array1) || !is_array($array2)) { + return false; + } + $newarray = $array1; + foreach ($array2 as $key => $val) { + if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) { + $newarray[$key] = self::array_merge_noclobber($newarray[$key], $val); + } elseif (!isset($newarray[$key])) { + $newarray[$key] = $val; + } + } + return $newarray; + } + + public static function flipped_array_merge_noclobber($array1, $array2) { + if (!is_array($array1) || !is_array($array2)) { + return false; + } + # naturally, this only works non-recursively + $newarray = array_flip($array1); + foreach (array_flip($array2) as $key => $val) { + if (!isset($newarray[$key])) { + $newarray[$key] = count($newarray); + } + } + return array_flip($newarray); + } + + + public static function ksort_recursive(&$theArray) { + ksort($theArray); + foreach ($theArray as $key => $value) { + if (is_array($value)) { + self::ksort_recursive($theArray[$key]); + } + } + return true; + } + + public static function fileextension($filename, $numextensions=1) { + if (strstr($filename, '.')) { + $reversedfilename = strrev($filename); + $offset = 0; + for ($i = 0; $i < $numextensions; $i++) { + $offset = strpos($reversedfilename, '.', $offset + 1); + if ($offset === false) { + return ''; + } + } + return strrev(substr($reversedfilename, 0, $offset)); + } + return ''; + } + + + public static function PlaytimeString($seconds) { + $sign = (($seconds < 0) ? '-' : ''); + $seconds = round(abs($seconds)); + $H = (int) floor( $seconds / 3600); + $M = (int) floor(($seconds - (3600 * $H) ) / 60); + $S = (int) round( $seconds - (3600 * $H) - (60 * $M) ); + return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT); + } + + + public static function DateMac2Unix($macdate) { + // Macintosh timestamp: seconds since 00:00h January 1, 1904 + // UNIX timestamp: seconds since 00:00h January 1, 1970 + return self::CastAsInt($macdate - 2082844800); + } + + + public static function FixedPoint8_8($rawdata) { + return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8)); + } + + + public static function FixedPoint16_16($rawdata) { + return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16)); + } + + + public static function FixedPoint2_30($rawdata) { + $binarystring = self::BigEndian2Bin($rawdata); + return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30)); + } + + + public static function CreateDeepArray($ArrayPath, $Separator, $Value) { + // assigns $Value to a nested array path: + // $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt') + // is the same as: + // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt')))); + // or + // $foo['path']['to']['my'] = 'file.txt'; + $ArrayPath = ltrim($ArrayPath, $Separator); + if (($pos = strpos($ArrayPath, $Separator)) !== false) { + $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value); + } else { + $ReturnedArray[$ArrayPath] = $Value; + } + return $ReturnedArray; + } + + public static function array_max($arraydata, $returnkey=false) { + $maxvalue = false; + $maxkey = false; + foreach ($arraydata as $key => $value) { + if (!is_array($value)) { + if ($value > $maxvalue) { + $maxvalue = $value; + $maxkey = $key; + } + } + } + return ($returnkey ? $maxkey : $maxvalue); + } + + public static function array_min($arraydata, $returnkey=false) { + $minvalue = false; + $minkey = false; + foreach ($arraydata as $key => $value) { + if (!is_array($value)) { + if ($value > $minvalue) { + $minvalue = $value; + $minkey = $key; + } + } + } + return ($returnkey ? $minkey : $minvalue); + } + + public static function XML2array($XMLstring) { + if (function_exists('simplexml_load_string') && function_exists('libxml_disable_entity_loader')) { + // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html + // https://core.trac.wordpress.org/changeset/29378 + $loader = libxml_disable_entity_loader(true); + $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT); + $return = self::SimpleXMLelement2array($XMLobject); + libxml_disable_entity_loader($loader); + return $return; + } + return false; + } + + public static function SimpleXMLelement2array($XMLobject) { + if (!is_object($XMLobject) && !is_array($XMLobject)) { + return $XMLobject; + } + $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject); + foreach ($XMLarray as $key => $value) { + $XMLarray[$key] = self::SimpleXMLelement2array($value); + } + return $XMLarray; + } + + + // Allan Hansen + // self::md5_data() - returns md5sum for a file from startuing position to absolute end position + public static function hash_data($file, $offset, $end, $algorithm) { + static $tempdir = ''; + if (!self::intValueSupported($end)) { + return false; + } + switch ($algorithm) { + case 'md5': + $hash_function = 'md5_file'; + $unix_call = 'md5sum'; + $windows_call = 'md5sum.exe'; + $hash_length = 32; + break; + + case 'sha1': + $hash_function = 'sha1_file'; + $unix_call = 'sha1sum'; + $windows_call = 'sha1sum.exe'; + $hash_length = 40; + break; + + default: + throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()'); + break; + } + $size = $end - $offset; + while (true) { + if (GETID3_OS_ISWINDOWS) { + + // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data + // Fall back to create-temp-file method: + if ($algorithm == 'sha1') { + break; + } + + $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call); + foreach ($RequiredFiles as $required_file) { + if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) { + // helper apps not available - fall back to old method + break 2; + } + } + $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | '; + $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | '; + $commandline .= GETID3_HELPERAPPSDIR.$windows_call; + + } else { + + $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | '; + $commandline .= 'tail -c'.$size.' | '; + $commandline .= $unix_call; + + } + if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { + //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm'); + break; + } + return substr(`$commandline`, 0, $hash_length); + } + + if (empty($tempdir)) { + // yes this is ugly, feel free to suggest a better way + require_once(dirname(__FILE__).'/getid3.php'); + $getid3_temp = new getID3(); + $tempdir = $getid3_temp->tempdir; + unset($getid3_temp); + } + // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir + if (($data_filename = tempnam($tempdir, 'gI3')) === false) { + // can't find anywhere to create a temp file, just fail + return false; + } + + // Init + $result = false; + + // copy parts of file + try { + self::CopyFileParts($file, $data_filename, $offset, $end - $offset); + $result = $hash_function($data_filename); + } catch (Exception $e) { + throw new Exception('self::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage()); + } + unlink($data_filename); + return $result; + } + + public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) { + if (!self::intValueSupported($offset + $length)) { + throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit'); + } + if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) { + if (($fp_dest = fopen($filename_dest, 'wb'))) { + if (fseek($fp_src, $offset) == 0) { + $byteslefttowrite = $length; + while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) { + $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite); + $byteslefttowrite -= $byteswritten; + } + return true; + } else { + throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source); + } + fclose($fp_dest); + } else { + throw new Exception('failed to create file for writing '.$filename_dest); + } + fclose($fp_src); + } else { + throw new Exception('failed to open file for reading '.$filename_source); + } + return false; + } + + public static function iconv_fallback_int_utf8($charval) { + if ($charval < 128) { + // 0bbbbbbb + $newcharstring = chr($charval); + } elseif ($charval < 2048) { + // 110bbbbb 10bbbbbb + $newcharstring = chr(($charval >> 6) | 0xC0); + $newcharstring .= chr(($charval & 0x3F) | 0x80); + } elseif ($charval < 65536) { + // 1110bbbb 10bbbbbb 10bbbbbb + $newcharstring = chr(($charval >> 12) | 0xE0); + $newcharstring .= chr(($charval >> 6) | 0xC0); + $newcharstring .= chr(($charval & 0x3F) | 0x80); + } else { + // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + $newcharstring = chr(($charval >> 18) | 0xF0); + $newcharstring .= chr(($charval >> 12) | 0xC0); + $newcharstring .= chr(($charval >> 6) | 0xC0); + $newcharstring .= chr(($charval & 0x3F) | 0x80); + } + return $newcharstring; + } + + // ISO-8859-1 => UTF-8 + public static function iconv_fallback_iso88591_utf8($string, $bom=false) { + if (function_exists('utf8_encode')) { + return utf8_encode($string); + } + // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support) + $newcharstring = ''; + if ($bom) { + $newcharstring .= "\xEF\xBB\xBF"; + } + for ($i = 0; $i < strlen($string); $i++) { + $charval = ord($string{$i}); + $newcharstring .= self::iconv_fallback_int_utf8($charval); + } + return $newcharstring; + } + + // ISO-8859-1 => UTF-16BE + public static function iconv_fallback_iso88591_utf16be($string, $bom=false) { + $newcharstring = ''; + if ($bom) { + $newcharstring .= "\xFE\xFF"; + } + for ($i = 0; $i < strlen($string); $i++) { + $newcharstring .= "\x00".$string{$i}; + } + return $newcharstring; + } + + // ISO-8859-1 => UTF-16LE + public static function iconv_fallback_iso88591_utf16le($string, $bom=false) { + $newcharstring = ''; + if ($bom) { + $newcharstring .= "\xFF\xFE"; + } + for ($i = 0; $i < strlen($string); $i++) { + $newcharstring .= $string{$i}."\x00"; + } + return $newcharstring; + } + + // ISO-8859-1 => UTF-16LE (BOM) + public static function iconv_fallback_iso88591_utf16($string) { + return self::iconv_fallback_iso88591_utf16le($string, true); + } + + // UTF-8 => ISO-8859-1 + public static function iconv_fallback_utf8_iso88591($string) { + if (function_exists('utf8_decode')) { + return utf8_decode($string); + } + // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support) + $newcharstring = ''; + $offset = 0; + $stringlength = strlen($string); + while ($offset < $stringlength) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { + // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & + ((ord($string{($offset + 1)}) & 0x3F) << 12) & + ((ord($string{($offset + 2)}) & 0x3F) << 6) & + (ord($string{($offset + 3)}) & 0x3F); + $offset += 4; + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { + // 1110bbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & + ((ord($string{($offset + 1)}) & 0x3F) << 6) & + (ord($string{($offset + 2)}) & 0x3F); + $offset += 3; + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { + // 110bbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & + (ord($string{($offset + 1)}) & 0x3F); + $offset += 2; + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { + // 0bbbbbbb + $charval = ord($string{$offset}); + $offset += 1; + } else { + // error? throw some kind of warning here? + $charval = false; + $offset += 1; + } + if ($charval !== false) { + $newcharstring .= (($charval < 256) ? chr($charval) : '?'); + } + } + return $newcharstring; + } + + // UTF-8 => UTF-16BE + public static function iconv_fallback_utf8_utf16be($string, $bom=false) { + $newcharstring = ''; + if ($bom) { + $newcharstring .= "\xFE\xFF"; + } + $offset = 0; + $stringlength = strlen($string); + while ($offset < $stringlength) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { + // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & + ((ord($string{($offset + 1)}) & 0x3F) << 12) & + ((ord($string{($offset + 2)}) & 0x3F) << 6) & + (ord($string{($offset + 3)}) & 0x3F); + $offset += 4; + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { + // 1110bbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & + ((ord($string{($offset + 1)}) & 0x3F) << 6) & + (ord($string{($offset + 2)}) & 0x3F); + $offset += 3; + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { + // 110bbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & + (ord($string{($offset + 1)}) & 0x3F); + $offset += 2; + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { + // 0bbbbbbb + $charval = ord($string{$offset}); + $offset += 1; + } else { + // error? throw some kind of warning here? + $charval = false; + $offset += 1; + } + if ($charval !== false) { + $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?'); + } + } + return $newcharstring; + } + + // UTF-8 => UTF-16LE + public static function iconv_fallback_utf8_utf16le($string, $bom=false) { + $newcharstring = ''; + if ($bom) { + $newcharstring .= "\xFF\xFE"; + } + $offset = 0; + $stringlength = strlen($string); + while ($offset < $stringlength) { + if ((ord($string{$offset}) | 0x07) == 0xF7) { + // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) & + ((ord($string{($offset + 1)}) & 0x3F) << 12) & + ((ord($string{($offset + 2)}) & 0x3F) << 6) & + (ord($string{($offset + 3)}) & 0x3F); + $offset += 4; + } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) { + // 1110bbbb 10bbbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) & + ((ord($string{($offset + 1)}) & 0x3F) << 6) & + (ord($string{($offset + 2)}) & 0x3F); + $offset += 3; + } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) { + // 110bbbbb 10bbbbbb + $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) & + (ord($string{($offset + 1)}) & 0x3F); + $offset += 2; + } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) { + // 0bbbbbbb + $charval = ord($string{$offset}); + $offset += 1; + } else { + // error? maybe throw some warning here? + $charval = false; + $offset += 1; + } + if ($charval !== false) { + $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00"); + } + } + return $newcharstring; + } + + // UTF-8 => UTF-16LE (BOM) + public static function iconv_fallback_utf8_utf16($string) { + return self::iconv_fallback_utf8_utf16le($string, true); + } + + // UTF-16BE => UTF-8 + public static function iconv_fallback_utf16be_utf8($string) { + if (substr($string, 0, 2) == "\xFE\xFF") { + // strip BOM + $string = substr($string, 2); + } + $newcharstring = ''; + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::BigEndian2Int(substr($string, $i, 2)); + $newcharstring .= self::iconv_fallback_int_utf8($charval); + } + return $newcharstring; + } + + // UTF-16LE => UTF-8 + public static function iconv_fallback_utf16le_utf8($string) { + if (substr($string, 0, 2) == "\xFF\xFE") { + // strip BOM + $string = substr($string, 2); + } + $newcharstring = ''; + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::LittleEndian2Int(substr($string, $i, 2)); + $newcharstring .= self::iconv_fallback_int_utf8($charval); + } + return $newcharstring; + } + + // UTF-16BE => ISO-8859-1 + public static function iconv_fallback_utf16be_iso88591($string) { + if (substr($string, 0, 2) == "\xFE\xFF") { + // strip BOM + $string = substr($string, 2); + } + $newcharstring = ''; + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::BigEndian2Int(substr($string, $i, 2)); + $newcharstring .= (($charval < 256) ? chr($charval) : '?'); + } + return $newcharstring; + } + + // UTF-16LE => ISO-8859-1 + public static function iconv_fallback_utf16le_iso88591($string) { + if (substr($string, 0, 2) == "\xFF\xFE") { + // strip BOM + $string = substr($string, 2); + } + $newcharstring = ''; + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::LittleEndian2Int(substr($string, $i, 2)); + $newcharstring .= (($charval < 256) ? chr($charval) : '?'); + } + return $newcharstring; + } + + // UTF-16 (BOM) => ISO-8859-1 + public static function iconv_fallback_utf16_iso88591($string) { + $bom = substr($string, 0, 2); + if ($bom == "\xFE\xFF") { + return self::iconv_fallback_utf16be_iso88591(substr($string, 2)); + } elseif ($bom == "\xFF\xFE") { + return self::iconv_fallback_utf16le_iso88591(substr($string, 2)); + } + return $string; + } + + // UTF-16 (BOM) => UTF-8 + public static function iconv_fallback_utf16_utf8($string) { + $bom = substr($string, 0, 2); + if ($bom == "\xFE\xFF") { + return self::iconv_fallback_utf16be_utf8(substr($string, 2)); + } elseif ($bom == "\xFF\xFE") { + return self::iconv_fallback_utf16le_utf8(substr($string, 2)); + } + return $string; + } + + public static function iconv_fallback($in_charset, $out_charset, $string) { + + if ($in_charset == $out_charset) { + return $string; + } + + // mb_convert_encoding() availble + if (function_exists('mb_convert_encoding')) { + if ($converted_string = @mb_convert_encoding($string, $out_charset, $in_charset)) { + switch ($out_charset) { + case 'ISO-8859-1': + $converted_string = rtrim($converted_string, "\x00"); + break; + } + return $converted_string; + } + return $string; + } + // iconv() availble + else if (function_exists('iconv')) { + if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) { + switch ($out_charset) { + case 'ISO-8859-1': + $converted_string = rtrim($converted_string, "\x00"); + break; + } + return $converted_string; + } + + // iconv() may sometimes fail with "illegal character in input string" error message + // and return an empty string, but returning the unconverted string is more useful + return $string; + } + + + // neither mb_convert_encoding or iconv() is available + static $ConversionFunctionList = array(); + if (empty($ConversionFunctionList)) { + $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8'; + $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16'; + $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be'; + $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le'; + $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591'; + $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16'; + $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be'; + $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le'; + $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591'; + $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8'; + $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591'; + $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8'; + $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591'; + $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8'; + } + if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) { + $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)]; + return self::$ConversionFunction($string); + } + throw new Exception('PHP does not has mb_convert_encoding() or iconv() support - cannot convert from '.$in_charset.' to '.$out_charset); + } + + public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') { + if (is_string($data)) { + return self::MultiByteCharString2HTML($data, $charset); + } elseif (is_array($data)) { + $return_data = array(); + foreach ($data as $key => $value) { + $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset); + } + return $return_data; + } + // integer, float, objects, resources, etc + return $data; + } + + public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') { + $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string + $HTMLstring = ''; + + switch (strtolower($charset)) { + case '1251': + case '1252': + case '866': + case '932': + case '936': + case '950': + case 'big5': + case 'big5-hkscs': + case 'cp1251': + case 'cp1252': + case 'cp866': + case 'euc-jp': + case 'eucjp': + case 'gb2312': + case 'ibm866': + case 'iso-8859-1': + case 'iso-8859-15': + case 'iso8859-1': + case 'iso8859-15': + case 'koi8-r': + case 'koi8-ru': + case 'koi8r': + case 'shift_jis': + case 'sjis': + case 'win-1251': + case 'windows-1251': + case 'windows-1252': + $HTMLstring = htmlentities($string, ENT_COMPAT, $charset); + break; + + case 'utf-8': + $strlen = strlen($string); + for ($i = 0; $i < $strlen; $i++) { + $char_ord_val = ord($string{$i}); + $charval = 0; + if ($char_ord_val < 0x80) { + $charval = $char_ord_val; + } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) { + $charval = (($char_ord_val & 0x07) << 18); + $charval += ((ord($string{++$i}) & 0x3F) << 12); + $charval += ((ord($string{++$i}) & 0x3F) << 6); + $charval += (ord($string{++$i}) & 0x3F); + } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) { + $charval = (($char_ord_val & 0x0F) << 12); + $charval += ((ord($string{++$i}) & 0x3F) << 6); + $charval += (ord($string{++$i}) & 0x3F); + } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) { + $charval = (($char_ord_val & 0x1F) << 6); + $charval += (ord($string{++$i}) & 0x3F); + } + if (($charval >= 32) && ($charval <= 127)) { + $HTMLstring .= htmlentities(chr($charval)); + } else { + $HTMLstring .= '&#'.$charval.';'; + } + } + break; + + case 'utf-16le': + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::LittleEndian2Int(substr($string, $i, 2)); + if (($charval >= 32) && ($charval <= 127)) { + $HTMLstring .= chr($charval); + } else { + $HTMLstring .= '&#'.$charval.';'; + } + } + break; + + case 'utf-16be': + for ($i = 0; $i < strlen($string); $i += 2) { + $charval = self::BigEndian2Int(substr($string, $i, 2)); + if (($charval >= 32) && ($charval <= 127)) { + $HTMLstring .= chr($charval); + } else { + $HTMLstring .= '&#'.$charval.';'; + } + } + break; + + default: + $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()'; + break; + } + return $HTMLstring; + } + + + + public static function RGADnameLookup($namecode) { + static $RGADname = array(); + if (empty($RGADname)) { + $RGADname[0] = 'not set'; + $RGADname[1] = 'Track Gain Adjustment'; + $RGADname[2] = 'Album Gain Adjustment'; + } + + return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : ''); + } + + + public static function RGADoriginatorLookup($originatorcode) { + static $RGADoriginator = array(); + if (empty($RGADoriginator)) { + $RGADoriginator[0] = 'unspecified'; + $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer'; + $RGADoriginator[2] = 'set by user'; + $RGADoriginator[3] = 'determined automatically'; + } + + return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : ''); + } + + + public static function RGADadjustmentLookup($rawadjustment, $signbit) { + $adjustment = $rawadjustment / 10; + if ($signbit == 1) { + $adjustment *= -1; + } + return (float) $adjustment; + } + + + public static function RGADgainString($namecode, $originatorcode, $replaygain) { + if ($replaygain < 0) { + $signbit = '1'; + } else { + $signbit = '0'; + } + $storedreplaygain = intval(round($replaygain * 10)); + $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT); + $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT); + $gainstring .= $signbit; + $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT); + + return $gainstring; + } + + public static function RGADamplitude2dB($amplitude) { + return 20 * log10($amplitude); + } + + + public static function GetDataImageSize($imgData, &$imageinfo=array()) { + static $tempdir = ''; + if (empty($tempdir)) { + if (function_exists('sys_get_temp_dir')) { + $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52 + } + + // yes this is ugly, feel free to suggest a better way + if (include_once(dirname(__FILE__).'/getid3.php')) { + if ($getid3_temp = new getID3()) { + if ($getid3_temp_tempdir = $getid3_temp->tempdir) { + $tempdir = $getid3_temp_tempdir; + } + unset($getid3_temp, $getid3_temp_tempdir); + } + } + } + $GetDataImageSize = false; + if ($tempfilename = tempnam($tempdir, 'gI3')) { + if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) { + fwrite($tmp, $imgData); + fclose($tmp); + $GetDataImageSize = @getimagesize($tempfilename, $imageinfo); + if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) { + return false; + } + $GetDataImageSize['height'] = $GetDataImageSize[0]; + $GetDataImageSize['width'] = $GetDataImageSize[1]; + } + unlink($tempfilename); + } + return $GetDataImageSize; + } + + public static function ImageExtFromMime($mime_type) { + // temporary way, works OK for now, but should be reworked in the future + return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type); + } + + public static function ImageTypesLookup($imagetypeid) { + static $ImageTypesLookup = array(); + if (empty($ImageTypesLookup)) { + $ImageTypesLookup[1] = 'gif'; + $ImageTypesLookup[2] = 'jpeg'; + $ImageTypesLookup[3] = 'png'; + $ImageTypesLookup[4] = 'swf'; + $ImageTypesLookup[5] = 'psd'; + $ImageTypesLookup[6] = 'bmp'; + $ImageTypesLookup[7] = 'tiff (little-endian)'; + $ImageTypesLookup[8] = 'tiff (big-endian)'; + $ImageTypesLookup[9] = 'jpc'; + $ImageTypesLookup[10] = 'jp2'; + $ImageTypesLookup[11] = 'jpx'; + $ImageTypesLookup[12] = 'jb2'; + $ImageTypesLookup[13] = 'swc'; + $ImageTypesLookup[14] = 'iff'; + } + return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : ''); + } + + public static function CopyTagsToComments(&$ThisFileInfo) { + + // Copy all entries from ['tags'] into common ['comments'] + if (!empty($ThisFileInfo['tags'])) { + foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) { + foreach ($tagarray as $tagname => $tagdata) { + foreach ($tagdata as $key => $value) { + if (!empty($value)) { + if (empty($ThisFileInfo['comments'][$tagname])) { + + // fall through and append value + + } elseif ($tagtype == 'id3v1') { + + $newvaluelength = strlen(trim($value)); + foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) { + $oldvaluelength = strlen(trim($existingvalue)); + if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) { + // new value is identical but shorter-than (or equal-length to) one already in comments - skip + break 2; + } + } + + } elseif (!is_array($value)) { + + $newvaluelength = strlen(trim($value)); + foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) { + $oldvaluelength = strlen(trim($existingvalue)); + if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) { + $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value); + //break 2; + break; + } + } + + } + if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) { + $value = (is_string($value) ? trim($value) : $value); + if (!is_int($key) && !ctype_digit($key)) { + $ThisFileInfo['comments'][$tagname][$key] = $value; + } else { + if (isset($ThisFileInfo['comments'][$tagname])) { + $ThisFileInfo['comments'][$tagname] = array($value); + } else { + $ThisFileInfo['comments'][$tagname][] = $value; + } + } + } + } + } + } + } + + // attempt to standardize spelling of returned keys + $StandardizeFieldNames = array( + 'tracknumber' => 'track_number', + 'track' => 'track_number', + ); + foreach ($StandardizeFieldNames as $badkey => $goodkey) { + if (array_key_exists($badkey, $ThisFileInfo['comments']) && !array_key_exists($goodkey, $ThisFileInfo['comments'])) { + $ThisFileInfo['comments'][$goodkey] = $ThisFileInfo['comments'][$badkey]; + unset($ThisFileInfo['comments'][$badkey]); + } + } + + // Copy to ['comments_html'] + if (!empty($ThisFileInfo['comments'])) { + foreach ($ThisFileInfo['comments'] as $field => $values) { + if ($field == 'picture') { + // pictures can take up a lot of space, and we don't need multiple copies of them + // let there be a single copy in [comments][picture], and not elsewhere + continue; + } + foreach ($values as $index => $value) { + if (is_array($value)) { + $ThisFileInfo['comments_html'][$field][$index] = $value; + } else { + $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding'])); + } + } + } + } + + } + return true; + } + + + public static function EmbeddedLookup($key, $begin, $end, $file, $name) { + + // Cached + static $cache; + if (isset($cache[$file][$name])) { + return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : ''); + } + + // Init + $keylength = strlen($key); + $line_count = $end - $begin - 7; + + // Open php file + $fp = fopen($file, 'r'); + + // Discard $begin lines + for ($i = 0; $i < ($begin + 3); $i++) { + fgets($fp, 1024); + } + + // Loop thru line + while (0 < $line_count--) { + + // Read line + $line = ltrim(fgets($fp, 1024), "\t "); + + // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key + //$keycheck = substr($line, 0, $keylength); + //if ($key == $keycheck) { + // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1); + // break; + //} + + // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key + //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1)); + $explodedLine = explode("\t", $line, 2); + $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : ''); + $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : ''); + $cache[$file][$name][$ThisKey] = trim($ThisValue); + } + + // Close and return + fclose($fp); + return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : ''); + } + + public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) { + global $GETID3_ERRORARRAY; + + if (file_exists($filename)) { + if (include_once($filename)) { + return true; + } else { + $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors'; + } + } else { + $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing'; + } + if ($DieOnFailure) { + throw new Exception($diemessage); + } else { + $GETID3_ERRORARRAY[] = $diemessage; + } + return false; + } + + public static function trimNullByte($string) { + return trim($string, "\x00"); + } + + public static function getFileSizeSyscall($path) { + $filesize = false; + + if (GETID3_OS_ISWINDOWS) { + if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini: + $filesystem = new COM('Scripting.FileSystemObject'); + $file = $filesystem->GetFile($path); + $filesize = $file->Size(); + unset($filesystem, $file); + } else { + $commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI'; + } + } else { + $commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\''; + } + if (isset($commandline)) { + $output = trim(`$commandline`); + if (ctype_digit($output)) { + $filesize = (float) $output; + } + } + return $filesize; + } + + + /** + * Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268) + * @param string $path A path. + * @param string $suffix If the name component ends in suffix this will also be cut off. + * @return string + */ + public static function mb_basename($path, $suffix = null) { + $splited = preg_split('#/#', rtrim($path, '/ ')); + return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1); + } + +} diff --git a/backend/wp-includes/ID3/getid3.php b/backend/wp-includes/ID3/getid3.php new file mode 100644 index 0000000..7732c19 --- /dev/null +++ b/backend/wp-includes/ID3/getid3.php @@ -0,0 +1,1844 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// // +// Please see readme.txt for more information // +// /// +///////////////////////////////////////////////////////////////// + +// define a constant rather than looking up every time it is needed +if (!defined('GETID3_OS_ISWINDOWS')) { + define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0)); +} +// Get base path of getID3() - ONCE +if (!defined('GETID3_INCLUDEPATH')) { + define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR); +} +// Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923) +if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) { + define('IMG_JPG', IMAGETYPE_JPEG); +} +if (!defined('ENT_SUBSTITUTE')) { // PHP5.3 adds ENT_IGNORE, PHP5.4 adds ENT_SUBSTITUTE + define('ENT_SUBSTITUTE', (defined('ENT_IGNORE') ? ENT_IGNORE : 8)); +} + +// attempt to define temp dir as something flexible but reliable +$temp_dir = ini_get('upload_tmp_dir'); +if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) { + $temp_dir = ''; +} +if (!$temp_dir && function_exists('sys_get_temp_dir')) { // sys_get_temp_dir added in PHP v5.2.1 + // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts + $temp_dir = sys_get_temp_dir(); +} +$temp_dir = @realpath($temp_dir); // see https://github.com/JamesHeinrich/getID3/pull/10 +$open_basedir = ini_get('open_basedir'); +if ($open_basedir) { + // e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/" + $temp_dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir); + $open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir); + if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) { + $temp_dir .= DIRECTORY_SEPARATOR; + } + $found_valid_tempdir = false; + $open_basedirs = explode(PATH_SEPARATOR, $open_basedir); + foreach ($open_basedirs as $basedir) { + if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) { + $basedir .= DIRECTORY_SEPARATOR; + } + if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) { + $found_valid_tempdir = true; + break; + } + } + if (!$found_valid_tempdir) { + $temp_dir = ''; + } + unset($open_basedirs, $found_valid_tempdir, $basedir); +} +if (!$temp_dir) { + $temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir +} +// $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system +if (!defined('GETID3_TEMP_DIR')) { + define('GETID3_TEMP_DIR', $temp_dir); +} +unset($open_basedir, $temp_dir); + +// End: Defines + + +class getID3 +{ + // public: Settings + public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE + public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252' + + // public: Optional tag checks - disable for speed. + public $option_tag_id3v1 = true; // Read and process ID3v1 tags + public $option_tag_id3v2 = true; // Read and process ID3v2 tags + public $option_tag_lyrics3 = true; // Read and process Lyrics3 tags + public $option_tag_apetag = true; // Read and process APE tags + public $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding + public $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities + + // public: Optional tag/comment calucations + public $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc + + // public: Optional handling of embedded attachments (e.g. images) + public $option_save_attachments = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility + + // public: Optional calculations + public $option_md5_data = false; // Get MD5 sum of data part - slow + public $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG + public $option_sha1_data = false; // Get SHA1 sum of data part - slow + public $option_max_2gb_check = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX) + + // public: Read buffer size in bytes + public $option_fread_buffer_size = 32768; + + // Public variables + public $filename; // Filename of file being analysed. + public $fp; // Filepointer to file being analysed. + public $info; // Result array. + public $tempdir = GETID3_TEMP_DIR; + public $memory_limit = 0; + + // Protected variables + protected $startup_error = ''; + protected $startup_warning = ''; + + const VERSION = '1.9.14-201706111222'; + const FREAD_BUFFER_SIZE = 32768; + + const ATTACHMENTS_NONE = false; + const ATTACHMENTS_INLINE = true; + + // public: constructor + public function __construct() { + + // Check memory + $this->memory_limit = ini_get('memory_limit'); + if (preg_match('#([0-9]+) ?M#i', $this->memory_limit, $matches)) { + // could be stored as "16M" rather than 16777216 for example + $this->memory_limit = $matches[1] * 1048576; + } elseif (preg_match('#([0-9]+) ?G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0 + // could be stored as "2G" rather than 2147483648 for example + $this->memory_limit = $matches[1] * 1073741824; + } + if ($this->memory_limit <= 0) { + // memory limits probably disabled + } elseif ($this->memory_limit <= 4194304) { + $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini'."\n"; + } elseif ($this->memory_limit <= 12582912) { + $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini'."\n"; + } + + // Check safe_mode off + if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { + $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.'); + } + + if (($mbstring_func_overload = ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) { + // http://php.net/manual/en/mbstring.overload.php + // "mbstring.func_overload in php.ini is a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions" + // getID3 cannot run when string functions are overloaded. It doesn't matter if mail() or ereg* functions are overloaded since getID3 does not use those. + $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n"; + } + + // Check for magic_quotes_runtime + if (function_exists('get_magic_quotes_runtime')) { + if (get_magic_quotes_runtime()) { + $this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n"; + } + } + + // Check for magic_quotes_gpc + if (function_exists('magic_quotes_gpc')) { + if (get_magic_quotes_gpc()) { + $this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n"; + } + } + + // Load support library + if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) { + $this->startup_error .= 'getid3.lib.php is missing or corrupt'."\n"; + } + + if ($this->option_max_2gb_check === null) { + $this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647); + } + + + // Needed for Windows only: + // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC + // as well as other helper functions such as head, tail, md5sum, etc + // This path cannot contain spaces, but the below code will attempt to get the + // 8.3-equivalent path automatically + // IMPORTANT: This path must include the trailing slash + if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) { + + $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path + + if (!is_dir($helperappsdir)) { + $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist'."\n"; + } elseif (strpos(realpath($helperappsdir), ' ') !== false) { + $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir)); + $path_so_far = array(); + foreach ($DirPieces as $key => $value) { + if (strpos($value, ' ') !== false) { + if (!empty($path_so_far)) { + $commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far)); + $dir_listing = `$commandline`; + $lines = explode("\n", $dir_listing); + foreach ($lines as $line) { + $line = trim($line); + if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) { + list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches; + if ((strtoupper($filesize) == '') && (strtolower($filename) == strtolower($value))) { + $value = $shortname; + } + } + } + } else { + $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.'."\n"; + } + } + $path_so_far[] = $value; + } + $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far); + } + define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR); + } + + if (!empty($this->startup_error)) { + echo $this->startup_error; + throw new getid3_exception($this->startup_error); + } + + return true; + } + + public function version() { + return self::VERSION; + } + + public function fread_buffer_size() { + return $this->option_fread_buffer_size; + } + + + // public: setOption + public function setOption($optArray) { + if (!is_array($optArray) || empty($optArray)) { + return false; + } + foreach ($optArray as $opt => $val) { + if (isset($this->$opt) === false) { + continue; + } + $this->$opt = $val; + } + return true; + } + + + public function openfile($filename, $filesize=null) { + try { + if (!empty($this->startup_error)) { + throw new getid3_exception($this->startup_error); + } + if (!empty($this->startup_warning)) { + foreach (explode("\n", $this->startup_warning) as $startup_warning) { + $this->warning($startup_warning); + } + } + + // init result array and set parameters + $this->filename = $filename; + $this->info = array(); + $this->info['GETID3_VERSION'] = $this->version(); + $this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false); + + // remote files not supported + if (preg_match('#^(ht|f)tp://#', $filename)) { + throw new getid3_exception('Remote files are not supported - please copy the file locally first'); + } + + $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename); + $filename = preg_replace('#(?fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720 + if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { + // great + } else { + $errormessagelist = array(); + if (!is_readable($filename)) { + $errormessagelist[] = '!is_readable'; + } + if (!is_file($filename)) { + $errormessagelist[] = '!is_file'; + } + if (!file_exists($filename)) { + $errormessagelist[] = '!file_exists'; + } + if (empty($errormessagelist)) { + $errormessagelist[] = 'fopen failed'; + } + throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')'); + } + + $this->info['filesize'] = (!is_null($filesize) ? $filesize : filesize($filename)); + // set redundant parameters - might be needed in some include file + // filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion + $filename = str_replace('\\', '/', $filename); + $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename))); + $this->info['filename'] = getid3_lib::mb_basename($filename); + $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename']; + + // set more parameters + $this->info['avdataoffset'] = 0; + $this->info['avdataend'] = $this->info['filesize']; + $this->info['fileformat'] = ''; // filled in later + $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used + $this->info['video']['dataformat'] = ''; // filled in later, unset if not used + $this->info['tags'] = array(); // filled in later, unset if not used + $this->info['error'] = array(); // filled in later, unset if not used + $this->info['warning'] = array(); // filled in later, unset if not used + $this->info['comments'] = array(); // filled in later, unset if not used + $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired + + // option_max_2gb_check + if ($this->option_max_2gb_check) { + // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB) + // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize + // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer + $fseek = fseek($this->fp, 0, SEEK_END); + if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) || + ($this->info['filesize'] < 0) || + (ftell($this->fp) < 0)) { + $real_filesize = getid3_lib::getFileSizeSyscall($this->info['filenamepath']); + + if ($real_filesize === false) { + unset($this->info['filesize']); + fclose($this->fp); + throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.'); + } elseif (getid3_lib::intValueSupported($real_filesize)) { + unset($this->info['filesize']); + fclose($this->fp); + throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org'); + } + $this->info['filesize'] = $real_filesize; + $this->warning('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.'); + } + } + + return true; + + } catch (Exception $e) { + $this->error($e->getMessage()); + } + return false; + } + + // public: analyze file + public function analyze($filename, $filesize=null, $original_filename='') { + try { + if (!$this->openfile($filename, $filesize)) { + return $this->info; + } + + // Handle tags + foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) { + $option_tag = 'option_tag_'.$tag_name; + if ($this->$option_tag) { + $this->include_module('tag.'.$tag_name); + try { + $tag_class = 'getid3_'.$tag_name; + $tag = new $tag_class($this); + $tag->Analyze(); + } + catch (getid3_exception $e) { + throw $e; + } + } + } + if (isset($this->info['id3v2']['tag_offset_start'])) { + $this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']); + } + foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) { + if (isset($this->info[$tag_key]['tag_offset_start'])) { + $this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']); + } + } + + // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier + if (!$this->option_tag_id3v2) { + fseek($this->fp, 0); + $header = fread($this->fp, 10); + if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) { + $this->info['id3v2']['header'] = true; + $this->info['id3v2']['majorversion'] = ord($header{3}); + $this->info['id3v2']['minorversion'] = ord($header{4}); + $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length + } + } + + // read 32 kb file data + fseek($this->fp, $this->info['avdataoffset']); + $formattest = fread($this->fp, 32774); + + // determine format + $determined_format = $this->GetFileFormat($formattest, ($original_filename ? $original_filename : $filename)); + + // unable to determine file format + if (!$determined_format) { + fclose($this->fp); + return $this->error('unable to determine file format'); + } + + // check for illegal ID3 tags + if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) { + if ($determined_format['fail_id3'] === 'ERROR') { + fclose($this->fp); + return $this->error('ID3 tags not allowed on this file type.'); + } elseif ($determined_format['fail_id3'] === 'WARNING') { + $this->warning('ID3 tags not allowed on this file type.'); + } + } + + // check for illegal APE tags + if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) { + if ($determined_format['fail_ape'] === 'ERROR') { + fclose($this->fp); + return $this->error('APE tags not allowed on this file type.'); + } elseif ($determined_format['fail_ape'] === 'WARNING') { + $this->warning('APE tags not allowed on this file type.'); + } + } + + // set mime type + $this->info['mime_type'] = $determined_format['mime_type']; + + // supported format signature pattern detected, but module deleted + if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) { + fclose($this->fp); + return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.'); + } + + // module requires mb_convert_encoding/iconv support + // Check encoding/iconv support + if (!empty($determined_format['iconv_req']) && !function_exists('mb_convert_encoding') && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) { + $errormessage = 'mb_convert_encoding() or iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. '; + if (GETID3_OS_ISWINDOWS) { + $errormessage .= 'PHP does not have mb_convert_encoding() or iconv() support. Please enable php_mbstring.dll / php_iconv.dll in php.ini, and copy php_mbstring.dll / iconv.dll from c:/php/dlls to c:/windows/system32'; + } else { + $errormessage .= 'PHP is not compiled with mb_convert_encoding() or iconv() support. Please recompile with the --enable-mbstring / --with-iconv switch'; + } + return $this->error($errormessage); + } + + // include module + include_once(GETID3_INCLUDEPATH.$determined_format['include']); + + // instantiate module class + $class_name = 'getid3_'.$determined_format['module']; + if (!class_exists($class_name)) { + return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.'); + } + $class = new $class_name($this); + $class->Analyze(); + unset($class); + + // close file + fclose($this->fp); + + // process all tags - copy to 'tags' and convert charsets + if ($this->option_tags_process) { + $this->HandleAllTags(); + } + + // perform more calculations + if ($this->option_extra_info) { + $this->ChannelsBitratePlaytimeCalculations(); + $this->CalculateCompressionRatioVideo(); + $this->CalculateCompressionRatioAudio(); + $this->CalculateReplayGain(); + $this->ProcessAudioStreams(); + } + + // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags + if ($this->option_md5_data) { + // do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too + if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) { + $this->getHashdata('md5'); + } + } + + // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags + if ($this->option_sha1_data) { + $this->getHashdata('sha1'); + } + + // remove undesired keys + $this->CleanUp(); + + } catch (Exception $e) { + $this->error('Caught exception: '.$e->getMessage()); + } + + // return info array + return $this->info; + } + + + // private: error handling + public function error($message) { + $this->CleanUp(); + if (!isset($this->info['error'])) { + $this->info['error'] = array(); + } + $this->info['error'][] = $message; + return $this->info; + } + + + // private: warning handling + public function warning($message) { + $this->info['warning'][] = $message; + return true; + } + + + // private: CleanUp + private function CleanUp() { + + // remove possible empty keys + $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate'); + foreach ($AVpossibleEmptyKeys as $dummy => $key) { + if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) { + unset($this->info['audio'][$key]); + } + if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) { + unset($this->info['video'][$key]); + } + } + + // remove empty root keys + if (!empty($this->info)) { + foreach ($this->info as $key => $value) { + if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) { + unset($this->info[$key]); + } + } + } + + // remove meaningless entries from unknown-format files + if (empty($this->info['fileformat'])) { + if (isset($this->info['avdataoffset'])) { + unset($this->info['avdataoffset']); + } + if (isset($this->info['avdataend'])) { + unset($this->info['avdataend']); + } + } + + // remove possible duplicated identical entries + if (!empty($this->info['error'])) { + $this->info['error'] = array_values(array_unique($this->info['error'])); + } + if (!empty($this->info['warning'])) { + $this->info['warning'] = array_values(array_unique($this->info['warning'])); + } + + // remove "global variable" type keys + unset($this->info['php_memory_limit']); + + return true; + } + + + // return array containing information about all supported formats + public function GetFileFormatArray() { + static $format_info = array(); + if (empty($format_info)) { + $format_info = array( + + // Audio formats + + // AC-3 - audio - Dolby AC-3 / Dolby Digital + 'ac3' => array( + 'pattern' => '^\\x0B\\x77', + 'group' => 'audio', + 'module' => 'ac3', + 'mime_type' => 'audio/ac3', + ), + + // AAC - audio - Advanced Audio Coding (AAC) - ADIF format + 'adif' => array( + 'pattern' => '^ADIF', + 'group' => 'audio', + 'module' => 'aac', + 'mime_type' => 'application/octet-stream', + 'fail_ape' => 'WARNING', + ), + +/* + // AA - audio - Audible Audiobook + 'aa' => array( + 'pattern' => '^.{4}\\x57\\x90\\x75\\x36', + 'group' => 'audio', + 'module' => 'aa', + 'mime_type' => 'audio/audible', + ), +*/ + // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) + 'adts' => array( + 'pattern' => '^\\xFF[\\xF0-\\xF1\\xF8-\\xF9]', + 'group' => 'audio', + 'module' => 'aac', + 'mime_type' => 'application/octet-stream', + 'fail_ape' => 'WARNING', + ), + + + // AU - audio - NeXT/Sun AUdio (AU) + 'au' => array( + 'pattern' => '^\\.snd', + 'group' => 'audio', + 'module' => 'au', + 'mime_type' => 'audio/basic', + ), + + // AMR - audio - Adaptive Multi Rate + 'amr' => array( + 'pattern' => '^\\x23\\x21AMR\\x0A', // #!AMR[0A] + 'group' => 'audio', + 'module' => 'amr', + 'mime_type' => 'audio/amr', + ), + + // AVR - audio - Audio Visual Research + 'avr' => array( + 'pattern' => '^2BIT', + 'group' => 'audio', + 'module' => 'avr', + 'mime_type' => 'application/octet-stream', + ), + + // BONK - audio - Bonk v0.9+ + 'bonk' => array( + 'pattern' => '^\\x00(BONK|INFO|META| ID3)', + 'group' => 'audio', + 'module' => 'bonk', + 'mime_type' => 'audio/xmms-bonk', + ), + + // DSF - audio - Direct Stream Digital (DSD) Storage Facility files (DSF) - https://en.wikipedia.org/wiki/Direct_Stream_Digital + 'dsf' => array( + 'pattern' => '^DSD ', // including trailing space: 44 53 44 20 + 'group' => 'audio', + 'module' => 'dsf', + 'mime_type' => 'audio/dsd', + ), + + // DSS - audio - Digital Speech Standard + 'dss' => array( + 'pattern' => '^[\\x02-\\x06]ds[s2]', + 'group' => 'audio', + 'module' => 'dss', + 'mime_type' => 'application/octet-stream', + ), + + // DTS - audio - Dolby Theatre System + 'dts' => array( + 'pattern' => '^\\x7F\\xFE\\x80\\x01', + 'group' => 'audio', + 'module' => 'dts', + 'mime_type' => 'audio/dts', + ), + + // FLAC - audio - Free Lossless Audio Codec + 'flac' => array( + 'pattern' => '^fLaC', + 'group' => 'audio', + 'module' => 'flac', + 'mime_type' => 'audio/x-flac', + ), + + // LA - audio - Lossless Audio (LA) + 'la' => array( + 'pattern' => '^LA0[2-4]', + 'group' => 'audio', + 'module' => 'la', + 'mime_type' => 'application/octet-stream', + ), + + // LPAC - audio - Lossless Predictive Audio Compression (LPAC) + 'lpac' => array( + 'pattern' => '^LPAC', + 'group' => 'audio', + 'module' => 'lpac', + 'mime_type' => 'application/octet-stream', + ), + + // MIDI - audio - MIDI (Musical Instrument Digital Interface) + 'midi' => array( + 'pattern' => '^MThd', + 'group' => 'audio', + 'module' => 'midi', + 'mime_type' => 'audio/midi', + ), + + // MAC - audio - Monkey's Audio Compressor + 'mac' => array( + 'pattern' => '^MAC ', + 'group' => 'audio', + 'module' => 'monkey', + 'mime_type' => 'application/octet-stream', + ), + +// has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available +// // MOD - audio - MODule (assorted sub-formats) +// 'mod' => array( +// 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', +// 'group' => 'audio', +// 'module' => 'mod', +// 'option' => 'mod', +// 'mime_type' => 'audio/mod', +// ), + + // MOD - audio - MODule (Impulse Tracker) + 'it' => array( + 'pattern' => '^IMPM', + 'group' => 'audio', + 'module' => 'mod', + //'option' => 'it', + 'mime_type' => 'audio/it', + ), + + // MOD - audio - MODule (eXtended Module, various sub-formats) + 'xm' => array( + 'pattern' => '^Extended Module', + 'group' => 'audio', + 'module' => 'mod', + //'option' => 'xm', + 'mime_type' => 'audio/xm', + ), + + // MOD - audio - MODule (ScreamTracker) + 's3m' => array( + 'pattern' => '^.{44}SCRM', + 'group' => 'audio', + 'module' => 'mod', + //'option' => 's3m', + 'mime_type' => 'audio/s3m', + ), + + // MPC - audio - Musepack / MPEGplus + 'mpc' => array( + 'pattern' => '^(MPCK|MP\\+|[\\x00\\x01\\x10\\x11\\x40\\x41\\x50\\x51\\x80\\x81\\x90\\x91\\xC0\\xC1\\xD0\\xD1][\\x20-\\x37][\\x00\\x20\\x40\\x60\\x80\\xA0\\xC0\\xE0])', + 'group' => 'audio', + 'module' => 'mpc', + 'mime_type' => 'audio/x-musepack', + ), + + // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) + 'mp3' => array( + 'pattern' => '^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\x0B\\x10-\\x1B\\x20-\\x2B\\x30-\\x3B\\x40-\\x4B\\x50-\\x5B\\x60-\\x6B\\x70-\\x7B\\x80-\\x8B\\x90-\\x9B\\xA0-\\xAB\\xB0-\\xBB\\xC0-\\xCB\\xD0-\\xDB\\xE0-\\xEB\\xF0-\\xFB]', + 'group' => 'audio', + 'module' => 'mp3', + 'mime_type' => 'audio/mpeg', + ), + + // OFR - audio - OptimFROG + 'ofr' => array( + 'pattern' => '^(\\*RIFF|OFR)', + 'group' => 'audio', + 'module' => 'optimfrog', + 'mime_type' => 'application/octet-stream', + ), + + // RKAU - audio - RKive AUdio compressor + 'rkau' => array( + 'pattern' => '^RKA', + 'group' => 'audio', + 'module' => 'rkau', + 'mime_type' => 'application/octet-stream', + ), + + // SHN - audio - Shorten + 'shn' => array( + 'pattern' => '^ajkg', + 'group' => 'audio', + 'module' => 'shorten', + 'mime_type' => 'audio/xmms-shn', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) + 'tta' => array( + 'pattern' => '^TTA', // could also be '^TTA(\\x01|\\x02|\\x03|2|1)' + 'group' => 'audio', + 'module' => 'tta', + 'mime_type' => 'application/octet-stream', + ), + + // VOC - audio - Creative Voice (VOC) + 'voc' => array( + 'pattern' => '^Creative Voice File', + 'group' => 'audio', + 'module' => 'voc', + 'mime_type' => 'audio/voc', + ), + + // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF) + 'vqf' => array( + 'pattern' => '^TWIN', + 'group' => 'audio', + 'module' => 'vqf', + 'mime_type' => 'application/octet-stream', + ), + + // WV - audio - WavPack (v4.0+) + 'wv' => array( + 'pattern' => '^wvpk', + 'group' => 'audio', + 'module' => 'wavpack', + 'mime_type' => 'application/octet-stream', + ), + + + // Audio-Video formats + + // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio + 'asf' => array( + 'pattern' => '^\\x30\\x26\\xB2\\x75\\x8E\\x66\\xCF\\x11\\xA6\\xD9\\x00\\xAA\\x00\\x62\\xCE\\x6C', + 'group' => 'audio-video', + 'module' => 'asf', + 'mime_type' => 'video/x-ms-asf', + 'iconv_req' => false, + ), + + // BINK - audio/video - Bink / Smacker + 'bink' => array( + 'pattern' => '^(BIK|SMK)', + 'group' => 'audio-video', + 'module' => 'bink', + 'mime_type' => 'application/octet-stream', + ), + + // FLV - audio/video - FLash Video + 'flv' => array( + 'pattern' => '^FLV[\\x01]', + 'group' => 'audio-video', + 'module' => 'flv', + 'mime_type' => 'video/x-flv', + ), + + // MKAV - audio/video - Mastroka + 'matroska' => array( + 'pattern' => '^\\x1A\\x45\\xDF\\xA3', + 'group' => 'audio-video', + 'module' => 'matroska', + 'mime_type' => 'video/x-matroska', // may also be audio/x-matroska + ), + + // MPEG - audio/video - MPEG (Moving Pictures Experts Group) + 'mpeg' => array( + 'pattern' => '^\\x00\\x00\\x01[\\xB3\\xBA]', + 'group' => 'audio-video', + 'module' => 'mpeg', + 'mime_type' => 'video/mpeg', + ), + + // NSV - audio/video - Nullsoft Streaming Video (NSV) + 'nsv' => array( + 'pattern' => '^NSV[sf]', + 'group' => 'audio-video', + 'module' => 'nsv', + 'mime_type' => 'application/octet-stream', + ), + + // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*)) + 'ogg' => array( + 'pattern' => '^OggS', + 'group' => 'audio', + 'module' => 'ogg', + 'mime_type' => 'application/ogg', + 'fail_id3' => 'WARNING', + 'fail_ape' => 'WARNING', + ), + + // QT - audio/video - Quicktime + 'quicktime' => array( + 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)', + 'group' => 'audio-video', + 'module' => 'quicktime', + 'mime_type' => 'video/quicktime', + ), + + // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF) + 'riff' => array( + 'pattern' => '^(RIFF|SDSS|FORM)', + 'group' => 'audio-video', + 'module' => 'riff', + 'mime_type' => 'audio/x-wav', + 'fail_ape' => 'WARNING', + ), + + // Real - audio/video - RealAudio, RealVideo + 'real' => array( + 'pattern' => '^\\.(RMF|ra)', + 'group' => 'audio-video', + 'module' => 'real', + 'mime_type' => 'audio/x-realaudio', + ), + + // SWF - audio/video - ShockWave Flash + 'swf' => array( + 'pattern' => '^(F|C)WS', + 'group' => 'audio-video', + 'module' => 'swf', + 'mime_type' => 'application/x-shockwave-flash', + ), + + // TS - audio/video - MPEG-2 Transport Stream + 'ts' => array( + 'pattern' => '^(\\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern + 'group' => 'audio-video', + 'module' => 'ts', + 'mime_type' => 'video/MP2T', + ), + + + // Still-Image formats + + // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4) + 'bmp' => array( + 'pattern' => '^BM', + 'group' => 'graphic', + 'module' => 'bmp', + 'mime_type' => 'image/bmp', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // GIF - still image - Graphics Interchange Format + 'gif' => array( + 'pattern' => '^GIF', + 'group' => 'graphic', + 'module' => 'gif', + 'mime_type' => 'image/gif', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // JPEG - still image - Joint Photographic Experts Group (JPEG) + 'jpg' => array( + 'pattern' => '^\\xFF\\xD8\\xFF', + 'group' => 'graphic', + 'module' => 'jpg', + 'mime_type' => 'image/jpeg', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // PCD - still image - Kodak Photo CD + 'pcd' => array( + 'pattern' => '^.{2048}PCD_IPI\\x00', + 'group' => 'graphic', + 'module' => 'pcd', + 'mime_type' => 'image/x-photo-cd', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // PNG - still image - Portable Network Graphics (PNG) + 'png' => array( + 'pattern' => '^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A', + 'group' => 'graphic', + 'module' => 'png', + 'mime_type' => 'image/png', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // SVG - still image - Scalable Vector Graphics (SVG) + 'svg' => array( + 'pattern' => '( 'graphic', + 'module' => 'svg', + 'mime_type' => 'image/svg+xml', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // TIFF - still image - Tagged Information File Format (TIFF) + 'tiff' => array( + 'pattern' => '^(II\\x2A\\x00|MM\\x00\\x2A)', + 'group' => 'graphic', + 'module' => 'tiff', + 'mime_type' => 'image/tiff', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // EFAX - still image - eFax (TIFF derivative) + 'efax' => array( + 'pattern' => '^\\xDC\\xFE', + 'group' => 'graphic', + 'module' => 'efax', + 'mime_type' => 'image/efax', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // Data formats + + // ISO - data - International Standards Organization (ISO) CD-ROM Image + 'iso' => array( + 'pattern' => '^.{32769}CD001', + 'group' => 'misc', + 'module' => 'iso', + 'mime_type' => 'application/octet-stream', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + 'iconv_req' => false, + ), + + // RAR - data - RAR compressed data + 'rar' => array( + 'pattern' => '^Rar\\!', + 'group' => 'archive', + 'module' => 'rar', + 'mime_type' => 'application/octet-stream', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // SZIP - audio/data - SZIP compressed data + 'szip' => array( + 'pattern' => '^SZ\\x0A\\x04', + 'group' => 'archive', + 'module' => 'szip', + 'mime_type' => 'application/octet-stream', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // TAR - data - TAR compressed data + 'tar' => array( + 'pattern' => '^.{100}[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20\\x00]{12}[0-9\\x20\\x00]{12}', + 'group' => 'archive', + 'module' => 'tar', + 'mime_type' => 'application/x-tar', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // GZIP - data - GZIP compressed data + 'gz' => array( + 'pattern' => '^\\x1F\\x8B\\x08', + 'group' => 'archive', + 'module' => 'gzip', + 'mime_type' => 'application/x-gzip', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // ZIP - data - ZIP compressed data + 'zip' => array( + 'pattern' => '^PK\\x03\\x04', + 'group' => 'archive', + 'module' => 'zip', + 'mime_type' => 'application/zip', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + + // Misc other formats + + // PAR2 - data - Parity Volume Set Specification 2.0 + 'par2' => array ( + 'pattern' => '^PAR2\\x00PKT', + 'group' => 'misc', + 'module' => 'par2', + 'mime_type' => 'application/octet-stream', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // PDF - data - Portable Document Format + 'pdf' => array( + 'pattern' => '^\\x25PDF', + 'group' => 'misc', + 'module' => 'pdf', + 'mime_type' => 'application/pdf', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // MSOFFICE - data - ZIP compressed data + 'msoffice' => array( + 'pattern' => '^\\xD0\\xCF\\x11\\xE0\\xA1\\xB1\\x1A\\xE1', // D0CF11E == DOCFILE == Microsoft Office Document + 'group' => 'misc', + 'module' => 'msoffice', + 'mime_type' => 'application/octet-stream', + 'fail_id3' => 'ERROR', + 'fail_ape' => 'ERROR', + ), + + // CUE - data - CUEsheet (index to single-file disc images) + 'cue' => array( + 'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents + 'group' => 'misc', + 'module' => 'cue', + 'mime_type' => 'application/octet-stream', + ), + + ); + } + + return $format_info; + } + + + + public function GetFileFormat(&$filedata, $filename='') { + // this function will determine the format of a file based on usually + // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG, + // and in the case of ISO CD image, 6 bytes offset 32kb from the start + // of the file). + + // Identify file format - loop through $format_info and detect with reg expr + foreach ($this->GetFileFormatArray() as $format_name => $info) { + // The /s switch on preg_match() forces preg_match() NOT to treat + // newline (0x0A) characters as special chars but do a binary match + if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) { + $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; + return $info; + } + } + + + if (preg_match('#\\.mp[123a]$#i', $filename)) { + // Too many mp3 encoders on the market put gabage in front of mpeg files + // use assume format on these if format detection failed + $GetFileFormatArray = $this->GetFileFormatArray(); + $info = $GetFileFormatArray['mp3']; + $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; + return $info; + } elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) { + // there's not really a useful consistent "magic" at the beginning of .cue files to identify them + // so until I think of something better, just go by filename if all other format checks fail + // and verify there's at least one instance of "TRACK xx AUDIO" in the file + $GetFileFormatArray = $this->GetFileFormatArray(); + $info = $GetFileFormatArray['cue']; + $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; + return $info; + } + + return false; + } + + + // converts array to $encoding charset from $this->encoding + public function CharConvert(&$array, $encoding) { + + // identical encoding - end here + if ($encoding == $this->encoding) { + return; + } + + // loop thru array + foreach ($array as $key => $value) { + + // go recursive + if (is_array($value)) { + $this->CharConvert($array[$key], $encoding); + } + + // convert string + elseif (is_string($value)) { + $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value)); + } + } + } + + + public function HandleAllTags() { + + // key name => array (tag name, character encoding) + static $tags; + if (empty($tags)) { + $tags = array( + 'asf' => array('asf' , 'UTF-16LE'), + 'midi' => array('midi' , 'ISO-8859-1'), + 'nsv' => array('nsv' , 'ISO-8859-1'), + 'ogg' => array('vorbiscomment' , 'UTF-8'), + 'png' => array('png' , 'UTF-8'), + 'tiff' => array('tiff' , 'ISO-8859-1'), + 'quicktime' => array('quicktime' , 'UTF-8'), + 'real' => array('real' , 'ISO-8859-1'), + 'vqf' => array('vqf' , 'ISO-8859-1'), + 'zip' => array('zip' , 'ISO-8859-1'), + 'riff' => array('riff' , 'ISO-8859-1'), + 'lyrics3' => array('lyrics3' , 'ISO-8859-1'), + 'id3v1' => array('id3v1' , $this->encoding_id3v1), + 'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8 + 'ape' => array('ape' , 'UTF-8'), + 'cue' => array('cue' , 'ISO-8859-1'), + 'matroska' => array('matroska' , 'UTF-8'), + 'flac' => array('vorbiscomment' , 'UTF-8'), + 'divxtag' => array('divx' , 'ISO-8859-1'), + 'iptc' => array('iptc' , 'ISO-8859-1'), + ); + } + + // loop through comments array + foreach ($tags as $comment_name => $tagname_encoding_array) { + list($tag_name, $encoding) = $tagname_encoding_array; + + // fill in default encoding type if not already present + if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) { + $this->info[$comment_name]['encoding'] = $encoding; + } + + // copy comments if key name set + if (!empty($this->info[$comment_name]['comments'])) { + foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) { + foreach ($valuearray as $key => $value) { + if (is_string($value)) { + $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed! + } + if ($value) { + if (!is_numeric($key)) { + $this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value; + } else { + $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; + } + } + } + if ($tag_key == 'picture') { + unset($this->info[$comment_name]['comments'][$tag_key]); + } + } + + if (!isset($this->info['tags'][$tag_name])) { + // comments are set but contain nothing but empty strings, so skip + continue; + } + + $this->CharConvert($this->info['tags'][$tag_name], $this->info[$comment_name]['encoding']); // only copy gets converted! + + if ($this->option_tags_html) { + foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) { + $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $this->info[$comment_name]['encoding']); + } + } + + } + + } + + // pictures can take up a lot of space, and we don't need multiple copies of them + // let there be a single copy in [comments][picture], and not elsewhere + if (!empty($this->info['tags'])) { + $unset_keys = array('tags', 'tags_html'); + foreach ($this->info['tags'] as $tagtype => $tagarray) { + foreach ($tagarray as $tagname => $tagdata) { + if ($tagname == 'picture') { + foreach ($tagdata as $key => $tagarray) { + $this->info['comments']['picture'][] = $tagarray; + if (isset($tagarray['data']) && isset($tagarray['image_mime'])) { + if (isset($this->info['tags'][$tagtype][$tagname][$key])) { + unset($this->info['tags'][$tagtype][$tagname][$key]); + } + if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) { + unset($this->info['tags_html'][$tagtype][$tagname][$key]); + } + } + } + } + } + foreach ($unset_keys as $unset_key) { + // remove possible empty keys from (e.g. [tags][id3v2][picture]) + if (empty($this->info[$unset_key][$tagtype]['picture'])) { + unset($this->info[$unset_key][$tagtype]['picture']); + } + if (empty($this->info[$unset_key][$tagtype])) { + unset($this->info[$unset_key][$tagtype]); + } + if (empty($this->info[$unset_key])) { + unset($this->info[$unset_key]); + } + } + // remove duplicate copy of picture data from (e.g. [id3v2][comments][picture]) + if (isset($this->info[$tagtype]['comments']['picture'])) { + unset($this->info[$tagtype]['comments']['picture']); + } + if (empty($this->info[$tagtype]['comments'])) { + unset($this->info[$tagtype]['comments']); + } + if (empty($this->info[$tagtype])) { + unset($this->info[$tagtype]); + } + } + } + return true; + } + + public function getHashdata($algorithm) { + switch ($algorithm) { + case 'md5': + case 'sha1': + break; + + default: + return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()'); + break; + } + + if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) { + + // We cannot get an identical md5_data value for Ogg files where the comments + // span more than 1 Ogg page (compared to the same audio data with smaller + // comments) using the normal getID3() method of MD5'ing the data between the + // end of the comments and the end of the file (minus any trailing tags), + // because the page sequence numbers of the pages that the audio data is on + // do not match. Under normal circumstances, where comments are smaller than + // the nominal 4-8kB page size, then this is not a problem, but if there are + // very large comments, the only way around it is to strip off the comment + // tags with vorbiscomment and MD5 that file. + // This procedure must be applied to ALL Ogg files, not just the ones with + // comments larger than 1 page, because the below method simply MD5's the + // whole file with the comments stripped, not just the portion after the + // comments block (which is the standard getID3() method. + + // The above-mentioned problem of comments spanning multiple pages and changing + // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but + // currently vorbiscomment only works on OggVorbis files. + + if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { + + $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)'); + $this->info[$algorithm.'_data'] = false; + + } else { + + // Prevent user from aborting script + $old_abort = ignore_user_abort(true); + + // Create empty file + $empty = tempnam(GETID3_TEMP_DIR, 'getID3'); + touch($empty); + + // Use vorbiscomment to make temp file without comments + $temp = tempnam(GETID3_TEMP_DIR, 'getID3'); + $file = $this->info['filenamepath']; + + if (GETID3_OS_ISWINDOWS) { + + if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) { + + $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"'; + $VorbisCommentError = `$commandline`; + + } else { + + $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR; + + } + + } else { + + $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1'; + $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1'; + $VorbisCommentError = `$commandline`; + + } + + if (!empty($VorbisCommentError)) { + + $this->warning('Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError); + $this->info[$algorithm.'_data'] = false; + + } else { + + // Get hash of newly created file + switch ($algorithm) { + case 'md5': + $this->info[$algorithm.'_data'] = md5_file($temp); + break; + + case 'sha1': + $this->info[$algorithm.'_data'] = sha1_file($temp); + break; + } + } + + // Clean up + unlink($empty); + unlink($temp); + + // Reset abort setting + ignore_user_abort($old_abort); + + } + + } else { + + if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) { + + // get hash from part of file + $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm); + + } else { + + // get hash from whole file + switch ($algorithm) { + case 'md5': + $this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']); + break; + + case 'sha1': + $this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']); + break; + } + } + + } + return true; + } + + + public function ChannelsBitratePlaytimeCalculations() { + + // set channelmode on audio + if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) { + // ignore + } elseif ($this->info['audio']['channels'] == 1) { + $this->info['audio']['channelmode'] = 'mono'; + } elseif ($this->info['audio']['channels'] == 2) { + $this->info['audio']['channelmode'] = 'stereo'; + } + + // Calculate combined bitrate - audio + video + $CombinedBitrate = 0; + $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0); + $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0); + if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) { + $this->info['bitrate'] = $CombinedBitrate; + } + //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) { + // // for example, VBR MPEG video files cannot determine video bitrate: + // // should not set overall bitrate and playtime from audio bitrate only + // unset($this->info['bitrate']); + //} + + // video bitrate undetermined, but calculable + if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) { + // if video bitrate not set + if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) { + // AND if audio bitrate is set to same as overall bitrate + if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) { + // AND if playtime is set + if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) { + // AND if AV data offset start/end is known + // THEN we can calculate the video bitrate + $this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']); + $this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate']; + } + } + } + } + + if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) { + $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate']; + } + + if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) { + $this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']; + } + if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) { + if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) { + // audio only + $this->info['audio']['bitrate'] = $this->info['bitrate']; + } elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) { + // video only + $this->info['video']['bitrate'] = $this->info['bitrate']; + } + } + + // Set playtime string + if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) { + $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']); + } + } + + + public function CalculateCompressionRatioVideo() { + if (empty($this->info['video'])) { + return false; + } + if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) { + return false; + } + if (empty($this->info['video']['bits_per_sample'])) { + return false; + } + + switch ($this->info['video']['dataformat']) { + case 'bmp': + case 'gif': + case 'jpeg': + case 'jpg': + case 'png': + case 'tiff': + $FrameRate = 1; + $PlaytimeSeconds = 1; + $BitrateCompressed = $this->info['filesize'] * 8; + break; + + default: + if (!empty($this->info['video']['frame_rate'])) { + $FrameRate = $this->info['video']['frame_rate']; + } else { + return false; + } + if (!empty($this->info['playtime_seconds'])) { + $PlaytimeSeconds = $this->info['playtime_seconds']; + } else { + return false; + } + if (!empty($this->info['video']['bitrate'])) { + $BitrateCompressed = $this->info['video']['bitrate']; + } else { + return false; + } + break; + } + $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate; + + $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed; + return true; + } + + + public function CalculateCompressionRatioAudio() { + if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) { + return false; + } + $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16)); + + if (!empty($this->info['audio']['streams'])) { + foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) { + if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) { + $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16)); + } + } + } + return true; + } + + + public function CalculateReplayGain() { + if (isset($this->info['replay_gain'])) { + if (!isset($this->info['replay_gain']['reference_volume'])) { + $this->info['replay_gain']['reference_volume'] = (double) 89.0; + } + if (isset($this->info['replay_gain']['track']['adjustment'])) { + $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment']; + } + if (isset($this->info['replay_gain']['album']['adjustment'])) { + $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment']; + } + + if (isset($this->info['replay_gain']['track']['peak'])) { + $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']); + } + if (isset($this->info['replay_gain']['album']['peak'])) { + $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']); + } + } + return true; + } + + public function ProcessAudioStreams() { + if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) { + if (!isset($this->info['audio']['streams'])) { + foreach ($this->info['audio'] as $key => $value) { + if ($key != 'streams') { + $this->info['audio']['streams'][0][$key] = $value; + } + } + } + } + return true; + } + + public function getid3_tempnam() { + return tempnam($this->tempdir, 'gI3'); + } + + public function include_module($name) { + //if (!file_exists($this->include_path.'module.'.$name.'.php')) { + if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) { + throw new getid3_exception('Required module.'.$name.'.php is missing.'); + } + include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php'); + return true; + } + + public static function is_writable ($filename) { + $ret = is_writable($filename); + + if (!$ret) { + $perms = fileperms($filename); + $ret = ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002); + } + + return $ret; + } + +} + + +abstract class getid3_handler { + + /** + * @var getID3 + */ + protected $getid3; // pointer + + protected $data_string_flag = false; // analyzing filepointer or string + protected $data_string = ''; // string to analyze + protected $data_string_position = 0; // seek position in string + protected $data_string_length = 0; // string length + + private $dependency_to = null; + + + public function __construct(getID3 $getid3, $call_module=null) { + $this->getid3 = $getid3; + + if ($call_module) { + $this->dependency_to = str_replace('getid3_', '', $call_module); + } + } + + + // Analyze from file pointer + abstract public function Analyze(); + + + // Analyze from string instead + public function AnalyzeString($string) { + // Enter string mode + $this->setStringMode($string); + + // Save info + $saved_avdataoffset = $this->getid3->info['avdataoffset']; + $saved_avdataend = $this->getid3->info['avdataend']; + $saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call + + // Reset some info + $this->getid3->info['avdataoffset'] = 0; + $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length; + + // Analyze + $this->Analyze(); + + // Restore some info + $this->getid3->info['avdataoffset'] = $saved_avdataoffset; + $this->getid3->info['avdataend'] = $saved_avdataend; + $this->getid3->info['filesize'] = $saved_filesize; + + // Exit string mode + $this->data_string_flag = false; + } + + public function setStringMode($string) { + $this->data_string_flag = true; + $this->data_string = $string; + $this->data_string_length = strlen($string); + } + + protected function ftell() { + if ($this->data_string_flag) { + return $this->data_string_position; + } + return ftell($this->getid3->fp); + } + + protected function fread($bytes) { + if ($this->data_string_flag) { + $this->data_string_position += $bytes; + return substr($this->data_string, $this->data_string_position - $bytes, $bytes); + } + $pos = $this->ftell() + $bytes; + if (!getid3_lib::intValueSupported($pos)) { + throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10); + } + + //return fread($this->getid3->fp, $bytes); + /* + * http://www.getid3.org/phpBB3/viewtopic.php?t=1930 + * "I found out that the root cause for the problem was how getID3 uses the PHP system function fread(). + * It seems to assume that fread() would always return as many bytes as were requested. + * However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes. + * The call may return only part of the requested data and a new call is needed to get more." + */ + $contents = ''; + do { + $part = fread($this->getid3->fp, $bytes); + $partLength = strlen($part); + $bytes -= $partLength; + $contents .= $part; + } while (($bytes > 0) && ($partLength > 0)); + return $contents; + } + + protected function fseek($bytes, $whence=SEEK_SET) { + if ($this->data_string_flag) { + switch ($whence) { + case SEEK_SET: + $this->data_string_position = $bytes; + break; + + case SEEK_CUR: + $this->data_string_position += $bytes; + break; + + case SEEK_END: + $this->data_string_position = $this->data_string_length + $bytes; + break; + } + return 0; + } else { + $pos = $bytes; + if ($whence == SEEK_CUR) { + $pos = $this->ftell() + $bytes; + } elseif ($whence == SEEK_END) { + $pos = $this->getid3->info['filesize'] + $bytes; + } + if (!getid3_lib::intValueSupported($pos)) { + throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10); + } + } + return fseek($this->getid3->fp, $bytes, $whence); + } + + protected function feof() { + if ($this->data_string_flag) { + return $this->data_string_position >= $this->data_string_length; + } + return feof($this->getid3->fp); + } + + final protected function isDependencyFor($module) { + return $this->dependency_to == $module; + } + + protected function error($text) { + $this->getid3->info['error'][] = $text; + + return false; + } + + protected function warning($text) { + return $this->getid3->warning($text); + } + + protected function notice($text) { + // does nothing for now + } + + public function saveAttachment($name, $offset, $length, $image_mime=null) { + try { + + // do not extract at all + if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) { + + $attachment = null; // do not set any + + // extract to return array + } elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) { + + $this->fseek($offset); + $attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory + if ($attachment === false || strlen($attachment) != $length) { + throw new Exception('failed to read attachment data'); + } + + // assume directory path is given + } else { + + // set up destination path + $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR); + if (!is_dir($dir) || !getID3::is_writable($dir)) { // check supplied directory + throw new Exception('supplied path ('.$dir.') does not exist, or is not writable'); + } + $dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : ''); + + // create dest file + if (($fp_dest = fopen($dest, 'wb')) == false) { + throw new Exception('failed to create file '.$dest); + } + + // copy data + $this->fseek($offset); + $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size()); + $bytesleft = $length; + while ($bytesleft > 0) { + if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) { + throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space'); + } + $bytesleft -= $byteswritten; + } + + fclose($fp_dest); + $attachment = $dest; + + } + + } catch (Exception $e) { + + // close and remove dest file if created + if (isset($fp_dest) && is_resource($fp_dest)) { + fclose($fp_dest); + unlink($dest); + } + + // do not set any is case of error + $attachment = null; + $this->warning('Failed to extract attachment '.$name.': '.$e->getMessage()); + + } + + // seek to the end of attachment + $this->fseek($offset + $length); + + return $attachment; + } + +} + + +class getid3_exception extends Exception +{ + public $message; +} diff --git a/backend/wp-includes/ID3/license.commercial.txt b/backend/wp-includes/ID3/license.commercial.txt new file mode 100644 index 0000000..416e5a1 --- /dev/null +++ b/backend/wp-includes/ID3/license.commercial.txt @@ -0,0 +1,27 @@ + getID3() Commercial License + =========================== + +getID3() is licensed under the "GNU Public License" (GPL) and/or the +"getID3() Commercial License" (gCL). This document describes the gCL. + +--------------------------------------------------------------------- + +The license is non-exclusively granted to a single person or company, +per payment of the license fee, for the lifetime of that person or +company. The license is non-transferrable. + +The gCL grants the licensee the right to use getID3() in commercial +closed-source projects. Modifications may be made to getID3() with no +obligation to release the modified source code. getID3() (or pieces +thereof) may be included in any number of projects authored (in whole +or in part) by the licensee. + +The licensee may use any version of getID3(), past, present or future, +as is most convenient. This license does not entitle the licensee to +receive any technical support, updates or bugfixes, except as such are +made publicly available to all getID3() users. + +The licensee may not sub-license getID3() itself, meaning that any +commercially released product containing all or parts of getID3() must +have added functionality beyond what is available in getID3(); +getID3() itself may not be re-licensed by the licensee. diff --git a/backend/wp-includes/ID3/license.txt b/backend/wp-includes/ID3/license.txt new file mode 100644 index 0000000..205c7e6 --- /dev/null +++ b/backend/wp-includes/ID3/license.txt @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////// +/// getID3() by James Heinrich // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// + +***************************************************************** +***************************************************************** + + getID3() is released under multiple licenses. You may choose + from the following licenses, and use getID3 according to the + terms of the license most suitable to your project. + +GNU GPL: https://gnu.org/licenses/gpl.html (v3) + https://gnu.org/licenses/old-licenses/gpl-2.0.html (v2) + https://gnu.org/licenses/old-licenses/gpl-1.0.html (v1) + +GNU LGPL: https://gnu.org/licenses/lgpl.html (v3) + +Mozilla MPL: http://www.mozilla.org/MPL/2.0/ (v2) + +getID3 Commercial License: http://getid3.org/#gCL (payment required) + +***************************************************************** +***************************************************************** + +Copies of each of the above licenses are included in the 'licenses' +directory of the getID3 distribution. diff --git a/backend/wp-includes/ID3/module.audio-video.asf.php b/backend/wp-includes/ID3/module.audio-video.asf.php new file mode 100644 index 0000000..23d3a0e --- /dev/null +++ b/backend/wp-includes/ID3/module.audio-video.asf.php @@ -0,0 +1,2013 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio-video.asf.php // +// module for analyzing ASF, WMA and WMV files // +// dependencies: module.audio-video.riff.php // +// /// +///////////////////////////////////////////////////////////////// + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); + +class getid3_asf extends getid3_handler { + + public function __construct(getID3 $getid3) { + parent::__construct($getid3); // extends getid3_handler::__construct() + + // initialize all GUID constants + $GUIDarray = $this->KnownGUIDs(); + foreach ($GUIDarray as $GUIDname => $hexstringvalue) { + if (!defined($GUIDname)) { + define($GUIDname, $this->GUIDtoBytestring($hexstringvalue)); + } + } + } + + public function Analyze() { + $info = &$this->getid3->info; + + // Shortcuts + $thisfile_audio = &$info['audio']; + $thisfile_video = &$info['video']; + $info['asf'] = array(); + $thisfile_asf = &$info['asf']; + $thisfile_asf['comments'] = array(); + $thisfile_asf_comments = &$thisfile_asf['comments']; + $thisfile_asf['header_object'] = array(); + $thisfile_asf_headerobject = &$thisfile_asf['header_object']; + + + // ASF structure: + // * Header Object [required] + // * File Properties Object [required] (global file attributes) + // * Stream Properties Object [required] (defines media stream & characteristics) + // * Header Extension Object [required] (additional functionality) + // * Content Description Object (bibliographic information) + // * Script Command Object (commands for during playback) + // * Marker Object (named jumped points within the file) + // * Data Object [required] + // * Data Packets + // * Index Object + + // Header Object: (mandatory, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for header object - GETID3_ASF_Header_Object + // Object Size QWORD 64 // size of header object, including 30 bytes of Header Object header + // Number of Header Objects DWORD 32 // number of objects in header object + // Reserved1 BYTE 8 // hardcoded: 0x01 + // Reserved2 BYTE 8 // hardcoded: 0x02 + + $info['fileformat'] = 'asf'; + + $this->fseek($info['avdataoffset']); + $HeaderObjectData = $this->fread(30); + + $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16); + $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']); + if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) { + unset($info['fileformat'], $info['asf']); + return $this->error('ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}'); + } + $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8)); + $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4)); + $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1)); + $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1)); + + $NextObjectOffset = $this->ftell(); + $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30); + $offset = 0; + + for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) { + $NextObjectGUID = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID); + $NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + switch ($NextObjectGUID) { + + case GETID3_ASF_File_Properties_Object: + // File Properties Object: (mandatory, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for file properties object - GETID3_ASF_File_Properties_Object + // Object Size QWORD 64 // size of file properties object, including 104 bytes of File Properties Object header + // File ID GUID 128 // unique ID - identical to File ID in Data Object + // File Size QWORD 64 // entire file in bytes. Invalid if Broadcast Flag == 1 + // Creation Date QWORD 64 // date & time of file creation. Maybe invalid if Broadcast Flag == 1 + // Data Packets Count QWORD 64 // number of data packets in Data Object. Invalid if Broadcast Flag == 1 + // Play Duration QWORD 64 // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1 + // Send Duration QWORD 64 // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1 + // Preroll QWORD 64 // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount + // Flags DWORD 32 // + // * Broadcast Flag bits 1 (0x01) // file is currently being written, some header values are invalid + // * Seekable Flag bits 1 (0x02) // is file seekable + // * Reserved bits 30 (0xFFFFFFFC) // reserved - set to zero + // Minimum Data Packet Size DWORD 32 // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1 + // Maximum Data Packet Size DWORD 32 // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1 + // Maximum Bitrate DWORD 32 // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead + + // shortcut + $thisfile_asf['file_properties_object'] = array(); + $thisfile_asf_filepropertiesobject = &$thisfile_asf['file_properties_object']; + + $thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID; + $thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize; + $thisfile_asf_filepropertiesobject['fileid'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_filepropertiesobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']); + $thisfile_asf_filepropertiesobject['filesize'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_filepropertiesobject['creation_date'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']); + $offset += 8; + $thisfile_asf_filepropertiesobject['data_packets'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_filepropertiesobject['play_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_filepropertiesobject['send_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_filepropertiesobject['preroll'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_filepropertiesobject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001); + $thisfile_asf_filepropertiesobject['flags']['seekable'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002); + + $thisfile_asf_filepropertiesobject['min_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_filepropertiesobject['max_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_filepropertiesobject['max_bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + + if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) { + + // broadcast flag is set, some values invalid + unset($thisfile_asf_filepropertiesobject['filesize']); + unset($thisfile_asf_filepropertiesobject['data_packets']); + unset($thisfile_asf_filepropertiesobject['play_duration']); + unset($thisfile_asf_filepropertiesobject['send_duration']); + unset($thisfile_asf_filepropertiesobject['min_packet_size']); + unset($thisfile_asf_filepropertiesobject['max_packet_size']); + + } else { + + // broadcast flag NOT set, perform calculations + $info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000); + + //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate']; + $info['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8) / $info['playtime_seconds']; + } + break; + + case GETID3_ASF_Stream_Properties_Object: + // Stream Properties Object: (mandatory, one per media stream) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object + // Object Size QWORD 64 // size of stream properties object, including 78 bytes of Stream Properties Object header + // Stream Type GUID 128 // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media + // Error Correction Type GUID 128 // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types + // Time Offset QWORD 64 // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream + // Type-Specific Data Length DWORD 32 // number of bytes for Type-Specific Data field + // Error Correction Data Length DWORD 32 // number of bytes for Error Correction Data field + // Flags WORD 16 // + // * Stream Number bits 7 (0x007F) // number of this stream. 1 <= valid <= 127 + // * Reserved bits 8 (0x7F80) // reserved - set to zero + // * Encrypted Content Flag bits 1 (0x8000) // stream contents encrypted if set + // Reserved DWORD 32 // reserved - set to zero + // Type-Specific Data BYTESTREAM variable // type-specific format data, depending on value of Stream Type + // Error Correction Data BYTESTREAM variable // error-correction-specific format data, depending on value of Error Correct Type + + // There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the + // stream number isn't known until halfway through decoding the structure, hence it + // it is decoded to a temporary variable and then stuck in the appropriate index later + + $StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset; + $StreamPropertiesObjectData['objectid'] = $NextObjectGUID; + $StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext; + $StreamPropertiesObjectData['objectsize'] = $NextObjectSize; + $StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $StreamPropertiesObjectData['stream_type_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']); + $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']); + $StreamPropertiesObjectData['time_offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $StreamPropertiesObjectData['type_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $StreamPropertiesObjectData['error_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $StreamPropertiesObjectData['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x007F; + $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000); + + $offset += 4; // reserved - DWORD + $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']); + $offset += $StreamPropertiesObjectData['type_data_length']; + $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']); + $offset += $StreamPropertiesObjectData['error_data_length']; + + switch ($StreamPropertiesObjectData['stream_type']) { + + case GETID3_ASF_Audio_Media: + $thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf'); + $thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr'); + + $audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16)); + unset($audiodata['raw']); + $thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio); + break; + + case GETID3_ASF_Video_Media: + $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); + $thisfile_video['bitrate_mode'] = (!empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr'); + break; + + case GETID3_ASF_Command_Media: + default: + // do nothing + break; + + } + + $thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData; + unset($StreamPropertiesObjectData); // clear for next stream, if any + break; + + case GETID3_ASF_Header_Extension_Object: + // Header Extension Object: (mandatory, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object + // Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header + // Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1 + // Reserved Field 2 WORD 16 // hardcoded: 0x00000006 + // Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46 + // Header Extension Data BYTESTREAM variable // array of zero or more extended header objects + + // shortcut + $thisfile_asf['header_extension_object'] = array(); + $thisfile_asf_headerextensionobject = &$thisfile_asf['header_extension_object']; + + $thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID; + $thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize; + $thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']); + if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) { + $this->warning('header_extension_object.reserved_1 GUID ('.$this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']).') does not match expected "GETID3_ASF_Reserved_1" GUID ('.$this->BytestringToGUID(GETID3_ASF_Reserved_1).')'); + //return false; + break; + } + $thisfile_asf_headerextensionobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) { + $this->warning('header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']).') does not match expected value of "6"'); + //return false; + break; + } + $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']); + $unhandled_sections = 0; + $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections); + if ($unhandled_sections === 0) { + unset($thisfile_asf_headerextensionobject['extension_data']); + } + $offset += $thisfile_asf_headerextensionobject['extension_data_size']; + break; + + case GETID3_ASF_Codec_List_Object: + // Codec List Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Codec List object - GETID3_ASF_Codec_List_Object + // Object Size QWORD 64 // size of Codec List object, including 44 bytes of Codec List Object header + // Reserved GUID 128 // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6 + // Codec Entries Count DWORD 32 // number of entries in Codec Entries array + // Codec Entries array of: variable // + // * Type WORD 16 // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec + // * Codec Name Length WORD 16 // number of Unicode characters stored in the Codec Name field + // * Codec Name WCHAR variable // array of Unicode characters - name of codec used to create the content + // * Codec Description Length WORD 16 // number of Unicode characters stored in the Codec Description field + // * Codec Description WCHAR variable // array of Unicode characters - description of format used to create the content + // * Codec Information Length WORD 16 // number of Unicode characters stored in the Codec Information field + // * Codec Information BYTESTREAM variable // opaque array of information bytes about the codec used to create the content + + // shortcut + $thisfile_asf['codec_list_object'] = array(); + $thisfile_asf_codeclistobject = &$thisfile_asf['codec_list_object']; + + $thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID; + $thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize; + $thisfile_asf_codeclistobject['reserved'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_codeclistobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']); + if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) { + $this->warning('codec_list_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}'); + //return false; + break; + } + $thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) { + // shortcut + $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array(); + $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter]; + + $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']); + + $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character + $offset += 2; + $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength); + $offset += $CodecNameLength; + + $CodecDescriptionLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character + $offset += 2; + $thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength); + $offset += $CodecDescriptionLength; + + $CodecInformationLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength); + $offset += $CodecInformationLength; + + if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec + + if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) { + $this->warning('[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-separated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"'); + } else { + + list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description'])); + $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']); + + if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) { + $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000); + } + //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) { + if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) { + //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate']; + $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate']; + } + + $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency)); + switch ($AudioCodecFrequency) { + case 8: + case 8000: + $thisfile_audio['sample_rate'] = 8000; + break; + + case 11: + case 11025: + $thisfile_audio['sample_rate'] = 11025; + break; + + case 12: + case 12000: + $thisfile_audio['sample_rate'] = 12000; + break; + + case 16: + case 16000: + $thisfile_audio['sample_rate'] = 16000; + break; + + case 22: + case 22050: + $thisfile_audio['sample_rate'] = 22050; + break; + + case 24: + case 24000: + $thisfile_audio['sample_rate'] = 24000; + break; + + case 32: + case 32000: + $thisfile_audio['sample_rate'] = 32000; + break; + + case 44: + case 441000: + $thisfile_audio['sample_rate'] = 44100; + break; + + case 48: + case 48000: + $thisfile_audio['sample_rate'] = 48000; + break; + + default: + $this->warning('unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')'); + break; + } + + if (!isset($thisfile_audio['channels'])) { + if (strstr($AudioCodecChannels, 'stereo')) { + $thisfile_audio['channels'] = 2; + } elseif (strstr($AudioCodecChannels, 'mono')) { + $thisfile_audio['channels'] = 1; + } + } + + } + } + } + break; + + case GETID3_ASF_Script_Command_Object: + // Script Command Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Script Command object - GETID3_ASF_Script_Command_Object + // Object Size QWORD 64 // size of Script Command object, including 44 bytes of Script Command Object header + // Reserved GUID 128 // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6 + // Commands Count WORD 16 // number of Commands structures in the Script Commands Objects + // Command Types Count WORD 16 // number of Command Types structures in the Script Commands Objects + // Command Types array of: variable // + // * Command Type Name Length WORD 16 // number of Unicode characters for Command Type Name + // * Command Type Name WCHAR variable // array of Unicode characters - name of a type of command + // Commands array of: variable // + // * Presentation Time DWORD 32 // presentation time of that command, in milliseconds + // * Type Index WORD 16 // type of this command, as a zero-based index into the array of Command Types of this object + // * Command Name Length WORD 16 // number of Unicode characters for Command Name + // * Command Name WCHAR variable // array of Unicode characters - name of this command + + // shortcut + $thisfile_asf['script_command_object'] = array(); + $thisfile_asf_scriptcommandobject = &$thisfile_asf['script_command_object']; + + $thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID; + $thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize; + $thisfile_asf_scriptcommandobject['reserved'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_scriptcommandobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']); + if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) { + $this->warning('script_command_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}'); + //return false; + break; + } + $thisfile_asf_scriptcommandobject['commands_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_scriptcommandobject['command_types_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) { + $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character + $offset += 2; + $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength); + $offset += $CommandTypeNameLength; + } + for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) { + $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + + $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character + $offset += 2; + $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength); + $offset += $CommandTypeNameLength; + } + break; + + case GETID3_ASF_Marker_Object: + // Marker Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Marker object - GETID3_ASF_Marker_Object + // Object Size QWORD 64 // size of Marker object, including 48 bytes of Marker Object header + // Reserved GUID 128 // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB + // Markers Count DWORD 32 // number of Marker structures in Marker Object + // Reserved WORD 16 // hardcoded: 0x0000 + // Name Length WORD 16 // number of bytes in the Name field + // Name WCHAR variable // name of the Marker Object + // Markers array of: variable // + // * Offset QWORD 64 // byte offset into Data Object + // * Presentation Time QWORD 64 // in 100-nanosecond units + // * Entry Length WORD 16 // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding) + // * Send Time DWORD 32 // in milliseconds + // * Flags DWORD 32 // hardcoded: 0x00000000 + // * Marker Description Length DWORD 32 // number of bytes in Marker Description field + // * Marker Description WCHAR variable // array of Unicode characters - description of marker entry + // * Padding BYTESTREAM variable // optional padding bytes + + // shortcut + $thisfile_asf['marker_object'] = array(); + $thisfile_asf_markerobject = &$thisfile_asf['marker_object']; + + $thisfile_asf_markerobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_markerobject['objectid'] = $NextObjectGUID; + $thisfile_asf_markerobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_markerobject['objectsize'] = $NextObjectSize; + $thisfile_asf_markerobject['reserved'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_markerobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_markerobject['reserved']); + if ($thisfile_asf_markerobject['reserved'] != $this->GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) { + $this->warning('marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved_1']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}'); + break; + } + $thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + if ($thisfile_asf_markerobject['reserved_2'] != 0) { + $this->warning('marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_markerobject['reserved_2']).') does not match expected value of "0"'); + break; + } + $thisfile_asf_markerobject['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']); + $offset += $thisfile_asf_markerobject['name_length']; + for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) { + $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8)); + $offset += 8; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['send_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['flags'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']); + $offset += $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']; + $PaddingLength = $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] - 4 - 4 - 4 - $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']; + if ($PaddingLength > 0) { + $thisfile_asf_markerobject['markers'][$MarkersCounter]['padding'] = substr($ASFHeaderData, $offset, $PaddingLength); + $offset += $PaddingLength; + } + } + break; + + case GETID3_ASF_Bitrate_Mutual_Exclusion_Object: + // Bitrate Mutual Exclusion Object: (optional) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Bitrate Mutual Exclusion object - GETID3_ASF_Bitrate_Mutual_Exclusion_Object + // Object Size QWORD 64 // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header + // Exlusion Type GUID 128 // nature of mutual exclusion relationship. one of: (GETID3_ASF_Mutex_Bitrate, GETID3_ASF_Mutex_Unknown) + // Stream Numbers Count WORD 16 // number of video streams + // Stream Numbers WORD variable // array of mutually exclusive video stream numbers. 1 <= valid <= 127 + + // shortcut + $thisfile_asf['bitrate_mutual_exclusion_object'] = array(); + $thisfile_asf_bitratemutualexclusionobject = &$thisfile_asf['bitrate_mutual_exclusion_object']; + + $thisfile_asf_bitratemutualexclusionobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_bitratemutualexclusionobject['objectid'] = $NextObjectGUID; + $thisfile_asf_bitratemutualexclusionobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_bitratemutualexclusionobject['objectsize'] = $NextObjectSize; + $thisfile_asf_bitratemutualexclusionobject['reserved'] = substr($ASFHeaderData, $offset, 16); + $thisfile_asf_bitratemutualexclusionobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']); + $offset += 16; + if (($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Unknown)) { + $this->warning('bitrate_mutual_exclusion_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']).'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Bitrate).'} or "GETID3_ASF_Mutex_Unknown" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Unknown).'}'); + //return false; + break; + } + $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) { + $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + } + break; + + case GETID3_ASF_Error_Correction_Object: + // Error Correction Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Error Correction object - GETID3_ASF_Error_Correction_Object + // Object Size QWORD 64 // size of Error Correction object, including 44 bytes of Error Correction Object header + // Error Correction Type GUID 128 // type of error correction. one of: (GETID3_ASF_No_Error_Correction, GETID3_ASF_Audio_Spread) + // Error Correction Data Length DWORD 32 // number of bytes in Error Correction Data field + // Error Correction Data BYTESTREAM variable // structure depends on value of Error Correction Type field + + // shortcut + $thisfile_asf['error_correction_object'] = array(); + $thisfile_asf_errorcorrectionobject = &$thisfile_asf['error_correction_object']; + + $thisfile_asf_errorcorrectionobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_errorcorrectionobject['objectid'] = $NextObjectGUID; + $thisfile_asf_errorcorrectionobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_errorcorrectionobject['objectsize'] = $NextObjectSize; + $thisfile_asf_errorcorrectionobject['error_correction_type'] = substr($ASFHeaderData, $offset, 16); + $offset += 16; + $thisfile_asf_errorcorrectionobject['error_correction_guid'] = $this->BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']); + $thisfile_asf_errorcorrectionobject['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + switch ($thisfile_asf_errorcorrectionobject['error_correction_type']) { + case GETID3_ASF_No_Error_Correction: + // should be no data, but just in case there is, skip to the end of the field + $offset += $thisfile_asf_errorcorrectionobject['error_correction_data_length']; + break; + + case GETID3_ASF_Audio_Spread: + // Field Name Field Type Size (bits) + // Span BYTE 8 // number of packets over which audio will be spread. + // Virtual Packet Length WORD 16 // size of largest audio payload found in audio stream + // Virtual Chunk Length WORD 16 // size of largest audio payload found in audio stream + // Silence Data Length WORD 16 // number of bytes in Silence Data field + // Silence Data BYTESTREAM variable // hardcoded: 0x00 * (Silence Data Length) bytes + + $thisfile_asf_errorcorrectionobject['span'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 1)); + $offset += 1; + $thisfile_asf_errorcorrectionobject['virtual_packet_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_errorcorrectionobject['virtual_chunk_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_errorcorrectionobject['silence_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_errorcorrectionobject['silence_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_errorcorrectionobject['silence_data_length']); + $offset += $thisfile_asf_errorcorrectionobject['silence_data_length']; + break; + + default: + $this->warning('error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']).'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {'.$this->BytestringToGUID(GETID3_ASF_No_Error_Correction).'} or "GETID3_ASF_Audio_Spread" GUID {'.$this->BytestringToGUID(GETID3_ASF_Audio_Spread).'}'); + //return false; + break; + } + + break; + + case GETID3_ASF_Content_Description_Object: + // Content Description Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Content Description object - GETID3_ASF_Content_Description_Object + // Object Size QWORD 64 // size of Content Description object, including 34 bytes of Content Description Object header + // Title Length WORD 16 // number of bytes in Title field + // Author Length WORD 16 // number of bytes in Author field + // Copyright Length WORD 16 // number of bytes in Copyright field + // Description Length WORD 16 // number of bytes in Description field + // Rating Length WORD 16 // number of bytes in Rating field + // Title WCHAR 16 // array of Unicode characters - Title + // Author WCHAR 16 // array of Unicode characters - Author + // Copyright WCHAR 16 // array of Unicode characters - Copyright + // Description WCHAR 16 // array of Unicode characters - Description + // Rating WCHAR 16 // array of Unicode characters - Rating + + // shortcut + $thisfile_asf['content_description_object'] = array(); + $thisfile_asf_contentdescriptionobject = &$thisfile_asf['content_description_object']; + + $thisfile_asf_contentdescriptionobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_contentdescriptionobject['objectid'] = $NextObjectGUID; + $thisfile_asf_contentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_contentdescriptionobject['objectsize'] = $NextObjectSize; + $thisfile_asf_contentdescriptionobject['title_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_contentdescriptionobject['author_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_contentdescriptionobject['copyright_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_contentdescriptionobject['description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_contentdescriptionobject['rating_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_contentdescriptionobject['title'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['title_length']); + $offset += $thisfile_asf_contentdescriptionobject['title_length']; + $thisfile_asf_contentdescriptionobject['author'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['author_length']); + $offset += $thisfile_asf_contentdescriptionobject['author_length']; + $thisfile_asf_contentdescriptionobject['copyright'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['copyright_length']); + $offset += $thisfile_asf_contentdescriptionobject['copyright_length']; + $thisfile_asf_contentdescriptionobject['description'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['description_length']); + $offset += $thisfile_asf_contentdescriptionobject['description_length']; + $thisfile_asf_contentdescriptionobject['rating'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['rating_length']); + $offset += $thisfile_asf_contentdescriptionobject['rating_length']; + + $ASFcommentKeysToCopy = array('title'=>'title', 'author'=>'artist', 'copyright'=>'copyright', 'description'=>'comment', 'rating'=>'rating'); + foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) { + if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) { + $thisfile_asf_comments[$keytocopyto][] = $this->TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]); + } + } + break; + + case GETID3_ASF_Extended_Content_Description_Object: + // Extended Content Description Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Extended Content Description object - GETID3_ASF_Extended_Content_Description_Object + // Object Size QWORD 64 // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header + // Content Descriptors Count WORD 16 // number of entries in Content Descriptors list + // Content Descriptors array of: variable // + // * Descriptor Name Length WORD 16 // size in bytes of Descriptor Name field + // * Descriptor Name WCHAR variable // array of Unicode characters - Descriptor Name + // * Descriptor Value Data Type WORD 16 // Lookup array: + // 0x0000 = Unicode String (variable length) + // 0x0001 = BYTE array (variable length) + // 0x0002 = BOOL (DWORD, 32 bits) + // 0x0003 = DWORD (DWORD, 32 bits) + // 0x0004 = QWORD (QWORD, 64 bits) + // 0x0005 = WORD (WORD, 16 bits) + // * Descriptor Value Length WORD 16 // number of bytes stored in Descriptor Value field + // * Descriptor Value variable variable // value for Content Descriptor + + // shortcut + $thisfile_asf['extended_content_description_object'] = array(); + $thisfile_asf_extendedcontentdescriptionobject = &$thisfile_asf['extended_content_description_object']; + + $thisfile_asf_extendedcontentdescriptionobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_extendedcontentdescriptionobject['objectid'] = $NextObjectGUID; + $thisfile_asf_extendedcontentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize; + $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) { + // shortcut + $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array(); + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter]; + + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['base_offset'] = $offset + 30; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']); + $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length']); + $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length']; + switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) { + case 0x0000: // Unicode string + break; + + case 0x0001: // BYTE array + // do nothing + break; + + case 0x0002: // BOOL + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = (bool) getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + break; + + case 0x0003: // DWORD + case 0x0004: // QWORD + case 0x0005: // WORD + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + break; + + default: + $this->warning('extended_content_description.content_descriptors.'.$ExtendedContentDescriptorsCounter.'.value_type is invalid ('.$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'].')'); + //return false; + break; + } + switch ($this->TrimConvert(strtolower($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']))) { + + case 'wm/albumartist': + case 'artist': + // Note: not 'artist', that comes from 'author' tag + $thisfile_asf_comments['albumartist'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'wm/albumtitle': + case 'album': + $thisfile_asf_comments['album'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'wm/genre': + case 'genre': + $thisfile_asf_comments['genre'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'wm/partofset': + $thisfile_asf_comments['partofset'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'wm/tracknumber': + case 'tracknumber': + // be careful casting to int: casting unicode strings to int gives unexpected results (stops parsing at first non-numeric character) + $thisfile_asf_comments['track'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + foreach ($thisfile_asf_comments['track'] as $key => $value) { + if (preg_match('/^[0-9\x00]+$/', $value)) { + $thisfile_asf_comments['track'][$key] = intval(str_replace("\x00", '', $value)); + } + } + break; + + case 'wm/track': + if (empty($thisfile_asf_comments['track'])) { + $thisfile_asf_comments['track'] = array(1 + $this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + } + break; + + case 'wm/year': + case 'year': + case 'date': + $thisfile_asf_comments['year'] = array( $this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'wm/lyrics': + case 'lyrics': + $thisfile_asf_comments['lyrics'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + break; + + case 'isvbr': + if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']) { + $thisfile_audio['bitrate_mode'] = 'vbr'; + $thisfile_video['bitrate_mode'] = 'vbr'; + } + break; + + case 'id3': + $this->getid3->include_module('tag.id3v2'); + + $getid3_id3v2 = new getid3_id3v2($this->getid3); + $getid3_id3v2->AnalyzeString($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + unset($getid3_id3v2); + + if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] > 1024) { + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = ''; + } + break; + + case 'wm/encodingtime': + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + $thisfile_asf_comments['encoding_time_unix'] = array($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix']); + break; + + case 'wm/picture': + $WMpicture = $this->ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + foreach ($WMpicture as $key => $value) { + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value; + } + unset($WMpicture); +/* + $wm_picture_offset = 0; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1)); + $wm_picture_offset += 1; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = self::WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']); + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4)); + $wm_picture_offset += 4; + + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = ''; + do { + $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2); + $wm_picture_offset += 2; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] .= $next_byte_pair; + } while ($next_byte_pair !== "\x00\x00"); + + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] = ''; + do { + $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2); + $wm_picture_offset += 2; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] .= $next_byte_pair; + } while ($next_byte_pair !== "\x00\x00"); + + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['dataoffset'] = $wm_picture_offset; + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'] = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset); + unset($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); + + $imageinfo = array(); + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = ''; + $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], $imageinfo); + unset($imageinfo); + if (!empty($imagechunkcheck)) { + $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]); + } + if (!isset($thisfile_asf_comments['picture'])) { + $thisfile_asf_comments['picture'] = array(); + } + $thisfile_asf_comments['picture'][] = array('data'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], 'image_mime'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime']); +*/ + break; + + default: + switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) { + case 0: // Unicode string + if (substr($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']), 0, 3) == 'WM/') { + $thisfile_asf_comments[str_replace('wm/', '', strtolower($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'])))] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'])); + } + break; + + case 1: + break; + } + break; + } + + } + break; + + case GETID3_ASF_Stream_Bitrate_Properties_Object: + // Stream Bitrate Properties Object: (optional, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Stream Bitrate Properties object - GETID3_ASF_Stream_Bitrate_Properties_Object + // Object Size QWORD 64 // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header + // Bitrate Records Count WORD 16 // number of records in Bitrate Records + // Bitrate Records array of: variable // + // * Flags WORD 16 // + // * * Stream Number bits 7 (0x007F) // number of this stream + // * * Reserved bits 9 (0xFF80) // hardcoded: 0 + // * Average Bitrate DWORD 32 // in bits per second + + // shortcut + $thisfile_asf['stream_bitrate_properties_object'] = array(); + $thisfile_asf_streambitratepropertiesobject = &$thisfile_asf['stream_bitrate_properties_object']; + + $thisfile_asf_streambitratepropertiesobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_streambitratepropertiesobject['objectid'] = $NextObjectGUID; + $thisfile_asf_streambitratepropertiesobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize; + $thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) { + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); + $offset += 2; + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F; + $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); + $offset += 4; + } + break; + + case GETID3_ASF_Padding_Object: + // Padding Object: (optional) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Padding object - GETID3_ASF_Padding_Object + // Object Size QWORD 64 // size of Padding object, including 24 bytes of ASF Padding Object header + // Padding Data BYTESTREAM variable // ignore + + // shortcut + $thisfile_asf['padding_object'] = array(); + $thisfile_asf_paddingobject = &$thisfile_asf['padding_object']; + + $thisfile_asf_paddingobject['offset'] = $NextObjectOffset + $offset; + $thisfile_asf_paddingobject['objectid'] = $NextObjectGUID; + $thisfile_asf_paddingobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_paddingobject['objectsize'] = $NextObjectSize; + $thisfile_asf_paddingobject['padding_length'] = $thisfile_asf_paddingobject['objectsize'] - 16 - 8; + $thisfile_asf_paddingobject['padding'] = substr($ASFHeaderData, $offset, $thisfile_asf_paddingobject['padding_length']); + $offset += ($NextObjectSize - 16 - 8); + break; + + case GETID3_ASF_Extended_Content_Encryption_Object: + case GETID3_ASF_Content_Encryption_Object: + // WMA DRM - just ignore + $offset += ($NextObjectSize - 16 - 8); + break; + + default: + // Implementations shall ignore any standard or non-standard object that they do not know how to handle. + if ($this->GUIDname($NextObjectGUIDtext)) { + $this->warning('unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8)); + } else { + $this->warning('unknown GUID {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8)); + } + $offset += ($NextObjectSize - 16 - 8); + break; + } + } + if (isset($thisfile_asf_streambitrateproperties['bitrate_records_count'])) { + $ASFbitrateAudio = 0; + $ASFbitrateVideo = 0; + for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitrateproperties['bitrate_records_count']; $BitrateRecordsCounter++) { + if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) { + switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) { + case 1: + $ASFbitrateVideo += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate']; + break; + + case 2: + $ASFbitrateAudio += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate']; + break; + + default: + // do nothing + break; + } + } + } + if ($ASFbitrateAudio > 0) { + $thisfile_audio['bitrate'] = $ASFbitrateAudio; + } + if ($ASFbitrateVideo > 0) { + $thisfile_video['bitrate'] = $ASFbitrateVideo; + } + } + if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) { + + $thisfile_audio['bitrate'] = 0; + $thisfile_video['bitrate'] = 0; + + foreach ($thisfile_asf['stream_properties_object'] as $streamnumber => $streamdata) { + + switch ($streamdata['stream_type']) { + case GETID3_ASF_Audio_Media: + // Field Name Field Type Size (bits) + // Codec ID / Format Tag WORD 16 // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure + // Number of Channels WORD 16 // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure + // Samples Per Second DWORD 32 // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure + // Average number of Bytes/sec DWORD 32 // bytes/sec of audio stream - defined as nAvgBytesPerSec field of WAVEFORMATEX structure + // Block Alignment WORD 16 // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure + // Bits per sample WORD 16 // bits per sample of mono data. set to zero for variable bitrate codecs. defined as wBitsPerSample field of WAVEFORMATEX structure + // Codec Specific Data Size WORD 16 // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure + // Codec Specific Data BYTESTREAM variable // array of codec-specific data bytes + + // shortcut + $thisfile_asf['audio_media'][$streamnumber] = array(); + $thisfile_asf_audiomedia_currentstream = &$thisfile_asf['audio_media'][$streamnumber]; + + $audiomediaoffset = 0; + + $thisfile_asf_audiomedia_currentstream = getid3_riff::parseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16)); + $audiomediaoffset += 16; + + $thisfile_audio['lossless'] = false; + switch ($thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']) { + case 0x0001: // PCM + case 0x0163: // WMA9 Lossless + $thisfile_audio['lossless'] = true; + break; + } + + if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { + foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { + if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { + $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate']; + $thisfile_audio['bitrate'] += $dataarray['bitrate']; + break; + } + } + } else { + if (!empty($thisfile_asf_audiomedia_currentstream['bytes_sec'])) { + $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8; + } elseif (!empty($thisfile_asf_audiomedia_currentstream['bitrate'])) { + $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate']; + } + } + $thisfile_audio['streams'][$streamnumber] = $thisfile_asf_audiomedia_currentstream; + $thisfile_audio['streams'][$streamnumber]['wformattag'] = $thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']; + $thisfile_audio['streams'][$streamnumber]['lossless'] = $thisfile_audio['lossless']; + $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate']; + $thisfile_audio['streams'][$streamnumber]['dataformat'] = 'wma'; + unset($thisfile_audio['streams'][$streamnumber]['raw']); + + $thisfile_asf_audiomedia_currentstream['codec_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $audiomediaoffset, 2)); + $audiomediaoffset += 2; + $thisfile_asf_audiomedia_currentstream['codec_data'] = substr($streamdata['type_specific_data'], $audiomediaoffset, $thisfile_asf_audiomedia_currentstream['codec_data_size']); + $audiomediaoffset += $thisfile_asf_audiomedia_currentstream['codec_data_size']; + + break; + + case GETID3_ASF_Video_Media: + // Field Name Field Type Size (bits) + // Encoded Image Width DWORD 32 // width of image in pixels + // Encoded Image Height DWORD 32 // height of image in pixels + // Reserved Flags BYTE 8 // hardcoded: 0x02 + // Format Data Size WORD 16 // size of Format Data field in bytes + // Format Data array of: variable // + // * Format Data Size DWORD 32 // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure + // * Image Width LONG 32 // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure + // * Image Height LONG 32 // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure + // * Reserved WORD 16 // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure + // * Bits Per Pixel Count WORD 16 // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure + // * Compression ID FOURCC 32 // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure + // * Image Size DWORD 32 // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure + // * Horizontal Pixels / Meter DWORD 32 // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure + // * Vertical Pixels / Meter DWORD 32 // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure + // * Colors Used Count DWORD 32 // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure + // * Important Colors Count DWORD 32 // number of color index required for displaying bitmap. if zero, all colors are required. defined as biClrImportant field of BITMAPINFOHEADER structure + // * Codec Specific Data BYTESTREAM variable // array of codec-specific data bytes + + // shortcut + $thisfile_asf['video_media'][$streamnumber] = array(); + $thisfile_asf_videomedia_currentstream = &$thisfile_asf['video_media'][$streamnumber]; + + $videomediaoffset = 0; + $thisfile_asf_videomedia_currentstream['image_width'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['image_height'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['flags'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 1)); + $videomediaoffset += 1; + $thisfile_asf_videomedia_currentstream['format_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2)); + $videomediaoffset += 2; + $thisfile_asf_videomedia_currentstream['format_data']['format_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['image_width'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['image_height'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['reserved'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2)); + $videomediaoffset += 2; + $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2)); + $videomediaoffset += 2; + $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'] = substr($streamdata['type_specific_data'], $videomediaoffset, 4); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['image_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['horizontal_pels'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['vertical_pels'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['colors_used'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['colors_important'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4)); + $videomediaoffset += 4; + $thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset); + + if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { + foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { + if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) { + $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate']; + $thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate']; + $thisfile_video['bitrate'] += $dataarray['bitrate']; + break; + } + } + } + + $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::fourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']); + + $thisfile_video['streams'][$streamnumber]['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']; + $thisfile_video['streams'][$streamnumber]['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec']; + $thisfile_video['streams'][$streamnumber]['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width']; + $thisfile_video['streams'][$streamnumber]['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height']; + $thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel']; + break; + + default: + break; + } + } + } + + while ($this->ftell() < $info['avdataend']) { + $NextObjectDataHeader = $this->fread(24); + $offset = 0; + $NextObjectGUID = substr($NextObjectDataHeader, 0, 16); + $offset += 16; + $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID); + $NextObjectSize = getid3_lib::LittleEndian2Int(substr($NextObjectDataHeader, $offset, 8)); + $offset += 8; + + switch ($NextObjectGUID) { + case GETID3_ASF_Data_Object: + // Data Object: (mandatory, one only) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Data object - GETID3_ASF_Data_Object + // Object Size QWORD 64 // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1 + // File ID GUID 128 // unique identifier. identical to File ID field in Header Object + // Total Data Packets QWORD 64 // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1 + // Reserved WORD 16 // hardcoded: 0x0101 + + // shortcut + $thisfile_asf['data_object'] = array(); + $thisfile_asf_dataobject = &$thisfile_asf['data_object']; + + $DataObjectData = $NextObjectDataHeader.$this->fread(50 - 24); + $offset = 24; + + $thisfile_asf_dataobject['objectid'] = $NextObjectGUID; + $thisfile_asf_dataobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_dataobject['objectsize'] = $NextObjectSize; + + $thisfile_asf_dataobject['fileid'] = substr($DataObjectData, $offset, 16); + $offset += 16; + $thisfile_asf_dataobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_dataobject['fileid']); + $thisfile_asf_dataobject['total_data_packets'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 8)); + $offset += 8; + $thisfile_asf_dataobject['reserved'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 2)); + $offset += 2; + if ($thisfile_asf_dataobject['reserved'] != 0x0101) { + $this->warning('data_object.reserved ('.getid3_lib::PrintHexBytes($thisfile_asf_dataobject['reserved']).') does not match expected value of "0x0101"'); + //return false; + break; + } + + // Data Packets array of: variable // + // * Error Correction Flags BYTE 8 // + // * * Error Correction Data Length bits 4 // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000 + // * * Opaque Data Present bits 1 // + // * * Error Correction Length Type bits 2 // number of bits for size of the error correction data. hardcoded: 00 + // * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure + // * Error Correction Data + + $info['avdataoffset'] = $this->ftell(); + $this->fseek(($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data + $info['avdataend'] = $this->ftell(); + break; + + case GETID3_ASF_Simple_Index_Object: + // Simple Index Object: (optional, recommended, one per video stream) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for Simple Index object - GETID3_ASF_Data_Object + // Object Size QWORD 64 // size of Simple Index object, including 56 bytes of Simple Index Object header + // File ID GUID 128 // unique identifier. may be zero or identical to File ID field in Data Object and Header Object + // Index Entry Time Interval QWORD 64 // interval between index entries in 100-nanosecond units + // Maximum Packet Count DWORD 32 // maximum packet count for all index entries + // Index Entries Count DWORD 32 // number of Index Entries structures + // Index Entries array of: variable // + // * Packet Number DWORD 32 // number of the Data Packet associated with this index entry + // * Packet Count WORD 16 // number of Data Packets to sent at this index entry + + // shortcut + $thisfile_asf['simple_index_object'] = array(); + $thisfile_asf_simpleindexobject = &$thisfile_asf['simple_index_object']; + + $SimpleIndexObjectData = $NextObjectDataHeader.$this->fread(56 - 24); + $offset = 24; + + $thisfile_asf_simpleindexobject['objectid'] = $NextObjectGUID; + $thisfile_asf_simpleindexobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_simpleindexobject['objectsize'] = $NextObjectSize; + + $thisfile_asf_simpleindexobject['fileid'] = substr($SimpleIndexObjectData, $offset, 16); + $offset += 16; + $thisfile_asf_simpleindexobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_simpleindexobject['fileid']); + $thisfile_asf_simpleindexobject['index_entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 8)); + $offset += 8; + $thisfile_asf_simpleindexobject['maximum_packet_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); + $offset += 4; + $thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); + $offset += 4; + + $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']); + for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) { + $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); + $offset += 4; + $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); + $offset += 2; + } + + break; + + case GETID3_ASF_Index_Object: + // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1) + // Field Name Field Type Size (bits) + // Object ID GUID 128 // GUID for the Index Object - GETID3_ASF_Index_Object + // Object Size QWORD 64 // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header + // Index Entry Time Interval DWORD 32 // Specifies the time interval between each index entry in ms. + // Index Specifiers Count WORD 16 // Specifies the number of Index Specifiers structures in this Index Object. + // Index Blocks Count DWORD 32 // Specifies the number of Index Blocks structures in this Index Object. + + // Index Entry Time Interval DWORD 32 // Specifies the time interval between index entries in milliseconds. This value cannot be 0. + // Index Specifiers Count WORD 16 // Specifies the number of entries in the Index Specifiers list. Valid values are 1 and greater. + // Index Specifiers array of: varies // + // * Stream Number WORD 16 // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127. + // * Index Type WORD 16 // Specifies Index Type values as follows: + // 1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time. + // 2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object. + // 3 = Nearest Past Cleanpoint. - indexes point to the closest data packet containing an entire object (or first fragment of an object) that has the Cleanpoint Flag set. + // Nearest Past Cleanpoint is the most common type of index. + // Index Entry Count DWORD 32 // Specifies the number of Index Entries in the block. + // * Block Positions QWORD varies // Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (i.e., the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed. + // * Index Entries array of: varies // + // * * Offsets DWORD varies // An offset value of 0xffffffff indicates an invalid offset value + + // shortcut + $thisfile_asf['asf_index_object'] = array(); + $thisfile_asf_asfindexobject = &$thisfile_asf['asf_index_object']; + + $ASFIndexObjectData = $NextObjectDataHeader.$this->fread(34 - 24); + $offset = 24; + + $thisfile_asf_asfindexobject['objectid'] = $NextObjectGUID; + $thisfile_asf_asfindexobject['objectid_guid'] = $NextObjectGUIDtext; + $thisfile_asf_asfindexobject['objectsize'] = $NextObjectSize; + + $thisfile_asf_asfindexobject['entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); + $offset += 4; + $thisfile_asf_asfindexobject['index_specifiers_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); + $offset += 2; + $thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); + $offset += 4; + + $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']); + for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { + $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); + $offset += 2; + $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber; + $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); + $offset += 2; + $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']); + } + + $ASFIndexObjectData .= $this->fread(4); + $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); + $offset += 4; + + $ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']); + for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { + $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8)); + $offset += 8; + } + + $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']); + for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) { + for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { + $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); + $offset += 4; + } + } + break; + + + default: + // Implementations shall ignore any standard or non-standard object that they do not know how to handle. + if ($this->GUIDname($NextObjectGUIDtext)) { + $this->warning('unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8)); + } else { + $this->warning('unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.($this->ftell() - 16 - 8)); + } + $this->fseek(($NextObjectSize - 16 - 8), SEEK_CUR); + break; + } + } + + if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) { + foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) { + switch ($streamdata['information']) { + case 'WMV1': + case 'WMV2': + case 'WMV3': + case 'MSS1': + case 'MSS2': + case 'WMVA': + case 'WVC1': + case 'WMVP': + case 'WVP2': + $thisfile_video['dataformat'] = 'wmv'; + $info['mime_type'] = 'video/x-ms-wmv'; + break; + + case 'MP42': + case 'MP43': + case 'MP4S': + case 'mp4s': + $thisfile_video['dataformat'] = 'asf'; + $info['mime_type'] = 'video/x-ms-asf'; + break; + + default: + switch ($streamdata['type_raw']) { + case 1: + if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) { + $thisfile_video['dataformat'] = 'wmv'; + if ($info['mime_type'] == 'video/x-ms-asf') { + $info['mime_type'] = 'video/x-ms-wmv'; + } + } + break; + + case 2: + if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) { + $thisfile_audio['dataformat'] = 'wma'; + if ($info['mime_type'] == 'video/x-ms-asf') { + $info['mime_type'] = 'audio/x-ms-wma'; + } + } + break; + + } + break; + } + } + } + + switch (isset($thisfile_audio['codec']) ? $thisfile_audio['codec'] : '') { + case 'MPEG Layer-3': + $thisfile_audio['dataformat'] = 'mp3'; + break; + + default: + break; + } + + if (isset($thisfile_asf_codeclistobject['codec_entries'])) { + foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) { + switch ($streamdata['type_raw']) { + + case 1: // video + $thisfile_video['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']); + break; + + case 2: // audio + $thisfile_audio['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']); + + // AH 2003-10-01 + $thisfile_audio['encoder_options'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][0]['description']); + + $thisfile_audio['codec'] = $thisfile_audio['encoder']; + break; + + default: + $this->warning('Unknown streamtype: [codec_list_object][codec_entries]['.$streamnumber.'][type_raw] == '.$streamdata['type_raw']); + break; + + } + } + } + + if (isset($info['audio'])) { + $thisfile_audio['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false); + $thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf'); + } + if (!empty($thisfile_video['dataformat'])) { + $thisfile_video['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false); + $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1); + $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); + } + if (!empty($thisfile_video['streams'])) { + $thisfile_video['resolution_x'] = 0; + $thisfile_video['resolution_y'] = 0; + foreach ($thisfile_video['streams'] as $key => $valuearray) { + if (($valuearray['resolution_x'] > $thisfile_video['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['resolution_y'])) { + $thisfile_video['resolution_x'] = $valuearray['resolution_x']; + $thisfile_video['resolution_y'] = $valuearray['resolution_y']; + } + } + } + $info['bitrate'] = (isset($thisfile_audio['bitrate']) ? $thisfile_audio['bitrate'] : 0) + (isset($thisfile_video['bitrate']) ? $thisfile_video['bitrate'] : 0); + + if ((!isset($info['playtime_seconds']) || ($info['playtime_seconds'] <= 0)) && ($info['bitrate'] > 0)) { + $info['playtime_seconds'] = ($info['filesize'] - $info['avdataoffset']) / ($info['bitrate'] / 8); + } + + return true; + } + + public static function codecListObjectTypeLookup($CodecListType) { + static $lookup = array( + 0x0001 => 'Video Codec', + 0x0002 => 'Audio Codec', + 0xFFFF => 'Unknown Codec' + ); + + return (isset($lookup[$CodecListType]) ? $lookup[$CodecListType] : 'Invalid Codec Type'); + } + + public static function KnownGUIDs() { + static $GUIDarray = array( + 'GETID3_ASF_Extended_Stream_Properties_Object' => '14E6A5CB-C672-4332-8399-A96952065B5A', + 'GETID3_ASF_Padding_Object' => '1806D474-CADF-4509-A4BA-9AABCB96AAE8', + 'GETID3_ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio' => '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8', + 'GETID3_ASF_Script_Command_Object' => '1EFB1A30-0B62-11D0-A39B-00A0C90348F6', + 'GETID3_ASF_No_Error_Correction' => '20FB5700-5B55-11CF-A8FD-00805F5C442B', + 'GETID3_ASF_Content_Branding_Object' => '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E', + 'GETID3_ASF_Content_Encryption_Object' => '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E', + 'GETID3_ASF_Digital_Signature_Object' => '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E', + 'GETID3_ASF_Extended_Content_Encryption_Object' => '298AE614-2622-4C17-B935-DAE07EE9289C', + 'GETID3_ASF_Simple_Index_Object' => '33000890-E5B1-11CF-89F4-00A0C90349CB', + 'GETID3_ASF_Degradable_JPEG_Media' => '35907DE0-E415-11CF-A917-00805F5C442B', + 'GETID3_ASF_Payload_Extension_System_Timecode' => '399595EC-8667-4E2D-8FDB-98814CE76C1E', + 'GETID3_ASF_Binary_Media' => '3AFB65E2-47EF-40F2-AC2C-70A90D71D343', + 'GETID3_ASF_Timecode_Index_Object' => '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C', + 'GETID3_ASF_Metadata_Library_Object' => '44231C94-9498-49D1-A141-1D134E457054', + 'GETID3_ASF_Reserved_3' => '4B1ACBE3-100B-11D0-A39B-00A0C90348F6', + 'GETID3_ASF_Reserved_4' => '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB', + 'GETID3_ASF_Command_Media' => '59DACFC0-59E6-11D0-A3AC-00A0C90348F6', + 'GETID3_ASF_Header_Extension_Object' => '5FBF03B5-A92E-11CF-8EE3-00C00C205365', + 'GETID3_ASF_Media_Object_Index_Parameters_Obj' => '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7', + 'GETID3_ASF_Header_Object' => '75B22630-668E-11CF-A6D9-00AA0062CE6C', + 'GETID3_ASF_Content_Description_Object' => '75B22633-668E-11CF-A6D9-00AA0062CE6C', + 'GETID3_ASF_Error_Correction_Object' => '75B22635-668E-11CF-A6D9-00AA0062CE6C', + 'GETID3_ASF_Data_Object' => '75B22636-668E-11CF-A6D9-00AA0062CE6C', + 'GETID3_ASF_Web_Stream_Media_Subtype' => '776257D4-C627-41CB-8F81-7AC7FF1C40CC', + 'GETID3_ASF_Stream_Bitrate_Properties_Object' => '7BF875CE-468D-11D1-8D82-006097C9A2B2', + 'GETID3_ASF_Language_List_Object' => '7C4346A9-EFE0-4BFC-B229-393EDE415C85', + 'GETID3_ASF_Codec_List_Object' => '86D15240-311D-11D0-A3A4-00A0C90348F6', + 'GETID3_ASF_Reserved_2' => '86D15241-311D-11D0-A3A4-00A0C90348F6', + 'GETID3_ASF_File_Properties_Object' => '8CABDCA1-A947-11CF-8EE4-00C00C205365', + 'GETID3_ASF_File_Transfer_Media' => '91BD222C-F21C-497A-8B6D-5AA86BFC0185', + 'GETID3_ASF_Old_RTP_Extension_Data' => '96800C63-4C94-11D1-837B-0080C7A37F95', + 'GETID3_ASF_Advanced_Mutual_Exclusion_Object' => 'A08649CF-4775-4670-8A16-6E35357566CD', + 'GETID3_ASF_Bandwidth_Sharing_Object' => 'A69609E6-517B-11D2-B6AF-00C04FD908E9', + 'GETID3_ASF_Reserved_1' => 'ABD3D211-A9BA-11cf-8EE6-00C00C205365', + 'GETID3_ASF_Bandwidth_Sharing_Exclusive' => 'AF6060AA-5197-11D2-B6AF-00C04FD908E9', + 'GETID3_ASF_Bandwidth_Sharing_Partial' => 'AF6060AB-5197-11D2-B6AF-00C04FD908E9', + 'GETID3_ASF_JFIF_Media' => 'B61BE100-5B4E-11CF-A8FD-00805F5C442B', + 'GETID3_ASF_Stream_Properties_Object' => 'B7DC0791-A9B7-11CF-8EE6-00C00C205365', + 'GETID3_ASF_Video_Media' => 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B', + 'GETID3_ASF_Audio_Spread' => 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220', + 'GETID3_ASF_Metadata_Object' => 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA', + 'GETID3_ASF_Payload_Ext_Syst_Sample_Duration' => 'C6BD9450-867F-4907-83A3-C77921B733AD', + 'GETID3_ASF_Group_Mutual_Exclusion_Object' => 'D1465A40-5A79-4338-B71B-E36B8FD6C249', + 'GETID3_ASF_Extended_Content_Description_Object' => 'D2D0A440-E307-11D2-97F0-00A0C95EA850', + 'GETID3_ASF_Stream_Prioritization_Object' => 'D4FED15B-88D3-454F-81F0-ED5C45999E24', + 'GETID3_ASF_Payload_Ext_System_Content_Type' => 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC', + 'GETID3_ASF_Old_File_Properties_Object' => 'D6E229D0-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_ASF_Header_Object' => 'D6E229D1-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_ASF_Data_Object' => 'D6E229D2-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Index_Object' => 'D6E229D3-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Stream_Properties_Object' => 'D6E229D4-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Content_Description_Object' => 'D6E229D5-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Script_Command_Object' => 'D6E229D6-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Marker_Object' => 'D6E229D7-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Component_Download_Object' => 'D6E229D8-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Stream_Group_Object' => 'D6E229D9-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Scalable_Object' => 'D6E229DA-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Prioritization_Object' => 'D6E229DB-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Bitrate_Mutual_Exclusion_Object' => 'D6E229DC-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Inter_Media_Dependency_Object' => 'D6E229DD-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Rating_Object' => 'D6E229DE-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Index_Parameters_Object' => 'D6E229DF-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Color_Table_Object' => 'D6E229E0-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Language_List_Object' => 'D6E229E1-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Audio_Media' => 'D6E229E2-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Video_Media' => 'D6E229E3-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Image_Media' => 'D6E229E4-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Timecode_Media' => 'D6E229E5-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Text_Media' => 'D6E229E6-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_MIDI_Media' => 'D6E229E7-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Command_Media' => 'D6E229E8-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_No_Error_Concealment' => 'D6E229EA-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Scrambled_Audio' => 'D6E229EB-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_No_Color_Table' => 'D6E229EC-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_SMPTE_Time' => 'D6E229ED-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_ASCII_Text' => 'D6E229EE-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Unicode_Text' => 'D6E229EF-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_HTML_Text' => 'D6E229F0-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_URL_Command' => 'D6E229F1-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Filename_Command' => 'D6E229F2-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_ACM_Codec' => 'D6E229F3-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_VCM_Codec' => 'D6E229F4-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_QuickTime_Codec' => 'D6E229F5-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_DirectShow_Transform_Filter' => 'D6E229F6-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_DirectShow_Rendering_Filter' => 'D6E229F7-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_No_Enhancement' => 'D6E229F8-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Unknown_Enhancement_Type' => 'D6E229F9-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Temporal_Enhancement' => 'D6E229FA-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Spatial_Enhancement' => 'D6E229FB-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Quality_Enhancement' => 'D6E229FC-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Number_of_Channels_Enhancement' => 'D6E229FD-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Frequency_Response_Enhancement' => 'D6E229FE-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Media_Object' => 'D6E229FF-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Mutex_Language' => 'D6E22A00-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Mutex_Bitrate' => 'D6E22A01-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Mutex_Unknown' => 'D6E22A02-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_ASF_Placeholder_Object' => 'D6E22A0E-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Old_Data_Unit_Extension_Object' => 'D6E22A0F-35DA-11D1-9034-00A0C90349BE', + 'GETID3_ASF_Web_Stream_Format' => 'DA1E6B13-8359-4050-B398-388E965BF00C', + 'GETID3_ASF_Payload_Ext_System_File_Name' => 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B', + 'GETID3_ASF_Marker_Object' => 'F487CD01-A951-11CF-8EE6-00C00C205365', + 'GETID3_ASF_Timecode_Index_Parameters_Object' => 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24', + 'GETID3_ASF_Audio_Media' => 'F8699E40-5B4D-11CF-A8FD-00805F5C442B', + 'GETID3_ASF_Media_Object_Index_Object' => 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C', + 'GETID3_ASF_Alt_Extended_Content_Encryption_Obj' => 'FF889EF1-ADEE-40DA-9E71-98704BB928CE', + 'GETID3_ASF_Index_Placeholder_Object' => 'D9AADE20-7C17-4F9C-BC28-8555DD98E2A2', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html + 'GETID3_ASF_Compatibility_Object' => '26F18B5D-4584-47EC-9F5F-0E651F0452C9', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html + ); + return $GUIDarray; + } + + public static function GUIDname($GUIDstring) { + static $GUIDarray = array(); + if (empty($GUIDarray)) { + $GUIDarray = self::KnownGUIDs(); + } + return array_search($GUIDstring, $GUIDarray); + } + + public static function ASFIndexObjectIndexTypeLookup($id) { + static $ASFIndexObjectIndexTypeLookup = array(); + if (empty($ASFIndexObjectIndexTypeLookup)) { + $ASFIndexObjectIndexTypeLookup[1] = 'Nearest Past Data Packet'; + $ASFIndexObjectIndexTypeLookup[2] = 'Nearest Past Media Object'; + $ASFIndexObjectIndexTypeLookup[3] = 'Nearest Past Cleanpoint'; + } + return (isset($ASFIndexObjectIndexTypeLookup[$id]) ? $ASFIndexObjectIndexTypeLookup[$id] : 'invalid'); + } + + public static function GUIDtoBytestring($GUIDstring) { + // Microsoft defines these 16-byte (128-bit) GUIDs in the strangest way: + // first 4 bytes are in little-endian order + // next 2 bytes are appended in little-endian order + // next 2 bytes are appended in little-endian order + // next 2 bytes are appended in big-endian order + // next 6 bytes are appended in big-endian order + + // AaBbCcDd-EeFf-GgHh-IiJj-KkLlMmNnOoPp is stored as this 16-byte string: + // $Dd $Cc $Bb $Aa $Ff $Ee $Hh $Gg $Ii $Jj $Kk $Ll $Mm $Nn $Oo $Pp + + $hexbytecharstring = chr(hexdec(substr($GUIDstring, 6, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 4, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 2, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 0, 2))); + + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 11, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 9, 2))); + + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 16, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 14, 2))); + + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 19, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 21, 2))); + + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 24, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 26, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 28, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 30, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 32, 2))); + $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 34, 2))); + + return $hexbytecharstring; + } + + public static function BytestringToGUID($Bytestring) { + $GUIDstring = str_pad(dechex(ord($Bytestring{3})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{2})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{1})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{0})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= '-'; + $GUIDstring .= str_pad(dechex(ord($Bytestring{5})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{4})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= '-'; + $GUIDstring .= str_pad(dechex(ord($Bytestring{7})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{6})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= '-'; + $GUIDstring .= str_pad(dechex(ord($Bytestring{8})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{9})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= '-'; + $GUIDstring .= str_pad(dechex(ord($Bytestring{10})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{11})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{12})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{13})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{14})), 2, '0', STR_PAD_LEFT); + $GUIDstring .= str_pad(dechex(ord($Bytestring{15})), 2, '0', STR_PAD_LEFT); + + return strtoupper($GUIDstring); + } + + public static function FILETIMEtoUNIXtime($FILETIME, $round=true) { + // FILETIME is a 64-bit unsigned integer representing + // the number of 100-nanosecond intervals since January 1, 1601 + // UNIX timestamp is number of seconds since January 1, 1970 + // 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days + if ($round) { + return intval(round(($FILETIME - 116444736000000000) / 10000000)); + } + return ($FILETIME - 116444736000000000) / 10000000; + } + + public static function WMpictureTypeLookup($WMpictureType) { + static $lookup = null; + if ($lookup === null) { + $lookup = array( + 0x03 => 'Front Cover', + 0x04 => 'Back Cover', + 0x00 => 'User Defined', + 0x05 => 'Leaflet Page', + 0x06 => 'Media Label', + 0x07 => 'Lead Artist', + 0x08 => 'Artist', + 0x09 => 'Conductor', + 0x0A => 'Band', + 0x0B => 'Composer', + 0x0C => 'Lyricist', + 0x0D => 'Recording Location', + 0x0E => 'During Recording', + 0x0F => 'During Performance', + 0x10 => 'Video Screen Capture', + 0x12 => 'Illustration', + 0x13 => 'Band Logotype', + 0x14 => 'Publisher Logotype' + ); + $lookup = array_map(function($str) { + return getid3_lib::iconv_fallback('UTF-8', 'UTF-16LE', $str); + }, $lookup); + } + + return (isset($lookup[$WMpictureType]) ? $lookup[$WMpictureType] : ''); + } + + public function HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) { + // http://msdn.microsoft.com/en-us/library/bb643323.aspx + + $offset = 0; + $objectOffset = 0; + $HeaderExtensionObjectParsed = array(); + while ($objectOffset < strlen($asf_header_extension_object_data)) { + $offset = $objectOffset; + $thisObject = array(); + + $thisObject['guid'] = substr($asf_header_extension_object_data, $offset, 16); + $offset += 16; + $thisObject['guid_text'] = $this->BytestringToGUID($thisObject['guid']); + $thisObject['guid_name'] = $this->GUIDname($thisObject['guid_text']); + + $thisObject['size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8)); + $offset += 8; + if ($thisObject['size'] <= 0) { + break; + } + + switch ($thisObject['guid']) { + case GETID3_ASF_Extended_Stream_Properties_Object: + $thisObject['start_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8)); + $offset += 8; + $thisObject['start_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['start_time']); + + $thisObject['end_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8)); + $offset += 8; + $thisObject['end_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['end_time']); + + $thisObject['data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['alternate_data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['alternate_buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['alternate_initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['maximum_object_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + $thisObject['flags']['reliable'] = (bool) $thisObject['flags_raw'] & 0x00000001; + $thisObject['flags']['seekable'] = (bool) $thisObject['flags_raw'] & 0x00000002; + $thisObject['flags']['no_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000004; + $thisObject['flags']['resend_live_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000008; + + $thisObject['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $thisObject['stream_language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $thisObject['average_time_per_frame'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $thisObject['stream_name_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $thisObject['payload_extension_system_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + for ($i = 0; $i < $thisObject['stream_name_count']; $i++) { + $streamName = array(); + + $streamName['language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $streamName['stream_name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $streamName['stream_name'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $streamName['stream_name_length'])); + $offset += $streamName['stream_name_length']; + + $thisObject['stream_names'][$i] = $streamName; + } + + for ($i = 0; $i < $thisObject['payload_extension_system_count']; $i++) { + $payloadExtensionSystem = array(); + + $payloadExtensionSystem['extension_system_id'] = substr($asf_header_extension_object_data, $offset, 16); + $offset += 16; + $payloadExtensionSystem['extension_system_id_text'] = $this->BytestringToGUID($payloadExtensionSystem['extension_system_id']); + + $payloadExtensionSystem['extension_system_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + if ($payloadExtensionSystem['extension_system_size'] <= 0) { + break 2; + } + + $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $payloadExtensionSystem['extension_system_info_length'])); + $offset += $payloadExtensionSystem['extension_system_info_length']; + + $thisObject['payload_extension_systems'][$i] = $payloadExtensionSystem; + } + + break; + + case GETID3_ASF_Padding_Object: + // padding, skip it + break; + + case GETID3_ASF_Metadata_Object: + $thisObject['description_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + for ($i = 0; $i < $thisObject['description_record_counts']; $i++) { + $descriptionRecord = array(); + + $descriptionRecord['reserved_1'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); // must be zero + $offset += 2; + + $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); + + $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); + $offset += $descriptionRecord['name_length']; + + $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']); + $offset += $descriptionRecord['data_length']; + switch ($descriptionRecord['data_type']) { + case 0x0000: // Unicode string + break; + + case 0x0001: // BYTE array + // do nothing + break; + + case 0x0002: // BOOL + $descriptionRecord['data'] = (bool) getid3_lib::LittleEndian2Int($descriptionRecord['data']); + break; + + case 0x0003: // DWORD + case 0x0004: // QWORD + case 0x0005: // WORD + $descriptionRecord['data'] = getid3_lib::LittleEndian2Int($descriptionRecord['data']); + break; + + case 0x0006: // GUID + $descriptionRecord['data_text'] = $this->BytestringToGUID($descriptionRecord['data']); + break; + } + + $thisObject['description_record'][$i] = $descriptionRecord; + } + break; + + case GETID3_ASF_Language_List_Object: + $thisObject['language_id_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + for ($i = 0; $i < $thisObject['language_id_record_counts']; $i++) { + $languageIDrecord = array(); + + $languageIDrecord['language_id_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 1)); + $offset += 1; + + $languageIDrecord['language_id'] = substr($asf_header_extension_object_data, $offset, $languageIDrecord['language_id_length']); + $offset += $languageIDrecord['language_id_length']; + + $thisObject['language_id_record'][$i] = $languageIDrecord; + } + break; + + case GETID3_ASF_Metadata_Library_Object: + $thisObject['description_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + for ($i = 0; $i < $thisObject['description_records_count']; $i++) { + $descriptionRecord = array(); + + $descriptionRecord['language_list_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + + $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); + $offset += 2; + $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); + + $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); + $offset += 4; + + $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); + $offset += $descriptionRecord['name_length']; + + $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']); + $offset += $descriptionRecord['data_length']; + + if (preg_match('#^WM/Picture$#', str_replace("\x00", '', trim($descriptionRecord['name'])))) { + $WMpicture = $this->ASF_WMpicture($descriptionRecord['data']); + foreach ($WMpicture as $key => $value) { + $descriptionRecord['data'] = $WMpicture; + } + unset($WMpicture); + } + + $thisObject['description_record'][$i] = $descriptionRecord; + } + break; + + default: + $unhandled_sections++; + if ($this->GUIDname($thisObject['guid_text'])) { + $this->warning('unhandled Header Extension Object GUID "'.$this->GUIDname($thisObject['guid_text']).'" {'.$thisObject['guid_text'].'} at offset '.($offset - 16 - 8)); + } else { + $this->warning('unknown Header Extension Object GUID {'.$thisObject['guid_text'].'} in at offset '.($offset - 16 - 8)); + } + break; + } + $HeaderExtensionObjectParsed[] = $thisObject; + + $objectOffset += $thisObject['size']; + } + return $HeaderExtensionObjectParsed; + } + + + public static function metadataLibraryObjectDataTypeLookup($id) { + static $lookup = array( + 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters + 0x0001 => 'BYTE array', // The type of the data is implementation-specific + 0x0002 => 'BOOL', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values + 0x0003 => 'DWORD', // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer + 0x0004 => 'QWORD', // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer + 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer + 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID + ); + return (isset($lookup[$id]) ? $lookup[$id] : 'invalid'); + } + + public function ASF_WMpicture(&$data) { + //typedef struct _WMPicture{ + // LPWSTR pwszMIMEType; + // BYTE bPictureType; + // LPWSTR pwszDescription; + // DWORD dwDataLen; + // BYTE* pbData; + //} WM_PICTURE; + + $WMpicture = array(); + + $offset = 0; + $WMpicture['image_type_id'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 1)); + $offset += 1; + $WMpicture['image_type'] = self::WMpictureTypeLookup($WMpicture['image_type_id']); + $WMpicture['image_size'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 4)); + $offset += 4; + + $WMpicture['image_mime'] = ''; + do { + $next_byte_pair = substr($data, $offset, 2); + $offset += 2; + $WMpicture['image_mime'] .= $next_byte_pair; + } while ($next_byte_pair !== "\x00\x00"); + + $WMpicture['image_description'] = ''; + do { + $next_byte_pair = substr($data, $offset, 2); + $offset += 2; + $WMpicture['image_description'] .= $next_byte_pair; + } while ($next_byte_pair !== "\x00\x00"); + + $WMpicture['dataoffset'] = $offset; + $WMpicture['data'] = substr($data, $offset); + + $imageinfo = array(); + $WMpicture['image_mime'] = ''; + $imagechunkcheck = getid3_lib::GetDataImageSize($WMpicture['data'], $imageinfo); + unset($imageinfo); + if (!empty($imagechunkcheck)) { + $WMpicture['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]); + } + if (!isset($this->getid3->info['asf']['comments']['picture'])) { + $this->getid3->info['asf']['comments']['picture'] = array(); + } + $this->getid3->info['asf']['comments']['picture'][] = array('data'=>$WMpicture['data'], 'image_mime'=>$WMpicture['image_mime']); + + return $WMpicture; + } + + + // Remove terminator 00 00 and convert UTF-16LE to Latin-1 + public static function TrimConvert($string) { + return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', self::TrimTerm($string)), ' '); + } + + + // Remove terminator 00 00 + public static function TrimTerm($string) { + // remove terminator, only if present (it should be, but...) + if (substr($string, -2) === "\x00\x00") { + $string = substr($string, 0, -2); + } + return $string; + } + +} diff --git a/backend/wp-includes/ID3/module.audio-video.flv.php b/backend/wp-includes/ID3/module.audio-video.flv.php new file mode 100644 index 0000000..661c77c --- /dev/null +++ b/backend/wp-includes/ID3/module.audio-video.flv.php @@ -0,0 +1,745 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +// // +// FLV module by Seth Kaufman // +// // +// * version 0.1 (26 June 2005) // +// // +// // +// * version 0.1.1 (15 July 2005) // +// minor modifications by James Heinrich // +// // +// * version 0.2 (22 February 2006) // +// Support for On2 VP6 codec and meta information // +// by Steve Webster // +// // +// * version 0.3 (15 June 2006) // +// Modified to not read entire file into memory // +// by James Heinrich // +// // +// * version 0.4 (07 December 2007) // +// Bugfixes for incorrectly parsed FLV dimensions // +// and incorrect parsing of onMetaTag // +// by Evgeny Moysevich // +// // +// * version 0.5 (21 May 2009) // +// Fixed parsing of audio tags and added additional codec // +// details. The duration is now read from onMetaTag (if // +// exists), rather than parsing whole file // +// by Nigel Barnes // +// // +// * version 0.6 (24 May 2009) // +// Better parsing of files with h264 video // +// by Evgeny Moysevich // +// // +// * version 0.6.1 (30 May 2011) // +// prevent infinite loops in expGolombUe() // +// // +// * version 0.7.0 (16 Jul 2013) // +// handle GETID3_FLV_VIDEO_VP6FLV_ALPHA // +// improved AVCSequenceParameterSetReader::readData() // +// by Xander Schouwerwou // +// // +///////////////////////////////////////////////////////////////// +// // +// module.audio-video.flv.php // +// module for analyzing Shockwave Flash Video files // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + +define('GETID3_FLV_TAG_AUDIO', 8); +define('GETID3_FLV_TAG_VIDEO', 9); +define('GETID3_FLV_TAG_META', 18); + +define('GETID3_FLV_VIDEO_H263', 2); +define('GETID3_FLV_VIDEO_SCREEN', 3); +define('GETID3_FLV_VIDEO_VP6FLV', 4); +define('GETID3_FLV_VIDEO_VP6FLV_ALPHA', 5); +define('GETID3_FLV_VIDEO_SCREENV2', 6); +define('GETID3_FLV_VIDEO_H264', 7); + +define('H264_AVC_SEQUENCE_HEADER', 0); +define('H264_PROFILE_BASELINE', 66); +define('H264_PROFILE_MAIN', 77); +define('H264_PROFILE_EXTENDED', 88); +define('H264_PROFILE_HIGH', 100); +define('H264_PROFILE_HIGH10', 110); +define('H264_PROFILE_HIGH422', 122); +define('H264_PROFILE_HIGH444', 144); +define('H264_PROFILE_HIGH444_PREDICTIVE', 244); + +class getid3_flv extends getid3_handler { + + const magic = 'FLV'; + + public $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration + + public function Analyze() { + $info = &$this->getid3->info; + + $this->fseek($info['avdataoffset']); + + $FLVdataLength = $info['avdataend'] - $info['avdataoffset']; + $FLVheader = $this->fread(5); + + $info['fileformat'] = 'flv'; + $info['flv']['header']['signature'] = substr($FLVheader, 0, 3); + $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1)); + $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1)); + + if ($info['flv']['header']['signature'] != self::magic) { + $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"'); + unset($info['flv'], $info['fileformat']); + return false; + } + + $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04); + $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01); + + $FrameSizeDataLength = getid3_lib::BigEndian2Int($this->fread(4)); + $FLVheaderFrameLength = 9; + if ($FrameSizeDataLength > $FLVheaderFrameLength) { + $this->fseek($FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR); + } + $Duration = 0; + $found_video = false; + $found_audio = false; + $found_meta = false; + $found_valid_meta_playtime = false; + $tagParseCount = 0; + $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0); + $flv_framecount = &$info['flv']['framecount']; + while ((($this->ftell() + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) { + $ThisTagHeader = $this->fread(16); + + $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4)); + $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1)); + $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3)); + $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3)); + $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1)); + $NextOffset = $this->ftell() - 1 + $DataLength; + if ($Timestamp > $Duration) { + $Duration = $Timestamp; + } + + $flv_framecount['total']++; + switch ($TagType) { + case GETID3_FLV_TAG_AUDIO: + $flv_framecount['audio']++; + if (!$found_audio) { + $found_audio = true; + $info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F; + $info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03; + $info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01; + $info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01; + } + break; + + case GETID3_FLV_TAG_VIDEO: + $flv_framecount['video']++; + if (!$found_video) { + $found_video = true; + $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07; + + $FLVvideoHeader = $this->fread(11); + + if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) { + // this code block contributed by: moysevichØgmail*com + + $AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1)); + if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) { + // read AVCDecoderConfigurationRecord + $configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1)); + $AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1)); + $profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1)); + $lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1)); + $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1)); + + if (($numOfSequenceParameterSets & 0x1F) != 0) { + // there is at least one SequenceParameterSet + // read size of the first SequenceParameterSet + //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2)); + $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2)); + // read the first SequenceParameterSet + $sps = $this->fread($spsSize); + if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red + $spsReader = new AVCSequenceParameterSetReader($sps); + $spsReader->readData(); + $info['video']['resolution_x'] = $spsReader->getWidth(); + $info['video']['resolution_y'] = $spsReader->getHeight(); + } + } + } + // end: moysevichØgmail*com + + } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) { + + $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7; + $PictureSizeType = $PictureSizeType & 0x0007; + $info['flv']['header']['videoSizeType'] = $PictureSizeType; + switch ($PictureSizeType) { + case 0: + //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)); + //$PictureSizeEnc <<= 1; + //$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8; + //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2)); + //$PictureSizeEnc <<= 1; + //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8; + + $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2)) >> 7; + $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2)) >> 7; + $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF; + $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF; + break; + + case 1: + $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3)) >> 7; + $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3)) >> 7; + $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF; + $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF; + break; + + case 2: + $info['video']['resolution_x'] = 352; + $info['video']['resolution_y'] = 288; + break; + + case 3: + $info['video']['resolution_x'] = 176; + $info['video']['resolution_y'] = 144; + break; + + case 4: + $info['video']['resolution_x'] = 128; + $info['video']['resolution_y'] = 96; + break; + + case 5: + $info['video']['resolution_x'] = 320; + $info['video']['resolution_y'] = 240; + break; + + case 6: + $info['video']['resolution_x'] = 160; + $info['video']['resolution_y'] = 120; + break; + + default: + $info['video']['resolution_x'] = 0; + $info['video']['resolution_y'] = 0; + break; + + } + + } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_VP6FLV_ALPHA) { + + /* contributed by schouwerwouØgmail*com */ + if (!isset($info['video']['resolution_x'])) { // only when meta data isn't set + $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2)); + $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 2)); + $info['video']['resolution_x'] = ($PictureSizeEnc['x'] & 0xFF) << 3; + $info['video']['resolution_y'] = ($PictureSizeEnc['y'] & 0xFF) << 3; + } + /* end schouwerwouØgmail*com */ + + } + if (!empty($info['video']['resolution_x']) && !empty($info['video']['resolution_y'])) { + $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y']; + } + } + break; + + // Meta tag + case GETID3_FLV_TAG_META: + if (!$found_meta) { + $found_meta = true; + $this->fseek(-1, SEEK_CUR); + $datachunk = $this->fread($DataLength); + $AMFstream = new AMFStream($datachunk); + $reader = new AMFReader($AMFstream); + $eventName = $reader->readData(); + $info['flv']['meta'][$eventName] = $reader->readData(); + unset($reader); + + $copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate'); + foreach ($copykeys as $sourcekey => $destkey) { + if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) { + switch ($sourcekey) { + case 'width': + case 'height': + $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey])); + break; + case 'audiodatarate': + $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000)); + break; + case 'videodatarate': + case 'frame_rate': + default: + $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey]; + break; + } + } + } + if (!empty($info['flv']['meta']['onMetaData']['duration'])) { + $found_valid_meta_playtime = true; + } + } + break; + + default: + // noop + break; + } + $this->fseek($NextOffset); + } + + $info['playtime_seconds'] = $Duration / 1000; + if ($info['playtime_seconds'] > 0) { + $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; + } + + if ($info['flv']['header']['hasAudio']) { + $info['audio']['codec'] = self::audioFormatLookup($info['flv']['audio']['audioFormat']); + $info['audio']['sample_rate'] = self::audioRateLookup($info['flv']['audio']['audioRate']); + $info['audio']['bits_per_sample'] = self::audioBitDepthLookup($info['flv']['audio']['audioSampleSize']); + + $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo + $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed + $info['audio']['dataformat'] = 'flv'; + } + if (!empty($info['flv']['header']['hasVideo'])) { + $info['video']['codec'] = self::videoCodecLookup($info['flv']['video']['videoCodec']); + $info['video']['dataformat'] = 'flv'; + $info['video']['lossless'] = false; + } + + // Set information from meta + if (!empty($info['flv']['meta']['onMetaData']['duration'])) { + $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration']; + $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; + } + if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) { + $info['audio']['codec'] = self::audioFormatLookup($info['flv']['meta']['onMetaData']['audiocodecid']); + } + if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) { + $info['video']['codec'] = self::videoCodecLookup($info['flv']['meta']['onMetaData']['videocodecid']); + } + return true; + } + + + public static function audioFormatLookup($id) { + static $lookup = array( + 0 => 'Linear PCM, platform endian', + 1 => 'ADPCM', + 2 => 'mp3', + 3 => 'Linear PCM, little endian', + 4 => 'Nellymoser 16kHz mono', + 5 => 'Nellymoser 8kHz mono', + 6 => 'Nellymoser', + 7 => 'G.711A-law logarithmic PCM', + 8 => 'G.711 mu-law logarithmic PCM', + 9 => 'reserved', + 10 => 'AAC', + 11 => 'Speex', + 12 => false, // unknown? + 13 => false, // unknown? + 14 => 'mp3 8kHz', + 15 => 'Device-specific sound', + ); + return (isset($lookup[$id]) ? $lookup[$id] : false); + } + + public static function audioRateLookup($id) { + static $lookup = array( + 0 => 5500, + 1 => 11025, + 2 => 22050, + 3 => 44100, + ); + return (isset($lookup[$id]) ? $lookup[$id] : false); + } + + public static function audioBitDepthLookup($id) { + static $lookup = array( + 0 => 8, + 1 => 16, + ); + return (isset($lookup[$id]) ? $lookup[$id] : false); + } + + public static function videoCodecLookup($id) { + static $lookup = array( + GETID3_FLV_VIDEO_H263 => 'Sorenson H.263', + GETID3_FLV_VIDEO_SCREEN => 'Screen video', + GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6', + GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel', + GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2', + GETID3_FLV_VIDEO_H264 => 'Sorenson H.264', + ); + return (isset($lookup[$id]) ? $lookup[$id] : false); + } +} + +class AMFStream { + public $bytes; + public $pos; + + public function __construct(&$bytes) { + $this->bytes =& $bytes; + $this->pos = 0; + } + + public function readByte() { + return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1)); + } + + public function readInt() { + return ($this->readByte() << 8) + $this->readByte(); + } + + public function readLong() { + return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte(); + } + + public function readDouble() { + return getid3_lib::BigEndian2Float($this->read(8)); + } + + public function readUTF() { + $length = $this->readInt(); + return $this->read($length); + } + + public function readLongUTF() { + $length = $this->readLong(); + return $this->read($length); + } + + public function read($length) { + $val = substr($this->bytes, $this->pos, $length); + $this->pos += $length; + return $val; + } + + public function peekByte() { + $pos = $this->pos; + $val = $this->readByte(); + $this->pos = $pos; + return $val; + } + + public function peekInt() { + $pos = $this->pos; + $val = $this->readInt(); + $this->pos = $pos; + return $val; + } + + public function peekLong() { + $pos = $this->pos; + $val = $this->readLong(); + $this->pos = $pos; + return $val; + } + + public function peekDouble() { + $pos = $this->pos; + $val = $this->readDouble(); + $this->pos = $pos; + return $val; + } + + public function peekUTF() { + $pos = $this->pos; + $val = $this->readUTF(); + $this->pos = $pos; + return $val; + } + + public function peekLongUTF() { + $pos = $this->pos; + $val = $this->readLongUTF(); + $this->pos = $pos; + return $val; + } +} + +class AMFReader { + public $stream; + + public function __construct(&$stream) { + $this->stream =& $stream; + } + + public function readData() { + $value = null; + + $type = $this->stream->readByte(); + switch ($type) { + + // Double + case 0: + $value = $this->readDouble(); + break; + + // Boolean + case 1: + $value = $this->readBoolean(); + break; + + // String + case 2: + $value = $this->readString(); + break; + + // Object + case 3: + $value = $this->readObject(); + break; + + // null + case 6: + return null; + break; + + // Mixed array + case 8: + $value = $this->readMixedArray(); + break; + + // Array + case 10: + $value = $this->readArray(); + break; + + // Date + case 11: + $value = $this->readDate(); + break; + + // Long string + case 13: + $value = $this->readLongString(); + break; + + // XML (handled as string) + case 15: + $value = $this->readXML(); + break; + + // Typed object (handled as object) + case 16: + $value = $this->readTypedObject(); + break; + + // Long string + default: + $value = '(unknown or unsupported data type)'; + break; + } + + return $value; + } + + public function readDouble() { + return $this->stream->readDouble(); + } + + public function readBoolean() { + return $this->stream->readByte() == 1; + } + + public function readString() { + return $this->stream->readUTF(); + } + + public function readObject() { + // Get highest numerical index - ignored +// $highestIndex = $this->stream->readLong(); + + $data = array(); + + while ($key = $this->stream->readUTF()) { + $data[$key] = $this->readData(); + } + // Mixed array record ends with empty string (0x00 0x00) and 0x09 + if (($key == '') && ($this->stream->peekByte() == 0x09)) { + // Consume byte + $this->stream->readByte(); + } + return $data; + } + + public function readMixedArray() { + // Get highest numerical index - ignored + $highestIndex = $this->stream->readLong(); + + $data = array(); + + while ($key = $this->stream->readUTF()) { + if (is_numeric($key)) { + $key = (float) $key; + } + $data[$key] = $this->readData(); + } + // Mixed array record ends with empty string (0x00 0x00) and 0x09 + if (($key == '') && ($this->stream->peekByte() == 0x09)) { + // Consume byte + $this->stream->readByte(); + } + + return $data; + } + + public function readArray() { + $length = $this->stream->readLong(); + $data = array(); + + for ($i = 0; $i < $length; $i++) { + $data[] = $this->readData(); + } + return $data; + } + + public function readDate() { + $timestamp = $this->stream->readDouble(); + $timezone = $this->stream->readInt(); + return $timestamp; + } + + public function readLongString() { + return $this->stream->readLongUTF(); + } + + public function readXML() { + return $this->stream->readLongUTF(); + } + + public function readTypedObject() { + $className = $this->stream->readUTF(); + return $this->readObject(); + } +} + +class AVCSequenceParameterSetReader { + public $sps; + public $start = 0; + public $currentBytes = 0; + public $currentBits = 0; + public $width; + public $height; + + public function __construct($sps) { + $this->sps = $sps; + } + + public function readData() { + $this->skipBits(8); + $this->skipBits(8); + $profile = $this->getBits(8); // read profile + if ($profile > 0) { + $this->skipBits(8); + $level_idc = $this->getBits(8); // level_idc + $this->expGolombUe(); // seq_parameter_set_id // sps + $this->expGolombUe(); // log2_max_frame_num_minus4 + $picOrderType = $this->expGolombUe(); // pic_order_cnt_type + if ($picOrderType == 0) { + $this->expGolombUe(); // log2_max_pic_order_cnt_lsb_minus4 + } elseif ($picOrderType == 1) { + $this->skipBits(1); // delta_pic_order_always_zero_flag + $this->expGolombSe(); // offset_for_non_ref_pic + $this->expGolombSe(); // offset_for_top_to_bottom_field + $num_ref_frames_in_pic_order_cnt_cycle = $this->expGolombUe(); // num_ref_frames_in_pic_order_cnt_cycle + for ($i = 0; $i < $num_ref_frames_in_pic_order_cnt_cycle; $i++) { + $this->expGolombSe(); // offset_for_ref_frame[ i ] + } + } + $this->expGolombUe(); // num_ref_frames + $this->skipBits(1); // gaps_in_frame_num_value_allowed_flag + $pic_width_in_mbs_minus1 = $this->expGolombUe(); // pic_width_in_mbs_minus1 + $pic_height_in_map_units_minus1 = $this->expGolombUe(); // pic_height_in_map_units_minus1 + + $frame_mbs_only_flag = $this->getBits(1); // frame_mbs_only_flag + if ($frame_mbs_only_flag == 0) { + $this->skipBits(1); // mb_adaptive_frame_field_flag + } + $this->skipBits(1); // direct_8x8_inference_flag + $frame_cropping_flag = $this->getBits(1); // frame_cropping_flag + + $frame_crop_left_offset = 0; + $frame_crop_right_offset = 0; + $frame_crop_top_offset = 0; + $frame_crop_bottom_offset = 0; + + if ($frame_cropping_flag) { + $frame_crop_left_offset = $this->expGolombUe(); // frame_crop_left_offset + $frame_crop_right_offset = $this->expGolombUe(); // frame_crop_right_offset + $frame_crop_top_offset = $this->expGolombUe(); // frame_crop_top_offset + $frame_crop_bottom_offset = $this->expGolombUe(); // frame_crop_bottom_offset + } + $this->skipBits(1); // vui_parameters_present_flag + // etc + + $this->width = (($pic_width_in_mbs_minus1 + 1) * 16) - ($frame_crop_left_offset * 2) - ($frame_crop_right_offset * 2); + $this->height = ((2 - $frame_mbs_only_flag) * ($pic_height_in_map_units_minus1 + 1) * 16) - ($frame_crop_top_offset * 2) - ($frame_crop_bottom_offset * 2); + } + } + + public function skipBits($bits) { + $newBits = $this->currentBits + $bits; + $this->currentBytes += (int)floor($newBits / 8); + $this->currentBits = $newBits % 8; + } + + public function getBit() { + $result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01; + $this->skipBits(1); + return $result; + } + + public function getBits($bits) { + $result = 0; + for ($i = 0; $i < $bits; $i++) { + $result = ($result << 1) + $this->getBit(); + } + return $result; + } + + public function expGolombUe() { + $significantBits = 0; + $bit = $this->getBit(); + while ($bit == 0) { + $significantBits++; + $bit = $this->getBit(); + + if ($significantBits > 31) { + // something is broken, this is an emergency escape to prevent infinite loops + return 0; + } + } + return (1 << $significantBits) + $this->getBits($significantBits) - 1; + } + + public function expGolombSe() { + $result = $this->expGolombUe(); + if (($result & 0x01) == 0) { + return -($result >> 1); + } else { + return ($result + 1) >> 1; + } + } + + public function getWidth() { + return $this->width; + } + + public function getHeight() { + return $this->height; + } +} diff --git a/backend/wp-includes/ID3/module.audio-video.matroska.php b/backend/wp-includes/ID3/module.audio-video.matroska.php new file mode 100644 index 0000000..825a22e --- /dev/null +++ b/backend/wp-includes/ID3/module.audio-video.matroska.php @@ -0,0 +1,1790 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio-video.matriska.php // +// module for analyzing Matroska containers // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + + +define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation. +define('EBML_ID_SEEKHEAD', 0x014D9B74); // [11][4D][9B][74] -- Contains the position of other level 1 elements. +define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found . +define('EBML_ID_INFO', 0x0549A966); // [15][49][A9][66] -- Contains miscellaneous general information and statistics on the file. +define('EBML_ID_TRACKS', 0x0654AE6B); // [16][54][AE][6B] -- A top-level block of information with many tracks described. +define('EBML_ID_SEGMENT', 0x08538067); // [18][53][80][67] -- This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment. +define('EBML_ID_ATTACHMENTS', 0x0941A469); // [19][41][A4][69] -- Contain attached files. +define('EBML_ID_EBML', 0x0A45DFA3); // [1A][45][DF][A3] -- Set the EBML characteristics of the data to follow. Each EBML document has to start with this. +define('EBML_ID_CUES', 0x0C53BB6B); // [1C][53][BB][6B] -- A top-level element to speed seeking access. All entries are local to the segment. +define('EBML_ID_CLUSTER', 0x0F43B675); // [1F][43][B6][75] -- The lower level element containing the (monolithic) Block structure. +define('EBML_ID_LANGUAGE', 0x02B59C); // [22][B5][9C] -- Specifies the language of the track in the Matroska languages form. +define('EBML_ID_TRACKTIMECODESCALE', 0x03314F); // [23][31][4F] -- The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs). +define('EBML_ID_DEFAULTDURATION', 0x03E383); // [23][E3][83] -- Number of nanoseconds (i.e. not scaled) per frame. +define('EBML_ID_CODECNAME', 0x058688); // [25][86][88] -- A human-readable string specifying the codec. +define('EBML_ID_CODECDOWNLOADURL', 0x06B240); // [26][B2][40] -- A URL to download about the codec used. +define('EBML_ID_TIMECODESCALE', 0x0AD7B1); // [2A][D7][B1] -- Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds). +define('EBML_ID_COLOURSPACE', 0x0EB524); // [2E][B5][24] -- Same value as in AVI (32 bits). +define('EBML_ID_GAMMAVALUE', 0x0FB523); // [2F][B5][23] -- Gamma Value. +define('EBML_ID_CODECSETTINGS', 0x1A9697); // [3A][96][97] -- A string describing the encoding setting used. +define('EBML_ID_CODECINFOURL', 0x1B4040); // [3B][40][40] -- A URL to find information about the codec used. +define('EBML_ID_PREVFILENAME', 0x1C83AB); // [3C][83][AB] -- An escaped filename corresponding to the previous segment. +define('EBML_ID_PREVUID', 0x1CB923); // [3C][B9][23] -- A unique ID to identify the previous chained segment (128 bits). +define('EBML_ID_NEXTFILENAME', 0x1E83BB); // [3E][83][BB] -- An escaped filename corresponding to the next segment. +define('EBML_ID_NEXTUID', 0x1EB923); // [3E][B9][23] -- A unique ID to identify the next chained segment (128 bits). +define('EBML_ID_CONTENTCOMPALGO', 0x0254); // [42][54] -- The compression algorithm used. Algorithms that have been specified so far are: +define('EBML_ID_CONTENTCOMPSETTINGS', 0x0255); // [42][55] -- Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track. +define('EBML_ID_DOCTYPE', 0x0282); // [42][82] -- A string that describes the type of document that follows this EBML header ('matroska' in our case). +define('EBML_ID_DOCTYPEREADVERSION', 0x0285); // [42][85] -- The minimum DocType version an interpreter has to support to read this file. +define('EBML_ID_EBMLVERSION', 0x0286); // [42][86] -- The version of EBML parser used to create the file. +define('EBML_ID_DOCTYPEVERSION', 0x0287); // [42][87] -- The version of DocType interpreter used to create the file. +define('EBML_ID_EBMLMAXIDLENGTH', 0x02F2); // [42][F2] -- The maximum length of the IDs you'll find in this file (4 or less in Matroska). +define('EBML_ID_EBMLMAXSIZELENGTH', 0x02F3); // [42][F3] -- The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid. +define('EBML_ID_EBMLREADVERSION', 0x02F7); // [42][F7] -- The minimum EBML version a parser has to support to read this file. +define('EBML_ID_CHAPLANGUAGE', 0x037C); // [43][7C] -- The languages corresponding to the string, in the bibliographic ISO-639-2 form. +define('EBML_ID_CHAPCOUNTRY', 0x037E); // [43][7E] -- The countries corresponding to the string, same 2 octets as in Internet domains. +define('EBML_ID_SEGMENTFAMILY', 0x0444); // [44][44] -- A randomly generated unique ID that all segments related to each other must use (128 bits). +define('EBML_ID_DATEUTC', 0x0461); // [44][61] -- Date of the origin of timecode (value 0), i.e. production date. +define('EBML_ID_TAGLANGUAGE', 0x047A); // [44][7A] -- Specifies the language of the tag specified, in the Matroska languages form. +define('EBML_ID_TAGDEFAULT', 0x0484); // [44][84] -- Indication to know if this is the default/original language to use for the given tag. +define('EBML_ID_TAGBINARY', 0x0485); // [44][85] -- The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString. +define('EBML_ID_TAGSTRING', 0x0487); // [44][87] -- The value of the Tag. +define('EBML_ID_DURATION', 0x0489); // [44][89] -- Duration of the segment (based on TimecodeScale). +define('EBML_ID_CHAPPROCESSPRIVATE', 0x050D); // [45][0D] -- Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent. +define('EBML_ID_CHAPTERFLAGENABLED', 0x0598); // [45][98] -- Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter. +define('EBML_ID_TAGNAME', 0x05A3); // [45][A3] -- The name of the Tag that is going to be stored. +define('EBML_ID_EDITIONENTRY', 0x05B9); // [45][B9] -- Contains all information about a segment edition. +define('EBML_ID_EDITIONUID', 0x05BC); // [45][BC] -- A unique ID to identify the edition. It's useful for tagging an edition. +define('EBML_ID_EDITIONFLAGHIDDEN', 0x05BD); // [45][BD] -- If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks). +define('EBML_ID_EDITIONFLAGDEFAULT', 0x05DB); // [45][DB] -- If a flag is set (1) the edition should be used as the default one. +define('EBML_ID_EDITIONFLAGORDERED', 0x05DD); // [45][DD] -- Specify if the chapters can be defined multiple times and the order to play them is enforced. +define('EBML_ID_FILEDATA', 0x065C); // [46][5C] -- The data of the file. +define('EBML_ID_FILEMIMETYPE', 0x0660); // [46][60] -- MIME type of the file. +define('EBML_ID_FILENAME', 0x066E); // [46][6E] -- Filename of the attached file. +define('EBML_ID_FILEREFERRAL', 0x0675); // [46][75] -- A binary value that a track/codec can refer to when the attachment is needed. +define('EBML_ID_FILEDESCRIPTION', 0x067E); // [46][7E] -- A human-friendly name for the attached file. +define('EBML_ID_FILEUID', 0x06AE); // [46][AE] -- Unique ID representing the file, as random as possible. +define('EBML_ID_CONTENTENCALGO', 0x07E1); // [47][E1] -- The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values: +define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the the data was encrypted with. +define('EBML_ID_CONTENTSIGNATURE', 0x07E3); // [47][E3] -- A cryptographic signature of the contents. +define('EBML_ID_CONTENTSIGKEYID', 0x07E4); // [47][E4] -- This is the ID of the private key the data was signed with. +define('EBML_ID_CONTENTSIGALGO', 0x07E5); // [47][E5] -- The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: +define('EBML_ID_CONTENTSIGHASHALGO', 0x07E6); // [47][E6] -- The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values: +define('EBML_ID_MUXINGAPP', 0x0D80); // [4D][80] -- Muxing application or library ("libmatroska-0.4.3"). +define('EBML_ID_SEEK', 0x0DBB); // [4D][BB] -- Contains a single seek entry to an EBML element. +define('EBML_ID_CONTENTENCODINGORDER', 0x1031); // [50][31] -- Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment. +define('EBML_ID_CONTENTENCODINGSCOPE', 0x1032); // [50][32] -- A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values: +define('EBML_ID_CONTENTENCODINGTYPE', 0x1033); // [50][33] -- A value describing what kind of transformation has been done. Possible values: +define('EBML_ID_CONTENTCOMPRESSION', 0x1034); // [50][34] -- Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking. +define('EBML_ID_CONTENTENCRYPTION', 0x1035); // [50][35] -- Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise. +define('EBML_ID_CUEREFNUMBER', 0x135F); // [53][5F] -- Number of the referenced Block of Track X in the specified Cluster. +define('EBML_ID_NAME', 0x136E); // [53][6E] -- A human-readable track name. +define('EBML_ID_CUEBLOCKNUMBER', 0x1378); // [53][78] -- Number of the Block in the specified Cluster. +define('EBML_ID_TRACKOFFSET', 0x137F); // [53][7F] -- A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track. +define('EBML_ID_SEEKID', 0x13AB); // [53][AB] -- The binary ID corresponding to the element name. +define('EBML_ID_SEEKPOSITION', 0x13AC); // [53][AC] -- The position of the element in the segment in octets (0 = first level 1 element). +define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode. +define('EBML_ID_OLDSTEREOMODE', 0x13B9); // [53][B9] -- Bogus StereoMode value used in old versions of libmatroska. DO NOT USE. (0: mono, 1: right eye, 2: left eye, 3: both eyes). +define('EBML_ID_PIXELCROPBOTTOM', 0x14AA); // [54][AA] -- The number of video pixels to remove at the bottom of the image (for HDTV content). +define('EBML_ID_DISPLAYWIDTH', 0x14B0); // [54][B0] -- Width of the video frames to display. +define('EBML_ID_DISPLAYUNIT', 0x14B2); // [54][B2] -- Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches). +define('EBML_ID_ASPECTRATIOTYPE', 0x14B3); // [54][B3] -- Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed). +define('EBML_ID_DISPLAYHEIGHT', 0x14BA); // [54][BA] -- Height of the video frames to display. +define('EBML_ID_PIXELCROPTOP', 0x14BB); // [54][BB] -- The number of video pixels to remove at the top of the image. +define('EBML_ID_PIXELCROPLEFT', 0x14CC); // [54][CC] -- The number of video pixels to remove on the left of the image. +define('EBML_ID_PIXELCROPRIGHT', 0x14DD); // [54][DD] -- The number of video pixels to remove on the right of the image. +define('EBML_ID_FLAGFORCED', 0x15AA); // [55][AA] -- Set if that track MUST be used during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. +define('EBML_ID_MAXBLOCKADDITIONID', 0x15EE); // [55][EE] -- The maximum value of BlockAddID. A value 0 means there is no BlockAdditions for this track. +define('EBML_ID_WRITINGAPP', 0x1741); // [57][41] -- Writing application ("mkvmerge-0.3.3"). +define('EBML_ID_CLUSTERSILENTTRACKS', 0x1854); // [58][54] -- The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use. +define('EBML_ID_CLUSTERSILENTTRACKNUMBER', 0x18D7); // [58][D7] -- One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster. +define('EBML_ID_ATTACHEDFILE', 0x21A7); // [61][A7] -- An attached file. +define('EBML_ID_CONTENTENCODING', 0x2240); // [62][40] -- Settings for one content encoding like compression or encryption. +define('EBML_ID_BITDEPTH', 0x2264); // [62][64] -- Bits per sample, mostly used for PCM. +define('EBML_ID_CODECPRIVATE', 0x23A2); // [63][A2] -- Private data only known to the codec. +define('EBML_ID_TARGETS', 0x23C0); // [63][C0] -- Contain all UIDs where the specified meta data apply. It is void to describe everything in the segment. +define('EBML_ID_CHAPTERPHYSICALEQUIV', 0x23C3); // [63][C3] -- Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values. +define('EBML_ID_TAGCHAPTERUID', 0x23C4); // [63][C4] -- A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment. +define('EBML_ID_TAGTRACKUID', 0x23C5); // [63][C5] -- A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment. +define('EBML_ID_TAGATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment. +define('EBML_ID_TAGEDITIONUID', 0x23C9); // [63][C9] -- A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment. +define('EBML_ID_TARGETTYPE', 0x23CA); // [63][CA] -- An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType). +define('EBML_ID_TRACKTRANSLATE', 0x2624); // [66][24] -- The track identification for the given Chapter Codec. +define('EBML_ID_TRACKTRANSLATETRACKID', 0x26A5); // [66][A5] -- The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used. +define('EBML_ID_TRACKTRANSLATECODEC', 0x26BF); // [66][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu). +define('EBML_ID_TRACKTRANSLATEEDITIONUID', 0x26FC); // [66][FC] -- Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment. +define('EBML_ID_SIMPLETAG', 0x27C8); // [67][C8] -- Contains general information about the target. +define('EBML_ID_TARGETTYPEVALUE', 0x28CA); // [68][CA] -- A number to indicate the logical level of the target (see TargetType). +define('EBML_ID_CHAPPROCESSCOMMAND', 0x2911); // [69][11] -- Contains all the commands associated to the Atom. +define('EBML_ID_CHAPPROCESSTIME', 0x2922); // [69][22] -- Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter). +define('EBML_ID_CHAPTERTRANSLATE', 0x2924); // [69][24] -- A tuple of corresponding ID used by chapter codecs to represent this segment. +define('EBML_ID_CHAPPROCESSDATA', 0x2933); // [69][33] -- Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands. +define('EBML_ID_CHAPPROCESS', 0x2944); // [69][44] -- Contains all the commands associated to the Atom. +define('EBML_ID_CHAPPROCESSCODECID', 0x2955); // [69][55] -- Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later. +define('EBML_ID_CHAPTERTRANSLATEID', 0x29A5); // [69][A5] -- The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used. +define('EBML_ID_CHAPTERTRANSLATECODEC', 0x29BF); // [69][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu). +define('EBML_ID_CHAPTERTRANSLATEEDITIONUID', 0x29FC); // [69][FC] -- Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment. +define('EBML_ID_CONTENTENCODINGS', 0x2D80); // [6D][80] -- Settings for several content encoding mechanisms like compression or encryption. +define('EBML_ID_MINCACHE', 0x2DE7); // [6D][E7] -- The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used. +define('EBML_ID_MAXCACHE', 0x2DF8); // [6D][F8] -- The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed. +define('EBML_ID_CHAPTERSEGMENTUID', 0x2E67); // [6E][67] -- A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used. +define('EBML_ID_CHAPTERSEGMENTEDITIONUID', 0x2EBC); // [6E][BC] -- The edition to play from the segment linked in ChapterSegmentUID. +define('EBML_ID_TRACKOVERLAY', 0x2FAB); // [6F][AB] -- Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc. +define('EBML_ID_TAG', 0x3373); // [73][73] -- Element containing elements specific to Tracks/Chapters. +define('EBML_ID_SEGMENTFILENAME', 0x3384); // [73][84] -- A filename corresponding to this segment. +define('EBML_ID_SEGMENTUID', 0x33A4); // [73][A4] -- A randomly generated unique ID to identify the current segment between many others (128 bits). +define('EBML_ID_CHAPTERUID', 0x33C4); // [73][C4] -- A unique ID to identify the Chapter. +define('EBML_ID_TRACKUID', 0x33C5); // [73][C5] -- A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file. +define('EBML_ID_ATTACHMENTLINK', 0x3446); // [74][46] -- The UID of an attachment that is used by this codec. +define('EBML_ID_CLUSTERBLOCKADDITIONS', 0x35A1); // [75][A1] -- Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data. +define('EBML_ID_CHANNELPOSITIONS', 0x347B); // [7D][7B] -- Table of horizontal angles for each successive channel, see appendix. +define('EBML_ID_OUTPUTSAMPLINGFREQUENCY', 0x38B5); // [78][B5] -- Real output sampling frequency in Hz (used for SBR techniques). +define('EBML_ID_TITLE', 0x3BA9); // [7B][A9] -- General name of the segment. +define('EBML_ID_CHAPTERDISPLAY', 0x00); // [80] -- Contains all possible strings to use for the chapter display. +define('EBML_ID_TRACKTYPE', 0x03); // [83] -- A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control). +define('EBML_ID_CHAPSTRING', 0x05); // [85] -- Contains the string to use as the chapter atom. +define('EBML_ID_CODECID', 0x06); // [86] -- An ID corresponding to the codec, see the codec page for more info. +define('EBML_ID_FLAGDEFAULT', 0x08); // [88] -- Set if that track (audio, video or subs) SHOULD be used if no language found matches the user preference. +define('EBML_ID_CHAPTERTRACKNUMBER', 0x09); // [89] -- UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks. +define('EBML_ID_CLUSTERSLICES', 0x0E); // [8E] -- Contains slices description. +define('EBML_ID_CHAPTERTRACK', 0x0F); // [8F] -- List of tracks on which the chapter applies. If this element is not present, all tracks apply +define('EBML_ID_CHAPTERTIMESTART', 0x11); // [91] -- Timecode of the start of Chapter (not scaled). +define('EBML_ID_CHAPTERTIMEEND', 0x12); // [92] -- Timecode of the end of Chapter (timecode excluded, not scaled). +define('EBML_ID_CUEREFTIME', 0x16); // [96] -- Timecode of the referenced Block. +define('EBML_ID_CUEREFCLUSTER', 0x17); // [97] -- Position of the Cluster containing the referenced Block. +define('EBML_ID_CHAPTERFLAGHIDDEN', 0x18); // [98] -- If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks). +define('EBML_ID_FLAGINTERLACED', 0x1A); // [9A] -- Set if the video is interlaced. +define('EBML_ID_CLUSTERBLOCKDURATION', 0x1B); // [9B] -- The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track. When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. +define('EBML_ID_FLAGLACING', 0x1C); // [9C] -- Set if the track may contain blocks using lacing. +define('EBML_ID_CHANNELS', 0x1F); // [9F] -- Numbers of channels in the track. +define('EBML_ID_CLUSTERBLOCKGROUP', 0x20); // [A0] -- Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock. +define('EBML_ID_CLUSTERBLOCK', 0x21); // [A1] -- Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode. +define('EBML_ID_CLUSTERBLOCKVIRTUAL', 0x22); // [A2] -- A Block with no data. It must be stored in the stream at the place the real Block should be in display order. +define('EBML_ID_CLUSTERSIMPLEBLOCK', 0x23); // [A3] -- Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed. +define('EBML_ID_CLUSTERCODECSTATE', 0x24); // [A4] -- The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry. +define('EBML_ID_CLUSTERBLOCKADDITIONAL', 0x25); // [A5] -- Interpreted by the codec as it wishes (using the BlockAddID). +define('EBML_ID_CLUSTERBLOCKMORE', 0x26); // [A6] -- Contain the BlockAdditional and some parameters. +define('EBML_ID_CLUSTERPOSITION', 0x27); // [A7] -- Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams. +define('EBML_ID_CODECDECODEALL', 0x2A); // [AA] -- The codec can decode potentially damaged data. +define('EBML_ID_CLUSTERPREVSIZE', 0x2B); // [AB] -- Size of the previous Cluster, in octets. Can be useful for backward playing. +define('EBML_ID_TRACKENTRY', 0x2E); // [AE] -- Describes a track with all elements. +define('EBML_ID_CLUSTERENCRYPTEDBLOCK', 0x2F); // [AF] -- Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed). +define('EBML_ID_PIXELWIDTH', 0x30); // [B0] -- Width of the encoded video frames in pixels. +define('EBML_ID_CUETIME', 0x33); // [B3] -- Absolute timecode according to the segment time base. +define('EBML_ID_SAMPLINGFREQUENCY', 0x35); // [B5] -- Sampling frequency in Hz. +define('EBML_ID_CHAPTERATOM', 0x36); // [B6] -- Contains the atom information to use as the chapter atom (apply to all tracks). +define('EBML_ID_CUETRACKPOSITIONS', 0x37); // [B7] -- Contain positions for different tracks corresponding to the timecode. +define('EBML_ID_FLAGENABLED', 0x39); // [B9] -- Set if the track is used. +define('EBML_ID_PIXELHEIGHT', 0x3A); // [BA] -- Height of the encoded video frames in pixels. +define('EBML_ID_CUEPOINT', 0x3B); // [BB] -- Contains all information relative to a seek point in the segment. +define('EBML_ID_CRC32', 0x3F); // [BF] -- The CRC is computed on all the data of the Master element it's in, regardless of its position. It's recommended to put the CRC value at the beggining of the Master element for easier reading. All level 1 elements should include a CRC-32. +define('EBML_ID_CLUSTERBLOCKADDITIONID', 0x4B); // [CB] -- The ID of the BlockAdditional element (0 is the main Block). +define('EBML_ID_CLUSTERLACENUMBER', 0x4C); // [CC] -- The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback. +define('EBML_ID_CLUSTERFRAMENUMBER', 0x4D); // [CD] -- The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame). +define('EBML_ID_CLUSTERDELAY', 0x4E); // [CE] -- The (scaled) delay to apply to the element. +define('EBML_ID_CLUSTERDURATION', 0x4F); // [CF] -- The (scaled) duration to apply to the element. +define('EBML_ID_TRACKNUMBER', 0x57); // [D7] -- The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number). +define('EBML_ID_CUEREFERENCE', 0x5B); // [DB] -- The Clusters containing the required referenced Blocks. +define('EBML_ID_VIDEO', 0x60); // [E0] -- Video settings. +define('EBML_ID_AUDIO', 0x61); // [E1] -- Audio settings. +define('EBML_ID_CLUSTERTIMESLICE', 0x68); // [E8] -- Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback. +define('EBML_ID_CUECODECSTATE', 0x6A); // [EA] -- The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry. +define('EBML_ID_CUEREFCODECSTATE', 0x6B); // [EB] -- The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry. +define('EBML_ID_VOID', 0x6C); // [EC] -- Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use. +define('EBML_ID_CLUSTERTIMECODE', 0x67); // [E7] -- Absolute timecode of the cluster (based on TimecodeScale). +define('EBML_ID_CLUSTERBLOCKADDID', 0x6E); // [EE] -- An ID to identify the BlockAdditional level. +define('EBML_ID_CUECLUSTERPOSITION', 0x71); // [F1] -- The position of the Cluster containing the required Block. +define('EBML_ID_CUETRACK', 0x77); // [F7] -- The track for which a position is given. +define('EBML_ID_CLUSTERREFERENCEPRIORITY', 0x7A); // [FA] -- This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced. +define('EBML_ID_CLUSTERREFERENCEBLOCK', 0x7B); // [FB] -- Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to. +define('EBML_ID_CLUSTERREFERENCEVIRTUAL', 0x7D); // [FD] -- Relative position of the data that should be in position of the virtual block. + + +/** +* @tutorial http://www.matroska.org/technical/specs/index.html +* +* @todo Rewrite EBML parser to reduce it's size and honor default element values +* @todo After rewrite implement stream size calculation, that will provide additional useful info and enable AAC/FLAC audio bitrate detection +*/ +class getid3_matroska extends getid3_handler +{ + // public options + public static $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful [default: TRUE] + public static $parse_whole_file = false; // true to parse the whole file, not only header [default: FALSE] + + // private parser settings/placeholders + private $EBMLbuffer = ''; + private $EBMLbuffer_offset = 0; + private $EBMLbuffer_length = 0; + private $current_offset = 0; + private $unuseful_elements = array(EBML_ID_CRC32, EBML_ID_VOID); + + public function Analyze() + { + $info = &$this->getid3->info; + + // parse container + try { + $this->parseEBML($info); + } catch (Exception $e) { + $this->error('EBML parser: '.$e->getMessage()); + } + + // calculate playtime + if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) { + foreach ($info['matroska']['info'] as $key => $infoarray) { + if (isset($infoarray['Duration'])) { + // TimecodeScale is how many nanoseconds each Duration unit is + $info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000); + break; + } + } + } + + // extract tags + if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) { + foreach ($info['matroska']['tags'] as $key => $infoarray) { + $this->ExtractCommentsSimpleTag($infoarray); + } + } + + // process tracks + if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) { + foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) { + + $track_info = array(); + $track_info['dataformat'] = self::CodecIDtoCommonName($trackarray['CodecID']); + $track_info['default'] = (isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true); + if (isset($trackarray['Name'])) { $track_info['name'] = $trackarray['Name']; } + + switch ($trackarray['TrackType']) { + + case 1: // Video + $track_info['resolution_x'] = $trackarray['PixelWidth']; + $track_info['resolution_y'] = $trackarray['PixelHeight']; + $track_info['display_unit'] = self::displayUnit(isset($trackarray['DisplayUnit']) ? $trackarray['DisplayUnit'] : 0); + $track_info['display_x'] = (isset($trackarray['DisplayWidth']) ? $trackarray['DisplayWidth'] : $trackarray['PixelWidth']); + $track_info['display_y'] = (isset($trackarray['DisplayHeight']) ? $trackarray['DisplayHeight'] : $trackarray['PixelHeight']); + + if (isset($trackarray['PixelCropBottom'])) { $track_info['crop_bottom'] = $trackarray['PixelCropBottom']; } + if (isset($trackarray['PixelCropTop'])) { $track_info['crop_top'] = $trackarray['PixelCropTop']; } + if (isset($trackarray['PixelCropLeft'])) { $track_info['crop_left'] = $trackarray['PixelCropLeft']; } + if (isset($trackarray['PixelCropRight'])) { $track_info['crop_right'] = $trackarray['PixelCropRight']; } + if (isset($trackarray['DefaultDuration'])) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); } + if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; } + + switch ($trackarray['CodecID']) { + case 'V_MS/VFW/FOURCC': + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); + + $parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']); + $track_info['codec'] = getid3_riff::fourccLookup($parsed['fourcc']); + $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed; + break; + + /*case 'V_MPEG4/ISO/AVC': + $h264['profile'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 1, 1)); + $h264['level'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 3, 1)); + $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 4, 1)); + $h264['NALUlength'] = ($rn & 3) + 1; + $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 5, 1)); + $nsps = ($rn & 31); + $offset = 6; + for ($i = 0; $i < $nsps; $i ++) { + $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2)); + $h264['SPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length); + $offset += 2 + $length; + } + $npps = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 1)); + $offset += 1; + for ($i = 0; $i < $npps; $i ++) { + $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2)); + $h264['PPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length); + $offset += 2 + $length; + } + $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $h264; + break;*/ + } + + $info['video']['streams'][] = $track_info; + break; + + case 2: // Audio + $track_info['sample_rate'] = (isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0); + $track_info['channels'] = (isset($trackarray['Channels']) ? $trackarray['Channels'] : 1); + $track_info['language'] = (isset($trackarray['Language']) ? $trackarray['Language'] : 'eng'); + if (isset($trackarray['BitDepth'])) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; } + if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; } + + switch ($trackarray['CodecID']) { + case 'A_PCM/INT/LIT': + case 'A_PCM/INT/BIG': + $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth']; + break; + + case 'A_AC3': + case 'A_EAC3': + case 'A_DTS': + case 'A_MPEG/L3': + case 'A_MPEG/L2': + case 'A_FLAC': + $module_dataformat = ($track_info['dataformat'] == 'mp2' ? 'mp3' : ($track_info['dataformat'] == 'eac3' ? 'ac3' : $track_info['dataformat'])); + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.$module_dataformat.'.php', __FILE__, true); + + if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) { + $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set'); + break; + } + + // create temp instance + $getid3_temp = new getID3(); + if ($track_info['dataformat'] != 'flac') { + $getid3_temp->openfile($this->getid3->filename); + } + $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset']; + if ($track_info['dataformat'][0] == 'm' || $track_info['dataformat'] == 'flac') { + $getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length']; + } + + // analyze + $class = 'getid3_'.$module_dataformat; + $header_data_key = $track_info['dataformat'][0] == 'm' ? 'mpeg' : $track_info['dataformat']; + $getid3_audio = new $class($getid3_temp, __CLASS__); + if ($track_info['dataformat'] == 'flac') { + $getid3_audio->AnalyzeString($trackarray['CodecPrivate']); + } + else { + $getid3_audio->Analyze(); + } + if (!empty($getid3_temp->info[$header_data_key])) { + $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info[$header_data_key]; + if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) { + foreach ($getid3_temp->info['audio'] as $key => $value) { + $track_info[$key] = $value; + } + } + } + else { + $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because '.$class.'::Analyze() failed at offset '.$getid3_temp->info['avdataoffset']); + } + + // copy errors and warnings + if (!empty($getid3_temp->info['error'])) { + foreach ($getid3_temp->info['error'] as $newerror) { + $this->warning($class.'() says: ['.$newerror.']'); + } + } + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $newerror) { + $this->warning($class.'() says: ['.$newerror.']'); + } + } + unset($getid3_temp, $getid3_audio); + break; + + case 'A_AAC': + case 'A_AAC/MPEG2/LC': + case 'A_AAC/MPEG2/LC/SBR': + case 'A_AAC/MPEG4/LC': + case 'A_AAC/MPEG4/LC/SBR': + $this->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated'); + break; + + case 'A_VORBIS': + if (!isset($trackarray['CodecPrivate'])) { + $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data not set'); + break; + } + $vorbis_offset = strpos($trackarray['CodecPrivate'], 'vorbis', 1); + if ($vorbis_offset === false) { + $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data does not contain "vorbis" keyword'); + break; + } + $vorbis_offset -= 1; + + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true); + + // create temp instance + $getid3_temp = new getID3(); + + // analyze + $getid3_ogg = new getid3_ogg($getid3_temp); + $oggpageinfo['page_seqno'] = 0; + $getid3_ogg->ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $oggpageinfo); + if (!empty($getid3_temp->info['ogg'])) { + $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg']; + if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) { + foreach ($getid3_temp->info['audio'] as $key => $value) { + $track_info[$key] = $value; + } + } + } + + // copy errors and warnings + if (!empty($getid3_temp->info['error'])) { + foreach ($getid3_temp->info['error'] as $newerror) { + $this->warning('getid3_ogg() says: ['.$newerror.']'); + } + } + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $newerror) { + $this->warning('getid3_ogg() says: ['.$newerror.']'); + } + } + + if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) { + $track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal']; + } + unset($getid3_temp, $getid3_ogg, $oggpageinfo, $vorbis_offset); + break; + + case 'A_MS/ACM': + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); + + $parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']); + foreach ($parsed as $key => $value) { + if ($key != 'raw') { + $track_info[$key] = $value; + } + } + $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed; + break; + + default: + $this->warning('Unhandled audio type "'.(isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '').'"'); + break; + } + + $info['audio']['streams'][] = $track_info; + break; + } + } + + if (!empty($info['video']['streams'])) { + $info['video'] = self::getDefaultStreamInfo($info['video']['streams']); + } + if (!empty($info['audio']['streams'])) { + $info['audio'] = self::getDefaultStreamInfo($info['audio']['streams']); + } + } + + // process attachments + if (isset($info['matroska']['attachments']) && $this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE) { + foreach ($info['matroska']['attachments'] as $i => $entry) { + if (strpos($entry['FileMimeType'], 'image/') === 0 && !empty($entry['FileData'])) { + $info['matroska']['comments']['picture'][] = array('data' => $entry['FileData'], 'image_mime' => $entry['FileMimeType'], 'filename' => $entry['FileName']); + } + } + } + + // determine mime type + if (!empty($info['video']['streams'])) { + $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska'); + } elseif (!empty($info['audio']['streams'])) { + $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'audio/webm' : 'audio/x-matroska'); + } elseif (isset($info['mime_type'])) { + unset($info['mime_type']); + } + + return true; + } + + private function parseEBML(&$info) { + // http://www.matroska.org/technical/specs/index.html#EBMLBasics + $this->current_offset = $info['avdataoffset']; + + while ($this->getEBMLelement($top_element, $info['avdataend'])) { + switch ($top_element['id']) { + + case EBML_ID_EBML: + $info['matroska']['header']['offset'] = $top_element['offset']; + $info['matroska']['header']['length'] = $top_element['length']; + + while ($this->getEBMLelement($element_data, $top_element['end'], true)) { + switch ($element_data['id']) { + + case EBML_ID_EBMLVERSION: + case EBML_ID_EBMLREADVERSION: + case EBML_ID_EBMLMAXIDLENGTH: + case EBML_ID_EBMLMAXSIZELENGTH: + case EBML_ID_DOCTYPEVERSION: + case EBML_ID_DOCTYPEREADVERSION: + $element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']); + break; + + case EBML_ID_DOCTYPE: + $element_data['data'] = getid3_lib::trimNullByte($element_data['data']); + $info['matroska']['doctype'] = $element_data['data']; + $info['fileformat'] = $element_data['data']; + break; + + default: + $this->unhandledElement('header', __LINE__, $element_data); + break; + } + + unset($element_data['offset'], $element_data['end']); + $info['matroska']['header']['elements'][] = $element_data; + } + break; + + case EBML_ID_SEGMENT: + $info['matroska']['segment'][0]['offset'] = $top_element['offset']; + $info['matroska']['segment'][0]['length'] = $top_element['length']; + + while ($this->getEBMLelement($element_data, $top_element['end'])) { + if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required + $info['matroska']['segments'][] = $element_data; + } + switch ($element_data['id']) { + + case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements. + + while ($this->getEBMLelement($seek_entry, $element_data['end'])) { + switch ($seek_entry['id']) { + + case EBML_ID_SEEK: // Contains a single seek entry to an EBML element + while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) { + + switch ($sub_seek_entry['id']) { + + case EBML_ID_SEEKID: + $seek_entry['target_id'] = self::EBML2Int($sub_seek_entry['data']); + $seek_entry['target_name'] = self::EBMLidName($seek_entry['target_id']); + break; + + case EBML_ID_SEEKPOSITION: + $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($sub_seek_entry['data']); + break; + + default: + $this->unhandledElement('seekhead.seek', __LINE__, $sub_seek_entry); } + break; + } + if (!isset($seek_entry['target_id'])) { + $this->warning('seek_entry[target_id] unexpectedly not set at '.$seek_entry['offset']); + break; + } + if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !self::$hide_clusters) { // collect clusters only if required + $info['matroska']['seek'][] = $seek_entry; + } + break; + + default: + $this->unhandledElement('seekhead', __LINE__, $seek_entry); + break; + } + } + break; + + case EBML_ID_TRACKS: // A top-level block of information with many tracks described. + $info['matroska']['tracks'] = $element_data; + + while ($this->getEBMLelement($track_entry, $element_data['end'])) { + switch ($track_entry['id']) { + + case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements. + + while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS, EBML_ID_CODECPRIVATE))) { + switch ($subelement['id']) { + + case EBML_ID_TRACKNUMBER: + case EBML_ID_TRACKUID: + case EBML_ID_TRACKTYPE: + case EBML_ID_MINCACHE: + case EBML_ID_MAXCACHE: + case EBML_ID_MAXBLOCKADDITIONID: + case EBML_ID_DEFAULTDURATION: // nanoseconds per frame + $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']); + break; + + case EBML_ID_TRACKTIMECODESCALE: + $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']); + break; + + case EBML_ID_CODECID: + case EBML_ID_LANGUAGE: + case EBML_ID_NAME: + case EBML_ID_CODECNAME: + $track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']); + break; + + case EBML_ID_CODECPRIVATE: + $track_entry[$subelement['id_name']] = $this->readEBMLelementData($subelement['length'], true); + break; + + case EBML_ID_FLAGENABLED: + case EBML_ID_FLAGDEFAULT: + case EBML_ID_FLAGFORCED: + case EBML_ID_FLAGLACING: + case EBML_ID_CODECDECODEALL: + $track_entry[$subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($subelement['data']); + break; + + case EBML_ID_VIDEO: + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) { + switch ($sub_subelement['id']) { + + case EBML_ID_PIXELWIDTH: + case EBML_ID_PIXELHEIGHT: + case EBML_ID_PIXELCROPBOTTOM: + case EBML_ID_PIXELCROPTOP: + case EBML_ID_PIXELCROPLEFT: + case EBML_ID_PIXELCROPRIGHT: + case EBML_ID_DISPLAYWIDTH: + case EBML_ID_DISPLAYHEIGHT: + case EBML_ID_DISPLAYUNIT: + case EBML_ID_ASPECTRATIOTYPE: + case EBML_ID_STEREOMODE: + case EBML_ID_OLDSTEREOMODE: + $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_FLAGINTERLACED: + $track_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_GAMMAVALUE: + $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']); + break; + + case EBML_ID_COLOURSPACE: + $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']); + break; + + default: + $this->unhandledElement('track.video', __LINE__, $sub_subelement); + break; + } + } + break; + + case EBML_ID_AUDIO: + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) { + switch ($sub_subelement['id']) { + + case EBML_ID_CHANNELS: + case EBML_ID_BITDEPTH: + $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_SAMPLINGFREQUENCY: + case EBML_ID_OUTPUTSAMPLINGFREQUENCY: + $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']); + break; + + case EBML_ID_CHANNELPOSITIONS: + $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']); + break; + + default: + $this->unhandledElement('track.audio', __LINE__, $sub_subelement); + break; + } + } + break; + + case EBML_ID_CONTENTENCODINGS: + + while ($this->getEBMLelement($sub_subelement, $subelement['end'])) { + switch ($sub_subelement['id']) { + + case EBML_ID_CONTENTENCODING: + + while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CONTENTCOMPRESSION, EBML_ID_CONTENTENCRYPTION))) { + switch ($sub_sub_subelement['id']) { + + case EBML_ID_CONTENTENCODINGORDER: + case EBML_ID_CONTENTENCODINGSCOPE: + case EBML_ID_CONTENTENCODINGTYPE: + $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + break; + + case EBML_ID_CONTENTCOMPRESSION: + + while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) { + switch ($sub_sub_sub_subelement['id']) { + + case EBML_ID_CONTENTCOMPALGO: + $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']); + break; + + case EBML_ID_CONTENTCOMPSETTINGS: + $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data']; + break; + + default: + $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement); + break; + } + } + break; + + case EBML_ID_CONTENTENCRYPTION: + + while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) { + switch ($sub_sub_sub_subelement['id']) { + + case EBML_ID_CONTENTENCALGO: + case EBML_ID_CONTENTSIGALGO: + case EBML_ID_CONTENTSIGHASHALGO: + $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']); + break; + + case EBML_ID_CONTENTENCKEYID: + case EBML_ID_CONTENTSIGNATURE: + case EBML_ID_CONTENTSIGKEYID: + $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data']; + break; + + default: + $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement); + break; + } + } + break; + + default: + $this->unhandledElement('track.contentencodings.contentencoding', __LINE__, $sub_sub_subelement); + break; + } + } + break; + + default: + $this->unhandledElement('track.contentencodings', __LINE__, $sub_subelement); + break; + } + } + break; + + default: + $this->unhandledElement('track', __LINE__, $subelement); + break; + } + } + + $info['matroska']['tracks']['tracks'][] = $track_entry; + break; + + default: + $this->unhandledElement('tracks', __LINE__, $track_entry); + break; + } + } + break; + + case EBML_ID_INFO: // Contains miscellaneous general information and statistics on the file. + $info_entry = array(); + + while ($this->getEBMLelement($subelement, $element_data['end'], true)) { + switch ($subelement['id']) { + + case EBML_ID_TIMECODESCALE: + $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']); + break; + + case EBML_ID_DURATION: + $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']); + break; + + case EBML_ID_DATEUTC: + $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']); + $info_entry[$subelement['id_name'].'_unix'] = self::EBMLdate2unix($info_entry[$subelement['id_name']]); + break; + + case EBML_ID_SEGMENTUID: + case EBML_ID_PREVUID: + case EBML_ID_NEXTUID: + $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']); + break; + + case EBML_ID_SEGMENTFAMILY: + $info_entry[$subelement['id_name']][] = getid3_lib::trimNullByte($subelement['data']); + break; + + case EBML_ID_SEGMENTFILENAME: + case EBML_ID_PREVFILENAME: + case EBML_ID_NEXTFILENAME: + case EBML_ID_TITLE: + case EBML_ID_MUXINGAPP: + case EBML_ID_WRITINGAPP: + $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']); + $info['matroska']['comments'][strtolower($subelement['id_name'])][] = $info_entry[$subelement['id_name']]; + break; + + case EBML_ID_CHAPTERTRANSLATE: + $chaptertranslate_entry = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) { + switch ($sub_subelement['id']) { + + case EBML_ID_CHAPTERTRANSLATEEDITIONUID: + $chaptertranslate_entry[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_CHAPTERTRANSLATECODEC: + $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_CHAPTERTRANSLATEID: + $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']); + break; + + default: + $this->unhandledElement('info.chaptertranslate', __LINE__, $sub_subelement); + break; + } + } + $info_entry[$subelement['id_name']] = $chaptertranslate_entry; + break; + + default: + $this->unhandledElement('info', __LINE__, $subelement); + break; + } + } + $info['matroska']['info'][] = $info_entry; + break; + + case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams. + if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway + $this->current_offset = $element_data['end']; + break; + } + $cues_entry = array(); + + while ($this->getEBMLelement($subelement, $element_data['end'])) { + switch ($subelement['id']) { + + case EBML_ID_CUEPOINT: + $cuepoint_entry = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CUETRACKPOSITIONS))) { + switch ($sub_subelement['id']) { + + case EBML_ID_CUETRACKPOSITIONS: + $cuetrackpositions_entry = array(); + + while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) { + switch ($sub_sub_subelement['id']) { + + case EBML_ID_CUETRACK: + case EBML_ID_CUECLUSTERPOSITION: + case EBML_ID_CUEBLOCKNUMBER: + case EBML_ID_CUECODECSTATE: + $cuetrackpositions_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + break; + + default: + $this->unhandledElement('cues.cuepoint.cuetrackpositions', __LINE__, $sub_sub_subelement); + break; + } + } + $cuepoint_entry[$sub_subelement['id_name']][] = $cuetrackpositions_entry; + break; + + case EBML_ID_CUETIME: + $cuepoint_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + default: + $this->unhandledElement('cues.cuepoint', __LINE__, $sub_subelement); + break; + } + } + $cues_entry[] = $cuepoint_entry; + break; + + default: + $this->unhandledElement('cues', __LINE__, $subelement); + break; + } + } + $info['matroska']['cues'] = $cues_entry; + break; + + case EBML_ID_TAGS: // Element containing elements specific to Tracks/Chapters. + $tags_entry = array(); + + while ($this->getEBMLelement($subelement, $element_data['end'], false)) { + switch ($subelement['id']) { + + case EBML_ID_TAG: + $tag_entry = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], false)) { + switch ($sub_subelement['id']) { + + case EBML_ID_TARGETS: + $targets_entry = array(); + + while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) { + switch ($sub_sub_subelement['id']) { + + case EBML_ID_TARGETTYPEVALUE: + $targets_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + $targets_entry[strtolower($sub_sub_subelement['id_name']).'_long'] = self::TargetTypeValue($targets_entry[$sub_sub_subelement['id_name']]); + break; + + case EBML_ID_TARGETTYPE: + $targets_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data']; + break; + + case EBML_ID_TAGTRACKUID: + case EBML_ID_TAGEDITIONUID: + case EBML_ID_TAGCHAPTERUID: + case EBML_ID_TAGATTACHMENTUID: + $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + break; + + default: + $this->unhandledElement('tags.tag.targets', __LINE__, $sub_sub_subelement); + break; + } + } + $tag_entry[$sub_subelement['id_name']] = $targets_entry; + break; + + case EBML_ID_SIMPLETAG: + $tag_entry[$sub_subelement['id_name']][] = $this->HandleEMBLSimpleTag($sub_subelement['end']); + break; + + default: + $this->unhandledElement('tags.tag', __LINE__, $sub_subelement); + break; + } + } + $tags_entry[] = $tag_entry; + break; + + default: + $this->unhandledElement('tags', __LINE__, $subelement); + break; + } + } + $info['matroska']['tags'] = $tags_entry; + break; + + case EBML_ID_ATTACHMENTS: // Contain attached files. + + while ($this->getEBMLelement($subelement, $element_data['end'])) { + switch ($subelement['id']) { + + case EBML_ID_ATTACHEDFILE: + $attachedfile_entry = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_FILEDATA))) { + switch ($sub_subelement['id']) { + + case EBML_ID_FILEDESCRIPTION: + case EBML_ID_FILENAME: + case EBML_ID_FILEMIMETYPE: + $attachedfile_entry[$sub_subelement['id_name']] = $sub_subelement['data']; + break; + + case EBML_ID_FILEDATA: + $attachedfile_entry['data_offset'] = $this->current_offset; + $attachedfile_entry['data_length'] = $sub_subelement['length']; + + $attachedfile_entry[$sub_subelement['id_name']] = $this->saveAttachment( + $attachedfile_entry['FileName'], + $attachedfile_entry['data_offset'], + $attachedfile_entry['data_length']); + + $this->current_offset = $sub_subelement['end']; + break; + + case EBML_ID_FILEUID: + $attachedfile_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + default: + $this->unhandledElement('attachments.attachedfile', __LINE__, $sub_subelement); + break; + } + } + $info['matroska']['attachments'][] = $attachedfile_entry; + break; + + default: + $this->unhandledElement('attachments', __LINE__, $subelement); + break; + } + } + break; + + case EBML_ID_CHAPTERS: + + while ($this->getEBMLelement($subelement, $element_data['end'])) { + switch ($subelement['id']) { + + case EBML_ID_EDITIONENTRY: + $editionentry_entry = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CHAPTERATOM))) { + switch ($sub_subelement['id']) { + + case EBML_ID_EDITIONUID: + $editionentry_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_EDITIONFLAGHIDDEN: + case EBML_ID_EDITIONFLAGDEFAULT: + case EBML_ID_EDITIONFLAGORDERED: + $editionentry_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_CHAPTERATOM: + $chapteratom_entry = array(); + + while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CHAPTERTRACK, EBML_ID_CHAPTERDISPLAY))) { + switch ($sub_sub_subelement['id']) { + + case EBML_ID_CHAPTERSEGMENTUID: + case EBML_ID_CHAPTERSEGMENTEDITIONUID: + $chapteratom_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data']; + break; + + case EBML_ID_CHAPTERFLAGENABLED: + case EBML_ID_CHAPTERFLAGHIDDEN: + $chapteratom_entry[$sub_sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + break; + + case EBML_ID_CHAPTERUID: + case EBML_ID_CHAPTERTIMESTART: + case EBML_ID_CHAPTERTIMEEND: + $chapteratom_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']); + break; + + case EBML_ID_CHAPTERTRACK: + $chaptertrack_entry = array(); + + while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) { + switch ($sub_sub_sub_subelement['id']) { + + case EBML_ID_CHAPTERTRACKNUMBER: + $chaptertrack_entry[$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']); + break; + + default: + $this->unhandledElement('chapters.editionentry.chapteratom.chaptertrack', __LINE__, $sub_sub_sub_subelement); + break; + } + } + $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chaptertrack_entry; + break; + + case EBML_ID_CHAPTERDISPLAY: + $chapterdisplay_entry = array(); + + while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) { + switch ($sub_sub_sub_subelement['id']) { + + case EBML_ID_CHAPSTRING: + case EBML_ID_CHAPLANGUAGE: + case EBML_ID_CHAPCOUNTRY: + $chapterdisplay_entry[$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data']; + break; + + default: + $this->unhandledElement('chapters.editionentry.chapteratom.chapterdisplay', __LINE__, $sub_sub_sub_subelement); + break; + } + } + $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chapterdisplay_entry; + break; + + default: + $this->unhandledElement('chapters.editionentry.chapteratom', __LINE__, $sub_sub_subelement); + break; + } + } + $editionentry_entry[$sub_subelement['id_name']][] = $chapteratom_entry; + break; + + default: + $this->unhandledElement('chapters.editionentry', __LINE__, $sub_subelement); + break; + } + } + $info['matroska']['chapters'][] = $editionentry_entry; + break; + + default: + $this->unhandledElement('chapters', __LINE__, $subelement); + break; + } + } + break; + + case EBML_ID_CLUSTER: // The lower level element containing the (monolithic) Block structure. + $cluster_entry = array(); + + while ($this->getEBMLelement($subelement, $element_data['end'], array(EBML_ID_CLUSTERSILENTTRACKS, EBML_ID_CLUSTERBLOCKGROUP, EBML_ID_CLUSTERSIMPLEBLOCK))) { + switch ($subelement['id']) { + + case EBML_ID_CLUSTERTIMECODE: + case EBML_ID_CLUSTERPOSITION: + case EBML_ID_CLUSTERPREVSIZE: + $cluster_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']); + break; + + case EBML_ID_CLUSTERSILENTTRACKS: + $cluster_silent_tracks = array(); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) { + switch ($sub_subelement['id']) { + + case EBML_ID_CLUSTERSILENTTRACKNUMBER: + $cluster_silent_tracks[] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + default: + $this->unhandledElement('cluster.silenttracks', __LINE__, $sub_subelement); + break; + } + } + $cluster_entry[$subelement['id_name']][] = $cluster_silent_tracks; + break; + + case EBML_ID_CLUSTERBLOCKGROUP: + $cluster_block_group = array('offset' => $this->current_offset); + + while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CLUSTERBLOCK))) { + switch ($sub_subelement['id']) { + + case EBML_ID_CLUSTERBLOCK: + $cluster_block_group[$sub_subelement['id_name']] = $this->HandleEMBLClusterBlock($sub_subelement, EBML_ID_CLUSTERBLOCK, $info); + break; + + case EBML_ID_CLUSTERREFERENCEPRIORITY: // unsigned-int + case EBML_ID_CLUSTERBLOCKDURATION: // unsigned-int + $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']); + break; + + case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int + $cluster_block_group[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data'], false, true); + break; + + case EBML_ID_CLUSTERCODECSTATE: + $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']); + break; + + default: + $this->unhandledElement('clusters.blockgroup', __LINE__, $sub_subelement); + break; + } + } + $cluster_entry[$subelement['id_name']][] = $cluster_block_group; + break; + + case EBML_ID_CLUSTERSIMPLEBLOCK: + $cluster_entry[$subelement['id_name']][] = $this->HandleEMBLClusterBlock($subelement, EBML_ID_CLUSTERSIMPLEBLOCK, $info); + break; + + default: + $this->unhandledElement('cluster', __LINE__, $subelement); + break; + } + $this->current_offset = $subelement['end']; + } + if (!self::$hide_clusters) { + $info['matroska']['cluster'][] = $cluster_entry; + } + + // check to see if all the data we need exists already, if so, break out of the loop + if (!self::$parse_whole_file) { + if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) { + if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) { + if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) { + return; + } + } + } + } + break; + + default: + $this->unhandledElement('segment', __LINE__, $element_data); + break; + } + } + break; + + default: + $this->unhandledElement('root', __LINE__, $top_element); + break; + } + } + } + + private function EnsureBufferHasEnoughData($min_data=1024) { + if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) { + $read_bytes = max($min_data, $this->getid3->fread_buffer_size()); + + try { + $this->fseek($this->current_offset); + $this->EBMLbuffer_offset = $this->current_offset; + $this->EBMLbuffer = $this->fread($read_bytes); + $this->EBMLbuffer_length = strlen($this->EBMLbuffer); + } catch (getid3_exception $e) { + $this->warning('EBML parser: '.$e->getMessage()); + return false; + } + + if ($this->EBMLbuffer_length == 0 && $this->feof()) { + return $this->error('EBML parser: ran out of file at offset '.$this->current_offset); + } + } + return true; + } + + private function readEBMLint() { + $actual_offset = $this->current_offset - $this->EBMLbuffer_offset; + + // get length of integer + $first_byte_int = ord($this->EBMLbuffer[$actual_offset]); + if (0x80 & $first_byte_int) { + $length = 1; + } elseif (0x40 & $first_byte_int) { + $length = 2; + } elseif (0x20 & $first_byte_int) { + $length = 3; + } elseif (0x10 & $first_byte_int) { + $length = 4; + } elseif (0x08 & $first_byte_int) { + $length = 5; + } elseif (0x04 & $first_byte_int) { + $length = 6; + } elseif (0x02 & $first_byte_int) { + $length = 7; + } elseif (0x01 & $first_byte_int) { + $length = 8; + } else { + throw new Exception('invalid EBML integer (leading 0x00) at '.$this->current_offset); + } + + // read + $int_value = self::EBML2Int(substr($this->EBMLbuffer, $actual_offset, $length)); + $this->current_offset += $length; + + return $int_value; + } + + private function readEBMLelementData($length, $check_buffer=false) { + if ($check_buffer && !$this->EnsureBufferHasEnoughData($length)) { + return false; + } + $data = substr($this->EBMLbuffer, $this->current_offset - $this->EBMLbuffer_offset, $length); + $this->current_offset += $length; + return $data; + } + + private function getEBMLelement(&$element, $parent_end, $get_data=false) { + if ($this->current_offset >= $parent_end) { + return false; + } + + if (!$this->EnsureBufferHasEnoughData()) { + $this->current_offset = PHP_INT_MAX; // do not exit parser right now, allow to finish current loop to gather maximum information + return false; + } + + $element = array(); + + // set offset + $element['offset'] = $this->current_offset; + + // get ID + $element['id'] = $this->readEBMLint(); + + // get name + $element['id_name'] = self::EBMLidName($element['id']); + + // get length + $element['length'] = $this->readEBMLint(); + + // get end offset + $element['end'] = $this->current_offset + $element['length']; + + // get raw data + $dont_parse = (in_array($element['id'], $this->unuseful_elements) || $element['id_name'] == dechex($element['id'])); + if (($get_data === true || (is_array($get_data) && !in_array($element['id'], $get_data))) && !$dont_parse) { + $element['data'] = $this->readEBMLelementData($element['length'], $element); + } + + return true; + } + + private function unhandledElement($type, $line, $element) { + // warn only about unknown and missed elements, not about unuseful + if (!in_array($element['id'], $this->unuseful_elements)) { + $this->warning('Unhandled '.$type.' element ['.basename(__FILE__).':'.$line.'] ('.$element['id'].'::'.$element['id_name'].' ['.$element['length'].' bytes]) at '.$element['offset']); + } + + // increase offset for unparsed elements + if (!isset($element['data'])) { + $this->current_offset = $element['end']; + } + } + + private function ExtractCommentsSimpleTag($SimpleTagArray) { + if (!empty($SimpleTagArray['SimpleTag'])) { + foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) { + if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) { + $this->getid3->info['matroska']['comments'][strtolower($SimpleTagData['TagName'])][] = $SimpleTagData['TagString']; + } + if (!empty($SimpleTagData['SimpleTag'])) { + $this->ExtractCommentsSimpleTag($SimpleTagData); + } + } + } + + return true; + } + + private function HandleEMBLSimpleTag($parent_end) { + $simpletag_entry = array(); + + while ($this->getEBMLelement($element, $parent_end, array(EBML_ID_SIMPLETAG))) { + switch ($element['id']) { + + case EBML_ID_TAGNAME: + case EBML_ID_TAGLANGUAGE: + case EBML_ID_TAGSTRING: + case EBML_ID_TAGBINARY: + $simpletag_entry[$element['id_name']] = $element['data']; + break; + + case EBML_ID_SIMPLETAG: + $simpletag_entry[$element['id_name']][] = $this->HandleEMBLSimpleTag($element['end']); + break; + + case EBML_ID_TAGDEFAULT: + $simpletag_entry[$element['id_name']] = (bool)getid3_lib::BigEndian2Int($element['data']); + break; + + default: + $this->unhandledElement('tag.simpletag', __LINE__, $element); + break; + } + } + + return $simpletag_entry; + } + + private function HandleEMBLClusterBlock($element, $block_type, &$info) { + // http://www.matroska.org/technical/specs/index.html#block_structure + // http://www.matroska.org/technical/specs/index.html#simpleblock_structure + + $block_data = array(); + $block_data['tracknumber'] = $this->readEBMLint(); + $block_data['timecode'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(2), false, true); + $block_data['flags_raw'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)); + + if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) { + $block_data['flags']['keyframe'] = (($block_data['flags_raw'] & 0x80) >> 7); + //$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0x70) >> 4); + } + else { + //$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0xF0) >> 4); + } + $block_data['flags']['invisible'] = (bool)(($block_data['flags_raw'] & 0x08) >> 3); + $block_data['flags']['lacing'] = (($block_data['flags_raw'] & 0x06) >> 1); // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing + if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) { + $block_data['flags']['discardable'] = (($block_data['flags_raw'] & 0x01)); + } + else { + //$block_data['flags']['reserved2'] = (($block_data['flags_raw'] & 0x01) >> 0); + } + $block_data['flags']['lacing_type'] = self::BlockLacingType($block_data['flags']['lacing']); + + // Lace (when lacing bit is set) + if ($block_data['flags']['lacing'] > 0) { + $block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8) + if ($block_data['flags']['lacing'] != 0x02) { + for ($i = 1; $i < $block_data['lace_frames']; $i ++) { // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace). + if ($block_data['flags']['lacing'] == 0x03) { // EBML lacing + $block_data['lace_frames_size'][$i] = $this->readEBMLint(); // TODO: read size correctly, calc size for the last frame. For now offsets are deteminded OK with readEBMLint() and that's the most important thing. + } + else { // Xiph lacing + $block_data['lace_frames_size'][$i] = 0; + do { + $size = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)); + $block_data['lace_frames_size'][$i] += $size; + } + while ($size == 255); + } + } + if ($block_data['flags']['lacing'] == 0x01) { // calc size of the last frame only for Xiph lacing, till EBML sizes are now anyway determined incorrectly + $block_data['lace_frames_size'][] = $element['end'] - $this->current_offset - array_sum($block_data['lace_frames_size']); + } + } + } + + if (!isset($info['matroska']['track_data_offsets'][$block_data['tracknumber']])) { + $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['offset'] = $this->current_offset; + $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset; + //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] = 0; + } + //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] += $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length']; + //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['duration'] = $block_data['timecode'] * ((isset($info['matroska']['info'][0]['TimecodeScale']) ? $info['matroska']['info'][0]['TimecodeScale'] : 1000000) / 1000000000); + + // set offset manually + $this->current_offset = $element['end']; + + return $block_data; + } + + private static function EBML2Int($EBMLstring) { + // http://matroska.org/specs/ + + // Element ID coded with an UTF-8 like system: + // 1xxx xxxx - Class A IDs (2^7 -2 possible values) (base 0x8X) + // 01xx xxxx xxxx xxxx - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX) + // 001x xxxx xxxx xxxx xxxx xxxx - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX) + // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX) + // Values with all x at 0 and 1 are reserved (hence the -2). + + // Data size, in octets, is also coded with an UTF-8 like system : + // 1xxx xxxx - value 0 to 2^7-2 + // 01xx xxxx xxxx xxxx - value 0 to 2^14-2 + // 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2 + // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2 + // 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^35-2 + // 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^42-2 + // 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2 + // 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2 + + $first_byte_int = ord($EBMLstring[0]); + if (0x80 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x7F); + } elseif (0x40 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x3F); + } elseif (0x20 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x1F); + } elseif (0x10 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x0F); + } elseif (0x08 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x07); + } elseif (0x04 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x03); + } elseif (0x02 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x01); + } elseif (0x01 & $first_byte_int) { + $EBMLstring[0] = chr($first_byte_int & 0x00); + } + + return getid3_lib::BigEndian2Int($EBMLstring); + } + + private static function EBMLdate2unix($EBMLdatestamp) { + // Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC) + // 978307200 == mktime(0, 0, 0, 1, 1, 2001) == January 1, 2001 12:00:00am UTC + return round(($EBMLdatestamp / 1000000000) + 978307200); + } + + public static function TargetTypeValue($target_type) { + // http://www.matroska.org/technical/specs/tagging/index.html + static $TargetTypeValue = array(); + if (empty($TargetTypeValue)) { + $TargetTypeValue[10] = 'A: ~ V:shot'; // the lowest hierarchy found in music or movies + $TargetTypeValue[20] = 'A:subtrack/part/movement ~ V:scene'; // corresponds to parts of a track for audio (like a movement) + $TargetTypeValue[30] = 'A:track/song ~ V:chapter'; // the common parts of an album or a movie + $TargetTypeValue[40] = 'A:part/session ~ V:part/session'; // when an album or episode has different logical parts + $TargetTypeValue[50] = 'A:album/opera/concert ~ V:movie/episode/concert'; // the most common grouping level of music and video (equals to an episode for TV series) + $TargetTypeValue[60] = 'A:edition/issue/volume/opus ~ V:season/sequel/volume'; // a list of lower levels grouped together + $TargetTypeValue[70] = 'A:collection ~ V:collection'; // the high hierarchy consisting of many different lower items + } + return (isset($TargetTypeValue[$target_type]) ? $TargetTypeValue[$target_type] : $target_type); + } + + public static function BlockLacingType($lacingtype) { + // http://matroska.org/technical/specs/index.html#block_structure + static $BlockLacingType = array(); + if (empty($BlockLacingType)) { + $BlockLacingType[0x00] = 'no lacing'; + $BlockLacingType[0x01] = 'Xiph lacing'; + $BlockLacingType[0x02] = 'fixed-size lacing'; + $BlockLacingType[0x03] = 'EBML lacing'; + } + return (isset($BlockLacingType[$lacingtype]) ? $BlockLacingType[$lacingtype] : $lacingtype); + } + + public static function CodecIDtoCommonName($codecid) { + // http://www.matroska.org/technical/specs/codecid/index.html + static $CodecIDlist = array(); + if (empty($CodecIDlist)) { + $CodecIDlist['A_AAC'] = 'aac'; + $CodecIDlist['A_AAC/MPEG2/LC'] = 'aac'; + $CodecIDlist['A_AC3'] = 'ac3'; + $CodecIDlist['A_EAC3'] = 'eac3'; + $CodecIDlist['A_DTS'] = 'dts'; + $CodecIDlist['A_FLAC'] = 'flac'; + $CodecIDlist['A_MPEG/L1'] = 'mp1'; + $CodecIDlist['A_MPEG/L2'] = 'mp2'; + $CodecIDlist['A_MPEG/L3'] = 'mp3'; + $CodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian + $CodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian + $CodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music + $CodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2 + $CodecIDlist['A_VORBIS'] = 'vorbis'; + $CodecIDlist['V_MPEG1'] = 'mpeg'; + $CodecIDlist['V_THEORA'] = 'theora'; + $CodecIDlist['V_REAL/RV40'] = 'real'; + $CodecIDlist['V_REAL/RV10'] = 'real'; + $CodecIDlist['V_REAL/RV20'] = 'real'; + $CodecIDlist['V_REAL/RV30'] = 'real'; + $CodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime + $CodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4'; + $CodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4'; + $CodecIDlist['V_MPEG4/ISO/AVC'] = 'h264'; + $CodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4'; + $CodecIDlist['V_VP8'] = 'vp8'; + $CodecIDlist['V_MS/VFW/FOURCC'] = 'vcm'; // Microsoft (TM) Video Codec Manager (VCM) + $CodecIDlist['A_MS/ACM'] = 'acm'; // Microsoft (TM) Audio Codec Manager (ACM) + } + return (isset($CodecIDlist[$codecid]) ? $CodecIDlist[$codecid] : $codecid); + } + + private static function EBMLidName($value) { + static $EBMLidList = array(); + if (empty($EBMLidList)) { + $EBMLidList[EBML_ID_ASPECTRATIOTYPE] = 'AspectRatioType'; + $EBMLidList[EBML_ID_ATTACHEDFILE] = 'AttachedFile'; + $EBMLidList[EBML_ID_ATTACHMENTLINK] = 'AttachmentLink'; + $EBMLidList[EBML_ID_ATTACHMENTS] = 'Attachments'; + $EBMLidList[EBML_ID_AUDIO] = 'Audio'; + $EBMLidList[EBML_ID_BITDEPTH] = 'BitDepth'; + $EBMLidList[EBML_ID_CHANNELPOSITIONS] = 'ChannelPositions'; + $EBMLidList[EBML_ID_CHANNELS] = 'Channels'; + $EBMLidList[EBML_ID_CHAPCOUNTRY] = 'ChapCountry'; + $EBMLidList[EBML_ID_CHAPLANGUAGE] = 'ChapLanguage'; + $EBMLidList[EBML_ID_CHAPPROCESS] = 'ChapProcess'; + $EBMLidList[EBML_ID_CHAPPROCESSCODECID] = 'ChapProcessCodecID'; + $EBMLidList[EBML_ID_CHAPPROCESSCOMMAND] = 'ChapProcessCommand'; + $EBMLidList[EBML_ID_CHAPPROCESSDATA] = 'ChapProcessData'; + $EBMLidList[EBML_ID_CHAPPROCESSPRIVATE] = 'ChapProcessPrivate'; + $EBMLidList[EBML_ID_CHAPPROCESSTIME] = 'ChapProcessTime'; + $EBMLidList[EBML_ID_CHAPSTRING] = 'ChapString'; + $EBMLidList[EBML_ID_CHAPTERATOM] = 'ChapterAtom'; + $EBMLidList[EBML_ID_CHAPTERDISPLAY] = 'ChapterDisplay'; + $EBMLidList[EBML_ID_CHAPTERFLAGENABLED] = 'ChapterFlagEnabled'; + $EBMLidList[EBML_ID_CHAPTERFLAGHIDDEN] = 'ChapterFlagHidden'; + $EBMLidList[EBML_ID_CHAPTERPHYSICALEQUIV] = 'ChapterPhysicalEquiv'; + $EBMLidList[EBML_ID_CHAPTERS] = 'Chapters'; + $EBMLidList[EBML_ID_CHAPTERSEGMENTEDITIONUID] = 'ChapterSegmentEditionUID'; + $EBMLidList[EBML_ID_CHAPTERSEGMENTUID] = 'ChapterSegmentUID'; + $EBMLidList[EBML_ID_CHAPTERTIMEEND] = 'ChapterTimeEnd'; + $EBMLidList[EBML_ID_CHAPTERTIMESTART] = 'ChapterTimeStart'; + $EBMLidList[EBML_ID_CHAPTERTRACK] = 'ChapterTrack'; + $EBMLidList[EBML_ID_CHAPTERTRACKNUMBER] = 'ChapterTrackNumber'; + $EBMLidList[EBML_ID_CHAPTERTRANSLATE] = 'ChapterTranslate'; + $EBMLidList[EBML_ID_CHAPTERTRANSLATECODEC] = 'ChapterTranslateCodec'; + $EBMLidList[EBML_ID_CHAPTERTRANSLATEEDITIONUID] = 'ChapterTranslateEditionUID'; + $EBMLidList[EBML_ID_CHAPTERTRANSLATEID] = 'ChapterTranslateID'; + $EBMLidList[EBML_ID_CHAPTERUID] = 'ChapterUID'; + $EBMLidList[EBML_ID_CLUSTER] = 'Cluster'; + $EBMLidList[EBML_ID_CLUSTERBLOCK] = 'ClusterBlock'; + $EBMLidList[EBML_ID_CLUSTERBLOCKADDID] = 'ClusterBlockAddID'; + $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONAL] = 'ClusterBlockAdditional'; + $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONID] = 'ClusterBlockAdditionID'; + $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONS] = 'ClusterBlockAdditions'; + $EBMLidList[EBML_ID_CLUSTERBLOCKDURATION] = 'ClusterBlockDuration'; + $EBMLidList[EBML_ID_CLUSTERBLOCKGROUP] = 'ClusterBlockGroup'; + $EBMLidList[EBML_ID_CLUSTERBLOCKMORE] = 'ClusterBlockMore'; + $EBMLidList[EBML_ID_CLUSTERBLOCKVIRTUAL] = 'ClusterBlockVirtual'; + $EBMLidList[EBML_ID_CLUSTERCODECSTATE] = 'ClusterCodecState'; + $EBMLidList[EBML_ID_CLUSTERDELAY] = 'ClusterDelay'; + $EBMLidList[EBML_ID_CLUSTERDURATION] = 'ClusterDuration'; + $EBMLidList[EBML_ID_CLUSTERENCRYPTEDBLOCK] = 'ClusterEncryptedBlock'; + $EBMLidList[EBML_ID_CLUSTERFRAMENUMBER] = 'ClusterFrameNumber'; + $EBMLidList[EBML_ID_CLUSTERLACENUMBER] = 'ClusterLaceNumber'; + $EBMLidList[EBML_ID_CLUSTERPOSITION] = 'ClusterPosition'; + $EBMLidList[EBML_ID_CLUSTERPREVSIZE] = 'ClusterPrevSize'; + $EBMLidList[EBML_ID_CLUSTERREFERENCEBLOCK] = 'ClusterReferenceBlock'; + $EBMLidList[EBML_ID_CLUSTERREFERENCEPRIORITY] = 'ClusterReferencePriority'; + $EBMLidList[EBML_ID_CLUSTERREFERENCEVIRTUAL] = 'ClusterReferenceVirtual'; + $EBMLidList[EBML_ID_CLUSTERSILENTTRACKNUMBER] = 'ClusterSilentTrackNumber'; + $EBMLidList[EBML_ID_CLUSTERSILENTTRACKS] = 'ClusterSilentTracks'; + $EBMLidList[EBML_ID_CLUSTERSIMPLEBLOCK] = 'ClusterSimpleBlock'; + $EBMLidList[EBML_ID_CLUSTERTIMECODE] = 'ClusterTimecode'; + $EBMLidList[EBML_ID_CLUSTERTIMESLICE] = 'ClusterTimeSlice'; + $EBMLidList[EBML_ID_CODECDECODEALL] = 'CodecDecodeAll'; + $EBMLidList[EBML_ID_CODECDOWNLOADURL] = 'CodecDownloadURL'; + $EBMLidList[EBML_ID_CODECID] = 'CodecID'; + $EBMLidList[EBML_ID_CODECINFOURL] = 'CodecInfoURL'; + $EBMLidList[EBML_ID_CODECNAME] = 'CodecName'; + $EBMLidList[EBML_ID_CODECPRIVATE] = 'CodecPrivate'; + $EBMLidList[EBML_ID_CODECSETTINGS] = 'CodecSettings'; + $EBMLidList[EBML_ID_COLOURSPACE] = 'ColourSpace'; + $EBMLidList[EBML_ID_CONTENTCOMPALGO] = 'ContentCompAlgo'; + $EBMLidList[EBML_ID_CONTENTCOMPRESSION] = 'ContentCompression'; + $EBMLidList[EBML_ID_CONTENTCOMPSETTINGS] = 'ContentCompSettings'; + $EBMLidList[EBML_ID_CONTENTENCALGO] = 'ContentEncAlgo'; + $EBMLidList[EBML_ID_CONTENTENCKEYID] = 'ContentEncKeyID'; + $EBMLidList[EBML_ID_CONTENTENCODING] = 'ContentEncoding'; + $EBMLidList[EBML_ID_CONTENTENCODINGORDER] = 'ContentEncodingOrder'; + $EBMLidList[EBML_ID_CONTENTENCODINGS] = 'ContentEncodings'; + $EBMLidList[EBML_ID_CONTENTENCODINGSCOPE] = 'ContentEncodingScope'; + $EBMLidList[EBML_ID_CONTENTENCODINGTYPE] = 'ContentEncodingType'; + $EBMLidList[EBML_ID_CONTENTENCRYPTION] = 'ContentEncryption'; + $EBMLidList[EBML_ID_CONTENTSIGALGO] = 'ContentSigAlgo'; + $EBMLidList[EBML_ID_CONTENTSIGHASHALGO] = 'ContentSigHashAlgo'; + $EBMLidList[EBML_ID_CONTENTSIGKEYID] = 'ContentSigKeyID'; + $EBMLidList[EBML_ID_CONTENTSIGNATURE] = 'ContentSignature'; + $EBMLidList[EBML_ID_CRC32] = 'CRC32'; + $EBMLidList[EBML_ID_CUEBLOCKNUMBER] = 'CueBlockNumber'; + $EBMLidList[EBML_ID_CUECLUSTERPOSITION] = 'CueClusterPosition'; + $EBMLidList[EBML_ID_CUECODECSTATE] = 'CueCodecState'; + $EBMLidList[EBML_ID_CUEPOINT] = 'CuePoint'; + $EBMLidList[EBML_ID_CUEREFCLUSTER] = 'CueRefCluster'; + $EBMLidList[EBML_ID_CUEREFCODECSTATE] = 'CueRefCodecState'; + $EBMLidList[EBML_ID_CUEREFERENCE] = 'CueReference'; + $EBMLidList[EBML_ID_CUEREFNUMBER] = 'CueRefNumber'; + $EBMLidList[EBML_ID_CUEREFTIME] = 'CueRefTime'; + $EBMLidList[EBML_ID_CUES] = 'Cues'; + $EBMLidList[EBML_ID_CUETIME] = 'CueTime'; + $EBMLidList[EBML_ID_CUETRACK] = 'CueTrack'; + $EBMLidList[EBML_ID_CUETRACKPOSITIONS] = 'CueTrackPositions'; + $EBMLidList[EBML_ID_DATEUTC] = 'DateUTC'; + $EBMLidList[EBML_ID_DEFAULTDURATION] = 'DefaultDuration'; + $EBMLidList[EBML_ID_DISPLAYHEIGHT] = 'DisplayHeight'; + $EBMLidList[EBML_ID_DISPLAYUNIT] = 'DisplayUnit'; + $EBMLidList[EBML_ID_DISPLAYWIDTH] = 'DisplayWidth'; + $EBMLidList[EBML_ID_DOCTYPE] = 'DocType'; + $EBMLidList[EBML_ID_DOCTYPEREADVERSION] = 'DocTypeReadVersion'; + $EBMLidList[EBML_ID_DOCTYPEVERSION] = 'DocTypeVersion'; + $EBMLidList[EBML_ID_DURATION] = 'Duration'; + $EBMLidList[EBML_ID_EBML] = 'EBML'; + $EBMLidList[EBML_ID_EBMLMAXIDLENGTH] = 'EBMLMaxIDLength'; + $EBMLidList[EBML_ID_EBMLMAXSIZELENGTH] = 'EBMLMaxSizeLength'; + $EBMLidList[EBML_ID_EBMLREADVERSION] = 'EBMLReadVersion'; + $EBMLidList[EBML_ID_EBMLVERSION] = 'EBMLVersion'; + $EBMLidList[EBML_ID_EDITIONENTRY] = 'EditionEntry'; + $EBMLidList[EBML_ID_EDITIONFLAGDEFAULT] = 'EditionFlagDefault'; + $EBMLidList[EBML_ID_EDITIONFLAGHIDDEN] = 'EditionFlagHidden'; + $EBMLidList[EBML_ID_EDITIONFLAGORDERED] = 'EditionFlagOrdered'; + $EBMLidList[EBML_ID_EDITIONUID] = 'EditionUID'; + $EBMLidList[EBML_ID_FILEDATA] = 'FileData'; + $EBMLidList[EBML_ID_FILEDESCRIPTION] = 'FileDescription'; + $EBMLidList[EBML_ID_FILEMIMETYPE] = 'FileMimeType'; + $EBMLidList[EBML_ID_FILENAME] = 'FileName'; + $EBMLidList[EBML_ID_FILEREFERRAL] = 'FileReferral'; + $EBMLidList[EBML_ID_FILEUID] = 'FileUID'; + $EBMLidList[EBML_ID_FLAGDEFAULT] = 'FlagDefault'; + $EBMLidList[EBML_ID_FLAGENABLED] = 'FlagEnabled'; + $EBMLidList[EBML_ID_FLAGFORCED] = 'FlagForced'; + $EBMLidList[EBML_ID_FLAGINTERLACED] = 'FlagInterlaced'; + $EBMLidList[EBML_ID_FLAGLACING] = 'FlagLacing'; + $EBMLidList[EBML_ID_GAMMAVALUE] = 'GammaValue'; + $EBMLidList[EBML_ID_INFO] = 'Info'; + $EBMLidList[EBML_ID_LANGUAGE] = 'Language'; + $EBMLidList[EBML_ID_MAXBLOCKADDITIONID] = 'MaxBlockAdditionID'; + $EBMLidList[EBML_ID_MAXCACHE] = 'MaxCache'; + $EBMLidList[EBML_ID_MINCACHE] = 'MinCache'; + $EBMLidList[EBML_ID_MUXINGAPP] = 'MuxingApp'; + $EBMLidList[EBML_ID_NAME] = 'Name'; + $EBMLidList[EBML_ID_NEXTFILENAME] = 'NextFilename'; + $EBMLidList[EBML_ID_NEXTUID] = 'NextUID'; + $EBMLidList[EBML_ID_OUTPUTSAMPLINGFREQUENCY] = 'OutputSamplingFrequency'; + $EBMLidList[EBML_ID_PIXELCROPBOTTOM] = 'PixelCropBottom'; + $EBMLidList[EBML_ID_PIXELCROPLEFT] = 'PixelCropLeft'; + $EBMLidList[EBML_ID_PIXELCROPRIGHT] = 'PixelCropRight'; + $EBMLidList[EBML_ID_PIXELCROPTOP] = 'PixelCropTop'; + $EBMLidList[EBML_ID_PIXELHEIGHT] = 'PixelHeight'; + $EBMLidList[EBML_ID_PIXELWIDTH] = 'PixelWidth'; + $EBMLidList[EBML_ID_PREVFILENAME] = 'PrevFilename'; + $EBMLidList[EBML_ID_PREVUID] = 'PrevUID'; + $EBMLidList[EBML_ID_SAMPLINGFREQUENCY] = 'SamplingFrequency'; + $EBMLidList[EBML_ID_SEEK] = 'Seek'; + $EBMLidList[EBML_ID_SEEKHEAD] = 'SeekHead'; + $EBMLidList[EBML_ID_SEEKID] = 'SeekID'; + $EBMLidList[EBML_ID_SEEKPOSITION] = 'SeekPosition'; + $EBMLidList[EBML_ID_SEGMENT] = 'Segment'; + $EBMLidList[EBML_ID_SEGMENTFAMILY] = 'SegmentFamily'; + $EBMLidList[EBML_ID_SEGMENTFILENAME] = 'SegmentFilename'; + $EBMLidList[EBML_ID_SEGMENTUID] = 'SegmentUID'; + $EBMLidList[EBML_ID_SIMPLETAG] = 'SimpleTag'; + $EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices'; + $EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode'; + $EBMLidList[EBML_ID_OLDSTEREOMODE] = 'OldStereoMode'; + $EBMLidList[EBML_ID_TAG] = 'Tag'; + $EBMLidList[EBML_ID_TAGATTACHMENTUID] = 'TagAttachmentUID'; + $EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary'; + $EBMLidList[EBML_ID_TAGCHAPTERUID] = 'TagChapterUID'; + $EBMLidList[EBML_ID_TAGDEFAULT] = 'TagDefault'; + $EBMLidList[EBML_ID_TAGEDITIONUID] = 'TagEditionUID'; + $EBMLidList[EBML_ID_TAGLANGUAGE] = 'TagLanguage'; + $EBMLidList[EBML_ID_TAGNAME] = 'TagName'; + $EBMLidList[EBML_ID_TAGTRACKUID] = 'TagTrackUID'; + $EBMLidList[EBML_ID_TAGS] = 'Tags'; + $EBMLidList[EBML_ID_TAGSTRING] = 'TagString'; + $EBMLidList[EBML_ID_TARGETS] = 'Targets'; + $EBMLidList[EBML_ID_TARGETTYPE] = 'TargetType'; + $EBMLidList[EBML_ID_TARGETTYPEVALUE] = 'TargetTypeValue'; + $EBMLidList[EBML_ID_TIMECODESCALE] = 'TimecodeScale'; + $EBMLidList[EBML_ID_TITLE] = 'Title'; + $EBMLidList[EBML_ID_TRACKENTRY] = 'TrackEntry'; + $EBMLidList[EBML_ID_TRACKNUMBER] = 'TrackNumber'; + $EBMLidList[EBML_ID_TRACKOFFSET] = 'TrackOffset'; + $EBMLidList[EBML_ID_TRACKOVERLAY] = 'TrackOverlay'; + $EBMLidList[EBML_ID_TRACKS] = 'Tracks'; + $EBMLidList[EBML_ID_TRACKTIMECODESCALE] = 'TrackTimecodeScale'; + $EBMLidList[EBML_ID_TRACKTRANSLATE] = 'TrackTranslate'; + $EBMLidList[EBML_ID_TRACKTRANSLATECODEC] = 'TrackTranslateCodec'; + $EBMLidList[EBML_ID_TRACKTRANSLATEEDITIONUID] = 'TrackTranslateEditionUID'; + $EBMLidList[EBML_ID_TRACKTRANSLATETRACKID] = 'TrackTranslateTrackID'; + $EBMLidList[EBML_ID_TRACKTYPE] = 'TrackType'; + $EBMLidList[EBML_ID_TRACKUID] = 'TrackUID'; + $EBMLidList[EBML_ID_VIDEO] = 'Video'; + $EBMLidList[EBML_ID_VOID] = 'Void'; + $EBMLidList[EBML_ID_WRITINGAPP] = 'WritingApp'; + } + + return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value)); + } + + public static function displayUnit($value) { + // http://www.matroska.org/technical/specs/index.html#DisplayUnit + static $units = array( + 0 => 'pixels', + 1 => 'centimeters', + 2 => 'inches', + 3 => 'Display Aspect Ratio'); + + return (isset($units[$value]) ? $units[$value] : 'unknown'); + } + + private static function getDefaultStreamInfo($streams) + { + foreach (array_reverse($streams) as $stream) { + if ($stream['default']) { + break; + } + } + + $unset = array('default', 'name'); + foreach ($unset as $u) { + if (isset($stream[$u])) { + unset($stream[$u]); + } + } + + $info = $stream; + $info['streams'] = $streams; + + return $info; + } + +} diff --git a/backend/wp-includes/ID3/module.audio-video.quicktime.php b/backend/wp-includes/ID3/module.audio-video.quicktime.php new file mode 100644 index 0000000..6f29ca4 --- /dev/null +++ b/backend/wp-includes/ID3/module.audio-video.quicktime.php @@ -0,0 +1,2666 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio-video.quicktime.php // +// module for analyzing Quicktime and MP3-in-MP4 files // +// dependencies: module.audio.mp3.php // +// dependencies: module.tag.id3v2.php // +// /// +///////////////////////////////////////////////////////////////// + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true); +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); // needed for ISO 639-2 language code lookup + +class getid3_quicktime extends getid3_handler +{ + + public $ReturnAtomData = true; + public $ParseAllPossibleAtoms = false; + + public function Analyze() { + $info = &$this->getid3->info; + + $info['fileformat'] = 'quicktime'; + $info['quicktime']['hinting'] = false; + $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present + + $this->fseek($info['avdataoffset']); + + $offset = 0; + $atomcounter = 0; + $atom_data_read_buffer_size = max($this->getid3->option_fread_buffer_size * 1024, ($info['php_memory_limit'] ? round($info['php_memory_limit'] / 4) : 1024)); // set read buffer to 25% of PHP memory limit (if one is specified), otherwise use option_fread_buffer_size [default: 32MB] + while ($offset < $info['avdataend']) { + if (!getid3_lib::intValueSupported($offset)) { + $this->error('Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions'); + break; + } + $this->fseek($offset); + $AtomHeader = $this->fread(8); + + $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4)); + $atomname = substr($AtomHeader, 4, 4); + + // 64-bit MOV patch by jlegateØktnc*com + if ($atomsize == 1) { + $atomsize = getid3_lib::BigEndian2Int($this->fread(8)); + } + + $info['quicktime'][$atomname]['name'] = $atomname; + $info['quicktime'][$atomname]['size'] = $atomsize; + $info['quicktime'][$atomname]['offset'] = $offset; + + if (($offset + $atomsize) > $info['avdataend']) { + $this->error('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)'); + return false; + } + + if ($atomsize == 0) { + // Furthermore, for historical reasons the list of atoms is optionally + // terminated by a 32-bit integer set to 0. If you are writing a program + // to read user data atoms, you should allow for the terminating 0. + break; + } + $atomHierarchy = array(); + $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms); + + $offset += $atomsize; + $atomcounter++; + } + + if (!empty($info['avdataend_tmp'])) { + // this value is assigned to a temp value and then erased because + // otherwise any atoms beyond the 'mdat' atom would not get parsed + $info['avdataend'] = $info['avdataend_tmp']; + unset($info['avdataend_tmp']); + } + + if (!empty($info['quicktime']['comments']['chapters']) && is_array($info['quicktime']['comments']['chapters']) && (count($info['quicktime']['comments']['chapters']) > 0)) { + $durations = $this->quicktime_time_to_sample_table($info); + for ($i = 0; $i < count($info['quicktime']['comments']['chapters']); $i++) { + $bookmark = array(); + $bookmark['title'] = $info['quicktime']['comments']['chapters'][$i]; + if (isset($durations[$i])) { + $bookmark['duration_sample'] = $durations[$i]['sample_duration']; + if ($i > 0) { + $bookmark['start_sample'] = $info['quicktime']['bookmarks'][($i - 1)]['start_sample'] + $info['quicktime']['bookmarks'][($i - 1)]['duration_sample']; + } else { + $bookmark['start_sample'] = 0; + } + if ($time_scale = $this->quicktime_bookmark_time_scale($info)) { + $bookmark['duration_seconds'] = $bookmark['duration_sample'] / $time_scale; + $bookmark['start_seconds'] = $bookmark['start_sample'] / $time_scale; + } + } + $info['quicktime']['bookmarks'][] = $bookmark; + } + } + + if (isset($info['quicktime']['temp_meta_key_names'])) { + unset($info['quicktime']['temp_meta_key_names']); + } + + if (!empty($info['quicktime']['comments']['location.ISO6709'])) { + // https://en.wikipedia.org/wiki/ISO_6709 + foreach ($info['quicktime']['comments']['location.ISO6709'] as $ISO6709string) { + $latitude = false; + $longitude = false; + $altitude = false; + if (preg_match('#^([\\+\\-])([0-9]{2}|[0-9]{4}|[0-9]{6})(\\.[0-9]+)?([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?(([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?)?/$#', $ISO6709string, $matches)) { + @list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches; + + if (strlen($lat_deg) == 2) { // [+-]DD.D + $latitude = floatval(ltrim($lat_deg, '0').$lat_deg_dec); + } elseif (strlen($lat_deg) == 4) { // [+-]DDMM.M + $latitude = floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0').$lat_deg_dec / 60); + } elseif (strlen($lat_deg) == 6) { // [+-]DDMMSS.S + $latitude = floatval(ltrim(substr($lat_deg, 0, 2), '0')) + floatval(ltrim(substr($lat_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lat_deg, 4, 2), '0').$lat_deg_dec / 3600); + } + + if (strlen($lon_deg) == 3) { // [+-]DDD.D + $longitude = floatval(ltrim($lon_deg, '0').$lon_deg_dec); + } elseif (strlen($lon_deg) == 5) { // [+-]DDDMM.M + $longitude = floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0').$lon_deg_dec / 60); + } elseif (strlen($lon_deg) == 7) { // [+-]DDDMMSS.S + $longitude = floatval(ltrim(substr($lon_deg, 0, 2), '0')) + floatval(ltrim(substr($lon_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($lon_deg, 4, 2), '0').$lon_deg_dec / 3600); + } + + if (strlen($alt_deg) == 3) { // [+-]DDD.D + $altitude = floatval(ltrim($alt_deg, '0').$alt_deg_dec); + } elseif (strlen($alt_deg) == 5) { // [+-]DDDMM.M + $altitude = floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0').$alt_deg_dec / 60); + } elseif (strlen($alt_deg) == 7) { // [+-]DDDMMSS.S + $altitude = floatval(ltrim(substr($alt_deg, 0, 2), '0')) + floatval(ltrim(substr($alt_deg, 2, 2), '0') / 60) + floatval(ltrim(substr($alt_deg, 4, 2), '0').$alt_deg_dec / 3600); + } + + if ($latitude !== false) { + $info['quicktime']['comments']['gps_latitude'][] = (($lat_sign == '-') ? -1 : 1) * floatval($latitude); + } + if ($longitude !== false) { + $info['quicktime']['comments']['gps_longitude'][] = (($lon_sign == '-') ? -1 : 1) * floatval($longitude); + } + if ($altitude !== false) { + $info['quicktime']['comments']['gps_altitude'][] = (($alt_sign == '-') ? -1 : 1) * floatval($altitude); + } + } + if ($latitude === false) { + $this->warning('location.ISO6709 string not parsed correctly: "'.$ISO6709string.'", please submit as a bug'); + } + break; + } + } + + if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) { + $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; + } + if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) { + $info['audio']['bitrate'] = $info['bitrate']; + } + if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) { + foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) { + $samples_per_second = $samples_count / $info['playtime_seconds']; + if ($samples_per_second > 240) { + // has to be audio samples + } else { + $info['video']['frame_rate'] = $samples_per_second; + break; + } + } + } + if ($info['audio']['dataformat'] == 'mp4') { + $info['fileformat'] = 'mp4'; + if (empty($info['video']['resolution_x'])) { + $info['mime_type'] = 'audio/mp4'; + unset($info['video']['dataformat']); + } else { + $info['mime_type'] = 'video/mp4'; + } + } + + if (!$this->ReturnAtomData) { + unset($info['quicktime']['moov']); + } + + if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) { + $info['audio']['dataformat'] = 'quicktime'; + } + if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) { + $info['video']['dataformat'] = 'quicktime'; + } + + return true; + } + + public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) { + // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm + // https://code.google.com/p/mp4v2/wiki/iTunesMetadata + + $info = &$this->getid3->info; + + $atom_parent = end($atomHierarchy); // not array_pop($atomHierarchy); see http://www.getid3.org/phpBB3/viewtopic.php?t=1717 + array_push($atomHierarchy, $atomname); + $atom_structure['hierarchy'] = implode(' ', $atomHierarchy); + $atom_structure['name'] = $atomname; + $atom_structure['size'] = $atomsize; + $atom_structure['offset'] = $baseoffset; + switch ($atomname) { + case 'moov': // MOVie container atom + case 'trak': // TRAcK container atom + case 'clip': // CLIPping container atom + case 'matt': // track MATTe container atom + case 'edts': // EDiTS container atom + case 'tref': // Track REFerence container atom + case 'mdia': // MeDIA container atom + case 'minf': // Media INFormation container atom + case 'dinf': // Data INFormation container atom + case 'udta': // User DaTA container atom + case 'cmov': // Compressed MOVie container atom + case 'rmra': // Reference Movie Record Atom + case 'rmda': // Reference Movie Descriptor Atom + case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR) + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + break; + + case 'ilst': // Item LiST container atom + if ($atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms)) { + // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted + $allnumericnames = true; + foreach ($atom_structure['subatoms'] as $subatomarray) { + if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) { + $allnumericnames = false; + break; + } + } + if ($allnumericnames) { + $newData = array(); + foreach ($atom_structure['subatoms'] as $subatomarray) { + foreach ($subatomarray['subatoms'] as $newData_subatomarray) { + unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']); + $newData[$subatomarray['name']] = $newData_subatomarray; + break; + } + } + $atom_structure['data'] = $newData; + unset($atom_structure['subatoms']); + } + } + break; + + case "\x00\x00\x00\x01": + case "\x00\x00\x00\x02": + case "\x00\x00\x00\x03": + case "\x00\x00\x00\x04": + case "\x00\x00\x00\x05": + $atomname = getid3_lib::BigEndian2Int($atomname); + $atom_structure['name'] = $atomname; + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + break; + + case 'stbl': // Sample TaBLe container atom + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + $isVideo = false; + $framerate = 0; + $framecount = 0; + foreach ($atom_structure['subatoms'] as $key => $value_array) { + if (isset($value_array['sample_description_table'])) { + foreach ($value_array['sample_description_table'] as $key2 => $value_array2) { + if (isset($value_array2['data_format'])) { + switch ($value_array2['data_format']) { + case 'avc1': + case 'mp4v': + // video data + $isVideo = true; + break; + case 'mp4a': + // audio data + break; + } + } + } + } elseif (isset($value_array['time_to_sample_table'])) { + foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) { + if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) { + $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3); + $framecount = $value_array2['sample_count']; + } + } + } + } + if ($isVideo && $framerate) { + $info['quicktime']['video']['frame_rate'] = $framerate; + $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate']; + } + if ($isVideo && $framecount) { + $info['quicktime']['video']['frame_count'] = $framecount; + } + break; + + + case "\xA9".'alb': // ALBum + case "\xA9".'ART': // + case "\xA9".'art': // ARTist + case "\xA9".'aut': // + case "\xA9".'cmt': // CoMmenT + case "\xA9".'com': // COMposer + case "\xA9".'cpy': // + case "\xA9".'day': // content created year + case "\xA9".'dir': // + case "\xA9".'ed1': // + case "\xA9".'ed2': // + case "\xA9".'ed3': // + case "\xA9".'ed4': // + case "\xA9".'ed5': // + case "\xA9".'ed6': // + case "\xA9".'ed7': // + case "\xA9".'ed8': // + case "\xA9".'ed9': // + case "\xA9".'enc': // + case "\xA9".'fmt': // + case "\xA9".'gen': // GENre + case "\xA9".'grp': // GRouPing + case "\xA9".'hst': // + case "\xA9".'inf': // + case "\xA9".'lyr': // LYRics + case "\xA9".'mak': // + case "\xA9".'mod': // + case "\xA9".'nam': // full NAMe + case "\xA9".'ope': // + case "\xA9".'PRD': // + case "\xA9".'prf': // + case "\xA9".'req': // + case "\xA9".'src': // + case "\xA9".'swr': // + case "\xA9".'too': // encoder + case "\xA9".'trk': // TRacK + case "\xA9".'url': // + case "\xA9".'wrn': // + case "\xA9".'wrt': // WRiTer + case '----': // itunes specific + case 'aART': // Album ARTist + case 'akID': // iTunes store account type + case 'apID': // Purchase Account + case 'atID': // + case 'catg': // CaTeGory + case 'cmID': // + case 'cnID': // + case 'covr': // COVeR artwork + case 'cpil': // ComPILation + case 'cprt': // CoPyRighT + case 'desc': // DESCription + case 'disk': // DISK number + case 'egid': // Episode Global ID + case 'geID': // + case 'gnre': // GeNRE + case 'hdvd': // HD ViDeo + case 'keyw': // KEYWord + case 'ldes': // Long DEScription + case 'pcst': // PodCaST + case 'pgap': // GAPless Playback + case 'plID': // + case 'purd': // PURchase Date + case 'purl': // Podcast URL + case 'rati': // + case 'rndu': // + case 'rpdu': // + case 'rtng': // RaTiNG + case 'sfID': // iTunes store country + case 'soaa': // SOrt Album Artist + case 'soal': // SOrt ALbum + case 'soar': // SOrt ARtist + case 'soco': // SOrt COmposer + case 'sonm': // SOrt NaMe + case 'sosn': // SOrt Show Name + case 'stik': // + case 'tmpo': // TeMPO (BPM) + case 'trkn': // TRacK Number + case 'tven': // tvEpisodeID + case 'tves': // TV EpiSode + case 'tvnn': // TV Network Name + case 'tvsh': // TV SHow Name + case 'tvsn': // TV SeasoN + if ($atom_parent == 'udta') { + // User data atom handler + $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); + $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); + $atom_structure['data'] = substr($atom_data, 4); + + $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); + if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { + $info['comments']['language'][] = $atom_structure['language']; + } + } else { + // Apple item list box atom handler + $atomoffset = 0; + if (substr($atom_data, 2, 2) == "\x10\xB5") { + // not sure what it means, but observed on iPhone4 data. + // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data + while ($atomoffset < strlen($atom_data)) { + $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2)); + $boxsmalltype = substr($atom_data, $atomoffset + 2, 2); + $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize); + if ($boxsmallsize <= 1) { + $this->warning('Invalid QuickTime atom smallbox size "'.$boxsmallsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset)); + $atom_structure['data'] = null; + $atomoffset = strlen($atom_data); + break; + } + switch ($boxsmalltype) { + case "\x10\xB5": + $atom_structure['data'] = $boxsmalldata; + break; + default: + $this->warning('Unknown QuickTime smallbox type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxsmalltype).'" ('.trim(getid3_lib::PrintHexBytes($boxsmalltype)).') at offset '.$baseoffset); + $atom_structure['data'] = $atom_data; + break; + } + $atomoffset += (4 + $boxsmallsize); + } + } else { + while ($atomoffset < strlen($atom_data)) { + $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4)); + $boxtype = substr($atom_data, $atomoffset + 4, 4); + $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8); + if ($boxsize <= 1) { + $this->warning('Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" at offset: '.($atom_structure['offset'] + $atomoffset)); + $atom_structure['data'] = null; + $atomoffset = strlen($atom_data); + break; + } + $atomoffset += $boxsize; + + switch ($boxtype) { + case 'mean': + case 'name': + $atom_structure[$boxtype] = substr($boxdata, 4); + break; + + case 'data': + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3)); + switch ($atom_structure['flags_raw']) { + case 0: // data flag + case 21: // tmpo/cpil flag + switch ($atomname) { + case 'cpil': + case 'hdvd': + case 'pcst': + case 'pgap': + // 8-bit integer (boolean) + $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); + break; + + case 'tmpo': + // 16-bit integer + $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2)); + break; + + case 'disk': + case 'trkn': + // binary + $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2)); + $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2)); + $atom_structure['data'] = empty($num) ? '' : $num; + $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total; + break; + + case 'gnre': + // enum + $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); + $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1); + break; + + case 'rtng': + // 8-bit integer + $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); + $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]); + break; + + case 'stik': + // 8-bit integer (enum) + $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1)); + $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]); + break; + + case 'sfID': + // 32-bit integer + $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); + $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]); + break; + + case 'egid': + case 'purl': + $atom_structure['data'] = substr($boxdata, 8); + break; + + case 'plID': + // 64-bit integer + $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 8)); + break; + + case 'covr': + $atom_structure['data'] = substr($boxdata, 8); + // not a foolproof check, but better than nothing + if (preg_match('#^\\xFF\\xD8\\xFF#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/jpeg'; + } elseif (preg_match('#^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/png'; + } elseif (preg_match('#^GIF#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/gif'; + } + break; + + case 'atID': + case 'cnID': + case 'geID': + case 'tves': + case 'tvsn': + default: + // 32-bit integer + $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4)); + } + break; + + case 1: // text flag + case 13: // image flag + default: + $atom_structure['data'] = substr($boxdata, 8); + if ($atomname == 'covr') { + // not a foolproof check, but better than nothing + if (preg_match('#^\\xFF\\xD8\\xFF#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/jpeg'; + } elseif (preg_match('#^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/png'; + } elseif (preg_match('#^GIF#', $atom_structure['data'])) { + $atom_structure['image_mime'] = 'image/gif'; + } + } + break; + + } + break; + + default: + $this->warning('Unknown QuickTime box type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $boxtype).'" ('.trim(getid3_lib::PrintHexBytes($boxtype)).') at offset '.$baseoffset); + $atom_structure['data'] = $atom_data; + + } + } + } + } + $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']); + break; + + + case 'play': // auto-PLAY atom + $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + + $info['quicktime']['autoplay'] = $atom_structure['autoplay']; + break; + + + case 'WLOC': // Window LOCation atom + $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); + $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); + break; + + + case 'LOOP': // LOOPing atom + case 'SelO': // play SELection Only atom + case 'AllF': // play ALL Frames atom + $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data); + break; + + + case 'name': // + case 'MCPS': // Media Cleaner PRo + case '@PRM': // adobe PReMiere version + case '@PRQ': // adobe PRemiere Quicktime version + $atom_structure['data'] = $atom_data; + break; + + + case 'cmvd': // Compressed MooV Data atom + // Code by ubergeekØubergeek*tv based on information from + // http://developer.apple.com/quicktime/icefloe/dispatch012.html + $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); + + $CompressedFileData = substr($atom_data, 4); + if ($UncompressedHeader = @gzuncompress($CompressedFileData)) { + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms); + } else { + $this->warning('Error decompressing compressed MOV atom at offset '.$atom_structure['offset']); + } + break; + + + case 'dcom': // Data COMpression atom + $atom_structure['compression_id'] = $atom_data; + $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data); + break; + + + case 'rdrf': // Reference movie Data ReFerence atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001); + + $atom_structure['reference_type_name'] = substr($atom_data, 4, 4); + $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + switch ($atom_structure['reference_type_name']) { + case 'url ': + $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12)); + break; + + case 'alis': + $atom_structure['file_alias'] = substr($atom_data, 12); + break; + + case 'rsrc': + $atom_structure['resource_alias'] = substr($atom_data, 12); + break; + + default: + $atom_structure['data'] = substr($atom_data, 12); + break; + } + break; + + + case 'rmqu': // Reference Movie QUality atom + $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data); + break; + + + case 'rmcs': // Reference Movie Cpu Speed atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + break; + + + case 'rmvc': // Reference Movie Version Check atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4); + $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); + $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2)); + break; + + + case 'rmcd': // Reference Movie Component check atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['component_type'] = substr($atom_data, 4, 4); + $atom_structure['component_subtype'] = substr($atom_data, 8, 4); + $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4); + $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); + $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); + $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4)); + break; + + + case 'rmdr': // Reference Movie Data Rate atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + + $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10; + break; + + + case 'rmla': // Reference Movie Language Atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + + $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); + if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { + $info['comments']['language'][] = $atom_structure['language']; + } + break; + + + case 'rmla': // Reference Movie Language Atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + break; + + + case 'ptv ': // Print To Video - defines a movie's full screen mode + // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm + $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); + $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000 + $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000 + $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1)); + $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1)); + + $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag']; + $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag']; + + $ptv_lookup[0] = 'normal'; + $ptv_lookup[1] = 'double'; + $ptv_lookup[2] = 'half'; + $ptv_lookup[3] = 'full'; + $ptv_lookup[4] = 'current'; + if (isset($ptv_lookup[$atom_structure['display_size_raw']])) { + $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']]; + } else { + $this->warning('unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')'); + } + break; + + + case 'stsd': // Sample Table Sample Description atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + + // see: https://github.com/JamesHeinrich/getID3/issues/111 + // Some corrupt files have been known to have high bits set in the number_entries field + // This field shouldn't really need to be 32-bits, values stores are likely in the range 1-100000 + // Workaround: mask off the upper byte and throw a warning if it's nonzero + if ($atom_structure['number_entries'] > 0x000FFFFF) { + if ($atom_structure['number_entries'] > 0x00FFFFFF) { + $this->warning('"stsd" atom contains improbably large number_entries (0x'.getid3_lib::PrintHexBytes(substr($atom_data, 4, 4), true, false).' = '.$atom_structure['number_entries'].'), probably in error. Ignoring upper byte and interpreting this as 0x'.getid3_lib::PrintHexBytes(substr($atom_data, 5, 3), true, false).' = '.($atom_structure['number_entries'] & 0x00FFFFFF)); + $atom_structure['number_entries'] = ($atom_structure['number_entries'] & 0x00FFFFFF); + } else { + $this->warning('"stsd" atom contains improbably large number_entries (0x'.getid3_lib::PrintHexBytes(substr($atom_data, 4, 4), true, false).' = '.$atom_structure['number_entries'].'), probably in error. Please report this to info@getid3.org referencing bug report #111'); + } + } + + $stsdEntriesDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4)); + $stsdEntriesDataOffset += 4; + $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4); + $stsdEntriesDataOffset += 4; + $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6)); + $stsdEntriesDataOffset += 6; + $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2)); + $stsdEntriesDataOffset += 2; + $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); + $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); + + $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2)); + $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2)); + $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4); + + switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) { + + case "\x00\x00\x00\x00": + // audio tracks + $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2)); + $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2)); + $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2)); + $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2)); + $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4)); + + // video tracks + // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap3/qtff3.html + $atom_structure['sample_description_table'][$i]['temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4)); + $atom_structure['sample_description_table'][$i]['spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4)); + $atom_structure['sample_description_table'][$i]['width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2)); + $atom_structure['sample_description_table'][$i]['height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2)); + $atom_structure['sample_description_table'][$i]['resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); + $atom_structure['sample_description_table'][$i]['resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4)); + $atom_structure['sample_description_table'][$i]['data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 4)); + $atom_structure['sample_description_table'][$i]['frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 36, 2)); + $atom_structure['sample_description_table'][$i]['compressor_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 38, 4); + $atom_structure['sample_description_table'][$i]['pixel_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 42, 2)); + $atom_structure['sample_description_table'][$i]['color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 44, 2)); + + switch ($atom_structure['sample_description_table'][$i]['data_format']) { + case '2vuY': + case 'avc1': + case 'cvid': + case 'dvc ': + case 'dvcp': + case 'gif ': + case 'h263': + case 'jpeg': + case 'kpcd': + case 'mjpa': + case 'mjpb': + case 'mp4v': + case 'png ': + case 'raw ': + case 'rle ': + case 'rpza': + case 'smc ': + case 'SVQ1': + case 'SVQ3': + case 'tiff': + case 'v210': + case 'v216': + case 'v308': + case 'v408': + case 'v410': + case 'yuv2': + $info['fileformat'] = 'mp4'; + $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; +// http://www.getid3.org/phpBB3/viewtopic.php?t=1550 +//if ((!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['width'])) && (empty($info['video']['resolution_x']) || empty($info['video']['resolution_y']) || (number_format($info['video']['resolution_x'], 6) != number_format(round($info['video']['resolution_x']), 6)) || (number_format($info['video']['resolution_y'], 6) != number_format(round($info['video']['resolution_y']), 6)))) { // ugly check for floating point numbers +if (!empty($atom_structure['sample_description_table'][$i]['width']) && !empty($atom_structure['sample_description_table'][$i]['height'])) { + // assume that values stored here are more important than values stored in [tkhd] atom + $info['video']['resolution_x'] = $atom_structure['sample_description_table'][$i]['width']; + $info['video']['resolution_y'] = $atom_structure['sample_description_table'][$i]['height']; + $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x']; + $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y']; +} + break; + + case 'qtvr': + $info['video']['dataformat'] = 'quicktimevr'; + break; + + case 'mp4a': + default: + $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); + $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate']; + $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels']; + $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth']; + $info['audio']['codec'] = $info['quicktime']['audio']['codec']; + $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate']; + $info['audio']['channels'] = $info['quicktime']['audio']['channels']; + $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth']; + switch ($atom_structure['sample_description_table'][$i]['data_format']) { + case 'raw ': // PCM + case 'alac': // Apple Lossless Audio Codec + $info['audio']['lossless'] = true; + break; + default: + $info['audio']['lossless'] = false; + break; + } + break; + } + break; + + default: + switch ($atom_structure['sample_description_table'][$i]['data_format']) { + case 'mp4s': + $info['fileformat'] = 'mp4'; + break; + + default: + // video atom + $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4)); + $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4)); + $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2)); + $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2)); + $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4)); + $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4)); + $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4)); + $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2)); + $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1)); + $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']); + $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2)); + $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2)); + + $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color'); + $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']); + + if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') { + $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format']; + $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']); + $info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']); + $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth']; + $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name']; + + $info['video']['codec'] = $info['quicktime']['video']['codec']; + $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth']; + } + $info['video']['lossless'] = false; + $info['video']['pixel_aspect_ratio'] = (float) 1; + break; + } + break; + } + switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) { + case 'mp4a': + $info['audio']['dataformat'] = 'mp4'; + $info['quicktime']['audio']['codec'] = 'mp4'; + break; + + case '3ivx': + case '3iv1': + case '3iv2': + $info['video']['dataformat'] = '3ivx'; + break; + + case 'xvid': + $info['video']['dataformat'] = 'xvid'; + break; + + case 'mp4v': + $info['video']['dataformat'] = 'mpeg4'; + break; + + case 'divx': + case 'div1': + case 'div2': + case 'div3': + case 'div4': + case 'div5': + case 'div6': + $info['video']['dataformat'] = 'divx'; + break; + + default: + // do nothing + break; + } + unset($atom_structure['sample_description_table'][$i]['data']); + } + break; + + + case 'stts': // Sample Table Time-to-Sample atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $sttsEntriesDataOffset = 8; + //$FrameRateCalculatorArray = array(); + $frames_count = 0; + + $max_stts_entries_to_scan = ($info['php_memory_limit'] ? min(floor($this->getid3->memory_limit / 10000), $atom_structure['number_entries']) : $atom_structure['number_entries']); + if ($max_stts_entries_to_scan < $atom_structure['number_entries']) { + $this->warning('QuickTime atom "stts" has '.$atom_structure['number_entries'].' but only scanning the first '.$max_stts_entries_to_scan.' entries due to limited PHP memory available ('.floor($atom_structure['number_entries'] / 1048576).'MB).'); + } + for ($i = 0; $i < $max_stts_entries_to_scan; $i++) { + $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); + $sttsEntriesDataOffset += 4; + $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4)); + $sttsEntriesDataOffset += 4; + + $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count']; + + // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM + //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) { + // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration']; + // if ($stts_new_framerate <= 60) { + // // some atoms have durations of "1" giving a very large framerate, which probably is not right + // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate); + // } + //} + // + //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count']; + } + $info['quicktime']['stts_framecount'][] = $frames_count; + //$sttsFramesTotal = 0; + //$sttsSecondsTotal = 0; + //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) { + // if (($frames_per_second > 60) || ($frames_per_second < 1)) { + // // not video FPS information, probably audio information + // $sttsFramesTotal = 0; + // $sttsSecondsTotal = 0; + // break; + // } + // $sttsFramesTotal += $frame_count; + // $sttsSecondsTotal += $frame_count / $frames_per_second; + //} + //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) { + // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) { + // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal; + // } + //} + break; + + + case 'stss': // Sample Table Sync Sample (key frames) atom + if ($ParseAllPossibleAtoms) { + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $stssEntriesDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4)); + $stssEntriesDataOffset += 4; + } + } + break; + + + case 'stsc': // Sample Table Sample-to-Chunk atom + if ($ParseAllPossibleAtoms) { + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $stscEntriesDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); + $stscEntriesDataOffset += 4; + $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); + $stscEntriesDataOffset += 4; + $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4)); + $stscEntriesDataOffset += 4; + } + } + break; + + + case 'stsz': // Sample Table SiZe atom + if ($ParseAllPossibleAtoms) { + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $stszEntriesDataOffset = 12; + if ($atom_structure['sample_size'] == 0) { + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4)); + $stszEntriesDataOffset += 4; + } + } + } + break; + + + case 'stco': // Sample Table Chunk Offset atom + if ($ParseAllPossibleAtoms) { + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $stcoEntriesDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4)); + $stcoEntriesDataOffset += 4; + } + } + break; + + + case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files) + if ($ParseAllPossibleAtoms) { + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $stcoEntriesDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8)); + $stcoEntriesDataOffset += 8; + } + } + break; + + + case 'dref': // Data REFerence atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $drefDataOffset = 8; + for ($i = 0; $i < $atom_structure['number_entries']; $i++) { + $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4)); + $drefDataOffset += 4; + $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4); + $drefDataOffset += 4; + $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1)); + $drefDataOffset += 1; + $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000 + $drefDataOffset += 3; + $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3)); + $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3); + + $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001); + } + break; + + + case 'gmin': // base Media INformation atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); + $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2)); + $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); + $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2)); + $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2)); + break; + + + case 'smhd': // Sound Media information HeaDer atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); + break; + + + case 'vmhd': // Video Media information HeaDer atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)); + $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2)); + $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); + + $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001); + break; + + + case 'hdlr': // HanDLeR reference atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['component_type'] = substr($atom_data, 4, 4); + $atom_structure['component_subtype'] = substr($atom_data, 8, 4); + $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4); + $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); + $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); + $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24)); + + if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { + $info['video']['dataformat'] = 'quicktimevr'; + } + break; + + + case 'mdhd': // MeDia HeaDer atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); + $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); + $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2)); + $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2)); + + if ($atom_structure['time_scale'] == 0) { + $this->error('Corrupt Quicktime file: mdhd.time_scale == zero'); + return false; + } + $info['quicktime']['time_scale'] = ((isset($info['quicktime']['time_scale']) && ($info['quicktime']['time_scale'] < 1000)) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']); + + $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); + $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); + $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; + $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']); + if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) { + $info['comments']['language'][] = $atom_structure['language']; + } + break; + + + case 'pnot': // Preview atom + $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format" + $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00 + $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT' + $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01 + + $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']); + break; + + + case 'crgn': // Clipping ReGioN atom + $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box, + $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields + $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region. + break; + + + case 'load': // track LOAD settings atom + $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); + $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); + + $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020); + $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100); + break; + + + case 'tmcd': // TiMe CoDe atom + case 'chap': // CHAPter list atom + case 'sync': // SYNChronization atom + case 'scpt': // tranSCriPT atom + case 'ssrc': // non-primary SouRCe atom + for ($i = 0; $i < strlen($atom_data); $i += 4) { + @$atom_structure['track_id'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); + } + break; + + + case 'elst': // Edit LiST atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) { + $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4)); + $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4)); + $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4)); + } + break; + + + case 'kmat': // compressed MATte atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000 + $atom_structure['matte_data_raw'] = substr($atom_data, 4); + break; + + + case 'ctab': // Color TABle atom + $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000 + $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000 + $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1; + for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) { + $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2)); + $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2)); + $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2)); + $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2)); + } + break; + + + case 'mvhd': // MoVie HeaDer atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); + $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); + $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4)); + $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2)); + $atom_structure['reserved'] = substr($atom_data, 26, 10); + $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4)); + $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4)); + $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4)); + $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4)); + $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4)); + $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4)); + $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4)); + $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4)); + $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4)); + $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4)); + $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4)); + $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4)); + $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4)); + $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4)); + $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4)); + $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4)); + + if ($atom_structure['time_scale'] == 0) { + $this->error('Corrupt Quicktime file: mvhd.time_scale == zero'); + return false; + } + $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); + $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); + $info['quicktime']['time_scale'] = ((isset($info['quicktime']['time_scale']) && ($info['quicktime']['time_scale'] < 1000)) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']); + $info['quicktime']['display_scale'] = $atom_structure['matrix_a']; + $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale']; + break; + + + case 'tkhd': // TracK HeaDer atom + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4)); + $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4)); + $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); + $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); + $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8)); + $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2)); + $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2)); + $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2)); + $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2)); +// http://developer.apple.com/library/mac/#documentation/QuickTime/RM/MovieBasics/MTEditing/K-Chapter/11MatrixFunctions.html +// http://developer.apple.com/library/mac/#documentation/QuickTime/qtff/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-18737 + $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4)); + $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4)); + $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 48, 4)); + $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4)); + $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4)); + $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 60, 4)); + $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4)); + $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 68, 4)); + $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4)); + $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4)); + $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4)); + $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001); + $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002); + $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004); + $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008); + $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); + $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); + + if ($atom_structure['flags']['enabled'] == 1) { + if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) { + $info['video']['resolution_x'] = $atom_structure['width']; + $info['video']['resolution_y'] = $atom_structure['height']; + } + $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']); + $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']); + $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x']; + $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y']; + } else { + // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295 + //if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); } + //if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); } + //if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); } + } + break; + + + case 'iods': // Initial Object DeScriptor atom + // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h + // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html + $offset = 0; + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3)); + $offset += 3; + $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset); + //$offset already adjusted by quicktime_read_mp4_descr_length() + $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); + $offset += 2; + $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + + $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields + for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) { + $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1)); + $offset += 1; + $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset); + //$offset already adjusted by quicktime_read_mp4_descr_length() + $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); + $offset += 4; + } + + $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']); + $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']); + break; + + case 'ftyp': // FileTYPe (?) atom (for MP4 it seems) + $atom_structure['signature'] = substr($atom_data, 0, 4); + $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $atom_structure['fourcc'] = substr($atom_data, 8, 4); + break; + + case 'mdat': // Media DATa atom + // 'mdat' contains the actual data for the audio/video, possibly also subtitles + +/* due to lack of known documentation, this is a kludge implementation. If you know of documentation on how mdat is properly structed, please send it to info@getid3.org */ + + // first, skip any 'wide' padding, and second 'mdat' header (with specified size of zero?) + $mdat_offset = 0; + while (true) { + if (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x08".'wide') { + $mdat_offset += 8; + } elseif (substr($atom_data, $mdat_offset, 8) == "\x00\x00\x00\x00".'mdat') { + $mdat_offset += 8; + } else { + break; + } + } + + // check to see if it looks like chapter titles, in the form of unterminated strings with a leading 16-bit size field + while (($mdat_offset < (strlen($atom_data) - 8)) + && ($chapter_string_length = getid3_lib::BigEndian2Int(substr($atom_data, $mdat_offset, 2))) + && ($chapter_string_length < 1000) + && ($chapter_string_length <= (strlen($atom_data) - $mdat_offset - 2)) + && preg_match('#^([\x00-\xFF]{2})([\x20-\xFF]+)$#', substr($atom_data, $mdat_offset, $chapter_string_length + 2), $chapter_matches)) { + list($dummy, $chapter_string_length_hex, $chapter_string) = $chapter_matches; + $mdat_offset += (2 + $chapter_string_length); + @$info['quicktime']['comments']['chapters'][] = $chapter_string; + + // "encd" atom specifies encoding. In theory could be anything, almost always UTF-8, but may be UTF-16 with BOM (not currently handled) + if (substr($atom_data, $mdat_offset, 12) == "\x00\x00\x00\x0C\x65\x6E\x63\x64\x00\x00\x01\x00") { // UTF-8 + $mdat_offset += 12; + } + } + + + if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) { + + $info['avdataoffset'] = $atom_structure['offset'] + 8; // $info['quicktime'][$atomname]['offset'] + 8; + $OldAVDataEnd = $info['avdataend']; + $info['avdataend'] = $atom_structure['offset'] + $atom_structure['size']; // $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size']; + + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; + $getid3_temp->info['avdataend'] = $info['avdataend']; + $getid3_mp3 = new getid3_mp3($getid3_temp); + if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode($this->fread(4)))) { + $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false); + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $value) { + $this->warning($value); + } + } + if (!empty($getid3_temp->info['mpeg'])) { + $info['mpeg'] = $getid3_temp->info['mpeg']; + if (isset($info['mpeg']['audio'])) { + $info['audio']['dataformat'] = 'mp3'; + $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3'))); + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; + $info['audio']['channels'] = $info['mpeg']['audio']['channels']; + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; + $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); + $info['bitrate'] = $info['audio']['bitrate']; + } + } + } + unset($getid3_mp3, $getid3_temp); + $info['avdataend'] = $OldAVDataEnd; + unset($OldAVDataEnd); + + } + + unset($mdat_offset, $chapter_string_length, $chapter_matches); + break; + + case 'free': // FREE space atom + case 'skip': // SKIP atom + case 'wide': // 64-bit expansion placeholder atom + // 'free', 'skip' and 'wide' are just padding, contains no useful data at all + + // When writing QuickTime files, it is sometimes necessary to update an atom's size. + // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom + // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime + // puts an 8-byte placeholder atom before any atoms it may have to update the size of. + // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the + // placeholder atom can be overwritten to obtain the necessary 8 extra bytes. + // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ). + break; + + + case 'nsav': // NoSAVe atom + // http://developer.apple.com/technotes/tn/tn2038.html + $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); + break; + + case 'ctyp': // Controller TYPe atom (seen on QTVR) + // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt + // some controller names are: + // 0x00 + 'std' for linear movie + // 'none' for no controls + $atom_structure['ctyp'] = substr($atom_data, 0, 4); + $info['quicktime']['controller'] = $atom_structure['ctyp']; + switch ($atom_structure['ctyp']) { + case 'qtvr': + $info['video']['dataformat'] = 'quicktimevr'; + break; + } + break; + + case 'pano': // PANOrama track (seen on QTVR) + $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); + break; + + case 'hint': // HINT track + case 'hinf': // + case 'hinv': // + case 'hnti': // + $info['quicktime']['hinting'] = true; + break; + + case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR) + for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) { + $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4)); + } + break; + + + // Observed-but-not-handled atom types are just listed here to prevent warnings being generated + case 'FXTC': // Something to do with Adobe After Effects (?) + case 'PrmA': + case 'code': + case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html + case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html + // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838] + // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html + // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html + case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html + case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html + case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html + case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html + //$atom_structure['data'] = $atom_data; + break; + + case "\xA9".'xyz': // GPS latitude+longitude+altitude + $atom_structure['data'] = $atom_data; + if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) { + @list($all, $latitude, $longitude, $altitude) = $matches; + $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude); + $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude); + if (!empty($altitude)) { + $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude); + } + } else { + $this->warning('QuickTime atom "©xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.'); + } + break; + + case 'NCDT': + // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html + // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100 + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms); + break; + case 'NCTH': // Nikon Camera THumbnail image + case 'NCVW': // Nikon Camera preVieW image + // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html + if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) { + $atom_structure['data'] = $atom_data; + $atom_structure['image_mime'] = 'image/jpeg'; + $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image')); + $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']); + } + break; + case 'NCTG': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG + $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data); + break; + case 'NCHD': // Nikon:MakerNoteVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html + case 'NCDB': // Nikon - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html + case 'CNCV': // Canon:CompressorVersion - http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html + $atom_structure['data'] = $atom_data; + break; + + case "\x00\x00\x00\x00": + // some kind of metacontainer, may contain a big data dump such as: + // mdta keys \005 mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst \01D \001 \015data \001DE\010Apple 0 \002 (data \001DE\0102011-05-11T17:54:04+0200 2 \003 *data \001DE\010+52.4936+013.3897+040.247/ \01D \004 \015data \001DE\0104.3.1 \005 \018data \001DE\010iPhone 4 + // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt + + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + break; + + case 'meta': // METAdata atom + // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html + + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms); + break; + + case 'data': // metaDATA atom + static $metaDATAkey = 1; // real ugly, but so is the QuickTime structure that stores keys and values in different multinested locations that are hard to relate to each other + // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data + $atom_structure['language'] = substr($atom_data, 4 + 0, 2); + $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2)); + $atom_structure['data'] = substr($atom_data, 4 + 4); + $atom_structure['key_name'] = @$info['quicktime']['temp_meta_key_names'][$metaDATAkey++]; + + if ($atom_structure['key_name'] && $atom_structure['data']) { + @$info['quicktime']['comments'][str_replace('com.apple.quicktime.', '', $atom_structure['key_name'])][] = $atom_structure['data']; + } + break; + + case 'keys': // KEYS that may be present in the metadata atom. + // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW21 + // The metadata item keys atom holds a list of the metadata keys that may be present in the metadata atom. + // This list is indexed starting with 1; 0 is a reserved index value. The metadata item keys atom is a full atom with an atom type of "keys". + $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1)); + $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); + $atom_structure['entry_count'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4)); + $keys_atom_offset = 8; + for ($i = 1; $i <= $atom_structure['entry_count']; $i++) { + $atom_structure['keys'][$i]['key_size'] = getid3_lib::BigEndian2Int(substr($atom_data, $keys_atom_offset + 0, 4)); + $atom_structure['keys'][$i]['key_namespace'] = substr($atom_data, $keys_atom_offset + 4, 4); + $atom_structure['keys'][$i]['key_value'] = substr($atom_data, $keys_atom_offset + 8, $atom_structure['keys'][$i]['key_size'] - 8); + $keys_atom_offset += $atom_structure['keys'][$i]['key_size']; // key_size includes the 4+4 bytes for key_size and key_namespace + + $info['quicktime']['temp_meta_key_names'][$i] = $atom_structure['keys'][$i]['key_value']; + } + break; + + case 'gps ': + // https://dashcamtalk.com/forum/threads/script-to-extract-gps-data-from-novatek-mp4.20808/page-2#post-291730 + // The 'gps ' contains simple look up table made up of 8byte rows, that point to the 'free' atoms that contains the actual GPS data. + // The first row is version/metadata/notsure, I skip that. + // The following rows consist of 4byte address (absolute) and 4byte size (0x1000), these point to the GPS data in the file. + + $GPS_rowsize = 8; // 4 bytes for offset, 4 bytes for size + if (strlen($atom_data) > 0) { + if ((strlen($atom_data) % $GPS_rowsize) == 0) { + $atom_structure['gps_toc'] = array(); + foreach (str_split($atom_data, $GPS_rowsize) as $counter => $datapair) { + $atom_structure['gps_toc'][] = unpack('Noffset/Nsize', substr($atom_data, $counter * $GPS_rowsize, $GPS_rowsize)); + } + + $atom_structure['gps_entries'] = array(); + $previous_offset = $this->ftell(); + foreach ($atom_structure['gps_toc'] as $key => $gps_pointer) { + if ($key == 0) { + // "The first row is version/metadata/notsure, I skip that." + continue; + } + $this->fseek($gps_pointer['offset']); + $GPS_free_data = $this->fread($gps_pointer['size']); + + /* + // 2017-05-10: I see some of the data, notably the Hour-Minute-Second, but cannot reconcile the rest of the data. However, the NMEA "GPRMC" line is there and relatively easy to parse, so I'm using that instead + + // https://dashcamtalk.com/forum/threads/script-to-extract-gps-data-from-novatek-mp4.20808/page-2#post-291730 + // The structure of the GPS data atom (the 'free' atoms mentioned above) is following: + // hour,minute,second,year,month,day,active,latitude_b,longitude_b,unknown2,latitude,longitude,speed = struct.unpack_from(' 90) ? 1900 : 2000); // complete lack of foresight: datestamps are stored with 2-digit years, take best guess + $GPS_this_GPRMC['timestamp'] = $year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second.$ms; + + $GPS_this_GPRMC['active'] = ($GPS_this_GPRMC['raw']['status'] == 'A'); // A=Active,V=Void + + foreach (array('latitude','longitude') as $latlon) { + preg_match('#^([0-9]{1,3})([0-9]{2}\\.[0-9]+)$#', $GPS_this_GPRMC['raw'][$latlon], $matches); + list($dummy, $deg, $min) = $matches; + $GPS_this_GPRMC[$latlon] = $deg + ($min / 60); + } + $GPS_this_GPRMC['latitude'] *= (($GPS_this_GPRMC['raw']['latitude_direction'] == 'S') ? -1 : 1); + $GPS_this_GPRMC['longitude'] *= (($GPS_this_GPRMC['raw']['longitude_direction'] == 'W') ? -1 : 1); + + $GPS_this_GPRMC['heading'] = $GPS_this_GPRMC['raw']['angle']; + $GPS_this_GPRMC['speed_knot'] = $GPS_this_GPRMC['raw']['knots']; + $GPS_this_GPRMC['speed_kmh'] = $GPS_this_GPRMC['raw']['knots'] * 1.852; + if ($GPS_this_GPRMC['raw']['variation']) { + $GPS_this_GPRMC['variation'] = $GPS_this_GPRMC['raw']['variation']; + $GPS_this_GPRMC['variation'] *= (($GPS_this_GPRMC['raw']['variation_direction'] == 'W') ? -1 : 1); + } + + $atom_structure['gps_entries'][$key] = $GPS_this_GPRMC; + + @$info['quicktime']['gps_track'][$GPS_this_GPRMC['timestamp']] = array( + 'latitude' => $GPS_this_GPRMC['latitude'], + 'longitude' => $GPS_this_GPRMC['longitude'], + 'speed_kmh' => $GPS_this_GPRMC['speed_kmh'], + 'heading' => $GPS_this_GPRMC['heading'], + ); + + } else { + $this->warning('Unhandled GPS format in "free" atom at offset '.$gps_pointer['offset']); + } + } + $this->fseek($previous_offset); + + } else { + $this->warning('QuickTime atom "'.$atomname.'" is not mod-8 bytes long ('.$atomsize.' bytes) at offset '.$baseoffset); + } + } else { + $this->warning('QuickTime atom "'.$atomname.'" is zero bytes long at offset '.$baseoffset); + } + break; + + case 'loci':// 3GP location (El Loco) + $info['quicktime']['comments']['gps_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); + $info['quicktime']['comments']['gps_lang'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); + $loffset = 0; + $info['quicktime']['comments']['gps_location'] = $this->LociString(substr($atom_data, 6), $loffset); + $loci_data=substr($atom_data, 6 + $loffset); + $info['quicktime']['comments']['gps_role'] = getid3_lib::BigEndian2Int(substr($loci_data, 0, 1)); + $info['quicktime']['comments']['gps_longitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 1, 4)); + $info['quicktime']['comments']['gps_latitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 5, 4)); + $info['quicktime']['comments']['gps_altitude'] = getid3_lib::FixedPoint16_16(substr($loci_data, 9, 4)); + $info['quicktime']['comments']['gps_body'] = $this->LociString(substr($loci_data, 13), $loffset); + $info['quicktime']['comments']['gps_notes'] = $this->LociString(substr($loci_data, 13 + $loffset), $loffset); + break; + + default: + $this->warning('Unknown QuickTime atom type: "'.preg_replace('#[^a-zA-Z0-9 _\\-]#', '?', $atomname).'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset); + $atom_structure['data'] = $atom_data; + break; + } + array_pop($atomHierarchy); + return $atom_structure; + } + + public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) { +//echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'

      '; + $atom_structure = false; + $subatomoffset = 0; + $subatomcounter = 0; + if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) { + return false; + } + while ($subatomoffset < strlen($atom_data)) { + $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4)); + $subatomname = substr($atom_data, $subatomoffset + 4, 4); + $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8); + if ($subatomsize == 0) { + // Furthermore, for historical reasons the list of atoms is optionally + // terminated by a 32-bit integer set to 0. If you are writing a program + // to read user data atoms, you should allow for the terminating 0. + if (strlen($atom_data) > 12) { + $subatomoffset += 4; + continue; + } + return $atom_structure; + } + + $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms); + + $subatomoffset += $subatomsize; + $subatomcounter++; + } + return $atom_structure; + } + + + public function quicktime_read_mp4_descr_length($data, &$offset) { + // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html + $num_bytes = 0; + $length = 0; + do { + $b = ord(substr($data, $offset++, 1)); + $length = ($length << 7) | ($b & 0x7F); + } while (($b & 0x80) && ($num_bytes++ < 4)); + return $length; + } + + + public function QuicktimeLanguageLookup($languageid) { + // http://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap4/qtff4.html#//apple_ref/doc/uid/TP40000939-CH206-34353 + static $QuicktimeLanguageLookup = array(); + if (empty($QuicktimeLanguageLookup)) { + $QuicktimeLanguageLookup[0] = 'English'; + $QuicktimeLanguageLookup[1] = 'French'; + $QuicktimeLanguageLookup[2] = 'German'; + $QuicktimeLanguageLookup[3] = 'Italian'; + $QuicktimeLanguageLookup[4] = 'Dutch'; + $QuicktimeLanguageLookup[5] = 'Swedish'; + $QuicktimeLanguageLookup[6] = 'Spanish'; + $QuicktimeLanguageLookup[7] = 'Danish'; + $QuicktimeLanguageLookup[8] = 'Portuguese'; + $QuicktimeLanguageLookup[9] = 'Norwegian'; + $QuicktimeLanguageLookup[10] = 'Hebrew'; + $QuicktimeLanguageLookup[11] = 'Japanese'; + $QuicktimeLanguageLookup[12] = 'Arabic'; + $QuicktimeLanguageLookup[13] = 'Finnish'; + $QuicktimeLanguageLookup[14] = 'Greek'; + $QuicktimeLanguageLookup[15] = 'Icelandic'; + $QuicktimeLanguageLookup[16] = 'Maltese'; + $QuicktimeLanguageLookup[17] = 'Turkish'; + $QuicktimeLanguageLookup[18] = 'Croatian'; + $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)'; + $QuicktimeLanguageLookup[20] = 'Urdu'; + $QuicktimeLanguageLookup[21] = 'Hindi'; + $QuicktimeLanguageLookup[22] = 'Thai'; + $QuicktimeLanguageLookup[23] = 'Korean'; + $QuicktimeLanguageLookup[24] = 'Lithuanian'; + $QuicktimeLanguageLookup[25] = 'Polish'; + $QuicktimeLanguageLookup[26] = 'Hungarian'; + $QuicktimeLanguageLookup[27] = 'Estonian'; + $QuicktimeLanguageLookup[28] = 'Lettish'; + $QuicktimeLanguageLookup[28] = 'Latvian'; + $QuicktimeLanguageLookup[29] = 'Saamisk'; + $QuicktimeLanguageLookup[29] = 'Lappish'; + $QuicktimeLanguageLookup[30] = 'Faeroese'; + $QuicktimeLanguageLookup[31] = 'Farsi'; + $QuicktimeLanguageLookup[31] = 'Persian'; + $QuicktimeLanguageLookup[32] = 'Russian'; + $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)'; + $QuicktimeLanguageLookup[34] = 'Flemish'; + $QuicktimeLanguageLookup[35] = 'Irish'; + $QuicktimeLanguageLookup[36] = 'Albanian'; + $QuicktimeLanguageLookup[37] = 'Romanian'; + $QuicktimeLanguageLookup[38] = 'Czech'; + $QuicktimeLanguageLookup[39] = 'Slovak'; + $QuicktimeLanguageLookup[40] = 'Slovenian'; + $QuicktimeLanguageLookup[41] = 'Yiddish'; + $QuicktimeLanguageLookup[42] = 'Serbian'; + $QuicktimeLanguageLookup[43] = 'Macedonian'; + $QuicktimeLanguageLookup[44] = 'Bulgarian'; + $QuicktimeLanguageLookup[45] = 'Ukrainian'; + $QuicktimeLanguageLookup[46] = 'Byelorussian'; + $QuicktimeLanguageLookup[47] = 'Uzbek'; + $QuicktimeLanguageLookup[48] = 'Kazakh'; + $QuicktimeLanguageLookup[49] = 'Azerbaijani'; + $QuicktimeLanguageLookup[50] = 'AzerbaijanAr'; + $QuicktimeLanguageLookup[51] = 'Armenian'; + $QuicktimeLanguageLookup[52] = 'Georgian'; + $QuicktimeLanguageLookup[53] = 'Moldavian'; + $QuicktimeLanguageLookup[54] = 'Kirghiz'; + $QuicktimeLanguageLookup[55] = 'Tajiki'; + $QuicktimeLanguageLookup[56] = 'Turkmen'; + $QuicktimeLanguageLookup[57] = 'Mongolian'; + $QuicktimeLanguageLookup[58] = 'MongolianCyr'; + $QuicktimeLanguageLookup[59] = 'Pashto'; + $QuicktimeLanguageLookup[60] = 'Kurdish'; + $QuicktimeLanguageLookup[61] = 'Kashmiri'; + $QuicktimeLanguageLookup[62] = 'Sindhi'; + $QuicktimeLanguageLookup[63] = 'Tibetan'; + $QuicktimeLanguageLookup[64] = 'Nepali'; + $QuicktimeLanguageLookup[65] = 'Sanskrit'; + $QuicktimeLanguageLookup[66] = 'Marathi'; + $QuicktimeLanguageLookup[67] = 'Bengali'; + $QuicktimeLanguageLookup[68] = 'Assamese'; + $QuicktimeLanguageLookup[69] = 'Gujarati'; + $QuicktimeLanguageLookup[70] = 'Punjabi'; + $QuicktimeLanguageLookup[71] = 'Oriya'; + $QuicktimeLanguageLookup[72] = 'Malayalam'; + $QuicktimeLanguageLookup[73] = 'Kannada'; + $QuicktimeLanguageLookup[74] = 'Tamil'; + $QuicktimeLanguageLookup[75] = 'Telugu'; + $QuicktimeLanguageLookup[76] = 'Sinhalese'; + $QuicktimeLanguageLookup[77] = 'Burmese'; + $QuicktimeLanguageLookup[78] = 'Khmer'; + $QuicktimeLanguageLookup[79] = 'Lao'; + $QuicktimeLanguageLookup[80] = 'Vietnamese'; + $QuicktimeLanguageLookup[81] = 'Indonesian'; + $QuicktimeLanguageLookup[82] = 'Tagalog'; + $QuicktimeLanguageLookup[83] = 'MalayRoman'; + $QuicktimeLanguageLookup[84] = 'MalayArabic'; + $QuicktimeLanguageLookup[85] = 'Amharic'; + $QuicktimeLanguageLookup[86] = 'Tigrinya'; + $QuicktimeLanguageLookup[87] = 'Galla'; + $QuicktimeLanguageLookup[87] = 'Oromo'; + $QuicktimeLanguageLookup[88] = 'Somali'; + $QuicktimeLanguageLookup[89] = 'Swahili'; + $QuicktimeLanguageLookup[90] = 'Ruanda'; + $QuicktimeLanguageLookup[91] = 'Rundi'; + $QuicktimeLanguageLookup[92] = 'Chewa'; + $QuicktimeLanguageLookup[93] = 'Malagasy'; + $QuicktimeLanguageLookup[94] = 'Esperanto'; + $QuicktimeLanguageLookup[128] = 'Welsh'; + $QuicktimeLanguageLookup[129] = 'Basque'; + $QuicktimeLanguageLookup[130] = 'Catalan'; + $QuicktimeLanguageLookup[131] = 'Latin'; + $QuicktimeLanguageLookup[132] = 'Quechua'; + $QuicktimeLanguageLookup[133] = 'Guarani'; + $QuicktimeLanguageLookup[134] = 'Aymara'; + $QuicktimeLanguageLookup[135] = 'Tatar'; + $QuicktimeLanguageLookup[136] = 'Uighur'; + $QuicktimeLanguageLookup[137] = 'Dzongkha'; + $QuicktimeLanguageLookup[138] = 'JavaneseRom'; + $QuicktimeLanguageLookup[32767] = 'Unspecified'; + } + if (($languageid > 138) && ($languageid < 32767)) { + /* + ISO Language Codes - http://www.loc.gov/standards/iso639-2/php/code_list.php + Because the language codes specified by ISO 639-2/T are three characters long, they must be packed to fit into a 16-bit field. + The packing algorithm must map each of the three characters, which are always lowercase, into a 5-bit integer and then concatenate + these integers into the least significant 15 bits of a 16-bit integer, leaving the 16-bit integer's most significant bit set to zero. + + One algorithm for performing this packing is to treat each ISO character as a 16-bit integer. Subtract 0x60 from the first character + and multiply by 2^10 (0x400), subtract 0x60 from the second character and multiply by 2^5 (0x20), subtract 0x60 from the third character, + and add the three 16-bit values. This will result in a single 16-bit value with the three codes correctly packed into the 15 least + significant bits and the most significant bit set to zero. + */ + $iso_language_id = ''; + $iso_language_id .= chr((($languageid & 0x7C00) >> 10) + 0x60); + $iso_language_id .= chr((($languageid & 0x03E0) >> 5) + 0x60); + $iso_language_id .= chr((($languageid & 0x001F) >> 0) + 0x60); + $QuicktimeLanguageLookup[$languageid] = getid3_id3v2::LanguageLookup($iso_language_id); + } + return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid'); + } + + public function QuicktimeVideoCodecLookup($codecid) { + static $QuicktimeVideoCodecLookup = array(); + if (empty($QuicktimeVideoCodecLookup)) { + $QuicktimeVideoCodecLookup['.SGI'] = 'SGI'; + $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1'; + $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2'; + $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4'; + $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB'; + $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC'; + $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG'; + $QuicktimeVideoCodecLookup['b16g'] = '16Gray'; + $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray'; + $QuicktimeVideoCodecLookup['b48r'] = '48RGB'; + $QuicktimeVideoCodecLookup['b64a'] = '64ARGB'; + $QuicktimeVideoCodecLookup['base'] = 'Base'; + $QuicktimeVideoCodecLookup['clou'] = 'Cloud'; + $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK'; + $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak'; + $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG'; + $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC'; + $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL'; + $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC'; + $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL'; + $QuicktimeVideoCodecLookup['fire'] = 'Fire'; + $QuicktimeVideoCodecLookup['flic'] = 'FLC'; + $QuicktimeVideoCodecLookup['gif '] = 'GIF'; + $QuicktimeVideoCodecLookup['h261'] = 'H261'; + $QuicktimeVideoCodecLookup['h263'] = 'H263'; + $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4'; + $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG'; + $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD'; + $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A'; + $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B'; + $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1'; + $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420'; + $QuicktimeVideoCodecLookup['path'] = 'Vector'; + $QuicktimeVideoCodecLookup['png '] = 'PNG'; + $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint'; + $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX'; + $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw'; + $QuicktimeVideoCodecLookup['raw '] = 'RAW'; + $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple'; + $QuicktimeVideoCodecLookup['rpza'] = 'Video'; + $QuicktimeVideoCodecLookup['smc '] = 'Graphics'; + $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1'; + $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3'; + $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9'; + $QuicktimeVideoCodecLookup['tga '] = 'Targa'; + $QuicktimeVideoCodecLookup['tiff'] = 'TIFF'; + $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW'; + $QuicktimeVideoCodecLookup['WRLE'] = 'BMP'; + $QuicktimeVideoCodecLookup['y420'] = 'YUV420'; + $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo'; + $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned'; + $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned'; + } + return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : ''); + } + + public function QuicktimeAudioCodecLookup($codecid) { + static $QuicktimeAudioCodecLookup = array(); + if (empty($QuicktimeAudioCodecLookup)) { + $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias'; + $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC'; + $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1'; + $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec'; + $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1'; + $QuicktimeAudioCodecLookup['conv'] = 'Sample Format'; + $QuicktimeAudioCodecLookup['dvca'] = 'DV'; + $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1'; + $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer'; + $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point'; + $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point'; + $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1'; + $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer'; + $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer'; + $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1'; + $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1'; + $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1'; + $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer'; + $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer'; + $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC'; + $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM'; + $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA'; + $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III'; + $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding'; + $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice'; + $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2'; + $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1'; + $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate'; + $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate'; + $QuicktimeAudioCodecLookup['raw '] = 'raw PCM'; + $QuicktimeAudioCodecLookup['sour'] = 'Sound Source'; + $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)'; + $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II'; + $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II'; + $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II'; + $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II'; + $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)'; + $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1'; + } + return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : ''); + } + + public function QuicktimeDCOMLookup($compressionid) { + static $QuicktimeDCOMLookup = array(); + if (empty($QuicktimeDCOMLookup)) { + $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate'; + $QuicktimeDCOMLookup['adec'] = 'Apple Compression'; + } + return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : ''); + } + + public function QuicktimeColorNameLookup($colordepthid) { + static $QuicktimeColorNameLookup = array(); + if (empty($QuicktimeColorNameLookup)) { + $QuicktimeColorNameLookup[1] = '2-color (monochrome)'; + $QuicktimeColorNameLookup[2] = '4-color'; + $QuicktimeColorNameLookup[4] = '16-color'; + $QuicktimeColorNameLookup[8] = '256-color'; + $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)'; + $QuicktimeColorNameLookup[24] = 'millions (24-bit color)'; + $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)'; + $QuicktimeColorNameLookup[33] = 'black & white'; + $QuicktimeColorNameLookup[34] = '4-gray'; + $QuicktimeColorNameLookup[36] = '16-gray'; + $QuicktimeColorNameLookup[40] = '256-gray'; + } + return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid'); + } + + public function QuicktimeSTIKLookup($stik) { + static $QuicktimeSTIKLookup = array(); + if (empty($QuicktimeSTIKLookup)) { + $QuicktimeSTIKLookup[0] = 'Movie'; + $QuicktimeSTIKLookup[1] = 'Normal'; + $QuicktimeSTIKLookup[2] = 'Audiobook'; + $QuicktimeSTIKLookup[5] = 'Whacked Bookmark'; + $QuicktimeSTIKLookup[6] = 'Music Video'; + $QuicktimeSTIKLookup[9] = 'Short Film'; + $QuicktimeSTIKLookup[10] = 'TV Show'; + $QuicktimeSTIKLookup[11] = 'Booklet'; + $QuicktimeSTIKLookup[14] = 'Ringtone'; + $QuicktimeSTIKLookup[21] = 'Podcast'; + } + return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid'); + } + + public function QuicktimeIODSaudioProfileName($audio_profile_id) { + static $QuicktimeIODSaudioProfileNameLookup = array(); + if (empty($QuicktimeIODSaudioProfileNameLookup)) { + $QuicktimeIODSaudioProfileNameLookup = array( + 0x00 => 'ISO Reserved (0x00)', + 0x01 => 'Main Audio Profile @ Level 1', + 0x02 => 'Main Audio Profile @ Level 2', + 0x03 => 'Main Audio Profile @ Level 3', + 0x04 => 'Main Audio Profile @ Level 4', + 0x05 => 'Scalable Audio Profile @ Level 1', + 0x06 => 'Scalable Audio Profile @ Level 2', + 0x07 => 'Scalable Audio Profile @ Level 3', + 0x08 => 'Scalable Audio Profile @ Level 4', + 0x09 => 'Speech Audio Profile @ Level 1', + 0x0A => 'Speech Audio Profile @ Level 2', + 0x0B => 'Synthetic Audio Profile @ Level 1', + 0x0C => 'Synthetic Audio Profile @ Level 2', + 0x0D => 'Synthetic Audio Profile @ Level 3', + 0x0E => 'High Quality Audio Profile @ Level 1', + 0x0F => 'High Quality Audio Profile @ Level 2', + 0x10 => 'High Quality Audio Profile @ Level 3', + 0x11 => 'High Quality Audio Profile @ Level 4', + 0x12 => 'High Quality Audio Profile @ Level 5', + 0x13 => 'High Quality Audio Profile @ Level 6', + 0x14 => 'High Quality Audio Profile @ Level 7', + 0x15 => 'High Quality Audio Profile @ Level 8', + 0x16 => 'Low Delay Audio Profile @ Level 1', + 0x17 => 'Low Delay Audio Profile @ Level 2', + 0x18 => 'Low Delay Audio Profile @ Level 3', + 0x19 => 'Low Delay Audio Profile @ Level 4', + 0x1A => 'Low Delay Audio Profile @ Level 5', + 0x1B => 'Low Delay Audio Profile @ Level 6', + 0x1C => 'Low Delay Audio Profile @ Level 7', + 0x1D => 'Low Delay Audio Profile @ Level 8', + 0x1E => 'Natural Audio Profile @ Level 1', + 0x1F => 'Natural Audio Profile @ Level 2', + 0x20 => 'Natural Audio Profile @ Level 3', + 0x21 => 'Natural Audio Profile @ Level 4', + 0x22 => 'Mobile Audio Internetworking Profile @ Level 1', + 0x23 => 'Mobile Audio Internetworking Profile @ Level 2', + 0x24 => 'Mobile Audio Internetworking Profile @ Level 3', + 0x25 => 'Mobile Audio Internetworking Profile @ Level 4', + 0x26 => 'Mobile Audio Internetworking Profile @ Level 5', + 0x27 => 'Mobile Audio Internetworking Profile @ Level 6', + 0x28 => 'AAC Profile @ Level 1', + 0x29 => 'AAC Profile @ Level 2', + 0x2A => 'AAC Profile @ Level 4', + 0x2B => 'AAC Profile @ Level 5', + 0x2C => 'High Efficiency AAC Profile @ Level 2', + 0x2D => 'High Efficiency AAC Profile @ Level 3', + 0x2E => 'High Efficiency AAC Profile @ Level 4', + 0x2F => 'High Efficiency AAC Profile @ Level 5', + 0xFE => 'Not part of MPEG-4 audio profiles', + 0xFF => 'No audio capability required', + ); + } + return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private'); + } + + + public function QuicktimeIODSvideoProfileName($video_profile_id) { + static $QuicktimeIODSvideoProfileNameLookup = array(); + if (empty($QuicktimeIODSvideoProfileNameLookup)) { + $QuicktimeIODSvideoProfileNameLookup = array( + 0x00 => 'Reserved (0x00) Profile', + 0x01 => 'Simple Profile @ Level 1', + 0x02 => 'Simple Profile @ Level 2', + 0x03 => 'Simple Profile @ Level 3', + 0x08 => 'Simple Profile @ Level 0', + 0x10 => 'Simple Scalable Profile @ Level 0', + 0x11 => 'Simple Scalable Profile @ Level 1', + 0x12 => 'Simple Scalable Profile @ Level 2', + 0x15 => 'AVC/H264 Profile', + 0x21 => 'Core Profile @ Level 1', + 0x22 => 'Core Profile @ Level 2', + 0x32 => 'Main Profile @ Level 2', + 0x33 => 'Main Profile @ Level 3', + 0x34 => 'Main Profile @ Level 4', + 0x42 => 'N-bit Profile @ Level 2', + 0x51 => 'Scalable Texture Profile @ Level 1', + 0x61 => 'Simple Face Animation Profile @ Level 1', + 0x62 => 'Simple Face Animation Profile @ Level 2', + 0x63 => 'Simple FBA Profile @ Level 1', + 0x64 => 'Simple FBA Profile @ Level 2', + 0x71 => 'Basic Animated Texture Profile @ Level 1', + 0x72 => 'Basic Animated Texture Profile @ Level 2', + 0x81 => 'Hybrid Profile @ Level 1', + 0x82 => 'Hybrid Profile @ Level 2', + 0x91 => 'Advanced Real Time Simple Profile @ Level 1', + 0x92 => 'Advanced Real Time Simple Profile @ Level 2', + 0x93 => 'Advanced Real Time Simple Profile @ Level 3', + 0x94 => 'Advanced Real Time Simple Profile @ Level 4', + 0xA1 => 'Core Scalable Profile @ Level1', + 0xA2 => 'Core Scalable Profile @ Level2', + 0xA3 => 'Core Scalable Profile @ Level3', + 0xB1 => 'Advanced Coding Efficiency Profile @ Level 1', + 0xB2 => 'Advanced Coding Efficiency Profile @ Level 2', + 0xB3 => 'Advanced Coding Efficiency Profile @ Level 3', + 0xB4 => 'Advanced Coding Efficiency Profile @ Level 4', + 0xC1 => 'Advanced Core Profile @ Level 1', + 0xC2 => 'Advanced Core Profile @ Level 2', + 0xD1 => 'Advanced Scalable Texture @ Level1', + 0xD2 => 'Advanced Scalable Texture @ Level2', + 0xE1 => 'Simple Studio Profile @ Level 1', + 0xE2 => 'Simple Studio Profile @ Level 2', + 0xE3 => 'Simple Studio Profile @ Level 3', + 0xE4 => 'Simple Studio Profile @ Level 4', + 0xE5 => 'Core Studio Profile @ Level 1', + 0xE6 => 'Core Studio Profile @ Level 2', + 0xE7 => 'Core Studio Profile @ Level 3', + 0xE8 => 'Core Studio Profile @ Level 4', + 0xF0 => 'Advanced Simple Profile @ Level 0', + 0xF1 => 'Advanced Simple Profile @ Level 1', + 0xF2 => 'Advanced Simple Profile @ Level 2', + 0xF3 => 'Advanced Simple Profile @ Level 3', + 0xF4 => 'Advanced Simple Profile @ Level 4', + 0xF5 => 'Advanced Simple Profile @ Level 5', + 0xF7 => 'Advanced Simple Profile @ Level 3b', + 0xF8 => 'Fine Granularity Scalable Profile @ Level 0', + 0xF9 => 'Fine Granularity Scalable Profile @ Level 1', + 0xFA => 'Fine Granularity Scalable Profile @ Level 2', + 0xFB => 'Fine Granularity Scalable Profile @ Level 3', + 0xFC => 'Fine Granularity Scalable Profile @ Level 4', + 0xFD => 'Fine Granularity Scalable Profile @ Level 5', + 0xFE => 'Not part of MPEG-4 Visual profiles', + 0xFF => 'No visual capability required', + ); + } + return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile'); + } + + + public function QuicktimeContentRatingLookup($rtng) { + static $QuicktimeContentRatingLookup = array(); + if (empty($QuicktimeContentRatingLookup)) { + $QuicktimeContentRatingLookup[0] = 'None'; + $QuicktimeContentRatingLookup[2] = 'Clean'; + $QuicktimeContentRatingLookup[4] = 'Explicit'; + } + return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid'); + } + + public function QuicktimeStoreAccountTypeLookup($akid) { + static $QuicktimeStoreAccountTypeLookup = array(); + if (empty($QuicktimeStoreAccountTypeLookup)) { + $QuicktimeStoreAccountTypeLookup[0] = 'iTunes'; + $QuicktimeStoreAccountTypeLookup[1] = 'AOL'; + } + return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid'); + } + + public function QuicktimeStoreFrontCodeLookup($sfid) { + static $QuicktimeStoreFrontCodeLookup = array(); + if (empty($QuicktimeStoreFrontCodeLookup)) { + $QuicktimeStoreFrontCodeLookup[143460] = 'Australia'; + $QuicktimeStoreFrontCodeLookup[143445] = 'Austria'; + $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium'; + $QuicktimeStoreFrontCodeLookup[143455] = 'Canada'; + $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark'; + $QuicktimeStoreFrontCodeLookup[143447] = 'Finland'; + $QuicktimeStoreFrontCodeLookup[143442] = 'France'; + $QuicktimeStoreFrontCodeLookup[143443] = 'Germany'; + $QuicktimeStoreFrontCodeLookup[143448] = 'Greece'; + $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland'; + $QuicktimeStoreFrontCodeLookup[143450] = 'Italy'; + $QuicktimeStoreFrontCodeLookup[143462] = 'Japan'; + $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg'; + $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands'; + $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand'; + $QuicktimeStoreFrontCodeLookup[143457] = 'Norway'; + $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal'; + $QuicktimeStoreFrontCodeLookup[143454] = 'Spain'; + $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden'; + $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland'; + $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom'; + $QuicktimeStoreFrontCodeLookup[143441] = 'United States'; + } + return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid'); + } + + public function QuicktimeParseNikonNCTG($atom_data) { + // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG + // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100 + // Data is stored as records of: + // * 4 bytes record type + // * 2 bytes size of data field type: + // 0x0001 = flag (size field *= 1-byte) + // 0x0002 = char (size field *= 1-byte) + // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB + // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD + // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together + // 0x0007 = bytes (size field *= 1-byte), values are stored as ?????? + // 0x0008 = ????? (size field *= 2-byte), values are stored as ?????? + // * 2 bytes data size field + // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15") + // all integers are stored BigEndian + + $NCTGtagName = array( + 0x00000001 => 'Make', + 0x00000002 => 'Model', + 0x00000003 => 'Software', + 0x00000011 => 'CreateDate', + 0x00000012 => 'DateTimeOriginal', + 0x00000013 => 'FrameCount', + 0x00000016 => 'FrameRate', + 0x00000022 => 'FrameWidth', + 0x00000023 => 'FrameHeight', + 0x00000032 => 'AudioChannels', + 0x00000033 => 'AudioBitsPerSample', + 0x00000034 => 'AudioSampleRate', + 0x02000001 => 'MakerNoteVersion', + 0x02000005 => 'WhiteBalance', + 0x0200000b => 'WhiteBalanceFineTune', + 0x0200001e => 'ColorSpace', + 0x02000023 => 'PictureControlData', + 0x02000024 => 'WorldTime', + 0x02000032 => 'UnknownInfo', + 0x02000083 => 'LensType', + 0x02000084 => 'Lens', + ); + + $offset = 0; + $datalength = strlen($atom_data); + $parsed = array(); + while ($offset < $datalength) { +//echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'
      '; + $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4; + $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2; + $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2; + switch ($data_size_type) { + case 0x0001: // 0x0001 = flag (size field *= 1-byte) + $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1)); + $offset += ($data_size * 1); + break; + case 0x0002: // 0x0002 = char (size field *= 1-byte) + $data = substr($atom_data, $offset, $data_size * 1); + $offset += ($data_size * 1); + $data = rtrim($data, "\x00"); + break; + case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB + $data = ''; + for ($i = $data_size - 1; $i >= 0; $i--) { + $data .= substr($atom_data, $offset + ($i * 2), 2); + } + $data = getid3_lib::BigEndian2Int($data); + $offset += ($data_size * 2); + break; + case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD + $data = ''; + for ($i = $data_size - 1; $i >= 0; $i--) { + $data .= substr($atom_data, $offset + ($i * 4), 4); + } + $data = getid3_lib::BigEndian2Int($data); + $offset += ($data_size * 4); + break; + case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together + $data = array(); + for ($i = 0; $i < $data_size; $i++) { + $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4)); + $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4)); + if ($denomninator == 0) { + $data[$i] = false; + } else { + $data[$i] = (double) $numerator / $denomninator; + } + } + $offset += (8 * $data_size); + if (count($data) == 1) { + $data = $data[0]; + } + break; + case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ?????? + $data = substr($atom_data, $offset, $data_size * 1); + $offset += ($data_size * 1); + break; + case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ?????? + $data = substr($atom_data, $offset, $data_size * 2); + $offset += ($data_size * 2); + break; + default: +echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'
      '; + break 2; + } + + switch ($record_type) { + case 0x00000011: // CreateDate + case 0x00000012: // DateTimeOriginal + $data = strtotime($data); + break; + case 0x0200001e: // ColorSpace + switch ($data) { + case 1: + $data = 'sRGB'; + break; + case 2: + $data = 'Adobe RGB'; + break; + } + break; + case 0x02000023: // PictureControlData + $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full'); + $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a'); + $ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a'); + $data = array( + 'PictureControlVersion' => substr($data, 0, 4), + 'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"), + 'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"), + //'?' => substr($data, 44, 4), + 'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))], + 'PictureControlQuickAdjust' => ord(substr($data, 49, 1)), + 'Sharpness' => ord(substr($data, 50, 1)), + 'Contrast' => ord(substr($data, 51, 1)), + 'Brightness' => ord(substr($data, 52, 1)), + 'Saturation' => ord(substr($data, 53, 1)), + 'HueAdjustment' => ord(substr($data, 54, 1)), + 'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))], + 'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))], + 'ToningSaturation' => ord(substr($data, 57, 1)), + ); + break; + case 0x02000024: // WorldTime + // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime + // timezone is stored as offset from GMT in minutes + $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2)); + if ($timezone & 0x8000) { + $timezone = 0 - (0x10000 - $timezone); + } + $timezone /= 60; + + $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1)); + switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) { + case 2: + $datedisplayformat = 'D/M/Y'; break; + case 1: + $datedisplayformat = 'M/D/Y'; break; + case 0: + default: + $datedisplayformat = 'Y/M/D'; break; + } + + $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat); + break; + case 0x02000083: // LensType + $data = array( + //'_' => $data, + 'mf' => (bool) ($data & 0x01), + 'd' => (bool) ($data & 0x02), + 'g' => (bool) ($data & 0x04), + 'vr' => (bool) ($data & 0x08), + ); + break; + } + $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT)); + $parsed[$tag_name] = $data; + } + return $parsed; + } + + + public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') { + static $handyatomtranslatorarray = array(); + if (empty($handyatomtranslatorarray)) { + // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt + // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt + // http://atomicparsley.sourceforge.net/mpeg-4files.html + // https://code.google.com/p/mp4v2/wiki/iTunesMetadata + $handyatomtranslatorarray["\xA9".'alb'] = 'album'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'ART'] = 'artist'; + $handyatomtranslatorarray["\xA9".'art'] = 'artist'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'aut'] = 'author'; + $handyatomtranslatorarray["\xA9".'cmt'] = 'comment'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'com'] = 'comment'; + $handyatomtranslatorarray["\xA9".'cpy'] = 'copyright'; + $handyatomtranslatorarray["\xA9".'day'] = 'creation_date'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'dir'] = 'director'; + $handyatomtranslatorarray["\xA9".'ed1'] = 'edit1'; + $handyatomtranslatorarray["\xA9".'ed2'] = 'edit2'; + $handyatomtranslatorarray["\xA9".'ed3'] = 'edit3'; + $handyatomtranslatorarray["\xA9".'ed4'] = 'edit4'; + $handyatomtranslatorarray["\xA9".'ed5'] = 'edit5'; + $handyatomtranslatorarray["\xA9".'ed6'] = 'edit6'; + $handyatomtranslatorarray["\xA9".'ed7'] = 'edit7'; + $handyatomtranslatorarray["\xA9".'ed8'] = 'edit8'; + $handyatomtranslatorarray["\xA9".'ed9'] = 'edit9'; + $handyatomtranslatorarray["\xA9".'enc'] = 'encoded_by'; + $handyatomtranslatorarray["\xA9".'fmt'] = 'format'; + $handyatomtranslatorarray["\xA9".'gen'] = 'genre'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'grp'] = 'grouping'; // iTunes 4.2 + $handyatomtranslatorarray["\xA9".'hst'] = 'host_computer'; + $handyatomtranslatorarray["\xA9".'inf'] = 'information'; + $handyatomtranslatorarray["\xA9".'lyr'] = 'lyrics'; // iTunes 5.0 + $handyatomtranslatorarray["\xA9".'mak'] = 'make'; + $handyatomtranslatorarray["\xA9".'mod'] = 'model'; + $handyatomtranslatorarray["\xA9".'nam'] = 'title'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'ope'] = 'composer'; + $handyatomtranslatorarray["\xA9".'prd'] = 'producer'; + $handyatomtranslatorarray["\xA9".'PRD'] = 'product'; + $handyatomtranslatorarray["\xA9".'prf'] = 'performers'; + $handyatomtranslatorarray["\xA9".'req'] = 'system_requirements'; + $handyatomtranslatorarray["\xA9".'src'] = 'source_credit'; + $handyatomtranslatorarray["\xA9".'swr'] = 'software'; + $handyatomtranslatorarray["\xA9".'too'] = 'encoding_tool'; // iTunes 4.0 + $handyatomtranslatorarray["\xA9".'trk'] = 'track'; + $handyatomtranslatorarray["\xA9".'url'] = 'url'; + $handyatomtranslatorarray["\xA9".'wrn'] = 'warning'; + $handyatomtranslatorarray["\xA9".'wrt'] = 'composer'; + $handyatomtranslatorarray['aART'] = 'album_artist'; + $handyatomtranslatorarray['apID'] = 'purchase_account'; + $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9 + $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0 + $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0 + $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0? + $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0 + $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0 + $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9 + $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0 + $handyatomtranslatorarray['hdvd'] = 'hd_video'; // iTunes 4.0 + $handyatomtranslatorarray['ldes'] = 'description_long'; // + $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9 + $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9 + $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0 + $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2 + $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9 + $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0 + $handyatomtranslatorarray['soaa'] = 'sort_album_artist'; // + $handyatomtranslatorarray['soal'] = 'sort_album'; // + $handyatomtranslatorarray['soar'] = 'sort_artist'; // + $handyatomtranslatorarray['soco'] = 'sort_composer'; // + $handyatomtranslatorarray['sonm'] = 'sort_title'; // + $handyatomtranslatorarray['sosn'] = 'sort_show'; // + $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9 + $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0 + $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0 + $handyatomtranslatorarray['tven'] = 'tv_episode_id'; // + $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0 + $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0 + $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0 + $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0 + + // boxnames: + /* + $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB'; + $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM'; + $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params'; + $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain'; + $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak'; + $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax'; + $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID'; + $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id'; + $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id'; + $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id'; + $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id'; + $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id'; + + // http://age.hobba.nl/audio/tag_frame_reference.html + $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355 + $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355 + */ + } + $info = &$this->getid3->info; + $comment_key = ''; + if ($boxname && ($boxname != $keyname)) { + $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname); + } elseif (isset($handyatomtranslatorarray[$keyname])) { + $comment_key = $handyatomtranslatorarray[$keyname]; + } + if ($comment_key) { + if ($comment_key == 'picture') { + if (!is_array($data)) { + $image_mime = ''; + if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) { + $image_mime = 'image/png'; + } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) { + $image_mime = 'image/jpeg'; + } elseif (preg_match('#^GIF#', $data)) { + $image_mime = 'image/gif'; + } elseif (preg_match('#^BM#', $data)) { + $image_mime = 'image/bmp'; + } + $data = array('data'=>$data, 'image_mime'=>$image_mime); + } + } + $gooddata = array($data); + if ($comment_key == 'genre') { + // some other taggers separate multiple genres with semicolon, e.g. "Heavy Metal;Thrash Metal;Metal" + $gooddata = explode(';', $data); + } + foreach ($gooddata as $data) { + $info['quicktime']['comments'][$comment_key][] = $data; + } + } + return true; + } + + public function LociString($lstring, &$count) { + // Loci strings are UTF-8 or UTF-16 and null (x00/x0000) terminated. UTF-16 has a BOM + // Also need to return the number of bytes the string occupied so additional fields can be extracted + $len = strlen($lstring); + if ($len == 0) { + $count = 0; + return ''; + } + if ($lstring[0] == "\x00") { + $count = 1; + return ''; + } + //check for BOM + if ($len > 2 && (($lstring[0] == "\xFE" && $lstring[1] == "\xFF") || ($lstring[0] == "\xFF" && $lstring[1] == "\xFE"))) { + //UTF-16 + if (preg_match('/(.*)\x00/', $lstring, $lmatches)){ + $count = strlen($lmatches[1]) * 2 + 2; //account for 2 byte characters and trailing \x0000 + return getid3_lib::iconv_fallback_utf16_utf8($lmatches[1]); + } else { + return ''; + } + } else { + //UTF-8 + if (preg_match('/(.*)\x00/', $lstring, $lmatches)){ + $count = strlen($lmatches[1]) + 1; //account for trailing \x00 + return $lmatches[1]; + }else { + return ''; + } + + } + } + + public function NoNullString($nullterminatedstring) { + // remove the single null terminator on null terminated strings + if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") { + return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1); + } + return $nullterminatedstring; + } + + public function Pascal2String($pascalstring) { + // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string + return substr($pascalstring, 1); + } + + + /* + // helper functions for m4b audiobook chapters + // code by Steffen Hartmann 2015-Nov-08 + */ + public function search_tag_by_key($info, $tag, $history, &$result) { + foreach ($info as $key => $value) { + $key_history = $history.'/'.$key; + if ($key === $tag) { + $result[] = array($key_history, $info); + } else { + if (is_array($value)) { + $this->search_tag_by_key($value, $tag, $key_history, $result); + } + } + } + } + + public function search_tag_by_pair($info, $k, $v, $history, &$result) { + foreach ($info as $key => $value) { + $key_history = $history.'/'.$key; + if (($key === $k) && ($value === $v)) { + $result[] = array($key_history, $info); + } else { + if (is_array($value)) { + $this->search_tag_by_pair($value, $k, $v, $key_history, $result); + } + } + } + } + + public function quicktime_time_to_sample_table($info) { + $res = array(); + $this->search_tag_by_pair($info['quicktime']['moov'], 'name', 'stbl', 'quicktime/moov', $res); + foreach ($res as $value) { + $stbl_res = array(); + $this->search_tag_by_pair($value[1], 'data_format', 'text', $value[0], $stbl_res); + if (count($stbl_res) > 0) { + $stts_res = array(); + $this->search_tag_by_key($value[1], 'time_to_sample_table', $value[0], $stts_res); + if (count($stts_res) > 0) { + return $stts_res[0][1]['time_to_sample_table']; + } + } + } + return array(); + } + + function quicktime_bookmark_time_scale($info) { + $time_scale = ''; + $ts_prefix_len = 0; + $res = array(); + $this->search_tag_by_pair($info['quicktime']['moov'], 'name', 'stbl', 'quicktime/moov', $res); + foreach ($res as $value) { + $stbl_res = array(); + $this->search_tag_by_pair($value[1], 'data_format', 'text', $value[0], $stbl_res); + if (count($stbl_res) > 0) { + $ts_res = array(); + $this->search_tag_by_key($info['quicktime']['moov'], 'time_scale', 'quicktime/moov', $ts_res); + foreach ($ts_res as $value) { + $prefix = substr($value[0], 0, -12); + if ((substr($stbl_res[0][0], 0, strlen($prefix)) === $prefix) && ($ts_prefix_len < strlen($prefix))) { + $time_scale = $value[1]['time_scale']; + $ts_prefix_len = strlen($prefix); + } + } + } + } + return $time_scale; + } + /* + // END helper functions for m4b audiobook chapters + */ + + +} diff --git a/backend/wp-includes/ID3/module.audio-video.riff.php b/backend/wp-includes/ID3/module.audio-video.riff.php new file mode 100644 index 0000000..53f9350 --- /dev/null +++ b/backend/wp-includes/ID3/module.audio-video.riff.php @@ -0,0 +1,2638 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio-video.riff.php // +// module for analyzing RIFF files // +// multiple formats supported by this module: // +// Wave, AVI, AIFF/AIFC, (MP3,AC3)/RIFF, Wavpack v3, 8SVX // +// dependencies: module.audio.mp3.php // +// module.audio.ac3.php // +// module.audio.dts.php // +// /// +///////////////////////////////////////////////////////////////// + +/** +* @todo Parse AC-3/DTS audio inside WAVE correctly +* @todo Rewrite RIFF parser totally +*/ + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true); +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true); +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.dts.php', __FILE__, true); + +class getid3_riff extends getid3_handler { + + protected $container = 'riff'; // default + + public function Analyze() { + $info = &$this->getid3->info; + + // initialize these values to an empty array, otherwise they default to NULL + // and you can't append array values to a NULL value + $info['riff'] = array('raw'=>array()); + + // Shortcuts + $thisfile_riff = &$info['riff']; + $thisfile_riff_raw = &$thisfile_riff['raw']; + $thisfile_audio = &$info['audio']; + $thisfile_video = &$info['video']; + $thisfile_audio_dataformat = &$thisfile_audio['dataformat']; + $thisfile_riff_audio = &$thisfile_riff['audio']; + $thisfile_riff_video = &$thisfile_riff['video']; + + $Original['avdataoffset'] = $info['avdataoffset']; + $Original['avdataend'] = $info['avdataend']; + + $this->fseek($info['avdataoffset']); + $RIFFheader = $this->fread(12); + $offset = $this->ftell(); + $RIFFtype = substr($RIFFheader, 0, 4); + $RIFFsize = substr($RIFFheader, 4, 4); + $RIFFsubtype = substr($RIFFheader, 8, 4); + + switch ($RIFFtype) { + + case 'FORM': // AIFF, AIFC + //$info['fileformat'] = 'aiff'; + $this->container = 'aiff'; + $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize); + $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); + break; + + case 'RIFF': // AVI, WAV, etc + case 'SDSS': // SDSS is identical to RIFF, just renamed. Used by SmartSound QuickTracks (www.smartsound.com) + case 'RMP3': // RMP3 is identical to RIFF, just renamed. Used by [unknown program] when creating RIFF-MP3s + //$info['fileformat'] = 'riff'; + $this->container = 'riff'; + $thisfile_riff['header_size'] = $this->EitherEndian2Int($RIFFsize); + if ($RIFFsubtype == 'RMP3') { + // RMP3 is identical to WAVE, just renamed. Used by [unknown program] when creating RIFF-MP3s + $RIFFsubtype = 'WAVE'; + } + if ($RIFFsubtype != 'AMV ') { + // AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size + // Handled separately in ParseRIFFAMV() + $thisfile_riff[$RIFFsubtype] = $this->ParseRIFF($offset, ($offset + $thisfile_riff['header_size'] - 4)); + } + if (($info['avdataend'] - $info['filesize']) == 1) { + // LiteWave appears to incorrectly *not* pad actual output file + // to nearest WORD boundary so may appear to be short by one + // byte, in which case - skip warning + $info['avdataend'] = $info['filesize']; + } + + $nextRIFFoffset = $Original['avdataoffset'] + 8 + $thisfile_riff['header_size']; // 8 = "RIFF" + 32-bit offset + while ($nextRIFFoffset < min($info['filesize'], $info['avdataend'])) { + try { + $this->fseek($nextRIFFoffset); + } catch (getid3_exception $e) { + if ($e->getCode() == 10) { + //$this->warning('RIFF parser: '.$e->getMessage()); + $this->error('AVI extends beyond '.round(PHP_INT_MAX / 1073741824).'GB and PHP filesystem functions cannot read that far, playtime may be wrong'); + $this->warning('[avdataend] value may be incorrect, multiple AVIX chunks may be present'); + break; + } else { + throw $e; + } + } + $nextRIFFheader = $this->fread(12); + if ($nextRIFFoffset == ($info['avdataend'] - 1)) { + if (substr($nextRIFFheader, 0, 1) == "\x00") { + // RIFF padded to WORD boundary, we're actually already at the end + break; + } + } + $nextRIFFheaderID = substr($nextRIFFheader, 0, 4); + $nextRIFFsize = $this->EitherEndian2Int(substr($nextRIFFheader, 4, 4)); + $nextRIFFtype = substr($nextRIFFheader, 8, 4); + $chunkdata = array(); + $chunkdata['offset'] = $nextRIFFoffset + 8; + $chunkdata['size'] = $nextRIFFsize; + $nextRIFFoffset = $chunkdata['offset'] + $chunkdata['size']; + + switch ($nextRIFFheaderID) { + case 'RIFF': + $chunkdata['chunks'] = $this->ParseRIFF($chunkdata['offset'] + 4, $nextRIFFoffset); + if (!isset($thisfile_riff[$nextRIFFtype])) { + $thisfile_riff[$nextRIFFtype] = array(); + } + $thisfile_riff[$nextRIFFtype][] = $chunkdata; + break; + + case 'AMV ': + unset($info['riff']); + $info['amv'] = $this->ParseRIFFAMV($chunkdata['offset'] + 4, $nextRIFFoffset); + break; + + case 'JUNK': + // ignore + $thisfile_riff[$nextRIFFheaderID][] = $chunkdata; + break; + + case 'IDVX': + $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunkdata['size'])); + break; + + default: + if ($info['filesize'] == ($chunkdata['offset'] - 8 + 128)) { + $DIVXTAG = $nextRIFFheader.$this->fread(128 - 12); + if (substr($DIVXTAG, -7) == 'DIVXTAG') { + // DIVXTAG is supposed to be inside an IDVX chunk in a LIST chunk, but some bad encoders just slap it on the end of a file + $this->warning('Found wrongly-structured DIVXTAG at offset '.($this->ftell() - 128).', parsing anyway'); + $info['divxtag']['comments'] = self::ParseDIVXTAG($DIVXTAG); + break 2; + } + } + $this->warning('Expecting "RIFF|JUNK|IDVX" at '.$nextRIFFoffset.', found "'.$nextRIFFheaderID.'" ('.getid3_lib::PrintHexBytes($nextRIFFheaderID).') - skipping rest of file'); + break 2; + + } + + } + if ($RIFFsubtype == 'WAVE') { + $thisfile_riff_WAVE = &$thisfile_riff['WAVE']; + } + break; + + default: + $this->error('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$RIFFsubtype.'" instead'); + //unset($info['fileformat']); + return false; + } + + $streamindex = 0; + switch ($RIFFsubtype) { + + // http://en.wikipedia.org/wiki/Wav + case 'WAVE': + $info['fileformat'] = 'wav'; + + if (empty($thisfile_audio['bitrate_mode'])) { + $thisfile_audio['bitrate_mode'] = 'cbr'; + } + if (empty($thisfile_audio_dataformat)) { + $thisfile_audio_dataformat = 'wav'; + } + + if (isset($thisfile_riff_WAVE['data'][0]['offset'])) { + $info['avdataoffset'] = $thisfile_riff_WAVE['data'][0]['offset'] + 8; + $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff_WAVE['data'][0]['size']; + } + if (isset($thisfile_riff_WAVE['fmt '][0]['data'])) { + + $thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($thisfile_riff_WAVE['fmt '][0]['data']); + $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag']; + if (!isset($thisfile_riff_audio[$streamindex]['bitrate']) || ($thisfile_riff_audio[$streamindex]['bitrate'] == 0)) { + $this->error('Corrupt RIFF file: bitrate_audio == zero'); + return false; + } + $thisfile_riff_raw['fmt '] = $thisfile_riff_audio[$streamindex]['raw']; + unset($thisfile_riff_audio[$streamindex]['raw']); + $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex]; + + $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]); + if (substr($thisfile_audio['codec'], 0, strlen('unknown: 0x')) == 'unknown: 0x') { + $this->warning('Audio codec = '.$thisfile_audio['codec']); + } + $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate']; + + if (empty($info['playtime_seconds'])) { // may already be set (e.g. DTS-WAV) + $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']); + } + + $thisfile_audio['lossless'] = false; + if (isset($thisfile_riff_WAVE['data'][0]['offset']) && isset($thisfile_riff_raw['fmt ']['wFormatTag'])) { + switch ($thisfile_riff_raw['fmt ']['wFormatTag']) { + + case 0x0001: // PCM + $thisfile_audio['lossless'] = true; + break; + + case 0x2000: // AC-3 + $thisfile_audio_dataformat = 'ac3'; + break; + + default: + // do nothing + break; + + } + } + $thisfile_audio['streams'][$streamindex]['wformattag'] = $thisfile_audio['wformattag']; + $thisfile_audio['streams'][$streamindex]['bitrate_mode'] = $thisfile_audio['bitrate_mode']; + $thisfile_audio['streams'][$streamindex]['lossless'] = $thisfile_audio['lossless']; + $thisfile_audio['streams'][$streamindex]['dataformat'] = $thisfile_audio_dataformat; + } + + if (isset($thisfile_riff_WAVE['rgad'][0]['data'])) { + + // shortcuts + $rgadData = &$thisfile_riff_WAVE['rgad'][0]['data']; + $thisfile_riff_raw['rgad'] = array('track'=>array(), 'album'=>array()); + $thisfile_riff_raw_rgad = &$thisfile_riff_raw['rgad']; + $thisfile_riff_raw_rgad_track = &$thisfile_riff_raw_rgad['track']; + $thisfile_riff_raw_rgad_album = &$thisfile_riff_raw_rgad['album']; + + $thisfile_riff_raw_rgad['fPeakAmplitude'] = getid3_lib::LittleEndian2Float(substr($rgadData, 0, 4)); + $thisfile_riff_raw_rgad['nRadioRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 4, 2)); + $thisfile_riff_raw_rgad['nAudiophileRgAdjust'] = $this->EitherEndian2Int(substr($rgadData, 6, 2)); + + $nRadioRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT); + $nAudiophileRgAdjustBitstring = str_pad(getid3_lib::Dec2Bin($thisfile_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT); + $thisfile_riff_raw_rgad_track['name'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 0, 3)); + $thisfile_riff_raw_rgad_track['originator'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 3, 3)); + $thisfile_riff_raw_rgad_track['signbit'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 6, 1)); + $thisfile_riff_raw_rgad_track['adjustment'] = getid3_lib::Bin2Dec(substr($nRadioRgAdjustBitstring, 7, 9)); + $thisfile_riff_raw_rgad_album['name'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 0, 3)); + $thisfile_riff_raw_rgad_album['originator'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 3, 3)); + $thisfile_riff_raw_rgad_album['signbit'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 6, 1)); + $thisfile_riff_raw_rgad_album['adjustment'] = getid3_lib::Bin2Dec(substr($nAudiophileRgAdjustBitstring, 7, 9)); + + $thisfile_riff['rgad']['peakamplitude'] = $thisfile_riff_raw_rgad['fPeakAmplitude']; + if (($thisfile_riff_raw_rgad_track['name'] != 0) && ($thisfile_riff_raw_rgad_track['originator'] != 0)) { + $thisfile_riff['rgad']['track']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_track['name']); + $thisfile_riff['rgad']['track']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_track['originator']); + $thisfile_riff['rgad']['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_track['adjustment'], $thisfile_riff_raw_rgad_track['signbit']); + } + if (($thisfile_riff_raw_rgad_album['name'] != 0) && ($thisfile_riff_raw_rgad_album['originator'] != 0)) { + $thisfile_riff['rgad']['album']['name'] = getid3_lib::RGADnameLookup($thisfile_riff_raw_rgad_album['name']); + $thisfile_riff['rgad']['album']['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_riff_raw_rgad_album['originator']); + $thisfile_riff['rgad']['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($thisfile_riff_raw_rgad_album['adjustment'], $thisfile_riff_raw_rgad_album['signbit']); + } + } + + if (isset($thisfile_riff_WAVE['fact'][0]['data'])) { + $thisfile_riff_raw['fact']['NumberOfSamples'] = $this->EitherEndian2Int(substr($thisfile_riff_WAVE['fact'][0]['data'], 0, 4)); + + // This should be a good way of calculating exact playtime, + // but some sample files have had incorrect number of samples, + // so cannot use this method + + // if (!empty($thisfile_riff_raw['fmt ']['nSamplesPerSec'])) { + // $info['playtime_seconds'] = (float) $thisfile_riff_raw['fact']['NumberOfSamples'] / $thisfile_riff_raw['fmt ']['nSamplesPerSec']; + // } + } + if (!empty($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'])) { + $thisfile_audio['bitrate'] = getid3_lib::CastAsInt($thisfile_riff_raw['fmt ']['nAvgBytesPerSec'] * 8); + } + + if (isset($thisfile_riff_WAVE['bext'][0]['data'])) { + // shortcut + $thisfile_riff_WAVE_bext_0 = &$thisfile_riff_WAVE['bext'][0]; + + $thisfile_riff_WAVE_bext_0['title'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 0, 256)); + $thisfile_riff_WAVE_bext_0['author'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 256, 32)); + $thisfile_riff_WAVE_bext_0['reference'] = trim(substr($thisfile_riff_WAVE_bext_0['data'], 288, 32)); + $thisfile_riff_WAVE_bext_0['origin_date'] = substr($thisfile_riff_WAVE_bext_0['data'], 320, 10); + $thisfile_riff_WAVE_bext_0['origin_time'] = substr($thisfile_riff_WAVE_bext_0['data'], 330, 8); + $thisfile_riff_WAVE_bext_0['time_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 338, 8)); + $thisfile_riff_WAVE_bext_0['bwf_version'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 346, 1)); + $thisfile_riff_WAVE_bext_0['reserved'] = substr($thisfile_riff_WAVE_bext_0['data'], 347, 254); + $thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601))); + if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) { + if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) { + list($dummy, $bext_timestamp['year'], $bext_timestamp['month'], $bext_timestamp['day']) = $matches_bext_date; + list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time; + $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']); + } else { + $this->warning('RIFF.WAVE.BEXT.origin_time is invalid'); + } + } else { + $this->warning('RIFF.WAVE.BEXT.origin_date is invalid'); + } + $thisfile_riff['comments']['author'][] = $thisfile_riff_WAVE_bext_0['author']; + $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_bext_0['title']; + } + + if (isset($thisfile_riff_WAVE['MEXT'][0]['data'])) { + // shortcut + $thisfile_riff_WAVE_MEXT_0 = &$thisfile_riff_WAVE['MEXT'][0]; + + $thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 0, 2)); + $thisfile_riff_WAVE_MEXT_0['flags']['homogenous'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0001); + if ($thisfile_riff_WAVE_MEXT_0['flags']['homogenous']) { + $thisfile_riff_WAVE_MEXT_0['flags']['padding'] = ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0002) ? false : true; + $thisfile_riff_WAVE_MEXT_0['flags']['22_or_44'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0004); + $thisfile_riff_WAVE_MEXT_0['flags']['free_format'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['sound_information'] & 0x0008); + + $thisfile_riff_WAVE_MEXT_0['nominal_frame_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 2, 2)); + } + $thisfile_riff_WAVE_MEXT_0['anciliary_data_length'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 6, 2)); + $thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_MEXT_0['data'], 8, 2)); + $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_left'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0001); + $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_free'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0002); + $thisfile_riff_WAVE_MEXT_0['flags']['anciliary_data_right'] = (bool) ($thisfile_riff_WAVE_MEXT_0['raw']['anciliary_data_def'] & 0x0004); + } + + if (isset($thisfile_riff_WAVE['cart'][0]['data'])) { + // shortcut + $thisfile_riff_WAVE_cart_0 = &$thisfile_riff_WAVE['cart'][0]; + + $thisfile_riff_WAVE_cart_0['version'] = substr($thisfile_riff_WAVE_cart_0['data'], 0, 4); + $thisfile_riff_WAVE_cart_0['title'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 4, 64)); + $thisfile_riff_WAVE_cart_0['artist'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 68, 64)); + $thisfile_riff_WAVE_cart_0['cut_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 132, 64)); + $thisfile_riff_WAVE_cart_0['client_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 196, 64)); + $thisfile_riff_WAVE_cart_0['category'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 260, 64)); + $thisfile_riff_WAVE_cart_0['classification'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 324, 64)); + $thisfile_riff_WAVE_cart_0['out_cue'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 388, 64)); + $thisfile_riff_WAVE_cart_0['start_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 452, 10)); + $thisfile_riff_WAVE_cart_0['start_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 462, 8)); + $thisfile_riff_WAVE_cart_0['end_date'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 470, 10)); + $thisfile_riff_WAVE_cart_0['end_time'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 480, 8)); + $thisfile_riff_WAVE_cart_0['producer_app_id'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 488, 64)); + $thisfile_riff_WAVE_cart_0['producer_app_version'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 552, 64)); + $thisfile_riff_WAVE_cart_0['user_defined_text'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 616, 64)); + $thisfile_riff_WAVE_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 680, 4), true); + for ($i = 0; $i < 8; $i++) { + $thisfile_riff_WAVE_cart_0['post_time'][$i]['usage_fourcc'] = substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8), 4); + $thisfile_riff_WAVE_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_cart_0['data'], 684 + ($i * 8) + 4, 4)); + } + $thisfile_riff_WAVE_cart_0['url'] = trim(substr($thisfile_riff_WAVE_cart_0['data'], 748, 1024)); + $thisfile_riff_WAVE_cart_0['tag_text'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_cart_0['data'], 1772))); + + $thisfile_riff['comments']['artist'][] = $thisfile_riff_WAVE_cart_0['artist']; + $thisfile_riff['comments']['title'][] = $thisfile_riff_WAVE_cart_0['title']; + } + + if (isset($thisfile_riff_WAVE['SNDM'][0]['data'])) { + // SoundMiner metadata + + // shortcuts + $thisfile_riff_WAVE_SNDM_0 = &$thisfile_riff_WAVE['SNDM'][0]; + $thisfile_riff_WAVE_SNDM_0_data = &$thisfile_riff_WAVE_SNDM_0['data']; + $SNDM_startoffset = 0; + $SNDM_endoffset = $thisfile_riff_WAVE_SNDM_0['size']; + + while ($SNDM_startoffset < $SNDM_endoffset) { + $SNDM_thisTagOffset = 0; + $SNDM_thisTagSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4)); + $SNDM_thisTagOffset += 4; + $SNDM_thisTagKey = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 4); + $SNDM_thisTagOffset += 4; + $SNDM_thisTagDataSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2)); + $SNDM_thisTagOffset += 2; + $SNDM_thisTagDataFlags = getid3_lib::BigEndian2Int(substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, 2)); + $SNDM_thisTagOffset += 2; + $SNDM_thisTagDataText = substr($thisfile_riff_WAVE_SNDM_0_data, $SNDM_startoffset + $SNDM_thisTagOffset, $SNDM_thisTagDataSize); + $SNDM_thisTagOffset += $SNDM_thisTagDataSize; + + if ($SNDM_thisTagSize != (4 + 4 + 2 + 2 + $SNDM_thisTagDataSize)) { + $this->warning('RIFF.WAVE.SNDM.data contains tag not expected length (expected: '.$SNDM_thisTagSize.', found: '.(4 + 4 + 2 + 2 + $SNDM_thisTagDataSize).') at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')'); + break; + } elseif ($SNDM_thisTagSize <= 0) { + $this->warning('RIFF.WAVE.SNDM.data contains zero-size tag at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')'); + break; + } + $SNDM_startoffset += $SNDM_thisTagSize; + + $thisfile_riff_WAVE_SNDM_0['parsed_raw'][$SNDM_thisTagKey] = $SNDM_thisTagDataText; + if ($parsedkey = self::waveSNDMtagLookup($SNDM_thisTagKey)) { + $thisfile_riff_WAVE_SNDM_0['parsed'][$parsedkey] = $SNDM_thisTagDataText; + } else { + $this->warning('RIFF.WAVE.SNDM contains unknown tag "'.$SNDM_thisTagKey.'" at offset '.$SNDM_startoffset.' (file offset '.($thisfile_riff_WAVE_SNDM_0['offset'] + $SNDM_startoffset).')'); + } + } + + $tagmapping = array( + 'tracktitle'=>'title', + 'category' =>'genre', + 'cdtitle' =>'album', + 'tracktitle'=>'title', + ); + foreach ($tagmapping as $fromkey => $tokey) { + if (isset($thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey])) { + $thisfile_riff['comments'][$tokey][] = $thisfile_riff_WAVE_SNDM_0['parsed'][$fromkey]; + } + } + } + + if (isset($thisfile_riff_WAVE['iXML'][0]['data'])) { + // requires functions simplexml_load_string and get_object_vars + if ($parsedXML = getid3_lib::XML2array($thisfile_riff_WAVE['iXML'][0]['data'])) { + $thisfile_riff_WAVE['iXML'][0]['parsed'] = $parsedXML; + if (isset($parsedXML['SPEED']['MASTER_SPEED'])) { + @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['MASTER_SPEED']); + $thisfile_riff_WAVE['iXML'][0]['master_speed'] = $numerator / ($denominator ? $denominator : 1000); + } + if (isset($parsedXML['SPEED']['TIMECODE_RATE'])) { + @list($numerator, $denominator) = explode('/', $parsedXML['SPEED']['TIMECODE_RATE']); + $thisfile_riff_WAVE['iXML'][0]['timecode_rate'] = $numerator / ($denominator ? $denominator : 1000); + } + if (isset($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO']) && !empty($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) && !empty($thisfile_riff_WAVE['iXML'][0]['timecode_rate'])) { + $samples_since_midnight = floatval(ltrim($parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_HI'].$parsedXML['SPEED']['TIMESTAMP_SAMPLES_SINCE_MIDNIGHT_LO'], '0')); + $timestamp_sample_rate = (is_array($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) ? max($parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']) : $parsedXML['SPEED']['TIMESTAMP_SAMPLE_RATE']); // XML could possibly contain more than one TIMESTAMP_SAMPLE_RATE tag, returning as array instead of integer [why? does it make sense? perhaps doesn't matter but getID3 needs to deal with it] - see https://github.com/JamesHeinrich/getID3/issues/105 + $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] = $samples_since_midnight / $timestamp_sample_rate; + $h = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] / 3600); + $m = floor(($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600)) / 60); + $s = floor( $thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60)); + $f = ($thisfile_riff_WAVE['iXML'][0]['timecode_seconds'] - ($h * 3600) - ($m * 60) - $s) * $thisfile_riff_WAVE['iXML'][0]['timecode_rate']; + $thisfile_riff_WAVE['iXML'][0]['timecode_string'] = sprintf('%02d:%02d:%02d:%05.2f', $h, $m, $s, $f); + $thisfile_riff_WAVE['iXML'][0]['timecode_string_round'] = sprintf('%02d:%02d:%02d:%02d', $h, $m, $s, round($f)); + unset($samples_since_midnight, $timestamp_sample_rate, $h, $m, $s, $f); + } + unset($parsedXML); + } + } + + + + if (!isset($thisfile_audio['bitrate']) && isset($thisfile_riff_audio[$streamindex]['bitrate'])) { + $thisfile_audio['bitrate'] = $thisfile_riff_audio[$streamindex]['bitrate']; + $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $thisfile_audio['bitrate']); + } + + if (!empty($info['wavpack'])) { + $thisfile_audio_dataformat = 'wavpack'; + $thisfile_audio['bitrate_mode'] = 'vbr'; + $thisfile_audio['encoder'] = 'WavPack v'.$info['wavpack']['version']; + + // Reset to the way it was - RIFF parsing will have messed this up + $info['avdataend'] = $Original['avdataend']; + $thisfile_audio['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; + + $this->fseek($info['avdataoffset'] - 44); + $RIFFdata = $this->fread(44); + $OrignalRIFFheaderSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 4, 4)) + 8; + $OrignalRIFFdataSize = getid3_lib::LittleEndian2Int(substr($RIFFdata, 40, 4)) + 44; + + if ($OrignalRIFFheaderSize > $OrignalRIFFdataSize) { + $info['avdataend'] -= ($OrignalRIFFheaderSize - $OrignalRIFFdataSize); + $this->fseek($info['avdataend']); + $RIFFdata .= $this->fread($OrignalRIFFheaderSize - $OrignalRIFFdataSize); + } + + // move the data chunk after all other chunks (if any) + // so that the RIFF parser doesn't see EOF when trying + // to skip over the data chunk + $RIFFdata = substr($RIFFdata, 0, 36).substr($RIFFdata, 44).substr($RIFFdata, 36, 8); + $getid3_riff = new getid3_riff($this->getid3); + $getid3_riff->ParseRIFFdata($RIFFdata); + unset($getid3_riff); + } + + if (isset($thisfile_riff_raw['fmt ']['wFormatTag'])) { + switch ($thisfile_riff_raw['fmt ']['wFormatTag']) { + case 0x0001: // PCM + if (!empty($info['ac3'])) { + // Dolby Digital WAV files masquerade as PCM-WAV, but they're not + $thisfile_audio['wformattag'] = 0x2000; + $thisfile_audio['codec'] = self::wFormatTagLookup($thisfile_audio['wformattag']); + $thisfile_audio['lossless'] = false; + $thisfile_audio['bitrate'] = $info['ac3']['bitrate']; + $thisfile_audio['sample_rate'] = $info['ac3']['sample_rate']; + } + if (!empty($info['dts'])) { + // Dolby DTS files masquerade as PCM-WAV, but they're not + $thisfile_audio['wformattag'] = 0x2001; + $thisfile_audio['codec'] = self::wFormatTagLookup($thisfile_audio['wformattag']); + $thisfile_audio['lossless'] = false; + $thisfile_audio['bitrate'] = $info['dts']['bitrate']; + $thisfile_audio['sample_rate'] = $info['dts']['sample_rate']; + } + break; + case 0x08AE: // ClearJump LiteWave + $thisfile_audio['bitrate_mode'] = 'vbr'; + $thisfile_audio_dataformat = 'litewave'; + + //typedef struct tagSLwFormat { + // WORD m_wCompFormat; // low byte defines compression method, high byte is compression flags + // DWORD m_dwScale; // scale factor for lossy compression + // DWORD m_dwBlockSize; // number of samples in encoded blocks + // WORD m_wQuality; // alias for the scale factor + // WORD m_wMarkDistance; // distance between marks in bytes + // WORD m_wReserved; + // + // //following paramters are ignored if CF_FILESRC is not set + // DWORD m_dwOrgSize; // original file size in bytes + // WORD m_bFactExists; // indicates if 'fact' chunk exists in the original file + // DWORD m_dwRiffChunkSize; // riff chunk size in the original file + // + // PCMWAVEFORMAT m_OrgWf; // original wave format + // }SLwFormat, *PSLwFormat; + + // shortcut + $thisfile_riff['litewave']['raw'] = array(); + $riff_litewave = &$thisfile_riff['litewave']; + $riff_litewave_raw = &$riff_litewave['raw']; + + $flags = array( + 'compression_method' => 1, + 'compression_flags' => 1, + 'm_dwScale' => 4, + 'm_dwBlockSize' => 4, + 'm_wQuality' => 2, + 'm_wMarkDistance' => 2, + 'm_wReserved' => 2, + 'm_dwOrgSize' => 4, + 'm_bFactExists' => 2, + 'm_dwRiffChunkSize' => 4, + ); + $litewave_offset = 18; + foreach ($flags as $flag => $length) { + $riff_litewave_raw[$flag] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE['fmt '][0]['data'], $litewave_offset, $length)); + $litewave_offset += $length; + } + + //$riff_litewave['quality_factor'] = intval(round((2000 - $riff_litewave_raw['m_dwScale']) / 20)); + $riff_litewave['quality_factor'] = $riff_litewave_raw['m_wQuality']; + + $riff_litewave['flags']['raw_source'] = ($riff_litewave_raw['compression_flags'] & 0x01) ? false : true; + $riff_litewave['flags']['vbr_blocksize'] = ($riff_litewave_raw['compression_flags'] & 0x02) ? false : true; + $riff_litewave['flags']['seekpoints'] = (bool) ($riff_litewave_raw['compression_flags'] & 0x04); + + $thisfile_audio['lossless'] = (($riff_litewave_raw['m_wQuality'] == 100) ? true : false); + $thisfile_audio['encoder_options'] = '-q'.$riff_litewave['quality_factor']; + break; + + default: + break; + } + } + if ($info['avdataend'] > $info['filesize']) { + switch (!empty($thisfile_audio_dataformat) ? $thisfile_audio_dataformat : '') { + case 'wavpack': // WavPack + case 'lpac': // LPAC + case 'ofr': // OptimFROG + case 'ofs': // OptimFROG DualStream + // lossless compressed audio formats that keep original RIFF headers - skip warning + break; + + case 'litewave': + if (($info['avdataend'] - $info['filesize']) == 1) { + // LiteWave appears to incorrectly *not* pad actual output file + // to nearest WORD boundary so may appear to be short by one + // byte, in which case - skip warning + } else { + // Short by more than one byte, throw warning + $this->warning('Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)'); + $info['avdataend'] = $info['filesize']; + } + break; + + default: + if ((($info['avdataend'] - $info['filesize']) == 1) && (($thisfile_riff[$RIFFsubtype]['data'][0]['size'] % 2) == 0) && ((($info['filesize'] - $info['avdataoffset']) % 2) == 1)) { + // output file appears to be incorrectly *not* padded to nearest WORD boundary + // Output less severe warning + $this->warning('File should probably be padded to nearest WORD boundary, but it is not (expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' therefore short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)'); + $info['avdataend'] = $info['filesize']; + } else { + // Short by more than one byte, throw warning + $this->warning('Probably truncated file - expecting '.$thisfile_riff[$RIFFsubtype]['data'][0]['size'].' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($thisfile_riff[$RIFFsubtype]['data'][0]['size'] - ($info['filesize'] - $info['avdataoffset'])).' bytes)'); + $info['avdataend'] = $info['filesize']; + } + break; + } + } + if (!empty($info['mpeg']['audio']['LAME']['audio_bytes'])) { + if ((($info['avdataend'] - $info['avdataoffset']) - $info['mpeg']['audio']['LAME']['audio_bytes']) == 1) { + $info['avdataend']--; + $this->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'); + } + } + if (isset($thisfile_audio_dataformat) && ($thisfile_audio_dataformat == 'ac3')) { + unset($thisfile_audio['bits_per_sample']); + if (!empty($info['ac3']['bitrate']) && ($info['ac3']['bitrate'] != $thisfile_audio['bitrate'])) { + $thisfile_audio['bitrate'] = $info['ac3']['bitrate']; + } + } + break; + + // http://en.wikipedia.org/wiki/Audio_Video_Interleave + case 'AVI ': + $info['fileformat'] = 'avi'; + $info['mime_type'] = 'video/avi'; + + $thisfile_video['bitrate_mode'] = 'vbr'; // maybe not, but probably + $thisfile_video['dataformat'] = 'avi'; + + if (isset($thisfile_riff[$RIFFsubtype]['movi']['offset'])) { + $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['movi']['offset'] + 8; + if (isset($thisfile_riff['AVIX'])) { + $info['avdataend'] = $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['offset'] + $thisfile_riff['AVIX'][(count($thisfile_riff['AVIX']) - 1)]['chunks']['movi']['size']; + } else { + $info['avdataend'] = $thisfile_riff['AVI ']['movi']['offset'] + $thisfile_riff['AVI ']['movi']['size']; + } + if ($info['avdataend'] > $info['filesize']) { + $this->warning('Probably truncated file - expecting '.($info['avdataend'] - $info['avdataoffset']).' bytes of data, only found '.($info['filesize'] - $info['avdataoffset']).' (short by '.($info['avdataend'] - $info['filesize']).' bytes)'); + $info['avdataend'] = $info['filesize']; + } + } + + if (isset($thisfile_riff['AVI ']['hdrl']['strl']['indx'])) { + //$bIndexType = array( + // 0x00 => 'AVI_INDEX_OF_INDEXES', + // 0x01 => 'AVI_INDEX_OF_CHUNKS', + // 0x80 => 'AVI_INDEX_IS_DATA', + //); + //$bIndexSubtype = array( + // 0x01 => array( + // 0x01 => 'AVI_INDEX_2FIELD', + // ), + //); + foreach ($thisfile_riff['AVI ']['hdrl']['strl']['indx'] as $streamnumber => $steamdataarray) { + $ahsisd = &$thisfile_riff['AVI ']['hdrl']['strl']['indx'][$streamnumber]['data']; + + $thisfile_riff_raw['indx'][$streamnumber]['wLongsPerEntry'] = $this->EitherEndian2Int(substr($ahsisd, 0, 2)); + $thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType'] = $this->EitherEndian2Int(substr($ahsisd, 2, 1)); + $thisfile_riff_raw['indx'][$streamnumber]['bIndexType'] = $this->EitherEndian2Int(substr($ahsisd, 3, 1)); + $thisfile_riff_raw['indx'][$streamnumber]['nEntriesInUse'] = $this->EitherEndian2Int(substr($ahsisd, 4, 4)); + $thisfile_riff_raw['indx'][$streamnumber]['dwChunkId'] = substr($ahsisd, 8, 4); + $thisfile_riff_raw['indx'][$streamnumber]['dwReserved'] = $this->EitherEndian2Int(substr($ahsisd, 12, 4)); + + //$thisfile_riff_raw['indx'][$streamnumber]['bIndexType_name'] = $bIndexType[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']]; + //$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType_name'] = $bIndexSubtype[$thisfile_riff_raw['indx'][$streamnumber]['bIndexType']][$thisfile_riff_raw['indx'][$streamnumber]['bIndexSubType']]; + + unset($ahsisd); + } + } + if (isset($thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data'])) { + $avihData = $thisfile_riff['AVI ']['hdrl']['avih'][$streamindex]['data']; + + // shortcut + $thisfile_riff_raw['avih'] = array(); + $thisfile_riff_raw_avih = &$thisfile_riff_raw['avih']; + + $thisfile_riff_raw_avih['dwMicroSecPerFrame'] = $this->EitherEndian2Int(substr($avihData, 0, 4)); // frame display rate (or 0L) + if ($thisfile_riff_raw_avih['dwMicroSecPerFrame'] == 0) { + $this->error('Corrupt RIFF file: avih.dwMicroSecPerFrame == zero'); + return false; + } + + $flags = array( + 'dwMaxBytesPerSec', // max. transfer rate + 'dwPaddingGranularity', // pad to multiples of this size; normally 2K. + 'dwFlags', // the ever-present flags + 'dwTotalFrames', // # frames in file + 'dwInitialFrames', // + 'dwStreams', // + 'dwSuggestedBufferSize', // + 'dwWidth', // + 'dwHeight', // + 'dwScale', // + 'dwRate', // + 'dwStart', // + 'dwLength', // + ); + $avih_offset = 4; + foreach ($flags as $flag) { + $thisfile_riff_raw_avih[$flag] = $this->EitherEndian2Int(substr($avihData, $avih_offset, 4)); + $avih_offset += 4; + } + + $flags = array( + 'hasindex' => 0x00000010, + 'mustuseindex' => 0x00000020, + 'interleaved' => 0x00000100, + 'trustcktype' => 0x00000800, + 'capturedfile' => 0x00010000, + 'copyrighted' => 0x00020010, + ); + foreach ($flags as $flag => $value) { + $thisfile_riff_raw_avih['flags'][$flag] = (bool) ($thisfile_riff_raw_avih['dwFlags'] & $value); + } + + // shortcut + $thisfile_riff_video[$streamindex] = array(); + $thisfile_riff_video_current = &$thisfile_riff_video[$streamindex]; + + if ($thisfile_riff_raw_avih['dwWidth'] > 0) { + $thisfile_riff_video_current['frame_width'] = $thisfile_riff_raw_avih['dwWidth']; + $thisfile_video['resolution_x'] = $thisfile_riff_video_current['frame_width']; + } + if ($thisfile_riff_raw_avih['dwHeight'] > 0) { + $thisfile_riff_video_current['frame_height'] = $thisfile_riff_raw_avih['dwHeight']; + $thisfile_video['resolution_y'] = $thisfile_riff_video_current['frame_height']; + } + if ($thisfile_riff_raw_avih['dwTotalFrames'] > 0) { + $thisfile_riff_video_current['total_frames'] = $thisfile_riff_raw_avih['dwTotalFrames']; + $thisfile_video['total_frames'] = $thisfile_riff_video_current['total_frames']; + } + + $thisfile_riff_video_current['frame_rate'] = round(1000000 / $thisfile_riff_raw_avih['dwMicroSecPerFrame'], 3); + $thisfile_video['frame_rate'] = $thisfile_riff_video_current['frame_rate']; + } + if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) { + if (is_array($thisfile_riff['AVI ']['hdrl']['strl']['strh'])) { + for ($i = 0; $i < count($thisfile_riff['AVI ']['hdrl']['strl']['strh']); $i++) { + if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) { + $strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data']; + $strhfccType = substr($strhData, 0, 4); + + if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data'])) { + $strfData = $thisfile_riff['AVI ']['hdrl']['strl']['strf'][$i]['data']; + + // shortcut + $thisfile_riff_raw_strf_strhfccType_streamindex = &$thisfile_riff_raw['strf'][$strhfccType][$streamindex]; + + switch ($strhfccType) { + case 'auds': + $thisfile_audio['bitrate_mode'] = 'cbr'; + $thisfile_audio_dataformat = 'wav'; + if (isset($thisfile_riff_audio) && is_array($thisfile_riff_audio)) { + $streamindex = count($thisfile_riff_audio); + } + + $thisfile_riff_audio[$streamindex] = self::parseWAVEFORMATex($strfData); + $thisfile_audio['wformattag'] = $thisfile_riff_audio[$streamindex]['raw']['wFormatTag']; + + // shortcut + $thisfile_audio['streams'][$streamindex] = $thisfile_riff_audio[$streamindex]; + $thisfile_audio_streams_currentstream = &$thisfile_audio['streams'][$streamindex]; + + if ($thisfile_audio_streams_currentstream['bits_per_sample'] == 0) { + unset($thisfile_audio_streams_currentstream['bits_per_sample']); + } + $thisfile_audio_streams_currentstream['wformattag'] = $thisfile_audio_streams_currentstream['raw']['wFormatTag']; + unset($thisfile_audio_streams_currentstream['raw']); + + // shortcut + $thisfile_riff_raw['strf'][$strhfccType][$streamindex] = $thisfile_riff_audio[$streamindex]['raw']; + + unset($thisfile_riff_audio[$streamindex]['raw']); + $thisfile_audio = getid3_lib::array_merge_noclobber($thisfile_audio, $thisfile_riff_audio[$streamindex]); + + $thisfile_audio['lossless'] = false; + switch ($thisfile_riff_raw_strf_strhfccType_streamindex['wFormatTag']) { + case 0x0001: // PCM + $thisfile_audio_dataformat = 'wav'; + $thisfile_audio['lossless'] = true; + break; + + case 0x0050: // MPEG Layer 2 or Layer 1 + $thisfile_audio_dataformat = 'mp2'; // Assume Layer-2 + break; + + case 0x0055: // MPEG Layer 3 + $thisfile_audio_dataformat = 'mp3'; + break; + + case 0x00FF: // AAC + $thisfile_audio_dataformat = 'aac'; + break; + + case 0x0161: // Windows Media v7 / v8 / v9 + case 0x0162: // Windows Media Professional v9 + case 0x0163: // Windows Media Lossess v9 + $thisfile_audio_dataformat = 'wma'; + break; + + case 0x2000: // AC-3 + $thisfile_audio_dataformat = 'ac3'; + break; + + case 0x2001: // DTS + $thisfile_audio_dataformat = 'dts'; + break; + + default: + $thisfile_audio_dataformat = 'wav'; + break; + } + $thisfile_audio_streams_currentstream['dataformat'] = $thisfile_audio_dataformat; + $thisfile_audio_streams_currentstream['lossless'] = $thisfile_audio['lossless']; + $thisfile_audio_streams_currentstream['bitrate_mode'] = $thisfile_audio['bitrate_mode']; + break; + + + case 'iavs': + case 'vids': + // shortcut + $thisfile_riff_raw['strh'][$i] = array(); + $thisfile_riff_raw_strh_current = &$thisfile_riff_raw['strh'][$i]; + + $thisfile_riff_raw_strh_current['fccType'] = substr($strhData, 0, 4); // same as $strhfccType; + $thisfile_riff_raw_strh_current['fccHandler'] = substr($strhData, 4, 4); + $thisfile_riff_raw_strh_current['dwFlags'] = $this->EitherEndian2Int(substr($strhData, 8, 4)); // Contains AVITF_* flags + $thisfile_riff_raw_strh_current['wPriority'] = $this->EitherEndian2Int(substr($strhData, 12, 2)); + $thisfile_riff_raw_strh_current['wLanguage'] = $this->EitherEndian2Int(substr($strhData, 14, 2)); + $thisfile_riff_raw_strh_current['dwInitialFrames'] = $this->EitherEndian2Int(substr($strhData, 16, 4)); + $thisfile_riff_raw_strh_current['dwScale'] = $this->EitherEndian2Int(substr($strhData, 20, 4)); + $thisfile_riff_raw_strh_current['dwRate'] = $this->EitherEndian2Int(substr($strhData, 24, 4)); + $thisfile_riff_raw_strh_current['dwStart'] = $this->EitherEndian2Int(substr($strhData, 28, 4)); + $thisfile_riff_raw_strh_current['dwLength'] = $this->EitherEndian2Int(substr($strhData, 32, 4)); + $thisfile_riff_raw_strh_current['dwSuggestedBufferSize'] = $this->EitherEndian2Int(substr($strhData, 36, 4)); + $thisfile_riff_raw_strh_current['dwQuality'] = $this->EitherEndian2Int(substr($strhData, 40, 4)); + $thisfile_riff_raw_strh_current['dwSampleSize'] = $this->EitherEndian2Int(substr($strhData, 44, 4)); + $thisfile_riff_raw_strh_current['rcFrame'] = $this->EitherEndian2Int(substr($strhData, 48, 4)); + + $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strh_current['fccHandler']); + $thisfile_video['fourcc'] = $thisfile_riff_raw_strh_current['fccHandler']; + if (!$thisfile_riff_video_current['codec'] && isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) && self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) { + $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']); + $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']; + } + $thisfile_video['codec'] = $thisfile_riff_video_current['codec']; + $thisfile_video['pixel_aspect_ratio'] = (float) 1; + switch ($thisfile_riff_raw_strh_current['fccHandler']) { + case 'HFYU': // Huffman Lossless Codec + case 'IRAW': // Intel YUV Uncompressed + case 'YUY2': // Uncompressed YUV 4:2:2 + $thisfile_video['lossless'] = true; + break; + + default: + $thisfile_video['lossless'] = false; + break; + } + + switch ($strhfccType) { + case 'vids': + $thisfile_riff_raw_strf_strhfccType_streamindex = self::ParseBITMAPINFOHEADER(substr($strfData, 0, 40), ($this->container == 'riff')); + $thisfile_video['bits_per_sample'] = $thisfile_riff_raw_strf_strhfccType_streamindex['biBitCount']; + + if ($thisfile_riff_video_current['codec'] == 'DV') { + $thisfile_riff_video_current['dv_type'] = 2; + } + break; + + case 'iavs': + $thisfile_riff_video_current['dv_type'] = 1; + break; + } + break; + + default: + $this->warning('Unhandled fccType for stream ('.$i.'): "'.$strhfccType.'"'); + break; + + } + } + } + + if (isset($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc'])) { + + $thisfile_video['fourcc'] = $thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']; + if (self::fourccLookup($thisfile_video['fourcc'])) { + $thisfile_riff_video_current['codec'] = self::fourccLookup($thisfile_video['fourcc']); + $thisfile_video['codec'] = $thisfile_riff_video_current['codec']; + } + + switch ($thisfile_riff_raw_strf_strhfccType_streamindex['fourcc']) { + case 'HFYU': // Huffman Lossless Codec + case 'IRAW': // Intel YUV Uncompressed + case 'YUY2': // Uncompressed YUV 4:2:2 + $thisfile_video['lossless'] = true; + //$thisfile_video['bits_per_sample'] = 24; + break; + + default: + $thisfile_video['lossless'] = false; + //$thisfile_video['bits_per_sample'] = 24; + break; + } + + } + } + } + } + break; + + + case 'AMV ': + $info['fileformat'] = 'amv'; + $info['mime_type'] = 'video/amv'; + + $thisfile_video['bitrate_mode'] = 'vbr'; // it's MJPEG, presumably contant-quality encoding, thereby VBR + $thisfile_video['dataformat'] = 'mjpeg'; + $thisfile_video['codec'] = 'mjpeg'; + $thisfile_video['lossless'] = false; + $thisfile_video['bits_per_sample'] = 24; + + $thisfile_audio['dataformat'] = 'adpcm'; + $thisfile_audio['lossless'] = false; + break; + + + // http://en.wikipedia.org/wiki/CD-DA + case 'CDDA': + $info['fileformat'] = 'cda'; + unset($info['mime_type']); + + $thisfile_audio_dataformat = 'cda'; + + $info['avdataoffset'] = 44; + + if (isset($thisfile_riff['CDDA']['fmt '][0]['data'])) { + // shortcut + $thisfile_riff_CDDA_fmt_0 = &$thisfile_riff['CDDA']['fmt '][0]; + + $thisfile_riff_CDDA_fmt_0['unknown1'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 0, 2)); + $thisfile_riff_CDDA_fmt_0['track_num'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 2, 2)); + $thisfile_riff_CDDA_fmt_0['disc_id'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 4, 4)); + $thisfile_riff_CDDA_fmt_0['start_offset_frame'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 8, 4)); + $thisfile_riff_CDDA_fmt_0['playtime_frames'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 12, 4)); + $thisfile_riff_CDDA_fmt_0['unknown6'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 16, 4)); + $thisfile_riff_CDDA_fmt_0['unknown7'] = $this->EitherEndian2Int(substr($thisfile_riff_CDDA_fmt_0['data'], 20, 4)); + + $thisfile_riff_CDDA_fmt_0['start_offset_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['start_offset_frame'] / 75; + $thisfile_riff_CDDA_fmt_0['playtime_seconds'] = (float) $thisfile_riff_CDDA_fmt_0['playtime_frames'] / 75; + $info['comments']['track'] = $thisfile_riff_CDDA_fmt_0['track_num']; + $info['playtime_seconds'] = $thisfile_riff_CDDA_fmt_0['playtime_seconds']; + + // hardcoded data for CD-audio + $thisfile_audio['lossless'] = true; + $thisfile_audio['sample_rate'] = 44100; + $thisfile_audio['channels'] = 2; + $thisfile_audio['bits_per_sample'] = 16; + $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $thisfile_audio['channels'] * $thisfile_audio['bits_per_sample']; + $thisfile_audio['bitrate_mode'] = 'cbr'; + } + break; + + // http://en.wikipedia.org/wiki/AIFF + case 'AIFF': + case 'AIFC': + $info['fileformat'] = 'aiff'; + $info['mime_type'] = 'audio/x-aiff'; + + $thisfile_audio['bitrate_mode'] = 'cbr'; + $thisfile_audio_dataformat = 'aiff'; + $thisfile_audio['lossless'] = true; + + if (isset($thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'])) { + $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['SSND'][0]['offset'] + 8; + $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['SSND'][0]['size']; + if ($info['avdataend'] > $info['filesize']) { + if (($info['avdataend'] == ($info['filesize'] + 1)) && (($info['filesize'] % 2) == 1)) { + // structures rounded to 2-byte boundary, but dumb encoders + // forget to pad end of file to make this actually work + } else { + $this->warning('Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['SSND'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found'); + } + $info['avdataend'] = $info['filesize']; + } + } + + if (isset($thisfile_riff[$RIFFsubtype]['COMM'][0]['data'])) { + + // shortcut + $thisfile_riff_RIFFsubtype_COMM_0_data = &$thisfile_riff[$RIFFsubtype]['COMM'][0]['data']; + + $thisfile_riff_audio['channels'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 0, 2), true); + $thisfile_riff_audio['total_samples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 2, 4), false); + $thisfile_riff_audio['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 6, 2), true); + $thisfile_riff_audio['sample_rate'] = (int) getid3_lib::BigEndian2Float(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 8, 10)); + + if ($thisfile_riff[$RIFFsubtype]['COMM'][0]['size'] > 18) { + $thisfile_riff_audio['codec_fourcc'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 18, 4); + $CodecNameSize = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_COMM_0_data, 22, 1), false); + $thisfile_riff_audio['codec_name'] = substr($thisfile_riff_RIFFsubtype_COMM_0_data, 23, $CodecNameSize); + switch ($thisfile_riff_audio['codec_name']) { + case 'NONE': + $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)'; + $thisfile_audio['lossless'] = true; + break; + + case '': + switch ($thisfile_riff_audio['codec_fourcc']) { + // http://developer.apple.com/qa/snd/snd07.html + case 'sowt': + $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM'; + $thisfile_audio['lossless'] = true; + break; + + case 'twos': + $thisfile_riff_audio['codec_name'] = 'Two\'s Compliment Big-Endian PCM'; + $thisfile_audio['lossless'] = true; + break; + + default: + break; + } + break; + + default: + $thisfile_audio['codec'] = $thisfile_riff_audio['codec_name']; + $thisfile_audio['lossless'] = false; + break; + } + } + + $thisfile_audio['channels'] = $thisfile_riff_audio['channels']; + if ($thisfile_riff_audio['bits_per_sample'] > 0) { + $thisfile_audio['bits_per_sample'] = $thisfile_riff_audio['bits_per_sample']; + } + $thisfile_audio['sample_rate'] = $thisfile_riff_audio['sample_rate']; + if ($thisfile_audio['sample_rate'] == 0) { + $this->error('Corrupted AIFF file: sample_rate == zero'); + return false; + } + $info['playtime_seconds'] = $thisfile_riff_audio['total_samples'] / $thisfile_audio['sample_rate']; + } + + if (isset($thisfile_riff[$RIFFsubtype]['COMT'])) { + $offset = 0; + $CommentCount = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false); + $offset += 2; + for ($i = 0; $i < $CommentCount; $i++) { + $info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 4), false); + $offset += 4; + $info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), true); + $offset += 2; + $CommentLength = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, 2), false); + $offset += 2; + $info['comments_raw'][$i]['comment'] = substr($thisfile_riff[$RIFFsubtype]['COMT'][0]['data'], $offset, $CommentLength); + $offset += $CommentLength; + + $info['comments_raw'][$i]['timestamp_unix'] = getid3_lib::DateMac2Unix($info['comments_raw'][$i]['timestamp']); + $thisfile_riff['comments']['comment'][] = $info['comments_raw'][$i]['comment']; + } + } + + $CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment'); + foreach ($CommentsChunkNames as $key => $value) { + if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) { + $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data']; + } + } +/* + if (isset($thisfile_riff[$RIFFsubtype]['ID3 '])) { + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_id3v2 = new getid3_id3v2($getid3_temp); + $getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['ID3 '][0]['offset'] + 8; + if ($thisfile_riff[$RIFFsubtype]['ID3 '][0]['valid'] = $getid3_id3v2->Analyze()) { + $info['id3v2'] = $getid3_temp->info['id3v2']; + } + unset($getid3_temp, $getid3_id3v2); + } +*/ + break; + + // http://en.wikipedia.org/wiki/8SVX + case '8SVX': + $info['fileformat'] = '8svx'; + $info['mime_type'] = 'audio/8svx'; + + $thisfile_audio['bitrate_mode'] = 'cbr'; + $thisfile_audio_dataformat = '8svx'; + $thisfile_audio['bits_per_sample'] = 8; + $thisfile_audio['channels'] = 1; // overridden below, if need be + + if (isset($thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'])) { + $info['avdataoffset'] = $thisfile_riff[$RIFFsubtype]['BODY'][0]['offset'] + 8; + $info['avdataend'] = $info['avdataoffset'] + $thisfile_riff[$RIFFsubtype]['BODY'][0]['size']; + if ($info['avdataend'] > $info['filesize']) { + $this->warning('Probable truncated AIFF file: expecting '.$thisfile_riff[$RIFFsubtype]['BODY'][0]['size'].' bytes of audio data, only '.($info['filesize'] - $info['avdataoffset']).' bytes found'); + } + } + + if (isset($thisfile_riff[$RIFFsubtype]['VHDR'][0]['offset'])) { + // shortcut + $thisfile_riff_RIFFsubtype_VHDR_0 = &$thisfile_riff[$RIFFsubtype]['VHDR'][0]; + + $thisfile_riff_RIFFsubtype_VHDR_0['oneShotHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 0, 4)); + $thisfile_riff_RIFFsubtype_VHDR_0['repeatHiSamples'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 4, 4)); + $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerHiCycle'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 8, 4)); + $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 12, 2)); + $thisfile_riff_RIFFsubtype_VHDR_0['ctOctave'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 14, 1)); + $thisfile_riff_RIFFsubtype_VHDR_0['sCompression'] = getid3_lib::BigEndian2Int(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 15, 1)); + $thisfile_riff_RIFFsubtype_VHDR_0['Volume'] = getid3_lib::FixedPoint16_16(substr($thisfile_riff_RIFFsubtype_VHDR_0['data'], 16, 4)); + + $thisfile_audio['sample_rate'] = $thisfile_riff_RIFFsubtype_VHDR_0['samplesPerSec']; + + switch ($thisfile_riff_RIFFsubtype_VHDR_0['sCompression']) { + case 0: + $thisfile_audio['codec'] = 'Pulse Code Modulation (PCM)'; + $thisfile_audio['lossless'] = true; + $ActualBitsPerSample = 8; + break; + + case 1: + $thisfile_audio['codec'] = 'Fibonacci-delta encoding'; + $thisfile_audio['lossless'] = false; + $ActualBitsPerSample = 4; + break; + + default: + $this->warning('Unexpected sCompression value in 8SVX.VHDR chunk - expecting 0 or 1, found "'.sCompression.'"'); + break; + } + } + + if (isset($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'])) { + $ChannelsIndex = getid3_lib::BigEndian2Int(substr($thisfile_riff[$RIFFsubtype]['CHAN'][0]['data'], 0, 4)); + switch ($ChannelsIndex) { + case 6: // Stereo + $thisfile_audio['channels'] = 2; + break; + + case 2: // Left channel only + case 4: // Right channel only + $thisfile_audio['channels'] = 1; + break; + + default: + $this->warning('Unexpected value in 8SVX.CHAN chunk - expecting 2 or 4 or 6, found "'.$ChannelsIndex.'"'); + break; + } + + } + + $CommentsChunkNames = array('NAME'=>'title', 'author'=>'artist', '(c) '=>'copyright', 'ANNO'=>'comment'); + foreach ($CommentsChunkNames as $key => $value) { + if (isset($thisfile_riff[$RIFFsubtype][$key][0]['data'])) { + $thisfile_riff['comments'][$value][] = $thisfile_riff[$RIFFsubtype][$key][0]['data']; + } + } + + $thisfile_audio['bitrate'] = $thisfile_audio['sample_rate'] * $ActualBitsPerSample * $thisfile_audio['channels']; + if (!empty($thisfile_audio['bitrate'])) { + $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($thisfile_audio['bitrate'] / 8); + } + break; + + case 'CDXA': + $info['fileformat'] = 'vcd'; // Asume Video CD + $info['mime_type'] = 'video/mpeg'; + + if (!empty($thisfile_riff['CDXA']['data'][0]['size'])) { + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.mpeg.php', __FILE__, true); + + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_mpeg = new getid3_mpeg($getid3_temp); + $getid3_mpeg->Analyze(); + if (empty($getid3_temp->info['error'])) { + $info['audio'] = $getid3_temp->info['audio']; + $info['video'] = $getid3_temp->info['video']; + $info['mpeg'] = $getid3_temp->info['mpeg']; + $info['warning'] = $getid3_temp->info['warning']; + } + unset($getid3_temp, $getid3_mpeg); + } + break; + + case 'WEBP': + // https://developers.google.com/speed/webp/docs/riff_container + // https://tools.ietf.org/html/rfc6386 + // https://chromium.googlesource.com/webm/libwebp/+/master/doc/webp-lossless-bitstream-spec.txt + $info['fileformat'] = 'webp'; + $info['mime_type'] = 'image/webp'; + + if (!empty($thisfile_riff['WEBP']['VP8 '][0]['size'])) { + $old_offset = $this->ftell(); + $this->fseek($thisfile_riff['WEBP']['VP8 '][0]['offset'] + 8); // 4 bytes "VP8 " + 4 bytes chunk size + $WEBP_VP8_header = $this->fread(10); + $this->fseek($old_offset); + if (substr($WEBP_VP8_header, 3, 3) == "\x9D\x01\x2A") { + $thisfile_riff['WEBP']['VP8 '][0]['keyframe'] = !(getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x800000); + $thisfile_riff['WEBP']['VP8 '][0]['version'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x700000) >> 20; + $thisfile_riff['WEBP']['VP8 '][0]['show_frame'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x080000); + $thisfile_riff['WEBP']['VP8 '][0]['data_bytes'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 0, 3)) & 0x07FFFF) >> 0; + + $thisfile_riff['WEBP']['VP8 '][0]['scale_x'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 6, 2)) & 0xC000) >> 14; + $thisfile_riff['WEBP']['VP8 '][0]['width'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 6, 2)) & 0x3FFF); + $thisfile_riff['WEBP']['VP8 '][0]['scale_y'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 8, 2)) & 0xC000) >> 14; + $thisfile_riff['WEBP']['VP8 '][0]['height'] = (getid3_lib::LittleEndian2Int(substr($WEBP_VP8_header, 8, 2)) & 0x3FFF); + + $info['video']['resolution_x'] = $thisfile_riff['WEBP']['VP8 '][0]['width']; + $info['video']['resolution_y'] = $thisfile_riff['WEBP']['VP8 '][0]['height']; + } else { + $this->error('Expecting 9D 01 2A at offset '.($thisfile_riff['WEBP']['VP8 '][0]['offset'] + 8 + 3).', found "'.getid3_lib::PrintHexBytes(substr($WEBP_VP8_header, 3, 3)).'"'); + } + + } + if (!empty($thisfile_riff['WEBP']['VP8L'][0]['size'])) { + $old_offset = $this->ftell(); + $this->fseek($thisfile_riff['WEBP']['VP8L'][0]['offset'] + 8); // 4 bytes "VP8L" + 4 bytes chunk size + $WEBP_VP8L_header = $this->fread(10); + $this->fseek($old_offset); + if (substr($WEBP_VP8L_header, 0, 1) == "\x2F") { + $width_height_flags = getid3_lib::LittleEndian2Bin(substr($WEBP_VP8L_header, 1, 4)); + $thisfile_riff['WEBP']['VP8L'][0]['width'] = bindec(substr($width_height_flags, 18, 14)) + 1; + $thisfile_riff['WEBP']['VP8L'][0]['height'] = bindec(substr($width_height_flags, 4, 14)) + 1; + $thisfile_riff['WEBP']['VP8L'][0]['alpha_is_used'] = (bool) bindec(substr($width_height_flags, 3, 1)); + $thisfile_riff['WEBP']['VP8L'][0]['version'] = bindec(substr($width_height_flags, 0, 3)); + + $info['video']['resolution_x'] = $thisfile_riff['WEBP']['VP8L'][0]['width']; + $info['video']['resolution_y'] = $thisfile_riff['WEBP']['VP8L'][0]['height']; + } else { + $this->error('Expecting 2F at offset '.($thisfile_riff['WEBP']['VP8L'][0]['offset'] + 8).', found "'.getid3_lib::PrintHexBytes(substr($WEBP_VP8L_header, 0, 1)).'"'); + } + + } + break; + + default: + $this->error('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA|WEBP), found "'.$RIFFsubtype.'" instead'); + //unset($info['fileformat']); + } + + switch ($RIFFsubtype) { + case 'WAVE': + case 'AIFF': + case 'AIFC': + $ID3v2_key_good = 'id3 '; + $ID3v2_keys_bad = array('ID3 ', 'tag '); + foreach ($ID3v2_keys_bad as $ID3v2_key_bad) { + if (isset($thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]) && !array_key_exists($ID3v2_key_good, $thisfile_riff[$RIFFsubtype])) { + $thisfile_riff[$RIFFsubtype][$ID3v2_key_good] = $thisfile_riff[$RIFFsubtype][$ID3v2_key_bad]; + $this->warning('mapping "'.$ID3v2_key_bad.'" chunk to "'.$ID3v2_key_good.'"'); + } + } + + if (isset($thisfile_riff[$RIFFsubtype]['id3 '])) { + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); + + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_id3v2 = new getid3_id3v2($getid3_temp); + $getid3_id3v2->StartingOffset = $thisfile_riff[$RIFFsubtype]['id3 '][0]['offset'] + 8; + if ($thisfile_riff[$RIFFsubtype]['id3 '][0]['valid'] = $getid3_id3v2->Analyze()) { + $info['id3v2'] = $getid3_temp->info['id3v2']; + } + unset($getid3_temp, $getid3_id3v2); + } + break; + } + + if (isset($thisfile_riff_WAVE['DISP']) && is_array($thisfile_riff_WAVE['DISP'])) { + $thisfile_riff['comments']['title'][] = trim(substr($thisfile_riff_WAVE['DISP'][count($thisfile_riff_WAVE['DISP']) - 1]['data'], 4)); + } + if (isset($thisfile_riff_WAVE['INFO']) && is_array($thisfile_riff_WAVE['INFO'])) { + self::parseComments($thisfile_riff_WAVE['INFO'], $thisfile_riff['comments']); + } + if (isset($thisfile_riff['AVI ']['INFO']) && is_array($thisfile_riff['AVI ']['INFO'])) { + self::parseComments($thisfile_riff['AVI ']['INFO'], $thisfile_riff['comments']); + } + + if (empty($thisfile_audio['encoder']) && !empty($info['mpeg']['audio']['LAME']['short_version'])) { + $thisfile_audio['encoder'] = $info['mpeg']['audio']['LAME']['short_version']; + } + + if (!isset($info['playtime_seconds'])) { + $info['playtime_seconds'] = 0; + } + if (isset($thisfile_riff_raw['strh'][0]['dwLength']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) { + // needed for >2GB AVIs where 'avih' chunk only lists number of frames in that chunk, not entire movie + $info['playtime_seconds'] = $thisfile_riff_raw['strh'][0]['dwLength'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000); + } elseif (isset($thisfile_riff_raw['avih']['dwTotalFrames']) && isset($thisfile_riff_raw['avih']['dwMicroSecPerFrame'])) { + $info['playtime_seconds'] = $thisfile_riff_raw['avih']['dwTotalFrames'] * ($thisfile_riff_raw['avih']['dwMicroSecPerFrame'] / 1000000); + } + + if ($info['playtime_seconds'] > 0) { + if (isset($thisfile_riff_audio) && isset($thisfile_riff_video)) { + + if (!isset($info['bitrate'])) { + $info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8); + } + + } elseif (isset($thisfile_riff_audio) && !isset($thisfile_riff_video)) { + + if (!isset($thisfile_audio['bitrate'])) { + $thisfile_audio['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8); + } + + } elseif (!isset($thisfile_riff_audio) && isset($thisfile_riff_video)) { + + if (!isset($thisfile_video['bitrate'])) { + $thisfile_video['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8); + } + + } + } + + + if (isset($thisfile_riff_video) && isset($thisfile_audio['bitrate']) && ($thisfile_audio['bitrate'] > 0) && ($info['playtime_seconds'] > 0)) { + + $info['bitrate'] = ((($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds']) * 8); + $thisfile_audio['bitrate'] = 0; + $thisfile_video['bitrate'] = $info['bitrate']; + foreach ($thisfile_riff_audio as $channelnumber => $audioinfoarray) { + $thisfile_video['bitrate'] -= $audioinfoarray['bitrate']; + $thisfile_audio['bitrate'] += $audioinfoarray['bitrate']; + } + if ($thisfile_video['bitrate'] <= 0) { + unset($thisfile_video['bitrate']); + } + if ($thisfile_audio['bitrate'] <= 0) { + unset($thisfile_audio['bitrate']); + } + } + + if (isset($info['mpeg']['audio'])) { + $thisfile_audio_dataformat = 'mp'.$info['mpeg']['audio']['layer']; + $thisfile_audio['sample_rate'] = $info['mpeg']['audio']['sample_rate']; + $thisfile_audio['channels'] = $info['mpeg']['audio']['channels']; + $thisfile_audio['bitrate'] = $info['mpeg']['audio']['bitrate']; + $thisfile_audio['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); + if (!empty($info['mpeg']['audio']['codec'])) { + $thisfile_audio['codec'] = $info['mpeg']['audio']['codec'].' '.$thisfile_audio['codec']; + } + if (!empty($thisfile_audio['streams'])) { + foreach ($thisfile_audio['streams'] as $streamnumber => $streamdata) { + if ($streamdata['dataformat'] == $thisfile_audio_dataformat) { + $thisfile_audio['streams'][$streamnumber]['sample_rate'] = $thisfile_audio['sample_rate']; + $thisfile_audio['streams'][$streamnumber]['channels'] = $thisfile_audio['channels']; + $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate']; + $thisfile_audio['streams'][$streamnumber]['bitrate_mode'] = $thisfile_audio['bitrate_mode']; + $thisfile_audio['streams'][$streamnumber]['codec'] = $thisfile_audio['codec']; + } + } + } + $getid3_mp3 = new getid3_mp3($this->getid3); + $thisfile_audio['encoder_options'] = $getid3_mp3->GuessEncoderOptions(); + unset($getid3_mp3); + } + + + if (!empty($thisfile_riff_raw['fmt ']['wBitsPerSample']) && ($thisfile_riff_raw['fmt ']['wBitsPerSample'] > 0)) { + switch ($thisfile_audio_dataformat) { + case 'ac3': + // ignore bits_per_sample + break; + + default: + $thisfile_audio['bits_per_sample'] = $thisfile_riff_raw['fmt ']['wBitsPerSample']; + break; + } + } + + + if (empty($thisfile_riff_raw)) { + unset($thisfile_riff['raw']); + } + if (empty($thisfile_riff_audio)) { + unset($thisfile_riff['audio']); + } + if (empty($thisfile_riff_video)) { + unset($thisfile_riff['video']); + } + + return true; + } + + public function ParseRIFFAMV($startoffset, $maxoffset) { + // AMV files are RIFF-AVI files with parts of the spec deliberately broken, such as chunk size fields hardcoded to zero (because players known in hardware that these fields are always a certain size + + // https://code.google.com/p/amv-codec-tools/wiki/AmvDocumentation + //typedef struct _amvmainheader { + //FOURCC fcc; // 'amvh' + //DWORD cb; + //DWORD dwMicroSecPerFrame; + //BYTE reserve[28]; + //DWORD dwWidth; + //DWORD dwHeight; + //DWORD dwSpeed; + //DWORD reserve0; + //DWORD reserve1; + //BYTE bTimeSec; + //BYTE bTimeMin; + //WORD wTimeHour; + //} AMVMAINHEADER; + + $info = &$this->getid3->info; + $RIFFchunk = false; + + try { + + $this->fseek($startoffset); + $maxoffset = min($maxoffset, $info['avdataend']); + $AMVheader = $this->fread(284); + if (substr($AMVheader, 0, 8) != 'hdrlamvh') { + throw new Exception('expecting "hdrlamv" at offset '.($startoffset + 0).', found "'.substr($AMVheader, 0, 8).'"'); + } + if (substr($AMVheader, 8, 4) != "\x38\x00\x00\x00") { // "amvh" chunk size, hardcoded to 0x38 = 56 bytes + throw new Exception('expecting "0x38000000" at offset '.($startoffset + 8).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 8, 4)).'"'); + } + $RIFFchunk = array(); + $RIFFchunk['amvh']['us_per_frame'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 12, 4)); + $RIFFchunk['amvh']['reserved28'] = substr($AMVheader, 16, 28); // null? reserved? + $RIFFchunk['amvh']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 44, 4)); + $RIFFchunk['amvh']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 48, 4)); + $RIFFchunk['amvh']['frame_rate_int'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 52, 4)); + $RIFFchunk['amvh']['reserved0'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 56, 4)); // 1? reserved? + $RIFFchunk['amvh']['reserved1'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 60, 4)); // 0? reserved? + $RIFFchunk['amvh']['runtime_sec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 64, 1)); + $RIFFchunk['amvh']['runtime_min'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 65, 1)); + $RIFFchunk['amvh']['runtime_hrs'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 66, 2)); + + $info['video']['frame_rate'] = 1000000 / $RIFFchunk['amvh']['us_per_frame']; + $info['video']['resolution_x'] = $RIFFchunk['amvh']['resolution_x']; + $info['video']['resolution_y'] = $RIFFchunk['amvh']['resolution_y']; + $info['playtime_seconds'] = ($RIFFchunk['amvh']['runtime_hrs'] * 3600) + ($RIFFchunk['amvh']['runtime_min'] * 60) + $RIFFchunk['amvh']['runtime_sec']; + + // the rest is all hardcoded(?) and does not appear to be useful until you get to audio info at offset 256, even then everything is probably hardcoded + + if (substr($AMVheader, 68, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x38\x00\x00\x00") { + throw new Exception('expecting "LIST<0x00000000>strlstrh<0x38000000>" at offset '.($startoffset + 68).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 68, 20)).'"'); + } + // followed by 56 bytes of null: substr($AMVheader, 88, 56) -> 144 + if (substr($AMVheader, 144, 8) != 'strf'."\x24\x00\x00\x00") { + throw new Exception('expecting "strf<0x24000000>" at offset '.($startoffset + 144).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 144, 8)).'"'); + } + // followed by 36 bytes of null: substr($AMVheader, 144, 36) -> 180 + + if (substr($AMVheader, 188, 20) != 'LIST'."\x00\x00\x00\x00".'strlstrh'."\x30\x00\x00\x00") { + throw new Exception('expecting "LIST<0x00000000>strlstrh<0x30000000>" at offset '.($startoffset + 188).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 188, 20)).'"'); + } + // followed by 48 bytes of null: substr($AMVheader, 208, 48) -> 256 + if (substr($AMVheader, 256, 8) != 'strf'."\x14\x00\x00\x00") { + throw new Exception('expecting "strf<0x14000000>" at offset '.($startoffset + 256).', found "'.getid3_lib::PrintHexBytes(substr($AMVheader, 256, 8)).'"'); + } + // followed by 20 bytes of a modified WAVEFORMATEX: + // typedef struct { + // WORD wFormatTag; //(Fixme: this is equal to PCM's 0x01 format code) + // WORD nChannels; //(Fixme: this is always 1) + // DWORD nSamplesPerSec; //(Fixme: for all known sample files this is equal to 22050) + // DWORD nAvgBytesPerSec; //(Fixme: for all known sample files this is equal to 44100) + // WORD nBlockAlign; //(Fixme: this seems to be 2 in AMV files, is this correct ?) + // WORD wBitsPerSample; //(Fixme: this seems to be 16 in AMV files instead of the expected 4) + // WORD cbSize; //(Fixme: this seems to be 0 in AMV files) + // WORD reserved; + // } WAVEFORMATEX; + $RIFFchunk['strf']['wformattag'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 264, 2)); + $RIFFchunk['strf']['nchannels'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 266, 2)); + $RIFFchunk['strf']['nsamplespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 268, 4)); + $RIFFchunk['strf']['navgbytespersec'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 272, 4)); + $RIFFchunk['strf']['nblockalign'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 276, 2)); + $RIFFchunk['strf']['wbitspersample'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 278, 2)); + $RIFFchunk['strf']['cbsize'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 280, 2)); + $RIFFchunk['strf']['reserved'] = getid3_lib::LittleEndian2Int(substr($AMVheader, 282, 2)); + + + $info['audio']['lossless'] = false; + $info['audio']['sample_rate'] = $RIFFchunk['strf']['nsamplespersec']; + $info['audio']['channels'] = $RIFFchunk['strf']['nchannels']; + $info['audio']['bits_per_sample'] = $RIFFchunk['strf']['wbitspersample']; + $info['audio']['bitrate'] = $info['audio']['sample_rate'] * $info['audio']['channels'] * $info['audio']['bits_per_sample']; + $info['audio']['bitrate_mode'] = 'cbr'; + + + } catch (getid3_exception $e) { + if ($e->getCode() == 10) { + $this->warning('RIFFAMV parser: '.$e->getMessage()); + } else { + throw $e; + } + } + + return $RIFFchunk; + } + + + public function ParseRIFF($startoffset, $maxoffset) { + $info = &$this->getid3->info; + + $RIFFchunk = false; + $FoundAllChunksWeNeed = false; + + try { + $this->fseek($startoffset); + $maxoffset = min($maxoffset, $info['avdataend']); + while ($this->ftell() < $maxoffset) { + $chunknamesize = $this->fread(8); + //$chunkname = substr($chunknamesize, 0, 4); + $chunkname = str_replace("\x00", '_', substr($chunknamesize, 0, 4)); // note: chunk names of 4 null bytes do appear to be legal (has been observed inside INFO and PRMI chunks, for example), but makes traversing array keys more difficult + $chunksize = $this->EitherEndian2Int(substr($chunknamesize, 4, 4)); + //if (strlen(trim($chunkname, "\x00")) < 4) { + if (strlen($chunkname) < 4) { + $this->error('Expecting chunk name at offset '.($this->ftell() - 8).' but found nothing. Aborting RIFF parsing.'); + break; + } + if (($chunksize == 0) && ($chunkname != 'JUNK')) { + $this->warning('Chunk ('.$chunkname.') size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.'); + break; + } + if (($chunksize % 2) != 0) { + // all structures are packed on word boundaries + $chunksize++; + } + + switch ($chunkname) { + case 'LIST': + $listname = $this->fread(4); + if (preg_match('#^(movi|rec )$#i', $listname)) { + $RIFFchunk[$listname]['offset'] = $this->ftell() - 4; + $RIFFchunk[$listname]['size'] = $chunksize; + + if (!$FoundAllChunksWeNeed) { + $WhereWeWere = $this->ftell(); + $AudioChunkHeader = $this->fread(12); + $AudioChunkStreamNum = substr($AudioChunkHeader, 0, 2); + $AudioChunkStreamType = substr($AudioChunkHeader, 2, 2); + $AudioChunkSize = getid3_lib::LittleEndian2Int(substr($AudioChunkHeader, 4, 4)); + + if ($AudioChunkStreamType == 'wb') { + $FirstFourBytes = substr($AudioChunkHeader, 8, 4); + if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $FirstFourBytes)) { + // MP3 + if (getid3_mp3::MPEGaudioHeaderBytesValid($FirstFourBytes)) { + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $this->ftell() - 4; + $getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize; + $getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__); + $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false); + if (isset($getid3_temp->info['mpeg']['audio'])) { + $info['mpeg']['audio'] = $getid3_temp->info['mpeg']['audio']; + $info['audio'] = $getid3_temp->info['audio']; + $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer']; + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; + $info['audio']['channels'] = $info['mpeg']['audio']['channels']; + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; + $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); + //$info['bitrate'] = $info['audio']['bitrate']; + } + unset($getid3_temp, $getid3_mp3); + } + + } elseif (strpos($FirstFourBytes, getid3_ac3::syncword) === 0) { + + // AC3 + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $this->ftell() - 4; + $getid3_temp->info['avdataend'] = $this->ftell() + $AudioChunkSize; + $getid3_ac3 = new getid3_ac3($getid3_temp); + $getid3_ac3->Analyze(); + if (empty($getid3_temp->info['error'])) { + $info['audio'] = $getid3_temp->info['audio']; + $info['ac3'] = $getid3_temp->info['ac3']; + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $key => $value) { + $this->warning($value); + } + } + } + unset($getid3_temp, $getid3_ac3); + } + } + $FoundAllChunksWeNeed = true; + $this->fseek($WhereWeWere); + } + $this->fseek($chunksize - 4, SEEK_CUR); + + } else { + + if (!isset($RIFFchunk[$listname])) { + $RIFFchunk[$listname] = array(); + } + $LISTchunkParent = $listname; + $LISTchunkMaxOffset = $this->ftell() - 4 + $chunksize; + if ($parsedChunk = $this->ParseRIFF($this->ftell(), $LISTchunkMaxOffset)) { + $RIFFchunk[$listname] = array_merge_recursive($RIFFchunk[$listname], $parsedChunk); + } + + } + break; + + default: + if (preg_match('#^[0-9]{2}(wb|pc|dc|db)$#', $chunkname)) { + $this->fseek($chunksize, SEEK_CUR); + break; + } + $thisindex = 0; + if (isset($RIFFchunk[$chunkname]) && is_array($RIFFchunk[$chunkname])) { + $thisindex = count($RIFFchunk[$chunkname]); + } + $RIFFchunk[$chunkname][$thisindex]['offset'] = $this->ftell() - 8; + $RIFFchunk[$chunkname][$thisindex]['size'] = $chunksize; + switch ($chunkname) { + case 'data': + $info['avdataoffset'] = $this->ftell(); + $info['avdataend'] = $info['avdataoffset'] + $chunksize; + + $testData = $this->fread(36); + if ($testData === '') { + break; + } + if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($testData, 0, 4))) { + + // Probably is MP3 data + if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($testData, 0, 4))) { + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; + $getid3_temp->info['avdataend'] = $info['avdataend']; + $getid3_mp3 = new getid3_mp3($getid3_temp, __CLASS__); + $getid3_mp3->getOnlyMPEGaudioInfo($info['avdataoffset'], false); + if (empty($getid3_temp->info['error'])) { + $info['audio'] = $getid3_temp->info['audio']; + $info['mpeg'] = $getid3_temp->info['mpeg']; + } + unset($getid3_temp, $getid3_mp3); + } + + } elseif (($isRegularAC3 = (substr($testData, 0, 2) == getid3_ac3::syncword)) || substr($testData, 8, 2) == strrev(getid3_ac3::syncword)) { + + // This is probably AC-3 data + $getid3_temp = new getID3(); + if ($isRegularAC3) { + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; + $getid3_temp->info['avdataend'] = $info['avdataend']; + } + $getid3_ac3 = new getid3_ac3($getid3_temp); + if ($isRegularAC3) { + $getid3_ac3->Analyze(); + } else { + // Dolby Digital WAV + // AC-3 content, but not encoded in same format as normal AC-3 file + // For one thing, byte order is swapped + $ac3_data = ''; + for ($i = 0; $i < 28; $i += 2) { + $ac3_data .= substr($testData, 8 + $i + 1, 1); + $ac3_data .= substr($testData, 8 + $i + 0, 1); + } + $getid3_ac3->AnalyzeString($ac3_data); + } + + if (empty($getid3_temp->info['error'])) { + $info['audio'] = $getid3_temp->info['audio']; + $info['ac3'] = $getid3_temp->info['ac3']; + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $newerror) { + $this->warning('getid3_ac3() says: ['.$newerror.']'); + } + } + } + unset($getid3_temp, $getid3_ac3); + + } elseif (preg_match('/^('.implode('|', array_map('preg_quote', getid3_dts::$syncwords)).')/', $testData)) { + + // This is probably DTS data + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; + $getid3_dts = new getid3_dts($getid3_temp); + $getid3_dts->Analyze(); + if (empty($getid3_temp->info['error'])) { + $info['audio'] = $getid3_temp->info['audio']; + $info['dts'] = $getid3_temp->info['dts']; + $info['playtime_seconds'] = $getid3_temp->info['playtime_seconds']; // may not match RIFF calculations since DTS-WAV often used 14/16 bit-word packing + if (!empty($getid3_temp->info['warning'])) { + foreach ($getid3_temp->info['warning'] as $newerror) { + $this->warning('getid3_dts() says: ['.$newerror.']'); + } + } + } + + unset($getid3_temp, $getid3_dts); + + } elseif (substr($testData, 0, 4) == 'wvpk') { + + // This is WavPack data + $info['wavpack']['offset'] = $info['avdataoffset']; + $info['wavpack']['size'] = getid3_lib::LittleEndian2Int(substr($testData, 4, 4)); + $this->parseWavPackHeader(substr($testData, 8, 28)); + + } else { + // This is some other kind of data (quite possibly just PCM) + // do nothing special, just skip it + } + $nextoffset = $info['avdataend']; + $this->fseek($nextoffset); + break; + + case 'iXML': + case 'bext': + case 'cart': + case 'fmt ': + case 'strh': + case 'strf': + case 'indx': + case 'MEXT': + case 'DISP': + // always read data in + case 'JUNK': + // should be: never read data in + // but some programs write their version strings in a JUNK chunk (e.g. VirtualDub, AVIdemux, etc) + if ($chunksize < 1048576) { + if ($chunksize > 0) { + $RIFFchunk[$chunkname][$thisindex]['data'] = $this->fread($chunksize); + if ($chunkname == 'JUNK') { + if (preg_match('#^([\\x20-\\x7F]+)#', $RIFFchunk[$chunkname][$thisindex]['data'], $matches)) { + // only keep text characters [chr(32)-chr(127)] + $info['riff']['comments']['junk'][] = trim($matches[1]); + } + // but if nothing there, ignore + // remove the key in either case + unset($RIFFchunk[$chunkname][$thisindex]['data']); + } + } + } else { + $this->warning('Chunk "'.$chunkname.'" at offset '.$this->ftell().' is unexpectedly larger than 1MB (claims to be '.number_format($chunksize).' bytes), skipping data'); + $this->fseek($chunksize, SEEK_CUR); + } + break; + + //case 'IDVX': + // $info['divxtag']['comments'] = self::ParseDIVXTAG($this->fread($chunksize)); + // break; + + default: + if (!empty($LISTchunkParent) && (($RIFFchunk[$chunkname][$thisindex]['offset'] + $RIFFchunk[$chunkname][$thisindex]['size']) <= $LISTchunkMaxOffset)) { + $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['offset'] = $RIFFchunk[$chunkname][$thisindex]['offset']; + $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['size'] = $RIFFchunk[$chunkname][$thisindex]['size']; + unset($RIFFchunk[$chunkname][$thisindex]['offset']); + unset($RIFFchunk[$chunkname][$thisindex]['size']); + if (isset($RIFFchunk[$chunkname][$thisindex]) && empty($RIFFchunk[$chunkname][$thisindex])) { + unset($RIFFchunk[$chunkname][$thisindex]); + } + if (isset($RIFFchunk[$chunkname]) && empty($RIFFchunk[$chunkname])) { + unset($RIFFchunk[$chunkname]); + } + $RIFFchunk[$LISTchunkParent][$chunkname][$thisindex]['data'] = $this->fread($chunksize); + } elseif ($chunksize < 2048) { + // only read data in if smaller than 2kB + $RIFFchunk[$chunkname][$thisindex]['data'] = $this->fread($chunksize); + } else { + $this->fseek($chunksize, SEEK_CUR); + } + break; + } + break; + } + } + + } catch (getid3_exception $e) { + if ($e->getCode() == 10) { + $this->warning('RIFF parser: '.$e->getMessage()); + } else { + throw $e; + } + } + + return $RIFFchunk; + } + + public function ParseRIFFdata(&$RIFFdata) { + $info = &$this->getid3->info; + if ($RIFFdata) { + $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3'); + $fp_temp = fopen($tempfile, 'wb'); + $RIFFdataLength = strlen($RIFFdata); + $NewLengthString = getid3_lib::LittleEndian2String($RIFFdataLength, 4); + for ($i = 0; $i < 4; $i++) { + $RIFFdata[($i + 4)] = $NewLengthString[$i]; + } + fwrite($fp_temp, $RIFFdata); + fclose($fp_temp); + + $getid3_temp = new getID3(); + $getid3_temp->openfile($tempfile); + $getid3_temp->info['filesize'] = $RIFFdataLength; + $getid3_temp->info['filenamepath'] = $info['filenamepath']; + $getid3_temp->info['tags'] = $info['tags']; + $getid3_temp->info['warning'] = $info['warning']; + $getid3_temp->info['error'] = $info['error']; + $getid3_temp->info['comments'] = $info['comments']; + $getid3_temp->info['audio'] = (isset($info['audio']) ? $info['audio'] : array()); + $getid3_temp->info['video'] = (isset($info['video']) ? $info['video'] : array()); + $getid3_riff = new getid3_riff($getid3_temp); + $getid3_riff->Analyze(); + + $info['riff'] = $getid3_temp->info['riff']; + $info['warning'] = $getid3_temp->info['warning']; + $info['error'] = $getid3_temp->info['error']; + $info['tags'] = $getid3_temp->info['tags']; + $info['comments'] = $getid3_temp->info['comments']; + unset($getid3_riff, $getid3_temp); + unlink($tempfile); + } + return false; + } + + public static function parseComments(&$RIFFinfoArray, &$CommentsTargetArray) { + $RIFFinfoKeyLookup = array( + 'IARL'=>'archivallocation', + 'IART'=>'artist', + 'ICDS'=>'costumedesigner', + 'ICMS'=>'commissionedby', + 'ICMT'=>'comment', + 'ICNT'=>'country', + 'ICOP'=>'copyright', + 'ICRD'=>'creationdate', + 'IDIM'=>'dimensions', + 'IDIT'=>'digitizationdate', + 'IDPI'=>'resolution', + 'IDST'=>'distributor', + 'IEDT'=>'editor', + 'IENG'=>'engineers', + 'IFRM'=>'accountofparts', + 'IGNR'=>'genre', + 'IKEY'=>'keywords', + 'ILGT'=>'lightness', + 'ILNG'=>'language', + 'IMED'=>'orignalmedium', + 'IMUS'=>'composer', + 'INAM'=>'title', + 'IPDS'=>'productiondesigner', + 'IPLT'=>'palette', + 'IPRD'=>'product', + 'IPRO'=>'producer', + 'IPRT'=>'part', + 'IRTD'=>'rating', + 'ISBJ'=>'subject', + 'ISFT'=>'software', + 'ISGN'=>'secondarygenre', + 'ISHP'=>'sharpness', + 'ISRC'=>'sourcesupplier', + 'ISRF'=>'digitizationsource', + 'ISTD'=>'productionstudio', + 'ISTR'=>'starring', + 'ITCH'=>'encoded_by', + 'IWEB'=>'url', + 'IWRI'=>'writer', + '____'=>'comment', + ); + foreach ($RIFFinfoKeyLookup as $key => $value) { + if (isset($RIFFinfoArray[$key])) { + foreach ($RIFFinfoArray[$key] as $commentid => $commentdata) { + if (trim($commentdata['data']) != '') { + if (isset($CommentsTargetArray[$value])) { + $CommentsTargetArray[$value][] = trim($commentdata['data']); + } else { + $CommentsTargetArray[$value] = array(trim($commentdata['data'])); + } + } + } + } + } + return true; + } + + public static function parseWAVEFORMATex($WaveFormatExData) { + // shortcut + $WaveFormatEx['raw'] = array(); + $WaveFormatEx_raw = &$WaveFormatEx['raw']; + + $WaveFormatEx_raw['wFormatTag'] = substr($WaveFormatExData, 0, 2); + $WaveFormatEx_raw['nChannels'] = substr($WaveFormatExData, 2, 2); + $WaveFormatEx_raw['nSamplesPerSec'] = substr($WaveFormatExData, 4, 4); + $WaveFormatEx_raw['nAvgBytesPerSec'] = substr($WaveFormatExData, 8, 4); + $WaveFormatEx_raw['nBlockAlign'] = substr($WaveFormatExData, 12, 2); + $WaveFormatEx_raw['wBitsPerSample'] = substr($WaveFormatExData, 14, 2); + if (strlen($WaveFormatExData) > 16) { + $WaveFormatEx_raw['cbSize'] = substr($WaveFormatExData, 16, 2); + } + $WaveFormatEx_raw = array_map('getid3_lib::LittleEndian2Int', $WaveFormatEx_raw); + + $WaveFormatEx['codec'] = self::wFormatTagLookup($WaveFormatEx_raw['wFormatTag']); + $WaveFormatEx['channels'] = $WaveFormatEx_raw['nChannels']; + $WaveFormatEx['sample_rate'] = $WaveFormatEx_raw['nSamplesPerSec']; + $WaveFormatEx['bitrate'] = $WaveFormatEx_raw['nAvgBytesPerSec'] * 8; + $WaveFormatEx['bits_per_sample'] = $WaveFormatEx_raw['wBitsPerSample']; + + return $WaveFormatEx; + } + + public function parseWavPackHeader($WavPackChunkData) { + // typedef struct { + // char ckID [4]; + // long ckSize; + // short version; + // short bits; // added for version 2.00 + // short flags, shift; // added for version 3.00 + // long total_samples, crc, crc2; + // char extension [4], extra_bc, extras [3]; + // } WavpackHeader; + + // shortcut + $info = &$this->getid3->info; + $info['wavpack'] = array(); + $thisfile_wavpack = &$info['wavpack']; + + $thisfile_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 0, 2)); + if ($thisfile_wavpack['version'] >= 2) { + $thisfile_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 2, 2)); + } + if ($thisfile_wavpack['version'] >= 3) { + $thisfile_wavpack['flags_raw'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 4, 2)); + $thisfile_wavpack['shift'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 6, 2)); + $thisfile_wavpack['total_samples'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 8, 4)); + $thisfile_wavpack['crc1'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 12, 4)); + $thisfile_wavpack['crc2'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 16, 4)); + $thisfile_wavpack['extension'] = substr($WavPackChunkData, 20, 4); + $thisfile_wavpack['extra_bc'] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 24, 1)); + for ($i = 0; $i <= 2; $i++) { + $thisfile_wavpack['extras'][] = getid3_lib::LittleEndian2Int(substr($WavPackChunkData, 25 + $i, 1)); + } + + // shortcut + $thisfile_wavpack['flags'] = array(); + $thisfile_wavpack_flags = &$thisfile_wavpack['flags']; + + $thisfile_wavpack_flags['mono'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000001); + $thisfile_wavpack_flags['fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000002); + $thisfile_wavpack_flags['raw_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000004); + $thisfile_wavpack_flags['calc_noise'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000008); + $thisfile_wavpack_flags['high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000010); + $thisfile_wavpack_flags['3_byte_samples'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000020); + $thisfile_wavpack_flags['over_20_bits'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000040); + $thisfile_wavpack_flags['use_wvc'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000080); + $thisfile_wavpack_flags['noiseshaping'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000100); + $thisfile_wavpack_flags['very_fast_mode'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000200); + $thisfile_wavpack_flags['new_high_quality'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000400); + $thisfile_wavpack_flags['cancel_extreme'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x000800); + $thisfile_wavpack_flags['cross_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x001000); + $thisfile_wavpack_flags['new_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x002000); + $thisfile_wavpack_flags['joint_stereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x004000); + $thisfile_wavpack_flags['extra_decorrelation'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x008000); + $thisfile_wavpack_flags['override_noiseshape'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x010000); + $thisfile_wavpack_flags['override_jointstereo'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x020000); + $thisfile_wavpack_flags['copy_source_filetime'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x040000); + $thisfile_wavpack_flags['create_exe'] = (bool) ($thisfile_wavpack['flags_raw'] & 0x080000); + } + + return true; + } + + public static function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) { + + $parsed['biSize'] = substr($BITMAPINFOHEADER, 0, 4); // number of bytes required by the BITMAPINFOHEADER structure + $parsed['biWidth'] = substr($BITMAPINFOHEADER, 4, 4); // width of the bitmap in pixels + $parsed['biHeight'] = substr($BITMAPINFOHEADER, 8, 4); // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner + $parsed['biPlanes'] = substr($BITMAPINFOHEADER, 12, 2); // number of color planes on the target device. In most cases this value must be set to 1 + $parsed['biBitCount'] = substr($BITMAPINFOHEADER, 14, 2); // Specifies the number of bits per pixels + $parsed['biSizeImage'] = substr($BITMAPINFOHEADER, 20, 4); // size of the bitmap data section of the image (the actual pixel data, excluding BITMAPINFOHEADER and RGBQUAD structures) + $parsed['biXPelsPerMeter'] = substr($BITMAPINFOHEADER, 24, 4); // horizontal resolution, in pixels per metre, of the target device + $parsed['biYPelsPerMeter'] = substr($BITMAPINFOHEADER, 28, 4); // vertical resolution, in pixels per metre, of the target device + $parsed['biClrUsed'] = substr($BITMAPINFOHEADER, 32, 4); // actual number of color indices in the color table used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression + $parsed['biClrImportant'] = substr($BITMAPINFOHEADER, 36, 4); // number of color indices that are considered important for displaying the bitmap. If this value is zero, all colors are important + $parsed = array_map('getid3_lib::'.($littleEndian ? 'Little' : 'Big').'Endian2Int', $parsed); + + $parsed['fourcc'] = substr($BITMAPINFOHEADER, 16, 4); // compression identifier + + return $parsed; + } + + public static function ParseDIVXTAG($DIVXTAG, $raw=false) { + // structure from "IDivX" source, Form1.frm, by "Greg Frazier of Daemonic Software Group", email: gfrazier@icestorm.net, web: http://dsg.cjb.net/ + // source available at http://files.divx-digest.com/download/c663efe7ef8ad2e90bf4af4d3ea6188a/on0SWN2r/edit/IDivX.zip + // 'Byte Layout: '1111111111111111 + // '32 for Movie - 1 '1111111111111111 + // '28 for Author - 6 '6666666666666666 + // '4 for year - 2 '6666666666662222 + // '3 for genre - 3 '7777777777777777 + // '48 for Comments - 7 '7777777777777777 + // '1 for Rating - 4 '7777777777777777 + // '5 for Future Additions - 0 '333400000DIVXTAG + // '128 bytes total + + static $DIVXTAGgenre = array( + 0 => 'Action', + 1 => 'Action/Adventure', + 2 => 'Adventure', + 3 => 'Adult', + 4 => 'Anime', + 5 => 'Cartoon', + 6 => 'Claymation', + 7 => 'Comedy', + 8 => 'Commercial', + 9 => 'Documentary', + 10 => 'Drama', + 11 => 'Home Video', + 12 => 'Horror', + 13 => 'Infomercial', + 14 => 'Interactive', + 15 => 'Mystery', + 16 => 'Music Video', + 17 => 'Other', + 18 => 'Religion', + 19 => 'Sci Fi', + 20 => 'Thriller', + 21 => 'Western', + ), + $DIVXTAGrating = array( + 0 => 'Unrated', + 1 => 'G', + 2 => 'PG', + 3 => 'PG-13', + 4 => 'R', + 5 => 'NC-17', + ); + + $parsed['title'] = trim(substr($DIVXTAG, 0, 32)); + $parsed['artist'] = trim(substr($DIVXTAG, 32, 28)); + $parsed['year'] = intval(trim(substr($DIVXTAG, 60, 4))); + $parsed['comment'] = trim(substr($DIVXTAG, 64, 48)); + $parsed['genre_id'] = intval(trim(substr($DIVXTAG, 112, 3))); + $parsed['rating_id'] = ord(substr($DIVXTAG, 115, 1)); + //$parsed['padding'] = substr($DIVXTAG, 116, 5); // 5-byte null + //$parsed['magic'] = substr($DIVXTAG, 121, 7); // "DIVXTAG" + + $parsed['genre'] = (isset($DIVXTAGgenre[$parsed['genre_id']]) ? $DIVXTAGgenre[$parsed['genre_id']] : $parsed['genre_id']); + $parsed['rating'] = (isset($DIVXTAGrating[$parsed['rating_id']]) ? $DIVXTAGrating[$parsed['rating_id']] : $parsed['rating_id']); + + if (!$raw) { + unset($parsed['genre_id'], $parsed['rating_id']); + foreach ($parsed as $key => $value) { + if (!$value === '') { + unset($parsed['key']); + } + } + } + + foreach ($parsed as $tag => $value) { + $parsed[$tag] = array($value); + } + + return $parsed; + } + + public static function waveSNDMtagLookup($tagshortname) { + $begin = __LINE__; + + /** This is not a comment! + + ©kwd keywords + ©BPM bpm + ©trt tracktitle + ©des description + ©gen category + ©fin featuredinstrument + ©LID longid + ©bex bwdescription + ©pub publisher + ©cdt cdtitle + ©alb library + ©com composer + + */ + + return getid3_lib::EmbeddedLookup($tagshortname, $begin, __LINE__, __FILE__, 'riff-sndm'); + } + + public static function wFormatTagLookup($wFormatTag) { + + $begin = __LINE__; + + /** This is not a comment! + + 0x0000 Microsoft Unknown Wave Format + 0x0001 Pulse Code Modulation (PCM) + 0x0002 Microsoft ADPCM + 0x0003 IEEE Float + 0x0004 Compaq Computer VSELP + 0x0005 IBM CVSD + 0x0006 Microsoft A-Law + 0x0007 Microsoft mu-Law + 0x0008 Microsoft DTS + 0x0010 OKI ADPCM + 0x0011 Intel DVI/IMA ADPCM + 0x0012 Videologic MediaSpace ADPCM + 0x0013 Sierra Semiconductor ADPCM + 0x0014 Antex Electronics G.723 ADPCM + 0x0015 DSP Solutions DigiSTD + 0x0016 DSP Solutions DigiFIX + 0x0017 Dialogic OKI ADPCM + 0x0018 MediaVision ADPCM + 0x0019 Hewlett-Packard CU + 0x0020 Yamaha ADPCM + 0x0021 Speech Compression Sonarc + 0x0022 DSP Group TrueSpeech + 0x0023 Echo Speech EchoSC1 + 0x0024 Audiofile AF36 + 0x0025 Audio Processing Technology APTX + 0x0026 AudioFile AF10 + 0x0027 Prosody 1612 + 0x0028 LRC + 0x0030 Dolby AC2 + 0x0031 Microsoft GSM 6.10 + 0x0032 MSNAudio + 0x0033 Antex Electronics ADPCME + 0x0034 Control Resources VQLPC + 0x0035 DSP Solutions DigiREAL + 0x0036 DSP Solutions DigiADPCM + 0x0037 Control Resources CR10 + 0x0038 Natural MicroSystems VBXADPCM + 0x0039 Crystal Semiconductor IMA ADPCM + 0x003A EchoSC3 + 0x003B Rockwell ADPCM + 0x003C Rockwell Digit LK + 0x003D Xebec + 0x0040 Antex Electronics G.721 ADPCM + 0x0041 G.728 CELP + 0x0042 MSG723 + 0x0050 MPEG Layer-2 or Layer-1 + 0x0052 RT24 + 0x0053 PAC + 0x0055 MPEG Layer-3 + 0x0059 Lucent G.723 + 0x0060 Cirrus + 0x0061 ESPCM + 0x0062 Voxware + 0x0063 Canopus Atrac + 0x0064 G.726 ADPCM + 0x0065 G.722 ADPCM + 0x0066 DSAT + 0x0067 DSAT Display + 0x0069 Voxware Byte Aligned + 0x0070 Voxware AC8 + 0x0071 Voxware AC10 + 0x0072 Voxware AC16 + 0x0073 Voxware AC20 + 0x0074 Voxware MetaVoice + 0x0075 Voxware MetaSound + 0x0076 Voxware RT29HW + 0x0077 Voxware VR12 + 0x0078 Voxware VR18 + 0x0079 Voxware TQ40 + 0x0080 Softsound + 0x0081 Voxware TQ60 + 0x0082 MSRT24 + 0x0083 G.729A + 0x0084 MVI MV12 + 0x0085 DF G.726 + 0x0086 DF GSM610 + 0x0088 ISIAudio + 0x0089 Onlive + 0x0091 SBC24 + 0x0092 Dolby AC3 SPDIF + 0x0093 MediaSonic G.723 + 0x0094 Aculab PLC Prosody 8kbps + 0x0097 ZyXEL ADPCM + 0x0098 Philips LPCBB + 0x0099 Packed + 0x00FF AAC + 0x0100 Rhetorex ADPCM + 0x0101 IBM mu-law + 0x0102 IBM A-law + 0x0103 IBM AVC Adaptive Differential Pulse Code Modulation (ADPCM) + 0x0111 Vivo G.723 + 0x0112 Vivo Siren + 0x0123 Digital G.723 + 0x0125 Sanyo LD ADPCM + 0x0130 Sipro Lab Telecom ACELP NET + 0x0131 Sipro Lab Telecom ACELP 4800 + 0x0132 Sipro Lab Telecom ACELP 8V3 + 0x0133 Sipro Lab Telecom G.729 + 0x0134 Sipro Lab Telecom G.729A + 0x0135 Sipro Lab Telecom Kelvin + 0x0140 Windows Media Video V8 + 0x0150 Qualcomm PureVoice + 0x0151 Qualcomm HalfRate + 0x0155 Ring Zero Systems TUB GSM + 0x0160 Microsoft Audio 1 + 0x0161 Windows Media Audio V7 / V8 / V9 + 0x0162 Windows Media Audio Professional V9 + 0x0163 Windows Media Audio Lossless V9 + 0x0200 Creative Labs ADPCM + 0x0202 Creative Labs Fastspeech8 + 0x0203 Creative Labs Fastspeech10 + 0x0210 UHER Informatic GmbH ADPCM + 0x0220 Quarterdeck + 0x0230 I-link Worldwide VC + 0x0240 Aureal RAW Sport + 0x0250 Interactive Products HSX + 0x0251 Interactive Products RPELP + 0x0260 Consistent Software CS2 + 0x0270 Sony SCX + 0x0300 Fujitsu FM Towns Snd + 0x0400 BTV Digital + 0x0401 Intel Music Coder + 0x0450 QDesign Music + 0x0680 VME VMPCM + 0x0681 AT&T Labs TPC + 0x08AE ClearJump LiteWave + 0x1000 Olivetti GSM + 0x1001 Olivetti ADPCM + 0x1002 Olivetti CELP + 0x1003 Olivetti SBC + 0x1004 Olivetti OPR + 0x1100 Lernout & Hauspie Codec (0x1100) + 0x1101 Lernout & Hauspie CELP Codec (0x1101) + 0x1102 Lernout & Hauspie SBC Codec (0x1102) + 0x1103 Lernout & Hauspie SBC Codec (0x1103) + 0x1104 Lernout & Hauspie SBC Codec (0x1104) + 0x1400 Norris + 0x1401 AT&T ISIAudio + 0x1500 Soundspace Music Compression + 0x181C VoxWare RT24 Speech + 0x1FC4 NCT Soft ALF2CD (www.nctsoft.com) + 0x2000 Dolby AC3 + 0x2001 Dolby DTS + 0x2002 WAVE_FORMAT_14_4 + 0x2003 WAVE_FORMAT_28_8 + 0x2004 WAVE_FORMAT_COOK + 0x2005 WAVE_FORMAT_DNET + 0x674F Ogg Vorbis 1 + 0x6750 Ogg Vorbis 2 + 0x6751 Ogg Vorbis 3 + 0x676F Ogg Vorbis 1+ + 0x6770 Ogg Vorbis 2+ + 0x6771 Ogg Vorbis 3+ + 0x7A21 GSM-AMR (CBR, no SID) + 0x7A22 GSM-AMR (VBR, including SID) + 0xFFFE WAVE_FORMAT_EXTENSIBLE + 0xFFFF WAVE_FORMAT_DEVELOPMENT + + */ + + return getid3_lib::EmbeddedLookup('0x'.str_pad(strtoupper(dechex($wFormatTag)), 4, '0', STR_PAD_LEFT), $begin, __LINE__, __FILE__, 'riff-wFormatTag'); + } + + public static function fourccLookup($fourcc) { + + $begin = __LINE__; + + /** This is not a comment! + + swot http://developer.apple.com/qa/snd/snd07.html + ____ No Codec (____) + _BIT BI_BITFIELDS (Raw RGB) + _JPG JPEG compressed + _PNG PNG compressed W3C/ISO/IEC (RFC-2083) + _RAW Full Frames (Uncompressed) + _RGB Raw RGB Bitmap + _RL4 RLE 4bpp RGB + _RL8 RLE 8bpp RGB + 3IV1 3ivx MPEG-4 v1 + 3IV2 3ivx MPEG-4 v2 + 3IVX 3ivx MPEG-4 + AASC Autodesk Animator + ABYR Kensington ?ABYR? + AEMI Array Microsystems VideoONE MPEG1-I Capture + AFLC Autodesk Animator FLC + AFLI Autodesk Animator FLI + AMPG Array Microsystems VideoONE MPEG + ANIM Intel RDX (ANIM) + AP41 AngelPotion Definitive + ASV1 Asus Video v1 + ASV2 Asus Video v2 + ASVX Asus Video 2.0 (audio) + AUR2 AuraVision Aura 2 Codec - YUV 4:2:2 + AURA AuraVision Aura 1 Codec - YUV 4:1:1 + AVDJ Independent JPEG Group\'s codec (AVDJ) + AVRN Independent JPEG Group\'s codec (AVRN) + AYUV 4:4:4 YUV (AYUV) + AZPR Quicktime Apple Video (AZPR) + BGR Raw RGB32 + BLZ0 Blizzard DivX MPEG-4 + BTVC Conexant Composite Video + BINK RAD Game Tools Bink Video + BT20 Conexant Prosumer Video + BTCV Conexant Composite Video Codec + BW10 Data Translation Broadway MPEG Capture + CC12 Intel YUV12 + CDVC Canopus DV + CFCC Digital Processing Systems DPS Perception + CGDI Microsoft Office 97 Camcorder Video + CHAM Winnov Caviara Champagne + CJPG Creative WebCam JPEG + CLJR Cirrus Logic YUV 4:1:1 + CMYK Common Data Format in Printing (Colorgraph) + CPLA Weitek 4:2:0 YUV Planar + CRAM Microsoft Video 1 (CRAM) + cvid Radius Cinepak + CVID Radius Cinepak + CWLT Microsoft Color WLT DIB + CYUV Creative Labs YUV + CYUY ATI YUV + D261 H.261 + D263 H.263 + DIB Device Independent Bitmap + DIV1 FFmpeg OpenDivX + DIV2 Microsoft MPEG-4 v1/v2 + DIV3 DivX ;-) MPEG-4 v3.x Low-Motion + DIV4 DivX ;-) MPEG-4 v3.x Fast-Motion + DIV5 DivX MPEG-4 v5.x + DIV6 DivX ;-) (MS MPEG-4 v3.x) + DIVX DivX MPEG-4 v4 (OpenDivX / Project Mayo) + divx DivX MPEG-4 + DMB1 Matrox Rainbow Runner hardware MJPEG + DMB2 Paradigm MJPEG + DSVD ?DSVD? + DUCK Duck TrueMotion 1.0 + DPS0 DPS/Leitch Reality Motion JPEG + DPSC DPS/Leitch PAR Motion JPEG + DV25 Matrox DVCPRO codec + DV50 Matrox DVCPRO50 codec + DVC IEC 61834 and SMPTE 314M (DVC/DV Video) + DVCP IEC 61834 and SMPTE 314M (DVC/DV Video) + DVHD IEC Standard DV 1125 lines @ 30fps / 1250 lines @ 25fps + DVMA Darim Vision DVMPEG (dummy for MPEG compressor) (www.darvision.com) + DVSL IEC Standard DV compressed in SD (SDL) + DVAN ?DVAN? + DVE2 InSoft DVE-2 Videoconferencing + dvsd IEC 61834 and SMPTE 314M DVC/DV Video + DVSD IEC 61834 and SMPTE 314M DVC/DV Video + DVX1 Lucent DVX1000SP Video Decoder + DVX2 Lucent DVX2000S Video Decoder + DVX3 Lucent DVX3000S Video Decoder + DX50 DivX v5 + DXT1 Microsoft DirectX Compressed Texture (DXT1) + DXT2 Microsoft DirectX Compressed Texture (DXT2) + DXT3 Microsoft DirectX Compressed Texture (DXT3) + DXT4 Microsoft DirectX Compressed Texture (DXT4) + DXT5 Microsoft DirectX Compressed Texture (DXT5) + DXTC Microsoft DirectX Compressed Texture (DXTC) + DXTn Microsoft DirectX Compressed Texture (DXTn) + EM2V Etymonix MPEG-2 I-frame (www.etymonix.com) + EKQ0 Elsa ?EKQ0? + ELK0 Elsa ?ELK0? + ESCP Eidos Escape + ETV1 eTreppid Video ETV1 + ETV2 eTreppid Video ETV2 + ETVC eTreppid Video ETVC + FLIC Autodesk FLI/FLC Animation + FLV1 Sorenson Spark + FLV4 On2 TrueMotion VP6 + FRWT Darim Vision Forward Motion JPEG (www.darvision.com) + FRWU Darim Vision Forward Uncompressed (www.darvision.com) + FLJP D-Vision Field Encoded Motion JPEG + FPS1 FRAPS v1 + FRWA SoftLab-Nsk Forward Motion JPEG w/ alpha channel + FRWD SoftLab-Nsk Forward Motion JPEG + FVF1 Iterated Systems Fractal Video Frame + GLZW Motion LZW (gabest@freemail.hu) + GPEG Motion JPEG (gabest@freemail.hu) + GWLT Microsoft Greyscale WLT DIB + H260 Intel ITU H.260 Videoconferencing + H261 Intel ITU H.261 Videoconferencing + H262 Intel ITU H.262 Videoconferencing + H263 Intel ITU H.263 Videoconferencing + H264 Intel ITU H.264 Videoconferencing + H265 Intel ITU H.265 Videoconferencing + H266 Intel ITU H.266 Videoconferencing + H267 Intel ITU H.267 Videoconferencing + H268 Intel ITU H.268 Videoconferencing + H269 Intel ITU H.269 Videoconferencing + HFYU Huffman Lossless Codec + HMCR Rendition Motion Compensation Format (HMCR) + HMRR Rendition Motion Compensation Format (HMRR) + I263 FFmpeg I263 decoder + IF09 Indeo YVU9 ("YVU9 with additional delta-frame info after the U plane") + IUYV Interlaced version of UYVY (www.leadtools.com) + IY41 Interlaced version of Y41P (www.leadtools.com) + IYU1 12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard + IYU2 24 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec IEEE standard + IYUV Planar YUV format (8-bpp Y plane, followed by 8-bpp 2×2 U and V planes) + i263 Intel ITU H.263 Videoconferencing (i263) + I420 Intel Indeo 4 + IAN Intel Indeo 4 (RDX) + ICLB InSoft CellB Videoconferencing + IGOR Power DVD + IJPG Intergraph JPEG + ILVC Intel Layered Video + ILVR ITU-T H.263+ + IPDV I-O Data Device Giga AVI DV Codec + IR21 Intel Indeo 2.1 + IRAW Intel YUV Uncompressed + IV30 Intel Indeo 3.0 + IV31 Intel Indeo 3.1 + IV32 Ligos Indeo 3.2 + IV33 Ligos Indeo 3.3 + IV34 Ligos Indeo 3.4 + IV35 Ligos Indeo 3.5 + IV36 Ligos Indeo 3.6 + IV37 Ligos Indeo 3.7 + IV38 Ligos Indeo 3.8 + IV39 Ligos Indeo 3.9 + IV40 Ligos Indeo Interactive 4.0 + IV41 Ligos Indeo Interactive 4.1 + IV42 Ligos Indeo Interactive 4.2 + IV43 Ligos Indeo Interactive 4.3 + IV44 Ligos Indeo Interactive 4.4 + IV45 Ligos Indeo Interactive 4.5 + IV46 Ligos Indeo Interactive 4.6 + IV47 Ligos Indeo Interactive 4.7 + IV48 Ligos Indeo Interactive 4.8 + IV49 Ligos Indeo Interactive 4.9 + IV50 Ligos Indeo Interactive 5.0 + JBYR Kensington ?JBYR? + JPEG Still Image JPEG DIB + JPGL Pegasus Lossless Motion JPEG + KMVC Team17 Software Karl Morton\'s Video Codec + LSVM Vianet Lighting Strike Vmail (Streaming) (www.vianet.com) + LEAD LEAD Video Codec + Ljpg LEAD MJPEG Codec + MDVD Alex MicroDVD Video (hacked MS MPEG-4) (www.tiasoft.de) + MJPA Morgan Motion JPEG (MJPA) (www.morgan-multimedia.com) + MJPB Morgan Motion JPEG (MJPB) (www.morgan-multimedia.com) + MMES Matrox MPEG-2 I-frame + MP2v Microsoft S-Mpeg 4 version 1 (MP2v) + MP42 Microsoft S-Mpeg 4 version 2 (MP42) + MP43 Microsoft S-Mpeg 4 version 3 (MP43) + MP4S Microsoft S-Mpeg 4 version 3 (MP4S) + MP4V FFmpeg MPEG-4 + MPG1 FFmpeg MPEG 1/2 + MPG2 FFmpeg MPEG 1/2 + MPG3 FFmpeg DivX ;-) (MS MPEG-4 v3) + MPG4 Microsoft MPEG-4 + MPGI Sigma Designs MPEG + MPNG PNG images decoder + MSS1 Microsoft Windows Screen Video + MSZH LCL (Lossless Codec Library) (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm) + M261 Microsoft H.261 + M263 Microsoft H.263 + M4S2 Microsoft Fully Compliant MPEG-4 v2 simple profile (M4S2) + m4s2 Microsoft Fully Compliant MPEG-4 v2 simple profile (m4s2) + MC12 ATI Motion Compensation Format (MC12) + MCAM ATI Motion Compensation Format (MCAM) + MJ2C Morgan Multimedia Motion JPEG2000 + mJPG IBM Motion JPEG w/ Huffman Tables + MJPG Microsoft Motion JPEG DIB + MP42 Microsoft MPEG-4 (low-motion) + MP43 Microsoft MPEG-4 (fast-motion) + MP4S Microsoft MPEG-4 (MP4S) + mp4s Microsoft MPEG-4 (mp4s) + MPEG Chromatic Research MPEG-1 Video I-Frame + MPG4 Microsoft MPEG-4 Video High Speed Compressor + MPGI Sigma Designs MPEG + MRCA FAST Multimedia Martin Regen Codec + MRLE Microsoft Run Length Encoding + MSVC Microsoft Video 1 + MTX1 Matrox ?MTX1? + MTX2 Matrox ?MTX2? + MTX3 Matrox ?MTX3? + MTX4 Matrox ?MTX4? + MTX5 Matrox ?MTX5? + MTX6 Matrox ?MTX6? + MTX7 Matrox ?MTX7? + MTX8 Matrox ?MTX8? + MTX9 Matrox ?MTX9? + MV12 Motion Pixels Codec (old) + MWV1 Aware Motion Wavelets + nAVI SMR Codec (hack of Microsoft MPEG-4) (IRC #shadowrealm) + NT00 NewTek LightWave HDTV YUV w/ Alpha (www.newtek.com) + NUV1 NuppelVideo + NTN1 Nogatech Video Compression 1 + NVS0 nVidia GeForce Texture (NVS0) + NVS1 nVidia GeForce Texture (NVS1) + NVS2 nVidia GeForce Texture (NVS2) + NVS3 nVidia GeForce Texture (NVS3) + NVS4 nVidia GeForce Texture (NVS4) + NVS5 nVidia GeForce Texture (NVS5) + NVT0 nVidia GeForce Texture (NVT0) + NVT1 nVidia GeForce Texture (NVT1) + NVT2 nVidia GeForce Texture (NVT2) + NVT3 nVidia GeForce Texture (NVT3) + NVT4 nVidia GeForce Texture (NVT4) + NVT5 nVidia GeForce Texture (NVT5) + PIXL MiroXL, Pinnacle PCTV + PDVC I-O Data Device Digital Video Capture DV codec + PGVV Radius Video Vision + PHMO IBM Photomotion + PIM1 MPEG Realtime (Pinnacle Cards) + PIM2 Pegasus Imaging ?PIM2? + PIMJ Pegasus Imaging Lossless JPEG + PVEZ Horizons Technology PowerEZ + PVMM PacketVideo Corporation MPEG-4 + PVW2 Pegasus Imaging Wavelet Compression + Q1.0 Q-Team\'s QPEG 1.0 (www.q-team.de) + Q1.1 Q-Team\'s QPEG 1.1 (www.q-team.de) + QPEG Q-Team QPEG 1.0 + qpeq Q-Team QPEG 1.1 + RGB Raw BGR32 + RGBA Raw RGB w/ Alpha + RMP4 REALmagic MPEG-4 (unauthorized XVID copy) (www.sigmadesigns.com) + ROQV Id RoQ File Video Decoder + RPZA Quicktime Apple Video (RPZA) + RUD0 Rududu video codec (http://rududu.ifrance.com/rududu/) + RV10 RealVideo 1.0 (aka RealVideo 5.0) + RV13 RealVideo 1.0 (RV13) + RV20 RealVideo G2 + RV30 RealVideo 8 + RV40 RealVideo 9 + RGBT Raw RGB w/ Transparency + RLE Microsoft Run Length Encoder + RLE4 Run Length Encoded (4bpp, 16-color) + RLE8 Run Length Encoded (8bpp, 256-color) + RT21 Intel Indeo RealTime Video 2.1 + rv20 RealVideo G2 + rv30 RealVideo 8 + RVX Intel RDX (RVX ) + SMC Apple Graphics (SMC ) + SP54 Logitech Sunplus Sp54 Codec for Mustek GSmart Mini 2 + SPIG Radius Spigot + SVQ3 Sorenson Video 3 (Apple Quicktime 5) + s422 Tekram VideoCap C210 YUV 4:2:2 + SDCC Sun Communication Digital Camera Codec + SFMC CrystalNet Surface Fitting Method + SMSC Radius SMSC + SMSD Radius SMSD + smsv WorldConnect Wavelet Video + SPIG Radius Spigot + SPLC Splash Studios ACM Audio Codec (www.splashstudios.net) + SQZ2 Microsoft VXTreme Video Codec V2 + STVA ST Microelectronics CMOS Imager Data (Bayer) + STVB ST Microelectronics CMOS Imager Data (Nudged Bayer) + STVC ST Microelectronics CMOS Imager Data (Bunched) + STVX ST Microelectronics CMOS Imager Data (Extended CODEC Data Format) + STVY ST Microelectronics CMOS Imager Data (Extended CODEC Data Format with Correction Data) + SV10 Sorenson Video R1 + SVQ1 Sorenson Video + T420 Toshiba YUV 4:2:0 + TM2A Duck TrueMotion Archiver 2.0 (www.duck.com) + TVJP Pinnacle/Truevision Targa 2000 board (TVJP) + TVMJ Pinnacle/Truevision Targa 2000 board (TVMJ) + TY0N Tecomac Low-Bit Rate Codec (www.tecomac.com) + TY2C Trident Decompression Driver + TLMS TeraLogic Motion Intraframe Codec (TLMS) + TLST TeraLogic Motion Intraframe Codec (TLST) + TM20 Duck TrueMotion 2.0 + TM2X Duck TrueMotion 2X + TMIC TeraLogic Motion Intraframe Codec (TMIC) + TMOT Horizons Technology TrueMotion S + tmot Horizons TrueMotion Video Compression + TR20 Duck TrueMotion RealTime 2.0 + TSCC TechSmith Screen Capture Codec + TV10 Tecomac Low-Bit Rate Codec + TY2N Trident ?TY2N? + U263 UB Video H.263/H.263+/H.263++ Decoder + UMP4 UB Video MPEG 4 (www.ubvideo.com) + UYNV Nvidia UYVY packed 4:2:2 + UYVP Evans & Sutherland YCbCr 4:2:2 extended precision + UCOD eMajix.com ClearVideo + ULTI IBM Ultimotion + UYVY UYVY packed 4:2:2 + V261 Lucent VX2000S + VIFP VFAPI Reader Codec (www.yks.ne.jp/~hori/) + VIV1 FFmpeg H263+ decoder + VIV2 Vivo H.263 + VQC2 Vector-quantised codec 2 (research) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf) + VTLP Alaris VideoGramPiX + VYU9 ATI YUV (VYU9) + VYUY ATI YUV (VYUY) + V261 Lucent VX2000S + V422 Vitec Multimedia 24-bit YUV 4:2:2 Format + V655 Vitec Multimedia 16-bit YUV 4:2:2 Format + VCR1 ATI Video Codec 1 + VCR2 ATI Video Codec 2 + VCR3 ATI VCR 3.0 + VCR4 ATI VCR 4.0 + VCR5 ATI VCR 5.0 + VCR6 ATI VCR 6.0 + VCR7 ATI VCR 7.0 + VCR8 ATI VCR 8.0 + VCR9 ATI VCR 9.0 + VDCT Vitec Multimedia Video Maker Pro DIB + VDOM VDOnet VDOWave + VDOW VDOnet VDOLive (H.263) + VDTZ Darim Vison VideoTizer YUV + VGPX Alaris VideoGramPiX + VIDS Vitec Multimedia YUV 4:2:2 CCIR 601 for V422 + VIVO Vivo H.263 v2.00 + vivo Vivo H.263 + VIXL Miro/Pinnacle Video XL + VLV1 VideoLogic/PURE Digital Videologic Capture + VP30 On2 VP3.0 + VP31 On2 VP3.1 + VP6F On2 TrueMotion VP6 + VX1K Lucent VX1000S Video Codec + VX2K Lucent VX2000S Video Codec + VXSP Lucent VX1000SP Video Codec + WBVC Winbond W9960 + WHAM Microsoft Video 1 (WHAM) + WINX Winnov Software Compression + WJPG AverMedia Winbond JPEG + WMV1 Windows Media Video V7 + WMV2 Windows Media Video V8 + WMV3 Windows Media Video V9 + WNV1 Winnov Hardware Compression + XYZP Extended PAL format XYZ palette (www.riff.org) + x263 Xirlink H.263 + XLV0 NetXL Video Decoder + XMPG Xing MPEG (I-Frame only) + XVID XviD MPEG-4 (www.xvid.org) + XXAN ?XXAN? + YU92 Intel YUV (YU92) + YUNV Nvidia Uncompressed YUV 4:2:2 + YUVP Extended PAL format YUV palette (www.riff.org) + Y211 YUV 2:1:1 Packed + Y411 YUV 4:1:1 Packed + Y41B Weitek YUV 4:1:1 Planar + Y41P Brooktree PC1 YUV 4:1:1 Packed + Y41T Brooktree PC1 YUV 4:1:1 with transparency + Y42B Weitek YUV 4:2:2 Planar + Y42T Brooktree UYUV 4:2:2 with transparency + Y422 ADS Technologies Copy of UYVY used in Pyro WebCam firewire camera + Y800 Simple, single Y plane for monochrome images + Y8 Grayscale video + YC12 Intel YUV 12 codec + YUV8 Winnov Caviar YUV8 + YUV9 Intel YUV9 + YUY2 Uncompressed YUV 4:2:2 + YUYV Canopus YUV + YV12 YVU12 Planar + YVU9 Intel YVU9 Planar (8-bpp Y plane, followed by 8-bpp 4x4 U and V planes) + YVYU YVYU 4:2:2 Packed + ZLIB Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm) + ZPEG Metheus Video Zipper + + */ + + return getid3_lib::EmbeddedLookup($fourcc, $begin, __LINE__, __FILE__, 'riff-fourcc'); + } + + private function EitherEndian2Int($byteword, $signed=false) { + if ($this->container == 'riff') { + return getid3_lib::LittleEndian2Int($byteword, $signed); + } + return getid3_lib::BigEndian2Int($byteword, false, $signed); + } + +} diff --git a/backend/wp-includes/ID3/module.audio.ac3.php b/backend/wp-includes/ID3/module.audio.ac3.php new file mode 100644 index 0000000..27c328d --- /dev/null +++ b/backend/wp-includes/ID3/module.audio.ac3.php @@ -0,0 +1,733 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio.ac3.php // +// module for analyzing AC-3 (aka Dolby Digital) audio files // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + + +class getid3_ac3 extends getid3_handler +{ + private $AC3header = array(); + private $BSIoffset = 0; + + const syncword = 0x0B77; + + public function Analyze() { + $info = &$this->getid3->info; + + ///AH + $info['ac3']['raw']['bsi'] = array(); + $thisfile_ac3 = &$info['ac3']; + $thisfile_ac3_raw = &$thisfile_ac3['raw']; + $thisfile_ac3_raw_bsi = &$thisfile_ac3_raw['bsi']; + + + // http://www.atsc.org/standards/a_52a.pdf + + $info['fileformat'] = 'ac3'; + + // An AC-3 serial coded audio bit stream is made up of a sequence of synchronization frames + // Each synchronization frame contains 6 coded audio blocks (AB), each of which represent 256 + // new audio samples per channel. A synchronization information (SI) header at the beginning + // of each frame contains information needed to acquire and maintain synchronization. A + // bit stream information (BSI) header follows SI, and contains parameters describing the coded + // audio service. The coded audio blocks may be followed by an auxiliary data (Aux) field. At the + // end of each frame is an error check field that includes a CRC word for error detection. An + // additional CRC word is located in the SI header, the use of which, by a decoder, is optional. + // + // syncinfo() | bsi() | AB0 | AB1 | AB2 | AB3 | AB4 | AB5 | Aux | CRC + + // syncinfo() { + // syncword 16 + // crc1 16 + // fscod 2 + // frmsizecod 6 + // } /* end of syncinfo */ + + $this->fseek($info['avdataoffset']); + $tempAC3header = $this->fread(100); // should be enough to cover all data, there are some variable-length fields...? + $this->AC3header['syncinfo'] = getid3_lib::BigEndian2Int(substr($tempAC3header, 0, 2)); + $this->AC3header['bsi'] = getid3_lib::BigEndian2Bin(substr($tempAC3header, 2)); + $thisfile_ac3_raw_bsi['bsid'] = (getid3_lib::LittleEndian2Int(substr($tempAC3header, 5, 1)) & 0xF8) >> 3; // AC3 and E-AC3 put the "bsid" version identifier in the same place, but unfortnately the 4 bytes between the syncword and the version identifier are interpreted differently, so grab it here so the following code structure can make sense + unset($tempAC3header); + + if ($this->AC3header['syncinfo'] !== self::syncword) { + if (!$this->isDependencyFor('matroska')) { + unset($info['fileformat'], $info['ac3']); + return $this->error('Expecting "'.dechex(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.dechex($this->AC3header['syncinfo']).'"'); + } + } + + $info['audio']['dataformat'] = 'ac3'; + $info['audio']['bitrate_mode'] = 'cbr'; + $info['audio']['lossless'] = false; + + if ($thisfile_ac3_raw_bsi['bsid'] <= 8) { + + $thisfile_ac3_raw_bsi['crc1'] = getid3_lib::Bin2Dec($this->readHeaderBSI(16)); + $thisfile_ac3_raw_bsi['fscod'] = $this->readHeaderBSI(2); // 5.4.1.3 + $thisfile_ac3_raw_bsi['frmsizecod'] = $this->readHeaderBSI(6); // 5.4.1.4 + if ($thisfile_ac3_raw_bsi['frmsizecod'] > 37) { // binary: 100101 - see Table 5.18 Frame Size Code Table (1 word = 16 bits) + $this->warning('Unexpected ac3.bsi.frmsizecod value: '.$thisfile_ac3_raw_bsi['frmsizecod'].', bitrate not set correctly'); + } + + $thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5); // we already know this from pre-parsing the version identifier, but re-read it to let the bitstream flow as intended + $thisfile_ac3_raw_bsi['bsmod'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['acmod'] = $this->readHeaderBSI(3); + + if ($thisfile_ac3_raw_bsi['acmod'] & 0x01) { + // If the lsb of acmod is a 1, center channel is in use and cmixlev follows in the bit stream. + $thisfile_ac3_raw_bsi['cmixlev'] = $this->readHeaderBSI(2); + $thisfile_ac3['center_mix_level'] = self::centerMixLevelLookup($thisfile_ac3_raw_bsi['cmixlev']); + } + + if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) { + // If the msb of acmod is a 1, surround channels are in use and surmixlev follows in the bit stream. + $thisfile_ac3_raw_bsi['surmixlev'] = $this->readHeaderBSI(2); + $thisfile_ac3['surround_mix_level'] = self::surroundMixLevelLookup($thisfile_ac3_raw_bsi['surmixlev']); + } + + if ($thisfile_ac3_raw_bsi['acmod'] == 0x02) { + // When operating in the two channel mode, this 2-bit code indicates whether or not the program has been encoded in Dolby Surround. + $thisfile_ac3_raw_bsi['dsurmod'] = $this->readHeaderBSI(2); + $thisfile_ac3['dolby_surround_mode'] = self::dolbySurroundModeLookup($thisfile_ac3_raw_bsi['dsurmod']); + } + + $thisfile_ac3_raw_bsi['flags']['lfeon'] = (bool) $this->readHeaderBSI(1); + + // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1-31. + // The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent. + $thisfile_ac3_raw_bsi['dialnorm'] = $this->readHeaderBSI(5); // 5.4.2.8 dialnorm: Dialogue Normalization, 5 Bits + + $thisfile_ac3_raw_bsi['flags']['compr'] = (bool) $this->readHeaderBSI(1); // 5.4.2.9 compre: Compression Gain Word Exists, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['compr']) { + $thisfile_ac3_raw_bsi['compr'] = $this->readHeaderBSI(8); // 5.4.2.10 compr: Compression Gain Word, 8 Bits + $thisfile_ac3['heavy_compression'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr']); + } + + $thisfile_ac3_raw_bsi['flags']['langcod'] = (bool) $this->readHeaderBSI(1); // 5.4.2.11 langcode: Language Code Exists, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['langcod']) { + $thisfile_ac3_raw_bsi['langcod'] = $this->readHeaderBSI(8); // 5.4.2.12 langcod: Language Code, 8 Bits + } + + $thisfile_ac3_raw_bsi['flags']['audprodinfo'] = (bool) $this->readHeaderBSI(1); // 5.4.2.13 audprodie: Audio Production Information Exists, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['audprodinfo']) { + $thisfile_ac3_raw_bsi['mixlevel'] = $this->readHeaderBSI(5); // 5.4.2.14 mixlevel: Mixing Level, 5 Bits + $thisfile_ac3_raw_bsi['roomtyp'] = $this->readHeaderBSI(2); // 5.4.2.15 roomtyp: Room Type, 2 Bits + + $thisfile_ac3['mixing_level'] = (80 + $thisfile_ac3_raw_bsi['mixlevel']).'dB'; + $thisfile_ac3['room_type'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp']); + } + + + $thisfile_ac3_raw_bsi['dialnorm2'] = $this->readHeaderBSI(5); // 5.4.2.16 dialnorm2: Dialogue Normalization, ch2, 5 Bits + $thisfile_ac3['dialogue_normalization2'] = '-'.$thisfile_ac3_raw_bsi['dialnorm2'].'dB'; // This indicates how far the average dialogue level is below digital 100 percent. Valid values are 1-31. The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent. + + $thisfile_ac3_raw_bsi['flags']['compr2'] = (bool) $this->readHeaderBSI(1); // 5.4.2.17 compr2e: Compression Gain Word Exists, ch2, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['compr2']) { + $thisfile_ac3_raw_bsi['compr2'] = $this->readHeaderBSI(8); // 5.4.2.18 compr2: Compression Gain Word, ch2, 8 Bits + $thisfile_ac3['heavy_compression2'] = self::heavyCompression($thisfile_ac3_raw_bsi['compr2']); + } + + $thisfile_ac3_raw_bsi['flags']['langcod2'] = (bool) $this->readHeaderBSI(1); // 5.4.2.19 langcod2e: Language Code Exists, ch2, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['langcod2']) { + $thisfile_ac3_raw_bsi['langcod2'] = $this->readHeaderBSI(8); // 5.4.2.20 langcod2: Language Code, ch2, 8 Bits + } + + $thisfile_ac3_raw_bsi['flags']['audprodinfo2'] = (bool) $this->readHeaderBSI(1); // 5.4.2.21 audprodi2e: Audio Production Information Exists, ch2, 1 Bit + if ($thisfile_ac3_raw_bsi['flags']['audprodinfo2']) { + $thisfile_ac3_raw_bsi['mixlevel2'] = $this->readHeaderBSI(5); // 5.4.2.22 mixlevel2: Mixing Level, ch2, 5 Bits + $thisfile_ac3_raw_bsi['roomtyp2'] = $this->readHeaderBSI(2); // 5.4.2.23 roomtyp2: Room Type, ch2, 2 Bits + + $thisfile_ac3['mixing_level2'] = (80 + $thisfile_ac3_raw_bsi['mixlevel2']).'dB'; + $thisfile_ac3['room_type2'] = self::roomTypeLookup($thisfile_ac3_raw_bsi['roomtyp2']); + } + + $thisfile_ac3_raw_bsi['copyright'] = (bool) $this->readHeaderBSI(1); // 5.4.2.24 copyrightb: Copyright Bit, 1 Bit + + $thisfile_ac3_raw_bsi['original'] = (bool) $this->readHeaderBSI(1); // 5.4.2.25 origbs: Original Bit Stream, 1 Bit + + $thisfile_ac3_raw_bsi['flags']['timecod1'] = $this->readHeaderBSI(2); // 5.4.2.26 timecod1e, timcode2e: Time Code (first and second) Halves Exist, 2 Bits + if ($thisfile_ac3_raw_bsi['flags']['timecod1'] & 0x01) { + $thisfile_ac3_raw_bsi['timecod1'] = $this->readHeaderBSI(14); // 5.4.2.27 timecod1: Time code first half, 14 bits + $thisfile_ac3['timecode1'] = 0; + $thisfile_ac3['timecode1'] += (($thisfile_ac3_raw_bsi['timecod1'] & 0x3E00) >> 9) * 3600; // The first 5 bits of this 14-bit field represent the time in hours, with valid values of 0�23 + $thisfile_ac3['timecode1'] += (($thisfile_ac3_raw_bsi['timecod1'] & 0x01F8) >> 3) * 60; // The next 6 bits represent the time in minutes, with valid values of 0�59 + $thisfile_ac3['timecode1'] += (($thisfile_ac3_raw_bsi['timecod1'] & 0x0003) >> 0) * 8; // The final 3 bits represents the time in 8 second increments, with valid values of 0�7 (representing 0, 8, 16, ... 56 seconds) + } + if ($thisfile_ac3_raw_bsi['flags']['timecod1'] & 0x02) { + $thisfile_ac3_raw_bsi['timecod2'] = $this->readHeaderBSI(14); // 5.4.2.28 timecod2: Time code second half, 14 bits + $thisfile_ac3['timecode2'] = 0; + $thisfile_ac3['timecode2'] += (($thisfile_ac3_raw_bsi['timecod2'] & 0x3800) >> 11) * 1; // The first 3 bits of this 14-bit field represent the time in seconds, with valid values from 0�7 (representing 0-7 seconds) + $thisfile_ac3['timecode2'] += (($thisfile_ac3_raw_bsi['timecod2'] & 0x07C0) >> 6) * (1 / 30); // The next 5 bits represents the time in frames, with valid values from 0�29 (one frame = 1/30th of a second) + $thisfile_ac3['timecode2'] += (($thisfile_ac3_raw_bsi['timecod2'] & 0x003F) >> 0) * ((1 / 30) / 60); // The final 6 bits represents fractions of 1/64 of a frame, with valid values from 0�63 + } + + $thisfile_ac3_raw_bsi['flags']['addbsi'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['addbsi']) { + $thisfile_ac3_raw_bsi['addbsi_length'] = $this->readHeaderBSI(6) + 1; // This 6-bit code, which exists only if addbside is a 1, indicates the length in bytes of additional bit stream information. The valid range of addbsil is 0�63, indicating 1�64 additional bytes, respectively. + + $this->AC3header['bsi'] .= getid3_lib::BigEndian2Bin($this->fread($thisfile_ac3_raw_bsi['addbsi_length'])); + + $thisfile_ac3_raw_bsi['addbsi_data'] = substr($this->AC3header['bsi'], $this->BSIoffset, $thisfile_ac3_raw_bsi['addbsi_length'] * 8); + $this->BSIoffset += $thisfile_ac3_raw_bsi['addbsi_length'] * 8; + } + + + } elseif ($thisfile_ac3_raw_bsi['bsid'] <= 16) { // E-AC3 + + +$this->error('E-AC3 parsing is incomplete and experimental in this version of getID3 ('.$this->getid3->version().'). Notably the bitrate calculations are wrong -- value might (or not) be correct, but it is not calculated correctly. Email info@getid3.org if you know how to calculate EAC3 bitrate correctly.'); + $info['audio']['dataformat'] = 'eac3'; + + $thisfile_ac3_raw_bsi['strmtyp'] = $this->readHeaderBSI(2); + $thisfile_ac3_raw_bsi['substreamid'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['frmsiz'] = $this->readHeaderBSI(11); + $thisfile_ac3_raw_bsi['fscod'] = $this->readHeaderBSI(2); + if ($thisfile_ac3_raw_bsi['fscod'] == 3) { + $thisfile_ac3_raw_bsi['fscod2'] = $this->readHeaderBSI(2); + $thisfile_ac3_raw_bsi['numblkscod'] = 3; // six blocks per syncframe + } else { + $thisfile_ac3_raw_bsi['numblkscod'] = $this->readHeaderBSI(2); + } + $thisfile_ac3['bsi']['blocks_per_sync_frame'] = self::blocksPerSyncFrame($thisfile_ac3_raw_bsi['numblkscod']); + $thisfile_ac3_raw_bsi['acmod'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['flags']['lfeon'] = (bool) $this->readHeaderBSI(1); + $thisfile_ac3_raw_bsi['bsid'] = $this->readHeaderBSI(5); // we already know this from pre-parsing the version identifier, but re-read it to let the bitstream flow as intended + $thisfile_ac3_raw_bsi['dialnorm'] = $this->readHeaderBSI(5); + $thisfile_ac3_raw_bsi['flags']['compr'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['compr']) { + $thisfile_ac3_raw_bsi['compr'] = $this->readHeaderBSI(8); + } + if ($thisfile_ac3_raw_bsi['acmod'] == 0) { // if 1+1 mode (dual mono, so some items need a second value) + $thisfile_ac3_raw_bsi['dialnorm2'] = $this->readHeaderBSI(5); + $thisfile_ac3_raw_bsi['flags']['compr2'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['compr2']) { + $thisfile_ac3_raw_bsi['compr2'] = $this->readHeaderBSI(8); + } + } + if ($thisfile_ac3_raw_bsi['strmtyp'] == 1) { // if dependent stream + $thisfile_ac3_raw_bsi['flags']['chanmap'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['chanmap']) { + $thisfile_ac3_raw_bsi['chanmap'] = $this->readHeaderBSI(8); + } + } + $thisfile_ac3_raw_bsi['flags']['mixmdat'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['mixmdat']) { // Mixing metadata + if ($thisfile_ac3_raw_bsi['acmod'] > 2) { // if more than 2 channels + $thisfile_ac3_raw_bsi['dmixmod'] = $this->readHeaderBSI(2); + } + if (($thisfile_ac3_raw_bsi['acmod'] & 0x01) && ($thisfile_ac3_raw_bsi['acmod'] > 2)) { // if three front channels exist + $thisfile_ac3_raw_bsi['ltrtcmixlev'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['lorocmixlev'] = $this->readHeaderBSI(3); + } + if ($thisfile_ac3_raw_bsi['acmod'] & 0x04) { // if a surround channel exists + $thisfile_ac3_raw_bsi['ltrtsurmixlev'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['lorosurmixlev'] = $this->readHeaderBSI(3); + } + if ($thisfile_ac3_raw_bsi['flags']['lfeon']) { // if the LFE channel exists + $thisfile_ac3_raw_bsi['flags']['lfemixlevcod'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['lfemixlevcod']) { + $thisfile_ac3_raw_bsi['lfemixlevcod'] = $this->readHeaderBSI(5); + } + } + if ($thisfile_ac3_raw_bsi['strmtyp'] == 0) { // if independent stream + $thisfile_ac3_raw_bsi['flags']['pgmscl'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['pgmscl']) { + $thisfile_ac3_raw_bsi['pgmscl'] = $this->readHeaderBSI(6); + } + if ($thisfile_ac3_raw_bsi['acmod'] == 0) { // if 1+1 mode (dual mono, so some items need a second value) + $thisfile_ac3_raw_bsi['flags']['pgmscl2'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['pgmscl2']) { + $thisfile_ac3_raw_bsi['pgmscl2'] = $this->readHeaderBSI(6); + } + } + $thisfile_ac3_raw_bsi['flags']['extpgmscl'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['extpgmscl']) { + $thisfile_ac3_raw_bsi['extpgmscl'] = $this->readHeaderBSI(6); + } + $thisfile_ac3_raw_bsi['mixdef'] = $this->readHeaderBSI(2); + if ($thisfile_ac3_raw_bsi['mixdef'] == 1) { // mixing option 2 + $thisfile_ac3_raw_bsi['premixcmpsel'] = (bool) $this->readHeaderBSI(1); + $thisfile_ac3_raw_bsi['drcsrc'] = (bool) $this->readHeaderBSI(1); + $thisfile_ac3_raw_bsi['premixcmpscl'] = $this->readHeaderBSI(3); + } elseif ($thisfile_ac3_raw_bsi['mixdef'] == 2) { // mixing option 3 + $thisfile_ac3_raw_bsi['mixdata'] = $this->readHeaderBSI(12); + } elseif ($thisfile_ac3_raw_bsi['mixdef'] == 3) { // mixing option 4 + $mixdefbitsread = 0; + $thisfile_ac3_raw_bsi['mixdeflen'] = $this->readHeaderBSI(5); $mixdefbitsread += 5; + $thisfile_ac3_raw_bsi['flags']['mixdata2'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['mixdata2']) { + $thisfile_ac3_raw_bsi['premixcmpsel'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + $thisfile_ac3_raw_bsi['drcsrc'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + $thisfile_ac3_raw_bsi['premixcmpscl'] = $this->readHeaderBSI(3); $mixdefbitsread += 3; + $thisfile_ac3_raw_bsi['flags']['extpgmlscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmlscl']) { + $thisfile_ac3_raw_bsi['extpgmlscl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['extpgmcscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmcscl']) { + $thisfile_ac3_raw_bsi['extpgmcscl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['extpgmrscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmrscl']) { + $thisfile_ac3_raw_bsi['extpgmrscl'] = $this->readHeaderBSI(4); + } + $thisfile_ac3_raw_bsi['flags']['extpgmlsscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmlsscl']) { + $thisfile_ac3_raw_bsi['extpgmlsscl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['extpgmrsscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmrsscl']) { + $thisfile_ac3_raw_bsi['extpgmrsscl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['extpgmlfescl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmlfescl']) { + $thisfile_ac3_raw_bsi['extpgmlfescl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['dmixscl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['dmixscl']) { + $thisfile_ac3_raw_bsi['dmixscl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['addch'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['addch']) { + $thisfile_ac3_raw_bsi['flags']['extpgmaux1scl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmaux1scl']) { + $thisfile_ac3_raw_bsi['extpgmaux1scl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + $thisfile_ac3_raw_bsi['flags']['extpgmaux2scl'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['extpgmaux2scl']) { + $thisfile_ac3_raw_bsi['extpgmaux2scl'] = $this->readHeaderBSI(4); $mixdefbitsread += 4; + } + } + } + $thisfile_ac3_raw_bsi['flags']['mixdata3'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['mixdata3']) { + $thisfile_ac3_raw_bsi['spchdat'] = $this->readHeaderBSI(5); $mixdefbitsread += 5; + $thisfile_ac3_raw_bsi['flags']['addspchdat'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['addspchdat']) { + $thisfile_ac3_raw_bsi['spchdat1'] = $this->readHeaderBSI(5); $mixdefbitsread += 5; + $thisfile_ac3_raw_bsi['spchan1att'] = $this->readHeaderBSI(2); $mixdefbitsread += 2; + $thisfile_ac3_raw_bsi['flags']['addspchdat1'] = (bool) $this->readHeaderBSI(1); $mixdefbitsread += 1; + if ($thisfile_ac3_raw_bsi['flags']['addspchdat1']) { + $thisfile_ac3_raw_bsi['spchdat2'] = $this->readHeaderBSI(5); $mixdefbitsread += 5; + $thisfile_ac3_raw_bsi['spchan2att'] = $this->readHeaderBSI(3); $mixdefbitsread += 3; + } + } + } + $mixdata_bits = (8 * ($thisfile_ac3_raw_bsi['mixdeflen'] + 2)) - $mixdefbitsread; + $mixdata_fill = (($mixdata_bits % 8) ? 8 - ($mixdata_bits % 8) : 0); + $thisfile_ac3_raw_bsi['mixdata'] = $this->readHeaderBSI($mixdata_bits); + $thisfile_ac3_raw_bsi['mixdatafill'] = $this->readHeaderBSI($mixdata_fill); + unset($mixdefbitsread, $mixdata_bits, $mixdata_fill); + } + if ($thisfile_ac3_raw_bsi['acmod'] < 2) { // if mono or dual mono source + $thisfile_ac3_raw_bsi['flags']['paninfo'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['paninfo']) { + $thisfile_ac3_raw_bsi['panmean'] = $this->readHeaderBSI(8); + $thisfile_ac3_raw_bsi['paninfo'] = $this->readHeaderBSI(6); + } + if ($thisfile_ac3_raw_bsi['acmod'] == 0) { // if 1+1 mode (dual mono, so some items need a second value) + $thisfile_ac3_raw_bsi['flags']['paninfo2'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['paninfo2']) { + $thisfile_ac3_raw_bsi['panmean2'] = $this->readHeaderBSI(8); + $thisfile_ac3_raw_bsi['paninfo2'] = $this->readHeaderBSI(6); + } + } + } + $thisfile_ac3_raw_bsi['flags']['frmmixcfginfo'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['frmmixcfginfo']) { // mixing configuration information + if ($thisfile_ac3_raw_bsi['numblkscod'] == 0) { + $thisfile_ac3_raw_bsi['blkmixcfginfo'][0] = $this->readHeaderBSI(5); + } else { + for ($blk = 0; $blk < $thisfile_ac3_raw_bsi['numblkscod']; $blk++) { + $thisfile_ac3_raw_bsi['flags']['blkmixcfginfo'.$blk] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['blkmixcfginfo'.$blk]) { // mixing configuration information + $thisfile_ac3_raw_bsi['blkmixcfginfo'][$blk] = $this->readHeaderBSI(5); + } + } + } + } + } + } + $thisfile_ac3_raw_bsi['flags']['infomdat'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['infomdat']) { // Informational metadata + $thisfile_ac3_raw_bsi['bsmod'] = $this->readHeaderBSI(3); + $thisfile_ac3_raw_bsi['flags']['copyrightb'] = (bool) $this->readHeaderBSI(1); + $thisfile_ac3_raw_bsi['flags']['origbs'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['acmod'] == 2) { // if in 2/0 mode + $thisfile_ac3_raw_bsi['dsurmod'] = $this->readHeaderBSI(2); + $thisfile_ac3_raw_bsi['dheadphonmod'] = $this->readHeaderBSI(2); + } + if ($thisfile_ac3_raw_bsi['acmod'] >= 6) { // if both surround channels exist + $thisfile_ac3_raw_bsi['dsurexmod'] = $this->readHeaderBSI(2); + } + $thisfile_ac3_raw_bsi['flags']['audprodi'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['audprodi']) { + $thisfile_ac3_raw_bsi['mixlevel'] = $this->readHeaderBSI(5); + $thisfile_ac3_raw_bsi['roomtyp'] = $this->readHeaderBSI(2); + $thisfile_ac3_raw_bsi['flags']['adconvtyp'] = (bool) $this->readHeaderBSI(1); + } + if ($thisfile_ac3_raw_bsi['acmod'] == 0) { // if 1+1 mode (dual mono, so some items need a second value) + $thisfile_ac3_raw_bsi['flags']['audprodi2'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['audprodi2']) { + $thisfile_ac3_raw_bsi['mixlevel2'] = $this->readHeaderBSI(5); + $thisfile_ac3_raw_bsi['roomtyp2'] = $this->readHeaderBSI(2); + $thisfile_ac3_raw_bsi['flags']['adconvtyp2'] = (bool) $this->readHeaderBSI(1); + } + } + if ($thisfile_ac3_raw_bsi['fscod'] < 3) { // if not half sample rate + $thisfile_ac3_raw_bsi['flags']['sourcefscod'] = (bool) $this->readHeaderBSI(1); + } + } + if (($thisfile_ac3_raw_bsi['strmtyp'] == 0) && ($thisfile_ac3_raw_bsi['numblkscod'] != 3)) { // if both surround channels exist + $thisfile_ac3_raw_bsi['flags']['convsync'] = (bool) $this->readHeaderBSI(1); + } + if ($thisfile_ac3_raw_bsi['strmtyp'] == 2) { // if bit stream converted from AC-3 + if ($thisfile_ac3_raw_bsi['numblkscod'] != 3) { // 6 blocks per syncframe + $thisfile_ac3_raw_bsi['flags']['blkid'] = 1; + } else { + $thisfile_ac3_raw_bsi['flags']['blkid'] = (bool) $this->readHeaderBSI(1); + } + if ($thisfile_ac3_raw_bsi['flags']['blkid']) { + $thisfile_ac3_raw_bsi['frmsizecod'] = $this->readHeaderBSI(6); + } + } + $thisfile_ac3_raw_bsi['flags']['addbsi'] = (bool) $this->readHeaderBSI(1); + if ($thisfile_ac3_raw_bsi['flags']['addbsi']) { + $thisfile_ac3_raw_bsi['addbsil'] = $this->readHeaderBSI(6); + $thisfile_ac3_raw_bsi['addbsi'] = $this->readHeaderBSI(($thisfile_ac3_raw_bsi['addbsil'] + 1) * 8); + } + + } else { + + $this->error('Bit stream identification is version '.$thisfile_ac3_raw_bsi['bsid'].', but getID3() only understands up to version 16. Please submit a support ticket with a sample file.'); + unset($info['ac3']); + return false; + + } + + if (isset($thisfile_ac3_raw_bsi['fscod2'])) { + $thisfile_ac3['sample_rate'] = self::sampleRateCodeLookup2($thisfile_ac3_raw_bsi['fscod2']); + } else { + $thisfile_ac3['sample_rate'] = self::sampleRateCodeLookup($thisfile_ac3_raw_bsi['fscod']); + } + if ($thisfile_ac3_raw_bsi['fscod'] <= 3) { + $info['audio']['sample_rate'] = $thisfile_ac3['sample_rate']; + } else { + $this->warning('Unexpected ac3.bsi.fscod value: '.$thisfile_ac3_raw_bsi['fscod']); + } + if (isset($thisfile_ac3_raw_bsi['frmsizecod'])) { + $thisfile_ac3['frame_length'] = self::frameSizeLookup($thisfile_ac3_raw_bsi['frmsizecod'], $thisfile_ac3_raw_bsi['fscod']); + $thisfile_ac3['bitrate'] = self::bitrateLookup($thisfile_ac3_raw_bsi['frmsizecod']); + } elseif (!empty($thisfile_ac3_raw_bsi['frmsiz'])) { +// this isn't right, but it's (usually) close, roughly 5% less than it should be. +// but WHERE is the actual bitrate value stored in EAC3?? email info@getid3.org if you know! + $thisfile_ac3['bitrate'] = ($thisfile_ac3_raw_bsi['frmsiz'] + 1) * 16 * 30; // The frmsiz field shall contain a value one less than the overall size of the coded syncframe in 16-bit words. That is, this field may assume a value ranging from 0 to 2047, and these values correspond to syncframe sizes ranging from 1 to 2048. +// kludge-fix to make it approximately the expected value, still not "right": +$thisfile_ac3['bitrate'] = round(($thisfile_ac3['bitrate'] * 1.05) / 16000) * 16000; + } + $info['audio']['bitrate'] = $thisfile_ac3['bitrate']; + + $thisfile_ac3['service_type'] = self::serviceTypeLookup($thisfile_ac3_raw_bsi['bsmod'], $thisfile_ac3_raw_bsi['acmod']); + $ac3_coding_mode = self::audioCodingModeLookup($thisfile_ac3_raw_bsi['acmod']); + foreach($ac3_coding_mode as $key => $value) { + $thisfile_ac3[$key] = $value; + } + switch ($thisfile_ac3_raw_bsi['acmod']) { + case 0: + case 1: + $info['audio']['channelmode'] = 'mono'; + break; + case 3: + case 4: + $info['audio']['channelmode'] = 'stereo'; + break; + default: + $info['audio']['channelmode'] = 'surround'; + break; + } + $info['audio']['channels'] = $thisfile_ac3['num_channels']; + + $thisfile_ac3['lfe_enabled'] = $thisfile_ac3_raw_bsi['flags']['lfeon']; + if ($thisfile_ac3_raw_bsi['flags']['lfeon']) { + $info['audio']['channels'] .= '.1'; + } + + $thisfile_ac3['channels_enabled'] = self::channelsEnabledLookup($thisfile_ac3_raw_bsi['acmod'], $thisfile_ac3_raw_bsi['flags']['lfeon']); + $thisfile_ac3['dialogue_normalization'] = '-'.$thisfile_ac3_raw_bsi['dialnorm'].'dB'; + + return true; + } + + private function readHeaderBSI($length) { + $data = substr($this->AC3header['bsi'], $this->BSIoffset, $length); + $this->BSIoffset += $length; + + return bindec($data); + } + + public static function sampleRateCodeLookup($fscod) { + static $sampleRateCodeLookup = array( + 0 => 48000, + 1 => 44100, + 2 => 32000, + 3 => 'reserved' // If the reserved code is indicated, the decoder should not attempt to decode audio and should mute. + ); + return (isset($sampleRateCodeLookup[$fscod]) ? $sampleRateCodeLookup[$fscod] : false); + } + + public static function sampleRateCodeLookup2($fscod2) { + static $sampleRateCodeLookup2 = array( + 0 => 24000, + 1 => 22050, + 2 => 16000, + 3 => 'reserved' // If the reserved code is indicated, the decoder should not attempt to decode audio and should mute. + ); + return (isset($sampleRateCodeLookup2[$fscod2]) ? $sampleRateCodeLookup2[$fscod2] : false); + } + + public static function serviceTypeLookup($bsmod, $acmod) { + static $serviceTypeLookup = array(); + if (empty($serviceTypeLookup)) { + for ($i = 0; $i <= 7; $i++) { + $serviceTypeLookup[0][$i] = 'main audio service: complete main (CM)'; + $serviceTypeLookup[1][$i] = 'main audio service: music and effects (ME)'; + $serviceTypeLookup[2][$i] = 'associated service: visually impaired (VI)'; + $serviceTypeLookup[3][$i] = 'associated service: hearing impaired (HI)'; + $serviceTypeLookup[4][$i] = 'associated service: dialogue (D)'; + $serviceTypeLookup[5][$i] = 'associated service: commentary (C)'; + $serviceTypeLookup[6][$i] = 'associated service: emergency (E)'; + } + + $serviceTypeLookup[7][1] = 'associated service: voice over (VO)'; + for ($i = 2; $i <= 7; $i++) { + $serviceTypeLookup[7][$i] = 'main audio service: karaoke'; + } + } + return (isset($serviceTypeLookup[$bsmod][$acmod]) ? $serviceTypeLookup[$bsmod][$acmod] : false); + } + + public static function audioCodingModeLookup($acmod) { + // array(channel configuration, # channels (not incl LFE), channel order) + static $audioCodingModeLookup = array ( + 0 => array('channel_config'=>'1+1', 'num_channels'=>2, 'channel_order'=>'Ch1,Ch2'), + 1 => array('channel_config'=>'1/0', 'num_channels'=>1, 'channel_order'=>'C'), + 2 => array('channel_config'=>'2/0', 'num_channels'=>2, 'channel_order'=>'L,R'), + 3 => array('channel_config'=>'3/0', 'num_channels'=>3, 'channel_order'=>'L,C,R'), + 4 => array('channel_config'=>'2/1', 'num_channels'=>3, 'channel_order'=>'L,R,S'), + 5 => array('channel_config'=>'3/1', 'num_channels'=>4, 'channel_order'=>'L,C,R,S'), + 6 => array('channel_config'=>'2/2', 'num_channels'=>4, 'channel_order'=>'L,R,SL,SR'), + 7 => array('channel_config'=>'3/2', 'num_channels'=>5, 'channel_order'=>'L,C,R,SL,SR'), + ); + return (isset($audioCodingModeLookup[$acmod]) ? $audioCodingModeLookup[$acmod] : false); + } + + public static function centerMixLevelLookup($cmixlev) { + static $centerMixLevelLookup; + if (empty($centerMixLevelLookup)) { + $centerMixLevelLookup = array( + 0 => pow(2, -3.0 / 6), // 0.707 (-3.0 dB) + 1 => pow(2, -4.5 / 6), // 0.595 (-4.5 dB) + 2 => pow(2, -6.0 / 6), // 0.500 (-6.0 dB) + 3 => 'reserved' + ); + } + return (isset($centerMixLevelLookup[$cmixlev]) ? $centerMixLevelLookup[$cmixlev] : false); + } + + public static function surroundMixLevelLookup($surmixlev) { + static $surroundMixLevelLookup; + if (empty($surroundMixLevelLookup)) { + $surroundMixLevelLookup = array( + 0 => pow(2, -3.0 / 6), + 1 => pow(2, -6.0 / 6), + 2 => 0, + 3 => 'reserved' + ); + } + return (isset($surroundMixLevelLookup[$surmixlev]) ? $surroundMixLevelLookup[$surmixlev] : false); + } + + public static function dolbySurroundModeLookup($dsurmod) { + static $dolbySurroundModeLookup = array( + 0 => 'not indicated', + 1 => 'Not Dolby Surround encoded', + 2 => 'Dolby Surround encoded', + 3 => 'reserved' + ); + return (isset($dolbySurroundModeLookup[$dsurmod]) ? $dolbySurroundModeLookup[$dsurmod] : false); + } + + public static function channelsEnabledLookup($acmod, $lfeon) { + $lookup = array( + 'ch1'=>(bool) ($acmod == 0), + 'ch2'=>(bool) ($acmod == 0), + 'left'=>(bool) ($acmod > 1), + 'right'=>(bool) ($acmod > 1), + 'center'=>(bool) ($acmod & 0x01), + 'surround_mono'=>false, + 'surround_left'=>false, + 'surround_right'=>false, + 'lfe'=>$lfeon); + switch ($acmod) { + case 4: + case 5: + $lookup['surround_mono'] = true; + break; + case 6: + case 7: + $lookup['surround_left'] = true; + $lookup['surround_right'] = true; + break; + } + return $lookup; + } + + public static function heavyCompression($compre) { + // The first four bits indicate gain changes in 6.02dB increments which can be + // implemented with an arithmetic shift operation. The following four bits + // indicate linear gain changes, and require a 5-bit multiply. + // We will represent the two 4-bit fields of compr as follows: + // X0 X1 X2 X3 . Y4 Y5 Y6 Y7 + // The meaning of the X values is most simply described by considering X to represent a 4-bit + // signed integer with values from -8 to +7. The gain indicated by X is then (X + 1) * 6.02 dB. The + // following table shows this in detail. + + // Meaning of 4 msb of compr + // 7 +48.16 dB + // 6 +42.14 dB + // 5 +36.12 dB + // 4 +30.10 dB + // 3 +24.08 dB + // 2 +18.06 dB + // 1 +12.04 dB + // 0 +6.02 dB + // -1 0 dB + // -2 -6.02 dB + // -3 -12.04 dB + // -4 -18.06 dB + // -5 -24.08 dB + // -6 -30.10 dB + // -7 -36.12 dB + // -8 -42.14 dB + + $fourbit = str_pad(decbin(($compre & 0xF0) >> 4), 4, '0', STR_PAD_LEFT); + if ($fourbit{0} == '1') { + $log_gain = -8 + bindec(substr($fourbit, 1)); + } else { + $log_gain = bindec(substr($fourbit, 1)); + } + $log_gain = ($log_gain + 1) * getid3_lib::RGADamplitude2dB(2); + + // The value of Y is a linear representation of a gain change of up to -6 dB. Y is considered to + // be an unsigned fractional integer, with a leading value of 1, or: 0.1 Y4 Y5 Y6 Y7 (base 2). Y can + // represent values between 0.111112 (or 31/32) and 0.100002 (or 1/2). Thus, Y can represent gain + // changes from -0.28 dB to -6.02 dB. + + $lin_gain = (16 + ($compre & 0x0F)) / 32; + + // The combination of X and Y values allows compr to indicate gain changes from + // 48.16 - 0.28 = +47.89 dB, to + // -42.14 - 6.02 = -48.16 dB. + + return $log_gain - $lin_gain; + } + + public static function roomTypeLookup($roomtyp) { + static $roomTypeLookup = array( + 0 => 'not indicated', + 1 => 'large room, X curve monitor', + 2 => 'small room, flat monitor', + 3 => 'reserved' + ); + return (isset($roomTypeLookup[$roomtyp]) ? $roomTypeLookup[$roomtyp] : false); + } + + public static function frameSizeLookup($frmsizecod, $fscod) { + // LSB is whether padding is used or not + $padding = (bool) ($frmsizecod & 0x01); + $framesizeid = ($frmsizecod & 0x3E) >> 1; + + static $frameSizeLookup = array(); + if (empty($frameSizeLookup)) { + $frameSizeLookup = array ( + 0 => array( 128, 138, 192), // 32 kbps + 1 => array( 160, 174, 240), // 40 kbps + 2 => array( 192, 208, 288), // 48 kbps + 3 => array( 224, 242, 336), // 56 kbps + 4 => array( 256, 278, 384), // 64 kbps + 5 => array( 320, 348, 480), // 80 kbps + 6 => array( 384, 416, 576), // 96 kbps + 7 => array( 448, 486, 672), // 112 kbps + 8 => array( 512, 556, 768), // 128 kbps + 9 => array( 640, 696, 960), // 160 kbps + 10 => array( 768, 834, 1152), // 192 kbps + 11 => array( 896, 974, 1344), // 224 kbps + 12 => array(1024, 1114, 1536), // 256 kbps + 13 => array(1280, 1392, 1920), // 320 kbps + 14 => array(1536, 1670, 2304), // 384 kbps + 15 => array(1792, 1950, 2688), // 448 kbps + 16 => array(2048, 2228, 3072), // 512 kbps + 17 => array(2304, 2506, 3456), // 576 kbps + 18 => array(2560, 2786, 3840) // 640 kbps + ); + } + if (($fscod == 1) && $padding) { + // frame lengths are padded by 1 word (16 bits) at 44100 + $frameSizeLookup[$frmsizecod] += 2; + } + return (isset($frameSizeLookup[$framesizeid][$fscod]) ? $frameSizeLookup[$framesizeid][$fscod] : false); + } + + public static function bitrateLookup($frmsizecod) { + // LSB is whether padding is used or not + $padding = (bool) ($frmsizecod & 0x01); + $framesizeid = ($frmsizecod & 0x3E) >> 1; + + static $bitrateLookup = array( + 0 => 32000, + 1 => 40000, + 2 => 48000, + 3 => 56000, + 4 => 64000, + 5 => 80000, + 6 => 96000, + 7 => 112000, + 8 => 128000, + 9 => 160000, + 10 => 192000, + 11 => 224000, + 12 => 256000, + 13 => 320000, + 14 => 384000, + 15 => 448000, + 16 => 512000, + 17 => 576000, + 18 => 640000, + ); + return (isset($bitrateLookup[$framesizeid]) ? $bitrateLookup[$framesizeid] : false); + } + + public static function blocksPerSyncFrame($numblkscod) { + static $blocksPerSyncFrameLookup = array( + 0 => 1, + 1 => 2, + 2 => 3, + 3 => 6, + ); + return (isset($blocksPerSyncFrameLookup[$numblkscod]) ? $blocksPerSyncFrameLookup[$numblkscod] : false); + } + + +} diff --git a/backend/wp-includes/ID3/module.audio.dts.php b/backend/wp-includes/ID3/module.audio.dts.php new file mode 100644 index 0000000..bdc78f0 --- /dev/null +++ b/backend/wp-includes/ID3/module.audio.dts.php @@ -0,0 +1,291 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio.dts.php // +// module for analyzing DTS Audio files // +// dependencies: NONE // +// // +///////////////////////////////////////////////////////////////// + + +/** +* @tutorial http://wiki.multimedia.cx/index.php?title=DTS +*/ +class getid3_dts extends getid3_handler +{ + /** + * Default DTS syncword used in native .cpt or .dts formats + */ + const syncword = "\x7F\xFE\x80\x01"; + + private $readBinDataOffset = 0; + + /** + * Possible syncwords indicating bitstream encoding + */ + public static $syncwords = array( + 0 => "\x7F\xFE\x80\x01", // raw big-endian + 1 => "\xFE\x7F\x01\x80", // raw little-endian + 2 => "\x1F\xFF\xE8\x00", // 14-bit big-endian + 3 => "\xFF\x1F\x00\xE8"); // 14-bit little-endian + + public function Analyze() { + $info = &$this->getid3->info; + $info['fileformat'] = 'dts'; + + $this->fseek($info['avdataoffset']); + $DTSheader = $this->fread(20); // we only need 2 words magic + 6 words frame header, but these words may be normal 16-bit words OR 14-bit words with 2 highest bits set to zero, so 8 words can be either 8*16/8 = 16 bytes OR 8*16*(16/14)/8 = 18.3 bytes + + // check syncword + $sync = substr($DTSheader, 0, 4); + if (($encoding = array_search($sync, self::$syncwords)) !== false) { + + $info['dts']['raw']['magic'] = $sync; + $this->readBinDataOffset = 32; + + } elseif ($this->isDependencyFor('matroska')) { + + // Matroska contains DTS without syncword encoded as raw big-endian format + $encoding = 0; + $this->readBinDataOffset = 0; + + } else { + + unset($info['fileformat']); + return $this->error('Expecting "'.implode('| ', array_map('getid3_lib::PrintHexBytes', self::$syncwords)).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($sync).'"'); + + } + + // decode header + $fhBS = ''; + for ($word_offset = 0; $word_offset <= strlen($DTSheader); $word_offset += 2) { + switch ($encoding) { + case 0: // raw big-endian + $fhBS .= getid3_lib::BigEndian2Bin( substr($DTSheader, $word_offset, 2) ); + break; + case 1: // raw little-endian + $fhBS .= getid3_lib::BigEndian2Bin(strrev(substr($DTSheader, $word_offset, 2))); + break; + case 2: // 14-bit big-endian + $fhBS .= substr(getid3_lib::BigEndian2Bin( substr($DTSheader, $word_offset, 2) ), 2, 14); + break; + case 3: // 14-bit little-endian + $fhBS .= substr(getid3_lib::BigEndian2Bin(strrev(substr($DTSheader, $word_offset, 2))), 2, 14); + break; + } + } + + $info['dts']['raw']['frame_type'] = $this->readBinData($fhBS, 1); + $info['dts']['raw']['deficit_samples'] = $this->readBinData($fhBS, 5); + $info['dts']['flags']['crc_present'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['raw']['pcm_sample_blocks'] = $this->readBinData($fhBS, 7); + $info['dts']['raw']['frame_byte_size'] = $this->readBinData($fhBS, 14); + $info['dts']['raw']['channel_arrangement'] = $this->readBinData($fhBS, 6); + $info['dts']['raw']['sample_frequency'] = $this->readBinData($fhBS, 4); + $info['dts']['raw']['bitrate'] = $this->readBinData($fhBS, 5); + $info['dts']['flags']['embedded_downmix'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['dynamicrange'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['timestamp'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['auxdata'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['hdcd'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['raw']['extension_audio'] = $this->readBinData($fhBS, 3); + $info['dts']['flags']['extended_coding'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['audio_sync_insertion'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['raw']['lfe_effects'] = $this->readBinData($fhBS, 2); + $info['dts']['flags']['predictor_history'] = (bool) $this->readBinData($fhBS, 1); + if ($info['dts']['flags']['crc_present']) { + $info['dts']['raw']['crc16'] = $this->readBinData($fhBS, 16); + } + $info['dts']['flags']['mri_perfect_reconst'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['raw']['encoder_soft_version'] = $this->readBinData($fhBS, 4); + $info['dts']['raw']['copy_history'] = $this->readBinData($fhBS, 2); + $info['dts']['raw']['bits_per_sample'] = $this->readBinData($fhBS, 2); + $info['dts']['flags']['surround_es'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['front_sum_diff'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['flags']['surround_sum_diff'] = (bool) $this->readBinData($fhBS, 1); + $info['dts']['raw']['dialog_normalization'] = $this->readBinData($fhBS, 4); + + + $info['dts']['bitrate'] = self::bitrateLookup($info['dts']['raw']['bitrate']); + $info['dts']['bits_per_sample'] = self::bitPerSampleLookup($info['dts']['raw']['bits_per_sample']); + $info['dts']['sample_rate'] = self::sampleRateLookup($info['dts']['raw']['sample_frequency']); + $info['dts']['dialog_normalization'] = self::dialogNormalization($info['dts']['raw']['dialog_normalization'], $info['dts']['raw']['encoder_soft_version']); + $info['dts']['flags']['lossless'] = (($info['dts']['raw']['bitrate'] == 31) ? true : false); + $info['dts']['bitrate_mode'] = (($info['dts']['raw']['bitrate'] == 30) ? 'vbr' : 'cbr'); + $info['dts']['channels'] = self::numChannelsLookup($info['dts']['raw']['channel_arrangement']); + $info['dts']['channel_arrangement'] = self::channelArrangementLookup($info['dts']['raw']['channel_arrangement']); + + $info['audio']['dataformat'] = 'dts'; + $info['audio']['lossless'] = $info['dts']['flags']['lossless']; + $info['audio']['bitrate_mode'] = $info['dts']['bitrate_mode']; + $info['audio']['bits_per_sample'] = $info['dts']['bits_per_sample']; + $info['audio']['sample_rate'] = $info['dts']['sample_rate']; + $info['audio']['channels'] = $info['dts']['channels']; + $info['audio']['bitrate'] = $info['dts']['bitrate']; + if (isset($info['avdataend']) && !empty($info['dts']['bitrate']) && is_numeric($info['dts']['bitrate'])) { + $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) / ($info['dts']['bitrate'] / 8); + if (($encoding == 2) || ($encoding == 3)) { + // 14-bit data packed into 16-bit words, so the playtime is wrong because only (14/16) of the bytes in the data portion of the file are used at the specified bitrate + $info['playtime_seconds'] *= (14 / 16); + } + } + return true; + } + + private function readBinData($bin, $length) { + $data = substr($bin, $this->readBinDataOffset, $length); + $this->readBinDataOffset += $length; + + return bindec($data); + } + + public static function bitrateLookup($index) { + static $lookup = array( + 0 => 32000, + 1 => 56000, + 2 => 64000, + 3 => 96000, + 4 => 112000, + 5 => 128000, + 6 => 192000, + 7 => 224000, + 8 => 256000, + 9 => 320000, + 10 => 384000, + 11 => 448000, + 12 => 512000, + 13 => 576000, + 14 => 640000, + 15 => 768000, + 16 => 960000, + 17 => 1024000, + 18 => 1152000, + 19 => 1280000, + 20 => 1344000, + 21 => 1408000, + 22 => 1411200, + 23 => 1472000, + 24 => 1536000, + 25 => 1920000, + 26 => 2048000, + 27 => 3072000, + 28 => 3840000, + 29 => 'open', + 30 => 'variable', + 31 => 'lossless', + ); + return (isset($lookup[$index]) ? $lookup[$index] : false); + } + + public static function sampleRateLookup($index) { + static $lookup = array( + 0 => 'invalid', + 1 => 8000, + 2 => 16000, + 3 => 32000, + 4 => 'invalid', + 5 => 'invalid', + 6 => 11025, + 7 => 22050, + 8 => 44100, + 9 => 'invalid', + 10 => 'invalid', + 11 => 12000, + 12 => 24000, + 13 => 48000, + 14 => 'invalid', + 15 => 'invalid', + ); + return (isset($lookup[$index]) ? $lookup[$index] : false); + } + + public static function bitPerSampleLookup($index) { + static $lookup = array( + 0 => 16, + 1 => 20, + 2 => 24, + 3 => 24, + ); + return (isset($lookup[$index]) ? $lookup[$index] : false); + } + + public static function numChannelsLookup($index) { + switch ($index) { + case 0: + return 1; + break; + case 1: + case 2: + case 3: + case 4: + return 2; + break; + case 5: + case 6: + return 3; + break; + case 7: + case 8: + return 4; + break; + case 9: + return 5; + break; + case 10: + case 11: + case 12: + return 6; + break; + case 13: + return 7; + break; + case 14: + case 15: + return 8; + break; + } + return false; + } + + public static function channelArrangementLookup($index) { + static $lookup = array( + 0 => 'A', + 1 => 'A + B (dual mono)', + 2 => 'L + R (stereo)', + 3 => '(L+R) + (L-R) (sum-difference)', + 4 => 'LT + RT (left and right total)', + 5 => 'C + L + R', + 6 => 'L + R + S', + 7 => 'C + L + R + S', + 8 => 'L + R + SL + SR', + 9 => 'C + L + R + SL + SR', + 10 => 'CL + CR + L + R + SL + SR', + 11 => 'C + L + R+ LR + RR + OV', + 12 => 'CF + CR + LF + RF + LR + RR', + 13 => 'CL + C + CR + L + R + SL + SR', + 14 => 'CL + CR + L + R + SL1 + SL2 + SR1 + SR2', + 15 => 'CL + C+ CR + L + R + SL + S + SR', + ); + return (isset($lookup[$index]) ? $lookup[$index] : 'user-defined'); + } + + public static function dialogNormalization($index, $version) { + switch ($version) { + case 7: + return 0 - $index; + break; + case 6: + return 0 - 16 - $index; + break; + } + return false; + } + +} diff --git a/backend/wp-includes/ID3/module.audio.flac.php b/backend/wp-includes/ID3/module.audio.flac.php new file mode 100644 index 0000000..348cce3 --- /dev/null +++ b/backend/wp-includes/ID3/module.audio.flac.php @@ -0,0 +1,453 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio.flac.php // +// module for analyzing FLAC and OggFLAC audio files // +// dependencies: module.audio.ogg.php // +// /// +///////////////////////////////////////////////////////////////// + + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true); + +/** +* @tutorial http://flac.sourceforge.net/format.html +*/ +class getid3_flac extends getid3_handler +{ + const syncword = 'fLaC'; + + public function Analyze() { + $info = &$this->getid3->info; + + $this->fseek($info['avdataoffset']); + $StreamMarker = $this->fread(4); + if ($StreamMarker != self::syncword) { + return $this->error('Expecting "'.getid3_lib::PrintHexBytes(self::syncword).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($StreamMarker).'"'); + } + $info['fileformat'] = 'flac'; + $info['audio']['dataformat'] = 'flac'; + $info['audio']['bitrate_mode'] = 'vbr'; + $info['audio']['lossless'] = true; + + // parse flac container + return $this->parseMETAdata(); + } + + public function parseMETAdata() { + $info = &$this->getid3->info; + do { + $BlockOffset = $this->ftell(); + $BlockHeader = $this->fread(4); + $LBFBT = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1)); + $LastBlockFlag = (bool) ($LBFBT & 0x80); + $BlockType = ($LBFBT & 0x7F); + $BlockLength = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3)); + $BlockTypeText = self::metaBlockTypeLookup($BlockType); + + if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) { + $this->error('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file'); + break; + } + if ($BlockLength < 1) { + $this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid'); + break; + } + + $info['flac'][$BlockTypeText]['raw'] = array(); + $BlockTypeText_raw = &$info['flac'][$BlockTypeText]['raw']; + + $BlockTypeText_raw['offset'] = $BlockOffset; + $BlockTypeText_raw['last_meta_block'] = $LastBlockFlag; + $BlockTypeText_raw['block_type'] = $BlockType; + $BlockTypeText_raw['block_type_text'] = $BlockTypeText; + $BlockTypeText_raw['block_length'] = $BlockLength; + if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically + $BlockTypeText_raw['block_data'] = $this->fread($BlockLength); + } + + switch ($BlockTypeText) { + case 'STREAMINFO': // 0x00 + if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) { + return false; + } + break; + + case 'PADDING': // 0x01 + unset($info['flac']['PADDING']); // ignore + break; + + case 'APPLICATION': // 0x02 + if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) { + return false; + } + break; + + case 'SEEKTABLE': // 0x03 + if (!$this->parseSEEKTABLE($BlockTypeText_raw['block_data'])) { + return false; + } + break; + + case 'VORBIS_COMMENT': // 0x04 + if (!$this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) { + return false; + } + break; + + case 'CUESHEET': // 0x05 + if (!$this->parseCUESHEET($BlockTypeText_raw['block_data'])) { + return false; + } + break; + + case 'PICTURE': // 0x06 + if (!$this->parsePICTURE()) { + return false; + } + break; + + default: + $this->warning('Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockType.') at offset '.$BlockOffset); + } + + unset($info['flac'][$BlockTypeText]['raw']); + $info['avdataoffset'] = $this->ftell(); + } + while ($LastBlockFlag === false); + + // handle tags + if (!empty($info['flac']['VORBIS_COMMENT']['comments'])) { + $info['flac']['comments'] = $info['flac']['VORBIS_COMMENT']['comments']; + } + if (!empty($info['flac']['VORBIS_COMMENT']['vendor'])) { + $info['audio']['encoder'] = str_replace('reference ', '', $info['flac']['VORBIS_COMMENT']['vendor']); + } + + // copy attachments to 'comments' array if nesesary + if (isset($info['flac']['PICTURE']) && ($this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE)) { + foreach ($info['flac']['PICTURE'] as $entry) { + if (!empty($entry['data'])) { + if (!isset($info['flac']['comments']['picture'])) { + $info['flac']['comments']['picture'] = array(); + } + $comments_picture_data = array(); + foreach (array('data', 'image_mime', 'image_width', 'image_height', 'imagetype', 'picturetype', 'description', 'datalength') as $picture_key) { + if (isset($entry[$picture_key])) { + $comments_picture_data[$picture_key] = $entry[$picture_key]; + } + } + $info['flac']['comments']['picture'][] = $comments_picture_data; + unset($comments_picture_data); + } + } + } + + if (isset($info['flac']['STREAMINFO'])) { + if (!$this->isDependencyFor('matroska')) { + $info['flac']['compressed_audio_bytes'] = $info['avdataend'] - $info['avdataoffset']; + } + $info['flac']['uncompressed_audio_bytes'] = $info['flac']['STREAMINFO']['samples_stream'] * $info['flac']['STREAMINFO']['channels'] * ($info['flac']['STREAMINFO']['bits_per_sample'] / 8); + if ($info['flac']['uncompressed_audio_bytes'] == 0) { + return $this->error('Corrupt FLAC file: uncompressed_audio_bytes == zero'); + } + if (!empty($info['flac']['compressed_audio_bytes'])) { + $info['flac']['compression_ratio'] = $info['flac']['compressed_audio_bytes'] / $info['flac']['uncompressed_audio_bytes']; + } + } + + // set md5_data_source - built into flac 0.5+ + if (isset($info['flac']['STREAMINFO']['audio_signature'])) { + + if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) { + $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)'); + } + else { + $info['md5_data_source'] = ''; + $md5 = $info['flac']['STREAMINFO']['audio_signature']; + for ($i = 0; $i < strlen($md5); $i++) { + $info['md5_data_source'] .= str_pad(dechex(ord($md5[$i])), 2, '00', STR_PAD_LEFT); + } + if (!preg_match('/^[0-9a-f]{32}$/', $info['md5_data_source'])) { + unset($info['md5_data_source']); + } + } + } + + if (isset($info['flac']['STREAMINFO']['bits_per_sample'])) { + $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample']; + if ($info['audio']['bits_per_sample'] == 8) { + // special case + // must invert sign bit on all data bytes before MD5'ing to match FLAC's calculated value + // MD5sum calculates on unsigned bytes, but FLAC calculated MD5 on 8-bit audio data as signed + $this->warning('FLAC calculates MD5 data strangely on 8-bit audio, so the stored md5_data_source value will not match the decoded WAV file'); + } + } + + return true; + } + + private function parseSTREAMINFO($BlockData) { + $info = &$this->getid3->info; + + $info['flac']['STREAMINFO'] = array(); + $streaminfo = &$info['flac']['STREAMINFO']; + + $streaminfo['min_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2)); + $streaminfo['max_block_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2)); + $streaminfo['min_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 4, 3)); + $streaminfo['max_frame_size'] = getid3_lib::BigEndian2Int(substr($BlockData, 7, 3)); + + $SRCSBSS = getid3_lib::BigEndian2Bin(substr($BlockData, 10, 8)); + $streaminfo['sample_rate'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 0, 20)); + $streaminfo['channels'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 20, 3)) + 1; + $streaminfo['bits_per_sample'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 23, 5)) + 1; + $streaminfo['samples_stream'] = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36)); + + $streaminfo['audio_signature'] = substr($BlockData, 18, 16); + + if (!empty($streaminfo['sample_rate'])) { + + $info['audio']['bitrate_mode'] = 'vbr'; + $info['audio']['sample_rate'] = $streaminfo['sample_rate']; + $info['audio']['channels'] = $streaminfo['channels']; + $info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample']; + $info['playtime_seconds'] = $streaminfo['samples_stream'] / $streaminfo['sample_rate']; + if ($info['playtime_seconds'] > 0) { + if (!$this->isDependencyFor('matroska')) { + $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds']; + } + else { + $this->warning('Cannot determine audio bitrate because total stream size is unknown'); + } + } + + } else { + return $this->error('Corrupt METAdata block: STREAMINFO'); + } + + return true; + } + + private function parseAPPLICATION($BlockData) { + $info = &$this->getid3->info; + + $ApplicationID = getid3_lib::BigEndian2Int(substr($BlockData, 0, 4)); + $info['flac']['APPLICATION'][$ApplicationID]['name'] = self::applicationIDLookup($ApplicationID); + $info['flac']['APPLICATION'][$ApplicationID]['data'] = substr($BlockData, 4); + + return true; + } + + private function parseSEEKTABLE($BlockData) { + $info = &$this->getid3->info; + + $offset = 0; + $BlockLength = strlen($BlockData); + $placeholderpattern = str_repeat("\xFF", 8); + while ($offset < $BlockLength) { + $SampleNumberString = substr($BlockData, $offset, 8); + $offset += 8; + if ($SampleNumberString == $placeholderpattern) { + + // placeholder point + getid3_lib::safe_inc($info['flac']['SEEKTABLE']['placeholders'], 1); + $offset += 10; + + } else { + + $SampleNumber = getid3_lib::BigEndian2Int($SampleNumberString); + $info['flac']['SEEKTABLE'][$SampleNumber]['offset'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8)); + $offset += 8; + $info['flac']['SEEKTABLE'][$SampleNumber]['samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 2)); + $offset += 2; + + } + } + + return true; + } + + private function parseVORBIS_COMMENT($BlockData) { + $info = &$this->getid3->info; + + $getid3_ogg = new getid3_ogg($this->getid3); + if ($this->isDependencyFor('matroska')) { + $getid3_ogg->setStringMode($this->data_string); + } + $getid3_ogg->ParseVorbisComments(); + if (isset($info['ogg'])) { + unset($info['ogg']['comments_raw']); + $info['flac']['VORBIS_COMMENT'] = $info['ogg']; + unset($info['ogg']); + } + + unset($getid3_ogg); + + return true; + } + + private function parseCUESHEET($BlockData) { + $info = &$this->getid3->info; + $offset = 0; + $info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($BlockData, $offset, 128), "\0"); + $offset += 128; + $info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8)); + $offset += 8; + $info['flac']['CUESHEET']['flags']['is_cd'] = (bool) (getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)) & 0x80); + $offset += 1; + + $offset += 258; // reserved + + $info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)); + $offset += 1; + + for ($track = 0; $track < $info['flac']['CUESHEET']['number_tracks']; $track++) { + $TrackSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8)); + $offset += 8; + $TrackNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)); + $offset += 1; + + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['sample_offset'] = $TrackSampleOffset; + + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['isrc'] = substr($BlockData, $offset, 12); + $offset += 12; + + $TrackFlagsRaw = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)); + $offset += 1; + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['is_audio'] = (bool) ($TrackFlagsRaw & 0x80); + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['flags']['pre_emphasis'] = (bool) ($TrackFlagsRaw & 0x40); + + $offset += 13; // reserved + + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points'] = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)); + $offset += 1; + + for ($index = 0; $index < $info['flac']['CUESHEET']['tracks'][$TrackNumber]['index_points']; $index++) { + $IndexSampleOffset = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 8)); + $offset += 8; + $IndexNumber = getid3_lib::BigEndian2Int(substr($BlockData, $offset, 1)); + $offset += 1; + + $offset += 3; // reserved + + $info['flac']['CUESHEET']['tracks'][$TrackNumber]['indexes'][$IndexNumber] = $IndexSampleOffset; + } + } + + return true; + } + + /** + * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment + * External usage: audio.ogg + */ + public function parsePICTURE() { + $info = &$this->getid3->info; + + $picture['typeid'] = getid3_lib::BigEndian2Int($this->fread(4)); + $picture['picturetype'] = self::pictureTypeLookup($picture['typeid']); + $picture['image_mime'] = $this->fread(getid3_lib::BigEndian2Int($this->fread(4))); + $descr_length = getid3_lib::BigEndian2Int($this->fread(4)); + if ($descr_length) { + $picture['description'] = $this->fread($descr_length); + } + $picture['image_width'] = getid3_lib::BigEndian2Int($this->fread(4)); + $picture['image_height'] = getid3_lib::BigEndian2Int($this->fread(4)); + $picture['color_depth'] = getid3_lib::BigEndian2Int($this->fread(4)); + $picture['colors_indexed'] = getid3_lib::BigEndian2Int($this->fread(4)); + $picture['datalength'] = getid3_lib::BigEndian2Int($this->fread(4)); + + if ($picture['image_mime'] == '-->') { + $picture['data'] = $this->fread($picture['datalength']); + } else { + $picture['data'] = $this->saveAttachment( + str_replace('/', '_', $picture['picturetype']).'_'.$this->ftell(), + $this->ftell(), + $picture['datalength'], + $picture['image_mime']); + } + + $info['flac']['PICTURE'][] = $picture; + + return true; + } + + public static function metaBlockTypeLookup($blocktype) { + static $lookup = array( + 0 => 'STREAMINFO', + 1 => 'PADDING', + 2 => 'APPLICATION', + 3 => 'SEEKTABLE', + 4 => 'VORBIS_COMMENT', + 5 => 'CUESHEET', + 6 => 'PICTURE', + ); + return (isset($lookup[$blocktype]) ? $lookup[$blocktype] : 'reserved'); + } + + public static function applicationIDLookup($applicationid) { + // http://flac.sourceforge.net/id.html + static $lookup = array( + 0x41544348 => 'FlacFile', // "ATCH" + 0x42534F4C => 'beSolo', // "BSOL" + 0x42554753 => 'Bugs Player', // "BUGS" + 0x43756573 => 'GoldWave cue points (specification)', // "Cues" + 0x46696361 => 'CUE Splitter', // "Fica" + 0x46746F6C => 'flac-tools', // "Ftol" + 0x4D4F5442 => 'MOTB MetaCzar', // "MOTB" + 0x4D505345 => 'MP3 Stream Editor', // "MPSE" + 0x4D754D4C => 'MusicML: Music Metadata Language', // "MuML" + 0x52494646 => 'Sound Devices RIFF chunk storage', // "RIFF" + 0x5346464C => 'Sound Font FLAC', // "SFFL" + 0x534F4E59 => 'Sony Creative Software', // "SONY" + 0x5351455A => 'flacsqueeze', // "SQEZ" + 0x54745776 => 'TwistedWave', // "TtWv" + 0x55495453 => 'UITS Embedding tools', // "UITS" + 0x61696666 => 'FLAC AIFF chunk storage', // "aiff" + 0x696D6167 => 'flac-image application for storing arbitrary files in APPLICATION metadata blocks', // "imag" + 0x7065656D => 'Parseable Embedded Extensible Metadata (specification)', // "peem" + 0x71667374 => 'QFLAC Studio', // "qfst" + 0x72696666 => 'FLAC RIFF chunk storage', // "riff" + 0x74756E65 => 'TagTuner', // "tune" + 0x78626174 => 'XBAT', // "xbat" + 0x786D6364 => 'xmcd', // "xmcd" + ); + return (isset($lookup[$applicationid]) ? $lookup[$applicationid] : 'reserved'); + } + + public static function pictureTypeLookup($type_id) { + static $lookup = array ( + 0 => 'Other', + 1 => '32x32 pixels \'file icon\' (PNG only)', + 2 => 'Other file icon', + 3 => 'Cover (front)', + 4 => 'Cover (back)', + 5 => 'Leaflet page', + 6 => 'Media (e.g. label side of CD)', + 7 => 'Lead artist/lead performer/soloist', + 8 => 'Artist/performer', + 9 => 'Conductor', + 10 => 'Band/Orchestra', + 11 => 'Composer', + 12 => 'Lyricist/text writer', + 13 => 'Recording Location', + 14 => 'During recording', + 15 => 'During performance', + 16 => 'Movie/video screen capture', + 17 => 'A bright coloured fish', + 18 => 'Illustration', + 19 => 'Band/artist logotype', + 20 => 'Publisher/Studio logotype', + ); + return (isset($lookup[$type_id]) ? $lookup[$type_id] : 'reserved'); + } + +} diff --git a/backend/wp-includes/ID3/module.audio.mp3.php b/backend/wp-includes/ID3/module.audio.mp3.php new file mode 100644 index 0000000..ed2d844 --- /dev/null +++ b/backend/wp-includes/ID3/module.audio.mp3.php @@ -0,0 +1,2023 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio.mp3.php // +// module for analyzing MP3 files // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + + +// number of frames to scan to determine if MPEG-audio sequence is valid +// Lower this number to 5-20 for faster scanning +// Increase this number to 50+ for most accurate detection of valid VBR/CBR +// mpeg-audio streams +define('GETID3_MP3_VALID_CHECK_FRAMES', 35); + + +class getid3_mp3 extends getid3_handler +{ + + public $allow_bruteforce = false; // forces getID3() to scan the file byte-by-byte and log all the valid audio frame headers - extremely slow, unrecommended, but may provide data from otherwise-unusuable files + + public function Analyze() { + $info = &$this->getid3->info; + + $initialOffset = $info['avdataoffset']; + + if (!$this->getOnlyMPEGaudioInfo($info['avdataoffset'])) { + if ($this->allow_bruteforce) { + $this->error('Rescanning file in BruteForce mode'); + $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp, $info); + } + } + + + if (isset($info['mpeg']['audio']['bitrate_mode'])) { + $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']); + } + + if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) { + + $synchoffsetwarning = 'Unknown data before synch '; + if (isset($info['id3v2']['headerlength'])) { + $synchoffsetwarning .= '(ID3v2 header ends at '.$info['id3v2']['headerlength'].', then '.($info['avdataoffset'] - $info['id3v2']['headerlength']).' bytes garbage, '; + } elseif ($initialOffset > 0) { + $synchoffsetwarning .= '(should be at '.$initialOffset.', '; + } else { + $synchoffsetwarning .= '(should be at beginning of file, '; + } + $synchoffsetwarning .= 'synch detected at '.$info['avdataoffset'].')'; + if (isset($info['audio']['bitrate_mode']) && ($info['audio']['bitrate_mode'] == 'cbr')) { + + if (!empty($info['id3v2']['headerlength']) && (($info['avdataoffset'] - $info['id3v2']['headerlength']) == $info['mpeg']['audio']['framelength'])) { + + $synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90-3.92) DLL in CBR mode.'; + $info['audio']['codec'] = 'LAME'; + $CurrentDataLAMEversionString = 'LAME3.'; + + } elseif (empty($info['id3v2']['headerlength']) && ($info['avdataoffset'] == $info['mpeg']['audio']['framelength'])) { + + $synchoffsetwarning .= '. This is a known problem with some versions of LAME (3.90 - 3.92) DLL in CBR mode.'; + $info['audio']['codec'] = 'LAME'; + $CurrentDataLAMEversionString = 'LAME3.'; + + } + + } + $this->warning($synchoffsetwarning); + + } + + if (isset($info['mpeg']['audio']['LAME'])) { + $info['audio']['codec'] = 'LAME'; + if (!empty($info['mpeg']['audio']['LAME']['long_version'])) { + $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['long_version'], "\x00"); + } elseif (!empty($info['mpeg']['audio']['LAME']['short_version'])) { + $info['audio']['encoder'] = rtrim($info['mpeg']['audio']['LAME']['short_version'], "\x00"); + } + } + + $CurrentDataLAMEversionString = (!empty($CurrentDataLAMEversionString) ? $CurrentDataLAMEversionString : (isset($info['audio']['encoder']) ? $info['audio']['encoder'] : '')); + if (!empty($CurrentDataLAMEversionString) && (substr($CurrentDataLAMEversionString, 0, 6) == 'LAME3.') && !preg_match('[0-9\)]', substr($CurrentDataLAMEversionString, -1))) { + // a version number of LAME that does not end with a number like "LAME3.92" + // or with a closing parenthesis like "LAME3.88 (alpha)" + // or a version of LAME with the LAMEtag-not-filled-in-DLL-mode bug (3.90-3.92) + + // not sure what the actual last frame length will be, but will be less than or equal to 1441 + $PossiblyLongerLAMEversion_FrameLength = 1441; + + // Not sure what version of LAME this is - look in padding of last frame for longer version string + $PossibleLAMEversionStringOffset = $info['avdataend'] - $PossiblyLongerLAMEversion_FrameLength; + $this->fseek($PossibleLAMEversionStringOffset); + $PossiblyLongerLAMEversion_Data = $this->fread($PossiblyLongerLAMEversion_FrameLength); + switch (substr($CurrentDataLAMEversionString, -1)) { + case 'a': + case 'b': + // "LAME3.94a" will have a longer version string of "LAME3.94 (alpha)" for example + // need to trim off "a" to match longer string + $CurrentDataLAMEversionString = substr($CurrentDataLAMEversionString, 0, -1); + break; + } + if (($PossiblyLongerLAMEversion_String = strstr($PossiblyLongerLAMEversion_Data, $CurrentDataLAMEversionString)) !== false) { + if (substr($PossiblyLongerLAMEversion_String, 0, strlen($CurrentDataLAMEversionString)) == $CurrentDataLAMEversionString) { + $PossiblyLongerLAMEversion_NewString = substr($PossiblyLongerLAMEversion_String, 0, strspn($PossiblyLongerLAMEversion_String, 'LAME0123456789., (abcdefghijklmnopqrstuvwxyzJFSOND)')); //"LAME3.90.3" "LAME3.87 (beta 1, Sep 27 2000)" "LAME3.88 (beta)" + if (empty($info['audio']['encoder']) || (strlen($PossiblyLongerLAMEversion_NewString) > strlen($info['audio']['encoder']))) { + $info['audio']['encoder'] = $PossiblyLongerLAMEversion_NewString; + } + } + } + } + if (!empty($info['audio']['encoder'])) { + $info['audio']['encoder'] = rtrim($info['audio']['encoder'], "\x00 "); + } + + switch (isset($info['mpeg']['audio']['layer']) ? $info['mpeg']['audio']['layer'] : '') { + case 1: + case 2: + $info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer']; + break; + } + if (isset($info['fileformat']) && ($info['fileformat'] == 'mp3')) { + switch ($info['audio']['dataformat']) { + case 'mp1': + case 'mp2': + case 'mp3': + $info['fileformat'] = $info['audio']['dataformat']; + break; + + default: + $this->warning('Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$info['audio']['dataformat'].'"'); + break; + } + } + + if (empty($info['fileformat'])) { + unset($info['fileformat']); + unset($info['audio']['bitrate_mode']); + unset($info['avdataoffset']); + unset($info['avdataend']); + return false; + } + + $info['mime_type'] = 'audio/mpeg'; + $info['audio']['lossless'] = false; + + // Calculate playtime + if (!isset($info['playtime_seconds']) && isset($info['audio']['bitrate']) && ($info['audio']['bitrate'] > 0)) { + $info['playtime_seconds'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['audio']['bitrate']; + } + + $info['audio']['encoder_options'] = $this->GuessEncoderOptions(); + + return true; + } + + + public function GuessEncoderOptions() { + // shortcuts + $info = &$this->getid3->info; + if (!empty($info['mpeg']['audio'])) { + $thisfile_mpeg_audio = &$info['mpeg']['audio']; + if (!empty($thisfile_mpeg_audio['LAME'])) { + $thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME']; + } + } + + $encoder_options = ''; + static $NamedPresetBitrates = array(16, 24, 40, 56, 112, 128, 160, 192, 256); + + if (isset($thisfile_mpeg_audio['VBR_method']) && ($thisfile_mpeg_audio['VBR_method'] == 'Fraunhofer') && !empty($thisfile_mpeg_audio['VBR_quality'])) { + + $encoder_options = 'VBR q'.$thisfile_mpeg_audio['VBR_quality']; + + } elseif (!empty($thisfile_mpeg_audio_lame['preset_used']) && (!in_array($thisfile_mpeg_audio_lame['preset_used_id'], $NamedPresetBitrates))) { + + $encoder_options = $thisfile_mpeg_audio_lame['preset_used']; + + } elseif (!empty($thisfile_mpeg_audio_lame['vbr_quality'])) { + + static $KnownEncoderValues = array(); + if (empty($KnownEncoderValues)) { + + //$KnownEncoderValues[abrbitrate_minbitrate][vbr_quality][raw_vbr_method][raw_noise_shaping][raw_stereo_mode][ath_type][lowpass_frequency] = 'preset name'; + $KnownEncoderValues[0xFF][58][1][1][3][2][20500] = '--alt-preset insane'; // 3.90, 3.90.1, 3.92 + $KnownEncoderValues[0xFF][58][1][1][3][2][20600] = '--alt-preset insane'; // 3.90.2, 3.90.3, 3.91 + $KnownEncoderValues[0xFF][57][1][1][3][4][20500] = '--alt-preset insane'; // 3.94, 3.95 + $KnownEncoderValues['**'][78][3][2][3][2][19500] = '--alt-preset extreme'; // 3.90, 3.90.1, 3.92 + $KnownEncoderValues['**'][78][3][2][3][2][19600] = '--alt-preset extreme'; // 3.90.2, 3.91 + $KnownEncoderValues['**'][78][3][1][3][2][19600] = '--alt-preset extreme'; // 3.90.3 + $KnownEncoderValues['**'][78][4][2][3][2][19500] = '--alt-preset fast extreme'; // 3.90, 3.90.1, 3.92 + $KnownEncoderValues['**'][78][4][2][3][2][19600] = '--alt-preset fast extreme'; // 3.90.2, 3.90.3, 3.91 + $KnownEncoderValues['**'][78][3][2][3][4][19000] = '--alt-preset standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues['**'][78][3][1][3][4][19000] = '--alt-preset standard'; // 3.90.3 + $KnownEncoderValues['**'][78][4][2][3][4][19000] = '--alt-preset fast standard'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues['**'][78][4][1][3][4][19000] = '--alt-preset fast standard'; // 3.90.3 + $KnownEncoderValues['**'][88][4][1][3][3][19500] = '--r3mix'; // 3.90, 3.90.1, 3.92 + $KnownEncoderValues['**'][88][4][1][3][3][19600] = '--r3mix'; // 3.90.2, 3.90.3, 3.91 + $KnownEncoderValues['**'][67][4][1][3][4][18000] = '--r3mix'; // 3.94, 3.95 + $KnownEncoderValues['**'][68][3][2][3][4][18000] = '--alt-preset medium'; // 3.90.3 + $KnownEncoderValues['**'][68][4][2][3][4][18000] = '--alt-preset fast medium'; // 3.90.3 + + $KnownEncoderValues[0xFF][99][1][1][1][2][0] = '--preset studio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0xFF][58][2][1][3][2][20600] = '--preset studio'; // 3.90.3, 3.93.1 + $KnownEncoderValues[0xFF][58][2][1][3][2][20500] = '--preset studio'; // 3.93 + $KnownEncoderValues[0xFF][57][2][1][3][4][20500] = '--preset studio'; // 3.94, 3.95 + $KnownEncoderValues[0xC0][88][1][1][1][2][0] = '--preset cd'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0xC0][58][2][2][3][2][19600] = '--preset cd'; // 3.90.3, 3.93.1 + $KnownEncoderValues[0xC0][58][2][2][3][2][19500] = '--preset cd'; // 3.93 + $KnownEncoderValues[0xC0][57][2][1][3][4][19500] = '--preset cd'; // 3.94, 3.95 + $KnownEncoderValues[0xA0][78][1][1][3][2][18000] = '--preset hifi'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0xA0][58][2][2][3][2][18000] = '--preset hifi'; // 3.90.3, 3.93, 3.93.1 + $KnownEncoderValues[0xA0][57][2][1][3][4][18000] = '--preset hifi'; // 3.94, 3.95 + $KnownEncoderValues[0x80][67][1][1][3][2][18000] = '--preset tape'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0x80][67][1][1][3][2][15000] = '--preset radio'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0x70][67][1][1][3][2][15000] = '--preset fm'; // 3.90, 3.90.1, 3.90.2, 3.91, 3.92 + $KnownEncoderValues[0x70][58][2][2][3][2][16000] = '--preset tape/radio/fm'; // 3.90.3, 3.93, 3.93.1 + $KnownEncoderValues[0x70][57][2][1][3][4][16000] = '--preset tape/radio/fm'; // 3.94, 3.95 + $KnownEncoderValues[0x38][58][2][2][0][2][10000] = '--preset voice'; // 3.90.3, 3.93, 3.93.1 + $KnownEncoderValues[0x38][57][2][1][0][4][15000] = '--preset voice'; // 3.94, 3.95 + $KnownEncoderValues[0x38][57][2][1][0][4][16000] = '--preset voice'; // 3.94a14 + $KnownEncoderValues[0x28][65][1][1][0][2][7500] = '--preset mw-us'; // 3.90, 3.90.1, 3.92 + $KnownEncoderValues[0x28][65][1][1][0][2][7600] = '--preset mw-us'; // 3.90.2, 3.91 + $KnownEncoderValues[0x28][58][2][2][0][2][7000] = '--preset mw-us'; // 3.90.3, 3.93, 3.93.1 + $KnownEncoderValues[0x28][57][2][1][0][4][10500] = '--preset mw-us'; // 3.94, 3.95 + $KnownEncoderValues[0x28][57][2][1][0][4][11200] = '--preset mw-us'; // 3.94a14 + $KnownEncoderValues[0x28][57][2][1][0][4][8800] = '--preset mw-us'; // 3.94a15 + $KnownEncoderValues[0x18][58][2][2][0][2][4000] = '--preset phon+/lw/mw-eu/sw'; // 3.90.3, 3.93.1 + $KnownEncoderValues[0x18][58][2][2][0][2][3900] = '--preset phon+/lw/mw-eu/sw'; // 3.93 + $KnownEncoderValues[0x18][57][2][1][0][4][5900] = '--preset phon+/lw/mw-eu/sw'; // 3.94, 3.95 + $KnownEncoderValues[0x18][57][2][1][0][4][6200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a14 + $KnownEncoderValues[0x18][57][2][1][0][4][3200] = '--preset phon+/lw/mw-eu/sw'; // 3.94a15 + $KnownEncoderValues[0x10][58][2][2][0][2][3800] = '--preset phone'; // 3.90.3, 3.93.1 + $KnownEncoderValues[0x10][58][2][2][0][2][3700] = '--preset phone'; // 3.93 + $KnownEncoderValues[0x10][57][2][1][0][4][5600] = '--preset phone'; // 3.94, 3.95 + } + + if (isset($KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) { + + $encoder_options = $KnownEncoderValues[$thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']]; + + } elseif (isset($KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']])) { + + $encoder_options = $KnownEncoderValues['**'][$thisfile_mpeg_audio_lame['vbr_quality']][$thisfile_mpeg_audio_lame['raw']['vbr_method']][$thisfile_mpeg_audio_lame['raw']['noise_shaping']][$thisfile_mpeg_audio_lame['raw']['stereo_mode']][$thisfile_mpeg_audio_lame['ath_type']][$thisfile_mpeg_audio_lame['lowpass_frequency']]; + + } elseif ($info['audio']['bitrate_mode'] == 'vbr') { + + // http://gabriel.mp3-tech.org/mp3infotag.html + // int Quality = (100 - 10 * gfp->VBR_q - gfp->quality)h + + + $LAME_V_value = 10 - ceil($thisfile_mpeg_audio_lame['vbr_quality'] / 10); + $LAME_q_value = 100 - $thisfile_mpeg_audio_lame['vbr_quality'] - ($LAME_V_value * 10); + $encoder_options = '-V'.$LAME_V_value.' -q'.$LAME_q_value; + + } elseif ($info['audio']['bitrate_mode'] == 'cbr') { + + $encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000); + + } else { + + $encoder_options = strtoupper($info['audio']['bitrate_mode']); + + } + + } elseif (!empty($thisfile_mpeg_audio_lame['bitrate_abr'])) { + + $encoder_options = 'ABR'.$thisfile_mpeg_audio_lame['bitrate_abr']; + + } elseif (!empty($info['audio']['bitrate'])) { + + if ($info['audio']['bitrate_mode'] == 'cbr') { + $encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000); + } else { + $encoder_options = strtoupper($info['audio']['bitrate_mode']); + } + + } + if (!empty($thisfile_mpeg_audio_lame['bitrate_min'])) { + $encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min']; + } + + if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) { + $encoder_options .= ' --nogap'; + } + + if (!empty($thisfile_mpeg_audio_lame['lowpass_frequency'])) { + $ExplodedOptions = explode(' ', $encoder_options, 4); + if ($ExplodedOptions[0] == '--r3mix') { + $ExplodedOptions[1] = 'r3mix'; + } + switch ($ExplodedOptions[0]) { + case '--preset': + case '--alt-preset': + case '--r3mix': + if ($ExplodedOptions[1] == 'fast') { + $ExplodedOptions[1] .= ' '.$ExplodedOptions[2]; + } + switch ($ExplodedOptions[1]) { + case 'portable': + case 'medium': + case 'standard': + case 'extreme': + case 'insane': + case 'fast portable': + case 'fast medium': + case 'fast standard': + case 'fast extreme': + case 'fast insane': + case 'r3mix': + static $ExpectedLowpass = array( + 'insane|20500' => 20500, + 'insane|20600' => 20600, // 3.90.2, 3.90.3, 3.91 + 'medium|18000' => 18000, + 'fast medium|18000' => 18000, + 'extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 + 'extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 + 'fast extreme|19500' => 19500, // 3.90, 3.90.1, 3.92, 3.95 + 'fast extreme|19600' => 19600, // 3.90.2, 3.90.3, 3.91, 3.93.1 + 'standard|19000' => 19000, + 'fast standard|19000' => 19000, + 'r3mix|19500' => 19500, // 3.90, 3.90.1, 3.92 + 'r3mix|19600' => 19600, // 3.90.2, 3.90.3, 3.91 + 'r3mix|18000' => 18000, // 3.94, 3.95 + ); + if (!isset($ExpectedLowpass[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio_lame['lowpass_frequency']]) && ($thisfile_mpeg_audio_lame['lowpass_frequency'] < 22050) && (round($thisfile_mpeg_audio_lame['lowpass_frequency'] / 1000) < round($thisfile_mpeg_audio['sample_rate'] / 2000))) { + $encoder_options .= ' --lowpass '.$thisfile_mpeg_audio_lame['lowpass_frequency']; + } + break; + + default: + break; + } + break; + } + } + + if (isset($thisfile_mpeg_audio_lame['raw']['source_sample_freq'])) { + if (($thisfile_mpeg_audio['sample_rate'] == 44100) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 1)) { + $encoder_options .= ' --resample 44100'; + } elseif (($thisfile_mpeg_audio['sample_rate'] == 48000) && ($thisfile_mpeg_audio_lame['raw']['source_sample_freq'] != 2)) { + $encoder_options .= ' --resample 48000'; + } elseif ($thisfile_mpeg_audio['sample_rate'] < 44100) { + switch ($thisfile_mpeg_audio_lame['raw']['source_sample_freq']) { + case 0: // <= 32000 + // may or may not be same as source frequency - ignore + break; + case 1: // 44100 + case 2: // 48000 + case 3: // 48000+ + $ExplodedOptions = explode(' ', $encoder_options, 4); + switch ($ExplodedOptions[0]) { + case '--preset': + case '--alt-preset': + switch ($ExplodedOptions[1]) { + case 'fast': + case 'portable': + case 'medium': + case 'standard': + case 'extreme': + case 'insane': + $encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate']; + break; + + default: + static $ExpectedResampledRate = array( + 'phon+/lw/mw-eu/sw|16000' => 16000, + 'mw-us|24000' => 24000, // 3.95 + 'mw-us|32000' => 32000, // 3.93 + 'mw-us|16000' => 16000, // 3.92 + 'phone|16000' => 16000, + 'phone|11025' => 11025, // 3.94a15 + 'radio|32000' => 32000, // 3.94a15 + 'fm/radio|32000' => 32000, // 3.92 + 'fm|32000' => 32000, // 3.90 + 'voice|32000' => 32000); + if (!isset($ExpectedResampledRate[$ExplodedOptions[1].'|'.$thisfile_mpeg_audio['sample_rate']])) { + $encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate']; + } + break; + } + break; + + case '--r3mix': + default: + $encoder_options .= ' --resample '.$thisfile_mpeg_audio['sample_rate']; + break; + } + break; + } + } + } + if (empty($encoder_options) && !empty($info['audio']['bitrate']) && !empty($info['audio']['bitrate_mode'])) { + //$encoder_options = strtoupper($info['audio']['bitrate_mode']).ceil($info['audio']['bitrate'] / 1000); + $encoder_options = strtoupper($info['audio']['bitrate_mode']); + } + + return $encoder_options; + } + + + public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) { + static $MPEGaudioVersionLookup; + static $MPEGaudioLayerLookup; + static $MPEGaudioBitrateLookup; + static $MPEGaudioFrequencyLookup; + static $MPEGaudioChannelModeLookup; + static $MPEGaudioModeExtensionLookup; + static $MPEGaudioEmphasisLookup; + if (empty($MPEGaudioVersionLookup)) { + $MPEGaudioVersionLookup = self::MPEGaudioVersionArray(); + $MPEGaudioLayerLookup = self::MPEGaudioLayerArray(); + $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray(); + $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray(); + $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray(); + $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray(); + $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray(); + } + + if ($this->fseek($offset) != 0) { + $this->error('decodeMPEGaudioHeader() failed to seek to next offset at '.$offset); + return false; + } + //$headerstring = $this->fread(1441); // worst-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame + $headerstring = $this->fread(226); // LAME header at offset 36 + 190 bytes of Xing/LAME data + + // MP3 audio frame structure: + // $aa $aa $aa $aa [$bb $bb] $cc... + // where $aa..$aa is the four-byte mpeg-audio header (below) + // $bb $bb is the optional 2-byte CRC + // and $cc... is the audio data + + $head4 = substr($headerstring, 0, 4); + $head4_key = getid3_lib::PrintHexBytes($head4, true, false, false); + static $MPEGaudioHeaderDecodeCache = array(); + if (isset($MPEGaudioHeaderDecodeCache[$head4_key])) { + $MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4_key]; + } else { + $MPEGheaderRawArray = self::MPEGaudioHeaderDecode($head4); + $MPEGaudioHeaderDecodeCache[$head4_key] = $MPEGheaderRawArray; + } + + static $MPEGaudioHeaderValidCache = array(); + if (!isset($MPEGaudioHeaderValidCache[$head4_key])) { // Not in cache + //$MPEGaudioHeaderValidCache[$head4_key] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, true); // allow badly-formatted freeformat (from LAME 3.90 - 3.93.1) + $MPEGaudioHeaderValidCache[$head4_key] = self::MPEGaudioHeaderValid($MPEGheaderRawArray, false, false); + } + + // shortcut + if (!isset($info['mpeg']['audio'])) { + $info['mpeg']['audio'] = array(); + } + $thisfile_mpeg_audio = &$info['mpeg']['audio']; + + + if ($MPEGaudioHeaderValidCache[$head4_key]) { + $thisfile_mpeg_audio['raw'] = $MPEGheaderRawArray; + } else { + $this->error('Invalid MPEG audio header ('.getid3_lib::PrintHexBytes($head4).') at offset '.$offset); + return false; + } + + if (!$FastMPEGheaderScan) { + $thisfile_mpeg_audio['version'] = $MPEGaudioVersionLookup[$thisfile_mpeg_audio['raw']['version']]; + $thisfile_mpeg_audio['layer'] = $MPEGaudioLayerLookup[$thisfile_mpeg_audio['raw']['layer']]; + + $thisfile_mpeg_audio['channelmode'] = $MPEGaudioChannelModeLookup[$thisfile_mpeg_audio['raw']['channelmode']]; + $thisfile_mpeg_audio['channels'] = (($thisfile_mpeg_audio['channelmode'] == 'mono') ? 1 : 2); + $thisfile_mpeg_audio['sample_rate'] = $MPEGaudioFrequencyLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['raw']['sample_rate']]; + $thisfile_mpeg_audio['protection'] = !$thisfile_mpeg_audio['raw']['protection']; + $thisfile_mpeg_audio['private'] = (bool) $thisfile_mpeg_audio['raw']['private']; + $thisfile_mpeg_audio['modeextension'] = $MPEGaudioModeExtensionLookup[$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['modeextension']]; + $thisfile_mpeg_audio['copyright'] = (bool) $thisfile_mpeg_audio['raw']['copyright']; + $thisfile_mpeg_audio['original'] = (bool) $thisfile_mpeg_audio['raw']['original']; + $thisfile_mpeg_audio['emphasis'] = $MPEGaudioEmphasisLookup[$thisfile_mpeg_audio['raw']['emphasis']]; + + $info['audio']['channels'] = $thisfile_mpeg_audio['channels']; + $info['audio']['sample_rate'] = $thisfile_mpeg_audio['sample_rate']; + + if ($thisfile_mpeg_audio['protection']) { + $thisfile_mpeg_audio['crc'] = getid3_lib::BigEndian2Int(substr($headerstring, 4, 2)); + } + } + + if ($thisfile_mpeg_audio['raw']['bitrate'] == 15) { + // http://www.hydrogenaudio.org/?act=ST&f=16&t=9682&st=0 + $this->warning('Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1'); + $thisfile_mpeg_audio['raw']['bitrate'] = 0; + } + $thisfile_mpeg_audio['padding'] = (bool) $thisfile_mpeg_audio['raw']['padding']; + $thisfile_mpeg_audio['bitrate'] = $MPEGaudioBitrateLookup[$thisfile_mpeg_audio['version']][$thisfile_mpeg_audio['layer']][$thisfile_mpeg_audio['raw']['bitrate']]; + + if (($thisfile_mpeg_audio['bitrate'] == 'free') && ($offset == $info['avdataoffset'])) { + // only skip multiple frame check if free-format bitstream found at beginning of file + // otherwise is quite possibly simply corrupted data + $recursivesearch = false; + } + + // For Layer 2 there are some combinations of bitrate and mode which are not allowed. + if (!$FastMPEGheaderScan && ($thisfile_mpeg_audio['layer'] == '2')) { + + $info['audio']['dataformat'] = 'mp2'; + switch ($thisfile_mpeg_audio['channelmode']) { + + case 'mono': + if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] <= 192000)) { + // these are ok + } else { + $this->error($thisfile_mpeg_audio['bitrate'].'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.'); + return false; + } + break; + + case 'stereo': + case 'joint stereo': + case 'dual channel': + if (($thisfile_mpeg_audio['bitrate'] == 'free') || ($thisfile_mpeg_audio['bitrate'] == 64000) || ($thisfile_mpeg_audio['bitrate'] >= 96000)) { + // these are ok + } else { + $this->error(intval(round($thisfile_mpeg_audio['bitrate'] / 1000)).'kbps not allowed in Layer 2, '.$thisfile_mpeg_audio['channelmode'].'.'); + return false; + } + break; + + } + + } + + + if ($info['audio']['sample_rate'] > 0) { + $thisfile_mpeg_audio['framelength'] = self::MPEGaudioFrameLength($thisfile_mpeg_audio['bitrate'], $thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['layer'], (int) $thisfile_mpeg_audio['padding'], $info['audio']['sample_rate']); + } + + $nextframetestoffset = $offset + 1; + if ($thisfile_mpeg_audio['bitrate'] != 'free') { + + $info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate']; + + if (isset($thisfile_mpeg_audio['framelength'])) { + $nextframetestoffset = $offset + $thisfile_mpeg_audio['framelength']; + } else { + $this->error('Frame at offset('.$offset.') is has an invalid frame length.'); + return false; + } + + } + + $ExpectedNumberOfAudioBytes = 0; + + //////////////////////////////////////////////////////////////////////////////////// + // Variable-bitrate headers + + if (substr($headerstring, 4 + 32, 4) == 'VBRI') { + // Fraunhofer VBR header is hardcoded 'VBRI' at offset 0x24 (36) + // specs taken from http://minnie.tuhs.org/pipermail/mp3encoder/2001-January/001800.html + + $thisfile_mpeg_audio['bitrate_mode'] = 'vbr'; + $thisfile_mpeg_audio['VBR_method'] = 'Fraunhofer'; + $info['audio']['codec'] = 'Fraunhofer'; + + $SideInfoData = substr($headerstring, 4 + 2, 32); + + $FraunhoferVBROffset = 36; + + $thisfile_mpeg_audio['VBR_encoder_version'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 4, 2)); // VbriVersion + $thisfile_mpeg_audio['VBR_encoder_delay'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 6, 2)); // VbriDelay + $thisfile_mpeg_audio['VBR_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 8, 2)); // VbriQuality + $thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 10, 4)); // VbriStreamBytes + $thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 14, 4)); // VbriStreamFrames + $thisfile_mpeg_audio['VBR_seek_offsets'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 18, 2)); // VbriTableSize + $thisfile_mpeg_audio['VBR_seek_scale'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 20, 2)); // VbriTableScale + $thisfile_mpeg_audio['VBR_entry_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 22, 2)); // VbriEntryBytes + $thisfile_mpeg_audio['VBR_entry_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 24, 2)); // VbriEntryFrames + + $ExpectedNumberOfAudioBytes = $thisfile_mpeg_audio['VBR_bytes']; + + $previousbyteoffset = $offset; + for ($i = 0; $i < $thisfile_mpeg_audio['VBR_seek_offsets']; $i++) { + $Fraunhofer_OffsetN = getid3_lib::BigEndian2Int(substr($headerstring, $FraunhoferVBROffset, $thisfile_mpeg_audio['VBR_entry_bytes'])); + $FraunhoferVBROffset += $thisfile_mpeg_audio['VBR_entry_bytes']; + $thisfile_mpeg_audio['VBR_offsets_relative'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio['VBR_seek_scale']); + $thisfile_mpeg_audio['VBR_offsets_absolute'][$i] = ($Fraunhofer_OffsetN * $thisfile_mpeg_audio['VBR_seek_scale']) + $previousbyteoffset; + $previousbyteoffset += $Fraunhofer_OffsetN; + } + + + } else { + + // Xing VBR header is hardcoded 'Xing' at a offset 0x0D (13), 0x15 (21) or 0x24 (36) + // depending on MPEG layer and number of channels + + $VBRidOffset = self::XingVBRidOffset($thisfile_mpeg_audio['version'], $thisfile_mpeg_audio['channelmode']); + $SideInfoData = substr($headerstring, 4 + 2, $VBRidOffset - 4); + + if ((substr($headerstring, $VBRidOffset, strlen('Xing')) == 'Xing') || (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Info')) { + // 'Xing' is traditional Xing VBR frame + // 'Info' is LAME-encoded CBR (This was done to avoid CBR files to be recognized as traditional Xing VBR files by some decoders.) + // 'Info' *can* legally be used to specify a VBR file as well, however. + + // http://www.multiweb.cz/twoinches/MP3inside.htm + //00..03 = "Xing" or "Info" + //04..07 = Flags: + // 0x01 Frames Flag set if value for number of frames in file is stored + // 0x02 Bytes Flag set if value for filesize in bytes is stored + // 0x04 TOC Flag set if values for TOC are stored + // 0x08 VBR Scale Flag set if values for VBR scale is stored + //08..11 Frames: Number of frames in file (including the first Xing/Info one) + //12..15 Bytes: File length in Bytes + //16..115 TOC (Table of Contents): + // Contains of 100 indexes (one Byte length) for easier lookup in file. Approximately solves problem with moving inside file. + // Each Byte has a value according this formula: + // (TOC[i] / 256) * fileLenInBytes + // So if song lasts eg. 240 sec. and you want to jump to 60. sec. (and file is 5 000 000 Bytes length) you can use: + // TOC[(60/240)*100] = TOC[25] + // and corresponding Byte in file is then approximately at: + // (TOC[25]/256) * 5000000 + //116..119 VBR Scale + + + // should be safe to leave this at 'vbr' and let it be overriden to 'cbr' if a CBR preset/mode is used by LAME +// if (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Xing') { + $thisfile_mpeg_audio['bitrate_mode'] = 'vbr'; + $thisfile_mpeg_audio['VBR_method'] = 'Xing'; +// } else { +// $ScanAsCBR = true; +// $thisfile_mpeg_audio['bitrate_mode'] = 'cbr'; +// } + + $thisfile_mpeg_audio['xing_flags_raw'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 4, 4)); + + $thisfile_mpeg_audio['xing_flags']['frames'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000001); + $thisfile_mpeg_audio['xing_flags']['bytes'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000002); + $thisfile_mpeg_audio['xing_flags']['toc'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000004); + $thisfile_mpeg_audio['xing_flags']['vbr_scale'] = (bool) ($thisfile_mpeg_audio['xing_flags_raw'] & 0x00000008); + + if ($thisfile_mpeg_audio['xing_flags']['frames']) { + $thisfile_mpeg_audio['VBR_frames'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 8, 4)); + //$thisfile_mpeg_audio['VBR_frames']--; // don't count header Xing/Info frame + } + if ($thisfile_mpeg_audio['xing_flags']['bytes']) { + $thisfile_mpeg_audio['VBR_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 12, 4)); + } + + //if (($thisfile_mpeg_audio['bitrate'] == 'free') && !empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) { + //if (!empty($thisfile_mpeg_audio['VBR_frames']) && !empty($thisfile_mpeg_audio['VBR_bytes'])) { + if (!empty($thisfile_mpeg_audio['VBR_frames'])) { + $used_filesize = 0; + if (!empty($thisfile_mpeg_audio['VBR_bytes'])) { + $used_filesize = $thisfile_mpeg_audio['VBR_bytes']; + } elseif (!empty($info['filesize'])) { + $used_filesize = $info['filesize']; + $used_filesize -= intval(@$info['id3v2']['headerlength']); + $used_filesize -= (isset($info['id3v1']) ? 128 : 0); + $used_filesize -= (isset($info['tag_offset_end']) ? $info['tag_offset_end'] - $info['tag_offset_start'] : 0); + $this->warning('MP3.Xing header missing VBR_bytes, assuming MPEG audio portion of file is '.number_format($used_filesize).' bytes'); + } + + $framelengthfloat = $used_filesize / $thisfile_mpeg_audio['VBR_frames']; + + if ($thisfile_mpeg_audio['layer'] == '1') { + // BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12 + //$info['audio']['bitrate'] = ((($framelengthfloat / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12; + $info['audio']['bitrate'] = ($framelengthfloat / 4) * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 12; + } else { + // Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144 + //$info['audio']['bitrate'] = (($framelengthfloat - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144; + $info['audio']['bitrate'] = $framelengthfloat * $thisfile_mpeg_audio['sample_rate'] * (2 / $info['audio']['channels']) / 144; + } + $thisfile_mpeg_audio['framelength'] = floor($framelengthfloat); + } + + if ($thisfile_mpeg_audio['xing_flags']['toc']) { + $LAMEtocData = substr($headerstring, $VBRidOffset + 16, 100); + for ($i = 0; $i < 100; $i++) { + $thisfile_mpeg_audio['toc'][$i] = ord($LAMEtocData{$i}); + } + } + if ($thisfile_mpeg_audio['xing_flags']['vbr_scale']) { + $thisfile_mpeg_audio['VBR_scale'] = getid3_lib::BigEndian2Int(substr($headerstring, $VBRidOffset + 116, 4)); + } + + + // http://gabriel.mp3-tech.org/mp3infotag.html + if (substr($headerstring, $VBRidOffset + 120, 4) == 'LAME') { + + // shortcut + $thisfile_mpeg_audio['LAME'] = array(); + $thisfile_mpeg_audio_lame = &$thisfile_mpeg_audio['LAME']; + + + $thisfile_mpeg_audio_lame['long_version'] = substr($headerstring, $VBRidOffset + 120, 20); + $thisfile_mpeg_audio_lame['short_version'] = substr($thisfile_mpeg_audio_lame['long_version'], 0, 9); + + if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.90') { + + // extra 11 chars are not part of version string when LAMEtag present + unset($thisfile_mpeg_audio_lame['long_version']); + + // It the LAME tag was only introduced in LAME v3.90 + // http://www.hydrogenaudio.org/?act=ST&f=15&t=9933 + + // Offsets of various bytes in http://gabriel.mp3-tech.org/mp3infotag.html + // are assuming a 'Xing' identifier offset of 0x24, which is the case for + // MPEG-1 non-mono, but not for other combinations + $LAMEtagOffsetContant = $VBRidOffset - 0x24; + + // shortcuts + $thisfile_mpeg_audio_lame['RGAD'] = array('track'=>array(), 'album'=>array()); + $thisfile_mpeg_audio_lame_RGAD = &$thisfile_mpeg_audio_lame['RGAD']; + $thisfile_mpeg_audio_lame_RGAD_track = &$thisfile_mpeg_audio_lame_RGAD['track']; + $thisfile_mpeg_audio_lame_RGAD_album = &$thisfile_mpeg_audio_lame_RGAD['album']; + $thisfile_mpeg_audio_lame['raw'] = array(); + $thisfile_mpeg_audio_lame_raw = &$thisfile_mpeg_audio_lame['raw']; + + // byte $9B VBR Quality + // This field is there to indicate a quality level, although the scale was not precised in the original Xing specifications. + // Actually overwrites original Xing bytes + unset($thisfile_mpeg_audio['VBR_scale']); + $thisfile_mpeg_audio_lame['vbr_quality'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0x9B, 1)); + + // bytes $9C-$A4 Encoder short VersionString + $thisfile_mpeg_audio_lame['short_version'] = substr($headerstring, $LAMEtagOffsetContant + 0x9C, 9); + + // byte $A5 Info Tag revision + VBR method + $LAMEtagRevisionVBRmethod = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA5, 1)); + + $thisfile_mpeg_audio_lame['tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4; + $thisfile_mpeg_audio_lame_raw['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F; + $thisfile_mpeg_audio_lame['vbr_method'] = self::LAMEvbrMethodLookup($thisfile_mpeg_audio_lame_raw['vbr_method']); + $thisfile_mpeg_audio['bitrate_mode'] = substr($thisfile_mpeg_audio_lame['vbr_method'], 0, 3); // usually either 'cbr' or 'vbr', but truncates 'vbr-old / vbr-rh' to 'vbr' + + // byte $A6 Lowpass filter value + $thisfile_mpeg_audio_lame['lowpass_frequency'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA6, 1)) * 100; + + // bytes $A7-$AE Replay Gain + // http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html + // bytes $A7-$AA : 32 bit floating point "Peak signal amplitude" + if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.94b') { + // LAME 3.94a16 and later - 9.23 fixed point + // ie 0x0059E2EE / (2^23) = 5890798 / 8388608 = 0.7022378444671630859375 + $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = (float) ((getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4))) / 8388608); + } else { + // LAME 3.94a15 and earlier - 32-bit floating point + // Actually 3.94a16 will fall in here too and be WRONG, but is hard to detect 3.94a16 vs 3.94a15 + $thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] = getid3_lib::LittleEndian2Float(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4)); + } + if ($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'] == 0) { + unset($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']); + } else { + $thisfile_mpeg_audio_lame_RGAD['peak_db'] = getid3_lib::RGADamplitude2dB($thisfile_mpeg_audio_lame_RGAD['peak_amplitude']); + } + + $thisfile_mpeg_audio_lame_raw['RGAD_track'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2)); + $thisfile_mpeg_audio_lame_raw['RGAD_album'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2)); + + + if ($thisfile_mpeg_audio_lame_raw['RGAD_track'] != 0) { + + $thisfile_mpeg_audio_lame_RGAD_track['raw']['name'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0xE000) >> 13; + $thisfile_mpeg_audio_lame_RGAD_track['raw']['originator'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x1C00) >> 10; + $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit'] = ($thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x0200) >> 9; + $thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_track'] & 0x01FF; + $thisfile_mpeg_audio_lame_RGAD_track['name'] = getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['name']); + $thisfile_mpeg_audio_lame_RGAD_track['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['originator']); + $thisfile_mpeg_audio_lame_RGAD_track['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_track['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_track['raw']['sign_bit']); + + if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { + $info['replay_gain']['track']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; + } + $info['replay_gain']['track']['originator'] = $thisfile_mpeg_audio_lame_RGAD_track['originator']; + $info['replay_gain']['track']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_track['gain_db']; + } else { + unset($thisfile_mpeg_audio_lame_RGAD['track']); + } + if ($thisfile_mpeg_audio_lame_raw['RGAD_album'] != 0) { + + $thisfile_mpeg_audio_lame_RGAD_album['raw']['name'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0xE000) >> 13; + $thisfile_mpeg_audio_lame_RGAD_album['raw']['originator'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x1C00) >> 10; + $thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit'] = ($thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x0200) >> 9; + $thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'] = $thisfile_mpeg_audio_lame_raw['RGAD_album'] & 0x01FF; + $thisfile_mpeg_audio_lame_RGAD_album['name'] = getid3_lib::RGADnameLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['name']); + $thisfile_mpeg_audio_lame_RGAD_album['originator'] = getid3_lib::RGADoriginatorLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['originator']); + $thisfile_mpeg_audio_lame_RGAD_album['gain_db'] = getid3_lib::RGADadjustmentLookup($thisfile_mpeg_audio_lame_RGAD_album['raw']['gain_adjust'], $thisfile_mpeg_audio_lame_RGAD_album['raw']['sign_bit']); + + if (!empty($thisfile_mpeg_audio_lame_RGAD['peak_amplitude'])) { + $info['replay_gain']['album']['peak'] = $thisfile_mpeg_audio_lame_RGAD['peak_amplitude']; + } + $info['replay_gain']['album']['originator'] = $thisfile_mpeg_audio_lame_RGAD_album['originator']; + $info['replay_gain']['album']['adjustment'] = $thisfile_mpeg_audio_lame_RGAD_album['gain_db']; + } else { + unset($thisfile_mpeg_audio_lame_RGAD['album']); + } + if (empty($thisfile_mpeg_audio_lame_RGAD)) { + unset($thisfile_mpeg_audio_lame['RGAD']); + } + + + // byte $AF Encoding flags + ATH Type + $EncodingFlagsATHtype = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAF, 1)); + $thisfile_mpeg_audio_lame['encoding_flags']['nspsytune'] = (bool) ($EncodingFlagsATHtype & 0x10); + $thisfile_mpeg_audio_lame['encoding_flags']['nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20); + $thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'] = (bool) ($EncodingFlagsATHtype & 0x40); + $thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev'] = (bool) ($EncodingFlagsATHtype & 0x80); + $thisfile_mpeg_audio_lame['ath_type'] = $EncodingFlagsATHtype & 0x0F; + + // byte $B0 if ABR {specified bitrate} else {minimal bitrate} + $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB0, 1)); + if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 2) { // Average BitRate (ABR) + $thisfile_mpeg_audio_lame['bitrate_abr'] = $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']; + } elseif ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) { // Constant BitRate (CBR) + // ignore + } elseif ($thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate'] > 0) { // Variable BitRate (VBR) - minimum bitrate + $thisfile_mpeg_audio_lame['bitrate_min'] = $thisfile_mpeg_audio_lame['raw']['abrbitrate_minbitrate']; + } + + // bytes $B1-$B3 Encoder delays + $EncoderDelays = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB1, 3)); + $thisfile_mpeg_audio_lame['encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12; + $thisfile_mpeg_audio_lame['end_padding'] = $EncoderDelays & 0x000FFF; + + // byte $B4 Misc + $MiscByte = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB4, 1)); + $thisfile_mpeg_audio_lame_raw['noise_shaping'] = ($MiscByte & 0x03); + $thisfile_mpeg_audio_lame_raw['stereo_mode'] = ($MiscByte & 0x1C) >> 2; + $thisfile_mpeg_audio_lame_raw['not_optimal_quality'] = ($MiscByte & 0x20) >> 5; + $thisfile_mpeg_audio_lame_raw['source_sample_freq'] = ($MiscByte & 0xC0) >> 6; + $thisfile_mpeg_audio_lame['noise_shaping'] = $thisfile_mpeg_audio_lame_raw['noise_shaping']; + $thisfile_mpeg_audio_lame['stereo_mode'] = self::LAMEmiscStereoModeLookup($thisfile_mpeg_audio_lame_raw['stereo_mode']); + $thisfile_mpeg_audio_lame['not_optimal_quality'] = (bool) $thisfile_mpeg_audio_lame_raw['not_optimal_quality']; + $thisfile_mpeg_audio_lame['source_sample_freq'] = self::LAMEmiscSourceSampleFrequencyLookup($thisfile_mpeg_audio_lame_raw['source_sample_freq']); + + // byte $B5 MP3 Gain + $thisfile_mpeg_audio_lame_raw['mp3_gain'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB5, 1), false, true); + $thisfile_mpeg_audio_lame['mp3_gain_db'] = (getid3_lib::RGADamplitude2dB(2) / 4) * $thisfile_mpeg_audio_lame_raw['mp3_gain']; + $thisfile_mpeg_audio_lame['mp3_gain_factor'] = pow(2, ($thisfile_mpeg_audio_lame['mp3_gain_db'] / 6)); + + // bytes $B6-$B7 Preset and surround info + $PresetSurroundBytes = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB6, 2)); + // Reserved = ($PresetSurroundBytes & 0xC000); + $thisfile_mpeg_audio_lame_raw['surround_info'] = ($PresetSurroundBytes & 0x3800); + $thisfile_mpeg_audio_lame['surround_info'] = self::LAMEsurroundInfoLookup($thisfile_mpeg_audio_lame_raw['surround_info']); + $thisfile_mpeg_audio_lame['preset_used_id'] = ($PresetSurroundBytes & 0x07FF); + $thisfile_mpeg_audio_lame['preset_used'] = self::LAMEpresetUsedLookup($thisfile_mpeg_audio_lame); + if (!empty($thisfile_mpeg_audio_lame['preset_used_id']) && empty($thisfile_mpeg_audio_lame['preset_used'])) { + $this->warning('Unknown LAME preset used ('.$thisfile_mpeg_audio_lame['preset_used_id'].') - please report to info@getid3.org'); + } + if (($thisfile_mpeg_audio_lame['short_version'] == 'LAME3.90.') && !empty($thisfile_mpeg_audio_lame['preset_used_id'])) { + // this may change if 3.90.4 ever comes out + $thisfile_mpeg_audio_lame['short_version'] = 'LAME3.90.3'; + } + + // bytes $B8-$BB MusicLength + $thisfile_mpeg_audio_lame['audio_bytes'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB8, 4)); + $ExpectedNumberOfAudioBytes = (($thisfile_mpeg_audio_lame['audio_bytes'] > 0) ? $thisfile_mpeg_audio_lame['audio_bytes'] : $thisfile_mpeg_audio['VBR_bytes']); + + // bytes $BC-$BD MusicCRC + $thisfile_mpeg_audio_lame['music_crc'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBC, 2)); + + // bytes $BE-$BF CRC-16 of Info Tag + $thisfile_mpeg_audio_lame['lame_tag_crc'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBE, 2)); + + + // LAME CBR + if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) { + + $thisfile_mpeg_audio['bitrate_mode'] = 'cbr'; + $thisfile_mpeg_audio['bitrate'] = self::ClosestStandardMP3Bitrate($thisfile_mpeg_audio['bitrate']); + $info['audio']['bitrate'] = $thisfile_mpeg_audio['bitrate']; + //if (empty($thisfile_mpeg_audio['bitrate']) || (!empty($thisfile_mpeg_audio_lame['bitrate_min']) && ($thisfile_mpeg_audio_lame['bitrate_min'] != 255))) { + // $thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio_lame['bitrate_min']; + //} + + } + + } + } + + } else { + + // not Fraunhofer or Xing VBR methods, most likely CBR (but could be VBR with no header) + $thisfile_mpeg_audio['bitrate_mode'] = 'cbr'; + if ($recursivesearch) { + $thisfile_mpeg_audio['bitrate_mode'] = 'vbr'; + if ($this->RecursiveFrameScanning($offset, $nextframetestoffset, true)) { + $recursivesearch = false; + $thisfile_mpeg_audio['bitrate_mode'] = 'cbr'; + } + if ($thisfile_mpeg_audio['bitrate_mode'] == 'vbr') { + $this->warning('VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.'); + } + } + + } + + } + + if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($info['avdataend'] - $info['avdataoffset']))) { + if ($ExpectedNumberOfAudioBytes > ($info['avdataend'] - $info['avdataoffset'])) { + if ($this->isDependencyFor('matroska') || $this->isDependencyFor('riff')) { + // ignore, audio data is broken into chunks so will always be data "missing" + } + elseif (($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])) == 1) { + $this->warning('Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)'); + } + else { + $this->warning('Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($info['avdataend'] - $info['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($info['avdataend'] - $info['avdataoffset'])).' bytes)'); + } + } else { + if ((($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes) == 1) { + // $prenullbytefileoffset = $this->ftell(); + // $this->fseek($info['avdataend']); + // $PossibleNullByte = $this->fread(1); + // $this->fseek($prenullbytefileoffset); + // if ($PossibleNullByte === "\x00") { + $info['avdataend']--; + // $this->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored'); + // } else { + // $this->warning('Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)'); + // } + } else { + $this->warning('Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($info['avdataend'] - $info['avdataoffset']).' ('.(($info['avdataend'] - $info['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)'); + } + } + } + + if (($thisfile_mpeg_audio['bitrate'] == 'free') && empty($info['audio']['bitrate'])) { + if (($offset == $info['avdataoffset']) && empty($thisfile_mpeg_audio['VBR_frames'])) { + $framebytelength = $this->FreeFormatFrameLength($offset, true); + if ($framebytelength > 0) { + $thisfile_mpeg_audio['framelength'] = $framebytelength; + if ($thisfile_mpeg_audio['layer'] == '1') { + // BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12 + $info['audio']['bitrate'] = ((($framebytelength / 4) - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 12; + } else { + // Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144 + $info['audio']['bitrate'] = (($framebytelength - intval($thisfile_mpeg_audio['padding'])) * $thisfile_mpeg_audio['sample_rate']) / 144; + } + } else { + $this->error('Error calculating frame length of free-format MP3 without Xing/LAME header'); + } + } + } + + if (isset($thisfile_mpeg_audio['VBR_frames']) ? $thisfile_mpeg_audio['VBR_frames'] : '') { + switch ($thisfile_mpeg_audio['bitrate_mode']) { + case 'vbr': + case 'abr': + $bytes_per_frame = 1152; + if (($thisfile_mpeg_audio['version'] == '1') && ($thisfile_mpeg_audio['layer'] == 1)) { + $bytes_per_frame = 384; + } elseif ((($thisfile_mpeg_audio['version'] == '2') || ($thisfile_mpeg_audio['version'] == '2.5')) && ($thisfile_mpeg_audio['layer'] == 3)) { + $bytes_per_frame = 576; + } + $thisfile_mpeg_audio['VBR_bitrate'] = (isset($thisfile_mpeg_audio['VBR_bytes']) ? (($thisfile_mpeg_audio['VBR_bytes'] / $thisfile_mpeg_audio['VBR_frames']) * 8) * ($info['audio']['sample_rate'] / $bytes_per_frame) : 0); + if ($thisfile_mpeg_audio['VBR_bitrate'] > 0) { + $info['audio']['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; + $thisfile_mpeg_audio['bitrate'] = $thisfile_mpeg_audio['VBR_bitrate']; // to avoid confusion + } + break; + } + } + + // End variable-bitrate headers + //////////////////////////////////////////////////////////////////////////////////// + + if ($recursivesearch) { + + if (!$this->RecursiveFrameScanning($offset, $nextframetestoffset, $ScanAsCBR)) { + return false; + } + + } + + + //if (false) { + // // experimental side info parsing section - not returning anything useful yet + // + // $SideInfoBitstream = getid3_lib::BigEndian2Bin($SideInfoData); + // $SideInfoOffset = 0; + // + // if ($thisfile_mpeg_audio['version'] == '1') { + // if ($thisfile_mpeg_audio['channelmode'] == 'mono') { + // // MPEG-1 (mono) + // $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9); + // $SideInfoOffset += 9; + // $SideInfoOffset += 5; + // } else { + // // MPEG-1 (stereo, joint-stereo, dual-channel) + // $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9); + // $SideInfoOffset += 9; + // $SideInfoOffset += 3; + // } + // } else { // 2 or 2.5 + // if ($thisfile_mpeg_audio['channelmode'] == 'mono') { + // // MPEG-2, MPEG-2.5 (mono) + // $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8); + // $SideInfoOffset += 8; + // $SideInfoOffset += 1; + // } else { + // // MPEG-2, MPEG-2.5 (stereo, joint-stereo, dual-channel) + // $thisfile_mpeg_audio['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8); + // $SideInfoOffset += 8; + // $SideInfoOffset += 2; + // } + // } + // + // if ($thisfile_mpeg_audio['version'] == '1') { + // for ($channel = 0; $channel < $info['audio']['channels']; $channel++) { + // for ($scfsi_band = 0; $scfsi_band < 4; $scfsi_band++) { + // $thisfile_mpeg_audio['scfsi'][$channel][$scfsi_band] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 2; + // } + // } + // } + // for ($granule = 0; $granule < (($thisfile_mpeg_audio['version'] == '1') ? 2 : 1); $granule++) { + // for ($channel = 0; $channel < $info['audio']['channels']; $channel++) { + // $thisfile_mpeg_audio['part2_3_length'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 12); + // $SideInfoOffset += 12; + // $thisfile_mpeg_audio['big_values'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9); + // $SideInfoOffset += 9; + // $thisfile_mpeg_audio['global_gain'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 8); + // $SideInfoOffset += 8; + // if ($thisfile_mpeg_audio['version'] == '1') { + // $thisfile_mpeg_audio['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4); + // $SideInfoOffset += 4; + // } else { + // $thisfile_mpeg_audio['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9); + // $SideInfoOffset += 9; + // } + // $thisfile_mpeg_audio['window_switching_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 1; + // + // if ($thisfile_mpeg_audio['window_switching_flag'][$granule][$channel] == '1') { + // + // $thisfile_mpeg_audio['block_type'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 2); + // $SideInfoOffset += 2; + // $thisfile_mpeg_audio['mixed_block_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 1; + // + // for ($region = 0; $region < 2; $region++) { + // $thisfile_mpeg_audio['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5); + // $SideInfoOffset += 5; + // } + // $thisfile_mpeg_audio['table_select'][$granule][$channel][2] = 0; + // + // for ($window = 0; $window < 3; $window++) { + // $thisfile_mpeg_audio['subblock_gain'][$granule][$channel][$window] = substr($SideInfoBitstream, $SideInfoOffset, 3); + // $SideInfoOffset += 3; + // } + // + // } else { + // + // for ($region = 0; $region < 3; $region++) { + // $thisfile_mpeg_audio['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5); + // $SideInfoOffset += 5; + // } + // + // $thisfile_mpeg_audio['region0_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4); + // $SideInfoOffset += 4; + // $thisfile_mpeg_audio['region1_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 3); + // $SideInfoOffset += 3; + // $thisfile_mpeg_audio['block_type'][$granule][$channel] = 0; + // } + // + // if ($thisfile_mpeg_audio['version'] == '1') { + // $thisfile_mpeg_audio['preflag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 1; + // } + // $thisfile_mpeg_audio['scalefac_scale'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 1; + // $thisfile_mpeg_audio['count1table_select'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1); + // $SideInfoOffset += 1; + // } + // } + //} + + return true; + } + + public function RecursiveFrameScanning(&$offset, &$nextframetestoffset, $ScanAsCBR) { + $info = &$this->getid3->info; + $firstframetestarray = array('error' => array(), 'warning'=> array(), 'avdataend' => $info['avdataend'], 'avdataoffset' => $info['avdataoffset']); + $this->decodeMPEGaudioHeader($offset, $firstframetestarray, false); + + for ($i = 0; $i < GETID3_MP3_VALID_CHECK_FRAMES; $i++) { + // check next GETID3_MP3_VALID_CHECK_FRAMES frames for validity, to make sure we haven't run across a false synch + if (($nextframetestoffset + 4) >= $info['avdataend']) { + // end of file + return true; + } + + $nextframetestarray = array('error' => array(), 'warning' => array(), 'avdataend' => $info['avdataend'], 'avdataoffset'=>$info['avdataoffset']); + if ($this->decodeMPEGaudioHeader($nextframetestoffset, $nextframetestarray, false)) { + if ($ScanAsCBR) { + // force CBR mode, used for trying to pick out invalid audio streams with valid(?) VBR headers, or VBR streams with no VBR header + if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($firstframetestarray['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $firstframetestarray['mpeg']['audio']['bitrate'])) { + return false; + } + } + + + // next frame is OK, get ready to check the one after that + if (isset($nextframetestarray['mpeg']['audio']['framelength']) && ($nextframetestarray['mpeg']['audio']['framelength'] > 0)) { + $nextframetestoffset += $nextframetestarray['mpeg']['audio']['framelength']; + } else { + $this->error('Frame at offset ('.$offset.') is has an invalid frame length.'); + return false; + } + + } elseif (!empty($firstframetestarray['mpeg']['audio']['framelength']) && (($nextframetestoffset + $firstframetestarray['mpeg']['audio']['framelength']) > $info['avdataend'])) { + + // it's not the end of the file, but there's not enough data left for another frame, so assume it's garbage/padding and return OK + return true; + + } else { + + // next frame is not valid, note the error and fail, so scanning can contiue for a valid frame sequence + $this->warning('Frame at offset ('.$offset.') is valid, but the next one at ('.$nextframetestoffset.') is not.'); + + return false; + } + } + return true; + } + + public function FreeFormatFrameLength($offset, $deepscan=false) { + $info = &$this->getid3->info; + + $this->fseek($offset); + $MPEGaudioData = $this->fread(32768); + + $SyncPattern1 = substr($MPEGaudioData, 0, 4); + // may be different pattern due to padding + $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) | 0x02).$SyncPattern1{3}; + if ($SyncPattern2 === $SyncPattern1) { + $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) & 0xFD).$SyncPattern1{3}; + } + + $framelength = false; + $framelength1 = strpos($MPEGaudioData, $SyncPattern1, 4); + $framelength2 = strpos($MPEGaudioData, $SyncPattern2, 4); + if ($framelength1 > 4) { + $framelength = $framelength1; + } + if (($framelength2 > 4) && ($framelength2 < $framelength1)) { + $framelength = $framelength2; + } + if (!$framelength) { + + // LAME 3.88 has a different value for modeextension on the first frame vs the rest + $framelength1 = strpos($MPEGaudioData, substr($SyncPattern1, 0, 3), 4); + $framelength2 = strpos($MPEGaudioData, substr($SyncPattern2, 0, 3), 4); + + if ($framelength1 > 4) { + $framelength = $framelength1; + } + if (($framelength2 > 4) && ($framelength2 < $framelength1)) { + $framelength = $framelength2; + } + if (!$framelength) { + $this->error('Cannot find next free-format synch pattern ('.getid3_lib::PrintHexBytes($SyncPattern1).' or '.getid3_lib::PrintHexBytes($SyncPattern2).') after offset '.$offset); + return false; + } else { + $this->warning('ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)'); + $info['audio']['codec'] = 'LAME'; + $info['audio']['encoder'] = 'LAME3.88'; + $SyncPattern1 = substr($SyncPattern1, 0, 3); + $SyncPattern2 = substr($SyncPattern2, 0, 3); + } + } + + if ($deepscan) { + + $ActualFrameLengthValues = array(); + $nextoffset = $offset + $framelength; + while ($nextoffset < ($info['avdataend'] - 6)) { + $this->fseek($nextoffset - 1); + $NextSyncPattern = $this->fread(6); + if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) { + // good - found where expected + $ActualFrameLengthValues[] = $framelength; + } elseif ((substr($NextSyncPattern, 0, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 0, strlen($SyncPattern2)) == $SyncPattern2)) { + // ok - found one byte earlier than expected (last frame wasn't padded, first frame was) + $ActualFrameLengthValues[] = ($framelength - 1); + $nextoffset--; + } elseif ((substr($NextSyncPattern, 2, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 2, strlen($SyncPattern2)) == $SyncPattern2)) { + // ok - found one byte later than expected (last frame was padded, first frame wasn't) + $ActualFrameLengthValues[] = ($framelength + 1); + $nextoffset++; + } else { + $this->error('Did not find expected free-format sync pattern at offset '.$nextoffset); + return false; + } + $nextoffset += $framelength; + } + if (count($ActualFrameLengthValues) > 0) { + $framelength = intval(round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues))); + } + } + return $framelength; + } + + public function getOnlyMPEGaudioInfoBruteForce() { + $MPEGaudioHeaderDecodeCache = array(); + $MPEGaudioHeaderValidCache = array(); + $MPEGaudioHeaderLengthCache = array(); + $MPEGaudioVersionLookup = self::MPEGaudioVersionArray(); + $MPEGaudioLayerLookup = self::MPEGaudioLayerArray(); + $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray(); + $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray(); + $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray(); + $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray(); + $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray(); + $LongMPEGversionLookup = array(); + $LongMPEGlayerLookup = array(); + $LongMPEGbitrateLookup = array(); + $LongMPEGpaddingLookup = array(); + $LongMPEGfrequencyLookup = array(); + $Distribution['bitrate'] = array(); + $Distribution['frequency'] = array(); + $Distribution['layer'] = array(); + $Distribution['version'] = array(); + $Distribution['padding'] = array(); + + $info = &$this->getid3->info; + $this->fseek($info['avdataoffset']); + + $max_frames_scan = 5000; + $frames_scanned = 0; + + $previousvalidframe = $info['avdataoffset']; + while ($this->ftell() < $info['avdataend']) { + set_time_limit(30); + $head4 = $this->fread(4); + if (strlen($head4) < 4) { + break; + } + if ($head4{0} != "\xFF") { + for ($i = 1; $i < 4; $i++) { + if ($head4{$i} == "\xFF") { + $this->fseek($i - 4, SEEK_CUR); + continue 2; + } + } + continue; + } + if (!isset($MPEGaudioHeaderDecodeCache[$head4])) { + $MPEGaudioHeaderDecodeCache[$head4] = self::MPEGaudioHeaderDecode($head4); + } + if (!isset($MPEGaudioHeaderValidCache[$head4])) { + $MPEGaudioHeaderValidCache[$head4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4], false, false); + } + if ($MPEGaudioHeaderValidCache[$head4]) { + + if (!isset($MPEGaudioHeaderLengthCache[$head4])) { + $LongMPEGversionLookup[$head4] = $MPEGaudioVersionLookup[$MPEGaudioHeaderDecodeCache[$head4]['version']]; + $LongMPEGlayerLookup[$head4] = $MPEGaudioLayerLookup[$MPEGaudioHeaderDecodeCache[$head4]['layer']]; + $LongMPEGbitrateLookup[$head4] = $MPEGaudioBitrateLookup[$LongMPEGversionLookup[$head4]][$LongMPEGlayerLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['bitrate']]; + $LongMPEGpaddingLookup[$head4] = (bool) $MPEGaudioHeaderDecodeCache[$head4]['padding']; + $LongMPEGfrequencyLookup[$head4] = $MPEGaudioFrequencyLookup[$LongMPEGversionLookup[$head4]][$MPEGaudioHeaderDecodeCache[$head4]['sample_rate']]; + $MPEGaudioHeaderLengthCache[$head4] = self::MPEGaudioFrameLength( + $LongMPEGbitrateLookup[$head4], + $LongMPEGversionLookup[$head4], + $LongMPEGlayerLookup[$head4], + $LongMPEGpaddingLookup[$head4], + $LongMPEGfrequencyLookup[$head4]); + } + if ($MPEGaudioHeaderLengthCache[$head4] > 4) { + $WhereWeWere = $this->ftell(); + $this->fseek($MPEGaudioHeaderLengthCache[$head4] - 4, SEEK_CUR); + $next4 = $this->fread(4); + if ($next4{0} == "\xFF") { + if (!isset($MPEGaudioHeaderDecodeCache[$next4])) { + $MPEGaudioHeaderDecodeCache[$next4] = self::MPEGaudioHeaderDecode($next4); + } + if (!isset($MPEGaudioHeaderValidCache[$next4])) { + $MPEGaudioHeaderValidCache[$next4] = self::MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false); + } + if ($MPEGaudioHeaderValidCache[$next4]) { + $this->fseek(-4, SEEK_CUR); + + getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]); + getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]); + getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]); + getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]); + getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]); + if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) { + $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']); + $this->warning('too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.'); + foreach ($Distribution as $key1 => $value1) { + foreach ($value1 as $key2 => $value2) { + $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned); + } + } + break; + } + continue; + } + } + unset($next4); + $this->fseek($WhereWeWere - 3); + } + + } + } + foreach ($Distribution as $key => $value) { + ksort($Distribution[$key], SORT_NUMERIC); + } + ksort($Distribution['version'], SORT_STRING); + $info['mpeg']['audio']['bitrate_distribution'] = $Distribution['bitrate']; + $info['mpeg']['audio']['frequency_distribution'] = $Distribution['frequency']; + $info['mpeg']['audio']['layer_distribution'] = $Distribution['layer']; + $info['mpeg']['audio']['version_distribution'] = $Distribution['version']; + $info['mpeg']['audio']['padding_distribution'] = $Distribution['padding']; + if (count($Distribution['version']) > 1) { + $this->error('Corrupt file - more than one MPEG version detected'); + } + if (count($Distribution['layer']) > 1) { + $this->error('Corrupt file - more than one MPEG layer detected'); + } + if (count($Distribution['frequency']) > 1) { + $this->error('Corrupt file - more than one MPEG sample rate detected'); + } + + + $bittotal = 0; + foreach ($Distribution['bitrate'] as $bitratevalue => $bitratecount) { + if ($bitratevalue != 'free') { + $bittotal += ($bitratevalue * $bitratecount); + } + } + $info['mpeg']['audio']['frame_count'] = array_sum($Distribution['bitrate']); + if ($info['mpeg']['audio']['frame_count'] == 0) { + $this->error('no MPEG audio frames found'); + return false; + } + $info['mpeg']['audio']['bitrate'] = ($bittotal / $info['mpeg']['audio']['frame_count']); + $info['mpeg']['audio']['bitrate_mode'] = ((count($Distribution['bitrate']) > 0) ? 'vbr' : 'cbr'); + $info['mpeg']['audio']['sample_rate'] = getid3_lib::array_max($Distribution['frequency'], true); + + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; + $info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode']; + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; + $info['audio']['dataformat'] = 'mp'.getid3_lib::array_max($Distribution['layer'], true); + $info['fileformat'] = $info['audio']['dataformat']; + + return true; + } + + + public function getOnlyMPEGaudioInfo($avdataoffset, $BitrateHistogram=false) { + // looks for synch, decodes MPEG audio header + + $info = &$this->getid3->info; + + static $MPEGaudioVersionLookup; + static $MPEGaudioLayerLookup; + static $MPEGaudioBitrateLookup; + if (empty($MPEGaudioVersionLookup)) { + $MPEGaudioVersionLookup = self::MPEGaudioVersionArray(); + $MPEGaudioLayerLookup = self::MPEGaudioLayerArray(); + $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray(); + + } + + $this->fseek($avdataoffset); + $sync_seek_buffer_size = min(128 * 1024, $info['avdataend'] - $avdataoffset); + if ($sync_seek_buffer_size <= 0) { + $this->error('Invalid $sync_seek_buffer_size at offset '.$avdataoffset); + return false; + } + $header = $this->fread($sync_seek_buffer_size); + $sync_seek_buffer_size = strlen($header); + $SynchSeekOffset = 0; + while ($SynchSeekOffset < $sync_seek_buffer_size) { + if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !feof($this->getid3->fp)) { + + if ($SynchSeekOffset > $sync_seek_buffer_size) { + // if a synch's not found within the first 128k bytes, then give up + $this->error('Could not find valid MPEG audio synch within the first '.round($sync_seek_buffer_size / 1024).'kB'); + if (isset($info['audio']['bitrate'])) { + unset($info['audio']['bitrate']); + } + if (isset($info['mpeg']['audio'])) { + unset($info['mpeg']['audio']); + } + if (empty($info['mpeg'])) { + unset($info['mpeg']); + } + return false; + + } elseif (feof($this->getid3->fp)) { + + $this->error('Could not find valid MPEG audio synch before end of file'); + if (isset($info['audio']['bitrate'])) { + unset($info['audio']['bitrate']); + } + if (isset($info['mpeg']['audio'])) { + unset($info['mpeg']['audio']); + } + if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) { + unset($info['mpeg']); + } + return false; + } + } + + if (($SynchSeekOffset + 1) >= strlen($header)) { + $this->error('Could not find valid MPEG synch before end of file'); + return false; + } + + if (($header{$SynchSeekOffset} == "\xFF") && ($header{($SynchSeekOffset + 1)} > "\xE0")) { // synch detected + if (!isset($FirstFrameThisfileInfo) && !isset($info['mpeg']['audio'])) { + $FirstFrameThisfileInfo = $info; + $FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset; + if (!$this->decodeMPEGaudioHeader($FirstFrameAVDataOffset, $FirstFrameThisfileInfo, false)) { + // if this is the first valid MPEG-audio frame, save it in case it's a VBR header frame and there's + // garbage between this frame and a valid sequence of MPEG-audio frames, to be restored below + unset($FirstFrameThisfileInfo); + } + } + + $dummy = $info; // only overwrite real data if valid header found + if ($this->decodeMPEGaudioHeader($avdataoffset + $SynchSeekOffset, $dummy, true)) { + $info = $dummy; + $info['avdataoffset'] = $avdataoffset + $SynchSeekOffset; + switch (isset($info['fileformat']) ? $info['fileformat'] : '') { + case '': + case 'id3': + case 'ape': + case 'mp3': + $info['fileformat'] = 'mp3'; + $info['audio']['dataformat'] = 'mp3'; + break; + } + if (isset($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode']) && ($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr')) { + if (!(abs($info['audio']['bitrate'] - $FirstFrameThisfileInfo['audio']['bitrate']) <= 1)) { + // If there is garbage data between a valid VBR header frame and a sequence + // of valid MPEG-audio frames the VBR data is no longer discarded. + $info = $FirstFrameThisfileInfo; + $info['avdataoffset'] = $FirstFrameAVDataOffset; + $info['fileformat'] = 'mp3'; + $info['audio']['dataformat'] = 'mp3'; + $dummy = $info; + unset($dummy['mpeg']['audio']); + $GarbageOffsetStart = $FirstFrameAVDataOffset + $FirstFrameThisfileInfo['mpeg']['audio']['framelength']; + $GarbageOffsetEnd = $avdataoffset + $SynchSeekOffset; + if ($this->decodeMPEGaudioHeader($GarbageOffsetEnd, $dummy, true, true)) { + $info = $dummy; + $info['avdataoffset'] = $GarbageOffsetEnd; + $this->warning('apparently-valid VBR header not used because could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.'), but did find valid CBR stream starting at '.$GarbageOffsetEnd); + } else { + $this->warning('using data from VBR header even though could not find '.GETID3_MP3_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.')'); + } + } + } + if (isset($info['mpeg']['audio']['bitrate_mode']) && ($info['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($info['mpeg']['audio']['VBR_method'])) { + // VBR file with no VBR header + $BitrateHistogram = true; + } + + if ($BitrateHistogram) { + + $info['mpeg']['audio']['stereo_distribution'] = array('stereo'=>0, 'joint stereo'=>0, 'dual channel'=>0, 'mono'=>0); + $info['mpeg']['audio']['version_distribution'] = array('1'=>0, '2'=>0, '2.5'=>0); + + if ($info['mpeg']['audio']['version'] == '1') { + if ($info['mpeg']['audio']['layer'] == 3) { + $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0); + } elseif ($info['mpeg']['audio']['layer'] == 2) { + $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 320000=>0, 384000=>0); + } elseif ($info['mpeg']['audio']['layer'] == 1) { + $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 64000=>0, 96000=>0, 128000=>0, 160000=>0, 192000=>0, 224000=>0, 256000=>0, 288000=>0, 320000=>0, 352000=>0, 384000=>0, 416000=>0, 448000=>0); + } + } elseif ($info['mpeg']['audio']['layer'] == 1) { + $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0, 176000=>0, 192000=>0, 224000=>0, 256000=>0); + } else { + $info['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 8000=>0, 16000=>0, 24000=>0, 32000=>0, 40000=>0, 48000=>0, 56000=>0, 64000=>0, 80000=>0, 96000=>0, 112000=>0, 128000=>0, 144000=>0, 160000=>0); + } + + $dummy = array('error'=>$info['error'], 'warning'=>$info['warning'], 'avdataend'=>$info['avdataend'], 'avdataoffset'=>$info['avdataoffset']); + $synchstartoffset = $info['avdataoffset']; + $this->fseek($info['avdataoffset']); + + // you can play with these numbers: + $max_frames_scan = 50000; + $max_scan_segments = 10; + + // don't play with these numbers: + $FastMode = false; + $SynchErrorsFound = 0; + $frames_scanned = 0; + $this_scan_segment = 0; + $frames_scan_per_segment = ceil($max_frames_scan / $max_scan_segments); + $pct_data_scanned = 0; + for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) { + $frames_scanned_this_segment = 0; + if ($this->ftell() >= $info['avdataend']) { + break; + } + $scan_start_offset[$current_segment] = max($this->ftell(), $info['avdataoffset'] + round($current_segment * (($info['avdataend'] - $info['avdataoffset']) / $max_scan_segments))); + if ($current_segment > 0) { + $this->fseek($scan_start_offset[$current_segment]); + $buffer_4k = $this->fread(4096); + for ($j = 0; $j < (strlen($buffer_4k) - 4); $j++) { + if (($buffer_4k{$j} == "\xFF") && ($buffer_4k{($j + 1)} > "\xE0")) { // synch detected + if ($this->decodeMPEGaudioHeader($scan_start_offset[$current_segment] + $j, $dummy, false, false, $FastMode)) { + $calculated_next_offset = $scan_start_offset[$current_segment] + $j + $dummy['mpeg']['audio']['framelength']; + if ($this->decodeMPEGaudioHeader($calculated_next_offset, $dummy, false, false, $FastMode)) { + $scan_start_offset[$current_segment] += $j; + break; + } + } + } + } + } + $synchstartoffset = $scan_start_offset[$current_segment]; + while ($this->decodeMPEGaudioHeader($synchstartoffset, $dummy, false, false, $FastMode)) { + $FastMode = true; + $thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy['mpeg']['audio']['raw']['version']]][$MPEGaudioLayerLookup[$dummy['mpeg']['audio']['raw']['layer']]][$dummy['mpeg']['audio']['raw']['bitrate']]; + + if (empty($dummy['mpeg']['audio']['framelength'])) { + $SynchErrorsFound++; + $synchstartoffset++; + } else { + getid3_lib::safe_inc($info['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]); + getid3_lib::safe_inc($info['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]); + getid3_lib::safe_inc($info['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]); + $synchstartoffset += $dummy['mpeg']['audio']['framelength']; + } + $frames_scanned++; + if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) { + $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']); + if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) { + // file likely contains < $max_frames_scan, just scan as one segment + $max_scan_segments = 1; + $frames_scan_per_segment = $max_frames_scan; + } else { + $pct_data_scanned += $this_pct_scanned; + break; + } + } + } + } + if ($pct_data_scanned > 0) { + $this->warning('too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.'); + foreach ($info['mpeg']['audio'] as $key1 => $value1) { + if (!preg_match('#_distribution$#i', $key1)) { + continue; + } + foreach ($value1 as $key2 => $value2) { + $info['mpeg']['audio'][$key1][$key2] = round($value2 / $pct_data_scanned); + } + } + } + + if ($SynchErrorsFound > 0) { + $this->warning('Found '.$SynchErrorsFound.' synch errors in histogram analysis'); + //return false; + } + + $bittotal = 0; + $framecounter = 0; + foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) { + $framecounter += $bitratecount; + if ($bitratevalue != 'free') { + $bittotal += ($bitratevalue * $bitratecount); + } + } + if ($framecounter == 0) { + $this->error('Corrupt MP3 file: framecounter == zero'); + return false; + } + $info['mpeg']['audio']['frame_count'] = getid3_lib::CastAsInt($framecounter); + $info['mpeg']['audio']['bitrate'] = ($bittotal / $framecounter); + + $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate']; + + + // Definitively set VBR vs CBR, even if the Xing/LAME/VBRI header says differently + $distinct_bitrates = 0; + foreach ($info['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) { + if ($bitrate_count > 0) { + $distinct_bitrates++; + } + } + if ($distinct_bitrates > 1) { + $info['mpeg']['audio']['bitrate_mode'] = 'vbr'; + } else { + $info['mpeg']['audio']['bitrate_mode'] = 'cbr'; + } + $info['audio']['bitrate_mode'] = $info['mpeg']['audio']['bitrate_mode']; + + } + + break; // exit while() + } + } + + $SynchSeekOffset++; + if (($avdataoffset + $SynchSeekOffset) >= $info['avdataend']) { + // end of file/data + + if (empty($info['mpeg']['audio'])) { + + $this->error('could not find valid MPEG synch before end of file'); + if (isset($info['audio']['bitrate'])) { + unset($info['audio']['bitrate']); + } + if (isset($info['mpeg']['audio'])) { + unset($info['mpeg']['audio']); + } + if (isset($info['mpeg']) && (!is_array($info['mpeg']) || empty($info['mpeg']))) { + unset($info['mpeg']); + } + return false; + + } + break; + } + + } + $info['audio']['channels'] = $info['mpeg']['audio']['channels']; + $info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode']; + $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate']; + return true; + } + + + public static function MPEGaudioVersionArray() { + static $MPEGaudioVersion = array('2.5', false, '2', '1'); + return $MPEGaudioVersion; + } + + public static function MPEGaudioLayerArray() { + static $MPEGaudioLayer = array(false, 3, 2, 1); + return $MPEGaudioLayer; + } + + public static function MPEGaudioBitrateArray() { + static $MPEGaudioBitrate; + if (empty($MPEGaudioBitrate)) { + $MPEGaudioBitrate = array ( + '1' => array (1 => array('free', 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000), + 2 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000), + 3 => array('free', 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000) + ), + + '2' => array (1 => array('free', 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000), + 2 => array('free', 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000), + ) + ); + $MPEGaudioBitrate['2'][3] = $MPEGaudioBitrate['2'][2]; + $MPEGaudioBitrate['2.5'] = $MPEGaudioBitrate['2']; + } + return $MPEGaudioBitrate; + } + + public static function MPEGaudioFrequencyArray() { + static $MPEGaudioFrequency; + if (empty($MPEGaudioFrequency)) { + $MPEGaudioFrequency = array ( + '1' => array(44100, 48000, 32000), + '2' => array(22050, 24000, 16000), + '2.5' => array(11025, 12000, 8000) + ); + } + return $MPEGaudioFrequency; + } + + public static function MPEGaudioChannelModeArray() { + static $MPEGaudioChannelMode = array('stereo', 'joint stereo', 'dual channel', 'mono'); + return $MPEGaudioChannelMode; + } + + public static function MPEGaudioModeExtensionArray() { + static $MPEGaudioModeExtension; + if (empty($MPEGaudioModeExtension)) { + $MPEGaudioModeExtension = array ( + 1 => array('4-31', '8-31', '12-31', '16-31'), + 2 => array('4-31', '8-31', '12-31', '16-31'), + 3 => array('', 'IS', 'MS', 'IS+MS') + ); + } + return $MPEGaudioModeExtension; + } + + public static function MPEGaudioEmphasisArray() { + static $MPEGaudioEmphasis = array('none', '50/15ms', false, 'CCIT J.17'); + return $MPEGaudioEmphasis; + } + + public static function MPEGaudioHeaderBytesValid($head4, $allowBitrate15=false) { + return self::MPEGaudioHeaderValid(self::MPEGaudioHeaderDecode($head4), false, $allowBitrate15); + } + + public static function MPEGaudioHeaderValid($rawarray, $echoerrors=false, $allowBitrate15=false) { + if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) { + return false; + } + + static $MPEGaudioVersionLookup; + static $MPEGaudioLayerLookup; + static $MPEGaudioBitrateLookup; + static $MPEGaudioFrequencyLookup; + static $MPEGaudioChannelModeLookup; + static $MPEGaudioModeExtensionLookup; + static $MPEGaudioEmphasisLookup; + if (empty($MPEGaudioVersionLookup)) { + $MPEGaudioVersionLookup = self::MPEGaudioVersionArray(); + $MPEGaudioLayerLookup = self::MPEGaudioLayerArray(); + $MPEGaudioBitrateLookup = self::MPEGaudioBitrateArray(); + $MPEGaudioFrequencyLookup = self::MPEGaudioFrequencyArray(); + $MPEGaudioChannelModeLookup = self::MPEGaudioChannelModeArray(); + $MPEGaudioModeExtensionLookup = self::MPEGaudioModeExtensionArray(); + $MPEGaudioEmphasisLookup = self::MPEGaudioEmphasisArray(); + } + + if (isset($MPEGaudioVersionLookup[$rawarray['version']])) { + $decodedVersion = $MPEGaudioVersionLookup[$rawarray['version']]; + } else { + echo ($echoerrors ? "\n".'invalid Version ('.$rawarray['version'].')' : ''); + return false; + } + if (isset($MPEGaudioLayerLookup[$rawarray['layer']])) { + $decodedLayer = $MPEGaudioLayerLookup[$rawarray['layer']]; + } else { + echo ($echoerrors ? "\n".'invalid Layer ('.$rawarray['layer'].')' : ''); + return false; + } + if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) { + echo ($echoerrors ? "\n".'invalid Bitrate ('.$rawarray['bitrate'].')' : ''); + if ($rawarray['bitrate'] == 15) { + // known issue in LAME 3.90 - 3.93.1 where free-format has bitrate ID of 15 instead of 0 + // let it go through here otherwise file will not be identified + if (!$allowBitrate15) { + return false; + } + } else { + return false; + } + } + if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) { + echo ($echoerrors ? "\n".'invalid Frequency ('.$rawarray['sample_rate'].')' : ''); + return false; + } + if (!isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) { + echo ($echoerrors ? "\n".'invalid ChannelMode ('.$rawarray['channelmode'].')' : ''); + return false; + } + if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) { + echo ($echoerrors ? "\n".'invalid Mode Extension ('.$rawarray['modeextension'].')' : ''); + return false; + } + if (!isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) { + echo ($echoerrors ? "\n".'invalid Emphasis ('.$rawarray['emphasis'].')' : ''); + return false; + } + // These are just either set or not set, you can't mess that up :) + // $rawarray['protection']; + // $rawarray['padding']; + // $rawarray['private']; + // $rawarray['copyright']; + // $rawarray['original']; + + return true; + } + + public static function MPEGaudioHeaderDecode($Header4Bytes) { + // AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM + // A - Frame sync (all bits set) + // B - MPEG Audio version ID + // C - Layer description + // D - Protection bit + // E - Bitrate index + // F - Sampling rate frequency index + // G - Padding bit + // H - Private bit + // I - Channel Mode + // J - Mode extension (Only if Joint stereo) + // K - Copyright + // L - Original + // M - Emphasis + + if (strlen($Header4Bytes) != 4) { + return false; + } + + $MPEGrawHeader['synch'] = (getid3_lib::BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xFFE0) >> 4; + $MPEGrawHeader['version'] = (ord($Header4Bytes{1}) & 0x18) >> 3; // BB + $MPEGrawHeader['layer'] = (ord($Header4Bytes{1}) & 0x06) >> 1; // CC + $MPEGrawHeader['protection'] = (ord($Header4Bytes{1}) & 0x01); // D + $MPEGrawHeader['bitrate'] = (ord($Header4Bytes{2}) & 0xF0) >> 4; // EEEE + $MPEGrawHeader['sample_rate'] = (ord($Header4Bytes{2}) & 0x0C) >> 2; // FF + $MPEGrawHeader['padding'] = (ord($Header4Bytes{2}) & 0x02) >> 1; // G + $MPEGrawHeader['private'] = (ord($Header4Bytes{2}) & 0x01); // H + $MPEGrawHeader['channelmode'] = (ord($Header4Bytes{3}) & 0xC0) >> 6; // II + $MPEGrawHeader['modeextension'] = (ord($Header4Bytes{3}) & 0x30) >> 4; // JJ + $MPEGrawHeader['copyright'] = (ord($Header4Bytes{3}) & 0x08) >> 3; // K + $MPEGrawHeader['original'] = (ord($Header4Bytes{3}) & 0x04) >> 2; // L + $MPEGrawHeader['emphasis'] = (ord($Header4Bytes{3}) & 0x03); // MM + + return $MPEGrawHeader; + } + + public static function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) { + static $AudioFrameLengthCache = array(); + + if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) { + $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = false; + if ($bitrate != 'free') { + + if ($version == '1') { + + if ($layer == '1') { + + // For Layer I slot is 32 bits long + $FrameLengthCoefficient = 48; + $SlotLength = 4; + + } else { // Layer 2 / 3 + + // for Layer 2 and Layer 3 slot is 8 bits long. + $FrameLengthCoefficient = 144; + $SlotLength = 1; + + } + + } else { // MPEG-2 / MPEG-2.5 + + if ($layer == '1') { + + // For Layer I slot is 32 bits long + $FrameLengthCoefficient = 24; + $SlotLength = 4; + + } elseif ($layer == '2') { + + // for Layer 2 and Layer 3 slot is 8 bits long. + $FrameLengthCoefficient = 144; + $SlotLength = 1; + + } else { // layer 3 + + // for Layer 2 and Layer 3 slot is 8 bits long. + $FrameLengthCoefficient = 72; + $SlotLength = 1; + + } + + } + + // FrameLengthInBytes = ((Coefficient * BitRate) / SampleRate) + Padding + if ($samplerate > 0) { + $NewFramelength = ($FrameLengthCoefficient * $bitrate) / $samplerate; + $NewFramelength = floor($NewFramelength / $SlotLength) * $SlotLength; // round to next-lower multiple of SlotLength (1 byte for Layer 2/3, 4 bytes for Layer I) + if ($padding) { + $NewFramelength += $SlotLength; + } + $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = (int) $NewFramelength; + } + } + } + return $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate]; + } + + public static function ClosestStandardMP3Bitrate($bit_rate) { + static $standard_bit_rates = array (320000, 256000, 224000, 192000, 160000, 128000, 112000, 96000, 80000, 64000, 56000, 48000, 40000, 32000, 24000, 16000, 8000); + static $bit_rate_table = array (0=>'-'); + $round_bit_rate = intval(round($bit_rate, -3)); + if (!isset($bit_rate_table[$round_bit_rate])) { + if ($round_bit_rate > max($standard_bit_rates)) { + $bit_rate_table[$round_bit_rate] = round($bit_rate, 2 - strlen($bit_rate)); + } else { + $bit_rate_table[$round_bit_rate] = max($standard_bit_rates); + foreach ($standard_bit_rates as $standard_bit_rate) { + if ($round_bit_rate >= $standard_bit_rate + (($bit_rate_table[$round_bit_rate] - $standard_bit_rate) / 2)) { + break; + } + $bit_rate_table[$round_bit_rate] = $standard_bit_rate; + } + } + } + return $bit_rate_table[$round_bit_rate]; + } + + public static function XingVBRidOffset($version, $channelmode) { + static $XingVBRidOffsetCache = array(); + if (empty($XingVBRidOffset)) { + $XingVBRidOffset = array ( + '1' => array ('mono' => 0x15, // 4 + 17 = 21 + 'stereo' => 0x24, // 4 + 32 = 36 + 'joint stereo' => 0x24, + 'dual channel' => 0x24 + ), + + '2' => array ('mono' => 0x0D, // 4 + 9 = 13 + 'stereo' => 0x15, // 4 + 17 = 21 + 'joint stereo' => 0x15, + 'dual channel' => 0x15 + ), + + '2.5' => array ('mono' => 0x15, + 'stereo' => 0x15, + 'joint stereo' => 0x15, + 'dual channel' => 0x15 + ) + ); + } + return $XingVBRidOffset[$version][$channelmode]; + } + + public static function LAMEvbrMethodLookup($VBRmethodID) { + static $LAMEvbrMethodLookup = array( + 0x00 => 'unknown', + 0x01 => 'cbr', + 0x02 => 'abr', + 0x03 => 'vbr-old / vbr-rh', + 0x04 => 'vbr-new / vbr-mtrh', + 0x05 => 'vbr-mt', + 0x06 => 'vbr (full vbr method 4)', + 0x08 => 'cbr (constant bitrate 2 pass)', + 0x09 => 'abr (2 pass)', + 0x0F => 'reserved' + ); + return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : ''); + } + + public static function LAMEmiscStereoModeLookup($StereoModeID) { + static $LAMEmiscStereoModeLookup = array( + 0 => 'mono', + 1 => 'stereo', + 2 => 'dual mono', + 3 => 'joint stereo', + 4 => 'forced stereo', + 5 => 'auto', + 6 => 'intensity stereo', + 7 => 'other' + ); + return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : ''); + } + + public static function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) { + static $LAMEmiscSourceSampleFrequencyLookup = array( + 0 => '<= 32 kHz', + 1 => '44.1 kHz', + 2 => '48 kHz', + 3 => '> 48kHz' + ); + return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : ''); + } + + public static function LAMEsurroundInfoLookup($SurroundInfoID) { + static $LAMEsurroundInfoLookup = array( + 0 => 'no surround info', + 1 => 'DPL encoding', + 2 => 'DPL2 encoding', + 3 => 'Ambisonic encoding' + ); + return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved'); + } + + public static function LAMEpresetUsedLookup($LAMEtag) { + + if ($LAMEtag['preset_used_id'] == 0) { + // no preset used (LAME >=3.93) + // no preset recorded (LAME <3.93) + return ''; + } + $LAMEpresetUsedLookup = array(); + + ///// THIS PART CANNOT BE STATIC . + for ($i = 8; $i <= 320; $i++) { + switch ($LAMEtag['vbr_method']) { + case 'cbr': + $LAMEpresetUsedLookup[$i] = '--alt-preset '.$LAMEtag['vbr_method'].' '.$i; + break; + case 'abr': + default: // other VBR modes shouldn't be here(?) + $LAMEpresetUsedLookup[$i] = '--alt-preset '.$i; + break; + } + } + + // named old-style presets (studio, phone, voice, etc) are handled in GuessEncoderOptions() + + // named alt-presets + $LAMEpresetUsedLookup[1000] = '--r3mix'; + $LAMEpresetUsedLookup[1001] = '--alt-preset standard'; + $LAMEpresetUsedLookup[1002] = '--alt-preset extreme'; + $LAMEpresetUsedLookup[1003] = '--alt-preset insane'; + $LAMEpresetUsedLookup[1004] = '--alt-preset fast standard'; + $LAMEpresetUsedLookup[1005] = '--alt-preset fast extreme'; + $LAMEpresetUsedLookup[1006] = '--alt-preset medium'; + $LAMEpresetUsedLookup[1007] = '--alt-preset fast medium'; + + // LAME 3.94 additions/changes + $LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003 + $LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003 + + $LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003 + $LAMEpresetUsedLookup[410] = '-V9'; + $LAMEpresetUsedLookup[420] = '-V8'; + $LAMEpresetUsedLookup[440] = '-V6'; + $LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003 + $LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003 + $LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003 + $LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003 + $LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003 + $LAMEpresetUsedLookup[490] = '-V1'; + $LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003 + + return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info@getid3.org'); + } + +} diff --git a/backend/wp-includes/ID3/module.audio.ogg.php b/backend/wp-includes/ID3/module.audio.ogg.php new file mode 100644 index 0000000..e41c96c --- /dev/null +++ b/backend/wp-includes/ID3/module.audio.ogg.php @@ -0,0 +1,840 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.audio.ogg.php // +// module for analyzing Ogg Vorbis, OggFLAC and Speex files // +// dependencies: module.audio.flac.php // +// /// +///////////////////////////////////////////////////////////////// + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true); + +class getid3_ogg extends getid3_handler +{ + // http://xiph.org/vorbis/doc/Vorbis_I_spec.html + public function Analyze() { + $info = &$this->getid3->info; + + $info['fileformat'] = 'ogg'; + + // Warn about illegal tags - only vorbiscomments are allowed + if (isset($info['id3v2'])) { + $this->warning('Illegal ID3v2 tag present.'); + } + if (isset($info['id3v1'])) { + $this->warning('Illegal ID3v1 tag present.'); + } + if (isset($info['ape'])) { + $this->warning('Illegal APE tag present.'); + } + + + // Page 1 - Stream Header + + $this->fseek($info['avdataoffset']); + + $oggpageinfo = $this->ParseOggPageHeader(); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo; + + if ($this->ftell() >= $this->getid3->fread_buffer_size()) { + $this->error('Could not find start of Ogg page in the first '.$this->getid3->fread_buffer_size().' bytes (this might not be an Ogg-Vorbis file?)'); + unset($info['fileformat']); + unset($info['ogg']); + return false; + } + + $filedata = $this->fread($oggpageinfo['page_length']); + $filedataoffset = 0; + + if (substr($filedata, 0, 4) == 'fLaC') { + + $info['audio']['dataformat'] = 'flac'; + $info['audio']['bitrate_mode'] = 'vbr'; + $info['audio']['lossless'] = true; + + } elseif (substr($filedata, 1, 6) == 'vorbis') { + + $this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo); + + } elseif (substr($filedata, 0, 8) == 'OpusHead') { + + if( $this->ParseOpusPageHeader($filedata, $filedataoffset, $oggpageinfo) == false ) { + return false; + } + + } elseif (substr($filedata, 0, 8) == 'Speex ') { + + // http://www.speex.org/manual/node10.html + + $info['audio']['dataformat'] = 'speex'; + $info['mime_type'] = 'audio/speex'; + $info['audio']['bitrate_mode'] = 'abr'; + $info['audio']['lossless'] = false; + + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_string'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'Speex ' + $filedataoffset += 8; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version'] = substr($filedata, $filedataoffset, 20); + $filedataoffset += 20; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version_id'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['header_size'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode_bitstream_version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['bitrate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['framesize'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['frames_per_packet'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['extra_headers'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved1'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['reserved2'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + + $info['speex']['speex_version'] = trim($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['speex_version']); + $info['speex']['sample_rate'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['rate']; + $info['speex']['channels'] = $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['nb_channels']; + $info['speex']['vbr'] = (bool) $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['vbr']; + $info['speex']['band_type'] = $this->SpeexBandModeLookup($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['mode']); + + $info['audio']['sample_rate'] = $info['speex']['sample_rate']; + $info['audio']['channels'] = $info['speex']['channels']; + if ($info['speex']['vbr']) { + $info['audio']['bitrate_mode'] = 'vbr'; + } + + } elseif (substr($filedata, 0, 7) == "\x80".'theora') { + + // http://www.theora.org/doc/Theora.pdf (section 6.2) + + $info['ogg']['pageheader']['theora']['theora_magic'] = substr($filedata, $filedataoffset, 7); // hard-coded to "\x80.'theora' + $filedataoffset += 7; + $info['ogg']['pageheader']['theora']['version_major'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['version_minor'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['version_revision'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['frame_width_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + $info['ogg']['pageheader']['theora']['frame_height_macroblocks'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + $info['ogg']['pageheader']['theora']['resolution_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); + $filedataoffset += 3; + $info['ogg']['pageheader']['theora']['resolution_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); + $filedataoffset += 3; + $info['ogg']['pageheader']['theora']['picture_offset_x'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['picture_offset_y'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['frame_rate_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader']['theora']['frame_rate_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); + $filedataoffset += 3; + $info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); + $filedataoffset += 3; + $info['ogg']['pageheader']['theora']['color_space_id'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader']['theora']['nominal_bitrate'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 3)); + $filedataoffset += 3; + $info['ogg']['pageheader']['theora']['flags'] = getid3_lib::BigEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + + $info['ogg']['pageheader']['theora']['quality'] = ($info['ogg']['pageheader']['theora']['flags'] & 0xFC00) >> 10; + $info['ogg']['pageheader']['theora']['kfg_shift'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x03E0) >> 5; + $info['ogg']['pageheader']['theora']['pixel_format_id'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0018) >> 3; + $info['ogg']['pageheader']['theora']['reserved'] = ($info['ogg']['pageheader']['theora']['flags'] & 0x0007) >> 0; // should be 0 + $info['ogg']['pageheader']['theora']['color_space'] = self::TheoraColorSpace($info['ogg']['pageheader']['theora']['color_space_id']); + $info['ogg']['pageheader']['theora']['pixel_format'] = self::TheoraPixelFormat($info['ogg']['pageheader']['theora']['pixel_format_id']); + + $info['video']['dataformat'] = 'theora'; + $info['mime_type'] = 'video/ogg'; + //$info['audio']['bitrate_mode'] = 'abr'; + //$info['audio']['lossless'] = false; + $info['video']['resolution_x'] = $info['ogg']['pageheader']['theora']['resolution_x']; + $info['video']['resolution_y'] = $info['ogg']['pageheader']['theora']['resolution_y']; + if ($info['ogg']['pageheader']['theora']['frame_rate_denominator'] > 0) { + $info['video']['frame_rate'] = (float) $info['ogg']['pageheader']['theora']['frame_rate_numerator'] / $info['ogg']['pageheader']['theora']['frame_rate_denominator']; + } + if ($info['ogg']['pageheader']['theora']['pixel_aspect_denominator'] > 0) { + $info['video']['pixel_aspect_ratio'] = (float) $info['ogg']['pageheader']['theora']['pixel_aspect_numerator'] / $info['ogg']['pageheader']['theora']['pixel_aspect_denominator']; + } +$this->warning('Ogg Theora (v3) not fully supported in this version of getID3 ['.$this->getid3->version().'] -- bitrate, playtime and all audio data are currently unavailable'); + + + } elseif (substr($filedata, 0, 8) == "fishead\x00") { + + // Ogg Skeleton version 3.0 Format Specification + // http://xiph.org/ogg/doc/skeleton.html + $filedataoffset += 8; + $info['ogg']['skeleton']['fishead']['raw']['version_major'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + $info['ogg']['skeleton']['fishead']['raw']['version_minor'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fishead']['raw']['utc'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 20)); + $filedataoffset += 20; + + $info['ogg']['skeleton']['fishead']['version'] = $info['ogg']['skeleton']['fishead']['raw']['version_major'].'.'.$info['ogg']['skeleton']['fishead']['raw']['version_minor']; + $info['ogg']['skeleton']['fishead']['presentationtime'] = $info['ogg']['skeleton']['fishead']['raw']['presentationtime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['presentationtime_denominator']; + $info['ogg']['skeleton']['fishead']['basetime'] = $info['ogg']['skeleton']['fishead']['raw']['basetime_numerator'] / $info['ogg']['skeleton']['fishead']['raw']['basetime_denominator']; + $info['ogg']['skeleton']['fishead']['utc'] = $info['ogg']['skeleton']['fishead']['raw']['utc']; + + + $counter = 0; + do { + $oggpageinfo = $this->ParseOggPageHeader(); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno'].'.'.$counter++] = $oggpageinfo; + $filedata = $this->fread($oggpageinfo['page_length']); + $this->fseek($oggpageinfo['page_end_offset']); + + if (substr($filedata, 0, 8) == "fisbone\x00") { + + $filedataoffset = 8; + $info['ogg']['skeleton']['fisbone']['raw']['message_header_offset'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['skeleton']['fisbone']['raw']['serial_number'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['skeleton']['fisbone']['raw']['number_header_packets'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['skeleton']['fisbone']['raw']['granulerate_numerator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fisbone']['raw']['granulerate_denominator'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fisbone']['raw']['basegranule'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $info['ogg']['skeleton']['fisbone']['raw']['preroll'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['skeleton']['fisbone']['raw']['granuleshift'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['skeleton']['fisbone']['raw']['padding'] = substr($filedata, $filedataoffset, 3); + $filedataoffset += 3; + + } elseif (substr($filedata, 1, 6) == 'theora') { + + $info['video']['dataformat'] = 'theora1'; + $this->error('Ogg Theora (v1) not correctly handled in this version of getID3 ['.$this->getid3->version().']'); + //break; + + } elseif (substr($filedata, 1, 6) == 'vorbis') { + + $this->ParseVorbisPageHeader($filedata, $filedataoffset, $oggpageinfo); + + } else { + $this->error('unexpected'); + //break; + } + //} while ($oggpageinfo['page_seqno'] == 0); + } while (($oggpageinfo['page_seqno'] == 0) && (substr($filedata, 0, 8) != "fisbone\x00")); + + $this->fseek($oggpageinfo['page_start_offset']); + + $this->error('Ogg Skeleton not correctly handled in this version of getID3 ['.$this->getid3->version().']'); + //return false; + + } else { + + $this->error('Expecting either "Speex ", "OpusHead" or "vorbis" identifier strings, found "'.substr($filedata, 0, 8).'"'); + unset($info['ogg']); + unset($info['mime_type']); + return false; + + } + + // Page 2 - Comment Header + $oggpageinfo = $this->ParseOggPageHeader(); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo; + + switch ($info['audio']['dataformat']) { + case 'vorbis': + $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, 0, 1)); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 1, 6); // hard-coded to 'vorbis' + + $this->ParseVorbisComments(); + break; + + case 'flac': + $flac = new getid3_flac($this->getid3); + if (!$flac->parseMETAdata()) { + $this->error('Failed to parse FLAC headers'); + return false; + } + unset($flac); + break; + + case 'speex': + $this->fseek($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length'], SEEK_CUR); + $this->ParseVorbisComments(); + break; + + case 'opus': + $filedata = $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, 0, 8); // hard-coded to 'OpusTags' + if(substr($filedata, 0, 8) != 'OpusTags') { + $this->error('Expected "OpusTags" as header but got "'.substr($filedata, 0, 8).'"'); + return false; + } + + $this->ParseVorbisComments(); + break; + + } + + // Last Page - Number of Samples + if (!getid3_lib::intValueSupported($info['avdataend'])) { + + $this->warning('Unable to parse Ogg end chunk file (PHP does not support file operations beyond '.round(PHP_INT_MAX / 1073741824).'GB)'); + + } else { + + $this->fseek(max($info['avdataend'] - $this->getid3->fread_buffer_size(), 0)); + $LastChunkOfOgg = strrev($this->fread($this->getid3->fread_buffer_size())); + if ($LastOggSpostion = strpos($LastChunkOfOgg, 'SggO')) { + $this->fseek($info['avdataend'] - ($LastOggSpostion + strlen('SggO'))); + $info['avdataend'] = $this->ftell(); + $info['ogg']['pageheader']['eos'] = $this->ParseOggPageHeader(); + $info['ogg']['samples'] = $info['ogg']['pageheader']['eos']['pcm_abs_position']; + if ($info['ogg']['samples'] == 0) { + $this->error('Corrupt Ogg file: eos.number of samples == zero'); + return false; + } + if (!empty($info['audio']['sample_rate'])) { + $info['ogg']['bitrate_average'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['ogg']['samples'] / $info['audio']['sample_rate']); + } + } + + } + + if (!empty($info['ogg']['bitrate_average'])) { + $info['audio']['bitrate'] = $info['ogg']['bitrate_average']; + } elseif (!empty($info['ogg']['bitrate_nominal'])) { + $info['audio']['bitrate'] = $info['ogg']['bitrate_nominal']; + } elseif (!empty($info['ogg']['bitrate_min']) && !empty($info['ogg']['bitrate_max'])) { + $info['audio']['bitrate'] = ($info['ogg']['bitrate_min'] + $info['ogg']['bitrate_max']) / 2; + } + if (isset($info['audio']['bitrate']) && !isset($info['playtime_seconds'])) { + if ($info['audio']['bitrate'] == 0) { + $this->error('Corrupt Ogg file: bitrate_audio == zero'); + return false; + } + $info['playtime_seconds'] = (float) ((($info['avdataend'] - $info['avdataoffset']) * 8) / $info['audio']['bitrate']); + } + + if (isset($info['ogg']['vendor'])) { + $info['audio']['encoder'] = preg_replace('/^Encoded with /', '', $info['ogg']['vendor']); + + // Vorbis only + if ($info['audio']['dataformat'] == 'vorbis') { + + // Vorbis 1.0 starts with Xiph.Org + if (preg_match('/^Xiph.Org/', $info['audio']['encoder'])) { + + if ($info['audio']['bitrate_mode'] == 'abr') { + + // Set -b 128 on abr files + $info['audio']['encoder_options'] = '-b '.round($info['ogg']['bitrate_nominal'] / 1000); + + } elseif (($info['audio']['bitrate_mode'] == 'vbr') && ($info['audio']['channels'] == 2) && ($info['audio']['sample_rate'] >= 44100) && ($info['audio']['sample_rate'] <= 48000)) { + // Set -q N on vbr files + $info['audio']['encoder_options'] = '-q '.$this->get_quality_from_nominal_bitrate($info['ogg']['bitrate_nominal']); + + } + } + + if (empty($info['audio']['encoder_options']) && !empty($info['ogg']['bitrate_nominal'])) { + $info['audio']['encoder_options'] = 'Nominal bitrate: '.intval(round($info['ogg']['bitrate_nominal'] / 1000)).'kbps'; + } + } + } + + return true; + } + + public function ParseVorbisPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) { + $info = &$this->getid3->info; + $info['audio']['dataformat'] = 'vorbis'; + $info['audio']['lossless'] = false; + + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['stream_type'] = substr($filedata, $filedataoffset, 6); // hard-coded to 'vorbis' + $filedataoffset += 6; + $info['ogg']['bitstreamversion'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['numberofchannels'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $info['audio']['channels'] = $info['ogg']['numberofchannels']; + $info['ogg']['samplerate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + if ($info['ogg']['samplerate'] == 0) { + $this->error('Corrupt Ogg file: sample rate == zero'); + return false; + } + $info['audio']['sample_rate'] = $info['ogg']['samplerate']; + $info['ogg']['samples'] = 0; // filled in later + $info['ogg']['bitrate_average'] = 0; // filled in later + $info['ogg']['bitrate_max'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['bitrate_nominal'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['bitrate_min'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $info['ogg']['blocksize_small'] = pow(2, getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0x0F); + $info['ogg']['blocksize_large'] = pow(2, (getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)) & 0xF0) >> 4); + $info['ogg']['stop_bit'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); // must be 1, marks end of packet + + $info['audio']['bitrate_mode'] = 'vbr'; // overridden if actually abr + if ($info['ogg']['bitrate_max'] == 0xFFFFFFFF) { + unset($info['ogg']['bitrate_max']); + $info['audio']['bitrate_mode'] = 'abr'; + } + if ($info['ogg']['bitrate_nominal'] == 0xFFFFFFFF) { + unset($info['ogg']['bitrate_nominal']); + } + if ($info['ogg']['bitrate_min'] == 0xFFFFFFFF) { + unset($info['ogg']['bitrate_min']); + $info['audio']['bitrate_mode'] = 'abr'; + } + return true; + } + + // http://tools.ietf.org/html/draft-ietf-codec-oggopus-03 + public function ParseOpusPageHeader(&$filedata, &$filedataoffset, &$oggpageinfo) { + $info = &$this->getid3->info; + $info['audio']['dataformat'] = 'opus'; + $info['mime_type'] = 'audio/ogg; codecs=opus'; + + /** @todo find a usable way to detect abr (vbr that is padded to be abr) */ + $info['audio']['bitrate_mode'] = 'vbr'; + + $info['audio']['lossless'] = false; + + $info['ogg']['pageheader']['opus']['opus_magic'] = substr($filedata, $filedataoffset, 8); // hard-coded to 'OpusHead' + $filedataoffset += 8; + $info['ogg']['pageheader']['opus']['version'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + + if ($info['ogg']['pageheader']['opus']['version'] < 1 || $info['ogg']['pageheader']['opus']['version'] > 15) { + $this->error('Unknown opus version number (only accepting 1-15)'); + return false; + } + + $info['ogg']['pageheader']['opus']['out_channel_count'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + + if ($info['ogg']['pageheader']['opus']['out_channel_count'] == 0) { + $this->error('Invalid channel count in opus header (must not be zero)'); + return false; + } + + $info['ogg']['pageheader']['opus']['pre_skip'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); + $filedataoffset += 2; + + $info['ogg']['pageheader']['opus']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + + //$info['ogg']['pageheader']['opus']['output_gain'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 2)); + //$filedataoffset += 2; + + //$info['ogg']['pageheader']['opus']['channel_mapping_family'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + //$filedataoffset += 1; + + $info['opus']['opus_version'] = $info['ogg']['pageheader']['opus']['version']; + $info['opus']['sample_rate'] = $info['ogg']['pageheader']['opus']['sample_rate']; + $info['opus']['out_channel_count'] = $info['ogg']['pageheader']['opus']['out_channel_count']; + + $info['audio']['channels'] = $info['opus']['out_channel_count']; + $info['audio']['sample_rate'] = $info['opus']['sample_rate']; + return true; + } + + + public function ParseOggPageHeader() { + // http://xiph.org/ogg/vorbis/doc/framing.html + $oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file + + $filedata = $this->fread($this->getid3->fread_buffer_size()); + $filedataoffset = 0; + while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) { + if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) { + // should be found before here + return false; + } + if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) { + if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === false)) { + // get some more data, unless eof, in which case fail + return false; + } + } + } + $filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS' + + $oggheader['stream_structver'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $oggheader['flags_raw'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $oggheader['flags']['fresh'] = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet + $oggheader['flags']['bos'] = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos) + $oggheader['flags']['eos'] = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos) + + $oggheader['pcm_abs_position'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8)); + $filedataoffset += 8; + $oggheader['stream_serialno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $oggheader['page_seqno'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $oggheader['page_checksum'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4)); + $filedataoffset += 4; + $oggheader['page_segments'] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $oggheader['page_length'] = 0; + for ($i = 0; $i < $oggheader['page_segments']; $i++) { + $oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1)); + $filedataoffset += 1; + $oggheader['page_length'] += $oggheader['segment_table'][$i]; + } + $oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset; + $oggheader['page_end_offset'] = $oggheader['header_end_offset'] + $oggheader['page_length']; + $this->fseek($oggheader['header_end_offset']); + + return $oggheader; + } + + // http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810005 + public function ParseVorbisComments() { + $info = &$this->getid3->info; + + $OriginalOffset = $this->ftell(); + $commentdataoffset = 0; + $VorbisCommentPage = 1; + + switch ($info['audio']['dataformat']) { + case 'vorbis': + case 'speex': + case 'opus': + $CommentStartOffset = $info['ogg']['pageheader'][$VorbisCommentPage]['page_start_offset']; // Second Ogg page, after header block + $this->fseek($CommentStartOffset); + $commentdataoffset = 27 + $info['ogg']['pageheader'][$VorbisCommentPage]['page_segments']; + $commentdata = $this->fread(self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1) + $commentdataoffset); + + if ($info['audio']['dataformat'] == 'vorbis') { + $commentdataoffset += (strlen('vorbis') + 1); + } + else if ($info['audio']['dataformat'] == 'opus') { + $commentdataoffset += strlen('OpusTags'); + } + + break; + + case 'flac': + $CommentStartOffset = $info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4; + $this->fseek($CommentStartOffset); + $commentdata = $this->fread($info['flac']['VORBIS_COMMENT']['raw']['block_length']); + break; + + default: + return false; + break; + } + + $VendorSize = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4)); + $commentdataoffset += 4; + + $info['ogg']['vendor'] = substr($commentdata, $commentdataoffset, $VendorSize); + $commentdataoffset += $VendorSize; + + $CommentsCount = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4)); + $commentdataoffset += 4; + $info['avdataoffset'] = $CommentStartOffset + $commentdataoffset; + + $basicfields = array('TITLE', 'ARTIST', 'ALBUM', 'TRACKNUMBER', 'GENRE', 'DATE', 'DESCRIPTION', 'COMMENT'); + $ThisFileInfo_ogg_comments_raw = &$info['ogg']['comments_raw']; + for ($i = 0; $i < $CommentsCount; $i++) { + + if ($i >= 10000) { + // https://github.com/owncloud/music/issues/212#issuecomment-43082336 + $this->warning('Unexpectedly large number ('.$CommentsCount.') of Ogg comments - breaking after reading '.$i.' comments'); + break; + } + + $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] = $CommentStartOffset + $commentdataoffset; + + if ($this->ftell() < ($ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + 4)) { + if ($oggpageinfo = $this->ParseOggPageHeader()) { + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo; + + $VorbisCommentPage++; + + // First, save what we haven't read yet + $AsYetUnusedData = substr($commentdata, $commentdataoffset); + + // Then take that data off the end + $commentdata = substr($commentdata, 0, $commentdataoffset); + + // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct + $commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); + $commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); + + // Finally, stick the unused data back on the end + $commentdata .= $AsYetUnusedData; + + //$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); + $commentdata .= $this->fread($this->OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1)); + } + + } + $ThisFileInfo_ogg_comments_raw[$i]['size'] = getid3_lib::LittleEndian2Int(substr($commentdata, $commentdataoffset, 4)); + + // replace avdataoffset with position just after the last vorbiscomment + $info['avdataoffset'] = $ThisFileInfo_ogg_comments_raw[$i]['dataoffset'] + $ThisFileInfo_ogg_comments_raw[$i]['size'] + 4; + + $commentdataoffset += 4; + while ((strlen($commentdata) - $commentdataoffset) < $ThisFileInfo_ogg_comments_raw[$i]['size']) { + if (($ThisFileInfo_ogg_comments_raw[$i]['size'] > $info['avdataend']) || ($ThisFileInfo_ogg_comments_raw[$i]['size'] < 0)) { + $this->warning('Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($ThisFileInfo_ogg_comments_raw[$i]['size']).' bytes) - aborting reading comments'); + break 2; + } + + $VorbisCommentPage++; + + $oggpageinfo = $this->ParseOggPageHeader(); + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']] = $oggpageinfo; + + // First, save what we haven't read yet + $AsYetUnusedData = substr($commentdata, $commentdataoffset); + + // Then take that data off the end + $commentdata = substr($commentdata, 0, $commentdataoffset); + + // Add [headerlength] bytes of dummy data for the Ogg Page Header, just to keep absolute offsets correct + $commentdata .= str_repeat("\x00", 27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); + $commentdataoffset += (27 + $info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_segments']); + + // Finally, stick the unused data back on the end + $commentdata .= $AsYetUnusedData; + + //$commentdata .= $this->fread($info['ogg']['pageheader'][$oggpageinfo['page_seqno']]['page_length']); + if (!isset($info['ogg']['pageheader'][$VorbisCommentPage])) { + $this->warning('undefined Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell()); + break; + } + $readlength = self::OggPageSegmentLength($info['ogg']['pageheader'][$VorbisCommentPage], 1); + if ($readlength <= 0) { + $this->warning('invalid length Vorbis Comment page "'.$VorbisCommentPage.'" at offset '.$this->ftell()); + break; + } + $commentdata .= $this->fread($readlength); + + //$filebaseoffset += $oggpageinfo['header_end_offset'] - $oggpageinfo['page_start_offset']; + } + $ThisFileInfo_ogg_comments_raw[$i]['offset'] = $commentdataoffset; + $commentstring = substr($commentdata, $commentdataoffset, $ThisFileInfo_ogg_comments_raw[$i]['size']); + $commentdataoffset += $ThisFileInfo_ogg_comments_raw[$i]['size']; + + if (!$commentstring) { + + // no comment? + $this->warning('Blank Ogg comment ['.$i.']'); + + } elseif (strstr($commentstring, '=')) { + + $commentexploded = explode('=', $commentstring, 2); + $ThisFileInfo_ogg_comments_raw[$i]['key'] = strtoupper($commentexploded[0]); + $ThisFileInfo_ogg_comments_raw[$i]['value'] = (isset($commentexploded[1]) ? $commentexploded[1] : ''); + + if ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'METADATA_BLOCK_PICTURE') { + + // http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE + // The unencoded format is that of the FLAC picture block. The fields are stored in big endian order as in FLAC, picture data is stored according to the relevant standard. + // http://flac.sourceforge.net/format.html#metadata_block_picture + $flac = new getid3_flac($this->getid3); + $flac->setStringMode(base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value'])); + $flac->parsePICTURE(); + $info['ogg']['comments']['picture'][] = $flac->getid3->info['flac']['PICTURE'][0]; + unset($flac); + + } elseif ($ThisFileInfo_ogg_comments_raw[$i]['key'] == 'COVERART') { + + $data = base64_decode($ThisFileInfo_ogg_comments_raw[$i]['value']); + $this->notice('Found deprecated COVERART tag, it should be replaced in honor of METADATA_BLOCK_PICTURE structure'); + /** @todo use 'coverartmime' where available */ + $imageinfo = getid3_lib::GetDataImageSize($data); + if ($imageinfo === false || !isset($imageinfo['mime'])) { + $this->warning('COVERART vorbiscomment tag contains invalid image'); + continue; + } + + $ogg = new self($this->getid3); + $ogg->setStringMode($data); + $info['ogg']['comments']['picture'][] = array( + 'image_mime' => $imageinfo['mime'], + 'datalength' => strlen($data), + 'picturetype' => 'cover art', + 'image_height' => $imageinfo['height'], + 'image_width' => $imageinfo['width'], + 'data' => $ogg->saveAttachment('coverart', 0, strlen($data), $imageinfo['mime']), + ); + unset($ogg); + + } else { + + $info['ogg']['comments'][strtolower($ThisFileInfo_ogg_comments_raw[$i]['key'])][] = $ThisFileInfo_ogg_comments_raw[$i]['value']; + + } + + } else { + + $this->warning('[known problem with CDex >= v1.40, < v1.50b7] Invalid Ogg comment name/value pair ['.$i.']: '.$commentstring); + + } + unset($ThisFileInfo_ogg_comments_raw[$i]); + } + unset($ThisFileInfo_ogg_comments_raw); + + + // Replay Gain Adjustment + // http://privatewww.essex.ac.uk/~djmrob/replaygain/ + if (isset($info['ogg']['comments']) && is_array($info['ogg']['comments'])) { + foreach ($info['ogg']['comments'] as $index => $commentvalue) { + switch ($index) { + case 'rg_audiophile': + case 'replaygain_album_gain': + $info['replay_gain']['album']['adjustment'] = (double) $commentvalue[0]; + unset($info['ogg']['comments'][$index]); + break; + + case 'rg_radio': + case 'replaygain_track_gain': + $info['replay_gain']['track']['adjustment'] = (double) $commentvalue[0]; + unset($info['ogg']['comments'][$index]); + break; + + case 'replaygain_album_peak': + $info['replay_gain']['album']['peak'] = (double) $commentvalue[0]; + unset($info['ogg']['comments'][$index]); + break; + + case 'rg_peak': + case 'replaygain_track_peak': + $info['replay_gain']['track']['peak'] = (double) $commentvalue[0]; + unset($info['ogg']['comments'][$index]); + break; + + case 'replaygain_reference_loudness': + $info['replay_gain']['reference_volume'] = (double) $commentvalue[0]; + unset($info['ogg']['comments'][$index]); + break; + + default: + // do nothing + break; + } + } + } + + $this->fseek($OriginalOffset); + + return true; + } + + public static function SpeexBandModeLookup($mode) { + static $SpeexBandModeLookup = array(); + if (empty($SpeexBandModeLookup)) { + $SpeexBandModeLookup[0] = 'narrow'; + $SpeexBandModeLookup[1] = 'wide'; + $SpeexBandModeLookup[2] = 'ultra-wide'; + } + return (isset($SpeexBandModeLookup[$mode]) ? $SpeexBandModeLookup[$mode] : null); + } + + + public static function OggPageSegmentLength($OggInfoArray, $SegmentNumber=1) { + for ($i = 0; $i < $SegmentNumber; $i++) { + $segmentlength = 0; + foreach ($OggInfoArray['segment_table'] as $key => $value) { + $segmentlength += $value; + if ($value < 255) { + break; + } + } + } + return $segmentlength; + } + + + public static function get_quality_from_nominal_bitrate($nominal_bitrate) { + + // decrease precision + $nominal_bitrate = $nominal_bitrate / 1000; + + if ($nominal_bitrate < 128) { + // q-1 to q4 + $qval = ($nominal_bitrate - 64) / 16; + } elseif ($nominal_bitrate < 256) { + // q4 to q8 + $qval = $nominal_bitrate / 32; + } elseif ($nominal_bitrate < 320) { + // q8 to q9 + $qval = ($nominal_bitrate + 256) / 64; + } else { + // q9 to q10 + $qval = ($nominal_bitrate + 1300) / 180; + } + //return $qval; // 5.031324 + //return intval($qval); // 5 + return round($qval, 1); // 5 or 4.9 + } + + public static function TheoraColorSpace($colorspace_id) { + // http://www.theora.org/doc/Theora.pdf (table 6.3) + static $TheoraColorSpaceLookup = array(); + if (empty($TheoraColorSpaceLookup)) { + $TheoraColorSpaceLookup[0] = 'Undefined'; + $TheoraColorSpaceLookup[1] = 'Rec. 470M'; + $TheoraColorSpaceLookup[2] = 'Rec. 470BG'; + $TheoraColorSpaceLookup[3] = 'Reserved'; + } + return (isset($TheoraColorSpaceLookup[$colorspace_id]) ? $TheoraColorSpaceLookup[$colorspace_id] : null); + } + + public static function TheoraPixelFormat($pixelformat_id) { + // http://www.theora.org/doc/Theora.pdf (table 6.4) + static $TheoraPixelFormatLookup = array(); + if (empty($TheoraPixelFormatLookup)) { + $TheoraPixelFormatLookup[0] = '4:2:0'; + $TheoraPixelFormatLookup[1] = 'Reserved'; + $TheoraPixelFormatLookup[2] = '4:2:2'; + $TheoraPixelFormatLookup[3] = '4:4:4'; + } + return (isset($TheoraPixelFormatLookup[$pixelformat_id]) ? $TheoraPixelFormatLookup[$pixelformat_id] : null); + } + +} diff --git a/backend/wp-includes/ID3/module.tag.apetag.php b/backend/wp-includes/ID3/module.tag.apetag.php new file mode 100644 index 0000000..eb081b4 --- /dev/null +++ b/backend/wp-includes/ID3/module.tag.apetag.php @@ -0,0 +1,416 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.tag.apetag.php // +// module for analyzing APE tags // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + +class getid3_apetag extends getid3_handler +{ + public $inline_attachments = true; // true: return full data for all attachments; false: return no data for all attachments; integer: return data for attachments <= than this; string: save as file to this directory + public $overrideendoffset = 0; + + public function Analyze() { + $info = &$this->getid3->info; + + if (!getid3_lib::intValueSupported($info['filesize'])) { + $this->warning('Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'); + return false; + } + + $id3v1tagsize = 128; + $apetagheadersize = 32; + $lyrics3tagsize = 10; + + if ($this->overrideendoffset == 0) { + + $this->fseek(0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END); + $APEfooterID3v1 = $this->fread($id3v1tagsize + $apetagheadersize + $lyrics3tagsize); + + //if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) { + if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') { + + // APE tag found before ID3v1 + $info['ape']['tag_offset_end'] = $info['filesize'] - $id3v1tagsize; + + //} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) { + } elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') { + + // APE tag found, no ID3v1 + $info['ape']['tag_offset_end'] = $info['filesize']; + + } + + } else { + + $this->fseek($this->overrideendoffset - $apetagheadersize); + if ($this->fread(8) == 'APETAGEX') { + $info['ape']['tag_offset_end'] = $this->overrideendoffset; + } + + } + if (!isset($info['ape']['tag_offset_end'])) { + + // APE tag not found + unset($info['ape']); + return false; + + } + + // shortcut + $thisfile_ape = &$info['ape']; + + $this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize); + $APEfooterData = $this->fread(32); + if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) { + $this->error('Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']); + return false; + } + + if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) { + $this->fseek($thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize); + $thisfile_ape['tag_offset_start'] = $this->ftell(); + $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize); + } else { + $thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize']; + $this->fseek($thisfile_ape['tag_offset_start']); + $APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize']); + } + $info['avdataend'] = $thisfile_ape['tag_offset_start']; + + if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) { + $this->warning('ID3v1 tag information ignored since it appears to be a false synch in APEtag data'); + unset($info['id3v1']); + foreach ($info['warning'] as $key => $value) { + if ($value == 'Some ID3v1 fields do not use NULL characters for padding') { + unset($info['warning'][$key]); + sort($info['warning']); + break; + } + } + } + + $offset = 0; + if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) { + if ($thisfile_ape['header'] = $this->parseAPEheaderFooter(substr($APEtagData, 0, $apetagheadersize))) { + $offset += $apetagheadersize; + } else { + $this->error('Error parsing APE header at offset '.$thisfile_ape['tag_offset_start']); + return false; + } + } + + // shortcut + $info['replay_gain'] = array(); + $thisfile_replaygain = &$info['replay_gain']; + + for ($i = 0; $i < $thisfile_ape['footer']['raw']['tag_items']; $i++) { + $value_size = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4)); + $offset += 4; + $item_flags = getid3_lib::LittleEndian2Int(substr($APEtagData, $offset, 4)); + $offset += 4; + if (strstr(substr($APEtagData, $offset), "\x00") === false) { + $this->error('Cannot find null-byte (0x00) separator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset)); + return false; + } + $ItemKeyLength = strpos($APEtagData, "\x00", $offset) - $offset; + $item_key = strtolower(substr($APEtagData, $offset, $ItemKeyLength)); + + // shortcut + $thisfile_ape['items'][$item_key] = array(); + $thisfile_ape_items_current = &$thisfile_ape['items'][$item_key]; + + $thisfile_ape_items_current['offset'] = $thisfile_ape['tag_offset_start'] + $offset; + + $offset += ($ItemKeyLength + 1); // skip 0x00 terminator + $thisfile_ape_items_current['data'] = substr($APEtagData, $offset, $value_size); + $offset += $value_size; + + $thisfile_ape_items_current['flags'] = $this->parseAPEtagFlags($item_flags); + switch ($thisfile_ape_items_current['flags']['item_contents_raw']) { + case 0: // UTF-8 + case 2: // Locator (URL, filename, etc), UTF-8 encoded + $thisfile_ape_items_current['data'] = explode("\x00", $thisfile_ape_items_current['data']); + break; + + case 1: // binary data + default: + break; + } + + switch (strtolower($item_key)) { + // http://wiki.hydrogenaud.io/index.php?title=ReplayGain#MP3Gain + case 'replaygain_track_gain': + if (preg_match('#^[\\-\\+][0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) { + $thisfile_replaygain['track']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero! + $thisfile_replaygain['track']['originator'] = 'unspecified'; + } else { + $this->warning('MP3gainTrackGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'replaygain_track_peak': + if (preg_match('#^[0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) { + $thisfile_replaygain['track']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero! + $thisfile_replaygain['track']['originator'] = 'unspecified'; + if ($thisfile_replaygain['track']['peak'] <= 0) { + $this->warning('ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")'); + } + } else { + $this->warning('MP3gainTrackPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'replaygain_album_gain': + if (preg_match('#^[\\-\\+][0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) { + $thisfile_replaygain['album']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero! + $thisfile_replaygain['album']['originator'] = 'unspecified'; + } else { + $this->warning('MP3gainAlbumGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'replaygain_album_peak': + if (preg_match('#^[0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) { + $thisfile_replaygain['album']['peak'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero! + $thisfile_replaygain['album']['originator'] = 'unspecified'; + if ($thisfile_replaygain['album']['peak'] <= 0) { + $this->warning('ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")'); + } + } else { + $this->warning('MP3gainAlbumPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'mp3gain_undo': + if (preg_match('#^[\\-\\+][0-9]{3},[\\-\\+][0-9]{3},[NW]$#', $thisfile_ape_items_current['data'][0])) { + list($mp3gain_undo_left, $mp3gain_undo_right, $mp3gain_undo_wrap) = explode(',', $thisfile_ape_items_current['data'][0]); + $thisfile_replaygain['mp3gain']['undo_left'] = intval($mp3gain_undo_left); + $thisfile_replaygain['mp3gain']['undo_right'] = intval($mp3gain_undo_right); + $thisfile_replaygain['mp3gain']['undo_wrap'] = (($mp3gain_undo_wrap == 'Y') ? true : false); + } else { + $this->warning('MP3gainUndo value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'mp3gain_minmax': + if (preg_match('#^[0-9]{3},[0-9]{3}$#', $thisfile_ape_items_current['data'][0])) { + list($mp3gain_globalgain_min, $mp3gain_globalgain_max) = explode(',', $thisfile_ape_items_current['data'][0]); + $thisfile_replaygain['mp3gain']['globalgain_track_min'] = intval($mp3gain_globalgain_min); + $thisfile_replaygain['mp3gain']['globalgain_track_max'] = intval($mp3gain_globalgain_max); + } else { + $this->warning('MP3gainMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'mp3gain_album_minmax': + if (preg_match('#^[0-9]{3},[0-9]{3}$#', $thisfile_ape_items_current['data'][0])) { + list($mp3gain_globalgain_album_min, $mp3gain_globalgain_album_max) = explode(',', $thisfile_ape_items_current['data'][0]); + $thisfile_replaygain['mp3gain']['globalgain_album_min'] = intval($mp3gain_globalgain_album_min); + $thisfile_replaygain['mp3gain']['globalgain_album_max'] = intval($mp3gain_globalgain_album_max); + } else { + $this->warning('MP3gainAlbumMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"'); + } + break; + + case 'tracknumber': + if (is_array($thisfile_ape_items_current['data'])) { + foreach ($thisfile_ape_items_current['data'] as $comment) { + $thisfile_ape['comments']['track'][] = $comment; + } + } + break; + + case 'cover art (artist)': + case 'cover art (back)': + case 'cover art (band logo)': + case 'cover art (band)': + case 'cover art (colored fish)': + case 'cover art (composer)': + case 'cover art (conductor)': + case 'cover art (front)': + case 'cover art (icon)': + case 'cover art (illustration)': + case 'cover art (lead)': + case 'cover art (leaflet)': + case 'cover art (lyricist)': + case 'cover art (media)': + case 'cover art (movie scene)': + case 'cover art (other icon)': + case 'cover art (other)': + case 'cover art (performance)': + case 'cover art (publisher logo)': + case 'cover art (recording)': + case 'cover art (studio)': + // list of possible cover arts from http://taglib-sharp.sourcearchive.com/documentation/2.0.3.0-2/Ape_2Tag_8cs-source.html + if (is_array($thisfile_ape_items_current['data'])) { + $this->warning('APEtag "'.$item_key.'" should be flagged as Binary data, but was incorrectly flagged as UTF-8'); + $thisfile_ape_items_current['data'] = implode("\x00", $thisfile_ape_items_current['data']); + } + list($thisfile_ape_items_current['filename'], $thisfile_ape_items_current['data']) = explode("\x00", $thisfile_ape_items_current['data'], 2); + $thisfile_ape_items_current['data_offset'] = $thisfile_ape_items_current['offset'] + strlen($thisfile_ape_items_current['filename']."\x00"); + $thisfile_ape_items_current['data_length'] = strlen($thisfile_ape_items_current['data']); + + do { + $thisfile_ape_items_current['image_mime'] = ''; + $imageinfo = array(); + $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_ape_items_current['data'], $imageinfo); + if (($imagechunkcheck === false) || !isset($imagechunkcheck[2])) { + $this->warning('APEtag "'.$item_key.'" contains invalid image data'); + break; + } + $thisfile_ape_items_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]); + + if ($this->inline_attachments === false) { + // skip entirely + unset($thisfile_ape_items_current['data']); + break; + } + if ($this->inline_attachments === true) { + // great + } elseif (is_int($this->inline_attachments)) { + if ($this->inline_attachments < $thisfile_ape_items_current['data_length']) { + // too big, skip + $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' is too large to process inline ('.number_format($thisfile_ape_items_current['data_length']).' bytes)'); + unset($thisfile_ape_items_current['data']); + break; + } + } elseif (is_string($this->inline_attachments)) { + $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR); + if (!is_dir($this->inline_attachments) || !getID3::is_writable($this->inline_attachments)) { + // cannot write, skip + $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)'); + unset($thisfile_ape_items_current['data']); + break; + } + } + // if we get this far, must be OK + if (is_string($this->inline_attachments)) { + $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset']; + if (!file_exists($destination_filename) || getID3::is_writable($destination_filename)) { + file_put_contents($destination_filename, $thisfile_ape_items_current['data']); + } else { + $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)'); + } + $thisfile_ape_items_current['data_filename'] = $destination_filename; + unset($thisfile_ape_items_current['data']); + } else { + if (!isset($info['ape']['comments']['picture'])) { + $info['ape']['comments']['picture'] = array(); + } + $comments_picture_data = array(); + foreach (array('data', 'image_mime', 'image_width', 'image_height', 'imagetype', 'picturetype', 'description', 'datalength') as $picture_key) { + if (isset($thisfile_ape_items_current[$picture_key])) { + $comments_picture_data[$picture_key] = $thisfile_ape_items_current[$picture_key]; + } + } + $info['ape']['comments']['picture'][] = $comments_picture_data; + unset($comments_picture_data); + } + } while (false); + break; + + default: + if (is_array($thisfile_ape_items_current['data'])) { + foreach ($thisfile_ape_items_current['data'] as $comment) { + $thisfile_ape['comments'][strtolower($item_key)][] = $comment; + } + } + break; + } + + } + if (empty($thisfile_replaygain)) { + unset($info['replay_gain']); + } + return true; + } + + public function parseAPEheaderFooter($APEheaderFooterData) { + // http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html + + // shortcut + $headerfooterinfo['raw'] = array(); + $headerfooterinfo_raw = &$headerfooterinfo['raw']; + + $headerfooterinfo_raw['footer_tag'] = substr($APEheaderFooterData, 0, 8); + if ($headerfooterinfo_raw['footer_tag'] != 'APETAGEX') { + return false; + } + $headerfooterinfo_raw['version'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 8, 4)); + $headerfooterinfo_raw['tagsize'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 12, 4)); + $headerfooterinfo_raw['tag_items'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 16, 4)); + $headerfooterinfo_raw['global_flags'] = getid3_lib::LittleEndian2Int(substr($APEheaderFooterData, 20, 4)); + $headerfooterinfo_raw['reserved'] = substr($APEheaderFooterData, 24, 8); + + $headerfooterinfo['tag_version'] = $headerfooterinfo_raw['version'] / 1000; + if ($headerfooterinfo['tag_version'] >= 2) { + $headerfooterinfo['flags'] = $this->parseAPEtagFlags($headerfooterinfo_raw['global_flags']); + } + return $headerfooterinfo; + } + + public function parseAPEtagFlags($rawflagint) { + // "Note: APE Tags 1.0 do not use any of the APE Tag flags. + // All are set to zero on creation and ignored on reading." + // http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags + $flags['header'] = (bool) ($rawflagint & 0x80000000); + $flags['footer'] = (bool) ($rawflagint & 0x40000000); + $flags['this_is_header'] = (bool) ($rawflagint & 0x20000000); + $flags['item_contents_raw'] = ($rawflagint & 0x00000006) >> 1; + $flags['read_only'] = (bool) ($rawflagint & 0x00000001); + + $flags['item_contents'] = $this->APEcontentTypeFlagLookup($flags['item_contents_raw']); + + return $flags; + } + + public function APEcontentTypeFlagLookup($contenttypeid) { + static $APEcontentTypeFlagLookup = array( + 0 => 'utf-8', + 1 => 'binary', + 2 => 'external', + 3 => 'reserved' + ); + return (isset($APEcontentTypeFlagLookup[$contenttypeid]) ? $APEcontentTypeFlagLookup[$contenttypeid] : 'invalid'); + } + + public function APEtagItemIsUTF8Lookup($itemkey) { + static $APEtagItemIsUTF8Lookup = array( + 'title', + 'subtitle', + 'artist', + 'album', + 'debut album', + 'publisher', + 'conductor', + 'track', + 'composer', + 'comment', + 'copyright', + 'publicationright', + 'file', + 'year', + 'record date', + 'record location', + 'genre', + 'media', + 'related', + 'isrc', + 'abstract', + 'language', + 'bibliography' + ); + return in_array(strtolower($itemkey), $APEtagItemIsUTF8Lookup); + } + +} diff --git a/backend/wp-includes/ID3/module.tag.id3v1.php b/backend/wp-includes/ID3/module.tag.id3v1.php new file mode 100644 index 0000000..d160e9b --- /dev/null +++ b/backend/wp-includes/ID3/module.tag.id3v1.php @@ -0,0 +1,381 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +// // +// module.tag.id3v1.php // +// module for analyzing ID3v1 tags // +// dependencies: NONE // +// /// +///////////////////////////////////////////////////////////////// + + +class getid3_id3v1 extends getid3_handler +{ + + public function Analyze() { + $info = &$this->getid3->info; + + if (!getid3_lib::intValueSupported($info['filesize'])) { + $this->warning('Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'); + return false; + } + + $this->fseek(-256, SEEK_END); + $preid3v1 = $this->fread(128); + $id3v1tag = $this->fread(128); + + if (substr($id3v1tag, 0, 3) == 'TAG') { + + $info['avdataend'] = $info['filesize'] - 128; + + $ParsedID3v1['title'] = $this->cutfield(substr($id3v1tag, 3, 30)); + $ParsedID3v1['artist'] = $this->cutfield(substr($id3v1tag, 33, 30)); + $ParsedID3v1['album'] = $this->cutfield(substr($id3v1tag, 63, 30)); + $ParsedID3v1['year'] = $this->cutfield(substr($id3v1tag, 93, 4)); + $ParsedID3v1['comment'] = substr($id3v1tag, 97, 30); // can't remove nulls yet, track detection depends on them + $ParsedID3v1['genreid'] = ord(substr($id3v1tag, 127, 1)); + + // If second-last byte of comment field is null and last byte of comment field is non-null + // then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number + if (($id3v1tag{125} === "\x00") && ($id3v1tag{126} !== "\x00")) { + $ParsedID3v1['track'] = ord(substr($ParsedID3v1['comment'], 29, 1)); + $ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28); + } + $ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']); + + $ParsedID3v1['genre'] = $this->LookupGenreName($ParsedID3v1['genreid']); + if (!empty($ParsedID3v1['genre'])) { + unset($ParsedID3v1['genreid']); + } + if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) { + unset($ParsedID3v1['genre']); + } + + foreach ($ParsedID3v1 as $key => $value) { + $ParsedID3v1['comments'][$key][0] = $value; + } + // ID3v1 encoding detection hack START + // ID3v1 is defined as always using ISO-8859-1 encoding, but it is not uncommon to find files tagged with ID3v1 using Windows-1251 or other character sets + // Since ID3v1 has no concept of character sets there is no certain way to know we have the correct non-ISO-8859-1 character set, but we can guess + $ID3v1encoding = 'ISO-8859-1'; + foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) { + foreach ($valuearray as $key => $value) { + if (preg_match('#^[\\x00-\\x40\\xA8\\B8\\x80-\\xFF]+$#', $value)) { + foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) { + if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) { + $ID3v1encoding = $id3v1_bad_encoding; + break 3; + } elseif (function_exists('iconv') && @iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) { + $ID3v1encoding = $id3v1_bad_encoding; + break 3; + } + } + } + } + } + // ID3v1 encoding detection hack END + + // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces + $GoodFormatID3v1tag = $this->GenerateID3v1Tag( + $ParsedID3v1['title'], + $ParsedID3v1['artist'], + $ParsedID3v1['album'], + $ParsedID3v1['year'], + (isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false), + $ParsedID3v1['comment'], + (!empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : '')); + $ParsedID3v1['padding_valid'] = true; + if ($id3v1tag !== $GoodFormatID3v1tag) { + $ParsedID3v1['padding_valid'] = false; + $this->warning('Some ID3v1 fields do not use NULL characters for padding'); + } + + $ParsedID3v1['tag_offset_end'] = $info['filesize']; + $ParsedID3v1['tag_offset_start'] = $ParsedID3v1['tag_offset_end'] - 128; + + $info['id3v1'] = $ParsedID3v1; + $info['id3v1']['encoding'] = $ID3v1encoding; + } + + if (substr($preid3v1, 0, 3) == 'TAG') { + // The way iTunes handles tags is, well, brain-damaged. + // It completely ignores v1 if ID3v2 is present. + // This goes as far as adding a new v1 tag *even if there already is one* + + // A suspected double-ID3v1 tag has been detected, but it could be that + // the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag + if (substr($preid3v1, 96, 8) == 'APETAGEX') { + // an APE tag footer was found before the last ID3v1, assume false "TAG" synch + } elseif (substr($preid3v1, 119, 6) == 'LYRICS') { + // a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch + } else { + // APE and Lyrics3 footers not found - assume double ID3v1 + $this->warning('Duplicate ID3v1 tag detected - this has been known to happen with iTunes'); + $info['avdataend'] -= 128; + } + } + + return true; + } + + public static function cutfield($str) { + return trim(substr($str, 0, strcspn($str, "\x00"))); + } + + public static function ArrayOfGenres($allowSCMPXextended=false) { + static $GenreLookup = array( + 0 => 'Blues', + 1 => 'Classic Rock', + 2 => 'Country', + 3 => 'Dance', + 4 => 'Disco', + 5 => 'Funk', + 6 => 'Grunge', + 7 => 'Hip-Hop', + 8 => 'Jazz', + 9 => 'Metal', + 10 => 'New Age', + 11 => 'Oldies', + 12 => 'Other', + 13 => 'Pop', + 14 => 'R&B', + 15 => 'Rap', + 16 => 'Reggae', + 17 => 'Rock', + 18 => 'Techno', + 19 => 'Industrial', + 20 => 'Alternative', + 21 => 'Ska', + 22 => 'Death Metal', + 23 => 'Pranks', + 24 => 'Soundtrack', + 25 => 'Euro-Techno', + 26 => 'Ambient', + 27 => 'Trip-Hop', + 28 => 'Vocal', + 29 => 'Jazz+Funk', + 30 => 'Fusion', + 31 => 'Trance', + 32 => 'Classical', + 33 => 'Instrumental', + 34 => 'Acid', + 35 => 'House', + 36 => 'Game', + 37 => 'Sound Clip', + 38 => 'Gospel', + 39 => 'Noise', + 40 => 'Alt. Rock', + 41 => 'Bass', + 42 => 'Soul', + 43 => 'Punk', + 44 => 'Space', + 45 => 'Meditative', + 46 => 'Instrumental Pop', + 47 => 'Instrumental Rock', + 48 => 'Ethnic', + 49 => 'Gothic', + 50 => 'Darkwave', + 51 => 'Techno-Industrial', + 52 => 'Electronic', + 53 => 'Pop-Folk', + 54 => 'Eurodance', + 55 => 'Dream', + 56 => 'Southern Rock', + 57 => 'Comedy', + 58 => 'Cult', + 59 => 'Gangsta Rap', + 60 => 'Top 40', + 61 => 'Christian Rap', + 62 => 'Pop/Funk', + 63 => 'Jungle', + 64 => 'Native American', + 65 => 'Cabaret', + 66 => 'New Wave', + 67 => 'Psychedelic', + 68 => 'Rave', + 69 => 'Showtunes', + 70 => 'Trailer', + 71 => 'Lo-Fi', + 72 => 'Tribal', + 73 => 'Acid Punk', + 74 => 'Acid Jazz', + 75 => 'Polka', + 76 => 'Retro', + 77 => 'Musical', + 78 => 'Rock & Roll', + 79 => 'Hard Rock', + 80 => 'Folk', + 81 => 'Folk/Rock', + 82 => 'National Folk', + 83 => 'Swing', + 84 => 'Fast-Fusion', + 85 => 'Bebob', + 86 => 'Latin', + 87 => 'Revival', + 88 => 'Celtic', + 89 => 'Bluegrass', + 90 => 'Avantgarde', + 91 => 'Gothic Rock', + 92 => 'Progressive Rock', + 93 => 'Psychedelic Rock', + 94 => 'Symphonic Rock', + 95 => 'Slow Rock', + 96 => 'Big Band', + 97 => 'Chorus', + 98 => 'Easy Listening', + 99 => 'Acoustic', + 100 => 'Humour', + 101 => 'Speech', + 102 => 'Chanson', + 103 => 'Opera', + 104 => 'Chamber Music', + 105 => 'Sonata', + 106 => 'Symphony', + 107 => 'Booty Bass', + 108 => 'Primus', + 109 => 'Porn Groove', + 110 => 'Satire', + 111 => 'Slow Jam', + 112 => 'Club', + 113 => 'Tango', + 114 => 'Samba', + 115 => 'Folklore', + 116 => 'Ballad', + 117 => 'Power Ballad', + 118 => 'Rhythmic Soul', + 119 => 'Freestyle', + 120 => 'Duet', + 121 => 'Punk Rock', + 122 => 'Drum Solo', + 123 => 'A Cappella', + 124 => 'Euro-House', + 125 => 'Dance Hall', + 126 => 'Goa', + 127 => 'Drum & Bass', + 128 => 'Club-House', + 129 => 'Hardcore', + 130 => 'Terror', + 131 => 'Indie', + 132 => 'BritPop', + 133 => 'Negerpunk', + 134 => 'Polsk Punk', + 135 => 'Beat', + 136 => 'Christian Gangsta Rap', + 137 => 'Heavy Metal', + 138 => 'Black Metal', + 139 => 'Crossover', + 140 => 'Contemporary Christian', + 141 => 'Christian Rock', + 142 => 'Merengue', + 143 => 'Salsa', + 144 => 'Thrash Metal', + 145 => 'Anime', + 146 => 'JPop', + 147 => 'Synthpop', + + 255 => 'Unknown', + + 'CR' => 'Cover', + 'RX' => 'Remix' + ); + + static $GenreLookupSCMPX = array(); + if ($allowSCMPXextended && empty($GenreLookupSCMPX)) { + $GenreLookupSCMPX = $GenreLookup; + // http://www.geocities.co.jp/SiliconValley-Oakland/3664/alittle.html#GenreExtended + // Extended ID3v1 genres invented by SCMPX + // Note that 255 "Japanese Anime" conflicts with standard "Unknown" + $GenreLookupSCMPX[240] = 'Sacred'; + $GenreLookupSCMPX[241] = 'Northern Europe'; + $GenreLookupSCMPX[242] = 'Irish & Scottish'; + $GenreLookupSCMPX[243] = 'Scotland'; + $GenreLookupSCMPX[244] = 'Ethnic Europe'; + $GenreLookupSCMPX[245] = 'Enka'; + $GenreLookupSCMPX[246] = 'Children\'s Song'; + $GenreLookupSCMPX[247] = 'Japanese Sky'; + $GenreLookupSCMPX[248] = 'Japanese Heavy Rock'; + $GenreLookupSCMPX[249] = 'Japanese Doom Rock'; + $GenreLookupSCMPX[250] = 'Japanese J-POP'; + $GenreLookupSCMPX[251] = 'Japanese Seiyu'; + $GenreLookupSCMPX[252] = 'Japanese Ambient Techno'; + $GenreLookupSCMPX[253] = 'Japanese Moemoe'; + $GenreLookupSCMPX[254] = 'Japanese Tokusatsu'; + //$GenreLookupSCMPX[255] = 'Japanese Anime'; + } + + return ($allowSCMPXextended ? $GenreLookupSCMPX : $GenreLookup); + } + + public static function LookupGenreName($genreid, $allowSCMPXextended=true) { + switch ($genreid) { + case 'RX': + case 'CR': + break; + default: + if (!is_numeric($genreid)) { + return false; + } + $genreid = intval($genreid); // to handle 3 or '3' or '03' + break; + } + $GenreLookup = self::ArrayOfGenres($allowSCMPXextended); + return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false); + } + + public static function LookupGenreID($genre, $allowSCMPXextended=false) { + $GenreLookup = self::ArrayOfGenres($allowSCMPXextended); + $LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre)); + foreach ($GenreLookup as $key => $value) { + if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) { + return $key; + } + } + return false; + } + + public static function StandardiseID3v1GenreName($OriginalGenre) { + if (($GenreID = self::LookupGenreID($OriginalGenre)) !== false) { + return self::LookupGenreName($GenreID); + } + return $OriginalGenre; + } + + public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') { + $ID3v1Tag = 'TAG'; + $ID3v1Tag .= str_pad(trim(substr($title, 0, 30)), 30, "\x00", STR_PAD_RIGHT); + $ID3v1Tag .= str_pad(trim(substr($artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT); + $ID3v1Tag .= str_pad(trim(substr($album, 0, 30)), 30, "\x00", STR_PAD_RIGHT); + $ID3v1Tag .= str_pad(trim(substr($year, 0, 4)), 4, "\x00", STR_PAD_LEFT); + if (!empty($track) && ($track > 0) && ($track <= 255)) { + $ID3v1Tag .= str_pad(trim(substr($comment, 0, 28)), 28, "\x00", STR_PAD_RIGHT); + $ID3v1Tag .= "\x00"; + if (gettype($track) == 'string') { + $track = (int) $track; + } + $ID3v1Tag .= chr($track); + } else { + $ID3v1Tag .= str_pad(trim(substr($comment, 0, 30)), 30, "\x00", STR_PAD_RIGHT); + } + if (($genreid < 0) || ($genreid > 147)) { + $genreid = 255; // 'unknown' genre + } + switch (gettype($genreid)) { + case 'string': + case 'integer': + $ID3v1Tag .= chr(intval($genreid)); + break; + default: + $ID3v1Tag .= chr(255); // 'unknown' genre + break; + } + + return $ID3v1Tag; + } + +} diff --git a/backend/wp-includes/ID3/module.tag.id3v2.php b/backend/wp-includes/ID3/module.tag.id3v2.php new file mode 100644 index 0000000..fc586e8 --- /dev/null +++ b/backend/wp-includes/ID3/module.tag.id3v2.php @@ -0,0 +1,3741 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +/// // +// module.tag.id3v2.php // +// module for analyzing ID3v2 tags // +// dependencies: module.tag.id3v1.php // +// /// +///////////////////////////////////////////////////////////////// + +getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true); + +class getid3_id3v2 extends getid3_handler +{ + public $StartingOffset = 0; + + public function Analyze() { + $info = &$this->getid3->info; + + // Overall tag structure: + // +-----------------------------+ + // | Header (10 bytes) | + // +-----------------------------+ + // | Extended Header | + // | (variable length, OPTIONAL) | + // +-----------------------------+ + // | Frames (variable length) | + // +-----------------------------+ + // | Padding | + // | (variable length, OPTIONAL) | + // +-----------------------------+ + // | Footer (10 bytes, OPTIONAL) | + // +-----------------------------+ + + // Header + // ID3v2/file identifier "ID3" + // ID3v2 version $04 00 + // ID3v2 flags (%ab000000 in v2.2, %abc00000 in v2.3, %abcd0000 in v2.4.x) + // ID3v2 size 4 * %0xxxxxxx + + + // shortcuts + $info['id3v2']['header'] = true; + $thisfile_id3v2 = &$info['id3v2']; + $thisfile_id3v2['flags'] = array(); + $thisfile_id3v2_flags = &$thisfile_id3v2['flags']; + + + $this->fseek($this->StartingOffset); + $header = $this->fread(10); + if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) { + + $thisfile_id3v2['majorversion'] = ord($header{3}); + $thisfile_id3v2['minorversion'] = ord($header{4}); + + // shortcut + $id3v2_majorversion = &$thisfile_id3v2['majorversion']; + + } else { + + unset($info['id3v2']); + return false; + + } + + if ($id3v2_majorversion > 4) { // this script probably won't correctly parse ID3v2.5.x and above (if it ever exists) + + $this->error('this script only parses up to ID3v2.4.x - this tag is ID3v2.'.$id3v2_majorversion.'.'.$thisfile_id3v2['minorversion']); + return false; + + } + + $id3_flags = ord($header{5}); + switch ($id3v2_majorversion) { + case 2: + // %ab000000 in v2.2 + $thisfile_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80); // a - Unsynchronisation + $thisfile_id3v2_flags['compression'] = (bool) ($id3_flags & 0x40); // b - Compression + break; + + case 3: + // %abc00000 in v2.3 + $thisfile_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80); // a - Unsynchronisation + $thisfile_id3v2_flags['exthead'] = (bool) ($id3_flags & 0x40); // b - Extended header + $thisfile_id3v2_flags['experim'] = (bool) ($id3_flags & 0x20); // c - Experimental indicator + break; + + case 4: + // %abcd0000 in v2.4 + $thisfile_id3v2_flags['unsynch'] = (bool) ($id3_flags & 0x80); // a - Unsynchronisation + $thisfile_id3v2_flags['exthead'] = (bool) ($id3_flags & 0x40); // b - Extended header + $thisfile_id3v2_flags['experim'] = (bool) ($id3_flags & 0x20); // c - Experimental indicator + $thisfile_id3v2_flags['isfooter'] = (bool) ($id3_flags & 0x10); // d - Footer present + break; + } + + $thisfile_id3v2['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length + + $thisfile_id3v2['tag_offset_start'] = $this->StartingOffset; + $thisfile_id3v2['tag_offset_end'] = $thisfile_id3v2['tag_offset_start'] + $thisfile_id3v2['headerlength']; + + + + // create 'encoding' key - used by getid3::HandleAllTags() + // in ID3v2 every field can have it's own encoding type + // so force everything to UTF-8 so it can be handled consistantly + $thisfile_id3v2['encoding'] = 'UTF-8'; + + + // Frames + + // All ID3v2 frames consists of one frame header followed by one or more + // fields containing the actual information. The header is always 10 + // bytes and laid out as follows: + // + // Frame ID $xx xx xx xx (four characters) + // Size 4 * %0xxxxxxx + // Flags $xx xx + + $sizeofframes = $thisfile_id3v2['headerlength'] - 10; // not including 10-byte initial header + if (!empty($thisfile_id3v2['exthead']['length'])) { + $sizeofframes -= ($thisfile_id3v2['exthead']['length'] + 4); + } + if (!empty($thisfile_id3v2_flags['isfooter'])) { + $sizeofframes -= 10; // footer takes last 10 bytes of ID3v2 header, after frame data, before audio + } + if ($sizeofframes > 0) { + + $framedata = $this->fread($sizeofframes); // read all frames from file into $framedata variable + + // if entire frame data is unsynched, de-unsynch it now (ID3v2.3.x) + if (!empty($thisfile_id3v2_flags['unsynch']) && ($id3v2_majorversion <= 3)) { + $framedata = $this->DeUnsynchronise($framedata); + } + // [in ID3v2.4.0] Unsynchronisation [S:6.1] is done on frame level, instead + // of on tag level, making it easier to skip frames, increasing the streamability + // of the tag. The unsynchronisation flag in the header [S:3.1] indicates that + // there exists an unsynchronised frame, while the new unsynchronisation flag in + // the frame header [S:4.1.2] indicates unsynchronisation. + + + //$framedataoffset = 10 + ($thisfile_id3v2['exthead']['length'] ? $thisfile_id3v2['exthead']['length'] + 4 : 0); // how many bytes into the stream - start from after the 10-byte header (and extended header length+4, if present) + $framedataoffset = 10; // how many bytes into the stream - start from after the 10-byte header + + + // Extended Header + if (!empty($thisfile_id3v2_flags['exthead'])) { + $extended_header_offset = 0; + + if ($id3v2_majorversion == 3) { + + // v2.3 definition: + //Extended header size $xx xx xx xx // 32-bit integer + //Extended Flags $xx xx + // %x0000000 %00000000 // v2.3 + // x - CRC data present + //Size of padding $xx xx xx xx + + $thisfile_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4), 0); + $extended_header_offset += 4; + + $thisfile_id3v2['exthead']['flag_bytes'] = 2; + $thisfile_id3v2['exthead']['flag_raw'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, $thisfile_id3v2['exthead']['flag_bytes'])); + $extended_header_offset += $thisfile_id3v2['exthead']['flag_bytes']; + + $thisfile_id3v2['exthead']['flags']['crc'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x8000); + + $thisfile_id3v2['exthead']['padding_size'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4)); + $extended_header_offset += 4; + + if ($thisfile_id3v2['exthead']['flags']['crc']) { + $thisfile_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4)); + $extended_header_offset += 4; + } + $extended_header_offset += $thisfile_id3v2['exthead']['padding_size']; + + } elseif ($id3v2_majorversion == 4) { + + // v2.4 definition: + //Extended header size 4 * %0xxxxxxx // 28-bit synchsafe integer + //Number of flag bytes $01 + //Extended Flags $xx + // %0bcd0000 // v2.4 + // b - Tag is an update + // Flag data length $00 + // c - CRC data present + // Flag data length $05 + // Total frame CRC 5 * %0xxxxxxx + // d - Tag restrictions + // Flag data length $01 + + $thisfile_id3v2['exthead']['length'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 4), true); + $extended_header_offset += 4; + + $thisfile_id3v2['exthead']['flag_bytes'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should always be 1 + $extended_header_offset += 1; + + $thisfile_id3v2['exthead']['flag_raw'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, $thisfile_id3v2['exthead']['flag_bytes'])); + $extended_header_offset += $thisfile_id3v2['exthead']['flag_bytes']; + + $thisfile_id3v2['exthead']['flags']['update'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x40); + $thisfile_id3v2['exthead']['flags']['crc'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x20); + $thisfile_id3v2['exthead']['flags']['restrictions'] = (bool) ($thisfile_id3v2['exthead']['flag_raw'] & 0x10); + + if ($thisfile_id3v2['exthead']['flags']['update']) { + $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 0 + $extended_header_offset += 1; + } + + if ($thisfile_id3v2['exthead']['flags']['crc']) { + $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 5 + $extended_header_offset += 1; + $thisfile_id3v2['exthead']['flag_data']['crc'] = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, $ext_header_chunk_length), true, false); + $extended_header_offset += $ext_header_chunk_length; + } + + if ($thisfile_id3v2['exthead']['flags']['restrictions']) { + $ext_header_chunk_length = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); // should be 1 + $extended_header_offset += 1; + + // %ppqrrstt + $restrictions_raw = getid3_lib::BigEndian2Int(substr($framedata, $extended_header_offset, 1)); + $extended_header_offset += 1; + $thisfile_id3v2['exthead']['flags']['restrictions']['tagsize'] = ($restrictions_raw & 0xC0) >> 6; // p - Tag size restrictions + $thisfile_id3v2['exthead']['flags']['restrictions']['textenc'] = ($restrictions_raw & 0x20) >> 5; // q - Text encoding restrictions + $thisfile_id3v2['exthead']['flags']['restrictions']['textsize'] = ($restrictions_raw & 0x18) >> 3; // r - Text fields size restrictions + $thisfile_id3v2['exthead']['flags']['restrictions']['imgenc'] = ($restrictions_raw & 0x04) >> 2; // s - Image encoding restrictions + $thisfile_id3v2['exthead']['flags']['restrictions']['imgsize'] = ($restrictions_raw & 0x03) >> 0; // t - Image size restrictions + + $thisfile_id3v2['exthead']['flags']['restrictions_text']['tagsize'] = $this->LookupExtendedHeaderRestrictionsTagSizeLimits($thisfile_id3v2['exthead']['flags']['restrictions']['tagsize']); + $thisfile_id3v2['exthead']['flags']['restrictions_text']['textenc'] = $this->LookupExtendedHeaderRestrictionsTextEncodings($thisfile_id3v2['exthead']['flags']['restrictions']['textenc']); + $thisfile_id3v2['exthead']['flags']['restrictions_text']['textsize'] = $this->LookupExtendedHeaderRestrictionsTextFieldSize($thisfile_id3v2['exthead']['flags']['restrictions']['textsize']); + $thisfile_id3v2['exthead']['flags']['restrictions_text']['imgenc'] = $this->LookupExtendedHeaderRestrictionsImageEncoding($thisfile_id3v2['exthead']['flags']['restrictions']['imgenc']); + $thisfile_id3v2['exthead']['flags']['restrictions_text']['imgsize'] = $this->LookupExtendedHeaderRestrictionsImageSizeSize($thisfile_id3v2['exthead']['flags']['restrictions']['imgsize']); + } + + if ($thisfile_id3v2['exthead']['length'] != $extended_header_offset) { + $this->warning('ID3v2.4 extended header length mismatch (expecting '.intval($thisfile_id3v2['exthead']['length']).', found '.intval($extended_header_offset).')'); + } + } + + $framedataoffset += $extended_header_offset; + $framedata = substr($framedata, $extended_header_offset); + } // end extended header + + + while (isset($framedata) && (strlen($framedata) > 0)) { // cycle through until no more frame data is left to parse + if (strlen($framedata) <= $this->ID3v2HeaderLength($id3v2_majorversion)) { + // insufficient room left in ID3v2 header for actual data - must be padding + $thisfile_id3v2['padding']['start'] = $framedataoffset; + $thisfile_id3v2['padding']['length'] = strlen($framedata); + $thisfile_id3v2['padding']['valid'] = true; + for ($i = 0; $i < $thisfile_id3v2['padding']['length']; $i++) { + if ($framedata{$i} != "\x00") { + $thisfile_id3v2['padding']['valid'] = false; + $thisfile_id3v2['padding']['errorpos'] = $thisfile_id3v2['padding']['start'] + $i; + $this->warning('Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)'); + break; + } + } + break; // skip rest of ID3v2 header + } + if ($id3v2_majorversion == 2) { + // Frame ID $xx xx xx (three characters) + // Size $xx xx xx (24-bit integer) + // Flags $xx xx + + $frame_header = substr($framedata, 0, 6); // take next 6 bytes for header + $framedata = substr($framedata, 6); // and leave the rest in $framedata + $frame_name = substr($frame_header, 0, 3); + $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 3, 3), 0); + $frame_flags = 0; // not used for anything in ID3v2.2, just set to avoid E_NOTICEs + + } elseif ($id3v2_majorversion > 2) { + + // Frame ID $xx xx xx xx (four characters) + // Size $xx xx xx xx (32-bit integer in v2.3, 28-bit synchsafe in v2.4+) + // Flags $xx xx + + $frame_header = substr($framedata, 0, 10); // take next 10 bytes for header + $framedata = substr($framedata, 10); // and leave the rest in $framedata + + $frame_name = substr($frame_header, 0, 4); + if ($id3v2_majorversion == 3) { + $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0); // 32-bit integer + } else { // ID3v2.4+ + $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 1); // 32-bit synchsafe integer (28-bit value) + } + + if ($frame_size < (strlen($framedata) + 4)) { + $nextFrameID = substr($framedata, $frame_size, 4); + if ($this->IsValidID3v2FrameName($nextFrameID, $id3v2_majorversion)) { + // next frame is OK + } elseif (($frame_name == "\x00".'MP3') || ($frame_name == "\x00\x00".'MP') || ($frame_name == ' MP3') || ($frame_name == 'MP3e')) { + // MP3ext known broken frames - "ok" for the purposes of this test + } elseif (($id3v2_majorversion == 4) && ($this->IsValidID3v2FrameName(substr($framedata, getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0), 4), 3))) { + $this->warning('ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of (Helium2; iTunes) are known culprits of this. Tag has been parsed as ID3v2.3'); + $id3v2_majorversion = 3; + $frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0); // 32-bit integer + } + } + + + $frame_flags = getid3_lib::BigEndian2Int(substr($frame_header, 8, 2)); + } + + if ((($id3v2_majorversion == 2) && ($frame_name == "\x00\x00\x00")) || ($frame_name == "\x00\x00\x00\x00")) { + // padding encountered + + $thisfile_id3v2['padding']['start'] = $framedataoffset; + $thisfile_id3v2['padding']['length'] = strlen($frame_header) + strlen($framedata); + $thisfile_id3v2['padding']['valid'] = true; + + $len = strlen($framedata); + for ($i = 0; $i < $len; $i++) { + if ($framedata{$i} != "\x00") { + $thisfile_id3v2['padding']['valid'] = false; + $thisfile_id3v2['padding']['errorpos'] = $thisfile_id3v2['padding']['start'] + $i; + $this->warning('Invalid ID3v2 padding found at offset '.$thisfile_id3v2['padding']['errorpos'].' (the remaining '.($thisfile_id3v2['padding']['length'] - $i).' bytes are considered invalid)'); + break; + } + } + break; // skip rest of ID3v2 header + } + + if ($iTunesBrokenFrameNameFixed = self::ID3v22iTunesBrokenFrameName($frame_name)) { + $this->warning('error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by iTunes (versions "X v2.0.3", "v3.0.1", "v7.0.0.70" are known-guilty, probably others too)]. Translated frame name from "'.str_replace("\x00", ' ', $frame_name).'" to "'.$iTunesBrokenFrameNameFixed.'" for parsing.'); + $frame_name = $iTunesBrokenFrameNameFixed; + } + if (($frame_size <= strlen($framedata)) && ($this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion))) { + + unset($parsedFrame); + $parsedFrame['frame_name'] = $frame_name; + $parsedFrame['frame_flags_raw'] = $frame_flags; + $parsedFrame['data'] = substr($framedata, 0, $frame_size); + $parsedFrame['datalength'] = getid3_lib::CastAsInt($frame_size); + $parsedFrame['dataoffset'] = $framedataoffset; + + $this->ParseID3v2Frame($parsedFrame); + $thisfile_id3v2[$frame_name][] = $parsedFrame; + + $framedata = substr($framedata, $frame_size); + + } else { // invalid frame length or FrameID + + if ($frame_size <= strlen($framedata)) { + + if ($this->IsValidID3v2FrameName(substr($framedata, $frame_size, 4), $id3v2_majorversion)) { + + // next frame is valid, just skip the current frame + $framedata = substr($framedata, $frame_size); + $this->warning('Next ID3v2 frame is valid, skipping current frame.'); + + } else { + + // next frame is invalid too, abort processing + //unset($framedata); + $framedata = null; + $this->error('Next ID3v2 frame is also invalid, aborting processing.'); + + } + + } elseif ($frame_size == strlen($framedata)) { + + // this is the last frame, just skip + $this->warning('This was the last ID3v2 frame.'); + + } else { + + // next frame is invalid too, abort processing + //unset($framedata); + $framedata = null; + $this->warning('Invalid ID3v2 frame size, aborting.'); + + } + if (!$this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion)) { + + switch ($frame_name) { + case "\x00\x00".'MP': + case "\x00".'MP3': + case ' MP3': + case 'MP3e': + case "\x00".'MP': + case ' MP': + case 'MP3': + $this->warning('error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))). [Note: this particular error has been known to happen with tags edited by "MP3ext (www.mutschler.de/mp3ext/)"]'); + break; + + default: + $this->warning('error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: !IsValidID3v2FrameName("'.str_replace("\x00", ' ', $frame_name).'", '.$id3v2_majorversion.'))).'); + break; + } + + } elseif (!isset($framedata) || ($frame_size > strlen($framedata))) { + + $this->error('error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag). (ERROR: $frame_size ('.$frame_size.') > strlen($framedata) ('.(isset($framedata) ? strlen($framedata) : 'null').')).'); + + } else { + + $this->error('error parsing "'.$frame_name.'" ('.$framedataoffset.' bytes into the ID3v2.'.$id3v2_majorversion.' tag).'); + + } + + } + $framedataoffset += ($frame_size + $this->ID3v2HeaderLength($id3v2_majorversion)); + + } + + } + + + // Footer + + // The footer is a copy of the header, but with a different identifier. + // ID3v2 identifier "3DI" + // ID3v2 version $04 00 + // ID3v2 flags %abcd0000 + // ID3v2 size 4 * %0xxxxxxx + + if (isset($thisfile_id3v2_flags['isfooter']) && $thisfile_id3v2_flags['isfooter']) { + $footer = $this->fread(10); + if (substr($footer, 0, 3) == '3DI') { + $thisfile_id3v2['footer'] = true; + $thisfile_id3v2['majorversion_footer'] = ord($footer{3}); + $thisfile_id3v2['minorversion_footer'] = ord($footer{4}); + } + if ($thisfile_id3v2['majorversion_footer'] <= 4) { + $id3_flags = ord(substr($footer{5})); + $thisfile_id3v2_flags['unsynch_footer'] = (bool) ($id3_flags & 0x80); + $thisfile_id3v2_flags['extfoot_footer'] = (bool) ($id3_flags & 0x40); + $thisfile_id3v2_flags['experim_footer'] = (bool) ($id3_flags & 0x20); + $thisfile_id3v2_flags['isfooter_footer'] = (bool) ($id3_flags & 0x10); + + $thisfile_id3v2['footerlength'] = getid3_lib::BigEndian2Int(substr($footer, 6, 4), 1); + } + } // end footer + + if (isset($thisfile_id3v2['comments']['genre'])) { + $genres = array(); + foreach ($thisfile_id3v2['comments']['genre'] as $key => $value) { + foreach ($this->ParseID3v2GenreString($value) as $genre) { + $genres[] = $genre; + } + } + $thisfile_id3v2['comments']['genre'] = array_unique($genres); + unset($key, $value, $genres, $genre); + } + + if (isset($thisfile_id3v2['comments']['track'])) { + foreach ($thisfile_id3v2['comments']['track'] as $key => $value) { + if (strstr($value, '/')) { + list($thisfile_id3v2['comments']['tracknum'][$key], $thisfile_id3v2['comments']['totaltracks'][$key]) = explode('/', $thisfile_id3v2['comments']['track'][$key]); + } + } + } + + if (!isset($thisfile_id3v2['comments']['year']) && !empty($thisfile_id3v2['comments']['recording_time'][0]) && preg_match('#^([0-9]{4})#', trim($thisfile_id3v2['comments']['recording_time'][0]), $matches)) { + $thisfile_id3v2['comments']['year'] = array($matches[1]); + } + + + if (!empty($thisfile_id3v2['TXXX'])) { + // MediaMonkey does this, maybe others: write a blank RGAD frame, but put replay-gain adjustment values in TXXX frames + foreach ($thisfile_id3v2['TXXX'] as $txxx_array) { + switch ($txxx_array['description']) { + case 'replaygain_track_gain': + if (empty($info['replay_gain']['track']['adjustment']) && !empty($txxx_array['data'])) { + $info['replay_gain']['track']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data']))); + } + break; + case 'replaygain_track_peak': + if (empty($info['replay_gain']['track']['peak']) && !empty($txxx_array['data'])) { + $info['replay_gain']['track']['peak'] = floatval($txxx_array['data']); + } + break; + case 'replaygain_album_gain': + if (empty($info['replay_gain']['album']['adjustment']) && !empty($txxx_array['data'])) { + $info['replay_gain']['album']['adjustment'] = floatval(trim(str_replace('dB', '', $txxx_array['data']))); + } + break; + } + } + } + + + // Set avdataoffset + $info['avdataoffset'] = $thisfile_id3v2['headerlength']; + if (isset($thisfile_id3v2['footer'])) { + $info['avdataoffset'] += 10; + } + + return true; + } + + + public function ParseID3v2GenreString($genrestring) { + // Parse genres into arrays of genreName and genreID + // ID3v2.2.x, ID3v2.3.x: '(21)' or '(4)Eurodisco' or '(51)(39)' or '(55)((I think...)' + // ID3v2.4.x: '21' $00 'Eurodisco' $00 + $clean_genres = array(); + + // hack-fixes for some badly-written ID3v2.3 taggers, while trying not to break correctly-written tags + if (($this->getid3->info['id3v2']['majorversion'] == 3) && !preg_match('#[\x00]#', $genrestring)) { + // note: MusicBrainz Picard incorrectly stores plaintext genres separated by "/" when writing in ID3v2.3 mode, hack-fix here: + // replace / with NULL, then replace back the two ID3v1 genres that legitimately have "/" as part of the single genre name + if (preg_match('#/#', $genrestring)) { + $genrestring = str_replace('/', "\x00", $genrestring); + $genrestring = str_replace('Pop'."\x00".'Funk', 'Pop/Funk', $genrestring); + $genrestring = str_replace('Rock'."\x00".'Rock', 'Folk/Rock', $genrestring); + } + + // some other taggers separate multiple genres with semicolon, e.g. "Heavy Metal;Thrash Metal;Metal" + if (preg_match('#;#', $genrestring)) { + $genrestring = str_replace(';', "\x00", $genrestring); + } + } + + + if (strpos($genrestring, "\x00") === false) { + $genrestring = preg_replace('#\(([0-9]{1,3})\)#', '$1'."\x00", $genrestring); + } + + $genre_elements = explode("\x00", $genrestring); + foreach ($genre_elements as $element) { + $element = trim($element); + if ($element) { + if (preg_match('#^[0-9]{1,3}#', $element)) { + $clean_genres[] = getid3_id3v1::LookupGenreName($element); + } else { + $clean_genres[] = str_replace('((', '(', $element); + } + } + } + return $clean_genres; + } + + + public function ParseID3v2Frame(&$parsedFrame) { + + // shortcuts + $info = &$this->getid3->info; + $id3v2_majorversion = $info['id3v2']['majorversion']; + + $parsedFrame['framenamelong'] = $this->FrameNameLongLookup($parsedFrame['frame_name']); + if (empty($parsedFrame['framenamelong'])) { + unset($parsedFrame['framenamelong']); + } + $parsedFrame['framenameshort'] = $this->FrameNameShortLookup($parsedFrame['frame_name']); + if (empty($parsedFrame['framenameshort'])) { + unset($parsedFrame['framenameshort']); + } + + if ($id3v2_majorversion >= 3) { // frame flags are not part of the ID3v2.2 standard + if ($id3v2_majorversion == 3) { + // Frame Header Flags + // %abc00000 %ijk00000 + $parsedFrame['flags']['TagAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x8000); // a - Tag alter preservation + $parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000); // b - File alter preservation + $parsedFrame['flags']['ReadOnly'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000); // c - Read only + $parsedFrame['flags']['compression'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0080); // i - Compression + $parsedFrame['flags']['Encryption'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0040); // j - Encryption + $parsedFrame['flags']['GroupingIdentity'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0020); // k - Grouping identity + + } elseif ($id3v2_majorversion == 4) { + // Frame Header Flags + // %0abc0000 %0h00kmnp + $parsedFrame['flags']['TagAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000); // a - Tag alter preservation + $parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000); // b - File alter preservation + $parsedFrame['flags']['ReadOnly'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x1000); // c - Read only + $parsedFrame['flags']['GroupingIdentity'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0040); // h - Grouping identity + $parsedFrame['flags']['compression'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0008); // k - Compression + $parsedFrame['flags']['Encryption'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0004); // m - Encryption + $parsedFrame['flags']['Unsynchronisation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0002); // n - Unsynchronisation + $parsedFrame['flags']['DataLengthIndicator'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x0001); // p - Data length indicator + + // Frame-level de-unsynchronisation - ID3v2.4 + if ($parsedFrame['flags']['Unsynchronisation']) { + $parsedFrame['data'] = $this->DeUnsynchronise($parsedFrame['data']); + } + + if ($parsedFrame['flags']['DataLengthIndicator']) { + $parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1); + $parsedFrame['data'] = substr($parsedFrame['data'], 4); + } + } + + // Frame-level de-compression + if ($parsedFrame['flags']['compression']) { + $parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4)); + if (!function_exists('gzuncompress')) { + $this->warning('gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"'); + } else { + if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) { + //if ($decompresseddata = @gzuncompress($parsedFrame['data'])) { + $parsedFrame['data'] = $decompresseddata; + unset($decompresseddata); + } else { + $this->warning('gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"'); + } + } + } + } + + if (!empty($parsedFrame['flags']['DataLengthIndicator'])) { + if ($parsedFrame['data_length_indicator'] != strlen($parsedFrame['data'])) { + $this->warning('ID3v2 frame "'.$parsedFrame['frame_name'].'" should be '.$parsedFrame['data_length_indicator'].' bytes long according to DataLengthIndicator, but found '.strlen($parsedFrame['data']).' bytes of data'); + } + } + + if (isset($parsedFrame['datalength']) && ($parsedFrame['datalength'] == 0)) { + + $warning = 'Frame "'.$parsedFrame['frame_name'].'" at offset '.$parsedFrame['dataoffset'].' has no data portion'; + switch ($parsedFrame['frame_name']) { + case 'WCOM': + $warning .= ' (this is known to happen with files tagged by RioPort)'; + break; + + default: + break; + } + $this->warning($warning); + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'UFID')) || // 4.1 UFID Unique file identifier + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'UFI'))) { // 4.1 UFI Unique file identifier + // There may be more than one 'UFID' frame in a tag, + // but only one with the same 'Owner identifier'. + //
      + // Owner identifier $00 + // Identifier + $exploded = explode("\x00", $parsedFrame['data'], 2); + $parsedFrame['ownerid'] = (isset($exploded[0]) ? $exploded[0] : ''); + $parsedFrame['data'] = (isset($exploded[1]) ? $exploded[1] : ''); + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'TXXX')) || // 4.2.2 TXXX User defined text information frame + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'TXX'))) { // 4.2.2 TXX User defined text information frame + // There may be more than one 'TXXX' frame in each tag, + // but only one with the same description. + //
      + // Text encoding $xx + // Description $00 (00) + // Value + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['description'] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $frame_description)); + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); + if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); + } else { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = trim(getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data'])); + } + } + //unset($parsedFrame['data']); do not unset, may be needed elsewhere, e.g. for replaygain + + + } elseif ($parsedFrame['frame_name']{0} == 'T') { // 4.2. T??[?] Text information frame + // There may only be one text information frame of its kind in an tag. + //
      + // Text encoding $xx + // Information + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + } + + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + // ID3v2.3 specs say that TPE1 (and others) can contain multiple artist values separated with / + // This of course breaks when an artist name contains slash character, e.g. "AC/DC" + // MP3tag (maybe others) implement alternative system where multiple artists are null-separated, which makes more sense + // getID3 will split null-separated artists into multiple artists and leave slash-separated ones to the user + switch ($parsedFrame['encoding']) { + case 'UTF-16': + case 'UTF-16BE': + case 'UTF-16LE': + $wordsize = 2; + break; + case 'ISO-8859-1': + case 'UTF-8': + default: + $wordsize = 1; + break; + } + $Txxx_elements = array(); + $Txxx_elements_start_offset = 0; + for ($i = 0; $i < strlen($parsedFrame['data']); $i += $wordsize) { + if (substr($parsedFrame['data'], $i, $wordsize) == str_repeat("\x00", $wordsize)) { + $Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset); + $Txxx_elements_start_offset = $i + $wordsize; + } + } + $Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset); + foreach ($Txxx_elements as $Txxx_element) { + $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $Txxx_element); + if (!empty($string)) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string; + } + } + unset($string, $wordsize, $i, $Txxx_elements, $Txxx_element, $Txxx_elements_start_offset); + } + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'WXXX')) || // 4.3.2 WXXX User defined URL link frame + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'WXX'))) { // 4.3.2 WXX User defined URL link frame + // There may be more than one 'WXXX' frame in each tag, + // but only one with the same description + //
      + // Text encoding $xx + // Description $00 (00) + // URL + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); + + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + if ($frame_terminatorpos) { + // there are null bytes after the data - this is not according to spec + // only use data up to first null byte + $frame_urldata = (string) substr($parsedFrame['data'], 0, $frame_terminatorpos); + } else { + // no null bytes following data, just use all data + $frame_urldata = (string) $parsedFrame['data']; + } + + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['url'] = $frame_urldata; + $parsedFrame['description'] = $frame_description; + if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['url']); + } + unset($parsedFrame['data']); + + + } elseif ($parsedFrame['frame_name']{0} == 'W') { // 4.3. W??? URL link frames + // There may only be one URL link frame of its kind in a tag, + // except when stated otherwise in the frame description + //
      + // URL + + $parsedFrame['url'] = trim($parsedFrame['data']); + if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['url']; + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion == 3) && ($parsedFrame['frame_name'] == 'IPLS')) || // 4.4 IPLS Involved people list (ID3v2.3 only) + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'IPL'))) { // 4.4 IPL Involved people list (ID3v2.2 only) + // http://id3.org/id3v2.3.0#sec4.4 + // There may only be one 'IPL' frame in each tag + //
      + // Text encoding $xx + // People list strings + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + } + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($parsedFrame['encodingid']); + $parsedFrame['data_raw'] = (string) substr($parsedFrame['data'], $frame_offset); + + // http://www.getid3.org/phpBB3/viewtopic.php?t=1369 + // "this tag typically contains null terminated strings, which are associated in pairs" + // "there are users that use the tag incorrectly" + $IPLS_parts = array(); + if (strpos($parsedFrame['data_raw'], "\x00") !== false) { + $IPLS_parts_unsorted = array(); + if (((strlen($parsedFrame['data_raw']) % 2) == 0) && ((substr($parsedFrame['data_raw'], 0, 2) == "\xFF\xFE") || (substr($parsedFrame['data_raw'], 0, 2) == "\xFE\xFF"))) { + // UTF-16, be careful looking for null bytes since most 2-byte characters may contain one; you need to find twin null bytes, and on even padding + $thisILPS = ''; + for ($i = 0; $i < strlen($parsedFrame['data_raw']); $i += 2) { + $twobytes = substr($parsedFrame['data_raw'], $i, 2); + if ($twobytes === "\x00\x00") { + $IPLS_parts_unsorted[] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $thisILPS); + $thisILPS = ''; + } else { + $thisILPS .= $twobytes; + } + } + if (strlen($thisILPS) > 2) { // 2-byte BOM + $IPLS_parts_unsorted[] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $thisILPS); + } + } else { + // ISO-8859-1 or UTF-8 or other single-byte-null character set + $IPLS_parts_unsorted = explode("\x00", $parsedFrame['data_raw']); + } + if (count($IPLS_parts_unsorted) == 1) { + // just a list of names, e.g. "Dino Baptiste, Jimmy Copley, John Gordon, Bernie Marsden, Sharon Watson" + foreach ($IPLS_parts_unsorted as $key => $value) { + $IPLS_parts_sorted = preg_split('#[;,\\r\\n\\t]#', $value); + $position = ''; + foreach ($IPLS_parts_sorted as $person) { + $IPLS_parts[] = array('position'=>$position, 'person'=>$person); + } + } + } elseif ((count($IPLS_parts_unsorted) % 2) == 0) { + $position = ''; + $person = ''; + foreach ($IPLS_parts_unsorted as $key => $value) { + if (($key % 2) == 0) { + $position = $value; + } else { + $person = $value; + $IPLS_parts[] = array('position'=>$position, 'person'=>$person); + $position = ''; + $person = ''; + } + } + } else { + foreach ($IPLS_parts_unsorted as $key => $value) { + $IPLS_parts[] = array($value); + } + } + + } else { + $IPLS_parts = preg_split('#[;,\\r\\n\\t]#', $parsedFrame['data_raw']); + } + $parsedFrame['data'] = $IPLS_parts; + + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data']; + } + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'MCDI')) || // 4.4 MCDI Music CD identifier + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'MCI'))) { // 4.5 MCI Music CD identifier + // There may only be one 'MCDI' frame in each tag + //
      + // CD TOC + + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $parsedFrame['data']; + } + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'ETCO')) || // 4.5 ETCO Event timing codes + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'ETC'))) { // 4.6 ETC Event timing codes + // There may only be one 'ETCO' frame in each tag + //
      + // Time stamp format $xx + // Where time stamp format is: + // $01 (32-bit value) MPEG frames from beginning of file + // $02 (32-bit value) milliseconds from beginning of file + // Followed by a list of key events in the following format: + // Type of event $xx + // Time stamp $xx (xx ...) + // The 'Time stamp' is set to zero if directly at the beginning of the sound + // or after the previous event. All events MUST be sorted in chronological order. + + $frame_offset = 0; + $parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + + while ($frame_offset < strlen($parsedFrame['data'])) { + $parsedFrame['typeid'] = substr($parsedFrame['data'], $frame_offset++, 1); + $parsedFrame['type'] = $this->ETCOEventLookup($parsedFrame['typeid']); + $parsedFrame['timestamp'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'MLLT')) || // 4.6 MLLT MPEG location lookup table + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'MLL'))) { // 4.7 MLL MPEG location lookup table + // There may only be one 'MLLT' frame in each tag + //
      + // MPEG frames between reference $xx xx + // Bytes between reference $xx xx xx + // Milliseconds between reference $xx xx xx + // Bits for bytes deviation $xx + // Bits for milliseconds dev. $xx + // Then for every reference the following data is included; + // Deviation in bytes %xxx.... + // Deviation in milliseconds %xxx.... + + $frame_offset = 0; + $parsedFrame['framesbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 2)); + $parsedFrame['bytesbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 2, 3)); + $parsedFrame['msbetweenreferences'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 5, 3)); + $parsedFrame['bitsforbytesdeviation'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 8, 1)); + $parsedFrame['bitsformsdeviation'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 9, 1)); + $parsedFrame['data'] = substr($parsedFrame['data'], 10); + while ($frame_offset < strlen($parsedFrame['data'])) { + $deviationbitstream .= getid3_lib::BigEndian2Bin(substr($parsedFrame['data'], $frame_offset++, 1)); + } + $reference_counter = 0; + while (strlen($deviationbitstream) > 0) { + $parsedFrame[$reference_counter]['bytedeviation'] = bindec(substr($deviationbitstream, 0, $parsedFrame['bitsforbytesdeviation'])); + $parsedFrame[$reference_counter]['msdeviation'] = bindec(substr($deviationbitstream, $parsedFrame['bitsforbytesdeviation'], $parsedFrame['bitsformsdeviation'])); + $deviationbitstream = substr($deviationbitstream, $parsedFrame['bitsforbytesdeviation'] + $parsedFrame['bitsformsdeviation']); + $reference_counter++; + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'SYTC')) || // 4.7 SYTC Synchronised tempo codes + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'STC'))) { // 4.8 STC Synchronised tempo codes + // There may only be one 'SYTC' frame in each tag + //
      + // Time stamp format $xx + // Tempo data + // Where time stamp format is: + // $01 (32-bit value) MPEG frames from beginning of file + // $02 (32-bit value) milliseconds from beginning of file + + $frame_offset = 0; + $parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $timestamp_counter = 0; + while ($frame_offset < strlen($parsedFrame['data'])) { + $parsedFrame[$timestamp_counter]['tempo'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + if ($parsedFrame[$timestamp_counter]['tempo'] == 255) { + $parsedFrame[$timestamp_counter]['tempo'] += ord(substr($parsedFrame['data'], $frame_offset++, 1)); + } + $parsedFrame[$timestamp_counter]['timestamp'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $timestamp_counter++; + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'USLT')) || // 4.8 USLT Unsynchronised lyric/text transcription + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'ULT'))) { // 4.9 ULT Unsynchronised lyric/text transcription + // There may be more than one 'Unsynchronised lyrics/text transcription' frame + // in each tag, but only one with the same language and content descriptor. + //
      + // Text encoding $xx + // Language $xx xx xx + // Content descriptor $00 (00) + // Lyrics/text + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_language = substr($parsedFrame['data'], $frame_offset, 3); + $frame_offset += 3; + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); + + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['language'] = $frame_language; + $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); + $parsedFrame['description'] = $frame_description; + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'SYLT')) || // 4.9 SYLT Synchronised lyric/text + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'SLT'))) { // 4.10 SLT Synchronised lyric/text + // There may be more than one 'SYLT' frame in each tag, + // but only one with the same language and content descriptor. + //
      + // Text encoding $xx + // Language $xx xx xx + // Time stamp format $xx + // $01 (32-bit value) MPEG frames from beginning of file + // $02 (32-bit value) milliseconds from beginning of file + // Content type $xx + // Content descriptor $00 (00) + // Terminated text to be synced (typically a syllable) + // Sync identifier (terminator to above string) $00 (00) + // Time stamp $xx (xx ...) + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_language = substr($parsedFrame['data'], $frame_offset, 3); + $frame_offset += 3; + $parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['contenttypeid'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['contenttype'] = $this->SYTLContentTypeLookup($parsedFrame['contenttypeid']); + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['language'] = $frame_language; + $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); + + $timestampindex = 0; + $frame_remainingdata = substr($parsedFrame['data'], $frame_offset); + while (strlen($frame_remainingdata)) { + $frame_offset = 0; + $frame_terminatorpos = strpos($frame_remainingdata, $frame_textencoding_terminator); + if ($frame_terminatorpos === false) { + $frame_remainingdata = ''; + } else { + if (ord(substr($frame_remainingdata, $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $parsedFrame['lyrics'][$timestampindex]['data'] = substr($frame_remainingdata, $frame_offset, $frame_terminatorpos - $frame_offset); + + $frame_remainingdata = substr($frame_remainingdata, $frame_terminatorpos + strlen($frame_textencoding_terminator)); + if (($timestampindex == 0) && (ord($frame_remainingdata{0}) != 0)) { + // timestamp probably omitted for first data item + } else { + $parsedFrame['lyrics'][$timestampindex]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 4)); + $frame_remainingdata = substr($frame_remainingdata, 4); + } + $timestampindex++; + } + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'COMM')) || // 4.10 COMM Comments + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'COM'))) { // 4.11 COM Comments + // There may be more than one comment frame in each tag, + // but only one with the same language and content descriptor. + //
      + // Text encoding $xx + // Language $xx xx xx + // Short content descrip. $00 (00) + // The actual text + + if (strlen($parsedFrame['data']) < 5) { + + $this->warning('Invalid data (too short) for "'.$parsedFrame['frame_name'].'" frame at offset '.$parsedFrame['dataoffset']); + + } else { + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_language = substr($parsedFrame['data'], $frame_offset, 3); + $frame_offset += 3; + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $frame_text = (string) substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); + + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['language'] = $frame_language; + $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); + $parsedFrame['description'] = $frame_description; + $parsedFrame['data'] = $frame_text; + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $commentkey = ($parsedFrame['description'] ? $parsedFrame['description'] : (!empty($info['id3v2']['comments'][$parsedFrame['framenameshort']]) ? count($info['id3v2']['comments'][$parsedFrame['framenameshort']]) : 0)); + if (!isset($info['id3v2']['comments'][$parsedFrame['framenameshort']]) || !array_key_exists($commentkey, $info['id3v2']['comments'][$parsedFrame['framenameshort']])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][$commentkey] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); + } else { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); + } + } + + } + + } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'RVA2')) { // 4.11 RVA2 Relative volume adjustment (2) (ID3v2.4+ only) + // There may be more than one 'RVA2' frame in each tag, + // but only one with the same identification string + //
      + // Identification $00 + // The 'identification' string is used to identify the situation and/or + // device where this adjustment should apply. The following is then + // repeated for every channel: + // Type of channel $xx + // Volume adjustment $xx xx + // Bits representing peak $xx + // Peak volume $xx (xx ...) + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00"); + $frame_idstring = substr($parsedFrame['data'], 0, $frame_terminatorpos); + if (ord($frame_idstring) === 0) { + $frame_idstring = ''; + } + $frame_remainingdata = substr($parsedFrame['data'], $frame_terminatorpos + strlen("\x00")); + $parsedFrame['description'] = $frame_idstring; + $RVA2channelcounter = 0; + while (strlen($frame_remainingdata) >= 5) { + $frame_offset = 0; + $frame_channeltypeid = ord(substr($frame_remainingdata, $frame_offset++, 1)); + $parsedFrame[$RVA2channelcounter]['channeltypeid'] = $frame_channeltypeid; + $parsedFrame[$RVA2channelcounter]['channeltype'] = $this->RVA2ChannelTypeLookup($frame_channeltypeid); + $parsedFrame[$RVA2channelcounter]['volumeadjust'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, 2), false, true); // 16-bit signed + $frame_offset += 2; + $parsedFrame[$RVA2channelcounter]['bitspeakvolume'] = ord(substr($frame_remainingdata, $frame_offset++, 1)); + if (($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] < 1) || ($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] > 4)) { + $this->warning('ID3v2::RVA2 frame['.$RVA2channelcounter.'] contains invalid '.$parsedFrame[$RVA2channelcounter]['bitspeakvolume'].'-byte bits-representing-peak value'); + break; + } + $frame_bytespeakvolume = ceil($parsedFrame[$RVA2channelcounter]['bitspeakvolume'] / 8); + $parsedFrame[$RVA2channelcounter]['peakvolume'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, $frame_offset, $frame_bytespeakvolume)); + $frame_remainingdata = substr($frame_remainingdata, $frame_offset + $frame_bytespeakvolume); + $RVA2channelcounter++; + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion == 3) && ($parsedFrame['frame_name'] == 'RVAD')) || // 4.12 RVAD Relative volume adjustment (ID3v2.3 only) + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'RVA'))) { // 4.12 RVA Relative volume adjustment (ID3v2.2 only) + // There may only be one 'RVA' frame in each tag + //
      + // ID3v2.2 => Increment/decrement %000000ba + // ID3v2.3 => Increment/decrement %00fedcba + // Bits used for volume descr. $xx + // Relative volume change, right $xx xx (xx ...) // a + // Relative volume change, left $xx xx (xx ...) // b + // Peak volume right $xx xx (xx ...) + // Peak volume left $xx xx (xx ...) + // ID3v2.3 only, optional (not present in ID3v2.2): + // Relative volume change, right back $xx xx (xx ...) // c + // Relative volume change, left back $xx xx (xx ...) // d + // Peak volume right back $xx xx (xx ...) + // Peak volume left back $xx xx (xx ...) + // ID3v2.3 only, optional (not present in ID3v2.2): + // Relative volume change, center $xx xx (xx ...) // e + // Peak volume center $xx xx (xx ...) + // ID3v2.3 only, optional (not present in ID3v2.2): + // Relative volume change, bass $xx xx (xx ...) // f + // Peak volume bass $xx xx (xx ...) + + $frame_offset = 0; + $frame_incrdecrflags = getid3_lib::BigEndian2Bin(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['incdec']['right'] = (bool) substr($frame_incrdecrflags, 6, 1); + $parsedFrame['incdec']['left'] = (bool) substr($frame_incrdecrflags, 7, 1); + $parsedFrame['bitsvolume'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_bytesvolume = ceil($parsedFrame['bitsvolume'] / 8); + $parsedFrame['volumechange']['right'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['right'] === false) { + $parsedFrame['volumechange']['right'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['volumechange']['left'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['left'] === false) { + $parsedFrame['volumechange']['left'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['right'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['left'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + if ($id3v2_majorversion == 3) { + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_offset); + if (strlen($parsedFrame['data']) > 0) { + $parsedFrame['incdec']['rightrear'] = (bool) substr($frame_incrdecrflags, 4, 1); + $parsedFrame['incdec']['leftrear'] = (bool) substr($frame_incrdecrflags, 5, 1); + $parsedFrame['volumechange']['rightrear'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['rightrear'] === false) { + $parsedFrame['volumechange']['rightrear'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['volumechange']['leftrear'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['leftrear'] === false) { + $parsedFrame['volumechange']['leftrear'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['rightrear'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['leftrear'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + } + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_offset); + if (strlen($parsedFrame['data']) > 0) { + $parsedFrame['incdec']['center'] = (bool) substr($frame_incrdecrflags, 3, 1); + $parsedFrame['volumechange']['center'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['center'] === false) { + $parsedFrame['volumechange']['center'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['center'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + } + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_offset); + if (strlen($parsedFrame['data']) > 0) { + $parsedFrame['incdec']['bass'] = (bool) substr($frame_incrdecrflags, 2, 1); + $parsedFrame['volumechange']['bass'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + if ($parsedFrame['incdec']['bass'] === false) { + $parsedFrame['volumechange']['bass'] *= -1; + } + $frame_offset += $frame_bytesvolume; + $parsedFrame['peakvolume']['bass'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesvolume)); + $frame_offset += $frame_bytesvolume; + } + } + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'EQU2')) { // 4.12 EQU2 Equalisation (2) (ID3v2.4+ only) + // There may be more than one 'EQU2' frame in each tag, + // but only one with the same identification string + //
      + // Interpolation method $xx + // $00 Band + // $01 Linear + // Identification $00 + // The following is then repeated for every adjustment point + // Frequency $xx xx + // Volume adjustment $xx xx + + $frame_offset = 0; + $frame_interpolationmethod = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_idstring = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_idstring) === 0) { + $frame_idstring = ''; + } + $parsedFrame['description'] = $frame_idstring; + $frame_remainingdata = substr($parsedFrame['data'], $frame_terminatorpos + strlen("\x00")); + while (strlen($frame_remainingdata)) { + $frame_frequency = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 2)) / 2; + $parsedFrame['data'][$frame_frequency] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 2, 2), false, true); + $frame_remainingdata = substr($frame_remainingdata, 4); + } + $parsedFrame['interpolationmethod'] = $frame_interpolationmethod; + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion == 3) && ($parsedFrame['frame_name'] == 'EQUA')) || // 4.12 EQUA Equalisation (ID3v2.3 only) + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'EQU'))) { // 4.13 EQU Equalisation (ID3v2.2 only) + // There may only be one 'EQUA' frame in each tag + //
      + // Adjustment bits $xx + // This is followed by 2 bytes + ('adjustment bits' rounded up to the + // nearest byte) for every equalisation band in the following format, + // giving a frequency range of 0 - 32767Hz: + // Increment/decrement %x (MSB of the Frequency) + // Frequency (lower 15 bits) + // Adjustment $xx (xx ...) + + $frame_offset = 0; + $parsedFrame['adjustmentbits'] = substr($parsedFrame['data'], $frame_offset++, 1); + $frame_adjustmentbytes = ceil($parsedFrame['adjustmentbits'] / 8); + + $frame_remainingdata = (string) substr($parsedFrame['data'], $frame_offset); + while (strlen($frame_remainingdata) > 0) { + $frame_frequencystr = getid3_lib::BigEndian2Bin(substr($frame_remainingdata, 0, 2)); + $frame_incdec = (bool) substr($frame_frequencystr, 0, 1); + $frame_frequency = bindec(substr($frame_frequencystr, 1, 15)); + $parsedFrame[$frame_frequency]['incdec'] = $frame_incdec; + $parsedFrame[$frame_frequency]['adjustment'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 2, $frame_adjustmentbytes)); + if ($parsedFrame[$frame_frequency]['incdec'] === false) { + $parsedFrame[$frame_frequency]['adjustment'] *= -1; + } + $frame_remainingdata = substr($frame_remainingdata, 2 + $frame_adjustmentbytes); + } + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'RVRB')) || // 4.13 RVRB Reverb + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'REV'))) { // 4.14 REV Reverb + // There may only be one 'RVRB' frame in each tag. + //
      + // Reverb left (ms) $xx xx + // Reverb right (ms) $xx xx + // Reverb bounces, left $xx + // Reverb bounces, right $xx + // Reverb feedback, left to left $xx + // Reverb feedback, left to right $xx + // Reverb feedback, right to right $xx + // Reverb feedback, right to left $xx + // Premix left to right $xx + // Premix right to left $xx + + $frame_offset = 0; + $parsedFrame['left'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['right'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['bouncesL'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['bouncesR'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['feedbackLL'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['feedbackLR'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['feedbackRR'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['feedbackRL'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['premixLR'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['premixRL'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'APIC')) || // 4.14 APIC Attached picture + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'PIC'))) { // 4.15 PIC Attached picture + // There may be several pictures attached to one file, + // each in their individual 'APIC' frame, but only one + // with the same content descriptor + //
      + // Text encoding $xx + // ID3v2.3+ => MIME type $00 + // ID3v2.2 => Image format $xx xx xx + // Picture type $xx + // Description $00 (00) + // Picture data + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + + if ($id3v2_majorversion == 2 && strlen($parsedFrame['data']) > $frame_offset) { + $frame_imagetype = substr($parsedFrame['data'], $frame_offset, 3); + if (strtolower($frame_imagetype) == 'ima') { + // complete hack for mp3Rage (www.chaoticsoftware.com) that puts ID3v2.3-formatted + // MIME type instead of 3-char ID3v2.2-format image type (thanks xbhoffØpacbell*net) + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_mimetype) === 0) { + $frame_mimetype = ''; + } + $frame_imagetype = strtoupper(str_replace('image/', '', strtolower($frame_mimetype))); + if ($frame_imagetype == 'JPEG') { + $frame_imagetype = 'JPG'; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + } else { + $frame_offset += 3; + } + } + if ($id3v2_majorversion > 2 && strlen($parsedFrame['data']) > $frame_offset) { + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_mimetype) === 0) { + $frame_mimetype = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + } + + $frame_picturetype = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + + if ($frame_offset >= $parsedFrame['datalength']) { + $this->warning('data portion of APIC frame is missing at offset '.($parsedFrame['dataoffset'] + 8 + $frame_offset)); + } else { + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + if ($id3v2_majorversion == 2) { + $parsedFrame['imagetype'] = $frame_imagetype; + } else { + $parsedFrame['mime'] = $frame_mimetype; + } + $parsedFrame['picturetypeid'] = $frame_picturetype; + $parsedFrame['picturetype'] = $this->APICPictureTypeLookup($frame_picturetype); + $parsedFrame['description'] = $frame_description; + $parsedFrame['data'] = substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator)); + $parsedFrame['datalength'] = strlen($parsedFrame['data']); + + $parsedFrame['image_mime'] = ''; + $imageinfo = array(); + if ($imagechunkcheck = getid3_lib::GetDataImageSize($parsedFrame['data'], $imageinfo)) { + if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) { + $parsedFrame['image_mime'] = 'image/'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]); + if ($imagechunkcheck[0]) { + $parsedFrame['image_width'] = $imagechunkcheck[0]; + } + if ($imagechunkcheck[1]) { + $parsedFrame['image_height'] = $imagechunkcheck[1]; + } + } + } + + do { + if ($this->getid3->option_save_attachments === false) { + // skip entirely + unset($parsedFrame['data']); + break; + } + if ($this->getid3->option_save_attachments === true) { + // great +/* + } elseif (is_int($this->getid3->option_save_attachments)) { + if ($this->getid3->option_save_attachments < $parsedFrame['data_length']) { + // too big, skip + $this->warning('attachment at '.$frame_offset.' is too large to process inline ('.number_format($parsedFrame['data_length']).' bytes)'); + unset($parsedFrame['data']); + break; + } +*/ + } elseif (is_string($this->getid3->option_save_attachments)) { + $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR); + if (!is_dir($dir) || !getID3::is_writable($dir)) { + // cannot write, skip + $this->warning('attachment at '.$frame_offset.' cannot be saved to "'.$dir.'" (not writable)'); + unset($parsedFrame['data']); + break; + } + } + // if we get this far, must be OK + if (is_string($this->getid3->option_save_attachments)) { + $destination_filename = $dir.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$frame_offset; + if (!file_exists($destination_filename) || getID3::is_writable($destination_filename)) { + file_put_contents($destination_filename, $parsedFrame['data']); + } else { + $this->warning('attachment at '.$frame_offset.' cannot be saved to "'.$destination_filename.'" (not writable)'); + } + $parsedFrame['data_filename'] = $destination_filename; + unset($parsedFrame['data']); + } else { + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + if (!isset($info['id3v2']['comments']['picture'])) { + $info['id3v2']['comments']['picture'] = array(); + } + $comments_picture_data = array(); + foreach (array('data', 'image_mime', 'image_width', 'image_height', 'imagetype', 'picturetype', 'description', 'datalength') as $picture_key) { + if (isset($parsedFrame[$picture_key])) { + $comments_picture_data[$picture_key] = $parsedFrame[$picture_key]; + } + } + $info['id3v2']['comments']['picture'][] = $comments_picture_data; + unset($comments_picture_data); + } + } + } while (false); + } + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'GEOB')) || // 4.15 GEOB General encapsulated object + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'GEO'))) { // 4.16 GEO General encapsulated object + // There may be more than one 'GEOB' frame in each tag, + // but only one with the same content descriptor + //
      + // Text encoding $xx + // MIME type $00 + // Filename $00 (00) + // Content description $00 (00) + // Encapsulated object + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_mimetype) === 0) { + $frame_mimetype = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_filename = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_filename) === 0) { + $frame_filename = ''; + } + $frame_offset = $frame_terminatorpos + strlen($frame_textencoding_terminator); + + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $frame_offset = $frame_terminatorpos + strlen($frame_textencoding_terminator); + + $parsedFrame['objectdata'] = (string) substr($parsedFrame['data'], $frame_offset); + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['mime'] = $frame_mimetype; + $parsedFrame['filename'] = $frame_filename; + $parsedFrame['description'] = $frame_description; + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'PCNT')) || // 4.16 PCNT Play counter + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'CNT'))) { // 4.17 CNT Play counter + // There may only be one 'PCNT' frame in each tag. + // When the counter reaches all one's, one byte is inserted in + // front of the counter thus making the counter eight bits bigger + //
      + // Counter $xx xx xx xx (xx ...) + + $parsedFrame['data'] = getid3_lib::BigEndian2Int($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'POPM')) || // 4.17 POPM Popularimeter + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'POP'))) { // 4.18 POP Popularimeter + // There may be more than one 'POPM' frame in each tag, + // but only one with the same email address + //
      + // Email to user $00 + // Rating $xx + // Counter $xx xx xx xx (xx ...) + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_emailaddress = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_emailaddress) === 0) { + $frame_emailaddress = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + $frame_rating = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['counter'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset)); + $parsedFrame['email'] = $frame_emailaddress; + $parsedFrame['rating'] = $frame_rating; + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'RBUF')) || // 4.18 RBUF Recommended buffer size + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'BUF'))) { // 4.19 BUF Recommended buffer size + // There may only be one 'RBUF' frame in each tag + //
      + // Buffer size $xx xx xx + // Embedded info flag %0000000x + // Offset to next tag $xx xx xx xx + + $frame_offset = 0; + $parsedFrame['buffersize'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 3)); + $frame_offset += 3; + + $frame_embeddedinfoflags = getid3_lib::BigEndian2Bin(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['flags']['embededinfo'] = (bool) substr($frame_embeddedinfoflags, 7, 1); + $parsedFrame['nexttagoffset'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'CRM')) { // 4.20 Encrypted meta frame (ID3v2.2 only) + // There may be more than one 'CRM' frame in a tag, + // but only one with the same 'owner identifier' + //
      + // Owner identifier $00 (00) + // Content/explanation $00 (00) + // Encrypted datablock + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $parsedFrame['ownerid'] = $frame_ownerid; + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + $parsedFrame['description'] = $frame_description; + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'AENC')) || // 4.19 AENC Audio encryption + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'CRA'))) { // 4.21 CRA Audio encryption + // There may be more than one 'AENC' frames in a tag, + // but only one with the same 'Owner identifier' + //
      + // Owner identifier $00 + // Preview start $xx xx + // Preview length $xx xx + // Encryption info + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_ownerid) === 0) { + $frame_ownerid = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + $parsedFrame['ownerid'] = $frame_ownerid; + $parsedFrame['previewstart'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['previewlength'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['encryptioninfo'] = (string) substr($parsedFrame['data'], $frame_offset); + unset($parsedFrame['data']); + + + } elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'LINK')) || // 4.20 LINK Linked information + (($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'LNK'))) { // 4.22 LNK Linked information + // There may be more than one 'LINK' frame in a tag, + // but only one with the same contents + //
      + // ID3v2.3+ => Frame identifier $xx xx xx xx + // ID3v2.2 => Frame identifier $xx xx xx + // URL $00 + // ID and additional data + + $frame_offset = 0; + if ($id3v2_majorversion == 2) { + $parsedFrame['frameid'] = substr($parsedFrame['data'], $frame_offset, 3); + $frame_offset += 3; + } else { + $parsedFrame['frameid'] = substr($parsedFrame['data'], $frame_offset, 4); + $frame_offset += 4; + } + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_url = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_url) === 0) { + $frame_url = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + $parsedFrame['url'] = $frame_url; + + $parsedFrame['additionaldata'] = (string) substr($parsedFrame['data'], $frame_offset); + if (!empty($parsedFrame['framenameshort']) && $parsedFrame['url']) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback_iso88591_utf8($parsedFrame['url']); + } + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'POSS')) { // 4.21 POSS Position synchronisation frame (ID3v2.3+ only) + // There may only be one 'POSS' frame in each tag + // + // Time stamp format $xx + // Position $xx (xx ...) + + $frame_offset = 0; + $parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['position'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset)); + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'USER')) { // 4.22 USER Terms of use (ID3v2.3+ only) + // There may be more than one 'Terms of use' frame in a tag, + // but only one with the same 'Language' + //
      + // Text encoding $xx + // Language $xx xx xx + // The actual text + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + } + $frame_language = substr($parsedFrame['data'], $frame_offset, 3); + $frame_offset += 3; + $parsedFrame['language'] = $frame_language; + $parsedFrame['languagename'] = $this->LanguageLookup($frame_language, false); + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) { + $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']); + } + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'OWNE')) { // 4.23 OWNE Ownership frame (ID3v2.3+ only) + // There may only be one 'OWNE' frame in a tag + //
      + // Text encoding $xx + // Price paid $00 + // Date of purch. + // Seller + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + } + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_pricepaid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $parsedFrame['pricepaid']['currencyid'] = substr($frame_pricepaid, 0, 3); + $parsedFrame['pricepaid']['currency'] = $this->LookupCurrencyUnits($parsedFrame['pricepaid']['currencyid']); + $parsedFrame['pricepaid']['value'] = substr($frame_pricepaid, 3); + + $parsedFrame['purchasedate'] = substr($parsedFrame['data'], $frame_offset, 8); + if ($this->IsValidDateStampString($parsedFrame['purchasedate'])) { + $parsedFrame['purchasedateunix'] = mktime (0, 0, 0, substr($parsedFrame['purchasedate'], 4, 2), substr($parsedFrame['purchasedate'], 6, 2), substr($parsedFrame['purchasedate'], 0, 4)); + } + $frame_offset += 8; + + $parsedFrame['seller'] = (string) substr($parsedFrame['data'], $frame_offset); + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'COMR')) { // 4.24 COMR Commercial frame (ID3v2.3+ only) + // There may be more than one 'commercial frame' in a tag, + // but no two may be identical + //
      + // Text encoding $xx + // Price string $00 + // Valid until + // Contact URL $00 + // Received as $xx + // Name of seller $00 (00) + // Description $00 (00) + // Picture MIME type $00 + // Seller logo + + $frame_offset = 0; + $frame_textencoding = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_textencoding_terminator = $this->TextEncodingTerminatorLookup($frame_textencoding); + if ((($id3v2_majorversion <= 3) && ($frame_textencoding > 1)) || (($id3v2_majorversion == 4) && ($frame_textencoding > 3))) { + $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding'); + $frame_textencoding_terminator = "\x00"; + } + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_pricestring = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + $frame_offset = $frame_terminatorpos + strlen("\x00"); + $frame_rawpricearray = explode('/', $frame_pricestring); + foreach ($frame_rawpricearray as $key => $val) { + $frame_currencyid = substr($val, 0, 3); + $parsedFrame['price'][$frame_currencyid]['currency'] = $this->LookupCurrencyUnits($frame_currencyid); + $parsedFrame['price'][$frame_currencyid]['value'] = substr($val, 3); + } + + $frame_datestring = substr($parsedFrame['data'], $frame_offset, 8); + $frame_offset += 8; + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_contacturl = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $frame_receivedasid = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_sellername = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_sellername) === 0) { + $frame_sellername = ''; + } + $frame_offset = $frame_terminatorpos + strlen($frame_textencoding_terminator); + + $frame_terminatorpos = strpos($parsedFrame['data'], $frame_textencoding_terminator, $frame_offset); + if (ord(substr($parsedFrame['data'], $frame_terminatorpos + strlen($frame_textencoding_terminator), 1)) === 0) { + $frame_terminatorpos++; // strpos() fooled because 2nd byte of Unicode chars are often 0x00 + } + $frame_description = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (in_array($frame_description, array("\x00", "\x00\x00", "\xFF\xFE", "\xFE\xFF"))) { + // if description only contains a BOM or terminator then make it blank + $frame_description = ''; + } + $frame_offset = $frame_terminatorpos + strlen($frame_textencoding_terminator); + + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_mimetype = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $frame_sellerlogo = substr($parsedFrame['data'], $frame_offset); + + $parsedFrame['encodingid'] = $frame_textencoding; + $parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding); + + $parsedFrame['pricevaliduntil'] = $frame_datestring; + $parsedFrame['contacturl'] = $frame_contacturl; + $parsedFrame['receivedasid'] = $frame_receivedasid; + $parsedFrame['receivedas'] = $this->COMRReceivedAsLookup($frame_receivedasid); + $parsedFrame['sellername'] = $frame_sellername; + $parsedFrame['description'] = $frame_description; + $parsedFrame['mime'] = $frame_mimetype; + $parsedFrame['logo'] = $frame_sellerlogo; + unset($parsedFrame['data']); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'ENCR')) { // 4.25 ENCR Encryption method registration (ID3v2.3+ only) + // There may be several 'ENCR' frames in a tag, + // but only one containing the same symbol + // and only one containing the same owner identifier + //
      + // Owner identifier $00 + // Method symbol $xx + // Encryption data + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_ownerid) === 0) { + $frame_ownerid = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $parsedFrame['ownerid'] = $frame_ownerid; + $parsedFrame['methodsymbol'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'GRID')) { // 4.26 GRID Group identification registration (ID3v2.3+ only) + + // There may be several 'GRID' frames in a tag, + // but only one containing the same symbol + // and only one containing the same owner identifier + //
      + // Owner identifier $00 + // Group symbol $xx + // Group dependent data + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_ownerid) === 0) { + $frame_ownerid = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $parsedFrame['ownerid'] = $frame_ownerid; + $parsedFrame['groupsymbol'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'PRIV')) { // 4.27 PRIV Private frame (ID3v2.3+ only) + // The tag may contain more than one 'PRIV' frame + // but only with different contents + //
      + // Owner identifier $00 + // The private data + + $frame_offset = 0; + $frame_terminatorpos = strpos($parsedFrame['data'], "\x00", $frame_offset); + $frame_ownerid = substr($parsedFrame['data'], $frame_offset, $frame_terminatorpos - $frame_offset); + if (ord($frame_ownerid) === 0) { + $frame_ownerid = ''; + } + $frame_offset = $frame_terminatorpos + strlen("\x00"); + + $parsedFrame['ownerid'] = $frame_ownerid; + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + + + } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'SIGN')) { // 4.28 SIGN Signature frame (ID3v2.4+ only) + // There may be more than one 'signature frame' in a tag, + // but no two may be identical + //
      + // Group symbol $xx + // Signature + + $frame_offset = 0; + $parsedFrame['groupsymbol'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $parsedFrame['data'] = (string) substr($parsedFrame['data'], $frame_offset); + + + } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'SEEK')) { // 4.29 SEEK Seek frame (ID3v2.4+ only) + // There may only be one 'seek frame' in a tag + //
      + // Minimum offset to next tag $xx xx xx xx + + $frame_offset = 0; + $parsedFrame['data'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + + + } elseif (($id3v2_majorversion >= 4) && ($parsedFrame['frame_name'] == 'ASPI')) { // 4.30 ASPI Audio seek point index (ID3v2.4+ only) + // There may only be one 'audio seek point index' frame in a tag + //
      + // Indexed data start (S) $xx xx xx xx + // Indexed data length (L) $xx xx xx xx + // Number of index points (N) $xx xx + // Bits per index point (b) $xx + // Then for every index point the following data is included: + // Fraction at index (Fi) $xx (xx) + + $frame_offset = 0; + $parsedFrame['datastart'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $parsedFrame['indexeddatalength'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $parsedFrame['indexpoints'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['bitsperpoint'] = ord(substr($parsedFrame['data'], $frame_offset++, 1)); + $frame_bytesperpoint = ceil($parsedFrame['bitsperpoint'] / 8); + for ($i = 0; $i < $parsedFrame['indexpoints']; $i++) { + $parsedFrame['indexes'][$i] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, $frame_bytesperpoint)); + $frame_offset += $frame_bytesperpoint; + } + unset($parsedFrame['data']); + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'RGAD')) { // Replay Gain Adjustment + // http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html + // There may only be one 'RGAD' frame in a tag + //
      + // Peak Amplitude $xx $xx $xx $xx + // Radio Replay Gain Adjustment %aaabbbcd %dddddddd + // Audiophile Replay Gain Adjustment %aaabbbcd %dddddddd + // a - name code + // b - originator code + // c - sign bit + // d - replay gain adjustment + + $frame_offset = 0; + $parsedFrame['peakamplitude'] = getid3_lib::BigEndian2Float(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $rg_track_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $rg_album_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + $parsedFrame['raw']['track']['name'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 0, 3)); + $parsedFrame['raw']['track']['originator'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 3, 3)); + $parsedFrame['raw']['track']['signbit'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 6, 1)); + $parsedFrame['raw']['track']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_track_adjustment, 7, 9)); + $parsedFrame['raw']['album']['name'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 0, 3)); + $parsedFrame['raw']['album']['originator'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 3, 3)); + $parsedFrame['raw']['album']['signbit'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 6, 1)); + $parsedFrame['raw']['album']['adjustment'] = getid3_lib::Bin2Dec(substr($rg_album_adjustment, 7, 9)); + $parsedFrame['track']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['track']['name']); + $parsedFrame['track']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['track']['originator']); + $parsedFrame['track']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['track']['adjustment'], $parsedFrame['raw']['track']['signbit']); + $parsedFrame['album']['name'] = getid3_lib::RGADnameLookup($parsedFrame['raw']['album']['name']); + $parsedFrame['album']['originator'] = getid3_lib::RGADoriginatorLookup($parsedFrame['raw']['album']['originator']); + $parsedFrame['album']['adjustment'] = getid3_lib::RGADadjustmentLookup($parsedFrame['raw']['album']['adjustment'], $parsedFrame['raw']['album']['signbit']); + + $info['replay_gain']['track']['peak'] = $parsedFrame['peakamplitude']; + $info['replay_gain']['track']['originator'] = $parsedFrame['track']['originator']; + $info['replay_gain']['track']['adjustment'] = $parsedFrame['track']['adjustment']; + $info['replay_gain']['album']['originator'] = $parsedFrame['album']['originator']; + $info['replay_gain']['album']['adjustment'] = $parsedFrame['album']['adjustment']; + + unset($parsedFrame['data']); + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'CHAP')) { // CHAP Chapters frame (ID3v2.3+ only) + // http://id3.org/id3v2-chapters-1.0 + // (10 bytes) + // Element ID $00 + // Start time $xx xx xx xx + // End time $xx xx xx xx + // Start offset $xx xx xx xx + // End offset $xx xx xx xx + // + + $frame_offset = 0; + @list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2); + $frame_offset += strlen($parsedFrame['element_id']."\x00"); + $parsedFrame['time_begin'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $parsedFrame['time_end'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + if (substr($parsedFrame['data'], $frame_offset, 4) != "\xFF\xFF\xFF\xFF") { + // "If these bytes are all set to 0xFF then the value should be ignored and the start time value should be utilized." + $parsedFrame['offset_begin'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + } + $frame_offset += 4; + if (substr($parsedFrame['data'], $frame_offset, 4) != "\xFF\xFF\xFF\xFF") { + // "If these bytes are all set to 0xFF then the value should be ignored and the start time value should be utilized." + $parsedFrame['offset_end'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + } + $frame_offset += 4; + + if ($frame_offset < strlen($parsedFrame['data'])) { + $parsedFrame['subframes'] = array(); + while ($frame_offset < strlen($parsedFrame['data'])) { + // + $subframe = array(); + $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); + $frame_offset += 4; + $subframe['size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $subframe['flags_raw'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + if ($subframe['size'] > (strlen($parsedFrame['data']) - $frame_offset)) { + $this->warning('CHAP subframe "'.$subframe['name'].'" at frame offset '.$frame_offset.' claims to be "'.$subframe['size'].'" bytes, which is more than the available data ('.(strlen($parsedFrame['data']) - $frame_offset).' bytes)'); + break; + } + $subframe_rawdata = substr($parsedFrame['data'], $frame_offset, $subframe['size']); + $frame_offset += $subframe['size']; + + $subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1)); + $subframe['text'] = substr($subframe_rawdata, 1); + $subframe['encoding'] = $this->TextEncodingNameLookup($subframe['encodingid']); + $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));; + switch (substr($encoding_converted_text, 0, 2)) { + case "\xFF\xFE": + case "\xFE\xFF": + switch (strtoupper($info['id3v2']['encoding'])) { + case 'ISO-8859-1': + case 'UTF-8': + $encoding_converted_text = substr($encoding_converted_text, 2); + // remove unwanted byte-order-marks + break; + default: + // ignore + break; + } + break; + default: + // do not remove BOM + break; + } + + if (($subframe['name'] == 'TIT2') || ($subframe['name'] == 'TIT3')) { + if ($subframe['name'] == 'TIT2') { + $parsedFrame['chapter_name'] = $encoding_converted_text; + } elseif ($subframe['name'] == 'TIT3') { + $parsedFrame['chapter_description'] = $encoding_converted_text; + } + $parsedFrame['subframes'][] = $subframe; + } else { + $this->warning('ID3v2.CHAP subframe "'.$subframe['name'].'" not handled (only TIT2 and TIT3)'); + } + } + unset($subframe_rawdata, $subframe, $encoding_converted_text); + } + + $id3v2_chapter_entry = array(); + foreach (array('id', 'time_begin', 'time_end', 'offset_begin', 'offset_end', 'chapter_name', 'chapter_description') as $id3v2_chapter_key) { + if (isset($parsedFrame[$id3v2_chapter_key])) { + $id3v2_chapter_entry[$id3v2_chapter_key] = $parsedFrame[$id3v2_chapter_key]; + } + } + if (!isset($info['id3v2']['chapters'])) { + $info['id3v2']['chapters'] = array(); + } + $info['id3v2']['chapters'][] = $id3v2_chapter_entry; + unset($id3v2_chapter_entry, $id3v2_chapter_key); + + + } elseif (($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'CTOC')) { // CTOC Chapters Table Of Contents frame (ID3v2.3+ only) + // http://id3.org/id3v2-chapters-1.0 + // (10 bytes) + // Element ID $00 + // CTOC flags %xx + // Entry count $xx + // Child Element ID $00 /* zero or more child CHAP or CTOC entries */ + // + + $frame_offset = 0; + @list($parsedFrame['element_id']) = explode("\x00", $parsedFrame['data'], 2); + $frame_offset += strlen($parsedFrame['element_id']."\x00"); + $ctoc_flags_raw = ord(substr($parsedFrame['data'], $frame_offset, 1)); + $frame_offset += 1; + $parsedFrame['entry_count'] = ord(substr($parsedFrame['data'], $frame_offset, 1)); + $frame_offset += 1; + + $terminator_position = null; + for ($i = 0; $i < $parsedFrame['entry_count']; $i++) { + $terminator_position = strpos($parsedFrame['data'], "\x00", $frame_offset); + $parsedFrame['child_element_ids'][$i] = substr($parsedFrame['data'], $frame_offset, $terminator_position - $frame_offset); + $frame_offset = $terminator_position + 1; + } + + $parsedFrame['ctoc_flags']['ordered'] = (bool) ($ctoc_flags_raw & 0x01); + $parsedFrame['ctoc_flags']['top_level'] = (bool) ($ctoc_flags_raw & 0x03); + + unset($ctoc_flags_raw, $terminator_position); + + if ($frame_offset < strlen($parsedFrame['data'])) { + $parsedFrame['subframes'] = array(); + while ($frame_offset < strlen($parsedFrame['data'])) { + // + $subframe = array(); + $subframe['name'] = substr($parsedFrame['data'], $frame_offset, 4); + $frame_offset += 4; + $subframe['size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4)); + $frame_offset += 4; + $subframe['flags_raw'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 2)); + $frame_offset += 2; + if ($subframe['size'] > (strlen($parsedFrame['data']) - $frame_offset)) { + $this->warning('CTOS subframe "'.$subframe['name'].'" at frame offset '.$frame_offset.' claims to be "'.$subframe['size'].'" bytes, which is more than the available data ('.(strlen($parsedFrame['data']) - $frame_offset).' bytes)'); + break; + } + $subframe_rawdata = substr($parsedFrame['data'], $frame_offset, $subframe['size']); + $frame_offset += $subframe['size']; + + $subframe['encodingid'] = ord(substr($subframe_rawdata, 0, 1)); + $subframe['text'] = substr($subframe_rawdata, 1); + $subframe['encoding'] = $this->TextEncodingNameLookup($subframe['encodingid']); + $encoding_converted_text = trim(getid3_lib::iconv_fallback($subframe['encoding'], $info['encoding'], $subframe['text']));; + switch (substr($encoding_converted_text, 0, 2)) { + case "\xFF\xFE": + case "\xFE\xFF": + switch (strtoupper($info['id3v2']['encoding'])) { + case 'ISO-8859-1': + case 'UTF-8': + $encoding_converted_text = substr($encoding_converted_text, 2); + // remove unwanted byte-order-marks + break; + default: + // ignore + break; + } + break; + default: + // do not remove BOM + break; + } + + if (($subframe['name'] == 'TIT2') || ($subframe['name'] == 'TIT3')) { + if ($subframe['name'] == 'TIT2') { + $parsedFrame['toc_name'] = $encoding_converted_text; + } elseif ($subframe['name'] == 'TIT3') { + $parsedFrame['toc_description'] = $encoding_converted_text; + } + $parsedFrame['subframes'][] = $subframe; + } else { + $this->warning('ID3v2.CTOC subframe "'.$subframe['name'].'" not handled (only TIT2 and TIT3)'); + } + } + unset($subframe_rawdata, $subframe, $encoding_converted_text); + } + + } + + return true; + } + + + public function DeUnsynchronise($data) { + return str_replace("\xFF\x00", "\xFF", $data); + } + + public function LookupExtendedHeaderRestrictionsTagSizeLimits($index) { + static $LookupExtendedHeaderRestrictionsTagSizeLimits = array( + 0x00 => 'No more than 128 frames and 1 MB total tag size', + 0x01 => 'No more than 64 frames and 128 KB total tag size', + 0x02 => 'No more than 32 frames and 40 KB total tag size', + 0x03 => 'No more than 32 frames and 4 KB total tag size', + ); + return (isset($LookupExtendedHeaderRestrictionsTagSizeLimits[$index]) ? $LookupExtendedHeaderRestrictionsTagSizeLimits[$index] : ''); + } + + public function LookupExtendedHeaderRestrictionsTextEncodings($index) { + static $LookupExtendedHeaderRestrictionsTextEncodings = array( + 0x00 => 'No restrictions', + 0x01 => 'Strings are only encoded with ISO-8859-1 or UTF-8', + ); + return (isset($LookupExtendedHeaderRestrictionsTextEncodings[$index]) ? $LookupExtendedHeaderRestrictionsTextEncodings[$index] : ''); + } + + public function LookupExtendedHeaderRestrictionsTextFieldSize($index) { + static $LookupExtendedHeaderRestrictionsTextFieldSize = array( + 0x00 => 'No restrictions', + 0x01 => 'No string is longer than 1024 characters', + 0x02 => 'No string is longer than 128 characters', + 0x03 => 'No string is longer than 30 characters', + ); + return (isset($LookupExtendedHeaderRestrictionsTextFieldSize[$index]) ? $LookupExtendedHeaderRestrictionsTextFieldSize[$index] : ''); + } + + public function LookupExtendedHeaderRestrictionsImageEncoding($index) { + static $LookupExtendedHeaderRestrictionsImageEncoding = array( + 0x00 => 'No restrictions', + 0x01 => 'Images are encoded only with PNG or JPEG', + ); + return (isset($LookupExtendedHeaderRestrictionsImageEncoding[$index]) ? $LookupExtendedHeaderRestrictionsImageEncoding[$index] : ''); + } + + public function LookupExtendedHeaderRestrictionsImageSizeSize($index) { + static $LookupExtendedHeaderRestrictionsImageSizeSize = array( + 0x00 => 'No restrictions', + 0x01 => 'All images are 256x256 pixels or smaller', + 0x02 => 'All images are 64x64 pixels or smaller', + 0x03 => 'All images are exactly 64x64 pixels, unless required otherwise', + ); + return (isset($LookupExtendedHeaderRestrictionsImageSizeSize[$index]) ? $LookupExtendedHeaderRestrictionsImageSizeSize[$index] : ''); + } + + public function LookupCurrencyUnits($currencyid) { + + $begin = __LINE__; + + /** This is not a comment! + + + AED Dirhams + AFA Afghanis + ALL Leke + AMD Drams + ANG Guilders + AOA Kwanza + ARS Pesos + ATS Schillings + AUD Dollars + AWG Guilders + AZM Manats + BAM Convertible Marka + BBD Dollars + BDT Taka + BEF Francs + BGL Leva + BHD Dinars + BIF Francs + BMD Dollars + BND Dollars + BOB Bolivianos + BRL Brazil Real + BSD Dollars + BTN Ngultrum + BWP Pulas + BYR Rubles + BZD Dollars + CAD Dollars + CDF Congolese Francs + CHF Francs + CLP Pesos + CNY Yuan Renminbi + COP Pesos + CRC Colones + CUP Pesos + CVE Escudos + CYP Pounds + CZK Koruny + DEM Deutsche Marks + DJF Francs + DKK Kroner + DOP Pesos + DZD Algeria Dinars + EEK Krooni + EGP Pounds + ERN Nakfa + ESP Pesetas + ETB Birr + EUR Euro + FIM Markkaa + FJD Dollars + FKP Pounds + FRF Francs + GBP Pounds + GEL Lari + GGP Pounds + GHC Cedis + GIP Pounds + GMD Dalasi + GNF Francs + GRD Drachmae + GTQ Quetzales + GYD Dollars + HKD Dollars + HNL Lempiras + HRK Kuna + HTG Gourdes + HUF Forints + IDR Rupiahs + IEP Pounds + ILS New Shekels + IMP Pounds + INR Rupees + IQD Dinars + IRR Rials + ISK Kronur + ITL Lire + JEP Pounds + JMD Dollars + JOD Dinars + JPY Yen + KES Shillings + KGS Soms + KHR Riels + KMF Francs + KPW Won + KWD Dinars + KYD Dollars + KZT Tenge + LAK Kips + LBP Pounds + LKR Rupees + LRD Dollars + LSL Maloti + LTL Litai + LUF Francs + LVL Lati + LYD Dinars + MAD Dirhams + MDL Lei + MGF Malagasy Francs + MKD Denars + MMK Kyats + MNT Tugriks + MOP Patacas + MRO Ouguiyas + MTL Liri + MUR Rupees + MVR Rufiyaa + MWK Kwachas + MXN Pesos + MYR Ringgits + MZM Meticais + NAD Dollars + NGN Nairas + NIO Gold Cordobas + NLG Guilders + NOK Krone + NPR Nepal Rupees + NZD Dollars + OMR Rials + PAB Balboa + PEN Nuevos Soles + PGK Kina + PHP Pesos + PKR Rupees + PLN Zlotych + PTE Escudos + PYG Guarani + QAR Rials + ROL Lei + RUR Rubles + RWF Rwanda Francs + SAR Riyals + SBD Dollars + SCR Rupees + SDD Dinars + SEK Kronor + SGD Dollars + SHP Pounds + SIT Tolars + SKK Koruny + SLL Leones + SOS Shillings + SPL Luigini + SRG Guilders + STD Dobras + SVC Colones + SYP Pounds + SZL Emalangeni + THB Baht + TJR Rubles + TMM Manats + TND Dinars + TOP Pa'anga + TRL Liras + TTD Dollars + TVD Tuvalu Dollars + TWD New Dollars + TZS Shillings + UAH Hryvnia + UGX Shillings + USD Dollars + UYU Pesos + UZS Sums + VAL Lire + VEB Bolivares + VND Dong + VUV Vatu + WST Tala + XAF Francs + XAG Ounces + XAU Ounces + XCD Dollars + XDR Special Drawing Rights + XPD Ounces + XPF Francs + XPT Ounces + YER Rials + YUM New Dinars + ZAR Rand + ZMK Kwacha + ZWD Zimbabwe Dollars + + */ + + return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-units'); + } + + + public function LookupCurrencyCountry($currencyid) { + + $begin = __LINE__; + + /** This is not a comment! + + AED United Arab Emirates + AFA Afghanistan + ALL Albania + AMD Armenia + ANG Netherlands Antilles + AOA Angola + ARS Argentina + ATS Austria + AUD Australia + AWG Aruba + AZM Azerbaijan + BAM Bosnia and Herzegovina + BBD Barbados + BDT Bangladesh + BEF Belgium + BGL Bulgaria + BHD Bahrain + BIF Burundi + BMD Bermuda + BND Brunei Darussalam + BOB Bolivia + BRL Brazil + BSD Bahamas + BTN Bhutan + BWP Botswana + BYR Belarus + BZD Belize + CAD Canada + CDF Congo/Kinshasa + CHF Switzerland + CLP Chile + CNY China + COP Colombia + CRC Costa Rica + CUP Cuba + CVE Cape Verde + CYP Cyprus + CZK Czech Republic + DEM Germany + DJF Djibouti + DKK Denmark + DOP Dominican Republic + DZD Algeria + EEK Estonia + EGP Egypt + ERN Eritrea + ESP Spain + ETB Ethiopia + EUR Euro Member Countries + FIM Finland + FJD Fiji + FKP Falkland Islands (Malvinas) + FRF France + GBP United Kingdom + GEL Georgia + GGP Guernsey + GHC Ghana + GIP Gibraltar + GMD Gambia + GNF Guinea + GRD Greece + GTQ Guatemala + GYD Guyana + HKD Hong Kong + HNL Honduras + HRK Croatia + HTG Haiti + HUF Hungary + IDR Indonesia + IEP Ireland (Eire) + ILS Israel + IMP Isle of Man + INR India + IQD Iraq + IRR Iran + ISK Iceland + ITL Italy + JEP Jersey + JMD Jamaica + JOD Jordan + JPY Japan + KES Kenya + KGS Kyrgyzstan + KHR Cambodia + KMF Comoros + KPW Korea + KWD Kuwait + KYD Cayman Islands + KZT Kazakstan + LAK Laos + LBP Lebanon + LKR Sri Lanka + LRD Liberia + LSL Lesotho + LTL Lithuania + LUF Luxembourg + LVL Latvia + LYD Libya + MAD Morocco + MDL Moldova + MGF Madagascar + MKD Macedonia + MMK Myanmar (Burma) + MNT Mongolia + MOP Macau + MRO Mauritania + MTL Malta + MUR Mauritius + MVR Maldives (Maldive Islands) + MWK Malawi + MXN Mexico + MYR Malaysia + MZM Mozambique + NAD Namibia + NGN Nigeria + NIO Nicaragua + NLG Netherlands (Holland) + NOK Norway + NPR Nepal + NZD New Zealand + OMR Oman + PAB Panama + PEN Peru + PGK Papua New Guinea + PHP Philippines + PKR Pakistan + PLN Poland + PTE Portugal + PYG Paraguay + QAR Qatar + ROL Romania + RUR Russia + RWF Rwanda + SAR Saudi Arabia + SBD Solomon Islands + SCR Seychelles + SDD Sudan + SEK Sweden + SGD Singapore + SHP Saint Helena + SIT Slovenia + SKK Slovakia + SLL Sierra Leone + SOS Somalia + SPL Seborga + SRG Suriname + STD São Tome and Principe + SVC El Salvador + SYP Syria + SZL Swaziland + THB Thailand + TJR Tajikistan + TMM Turkmenistan + TND Tunisia + TOP Tonga + TRL Turkey + TTD Trinidad and Tobago + TVD Tuvalu + TWD Taiwan + TZS Tanzania + UAH Ukraine + UGX Uganda + USD United States of America + UYU Uruguay + UZS Uzbekistan + VAL Vatican City + VEB Venezuela + VND Viet Nam + VUV Vanuatu + WST Samoa + XAF Communauté Financière Africaine + XAG Silver + XAU Gold + XCD East Caribbean + XDR International Monetary Fund + XPD Palladium + XPF Comptoirs Français du Pacifique + XPT Platinum + YER Yemen + YUM Yugoslavia + ZAR South Africa + ZMK Zambia + ZWD Zimbabwe + + */ + + return getid3_lib::EmbeddedLookup($currencyid, $begin, __LINE__, __FILE__, 'id3v2-currency-country'); + } + + + + public static function LanguageLookup($languagecode, $casesensitive=false) { + + if (!$casesensitive) { + $languagecode = strtolower($languagecode); + } + + // http://www.id3.org/id3v2.4.0-structure.txt + // [4. ID3v2 frame overview] + // The three byte language field, present in several frames, is used to + // describe the language of the frame's content, according to ISO-639-2 + // [ISO-639-2]. The language should be represented in lower case. If the + // language is not known the string "XXX" should be used. + + + // ISO 639-2 - http://www.id3.org/iso639-2.html + + $begin = __LINE__; + + /** This is not a comment! + + XXX unknown + xxx unknown + aar Afar + abk Abkhazian + ace Achinese + ach Acoli + ada Adangme + afa Afro-Asiatic (Other) + afh Afrihili + afr Afrikaans + aka Akan + akk Akkadian + alb Albanian + ale Aleut + alg Algonquian Languages + amh Amharic + ang English, Old (ca. 450-1100) + apa Apache Languages + ara Arabic + arc Aramaic + arm Armenian + arn Araucanian + arp Arapaho + art Artificial (Other) + arw Arawak + asm Assamese + ath Athapascan Languages + ava Avaric + ave Avestan + awa Awadhi + aym Aymara + aze Azerbaijani + bad Banda + bai Bamileke Languages + bak Bashkir + bal Baluchi + bam Bambara + ban Balinese + baq Basque + bas Basa + bat Baltic (Other) + bej Beja + bel Byelorussian + bem Bemba + ben Bengali + ber Berber (Other) + bho Bhojpuri + bih Bihari + bik Bikol + bin Bini + bis Bislama + bla Siksika + bnt Bantu (Other) + bod Tibetan + bra Braj + bre Breton + bua Buriat + bug Buginese + bul Bulgarian + bur Burmese + cad Caddo + cai Central American Indian (Other) + car Carib + cat Catalan + cau Caucasian (Other) + ceb Cebuano + cel Celtic (Other) + ces Czech + cha Chamorro + chb Chibcha + che Chechen + chg Chagatai + chi Chinese + chm Mari + chn Chinook jargon + cho Choctaw + chr Cherokee + chu Church Slavic + chv Chuvash + chy Cheyenne + cop Coptic + cor Cornish + cos Corsican + cpe Creoles and Pidgins, English-based (Other) + cpf Creoles and Pidgins, French-based (Other) + cpp Creoles and Pidgins, Portuguese-based (Other) + cre Cree + crp Creoles and Pidgins (Other) + cus Cushitic (Other) + cym Welsh + cze Czech + dak Dakota + dan Danish + del Delaware + deu German + din Dinka + div Divehi + doi Dogri + dra Dravidian (Other) + dua Duala + dum Dutch, Middle (ca. 1050-1350) + dut Dutch + dyu Dyula + dzo Dzongkha + efi Efik + egy Egyptian (Ancient) + eka Ekajuk + ell Greek, Modern (1453-) + elx Elamite + eng English + enm English, Middle (ca. 1100-1500) + epo Esperanto + esk Eskimo (Other) + esl Spanish + est Estonian + eus Basque + ewe Ewe + ewo Ewondo + fan Fang + fao Faroese + fas Persian + fat Fanti + fij Fijian + fin Finnish + fiu Finno-Ugrian (Other) + fon Fon + fra French + fre French + frm French, Middle (ca. 1400-1600) + fro French, Old (842- ca. 1400) + fry Frisian + ful Fulah + gaa Ga + gae Gaelic (Scots) + gai Irish + gay Gayo + gdh Gaelic (Scots) + gem Germanic (Other) + geo Georgian + ger German + gez Geez + gil Gilbertese + glg Gallegan + gmh German, Middle High (ca. 1050-1500) + goh German, Old High (ca. 750-1050) + gon Gondi + got Gothic + grb Grebo + grc Greek, Ancient (to 1453) + gre Greek, Modern (1453-) + grn Guarani + guj Gujarati + hai Haida + hau Hausa + haw Hawaiian + heb Hebrew + her Herero + hil Hiligaynon + him Himachali + hin Hindi + hmo Hiri Motu + hun Hungarian + hup Hupa + hye Armenian + iba Iban + ibo Igbo + ice Icelandic + ijo Ijo + iku Inuktitut + ilo Iloko + ina Interlingua (International Auxiliary language Association) + inc Indic (Other) + ind Indonesian + ine Indo-European (Other) + ine Interlingue + ipk Inupiak + ira Iranian (Other) + iri Irish + iro Iroquoian uages + isl Icelandic + ita Italian + jav Javanese + jaw Javanese + jpn Japanese + jpr Judeo-Persian + jrb Judeo-Arabic + kaa Kara-Kalpak + kab Kabyle + kac Kachin + kal Greenlandic + kam Kamba + kan Kannada + kar Karen + kas Kashmiri + kat Georgian + kau Kanuri + kaw Kawi + kaz Kazakh + kha Khasi + khi Khoisan (Other) + khm Khmer + kho Khotanese + kik Kikuyu + kin Kinyarwanda + kir Kirghiz + kok Konkani + kom Komi + kon Kongo + kor Korean + kpe Kpelle + kro Kru + kru Kurukh + kua Kuanyama + kum Kumyk + kur Kurdish + kus Kusaie + kut Kutenai + lad Ladino + lah Lahnda + lam Lamba + lao Lao + lat Latin + lav Latvian + lez Lezghian + lin Lingala + lit Lithuanian + lol Mongo + loz Lozi + ltz Letzeburgesch + lub Luba-Katanga + lug Ganda + lui Luiseno + lun Lunda + luo Luo (Kenya and Tanzania) + mac Macedonian + mad Madurese + mag Magahi + mah Marshall + mai Maithili + mak Macedonian + mak Makasar + mal Malayalam + man Mandingo + mao Maori + map Austronesian (Other) + mar Marathi + mas Masai + max Manx + may Malay + men Mende + mga Irish, Middle (900 - 1200) + mic Micmac + min Minangkabau + mis Miscellaneous (Other) + mkh Mon-Kmer (Other) + mlg Malagasy + mlt Maltese + mni Manipuri + mno Manobo Languages + moh Mohawk + mol Moldavian + mon Mongolian + mos Mossi + mri Maori + msa Malay + mul Multiple Languages + mun Munda Languages + mus Creek + mwr Marwari + mya Burmese + myn Mayan Languages + nah Aztec + nai North American Indian (Other) + nau Nauru + nav Navajo + nbl Ndebele, South + nde Ndebele, North + ndo Ndongo + nep Nepali + new Newari + nic Niger-Kordofanian (Other) + niu Niuean + nla Dutch + nno Norwegian (Nynorsk) + non Norse, Old + nor Norwegian + nso Sotho, Northern + nub Nubian Languages + nya Nyanja + nym Nyamwezi + nyn Nyankole + nyo Nyoro + nzi Nzima + oci Langue d'Oc (post 1500) + oji Ojibwa + ori Oriya + orm Oromo + osa Osage + oss Ossetic + ota Turkish, Ottoman (1500 - 1928) + oto Otomian Languages + paa Papuan-Australian (Other) + pag Pangasinan + pal Pahlavi + pam Pampanga + pan Panjabi + pap Papiamento + pau Palauan + peo Persian, Old (ca 600 - 400 B.C.) + per Persian + phn Phoenician + pli Pali + pol Polish + pon Ponape + por Portuguese + pra Prakrit uages + pro Provencal, Old (to 1500) + pus Pushto + que Quechua + raj Rajasthani + rar Rarotongan + roa Romance (Other) + roh Rhaeto-Romance + rom Romany + ron Romanian + rum Romanian + run Rundi + rus Russian + sad Sandawe + sag Sango + sah Yakut + sai South American Indian (Other) + sal Salishan Languages + sam Samaritan Aramaic + san Sanskrit + sco Scots + scr Serbo-Croatian + sel Selkup + sem Semitic (Other) + sga Irish, Old (to 900) + shn Shan + sid Sidamo + sin Singhalese + sio Siouan Languages + sit Sino-Tibetan (Other) + sla Slavic (Other) + slk Slovak + slo Slovak + slv Slovenian + smi Sami Languages + smo Samoan + sna Shona + snd Sindhi + sog Sogdian + som Somali + son Songhai + sot Sotho, Southern + spa Spanish + sqi Albanian + srd Sardinian + srr Serer + ssa Nilo-Saharan (Other) + ssw Siswant + ssw Swazi + suk Sukuma + sun Sudanese + sus Susu + sux Sumerian + sve Swedish + swa Swahili + swe Swedish + syr Syriac + tah Tahitian + tam Tamil + tat Tatar + tel Telugu + tem Timne + ter Tereno + tgk Tajik + tgl Tagalog + tha Thai + tib Tibetan + tig Tigre + tir Tigrinya + tiv Tivi + tli Tlingit + tmh Tamashek + tog Tonga (Nyasa) + ton Tonga (Tonga Islands) + tru Truk + tsi Tsimshian + tsn Tswana + tso Tsonga + tuk Turkmen + tum Tumbuka + tur Turkish + tut Altaic (Other) + twi Twi + tyv Tuvinian + uga Ugaritic + uig Uighur + ukr Ukrainian + umb Umbundu + und Undetermined + urd Urdu + uzb Uzbek + vai Vai + ven Venda + vie Vietnamese + vol Volapük + vot Votic + wak Wakashan Languages + wal Walamo + war Waray + was Washo + wel Welsh + wen Sorbian Languages + wol Wolof + xho Xhosa + yao Yao + yap Yap + yid Yiddish + yor Yoruba + zap Zapotec + zen Zenaga + zha Zhuang + zho Chinese + zul Zulu + zun Zuni + + */ + + return getid3_lib::EmbeddedLookup($languagecode, $begin, __LINE__, __FILE__, 'id3v2-languagecode'); + } + + + public static function ETCOEventLookup($index) { + if (($index >= 0x17) && ($index <= 0xDF)) { + return 'reserved for future use'; + } + if (($index >= 0xE0) && ($index <= 0xEF)) { + return 'not predefined synch 0-F'; + } + if (($index >= 0xF0) && ($index <= 0xFC)) { + return 'reserved for future use'; + } + + static $EventLookup = array( + 0x00 => 'padding (has no meaning)', + 0x01 => 'end of initial silence', + 0x02 => 'intro start', + 0x03 => 'main part start', + 0x04 => 'outro start', + 0x05 => 'outro end', + 0x06 => 'verse start', + 0x07 => 'refrain start', + 0x08 => 'interlude start', + 0x09 => 'theme start', + 0x0A => 'variation start', + 0x0B => 'key change', + 0x0C => 'time change', + 0x0D => 'momentary unwanted noise (Snap, Crackle & Pop)', + 0x0E => 'sustained noise', + 0x0F => 'sustained noise end', + 0x10 => 'intro end', + 0x11 => 'main part end', + 0x12 => 'verse end', + 0x13 => 'refrain end', + 0x14 => 'theme end', + 0x15 => 'profanity', + 0x16 => 'profanity end', + 0xFD => 'audio end (start of silence)', + 0xFE => 'audio file ends', + 0xFF => 'one more byte of events follows' + ); + + return (isset($EventLookup[$index]) ? $EventLookup[$index] : ''); + } + + public static function SYTLContentTypeLookup($index) { + static $SYTLContentTypeLookup = array( + 0x00 => 'other', + 0x01 => 'lyrics', + 0x02 => 'text transcription', + 0x03 => 'movement/part name', // (e.g. 'Adagio') + 0x04 => 'events', // (e.g. 'Don Quijote enters the stage') + 0x05 => 'chord', // (e.g. 'Bb F Fsus') + 0x06 => 'trivia/\'pop up\' information', + 0x07 => 'URLs to webpages', + 0x08 => 'URLs to images' + ); + + return (isset($SYTLContentTypeLookup[$index]) ? $SYTLContentTypeLookup[$index] : ''); + } + + public static function APICPictureTypeLookup($index, $returnarray=false) { + static $APICPictureTypeLookup = array( + 0x00 => 'Other', + 0x01 => '32x32 pixels \'file icon\' (PNG only)', + 0x02 => 'Other file icon', + 0x03 => 'Cover (front)', + 0x04 => 'Cover (back)', + 0x05 => 'Leaflet page', + 0x06 => 'Media (e.g. label side of CD)', + 0x07 => 'Lead artist/lead performer/soloist', + 0x08 => 'Artist/performer', + 0x09 => 'Conductor', + 0x0A => 'Band/Orchestra', + 0x0B => 'Composer', + 0x0C => 'Lyricist/text writer', + 0x0D => 'Recording Location', + 0x0E => 'During recording', + 0x0F => 'During performance', + 0x10 => 'Movie/video screen capture', + 0x11 => 'A bright coloured fish', + 0x12 => 'Illustration', + 0x13 => 'Band/artist logotype', + 0x14 => 'Publisher/Studio logotype' + ); + if ($returnarray) { + return $APICPictureTypeLookup; + } + return (isset($APICPictureTypeLookup[$index]) ? $APICPictureTypeLookup[$index] : ''); + } + + public static function COMRReceivedAsLookup($index) { + static $COMRReceivedAsLookup = array( + 0x00 => 'Other', + 0x01 => 'Standard CD album with other songs', + 0x02 => 'Compressed audio on CD', + 0x03 => 'File over the Internet', + 0x04 => 'Stream over the Internet', + 0x05 => 'As note sheets', + 0x06 => 'As note sheets in a book with other sheets', + 0x07 => 'Music on other media', + 0x08 => 'Non-musical merchandise' + ); + + return (isset($COMRReceivedAsLookup[$index]) ? $COMRReceivedAsLookup[$index] : ''); + } + + public static function RVA2ChannelTypeLookup($index) { + static $RVA2ChannelTypeLookup = array( + 0x00 => 'Other', + 0x01 => 'Master volume', + 0x02 => 'Front right', + 0x03 => 'Front left', + 0x04 => 'Back right', + 0x05 => 'Back left', + 0x06 => 'Front centre', + 0x07 => 'Back centre', + 0x08 => 'Subwoofer' + ); + + return (isset($RVA2ChannelTypeLookup[$index]) ? $RVA2ChannelTypeLookup[$index] : ''); + } + + public static function FrameNameLongLookup($framename) { + + $begin = __LINE__; + + /** This is not a comment! + + AENC Audio encryption + APIC Attached picture + ASPI Audio seek point index + BUF Recommended buffer size + CNT Play counter + COM Comments + COMM Comments + COMR Commercial frame + CRA Audio encryption + CRM Encrypted meta frame + ENCR Encryption method registration + EQU Equalisation + EQU2 Equalisation (2) + EQUA Equalisation + ETC Event timing codes + ETCO Event timing codes + GEO General encapsulated object + GEOB General encapsulated object + GRID Group identification registration + IPL Involved people list + IPLS Involved people list + LINK Linked information + LNK Linked information + MCDI Music CD identifier + MCI Music CD Identifier + MLL MPEG location lookup table + MLLT MPEG location lookup table + OWNE Ownership frame + PCNT Play counter + PIC Attached picture + POP Popularimeter + POPM Popularimeter + POSS Position synchronisation frame + PRIV Private frame + RBUF Recommended buffer size + REV Reverb + RVA Relative volume adjustment + RVA2 Relative volume adjustment (2) + RVAD Relative volume adjustment + RVRB Reverb + SEEK Seek frame + SIGN Signature frame + SLT Synchronised lyric/text + STC Synced tempo codes + SYLT Synchronised lyric/text + SYTC Synchronised tempo codes + TAL Album/Movie/Show title + TALB Album/Movie/Show title + TBP BPM (Beats Per Minute) + TBPM BPM (beats per minute) + TCM Composer + TCMP Part of a compilation + TCO Content type + TCOM Composer + TCON Content type + TCOP Copyright message + TCP Part of a compilation + TCR Copyright message + TDA Date + TDAT Date + TDEN Encoding time + TDLY Playlist delay + TDOR Original release time + TDRC Recording time + TDRL Release time + TDTG Tagging time + TDY Playlist delay + TEN Encoded by + TENC Encoded by + TEXT Lyricist/Text writer + TFLT File type + TFT File type + TIM Time + TIME Time + TIPL Involved people list + TIT1 Content group description + TIT2 Title/songname/content description + TIT3 Subtitle/Description refinement + TKE Initial key + TKEY Initial key + TLA Language(s) + TLAN Language(s) + TLE Length + TLEN Length + TMCL Musician credits list + TMED Media type + TMOO Mood + TMT Media type + TOA Original artist(s)/performer(s) + TOAL Original album/movie/show title + TOF Original filename + TOFN Original filename + TOL Original Lyricist(s)/text writer(s) + TOLY Original lyricist(s)/text writer(s) + TOPE Original artist(s)/performer(s) + TOR Original release year + TORY Original release year + TOT Original album/Movie/Show title + TOWN File owner/licensee + TP1 Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group + TP2 Band/Orchestra/Accompaniment + TP3 Conductor/Performer refinement + TP4 Interpreted, remixed, or otherwise modified by + TPA Part of a set + TPB Publisher + TPE1 Lead performer(s)/Soloist(s) + TPE2 Band/orchestra/accompaniment + TPE3 Conductor/performer refinement + TPE4 Interpreted, remixed, or otherwise modified by + TPOS Part of a set + TPRO Produced notice + TPUB Publisher + TRC ISRC (International Standard Recording Code) + TRCK Track number/Position in set + TRD Recording dates + TRDA Recording dates + TRK Track number/Position in set + TRSN Internet radio station name + TRSO Internet radio station owner + TS2 Album-Artist sort order + TSA Album sort order + TSC Composer sort order + TSI Size + TSIZ Size + TSO2 Album-Artist sort order + TSOA Album sort order + TSOC Composer sort order + TSOP Performer sort order + TSOT Title sort order + TSP Performer sort order + TSRC ISRC (international standard recording code) + TSS Software/hardware and settings used for encoding + TSSE Software/Hardware and settings used for encoding + TSST Set subtitle + TST Title sort order + TT1 Content group description + TT2 Title/Songname/Content description + TT3 Subtitle/Description refinement + TXT Lyricist/text writer + TXX User defined text information frame + TXXX User defined text information frame + TYE Year + TYER Year + UFI Unique file identifier + UFID Unique file identifier + ULT Unsychronised lyric/text transcription + USER Terms of use + USLT Unsynchronised lyric/text transcription + WAF Official audio file webpage + WAR Official artist/performer webpage + WAS Official audio source webpage + WCM Commercial information + WCOM Commercial information + WCOP Copyright/Legal information + WCP Copyright/Legal information + WOAF Official audio file webpage + WOAR Official artist/performer webpage + WOAS Official audio source webpage + WORS Official Internet radio station homepage + WPAY Payment + WPB Publishers official webpage + WPUB Publishers official webpage + WXX User defined URL link frame + WXXX User defined URL link frame + TFEA Featured Artist + TSTU Recording Studio + rgad Replay Gain Adjustment + + */ + + return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_long'); + + // Last three: + // from Helium2 [www.helium2.com] + // from http://privatewww.essex.ac.uk/~djmrob/replaygain/file_format_id3v2.html + } + + + public static function FrameNameShortLookup($framename) { + + $begin = __LINE__; + + /** This is not a comment! + + AENC audio_encryption + APIC attached_picture + ASPI audio_seek_point_index + BUF recommended_buffer_size + CNT play_counter + COM comment + COMM comment + COMR commercial_frame + CRA audio_encryption + CRM encrypted_meta_frame + ENCR encryption_method_registration + EQU equalisation + EQU2 equalisation + EQUA equalisation + ETC event_timing_codes + ETCO event_timing_codes + GEO general_encapsulated_object + GEOB general_encapsulated_object + GRID group_identification_registration + IPL involved_people_list + IPLS involved_people_list + LINK linked_information + LNK linked_information + MCDI music_cd_identifier + MCI music_cd_identifier + MLL mpeg_location_lookup_table + MLLT mpeg_location_lookup_table + OWNE ownership_frame + PCNT play_counter + PIC attached_picture + POP popularimeter + POPM popularimeter + POSS position_synchronisation_frame + PRIV private_frame + RBUF recommended_buffer_size + REV reverb + RVA relative_volume_adjustment + RVA2 relative_volume_adjustment + RVAD relative_volume_adjustment + RVRB reverb + SEEK seek_frame + SIGN signature_frame + SLT synchronised_lyric + STC synced_tempo_codes + SYLT synchronised_lyric + SYTC synchronised_tempo_codes + TAL album + TALB album + TBP bpm + TBPM bpm + TCM composer + TCMP part_of_a_compilation + TCO genre + TCOM composer + TCON genre + TCOP copyright_message + TCP part_of_a_compilation + TCR copyright_message + TDA date + TDAT date + TDEN encoding_time + TDLY playlist_delay + TDOR original_release_time + TDRC recording_time + TDRL release_time + TDTG tagging_time + TDY playlist_delay + TEN encoded_by + TENC encoded_by + TEXT lyricist + TFLT file_type + TFT file_type + TIM time + TIME time + TIPL involved_people_list + TIT1 content_group_description + TIT2 title + TIT3 subtitle + TKE initial_key + TKEY initial_key + TLA language + TLAN language + TLE length + TLEN length + TMCL musician_credits_list + TMED media_type + TMOO mood + TMT media_type + TOA original_artist + TOAL original_album + TOF original_filename + TOFN original_filename + TOL original_lyricist + TOLY original_lyricist + TOPE original_artist + TOR original_year + TORY original_year + TOT original_album + TOWN file_owner + TP1 artist + TP2 band + TP3 conductor + TP4 remixer + TPA part_of_a_set + TPB publisher + TPE1 artist + TPE2 band + TPE3 conductor + TPE4 remixer + TPOS part_of_a_set + TPRO produced_notice + TPUB publisher + TRC isrc + TRCK track_number + TRD recording_dates + TRDA recording_dates + TRK track_number + TRSN internet_radio_station_name + TRSO internet_radio_station_owner + TS2 album_artist_sort_order + TSA album_sort_order + TSC composer_sort_order + TSI size + TSIZ size + TSO2 album_artist_sort_order + TSOA album_sort_order + TSOC composer_sort_order + TSOP performer_sort_order + TSOT title_sort_order + TSP performer_sort_order + TSRC isrc + TSS encoder_settings + TSSE encoder_settings + TSST set_subtitle + TST title_sort_order + TT1 content_group_description + TT2 title + TT3 subtitle + TXT lyricist + TXX text + TXXX text + TYE year + TYER year + UFI unique_file_identifier + UFID unique_file_identifier + ULT unsychronised_lyric + USER terms_of_use + USLT unsynchronised_lyric + WAF url_file + WAR url_artist + WAS url_source + WCM commercial_information + WCOM commercial_information + WCOP copyright + WCP copyright + WOAF url_file + WOAR url_artist + WOAS url_source + WORS url_station + WPAY url_payment + WPB url_publisher + WPUB url_publisher + WXX url_user + WXXX url_user + TFEA featured_artist + TSTU recording_studio + rgad replay_gain_adjustment + + */ + + return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short'); + } + + public static function TextEncodingTerminatorLookup($encoding) { + // http://www.id3.org/id3v2.4.0-structure.txt + // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: + static $TextEncodingTerminatorLookup = array( + 0 => "\x00", // $00 ISO-8859-1. Terminated with $00. + 1 => "\x00\x00", // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. + 2 => "\x00\x00", // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. + 3 => "\x00", // $03 UTF-8 encoded Unicode. Terminated with $00. + 255 => "\x00\x00" + ); + return (isset($TextEncodingTerminatorLookup[$encoding]) ? $TextEncodingTerminatorLookup[$encoding] : "\x00"); + } + + public static function TextEncodingNameLookup($encoding) { + // http://www.id3.org/id3v2.4.0-structure.txt + // Frames that allow different types of text encoding contains a text encoding description byte. Possible encodings: + static $TextEncodingNameLookup = array( + 0 => 'ISO-8859-1', // $00 ISO-8859-1. Terminated with $00. + 1 => 'UTF-16', // $01 UTF-16 encoded Unicode with BOM. All strings in the same frame SHALL have the same byteorder. Terminated with $00 00. + 2 => 'UTF-16BE', // $02 UTF-16BE encoded Unicode without BOM. Terminated with $00 00. + 3 => 'UTF-8', // $03 UTF-8 encoded Unicode. Terminated with $00. + 255 => 'UTF-16BE' + ); + return (isset($TextEncodingNameLookup[$encoding]) ? $TextEncodingNameLookup[$encoding] : 'ISO-8859-1'); + } + + public static function IsValidID3v2FrameName($framename, $id3v2majorversion) { + switch ($id3v2majorversion) { + case 2: + return preg_match('#[A-Z][A-Z0-9]{2}#', $framename); + break; + + case 3: + case 4: + return preg_match('#[A-Z][A-Z0-9]{3}#', $framename); + break; + } + return false; + } + + public static function IsANumber($numberstring, $allowdecimal=false, $allownegative=false) { + for ($i = 0; $i < strlen($numberstring); $i++) { + if ((chr($numberstring{$i}) < chr('0')) || (chr($numberstring{$i}) > chr('9'))) { + if (($numberstring{$i} == '.') && $allowdecimal) { + // allowed + } elseif (($numberstring{$i} == '-') && $allownegative && ($i == 0)) { + // allowed + } else { + return false; + } + } + } + return true; + } + + public static function IsValidDateStampString($datestamp) { + if (strlen($datestamp) != 8) { + return false; + } + if (!self::IsANumber($datestamp, false)) { + return false; + } + $year = substr($datestamp, 0, 4); + $month = substr($datestamp, 4, 2); + $day = substr($datestamp, 6, 2); + if (($year == 0) || ($month == 0) || ($day == 0)) { + return false; + } + if ($month > 12) { + return false; + } + if ($day > 31) { + return false; + } + if (($day > 30) && (($month == 4) || ($month == 6) || ($month == 9) || ($month == 11))) { + return false; + } + if (($day > 29) && ($month == 2)) { + return false; + } + return true; + } + + public static function ID3v2HeaderLength($majorversion) { + return (($majorversion == 2) ? 6 : 10); + } + + public static function ID3v22iTunesBrokenFrameName($frame_name) { + // iTunes (multiple versions) has been known to write ID3v2.3 style frames + // but use ID3v2.2 frame names, right-padded using either [space] or [null] + // to make them fit in the 4-byte frame name space of the ID3v2.3 frame. + // This function will detect and translate the corrupt frame name into ID3v2.3 standard. + static $ID3v22_iTunes_BrokenFrames = array( + 'BUF' => 'RBUF', // Recommended buffer size + 'CNT' => 'PCNT', // Play counter + 'COM' => 'COMM', // Comments + 'CRA' => 'AENC', // Audio encryption + 'EQU' => 'EQUA', // Equalisation + 'ETC' => 'ETCO', // Event timing codes + 'GEO' => 'GEOB', // General encapsulated object + 'IPL' => 'IPLS', // Involved people list + 'LNK' => 'LINK', // Linked information + 'MCI' => 'MCDI', // Music CD identifier + 'MLL' => 'MLLT', // MPEG location lookup table + 'PIC' => 'APIC', // Attached picture + 'POP' => 'POPM', // Popularimeter + 'REV' => 'RVRB', // Reverb + 'RVA' => 'RVAD', // Relative volume adjustment + 'SLT' => 'SYLT', // Synchronised lyric/text + 'STC' => 'SYTC', // Synchronised tempo codes + 'TAL' => 'TALB', // Album/Movie/Show title + 'TBP' => 'TBPM', // BPM (beats per minute) + 'TCM' => 'TCOM', // Composer + 'TCO' => 'TCON', // Content type + 'TCP' => 'TCMP', // Part of a compilation + 'TCR' => 'TCOP', // Copyright message + 'TDA' => 'TDAT', // Date + 'TDY' => 'TDLY', // Playlist delay + 'TEN' => 'TENC', // Encoded by + 'TFT' => 'TFLT', // File type + 'TIM' => 'TIME', // Time + 'TKE' => 'TKEY', // Initial key + 'TLA' => 'TLAN', // Language(s) + 'TLE' => 'TLEN', // Length + 'TMT' => 'TMED', // Media type + 'TOA' => 'TOPE', // Original artist(s)/performer(s) + 'TOF' => 'TOFN', // Original filename + 'TOL' => 'TOLY', // Original lyricist(s)/text writer(s) + 'TOR' => 'TORY', // Original release year + 'TOT' => 'TOAL', // Original album/movie/show title + 'TP1' => 'TPE1', // Lead performer(s)/Soloist(s) + 'TP2' => 'TPE2', // Band/orchestra/accompaniment + 'TP3' => 'TPE3', // Conductor/performer refinement + 'TP4' => 'TPE4', // Interpreted, remixed, or otherwise modified by + 'TPA' => 'TPOS', // Part of a set + 'TPB' => 'TPUB', // Publisher + 'TRC' => 'TSRC', // ISRC (international standard recording code) + 'TRD' => 'TRDA', // Recording dates + 'TRK' => 'TRCK', // Track number/Position in set + 'TS2' => 'TSO2', // Album-Artist sort order + 'TSA' => 'TSOA', // Album sort order + 'TSC' => 'TSOC', // Composer sort order + 'TSI' => 'TSIZ', // Size + 'TSP' => 'TSOP', // Performer sort order + 'TSS' => 'TSSE', // Software/Hardware and settings used for encoding + 'TST' => 'TSOT', // Title sort order + 'TT1' => 'TIT1', // Content group description + 'TT2' => 'TIT2', // Title/songname/content description + 'TT3' => 'TIT3', // Subtitle/Description refinement + 'TXT' => 'TEXT', // Lyricist/Text writer + 'TXX' => 'TXXX', // User defined text information frame + 'TYE' => 'TYER', // Year + 'UFI' => 'UFID', // Unique file identifier + 'ULT' => 'USLT', // Unsynchronised lyric/text transcription + 'WAF' => 'WOAF', // Official audio file webpage + 'WAR' => 'WOAR', // Official artist/performer webpage + 'WAS' => 'WOAS', // Official audio source webpage + 'WCM' => 'WCOM', // Commercial information + 'WCP' => 'WCOP', // Copyright/Legal information + 'WPB' => 'WPUB', // Publishers official webpage + 'WXX' => 'WXXX', // User defined URL link frame + ); + if (strlen($frame_name) == 4) { + if ((substr($frame_name, 3, 1) == ' ') || (substr($frame_name, 3, 1) == "\x00")) { + if (isset($ID3v22_iTunes_BrokenFrames[substr($frame_name, 0, 3)])) { + return $ID3v22_iTunes_BrokenFrames[substr($frame_name, 0, 3)]; + } + } + } + return false; + } + +} diff --git a/backend/wp-includes/ID3/module.tag.lyrics3.php b/backend/wp-includes/ID3/module.tag.lyrics3.php new file mode 100644 index 0000000..1645396 --- /dev/null +++ b/backend/wp-includes/ID3/module.tag.lyrics3.php @@ -0,0 +1,298 @@ + // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// +// See readme.txt for more details // +///////////////////////////////////////////////////////////////// +/// // +// module.tag.lyrics3.php // +// module for analyzing Lyrics3 tags // +// dependencies: module.tag.apetag.php (optional) // +// /// +///////////////////////////////////////////////////////////////// + + +class getid3_lyrics3 extends getid3_handler +{ + + public function Analyze() { + $info = &$this->getid3->info; + + // http://www.volweb.cz/str/tags.htm + + if (!getid3_lib::intValueSupported($info['filesize'])) { + $this->warning('Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'); + return false; + } + + $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] + $lyrics3_id3v1 = $this->fread(128 + 9 + 6); + $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size + $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 + $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 + + if ($lyrics3end == 'LYRICSEND') { + // Lyrics3v1, ID3v1, no APE + + $lyrics3size = 5100; + $lyrics3offset = $info['filesize'] - 128 - $lyrics3size; + $lyrics3version = 1; + + } elseif ($lyrics3end == 'LYRICS200') { + // Lyrics3v2, ID3v1, no APE + + // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200' + $lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200'); + $lyrics3offset = $info['filesize'] - 128 - $lyrics3size; + $lyrics3version = 2; + + } elseif (substr(strrev($lyrics3_id3v1), 0, 9) == strrev('LYRICSEND')) { + // Lyrics3v1, no ID3v1, no APE + + $lyrics3size = 5100; + $lyrics3offset = $info['filesize'] - $lyrics3size; + $lyrics3version = 1; + $lyrics3offset = $info['filesize'] - $lyrics3size; + + } elseif (substr(strrev($lyrics3_id3v1), 0, 9) == strrev('LYRICS200')) { + + // Lyrics3v2, no ID3v1, no APE + + $lyrics3size = strrev(substr(strrev($lyrics3_id3v1), 9, 6)) + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200' + $lyrics3offset = $info['filesize'] - $lyrics3size; + $lyrics3version = 2; + + } else { + + if (isset($info['ape']['tag_offset_start']) && ($info['ape']['tag_offset_start'] > 15)) { + + $this->fseek($info['ape']['tag_offset_start'] - 15); + $lyrics3lsz = $this->fread(6); + $lyrics3end = $this->fread(9); + + if ($lyrics3end == 'LYRICSEND') { + // Lyrics3v1, APE, maybe ID3v1 + + $lyrics3size = 5100; + $lyrics3offset = $info['ape']['tag_offset_start'] - $lyrics3size; + $info['avdataend'] = $lyrics3offset; + $lyrics3version = 1; + $this->warning('APE tag located after Lyrics3, will probably break Lyrics3 compatability'); + + } elseif ($lyrics3end == 'LYRICS200') { + // Lyrics3v2, APE, maybe ID3v1 + + $lyrics3size = $lyrics3lsz + 6 + strlen('LYRICS200'); // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200' + $lyrics3offset = $info['ape']['tag_offset_start'] - $lyrics3size; + $lyrics3version = 2; + $this->warning('APE tag located after Lyrics3, will probably break Lyrics3 compatability'); + + } + + } + + } + + if (isset($lyrics3offset)) { + $info['avdataend'] = $lyrics3offset; + $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size); + + if (!isset($info['ape'])) { + if (isset($info['lyrics3']['tag_offset_start'])) { + $GETID3_ERRORARRAY = &$info['warning']; + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); + $getid3_temp = new getID3(); + $getid3_temp->openfile($this->getid3->filename); + $getid3_apetag = new getid3_apetag($getid3_temp); + $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; + $getid3_apetag->Analyze(); + if (!empty($getid3_temp->info['ape'])) { + $info['ape'] = $getid3_temp->info['ape']; + } + if (!empty($getid3_temp->info['replay_gain'])) { + $info['replay_gain'] = $getid3_temp->info['replay_gain']; + } + unset($getid3_temp, $getid3_apetag); + } else { + $this->warning('Lyrics3 and APE tags appear to have become entangled (most likely due to updating the APE tags with a non-Lyrics3-aware tagger)'); + } + } + + } + + return true; + } + + public function getLyrics3Data($endoffset, $version, $length) { + // http://www.volweb.cz/str/tags.htm + + $info = &$this->getid3->info; + + if (!getid3_lib::intValueSupported($endoffset)) { + $this->warning('Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'); + return false; + } + + $this->fseek($endoffset); + if ($length <= 0) { + return false; + } + $rawdata = $this->fread($length); + + $ParsedLyrics3['raw']['lyrics3version'] = $version; + $ParsedLyrics3['raw']['lyrics3tagsize'] = $length; + $ParsedLyrics3['tag_offset_start'] = $endoffset; + $ParsedLyrics3['tag_offset_end'] = $endoffset + $length - 1; + + if (substr($rawdata, 0, 11) != 'LYRICSBEGIN') { + if (strpos($rawdata, 'LYRICSBEGIN') !== false) { + + $this->warning('"LYRICSBEGIN" expected at '.$endoffset.' but actually found at '.($endoffset + strpos($rawdata, 'LYRICSBEGIN')).' - this is invalid for Lyrics3 v'.$version); + $info['avdataend'] = $endoffset + strpos($rawdata, 'LYRICSBEGIN'); + $rawdata = substr($rawdata, strpos($rawdata, 'LYRICSBEGIN')); + $length = strlen($rawdata); + $ParsedLyrics3['tag_offset_start'] = $info['avdataend']; + $ParsedLyrics3['raw']['lyrics3tagsize'] = $length; + + } else { + + $this->error('"LYRICSBEGIN" expected at '.$endoffset.' but found "'.substr($rawdata, 0, 11).'" instead'); + return false; + + } + + } + + switch ($version) { + + case 1: + if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICSEND') { + $ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9)); + $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); + } else { + $this->error('"LYRICSEND" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'); + return false; + } + break; + + case 2: + if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICS200') { + $ParsedLyrics3['raw']['unparsed'] = substr($rawdata, 11, strlen($rawdata) - 11 - 9 - 6); // LYRICSBEGIN + LYRICS200 + LSZ + $rawdata = $ParsedLyrics3['raw']['unparsed']; + while (strlen($rawdata) > 0) { + $fieldname = substr($rawdata, 0, 3); + $fieldsize = (int) substr($rawdata, 3, 5); + $ParsedLyrics3['raw'][$fieldname] = substr($rawdata, 8, $fieldsize); + $rawdata = substr($rawdata, 3 + 5 + $fieldsize); + } + + if (isset($ParsedLyrics3['raw']['IND'])) { + $i = 0; + $flagnames = array('lyrics', 'timestamps', 'inhibitrandom'); + foreach ($flagnames as $flagname) { + if (strlen($ParsedLyrics3['raw']['IND']) > $i++) { + $ParsedLyrics3['flags'][$flagname] = $this->IntString2Bool(substr($ParsedLyrics3['raw']['IND'], $i, 1 - 1)); + } + } + } + + $fieldnametranslation = array('ETT'=>'title', 'EAR'=>'artist', 'EAL'=>'album', 'INF'=>'comment', 'AUT'=>'author'); + foreach ($fieldnametranslation as $key => $value) { + if (isset($ParsedLyrics3['raw'][$key])) { + $ParsedLyrics3['comments'][$value][] = trim($ParsedLyrics3['raw'][$key]); + } + } + + if (isset($ParsedLyrics3['raw']['IMG'])) { + $imagestrings = explode("\r\n", $ParsedLyrics3['raw']['IMG']); + foreach ($imagestrings as $key => $imagestring) { + if (strpos($imagestring, '||') !== false) { + $imagearray = explode('||', $imagestring); + $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : ''); + $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : ''); + $ParsedLyrics3['images'][$key]['timestamp'] = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : ''); + } + } + } + if (isset($ParsedLyrics3['raw']['LYR'])) { + $this->Lyrics3LyricsTimestampParse($ParsedLyrics3); + } + } else { + $this->error('"LYRICS200" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead'); + return false; + } + break; + + default: + $this->error('Cannot process Lyrics3 version '.$version.' (only v1 and v2)'); + return false; + break; + } + + + if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] <= $ParsedLyrics3['tag_offset_end'])) { + $this->warning('ID3v1 tag information ignored since it appears to be a false synch in Lyrics3 tag data'); + unset($info['id3v1']); + foreach ($info['warning'] as $key => $value) { + if ($value == 'Some ID3v1 fields do not use NULL characters for padding') { + unset($info['warning'][$key]); + sort($info['warning']); + break; + } + } + } + + $info['lyrics3'] = $ParsedLyrics3; + + return true; + } + + public function Lyrics3Timestamp2Seconds($rawtimestamp) { + if (preg_match('#^\\[([0-9]{2}):([0-9]{2})\\]$#', $rawtimestamp, $regs)) { + return (int) (($regs[1] * 60) + $regs[2]); + } + return false; + } + + public function Lyrics3LyricsTimestampParse(&$Lyrics3data) { + $lyricsarray = explode("\r\n", $Lyrics3data['raw']['LYR']); + foreach ($lyricsarray as $key => $lyricline) { + $regs = array(); + unset($thislinetimestamps); + while (preg_match('#^(\\[[0-9]{2}:[0-9]{2}\\])#', $lyricline, $regs)) { + $thislinetimestamps[] = $this->Lyrics3Timestamp2Seconds($regs[0]); + $lyricline = str_replace($regs[0], '', $lyricline); + } + $notimestamplyricsarray[$key] = $lyricline; + if (isset($thislinetimestamps) && is_array($thislinetimestamps)) { + sort($thislinetimestamps); + foreach ($thislinetimestamps as $timestampkey => $timestamp) { + if (isset($Lyrics3data['synchedlyrics'][$timestamp])) { + // timestamps only have a 1-second resolution, it's possible that multiple lines + // could have the same timestamp, if so, append + $Lyrics3data['synchedlyrics'][$timestamp] .= "\r\n".$lyricline; + } else { + $Lyrics3data['synchedlyrics'][$timestamp] = $lyricline; + } + } + } + } + $Lyrics3data['unsynchedlyrics'] = implode("\r\n", $notimestamplyricsarray); + if (isset($Lyrics3data['synchedlyrics']) && is_array($Lyrics3data['synchedlyrics'])) { + ksort($Lyrics3data['synchedlyrics']); + } + return true; + } + + public function IntString2Bool($char) { + if ($char == '1') { + return true; + } elseif ($char == '0') { + return false; + } + return null; + } +} diff --git a/backend/wp-includes/ID3/readme.txt b/backend/wp-includes/ID3/readme.txt new file mode 100644 index 0000000..b627cc2 --- /dev/null +++ b/backend/wp-includes/ID3/readme.txt @@ -0,0 +1,604 @@ +///////////////////////////////////////////////////////////////// +/// getID3() by James Heinrich // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +// also https://github.com/JamesHeinrich/getID3 // +///////////////////////////////////////////////////////////////// + +***************************************************************** +***************************************************************** + + getID3() is released under multiple licenses. You may choose + from the following licenses, and use getID3 according to the + terms of the license most suitable to your project. + +GNU GPL: https://gnu.org/licenses/gpl.html (v3) + https://gnu.org/licenses/old-licenses/gpl-2.0.html (v2) + https://gnu.org/licenses/old-licenses/gpl-1.0.html (v1) + +GNU LGPL: https://gnu.org/licenses/lgpl.html (v3) + +Mozilla MPL: http://www.mozilla.org/MPL/2.0/ (v2) + +getID3 Commercial License: http://getid3.org/#gCL (payment required) + +***************************************************************** +***************************************************************** +Copies of each of the above licenses are included in the 'licenses' +directory of the getID3 distribution. + + + +---------------------------------------------+ + | If you want to donate, there is a link on | + | http://www.getid3.org for PayPal donations. | + +---------------------------------------------+ + + +Quick Start +=========================================================================== + +Q: How can I check that getID3() works on my server/files? +A: Unzip getID3() to a directory, then access /demos/demo.browse.php + + + +Support +=========================================================================== + +Q: I have a question, or I found a bug. What do I do? +A: The preferred method of support requests and/or bug reports is the + forum at http://support.getid3.org/ + + + +Sourceforge Notification +=========================================================================== + +It's highly recommended that you sign up for notification from +Sourceforge for when new versions are released. Please visit: +http://sourceforge.net/project/showfiles.php?group_id=55859 +and click the little "monitor package" icon/link. If you're +previously signed up for the mailing list, be aware that it has +been discontinued, only the automated Sourceforge notification +will be used from now on. + + + +What does getID3() do? +=========================================================================== + +Reads & parses (to varying degrees): + ¤ tags: + * APE (v1 and v2) + * ID3v1 (& ID3v1.1) + * ID3v2 (v2.4, v2.3, v2.2) + * Lyrics3 (v1 & v2) + + ¤ audio-lossy: + * MP3/MP2/MP1 + * MPC / Musepack + * Ogg (Vorbis, OggFLAC, Speex) + * AAC / MP4 + * AC3 + * DTS + * RealAudio + * Speex + * DSS + * VQF + + ¤ audio-lossless: + * AIFF + * AU + * Bonk + * CD-audio (*.cda) + * FLAC + * LA (Lossless Audio) + * LiteWave + * LPAC + * MIDI + * Monkey's Audio + * OptimFROG + * RKAU + * Shorten + * TTA + * VOC + * WAV (RIFF) + * WavPack + + ¤ audio-video: + * ASF: ASF, Windows Media Audio (WMA), Windows Media Video (WMV) + * AVI (RIFF) + * Flash + * Matroska (MKV) + * MPEG-1 / MPEG-2 + * NSV (Nullsoft Streaming Video) + * Quicktime (including MP4) + * RealVideo + + ¤ still image: + * BMP + * GIF + * JPEG + * PNG + * TIFF + * SWF (Flash) + * PhotoCD + + ¤ data: + * ISO-9660 CD-ROM image (directory structure) + * SZIP (limited support) + * ZIP (directory structure) + * TAR + * CUE + + +Writes: + * ID3v1 (& ID3v1.1) + * ID3v2 (v2.3 & v2.4) + * VorbisComment on OggVorbis + * VorbisComment on FLAC (not OggFLAC) + * APE v2 + * Lyrics3 (delete only) + + + +Requirements +=========================================================================== + +* PHP 4.2.0 up to 5.2.x for getID3() 1.7.x (and earlier) +* PHP 5.0.5 (or higher) for getID3() 1.8.x (and up) +* PHP 5.0.5 (or higher) for getID3() 2.0.x (and up) +* at least 4MB memory for PHP. 8MB or more is highly recommended. + 12MB is required with all modules loaded. + + + +Usage +=========================================================================== + +See /demos/demo.basic.php for a very basic use of getID3() with no +fancy output, just scanning one file. + +See structure.txt for the returned data structure. + +*> For an example of a complete directory-browsing, <* +*> file-scanning implementation of getID3(), please run <* +*> /demos/demo.browse.php <* + +See /demos/demo.mysql.php for a sample recursive scanning code that +scans every file in a given directory, and all sub-directories, stores +the results in a database and allows various analysis / maintenance +operations + +To analyze remote files over HTTP or FTP you need to copy the file +locally first before running getID3(). Your code would look something +like this: + +// Copy remote file locally to scan with getID3() +$remotefilename = 'http://www.example.com/filename.mp3'; +if ($fp_remote = fopen($remotefilename, 'rb')) { + $localtempfilename = tempnam('/tmp', 'getID3'); + if ($fp_local = fopen($localtempfilename, 'wb')) { + while ($buffer = fread($fp_remote, 8192)) { + fwrite($fp_local, $buffer); + } + fclose($fp_local); + + // Initialize getID3 engine + $getID3 = new getID3; + + $ThisFileInfo = $getID3->analyze($filename); + + // Delete temporary file + unlink($localtempfilename); + } + fclose($fp_remote); +} + + +See /demos/demo.write.php for how to write tags. + + + +What does the returned data structure look like? +=========================================================================== + +See structure.txt + +It is recommended that you look at the output of +/demos/demo.browse.php scanning the file(s) you're interested in to +confirm what data is actually returned for any particular filetype in +general, and your files in particular, as the actual data returned +may vary considerably depending on what information is available in +the file itself. + + + +Notes +=========================================================================== + +getID3() 1.x: +If the format parser encounters a critical problem, it will return +something in $fileinfo['error'], describing the encountered error. If +a less critical error or notice is generated it will appear in +$fileinfo['warning']. Both keys may contain more than one warning or +error. If something is returned in ['error'] then the file was not +correctly parsed and returned data may or may not be correct and/or +complete. If something is returned in ['warning'] (and not ['error']) +then the data that is returned is OK - usually getID3() is reporting +errors in the file that have been worked around due to known bugs in +other programs. Some warnings may indicate that the data that is +returned is OK but that some data could not be extracted due to +errors in the file. + +getID3() 2.x: +See above except errors are thrown (so you will only get one error). + + + +Disclaimer +=========================================================================== + +getID3() has been tested on many systems, on many types of files, +under many operating systems, and is generally believe to be stable +and safe. That being said, there is still the chance there is an +undiscovered and/or unfixed bug that may potentially corrupt your +file, especially within the writing functions. By using getID3() you +agree that it's not my fault if any of your files are corrupted. +In fact, I'm not liable for anything :) + + + +License +=========================================================================== + +GNU General Public License - see license.txt + +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: +Free Software Foundation, Inc. +59 Temple Place - Suite 330 +Boston, MA 02111-1307, USA. + +FAQ: +Q: Can I use getID3() in my program? Do I need a commercial license? +A: You're generally free to use getID3 however you see fit. The only + case in which you would require a commercial license is if you're + selling your closed-source program that integrates getID3. If you + sell your program including a copy of getID3, that's fine as long + as you include a copy of the sourcecode when you sell it. Or you + can distribute your code without getID3 and say "download it from + getid3.sourceforge.net" + + + +Why is it called "getID3()" if it does so much more than just that? +=========================================================================== + +v0.1 did in fact just do that. I don't have a copy of code that old, but I +could essentially write it today with a one-line function: + function getID3($filename) { return unpack('a3TAG/a30title/a30artist/a30album/a4year/a28comment/c1track/c1genreid', substr(file_get_contents($filename), -128)); } + + +Future Plans +=========================================================================== +http://www.getid3.org/phpBB3/viewforum.php?f=7 + +* Better support for MP4 container format +* Scan for appended ID3v2 tag at end of file per ID3v2.4 specs (Section 5.0) +* Support for JPEG-2000 (http://www.morgan-multimedia.com/jpeg2000_overview.htm) +* Support for MOD (mod/stm/s3m/it/xm/mtm/ult/669) +* Support for ACE (thanks Vince) +* Support for Ogg other than Vorbis, Speex and OggFlac (ie. Ogg+Xvid) +* Ability to create Xing/LAME VBR header for VBR MP3s that are missing VBR header +* Ability to "clean" ID3v2 padding (replace invalid padding with valid padding) +* Warn if MP3s change version mid-stream (in full-scan mode) +* check for corrupt/broken mid-file MP3 streams in histogram scan +* Support for lossless-compression formats + (http://www.firstpr.com.au/audiocomp/lossless/#Links) + (http://compression.ca/act-sound.html) + (http://web.inter.nl.net/users/hvdh/lossless/lossless.htm) +* Support for RIFF-INFO chunks + * http://lotto.st-andrews.ac.uk/~njh/tag_interchange.html + (thanks Nick Humfrey ) + * http://abcavi.narod.ru/sof/abcavi/infotags.htm + (thanks Kibi) +* Better support for Bink video +* http://www.hr/josip/DSP/AudioFile2.html +* http://www.pcisys.net/~melanson/codecs/ +* Detect mp3PRO +* Support for PSD +* Support for JPC +* Support for JP2 +* Support for JPX +* Support for JB2 +* Support for IFF +* Support for ICO +* Support for ANI +* Support for EXE (comments, author, etc) (thanks p*quaedackersØplanet*nl) +* Support for DVD-IFO (region, subtitles, aspect ratio, etc) + (thanks p*quaedackersØplanet*nl) +* More complete support for SWF - parsing encapsulated MP3 and/or JPEG content + (thanks n8n8Øyahoo*com) +* Support for a2b +* Optional scan-through-frames for AVI verification + (thanks rockcohenØmassive-interactive*nl) +* Support for TTF (thanks infoØbutterflyx*com) +* Support for DSS (http://www.getid3.org/phpBB3/viewtopic.php?t=171) +* Support for SMAF (http://smaf-yamaha.com/what/demo.html) + http://www.getid3.org/phpBB3/viewtopic.php?t=182 +* Support for AMR (http://www.getid3.org/phpBB3/viewtopic.php?t=195) +* Support for 3gpp (http://www.getid3.org/phpBB3/viewtopic.php?t=195) +* Support for ID4 (http://www.wackysoft.cjb.net grizlyY2KØhotmail*com) +* Parse XML data returned in Ogg comments +* Parse XML data from Quicktime SMIL metafiles (klausrathØmac*com) +* ID3v2 genre string creator function +* More complete parsing of JPG +* Support for all old-style ASF packets +* ASF/WMA/WMV tag writing +* Parse declared T??? ID3v2 text information frames, where appropriate + (thanks Christian Fritz for the idea) +* Recognize encoder: + http://www.guerillasoft.com/EncSpot2/index.html + http://ff123.net/identify.html + http://www.hydrogenaudio.org/?act=ST&f=16&t=9414 + http://www.hydrogenaudio.org/?showtopic=11785 +* Support for other OS/2 bitmap structures: Bitmap Array('BA'), + Color Icon('CI'), Color Pointer('CP'), Icon('IC'), Pointer ('PT') + http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm +* Support for WavPack RAW mode +* ASF/WMA/WMV data packet parsing +* ID3v2FrameFlagsLookupTagAlter() +* ID3v2FrameFlagsLookupFileAlter() +* obey ID3v2 tag alter/preserve/discard rules +* http://www.geocities.com/SiliconValley/Sector/9654/Softdoc/Illyrium/Aolyr.htm +* proper checking for LINK/LNK frame validity in ID3v2 writing +* proper checking for ASPI-TLEN frame validity in ID3v2 writing +* proper checking for COMR frame validity in ID3v2 writing +* http://www.geocities.co.jp/SiliconValley-Oakland/3664/index.html +* decode GEOB ID3v2 structure as encoded by RealJukebox, + decode NCON ID3v2 structure as encoded by MusicMatch + (probably won't happen - the formats are proprietary) + + + +Known Bugs/Issues in getID3() that may be fixed eventually +=========================================================================== +http://www.getid3.org/phpBB3/viewtopic.php?t=25 + +* Cannot determine bitrate for MPEG video with VBR video data + (need documentation) +* Interlace/progressive cannot be determined for MPEG video + (need documentation) +* MIDI playtime is sometimes inaccurate +* AAC-RAW mode files cannot be identified +* WavPack-RAW mode files cannot be identified +* mp4 files report lots of "Unknown QuickTime atom type" + (need documentation) +* Encrypted ASF/WMA/WMV files warn about "unhandled GUID + ASF_Content_Encryption_Object" +* Bitrate split between audio and video cannot be calculated for + NSV, only the total bitrate. (need documentation) +* All Ogg formats (Vorbis, OggFLAC, Speex) are affected by the + problem of large VorbisComments spanning multiple Ogg pages, but + but only OggVorbis files can be processed with vorbiscomment. +* The version of "head" supplied with Mac OS 10.2.8 (maybe other + versions too) does only understands a single option (-n) and + therefore fails. getID3 ignores this and returns wrong md5_data. + + + +Known Bugs/Issues in getID3() that cannot be fixed +-------------------------------------------------- +http://www.getid3.org/phpBB3/viewtopic.php?t=25 + +* 32-bit PHP installations only: + Files larger than 2GB cannot always be parsed fully by getID3() + due to limitations in the 32-bit PHP filesystem functions. + NOTE: Since v1.7.8b3 there is partial support for larger-than- + 2GB files, most of which will parse OK, as long as no critical + data is located beyond the 2GB offset. + Known will-work: + * all file formats on 64-bit PHP + * ZIP (format doesn't support files >2GB) + * FLAC (current encoders don't support files >2GB) + Known will-not-work: + * ID3v1 tags (always located at end-of-file) + * Lyrics3 tags (always located at end-of-file) + * APE tags (always located at end-of-file) + Maybe-will-work: + * Quicktime (will work if needed metadata is before 2GB offset, + that is if the file has been hinted/optimized for streaming) + * RIFF.WAV (should work fine, but gives warnings about not being + able to parse all chunks) + * RIFF.AVI (playtime will probably be wrong, is only based on + "movi" chunk that fits in the first 2GB, should issue error + to show that playtime is incorrect. Other data should be mostly + correct, assuming that data is constant throughout the file) +* PHP <= v5 on Windows cannot read UTF-8 filenames + + +Known Bugs/Issues in other programs +----------------------------------- +http://www.getid3.org/phpBB3/viewtopic.php?t=25 + +* Windows Media Player (up to v11) and iTunes (up to v10+) do + not correctly handle ID3v2.3 tags with UTF-16BE+BOM + encoding (they assume the data is UTF-16LE+BOM and either + crash (WMP) or output Asian character set (iTunes) +* Winamp (up to v2.80 at least) does not support ID3v2.4 tags, + only ID3v2.3 + see: http://forums.winamp.com/showthread.php?postid=387524 +* Some versions of Helium2 (www.helium2.com) do not write + ID3v2.4-compliant Frame Sizes, even though the tag is marked + as ID3v2.4) (detected by getID3()) +* MP3ext V3.3.17 places a non-compliant padding string at the end + of the ID3v2 header. This is supposedly fixed in v3.4b21 but + only if you manually add a registry key. This fix is not yet + confirmed. (detected by getID3()) +* CDex v1.40 (fixed by v1.50b7) writes non-compliant Ogg comment + strings, supposed to be in the format "NAME=value" but actually + written just "value" (detected by getID3()) +* Oggenc 0.9-rc3 flags the encoded file as ABR whether it's + actually ABR or VBR. +* iTunes (versions "X v2.0.3", "v3.0.1" are known-guilty, probably + other versions are too) writes ID3v2.3 comment tags using a + frame name 'COM ' which is not valid for ID3v2.3+ (it's an + ID3v2.2-style frame name) (detected by getID3()) +* MP2enc does not encode mono CBR MP2 files properly (half speed + sound and double playtime) +* MP2enc does not encode mono VBR MP2 files properly (actually + encoded as stereo) +* tooLAME does not encode mono VBR MP2 files properly (actually + encoded as stereo) +* AACenc encodes files in VBR mode (actually ABR) even if CBR is + specified +* AAC/ADIF - bitrate_mode = cbr for vbr files +* LAME 3.90-3.92 prepends one frame of null data (space for the + LAME/VBR header, but it never gets written) when encoding in CBR + mode with the DLL +* Ahead Nero encodes TwinVQF with a DSIZ value (which is supposed + to be the filesize in bytes) of "0" for TwinVQF v1.0 and "1" for + TwinVQF v2.0 (detected by getID3()) +* Ahead Nero encodes TwinVQF files 1 second shorter than they + should be +* AAC-ADTS files are always actually encoded VBR, even if CBR mode + is specified (the CBR-mode switches on the encoder enable ABR + mode, not CBR as such, but it's not possible to tell the + difference between such ABR files and true VBR) +* STREAMINFO.audio_signature in OggFLAC is always null. "The reason + it's like that is because there is no seeking support in + libOggFLAC yet, so it has no way to go back and write the + computed sum after encoding. Seeking support in Ogg FLAC is the + #1 item for the next release." - Josh Coalson (FLAC developer) + NOTE: getID3() will calculate md5_data in a method similar to + other file formats, but that value cannot be compared to the + md5_data value from FLAC data in a FLAC file format. +* STREAMINFO.audio_signature is not calculated in FLAC v0.3.0 & + v0.4.0 - getID3() will calculate md5_data in a method similar to + other file formats, but that value cannot be compared to the + md5_data value from FLAC v0.5.0+ +* RioPort (various versions including 2.0 and 3.11) tags ID3v2 with + a WCOM frame that has no data portion +* Earlier versions of Coolplayer adds illegal ID3 tags to Ogg Vorbis + files, thus making them corrupt. +* Meracl ID3 Tag Writer v1.3.4 (and older) incorrectly truncates the + last byte of data from an MP3 file when appending a new ID3v1 tag. + (detected by getID3()) +* Lossless-Audio files encoded with and without the -noseek switch + do actually differ internally and therefore cannot match md5_data +* iTunes has been known to append a new ID3v1 tag on the end of an + existing ID3v1 tag when ID3v2 tag is also present + (detected by getID3()) +* MediaMonkey may write a blank RGAD ID3v2 frame but put actual + replay gain adjustments in a series of user-defined TXXX frames + (detected and handled by getID3() since v1.9.2) + + + + +Reference material: +=========================================================================== + +[www.id3.org material now mirrored at http://id3lib.sourceforge.net/id3/] +* http://www.id3.org/id3v2.4.0-structure.txt +* http://www.id3.org/id3v2.4.0-frames.txt +* http://www.id3.org/id3v2.4.0-changes.txt +* http://www.id3.org/id3v2.3.0.txt +* http://www.id3.org/id3v2-00.txt +* http://www.id3.org/mp3frame.html +* http://minnie.tuhs.org/pipermail/mp3encoder/2001-January/001800.html +* http://www.dv.co.yu/mpgscript/mpeghdr.htm +* http://www.mp3-tech.org/programmer/frame_header.html +* http://users.belgacom.net/gc247244/extra/tag.html +* http://gabriel.mp3-tech.org/mp3infotag.html +* http://www.id3.org/iso4217.html +* http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT +* http://www.xiph.org/ogg/vorbis/doc/framing.html +* http://www.xiph.org/ogg/vorbis/doc/v-comment.html +* http://leknor.com/code/php/class.ogg.php.txt +* http://www.id3.org/iso639-2.html +* http://www.id3.org/lyrics3.html +* http://www.id3.org/lyrics3200.html +* http://www.psc.edu/general/software/packages/ieee/ieee.html +* http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html +* http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html +* http://www.jmcgowan.com/avi.html +* http://www.wotsit.org/ +* http://www.herdsoft.com/ti/davincie/davp3xo2.htm +* http://www.mathdogs.com/vorbis-illuminated/bitstream-appendix.html +* "Standard MIDI File Format" by Dustin Caldwell (from www.wotsit.org) +* http://midistudio.com/Help/GMSpecs_Patches.htm +* http://www.xiph.org/archives/vorbis/200109/0459.html +* http://www.replaygain.org/ +* http://www.lossless-audio.com/ +* http://download.microsoft.com/download/winmediatech40/Doc/1.0/WIN98MeXP/EN-US/ASF_Specification_v.1.0.exe +* http://mediaxw.sourceforge.net/files/doc/Active%20Streaming%20Format%20(ASF)%201.0%20Specification.pdf +* http://www.uni-jena.de/~pfk/mpp/sv8/ (archived at http://www.hydrogenaudio.org/musepack/klemm/www.personal.uni-jena.de/~pfk/mpp/sv8/) +* http://jfaul.de/atl/ +* http://www.uni-jena.de/~pfk/mpp/ (archived at http://www.hydrogenaudio.org/musepack/klemm/www.personal.uni-jena.de/~pfk/mpp/) +* http://www.libpng.org/pub/png/spec/png-1.2-pdg.html +* http://www.real.com/devzone/library/creating/rmsdk/doc/rmff.htm +* http://www.fastgraph.com/help/bmp_os2_header_format.html +* http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm +* http://flac.sourceforge.net/format.html +* http://www.research.att.com/projects/mpegaudio/mpeg2.html +* http://www.audiocoding.com/wiki/index.php?page=AAC +* http://libmpeg.org/mpeg4/doc/w2203tfs.pdf +* http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt +* http://developer.apple.com/techpubs/quicktime/qtdevdocs/RM/frameset.htm +* http://www.nullsoft.com/nsv/ +* http://www.wotsit.org/download.asp?f=iso9660 +* http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html +* http://www.cdroller.com/htm/readdata.html +* http://www.speex.org/manual/node10.html +* http://www.harmony-central.com/Computer/Programming/aiff-file-format.doc +* http://www.faqs.org/rfcs/rfc2361.html +* http://ghido.shelter.ro/ +* http://www.ebu.ch/tech_t3285.pdf +* http://www.sr.se/utveckling/tu/bwf +* http://ftp.aessc.org/pub/aes46-2002.pdf +* http://cartchunk.org:8080/ +* http://www.broadcastpapers.com/radio/cartchunk01.htm +* http://www.hr/josip/DSP/AudioFile2.html +* http://home.attbi.com/~chris.bagwell/AudioFormats-11.html +* http://www.pure-mac.com/extkey.html +* http://cesnet.dl.sourceforge.net/sourceforge/bonkenc/bonk-binary-format-0.9.txt +* http://www.headbands.com/gspot/ +* http://www.openswf.org/spec/SWFfileformat.html +* http://j-faul.virtualave.net/ +* http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html +* http://cui.unige.ch/OSG/info/AudioFormats/ap11.html +* http://sswf.sourceforge.net/SWFalexref.html +* http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt +* http://www-lehre.informatik.uni-osnabrueck.de/~fbstark/diplom/docs/swf/Flash_Uncovered.htm +* http://developer.apple.com/quicktime/icefloe/dispatch012.html +* http://www.csdn.net/Dev/Format/graphics/PCD.htm +* http://tta.iszf.irk.ru/ +* http://www.atsc.org/standards/a_52a.pdf +* http://www.alanwood.net/unicode/ +* http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html +* http://www.its.msstate.edu/net/real/reports/config/tags.stats +* http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt +* http://brennan.young.net/Comp/LiveStage/things.html +* http://www.multiweb.cz/twoinches/MP3inside.htm +* http://www.geocities.co.jp/SiliconValley-Oakland/3664/alittle.html#GenreExtended +* http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/ +* http://www.unicode.org/unicode/faq/utf_bom.html +* http://tta.corecodec.org/?menu=format +* http://www.scvi.net/nsvformat.htm +* http://pda.etsi.org/pda/queryform.asp +* http://cpansearch.perl.org/src/RGIBSON/Audio-DSS-0.02/lib/Audio/DSS.pm +* http://trac.musepack.net/trac/wiki/SV8Specification +* http://wyday.com/cuesharp/specification.php +* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html \ No newline at end of file diff --git a/backend/wp-includes/IXR/class-IXR-base64.php b/backend/wp-includes/IXR/class-IXR-base64.php new file mode 100644 index 0000000..910f81b --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-base64.php @@ -0,0 +1,32 @@ +data = $data; + } + + /** + * PHP4 constructor. + */ + public function IXR_Base64( $data ) { + self::__construct( $data ); + } + + function getXml() + { + return ''.base64_encode($this->data).''; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-client.php b/backend/wp-includes/IXR/class-IXR-client.php new file mode 100644 index 0000000..f66bcb3 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-client.php @@ -0,0 +1,166 @@ +server = $bits['host']; + $this->port = isset($bits['port']) ? $bits['port'] : 80; + $this->path = isset($bits['path']) ? $bits['path'] : '/'; + + // Make absolutely sure we have a path + if (!$this->path) { + $this->path = '/'; + } + + if ( ! empty( $bits['query'] ) ) { + $this->path .= '?' . $bits['query']; + } + } else { + $this->server = $server; + $this->path = $path; + $this->port = $port; + } + $this->useragent = 'The Incutio XML-RPC PHP Library'; + $this->timeout = $timeout; + } + + /** + * PHP4 constructor. + */ + public function IXR_Client( $server, $path = false, $port = 80, $timeout = 15 ) { + self::__construct( $server, $path, $port, $timeout ); + } + + function query() + { + $args = func_get_args(); + $method = array_shift($args); + $request = new IXR_Request($method, $args); + $length = $request->getLength(); + $xml = $request->getXml(); + $r = "\r\n"; + $request = "POST {$this->path} HTTP/1.0$r"; + + // Merged from WP #8145 - allow custom headers + $this->headers['Host'] = $this->server; + $this->headers['Content-Type'] = 'text/xml'; + $this->headers['User-Agent'] = $this->useragent; + $this->headers['Content-Length']= $length; + + foreach( $this->headers as $header => $value ) { + $request .= "{$header}: {$value}{$r}"; + } + $request .= $r; + + $request .= $xml; + + // Now send the request + if ($this->debug) { + echo '
      '.htmlspecialchars($request)."\n
      \n\n"; + } + + if ($this->timeout) { + $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); + } else { + $fp = @fsockopen($this->server, $this->port, $errno, $errstr); + } + if (!$fp) { + $this->error = new IXR_Error(-32300, 'transport error - could not open socket'); + return false; + } + fputs($fp, $request); + $contents = ''; + $debugContents = ''; + $gotFirstLine = false; + $gettingHeaders = true; + while (!feof($fp)) { + $line = fgets($fp, 4096); + if (!$gotFirstLine) { + // Check line for '200' + if (strstr($line, '200') === false) { + $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200'); + return false; + } + $gotFirstLine = true; + } + if (trim($line) == '') { + $gettingHeaders = false; + } + if (!$gettingHeaders) { + // merged from WP #12559 - remove trim + $contents .= $line; + } + if ($this->debug) { + $debugContents .= $line; + } + } + if ($this->debug) { + echo '
      '.htmlspecialchars($debugContents)."\n
      \n\n"; + } + + // Now parse what we've got back + $this->message = new IXR_Message($contents); + if (!$this->message->parse()) { + // XML error + $this->error = new IXR_Error(-32700, 'parse error. not well formed'); + return false; + } + + // Is the message a fault? + if ($this->message->messageType == 'fault') { + $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); + return false; + } + + // Message must be OK + return true; + } + + function getResponse() + { + // methodResponses can only have one param - return that + return $this->message->params[0]; + } + + function isError() + { + return (is_object($this->error)); + } + + function getErrorCode() + { + return $this->error->code; + } + + function getErrorMessage() + { + return $this->error->message; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-clientmulticall.php b/backend/wp-includes/IXR/class-IXR-clientmulticall.php new file mode 100644 index 0000000..bc40efd --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-clientmulticall.php @@ -0,0 +1,44 @@ +useragent = 'The Incutio XML-RPC PHP Library (multicall client)'; + } + + /** + * PHP4 constructor. + */ + public function IXR_ClientMulticall( $server, $path = false, $port = 80 ) { + self::__construct( $server, $path, $port ); + } + + function addCall() + { + $args = func_get_args(); + $methodName = array_shift($args); + $struct = array( + 'methodName' => $methodName, + 'params' => $args + ); + $this->calls[] = $struct; + } + + function query() + { + // Prepare multicall, then call the parent::query() method + return parent::query('system.multicall', $this->calls); + } +} diff --git a/backend/wp-includes/IXR/class-IXR-date.php b/backend/wp-includes/IXR/class-IXR-date.php new file mode 100644 index 0000000..7304f60 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-date.php @@ -0,0 +1,74 @@ +parseTimestamp($time); + } else { + $this->parseIso($time); + } + } + + /** + * PHP4 constructor. + */ + public function IXR_Date( $time ) { + self::__construct( $time ); + } + + function parseTimestamp($timestamp) + { + $this->year = date('Y', $timestamp); + $this->month = date('m', $timestamp); + $this->day = date('d', $timestamp); + $this->hour = date('H', $timestamp); + $this->minute = date('i', $timestamp); + $this->second = date('s', $timestamp); + $this->timezone = ''; + } + + function parseIso($iso) + { + $this->year = substr($iso, 0, 4); + $this->month = substr($iso, 4, 2); + $this->day = substr($iso, 6, 2); + $this->hour = substr($iso, 9, 2); + $this->minute = substr($iso, 12, 2); + $this->second = substr($iso, 15, 2); + $this->timezone = substr($iso, 17); + } + + function getIso() + { + return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; + } + + function getXml() + { + return ''.$this->getIso().''; + } + + function getTimestamp() + { + return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year); + } +} diff --git a/backend/wp-includes/IXR/class-IXR-error.php b/backend/wp-includes/IXR/class-IXR-error.php new file mode 100644 index 0000000..660f7d1 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-error.php @@ -0,0 +1,53 @@ +code = $code; + $this->message = htmlspecialchars($message); + } + + /** + * PHP4 constructor. + */ + public function IXR_Error( $code, $message ) { + self::__construct( $code, $message ); + } + + function getXml() + { + $xml = << + + + + + faultCode + {$this->code} + + + faultString + {$this->message} + + + + + + +EOD; + return $xml; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-introspectionserver.php b/backend/wp-includes/IXR/class-IXR-introspectionserver.php new file mode 100644 index 0000000..5628d81 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-introspectionserver.php @@ -0,0 +1,174 @@ +setCallbacks(); + $this->setCapabilities(); + $this->capabilities['introspection'] = array( + 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html', + 'specVersion' => 1 + ); + $this->addCallback( + 'system.methodSignature', + 'this:methodSignature', + array('array', 'string'), + 'Returns an array describing the return type and required parameters of a method' + ); + $this->addCallback( + 'system.getCapabilities', + 'this:getCapabilities', + array('struct'), + 'Returns a struct describing the XML-RPC specifications supported by this server' + ); + $this->addCallback( + 'system.listMethods', + 'this:listMethods', + array('array'), + 'Returns an array of available methods on this server' + ); + $this->addCallback( + 'system.methodHelp', + 'this:methodHelp', + array('string', 'string'), + 'Returns a documentation string for the specified method' + ); + } + + /** + * PHP4 constructor. + */ + public function IXR_IntrospectionServer() { + self::__construct(); + } + + function addCallback($method, $callback, $args, $help) + { + $this->callbacks[$method] = $callback; + $this->signatures[$method] = $args; + $this->help[$method] = $help; + } + + function call($methodname, $args) + { + // Make sure it's in an array + if ($args && !is_array($args)) { + $args = array($args); + } + + // Over-rides default call method, adds signature check + if (!$this->hasMethod($methodname)) { + return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.'); + } + $method = $this->callbacks[$methodname]; + $signature = $this->signatures[$methodname]; + $returnType = array_shift($signature); + + // Check the number of arguments + if (count($args) != count($signature)) { + return new IXR_Error(-32602, 'server error. wrong number of method parameters'); + } + + // Check the argument types + $ok = true; + $argsbackup = $args; + for ($i = 0, $j = count($args); $i < $j; $i++) { + $arg = array_shift($args); + $type = array_shift($signature); + switch ($type) { + case 'int': + case 'i4': + if (is_array($arg) || !is_int($arg)) { + $ok = false; + } + break; + case 'base64': + case 'string': + if (!is_string($arg)) { + $ok = false; + } + break; + case 'boolean': + if ($arg !== false && $arg !== true) { + $ok = false; + } + break; + case 'float': + case 'double': + if (!is_float($arg)) { + $ok = false; + } + break; + case 'date': + case 'dateTime.iso8601': + if (!is_a($arg, 'IXR_Date')) { + $ok = false; + } + break; + } + if (!$ok) { + return new IXR_Error(-32602, 'server error. invalid method parameters'); + } + } + // It passed the test - run the "real" method call + return parent::call($methodname, $argsbackup); + } + + function methodSignature($method) + { + if (!$this->hasMethod($method)) { + return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.'); + } + // We should be returning an array of types + $types = $this->signatures[$method]; + $return = array(); + foreach ($types as $type) { + switch ($type) { + case 'string': + $return[] = 'string'; + break; + case 'int': + case 'i4': + $return[] = 42; + break; + case 'double': + $return[] = 3.1415; + break; + case 'dateTime.iso8601': + $return[] = new IXR_Date(time()); + break; + case 'boolean': + $return[] = true; + break; + case 'base64': + $return[] = new IXR_Base64('base64'); + break; + case 'array': + $return[] = array('array'); + break; + case 'struct': + $return[] = array('struct' => 'struct'); + break; + } + } + return $return; + } + + function methodHelp($method) + { + return $this->help[$method]; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-message.php b/backend/wp-includes/IXR/class-IXR-message.php new file mode 100644 index 0000000..013eae3 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-message.php @@ -0,0 +1,234 @@ +message =& $message; + } + + /** + * PHP4 constructor. + */ + public function IXR_Message( $message ) { + self::__construct( $message ); + } + + function parse() + { + if ( ! function_exists( 'xml_parser_create' ) ) { + trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); + return false; + } + + // first remove the XML declaration + // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages + $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 ); + $this->message = trim( substr_replace( $this->message, $header, 0, 100 ) ); + if ( '' == $this->message ) { + return false; + } + + // Then remove the DOCTYPE + $header = preg_replace( '/^]*+>/i', '', substr( $this->message, 0, 200 ), 1 ); + $this->message = trim( substr_replace( $this->message, $header, 0, 200 ) ); + if ( '' == $this->message ) { + return false; + } + + // Check that the root tag is valid + $root_tag = substr( $this->message, 0, strcspn( substr( $this->message, 0, 20 ), "> \t\r\n" ) ); + if ( 'message, '<' ) ) { + return false; + } + + $this->_parser = xml_parser_create(); + // Set XML parser to take the case of tags in to account + xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false); + // Set XML parser callback functions + xml_set_object($this->_parser, $this); + xml_set_element_handler($this->_parser, 'tag_open', 'tag_close'); + xml_set_character_data_handler($this->_parser, 'cdata'); + + // 256Kb, parse in chunks to avoid the RAM usage on very large messages + $chunk_size = 262144; + + /** + * Filters the chunk size that can be used to parse an XML-RPC reponse message. + * + * @since 4.4.0 + * + * @param int $chunk_size Chunk size to parse in bytes. + */ + $chunk_size = apply_filters( 'xmlrpc_chunk_parsing_size', $chunk_size ); + + $final = false; + do { + if (strlen($this->message) <= $chunk_size) { + $final = true; + } + $part = substr($this->message, 0, $chunk_size); + $this->message = substr($this->message, $chunk_size); + if (!xml_parse($this->_parser, $part, $final)) { + return false; + } + if ($final) { + break; + } + } while (true); + xml_parser_free($this->_parser); + + // Grab the error messages, if any + if ($this->messageType == 'fault') { + $this->faultCode = $this->params[0]['faultCode']; + $this->faultString = $this->params[0]['faultString']; + } + return true; + } + + function tag_open($parser, $tag, $attr) + { + $this->_currentTagContents = ''; + $this->currentTag = $tag; + switch($tag) { + case 'methodCall': + case 'methodResponse': + case 'fault': + $this->messageType = $tag; + break; + /* Deal with stacks of arrays and structs */ + case 'data': // data is to all intents and puposes more interesting than array + $this->_arraystructstypes[] = 'array'; + $this->_arraystructs[] = array(); + break; + case 'struct': + $this->_arraystructstypes[] = 'struct'; + $this->_arraystructs[] = array(); + break; + } + } + + function cdata($parser, $cdata) + { + $this->_currentTagContents .= $cdata; + } + + function tag_close($parser, $tag) + { + $valueFlag = false; + switch($tag) { + case 'int': + case 'i4': + $value = (int)trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'double': + $value = (double)trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'string': + $value = (string)trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'dateTime.iso8601': + $value = new IXR_Date(trim($this->_currentTagContents)); + $valueFlag = true; + break; + case 'value': + // "If no type is indicated, the type is string." + if (trim($this->_currentTagContents) != '') { + $value = (string)$this->_currentTagContents; + $valueFlag = true; + } + break; + case 'boolean': + $value = (boolean)trim($this->_currentTagContents); + $valueFlag = true; + break; + case 'base64': + $value = base64_decode($this->_currentTagContents); + $valueFlag = true; + break; + /* Deal with stacks of arrays and structs */ + case 'data': + case 'struct': + $value = array_pop($this->_arraystructs); + array_pop($this->_arraystructstypes); + $valueFlag = true; + break; + case 'member': + array_pop($this->_currentStructName); + break; + case 'name': + $this->_currentStructName[] = trim($this->_currentTagContents); + break; + case 'methodName': + $this->methodName = trim($this->_currentTagContents); + break; + } + + if ($valueFlag) { + if (count($this->_arraystructs) > 0) { + // Add value to struct or array + if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') { + // Add to struct + $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value; + } else { + // Add to array + $this->_arraystructs[count($this->_arraystructs)-1][] = $value; + } + } else { + // Just add as a parameter + $this->params[] = $value; + } + } + $this->_currentTagContents = ''; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-request.php b/backend/wp-includes/IXR/class-IXR-request.php new file mode 100644 index 0000000..b00687b --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-request.php @@ -0,0 +1,54 @@ +method = $method; + $this->args = $args; + $this->xml = << + +{$this->method} + + +EOD; + foreach ($this->args as $arg) { + $this->xml .= ''; + $v = new IXR_Value($arg); + $this->xml .= $v->getXml(); + $this->xml .= "\n"; + } + $this->xml .= ''; + } + + /** + * PHP4 constructor. + */ + public function IXR_Request( $method, $args ) { + self::__construct( $method, $args ); + } + + function getLength() + { + return strlen($this->xml); + } + + function getXml() + { + return $this->xml; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-server.php b/backend/wp-includes/IXR/class-IXR-server.php new file mode 100644 index 0000000..095e445 --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-server.php @@ -0,0 +1,225 @@ +setCapabilities(); + if ($callbacks) { + $this->callbacks = $callbacks; + } + $this->setCallbacks(); + if (!$wait) { + $this->serve($data); + } + } + + /** + * PHP4 constructor. + */ + public function IXR_Server( $callbacks = false, $data = false, $wait = false ) { + self::__construct( $callbacks, $data, $wait ); + } + + function serve($data = false) + { + if (!$data) { + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') { + if ( function_exists( 'status_header' ) ) { + status_header( 405 ); // WP #20986 + header( 'Allow: POST' ); + } + header('Content-Type: text/plain'); // merged from WP #9093 + die('XML-RPC server accepts POST requests only.'); + } + + global $HTTP_RAW_POST_DATA; + if (empty($HTTP_RAW_POST_DATA)) { + // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293 + $data = file_get_contents('php://input'); + } else { + $data =& $HTTP_RAW_POST_DATA; + } + } + $this->message = new IXR_Message($data); + if (!$this->message->parse()) { + $this->error(-32700, 'parse error. not well formed'); + } + if ($this->message->messageType != 'methodCall') { + $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall'); + } + $result = $this->call($this->message->methodName, $this->message->params); + + // Is the result an error? + if (is_a($result, 'IXR_Error')) { + $this->error($result); + } + + // Encode the result + $r = new IXR_Value($result); + $resultxml = $r->getXml(); + + // Create the XML + $xml = << + + + + $resultxml + + + + + +EOD; + // Send it + $this->output($xml); + } + + function call($methodname, $args) + { + if (!$this->hasMethod($methodname)) { + return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.'); + } + $method = $this->callbacks[$methodname]; + + // Perform the callback and send the response + if (count($args) == 1) { + // If only one parameter just send that instead of the whole array + $args = $args[0]; + } + + // Are we dealing with a function or a method? + if (is_string($method) && substr($method, 0, 5) == 'this:') { + // It's a class method - check it exists + $method = substr($method, 5); + if (!method_exists($this, $method)) { + return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.'); + } + + //Call the method + $result = $this->$method($args); + } else { + // It's a function - does it exist? + if (is_array($method)) { + if (!is_callable(array($method[0], $method[1]))) { + return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); + } + } else if (!function_exists($method)) { + return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.'); + } + + // Call the function + $result = call_user_func($method, $args); + } + return $result; + } + + function error($error, $message = false) + { + // Accepts either an error object or an error code and message + if ($message && !is_object($error)) { + $error = new IXR_Error($error, $message); + } + $this->output($error->getXml()); + } + + function output($xml) + { + $charset = function_exists('get_option') ? get_option('blog_charset') : ''; + if ($charset) + $xml = ''."\n".$xml; + else + $xml = ''."\n".$xml; + $length = strlen($xml); + header('Connection: close'); + if ($charset) + header('Content-Type: text/xml; charset='.$charset); + else + header('Content-Type: text/xml'); + header('Date: '.date('r')); + echo $xml; + exit; + } + + function hasMethod($method) + { + return in_array($method, array_keys($this->callbacks)); + } + + function setCapabilities() + { + // Initialises capabilities array + $this->capabilities = array( + 'xmlrpc' => array( + 'specUrl' => 'http://www.xmlrpc.com/spec', + 'specVersion' => 1 + ), + 'faults_interop' => array( + 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', + 'specVersion' => 20010516 + ), + 'system.multicall' => array( + 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208', + 'specVersion' => 1 + ), + ); + } + + function getCapabilities($args) + { + return $this->capabilities; + } + + function setCallbacks() + { + $this->callbacks['system.getCapabilities'] = 'this:getCapabilities'; + $this->callbacks['system.listMethods'] = 'this:listMethods'; + $this->callbacks['system.multicall'] = 'this:multiCall'; + } + + function listMethods($args) + { + // Returns a list of methods - uses array_reverse to ensure user defined + // methods are listed before server defined methods + return array_reverse(array_keys($this->callbacks)); + } + + function multiCall($methodcalls) + { + // See http://www.xmlrpc.com/discuss/msgReader$1208 + $return = array(); + foreach ($methodcalls as $call) { + $method = $call['methodName']; + $params = $call['params']; + if ($method == 'system.multicall') { + $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden'); + } else { + $result = $this->call($method, $params); + } + if (is_a($result, 'IXR_Error')) { + $return[] = array( + 'faultCode' => $result->code, + 'faultString' => $result->message + ); + } else { + $return[] = array($result); + } + } + return $return; + } +} diff --git a/backend/wp-includes/IXR/class-IXR-value.php b/backend/wp-includes/IXR/class-IXR-value.php new file mode 100644 index 0000000..0fd878b --- /dev/null +++ b/backend/wp-includes/IXR/class-IXR-value.php @@ -0,0 +1,138 @@ +data = $data; + if (!$type) { + $type = $this->calculateType(); + } + $this->type = $type; + if ($type == 'struct') { + // Turn all the values in the array in to new IXR_Value objects + foreach ($this->data as $key => $value) { + $this->data[$key] = new IXR_Value($value); + } + } + if ($type == 'array') { + for ($i = 0, $j = count($this->data); $i < $j; $i++) { + $this->data[$i] = new IXR_Value($this->data[$i]); + } + } + } + + /** + * PHP4 constructor. + */ + public function IXR_Value( $data, $type = false ) { + self::__construct( $data, $type ); + } + + function calculateType() + { + if ($this->data === true || $this->data === false) { + return 'boolean'; + } + if (is_integer($this->data)) { + return 'int'; + } + if (is_double($this->data)) { + return 'double'; + } + + // Deal with IXR object types base64 and date + if (is_object($this->data) && is_a($this->data, 'IXR_Date')) { + return 'date'; + } + if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) { + return 'base64'; + } + + // If it is a normal PHP object convert it in to a struct + if (is_object($this->data)) { + $this->data = get_object_vars($this->data); + return 'struct'; + } + if (!is_array($this->data)) { + return 'string'; + } + + // We have an array - is it an array or a struct? + if ($this->isStruct($this->data)) { + return 'struct'; + } else { + return 'array'; + } + } + + function getXml() + { + // Return XML for this value + switch ($this->type) { + case 'boolean': + return ''.(($this->data) ? '1' : '0').''; + break; + case 'int': + return ''.$this->data.''; + break; + case 'double': + return ''.$this->data.''; + break; + case 'string': + return ''.htmlspecialchars($this->data).''; + break; + case 'array': + $return = ''."\n"; + foreach ($this->data as $item) { + $return .= ' '.$item->getXml()."\n"; + } + $return .= ''; + return $return; + break; + case 'struct': + $return = ''."\n"; + foreach ($this->data as $name => $value) { + $name = htmlspecialchars($name); + $return .= " $name"; + $return .= $value->getXml()."\n"; + } + $return .= ''; + return $return; + break; + case 'date': + case 'base64': + return $this->data->getXml(); + break; + } + return false; + } + + /** + * Checks whether or not the supplied array is a struct or not + * + * @param array $array + * @return bool + */ + function isStruct($array) + { + $expected = 0; + foreach ($array as $key => $value) { + if ((string)$key !== (string)$expected) { + return true; + } + $expected++; + } + return false; + } +} diff --git a/backend/wp-includes/Requests/Auth.php b/backend/wp-includes/Requests/Auth.php new file mode 100644 index 0000000..bca4109 --- /dev/null +++ b/backend/wp-includes/Requests/Auth.php @@ -0,0 +1,33 @@ +user, $this->pass) = $args; + } + } + + /** + * Register the necessary callbacks + * + * @see curl_before_send + * @see fsockopen_header + * @param Requests_Hooks $hooks Hook system + */ + public function register(Requests_Hooks &$hooks) { + $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); + $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); + } + + /** + * Set cURL parameters before the data is sent + * + * @param resource $handle cURL resource + */ + public function curl_before_send(&$handle) { + curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString()); + } + + /** + * Add extra headers to the request before sending + * + * @param string $out HTTP header string + */ + public function fsockopen_header(&$out) { + $out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString())); + } + + /** + * Get the authentication string (user:pass) + * + * @return string + */ + public function getAuthString() { + return $this->user . ':' . $this->pass; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Cookie.php b/backend/wp-includes/Requests/Cookie.php new file mode 100644 index 0000000..00fbbc7 --- /dev/null +++ b/backend/wp-includes/Requests/Cookie.php @@ -0,0 +1,500 @@ +name = $name; + $this->value = $value; + $this->attributes = $attributes; + $default_flags = array( + 'creation' => time(), + 'last-access' => time(), + 'persistent' => false, + 'host-only' => true, + ); + $this->flags = array_merge($default_flags, $flags); + + $this->reference_time = time(); + if ($reference_time !== null) { + $this->reference_time = $reference_time; + } + + $this->normalize(); + } + + /** + * Check if a cookie is expired. + * + * Checks the age against $this->reference_time to determine if the cookie + * is expired. + * + * @return boolean True if expired, false if time is valid. + */ + public function is_expired() { + // RFC6265, s. 4.1.2.2: + // If a cookie has both the Max-Age and the Expires attribute, the Max- + // Age attribute has precedence and controls the expiration date of the + // cookie. + if (isset($this->attributes['max-age'])) { + $max_age = $this->attributes['max-age']; + return $max_age < $this->reference_time; + } + + if (isset($this->attributes['expires'])) { + $expires = $this->attributes['expires']; + return $expires < $this->reference_time; + } + + return false; + } + + /** + * Check if a cookie is valid for a given URI + * + * @param Requests_IRI $uri URI to check + * @return boolean Whether the cookie is valid for the given URI + */ + public function uri_matches(Requests_IRI $uri) { + if (!$this->domain_matches($uri->host)) { + return false; + } + + if (!$this->path_matches($uri->path)) { + return false; + } + + return empty($this->attributes['secure']) || $uri->scheme === 'https'; + } + + /** + * Check if a cookie is valid for a given domain + * + * @param string $string Domain to check + * @return boolean Whether the cookie is valid for the given domain + */ + public function domain_matches($string) { + if (!isset($this->attributes['domain'])) { + // Cookies created manually; cookies created by Requests will set + // the domain to the requested domain + return true; + } + + $domain_string = $this->attributes['domain']; + if ($domain_string === $string) { + // The domain string and the string are identical. + return true; + } + + // If the cookie is marked as host-only and we don't have an exact + // match, reject the cookie + if ($this->flags['host-only'] === true) { + return false; + } + + if (strlen($string) <= strlen($domain_string)) { + // For obvious reasons, the string cannot be a suffix if the domain + // is shorter than the domain string + return false; + } + + if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { + // The domain string should be a suffix of the string. + return false; + } + + $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); + if (substr($prefix, -1) !== '.') { + // The last character of the string that is not included in the + // domain string should be a %x2E (".") character. + return false; + } + + // The string should be a host name (i.e., not an IP address). + return !preg_match('#^(.+\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $string); + } + + /** + * Check if a cookie is valid for a given path + * + * From the path-match check in RFC 6265 section 5.1.4 + * + * @param string $request_path Path to check + * @return boolean Whether the cookie is valid for the given path + */ + public function path_matches($request_path) { + if (empty($request_path)) { + // Normalize empty path to root + $request_path = '/'; + } + + if (!isset($this->attributes['path'])) { + // Cookies created manually; cookies created by Requests will set + // the path to the requested path + return true; + } + + $cookie_path = $this->attributes['path']; + + if ($cookie_path === $request_path) { + // The cookie-path and the request-path are identical. + return true; + } + + if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { + if (substr($cookie_path, -1) === '/') { + // The cookie-path is a prefix of the request-path, and the last + // character of the cookie-path is %x2F ("/"). + return true; + } + + if (substr($request_path, strlen($cookie_path), 1) === '/') { + // The cookie-path is a prefix of the request-path, and the + // first character of the request-path that is not included in + // the cookie-path is a %x2F ("/") character. + return true; + } + } + + return false; + } + + /** + * Normalize cookie and attributes + * + * @return boolean Whether the cookie was successfully normalized + */ + public function normalize() { + foreach ($this->attributes as $key => $value) { + $orig_value = $value; + $value = $this->normalize_attribute($key, $value); + if ($value === null) { + unset($this->attributes[$key]); + continue; + } + + if ($value !== $orig_value) { + $this->attributes[$key] = $value; + } + } + + return true; + } + + /** + * Parse an individual cookie attribute + * + * Handles parsing individual attributes from the cookie values. + * + * @param string $name Attribute name + * @param string|boolean $value Attribute value (string value, or true if empty/flag) + * @return mixed Value if available, or null if the attribute value is invalid (and should be skipped) + */ + protected function normalize_attribute($name, $value) { + switch (strtolower($name)) { + case 'expires': + // Expiration parsing, as per RFC 6265 section 5.2.1 + if (is_int($value)) { + return $value; + } + + $expiry_time = strtotime($value); + if ($expiry_time === false) { + return null; + } + + return $expiry_time; + + case 'max-age': + // Expiration parsing, as per RFC 6265 section 5.2.2 + if (is_int($value)) { + return $value; + } + + // Check that we have a valid age + if (!preg_match('/^-?\d+$/', $value)) { + return null; + } + + $delta_seconds = (int) $value; + if ($delta_seconds <= 0) { + $expiry_time = 0; + } + else { + $expiry_time = $this->reference_time + $delta_seconds; + } + + return $expiry_time; + + case 'domain': + // Domain normalization, as per RFC 6265 section 5.2.3 + if ($value[0] === '.') { + $value = substr($value, 1); + } + + return $value; + + default: + return $value; + } + } + + /** + * Format a cookie for a Cookie header + * + * This is used when sending cookies to a server. + * + * @return string Cookie formatted for Cookie header + */ + public function format_for_header() { + return sprintf('%s=%s', $this->name, $this->value); + } + + /** + * Format a cookie for a Cookie header + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::format_for_header} + * @return string + */ + public function formatForHeader() { + return $this->format_for_header(); + } + + /** + * Format a cookie for a Set-Cookie header + * + * This is used when sending cookies to clients. This isn't really + * applicable to client-side usage, but might be handy for debugging. + * + * @return string Cookie formatted for Set-Cookie header + */ + public function format_for_set_cookie() { + $header_value = $this->format_for_header(); + if (!empty($this->attributes)) { + $parts = array(); + foreach ($this->attributes as $key => $value) { + // Ignore non-associative attributes + if (is_numeric($key)) { + $parts[] = $value; + } + else { + $parts[] = sprintf('%s=%s', $key, $value); + } + } + + $header_value .= '; ' . implode('; ', $parts); + } + return $header_value; + } + + /** + * Format a cookie for a Set-Cookie header + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::format_for_set_cookie} + * @return string + */ + public function formatForSetCookie() { + return $this->format_for_set_cookie(); + } + + /** + * Get the cookie value + * + * Attributes and other data can be accessed via methods. + */ + public function __toString() { + return $this->value; + } + + /** + * Parse a cookie string into a cookie object + * + * Based on Mozilla's parsing code in Firefox and related projects, which + * is an intentional deviation from RFC 2109 and RFC 2616. RFC 6265 + * specifies some of this handling, but not in a thorough manner. + * + * @param string Cookie header value (from a Set-Cookie header) + * @return Requests_Cookie Parsed cookie object + */ + public static function parse($string, $name = '', $reference_time = null) { + $parts = explode(';', $string); + $kvparts = array_shift($parts); + + if (!empty($name)) { + $value = $string; + } + elseif (strpos($kvparts, '=') === false) { + // Some sites might only have a value without the equals separator. + // Deviate from RFC 6265 and pretend it was actually a blank name + // (`=foo`) + // + // https://bugzilla.mozilla.org/show_bug.cgi?id=169091 + $name = ''; + $value = $kvparts; + } + else { + list($name, $value) = explode('=', $kvparts, 2); + } + $name = trim($name); + $value = trim($value); + + // Attribute key are handled case-insensitively + $attributes = new Requests_Utility_CaseInsensitiveDictionary(); + + if (!empty($parts)) { + foreach ($parts as $part) { + if (strpos($part, '=') === false) { + $part_key = $part; + $part_value = true; + } + else { + list($part_key, $part_value) = explode('=', $part, 2); + $part_value = trim($part_value); + } + + $part_key = trim($part_key); + $attributes[$part_key] = $part_value; + } + } + + return new Requests_Cookie($name, $value, $attributes, array(), $reference_time); + } + + /** + * Parse all Set-Cookie headers from request headers + * + * @param Requests_Response_Headers $headers Headers to parse from + * @param Requests_IRI|null $origin URI for comparing cookie origins + * @param int|null $time Reference time for expiration calculation + * @return array + */ + public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { + $cookie_headers = $headers->getValues('Set-Cookie'); + if (empty($cookie_headers)) { + return array(); + } + + $cookies = array(); + foreach ($cookie_headers as $header) { + $parsed = self::parse($header, '', $time); + + // Default domain/path attributes + if (empty($parsed->attributes['domain']) && !empty($origin)) { + $parsed->attributes['domain'] = $origin->host; + $parsed->flags['host-only'] = true; + } + else { + $parsed->flags['host-only'] = false; + } + + $path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/'); + if (!$path_is_valid && !empty($origin)) { + $path = $origin->path; + + // Default path normalization as per RFC 6265 section 5.1.4 + if (substr($path, 0, 1) !== '/') { + // If the uri-path is empty or if the first character of + // the uri-path is not a %x2F ("/") character, output + // %x2F ("/") and skip the remaining steps. + $path = '/'; + } + elseif (substr_count($path, '/') === 1) { + // If the uri-path contains no more than one %x2F ("/") + // character, output %x2F ("/") and skip the remaining + // step. + $path = '/'; + } + else { + // Output the characters of the uri-path from the first + // character up to, but not including, the right-most + // %x2F ("/"). + $path = substr($path, 0, strrpos($path, '/')); + } + $parsed->attributes['path'] = $path; + } + + // Reject invalid cookie domains + if (!empty($origin) && !$parsed->domain_matches($origin->host)) { + continue; + } + + $cookies[$parsed->name] = $parsed; + } + + return $cookies; + } + + /** + * Parse all Set-Cookie headers from request headers + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie::parse_from_headers} + * @return string + */ + public static function parseFromHeaders(Requests_Response_Headers $headers) { + return self::parse_from_headers($headers); + } +} diff --git a/backend/wp-includes/Requests/Cookie/Jar.php b/backend/wp-includes/Requests/Cookie/Jar.php new file mode 100644 index 0000000..69be0fb --- /dev/null +++ b/backend/wp-includes/Requests/Cookie/Jar.php @@ -0,0 +1,175 @@ +cookies = $cookies; + } + + /** + * Normalise cookie data into a Requests_Cookie + * + * @param string|Requests_Cookie $cookie + * @return Requests_Cookie + */ + public function normalize_cookie($cookie, $key = null) { + if ($cookie instanceof Requests_Cookie) { + return $cookie; + } + + return Requests_Cookie::parse($cookie, $key); + } + + /** + * Normalise cookie data into a Requests_Cookie + * + * @codeCoverageIgnore + * @deprecated Use {@see Requests_Cookie_Jar::normalize_cookie} + * @return Requests_Cookie + */ + public function normalizeCookie($cookie, $key = null) { + return $this->normalize_cookie($cookie, $key); + } + + /** + * Check if the given item exists + * + * @param string $key Item key + * @return boolean Does the item exist? + */ + public function offsetExists($key) { + return isset($this->cookies[$key]); + } + + /** + * Get the value for the item + * + * @param string $key Item key + * @return string Item value + */ + public function offsetGet($key) { + if (!isset($this->cookies[$key])) { + return null; + } + + return $this->cookies[$key]; + } + + /** + * Set the given item + * + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) + * + * @param string $key Item name + * @param string $value Item value + */ + public function offsetSet($key, $value) { + if ($key === null) { + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); + } + + $this->cookies[$key] = $value; + } + + /** + * Unset the given header + * + * @param string $key + */ + public function offsetUnset($key) { + unset($this->cookies[$key]); + } + + /** + * Get an iterator for the data + * + * @return ArrayIterator + */ + public function getIterator() { + return new ArrayIterator($this->cookies); + } + + /** + * Register the cookie handler with the request's hooking system + * + * @param Requests_Hooker $hooks Hooking system + */ + public function register(Requests_Hooker $hooks) { + $hooks->register('requests.before_request', array($this, 'before_request')); + $hooks->register('requests.before_redirect_check', array($this, 'before_redirect_check')); + } + + /** + * Add Cookie header to a request if we have any + * + * As per RFC 6265, cookies are separated by '; ' + * + * @param string $url + * @param array $headers + * @param array $data + * @param string $type + * @param array $options + */ + public function before_request($url, &$headers, &$data, &$type, &$options) { + if (!$url instanceof Requests_IRI) { + $url = new Requests_IRI($url); + } + + if (!empty($this->cookies)) { + $cookies = array(); + foreach ($this->cookies as $key => $cookie) { + $cookie = $this->normalize_cookie($cookie, $key); + + // Skip expired cookies + if ($cookie->is_expired()) { + continue; + } + + if ($cookie->domain_matches($url->host)) { + $cookies[] = $cookie->format_for_header(); + } + } + + $headers['Cookie'] = implode('; ', $cookies); + } + } + + /** + * Parse all cookies from a response and attach them to the response + * + * @var Requests_Response $response + */ + public function before_redirect_check(Requests_Response &$return) { + $url = $return->url; + if (!$url instanceof Requests_IRI) { + $url = new Requests_IRI($url); + } + + $cookies = Requests_Cookie::parse_from_headers($return->headers, $url); + $this->cookies = array_merge($this->cookies, $cookies); + $return->cookies = $this; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Exception.php b/backend/wp-includes/Requests/Exception.php new file mode 100644 index 0000000..37d4711 --- /dev/null +++ b/backend/wp-includes/Requests/Exception.php @@ -0,0 +1,62 @@ +type = $type; + $this->data = $data; + } + + /** + * Like {@see getCode()}, but a string code. + * + * @codeCoverageIgnore + * @return string + */ + public function getType() { + return $this->type; + } + + /** + * Gives any relevant data + * + * @codeCoverageIgnore + * @return mixed + */ + public function getData() { + return $this->data; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Exception/HTTP.php b/backend/wp-includes/Requests/Exception/HTTP.php new file mode 100644 index 0000000..9ac6a87 --- /dev/null +++ b/backend/wp-includes/Requests/Exception/HTTP.php @@ -0,0 +1,71 @@ +reason = $reason; + } + + $message = sprintf('%d %s', $this->code, $this->reason); + parent::__construct($message, 'httpresponse', $data, $this->code); + } + + /** + * Get the status message + */ + public function getReason() { + return $this->reason; + } + + /** + * Get the correct exception class for a given error code + * + * @param int|bool $code HTTP status code, or false if unavailable + * @return string Exception class name to use + */ + public static function get_class($code) { + if (!$code) { + return 'Requests_Exception_HTTP_Unknown'; + } + + $class = sprintf('Requests_Exception_HTTP_%d', $code); + if (class_exists($class)) { + return $class; + } + + return 'Requests_Exception_HTTP_Unknown'; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Exception/HTTP/304.php b/backend/wp-includes/Requests/Exception/HTTP/304.php new file mode 100644 index 0000000..6799033 --- /dev/null +++ b/backend/wp-includes/Requests/Exception/HTTP/304.php @@ -0,0 +1,27 @@ +code = $data->status_code; + } + + parent::__construct($reason, $data); + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Exception/Transport.php b/backend/wp-includes/Requests/Exception/Transport.php new file mode 100644 index 0000000..e60b488 --- /dev/null +++ b/backend/wp-includes/Requests/Exception/Transport.php @@ -0,0 +1,5 @@ +type = $type; + } + + if ($code !== null) { + $this->code = $code; + } + + if ($message !== null) { + $this->reason = $message; + } + + $message = sprintf('%d %s', $this->code, $this->reason); + parent::__construct($message, $this->type, $data, $this->code); + } + + /** + * Get the error message + */ + public function getReason() { + return $this->reason; + } + +} diff --git a/backend/wp-includes/Requests/Hooker.php b/backend/wp-includes/Requests/Hooker.php new file mode 100644 index 0000000..f667ae9 --- /dev/null +++ b/backend/wp-includes/Requests/Hooker.php @@ -0,0 +1,33 @@ +0 is executed later + */ + public function register($hook, $callback, $priority = 0); + + /** + * Dispatch a message + * + * @param string $hook Hook name + * @param array $parameters Parameters to pass to callbacks + * @return boolean Successfulness + */ + public function dispatch($hook, $parameters = array()); +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Hooks.php b/backend/wp-includes/Requests/Hooks.php new file mode 100644 index 0000000..2e61c73 --- /dev/null +++ b/backend/wp-includes/Requests/Hooks.php @@ -0,0 +1,68 @@ +0 is executed later + */ + public function register($hook, $callback, $priority = 0) { + if (!isset($this->hooks[$hook])) { + $this->hooks[$hook] = array(); + } + if (!isset($this->hooks[$hook][$priority])) { + $this->hooks[$hook][$priority] = array(); + } + + $this->hooks[$hook][$priority][] = $callback; + } + + /** + * Dispatch a message + * + * @param string $hook Hook name + * @param array $parameters Parameters to pass to callbacks + * @return boolean Successfulness + */ + public function dispatch($hook, $parameters = array()) { + if (empty($this->hooks[$hook])) { + return false; + } + + foreach ($this->hooks[$hook] as $priority => $hooked) { + foreach ($hooked as $callback) { + call_user_func_array($callback, $parameters); + } + } + + return true; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/IDNAEncoder.php b/backend/wp-includes/Requests/IDNAEncoder.php new file mode 100644 index 0000000..ebbe211 --- /dev/null +++ b/backend/wp-includes/Requests/IDNAEncoder.php @@ -0,0 +1,388 @@ + 0) { + if ($position + $length > $strlen) { + throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character); + } + for ($position++; $remaining > 0; $position++) { + $value = ord($input[$position]); + + // If it is invalid, count the sequence as invalid and reprocess the current byte: + if (($value & 0xC0) !== 0x80) { + throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character); + } + + $character |= ($value & 0x3F) << (--$remaining * 6); + } + $position--; + } + + if ( + // Non-shortest form sequences are invalid + $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of ucschar codepoints + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + || ( + // Everything else not in ucschar + $character > 0xD7FF && $character < 0xF900 + || $character < 0x20 + || $character > 0x7E && $character < 0xA0 + || $character > 0xEFFFD + ) + ) { + throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character); + } + + $codepoints[] = $character; + } + + return $codepoints; + } + + /** + * RFC3492-compliant encoder + * + * @internal Pseudo-code from Section 6.3 is commented with "#" next to relevant code + * @throws Requests_Exception On character outside of the domain (never happens with Punycode) (`idna.character_outside_domain`) + * + * @param string $input UTF-8 encoded string to encode + * @return string Punycode-encoded string + */ + public static function punycode_encode($input) { + $output = ''; +# let n = initial_n + $n = self::BOOTSTRAP_INITIAL_N; +# let delta = 0 + $delta = 0; +# let bias = initial_bias + $bias = self::BOOTSTRAP_INITIAL_BIAS; +# let h = b = the number of basic code points in the input + $h = $b = 0; // see loop +# copy them to the output in order + $codepoints = self::utf8_to_codepoints($input); + $extended = array(); + + foreach ($codepoints as $char) { + if ($char < 128) { + // Character is valid ASCII + // TODO: this should also check if it's valid for a URL + $output .= chr($char); + $h++; + } + // Check if the character is non-ASCII, but below initial n + // This never occurs for Punycode, so ignore in coverage + // @codeCoverageIgnoreStart + elseif ($char < $n) { + throw new Requests_Exception('Invalid character', 'idna.character_outside_domain', $char); + } + // @codeCoverageIgnoreEnd + else { + $extended[$char] = true; + } + } + $extended = array_keys($extended); + sort($extended); + $b = $h; +# [copy them] followed by a delimiter if b > 0 + if (strlen($output) > 0) { + $output .= '-'; + } +# {if the input contains a non-basic code point < n then fail} +# while h < length(input) do begin + while ($h < count($codepoints)) { +# let m = the minimum code point >= n in the input + $m = array_shift($extended); + //printf('next code point to insert is %s' . PHP_EOL, dechex($m)); +# let delta = delta + (m - n) * (h + 1), fail on overflow + $delta += ($m - $n) * ($h + 1); +# let n = m + $n = $m; +# for each code point c in the input (in order) do begin + for ($num = 0; $num < count($codepoints); $num++) { + $c = $codepoints[$num]; +# if c < n then increment delta, fail on overflow + if ($c < $n) { + $delta++; + } +# if c == n then begin + elseif ($c === $n) { +# let q = delta + $q = $delta; +# for k = base to infinity in steps of base do begin + for ($k = self::BOOTSTRAP_BASE; ; $k += self::BOOTSTRAP_BASE) { +# let t = tmin if k <= bias {+ tmin}, or +# tmax if k >= bias + tmax, or k - bias otherwise + if ($k <= ($bias + self::BOOTSTRAP_TMIN)) { + $t = self::BOOTSTRAP_TMIN; + } + elseif ($k >= ($bias + self::BOOTSTRAP_TMAX)) { + $t = self::BOOTSTRAP_TMAX; + } + else { + $t = $k - $bias; + } +# if q < t then break + if ($q < $t) { + break; + } +# output the code point for digit t + ((q - t) mod (base - t)) + $digit = $t + (($q - $t) % (self::BOOTSTRAP_BASE - $t)); + $output .= self::digit_to_char($digit); +# let q = (q - t) div (base - t) + $q = floor(($q - $t) / (self::BOOTSTRAP_BASE - $t)); +# end + } +# output the code point for digit q + $output .= self::digit_to_char($q); +# let bias = adapt(delta, h + 1, test h equals b?) + $bias = self::adapt($delta, $h + 1, $h === $b); +# let delta = 0 + $delta = 0; +# increment h + $h++; +# end + } +# end + } +# increment delta and n + $delta++; + $n++; +# end + } + + return $output; + } + + /** + * Convert a digit to its respective character + * + * @see https://tools.ietf.org/html/rfc3492#section-5 + * @throws Requests_Exception On invalid digit (`idna.invalid_digit`) + * + * @param int $digit Digit in the range 0-35 + * @return string Single character corresponding to digit + */ + protected static function digit_to_char($digit) { + // @codeCoverageIgnoreStart + // As far as I know, this never happens, but still good to be sure. + if ($digit < 0 || $digit > 35) { + throw new Requests_Exception(sprintf('Invalid digit %d', $digit), 'idna.invalid_digit', $digit); + } + // @codeCoverageIgnoreEnd + $digits = 'abcdefghijklmnopqrstuvwxyz0123456789'; + return substr($digits, $digit, 1); + } + + /** + * Adapt the bias + * + * @see https://tools.ietf.org/html/rfc3492#section-6.1 + * @param int $delta + * @param int $numpoints + * @param bool $firsttime + * @return int New bias + */ + protected static function adapt($delta, $numpoints, $firsttime) { +# function adapt(delta,numpoints,firsttime): +# if firsttime then let delta = delta div damp + if ($firsttime) { + $delta = floor($delta / self::BOOTSTRAP_DAMP); + } +# else let delta = delta div 2 + else { + $delta = floor($delta / 2); + } +# let delta = delta + (delta div numpoints) + $delta += floor($delta / $numpoints); +# let k = 0 + $k = 0; +# while delta > ((base - tmin) * tmax) div 2 do begin + $max = floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN) * self::BOOTSTRAP_TMAX) / 2); + while ($delta > $max) { +# let delta = delta div (base - tmin) + $delta = floor($delta / (self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN)); +# let k = k + base + $k += self::BOOTSTRAP_BASE; +# end + } +# return k + (((base - tmin + 1) * delta) div (delta + skew)) + return $k + floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN + 1) * $delta) / ($delta + self::BOOTSTRAP_SKEW)); + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/IPv6.php b/backend/wp-includes/Requests/IPv6.php new file mode 100644 index 0000000..204dbd7 --- /dev/null +++ b/backend/wp-includes/Requests/IPv6.php @@ -0,0 +1,190 @@ + FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 + * + * @author Alexander Merz + * @author elfrink at introweb dot nl + * @author Josh Peck + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @param string $ip An IPv6 address + * @return string The uncompressed IPv6 address + */ + public static function uncompress($ip) { + if (substr_count($ip, '::') !== 1) { + return $ip; + } + + list($ip1, $ip2) = explode('::', $ip); + $c1 = ($ip1 === '') ? -1 : substr_count($ip1, ':'); + $c2 = ($ip2 === '') ? -1 : substr_count($ip2, ':'); + + if (strpos($ip2, '.') !== false) { + $c2++; + } + // :: + if ($c1 === -1 && $c2 === -1) { + $ip = '0:0:0:0:0:0:0:0'; + } + // ::xxx + else if ($c1 === -1) { + $fill = str_repeat('0:', 7 - $c2); + $ip = str_replace('::', $fill, $ip); + } + // xxx:: + else if ($c2 === -1) { + $fill = str_repeat(':0', 7 - $c1); + $ip = str_replace('::', $fill, $ip); + } + // xxx::xxx + else { + $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); + $ip = str_replace('::', $fill, $ip); + } + return $ip; + } + + /** + * Compresses an IPv6 address + * + * RFC 4291 allows you to compress consecutive zero pieces in an address to + * '::'. This method expects a valid IPv6 address and compresses consecutive + * zero pieces to '::'. + * + * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 + * 0:0:0:0:0:0:0:1 -> ::1 + * + * @see uncompress() + * @param string $ip An IPv6 address + * @return string The compressed IPv6 address + */ + public static function compress($ip) { + // Prepare the IP to be compressed + $ip = self::uncompress($ip); + $ip_parts = self::split_v6_v4($ip); + + // Replace all leading zeros + $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); + + // Find bunches of zeros + if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) { + $max = 0; + $pos = null; + foreach ($matches[0] as $match) { + if (strlen($match[0]) > $max) { + $max = strlen($match[0]); + $pos = $match[1]; + } + } + + $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); + } + + if ($ip_parts[1] !== '') { + return implode(':', $ip_parts); + } + else { + return $ip_parts[0]; + } + } + + /** + * Splits an IPv6 address into the IPv6 and IPv4 representation parts + * + * RFC 4291 allows you to represent the last two parts of an IPv6 address + * using the standard IPv4 representation + * + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 + * + * @param string $ip An IPv6 address + * @return string[] [0] contains the IPv6 represented part, and [1] the IPv4 represented part + */ + protected static function split_v6_v4($ip) { + if (strpos($ip, '.') !== false) { + $pos = strrpos($ip, ':'); + $ipv6_part = substr($ip, 0, $pos); + $ipv4_part = substr($ip, $pos + 1); + return array($ipv6_part, $ipv4_part); + } + else { + return array($ip, ''); + } + } + + /** + * Checks an IPv6 address + * + * Checks if the given IP is a valid IPv6 address + * + * @param string $ip An IPv6 address + * @return bool true if $ip is a valid IPv6 address + */ + public static function check_ipv6($ip) { + $ip = self::uncompress($ip); + list($ipv6, $ipv4) = self::split_v6_v4($ip); + $ipv6 = explode(':', $ipv6); + $ipv4 = explode('.', $ipv4); + if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) { + foreach ($ipv6 as $ipv6_part) { + // The section can't be empty + if ($ipv6_part === '') { + return false; + } + + // Nor can it be over four characters + if (strlen($ipv6_part) > 4) { + return false; + } + + // Remove leading zeros (this is safe because of the above) + $ipv6_part = ltrim($ipv6_part, '0'); + if ($ipv6_part === '') { + $ipv6_part = '0'; + } + + // Check the value is valid + $value = hexdec($ipv6_part); + if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) { + return false; + } + } + if (count($ipv4) === 4) { + foreach ($ipv4 as $ipv4_part) { + $value = (int) $ipv4_part; + if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) { + return false; + } + } + } + return true; + } + else { + return false; + } + } +} diff --git a/backend/wp-includes/Requests/IRI.php b/backend/wp-includes/Requests/IRI.php new file mode 100644 index 0000000..8dc2fa2 --- /dev/null +++ b/backend/wp-includes/Requests/IRI.php @@ -0,0 +1,1084 @@ + array( + 'port' => 674 + ), + 'dict' => array( + 'port' => 2628 + ), + 'file' => array( + 'ihost' => 'localhost' + ), + 'http' => array( + 'port' => 80, + ), + 'https' => array( + 'port' => 443, + ), + ); + + /** + * Return the entire IRI when you try and read the object as a string + * + * @return string + */ + public function __toString() { + return $this->get_iri(); + } + + /** + * Overload __set() to provide access via properties + * + * @param string $name Property name + * @param mixed $value Property value + */ + public function __set($name, $value) { + if (method_exists($this, 'set_' . $name)) { + call_user_func(array($this, 'set_' . $name), $value); + } + elseif ( + $name === 'iauthority' + || $name === 'iuserinfo' + || $name === 'ihost' + || $name === 'ipath' + || $name === 'iquery' + || $name === 'ifragment' + ) { + call_user_func(array($this, 'set_' . substr($name, 1)), $value); + } + } + + /** + * Overload __get() to provide access via properties + * + * @param string $name Property name + * @return mixed + */ + public function __get($name) { + // isset() returns false for null, we don't want to do that + // Also why we use array_key_exists below instead of isset() + $props = get_object_vars($this); + + if ( + $name === 'iri' || + $name === 'uri' || + $name === 'iauthority' || + $name === 'authority' + ) { + $method = 'get_' . $name; + $return = $this->$method(); + } + elseif (array_key_exists($name, $props)) { + $return = $this->$name; + } + // host -> ihost + elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) { + $name = $prop; + $return = $this->$prop; + } + // ischeme -> scheme + elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) { + $name = $prop; + $return = $this->$prop; + } + else { + trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); + $return = null; + } + + if ($return === null && isset($this->normalization[$this->scheme][$name])) { + return $this->normalization[$this->scheme][$name]; + } + else { + return $return; + } + } + + /** + * Overload __isset() to provide access via properties + * + * @param string $name Property name + * @return bool + */ + public function __isset($name) { + return (method_exists($this, 'get_' . $name) || isset($this->$name)); + } + + /** + * Overload __unset() to provide access via properties + * + * @param string $name Property name + */ + public function __unset($name) { + if (method_exists($this, 'set_' . $name)) { + call_user_func(array($this, 'set_' . $name), ''); + } + } + + /** + * Create a new IRI object, from a specified string + * + * @param string|null $iri + */ + public function __construct($iri = null) { + $this->set_iri($iri); + } + + /** + * Create a new IRI object by resolving a relative IRI + * + * Returns false if $base is not absolute, otherwise an IRI. + * + * @param IRI|string $base (Absolute) Base IRI + * @param IRI|string $relative Relative IRI + * @return IRI|false + */ + public static function absolutize($base, $relative) { + if (!($relative instanceof Requests_IRI)) { + $relative = new Requests_IRI($relative); + } + if (!$relative->is_valid()) { + return false; + } + elseif ($relative->scheme !== null) { + return clone $relative; + } + + if (!($base instanceof Requests_IRI)) { + $base = new Requests_IRI($base); + } + if ($base->scheme === null || !$base->is_valid()) { + return false; + } + + if ($relative->get_iri() !== '') { + if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) { + $target = clone $relative; + $target->scheme = $base->scheme; + } + else { + $target = new Requests_IRI; + $target->scheme = $base->scheme; + $target->iuserinfo = $base->iuserinfo; + $target->ihost = $base->ihost; + $target->port = $base->port; + if ($relative->ipath !== '') { + if ($relative->ipath[0] === '/') { + $target->ipath = $relative->ipath; + } + elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') { + $target->ipath = '/' . $relative->ipath; + } + elseif (($last_segment = strrpos($base->ipath, '/')) !== false) { + $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; + } + else { + $target->ipath = $relative->ipath; + } + $target->ipath = $target->remove_dot_segments($target->ipath); + $target->iquery = $relative->iquery; + } + else { + $target->ipath = $base->ipath; + if ($relative->iquery !== null) { + $target->iquery = $relative->iquery; + } + elseif ($base->iquery !== null) { + $target->iquery = $base->iquery; + } + } + $target->ifragment = $relative->ifragment; + } + } + else { + $target = clone $base; + $target->ifragment = null; + } + $target->scheme_normalization(); + return $target; + } + + /** + * Parse an IRI into scheme/authority/path/query/fragment segments + * + * @param string $iri + * @return array + */ + protected function parse_iri($iri) { + $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); + $has_match = preg_match('/^((?P[^:\/?#]+):)?(\/\/(?P[^\/?#]*))?(?P[^?#]*)(\?(?P[^#]*))?(#(?P.*))?$/', $iri, $match); + if (!$has_match) { + throw new Requests_Exception('Cannot parse supplied IRI', 'iri.cannot_parse', $iri); + } + + if ($match[1] === '') { + $match['scheme'] = null; + } + if (!isset($match[3]) || $match[3] === '') { + $match['authority'] = null; + } + if (!isset($match[5])) { + $match['path'] = ''; + } + if (!isset($match[6]) || $match[6] === '') { + $match['query'] = null; + } + if (!isset($match[8]) || $match[8] === '') { + $match['fragment'] = null; + } + return $match; + } + + /** + * Remove dot segments from a path + * + * @param string $input + * @return string + */ + protected function remove_dot_segments($input) { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { + // A: If the input buffer begins with a prefix of "../" or "./", + // then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", + // where "." is a complete path segment, then replace that prefix + // with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) { + $input = substr($input, 2); + } + elseif ($input === '/.') { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", + // where ".." is a complete path segment, then replace that prefix + // with "/" in the input buffer and remove the last segment and its + // preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) { + $input = substr($input, 3); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove + // that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of + // the output buffer, including the initial "/" character (if any) + // and any subsequent characters up to, but not including, the next + // "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + /** + * Replace invalid character with percent encoding + * + * @param string $string Input string + * @param string $extra_chars Valid characters not in iunreserved or + * iprivate (this is ASCII-only) + * @param bool $iprivate Allow iprivate + * @return string + */ + protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) { + // Normalize as many pct-encoded sections as possible + $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array(&$this, 'remove_iunreserved_percent_encoded'), $string); + + // Replace invalid percent characters + $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); + + // Add unreserved and % to $extra_chars (the latter is safe because all + // pct-encoded sections are now valid). + $extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; + + // Now replace any bytes that aren't allowed with their pct-encoded versions + $position = 0; + $strlen = strlen($string); + while (($position += strspn($string, $extra_chars, $position)) < $strlen) { + $value = ord($string[$position]); + + // Start position + $start = $position; + + // By default we are valid + $valid = true; + + // No one byte sequences are valid due to the while. + // Two byte sequence: + if (($value & 0xE0) === 0xC0) { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else { + $valid = false; + $length = 1; + $remaining = 0; + } + + if ($remaining) { + if ($position + $length <= $strlen) { + for ($position++; $remaining; $position++) { + $value = ord($string[$position]); + + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) { + $character |= ($value & 0x3F) << (--$remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte: + else { + $valid = false; + $position--; + break; + } + } + } + else { + $position = $strlen - 1; + $valid = false; + } + } + + // Percent encode anything invalid or not in ucschar + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of ucschar codepoints + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + || ( + // Everything else not in ucschar + $character > 0xD7FF && $character < 0xF900 + || $character < 0xA0 + || $character > 0xEFFFD + ) + && ( + // Everything not in iprivate, if it applies + !$iprivate + || $character < 0xE000 + || $character > 0x10FFFD + ) + ) { + // If we were a character, pretend we weren't, but rather an error. + if ($valid) { + $position--; + } + + for ($j = $start; $j <= $position; $j++) { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); + $j += 2; + $position += 2; + $strlen += 2; + } + } + } + + return $string; + } + + /** + * Callback function for preg_replace_callback. + * + * Removes sequences of percent encoded bytes that represent UTF-8 + * encoded characters in iunreserved + * + * @param array $match PCRE match + * @return string Replacement + */ + protected function remove_iunreserved_percent_encoded($match) { + // As we just have valid percent encoded sequences we can just explode + // and ignore the first member of the returned array (an empty string). + $bytes = explode('%', $match[0]); + + // Initialize the new string (this is what will be returned) and that + // there are no bytes remaining in the current sequence (unsurprising + // at the first byte!). + $string = ''; + $remaining = 0; + + // Loop over each and every byte, and set $value to its value + for ($i = 1, $len = count($bytes); $i < $len; $i++) { + $value = hexdec($bytes[$i]); + + // If we're the first byte of sequence: + if (!$remaining) { + // Start position + $start = $i; + + // By default we are valid + $valid = true; + + // One byte sequence: + if ($value <= 0x7F) { + $character = $value; + $length = 1; + } + // Two byte sequence: + elseif (($value & 0xE0) === 0xC0) { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else { + $valid = false; + $remaining = 0; + } + } + // Continuation byte: + else { + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) { + $remaining--; + $character |= ($value & 0x3F) << ($remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: + else { + $valid = false; + $remaining = 0; + $i--; + } + } + + // If we've reached the end of the current byte sequence, append it to Unicode::$data + if (!$remaining) { + // Percent encode anything invalid or not in iunreserved + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of iunreserved codepoints + || $character < 0x2D + || $character > 0xEFFFD + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + // Everything else not in iunreserved (this is all BMP) + || $character === 0x2F + || $character > 0x39 && $character < 0x41 + || $character > 0x5A && $character < 0x61 + || $character > 0x7A && $character < 0x7E + || $character > 0x7E && $character < 0xA0 + || $character > 0xD7FF && $character < 0xF900 + ) { + for ($j = $start; $j <= $i; $j++) { + $string .= '%' . strtoupper($bytes[$j]); + } + } + else { + for ($j = $start; $j <= $i; $j++) { + $string .= chr(hexdec($bytes[$j])); + } + } + } + } + + // If we have any bytes left over they are invalid (i.e., we are + // mid-way through a multi-byte sequence) + if ($remaining) { + for ($j = $start; $j < $len; $j++) { + $string .= '%' . strtoupper($bytes[$j]); + } + } + + return $string; + } + + protected function scheme_normalization() { + if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { + $this->iuserinfo = null; + } + if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { + $this->ihost = null; + } + if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { + $this->port = null; + } + if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { + $this->ipath = ''; + } + if (isset($this->ihost) && empty($this->ipath)) { + $this->ipath = '/'; + } + if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { + $this->iquery = null; + } + if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { + $this->ifragment = null; + } + } + + /** + * Check if the object represents a valid IRI. This needs to be done on each + * call as some things change depending on another part of the IRI. + * + * @return bool + */ + public function is_valid() { + $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; + if ($this->ipath !== '' && + ( + $isauthority && $this->ipath[0] !== '/' || + ( + $this->scheme === null && + !$isauthority && + strpos($this->ipath, ':') !== false && + (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) + ) + ) + ) { + return false; + } + + return true; + } + + /** + * Set the entire IRI. Returns true on success, false on failure (if there + * are any invalid characters). + * + * @param string $iri + * @return bool + */ + protected function set_iri($iri) { + static $cache; + if (!$cache) { + $cache = array(); + } + + if ($iri === null) { + return true; + } + if (isset($cache[$iri])) { + list($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return) = $cache[$iri]; + return $return; + } + + $parsed = $this->parse_iri((string) $iri); + + $return = $this->set_scheme($parsed['scheme']) + && $this->set_authority($parsed['authority']) + && $this->set_path($parsed['path']) + && $this->set_query($parsed['query']) + && $this->set_fragment($parsed['fragment']); + + $cache[$iri] = array($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return); + return $return; + } + + /** + * Set the scheme. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $scheme + * @return bool + */ + protected function set_scheme($scheme) { + if ($scheme === null) { + $this->scheme = null; + } + elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) { + $this->scheme = null; + return false; + } + else { + $this->scheme = strtolower($scheme); + } + return true; + } + + /** + * Set the authority. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $authority + * @return bool + */ + protected function set_authority($authority) { + static $cache; + if (!$cache) { + $cache = array(); + } + + if ($authority === null) { + $this->iuserinfo = null; + $this->ihost = null; + $this->port = null; + return true; + } + if (isset($cache[$authority])) { + list($this->iuserinfo, + $this->ihost, + $this->port, + $return) = $cache[$authority]; + + return $return; + } + + $remaining = $authority; + if (($iuserinfo_end = strrpos($remaining, '@')) !== false) { + $iuserinfo = substr($remaining, 0, $iuserinfo_end); + $remaining = substr($remaining, $iuserinfo_end + 1); + } + else { + $iuserinfo = null; + } + if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) { + $port = substr($remaining, $port_start + 1); + if ($port === false || $port === '') { + $port = null; + } + $remaining = substr($remaining, 0, $port_start); + } + else { + $port = null; + } + + $return = $this->set_userinfo($iuserinfo) && + $this->set_host($remaining) && + $this->set_port($port); + + $cache[$authority] = array($this->iuserinfo, + $this->ihost, + $this->port, + $return); + + return $return; + } + + /** + * Set the iuserinfo. + * + * @param string $iuserinfo + * @return bool + */ + protected function set_userinfo($iuserinfo) { + if ($iuserinfo === null) { + $this->iuserinfo = null; + } + else { + $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); + $this->scheme_normalization(); + } + + return true; + } + + /** + * Set the ihost. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $ihost + * @return bool + */ + protected function set_host($ihost) { + if ($ihost === null) { + $this->ihost = null; + return true; + } + if (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') { + if (Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) { + $this->ihost = '[' . Requests_IPv6::compress(substr($ihost, 1, -1)) . ']'; + } + else { + $this->ihost = null; + return false; + } + } + else { + $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); + + // Lowercase, but ignore pct-encoded sections (as they should + // remain uppercase). This must be done after the previous step + // as that can add unescaped characters. + $position = 0; + $strlen = strlen($ihost); + while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) { + if ($ihost[$position] === '%') { + $position += 3; + } + else { + $ihost[$position] = strtolower($ihost[$position]); + $position++; + } + } + + $this->ihost = $ihost; + } + + $this->scheme_normalization(); + + return true; + } + + /** + * Set the port. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $port + * @return bool + */ + protected function set_port($port) { + if ($port === null) { + $this->port = null; + return true; + } + + if (strspn($port, '0123456789') === strlen($port)) { + $this->port = (int) $port; + $this->scheme_normalization(); + return true; + } + + $this->port = null; + return false; + } + + /** + * Set the ipath. + * + * @param string $ipath + * @return bool + */ + protected function set_path($ipath) { + static $cache; + if (!$cache) { + $cache = array(); + } + + $ipath = (string) $ipath; + + if (isset($cache[$ipath])) { + $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; + } + else { + $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); + $removed = $this->remove_dot_segments($valid); + + $cache[$ipath] = array($valid, $removed); + $this->ipath = ($this->scheme !== null) ? $removed : $valid; + } + $this->scheme_normalization(); + return true; + } + + /** + * Set the iquery. + * + * @param string $iquery + * @return bool + */ + protected function set_query($iquery) { + if ($iquery === null) { + $this->iquery = null; + } + else { + $this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); + $this->scheme_normalization(); + } + return true; + } + + /** + * Set the ifragment. + * + * @param string $ifragment + * @return bool + */ + protected function set_fragment($ifragment) { + if ($ifragment === null) { + $this->ifragment = null; + } + else { + $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); + $this->scheme_normalization(); + } + return true; + } + + /** + * Convert an IRI to a URI (or parts thereof) + * + * @param string|bool IRI to convert (or false from {@see get_iri}) + * @return string|false URI if IRI is valid, false otherwise. + */ + protected function to_uri($string) { + if (!is_string($string)) { + return false; + } + + static $non_ascii; + if (!$non_ascii) { + $non_ascii = implode('', range("\x80", "\xFF")); + } + + $position = 0; + $strlen = strlen($string); + while (($position += strcspn($string, $non_ascii, $position)) < $strlen) { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); + $position += 3; + $strlen += 2; + } + + return $string; + } + + /** + * Get the complete IRI + * + * @return string + */ + protected function get_iri() { + if (!$this->is_valid()) { + return false; + } + + $iri = ''; + if ($this->scheme !== null) { + $iri .= $this->scheme . ':'; + } + if (($iauthority = $this->get_iauthority()) !== null) { + $iri .= '//' . $iauthority; + } + $iri .= $this->ipath; + if ($this->iquery !== null) { + $iri .= '?' . $this->iquery; + } + if ($this->ifragment !== null) { + $iri .= '#' . $this->ifragment; + } + + return $iri; + } + + /** + * Get the complete URI + * + * @return string + */ + protected function get_uri() { + return $this->to_uri($this->get_iri()); + } + + /** + * Get the complete iauthority + * + * @return string + */ + protected function get_iauthority() { + if ($this->iuserinfo === null && $this->ihost === null && $this->port === null) { + return null; + } + + $iauthority = ''; + if ($this->iuserinfo !== null) { + $iauthority .= $this->iuserinfo . '@'; + } + if ($this->ihost !== null) { + $iauthority .= $this->ihost; + } + if ($this->port !== null) { + $iauthority .= ':' . $this->port; + } + return $iauthority; + } + + /** + * Get the complete authority + * + * @return string + */ + protected function get_authority() { + $iauthority = $this->get_iauthority(); + if (is_string($iauthority)) { + return $this->to_uri($iauthority); + } + else { + return $iauthority; + } + } +} diff --git a/backend/wp-includes/Requests/Proxy.php b/backend/wp-includes/Requests/Proxy.php new file mode 100644 index 0000000..ac7c1d6 --- /dev/null +++ b/backend/wp-includes/Requests/Proxy.php @@ -0,0 +1,35 @@ +proxy = $args; + } + elseif (is_array($args)) { + if (count($args) == 1) { + list($this->proxy) = $args; + } + elseif (count($args) == 3) { + list($this->proxy, $this->user, $this->pass) = $args; + $this->use_authentication = true; + } + else { + throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs'); + } + } + } + + /** + * Register the necessary callbacks + * + * @since 1.6 + * @see curl_before_send + * @see fsockopen_remote_socket + * @see fsockopen_remote_host_path + * @see fsockopen_header + * @param Requests_Hooks $hooks Hook system + */ + public function register(Requests_Hooks &$hooks) { + $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); + + $hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket')); + $hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path')); + if ($this->use_authentication) { + $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); + } + } + + /** + * Set cURL parameters before the data is sent + * + * @since 1.6 + * @param resource $handle cURL resource + */ + public function curl_before_send(&$handle) { + curl_setopt($handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); + curl_setopt($handle, CURLOPT_PROXY, $this->proxy); + + if ($this->use_authentication) { + curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + curl_setopt($handle, CURLOPT_PROXYUSERPWD, $this->get_auth_string()); + } + } + + /** + * Alter remote socket information before opening socket connection + * + * @since 1.6 + * @param string $remote_socket Socket connection string + */ + public function fsockopen_remote_socket(&$remote_socket) { + $remote_socket = $this->proxy; + } + + /** + * Alter remote path before getting stream data + * + * @since 1.6 + * @param string $path Path to send in HTTP request string ("GET ...") + * @param string $url Full URL we're requesting + */ + public function fsockopen_remote_host_path(&$path, $url) { + $path = $url; + } + + /** + * Add extra headers to the request before sending + * + * @since 1.6 + * @param string $out HTTP header string + */ + public function fsockopen_header(&$out) { + $out .= sprintf("Proxy-Authorization: Basic %s\r\n", base64_encode($this->get_auth_string())); + } + + /** + * Get the authentication string (user:pass) + * + * @since 1.6 + * @return string + */ + public function get_auth_string() { + return $this->user . ':' . $this->pass; + } +} \ No newline at end of file diff --git a/backend/wp-includes/Requests/Response.php b/backend/wp-includes/Requests/Response.php new file mode 100644 index 0000000..3152fb6 --- /dev/null +++ b/backend/wp-includes/Requests/Response.php @@ -0,0 +1,121 @@ +headers = new Requests_Response_Headers(); + $this->cookies = new Requests_Cookie_Jar(); + } + + /** + * Response body + * + * @var string + */ + public $body = ''; + + /** + * Raw HTTP data from the transport + * + * @var string + */ + public $raw = ''; + + /** + * Headers, as an associative array + * + * @var Requests_Response_Headers Array-like object representing headers + */ + public $headers = array(); + + /** + * Status code, false if non-blocking + * + * @var integer|boolean + */ + public $status_code = false; + + /** + * Protocol version, false if non-blocking + * @var float|boolean + */ + public $protocol_version = false; + + /** + * Whether the request succeeded or not + * + * @var boolean + */ + public $success = false; + + /** + * Number of redirects the request used + * + * @var integer + */ + public $redirects = 0; + + /** + * URL requested + * + * @var string + */ + public $url = ''; + + /** + * Previous requests (from redirects) + * + * @var array Array of Requests_Response objects + */ + public $history = array(); + + /** + * Cookies from the request + * + * @var Requests_Cookie_Jar Array-like object representing a cookie jar + */ + public $cookies = array(); + + /** + * Is the response a redirect? + * + * @return boolean True if redirect (3xx status), false if not. + */ + public function is_redirect() { + $code = $this->status_code; + return in_array($code, array(300, 301, 302, 303, 307)) || $code > 307 && $code < 400; + } + + /** + * Throws an exception if the request was not successful + * + * @throws Requests_Exception If `$allow_redirects` is false, and code is 3xx (`response.no_redirects`) + * @throws Requests_Exception_HTTP On non-successful status code. Exception class corresponds to code (e.g. {@see Requests_Exception_HTTP_404}) + * @param boolean $allow_redirects Set to false to throw on a 3xx as well + */ + public function throw_for_status($allow_redirects = true) { + if ($this->is_redirect()) { + if (!$allow_redirects) { + throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this); + } + } + elseif (!$this->success) { + $exception = Requests_Exception_HTTP::get_class($this->status_code); + throw new $exception(null, $this); + } + } +} diff --git a/backend/wp-includes/Requests/Response/Headers.php b/backend/wp-includes/Requests/Response/Headers.php new file mode 100644 index 0000000..cc6a208 --- /dev/null +++ b/backend/wp-includes/Requests/Response/Headers.php @@ -0,0 +1,98 @@ +data[$key])) { + return null; + } + + return $this->flatten($this->data[$key]); + } + + /** + * Set the given item + * + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) + * + * @param string $key Item name + * @param string $value Item value + */ + public function offsetSet($key, $value) { + if ($key === null) { + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); + } + + $key = strtolower($key); + + if (!isset($this->data[$key])) { + $this->data[$key] = array(); + } + + $this->data[$key][] = $value; + } + + /** + * Get all values for a given header + * + * @param string $key + * @return array Header values + */ + public function getValues($key) { + $key = strtolower($key); + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * Flattens a value into a string + * + * Converts an array into a string by imploding values with a comma, as per + * RFC2616's rules for folding headers. + * + * @param string|array $value Value to flatten + * @return string Flattened value + */ + public function flatten($value) { + if (is_array($value)) { + $value = implode(',', $value); + } + + return $value; + } + + /** + * Get an iterator for the data + * + * Converts the internal + * @return ArrayIterator + */ + public function getIterator() { + return new Requests_Utility_FilteredIterator($this->data, array($this, 'flatten')); + } +} diff --git a/backend/wp-includes/Requests/SSL.php b/backend/wp-includes/Requests/SSL.php new file mode 100644 index 0000000..2b03768 --- /dev/null +++ b/backend/wp-includes/Requests/SSL.php @@ -0,0 +1,152 @@ +useragent = 'X';` + * + * @var array + */ + public $options = array(); + + /** + * Create a new session + * + * @param string|null $url Base URL for requests + * @param array $headers Default headers for requests + * @param array $data Default data for requests + * @param array $options Default options for requests + */ + public function __construct($url = null, $headers = array(), $data = array(), $options = array()) { + $this->url = $url; + $this->headers = $headers; + $this->data = $data; + $this->options = $options; + + if (empty($this->options['cookies'])) { + $this->options['cookies'] = new Requests_Cookie_Jar(); + } + } + + /** + * Get a property's value + * + * @param string $key Property key + * @return mixed|null Property value, null if none found + */ + public function __get($key) { + if (isset($this->options[$key])) { + return $this->options[$key]; + } + + return null; + } + + /** + * Set a property's value + * + * @param string $key Property key + * @param mixed $value Property value + */ + public function __set($key, $value) { + $this->options[$key] = $value; + } + + /** + * Remove a property's value + * + * @param string $key Property key + */ + public function __isset($key) { + return isset($this->options[$key]); + } + + /** + * Remove a property's value + * + * @param string $key Property key + */ + public function __unset($key) { + if (isset($this->options[$key])) { + unset($this->options[$key]); + } + } + + /**#@+ + * @see request() + * @param string $url + * @param array $headers + * @param array $options + * @return Requests_Response + */ + /** + * Send a GET request + */ + public function get($url, $headers = array(), $options = array()) { + return $this->request($url, $headers, null, Requests::GET, $options); + } + + /** + * Send a HEAD request + */ + public function head($url, $headers = array(), $options = array()) { + return $this->request($url, $headers, null, Requests::HEAD, $options); + } + + /** + * Send a DELETE request + */ + public function delete($url, $headers = array(), $options = array()) { + return $this->request($url, $headers, null, Requests::DELETE, $options); + } + /**#@-*/ + + /**#@+ + * @see request() + * @param string $url + * @param array $headers + * @param array $data + * @param array $options + * @return Requests_Response + */ + /** + * Send a POST request + */ + public function post($url, $headers = array(), $data = array(), $options = array()) { + return $this->request($url, $headers, $data, Requests::POST, $options); + } + + /** + * Send a PUT request + */ + public function put($url, $headers = array(), $data = array(), $options = array()) { + return $this->request($url, $headers, $data, Requests::PUT, $options); + } + + /** + * Send a PATCH request + * + * Note: Unlike {@see post} and {@see put}, `$headers` is required, as the + * specification recommends that should send an ETag + * + * @link https://tools.ietf.org/html/rfc5789 + */ + public function patch($url, $headers, $data = array(), $options = array()) { + return $this->request($url, $headers, $data, Requests::PATCH, $options); + } + /**#@-*/ + + /** + * Main interface for HTTP requests + * + * This method initiates a request and sends it via a transport before + * parsing. + * + * @see Requests::request() + * + * @throws Requests_Exception On invalid URLs (`nonhttp`) + * + * @param string $url URL to request + * @param array $headers Extra headers to send with the request + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param string $type HTTP request type (use Requests constants) + * @param array $options Options for the request (see {@see Requests::request}) + * @return Requests_Response + */ + public function request($url, $headers = array(), $data = array(), $type = Requests::GET, $options = array()) { + $request = $this->merge_request(compact('url', 'headers', 'data', 'options')); + + return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']); + } + + /** + * Send multiple HTTP requests simultaneously + * + * @see Requests::request_multiple() + * + * @param array $requests Requests data (see {@see Requests::request_multiple}) + * @param array $options Global and default options (see {@see Requests::request}) + * @return array Responses (either Requests_Response or a Requests_Exception object) + */ + public function request_multiple($requests, $options = array()) { + foreach ($requests as $key => $request) { + $requests[$key] = $this->merge_request($request, false); + } + + $options = array_merge($this->options, $options); + + // Disallow forcing the type, as that's a per request setting + unset($options['type']); + + return Requests::request_multiple($requests, $options); + } + + /** + * Merge a request's data with the default data + * + * @param array $request Request data (same form as {@see request_multiple}) + * @param boolean $merge_options Should we merge options as well? + * @return array Request data + */ + protected function merge_request($request, $merge_options = true) { + if ($this->url !== null) { + $request['url'] = Requests_IRI::absolutize($this->url, $request['url']); + $request['url'] = $request['url']->uri; + } + + if (empty($request['headers'])) { + $request['headers'] = array(); + } + $request['headers'] = array_merge($this->headers, $request['headers']); + + if (empty($request['data'])) { + if (is_array($this->data)) { + $request['data'] = $this->data; + } + } + elseif (is_array($request['data']) && is_array($this->data)) { + $request['data'] = array_merge($this->data, $request['data']); + } + + if ($merge_options !== false) { + $request['options'] = array_merge($this->options, $request['options']); + + // Disallow forcing the type, as that's a per request setting + unset($request['options']['type']); + } + + return $request; + } +} diff --git a/backend/wp-includes/Requests/Transport.php b/backend/wp-includes/Requests/Transport.php new file mode 100644 index 0000000..7e4a262 --- /dev/null +++ b/backend/wp-includes/Requests/Transport.php @@ -0,0 +1,41 @@ +version = $curl['version_number']; + $this->handle = curl_init(); + + curl_setopt($this->handle, CURLOPT_HEADER, false); + curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1); + if ($this->version >= self::CURL_7_10_5) { + curl_setopt($this->handle, CURLOPT_ENCODING, ''); + } + if (defined('CURLOPT_PROTOCOLS')) { + curl_setopt($this->handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + } + if (defined('CURLOPT_REDIR_PROTOCOLS')) { + curl_setopt($this->handle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); + } + } + + /** + * Destructor + */ + public function __destruct() { + if (is_resource($this->handle)) { + curl_close($this->handle); + } + } + + /** + * Perform a request + * + * @throws Requests_Exception On a cURL error (`curlerror`) + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + * @return string Raw HTTP result + */ + public function request($url, $headers = array(), $data = array(), $options = array()) { + $this->hooks = $options['hooks']; + + $this->setup_handle($url, $headers, $data, $options); + + $options['hooks']->dispatch('curl.before_send', array(&$this->handle)); + + if ($options['filename'] !== false) { + $this->stream_handle = fopen($options['filename'], 'wb'); + } + + $this->response_data = ''; + $this->response_bytes = 0; + $this->response_byte_limit = false; + if ($options['max_bytes'] !== false) { + $this->response_byte_limit = $options['max_bytes']; + } + + if (isset($options['verify'])) { + if ($options['verify'] === false) { + curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($this->handle, CURLOPT_SSL_VERIFYPEER, 0); + } + elseif (is_string($options['verify'])) { + curl_setopt($this->handle, CURLOPT_CAINFO, $options['verify']); + } + } + + if (isset($options['verifyname']) && $options['verifyname'] === false) { + curl_setopt($this->handle, CURLOPT_SSL_VERIFYHOST, 0); + } + + curl_exec($this->handle); + $response = $this->response_data; + + $options['hooks']->dispatch('curl.after_send', array()); + + if (curl_errno($this->handle) === 23 || curl_errno($this->handle) === 61) { + // Reset encoding and try again + curl_setopt($this->handle, CURLOPT_ENCODING, 'none'); + + $this->response_data = ''; + $this->response_bytes = 0; + curl_exec($this->handle); + $response = $this->response_data; + } + + $this->process_response($response, $options); + + // Need to remove the $this reference from the curl handle. + // Otherwise Requests_Transport_cURL wont be garbage collected and the curl_close() will never be called. + curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, null); + curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, null); + + return $this->headers; + } + + /** + * Send multiple requests simultaneously + * + * @param array $requests Request data + * @param array $options Global options + * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well) + */ + public function request_multiple($requests, $options) { + // If you're not requesting, we can't get any responses ¯\_(ツ)_/¯ + if (empty($requests)) { + return array(); + } + + $multihandle = curl_multi_init(); + $subrequests = array(); + $subhandles = array(); + + $class = get_class($this); + foreach ($requests as $id => $request) { + $subrequests[$id] = new $class(); + $subhandles[$id] = $subrequests[$id]->get_subrequest_handle($request['url'], $request['headers'], $request['data'], $request['options']); + $request['options']['hooks']->dispatch('curl.before_multi_add', array(&$subhandles[$id])); + curl_multi_add_handle($multihandle, $subhandles[$id]); + } + + $completed = 0; + $responses = array(); + + $request['options']['hooks']->dispatch('curl.before_multi_exec', array(&$multihandle)); + + do { + $active = false; + + do { + $status = curl_multi_exec($multihandle, $active); + } + while ($status === CURLM_CALL_MULTI_PERFORM); + + $to_process = array(); + + // Read the information as needed + while ($done = curl_multi_info_read($multihandle)) { + $key = array_search($done['handle'], $subhandles, true); + if (!isset($to_process[$key])) { + $to_process[$key] = $done; + } + } + + // Parse the finished requests before we start getting the new ones + foreach ($to_process as $key => $done) { + $options = $requests[$key]['options']; + if (CURLE_OK !== $done['result']) { + //get error string for handle. + $reason = curl_error($done['handle']); + $exception = new Requests_Exception_Transport_cURL( + $reason, + Requests_Exception_Transport_cURL::EASY, + $done['handle'], + $done['result'] + ); + $responses[$key] = $exception; + $options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key])); + } + else { + $responses[$key] = $subrequests[$key]->process_response($subrequests[$key]->response_data, $options); + + $options['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$key], $requests[$key])); + } + + curl_multi_remove_handle($multihandle, $done['handle']); + curl_close($done['handle']); + + if (!is_string($responses[$key])) { + $options['hooks']->dispatch('multiple.request.complete', array(&$responses[$key], $key)); + } + $completed++; + } + } + while ($active || $completed < count($subrequests)); + + $request['options']['hooks']->dispatch('curl.after_multi_exec', array(&$multihandle)); + + curl_multi_close($multihandle); + + return $responses; + } + + /** + * Get the cURL handle for use in a multi-request + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + * @return resource Subrequest's cURL handle + */ + public function &get_subrequest_handle($url, $headers, $data, $options) { + $this->setup_handle($url, $headers, $data, $options); + + if ($options['filename'] !== false) { + $this->stream_handle = fopen($options['filename'], 'wb'); + } + + $this->response_data = ''; + $this->response_bytes = 0; + $this->response_byte_limit = false; + if ($options['max_bytes'] !== false) { + $this->response_byte_limit = $options['max_bytes']; + } + $this->hooks = $options['hooks']; + + return $this->handle; + } + + /** + * Setup the cURL handle for the given data + * + * @param string $url URL to request + * @param array $headers Associative array of request headers + * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD + * @param array $options Request options, see {@see Requests::response()} for documentation + */ + protected function setup_handle($url, $headers, $data, $options) { + $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); + + // Force closing the connection for old versions of cURL (<7.22). + if ( ! isset( $headers['Connection'] ) ) { + $headers['Connection'] = 'close'; + } + + $headers = Requests::flatten($headers); + + if (!empty($data)) { + $data_format = $options['data_format']; + + if ($data_format === 'query') { + $url = self::format_get($url, $data); + $data = ''; + } + elseif (!is_string($data)) { + $data = http_build_query($data, null, '&'); + } + } + + switch ($options['type']) { + case Requests::POST: + curl_setopt($this->handle, CURLOPT_POST, true); + curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); + break; + case Requests::HEAD: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + curl_setopt($this->handle, CURLOPT_NOBODY, true); + break; + case Requests::TRACE: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + break; + case Requests::PATCH: + case Requests::PUT: + case Requests::DELETE: + case Requests::OPTIONS: + default: + curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $options['type']); + if (!empty($data)) { + curl_setopt($this->handle, CURLOPT_POSTFIELDS, $data); + } + } + + // cURL requires a minimum timeout of 1 second when using the system + // DNS resolver, as it uses `alarm()`, which is second resolution only. + // There's no way to detect which DNS resolver is being used from our + // end, so we need to round up regardless of the supplied timeout. + // + // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609 + $timeout = max($options['timeout'], 1); + + if (is_int($timeout) || $this->version < self::CURL_7_16_2) { + curl_setopt($this->handle, CURLOPT_TIMEOUT, ceil($timeout)); + } + else { + curl_setopt($this->handle, CURLOPT_TIMEOUT_MS, round($timeout * 1000)); + } + + if (is_int($options['connect_timeout']) || $this->version < self::CURL_7_16_2) { + curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT, ceil($options['connect_timeout'])); + } + else { + curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, round($options['connect_timeout'] * 1000)); + } + curl_setopt($this->handle, CURLOPT_URL, $url); + curl_setopt($this->handle, CURLOPT_REFERER, $url); + curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']); + if (!empty($headers)) { + curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers); + } + if ($options['protocol_version'] === 1.1) { + curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); + } + else { + curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + } + + if (true === $options['blocking']) { + curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array(&$this, 'stream_headers')); + curl_setopt($this->handle, CURLOPT_WRITEFUNCTION, array(&$this, 'stream_body')); + curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE); + } + } + + /** + * Process a response + * + * @param string $response Response data from the body + * @param array $options Request options + * @return string HTTP response data including headers + */ + public function process_response($response, $options) { + if ($options['blocking'] === false) { + $fake_headers = ''; + $options['hooks']->dispatch('curl.after_request', array(&$fake_headers)); + return false; + } + if ($options['filename'] !== false) { + fclose($this->stream_handle); + $this->headers = trim($this->headers); + } + else { + $this->headers .= $response; + } + + if (curl_errno($this->handle)) { + $error = sprintf( + 'cURL error %s: %s', + curl_errno($this->handle), + curl_error($this->handle) + ); + throw new Requests_Exception($error, 'curlerror', $this->handle); + } + $this->info = curl_getinfo($this->handle); + + $options['hooks']->dispatch('curl.after_request', array(&$this->headers, &$this->info)); + return $this->headers; + } + + /** + * Collect the headers as they are received + * + * @param resource $handle cURL resource + * @param string $headers Header string + * @return integer Length of provided header + */ + public function stream_headers($handle, $headers) { + // Why do we do this? cURL will send both the final response and any + // interim responses, such as a 100 Continue. We don't need that. + // (We may want to keep this somewhere just in case) + if ($this->done_headers) { + $this->headers = ''; + $this->done_headers = false; + } + $this->headers .= $headers; + + if ($headers === "\r\n") { + $this->done_headers = true; + } + return strlen($headers); + } + + /** + * Collect data as it's received + * + * @since 1.6.1 + * + * @param resource $handle cURL resource + * @param string $data Body data + * @return integer Length of provided data + */ + public function stream_body($handle, $data) { + $this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit)); + $data_length = strlen($data); + + // Are we limiting the response size? + if ($this->response_byte_limit) { + if ($this->response_bytes === $this->response_byte_limit) { + // Already at maximum, move on + return $data_length; + } + + if (($this->response_bytes + $data_length) > $this->response_byte_limit) { + // Limit the length + $limited_length = ($this->response_byte_limit - $this->response_bytes); + $data = substr($data, 0, $limited_length); + } + } + + if ($this->stream_handle) { + fwrite($this->stream_handle, $data); + } + else { + $this->response_data .= $data; + } + + $this->response_bytes += strlen($data); + return $data_length; + } + + /** + * Format a URL given GET data + * + * @param string $url + * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query} + * @return string URL with data + */ + protected static function format_get($url, $data) { + if (!empty($data)) { + $url_parts = parse_url($url); + if (empty($url_parts['query'])) { + $query = $url_parts['query'] = ''; + } + else { + $query = $url_parts['query']; + } + + $query .= '&' . http_build_query($data, null, '&'); + $query = trim($query, '&'); + + if (empty($url_parts['query'])) { + $url .= '?' . $query; + } + else { + $url = str_replace($url_parts['query'], $query, $url); + } + } + return $url; + } + + /** + * Whether this transport is valid + * + * @codeCoverageIgnore + * @return boolean True if the transport is valid, false otherwise. + */ + public static function test($capabilities = array()) { + if (!function_exists('curl_init') || !function_exists('curl_exec')) { + return false; + } + + // If needed, check that our installed curl version supports SSL + if (isset($capabilities['ssl']) && $capabilities['ssl']) { + $curl_version = curl_version(); + if (!(CURL_VERSION_SSL & $curl_version['features'])) { + return false; + } + } + + return true; + } +} diff --git a/backend/wp-includes/Requests/Transport/fsockopen.php b/backend/wp-includes/Requests/Transport/fsockopen.php new file mode 100644 index 0000000..21cb56d --- /dev/null +++ b/backend/wp-includes/Requests/Transport/fsockopen.php @@ -0,0 +1,444 @@ +dispatch('fsockopen.before_request'); + + $url_parts = parse_url($url); + if (empty($url_parts)) { + throw new Requests_Exception('Invalid URL.', 'invalidurl', $url); + } + $host = $url_parts['host']; + $context = stream_context_create(); + $verifyname = false; + $case_insensitive_headers = new Requests_Utility_CaseInsensitiveDictionary($headers); + + // HTTPS support + if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { + $remote_socket = 'ssl://' . $host; + if (!isset($url_parts['port'])) { + $url_parts['port'] = 443; + } + + $context_options = array( + 'verify_peer' => true, + // 'CN_match' => $host, + 'capture_peer_cert' => true + ); + $verifyname = true; + + // SNI, if enabled (OpenSSL >=0.9.8j) + if (defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME) { + $context_options['SNI_enabled'] = true; + if (isset($options['verifyname']) && $options['verifyname'] === false) { + $context_options['SNI_enabled'] = false; + } + } + + if (isset($options['verify'])) { + if ($options['verify'] === false) { + $context_options['verify_peer'] = false; + } + elseif (is_string($options['verify'])) { + $context_options['cafile'] = $options['verify']; + } + } + + if (isset($options['verifyname']) && $options['verifyname'] === false) { + $context_options['verify_peer_name'] = false; + $verifyname = false; + } + + stream_context_set_option($context, array('ssl' => $context_options)); + } + else { + $remote_socket = 'tcp://' . $host; + } + + $this->max_bytes = $options['max_bytes']; + + if (!isset($url_parts['port'])) { + $url_parts['port'] = 80; + } + $remote_socket .= ':' . $url_parts['port']; + + set_error_handler(array($this, 'connect_error_handler'), E_WARNING | E_NOTICE); + + $options['hooks']->dispatch('fsockopen.remote_socket', array(&$remote_socket)); + + $socket = stream_socket_client($remote_socket, $errno, $errstr, ceil($options['connect_timeout']), STREAM_CLIENT_CONNECT, $context); + + restore_error_handler(); + + if ($verifyname && !$this->verify_certificate_from_context($host, $context)) { + throw new Requests_Exception('SSL certificate did not match the requested domain name', 'ssl.no_match'); + } + + if (!$socket) { + if ($errno === 0) { + // Connection issue + throw new Requests_Exception(rtrim($this->connect_error), 'fsockopen.connect_error'); + } + + throw new Requests_Exception($errstr, 'fsockopenerror', null, $errno); + } + + $data_format = $options['data_format']; + + if ($data_format === 'query') { + $path = self::format_get($url_parts, $data); + $data = ''; + } + else { + $path = self::format_get($url_parts, array()); + } + + $options['hooks']->dispatch('fsockopen.remote_host_path', array(&$path, $url)); + + $request_body = ''; + $out = sprintf("%s %s HTTP/%.1f\r\n", $options['type'], $path, $options['protocol_version']); + + if ($options['type'] !== Requests::TRACE) { + if (is_array($data)) { + $request_body = http_build_query($data, null, '&'); + } + else { + $request_body = $data; + } + + if (!empty($data)) { + if (!isset($case_insensitive_headers['Content-Length'])) { + $headers['Content-Length'] = strlen($request_body); + } + + if (!isset($case_insensitive_headers['Content-Type'])) { + $headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + } + } + } + + if (!isset($case_insensitive_headers['Host'])) { + $out .= sprintf('Host: %s', $url_parts['host']); + + if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) { + $out .= ':' . $url_parts['port']; + } + $out .= "\r\n"; + } + + if (!isset($case_insensitive_headers['User-Agent'])) { + $out .= sprintf("User-Agent: %s\r\n", $options['useragent']); + } + + $accept_encoding = $this->accept_encoding(); + if (!isset($case_insensitive_headers['Accept-Encoding']) && !empty($accept_encoding)) { + $out .= sprintf("Accept-Encoding: %s\r\n", $accept_encoding); + } + + $headers = Requests::flatten($headers); + + if (!empty($headers)) { + $out .= implode($headers, "\r\n") . "\r\n"; + } + + $options['hooks']->dispatch('fsockopen.after_headers', array(&$out)); + + if (substr($out, -2) !== "\r\n") { + $out .= "\r\n"; + } + + if (!isset($case_insensitive_headers['Connection'])) { + $out .= "Connection: Close\r\n"; + } + + $out .= "\r\n" . $request_body; + + $options['hooks']->dispatch('fsockopen.before_send', array(&$out)); + + fwrite($socket, $out); + $options['hooks']->dispatch('fsockopen.after_send', array($out)); + + if (!$options['blocking']) { + fclose($socket); + $fake_headers = ''; + $options['hooks']->dispatch('fsockopen.after_request', array(&$fake_headers)); + return ''; + } + + $timeout_sec = (int) floor($options['timeout']); + if ($timeout_sec == $options['timeout']) { + $timeout_msec = 0; + } + else { + $timeout_msec = self::SECOND_IN_MICROSECONDS * $options['timeout'] % self::SECOND_IN_MICROSECONDS; + } + stream_set_timeout($socket, $timeout_sec, $timeout_msec); + + $response = $body = $headers = ''; + $this->info = stream_get_meta_data($socket); + $size = 0; + $doingbody = false; + $download = false; + if ($options['filename']) { + $download = fopen($options['filename'], 'wb'); + } + + while (!feof($socket)) { + $this->info = stream_get_meta_data($socket); + if ($this->info['timed_out']) { + throw new Requests_Exception('fsocket timed out', 'timeout'); + } + + $block = fread($socket, Requests::BUFFER_SIZE); + if (!$doingbody) { + $response .= $block; + if (strpos($response, "\r\n\r\n")) { + list($headers, $block) = explode("\r\n\r\n", $response, 2); + $doingbody = true; + } + } + + // Are we in body mode now? + if ($doingbody) { + $options['hooks']->dispatch('request.progress', array($block, $size, $this->max_bytes)); + $data_length = strlen($block); + if ($this->max_bytes) { + // Have we already hit a limit? + if ($size === $this->max_bytes) { + continue; + } + if (($size + $data_length) > $this->max_bytes) { + // Limit the length + $limited_length = ($this->max_bytes - $size); + $block = substr($block, 0, $limited_length); + } + } + + $size += strlen($block); + if ($download) { + fwrite($download, $block); + } + else { + $body .= $block; + } + } + } + $this->headers = $headers; + + if ($download) { + fclose($download); + } + else { + $this->headers .= "\r\n\r\n" . $body; + } + fclose($socket); + + $options['hooks']->dispatch('fsockopen.after_request', array(&$this->headers, &$this->info)); + return $this->headers; + } + + /** + * Send multiple requests simultaneously + * + * @param array $requests Request data (array of 'url', 'headers', 'data', 'options') as per {@see Requests_Transport::request} + * @param array $options Global options, see {@see Requests::response()} for documentation + * @return array Array of Requests_Response objects (may contain Requests_Exception or string responses as well) + */ + public function request_multiple($requests, $options) { + $responses = array(); + $class = get_class($this); + foreach ($requests as $id => $request) { + try { + $handler = new $class(); + $responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']); + + $request['options']['hooks']->dispatch('transport.internal.parse_response', array(&$responses[$id], $request)); + } + catch (Requests_Exception $e) { + $responses[$id] = $e; + } + + if (!is_string($responses[$id])) { + $request['options']['hooks']->dispatch('multiple.request.complete', array(&$responses[$id], $id)); + } + } + + return $responses; + } + + /** + * Retrieve the encodings we can accept + * + * @return string Accept-Encoding header value + */ + protected static function accept_encoding() { + $type = array(); + if (function_exists('gzinflate')) { + $type[] = 'deflate;q=1.0'; + } + + if (function_exists('gzuncompress')) { + $type[] = 'compress;q=0.5'; + } + + $type[] = 'gzip;q=0.5'; + + return implode(', ', $type); + } + + /** + * Format a URL given GET data + * + * @param array $url_parts + * @param array|object $data Data to build query using, see {@see https://secure.php.net/http_build_query} + * @return string URL with data + */ + protected static function format_get($url_parts, $data) { + if (!empty($data)) { + if (empty($url_parts['query'])) { + $url_parts['query'] = ''; + } + + $url_parts['query'] .= '&' . http_build_query($data, null, '&'); + $url_parts['query'] = trim($url_parts['query'], '&'); + } + if (isset($url_parts['path'])) { + if (isset($url_parts['query'])) { + $get = $url_parts['path'] . '?' . $url_parts['query']; + } + else { + $get = $url_parts['path']; + } + } + else { + $get = '/'; + } + return $get; + } + + /** + * Error handler for stream_socket_client() + * + * @param int $errno Error number (e.g. E_WARNING) + * @param string $errstr Error message + */ + public function connect_error_handler($errno, $errstr) { + // Double-check we can handle it + if (($errno & E_WARNING) === 0 && ($errno & E_NOTICE) === 0) { + // Return false to indicate the default error handler should engage + return false; + } + + $this->connect_error .= $errstr . "\n"; + return true; + } + + /** + * Verify the certificate against common name and subject alternative names + * + * Unfortunately, PHP doesn't check the certificate against the alternative + * names, leading things like 'https://www.github.com/' to be invalid. + * Instead + * + * @see https://tools.ietf.org/html/rfc2818#section-3.1 RFC2818, Section 3.1 + * + * @throws Requests_Exception On failure to connect via TLS (`fsockopen.ssl.connect_error`) + * @throws Requests_Exception On not obtaining a match for the host (`fsockopen.ssl.no_match`) + * @param string $host Host name to verify against + * @param resource $context Stream context + * @return bool + */ + public function verify_certificate_from_context($host, $context) { + $meta = stream_context_get_options($context); + + // If we don't have SSL options, then we couldn't make the connection at + // all + if (empty($meta) || empty($meta['ssl']) || empty($meta['ssl']['peer_certificate'])) { + throw new Requests_Exception(rtrim($this->connect_error), 'ssl.connect_error'); + } + + $cert = openssl_x509_parse($meta['ssl']['peer_certificate']); + + return Requests_SSL::verify_certificate($host, $cert); + } + + /** + * Whether this transport is valid + * + * @codeCoverageIgnore + * @return boolean True if the transport is valid, false otherwise. + */ + public static function test($capabilities = array()) { + if (!function_exists('fsockopen')) { + return false; + } + + // If needed, check that streams support SSL + if (isset($capabilities['ssl']) && $capabilities['ssl']) { + if (!extension_loaded('openssl') || !function_exists('openssl_x509_parse')) { + return false; + } + + // Currently broken, thanks to https://github.com/facebook/hhvm/issues/2156 + if (defined('HHVM_VERSION')) { + return false; + } + } + + return true; + } +} diff --git a/backend/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php b/backend/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php new file mode 100644 index 0000000..2c97893 --- /dev/null +++ b/backend/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php @@ -0,0 +1,103 @@ + $value) { + $this->offsetSet($key, $value); + } + } + + /** + * Check if the given item exists + * + * @param string $key Item key + * @return boolean Does the item exist? + */ + public function offsetExists($key) { + $key = strtolower($key); + return isset($this->data[$key]); + } + + /** + * Get the value for the item + * + * @param string $key Item key + * @return string Item value + */ + public function offsetGet($key) { + $key = strtolower($key); + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * Set the given item + * + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) + * + * @param string $key Item name + * @param string $value Item value + */ + public function offsetSet($key, $value) { + if ($key === null) { + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); + } + + $key = strtolower($key); + $this->data[$key] = $value; + } + + /** + * Unset the given header + * + * @param string $key + */ + public function offsetUnset($key) { + unset($this->data[strtolower($key)]); + } + + /** + * Get an iterator for the data + * + * @return ArrayIterator + */ + public function getIterator() { + return new ArrayIterator($this->data); + } + + /** + * Get the headers as an array + * + * @return array Header data + */ + public function getAll() { + return $this->data; + } +} diff --git a/backend/wp-includes/Requests/Utility/FilteredIterator.php b/backend/wp-includes/Requests/Utility/FilteredIterator.php new file mode 100644 index 0000000..76a29e7 --- /dev/null +++ b/backend/wp-includes/Requests/Utility/FilteredIterator.php @@ -0,0 +1,45 @@ +callback = $callback; + } + + /** + * Get the current item's value after filtering + * + * @return string + */ + public function current() { + $value = parent::current(); + $value = call_user_func($this->callback, $value); + return $value; + } +} diff --git a/backend/wp-includes/SimplePie/Author.php b/backend/wp-includes/SimplePie/Author.php new file mode 100644 index 0000000..bbf3812 --- /dev/null +++ b/backend/wp-includes/SimplePie/Author.php @@ -0,0 +1,157 @@ +name = $name; + $this->link = $link; + $this->email = $email; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Author's name + * + * @return string|null + */ + public function get_name() + { + if ($this->name !== null) + { + return $this->name; + } + else + { + return null; + } + } + + /** + * Author's link + * + * @return string|null + */ + public function get_link() + { + if ($this->link !== null) + { + return $this->link; + } + else + { + return null; + } + } + + /** + * Author's email address + * + * @return string|null + */ + public function get_email() + { + if ($this->email !== null) + { + return $this->email; + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Cache.php b/backend/wp-includes/SimplePie/Cache.php new file mode 100644 index 0000000..75586d7 --- /dev/null +++ b/backend/wp-includes/SimplePie/Cache.php @@ -0,0 +1,133 @@ + 'SimplePie_Cache_MySQL', + 'memcache' => 'SimplePie_Cache_Memcache', + ); + + /** + * Don't call the constructor. Please. + */ + private function __construct() { } + + /** + * Create a new SimplePie_Cache object + * + * @param string $location URL location (scheme is used to determine handler) + * @param string $filename Unique identifier for cache object + * @param string $extension 'spi' or 'spc' + * @return SimplePie_Cache_Base Type of object depends on scheme of `$location` + */ + public static function get_handler($location, $filename, $extension) + { + $type = explode(':', $location, 2); + $type = $type[0]; + if (!empty(self::$handlers[$type])) + { + $class = self::$handlers[$type]; + return new $class($location, $filename, $extension); + } + + return new SimplePie_Cache_File($location, $filename, $extension); + } + + /** + * Create a new SimplePie_Cache object + * + * @deprecated Use {@see get_handler} instead + */ + public function create($location, $filename, $extension) + { + trigger_error('Cache::create() has been replaced with Cache::get_handler(). Switch to the registry system to use this.', E_USER_DEPRECATED); + return self::get_handler($location, $filename, $extension); + } + + /** + * Register a handler + * + * @param string $type DSN type to register for + * @param string $class Name of handler class. Must implement SimplePie_Cache_Base + */ + public static function register($type, $class) + { + self::$handlers[$type] = $class; + } + + /** + * Parse a URL into an array + * + * @param string $url + * @return array + */ + public static function parse_URL($url) + { + $params = parse_url($url); + $params['extras'] = array(); + if (isset($params['query'])) + { + parse_str($params['query'], $params['extras']); + } + return $params; + } +} diff --git a/backend/wp-includes/SimplePie/Cache/Base.php b/backend/wp-includes/SimplePie/Cache/Base.php new file mode 100644 index 0000000..937e346 --- /dev/null +++ b/backend/wp-includes/SimplePie/Cache/Base.php @@ -0,0 +1,114 @@ +get_items(); + $items_by_id = array(); + + if (!empty($items)) + { + foreach ($items as $item) + { + $items_by_id[$item->get_id()] = $item; + } + + if (count($items_by_id) !== count($items)) + { + $items_by_id = array(); + foreach ($items as $item) + { + $items_by_id[$item->get_id(true)] = $item; + } + } + + if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; + } + else + { + $channel = null; + } + + if ($channel !== null) + { + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); + } + } + if (isset($data->data['items'])) + { + unset($data->data['items']); + } + if (isset($data->data['ordered_items'])) + { + unset($data->data['ordered_items']); + } + } + return array(serialize($data->data), $items_by_id); + } +} diff --git a/backend/wp-includes/SimplePie/Cache/File.php b/backend/wp-includes/SimplePie/Cache/File.php new file mode 100644 index 0000000..5797b3a --- /dev/null +++ b/backend/wp-includes/SimplePie/Cache/File.php @@ -0,0 +1,173 @@ +location = $location; + $this->filename = $name; + $this->extension = $type; + $this->name = "$this->location/$this->filename.$this->extension"; + } + + /** + * Save data to the cache + * + * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property + * @return bool Successfulness + */ + public function save($data) + { + if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) + { + if ($data instanceof SimplePie) + { + $data = $data->data; + } + + $data = serialize($data); + return (bool) file_put_contents($this->name, $data); + } + return false; + } + + /** + * Retrieve the data saved to the cache + * + * @return array Data for SimplePie::$data + */ + public function load() + { + if (file_exists($this->name) && is_readable($this->name)) + { + return unserialize(file_get_contents($this->name)); + } + return false; + } + + /** + * Retrieve the last modified time for the cache + * + * @return int Timestamp + */ + public function mtime() + { + if (file_exists($this->name)) + { + return filemtime($this->name); + } + return false; + } + + /** + * Set the last modified time to the current time + * + * @return bool Success status + */ + public function touch() + { + if (file_exists($this->name)) + { + return touch($this->name); + } + return false; + } + + /** + * Remove the cache + * + * @return bool Success status + */ + public function unlink() + { + if (file_exists($this->name)) + { + return unlink($this->name); + } + return false; + } +} diff --git a/backend/wp-includes/SimplePie/Cache/Memcache.php b/backend/wp-includes/SimplePie/Cache/Memcache.php new file mode 100644 index 0000000..fd44780 --- /dev/null +++ b/backend/wp-includes/SimplePie/Cache/Memcache.php @@ -0,0 +1,183 @@ +options = array( + 'host' => '127.0.0.1', + 'port' => 11211, + 'extras' => array( + 'timeout' => 3600, // one hour + 'prefix' => 'simplepie_', + ), + ); + $parsed = SimplePie_Cache::parse_URL($location); + $this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host']; + $this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port']; + $this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']); + $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); + + $this->cache = new Memcache(); + $this->cache->addServer($this->options['host'], (int) $this->options['port']); + } + + /** + * Save data to the cache + * + * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property + * @return bool Successfulness + */ + public function save($data) + { + if ($data instanceof SimplePie) + { + $data = $data->data; + } + return $this->cache->set($this->name, serialize($data), MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']); + } + + /** + * Retrieve the data saved to the cache + * + * @return array Data for SimplePie::$data + */ + public function load() + { + $data = $this->cache->get($this->name); + + if ($data !== false) + { + return unserialize($data); + } + return false; + } + + /** + * Retrieve the last modified time for the cache + * + * @return int Timestamp + */ + public function mtime() + { + $data = $this->cache->get($this->name); + + if ($data !== false) + { + // essentially ignore the mtime because Memcache expires on it's own + return time(); + } + + return false; + } + + /** + * Set the last modified time to the current time + * + * @return bool Success status + */ + public function touch() + { + $data = $this->cache->get($this->name); + + if ($data !== false) + { + return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->duration); + } + + return false; + } + + /** + * Remove the cache + * + * @return bool Success status + */ + public function unlink() + { + return $this->cache->delete($this->name, 0); + } +} diff --git a/backend/wp-includes/SimplePie/Cache/MySQL.php b/backend/wp-includes/SimplePie/Cache/MySQL.php new file mode 100644 index 0000000..d53ebc1 --- /dev/null +++ b/backend/wp-includes/SimplePie/Cache/MySQL.php @@ -0,0 +1,438 @@ +options = array( + 'user' => null, + 'pass' => null, + 'host' => '127.0.0.1', + 'port' => '3306', + 'path' => '', + 'extras' => array( + 'prefix' => '', + ), + ); + $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); + + // Path is prefixed with a "/" + $this->options['dbname'] = substr($this->options['path'], 1); + + try + { + $this->mysql = new PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); + } + catch (PDOException $e) + { + $this->mysql = null; + return; + } + + $this->id = $name . $type; + + if (!$query = $this->mysql->query('SHOW TABLES')) + { + $this->mysql = null; + return; + } + + $db = array(); + while ($row = $query->fetchColumn()) + { + $db[] = $row; + } + + if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db)) + { + $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))'); + if ($query === false) + { + $this->mysql = null; + } + } + + if (!in_array($this->options['extras']['prefix'] . 'items', $db)) + { + $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'); + if ($query === false) + { + $this->mysql = null; + } + } + } + + /** + * Save data to the cache + * + * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property + * @return bool Successfulness + */ + public function save($data) + { + if ($this->mysql === null) + { + return false; + } + + if ($data instanceof SimplePie) + { + $data = clone $data; + + $prepared = self::prepare_simplepie_object_for_cache($data); + + $query = $this->mysql->prepare('SELECT COUNT(*) FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed'); + $query->bindValue(':feed', $this->id); + if ($query->execute()) + { + if ($query->fetchColumn() > 0) + { + $items = count($prepared[1]); + if ($items) + { + $sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = :items, `data` = :data, `mtime` = :time WHERE `id` = :feed'; + $query = $this->mysql->prepare($sql); + $query->bindValue(':items', $items); + } + else + { + $sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed'; + $query = $this->mysql->prepare($sql); + } + + $query->bindValue(':data', $prepared[0]); + $query->bindValue(':time', time()); + $query->bindValue(':feed', $this->id); + if (!$query->execute()) + { + return false; + } + } + else + { + $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:feed, :count, :data, :time)'); + $query->bindValue(':feed', $this->id); + $query->bindValue(':count', count($prepared[1])); + $query->bindValue(':data', $prepared[0]); + $query->bindValue(':time', time()); + if (!$query->execute()) + { + return false; + } + } + + $ids = array_keys($prepared[1]); + if (!empty($ids)) + { + foreach ($ids as $id) + { + $database_ids[] = $this->mysql->quote($id); + } + + $query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `id` = ' . implode(' OR `id` = ', $database_ids) . ' AND `feed_id` = :feed'); + $query->bindValue(':feed', $this->id); + + if ($query->execute()) + { + $existing_ids = array(); + while ($row = $query->fetchColumn()) + { + $existing_ids[] = $row; + } + + $new_ids = array_diff($ids, $existing_ids); + + foreach ($new_ids as $new_id) + { + if (!($date = $prepared[1][$new_id]->get_date('U'))) + { + $date = time(); + } + + $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)'); + $query->bindValue(':feed', $this->id); + $query->bindValue(':id', $new_id); + $query->bindValue(':data', serialize($prepared[1][$new_id]->data)); + $query->bindValue(':date', $date); + if (!$query->execute()) + { + return false; + } + } + return true; + } + } + else + { + return true; + } + } + } + else + { + $query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed'); + $query->bindValue(':feed', $this->id); + if ($query->execute()) + { + if ($query->rowCount() > 0) + { + $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = 0, `data` = :data, `mtime` = :time WHERE `id` = :feed'); + $query->bindValue(':data', serialize($data)); + $query->bindValue(':time', time()); + $query->bindValue(':feed', $this->id); + if ($this->execute()) + { + return true; + } + } + else + { + $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:id, 0, :data, :time)'); + $query->bindValue(':id', $this->id); + $query->bindValue(':data', serialize($data)); + $query->bindValue(':time', time()); + if ($query->execute()) + { + return true; + } + } + } + } + return false; + } + + /** + * Retrieve the data saved to the cache + * + * @return array Data for SimplePie::$data + */ + public function load() + { + if ($this->mysql === null) + { + return false; + } + + $query = $this->mysql->prepare('SELECT `items`, `data` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); + $query->bindValue(':id', $this->id); + if ($query->execute() && ($row = $query->fetch())) + { + $data = unserialize($row[1]); + + if (isset($this->options['items'][0])) + { + $items = (int) $this->options['items'][0]; + } + else + { + $items = (int) $row[0]; + } + + if ($items !== 0) + { + if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; + } + else + { + $feed = null; + } + + if ($feed !== null) + { + $sql = 'SELECT `data` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :feed ORDER BY `posted` DESC'; + if ($items > 0) + { + $sql .= ' LIMIT ' . $items; + } + + $query = $this->mysql->prepare($sql); + $query->bindValue(':feed', $this->id); + if ($query->execute()) + { + while ($row = $query->fetchColumn()) + { + $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row); + } + } + else + { + return false; + } + } + } + return $data; + } + return false; + } + + /** + * Retrieve the last modified time for the cache + * + * @return int Timestamp + */ + public function mtime() + { + if ($this->mysql === null) + { + return false; + } + + $query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); + $query->bindValue(':id', $this->id); + if ($query->execute() && ($time = $query->fetchColumn())) + { + return $time; + } + else + { + return false; + } + } + + /** + * Set the last modified time to the current time + * + * @return bool Success status + */ + public function touch() + { + if ($this->mysql === null) + { + return false; + } + + $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id'); + $query->bindValue(':time', time()); + $query->bindValue(':id', $this->id); + if ($query->execute() && $query->rowCount() > 0) + { + return true; + } + else + { + return false; + } + } + + /** + * Remove the cache + * + * @return bool Success status + */ + public function unlink() + { + if ($this->mysql === null) + { + return false; + } + + $query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id'); + $query->bindValue(':id', $this->id); + $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); + $query2->bindValue(':id', $this->id); + if ($query->execute() && $query2->execute()) + { + return true; + } + else + { + return false; + } + } +} diff --git a/backend/wp-includes/SimplePie/Caption.php b/backend/wp-includes/SimplePie/Caption.php new file mode 100644 index 0000000..52922c5 --- /dev/null +++ b/backend/wp-includes/SimplePie/Caption.php @@ -0,0 +1,210 @@ +` captions as defined in Media RSS. + * + * Used by {@see SimplePie_Enclosure::get_caption()} and {@see SimplePie_Enclosure::get_captions()} + * + * This class can be overloaded with {@see SimplePie::set_caption_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Caption +{ + /** + * Content type + * + * @var string + * @see get_type() + */ + var $type; + + /** + * Language + * + * @var string + * @see get_language() + */ + var $lang; + + /** + * Start time + * + * @var string + * @see get_starttime() + */ + var $startTime; + + /** + * End time + * + * @var string + * @see get_endtime() + */ + var $endTime; + + /** + * Caption text + * + * @var string + * @see get_text() + */ + var $text; + + /** + * Constructor, used to input the data + * + * For documentation on all the parameters, see the corresponding + * properties and their accessors + */ + public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) + { + $this->type = $type; + $this->lang = $lang; + $this->startTime = $startTime; + $this->endTime = $endTime; + $this->text = $text; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the end time + * + * @return string|null Time in the format 'hh:mm:ss.SSS' + */ + public function get_endtime() + { + if ($this->endTime !== null) + { + return $this->endTime; + } + else + { + return null; + } + } + + /** + * Get the language + * + * @link http://tools.ietf.org/html/rfc3066 + * @return string|null Language code as per RFC 3066 + */ + public function get_language() + { + if ($this->lang !== null) + { + return $this->lang; + } + else + { + return null; + } + } + + /** + * Get the start time + * + * @return string|null Time in the format 'hh:mm:ss.SSS' + */ + public function get_starttime() + { + if ($this->startTime !== null) + { + return $this->startTime; + } + else + { + return null; + } + } + + /** + * Get the text of the caption + * + * @return string|null + */ + public function get_text() + { + if ($this->text !== null) + { + return $this->text; + } + else + { + return null; + } + } + + /** + * Get the content type (not MIME type) + * + * @return string|null Either 'text' or 'html' + */ + public function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Category.php b/backend/wp-includes/SimplePie/Category.php new file mode 100644 index 0000000..ad0407b --- /dev/null +++ b/backend/wp-includes/SimplePie/Category.php @@ -0,0 +1,157 @@ +term = $term; + $this->scheme = $scheme; + $this->label = $label; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the category identifier + * + * @return string|null + */ + public function get_term() + { + if ($this->term !== null) + { + return $this->term; + } + else + { + return null; + } + } + + /** + * Get the categorization scheme identifier + * + * @return string|null + */ + public function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + /** + * Get the human readable label + * + * @return string|null + */ + public function get_label() + { + if ($this->label !== null) + { + return $this->label; + } + else + { + return $this->get_term(); + } + } +} + diff --git a/backend/wp-includes/SimplePie/Content/Type/Sniffer.php b/backend/wp-includes/SimplePie/Content/Type/Sniffer.php new file mode 100644 index 0000000..20d053d --- /dev/null +++ b/backend/wp-includes/SimplePie/Content/Type/Sniffer.php @@ -0,0 +1,332 @@ +file = $file; + } + + /** + * Get the Content-Type of the specified file + * + * @return string Actual Content-Type + */ + public function get_type() + { + if (isset($this->file->headers['content-type'])) + { + if (!isset($this->file->headers['content-encoding']) + && ($this->file->headers['content-type'] === 'text/plain' + || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' + || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1' + || $this->file->headers['content-type'] === 'text/plain; charset=UTF-8')) + { + return $this->text_or_binary(); + } + + if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) + { + $official = substr($this->file->headers['content-type'], 0, $pos); + } + else + { + $official = $this->file->headers['content-type']; + } + $official = trim(strtolower($official)); + + if ($official === 'unknown/unknown' + || $official === 'application/unknown') + { + return $this->unknown(); + } + elseif (substr($official, -4) === '+xml' + || $official === 'text/xml' + || $official === 'application/xml') + { + return $official; + } + elseif (substr($official, 0, 6) === 'image/') + { + if ($return = $this->image()) + { + return $return; + } + else + { + return $official; + } + } + elseif ($official === 'text/html') + { + return $this->feed_or_html(); + } + else + { + return $official; + } + } + else + { + return $this->unknown(); + } + } + + /** + * Sniff text or binary + * + * @return string Actual Content-Type + */ + public function text_or_binary() + { + if (substr($this->file->body, 0, 2) === "\xFE\xFF" + || substr($this->file->body, 0, 2) === "\xFF\xFE" + || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" + || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") + { + return 'text/plain'; + } + elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) + { + return 'application/octect-stream'; + } + else + { + return 'text/plain'; + } + } + + /** + * Sniff unknown + * + * @return string Actual Content-Type + */ + public function unknown() + { + $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); + if (strtolower(substr($this->file->body, $ws, 14)) === 'file->body, $ws, 5)) === 'file->body, $ws, 7)) === 'file->body, 0, 5) === '%PDF-') + { + return 'application/pdf'; + } + elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') + { + return 'application/postscript'; + } + elseif (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") + { + return 'image/vnd.microsoft.icon'; + } + else + { + return $this->text_or_binary(); + } + } + + /** + * Sniff images + * + * @return string Actual Content-Type + */ + public function image() + { + if (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + elseif (substr($this->file->body, 0, 4) === "\x00\x00\x01\x00") + { + return 'image/vnd.microsoft.icon'; + } + else + { + return false; + } + } + + /** + * Sniff HTML + * + * @return string Actual Content-Type + */ + public function feed_or_html() + { + $len = strlen($this->file->body); + $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); + + while ($pos < $len) + { + switch ($this->file->body[$pos]) + { + case "\x09": + case "\x0A": + case "\x0D": + case "\x20": + $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); + continue 2; + + case '<': + $pos++; + break; + + default: + return 'text/html'; + } + + if (substr($this->file->body, $pos, 3) === '!--') + { + $pos += 3; + if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) + { + $pos += 3; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '!') + { + if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) + { + $pos++; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '?') + { + if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) + { + $pos += 2; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 3) === 'rss' + || substr($this->file->body, $pos, 7) === 'rdf:RDF') + { + return 'application/rss+xml'; + } + elseif (substr($this->file->body, $pos, 4) === 'feed') + { + return 'application/atom+xml'; + } + else + { + return 'text/html'; + } + } + + return 'text/html'; + } +} + diff --git a/backend/wp-includes/SimplePie/Copyright.php b/backend/wp-includes/SimplePie/Copyright.php new file mode 100644 index 0000000..57c535a --- /dev/null +++ b/backend/wp-includes/SimplePie/Copyright.php @@ -0,0 +1,130 @@ +` copyright tags as defined in Media RSS + * + * Used by {@see SimplePie_Enclosure::get_copyright()} + * + * This class can be overloaded with {@see SimplePie::set_copyright_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Copyright +{ + /** + * Copyright URL + * + * @var string + * @see get_url() + */ + var $url; + + /** + * Attribution + * + * @var string + * @see get_attribution() + */ + var $label; + + /** + * Constructor, used to input the data + * + * For documentation on all the parameters, see the corresponding + * properties and their accessors + */ + public function __construct($url = null, $label = null) + { + $this->url = $url; + $this->label = $label; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the copyright URL + * + * @return string|null URL to copyright information + */ + public function get_url() + { + if ($this->url !== null) + { + return $this->url; + } + else + { + return null; + } + } + + /** + * Get the attribution text + * + * @return string|null + */ + public function get_attribution() + { + if ($this->label !== null) + { + return $this->label; + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Core.php b/backend/wp-includes/SimplePie/Core.php new file mode 100644 index 0000000..46d9966 --- /dev/null +++ b/backend/wp-includes/SimplePie/Core.php @@ -0,0 +1,57 @@ +` as defined in Media RSS + * + * Used by {@see SimplePie_Enclosure::get_credit()} and {@see SimplePie_Enclosure::get_credits()} + * + * This class can be overloaded with {@see SimplePie::set_credit_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Credit +{ + /** + * Credited role + * + * @var string + * @see get_role() + */ + var $role; + + /** + * Organizational scheme + * + * @var string + * @see get_scheme() + */ + var $scheme; + + /** + * Credited name + * + * @var string + * @see get_name() + */ + var $name; + + /** + * Constructor, used to input the data + * + * For documentation on all the parameters, see the corresponding + * properties and their accessors + */ + public function __construct($role = null, $scheme = null, $name = null) + { + $this->role = $role; + $this->scheme = $scheme; + $this->name = $name; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the role of the person receiving credit + * + * @return string|null + */ + public function get_role() + { + if ($this->role !== null) + { + return $this->role; + } + else + { + return null; + } + } + + /** + * Get the organizational scheme + * + * @return string|null + */ + public function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + /** + * Get the credited person/entity's name + * + * @return string|null + */ + public function get_name() + { + if ($this->name !== null) + { + return $this->name; + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Decode/HTML/Entities.php b/backend/wp-includes/SimplePie/Decode/HTML/Entities.php new file mode 100644 index 0000000..069e8d8 --- /dev/null +++ b/backend/wp-includes/SimplePie/Decode/HTML/Entities.php @@ -0,0 +1,617 @@ +data = $data; + } + + /** + * Parse the input data + * + * @access public + * @return string Output data + */ + public function parse() + { + while (($this->position = strpos($this->data, '&', $this->position)) !== false) + { + $this->consume(); + $this->entity(); + $this->consumed = ''; + } + return $this->data; + } + + /** + * Consume the next byte + * + * @access private + * @return mixed The next byte, or false, if there is no more data + */ + public function consume() + { + if (isset($this->data[$this->position])) + { + $this->consumed .= $this->data[$this->position]; + return $this->data[$this->position++]; + } + else + { + return false; + } + } + + /** + * Consume a range of characters + * + * @access private + * @param string $chars Characters to consume + * @return mixed A series of characters that match the range, or false + */ + public function consume_range($chars) + { + if ($len = strspn($this->data, $chars, $this->position)) + { + $data = substr($this->data, $this->position, $len); + $this->consumed .= $data; + $this->position += $len; + return $data; + } + else + { + return false; + } + } + + /** + * Unconsume one byte + * + * @access private + */ + public function unconsume() + { + $this->consumed = substr($this->consumed, 0, -1); + $this->position--; + } + + /** + * Decode an entity + * + * @access private + */ + public function entity() + { + switch ($this->consume()) + { + case "\x09": + case "\x0A": + case "\x0B": + case "\x0B": + case "\x0C": + case "\x20": + case "\x3C": + case "\x26": + case false: + break; + + case "\x23": + switch ($this->consume()) + { + case "\x78": + case "\x58": + $range = '0123456789ABCDEFabcdef'; + $hex = true; + break; + + default: + $range = '0123456789'; + $hex = false; + $this->unconsume(); + break; + } + + if ($codepoint = $this->consume_range($range)) + { + static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); + + if ($hex) + { + $codepoint = hexdec($codepoint); + } + else + { + $codepoint = intval($codepoint); + } + + if (isset($windows_1252_specials[$codepoint])) + { + $replacement = $windows_1252_specials[$codepoint]; + } + else + { + $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); + } + + if (!in_array($this->consume(), array(';', false), true)) + { + $this->unconsume(); + } + + $consumed_length = strlen($this->consumed); + $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); + $this->position += strlen($replacement) - $consumed_length; + } + break; + + default: + static $entities = array( + 'Aacute' => "\xC3\x81", + 'aacute' => "\xC3\xA1", + 'Aacute;' => "\xC3\x81", + 'aacute;' => "\xC3\xA1", + 'Acirc' => "\xC3\x82", + 'acirc' => "\xC3\xA2", + 'Acirc;' => "\xC3\x82", + 'acirc;' => "\xC3\xA2", + 'acute' => "\xC2\xB4", + 'acute;' => "\xC2\xB4", + 'AElig' => "\xC3\x86", + 'aelig' => "\xC3\xA6", + 'AElig;' => "\xC3\x86", + 'aelig;' => "\xC3\xA6", + 'Agrave' => "\xC3\x80", + 'agrave' => "\xC3\xA0", + 'Agrave;' => "\xC3\x80", + 'agrave;' => "\xC3\xA0", + 'alefsym;' => "\xE2\x84\xB5", + 'Alpha;' => "\xCE\x91", + 'alpha;' => "\xCE\xB1", + 'AMP' => "\x26", + 'amp' => "\x26", + 'AMP;' => "\x26", + 'amp;' => "\x26", + 'and;' => "\xE2\x88\xA7", + 'ang;' => "\xE2\x88\xA0", + 'apos;' => "\x27", + 'Aring' => "\xC3\x85", + 'aring' => "\xC3\xA5", + 'Aring;' => "\xC3\x85", + 'aring;' => "\xC3\xA5", + 'asymp;' => "\xE2\x89\x88", + 'Atilde' => "\xC3\x83", + 'atilde' => "\xC3\xA3", + 'Atilde;' => "\xC3\x83", + 'atilde;' => "\xC3\xA3", + 'Auml' => "\xC3\x84", + 'auml' => "\xC3\xA4", + 'Auml;' => "\xC3\x84", + 'auml;' => "\xC3\xA4", + 'bdquo;' => "\xE2\x80\x9E", + 'Beta;' => "\xCE\x92", + 'beta;' => "\xCE\xB2", + 'brvbar' => "\xC2\xA6", + 'brvbar;' => "\xC2\xA6", + 'bull;' => "\xE2\x80\xA2", + 'cap;' => "\xE2\x88\xA9", + 'Ccedil' => "\xC3\x87", + 'ccedil' => "\xC3\xA7", + 'Ccedil;' => "\xC3\x87", + 'ccedil;' => "\xC3\xA7", + 'cedil' => "\xC2\xB8", + 'cedil;' => "\xC2\xB8", + 'cent' => "\xC2\xA2", + 'cent;' => "\xC2\xA2", + 'Chi;' => "\xCE\xA7", + 'chi;' => "\xCF\x87", + 'circ;' => "\xCB\x86", + 'clubs;' => "\xE2\x99\xA3", + 'cong;' => "\xE2\x89\x85", + 'COPY' => "\xC2\xA9", + 'copy' => "\xC2\xA9", + 'COPY;' => "\xC2\xA9", + 'copy;' => "\xC2\xA9", + 'crarr;' => "\xE2\x86\xB5", + 'cup;' => "\xE2\x88\xAA", + 'curren' => "\xC2\xA4", + 'curren;' => "\xC2\xA4", + 'Dagger;' => "\xE2\x80\xA1", + 'dagger;' => "\xE2\x80\xA0", + 'dArr;' => "\xE2\x87\x93", + 'darr;' => "\xE2\x86\x93", + 'deg' => "\xC2\xB0", + 'deg;' => "\xC2\xB0", + 'Delta;' => "\xCE\x94", + 'delta;' => "\xCE\xB4", + 'diams;' => "\xE2\x99\xA6", + 'divide' => "\xC3\xB7", + 'divide;' => "\xC3\xB7", + 'Eacute' => "\xC3\x89", + 'eacute' => "\xC3\xA9", + 'Eacute;' => "\xC3\x89", + 'eacute;' => "\xC3\xA9", + 'Ecirc' => "\xC3\x8A", + 'ecirc' => "\xC3\xAA", + 'Ecirc;' => "\xC3\x8A", + 'ecirc;' => "\xC3\xAA", + 'Egrave' => "\xC3\x88", + 'egrave' => "\xC3\xA8", + 'Egrave;' => "\xC3\x88", + 'egrave;' => "\xC3\xA8", + 'empty;' => "\xE2\x88\x85", + 'emsp;' => "\xE2\x80\x83", + 'ensp;' => "\xE2\x80\x82", + 'Epsilon;' => "\xCE\x95", + 'epsilon;' => "\xCE\xB5", + 'equiv;' => "\xE2\x89\xA1", + 'Eta;' => "\xCE\x97", + 'eta;' => "\xCE\xB7", + 'ETH' => "\xC3\x90", + 'eth' => "\xC3\xB0", + 'ETH;' => "\xC3\x90", + 'eth;' => "\xC3\xB0", + 'Euml' => "\xC3\x8B", + 'euml' => "\xC3\xAB", + 'Euml;' => "\xC3\x8B", + 'euml;' => "\xC3\xAB", + 'euro;' => "\xE2\x82\xAC", + 'exist;' => "\xE2\x88\x83", + 'fnof;' => "\xC6\x92", + 'forall;' => "\xE2\x88\x80", + 'frac12' => "\xC2\xBD", + 'frac12;' => "\xC2\xBD", + 'frac14' => "\xC2\xBC", + 'frac14;' => "\xC2\xBC", + 'frac34' => "\xC2\xBE", + 'frac34;' => "\xC2\xBE", + 'frasl;' => "\xE2\x81\x84", + 'Gamma;' => "\xCE\x93", + 'gamma;' => "\xCE\xB3", + 'ge;' => "\xE2\x89\xA5", + 'GT' => "\x3E", + 'gt' => "\x3E", + 'GT;' => "\x3E", + 'gt;' => "\x3E", + 'hArr;' => "\xE2\x87\x94", + 'harr;' => "\xE2\x86\x94", + 'hearts;' => "\xE2\x99\xA5", + 'hellip;' => "\xE2\x80\xA6", + 'Iacute' => "\xC3\x8D", + 'iacute' => "\xC3\xAD", + 'Iacute;' => "\xC3\x8D", + 'iacute;' => "\xC3\xAD", + 'Icirc' => "\xC3\x8E", + 'icirc' => "\xC3\xAE", + 'Icirc;' => "\xC3\x8E", + 'icirc;' => "\xC3\xAE", + 'iexcl' => "\xC2\xA1", + 'iexcl;' => "\xC2\xA1", + 'Igrave' => "\xC3\x8C", + 'igrave' => "\xC3\xAC", + 'Igrave;' => "\xC3\x8C", + 'igrave;' => "\xC3\xAC", + 'image;' => "\xE2\x84\x91", + 'infin;' => "\xE2\x88\x9E", + 'int;' => "\xE2\x88\xAB", + 'Iota;' => "\xCE\x99", + 'iota;' => "\xCE\xB9", + 'iquest' => "\xC2\xBF", + 'iquest;' => "\xC2\xBF", + 'isin;' => "\xE2\x88\x88", + 'Iuml' => "\xC3\x8F", + 'iuml' => "\xC3\xAF", + 'Iuml;' => "\xC3\x8F", + 'iuml;' => "\xC3\xAF", + 'Kappa;' => "\xCE\x9A", + 'kappa;' => "\xCE\xBA", + 'Lambda;' => "\xCE\x9B", + 'lambda;' => "\xCE\xBB", + 'lang;' => "\xE3\x80\x88", + 'laquo' => "\xC2\xAB", + 'laquo;' => "\xC2\xAB", + 'lArr;' => "\xE2\x87\x90", + 'larr;' => "\xE2\x86\x90", + 'lceil;' => "\xE2\x8C\x88", + 'ldquo;' => "\xE2\x80\x9C", + 'le;' => "\xE2\x89\xA4", + 'lfloor;' => "\xE2\x8C\x8A", + 'lowast;' => "\xE2\x88\x97", + 'loz;' => "\xE2\x97\x8A", + 'lrm;' => "\xE2\x80\x8E", + 'lsaquo;' => "\xE2\x80\xB9", + 'lsquo;' => "\xE2\x80\x98", + 'LT' => "\x3C", + 'lt' => "\x3C", + 'LT;' => "\x3C", + 'lt;' => "\x3C", + 'macr' => "\xC2\xAF", + 'macr;' => "\xC2\xAF", + 'mdash;' => "\xE2\x80\x94", + 'micro' => "\xC2\xB5", + 'micro;' => "\xC2\xB5", + 'middot' => "\xC2\xB7", + 'middot;' => "\xC2\xB7", + 'minus;' => "\xE2\x88\x92", + 'Mu;' => "\xCE\x9C", + 'mu;' => "\xCE\xBC", + 'nabla;' => "\xE2\x88\x87", + 'nbsp' => "\xC2\xA0", + 'nbsp;' => "\xC2\xA0", + 'ndash;' => "\xE2\x80\x93", + 'ne;' => "\xE2\x89\xA0", + 'ni;' => "\xE2\x88\x8B", + 'not' => "\xC2\xAC", + 'not;' => "\xC2\xAC", + 'notin;' => "\xE2\x88\x89", + 'nsub;' => "\xE2\x8A\x84", + 'Ntilde' => "\xC3\x91", + 'ntilde' => "\xC3\xB1", + 'Ntilde;' => "\xC3\x91", + 'ntilde;' => "\xC3\xB1", + 'Nu;' => "\xCE\x9D", + 'nu;' => "\xCE\xBD", + 'Oacute' => "\xC3\x93", + 'oacute' => "\xC3\xB3", + 'Oacute;' => "\xC3\x93", + 'oacute;' => "\xC3\xB3", + 'Ocirc' => "\xC3\x94", + 'ocirc' => "\xC3\xB4", + 'Ocirc;' => "\xC3\x94", + 'ocirc;' => "\xC3\xB4", + 'OElig;' => "\xC5\x92", + 'oelig;' => "\xC5\x93", + 'Ograve' => "\xC3\x92", + 'ograve' => "\xC3\xB2", + 'Ograve;' => "\xC3\x92", + 'ograve;' => "\xC3\xB2", + 'oline;' => "\xE2\x80\xBE", + 'Omega;' => "\xCE\xA9", + 'omega;' => "\xCF\x89", + 'Omicron;' => "\xCE\x9F", + 'omicron;' => "\xCE\xBF", + 'oplus;' => "\xE2\x8A\x95", + 'or;' => "\xE2\x88\xA8", + 'ordf' => "\xC2\xAA", + 'ordf;' => "\xC2\xAA", + 'ordm' => "\xC2\xBA", + 'ordm;' => "\xC2\xBA", + 'Oslash' => "\xC3\x98", + 'oslash' => "\xC3\xB8", + 'Oslash;' => "\xC3\x98", + 'oslash;' => "\xC3\xB8", + 'Otilde' => "\xC3\x95", + 'otilde' => "\xC3\xB5", + 'Otilde;' => "\xC3\x95", + 'otilde;' => "\xC3\xB5", + 'otimes;' => "\xE2\x8A\x97", + 'Ouml' => "\xC3\x96", + 'ouml' => "\xC3\xB6", + 'Ouml;' => "\xC3\x96", + 'ouml;' => "\xC3\xB6", + 'para' => "\xC2\xB6", + 'para;' => "\xC2\xB6", + 'part;' => "\xE2\x88\x82", + 'permil;' => "\xE2\x80\xB0", + 'perp;' => "\xE2\x8A\xA5", + 'Phi;' => "\xCE\xA6", + 'phi;' => "\xCF\x86", + 'Pi;' => "\xCE\xA0", + 'pi;' => "\xCF\x80", + 'piv;' => "\xCF\x96", + 'plusmn' => "\xC2\xB1", + 'plusmn;' => "\xC2\xB1", + 'pound' => "\xC2\xA3", + 'pound;' => "\xC2\xA3", + 'Prime;' => "\xE2\x80\xB3", + 'prime;' => "\xE2\x80\xB2", + 'prod;' => "\xE2\x88\x8F", + 'prop;' => "\xE2\x88\x9D", + 'Psi;' => "\xCE\xA8", + 'psi;' => "\xCF\x88", + 'QUOT' => "\x22", + 'quot' => "\x22", + 'QUOT;' => "\x22", + 'quot;' => "\x22", + 'radic;' => "\xE2\x88\x9A", + 'rang;' => "\xE3\x80\x89", + 'raquo' => "\xC2\xBB", + 'raquo;' => "\xC2\xBB", + 'rArr;' => "\xE2\x87\x92", + 'rarr;' => "\xE2\x86\x92", + 'rceil;' => "\xE2\x8C\x89", + 'rdquo;' => "\xE2\x80\x9D", + 'real;' => "\xE2\x84\x9C", + 'REG' => "\xC2\xAE", + 'reg' => "\xC2\xAE", + 'REG;' => "\xC2\xAE", + 'reg;' => "\xC2\xAE", + 'rfloor;' => "\xE2\x8C\x8B", + 'Rho;' => "\xCE\xA1", + 'rho;' => "\xCF\x81", + 'rlm;' => "\xE2\x80\x8F", + 'rsaquo;' => "\xE2\x80\xBA", + 'rsquo;' => "\xE2\x80\x99", + 'sbquo;' => "\xE2\x80\x9A", + 'Scaron;' => "\xC5\xA0", + 'scaron;' => "\xC5\xA1", + 'sdot;' => "\xE2\x8B\x85", + 'sect' => "\xC2\xA7", + 'sect;' => "\xC2\xA7", + 'shy' => "\xC2\xAD", + 'shy;' => "\xC2\xAD", + 'Sigma;' => "\xCE\xA3", + 'sigma;' => "\xCF\x83", + 'sigmaf;' => "\xCF\x82", + 'sim;' => "\xE2\x88\xBC", + 'spades;' => "\xE2\x99\xA0", + 'sub;' => "\xE2\x8A\x82", + 'sube;' => "\xE2\x8A\x86", + 'sum;' => "\xE2\x88\x91", + 'sup;' => "\xE2\x8A\x83", + 'sup1' => "\xC2\xB9", + 'sup1;' => "\xC2\xB9", + 'sup2' => "\xC2\xB2", + 'sup2;' => "\xC2\xB2", + 'sup3' => "\xC2\xB3", + 'sup3;' => "\xC2\xB3", + 'supe;' => "\xE2\x8A\x87", + 'szlig' => "\xC3\x9F", + 'szlig;' => "\xC3\x9F", + 'Tau;' => "\xCE\xA4", + 'tau;' => "\xCF\x84", + 'there4;' => "\xE2\x88\xB4", + 'Theta;' => "\xCE\x98", + 'theta;' => "\xCE\xB8", + 'thetasym;' => "\xCF\x91", + 'thinsp;' => "\xE2\x80\x89", + 'THORN' => "\xC3\x9E", + 'thorn' => "\xC3\xBE", + 'THORN;' => "\xC3\x9E", + 'thorn;' => "\xC3\xBE", + 'tilde;' => "\xCB\x9C", + 'times' => "\xC3\x97", + 'times;' => "\xC3\x97", + 'TRADE;' => "\xE2\x84\xA2", + 'trade;' => "\xE2\x84\xA2", + 'Uacute' => "\xC3\x9A", + 'uacute' => "\xC3\xBA", + 'Uacute;' => "\xC3\x9A", + 'uacute;' => "\xC3\xBA", + 'uArr;' => "\xE2\x87\x91", + 'uarr;' => "\xE2\x86\x91", + 'Ucirc' => "\xC3\x9B", + 'ucirc' => "\xC3\xBB", + 'Ucirc;' => "\xC3\x9B", + 'ucirc;' => "\xC3\xBB", + 'Ugrave' => "\xC3\x99", + 'ugrave' => "\xC3\xB9", + 'Ugrave;' => "\xC3\x99", + 'ugrave;' => "\xC3\xB9", + 'uml' => "\xC2\xA8", + 'uml;' => "\xC2\xA8", + 'upsih;' => "\xCF\x92", + 'Upsilon;' => "\xCE\xA5", + 'upsilon;' => "\xCF\x85", + 'Uuml' => "\xC3\x9C", + 'uuml' => "\xC3\xBC", + 'Uuml;' => "\xC3\x9C", + 'uuml;' => "\xC3\xBC", + 'weierp;' => "\xE2\x84\x98", + 'Xi;' => "\xCE\x9E", + 'xi;' => "\xCE\xBE", + 'Yacute' => "\xC3\x9D", + 'yacute' => "\xC3\xBD", + 'Yacute;' => "\xC3\x9D", + 'yacute;' => "\xC3\xBD", + 'yen' => "\xC2\xA5", + 'yen;' => "\xC2\xA5", + 'yuml' => "\xC3\xBF", + 'Yuml;' => "\xC5\xB8", + 'yuml;' => "\xC3\xBF", + 'Zeta;' => "\xCE\x96", + 'zeta;' => "\xCE\xB6", + 'zwj;' => "\xE2\x80\x8D", + 'zwnj;' => "\xE2\x80\x8C" + ); + + for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) + { + $consumed = substr($this->consumed, 1); + if (isset($entities[$consumed])) + { + $match = $consumed; + } + } + + if ($match !== null) + { + $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); + $this->position += strlen($entities[$match]) - strlen($consumed) - 1; + } + break; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Enclosure.php b/backend/wp-includes/SimplePie/Enclosure.php new file mode 100644 index 0000000..5567437 --- /dev/null +++ b/backend/wp-includes/SimplePie/Enclosure.php @@ -0,0 +1,1380 @@ +bitrate = $bitrate; + $this->captions = $captions; + $this->categories = $categories; + $this->channels = $channels; + $this->copyright = $copyright; + $this->credits = $credits; + $this->description = $description; + $this->duration = $duration; + $this->expression = $expression; + $this->framerate = $framerate; + $this->hashes = $hashes; + $this->height = $height; + $this->keywords = $keywords; + $this->lang = $lang; + $this->length = $length; + $this->link = $link; + $this->medium = $medium; + $this->player = $player; + $this->ratings = $ratings; + $this->restrictions = $restrictions; + $this->samplingrate = $samplingrate; + $this->thumbnails = $thumbnails; + $this->title = $title; + $this->type = $type; + $this->width = $width; + + if (class_exists('idna_convert')) + { + $idn = new idna_convert(); + $parsed = SimplePie_Misc::parse_url($link); + $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->handler = $this->get_handler(); // Needs to load last + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the bitrate + * + * @return string|null + */ + public function get_bitrate() + { + if ($this->bitrate !== null) + { + return $this->bitrate; + } + else + { + return null; + } + } + + /** + * Get a single caption + * + * @param int $key + * @return SimplePie_Caption|null + */ + public function get_caption($key = 0) + { + $captions = $this->get_captions(); + if (isset($captions[$key])) + { + return $captions[$key]; + } + else + { + return null; + } + } + + /** + * Get all captions + * + * @return array|null Array of {@see SimplePie_Caption} objects + */ + public function get_captions() + { + if ($this->captions !== null) + { + return $this->captions; + } + else + { + return null; + } + } + + /** + * Get a single category + * + * @param int $key + * @return SimplePie_Category|null + */ + public function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + /** + * Get all categories + * + * @return array|null Array of {@see SimplePie_Category} objects + */ + public function get_categories() + { + if ($this->categories !== null) + { + return $this->categories; + } + else + { + return null; + } + } + + /** + * Get the number of audio channels + * + * @return int|null + */ + public function get_channels() + { + if ($this->channels !== null) + { + return $this->channels; + } + else + { + return null; + } + } + + /** + * Get the copyright information + * + * @return SimplePie_Copyright|null + */ + public function get_copyright() + { + if ($this->copyright !== null) + { + return $this->copyright; + } + else + { + return null; + } + } + + /** + * Get a single credit + * + * @param int $key + * @return SimplePie_Credit|null + */ + public function get_credit($key = 0) + { + $credits = $this->get_credits(); + if (isset($credits[$key])) + { + return $credits[$key]; + } + else + { + return null; + } + } + + /** + * Get all credits + * + * @return array|null Array of {@see SimplePie_Credit} objects + */ + public function get_credits() + { + if ($this->credits !== null) + { + return $this->credits; + } + else + { + return null; + } + } + + /** + * Get the description of the enclosure + * + * @return string|null + */ + public function get_description() + { + if ($this->description !== null) + { + return $this->description; + } + else + { + return null; + } + } + + /** + * Get the duration of the enclosure + * + * @param string $convert Convert seconds into hh:mm:ss + * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) + */ + public function get_duration($convert = false) + { + if ($this->duration !== null) + { + if ($convert) + { + $time = SimplePie_Misc::time_hms($this->duration); + return $time; + } + else + { + return $this->duration; + } + } + else + { + return null; + } + } + + /** + * Get the expression + * + * @return string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full' + */ + public function get_expression() + { + if ($this->expression !== null) + { + return $this->expression; + } + else + { + return 'full'; + } + } + + /** + * Get the file extension + * + * @return string|null + */ + public function get_extension() + { + if ($this->link !== null) + { + $url = SimplePie_Misc::parse_url($this->link); + if ($url['path'] !== '') + { + return pathinfo($url['path'], PATHINFO_EXTENSION); + } + } + return null; + } + + /** + * Get the framerate (in frames-per-second) + * + * @return string|null + */ + public function get_framerate() + { + if ($this->framerate !== null) + { + return $this->framerate; + } + else + { + return null; + } + } + + /** + * Get the preferred handler + * + * @return string|null One of 'flash', 'fmedia', 'quicktime', 'wmedia', 'mp3' + */ + public function get_handler() + { + return $this->get_real_type(true); + } + + /** + * Get a single hash + * + * @link http://www.rssboard.org/media-rss#media-hash + * @param int $key + * @return string|null Hash as per `media:hash`, prefixed with "$algo:" + */ + public function get_hash($key = 0) + { + $hashes = $this->get_hashes(); + if (isset($hashes[$key])) + { + return $hashes[$key]; + } + else + { + return null; + } + } + + /** + * Get all credits + * + * @return array|null Array of strings, see {@see get_hash()} + */ + public function get_hashes() + { + if ($this->hashes !== null) + { + return $this->hashes; + } + else + { + return null; + } + } + + /** + * Get the height + * + * @return string|null + */ + public function get_height() + { + if ($this->height !== null) + { + return $this->height; + } + else + { + return null; + } + } + + /** + * Get the language + * + * @link http://tools.ietf.org/html/rfc3066 + * @return string|null Language code as per RFC 3066 + */ + public function get_language() + { + if ($this->lang !== null) + { + return $this->lang; + } + else + { + return null; + } + } + + /** + * Get a single keyword + * + * @param int $key + * @return string|null + */ + public function get_keyword($key = 0) + { + $keywords = $this->get_keywords(); + if (isset($keywords[$key])) + { + return $keywords[$key]; + } + else + { + return null; + } + } + + /** + * Get all keywords + * + * @return array|null Array of strings + */ + public function get_keywords() + { + if ($this->keywords !== null) + { + return $this->keywords; + } + else + { + return null; + } + } + + /** + * Get length + * + * @return float Length in bytes + */ + public function get_length() + { + if ($this->length !== null) + { + return $this->length; + } + else + { + return null; + } + } + + /** + * Get the URL + * + * @return string|null + */ + public function get_link() + { + if ($this->link !== null) + { + return urldecode($this->link); + } + else + { + return null; + } + } + + /** + * Get the medium + * + * @link http://www.rssboard.org/media-rss#media-content + * @return string|null Should be one of 'image', 'audio', 'video', 'document', 'executable' + */ + public function get_medium() + { + if ($this->medium !== null) + { + return $this->medium; + } + else + { + return null; + } + } + + /** + * Get the player URL + * + * Typically the same as {@see get_permalink()} + * @return string|null Player URL + */ + public function get_player() + { + if ($this->player !== null) + { + return $this->player; + } + else + { + return null; + } + } + + /** + * Get a single rating + * + * @param int $key + * @return SimplePie_Rating|null + */ + public function get_rating($key = 0) + { + $ratings = $this->get_ratings(); + if (isset($ratings[$key])) + { + return $ratings[$key]; + } + else + { + return null; + } + } + + /** + * Get all ratings + * + * @return array|null Array of {@see SimplePie_Rating} objects + */ + public function get_ratings() + { + if ($this->ratings !== null) + { + return $this->ratings; + } + else + { + return null; + } + } + + /** + * Get a single restriction + * + * @param int $key + * @return SimplePie_Restriction|null + */ + public function get_restriction($key = 0) + { + $restrictions = $this->get_restrictions(); + if (isset($restrictions[$key])) + { + return $restrictions[$key]; + } + else + { + return null; + } + } + + /** + * Get all restrictions + * + * @return array|null Array of {@see SimplePie_Restriction} objects + */ + public function get_restrictions() + { + if ($this->restrictions !== null) + { + return $this->restrictions; + } + else + { + return null; + } + } + + /** + * Get the sampling rate (in kHz) + * + * @return string|null + */ + public function get_sampling_rate() + { + if ($this->samplingrate !== null) + { + return $this->samplingrate; + } + else + { + return null; + } + } + + /** + * Get the file size (in MiB) + * + * @return float|null File size in mebibytes (1048 bytes) + */ + public function get_size() + { + $length = $this->get_length(); + if ($length !== null) + { + return round($length/1048576, 2); + } + else + { + return null; + } + } + + /** + * Get a single thumbnail + * + * @param int $key + * @return string|null Thumbnail URL + */ + public function get_thumbnail($key = 0) + { + $thumbnails = $this->get_thumbnails(); + if (isset($thumbnails[$key])) + { + return $thumbnails[$key]; + } + else + { + return null; + } + } + + /** + * Get all thumbnails + * + * @return array|null Array of thumbnail URLs + */ + public function get_thumbnails() + { + if ($this->thumbnails !== null) + { + return $this->thumbnails; + } + else + { + return null; + } + } + + /** + * Get the title + * + * @return string|null + */ + public function get_title() + { + if ($this->title !== null) + { + return $this->title; + } + else + { + return null; + } + } + + /** + * Get mimetype of the enclosure + * + * @see get_real_type() + * @return string|null MIME type + */ + public function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } + + /** + * Get the width + * + * @return string|null + */ + public function get_width() + { + if ($this->width !== null) + { + return $this->width; + } + else + { + return null; + } + } + + /** + * Embed the enclosure using `` + * + * @deprecated Use the second parameter to {@see embed} instead + * + * @param array|string $options See first paramter to {@see embed} + * @return string HTML string to output + */ + public function native_embed($options='') + { + return $this->embed($options, true); + } + + /** + * Embed the enclosure using Javascript + * + * `$options` is an array or comma-separated key:value string, with the + * following properties: + * + * - `alt` (string): Alternate content for when an end-user does not have + * the appropriate handler installed or when a file type is + * unsupported. Can be any text or HTML. Defaults to blank. + * - `altclass` (string): If a file type is unsupported, the end-user will + * see the alt text (above) linked directly to the content. That link + * will have this value as its class name. Defaults to blank. + * - `audio` (string): This is an image that should be used as a + * placeholder for audio files before they're loaded (QuickTime-only). + * Can be any relative or absolute URL. Defaults to blank. + * - `bgcolor` (string): The background color for the media, if not + * already transparent. Defaults to `#ffffff`. + * - `height` (integer): The height of the embedded media. Accepts any + * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`, + * and it is recommended that you use this default. + * - `loop` (boolean): Do you want the media to loop when its done? + * Defaults to `false`. + * - `mediaplayer` (string): The location of the included + * `mediaplayer.swf` file. This allows for the playback of Flash Video + * (`.flv`) files, and is the default handler for non-Odeo MP3's. + * Defaults to blank. + * - `video` (string): This is an image that should be used as a + * placeholder for video files before they're loaded (QuickTime-only). + * Can be any relative or absolute URL. Defaults to blank. + * - `width` (integer): The width of the embedded media. Accepts any + * numeric pixel value (such as `480`) or `auto`. Defaults to `auto`, + * and it is recommended that you use this default. + * - `widescreen` (boolean): Is the enclosure widescreen or standard? + * This applies only to video enclosures, and will automatically resize + * the content appropriately. Defaults to `false`, implying 4:3 mode. + * + * Note: Non-widescreen (4:3) mode with `width` and `height` set to `auto` + * will default to 480x360 video resolution. Widescreen (16:9) mode with + * `width` and `height` set to `auto` will default to 480x270 video resolution. + * + * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. + * @param array|string $options Comma-separated key:value list, or array + * @param bool $native Use `` + * @return string HTML string to output + */ + public function embed($options = '', $native = false) + { + // Set up defaults + $audio = ''; + $video = ''; + $alt = ''; + $altclass = ''; + $loop = 'false'; + $width = 'auto'; + $height = 'auto'; + $bgcolor = '#ffffff'; + $mediaplayer = ''; + $widescreen = false; + $handler = $this->get_handler(); + $type = $this->get_real_type(); + + // Process options and reassign values as necessary + if (is_array($options)) + { + extract($options); + } + else + { + $options = explode(',', $options); + foreach($options as $option) + { + $opt = explode(':', $option, 2); + if (isset($opt[0], $opt[1])) + { + $opt[0] = trim($opt[0]); + $opt[1] = trim($opt[1]); + switch ($opt[0]) + { + case 'audio': + $audio = $opt[1]; + break; + + case 'video': + $video = $opt[1]; + break; + + case 'alt': + $alt = $opt[1]; + break; + + case 'altclass': + $altclass = $opt[1]; + break; + + case 'loop': + $loop = $opt[1]; + break; + + case 'width': + $width = $opt[1]; + break; + + case 'height': + $height = $opt[1]; + break; + + case 'bgcolor': + $bgcolor = $opt[1]; + break; + + case 'mediaplayer': + $mediaplayer = $opt[1]; + break; + + case 'widescreen': + $widescreen = $opt[1]; + break; + } + } + } + } + + $mime = explode('/', $type, 2); + $mime = $mime[0]; + + // Process values for 'auto' + if ($width === 'auto') + { + if ($mime === 'video') + { + if ($height === 'auto') + { + $width = 480; + } + elseif ($widescreen) + { + $width = round((intval($height)/9)*16); + } + else + { + $width = round((intval($height)/3)*4); + } + } + else + { + $width = '100%'; + } + } + + if ($height === 'auto') + { + if ($mime === 'audio') + { + $height = 0; + } + elseif ($mime === 'video') + { + if ($width === 'auto') + { + if ($widescreen) + { + $height = 270; + } + else + { + $height = 360; + } + } + elseif ($widescreen) + { + $height = round((intval($width)/16)*9); + } + else + { + $height = round((intval($width)/4)*3); + } + } + else + { + $height = 376; + } + } + elseif ($mime === 'audio') + { + $height = 0; + } + + // Set proper placeholder value + if ($mime === 'audio') + { + $placeholder = $audio; + } + elseif ($mime === 'video') + { + $placeholder = $video; + } + + $embed = ''; + + // Flash + if ($handler === 'flash') + { + if ($native) + { + $embed .= "get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\">"; + } + else + { + $embed .= ""; + } + } + + // Flash Media Player file types. + // Preferred handler for MP3 file types. + elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) + { + $height += 20; + if ($native) + { + $embed .= "get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\">"; + } + else + { + $embed .= ""; + } + } + + // QuickTime 7 file types. Need to test with QuickTime 6. + // Only handle MP3's if the Flash Media Player is not present. + elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) + { + $height += 16; + if ($native) + { + if ($placeholder !== '') + { + $embed .= "get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; + } + else + { + $embed .= "get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; + } + } + else + { + $embed .= ""; + } + } + + // Windows Media + elseif ($handler === 'wmedia') + { + $height += 45; + if ($native) + { + $embed .= "get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\">"; + } + else + { + $embed .= ""; + } + } + + // Everything else + else $embed .= '' . $alt . ''; + + return $embed; + } + + /** + * Get the real media type + * + * Often, feeds lie to us, necessitating a bit of deeper inspection. This + * converts types to their canonical representations based on the file + * extension + * + * @see get_type() + * @param bool $find_handler Internal use only, use {@see get_handler()} instead + * @return string MIME type + */ + public function get_real_type($find_handler = false) + { + // Mime-types by handler. + $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash + $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player + $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime + $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media + $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 + + if ($this->get_type() !== null) + { + $type = strtolower($this->type); + } + else + { + $type = null; + } + + // If we encounter an unsupported mime-type, check the file extension and guess intelligently. + if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) + { + switch (strtolower($this->get_extension())) + { + // Audio mime-types + case 'aac': + case 'adts': + $type = 'audio/acc'; + break; + + case 'aif': + case 'aifc': + case 'aiff': + case 'cdda': + $type = 'audio/aiff'; + break; + + case 'bwf': + $type = 'audio/wav'; + break; + + case 'kar': + case 'mid': + case 'midi': + case 'smf': + $type = 'audio/midi'; + break; + + case 'm4a': + $type = 'audio/x-m4a'; + break; + + case 'mp3': + case 'swa': + $type = 'audio/mp3'; + break; + + case 'wav': + $type = 'audio/wav'; + break; + + case 'wax': + $type = 'audio/x-ms-wax'; + break; + + case 'wma': + $type = 'audio/x-ms-wma'; + break; + + // Video mime-types + case '3gp': + case '3gpp': + $type = 'video/3gpp'; + break; + + case '3g2': + case '3gp2': + $type = 'video/3gpp2'; + break; + + case 'asf': + $type = 'video/x-ms-asf'; + break; + + case 'flv': + $type = 'video/x-flv'; + break; + + case 'm1a': + case 'm1s': + case 'm1v': + case 'm15': + case 'm75': + case 'mp2': + case 'mpa': + case 'mpeg': + case 'mpg': + case 'mpm': + case 'mpv': + $type = 'video/mpeg'; + break; + + case 'm4v': + $type = 'video/x-m4v'; + break; + + case 'mov': + case 'qt': + $type = 'video/quicktime'; + break; + + case 'mp4': + case 'mpg4': + $type = 'video/mp4'; + break; + + case 'sdv': + $type = 'video/sd-video'; + break; + + case 'wm': + $type = 'video/x-ms-wm'; + break; + + case 'wmv': + $type = 'video/x-ms-wmv'; + break; + + case 'wvx': + $type = 'video/x-ms-wvx'; + break; + + // Flash mime-types + case 'spl': + $type = 'application/futuresplash'; + break; + + case 'swf': + $type = 'application/x-shockwave-flash'; + break; + } + } + + if ($find_handler) + { + if (in_array($type, $types_flash)) + { + return 'flash'; + } + elseif (in_array($type, $types_fmedia)) + { + return 'fmedia'; + } + elseif (in_array($type, $types_quicktime)) + { + return 'quicktime'; + } + elseif (in_array($type, $types_wmedia)) + { + return 'wmedia'; + } + elseif (in_array($type, $types_mp3)) + { + return 'mp3'; + } + else + { + return null; + } + } + else + { + return $type; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Exception.php b/backend/wp-includes/SimplePie/Exception.php new file mode 100644 index 0000000..73e104d --- /dev/null +++ b/backend/wp-includes/SimplePie/Exception.php @@ -0,0 +1,52 @@ +encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->url = $url; + $this->useragent = $useragent; + if (preg_match('/^http(s)?:\/\//i', $url)) + { + if ($useragent === null) + { + $useragent = ini_get('user_agent'); + $this->useragent = $useragent; + } + if (!is_array($headers)) + { + $headers = array(); + } + if (!$force_fsockopen && function_exists('curl_exec')) + { + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; + $fp = curl_init(); + $headers2 = array(); + foreach ($headers as $key => $value) + { + $headers2[] = "$key: $value"; + } + if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) + { + curl_setopt($fp, CURLOPT_ENCODING, ''); + } + curl_setopt($fp, CURLOPT_URL, $url); + curl_setopt($fp, CURLOPT_HEADER, 1); + curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_REFERER, $url); + curl_setopt($fp, CURLOPT_USERAGENT, $useragent); + curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); + if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) + { + curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); + } + + $this->headers = curl_exec($fp); + if (curl_errno($fp) === 23 || curl_errno($fp) === 61) + { + curl_setopt($fp, CURLOPT_ENCODING, 'none'); + $this->headers = curl_exec($fp); + } + if (curl_errno($fp)) + { + $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); + $this->success = false; + } + else + { + $info = curl_getinfo($fp); + curl_close($fp); + $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); + $this->headers = array_pop($this->headers); + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + { + $this->redirects++; + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); + return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); + } + } + } + } + else + { + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; + $url_parts = parse_url($url); + $socket_host = $url_parts['host']; + if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') + { + $socket_host = "ssl://$url_parts[host]"; + $url_parts['port'] = 443; + } + if (!isset($url_parts['port'])) + { + $url_parts['port'] = 80; + } + $fp = @fsockopen($socket_host, $url_parts['port'], $errno, $errstr, $timeout); + if (!$fp) + { + $this->error = 'fsockopen error: ' . $errstr; + $this->success = false; + } + else + { + stream_set_timeout($fp, $timeout); + if (isset($url_parts['path'])) + { + if (isset($url_parts['query'])) + { + $get = "$url_parts[path]?$url_parts[query]"; + } + else + { + $get = $url_parts['path']; + } + } + else + { + $get = '/'; + } + $out = "GET $get HTTP/1.1\r\n"; + $out .= "Host: $url_parts[host]\r\n"; + $out .= "User-Agent: $useragent\r\n"; + if (extension_loaded('zlib')) + { + $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; + } + + if (isset($url_parts['user']) && isset($url_parts['pass'])) + { + $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; + } + foreach ($headers as $key => $value) + { + $out .= "$key: $value\r\n"; + } + $out .= "Connection: Close\r\n\r\n"; + fwrite($fp, $out); + + $info = stream_get_meta_data($fp); + + $this->headers = ''; + while (!$info['eof'] && !$info['timed_out']) + { + $this->headers .= fread($fp, 1160); + $info = stream_get_meta_data($fp); + } + if (!$info['timed_out']) + { + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + { + $this->redirects++; + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); + return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); + } + if (isset($this->headers['content-encoding'])) + { + // Hey, we act dumb elsewhere, so let's do that here too + switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) + { + case 'gzip': + case 'x-gzip': + $decoder = new SimplePie_gzdecode($this->body); + if (!$decoder->parse()) + { + $this->error = 'Unable to decode HTTP "gzip" stream'; + $this->success = false; + } + else + { + $this->body = $decoder->data; + } + break; + + case 'deflate': + if (($decompressed = gzinflate($this->body)) !== false) + { + $this->body = $decompressed; + } + else if (($decompressed = gzuncompress($this->body)) !== false) + { + $this->body = $decompressed; + } + else if (function_exists('gzdecode') && ($decompressed = gzdecode($this->body)) !== false) + { + $this->body = $decompressed; + } + else + { + $this->error = 'Unable to decode HTTP "deflate" stream'; + $this->success = false; + } + break; + + default: + $this->error = 'Unknown content coding'; + $this->success = false; + } + } + } + } + else + { + $this->error = 'fsocket timed out'; + $this->success = false; + } + fclose($fp); + } + } + } + else + { + $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; + if (!$this->body = file_get_contents($url)) + { + $this->error = 'file_get_contents could not read the file'; + $this->success = false; + } + } + } +} diff --git a/backend/wp-includes/SimplePie/HTTP/Parser.php b/backend/wp-includes/SimplePie/HTTP/Parser.php new file mode 100644 index 0000000..bff2222 --- /dev/null +++ b/backend/wp-includes/SimplePie/HTTP/Parser.php @@ -0,0 +1,500 @@ +data = $data; + $this->data_length = strlen($this->data); + } + + /** + * Parse the input data + * + * @return bool true on success, false on failure + */ + public function parse() + { + while ($this->state && $this->state !== 'emit' && $this->has_data()) + { + $state = $this->state; + $this->$state(); + } + $this->data = ''; + if ($this->state === 'emit' || $this->state === 'body') + { + return true; + } + else + { + $this->http_version = ''; + $this->status_code = ''; + $this->reason = ''; + $this->headers = array(); + $this->body = ''; + return false; + } + } + + /** + * Check whether there is data beyond the pointer + * + * @return bool true if there is further data, false if not + */ + protected function has_data() + { + return (bool) ($this->position < $this->data_length); + } + + /** + * See if the next character is LWS + * + * @return bool true if the next character is LWS, false if not + */ + protected function is_linear_whitespace() + { + return (bool) ($this->data[$this->position] === "\x09" + || $this->data[$this->position] === "\x20" + || ($this->data[$this->position] === "\x0A" + && isset($this->data[$this->position + 1]) + && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); + } + + /** + * Parse the HTTP version + */ + protected function http_version() + { + if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') + { + $len = strspn($this->data, '0123456789.', 5); + $this->http_version = substr($this->data, 5, $len); + $this->position += 5 + $len; + if (substr_count($this->http_version, '.') <= 1) + { + $this->http_version = (float) $this->http_version; + $this->position += strspn($this->data, "\x09\x20", $this->position); + $this->state = 'status'; + } + else + { + $this->state = false; + } + } + else + { + $this->state = false; + } + } + + /** + * Parse the status code + */ + protected function status() + { + if ($len = strspn($this->data, '0123456789', $this->position)) + { + $this->status_code = (int) substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'reason'; + } + else + { + $this->state = false; + } + } + + /** + * Parse the reason phrase + */ + protected function reason() + { + $len = strcspn($this->data, "\x0A", $this->position); + $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20"); + $this->position += $len + 1; + $this->state = 'new_line'; + } + + /** + * Deal with a new line, shifting data around as needed + */ + protected function new_line() + { + $this->value = trim($this->value, "\x0D\x20"); + if ($this->name !== '' && $this->value !== '') + { + $this->name = strtolower($this->name); + // We should only use the last Content-Type header. c.f. issue #1 + if (isset($this->headers[$this->name]) && $this->name !== 'content-type') + { + $this->headers[$this->name] .= ', ' . $this->value; + } + else + { + $this->headers[$this->name] = $this->value; + } + } + $this->name = ''; + $this->value = ''; + if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") + { + $this->position += 2; + $this->state = 'body'; + } + elseif ($this->data[$this->position] === "\x0A") + { + $this->position++; + $this->state = 'body'; + } + else + { + $this->state = 'name'; + } + } + + /** + * Parse a header name + */ + protected function name() + { + $len = strcspn($this->data, "\x0A:", $this->position); + if (isset($this->data[$this->position + $len])) + { + if ($this->data[$this->position + $len] === "\x0A") + { + $this->position += $len; + $this->state = 'new_line'; + } + else + { + $this->name = substr($this->data, $this->position, $len); + $this->position += $len + 1; + $this->state = 'value'; + } + } + else + { + $this->state = false; + } + } + + /** + * Parse LWS, replacing consecutive LWS characters with a single space + */ + protected function linear_whitespace() + { + do + { + if (substr($this->data, $this->position, 2) === "\x0D\x0A") + { + $this->position += 2; + } + elseif ($this->data[$this->position] === "\x0A") + { + $this->position++; + } + $this->position += strspn($this->data, "\x09\x20", $this->position); + } while ($this->has_data() && $this->is_linear_whitespace()); + $this->value .= "\x20"; + } + + /** + * See what state to move to while within non-quoted header values + */ + protected function value() + { + if ($this->is_linear_whitespace()) + { + $this->linear_whitespace(); + } + else + { + switch ($this->data[$this->position]) + { + case '"': + // Workaround for ETags: we have to include the quotes as + // part of the tag. + if (strtolower($this->name) === 'etag') + { + $this->value .= '"'; + $this->position++; + $this->state = 'value_char'; + break; + } + $this->position++; + $this->state = 'quote'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + default: + $this->state = 'value_char'; + break; + } + } + } + + /** + * Parse a header value while outside quotes + */ + protected function value_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * See what state to move to while within quoted header values + */ + protected function quote() + { + if ($this->is_linear_whitespace()) + { + $this->linear_whitespace(); + } + else + { + switch ($this->data[$this->position]) + { + case '"': + $this->position++; + $this->state = 'value'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + case '\\': + $this->position++; + $this->state = 'quote_escaped'; + break; + + default: + $this->state = 'quote_char'; + break; + } + } + } + + /** + * Parse a header value while within quotes + */ + protected function quote_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * Parse an escaped character within quotes + */ + protected function quote_escaped() + { + $this->value .= $this->data[$this->position]; + $this->position++; + $this->state = 'quote'; + } + + /** + * Parse the body + */ + protected function body() + { + $this->body = substr($this->data, $this->position); + if (!empty($this->headers['transfer-encoding'])) + { + unset($this->headers['transfer-encoding']); + $this->state = 'chunked'; + } + else + { + $this->state = 'emit'; + } + } + + /** + * Parsed a "Transfer-Encoding: chunked" body + */ + protected function chunked() + { + if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($this->body))) + { + $this->state = 'emit'; + return; + } + + $decoded = ''; + $encoded = $this->body; + + while (true) + { + $is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches ); + if (!$is_chunked) + { + // Looks like it's not chunked after all + $this->state = 'emit'; + return; + } + + $length = hexdec(trim($matches[1])); + if ($length === 0) + { + // Ignore trailer headers + $this->state = 'emit'; + $this->body = $decoded; + return; + } + + $chunk_length = strlen($matches[0]); + $decoded .= $part = substr($encoded, $chunk_length, $length); + $encoded = substr($encoded, $chunk_length + $length + 2); + + if (trim($encoded) === '0' || empty($encoded)) + { + $this->state = 'emit'; + $this->body = $decoded; + return; + } + } + } +} diff --git a/backend/wp-includes/SimplePie/IRI.php b/backend/wp-includes/SimplePie/IRI.php new file mode 100644 index 0000000..d3198c0 --- /dev/null +++ b/backend/wp-includes/SimplePie/IRI.php @@ -0,0 +1,1238 @@ + array( + 'port' => 674 + ), + 'dict' => array( + 'port' => 2628 + ), + 'file' => array( + 'ihost' => 'localhost' + ), + 'http' => array( + 'port' => 80, + 'ipath' => '/' + ), + 'https' => array( + 'port' => 443, + 'ipath' => '/' + ), + ); + + /** + * Return the entire IRI when you try and read the object as a string + * + * @return string + */ + public function __toString() + { + return $this->get_iri(); + } + + /** + * Overload __set() to provide access via properties + * + * @param string $name Property name + * @param mixed $value Property value + */ + public function __set($name, $value) + { + if (method_exists($this, 'set_' . $name)) + { + call_user_func(array($this, 'set_' . $name), $value); + } + elseif ( + $name === 'iauthority' + || $name === 'iuserinfo' + || $name === 'ihost' + || $name === 'ipath' + || $name === 'iquery' + || $name === 'ifragment' + ) + { + call_user_func(array($this, 'set_' . substr($name, 1)), $value); + } + } + + /** + * Overload __get() to provide access via properties + * + * @param string $name Property name + * @return mixed + */ + public function __get($name) + { + // isset() returns false for null, we don't want to do that + // Also why we use array_key_exists below instead of isset() + $props = get_object_vars($this); + + if ( + $name === 'iri' || + $name === 'uri' || + $name === 'iauthority' || + $name === 'authority' + ) + { + $return = $this->{"get_$name"}(); + } + elseif (array_key_exists($name, $props)) + { + $return = $this->$name; + } + // host -> ihost + elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) + { + $name = $prop; + $return = $this->$prop; + } + // ischeme -> scheme + elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) + { + $name = $prop; + $return = $this->$prop; + } + else + { + trigger_error('Undefined property: ' . get_class($this) . '::' . $name, E_USER_NOTICE); + $return = null; + } + + if ($return === null && isset($this->normalization[$this->scheme][$name])) + { + return $this->normalization[$this->scheme][$name]; + } + else + { + return $return; + } + } + + /** + * Overload __isset() to provide access via properties + * + * @param string $name Property name + * @return bool + */ + public function __isset($name) + { + if (method_exists($this, 'get_' . $name) || isset($this->$name)) + { + return true; + } + else + { + return false; + } + } + + /** + * Overload __unset() to provide access via properties + * + * @param string $name Property name + */ + public function __unset($name) + { + if (method_exists($this, 'set_' . $name)) + { + call_user_func(array($this, 'set_' . $name), ''); + } + } + + /** + * Create a new IRI object, from a specified string + * + * @param string $iri + */ + public function __construct($iri = null) + { + $this->set_iri($iri); + } + + /** + * Create a new IRI object by resolving a relative IRI + * + * Returns false if $base is not absolute, otherwise an IRI. + * + * @param IRI|string $base (Absolute) Base IRI + * @param IRI|string $relative Relative IRI + * @return IRI|false + */ + public static function absolutize($base, $relative) + { + if (!($relative instanceof SimplePie_IRI)) + { + $relative = new SimplePie_IRI($relative); + } + if (!$relative->is_valid()) + { + return false; + } + elseif ($relative->scheme !== null) + { + return clone $relative; + } + else + { + if (!($base instanceof SimplePie_IRI)) + { + $base = new SimplePie_IRI($base); + } + if ($base->scheme !== null && $base->is_valid()) + { + if ($relative->get_iri() !== '') + { + if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) + { + $target = clone $relative; + $target->scheme = $base->scheme; + } + else + { + $target = new SimplePie_IRI; + $target->scheme = $base->scheme; + $target->iuserinfo = $base->iuserinfo; + $target->ihost = $base->ihost; + $target->port = $base->port; + if ($relative->ipath !== '') + { + if ($relative->ipath[0] === '/') + { + $target->ipath = $relative->ipath; + } + elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') + { + $target->ipath = '/' . $relative->ipath; + } + elseif (($last_segment = strrpos($base->ipath, '/')) !== false) + { + $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; + } + else + { + $target->ipath = $relative->ipath; + } + $target->ipath = $target->remove_dot_segments($target->ipath); + $target->iquery = $relative->iquery; + } + else + { + $target->ipath = $base->ipath; + if ($relative->iquery !== null) + { + $target->iquery = $relative->iquery; + } + elseif ($base->iquery !== null) + { + $target->iquery = $base->iquery; + } + } + $target->ifragment = $relative->ifragment; + } + } + else + { + $target = clone $base; + $target->ifragment = null; + } + $target->scheme_normalization(); + return $target; + } + else + { + return false; + } + } + } + + /** + * Parse an IRI into scheme/authority/path/query/fragment segments + * + * @param string $iri + * @return array + */ + protected function parse_iri($iri) + { + $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); + if (preg_match('/^((?P[^:\/?#]+):)?(\/\/(?P[^\/?#]*))?(?P[^?#]*)(\?(?P[^#]*))?(#(?P.*))?$/', $iri, $match)) + { + if ($match[1] === '') + { + $match['scheme'] = null; + } + if (!isset($match[3]) || $match[3] === '') + { + $match['authority'] = null; + } + if (!isset($match[5])) + { + $match['path'] = ''; + } + if (!isset($match[6]) || $match[6] === '') + { + $match['query'] = null; + } + if (!isset($match[8]) || $match[8] === '') + { + $match['fragment'] = null; + } + return $match; + } + else + { + // This can occur when a paragraph is accidentally parsed as a URI + return false; + } + } + + /** + * Remove dot segments from a path + * + * @param string $input + * @return string + */ + protected function remove_dot_segments($input) + { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') + { + // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) + { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) + { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) + { + $input = substr($input, 2); + } + elseif ($input === '/.') + { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) + { + $input = substr($input, 3); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') + { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') + { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) + { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else + { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + /** + * Replace invalid character with percent encoding + * + * @param string $string Input string + * @param string $extra_chars Valid characters not in iunreserved or + * iprivate (this is ASCII-only) + * @param bool $iprivate Allow iprivate + * @return string + */ + protected function replace_invalid_with_pct_encoding($string, $extra_chars, $iprivate = false) + { + // Normalize as many pct-encoded sections as possible + $string = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $string); + + // Replace invalid percent characters + $string = preg_replace('/%(?![A-Fa-f0-9]{2})/', '%25', $string); + + // Add unreserved and % to $extra_chars (the latter is safe because all + // pct-encoded sections are now valid). + $extra_chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~%'; + + // Now replace any bytes that aren't allowed with their pct-encoded versions + $position = 0; + $strlen = strlen($string); + while (($position += strspn($string, $extra_chars, $position)) < $strlen) + { + $value = ord($string[$position]); + + // Start position + $start = $position; + + // By default we are valid + $valid = true; + + // No one byte sequences are valid due to the while. + // Two byte sequence: + if (($value & 0xE0) === 0xC0) + { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) + { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) + { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else + { + $valid = false; + $length = 1; + $remaining = 0; + } + + if ($remaining) + { + if ($position + $length <= $strlen) + { + for ($position++; $remaining; $position++) + { + $value = ord($string[$position]); + + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) + { + $character |= ($value & 0x3F) << (--$remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte: + else + { + $valid = false; + $position--; + break; + } + } + } + else + { + $position = $strlen - 1; + $valid = false; + } + } + + // Percent encode anything invalid or not in ucschar + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of ucschar codepoints + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + || ( + // Everything else not in ucschar + $character > 0xD7FF && $character < 0xF900 + || $character < 0xA0 + || $character > 0xEFFFD + ) + && ( + // Everything not in iprivate, if it applies + !$iprivate + || $character < 0xE000 + || $character > 0x10FFFD + ) + ) + { + // If we were a character, pretend we weren't, but rather an error. + if ($valid) + $position--; + + for ($j = $start; $j <= $position; $j++) + { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); + $j += 2; + $position += 2; + $strlen += 2; + } + } + } + + return $string; + } + + /** + * Callback function for preg_replace_callback. + * + * Removes sequences of percent encoded bytes that represent UTF-8 + * encoded characters in iunreserved + * + * @param array $match PCRE match + * @return string Replacement + */ + protected function remove_iunreserved_percent_encoded($match) + { + // As we just have valid percent encoded sequences we can just explode + // and ignore the first member of the returned array (an empty string). + $bytes = explode('%', $match[0]); + + // Initialize the new string (this is what will be returned) and that + // there are no bytes remaining in the current sequence (unsurprising + // at the first byte!). + $string = ''; + $remaining = 0; + + // Loop over each and every byte, and set $value to its value + for ($i = 1, $len = count($bytes); $i < $len; $i++) + { + $value = hexdec($bytes[$i]); + + // If we're the first byte of sequence: + if (!$remaining) + { + // Start position + $start = $i; + + // By default we are valid + $valid = true; + + // One byte sequence: + if ($value <= 0x7F) + { + $character = $value; + $length = 1; + } + // Two byte sequence: + elseif (($value & 0xE0) === 0xC0) + { + $character = ($value & 0x1F) << 6; + $length = 2; + $remaining = 1; + } + // Three byte sequence: + elseif (($value & 0xF0) === 0xE0) + { + $character = ($value & 0x0F) << 12; + $length = 3; + $remaining = 2; + } + // Four byte sequence: + elseif (($value & 0xF8) === 0xF0) + { + $character = ($value & 0x07) << 18; + $length = 4; + $remaining = 3; + } + // Invalid byte: + else + { + $valid = false; + $remaining = 0; + } + } + // Continuation byte: + else + { + // Check that the byte is valid, then add it to the character: + if (($value & 0xC0) === 0x80) + { + $remaining--; + $character |= ($value & 0x3F) << ($remaining * 6); + } + // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: + else + { + $valid = false; + $remaining = 0; + $i--; + } + } + + // If we've reached the end of the current byte sequence, append it to Unicode::$data + if (!$remaining) + { + // Percent encode anything invalid or not in iunreserved + if ( + // Invalid sequences + !$valid + // Non-shortest form sequences are invalid + || $length > 1 && $character <= 0x7F + || $length > 2 && $character <= 0x7FF + || $length > 3 && $character <= 0xFFFF + // Outside of range of iunreserved codepoints + || $character < 0x2D + || $character > 0xEFFFD + // Noncharacters + || ($character & 0xFFFE) === 0xFFFE + || $character >= 0xFDD0 && $character <= 0xFDEF + // Everything else not in iunreserved (this is all BMP) + || $character === 0x2F + || $character > 0x39 && $character < 0x41 + || $character > 0x5A && $character < 0x61 + || $character > 0x7A && $character < 0x7E + || $character > 0x7E && $character < 0xA0 + || $character > 0xD7FF && $character < 0xF900 + ) + { + for ($j = $start; $j <= $i; $j++) + { + $string .= '%' . strtoupper($bytes[$j]); + } + } + else + { + for ($j = $start; $j <= $i; $j++) + { + $string .= chr(hexdec($bytes[$j])); + } + } + } + } + + // If we have any bytes left over they are invalid (i.e., we are + // mid-way through a multi-byte sequence) + if ($remaining) + { + for ($j = $start; $j < $len; $j++) + { + $string .= '%' . strtoupper($bytes[$j]); + } + } + + return $string; + } + + protected function scheme_normalization() + { + if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) + { + $this->iuserinfo = null; + } + if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) + { + $this->ihost = null; + } + if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) + { + $this->port = null; + } + if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) + { + $this->ipath = ''; + } + if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) + { + $this->iquery = null; + } + if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) + { + $this->ifragment = null; + } + } + + /** + * Check if the object represents a valid IRI. This needs to be done on each + * call as some things change depending on another part of the IRI. + * + * @return bool + */ + public function is_valid() + { + $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; + if ($this->ipath !== '' && + ( + $isauthority && ( + $this->ipath[0] !== '/' || + substr($this->ipath, 0, 2) === '//' + ) || + ( + $this->scheme === null && + !$isauthority && + strpos($this->ipath, ':') !== false && + (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) + ) + ) + ) + { + return false; + } + + return true; + } + + /** + * Set the entire IRI. Returns true on success, false on failure (if there + * are any invalid characters). + * + * @param string $iri + * @return bool + */ + public function set_iri($iri) + { + static $cache; + if (!$cache) + { + $cache = array(); + } + + if ($iri === null) + { + return true; + } + elseif (isset($cache[$iri])) + { + list($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return) = $cache[$iri]; + return $return; + } + else + { + $parsed = $this->parse_iri((string) $iri); + if (!$parsed) + { + return false; + } + + $return = $this->set_scheme($parsed['scheme']) + && $this->set_authority($parsed['authority']) + && $this->set_path($parsed['path']) + && $this->set_query($parsed['query']) + && $this->set_fragment($parsed['fragment']); + + $cache[$iri] = array($this->scheme, + $this->iuserinfo, + $this->ihost, + $this->port, + $this->ipath, + $this->iquery, + $this->ifragment, + $return); + return $return; + } + } + + /** + * Set the scheme. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $scheme + * @return bool + */ + public function set_scheme($scheme) + { + if ($scheme === null) + { + $this->scheme = null; + } + elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) + { + $this->scheme = null; + return false; + } + else + { + $this->scheme = strtolower($scheme); + } + return true; + } + + /** + * Set the authority. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $authority + * @return bool + */ + public function set_authority($authority) + { + static $cache; + if (!$cache) + $cache = array(); + + if ($authority === null) + { + $this->iuserinfo = null; + $this->ihost = null; + $this->port = null; + return true; + } + elseif (isset($cache[$authority])) + { + list($this->iuserinfo, + $this->ihost, + $this->port, + $return) = $cache[$authority]; + + return $return; + } + else + { + $remaining = $authority; + if (($iuserinfo_end = strrpos($remaining, '@')) !== false) + { + $iuserinfo = substr($remaining, 0, $iuserinfo_end); + $remaining = substr($remaining, $iuserinfo_end + 1); + } + else + { + $iuserinfo = null; + } + if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) + { + if (($port = substr($remaining, $port_start + 1)) === false) + { + $port = null; + } + $remaining = substr($remaining, 0, $port_start); + } + else + { + $port = null; + } + + $return = $this->set_userinfo($iuserinfo) && + $this->set_host($remaining) && + $this->set_port($port); + + $cache[$authority] = array($this->iuserinfo, + $this->ihost, + $this->port, + $return); + + return $return; + } + } + + /** + * Set the iuserinfo. + * + * @param string $iuserinfo + * @return bool + */ + public function set_userinfo($iuserinfo) + { + if ($iuserinfo === null) + { + $this->iuserinfo = null; + } + else + { + $this->iuserinfo = $this->replace_invalid_with_pct_encoding($iuserinfo, '!$&\'()*+,;=:'); + $this->scheme_normalization(); + } + + return true; + } + + /** + * Set the ihost. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $ihost + * @return bool + */ + public function set_host($ihost) + { + if ($ihost === null) + { + $this->ihost = null; + return true; + } + elseif (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') + { + if (SimplePie_Net_IPv6::check_ipv6(substr($ihost, 1, -1))) + { + $this->ihost = '[' . SimplePie_Net_IPv6::compress(substr($ihost, 1, -1)) . ']'; + } + else + { + $this->ihost = null; + return false; + } + } + else + { + $ihost = $this->replace_invalid_with_pct_encoding($ihost, '!$&\'()*+,;='); + + // Lowercase, but ignore pct-encoded sections (as they should + // remain uppercase). This must be done after the previous step + // as that can add unescaped characters. + $position = 0; + $strlen = strlen($ihost); + while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) + { + if ($ihost[$position] === '%') + { + $position += 3; + } + else + { + $ihost[$position] = strtolower($ihost[$position]); + $position++; + } + } + + $this->ihost = $ihost; + } + + $this->scheme_normalization(); + + return true; + } + + /** + * Set the port. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @param string $port + * @return bool + */ + public function set_port($port) + { + if ($port === null) + { + $this->port = null; + return true; + } + elseif (strspn($port, '0123456789') === strlen($port)) + { + $this->port = (int) $port; + $this->scheme_normalization(); + return true; + } + else + { + $this->port = null; + return false; + } + } + + /** + * Set the ipath. + * + * @param string $ipath + * @return bool + */ + public function set_path($ipath) + { + static $cache; + if (!$cache) + { + $cache = array(); + } + + $ipath = (string) $ipath; + + if (isset($cache[$ipath])) + { + $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; + } + else + { + $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); + $removed = $this->remove_dot_segments($valid); + + $cache[$ipath] = array($valid, $removed); + $this->ipath = ($this->scheme !== null) ? $removed : $valid; + } + + $this->scheme_normalization(); + return true; + } + + /** + * Set the iquery. + * + * @param string $iquery + * @return bool + */ + public function set_query($iquery) + { + if ($iquery === null) + { + $this->iquery = null; + } + else + { + $this->iquery = $this->replace_invalid_with_pct_encoding($iquery, '!$&\'()*+,;=:@/?', true); + $this->scheme_normalization(); + } + return true; + } + + /** + * Set the ifragment. + * + * @param string $ifragment + * @return bool + */ + public function set_fragment($ifragment) + { + if ($ifragment === null) + { + $this->ifragment = null; + } + else + { + $this->ifragment = $this->replace_invalid_with_pct_encoding($ifragment, '!$&\'()*+,;=:@/?'); + $this->scheme_normalization(); + } + return true; + } + + /** + * Convert an IRI to a URI (or parts thereof) + * + * @return string + */ + public function to_uri($string) + { + static $non_ascii; + if (!$non_ascii) + { + $non_ascii = implode('', range("\x80", "\xFF")); + } + + $position = 0; + $strlen = strlen($string); + while (($position += strcspn($string, $non_ascii, $position)) < $strlen) + { + $string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); + $position += 3; + $strlen += 2; + } + + return $string; + } + + /** + * Get the complete IRI + * + * @return string + */ + public function get_iri() + { + if (!$this->is_valid()) + { + return false; + } + + $iri = ''; + if ($this->scheme !== null) + { + $iri .= $this->scheme . ':'; + } + if (($iauthority = $this->get_iauthority()) !== null) + { + $iri .= '//' . $iauthority; + } + if ($this->ipath !== '') + { + $iri .= $this->ipath; + } + elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') + { + $iri .= $this->normalization[$this->scheme]['ipath']; + } + if ($this->iquery !== null) + { + $iri .= '?' . $this->iquery; + } + if ($this->ifragment !== null) + { + $iri .= '#' . $this->ifragment; + } + + return $iri; + } + + /** + * Get the complete URI + * + * @return string + */ + public function get_uri() + { + return $this->to_uri($this->get_iri()); + } + + /** + * Get the complete iauthority + * + * @return string + */ + protected function get_iauthority() + { + if ($this->iuserinfo !== null || $this->ihost !== null || $this->port !== null) + { + $iauthority = ''; + if ($this->iuserinfo !== null) + { + $iauthority .= $this->iuserinfo . '@'; + } + if ($this->ihost !== null) + { + $iauthority .= $this->ihost; + } + if ($this->port !== null) + { + $iauthority .= ':' . $this->port; + } + return $iauthority; + } + else + { + return null; + } + } + + /** + * Get the complete authority + * + * @return string + */ + protected function get_authority() + { + $iauthority = $this->get_iauthority(); + if (is_string($iauthority)) + return $this->to_uri($iauthority); + else + return $iauthority; + } +} diff --git a/backend/wp-includes/SimplePie/Item.php b/backend/wp-includes/SimplePie/Item.php new file mode 100644 index 0000000..a77574b --- /dev/null +++ b/backend/wp-includes/SimplePie/Item.php @@ -0,0 +1,2964 @@ +feed = $feed; + $this->data = $data; + } + + /** + * Set the registry handler + * + * This is usually used by {@see SimplePie_Registry::create} + * + * @since 1.3 + * @param SimplePie_Registry $registry + */ + public function set_registry(SimplePie_Registry $registry) + { + $this->registry = $registry; + } + + /** + * Get a string representation of the item + * + * @return string + */ + public function __toString() + { + return md5(serialize($this->data)); + } + + /** + * Remove items that link back to this before destroying this object + */ + public function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + unset($this->feed); + } + } + + /** + * Get data for an item-level element + * + * This method allows you to get access to ANY element/attribute that is a + * sub-element of the item/entry tag. + * + * See {@see SimplePie::get_feed_tags()} for a description of the return value + * + * @since 1.0 + * @see http://simplepie.org/wiki/faq/supported_xml_namespaces + * @param string $namespace The URL of the XML namespace of the elements you're trying to access + * @param string $tag Tag name + * @return array + */ + public function get_item_tags($namespace, $tag) + { + if (isset($this->data['child'][$namespace][$tag])) + { + return $this->data['child'][$namespace][$tag]; + } + else + { + return null; + } + } + + /** + * Get the base URL value from the parent feed + * + * Uses `` + * + * @param array $element + * @return string + */ + public function get_base($element = array()) + { + return $this->feed->get_base($element); + } + + /** + * Sanitize feed data + * + * @access private + * @see SimplePie::sanitize() + * @param string $data Data to sanitize + * @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants + * @param string $base Base URL to resolve URLs against + * @return string Sanitized data + */ + public function sanitize($data, $type, $base = '') + { + return $this->feed->sanitize($data, $type, $base); + } + + /** + * Get the parent feed + * + * Note: this may not work as you think for multifeeds! + * + * @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed + * @since 1.0 + * @return SimplePie + */ + public function get_feed() + { + return $this->feed; + } + + /** + * Get the unique identifier for the item + * + * This is usually used when writing code to check for new items in a feed. + * + * Uses ``, ``, `` or the `about` attribute + * for RDF. If none of these are supplied (or `$hash` is true), creates an + * MD5 hash based on the permalink and title. If either of those are not + * supplied, creates a hash based on the full feed data. + * + * @since Beta 2 + * @param boolean $hash Should we force using a hash instead of the supplied ID? + * @return string + */ + public function get_id($hash = false) + { + if (!$hash) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'])) + { + return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (($return = $this->get_permalink()) !== null) + { + return $return; + } + elseif (($return = $this->get_title()) !== null) + { + return $return; + } + } + if ($this->get_permalink() !== null || $this->get_title() !== null) + { + return md5($this->get_permalink() . $this->get_title()); + } + else + { + return md5(serialize($this->data)); + } + } + + /** + * Get the title of the item + * + * Uses ``, `` or `<dc:title>` + * + * @since Beta 2 (previously called `get_item_title` since 0.8) + * @return string|null + */ + public function get_title() + { + if (!isset($this->data['title'])) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $this->data['title'] = null; + } + } + return $this->data['title']; + } + + /** + * Get the content for the item + * + * Prefers summaries over full content , but will return full content if a + * summary does not exist. + * + * To prefer full content instead, use {@see get_content} + * + * Uses `<atom:summary>`, `<description>`, `<dc:description>` or + * `<itunes:subtitle>` + * + * @since 0.8 + * @param boolean $description_only Should we avoid falling back to the content? + * @return string|null + */ + public function get_description($description_only = false) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); + } + + elseif (!$description_only) + { + return $this->get_content(true); + } + else + { + return null; + } + } + + /** + * Get the content for the item + * + * Prefers full content over summaries, but will return a summary if full + * content does not exist. + * + * To prefer summaries instead, use {@see get_description} + * + * Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module) + * + * @since 1.0 + * @param boolean $content_only Should we avoid falling back to the description? + * @return string|null + */ + public function get_content($content_only = false) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif (!$content_only) + { + return $this->get_description(true); + } + else + { + return null; + } + } + + /** + * Get a category for the item + * + * @since Beta 3 (previously called `get_categories()` since Beta 2) + * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Category|null + */ + public function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + /** + * Get all categories for the item + * + * Uses `<atom:category>`, `<category>` or `<dc:subject>` + * + * @since Beta 3 + * @return array|null List of {@see SimplePie_Category} objects + */ + public function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = $this->registry->create('Category', array($term, $scheme, null)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($categories)) + { + return array_unique($categories); + } + else + { + return null; + } + } + + /** + * Get an author for the item + * + * @since Beta 2 + * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Author|null + */ + public function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + /** + * Get a contributor for the item + * + * @since 1.1 + * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Author|null + */ + public function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + /** + * Get all contributors for the item + * + * Uses `<atom:contributor>` + * + * @since 1.1 + * @return array|null List of {@see SimplePie_Author} objects + */ + public function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + + if (!empty($contributors)) + { + return array_unique($contributors); + } + else + { + return null; + } + } + + /** + * Get all authors for the item + * + * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>` + * + * @since Beta 2 + * @return array|null List of {@see SimplePie_Author} objects + */ + public function get_authors() + { + $authors = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) + { + $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($authors)) + { + return array_unique($authors); + } + elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) + { + return $authors; + } + elseif ($authors = $this->feed->get_authors()) + { + return $authors; + } + else + { + return null; + } + } + + /** + * Get the copyright info for the item + * + * Uses `<atom:rights>` or `<dc:rights>` + * + * @since 1.1 + * @return string + */ + public function get_copyright() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + /** + * Get the posting date/time for the item + * + * Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`, + * `<atom:modified>`, `<pubDate>` or `<dc:date>` + * + * Note: obeys PHP's timezone setting. To get a UTC date/time, use + * {@see get_gmdate} + * + * @since Beta 2 (previously called `get_item_date` since 0.8) + * + * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) + * @return int|string|null + */ + public function get_date($date_format = 'j F Y, g:i a') + { + if (!isset($this->data['date'])) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + + if (!empty($this->data['date']['raw'])) + { + $parser = $this->registry->call('Parse_Date', 'get'); + $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); + } + else + { + $this->data['date'] = null; + } + } + if ($this->data['date']) + { + $date_format = (string) $date_format; + switch ($date_format) + { + case '': + return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); + + case 'U': + return $this->data['date']['parsed']; + + default: + return date($date_format, $this->data['date']['parsed']); + } + } + else + { + return null; + } + } + + /** + * Get the update date/time for the item + * + * Uses `<atom:updated>` + * + * Note: obeys PHP's timezone setting. To get a UTC date/time, use + * {@see get_gmdate} + * + * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) + * @return int|string|null + */ + public function get_updated_date($date_format = 'j F Y, g:i a') + { + if (!isset($this->data['updated'])) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) + { + $this->data['updated']['raw'] = $return[0]['data']; + } + + if (!empty($this->data['updated']['raw'])) + { + $parser = $this->registry->call('Parse_Date', 'get'); + $this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']); + } + else + { + $this->data['updated'] = null; + } + } + if ($this->data['updated']) + { + $date_format = (string) $date_format; + switch ($date_format) + { + case '': + return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); + + case 'U': + return $this->data['updated']['parsed']; + + default: + return date($date_format, $this->data['updated']['parsed']); + } + } + else + { + return null; + } + } + + /** + * Get the localized posting date/time for the item + * + * Returns the date formatted in the localized language. To display in + * languages other than the server's default, you need to change the locale + * with {@link http://php.net/setlocale setlocale()}. The available + * localizations depend on which ones are installed on your web server. + * + * @since 1.0 + * + * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data) + * @return int|string|null + */ + public function get_local_date($date_format = '%c') + { + if (!$date_format) + { + return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (($date = $this->get_date('U')) !== null && $date !== false) + { + return strftime($date_format, $date); + } + else + { + return null; + } + } + + /** + * Get the posting date/time for the item (UTC time) + * + * @see get_date + * @param string $date_format Supports any PHP date format from {@see http://php.net/date} + * @return int|string|null + */ + public function get_gmdate($date_format = 'j F Y, g:i a') + { + $date = $this->get_date('U'); + if ($date === null) + { + return null; + } + + return gmdate($date_format, $date); + } + + /** + * Get the update date/time for the item (UTC time) + * + * @see get_updated_date + * @param string $date_format Supports any PHP date format from {@see http://php.net/date} + * @return int|string|null + */ + public function get_updated_gmdate($date_format = 'j F Y, g:i a') + { + $date = $this->get_updated_date('U'); + if ($date === null) + { + return null; + } + + return gmdate($date_format, $date); + } + + /** + * Get the permalink for the item + * + * Returns the first link available with a relationship of "alternate". + * Identical to {@see get_link()} with key 0 + * + * @see get_link + * @since 0.8 + * @return string|null Permalink URL + */ + public function get_permalink() + { + $link = $this->get_link(); + $enclosure = $this->get_enclosure(0); + if ($link !== null) + { + return $link; + } + elseif ($enclosure !== null) + { + return $enclosure->get_link(); + } + else + { + return null; + } + } + + /** + * Get a single link for the item + * + * @since Beta 3 + * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 + * @param string $rel The relationship of the link to return + * @return string|null Link URL + */ + public function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if ($links[$key] !== null) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Get all links for the item + * + * Uses `<atom:link>`, `<link>` or `<guid>` + * + * @since Beta 2 + * @param string $rel The relationship of links to return + * @return array|null Links found for the item (strings) + */ + public function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) + { + if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + /** + * Get an enclosure from the item + * + * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS. + * + * @since Beta 2 + * @todo Add ability to prefer one type of content over another (in a media group). + * @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Enclosure|null + */ + public function get_enclosure($key = 0, $prefer = null) + { + $enclosures = $this->get_enclosures(); + if (isset($enclosures[$key])) + { + return $enclosures[$key]; + } + else + { + return null; + } + } + + /** + * Get all available enclosures (podcasts, etc.) + * + * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS. + * + * At this point, we're pretty much assuming that all enclosures for an item + * are the same content. Anything else is too complicated to + * properly support. + * + * @since Beta 2 + * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). + * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). + * @return array|null List of SimplePie_Enclosure items + */ + public function get_enclosures() + { + if (!isset($this->data['enclosures'])) + { + $this->data['enclosures'] = array(); + + // Elements + $captions_parent = null; + $categories_parent = null; + $copyrights_parent = null; + $credits_parent = null; + $description_parent = null; + $duration_parent = null; + $hashes_parent = null; + $keywords_parent = null; + $player_parent = null; + $ratings_parent = null; + $restrictions_parent = null; + $thumbnails_parent = null; + $title_parent = null; + + // Let's do the channel and item-level ones first, and just re-use them if we need to. + $parent = $this->get_feed(); + + // CAPTIONS + if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) + { + foreach ($captions as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); + } + } + elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) + { + foreach ($captions as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); + } + } + if (is_array($captions_parent)) + { + $captions_parent = array_values(array_unique($captions_parent)); + } + + // CATEGORIES + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) + { + $term = null; + $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; + $label = null; + if (isset($category['attribs']['']['text'])) + { + $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); + + if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) + { + foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) + { + if (isset($subcategory['attribs']['']['text'])) + { + $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + } + } + if (is_array($categories_parent)) + { + $categories_parent = array_values(array_unique($categories_parent)); + } + + // COPYRIGHT + if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) + { + $copyright_url = null; + $copyright_label = null; + if (isset($copyright[0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($copyright[0]['data'])) + { + $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); + } + elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) + { + $copyright_url = null; + $copyright_label = null; + if (isset($copyright[0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($copyright[0]['data'])) + { + $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); + } + + // CREDITS + if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) + { + foreach ($credits as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); + } + } + elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) + { + foreach ($credits as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); + } + } + if (is_array($credits_parent)) + { + $credits_parent = array_values(array_unique($credits_parent)); + } + + // DESCRIPTION + if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) + { + if (isset($description_parent[0]['data'])) + { + $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) + { + if (isset($description_parent[0]['data'])) + { + $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + + // DURATION + if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) + { + $seconds = null; + $minutes = null; + $hours = null; + if (isset($duration_parent[0]['data'])) + { + $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + if (sizeof($temp) > 0) + { + $seconds = (int) array_pop($temp); + } + if (sizeof($temp) > 0) + { + $minutes = (int) array_pop($temp); + $seconds += $minutes * 60; + } + if (sizeof($temp) > 0) + { + $hours = (int) array_pop($temp); + $seconds += $hours * 3600; + } + unset($temp); + $duration_parent = $seconds; + } + } + + // HASHES + if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) + { + foreach ($hashes_iterator as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes_parent[] = $algo.':'.$value; + } + } + elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) + { + foreach ($hashes_iterator as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes_parent[] = $algo.':'.$value; + } + } + if (is_array($hashes_parent)) + { + $hashes_parent = array_values(array_unique($hashes_parent)); + } + + // KEYWORDS + if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + if (is_array($keywords_parent)) + { + $keywords_parent = array_values(array_unique($keywords_parent)); + } + + // PLAYER + if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) + { + if (isset($player_parent[0]['attribs']['']['url'])) + { + $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) + { + if (isset($player_parent[0]['attribs']['']['url'])) + { + $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + + // RATINGS + if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) + { + foreach ($ratings as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + } + elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) + { + foreach ($ratings as $rating) + { + $rating_scheme = 'urn:itunes'; + $rating_value = null; + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + } + elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) + { + foreach ($ratings as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + } + elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) + { + foreach ($ratings as $rating) + { + $rating_scheme = 'urn:itunes'; + $rating_value = null; + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + } + if (is_array($ratings_parent)) + { + $ratings_parent = array_values(array_unique($ratings_parent)); + } + + // RESTRICTIONS + if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + } + elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = 'allow'; + $restriction_type = null; + $restriction_value = 'itunes'; + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') + { + $restriction_relationship = 'deny'; + } + $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + } + elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + } + elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = 'allow'; + $restriction_type = null; + $restriction_value = 'itunes'; + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') + { + $restriction_relationship = 'deny'; + } + $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + } + if (is_array($restrictions_parent)) + { + $restrictions_parent = array_values(array_unique($restrictions_parent)); + } + else + { + $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); + } + + // THUMBNAILS + if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) + { + foreach ($thumbnails as $thumbnail) + { + if (isset($thumbnail['attribs']['']['url'])) + { + $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + } + elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) + { + foreach ($thumbnails as $thumbnail) + { + if (isset($thumbnail['attribs']['']['url'])) + { + $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + } + + // TITLES + if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) + { + if (isset($title_parent[0]['data'])) + { + $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) + { + if (isset($title_parent[0]['data'])) + { + $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + + // Clear the memory + unset($parent); + + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // If we have media:group tags, loop through them. + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) + { + if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) + { + // If we have media:content tags, loop through them. + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) + { + if (isset($content['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // Start checking the attributes of media:content + if (isset($content['attribs']['']['bitrate'])) + { + $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['channels'])) + { + $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['duration'])) + { + $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $duration = $duration_parent; + } + if (isset($content['attribs']['']['expression'])) + { + $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['framerate'])) + { + $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['height'])) + { + $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['lang'])) + { + $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['fileSize'])) + { + $length = ceil($content['attribs']['']['fileSize']); + } + if (isset($content['attribs']['']['medium'])) + { + $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['samplingrate'])) + { + $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['type'])) + { + $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['width'])) + { + $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + + // Checking the other optional media: elements. Priority: media:content, media:group, item, channel + + // CAPTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); + } + if (is_array($captions)) + { + $captions = array_values(array_unique($captions)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); + } + if (is_array($captions)) + { + $captions = array_values(array_unique($captions)); + } + } + else + { + $captions = $captions_parent; + } + + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + } + if (is_array($categories) && is_array($categories_parent)) + { + $categories = array_values(array_unique(array_merge($categories, $categories_parent))); + } + elseif (is_array($categories)) + { + $categories = array_values(array_unique($categories)); + } + elseif (is_array($categories_parent)) + { + $categories = array_values(array_unique($categories_parent)); + } + + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); + } + else + { + $copyrights = $copyrights_parent; + } + + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); + } + if (is_array($credits)) + { + $credits = array_values(array_unique($credits)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); + } + if (is_array($credits)) + { + $credits = array_values(array_unique($credits)); + } + } + else + { + $credits = $credits_parent; + } + + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $description = $description_parent; + } + + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(array_unique($hashes)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(array_unique($hashes)); + } + } + else + { + $hashes = $hashes_parent; + } + + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(array_unique($keywords)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(array_unique($keywords)); + } + } + else + { + $keywords = $keywords_parent; + } + + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $player = $player_parent; + } + + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + if (is_array($ratings)) + { + $ratings = array_values(array_unique($ratings)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + if (is_array($ratings)) + { + $ratings = array_values(array_unique($ratings)); + } + } + else + { + $ratings = $ratings_parent; + } + + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + if (is_array($restrictions)) + { + $restrictions = array_values(array_unique($restrictions)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + if (is_array($restrictions)) + { + $restrictions = array_values(array_unique($restrictions)); + } + } + else + { + $restrictions = $restrictions_parent; + } + + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(array_unique($thumbnails)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(array_unique($thumbnails)); + } + } + else + { + $thumbnails = $thumbnails_parent; + } + + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $title = $title_parent; + } + + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); + } + } + } + } + + // If we have standalone media:content tags, loop through them. + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) + { + foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) + { + if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // Start checking the attributes of media:content + if (isset($content['attribs']['']['bitrate'])) + { + $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['channels'])) + { + $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['duration'])) + { + $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $duration = $duration_parent; + } + if (isset($content['attribs']['']['expression'])) + { + $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['framerate'])) + { + $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['height'])) + { + $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['lang'])) + { + $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['fileSize'])) + { + $length = ceil($content['attribs']['']['fileSize']); + } + if (isset($content['attribs']['']['medium'])) + { + $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['samplingrate'])) + { + $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['type'])) + { + $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['width'])) + { + $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['url'])) + { + $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + // Checking the other optional media: elements. Priority: media:content, media:group, item, channel + + // CAPTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); + } + if (is_array($captions)) + { + $captions = array_values(array_unique($captions)); + } + } + else + { + $captions = $captions_parent; + } + + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + } + if (is_array($categories) && is_array($categories_parent)) + { + $categories = array_values(array_unique(array_merge($categories, $categories_parent))); + } + elseif (is_array($categories)) + { + $categories = array_values(array_unique($categories)); + } + elseif (is_array($categories_parent)) + { + $categories = array_values(array_unique($categories_parent)); + } + else + { + $categories = null; + } + + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); + } + else + { + $copyrights = $copyrights_parent; + } + + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); + } + if (is_array($credits)) + { + $credits = array_values(array_unique($credits)); + } + } + else + { + $credits = $credits_parent; + } + + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $description = $description_parent; + } + + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(array_unique($hashes)); + } + } + else + { + $hashes = $hashes_parent; + } + + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(array_unique($keywords)); + } + } + else + { + $keywords = $keywords_parent; + } + + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $player = $player_parent; + } + + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); + } + if (is_array($ratings)) + { + $ratings = array_values(array_unique($ratings)); + } + } + else + { + $ratings = $ratings_parent; + } + + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); + } + if (is_array($restrictions)) + { + $restrictions = array_values(array_unique($restrictions)); + } + } + else + { + $restrictions = $restrictions_parent; + } + + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(array_unique($thumbnails)); + } + } + else + { + $thumbnails = $thumbnails_parent; + } + + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $title = $title_parent; + } + + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); + } + } + } + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) + { + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + if (isset($link['attribs']['']['type'])) + { + $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($link['attribs']['']['length'])) + { + $length = ceil($link['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); + } + } + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) + { + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + if (isset($link['attribs']['']['type'])) + { + $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($link['attribs']['']['length'])) + { + $length = ceil($link['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); + } + } + + if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) + { + if (isset($enclosure[0]['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); + if (isset($enclosure[0]['attribs']['']['type'])) + { + $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($enclosure[0]['attribs']['']['length'])) + { + $length = ceil($enclosure[0]['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); + } + } + + if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) + { + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); + } + + $this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); + } + if (!empty($this->data['enclosures'])) + { + return $this->data['enclosures']; + } + else + { + return null; + } + } + + /** + * Get the latitude coordinates for the item + * + * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications + * + * Uses `<geo:lat>` or `<georss:point>` + * + * @since 1.0 + * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo + * @link http://www.georss.org/ GeoRSS + * @return string|null + */ + public function get_latitude() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + /** + * Get the longitude coordinates for the item + * + * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications + * + * Uses `<geo:long>`, `<geo:lon>` or `<georss:point>` + * + * @since 1.0 + * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo + * @link http://www.georss.org/ GeoRSS + * @return string|null + */ + public function get_longitude() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + /** + * Get the `<atom:source>` for the item + * + * @since 1.1 + * @return SimplePie_Source|null + */ + public function get_source() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) + { + return $this->registry->create('Source', array($this, $return[0])); + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Locator.php b/backend/wp-includes/SimplePie/Locator.php new file mode 100644 index 0000000..da89514 --- /dev/null +++ b/backend/wp-includes/SimplePie/Locator.php @@ -0,0 +1,372 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Used for feed auto-discovery + * + * + * This class can be overloaded with {@see SimplePie::set_locator_class()} + * + * @package SimplePie + */ +class SimplePie_Locator +{ + var $useragent; + var $timeout; + var $file; + var $local = array(); + var $elsewhere = array(); + var $cached_entities = array(); + var $http_base; + var $base; + var $base_location = 0; + var $checked_feeds = 0; + var $max_checked_feeds = 10; + protected $registry; + + public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10) + { + $this->file = $file; + $this->useragent = $useragent; + $this->timeout = $timeout; + $this->max_checked_feeds = $max_checked_feeds; + + if (class_exists('DOMDocument')) + { + $this->dom = new DOMDocument(); + + set_error_handler(array('SimplePie_Misc', 'silence_errors')); + $this->dom->loadHTML($this->file->body); + restore_error_handler(); + } + else + { + $this->dom = null; + } + } + + public function set_registry(SimplePie_Registry $registry) + { + $this->registry = $registry; + } + + public function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) + { + if ($this->is_feed($this->file)) + { + return $this->file; + } + + if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = $this->registry->create('Content_Type_Sniffer', array($this->file)); + if ($sniffer->get_type() !== 'text/html') + { + return null; + } + } + + if ($type & ~SIMPLEPIE_LOCATOR_NONE) + { + $this->get_base(); + } + + if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) + { + return $working[0]; + } + + if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) + { + if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) + { + return $working; + } + } + return null; + } + + public function is_feed($file) + { + if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = $this->registry->create('Content_Type_Sniffer', array($file)); + $sniffed = $sniffer->get_type(); + if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) + { + return true; + } + else + { + return false; + } + } + elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) + { + return true; + } + else + { + return false; + } + } + + public function get_base() + { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } + $this->http_base = $this->file->url; + $this->base = $this->http_base; + $elements = $this->dom->getElementsByTagName('base'); + foreach ($elements as $element) + { + if ($element->hasAttribute('href')) + { + $base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); + if ($base === false) + { + continue; + } + $this->base = $base; + $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0; + break; + } + } + } + + public function autodiscovery() + { + $done = array(); + $feeds = array(); + $feeds = array_merge($feeds, $this->search_elements_by_tag('link', $done, $feeds)); + $feeds = array_merge($feeds, $this->search_elements_by_tag('a', $done, $feeds)); + $feeds = array_merge($feeds, $this->search_elements_by_tag('area', $done, $feeds)); + + if (!empty($feeds)) + { + return array_values($feeds); + } + else + { + return null; + } + } + + protected function search_elements_by_tag($name, &$done, $feeds) + { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } + + $links = $this->dom->getElementsByTagName($name); + foreach ($links as $link) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if ($link->hasAttribute('href') && $link->hasAttribute('rel')) + { + $rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel'))))); + $line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1; + + if ($this->base_location < $line) + { + $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); + } + else + { + $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); + } + if ($href === false) + { + continue; + } + + if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) + { + $this->checked_feeds++; + $headers = array( + 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', + ); + $feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent)); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + $feeds[$href] = $feed; + } + } + $done[] = $href; + } + } + + return $feeds; + } + + public function get_links() + { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } + + $links = $this->dom->getElementsByTagName('a'); + foreach ($links as $link) + { + if ($link->hasAttribute('href')) + { + $href = trim($link->getAttribute('href')); + $parsed = $this->registry->call('Misc', 'parse_url', array($href)); + if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) + { + if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()) + { + $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->base)); + } + else + { + $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); + } + if ($href === false) + { + continue; + } + + $current = $this->registry->call('Misc', 'parse_url', array($this->file->url)); + + if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) + { + $this->local[] = $href; + } + else + { + $this->elsewhere[] = $href; + } + } + } + } + $this->local = array_unique($this->local); + $this->elsewhere = array_unique($this->elsewhere); + if (!empty($this->local) || !empty($this->elsewhere)) + { + return true; + } + return null; + } + + public function extension(&$array) + { + foreach ($array as $key => $value) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) + { + $this->checked_feeds++; + + $headers = array( + 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', + ); + $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent)); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + return $feed; + } + else + { + unset($array[$key]); + } + } + } + return null; + } + + public function body(&$array) + { + foreach ($array as $key => $value) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if (preg_match('/(rss|rdf|atom|xml)/i', $value)) + { + $this->checked_feeds++; + $headers = array( + 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', + ); + $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent)); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + return $feed; + } + else + { + unset($array[$key]); + } + } + } + return null; + } +} + diff --git a/backend/wp-includes/SimplePie/Misc.php b/backend/wp-includes/SimplePie/Misc.php new file mode 100644 index 0000000..1c1b618 --- /dev/null +++ b/backend/wp-includes/SimplePie/Misc.php @@ -0,0 +1,2247 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Miscellanous utilities + * + * @package SimplePie + */ +class SimplePie_Misc +{ + public static function time_hms($seconds) + { + $time = ''; + + $hours = floor($seconds / 3600); + $remainder = $seconds % 3600; + if ($hours > 0) + { + $time .= $hours.':'; + } + + $minutes = floor($remainder / 60); + $seconds = $remainder % 60; + if ($minutes < 10 && $hours > 0) + { + $minutes = '0' . $minutes; + } + if ($seconds < 10) + { + $seconds = '0' . $seconds; + } + + $time .= $minutes.':'; + $time .= $seconds; + + return $time; + } + + public static function absolutize_url($relative, $base) + { + $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); + if ($iri === false) + { + return false; + } + return $iri->get_uri(); + } + + /** + * Get a HTML/XML element from a HTML string + * + * @deprecated Use DOMDocument instead (parsing HTML with regex is bad!) + * @param string $realname Element name (including namespace prefix if applicable) + * @param string $string HTML document + * @return array + */ + public static function get_element($realname, $string) + { + $return = array(); + $name = preg_quote($realname, '/'); + if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) + { + for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) + { + $return[$i]['tag'] = $realname; + $return[$i]['full'] = $matches[$i][0][0]; + $return[$i]['offset'] = $matches[$i][0][1]; + if (strlen($matches[$i][3][0]) <= 2) + { + $return[$i]['self_closing'] = true; + } + else + { + $return[$i]['self_closing'] = false; + $return[$i]['content'] = $matches[$i][4][0]; + } + $return[$i]['attribs'] = array(); + if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) + { + for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) + { + if (count($attribs[$j]) === 2) + { + $attribs[$j][2] = $attribs[$j][1]; + } + $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j])); + } + } + } + } + return $return; + } + + public static function element_implode($element) + { + $full = "<$element[tag]"; + foreach ($element['attribs'] as $key => $value) + { + $key = strtolower($key); + $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; + } + if ($element['self_closing']) + { + $full .= ' />'; + } + else + { + $full .= ">$element[content]</$element[tag]>"; + } + return $full; + } + + public static function error($message, $level, $file, $line) + { + if ((ini_get('error_reporting') & $level) > 0) + { + switch ($level) + { + case E_USER_ERROR: + $note = 'PHP Error'; + break; + case E_USER_WARNING: + $note = 'PHP Warning'; + break; + case E_USER_NOTICE: + $note = 'PHP Notice'; + break; + default: + $note = 'Unknown Error'; + break; + } + + $log_error = true; + if (!function_exists('error_log')) + { + $log_error = false; + } + + $log_file = @ini_get('error_log'); + if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file)) + { + $log_error = false; + } + + if ($log_error) + { + @error_log("$note: $message in $file on line $line", 0); + } + } + + return $message; + } + + public static function fix_protocol($url, $http = 1) + { + $url = SimplePie_Misc::normalize_url($url); + $parsed = SimplePie_Misc::parse_url($url); + if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') + { + return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); + } + + if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) + { + return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); + } + + if ($http === 2 && $parsed['scheme'] !== '') + { + return "feed:$url"; + } + elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'podcast', 0, 4); + } + elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'itpc', 0, 4); + } + else + { + return $url; + } + } + + public static function parse_url($url) + { + $iri = new SimplePie_IRI($url); + return array( + 'scheme' => (string) $iri->scheme, + 'authority' => (string) $iri->authority, + 'path' => (string) $iri->path, + 'query' => (string) $iri->query, + 'fragment' => (string) $iri->fragment + ); + } + + public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') + { + $iri = new SimplePie_IRI(''); + $iri->scheme = $scheme; + $iri->authority = $authority; + $iri->path = $path; + $iri->query = $query; + $iri->fragment = $fragment; + return $iri->get_uri(); + } + + public static function normalize_url($url) + { + $iri = new SimplePie_IRI($url); + return $iri->get_uri(); + } + + public static function percent_encoding_normalization($match) + { + $integer = hexdec($match[1]); + if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) + { + return chr($integer); + } + else + { + return strtoupper($match[0]); + } + } + + /** + * Converts a Windows-1252 encoded string to a UTF-8 encoded string + * + * @static + * @param string $string Windows-1252 encoded string + * @return string UTF-8 encoded string + */ + public static function windows_1252_to_utf8($string) + { + static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"); + + return strtr($string, $convert_table); + } + + /** + * Change a string from one encoding to another + * + * @param string $data Raw data in $input encoding + * @param string $input Encoding of $data + * @param string $output Encoding you want + * @return string|boolean False if we can't convert it + */ + public static function change_encoding($data, $input, $output) + { + $input = SimplePie_Misc::encoding($input); + $output = SimplePie_Misc::encoding($output); + + // We fail to fail on non US-ASCII bytes + if ($input === 'US-ASCII') + { + static $non_ascii_octects = ''; + if (!$non_ascii_octects) + { + for ($i = 0x80; $i <= 0xFF; $i++) + { + $non_ascii_octects .= chr($i); + } + } + $data = substr($data, 0, strcspn($data, $non_ascii_octects)); + } + + // This is first, as behaviour of this is completely predictable + if ($input === 'windows-1252' && $output === 'UTF-8') + { + return SimplePie_Misc::windows_1252_to_utf8($data); + } + // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). + elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output))) + { + return $return; + } + // This is last, as behaviour of this varies with OS userland and PHP version + elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) + { + return $return; + } + // If we can't do anything, just fail + else + { + return false; + } + } + + protected static function change_encoding_mbstring($data, $input, $output) + { + if ($input === 'windows-949') + { + $input = 'EUC-KR'; + } + if ($output === 'windows-949') + { + $output = 'EUC-KR'; + } + if ($input === 'Windows-31J') + { + $input = 'SJIS'; + } + if ($output === 'Windows-31J') + { + $output = 'SJIS'; + } + + // Check that the encoding is supported + if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80") + { + return false; + } + if (!in_array($input, mb_list_encodings())) + { + return false; + } + + // Let's do some conversion + if ($return = @mb_convert_encoding($data, $output, $input)) + { + return $return; + } + + return false; + } + + protected static function change_encoding_iconv($data, $input, $output) + { + return @iconv($input, $output, $data); + } + + /** + * Normalize an encoding name + * + * This is automatically generated by create.php + * + * To generate it, run `php create.php` on the command line, and copy the + * output to replace this function. + * + * @param string $charset Character set to standardise + * @return string Standardised name + */ + public static function encoding($charset) + { + // Normalization from UTS #22 + switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) + { + case 'adobestandardencoding': + case 'csadobestandardencoding': + return 'Adobe-Standard-Encoding'; + + case 'adobesymbolencoding': + case 'cshppsmath': + return 'Adobe-Symbol-Encoding'; + + case 'ami1251': + case 'amiga1251': + return 'Amiga-1251'; + + case 'ansix31101983': + case 'csat5001983': + case 'csiso99naplps': + case 'isoir99': + case 'naplps': + return 'ANSI_X3.110-1983'; + + case 'arabic7': + case 'asmo449': + case 'csiso89asmo449': + case 'iso9036': + case 'isoir89': + return 'ASMO_449'; + + case 'big5': + case 'csbig5': + return 'Big5'; + + case 'big5hkscs': + return 'Big5-HKSCS'; + + case 'bocu1': + case 'csbocu1': + return 'BOCU-1'; + + case 'brf': + case 'csbrf': + return 'BRF'; + + case 'bs4730': + case 'csiso4unitedkingdom': + case 'gb': + case 'iso646gb': + case 'isoir4': + case 'uk': + return 'BS_4730'; + + case 'bsviewdata': + case 'csiso47bsviewdata': + case 'isoir47': + return 'BS_viewdata'; + + case 'cesu8': + case 'cscesu8': + return 'CESU-8'; + + case 'ca': + case 'csa71': + case 'csaz243419851': + case 'csiso121canadian1': + case 'iso646ca': + case 'isoir121': + return 'CSA_Z243.4-1985-1'; + + case 'csa72': + case 'csaz243419852': + case 'csiso122canadian2': + case 'iso646ca2': + case 'isoir122': + return 'CSA_Z243.4-1985-2'; + + case 'csaz24341985gr': + case 'csiso123csaz24341985gr': + case 'isoir123': + return 'CSA_Z243.4-1985-gr'; + + case 'csiso139csn369103': + case 'csn369103': + case 'isoir139': + return 'CSN_369103'; + + case 'csdecmcs': + case 'dec': + case 'decmcs': + return 'DEC-MCS'; + + case 'csiso21german': + case 'de': + case 'din66003': + case 'iso646de': + case 'isoir21': + return 'DIN_66003'; + + case 'csdkus': + case 'dkus': + return 'dk-us'; + + case 'csiso646danish': + case 'dk': + case 'ds2089': + case 'iso646dk': + return 'DS_2089'; + + case 'csibmebcdicatde': + case 'ebcdicatde': + return 'EBCDIC-AT-DE'; + + case 'csebcdicatdea': + case 'ebcdicatdea': + return 'EBCDIC-AT-DE-A'; + + case 'csebcdiccafr': + case 'ebcdiccafr': + return 'EBCDIC-CA-FR'; + + case 'csebcdicdkno': + case 'ebcdicdkno': + return 'EBCDIC-DK-NO'; + + case 'csebcdicdknoa': + case 'ebcdicdknoa': + return 'EBCDIC-DK-NO-A'; + + case 'csebcdices': + case 'ebcdices': + return 'EBCDIC-ES'; + + case 'csebcdicesa': + case 'ebcdicesa': + return 'EBCDIC-ES-A'; + + case 'csebcdicess': + case 'ebcdicess': + return 'EBCDIC-ES-S'; + + case 'csebcdicfise': + case 'ebcdicfise': + return 'EBCDIC-FI-SE'; + + case 'csebcdicfisea': + case 'ebcdicfisea': + return 'EBCDIC-FI-SE-A'; + + case 'csebcdicfr': + case 'ebcdicfr': + return 'EBCDIC-FR'; + + case 'csebcdicit': + case 'ebcdicit': + return 'EBCDIC-IT'; + + case 'csebcdicpt': + case 'ebcdicpt': + return 'EBCDIC-PT'; + + case 'csebcdicuk': + case 'ebcdicuk': + return 'EBCDIC-UK'; + + case 'csebcdicus': + case 'ebcdicus': + return 'EBCDIC-US'; + + case 'csiso111ecmacyrillic': + case 'ecmacyrillic': + case 'isoir111': + case 'koi8e': + return 'ECMA-cyrillic'; + + case 'csiso17spanish': + case 'es': + case 'iso646es': + case 'isoir17': + return 'ES'; + + case 'csiso85spanish2': + case 'es2': + case 'iso646es2': + case 'isoir85': + return 'ES2'; + + case 'cseucpkdfmtjapanese': + case 'eucjp': + case 'extendedunixcodepackedformatforjapanese': + return 'EUC-JP'; + + case 'cseucfixwidjapanese': + case 'extendedunixcodefixedwidthforjapanese': + return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; + + case 'gb18030': + return 'GB18030'; + + case 'chinese': + case 'cp936': + case 'csgb2312': + case 'csiso58gb231280': + case 'gb2312': + case 'gb231280': + case 'gbk': + case 'isoir58': + case 'ms936': + case 'windows936': + return 'GBK'; + + case 'cn': + case 'csiso57gb1988': + case 'gb198880': + case 'iso646cn': + case 'isoir57': + return 'GB_1988-80'; + + case 'csiso153gost1976874': + case 'gost1976874': + case 'isoir153': + case 'stsev35888': + return 'GOST_19768-74'; + + case 'csiso150': + case 'csiso150greekccitt': + case 'greekccitt': + case 'isoir150': + return 'greek-ccitt'; + + case 'csiso88greek7': + case 'greek7': + case 'isoir88': + return 'greek7'; + + case 'csiso18greek7old': + case 'greek7old': + case 'isoir18': + return 'greek7-old'; + + case 'cshpdesktop': + case 'hpdesktop': + return 'HP-DeskTop'; + + case 'cshplegal': + case 'hplegal': + return 'HP-Legal'; + + case 'cshpmath8': + case 'hpmath8': + return 'HP-Math8'; + + case 'cshppifont': + case 'hppifont': + return 'HP-Pi-font'; + + case 'cshproman8': + case 'hproman8': + case 'r8': + case 'roman8': + return 'hp-roman8'; + + case 'hzgb2312': + return 'HZ-GB-2312'; + + case 'csibmsymbols': + case 'ibmsymbols': + return 'IBM-Symbols'; + + case 'csibmthai': + case 'ibmthai': + return 'IBM-Thai'; + + case 'cp37': + case 'csibm37': + case 'ebcdiccpca': + case 'ebcdiccpnl': + case 'ebcdiccpus': + case 'ebcdiccpwt': + case 'ibm37': + return 'IBM037'; + + case 'cp38': + case 'csibm38': + case 'ebcdicint': + case 'ibm38': + return 'IBM038'; + + case 'cp273': + case 'csibm273': + case 'ibm273': + return 'IBM273'; + + case 'cp274': + case 'csibm274': + case 'ebcdicbe': + case 'ibm274': + return 'IBM274'; + + case 'cp275': + case 'csibm275': + case 'ebcdicbr': + case 'ibm275': + return 'IBM275'; + + case 'csibm277': + case 'ebcdiccpdk': + case 'ebcdiccpno': + case 'ibm277': + return 'IBM277'; + + case 'cp278': + case 'csibm278': + case 'ebcdiccpfi': + case 'ebcdiccpse': + case 'ibm278': + return 'IBM278'; + + case 'cp280': + case 'csibm280': + case 'ebcdiccpit': + case 'ibm280': + return 'IBM280'; + + case 'cp281': + case 'csibm281': + case 'ebcdicjpe': + case 'ibm281': + return 'IBM281'; + + case 'cp284': + case 'csibm284': + case 'ebcdiccpes': + case 'ibm284': + return 'IBM284'; + + case 'cp285': + case 'csibm285': + case 'ebcdiccpgb': + case 'ibm285': + return 'IBM285'; + + case 'cp290': + case 'csibm290': + case 'ebcdicjpkana': + case 'ibm290': + return 'IBM290'; + + case 'cp297': + case 'csibm297': + case 'ebcdiccpfr': + case 'ibm297': + return 'IBM297'; + + case 'cp420': + case 'csibm420': + case 'ebcdiccpar1': + case 'ibm420': + return 'IBM420'; + + case 'cp423': + case 'csibm423': + case 'ebcdiccpgr': + case 'ibm423': + return 'IBM423'; + + case 'cp424': + case 'csibm424': + case 'ebcdiccphe': + case 'ibm424': + return 'IBM424'; + + case '437': + case 'cp437': + case 'cspc8codepage437': + case 'ibm437': + return 'IBM437'; + + case 'cp500': + case 'csibm500': + case 'ebcdiccpbe': + case 'ebcdiccpch': + case 'ibm500': + return 'IBM500'; + + case 'cp775': + case 'cspc775baltic': + case 'ibm775': + return 'IBM775'; + + case '850': + case 'cp850': + case 'cspc850multilingual': + case 'ibm850': + return 'IBM850'; + + case '851': + case 'cp851': + case 'csibm851': + case 'ibm851': + return 'IBM851'; + + case '852': + case 'cp852': + case 'cspcp852': + case 'ibm852': + return 'IBM852'; + + case '855': + case 'cp855': + case 'csibm855': + case 'ibm855': + return 'IBM855'; + + case '857': + case 'cp857': + case 'csibm857': + case 'ibm857': + return 'IBM857'; + + case 'ccsid858': + case 'cp858': + case 'ibm858': + case 'pcmultilingual850euro': + return 'IBM00858'; + + case '860': + case 'cp860': + case 'csibm860': + case 'ibm860': + return 'IBM860'; + + case '861': + case 'cp861': + case 'cpis': + case 'csibm861': + case 'ibm861': + return 'IBM861'; + + case '862': + case 'cp862': + case 'cspc862latinhebrew': + case 'ibm862': + return 'IBM862'; + + case '863': + case 'cp863': + case 'csibm863': + case 'ibm863': + return 'IBM863'; + + case 'cp864': + case 'csibm864': + case 'ibm864': + return 'IBM864'; + + case '865': + case 'cp865': + case 'csibm865': + case 'ibm865': + return 'IBM865'; + + case '866': + case 'cp866': + case 'csibm866': + case 'ibm866': + return 'IBM866'; + + case 'cp868': + case 'cpar': + case 'csibm868': + case 'ibm868': + return 'IBM868'; + + case '869': + case 'cp869': + case 'cpgr': + case 'csibm869': + case 'ibm869': + return 'IBM869'; + + case 'cp870': + case 'csibm870': + case 'ebcdiccproece': + case 'ebcdiccpyu': + case 'ibm870': + return 'IBM870'; + + case 'cp871': + case 'csibm871': + case 'ebcdiccpis': + case 'ibm871': + return 'IBM871'; + + case 'cp880': + case 'csibm880': + case 'ebcdiccyrillic': + case 'ibm880': + return 'IBM880'; + + case 'cp891': + case 'csibm891': + case 'ibm891': + return 'IBM891'; + + case 'cp903': + case 'csibm903': + case 'ibm903': + return 'IBM903'; + + case '904': + case 'cp904': + case 'csibbm904': + case 'ibm904': + return 'IBM904'; + + case 'cp905': + case 'csibm905': + case 'ebcdiccptr': + case 'ibm905': + return 'IBM905'; + + case 'cp918': + case 'csibm918': + case 'ebcdiccpar2': + case 'ibm918': + return 'IBM918'; + + case 'ccsid924': + case 'cp924': + case 'ebcdiclatin9euro': + case 'ibm924': + return 'IBM00924'; + + case 'cp1026': + case 'csibm1026': + case 'ibm1026': + return 'IBM1026'; + + case 'ibm1047': + return 'IBM1047'; + + case 'ccsid1140': + case 'cp1140': + case 'ebcdicus37euro': + case 'ibm1140': + return 'IBM01140'; + + case 'ccsid1141': + case 'cp1141': + case 'ebcdicde273euro': + case 'ibm1141': + return 'IBM01141'; + + case 'ccsid1142': + case 'cp1142': + case 'ebcdicdk277euro': + case 'ebcdicno277euro': + case 'ibm1142': + return 'IBM01142'; + + case 'ccsid1143': + case 'cp1143': + case 'ebcdicfi278euro': + case 'ebcdicse278euro': + case 'ibm1143': + return 'IBM01143'; + + case 'ccsid1144': + case 'cp1144': + case 'ebcdicit280euro': + case 'ibm1144': + return 'IBM01144'; + + case 'ccsid1145': + case 'cp1145': + case 'ebcdices284euro': + case 'ibm1145': + return 'IBM01145'; + + case 'ccsid1146': + case 'cp1146': + case 'ebcdicgb285euro': + case 'ibm1146': + return 'IBM01146'; + + case 'ccsid1147': + case 'cp1147': + case 'ebcdicfr297euro': + case 'ibm1147': + return 'IBM01147'; + + case 'ccsid1148': + case 'cp1148': + case 'ebcdicinternational500euro': + case 'ibm1148': + return 'IBM01148'; + + case 'ccsid1149': + case 'cp1149': + case 'ebcdicis871euro': + case 'ibm1149': + return 'IBM01149'; + + case 'csiso143iecp271': + case 'iecp271': + case 'isoir143': + return 'IEC_P27-1'; + + case 'csiso49inis': + case 'inis': + case 'isoir49': + return 'INIS'; + + case 'csiso50inis8': + case 'inis8': + case 'isoir50': + return 'INIS-8'; + + case 'csiso51iniscyrillic': + case 'iniscyrillic': + case 'isoir51': + return 'INIS-cyrillic'; + + case 'csinvariant': + case 'invariant': + return 'INVARIANT'; + + case 'iso2022cn': + return 'ISO-2022-CN'; + + case 'iso2022cnext': + return 'ISO-2022-CN-EXT'; + + case 'csiso2022jp': + case 'iso2022jp': + return 'ISO-2022-JP'; + + case 'csiso2022jp2': + case 'iso2022jp2': + return 'ISO-2022-JP-2'; + + case 'csiso2022kr': + case 'iso2022kr': + return 'ISO-2022-KR'; + + case 'cswindows30latin1': + case 'iso88591windows30latin1': + return 'ISO-8859-1-Windows-3.0-Latin-1'; + + case 'cswindows31latin1': + case 'iso88591windows31latin1': + return 'ISO-8859-1-Windows-3.1-Latin-1'; + + case 'csisolatin2': + case 'iso88592': + case 'iso885921987': + case 'isoir101': + case 'l2': + case 'latin2': + return 'ISO-8859-2'; + + case 'cswindows31latin2': + case 'iso88592windowslatin2': + return 'ISO-8859-2-Windows-Latin-2'; + + case 'csisolatin3': + case 'iso88593': + case 'iso885931988': + case 'isoir109': + case 'l3': + case 'latin3': + return 'ISO-8859-3'; + + case 'csisolatin4': + case 'iso88594': + case 'iso885941988': + case 'isoir110': + case 'l4': + case 'latin4': + return 'ISO-8859-4'; + + case 'csisolatincyrillic': + case 'cyrillic': + case 'iso88595': + case 'iso885951988': + case 'isoir144': + return 'ISO-8859-5'; + + case 'arabic': + case 'asmo708': + case 'csisolatinarabic': + case 'ecma114': + case 'iso88596': + case 'iso885961987': + case 'isoir127': + return 'ISO-8859-6'; + + case 'csiso88596e': + case 'iso88596e': + return 'ISO-8859-6-E'; + + case 'csiso88596i': + case 'iso88596i': + return 'ISO-8859-6-I'; + + case 'csisolatingreek': + case 'ecma118': + case 'elot928': + case 'greek': + case 'greek8': + case 'iso88597': + case 'iso885971987': + case 'isoir126': + return 'ISO-8859-7'; + + case 'csisolatinhebrew': + case 'hebrew': + case 'iso88598': + case 'iso885981988': + case 'isoir138': + return 'ISO-8859-8'; + + case 'csiso88598e': + case 'iso88598e': + return 'ISO-8859-8-E'; + + case 'csiso88598i': + case 'iso88598i': + return 'ISO-8859-8-I'; + + case 'cswindows31latin5': + case 'iso88599windowslatin5': + return 'ISO-8859-9-Windows-Latin-5'; + + case 'csisolatin6': + case 'iso885910': + case 'iso8859101992': + case 'isoir157': + case 'l6': + case 'latin6': + return 'ISO-8859-10'; + + case 'iso885913': + return 'ISO-8859-13'; + + case 'iso885914': + case 'iso8859141998': + case 'isoceltic': + case 'isoir199': + case 'l8': + case 'latin8': + return 'ISO-8859-14'; + + case 'iso885915': + case 'latin9': + return 'ISO-8859-15'; + + case 'iso885916': + case 'iso8859162001': + case 'isoir226': + case 'l10': + case 'latin10': + return 'ISO-8859-16'; + + case 'iso10646j1': + return 'ISO-10646-J-1'; + + case 'csunicode': + case 'iso10646ucs2': + return 'ISO-10646-UCS-2'; + + case 'csucs4': + case 'iso10646ucs4': + return 'ISO-10646-UCS-4'; + + case 'csunicodeascii': + case 'iso10646ucsbasic': + return 'ISO-10646-UCS-Basic'; + + case 'csunicodelatin1': + case 'iso10646': + case 'iso10646unicodelatin1': + return 'ISO-10646-Unicode-Latin1'; + + case 'csiso10646utf1': + case 'iso10646utf1': + return 'ISO-10646-UTF-1'; + + case 'csiso115481': + case 'iso115481': + case 'isotr115481': + return 'ISO-11548-1'; + + case 'csiso90': + case 'isoir90': + return 'iso-ir-90'; + + case 'csunicodeibm1261': + case 'isounicodeibm1261': + return 'ISO-Unicode-IBM-1261'; + + case 'csunicodeibm1264': + case 'isounicodeibm1264': + return 'ISO-Unicode-IBM-1264'; + + case 'csunicodeibm1265': + case 'isounicodeibm1265': + return 'ISO-Unicode-IBM-1265'; + + case 'csunicodeibm1268': + case 'isounicodeibm1268': + return 'ISO-Unicode-IBM-1268'; + + case 'csunicodeibm1276': + case 'isounicodeibm1276': + return 'ISO-Unicode-IBM-1276'; + + case 'csiso646basic1983': + case 'iso646basic1983': + case 'ref': + return 'ISO_646.basic:1983'; + + case 'csiso2intlrefversion': + case 'irv': + case 'iso646irv1983': + case 'isoir2': + return 'ISO_646.irv:1983'; + + case 'csiso2033': + case 'e13b': + case 'iso20331983': + case 'isoir98': + return 'ISO_2033-1983'; + + case 'csiso5427cyrillic': + case 'iso5427': + case 'isoir37': + return 'ISO_5427'; + + case 'iso5427cyrillic1981': + case 'iso54271981': + case 'isoir54': + return 'ISO_5427:1981'; + + case 'csiso5428greek': + case 'iso54281980': + case 'isoir55': + return 'ISO_5428:1980'; + + case 'csiso6937add': + case 'iso6937225': + case 'isoir152': + return 'ISO_6937-2-25'; + + case 'csisotextcomm': + case 'iso69372add': + case 'isoir142': + return 'ISO_6937-2-add'; + + case 'csiso8859supp': + case 'iso8859supp': + case 'isoir154': + case 'latin125': + return 'ISO_8859-supp'; + + case 'csiso10367box': + case 'iso10367box': + case 'isoir155': + return 'ISO_10367-box'; + + case 'csiso15italian': + case 'iso646it': + case 'isoir15': + case 'it': + return 'IT'; + + case 'csiso13jisc6220jp': + case 'isoir13': + case 'jisc62201969': + case 'jisc62201969jp': + case 'katakana': + case 'x2017': + return 'JIS_C6220-1969-jp'; + + case 'csiso14jisc6220ro': + case 'iso646jp': + case 'isoir14': + case 'jisc62201969ro': + case 'jp': + return 'JIS_C6220-1969-ro'; + + case 'csiso42jisc62261978': + case 'isoir42': + case 'jisc62261978': + return 'JIS_C6226-1978'; + + case 'csiso87jisx208': + case 'isoir87': + case 'jisc62261983': + case 'jisx2081983': + case 'x208': + return 'JIS_C6226-1983'; + + case 'csiso91jisc62291984a': + case 'isoir91': + case 'jisc62291984a': + case 'jpocra': + return 'JIS_C6229-1984-a'; + + case 'csiso92jisc62991984b': + case 'iso646jpocrb': + case 'isoir92': + case 'jisc62291984b': + case 'jpocrb': + return 'JIS_C6229-1984-b'; + + case 'csiso93jis62291984badd': + case 'isoir93': + case 'jisc62291984badd': + case 'jpocrbadd': + return 'JIS_C6229-1984-b-add'; + + case 'csiso94jis62291984hand': + case 'isoir94': + case 'jisc62291984hand': + case 'jpocrhand': + return 'JIS_C6229-1984-hand'; + + case 'csiso95jis62291984handadd': + case 'isoir95': + case 'jisc62291984handadd': + case 'jpocrhandadd': + return 'JIS_C6229-1984-hand-add'; + + case 'csiso96jisc62291984kana': + case 'isoir96': + case 'jisc62291984kana': + return 'JIS_C6229-1984-kana'; + + case 'csjisencoding': + case 'jisencoding': + return 'JIS_Encoding'; + + case 'cshalfwidthkatakana': + case 'jisx201': + case 'x201': + return 'JIS_X0201'; + + case 'csiso159jisx2121990': + case 'isoir159': + case 'jisx2121990': + case 'x212': + return 'JIS_X0212-1990'; + + case 'csiso141jusib1002': + case 'iso646yu': + case 'isoir141': + case 'js': + case 'jusib1002': + case 'yu': + return 'JUS_I.B1.002'; + + case 'csiso147macedonian': + case 'isoir147': + case 'jusib1003mac': + case 'macedonian': + return 'JUS_I.B1.003-mac'; + + case 'csiso146serbian': + case 'isoir146': + case 'jusib1003serb': + case 'serbian': + return 'JUS_I.B1.003-serb'; + + case 'koi7switched': + return 'KOI7-switched'; + + case 'cskoi8r': + case 'koi8r': + return 'KOI8-R'; + + case 'koi8u': + return 'KOI8-U'; + + case 'csksc5636': + case 'iso646kr': + case 'ksc5636': + return 'KSC5636'; + + case 'cskz1048': + case 'kz1048': + case 'rk1048': + case 'strk10482002': + return 'KZ-1048'; + + case 'csiso19latingreek': + case 'isoir19': + case 'latingreek': + return 'latin-greek'; + + case 'csiso27latingreek1': + case 'isoir27': + case 'latingreek1': + return 'Latin-greek-1'; + + case 'csiso158lap': + case 'isoir158': + case 'lap': + case 'latinlap': + return 'latin-lap'; + + case 'csmacintosh': + case 'mac': + case 'macintosh': + return 'macintosh'; + + case 'csmicrosoftpublishing': + case 'microsoftpublishing': + return 'Microsoft-Publishing'; + + case 'csmnem': + case 'mnem': + return 'MNEM'; + + case 'csmnemonic': + case 'mnemonic': + return 'MNEMONIC'; + + case 'csiso86hungarian': + case 'hu': + case 'iso646hu': + case 'isoir86': + case 'msz77953': + return 'MSZ_7795.3'; + + case 'csnatsdano': + case 'isoir91': + case 'natsdano': + return 'NATS-DANO'; + + case 'csnatsdanoadd': + case 'isoir92': + case 'natsdanoadd': + return 'NATS-DANO-ADD'; + + case 'csnatssefi': + case 'isoir81': + case 'natssefi': + return 'NATS-SEFI'; + + case 'csnatssefiadd': + case 'isoir82': + case 'natssefiadd': + return 'NATS-SEFI-ADD'; + + case 'csiso151cuba': + case 'cuba': + case 'iso646cu': + case 'isoir151': + case 'ncnc1081': + return 'NC_NC00-10:81'; + + case 'csiso69french': + case 'fr': + case 'iso646fr': + case 'isoir69': + case 'nfz62010': + return 'NF_Z_62-010'; + + case 'csiso25french': + case 'iso646fr1': + case 'isoir25': + case 'nfz620101973': + return 'NF_Z_62-010_(1973)'; + + case 'csiso60danishnorwegian': + case 'csiso60norwegian1': + case 'iso646no': + case 'isoir60': + case 'no': + case 'ns45511': + return 'NS_4551-1'; + + case 'csiso61norwegian2': + case 'iso646no2': + case 'isoir61': + case 'no2': + case 'ns45512': + return 'NS_4551-2'; + + case 'osdebcdicdf3irv': + return 'OSD_EBCDIC_DF03_IRV'; + + case 'osdebcdicdf41': + return 'OSD_EBCDIC_DF04_1'; + + case 'osdebcdicdf415': + return 'OSD_EBCDIC_DF04_15'; + + case 'cspc8danishnorwegian': + case 'pc8danishnorwegian': + return 'PC8-Danish-Norwegian'; + + case 'cspc8turkish': + case 'pc8turkish': + return 'PC8-Turkish'; + + case 'csiso16portuguese': + case 'iso646pt': + case 'isoir16': + case 'pt': + return 'PT'; + + case 'csiso84portuguese2': + case 'iso646pt2': + case 'isoir84': + case 'pt2': + return 'PT2'; + + case 'cp154': + case 'csptcp154': + case 'cyrillicasian': + case 'pt154': + case 'ptcp154': + return 'PTCP154'; + + case 'scsu': + return 'SCSU'; + + case 'csiso10swedish': + case 'fi': + case 'iso646fi': + case 'iso646se': + case 'isoir10': + case 'se': + case 'sen850200b': + return 'SEN_850200_B'; + + case 'csiso11swedishfornames': + case 'iso646se2': + case 'isoir11': + case 'se2': + case 'sen850200c': + return 'SEN_850200_C'; + + case 'csiso102t617bit': + case 'isoir102': + case 't617bit': + return 'T.61-7bit'; + + case 'csiso103t618bit': + case 'isoir103': + case 't61': + case 't618bit': + return 'T.61-8bit'; + + case 'csiso128t101g2': + case 'isoir128': + case 't101g2': + return 'T.101-G2'; + + case 'cstscii': + case 'tscii': + return 'TSCII'; + + case 'csunicode11': + case 'unicode11': + return 'UNICODE-1-1'; + + case 'csunicode11utf7': + case 'unicode11utf7': + return 'UNICODE-1-1-UTF-7'; + + case 'csunknown8bit': + case 'unknown8bit': + return 'UNKNOWN-8BIT'; + + case 'ansix341968': + case 'ansix341986': + case 'ascii': + case 'cp367': + case 'csascii': + case 'ibm367': + case 'iso646irv1991': + case 'iso646us': + case 'isoir6': + case 'us': + case 'usascii': + return 'US-ASCII'; + + case 'csusdk': + case 'usdk': + return 'us-dk'; + + case 'utf7': + return 'UTF-7'; + + case 'utf8': + return 'UTF-8'; + + case 'utf16': + return 'UTF-16'; + + case 'utf16be': + return 'UTF-16BE'; + + case 'utf16le': + return 'UTF-16LE'; + + case 'utf32': + return 'UTF-32'; + + case 'utf32be': + return 'UTF-32BE'; + + case 'utf32le': + return 'UTF-32LE'; + + case 'csventurainternational': + case 'venturainternational': + return 'Ventura-International'; + + case 'csventuramath': + case 'venturamath': + return 'Ventura-Math'; + + case 'csventuraus': + case 'venturaus': + return 'Ventura-US'; + + case 'csiso70videotexsupp1': + case 'isoir70': + case 'videotexsuppl': + return 'videotex-suppl'; + + case 'csviqr': + case 'viqr': + return 'VIQR'; + + case 'csviscii': + case 'viscii': + return 'VISCII'; + + case 'csshiftjis': + case 'cswindows31j': + case 'mskanji': + case 'shiftjis': + case 'windows31j': + return 'Windows-31J'; + + case 'iso885911': + case 'tis620': + return 'windows-874'; + + case 'cseuckr': + case 'csksc56011987': + case 'euckr': + case 'isoir149': + case 'korean': + case 'ksc5601': + case 'ksc56011987': + case 'ksc56011989': + case 'windows949': + return 'windows-949'; + + case 'windows1250': + return 'windows-1250'; + + case 'windows1251': + return 'windows-1251'; + + case 'cp819': + case 'csisolatin1': + case 'ibm819': + case 'iso88591': + case 'iso885911987': + case 'isoir100': + case 'l1': + case 'latin1': + case 'windows1252': + return 'windows-1252'; + + case 'windows1253': + return 'windows-1253'; + + case 'csisolatin5': + case 'iso88599': + case 'iso885991989': + case 'isoir148': + case 'l5': + case 'latin5': + case 'windows1254': + return 'windows-1254'; + + case 'windows1255': + return 'windows-1255'; + + case 'windows1256': + return 'windows-1256'; + + case 'windows1257': + return 'windows-1257'; + + case 'windows1258': + return 'windows-1258'; + + default: + return $charset; + } + } + + public static function get_curl_version() + { + if (is_array($curl = curl_version())) + { + $curl = $curl['version']; + } + elseif (substr($curl, 0, 5) === 'curl/') + { + $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); + } + elseif (substr($curl, 0, 8) === 'libcurl/') + { + $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); + } + else + { + $curl = 0; + } + return $curl; + } + + /** + * Strip HTML comments + * + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + public static function strip_comments($data) + { + $output = ''; + while (($start = strpos($data, '<!--')) !== false) + { + $output .= substr($data, 0, $start); + if (($end = strpos($data, '-->', $start)) !== false) + { + $data = substr_replace($data, '', 0, $end + 3); + } + else + { + $data = ''; + } + } + return $output . $data; + } + + public static function parse_date($dt) + { + $parser = SimplePie_Parse_Date::get(); + return $parser->parse($dt); + } + + /** + * Decode HTML entities + * + * @deprecated Use DOMDocument instead + * @param string $data Input data + * @return string Output data + */ + public static function entities_decode($data) + { + $decoder = new SimplePie_Decode_HTML_Entities($data); + return $decoder->parse(); + } + + /** + * Remove RFC822 comments + * + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + public static function uncomment_rfc822($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) + { + $output .= substr($string, $position, $pos - $position); + $position = $pos + 1; + if ($string[$pos - 1] !== '\\') + { + $depth++; + while ($depth && $position < $length) + { + $position += strcspn($string, '()', $position); + if ($string[$position - 1] === '\\') + { + $position++; + continue; + } + elseif (isset($string[$position])) + { + switch ($string[$position]) + { + case '(': + $depth++; + break; + + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); + + return $output; + } + + public static function parse_mime($mime) + { + if (($pos = strpos($mime, ';')) === false) + { + return trim($mime); + } + else + { + return trim(substr($mime, 0, $pos)); + } + } + + public static function atom_03_construct_type($attribs) + { + if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) + { + $mode = SIMPLEPIE_CONSTRUCT_BASE64; + } + else + { + $mode = SIMPLEPIE_CONSTRUCT_NONE; + } + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + case 'text/plain': + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + + case 'html': + case 'text/html': + return SIMPLEPIE_CONSTRUCT_HTML | $mode; + + case 'xhtml': + case 'application/xhtml+xml': + return SIMPLEPIE_CONSTRUCT_XHTML | $mode; + + default: + return SIMPLEPIE_CONSTRUCT_NONE | $mode; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + } + } + + public static function atom_10_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; + + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; + + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; + + default: + return SIMPLEPIE_CONSTRUCT_NONE; + } + } + return SIMPLEPIE_CONSTRUCT_TEXT; + } + + public static function atom_10_content_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + $type = strtolower(trim($attribs['']['type'])); + switch ($type) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; + + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; + + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; + } + if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') + { + return SIMPLEPIE_CONSTRUCT_NONE; + } + else + { + return SIMPLEPIE_CONSTRUCT_BASE64; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT; + } + } + + public static function is_isegment_nz_nc($string) + { + return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); + } + + public static function space_seperated_tokens($string) + { + $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; + $string_length = strlen($string); + + $position = strspn($string, $space_characters); + $tokens = array(); + + while ($position < $string_length) + { + $len = strcspn($string, $space_characters, $position); + $tokens[] = substr($string, $position, $len); + $position += $len; + $position += strspn($string, $space_characters, $position); + } + + return $tokens; + } + + /** + * Converts a unicode codepoint to a UTF-8 character + * + * @static + * @param int $codepoint Unicode codepoint + * @return string UTF-8 character + */ + public static function codepoint_to_utf8($codepoint) + { + $codepoint = (int) $codepoint; + if ($codepoint < 0) + { + return false; + } + else if ($codepoint <= 0x7f) + { + return chr($codepoint); + } + else if ($codepoint <= 0x7ff) + { + return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0xffff) + { + return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0x10ffff) + { + return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } + else + { + // U+FFFD REPLACEMENT CHARACTER + return "\xEF\xBF\xBD"; + } + } + + /** + * Similar to parse_str() + * + * Returns an associative array of name/value pairs, where the value is an + * array of values that have used the same name + * + * @static + * @param string $str The input string. + * @return array + */ + public static function parse_str($str) + { + $return = array(); + $str = explode('&', $str); + + foreach ($str as $section) + { + if (strpos($section, '=') !== false) + { + list($name, $value) = explode('=', $section, 2); + $return[urldecode($name)][] = urldecode($value); + } + else + { + $return[urldecode($section)][] = null; + } + } + + return $return; + } + + /** + * Detect XML encoding, as per XML 1.0 Appendix F.1 + * + * @todo Add support for EBCDIC + * @param string $data XML data + * @param SimplePie_Registry $registry Class registry + * @return array Possible encodings + */ + public static function xml_encoding($data, $registry) + { + // UTF-32 Big Endian BOM + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") + { + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian BOM + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") + { + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian BOM + elseif (substr($data, 0, 2) === "\xFE\xFF") + { + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian BOM + elseif (substr($data, 0, 2) === "\xFF\xFE") + { + $encoding[] = 'UTF-16LE'; + } + // UTF-8 BOM + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") + { + $encoding[] = 'UTF-8'; + } + // UTF-32 Big Endian Without BOM + elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") + { + if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) + { + $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'))); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian Without BOM + elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") + { + if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) + { + $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'))); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian Without BOM + elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") + { + if ($pos = strpos($data, "\x00\x3F\x00\x3E")) + { + $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'))); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian Without BOM + elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") + { + if ($pos = strpos($data, "\x3F\x00\x3E\x00")) + { + $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'))); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16LE'; + } + // US-ASCII (or superset) + elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") + { + if ($pos = strpos($data, "\x3F\x3E")) + { + $parser = $registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5))); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-8'; + } + // Fallback to UTF-8 + else + { + $encoding[] = 'UTF-8'; + } + return $encoding; + } + + public static function output_javascript() + { + if (function_exists('ob_gzhandler')) + { + ob_start('ob_gzhandler'); + } + header('Content-type: text/javascript; charset: UTF-8'); + header('Cache-Control: must-revalidate'); + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days + ?> +function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { + if (placeholder != '') { + document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); + } + else { + document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); + } +} + +function embed_flash(bgcolor, width, height, link, loop, type) { + document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); +} + +function embed_flv(width, height, link, placeholder, loop, player) { + document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>'); +} + +function embed_wmedia(width, height, link) { + document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); +} + <?php + } + + /** + * Get the SimplePie build timestamp + * + * Uses the git index if it exists, otherwise uses the modification time + * of the newest file. + */ + public static function get_build() + { + $root = dirname(dirname(__FILE__)); + if (file_exists($root . '/.git/index')) + { + return filemtime($root . '/.git/index'); + } + elseif (file_exists($root . '/SimplePie')) + { + $time = 0; + foreach (glob($root . '/SimplePie/*.php') as $file) + { + if (($mtime = filemtime($file)) > $time) + { + $time = $mtime; + } + } + return $time; + } + elseif (file_exists(dirname(__FILE__) . '/Core.php')) + { + return filemtime(dirname(__FILE__) . '/Core.php'); + } + else + { + return filemtime(__FILE__); + } + } + + /** + * Format debugging information + */ + public static function debug(&$sp) + { + $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n"; + $info .= 'PHP ' . PHP_VERSION . "\n"; + if ($sp->error() !== null) + { + $info .= 'Error occurred: ' . $sp->error() . "\n"; + } + else + { + $info .= "No error found.\n"; + } + $info .= "Extensions:\n"; + $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml'); + foreach ($extensions as $ext) + { + if (extension_loaded($ext)) + { + $info .= " $ext loaded\n"; + switch ($ext) + { + case 'pcre': + $info .= ' Version ' . PCRE_VERSION . "\n"; + break; + case 'curl': + $version = curl_version(); + $info .= ' Version ' . $version['version'] . "\n"; + break; + case 'mbstring': + $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n"; + break; + case 'iconv': + $info .= ' Version ' . ICONV_VERSION . "\n"; + break; + case 'xml': + $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n"; + break; + } + } + else + { + $info .= " $ext not loaded\n"; + } + } + return $info; + } + + public static function silence_errors($num, $str) + { + // No-op + } +} + diff --git a/backend/wp-includes/SimplePie/Net/IPv6.php b/backend/wp-includes/SimplePie/Net/IPv6.php new file mode 100644 index 0000000..da80d8a --- /dev/null +++ b/backend/wp-includes/SimplePie/Net/IPv6.php @@ -0,0 +1,276 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + + +/** + * Class to validate and to work with IPv6 addresses. + * + * @package SimplePie + * @subpackage HTTP + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/package/Net_IPv6 + * @author Alexander Merz <alexander.merz@web.de> + * @author elfrink at introweb dot nl + * @author Josh Peck <jmp at joshpeck dot org> + * @author Geoffrey Sneddon <geoffers@gmail.com> + */ +class SimplePie_Net_IPv6 +{ + /** + * Uncompresses an IPv6 address + * + * RFC 4291 allows you to compress concecutive zero pieces in an address to + * '::'. This method expects a valid IPv6 address and expands the '::' to + * the required number of zero pieces. + * + * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 + * + * @author Alexander Merz <alexander.merz@web.de> + * @author elfrink at introweb dot nl + * @author Josh Peck <jmp at joshpeck dot org> + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @param string $ip An IPv6 address + * @return string The uncompressed IPv6 address + */ + public static function uncompress($ip) + { + $c1 = -1; + $c2 = -1; + if (substr_count($ip, '::') === 1) + { + list($ip1, $ip2) = explode('::', $ip); + if ($ip1 === '') + { + $c1 = -1; + } + else + { + $c1 = substr_count($ip1, ':'); + } + if ($ip2 === '') + { + $c2 = -1; + } + else + { + $c2 = substr_count($ip2, ':'); + } + if (strpos($ip2, '.') !== false) + { + $c2++; + } + // :: + if ($c1 === -1 && $c2 === -1) + { + $ip = '0:0:0:0:0:0:0:0'; + } + // ::xxx + else if ($c1 === -1) + { + $fill = str_repeat('0:', 7 - $c2); + $ip = str_replace('::', $fill, $ip); + } + // xxx:: + else if ($c2 === -1) + { + $fill = str_repeat(':0', 7 - $c1); + $ip = str_replace('::', $fill, $ip); + } + // xxx::xxx + else + { + $fill = ':' . str_repeat('0:', 6 - $c2 - $c1); + $ip = str_replace('::', $fill, $ip); + } + } + return $ip; + } + + /** + * Compresses an IPv6 address + * + * RFC 4291 allows you to compress concecutive zero pieces in an address to + * '::'. This method expects a valid IPv6 address and compresses consecutive + * zero pieces to '::'. + * + * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 + * 0:0:0:0:0:0:0:1 -> ::1 + * + * @see uncompress() + * @param string $ip An IPv6 address + * @return string The compressed IPv6 address + */ + public static function compress($ip) + { + // Prepare the IP to be compressed + $ip = self::uncompress($ip); + $ip_parts = self::split_v6_v4($ip); + + // Replace all leading zeros + $ip_parts[0] = preg_replace('/(^|:)0+([0-9])/', '\1\2', $ip_parts[0]); + + // Find bunches of zeros + if (preg_match_all('/(?:^|:)(?:0(?::|$))+/', $ip_parts[0], $matches, PREG_OFFSET_CAPTURE)) + { + $max = 0; + $pos = null; + foreach ($matches[0] as $match) + { + if (strlen($match[0]) > $max) + { + $max = strlen($match[0]); + $pos = $match[1]; + } + } + + $ip_parts[0] = substr_replace($ip_parts[0], '::', $pos, $max); + } + + if ($ip_parts[1] !== '') + { + return implode(':', $ip_parts); + } + else + { + return $ip_parts[0]; + } + } + + /** + * Splits an IPv6 address into the IPv6 and IPv4 representation parts + * + * RFC 4291 allows you to represent the last two parts of an IPv6 address + * using the standard IPv4 representation + * + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 + * + * @param string $ip An IPv6 address + * @return array [0] contains the IPv6 represented part, and [1] the IPv4 represented part + */ + private static function split_v6_v4($ip) + { + if (strpos($ip, '.') !== false) + { + $pos = strrpos($ip, ':'); + $ipv6_part = substr($ip, 0, $pos); + $ipv4_part = substr($ip, $pos + 1); + return array($ipv6_part, $ipv4_part); + } + else + { + return array($ip, ''); + } + } + + /** + * Checks an IPv6 address + * + * Checks if the given IP is a valid IPv6 address + * + * @param string $ip An IPv6 address + * @return bool true if $ip is a valid IPv6 address + */ + public static function check_ipv6($ip) + { + $ip = self::uncompress($ip); + list($ipv6, $ipv4) = self::split_v6_v4($ip); + $ipv6 = explode(':', $ipv6); + $ipv4 = explode('.', $ipv4); + if (count($ipv6) === 8 && count($ipv4) === 1 || count($ipv6) === 6 && count($ipv4) === 4) + { + foreach ($ipv6 as $ipv6_part) + { + // The section can't be empty + if ($ipv6_part === '') + return false; + + // Nor can it be over four characters + if (strlen($ipv6_part) > 4) + return false; + + // Remove leading zeros (this is safe because of the above) + $ipv6_part = ltrim($ipv6_part, '0'); + if ($ipv6_part === '') + $ipv6_part = '0'; + + // Check the value is valid + $value = hexdec($ipv6_part); + if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF) + return false; + } + if (count($ipv4) === 4) + { + foreach ($ipv4 as $ipv4_part) + { + $value = (int) $ipv4_part; + if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) + return false; + } + } + return true; + } + else + { + return false; + } + } + + /** + * Checks if the given IP is a valid IPv6 address + * + * @codeCoverageIgnore + * @deprecated Use {@see SimplePie_Net_IPv6::check_ipv6()} instead + * @see check_ipv6 + * @param string $ip An IPv6 address + * @return bool true if $ip is a valid IPv6 address + */ + public static function checkIPv6($ip) + { + return self::check_ipv6($ip); + } +} diff --git a/backend/wp-includes/SimplePie/Parse/Date.php b/backend/wp-includes/SimplePie/Parse/Date.php new file mode 100644 index 0000000..88e46e0 --- /dev/null +++ b/backend/wp-includes/SimplePie/Parse/Date.php @@ -0,0 +1,984 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + + +/** + * Date Parser + * + * @package SimplePie + * @subpackage Parsing + */ +class SimplePie_Parse_Date +{ + /** + * Input data + * + * @access protected + * @var string + */ + var $date; + + /** + * List of days, calendar day name => ordinal day number in the week + * + * @access protected + * @var array + */ + var $day = array( + // English + 'mon' => 1, + 'monday' => 1, + 'tue' => 2, + 'tuesday' => 2, + 'wed' => 3, + 'wednesday' => 3, + 'thu' => 4, + 'thursday' => 4, + 'fri' => 5, + 'friday' => 5, + 'sat' => 6, + 'saturday' => 6, + 'sun' => 7, + 'sunday' => 7, + // Dutch + 'maandag' => 1, + 'dinsdag' => 2, + 'woensdag' => 3, + 'donderdag' => 4, + 'vrijdag' => 5, + 'zaterdag' => 6, + 'zondag' => 7, + // French + 'lundi' => 1, + 'mardi' => 2, + 'mercredi' => 3, + 'jeudi' => 4, + 'vendredi' => 5, + 'samedi' => 6, + 'dimanche' => 7, + // German + 'montag' => 1, + 'dienstag' => 2, + 'mittwoch' => 3, + 'donnerstag' => 4, + 'freitag' => 5, + 'samstag' => 6, + 'sonnabend' => 6, + 'sonntag' => 7, + // Italian + 'lunedì' => 1, + 'martedì' => 2, + 'mercoledì' => 3, + 'giovedì' => 4, + 'venerdì' => 5, + 'sabato' => 6, + 'domenica' => 7, + // Spanish + 'lunes' => 1, + 'martes' => 2, + 'miércoles' => 3, + 'jueves' => 4, + 'viernes' => 5, + 'sábado' => 6, + 'domingo' => 7, + // Finnish + 'maanantai' => 1, + 'tiistai' => 2, + 'keskiviikko' => 3, + 'torstai' => 4, + 'perjantai' => 5, + 'lauantai' => 6, + 'sunnuntai' => 7, + // Hungarian + 'hétfÅ‘' => 1, + 'kedd' => 2, + 'szerda' => 3, + 'csütörtok' => 4, + 'péntek' => 5, + 'szombat' => 6, + 'vasárnap' => 7, + // Greek + 'Δευ' => 1, + 'ΤÏι' => 2, + 'Τετ' => 3, + 'Πεμ' => 4, + 'ΠαÏ' => 5, + 'Σαβ' => 6, + 'ΚυÏ' => 7, + ); + + /** + * List of months, calendar month name => calendar month number + * + * @access protected + * @var array + */ + var $month = array( + // English + 'jan' => 1, + 'january' => 1, + 'feb' => 2, + 'february' => 2, + 'mar' => 3, + 'march' => 3, + 'apr' => 4, + 'april' => 4, + 'may' => 5, + // No long form of May + 'jun' => 6, + 'june' => 6, + 'jul' => 7, + 'july' => 7, + 'aug' => 8, + 'august' => 8, + 'sep' => 9, + 'september' => 8, + 'oct' => 10, + 'october' => 10, + 'nov' => 11, + 'november' => 11, + 'dec' => 12, + 'december' => 12, + // Dutch + 'januari' => 1, + 'februari' => 2, + 'maart' => 3, + 'april' => 4, + 'mei' => 5, + 'juni' => 6, + 'juli' => 7, + 'augustus' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'december' => 12, + // French + 'janvier' => 1, + 'février' => 2, + 'mars' => 3, + 'avril' => 4, + 'mai' => 5, + 'juin' => 6, + 'juillet' => 7, + 'août' => 8, + 'septembre' => 9, + 'octobre' => 10, + 'novembre' => 11, + 'décembre' => 12, + // German + 'januar' => 1, + 'februar' => 2, + 'märz' => 3, + 'april' => 4, + 'mai' => 5, + 'juni' => 6, + 'juli' => 7, + 'august' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'dezember' => 12, + // Italian + 'gennaio' => 1, + 'febbraio' => 2, + 'marzo' => 3, + 'aprile' => 4, + 'maggio' => 5, + 'giugno' => 6, + 'luglio' => 7, + 'agosto' => 8, + 'settembre' => 9, + 'ottobre' => 10, + 'novembre' => 11, + 'dicembre' => 12, + // Spanish + 'enero' => 1, + 'febrero' => 2, + 'marzo' => 3, + 'abril' => 4, + 'mayo' => 5, + 'junio' => 6, + 'julio' => 7, + 'agosto' => 8, + 'septiembre' => 9, + 'setiembre' => 9, + 'octubre' => 10, + 'noviembre' => 11, + 'diciembre' => 12, + // Finnish + 'tammikuu' => 1, + 'helmikuu' => 2, + 'maaliskuu' => 3, + 'huhtikuu' => 4, + 'toukokuu' => 5, + 'kesäkuu' => 6, + 'heinäkuu' => 7, + 'elokuu' => 8, + 'suuskuu' => 9, + 'lokakuu' => 10, + 'marras' => 11, + 'joulukuu' => 12, + // Hungarian + 'január' => 1, + 'február' => 2, + 'március' => 3, + 'április' => 4, + 'május' => 5, + 'június' => 6, + 'július' => 7, + 'augusztus' => 8, + 'szeptember' => 9, + 'október' => 10, + 'november' => 11, + 'december' => 12, + // Greek + 'Ιαν' => 1, + 'Φεβ' => 2, + 'Μάώ' => 3, + 'Μαώ' => 3, + 'ΑπÏ' => 4, + 'Μάι' => 5, + 'Μαϊ' => 5, + 'Μαι' => 5, + 'ΙοÏν' => 6, + 'Ιον' => 6, + 'ΙοÏλ' => 7, + 'Ιολ' => 7, + 'ΑÏγ' => 8, + 'Αυγ' => 8, + 'Σεπ' => 9, + 'Οκτ' => 10, + 'Îοέ' => 11, + 'Δεκ' => 12, + ); + + /** + * List of timezones, abbreviation => offset from UTC + * + * @access protected + * @var array + */ + var $timezone = array( + 'ACDT' => 37800, + 'ACIT' => 28800, + 'ACST' => 34200, + 'ACT' => -18000, + 'ACWDT' => 35100, + 'ACWST' => 31500, + 'AEDT' => 39600, + 'AEST' => 36000, + 'AFT' => 16200, + 'AKDT' => -28800, + 'AKST' => -32400, + 'AMDT' => 18000, + 'AMT' => -14400, + 'ANAST' => 46800, + 'ANAT' => 43200, + 'ART' => -10800, + 'AZOST' => -3600, + 'AZST' => 18000, + 'AZT' => 14400, + 'BIOT' => 21600, + 'BIT' => -43200, + 'BOT' => -14400, + 'BRST' => -7200, + 'BRT' => -10800, + 'BST' => 3600, + 'BTT' => 21600, + 'CAST' => 18000, + 'CAT' => 7200, + 'CCT' => 23400, + 'CDT' => -18000, + 'CEDT' => 7200, + 'CEST' => 7200, + 'CET' => 3600, + 'CGST' => -7200, + 'CGT' => -10800, + 'CHADT' => 49500, + 'CHAST' => 45900, + 'CIST' => -28800, + 'CKT' => -36000, + 'CLDT' => -10800, + 'CLST' => -14400, + 'COT' => -18000, + 'CST' => -21600, + 'CVT' => -3600, + 'CXT' => 25200, + 'DAVT' => 25200, + 'DTAT' => 36000, + 'EADT' => -18000, + 'EAST' => -21600, + 'EAT' => 10800, + 'ECT' => -18000, + 'EDT' => -14400, + 'EEST' => 10800, + 'EET' => 7200, + 'EGT' => -3600, + 'EKST' => 21600, + 'EST' => -18000, + 'FJT' => 43200, + 'FKDT' => -10800, + 'FKST' => -14400, + 'FNT' => -7200, + 'GALT' => -21600, + 'GEDT' => 14400, + 'GEST' => 10800, + 'GFT' => -10800, + 'GILT' => 43200, + 'GIT' => -32400, + 'GST' => 14400, + 'GST' => -7200, + 'GYT' => -14400, + 'HAA' => -10800, + 'HAC' => -18000, + 'HADT' => -32400, + 'HAE' => -14400, + 'HAP' => -25200, + 'HAR' => -21600, + 'HAST' => -36000, + 'HAT' => -9000, + 'HAY' => -28800, + 'HKST' => 28800, + 'HMT' => 18000, + 'HNA' => -14400, + 'HNC' => -21600, + 'HNE' => -18000, + 'HNP' => -28800, + 'HNR' => -25200, + 'HNT' => -12600, + 'HNY' => -32400, + 'IRDT' => 16200, + 'IRKST' => 32400, + 'IRKT' => 28800, + 'IRST' => 12600, + 'JFDT' => -10800, + 'JFST' => -14400, + 'JST' => 32400, + 'KGST' => 21600, + 'KGT' => 18000, + 'KOST' => 39600, + 'KOVST' => 28800, + 'KOVT' => 25200, + 'KRAST' => 28800, + 'KRAT' => 25200, + 'KST' => 32400, + 'LHDT' => 39600, + 'LHST' => 37800, + 'LINT' => 50400, + 'LKT' => 21600, + 'MAGST' => 43200, + 'MAGT' => 39600, + 'MAWT' => 21600, + 'MDT' => -21600, + 'MESZ' => 7200, + 'MEZ' => 3600, + 'MHT' => 43200, + 'MIT' => -34200, + 'MNST' => 32400, + 'MSDT' => 14400, + 'MSST' => 10800, + 'MST' => -25200, + 'MUT' => 14400, + 'MVT' => 18000, + 'MYT' => 28800, + 'NCT' => 39600, + 'NDT' => -9000, + 'NFT' => 41400, + 'NMIT' => 36000, + 'NOVST' => 25200, + 'NOVT' => 21600, + 'NPT' => 20700, + 'NRT' => 43200, + 'NST' => -12600, + 'NUT' => -39600, + 'NZDT' => 46800, + 'NZST' => 43200, + 'OMSST' => 25200, + 'OMST' => 21600, + 'PDT' => -25200, + 'PET' => -18000, + 'PETST' => 46800, + 'PETT' => 43200, + 'PGT' => 36000, + 'PHOT' => 46800, + 'PHT' => 28800, + 'PKT' => 18000, + 'PMDT' => -7200, + 'PMST' => -10800, + 'PONT' => 39600, + 'PST' => -28800, + 'PWT' => 32400, + 'PYST' => -10800, + 'PYT' => -14400, + 'RET' => 14400, + 'ROTT' => -10800, + 'SAMST' => 18000, + 'SAMT' => 14400, + 'SAST' => 7200, + 'SBT' => 39600, + 'SCDT' => 46800, + 'SCST' => 43200, + 'SCT' => 14400, + 'SEST' => 3600, + 'SGT' => 28800, + 'SIT' => 28800, + 'SRT' => -10800, + 'SST' => -39600, + 'SYST' => 10800, + 'SYT' => 7200, + 'TFT' => 18000, + 'THAT' => -36000, + 'TJT' => 18000, + 'TKT' => -36000, + 'TMT' => 18000, + 'TOT' => 46800, + 'TPT' => 32400, + 'TRUT' => 36000, + 'TVT' => 43200, + 'TWT' => 28800, + 'UYST' => -7200, + 'UYT' => -10800, + 'UZT' => 18000, + 'VET' => -14400, + 'VLAST' => 39600, + 'VLAT' => 36000, + 'VOST' => 21600, + 'VUT' => 39600, + 'WAST' => 7200, + 'WAT' => 3600, + 'WDT' => 32400, + 'WEST' => 3600, + 'WFT' => 43200, + 'WIB' => 25200, + 'WIT' => 32400, + 'WITA' => 28800, + 'WKST' => 18000, + 'WST' => 28800, + 'YAKST' => 36000, + 'YAKT' => 32400, + 'YAPT' => 36000, + 'YEKST' => 21600, + 'YEKT' => 18000, + ); + + /** + * Cached PCRE for SimplePie_Parse_Date::$day + * + * @access protected + * @var string + */ + var $day_pcre; + + /** + * Cached PCRE for SimplePie_Parse_Date::$month + * + * @access protected + * @var string + */ + var $month_pcre; + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $built_in = array(); + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $user = array(); + + /** + * Create new SimplePie_Parse_Date object, and set self::day_pcre, + * self::month_pcre, and self::built_in + * + * @access private + */ + public function __construct() + { + $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; + $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; + + static $cache; + if (!isset($cache[get_class($this)])) + { + $all_methods = get_class_methods($this); + + foreach ($all_methods as $method) + { + if (strtolower(substr($method, 0, 5)) === 'date_') + { + $cache[get_class($this)][] = $method; + } + } + } + + foreach ($cache[get_class($this)] as $method) + { + $this->built_in[] = $method; + } + } + + /** + * Get the object + * + * @access public + */ + public static function get() + { + static $object; + if (!$object) + { + $object = new SimplePie_Parse_Date; + } + return $object; + } + + /** + * Parse a date + * + * @final + * @access public + * @param string $date Date to parse + * @return int Timestamp corresponding to date string, or false on failure + */ + public function parse($date) + { + foreach ($this->user as $method) + { + if (($returned = call_user_func($method, $date)) !== false) + { + return $returned; + } + } + + foreach ($this->built_in as $method) + { + if (($returned = call_user_func(array($this, $method), $date)) !== false) + { + return $returned; + } + } + + return false; + } + + /** + * Add a callback method to parse a date + * + * @final + * @access public + * @param callable $callback + */ + public function add_callback($callback) + { + if (is_callable($callback)) + { + $this->user[] = $callback; + } + else + { + trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); + } + } + + /** + * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as + * well as allowing any of upper or lower case "T", horizontal tabs, or + * spaces to be used as the time seperator (including more than one)) + * + * @access protected + * @return int Timestamp + */ + public function date_w3cdtf($date) + { + static $pcre; + if (!$pcre) + { + $year = '([0-9]{4})'; + $month = $day = $hour = $minute = $second = '([0-9]{2})'; + $decimal = '([0-9]*)'; + $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; + $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Year + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Decimal fraction of a second + 8: Zulu + 9: Timezone ± + 10: Timezone hours + 11: Timezone minutes + */ + + // Fill in empty matches + for ($i = count($match); $i <= 3; $i++) + { + $match[$i] = '1'; + } + + for ($i = count($match); $i <= 7; $i++) + { + $match[$i] = '0'; + } + + // Numeric timezone + if (isset($match[9]) && $match[9] !== '') + { + $timezone = $match[10] * 3600; + $timezone += $match[11] * 60; + if ($match[9] === '-') + { + $timezone = 0 - $timezone; + } + } + else + { + $timezone = 0; + } + + // Convert the number of seconds to an integer, taking decimals into account + $second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); + + return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; + } + else + { + return false; + } + } + + /** + * Remove RFC822 comments + * + * @access protected + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + public function remove_rfc2822_comments($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) + { + $output .= substr($string, $position, $pos - $position); + $position = $pos + 1; + if ($string[$pos - 1] !== '\\') + { + $depth++; + while ($depth && $position < $length) + { + $position += strcspn($string, '()', $position); + if ($string[$position - 1] === '\\') + { + $position++; + continue; + } + elseif (isset($string[$position])) + { + switch ($string[$position]) + { + case '(': + $depth++; + break; + + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); + + return $output; + } + + /** + * Parse RFC2822's date format + * + * @access protected + * @return int Timestamp + */ + public function date_rfc2822($date) + { + static $pcre; + if (!$pcre) + { + $wsp = '[\x09\x20]'; + $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)'; + $optional_fws = $fws . '?'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $minute = $second = '([0-9]{2})'; + $year = '([0-9]{2,4})'; + $num_zone = '([+\-])([0-9]{2})([0-9]{2})'; + $character_zone = '([A-Z]{1,5})'; + $zone = '(?:' . $num_zone . '|' . $character_zone . ')'; + $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i'; + } + if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone ± + 9: Timezone hours + 10: Timezone minutes + 11: Alphabetic timezone + */ + + // Find the month number + $month = $this->month[strtolower($match[3])]; + + // Numeric timezone + if ($match[8] !== '') + { + $timezone = $match[9] * 3600; + $timezone += $match[10] * 60; + if ($match[8] === '-') + { + $timezone = 0 - $timezone; + } + } + // Character timezone + elseif (isset($this->timezone[strtoupper($match[11])])) + { + $timezone = $this->timezone[strtoupper($match[11])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2/3 digit years + if ($match[4] < 50) + { + $match[4] += 2000; + } + elseif ($match[4] < 1000) + { + $match[4] += 1900; + } + + // Second is optional, if it is empty set it to zero + if ($match[7] !== '') + { + $second = $match[7]; + } + else + { + $second = 0; + } + + return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse RFC850's date format + * + * @access protected + * @return int Timestamp + */ + public function date_rfc850($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $year = $hour = $minute = $second = '([0-9]{2})'; + $zone = '([A-Z]{1,5})'; + $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone + */ + + // Month + $month = $this->month[strtolower($match[3])]; + + // Character timezone + if (isset($this->timezone[strtoupper($match[8])])) + { + $timezone = $this->timezone[strtoupper($match[8])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2 digit year + if ($match[4] < 50) + { + $match[4] += 2000; + } + else + { + $match[4] += 1900; + } + + return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse C99's asctime()'s date format + * + * @access protected + * @return int Timestamp + */ + public function date_asctime($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $wday_name = $this->day_pcre; + $mon_name = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $sec = $min = '([0-9]{2})'; + $year = '([0-9]{4})'; + $terminator = '\x0A?\x00?'; + $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Year + */ + + $month = $this->month[strtolower($match[2])]; + return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); + } + else + { + return false; + } + } + + /** + * Parse dates using strtotime() + * + * @access protected + * @return int Timestamp + */ + public function date_strtotime($date) + { + $strtotime = strtotime($date); + if ($strtotime === -1 || $strtotime === false) + { + return false; + } + else + { + return $strtotime; + } + } +} + diff --git a/backend/wp-includes/SimplePie/Parser.php b/backend/wp-includes/SimplePie/Parser.php new file mode 100644 index 0000000..d698552 --- /dev/null +++ b/backend/wp-includes/SimplePie/Parser.php @@ -0,0 +1,407 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Parses XML into something sane + * + * + * This class can be overloaded with {@see SimplePie::set_parser_class()} + * + * @package SimplePie + * @subpackage Parsing + */ +class SimplePie_Parser +{ + var $error_code; + var $error_string; + var $current_line; + var $current_column; + var $current_byte; + var $separator = ' '; + var $namespace = array(''); + var $element = array(''); + var $xml_base = array(''); + var $xml_base_explicit = array(false); + var $xml_lang = array(''); + var $data = array(); + var $datas = array(array()); + var $current_xhtml_construct = -1; + var $encoding; + protected $registry; + + public function set_registry(SimplePie_Registry $registry) + { + $this->registry = $registry; + } + + public function parse(&$data, $encoding) + { + // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character + if (strtoupper($encoding) === 'US-ASCII') + { + $this->encoding = 'UTF-8'; + } + else + { + $this->encoding = $encoding; + } + + // Strip BOM: + // UTF-32 Big Endian BOM + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") + { + $data = substr($data, 4); + } + // UTF-32 Little Endian BOM + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") + { + $data = substr($data, 4); + } + // UTF-16 Big Endian BOM + elseif (substr($data, 0, 2) === "\xFE\xFF") + { + $data = substr($data, 2); + } + // UTF-16 Little Endian BOM + elseif (substr($data, 0, 2) === "\xFF\xFE") + { + $data = substr($data, 2); + } + // UTF-8 BOM + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") + { + $data = substr($data, 3); + } + + if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false) + { + $declaration = $this->registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5))); + if ($declaration->parse()) + { + $data = substr($data, $pos + 2); + $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; + } + else + { + $this->error_string = 'SimplePie bug! Please report this!'; + return false; + } + } + + $return = true; + + static $xml_is_sane = null; + if ($xml_is_sane === null) + { + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + + // Create the parser + if ($xml_is_sane) + { + $xml = xml_parser_create_ns($this->encoding, $this->separator); + xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); + xml_set_object($xml, $this); + xml_set_character_data_handler($xml, 'cdata'); + xml_set_element_handler($xml, 'tag_open', 'tag_close'); + + // Parse! + if (!xml_parse($xml, $data, true)) + { + $this->error_code = xml_get_error_code($xml); + $this->error_string = xml_error_string($this->error_code); + $return = false; + } + $this->current_line = xml_get_current_line_number($xml); + $this->current_column = xml_get_current_column_number($xml); + $this->current_byte = xml_get_current_byte_index($xml); + xml_parser_free($xml); + return $return; + } + else + { + libxml_clear_errors(); + $xml = new XMLReader(); + $xml->xml($data); + while (@$xml->read()) + { + switch ($xml->nodeType) + { + + case constant('XMLReader::END_ELEMENT'): + if ($xml->namespaceURI !== '') + { + $tagName = $xml->namespaceURI . $this->separator . $xml->localName; + } + else + { + $tagName = $xml->localName; + } + $this->tag_close(null, $tagName); + break; + case constant('XMLReader::ELEMENT'): + $empty = $xml->isEmptyElement; + if ($xml->namespaceURI !== '') + { + $tagName = $xml->namespaceURI . $this->separator . $xml->localName; + } + else + { + $tagName = $xml->localName; + } + $attributes = array(); + while ($xml->moveToNextAttribute()) + { + if ($xml->namespaceURI !== '') + { + $attrName = $xml->namespaceURI . $this->separator . $xml->localName; + } + else + { + $attrName = $xml->localName; + } + $attributes[$attrName] = $xml->value; + } + $this->tag_open(null, $tagName, $attributes); + if ($empty) + { + $this->tag_close(null, $tagName); + } + break; + case constant('XMLReader::TEXT'): + + case constant('XMLReader::CDATA'): + $this->cdata(null, $xml->value); + break; + } + } + if ($error = libxml_get_last_error()) + { + $this->error_code = $error->code; + $this->error_string = $error->message; + $this->current_line = $error->line; + $this->current_column = $error->column; + return false; + } + else + { + return true; + } + } + } + + public function get_error_code() + { + return $this->error_code; + } + + public function get_error_string() + { + return $this->error_string; + } + + public function get_current_line() + { + return $this->current_line; + } + + public function get_current_column() + { + return $this->current_column; + } + + public function get_current_byte() + { + return $this->current_byte; + } + + public function get_data() + { + return $this->data; + } + + public function tag_open($parser, $tag, $attributes) + { + list($this->namespace[], $this->element[]) = $this->split_ns($tag); + + $attribs = array(); + foreach ($attributes as $name => $value) + { + list($attrib_namespace, $attribute) = $this->split_ns($name); + $attribs[$attrib_namespace][$attribute] = $value; + } + + if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) + { + $base = $this->registry->call('Misc', 'absolutize_url', array($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base))); + if ($base !== false) + { + $this->xml_base[] = $base; + $this->xml_base_explicit[] = true; + } + } + else + { + $this->xml_base[] = end($this->xml_base); + $this->xml_base_explicit[] = end($this->xml_base_explicit); + } + + if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) + { + $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; + } + else + { + $this->xml_lang[] = end($this->xml_lang); + } + + if ($this->current_xhtml_construct >= 0) + { + $this->current_xhtml_construct++; + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) + { + $this->data['data'] .= '<' . end($this->element); + if (isset($attribs[''])) + { + foreach ($attribs[''] as $name => $value) + { + $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; + } + } + $this->data['data'] .= '>'; + } + } + else + { + $this->datas[] =& $this->data; + $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; + $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); + if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml') + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_20 && in_array(end($this->element), array('title'))) + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_090 && in_array(end($this->element), array('title'))) + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_10 && in_array(end($this->element), array('title')))) + { + $this->current_xhtml_construct = 0; + } + } + } + + public function cdata($parser, $cdata) + { + if ($this->current_xhtml_construct >= 0) + { + $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); + } + else + { + $this->data['data'] .= $cdata; + } + } + + public function tag_close($parser, $tag) + { + if ($this->current_xhtml_construct >= 0) + { + $this->current_xhtml_construct--; + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) + { + $this->data['data'] .= '</' . end($this->element) . '>'; + } + } + if ($this->current_xhtml_construct === -1) + { + $this->data =& $this->datas[count($this->datas) - 1]; + array_pop($this->datas); + } + + array_pop($this->element); + array_pop($this->namespace); + array_pop($this->xml_base); + array_pop($this->xml_base_explicit); + array_pop($this->xml_lang); + } + + public function split_ns($string) + { + static $cache = array(); + if (!isset($cache[$string])) + { + if ($pos = strpos($string, $this->separator)) + { + static $separator_length; + if (!$separator_length) + { + $separator_length = strlen($this->separator); + } + $namespace = substr($string, 0, $pos); + $local_name = substr($string, $pos + $separator_length); + if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) + { + $namespace = SIMPLEPIE_NAMESPACE_ITUNES; + } + + // Normalize the Media RSS namespaces + if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG || + $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2 || + $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3 || + $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4 || + $namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5 ) + { + $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; + } + $cache[$string] = array($namespace, $local_name); + } + else + { + $cache[$string] = array('', $string); + } + } + return $cache[$string]; + } +} diff --git a/backend/wp-includes/SimplePie/Rating.php b/backend/wp-includes/SimplePie/Rating.php new file mode 100644 index 0000000..8689e5d --- /dev/null +++ b/backend/wp-includes/SimplePie/Rating.php @@ -0,0 +1,129 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Handles `<media:rating>` or `<itunes:explicit>` tags as defined in Media RSS and iTunes RSS respectively + * + * Used by {@see SimplePie_Enclosure::get_rating()} and {@see SimplePie_Enclosure::get_ratings()} + * + * This class can be overloaded with {@see SimplePie::set_rating_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Rating +{ + /** + * Rating scheme + * + * @var string + * @see get_scheme() + */ + var $scheme; + + /** + * Rating value + * + * @var string + * @see get_value() + */ + var $value; + + /** + * Constructor, used to input the data + * + * For documentation on all the parameters, see the corresponding + * properties and their accessors + */ + public function __construct($scheme = null, $value = null) + { + $this->scheme = $scheme; + $this->value = $value; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the organizational scheme for the rating + * + * @return string|null + */ + public function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + /** + * Get the value of the rating + * + * @return string|null + */ + public function get_value() + { + if ($this->value !== null) + { + return $this->value; + } + else + { + return null; + } + } +} diff --git a/backend/wp-includes/SimplePie/Registry.php b/backend/wp-includes/SimplePie/Registry.php new file mode 100644 index 0000000..1072cde --- /dev/null +++ b/backend/wp-includes/SimplePie/Registry.php @@ -0,0 +1,225 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Handles creating objects and calling methods + * + * Access this via {@see SimplePie::get_registry()} + * + * @package SimplePie + */ +class SimplePie_Registry +{ + /** + * Default class mapping + * + * Overriding classes *must* subclass these. + * + * @var array + */ + protected $default = array( + 'Cache' => 'SimplePie_Cache', + 'Locator' => 'SimplePie_Locator', + 'Parser' => 'SimplePie_Parser', + 'File' => 'SimplePie_File', + 'Sanitize' => 'SimplePie_Sanitize', + 'Item' => 'SimplePie_Item', + 'Author' => 'SimplePie_Author', + 'Category' => 'SimplePie_Category', + 'Enclosure' => 'SimplePie_Enclosure', + 'Caption' => 'SimplePie_Caption', + 'Copyright' => 'SimplePie_Copyright', + 'Credit' => 'SimplePie_Credit', + 'Rating' => 'SimplePie_Rating', + 'Restriction' => 'SimplePie_Restriction', + 'Content_Type_Sniffer' => 'SimplePie_Content_Type_Sniffer', + 'Source' => 'SimplePie_Source', + 'Misc' => 'SimplePie_Misc', + 'XML_Declaration_Parser' => 'SimplePie_XML_Declaration_Parser', + 'Parse_Date' => 'SimplePie_Parse_Date', + ); + + /** + * Class mapping + * + * @see register() + * @var array + */ + protected $classes = array(); + + /** + * Legacy classes + * + * @see register() + * @var array + */ + protected $legacy = array(); + + /** + * Constructor + * + * No-op + */ + public function __construct() { } + + /** + * Register a class + * + * @param string $type See {@see $default} for names + * @param string $class Class name, must subclass the corresponding default + * @param bool $legacy Whether to enable legacy support for this class + * @return bool Successfulness + */ + public function register($type, $class, $legacy = false) + { + if (!is_subclass_of($class, $this->default[$type])) + { + return false; + } + + $this->classes[$type] = $class; + + if ($legacy) + { + $this->legacy[] = $class; + } + + return true; + } + + /** + * Get the class registered for a type + * + * Where possible, use {@see create()} or {@see call()} instead + * + * @param string $type + * @return string|null + */ + public function get_class($type) + { + if (!empty($this->classes[$type])) + { + return $this->classes[$type]; + } + if (!empty($this->default[$type])) + { + return $this->default[$type]; + } + + return null; + } + + /** + * Create a new instance of a given type + * + * @param string $type + * @param array $parameters Parameters to pass to the constructor + * @return object Instance of class + */ + public function &create($type, $parameters = array()) + { + $class = $this->get_class($type); + + if (in_array($class, $this->legacy)) + { + switch ($type) + { + case 'locator': + // Legacy: file, timeout, useragent, file_class, max_checked_feeds, content_type_sniffer_class + // Specified: file, timeout, useragent, max_checked_feeds + $replacement = array($this->get_class('file'), $parameters[3], $this->get_class('content_type_sniffer')); + array_splice($parameters, 3, 1, $replacement); + break; + } + } + + if (!method_exists($class, '__construct')) + { + $instance = new $class; + } + else + { + $reflector = new ReflectionClass($class); + $instance = $reflector->newInstanceArgs($parameters); + } + + if (method_exists($instance, 'set_registry')) + { + $instance->set_registry($this); + } + return $instance; + } + + /** + * Call a static method for a type + * + * @param string $type + * @param string $method + * @param array $parameters + * @return mixed + */ + public function &call($type, $method, $parameters = array()) + { + $class = $this->get_class($type); + + if (in_array($class, $this->legacy)) + { + switch ($type) + { + case 'Cache': + // For backwards compatibility with old non-static + // Cache::create() methods + if ($method === 'get_handler') + { + $result = @call_user_func_array(array($class, 'create'), $parameters); + return $result; + } + break; + } + } + + $result = call_user_func_array(array($class, $method), $parameters); + return $result; + } +} \ No newline at end of file diff --git a/backend/wp-includes/SimplePie/Restriction.php b/backend/wp-includes/SimplePie/Restriction.php new file mode 100644 index 0000000..4ba371b --- /dev/null +++ b/backend/wp-includes/SimplePie/Restriction.php @@ -0,0 +1,155 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Handles `<media:restriction>` as defined in Media RSS + * + * Used by {@see SimplePie_Enclosure::get_restriction()} and {@see SimplePie_Enclosure::get_restrictions()} + * + * This class can be overloaded with {@see SimplePie::set_restriction_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Restriction +{ + /** + * Relationship ('allow'/'deny') + * + * @var string + * @see get_relationship() + */ + var $relationship; + + /** + * Type of restriction + * + * @var string + * @see get_type() + */ + var $type; + + /** + * Restricted values + * + * @var string + * @see get_value() + */ + var $value; + + /** + * Constructor, used to input the data + * + * For documentation on all the parameters, see the corresponding + * properties and their accessors + */ + public function __construct($relationship = null, $type = null, $value = null) + { + $this->relationship = $relationship; + $this->type = $type; + $this->value = $value; + } + + /** + * String-ified version + * + * @return string + */ + public function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + /** + * Get the relationship + * + * @return string|null Either 'allow' or 'deny' + */ + public function get_relationship() + { + if ($this->relationship !== null) + { + return $this->relationship; + } + else + { + return null; + } + } + + /** + * Get the type + * + * @return string|null + */ + public function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } + + /** + * Get the list of restricted things + * + * @return string|null + */ + public function get_value() + { + if ($this->value !== null) + { + return $this->value; + } + else + { + return null; + } + } +} diff --git a/backend/wp-includes/SimplePie/Sanitize.php b/backend/wp-includes/SimplePie/Sanitize.php new file mode 100644 index 0000000..1ce047a --- /dev/null +++ b/backend/wp-includes/SimplePie/Sanitize.php @@ -0,0 +1,554 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Used for data cleanup and post-processing + * + * + * This class can be overloaded with {@see SimplePie::set_sanitize_class()} + * + * @package SimplePie + * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags + */ +class SimplePie_Sanitize +{ + // Private vars + var $base; + + // Options + var $remove_div = true; + var $image_handler = ''; + var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + var $encode_instead_of_strip = false; + var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); + var $strip_comments = false; + var $output_encoding = 'UTF-8'; + var $enable_cache = true; + var $cache_location = './cache'; + var $cache_name_function = 'md5'; + var $timeout = 10; + var $useragent = ''; + var $force_fsockopen = false; + var $replace_url_attributes = null; + + public function __construct() + { + // Set defaults + $this->set_url_replacements(null); + } + + public function remove_div($enable = true) + { + $this->remove_div = (bool) $enable; + } + + public function set_image_handler($page = false) + { + if ($page) + { + $this->image_handler = (string) $page; + } + else + { + $this->image_handler = false; + } + } + + public function set_registry(SimplePie_Registry $registry) + { + $this->registry = $registry; + } + + public function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') + { + if (isset($enable_cache)) + { + $this->enable_cache = (bool) $enable_cache; + } + + if ($cache_location) + { + $this->cache_location = (string) $cache_location; + } + + if ($cache_name_function) + { + $this->cache_name_function = (string) $cache_name_function; + } + } + + public function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) + { + if ($timeout) + { + $this->timeout = (string) $timeout; + } + + if ($useragent) + { + $this->useragent = (string) $useragent; + } + + if ($force_fsockopen) + { + $this->force_fsockopen = (string) $force_fsockopen; + } + } + + public function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) + { + if ($tags) + { + if (is_array($tags)) + { + $this->strip_htmltags = $tags; + } + else + { + $this->strip_htmltags = explode(',', $tags); + } + } + else + { + $this->strip_htmltags = false; + } + } + + public function encode_instead_of_strip($encode = false) + { + $this->encode_instead_of_strip = (bool) $encode; + } + + public function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) + { + if ($attribs) + { + if (is_array($attribs)) + { + $this->strip_attributes = $attribs; + } + else + { + $this->strip_attributes = explode(',', $attribs); + } + } + else + { + $this->strip_attributes = false; + } + } + + public function strip_comments($strip = false) + { + $this->strip_comments = (bool) $strip; + } + + public function set_output_encoding($encoding = 'UTF-8') + { + $this->output_encoding = (string) $encoding; + } + + /** + * Set element/attribute key/value pairs of HTML attributes + * containing URLs that need to be resolved relative to the feed + * + * Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite, + * |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite, + * |q|@cite + * + * @since 1.0 + * @param array|null $element_attribute Element/attribute key/value pairs, null for default + */ + public function set_url_replacements($element_attribute = null) + { + if ($element_attribute === null) + { + $element_attribute = array( + 'a' => 'href', + 'area' => 'href', + 'blockquote' => 'cite', + 'del' => 'cite', + 'form' => 'action', + 'img' => array( + 'longdesc', + 'src' + ), + 'input' => 'src', + 'ins' => 'cite', + 'q' => 'cite' + ); + } + $this->replace_url_attributes = (array) $element_attribute; + } + + public function sanitize($data, $type, $base = '') + { + $data = trim($data); + if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) + { + if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) + { + if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) + { + $type |= SIMPLEPIE_CONSTRUCT_HTML; + } + else + { + $type |= SIMPLEPIE_CONSTRUCT_TEXT; + } + } + + if ($type & SIMPLEPIE_CONSTRUCT_BASE64) + { + $data = base64_decode($data); + } + + if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) + { + + if (!class_exists('DOMDocument')) + { + $this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__)); + return ''; + } + $document = new DOMDocument(); + $document->encoding = 'UTF-8'; + $data = $this->preprocess($data, $type); + + set_error_handler(array('SimplePie_Misc', 'silence_errors')); + $document->loadHTML($data); + restore_error_handler(); + + // Strip comments + if ($this->strip_comments) + { + $xpath = new DOMXPath($document); + $comments = $xpath->query('//comment()'); + + foreach ($comments as $comment) + { + $comment->parentNode->removeChild($comment); + } + } + + // Strip out HTML tags and attributes that might cause various security problems. + // Based on recommendations by Mark Pilgrim at: + // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely + if ($this->strip_htmltags) + { + foreach ($this->strip_htmltags as $tag) + { + $this->strip_tag($tag, $document, $type); + } + } + + if ($this->strip_attributes) + { + foreach ($this->strip_attributes as $attrib) + { + $this->strip_attr($attrib, $document); + } + } + + // Replace relative URLs + $this->base = $base; + foreach ($this->replace_url_attributes as $element => $attributes) + { + $this->replace_urls($document, $element, $attributes); + } + + // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. + if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) + { + $images = $document->getElementsByTagName('img'); + foreach ($images as $img) + { + if ($img->hasAttribute('src')) + { + $image_url = call_user_func($this->cache_name_function, $img->getAttribute('src')); + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, $image_url, 'spi')); + + if ($cache->load()) + { + $img->setAttribute('src', $this->image_handler . $image_url); + } + else + { + $file = $this->registry->create('File', array($img->getAttribute('src'), $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen)); + $headers = $file->headers; + + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) + { + if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) + { + $img->setAttribute('src', $this->image_handler . $image_url); + } + else + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + } + } + } + } + } + } + + // Remove the DOCTYPE + // Seems to cause segfaulting if we don't do this + if ($document->firstChild instanceof DOMDocumentType) + { + $document->removeChild($document->firstChild); + } + + // Move everything from the body to the root + $real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0); + $document->replaceChild($real_body, $document->firstChild); + + // Finally, convert to a HTML string + $data = trim($document->saveHTML()); + + if ($this->remove_div) + { + $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); + $data = preg_replace('/<\/div>$/', '', $data); + } + else + { + $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); + } + } + + if ($type & SIMPLEPIE_CONSTRUCT_IRI) + { + $absolute = $this->registry->call('Misc', 'absolutize_url', array($data, $base)); + if ($absolute !== false) + { + $data = $absolute; + } + } + + if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) + { + $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); + } + + if ($this->output_encoding !== 'UTF-8') + { + $data = $this->registry->call('Misc', 'change_encoding', array($data, 'UTF-8', $this->output_encoding)); + } + } + return $data; + } + + protected function preprocess($html, $type) + { + $ret = ''; + if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML) + { + // Atom XHTML constructs are wrapped with a div by default + // Note: No protection if $html contains a stray </div>! + $html = '<div>' . $html . '</div>'; + $ret .= '<!DOCTYPE html>'; + $content_type = 'text/html'; + } + else + { + $ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; + $content_type = 'application/xhtml+xml'; + } + + $ret .= '<html><head>'; + $ret .= '<meta http-equiv="Content-Type" content="' . $content_type . '; charset=utf-8" />'; + $ret .= '</head><body>' . $html . '</body></html>'; + return $ret; + } + + public function replace_urls($document, $tag, $attributes) + { + if (!is_array($attributes)) + { + $attributes = array($attributes); + } + + if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) + { + $elements = $document->getElementsByTagName($tag); + foreach ($elements as $element) + { + foreach ($attributes as $attribute) + { + if ($element->hasAttribute($attribute)) + { + $value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base)); + if ($value !== false) + { + $element->setAttribute($attribute, $value); + } + } + } + } + } + } + + public function do_strip_htmltags($match) + { + if ($this->encode_instead_of_strip) + { + if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) + { + $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); + $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); + return "<$match[1]$match[2]>$match[3]</$match[1]>"; + } + else + { + return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); + } + } + elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) + { + return $match[4]; + } + else + { + return ''; + } + } + + protected function strip_tag($tag, $document, $type) + { + $xpath = new DOMXPath($document); + $elements = $xpath->query('body//' . $tag); + if ($this->encode_instead_of_strip) + { + foreach ($elements as $element) + { + $fragment = $document->createDocumentFragment(); + + // For elements which aren't script or style, include the tag itself + if (!in_array($tag, array('script', 'style'))) + { + $text = '<' . $tag; + if ($element->hasAttributes()) + { + $attrs = array(); + foreach ($element->attributes as $name => $attr) + { + $value = $attr->value; + + // In XHTML, empty values should never exist, so we repeat the value + if (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_XHTML)) + { + $value = $name; + } + // For HTML, empty is fine + elseif (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_HTML)) + { + $attrs[] = $name; + continue; + } + + // Standard attribute text + $attrs[] = $name . '="' . $attr->value . '"'; + } + $text .= ' ' . implode(' ', $attrs); + } + $text .= '>'; + $fragment->appendChild(new DOMText($text)); + } + + $number = $element->childNodes->length; + for ($i = $number; $i > 0; $i--) + { + $child = $element->childNodes->item(0); + $fragment->appendChild($child); + } + + if (!in_array($tag, array('script', 'style'))) + { + $fragment->appendChild(new DOMText('</' . $tag . '>')); + } + + $element->parentNode->replaceChild($fragment, $element); + } + + return; + } + elseif (in_array($tag, array('script', 'style'))) + { + foreach ($elements as $element) + { + $element->parentNode->removeChild($element); + } + + return; + } + else + { + foreach ($elements as $element) + { + $fragment = $document->createDocumentFragment(); + $number = $element->childNodes->length; + for ($i = $number; $i > 0; $i--) + { + $child = $element->childNodes->item(0); + $fragment->appendChild($child); + } + + $element->parentNode->replaceChild($fragment, $element); + } + } + } + + protected function strip_attr($attrib, $document) + { + $xpath = new DOMXPath($document); + $elements = $xpath->query('//*[@' . $attrib . ']'); + + foreach ($elements as $element) + { + $element->removeAttribute($attrib); + } + } +} diff --git a/backend/wp-includes/SimplePie/Source.php b/backend/wp-includes/SimplePie/Source.php new file mode 100644 index 0000000..51d8e6c --- /dev/null +++ b/backend/wp-includes/SimplePie/Source.php @@ -0,0 +1,611 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * Handles `<atom:source>` + * + * Used by {@see SimplePie_Item::get_source()} + * + * This class can be overloaded with {@see SimplePie::set_source_class()} + * + * @package SimplePie + * @subpackage API + */ +class SimplePie_Source +{ + var $item; + var $data = array(); + protected $registry; + + public function __construct($item, $data) + { + $this->item = $item; + $this->data = $data; + } + + public function set_registry(SimplePie_Registry $registry) + { + $this->registry = $registry; + } + + public function __toString() + { + return md5(serialize($this->data)); + } + + public function get_source_tags($namespace, $tag) + { + if (isset($this->data['child'][$namespace][$tag])) + { + return $this->data['child'][$namespace][$tag]; + } + else + { + return null; + } + } + + public function get_base($element = array()) + { + return $this->item->get_base($element); + } + + public function sanitize($data, $type, $base = '') + { + return $this->item->sanitize($data, $type, $base); + } + + public function get_item() + { + return $this->item; + } + + public function get_title() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + public function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + public function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = $this->registry->create('Category', array($term, $scheme, null)); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($categories)) + { + return array_unique($categories); + } + else + { + return null; + } + } + + public function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + public function get_authors() + { + $authors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($authors)) + { + return array_unique($authors); + } + else + { + return null; + } + } + + public function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + public function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + + if (!empty($contributors)) + { + return array_unique($contributors); + } + else + { + return null; + } + } + + public function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if (isset($links[$key])) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Added for parity between the parent-level and the item/entry-level. + */ + public function get_permalink() + { + return $this->get_link(0); + } + + public function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + public function get_description() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + else + { + return null; + } + } + + public function get_copyright() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + public function get_language() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['xml_lang'])) + { + return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + public function get_latitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + public function get_longitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + public function get_image_url() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) + { + return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } +} + diff --git a/backend/wp-includes/SimplePie/XML/Declaration/Parser.php b/backend/wp-includes/SimplePie/XML/Declaration/Parser.php new file mode 100644 index 0000000..aec19f1 --- /dev/null +++ b/backend/wp-includes/SimplePie/XML/Declaration/Parser.php @@ -0,0 +1,362 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + + +/** + * Parses the XML Declaration + * + * @package SimplePie + * @subpackage Parsing + */ +class SimplePie_XML_Declaration_Parser +{ + /** + * XML Version + * + * @access public + * @var string + */ + var $version = '1.0'; + + /** + * Encoding + * + * @access public + * @var string + */ + var $encoding = 'UTF-8'; + + /** + * Standalone + * + * @access public + * @var bool + */ + var $standalone = false; + + /** + * Current state of the state machine + * + * @access private + * @var string + */ + var $state = 'before_version_name'; + + /** + * Input data + * + * @access private + * @var string + */ + var $data = ''; + + /** + * Input data length (to avoid calling strlen() everytime this is needed) + * + * @access private + * @var int + */ + var $data_length = 0; + + /** + * Current position of the pointer + * + * @var int + * @access private + */ + var $position = 0; + + /** + * Create an instance of the class with the input data + * + * @access public + * @param string $data Input data + */ + public function __construct($data) + { + $this->data = $data; + $this->data_length = strlen($this->data); + } + + /** + * Parse the input data + * + * @access public + * @return bool true on success, false on failure + */ + public function parse() + { + while ($this->state && $this->state !== 'emit' && $this->has_data()) + { + $state = $this->state; + $this->$state(); + } + $this->data = ''; + if ($this->state === 'emit') + { + return true; + } + else + { + $this->version = ''; + $this->encoding = ''; + $this->standalone = ''; + return false; + } + } + + /** + * Check whether there is data beyond the pointer + * + * @access private + * @return bool true if there is further data, false if not + */ + public function has_data() + { + return (bool) ($this->position < $this->data_length); + } + + /** + * Advance past any whitespace + * + * @return int Number of whitespace characters passed + */ + public function skip_whitespace() + { + $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position); + $this->position += $whitespace; + return $whitespace; + } + + /** + * Read value + */ + public function get_value() + { + $quote = substr($this->data, $this->position, 1); + if ($quote === '"' || $quote === "'") + { + $this->position++; + $len = strcspn($this->data, $quote, $this->position); + if ($this->has_data()) + { + $value = substr($this->data, $this->position, $len); + $this->position += $len + 1; + return $value; + } + } + return false; + } + + public function before_version_name() + { + if ($this->skip_whitespace()) + { + $this->state = 'version_name'; + } + else + { + $this->state = false; + } + } + + public function version_name() + { + if (substr($this->data, $this->position, 7) === 'version') + { + $this->position += 7; + $this->skip_whitespace(); + $this->state = 'version_equals'; + } + else + { + $this->state = false; + } + } + + public function version_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'version_value'; + } + else + { + $this->state = false; + } + } + + public function version_value() + { + if ($this->version = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'encoding_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } + + public function encoding_name() + { + if (substr($this->data, $this->position, 8) === 'encoding') + { + $this->position += 8; + $this->skip_whitespace(); + $this->state = 'encoding_equals'; + } + else + { + $this->state = 'standalone_name'; + } + } + + public function encoding_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'encoding_value'; + } + else + { + $this->state = false; + } + } + + public function encoding_value() + { + if ($this->encoding = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'standalone_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } + + public function standalone_name() + { + if (substr($this->data, $this->position, 10) === 'standalone') + { + $this->position += 10; + $this->skip_whitespace(); + $this->state = 'standalone_equals'; + } + else + { + $this->state = false; + } + } + + public function standalone_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'standalone_value'; + } + else + { + $this->state = false; + } + } + + public function standalone_value() + { + if ($standalone = $this->get_value()) + { + switch ($standalone) + { + case 'yes': + $this->standalone = true; + break; + + case 'no': + $this->standalone = false; + break; + + default: + $this->state = false; + return; + } + + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = false; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } +} diff --git a/backend/wp-includes/SimplePie/gzdecode.php b/backend/wp-includes/SimplePie/gzdecode.php new file mode 100644 index 0000000..52e024e --- /dev/null +++ b/backend/wp-includes/SimplePie/gzdecode.php @@ -0,0 +1,371 @@ +<?php +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + + +/** + * Decode 'gzip' encoded HTTP data + * + * @package SimplePie + * @subpackage HTTP + * @link http://www.gzip.org/format.txt + */ +class SimplePie_gzdecode +{ + /** + * Compressed data + * + * @access private + * @var string + * @see gzdecode::$data + */ + var $compressed_data; + + /** + * Size of compressed data + * + * @access private + * @var int + */ + var $compressed_size; + + /** + * Minimum size of a valid gzip string + * + * @access private + * @var int + */ + var $min_compressed_size = 18; + + /** + * Current position of pointer + * + * @access private + * @var int + */ + var $position = 0; + + /** + * Flags (FLG) + * + * @access private + * @var int + */ + var $flags; + + /** + * Uncompressed data + * + * @access public + * @see gzdecode::$compressed_data + * @var string + */ + var $data; + + /** + * Modified time + * + * @access public + * @var int + */ + var $MTIME; + + /** + * Extra Flags + * + * @access public + * @var int + */ + var $XFL; + + /** + * Operating System + * + * @access public + * @var int + */ + var $OS; + + /** + * Subfield ID 1 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI2 + * @var string + */ + var $SI1; + + /** + * Subfield ID 2 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI1 + * @var string + */ + var $SI2; + + /** + * Extra field content + * + * @access public + * @see gzdecode::$SI1 + * @see gzdecode::$SI2 + * @var string + */ + var $extra_field; + + /** + * Original filename + * + * @access public + * @var string + */ + var $filename; + + /** + * Human readable comment + * + * @access public + * @var string + */ + var $comment; + + /** + * Don't allow anything to be set + * + * @param string $name + * @param mixed $value + */ + public function __set($name, $value) + { + trigger_error("Cannot write property $name", E_USER_ERROR); + } + + /** + * Set the compressed string and related properties + * + * @param string $data + */ + public function __construct($data) + { + $this->compressed_data = $data; + $this->compressed_size = strlen($data); + } + + /** + * Decode the GZIP stream + * + * @return bool Successfulness + */ + public function parse() + { + if ($this->compressed_size >= $this->min_compressed_size) + { + // Check ID1, ID2, and CM + if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") + { + return false; + } + + // Get the FLG (FLaGs) + $this->flags = ord($this->compressed_data[3]); + + // FLG bits above (1 << 4) are reserved + if ($this->flags > 0x1F) + { + return false; + } + + // Advance the pointer after the above + $this->position += 4; + + // MTIME + $mtime = substr($this->compressed_data, $this->position, 4); + // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness + if (current(unpack('S', "\x00\x01")) === 1) + { + $mtime = strrev($mtime); + } + $this->MTIME = current(unpack('l', $mtime)); + $this->position += 4; + + // Get the XFL (eXtra FLags) + $this->XFL = ord($this->compressed_data[$this->position++]); + + // Get the OS (Operating System) + $this->OS = ord($this->compressed_data[$this->position++]); + + // Parse the FEXTRA + if ($this->flags & 4) + { + // Read subfield IDs + $this->SI1 = $this->compressed_data[$this->position++]; + $this->SI2 = $this->compressed_data[$this->position++]; + + // SI2 set to zero is reserved for future use + if ($this->SI2 === "\x00") + { + return false; + } + + // Get the length of the extra field + $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + $this->position += 2; + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 4; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the extra field to the given data + $this->extra_field = substr($this->compressed_data, $this->position, $len); + $this->position += $len; + } + else + { + return false; + } + } + + // Parse the FNAME + if ($this->flags & 8) + { + // Get the length of the filename + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original filename to the given string + $this->filename = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FCOMMENT + if ($this->flags & 16) + { + // Get the length of the comment + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original comment to the given string + $this->comment = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FHCRC + if ($this->flags & 2) + { + // Check the length of the string is still valid + $this->min_compressed_size += $len + 2; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Read the CRC + $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + + // Check the CRC matches + if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) + { + $this->position += 2; + } + else + { + return false; + } + } + else + { + return false; + } + } + + // Decompress the actual data + if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) + { + return false; + } + else + { + $this->position = $this->compressed_size - 8; + } + + // Check CRC of data + $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) + { + return false; + }*/ + + // Check ISIZE of data + $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) + { + return false; + } + + // Wow, against all odds, we've actually got a valid gzip string + return true; + } + else + { + return false; + } + } +} diff --git a/backend/wp-includes/Text/Diff.php b/backend/wp-includes/Text/Diff.php new file mode 100644 index 0000000..edcdd3a --- /dev/null +++ b/backend/wp-includes/Text/Diff.php @@ -0,0 +1,506 @@ +<?php +/** + * General API for generating and formatting diffs - the differences between + * two sequences of strings. + * + * The original PHP version of this code was written by Geoffrey T. Dairiki + * <dairiki@dairiki.org>, and is used/adapted with his permission. + * + * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org> + * Copyright 2004-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + */ +class Text_Diff { + + /** + * Array of changes. + * + * @var array + */ + var $_edits; + + /** + * Computes diffs between sequences of strings. + * + * @param string $engine Name of the diffing engine to use. 'auto' + * will automatically select the best. + * @param array $params Parameters to pass to the diffing engine. + * Normally an array of two arrays, each + * containing the lines from a file. + */ + function __construct( $engine, $params ) + { + // Backward compatibility workaround. + if (!is_string($engine)) { + $params = array($engine, $params); + $engine = 'auto'; + } + + if ($engine == 'auto') { + $engine = extension_loaded('xdiff') ? 'xdiff' : 'native'; + } else { + $engine = basename($engine); + } + + // WP #7391 + require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php'; + $class = 'Text_Diff_Engine_' . $engine; + $diff_engine = new $class(); + + $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params); + } + + /** + * PHP4 constructor. + */ + public function Text_Diff( $engine, $params ) { + self::__construct( $engine, $params ); + } + + /** + * Returns the array of differences. + */ + function getDiff() + { + return $this->_edits; + } + + /** + * returns the number of new (added) lines in a given diff. + * + * @since Text_Diff 1.1.0 + * + * @return integer The number of new lines + */ + function countAddedLines() + { + $count = 0; + foreach ($this->_edits as $edit) { + if (is_a($edit, 'Text_Diff_Op_add') || + is_a($edit, 'Text_Diff_Op_change')) { + $count += $edit->nfinal(); + } + } + return $count; + } + + /** + * Returns the number of deleted (removed) lines in a given diff. + * + * @since Text_Diff 1.1.0 + * + * @return integer The number of deleted lines + */ + function countDeletedLines() + { + $count = 0; + foreach ($this->_edits as $edit) { + if (is_a($edit, 'Text_Diff_Op_delete') || + is_a($edit, 'Text_Diff_Op_change')) { + $count += $edit->norig(); + } + } + return $count; + } + + /** + * Computes a reversed diff. + * + * Example: + * <code> + * $diff = new Text_Diff($lines1, $lines2); + * $rev = $diff->reverse(); + * </code> + * + * @return Text_Diff A Diff object representing the inverse of the + * original diff. Note that we purposely don't return a + * reference here, since this essentially is a clone() + * method. + */ + function reverse() + { + if (version_compare(zend_version(), '2', '>')) { + $rev = clone($this); + } else { + $rev = $this; + } + $rev->_edits = array(); + foreach ($this->_edits as $edit) { + $rev->_edits[] = $edit->reverse(); + } + return $rev; + } + + /** + * Checks for an empty diff. + * + * @return boolean True if two sequences were identical. + */ + function isEmpty() + { + foreach ($this->_edits as $edit) { + if (!is_a($edit, 'Text_Diff_Op_copy')) { + return false; + } + } + return true; + } + + /** + * Computes the length of the Longest Common Subsequence (LCS). + * + * This is mostly for diagnostic purposes. + * + * @return integer The length of the LCS. + */ + function lcs() + { + $lcs = 0; + foreach ($this->_edits as $edit) { + if (is_a($edit, 'Text_Diff_Op_copy')) { + $lcs += count($edit->orig); + } + } + return $lcs; + } + + /** + * Gets the original set of lines. + * + * This reconstructs the $from_lines parameter passed to the constructor. + * + * @return array The original sequence of strings. + */ + function getOriginal() + { + $lines = array(); + foreach ($this->_edits as $edit) { + if ($edit->orig) { + array_splice($lines, count($lines), 0, $edit->orig); + } + } + return $lines; + } + + /** + * Gets the final set of lines. + * + * This reconstructs the $to_lines parameter passed to the constructor. + * + * @return array The sequence of strings. + */ + function getFinal() + { + $lines = array(); + foreach ($this->_edits as $edit) { + if ($edit->final) { + array_splice($lines, count($lines), 0, $edit->final); + } + } + return $lines; + } + + /** + * Removes trailing newlines from a line of text. This is meant to be used + * with array_walk(). + * + * @param string $line The line to trim. + * @param integer $key The index of the line in the array. Not used. + */ + static function trimNewlines(&$line, $key) + { + $line = str_replace(array("\n", "\r"), '', $line); + } + + /** + * Determines the location of the system temporary directory. + * + * @static + * + * @access protected + * + * @return string A directory name which can be used for temp files. + * Returns false if one could not be found. + */ + function _getTempDir() + { + $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', + 'c:\windows\temp', 'c:\winnt\temp'); + + /* Try PHP's upload_tmp_dir directive. */ + $tmp = ini_get('upload_tmp_dir'); + + /* Otherwise, try to determine the TMPDIR environment variable. */ + if (!strlen($tmp)) { + $tmp = getenv('TMPDIR'); + } + + /* If we still cannot determine a value, then cycle through a list of + * preset possibilities. */ + while (!strlen($tmp) && count($tmp_locations)) { + $tmp_check = array_shift($tmp_locations); + if (@is_dir($tmp_check)) { + $tmp = $tmp_check; + } + } + + /* If it is still empty, we have failed, so return false; otherwise + * return the directory determined. */ + return strlen($tmp) ? $tmp : false; + } + + /** + * Checks a diff for validity. + * + * This is here only for debugging purposes. + */ + function _check($from_lines, $to_lines) + { + if (serialize($from_lines) != serialize($this->getOriginal())) { + trigger_error("Reconstructed original doesn't match", E_USER_ERROR); + } + if (serialize($to_lines) != serialize($this->getFinal())) { + trigger_error("Reconstructed final doesn't match", E_USER_ERROR); + } + + $rev = $this->reverse(); + if (serialize($to_lines) != serialize($rev->getOriginal())) { + trigger_error("Reversed original doesn't match", E_USER_ERROR); + } + if (serialize($from_lines) != serialize($rev->getFinal())) { + trigger_error("Reversed final doesn't match", E_USER_ERROR); + } + + $prevtype = null; + foreach ($this->_edits as $edit) { + if ($prevtype == get_class($edit)) { + trigger_error("Edit sequence is non-optimal", E_USER_ERROR); + } + $prevtype = get_class($edit); + } + + return true; + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + */ +class Text_MappedDiff extends Text_Diff { + + /** + * Computes a diff between sequences of strings. + * + * This can be used to compute things like case-insensitve diffs, or diffs + * which ignore changes in white-space. + * + * @param array $from_lines An array of strings. + * @param array $to_lines An array of strings. + * @param array $mapped_from_lines This array should have the same size + * number of elements as $from_lines. The + * elements in $mapped_from_lines and + * $mapped_to_lines are what is actually + * compared when computing the diff. + * @param array $mapped_to_lines This array should have the same number + * of elements as $to_lines. + */ + function __construct($from_lines, $to_lines, + $mapped_from_lines, $mapped_to_lines) + { + assert(count($from_lines) == count($mapped_from_lines)); + assert(count($to_lines) == count($mapped_to_lines)); + + parent::Text_Diff($mapped_from_lines, $mapped_to_lines); + + $xi = $yi = 0; + for ($i = 0; $i < count($this->_edits); $i++) { + $orig = &$this->_edits[$i]->orig; + if (is_array($orig)) { + $orig = array_slice($from_lines, $xi, count($orig)); + $xi += count($orig); + } + + $final = &$this->_edits[$i]->final; + if (is_array($final)) { + $final = array_slice($to_lines, $yi, count($final)); + $yi += count($final); + } + } + } + + /** + * PHP4 constructor. + */ + public function Text_MappedDiff( $from_lines, $to_lines, + $mapped_from_lines, $mapped_to_lines ) { + self::__construct( $from_lines, $to_lines, + $mapped_from_lines, $mapped_to_lines ); + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * + * @access private + */ +class Text_Diff_Op { + + var $orig; + var $final; + + function &reverse() + { + trigger_error('Abstract method', E_USER_ERROR); + } + + function norig() + { + return $this->orig ? count($this->orig) : 0; + } + + function nfinal() + { + return $this->final ? count($this->final) : 0; + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * + * @access private + */ +class Text_Diff_Op_copy extends Text_Diff_Op { + + /** + * PHP5 constructor. + */ + function __construct( $orig, $final = false ) + { + if (!is_array($final)) { + $final = $orig; + } + $this->orig = $orig; + $this->final = $final; + } + + /** + * PHP4 constructor. + */ + public function Text_Diff_Op_copy( $orig, $final = false ) { + self::__construct( $orig, $final ); + } + + function &reverse() + { + $reverse = new Text_Diff_Op_copy($this->final, $this->orig); + return $reverse; + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * + * @access private + */ +class Text_Diff_Op_delete extends Text_Diff_Op { + + /** + * PHP5 constructor. + */ + function __construct( $lines ) + { + $this->orig = $lines; + $this->final = false; + } + + /** + * PHP4 constructor. + */ + public function Text_Diff_Op_delete( $lines ) { + self::__construct( $lines ); + } + + function &reverse() + { + $reverse = new Text_Diff_Op_add($this->orig); + return $reverse; + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * + * @access private + */ +class Text_Diff_Op_add extends Text_Diff_Op { + + /** + * PHP5 constructor. + */ + function __construct( $lines ) + { + $this->final = $lines; + $this->orig = false; + } + + /** + * PHP4 constructor. + */ + public function Text_Diff_Op_add( $lines ) { + self::__construct( $lines ); + } + + function &reverse() + { + $reverse = new Text_Diff_Op_delete($this->final); + return $reverse; + } + +} + +/** + * @package Text_Diff + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * + * @access private + */ +class Text_Diff_Op_change extends Text_Diff_Op { + + /** + * PHP5 constructor. + */ + function __construct( $orig, $final ) + { + $this->orig = $orig; + $this->final = $final; + } + + /** + * PHP4 constructor. + */ + public function Text_Diff_Op_change( $orig, $final ) { + self::__construct( $orig, $final ); + } + + function &reverse() + { + $reverse = new Text_Diff_Op_change($this->final, $this->orig); + return $reverse; + } + +} diff --git a/backend/wp-includes/Text/Diff/Engine/native.php b/backend/wp-includes/Text/Diff/Engine/native.php new file mode 100644 index 0000000..5824329 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Engine/native.php @@ -0,0 +1,438 @@ +<?php +/** + * Class used internally by Text_Diff to actually compute the diffs. + * + * This class is implemented using native PHP code. + * + * The algorithm used here is mostly lifted from the perl module + * Algorithm::Diff (version 1.06) by Ned Konz, which is available at: + * http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip + * + * More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html + * + * Some ideas (and a bit of code) are taken from analyze.c, of GNU + * diffutils-2.7, which can be found at: + * ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz + * + * Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from + * Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this + * code was written by him, and is used/adapted with his permission. + * + * Copyright 2004-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @author Geoffrey T. Dairiki <dairiki@dairiki.org> + * @package Text_Diff + */ +class Text_Diff_Engine_native { + + function diff($from_lines, $to_lines) + { + array_walk($from_lines, array('Text_Diff', 'trimNewlines')); + array_walk($to_lines, array('Text_Diff', 'trimNewlines')); + + $n_from = count($from_lines); + $n_to = count($to_lines); + + $this->xchanged = $this->ychanged = array(); + $this->xv = $this->yv = array(); + $this->xind = $this->yind = array(); + unset($this->seq); + unset($this->in_seq); + unset($this->lcs); + + // Skip leading common lines. + for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) { + if ($from_lines[$skip] !== $to_lines[$skip]) { + break; + } + $this->xchanged[$skip] = $this->ychanged[$skip] = false; + } + + // Skip trailing common lines. + $xi = $n_from; $yi = $n_to; + for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) { + if ($from_lines[$xi] !== $to_lines[$yi]) { + break; + } + $this->xchanged[$xi] = $this->ychanged[$yi] = false; + } + + // Ignore lines which do not exist in both files. + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { + $xhash[$from_lines[$xi]] = 1; + } + for ($yi = $skip; $yi < $n_to - $endskip; $yi++) { + $line = $to_lines[$yi]; + if (($this->ychanged[$yi] = empty($xhash[$line]))) { + continue; + } + $yhash[$line] = 1; + $this->yv[] = $line; + $this->yind[] = $yi; + } + for ($xi = $skip; $xi < $n_from - $endskip; $xi++) { + $line = $from_lines[$xi]; + if (($this->xchanged[$xi] = empty($yhash[$line]))) { + continue; + } + $this->xv[] = $line; + $this->xind[] = $xi; + } + + // Find the LCS. + $this->_compareseq(0, count($this->xv), 0, count($this->yv)); + + // Merge edits when possible. + $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged); + $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged); + + // Compute the edit operations. + $edits = array(); + $xi = $yi = 0; + while ($xi < $n_from || $yi < $n_to) { + assert($yi < $n_to || $this->xchanged[$xi]); + assert($xi < $n_from || $this->ychanged[$yi]); + + // Skip matching "snake". + $copy = array(); + while ($xi < $n_from && $yi < $n_to + && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { + $copy[] = $from_lines[$xi++]; + ++$yi; + } + if ($copy) { + $edits[] = new Text_Diff_Op_copy($copy); + } + + // Find deletes & adds. + $delete = array(); + while ($xi < $n_from && $this->xchanged[$xi]) { + $delete[] = $from_lines[$xi++]; + } + + $add = array(); + while ($yi < $n_to && $this->ychanged[$yi]) { + $add[] = $to_lines[$yi++]; + } + + if ($delete && $add) { + $edits[] = new Text_Diff_Op_change($delete, $add); + } elseif ($delete) { + $edits[] = new Text_Diff_Op_delete($delete); + } elseif ($add) { + $edits[] = new Text_Diff_Op_add($add); + } + } + + return $edits; + } + + /** + * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF, + * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized + * segments. + * + * Returns (LCS, PTS). LCS is the length of the LCS. PTS is an array of + * NCHUNKS+1 (X, Y) indexes giving the diving points between sub + * sequences. The first sub-sequence is contained in (X0, X1), (Y0, Y1), + * the second in (X1, X2), (Y1, Y2) and so on. Note that (X0, Y0) == + * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). + * + * This function assumes that the first lines of the specified portions of + * the two files do not match, and likewise that the last lines do not + * match. The caller must trim matching lines from the beginning and end + * of the portions it is going to specify. + */ + function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks) + { + $flip = false; + + if ($xlim - $xoff > $ylim - $yoff) { + /* Things seems faster (I'm not sure I understand why) when the + * shortest sequence is in X. */ + $flip = true; + list ($xoff, $xlim, $yoff, $ylim) + = array($yoff, $ylim, $xoff, $xlim); + } + + if ($flip) { + for ($i = $ylim - 1; $i >= $yoff; $i--) { + $ymatches[$this->xv[$i]][] = $i; + } + } else { + for ($i = $ylim - 1; $i >= $yoff; $i--) { + $ymatches[$this->yv[$i]][] = $i; + } + } + + $this->lcs = 0; + $this->seq[0]= $yoff - 1; + $this->in_seq = array(); + $ymids[0] = array(); + + $numer = $xlim - $xoff + $nchunks - 1; + $x = $xoff; + for ($chunk = 0; $chunk < $nchunks; $chunk++) { + if ($chunk > 0) { + for ($i = 0; $i <= $this->lcs; $i++) { + $ymids[$i][$chunk - 1] = $this->seq[$i]; + } + } + + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks); + for (; $x < $x1; $x++) { + $line = $flip ? $this->yv[$x] : $this->xv[$x]; + if (empty($ymatches[$line])) { + continue; + } + $matches = $ymatches[$line]; + reset($matches); + while ($y = current($matches)) { + if (empty($this->in_seq[$y])) { + $k = $this->_lcsPos($y); + assert($k > 0); + $ymids[$k] = $ymids[$k - 1]; + break; + } + next($matches); + } + while ($y = current($matches)) { + if ($y > $this->seq[$k - 1]) { + assert($y <= $this->seq[$k]); + /* Optimization: this is a common case: next match is + * just replacing previous match. */ + $this->in_seq[$this->seq[$k]] = false; + $this->seq[$k] = $y; + $this->in_seq[$y] = 1; + } elseif (empty($this->in_seq[$y])) { + $k = $this->_lcsPos($y); + assert($k > 0); + $ymids[$k] = $ymids[$k - 1]; + } + next($matches); + } + } + } + + $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); + $ymid = $ymids[$this->lcs]; + for ($n = 0; $n < $nchunks - 1; $n++) { + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); + $y1 = $ymid[$n] + 1; + $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); + } + $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); + + return array($this->lcs, $seps); + } + + function _lcsPos($ypos) + { + $end = $this->lcs; + if ($end == 0 || $ypos > $this->seq[$end]) { + $this->seq[++$this->lcs] = $ypos; + $this->in_seq[$ypos] = 1; + return $this->lcs; + } + + $beg = 1; + while ($beg < $end) { + $mid = (int)(($beg + $end) / 2); + if ($ypos > $this->seq[$mid]) { + $beg = $mid + 1; + } else { + $end = $mid; + } + } + + assert($ypos != $this->seq[$end]); + + $this->in_seq[$this->seq[$end]] = false; + $this->seq[$end] = $ypos; + $this->in_seq[$ypos] = 1; + return $end; + } + + /** + * Finds LCS of two sequences. + * + * The results are recorded in the vectors $this->{x,y}changed[], by + * storing a 1 in the element for each line that is an insertion or + * deletion (ie. is not in the LCS). + * + * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. + * + * Note that XLIM, YLIM are exclusive bounds. All line numbers are + * origin-0 and discarded lines are not counted. + */ + function _compareseq ($xoff, $xlim, $yoff, $ylim) + { + /* Slide down the bottom initial diagonal. */ + while ($xoff < $xlim && $yoff < $ylim + && $this->xv[$xoff] == $this->yv[$yoff]) { + ++$xoff; + ++$yoff; + } + + /* Slide up the top initial diagonal. */ + while ($xlim > $xoff && $ylim > $yoff + && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { + --$xlim; + --$ylim; + } + + if ($xoff == $xlim || $yoff == $ylim) { + $lcs = 0; + } else { + /* This is ad hoc but seems to work well. $nchunks = + * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks = + * max(2,min(8,(int)$nchunks)); */ + $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; + list($lcs, $seps) + = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); + } + + if ($lcs == 0) { + /* X and Y sequences have no common subsequence: mark all + * changed. */ + while ($yoff < $ylim) { + $this->ychanged[$this->yind[$yoff++]] = 1; + } + while ($xoff < $xlim) { + $this->xchanged[$this->xind[$xoff++]] = 1; + } + } else { + /* Use the partitions to split this problem into subproblems. */ + reset($seps); + $pt1 = $seps[0]; + while ($pt2 = next($seps)) { + $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); + $pt1 = $pt2; + } + } + } + + /** + * Adjusts inserts/deletes of identical lines to join changes as much as + * possible. + * + * We do something when a run of changed lines include a line at one end + * and has an excluded, identical line at the other. We are free to + * choose which identical line is included. `compareseq' usually chooses + * the one at the beginning, but usually it is cleaner to consider the + * following identical line to be the "change". + * + * This is extracted verbatim from analyze.c (GNU diffutils-2.7). + */ + function _shiftBoundaries($lines, &$changed, $other_changed) + { + $i = 0; + $j = 0; + + assert(count($lines) == count($changed)); + $len = count($lines); + $other_len = count($other_changed); + + while (1) { + /* Scan forward to find the beginning of another run of + * changes. Also keep track of the corresponding point in the + * other file. + * + * Throughout this code, $i and $j are adjusted together so that + * the first $i elements of $changed and the first $j elements of + * $other_changed both contain the same number of zeros (unchanged + * lines). + * + * Furthermore, $j is always kept so that $j == $other_len or + * $other_changed[$j] == false. */ + while ($j < $other_len && $other_changed[$j]) { + $j++; + } + + while ($i < $len && ! $changed[$i]) { + assert($j < $other_len && ! $other_changed[$j]); + $i++; $j++; + while ($j < $other_len && $other_changed[$j]) { + $j++; + } + } + + if ($i == $len) { + break; + } + + $start = $i; + + /* Find the end of this run of changes. */ + while (++$i < $len && $changed[$i]) { + continue; + } + + do { + /* Record the length of this run of changes, so that we can + * later determine whether the run has grown. */ + $runlength = $i - $start; + + /* Move the changed region back, so long as the previous + * unchanged line matches the last changed one. This merges + * with previous changed regions. */ + while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { + $changed[--$start] = 1; + $changed[--$i] = false; + while ($start > 0 && $changed[$start - 1]) { + $start--; + } + assert($j > 0); + while ($other_changed[--$j]) { + continue; + } + assert($j >= 0 && !$other_changed[$j]); + } + + /* Set CORRESPONDING to the end of the changed run, at the + * last point where it corresponds to a changed run in the + * other file. CORRESPONDING == LEN means no such point has + * been found. */ + $corresponding = $j < $other_len ? $i : $len; + + /* Move the changed region forward, so long as the first + * changed line matches the following unchanged one. This + * merges with following changed regions. Do this second, so + * that if there are no merges, the changed region is moved + * forward as far as possible. */ + while ($i < $len && $lines[$start] == $lines[$i]) { + $changed[$start++] = false; + $changed[$i++] = 1; + while ($i < $len && $changed[$i]) { + $i++; + } + + assert($j < $other_len && ! $other_changed[$j]); + $j++; + if ($j < $other_len && $other_changed[$j]) { + $corresponding = $i; + while ($j < $other_len && $other_changed[$j]) { + $j++; + } + } + } + } while ($runlength != $i - $start); + + /* If possible, move the fully-merged run of changes back to a + * corresponding run in the other file. */ + while ($corresponding < $i) { + $changed[--$start] = 1; + $changed[--$i] = 0; + assert($j > 0); + while ($other_changed[--$j]) { + continue; + } + assert($j >= 0 && !$other_changed[$j]); + } + } + } + +} diff --git a/backend/wp-includes/Text/Diff/Engine/shell.php b/backend/wp-includes/Text/Diff/Engine/shell.php new file mode 100644 index 0000000..91c1843 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Engine/shell.php @@ -0,0 +1,162 @@ +<?php +/** + * Class used internally by Diff to actually compute the diffs. + * + * This class uses the Unix `diff` program via shell_exec to compute the + * differences between the two input arrays. + * + * Copyright 2007-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @author Milian Wolff <mail@milianw.de> + * @package Text_Diff + * @since 0.3.0 + */ +class Text_Diff_Engine_shell { + + /** + * Path to the diff executable + * + * @var string + */ + var $_diffCommand = 'diff'; + + /** + * Returns the array of differences. + * + * @param array $from_lines lines of text from old file + * @param array $to_lines lines of text from new file + * + * @return array all changes made (array with Text_Diff_Op_* objects) + */ + function diff($from_lines, $to_lines) + { + array_walk($from_lines, array('Text_Diff', 'trimNewlines')); + array_walk($to_lines, array('Text_Diff', 'trimNewlines')); + + $temp_dir = Text_Diff::_getTempDir(); + + // Execute gnu diff or similar to get a standard diff file. + $from_file = tempnam($temp_dir, 'Text_Diff'); + $to_file = tempnam($temp_dir, 'Text_Diff'); + $fp = fopen($from_file, 'w'); + fwrite($fp, implode("\n", $from_lines)); + fclose($fp); + $fp = fopen($to_file, 'w'); + fwrite($fp, implode("\n", $to_lines)); + fclose($fp); + $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file); + unlink($from_file); + unlink($to_file); + + if (is_null($diff)) { + // No changes were made + return array(new Text_Diff_Op_copy($from_lines)); + } + + $from_line_no = 1; + $to_line_no = 1; + $edits = array(); + + // Get changed lines by parsing something like: + // 0a1,2 + // 1,2c4,6 + // 1,5d6 + preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff, + $matches, PREG_SET_ORDER); + + foreach ($matches as $match) { + if (!isset($match[5])) { + // This paren is not set every time (see regex). + $match[5] = false; + } + + if ($match[3] == 'a') { + $from_line_no--; + } + + if ($match[3] == 'd') { + $to_line_no--; + } + + if ($from_line_no < $match[1] || $to_line_no < $match[4]) { + // copied lines + assert('$match[1] - $from_line_no == $match[4] - $to_line_no'); + array_push($edits, + new Text_Diff_Op_copy( + $this->_getLines($from_lines, $from_line_no, $match[1] - 1), + $this->_getLines($to_lines, $to_line_no, $match[4] - 1))); + } + + switch ($match[3]) { + case 'd': + // deleted lines + array_push($edits, + new Text_Diff_Op_delete( + $this->_getLines($from_lines, $from_line_no, $match[2]))); + $to_line_no++; + break; + + case 'c': + // changed lines + array_push($edits, + new Text_Diff_Op_change( + $this->_getLines($from_lines, $from_line_no, $match[2]), + $this->_getLines($to_lines, $to_line_no, $match[5]))); + break; + + case 'a': + // added lines + array_push($edits, + new Text_Diff_Op_add( + $this->_getLines($to_lines, $to_line_no, $match[5]))); + $from_line_no++; + break; + } + } + + if (!empty($from_lines)) { + // Some lines might still be pending. Add them as copied + array_push($edits, + new Text_Diff_Op_copy( + $this->_getLines($from_lines, $from_line_no, + $from_line_no + count($from_lines) - 1), + $this->_getLines($to_lines, $to_line_no, + $to_line_no + count($to_lines) - 1))); + } + + return $edits; + } + + /** + * Get lines from either the old or new text + * + * @access private + * + * @param array $text_lines Either $from_lines or $to_lines (passed by reference). + * @param int $line_no Current line number (passed by reference). + * @param int $end Optional end line, when we want to chop more + * than one line. + * + * @return array The chopped lines + */ + function _getLines(&$text_lines, &$line_no, $end = false) + { + if (!empty($end)) { + $lines = array(); + // We can shift even more + while ($line_no <= $end) { + array_push($lines, array_shift($text_lines)); + $line_no++; + } + } else { + $lines = array(array_shift($text_lines)); + $line_no++; + } + + return $lines; + } + +} diff --git a/backend/wp-includes/Text/Diff/Engine/string.php b/backend/wp-includes/Text/Diff/Engine/string.php new file mode 100644 index 0000000..76a1111 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Engine/string.php @@ -0,0 +1,248 @@ +<?php +/** + * Parses unified or context diffs output from eg. the diff utility. + * + * Example: + * <code> + * $patch = file_get_contents('example.patch'); + * $diff = new Text_Diff('string', array($patch)); + * $renderer = new Text_Diff_Renderer_inline(); + * echo $renderer->render($diff); + * </code> + * + * Copyright 2005 Örjan Persson <o@42mm.org> + * Copyright 2005-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @author Örjan Persson <o@42mm.org> + * @package Text_Diff + * @since 0.2.0 + */ +class Text_Diff_Engine_string { + + /** + * Parses a unified or context diff. + * + * First param contains the whole diff and the second can be used to force + * a specific diff type. If the second parameter is 'autodetect', the + * diff will be examined to find out which type of diff this is. + * + * @param string $diff The diff content. + * @param string $mode The diff mode of the content in $diff. One of + * 'context', 'unified', or 'autodetect'. + * + * @return array List of all diff operations. + */ + function diff($diff, $mode = 'autodetect') + { + // Detect line breaks. + $lnbr = "\n"; + if (strpos($diff, "\r\n") !== false) { + $lnbr = "\r\n"; + } elseif (strpos($diff, "\r") !== false) { + $lnbr = "\r"; + } + + // Make sure we have a line break at the EOF. + if (substr($diff, -strlen($lnbr)) != $lnbr) { + $diff .= $lnbr; + } + + if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { + return PEAR::raiseError('Type of diff is unsupported'); + } + + if ($mode == 'autodetect') { + $context = strpos($diff, '***'); + $unified = strpos($diff, '---'); + if ($context === $unified) { + return PEAR::raiseError('Type of diff could not be detected'); + } elseif ($context === false || $unified === false) { + $mode = $context !== false ? 'context' : 'unified'; + } else { + $mode = $context < $unified ? 'context' : 'unified'; + } + } + + // Split by new line and remove the diff header, if there is one. + $diff = explode($lnbr, $diff); + if (($mode == 'context' && strpos($diff[0], '***') === 0) || + ($mode == 'unified' && strpos($diff[0], '---') === 0)) { + array_shift($diff); + array_shift($diff); + } + + if ($mode == 'context') { + return $this->parseContextDiff($diff); + } else { + return $this->parseUnifiedDiff($diff); + } + } + + /** + * Parses an array containing the unified diff. + * + * @param array $diff Array of lines. + * + * @return array List of all diff operations. + */ + function parseUnifiedDiff($diff) + { + $edits = array(); + $end = count($diff) - 1; + for ($i = 0; $i < $end;) { + $diff1 = array(); + switch (substr($diff[$i], 0, 1)) { + case ' ': + do { + $diff1[] = substr($diff[$i], 1); + } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); + $edits[] = new Text_Diff_Op_copy($diff1); + break; + + case '+': + // get all new lines + do { + $diff1[] = substr($diff[$i], 1); + } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); + $edits[] = new Text_Diff_Op_add($diff1); + break; + + case '-': + // get changed or removed lines + $diff2 = array(); + do { + $diff1[] = substr($diff[$i], 1); + } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); + + while ($i < $end && substr($diff[$i], 0, 1) == '+') { + $diff2[] = substr($diff[$i++], 1); + } + if (count($diff2) == 0) { + $edits[] = new Text_Diff_Op_delete($diff1); + } else { + $edits[] = new Text_Diff_Op_change($diff1, $diff2); + } + break; + + default: + $i++; + break; + } + } + + return $edits; + } + + /** + * Parses an array containing the context diff. + * + * @param array $diff Array of lines. + * + * @return array List of all diff operations. + */ + function parseContextDiff(&$diff) + { + $edits = array(); + $i = $max_i = $j = $max_j = 0; + $end = count($diff) - 1; + while ($i < $end && $j < $end) { + while ($i >= $max_i && $j >= $max_j) { + // Find the boundaries of the diff output of the two files + for ($i = $j; + $i < $end && substr($diff[$i], 0, 3) == '***'; + $i++); + for ($max_i = $i; + $max_i < $end && substr($diff[$max_i], 0, 3) != '---'; + $max_i++); + for ($j = $max_i; + $j < $end && substr($diff[$j], 0, 3) == '---'; + $j++); + for ($max_j = $j; + $max_j < $end && substr($diff[$max_j], 0, 3) != '***'; + $max_j++); + } + + // find what hasn't been changed + $array = array(); + while ($i < $max_i && + $j < $max_j && + strcmp($diff[$i], $diff[$j]) == 0) { + $array[] = substr($diff[$i], 2); + $i++; + $j++; + } + + while ($i < $max_i && ($max_j-$j) <= 1) { + if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') { + break; + } + $array[] = substr($diff[$i++], 2); + } + + while ($j < $max_j && ($max_i-$i) <= 1) { + if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') { + break; + } + $array[] = substr($diff[$j++], 2); + } + if (count($array) > 0) { + $edits[] = new Text_Diff_Op_copy($array); + } + + if ($i < $max_i) { + $diff1 = array(); + switch (substr($diff[$i], 0, 1)) { + case '!': + $diff2 = array(); + do { + $diff1[] = substr($diff[$i], 2); + if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { + $diff2[] = substr($diff[$j++], 2); + } + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); + $edits[] = new Text_Diff_Op_change($diff1, $diff2); + break; + + case '+': + do { + $diff1[] = substr($diff[$i], 2); + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); + $edits[] = new Text_Diff_Op_add($diff1); + break; + + case '-': + do { + $diff1[] = substr($diff[$i], 2); + } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); + $edits[] = new Text_Diff_Op_delete($diff1); + break; + } + } + + if ($j < $max_j) { + $diff2 = array(); + switch (substr($diff[$j], 0, 1)) { + case '+': + do { + $diff2[] = substr($diff[$j++], 2); + } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); + $edits[] = new Text_Diff_Op_add($diff2); + break; + + case '-': + do { + $diff2[] = substr($diff[$j++], 2); + } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); + $edits[] = new Text_Diff_Op_delete($diff2); + break; + } + } + } + + return $edits; + } + +} diff --git a/backend/wp-includes/Text/Diff/Engine/xdiff.php b/backend/wp-includes/Text/Diff/Engine/xdiff.php new file mode 100644 index 0000000..02ce848 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Engine/xdiff.php @@ -0,0 +1,64 @@ +<?php +/** + * Class used internally by Diff to actually compute the diffs. + * + * This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff) + * to compute the differences between the two input arrays. + * + * Copyright 2004-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @author Jon Parise <jon@horde.org> + * @package Text_Diff + */ +class Text_Diff_Engine_xdiff { + + /** + */ + function diff($from_lines, $to_lines) + { + array_walk($from_lines, array('Text_Diff', 'trimNewlines')); + array_walk($to_lines, array('Text_Diff', 'trimNewlines')); + + /* Convert the two input arrays into strings for xdiff processing. */ + $from_string = implode("\n", $from_lines); + $to_string = implode("\n", $to_lines); + + /* Diff the two strings and convert the result to an array. */ + $diff = xdiff_string_diff($from_string, $to_string, count($to_lines)); + $diff = explode("\n", $diff); + + /* Walk through the diff one line at a time. We build the $edits + * array of diff operations by reading the first character of the + * xdiff output (which is in the "unified diff" format). + * + * Note that we don't have enough information to detect "changed" + * lines using this approach, so we can't add Text_Diff_Op_changed + * instances to the $edits array. The result is still perfectly + * valid, albeit a little less descriptive and efficient. */ + $edits = array(); + foreach ($diff as $line) { + if (!strlen($line)) { + continue; + } + switch ($line[0]) { + case ' ': + $edits[] = new Text_Diff_Op_copy(array(substr($line, 1))); + break; + + case '+': + $edits[] = new Text_Diff_Op_add(array(substr($line, 1))); + break; + + case '-': + $edits[] = new Text_Diff_Op_delete(array(substr($line, 1))); + break; + } + } + + return $edits; + } + +} diff --git a/backend/wp-includes/Text/Diff/Renderer.php b/backend/wp-includes/Text/Diff/Renderer.php new file mode 100644 index 0000000..712d985 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Renderer.php @@ -0,0 +1,242 @@ +<?php +/** + * A class to render Diffs in different formats. + * + * This class renders the diff in classic diff format. It is intended that + * this class be customized via inheritance, to obtain fancier outputs. + * + * Copyright 2004-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @package Text_Diff + */ +class Text_Diff_Renderer { + + /** + * Number of leading context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses may want to + * set this to other values. + */ + var $_leading_context_lines = 0; + + /** + * Number of trailing context "lines" to preserve. + * + * This should be left at zero for this class, but subclasses may want to + * set this to other values. + */ + var $_trailing_context_lines = 0; + + /** + * Constructor. + */ + function __construct( $params = array() ) + { + foreach ($params as $param => $value) { + $v = '_' . $param; + if (isset($this->$v)) { + $this->$v = $value; + } + } + } + + /** + * PHP4 constructor. + */ + public function Text_Diff_Renderer( $params = array() ) { + self::__construct( $params ); + } + + /** + * Get any renderer parameters. + * + * @return array All parameters of this renderer object. + */ + function getParams() + { + $params = array(); + foreach (get_object_vars($this) as $k => $v) { + if ($k[0] == '_') { + $params[substr($k, 1)] = $v; + } + } + + return $params; + } + + /** + * Renders a diff. + * + * @param Text_Diff $diff A Text_Diff object. + * + * @return string The formatted output. + */ + function render($diff) + { + $xi = $yi = 1; + $block = false; + $context = array(); + + $nlead = $this->_leading_context_lines; + $ntrail = $this->_trailing_context_lines; + + $output = $this->_startDiff(); + + $diffs = $diff->getDiff(); + foreach ($diffs as $i => $edit) { + /* If these are unchanged (copied) lines, and we want to keep + * leading or trailing context lines, extract them from the copy + * block. */ + if (is_a($edit, 'Text_Diff_Op_copy')) { + /* Do we have any diff blocks yet? */ + if (is_array($block)) { + /* How many lines to keep as context from the copy + * block. */ + $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail; + if (count($edit->orig) <= $keep) { + /* We have less lines in the block than we want for + * context => keep the whole block. */ + $block[] = $edit; + } else { + if ($ntrail) { + /* Create a new block with as many lines as we need + * for the trailing context. */ + $context = array_slice($edit->orig, 0, $ntrail); + $block[] = new Text_Diff_Op_copy($context); + } + /* @todo */ + $output .= $this->_block($x0, $ntrail + $xi - $x0, + $y0, $ntrail + $yi - $y0, + $block); + $block = false; + } + } + /* Keep the copy block as the context for the next block. */ + $context = $edit->orig; + } else { + /* Don't we have any diff blocks yet? */ + if (!is_array($block)) { + /* Extract context lines from the preceding copy block. */ + $context = array_slice($context, count($context) - $nlead); + $x0 = $xi - count($context); + $y0 = $yi - count($context); + $block = array(); + if ($context) { + $block[] = new Text_Diff_Op_copy($context); + } + } + $block[] = $edit; + } + + if ($edit->orig) { + $xi += count($edit->orig); + } + if ($edit->final) { + $yi += count($edit->final); + } + } + + if (is_array($block)) { + $output .= $this->_block($x0, $xi - $x0, + $y0, $yi - $y0, + $block); + } + + return $output . $this->_endDiff(); + } + + function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) + { + $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen)); + + foreach ($edits as $edit) { + switch (strtolower(get_class($edit))) { + case 'text_diff_op_copy': + $output .= $this->_context($edit->orig); + break; + + case 'text_diff_op_add': + $output .= $this->_added($edit->final); + break; + + case 'text_diff_op_delete': + $output .= $this->_deleted($edit->orig); + break; + + case 'text_diff_op_change': + $output .= $this->_changed($edit->orig, $edit->final); + break; + } + } + + return $output . $this->_endBlock(); + } + + function _startDiff() + { + return ''; + } + + function _endDiff() + { + return ''; + } + + function _blockHeader($xbeg, $xlen, $ybeg, $ylen) + { + if ($xlen > 1) { + $xbeg .= ',' . ($xbeg + $xlen - 1); + } + if ($ylen > 1) { + $ybeg .= ',' . ($ybeg + $ylen - 1); + } + + // this matches the GNU Diff behaviour + if ($xlen && !$ylen) { + $ybeg--; + } elseif (!$xlen) { + $xbeg--; + } + + return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg; + } + + function _startBlock($header) + { + return $header . "\n"; + } + + function _endBlock() + { + return ''; + } + + function _lines($lines, $prefix = ' ') + { + return $prefix . implode("\n$prefix", $lines) . "\n"; + } + + function _context($lines) + { + return $this->_lines($lines, ' '); + } + + function _added($lines) + { + return $this->_lines($lines, '> '); + } + + function _deleted($lines) + { + return $this->_lines($lines, '< '); + } + + function _changed($orig, $final) + { + return $this->_deleted($orig) . "---\n" . $this->_added($final); + } + +} diff --git a/backend/wp-includes/Text/Diff/Renderer/inline.php b/backend/wp-includes/Text/Diff/Renderer/inline.php new file mode 100644 index 0000000..392bd57 --- /dev/null +++ b/backend/wp-includes/Text/Diff/Renderer/inline.php @@ -0,0 +1,206 @@ +<?php +/** + * "Inline" diff renderer. + * + * Copyright 2004-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you did + * not receive this file, see http://opensource.org/licenses/lgpl-license.php. + * + * @author Ciprian Popovici + * @package Text_Diff + */ + +/** Text_Diff_Renderer */ + +// WP #7391 +require_once dirname(dirname(__FILE__)) . '/Renderer.php'; + +/** + * "Inline" diff renderer. + * + * This class renders diffs in the Wiki-style "inline" format. + * + * @author Ciprian Popovici + * @package Text_Diff + */ +class Text_Diff_Renderer_inline extends Text_Diff_Renderer { + + /** + * Number of leading context "lines" to preserve. + * + * @var integer + */ + var $_leading_context_lines = 10000; + + /** + * Number of trailing context "lines" to preserve. + * + * @var integer + */ + var $_trailing_context_lines = 10000; + + /** + * Prefix for inserted text. + * + * @var string + */ + var $_ins_prefix = '<ins>'; + + /** + * Suffix for inserted text. + * + * @var string + */ + var $_ins_suffix = '</ins>'; + + /** + * Prefix for deleted text. + * + * @var string + */ + var $_del_prefix = '<del>'; + + /** + * Suffix for deleted text. + * + * @var string + */ + var $_del_suffix = '</del>'; + + /** + * Header for each change block. + * + * @var string + */ + var $_block_header = ''; + + /** + * Whether to split down to character-level. + * + * @var boolean + */ + var $_split_characters = false; + + /** + * What are we currently splitting on? Used to recurse to show word-level + * or character-level changes. + * + * @var string + */ + var $_split_level = 'lines'; + + function _blockHeader($xbeg, $xlen, $ybeg, $ylen) + { + return $this->_block_header; + } + + function _startBlock($header) + { + return $header; + } + + function _lines($lines, $prefix = ' ', $encode = true) + { + if ($encode) { + array_walk($lines, array(&$this, '_encode')); + } + + if ($this->_split_level == 'lines') { + return implode("\n", $lines) . "\n"; + } else { + return implode('', $lines); + } + } + + function _added($lines) + { + array_walk($lines, array(&$this, '_encode')); + $lines[0] = $this->_ins_prefix . $lines[0]; + $lines[count($lines) - 1] .= $this->_ins_suffix; + return $this->_lines($lines, ' ', false); + } + + function _deleted($lines, $words = false) + { + array_walk($lines, array(&$this, '_encode')); + $lines[0] = $this->_del_prefix . $lines[0]; + $lines[count($lines) - 1] .= $this->_del_suffix; + return $this->_lines($lines, ' ', false); + } + + function _changed($orig, $final) + { + /* If we've already split on characters, just display. */ + if ($this->_split_level == 'characters') { + return $this->_deleted($orig) + . $this->_added($final); + } + + /* If we've already split on words, just display. */ + if ($this->_split_level == 'words') { + $prefix = ''; + while ($orig[0] !== false && $final[0] !== false && + substr($orig[0], 0, 1) == ' ' && + substr($final[0], 0, 1) == ' ') { + $prefix .= substr($orig[0], 0, 1); + $orig[0] = substr($orig[0], 1); + $final[0] = substr($final[0], 1); + } + return $prefix . $this->_deleted($orig) . $this->_added($final); + } + + $text1 = implode("\n", $orig); + $text2 = implode("\n", $final); + + /* Non-printing newline marker. */ + $nl = "\0"; + + if ($this->_split_characters) { + $diff = new Text_Diff('native', + array(preg_split('//', $text1), + preg_split('//', $text2))); + } else { + /* We want to split on word boundaries, but we need to preserve + * whitespace as well. Therefore we split on words, but include + * all blocks of whitespace in the wordlist. */ + $diff = new Text_Diff('native', + array($this->_splitOnWords($text1, $nl), + $this->_splitOnWords($text2, $nl))); + } + + /* Get the diff in inline format. */ + $renderer = new Text_Diff_Renderer_inline + (array_merge($this->getParams(), + array('split_level' => $this->_split_characters ? 'characters' : 'words'))); + + /* Run the diff and get the output. */ + return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; + } + + function _splitOnWords($string, $newlineEscape = "\n") + { + // Ignore \0; otherwise the while loop will never finish. + $string = str_replace("\0", '', $string); + + $words = array(); + $length = strlen($string); + $pos = 0; + + while ($pos < $length) { + // Eat a word with any preceding whitespace. + $spaces = strspn(substr($string, $pos), " \n"); + $nextpos = strcspn(substr($string, $pos + $spaces), " \n"); + $words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos)); + $pos += $spaces + $nextpos; + } + + return $words; + } + + function _encode(&$string) + { + $string = htmlspecialchars($string); + } + +} diff --git a/backend/wp-includes/admin-bar.php b/backend/wp-includes/admin-bar.php new file mode 100644 index 0000000..1be7034 --- /dev/null +++ b/backend/wp-includes/admin-bar.php @@ -0,0 +1,1052 @@ +<?php +/** + * Toolbar API: Top-level Toolbar functionality + * + * @package WordPress + * @subpackage Toolbar + * @since 3.1.0 + */ + +/** + * Instantiate the admin bar object and set it up as a global for access elsewhere. + * + * UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR. + * For that, use show_admin_bar(false) or the {@see 'show_admin_bar'} filter. + * + * @since 3.1.0 + * @access private + * + * @global WP_Admin_Bar $wp_admin_bar + * + * @return bool Whether the admin bar was successfully initialized. + */ +function _wp_admin_bar_init() { + global $wp_admin_bar; + + if ( ! is_admin_bar_showing() ) + return false; + + /* Load the admin bar class code ready for instantiation */ + require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); + + /* Instantiate the admin bar */ + + /** + * Filters the admin bar class to instantiate. + * + * @since 3.1.0 + * + * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. + */ + $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); + if ( class_exists( $admin_bar_class ) ) + $wp_admin_bar = new $admin_bar_class; + else + return false; + + $wp_admin_bar->initialize(); + $wp_admin_bar->add_menus(); + + return true; +} + +/** + * Renders the admin bar to the page based on the $wp_admin_bar->menu member var. + * + * This is called very late on the footer actions so that it will render after + * anything else being added to the footer. + * + * It includes the {@see 'admin_bar_menu'} action which should be used to hook in and + * add new menus to the admin bar. That way you can be sure that you are adding at most + * optimal point, right before the admin bar is rendered. This also gives you access to + * the `$post` global, among others. + * + * @since 3.1.0 + * + * @global WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_render() { + global $wp_admin_bar; + + if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) + return; + + /** + * Load all necessary admin bar items. + * + * This is the hook used to add, remove, or manipulate admin bar items. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference + */ + do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) ); + + /** + * Fires before the admin bar is rendered. + * + * @since 3.1.0 + */ + do_action( 'wp_before_admin_bar_render' ); + + $wp_admin_bar->render(); + + /** + * Fires after the admin bar is rendered. + * + * @since 3.1.0 + */ + do_action( 'wp_after_admin_bar_render' ); +} + +/** + * Add the WordPress logo menu. + * + * @since 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_wp_menu( $wp_admin_bar ) { + if ( current_user_can( 'read' ) ) { + $about_url = self_admin_url( 'about.php' ); + } elseif ( is_multisite() ) { + $about_url = get_dashboard_url( get_current_user_id(), 'about.php' ); + } else { + $about_url = false; + } + + $wp_logo_menu_args = array( + 'id' => 'wp-logo', + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>', + 'href' => $about_url, + ); + + // Set tabindex="0" to make sub menus accessible when no URL is available. + if ( ! $about_url ) { + $wp_logo_menu_args['meta'] = array( + 'tabindex' => 0, + ); + } + + $wp_admin_bar->add_menu( $wp_logo_menu_args ); + + if ( $about_url ) { + // Add "About WordPress" link + $wp_admin_bar->add_menu( array( + 'parent' => 'wp-logo', + 'id' => 'about', + 'title' => __('About WordPress'), + 'href' => $about_url, + ) ); + } + + // Add WordPress.org link + $wp_admin_bar->add_menu( array( + 'parent' => 'wp-logo-external', + 'id' => 'wporg', + 'title' => __('WordPress.org'), + 'href' => __('https://wordpress.org/'), + ) ); + + // Add codex link + $wp_admin_bar->add_menu( array( + 'parent' => 'wp-logo-external', + 'id' => 'documentation', + 'title' => __('Documentation'), + 'href' => __('https://codex.wordpress.org/'), + ) ); + + // Add forums link + $wp_admin_bar->add_menu( array( + 'parent' => 'wp-logo-external', + 'id' => 'support-forums', + 'title' => __('Support Forums'), + 'href' => __('https://wordpress.org/support/'), + ) ); + + // Add feedback link + $wp_admin_bar->add_menu( array( + 'parent' => 'wp-logo-external', + 'id' => 'feedback', + 'title' => __('Feedback'), + 'href' => __('https://wordpress.org/support/forum/requests-and-feedback'), + ) ); +} + +/** + * Add the sidebar toggle button. + * + * @since 3.8.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) { + if ( is_admin() ) { + $wp_admin_bar->add_menu( array( + 'id' => 'menu-toggle', + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>', + 'href' => '#', + ) ); + } +} + +/** + * Add the "My Account" item. + * + * @since 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_my_account_item( $wp_admin_bar ) { + $user_id = get_current_user_id(); + $current_user = wp_get_current_user(); + + if ( ! $user_id ) + return; + + if ( current_user_can( 'read' ) ) { + $profile_url = get_edit_profile_url( $user_id ); + } elseif ( is_multisite() ) { + $profile_url = get_dashboard_url( $user_id, 'profile.php' ); + } else { + $profile_url = false; + } + + $avatar = get_avatar( $user_id, 26 ); + /* translators: %s: current user's display name */ + $howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' ); + $class = empty( $avatar ) ? '' : 'with-avatar'; + + $wp_admin_bar->add_menu( array( + 'id' => 'my-account', + 'parent' => 'top-secondary', + 'title' => $howdy . $avatar, + 'href' => $profile_url, + 'meta' => array( + 'class' => $class, + ), + ) ); +} + +/** + * Add the "My Account" submenu items. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_my_account_menu( $wp_admin_bar ) { + $user_id = get_current_user_id(); + $current_user = wp_get_current_user(); + + if ( ! $user_id ) + return; + + if ( current_user_can( 'read' ) ) { + $profile_url = get_edit_profile_url( $user_id ); + } elseif ( is_multisite() ) { + $profile_url = get_dashboard_url( $user_id, 'profile.php' ); + } else { + $profile_url = false; + } + + $wp_admin_bar->add_group( array( + 'parent' => 'my-account', + 'id' => 'user-actions', + ) ); + + $user_info = get_avatar( $user_id, 64 ); + $user_info .= "<span class='display-name'>{$current_user->display_name}</span>"; + + if ( $current_user->display_name !== $current_user->user_login ) + $user_info .= "<span class='username'>{$current_user->user_login}</span>"; + + $wp_admin_bar->add_menu( array( + 'parent' => 'user-actions', + 'id' => 'user-info', + 'title' => $user_info, + 'href' => $profile_url, + 'meta' => array( + 'tabindex' => -1, + ), + ) ); + + if ( false !== $profile_url ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'user-actions', + 'id' => 'edit-profile', + 'title' => __( 'Edit My Profile' ), + 'href' => $profile_url, + ) ); + } + + $wp_admin_bar->add_menu( array( + 'parent' => 'user-actions', + 'id' => 'logout', + 'title' => __( 'Log Out' ), + 'href' => wp_logout_url(), + ) ); +} + +/** + * Add the "Site Name" menu. + * + * @since 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_site_menu( $wp_admin_bar ) { + // Don't show for logged out users. + if ( ! is_user_logged_in() ) + return; + + // Show only when the user is a member of this site, or they're a super admin. + if ( ! is_user_member_of_blog() && ! current_user_can( 'manage_network' ) ) { + return; + } + + $blogname = get_bloginfo('name'); + + if ( ! $blogname ) { + $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); + } + + if ( is_network_admin() ) { + /* translators: %s: site name */ + $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_network()->site_name ) ); + } elseif ( is_user_admin() ) { + /* translators: %s: site name */ + $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_network()->site_name ) ); + } + + $title = wp_html_excerpt( $blogname, 40, '…' ); + + $wp_admin_bar->add_menu( array( + 'id' => 'site-name', + 'title' => $title, + 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), + ) ); + + // Create submenu items. + + if ( is_admin() ) { + // Add an option to visit the site. + $wp_admin_bar->add_menu( array( + 'parent' => 'site-name', + 'id' => 'view-site', + 'title' => __( 'Visit Site' ), + 'href' => home_url( '/' ), + ) ); + + if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'site-name', + 'id' => 'edit-site', + 'title' => __( 'Edit Site' ), + 'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ), + ) ); + } + + } else if ( current_user_can( 'read' ) ) { + // We're on the front end, link to the Dashboard. + $wp_admin_bar->add_menu( array( + 'parent' => 'site-name', + 'id' => 'dashboard', + 'title' => __( 'Dashboard' ), + 'href' => admin_url(), + ) ); + + // Add the appearance submenu items. + wp_admin_bar_appearance_menu( $wp_admin_bar ); + } +} + +/** + * Adds the "Customize" link to the Toolbar. + * + * @since 4.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. + * @global WP_Customize_Manager $wp_customize + */ +function wp_admin_bar_customize_menu( $wp_admin_bar ) { + global $wp_customize; + + // Don't show for users who can't access the customizer or when in the admin. + if ( ! current_user_can( 'customize' ) || is_admin() ) { + return; + } + + // Don't show if the user cannot edit a given customize_changeset post currently being previewed. + if ( is_customize_preview() && $wp_customize->changeset_post_id() && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) { + return; + } + + $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + if ( is_customize_preview() && $wp_customize->changeset_uuid() ) { + $current_url = remove_query_arg( 'customize_changeset_uuid', $current_url ); + } + + $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); + if ( is_customize_preview() ) { + $customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $customize_url ); + } + + $wp_admin_bar->add_menu( array( + 'id' => 'customize', + 'title' => __( 'Customize' ), + 'href' => $customize_url, + 'meta' => array( + 'class' => 'hide-if-no-customize', + ), + ) ); + add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); +} + +/** + * Add the "My Sites/[Site Name]" menu and all submenus. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { + // Don't show for logged out users or single site mode. + if ( ! is_user_logged_in() || ! is_multisite() ) + return; + + // Show only when the user has at least one site, or they're a super admin. + if ( count( $wp_admin_bar->user->blogs ) < 1 && ! current_user_can( 'manage_network' ) ) { + return; + } + + if ( $wp_admin_bar->user->active_blog ) { + $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ); + } else { + $my_sites_url = admin_url( 'my-sites.php' ); + } + + $wp_admin_bar->add_menu( array( + 'id' => 'my-sites', + 'title' => __( 'My Sites' ), + 'href' => $my_sites_url, + ) ); + + if ( current_user_can( 'manage_network' ) ) { + $wp_admin_bar->add_group( array( + 'parent' => 'my-sites', + 'id' => 'my-sites-super-admin', + ) ); + + $wp_admin_bar->add_menu( array( + 'parent' => 'my-sites-super-admin', + 'id' => 'network-admin', + 'title' => __('Network Admin'), + 'href' => network_admin_url(), + ) ); + + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-d', + 'title' => __( 'Dashboard' ), + 'href' => network_admin_url(), + ) ); + + if ( current_user_can( 'manage_sites' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-s', + 'title' => __( 'Sites' ), + 'href' => network_admin_url( 'sites.php' ), + ) ); + } + + if ( current_user_can( 'manage_network_users' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-u', + 'title' => __( 'Users' ), + 'href' => network_admin_url( 'users.php' ), + ) ); + } + + if ( current_user_can( 'manage_network_themes' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-t', + 'title' => __( 'Themes' ), + 'href' => network_admin_url( 'themes.php' ), + ) ); + } + + if ( current_user_can( 'manage_network_plugins' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-p', + 'title' => __( 'Plugins' ), + 'href' => network_admin_url( 'plugins.php' ), + ) ); + } + + if ( current_user_can( 'manage_network_options' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'network-admin', + 'id' => 'network-admin-o', + 'title' => __( 'Settings' ), + 'href' => network_admin_url( 'settings.php' ), + ) ); + } + } + + // Add site links + $wp_admin_bar->add_group( array( + 'parent' => 'my-sites', + 'id' => 'my-sites-list', + 'meta' => array( + 'class' => current_user_can( 'manage_network' ) ? 'ab-sub-secondary' : '', + ), + ) ); + + foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { + switch_to_blog( $blog->userblog_id ); + + $blavatar = '<div class="blavatar"></div>'; + + $blogname = $blog->blogname; + + if ( ! $blogname ) { + $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); + } + + $menu_id = 'blog-' . $blog->userblog_id; + + if ( current_user_can( 'read' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'my-sites-list', + 'id' => $menu_id, + 'title' => $blavatar . $blogname, + 'href' => admin_url(), + ) ); + + $wp_admin_bar->add_menu( array( + 'parent' => $menu_id, + 'id' => $menu_id . '-d', + 'title' => __( 'Dashboard' ), + 'href' => admin_url(), + ) ); + } else { + $wp_admin_bar->add_menu( array( + 'parent' => 'my-sites-list', + 'id' => $menu_id, + 'title' => $blavatar . $blogname, + 'href' => home_url(), + ) ); + } + + if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => $menu_id, + 'id' => $menu_id . '-n', + 'title' => __( 'New Post' ), + 'href' => admin_url( 'post-new.php' ), + ) ); + } + + if ( current_user_can( 'edit_posts' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => $menu_id, + 'id' => $menu_id . '-c', + 'title' => __( 'Manage Comments' ), + 'href' => admin_url( 'edit-comments.php' ), + ) ); + } + + $wp_admin_bar->add_menu( array( + 'parent' => $menu_id, + 'id' => $menu_id . '-v', + 'title' => __( 'Visit Site' ), + 'href' => home_url( '/' ), + ) ); + + restore_current_blog(); + } +} + +/** + * Provide a shortlink. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { + $short = wp_get_shortlink( 0, 'query' ); + $id = 'get-shortlink'; + + if ( empty( $short ) ) + return; + + $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />'; + + $wp_admin_bar->add_menu( array( + 'id' => $id, + 'title' => __( 'Shortlink' ), + 'href' => $short, + 'meta' => array( 'html' => $html ), + ) ); +} + +/** + * Provide an edit link for posts and terms. + * + * @since 3.1.0 + * + * @global WP_Term $tag + * @global WP_Query $wp_the_query + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_edit_menu( $wp_admin_bar ) { + global $tag, $wp_the_query, $user_id; + + if ( is_admin() ) { + $current_screen = get_current_screen(); + $post = get_post(); + + if ( 'post' == $current_screen->base + && 'add' != $current_screen->action + && ( $post_type_object = get_post_type_object( $post->post_type ) ) + && current_user_can( 'read_post', $post->ID ) + && ( $post_type_object->public ) + && ( $post_type_object->show_in_admin_bar ) ) + { + if ( 'draft' == $post->post_status ) { + $preview_link = get_preview_post_link( $post ); + $wp_admin_bar->add_menu( array( + 'id' => 'preview', + 'title' => $post_type_object->labels->view_item, + 'href' => esc_url( $preview_link ), + 'meta' => array( 'target' => 'wp-preview-' . $post->ID ), + ) ); + } else { + $wp_admin_bar->add_menu( array( + 'id' => 'view', + 'title' => $post_type_object->labels->view_item, + 'href' => get_permalink( $post->ID ) + ) ); + } + } elseif ( 'edit' == $current_screen->base + && ( $post_type_object = get_post_type_object( $current_screen->post_type ) ) + && ( $post_type_object->public ) + && ( $post_type_object->show_in_admin_bar ) + && ( get_post_type_archive_link( $post_type_object->name ) ) + && ! ( 'post' === $post_type_object->name && 'posts' === get_option( 'show_on_front' ) ) ) + { + $wp_admin_bar->add_node( array( + 'id' => 'archive', + 'title' => $post_type_object->labels->view_items, + 'href' => get_post_type_archive_link( $current_screen->post_type ) + ) ); + } elseif ( 'term' == $current_screen->base + && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) + && ( $tax = get_taxonomy( $tag->taxonomy ) ) + && $tax->public ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'view', + 'title' => $tax->labels->view_item, + 'href' => get_term_link( $tag ) + ) ); + } elseif ( 'user-edit' == $current_screen->base + && isset( $user_id ) + && ( $user_object = get_userdata( $user_id ) ) + && $user_object->exists() + && $view_link = get_author_posts_url( $user_object->ID ) ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'view', + 'title' => __( 'View User' ), + 'href' => $view_link, + ) ); + } + } else { + $current_object = $wp_the_query->get_queried_object(); + + if ( empty( $current_object ) ) + return; + + if ( ! empty( $current_object->post_type ) + && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) + && current_user_can( 'edit_post', $current_object->ID ) + && $post_type_object->show_in_admin_bar + && $edit_post_link = get_edit_post_link( $current_object->ID ) ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'edit', + 'title' => $post_type_object->labels->edit_item, + 'href' => $edit_post_link + ) ); + } elseif ( ! empty( $current_object->taxonomy ) + && ( $tax = get_taxonomy( $current_object->taxonomy ) ) + && current_user_can( 'edit_term', $current_object->term_id ) + && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'edit', + 'title' => $tax->labels->edit_item, + 'href' => $edit_term_link + ) ); + } elseif ( is_a( $current_object, 'WP_User' ) + && current_user_can( 'edit_user', $current_object->ID ) + && $edit_user_link = get_edit_user_link( $current_object->ID ) ) + { + $wp_admin_bar->add_menu( array( + 'id' => 'edit', + 'title' => __( 'Edit User' ), + 'href' => $edit_user_link, + ) ); + } + } +} + +/** + * Add "Add New" menu. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_new_content_menu( $wp_admin_bar ) { + $actions = array(); + + $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); + + if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) + $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); + + if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) + $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); + + if ( current_user_can( 'manage_links' ) ) + $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); + + if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) + $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); + + unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); + + // Add any additional custom post types. + foreach ( $cpts as $cpt ) { + if ( ! current_user_can( $cpt->cap->create_posts ) ) + continue; + + $key = 'post-new.php?post_type=' . $cpt->name; + $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); + } + // Avoid clash with parent node and a 'content' post type. + if ( isset( $actions['post-new.php?post_type=content'] ) ) + $actions['post-new.php?post_type=content'][1] = 'add-new-content'; + + if ( current_user_can( 'create_users' ) || ( is_multisite() && current_user_can( 'promote_users' ) ) ) { + $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); + } + + if ( ! $actions ) + return; + + $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>'; + + $wp_admin_bar->add_menu( array( + 'id' => 'new-content', + 'title' => $title, + 'href' => admin_url( current( array_keys( $actions ) ) ), + ) ); + + foreach ( $actions as $link => $action ) { + list( $title, $id ) = $action; + + $wp_admin_bar->add_menu( array( + 'parent' => 'new-content', + 'id' => $id, + 'title' => $title, + 'href' => admin_url( $link ) + ) ); + } +} + +/** + * Add edit comments link with awaiting moderation count bubble. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_comments_menu( $wp_admin_bar ) { + if ( !current_user_can('edit_posts') ) + return; + + $awaiting_mod = wp_count_comments(); + $awaiting_mod = $awaiting_mod->moderated; + $awaiting_text = sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ); + + $icon = '<span class="ab-icon"></span>'; + $title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>'; + $title .= '<span class="screen-reader-text">' . $awaiting_text . '</span>'; + + $wp_admin_bar->add_menu( array( + 'id' => 'comments', + 'title' => $icon . $title, + 'href' => admin_url('edit-comments.php'), + ) ); +} + +/** + * Add appearance submenu items to the "Site Name" menu. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_appearance_menu( $wp_admin_bar ) { + $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) ); + + if ( current_user_can( 'switch_themes' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'themes', + 'title' => __( 'Themes' ), + 'href' => admin_url( 'themes.php' ), + ) ); + } + + if ( ! current_user_can( 'edit_theme_options' ) ) { + return; + } + + if ( current_theme_supports( 'widgets' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'widgets', + 'title' => __( 'Widgets' ), + 'href' => admin_url( 'widgets.php' ), + ) ); + } + + if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) + $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); + + if ( current_theme_supports( 'custom-background' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'background', + 'title' => __( 'Background' ), + 'href' => admin_url( 'themes.php?page=custom-background' ), + 'meta' => array( + 'class' => 'hide-if-customize', + ), + ) ); + } + + if ( current_theme_supports( 'custom-header' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'header', + 'title' => __( 'Header' ), + 'href' => admin_url( 'themes.php?page=custom-header' ), + 'meta' => array( + 'class' => 'hide-if-customize', + ), + ) ); + } + +} + +/** + * Provide an update link if theme/plugin/core updates are available. + * + * @since 3.1.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_updates_menu( $wp_admin_bar ) { + + $update_data = wp_get_update_data(); + + if ( !$update_data['counts']['total'] ) + return; + + $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; + $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; + + $wp_admin_bar->add_menu( array( + 'id' => 'updates', + 'title' => $title, + 'href' => network_admin_url( 'update-core.php' ), + 'meta' => array( + 'title' => $update_data['title'], + ), + ) ); +} + +/** + * Add search form. + * + * @since 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_search_menu( $wp_admin_bar ) { + if ( is_admin() ) + return; + + $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">'; + $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />'; + $form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>'; + $form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>'; + $form .= '</form>'; + + $wp_admin_bar->add_menu( array( + 'parent' => 'top-secondary', + 'id' => 'search', + 'title' => $form, + 'meta' => array( + 'class' => 'admin-bar-search', + 'tabindex' => -1, + ) + ) ); +} + +/** + * Add secondary menus. + * + * @since 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) { + $wp_admin_bar->add_group( array( + 'id' => 'top-secondary', + 'meta' => array( + 'class' => 'ab-top-secondary', + ), + ) ); + + $wp_admin_bar->add_group( array( + 'parent' => 'wp-logo', + 'id' => 'wp-logo-external', + 'meta' => array( + 'class' => 'ab-sub-secondary', + ), + ) ); +} + +/** + * Style and scripts for the admin bar. + * + * @since 3.1.0 + */ +function wp_admin_bar_header() { ?> +<style type="text/css" media="print">#wpadminbar { display:none; }</style> +<?php +} + +/** + * Default admin bar callback. + * + * @since 3.1.0 + */ +function _admin_bar_bump_cb() { ?> +<style type="text/css" media="screen"> + html { margin-top: 32px !important; } + * html body { margin-top: 32px !important; } + @media screen and ( max-width: 782px ) { + html { margin-top: 46px !important; } + * html body { margin-top: 46px !important; } + } +</style> +<?php +} + +/** + * Sets the display status of the admin bar. + * + * This can be called immediately upon plugin load. It does not need to be called + * from a function hooked to the {@see 'init'} action. + * + * @since 3.1.0 + * + * @global bool $show_admin_bar + * + * @param bool $show Whether to allow the admin bar to show. + */ +function show_admin_bar( $show ) { + global $show_admin_bar; + $show_admin_bar = (bool) $show; +} + +/** + * Determine whether the admin bar should be showing. + * + * @since 3.1.0 + * + * @global bool $show_admin_bar + * @global string $pagenow + * + * @return bool Whether the admin bar should be showing. + */ +function is_admin_bar_showing() { + global $show_admin_bar, $pagenow; + + // For all these types of requests, we never want an admin bar. + if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) + return false; + + if ( is_embed() ) { + return false; + } + + // Integrated into the admin. + if ( is_admin() ) + return true; + + if ( ! isset( $show_admin_bar ) ) { + if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) { + $show_admin_bar = false; + } else { + $show_admin_bar = _get_admin_bar_pref(); + } + } + + /** + * Filters whether to show the admin bar. + * + * Returning false to this hook is the recommended way to hide the admin bar. + * The user's display preference is used for logged in users. + * + * @since 3.1.0 + * + * @param bool $show_admin_bar Whether the admin bar should be shown. Default false. + */ + $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar ); + + return $show_admin_bar; +} + +/** + * Retrieve the admin bar display preference of a user. + * + * @since 3.1.0 + * @access private + * + * @param string $context Context of this preference check. Defaults to 'front'. The 'admin' + * preference is no longer used. + * @param int $user Optional. ID of the user to check, defaults to 0 for current user. + * @return bool Whether the admin bar should be showing for this user. + */ +function _get_admin_bar_pref( $context = 'front', $user = 0 ) { + $pref = get_user_option( "show_admin_bar_{$context}", $user ); + if ( false === $pref ) + return true; + + return 'true' === $pref; +} diff --git a/backend/wp-includes/atomlib.php b/backend/wp-includes/atomlib.php new file mode 100644 index 0000000..c326de2 --- /dev/null +++ b/backend/wp-includes/atomlib.php @@ -0,0 +1,394 @@ +<?php +/** + * Atom Syndication Format PHP Library + * + * @package AtomLib + * @link http://code.google.com/p/phpatomlib/ + * + * @author Elias Torres <elias@torrez.us> + * @version 0.4 + * @since 2.3.0 + */ + +/** + * Structure that store common Atom Feed Properties + * + * @package AtomLib + */ +class AtomFeed { + /** + * Stores Links + * @var array + * @access public + */ + var $links = array(); + /** + * Stores Categories + * @var array + * @access public + */ + var $categories = array(); + /** + * Stores Entries + * + * @var array + * @access public + */ + var $entries = array(); +} + +/** + * Structure that store Atom Entry Properties + * + * @package AtomLib + */ +class AtomEntry { + /** + * Stores Links + * @var array + * @access public + */ + var $links = array(); + /** + * Stores Categories + * @var array + * @access public + */ + var $categories = array(); +} + +/** + * AtomLib Atom Parser API + * + * @package AtomLib + */ +class AtomParser { + + var $NS = 'http://www.w3.org/2005/Atom'; + var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); + var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft'); + + var $debug = false; + + var $depth = 0; + var $indent = 2; + var $in_content; + var $ns_contexts = array(); + var $ns_decls = array(); + var $content_ns_decls = array(); + var $content_ns_contexts = array(); + var $is_xhtml = false; + var $is_html = false; + var $is_text = true; + var $skipped_div = false; + + var $FILE = "php://input"; + + var $feed; + var $current; + + /** + * PHP5 constructor. + */ + function __construct() { + + $this->feed = new AtomFeed(); + $this->current = null; + $this->map_attrs_func = array( __CLASS__, 'map_attrs' ); + $this->map_xmlns_func = array( __CLASS__, 'map_xmlns' ); + } + + /** + * PHP4 constructor. + */ + public function AtomParser() { + self::__construct(); + } + + /** + * Map attributes to key="val" + * + * @param string $k Key + * @param string $v Value + * @return string + */ + public static function map_attrs($k, $v) { + return "$k=\"$v\""; + } + + /** + * Map XML namespace to string. + * + * @param indexish $p XML Namespace element index + * @param array $n Two-element array pair. [ 0 => {namespace}, 1 => {url} ] + * @return string 'xmlns="{url}"' or 'xmlns:{namespace}="{url}"' + */ + public static function map_xmlns($p, $n) { + $xd = "xmlns"; + if( 0 < strlen($n[0]) ) { + $xd .= ":{$n[0]}"; + } + return "{$xd}=\"{$n[1]}\""; + } + + function _p($msg) { + if($this->debug) { + print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n"; + } + } + + function error_handler($log_level, $log_text, $error_file, $error_line) { + $this->error = $log_text; + } + + function parse() { + + set_error_handler(array(&$this, 'error_handler')); + + array_unshift($this->ns_contexts, array()); + + if ( ! function_exists( 'xml_parser_create_ns' ) ) { + trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); + return false; + } + + $parser = xml_parser_create_ns(); + xml_set_object($parser, $this); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); + xml_set_character_data_handler($parser, "cdata"); + xml_set_default_handler($parser, "_default"); + xml_set_start_namespace_decl_handler($parser, "start_ns"); + xml_set_end_namespace_decl_handler($parser, "end_ns"); + + $this->content = ''; + + $ret = true; + + $fp = fopen($this->FILE, "r"); + while ($data = fread($fp, 4096)) { + if($this->debug) $this->content .= $data; + + if(!xml_parse($parser, $data, feof($fp))) { + /* translators: 1: error message, 2: line number */ + trigger_error(sprintf(__('XML Error: %1$s at line %2$s')."\n", + xml_error_string(xml_get_error_code($parser)), + xml_get_current_line_number($parser))); + $ret = false; + break; + } + } + fclose($fp); + + xml_parser_free($parser); + + restore_error_handler(); + + return $ret; + } + + function start_element($parser, $name, $attrs) { + + $tag = array_pop(explode(":", $name)); + + switch($name) { + case $this->NS . ':feed': + $this->current = $this->feed; + break; + case $this->NS . ':entry': + $this->current = new AtomEntry(); + break; + }; + + $this->_p("start_element('$name')"); + #$this->_p(print_r($this->ns_contexts,true)); + #$this->_p('current(' . $this->current . ')'); + + array_unshift($this->ns_contexts, $this->ns_decls); + + $this->depth++; + + if(!empty($this->in_content)) { + + $this->content_ns_decls = array(); + + if($this->is_html || $this->is_text) + trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup."); + + $attrs_prefix = array(); + + // resolve prefixes for attributes + foreach($attrs as $key => $value) { + $with_prefix = $this->ns_to_prefix($key, true); + $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value); + } + + $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); + if(strlen($attrs_str) > 0) { + $attrs_str = " " . $attrs_str; + } + + $with_prefix = $this->ns_to_prefix($name); + + if(!$this->is_declared_content_ns($with_prefix[0])) { + array_push($this->content_ns_decls, $with_prefix[0]); + } + + $xmlns_str = ''; + if(count($this->content_ns_decls) > 0) { + array_unshift($this->content_ns_contexts, $this->content_ns_decls); + $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0]))); + if(strlen($xmlns_str) > 0) { + $xmlns_str = " " . $xmlns_str; + } + } + + array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">")); + + } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { + $this->in_content = array(); + $this->is_xhtml = $attrs['type'] == 'xhtml'; + $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html'; + $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text'; + $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type'])); + + if(in_array('src',array_keys($attrs))) { + $this->current->$tag = $attrs; + } else { + array_push($this->in_content, array($tag,$this->depth, $type)); + } + } else if($tag == 'link') { + array_push($this->current->links, $attrs); + } else if($tag == 'category') { + array_push($this->current->categories, $attrs); + } + + $this->ns_decls = array(); + } + + function end_element($parser, $name) { + + $tag = array_pop(explode(":", $name)); + + $ccount = count($this->in_content); + + # if we are *in* content, then let's proceed to serialize it + if(!empty($this->in_content)) { + # if we are ending the original content element + # then let's finalize the content + if($this->in_content[0][0] == $tag && + $this->in_content[0][1] == $this->depth) { + $origtype = $this->in_content[0][2]; + array_shift($this->in_content); + $newcontent = array(); + foreach($this->in_content as $c) { + if(count($c) == 3) { + array_push($newcontent, $c[2]); + } else { + if($this->is_xhtml || $this->is_text) { + array_push($newcontent, $this->xml_escape($c)); + } else { + array_push($newcontent, $c); + } + } + } + if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) { + $this->current->$tag = array($origtype, join('',$newcontent)); + } else { + $this->current->$tag = join('',$newcontent); + } + $this->in_content = array(); + } else if($this->in_content[$ccount-1][0] == $tag && + $this->in_content[$ccount-1][1] == $this->depth) { + $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>"; + } else { + # else, just finalize the current element's content + $endtag = $this->ns_to_prefix($name); + array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>")); + } + } + + array_shift($this->ns_contexts); + + $this->depth--; + + if($name == ($this->NS . ':entry')) { + array_push($this->feed->entries, $this->current); + $this->current = null; + } + + $this->_p("end_element('$name')"); + } + + function start_ns($parser, $prefix, $uri) { + $this->_p("starting: " . $prefix . ":" . $uri); + array_push($this->ns_decls, array($prefix,$uri)); + } + + function end_ns($parser, $prefix) { + $this->_p("ending: #" . $prefix . "#"); + } + + function cdata($parser, $data) { + $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#"); + if(!empty($this->in_content)) { + array_push($this->in_content, $data); + } + } + + function _default($parser, $data) { + # when does this gets called? + } + + + function ns_to_prefix($qname, $attr=false) { + # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div') + $components = explode(":", $qname); + + # grab the last one (e.g 'div') + $name = array_pop($components); + + if(!empty($components)) { + # re-join back the namespace component + $ns = join(":",$components); + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if($mapping[1] == $ns && strlen($mapping[0]) > 0) { + return array($mapping, "$mapping[0]:$name"); + } + } + } + } + + if($attr) { + return array(null, $name); + } else { + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if(strlen($mapping[0]) == 0) { + return array($mapping, $name); + } + } + } + } + } + + function is_declared_content_ns($new_mapping) { + foreach($this->content_ns_contexts as $context) { + foreach($context as $mapping) { + if($new_mapping == $mapping) { + return true; + } + } + } + return false; + } + + function xml_escape($string) + { + return str_replace(array('&','"',"'",'<','>'), + array('&','"',''','<','>'), + $string ); + } +} diff --git a/backend/wp-includes/author-template.php b/backend/wp-includes/author-template.php new file mode 100644 index 0000000..4baf681 --- /dev/null +++ b/backend/wp-includes/author-template.php @@ -0,0 +1,543 @@ +<?php +/** + * Author Template functions for use in themes. + * + * These functions must be used within the WordPress Loop. + * + * @link https://codex.wordpress.org/Author_Templates + * + * @package WordPress + * @subpackage Template + */ + +/** + * Retrieve the author of the current post. + * + * @since 1.5.0 + * + * @global object $authordata The current author's DB object. + * + * @param string $deprecated Deprecated. + * @return string|null The author's display name. + */ +function get_the_author($deprecated = '') { + global $authordata; + + if ( !empty( $deprecated ) ) + _deprecated_argument( __FUNCTION__, '2.1.0' ); + + /** + * Filters the display name of the current post's author. + * + * @since 2.9.0 + * + * @param string $authordata->display_name The author's display name. + */ + return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null); +} + +/** + * Display the name of the author of the current post. + * + * The behavior of this function is based off of old functionality predating + * get_the_author(). This function is not deprecated, but is designed to echo + * the value from get_the_author() and as an result of any old theme that might + * still use the old behavior will also pass the value from get_the_author(). + * + * The normal, expected behavior of this function is to echo the author and not + * return it. However, backward compatibility has to be maintained. + * + * @since 0.71 + * @see get_the_author() + * @link https://codex.wordpress.org/Template_Tags/the_author + * + * @param string $deprecated Deprecated. + * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it. + * @return string|null The author's display name, from get_the_author(). + */ +function the_author( $deprecated = '', $deprecated_echo = true ) { + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __FUNCTION__, '2.1.0' ); + } + + if ( true !== $deprecated_echo ) { + _deprecated_argument( __FUNCTION__, '1.5.0', + /* translators: %s: get_the_author() */ + sprintf( __( 'Use %s instead if you do not want the value echoed.' ), + '<code>get_the_author()</code>' + ) + ); + } + + if ( $deprecated_echo ) { + echo get_the_author(); + } + + return get_the_author(); +} + +/** + * Retrieve the author who last edited the current post. + * + * @since 2.8.0 + * + * @return string|void The author's display name. + */ +function get_the_modified_author() { + if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) { + $last_user = get_userdata($last_id); + + /** + * Filters the display name of the author who last edited the current post. + * + * @since 2.8.0 + * + * @param string $last_user->display_name The author's display name. + */ + return apply_filters('the_modified_author', $last_user->display_name); + } +} + +/** + * Display the name of the author who last edited the current post, + * if the author's ID is available. + * + * @since 2.8.0 + * + * @see get_the_author() + */ +function the_modified_author() { + echo get_the_modified_author(); +} + +/** + * Retrieves the requested data of the author of the current post. + * + * Valid values for the `$field` parameter include: + * + * - admin_color + * - aim + * - comment_shortcuts + * - description + * - display_name + * - first_name + * - ID + * - jabber + * - last_name + * - nickname + * - plugins_last_view + * - plugins_per_page + * - rich_editing + * - syntax_highlighting + * - user_activation_key + * - user_description + * - user_email + * - user_firstname + * - user_lastname + * - user_level + * - user_login + * - user_nicename + * - user_pass + * - user_registered + * - user_status + * - user_url + * - yim + * + * @since 2.8.0 + * + * @global object $authordata The current author's DB object. + * + * @param string $field Optional. The user field to retrieve. Default empty. + * @param int $user_id Optional. User ID. + * @return string The author's field from the current author's DB object, otherwise an empty string. + */ +function get_the_author_meta( $field = '', $user_id = false ) { + $original_user_id = $user_id; + + if ( ! $user_id ) { + global $authordata; + $user_id = isset( $authordata->ID ) ? $authordata->ID : 0; + } else { + $authordata = get_userdata( $user_id ); + } + + if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) + $field = 'user_' . $field; + + $value = isset( $authordata->$field ) ? $authordata->$field : ''; + + /** + * Filters the value of the requested user metadata. + * + * The filter name is dynamic and depends on the $field parameter of the function. + * + * @since 2.8.0 + * @since 4.3.0 The `$original_user_id` parameter was added. + * + * @param string $value The value of the metadata. + * @param int $user_id The user ID for the value. + * @param int|bool $original_user_id The original user ID, as passed to the function. + */ + return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id ); +} + +/** + * Outputs the field from the user's DB object. Defaults to current post's author. + * + * @since 2.8.0 + * + * @param string $field Selects the field of the users record. See get_the_author_meta() + * for the list of possible fields. + * @param int $user_id Optional. User ID. + * + * @see get_the_author_meta() + */ +function the_author_meta( $field = '', $user_id = false ) { + $author_meta = get_the_author_meta( $field, $user_id ); + + /** + * The value of the requested user metadata. + * + * The filter name is dynamic and depends on the $field parameter of the function. + * + * @since 2.8.0 + * + * @param string $author_meta The value of the metadata. + * @param int $user_id The user ID. + */ + echo apply_filters( "the_author_{$field}", $author_meta, $user_id ); +} + +/** + * Retrieve either author's link or author's name. + * + * If the author has a home page set, return an HTML link, otherwise just return the + * author's name. + * + * @since 3.0.0 + * + * @return string|null An HTML link if the author's url exist in user meta, + * else the result of get_the_author(). + */ +function get_the_author_link() { + if ( get_the_author_meta('url') ) { + return sprintf( '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', + esc_url( get_the_author_meta('url') ), + /* translators: %s: author's display name */ + esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author() ) ), + get_the_author() + ); + } else { + return get_the_author(); + } +} + +/** + * Display either author's link or author's name. + * + * If the author has a home page set, echo an HTML link, otherwise just echo the + * author's name. + * + * @link https://codex.wordpress.org/Template_Tags/the_author_link + * + * @since 2.1.0 + */ +function the_author_link() { + echo get_the_author_link(); +} + +/** + * Retrieve the number of posts by the author of the current post. + * + * @since 1.5.0 + * + * @return int The number of posts by the author. + */ +function get_the_author_posts() { + $post = get_post(); + if ( ! $post ) { + return 0; + } + return count_user_posts( $post->post_author, $post->post_type ); +} + +/** + * Display the number of posts by the author of the current post. + * + * @link https://codex.wordpress.org/Template_Tags/the_author_posts + * @since 0.71 + */ +function the_author_posts() { + echo get_the_author_posts(); +} + +/** + * Retrieves an HTML link to the author page of the current post's author. + * + * Returns an HTML-formatted link using get_author_posts_url(). + * + * @since 4.4.0 + * + * @global object $authordata The current author's DB object. + * + * @return string An HTML link to the author page. + */ +function get_the_author_posts_link() { + global $authordata; + if ( ! is_object( $authordata ) ) { + return; + } + + $link = sprintf( '<a href="%1$s" title="%2$s" rel="author">%3$s</a>', + esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), + /* translators: %s: author's display name */ + esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), + get_the_author() + ); + + /** + * Filters the link to the author page of the author of the current post. + * + * @since 2.9.0 + * + * @param string $link HTML link. + */ + return apply_filters( 'the_author_posts_link', $link ); +} + +/** + * Displays an HTML link to the author page of the current post's author. + * + * @since 1.2.0 + * @since 4.4.0 Converted into a wrapper for get_the_author_posts_link() + * + * @param string $deprecated Unused. + */ +function the_author_posts_link( $deprecated = '' ) { + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __FUNCTION__, '2.1.0' ); + } + echo get_the_author_posts_link(); +} + +/** + * Retrieve the URL to the author page for the user with the ID provided. + * + * @since 2.1.0 + * + * @global WP_Rewrite $wp_rewrite + * + * @param int $author_id Author ID. + * @param string $author_nicename Optional. The author's nicename (slug). Default empty. + * @return string The URL to the author's page. + */ +function get_author_posts_url( $author_id, $author_nicename = '' ) { + global $wp_rewrite; + $auth_ID = (int) $author_id; + $link = $wp_rewrite->get_author_permastruct(); + + if ( empty($link) ) { + $file = home_url( '/' ); + $link = $file . '?author=' . $auth_ID; + } else { + if ( '' == $author_nicename ) { + $user = get_userdata($author_id); + if ( !empty($user->user_nicename) ) + $author_nicename = $user->user_nicename; + } + $link = str_replace('%author%', $author_nicename, $link); + $link = home_url( user_trailingslashit( $link ) ); + } + + /** + * Filters the URL to the author's page. + * + * @since 2.1.0 + * + * @param string $link The URL to the author's page. + * @param int $author_id The author's id. + * @param string $author_nicename The author's nice name. + */ + $link = apply_filters( 'author_link', $link, $author_id, $author_nicename ); + + return $link; +} + +/** + * List all the authors of the site, with several options available. + * + * @link https://codex.wordpress.org/Template_Tags/wp_list_authors + * + * @since 1.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string|array $args { + * Optional. Array or string of default arguments. + * + * @type string $orderby How to sort the authors. Accepts 'nicename', 'email', 'url', 'registered', + * 'user_nicename', 'user_email', 'user_url', 'user_registered', 'name', + * 'display_name', 'post_count', 'ID', 'meta_value', 'user_login'. Default 'name'. + * @type string $order Sorting direction for $orderby. Accepts 'ASC', 'DESC'. Default 'ASC'. + * @type int $number Maximum authors to return or display. Default empty (all authors). + * @type bool $optioncount Show the count in parenthesis next to the author's name. Default false. + * @type bool $exclude_admin Whether to exclude the 'admin' account, if it exists. Default false. + * @type bool $show_fullname Whether to show the author's full name. Default false. + * @type bool $hide_empty Whether to hide any authors with no posts. Default true. + * @type string $feed If not empty, show a link to the author's feed and use this text as the alt + * parameter of the link. Default empty. + * @type string $feed_image If not empty, show a link to the author's feed and use this image URL as + * clickable anchor. Default empty. + * @type string $feed_type The feed type to link to, such as 'rss2'. Defaults to default feed type. + * @type bool $echo Whether to output the result or instead return it. Default true. + * @type string $style If 'list', each author is wrapped in an `<li>` element, otherwise the authors + * will be separated by commas. + * @type bool $html Whether to list the items in HTML form or plaintext. Default true. + * @type array|string $exclude Array or comma/space-separated list of author IDs to exclude. Default empty. + * @type array|string $include Array or comma/space-separated list of author IDs to include. Default empty. + * } + * @return string|void The output, if echo is set to false. + */ +function wp_list_authors( $args = '' ) { + global $wpdb; + + $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', 'number' => '', + 'optioncount' => false, 'exclude_admin' => true, + 'show_fullname' => false, 'hide_empty' => true, + 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, + 'style' => 'list', 'html' => true, 'exclude' => '', 'include' => '' + ); + + $args = wp_parse_args( $args, $defaults ); + + $return = ''; + + $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); + $query_args['fields'] = 'ids'; + $authors = get_users( $query_args ); + + $author_count = array(); + foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) { + $author_count[$row->post_author] = $row->count; + } + foreach ( $authors as $author_id ) { + $author = get_userdata( $author_id ); + + if ( $args['exclude_admin'] && 'admin' == $author->display_name ) { + continue; + } + + $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0; + + if ( ! $posts && $args['hide_empty'] ) { + continue; + } + + if ( $args['show_fullname'] && $author->first_name && $author->last_name ) { + $name = "$author->first_name $author->last_name"; + } else { + $name = $author->display_name; + } + + if ( ! $args['html'] ) { + $return .= $name . ', '; + + continue; // No need to go further to process HTML. + } + + if ( 'list' == $args['style'] ) { + $return .= '<li>'; + } + + $link = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', + get_author_posts_url( $author->ID, $author->user_nicename ), + /* translators: %s: author's display name */ + esc_attr( sprintf( __( 'Posts by %s' ), $author->display_name ) ), + $name + ); + + if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) { + $link .= ' '; + if ( empty( $args['feed_image'] ) ) { + $link .= '('; + } + + $link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"'; + + $alt = ''; + if ( ! empty( $args['feed'] ) ) { + $alt = ' alt="' . esc_attr( $args['feed'] ) . '"'; + $name = $args['feed']; + } + + $link .= '>'; + + if ( ! empty( $args['feed_image'] ) ) { + $link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; + } else { + $link .= $name; + } + + $link .= '</a>'; + + if ( empty( $args['feed_image'] ) ) { + $link .= ')'; + } + } + + if ( $args['optioncount'] ) { + $link .= ' ('. $posts . ')'; + } + + $return .= $link; + $return .= ( 'list' == $args['style'] ) ? '</li>' : ', '; + } + + $return = rtrim( $return, ', ' ); + + if ( ! $args['echo'] ) { + return $return; + } + echo $return; +} + +/** + * Does this site have more than one author + * + * Checks to see if more than one author has published posts. + * + * @since 3.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return bool Whether or not we have more than one author + */ +function is_multi_author() { + global $wpdb; + + if ( false === ( $is_multi_author = get_transient( 'is_multi_author' ) ) ) { + $rows = (array) $wpdb->get_col("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2"); + $is_multi_author = 1 < count( $rows ) ? 1 : 0; + set_transient( 'is_multi_author', $is_multi_author ); + } + + /** + * Filters whether the site has more than one author with published posts. + * + * @since 3.2.0 + * + * @param bool $is_multi_author Whether $is_multi_author should evaluate as true. + */ + return apply_filters( 'is_multi_author', (bool) $is_multi_author ); +} + +/** + * Helper function to clear the cache for number of authors. + * + * @since 3.2.0 + * @access private + */ +function __clear_multi_author_cache() { + delete_transient( 'is_multi_author' ); +} diff --git a/backend/wp-includes/bookmark-template.php b/backend/wp-includes/bookmark-template.php new file mode 100644 index 0000000..c6b7fd2 --- /dev/null +++ b/backend/wp-includes/bookmark-template.php @@ -0,0 +1,304 @@ +<?php +/** + * Bookmark Template Functions for usage in Themes + * + * @package WordPress + * @subpackage Template + */ + +/** + * The formatted output of a list of bookmarks. + * + * The $bookmarks array must contain bookmark objects and will be iterated over + * to retrieve the bookmark to be used in the output. + * + * The output is formatted as HTML with no way to change that format. However, + * what is between, before, and after can be changed. The link itself will be + * HTML. + * + * This function is used internally by wp_list_bookmarks() and should not be + * used by themes. + * + * @since 2.1.0 + * @access private + * + * @param array $bookmarks List of bookmarks to traverse. + * @param string|array $args { + * Optional. Bookmarks arguments. + * + * @type int|bool $show_updated Whether to show the time the bookmark was last updated. + * Accepts 1|true or 0|false. Default 0|false. + * @type int|bool $show_description Whether to show the bookmakr description. Accepts 1|true, + * Accepts 1|true or 0|false. Default 0|false. + * @type int|bool $show_images Whether to show the link image if available. Accepts 1|true + * or 0|false. Default 1|true. + * @type int|bool $show_name Whether to show link name if available. Accepts 1|true or + * 0|false. Default 0|false. + * @type string $before The HTML or text to prepend to each bookmark. Default `<li>`. + * @type string $after The HTML or text to append to each bookmark. Default `</li>`. + * @type string $link_before The HTML or text to prepend to each bookmark inside the anchor + * tags. Default empty. + * @type string $link_after The HTML or text to append to each bookmark inside the anchor + * tags. Default empty. + * @type string $between The string for use in between the link, description, and image. + * Default "\n". + * @type int|bool $show_rating Whether to show the link rating. Accepts 1|true or 0|false. + * Default 0|false. + * + * } + * @return string Formatted output in HTML + */ +function _walk_bookmarks( $bookmarks, $args = '' ) { + $defaults = array( + 'show_updated' => 0, 'show_description' => 0, + 'show_images' => 1, 'show_name' => 0, + 'before' => '<li>', 'after' => '</li>', 'between' => "\n", + 'show_rating' => 0, 'link_before' => '', 'link_after' => '' + ); + + $r = wp_parse_args( $args, $defaults ); + + $output = ''; // Blank string to start with. + + foreach ( (array) $bookmarks as $bookmark ) { + if ( ! isset( $bookmark->recently_updated ) ) { + $bookmark->recently_updated = false; + } + $output .= $r['before']; + if ( $r['show_updated'] && $bookmark->recently_updated ) { + $output .= '<em>'; + } + $the_link = '#'; + if ( ! empty( $bookmark->link_url ) ) { + $the_link = esc_url( $bookmark->link_url ); + } + $desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) ); + $name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) ); + $title = $desc; + + if ( $r['show_updated'] ) { + if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) { + $title .= ' ('; + $title .= sprintf( + __('Last updated: %s'), + date( + get_option( 'links_updated_date_format' ), + $bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) + ) + ); + $title .= ')'; + } + } + $alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"'; + + if ( '' != $title ) { + $title = ' title="' . $title . '"'; + } + $rel = $bookmark->link_rel; + if ( '' != $rel ) { + $rel = ' rel="' . esc_attr($rel) . '"'; + } + $target = $bookmark->link_target; + if ( '' != $target ) { + $target = ' target="' . $target . '"'; + } + $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>'; + + $output .= $r['link_before']; + + if ( $bookmark->link_image != null && $r['show_images'] ) { + if ( strpos( $bookmark->link_image, 'http' ) === 0 ) { + $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; + } else { // If it's a relative path + $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />"; + } + if ( $r['show_name'] ) { + $output .= " $name"; + } + } else { + $output .= $name; + } + + $output .= $r['link_after']; + + $output .= '</a>'; + + if ( $r['show_updated'] && $bookmark->recently_updated ) { + $output .= '</em>'; + } + + if ( $r['show_description'] && '' != $desc ) { + $output .= $r['between'] . $desc; + } + + if ( $r['show_rating'] ) { + $output .= $r['between'] . sanitize_bookmark_field( + 'link_rating', + $bookmark->link_rating, + $bookmark->link_id, + 'display' + ); + } + $output .= $r['after'] . "\n"; + } // end while + + return $output; +} + +/** + * Retrieve or echo all of the bookmarks. + * + * List of default arguments are as follows: + * + * These options define how the Category name will appear before the category + * links are displayed, if 'categorize' is 1. If 'categorize' is 0, then it will + * display for only the 'title_li' string and only if 'title_li' is not empty. + * + * @since 2.1.0 + * + * @see _walk_bookmarks() + * + * @param string|array $args { + * Optional. String or array of arguments to list bookmarks. + * + * @type string $orderby How to order the links by. Accepts post fields. Default 'name'. + * @type string $order Whether to order bookmarks in ascending or descending order. + * Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'. + * @type int $limit Amount of bookmarks to display. Accepts 1+ or -1 for all. + * Default -1. + * @type string $category Comma-separated list of category ids to include links from. + * Default empty. + * @type string $category_name Category to retrieve links for by name. Default empty. + * @type int|bool $hide_invisible Whether to show or hide links marked as 'invisible'. Accepts + * 1|true or 0|false. Default 1|true. + * @type int|bool $show_updated Whether to display the time the bookmark was last updated. + * Accepts 1|true or 0|false. Default 0|false. + * @type int|bool $echo Whether to echo or return the formatted bookmarks. Accepts + * 1|true (echo) or 0|false (return). Default 1|true. + * @type int|bool $categorize Whether to show links listed by category or in a single column. + * Accepts 1|true (by category) or 0|false (one column). Default 1|true. + * @type int|bool $show_description Whether to show the bookmark descriptions. Accepts 1|true or 0|false. + * Default 0|false. + * @type string $title_li What to show before the links appear. Default 'Bookmarks'. + * @type string $title_before The HTML or text to prepend to the $title_li string. Default '<h2>'. + * @type string $title_after The HTML or text to append to the $title_li string. Default '</h2>'. + * @type string $class The CSS class to use for the $title_li. Default 'linkcat'. + * @type string $category_before The HTML or text to prepend to $title_before if $categorize is true. + * String must contain '%id' and '%class' to inherit the category ID and + * the $class argument used for formatting in themes. + * Default '<li id="%id" class="%class">'. + * @type string $category_after The HTML or text to append to $title_after if $categorize is true. + * Default '</li>'. + * @type string $category_orderby How to order the bookmark category based on term scheme if $categorize + * is true. Default 'name'. + * @type string $category_order Whether to order categories in ascending or descending order if + * $categorize is true. Accepts 'ASC' (ascending) or 'DESC' (descending). + * Default 'ASC'. + * } + * @return string|void Will only return if echo option is set to not echo. Default is not return anything. + */ +function wp_list_bookmarks( $args = '' ) { + $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', + 'limit' => -1, 'category' => '', 'exclude_category' => '', + 'category_name' => '', 'hide_invisible' => 1, + 'show_updated' => 0, 'echo' => 1, + 'categorize' => 1, 'title_li' => __('Bookmarks'), + 'title_before' => '<h2>', 'title_after' => '</h2>', + 'category_orderby' => 'name', 'category_order' => 'ASC', + 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">', + 'category_after' => '</li>' + ); + + $r = wp_parse_args( $args, $defaults ); + + $output = ''; + + if ( ! is_array( $r['class'] ) ) { + $r['class'] = explode( ' ', $r['class'] ); + } + $r['class'] = array_map( 'sanitize_html_class', $r['class'] ); + $r['class'] = trim( join( ' ', $r['class'] ) ); + + if ( $r['categorize'] ) { + $cats = get_terms( 'link_category', array( + 'name__like' => $r['category_name'], + 'include' => $r['category'], + 'exclude' => $r['exclude_category'], + 'orderby' => $r['category_orderby'], + 'order' => $r['category_order'], + 'hierarchical' => 0 + ) ); + if ( empty( $cats ) ) { + $r['categorize'] = false; + } + } + + if ( $r['categorize'] ) { + // Split the bookmarks into ul's for each category + foreach ( (array) $cats as $cat ) { + $params = array_merge( $r, array( 'category' => $cat->term_id ) ); + $bookmarks = get_bookmarks( $params ); + if ( empty( $bookmarks ) ) { + continue; + } + $output .= str_replace( + array( '%id', '%class' ), + array( "linkcat-$cat->term_id", $r['class'] ), + $r['category_before'] + ); + /** + * Filters the bookmarks category name. + * + * @since 2.2.0 + * + * @param string $cat_name The category name of bookmarks. + */ + $catname = apply_filters( 'link_category', $cat->name ); + + $output .= $r['title_before']; + $output .= $catname; + $output .= $r['title_after']; + $output .= "\n\t<ul class='xoxo blogroll'>\n"; + $output .= _walk_bookmarks( $bookmarks, $r ); + $output .= "\n\t</ul>\n"; + $output .= $r['category_after'] . "\n"; + } + } else { + //output one single list using title_li for the title + $bookmarks = get_bookmarks( $r ); + + if ( ! empty( $bookmarks ) ) { + if ( ! empty( $r['title_li'] ) ) { + $output .= str_replace( + array( '%id', '%class' ), + array( "linkcat-" . $r['category'], $r['class'] ), + $r['category_before'] + ); + $output .= $r['title_before']; + $output .= $r['title_li']; + $output .= $r['title_after']; + $output .= "\n\t<ul class='xoxo blogroll'>\n"; + $output .= _walk_bookmarks( $bookmarks, $r ); + $output .= "\n\t</ul>\n"; + $output .= $r['category_after'] . "\n"; + } else { + $output .= _walk_bookmarks( $bookmarks, $r ); + } + } + } + + /** + * Filters the bookmarks list before it is echoed or returned. + * + * @since 2.5.0 + * + * @param string $html The HTML list of bookmarks. + */ + $html = apply_filters( 'wp_list_bookmarks', $output ); + + if ( ! $r['echo'] ) { + return $html; + } + echo $html; +} diff --git a/backend/wp-includes/bookmark.php b/backend/wp-includes/bookmark.php new file mode 100644 index 0000000..cb1bee7 --- /dev/null +++ b/backend/wp-includes/bookmark.php @@ -0,0 +1,421 @@ +<?php +/** + * Link/Bookmark API + * + * @package WordPress + * @subpackage Bookmark + */ + +/** + * Retrieve Bookmark data + * + * @since 2.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|stdClass $bookmark + * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to + * an stdClass object, an associative array, or a numeric array, respectively. Default OBJECT. + * @param string $filter Optional, default is 'raw'. + * @return array|object|null Type returned depends on $output value. + */ +function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') { + global $wpdb; + + if ( empty($bookmark) ) { + if ( isset($GLOBALS['link']) ) + $_bookmark = & $GLOBALS['link']; + else + $_bookmark = null; + } elseif ( is_object($bookmark) ) { + wp_cache_add($bookmark->link_id, $bookmark, 'bookmark'); + $_bookmark = $bookmark; + } else { + if ( isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark) ) { + $_bookmark = & $GLOBALS['link']; + } elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) { + $_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark)); + if ( $_bookmark ) { + $_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) ); + wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' ); + } + } + } + + if ( ! $_bookmark ) + return $_bookmark; + + $_bookmark = sanitize_bookmark($_bookmark, $filter); + + if ( $output == OBJECT ) { + return $_bookmark; + } elseif ( $output == ARRAY_A ) { + return get_object_vars($_bookmark); + } elseif ( $output == ARRAY_N ) { + return array_values(get_object_vars($_bookmark)); + } else { + return $_bookmark; + } +} + +/** + * Retrieve single bookmark data item or field. + * + * @since 2.3.0 + * + * @param string $field The name of the data field to return + * @param int $bookmark The bookmark ID to get field + * @param string $context Optional. The context of how the field will be used. + * @return string|WP_Error + */ +function get_bookmark_field( $field, $bookmark, $context = 'display' ) { + $bookmark = (int) $bookmark; + $bookmark = get_bookmark( $bookmark ); + + if ( is_wp_error($bookmark) ) + return $bookmark; + + if ( !is_object($bookmark) ) + return ''; + + if ( !isset($bookmark->$field) ) + return ''; + + return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); +} + +/** + * Retrieves the list of bookmarks + * + * Attempts to retrieve from the cache first based on MD5 hash of arguments. If + * that fails, then the query will be built from the arguments and executed. The + * results will be stored to the cache. + * + * @since 2.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string|array $args { + * Optional. String or array of arguments to retrieve bookmarks. + * + * @type string $orderby How to order the links by. Accepts post fields. Default 'name'. + * @type string $order Whether to order bookmarks in ascending or descending order. + * Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'. + * @type int $limit Amount of bookmarks to display. Accepts 1+ or -1 for all. + * Default -1. + * @type string $category Comma-separated list of category ids to include links from. + * Default empty. + * @type string $category_name Category to retrieve links for by name. Default empty. + * @type int|bool $hide_invisible Whether to show or hide links marked as 'invisible'. Accepts + * 1|true or 0|false. Default 1|true. + * @type int|bool $show_updated Whether to display the time the bookmark was last updated. + * Accepts 1|true or 0|false. Default 0|false. + * @type string $include Comma-separated list of bookmark IDs to include. Default empty. + * @type string $exclude Comma-separated list of bookmark IDs to exclude. Default empty. + * } + * @return array List of bookmark row objects. + */ +function get_bookmarks( $args = '' ) { + global $wpdb; + + $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', + 'limit' => -1, 'category' => '', + 'category_name' => '', 'hide_invisible' => 1, + 'show_updated' => 0, 'include' => '', + 'exclude' => '', 'search' => '' + ); + + $r = wp_parse_args( $args, $defaults ); + + $key = md5( serialize( $r ) ); + $cache = false; + if ( 'rand' !== $r['orderby'] && $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { + if ( is_array( $cache ) && isset( $cache[ $key ] ) ) { + $bookmarks = $cache[ $key ]; + /** + * Filters the returned list of bookmarks. + * + * The first time the hook is evaluated in this file, it returns the cached + * bookmarks list. The second evaluation returns a cached bookmarks list if the + * link category is passed but does not exist. The third evaluation returns + * the full cached results. + * + * @since 2.1.0 + * + * @see get_bookmarks() + * + * @param array $bookmarks List of the cached bookmarks. + * @param array $r An array of bookmark query arguments. + */ + return apply_filters( 'get_bookmarks', $bookmarks, $r ); + } + } + + if ( ! is_array( $cache ) ) { + $cache = array(); + } + + $inclusions = ''; + if ( ! empty( $r['include'] ) ) { + $r['exclude'] = ''; //ignore exclude, category, and category_name params if using include + $r['category'] = ''; + $r['category_name'] = ''; + $inclinks = preg_split( '/[\s,]+/', $r['include'] ); + if ( count( $inclinks ) ) { + foreach ( $inclinks as $inclink ) { + if ( empty( $inclusions ) ) { + $inclusions = ' AND ( link_id = ' . intval( $inclink ) . ' '; + } else { + $inclusions .= ' OR link_id = ' . intval( $inclink ) . ' '; + } + } + } + } + if (! empty( $inclusions ) ) { + $inclusions .= ')'; + } + + $exclusions = ''; + if ( ! empty( $r['exclude'] ) ) { + $exlinks = preg_split( '/[\s,]+/', $r['exclude'] ); + if ( count( $exlinks ) ) { + foreach ( $exlinks as $exlink ) { + if ( empty( $exclusions ) ) { + $exclusions = ' AND ( link_id <> ' . intval( $exlink ) . ' '; + } else { + $exclusions .= ' AND link_id <> ' . intval( $exlink ) . ' '; + } + } + } + } + if ( ! empty( $exclusions ) ) { + $exclusions .= ')'; + } + + if ( ! empty( $r['category_name'] ) ) { + if ( $r['category'] = get_term_by('name', $r['category_name'], 'link_category') ) { + $r['category'] = $r['category']->term_id; + } else { + $cache[ $key ] = array(); + wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); + /** This filter is documented in wp-includes/bookmark.php */ + return apply_filters( 'get_bookmarks', array(), $r ); + } + } + + $search = ''; + if ( ! empty( $r['search'] ) ) { + $like = '%' . $wpdb->esc_like( $r['search'] ) . '%'; + $search = $wpdb->prepare(" AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ", $like, $like, $like ); + } + + $category_query = ''; + $join = ''; + if ( ! empty( $r['category'] ) ) { + $incategories = preg_split( '/[\s,]+/', $r['category'] ); + if ( count($incategories) ) { + foreach ( $incategories as $incat ) { + if ( empty( $category_query ) ) { + $category_query = ' AND ( tt.term_id = ' . intval( $incat ) . ' '; + } else { + $category_query .= ' OR tt.term_id = ' . intval( $incat ) . ' '; + } + } + } + } + if ( ! empty( $category_query ) ) { + $category_query .= ") AND taxonomy = 'link_category'"; + $join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id"; + } + + if ( $r['show_updated'] ) { + $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated "; + } else { + $recently_updated_test = ''; + } + + $get_updated = ( $r['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; + + $orderby = strtolower( $r['orderby'] ); + $length = ''; + switch ( $orderby ) { + case 'length': + $length = ", CHAR_LENGTH(link_name) AS length"; + break; + case 'rand': + $orderby = 'rand()'; + break; + case 'link_id': + $orderby = "$wpdb->links.link_id"; + break; + default: + $orderparams = array(); + $keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes', 'link_description' ); + foreach ( explode( ',', $orderby ) as $ordparam ) { + $ordparam = trim( $ordparam ); + + if ( in_array( 'link_' . $ordparam, $keys ) ) { + $orderparams[] = 'link_' . $ordparam; + } elseif ( in_array( $ordparam, $keys ) ) { + $orderparams[] = $ordparam; + } + } + $orderby = implode( ',', $orderparams ); + } + + if ( empty( $orderby ) ) { + $orderby = 'link_name'; + } + + $order = strtoupper( $r['order'] ); + if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { + $order = 'ASC'; + } + + $visible = ''; + if ( $r['hide_invisible'] ) { + $visible = "AND link_visible = 'Y'"; + } + + $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; + $query .= " $exclusions $inclusions $search"; + $query .= " ORDER BY $orderby $order"; + if ( $r['limit'] != -1 ) { + $query .= ' LIMIT ' . $r['limit']; + } + + $results = $wpdb->get_results( $query ); + + if ( 'rand()' !== $orderby ) { + $cache[ $key ] = $results; + wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); + } + + /** This filter is documented in wp-includes/bookmark.php */ + return apply_filters( 'get_bookmarks', $results, $r ); +} + +/** + * Sanitizes all bookmark fields + * + * @since 2.3.0 + * + * @param stdClass|array $bookmark Bookmark row + * @param string $context Optional, default is 'display'. How to filter the + * fields + * @return stdClass|array Same type as $bookmark but with fields sanitized. + */ +function sanitize_bookmark($bookmark, $context = 'display') { + $fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', + 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', + 'link_rel', 'link_notes', 'link_rss', ); + + if ( is_object($bookmark) ) { + $do_object = true; + $link_id = $bookmark->link_id; + } else { + $do_object = false; + $link_id = $bookmark['link_id']; + } + + foreach ( $fields as $field ) { + if ( $do_object ) { + if ( isset($bookmark->$field) ) + $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context); + } else { + if ( isset($bookmark[$field]) ) + $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context); + } + } + + return $bookmark; +} + +/** + * Sanitizes a bookmark field. + * + * Sanitizes the bookmark fields based on what the field name is. If the field + * has a strict value set, then it will be tested for that, else a more generic + * filtering is applied. After the more strict filter is applied, if the `$context` + * is 'raw' then the value is immediately return. + * + * Hooks exist for the more generic cases. With the 'edit' context, the {@see 'edit_$field'} + * filter will be called and passed the `$value` and `$bookmark_id` respectively. + * + * With the 'db' context, the {@see 'pre_$field'} filter is called and passed the value. + * The 'display' context is the final context and has the `$field` has the filter name + * and is passed the `$value`, `$bookmark_id`, and `$context`, respectively. + * + * @since 2.3.0 + * + * @param string $field The bookmark field. + * @param mixed $value The bookmark field value. + * @param int $bookmark_id Bookmark ID. + * @param string $context How to filter the field value. Accepts 'raw', 'edit', 'attribute', + * 'js', 'db', or 'display' + * @return mixed The filtered value. + */ +function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { + switch ( $field ) { + case 'link_id' : // ints + case 'link_rating' : + $value = (int) $value; + break; + case 'link_category' : // array( ints ) + $value = array_map('absint', (array) $value); + // We return here so that the categories aren't filtered. + // The 'link_category' filter is for the name of a link category, not an array of a link's link categories + return $value; + + case 'link_visible' : // bool stored as Y|N + $value = preg_replace('/[^YNyn]/', '', $value); + break; + case 'link_target' : // "enum" + $targets = array('_top', '_blank'); + if ( ! in_array($value, $targets) ) + $value = ''; + break; + } + + if ( 'raw' == $context ) + return $value; + + if ( 'edit' == $context ) { + /** This filter is documented in wp-includes/post.php */ + $value = apply_filters( "edit_{$field}", $value, $bookmark_id ); + + if ( 'link_notes' == $field ) { + $value = esc_html( $value ); // textarea_escaped + } else { + $value = esc_attr($value); + } + } elseif ( 'db' == $context ) { + /** This filter is documented in wp-includes/post.php */ + $value = apply_filters( "pre_{$field}", $value ); + } else { + /** This filter is documented in wp-includes/post.php */ + $value = apply_filters( "{$field}", $value, $bookmark_id, $context ); + + if ( 'attribute' == $context ) { + $value = esc_attr( $value ); + } elseif ( 'js' == $context ) { + $value = esc_js( $value ); + } + } + + return $value; +} + +/** + * Deletes the bookmark cache. + * + * @since 2.7.0 + * + * @param int $bookmark_id Bookmark ID. + */ +function clean_bookmark_cache( $bookmark_id ) { + wp_cache_delete( $bookmark_id, 'bookmark' ); + wp_cache_delete( 'get_bookmarks', 'bookmark' ); + clean_object_term_cache( $bookmark_id, 'link'); +} diff --git a/backend/wp-includes/cache.php b/backend/wp-includes/cache.php new file mode 100644 index 0000000..ddfd6e2 --- /dev/null +++ b/backend/wp-includes/cache.php @@ -0,0 +1,732 @@ +<?php +/** + * Object Cache API + * + * @link https://codex.wordpress.org/Class_Reference/WP_Object_Cache + * + * @package WordPress + * @subpackage Cache + */ + +/** + * Adds data to the cache, if the cache key doesn't already exist. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::add() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The cache key to use for retrieval later. + * @param mixed $data The data to add to the cache. + * @param string $group Optional. The group to add the cache to. Enables the same key + * to be used across groups. Default empty. + * @param int $expire Optional. When the cache data should expire, in seconds. + * Default 0 (no expiration). + * @return bool False if cache key and group already exist, true on success. + */ +function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->add( $key, $data, $group, (int) $expire ); +} + +/** + * Closes the cache. + * + * This function has ceased to do anything since WordPress 2.5. The + * functionality was removed along with the rest of the persistent cache. + * + * This does not mean that plugins can't implement this function when they need + * to make sure that the cache is cleaned up after WordPress no longer needs it. + * + * @since 2.0.0 + * + * @return true Always returns true. + */ +function wp_cache_close() { + return true; +} + +/** + * Decrements numeric cache item's value. + * + * @since 3.3.0 + * + * @see WP_Object_Cache::decr() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The cache key to decrement. + * @param int $offset Optional. The amount by which to decrement the item's value. Default 1. + * @param string $group Optional. The group the key is in. Default empty. + * @return false|int False on failure, the item's new value on success. + */ +function wp_cache_decr( $key, $offset = 1, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->decr( $key, $offset, $group ); +} + +/** + * Removes the cache contents matching key and group. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::delete() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key What the contents in the cache are called. + * @param string $group Optional. Where the cache contents are grouped. Default empty. + * @return bool True on successful removal, false on failure. + */ +function wp_cache_delete( $key, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->delete($key, $group); +} + +/** + * Removes all cache items. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::flush() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @return bool False on failure, true on success + */ +function wp_cache_flush() { + global $wp_object_cache; + + return $wp_object_cache->flush(); +} + +/** + * Retrieves the cache contents from the cache by key and group. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::get() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The key under which the cache contents are stored. + * @param string $group Optional. Where the cache contents are grouped. Default empty. + * @param bool $force Optional. Whether to force an update of the local cache from the persistent + * cache. Default false. + * @param bool $found Optional. Whether the key was found in the cache (passed by reference). + * Disambiguates a return of false, a storable value. Default null. + * @return bool|mixed False on failure to retrieve contents or the cache + * contents on success + */ +function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { + global $wp_object_cache; + + return $wp_object_cache->get( $key, $group, $force, $found ); +} + +/** + * Increment numeric cache item's value + * + * @since 3.3.0 + * + * @see WP_Object_Cache::incr() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The key for the cache contents that should be incremented. + * @param int $offset Optional. The amount by which to increment the item's value. Default 1. + * @param string $group Optional. The group the key is in. Default empty. + * @return false|int False on failure, the item's new value on success. + */ +function wp_cache_incr( $key, $offset = 1, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->incr( $key, $offset, $group ); +} + +/** + * Sets up Object Cache Global and assigns it. + * + * @since 2.0.0 + * + * @global WP_Object_Cache $wp_object_cache + */ +function wp_cache_init() { + $GLOBALS['wp_object_cache'] = new WP_Object_Cache(); +} + +/** + * Replaces the contents of the cache with new data. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::replace() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The key for the cache data that should be replaced. + * @param mixed $data The new data to store in the cache. + * @param string $group Optional. The group for the cache data that should be replaced. + * Default empty. + * @param int $expire Optional. When to expire the cache contents, in seconds. + * Default 0 (no expiration). + * @return bool False if original value does not exist, true if contents were replaced + */ +function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->replace( $key, $data, $group, (int) $expire ); +} + +/** + * Saves the data to the cache. + * + * Differs from wp_cache_add() and wp_cache_replace() in that it will always write data. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::set() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int|string $key The cache key to use for retrieval later. + * @param mixed $data The contents to store in the cache. + * @param string $group Optional. Where to group the cache contents. Enables the same key + * to be used across groups. Default empty. + * @param int $expire Optional. When to expire the cache contents, in seconds. + * Default 0 (no expiration). + * @return bool False on failure, true on success + */ +function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->set( $key, $data, $group, (int) $expire ); +} + +/** + * Switches the internal blog ID. + * + * This changes the blog id used to create keys in blog specific groups. + * + * @since 3.5.0 + * + * @see WP_Object_Cache::switch_to_blog() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param int $blog_id Site ID. + */ +function wp_cache_switch_to_blog( $blog_id ) { + global $wp_object_cache; + + $wp_object_cache->switch_to_blog( $blog_id ); +} + +/** + * Adds a group or set of groups to the list of global groups. + * + * @since 2.6.0 + * + * @see WP_Object_Cache::add_global_groups() + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + * + * @param string|array $groups A group or an array of groups to add. + */ +function wp_cache_add_global_groups( $groups ) { + global $wp_object_cache; + + $wp_object_cache->add_global_groups( $groups ); +} + +/** + * Adds a group or set of groups to the list of non-persistent groups. + * + * @since 2.6.0 + * + * @param string|array $groups A group or an array of groups to add. + */ +function wp_cache_add_non_persistent_groups( $groups ) { + // Default cache doesn't persist so nothing to do here. +} + +/** + * Reset internal cache keys and structures. + * + * If the cache back end uses global blog or site IDs as part of its cache keys, + * this function instructs the back end to reset those keys and perform any cleanup + * since blog or site IDs have changed since cache init. + * + * This function is deprecated. Use wp_cache_switch_to_blog() instead of this + * function when preparing the cache for a blog switch. For clearing the cache + * during unit tests, consider using wp_cache_init(). wp_cache_init() is not + * recommended outside of unit tests as the performance penalty for using it is + * high. + * + * @since 2.6.0 + * @deprecated 3.5.0 WP_Object_Cache::reset() + * @see WP_Object_Cache::reset() + * + * @global WP_Object_Cache $wp_object_cache Object cache global instance. + */ +function wp_cache_reset() { + _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Object_Cache::reset()' ); + + global $wp_object_cache; + + $wp_object_cache->reset(); +} + +/** + * Core class that implements an object cache. + * + * The WordPress Object Cache is used to save on trips to the database. The + * Object Cache stores all of the cache data to memory and makes the cache + * contents available by using a key, which is used to name and later retrieve + * the cache contents. + * + * The Object Cache can be replaced by other caching mechanisms by placing files + * in the wp-content folder which is looked at in wp-settings. If that file + * exists, then this file will not be included. + * + * @since 2.0.0 + */ +class WP_Object_Cache { + + /** + * Holds the cached objects. + * + * @since 2.0.0 + * @var array + */ + private $cache = array(); + + /** + * The amount of times the cache data was already stored in the cache. + * + * @since 2.5.0 + * @var int + */ + public $cache_hits = 0; + + /** + * Amount of times the cache did not have the request in cache. + * + * @since 2.0.0 + * @var int + */ + public $cache_misses = 0; + + /** + * List of global cache groups. + * + * @since 3.0.0 + * @var array + */ + protected $global_groups = array(); + + /** + * The blog prefix to prepend to keys in non-global groups. + * + * @since 3.5.0 + * @var int + */ + private $blog_prefix; + + /** + * Holds the value of is_multisite(). + * + * @since 3.5.0 + * @var bool + */ + private $multisite; + + /** + * Makes private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + return $this->$name; + } + + /** + * Makes private properties settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set( $name, $value ) { + return $this->$name = $value; + } + + /** + * Makes private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + return isset( $this->$name ); + } + + /** + * Makes private properties un-settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to unset. + */ + public function __unset( $name ) { + unset( $this->$name ); + } + + /** + * Adds data to the cache if it doesn't already exist. + * + * @since 2.0.0 + * + * @uses WP_Object_Cache::_exists() Checks to see if the cache already has data. + * @uses WP_Object_Cache::set() Sets the data after the checking the cache + * contents existence. + * + * @param int|string $key What to call the contents in the cache. + * @param mixed $data The contents to store in the cache. + * @param string $group Optional. Where to group the cache contents. Default 'default'. + * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). + * @return bool False if cache key and group already exist, true on success + */ + public function add( $key, $data, $group = 'default', $expire = 0 ) { + if ( wp_suspend_cache_addition() ) + return false; + + if ( empty( $group ) ) + $group = 'default'; + + $id = $key; + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $id = $this->blog_prefix . $key; + + if ( $this->_exists( $id, $group ) ) + return false; + + return $this->set( $key, $data, $group, (int) $expire ); + } + + /** + * Sets the list of global cache groups. + * + * @since 3.0.0 + * + * @param array $groups List of groups that are global. + */ + public function add_global_groups( $groups ) { + $groups = (array) $groups; + + $groups = array_fill_keys( $groups, true ); + $this->global_groups = array_merge( $this->global_groups, $groups ); + } + + /** + * Decrements numeric cache item's value. + * + * @since 3.3.0 + * + * @param int|string $key The cache key to decrement. + * @param int $offset Optional. The amount by which to decrement the item's value. Default 1. + * @param string $group Optional. The group the key is in. Default 'default'. + * @return false|int False on failure, the item's new value on success. + */ + public function decr( $key, $offset = 1, $group = 'default' ) { + if ( empty( $group ) ) + $group = 'default'; + + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $key = $this->blog_prefix . $key; + + if ( ! $this->_exists( $key, $group ) ) + return false; + + if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) + $this->cache[ $group ][ $key ] = 0; + + $offset = (int) $offset; + + $this->cache[ $group ][ $key ] -= $offset; + + if ( $this->cache[ $group ][ $key ] < 0 ) + $this->cache[ $group ][ $key ] = 0; + + return $this->cache[ $group ][ $key ]; + } + + /** + * Removes the contents of the cache key in the group. + * + * If the cache key does not exist in the group, then nothing will happen. + * + * @since 2.0.0 + * + * @param int|string $key What the contents in the cache are called. + * @param string $group Optional. Where the cache contents are grouped. Default 'default'. + * @param bool $deprecated Optional. Unused. Default false. + * @return bool False if the contents weren't deleted and true on success. + */ + public function delete( $key, $group = 'default', $deprecated = false ) { + if ( empty( $group ) ) + $group = 'default'; + + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $key = $this->blog_prefix . $key; + + if ( ! $this->_exists( $key, $group ) ) + return false; + + unset( $this->cache[$group][$key] ); + return true; + } + + /** + * Clears the object cache of all data. + * + * @since 2.0.0 + * + * @return true Always returns true. + */ + public function flush() { + $this->cache = array(); + + return true; + } + + /** + * Retrieves the cache contents, if it exists. + * + * The contents will be first attempted to be retrieved by searching by the + * key in the cache group. If the cache is hit (success) then the contents + * are returned. + * + * On failure, the number of cache misses will be incremented. + * + * @since 2.0.0 + * + * @param int|string $key What the contents in the cache are called. + * @param string $group Optional. Where the cache contents are grouped. Default 'default'. + * @param string $force Optional. Unused. Whether to force a refetch rather than relying on the local + * cache. Default false. + * @param bool $found Optional. Whether the key was found in the cache (passed by reference). + * Disambiguates a return of false, a storable value. Default null. + * @return false|mixed False on failure to retrieve contents or the cache contents on success. + */ + public function get( $key, $group = 'default', $force = false, &$found = null ) { + if ( empty( $group ) ) + $group = 'default'; + + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $key = $this->blog_prefix . $key; + + if ( $this->_exists( $key, $group ) ) { + $found = true; + $this->cache_hits += 1; + if ( is_object($this->cache[$group][$key]) ) + return clone $this->cache[$group][$key]; + else + return $this->cache[$group][$key]; + } + + $found = false; + $this->cache_misses += 1; + return false; + } + + /** + * Increments numeric cache item's value. + * + * @since 3.3.0 + * + * @param int|string $key The cache key to increment + * @param int $offset Optional. The amount by which to increment the item's value. Default 1. + * @param string $group Optional. The group the key is in. Default 'default'. + * @return false|int False on failure, the item's new value on success. + */ + public function incr( $key, $offset = 1, $group = 'default' ) { + if ( empty( $group ) ) + $group = 'default'; + + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $key = $this->blog_prefix . $key; + + if ( ! $this->_exists( $key, $group ) ) + return false; + + if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) + $this->cache[ $group ][ $key ] = 0; + + $offset = (int) $offset; + + $this->cache[ $group ][ $key ] += $offset; + + if ( $this->cache[ $group ][ $key ] < 0 ) + $this->cache[ $group ][ $key ] = 0; + + return $this->cache[ $group ][ $key ]; + } + + /** + * Replaces the contents in the cache, if contents already exist. + * + * @since 2.0.0 + * + * @see WP_Object_Cache::set() + * + * @param int|string $key What to call the contents in the cache. + * @param mixed $data The contents to store in the cache. + * @param string $group Optional. Where to group the cache contents. Default 'default'. + * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). + * @return bool False if not exists, true if contents were replaced. + */ + public function replace( $key, $data, $group = 'default', $expire = 0 ) { + if ( empty( $group ) ) + $group = 'default'; + + $id = $key; + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $id = $this->blog_prefix . $key; + + if ( ! $this->_exists( $id, $group ) ) + return false; + + return $this->set( $key, $data, $group, (int) $expire ); + } + + /** + * Resets cache keys. + * + * @since 3.0.0 + * + * @deprecated 3.5.0 Use switch_to_blog() + * @see switch_to_blog() + */ + public function reset() { + _deprecated_function( __FUNCTION__, '3.5.0', 'switch_to_blog()' ); + + // Clear out non-global caches since the blog ID has changed. + foreach ( array_keys( $this->cache ) as $group ) { + if ( ! isset( $this->global_groups[ $group ] ) ) + unset( $this->cache[ $group ] ); + } + } + + /** + * Sets the data contents into the cache. + * + * The cache contents is grouped by the $group parameter followed by the + * $key. This allows for duplicate ids in unique groups. Therefore, naming of + * the group should be used with care and should follow normal function + * naming guidelines outside of core WordPress usage. + * + * The $expire parameter is not used, because the cache will automatically + * expire for each time a page is accessed and PHP finishes. The method is + * more for cache plugins which use files. + * + * @since 2.0.0 + * + * @param int|string $key What to call the contents in the cache. + * @param mixed $data The contents to store in the cache. + * @param string $group Optional. Where to group the cache contents. Default 'default'. + * @param int $expire Not Used. + * @return true Always returns true. + */ + public function set( $key, $data, $group = 'default', $expire = 0 ) { + if ( empty( $group ) ) + $group = 'default'; + + if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) + $key = $this->blog_prefix . $key; + + if ( is_object( $data ) ) + $data = clone $data; + + $this->cache[$group][$key] = $data; + return true; + } + + /** + * Echoes the stats of the caching. + * + * Gives the cache hits, and cache misses. Also prints every cached group, + * key and the data. + * + * @since 2.0.0 + */ + public function stats() { + echo "<p>"; + echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />"; + echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />"; + echo "</p>"; + echo '<ul>'; + foreach ($this->cache as $group => $cache) { + echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>'; + } + echo '</ul>'; + } + + /** + * Switches the internal blog ID. + * + * This changes the blog ID used to create keys in blog specific groups. + * + * @since 3.5.0 + * + * @param int $blog_id Blog ID. + */ + public function switch_to_blog( $blog_id ) { + $blog_id = (int) $blog_id; + $this->blog_prefix = $this->multisite ? $blog_id . ':' : ''; + } + + /** + * Serves as a utility function to determine whether a key exists in the cache. + * + * @since 3.4.0 + * + * @param int|string $key Cache key to check for existence. + * @param string $group Cache group for the key existence check. + * @return bool Whether the key exists in the cache for the given group. + */ + protected function _exists( $key, $group ) { + return isset( $this->cache[ $group ] ) && ( isset( $this->cache[ $group ][ $key ] ) || array_key_exists( $key, $this->cache[ $group ] ) ); + } + + /** + * Sets up object properties; PHP 5 style constructor. + * + * @since 2.0.8 + */ + public function __construct() { + $this->multisite = is_multisite(); + $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : ''; + + + /** + * @todo This should be moved to the PHP4 style constructor, PHP5 + * already calls __destruct() + */ + register_shutdown_function( array( $this, '__destruct' ) ); + } + + /** + * Saves the object cache before object is completely destroyed. + * + * Called upon object destruction, which should be when PHP ends. + * + * @since 2.0.8 + * + * @return true Always returns true. + */ + public function __destruct() { + return true; + } +} diff --git a/backend/wp-includes/canonical.php b/backend/wp-includes/canonical.php new file mode 100644 index 0000000..03c51f1 --- /dev/null +++ b/backend/wp-includes/canonical.php @@ -0,0 +1,678 @@ +<?php +/** + * Canonical API to handle WordPress Redirecting + * + * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" + * by Mark Jaquith + * + * @package WordPress + * @since 2.3.0 + */ + +/** + * Redirects incoming links to the proper URL based on the site url. + * + * Search engines consider www.somedomain.com and somedomain.com to be two + * different URLs when they both go to the same location. This SEO enhancement + * prevents penalty for duplicate content by redirecting all incoming links to + * one or the other. + * + * Prevents redirection for feeds, trackbacks, searches, and + * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+, + * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST + * requests. + * + * Will also attempt to find the correct link when a user enters a URL that does + * not exist based on exact WordPress query. Will instead try to parse the URL + * or query in an attempt to figure the correct page to go to. + * + * @since 2.3.0 + * + * @global WP_Rewrite $wp_rewrite + * @global bool $is_IIS + * @global WP_Query $wp_query + * @global wpdb $wpdb WordPress database abstraction object. + * @global WP $wp Current WordPress environment instance. + * + * @param string $requested_url Optional. The URL that was requested, used to + * figure if redirect is needed. + * @param bool $do_redirect Optional. Redirect to the new URL. + * @return string|void The string of the URL, if redirect needed. + */ +function redirect_canonical( $requested_url = null, $do_redirect = true ) { + global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp; + + if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) { + return; + } + + // If we're not in wp-admin and the post has been published and preview nonce + // is non-existent or invalid then no need for preview in query + if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) { + if ( ! isset( $_GET['preview_id'] ) + || ! isset( $_GET['preview_nonce'] ) + || ! wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . (int) $_GET['preview_id'] ) ) { + $wp_query->is_preview = false; + } + } + + if ( is_trackback() || is_search() || is_admin() || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) { + return; + } + + if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) { + // build the URL in the address bar + $requested_url = is_ssl() ? 'https://' : 'http://'; + $requested_url .= $_SERVER['HTTP_HOST']; + $requested_url .= $_SERVER['REQUEST_URI']; + } + + $original = @parse_url($requested_url); + if ( false === $original ) { + return; + } + + $redirect = $original; + $redirect_url = false; + + // Notice fixing + if ( !isset($redirect['path']) ) + $redirect['path'] = ''; + if ( !isset($redirect['query']) ) + $redirect['query'] = ''; + + // If the original URL ended with non-breaking spaces, they were almost + // certainly inserted by accident. Let's remove them, so the reader doesn't + // see a 404 error with no obvious cause. + $redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] ); + + // It's not a preview, so remove it from URL + if ( get_query_var( 'preview' ) ) { + $redirect['query'] = remove_query_arg( 'preview', $redirect['query'] ); + } + + if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) { + if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) { + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed'), $redirect_url ); + $redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH ); + } + } + + if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) { + + $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) ); + + if ( isset($vars[0]) && $vars = $vars[0] ) { + if ( 'revision' == $vars->post_type && $vars->post_parent > 0 ) + $id = $vars->post_parent; + + if ( $redirect_url = get_permalink($id) ) + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); + } + } + + // These tests give us a WP-generated permalink + if ( is_404() ) { + + // Redirect ?page_id, ?p=, ?attachment_id= to their respective url's + $id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') ); + if ( $id && $redirect_post = get_post($id) ) { + $post_type_obj = get_post_type_object($redirect_post->post_type); + if ( $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) { + $redirect_url = get_permalink($redirect_post); + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); + } + } + + if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) ) { + $year = get_query_var( 'year' ); + $month = get_query_var( 'monthnum' ); + $day = get_query_var( 'day' ); + $date = sprintf( '%04d-%02d-%02d', $year, $month, $day ); + if ( ! wp_checkdate( $month, $day, $year, $date ) ) { + $redirect_url = get_month_link( $year, $month ); + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url ); + } + } elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && 12 < get_query_var( 'monthnum' ) ) { + $redirect_url = get_year_link( get_query_var( 'year' ) ); + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url ); + } + + if ( ! $redirect_url ) { + if ( $redirect_url = redirect_guess_404_permalink() ) { + $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url ); + } + } + + if ( get_query_var( 'page' ) && $wp_query->post && + false !== strpos( $wp_query->post->post_content, '<!--nextpage-->' ) ) { + $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); + $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); + $redirect_url = get_permalink( $wp_query->post->ID ); + } + + } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { + // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 + if ( is_attachment() && + ! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) && + ! $redirect_url ) { + if ( ! empty( $_GET['attachment_id'] ) ) { + $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) ); + if ( $redirect_url ) { + $redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] ); + } + } else { + $redirect_url = get_attachment_link(); + } + } elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) { + if ( $redirect_url = get_permalink(get_query_var('p')) ) + $redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']); + } elseif ( is_single() && !empty($_GET['name']) && ! $redirect_url ) { + if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) ) + $redirect['query'] = remove_query_arg('name', $redirect['query']); + } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) { + if ( $redirect_url = get_permalink(get_query_var('page_id')) ) + $redirect['query'] = remove_query_arg('page_id', $redirect['query']); + } elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front') && ! $redirect_url ) { + $redirect_url = home_url('/'); + } elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url ) { + if ( $redirect_url = get_permalink(get_option('page_for_posts')) ) + $redirect['query'] = remove_query_arg('page_id', $redirect['query']); + } elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) { + $m = get_query_var('m'); + switch ( strlen($m) ) { + case 4: // Yearly + $redirect_url = get_year_link($m); + break; + case 6: // Monthly + $redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) ); + break; + case 8: // Daily + $redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2)); + break; + } + if ( $redirect_url ) + $redirect['query'] = remove_query_arg('m', $redirect['query']); + // now moving on to non ?m=X year/month/day links + } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) { + if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) ) + $redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']); + } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) { + if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) ) + $redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']); + } elseif ( is_year() && !empty($_GET['year']) ) { + if ( $redirect_url = get_year_link(get_query_var('year')) ) + $redirect['query'] = remove_query_arg('year', $redirect['query']); + } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { + $author = get_userdata(get_query_var('author')); + if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) { + if ( $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) + $redirect['query'] = remove_query_arg('author', $redirect['query']); + } + } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) + + $term_count = 0; + foreach ( $wp_query->tax_query->queried_terms as $tax_query ) + $term_count += count( $tax_query['terms'] ); + + $obj = $wp_query->get_queried_object(); + if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) { + if ( !empty($redirect['query']) ) { + // Strip taxonomy query vars off the url. + $qv_remove = array( 'term', 'taxonomy'); + if ( is_category() ) { + $qv_remove[] = 'category_name'; + $qv_remove[] = 'cat'; + } elseif ( is_tag() ) { + $qv_remove[] = 'tag'; + $qv_remove[] = 'tag_id'; + } else { // Custom taxonomies will have a custom query var, remove those too: + $tax_obj = get_taxonomy( $obj->taxonomy ); + if ( false !== $tax_obj->query_var ) + $qv_remove[] = $tax_obj->query_var; + } + + $rewrite_vars = array_diff( array_keys($wp_query->query), array_keys($_GET) ); + + if ( !array_diff($rewrite_vars, array_keys($_GET)) ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET + $redirect['query'] = remove_query_arg($qv_remove, $redirect['query']); //Remove all of the per-tax qv's + + // Create the destination url for this taxonomy + $tax_url = parse_url($tax_url); + if ( ! empty($tax_url['query']) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv.. + parse_str($tax_url['query'], $query_vars); + $redirect['query'] = add_query_arg($query_vars, $redirect['query']); + } else { // Taxonomy is accessible via a "pretty-URL" + $redirect['path'] = $tax_url['path']; + } + + } else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite + foreach ( $qv_remove as $_qv ) { + if ( isset($rewrite_vars[$_qv]) ) + $redirect['query'] = remove_query_arg($_qv, $redirect['query']); + } + } + } + + } + } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) { + $category = get_category_by_path( $cat ); + if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) { + $redirect_url = get_permalink($wp_query->get_queried_object_id()); + } + } + + // Post Paging + if ( is_singular() && get_query_var('page') ) { + if ( !$redirect_url ) + $redirect_url = get_permalink( get_queried_object_id() ); + + $page = get_query_var( 'page' ); + if ( $page > 1 ) { + if ( is_front_page() ) { + $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' ); + } else { + $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' ); + } + } + $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); + } + + // paging and feeds + if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) { + while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) { + // Strip off paging and feed + $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging + $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings + $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging + } + + $addl_path = ''; + if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) { + $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; + if ( !is_singular() && get_query_var( 'withcomments' ) ) + $addl_path .= 'comments/'; + if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var('feed') ) || 'rss' == get_query_var('feed') ) + $addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' ); + else + $addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' ); + $redirect['query'] = remove_query_arg( 'feed', $redirect['query'] ); + } elseif ( is_feed() && 'old' == get_query_var('feed') ) { + $old_feed_files = array( + 'wp-atom.php' => 'atom', + 'wp-commentsrss2.php' => 'comments_rss2', + 'wp-feed.php' => get_default_feed(), + 'wp-rdf.php' => 'rdf', + 'wp-rss.php' => 'rss2', + 'wp-rss2.php' => 'rss2', + ); + if ( isset( $old_feed_files[ basename( $redirect['path'] ) ] ) ) { + $redirect_url = get_feed_link( $old_feed_files[ basename( $redirect['path'] ) ] ); + wp_redirect( $redirect_url, 301 ); + die(); + } + } + + if ( get_query_var('paged') > 0 ) { + $paged = get_query_var('paged'); + $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] ); + if ( !is_feed() ) { + if ( $paged > 1 && !is_single() ) { + $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged'); + } elseif ( !is_single() ) { + $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; + } + } elseif ( $paged > 1 ) { + $redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] ); + } + } + + if ( get_option( 'page_comments' ) && ( + ( 'newest' == get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 0 ) || + ( 'newest' != get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 1 ) + ) ) { + $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' ); + $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); + } + + $redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/ + if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false ) + $redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/'; + if ( !empty( $addl_path ) ) + $redirect['path'] = trailingslashit($redirect['path']) . $addl_path; + $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; + } + + if ( 'wp-register.php' == basename( $redirect['path'] ) ) { + if ( is_multisite() ) { + /** This filter is documented in wp-login.php */ + $redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); + } else { + $redirect_url = wp_registration_url(); + } + + wp_redirect( $redirect_url, 301 ); + die(); + } + } + + // tack on any additional query vars + $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); + if ( $redirect_url && !empty($redirect['query']) ) { + parse_str( $redirect['query'], $_parsed_query ); + $redirect = @parse_url($redirect_url); + + if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) { + parse_str( $redirect['query'], $_parsed_redirect_query ); + + if ( empty( $_parsed_redirect_query['name'] ) ) + unset( $_parsed_query['name'] ); + } + + $_parsed_query = rawurlencode_deep( $_parsed_query ); + $redirect_url = add_query_arg( $_parsed_query, $redirect_url ); + } + + if ( $redirect_url ) + $redirect = @parse_url($redirect_url); + + // www.example.com vs example.com + $user_home = @parse_url(home_url()); + if ( !empty($user_home['host']) ) + $redirect['host'] = $user_home['host']; + if ( empty($user_home['path']) ) + $user_home['path'] = '/'; + + // Handle ports + if ( !empty($user_home['port']) ) + $redirect['port'] = $user_home['port']; + else + unset($redirect['port']); + + // trailing /index.php + $redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']); + + $punctuation_pattern = implode( '|', array_map( 'preg_quote', array( + ' ', '%20', // space + '!', '%21', // exclamation mark + '"', '%22', // double quote + "'", '%27', // single quote + '(', '%28', // opening bracket + ')', '%29', // closing bracket + ',', '%2C', // comma + '.', '%2E', // period + ';', '%3B', // semicolon + '{', '%7B', // opening curly bracket + '}', '%7D', // closing curly bracket + '%E2%80%9C', // opening curly quote + '%E2%80%9D', // closing curly quote + ) ) ); + + // Remove trailing spaces and end punctuation from the path. + $redirect['path'] = preg_replace( "#($punctuation_pattern)+$#", '', $redirect['path'] ); + + if ( !empty( $redirect['query'] ) ) { + // Remove trailing spaces and end punctuation from certain terminating query string args. + $redirect['query'] = preg_replace( "#((p|page_id|cat|tag)=[^&]*?)($punctuation_pattern)+$#", '$1', $redirect['query'] ); + + // Clean up empty query strings + $redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&'); + + // Redirect obsolete feeds + $redirect['query'] = preg_replace( '#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query'] ); + + // Remove redundant leading ampersands + $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); + } + + // strip /index.php/ when we're not using PATHINFO permalinks + if ( !$wp_rewrite->using_index_permalinks() ) + $redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] ); + + // trailing slashes + if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) { + $user_ts_type = ''; + if ( get_query_var('paged') > 0 ) { + $user_ts_type = 'paged'; + } else { + foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) { + $func = 'is_' . $type; + if ( call_user_func($func) ) { + $user_ts_type = $type; + break; + } + } + } + $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type); + } elseif ( is_front_page() ) { + $redirect['path'] = trailingslashit($redirect['path']); + } + + // Strip multiple slashes out of the URL + if ( strpos($redirect['path'], '//') > -1 ) + $redirect['path'] = preg_replace('|/+|', '/', $redirect['path']); + + // Always trailing slash the Front Page URL + if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) ) + $redirect['path'] = trailingslashit($redirect['path']); + + // Ignore differences in host capitalization, as this can lead to infinite redirects + // Only redirect no-www <=> yes-www + if ( strtolower($original['host']) == strtolower($redirect['host']) || + ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) ) + $redirect['host'] = $original['host']; + + $compare_original = array( $original['host'], $original['path'] ); + + if ( !empty( $original['port'] ) ) + $compare_original[] = $original['port']; + + if ( !empty( $original['query'] ) ) + $compare_original[] = $original['query']; + + $compare_redirect = array( $redirect['host'], $redirect['path'] ); + + if ( !empty( $redirect['port'] ) ) + $compare_redirect[] = $redirect['port']; + + if ( !empty( $redirect['query'] ) ) + $compare_redirect[] = $redirect['query']; + + if ( $compare_original !== $compare_redirect ) { + $redirect_url = $redirect['scheme'] . '://' . $redirect['host']; + if ( !empty($redirect['port']) ) + $redirect_url .= ':' . $redirect['port']; + $redirect_url .= $redirect['path']; + if ( !empty($redirect['query']) ) + $redirect_url .= '?' . $redirect['query']; + } + + if ( ! $redirect_url || $redirect_url == $requested_url ) { + return; + } + + // Hex encoded octets are case-insensitive. + if ( false !== strpos($requested_url, '%') ) { + if ( !function_exists('lowercase_octets') ) { + /** + * Converts the first hex-encoded octet match to lowercase. + * + * @since 3.1.0 + * @ignore + * + * @param array $matches Hex-encoded octet matches for the requested URL. + * @return string Lowercased version of the first match. + */ + function lowercase_octets($matches) { + return strtolower( $matches[0] ); + } + } + $requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url); + } + + /** + * Filters the canonical redirect URL. + * + * Returning false to this filter will cancel the redirect. + * + * @since 2.3.0 + * + * @param string $redirect_url The redirect URL. + * @param string $requested_url The requested URL. + */ + $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url ); + + // yes, again -- in case the filter aborted the request + if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) == strip_fragment_from_url( $requested_url ) ) { + return; + } + + if ( $do_redirect ) { + // protect against chained redirects + if ( !redirect_canonical($redirect_url, false) ) { + wp_redirect($redirect_url, 301); + exit(); + } else { + // Debug + // die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) ); + return; + } + } else { + return $redirect_url; + } +} + +/** + * Removes arguments from a query string if they are not present in a URL + * DO NOT use this in plugin code. + * + * @since 3.4.0 + * @access private + * + * @param string $query_string + * @param array $args_to_check + * @param string $url + * @return string The altered query string + */ +function _remove_qs_args_if_not_in_url( $query_string, Array $args_to_check, $url ) { + $parsed_url = @parse_url( $url ); + if ( ! empty( $parsed_url['query'] ) ) { + parse_str( $parsed_url['query'], $parsed_query ); + foreach ( $args_to_check as $qv ) { + if ( !isset( $parsed_query[$qv] ) ) + $query_string = remove_query_arg( $qv, $query_string ); + } + } else { + $query_string = remove_query_arg( $args_to_check, $query_string ); + } + return $query_string; +} + +/** + * Strips the #fragment from a URL, if one is present. + * + * @since 4.4.0 + * + * @param string $url The URL to strip. + * @return string The altered URL. + */ +function strip_fragment_from_url( $url ) { + $parsed_url = @parse_url( $url ); + if ( ! empty( $parsed_url['host'] ) ) { + // This mirrors code in redirect_canonical(). It does not handle every case. + $url = $parsed_url['scheme'] . '://' . $parsed_url['host']; + if ( ! empty( $parsed_url['port'] ) ) { + $url .= ':' . $parsed_url['port']; + } + + if ( ! empty( $parsed_url['path'] ) ) { + $url .= $parsed_url['path']; + } + + if ( ! empty( $parsed_url['query'] ) ) { + $url .= '?' . $parsed_url['query']; + } + } + + return $url; +} + +/** + * Attempts to guess the correct URL based on query vars + * + * @since 2.3.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return false|string The correct URL if one is found. False on failure. + */ +function redirect_guess_404_permalink() { + global $wpdb; + + if ( get_query_var('name') ) { + $where = $wpdb->prepare("post_name LIKE %s", $wpdb->esc_like( get_query_var('name') ) . '%'); + + // if any of post_type, year, monthnum, or day are set, use them to refine the query + if ( get_query_var('post_type') ) + $where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type')); + else + $where .= " AND post_type IN ('" . implode( "', '", get_post_types( array( 'public' => true ) ) ) . "')"; + + if ( get_query_var('year') ) + $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year')); + if ( get_query_var('monthnum') ) + $where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum')); + if ( get_query_var('day') ) + $where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day')); + + $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'"); + if ( ! $post_id ) + return false; + if ( get_query_var( 'feed' ) ) + return get_post_comments_feed_link( $post_id, get_query_var( 'feed' ) ); + elseif ( get_query_var( 'page' ) && 1 < get_query_var( 'page' ) ) + return trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' ); + else + return get_permalink( $post_id ); + } + + return false; +} + +/** + * Redirects a variety of shorthand URLs to the admin. + * + * If a user visits example.com/admin, they'll be redirected to /wp-admin. + * Visiting /login redirects to /wp-login.php, and so on. + * + * @since 3.4.0 + * + * @global WP_Rewrite $wp_rewrite + */ +function wp_redirect_admin_locations() { + global $wp_rewrite; + if ( ! ( is_404() && $wp_rewrite->using_permalinks() ) ) + return; + + $admins = array( + home_url( 'wp-admin', 'relative' ), + home_url( 'dashboard', 'relative' ), + home_url( 'admin', 'relative' ), + site_url( 'dashboard', 'relative' ), + site_url( 'admin', 'relative' ), + ); + if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) { + wp_redirect( admin_url() ); + exit; + } + + $logins = array( + home_url( 'wp-login.php', 'relative' ), + home_url( 'login', 'relative' ), + site_url( 'login', 'relative' ), + ); + if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) { + wp_redirect( wp_login_url() ); + exit; + } +} diff --git a/backend/wp-includes/capabilities.php b/backend/wp-includes/capabilities.php new file mode 100644 index 0000000..e71cbfa --- /dev/null +++ b/backend/wp-includes/capabilities.php @@ -0,0 +1,921 @@ +<?php +/** + * Core User Role & Capabilities API + * + * @package WordPress + * @subpackage Users + */ + +/** + * Map meta capabilities to primitive capabilities. + * + * This does not actually compare whether the user ID has the actual capability, + * just what the capability or capabilities are. Meta capability list value can + * be 'delete_user', 'edit_user', 'remove_user', 'promote_user', 'delete_post', + * 'delete_page', 'edit_post', 'edit_page', 'read_post', or 'read_page'. + * + * @since 2.0.0 + * + * @global array $post_type_meta_caps Used to get post type meta capabilities. + * + * @param string $cap Capability name. + * @param int $user_id User ID. + * @param int $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap. + * "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used + * by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts', + * 'edit_others_posts', etc. The parameter is accessed via func_get_args(). + * @return array Actual capabilities for meta capability. + */ +function map_meta_cap( $cap, $user_id ) { + $args = array_slice( func_get_args(), 2 ); + $caps = array(); + + switch ( $cap ) { + case 'remove_user': + // In multisite the user must be a super admin to remove themselves. + if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) { + $caps[] = 'do_not_allow'; + } else { + $caps[] = 'remove_users'; + } + break; + case 'promote_user': + case 'add_users': + $caps[] = 'promote_users'; + break; + case 'edit_user': + case 'edit_users': + // Allow user to edit itself + if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) + break; + + // In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin. + if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) { + $caps[] = 'do_not_allow'; + } else { + $caps[] = 'edit_users'; // edit_user maps to edit_users. + } + break; + case 'delete_post': + case 'delete_page': + $post = get_post( $args[0] ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + } + + if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) { + $caps[] = 'manage_options'; + break; + } + + $post_type = get_post_type_object( $post->post_type ); + if ( ! $post_type ) { + /* translators: 1: post type, 2: capability name */ + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); + $caps[] = 'edit_others_posts'; + break; + } + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'delete_post' == $cap ) + $cap = $post_type->cap->$cap; + break; + } + + // If the post author is set and the user is the author... + if ( $post->post_author && $user_id == $post->post_author ) { + // If the post is published or scheduled... + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->delete_published_posts; + } elseif ( 'trash' == $post->post_status ) { + $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); + if ( in_array( $status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->delete_published_posts; + } else { + $caps[] = $post_type->cap->delete_posts; + } + } else { + // If the post is draft... + $caps[] = $post_type->cap->delete_posts; + } + } else { + // The user is trying to edit someone else's post. + $caps[] = $post_type->cap->delete_others_posts; + // The post is published or scheduled, extra cap required. + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->delete_published_posts; + } elseif ( 'private' == $post->post_status ) { + $caps[] = $post_type->cap->delete_private_posts; + } + } + + /* + * Setting the privacy policy page requires `manage_privacy_options`, + * so deleting it should require that too. + */ + if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) { + $caps = array_merge( $caps, map_meta_cap( 'manage_privacy_options', $user_id ) ); + } + + break; + // edit_post breaks down to edit_posts, edit_published_posts, or + // edit_others_posts + case 'edit_post': + case 'edit_page': + $post = get_post( $args[0] ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + } + + $post_type = get_post_type_object( $post->post_type ); + if ( ! $post_type ) { + /* translators: 1: post type, 2: capability name */ + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); + $caps[] = 'edit_others_posts'; + break; + } + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'edit_post' == $cap ) + $cap = $post_type->cap->$cap; + break; + } + + // If the post author is set and the user is the author... + if ( $post->post_author && $user_id == $post->post_author ) { + // If the post is published or scheduled... + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->edit_published_posts; + } elseif ( 'trash' == $post->post_status ) { + $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); + if ( in_array( $status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->edit_published_posts; + } else { + $caps[] = $post_type->cap->edit_posts; + } + } else { + // If the post is draft... + $caps[] = $post_type->cap->edit_posts; + } + } else { + // The user is trying to edit someone else's post. + $caps[] = $post_type->cap->edit_others_posts; + // The post is published or scheduled, extra cap required. + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { + $caps[] = $post_type->cap->edit_published_posts; + } elseif ( 'private' == $post->post_status ) { + $caps[] = $post_type->cap->edit_private_posts; + } + } + + /* + * Setting the privacy policy page requires `manage_privacy_options`, + * so editing it should require that too. + */ + if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) { + $caps = array_merge( $caps, map_meta_cap( 'manage_privacy_options', $user_id ) ); + } + + break; + case 'read_post': + case 'read_page': + $post = get_post( $args[0] ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + } + + $post_type = get_post_type_object( $post->post_type ); + if ( ! $post_type ) { + /* translators: 1: post type, 2: capability name */ + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); + $caps[] = 'edit_others_posts'; + break; + } + + if ( ! $post_type->map_meta_cap ) { + $caps[] = $post_type->cap->$cap; + // Prior to 3.1 we would re-call map_meta_cap here. + if ( 'read_post' == $cap ) + $cap = $post_type->cap->$cap; + break; + } + + $status_obj = get_post_status_object( $post->post_status ); + if ( $status_obj->public ) { + $caps[] = $post_type->cap->read; + break; + } + + if ( $post->post_author && $user_id == $post->post_author ) { + $caps[] = $post_type->cap->read; + } elseif ( $status_obj->private ) { + $caps[] = $post_type->cap->read_private_posts; + } else { + $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); + } + break; + case 'publish_post': + $post = get_post( $args[0] ); + if ( ! $post ) { + $caps[] = 'do_not_allow'; + break; + } + + $post_type = get_post_type_object( $post->post_type ); + if ( ! $post_type ) { + /* translators: 1: post type, 2: capability name */ + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); + $caps[] = 'edit_others_posts'; + break; + } + + $caps[] = $post_type->cap->publish_posts; + break; + case 'edit_post_meta': + case 'delete_post_meta': + case 'add_post_meta': + case 'edit_comment_meta': + case 'delete_comment_meta': + case 'add_comment_meta': + case 'edit_term_meta': + case 'delete_term_meta': + case 'add_term_meta': + case 'edit_user_meta': + case 'delete_user_meta': + case 'add_user_meta': + list( $_, $object_type, $_ ) = explode( '_', $cap ); + $object_id = (int) $args[0]; + + switch ( $object_type ) { + case 'post': + $post = get_post( $object_id ); + if ( ! $post ) { + break; + } + + $sub_type = get_post_type( $post ); + break; + + case 'comment': + $comment = get_comment( $object_id ); + if ( ! $comment ) { + break; + } + + $sub_type = empty( $comment->comment_type ) ? 'comment' : $comment->comment_type; + break; + + case 'term': + $term = get_term( $object_id ); + if ( ! $term instanceof WP_Term ) { + break; + } + + $sub_type = $term->taxonomy; + break; + + case 'user': + $user = get_user_by( 'id', $object_id ); + if ( ! $user ) { + break; + } + + $sub_type = 'user'; + break; + } + + if ( empty( $sub_type ) ) { + $caps[] = 'do_not_allow'; + break; + } + + $caps = map_meta_cap( "edit_{$object_type}", $user_id, $object_id ); + + $meta_key = isset( $args[1] ) ? $args[1] : false; + + $has_filter = has_filter( "auth_{$object_type}_meta_{$meta_key}" ) || has_filter( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}" ); + if ( $meta_key && $has_filter ) { + + /** + * Filters whether the user is allowed to edit meta. + * + * Use the {@see auth_post_$object_type_meta_$meta_key} filter to modify capabilities for + * specific object types. Return true to have the mapped meta caps from edit_{$object_type} apply. + * + * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. + * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). + * + * @since 3.3.0 As 'auth_post_meta_{$meta_key}'. + * @since 4.6.0 + * + * @param bool $allowed Whether the user can add the post meta. Default false. + * @param string $meta_key The meta key. + * @param int $post_id Post ID. + * @param int $user_id User ID. + * @param string $cap Capability name. + * @param array $caps User capabilities. + */ + $allowed = apply_filters( "auth_{$object_type}_meta_{$meta_key}", false, $meta_key, $object_id, $user_id, $cap, $caps ); + + /** + * Filters whether the user is allowed to add post meta to a post of a given type. + * + * Use the {@see auth_$object_type_$sub_type_meta_$meta_key} filter to modify capabilities for + * specific object types/subtypes. Return true to have the mapped meta caps from edit_{$object_type} apply. + * + * The dynamic portion of the hook name, `$object_type` refers to the object type being filtered. + * The dynamic portion of the hook name, `$sub_type` refers to the object subtype being filtered. + * The dynamic portion of the hook name, `$meta_key`, refers to the meta key passed to map_meta_cap(). + * + * @since 4.6.0 As 'auth_post_{$post_type}_meta_{$meta_key}'. + * @since 4.7.0 + * + * @param bool $allowed Whether the user can add the post meta. Default false. + * @param string $meta_key The meta key. + * @param int $post_id Post ID. + * @param int $user_id User ID. + * @param string $cap Capability name. + * @param array $caps User capabilities. + */ + $allowed = apply_filters( "auth_{$object_type}_{$sub_type}_meta_{$meta_key}", $allowed, $meta_key, $object_id, $user_id, $cap, $caps ); + + if ( ! $allowed ) { + $caps[] = $cap; + } + } elseif ( $meta_key && is_protected_meta( $meta_key, $object_type ) ) { + $caps[] = $cap; + } + break; + case 'edit_comment': + $comment = get_comment( $args[0] ); + if ( ! $comment ) { + $caps[] = 'do_not_allow'; + break; + } + + $post = get_post( $comment->comment_post_ID ); + + /* + * If the post doesn't exist, we have an orphaned comment. + * Fall back to the edit_posts capability, instead. + */ + if ( $post ) { + $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); + } else { + $caps = map_meta_cap( 'edit_posts', $user_id ); + } + break; + case 'unfiltered_upload': + if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) + $caps[] = $cap; + else + $caps[] = 'do_not_allow'; + break; + case 'edit_css' : + case 'unfiltered_html' : + // Disallow unfiltered_html for all users, even admins and super admins. + if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) + $caps[] = 'do_not_allow'; + elseif ( is_multisite() && ! is_super_admin( $user_id ) ) + $caps[] = 'do_not_allow'; + else + $caps[] = 'unfiltered_html'; + break; + case 'edit_files': + case 'edit_plugins': + case 'edit_themes': + // Disallow the file editors. + if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) + $caps[] = 'do_not_allow'; + elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) ) + $caps[] = 'do_not_allow'; + elseif ( is_multisite() && ! is_super_admin( $user_id ) ) + $caps[] = 'do_not_allow'; + else + $caps[] = $cap; + break; + case 'update_plugins': + case 'delete_plugins': + case 'install_plugins': + case 'upload_plugins': + case 'update_themes': + case 'delete_themes': + case 'install_themes': + case 'upload_themes': + case 'update_core': + // Disallow anything that creates, deletes, or updates core, plugin, or theme files. + // Files in uploads are excepted. + if ( ! wp_is_file_mod_allowed( 'capability_update_core' ) ) { + $caps[] = 'do_not_allow'; + } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { + $caps[] = 'do_not_allow'; + } elseif ( 'upload_themes' === $cap ) { + $caps[] = 'install_themes'; + } elseif ( 'upload_plugins' === $cap ) { + $caps[] = 'install_plugins'; + } else { + $caps[] = $cap; + } + break; + case 'install_languages': + case 'update_languages': + if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) { + $caps[] = 'do_not_allow'; + } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { + $caps[] = 'do_not_allow'; + } else { + $caps[] = 'install_languages'; + } + break; + case 'activate_plugins': + case 'deactivate_plugins': + case 'activate_plugin': + case 'deactivate_plugin': + $caps[] = 'activate_plugins'; + if ( is_multisite() ) { + // update_, install_, and delete_ are handled above with is_super_admin(). + $menu_perms = get_site_option( 'menu_items', array() ); + if ( empty( $menu_perms['plugins'] ) ) + $caps[] = 'manage_network_plugins'; + } + break; + case 'delete_user': + case 'delete_users': + // If multisite only super admins can delete users. + if ( is_multisite() && ! is_super_admin( $user_id ) ) + $caps[] = 'do_not_allow'; + else + $caps[] = 'delete_users'; // delete_user maps to delete_users. + break; + case 'create_users': + if ( !is_multisite() ) + $caps[] = $cap; + elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) + $caps[] = $cap; + else + $caps[] = 'do_not_allow'; + break; + case 'manage_links' : + if ( get_option( 'link_manager_enabled' ) ) + $caps[] = $cap; + else + $caps[] = 'do_not_allow'; + break; + case 'customize' : + $caps[] = 'edit_theme_options'; + break; + case 'delete_site': + if ( is_multisite() ) { + $caps[] = 'manage_options'; + } else { + $caps[] = 'do_not_allow'; + } + break; + case 'edit_term': + case 'delete_term': + case 'assign_term': + $term_id = (int) $args[0]; + $term = get_term( $term_id ); + if ( ! $term || is_wp_error( $term ) ) { + $caps[] = 'do_not_allow'; + break; + } + + $tax = get_taxonomy( $term->taxonomy ); + if ( ! $tax ) { + $caps[] = 'do_not_allow'; + break; + } + + if ( 'delete_term' === $cap && ( $term->term_id == get_option( 'default_' . $term->taxonomy ) ) ) { + $caps[] = 'do_not_allow'; + break; + } + + $taxo_cap = $cap . 's'; + + $caps = map_meta_cap( $tax->cap->$taxo_cap, $user_id, $term_id ); + + break; + case 'manage_post_tags': + case 'edit_categories': + case 'edit_post_tags': + case 'delete_categories': + case 'delete_post_tags': + $caps[] = 'manage_categories'; + break; + case 'assign_categories': + case 'assign_post_tags': + $caps[] = 'edit_posts'; + break; + case 'create_sites': + case 'delete_sites': + case 'manage_network': + case 'manage_sites': + case 'manage_network_users': + case 'manage_network_plugins': + case 'manage_network_themes': + case 'manage_network_options': + case 'upgrade_network': + $caps[] = $cap; + break; + case 'setup_network': + if ( is_multisite() ) { + $caps[] = 'manage_network_options'; + } else { + $caps[] = 'manage_options'; + } + break; + case 'export_others_personal_data': + case 'erase_others_personal_data': + case 'manage_privacy_options': + $caps[] = is_multisite() ? 'manage_network' : 'manage_options'; + break; + default: + // Handle meta capabilities for custom post types. + global $post_type_meta_caps; + if ( isset( $post_type_meta_caps[ $cap ] ) ) { + $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); + return call_user_func_array( 'map_meta_cap', $args ); + } + + // If no meta caps match, return the original cap. + $caps[] = $cap; + } + + /** + * Filters a user's capabilities depending on specific context and/or privilege. + * + * @since 2.8.0 + * + * @param array $caps Returns the user's actual capabilities. + * @param string $cap Capability name. + * @param int $user_id The user ID. + * @param array $args Adds the context to the cap. Typically the object ID. + */ + return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args ); +} + +/** + * Whether the current user has a specific capability. + * + * While checking against particular roles in place of a capability is supported + * in part, this practice is discouraged as it may produce unreliable results. + * + * Note: Will always return true if the current user is a super admin, unless specifically denied. + * + * @since 2.0.0 + * + * @see WP_User::has_cap() + * @see map_meta_cap() + * + * @param string $capability Capability name. + * @param int $object_id Optional. ID of the specific object to check against if `$capability` is a "meta" cap. + * "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used + * by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts', + * 'edit_others_posts', etc. Accessed via func_get_args() and passed to WP_User::has_cap(), + * then map_meta_cap(). + * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is + * passed, whether the current user has the given meta capability for the given object. + */ +function current_user_can( $capability ) { + $current_user = wp_get_current_user(); + + if ( empty( $current_user ) ) + return false; + + $args = array_slice( func_get_args(), 1 ); + $args = array_merge( array( $capability ), $args ); + + return call_user_func_array( array( $current_user, 'has_cap' ), $args ); +} + +/** + * Whether the current user has a specific capability for a given site. + * + * @since 3.0.0 + * + * @param int $blog_id Site ID. + * @param string $capability Capability name. + * @return bool Whether the user has the given capability. + */ +function current_user_can_for_blog( $blog_id, $capability ) { + $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; + + $current_user = wp_get_current_user(); + + if ( empty( $current_user ) ) { + if ( $switched ) { + restore_current_blog(); + } + return false; + } + + $args = array_slice( func_get_args(), 2 ); + $args = array_merge( array( $capability ), $args ); + + $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); + + if ( $switched ) { + restore_current_blog(); + } + + return $can; +} + +/** + * Whether the author of the supplied post has a specific capability. + * + * @since 2.9.0 + * + * @param int|WP_Post $post Post ID or post object. + * @param string $capability Capability name. + * @return bool Whether the post author has the given capability. + */ +function author_can( $post, $capability ) { + if ( !$post = get_post($post) ) + return false; + + $author = get_userdata( $post->post_author ); + + if ( ! $author ) + return false; + + $args = array_slice( func_get_args(), 2 ); + $args = array_merge( array( $capability ), $args ); + + return call_user_func_array( array( $author, 'has_cap' ), $args ); +} + +/** + * Whether a particular user has a specific capability. + * + * @since 3.1.0 + * + * @param int|WP_User $user User ID or object. + * @param string $capability Capability name. + * @return bool Whether the user has the given capability. + */ +function user_can( $user, $capability ) { + if ( ! is_object( $user ) ) + $user = get_userdata( $user ); + + if ( ! $user || ! $user->exists() ) + return false; + + $args = array_slice( func_get_args(), 2 ); + $args = array_merge( array( $capability ), $args ); + + return call_user_func_array( array( $user, 'has_cap' ), $args ); +} + +/** + * Retrieves the global WP_Roles instance and instantiates it if necessary. + * + * @since 4.3.0 + * + * @global WP_Roles $wp_roles WP_Roles global instance. + * + * @return WP_Roles WP_Roles global instance if not already instantiated. + */ +function wp_roles() { + global $wp_roles; + + if ( ! isset( $wp_roles ) ) { + $wp_roles = new WP_Roles(); + } + return $wp_roles; +} + +/** + * Retrieve role object. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @return WP_Role|null WP_Role object if found, null if the role does not exist. + */ +function get_role( $role ) { + return wp_roles()->get_role( $role ); +} + +/** + * Add role, if it does not exist. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @param string $display_name Display name for role. + * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false ); + * @return WP_Role|null WP_Role object if role is added, null if already exists. + */ +function add_role( $role, $display_name, $capabilities = array() ) { + if ( empty( $role ) ) { + return; + } + return wp_roles()->add_role( $role, $display_name, $capabilities ); +} + +/** + * Remove role, if it exists. + * + * @since 2.0.0 + * + * @param string $role Role name. + */ +function remove_role( $role ) { + wp_roles()->remove_role( $role ); +} + +/** + * Retrieve a list of super admins. + * + * @since 3.0.0 + * + * @global array $super_admins + * + * @return array List of super admin logins + */ +function get_super_admins() { + global $super_admins; + + if ( isset($super_admins) ) + return $super_admins; + else + return get_site_option( 'site_admins', array('admin') ); +} + +/** + * Determine if user is a site admin. + * + * @since 3.0.0 + * + * @param int $user_id (Optional) The ID of a user. Defaults to the current user. + * @return bool True if the user is a site admin. + */ +function is_super_admin( $user_id = false ) { + if ( ! $user_id || $user_id == get_current_user_id() ) + $user = wp_get_current_user(); + else + $user = get_userdata( $user_id ); + + if ( ! $user || ! $user->exists() ) + return false; + + if ( is_multisite() ) { + $super_admins = get_super_admins(); + if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) + return true; + } else { + if ( $user->has_cap('delete_users') ) + return true; + } + + return false; +} + +/** + * Grants Super Admin privileges. + * + * @since 3.0.0 + * + * @global array $super_admins + * + * @param int $user_id ID of the user to be granted Super Admin privileges. + * @return bool True on success, false on failure. This can fail when the user is + * already a super admin or when the `$super_admins` global is defined. + */ +function grant_super_admin( $user_id ) { + // If global super_admins override is defined, there is nothing to do here. + if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) { + return false; + } + + /** + * Fires before the user is granted Super Admin privileges. + * + * @since 3.0.0 + * + * @param int $user_id ID of the user that is about to be granted Super Admin privileges. + */ + do_action( 'grant_super_admin', $user_id ); + + // Directly fetch site_admins instead of using get_super_admins() + $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); + + $user = get_userdata( $user_id ); + if ( $user && ! in_array( $user->user_login, $super_admins ) ) { + $super_admins[] = $user->user_login; + update_site_option( 'site_admins' , $super_admins ); + + /** + * Fires after the user is granted Super Admin privileges. + * + * @since 3.0.0 + * + * @param int $user_id ID of the user that was granted Super Admin privileges. + */ + do_action( 'granted_super_admin', $user_id ); + return true; + } + return false; +} + +/** + * Revokes Super Admin privileges. + * + * @since 3.0.0 + * + * @global array $super_admins + * + * @param int $user_id ID of the user Super Admin privileges to be revoked from. + * @return bool True on success, false on failure. This can fail when the user's email + * is the network admin email or when the `$super_admins` global is defined. + */ +function revoke_super_admin( $user_id ) { + // If global super_admins override is defined, there is nothing to do here. + if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) { + return false; + } + + /** + * Fires before the user's Super Admin privileges are revoked. + * + * @since 3.0.0 + * + * @param int $user_id ID of the user Super Admin privileges are being revoked from. + */ + do_action( 'revoke_super_admin', $user_id ); + + // Directly fetch site_admins instead of using get_super_admins() + $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); + + $user = get_userdata( $user_id ); + if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) { + if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { + unset( $super_admins[$key] ); + update_site_option( 'site_admins', $super_admins ); + + /** + * Fires after the user's Super Admin privileges are revoked. + * + * @since 3.0.0 + * + * @param int $user_id ID of the user Super Admin privileges were revoked from. + */ + do_action( 'revoked_super_admin', $user_id ); + return true; + } + } + return false; +} + +/** + * Filters the user capabilities to grant the 'install_languages' capability as necessary. + * + * A user must have at least one out of the 'update_core', 'install_plugins', and + * 'install_themes' capabilities to qualify for 'install_languages'. + * + * @since 4.9.0 + * + * @param array $allcaps An array of all the user's capabilities. + * @return array Filtered array of the user's capabilities. + */ +function wp_maybe_grant_install_languages_cap( $allcaps ) { + if ( ! empty( $allcaps['update_core'] ) || ! empty( $allcaps['install_plugins'] ) || ! empty( $allcaps['install_themes'] ) ) { + $allcaps['install_languages'] = true; + } + + return $allcaps; +} diff --git a/backend/wp-includes/category-template.php b/backend/wp-includes/category-template.php new file mode 100644 index 0000000..e090fac --- /dev/null +++ b/backend/wp-includes/category-template.php @@ -0,0 +1,1415 @@ +<?php +/** + * Taxonomy API: Core category-specific template tags + * + * @package WordPress + * @subpackage Template + * @since 1.2.0 + */ + +/** + * Retrieve category link URL. + * + * @since 1.0.0 + * @see get_term_link() + * + * @param int|object $category Category ID or object. + * @return string Link on success, empty string if category does not exist. + */ +function get_category_link( $category ) { + if ( ! is_object( $category ) ) + $category = (int) $category; + + $category = get_term_link( $category ); + + if ( is_wp_error( $category ) ) + return ''; + + return $category; +} + +/** + * Retrieve category parents with separator. + * + * @since 1.2.0 + * @since 4.8.0 The `$visited` parameter was deprecated and renamed to `$deprecated`. + * + * @param int $id Category ID. + * @param bool $link Optional, default is false. Whether to format with link. + * @param string $separator Optional, default is '/'. How to separate categories. + * @param bool $nicename Optional, default is false. Whether to use nice name for display. + * @param array $deprecated Not used. + * @return string|WP_Error A list of category parents on success, WP_Error on failure. + */ +function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $deprecated = array() ) { + + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __FUNCTION__, '4.8.0' ); + } + + $format = $nicename ? 'slug' : 'name'; + + $args = array( + 'separator' => $separator, + 'link' => $link, + 'format' => $format, + ); + + return get_term_parents_list( $id, 'category', $args ); +} + +/** + * Retrieve post categories. + * + * This tag may be used outside The Loop by passing a post id as the parameter. + * + * Note: This function only returns results from the default "category" taxonomy. + * For custom taxonomies use get_the_terms(). + * + * @since 0.71 + * + * @param int $id Optional, default to current post ID. The post ID. + * @return array Array of WP_Term objects, one for each category assigned to the post. + */ +function get_the_category( $id = false ) { + $categories = get_the_terms( $id, 'category' ); + if ( ! $categories || is_wp_error( $categories ) ) + $categories = array(); + + $categories = array_values( $categories ); + + foreach ( array_keys( $categories ) as $key ) { + _make_cat_compat( $categories[$key] ); + } + + /** + * Filters the array of categories to return for a post. + * + * @since 3.1.0 + * @since 4.4.0 Added `$id` parameter. + * + * @param array $categories An array of categories to return for the post. + * @param int $id ID of the post. + */ + return apply_filters( 'get_the_categories', $categories, $id ); +} + +/** + * Retrieve category name based on category ID. + * + * @since 0.71 + * + * @param int $cat_ID Category ID. + * @return string|WP_Error Category name on success, WP_Error on failure. + */ +function get_the_category_by_ID( $cat_ID ) { + $cat_ID = (int) $cat_ID; + $category = get_term( $cat_ID ); + + if ( is_wp_error( $category ) ) + return $category; + + return ( $category ) ? $category->name : ''; +} + +/** + * Retrieve category list for a post in either HTML list or custom format. + * + * @since 1.5.1 + * + * @global WP_Rewrite $wp_rewrite + * + * @param string $separator Optional. Separator between the categories. By default, the links are placed + * in an unordered list. An empty string will result in the default behavior. + * @param string $parents Optional. How to display the parents. + * @param int $post_id Optional. Post ID to retrieve categories. + * @return string + */ +function get_the_category_list( $separator = '', $parents = '', $post_id = false ) { + global $wp_rewrite; + if ( ! is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) { + /** This filter is documented in wp-includes/category-template.php */ + return apply_filters( 'the_category', '', $separator, $parents ); + } + + /** + * Filters the categories before building the category list. + * + * @since 4.4.0 + * + * @param array $categories An array of the post's categories. + * @param int|bool $post_id ID of the post we're retrieving categories for. When `false`, we assume the + * current post in the loop. + */ + $categories = apply_filters( 'the_category_list', get_the_category( $post_id ), $post_id ); + + if ( empty( $categories ) ) { + /** This filter is documented in wp-includes/category-template.php */ + return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents ); + } + + $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; + + $thelist = ''; + if ( '' == $separator ) { + $thelist .= '<ul class="post-categories">'; + foreach ( $categories as $category ) { + $thelist .= "\n\t<li>"; + switch ( strtolower( $parents ) ) { + case 'multiple': + if ( $category->parent ) + $thelist .= get_category_parents( $category->parent, true, $separator ); + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>'; + break; + case 'single': + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>'; + if ( $category->parent ) + $thelist .= get_category_parents( $category->parent, false, $separator ); + $thelist .= $category->name.'</a></li>'; + break; + case '': + default: + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>'; + } + } + $thelist .= '</ul>'; + } else { + $i = 0; + foreach ( $categories as $category ) { + if ( 0 < $i ) + $thelist .= $separator; + switch ( strtolower( $parents ) ) { + case 'multiple': + if ( $category->parent ) + $thelist .= get_category_parents( $category->parent, true, $separator ); + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>'; + break; + case 'single': + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>'; + if ( $category->parent ) + $thelist .= get_category_parents( $category->parent, false, $separator ); + $thelist .= "$category->name</a>"; + break; + case '': + default: + $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>'; + } + ++$i; + } + } + + /** + * Filters the category or list of categories. + * + * @since 1.2.0 + * + * @param string $thelist List of categories for the current post. + * @param string $separator Separator used between the categories. + * @param string $parents How to display the category parents. Accepts 'multiple', + * 'single', or empty. + */ + return apply_filters( 'the_category', $thelist, $separator, $parents ); +} + +/** + * Check if the current post is within any of the given categories. + * + * The given categories are checked against the post's categories' term_ids, names and slugs. + * Categories given as integers will only be checked against the post's categories' term_ids. + * + * Prior to v2.5 of WordPress, category names were not supported. + * Prior to v2.7, category slugs were not supported. + * Prior to v2.7, only one category could be compared: in_category( $single_category ). + * Prior to v2.7, this function could only be used in the WordPress Loop. + * As of 2.7, the function can be used anywhere if it is provided a post ID or post object. + * + * @since 1.2.0 + * + * @param int|string|array $category Category ID, name or slug, or array of said. + * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0) + * @return bool True if the current post is in any of the given categories. + */ +function in_category( $category, $post = null ) { + if ( empty( $category ) ) + return false; + + return has_category( $category, $post ); +} + +/** + * Display category list for a post in either HTML list or custom format. + * + * @since 0.71 + * + * @param string $separator Optional. Separator between the categories. By default, the links are placed + * in an unordered list. An empty string will result in the default behavior. + * @param string $parents Optional. How to display the parents. + * @param int $post_id Optional. Post ID to retrieve categories. + */ +function the_category( $separator = '', $parents = '', $post_id = false ) { + echo get_the_category_list( $separator, $parents, $post_id ); +} + +/** + * Retrieve category description. + * + * @since 1.0.0 + * + * @param int $category Optional. Category ID. Will use global category ID by default. + * @return string Category description, available. + */ +function category_description( $category = 0 ) { + return term_description( $category, 'category' ); +} + +/** + * Display or retrieve the HTML dropdown list of categories. + * + * The 'hierarchical' argument, which is disabled by default, will override the + * depth argument, unless it is true. When the argument is false, it will + * display all of the categories. When it is enabled it will use the value in + * the 'depth' argument. + * + * @since 2.1.0 + * @since 4.2.0 Introduced the `value_field` argument. + * @since 4.6.0 Introduced the `required` argument. + * + * @param string|array $args { + * Optional. Array or string of arguments to generate a categories drop-down element. See WP_Term_Query::__construct() + * for information on additional accepted arguments. + * + * @type string $show_option_all Text to display for showing all categories. Default empty. + * @type string $show_option_none Text to display for showing no categories. Default empty. + * @type string $option_none_value Value to use when no category is selected. Default empty. + * @type string $orderby Which column to use for ordering categories. See get_terms() for a list + * of accepted values. Default 'id' (term_id). + * @type bool $pad_counts See get_terms() for an argument description. Default false. + * @type bool|int $show_count Whether to include post counts. Accepts 0, 1, or their bool equivalents. + * Default 0. + * @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their + * bool equivalents. Default 1. + * @type bool|int $hierarchical Whether to traverse the taxonomy hierarchy. Accepts 0, 1, or their bool + * equivalents. Default 0. + * @type int $depth Maximum depth. Default 0. + * @type int $tab_index Tab index for the select element. Default 0 (no tabindex). + * @type string $name Value for the 'name' attribute of the select element. Default 'cat'. + * @type string $id Value for the 'id' attribute of the select element. Defaults to the value + * of `$name`. + * @type string $class Value for the 'class' attribute of the select element. Default 'postform'. + * @type int|string $selected Value of the option that should be selected. Default 0. + * @type string $value_field Term field that should be used to populate the 'value' attribute + * of the option elements. Accepts any valid term field: 'term_id', 'name', + * 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', + * 'parent', 'count'. Default 'term_id'. + * @type string|array $taxonomy Name of the category or categories to retrieve. Default 'category'. + * @type bool $hide_if_empty True to skip generating markup if no categories are found. + * Default false (create select element even if no categories are found). + * @type bool $required Whether the `<select>` element should have the HTML5 'required' attribute. + * Default false. + * } + * @return string HTML content only if 'echo' argument is 0. + */ +function wp_dropdown_categories( $args = '' ) { + $defaults = array( + 'show_option_all' => '', + 'show_option_none' => '', + 'orderby' => 'id', + 'order' => 'ASC', + 'show_count' => 0, + 'hide_empty' => 1, + 'child_of' => 0, + 'exclude' => '', + 'echo' => 1, + 'selected' => 0, + 'hierarchical' => 0, + 'name' => 'cat', + 'id' => '', + 'class' => 'postform', + 'depth' => 0, + 'tab_index' => 0, + 'taxonomy' => 'category', + 'hide_if_empty' => false, + 'option_none_value' => -1, + 'value_field' => 'term_id', + 'required' => false, + ); + + $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; + + // Back compat. + if ( isset( $args['type'] ) && 'link' == $args['type'] ) { + _deprecated_argument( __FUNCTION__, '3.0.0', + /* translators: 1: "type => link", 2: "taxonomy => link_category" */ + sprintf( __( '%1$s is deprecated. Use %2$s instead.' ), + '<code>type => link</code>', + '<code>taxonomy => link_category</code>' + ) + ); + $args['taxonomy'] = 'link_category'; + } + + $r = wp_parse_args( $args, $defaults ); + $option_none_value = $r['option_none_value']; + + if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { + $r['pad_counts'] = true; + } + + $tab_index = $r['tab_index']; + + $tab_index_attribute = ''; + if ( (int) $tab_index > 0 ) { + $tab_index_attribute = " tabindex=\"$tab_index\""; + } + + // Avoid clashes with the 'name' param of get_terms(). + $get_terms_args = $r; + unset( $get_terms_args['name'] ); + $categories = get_terms( $r['taxonomy'], $get_terms_args ); + + $name = esc_attr( $r['name'] ); + $class = esc_attr( $r['class'] ); + $id = $r['id'] ? esc_attr( $r['id'] ) : $name; + $required = $r['required'] ? 'required' : ''; + + if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) { + $output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n"; + } else { + $output = ''; + } + if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) { + + /** + * Filters a taxonomy drop-down display element. + * + * A variety of taxonomy drop-down display elements can be modified + * just prior to display via this filter. Filterable arguments include + * 'show_option_none', 'show_option_all', and various forms of the + * term name. + * + * @since 1.2.0 + * + * @see wp_dropdown_categories() + * + * @param string $element Category name. + * @param WP_Term|null $category The category object, or null if there's no corresponding category. + */ + $show_option_none = apply_filters( 'list_cats', $r['show_option_none'], null ); + $output .= "\t<option value='" . esc_attr( $option_none_value ) . "' selected='selected'>$show_option_none</option>\n"; + } + + if ( ! empty( $categories ) ) { + + if ( $r['show_option_all'] ) { + + /** This filter is documented in wp-includes/category-template.php */ + $show_option_all = apply_filters( 'list_cats', $r['show_option_all'], null ); + $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : ''; + $output .= "\t<option value='0'$selected>$show_option_all</option>\n"; + } + + if ( $r['show_option_none'] ) { + + /** This filter is documented in wp-includes/category-template.php */ + $show_option_none = apply_filters( 'list_cats', $r['show_option_none'], null ); + $selected = selected( $option_none_value, $r['selected'], false ); + $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$selected>$show_option_none</option>\n"; + } + + if ( $r['hierarchical'] ) { + $depth = $r['depth']; // Walk the full depth. + } else { + $depth = -1; // Flat. + } + $output .= walk_category_dropdown_tree( $categories, $depth, $r ); + } + + if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) { + $output .= "</select>\n"; + } + /** + * Filters the taxonomy drop-down output. + * + * @since 2.1.0 + * + * @param string $output HTML output. + * @param array $r Arguments used to build the drop-down. + */ + $output = apply_filters( 'wp_dropdown_cats', $output, $r ); + + if ( $r['echo'] ) { + echo $output; + } + return $output; +} + +/** + * Display or retrieve the HTML list of categories. + * + * @since 2.1.0 + * @since 4.4.0 Introduced the `hide_title_if_empty` and `separator` arguments. The `current_category` argument was modified to + * optionally accept an array of values. + * + * @param string|array $args { + * Array of optional arguments. + * + * @type int $child_of Term ID to retrieve child terms of. See get_terms(). Default 0. + * @type int|array $current_category ID of category, or array of IDs of categories, that should get the + * 'current-cat' class. Default 0. + * @type int $depth Category depth. Used for tab indentation. Default 0. + * @type bool|int $echo True to echo markup, false to return it. Default 1. + * @type array|string $exclude Array or comma/space-separated string of term IDs to exclude. + * If `$hierarchical` is true, descendants of `$exclude` terms will also + * be excluded; see `$exclude_tree`. See get_terms(). + * Default empty string. + * @type array|string $exclude_tree Array or comma/space-separated string of term IDs to exclude, along + * with their descendants. See get_terms(). Default empty string. + * @type string $feed Text to use for the feed link. Default 'Feed for all posts filed + * under [cat name]'. + * @type string $feed_image URL of an image to use for the feed link. Default empty string. + * @type string $feed_type Feed type. Used to build feed link. See get_term_feed_link(). + * Default empty string (default feed). + * @type bool|int $hide_empty Whether to hide categories that don't have any posts attached to them. + * Default 1. + * @type bool $hide_title_if_empty Whether to hide the `$title_li` element if there are no terms in + * the list. Default false (title will always be shown). + * @type bool $hierarchical Whether to include terms that have non-empty descendants. + * See get_terms(). Default true. + * @type string $order Which direction to order categories. Accepts 'ASC' or 'DESC'. + * Default 'ASC'. + * @type string $orderby The column to use for ordering categories. Default 'name'. + * @type string $separator Separator between links. Default '<br />'. + * @type bool|int $show_count Whether to show how many posts are in the category. Default 0. + * @type string $show_option_all Text to display for showing all categories. Default empty string. + * @type string $show_option_none Text to display for the 'no categories' option. + * Default 'No categories'. + * @type string $style The style used to display the categories list. If 'list', categories + * will be output as an unordered list. If left empty or another value, + * categories will be output separated by `<br>` tags. Default 'list'. + * @type string $taxonomy Taxonomy name. Default 'category'. + * @type string $title_li Text to use for the list title `<li>` element. Pass an empty string + * to disable. Default 'Categories'. + * @type bool|int $use_desc_for_title Whether to use the category description as the title attribute. + * Default 1. + * } + * @return false|string HTML content only if 'echo' argument is 0. + */ +function wp_list_categories( $args = '' ) { + $defaults = array( + 'child_of' => 0, + 'current_category' => 0, + 'depth' => 0, + 'echo' => 1, + 'exclude' => '', + 'exclude_tree' => '', + 'feed' => '', + 'feed_image' => '', + 'feed_type' => '', + 'hide_empty' => 1, + 'hide_title_if_empty' => false, + 'hierarchical' => true, + 'order' => 'ASC', + 'orderby' => 'name', + 'separator' => '<br />', + 'show_count' => 0, + 'show_option_all' => '', + 'show_option_none' => __( 'No categories' ), + 'style' => 'list', + 'taxonomy' => 'category', + 'title_li' => __( 'Categories' ), + 'use_desc_for_title' => 1, + ); + + $r = wp_parse_args( $args, $defaults ); + + if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) + $r['pad_counts'] = true; + + // Descendants of exclusions should be excluded too. + if ( true == $r['hierarchical'] ) { + $exclude_tree = array(); + + if ( $r['exclude_tree'] ) { + $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude_tree'] ) ); + } + + if ( $r['exclude'] ) { + $exclude_tree = array_merge( $exclude_tree, wp_parse_id_list( $r['exclude'] ) ); + } + + $r['exclude_tree'] = $exclude_tree; + $r['exclude'] = ''; + } + + if ( ! isset( $r['class'] ) ) + $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy']; + + if ( ! taxonomy_exists( $r['taxonomy'] ) ) { + return false; + } + + $show_option_all = $r['show_option_all']; + $show_option_none = $r['show_option_none']; + + $categories = get_categories( $r ); + + $output = ''; + if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) { + $output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>'; + } + if ( empty( $categories ) ) { + if ( ! empty( $show_option_none ) ) { + if ( 'list' == $r['style'] ) { + $output .= '<li class="cat-item-none">' . $show_option_none . '</li>'; + } else { + $output .= $show_option_none; + } + } + } else { + if ( ! empty( $show_option_all ) ) { + + $posts_page = ''; + + // For taxonomies that belong only to custom post types, point to a valid archive. + $taxonomy_object = get_taxonomy( $r['taxonomy'] ); + if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) { + foreach ( $taxonomy_object->object_type as $object_type ) { + $_object_type = get_post_type_object( $object_type ); + + // Grab the first one. + if ( ! empty( $_object_type->has_archive ) ) { + $posts_page = get_post_type_archive_link( $object_type ); + break; + } + } + } + + // Fallback for the 'All' link is the posts page. + if ( ! $posts_page ) { + if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) { + $posts_page = get_permalink( get_option( 'page_for_posts' ) ); + } else { + $posts_page = home_url( '/' ); + } + } + + $posts_page = esc_url( $posts_page ); + if ( 'list' == $r['style'] ) { + $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>"; + } else { + $output .= "<a href='$posts_page'>$show_option_all</a>"; + } + } + + if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) { + $current_term_object = get_queried_object(); + if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) { + $r['current_category'] = get_queried_object_id(); + } + } + + if ( $r['hierarchical'] ) { + $depth = $r['depth']; + } else { + $depth = -1; // Flat. + } + $output .= walk_category_tree( $categories, $depth, $r ); + } + + if ( $r['title_li'] && 'list' == $r['style'] && ( ! empty( $categories ) || ! $r['hide_title_if_empty'] ) ) { + $output .= '</ul></li>'; + } + + /** + * Filters the HTML output of a taxonomy list. + * + * @since 2.1.0 + * + * @param string $output HTML output. + * @param array $args An array of taxonomy-listing arguments. + */ + $html = apply_filters( 'wp_list_categories', $output, $args ); + + if ( $r['echo'] ) { + echo $html; + } else { + return $html; + } +} + +/** + * Display tag cloud. + * + * The text size is set by the 'smallest' and 'largest' arguments, which will + * use the 'unit' argument value for the CSS text size unit. The 'format' + * argument can be 'flat' (default), 'list', or 'array'. The flat value for the + * 'format' argument will separate tags with spaces. The list value for the + * 'format' argument will format the tags in a UL HTML list. The array value for + * the 'format' argument will return in PHP array type format. + * + * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'. + * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'. + * + * The 'number' argument is how many tags to return. By default, the limit will + * be to return the top 45 tags in the tag cloud list. + * + * The 'topic_count_text' argument is a nooped plural from _n_noop() to generate the + * text for the tag link count. + * + * The 'topic_count_text_callback' argument is a function, which given the count + * of the posts with that tag returns a text for the tag link count. + * + * The 'post_type' argument is used only when 'link' is set to 'edit'. It determines the post_type + * passed to edit.php for the popular tags edit links. + * + * The 'exclude' and 'include' arguments are used for the get_tags() function. Only one + * should be used, because only one will be used and the other ignored, if they are both set. + * + * @since 2.3.0 + * @since 4.8.0 Added the `show_count` argument. + * + * @param array|string|null $args Optional. Override default arguments. + * @return void|array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument. + * Otherwise, this function outputs the tag cloud. + */ +function wp_tag_cloud( $args = '' ) { + $defaults = array( + 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, + 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', + 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true, + 'show_count' => 0, + ); + $args = wp_parse_args( $args, $defaults ); + + $tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags + + if ( empty( $tags ) || is_wp_error( $tags ) ) + return; + + foreach ( $tags as $key => $tag ) { + if ( 'edit' == $args['link'] ) + $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] ); + else + $link = get_term_link( intval($tag->term_id), $tag->taxonomy ); + if ( is_wp_error( $link ) ) + return; + + $tags[ $key ]->link = $link; + $tags[ $key ]->id = $tag->term_id; + } + + $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args + + /** + * Filters the tag cloud output. + * + * @since 2.3.0 + * + * @param string $return HTML output of the tag cloud. + * @param array $args An array of tag cloud arguments. + */ + $return = apply_filters( 'wp_tag_cloud', $return, $args ); + + if ( 'array' == $args['format'] || empty($args['echo']) ) + return $return; + + echo $return; +} + +/** + * Default topic count scaling for tag links. + * + * @since 2.9.0 + * + * @param int $count Number of posts with that tag. + * @return int Scaled count. + */ +function default_topic_count_scale( $count ) { + return round(log10($count + 1) * 100); +} + +/** + * Generates a tag cloud (heatmap) from provided data. + * + * @todo Complete functionality. + * @since 2.3.0 + * @since 4.8.0 Added the `show_count` argument. + * + * @param array $tags List of tags. + * @param string|array $args { + * Optional. Array of string of arguments for generating a tag cloud. + * + * @type int $smallest Smallest font size used to display tags. Paired + * with the value of `$unit`, to determine CSS text + * size unit. Default 8 (pt). + * @type int $largest Largest font size used to display tags. Paired + * with the value of `$unit`, to determine CSS text + * size unit. Default 22 (pt). + * @type string $unit CSS text size unit to use with the `$smallest` + * and `$largest` values. Accepts any valid CSS text + * size unit. Default 'pt'. + * @type int $number The number of tags to return. Accepts any + * positive integer or zero to return all. + * Default 0. + * @type string $format Format to display the tag cloud in. Accepts 'flat' + * (tags separated with spaces), 'list' (tags displayed + * in an unordered list), or 'array' (returns an array). + * Default 'flat'. + * @type string $separator HTML or text to separate the tags. Default "\n" (newline). + * @type string $orderby Value to order tags by. Accepts 'name' or 'count'. + * Default 'name'. The {@see 'tag_cloud_sort'} filter + * can also affect how tags are sorted. + * @type string $order How to order the tags. Accepts 'ASC' (ascending), + * 'DESC' (descending), or 'RAND' (random). Default 'ASC'. + * @type int|bool $filter Whether to enable filtering of the final output + * via {@see 'wp_generate_tag_cloud'}. Default 1|true. + * @type string $topic_count_text Nooped plural text from _n_noop() to supply to + * tag counts. Default null. + * @type callable $topic_count_text_callback Callback used to generate nooped plural text for + * tag counts based on the count. Default null. + * @type callable $topic_count_scale_callback Callback used to determine the tag count scaling + * value. Default default_topic_count_scale(). + * @type bool|int $show_count Whether to display the tag counts. Default 0. Accepts + * 0, 1, or their bool equivalents. + * } + * @return string|array Tag cloud as a string or an array, depending on 'format' argument. + */ +function wp_generate_tag_cloud( $tags, $args = '' ) { + $defaults = array( + 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0, + 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', + 'topic_count_text' => null, 'topic_count_text_callback' => null, + 'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1, + 'show_count' => 0, + ); + + $args = wp_parse_args( $args, $defaults ); + + $return = ( 'array' === $args['format'] ) ? array() : ''; + + if ( empty( $tags ) ) { + return $return; + } + + // Juggle topic counts. + if ( isset( $args['topic_count_text'] ) ) { + // First look for nooped plural support via topic_count_text. + $translate_nooped_plural = $args['topic_count_text']; + } elseif ( ! empty( $args['topic_count_text_callback'] ) ) { + // Look for the alternative callback style. Ignore the previous default. + if ( $args['topic_count_text_callback'] === 'default_topic_count_text' ) { + $translate_nooped_plural = _n_noop( '%s item', '%s items' ); + } else { + $translate_nooped_plural = false; + } + } elseif ( isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { + // If no callback exists, look for the old-style single_text and multiple_text arguments. + $translate_nooped_plural = _n_noop( $args['single_text'], $args['multiple_text'] ); + } else { + // This is the default for when no callback, plural, or argument is passed in. + $translate_nooped_plural = _n_noop( '%s item', '%s items' ); + } + + /** + * Filters how the items in a tag cloud are sorted. + * + * @since 2.8.0 + * + * @param array $tags Ordered array of terms. + * @param array $args An array of tag cloud arguments. + */ + $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args ); + if ( empty( $tags_sorted ) ) { + return $return; + } + + if ( $tags_sorted !== $tags ) { + $tags = $tags_sorted; + unset( $tags_sorted ); + } else { + if ( 'RAND' === $args['order'] ) { + shuffle( $tags ); + } else { + // SQL cannot save you; this is a second (potentially different) sort on a subset of data. + if ( 'name' === $args['orderby'] ) { + uasort( $tags, '_wp_object_name_sort_cb' ); + } else { + uasort( $tags, '_wp_object_count_sort_cb' ); + } + + if ( 'DESC' === $args['order'] ) { + $tags = array_reverse( $tags, true ); + } + } + } + + if ( $args['number'] > 0 ) + $tags = array_slice( $tags, 0, $args['number'] ); + + $counts = array(); + $real_counts = array(); // For the alt tag + foreach ( (array) $tags as $key => $tag ) { + $real_counts[ $key ] = $tag->count; + $counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count ); + } + + $min_count = min( $counts ); + $spread = max( $counts ) - $min_count; + if ( $spread <= 0 ) + $spread = 1; + $font_spread = $args['largest'] - $args['smallest']; + if ( $font_spread < 0 ) + $font_spread = 1; + $font_step = $font_spread / $spread; + + $aria_label = false; + /* + * Determine whether to output an 'aria-label' attribute with the tag name and count. + * When tags have a different font size, they visually convey an important information + * that should be available to assistive technologies too. On the other hand, sometimes + * themes set up the Tag Cloud to display all tags with the same font size (setting + * the 'smallest' and 'largest' arguments to the same value). + * In order to always serve the same content to all users, the 'aria-label' gets printed out: + * - when tags have a different size + * - when the tag count is displayed (for example when users check the checkbox in the + * Tag Cloud widget), regardless of the tags font size + */ + if ( $args['show_count'] || 0 !== $font_spread ) { + $aria_label = true; + } + + // Assemble the data that will be used to generate the tag cloud markup. + $tags_data = array(); + foreach ( $tags as $key => $tag ) { + $tag_id = isset( $tag->id ) ? $tag->id : $key; + + $count = $counts[ $key ]; + $real_count = $real_counts[ $key ]; + + if ( $translate_nooped_plural ) { + $formatted_count = sprintf( translate_nooped_plural( $translate_nooped_plural, $real_count ), number_format_i18n( $real_count ) ); + } else { + $formatted_count = call_user_func( $args['topic_count_text_callback'], $real_count, $tag, $args ); + } + + $tags_data[] = array( + 'id' => $tag_id, + 'url' => '#' != $tag->link ? $tag->link : '#', + 'role' => '#' != $tag->link ? '' : ' role="button"', + 'name' => $tag->name, + 'formatted_count' => $formatted_count, + 'slug' => $tag->slug, + 'real_count' => $real_count, + 'class' => 'tag-cloud-link tag-link-' . $tag_id, + 'font_size' => $args['smallest'] + ( $count - $min_count ) * $font_step, + 'aria_label' => $aria_label ? sprintf( ' aria-label="%1$s (%2$s)"', esc_attr( $tag->name ), esc_attr( $formatted_count ) ) : '', + 'show_count' => $args['show_count'] ? '<span class="tag-link-count"> (' . $real_count . ')</span>' : '', + ); + } + + /** + * Filters the data used to generate the tag cloud. + * + * @since 4.3.0 + * + * @param array $tags_data An array of term data for term used to generate the tag cloud. + */ + $tags_data = apply_filters( 'wp_generate_tag_cloud_data', $tags_data ); + + $a = array(); + + // Generate the output links array. + foreach ( $tags_data as $key => $tag_data ) { + $class = $tag_data['class'] . ' tag-link-position-' . ( $key + 1 ); + $a[] = sprintf( + '<a href="%1$s"%2$s class="%3$s" style="font-size: %4$s;"%5$s>%6$s%7$s</a>', + esc_url( $tag_data['url'] ), + $tag_data['role'], + esc_attr( $class ), + esc_attr( str_replace( ',', '.', $tag_data['font_size'] ) . $args['unit'] ), + $tag_data['aria_label'], + esc_html( $tag_data['name'] ), + $tag_data['show_count'] + ); + } + + switch ( $args['format'] ) { + case 'array' : + $return =& $a; + break; + case 'list' : + /* + * Force role="list", as some browsers (sic: Safari 10) don't expose to assistive + * technologies the default role when the list is styled with `list-style: none`. + * Note: this is redundant but doesn't harm. + */ + $return = "<ul class='wp-tag-cloud' role='list'>\n\t<li>"; + $return .= join( "</li>\n\t<li>", $a ); + $return .= "</li>\n</ul>\n"; + break; + default : + $return = join( $args['separator'], $a ); + break; + } + + if ( $args['filter'] ) { + /** + * Filters the generated output of a tag cloud. + * + * The filter is only evaluated if a true value is passed + * to the $filter argument in wp_generate_tag_cloud(). + * + * @since 2.3.0 + * + * @see wp_generate_tag_cloud() + * + * @param array|string $return String containing the generated HTML tag cloud output + * or an array of tag links if the 'format' argument + * equals 'array'. + * @param array $tags An array of terms used in the tag cloud. + * @param array $args An array of wp_generate_tag_cloud() arguments. + */ + return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args ); + } + + else + return $return; +} + +/** + * Serves as a callback for comparing objects based on name. + * + * Used with `uasort()`. + * + * @since 3.1.0 + * @access private + * + * @param object $a The first object to compare. + * @param object $b The second object to compare. + * @return int Negative number if `$a->name` is less than `$b->name`, zero if they are equal, + * or greater than zero if `$a->name` is greater than `$b->name`. + */ +function _wp_object_name_sort_cb( $a, $b ) { + return strnatcasecmp( $a->name, $b->name ); +} + +/** + * Serves as a callback for comparing objects based on count. + * + * Used with `uasort()`. + * + * @since 3.1.0 + * @access private + * + * @param object $a The first object to compare. + * @param object $b The second object to compare. + * @return bool Whether the count value for `$a` is greater than the count value for `$b`. + */ +function _wp_object_count_sort_cb( $a, $b ) { + return ( $a->count > $b->count ); +} + +// +// Helper functions +// + +/** + * Retrieve HTML list content for category list. + * + * @uses Walker_Category to create HTML list content. + * @since 2.1.0 + * @see Walker_Category::walk() for parameters and return description. + * @return string + */ +function walk_category_tree() { + $args = func_get_args(); + // the user's options are the third parameter + if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { + $walker = new Walker_Category; + } else { + $walker = $args[2]['walker']; + } + return call_user_func_array( array( $walker, 'walk' ), $args ); +} + +/** + * Retrieve HTML dropdown (select) content for category list. + * + * @uses Walker_CategoryDropdown to create HTML dropdown content. + * @since 2.1.0 + * @see Walker_CategoryDropdown::walk() for parameters and return description. + * @return string + */ +function walk_category_dropdown_tree() { + $args = func_get_args(); + // the user's options are the third parameter + if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { + $walker = new Walker_CategoryDropdown; + } else { + $walker = $args[2]['walker']; + } + return call_user_func_array( array( $walker, 'walk' ), $args ); +} + +// +// Tags +// + +/** + * Retrieve the link to the tag. + * + * @since 2.3.0 + * @see get_term_link() + * + * @param int|object $tag Tag ID or object. + * @return string Link on success, empty string if tag does not exist. + */ +function get_tag_link( $tag ) { + return get_category_link( $tag ); +} + +/** + * Retrieve the tags for a post. + * + * @since 2.3.0 + * + * @param int $id Post ID. + * @return array|false|WP_Error Array of tag objects on success, false on failure. + */ +function get_the_tags( $id = 0 ) { + + /** + * Filters the array of tags for the given post. + * + * @since 2.3.0 + * + * @see get_the_terms() + * + * @param array $terms An array of tags for the given post. + */ + return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) ); +} + +/** + * Retrieve the tags for a post formatted as a string. + * + * @since 2.3.0 + * + * @param string $before Optional. Before tags. + * @param string $sep Optional. Between tags. + * @param string $after Optional. After tags. + * @param int $id Optional. Post ID. Defaults to the current post. + * @return string|false|WP_Error A list of tags on success, false if there are no terms, WP_Error on failure. + */ +function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) { + + /** + * Filters the tags list for a given post. + * + * @since 2.3.0 + * + * @param string $tag_list List of tags. + * @param string $before String to use before tags. + * @param string $sep String to use between the tags. + * @param string $after String to use after tags. + * @param int $id Post ID. + */ + return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id ); +} + +/** + * Retrieve the tags for a post. + * + * @since 2.3.0 + * + * @param string $before Optional. Before list. + * @param string $sep Optional. Separate items using this. + * @param string $after Optional. After list. + */ +function the_tags( $before = null, $sep = ', ', $after = '' ) { + if ( null === $before ) + $before = __('Tags: '); + + $the_tags = get_the_tag_list( $before, $sep, $after ); + + if ( ! is_wp_error( $the_tags ) ) { + echo $the_tags; + } +} + +/** + * Retrieve tag description. + * + * @since 2.8.0 + * + * @param int $tag Optional. Tag ID. Will use global tag ID by default. + * @return string Tag description, available. + */ +function tag_description( $tag = 0 ) { + return term_description( $tag ); +} + +/** + * Retrieve term description. + * + * @since 2.8.0 + * @since 4.9.2 The `$taxonomy` parameter was deprecated. + * + * @param int $term Optional. Term ID. Will use global term ID by default. + * @param null $deprecated Deprecated argument. + * @return string Term description, available. + */ +function term_description( $term = 0, $deprecated = null ) { + if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) { + $term = get_queried_object(); + if ( $term ) { + $term = $term->term_id; + } + } + $description = get_term_field( 'description', $term ); + return is_wp_error( $description ) ? '' : $description; +} + +/** + * Retrieve the terms of the taxonomy that are attached to the post. + * + * @since 2.5.0 + * + * @param int|object $post Post ID or object. + * @param string $taxonomy Taxonomy name. + * @return array|false|WP_Error Array of WP_Term objects on success, false if there are no terms + * or the post does not exist, WP_Error on failure. + */ +function get_the_terms( $post, $taxonomy ) { + if ( ! $post = get_post( $post ) ) + return false; + + $terms = get_object_term_cache( $post->ID, $taxonomy ); + if ( false === $terms ) { + $terms = wp_get_object_terms( $post->ID, $taxonomy ); + if ( ! is_wp_error( $terms ) ) { + $term_ids = wp_list_pluck( $terms, 'term_id' ); + wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' ); + } + } + + /** + * Filters the list of terms attached to the given post. + * + * @since 3.1.0 + * + * @param array|WP_Error $terms List of attached terms, or WP_Error on failure. + * @param int $post_id Post ID. + * @param string $taxonomy Name of the taxonomy. + */ + $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); + + if ( empty( $terms ) ) + return false; + + return $terms; +} + +/** + * Retrieve a post's terms as a list with specified format. + * + * @since 2.5.0 + * + * @param int $id Post ID. + * @param string $taxonomy Taxonomy name. + * @param string $before Optional. Before list. + * @param string $sep Optional. Separate items using this. + * @param string $after Optional. After list. + * @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure. + */ +function get_the_term_list( $id, $taxonomy, $before = '', $sep = '', $after = '' ) { + $terms = get_the_terms( $id, $taxonomy ); + + if ( is_wp_error( $terms ) ) + return $terms; + + if ( empty( $terms ) ) + return false; + + $links = array(); + + foreach ( $terms as $term ) { + $link = get_term_link( $term, $taxonomy ); + if ( is_wp_error( $link ) ) { + return $link; + } + $links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>'; + } + + /** + * Filters the term links for a given taxonomy. + * + * The dynamic portion of the filter name, `$taxonomy`, refers + * to the taxonomy slug. + * + * @since 2.5.0 + * + * @param array $links An array of term links. + */ + $term_links = apply_filters( "term_links-{$taxonomy}", $links ); + + return $before . join( $sep, $term_links ) . $after; +} + +/** + * Retrieve term parents with separator. + * + * @since 4.8.0 + * + * @param int $term_id Term ID. + * @param string $taxonomy Taxonomy name. + * @param string|array $args { + * Array of optional arguments. + * + * @type string $format Use term names or slugs for display. Accepts 'name' or 'slug'. + * Default 'name'. + * @type string $separator Separator for between the terms. Default '/'. + * @type bool $link Whether to format as a link. Default true. + * @type bool $inclusive Include the term to get the parents for. Default true. + * } + * @return string|WP_Error A list of term parents on success, WP_Error or empty string on failure. + */ +function get_term_parents_list( $term_id, $taxonomy, $args = array() ) { + $list = ''; + $term = get_term( $term_id, $taxonomy ); + + if ( is_wp_error( $term ) ) { + return $term; + } + + if ( ! $term ) { + return $list; + } + + $term_id = $term->term_id; + + $defaults = array( + 'format' => 'name', + 'separator' => '/', + 'link' => true, + 'inclusive' => true, + ); + + $args = wp_parse_args( $args, $defaults ); + + foreach ( array( 'link', 'inclusive' ) as $bool ) { + $args[ $bool ] = wp_validate_boolean( $args[ $bool ] ); + } + + $parents = get_ancestors( $term_id, $taxonomy, 'taxonomy' ); + + if ( $args['inclusive'] ) { + array_unshift( $parents, $term_id ); + } + + foreach ( array_reverse( $parents ) as $term_id ) { + $parent = get_term( $term_id, $taxonomy ); + $name = ( 'slug' === $args['format'] ) ? $parent->slug : $parent->name; + + if ( $args['link'] ) { + $list .= '<a href="' . esc_url( get_term_link( $parent->term_id, $taxonomy ) ) . '">' . $name . '</a>' . $args['separator']; + } else { + $list .= $name . $args['separator']; + } + } + + return $list; +} + +/** + * Display the terms in a list. + * + * @since 2.5.0 + * + * @param int $id Post ID. + * @param string $taxonomy Taxonomy name. + * @param string $before Optional. Before list. + * @param string $sep Optional. Separate items using this. + * @param string $after Optional. After list. + * @return false|void False on WordPress error. + */ +function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { + $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after ); + + if ( is_wp_error( $term_list ) ) + return false; + + /** + * Filters the list of terms to display. + * + * @since 2.9.0 + * + * @param array $term_list List of terms to display. + * @param string $taxonomy The taxonomy name. + * @param string $before String to use before the terms. + * @param string $sep String to use between the terms. + * @param string $after String to use after the terms. + */ + echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after ); +} + +/** + * Check if the current post has any of given category. + * + * @since 3.1.0 + * + * @param string|int|array $category Optional. The category name/term_id/slug or array of them to check for. + * @param int|object $post Optional. Post to check instead of the current post. + * @return bool True if the current post has any of the given categories (or any category, if no category specified). + */ +function has_category( $category = '', $post = null ) { + return has_term( $category, 'category', $post ); +} + +/** + * Check if the current post has any of given tags. + * + * The given tags are checked against the post's tags' term_ids, names and slugs. + * Tags given as integers will only be checked against the post's tags' term_ids. + * If no tags are given, determines if post has any tags. + * + * Prior to v2.7 of WordPress, tags given as integers would also be checked against the post's tags' names and slugs (in addition to term_ids) + * Prior to v2.7, this function could only be used in the WordPress Loop. + * As of 2.7, the function can be used anywhere if it is provided a post ID or post object. + * + * @since 2.6.0 + * + * @param string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for. + * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0) + * @return bool True if the current post has any of the given tags (or any tag, if no tag specified). + */ +function has_tag( $tag = '', $post = null ) { + return has_term( $tag, 'post_tag', $post ); +} + +/** + * Check if the current post has any of given terms. + * + * The given terms are checked against the post's terms' term_ids, names and slugs. + * Terms given as integers will only be checked against the post's terms' term_ids. + * If no terms are given, determines if post has any terms. + * + * @since 3.1.0 + * + * @param string|int|array $term Optional. The term name/term_id/slug or array of them to check for. + * @param string $taxonomy Taxonomy name + * @param int|object $post Optional. Post to check instead of the current post. + * @return bool True if the current post has any of the given tags (or any tag, if no tag specified). + */ +function has_term( $term = '', $taxonomy = '', $post = null ) { + $post = get_post($post); + + if ( !$post ) + return false; + + $r = is_object_in_term( $post->ID, $taxonomy, $term ); + if ( is_wp_error( $r ) ) + return false; + + return $r; +} diff --git a/backend/wp-includes/category.php b/backend/wp-includes/category.php new file mode 100644 index 0000000..5b990d3 --- /dev/null +++ b/backend/wp-includes/category.php @@ -0,0 +1,360 @@ +<?php +/** + * Taxonomy API: Core category-specific functionality + * + * @package WordPress + * @subpackage Taxonomy + */ + +/** + * Retrieve list of category objects. + * + * If you change the type to 'link' in the arguments, then the link categories + * will be returned instead. Also all categories will be updated to be backward + * compatible with pre-2.3 plugins and themes. + * + * @since 2.1.0 + * @see get_terms() Type of arguments that can be changed. + * + * @param string|array $args { + * Optional. Arguments to retrieve categories. See get_terms() for additional options. + * + * @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'. + * } + * @return array List of categories. + */ +function get_categories( $args = '' ) { + $defaults = array( 'taxonomy' => 'category' ); + $args = wp_parse_args( $args, $defaults ); + + $taxonomy = $args['taxonomy']; + + /** + * Filters the taxonomy used to retrieve terms when calling get_categories(). + * + * @since 2.7.0 + * + * @param string $taxonomy Taxonomy to retrieve terms from. + * @param array $args An array of arguments. See get_terms(). + */ + $taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args ); + + // Back compat + if ( isset($args['type']) && 'link' == $args['type'] ) { + _deprecated_argument( __FUNCTION__, '3.0.0', + /* translators: 1: "type => link", 2: "taxonomy => link_category" */ + sprintf( __( '%1$s is deprecated. Use %2$s instead.' ), + '<code>type => link</code>', + '<code>taxonomy => link_category</code>' + ) + ); + $taxonomy = $args['taxonomy'] = 'link_category'; + } + + $categories = get_terms( $taxonomy, $args ); + + if ( is_wp_error( $categories ) ) { + $categories = array(); + } else { + $categories = (array) $categories; + foreach ( array_keys( $categories ) as $k ) { + _make_cat_compat( $categories[ $k ] ); + } + } + + return $categories; +} + +/** + * Retrieves category data given a category ID or category object. + * + * If you pass the $category parameter an object, which is assumed to be the + * category row object retrieved the database. It will cache the category data. + * + * If you pass $category an integer of the category ID, then that category will + * be retrieved from the database, if it isn't already cached, and pass it back. + * + * If you look at get_term(), then both types will be passed through several + * filters and finally sanitized based on the $filter parameter value. + * + * The category will converted to maintain backward compatibility. + * + * @since 1.5.1 + * + * @param int|object $category Category ID or Category row object + * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a + * WP_Term object, an associative array, or a numeric array, respectively. Default OBJECT. + * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. + * @return object|array|WP_Error|null Category data in type defined by $output parameter. + * WP_Error if $category is empty, null if it does not exist. + */ +function get_category( $category, $output = OBJECT, $filter = 'raw' ) { + $category = get_term( $category, 'category', $output, $filter ); + + if ( is_wp_error( $category ) ) + return $category; + + _make_cat_compat( $category ); + + return $category; +} + +/** + * Retrieve category based on URL containing the category slug. + * + * Breaks the $category_path parameter up to get the category slug. + * + * Tries to find the child path and will return it. If it doesn't find a + * match, then it will return the first category matching slug, if $full_match, + * is set to false. If it does not, then it will return null. + * + * It is also possible that it will return a WP_Error object on failure. Check + * for it when using this function. + * + * @since 2.1.0 + * + * @param string $category_path URL containing category slugs. + * @param bool $full_match Optional. Whether full path should be matched. + * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to + * a WP_Term object, an associative array, or a numeric array, respectively. Default OBJECT. + * @return WP_Term|array|WP_Error|null Type is based on $output value. + */ +function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) { + $category_path = rawurlencode( urldecode( $category_path ) ); + $category_path = str_replace( '%2F', '/', $category_path ); + $category_path = str_replace( '%20', ' ', $category_path ); + $category_paths = '/' . trim( $category_path, '/' ); + $leaf_path = sanitize_title( basename( $category_paths ) ); + $category_paths = explode( '/', $category_paths ); + $full_path = ''; + foreach ( (array) $category_paths as $pathdir ) { + $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir ); + } + $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) ); + + if ( empty( $categories ) ) { + return; + } + + foreach ( $categories as $category ) { + $path = '/' . $leaf_path; + $curcategory = $category; + while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) { + $curcategory = get_term( $curcategory->parent, 'category' ); + if ( is_wp_error( $curcategory ) ) { + return $curcategory; + } + $path = '/' . $curcategory->slug . $path; + } + + if ( $path == $full_path ) { + $category = get_term( $category->term_id, 'category', $output ); + _make_cat_compat( $category ); + return $category; + } + } + + // If full matching is not required, return the first cat that matches the leaf. + if ( ! $full_match ) { + $category = get_term( reset( $categories )->term_id, 'category', $output ); + _make_cat_compat( $category ); + return $category; + } +} + +/** + * Retrieve category object by category slug. + * + * @since 2.3.0 + * + * @param string $slug The category slug. + * @return object Category data object + */ +function get_category_by_slug( $slug ) { + $category = get_term_by( 'slug', $slug, 'category' ); + if ( $category ) + _make_cat_compat( $category ); + + return $category; +} + +/** + * Retrieve the ID of a category from its name. + * + * @since 1.0.0 + * + * @param string $cat_name Category name. + * @return int 0, if failure and ID of category on success. + */ +function get_cat_ID( $cat_name ) { + $cat = get_term_by( 'name', $cat_name, 'category' ); + if ( $cat ) + return $cat->term_id; + return 0; +} + +/** + * Retrieve the name of a category from its ID. + * + * @since 1.0.0 + * + * @param int $cat_id Category ID + * @return string Category name, or an empty string if category doesn't exist. + */ +function get_cat_name( $cat_id ) { + $cat_id = (int) $cat_id; + $category = get_term( $cat_id, 'category' ); + if ( ! $category || is_wp_error( $category ) ) + return ''; + return $category->name; +} + +/** + * Check if a category is an ancestor of another category. + * + * You can use either an id or the category object for both parameters. If you + * use an integer the category will be retrieved. + * + * @since 2.1.0 + * + * @param int|object $cat1 ID or object to check if this is the parent category. + * @param int|object $cat2 The child category. + * @return bool Whether $cat2 is child of $cat1 + */ +function cat_is_ancestor_of( $cat1, $cat2 ) { + return term_is_ancestor_of( $cat1, $cat2, 'category' ); +} + +/** + * Sanitizes category data based on context. + * + * @since 2.3.0 + * + * @param object|array $category Category data + * @param string $context Optional. Default is 'display'. + * @return object|array Same type as $category with sanitized data for safe use. + */ +function sanitize_category( $category, $context = 'display' ) { + return sanitize_term( $category, 'category', $context ); +} + +/** + * Sanitizes data in single category key field. + * + * @since 2.3.0 + * + * @param string $field Category key to sanitize + * @param mixed $value Category value to sanitize + * @param int $cat_id Category ID + * @param string $context What filter to use, 'raw', 'display', etc. + * @return mixed Same type as $value after $value has been sanitized. + */ +function sanitize_category_field( $field, $value, $cat_id, $context ) { + return sanitize_term_field( $field, $value, $cat_id, 'category', $context ); +} + +/* Tags */ + +/** + * Retrieves all post tags. + * + * @since 2.3.0 + * @see get_terms() For list of arguments to pass. + * + * @param string|array $args Tag arguments to use when retrieving tags. + * @return array List of tags. + */ +function get_tags( $args = '' ) { + $tags = get_terms( 'post_tag', $args ); + + if ( empty( $tags ) ) { + $return = array(); + return $return; + } + + /** + * Filters the array of term objects returned for the 'post_tag' taxonomy. + * + * @since 2.3.0 + * + * @param array $tags Array of 'post_tag' term objects. + * @param array $args An array of arguments. @see get_terms() + */ + $tags = apply_filters( 'get_tags', $tags, $args ); + return $tags; +} + +/** + * Retrieve post tag by tag ID or tag object. + * + * If you pass the $tag parameter an object, which is assumed to be the tag row + * object retrieved the database. It will cache the tag data. + * + * If you pass $tag an integer of the tag ID, then that tag will + * be retrieved from the database, if it isn't already cached, and pass it back. + * + * If you look at get_term(), then both types will be passed through several + * filters and finally sanitized based on the $filter parameter value. + * + * @since 2.3.0 + * + * @param int|WP_Term|object $tag A tag ID or object. + * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to + * a WP_Term object, an associative array, or a numeric array, respectively. Default OBJECT. + * @param string $filter Optional. Default is raw or no WordPress defined filter will applied. + * @return WP_Term|array|WP_Error|null Tag data in type defined by $output parameter. WP_Error if $tag is empty, null if it does not exist. + */ +function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) { + return get_term( $tag, 'post_tag', $output, $filter ); +} + +/* Cache */ + +/** + * Remove the category cache data based on ID. + * + * @since 2.1.0 + * + * @param int $id Category ID + */ +function clean_category_cache( $id ) { + clean_term_cache( $id, 'category' ); +} + +/** + * Update category structure to old pre 2.3 from new taxonomy structure. + * + * This function was added for the taxonomy support to update the new category + * structure with the old category one. This will maintain compatibility with + * plugins and themes which depend on the old key or property names. + * + * The parameter should only be passed a variable and not create the array or + * object inline to the parameter. The reason for this is that parameter is + * passed by reference and PHP will fail unless it has the variable. + * + * There is no return value, because everything is updated on the variable you + * pass to it. This is one of the features with using pass by reference in PHP. + * + * @since 2.3.0 + * @since 4.4.0 The `$category` parameter now also accepts a WP_Term object. + * @access private + * + * @param array|object|WP_Term $category Category Row object or array + */ +function _make_cat_compat( &$category ) { + if ( is_object( $category ) && ! is_wp_error( $category ) ) { + $category->cat_ID = $category->term_id; + $category->category_count = $category->count; + $category->category_description = $category->description; + $category->cat_name = $category->name; + $category->category_nicename = $category->slug; + $category->category_parent = $category->parent; + } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) { + $category['cat_ID'] = &$category['term_id']; + $category['category_count'] = &$category['count']; + $category['category_description'] = &$category['description']; + $category['cat_name'] = &$category['name']; + $category['category_nicename'] = &$category['slug']; + $category['category_parent'] = &$category['parent']; + } +} diff --git a/backend/wp-includes/certificates/ca-bundle.crt b/backend/wp-includes/certificates/ca-bundle.crt new file mode 100644 index 0000000..2ae3a97 --- /dev/null +++ b/backend/wp-includes/certificates/ca-bundle.crt @@ -0,0 +1,4327 @@ +## +## Bundle of CA Root Certificates +## +## Certificate data from Mozilla as of: Wed Sep 16 08:58:11 2015 +## Includes a WordPress Modification - We include the 'legacy' 1024bit certificates +## for backward compatibility. See https://core.trac.wordpress.org/ticket/34935#comment:10 +## +## This is a bundle of X.509 certificates of public Certificate Authorities +## (CA). These were automatically extracted from Mozilla's root certificates +## file (certdata.txt). This file can be found in the mozilla source tree: +## http://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt +## +## It contains the certificates in PEM format and therefore +## can be directly used with curl / libcurl / php_curl, or with +## an Apache+mod_ssl webserver for SSL client authentication. +## Just configure this file as the SSLCACertificateFile. +## +## Conversion done with mk-ca-bundle.pl version 1.25. +## SHA1: ed3c0bbfb7912bcc00cd2033b0cb85c98d10559c +## + +GTE CyberTrust Global Root +========================== +-----BEGIN CERTIFICATE----- +MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYDVQQKEw9HVEUg +Q29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNvbHV0aW9ucywgSW5jLjEjMCEG +A1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJvb3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEz +MjM1OTAwWjB1MQswCQYDVQQGEwJVUzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQL +Ex5HVEUgQ3liZXJUcnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0 +IEdsb2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrHiM3dFw4u +sJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTSr41tiGeA5u2ylc9yMcql +HHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X404Wqk2kmhXBIgD8SFcd5tB8FLztimQID +AQABMA0GCSqGSIb3DQEBBAUAA4GBAG3rGwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMW +M4ETCJ57NE7fQMh017l93PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OF +NMQkpw0PlZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ +-----END CERTIFICATE----- + +Thawte Server CA +================ +-----BEGIN CERTIFICATE----- +MIIDEzCCAnygAwIBAgIBATANBgkqhkiG9w0BAQQFADCBxDELMAkGA1UEBhMCWkExFTATBgNVBAgT +DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs +dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcGA1UE +AxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0ZS5j +b20wHhcNOTYwODAxMDAwMDAwWhcNMjAxMjMxMjM1OTU5WjCBxDELMAkGA1UEBhMCWkExFTATBgNV +BAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29u +c3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEZMBcG +A1UEAxMQVGhhd3RlIFNlcnZlciBDQTEmMCQGCSqGSIb3DQEJARYXc2VydmVyLWNlcnRzQHRoYXd0 +ZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANOkUG7I/1Zr5s9dtuoMaHVHoqrC2oQl +/Kj0R1HahbUgdJSGHg91yekIYfUGbTBuFRkC6VLAYttNmZ7iagxEOM3+vuNkCXDF/rFrKbYvScg7 +1CcEJRCXL+eQbcAoQpnXTEPew/UhbVSfXcNY4cDk2VuwuNy0e982OsK1ZiIS1ocNAgMBAAGjEzAR +MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAB/pMaVz7lcxG7oWDTSEwjsrZqG9J +GubaUeNgcGyEYRGhGshIPllDfU+VPaGLtwtimHp1it2ITk6eQNuozDJ0uW8NxuOzRAvZim+aKZuZ +GCg70eNAKJpaPNW15yAbi8qkq43pUdniTCxZqdq5snUb9kLy78fyGPmJvKP/iiMucEc= +-----END CERTIFICATE----- + +Thawte Premium Server CA +======================== +-----BEGIN CERTIFICATE----- +MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkExFTATBgNVBAgT +DFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3Vs +dGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UE +AxMYVGhhd3RlIFByZW1pdW0gU2VydmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZl +ckB0aGF3dGUuY29tMB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYT +AlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU +VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2 +aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNlcnZlciBDQTEoMCYGCSqGSIb3DQEJARYZ +cHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2 +aovXwlue2oFBYo847kkEVdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIh +Udib0GfQug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMRuHM/ +qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQAm +SCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUIhfzJATj/Tb7yFkJD57taRvvBxhEf +8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JMpAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7t +UCemDaYj+bvLpgcUQg== +-----END CERTIFICATE----- + +Equifax Secure CA +================= +-----BEGIN CERTIFICATE----- +MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJVUzEQMA4GA1UE +ChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5 +MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoT +B0VxdWlmYXgxLTArBgNVBAsTJEVxdWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCB +nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPR +fM6fBeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+AcJkVV5MW +8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kCAwEAAaOCAQkwggEFMHAG +A1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UE +CxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoG +A1UdEAQTMBGBDzIwMTgwODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvS +spXXR9gjIBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQFMAMB +Af8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GBAFjOKer89961 +zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y7qj/WsjTVbJmcVfewCHrPSqnI0kB +BIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee95 +70+sB3c4 +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA +TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah +WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf +Tqj/ZA1k +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority - G2 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO +FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71 +lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB +MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT +1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD +Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9 +-----END CERTIFICATE----- + +GlobalSign Root CA +================== +-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx +GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds +b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV +BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD +VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa +DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc +THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb +Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP +c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX +gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF +AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj +Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG +j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH +hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC +X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== +-----END CERTIFICATE----- + +GlobalSign Root CA - R2 +======================= +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv +YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh +bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln +bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6 +ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp +s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN +S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL +TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C +ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E +FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i +YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN +BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp +9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu +01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7 +9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 +TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== +-----END CERTIFICATE----- + + +ValiCert Class 1 VA +=================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNTIy +MjM0OFoXDTE5MDYyNTIyMjM0OFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDEg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDYWYJ6ibiWuqYvaG9YLqdUHAZu9OqNSLwxlBfw8068srg1knaw0KWlAdcAAxIi +GQj4/xEjm84H9b9pGib+TunRf50sQB1ZaG6m+FiwnRqP0z/x3BkGgagO4DrdyFNFCQbmD3DD+kCm +DuJWBQ8YTfwggtFzVXSNdnKgHZ0dwN0/cQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFBoPUn0LBwG +lN+VYH+Wexf+T3GtZMjdd9LvWVXoP+iOBSoh8gfStadS/pyxtuJbdxdA6nLWI8sogTLDAHkY7FkX +icnGah5xyf23dKUlRWnFSKsZ4UWKJWsZ7uW7EvV/96aNUcPwnXS3qT6gpf+2SQMT2iLM7XGCK5nP +Orf1LXLI +-----END CERTIFICATE----- + +ValiCert Class 2 VA +=================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAw +MTk1NFoXDTE5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDOOnHK5avIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVC +CSRrCl6zfN1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7Rf +ZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9vUJSZ +SWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTuIYEZoDJJKPTEjlbV +UjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8 +W9ViH0Pd +-----END CERTIFICATE----- + +RSA Root Certificate 1 +====================== +-----BEGIN CERTIFICATE----- +MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp +b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs +YXNzIDMgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh +bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAw +MjIzM1oXDTE5MDYyNjAwMjIzM1owgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0 +d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDMg +UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0 +LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDjmFGWHOjVsQaBalfDcnWTq8+epvzzFlLWLU2fNUSoLgRNB0mKOCn1dzfnt6td +3zZxFJmP3MKS8edgkpfs2Ejcv8ECIMYkpChMMFp2bbFc893enhBxoYjHW5tBbcqwuI4V7q0zK89H +BFx1cQqYJJgpp0lZpd34t0NiYfPT4tBVPwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFa7AliEZwgs +3x/be0kz9dNnnfS0ChCzycUs4pJqcXgn8nCDQtM+z6lU9PHYkhaM0QTLS6vJn0WuPIqpsHEzXcjF +V9+vqDWzf4mH6eglkrh/hXqu1rweN1gqZ8mRzyqBPu3GOd/APhmcGcwTTYJBtYze4D1gCCAPRX5r +on+jjBXu +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1 +EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc +cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw +EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj +055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f +j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0 +xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa +t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- + +Verisign Class 4 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS +tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM +8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW +Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX +Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt +mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm +fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd +RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG +UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== +-----END CERTIFICATE----- + +Entrust.net Secure Server CA +============================ +-----BEGIN CERTIFICATE----- +MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMCVVMxFDASBgNV +BAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5uZXQvQ1BTIGluY29ycC4gYnkg +cmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRl +ZDE6MDgGA1UEAxMxRW50cnVzdC5uZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhv +cml0eTAeFw05OTA1MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIG +A1UEChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBi +eSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1p +dGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQ +aO2f55M28Qpku0f1BBc/I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5 +gXpa0zf3wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OCAdcw +ggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHboIHYpIHVMIHSMQsw +CQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5l +dC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF +bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu +dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0MFqBDzIwMTkw +NTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8BdiE1U9s/8KAGv7UISX8+1i0Bow +HQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAaMAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EA +BAwwChsEVjQuMAMCBJAwDQYJKoZIhvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyN +Ewr75Ji174z4xRAN95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9 +n9cd2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= +-----END CERTIFICATE----- + +Entrust.net Premium 2048 Secure Server CA +========================================= +-----BEGIN CERTIFICATE----- +MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u +ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp +bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV +BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx +NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3 +d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl +MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u +ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL +Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr +hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW +nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi +VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ +KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy +T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf +zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT +J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e +nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE= +-----END CERTIFICATE----- + +Baltimore CyberTrust Root +========================= +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE +ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li +ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC +SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs +dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME +uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB +UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C +G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9 +XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr +l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI +VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB +BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh +cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5 +hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa +Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H +RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp +-----END CERTIFICATE----- + +Equifax Secure Global eBusiness CA +================================== +-----BEGIN CERTIFICATE----- +MIICkDCCAfmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBaMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +RXF1aWZheCBTZWN1cmUgSW5jLjEtMCsGA1UEAxMkRXF1aWZheCBTZWN1cmUgR2xvYmFsIGVCdXNp +bmVzcyBDQS0xMB4XDTk5MDYyMTA0MDAwMFoXDTIwMDYyMTA0MDAwMFowWjELMAkGA1UEBhMCVVMx +HDAaBgNVBAoTE0VxdWlmYXggU2VjdXJlIEluYy4xLTArBgNVBAMTJEVxdWlmYXggU2VjdXJlIEds +b2JhbCBlQnVzaW5lc3MgQ0EtMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuucXkAJlsTRV +PEnCUdXfp9E3j9HngXNBUmCbnaEXJnitx7HoJpQytd4zjTov2/KaelpzmKNc6fuKcxtc58O/gGzN +qfTWK8D3+ZmqY6KxRwIP1ORROhI8bIpaVIRw28HFkM9yRcuoWcDNM50/o5brhTMhHD4ePmBudpxn +hcXIw2ECAwEAAaNmMGQwEQYJYIZIAYb4QgEBBAQDAgAHMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0j +BBgwFoAUvqigdHJQa0S3ySPY+6j/s1draGwwHQYDVR0OBBYEFL6ooHRyUGtEt8kj2Puo/7NXa2hs +MA0GCSqGSIb3DQEBBAUAA4GBADDiAVGqx+pf2rnQZQ8w1j7aDRRJbpGTJxQx78T3LUX47Me/okEN +I7SS+RkAZ70Br83gcfxaz2TE4JaY0KNA4gGK7ycH8WUBikQtBmV1UsCGECAhX2xrD2yuCRyv8qIY +NMR1pHMc8Y3c7635s3a0kr/clRAevsvIO1qEYBlWlKlV +-----END CERTIFICATE----- + +Equifax Secure eBusiness CA 1 +============================= +-----BEGIN CERTIFICATE----- +MIICgjCCAeugAwIBAgIBBDANBgkqhkiG9w0BAQQFADBTMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +RXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNzIENB +LTEwHhcNOTkwNjIxMDQwMDAwWhcNMjAwNjIxMDQwMDAwWjBTMQswCQYDVQQGEwJVUzEcMBoGA1UE +ChMTRXF1aWZheCBTZWN1cmUgSW5jLjEmMCQGA1UEAxMdRXF1aWZheCBTZWN1cmUgZUJ1c2luZXNz +IENBLTEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM4vGbwXt3fek6lfWg0XTzQaDJj0ItlZ +1MRoRvC0NcWFAyDGr0WlIVFFQesWWDYyb+JQYmT5/VGcqiTZ9J2DKocKIdMSODRsjQBuWqDZQu4a +IZX5UkxVWsUPOE9G+m34LjXWHXzr4vCwdYDIqROsvojvOm6rXyo4YgKwEnv+j6YDAgMBAAGjZjBk +MBEGCWCGSAGG+EIBAQQEAwIABzAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEp4MlIR21kW +Nl7fwRQ2QGpHfEyhMB0GA1UdDgQWBBRKeDJSEdtZFjZe38EUNkBqR3xMoTANBgkqhkiG9w0BAQQF +AAOBgQB1W6ibAxHm6VZMzfmpTMANmvPMZWnmJXbMWbfWVMMdzZmsGd20hdXgPfxiIKeES1hl8eL5 +lSE/9dR+WB5Hh1Q+WKG1tfgq73HnvMP2sUlG4tega+VWeponmHxGYhTnyfxuAxJ5gDgdSIKN/Bf+ +KpYrtWKmpj29f5JZzVoqgrI3eQ== +-----END CERTIFICATE----- + +AddTrust Low-Value Services Root +================================ +-----BEGIN CERTIFICATE----- +MIIEGDCCAwCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYDVQQDExhBZGRU +cnVzdCBDbGFzcyAxIENBIFJvb3QwHhcNMDAwNTMwMTAzODMxWhcNMjAwNTMwMTAzODMxWjBlMQsw +CQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBO +ZXR3b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCWltQhSWDia+hBBwzexODcEyPNwTXH+9ZOEQpnXvUGW2ulCDtbKRY6 +54eyNAbFvAWlA3yCyykQruGIgb3WntP+LVbBFc7jJp0VLhD7Bo8wBN6ntGO0/7Gcrjyvd7ZWxbWr +oulpOj0OM3kyP3CCkplhbY0wCI9xP6ZIVxn4JdxLZlyldI+Yrsj5wAYi56xz36Uu+1LcsRVlIPo1 +Zmne3yzxbrww2ywkEtvrNTVokMsAsJchPXQhI2U0K7t4WaPW4XY5mqRJjox0r26kmqPZm9I4XJui +GMx1I4S+6+JNM3GOGvDC+Mcdoq0Dlyz4zyXG9rgkMbFjXZJ/Y/AlyVMuH79NAgMBAAGjgdIwgc8w +HQYDVR0OBBYEFJWxtPCUtr3H2tERCSG+wa9J/RB7MAsGA1UdDwQEAwIBBjAPBgNVHRMBAf8EBTAD +AQH/MIGPBgNVHSMEgYcwgYSAFJWxtPCUtr3H2tERCSG+wa9J/RB7oWmkZzBlMQswCQYDVQQGEwJT +RTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEw +HwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBACxt +ZBsfzQ3duQH6lmM0MkhHma6X7f1yFqZzR1r0693p9db7RcwpiURdv0Y5PejuvE1Uhh4dbOMXJ0Ph +iVYrqW9yTkkz43J8KiOavD7/KCrto/8cI7pDVwlnTUtiBi34/2ydYB7YHEt9tTEv2dB8Xfjea4MY +eDdXL+gzB2ffHsdrKpV2ro9Xo/D0UrSpUwjP4E/TelOL/bscVjby/rK25Xa71SJlpz/+0WatC7xr +mYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOAWiFeIc9TVPC6b4nbqKqVz4vj +ccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk= +-----END CERTIFICATE----- + +AddTrust External Root +====================== +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYD +VQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEw +NDgzOFowbzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRU +cnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0Eg +Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvtH7xsD821 ++iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9uMq/NzgtHj6RQa1wVsfw +Tz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzXmk6vBbOmcZSccbNQYArHE504B4YCqOmo +aSYYkKtMsE8jqzpPhNjfzp/haW+710LXa0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy +2xSoRcRdKn23tNbE7qzNE0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv7 +7+ldU9U0WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYDVR0P +BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0Jvf6xCZU7wO94CTL +VBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRk +VHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB +IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZl +j7DYd7usQWxHYINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvCNr4TDea9Y355 +e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEXc4g/VhsxOBi0cQ+azcgOno4u +G+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5amnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- + +AddTrust Public Services Root +============================= +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSAwHgYDVQQDExdBZGRU +cnVzdCBQdWJsaWMgQ0EgUm9vdDAeFw0wMDA1MzAxMDQxNTBaFw0yMDA1MzAxMDQxNTBaMGQxCzAJ +BgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5l +dHdvcmsxIDAeBgNVBAMTF0FkZFRydXN0IFB1YmxpYyBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEA6Rowj4OIFMEg2Dybjxt+A3S72mnTRqX4jsIMEZBRpS9mVEBV6tsfSlbu +nyNu9DnLoblv8n75XYcmYZ4c+OLspoH4IcUkzBEMP9smcnrHAZcHF/nXGCwwfQ56HmIexkvA/X1i +d9NEHif2P0tEs7c42TkfYNVRknMDtABp4/MUTu7R3AnPdzRGULD4EfL+OHn3Bzn+UZKXC1sIXzSG +Aa2Il+tmzV7R/9x98oTaunet3IAIx6eH1lWfl2royBFkuucZKT8Rs3iQhCBSWxHveNCD9tVIkNAw +HM+A+WD+eeSI8t0A65RF62WUaUC6wNW0uLp9BBGo6zEFlpROWCGOn9Bg/QIDAQABo4HRMIHOMB0G +A1UdDgQWBBSBPjfYkrAfd59ctKtzquf2NGAv+jALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB +/zCBjgYDVR0jBIGGMIGDgBSBPjfYkrAfd59ctKtzquf2NGAv+qFopGYwZDELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29yazEgMB4G +A1UEAxMXQWRkVHJ1c3QgUHVibGljIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBAAP3FUr4 +JNojVhaTdt02KLmuG7jD8WS6IBh4lSknVwW8fCr0uVFV2ocC3g8WFzH4qnkuCRO7r7IgGRLlk/lL ++YPoRNWyQSW/iHVv/xD8SlTQX/D67zZzfRs2RcYhbbQVuE7PnFylPVoAjgbjPGsye/Kf8Lb93/Ao +GEjwxrzQvzSAlsJKsW2Ox5BF3i9nrEUEo3rcVZLJR2bYGozH7ZxOmuASu7VqTITh4SINhwBk/ox9 +Yjllpu9CtoAlEmEBqCQTcAARJl/6NVDFSMwGR+gn2HCNX2TmoUQmXiLsks3/QppEIW1cxeMiHV9H +EufOX1362KqxMy3ZdvJOOjMMK7MtkAY= +-----END CERTIFICATE----- + +AddTrust Qualified Certificates Root +==================================== +-----BEGIN CERTIFICATE----- +MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEUMBIGA1UEChML +QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSMwIQYDVQQDExpBZGRU +cnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcx +CzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQ +IE5ldHdvcmsxIzAhBgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwqxBb/4Oxx +64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G87B4pfYOQnrjfxvM0PC3 +KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i2O+tCBGaKZnhqkRFmhJePp1tUvznoD1o +L/BLcHwTOK28FSXx1s6rosAx1i+f4P8UWfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GR +wVY18BTcZTYJbqukB8c10cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HU +MIHRMB0GA1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6FrpGkwZzELMAkGA1UE +BhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29y +azEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlmaWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQAD +ggEBABmrder4i2VhlRO6aQTvhsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxG +GuoYQ992zPlmhpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X +dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3P6CxB9bpT9ze +RXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9YiQBCYz95OdBEsIJuQRno3eDB +iFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5noxqE= +-----END CERTIFICATE----- + +Entrust Root Certification Authority +==================================== +-----BEGIN CERTIFICATE----- +MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV +BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw +b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG +A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0 +MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu +MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu +Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v +dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz +A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww +Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68 +j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN +rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw +DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1 +MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH +hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA +A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM +Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa +v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS +W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0 +tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8 +-----END CERTIFICATE----- + +RSA Security 2048 v3 +==================== +-----BEGIN CERTIFICATE----- +MIIDYTCCAkmgAwIBAgIQCgEBAQAAAnwAAAAKAAAAAjANBgkqhkiG9w0BAQUFADA6MRkwFwYDVQQK +ExBSU0EgU2VjdXJpdHkgSW5jMR0wGwYDVQQLExRSU0EgU2VjdXJpdHkgMjA0OCBWMzAeFw0wMTAy +MjIyMDM5MjNaFw0yNjAyMjIyMDM5MjNaMDoxGTAXBgNVBAoTEFJTQSBTZWN1cml0eSBJbmMxHTAb +BgNVBAsTFFJTQSBTZWN1cml0eSAyMDQ4IFYzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAt49VcdKA3XtpeafwGFAyPGJn9gqVB93mG/Oe2dJBVGutn3y+Gc37RqtBaB4Y6lXIL5F4iSj7 +Jylg/9+PjDvJSZu1pJTOAeo+tWN7fyb9Gd3AIb2E0S1PRsNO3Ng3OTsor8udGuorryGlwSMiuLgb +WhOHV4PR8CDn6E8jQrAApX2J6elhc5SYcSa8LWrg903w8bYqODGBDSnhAMFRD0xS+ARaqn1y07iH +KrtjEAMqs6FPDVpeRrc9DvV07Jmf+T0kgYim3WBU6JU2PcYJk5qjEoAAVZkZR73QpXzDuvsf9/UP ++Ky5tfQ3mBMY3oVbtwyCO4dvlTlYMNpuAWgXIszACwIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/ +MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQHw1EwpKrpRa41JPr/JCwz0LGdjDAdBgNVHQ4E +FgQUB8NRMKSq6UWuNST6/yQsM9CxnYwwDQYJKoZIhvcNAQEFBQADggEBAF8+hnZuuDU8TjYcHnmY +v/3VEhF5Ug7uMYm83X/50cYVIeiKAVQNOvtUudZj1LGqlk2iQk3UUx+LEN5/Zb5gEydxiKRz44Rj +0aRV4VCT5hsOedBnvEbIvz8XDZXmxpBp3ue0L96VfdASPz0+f00/FGj1EVDVwfSQpQgdMWD/YIwj +VAqv/qFuxdF6Kmh4zx6CCiC0H63lhbJqaHVOrSU3lIW+vaHU6rcMSzyd6BIA8F+sDeGscGNz9395 +nzIlQnQFgCi/vcEkllgVsRch6YlL2weIZ/QVrXA+L02FO8K32/6YaCOJ4XQP3vTFhGMpG8zLB8kA +pKnXwiJPZ9d37CAFYd4= +-----END CERTIFICATE----- + +GeoTrust Global CA +================== +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK +Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw +MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j +LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo +BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet +8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc +T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU +vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD +AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk +DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q +zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4 +d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2 +mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p +XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm +Mw== +-----END CERTIFICATE----- + +GeoTrust Global CA 2 +==================== +-----BEGIN CERTIFICATE----- +MIIDZjCCAk6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFsIENBIDIwHhcNMDQwMzA0MDUw +MDAwWhcNMTkwMzA0MDUwMDAwWjBEMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j +LjEdMBsGA1UEAxMUR2VvVHJ1c3QgR2xvYmFsIENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDvPE1APRDfO1MA4Wf+lGAVPoWI8YkNkMgoI5kF6CsgncbzYEbYwbLVjDHZ3CB5JIG/ +NTL8Y2nbsSpr7iFY8gjpeMtvy/wWUsiRxP89c96xPqfCfWbB9X5SJBri1WeR0IIQ13hLTytCOb1k +LUCgsBDTOEhGiKEMuzozKmKY+wCdE1l/bztyqu6mD4b5BWHqZ38MN5aL5mkWRxHCJ1kDs6ZgwiFA +Vvqgx306E+PsV8ez1q6diYD3Aecs9pYrEw15LNnA5IZ7S4wMcoKK+xfNAGw6EzywhIdLFnopsk/b +HdQL82Y3vdj2V7teJHq4PIu5+pIaGoSe2HSPqht/XvT+RSIhAgMBAAGjYzBhMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFHE4NvICMVNHK266ZUapEBVYIAUJMB8GA1UdIwQYMBaAFHE4NvICMVNH +K266ZUapEBVYIAUJMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQUFAAOCAQEAA/e1K6tdEPx7 +srJerJsOflN4WT5CBP51o62sgU7XAotexC3IUnbHLB/8gTKY0UvGkpMzNTEv/NgdRN3ggX+d6Yvh +ZJFiCzkIjKx0nVnZellSlxG5FntvRdOW2TF9AjYPnDtuzywNA0ZF66D0f0hExghAzN4bcLUprbqL +OzRldRtxIR0sFAqwlpW41uryZfspuk/qkZN0abby/+Ea0AzRdoXLiiW9l14sbxWZJue2Kf8i7MkC +x1YAzUm5s2x7UwQa4qjJqhIFI8LO57sEAszAR6LkxCkvW0VXiVHuPOtSCP8HNR6fNWpHSlaY0VqF +H4z1Ir+rzoPz4iIprn2DQKi6bA== +-----END CERTIFICATE----- + +GeoTrust Universal CA +===================== +-----BEGIN CERTIFICATE----- +MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1 +MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu +Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t +JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e +RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs +7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d +8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V +qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga +Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB +Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu +KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08 +ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0 +XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB +hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc +aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2 +qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL +oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK +xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF +KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2 +DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK +xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU +p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI +P/rmMuGNG2+k5o7Y+SlIis5z/iw= +-----END CERTIFICATE----- + +GeoTrust Universal CA 2 +======================= +-----BEGIN CERTIFICATE----- +MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN +R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0 +MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg +SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA +A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0 +DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17 +j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q +JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a +QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2 +WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP +20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn +ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC +SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG +8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2 ++/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E +BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z +dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ +4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+ +mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq +A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg +Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP +pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d +FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp +gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm +X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS +-----END CERTIFICATE----- + + +America Online Root Certification Authority 1 +============================================= +-----BEGIN CERTIFICATE----- +MIIDpDCCAoygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eSAxMB4XDTAyMDUyODA2MDAwMFoXDTM3MTExOTIwNDMwMFowYzELMAkG +A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg +T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMTCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAKgv6KRpBgNHw+kqmP8ZonCaxlCyfqXfaE0bfA+2l2h9LaaLl+lkhsmj76CG +v2BlnEtUiMJIxUo5vxTjWVXlGbR0yLQFOVwWpeKVBeASrlmLojNoWBym1BW32J/X3HGrfpq/m44z +DyL9Hy7nBzbvYjnF3cu6JRQj3gzGPTzOggjmZj7aUTsWOqMFf6Dch9Wc/HKpoH145LcxVR5lu9Rh +sCFg7RAycsWSJR74kEoYeEfffjA3PlAb2xzTa5qGUwew76wGePiEmf4hjUyAtgyC9mZweRrTT6PP +8c9GsEsPPt2IYriMqQkoO3rHl+Ee5fSfwMCuJKDIodkP1nsmgmkyPacCAwEAAaNjMGEwDwYDVR0T +AQH/BAUwAwEB/zAdBgNVHQ4EFgQUAK3Zo/Z59m50qX8zPYEX10zPM94wHwYDVR0jBBgwFoAUAK3Z +o/Z59m50qX8zPYEX10zPM94wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBBQUAA4IBAQB8itEf +GDeC4Liwo+1WlchiYZwFos3CYiZhzRAW18y0ZTTQEYqtqKkFZu90821fnZmv9ov761KyBZiibyrF +VL0lvV+uyIbqRizBs73B6UlwGBaXCBOMIOAbLjpHyx7kADCVW/RFo8AasAFOq73AI25jP4BKxQft +3OJvx8Fi8eNy1gTIdGcL+oiroQHIb/AUr9KZzVGTfu0uOMe9zkZQPXLjeSWdm4grECDdpbgyn43g +Kd8hdIaC2y+CMMbHNYaz+ZZfRtsMRf3zUMNvxsNIrUam4SdHCh0Om7bCd39j8uB9Gr784N/Xx6ds +sPmuujz9dLQR6FgNgLzTqIA6me11zEZ7 +-----END CERTIFICATE----- + +America Online Root Certification Authority 2 +============================================= +-----BEGIN CERTIFICATE----- +MIIFpDCCA4ygAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEcMBoGA1UEChMT +QW1lcmljYSBPbmxpbmUgSW5jLjE2MDQGA1UEAxMtQW1lcmljYSBPbmxpbmUgUm9vdCBDZXJ0aWZp +Y2F0aW9uIEF1dGhvcml0eSAyMB4XDTAyMDUyODA2MDAwMFoXDTM3MDkyOTE0MDgwMFowYzELMAkG +A1UEBhMCVVMxHDAaBgNVBAoTE0FtZXJpY2EgT25saW5lIEluYy4xNjA0BgNVBAMTLUFtZXJpY2Eg +T25saW5lIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgMjCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAMxBRR3pPU0Q9oyxQcngXssNt79Hc9PwVU3dxgz6sWYFas14tNwC206B89en +fHG8dWOgXeMHDEjsJcQDIPT/DjsS/5uN4cbVG7RtIuOx238hZK+GvFciKtZHgVdEglZTvYYUAQv8 +f3SkWq7xuhG1m1hagLQ3eAkzfDJHA1zEpYNI9FdWboE2JxhP7JsowtS013wMPgwr38oE18aO6lhO +qKSlGBxsRZijQdEt0sdtjRnxrXm3gT+9BoInLRBYBbV4Bbkv2wxrkJB+FFk4u5QkE+XRnRTf04JN +RvCAOVIyD+OEsnpD8l7eXz8d3eOyG6ChKiMDbi4BFYdcpnV1x5dhvt6G3NRI270qv0pV2uh9UPu0 +gBe4lL8BPeraunzgWGcXuVjgiIZGZ2ydEEdYMtA1fHkqkKJaEBEjNa0vzORKW6fIJ/KD3l67Xnfn +6KVuY8INXWHQjNJsWiEOyiijzirplcdIz5ZvHZIlyMbGwcEMBawmxNJ10uEqZ8A9W6Wa6897Gqid +FEXlD6CaZd4vKL3Ob5Rmg0gp2OpljK+T2WSfVVcmv2/LNzGZo2C7HK2JNDJiuEMhBnIMoVxtRsX6 +Kc8w3onccVvdtjc+31D1uAclJuW8tf48ArO3+L5DwYcRlJ4jbBeKuIonDFRH8KmzwICMoCfrHRnj +B453cMor9H124HhnAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFE1FwWg4u3Op +aaEg5+31IqEjFNeeMB8GA1UdIwQYMBaAFE1FwWg4u3OpaaEg5+31IqEjFNeeMA4GA1UdDwEB/wQE +AwIBhjANBgkqhkiG9w0BAQUFAAOCAgEAZ2sGuV9FOypLM7PmG2tZTiLMubekJcmnxPBUlgtk87FY +T15R/LKXeydlwuXK5w0MJXti4/qftIe3RUavg6WXSIylvfEWK5t2LHo1YGwRgJfMqZJS5ivmae2p ++DYtLHe/YUjRYwu5W1LtGLBDQiKmsXeu3mnFzcccobGlHBD7GL4acN3Bkku+KVqdPzW+5X1R+FXg +JXUjhx5c3LqdsKyzadsXg8n33gy8CNyRnqjQ1xU3c6U1uPx+xURABsPr+CKAXEfOAuMRn0T//Zoy +zH1kUQ7rVyZ2OuMeIjzCpjbdGe+n/BLzJsBZMYVMnNjP36TMzCmT/5RtdlwTCJfy7aULTd3oyWgO +ZtMADjMSW7yV5TKQqLPGbIOtd+6Lfn6xqavT4fG2wLHqiMDn05DpKJKUe2h7lyoKZy2FAjgQ5ANh +1NolNscIWC2hp1GvMApJ9aZphwctREZ2jirlmjvXGKL8nDgQzMY70rUXOm/9riW99XJZZLF0Kjhf +GEzfz3EEWjbUvy+ZnOjZurGV5gJLIaFb1cFPj65pbVPbAZO1XB4Y3WRayhgoPmMEEf0cjQAPuDff +Z4qdZqkCapH/E8ovXYO8h5Ns3CRRFgQlZvqz2cK6Kb6aSDiCmfS/O0oxGfm/jiEzFMpPVF/7zvuP +cX/9XhmgD0uRuMRUvAawRY8mkaKO/qk= +-----END CERTIFICATE----- + +Visa eCommerce Root +=================== +-----BEGIN CERTIFICATE----- +MIIDojCCAoqgAwIBAgIQE4Y1TR0/BvLB+WUF1ZAcYjANBgkqhkiG9w0BAQUFADBrMQswCQYDVQQG +EwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2Ug +QXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNvbW1lcmNlIFJvb3QwHhcNMDIwNjI2MDIxODM2 +WhcNMjIwNjI0MDAxNjEyWjBrMQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMm +VmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNv +bW1lcmNlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvV95WHm6h2mCxlCfL +F9sHP4CFT8icttD0b0/Pmdjh28JIXDqsOTPHH2qLJj0rNfVIsZHBAk4ElpF7sDPwsRROEW+1QK8b +RaVK7362rPKgH1g/EkZgPI2h4H3PVz4zHvtH8aoVlwdVZqW1LS7YgFmypw23RuwhY/81q6UCzyr0 +TP579ZRdhE2o8mCP2w4lPJ9zcc+U30rq299yOIzzlr3xF7zSujtFWsan9sYXiwGd/BmoKoMWuDpI +/k4+oKsGGelT84ATB+0tvz8KPFUgOSwsAGl0lUq8ILKpeeUYiZGo3BxN77t+Nwtd/jmliFKMAGzs +GHxBvfaLdXe6YJ2E5/4tAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEG +MB0GA1UdDgQWBBQVOIMPPyw/cDMezUb+B4wg4NfDtzANBgkqhkiG9w0BAQUFAAOCAQEAX/FBfXxc +CLkr4NWSR/pnXKUTwwMhmytMiUbPWU3J/qVAtmPN3XEolWcRzCSs00Rsca4BIGsDoo8Ytyk6feUW +YFN4PMCvFYP3j1IzJL1kk5fui/fbGKhtcbP3LBfQdCVp9/5rPJS+TUtBjE7ic9DjkCJzQ83z7+pz +zkWKsKZJ/0x9nXGIxHYdkFsd7v3M9+79YKWxehZx0RbQfBI8bGmX265fOZpwLwU8GUYEmSA20GBu +YQa7FkKMcPcw++DbZqMAAb3mLNqRX6BGi01qnD093QVG/na/oAo85ADmJ7f/hC3euiInlhBx6yLt +398znM/jra6O1I7mT1GvFpLgXPYHDw== +-----END CERTIFICATE----- + +Certum Root CA +============== +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIDAQAgMA0GCSqGSIb3DQEBBQUAMD4xCzAJBgNVBAYTAlBMMRswGQYDVQQK +ExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBDQTAeFw0wMjA2MTExMDQ2Mzla +Fw0yNzA2MTExMDQ2MzlaMD4xCzAJBgNVBAYTAlBMMRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8u +by4xEjAQBgNVBAMTCUNlcnR1bSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6x +wS7TT3zNJc4YPk/EjG+AanPIW1H4m9LcuwBcsaD8dQPugfCI7iNS6eYVM42sLQnFdvkrOYCJ5JdL +kKWoePhzQ3ukYbDYWMzhbGZ+nPMJXlVjhNWo7/OxLjBos8Q82KxujZlakE403Daaj4GIULdtlkIJ +89eVgw1BS7Bqa/j8D35in2fE7SZfECYPCE/wpFcozo+47UX2bu4lXapuOb7kky/ZR6By6/qmW6/K +Uz/iDsaWVhFu9+lmqSbYf5VT7QqFiLpPKaVCjF62/IUgAKpoC6EahQGcxEZjgoi2IrHu/qpGWX7P +NSzVttpd90gzFFS269lvzs2I1qsb2pY7HVkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkq +hkiG9w0BAQUFAAOCAQEAuI3O7+cUus/usESSbLQ5PqKEbq24IXfS1HeCh+YgQYHu4vgRt2PRFze+ +GXYkHAQaTOs9qmdvLdTN/mUxcMUbpgIKumB7bVjCmkn+YzILa+M6wKyrO7Do0wlRjBCDxjTgxSvg +GrZgFCdsMneMvLJymM/NzD+5yCRCFNZX/OYmQ6kd5YCQzgNUKD73P9P4Te1qCjqTE5s7FCMTY5w/ +0YcneeVMUeMBrYVdGjux1XMQpNPyvG5k9VpWkKjHDkx0Dy5xO/fIR/RpbxXyEV6DHpx8Uq79AtoS +qFlnGNu8cN2bsWntgM6JQEhqDjXKKWYVIZQs6GAqm4VKQPNriiTsBhYscw== +-----END CERTIFICATE----- + +Comodo AAA Services root +======================== +-----BEGIN CERTIFICATE----- +MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw +MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl +c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV +BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG +C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs +i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW +Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH +Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK +Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f +BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl +cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz +LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm +7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz +Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z +8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C +12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== +-----END CERTIFICATE----- + +Comodo Secure Services root +=========================== +-----BEGIN CERTIFICATE----- +MIIEPzCCAyegAwIBAgIBATANBgkqhkiG9w0BAQUFADB+MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDEkMCIGA1UEAwwbU2VjdXJlIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAw +MDAwMFoXDTI4MTIzMTIzNTk1OVowfjELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFu +Y2hlc3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxJDAi +BgNVBAMMG1NlY3VyZSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAMBxM4KK0HDrc4eCQNUd5MvJDkKQ+d40uaG6EfQlhfPMcm3ye5drswfxdySRXyWP +9nQ95IDC+DwN879A6vfIUtFyb+/Iq0G4bi4XKpVpDM3SHpR7LZQdqnXXs5jLrLxkU0C8j6ysNstc +rbvd4JQX7NFc0L/vpZXJkMWwrPsbQ996CF23uPJAGysnnlDOXmWCiIxe004MeuoIkbY2qitC++rC +oznl2yY4rYsK7hljxxwk3wN42ubqwUcaCwtGCd0C/N7Lh1/XMGNooa7cMqG6vv5Eq2i2pRcV/b3V +p6ea5EQz6YiO/O1R65NxTq0B50SOqy3LqP4BSUjwwN3HaNiS/j0CAwEAAaOBxzCBxDAdBgNVHQ4E +FgQUPNiTiMLAggnMAZkGkyDpnnAJY08wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w +gYEGA1UdHwR6MHgwO6A5oDeGNWh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL1NlY3VyZUNlcnRpZmlj +YXRlU2VydmljZXMuY3JsMDmgN6A1hjNodHRwOi8vY3JsLmNvbW9kby5uZXQvU2VjdXJlQ2VydGlm +aWNhdGVTZXJ2aWNlcy5jcmwwDQYJKoZIhvcNAQEFBQADggEBAIcBbSMdflsXfcFhMs+P5/OKlFlm +4J4oqF7Tt/Q05qo5spcWxYJvMqTpjOev/e/C6LlLqqP05tqNZSH7uoDrJiiFGv45jN5bBAS0VPmj +Z55B+glSzAVIqMk/IQQezkhr/IXownuvf7fM+F86/TXGDe+X3EyrEeFryzHRbPtIgKvcnDe4IRRL +DXE97IMzbtFuMhbsmMcWi1mmNKsFVy2T96oTy9IT4rcuO81rUBcJaD61JlfutuC23bkpgHl9j6Pw +pCikFcSF9CfUa7/lXORlAnZUtOM3ZiTTGWHIUhDlizeauan5Hb/qmZJhlv8BzaFfDbxxvA6sCx1H +RR3B7Hzs/Sk= +-----END CERTIFICATE----- + +Comodo Trusted Services root +============================ +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIBATANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS +R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg +TGltaXRlZDElMCMGA1UEAwwcVHJ1c3RlZCBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczAeFw0wNDAxMDEw +MDAwMDBaFw0yODEyMzEyMzU5NTlaMH8xCzAJBgNVBAYTAkdCMRswGQYDVQQIDBJHcmVhdGVyIE1h +bmNoZXN0ZXIxEDAOBgNVBAcMB1NhbGZvcmQxGjAYBgNVBAoMEUNvbW9kbyBDQSBMaW1pdGVkMSUw +IwYDVQQDDBxUcnVzdGVkIENlcnRpZmljYXRlIFNlcnZpY2VzMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA33FvNlhTWvI2VFeAxHQIIO0Yfyod5jWaHiWsnOWWfnJSoBVC21ndZHoa0Lh7 +3TkVvFVIxO06AOoxEbrycXQaZ7jPM8yoMa+j49d/vzMtTGo87IvDktJTdyR0nAducPy9C1t2ul/y +/9c3S0pgePfw+spwtOpZqqPOSC+pw7ILfhdyFgymBwwbOM/JYrc/oJOlh0Hyt3BAd9i+FHzjqMB6 +juljatEPmsbS9Is6FARW1O24zG71++IsWL1/T2sr92AkWCTOJu80kTrV44HQsvAEAtdbtz6SrGsS +ivnkBbA7kUlcsutT6vifR4buv5XAwAaf0lteERv0xwQ1KdJVXOTt6wIDAQABo4HJMIHGMB0GA1Ud +DgQWBBTFe1i97doladL3WRaoszLAeydb9DAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB +/zCBgwYDVR0fBHwwejA8oDqgOIY2aHR0cDovL2NybC5jb21vZG9jYS5jb20vVHJ1c3RlZENlcnRp +ZmljYXRlU2VydmljZXMuY3JsMDqgOKA2hjRodHRwOi8vY3JsLmNvbW9kby5uZXQvVHJ1c3RlZENl +cnRpZmljYXRlU2VydmljZXMuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQDIk4E7ibSvuIQSTI3S8Ntw +uleGFTQQuS9/HrCoiWChisJ3DFBKmwCL2Iv0QeLQg4pKHBQGsKNoBXAxMKdTmw7pSqBYaWcOrp32 +pSxBvzwGa+RZzG0Q8ZZvH9/0BAKkn0U+yNj6NkZEUD+Cl5EfKNsYEYwq5GWDVxISjBc/lDb+XbDA +BHcTuPQV1T84zJQ6VdCsmPW6AF/ghhmBeC8owH7TzEIK9a5QoNE+xqFx7D+gIIxmOom0jtTYsU0l +R+4viMi14QVFwL4Ucd56/Y57fU0IlqUSc/AtyjcndBInTMu2l+nZrghtWjlA3QVHdWpaIbOjGM9O +9y5Xt5hwXsjEeLBi +-----END CERTIFICATE----- + +QuoVadis Root CA +================ +-----BEGIN CERTIFICATE----- +MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE +ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz +MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp +cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD +EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk +J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL +F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL +YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen +AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w +PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y +ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7 +MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj +YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs +ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh +Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW +Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu +BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw +FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6 +tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo +fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul +LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x +gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi +5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi +5nrQNiOKSnQ2+Q== +-----END CERTIFICATE----- + +QuoVadis Root CA 2 +================== +-----BEGIN CERTIFICATE----- +MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT +EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx +ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6 +XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk +lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB +lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy +lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt +66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn +wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh +D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy +BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie +J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud +DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU +a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT +ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv +Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3 +UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm +VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK ++JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW +IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1 +WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X +f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II +4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8 +VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u +-----END CERTIFICATE----- + +QuoVadis Root CA 3 +================== +-----BEGIN CERTIFICATE----- +MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT +EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx +OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg +DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij +KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K +DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv +BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp +p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8 +nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX +MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM +Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz +uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT +BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj +YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0 +aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB +BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD +VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4 +ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE +AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV +qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s +hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z +POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2 +Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp +8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC +bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu +g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p +vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr +qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto= +-----END CERTIFICATE----- + +Security Communication Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP +U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw +HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP +U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw +8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM +DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX +5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd +DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2 +JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw +DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g +0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a +mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ +s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ +6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi +FL39vmwLAw== +-----END CERTIFICATE----- + +Sonera Class 2 Root CA +====================== +-----BEGIN CERTIFICATE----- +MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG +U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw +NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh +IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3 +/Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT +dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG +f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P +tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH +nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT +XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt +0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI +cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph +Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx +EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH +llpwrN9M +-----END CERTIFICATE----- + +Staat der Nederlanden Root CA +============================= +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgIEAJiWijANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJOTDEeMBwGA1UE +ChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFhdCBkZXIgTmVkZXJsYW5kZW4g +Um9vdCBDQTAeFw0wMjEyMTcwOTIzNDlaFw0xNTEyMTYwOTE1MzhaMFUxCzAJBgNVBAYTAk5MMR4w +HAYDVQQKExVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xJjAkBgNVBAMTHVN0YWF0IGRlciBOZWRlcmxh +bmRlbiBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmNK1URF6gaYUmHFt +vsznExvWJw56s2oYHLZhWtVhCb/ekBPHZ+7d89rFDBKeNVU+LCeIQGv33N0iYfXCxw719tV2U02P +jLwYdjeFnejKScfST5gTCaI+Ioicf9byEGW07l8Y1Rfj+MX94p2i71MOhXeiD+EwR+4A5zN9RGca +C1Hoi6CeUJhoNFIfLm0B8mBF8jHrqTFoKbt6QZ7GGX+UtFE5A3+y3qcym7RHjm+0Sq7lr7HcsBth +vJly3uSJt3omXdozSVtSnA71iq3DuD3oBmrC1SoLbHuEvVYFy4ZlkuxEK7COudxwC0barbxjiDn6 +22r+I/q85Ej0ZytqERAhSQIDAQABo4GRMIGOMAwGA1UdEwQFMAMBAf8wTwYDVR0gBEgwRjBEBgRV +HSAAMDwwOgYIKwYBBQUHAgEWLmh0dHA6Ly93d3cucGtpb3ZlcmhlaWQubmwvcG9saWNpZXMvcm9v +dC1wb2xpY3kwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSofeu8Y6R0E3QA7Jbg0zTBLL9s+DAN +BgkqhkiG9w0BAQUFAAOCAQEABYSHVXQ2YcG70dTGFagTtJ+k/rvuFbQvBgwp8qiSpGEN/KtcCFtR +EytNwiphyPgJWPwtArI5fZlmgb9uXJVFIGzmeafR2Bwp/MIgJ1HI8XxdNGdphREwxgDS1/PTfLbw +MVcoEoJz6TMvplW0C5GUR5z6u3pCMuiufi3IvKwUv9kP2Vv8wfl6leF9fpb8cbDCTMjfRTTJzg3y +nGQI0DvDKcWy7ZAEwbEpkcUwb8GpcjPM/l0WFywRaed+/sWDCN+83CI6LiBpIzlWYGeQiy52OfsR +iJf2fL1LuCAWZwWN4jvBcj+UlTfHXbme2JOhF4//DGYVwSR8MnwDHTuhWEUykw== +-----END CERTIFICATE----- + +UTN DATACorp SGC Root CA +======================== +-----BEGIN CERTIFICATE----- +MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCBkzELMAkGA1UE +BhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UEChMVVGhl +IFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZ +BgNVBAMTElVUTiAtIERBVEFDb3JwIFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBa +MIGTMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4w +HAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRy +dXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ys +raP6LnD43m77VkIVni5c7yPeIbkFdicZD0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlo +wHDyUwDAXlCCpVZvNvlK4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA +9P4yPykqlXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulWbfXv +33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQABo4GrMIGoMAsGA1Ud +DwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRTMtGzz3/64PGgXYVOktKeRR20TzA9 +BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dD +LmNybDAqBgNVHSUEIzAhBggrBgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3 +DQEBBQUAA4IBAQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft +Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyjj98C5OBxOvG0 +I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVHKWss5nbZqSl9Mt3JNjy9rjXx +EZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwP +DPafepE39peC4N1xaf92P2BNPM/3mfnGV/TJVTl4uix5yaaIK/QI +-----END CERTIFICATE----- + +UTN USERFirst Hardware Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCBlzELMAkGA1UE +BhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UEChMVVGhl +IFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAd +BgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgx +OTIyWjCBlzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0 +eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVz +ZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdhcmUwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlI +wrthdBKWHTxqctU8EGc6Oe0rE81m65UJM6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFd +tqdt++BxF2uiiPsA3/4aMXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8 +i4fDidNdoI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqIDsjf +Pe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9KsyoUhbAgMBAAGjgbkw +gbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFKFyXyYbKJhDlV0HN9WF +lp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNF +UkZpcnN0LUhhcmR3YXJlLmNybDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUF +BwMGBggrBgEFBQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM +//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28GpgoiskliCE7/yMgUsogW +XecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gECJChicsZUN/KHAG8HQQZexB2 +lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kn +iCrVWFCVH/A7HFe7fRQ5YiuayZSSKqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67 +nfhmqA== +-----END CERTIFICATE----- + +Camerfirma Chambers of Commerce Root +==================================== +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBADANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJFVTEnMCUGA1UEChMe +QUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1i +ZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAx +NjEzNDNaFw0zNzA5MzAxNjEzNDRaMH8xCzAJBgNVBAYTAkVVMScwJQYDVQQKEx5BQyBDYW1lcmZp +cm1hIFNBIENJRiBBODI3NDMyODcxIzAhBgNVBAsTGmh0dHA6Ly93d3cuY2hhbWJlcnNpZ24ub3Jn +MSIwIAYDVQQDExlDaGFtYmVycyBvZiBDb21tZXJjZSBSb290MIIBIDANBgkqhkiG9w0BAQEFAAOC +AQ0AMIIBCAKCAQEAtzZV5aVdGDDg2olUkfzIx1L4L1DZ77F1c2VHfRtbunXF/KGIJPov7coISjlU +xFF6tdpg6jg8gbLL8bvZkSM/SAFwdakFKq0fcfPJVD0dBmpAPrMMhe5cG3nCYsS4No41XQEMIwRH +NaqbYE6gZj3LJgqcQKH0XZi/caulAGgq7YN6D6IUtdQis4CwPAxaUWktWBiP7Zme8a7ileb2R6jW +DA+wWFjbw2Y3npuRVDM30pQcakjJyfKl2qUMI/cjDpwyVV5xnIQFUZot/eZOKjRa3spAN2cMVCFV +d9oKDMyXroDclDZK9D7ONhMeU+SsTjoF7Nuucpw4i9A5O4kKPnf+dQIBA6OCAUQwggFAMBIGA1Ud +EwEB/wQIMAYBAf8CAQwwPAYDVR0fBDUwMzAxoC+gLYYraHR0cDovL2NybC5jaGFtYmVyc2lnbi5v +cmcvY2hhbWJlcnNyb290LmNybDAdBgNVHQ4EFgQU45T1sU3p26EpW1eLTXYGduHRooowDgYDVR0P +AQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzAnBgNVHREEIDAegRxjaGFtYmVyc3Jvb3RAY2hh +bWJlcnNpZ24ub3JnMCcGA1UdEgQgMB6BHGNoYW1iZXJzcm9vdEBjaGFtYmVyc2lnbi5vcmcwWAYD +VR0gBFEwTzBNBgsrBgEEAYGHLgoDATA+MDwGCCsGAQUFBwIBFjBodHRwOi8vY3BzLmNoYW1iZXJz +aWduLm9yZy9jcHMvY2hhbWJlcnNyb290Lmh0bWwwDQYJKoZIhvcNAQEFBQADggEBAAxBl8IahsAi +fJ/7kPMa0QOx7xP5IV8EnNrJpY0nbJaHkb5BkAFyk+cefV/2icZdp0AJPaxJRUXcLo0waLIJuvvD +L8y6C98/d3tGfToSJI6WjzwFCm/SlCgdbQzALogi1djPHRPH8EjX1wWnz8dHnjs8NMiAT9QUu/wN +UPf6s+xCX6ndbcj0dc97wXImsQEcXCz9ek60AcUFV7nnPKoF2YjpB0ZBzu9Bga5Y34OirsrXdx/n +ADydb47kMgkdTXg0eDQ8lJsm7U9xxhl6vSAiSFr+S30Dt+dYvsYyTnQeaN2oaFuzPu5ifdmA6Ap1 +erfutGWaIZDgqtCYvDi1czyL+Nw= +-----END CERTIFICATE----- + +Camerfirma Global Chambersign Root +================================== +-----BEGIN CERTIFICATE----- +MIIExTCCA62gAwIBAgIBADANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJFVTEnMCUGA1UEChMe +QUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1i +ZXJzaWduLm9yZzEgMB4GA1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwHhcNMDMwOTMwMTYx +NDE4WhcNMzcwOTMwMTYxNDE4WjB9MQswCQYDVQQGEwJFVTEnMCUGA1UEChMeQUMgQ2FtZXJmaXJt +YSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQLExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEg +MB4GA1UEAxMXR2xvYmFsIENoYW1iZXJzaWduIFJvb3QwggEgMA0GCSqGSIb3DQEBAQUAA4IBDQAw +ggEIAoIBAQCicKLQn0KuWxfH2H3PFIP8T8mhtxOviteePgQKkotgVvq0Mi+ITaFgCPS3CU6gSS9J +1tPfnZdan5QEcOw/Wdm3zGaLmFIoCQLfxS+EjXqXd7/sQJ0lcqu1PzKY+7e3/HKE5TWH+VX6ox8O +by4o3Wmg2UIQxvi1RMLQQ3/bvOSiPGpVeAp3qdjqGTK3L/5cPxvusZjsyq16aUXjlg9V9ubtdepl +6DJWk0aJqCWKZQbua795B9Dxt6/tLE2Su8CoX6dnfQTyFQhwrJLWfQTSM/tMtgsL+xrJxI0DqX5c +8lCrEqWhz0hQpe/SyBoT+rB/sYIcd2oPX9wLlY/vQ37mRQklAgEDo4IBUDCCAUwwEgYDVR0TAQH/ +BAgwBgEB/wIBDDA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3JsLmNoYW1iZXJzaWduLm9yZy9j +aGFtYmVyc2lnbnJvb3QuY3JsMB0GA1UdDgQWBBRDnDafsJ4wTcbOX60Qq+UDpfqpFDAOBgNVHQ8B +Af8EBAMCAQYwEQYJYIZIAYb4QgEBBAQDAgAHMCoGA1UdEQQjMCGBH2NoYW1iZXJzaWducm9vdEBj +aGFtYmVyc2lnbi5vcmcwKgYDVR0SBCMwIYEfY2hhbWJlcnNpZ25yb290QGNoYW1iZXJzaWduLm9y +ZzBbBgNVHSAEVDBSMFAGCysGAQQBgYcuCgEBMEEwPwYIKwYBBQUHAgEWM2h0dHA6Ly9jcHMuY2hh +bWJlcnNpZ24ub3JnL2Nwcy9jaGFtYmVyc2lnbnJvb3QuaHRtbDANBgkqhkiG9w0BAQUFAAOCAQEA +PDtwkfkEVCeR4e3t/mh/YV3lQWVPMvEYBZRqHN4fcNs+ezICNLUMbKGKfKX0j//U2K0X1S0E0T9Y +gOKBWYi+wONGkyT+kL0mojAt6JcmVzWJdJYY9hXiryQZVgICsroPFOrGimbBhkVVi76SvpykBMdJ +PJ7oKXqJ1/6v/2j1pReQvayZzKWGVwlnRtvWFsJG8eSpUPWP0ZIV018+xgBJOm5YstHRJw0lyDL4 +IBHNfTIzSJRUTN3cecQwn+uOuFW114hcxWokPbLTBQNRxgfvzBRydD1ucs4YKIxKoHflCStFREes +t2d/AYoFWpO+ocH/+OcOZ6RHSXZddZAa9SaP8A== +-----END CERTIFICATE----- + +NetLock Notary (Class A) Root +============================= +-----BEGIN CERTIFICATE----- +MIIGfTCCBWWgAwIBAgICAQMwDQYJKoZIhvcNAQEEBQAwga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQI +EwdIdW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6 +dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9j +ayBLb3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNDIzMTQ0N1oX +DTE5MDIxOTIzMTQ0N1owga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQIEwdIdW5nYXJ5MREwDwYDVQQH +EwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6dG9uc2FnaSBLZnQuMRowGAYD +VQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0TG9jayBLb3pqZWd5em9pIChDbGFz +cyBBKSBUYW51c2l0dmFueWtpYWRvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHSM +D7tM9DceqQWC2ObhbHDqeLVu0ThEDaiDzl3S1tWBxdRL51uUcCbbO51qTGL3cfNk1mE7PetzozfZ +z+qMkjvN9wfcZnSX9EUi3fRc4L9t875lM+QVOr/bmJBVOMTtplVjC7B4BPTjbsE/jvxReB+SnoPC +/tmwqcm8WgD/qaiYdPv2LD4VOQ22BFWoDpggQrOxJa1+mm9dU7GrDPzr4PN6s6iz/0b2Y6LYOph7 +tqyF/7AlT3Rj5xMHpQqPBffAZG9+pyeAlt7ULoZgx2srXnN7F+eRP2QM2EsiNCubMvJIH5+hCoR6 +4sKtlz2O1cH5VqNQ6ca0+pii7pXmKgOM3wIDAQABo4ICnzCCApswDgYDVR0PAQH/BAQDAgAGMBIG +A1UdEwEB/wQIMAYBAf8CAQQwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaC +Ak1GSUdZRUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pv +bGdhbHRhdGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQu +IEEgaGl0ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2Vn +LWJpenRvc2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0 +ZXRlbGUgYXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFz +IGxlaXJhc2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBh +IGh0dHBzOi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVu +b3J6ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1YW5jZSBh +bmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sg +Q1BTIGF2YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFp +bCBhdCBjcHNAbmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4IBAQBIJEb3ulZv+sgoA0BO5TE5 +ayZrU3/b39/zcT0mwBQOxmd7I6gMc90Bu8bKbjc5VdXHjFYgDigKDtIqpLBJUsY4B/6+CgmM0ZjP +ytoUMaFP0jn8DxEsQ8Pdq5PHVT5HfBgaANzze9jyf1JsIPQLX2lS9O74silg6+NJMSEN1rUQQeJB +CWziGppWS3cC9qCbmieH6FUpccKQn0V4GuEVZD3QDtigdp+uxdAu6tYPVuxkf1qbFFgBJ34TUMdr +KuZoPL9coAob4Q566eKAw+np9v1sEZ7Q5SgnK1QyQhSCdeZK8CtmdWOMovsEPoMOmzbwGOQmIMOM +8CgHrTwXZoi1/baI +-----END CERTIFICATE----- + + +NetLock Business (Class B) Root +=============================== +-----BEGIN CERTIFICATE----- +MIIFSzCCBLSgAwIBAgIBaTANBgkqhkiG9w0BAQQFADCBmTELMAkGA1UEBhMCSFUxETAPBgNVBAcT +CEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0b25zYWdpIEtmdC4xGjAYBgNV +BAsTEVRhbnVzaXR2YW55a2lhZG9rMTIwMAYDVQQDEylOZXRMb2NrIFV6bGV0aSAoQ2xhc3MgQikg +VGFudXNpdHZhbnlraWFkbzAeFw05OTAyMjUxNDEwMjJaFw0xOTAyMjAxNDEwMjJaMIGZMQswCQYD +VQQGEwJIVTERMA8GA1UEBxMIQnVkYXBlc3QxJzAlBgNVBAoTHk5ldExvY2sgSGFsb3phdGJpenRv +bnNhZ2kgS2Z0LjEaMBgGA1UECxMRVGFudXNpdHZhbnlraWFkb2sxMjAwBgNVBAMTKU5ldExvY2sg +VXpsZXRpIChDbGFzcyBCKSBUYW51c2l0dmFueWtpYWRvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB +iQKBgQCx6gTsIKAjwo84YM/HRrPVG/77uZmeBNwcf4xKgZjupNTKihe5In+DCnVMm8Bp2GQ5o+2S +o/1bXHQawEfKOml2mrriRBf8TKPV/riXiK+IA4kfpPIEPsgHC+b5sy96YhQJRhTKZPWLgLViqNhr +1nGTLbO/CVRY7QbrqHvcQ7GhaQIDAQABo4ICnzCCApswEgYDVR0TAQH/BAgwBgEB/wIBBDAOBgNV +HQ8BAf8EBAMCAAYwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1GSUdZ +RUxFTSEgRXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pvbGdhbHRh +dGFzaSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQuIEEgaGl0 +ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2VnLWJpenRv +c2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0ZXRlbGUg +YXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGphcmFzIGxlaXJh +c2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxhcGphbiBhIGh0dHBz +Oi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRvIGF6IGVsbGVub3J6ZXNA +bmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRoZSBpc3N1YW5jZSBhbmQgdGhl +IHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3QgdG8gdGhlIE5ldExvY2sgQ1BTIGF2 +YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBj +cHNAbmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUAA4GBAATbrowXr/gOkDFOzT4JwG06sPgzTEdM +43WIEJessDgVkcYplswhwG08pXTP2IKlOcNl40JwuyKQ433bNXbhoLXan3BukxowOR0w2y7jfLKR +stE3Kfq51hdcR0/jHTjrn9V7lagonhVK0dHQKwCXoOKSNitjrFgBazMpUIaD8QFI +-----END CERTIFICATE----- + +NetLock Express (Class C) Root +============================== +-----BEGIN CERTIFICATE----- +MIIFTzCCBLigAwIBAgIBaDANBgkqhkiG9w0BAQQFADCBmzELMAkGA1UEBhMCSFUxETAPBgNVBAcT +CEJ1ZGFwZXN0MScwJQYDVQQKEx5OZXRMb2NrIEhhbG96YXRiaXp0b25zYWdpIEtmdC4xGjAYBgNV +BAsTEVRhbnVzaXR2YW55a2lhZG9rMTQwMgYDVQQDEytOZXRMb2NrIEV4cHJlc3N6IChDbGFzcyBD +KSBUYW51c2l0dmFueWtpYWRvMB4XDTk5MDIyNTE0MDgxMVoXDTE5MDIyMDE0MDgxMVowgZsxCzAJ +BgNVBAYTAkhVMREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6 +dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE0MDIGA1UEAxMrTmV0TG9j +ayBFeHByZXNzeiAoQ2xhc3MgQykgVGFudXNpdHZhbnlraWFkbzCBnzANBgkqhkiG9w0BAQEFAAOB +jQAwgYkCgYEA6+ywbGGKIyWvYCDj2Z/8kwvbXY2wobNAOoLO/XXgeDIDhlqGlZHtU/qdQPzm6N3Z +W3oDvV3zOwzDUXmbrVWg6dADEK8KuhRC2VImESLH0iDMgqSaqf64gXadarfSNnU+sYYJ9m5tfk63 +euyucYT2BDMIJTLrdKwWRMbkQJMdf60CAwEAAaOCAp8wggKbMBIGA1UdEwEB/wQIMAYBAf8CAQQw +DgYDVR0PAQH/BAQDAgAGMBEGCWCGSAGG+EIBAQQEAwIABzCCAmAGCWCGSAGG+EIBDQSCAlEWggJN +RklHWUVMRU0hIEV6ZW4gdGFudXNpdHZhbnkgYSBOZXRMb2NrIEtmdC4gQWx0YWxhbm9zIFN6b2xn +YWx0YXRhc2kgRmVsdGV0ZWxlaWJlbiBsZWlydCBlbGphcmFzb2sgYWxhcGphbiBrZXN6dWx0LiBB +IGhpdGVsZXNpdGVzIGZvbHlhbWF0YXQgYSBOZXRMb2NrIEtmdC4gdGVybWVrZmVsZWxvc3NlZy1i +aXp0b3NpdGFzYSB2ZWRpLiBBIGRpZ2l0YWxpcyBhbGFpcmFzIGVsZm9nYWRhc2FuYWsgZmVsdGV0 +ZWxlIGF6IGVsb2lydCBlbGxlbm9yemVzaSBlbGphcmFzIG1lZ3RldGVsZS4gQXogZWxqYXJhcyBs +ZWlyYXNhIG1lZ3RhbGFsaGF0byBhIE5ldExvY2sgS2Z0LiBJbnRlcm5ldCBob25sYXBqYW4gYSBo +dHRwczovL3d3dy5uZXRsb2NrLm5ldC9kb2NzIGNpbWVuIHZhZ3kga2VyaGV0byBheiBlbGxlbm9y +emVzQG5ldGxvY2submV0IGUtbWFpbCBjaW1lbi4gSU1QT1JUQU5UISBUaGUgaXNzdWFuY2UgYW5k +IHRoZSB1c2Ugb2YgdGhpcyBjZXJ0aWZpY2F0ZSBpcyBzdWJqZWN0IHRvIHRoZSBOZXRMb2NrIENQ +UyBhdmFpbGFibGUgYXQgaHR0cHM6Ly93d3cubmV0bG9jay5uZXQvZG9jcyBvciBieSBlLW1haWwg +YXQgY3BzQG5ldGxvY2submV0LjANBgkqhkiG9w0BAQQFAAOBgQAQrX/XDDKACtiG8XmYta3UzbM2 +xJZIwVzNmtkFLp++UOv0JhQQLdRmF/iewSf98e3ke0ugbLWrmldwpu2gpO0u9f38vf5NNwgMvOOW +gyL1SRt/Syu0VMGAfJlOHdCM7tCs5ZL6dVb+ZKATj7i4Fp1hBWeAyNDYpQcCNJgEjTME1A== +-----END CERTIFICATE----- + +XRamp Global CA Root +==================== +-----BEGIN CERTIFICATE----- +MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE +BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj +dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx +HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg +U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu +IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx +foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE +zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs +AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry +xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap +oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC +AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc +/Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt +qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n +nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz +8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw= +-----END CERTIFICATE----- + +Go Daddy Class 2 CA +=================== +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY +VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG +A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g +RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD +ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv +2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32 +qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j +YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY +vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O +BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o +atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu +MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG +A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim +PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt +I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI +Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b +vZ8= +-----END CERTIFICATE----- + +Starfield Class 2 CA +==================== +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc +U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo +MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG +A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG +SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY +bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ +JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm +epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN +F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF +MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f +hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo +bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g +QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs +afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM +PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl +xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD +KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3 +QBFGmh95DmK/D5fs4C8fF5Q= +-----END CERTIFICATE----- + +StartCom Certification Authority +================================ +-----BEGIN CERTIFICATE----- +MIIHyTCCBbGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMN +U3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmlu +ZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0 +NjM2WhcNMzYwOTE3MTk0NjM2WjB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRk +LjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMg +U3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw +ggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZkpMyONvg45iPwbm2xPN1y +o4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rfOQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/ +Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/CJi/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/d +eMotHweXMAEtcnn6RtYTKqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt +2PZE4XNiHzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMMAv+Z +6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w+2OqqGwaVLRcJXrJ +osmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/ +untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVc +UjyJthkqcwEKDwOzEmDyei+B26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT +37uMdBNSSwIDAQABo4ICUjCCAk4wDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAa4wHQYDVR0OBBYE +FE4L7xqkQFulF2mHMMo0aEPQQa7yMGQGA1UdHwRdMFswLKAqoCiGJmh0dHA6Ly9jZXJ0LnN0YXJ0 +Y29tLm9yZy9zZnNjYS1jcmwuY3JsMCugKaAnhiVodHRwOi8vY3JsLnN0YXJ0Y29tLm9yZy9zZnNj +YS1jcmwuY3JsMIIBXQYDVR0gBIIBVDCCAVAwggFMBgsrBgEEAYG1NwEBATCCATswLwYIKwYBBQUH +AgEWI2h0dHA6Ly9jZXJ0LnN0YXJ0Y29tLm9yZy9wb2xpY3kucGRmMDUGCCsGAQUFBwIBFilodHRw +Oi8vY2VydC5zdGFydGNvbS5vcmcvaW50ZXJtZWRpYXRlLnBkZjCB0AYIKwYBBQUHAgIwgcMwJxYg +U3RhcnQgQ29tbWVyY2lhbCAoU3RhcnRDb20pIEx0ZC4wAwIBARqBl0xpbWl0ZWQgTGlhYmlsaXR5 +LCByZWFkIHRoZSBzZWN0aW9uICpMZWdhbCBMaW1pdGF0aW9ucyogb2YgdGhlIFN0YXJ0Q29tIENl +cnRpZmljYXRpb24gQXV0aG9yaXR5IFBvbGljeSBhdmFpbGFibGUgYXQgaHR0cDovL2NlcnQuc3Rh +cnRjb20ub3JnL3BvbGljeS5wZGYwEQYJYIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilT +dGFydENvbSBGcmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQUFAAOC +AgEAFmyZ9GYMNPXQhV59CuzaEE44HF7fpiUFS5Eyweg78T3dRAlbB0mKKctmArexmvclmAk8jhvh +3TaHK0u7aNM5Zj2gJsfyOZEdUauCe37Vzlrk4gNXcGmXCPleWKYK34wGmkUWFjgKXlf2Ysd6AgXm +vB618p70qSmD+LIU424oh0TDkBreOKk8rENNZEXO3SipXPJzewT4F+irsfMuXGRuczE6Eri8sxHk +fY+BUZo7jYn0TZNmezwD7dOaHZrzZVD1oNB1ny+v8OqCQ5j4aZyJecRDjkZy42Q2Eq/3JR44iZB3 +fsNrarnDy0RLrHiQi+fHLB5LEUTINFInzQpdn4XBidUaePKVEFMy3YCEZnXZtWgo+2EuvoSoOMCZ +EoalHmdkrQYuL6lwhceWD3yJZfWOQ1QOq92lgDmUYMA0yZZwLKMS9R9Ie70cfmu3nZD0Ijuu+Pwq +yvqCUqDvr0tVk+vBtfAii6w0TiYiBKGHLHVKt+V9E9e4DGTANtLJL4YSjCMJwRuCO3NJo2pXh5Tl +1njFmUNj403gdy3hZZlyaQQaRwnmDwFWJPsfvw55qVguucQJAX6Vum0ABj6y6koQOdjQK/W/7HW/ +lwLFCRsI3FU34oH7N4RDYiDK51ZLZer+bMEkkyShNOsF/5oirpt9P/FlUQqmMGqz9IgcgA38coro +g14= +-----END CERTIFICATE----- + +Taiwan GRCA +=========== +-----BEGIN CERTIFICATE----- +MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQG +EwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X +DTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1owPzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dv +dmVybm1lbnQgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qN +w8XRIePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1qgQdW8or5 +BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKyyhwOeYHWtXBiCAEuTk8O +1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAtsF/tnyMKtsc2AtJfcdgEWFelq16TheEfO +htX7MfP6Mb40qij7cEwdScevLJ1tZqa2jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov +J5pGfaENda1UhhXcSTvxls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7 +Q3hub/FCVGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHKYS1t +B6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoHEgKXTiCQ8P8NHuJB +O9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThNXo+EHWbNxWCWtFJaBYmOlXqYwZE8 +lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1UdDgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNV +HRMEBTADAQH/MDkGBGcqBwAEMTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg2 +09yewDL7MTqKUWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ +TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyfqzvS/3WXy6Tj +Zwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaKZEk9GhiHkASfQlK3T8v+R0F2 +Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFEJPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlU +D7gsL0u8qV1bYH+Mh6XgUmMqvtg7hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6Qz +DxARvBMB1uUO07+1EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+Hbk +Z6MmnD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WXudpVBrkk +7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44VbnzssQwmSNOXfJIoRIM3BKQ +CZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDeLMDDav7v3Aun+kbfYNucpllQdSNpc5Oy ++fwC00fmcc4QAu4njIT/rEUNE1yDMuAlpYYsfPQS +-----END CERTIFICATE----- + +Swisscom Root CA 1 +================== +-----BEGIN CERTIFICATE----- +MIIF2TCCA8GgAwIBAgIQXAuFXAvnWUHfV8w/f52oNjANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQG +EwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsTHERpZ2l0YWwgQ2VydGlmaWNhdGUgU2Vy +dmljZXMxGzAZBgNVBAMTElN3aXNzY29tIFJvb3QgQ0EgMTAeFw0wNTA4MTgxMjA2MjBaFw0yNTA4 +MTgyMjA2MjBaMGQxCzAJBgNVBAYTAmNoMREwDwYDVQQKEwhTd2lzc2NvbTElMCMGA1UECxMcRGln +aXRhbCBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczEbMBkGA1UEAxMSU3dpc3Njb20gUm9vdCBDQSAxMIIC +IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0LmwqAzZuz8h+BvVM5OAFmUgdbI9m2BtRsiM +MW8Xw/qabFbtPMWRV8PNq5ZJkCoZSx6jbVfd8StiKHVFXqrWW/oLJdihFvkcxC7mlSpnzNApbjyF +NDhhSbEAn9Y6cV9Nbc5fuankiX9qUvrKm/LcqfmdmUc/TilftKaNXXsLmREDA/7n29uj/x2lzZAe +AR81sH8A25Bvxn570e56eqeqDFdvpG3FEzuwpdntMhy0XmeLVNxzh+XTF3xmUHJd1BpYwdnP2IkC +b6dJtDZd0KTeByy2dbcokdaXvij1mB7qWybJvbCXc9qukSbraMH5ORXWZ0sKbU/Lz7DkQnGMU3nn +7uHbHaBuHYwadzVcFh4rUx80i9Fs/PJnB3r1re3WmquhsUvhzDdf/X/NTa64H5xD+SpYVUNFvJbN +cA78yeNmuk6NO4HLFWR7uZToXTNShXEuT46iBhFRyePLoW4xCGQMwtI89Tbo19AOeCMgkckkKmUp +WyL3Ic6DXqTz3kvTaI9GdVyDCW4pa8RwjPWd1yAv/0bSKzjCL3UcPX7ape8eYIVpQtPM+GP+HkM5 +haa2Y0EQs3MevNP6yn0WR+Kn1dCjigoIlmJWbjTb2QK5MHXjBNLnj8KwEUAKrNVxAmKLMb7dxiNY +MUJDLXT5xp6mig/p/r+D5kNXJLrvRjSq1xIBOO0CAwEAAaOBhjCBgzAOBgNVHQ8BAf8EBAMCAYYw +HQYDVR0hBBYwFDASBgdghXQBUwABBgdghXQBUwABMBIGA1UdEwEB/wQIMAYBAf8CAQcwHwYDVR0j +BBgwFoAUAyUv3m+CATpcLNwroWm1Z9SM0/0wHQYDVR0OBBYEFAMlL95vggE6XCzcK6FptWfUjNP9 +MA0GCSqGSIb3DQEBBQUAA4ICAQA1EMvspgQNDQ/NwNurqPKIlwzfky9NfEBWMXrrpA9gzXrzvsMn +jgM+pN0S734edAY8PzHyHHuRMSG08NBsl9Tpl7IkVh5WwzW9iAUPWxAaZOHHgjD5Mq2eUCzneAXQ +MbFamIp1TpBcahQq4FJHgmDmHtqBsfsUC1rxn9KVuj7QG9YVHaO+htXbD8BJZLsuUBlL0iT43R4H +VtA4oJVwIHaM190e3p9xxCPvgxNcoyQVTSlAPGrEqdi3pkSlDfTgnXceQHAm/NrZNuR55LU/vJtl +vrsRls/bxig5OgjOR1tTWsWZ/l2p3e9M1MalrQLmjAcSHm8D0W+go/MpvRLHUKKwf4ipmXeascCl +OS5cfGniLLDqN2qk4Vrh9VDlg++luyqI54zb/W1elxmofmZ1a3Hqv7HHb6D0jqTsNFFbjCYDcKF3 +1QESVwA12yPeDooomf2xEG9L/zgtYE4snOtnta1J7ksfrK/7DZBaZmBwXarNeNQk7shBoJMBkpxq +nvy5JMWzFYJ+vq6VK+uxwNrjAWALXmmshFZhvnEX/h0TD/7Gh0Xp/jKgGg0TpJRVcaUWi7rKibCy +x/yP2FS1k2Kdzs9Z+z0YzirLNRWCXf9UIltxUvu3yf5gmwBBZPCqKuy2QkPOiWaByIufOVQDJdMW +NY6E0F/6MBr1mmz0DlP5OlvRHA== +-----END CERTIFICATE----- + +DigiCert Assured ID Root CA +=========================== +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw +IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx +MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL +ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO +9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy +UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW +/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy +oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf +GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF +66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq +hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc +EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn +SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i +8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe ++o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== +-----END CERTIFICATE----- + +DigiCert Global Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw +HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw +MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3 +dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq +hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn +TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5 +BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H +4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y +7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB +o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm +8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF +BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr +EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt +tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886 +UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk +CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= +-----END CERTIFICATE----- + +DigiCert High Assurance EV Root CA +================================== +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw +KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw +MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ +MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu +Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t +Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS +OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3 +MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ +NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe +h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB +Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY +JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ +V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp +myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK +mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe +vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K +-----END CERTIFICATE----- + +Certplus Class 2 Primary CA +=========================== +-----BEGIN CERTIFICATE----- +MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAwPTELMAkGA1UE +BhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFzcyAyIFByaW1hcnkgQ0EwHhcN +OTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2Vy +dHBsdXMxGzAZBgNVBAMTEkNsYXNzIDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBANxQltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR +5aiRVhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyLkcAbmXuZ +Vg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCdEgETjdyAYveVqUSISnFO +YFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yasH7WLO7dDWWuwJKZtkIvEcupdM5i3y95e +e++U8Rs+yskhwcWYAqqi9lt3m/V+llU0HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRME +CDAGAQH/AgEKMAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJ +YIZIAYb4QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMuY29t +L0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/AN9WM2K191EBkOvD +P9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8yfFC82x/xXp8HVGIutIKPidd3i1R +TtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMRFcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+ +7UCmnYR0ObncHoUW2ikbhiMAybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW +//1IMwrh3KWBkJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7 +l7+ijrRU +-----END CERTIFICATE----- + +DST Root CA X3 +============== +-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK +ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X +DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1 +cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT +rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9 +UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy +xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d +utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T +AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ +MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug +dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE +GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw +RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS +fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ +-----END CERTIFICATE----- + +DST ACES CA X6 +============== +-----BEGIN CERTIFICATE----- +MIIECTCCAvGgAwIBAgIQDV6ZCtadt3js2AdWO4YV2TANBgkqhkiG9w0BAQUFADBbMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QxETAPBgNVBAsTCERTVCBBQ0VT +MRcwFQYDVQQDEw5EU1QgQUNFUyBDQSBYNjAeFw0wMzExMjAyMTE5NThaFw0xNzExMjAyMTE5NTha +MFsxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdDERMA8GA1UE +CxMIRFNUIEFDRVMxFzAVBgNVBAMTDkRTVCBBQ0VTIENBIFg2MIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAuT31LMmU3HWKlV1j6IR3dma5WZFcRt2SPp/5DgO0PWGSvSMmtWPuktKe1jzI +DZBfZIGxqAgNTNj50wUoUrQBJcWVHAx+PhCEdc/BGZFjz+iokYi5Q1K7gLFViYsx+tC3dr5BPTCa +pCIlF3PoHuLTrCq9Wzgh1SpL11V94zpVvddtawJXa+ZHfAjIgrrep4c9oW24MFbCswKBXy314pow +GCi4ZtPLAZZv6opFVdbgnf9nKxcCpk4aahELfrd755jWjHZvwTvbUJN+5dCOHze4vbrGn2zpfDPy +MjwmR/onJALJfh1biEITajV8fTXpLmaRcpPVMibEdPVTo7NdmvYJywIDAQABo4HIMIHFMA8GA1Ud +EwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgHGMB8GA1UdEQQYMBaBFHBraS1vcHNAdHJ1c3Rkc3Qu +Y29tMGIGA1UdIARbMFkwVwYKYIZIAWUDAgEBATBJMEcGCCsGAQUFBwIBFjtodHRwOi8vd3d3LnRy +dXN0ZHN0LmNvbS9jZXJ0aWZpY2F0ZXMvcG9saWN5L0FDRVMtaW5kZXguaHRtbDAdBgNVHQ4EFgQU +CXIGThhDD+XWzMNqizF7eI+og7gwDQYJKoZIhvcNAQEFBQADggEBAKPYjtay284F5zLNAdMEA+V2 +5FYrnJmQ6AgwbN99Pe7lv7UkQIRJ4dEorsTCOlMwiPH1d25Ryvr/ma8kXxug/fKshMrfqfBfBC6t +Fr8hlxCBPeP/h40y3JTlR4peahPJlJU90u7INJXQgNStMgiAVDzgvVJT11J8smk/f3rPanTK+gQq +nExaBqXpIK1FZg9p8d2/6eMyi/rgwYZNcjwu2JN4Cir42NInPRmJX1p7ijvMDNpRrscL9yuwNwXs +vFcj4jjSm2jzVhKIT0J8uDHEtdvkyCE06UgRNe76x5JXxZ805Mf29w4LTJxoeHtxMcfrHuBnQfO3 +oKfN5XozNmr6mis= +-----END CERTIFICATE----- + +TURKTRUST Certificate Services Provider Root 1 +============================================== +-----BEGIN CERTIFICATE----- +MIID+zCCAuOgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBtzE/MD0GA1UEAww2VMOcUktUUlVTVCBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGDAJUUjEP +MA0GA1UEBwwGQU5LQVJBMVYwVAYDVQQKDE0oYykgMjAwNSBUw5xSS1RSVVNUIEJpbGdpIMSwbGV0 +acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjAeFw0wNTA1MTMx +MDI3MTdaFw0xNTAzMjIxMDI3MTdaMIG3MT8wPQYDVQQDDDZUw5xSS1RSVVNUIEVsZWt0cm9uaWsg +U2VydGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLExCzAJBgNVBAYMAlRSMQ8wDQYDVQQHDAZB +TktBUkExVjBUBgNVBAoMTShjKSAyMDA1IFTDnFJLVFJVU1QgQmlsZ2kgxLBsZXRpxZ9pbSB2ZSBC +aWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEuxZ4uMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAylIF1mMD2Bxf3dJ7XfIMYGFbazt0K3gNfUW9InTojAPBxhEqPZW8qZSwu5GX +yGl8hMW0kWxsE2qkVa2kheiVfrMArwDCBRj1cJ02i67L5BuBf5OI+2pVu32Fks66WJ/bMsW9Xe8i +Si9BB35JYbOG7E6mQW6EvAPs9TscyB/C7qju6hJKjRTP8wrgUDn5CDX4EVmt5yLqS8oUBt5CurKZ +8y1UiBAG6uEaPj1nH/vO+3yC6BFdSsG5FOpU2WabfIl9BJpiyelSPJ6c79L1JuTm5Rh8i27fbMx4 +W09ysstcP4wFjdFMjK2Sx+F4f2VsSQZQLJ4ywtdKxnWKWU51b0dewQIDAQABoxAwDjAMBgNVHRME +BTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAV9VX/N5aAWSGk/KEVTCD21F/aAyT8z5Aa9CEKmu46 +sWrv7/hg0Uw2ZkUd82YCdAR7kjCo3gp2D++Vbr3JN+YaDayJSFvMgzbC9UZcWYJWtNX+I7TYVBxE +q8Sn5RTOPEFhfEPmzcSBCYsk+1Ql1haolgxnB2+zUEfjHCQo3SqYpGH+2+oSN7wBGjSFvW5P55Fy +B0SFHljKVETd96y5y4khctuPwGkplyqjrhgjlxxBKot8KsF8kOipKMDTkcatKIdAaLX/7KfS0zgY +nNN9aV3wxqUeJBujR/xpB2jn5Jq07Q+hh4cCzofSSE7hvP/L8XKSRGQDJereW26fyfJOrN3H +-----END CERTIFICATE----- + +TURKTRUST Certificate Services Provider Root 2 +============================================== +-----BEGIN CERTIFICATE----- +MIIEPDCCAySgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJUUjEP +MA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUg +QmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwHhcN +MDUxMTA3MTAwNzU3WhcNMTUwOTE2MTAwNzU3WjCBvjE/MD0GA1UEAww2VMOcUktUUlVTVCBFbGVr +dHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJUUjEPMA0G +A1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUgQmls +acWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgS2FzxLFtIDIwMDUwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpNn7DkUNMwxmYCMjHWHtPFoylzkkBH3MOrHUTpvqe +LCDe2JAOCtFp0if7qnefJ1Il4std2NiDUBd9irWCPwSOtNXwSadktx4uXyCcUHVPr+G1QRT0mJKI +x+XlZEdhR3n9wFHxwZnn3M5q+6+1ATDcRhzviuyV79z/rxAc653YsKpqhRgNF8k+v/Gb0AmJQv2g +QrSdiVFVKc8bcLyEVK3BEx+Y9C52YItdP5qtygy/p1Zbj3e41Z55SZI/4PGXJHpsmxcPbe9TmJEr +5A++WXkHeLuXlfSfadRYhwqp48y2WBmfJiGxxFmNskF1wK1pzpwACPI2/z7woQ8arBT9pmAPAgMB +AAGjQzBBMB0GA1UdDgQWBBTZN7NOBf3Zz58SFq62iS/rJTqIHDAPBgNVHQ8BAf8EBQMDBwYAMA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHJglrfJ3NgpXiOFX7KzLXb7iNcX/ntt +Rbj2hWyfIvwqECLsqrkw9qtY1jkQMZkpAL2JZkH7dN6RwRgLn7Vhy506vvWolKMiVW4XSf/SKfE4 +Jl3vpao6+XF75tpYHdN0wgH6PmlYX63LaL4ULptswLbcoCb6dxriJNoaN+BnrdFzgw2lGh1uEpJ+ +hGIAF728JRhX8tepb1mIvDS3LoV4nZbcFMMsilKbloxSZj2GFotHuFEJjOp9zYhys2AzsfAKRO8P +9Qk3iCQOLGsgOqL6EfJANZxEaGM7rDNvY7wsu/LSy3Z9fYjYHcgFHW68lKlmjHdxx/qR+i9Rnuk5 +UrbnBEI= +-----END CERTIFICATE----- + +SwissSign Gold CA - G2 +====================== +-----BEGIN CERTIFICATE----- +MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw +EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN +MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp +c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq +t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C +jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg +vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF +ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR +AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend +jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO +peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR +7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi +GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw +AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64 +OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov +L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm +5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr +44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf +Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m +Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp +mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk +vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf +KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br +NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj +viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ +-----END CERTIFICATE----- + +SwissSign Silver CA - G2 +======================== +-----BEGIN CERTIFICATE----- +MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT +BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X +DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3 +aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG +9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644 +N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm ++/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH +6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu +MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h +qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5 +FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs +ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc +celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X +CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB +tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0 +cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P +4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F +kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L +3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx +/uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa +DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP +e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu +WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ +DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub +DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority +======================================== +-----BEGIN CERTIFICATE----- +MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx +CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ +cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN +b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9 +nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge +RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt +tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI +hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K +Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN +NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa +Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG +1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk= +-----END CERTIFICATE----- + +thawte Primary Root CA +====================== +-----BEGIN CERTIFICATE----- +MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE +BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2 +aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3 +MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg +SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv +KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT +FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs +oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ +1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc +q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K +aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p +afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD +VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF +AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE +uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX +xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89 +jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH +z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA== +-----END CERTIFICATE----- + +VeriSign Class 3 Public Primary Certification Authority - G5 +============================================================ +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln +biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh +dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz +j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD +Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/ +Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r +fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/ +BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv +Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy +aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG +SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+ +X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE +KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC +Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE +ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq +-----END CERTIFICATE----- + +SecureTrust CA +============== +-----BEGIN CERTIFICATE----- +MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy +dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe +BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX +OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t +DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH +GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b +01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH +ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj +aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ +KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu +SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf +mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ +nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR +3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= +-----END CERTIFICATE----- + +Secure Global CA +================ +-----BEGIN CERTIFICATE----- +MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG +EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH +bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg +MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg +Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx +YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ +bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g +8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV +HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi +0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn +oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA +MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+ +OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn +CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5 +3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc +f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW +-----END CERTIFICATE----- + +COMODO Certification Authority +============================== +-----BEGIN CERTIFICATE----- +MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE +BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG +A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1 +dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb +MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD +T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH ++7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww +xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV +4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA +1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI +rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k +b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC +AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP +OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/ +RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc +IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN ++8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ== +-----END CERTIFICATE----- + +Network Solutions Certificate Authority +======================================= +-----BEGIN CERTIFICATE----- +MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG +EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr +IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx +MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu +MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx +jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT +aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT +crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc +/Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB +AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv +bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA +A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q +4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/ +GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv +wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD +ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey +-----END CERTIFICATE----- + +WellsSecure Public Root Certificate Authority +============================================= +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoM +F1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYw +NAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcN +MDcxMjEzMTcwNzU0WhcNMjIxMjE0MDAwNzU0WjCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dl +bGxzIEZhcmdvIFdlbGxzU2VjdXJlMRwwGgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYD +VQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDub7S9eeKPCCGeOARBJe+rWxxTkqxtnt3CxC5FlAM1 +iGd0V+PfjLindo8796jE2yljDpFoNoqXjopxaAkH5OjUDk/41itMpBb570OYj7OeUt9tkTmPOL13 +i0Nj67eT/DBMHAGTthP796EfvyXhdDcsHqRePGj4S78NuR4uNuip5Kf4D8uCdXw1LSLWwr8L87T8 +bJVhHlfXBIEyg1J55oNjz7fLY4sR4r1e6/aN7ZVyKLSsEmLpSjPmgzKuBXWVvYSV2ypcm44uDLiB +K0HmOFafSZtsdvqKXfcBeYF8wYNABf5x/Qw/zE5gCQ5lRxAvAcAFP4/4s0HvWkJ+We/SlwxlAgMB +AAGjggE0MIIBMDAPBgNVHRMBAf8EBTADAQH/MDkGA1UdHwQyMDAwLqAsoCqGKGh0dHA6Ly9jcmwu +cGtpLndlbGxzZmFyZ28uY29tL3dzcHJjYS5jcmwwDgYDVR0PAQH/BAQDAgHGMB0GA1UdDgQWBBQm +lRkQ2eihl5H/3BnZtQQ+0nMKajCBsgYDVR0jBIGqMIGngBQmlRkQ2eihl5H/3BnZtQQ+0nMKaqGB +i6SBiDCBhTELMAkGA1UEBhMCVVMxIDAeBgNVBAoMF1dlbGxzIEZhcmdvIFdlbGxzU2VjdXJlMRww +GgYDVQQLDBNXZWxscyBGYXJnbyBCYW5rIE5BMTYwNAYDVQQDDC1XZWxsc1NlY3VyZSBQdWJsaWMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQEwDQYJKoZIhvcNAQEFBQADggEBALkVsUSRzCPI +K0134/iaeycNzXK7mQDKfGYZUMbVmO2rvwNa5U3lHshPcZeG1eMd/ZDJPHV3V3p9+N701NX3leZ0 +bh08rnyd2wIDBSxxSyU+B+NemvVmFymIGjifz6pBA4SXa5M4esowRBskRDPQ5NHcKDj0E0M1NSlj +qHyita04pO2t/caaH/+Xc/77szWnk4bGdpEA5qxRFsQnMlzbc9qlk1eOPm01JghZ1edE13YgY+es +E2fDbbFwRnzVlhE9iW9dqKHrjQrawx0zbKPqZxmamX9LPYNRKh3KL4YMon4QLSvUFpULB6ouFJJJ +tylv2G0xffX8oRAHh84vWdw+WNs= +-----END CERTIFICATE----- + +COMODO ECC Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC +R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE +ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix +GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo +b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X +4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni +wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG +FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA +U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= +-----END CERTIFICATE----- + +IGC/A +===== +-----BEGIN CERTIFICATE----- +MIIEAjCCAuqgAwIBAgIFORFFEJQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkZSMQ8wDQYD +VQQIEwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVE +Q1NTSTEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZy +MB4XDTAyMTIxMzE0MjkyM1oXDTIwMTAxNzE0MjkyMlowgYUxCzAJBgNVBAYTAkZSMQ8wDQYDVQQI +EwZGcmFuY2UxDjAMBgNVBAcTBVBhcmlzMRAwDgYDVQQKEwdQTS9TR0ROMQ4wDAYDVQQLEwVEQ1NT +STEOMAwGA1UEAxMFSUdDL0ExIzAhBgkqhkiG9w0BCQEWFGlnY2FAc2dkbi5wbS5nb3V2LmZyMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsh/R0GLFMzvABIaIs9z4iPf930Pfeo2aSVz2 +TqrMHLmh6yeJ8kbpO0px1R2OLc/mratjUMdUC24SyZA2xtgv2pGqaMVy/hcKshd+ebUyiHDKcMCW +So7kVc0dJ5S/znIq7Fz5cyD+vfcuiWe4u0dzEvfRNWk68gq5rv9GQkaiv6GFGvm/5P9JhfejcIYy +HF2fYPepraX/z9E0+X1bF8bc1g4oa8Ld8fUzaJ1O/Id8NhLWo4DoQw1VYZTqZDdH6nfK0LJYBcNd +frGoRpAxVs5wKpayMLh35nnAvSk7/ZR3TL0gzUEl4C7HG7vupARB0l2tEmqKm0f7yd1GQOGdPDPQ +tQIDAQABo3cwdTAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBRjAVBgNVHSAEDjAMMAoGCCqB +egF5AQEBMB0GA1UdDgQWBBSjBS8YYFDCiQrdKyFP/45OqDAxNjAfBgNVHSMEGDAWgBSjBS8YYFDC +iQrdKyFP/45OqDAxNjANBgkqhkiG9w0BAQUFAAOCAQEABdwm2Pp3FURo/C9mOnTgXeQp/wYHE4RK +q89toB9RlPhJy3Q2FLwV3duJL92PoF189RLrn544pEfMs5bZvpwlqwN+Mw+VgQ39FuCIvjfwbF3Q +MZsyK10XZZOYYLxuj7GoPB7ZHPOpJkL5ZB3C55L29B5aqhlSXa/oovdgoPaN8In1buAKBQGVyYsg +Crpa/JosPL3Dt8ldeCUFP1YUmwza+zpI/pdpXsoQhvdOlgQITeywvl3cO45Pwf2aNjSaTFR+FwNI +lQgRHAdvhQh+XU3Endv7rs6y0bO4g2wdsrN58dhwmX7wEwLOXt1R0982gaEbeC9xs/FZTEYYKKuF +0mBWWg== +-----END CERTIFICATE----- + +Security Communication EV RootCA1 +================================= +-----BEGIN CERTIFICATE----- +MIIDfTCCAmWgAwIBAgIBADANBgkqhkiG9w0BAQUFADBgMQswCQYDVQQGEwJKUDElMCMGA1UEChMc +U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEqMCgGA1UECxMhU2VjdXJpdHkgQ29tbXVuaWNh +dGlvbiBFViBSb290Q0ExMB4XDTA3MDYwNjAyMTIzMloXDTM3MDYwNjAyMTIzMlowYDELMAkGA1UE +BhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKjAoBgNVBAsTIVNl +Y3VyaXR5IENvbW11bmljYXRpb24gRVYgUm9vdENBMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBALx/7FebJOD+nLpCeamIivqA4PUHKUPqjgo0No0c+qe1OXj/l3X3L+SqawSERMqm4miO +/VVQYg+kcQ7OBzgtQoVQrTyWb4vVog7P3kmJPdZkLjjlHmy1V4qe70gOzXppFodEtZDkBp2uoQSX +WHnvIEqCa4wiv+wfD+mEce3xDuS4GBPMVjZd0ZoeUWs5bmB2iDQL87PRsJ3KYeJkHcFGB7hj3R4z +ZbOOCVVSPbW9/wfrrWFVGCypaZhKqkDFMxRldAD5kd6vA0jFQFTcD4SQaCDFkpbcLuUCRarAX1T4 +bepJz11sS6/vmsJWXMY1VkJqMF/Cq/biPT+zyRGPMUzXn0kCAwEAAaNCMEAwHQYDVR0OBBYEFDVK +9U2vP9eCOKyrcWUXdYydVZPmMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqG +SIb3DQEBBQUAA4IBAQCoh+ns+EBnXcPBZsdAS5f8hxOQWsTvoMpfi7ent/HWtWS3irO4G8za+6xm +iEHO6Pzk2x6Ipu0nUBsCMCRGef4Eh3CXQHPRwMFXGZpppSeZq51ihPZRwSzJIxXYKLerJRO1RuGG +Av8mjMSIkh1W/hln8lXkgKNrnKt34VFxDSDbEJrbvXZ5B3eZKK2aXtqxT0QsNY6llsf9g/BYxnnW +mHyojf6GPgcWkuF75x3sM3Z+Qi5KhfmRiWiEA4Glm5q+4zfFVKtWOxgtQaQM+ELbmaDgcm+7XeEW +T1MKZPlO9L9OVL14bIjqv5wTJMJwaaJ/D8g8rQjJsJhAoyrniIPtd490 +-----END CERTIFICATE----- + +OISTE WISeKey Global Root GA CA +=============================== +-----BEGIN CERTIFICATE----- +MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UE +BhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHlyaWdodCAoYykgMjAwNTEiMCAG +A1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBH +bG9iYWwgUm9vdCBHQSBDQTAeFw0wNTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYD +VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIw +IAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5 +IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0+zAJs9 +Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxRVVuuk+g3/ytr6dTqvirdqFEr12bDYVxg +Asj1znJ7O7jyTmUIms2kahnBAbtzptf2w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbD +d50kc3vkDIzh2TbhmYsFmQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ +/yxViJGg4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t94B3R +LoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw +AwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ +KoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOxSPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vIm +MMkQyh2I+3QZH4VFvbBsUfk2ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4 ++vg1YFkCExh8vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa +hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZiFj4A4xylNoEY +okxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ/L7fCg0= +-----END CERTIFICATE----- + +Microsec e-Szigno Root CA +========================= +-----BEGIN CERTIFICATE----- +MIIHqDCCBpCgAwIBAgIRAMy4579OKRr9otxmpRwsDxEwDQYJKoZIhvcNAQEFBQAwcjELMAkGA1UE +BhMCSFUxETAPBgNVBAcTCEJ1ZGFwZXN0MRYwFAYDVQQKEw1NaWNyb3NlYyBMdGQuMRQwEgYDVQQL +EwtlLVN6aWdubyBDQTEiMCAGA1UEAxMZTWljcm9zZWMgZS1Temlnbm8gUm9vdCBDQTAeFw0wNTA0 +MDYxMjI4NDRaFw0xNzA0MDYxMjI4NDRaMHIxCzAJBgNVBAYTAkhVMREwDwYDVQQHEwhCdWRhcGVz +dDEWMBQGA1UEChMNTWljcm9zZWMgTHRkLjEUMBIGA1UECxMLZS1Temlnbm8gQ0ExIjAgBgNVBAMT +GU1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQDtyADVgXvNOABHzNuEwSFpLHSQDCHZU4ftPkNEU6+r+ICbPHiN1I2uuO/TEdyB5s87lozWbxXG +d36hL+BfkrYn13aaHUM86tnsL+4582pnS4uCzyL4ZVX+LMsvfUh6PXX5qqAnu3jCBspRwn5mS6/N +oqdNAoI/gqyFxuEPkEeZlApxcpMqyabAvjxWTHOSJ/FrtfX9/DAFYJLG65Z+AZHCabEeHXtTRbjc +QR/Ji3HWVBTji1R4P770Yjtb9aPs1ZJ04nQw7wHb4dSrmZsqa/i9phyGI0Jf7Enemotb9HI6QMVJ +PqW+jqpx62z69Rrkav17fVVA71hu5tnVvCSrwe+3AgMBAAGjggQ3MIIEMzBnBggrBgEFBQcBAQRb +MFkwKAYIKwYBBQUHMAGGHGh0dHBzOi8vcmNhLmUtc3ppZ25vLmh1L29jc3AwLQYIKwYBBQUHMAKG +IWh0dHA6Ly93d3cuZS1zemlnbm8uaHUvUm9vdENBLmNydDAPBgNVHRMBAf8EBTADAQH/MIIBcwYD +VR0gBIIBajCCAWYwggFiBgwrBgEEAYGoGAIBAQEwggFQMCgGCCsGAQUFBwIBFhxodHRwOi8vd3d3 +LmUtc3ppZ25vLmh1L1NaU1ovMIIBIgYIKwYBBQUHAgIwggEUHoIBEABBACAAdABhAG4A+gBzAO0A +dAB2AOEAbgB5ACAA6QByAHQAZQBsAG0AZQB6AOkAcwDpAGgAZQB6ACAA6QBzACAAZQBsAGYAbwBn +AGEAZADhAHMA4QBoAG8AegAgAGEAIABTAHoAbwBsAGcA4QBsAHQAYQB0APMAIABTAHoAbwBsAGcA +4QBsAHQAYQB0AOEAcwBpACAAUwB6AGEAYgDhAGwAeQB6AGEAdABhACAAcwB6AGUAcgBpAG4AdAAg +AGsAZQBsAGwAIABlAGwAagDhAHIAbgBpADoAIABoAHQAdABwADoALwAvAHcAdwB3AC4AZQAtAHMA +egBpAGcAbgBvAC4AaAB1AC8AUwBaAFMAWgAvMIHIBgNVHR8EgcAwgb0wgbqggbeggbSGIWh0dHA6 +Ly93d3cuZS1zemlnbm8uaHUvUm9vdENBLmNybIaBjmxkYXA6Ly9sZGFwLmUtc3ppZ25vLmh1L0NO +PU1pY3Jvc2VjJTIwZS1Temlnbm8lMjBSb290JTIwQ0EsT1U9ZS1Temlnbm8lMjBDQSxPPU1pY3Jv +c2VjJTIwTHRkLixMPUJ1ZGFwZXN0LEM9SFU/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5h +cnkwDgYDVR0PAQH/BAQDAgEGMIGWBgNVHREEgY4wgYuBEGluZm9AZS1zemlnbm8uaHWkdzB1MSMw +IQYDVQQDDBpNaWNyb3NlYyBlLVN6aWduw7MgUm9vdCBDQTEWMBQGA1UECwwNZS1TemlnbsOzIEhT +WjEWMBQGA1UEChMNTWljcm9zZWMgS2Z0LjERMA8GA1UEBxMIQnVkYXBlc3QxCzAJBgNVBAYTAkhV +MIGsBgNVHSMEgaQwgaGAFMegSXUWYYTbMUuE0vE3QJDvTtz3oXakdDByMQswCQYDVQQGEwJIVTER +MA8GA1UEBxMIQnVkYXBlc3QxFjAUBgNVBAoTDU1pY3Jvc2VjIEx0ZC4xFDASBgNVBAsTC2UtU3pp +Z25vIENBMSIwIAYDVQQDExlNaWNyb3NlYyBlLVN6aWdubyBSb290IENBghEAzLjnv04pGv2i3Gal +HCwPETAdBgNVHQ4EFgQUx6BJdRZhhNsxS4TS8TdAkO9O3PcwDQYJKoZIhvcNAQEFBQADggEBANMT +nGZjWS7KXHAM/IO8VbH0jgdsZifOwTsgqRy7RlRw7lrMoHfqaEQn6/Ip3Xep1fvj1KcExJW4C+FE +aGAHQzAxQmHl7tnlJNUb3+FKG6qfx1/4ehHqE5MAyopYse7tDk2016g2JnzgOsHVV4Lxdbb9iV/a +86g4nzUGCM4ilb7N1fy+W955a9x6qWVmvrElWl/tftOsRm1M9DKHtCAE4Gx4sHfRhUZLphK3dehK +yVZs15KrnfVJONJPU+NVkBHbmJbGSfI+9J8b4PeI3CVimUTYc78/MPMMNz7UwiiAc7EBt51alhQB +S6kRnSlqLtBdgcDPsiBDxwPgN05dCtxZICU= +-----END CERTIFICATE----- + +Certigna +======== +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw +EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3 +MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI +Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q +XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH +GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p +ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg +DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf +Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ +tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ +BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J +SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA +hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+ +ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu +PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY +1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw +WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg== +-----END CERTIFICATE----- + +TC TrustCenter Class 2 CA II +============================ +-----BEGIN CERTIFICATE----- +MIIEqjCCA5KgAwIBAgIOLmoAAQACH9dSISwRXDswDQYJKoZIhvcNAQEFBQAwdjELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxIjAgBgNVBAsTGVRDIFRydXN0Q2VudGVy +IENsYXNzIDIgQ0ExJTAjBgNVBAMTHFRDIFRydXN0Q2VudGVyIENsYXNzIDIgQ0EgSUkwHhcNMDYw +MTEyMTQzODQzWhcNMjUxMjMxMjI1OTU5WjB2MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMgVHJ1 +c3RDZW50ZXIgR21iSDEiMCAGA1UECxMZVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMiBDQTElMCMGA1UE +AxMcVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMiBDQSBJSTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAKuAh5uO8MN8h9foJIIRszzdQ2Lu+MNF2ujhoF/RKrLqk2jftMjWQ+nEdVl//OEd+DFw +IxuInie5e/060smp6RQvkL4DUsFJzfb95AhmC1eKokKguNV/aVyQMrKXDcpK3EY+AlWJU+MaWss2 +xgdW94zPEfRMuzBwBJWl9jmM/XOBCH2JXjIeIqkiRUuwZi4wzJ9l/fzLganx4Duvo4bRierERXlQ +Xa7pIXSSTYtZgo+U4+lK8edJsBTj9WLL1XK9H7nSn6DNqPoByNkN39r8R52zyFTfSUrxIan+GE7u +SNQZu+995OKdy1u2bv/jzVrndIIFuoAlOMvkaZ6vQaoahPUCAwEAAaOCATQwggEwMA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTjq1RMgKHbVkO3kUrL84J6E1wIqzCB +7QYDVR0fBIHlMIHiMIHfoIHcoIHZhjVodHRwOi8vd3d3LnRydXN0Y2VudGVyLmRlL2NybC92Mi90 +Y19jbGFzc18yX2NhX0lJLmNybIaBn2xkYXA6Ly93d3cudHJ1c3RjZW50ZXIuZGUvQ049VEMlMjBU +cnVzdENlbnRlciUyMENsYXNzJTIwMiUyMENBJTIwSUksTz1UQyUyMFRydXN0Q2VudGVyJTIwR21i +SCxPVT1yb290Y2VydHMsREM9dHJ1c3RjZW50ZXIsREM9ZGU/Y2VydGlmaWNhdGVSZXZvY2F0aW9u +TGlzdD9iYXNlPzANBgkqhkiG9w0BAQUFAAOCAQEAjNfffu4bgBCzg/XbEeprS6iSGNn3Bzn1LL4G +dXpoUxUc6krtXvwjshOg0wn/9vYua0Fxec3ibf2uWWuFHbhOIprtZjluS5TmVfwLG4t3wVMTZonZ +KNaL80VKY7f9ewthXbhtvsPcW3nS7Yblok2+XnR8au0WOB9/WIFaGusyiC2y8zl3gK9etmF1Kdsj +TYjKUCjLhdLTEKJZbtOTVAB6okaVhgWcqRmY5TFyDADiZ9lA4CQze28suVyrZZ0srHbqNZn1l7kP +JOzHdiEoZa5X6AeIdUpWoNIFOqTmjZKILPPy4cHGYdtBxceb9w4aUUXCYWvcZCcXjFq32nQozZfk +vQ== +-----END CERTIFICATE----- + +TC TrustCenter Universal CA I +============================= +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIOHaIAAQAC7LdggHiNtgYwDQYJKoZIhvcNAQEFBQAweTELMAkGA1UEBhMC +REUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxJDAiBgNVBAsTG1RDIFRydXN0Q2VudGVy +IFVuaXZlcnNhbCBDQTEmMCQGA1UEAxMdVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2FsIENBIEkwHhcN +MDYwMzIyMTU1NDI4WhcNMjUxMjMxMjI1OTU5WjB5MQswCQYDVQQGEwJERTEcMBoGA1UEChMTVEMg +VHJ1c3RDZW50ZXIgR21iSDEkMCIGA1UECxMbVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2FsIENBMSYw +JAYDVQQDEx1UQyBUcnVzdENlbnRlciBVbml2ZXJzYWwgQ0EgSTCCASIwDQYJKoZIhvcNAQEBBQAD +ggEPADCCAQoCggEBAKR3I5ZEr5D0MacQ9CaHnPM42Q9e3s9B6DGtxnSRJJZ4Hgmgm5qVSkr1YnwC +qMqs+1oEdjneX/H5s7/zA1hV0qq34wQi0fiU2iIIAI3TfCZdzHd55yx4Oagmcw6iXSVphU9VDprv +xrlE4Vc93x9UIuVvZaozhDrzznq+VZeujRIPFDPiUHDDSYcTvFHe15gSWu86gzOSBnWLknwSaHtw +ag+1m7Z3W0hZneTvWq3zwZ7U10VOylY0Ibw+F1tvdwxIAUMpsN0/lm7mlaoMwCC2/T42J5zjXM9O +gdwZu5GQfezmlwQek8wiSdeXhrYTCjxDI3d+8NzmzSQfO4ObNDqDNOMCAwEAAaNjMGEwHwYDVR0j +BBgwFoAUkqR1LKSevoFE63n8isWVpesQdXMwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AYYwHQYDVR0OBBYEFJKkdSyknr6BROt5/IrFlaXrEHVzMA0GCSqGSIb3DQEBBQUAA4IBAQAo0uCG +1eb4e/CX3CJrO5UUVg8RMKWaTzqwOuAGy2X17caXJ/4l8lfmXpWMPmRgFVp/Lw0BxbFg/UU1z/Cy +vwbZ71q+s2IhtNerNXxTPqYn8aEt2hojnczd7Dwtnic0XQ/CNnm8yUpiLe1r2X1BQ3y2qsrtYbE3 +ghUJGooWMNjsydZHcnhLEEYUjl8Or+zHL6sQ17bxbuyGssLoDZJz3KL0Dzq/YSMQiZxIQG5wALPT +ujdEWBF6AmqI8Dc08BnprNRlc/ZpjGSUOnmFKbAWKwyCPwacx/0QK54PLLae4xW/2TYcuiUaUj0a +7CIMHOCkoj3w6DnPgcB77V0fb8XQC9eY +-----END CERTIFICATE----- + +Deutsche Telekom Root CA 2 +========================== +-----BEGIN CERTIFICATE----- +MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMT +RGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEG +A1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENBIDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5 +MjM1OTAwWjBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0G +A1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBS +b290IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEUha88EOQ5 +bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhCQN/Po7qCWWqSG6wcmtoI +KyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1MjwrrFDa1sPeg5TKqAyZMg4ISFZbavva4VhY +AUlfckE8FQYBjl2tqriTtM2e66foai1SNNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aK +Se5TBY8ZTNXeWHmb0mocQqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTV +jlsB9WoHtxa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAPBgNV +HRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAlGRZrTlk5ynr +E/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756AbrsptJh6sTtU6zkXR34ajgv8HzFZMQSy +zhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpaIzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8 +rZ7/gFnkm0W09juwzTkZmDLl6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4G +dyd1Lx+4ivn+xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU +Cm26OWMohpLzGITY+9HPBVZkVw== +-----END CERTIFICATE----- + +ComSign Secured CA +================== +-----BEGIN CERTIFICATE----- +MIIDqzCCApOgAwIBAgIRAMcoRwmzuGxFjB36JPU2TukwDQYJKoZIhvcNAQEFBQAwPDEbMBkGA1UE +AxMSQ29tU2lnbiBTZWN1cmVkIENBMRAwDgYDVQQKEwdDb21TaWduMQswCQYDVQQGEwJJTDAeFw0w +NDAzMjQxMTM3MjBaFw0yOTAzMTYxNTA0NTZaMDwxGzAZBgNVBAMTEkNvbVNpZ24gU2VjdXJlZCBD +QTEQMA4GA1UEChMHQ29tU2lnbjELMAkGA1UEBhMCSUwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDGtWhfHZQVw6QIVS3joFd67+l0Kru5fFdJGhFeTymHDEjWaueP1H5XJLkGieQcPOqs +49ohgHMhCu95mGwfCP+hUH3ymBvJVG8+pSjsIQQPRbsHPaHA+iqYHU4Gk/v1iDurX8sWv+bznkqH +7Rnqwp9D5PGBpX8QTz7RSmKtUxvLg/8HZaWSLWapW7ha9B20IZFKF3ueMv5WJDmyVIRD9YTC2LxB +kMyd1mja6YJQqTtoz7VdApRgFrFD2UNd3V2Hbuq7s8lr9gOUCXDeFhF6K+h2j0kQmHe5Y1yLM5d1 +9guMsqtb3nQgJT/j8xH5h2iGNXHDHYwt6+UarA9z1YJZQIDTAgMBAAGjgacwgaQwDAYDVR0TBAUw +AwEB/zBEBgNVHR8EPTA7MDmgN6A1hjNodHRwOi8vZmVkaXIuY29tc2lnbi5jby5pbC9jcmwvQ29t +U2lnblNlY3VyZWRDQS5jcmwwDgYDVR0PAQH/BAQDAgGGMB8GA1UdIwQYMBaAFMFL7XC29z58ADsA +j8c+DkWfHl3sMB0GA1UdDgQWBBTBS+1wtvc+fAA7AI/HPg5Fnx5d7DANBgkqhkiG9w0BAQUFAAOC +AQEAFs/ukhNQq3sUnjO2QiBq1BW9Cav8cujvR3qQrFHBZE7piL1DRYHjZiM/EoZNGeQFsOY3wo3a +BijJD4mkU6l1P7CW+6tMM1X5eCZGbxs2mPtCdsGCuY7e+0X5YxtiOzkGynd6qDwJz2w2PQ8KRUtp +FhpFfTMDZflScZAmlaxMDPWLkz/MdXSFmLr/YnpNH4n+rr2UAJm/EaXc4HnFFgt9AmEd6oX5AhVP +51qJThRv4zdLhfXBPGHg/QVBspJ/wx2g0K5SZGBrGMYmnNj1ZOQ2GmKfig8+/21OGVZOIJFsnzQz +OjRXUDpvgV4GxvU+fE6OK85lBi5d0ipTdF7Tbieejw== +-----END CERTIFICATE----- + +Cybertrust Global Root +====================== +-----BEGIN CERTIFICATE----- +MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li +ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4 +MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD +ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA ++Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW +0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL +AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin +89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT +8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2 +MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G +A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO +lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi +5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2 +hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T +X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW +WL1WMRJOEcgh4LMRkWXbtKaIOM5V +-----END CERTIFICATE----- + +ePKI Root Certification Authority +================================= +-----BEGIN CERTIFICATE----- +MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG +EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg +Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx +MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq +MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs +IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi +lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv +qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX +12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O +WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+ +ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao +lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/ +vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi +Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi +MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH +ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0 +1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq +KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV +xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP +NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r +GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE +xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx +gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy +sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD +BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw= +-----END CERTIFICATE----- + +T\xc3\x9c\x42\xC4\xB0TAK UEKAE K\xC3\xB6k Sertifika Hizmet Sa\xC4\x9Flay\xc4\xb1\x63\xc4\xb1s\xc4\xb1 - S\xC3\xBCr\xC3\xBCm 3 +============================================================================================================================= +-----BEGIN CERTIFICATE----- +MIIFFzCCA/+gAwIBAgIBETANBgkqhkiG9w0BAQUFADCCASsxCzAJBgNVBAYTAlRSMRgwFgYDVQQH +DA9HZWJ6ZSAtIEtvY2FlbGkxRzBFBgNVBAoMPlTDvHJraXllIEJpbGltc2VsIHZlIFRla25vbG9q +aWsgQXJhxZ90xLFybWEgS3VydW11IC0gVMOcQsSwVEFLMUgwRgYDVQQLDD9VbHVzYWwgRWxla3Ry +b25payB2ZSBLcmlwdG9sb2ppIEFyYcWfdMSxcm1hIEVuc3RpdMO8c8O8IC0gVUVLQUUxIzAhBgNV +BAsMGkthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppMUowSAYDVQQDDEFUw5xCxLBUQUsgVUVLQUUg +S8O2ayBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsSAtIFPDvHLDvG0gMzAeFw0wNzA4 +MjQxMTM3MDdaFw0xNzA4MjExMTM3MDdaMIIBKzELMAkGA1UEBhMCVFIxGDAWBgNVBAcMD0dlYnpl +IC0gS29jYWVsaTFHMEUGA1UECgw+VMO8cmtpeWUgQmlsaW1zZWwgdmUgVGVrbm9sb2ppayBBcmHF +n3TEsXJtYSBLdXJ1bXUgLSBUw5xCxLBUQUsxSDBGBgNVBAsMP1VsdXNhbCBFbGVrdHJvbmlrIHZl +IEtyaXB0b2xvamkgQXJhxZ90xLFybWEgRW5zdGl0w7xzw7wgLSBVRUtBRTEjMCEGA1UECwwaS2Ft +dSBTZXJ0aWZpa2FzeW9uIE1lcmtlemkxSjBIBgNVBAMMQVTDnELEsFRBSyBVRUtBRSBLw7ZrIFNl +cnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIC0gU8O8csO8bSAzMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAim1L/xCIOsP2fpTo6iBkcK4hgb46ezzb8R1Sf1n68yJMlaCQvEhO +Eav7t7WNeoMojCZG2E6VQIdhn8WebYGHV2yKO7Rm6sxA/OOqbLLLAdsyv9Lrhc+hDVXDWzhXcLh1 +xnnRFDDtG1hba+818qEhTsXOfJlfbLm4IpNQp81McGq+agV/E5wrHur+R84EpW+sky58K5+eeROR +6Oqeyjh1jmKwlZMq5d/pXpduIF9fhHpEORlAHLpVK/swsoHvhOPc7Jg4OQOFCKlUAwUp8MmPi+oL +hmUZEdPpCSPeaJMDyTYcIW7OjGbxmTDY17PDHfiBLqi9ggtm/oLL4eAagsNAgQIDAQABo0IwQDAd +BgNVHQ4EFgQUvYiHyY/2pAoLquvF/pEjnatKijIwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAB18+kmPNOm3JpIWmgV050vQbTlswyb2zrgxvMTfvCr4 +N5EY3ATIZJkrGG2AA1nJrvhY0D7twyOfaTyGOBye79oneNGEN3GKPEs5z35FBtYt2IpNeBLWrcLT +y9LQQfMmNkqblWwM7uXRQydmwYj3erMgbOqwaSvHIOgMA8RBBZniP+Rr+KCGgceExh/VS4ESshYh +LBOhgLJeDEoTniDYYkCrkOpkSi+sDQESeUWoL4cZaMjihccwsnX5OD+ywJO0a+IDRM5noN+J1q2M +dqMTw5RhK2vZbMEHCiIHhWyFJEapvj+LeISCfiQMnf2BN+MlqO02TpUsyZyQ2uypQjyttgI= +-----END CERTIFICATE----- + +Buypass Class 2 CA 1 +==================== +-----BEGIN CERTIFICATE----- +MIIDUzCCAjugAwIBAgIBATANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMiBDQSAxMB4XDTA2 +MTAxMzEwMjUwOVoXDTE2MTAxMzEwMjUwOVowSzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBh +c3MgQVMtOTgzMTYzMzI3MR0wGwYDVQQDDBRCdXlwYXNzIENsYXNzIDIgQ0EgMTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAIs8B0XY9t/mx8q6jUPFR42wWsE425KEHK8T1A9vNkYgxC7M +cXA0ojTTNy7Y3Tp3L8DrKehc0rWpkTSHIln+zNvnma+WwajHQN2lFYxuyHyXA8vmIPLXl18xoS83 +0r7uvqmtqEyeIWZDO6i88wmjONVZJMHCR3axiFyCO7srpgTXjAePzdVBHfCuuCkslFJgNJQ72uA4 +0Z0zPhX0kzLFANq1KWYOOngPIVJfAuWSeyXTkh4vFZ2B5J2O6O+JzhRMVB0cgRJNcKi+EAUXfh/R +uFdV7c27UsKwHnjCTTZoy1YmwVLBvXb3WNVyfh9EdrsAiR0WnVE1703CVu9r4Iw7DekCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUP42aWYv8e3uco684sDntkHGA1sgwDgYDVR0P +AQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQAVGn4TirnoB6NLJzKyQJHyIdFkhb5jatLPgcIV +1Xp+DCmsNx4cfHZSldq1fyOhKXdlyTKdqC5Wq2B2zha0jX94wNWZUYN/Xtm+DKhQ7SLHrQVMdvvt +7h5HZPb3J31cKA9FxVxiXqaakZG3Uxcu3K1gnZZkOb1naLKuBctN518fV4bVIJwo+28TOPX2EZL2 +fZleHwzoq0QkKXJAPTZSr4xYkHPB7GEseaHsh7U/2k3ZIQAw3pDaDtMaSKk+hQsUi4y8QZ5q9w5w +wDX3OaJdZtB7WZ+oRxKaJyOkLY4ng5IgodcVf/EuGO70SH8vf/GhGLWhC5SgYiAynB321O+/TIho +-----END CERTIFICATE----- + +Buypass Class 3 CA 1 +==================== +-----BEGIN CERTIFICATE----- +MIIDUzCCAjugAwIBAgIBAjANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMyBDQSAxMB4XDTA1 +MDUwOTE0MTMwM1oXDTE1MDUwOTE0MTMwM1owSzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBh +c3MgQVMtOTgzMTYzMzI3MR0wGwYDVQQDDBRCdXlwYXNzIENsYXNzIDMgQ0EgMTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAKSO13TZKWTeXx+HgJHqTjnmGcZEC4DVC69TB4sSveZn8AKx +ifZgisRbsELRwCGoy+Gb72RRtqfPFfV0gGgEkKBYouZ0plNTVUhjP5JW3SROjvi6K//zNIqeKNc0 +n6wv1g/xpC+9UrJJhW05NfBEMJNGJPO251P7vGGvqaMU+8IXF4Rs4HyI+MkcVyzwPX6UvCWThOia +AJpFBUJXgPROztmuOfbIUxAMZTpHe2DC1vqRycZxbL2RhzyRhkmr8w+gbCZ2Xhysm3HljbybIR6c +1jh+JIAVMYKWsUnTYjdbiAwKYjT+p0h+mbEwi5A3lRyoH6UsjfRVyNvdWQrCrXig9IsCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUOBTmyPCppAP0Tj4io1vy1uCtQHQwDgYDVR0P +AQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQABZ6OMySU9E2NdFm/soT4JXJEVKirZgCFPBdy7 +pYmrEzMqnji3jG8CcmPHc3ceCQa6Oyh7pEfJYWsICCD8igWKH7y6xsL+z27sEzNxZy5p+qksP2bA +EllNC1QCkoS72xLvg3BweMhT+t/Gxv/ciC8HwEmdMldg0/L2mSlf56oBzKwzqBwKu5HEA6BvtjT5 +htOzdlSY9EqBs1OdTUDs5XcTRa9bqh/YL0yCe/4qxFi7T/ye/QNlGioOw6UgFpRreaaiErS7GqQj +el/wroQk5PMr+4okoyeYZdowdXb8GZHo2+ubPzK/QJcHJrrM85SFSnonk8+QQtS4Wxam58tAA915 +-----END CERTIFICATE----- + +EBG Elektronik Sertifika Hizmet Sa\xC4\x9Flay\xc4\xb1\x63\xc4\xb1s\xc4\xb1 +========================================================================== +-----BEGIN CERTIFICATE----- +MIIF5zCCA8+gAwIBAgIITK9zQhyOdAIwDQYJKoZIhvcNAQEFBQAwgYAxODA2BgNVBAMML0VCRyBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMTcwNQYDVQQKDC5FQkcg +QmlsacWfaW0gVGVrbm9sb2ppbGVyaSB2ZSBIaXptZXRsZXJpIEEuxZ4uMQswCQYDVQQGEwJUUjAe +Fw0wNjA4MTcwMDIxMDlaFw0xNjA4MTQwMDMxMDlaMIGAMTgwNgYDVQQDDC9FQkcgRWxla3Ryb25p +ayBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsTE3MDUGA1UECgwuRUJHIEJpbGnFn2lt +IFRla25vbG9qaWxlcmkgdmUgSGl6bWV0bGVyaSBBLsWeLjELMAkGA1UEBhMCVFIwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQDuoIRh0DpqZhAy2DE4f6en5f2h4fuXd7hxlugTlkaDT7by +X3JWbhNgpQGR4lvFzVcfd2NR/y8927k/qqk153nQ9dAktiHq6yOU/im/+4mRDGSaBUorzAzu8T2b +gmmkTPiab+ci2hC6X5L8GCcKqKpE+i4stPtGmggDg3KriORqcsnlZR9uKg+ds+g75AxuetpX/dfr +eYteIAbTdgtsApWjluTLdlHRKJ2hGvxEok3MenaoDT2/F08iiFD9rrbskFBKW5+VQarKD7JK/oCZ +TqNGFav4c0JqwmZ2sQomFd2TkuzbqV9UIlKRcF0T6kjsbgNs2d1s/OsNA/+mgxKb8amTD8UmTDGy +Y5lhcucqZJnSuOl14nypqZoaqsNW2xCaPINStnuWt6yHd6i58mcLlEOzrz5z+kI2sSXFCjEmN1Zn +uqMLfdb3ic1nobc6HmZP9qBVFCVMLDMNpkGMvQQxahByCp0OLna9XvNRiYuoP1Vzv9s6xiQFlpJI +qkuNKgPlV5EQ9GooFW5Hd4RcUXSfGenmHmMWOeMRFeNYGkS9y8RsZteEBt8w9DeiQyJ50hBs37vm +ExH8nYQKE3vwO9D8owrXieqWfo1IhR5kX9tUoqzVegJ5a9KK8GfaZXINFHDk6Y54jzJ0fFfy1tb0 +Nokb+Clsi7n2l9GkLqq+CxnCRelwXQIDAJ3Zo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB +/wQEAwIBBjAdBgNVHQ4EFgQU587GT/wWZ5b6SqMHwQSny2re2kcwHwYDVR0jBBgwFoAU587GT/wW +Z5b6SqMHwQSny2re2kcwDQYJKoZIhvcNAQEFBQADggIBAJuYml2+8ygjdsZs93/mQJ7ANtyVDR2t +FcU22NU57/IeIl6zgrRdu0waypIN30ckHrMk2pGI6YNw3ZPX6bqz3xZaPt7gyPvT/Wwp+BVGoGgm +zJNSroIBk5DKd8pNSe/iWtkqvTDOTLKBtjDOWU/aWR1qeqRFsIImgYZ29fUQALjuswnoT4cCB64k +XPBfrAowzIpAoHMEwfuJJPaaHFy3PApnNgUIMbOv2AFoKuB4j3TeuFGkjGwgPaL7s9QJ/XvCgKqT +bCmYIai7FvOpEl90tYeY8pUm3zTvilORiF0alKM/fCL414i6poyWqD1SNGKfAB5UVUJnxk1Gj7sU +RT0KlhaOEKGXmdXTMIXM3rRyt7yKPBgpaP3ccQfuJDlq+u2lrDgv+R4QDgZxGhBM/nV+/x5XOULK +1+EVoVZVWRvRo68R2E7DpSvvkL/A7IITW43WciyTTo9qKd+FPNMN4KIYEsxVL0e3p5sC/kH2iExt +2qkBR4NkJ2IQgtYSe14DHzSpyZH+r11thie3I6p1GMog57AP14kOpmciY/SDQSsGS7tY1dHXt7kQ +Y9iJSrSq3RZj9W6+YKH47ejWkE8axsWgKdOnIaj1Wjz3x0miIZpKlVIglnKaZsv30oZDfCK+lvm9 +AahH3eU7QPl1K5srRmSGjR70j/sHd9DqSaIcjVIUpgqT +-----END CERTIFICATE----- + +certSIGN ROOT CA +================ +-----BEGIN CERTIFICATE----- +MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD +VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa +Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE +CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I +JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH +rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2 +ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD +0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943 +AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B +Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB +AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8 +SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0 +x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt +vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz +TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD +-----END CERTIFICATE----- + +CNNIC ROOT +========== +-----BEGIN CERTIFICATE----- +MIIDVTCCAj2gAwIBAgIESTMAATANBgkqhkiG9w0BAQUFADAyMQswCQYDVQQGEwJDTjEOMAwGA1UE +ChMFQ05OSUMxEzARBgNVBAMTCkNOTklDIFJPT1QwHhcNMDcwNDE2MDcwOTE0WhcNMjcwNDE2MDcw +OTE0WjAyMQswCQYDVQQGEwJDTjEOMAwGA1UEChMFQ05OSUMxEzARBgNVBAMTCkNOTklDIFJPT1Qw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDTNfc/c3et6FtzF8LRb+1VvG7q6KR5smzD +o+/hn7E7SIX1mlwhIhAsxYLO2uOabjfhhyzcuQxauohV3/2q2x8x6gHx3zkBwRP9SFIhxFXf2tiz +VHa6dLG3fdfA6PZZxU3Iva0fFNrfWEQlMhkqx35+jq44sDB7R3IJMfAw28Mbdim7aXZOV/kbZKKT +VrdvmW7bCgScEeOAH8tjlBAKqeFkgjH5jCftppkA9nCTGPihNIaj3XrCGHn2emU1z5DrvTOTn1Or +czvmmzQgLx3vqR1jGqCA2wMv+SYahtKNu6m+UjqHZ0gNv7Sg2Ca+I19zN38m5pIEo3/PIKe38zrK +y5nLAgMBAAGjczBxMBEGCWCGSAGG+EIBAQQEAwIABzAfBgNVHSMEGDAWgBRl8jGtKvf33VKWCscC +wQ7vptU7ETAPBgNVHRMBAf8EBTADAQH/MAsGA1UdDwQEAwIB/jAdBgNVHQ4EFgQUZfIxrSr3991S +lgrHAsEO76bVOxEwDQYJKoZIhvcNAQEFBQADggEBAEs17szkrr/Dbq2flTtLP1se31cpolnKOOK5 +Gv+e5m4y3R6u6jW39ZORTtpC4cMXYFDy0VwmuYK36m3knITnA3kXr5g9lNvHugDnuL8BV8F3RTIM +O/G0HAiw/VGgod2aHRM2mm23xzy54cXZF/qD1T0VoDy7HgviyJA/qIYM/PmLXoXLT1tLYhFHxUV8 +BS9BsZ4QaRuZluBVeftOhpm4lNqGOGqTo+fLbuXf6iFViZx9fX+Y9QCJ7uOEwFyWtcVG6kbghVW2 +G8kS1sHNzYDzAgE8yGnLRUhj2JTQ7IUOO04RZfSCjKY9ri4ilAnIXOo8gV0WKgOXFlUJ24pBgp5m +mxE= +-----END CERTIFICATE----- + +ApplicationCA - Japanese Government +=================================== +-----BEGIN CERTIFICATE----- +MIIDoDCCAoigAwIBAgIBMTANBgkqhkiG9w0BAQUFADBDMQswCQYDVQQGEwJKUDEcMBoGA1UEChMT +SmFwYW5lc2UgR292ZXJubWVudDEWMBQGA1UECxMNQXBwbGljYXRpb25DQTAeFw0wNzEyMTIxNTAw +MDBaFw0xNzEyMTIxNTAwMDBaMEMxCzAJBgNVBAYTAkpQMRwwGgYDVQQKExNKYXBhbmVzZSBHb3Zl +cm5tZW50MRYwFAYDVQQLEw1BcHBsaWNhdGlvbkNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB +CgKCAQEAp23gdE6Hj6UG3mii24aZS2QNcfAKBZuOquHMLtJqO8F6tJdhjYq+xpqcBrSGUeQ3DnR4 +fl+Kf5Sk10cI/VBaVuRorChzoHvpfxiSQE8tnfWuREhzNgaeZCw7NCPbXCbkcXmP1G55IrmTwcrN +wVbtiGrXoDkhBFcsovW8R0FPXjQilbUfKW1eSvNNcr5BViCH/OlQR9cwFO5cjFW6WY2H/CPek9AE +jP3vbb3QesmlOmpyM8ZKDQUXKi17safY1vC+9D/qDihtQWEjdnjDuGWk81quzMKq2edY3rZ+nYVu +nyoKb58DKTCXKB28t89UKU5RMfkntigm/qJj5kEW8DOYRwIDAQABo4GeMIGbMB0GA1UdDgQWBBRU +WssmP3HMlEYNllPqa0jQk/5CdTAOBgNVHQ8BAf8EBAMCAQYwWQYDVR0RBFIwUKROMEwxCzAJBgNV +BAYTAkpQMRgwFgYDVQQKDA/ml6XmnKzlm73mlL/lupwxIzAhBgNVBAsMGuOCouODl+ODquOCseOD +vOOCt+ODp+ODs0NBMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADlqRHZ3ODrs +o2dGD/mLBqj7apAxzn7s2tGJfHrrLgy9mTLnsCTWw//1sogJhyzjVOGjprIIC8CFqMjSnHH2HZ9g +/DgzE+Ge3Atf2hZQKXsvcJEPmbo0NI2VdMV+eKlmXb3KIXdCEKxmJj3ekav9FfBv7WxfEPjzFvYD +io+nEhEMy/0/ecGc/WLuo89UDNErXxc+4z6/wCs+CZv+iKZ+tJIX/COUgb1up8WMwusRRdv4QcmW +dupwX3kSa+SjB1oF7ydJzyGfikwJcGapJsErEU4z0g781mzSDjJkaP+tBXhfAx2o45CsJOAPQKdL +rosot4LKGAfmt1t06SAZf7IbiVQ= +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority - G3 +============================================= +-----BEGIN CERTIFICATE----- +MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE +BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0 +IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz +NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo +YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT +LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j +K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE +c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C +IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu +dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr +2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9 +cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE +Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD +AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s +t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt +-----END CERTIFICATE----- + +thawte Primary Root CA - G2 +=========================== +-----BEGIN CERTIFICATE----- +MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC +VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu +IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg +Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV +MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG +b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt +IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS +LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5 +8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU +mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN +G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K +rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg== +-----END CERTIFICATE----- + +thawte Primary Root CA - G3 +=========================== +-----BEGIN CERTIFICATE----- +MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE +BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2 +aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w +ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh +d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD +VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG +A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At +P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC ++BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY +7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW +vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ +KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK +A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu +t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC +8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm +er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A= +-----END CERTIFICATE----- + +GeoTrust Primary Certification Authority - G2 +============================================= +-----BEGIN CERTIFICATE----- +MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu +Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1 +OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg +MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl +b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG +BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc +KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD +VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+ +EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m +ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2 +npaqBA+K +-----END CERTIFICATE----- + +VeriSign Universal Root Certification Authority +=============================================== +-----BEGIN CERTIFICATE----- +MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u +IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj +1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP +MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72 +9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I +AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR +tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G +CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O +a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud +DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3 +Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx +Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx +P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P +wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4 +mJO37M2CYfE45k+XmCpajQ== +-----END CERTIFICATE----- + +VeriSign Class 3 Public Primary Certification Authority - G4 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC +VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3 +b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz +ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU +cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo +b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8 +Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz +rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw +HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u +Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD +A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx +AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== +-----END CERTIFICATE----- + +NetLock Arany (Class Gold) FÅ‘tanúsítvány +============================================ +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G +A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610 +dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB +cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx +MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO +ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv +biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6 +c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu +0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw +/HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk +H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw +fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1 +neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB +BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW +qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta +YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC +bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna +NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu +dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E= +-----END CERTIFICATE----- + +Staat der Nederlanden Root CA - G2 +================================== +-----BEGIN CERTIFICATE----- +MIIFyjCCA7KgAwIBAgIEAJiWjDANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE +CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g +Um9vdCBDQSAtIEcyMB4XDTA4MDMyNjExMTgxN1oXDTIwMDMyNTExMDMxMFowWjELMAkGA1UEBhMC +TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l +ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMVZ +5291qj5LnLW4rJ4L5PnZyqtdj7U5EILXr1HgO+EASGrP2uEGQxGZqhQlEq0i6ABtQ8SpuOUfiUtn +vWFI7/3S4GCI5bkYYCjDdyutsDeqN95kWSpGV+RLufg3fNU254DBtvPUZ5uW6M7XxgpT0GtJlvOj +CwV3SPcl5XCsMBQgJeN/dVrlSPhOewMHBPqCYYdu8DvEpMfQ9XQ+pV0aCPKbJdL2rAQmPlU6Yiil +e7Iwr/g3wtG61jj99O9JMDeZJiFIhQGp5Rbn3JBV3w/oOM2ZNyFPXfUib2rFEhZgF1XyZWampzCR +OME4HYYEhLoaJXhena/MUGDWE4dS7WMfbWV9whUYdMrhfmQpjHLYFhN9C0lK8SgbIHRrxT3dsKpI +CT0ugpTNGmXZK4iambwYfp/ufWZ8Pr2UuIHOzZgweMFvZ9C+X+Bo7d7iscksWXiSqt8rYGPy5V65 +48r6f1CGPqI0GAwJaCgRHOThuVw+R7oyPxjMW4T182t0xHJ04eOLoEq9jWYv6q012iDTiIJh8BIi +trzQ1aTsr1SIJSQ8p22xcik/Plemf1WvbibG/ufMQFxRRIEKeN5KzlW/HdXZt1bv8Hb/C3m1r737 +qWmRRpdogBQ2HbN/uymYNqUg+oJgYjOk7Na6B6duxc8UpufWkjTYgfX8HV2qXB72o007uPc5AgMB +AAGjgZcwgZQwDwYDVR0TAQH/BAUwAwEB/zBSBgNVHSAESzBJMEcGBFUdIAAwPzA9BggrBgEFBQcC +ARYxaHR0cDovL3d3dy5wa2lvdmVyaGVpZC5ubC9wb2xpY2llcy9yb290LXBvbGljeS1HMjAOBgNV +HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJFoMocVHYnitfGsNig0jQt8YojrMA0GCSqGSIb3DQEBCwUA +A4ICAQCoQUpnKpKBglBu4dfYszk78wIVCVBR7y29JHuIhjv5tLySCZa59sCrI2AGeYwRTlHSeYAz ++51IvuxBQ4EffkdAHOV6CMqqi3WtFMTC6GY8ggen5ieCWxjmD27ZUD6KQhgpxrRW/FYQoAUXvQwj +f/ST7ZwaUb7dRUG/kSS0H4zpX897IZmflZ85OkYcbPnNe5yQzSipx6lVu6xiNGI1E0sUOlWDuYaN +kqbG9AclVMwWVxJKgnjIFNkXgiYtXSAfea7+1HAWFpWD2DU5/1JddRwWxRNVz0fMdWVSSt7wsKfk +CpYL+63C4iWEst3kvX5ZbJvw8NjnyvLplzh+ib7M+zkXYT9y2zqR2GUBGR2tUKRXCnxLvJxxcypF +URmFzI79R6d0lR2o0a9OF7FpJsKqeFdbxU2n5Z4FF5TKsl+gSRiNNOkmbEgeqmiSBeGCc1qb3Adb +CG19ndeNIdn8FCCqwkXfP+cAslHkwvgFuXkajDTznlvkN1trSt8sV4pAWja63XVECDdCcAz+3F4h +oKOKwJCcaNpQ5kUQR3i2TtJlycM33+FCY7BXN0Ute4qcvwXqZVUz9zkQxSgqIXobisQk+T8VyJoV +IPVVYpbtbZNQvOSqeK3Zywplh6ZmwcSBo3c6WB4L7oOLnR7SUqTMHW+wmG2UMbX4cQrcufx9MmDm +66+KAQ== +-----END CERTIFICATE----- + +CA Disig +======== +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBATANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJTSzETMBEGA1UEBxMK +QnJhdGlzbGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcwHhcNMDYw +MzIyMDEzOTM0WhcNMTYwMzIyMDEzOTM0WjBKMQswCQYDVQQGEwJTSzETMBEGA1UEBxMKQnJhdGlz +bGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCS9jHBfYj9mQGp2HvycXXxMcbzdWb6UShGhJd4NLxs/LxFWYgm +GErENx+hSkS943EE9UQX4j/8SFhvXJ56CbpRNyIjZkMhsDxkovhqFQ4/61HhVKndBpnXmjxUizkD +Pw/Fzsbrg3ICqB9x8y34dQjbYkzo+s7552oftms1grrijxaSfQUMbEYDXcDtab86wYqg6I7ZuUUo +hwjstMoVvoLdtUSLLa2GDGhibYVW8qwUYzrG0ZmsNHhWS8+2rT+MitcE5eN4TPWGqvWP+j1scaMt +ymfraHtuM6kMgiioTGohQBUgDCZbg8KpFhXAJIJdKxatymP2dACw30PEEGBWZ2NFAgMBAAGjgf8w +gfwwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUjbJJaJ1yCCW5wCf1UJNWSEZx+Y8wDgYDVR0P +AQH/BAQDAgEGMDYGA1UdEQQvMC2BE2Nhb3BlcmF0b3JAZGlzaWcuc2uGFmh0dHA6Ly93d3cuZGlz +aWcuc2svY2EwZgYDVR0fBF8wXTAtoCugKYYnaHR0cDovL3d3dy5kaXNpZy5zay9jYS9jcmwvY2Ff +ZGlzaWcuY3JsMCygKqAohiZodHRwOi8vY2EuZGlzaWcuc2svY2EvY3JsL2NhX2Rpc2lnLmNybDAa +BgNVHSAEEzARMA8GDSuBHpGT5goAAAABAQEwDQYJKoZIhvcNAQEFBQADggEBAF00dGFMrzvY/59t +WDYcPQuBDRIrRhCA/ec8J9B6yKm2fnQwM6M6int0wHl5QpNt/7EpFIKrIYwvF/k/Ji/1WcbvgAa3 +mkkp7M5+cTxqEEHA9tOasnxakZzArFvITV734VP/Q3f8nktnbNfzg9Gg4H8l37iYC5oyOGwwoPP/ +CBUz91BKez6jPiCp3C9WgArtQVCwyfTssuMmRAAOb54GvCKWU3BlxFAKRmukLyeBEicTXxChds6K +ezfqwzlhA5WYOudsiCUI/HloDYd9Yvi0X/vF2Ey9WLw/Q1vUHgFNPGO+I++MzVpQuGhU+QqZMxEA +4Z7CRneC9VkGjCFMhwnN5ag= +-----END CERTIFICATE----- + +Juur-SK +======= +-----BEGIN CERTIFICATE----- +MIIE5jCCA86gAwIBAgIEO45L/DANBgkqhkiG9w0BAQUFADBdMRgwFgYJKoZIhvcNAQkBFglwa2lA +c2suZWUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKExlBUyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMRAw +DgYDVQQDEwdKdXVyLVNLMB4XDTAxMDgzMDE0MjMwMVoXDTE2MDgyNjE0MjMwMVowXTEYMBYGCSqG +SIb3DQEJARYJcGtpQHNrLmVlMQswCQYDVQQGEwJFRTEiMCAGA1UEChMZQVMgU2VydGlmaXRzZWVy +aW1pc2tlc2t1czEQMA4GA1UEAxMHSnV1ci1TSzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAIFxNj4zB9bjMI0TfncyRsvPGbJgMUaXhvSYRqTCZUXP00B841oiqBB4M8yIsdOBSvZiF3tf +TQou0M+LI+5PAk676w7KvRhj6IAcjeEcjT3g/1tf6mTll+g/mX8MCgkzABpTpyHhOEvWgxutr2TC ++Rx6jGZITWYfGAriPrsfB2WThbkasLnE+w0R9vXW+RvHLCu3GFH+4Hv2qEivbDtPL+/40UceJlfw +UR0zlv/vWT3aTdEVNMfqPxZIe5EcgEMPPbgFPtGzlc3Yyg/CQ2fbt5PgIoIuvvVoKIO5wTtpeyDa +Tpxt4brNj3pssAki14sL2xzVWiZbDcDq5WDQn/413z8CAwEAAaOCAawwggGoMA8GA1UdEwEB/wQF +MAMBAf8wggEWBgNVHSAEggENMIIBCTCCAQUGCisGAQQBzh8BAQEwgfYwgdAGCCsGAQUFBwICMIHD +HoHAAFMAZQBlACAAcwBlAHIAdABpAGYAaQBrAGEAYQB0ACAAbwBuACAAdgDkAGwAagBhAHMAdABh +AHQAdQBkACAAQQBTAC0AaQBzACAAUwBlAHIAdABpAGYAaQB0AHMAZQBlAHIAaQBtAGkAcwBrAGUA +cwBrAHUAcwAgAGEAbABhAG0ALQBTAEsAIABzAGUAcgB0AGkAZgBpAGsAYQBhAHQAaQBkAGUAIABr +AGkAbgBuAGkAdABhAG0AaQBzAGUAawBzMCEGCCsGAQUFBwIBFhVodHRwOi8vd3d3LnNrLmVlL2Nw +cy8wKwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL3d3dy5zay5lZS9qdXVyL2NybC8wHQYDVR0OBBYE +FASqekej5ImvGs8KQKcYP2/v6X2+MB8GA1UdIwQYMBaAFASqekej5ImvGs8KQKcYP2/v6X2+MA4G +A1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQUFAAOCAQEAe8EYlFOiCfP+JmeaUOTDBS8rNXiRTHyo +ERF5TElZrMj3hWVcRrs7EKACr81Ptcw2Kuxd/u+gkcm2k298gFTsxwhwDY77guwqYHhpNjbRxZyL +abVAyJRld/JXIWY7zoVAtjNjGr95HvxcHdMdkxuLDF2FvZkwMhgJkVLpfKG6/2SSmuz+Ne6ML678 +IIbsSt4beDI3poHSna9aEhbKmVv8b20OxaAehsmR0FyYgl9jDIpaq9iVpszLita/ZEuOyoqysOkh +Mp6qqIWYNIE5ITuoOlIyPfZrN4YGWhWY3PARZv40ILcD9EEQfTmEeZZyY7aWAuVrua0ZTbvGRNs2 +yyqcjg== +-----END CERTIFICATE----- + +Hongkong Post Root CA 1 +======================= +-----BEGIN CERTIFICATE----- +MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT +DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx +NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n +IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1 +ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr +auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh +qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY +V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV +HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i +h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio +l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei +IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps +T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT +c4afU9hDDl3WY4JxHYB0yvbiAmvZWg== +-----END CERTIFICATE----- + +SecureSign RootCA11 +=================== +-----BEGIN CERTIFICATE----- +MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi +SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS +b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw +KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1 +cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL +TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO +wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq +g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP +O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA +bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX +t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh +OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r +bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ +Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01 +y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061 +lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I= +-----END CERTIFICATE----- + +ACEDICOM Root +============= +-----BEGIN CERTIFICATE----- +MIIFtTCCA52gAwIBAgIIYY3HhjsBggUwDQYJKoZIhvcNAQEFBQAwRDEWMBQGA1UEAwwNQUNFRElD +T00gUm9vdDEMMAoGA1UECwwDUEtJMQ8wDQYDVQQKDAZFRElDT00xCzAJBgNVBAYTAkVTMB4XDTA4 +MDQxODE2MjQyMloXDTI4MDQxMzE2MjQyMlowRDEWMBQGA1UEAwwNQUNFRElDT00gUm9vdDEMMAoG +A1UECwwDUEtJMQ8wDQYDVQQKDAZFRElDT00xCzAJBgNVBAYTAkVTMIICIjANBgkqhkiG9w0BAQEF +AAOCAg8AMIICCgKCAgEA/5KV4WgGdrQsyFhIyv2AVClVYyT/kGWbEHV7w2rbYgIB8hiGtXxaOLHk +WLn709gtn70yN78sFW2+tfQh0hOR2QetAQXW8713zl9CgQr5auODAKgrLlUTY4HKRxx7XBZXehuD +YAQ6PmXDzQHe3qTWDLqO3tkE7hdWIpuPY/1NFgu3e3eM+SW10W2ZEi5PGrjm6gSSrj0RuVFCPYew +MYWveVqc/udOXpJPQ/yrOq2lEiZmueIM15jO1FillUAKt0SdE3QrwqXrIhWYENiLxQSfHY9g5QYb +m8+5eaA9oiM/Qj9r+hwDezCNzmzAv+YbX79nuIQZ1RXve8uQNjFiybwCq0Zfm/4aaJQ0PZCOrfbk +HQl/Sog4P75n/TSW9R28MHTLOO7VbKvU/PQAtwBbhTIWdjPp2KOZnQUAqhbm84F9b32qhm2tFXTT +xKJxqvQUfecyuB+81fFOvW8XAjnXDpVCOscAPukmYxHqC9FK/xidstd7LzrZlvvoHpKuE1XI2Sf2 +3EgbsCTBheN3nZqk8wwRHQ3ItBTutYJXCb8gWH8vIiPYcMt5bMlL8qkqyPyHK9caUPgn6C9D4zq9 +2Fdx/c6mUlv53U3t5fZvie27k5x2IXXwkkwp9y+cAS7+UEaeZAwUswdbxcJzbPEHXEUkFDWug/Fq +TYl6+rPYLWbwNof1K1MCAwEAAaOBqjCBpzAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKaz +4SsrSbbXc6GqlPUB53NlTKxQMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUprPhKytJttdzoaqU +9QHnc2VMrFAwRAYDVR0gBD0wOzA5BgRVHSAAMDEwLwYIKwYBBQUHAgEWI2h0dHA6Ly9hY2VkaWNv +bS5lZGljb21ncm91cC5jb20vZG9jMA0GCSqGSIb3DQEBBQUAA4ICAQDOLAtSUWImfQwng4/F9tqg +aHtPkl7qpHMyEVNEskTLnewPeUKzEKbHDZ3Ltvo/Onzqv4hTGzz3gvoFNTPhNahXwOf9jU8/kzJP +eGYDdwdY6ZXIfj7QeQCM8htRM5u8lOk6e25SLTKeI6RF+7YuE7CLGLHdztUdp0J/Vb77W7tH1Pwk +zQSulgUV1qzOMPPKC8W64iLgpq0i5ALudBF/TP94HTXa5gI06xgSYXcGCRZj6hitoocf8seACQl1 +ThCojz2GuHURwCRiipZ7SkXp7FnFvmuD5uHorLUwHv4FB4D54SMNUI8FmP8sX+g7tq3PgbUhh8oI +KiMnMCArz+2UW6yyetLHKKGKC5tNSixthT8Jcjxn4tncB7rrZXtaAWPWkFtPF2Y9fwsZo5NjEFIq +nxQWWOLcpfShFosOkYuByptZ+thrkQdlVV9SH686+5DdaaVbnG0OLLb6zqylfDJKZ0DcMDQj3dcE +I2bw/FWAp/tmGYI1Z2JwOV5vx+qQQEQIHriy1tvuWacNGHk0vFQYXlPKNFHtRQrmjseCNj6nOGOp +MCwXEGCSn1WHElkQwg9naRHMTh5+Spqtr0CodaxWkHS4oJyleW/c6RrIaQXpuvoDs3zk4E7Czp3o +tkYNbn5XOmeUwssfnHdKZ05phkOTOPu220+DkdRgfks+KzgHVZhepA== +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky +CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX +bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/ +D/xwzoiQ +-----END CERTIFICATE----- + +Microsec e-Szigno Root CA 2009 +============================== +-----BEGIN CERTIFICATE----- +MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER +MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv +c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o +dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE +BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt +U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA +fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG +0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA +pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm +1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC +AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf +QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE +FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o +lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX +I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775 +tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02 +yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi +LXpUq3DDfSJlgnCW +-----END CERTIFICATE----- + +GlobalSign Root CA - R3 +======================= +-----BEGIN CERTIFICATE----- +MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv +YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh +bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln +bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt +iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ +0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3 +rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl +OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2 +xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7 +lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8 +EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E +bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18 +YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r +kpeDMdmztcpHWD9f +-----END CERTIFICATE----- + +Autoridad de Certificacion Firmaprofesional CIF A62634068 +========================================================= +-----BEGIN CERTIFICATE----- +MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA +BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 +MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw +QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB +NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD +Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P +B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY +7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH +ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI +plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX +MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX +LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK +bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU +vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud +EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH +DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp +cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA +bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx +ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx +51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk +R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP +T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f +Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl +osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR +crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR +saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD +KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi +6Et8Vcad+qMUu2WFbm5PEn4KPJ2V +-----END CERTIFICATE----- + +Izenpe.com +========== +-----BEGIN CERTIFICATE----- +MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG +EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz +MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu +QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ +03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK +ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU ++zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC +PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT +OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK +F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK +0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+ +0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB +leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID +AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+ +SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG +NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx +MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O +BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l +Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga +kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q +hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs +g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5 +aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5 +nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC +ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo +Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z +WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== +-----END CERTIFICATE----- + +Chambers of Commerce Root - 2008 +================================ +-----BEGIN CERTIFICATE----- +MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD +MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv +bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu +QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy +Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl +ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF +EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl +cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC +AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA +XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj +h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/ +ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk +NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g +D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331 +lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ +0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj +ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2 +EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI +G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ +BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh +bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh +bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC +CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH +AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1 +wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH +3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU +RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6 +M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1 +YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF +9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK +zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG +nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg +OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ +-----END CERTIFICATE----- + +Global Chambersign Root - 2008 +============================== +-----BEGIN CERTIFICATE----- +MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD +MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv +bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu +QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx +NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg +Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ +QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD +aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf +VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf +XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0 +ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB +/gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA +TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M +H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe +Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF +HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh +wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB +AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT +BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE +BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm +aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm +aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp +1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0 +dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG +/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6 +ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s +dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg +9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH +foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du +qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr +P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq +c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z +09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B +-----END CERTIFICATE----- + +Go Daddy Root Certificate Authority - G2 +======================================== +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu +MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5 +MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6 +b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G +A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq +9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD ++qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd +fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl +NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9 +BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac +vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r +5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV +N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO +LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1 +-----END CERTIFICATE----- + +Starfield Root Certificate Authority - G2 +========================================= +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0 +eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw +DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg +VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB +dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv +W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs +bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk +N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf +ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU +JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol +TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx +4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw +F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K +pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ +c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 +-----END CERTIFICATE----- + +Starfield Services Root Certificate Authority - G2 +================================================== +-----BEGIN CERTIFICATE----- +MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl +IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV +BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT +dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2 +h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa +hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP +LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB +rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG +SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP +E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy +xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd +iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza +YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6 +-----END CERTIFICATE----- + +AffirmTrust Commercial +====================== +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw +MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly +bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb +DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV +C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6 +BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww +MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV +HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG +hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi +qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv +0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh +sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8= +-----END CERTIFICATE----- + +AffirmTrust Networking +====================== +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw +MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly +bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE +Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI +dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24 +/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb +h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV +HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu +UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6 +12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23 +WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9 +/ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s= +-----END CERTIFICATE----- + +AffirmTrust Premium +=================== +-----BEGIN CERTIFICATE----- +MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS +BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy +OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy +dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A +MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn +BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV +5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs ++7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd +GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R +p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI +S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04 +6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5 +/bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo ++Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB +/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv +MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg +Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC +6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S +L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK ++4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV +BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg +IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60 +g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb +zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw== +-----END CERTIFICATE----- + +AffirmTrust Premium ECC +======================= +-----BEGIN CERTIFICATE----- +MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV +BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx +MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U +cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA +IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ +N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW +BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK +BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X +57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM +eQ== +-----END CERTIFICATE----- + +Certum Trusted Network CA +========================= +-----BEGIN CERTIFICATE----- +MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK +ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy +MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU +ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC +l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J +J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4 +fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0 +cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB +Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw +DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj +jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1 +mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj +Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI +03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw= +-----END CERTIFICATE----- + +Certinomis - Autorité Racine +============================= +-----BEGIN CERTIFICATE----- +MIIFnDCCA4SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJGUjETMBEGA1UEChMK +Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxJjAkBgNVBAMMHUNlcnRpbm9taXMg +LSBBdXRvcml0w6kgUmFjaW5lMB4XDTA4MDkxNzA4Mjg1OVoXDTI4MDkxNzA4Mjg1OVowYzELMAkG +A1UEBhMCRlIxEzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMSYw +JAYDVQQDDB1DZXJ0aW5vbWlzIC0gQXV0b3JpdMOpIFJhY2luZTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAJ2Fn4bT46/HsmtuM+Cet0I0VZ35gb5j2CN2DpdUzZlMGvE5x4jYF1AMnmHa +wE5V3udauHpOd4cN5bjr+p5eex7Ezyh0x5P1FMYiKAT5kcOrJ3NqDi5N8y4oH3DfVS9O7cdxbwly +Lu3VMpfQ8Vh30WC8Tl7bmoT2R2FFK/ZQpn9qcSdIhDWerP5pqZ56XjUl+rSnSTV3lqc2W+HN3yNw +2F1MpQiD8aYkOBOo7C+ooWfHpi2GR+6K/OybDnT0K0kCe5B1jPyZOQE51kqJ5Z52qz6WKDgmi92N +jMD2AR5vpTESOH2VwnHu7XSu5DaiQ3XV8QCb4uTXzEIDS3h65X27uK4uIJPT5GHfceF2Z5c/tt9q +c1pkIuVC28+BA5PY9OMQ4HL2AHCs8MF6DwV/zzRpRbWT5BnbUhYjBYkOjUjkJW+zeL9i9Qf6lSTC +lrLooyPCXQP8w9PlfMl1I9f09bze5N/NgL+RiH2nE7Q5uiy6vdFrzPOlKO1Enn1So2+WLhl+HPNb +xxaOu2B9d2ZHVIIAEWBsMsGoOBvrbpgT1u449fCfDu/+MYHB0iSVL1N6aaLwD4ZFjliCK0wi1F6g +530mJ0jfJUaNSih8hp75mxpZuWW/Bd22Ql095gBIgl4g9xGC3srYn+Y3RyYe63j3YcNBZFgCQfna +4NH4+ej9Uji29YnfAgMBAAGjWzBZMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G +A1UdDgQWBBQNjLZh2kS40RR9w759XkjwzspqsDAXBgNVHSAEEDAOMAwGCiqBegFWAgIAAQEwDQYJ +KoZIhvcNAQEFBQADggIBACQ+YAZ+He86PtvqrxyaLAEL9MW12Ukx9F1BjYkMTv9sov3/4gbIOZ/x +WqndIlgVqIrTseYyCYIDbNc/CMf4uboAbbnW/FIyXaR/pDGUu7ZMOH8oMDX/nyNTt7buFHAAQCva +R6s0fl6nVjBhK4tDrP22iCj1a7Y+YEq6QpA0Z43q619FVDsXrIvkxmUP7tCMXWY5zjKn2BCXwH40 +nJ+U8/aGH88bc62UeYdocMMzpXDn2NU4lG9jeeu/Cg4I58UvD0KgKxRA/yHgBcUn4YQRE7rWhh1B +CxMjidPJC+iKunqjo3M3NYB9Ergzd0A4wPpeMNLytqOx1qKVl4GbUu1pTP+A5FPbVFsDbVRfsbjv +JL1vnxHDx2TCDyhihWZeGnuyt++uNckZM6i4J9szVb9o4XVIRFb7zdNIu0eJOqxp9YDG5ERQL1TE +qkPFMTFYvZbF6nVsmnWxTfj3l/+WFvKXTej28xH5On2KOG4Ey+HTRRWqpdEdnV1j6CTmNhTih60b +WfVEm/vXd3wfAXBioSAaosUaKPQhA+4u2cGA6rnZgtZbdsLLO7XSAPCjDuGtbkD326C00EauFddE +wk01+dIL8hf2rGbVJLJP0RyZwG71fet0BLj5TXcJ17TPBzAJ8bgAVtkXFhYKK4bfjwEZGuW7gmP/ +vgt2Fl43N+bYdJeimUV5 +-----END CERTIFICATE----- + +Root CA Generalitat Valenciana +============================== +-----BEGIN CERTIFICATE----- +MIIGizCCBXOgAwIBAgIEO0XlaDANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJFUzEfMB0GA1UE +ChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UECxMGUEtJR1ZBMScwJQYDVQQDEx5Sb290 +IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmEwHhcNMDEwNzA2MTYyMjQ3WhcNMjEwNzAxMTUyMjQ3 +WjBoMQswCQYDVQQGEwJFUzEfMB0GA1UEChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UE +CxMGUEtJR1ZBMScwJQYDVQQDEx5Sb290IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmEwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGKqtXETcvIorKA3Qdyu0togu8M1JAJke+WmmmO3I2 +F0zo37i7L3bhQEZ0ZQKQUgi0/6iMweDHiVYQOTPvaLRfX9ptI6GJXiKjSgbwJ/BXufjpTjJ3Cj9B +ZPPrZe52/lSqfR0grvPXdMIKX/UIKFIIzFVd0g/bmoGlu6GzwZTNVOAydTGRGmKy3nXiz0+J2ZGQ +D0EbtFpKd71ng+CT516nDOeB0/RSrFOyA8dEJvt55cs0YFAQexvba9dHq198aMpunUEDEO5rmXte +JajCq+TA81yc477OMUxkHl6AovWDfgzWyoxVjr7gvkkHD6MkQXpYHYTqWBLI4bft75PelAgxAgMB +AAGjggM7MIIDNzAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLnBraS5n +dmEuZXMwEgYDVR0TAQH/BAgwBgEB/wIBAjCCAjQGA1UdIASCAiswggInMIICIwYKKwYBBAG/VQIB +ADCCAhMwggHoBggrBgEFBQcCAjCCAdoeggHWAEEAdQB0AG8AcgBpAGQAYQBkACAAZABlACAAQwBl +AHIAdABpAGYAaQBjAGEAYwBpAPMAbgAgAFIAYQDtAHoAIABkAGUAIABsAGEAIABHAGUAbgBlAHIA +YQBsAGkAdABhAHQAIABWAGEAbABlAG4AYwBpAGEAbgBhAC4ADQAKAEwAYQAgAEQAZQBjAGwAYQBy +AGEAYwBpAPMAbgAgAGQAZQAgAFAAcgDhAGMAdABpAGMAYQBzACAAZABlACAAQwBlAHIAdABpAGYA +aQBjAGEAYwBpAPMAbgAgAHEAdQBlACAAcgBpAGcAZQAgAGUAbAAgAGYAdQBuAGMAaQBvAG4AYQBt +AGkAZQBuAHQAbwAgAGQAZQAgAGwAYQAgAHAAcgBlAHMAZQBuAHQAZQAgAEEAdQB0AG8AcgBpAGQA +YQBkACAAZABlACAAQwBlAHIAdABpAGYAaQBjAGEAYwBpAPMAbgAgAHMAZQAgAGUAbgBjAHUAZQBu +AHQAcgBhACAAZQBuACAAbABhACAAZABpAHIAZQBjAGMAaQDzAG4AIAB3AGUAYgAgAGgAdAB0AHAA +OgAvAC8AdwB3AHcALgBwAGsAaQAuAGcAdgBhAC4AZQBzAC8AYwBwAHMwJQYIKwYBBQUHAgEWGWh0 +dHA6Ly93d3cucGtpLmd2YS5lcy9jcHMwHQYDVR0OBBYEFHs100DSHHgZZu90ECjcPk+yeAT8MIGV +BgNVHSMEgY0wgYqAFHs100DSHHgZZu90ECjcPk+yeAT8oWykajBoMQswCQYDVQQGEwJFUzEfMB0G +A1UEChMWR2VuZXJhbGl0YXQgVmFsZW5jaWFuYTEPMA0GA1UECxMGUEtJR1ZBMScwJQYDVQQDEx5S +b290IENBIEdlbmVyYWxpdGF0IFZhbGVuY2lhbmGCBDtF5WgwDQYJKoZIhvcNAQEFBQADggEBACRh +TvW1yEICKrNcda3FbcrnlD+laJWIwVTAEGmiEi8YPyVQqHxK6sYJ2fR1xkDar1CdPaUWu20xxsdz +Ckj+IHLtb8zog2EWRpABlUt9jppSCS/2bxzkoXHPjCpaF3ODR00PNvsETUlR4hTJZGH71BTg9J63 +NI8KJr2XXPR5OkowGcytT6CYirQxlyric21+eLj4iIlPsSKRZEv1UN4D2+XFducTZnV+ZfsBn5OH +iJ35Rld8TWCvmHMTI6QgkYH60GFmuH3Rr9ZvHmw96RH9qfmCIoaZM3Fa6hlXPZHNqcCjbgcTpsnt ++GijnsNacgmHKNHEc8RzGF9QdRYxn7fofMM= +-----END CERTIFICATE----- + +A-Trust-nQual-03 +================ +-----BEGIN CERTIFICATE----- +MIIDzzCCAregAwIBAgIDAWweMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJBVDFIMEYGA1UE +Cgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERhdGVudmVy +a2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5RdWFsLTAzMRkwFwYDVQQDDBBBLVRydXN0LW5R +dWFsLTAzMB4XDTA1MDgxNzIyMDAwMFoXDTE1MDgxNzIyMDAwMFowgY0xCzAJBgNVBAYTAkFUMUgw +RgYDVQQKDD9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGltIGVsZWt0ci4gRGF0 +ZW52ZXJrZWhyIEdtYkgxGTAXBgNVBAsMEEEtVHJ1c3QtblF1YWwtMDMxGTAXBgNVBAMMEEEtVHJ1 +c3QtblF1YWwtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtPWFuA/OQO8BBC4SA +zewqo51ru27CQoT3URThoKgtUaNR8t4j8DRE/5TrzAUjlUC5B3ilJfYKvUWG6Nm9wASOhURh73+n +yfrBJcyFLGM/BWBzSQXgYHiVEEvc+RFZznF/QJuKqiTfC0Li21a8StKlDJu3Qz7dg9MmEALP6iPE +SU7l0+m0iKsMrmKS1GWH2WrX9IWf5DMiJaXlyDO6w8dB3F/GaswADm0yqLaHNgBid5seHzTLkDx4 +iHQF63n1k3Flyp3HaxgtPVxO59X4PzF9j4fsCiIvI+n+u33J4PTs63zEsMMtYrWacdaxaujs2e3V +cuy+VwHOBVWf3tFgiBCzAgMBAAGjNjA0MA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECERqlWdV +eRFPMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAVdRU0VlIXLOThaq/Yy/kgM40 +ozRiPvbY7meIMQQDbwvUB/tOdQ/TLtPAF8fGKOwGDREkDg6lXb+MshOWcdzUzg4NCmgybLlBMRmr +sQd7TZjTXLDR8KdCoLXEjq/+8T/0709GAHbrAvv5ndJAlseIOrifEXnzgGWovR/TeIGgUUw3tKZd +JXDRZslo+S4RFGjxVJgIrCaSD96JntT6s3kr0qN51OyLrIdTaEJMUVF0HhsnLuP1Hyl0Te2v9+GS +mYHovjrHF1D2t8b8m7CKa9aIA5GPBnc6hQLdmNVDeD/GMBWsm2vLV7eJUYs66MmEDNuxUCAKGkq6 +ahq97BvIxYSazQ== +-----END CERTIFICATE----- + +TWCA Root Certification Authority +================================= +-----BEGIN CERTIFICATE----- +MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ +VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG +EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB +IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx +QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC +oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP +4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r +y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB +BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG +9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC +mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW +QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY +T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny +Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw== +-----END CERTIFICATE----- + +Security Communication RootCA2 +============================== +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc +U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh +dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC +SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy +aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++ ++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R +3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV +spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K +EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8 +QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB +CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj +u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk +3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q +tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29 +mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 +-----END CERTIFICATE----- + +EC-ACC +====== +-----BEGIN CERTIFICATE----- +MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE +BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w +ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD +VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE +CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT +BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7 +MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt +SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl +Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh +cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK +w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT +ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4 +HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a +E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw +0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD +VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0 +Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l +dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ +lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa +Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe +l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2 +E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D +5EI= +-----END CERTIFICATE----- + +Hellenic Academic and Research Institutions RootCA 2011 +======================================================= +-----BEGIN CERTIFICATE----- +MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT +O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y +aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z +IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT +AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z +IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo +IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI +1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa +71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u +8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH +3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/ +MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8 +MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu +b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt +XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8 +TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD +/md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N +7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4 +-----END CERTIFICATE----- + +Actalis Authentication Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM +BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE +AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky +MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz +IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290 +IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ +wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa +by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6 +zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f +YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2 +oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l +EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7 +hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8 +EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5 +jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY +iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt +ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI +WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0 +JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx +K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+ +Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC +4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo +2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz +lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem +OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9 +vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== +-----END CERTIFICATE----- + +Trustis FPS Root CA +=================== +-----BEGIN CERTIFICATE----- +MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG +EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290 +IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV +BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ +RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk +H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa +cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt +o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA +AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd +BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c +GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC +yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P +8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV +l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl +iB6XzCGcKQENZetX2fNXlrtIzYE= +-----END CERTIFICATE----- + +StartCom Certification Authority +================================ +-----BEGIN CERTIFICATE----- +MIIHhzCCBW+gAwIBAgIBLTANBgkqhkiG9w0BAQsFADB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMN +U3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmlu +ZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDYwOTE3MTk0 +NjM3WhcNMzYwOTE3MTk0NjM2WjB9MQswCQYDVQQGEwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRk +LjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMg +U3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw +ggIKAoICAQDBiNsJvGxGfHiflXu1M5DycmLWwTYgIiRezul38kMKogZkpMyONvg45iPwbm2xPN1y +o4UcodM9tDMr0y+v/uqwQVlntsQGfQqedIXWeUyAN3rfOQVSWff0G0ZDpNKFhdLDcfN1YjS6LIp/ +Ho/u7TTQEceWzVI9ujPW3U3eCztKS5/CJi/6tRYccjV3yjxd5srhJosaNnZcAdt0FCX+7bWgiA/d +eMotHweXMAEtcnn6RtYTKqi5pquDSR3l8u/d5AGOGAqPY1MWhWKpDhk6zLVmpsJrdAfkK+F2PrRt +2PZE4XNiHzvEvqBTViVsUQn3qqvKv3b9bZvzndu/PWa8DFaqr5hIlTpL36dYUNk4dalb6kMMAv+Z +6+hsTXBbKWWc3apdzK8BMewM69KN6Oqce+Zu9ydmDBpI125C4z/eIT574Q1w+2OqqGwaVLRcJXrJ +osmLFqa7LH4XXgVNWG4SHQHuEhANxjJ/GP/89PrNbpHoNkm+Gkhpi8KWTRoSsmkXwQqQ1vp5Iki/ +untp+HDH+no32NgN0nZPV/+Qt+OR0t3vwmC3Zzrd/qqc8NSLf3Iizsafl7b4r4qgEKjZ+xjGtrVc +UjyJthkqcwEKDwOzEmDyei+B26Nu/yYwl/WL3YlXtq09s68rxbd2AvCl1iuahhQqcvbjM4xdCUsT +37uMdBNSSwIDAQABo4ICEDCCAgwwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYD +VR0OBBYEFE4L7xqkQFulF2mHMMo0aEPQQa7yMB8GA1UdIwQYMBaAFE4L7xqkQFulF2mHMMo0aEPQ +Qa7yMIIBWgYDVR0gBIIBUTCCAU0wggFJBgsrBgEEAYG1NwEBATCCATgwLgYIKwYBBQUHAgEWImh0 +dHA6Ly93d3cuc3RhcnRzc2wuY29tL3BvbGljeS5wZGYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cu +c3RhcnRzc2wuY29tL2ludGVybWVkaWF0ZS5wZGYwgc8GCCsGAQUFBwICMIHCMCcWIFN0YXJ0IENv +bW1lcmNpYWwgKFN0YXJ0Q29tKSBMdGQuMAMCAQEagZZMaW1pdGVkIExpYWJpbGl0eSwgcmVhZCB0 +aGUgc2VjdGlvbiAqTGVnYWwgTGltaXRhdGlvbnMqIG9mIHRoZSBTdGFydENvbSBDZXJ0aWZpY2F0 +aW9uIEF1dGhvcml0eSBQb2xpY3kgYXZhaWxhYmxlIGF0IGh0dHA6Ly93d3cuc3RhcnRzc2wuY29t +L3BvbGljeS5wZGYwEQYJYIZIAYb4QgEBBAQDAgAHMDgGCWCGSAGG+EIBDQQrFilTdGFydENvbSBG +cmVlIFNTTCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTANBgkqhkiG9w0BAQsFAAOCAgEAjo/n3JR5 +fPGFf59Jb2vKXfuM/gTFwWLRfUKKvFO3lANmMD+x5wqnUCBVJX92ehQN6wQOQOY+2IirByeDqXWm +N3PH/UvSTa0XQMhGvjt/UfzDtgUx3M2FIk5xt/JxXrAaxrqTi3iSSoX4eA+D/i+tLPfkpLst0OcN +Org+zvZ49q5HJMqjNTbOx8aHmNrs++myziebiMMEofYLWWivydsQD032ZGNcpRJvkrKTlMeIFw6T +tn5ii5B/q06f/ON1FE8qMt9bDeD1e5MNq6HPh+GlBEXoPBKlCcWw0bdT82AUuoVpaiF8H3VhFyAX +e2w7QSlc4axa0c2Mm+tgHRns9+Ww2vl5GKVFP0lDV9LdJNUso/2RjSe15esUBppMeyG7Oq0wBhjA +2MFrLH9ZXF2RsXAiV+uKa0hK1Q8p7MZAwC+ITGgBF3f0JBlPvfrhsiAhS90a2Cl9qrjeVOwhVYBs +HvUwyKMQ5bLmKhQxw4UtjJixhlpPiVktucf3HMiKf8CdBUrmQk9io20ppB+Fq9vlgcitKj1MXVuE +JnHEhV5xJMqlG2zYYdMa4FTbzrqpMrUi9nNBCV24F10OD5mQ1kfabwo6YigUZ4LZ8dCAWZvLMdib +D4x3TrVoivJs9iQOLWxwxXPR3hTQcY+203sC9uO41Alua551hDnmfyWl8kgAwKQB2j8= +-----END CERTIFICATE----- + +StartCom Certification Authority G2 +=================================== +-----BEGIN CERTIFICATE----- +MIIFYzCCA0ugAwIBAgIBOzANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJJTDEWMBQGA1UEChMN +U3RhcnRDb20gTHRkLjEsMCoGA1UEAxMjU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +RzIwHhcNMTAwMTAxMDEwMDAxWhcNMzkxMjMxMjM1OTAxWjBTMQswCQYDVQQGEwJJTDEWMBQGA1UE +ChMNU3RhcnRDb20gTHRkLjEsMCoGA1UEAxMjU3RhcnRDb20gQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgRzIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2iTZbB7cgNr2Cu+EWIAOVeq8O +o1XJJZlKxdBWQYeQTSFgpBSHO839sj60ZwNq7eEPS8CRhXBF4EKe3ikj1AENoBB5uNsDvfOpL9HG +4A/LnooUCri99lZi8cVytjIl2bLzvWXFDSxu1ZJvGIsAQRSCb0AgJnooD/Uefyf3lLE3PbfHkffi +Aez9lInhzG7TNtYKGXmu1zSCZf98Qru23QumNK9LYP5/Q0kGi4xDuFby2X8hQxfqp0iVAXV16iul +Q5XqFYSdCI0mblWbq9zSOdIxHWDirMxWRST1HFSr7obdljKF+ExP6JV2tgXdNiNnvP8V4so75qbs +O+wmETRIjfaAKxojAuuKHDp2KntWFhxyKrOq42ClAJ8Em+JvHhRYW6Vsi1g8w7pOOlz34ZYrPu8H +vKTlXcxNnw3h3Kq74W4a7I/htkxNeXJdFzULHdfBR9qWJODQcqhaX2YtENwvKhOuJv4KHBnM0D4L +nMgJLvlblnpHnOl68wVQdJVznjAJ85eCXuaPOQgeWeU1FEIT/wCc976qUM/iUUjXuG+v+E5+M5iS +FGI6dWPPe/regjupuznixL0sAA7IF6wT700ljtizkC+p2il9Ha90OrInwMEePnWjFqmveiJdnxMa +z6eg6+OGCtP95paV1yPIN93EfKo2rJgaErHgTuixO/XWb/Ew1wIDAQABo0IwQDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUS8W0QGutHLOlHGVuRjaJhwUMDrYwDQYJ +KoZIhvcNAQELBQADggIBAHNXPyzVlTJ+N9uWkusZXn5T50HsEbZH77Xe7XRcxfGOSeD8bpkTzZ+K +2s06Ctg6Wgk/XzTQLwPSZh0avZyQN8gMjgdalEVGKua+etqhqaRpEpKwfTbURIfXUfEpY9Z1zRbk +J4kd+MIySP3bmdCPX1R0zKxnNBFi2QwKN4fRoxdIjtIXHfbX/dtl6/2o1PXWT6RbdejF0mCy2wl+ +JYt7ulKSnj7oxXehPOBKc2thz4bcQ///If4jXSRK9dNtD2IEBVeC2m6kMyV5Sy5UGYvMLD0w6dEG +/+gyRr61M3Z3qAFdlsHB1b6uJcDJHgoJIIihDsnzb02CVAAgp9KP5DlUFy6NHrgbuxu9mk47EDTc +nIhT76IxW1hPkWLIwpqazRVdOKnWvvgTtZ8SafJQYqz7Fzf07rh1Z2AQ+4NQ+US1dZxAF7L+/Xld +blhYXzD8AK6vM8EOTmy6p6ahfzLbOOCxchcKK5HsamMm7YnUeMx0HgX4a/6ManY5Ka5lIxKVCCIc +l85bBu4M4ru8H0ST9tg4RQUh7eStqxK2A6RCLi3ECToDZ2mEmuFZkIoohdVddLHRDiBYmxOlsGOm +7XtH/UVVMKTumtTm4ofvmMkyghEpIrwACjFeLQ/Ajulrso8uBtjRkcfGEvRM/TAXw8HaOFvjqerm +obp573PYtlNXLfbQ4ddI +-----END CERTIFICATE----- + +Buypass Class 2 Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X +DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 +eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1 +g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn +9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b +/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU +CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff +awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI +zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn +Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX +Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs +M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD +VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF +AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s +A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI +osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S +aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd +DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD +LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0 +oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC +wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS +CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN +rJgWVqA= +-----END CERTIFICATE----- + +Buypass Class 3 Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X +DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 +eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH +sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR +5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh +7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ +ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH +2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV +/afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ +RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA +Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq +j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD +VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF +AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV +cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G +uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG +Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8 +ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2 +KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz +6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug +UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe +eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi +Cp/HuZc= +-----END CERTIFICATE----- + +T-TeleSec GlobalRoot Class 3 +============================ +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM +IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU +cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx +MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz +dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD +ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK +9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU +NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF +iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W +0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA +MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr +AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb +fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT +ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h +P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml +e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw== +-----END CERTIFICATE----- + +TURKTRUST Certificate Services Provider Root 2007 +================================================= +-----BEGIN CERTIFICATE----- +MIIEPTCCAyWgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvzE/MD0GA1UEAww2VMOcUktUUlVTVCBF +bGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQGEwJUUjEP +MA0GA1UEBwwGQW5rYXJhMV4wXAYDVQQKDFVUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUg +QmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgQXJhbMSxayAyMDA3MB4X +DTA3MTIyNTE4MzcxOVoXDTE3MTIyMjE4MzcxOVowgb8xPzA9BgNVBAMMNlTDnFJLVFJVU1QgRWxl +a3Ryb25payBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsTELMAkGA1UEBhMCVFIxDzAN +BgNVBAcMBkFua2FyYTFeMFwGA1UECgxVVMOcUktUUlVTVCBCaWxnaSDEsGxldGnFn2ltIHZlIEJp +bGnFn2ltIEfDvHZlbmxpxJ9pIEhpem1ldGxlcmkgQS7Fni4gKGMpIEFyYWzEsWsgMjAwNzCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKu3PgqMyKVYFeaK7yc9SrToJdPNM8Ig3BnuiD9N +YvDdE3ePYakqtdTyuTFYKTsvP2qcb3N2Je40IIDu6rfwxArNK4aUyeNgsURSsloptJGXg9i3phQv +KUmi8wUG+7RP2qFsmmaf8EMJyupyj+sA1zU511YXRxcw9L6/P8JorzZAwan0qafoEGsIiveGHtya +KhUG9qPw9ODHFNRRf8+0222vR5YXm3dx2KdxnSQM9pQ/hTEST7ruToK4uT6PIzdezKKqdfcYbwnT +rqdUKDT74eA7YH2gvnmJhsifLfkKS8RQouf9eRbHegsYz85M733WB2+Y8a+xwXrXgTW4qhe04MsC +AwEAAaNCMEAwHQYDVR0OBBYEFCnFkKslrxHkYb+j/4hhkeYO/pyBMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAQDdr4Ouwo0RSVgrESLFF6QSU2TJ/s +Px+EnWVUXKgWAkD6bho3hO9ynYYKVZ1WKKxmLNA6VpM0ByWtCLCPyA8JWcqdmBzlVPi5RX9ql2+I +aE1KBiY3iAIOtsbWcpnOa3faYjGkVh+uX4132l32iPwa2Z61gfAyuOOI0JzzaqC5mxRZNTZPz/OO +Xl0XrRWV2N2y1RVuAE6zS89mlOTgzbUF2mNXi+WzqtvALhyQRNsaXRik7r4EW5nVcV9VZWRi1aKb +BFmGyGJ353yCRWo9F7/snXUMrqNvWtMvmDb08PUZqxFdyKbjKlhqQgnDvZImZjINXQhVdP+MmNAK +poRq0Tl9 +-----END CERTIFICATE----- + +D-TRUST Root Class 3 CA 2 2009 +============================== +-----BEGIN CERTIFICATE----- +MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe +Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE +LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD +ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA +BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv +KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z +p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC +AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ +4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y +eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw +MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G +PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw +OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm +2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0 +o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV +dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph +X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I= +-----END CERTIFICATE----- + +D-TRUST Root Class 3 CA 2 EV 2009 +================================= +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw +OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw +OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS +egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh +zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T +7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60 +sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35 +11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv +cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v +ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El +MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp +b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh +c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+ +PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05 +nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX +ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA +NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv +w9y4AyHqnxbxLFS1 +-----END CERTIFICATE----- + +PSCProcert +========== +-----BEGIN CERTIFICATE----- +MIIJhjCCB26gAwIBAgIBCzANBgkqhkiG9w0BAQsFADCCAR4xPjA8BgNVBAMTNUF1dG9yaWRhZCBk +ZSBDZXJ0aWZpY2FjaW9uIFJhaXogZGVsIEVzdGFkbyBWZW5lem9sYW5vMQswCQYDVQQGEwJWRTEQ +MA4GA1UEBxMHQ2FyYWNhczEZMBcGA1UECBMQRGlzdHJpdG8gQ2FwaXRhbDE2MDQGA1UEChMtU2lz +dGVtYSBOYWNpb25hbCBkZSBDZXJ0aWZpY2FjaW9uIEVsZWN0cm9uaWNhMUMwQQYDVQQLEzpTdXBl +cmludGVuZGVuY2lhIGRlIFNlcnZpY2lvcyBkZSBDZXJ0aWZpY2FjaW9uIEVsZWN0cm9uaWNhMSUw +IwYJKoZIhvcNAQkBFhZhY3JhaXpAc3VzY2VydGUuZ29iLnZlMB4XDTEwMTIyODE2NTEwMFoXDTIw +MTIyNTIzNTk1OVowgdExJjAkBgkqhkiG9w0BCQEWF2NvbnRhY3RvQHByb2NlcnQubmV0LnZlMQ8w +DQYDVQQHEwZDaGFjYW8xEDAOBgNVBAgTB01pcmFuZGExKjAoBgNVBAsTIVByb3ZlZWRvciBkZSBD +ZXJ0aWZpY2Fkb3MgUFJPQ0VSVDE2MDQGA1UEChMtU2lzdGVtYSBOYWNpb25hbCBkZSBDZXJ0aWZp +Y2FjaW9uIEVsZWN0cm9uaWNhMQswCQYDVQQGEwJWRTETMBEGA1UEAxMKUFNDUHJvY2VydDCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANW39KOUM6FGqVVhSQ2oh3NekS1wwQYalNo97BVC +wfWMrmoX8Yqt/ICV6oNEolt6Vc5Pp6XVurgfoCfAUFM+jbnADrgV3NZs+J74BCXfgI8Qhd19L3uA +3VcAZCP4bsm+lU/hdezgfl6VzbHvvnpC2Mks0+saGiKLt38GieU89RLAu9MLmV+QfI4tL3czkkoh +RqipCKzx9hEC2ZUWno0vluYC3XXCFCpa1sl9JcLB/KpnheLsvtF8PPqv1W7/U0HU9TI4seJfxPmO +EO8GqQKJ/+MMbpfg353bIdD0PghpbNjU5Db4g7ayNo+c7zo3Fn2/omnXO1ty0K+qP1xmk6wKImG2 +0qCZyFSTXai20b1dCl53lKItwIKOvMoDKjSuc/HUtQy9vmebVOvh+qBa7Dh+PsHMosdEMXXqP+UH +0quhJZb25uSgXTcYOWEAM11G1ADEtMo88aKjPvM6/2kwLkDd9p+cJsmWN63nOaK/6mnbVSKVUyqU +td+tFjiBdWbjxywbk5yqjKPK2Ww8F22c3HxT4CAnQzb5EuE8XL1mv6JpIzi4mWCZDlZTOpx+FIyw +Bm/xhnaQr/2v/pDGj59/i5IjnOcVdo/Vi5QTcmn7K2FjiO/mpF7moxdqWEfLcU8UC17IAggmosvp +r2uKGcfLFFb14dq12fy/czja+eevbqQ34gcnAgMBAAGjggMXMIIDEzASBgNVHRMBAf8ECDAGAQH/ +AgEBMDcGA1UdEgQwMC6CD3N1c2NlcnRlLmdvYi52ZaAbBgVghl4CAqASDBBSSUYtRy0yMDAwNDAz +Ni0wMB0GA1UdDgQWBBRBDxk4qpl/Qguk1yeYVKIXTC1RVDCCAVAGA1UdIwSCAUcwggFDgBStuyId +xuDSAaj9dlBSk+2YwU2u06GCASakggEiMIIBHjE+MDwGA1UEAxM1QXV0b3JpZGFkIGRlIENlcnRp +ZmljYWNpb24gUmFpeiBkZWwgRXN0YWRvIFZlbmV6b2xhbm8xCzAJBgNVBAYTAlZFMRAwDgYDVQQH +EwdDYXJhY2FzMRkwFwYDVQQIExBEaXN0cml0byBDYXBpdGFsMTYwNAYDVQQKEy1TaXN0ZW1hIE5h +Y2lvbmFsIGRlIENlcnRpZmljYWNpb24gRWxlY3Ryb25pY2ExQzBBBgNVBAsTOlN1cGVyaW50ZW5k +ZW5jaWEgZGUgU2VydmljaW9zIGRlIENlcnRpZmljYWNpb24gRWxlY3Ryb25pY2ExJTAjBgkqhkiG +9w0BCQEWFmFjcmFpekBzdXNjZXJ0ZS5nb2IudmWCAQowDgYDVR0PAQH/BAQDAgEGME0GA1UdEQRG +MESCDnByb2NlcnQubmV0LnZloBUGBWCGXgIBoAwMClBTQy0wMDAwMDKgGwYFYIZeAgKgEgwQUklG +LUotMzE2MzUzNzMtNzB2BgNVHR8EbzBtMEagRKBChkBodHRwOi8vd3d3LnN1c2NlcnRlLmdvYi52 +ZS9sY3IvQ0VSVElGSUNBRE8tUkFJWi1TSEEzODRDUkxERVIuY3JsMCOgIaAfhh1sZGFwOi8vYWNy +YWl6LnN1c2NlcnRlLmdvYi52ZTA3BggrBgEFBQcBAQQrMCkwJwYIKwYBBQUHMAGGG2h0dHA6Ly9v +Y3NwLnN1c2NlcnRlLmdvYi52ZTBBBgNVHSAEOjA4MDYGBmCGXgMBAjAsMCoGCCsGAQUFBwIBFh5o +dHRwOi8vd3d3LnN1c2NlcnRlLmdvYi52ZS9kcGMwDQYJKoZIhvcNAQELBQADggIBACtZ6yKZu4Sq +T96QxtGGcSOeSwORR3C7wJJg7ODU523G0+1ng3dS1fLld6c2suNUvtm7CpsR72H0xpkzmfWvADmN +g7+mvTV+LFwxNG9s2/NkAZiqlCxB3RWGymspThbASfzXg0gTB1GEMVKIu4YXx2sviiCtxQuPcD4q +uxtxj7mkoP3YldmvWb8lK5jpY5MvYB7Eqvh39YtsL+1+LrVPQA3uvFd359m21D+VJzog1eWuq2w1 +n8GhHVnchIHuTQfiSLaeS5UtQbHh6N5+LwUeaO6/u5BlOsju6rEYNxxik6SgMexxbJHmpHmJWhSn +FFAFTKQAVzAswbVhltw+HoSvOULP5dAssSS830DD7X9jSr3hTxJkhpXzsOfIt+FTvZLm8wyWuevo +5pLtp4EJFAv8lXrPj9Y0TzYS3F7RNHXGRoAvlQSMx4bEqCaJqD8Zm4G7UaRKhqsLEQ+xrmNTbSjq +3TNWOByyrYDT13K9mmyZY+gAu0F2BbdbmRiKw7gSXFbPVgx96OLP7bx0R/vu0xdOIk9W/1DzLuY5 +poLWccret9W6aAjtmcz9opLLabid+Qqkpj5PkygqYWwHJgD/ll9ohri4zspV4KuxPX+Y1zMOWj3Y +eMLEYC/HYvBhkdI4sPaeVdtAgAUSM84dkpvRabP/v/GSCmE1P93+hvS84Bpxs2Km +-----END CERTIFICATE----- + +China Internet Network Information Center EV Certificates Root +============================================================== +-----BEGIN CERTIFICATE----- +MIID9zCCAt+gAwIBAgIESJ8AATANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCQ04xMjAwBgNV +BAoMKUNoaW5hIEludGVybmV0IE5ldHdvcmsgSW5mb3JtYXRpb24gQ2VudGVyMUcwRQYDVQQDDD5D +aGluYSBJbnRlcm5ldCBOZXR3b3JrIEluZm9ybWF0aW9uIENlbnRlciBFViBDZXJ0aWZpY2F0ZXMg +Um9vdDAeFw0xMDA4MzEwNzExMjVaFw0zMDA4MzEwNzExMjVaMIGKMQswCQYDVQQGEwJDTjEyMDAG +A1UECgwpQ2hpbmEgSW50ZXJuZXQgTmV0d29yayBJbmZvcm1hdGlvbiBDZW50ZXIxRzBFBgNVBAMM +PkNoaW5hIEludGVybmV0IE5ldHdvcmsgSW5mb3JtYXRpb24gQ2VudGVyIEVWIENlcnRpZmljYXRl +cyBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm35z7r07eKpkQ0H1UN+U8i6y +jUqORlTSIRLIOTJCBumD1Z9S7eVnAztUwYyZmczpwA//DdmEEbK40ctb3B75aDFk4Zv6dOtouSCV +98YPjUesWgbdYavi7NifFy2cyjw1l1VxzUOFsUcW9SxTgHbP0wBkvUCZ3czY28Sf1hNfQYOL+Q2H +klY0bBoQCxfVWhyXWIQ8hBouXJE0bhlffxdpxWXvayHG1VA6v2G5BY3vbzQ6sm8UY78WO5upKv23 +KzhmBsUs4qpnHkWnjQRmQvaPK++IIGmPMowUc9orhpFjIpryp9vOiYurXccUwVswah+xt54ugQEC +7c+WXmPbqOY4twIDAQABo2MwYTAfBgNVHSMEGDAWgBR8cks5x8DbYqVPm6oYNJKiyoOCWTAPBgNV +HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUfHJLOcfA22KlT5uqGDSSosqD +glkwDQYJKoZIhvcNAQEFBQADggEBACrDx0M3j92tpLIM7twUbY8opJhJywyA6vPtI2Z1fcXTIWd5 +0XPFtQO3WKwMVC/GVhMPMdoG52U7HW8228gd+f2ABsqjPWYWqJ1MFn3AlUa1UeTiH9fqBk1jjZaM +7+czV0I664zBechNdn3e9rG3geCg+aF4RhcaVpjwTj2rHO3sOdwHSPdj/gauwqRcalsyiMXHM4Ws +ZkJHwlgkmeHlPuV1LI5D1l08eB6olYIpUNHRFrrvwb562bTYzB5MRuF3sTGrvSrIzo9uoV1/A3U0 +5K2JRVRevq4opbs/eHnrc7MKDf2+yfdWrPa37S+bISnHOLaVxATywy39FCqQmbkHzJ8= +-----END CERTIFICATE----- + +Swisscom Root CA 2 +================== +-----BEGIN CERTIFICATE----- +MIIF2TCCA8GgAwIBAgIQHp4o6Ejy5e/DfEoeWhhntjANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQG +EwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsTHERpZ2l0YWwgQ2VydGlmaWNhdGUgU2Vy +dmljZXMxGzAZBgNVBAMTElN3aXNzY29tIFJvb3QgQ0EgMjAeFw0xMTA2MjQwODM4MTRaFw0zMTA2 +MjUwNzM4MTRaMGQxCzAJBgNVBAYTAmNoMREwDwYDVQQKEwhTd2lzc2NvbTElMCMGA1UECxMcRGln +aXRhbCBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczEbMBkGA1UEAxMSU3dpc3Njb20gUm9vdCBDQSAyMIIC +IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlUJOhJ1R5tMJ6HJaI2nbeHCOFvErjw0DzpPM +LgAIe6szjPTpQOYXTKueuEcUMncy3SgM3hhLX3af+Dk7/E6J2HzFZ++r0rk0X2s682Q2zsKwzxNo +ysjL67XiPS4h3+os1OD5cJZM/2pYmLcX5BtS5X4HAB1f2uY+lQS3aYg5oUFgJWFLlTloYhyxCwWJ +wDaCFCE/rtuh/bxvHGCGtlOUSbkrRsVPACu/obvLP+DHVxxX6NZp+MEkUp2IVd3Chy50I9AU/SpH +Wrumnf2U5NGKpV+GY3aFy6//SSj8gO1MedK75MDvAe5QQQg1I3ArqRa0jG6F6bYRzzHdUyYb3y1a +SgJA/MTAtukxGggo5WDDH8SQjhBiYEQN7Aq+VRhxLKX0srwVYv8c474d2h5Xszx+zYIdkeNL6yxS +NLCK/RJOlrDrcH+eOfdmQrGrrFLadkBXeyq96G4DsguAhYidDMfCd7Camlf0uPoTXGiTOmekl9Ab +mbeGMktg2M7v0Ax/lZ9vh0+Hio5fCHyqW/xavqGRn1V9TrALacywlKinh/LTSlDcX3KwFnUey7QY +Ypqwpzmqm59m2I2mbJYV4+by+PGDYmy7Velhk6M99bFXi08jsJvllGov34zflVEpYKELKeRcVVi3 +qPyZ7iVNTA6z00yPhOgpD/0QVAKFyPnlw4vP5w8CAwEAAaOBhjCBgzAOBgNVHQ8BAf8EBAMCAYYw +HQYDVR0hBBYwFDASBgdghXQBUwIBBgdghXQBUwIBMBIGA1UdEwEB/wQIMAYBAf8CAQcwHQYDVR0O +BBYEFE0mICKJS9PVpAqhb97iEoHF8TwuMB8GA1UdIwQYMBaAFE0mICKJS9PVpAqhb97iEoHF8Twu +MA0GCSqGSIb3DQEBCwUAA4ICAQAyCrKkG8t9voJXiblqf/P0wS4RfbgZPnm3qKhyN2abGu2sEzsO +v2LwnN+ee6FTSA5BesogpxcbtnjsQJHzQq0Qw1zv/2BZf82Fo4s9SBwlAjxnffUy6S8w5X2lejjQ +82YqZh6NM4OKb3xuqFp1mrjX2lhIREeoTPpMSQpKwhI3qEAMw8jh0FcNlzKVxzqfl9NX+Ave5XLz +o9v/tdhZsnPdTSpxsrpJ9csc1fV5yJmz/MFMdOO0vSk3FQQoHt5FRnDsr7p4DooqzgB53MBfGWcs +a0vvaGgLQ+OswWIJ76bdZWGgr4RVSJFSHMYlkSrQwSIjYVmvRRGFHQEkNI/Ps/8XciATwoCqISxx +OQ7Qj1zB09GOInJGTB2Wrk9xseEFKZZZ9LuedT3PDTcNYtsmjGOpI99nBjx8Oto0QuFmtEYE3saW +mA9LSHokMnWRn6z3aOkquVVlzl1h0ydw2Df+n7mvoC5Wt6NlUe07qxS/TFED6F+KBZvuim6c779o ++sjaC+NCydAXFJy3SuCvkychVSa1ZC+N8f+mQAWFBVzKBxlcCxMoTFh/wqXvRdpg065lYZ1Tg3TC +rvJcwhbtkj6EPnNgiLx29CzP0H1907he0ZESEOnN3col49XtmS++dYFLJPlFRpTJKSFTnCZFqhMX +5OfNeOI5wSsSnqaeG8XmDtkx2Q== +-----END CERTIFICATE----- + +Swisscom Root EV CA 2 +===================== +-----BEGIN CERTIFICATE----- +MIIF4DCCA8igAwIBAgIRAPL6ZOJ0Y9ON/RAdBB92ylgwDQYJKoZIhvcNAQELBQAwZzELMAkGA1UE +BhMCY2gxETAPBgNVBAoTCFN3aXNzY29tMSUwIwYDVQQLExxEaWdpdGFsIENlcnRpZmljYXRlIFNl +cnZpY2VzMR4wHAYDVQQDExVTd2lzc2NvbSBSb290IEVWIENBIDIwHhcNMTEwNjI0MDk0NTA4WhcN +MzEwNjI1MDg0NTA4WjBnMQswCQYDVQQGEwJjaDERMA8GA1UEChMIU3dpc3Njb20xJTAjBgNVBAsT +HERpZ2l0YWwgQ2VydGlmaWNhdGUgU2VydmljZXMxHjAcBgNVBAMTFVN3aXNzY29tIFJvb3QgRVYg +Q0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMT3HS9X6lds93BdY7BxUglgRCgz +o3pOCvrY6myLURYaVa5UJsTMRQdBTxB5f3HSek4/OE6zAMaVylvNwSqD1ycfMQ4jFrclyxy0uYAy +Xhqdk/HoPGAsp15XGVhRXrwsVgu42O+LgrQ8uMIkqBPHoCE2G3pXKSinLr9xJZDzRINpUKTk4Rti +GZQJo/PDvO/0vezbE53PnUgJUmfANykRHvvSEaeFGHR55E+FFOtSN+KxRdjMDUN/rhPSays/p8Li +qG12W0OfvrSdsyaGOx9/5fLoZigWJdBLlzin5M8J0TbDC77aO0RYjb7xnglrPvMyxyuHxuxenPaH +Za0zKcQvidm5y8kDnftslFGXEBuGCxobP/YCfnvUxVFkKJ3106yDgYjTdLRZncHrYTNaRdHLOdAG +alNgHa/2+2m8atwBz735j9m9W8E6X47aD0upm50qKGsaCnw8qyIL5XctcfaCNYGu+HuB5ur+rPQa +m3Rc6I8k9l2dRsQs0h4rIWqDJ2dVSqTjyDKXZpBy2uPUZC5f46Fq9mDU5zXNysRojddxyNMkM3Ox +bPlq4SjbX8Y96L5V5jcb7STZDxmPX2MYWFCBUWVv8p9+agTnNCRxunZLWB4ZvRVgRaoMEkABnRDi +xzgHcgplwLa7JSnaFp6LNYth7eVxV4O1PHGf40+/fh6Bn0GXAgMBAAGjgYYwgYMwDgYDVR0PAQH/ +BAQDAgGGMB0GA1UdIQQWMBQwEgYHYIV0AVMCAgYHYIV0AVMCAjASBgNVHRMBAf8ECDAGAQH/AgED +MB0GA1UdDgQWBBRF2aWBbj2ITY1x0kbBbkUe88SAnTAfBgNVHSMEGDAWgBRF2aWBbj2ITY1x0kbB +bkUe88SAnTANBgkqhkiG9w0BAQsFAAOCAgEAlDpzBp9SSzBc1P6xXCX5145v9Ydkn+0UjrgEjihL +j6p7jjm02Vj2e6E1CqGdivdj5eu9OYLU43otb98TPLr+flaYC/NUn81ETm484T4VvwYmneTwkLbU +wp4wLh/vx3rEUMfqe9pQy3omywC0Wqu1kx+AiYQElY2NfwmTv9SoqORjbdlk5LgpWgi/UOGED1V7 +XwgiG/W9mR4U9s70WBCCswo9GcG/W6uqmdjyMb3lOGbcWAXH7WMaLgqXfIeTK7KK4/HsGOV1timH +59yLGn602MnTihdsfSlEvoqq9X46Lmgxk7lq2prg2+kupYTNHAq4Sgj5nPFhJpiTt3tm7JFe3VE/ +23MPrQRYCd0EApUKPtN236YQHoA96M2kZNEzx5LH4k5E4wnJTsJdhw4Snr8PyQUQ3nqjsTzyP6Wq +J3mtMX0f/fwZacXduT98zca0wjAefm6S139hdlqP65VNvBFuIXxZN5nQBrz5Bm0yFqXZaajh3DyA +HmBR3NdUIR7KYndP+tiPsys6DXhyyWhBWkdKwqPrGtcKqzwyVcgKEZzfdNbwQBUdyLmPtTbFr/gi +uMod89a2GQ+fYWVq6nTIfI/DT11lgh/ZDYnadXL77/FHZxOzyNEZiCcmmpl5fx7kLD977vHeTYuW +l8PVP3wbI+2ksx0WckNLIOFZfsLorSa/ovc= +-----END CERTIFICATE----- + +CA Disig Root R1 +================ +-----BEGIN CERTIFICATE----- +MIIFaTCCA1GgAwIBAgIJAMMDmu5QkG4oMA0GCSqGSIb3DQEBBQUAMFIxCzAJBgNVBAYTAlNLMRMw +EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp +ZyBSb290IFIxMB4XDTEyMDcxOTA5MDY1NloXDTQyMDcxOTA5MDY1NlowUjELMAkGA1UEBhMCU0sx +EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp +c2lnIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCqw3j33Jijp1pedxiy +3QRkD2P9m5YJgNXoqqXinCaUOuiZc4yd39ffg/N4T0Dhf9Kn0uXKE5Pn7cZ3Xza1lK/oOI7bm+V8 +u8yN63Vz4STN5qctGS7Y1oprFOsIYgrY3LMATcMjfF9DCCMyEtztDK3AfQ+lekLZWnDZv6fXARz2 +m6uOt0qGeKAeVjGu74IKgEH3G8muqzIm1Cxr7X1r5OJeIgpFy4QxTaz+29FHuvlglzmxZcfe+5nk +CiKxLU3lSCZpq+Kq8/v8kiky6bM+TR8noc2OuRf7JT7JbvN32g0S9l3HuzYQ1VTW8+DiR0jm3hTa +YVKvJrT1cU/J19IG32PK/yHoWQbgCNWEFVP3Q+V8xaCJmGtzxmjOZd69fwX3se72V6FglcXM6pM6 +vpmumwKjrckWtc7dXpl4fho5frLABaTAgqWjR56M6ly2vGfb5ipN0gTco65F97yLnByn1tUD3AjL +LhbKXEAz6GfDLuemROoRRRw1ZS0eRWEkG4IupZ0zXWX4Qfkuy5Q/H6MMMSRE7cderVC6xkGbrPAX +ZcD4XW9boAo0PO7X6oifmPmvTiT6l7Jkdtqr9O3jw2Dv1fkCyC2fg69naQanMVXVz0tv/wQFx1is +XxYb5dKj6zHbHzMVTdDypVP1y+E9Tmgt2BLdqvLmTZtJ5cUoobqwWsagtQIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUiQq0OJMa5qvum5EY+fU8PjXQ +04IwDQYJKoZIhvcNAQEFBQADggIBADKL9p1Kyb4U5YysOMo6CdQbzoaz3evUuii+Eq5FLAR0rBNR +xVgYZk2C2tXck8An4b58n1KeElb21Zyp9HWc+jcSjxyT7Ff+Bw+r1RL3D65hXlaASfX8MPWbTx9B +LxyE04nH4toCdu0Jz2zBuByDHBb6lM19oMgY0sidbvW9adRtPTXoHqJPYNcHKfyyo6SdbhWSVhlM +CrDpfNIZTUJG7L399ldb3Zh+pE3McgODWF3vkzpBemOqfDqo9ayk0d2iLbYq/J8BjuIQscTK5Gfb +VSUZP/3oNn6z4eGBrxEWi1CXYBmCAMBrTXO40RMHPuq2MU/wQppt4hF05ZSsjYSVPCGvxdpHyN85 +YmLLW1AL14FABZyb7bq2ix4Eb5YgOe2kfSnbSM6C3NQCjR0EMVrHS/BsYVLXtFHCgWzN4funodKS +ds+xDzdYpPJScWc/DIh4gInByLUfkmO+p3qKViwaqKactV2zY9ATIKHrkWzQjX2v3wvkF7mGnjix +lAxYjOBVqjtjbZqJYLhkKpLGN/R+Q0O3c+gB53+XD9fyexn9GtePyfqFa3qdnom2piiZk4hA9z7N +UaPK6u95RyG1/jLix8NRb76AdPCkwzryT+lf3xkK8jsTQ6wxpLPn6/wY1gGp8yqPNg7rtLG8t0zJ +a7+h89n07eLw4+1knj0vllJPgFOL +-----END CERTIFICATE----- + +CA Disig Root R2 +================ +-----BEGIN CERTIFICATE----- +MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw +EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp +ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx +EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp +c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC +w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia +xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7 +A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S +GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV +g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa +5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE +koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A +Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i +Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u +Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM +tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV +sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je +dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8 +1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx +mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01 +utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0 +sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg +UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV +7+ZtsH8tZ/3zbBt1RqPlShfppNcL +-----END CERTIFICATE----- + +ACCVRAIZ1 +========= +-----BEGIN CERTIFICATE----- +MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB +SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1 +MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH +UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM +jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0 +RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD +aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ +0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG +WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7 +8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR +5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J +9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK +Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw +Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu +Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2 +VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM +Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA +QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh +AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA +YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj +AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA +IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk +aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0 +dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2 +MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI +hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E +R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN +YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49 +nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ +TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3 +sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h +I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg +Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd +3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p +EfbRD0tVNEYqi4Y7 +-----END CERTIFICATE----- + +TWCA Global Root CA +=================== +-----BEGIN CERTIFICATE----- +MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT +CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD +QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK +EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg +Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C +nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV +r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR +Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV +tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W +KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99 +sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p +yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn +kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI +zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC +AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g +cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn +LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M +8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg +/eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg +lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP +A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m +i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8 +EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3 +zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0= +-----END CERTIFICATE----- + +TeliaSonera Root CA v1 +====================== +-----BEGIN CERTIFICATE----- +MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE +CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4 +MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW +VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+ +6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA +3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k +B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn +Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH +oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3 +F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ +oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7 +gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc +TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB +AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW +DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm +zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx +0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW +pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV +G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc +c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT +JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2 +qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6 +Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems +WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY= +-----END CERTIFICATE----- + +EE Certification Centre Root CA +=============================== +-----BEGIN CERTIFICATE----- +MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG +EwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEoMCYGA1UEAwwfRUUgQ2Vy +dGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYGCSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIw +MTAxMDMwMTAxMDMwWhgPMjAzMDEyMTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlB +UyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRy +ZSBSb290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEBAQUAA4IB +DwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUyeuuOF0+W2Ap7kaJjbMeM +TC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvObntl8jixwKIy72KyaOBhU8E2lf/slLo2 +rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIwWFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw +93X2PaRka9ZP585ArQ/dMtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtN +P2MbRMNE1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYDVR0T +AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/zQas8fElyalL1BSZ +MEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEF +BQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEFBQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+Rj +xY6hUFaTlrg4wCQiZrxTFGGVv9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqM +lIpPnTX/dqQGE5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u +uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIWiAYLtqZLICjU +3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/vGVCJYMzpJJUPwssd8m92kMfM +dcGWxZ0= +-----END CERTIFICATE----- + +E-Tugra Certification Authority +=============================== +-----BEGIN CERTIFICATE----- +MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w +DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls +ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN +ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw +NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx +QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl +cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD +DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A +MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd +hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K +CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g +ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ +BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0 +E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz +rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq +jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn +rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5 +dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB +/wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG +MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK +kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO +XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807 +VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo +a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc +dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV +KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT +Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0 +8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G +C7TbO6Orb1wdtn7os4I07QZcJA== +-----END CERTIFICATE----- + +T-TeleSec GlobalRoot Class 2 +============================ +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM +IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU +cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx +MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz +dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD +ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ +SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F +vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970 +2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV +WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA +MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy +YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4 +r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf +vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR +3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN +9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg== +-----END CERTIFICATE----- + +Atos TrustedRoot 2011 +===================== +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU +cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4 +MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG +A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV +hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr +54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+ +DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320 +HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR +z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R +l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ +bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB +CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h +k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh +TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9 +61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G +3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed +-----END CERTIFICATE----- + +QuoVadis Root CA 1 G3 +===================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG +A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv +b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN +MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg +RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE +PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm +PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6 +Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN +ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l +g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV +7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX +9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f +iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg +t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI +hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC +MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3 +GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct +Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP ++V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh +3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa +wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6 +O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0 +FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV +hMJKzRwuJIczYOXD +-----END CERTIFICATE----- + +QuoVadis Root CA 2 G3 +===================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG +A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv +b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN +MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg +RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh +ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY +NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t +oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o +MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l +V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo +L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ +sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD +6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh +lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI +hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66 +AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K +pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9 +x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz +dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X +U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw +mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD +zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN +JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr +O3jtZsSOeWmD3n+M +-----END CERTIFICATE----- + +QuoVadis Root CA 3 G3 +===================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG +A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv +b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN +MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg +RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286 +IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL +Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe +6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3 +I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U +VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7 +5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi +Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM +dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt +rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI +hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px +KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS +t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ +TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du +DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib +Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD +hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX +0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW +dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2 +PpxxVJkES/1Y+Zj0 +-----END CERTIFICATE----- + +DigiCert Assured ID Root G2 +=========================== +-----BEGIN CERTIFICATE----- +MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw +IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw +MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL +ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH +35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq +bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw +VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP +YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn +lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO +w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv +0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz +d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW +hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M +jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo +IhNzbM8m9Yop5w== +-----END CERTIFICATE----- + +DigiCert Assured ID Root G3 +=========================== +-----BEGIN CERTIFICATE----- +MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD +VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1 +MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ +BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb +RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs +KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF +UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy +YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy +1vUhZscv6pZjamVFkpUBtA== +-----END CERTIFICATE----- + +DigiCert Global Root G2 +======================= +-----BEGIN CERTIFICATE----- +MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw +HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx +MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3 +dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq +hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ +kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO +3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV +BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM +UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB +o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu +5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr +F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U +WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH +QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/ +iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl +MrY= +-----END CERTIFICATE----- + +DigiCert Global Root G3 +======================= +-----BEGIN CERTIFICATE----- +MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD +VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw +MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k +aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C +AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O +YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP +BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp +Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y +3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34 +VOKa5Vt8sycX +-----END CERTIFICATE----- + +DigiCert Trusted Root G4 +======================== +-----BEGIN CERTIFICATE----- +MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw +HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1 +MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G +CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp +pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o +k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa +vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY +QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6 +MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm +mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7 +f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH +dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8 +oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud +DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD +ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY +ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr +yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy +7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah +ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN +5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb +/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa +5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK +G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP +82Z+ +-----END CERTIFICATE----- + +WoSign +====== +-----BEGIN CERTIFICATE----- +MIIFdjCCA16gAwIBAgIQXmjWEXGUY1BWAGjzPsnFkTANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQG +EwJDTjEaMBgGA1UEChMRV29TaWduIENBIExpbWl0ZWQxKjAoBgNVBAMTIUNlcnRpZmljYXRpb24g +QXV0aG9yaXR5IG9mIFdvU2lnbjAeFw0wOTA4MDgwMTAwMDFaFw0zOTA4MDgwMTAwMDFaMFUxCzAJ +BgNVBAYTAkNOMRowGAYDVQQKExFXb1NpZ24gQ0EgTGltaXRlZDEqMCgGA1UEAxMhQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgb2YgV29TaWduMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA +vcqNrLiRFVaXe2tcesLea9mhsMMQI/qnobLMMfo+2aYpbxY94Gv4uEBf2zmoAHqLoE1UfcIiePyO +CbiohdfMlZdLdNiefvAA5A6JrkkoRBoQmTIPJYhTpA2zDxIIFgsDcSccf+Hb0v1naMQFXQoOXXDX +2JegvFNBmpGN9J42Znp+VsGQX+axaCA2pIwkLCxHC1l2ZjC1vt7tj/id07sBMOby8w7gLJKA84X5 +KIq0VC6a7fd2/BVoFutKbOsuEo/Uz/4Mx1wdC34FMr5esAkqQtXJTpCzWQ27en7N1QhatH/YHGkR ++ScPewavVIMYe+HdVHpRaG53/Ma/UkpmRqGyZxq7o093oL5d//xWC0Nyd5DKnvnyOfUNqfTq1+ez +EC8wQjchzDBwyYaYD8xYTYO7feUapTeNtqwylwA6Y3EkHp43xP901DfA4v6IRmAR3Qg/UDaruHqk +lWJqbrDKaiFaafPz+x1wOZXzp26mgYmhiMU7ccqjUu6Du/2gd/Tkb+dC221KmYo0SLwX3OSACCK2 +8jHAPwQ+658geda4BmRkAjHXqc1S+4RFaQkAKtxVi8QGRkvASh0JWzko/amrzgD5LkhLJuYwTKVY +yrREgk/nkR4zw7CT/xH8gdLKH3Ep3XZPkiWvHYG3Dy+MwwbMLyejSuQOmbp8HkUff6oZRZb9/D0C +AwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFOFmzw7R +8bNLtwYgFP6HEtX2/vs+MA0GCSqGSIb3DQEBBQUAA4ICAQCoy3JAsnbBfnv8rWTjMnvMPLZdRtP1 +LOJwXcgu2AZ9mNELIaCJWSQBnfmvCX0KI4I01fx8cpm5o9dU9OpScA7F9dY74ToJMuYhOZO9sxXq +T2r09Ys/L3yNWC7F4TmgPsc9SnOeQHrAK2GpZ8nzJLmzbVUsWh2eJXLOC62qx1ViC777Y7NhRCOj +y+EaDveaBk3e1CNOIZZbOVtXHS9dCF4Jef98l7VNg64N1uajeeAz0JmWAjCnPv/So0M/BVoG6kQC +2nz4SNAzqfkHx5Xh9T71XXG68pWpdIhhWeO/yloTunK0jF02h+mmxTwTv97QRCbut+wucPrXnbes +5cVAWubXbHssw1abR80LzvobtCHXt2a49CUwi1wNuepnsvRtrtWhnk/Yn+knArAdBtaP4/tIEp9/ +EaEQPkxROpaw0RPxx9gmrjrKkcRpnd8BKWRRb2jaFOwIQZeQjdCygPLPwj2/kWjFgGcexGATVdVh +mVd8upUPYUk6ynW8yQqTP2cOEvIo4jEbwFcW3wh8GcF+Dx+FHgo2fFt+J7x6v+Db9NpSvd4MVHAx +kUOVyLzwPt0JfjBkUO1/AaQzZ01oT74V77D2AhGiGxMlOtzCWfHjXEa7ZywCRuoeSKbmW9m1vFGi +kpbbqsY3Iqb+zCB0oy2pLmvLwIIRIbWTee5Ehr7XHuQe+w== +-----END CERTIFICATE----- + +WoSign China +============ +-----BEGIN CERTIFICATE----- +MIIFWDCCA0CgAwIBAgIQUHBrzdgT/BtOOzNy0hFIjTANBgkqhkiG9w0BAQsFADBGMQswCQYDVQQG +EwJDTjEaMBgGA1UEChMRV29TaWduIENBIExpbWl0ZWQxGzAZBgNVBAMMEkNBIOayg+mAmuagueiv +geS5pjAeFw0wOTA4MDgwMTAwMDFaFw0zOTA4MDgwMTAwMDFaMEYxCzAJBgNVBAYTAkNOMRowGAYD +VQQKExFXb1NpZ24gQ0EgTGltaXRlZDEbMBkGA1UEAwwSQ0Eg5rKD6YCa5qC56K+B5LmmMIICIjAN +BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0EkhHiX8h8EqwqzbdoYGTufQdDTc7WU1/FDWiD+k +8H/rD195L4mx/bxjWDeTmzj4t1up+thxx7S8gJeNbEvxUNUqKaqoGXqW5pWOdO2XCld19AXbbQs5 +uQF/qvbW2mzmBeCkTVL829B0txGMe41P/4eDrv8FAxNXUDf+jJZSEExfv5RxadmWPgxDT74wwJ85 +dE8GRV2j1lY5aAfMh09Qd5Nx2UQIsYo06Yms25tO4dnkUkWMLhQfkWsZHWgpLFbE4h4TV2TwYeO5 +Ed+w4VegG63XX9Gv2ystP9Bojg/qnw+LNVgbExz03jWhCl3W6t8Sb8D7aQdGctyB9gQjF+BNdeFy +b7Ao65vh4YOhn0pdr8yb+gIgthhid5E7o9Vlrdx8kHccREGkSovrlXLp9glk3Kgtn3R46MGiCWOc +76DbT52VqyBPt7D3h1ymoOQ3OMdc4zUPLK2jgKLsLl3Az+2LBcLmc272idX10kaO6m1jGx6KyX2m ++Jzr5dVjhU1zZmkR/sgO9MHHZklTfuQZa/HpelmjbX7FF+Ynxu8b22/8DU0GAbQOXDBGVWCvOGU6 +yke6rCzMRh+yRpY/8+0mBe53oWprfi1tWFxK1I5nuPHa1UaKJ/kR8slC/k7e3x9cxKSGhxYzoacX +GKUN5AXlK8IrC6KVkLn9YDxOiT7nnO4fuwECAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1Ud +EwEB/wQFMAMBAf8wHQYDVR0OBBYEFOBNv9ybQV0T6GTwp+kVpOGBwboxMA0GCSqGSIb3DQEBCwUA +A4ICAQBqinA4WbbaixjIvirTthnVZil6Xc1bL3McJk6jfW+rtylNpumlEYOnOXOvEESS5iVdT2H6 +yAa+Tkvv/vMx/sZ8cApBWNromUuWyXi8mHwCKe0JgOYKOoICKuLJL8hWGSbueBwj/feTZU7n85iY +r83d2Z5AiDEoOqsuC7CsDCT6eiaY8xJhEPRdF/d+4niXVOKM6Cm6jBAyvd0zaziGfjk9DgNyp115 +j0WKWa5bIW4xRtVZjc8VX90xJc/bYNaBRHIpAlf2ltTW/+op2znFuCyKGo3Oy+dCMYYFaA6eFN0A +kLppRQjbbpCBhqcqBT/mhDn4t/lXX0ykeVoQDF7Va/81XwVRHmyjdanPUIPTfPRm94KNPQx96N97 +qA4bLJyuQHCH2u2nFoJavjVsIE4iYdm8UXrNemHcSxH5/mc0zy4EZmFcV5cjjPOGG0jfKq+nwf/Y +jj4Du9gqsPoUJbJRa4ZDhS4HIxaAjUz7tGM7zMN07RujHv41D198HRaG9Q7DlfEvr10lO1Hm13ZB +ONFLAzkopR6RctR9q5czxNM+4Gm2KHmgCY0c0f9BckgG/Jou5yD5m6Leie2uPAmvylezkolwQOQv +T8Jwg0DXJCxr5wkf09XHwQj02w47HAcLQxGEIYbpgNR12KvxAmLBsX5VYc8T1yaw15zLKYs4SgsO +kI26oQ== +-----END CERTIFICATE----- + +COMODO RSA Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE +BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG +A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC +R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE +ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn +dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ +FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+ +5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG +x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX +2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL +OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3 +sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C +GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5 +WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E +FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w +DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt +rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+ +nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg +tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW +sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp +pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA +zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq +ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52 +7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I +LaZRfyHBNVOFBkpdn627G190 +-----END CERTIFICATE----- + +USERTrust RSA Certification Authority +===================================== +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK +ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK +ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz +0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j +Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn +RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O ++T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq +/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE +Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM +lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8 +yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+ +eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd +BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW +FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ +7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ +Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM +8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi +FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi +yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c +J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw +sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx +Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- + +USERTrust ECC Certification Authority +===================================== +-----BEGIN CERTIFICATE----- +MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC +VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC +VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2 +0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez +nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV +HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB +HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu +9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg= +-----END CERTIFICATE----- + +GlobalSign ECC Root CA - R4 +=========================== +-----BEGIN CERTIFICATE----- +MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb +R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD +EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb +R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD +EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl +OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P +AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV +MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF +JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q= +-----END CERTIFICATE----- + +GlobalSign ECC Root CA - R5 +=========================== +-----BEGIN CERTIFICATE----- +MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb +R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD +EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb +R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD +EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6 +SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS +h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd +BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx +uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7 +yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3 +-----END CERTIFICATE----- + +Staat der Nederlanden Root CA - G3 +================================== +-----BEGIN CERTIFICATE----- +MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE +CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g +Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC +TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l +ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y +olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t +x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy +EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K +Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur +mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5 +1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp +07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo +FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE +41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB +AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu +yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD +U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq +KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1 +v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA +8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b +8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r +mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq +1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI +JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV +tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk= +-----END CERTIFICATE----- + +Staat der Nederlanden EV Root CA +================================ +-----BEGIN CERTIFICATE----- +MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE +CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g +RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M +MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl +cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk +SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW +O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r +0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8 +Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV +XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr +08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV +0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd +74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx +fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa +ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI +eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu +c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq +5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN +b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN +f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi +5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4 +WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK +DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy +eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg== +-----END CERTIFICATE----- + +IdenTrust Commercial Root CA 1 +============================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG +EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS +b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES +MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB +IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld +hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/ +mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi +1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C +XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl +3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy +NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV +WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg +xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix +uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC +AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI +hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH +6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg +ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt +ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV +YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX +feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro +kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe +2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz +Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R +cGzM7vRX+Bi6hG6H +-----END CERTIFICATE----- + +IdenTrust Public Sector Root CA 1 +================================= +-----BEGIN CERTIFICATE----- +MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG +EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv +ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV +UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS +b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy +P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6 +Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI +rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf +qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS +mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn +ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh +LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v +iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL +4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B +Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw +DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj +t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A +mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt +GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt +m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx +NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4 +Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI +ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC +ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ +3Wl9af0AVqW3rLatt8o+Ae+c +-----END CERTIFICATE----- + +Entrust Root Certification Authority - G2 +========================================= +-----BEGIN CERTIFICATE----- +MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV +BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy +bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug +b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw +HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT +DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx +OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s +eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP +/vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz +HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU +s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y +TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx +AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6 +0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z +iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ +Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi +nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+ +vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO +e4pIb4tF9g== +-----END CERTIFICATE----- + +Entrust Root Certification Authority - EC1 +========================================== +-----BEGIN CERTIFICATE----- +MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx +FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn +YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl +ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw +FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs +LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg +dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt +IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy +AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef +9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h +vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8 +kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G +-----END CERTIFICATE----- + +CFCA EV ROOT +============ +-----BEGIN CERTIFICATE----- +MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE +CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB +IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw +MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD +DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV +BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD +7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN +uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW +ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7 +xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f +py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K +gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol +hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ +tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf +BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB +/wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB +ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q +ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua +4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG +E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX +BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn +aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy +PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX +kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C +ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su +-----END CERTIFICATE----- diff --git a/backend/wp-includes/class-IXR.php b/backend/wp-includes/class-IXR.php new file mode 100644 index 0000000..706e5e3 --- /dev/null +++ b/backend/wp-includes/class-IXR.php @@ -0,0 +1,60 @@ +<?php +/** + * IXR - The Incutio XML-RPC Library + * + * Copyright (c) 2010, Incutio Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - Neither the name of Incutio Ltd. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @package IXR + * @since 1.5.0 + * + * @copyright Incutio Ltd 2010 (http://www.incutio.com) + * @version 1.7.4 7th September 2010 + * @author Simon Willison + * @link http://scripts.incutio.com/xmlrpc/ Site/manual + * @license http://www.opensource.org/licenses/bsd-license.php BSD + */ + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-server.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-base64.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-client.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-clientmulticall.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-date.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-error.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-introspectionserver.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-message.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-request.php' ); + +require_once( ABSPATH . WPINC . '/IXR/class-IXR-value.php' ); \ No newline at end of file diff --git a/backend/wp-includes/class-feed.php b/backend/wp-includes/class-feed.php new file mode 100644 index 0000000..62dd119 --- /dev/null +++ b/backend/wp-includes/class-feed.php @@ -0,0 +1,18 @@ +<?php +/** + * Feed API + * + * @package WordPress + * @subpackage Feed + */ + +_deprecated_file( basename( __FILE__ ), '4.7.0', 'fetch_feed()' ); + +if ( ! class_exists( 'SimplePie', false ) ) { + require_once( ABSPATH . WPINC . '/class-simplepie.php' ); +} + +require_once( ABSPATH . WPINC . '/class-wp-feed-cache.php' ); +require_once( ABSPATH . WPINC . '/class-wp-feed-cache-transient.php' ); +require_once( ABSPATH . WPINC . '/class-wp-simplepie-file.php' ); +require_once( ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php' ); \ No newline at end of file diff --git a/backend/wp-includes/class-http.php b/backend/wp-includes/class-http.php new file mode 100644 index 0000000..c802f7f --- /dev/null +++ b/backend/wp-includes/class-http.php @@ -0,0 +1,1023 @@ +<?php +/** + * HTTP API: WP_Http class + * + * @package WordPress + * @subpackage HTTP + * @since 2.7.0 + */ + +if ( ! class_exists( 'Requests' ) ) { + require( ABSPATH . WPINC . '/class-requests.php' ); + + Requests::register_autoloader(); + Requests::set_certificate_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' ); +} + +/** + * Core class used for managing HTTP transports and making HTTP requests. + * + * This class is used to consistently make outgoing HTTP requests easy for developers + * while still being compatible with the many PHP configurations under which + * WordPress runs. + * + * Debugging includes several actions, which pass different variables for debugging the HTTP API. + * + * @since 2.7.0 + */ +class WP_Http { + + // Aliases for HTTP response codes. + const HTTP_CONTINUE = 100; + const SWITCHING_PROTOCOLS = 101; + const PROCESSING = 102; + + const OK = 200; + const CREATED = 201; + const ACCEPTED = 202; + const NON_AUTHORITATIVE_INFORMATION = 203; + const NO_CONTENT = 204; + const RESET_CONTENT = 205; + const PARTIAL_CONTENT = 206; + const MULTI_STATUS = 207; + const IM_USED = 226; + + const MULTIPLE_CHOICES = 300; + const MOVED_PERMANENTLY = 301; + const FOUND = 302; + const SEE_OTHER = 303; + const NOT_MODIFIED = 304; + const USE_PROXY = 305; + const RESERVED = 306; + const TEMPORARY_REDIRECT = 307; + const PERMANENT_REDIRECT = 308; + + const BAD_REQUEST = 400; + const UNAUTHORIZED = 401; + const PAYMENT_REQUIRED = 402; + const FORBIDDEN = 403; + const NOT_FOUND = 404; + const METHOD_NOT_ALLOWED = 405; + const NOT_ACCEPTABLE = 406; + const PROXY_AUTHENTICATION_REQUIRED = 407; + const REQUEST_TIMEOUT = 408; + const CONFLICT = 409; + const GONE = 410; + const LENGTH_REQUIRED = 411; + const PRECONDITION_FAILED = 412; + const REQUEST_ENTITY_TOO_LARGE = 413; + const REQUEST_URI_TOO_LONG = 414; + const UNSUPPORTED_MEDIA_TYPE = 415; + const REQUESTED_RANGE_NOT_SATISFIABLE = 416; + const EXPECTATION_FAILED = 417; + const IM_A_TEAPOT = 418; + const MISDIRECTED_REQUEST = 421; + const UNPROCESSABLE_ENTITY = 422; + const LOCKED = 423; + const FAILED_DEPENDENCY = 424; + const UPGRADE_REQUIRED = 426; + const PRECONDITION_REQUIRED = 428; + const TOO_MANY_REQUESTS = 429; + const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; + const UNAVAILABLE_FOR_LEGAL_REASONS = 451; + + const INTERNAL_SERVER_ERROR = 500; + const NOT_IMPLEMENTED = 501; + const BAD_GATEWAY = 502; + const SERVICE_UNAVAILABLE = 503; + const GATEWAY_TIMEOUT = 504; + const HTTP_VERSION_NOT_SUPPORTED = 505; + const VARIANT_ALSO_NEGOTIATES = 506; + const INSUFFICIENT_STORAGE = 507; + const NOT_EXTENDED = 510; + const NETWORK_AUTHENTICATION_REQUIRED = 511; + + /** + * Send an HTTP request to a URI. + * + * Please note: The only URI that are supported in the HTTP Transport implementation + * are the HTTP and HTTPS protocols. + * + * @since 2.7.0 + * + * @param string $url The request URL. + * @param string|array $args { + * Optional. Array or string of HTTP request arguments. + * + * @type string $method Request method. Accepts 'GET', 'POST', 'HEAD', or 'PUT'. + * Some transports technically allow others, but should not be + * assumed. Default 'GET'. + * @type int $timeout How long the connection should stay open in seconds. Default 5. + * @type int $redirection Number of allowed redirects. Not supported by all transports + * Default 5. + * @type string $httpversion Version of the HTTP protocol to use. Accepts '1.0' and '1.1'. + * Default '1.0'. + * @type string $user-agent User-agent value sent. + * Default 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ). + * @type bool $reject_unsafe_urls Whether to pass URLs through wp_http_validate_url(). + * Default false. + * @type bool $blocking Whether the calling code requires the result of the request. + * If set to false, the request will be sent to the remote server, + * and processing returned to the calling code immediately, the caller + * will know if the request succeeded or failed, but will not receive + * any response from the remote server. Default true. + * @type string|array $headers Array or string of headers to send with the request. + * Default empty array. + * @type array $cookies List of cookies to send with the request. Default empty array. + * @type string|array $body Body to send with the request. Default null. + * @type bool $compress Whether to compress the $body when sending the request. + * Default false. + * @type bool $decompress Whether to decompress a compressed response. If set to false and + * compressed content is returned in the response anyway, it will + * need to be separately decompressed. Default true. + * @type bool $sslverify Whether to verify SSL for the request. Default true. + * @type string sslcertificates Absolute path to an SSL certificate .crt file. + * Default ABSPATH . WPINC . '/certificates/ca-bundle.crt'. + * @type bool $stream Whether to stream to a file. If set to true and no filename was + * given, it will be droped it in the WP temp dir and its name will + * be set using the basename of the URL. Default false. + * @type string $filename Filename of the file to write to when streaming. $stream must be + * set to true. Default null. + * @type int $limit_response_size Size in bytes to limit the response to. Default null. + * + * } + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. + * A WP_Error instance upon error. + */ + public function request( $url, $args = array() ) { + $defaults = array( + 'method' => 'GET', + /** + * Filters the timeout value for an HTTP request. + * + * @since 2.7.0 + * + * @param int $timeout_value Time in seconds until a request times out. + * Default 5. + */ + 'timeout' => apply_filters( 'http_request_timeout', 5 ), + /** + * Filters the number of redirects allowed during an HTTP request. + * + * @since 2.7.0 + * + * @param int $redirect_count Number of redirects allowed. Default 5. + */ + 'redirection' => apply_filters( 'http_request_redirection_count', 5 ), + /** + * Filters the version of the HTTP protocol used in a request. + * + * @since 2.7.0 + * + * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'. + * Default '1.0'. + */ + 'httpversion' => apply_filters( 'http_request_version', '1.0' ), + /** + * Filters the user agent value sent with an HTTP request. + * + * @since 2.7.0 + * + * @param string $user_agent WordPress user agent string. + */ + 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) ), + /** + * Filters whether to pass URLs through wp_http_validate_url() in an HTTP request. + * + * @since 3.6.0 + * + * @param bool $pass_url Whether to pass URLs through wp_http_validate_url(). + * Default false. + */ + 'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ), + 'blocking' => true, + 'headers' => array(), + 'cookies' => array(), + 'body' => null, + 'compress' => false, + 'decompress' => true, + 'sslverify' => true, + 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', + 'stream' => false, + 'filename' => null, + 'limit_response_size' => null, + ); + + // Pre-parse for the HEAD checks. + $args = wp_parse_args( $args ); + + // By default, Head requests do not cause redirections. + if ( isset($args['method']) && 'HEAD' == $args['method'] ) + $defaults['redirection'] = 0; + + $r = wp_parse_args( $args, $defaults ); + /** + * Filters the arguments used in an HTTP request. + * + * @since 2.7.0 + * + * @param array $r An array of HTTP request arguments. + * @param string $url The request URL. + */ + $r = apply_filters( 'http_request_args', $r, $url ); + + // The transports decrement this, store a copy of the original value for loop purposes. + if ( ! isset( $r['_redirection'] ) ) + $r['_redirection'] = $r['redirection']; + + /** + * Filters whether to preempt an HTTP request's return value. + * + * Returning a non-false value from the filter will short-circuit the HTTP request and return + * early with that value. A filter should return either: + * + * - An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements + * - A WP_Error instance + * - boolean false (to avoid short-circuiting the response) + * + * Returning any other value may result in unexpected behaviour. + * + * @since 2.9.0 + * + * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false. + * @param array $r HTTP request arguments. + * @param string $url The request URL. + */ + $pre = apply_filters( 'pre_http_request', false, $r, $url ); + + if ( false !== $pre ) + return $pre; + + if ( function_exists( 'wp_kses_bad_protocol' ) ) { + if ( $r['reject_unsafe_urls'] ) { + $url = wp_http_validate_url( $url ); + } + if ( $url ) { + $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) ); + } + } + + $arrURL = @parse_url( $url ); + + if ( empty( $url ) || empty( $arrURL['scheme'] ) ) { + return new WP_Error('http_request_failed', __('A valid URL was not provided.')); + } + + if ( $this->block_request( $url ) ) { + return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) ); + } + + // If we are streaming to a file but no filename was given drop it in the WP temp dir + // and pick its name using the basename of the $url + if ( $r['stream'] ) { + if ( empty( $r['filename'] ) ) { + $r['filename'] = get_temp_dir() . basename( $url ); + } + + // Force some settings if we are streaming to a file and check for existence and perms of destination directory + $r['blocking'] = true; + if ( ! wp_is_writable( dirname( $r['filename'] ) ) ) { + return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) ); + } + } + + if ( is_null( $r['headers'] ) ) { + $r['headers'] = array(); + } + + // WP allows passing in headers as a string, weirdly. + if ( ! is_array( $r['headers'] ) ) { + $processedHeaders = WP_Http::processHeaders( $r['headers'] ); + $r['headers'] = $processedHeaders['headers']; + } + + // Setup arguments + $headers = $r['headers']; + $data = $r['body']; + $type = $r['method']; + $options = array( + 'timeout' => $r['timeout'], + 'useragent' => $r['user-agent'], + 'blocking' => $r['blocking'], + 'hooks' => new WP_HTTP_Requests_Hooks( $url, $r ), + ); + + // Ensure redirects follow browser behaviour. + $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) ); + + // Validate redirected URLs. + if ( function_exists( 'wp_kses_bad_protocol' ) && $r['reject_unsafe_urls'] ) { + $options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) ); + } + + if ( $r['stream'] ) { + $options['filename'] = $r['filename']; + } + if ( empty( $r['redirection'] ) ) { + $options['follow_redirects'] = false; + } else { + $options['redirects'] = $r['redirection']; + } + + // Use byte limit, if we can + if ( isset( $r['limit_response_size'] ) ) { + $options['max_bytes'] = $r['limit_response_size']; + } + + // If we've got cookies, use and convert them to Requests_Cookie. + if ( ! empty( $r['cookies'] ) ) { + $options['cookies'] = WP_Http::normalize_cookies( $r['cookies'] ); + } + + // SSL certificate handling + if ( ! $r['sslverify'] ) { + $options['verify'] = false; + $options['verifyname'] = false; + } else { + $options['verify'] = $r['sslcertificates']; + } + + // All non-GET/HEAD requests should put the arguments in the form body. + if ( 'HEAD' !== $type && 'GET' !== $type ) { + $options['data_format'] = 'body'; + } + + /** + * Filters whether SSL should be verified for non-local requests. + * + * @since 2.8.0 + * + * @param bool $ssl_verify Whether to verify the SSL connection. Default true. + */ + $options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'] ); + + // Check for proxies. + $proxy = new WP_HTTP_Proxy(); + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { + $options['proxy'] = new Requests_Proxy_HTTP( $proxy->host() . ':' . $proxy->port() ); + + if ( $proxy->use_authentication() ) { + $options['proxy']->use_authentication = true; + $options['proxy']->user = $proxy->username(); + $options['proxy']->pass = $proxy->password(); + } + } + + // Avoid issues where mbstring.func_overload is enabled + mbstring_binary_safe_encoding(); + + try { + $requests_response = Requests::request( $url, $headers, $data, $type, $options ); + + // Convert the response into an array + $http_response = new WP_HTTP_Requests_Response( $requests_response, $r['filename'] ); + $response = $http_response->to_array(); + + // Add the original object to the array. + $response['http_response'] = $http_response; + } + catch ( Requests_Exception $e ) { + $response = new WP_Error( 'http_request_failed', $e->getMessage() ); + } + + reset_mbstring_encoding(); + + /** + * Fires after an HTTP API response is received and before the response is returned. + * + * @since 2.8.0 + * + * @param array|WP_Error $response HTTP response or WP_Error object. + * @param string $context Context under which the hook is fired. + * @param string $class HTTP transport used. + * @param array $r HTTP request arguments. + * @param string $url The request URL. + */ + do_action( 'http_api_debug', $response, 'response', 'Requests', $r, $url ); + if ( is_wp_error( $response ) ) { + return $response; + } + + if ( ! $r['blocking'] ) { + return array( + 'headers' => array(), + 'body' => '', + 'response' => array( + 'code' => false, + 'message' => false, + ), + 'cookies' => array(), + 'http_response' => null, + ); + } + + /** + * Filters the HTTP API response immediately before the response is returned. + * + * @since 2.9.0 + * + * @param array $response HTTP response. + * @param array $r HTTP request arguments. + * @param string $url The request URL. + */ + return apply_filters( 'http_response', $response, $r, $url ); + } + + /** + * Normalizes cookies for using in Requests. + * + * @since 4.6.0 + * @static + * + * @param array $cookies List of cookies to send with the request. + * @return Requests_Cookie_Jar Cookie holder object. + */ + public static function normalize_cookies( $cookies ) { + $cookie_jar = new Requests_Cookie_Jar(); + + foreach ( $cookies as $name => $value ) { + if ( $value instanceof WP_Http_Cookie ) { + $cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes() ); + } elseif ( is_scalar( $value ) ) { + $cookie_jar[ $name ] = new Requests_Cookie( $name, $value ); + } + } + + return $cookie_jar; + } + + /** + * Match redirect behaviour to browser handling. + * + * Changes 302 redirects from POST to GET to match browser handling. Per + * RFC 7231, user agents can deviate from the strict reading of the + * specification for compatibility purposes. + * + * @since 4.6.0 + * @static + * + * @param string $location URL to redirect to. + * @param array $headers Headers for the redirect. + * @param string|array $data Body to send with the request. + * @param array $options Redirect request options. + * @param Requests_Response $original Response object. + */ + public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) { + // Browser compat + if ( $original->status_code === 302 ) { + $options['type'] = Requests::GET; + } + } + + /** + * Validate redirected URLs. + * + * @since 4.7.5 + * + * @throws Requests_Exception On unsuccessful URL validation + * @param string $location URL to redirect to. + */ + public static function validate_redirects( $location ) { + if ( ! wp_http_validate_url( $location ) ) { + throw new Requests_Exception( __('A valid URL was not provided.'), 'wp_http.redirect_failed_validation' ); + } + } + + /** + * Tests which transports are capable of supporting the request. + * + * @since 3.2.0 + * + * @param array $args Request arguments + * @param string $url URL to Request + * + * @return string|false Class name for the first transport that claims to support the request. False if no transport claims to support the request. + */ + public function _get_first_available_transport( $args, $url = null ) { + $transports = array( 'curl', 'streams' ); + + /** + * Filters which HTTP transports are available and in what order. + * + * @since 3.7.0 + * + * @param array $transports Array of HTTP transports to check. Default array contains + * 'curl', and 'streams', in that order. + * @param array $args HTTP request arguments. + * @param string $url The URL to request. + */ + $request_order = apply_filters( 'http_api_transports', $transports, $args, $url ); + + // Loop over each transport on each HTTP request looking for one which will serve this request's needs. + foreach ( $request_order as $transport ) { + if ( in_array( $transport, $transports ) ) { + $transport = ucfirst( $transport ); + } + $class = 'WP_Http_' . $transport; + + // Check to see if this transport is a possibility, calls the transport statically. + if ( !call_user_func( array( $class, 'test' ), $args, $url ) ) + continue; + + return $class; + } + + return false; + } + + /** + * Dispatches a HTTP request to a supporting transport. + * + * Tests each transport in order to find a transport which matches the request arguments. + * Also caches the transport instance to be used later. + * + * The order for requests is cURL, and then PHP Streams. + * + * @since 3.2.0 + * + * @static + * + * @param string $url URL to Request + * @param array $args Request arguments + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + private function _dispatch_request( $url, $args ) { + static $transports = array(); + + $class = $this->_get_first_available_transport( $args, $url ); + if ( !$class ) + return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) ); + + // Transport claims to support request, instantiate it and give it a whirl. + if ( empty( $transports[$class] ) ) + $transports[$class] = new $class; + + $response = $transports[$class]->request( $url, $args ); + + /** This action is documented in wp-includes/class-http.php */ + do_action( 'http_api_debug', $response, 'response', $class, $args, $url ); + + if ( is_wp_error( $response ) ) + return $response; + + /** + * Filters the HTTP API response immediately before the response is returned. + * + * @since 2.9.0 + * + * @param array $response HTTP response. + * @param array $args HTTP request arguments. + * @param string $url The request URL. + */ + return apply_filters( 'http_response', $response, $args, $url ); + } + + /** + * Uses the POST HTTP method. + * + * Used for sending data that is expected to be in the body. + * + * @since 2.7.0 + * + * @param string $url The request URL. + * @param string|array $args Optional. Override the defaults. + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + public function post($url, $args = array()) { + $defaults = array('method' => 'POST'); + $r = wp_parse_args( $args, $defaults ); + return $this->request($url, $r); + } + + /** + * Uses the GET HTTP method. + * + * Used for sending data that is expected to be in the body. + * + * @since 2.7.0 + * + * @param string $url The request URL. + * @param string|array $args Optional. Override the defaults. + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + public function get($url, $args = array()) { + $defaults = array('method' => 'GET'); + $r = wp_parse_args( $args, $defaults ); + return $this->request($url, $r); + } + + /** + * Uses the HEAD HTTP method. + * + * Used for sending data that is expected to be in the body. + * + * @since 2.7.0 + * + * @param string $url The request URL. + * @param string|array $args Optional. Override the defaults. + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + public function head($url, $args = array()) { + $defaults = array('method' => 'HEAD'); + $r = wp_parse_args( $args, $defaults ); + return $this->request($url, $r); + } + + /** + * Parses the responses and splits the parts into headers and body. + * + * @static + * @since 2.7.0 + * + * @param string $strResponse The full response string + * @return array Array with 'headers' and 'body' keys. + */ + public static function processResponse($strResponse) { + $res = explode("\r\n\r\n", $strResponse, 2); + + return array('headers' => $res[0], 'body' => isset($res[1]) ? $res[1] : ''); + } + + /** + * Transform header string into an array. + * + * If an array is given then it is assumed to be raw header data with numeric keys with the + * headers as the values. No headers must be passed that were already processed. + * + * @static + * @since 2.7.0 + * + * @param string|array $headers + * @param string $url The URL that was requested + * @return array Processed string headers. If duplicate headers are encountered, + * Then a numbered array is returned as the value of that header-key. + */ + public static function processHeaders( $headers, $url = '' ) { + // Split headers, one per array element. + if ( is_string($headers) ) { + // Tolerate line terminator: CRLF = LF (RFC 2616 19.3). + $headers = str_replace("\r\n", "\n", $headers); + /* + * Unfold folded header fields. LWS = [CRLF] 1*( SP | HT ) <US-ASCII SP, space (32)>, + * <US-ASCII HT, horizontal-tab (9)> (RFC 2616 2.2). + */ + $headers = preg_replace('/\n[ \t]/', ' ', $headers); + // Create the headers array. + $headers = explode("\n", $headers); + } + + $response = array('code' => 0, 'message' => ''); + + /* + * If a redirection has taken place, The headers for each page request may have been passed. + * In this case, determine the final HTTP header and parse from there. + */ + for ( $i = count($headers)-1; $i >= 0; $i-- ) { + if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) { + $headers = array_splice($headers, $i); + break; + } + } + + $cookies = array(); + $newheaders = array(); + foreach ( (array) $headers as $tempheader ) { + if ( empty($tempheader) ) + continue; + + if ( false === strpos($tempheader, ':') ) { + $stack = explode(' ', $tempheader, 3); + $stack[] = ''; + list( , $response['code'], $response['message']) = $stack; + continue; + } + + list($key, $value) = explode(':', $tempheader, 2); + + $key = strtolower( $key ); + $value = trim( $value ); + + if ( isset( $newheaders[ $key ] ) ) { + if ( ! is_array( $newheaders[ $key ] ) ) + $newheaders[$key] = array( $newheaders[ $key ] ); + $newheaders[ $key ][] = $value; + } else { + $newheaders[ $key ] = $value; + } + if ( 'set-cookie' == $key ) + $cookies[] = new WP_Http_Cookie( $value, $url ); + } + + // Cast the Response Code to an int + $response['code'] = intval( $response['code'] ); + + return array('response' => $response, 'headers' => $newheaders, 'cookies' => $cookies); + } + + /** + * Takes the arguments for a ::request() and checks for the cookie array. + * + * If it's found, then it upgrades any basic name => value pairs to WP_Http_Cookie instances, + * which are each parsed into strings and added to the Cookie: header (within the arguments array). + * Edits the array by reference. + * + * @since 2.8.0 + * @static + * + * @param array $r Full array of args passed into ::request() + */ + public static function buildCookieHeader( &$r ) { + if ( ! empty($r['cookies']) ) { + // Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances. + foreach ( $r['cookies'] as $name => $value ) { + if ( ! is_object( $value ) ) + $r['cookies'][ $name ] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) ); + } + + $cookies_header = ''; + foreach ( (array) $r['cookies'] as $cookie ) { + $cookies_header .= $cookie->getHeaderValue() . '; '; + } + + $cookies_header = substr( $cookies_header, 0, -2 ); + $r['headers']['cookie'] = $cookies_header; + } + } + + /** + * Decodes chunk transfer-encoding, based off the HTTP 1.1 specification. + * + * Based off the HTTP http_encoding_dechunk function. + * + * @link https://tools.ietf.org/html/rfc2616#section-19.4.6 Process for chunked decoding. + * + * @since 2.7.0 + * @static + * + * @param string $body Body content + * @return string Chunked decoded body on success or raw body on failure. + */ + public static function chunkTransferDecode( $body ) { + // The body is not chunked encoded or is malformed. + if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) ) + return $body; + + $parsed_body = ''; + + // We'll be altering $body, so need a backup in case of error. + $body_original = $body; + + while ( true ) { + $has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match ); + if ( ! $has_chunk || empty( $match[1] ) ) + return $body_original; + + $length = hexdec( $match[1] ); + $chunk_length = strlen( $match[0] ); + + // Parse out the chunk of data. + $parsed_body .= substr( $body, $chunk_length, $length ); + + // Remove the chunk from the raw data. + $body = substr( $body, $length + $chunk_length ); + + // End of the document. + if ( '0' === trim( $body ) ) + return $parsed_body; + } + } + + /** + * Block requests through the proxy. + * + * Those who are behind a proxy and want to prevent access to certain hosts may do so. This will + * prevent plugins from working and core functionality, if you don't include api.wordpress.org. + * + * You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php + * file and this will only allow localhost and your site to make requests. The constant + * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the + * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains + * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. + * + * @since 2.8.0 + * @link https://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. + * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS + * + * @staticvar array|null $accessible_hosts + * @staticvar array $wildcard_regex + * + * @param string $uri URI of url. + * @return bool True to block, false to allow. + */ + public function block_request($uri) { + // We don't need to block requests, because nothing is blocked. + if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL ) + return false; + + $check = parse_url($uri); + if ( ! $check ) + return true; + + $home = parse_url( get_option('siteurl') ); + + // Don't block requests back to ourselves by default. + if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) { + /** + * Filters whether to block local requests through the proxy. + * + * @since 2.8.0 + * + * @param bool $block Whether to block local requests through proxy. + * Default false. + */ + return apply_filters( 'block_local_requests', false ); + } + + if ( !defined('WP_ACCESSIBLE_HOSTS') ) + return true; + + static $accessible_hosts = null; + static $wildcard_regex = array(); + if ( null === $accessible_hosts ) { + $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); + + if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { + $wildcard_regex = array(); + foreach ( $accessible_hosts as $host ) + $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) ); + $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; + } + } + + if ( !empty($wildcard_regex) ) + return !preg_match($wildcard_regex, $check['host']); + else + return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If it's in the array, then we can't access it. + + } + + /** + * Used as a wrapper for PHP's parse_url() function that handles edgecases in < PHP 5.4.7. + * + * @deprecated 4.4.0 Use wp_parse_url() + * @see wp_parse_url() + * + * @param string $url The URL to parse. + * @return bool|array False on failure; Array of URL components on success; + * See parse_url()'s return values. + */ + protected static function parse_url( $url ) { + _deprecated_function( __METHOD__, '4.4.0', 'wp_parse_url()' ); + return wp_parse_url( $url ); + } + + /** + * Converts a relative URL to an absolute URL relative to a given URL. + * + * If an Absolute URL is provided, no processing of that URL is done. + * + * @since 3.4.0 + * + * @static + * + * @param string $maybe_relative_path The URL which might be relative + * @param string $url The URL which $maybe_relative_path is relative to + * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned. + */ + public static function make_absolute_url( $maybe_relative_path, $url ) { + if ( empty( $url ) ) + return $maybe_relative_path; + + if ( ! $url_parts = wp_parse_url( $url ) ) { + return $maybe_relative_path; + } + + if ( ! $relative_url_parts = wp_parse_url( $maybe_relative_path ) ) { + return $maybe_relative_path; + } + + // Check for a scheme on the 'relative' url + if ( ! empty( $relative_url_parts['scheme'] ) ) { + return $maybe_relative_path; + } + + $absolute_path = $url_parts['scheme'] . '://'; + + // Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url + if ( isset( $relative_url_parts['host'] ) ) { + $absolute_path .= $relative_url_parts['host']; + if ( isset( $relative_url_parts['port'] ) ) + $absolute_path .= ':' . $relative_url_parts['port']; + } else { + $absolute_path .= $url_parts['host']; + if ( isset( $url_parts['port'] ) ) + $absolute_path .= ':' . $url_parts['port']; + } + + // Start off with the Absolute URL path. + $path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/'; + + // If it's a root-relative path, then great. + if ( ! empty( $relative_url_parts['path'] ) && '/' == $relative_url_parts['path'][0] ) { + $path = $relative_url_parts['path']; + + // Else it's a relative path. + } elseif ( ! empty( $relative_url_parts['path'] ) ) { + // Strip off any file components from the absolute path. + $path = substr( $path, 0, strrpos( $path, '/' ) + 1 ); + + // Build the new path. + $path .= $relative_url_parts['path']; + + // Strip all /path/../ out of the path. + while ( strpos( $path, '../' ) > 1 ) { + $path = preg_replace( '![^/]+/\.\./!', '', $path ); + } + + // Strip any final leading ../ from the path. + $path = preg_replace( '!^/(\.\./)+!', '', $path ); + } + + // Add the Query string. + if ( ! empty( $relative_url_parts['query'] ) ) + $path .= '?' . $relative_url_parts['query']; + + return $absolute_path . '/' . ltrim( $path, '/' ); + } + + /** + * Handles HTTP Redirects and follows them if appropriate. + * + * @since 3.7.0 + * @static + * + * @param string $url The URL which was requested. + * @param array $args The Arguments which were used to make the request. + * @param array $response The Response of the HTTP request. + * @return false|object False if no redirect is present, a WP_HTTP or WP_Error result otherwise. + */ + public static function handle_redirects( $url, $args, $response ) { + // If no redirects are present, or, redirects were not requested, perform no action. + if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] ) + return false; + + // Only perform redirections on redirection http codes. + if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 ) + return false; + + // Don't redirect if we've run out of redirects. + if ( $args['redirection']-- <= 0 ) + return new WP_Error( 'http_request_failed', __('Too many redirects.') ); + + $redirect_location = $response['headers']['location']; + + // If there were multiple Location headers, use the last header specified. + if ( is_array( $redirect_location ) ) + $redirect_location = array_pop( $redirect_location ); + + $redirect_location = WP_Http::make_absolute_url( $redirect_location, $url ); + + // POST requests should not POST to a redirected location. + if ( 'POST' == $args['method'] ) { + if ( in_array( $response['response']['code'], array( 302, 303 ) ) ) + $args['method'] = 'GET'; + } + + // Include valid cookies in the redirect process. + if ( ! empty( $response['cookies'] ) ) { + foreach ( $response['cookies'] as $cookie ) { + if ( $cookie->test( $redirect_location ) ) + $args['cookies'][] = $cookie; + } + } + + return wp_remote_request( $redirect_location, $args ); + } + + /** + * Determines if a specified string represents an IP address or not. + * + * This function also detects the type of the IP address, returning either + * '4' or '6' to represent a IPv4 and IPv6 address respectively. + * This does not verify if the IP is a valid IP, only that it appears to be + * an IP address. + * + * @link http://home.deds.nl/~aeron/regex/ for IPv6 regex + * + * @since 3.7.0 + * @static + * + * @param string $maybe_ip A suspected IP address + * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure + */ + public static function is_ip_address( $maybe_ip ) { + if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) ) + return 4; + + if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) + return 6; + + return false; + } + +} diff --git a/backend/wp-includes/class-json.php b/backend/wp-includes/class-json.php new file mode 100644 index 0000000..7f34d3f --- /dev/null +++ b/backend/wp-includes/class-json.php @@ -0,0 +1,960 @@ +<?php +if ( ! class_exists( 'Services_JSON' ) ) : +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ +/** + * Converts to and from JSON format. + * + * JSON (JavaScript Object Notation) is a lightweight data-interchange + * format. It is easy for humans to read and write. It is easy for machines + * to parse and generate. It is based on a subset of the JavaScript + * Programming Language, Standard ECMA-262 3rd Edition - December 1999. + * This feature can also be found in Python. JSON is a text format that is + * completely language independent but uses conventions that are familiar + * to programmers of the C-family of languages, including C, C++, C#, Java, + * JavaScript, Perl, TCL, and many others. These properties make JSON an + * ideal data-interchange language. + * + * This package provides a simple encoder and decoder for JSON notation. It + * is intended for use with client-side Javascript applications that make + * use of HTTPRequest to perform server communication functions - data can + * be encoded into JSON notation for use in a client-side javascript, or + * decoded from incoming Javascript requests. JSON format is native to + * Javascript, and can be directly eval()'ed with no further parsing + * overhead + * + * All strings should be in ASCII or UTF-8 format! + * + * LICENSE: Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: Redistributions of source code must retain the + * above copyright notice, this list of conditions and the following + * disclaimer. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * @category + * @package Services_JSON + * @author Michal Migurski <mike-json@teczno.com> + * @author Matt Knapp <mdknapp[at]gmail[dot]com> + * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com> + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php 305040 2010-11-02 23:19:03Z alan_k $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_SLICE', 1); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_STR', 2); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_ARR', 3); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_OBJ', 4); + +/** + * Marker constant for Services_JSON::decode(), used to flag stack state + */ +define('SERVICES_JSON_IN_CMT', 5); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_LOOSE_TYPE', 16); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_SUPPRESS_ERRORS', 32); + +/** + * Behavior switch for Services_JSON::decode() + */ +define('SERVICES_JSON_USE_TO_JSON', 64); + +/** + * Converts to and from JSON format. + * + * Brief example of use: + * + * <code> + * // create a new instance of Services_JSON + * $json = new Services_JSON(); + * + * // convert a complexe value to JSON notation, and send it to the browser + * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); + * $output = $json->encode($value); + * + * print($output); + * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] + * + * // accept incoming POST data, assumed to be in JSON notation + * $input = file_get_contents('php://input', 1000000); + * $value = $json->decode($input); + * </code> + */ +class Services_JSON +{ + /** + * constructs a new JSON instance + * + * @param int $use object behavior flags; combine with boolean-OR + * + * possible values: + * - SERVICES_JSON_LOOSE_TYPE: loose typing. + * "{...}" syntax creates associative arrays + * instead of objects in decode(). + * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. + * Values which can't be encoded (e.g. resources) + * appear as NULL instead of throwing errors. + * By default, a deeply-nested resource will + * bubble up with an error, so all return values + * from encode() should be checked with isError() + * - SERVICES_JSON_USE_TO_JSON: call toJSON when serializing objects + * It serializes the return value from the toJSON call rather + * than the object itself, toJSON can return associative arrays, + * strings or numbers, if you return an object, make sure it does + * not have a toJSON method, otherwise an error will occur. + */ + function __construct( $use = 0 ) + { + $this->use = $use; + $this->_mb_strlen = function_exists('mb_strlen'); + $this->_mb_convert_encoding = function_exists('mb_convert_encoding'); + $this->_mb_substr = function_exists('mb_substr'); + } + + /** + * PHP4 constructor. + */ + public function Services_JSON( $use = 0 ) { + self::__construct( $use ); + } + // private - cache the mbstring lookup results.. + var $_mb_strlen = false; + var $_mb_substr = false; + var $_mb_convert_encoding = false; + + /** + * convert a string from one UTF-16 char to one UTF-8 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf16 UTF-16 character + * @return string UTF-8 character + * @access private + */ + function utf162utf8($utf16) + { + // oh please oh please oh please oh please oh please + if($this->_mb_convert_encoding) { + return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); + } + + $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); + + switch(true) { + case ((0x7F & $bytes) == $bytes): + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x7F & $bytes); + + case (0x07FF & $bytes) == $bytes: + // return a 2-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xC0 | (($bytes >> 6) & 0x1F)) + . chr(0x80 | ($bytes & 0x3F)); + + case (0xFFFF & $bytes) == $bytes: + // return a 3-byte UTF-8 character + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0xE0 | (($bytes >> 12) & 0x0F)) + . chr(0x80 | (($bytes >> 6) & 0x3F)) + . chr(0x80 | ($bytes & 0x3F)); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + function utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if($this->_mb_convert_encoding) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch($this->strlen8($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format (and sends JSON Header) + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function encode($var) + { + header('Content-type: application/json'); + return $this->encodeUnsafe($var); + } + /** + * encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!) + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function encodeUnsafe($var) + { + // see bug #16908 - regarding numeric locale printing + $lc = setlocale(LC_NUMERIC, 0); + setlocale(LC_NUMERIC, 'C'); + $ret = $this->_encode($var); + setlocale(LC_NUMERIC, $lc); + return $ret; + + } + /** + * PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + function _encode($var) + { + + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = $this->strlen8($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\'.$var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + if ($c+1 >= $strlen_var) { + $c += 1; + $ascii .= '?'; + break; + } + + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + if ($c+2 >= $strlen_var) { + $c += 2; + $ascii .= '?'; + break; + } + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + @ord($var{$c + 1}), + @ord($var{$c + 2})); + $c += 2; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + if ($c+3 >= $strlen_var) { + $c += 3; + $ascii .= '?'; + break; + } + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + if ($c+4 >= $strlen_var) { + $c += 4; + $ascii .= '?'; + break; + } + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + if ($c+5 >= $strlen_var) { + $c += 5; + $ascii .= '?'; + break; + } + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + return '"'.$ascii.'"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + $properties = array_map(array($this, 'name_value'), + array_keys($var), + array_values($var)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + } + + // treat it like a regular array + $elements = array_map(array($this, '_encode'), $var); + + foreach($elements as $element) { + if(Services_JSON::isError($element)) { + return $element; + } + } + + return '[' . join(',', $elements) . ']'; + + case 'object': + + // support toJSON methods. + if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) { + // this may end up allowing unlimited recursion + // so we check the return value to make sure it's not got the same method. + $recode = $var->toJSON(); + + if (method_exists($recode, 'toJSON')) { + + return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) + ? 'null' + : new Services_JSON_Error(get_class($var). + " toJSON returned an object with a toJSON method."); + + } + + return $this->_encode( $recode ); + } + + $vars = get_object_vars($var); + + $properties = array_map(array($this, 'name_value'), + array_keys($vars), + array_values($vars)); + + foreach($properties as $property) { + if(Services_JSON::isError($property)) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + + default: + return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) + ? 'null' + : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + function name_value($name, $value) + { + $encoded_value = $this->_encode($value); + + if(Services_JSON::isError($encoded_value)) { + return $encoded_value; + } + + return $this->_encode(strval($name)) . ':' . $encoded_value; + } + + /** + * reduce a string by removing leading and trailing comments and whitespace + * + * @param $str string string value to strip of comments and whitespace + * + * @return string string value stripped of comments and whitespace + * @access private + */ + function reduce_string($str) + { + $str = preg_replace(array( + + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', + + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', + + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' + + ), '', $str); + + // eliminate extraneous space + return trim($str); + } + + /** + * decodes a JSON string into appropriate variable + * + * @param string $str JSON-formatted string + * + * @return mixed number, boolean, string, array, or object + * corresponding to given JSON input string. + * See argument 1 to Services_JSON() above for object-output behavior. + * Note that decode() always returns strings + * in ASCII or UTF-8 format! + * @access public + */ + function decode($str) + { + $str = $this->reduce_string($str); + + switch (strtolower($str)) { + case 'true': + return true; + + case 'false': + return false; + + case 'null': + return null; + + default: + $m = array(); + + if (is_numeric($str)) { + // Lookie-loo, it's a number + + // This would work on its own, but I'm trying to be + // good about returning integers where appropriate: + // return (float)$str; + + // Return float or int, as appropriate + return ((float)$str == (integer)$str) + ? (integer)$str + : (float)$str; + + } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { + // STRINGS RETURNED IN UTF-8 FORMAT + $delim = $this->substr8($str, 0, 1); + $chrs = $this->substr8($str, 1, -1); + $utf8 = ''; + $strlen_chrs = $this->strlen8($chrs); + + for ($c = 0; $c < $strlen_chrs; ++$c) { + + $substr_chrs_c_2 = $this->substr8($chrs, $c, 2); + $ord_chrs_c = ord($chrs{$c}); + + switch (true) { + case $substr_chrs_c_2 == '\b': + $utf8 .= chr(0x08); + ++$c; + break; + case $substr_chrs_c_2 == '\t': + $utf8 .= chr(0x09); + ++$c; + break; + case $substr_chrs_c_2 == '\n': + $utf8 .= chr(0x0A); + ++$c; + break; + case $substr_chrs_c_2 == '\f': + $utf8 .= chr(0x0C); + ++$c; + break; + case $substr_chrs_c_2 == '\r': + $utf8 .= chr(0x0D); + ++$c; + break; + + case $substr_chrs_c_2 == '\\"': + case $substr_chrs_c_2 == '\\\'': + case $substr_chrs_c_2 == '\\\\': + case $substr_chrs_c_2 == '\\/': + if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || + ($delim == "'" && $substr_chrs_c_2 != '\\"')) { + $utf8 .= $chrs{++$c}; + } + break; + + case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)): + // single, escaped unicode character + $utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2))) + . chr(hexdec($this->substr8($chrs, ($c + 4), 2))); + $utf8 .= $this->utf162utf8($utf16); + $c += 5; + break; + + case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): + $utf8 .= $chrs{$c}; + break; + + case ($ord_chrs_c & 0xE0) == 0xC0: + // characters U-00000080 - U-000007FF, mask 110XXXXX + //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 2); + ++$c; + break; + + case ($ord_chrs_c & 0xF0) == 0xE0: + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 3); + $c += 2; + break; + + case ($ord_chrs_c & 0xF8) == 0xF0: + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 4); + $c += 3; + break; + + case ($ord_chrs_c & 0xFC) == 0xF8: + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 5); + $c += 4; + break; + + case ($ord_chrs_c & 0xFE) == 0xFC: + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $utf8 .= $this->substr8($chrs, $c, 6); + $c += 5; + break; + + } + + } + + return $utf8; + + } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { + // array, or object notation + + if ($str{0} == '[') { + $stk = array(SERVICES_JSON_IN_ARR); + $arr = array(); + } else { + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = array(); + } else { + $stk = array(SERVICES_JSON_IN_OBJ); + $obj = new stdClass(); + } + } + + array_push($stk, array('what' => SERVICES_JSON_SLICE, + 'where' => 0, + 'delim' => false)); + + $chrs = $this->substr8($str, 1, -1); + $chrs = $this->reduce_string($chrs); + + if ($chrs == '') { + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } else { + return $obj; + + } + } + + //print("\nparsing {$chrs}\n"); + + $strlen_chrs = $this->strlen8($chrs); + + for ($c = 0; $c <= $strlen_chrs; ++$c) { + + $top = end($stk); + $substr_chrs_c_2 = $this->substr8($chrs, $c, 2); + + if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { + // found a comma that is not inside a string, array, etc., + // OR we've reached the end of the character list + $slice = $this->substr8($chrs, $top['where'], ($c - $top['where'])); + array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); + //print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + // we are in an array, so just push an element onto the stack + array_push($arr, $this->decode($slice)); + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + // we are in an object, so figure + // out the property name and set an + // element in an associative array, + // for now + $parts = array(); + + if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) { + // "name":value pair + $key = $this->decode($parts[1]); + $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B")); + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) { + // name:value pair, where name is unquoted + $key = $parts[1]; + $val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B")); + + if ($this->use & SERVICES_JSON_LOOSE_TYPE) { + $obj[$key] = $val; + } else { + $obj->$key = $val; + } + } + + } + + } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { + // found a quote, and we are not inside a string + array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); + //print("Found start of string at {$c}\n"); + + } elseif (($chrs{$c} == $top['delim']) && + ($top['what'] == SERVICES_JSON_IN_STR) && + (($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) { + // found a quote, we're in a string, and it's not escaped + // we know that it's not escaped becase there is _not_ an + // odd number of backslashes at the end of the string so far + array_pop($stk); + //print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '[') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-bracket, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); + //print("Found start of array at {$c}\n"); + + } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { + // found a right-bracket, and we're in an array + array_pop($stk); + //print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($chrs{$c} == '{') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a left-brace, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); + //print("Found start of object at {$c}\n"); + + } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { + // found a right-brace, and we're in an object + array_pop($stk); + //print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } elseif (($substr_chrs_c_2 == '/*') && + in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { + // found a comment start, and we are in an array, object, or slice + array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); + $c++; + //print("Found start of comment at {$c}\n"); + + } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { + // found a comment end, and we're in one now + array_pop($stk); + $c++; + + for ($i = $top['where']; $i <= $c; ++$i) + $chrs = substr_replace($chrs, ' ', $i, 1); + + //print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n"); + + } + + } + + if (reset($stk) == SERVICES_JSON_IN_ARR) { + return $arr; + + } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { + return $obj; + + } + + } + } + } + + /** + * @todo Ultimately, this should just call PEAR::isError() + */ + function isError($data, $code = null) + { + if (class_exists('pear')) { + return PEAR::isError($data, $code); + } elseif (is_object($data) && (get_class($data) == 'services_json_error' || + is_subclass_of($data, 'services_json_error'))) { + return true; + } + + return false; + } + + /** + * Calculates length of string in bytes + * @param string + * @return integer length + */ + function strlen8( $str ) + { + if ( $this->_mb_strlen ) { + return mb_strlen( $str, "8bit" ); + } + return strlen( $str ); + } + + /** + * Returns part of a string, interpreting $start and $length as number of bytes. + * @param string + * @param integer start + * @param integer length + * @return integer length + */ + function substr8( $string, $start, $length=false ) + { + if ( $length === false ) { + $length = $this->strlen8( $string ) - $start; + } + if ( $this->_mb_substr ) { + return mb_substr( $string, $start, $length, "8bit" ); + } + return substr( $string, $start, $length ); + } + +} + +if (class_exists('PEAR_Error')) { + + class Services_JSON_Error extends PEAR_Error + { + function __construct($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + parent::PEAR_Error($message, $code, $mode, $options, $userinfo); + } + + public function Services_JSON_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) { + self::__construct($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null); + } + } + +} else { + + /** + * @todo Ultimately, this class shall be descended from PEAR_Error + */ + class Services_JSON_Error + { + /** + * PHP5 constructor. + */ + function __construct( $message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null ) + { + + } + + /** + * PHP4 constructor. + */ + public function Services_JSON_Error( $message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null ) { + self::__construct( $message, $code, $mode, $options, $userinfo ); + } + } + +} + +endif; diff --git a/backend/wp-includes/class-oembed.php b/backend/wp-includes/class-oembed.php new file mode 100644 index 0000000..359171e --- /dev/null +++ b/backend/wp-includes/class-oembed.php @@ -0,0 +1,728 @@ +<?php +/** + * API for fetching the HTML to embed remote content based on a provided URL + * + * Used internally by the WP_Embed class, but is designed to be generic. + * + * @link https://codex.wordpress.org/oEmbed oEmbed Codex Article + * @link http://oembed.com/ oEmbed Homepage + * + * @package WordPress + * @subpackage oEmbed + */ + +/** + * Core class used to implement oEmbed functionality. + * + * @since 2.9.0 + */ +class WP_oEmbed { + + /** + * A list of oEmbed providers. + * + * @since 2.9.0 + * @var array + */ + public $providers = array(); + + /** + * A list of an early oEmbed providers. + * + * @since 4.0.0 + * @static + * @var array + */ + public static $early_providers = array(); + + /** + * A list of private/protected methods, used for backward compatibility. + * + * @since 4.2.0 + * @var array + */ + private $compat_methods = array( '_fetch_with_format', '_parse_json', '_parse_xml', '_parse_xml_body' ); + + /** + * Constructor. + * + * @since 2.9.0 + */ + public function __construct() { + $host = urlencode( home_url() ); + $providers = array( + '#https?://((m|www)\.)?youtube\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ), + '#https?://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'https://www.youtube.com/oembed', true ), + '#https?://youtu\.be/.*#i' => array( 'https://www.youtube.com/oembed', true ), + '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'https://vimeo.com/api/oembed.{format}', true ), + '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), + '#https?://dai\.ly/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), + '#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), + '#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ), + '#https?://(.+\.)?smugmug\.com/.*#i' => array( 'https://api.smugmug.com/services/oembed/', true ), + '#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ), + 'http://i*.photobucket.com/albums/*' => array( 'http://api.photobucket.com/oembed', false ), + 'http://gi*.photobucket.com/groups/*' => array( 'http://api.photobucket.com/oembed', false ), + '#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'https://www.scribd.com/services/oembed', true ), + '#https?://wordpress\.tv/.*#i' => array( 'https://wordpress.tv/oembed/', true ), + '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ), + '#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ), + '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ), + '#https?://(www\.)?twitter\.com/\w{1,15}/status(es)?/.*#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?twitter\.com/\w{1,15}$#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?twitter\.com/\w{1,15}/likes$#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?twitter\.com/\w{1,15}/lists/.*#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?twitter\.com/\w{1,15}/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ), + '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ), + '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), + '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => array( 'https://api.instagram.com/oembed', true ), + '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), + '#https?://(.+\.)?imgur\.com/.*#i' => array( 'https://api.imgur.com/oembed', true ), + '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'https://api.meetup.com/oembed', true ), + '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'https://issuu.com/oembed_wp', true ), + '#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'https://www.collegehumor.com/oembed.{format}', true ), + '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'https://www.mixcloud.com/oembed', true ), + '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'https://www.ted.com/services/v1/oembed.{format}', true ), + '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'https://animoto.com/oembeds/create', true ), + '#https?://(.+)\.tumblr\.com/post/.*#i' => array( 'https://www.tumblr.com/oembed/1.0', true ), + '#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), + '#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ), + '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), + '#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ), + '#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/?for=' . $host, true ), + '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ), + '#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ), + '#https?://www\.facebook\.com/.*/posts/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/.*/activity/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/.*/photos/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/photo(s/|\.php).*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/permalink\.php.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/media/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/questions/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/notes/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), + '#https?://www\.facebook\.com/.*/videos/.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), + '#https?://www\.facebook\.com/video\.php.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), + '#https?://(www\.)?screencast\.com/.*#i' => array( 'https://api.screencast.com/external/oembed', true ), + '#https?://([a-z0-9-]+\.)?amazon\.(com|com\.mx|com\.br|ca)/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), + '#https?://([a-z0-9-]+\.)?amazon\.(co\.uk|de|fr|it|es|in|nl|ru)/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), + '#https?://([a-z0-9-]+\.)?amazon\.(co\.jp|com\.au)/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), + '#https?://([a-z0-9-]+\.)?amazon\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), + '#https?://(www\.)?a\.co/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), + '#https?://(www\.)?amzn\.to/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), + '#https?://(www\.)?amzn\.eu/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), + '#https?://(www\.)?amzn\.in/.*#i' => array( 'https://read.amazon.in/kp/api/oembed', true ), + '#https?://(www\.)?amzn\.asia/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), + '#https?://(www\.)?z\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), + '#https?://www\.someecards\.com/.+-cards/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), + '#https?://www\.someecards\.com/usercards/viewcard/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), + '#https?://some\.ly\/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ), + ); + + if ( ! empty( self::$early_providers['add'] ) ) { + foreach ( self::$early_providers['add'] as $format => $data ) { + $providers[ $format ] = $data; + } + } + + if ( ! empty( self::$early_providers['remove'] ) ) { + foreach ( self::$early_providers['remove'] as $format ) { + unset( $providers[ $format ] ); + } + } + + self::$early_providers = array(); + + /** + * Filters the list of whitelisted oEmbed providers. + * + * Since WordPress 4.4, oEmbed discovery is enabled for all users and allows embedding of sanitized + * iframes. The providers in this list are whitelisted, meaning they are trusted and allowed to + * embed any content, such as iframes, videos, JavaScript, and arbitrary HTML. + * + * Supported providers: + * + * | Provider | Flavor | Supports HTTPS | Since | + * | ------------ | --------------------------------- | :------------: | ------- | + * | Dailymotion | dailymotion.com | Yes | 2.9.0 | + * | Flickr | flickr.com | Yes | 2.9.0 | + * | Hulu | hulu.com | Yes | 2.9.0 | + * | Photobucket | photobucket.com | No | 2.9.0 | + * | Scribd | scribd.com | Yes | 2.9.0 | + * | Vimeo | vimeo.com | Yes | 2.9.0 | + * | WordPress.tv | wordpress.tv | Yes | 2.9.0 | + * | YouTube | youtube.com/watch | Yes | 2.9.0 | + * | Funny or Die | funnyordie.com | Yes | 3.0.0 | + * | Polldaddy | polldaddy.com | Yes | 3.0.0 | + * | SmugMug | smugmug.com | Yes | 3.0.0 | + * | YouTube | youtu.be | Yes | 3.0.0 | + * | Twitter | twitter.com | Yes | 3.4.0 | + * | Instagram | instagram.com | Yes | 3.5.0 | + * | Instagram | instagr.am | Yes | 3.5.0 | + * | Slideshare | slideshare.net | Yes | 3.5.0 | + * | SoundCloud | soundcloud.com | Yes | 3.5.0 | + * | Dailymotion | dai.ly | Yes | 3.6.0 | + * | Flickr | flic.kr | Yes | 3.6.0 | + * | Spotify | spotify.com | Yes | 3.6.0 | + * | Imgur | imgur.com | Yes | 3.9.0 | + * | Meetup.com | meetup.com | Yes | 3.9.0 | + * | Meetup.com | meetu.ps | Yes | 3.9.0 | + * | Animoto | animoto.com | Yes | 4.0.0 | + * | Animoto | video214.com | Yes | 4.0.0 | + * | CollegeHumor | collegehumor.com | Yes | 4.0.0 | + * | Issuu | issuu.com | Yes | 4.0.0 | + * | Mixcloud | mixcloud.com | Yes | 4.0.0 | + * | Polldaddy | poll.fm | Yes | 4.0.0 | + * | TED | ted.com | Yes | 4.0.0 | + * | YouTube | youtube.com/playlist | Yes | 4.0.0 | + * | Tumblr | tumblr.com | Yes | 4.2.0 | + * | Kickstarter | kickstarter.com | Yes | 4.2.0 | + * | Kickstarter | kck.st | Yes | 4.2.0 | + * | Cloudup | cloudup.com | Yes | 4.3.0 | + * | ReverbNation | reverbnation.com | Yes | 4.4.0 | + * | VideoPress | videopress.com | Yes | 4.4.0 | + * | Reddit | reddit.com | Yes | 4.4.0 | + * | Speaker Deck | speakerdeck.com | Yes | 4.4.0 | + * | Twitter | twitter.com/timelines | Yes | 4.5.0 | + * | Twitter | twitter.com/moments | Yes | 4.5.0 | + * | Facebook | facebook.com | Yes | 4.7.0 | + * | Twitter | twitter.com/user | Yes | 4.7.0 | + * | Twitter | twitter.com/likes | Yes | 4.7.0 | + * | Twitter | twitter.com/lists | Yes | 4.7.0 | + * | Screencast | screencast.com | Yes | 4.8.0 | + * | Amazon | amazon.com|com.mx|com.br|ca | Yes | 4.9.0 | + * | Amazon | amazon.de|fr|it|es|in|nl|ru|co.uk | Yes | 4.9.0 | + * | Amazon | amazon.co.jp|com.au | Yes | 4.9.0 | + * | Amazon | amazon.cn | Yes | 4.9.0 | + * | Amazon | a.co | Yes | 4.9.0 | + * | Amazon | amzn.to|eu|in|asia | Yes | 4.9.0 | + * | Amazon | z.cn | Yes | 4.9.0 | + * | Someecards | someecards.com | Yes | 4.9.0 | + * | Someecards | some.ly | Yes | 4.9.0 | + * + * No longer supported providers: + * + * | Provider | Flavor | Supports HTTPS | Since | Removed | + * | ------------ | -------------------- | :------------: | --------- | --------- | + * | Qik | qik.com | Yes | 2.9.0 | 3.9.0 | + * | Viddler | viddler.com | Yes | 2.9.0 | 4.0.0 | + * | Revision3 | revision3.com | No | 2.9.0 | 4.2.0 | + * | Blip | blip.tv | No | 2.9.0 | 4.4.0 | + * | Rdio | rdio.com | Yes | 3.6.0 | 4.4.1 | + * | Rdio | rd.io | Yes | 3.6.0 | 4.4.1 | + * | Vine | vine.co | Yes | 4.1.0 | 4.9.0 | + * + * @see wp_oembed_add_provider() + * + * @since 2.9.0 + * + * @param array $providers An array of popular oEmbed providers. + */ + $this->providers = apply_filters( 'oembed_providers', $providers ); + + // Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop(). + add_filter( 'oembed_dataparse', array($this, '_strip_newlines'), 10, 3 ); + } + + /** + * Exposes private/protected methods for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|bool Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( in_array( $name, $this->compat_methods ) ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Takes a URL and returns the corresponding oEmbed provider's URL, if there is one. + * + * @since 4.0.0 + * + * @see WP_oEmbed::discover() + * + * @param string $url The URL to the content. + * @param string|array $args Optional provider arguments. + * @return false|string False on failure, otherwise the oEmbed provider URL. + */ + public function get_provider( $url, $args = '' ) { + $args = wp_parse_args( $args ); + + $provider = false; + + if ( !isset($args['discover']) ) + $args['discover'] = true; + + foreach ( $this->providers as $matchmask => $data ) { + list( $providerurl, $regex ) = $data; + + // Turn the asterisk-type provider URLs into regex + if ( !$regex ) { + $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i'; + $matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask ); + } + + if ( preg_match( $matchmask, $url ) ) { + $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML + break; + } + } + + if ( !$provider && $args['discover'] ) + $provider = $this->discover( $url ); + + return $provider; + } + + /** + * Adds an oEmbed provider. + * + * The provider is added just-in-time when wp_oembed_add_provider() is called before + * the {@see 'plugins_loaded'} hook. + * + * The just-in-time addition is for the benefit of the {@see 'oembed_providers'} filter. + * + * @static + * @since 4.0.0 + * + * @see wp_oembed_add_provider() + * + * @param string $format Format of URL that this provider can handle. You can use + * asterisks as wildcards. + * @param string $provider The URL to the oEmbed provider.. + * @param bool $regex Optional. Whether the $format parameter is in a regex format. + * Default false. + */ + public static function _add_provider_early( $format, $provider, $regex = false ) { + if ( empty( self::$early_providers['add'] ) ) { + self::$early_providers['add'] = array(); + } + + self::$early_providers['add'][ $format ] = array( $provider, $regex ); + } + + /** + * Removes an oEmbed provider. + * + * The provider is removed just-in-time when wp_oembed_remove_provider() is called before + * the {@see 'plugins_loaded'} hook. + * + * The just-in-time removal is for the benefit of the {@see 'oembed_providers'} filter. + * + * @since 4.0.0 + * @static + * + * @see wp_oembed_remove_provider() + * + * @param string $format The format of URL that this provider can handle. You can use + * asterisks as wildcards. + */ + public static function _remove_provider_early( $format ) { + if ( empty( self::$early_providers['remove'] ) ) { + self::$early_providers['remove'] = array(); + } + + self::$early_providers['remove'][] = $format; + } + + /** + * Takes a URL and attempts to return the oEmbed data. + * + * @see WP_oEmbed::fetch() + * + * @since 4.8.0 + * + * @param string $url The URL to the content that should be attempted to be embedded. + * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. + * @return false|object False on failure, otherwise the result in the form of an object. + */ + public function get_data( $url, $args = '' ) { + $args = wp_parse_args( $args ); + + $provider = $this->get_provider( $url, $args ); + + if ( ! $provider ) { + return false; + } + + $data = $this->fetch( $provider, $url, $args ); + + if ( false === $data ) { + return false; + } + + return $data; + } + + /** + * The do-it-all function that takes a URL and attempts to return the HTML. + * + * @see WP_oEmbed::fetch() + * @see WP_oEmbed::data2html() + * + * @since 2.9.0 + * + * @param string $url The URL to the content that should be attempted to be embedded. + * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. + * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed. + */ + public function get_html( $url, $args = '' ) { + /** + * Filters the oEmbed result before any HTTP requests are made. + * + * This allows one to short-circuit the default logic, perhaps by + * replacing it with a routine that is more optimal for your setup. + * + * Passing a non-null value to the filter will effectively short-circuit retrieval, + * returning the passed value instead. + * + * @since 4.5.3 + * + * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. + * @param string $url The URL to the content that should be attempted to be embedded. + * @param array $args Optional. Arguments, usually passed from a shortcode. Default empty. + */ + $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); + + if ( null !== $pre ) { + return $pre; + } + + $data = $this->get_data( $url, $args ); + + if ( false === $data ) { + return false; + } + + /** + * Filters the HTML returned by the oEmbed provider. + * + * @since 2.9.0 + * + * @param string $data The returned oEmbed HTML. + * @param string $url URL of the content to be embedded. + * @param array $args Optional arguments, usually passed from a shortcode. + */ + return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); + } + + /** + * Attempts to discover link tags at the given URL for an oEmbed provider. + * + * @since 2.9.0 + * + * @param string $url The URL that should be inspected for discovery `<link>` tags. + * @return false|string False on failure, otherwise the oEmbed provider URL. + */ + public function discover( $url ) { + $providers = array(); + $args = array( + 'limit_response_size' => 153600, // 150 KB + ); + + /** + * Filters oEmbed remote get arguments. + * + * @since 4.0.0 + * + * @see WP_Http::request() + * + * @param array $args oEmbed remote get arguments. + * @param string $url URL to be inspected. + */ + $args = apply_filters( 'oembed_remote_get_args', $args, $url ); + + // Fetch URL content + $request = wp_safe_remote_get( $url, $args ); + if ( $html = wp_remote_retrieve_body( $request ) ) { + + /** + * Filters the link types that contain oEmbed provider URLs. + * + * @since 2.9.0 + * + * @param array $format Array of oEmbed link types. Accepts 'application/json+oembed', + * 'text/xml+oembed', and 'application/xml+oembed' (incorrect, + * used by at least Vimeo). + */ + $linktypes = apply_filters( 'oembed_linktypes', array( + 'application/json+oembed' => 'json', + 'text/xml+oembed' => 'xml', + 'application/xml+oembed' => 'xml', + ) ); + + // Strip <body> + if ( $html_head_end = stripos( $html, '</head>' ) ) { + $html = substr( $html, 0, $html_head_end ); + } + + // Do a quick check + $tagfound = false; + foreach ( $linktypes as $linktype => $format ) { + if ( stripos($html, $linktype) ) { + $tagfound = true; + break; + } + } + + if ( $tagfound && preg_match_all( '#<link([^<>]+)/?>#iU', $html, $links ) ) { + foreach ( $links[1] as $link ) { + $atts = shortcode_parse_atts( $link ); + + if ( !empty($atts['type']) && !empty($linktypes[$atts['type']]) && !empty($atts['href']) ) { + $providers[$linktypes[$atts['type']]] = htmlspecialchars_decode( $atts['href'] ); + + // Stop here if it's JSON (that's all we need) + if ( 'json' == $linktypes[$atts['type']] ) + break; + } + } + } + } + + // JSON is preferred to XML + if ( !empty($providers['json']) ) + return $providers['json']; + elseif ( !empty($providers['xml']) ) + return $providers['xml']; + else + return false; + } + + /** + * Connects to a oEmbed provider and returns the result. + * + * @since 2.9.0 + * + * @param string $provider The URL to the oEmbed provider. + * @param string $url The URL to the content that is desired to be embedded. + * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. + * @return false|object False on failure, otherwise the result in the form of an object. + */ + public function fetch( $provider, $url, $args = '' ) { + $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); + + $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider ); + $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); + $provider = add_query_arg( 'url', urlencode($url), $provider ); + $provider = add_query_arg( 'dnt', 1, $provider ); + + /** + * Filters the oEmbed URL to be fetched. + * + * @since 2.9.0 + * @since 4.9.0 The `dnt` (Do Not Track) query parameter was added to all oEmbed provider URLs. + * + * @param string $provider URL of the oEmbed provider. + * @param string $url URL of the content to be embedded. + * @param array $args Optional arguments, usually passed from a shortcode. + */ + $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); + + foreach ( array( 'json', 'xml' ) as $format ) { + $result = $this->_fetch_with_format( $provider, $format ); + if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() ) + continue; + return ( $result && ! is_wp_error( $result ) ) ? $result : false; + } + return false; + } + + /** + * Fetches result from an oEmbed provider for a specific format and complete provider URL + * + * @since 3.0.0 + * + * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.) + * @param string $format Format to use + * @return false|object|WP_Error False on failure, otherwise the result in the form of an object. + */ + private function _fetch_with_format( $provider_url_with_args, $format ) { + $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args ); + + /** This filter is documented in wp-includes/class-oembed.php */ + $args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args ); + + $response = wp_safe_remote_get( $provider_url_with_args, $args ); + if ( 501 == wp_remote_retrieve_response_code( $response ) ) + return new WP_Error( 'not-implemented' ); + if ( ! $body = wp_remote_retrieve_body( $response ) ) + return false; + $parse_method = "_parse_$format"; + return $this->$parse_method( $body ); + } + + /** + * Parses a json response body. + * + * @since 3.0.0 + * + * @param string $response_body + * @return object|false + */ + private function _parse_json( $response_body ) { + $data = json_decode( trim( $response_body ) ); + return ( $data && is_object( $data ) ) ? $data : false; + } + + /** + * Parses an XML response body. + * + * @since 3.0.0 + * + * @param string $response_body + * @return object|false + */ + private function _parse_xml( $response_body ) { + if ( ! function_exists( 'libxml_disable_entity_loader' ) ) + return false; + + $loader = libxml_disable_entity_loader( true ); + $errors = libxml_use_internal_errors( true ); + + $return = $this->_parse_xml_body( $response_body ); + + libxml_use_internal_errors( $errors ); + libxml_disable_entity_loader( $loader ); + + return $return; + } + + /** + * Serves as a helper function for parsing an XML response body. + * + * @since 3.6.0 + * + * @param string $response_body + * @return stdClass|false + */ + private function _parse_xml_body( $response_body ) { + if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) ) + return false; + + $dom = new DOMDocument; + $success = $dom->loadXML( $response_body ); + if ( ! $success ) + return false; + + if ( isset( $dom->doctype ) ) + return false; + + foreach ( $dom->childNodes as $child ) { + if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType ) + return false; + } + + $xml = simplexml_import_dom( $dom ); + if ( ! $xml ) + return false; + + $return = new stdClass; + foreach ( $xml as $key => $value ) { + $return->$key = (string) $value; + } + + return $return; + } + + /** + * Converts a data object from WP_oEmbed::fetch() and returns the HTML. + * + * @since 2.9.0 + * + * @param object $data A data object result from an oEmbed provider. + * @param string $url The URL to the content that is desired to be embedded. + * @return false|string False on error, otherwise the HTML needed to embed. + */ + public function data2html( $data, $url ) { + if ( ! is_object( $data ) || empty( $data->type ) ) + return false; + + $return = false; + + switch ( $data->type ) { + case 'photo': + if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) ) + break; + if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) ) + break; + + $title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : ''; + $return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>'; + break; + + case 'video': + case 'rich': + if ( ! empty( $data->html ) && is_string( $data->html ) ) + $return = $data->html; + break; + + case 'link': + if ( ! empty( $data->title ) && is_string( $data->title ) ) + $return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>'; + break; + + default: + $return = false; + } + + /** + * Filters the returned oEmbed HTML. + * + * Use this filter to add support for custom data types, or to filter the result. + * + * @since 2.9.0 + * + * @param string $return The returned oEmbed HTML. + * @param object $data A data object result from an oEmbed provider. + * @param string $url The URL of the content to be embedded. + */ + return apply_filters( 'oembed_dataparse', $return, $data, $url ); + } + + /** + * Strips any new lines from the HTML. + * + * @since 2.9.0 as strip_scribd_newlines() + * @since 3.0.0 + * + * @param string $html Existing HTML. + * @param object $data Data object from WP_oEmbed::data2html() + * @param string $url The original URL passed to oEmbed. + * @return string Possibly modified $html + */ + public function _strip_newlines( $html, $data, $url ) { + if ( false === strpos( $html, "\n" ) ) { + return $html; + } + + $count = 1; + $found = array(); + $token = '__PRE__'; + $search = array( "\t", "\n", "\r", ' ' ); + $replace = array( '__TAB__', '__NL__', '__CR__', '__SPACE__' ); + $tokenized = str_replace( $search, $replace, $html ); + + preg_match_all( '#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER ); + foreach ( $matches as $i => $match ) { + $tag_html = str_replace( $replace, $search, $match[0] ); + $tag_token = $token . $i; + + $found[ $tag_token ] = $tag_html; + $html = str_replace( $tag_html, $tag_token, $html, $count ); + } + + $replaced = str_replace( $replace, $search, $html ); + $stripped = str_replace( array( "\r\n", "\n" ), '', $replaced ); + $pre = array_values( $found ); + $tokens = array_keys( $found ); + + return str_replace( $tokens, $pre, $stripped ); + } +} diff --git a/backend/wp-includes/class-phpass.php b/backend/wp-includes/class-phpass.php new file mode 100644 index 0000000..8b8b113 --- /dev/null +++ b/backend/wp-includes/class-phpass.php @@ -0,0 +1,276 @@ +<?php +/** + * Portable PHP password hashing framework. + * @package phpass + * @since 2.5.0 + * @version 0.3 / WordPress + * @link http://www.openwall.com/phpass/ + */ + +# +# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in +# the public domain. Revised in subsequent years, still public domain. +# +# There's absolutely no warranty. +# +# Please be sure to update the Version line if you edit this file in any way. +# It is suggested that you leave the main version number intact, but indicate +# your project name (after the slash) and add your own revision information. +# +# Please do not change the "private" password hashing method implemented in +# here, thereby making your hashes incompatible. However, if you must, please +# change the hash type identifier (the "$P$") to something different. +# +# Obviously, since this code is in the public domain, the above are not +# requirements (there can be none), but merely suggestions. +# + +/** + * Portable PHP password hashing framework. + * + * @package phpass + * @version 0.3 / WordPress + * @link http://www.openwall.com/phpass/ + * @since 2.5.0 + */ +class PasswordHash { + var $itoa64; + var $iteration_count_log2; + var $portable_hashes; + var $random_state; + + /** + * PHP5 constructor. + */ + function __construct( $iteration_count_log2, $portable_hashes ) + { + $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + + if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) + $iteration_count_log2 = 8; + $this->iteration_count_log2 = $iteration_count_log2; + + $this->portable_hashes = $portable_hashes; + + $this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compatibility reasons + } + + /** + * PHP4 constructor. + */ + public function PasswordHash( $iteration_count_log2, $portable_hashes ) { + self::__construct( $iteration_count_log2, $portable_hashes ); + } + + function get_random_bytes($count) + { + $output = ''; + if ( @is_readable('/dev/urandom') && + ($fh = @fopen('/dev/urandom', 'rb'))) { + $output = fread($fh, $count); + fclose($fh); + } + + if (strlen($output) < $count) { + $output = ''; + for ($i = 0; $i < $count; $i += 16) { + $this->random_state = + md5(microtime() . $this->random_state); + $output .= + pack('H*', md5($this->random_state)); + } + $output = substr($output, 0, $count); + } + + return $output; + } + + function encode64($input, $count) + { + $output = ''; + $i = 0; + do { + $value = ord($input[$i++]); + $output .= $this->itoa64[$value & 0x3f]; + if ($i < $count) + $value |= ord($input[$i]) << 8; + $output .= $this->itoa64[($value >> 6) & 0x3f]; + if ($i++ >= $count) + break; + if ($i < $count) + $value |= ord($input[$i]) << 16; + $output .= $this->itoa64[($value >> 12) & 0x3f]; + if ($i++ >= $count) + break; + $output .= $this->itoa64[($value >> 18) & 0x3f]; + } while ($i < $count); + + return $output; + } + + function gensalt_private($input) + { + $output = '$P$'; + $output .= $this->itoa64[min($this->iteration_count_log2 + + ((PHP_VERSION >= '5') ? 5 : 3), 30)]; + $output .= $this->encode64($input, 6); + + return $output; + } + + function crypt_private($password, $setting) + { + $output = '*0'; + if (substr($setting, 0, 2) == $output) + $output = '*1'; + + $id = substr($setting, 0, 3); + # We use "$P$", phpBB3 uses "$H$" for the same thing + if ($id != '$P$' && $id != '$H$') + return $output; + + $count_log2 = strpos($this->itoa64, $setting[3]); + if ($count_log2 < 7 || $count_log2 > 30) + return $output; + + $count = 1 << $count_log2; + + $salt = substr($setting, 4, 8); + if (strlen($salt) != 8) + return $output; + + # We're kind of forced to use MD5 here since it's the only + # cryptographic primitive available in all versions of PHP + # currently in use. To implement our own low-level crypto + # in PHP would result in much worse performance and + # consequently in lower iteration counts and hashes that are + # quicker to crack (by non-PHP code). + if (PHP_VERSION >= '5') { + $hash = md5($salt . $password, TRUE); + do { + $hash = md5($hash . $password, TRUE); + } while (--$count); + } else { + $hash = pack('H*', md5($salt . $password)); + do { + $hash = pack('H*', md5($hash . $password)); + } while (--$count); + } + + $output = substr($setting, 0, 12); + $output .= $this->encode64($hash, 16); + + return $output; + } + + function gensalt_extended($input) + { + $count_log2 = min($this->iteration_count_log2 + 8, 24); + # This should be odd to not reveal weak DES keys, and the + # maximum valid value is (2**24 - 1) which is odd anyway. + $count = (1 << $count_log2) - 1; + + $output = '_'; + $output .= $this->itoa64[$count & 0x3f]; + $output .= $this->itoa64[($count >> 6) & 0x3f]; + $output .= $this->itoa64[($count >> 12) & 0x3f]; + $output .= $this->itoa64[($count >> 18) & 0x3f]; + + $output .= $this->encode64($input, 3); + + return $output; + } + + function gensalt_blowfish($input) + { + # This one needs to use a different order of characters and a + # different encoding scheme from the one in encode64() above. + # We care because the last character in our encoded string will + # only represent 2 bits. While two known implementations of + # bcrypt will happily accept and correct a salt string which + # has the 4 unused bits set to non-zero, we do not want to take + # chances and we also do not want to waste an additional byte + # of entropy. + $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + $output = '$2a$'; + $output .= chr(ord('0') + $this->iteration_count_log2 / 10); + $output .= chr(ord('0') + $this->iteration_count_log2 % 10); + $output .= '$'; + + $i = 0; + do { + $c1 = ord($input[$i++]); + $output .= $itoa64[$c1 >> 2]; + $c1 = ($c1 & 0x03) << 4; + if ($i >= 16) { + $output .= $itoa64[$c1]; + break; + } + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 4; + $output .= $itoa64[$c1]; + $c1 = ($c2 & 0x0f) << 2; + + $c2 = ord($input[$i++]); + $c1 |= $c2 >> 6; + $output .= $itoa64[$c1]; + $output .= $itoa64[$c2 & 0x3f]; + } while (1); + + return $output; + } + + function HashPassword($password) + { + if ( strlen( $password ) > 4096 ) { + return '*'; + } + + $random = ''; + + if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { + $random = $this->get_random_bytes(16); + $hash = + crypt($password, $this->gensalt_blowfish($random)); + if (strlen($hash) == 60) + return $hash; + } + + if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) { + if (strlen($random) < 3) + $random = $this->get_random_bytes(3); + $hash = + crypt($password, $this->gensalt_extended($random)); + if (strlen($hash) == 20) + return $hash; + } + + if (strlen($random) < 6) + $random = $this->get_random_bytes(6); + $hash = + $this->crypt_private($password, + $this->gensalt_private($random)); + if (strlen($hash) == 34) + return $hash; + + # Returning '*' on error is safe here, but would _not_ be safe + # in a crypt(3)-like function used _both_ for generating new + # hashes and for validating passwords against existing hashes. + return '*'; + } + + function CheckPassword($password, $stored_hash) + { + if ( strlen( $password ) > 4096 ) { + return false; + } + + $hash = $this->crypt_private($password, $stored_hash); + if ($hash[0] == '*') + $hash = crypt($password, $stored_hash); + + return $hash === $stored_hash; + } +} \ No newline at end of file diff --git a/backend/wp-includes/class-phpmailer.php b/backend/wp-includes/class-phpmailer.php new file mode 100644 index 0000000..7f5e353 --- /dev/null +++ b/backend/wp-includes/class-phpmailer.php @@ -0,0 +1,4040 @@ +<?php +/** + * PHPMailer - PHP email creation and transport class. + * PHP Version 5 + * @package PHPMailer + * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project + * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk> + * @author Jim Jagielski (jimjag) <jimjag@gmail.com> + * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer - PHP email creation and transport class. + * @package PHPMailer + * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk> + * @author Jim Jagielski (jimjag) <jimjag@gmail.com> + * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> + * @author Brent R. Matzelle (original founder) + */ +class PHPMailer +{ + /** + * The PHPMailer Version number. + * @var string + */ + public $Version = '5.2.22'; + + /** + * Email priority. + * Options: null (default), 1 = High, 3 = Normal, 5 = low. + * When null, the header is not set at all. + * @var integer + */ + public $Priority = null; + + /** + * The character set of the message. + * @var string + */ + public $CharSet = 'iso-8859-1'; + + /** + * The MIME Content-type of the message. + * @var string + */ + public $ContentType = 'text/plain'; + + /** + * The message encoding. + * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". + * @var string + */ + public $Encoding = '8bit'; + + /** + * Holds the most recent mailer error message. + * @var string + */ + public $ErrorInfo = ''; + + /** + * The From email address for the message. + * @var string + */ + public $From = 'root@localhost'; + + /** + * The From name of the message. + * @var string + */ + public $FromName = 'Root User'; + + /** + * The Sender email (Return-Path) of the message. + * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. + * @var string + */ + public $Sender = ''; + + /** + * The Return-Path of the message. + * If empty, it will be set to either From or Sender. + * @var string + * @deprecated Email senders should never set a return-path header; + * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything. + * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference + */ + public $ReturnPath = ''; + + /** + * The Subject of the message. + * @var string + */ + public $Subject = ''; + + /** + * An HTML or plain text message body. + * If HTML then call isHTML(true). + * @var string + */ + public $Body = ''; + + /** + * The plain-text message body. + * This body can be read by mail clients that do not have HTML email + * capability such as mutt & Eudora. + * Clients that can read HTML will view the normal Body. + * @var string + */ + public $AltBody = ''; + + /** + * An iCal message part body. + * Only supported in simple alt or alt_inline message types + * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator + * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ + * @link http://kigkonsult.se/iCalcreator/ + * @var string + */ + public $Ical = ''; + + /** + * The complete compiled MIME message body. + * @access protected + * @var string + */ + protected $MIMEBody = ''; + + /** + * The complete compiled MIME message headers. + * @var string + * @access protected + */ + protected $MIMEHeader = ''; + + /** + * Extra headers that createHeader() doesn't fold in. + * @var string + * @access protected + */ + protected $mailHeader = ''; + + /** + * Word-wrap the message body to this number of chars. + * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. + * @var integer + */ + public $WordWrap = 0; + + /** + * Which method to use to send mail. + * Options: "mail", "sendmail", or "smtp". + * @var string + */ + public $Mailer = 'mail'; + + /** + * The path to the sendmail program. + * @var string + */ + public $Sendmail = '/usr/sbin/sendmail'; + + /** + * Whether mail() uses a fully sendmail-compatible MTA. + * One which supports sendmail's "-oi -f" options. + * @var boolean + */ + public $UseSendmailOptions = true; + + /** + * Path to PHPMailer plugins. + * Useful if the SMTP class is not in the PHP include path. + * @var string + * @deprecated Should not be needed now there is an autoloader. + */ + public $PluginDir = ''; + + /** + * The email address that a reading confirmation should be sent to, also known as read receipt. + * @var string + */ + public $ConfirmReadingTo = ''; + + /** + * The hostname to use in the Message-ID header and as default HELO string. + * If empty, PHPMailer attempts to find one with, in order, + * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value + * 'localhost.localdomain'. + * @var string + */ + public $Hostname = ''; + + /** + * An ID to be used in the Message-ID header. + * If empty, a unique id will be generated. + * You can set your own, but it must be in the format "<id@domain>", + * as defined in RFC5322 section 3.6.4 or it will be ignored. + * @see https://tools.ietf.org/html/rfc5322#section-3.6.4 + * @var string + */ + public $MessageID = ''; + + /** + * The message Date to be used in the Date header. + * If empty, the current date will be added. + * @var string + */ + public $MessageDate = ''; + + /** + * SMTP hosts. + * Either a single hostname or multiple semicolon-delimited hostnames. + * You can also specify a different port + * for each host by using this format: [hostname:port] + * (e.g. "smtp1.example.com:25;smtp2.example.com"). + * You can also specify encryption type, for example: + * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). + * Hosts will be tried in order. + * @var string + */ + public $Host = 'localhost'; + + /** + * The default SMTP server port. + * @var integer + * @TODO Why is this needed when the SMTP class takes care of it? + */ + public $Port = 25; + + /** + * The SMTP HELO of the message. + * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find + * one with the same method described above for $Hostname. + * @var string + * @see PHPMailer::$Hostname + */ + public $Helo = ''; + + /** + * What kind of encryption to use on the SMTP connection. + * Options: '', 'ssl' or 'tls' + * @var string + */ + public $SMTPSecure = ''; + + /** + * Whether to enable TLS encryption automatically if a server supports it, + * even if `SMTPSecure` is not set to 'tls'. + * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. + * @var boolean + */ + public $SMTPAutoTLS = true; + + /** + * Whether to use SMTP authentication. + * Uses the Username and Password properties. + * @var boolean + * @see PHPMailer::$Username + * @see PHPMailer::$Password + */ + public $SMTPAuth = false; + + /** + * Options array passed to stream_context_create when connecting via SMTP. + * @var array + */ + public $SMTPOptions = array(); + + /** + * SMTP username. + * @var string + */ + public $Username = ''; + + /** + * SMTP password. + * @var string + */ + public $Password = ''; + + /** + * SMTP auth type. + * Options are CRAM-MD5, LOGIN, PLAIN, attempted in that order if not specified + * @var string + */ + public $AuthType = ''; + + /** + * SMTP realm. + * Used for NTLM auth + * @var string + */ + public $Realm = ''; + + /** + * SMTP workstation. + * Used for NTLM auth + * @var string + */ + public $Workstation = ''; + + /** + * The SMTP server timeout in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * @var integer + */ + public $Timeout = 300; + + /** + * SMTP class debug output mode. + * Debug output level. + * Options: + * * `0` No output + * * `1` Commands + * * `2` Data and commands + * * `3` As 2 plus connection status + * * `4` Low-level data output + * @var integer + * @see SMTP::$do_debug + */ + public $SMTPDebug = 0; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output + * * `error_log` Output to error log as configured in php.ini + * + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * <code> + * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; + * </code> + * @var string|callable + * @see SMTP::$Debugoutput + */ + public $Debugoutput = 'echo'; + + /** + * Whether to keep SMTP connection open after each message. + * If this is set to true then to close the connection + * requires an explicit call to smtpClose(). + * @var boolean + */ + public $SMTPKeepAlive = false; + + /** + * Whether to split multiple to addresses into multiple messages + * or send them all in one message. + * Only supported in `mail` and `sendmail` transports, not in SMTP. + * @var boolean + */ + public $SingleTo = false; + + /** + * Storage for addresses when SingleTo is enabled. + * @var array + * @TODO This should really not be public + */ + public $SingleToArray = array(); + + /** + * Whether to generate VERP addresses on send. + * Only applicable when sending via SMTP. + * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path + * @link http://www.postfix.org/VERP_README.html Postfix VERP info + * @var boolean + */ + public $do_verp = false; + + /** + * Whether to allow sending messages with an empty body. + * @var boolean + */ + public $AllowEmpty = false; + + /** + * The default line ending. + * @note The default remains "\n". We force CRLF where we know + * it must be used via self::CRLF. + * @var string + */ + public $LE = "\n"; + + /** + * DKIM selector. + * @var string + */ + public $DKIM_selector = ''; + + /** + * DKIM Identity. + * Usually the email address used as the source of the email. + * @var string + */ + public $DKIM_identity = ''; + + /** + * DKIM passphrase. + * Used if your key is encrypted. + * @var string + */ + public $DKIM_passphrase = ''; + + /** + * DKIM signing domain name. + * @example 'example.com' + * @var string + */ + public $DKIM_domain = ''; + + /** + * DKIM private key file path. + * @var string + */ + public $DKIM_private = ''; + + /** + * DKIM private key string. + * If set, takes precedence over `$DKIM_private`. + * @var string + */ + public $DKIM_private_string = ''; + + /** + * Callback Action function name. + * + * The function that handles the result of the send email action. + * It is called out by send() for each email sent. + * + * Value can be any php callable: http://www.php.net/is_callable + * + * Parameters: + * boolean $result result of the send action + * string $to email address of the recipient + * string $cc cc email addresses + * string $bcc bcc email addresses + * string $subject the subject + * string $body the email body + * string $from email address of sender + * @var string + */ + public $action_function = ''; + + /** + * What to put in the X-Mailer header. + * Options: An empty string for PHPMailer default, whitespace for none, or a string to use + * @var string + */ + public $XMailer = ''; + + /** + * Which validator to use by default when validating email addresses. + * May be a callable to inject your own validator, but there are several built-in validators. + * @see PHPMailer::validateAddress() + * @var string|callable + * @static + */ + public static $validator = 'auto'; + + /** + * An instance of the SMTP sender class. + * @var SMTP + * @access protected + */ + protected $smtp = null; + + /** + * The array of 'to' names and addresses. + * @var array + * @access protected + */ + protected $to = array(); + + /** + * The array of 'cc' names and addresses. + * @var array + * @access protected + */ + protected $cc = array(); + + /** + * The array of 'bcc' names and addresses. + * @var array + * @access protected + */ + protected $bcc = array(); + + /** + * The array of reply-to names and addresses. + * @var array + * @access protected + */ + protected $ReplyTo = array(); + + /** + * An array of all kinds of addresses. + * Includes all of $to, $cc, $bcc + * @var array + * @access protected + * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc + */ + protected $all_recipients = array(); + + /** + * An array of names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $all_recipients + * and one of $to, $cc, or $bcc. + * This array is used only for addresses with IDN. + * @var array + * @access protected + * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc + * @see PHPMailer::$all_recipients + */ + protected $RecipientsQueue = array(); + + /** + * An array of reply-to names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $ReplyTo. + * This array is used only for addresses with IDN. + * @var array + * @access protected + * @see PHPMailer::$ReplyTo + */ + protected $ReplyToQueue = array(); + + /** + * The array of attachments. + * @var array + * @access protected + */ + protected $attachment = array(); + + /** + * The array of custom headers. + * @var array + * @access protected + */ + protected $CustomHeader = array(); + + /** + * The most recent Message-ID (including angular brackets). + * @var string + * @access protected + */ + protected $lastMessageID = ''; + + /** + * The message's MIME type. + * @var string + * @access protected + */ + protected $message_type = ''; + + /** + * The array of MIME boundary strings. + * @var array + * @access protected + */ + protected $boundary = array(); + + /** + * The array of available languages. + * @var array + * @access protected + */ + protected $language = array(); + + /** + * The number of errors encountered. + * @var integer + * @access protected + */ + protected $error_count = 0; + + /** + * The S/MIME certificate file path. + * @var string + * @access protected + */ + protected $sign_cert_file = ''; + + /** + * The S/MIME key file path. + * @var string + * @access protected + */ + protected $sign_key_file = ''; + + /** + * The optional S/MIME extra certificates ("CA Chain") file path. + * @var string + * @access protected + */ + protected $sign_extracerts_file = ''; + + /** + * The S/MIME password for the key. + * Used only if the key is encrypted. + * @var string + * @access protected + */ + protected $sign_key_pass = ''; + + /** + * Whether to throw exceptions for errors. + * @var boolean + * @access protected + */ + protected $exceptions = false; + + /** + * Unique ID used for message ID and boundaries. + * @var string + * @access protected + */ + protected $uniqueid = ''; + + /** + * Error severity: message only, continue processing. + */ + const STOP_MESSAGE = 0; + + /** + * Error severity: message, likely ok to continue processing. + */ + const STOP_CONTINUE = 1; + + /** + * Error severity: message, plus full stop, critical error reached. + */ + const STOP_CRITICAL = 2; + + /** + * SMTP RFC standard line ending. + */ + const CRLF = "\r\n"; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1 + * @var integer + */ + const MAX_LINE_LENGTH = 998; + + /** + * Constructor. + * @param boolean $exceptions Should we throw external exceptions? + */ + public function __construct($exceptions = null) + { + if ($exceptions !== null) { + $this->exceptions = (boolean)$exceptions; + } + } + + /** + * Destructor. + */ + public function __destruct() + { + //Close any open SMTP connection nicely + $this->smtpClose(); + } + + /** + * Call mail() in a safe_mode-aware fashion. + * Also, unless sendmail_path points to sendmail (or something that + * claims to be sendmail), don't pass params (not a perfect fix, + * but it will do) + * @param string $to To + * @param string $subject Subject + * @param string $body Message Body + * @param string $header Additional Header(s) + * @param string $params Params + * @access private + * @return boolean + */ + private function mailPassthru($to, $subject, $body, $header, $params) + { + //Check overloading of mail function to avoid double-encoding + if (ini_get('mbstring.func_overload') & 1) { + $subject = $this->secureHeader($subject); + } else { + $subject = $this->encodeHeader($this->secureHeader($subject)); + } + + //Can't use additional_parameters in safe_mode, calling mail() with null params breaks + //@link http://php.net/manual/en/function.mail.php + if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) { + $result = @mail($to, $subject, $body, $header); + } else { + $result = @mail($to, $subject, $body, $header, $params); + } + return $result; + } + /** + * Output debugging info via user-defined method. + * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug). + * @see PHPMailer::$Debugoutput + * @see PHPMailer::$SMTPDebug + * @param string $str + */ + protected function edebug($str) + { + if ($this->SMTPDebug <= 0) { + return; + } + //Avoid clash with built-in function names + if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { + call_user_func($this->Debugoutput, $str, $this->SMTPDebug); + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ) + . "<br>\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/\r\n?/ms', "\n", $str); + echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( + "\n", + "\n \t ", + trim($str) + ) . "\n"; + } + } + + /** + * Sets message type to HTML or plain. + * @param boolean $isHtml True for HTML mode. + * @return void + */ + public function isHTML($isHtml = true) + { + if ($isHtml) { + $this->ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Send messages using SMTP. + * @return void + */ + public function isSMTP() + { + $this->Mailer = 'smtp'; + } + + /** + * Send messages using PHP's mail() function. + * @return void + */ + public function isMail() + { + $this->Mailer = 'mail'; + } + + /** + * Send messages using $Sendmail. + * @return void + */ + public function isSendmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (!stristr($ini_sendmail_path, 'sendmail')) { + $this->Sendmail = '/usr/sbin/sendmail'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'sendmail'; + } + + /** + * Send messages using qmail. + * @return void + */ + public function isQmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (!stristr($ini_sendmail_path, 'qmail')) { + $this->Sendmail = '/var/qmail/bin/qmail-inject'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'qmail'; + } + + /** + * Add a "To" address. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addAddress($address, $name = '') + { + return $this->addOrEnqueueAnAddress('to', $address, $name); + } + + /** + * Add a "CC" address. + * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('cc', $address, $name); + } + + /** + * Add a "BCC" address. + * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addBCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('bcc', $address, $name); + } + + /** + * Add a "Reply-To" address. + * @param string $address The email address to reply to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addReplyTo($address, $name = '') + { + return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer + * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still + * be modified after calling this function), addition of such addresses is delayed until send(). + * Addresses that have been added already return false, but do not throw exceptions. + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * @throws phpmailerException + * @return boolean true on success, false if address already used or invalid in some way + * @access protected + */ + protected function addOrEnqueueAnAddress($kind, $address, $name) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (($pos = strrpos($address, '@')) === false) { + // At-sign is misssing. + $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + $params = array($kind, $address, $name); + // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. + if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { + if ($kind != 'Reply-To') { + if (!array_key_exists($address, $this->RecipientsQueue)) { + $this->RecipientsQueue[$address] = $params; + return true; + } + } else { + if (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; + return true; + } + } + return false; + } + // Immediately add standard addresses without IDN. + return call_user_func_array(array($this, 'addAnAddress'), $params); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. + * Addresses that have been added already return false, but do not throw exceptions. + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * @throws phpmailerException + * @return boolean true on success, false if address already used or invalid in some way + * @access protected + */ + protected function addAnAddress($kind, $address, $name = '') + { + if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) { + $error_message = $this->lang('Invalid recipient kind: ') . $kind; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + if (!$this->validateAddress($address)) { + $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + if ($kind != 'Reply-To') { + if (!array_key_exists(strtolower($address), $this->all_recipients)) { + array_push($this->$kind, array($address, $name)); + $this->all_recipients[strtolower($address)] = true; + return true; + } + } else { + if (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = array($address, $name); + return true; + } + } + return false; + } + + /** + * Parse and validate a string containing one or more RFC822-style comma-separated email addresses + * of the form "display name <address>" into an array of name/address pairs. + * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. + * Note that quotes in the name part are removed. + * @param string $addrstr The address list string + * @param bool $useimap Whether to use the IMAP extension to parse the list + * @return array + * @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation + */ + public function parseAddresses($addrstr, $useimap = true) + { + $addresses = array(); + if ($useimap and function_exists('imap_rfc822_parse_adrlist')) { + //Use this built-in parser if it's available + $list = imap_rfc822_parse_adrlist($addrstr, ''); + foreach ($list as $address) { + if ($address->host != '.SYNTAX-ERROR.') { + if ($this->validateAddress($address->mailbox . '@' . $address->host)) { + $addresses[] = array( + 'name' => (property_exists($address, 'personal') ? $address->personal : ''), + 'address' => $address->mailbox . '@' . $address->host + ); + } + } + } + } else { + //Use this simpler parser + $list = explode(',', $addrstr); + foreach ($list as $address) { + $address = trim($address); + //Is there a separate name part? + if (strpos($address, '<') === false) { + //No separate name, just use the whole thing + if ($this->validateAddress($address)) { + $addresses[] = array( + 'name' => '', + 'address' => $address + ); + } + } else { + list($name, $email) = explode('<', $address); + $email = trim(str_replace('>', '', $email)); + if ($this->validateAddress($email)) { + $addresses[] = array( + 'name' => trim(str_replace(array('"', "'"), '', $name)), + 'address' => $email + ); + } + } + } + } + return $addresses; + } + + /** + * Set the From and FromName properties. + * @param string $address + * @param string $name + * @param boolean $auto Whether to also set the Sender address, defaults to true + * @throws phpmailerException + * @return boolean + */ + public function setFrom($address, $name = '', $auto = true) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + // Don't validate now addresses with IDN. Will be done in send(). + if (($pos = strrpos($address, '@')) === false or + (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and + !$this->validateAddress($address)) { + $error_message = $this->lang('invalid_address') . " (setFrom) $address"; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto) { + if (empty($this->Sender)) { + $this->Sender = $address; + } + } + return true; + } + + /** + * Return the Message-ID header of the last email. + * Technically this is the value from the last time the headers were created, + * but it's also the message ID of the last sent message except in + * pathological cases. + * @return string + */ + public function getLastMessageID() + { + return $this->lastMessageID; + } + + /** + * Check that a string looks like an email address. + * @param string $address The email address to check + * @param string|callable $patternselect A selector for the validation pattern to use : + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * Alternatively you may pass in a callable to inject your own validator, for example: + * PHPMailer::validateAddress('user@example.com', function($address) { + * return (strpos($address, '@') !== false); + * }); + * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. + * @return boolean + * @static + * @access public + */ + public static function validateAddress($address, $patternselect = null) + { + if (is_null($patternselect)) { + $patternselect = self::$validator; + } + if (is_callable($patternselect)) { + return call_user_func($patternselect, $address); + } + //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 + if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) { + return false; + } + if (!$patternselect or $patternselect == 'auto') { + //Check this constant first so it works when extension_loaded() is disabled by safe mode + //Constant was added in PHP 5.2.4 + if (defined('PCRE_VERSION')) { + //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2 + if (version_compare(PCRE_VERSION, '8.0.3') >= 0) { + $patternselect = 'pcre8'; + } else { + $patternselect = 'pcre'; + } + } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) { + //Fall back to older PCRE + $patternselect = 'pcre'; + } else { + //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension + if (version_compare(PHP_VERSION, '5.2.0') >= 0) { + $patternselect = 'php'; + } else { + $patternselect = 'noregex'; + } + } + } + switch ($patternselect) { + case 'pcre8': + /** + * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains. + * @link http://squiloople.com/2009/12/20/email-address-validation/ + * @copyright 2009-2010 Michael Rushton + * Feel free to use and redistribute this code. But please keep this copyright notice. + */ + return (boolean)preg_match( + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', + $address + ); + case 'pcre': + //An older regex that doesn't need a recent PCRE + return (boolean)preg_match( + '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . + '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . + '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . + '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . + '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' . + '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . + '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' . + '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . + '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', + $address + ); + case 'html5': + /** + * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. + * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) + */ + return (boolean)preg_match( + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . + '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', + $address + ); + case 'noregex': + //No PCRE! Do something _very_ approximate! + //Check the address is 3 chars or longer and contains an @ that's not the first or last char + return (strlen($address) >= 3 + and strpos($address, '@') >= 1 + and strpos($address, '@') != strlen($address) - 1); + case 'php': + default: + return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL); + } + } + + /** + * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the + * "intl" and "mbstring" PHP extensions. + * @return bool "true" if required functions for IDN support are present + */ + public function idnSupported() + { + // @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2. + return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); + } + + /** + * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. + * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. + * This function silently returns unmodified address if: + * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) + * - Conversion to punycode is impossible (e.g. required PHP functions are not available) + * or fails for any reason (e.g. domain has characters not allowed in an IDN) + * @see PHPMailer::$CharSet + * @param string $address The email address to convert + * @return string The encoded address in ASCII form + */ + public function punyencodeAddress($address) + { + // Verify we have required functions, CharSet, and at-sign. + if ($this->idnSupported() and + !empty($this->CharSet) and + ($pos = strrpos($address, '@')) !== false) { + $domain = substr($address, ++$pos); + // Verify CharSet string is a valid one, and domain properly encoded in this CharSet. + if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { + $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); + if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ? + idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : + idn_to_ascii($domain)) !== false) { + return substr($address, 0, $pos) . $punycode; + } + } + } + return $address; + } + + /** + * Create a message and send it. + * Uses the sending method specified by $Mailer. + * @throws phpmailerException + * @return boolean false on error - See the ErrorInfo property for details of the error. + */ + public function send() + { + try { + if (!$this->preSend()) { + return false; + } + return $this->postSend(); + } catch (phpmailerException $exc) { + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + } + + /** + * Prepare a message for sending. + * @throws phpmailerException + * @return boolean + */ + public function preSend() + { + try { + $this->error_count = 0; // Reset errors + $this->mailHeader = ''; + + // Dequeue recipient and Reply-To addresses with IDN + foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { + $params[1] = $this->punyencodeAddress($params[1]); + call_user_func_array(array($this, 'addAnAddress'), $params); + } + if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); + } + + // Validate From, Sender, and ConfirmReadingTo addresses + foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) { + $this->$address_kind = trim($this->$address_kind); + if (empty($this->$address_kind)) { + continue; + } + $this->$address_kind = $this->punyencodeAddress($this->$address_kind); + if (!$this->validateAddress($this->$address_kind)) { + $error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + } + + // Set whether the message is multipart/alternative + if ($this->alternativeExists()) { + $this->ContentType = 'multipart/alternative'; + } + + $this->setMessageType(); + // Refuse to send an empty message unless we are specifically allowing it + if (!$this->AllowEmpty and empty($this->Body)) { + throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); + } + + // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) + $this->MIMEHeader = ''; + $this->MIMEBody = $this->createBody(); + // createBody may have added some headers, so retain them + $tempheaders = $this->MIMEHeader; + $this->MIMEHeader = $this->createHeader(); + $this->MIMEHeader .= $tempheaders; + + // To capture the complete message when using mail(), create + // an extra header list which createHeader() doesn't fold in + if ($this->Mailer == 'mail') { + if (count($this->to) > 0) { + $this->mailHeader .= $this->addrAppend('To', $this->to); + } else { + $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + $this->mailHeader .= $this->headerLine( + 'Subject', + $this->encodeHeader($this->secureHeader(trim($this->Subject))) + ); + } + + // Sign with DKIM if enabled + if (!empty($this->DKIM_domain) + && !empty($this->DKIM_selector) + && (!empty($this->DKIM_private_string) + || (!empty($this->DKIM_private) && file_exists($this->DKIM_private)) + ) + ) { + $header_dkim = $this->DKIM_Add( + $this->MIMEHeader . $this->mailHeader, + $this->encodeHeader($this->secureHeader($this->Subject)), + $this->MIMEBody + ); + $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . + str_replace("\r\n", "\n", $header_dkim) . self::CRLF; + } + return true; + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + } + + /** + * Actually send a message. + * Send the email via the selected mechanism + * @throws phpmailerException + * @return boolean + */ + public function postSend() + { + try { + // Choose the mailer and send through it + switch ($this->Mailer) { + case 'sendmail': + case 'qmail': + return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); + case 'smtp': + return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); + case 'mail': + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + default: + $sendMethod = $this->Mailer.'Send'; + if (method_exists($this, $sendMethod)) { + return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); + } + + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + } + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + } + return false; + } + + /** + * Send mail using the $Sendmail program. + * @param string $header The message headers + * @param string $body The message body + * @see PHPMailer::$Sendmail + * @throws phpmailerException + * @access protected + * @return boolean + */ + protected function sendmailSend($header, $body) + { + // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (!empty($this->Sender) and self::isShellSafe($this->Sender)) { + if ($this->Mailer == 'qmail') { + $sendmailFmt = '%s -f%s'; + } else { + $sendmailFmt = '%s -oi -f%s -t'; + } + } else { + if ($this->Mailer == 'qmail') { + $sendmailFmt = '%s'; + } else { + $sendmailFmt = '%s -oi -t'; + } + } + + // TODO: If possible, this should be changed to escapeshellarg. Needs thorough testing. + $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); + + if ($this->SingleTo) { + foreach ($this->SingleToArray as $toAddr) { + if (!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, 'To: ' . $toAddr . "\n"); + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result == 0), + array($toAddr), + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From + ); + if ($result != 0) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + if (!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result == 0), + $this->to, + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From + ); + if ($result != 0) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + return true; + } + + /** + * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. + * + * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. + * @param string $string The string to be validated + * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report + * @access protected + * @return boolean + */ + protected static function isShellSafe($string) + { + // Future-proof + if (escapeshellcmd($string) !== $string + or !in_array(escapeshellarg($string), array("'$string'", "\"$string\"")) + ) { + return false; + } + + $length = strlen($string); + + for ($i = 0; $i < $length; $i++) { + $c = $string[$i]; + + // All other characters have a special meaning in at least one common shell, including = and +. + // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. + // Note that this does permit non-Latin alphanumeric characters based on the current locale. + if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { + return false; + } + } + + return true; + } + + /** + * Send mail using the PHP mail() function. + * @param string $header The message headers + * @param string $body The message body + * @link http://www.php.net/manual/en/book.mail.php + * @throws phpmailerException + * @access protected + * @return boolean + */ + protected function mailSend($header, $body) + { + $toArr = array(); + foreach ($this->to as $toaddr) { + $toArr[] = $this->addrFormat($toaddr); + } + $to = implode(', ', $toArr); + + $params = null; + //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver + if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { + // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (self::isShellSafe($this->Sender)) { + $params = sprintf('-f%s', $this->Sender); + } + } + if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + } + $result = false; + if ($this->SingleTo and count($toArr) > 1) { + foreach ($toArr as $toAddr) { + $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); + $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); + } + } else { + $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); + $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if (!$result) { + throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL); + } + return true; + } + + /** + * Get an instance to use for SMTP operations. + * Override this function to load your own SMTP implementation + * @return SMTP + */ + public function getSMTPInstance() + { + if (!is_object($this->smtp)) { + require_once( 'class-smtp.php' ); + $this->smtp = new SMTP; + } + return $this->smtp; + } + + /** + * Send mail via SMTP. + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * Uses the PHPMailerSMTP class by default. + * @see PHPMailer::getSMTPInstance() to use a different class. + * @param string $header The message headers + * @param string $body The message body + * @throws phpmailerException + * @uses SMTP + * @access protected + * @return boolean + */ + protected function smtpSend($header, $body) + { + $bad_rcpt = array(); + if (!$this->smtpConnect($this->SMTPOptions)) { + throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { + $smtp_from = $this->Sender; + } else { + $smtp_from = $this->From; + } + if (!$this->smtp->mail($smtp_from)) { + $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); + throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL); + } + + // Attempt to send to all recipients + foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { + foreach ($togroup as $to) { + if (!$this->smtp->recipient($to[0])) { + $error = $this->smtp->getError(); + $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']); + $isSent = false; + } else { + $isSent = true; + } + $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); + } + } + + // Only send the DATA command if we have viable recipients + if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { + throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL); + } + if ($this->SMTPKeepAlive) { + $this->smtp->reset(); + } else { + $this->smtp->quit(); + $this->smtp->close(); + } + //Create error message for any bad addresses + if (count($bad_rcpt) > 0) { + $errstr = ''; + foreach ($bad_rcpt as $bad) { + $errstr .= $bad['to'] . ': ' . $bad['error']; + } + throw new phpmailerException( + $this->lang('recipients_failed') . $errstr, + self::STOP_CONTINUE + ); + } + return true; + } + + /** + * Initiate a connection to an SMTP server. + * Returns false if the operation failed. + * @param array $options An array of options compatible with stream_context_create() + * @uses SMTP + * @access public + * @throws phpmailerException + * @return boolean + */ + public function smtpConnect($options = null) + { + if (is_null($this->smtp)) { + $this->smtp = $this->getSMTPInstance(); + } + + //If no options are provided, use whatever is set in the instance + if (is_null($options)) { + $options = $this->SMTPOptions; + } + + // Already connected? + if ($this->smtp->connected()) { + return true; + } + + $this->smtp->setTimeout($this->Timeout); + $this->smtp->setDebugLevel($this->SMTPDebug); + $this->smtp->setDebugOutput($this->Debugoutput); + $this->smtp->setVerp($this->do_verp); + $hosts = explode(';', $this->Host); + $lastexception = null; + + foreach ($hosts as $hostentry) { + $hostinfo = array(); + if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { + // Not a valid host entry + continue; + } + // $hostinfo[2]: optional ssl or tls prefix + // $hostinfo[3]: the hostname + // $hostinfo[4]: optional port number + // The host string prefix can temporarily override the current setting for SMTPSecure + // If it's not specified, the default value is used + $prefix = ''; + $secure = $this->SMTPSecure; + $tls = ($this->SMTPSecure == 'tls'); + if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) { + $prefix = 'ssl://'; + $tls = false; // Can't have SSL and TLS at the same time + $secure = 'ssl'; + } elseif ($hostinfo[2] == 'tls') { + $tls = true; + // tls doesn't use a prefix + $secure = 'tls'; + } + //Do we need the OpenSSL extension? + $sslext = defined('OPENSSL_ALGO_SHA1'); + if ('tls' === $secure or 'ssl' === $secure) { + //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled + if (!$sslext) { + throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); + } + } + $host = $hostinfo[3]; + $port = $this->Port; + $tport = (integer)$hostinfo[4]; + if ($tport > 0 and $tport < 65536) { + $port = $tport; + } + if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { + try { + if ($this->Helo) { + $hello = $this->Helo; + } else { + $hello = $this->serverHostname(); + } + $this->smtp->hello($hello); + //Automatically enable TLS encryption if: + // * it's not disabled + // * we have openssl extension + // * we are not already using SSL + // * the server offers STARTTLS + if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) { + $tls = true; + } + if ($tls) { + if (!$this->smtp->startTLS()) { + throw new phpmailerException($this->lang('connect_host')); + } + // We must resend EHLO after TLS negotiation + $this->smtp->hello($hello); + } + if ($this->SMTPAuth) { + if (!$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->Realm, + $this->Workstation + ) + ) { + throw new phpmailerException($this->lang('authenticate')); + } + } + return true; + } catch (phpmailerException $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + // We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } + } + } + // If we get here, all connection attempts have failed, so close connection hard + $this->smtp->close(); + // As we've caught all exceptions, just report whatever the last one was + if ($this->exceptions and !is_null($lastexception)) { + throw $lastexception; + } + return false; + } + + /** + * Close the active SMTP session if one exists. + * @return void + */ + public function smtpClose() + { + if (is_a($this->smtp, 'SMTP')) { + if ($this->smtp->connected()) { + $this->smtp->quit(); + $this->smtp->close(); + } + } + } + + /** + * Set the language for error messages. + * Returns false if it cannot load the language file. + * The default language is English. + * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") + * @param string $lang_path Path to the language file directory, with trailing separator (slash) + * @return boolean + * @access public + */ + public function setLanguage($langcode = 'en', $lang_path = '') + { + // Backwards compatibility for renamed language codes + $renamed_langcodes = array( + 'br' => 'pt_br', + 'cz' => 'cs', + 'dk' => 'da', + 'no' => 'nb', + 'se' => 'sv', + ); + + if (isset($renamed_langcodes[$langcode])) { + $langcode = $renamed_langcodes[$langcode]; + } + + // Define full set of translatable strings in English + $PHPMAILER_LANG = array( + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'data_not_accepted' => 'SMTP Error: data not accepted.', + 'empty_message' => 'Message body empty', + 'encoding' => 'Unknown encoding: ', + 'execute' => 'Could not execute: ', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'from_failed' => 'The following From address failed: ', + 'instantiate' => 'Could not instantiate mail function.', + 'invalid_address' => 'Invalid address: ', + 'mailer_not_supported' => ' mailer is not supported.', + 'provide_address' => 'You must provide at least one recipient email address.', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'signing' => 'Signing Error: ', + 'smtp_connect_failed' => 'SMTP connect() failed.', + 'smtp_error' => 'SMTP server error: ', + 'variable_set' => 'Cannot set or reset variable: ', + 'extension_missing' => 'Extension missing: ' + ); + if (empty($lang_path)) { + // Calculate an absolute path so it can work if CWD is not here + $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; + } + //Validate $langcode + if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { + $langcode = 'en'; + } + $foundlang = true; + $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; + // There is no English translation file + if ($langcode != 'en') { + // Make sure language file path is readable + if (!is_readable($lang_file)) { + $foundlang = false; + } else { + // Overwrite language-specific strings. + // This way we'll never have missing translation keys. + $foundlang = include $lang_file; + } + } + $this->language = $PHPMAILER_LANG; + return (boolean)$foundlang; // Returns false if language not found + } + + /** + * Get the array of strings for the current language. + * @return array + */ + public function getTranslations() + { + return $this->language; + } + + /** + * Create recipient headers. + * @access public + * @param string $type + * @param array $addr An array of recipient, + * where each recipient is a 2-element indexed array with element 0 containing an address + * and element 1 containing a name, like: + * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User')) + * @return string + */ + public function addrAppend($type, $addr) + { + $addresses = array(); + foreach ($addr as $address) { + $addresses[] = $this->addrFormat($address); + } + return $type . ': ' . implode(', ', $addresses) . $this->LE; + } + + /** + * Format an address for use in a message header. + * @access public + * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name + * like array('joe@example.com', 'Joe User') + * @return string + */ + public function addrFormat($addr) + { + if (empty($addr[1])) { // No name provided + return $this->secureHeader($addr[0]); + } else { + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( + $addr[0] + ) . '>'; + } + } + + /** + * Word-wrap message. + * For use with mailers that do not automatically perform wrapping + * and for quoted-printable encoded messages. + * Original written by philippe. + * @param string $message The message to wrap + * @param integer $length The line length to wrap to + * @param boolean $qp_mode Whether to run in Quoted-Printable mode + * @access public + * @return string + */ + public function wrapText($message, $length, $qp_mode = false) + { + if ($qp_mode) { + $soft_break = sprintf(' =%s', $this->LE); + } else { + $soft_break = $this->LE; + } + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == 'utf-8'); + $lelen = strlen($this->LE); + $crlflen = strlen(self::CRLF); + + $message = $this->fixEOL($message); + //Remove a trailing line break + if (substr($message, -$lelen) == $this->LE) { + $message = substr($message, 0, -$lelen); + } + + //Split message into lines + $lines = explode($this->LE, $message); + //Message will be rebuilt in here + $message = ''; + foreach ($lines as $line) { + $words = explode(' ', $line); + $buf = ''; + $firstword = true; + foreach ($words as $word) { + if ($qp_mode and (strlen($word) > $length)) { + $space_left = $length - strlen($buf) - $crlflen; + if (!$firstword) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->utf8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == '=') { + $len--; + } elseif (substr($word, $len - 2, 1) == '=') { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf('=%s', self::CRLF); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + if ($length <= 0) { + break; + } + $len = $length; + if ($is_utf8) { + $len = $this->utf8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == '=') { + $len--; + } elseif (substr($word, $len - 2, 1) == '=') { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf('=%s', self::CRLF); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + if (!$firstword) { + $buf .= ' '; + } + $buf .= $word; + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + $firstword = false; + } + $message .= $buf . self::CRLF; + } + + return $message; + } + + /** + * Find the last character boundary prior to $maxLength in a utf-8 + * quoted-printable encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param integer $maxLength Find the last character boundary prior to this length + * @return integer + */ + public function utf8CharBoundary($encodedText, $maxLength) + { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, '='); + if (false !== $encodedCharPos) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { + // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + if ($encodedCharPos > 0) { + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + } + $foundSplitPos = true; + } elseif ($dec >= 192) { + // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { + // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + /** + * Apply word wrapping to the message body. + * Wraps the message body to the number of chars set in the WordWrap property. + * You should only do this to plain-text bodies as wrapping HTML tags may break them. + * This is called automatically by createBody(), so you don't need to call it yourself. + * @access public + * @return void + */ + public function setWordWrap() + { + if ($this->WordWrap < 1) { + return; + } + + switch ($this->message_type) { + case 'alt': + case 'alt_inline': + case 'alt_attach': + case 'alt_inline_attach': + $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->wrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assemble message headers. + * @access public + * @return string The assembled headers + */ + public function createHeader() + { + $result = ''; + + if ($this->MessageDate == '') { + $this->MessageDate = self::rfcDate(); + } + $result .= $this->headerLine('Date', $this->MessageDate); + + // To be created automatically by mail() + if ($this->SingleTo) { + if ($this->Mailer != 'mail') { + foreach ($this->to as $toaddr) { + $this->SingleToArray[] = $this->addrFormat($toaddr); + } + } + } else { + if (count($this->to) > 0) { + if ($this->Mailer != 'mail') { + $result .= $this->addrAppend('To', $this->to); + } + } elseif (count($this->cc) == 0) { + $result .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + } + + $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); + + // sendmail and mail() extract Cc from the header before sending + if (count($this->cc) > 0) { + $result .= $this->addrAppend('Cc', $this->cc); + } + + // sendmail and mail() extract Bcc from the header before sending + if (( + $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' + ) + and count($this->bcc) > 0 + ) { + $result .= $this->addrAppend('Bcc', $this->bcc); + } + + if (count($this->ReplyTo) > 0) { + $result .= $this->addrAppend('Reply-To', $this->ReplyTo); + } + + // mail() sets the subject itself + if ($this->Mailer != 'mail') { + $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); + } + + // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4 + // https://tools.ietf.org/html/rfc5322#section-3.6.4 + if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) { + $this->lastMessageID = $this->MessageID; + } else { + $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname()); + } + $result .= $this->headerLine('Message-ID', $this->lastMessageID); + if (!is_null($this->Priority)) { + $result .= $this->headerLine('X-Priority', $this->Priority); + } + if ($this->XMailer == '') { + $result .= $this->headerLine( + 'X-Mailer', + 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)' + ); + } else { + $myXmailer = trim($this->XMailer); + if ($myXmailer) { + $result .= $this->headerLine('X-Mailer', $myXmailer); + } + } + + if ($this->ConfirmReadingTo != '') { + $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); + } + + // Add custom headers + foreach ($this->CustomHeader as $header) { + $result .= $this->headerLine( + trim($header[0]), + $this->encodeHeader(trim($header[1])) + ); + } + if (!$this->sign_key_file) { + $result .= $this->headerLine('MIME-Version', '1.0'); + $result .= $this->getMailMIME(); + } + + return $result; + } + + /** + * Get the message MIME type headers. + * @access public + * @return string + */ + public function getMailMIME() + { + $result = ''; + $ismultipart = true; + switch ($this->message_type) { + case 'inline': + $result .= $this->headerLine('Content-Type', 'multipart/related;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'attach': + case 'inline_attach': + case 'alt_attach': + case 'alt_inline_attach': + $result .= $this->headerLine('Content-Type', 'multipart/mixed;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'alt': + case 'alt_inline': + $result .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + default: + // Catches case 'plain': and case '': + $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); + $ismultipart = false; + break; + } + // RFC1341 part 5 says 7bit is assumed if not specified + if ($this->Encoding != '7bit') { + // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE + if ($ismultipart) { + if ($this->Encoding == '8bit') { + $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); + } + // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible + } else { + $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); + } + } + + if ($this->Mailer != 'mail') { + $result .= $this->LE; + } + + return $result; + } + + /** + * Returns the whole MIME message. + * Includes complete headers and body. + * Only valid post preSend(). + * @see PHPMailer::preSend() + * @access public + * @return string + */ + public function getSentMIMEMessage() + { + return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody; + } + + /** + * Create unique ID + * @return string + */ + protected function generateId() { + return md5(uniqid(time())); + } + + /** + * Assemble the message body. + * Returns an empty string on failure. + * @access public + * @throws phpmailerException + * @return string The assembled message body + */ + public function createBody() + { + $body = ''; + //Create unique IDs and preset boundaries + $this->uniqueid = $this->generateId(); + $this->boundary[1] = 'b1_' . $this->uniqueid; + $this->boundary[2] = 'b2_' . $this->uniqueid; + $this->boundary[3] = 'b3_' . $this->uniqueid; + + if ($this->sign_key_file) { + $body .= $this->getMailMIME() . $this->LE; + } + + $this->setWordWrap(); + + $bodyEncoding = $this->Encoding; + $bodyCharSet = $this->CharSet; + //Can we do a 7-bit downgrade? + if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) { + $bodyEncoding = '7bit'; + //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit + $bodyCharSet = 'us-ascii'; + } + //If lines are too long, and we're not already using an encoding that will shorten them, + //change to quoted-printable transfer encoding for the body part only + if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) { + $bodyEncoding = 'quoted-printable'; + } + + $altBodyEncoding = $this->Encoding; + $altBodyCharSet = $this->CharSet; + //Can we do a 7-bit downgrade? + if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) { + $altBodyEncoding = '7bit'; + //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit + $altBodyCharSet = 'us-ascii'; + } + //If lines are too long, and we're not already using an encoding that will shorten them, + //change to quoted-printable transfer encoding for the alt body part only + if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) { + $altBodyEncoding = 'quoted-printable'; + } + //Use this as a preamble in all multipart message types + $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE; + switch ($this->message_type) { + case 'inline': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[1]); + break; + case 'attach': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'inline_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'alt': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + if (!empty($this->Ical)) { + $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', ''); + $body .= $this->encodeString($this->Ical, $this->Encoding); + $body .= $this->LE . $this->LE; + } + $body .= $this->endBoundary($this->boundary[1]); + break; + case 'alt_inline': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[2]); + $body .= $this->LE; + $body .= $this->endBoundary($this->boundary[1]); + break; + case 'alt_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->endBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'alt_inline_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->textLine('--' . $this->boundary[2]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[3]); + $body .= $this->LE; + $body .= $this->endBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + default: + // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types + //Reset the `Encoding` property in case we changed it for line length reasons + $this->Encoding = $bodyEncoding; + $body .= $this->encodeString($this->Body, $this->Encoding); + break; + } + + if ($this->isError()) { + $body = ''; + } elseif ($this->sign_key_file) { + try { + if (!defined('PKCS7_TEXT')) { + throw new phpmailerException($this->lang('extension_missing') . 'openssl'); + } + // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 + $file = tempnam(sys_get_temp_dir(), 'mail'); + if (false === file_put_contents($file, $body)) { + throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); + } + $signed = tempnam(sys_get_temp_dir(), 'signed'); + //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 + if (empty($this->sign_extracerts_file)) { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null + ); + } else { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null, + PKCS7_DETACHED, + $this->sign_extracerts_file + ); + } + if ($sign) { + @unlink($file); + $body = file_get_contents($signed); + @unlink($signed); + //The message returned by openssl contains both headers and body, so need to split them up + $parts = explode("\n\n", $body, 2); + $this->MIMEHeader .= $parts[0] . $this->LE . $this->LE; + $body = $parts[1]; + } else { + @unlink($file); + @unlink($signed); + throw new phpmailerException($this->lang('signing') . openssl_error_string()); + } + } catch (phpmailerException $exc) { + $body = ''; + if ($this->exceptions) { + throw $exc; + } + } + } + return $body; + } + + /** + * Return the start of a message boundary. + * @access protected + * @param string $boundary + * @param string $charSet + * @param string $contentType + * @param string $encoding + * @return string + */ + protected function getBoundary($boundary, $charSet, $contentType, $encoding) + { + $result = ''; + if ($charSet == '') { + $charSet = $this->CharSet; + } + if ($contentType == '') { + $contentType = $this->ContentType; + } + if ($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->textLine('--' . $boundary); + $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); + $result .= $this->LE; + // RFC1341 part 5 says 7bit is assumed if not specified + if ($encoding != '7bit') { + $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); + } + $result .= $this->LE; + + return $result; + } + + /** + * Return the end of a message boundary. + * @access protected + * @param string $boundary + * @return string + */ + protected function endBoundary($boundary) + { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Set the message type. + * PHPMailer only supports some preset message types, not arbitrary MIME structures. + * @access protected + * @return void + */ + protected function setMessageType() + { + $type = array(); + if ($this->alternativeExists()) { + $type[] = 'alt'; + } + if ($this->inlineImageExists()) { + $type[] = 'inline'; + } + if ($this->attachmentExists()) { + $type[] = 'attach'; + } + $this->message_type = implode('_', $type); + if ($this->message_type == '') { + //The 'plain' message_type refers to the message having a single body element, not that it is plain-text + $this->message_type = 'plain'; + } + } + + /** + * Format a header line. + * @access public + * @param string $name + * @param string $value + * @return string + */ + public function headerLine($name, $value) + { + return $name . ': ' . $value . $this->LE; + } + + /** + * Return a formatted mail line. + * @access public + * @param string $value + * @return string + */ + public function textLine($value) + { + return $value . $this->LE; + } + + /** + * Add an attachment from a path on the filesystem. + * Never use a user-supplied path to a file! + * Returns false if the file could not be found or read. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @param string $disposition Disposition to use + * @throws phpmailerException + * @return boolean + */ + public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') + { + try { + if (!@is_file($path)) { + throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); + } + + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($path); + } + + $filename = basename($path); + if ($name == '') { + $name = $filename; + } + + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => $disposition, + 7 => 0 + ); + + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + return true; + } + + /** + * Return the array of attachments. + * @return array + */ + public function getAttachments() + { + return $this->attachment; + } + + /** + * Attach all file, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access protected + * @param string $disposition_type + * @param string $boundary + * @return string + */ + protected function attachAll($disposition_type, $boundary) + { + // Return text of body + $mime = array(); + $cidUniq = array(); + $incl = array(); + + // Add all attachments + foreach ($this->attachment as $attachment) { + // Check if it is a valid disposition_filter + if ($attachment[6] == $disposition_type) { + // Check for string attachment + $string = ''; + $path = ''; + $bString = $attachment[5]; + if ($bString) { + $string = $attachment[0]; + } else { + $path = $attachment[0]; + } + + $inclhash = md5(serialize($attachment)); + if (in_array($inclhash, $incl)) { + continue; + } + $incl[] = $inclhash; + $name = $attachment[2]; + $encoding = $attachment[3]; + $type = $attachment[4]; + $disposition = $attachment[6]; + $cid = $attachment[7]; + if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) { + continue; + } + $cidUniq[$cid] = true; + + $mime[] = sprintf('--%s%s', $boundary, $this->LE); + //Only include a filename property if we have one + if (!empty($name)) { + $mime[] = sprintf( + 'Content-Type: %s; name="%s"%s', + $type, + $this->encodeHeader($this->secureHeader($name)), + $this->LE + ); + } else { + $mime[] = sprintf( + 'Content-Type: %s%s', + $type, + $this->LE + ); + } + // RFC1341 part 5 says 7bit is assumed if not specified + if ($encoding != '7bit') { + $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE); + } + + if ($disposition == 'inline') { + $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE); + } + + // If a filename contains any of these chars, it should be quoted, + // but not otherwise: RFC2183 & RFC2045 5.1 + // Fixes a warning in IETF's msglint MIME checker + // Allow for bypassing the Content-Disposition header totally + if (!(empty($disposition))) { + $encoded_name = $this->encodeHeader($this->secureHeader($name)); + if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) { + $mime[] = sprintf( + 'Content-Disposition: %s; filename="%s"%s', + $disposition, + $encoded_name, + $this->LE . $this->LE + ); + } else { + if (!empty($encoded_name)) { + $mime[] = sprintf( + 'Content-Disposition: %s; filename=%s%s', + $disposition, + $encoded_name, + $this->LE . $this->LE + ); + } else { + $mime[] = sprintf( + 'Content-Disposition: %s%s', + $disposition, + $this->LE . $this->LE + ); + } + } + } else { + $mime[] = $this->LE; + } + + // Encode as string attachment + if ($bString) { + $mime[] = $this->encodeString($string, $encoding); + if ($this->isError()) { + return ''; + } + $mime[] = $this->LE . $this->LE; + } else { + $mime[] = $this->encodeFile($path, $encoding); + if ($this->isError()) { + return ''; + } + $mime[] = $this->LE . $this->LE; + } + } + } + + $mime[] = sprintf('--%s--%s', $boundary, $this->LE); + + return implode('', $mime); + } + + /** + * Encode a file attachment in requested format. + * Returns an empty string on failure. + * @param string $path The full path to the file + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @throws phpmailerException + * @access protected + * @return string + */ + protected function encodeFile($path, $encoding = 'base64') + { + try { + if (!is_readable($path)) { + throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE); + } + $magic_quotes = get_magic_quotes_runtime(); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime(false); + } else { + //Doesn't exist in PHP 5.4, but we don't need to check because + //get_magic_quotes_runtime always returns false in 5.4+ + //so it will never get here + ini_set('magic_quotes_runtime', false); + } + } + $file_buffer = file_get_contents($path); + $file_buffer = $this->encodeString($file_buffer, $encoding); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime($magic_quotes); + } else { + ini_set('magic_quotes_runtime', $magic_quotes); + } + } + return $file_buffer; + } catch (Exception $exc) { + $this->setError($exc->getMessage()); + return ''; + } + } + + /** + * Encode a string in requested format. + * Returns an empty string on failure. + * @param string $str The text to encode + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @access public + * @return string + */ + public function encodeString($str, $encoding = 'base64') + { + $encoded = ''; + switch (strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->fixEOL($str); + // Make sure it ends with a line break + if (substr($encoded, -(strlen($this->LE))) != $this->LE) { + $encoded .= $this->LE; + } + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->encodeQP($str); + break; + default: + $this->setError($this->lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string optimally. + * Picks shortest of Q, B, quoted-printable or none. + * @access public + * @param string $str + * @param string $position + * @return string + */ + public function encodeHeader($str, $position = 'text') + { + $matchcount = 0; + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + // Can't use addslashes as we don't know the value of magic_quotes_sybase + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + /** @noinspection PhpMissingBreakStatementInspection */ + case 'comment': + $matchcount = preg_match_all('/[()"]/', $str, $matches); + // Intentional fall-through + case 'text': + default: + $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + //There are no chars that need encoding + if ($matchcount == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + // Try to select the encoding which should produce the shortest output + if ($matchcount > strlen($str) / 3) { + // More than a third of the content will need encoding, so B encoding will be most efficient + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->base64EncodeWrapMB($str, "\n"); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->encodeQ($str, $position); + $encoded = $this->wrapText($encoded, $maxlen, true); + $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Check if a string contains multi-byte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return boolean + */ + public function hasMultiBytes($str) + { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return false; + } + } + + /** + * Does a string contain any 8-bit chars (in any charset)? + * @param string $text + * @return boolean + */ + public function has8bitChars($text) + { + return (boolean)preg_match('/[\x80-\xFF]/', $text); + } + + /** + * Encode and wrap long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid + * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283 + * @access public + * @param string $str multi-byte text to wrap encode + * @param string $linebreak string to use as linefeed/end-of-line + * @return string + */ + public function base64EncodeWrapMB($str, $linebreak = null) + { + $start = '=?' . $this->CharSet . '?B?'; + $end = '?='; + $encoded = ''; + if ($linebreak === null) { + $linebreak = $this->LE; + } + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } while (strlen($chunk) > $length); + $encoded .= $chunk . $linebreak; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($linebreak)); + return $encoded; + } + + /** + * Encode a string in quoted-printable format. + * According to RFC2045 section 6.7. + * @access public + * @param string $string The text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment + */ + public function encodeQP($string, $line_max = 76) + { + // Use native function if it's available (>= PHP5.3) + if (function_exists('quoted_printable_encode')) { + return quoted_printable_encode($string); + } + // Fall back to a pure PHP implementation + $string = str_replace( + array('%20', '%0D%0A.', '%0D%0A', '%'), + array(' ', "\r\n=2E", "\r\n", '='), + rawurlencode($string) + ); + return preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string); + } + + /** + * Backward compatibility wrapper for an old QP encoding function that was removed. + * @see PHPMailer::encodeQP() + * @access public + * @param string $string + * @param integer $line_max + * @param boolean $space_conv + * @return string + * @deprecated Use encodeQP instead. + */ + public function encodeQPphp( + $string, + $line_max = 76, + /** @noinspection PhpUnusedParameterInspection */ $space_conv = false + ) { + return $this->encodeQP($string, $line_max); + } + + /** + * Encode a string using Q encoding. + * @link http://tools.ietf.org/html/rfc2047 + * @param string $str the text to encode + * @param string $position Where the text is going to be used, see the RFC for what that means + * @access public + * @return string + */ + public function encodeQ($str, $position = 'text') + { + // There should not be any EOL in the string + $pattern = ''; + $encoded = str_replace(array("\r", "\n"), '', $str); + switch (strtolower($position)) { + case 'phrase': + // RFC 2047 section 5.3 + $pattern = '^A-Za-z0-9!*+\/ -'; + break; + /** @noinspection PhpMissingBreakStatementInspection */ + case 'comment': + // RFC 2047 section 5.2 + $pattern = '\(\)"'; + // intentional fall-through + // for this reason we build the $pattern without including delimiters and [] + case 'text': + default: + // RFC 2047 section 5.1 + // Replace every high ascii, control, =, ? and _ characters + $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; + break; + } + $matches = array(); + if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { + // If the string contains an '=', make sure it's the first thing we replace + // so as to avoid double-encoding + $eqkey = array_search('=', $matches[0]); + if (false !== $eqkey) { + unset($matches[0][$eqkey]); + array_unshift($matches[0], '='); + } + foreach (array_unique($matches[0]) as $char) { + $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); + } + } + // Replace every spaces to _ (more readable than =20) + return str_replace(' ', '_', $encoded); + } + + /** + * Add a string or binary attachment (non-filesystem). + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @param string $disposition Disposition to use + * @return void + */ + public function addStringAttachment( + $string, + $filename, + $encoding = 'base64', + $type = '', + $disposition = 'attachment' + ) { + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($filename); + } + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => $disposition, + 7 => 0 + ); + } + + /** + * Add an embedded (inline) attachment from a file. + * This can include images, sounds, and just about any other document type. + * These differ from 'regular' attachments in that they are intended to be + * displayed inline with the message, not just attached for download. + * This is used in HTML messages that embed the images + * the HTML refers to using the $cid value. + * Never use a user-supplied path to a file! + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment; Use this to reference + * the content when using an embedded image in HTML. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File MIME type. + * @param string $disposition Disposition to use + * @return boolean True on successfully adding an attachment + */ + public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') + { + if (!@is_file($path)) { + $this->setError($this->lang('file_access') . $path); + return false; + } + + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($path); + } + + $filename = basename($path); + if ($name == '') { + $name = $filename; + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => $disposition, + 7 => $cid + ); + return true; + } + + /** + * Add an embedded stringified attachment. + * This can include images, sounds, and just about any other document type. + * Be sure to set the $type to an image type for images: + * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'. + * @param string $string The attachment binary data. + * @param string $cid Content ID of the attachment; Use this to reference + * the content when using an embedded image in HTML. + * @param string $name + * @param string $encoding File encoding (see $Encoding). + * @param string $type MIME type. + * @param string $disposition Disposition to use + * @return boolean True on successfully adding an attachment + */ + public function addStringEmbeddedImage( + $string, + $cid, + $name = '', + $encoding = 'base64', + $type = '', + $disposition = 'inline' + ) { + // If a MIME type is not specified, try to work it out from the name + if ($type == '' and !empty($name)) { + $type = self::filenameToType($name); + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $name, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => $disposition, + 7 => $cid + ); + return true; + } + + /** + * Check if an inline attachment is present. + * @access public + * @return boolean + */ + public function inlineImageExists() + { + foreach ($this->attachment as $attachment) { + if ($attachment[6] == 'inline') { + return true; + } + } + return false; + } + + /** + * Check if an attachment (non-inline) is present. + * @return boolean + */ + public function attachmentExists() + { + foreach ($this->attachment as $attachment) { + if ($attachment[6] == 'attachment') { + return true; + } + } + return false; + } + + /** + * Check if this message has an alternative body set. + * @return boolean + */ + public function alternativeExists() + { + return !empty($this->AltBody); + } + + /** + * Clear queued addresses of given kind. + * @access protected + * @param string $kind 'to', 'cc', or 'bcc' + * @return void + */ + public function clearQueuedAddresses($kind) + { + $RecipientsQueue = $this->RecipientsQueue; + foreach ($RecipientsQueue as $address => $params) { + if ($params[0] == $kind) { + unset($this->RecipientsQueue[$address]); + } + } + } + + /** + * Clear all To recipients. + * @return void + */ + public function clearAddresses() + { + foreach ($this->to as $to) { + unset($this->all_recipients[strtolower($to[0])]); + } + $this->to = array(); + $this->clearQueuedAddresses('to'); + } + + /** + * Clear all CC recipients. + * @return void + */ + public function clearCCs() + { + foreach ($this->cc as $cc) { + unset($this->all_recipients[strtolower($cc[0])]); + } + $this->cc = array(); + $this->clearQueuedAddresses('cc'); + } + + /** + * Clear all BCC recipients. + * @return void + */ + public function clearBCCs() + { + foreach ($this->bcc as $bcc) { + unset($this->all_recipients[strtolower($bcc[0])]); + } + $this->bcc = array(); + $this->clearQueuedAddresses('bcc'); + } + + /** + * Clear all ReplyTo recipients. + * @return void + */ + public function clearReplyTos() + { + $this->ReplyTo = array(); + $this->ReplyToQueue = array(); + } + + /** + * Clear all recipient types. + * @return void + */ + public function clearAllRecipients() + { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + $this->all_recipients = array(); + $this->RecipientsQueue = array(); + } + + /** + * Clear all filesystem, string, and binary attachments. + * @return void + */ + public function clearAttachments() + { + $this->attachment = array(); + } + + /** + * Clear all custom headers. + * @return void + */ + public function clearCustomHeaders() + { + $this->CustomHeader = array(); + } + + /** + * Add an error message to the error container. + * @access protected + * @param string $msg + * @return void + */ + protected function setError($msg) + { + $this->error_count++; + if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { + $lasterror = $this->smtp->getError(); + if (!empty($lasterror['error'])) { + $msg .= $this->lang('smtp_error') . $lasterror['error']; + if (!empty($lasterror['detail'])) { + $msg .= ' Detail: '. $lasterror['detail']; + } + if (!empty($lasterror['smtp_code'])) { + $msg .= ' SMTP code: ' . $lasterror['smtp_code']; + } + if (!empty($lasterror['smtp_code_ex'])) { + $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; + } + } + } + $this->ErrorInfo = $msg; + } + + /** + * Return an RFC 822 formatted date. + * @access public + * @return string + * @static + */ + public static function rfcDate() + { + // Set the time zone to whatever the default is to avoid 500 errors + // Will default to UTC if it's not set properly in php.ini + date_default_timezone_set(@date_default_timezone_get()); + return date('D, j M Y H:i:s O'); + } + + /** + * Get the server hostname. + * Returns 'localhost.localdomain' if unknown. + * @access protected + * @return string + */ + protected function serverHostname() + { + $result = 'localhost.localdomain'; + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } elseif (function_exists('gethostname') && gethostname() !== false) { + $result = gethostname(); + } elseif (php_uname('n') !== false) { + $result = php_uname('n'); + } + return $result; + } + + /** + * Get an error message in the current language. + * @access protected + * @param string $key + * @return string + */ + protected function lang($key) + { + if (count($this->language) < 1) { + $this->setLanguage('en'); // set the default language + } + + if (array_key_exists($key, $this->language)) { + if ($key == 'smtp_connect_failed') { + //Include a link to troubleshooting docs on SMTP connection failure + //this is by far the biggest cause of support questions + //but it's usually not PHPMailer's fault. + return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; + } + return $this->language[$key]; + } else { + //Return the key as a fallback + return $key; + } + } + + /** + * Check if an error occurred. + * @access public + * @return boolean True if an error did occur. + */ + public function isError() + { + return ($this->error_count > 0); + } + + /** + * Ensure consistent line endings in a string. + * Changes every end of line from CRLF, CR or LF to $this->LE. + * @access public + * @param string $str String to fixEOL + * @return string + */ + public function fixEOL($str) + { + // Normalise to \n + $nstr = str_replace(array("\r\n", "\r"), "\n", $str); + // Now convert LE as needed + if ($this->LE !== "\n") { + $nstr = str_replace("\n", $this->LE, $nstr); + } + return $nstr; + } + + /** + * Add a custom header. + * $name value can be overloaded to contain + * both header name and value (name:value) + * @access public + * @param string $name Custom header name + * @param string $value Header value + * @return void + */ + public function addCustomHeader($name, $value = null) + { + if ($value === null) { + // Value passed in as name:value + $this->CustomHeader[] = explode(':', $name, 2); + } else { + $this->CustomHeader[] = array($name, $value); + } + } + + /** + * Returns all custom headers. + * @return array + */ + public function getCustomHeaders() + { + return $this->CustomHeader; + } + + /** + * Create a message body from an HTML string. + * Automatically inlines images and creates a plain-text version by converting the HTML, + * overwriting any existing values in Body and AltBody. + * Do not source $message content from user input! + * $basedir is prepended when handling relative URLs, e.g. <img src="/images/a.png"> and must not be empty + * will look for an image file in $basedir/images/a.png and convert it to inline. + * If you don't provide a $basedir, relative paths will be left untouched (and thus probably break in email) + * If you don't want to apply these transformations to your HTML, just set Body and AltBody directly. + * @access public + * @param string $message HTML message string + * @param string $basedir Absolute path to a base directory to prepend to relative paths to images + * @param boolean|callable $advanced Whether to use the internal HTML to text converter + * or your own custom converter @see PHPMailer::html2text() + * @return string $message The transformed message Body + */ + public function msgHTML($message, $basedir = '', $advanced = false) + { + preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images); + if (array_key_exists(2, $images)) { + if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { + // Ensure $basedir has a trailing / + $basedir .= '/'; + } + foreach ($images[2] as $imgindex => $url) { + // Convert data URIs into embedded images + if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) { + $data = substr($url, strpos($url, ',')); + if ($match[2]) { + $data = base64_decode($data); + } else { + $data = rawurldecode($data); + } + $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 + if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) { + $message = str_replace( + $images[0][$imgindex], + $images[1][$imgindex] . '="cid:' . $cid . '"', + $message + ); + } + continue; + } + if ( + // Only process relative URLs if a basedir is provided (i.e. no absolute local paths) + !empty($basedir) + // Ignore URLs containing parent dir traversal (..) + && (strpos($url, '..') === false) + // Do not change urls that are already inline images + && substr($url, 0, 4) !== 'cid:' + // Do not change absolute URLs, including anonymous protocol + && !preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url) + ) { + $filename = basename($url); + $directory = dirname($url); + if ($directory == '.') { + $directory = ''; + } + $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 + if (strlen($directory) > 1 && substr($directory, -1) != '/') { + $directory .= '/'; + } + if ($this->addEmbeddedImage( + $basedir . $directory . $filename, + $cid, + $filename, + 'base64', + self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION)) + ) + ) { + $message = preg_replace( + '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', + $images[1][$imgindex] . '="cid:' . $cid . '"', + $message + ); + } + } + } + } + $this->isHTML(true); + // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better + $this->Body = $this->normalizeBreaks($message); + $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced)); + if (!$this->alternativeExists()) { + $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . + self::CRLF . self::CRLF; + } + return $this->Body; + } + + /** + * Convert an HTML string into plain text. + * This is used by msgHTML(). + * Note - older versions of this function used a bundled advanced converter + * which was been removed for license reasons in #232. + * Example usage: + * <code> + * // Use default conversion + * $plain = $mail->html2text($html); + * // Use your own custom converter + * $plain = $mail->html2text($html, function($html) { + * $converter = new MyHtml2text($html); + * return $converter->get_text(); + * }); + * </code> + * @param string $html The HTML text to convert + * @param boolean|callable $advanced Any boolean value to use the internal converter, + * or provide your own callable for custom conversion. + * @return string + */ + public function html2text($html, $advanced = false) + { + if (is_callable($advanced)) { + return call_user_func($advanced, $html); + } + return html_entity_decode( + trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), + ENT_QUOTES, + $this->CharSet + ); + } + + /** + * Get the MIME type for a file extension. + * @param string $ext File extension + * @access public + * @return string MIME type of file. + * @static + */ + public static function _mime_types($ext = '') + { + $mimes = array( + 'xl' => 'application/excel', + 'js' => 'application/javascript', + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'bin' => 'application/macbinary', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'class' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mpga' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'eml' => 'message/rfc822', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'log' => 'text/plain', + 'text' => 'text/plain', + 'txt' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'vcf' => 'text/vcard', + 'vcard' => 'text/vcard', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mov' => 'video/quicktime', + 'qt' => 'video/quicktime', + 'rv' => 'video/vnd.rn-realvideo', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie' + ); + if (array_key_exists(strtolower($ext), $mimes)) { + return $mimes[strtolower($ext)]; + } + return 'application/octet-stream'; + } + + /** + * Map a file name to a MIME type. + * Defaults to 'application/octet-stream', i.e.. arbitrary binary data. + * @param string $filename A file name or full path, does not need to exist as a file + * @return string + * @static + */ + public static function filenameToType($filename) + { + // In case the path is a URL, strip any query string before getting extension + $qpos = strpos($filename, '?'); + if (false !== $qpos) { + $filename = substr($filename, 0, $qpos); + } + $pathinfo = self::mb_pathinfo($filename); + return self::_mime_types($pathinfo['extension']); + } + + /** + * Multi-byte-safe pathinfo replacement. + * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe. + * Works similarly to the one in PHP >= 5.2.0 + * @link http://www.php.net/manual/en/function.pathinfo.php#107461 + * @param string $path A filename or path, does not need to exist as a file + * @param integer|string $options Either a PATHINFO_* constant, + * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2 + * @return string|array + * @static + */ + public static function mb_pathinfo($path, $options = null) + { + $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''); + $pathinfo = array(); + if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) { + if (array_key_exists(1, $pathinfo)) { + $ret['dirname'] = $pathinfo[1]; + } + if (array_key_exists(2, $pathinfo)) { + $ret['basename'] = $pathinfo[2]; + } + if (array_key_exists(5, $pathinfo)) { + $ret['extension'] = $pathinfo[5]; + } + if (array_key_exists(3, $pathinfo)) { + $ret['filename'] = $pathinfo[3]; + } + } + switch ($options) { + case PATHINFO_DIRNAME: + case 'dirname': + return $ret['dirname']; + case PATHINFO_BASENAME: + case 'basename': + return $ret['basename']; + case PATHINFO_EXTENSION: + case 'extension': + return $ret['extension']; + case PATHINFO_FILENAME: + case 'filename': + return $ret['filename']; + default: + return $ret; + } + } + + /** + * Set or reset instance properties. + * You should avoid this function - it's more verbose, less efficient, more error-prone and + * harder to debug than setting properties directly. + * Usage Example: + * `$mail->set('SMTPSecure', 'tls');` + * is the same as: + * `$mail->SMTPSecure = 'tls';` + * @access public + * @param string $name The property name to set + * @param mixed $value The value to set the property to + * @return boolean + * @TODO Should this not be using the __set() magic function? + */ + public function set($name, $value = '') + { + if (property_exists($this, $name)) { + $this->$name = $value; + return true; + } else { + $this->setError($this->lang('variable_set') . $name); + return false; + } + } + + /** + * Strip newlines to prevent header injection. + * @access public + * @param string $str + * @return string + */ + public function secureHeader($str) + { + return trim(str_replace(array("\r", "\n"), '', $str)); + } + + /** + * Normalize line breaks in a string. + * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format. + * Defaults to CRLF (for message bodies) and preserves consecutive breaks. + * @param string $text + * @param string $breaktype What kind of line break to use, defaults to CRLF + * @return string + * @access public + * @static + */ + public static function normalizeBreaks($text, $breaktype = "\r\n") + { + return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text); + } + + /** + * Set the public and private key files and password for S/MIME signing. + * @access public + * @param string $cert_filename + * @param string $key_filename + * @param string $key_pass Password for private key + * @param string $extracerts_filename Optional path to chain certificate + */ + public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') + { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + $this->sign_extracerts_file = $extracerts_filename; + } + + /** + * Quoted-Printable-encode a DKIM header. + * @access public + * @param string $txt + * @return string + */ + public function DKIM_QP($txt) + { + $line = ''; + for ($i = 0; $i < strlen($txt); $i++) { + $ord = ord($txt[$i]); + if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { + $line .= $txt[$i]; + } else { + $line .= '=' . sprintf('%02X', $ord); + } + } + return $line; + } + + /** + * Generate a DKIM signature. + * @access public + * @param string $signHeader + * @throws phpmailerException + * @return string The DKIM signature value + */ + public function DKIM_Sign($signHeader) + { + if (!defined('PKCS7_TEXT')) { + if ($this->exceptions) { + throw new phpmailerException($this->lang('extension_missing') . 'openssl'); + } + return ''; + } + $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); + if ('' != $this->DKIM_passphrase) { + $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); + } else { + $privKey = openssl_pkey_get_private($privKeyStr); + } + //Workaround for missing digest algorithms in old PHP & OpenSSL versions + //@link http://stackoverflow.com/a/11117338/333340 + if (version_compare(PHP_VERSION, '5.3.0') >= 0 and + in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) { + if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) { + openssl_pkey_free($privKey); + return base64_encode($signature); + } + } else { + $pinfo = openssl_pkey_get_details($privKey); + $hash = hash('sha256', $signHeader); + //'Magic' constant for SHA256 from RFC3447 + //@link https://tools.ietf.org/html/rfc3447#page-43 + $t = '3031300d060960864801650304020105000420' . $hash; + $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3); + $eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t); + + if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) { + openssl_pkey_free($privKey); + return base64_encode($signature); + } + } + openssl_pkey_free($privKey); + return ''; + } + + /** + * Generate a DKIM canonicalization header. + * @access public + * @param string $signHeader Header + * @return string + */ + public function DKIM_HeaderC($signHeader) + { + $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader); + $lines = explode("\r\n", $signHeader); + foreach ($lines as $key => $line) { + list($heading, $value) = explode(':', $line, 2); + $heading = strtolower($heading); + $value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces + $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value + } + $signHeader = implode("\r\n", $lines); + return $signHeader; + } + + /** + * Generate a DKIM canonicalization body. + * @access public + * @param string $body Message Body + * @return string + */ + public function DKIM_BodyC($body) + { + if ($body == '') { + return "\r\n"; + } + // stabilize line endings + $body = str_replace("\r\n", "\n", $body); + $body = str_replace("\n", "\r\n", $body); + // END stabilize line endings + while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { + $body = substr($body, 0, strlen($body) - 2); + } + return $body; + } + + /** + * Create the DKIM header and body in a new message header. + * @access public + * @param string $headers_line Header lines + * @param string $subject Subject + * @param string $body Body + * @return string + */ + public function DKIM_Add($headers_line, $subject, $body) + { + $DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms + $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body + $DKIMquery = 'dns/txt'; // Query method + $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) + $subject_header = "Subject: $subject"; + $headers = explode($this->LE, $headers_line); + $from_header = ''; + $to_header = ''; + $date_header = ''; + $current = ''; + foreach ($headers as $header) { + if (strpos($header, 'From:') === 0) { + $from_header = $header; + $current = 'from_header'; + } elseif (strpos($header, 'To:') === 0) { + $to_header = $header; + $current = 'to_header'; + } elseif (strpos($header, 'Date:') === 0) { + $date_header = $header; + $current = 'date_header'; + } else { + if (!empty($$current) && strpos($header, ' =?') === 0) { + $$current .= $header; + } else { + $current = ''; + } + } + } + $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); + $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); + $date = str_replace('|', '=7C', $this->DKIM_QP($date_header)); + $subject = str_replace( + '|', + '=7C', + $this->DKIM_QP($subject_header) + ); // Copied header fields (dkim-quoted-printable) + $body = $this->DKIM_BodyC($body); + $DKIMlen = strlen($body); // Length of body + $DKIMb64 = base64_encode(pack('H*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body + if ('' == $this->DKIM_identity) { + $ident = ''; + } else { + $ident = ' i=' . $this->DKIM_identity . ';'; + } + $dkimhdrs = 'DKIM-Signature: v=1; a=' . + $DKIMsignatureType . '; q=' . + $DKIMquery . '; l=' . + $DKIMlen . '; s=' . + $this->DKIM_selector . + ";\r\n" . + "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . + "\th=From:To:Date:Subject;\r\n" . + "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . + "\tz=$from\r\n" . + "\t|$to\r\n" . + "\t|$date\r\n" . + "\t|$subject;\r\n" . + "\tbh=" . $DKIMb64 . ";\r\n" . + "\tb="; + $toSign = $this->DKIM_HeaderC( + $from_header . "\r\n" . + $to_header . "\r\n" . + $date_header . "\r\n" . + $subject_header . "\r\n" . + $dkimhdrs + ); + $signed = $this->DKIM_Sign($toSign); + return $dkimhdrs . $signed . "\r\n"; + } + + /** + * Detect if a string contains a line longer than the maximum line length allowed. + * @param string $str + * @return boolean + * @static + */ + public static function hasLineLongerThanMax($str) + { + //+2 to include CRLF line break for a 1000 total + return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str); + } + + /** + * Allows for public read access to 'to' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getToAddresses() + { + return $this->to; + } + + /** + * Allows for public read access to 'cc' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getCcAddresses() + { + return $this->cc; + } + + /** + * Allows for public read access to 'bcc' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getBccAddresses() + { + return $this->bcc; + } + + /** + * Allows for public read access to 'ReplyTo' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getReplyToAddresses() + { + return $this->ReplyTo; + } + + /** + * Allows for public read access to 'all_recipients' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getAllRecipientAddresses() + { + return $this->all_recipients; + } + + /** + * Perform a callback. + * @param boolean $isSent + * @param array $to + * @param array $cc + * @param array $bcc + * @param string $subject + * @param string $body + * @param string $from + */ + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from) + { + if (!empty($this->action_function) && is_callable($this->action_function)) { + $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); + call_user_func_array($this->action_function, $params); + } + } +} + +/** + * PHPMailer exception handler + * @package PHPMailer + */ +class phpmailerException extends Exception +{ + /** + * Prettify error message output + * @return string + */ + public function errorMessage() + { + $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n"; + return $errorMsg; + } +} diff --git a/backend/wp-includes/class-pop3.php b/backend/wp-includes/class-pop3.php new file mode 100644 index 0000000..7416dd7 --- /dev/null +++ b/backend/wp-includes/class-pop3.php @@ -0,0 +1,662 @@ +<?php +/** + * mail_fetch/setup.php + * + * Copyright (c) 1999-2011 CDI (cdi@thewebmasters.net) All Rights Reserved + * Modified by Philippe Mingo 2001-2009 mingo@rotedic.com + * An RFC 1939 compliant wrapper class for the POP3 protocol. + * + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * POP3 class + * + * @copyright 1999-2011 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @package plugins + * @subpackage mail_fetch + */ + +class POP3 { + var $ERROR = ''; // Error string. + + var $TIMEOUT = 60; // Default timeout before giving up on a + // network operation. + + var $COUNT = -1; // Mailbox msg count + + var $BUFFER = 512; // Socket buffer for socket fgets() calls. + // Per RFC 1939 the returned line a POP3 + // server can send is 512 bytes. + + var $FP = ''; // The connection to the server's + // file descriptor + + var $MAILSERVER = ''; // Set this to hard code the server name + + var $DEBUG = FALSE; // set to true to echo pop3 + // commands and responses to error_log + // this WILL log passwords! + + var $BANNER = ''; // Holds the banner returned by the + // pop server - used for apop() + + var $ALLOWAPOP = FALSE; // Allow or disallow apop() + // This must be set to true + // manually + + /** + * PHP5 constructor. + */ + function __construct ( $server = '', $timeout = '' ) { + settype($this->BUFFER,"integer"); + if( !empty($server) ) { + // Do not allow programs to alter MAILSERVER + // if it is already specified. They can get around + // this if they -really- want to, so don't count on it. + if(empty($this->MAILSERVER)) + $this->MAILSERVER = $server; + } + if(!empty($timeout)) { + settype($timeout,"integer"); + $this->TIMEOUT = $timeout; + if (!ini_get('safe_mode')) + set_time_limit($timeout); + } + return true; + } + + /** + * PHP4 constructor. + */ + public function POP3( $server = '', $timeout = '' ) { + self::__construct( $server, $timeout ); + } + + function update_timer () { + if (!ini_get('safe_mode')) + set_time_limit($this->TIMEOUT); + return true; + } + + function connect ($server, $port = 110) { + // Opens a socket to the specified server. Unless overridden, + // port defaults to 110. Returns true on success, false on fail + + // If MAILSERVER is set, override $server with its value. + + if (!isset($port) || !$port) {$port = 110;} + if(!empty($this->MAILSERVER)) + $server = $this->MAILSERVER; + + if(empty($server)){ + $this->ERROR = "POP3 connect: " . _("No server specified"); + unset($this->FP); + return false; + } + + $fp = @fsockopen("$server", $port, $errno, $errstr); + + if(!$fp) { + $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]"; + unset($this->FP); + return false; + } + + socket_set_blocking($fp,-1); + $this->update_timer(); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) + error_log("POP3 SEND [connect: $server] GOT [$reply]",0); + if(!$this->is_ok($reply)) { + $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]"; + unset($this->FP); + return false; + } + $this->FP = $fp; + $this->BANNER = $this->parse_banner($reply); + return true; + } + + function user ($user = "") { + // Sends the USER command, returns true or false + + if( empty($user) ) { + $this->ERROR = "POP3 user: " . _("no login ID submitted"); + return false; + } elseif(!isset($this->FP)) { + $this->ERROR = "POP3 user: " . _("connection not established"); + return false; + } else { + $reply = $this->send_cmd("USER $user"); + if(!$this->is_ok($reply)) { + $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]"; + return false; + } else + return true; + } + } + + function pass ($pass = "") { + // Sends the PASS command, returns # of msgs in mailbox, + // returns false (undef) on Auth failure + + if(empty($pass)) { + $this->ERROR = "POP3 pass: " . _("No password submitted"); + return false; + } elseif(!isset($this->FP)) { + $this->ERROR = "POP3 pass: " . _("connection not established"); + return false; + } else { + $reply = $this->send_cmd("PASS $pass"); + if(!$this->is_ok($reply)) { + $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]"; + $this->quit(); + return false; + } else { + // Auth successful. + $count = $this->last("count"); + $this->COUNT = $count; + return $count; + } + } + } + + function apop ($login,$pass) { + // Attempts an APOP login. If this fails, it'll + // try a standard login. YOUR SERVER MUST SUPPORT + // THE USE OF THE APOP COMMAND! + // (apop is optional per rfc1939) + + if(!isset($this->FP)) { + $this->ERROR = "POP3 apop: " . _("No connection to server"); + return false; + } elseif(!$this->ALLOWAPOP) { + $retVal = $this->login($login,$pass); + return $retVal; + } elseif(empty($login)) { + $this->ERROR = "POP3 apop: " . _("No login ID submitted"); + return false; + } elseif(empty($pass)) { + $this->ERROR = "POP3 apop: " . _("No password submitted"); + return false; + } else { + $banner = $this->BANNER; + if( (!$banner) or (empty($banner)) ) { + $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort"); + $retVal = $this->login($login,$pass); + return $retVal; + } else { + $AuthString = $banner; + $AuthString .= $pass; + $APOPString = md5($AuthString); + $cmd = "APOP $login $APOPString"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) { + $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort"); + $retVal = $this->login($login,$pass); + return $retVal; + } else { + // Auth successful. + $count = $this->last("count"); + $this->COUNT = $count; + return $count; + } + } + } + } + + function login ($login = "", $pass = "") { + // Sends both user and pass. Returns # of msgs in mailbox or + // false on failure (or -1, if the error occurs while getting + // the number of messages.) + + if( !isset($this->FP) ) { + $this->ERROR = "POP3 login: " . _("No connection to server"); + return false; + } else { + $fp = $this->FP; + if( !$this->user( $login ) ) { + // Preserve the error generated by user() + return false; + } else { + $count = $this->pass($pass); + if( (!$count) || ($count == -1) ) { + // Preserve the error generated by last() and pass() + return false; + } else + return $count; + } + } + } + + function top ($msgNum, $numLines = "0") { + // Gets the header and first $numLines of the msg body + // returns data in an array with each returned line being + // an array element. If $numLines is empty, returns + // only the header information, and none of the body. + + if(!isset($this->FP)) { + $this->ERROR = "POP3 top: " . _("No connection to server"); + return false; + } + $this->update_timer(); + + $fp = $this->FP; + $buffer = $this->BUFFER; + $cmd = "TOP $msgNum $numLines"; + fwrite($fp, "TOP $msgNum $numLines\r\n"); + $reply = fgets($fp, $buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { + @error_log("POP3 SEND [$cmd] GOT [$reply]",0); + } + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]"; + return false; + } + + $count = 0; + $MsgArray = array(); + + $line = fgets($fp,$buffer); + while ( !preg_match('/^\.\r\n/',$line)) + { + $MsgArray[$count] = $line; + $count++; + $line = fgets($fp,$buffer); + if(empty($line)) { break; } + } + + return $MsgArray; + } + + function pop_list ($msgNum = "") { + // If called with an argument, returns that msgs' size in octets + // No argument returns an associative array of undeleted + // msg numbers and their sizes in octets + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 pop_list: " . _("No connection to server"); + return false; + } + $fp = $this->FP; + $Total = $this->COUNT; + if( (!$Total) or ($Total == -1) ) + { + return false; + } + if($Total == 0) + { + return array("0","0"); + // return -1; // mailbox empty + } + + $this->update_timer(); + + if(!empty($msgNum)) + { + $cmd = "LIST $msgNum"; + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { + @error_log("POP3 SEND [$cmd] GOT [$reply]",0); + } + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; + return false; + } + list($junk,$num,$size) = preg_split('/\s+/',$reply); + return $size; + } + $cmd = "LIST"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) + { + $reply = $this->strip_clf($reply); + $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; + return false; + } + $MsgArray = array(); + $MsgArray[0] = $Total; + for($msgC=1;$msgC <= $Total; $msgC++) + { + if($msgC > $Total) { break; } + $line = fgets($fp,$this->BUFFER); + $line = $this->strip_clf($line); + if(strpos($line, '.') === 0) + { + $this->ERROR = "POP3 pop_list: " . _("Premature end of list"); + return false; + } + list($thisMsg,$msgSize) = preg_split('/\s+/',$line); + settype($thisMsg,"integer"); + if($thisMsg != $msgC) + { + $MsgArray[$msgC] = "deleted"; + } + else + { + $MsgArray[$msgC] = $msgSize; + } + } + return $MsgArray; + } + + function get ($msgNum) { + // Retrieve the specified msg number. Returns an array + // where each line of the msg is an array element. + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 get: " . _("No connection to server"); + return false; + } + + $this->update_timer(); + + $fp = $this->FP; + $buffer = $this->BUFFER; + $cmd = "RETR $msgNum"; + $reply = $this->send_cmd($cmd); + + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]"; + return false; + } + + $count = 0; + $MsgArray = array(); + + $line = fgets($fp,$buffer); + while ( !preg_match('/^\.\r\n/',$line)) + { + if ( $line{0} == '.' ) { $line = substr($line,1); } + $MsgArray[$count] = $line; + $count++; + $line = fgets($fp,$buffer); + if(empty($line)) { break; } + } + return $MsgArray; + } + + function last ( $type = "count" ) { + // Returns the highest msg number in the mailbox. + // returns -1 on error, 0+ on success, if type != count + // results in a popstat() call (2 element array returned) + + $last = -1; + if(!isset($this->FP)) + { + $this->ERROR = "POP3 last: " . _("No connection to server"); + return $last; + } + + $reply = $this->send_cmd("STAT"); + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]"; + return $last; + } + + $Vars = preg_split('/\s+/',$reply); + $count = $Vars[1]; + $size = $Vars[2]; + settype($count,"integer"); + settype($size,"integer"); + if($type != "count") + { + return array($count,$size); + } + return $count; + } + + function reset () { + // Resets the status of the remote server. This includes + // resetting the status of ALL msgs to not be deleted. + // This method automatically closes the connection to the server. + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 reset: " . _("No connection to server"); + return false; + } + $reply = $this->send_cmd("RSET"); + if(!$this->is_ok($reply)) + { + // The POP3 RSET command -never- gives a -ERR + // response - if it ever does, something truly + // wild is going on. + + $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]"; + @error_log("POP3 reset: ERROR [$reply]",0); + } + $this->quit(); + return true; + } + + function send_cmd ( $cmd = "" ) + { + // Sends a user defined command string to the + // POP server and returns the results. Useful for + // non-compliant or custom POP servers. + // Do NOT includ the \r\n as part of your command + // string - it will be appended automatically. + + // The return value is a standard fgets() call, which + // will read up to $this->BUFFER bytes of data, until it + // encounters a new line, or EOF, whichever happens first. + + // This method works best if $cmd responds with only + // one line of data. + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 send_cmd: " . _("No connection to server"); + return false; + } + + if(empty($cmd)) + { + $this->ERROR = "POP3 send_cmd: " . _("Empty command string"); + return ""; + } + + $fp = $this->FP; + $buffer = $this->BUFFER; + $this->update_timer(); + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + return $reply; + } + + function quit() { + // Closes the connection to the POP3 server, deleting + // any msgs marked as deleted. + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 quit: " . _("connection does not exist"); + return false; + } + $fp = $this->FP; + $cmd = "QUIT"; + fwrite($fp,"$cmd\r\n"); + $reply = fgets($fp,$this->BUFFER); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + fclose($fp); + unset($this->FP); + return true; + } + + function popstat () { + // Returns an array of 2 elements. The number of undeleted + // msgs in the mailbox, and the size of the mbox in octets. + + $PopArray = $this->last("array"); + + if($PopArray == -1) { return false; } + + if( (!$PopArray) or (empty($PopArray)) ) + { + return false; + } + return $PopArray; + } + + function uidl ($msgNum = "") + { + // Returns the UIDL of the msg specified. If called with + // no arguments, returns an associative array where each + // undeleted msg num is a key, and the msg's uidl is the element + // Array element 0 will contain the total number of msgs + + if(!isset($this->FP)) { + $this->ERROR = "POP3 uidl: " . _("No connection to server"); + return false; + } + + $fp = $this->FP; + $buffer = $this->BUFFER; + + if(!empty($msgNum)) { + $cmd = "UIDL $msgNum"; + $reply = $this->send_cmd($cmd); + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; + return false; + } + list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply); + return $myUidl; + } else { + $this->update_timer(); + + $UIDLArray = array(); + $Total = $this->COUNT; + $UIDLArray[0] = $Total; + + if ($Total < 1) + { + return $UIDLArray; + } + $cmd = "UIDL"; + fwrite($fp, "UIDL\r\n"); + $reply = fgets($fp, $buffer); + $reply = $this->strip_clf($reply); + if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; + return false; + } + + $line = ""; + $count = 1; + $line = fgets($fp,$buffer); + while ( !preg_match('/^\.\r\n/',$line)) { + list ($msg,$msgUidl) = preg_split('/\s+/',$line); + $msgUidl = $this->strip_clf($msgUidl); + if($count == $msg) { + $UIDLArray[$msg] = $msgUidl; + } + else + { + $UIDLArray[$count] = 'deleted'; + } + $count++; + $line = fgets($fp,$buffer); + } + } + return $UIDLArray; + } + + function delete ($msgNum = "") { + // Flags a specified msg as deleted. The msg will not + // be deleted until a quit() method is called. + + if(!isset($this->FP)) + { + $this->ERROR = "POP3 delete: " . _("No connection to server"); + return false; + } + if(empty($msgNum)) + { + $this->ERROR = "POP3 delete: " . _("No msg number submitted"); + return false; + } + $reply = $this->send_cmd("DELE $msgNum"); + if(!$this->is_ok($reply)) + { + $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]"; + return false; + } + return true; + } + + // ********************************************************* + + // The following methods are internal to the class. + + function is_ok ($cmd = "") { + // Return true or false on +OK or -ERR + + if( empty($cmd) ) + return false; + else + return( stripos($cmd, '+OK') !== false ); + } + + function strip_clf ($text = "") { + // Strips \r\n from server responses + + if(empty($text)) + return $text; + else { + $stripped = str_replace(array("\r","\n"),'',$text); + return $stripped; + } + } + + function parse_banner ( $server_text ) { + $outside = true; + $banner = ""; + $length = strlen($server_text); + for($count =0; $count < $length; $count++) + { + $digit = substr($server_text,$count,1); + if(!empty($digit)) { + if( (!$outside) && ($digit != '<') && ($digit != '>') ) + { + $banner .= $digit; + } + if ($digit == '<') + { + $outside = false; + } + if($digit == '>') + { + $outside = true; + } + } + } + $banner = $this->strip_clf($banner); // Just in case + return "<$banner>"; + } + +} // End class + +// For php4 compatibility +if (!function_exists("stripos")) { + function stripos($haystack, $needle){ + return strpos($haystack, stristr( $haystack, $needle )); + } +} diff --git a/backend/wp-includes/class-requests.php b/backend/wp-includes/class-requests.php new file mode 100644 index 0000000..bb26618 --- /dev/null +++ b/backend/wp-includes/class-requests.php @@ -0,0 +1,980 @@ +<?php +/** + * Requests for PHP + * + * Inspired by Requests for Python. + * + * Based on concepts from SimplePie_File, RequestCore and WP_Http. + * + * @package Requests + */ + +/** + * Requests for PHP + * + * Inspired by Requests for Python. + * + * Based on concepts from SimplePie_File, RequestCore and WP_Http. + * + * @package Requests + */ +class Requests { + /** + * POST method + * + * @var string + */ + const POST = 'POST'; + + /** + * PUT method + * + * @var string + */ + const PUT = 'PUT'; + + /** + * GET method + * + * @var string + */ + const GET = 'GET'; + + /** + * HEAD method + * + * @var string + */ + const HEAD = 'HEAD'; + + /** + * DELETE method + * + * @var string + */ + const DELETE = 'DELETE'; + + /** + * OPTIONS method + * + * @var string + */ + const OPTIONS = 'OPTIONS'; + + /** + * TRACE method + * + * @var string + */ + const TRACE = 'TRACE'; + + /** + * PATCH method + * + * @link https://tools.ietf.org/html/rfc5789 + * @var string + */ + const PATCH = 'PATCH'; + + /** + * Default size of buffer size to read streams + * + * @var integer + */ + const BUFFER_SIZE = 1160; + + /** + * Current version of Requests + * + * @var string + */ + const VERSION = '1.7'; + + /** + * Registered transport classes + * + * @var array + */ + protected static $transports = array(); + + /** + * Selected transport name + * + * Use {@see get_transport()} instead + * + * @var array + */ + public static $transport = array(); + + /** + * Default certificate path. + * + * @see Requests::get_certificate_path() + * @see Requests::set_certificate_path() + * + * @var string + */ + protected static $certificate_path; + + /** + * This is a static class, do not instantiate it + * + * @codeCoverageIgnore + */ + private function __construct() {} + + /** + * Autoloader for Requests + * + * Register this with {@see register_autoloader()} if you'd like to avoid + * having to create your own. + * + * (You can also use `spl_autoload_register` directly if you'd prefer.) + * + * @codeCoverageIgnore + * + * @param string $class Class name to load + */ + public static function autoloader($class) { + // Check that the class starts with "Requests" + if (strpos($class, 'Requests') !== 0) { + return; + } + + $file = str_replace('_', '/', $class); + if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) { + require_once(dirname(__FILE__) . '/' . $file . '.php'); + } + } + + /** + * Register the built-in autoloader + * + * @codeCoverageIgnore + */ + public static function register_autoloader() { + spl_autoload_register(array('Requests', 'autoloader')); + } + + /** + * Register a transport + * + * @param string $transport Transport class to add, must support the Requests_Transport interface + */ + public static function add_transport($transport) { + if (empty(self::$transports)) { + self::$transports = array( + 'Requests_Transport_cURL', + 'Requests_Transport_fsockopen', + ); + } + + self::$transports = array_merge(self::$transports, array($transport)); + } + + /** + * Get a working transport + * + * @throws Requests_Exception If no valid transport is found (`notransport`) + * @return Requests_Transport + */ + protected static function get_transport($capabilities = array()) { + // Caching code, don't bother testing coverage + // @codeCoverageIgnoreStart + // array of capabilities as a string to be used as an array key + ksort($capabilities); + $cap_string = serialize($capabilities); + + // Don't search for a transport if it's already been done for these $capabilities + if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { + return new self::$transport[$cap_string](); + } + // @codeCoverageIgnoreEnd + + if (empty(self::$transports)) { + self::$transports = array( + 'Requests_Transport_cURL', + 'Requests_Transport_fsockopen', + ); + } + + // Find us a working transport + foreach (self::$transports as $class) { + if (!class_exists($class)) { + continue; + } + + $result = call_user_func(array($class, 'test'), $capabilities); + if ($result) { + self::$transport[$cap_string] = $class; + break; + } + } + if (self::$transport[$cap_string] === null) { + throw new Requests_Exception('No working transports found', 'notransport', self::$transports); + } + + return new self::$transport[$cap_string](); + } + + /**#@+ + * @see request() + * @param string $url + * @param array $headers + * @param array $options + * @return Requests_Response + */ + /** + * Send a GET request + */ + public static function get($url, $headers = array(), $options = array()) { + return self::request($url, $headers, null, self::GET, $options); + } + + /** + * Send a HEAD request + */ + public static function head($url, $headers = array(), $options = array()) { + return self::request($url, $headers, null, self::HEAD, $options); + } + + /** + * Send a DELETE request + */ + public static function delete($url, $headers = array(), $options = array()) { + return self::request($url, $headers, null, self::DELETE, $options); + } + + /** + * Send a TRACE request + */ + public static function trace($url, $headers = array(), $options = array()) { + return self::request($url, $headers, null, self::TRACE, $options); + } + /**#@-*/ + + /**#@+ + * @see request() + * @param string $url + * @param array $headers + * @param array $data + * @param array $options + * @return Requests_Response + */ + /** + * Send a POST request + */ + public static function post($url, $headers = array(), $data = array(), $options = array()) { + return self::request($url, $headers, $data, self::POST, $options); + } + /** + * Send a PUT request + */ + public static function put($url, $headers = array(), $data = array(), $options = array()) { + return self::request($url, $headers, $data, self::PUT, $options); + } + + /** + * Send an OPTIONS request + */ + public static function options($url, $headers = array(), $data = array(), $options = array()) { + return self::request($url, $headers, $data, self::OPTIONS, $options); + } + + /** + * Send a PATCH request + * + * Note: Unlike {@see post} and {@see put}, `$headers` is required, as the + * specification recommends that should send an ETag + * + * @link https://tools.ietf.org/html/rfc5789 + */ + public static function patch($url, $headers, $data = array(), $options = array()) { + return self::request($url, $headers, $data, self::PATCH, $options); + } + /**#@-*/ + + /** + * Main interface for HTTP requests + * + * This method initiates a request and sends it via a transport before + * parsing. + * + * The `$options` parameter takes an associative array with the following + * options: + * + * - `timeout`: How long should we wait for a response? + * Note: for cURL, a minimum of 1 second applies, as DNS resolution + * operates at second-resolution only. + * (float, seconds with a millisecond precision, default: 10, example: 0.01) + * - `connect_timeout`: How long should we wait while trying to connect? + * (float, seconds with a millisecond precision, default: 10, example: 0.01) + * - `useragent`: Useragent to send to the server + * (string, default: php-requests/$version) + * - `follow_redirects`: Should we follow 3xx redirects? + * (boolean, default: true) + * - `redirects`: How many times should we redirect before erroring? + * (integer, default: 10) + * - `blocking`: Should we block processing on this request? + * (boolean, default: true) + * - `filename`: File to stream the body to instead. + * (string|boolean, default: false) + * - `auth`: Authentication handler or array of user/password details to use + * for Basic authentication + * (Requests_Auth|array|boolean, default: false) + * - `proxy`: Proxy details to use for proxy by-passing and authentication + * (Requests_Proxy|array|string|boolean, default: false) + * - `max_bytes`: Limit for the response body size. + * (integer|boolean, default: false) + * - `idn`: Enable IDN parsing + * (boolean, default: true) + * - `transport`: Custom transport. Either a class name, or a + * transport object. Defaults to the first working transport from + * {@see getTransport()} + * (string|Requests_Transport, default: {@see getTransport()}) + * - `hooks`: Hooks handler. + * (Requests_Hooker, default: new Requests_Hooks()) + * - `verify`: Should we verify SSL certificates? Allows passing in a custom + * certificate file as a string. (Using true uses the system-wide root + * certificate store instead, but this may have different behaviour + * across transports.) + * (string|boolean, default: library/Requests/Transport/cacert.pem) + * - `verifyname`: Should we verify the common name in the SSL certificate? + * (boolean: default, true) + * - `data_format`: How should we send the `$data` parameter? + * (string, one of 'query' or 'body', default: 'query' for + * HEAD/GET/DELETE, 'body' for POST/PUT/OPTIONS/PATCH) + * + * @throws Requests_Exception On invalid URLs (`nonhttp`) + * + * @param string $url URL to request + * @param array $headers Extra headers to send with the request + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param string $type HTTP request type (use Requests constants) + * @param array $options Options for the request (see description for more information) + * @return Requests_Response + */ + public static function request($url, $headers = array(), $data = array(), $type = self::GET, $options = array()) { + if (empty($options['type'])) { + $options['type'] = $type; + } + $options = array_merge(self::get_default_options(), $options); + + self::set_defaults($url, $headers, $data, $type, $options); + + $options['hooks']->dispatch('requests.before_request', array(&$url, &$headers, &$data, &$type, &$options)); + + if (!empty($options['transport'])) { + $transport = $options['transport']; + + if (is_string($options['transport'])) { + $transport = new $transport(); + } + } + else { + $need_ssl = (0 === stripos($url, 'https://')); + $capabilities = array('ssl' => $need_ssl); + $transport = self::get_transport($capabilities); + } + $response = $transport->request($url, $headers, $data, $options); + + $options['hooks']->dispatch('requests.before_parse', array(&$response, $url, $headers, $data, $type, $options)); + + return self::parse_response($response, $url, $headers, $data, $options); + } + + /** + * Send multiple HTTP requests simultaneously + * + * The `$requests` parameter takes an associative or indexed array of + * request fields. The key of each request can be used to match up the + * request with the returned data, or with the request passed into your + * `multiple.request.complete` callback. + * + * The request fields value is an associative array with the following keys: + * + * - `url`: Request URL Same as the `$url` parameter to + * {@see Requests::request} + * (string, required) + * - `headers`: Associative array of header fields. Same as the `$headers` + * parameter to {@see Requests::request} + * (array, default: `array()`) + * - `data`: Associative array of data fields or a string. Same as the + * `$data` parameter to {@see Requests::request} + * (array|string, default: `array()`) + * - `type`: HTTP request type (use Requests constants). Same as the `$type` + * parameter to {@see Requests::request} + * (string, default: `Requests::GET`) + * - `cookies`: Associative array of cookie name to value, or cookie jar. + * (array|Requests_Cookie_Jar) + * + * If the `$options` parameter is specified, individual requests will + * inherit options from it. This can be used to use a single hooking system, + * or set all the types to `Requests::POST`, for example. + * + * In addition, the `$options` parameter takes the following global options: + * + * - `complete`: A callback for when a request is complete. Takes two + * parameters, a Requests_Response/Requests_Exception reference, and the + * ID from the request array (Note: this can also be overridden on a + * per-request basis, although that's a little silly) + * (callback) + * + * @param array $requests Requests data (see description for more information) + * @param array $options Global and default options (see {@see Requests::request}) + * @return array Responses (either Requests_Response or a Requests_Exception object) + */ + public static function request_multiple($requests, $options = array()) { + $options = array_merge(self::get_default_options(true), $options); + + if (!empty($options['hooks'])) { + $options['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); + if (!empty($options['complete'])) { + $options['hooks']->register('multiple.request.complete', $options['complete']); + } + } + + foreach ($requests as $id => &$request) { + if (!isset($request['headers'])) { + $request['headers'] = array(); + } + if (!isset($request['data'])) { + $request['data'] = array(); + } + if (!isset($request['type'])) { + $request['type'] = self::GET; + } + if (!isset($request['options'])) { + $request['options'] = $options; + $request['options']['type'] = $request['type']; + } + else { + if (empty($request['options']['type'])) { + $request['options']['type'] = $request['type']; + } + $request['options'] = array_merge($options, $request['options']); + } + + self::set_defaults($request['url'], $request['headers'], $request['data'], $request['type'], $request['options']); + + // Ensure we only hook in once + if ($request['options']['hooks'] !== $options['hooks']) { + $request['options']['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); + if (!empty($request['options']['complete'])) { + $request['options']['hooks']->register('multiple.request.complete', $request['options']['complete']); + } + } + } + unset($request); + + if (!empty($options['transport'])) { + $transport = $options['transport']; + + if (is_string($options['transport'])) { + $transport = new $transport(); + } + } + else { + $transport = self::get_transport(); + } + $responses = $transport->request_multiple($requests, $options); + + foreach ($responses as $id => &$response) { + // If our hook got messed with somehow, ensure we end up with the + // correct response + if (is_string($response)) { + $request = $requests[$id]; + self::parse_multiple($response, $request); + $request['options']['hooks']->dispatch('multiple.request.complete', array(&$response, $id)); + } + } + + return $responses; + } + + /** + * Get the default options + * + * @see Requests::request() for values returned by this method + * @param boolean $multirequest Is this a multirequest? + * @return array Default option values + */ + protected static function get_default_options($multirequest = false) { + $defaults = array( + 'timeout' => 10, + 'connect_timeout' => 10, + 'useragent' => 'php-requests/' . self::VERSION, + 'protocol_version' => 1.1, + 'redirected' => 0, + 'redirects' => 10, + 'follow_redirects' => true, + 'blocking' => true, + 'type' => self::GET, + 'filename' => false, + 'auth' => false, + 'proxy' => false, + 'cookies' => false, + 'max_bytes' => false, + 'idn' => true, + 'hooks' => null, + 'transport' => null, + 'verify' => Requests::get_certificate_path(), + 'verifyname' => true, + ); + if ($multirequest !== false) { + $defaults['complete'] = null; + } + return $defaults; + } + + /** + * Get default certificate path. + * + * @return string Default certificate path. + */ + public static function get_certificate_path() { + if ( ! empty( Requests::$certificate_path ) ) { + return Requests::$certificate_path; + } + + return dirname(__FILE__) . '/Requests/Transport/cacert.pem'; + } + + /** + * Set default certificate path. + * + * @param string $path Certificate path, pointing to a PEM file. + */ + public static function set_certificate_path( $path ) { + Requests::$certificate_path = $path; + } + + /** + * Set the default values + * + * @param string $url URL to request + * @param array $headers Extra headers to send with the request + * @param array|null $data Data to send either as a query string for GET/HEAD requests, or in the body for POST requests + * @param string $type HTTP request type + * @param array $options Options for the request + * @return array $options + */ + protected static function set_defaults(&$url, &$headers, &$data, &$type, &$options) { + if (!preg_match('/^http(s)?:\/\//i', $url, $matches)) { + throw new Requests_Exception('Only HTTP(S) requests are handled.', 'nonhttp', $url); + } + + if (empty($options['hooks'])) { + $options['hooks'] = new Requests_Hooks(); + } + + if (is_array($options['auth'])) { + $options['auth'] = new Requests_Auth_Basic($options['auth']); + } + if ($options['auth'] !== false) { + $options['auth']->register($options['hooks']); + } + + if (is_string($options['proxy']) || is_array($options['proxy'])) { + $options['proxy'] = new Requests_Proxy_HTTP($options['proxy']); + } + if ($options['proxy'] !== false) { + $options['proxy']->register($options['hooks']); + } + + if (is_array($options['cookies'])) { + $options['cookies'] = new Requests_Cookie_Jar($options['cookies']); + } + elseif (empty($options['cookies'])) { + $options['cookies'] = new Requests_Cookie_Jar(); + } + if ($options['cookies'] !== false) { + $options['cookies']->register($options['hooks']); + } + + if ($options['idn'] !== false) { + $iri = new Requests_IRI($url); + $iri->host = Requests_IDNAEncoder::encode($iri->ihost); + $url = $iri->uri; + } + + // Massage the type to ensure we support it. + $type = strtoupper($type); + + if (!isset($options['data_format'])) { + if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) { + $options['data_format'] = 'query'; + } + else { + $options['data_format'] = 'body'; + } + } + } + + /** + * HTTP response parser + * + * @throws Requests_Exception On missing head/body separator (`requests.no_crlf_separator`) + * @throws Requests_Exception On missing head/body separator (`noversion`) + * @throws Requests_Exception On missing head/body separator (`toomanyredirects`) + * + * @param string $headers Full response text including headers and body + * @param string $url Original request URL + * @param array $req_headers Original $headers array passed to {@link request()}, in case we need to follow redirects + * @param array $req_data Original $data array passed to {@link request()}, in case we need to follow redirects + * @param array $options Original $options array passed to {@link request()}, in case we need to follow redirects + * @return Requests_Response + */ + protected static function parse_response($headers, $url, $req_headers, $req_data, $options) { + $return = new Requests_Response(); + if (!$options['blocking']) { + return $return; + } + + $return->raw = $headers; + $return->url = $url; + + if (!$options['filename']) { + if (($pos = strpos($headers, "\r\n\r\n")) === false) { + // Crap! + throw new Requests_Exception('Missing header/body separator', 'requests.no_crlf_separator'); + } + + $headers = substr($return->raw, 0, $pos); + $return->body = substr($return->raw, $pos + strlen("\n\r\n\r")); + } + else { + $return->body = ''; + } + // Pretend CRLF = LF for compatibility (RFC 2616, section 19.3) + $headers = str_replace("\r\n", "\n", $headers); + // Unfold headers (replace [CRLF] 1*( SP | HT ) with SP) as per RFC 2616 (section 2.2) + $headers = preg_replace('/\n[ \t]/', ' ', $headers); + $headers = explode("\n", $headers); + preg_match('#^HTTP/(1\.\d)[ \t]+(\d+)#i', array_shift($headers), $matches); + if (empty($matches)) { + throw new Requests_Exception('Response could not be parsed', 'noversion', $headers); + } + $return->protocol_version = (float) $matches[1]; + $return->status_code = (int) $matches[2]; + if ($return->status_code >= 200 && $return->status_code < 300) { + $return->success = true; + } + + foreach ($headers as $header) { + list($key, $value) = explode(':', $header, 2); + $value = trim($value); + preg_replace('#(\s+)#i', ' ', $value); + $return->headers[$key] = $value; + } + if (isset($return->headers['transfer-encoding'])) { + $return->body = self::decode_chunked($return->body); + unset($return->headers['transfer-encoding']); + } + if (isset($return->headers['content-encoding'])) { + $return->body = self::decompress($return->body); + } + + //fsockopen and cURL compatibility + if (isset($return->headers['connection'])) { + unset($return->headers['connection']); + } + + $options['hooks']->dispatch('requests.before_redirect_check', array(&$return, $req_headers, $req_data, $options)); + + if ($return->is_redirect() && $options['follow_redirects'] === true) { + if (isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { + if ($return->status_code === 303) { + $options['type'] = self::GET; + } + $options['redirected']++; + $location = $return->headers['location']; + if (strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { + // relative redirect, for compatibility make it absolute + $location = Requests_IRI::absolutize($url, $location); + $location = $location->uri; + } + + $hook_args = array( + &$location, + &$req_headers, + &$req_data, + &$options, + $return + ); + $options['hooks']->dispatch('requests.before_redirect', $hook_args); + $redirected = self::request($location, $req_headers, $req_data, $options['type'], $options); + $redirected->history[] = $return; + return $redirected; + } + elseif ($options['redirected'] >= $options['redirects']) { + throw new Requests_Exception('Too many redirects', 'toomanyredirects', $return); + } + } + + $return->redirects = $options['redirected']; + + $options['hooks']->dispatch('requests.after_request', array(&$return, $req_headers, $req_data, $options)); + return $return; + } + + /** + * Callback for `transport.internal.parse_response` + * + * Internal use only. Converts a raw HTTP response to a Requests_Response + * while still executing a multiple request. + * + * @param string $response Full response text including headers and body (will be overwritten with Response instance) + * @param array $request Request data as passed into {@see Requests::request_multiple()} + * @return null `$response` is either set to a Requests_Response instance, or a Requests_Exception object + */ + public static function parse_multiple(&$response, $request) { + try { + $url = $request['url']; + $headers = $request['headers']; + $data = $request['data']; + $options = $request['options']; + $response = self::parse_response($response, $url, $headers, $data, $options); + } + catch (Requests_Exception $e) { + $response = $e; + } + } + + /** + * Decoded a chunked body as per RFC 2616 + * + * @see https://tools.ietf.org/html/rfc2616#section-3.6.1 + * @param string $data Chunked body + * @return string Decoded body + */ + protected static function decode_chunked($data) { + if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { + return $data; + } + + + + $decoded = ''; + $encoded = $data; + + while (true) { + $is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); + if (!$is_chunked) { + // Looks like it's not chunked after all + return $data; + } + + $length = hexdec(trim($matches[1])); + if ($length === 0) { + // Ignore trailer headers + return $decoded; + } + + $chunk_length = strlen($matches[0]); + $decoded .= substr($encoded, $chunk_length, $length); + $encoded = substr($encoded, $chunk_length + $length + 2); + + if (trim($encoded) === '0' || empty($encoded)) { + return $decoded; + } + } + + // We'll never actually get down here + // @codeCoverageIgnoreStart + } + // @codeCoverageIgnoreEnd + + /** + * Convert a key => value array to a 'key: value' array for headers + * + * @param array $array Dictionary of header values + * @return array List of headers + */ + public static function flatten($array) { + $return = array(); + foreach ($array as $key => $value) { + $return[] = sprintf('%s: %s', $key, $value); + } + return $return; + } + + /** + * Convert a key => value array to a 'key: value' array for headers + * + * @codeCoverageIgnore + * @deprecated Misspelling of {@see Requests::flatten} + * @param array $array Dictionary of header values + * @return array List of headers + */ + public static function flattern($array) { + return self::flatten($array); + } + + /** + * Decompress an encoded body + * + * Implements gzip, compress and deflate. Guesses which it is by attempting + * to decode. + * + * @param string $data Compressed data in one of the above formats + * @return string Decompressed string + */ + public static function decompress($data) { + if (substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { + // Not actually compressed. Probably cURL ruining this for us. + return $data; + } + + if (function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) { + return $decoded; + } + elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) { + return $decoded; + } + elseif (($decoded = self::compatible_gzinflate($data)) !== false) { + return $decoded; + } + elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) { + return $decoded; + } + + return $data; + } + + /** + * Decompression of deflated string while staying compatible with the majority of servers. + * + * Certain Servers will return deflated data with headers which PHP's gzinflate() + * function cannot handle out of the box. The following function has been created from + * various snippets on the gzinflate() PHP documentation. + * + * Warning: Magic numbers within. Due to the potential different formats that the compressed + * data may be returned in, some "magic offsets" are needed to ensure proper decompression + * takes place. For a simple progmatic way to determine the magic offset in use, see: + * https://core.trac.wordpress.org/ticket/18273 + * + * @since 2.8.1 + * @link https://core.trac.wordpress.org/ticket/18273 + * @link https://secure.php.net/manual/en/function.gzinflate.php#70875 + * @link https://secure.php.net/manual/en/function.gzinflate.php#77336 + * + * @param string $gzData String to decompress. + * @return string|bool False on failure. + */ + public static function compatible_gzinflate($gzData) { + // Compressed data might contain a full zlib header, if so strip it for + // gzinflate() + if (substr($gzData, 0, 3) == "\x1f\x8b\x08") { + $i = 10; + $flg = ord(substr($gzData, 3, 1)); + if ($flg > 0) { + if ($flg & 4) { + list($xlen) = unpack('v', substr($gzData, $i, 2)); + $i = $i + 2 + $xlen; + } + if ($flg & 8) { + $i = strpos($gzData, "\0", $i) + 1; + } + if ($flg & 16) { + $i = strpos($gzData, "\0", $i) + 1; + } + if ($flg & 2) { + $i = $i + 2; + } + } + $decompressed = self::compatible_gzinflate(substr($gzData, $i)); + if (false !== $decompressed) { + return $decompressed; + } + } + + // If the data is Huffman Encoded, we must first strip the leading 2 + // byte Huffman marker for gzinflate() + // The response is Huffman coded by many compressors such as + // java.util.zip.Deflater, Ruby’s Zlib::Deflate, and .NET's + // System.IO.Compression.DeflateStream. + // + // See https://decompres.blogspot.com/ for a quick explanation of this + // data type + $huffman_encoded = false; + + // low nibble of first byte should be 0x08 + list(, $first_nibble) = unpack('h', $gzData); + + // First 2 bytes should be divisible by 0x1F + list(, $first_two_bytes) = unpack('n', $gzData); + + if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { + $huffman_encoded = true; + } + + if ($huffman_encoded) { + if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { + return $decompressed; + } + } + + if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { + // ZIP file format header + // Offset 6: 2 bytes, General-purpose field + // Offset 26: 2 bytes, filename length + // Offset 28: 2 bytes, optional field length + // Offset 30: Filename field, followed by optional field, followed + // immediately by data + list(, $general_purpose_flag) = unpack('v', substr($gzData, 6, 2)); + + // If the file has been compressed on the fly, 0x08 bit is set of + // the general purpose field. We can use this to differentiate + // between a compressed document, and a ZIP file + $zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag)); + + if (!$zip_compressed_on_the_fly) { + // Don't attempt to decode a compressed zip file + return $gzData; + } + + // Determine the first byte of data, based on the above ZIP header + // offsets: + $first_file_start = array_sum(unpack('v2', substr($gzData, 26, 4))); + if (false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { + return $decompressed; + } + return false; + } + + // Finally fall back to straight gzinflate + if (false !== ($decompressed = @gzinflate($gzData))) { + return $decompressed; + } + + // Fallback for all above failing, not expected, but included for + // debugging and preventing regressions and to track stats + if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { + return $decompressed; + } + + return false; + } + + public static function match_domain($host, $reference) { + // Check for a direct match + if ($host === $reference) { + return true; + } + + // Calculate the valid wildcard match if the host is not an IP address + // Also validates that the host has 3 parts or more, as per Firefox's + // ruleset. + $parts = explode('.', $host); + if (ip2long($host) === false && count($parts) >= 3) { + $parts[0] = '*'; + $wildcard = implode('.', $parts); + if ($wildcard === $reference) { + return true; + } + } + + return false; + } +} diff --git a/backend/wp-includes/class-simplepie.php b/backend/wp-includes/class-simplepie.php new file mode 100644 index 0000000..6110413 --- /dev/null +++ b/backend/wp-includes/class-simplepie.php @@ -0,0 +1,3094 @@ +<?php +if ( ! class_exists( 'SimplePie', false ) ) : + +// Load classes we will need. +require ABSPATH . WPINC . '/SimplePie/Misc.php'; +require ABSPATH . WPINC . '/SimplePie/Cache.php'; +require ABSPATH . WPINC . '/SimplePie/File.php'; +require ABSPATH . WPINC . '/SimplePie/Sanitize.php'; +require ABSPATH . WPINC . '/SimplePie/Registry.php'; +require ABSPATH . WPINC . '/SimplePie/IRI.php'; +require ABSPATH . WPINC . '/SimplePie/Locator.php'; +require ABSPATH . WPINC . '/SimplePie/Content/Type/Sniffer.php'; +require ABSPATH . WPINC . '/SimplePie/XML/Declaration/Parser.php'; +require ABSPATH . WPINC . '/SimplePie/Parser.php'; +require ABSPATH . WPINC . '/SimplePie/Item.php'; +require ABSPATH . WPINC . '/SimplePie/Parse/Date.php'; +require ABSPATH . WPINC . '/SimplePie/Author.php'; + +/** + * WordPress autoloader for SimplePie. + * + * @since 3.5.0 + */ +function wp_simplepie_autoload( $class ) { + if ( 0 !== strpos( $class, 'SimplePie_' ) ) + return; + + $file = ABSPATH . WPINC . '/' . str_replace( '_', '/', $class ) . '.php'; + include( $file ); +} + +/** + * We autoload classes we may not need. + */ +spl_autoload_register( 'wp_simplepie_autoload' ); + +/** + * SimplePie + * + * A PHP-Based RSS and Atom Feed Framework. + * Takes the hard work out of managing a complete RSS/Atom solution. + * + * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * * Neither the name of the SimplePie Team nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @package SimplePie + * @version 1.3.1 + * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue + * @author Ryan Parman + * @author Geoffrey Sneddon + * @author Ryan McCue + * @link http://simplepie.org/ SimplePie + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + */ + +/** + * SimplePie Name + */ +define('SIMPLEPIE_NAME', 'SimplePie'); + +/** + * SimplePie Version + */ +define('SIMPLEPIE_VERSION', '1.3.1'); + +/** + * SimplePie Build + * @todo Hardcode for release (there's no need to have to call SimplePie_Misc::get_build() only every load of simplepie.inc) + */ +define('SIMPLEPIE_BUILD', gmdate('YmdHis', SimplePie_Misc::get_build())); + +/** + * SimplePie Website URL + */ +define('SIMPLEPIE_URL', 'http://simplepie.org'); + +/** + * SimplePie Useragent + * @see SimplePie::set_useragent() + */ +define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD); + +/** + * SimplePie Linkback + */ +define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>'); + +/** + * No Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_NONE', 0); + +/** + * Feed Link Element Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); + +/** + * Local Feed Extension Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); + +/** + * Local Feed Body Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); + +/** + * Remote Feed Extension Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); + +/** + * Remote Feed Body Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); + +/** + * All Feed Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_ALL', 31); + +/** + * No known feed type + */ +define('SIMPLEPIE_TYPE_NONE', 0); + +/** + * RSS 0.90 + */ +define('SIMPLEPIE_TYPE_RSS_090', 1); + +/** + * RSS 0.91 (Netscape) + */ +define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); + +/** + * RSS 0.91 (Userland) + */ +define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); + +/** + * RSS 0.91 (both Netscape and Userland) + */ +define('SIMPLEPIE_TYPE_RSS_091', 6); + +/** + * RSS 0.92 + */ +define('SIMPLEPIE_TYPE_RSS_092', 8); + +/** + * RSS 0.93 + */ +define('SIMPLEPIE_TYPE_RSS_093', 16); + +/** + * RSS 0.94 + */ +define('SIMPLEPIE_TYPE_RSS_094', 32); + +/** + * RSS 1.0 + */ +define('SIMPLEPIE_TYPE_RSS_10', 64); + +/** + * RSS 2.0 + */ +define('SIMPLEPIE_TYPE_RSS_20', 128); + +/** + * RDF-based RSS + */ +define('SIMPLEPIE_TYPE_RSS_RDF', 65); + +/** + * Non-RDF-based RSS (truly intended as syndication format) + */ +define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); + +/** + * All RSS + */ +define('SIMPLEPIE_TYPE_RSS_ALL', 255); + +/** + * Atom 0.3 + */ +define('SIMPLEPIE_TYPE_ATOM_03', 256); + +/** + * Atom 1.0 + */ +define('SIMPLEPIE_TYPE_ATOM_10', 512); + +/** + * All Atom + */ +define('SIMPLEPIE_TYPE_ATOM_ALL', 768); + +/** + * All feed types + */ +define('SIMPLEPIE_TYPE_ALL', 1023); + +/** + * No construct + */ +define('SIMPLEPIE_CONSTRUCT_NONE', 0); + +/** + * Text construct + */ +define('SIMPLEPIE_CONSTRUCT_TEXT', 1); + +/** + * HTML construct + */ +define('SIMPLEPIE_CONSTRUCT_HTML', 2); + +/** + * XHTML construct + */ +define('SIMPLEPIE_CONSTRUCT_XHTML', 4); + +/** + * base64-encoded construct + */ +define('SIMPLEPIE_CONSTRUCT_BASE64', 8); + +/** + * IRI construct + */ +define('SIMPLEPIE_CONSTRUCT_IRI', 16); + +/** + * A construct that might be HTML + */ +define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); + +/** + * All constructs + */ +define('SIMPLEPIE_CONSTRUCT_ALL', 63); + +/** + * Don't change case + */ +define('SIMPLEPIE_SAME_CASE', 1); + +/** + * Change to lowercase + */ +define('SIMPLEPIE_LOWERCASE', 2); + +/** + * Change to uppercase + */ +define('SIMPLEPIE_UPPERCASE', 4); + +/** + * PCRE for HTML attributes + */ +define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*'); + +/** + * PCRE for XML attributes + */ +define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); + +/** + * XML Namespace + */ +define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); + +/** + * Atom 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); + +/** + * Atom 0.3 Namespace + */ +define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); + +/** + * RDF Namespace + */ +define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); + +/** + * RSS 0.90 Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); + +/** + * RSS 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); + +/** + * RSS 1.0 Content Module Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); + +/** + * RSS 2.0 Namespace + * (Stupid, I know, but I'm certain it will confuse people less with support.) + */ +define('SIMPLEPIE_NAMESPACE_RSS_20', ''); + +/** + * DC 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); + +/** + * DC 1.1 Namespace + */ +define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); + +/** + * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace + */ +define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); + +/** + * GeoRSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); + +/** + * Media RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); + +/** + * Wrong Media RSS Namespace. Caused by a long-standing typo in the spec. + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss'); + +/** + * Wrong Media RSS Namespace #2. New namespace introduced in Media RSS 1.5. + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG2', 'http://video.search.yahoo.com/mrss'); + +/** + * Wrong Media RSS Namespace #3. A possible typo of the Media RSS 1.5 namespace. + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG3', 'http://video.search.yahoo.com/mrss/'); + +/** + * Wrong Media RSS Namespace #4. New spec location after the RSS Advisory Board takes it over, but not a valid namespace. + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG4', 'http://www.rssboard.org/media-rss'); + +/** + * Wrong Media RSS Namespace #5. A possible typo of the RSS Advisory Board URL. + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG5', 'http://www.rssboard.org/media-rss/'); + +/** + * iTunes RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); + +/** + * XHTML Namespace + */ +define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); + +/** + * IANA Link Relations Registry + */ +define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); + +/** + * No file source + */ +define('SIMPLEPIE_FILE_SOURCE_NONE', 0); + +/** + * Remote file source + */ +define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1); + +/** + * Local file source + */ +define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2); + +/** + * fsockopen() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4); + +/** + * cURL file source + */ +define('SIMPLEPIE_FILE_SOURCE_CURL', 8); + +/** + * file_get_contents() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); + + + +/** + * SimplePie + * + * @package SimplePie + * @subpackage API + */ +class SimplePie +{ + /** + * @var array Raw data + * @access private + */ + public $data = array(); + + /** + * @var mixed Error string + * @access private + */ + public $error; + + /** + * @var object Instance of SimplePie_Sanitize (or other class) + * @see SimplePie::set_sanitize_class() + * @access private + */ + public $sanitize; + + /** + * @var string SimplePie Useragent + * @see SimplePie::set_useragent() + * @access private + */ + public $useragent = SIMPLEPIE_USERAGENT; + + /** + * @var string Feed URL + * @see SimplePie::set_feed_url() + * @access private + */ + public $feed_url; + + /** + * @var object Instance of SimplePie_File to use as a feed + * @see SimplePie::set_file() + * @access private + */ + public $file; + + /** + * @var string Raw feed data + * @see SimplePie::set_raw_data() + * @access private + */ + public $raw_data; + + /** + * @var int Timeout for fetching remote files + * @see SimplePie::set_timeout() + * @access private + */ + public $timeout = 10; + + /** + * @var bool Forces fsockopen() to be used for remote files instead + * of cURL, even if a new enough version is installed + * @see SimplePie::force_fsockopen() + * @access private + */ + public $force_fsockopen = false; + + /** + * @var bool Force the given data/URL to be treated as a feed no matter what + * it appears like + * @see SimplePie::force_feed() + * @access private + */ + public $force_feed = false; + + /** + * @var bool Enable/Disable Caching + * @see SimplePie::enable_cache() + * @access private + */ + public $cache = true; + + /** + * @var int Cache duration (in seconds) + * @see SimplePie::set_cache_duration() + * @access private + */ + public $cache_duration = 3600; + + /** + * @var int Auto-discovery cache duration (in seconds) + * @see SimplePie::set_autodiscovery_cache_duration() + * @access private + */ + public $autodiscovery_cache_duration = 604800; // 7 Days. + + /** + * @var string Cache location (relative to executing script) + * @see SimplePie::set_cache_location() + * @access private + */ + public $cache_location = './cache'; + + /** + * @var string Function that creates the cache filename + * @see SimplePie::set_cache_name_function() + * @access private + */ + public $cache_name_function = 'md5'; + + /** + * @var bool Reorder feed by date descending + * @see SimplePie::enable_order_by_date() + * @access private + */ + public $order_by_date = true; + + /** + * @var mixed Force input encoding to be set to the follow value + * (false, or anything type-cast to false, disables this feature) + * @see SimplePie::set_input_encoding() + * @access private + */ + public $input_encoding = false; + + /** + * @var int Feed Autodiscovery Level + * @see SimplePie::set_autodiscovery_level() + * @access private + */ + public $autodiscovery = SIMPLEPIE_LOCATOR_ALL; + + /** + * Class registry object + * + * @var SimplePie_Registry + */ + public $registry; + + /** + * @var int Maximum number of feeds to check with autodiscovery + * @see SimplePie::set_max_checked_feeds() + * @access private + */ + public $max_checked_feeds = 10; + + /** + * @var array All the feeds found during the autodiscovery process + * @see SimplePie::get_all_discovered_feeds() + * @access private + */ + public $all_discovered_feeds = array(); + + /** + * @var string Web-accessible path to the handler_image.php file. + * @see SimplePie::set_image_handler() + * @access private + */ + public $image_handler = ''; + + /** + * @var array Stores the URLs when multiple feeds are being initialized. + * @see SimplePie::set_feed_url() + * @access private + */ + public $multifeed_url = array(); + + /** + * @var array Stores SimplePie objects when multiple feeds initialized. + * @access private + */ + public $multifeed_objects = array(); + + /** + * @var array Stores the get_object_vars() array for use with multifeeds. + * @see SimplePie::set_feed_url() + * @access private + */ + public $config_settings = null; + + /** + * @var integer Stores the number of items to return per-feed with multifeeds. + * @see SimplePie::set_item_limit() + * @access private + */ + public $item_limit = 0; + + /** + * @var array Stores the default attributes to be stripped by strip_attributes(). + * @see SimplePie::strip_attributes() + * @access private + */ + public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); + + /** + * @var array Stores the default tags to be stripped by strip_htmltags(). + * @see SimplePie::strip_htmltags() + * @access private + */ + public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + + /** + * The SimplePie class contains feed level data and options + * + * To use SimplePie, create the SimplePie object with no parameters. You can + * then set configuration options using the provided methods. After setting + * them, you must initialise the feed using $feed->init(). At that point the + * object's methods and properties will be available to you. + * + * Previously, it was possible to pass in the feed URL along with cache + * options directly into the constructor. This has been removed as of 1.3 as + * it caused a lot of confusion. + * + * @since 1.0 Preview Release + */ + public function __construct() + { + if (version_compare(PHP_VERSION, '5.2', '<')) + { + trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.'); + die(); + } + + // Other objects, instances created here so we can set options on them + $this->sanitize = new SimplePie_Sanitize(); + $this->registry = new SimplePie_Registry(); + + if (func_num_args() > 0) + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_location() directly.', $level); + + $args = func_get_args(); + switch (count($args)) { + case 3: + $this->set_cache_duration($args[2]); + case 2: + $this->set_cache_location($args[1]); + case 1: + $this->set_feed_url($args[0]); + $this->init(); + } + } + } + + /** + * Used for converting object to a string + */ + public function __toString() + { + return md5(serialize($this->data)); + } + + /** + * Remove items that link back to this before destroying this object + */ + public function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + if (!empty($this->data['items'])) + { + foreach ($this->data['items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['items']); + } + if (!empty($this->data['ordered_items'])) + { + foreach ($this->data['ordered_items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['ordered_items']); + } + } + } + + /** + * Force the given data/URL to be treated as a feed + * + * This tells SimplePie to ignore the content-type provided by the server. + * Be careful when using this option, as it will also disable autodiscovery. + * + * @since 1.1 + * @param bool $enable Force the given data/URL to be treated as a feed + */ + public function force_feed($enable = false) + { + $this->force_feed = (bool) $enable; + } + + /** + * Set the URL of the feed you want to parse + * + * This allows you to enter the URL of the feed you want to parse, or the + * website you want to try to use auto-discovery on. This takes priority + * over any set raw data. + * + * You can set multiple feeds to mash together by passing an array instead + * of a string for the $url. Remember that with each additional feed comes + * additional processing and resources. + * + * @since 1.0 Preview Release + * @see set_raw_data() + * @param string|array $url This is the URL (or array of URLs) that you want to parse. + */ + public function set_feed_url($url) + { + $this->multifeed_url = array(); + if (is_array($url)) + { + foreach ($url as $value) + { + $this->multifeed_url[] = $this->registry->call('Misc', 'fix_protocol', array($value, 1)); + } + } + else + { + $this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1)); + } + } + + /** + * Set an instance of {@see SimplePie_File} to use as a feed + * + * @param SimplePie_File &$file + * @return bool True on success, false on failure + */ + public function set_file(&$file) + { + if ($file instanceof SimplePie_File) + { + $this->feed_url = $file->url; + $this->file =& $file; + return true; + } + return false; + } + + /** + * Set the raw XML data to parse + * + * Allows you to use a string of RSS/Atom data instead of a remote feed. + * + * If you have a feed available as a string in PHP, you can tell SimplePie + * to parse that data string instead of a remote feed. Any set feed URL + * takes precedence. + * + * @since 1.0 Beta 3 + * @param string $data RSS or Atom data as a string. + * @see set_feed_url() + */ + public function set_raw_data($data) + { + $this->raw_data = $data; + } + + /** + * Set the the default timeout for fetching remote feeds + * + * This allows you to change the maximum time the feed's server to respond + * and send the feed back. + * + * @since 1.0 Beta 3 + * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. + */ + public function set_timeout($timeout = 10) + { + $this->timeout = (int) $timeout; + } + + /** + * Force SimplePie to use fsockopen() instead of cURL + * + * @since 1.0 Beta 3 + * @param bool $enable Force fsockopen() to be used + */ + public function force_fsockopen($enable = false) + { + $this->force_fsockopen = (bool) $enable; + } + + /** + * Enable/disable caching in SimplePie. + * + * This option allows you to disable caching all-together in SimplePie. + * However, disabling the cache can lead to longer load times. + * + * @since 1.0 Preview Release + * @param bool $enable Enable caching + */ + public function enable_cache($enable = true) + { + $this->cache = (bool) $enable; + } + + /** + * Set the length of time (in seconds) that the contents of a feed will be + * cached + * + * @param int $seconds The feed content cache duration + */ + public function set_cache_duration($seconds = 3600) + { + $this->cache_duration = (int) $seconds; + } + + /** + * Set the length of time (in seconds) that the autodiscovered feed URL will + * be cached + * + * @param int $seconds The autodiscovered feed URL cache duration. + */ + public function set_autodiscovery_cache_duration($seconds = 604800) + { + $this->autodiscovery_cache_duration = (int) $seconds; + } + + /** + * Set the file system location where the cached files should be stored + * + * @param string $location The file system location. + */ + public function set_cache_location($location = './cache') + { + $this->cache_location = (string) $location; + } + + /** + * Set whether feed items should be sorted into reverse chronological order + * + * @param bool $enable Sort as reverse chronological order. + */ + public function enable_order_by_date($enable = true) + { + $this->order_by_date = (bool) $enable; + } + + /** + * Set the character encoding used to parse the feed + * + * This overrides the encoding reported by the feed, however it will fall + * back to the normal encoding detection if the override fails + * + * @param string $encoding Character encoding + */ + public function set_input_encoding($encoding = false) + { + if ($encoding) + { + $this->input_encoding = (string) $encoding; + } + else + { + $this->input_encoding = false; + } + } + + /** + * Set how much feed autodiscovery to do + * + * @see SIMPLEPIE_LOCATOR_NONE + * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY + * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION + * @see SIMPLEPIE_LOCATOR_LOCAL_BODY + * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION + * @see SIMPLEPIE_LOCATOR_REMOTE_BODY + * @see SIMPLEPIE_LOCATOR_ALL + * @param int $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator) + */ + public function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) + { + $this->autodiscovery = (int) $level; + } + + /** + * Get the class registry + * + * Use this to override SimplePie's default classes + * @see SimplePie_Registry + * @return SimplePie_Registry + */ + public function &get_registry() + { + return $this->registry; + } + + /**#@+ + * Useful when you are overloading or extending SimplePie's default classes. + * + * @deprecated Use {@see get_registry()} instead + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + * @param string $class Name of custom class + * @return boolean True on success, false otherwise + */ + /** + * Set which class SimplePie uses for caching + */ + public function set_cache_class($class = 'SimplePie_Cache') + { + return $this->registry->register('Cache', $class, true); + } + + /** + * Set which class SimplePie uses for auto-discovery + */ + public function set_locator_class($class = 'SimplePie_Locator') + { + return $this->registry->register('Locator', $class, true); + } + + /** + * Set which class SimplePie uses for XML parsing + */ + public function set_parser_class($class = 'SimplePie_Parser') + { + return $this->registry->register('Parser', $class, true); + } + + /** + * Set which class SimplePie uses for remote file fetching + */ + public function set_file_class($class = 'SimplePie_File') + { + return $this->registry->register('File', $class, true); + } + + /** + * Set which class SimplePie uses for data sanitization + */ + public function set_sanitize_class($class = 'SimplePie_Sanitize') + { + return $this->registry->register('Sanitize', $class, true); + } + + /** + * Set which class SimplePie uses for handling feed items + */ + public function set_item_class($class = 'SimplePie_Item') + { + return $this->registry->register('Item', $class, true); + } + + /** + * Set which class SimplePie uses for handling author data + */ + public function set_author_class($class = 'SimplePie_Author') + { + return $this->registry->register('Author', $class, true); + } + + /** + * Set which class SimplePie uses for handling category data + */ + public function set_category_class($class = 'SimplePie_Category') + { + return $this->registry->register('Category', $class, true); + } + + /** + * Set which class SimplePie uses for feed enclosures + */ + public function set_enclosure_class($class = 'SimplePie_Enclosure') + { + return $this->registry->register('Enclosure', $class, true); + } + + /** + * Set which class SimplePie uses for `<media:text>` captions + */ + public function set_caption_class($class = 'SimplePie_Caption') + { + return $this->registry->register('Caption', $class, true); + } + + /** + * Set which class SimplePie uses for `<media:copyright>` + */ + public function set_copyright_class($class = 'SimplePie_Copyright') + { + return $this->registry->register('Copyright', $class, true); + } + + /** + * Set which class SimplePie uses for `<media:credit>` + */ + public function set_credit_class($class = 'SimplePie_Credit') + { + return $this->registry->register('Credit', $class, true); + } + + /** + * Set which class SimplePie uses for `<media:rating>` + */ + public function set_rating_class($class = 'SimplePie_Rating') + { + return $this->registry->register('Rating', $class, true); + } + + /** + * Set which class SimplePie uses for `<media:restriction>` + */ + public function set_restriction_class($class = 'SimplePie_Restriction') + { + return $this->registry->register('Restriction', $class, true); + } + + /** + * Set which class SimplePie uses for content-type sniffing + */ + public function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') + { + return $this->registry->register('Content_Type_Sniffer', $class, true); + } + + /** + * Set which class SimplePie uses item sources + */ + public function set_source_class($class = 'SimplePie_Source') + { + return $this->registry->register('Source', $class, true); + } + /**#@-*/ + + /** + * Set the user agent string + * + * @param string $ua New user agent string. + */ + public function set_useragent($ua = SIMPLEPIE_USERAGENT) + { + $this->useragent = (string) $ua; + } + + /** + * Set callback function to create cache filename with + * + * @param mixed $function Callback function + */ + public function set_cache_name_function($function = 'md5') + { + if (is_callable($function)) + { + $this->cache_name_function = $function; + } + } + + /** + * Set options to make SP as fast as possible + * + * Forgoes a substantial amount of data sanitization in favor of speed. This + * turns SimplePie into a dumb parser of feeds. + * + * @param bool $set Whether to set them or not + */ + public function set_stupidly_fast($set = false) + { + if ($set) + { + $this->enable_order_by_date(false); + $this->remove_div(false); + $this->strip_comments(false); + $this->strip_htmltags(false); + $this->strip_attributes(false); + $this->set_image_handler(false); + } + } + + /** + * Set maximum number of feeds to check with autodiscovery + * + * @param int $max Maximum number of feeds to check + */ + public function set_max_checked_feeds($max = 10) + { + $this->max_checked_feeds = (int) $max; + } + + public function remove_div($enable = true) + { + $this->sanitize->remove_div($enable); + } + + public function strip_htmltags($tags = '', $encode = null) + { + if ($tags === '') + { + $tags = $this->strip_htmltags; + } + $this->sanitize->strip_htmltags($tags); + if ($encode !== null) + { + $this->sanitize->encode_instead_of_strip($tags); + } + } + + public function encode_instead_of_strip($enable = true) + { + $this->sanitize->encode_instead_of_strip($enable); + } + + public function strip_attributes($attribs = '') + { + if ($attribs === '') + { + $attribs = $this->strip_attributes; + } + $this->sanitize->strip_attributes($attribs); + } + + /** + * Set the output encoding + * + * Allows you to override SimplePie's output to match that of your webpage. + * This is useful for times when your webpages are not being served as + * UTF-8. This setting will be obeyed by {@see handle_content_type()}, and + * is similar to {@see set_input_encoding()}. + * + * It should be noted, however, that not all character encodings can support + * all characters. If your page is being served as ISO-8859-1 and you try + * to display a Japanese feed, you'll likely see garbled characters. + * Because of this, it is highly recommended to ensure that your webpages + * are served as UTF-8. + * + * The number of supported character encodings depends on whether your web + * host supports {@link http://php.net/mbstring mbstring}, + * {@link http://php.net/iconv iconv}, or both. See + * {@link http://simplepie.org/wiki/faq/Supported_Character_Encodings} for + * more information. + * + * @param string $encoding + */ + public function set_output_encoding($encoding = 'UTF-8') + { + $this->sanitize->set_output_encoding($encoding); + } + + public function strip_comments($strip = false) + { + $this->sanitize->strip_comments($strip); + } + + /** + * Set element/attribute key/value pairs of HTML attributes + * containing URLs that need to be resolved relative to the feed + * + * Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite, + * |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite, + * |q|@cite + * + * @since 1.0 + * @param array|null $element_attribute Element/attribute key/value pairs, null for default + */ + public function set_url_replacements($element_attribute = null) + { + $this->sanitize->set_url_replacements($element_attribute); + } + + /** + * Set the handler to enable the display of cached images. + * + * @param str $page Web-accessible path to the handler_image.php file. + * @param str $qs The query string that the value should be passed to. + */ + public function set_image_handler($page = false, $qs = 'i') + { + if ($page !== false) + { + $this->sanitize->set_image_handler($page . '?' . $qs . '='); + } + else + { + $this->image_handler = ''; + } + } + + /** + * Set the limit for items returned per-feed with multifeeds + * + * @param integer $limit The maximum number of items to return. + */ + public function set_item_limit($limit = 0) + { + $this->item_limit = (int) $limit; + } + + /** + * Initialize the feed object + * + * This is what makes everything happen. Period. This is where all of the + * configuration options get processed, feeds are fetched, cached, and + * parsed, and all of that other good stuff. + * + * @return boolean True if successful, false otherwise + */ + public function init() + { + // Check absolute bare minimum requirements. + if (!extension_loaded('xml') || !extension_loaded('pcre')) + { + return false; + } + // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. + elseif (!extension_loaded('xmlreader')) + { + static $xml_is_sane = null; + if ($xml_is_sane === null) + { + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + if (!$xml_is_sane) + { + return false; + } + } + + if (method_exists($this->sanitize, 'set_registry')) + { + $this->sanitize->set_registry($this->registry); + } + + // Pass whatever was set with config options over to the sanitizer. + // Pass the classes in for legacy support; new classes should use the registry instead + $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class('Cache')); + $this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen); + + if (!empty($this->multifeed_url)) + { + $i = 0; + $success = 0; + $this->multifeed_objects = array(); + $this->error = array(); + foreach ($this->multifeed_url as $url) + { + $this->multifeed_objects[$i] = clone $this; + $this->multifeed_objects[$i]->set_feed_url($url); + $single_success = $this->multifeed_objects[$i]->init(); + $success |= $single_success; + if (!$single_success) + { + $this->error[$i] = $this->multifeed_objects[$i]->error(); + } + $i++; + } + return (bool) $success; + } + elseif ($this->feed_url === null && $this->raw_data === null) + { + return false; + } + + $this->error = null; + $this->data = array(); + $this->multifeed_objects = array(); + $cache = false; + + if ($this->feed_url !== null) + { + $parsed_feed_url = $this->registry->call('Misc', 'parse_url', array($this->feed_url)); + + // Decide whether to enable caching + if ($this->cache && $parsed_feed_url['scheme'] !== '') + { + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); + } + + // Fetch the data via SimplePie_File into $this->raw_data + if (($fetched = $this->fetch_data($cache)) === true) + { + return true; + } + elseif ($fetched === false) { + return false; + } + + list($headers, $sniffed) = $fetched; + } + + // Set up array of possible encodings + $encodings = array(); + + // First check to see if input has been overridden. + if ($this->input_encoding !== false) + { + $encodings[] = $this->input_encoding; + } + + $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); + $text_types = array('text/xml', 'text/xml-external-parsed-entity'); + + // RFC 3023 (only applies to sniffed content) + if (isset($sniffed)) + { + if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = strtoupper($charset[1]); + } + $encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); + $encodings[] = 'UTF-8'; + } + elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = $charset[1]; + } + $encodings[] = 'US-ASCII'; + } + // Text MIME-type default + elseif (substr($sniffed, 0, 5) === 'text/') + { + $encodings[] = 'US-ASCII'; + } + } + + // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 + $encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry))); + $encodings[] = 'UTF-8'; + $encodings[] = 'ISO-8859-1'; + + // There's no point in trying an encoding twice + $encodings = array_unique($encodings); + + // Loop through each possible encoding, till we return something, or run out of possibilities + foreach ($encodings as $encoding) + { + // Change the encoding to UTF-8 (as we always use UTF-8 internally) + if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8'))) + { + // Create new parser + $parser = $this->registry->create('Parser'); + + // If it's parsed fine + if ($parser->parse($utf8_data, 'UTF-8')) + { + $this->data = $parser->get_data(); + if (!($this->get_type() & ~SIMPLEPIE_TYPE_NONE)) + { + $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); + return false; + } + + if (isset($headers)) + { + $this->data['headers'] = $headers; + } + $this->data['build'] = SIMPLEPIE_BUILD; + + // Cache the file if caching is enabled + if ($cache && !$cache->save($this)) + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + } + return true; + } + } + } + + if (isset($parser)) + { + // We have an error, just set SimplePie_Misc::error to it and quit + $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); + } + else + { + $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.'; + } + + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); + + return false; + } + + /** + * Fetch the data via SimplePie_File + * + * If the data is already cached, attempt to fetch it from there instead + * @param SimplePie_Cache|false $cache Cache handler, or false to not load from the cache + * @return array|true Returns true if the data was loaded from the cache, or an array of HTTP headers and sniffed type + */ + protected function fetch_data(&$cache) + { + // If it's enabled, use the cache + if ($cache) + { + // Load the Cache + $this->data = $cache->load(); + if (!empty($this->data)) + { + // If the cache is for an outdated build of SimplePie + if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) + { + $cache->unlink(); + $this->data = array(); + } + // If we've hit a collision just rerun it with caching disabled + elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) + { + $cache = false; + $this->data = array(); + } + // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. + elseif (isset($this->data['feed_url'])) + { + // If the autodiscovery cache is still valid use it. + if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) + { + // Do not need to do feed autodiscovery yet. + if ($this->data['feed_url'] !== $this->data['url']) + { + $this->set_feed_url($this->data['feed_url']); + return $this->init(); + } + + $cache->unlink(); + $this->data = array(); + } + } + // Check if the cache has been updated + elseif ($cache->mtime() + $this->cache_duration < time()) + { + // If we have last-modified and/or etag set + if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) + { + $headers = array( + 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', + ); + if (isset($this->data['headers']['last-modified'])) + { + $headers['if-modified-since'] = $this->data['headers']['last-modified']; + } + if (isset($this->data['headers']['etag'])) + { + $headers['if-none-match'] = $this->data['headers']['etag']; + } + + $file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen)); + + if ($file->success) + { + if ($file->status_code === 304) + { + $cache->touch(); + return true; + } + } + else + { + unset($file); + } + } + } + // If the cache is still valid, just return true + else + { + $this->raw_data = false; + return true; + } + } + // If the cache is empty, delete it + else + { + $cache->unlink(); + $this->data = array(); + } + } + // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. + if (!isset($file)) + { + if ($this->file instanceof SimplePie_File && $this->file->url === $this->feed_url) + { + $file =& $this->file; + } + else + { + $headers = array( + 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', + ); + $file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen)); + } + } + // If the file connection has an error, set SimplePie::error to that and quit + if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) + { + $this->error = $file->error; + return !empty($this->data); + } + + if (!$this->force_feed) + { + // Check if the supplied URL is a feed, if it isn't, look for it. + $locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds)); + + if (!$locate->is_feed($file)) + { + // We need to unset this so that if SimplePie::set_file() has been called that object is untouched + unset($file); + try + { + if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) + { + $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); + return false; + } + } + catch (SimplePie_Exception $e) + { + // This is usually because DOMDocument doesn't exist + $this->error = $e->getMessage(); + $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine())); + return false; + } + if ($cache) + { + $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); + if (!$cache->save($this)) + { + trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); + } + $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc')); + } + $this->feed_url = $file->url; + } + $locate = null; + } + + $this->raw_data = $file->body; + + $headers = $file->headers; + $sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file)); + $sniffed = $sniffer->get_type(); + + return array($headers, $sniffed); + } + + /** + * Get the error message for the occurred error. + * + * @return string|array Error message, or array of messages for multifeeds + */ + public function error() + { + return $this->error; + } + + /** + * Get the raw XML + * + * This is the same as the old `$feed->enable_xml_dump(true)`, but returns + * the data instead of printing it. + * + * @return string|boolean Raw XML data, false if the cache is used + */ + public function get_raw_data() + { + return $this->raw_data; + } + + /** + * Get the character encoding used for output + * + * @since Preview Release + * @return string + */ + public function get_encoding() + { + return $this->sanitize->output_encoding; + } + + /** + * Send the content-type header with correct encoding + * + * This method ensures that the SimplePie-enabled page is being served with + * the correct {@link http://www.iana.org/assignments/media-types/ mime-type} + * and character encoding HTTP headers (character encoding determined by the + * {@see set_output_encoding} config option). + * + * This won't work properly if any content or whitespace has already been + * sent to the browser, because it relies on PHP's + * {@link http://php.net/header header()} function, and these are the + * circumstances under which the function works. + * + * Because it's setting these settings for the entire page (as is the nature + * of HTTP headers), this should only be used once per page (again, at the + * top). + * + * @param string $mime MIME type to serve the page as + */ + public function handle_content_type($mime = 'text/html') + { + if (!headers_sent()) + { + $header = "Content-type: $mime;"; + if ($this->get_encoding()) + { + $header .= ' charset=' . $this->get_encoding(); + } + else + { + $header .= ' charset=UTF-8'; + } + header($header); + } + } + + /** + * Get the type of the feed + * + * This returns a SIMPLEPIE_TYPE_* constant, which can be tested against + * using {@link http://php.net/language.operators.bitwise bitwise operators} + * + * @since 0.8 (usage changed to using constants in 1.0) + * @see SIMPLEPIE_TYPE_NONE Unknown. + * @see SIMPLEPIE_TYPE_RSS_090 RSS 0.90. + * @see SIMPLEPIE_TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape). + * @see SIMPLEPIE_TYPE_RSS_091_USERLAND RSS 0.91 (Userland). + * @see SIMPLEPIE_TYPE_RSS_091 RSS 0.91. + * @see SIMPLEPIE_TYPE_RSS_092 RSS 0.92. + * @see SIMPLEPIE_TYPE_RSS_093 RSS 0.93. + * @see SIMPLEPIE_TYPE_RSS_094 RSS 0.94. + * @see SIMPLEPIE_TYPE_RSS_10 RSS 1.0. + * @see SIMPLEPIE_TYPE_RSS_20 RSS 2.0.x. + * @see SIMPLEPIE_TYPE_RSS_RDF RDF-based RSS. + * @see SIMPLEPIE_TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format). + * @see SIMPLEPIE_TYPE_RSS_ALL Any version of RSS. + * @see SIMPLEPIE_TYPE_ATOM_03 Atom 0.3. + * @see SIMPLEPIE_TYPE_ATOM_10 Atom 1.0. + * @see SIMPLEPIE_TYPE_ATOM_ALL Any version of Atom. + * @see SIMPLEPIE_TYPE_ALL Any known/supported feed type. + * @return int SIMPLEPIE_TYPE_* constant + */ + public function get_type() + { + if (!isset($this->data['type'])) + { + $this->data['type'] = SIMPLEPIE_TYPE_ALL; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; + } + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; + } + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) + { + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) + { + case '0.91': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + { + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + { + case '0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; + break; + + case '24': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; + break; + } + } + break; + + case '0.92': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; + break; + + case '0.93': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; + break; + + case '0.94': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; + break; + + case '2.0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; + break; + } + } + } + else + { + $this->data['type'] = SIMPLEPIE_TYPE_NONE; + } + } + return $this->data['type']; + } + + /** + * Get the URL for the feed + * + * May or may not be different from the URL passed to {@see set_feed_url()}, + * depending on whether auto-discovery was used. + * + * @since Preview Release (previously called `get_feed_url()` since SimplePie 0.8.) + * @todo If we have a perm redirect we should return the new URL + * @todo When we make the above change, let's support <itunes:new-feed-url> as well + * @todo Also, |atom:link|@rel=self + * @return string|null + */ + public function subscribe_url() + { + if ($this->feed_url !== null) + { + return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + /** + * Get data for an feed-level element + * + * This method allows you to get access to ANY element/attribute that is a + * sub-element of the opening feed tag. + * + * The return value is an indexed array of elements matching the given + * namespace and tag name. Each element has `attribs`, `data` and `child` + * subkeys. For `attribs` and `child`, these contain namespace subkeys. + * `attribs` then has one level of associative name => value data (where + * `value` is a string) after the namespace. `child` has tag-indexed keys + * after the namespace, each member of which is an indexed array matching + * this same format. + * + * For example: + * <pre> + * // This is probably a bad example because we already support + * // <media:content> natively, but it shows you how to parse through + * // the nodes. + * $group = $item->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group'); + * $content = $group[0]['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']; + * $file = $content[0]['attribs']['']['url']; + * echo $file; + * </pre> + * + * @since 1.0 + * @see http://simplepie.org/wiki/faq/supported_xml_namespaces + * @param string $namespace The URL of the XML namespace of the elements you're trying to access + * @param string $tag Tag name + * @return array + */ + public function get_feed_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_ATOM_10) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_ATOM_03) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_RDF) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; + } + } + return null; + } + + /** + * Get data for an channel-level element + * + * This method allows you to get access to ANY element/attribute in the + * channel/header section of the feed. + * + * See {@see SimplePie::get_feed_tags()} for a description of the return value + * + * @since 1.0 + * @see http://simplepie.org/wiki/faq/supported_xml_namespaces + * @param string $namespace The URL of the XML namespace of the elements you're trying to access + * @param string $tag Tag name + * @return array + */ + public function get_channel_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_ATOM_ALL) + { + if ($return = $this->get_feed_tags($namespace, $tag)) + { + return $return; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_10) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_090) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + return null; + } + + /** + * Get data for an channel-level element + * + * This method allows you to get access to ANY element/attribute in the + * image/logo section of the feed. + * + * See {@see SimplePie::get_feed_tags()} for a description of the return value + * + * @since 1.0 + * @see http://simplepie.org/wiki/faq/supported_xml_namespaces + * @param string $namespace The URL of the XML namespace of the elements you're trying to access + * @param string $tag Tag name + * @return array + */ + public function get_image_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_RSS_10) + { + if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_090) + { + if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + return null; + } + + /** + * Get the base URL value from the feed + * + * Uses `<xml:base>` if available, otherwise uses the first link in the + * feed, or failing that, the URL of the feed itself. + * + * @see get_link + * @see subscribe_url + * + * @param array $element + * @return string + */ + public function get_base($element = array()) + { + if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) + { + return $element['xml_base']; + } + elseif ($this->get_link() !== null) + { + return $this->get_link(); + } + else + { + return $this->subscribe_url(); + } + } + + /** + * Sanitize feed data + * + * @access private + * @see SimplePie_Sanitize::sanitize() + * @param string $data Data to sanitize + * @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants + * @param string $base Base URL to resolve URLs against + * @return string Sanitized data + */ + public function sanitize($data, $type, $base = '') + { + return $this->sanitize->sanitize($data, $type, $base); + } + + /** + * Get the title of the feed + * + * Uses `<atom:title>`, `<title>` or `<dc:title>` + * + * @since 1.0 (previously called `get_feed_title` since 0.8) + * @return string|null + */ + public function get_title() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + /** + * Get a category for the feed + * + * @since Unknown + * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Category|null + */ + public function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + /** + * Get all categories for the feed + * + * Uses `<atom:category>`, `<category>` or `<dc:subject>` + * + * @since Unknown + * @return array|null List of {@see SimplePie_Category} objects + */ + public function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = $this->registry->create('Category', array($term, $scheme, null)); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($categories)) + { + return array_unique($categories); + } + else + { + return null; + } + } + + /** + * Get an author for the feed + * + * @since 1.1 + * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Author|null + */ + public function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + /** + * Get all authors for the feed + * + * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>` + * + * @since 1.1 + * @return array|null List of {@see SimplePie_Author} objects + */ + public function get_authors() + { + $authors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); + } + + if (!empty($authors)) + { + return array_unique($authors); + } + else + { + return null; + } + } + + /** + * Get a contributor for the feed + * + * @since 1.1 + * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Author|null + */ + public function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + /** + * Get all contributors for the feed + * + * Uses `<atom:contributor>` + * + * @since 1.1 + * @return array|null List of {@see SimplePie_Author} objects + */ + public function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $uri, $email)); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = $this->registry->create('Author', array($name, $url, $email)); + } + } + + if (!empty($contributors)) + { + return array_unique($contributors); + } + else + { + return null; + } + } + + /** + * Get a single link for the feed + * + * @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) + * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 + * @param string $rel The relationship of the link to return + * @return string|null Link URL + */ + public function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if (isset($links[$key])) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Get the permalink for the item + * + * Returns the first link available with a relationship of "alternate". + * Identical to {@see get_link()} with key 0 + * + * @see get_link + * @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8) + * @internal Added for parity between the parent-level and the item/entry-level. + * @return string|null Link URL + */ + public function get_permalink() + { + return $this->get_link(0); + } + + /** + * Get all links for the feed + * + * Uses `<atom:link>` or `<link>` + * + * @since Beta 2 + * @param string $rel The relationship of links to return + * @return array|null Links found for the feed (strings) + */ + public function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + public function get_all_discovered_feeds() + { + return $this->all_discovered_feeds; + } + + /** + * Get the content for the item + * + * Uses `<atom:subtitle>`, `<atom:tagline>`, `<description>`, + * `<dc:description>`, `<itunes:summary>` or `<itunes:subtitle>` + * + * @since 1.0 (previously called `get_feed_description()` since 0.8) + * @return string|null + */ + public function get_description() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + else + { + return null; + } + } + + /** + * Get the copyright info for the feed + * + * Uses `<atom:rights>`, `<atom:copyright>` or `<dc:rights>` + * + * @since 1.0 (previously called `get_feed_copyright()` since 0.8) + * @return string|null + */ + public function get_copyright() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + /** + * Get the language for the feed + * + * Uses `<language>`, `<dc:language>`, or @xml_lang + * + * @since 1.0 (previously called `get_feed_language()` since 0.8) + * @return string|null + */ + public function get_language() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['headers']['content-language'])) + { + return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + /** + * Get the latitude coordinates for the item + * + * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications + * + * Uses `<geo:lat>` or `<georss:point>` + * + * @since 1.0 + * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo + * @link http://www.georss.org/ GeoRSS + * @return string|null + */ + public function get_latitude() + { + + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + /** + * Get the longitude coordinates for the feed + * + * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications + * + * Uses `<geo:long>`, `<geo:lon>` or `<georss:point>` + * + * @since 1.0 + * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo + * @link http://www.georss.org/ GeoRSS + * @return string|null + */ + public function get_longitude() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + /** + * Get the feed logo's title + * + * RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" title. + * + * Uses `<image><title>` or `<image><dc:title>` + * + * @return string|null + */ + public function get_image_title() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + /** + * Get the feed logo's URL + * + * RSS 0.9.0, 2.0, Atom 1.0, and feeds with iTunes RSS tags are allowed to + * have a "feed logo" URL. This points directly to the image itself. + * + * Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`, + * `<image><title>` or `<image><dc:title>` + * + * @return string|null + */ + public function get_image_url() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) + { + return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } + + + /** + * Get the feed logo's link + * + * RSS 0.9.0, 1.0 and 2.0 feeds are allowed to have a "feed logo" link. This + * points to a human-readable page that the image should link to. + * + * Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`, + * `<image><title>` or `<image><dc:title>` + * + * @return string|null + */ + public function get_image_link() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } + + /** + * Get the feed logo's link + * + * RSS 2.0 feeds are allowed to have a "feed logo" width. + * + * Uses `<image><width>` or defaults to 88.0 if no width is specified and + * the feed is an RSS 2.0 feed. + * + * @return int|float|null + */ + public function get_image_width() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) + { + return round($return[0]['data']); + } + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return 88.0; + } + else + { + return null; + } + } + + /** + * Get the feed logo's height + * + * RSS 2.0 feeds are allowed to have a "feed logo" height. + * + * Uses `<image><height>` or defaults to 31.0 if no height is specified and + * the feed is an RSS 2.0 feed. + * + * @return int|float|null + */ + public function get_image_height() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) + { + return round($return[0]['data']); + } + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return 31.0; + } + else + { + return null; + } + } + + /** + * Get the number of items in the feed + * + * This is well-suited for {@link http://php.net/for for()} loops with + * {@see get_item()} + * + * @param int $max Maximum value to return. 0 for no limit + * @return int Number of items in the feed + */ + public function get_item_quantity($max = 0) + { + $max = (int) $max; + $qty = count($this->get_items()); + if ($max === 0) + { + return $qty; + } + else + { + return ($qty > $max) ? $max : $qty; + } + } + + /** + * Get a single item from the feed + * + * This is better suited for {@link http://php.net/for for()} loops, whereas + * {@see get_items()} is better suited for + * {@link http://php.net/foreach foreach()} loops. + * + * @see get_item_quantity() + * @since Beta 2 + * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1 + * @return SimplePie_Item|null + */ + public function get_item($key = 0) + { + $items = $this->get_items(); + if (isset($items[$key])) + { + return $items[$key]; + } + else + { + return null; + } + } + + /** + * Get all items from the feed + * + * This is better suited for {@link http://php.net/for for()} loops, whereas + * {@see get_items()} is better suited for + * {@link http://php.net/foreach foreach()} loops. + * + * @see get_item_quantity + * @since Beta 2 + * @param int $start Index to start at + * @param int $end Number of items to return. 0 for all items after `$start` + * @return array|null List of {@see SimplePie_Item} objects + */ + public function get_items($start = 0, $end = 0) + { + if (!isset($this->data['items'])) + { + if (!empty($this->multifeed_objects)) + { + $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); + } + else + { + $this->data['items'] = array(); + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); + } + } + if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key])); + } + } + } + } + + if (!empty($this->data['items'])) + { + // If we want to order it by date, check if all items have a date, and then sort it + if ($this->order_by_date && empty($this->multifeed_objects)) + { + if (!isset($this->data['ordered_items'])) + { + $do_sort = true; + foreach ($this->data['items'] as $item) + { + if (!$item->get_date('U')) + { + $do_sort = false; + break; + } + } + $item = null; + $this->data['ordered_items'] = $this->data['items']; + if ($do_sort) + { + usort($this->data['ordered_items'], array(get_class($this), 'sort_items')); + } + } + $items = $this->data['ordered_items']; + } + else + { + $items = $this->data['items']; + } + + // Slice the data as desired + if ($end === 0) + { + return array_slice($items, $start); + } + else + { + return array_slice($items, $start, $end); + } + } + else + { + return array(); + } + } + + /** + * Set the favicon handler + * + * @deprecated Use your own favicon handling instead + */ + public function set_favicon_handler($page = false, $qs = 'i') + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Favicon handling has been removed, please use your own handling', $level); + return false; + } + + /** + * Get the favicon for the current feed + * + * @deprecated Use your own favicon handling instead + */ + public function get_favicon() + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('Favicon handling has been removed, please use your own handling', $level); + + if (($url = $this->get_link()) !== null) + { + return 'http://g.etfv.co/' . urlencode($url); + } + + return false; + } + + /** + * Magic method handler + * + * @param string $method Method name + * @param array $args Arguments to the method + * @return mixed + */ + public function __call($method, $args) + { + if (strpos($method, 'subscribe_') === 0) + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('subscribe_*() has been deprecated, implement the callback yourself', $level); + return ''; + } + if ($method === 'enable_xml_dump') + { + $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; + trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', $level); + return false; + } + + $class = get_class($this); + $trace = debug_backtrace(); + $file = $trace[0]['file']; + $line = $trace[0]['line']; + trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR); + } + + /** + * Sorting callback for items + * + * @access private + * @param SimplePie $a + * @param SimplePie $b + * @return boolean + */ + public static function sort_items($a, $b) + { + return $a->get_date('U') <= $b->get_date('U'); + } + + /** + * Merge items from several feeds into one + * + * If you're merging multiple feeds together, they need to all have dates + * for the items or else SimplePie will refuse to sort them. + * + * @link http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings + * @param array $urls List of SimplePie feed objects to merge + * @param int $start Starting item + * @param int $end Number of items to return + * @param int $limit Maximum number of items per feed + * @return array + */ + public static function merge_items($urls, $start = 0, $end = 0, $limit = 0) + { + if (is_array($urls) && sizeof($urls) > 0) + { + $items = array(); + foreach ($urls as $arg) + { + if ($arg instanceof SimplePie) + { + $items = array_merge($items, $arg->get_items(0, $limit)); + } + else + { + trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); + } + } + + $do_sort = true; + foreach ($items as $item) + { + if (!$item->get_date('U')) + { + $do_sort = false; + break; + } + } + $item = null; + if ($do_sort) + { + usort($items, array(get_class($urls[0]), 'sort_items')); + } + + if ($end === 0) + { + return array_slice($items, $start); + } + else + { + return array_slice($items, $start, $end); + } + } + else + { + trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); + return array(); + } + } +} +endif; \ No newline at end of file diff --git a/backend/wp-includes/class-smtp.php b/backend/wp-includes/class-smtp.php new file mode 100644 index 0000000..3ad0819 --- /dev/null +++ b/backend/wp-includes/class-smtp.php @@ -0,0 +1,1186 @@ +<?php +/** + * PHPMailer RFC821 SMTP email transport class. + * PHP Version 5 + * @package PHPMailer + * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project + * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk> + * @author Jim Jagielski (jimjag) <jimjag@gmail.com> + * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> + * @author Brent R. Matzelle (original founder) + * @copyright 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer RFC821 SMTP email transport class. + * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server. + * @package PHPMailer + * @author Chris Ryan + * @author Marcus Bointon <phpmailer@synchromedia.co.uk> + */ +class SMTP +{ + /** + * The PHPMailer SMTP version number. + * @var string + */ + const VERSION = '5.2.22'; + + /** + * SMTP line break constant. + * @var string + */ + const CRLF = "\r\n"; + + /** + * The SMTP port to use if one is not specified. + * @var integer + */ + const DEFAULT_SMTP_PORT = 25; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1 + * @var integer + */ + const MAX_LINE_LENGTH = 998; + + /** + * Debug level for no output + */ + const DEBUG_OFF = 0; + + /** + * Debug level to show client -> server messages + */ + const DEBUG_CLIENT = 1; + + /** + * Debug level to show client -> server and server -> client messages + */ + const DEBUG_SERVER = 2; + + /** + * Debug level to show connection status, client -> server and server -> client messages + */ + const DEBUG_CONNECTION = 3; + + /** + * Debug level to show all messages + */ + const DEBUG_LOWLEVEL = 4; + + /** + * The PHPMailer SMTP Version number. + * @var string + * @deprecated Use the `VERSION` constant instead + * @see SMTP::VERSION + */ + public $Version = '5.2.22'; + + /** + * SMTP server port number. + * @var integer + * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead + * @see SMTP::DEFAULT_SMTP_PORT + */ + public $SMTP_PORT = 25; + + /** + * SMTP reply line ending. + * @var string + * @deprecated Use the `CRLF` constant instead + * @see SMTP::CRLF + */ + public $CRLF = "\r\n"; + + /** + * Debug output level. + * Options: + * * self::DEBUG_OFF (`0`) No debug output, default + * * self::DEBUG_CLIENT (`1`) Client commands + * * self::DEBUG_SERVER (`2`) Client commands and server responses + * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status + * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages + * @var integer + */ + public $do_debug = self::DEBUG_OFF; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output + * * `error_log` Output to error log as configured in php.ini + * + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * <code> + * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; + * </code> + * @var string|callable + */ + public $Debugoutput = 'echo'; + + /** + * Whether to use VERP. + * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path + * @link http://www.postfix.org/VERP_README.html Info on VERP + * @var boolean + */ + public $do_verp = false; + + /** + * The timeout value for connection, in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. + * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 + * @var integer + */ + public $Timeout = 300; + + /** + * How long to wait for commands to complete, in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * @var integer + */ + public $Timelimit = 300; + + /** + * @var array patterns to extract smtp transaction id from smtp reply + * Only first capture group will be use, use non-capturing group to deal with it + * Extend this class to override this property to fulfil your needs. + */ + protected $smtp_transaction_id_patterns = array( + 'exim' => '/[0-9]{3} OK id=(.*)/', + 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', + 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/' + ); + + /** + * The socket for the server connection. + * @var resource + */ + protected $smtp_conn; + + /** + * Error information, if any, for the last SMTP command. + * @var array + */ + protected $error = array( + 'error' => '', + 'detail' => '', + 'smtp_code' => '', + 'smtp_code_ex' => '' + ); + + /** + * The reply the server sent to us for HELO. + * If null, no HELO string has yet been received. + * @var string|null + */ + protected $helo_rply = null; + + /** + * The set of SMTP extensions sent in reply to EHLO command. + * Indexes of the array are extension names. + * Value at index 'HELO' or 'EHLO' (according to command that was sent) + * represents the server name. In case of HELO it is the only element of the array. + * Other values can be boolean TRUE or an array containing extension options. + * If null, no HELO/EHLO string has yet been received. + * @var array|null + */ + protected $server_caps = null; + + /** + * The most recent reply received from the server. + * @var string + */ + protected $last_reply = ''; + + /** + * Output debugging info via a user-selected method. + * @see SMTP::$Debugoutput + * @see SMTP::$do_debug + * @param string $str Debug string to output + * @param integer $level The debug level of this message; see DEBUG_* constants + * @return void + */ + protected function edebug($str, $level = 0) + { + if ($level > $this->do_debug) { + return; + } + //Avoid clash with built-in function names + if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { + call_user_func($this->Debugoutput, $str, $level); + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ) + . "<br>\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); + echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( + "\n", + "\n \t ", + trim($str) + )."\n"; + } + } + + /** + * Connect to an SMTP server. + * @param string $host SMTP server IP or host name + * @param integer $port The port number to connect to + * @param integer $timeout How long to wait for the connection to open + * @param array $options An array of options for stream_context_create() + * @access public + * @return boolean + */ + public function connect($host, $port = null, $timeout = 30, $options = array()) + { + static $streamok; + //This is enabled by default since 5.0.0 but some providers disable it + //Check this once and cache the result + if (is_null($streamok)) { + $streamok = function_exists('stream_socket_client'); + } + // Clear errors to avoid confusion + $this->setError(''); + // Make sure we are __not__ connected + if ($this->connected()) { + // Already connected, generate error + $this->setError('Already connected to a server'); + return false; + } + if (empty($port)) { + $port = self::DEFAULT_SMTP_PORT; + } + // Connect to the SMTP server + $this->edebug( + "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), + self::DEBUG_CONNECTION + ); + $errno = 0; + $errstr = ''; + if ($streamok) { + $socket_context = stream_context_create($options); + set_error_handler(array($this, 'errorHandler')); + $this->smtp_conn = stream_socket_client( + $host . ":" . $port, + $errno, + $errstr, + $timeout, + STREAM_CLIENT_CONNECT, + $socket_context + ); + restore_error_handler(); + } else { + //Fall back to fsockopen which should work in more places, but is missing some features + $this->edebug( + "Connection: stream_socket_client not available, falling back to fsockopen", + self::DEBUG_CONNECTION + ); + set_error_handler(array($this, 'errorHandler')); + $this->smtp_conn = fsockopen( + $host, + $port, + $errno, + $errstr, + $timeout + ); + restore_error_handler(); + } + // Verify we connected properly + if (!is_resource($this->smtp_conn)) { + $this->setError( + 'Failed to connect to server', + $errno, + $errstr + ); + $this->edebug( + 'SMTP ERROR: ' . $this->error['error'] + . ": $errstr ($errno)", + self::DEBUG_CLIENT + ); + return false; + } + $this->edebug('Connection: opened', self::DEBUG_CONNECTION); + // SMTP server can take longer to respond, give longer timeout for first read + // Windows does not have support for this timeout function + if (substr(PHP_OS, 0, 3) != 'WIN') { + $max = ini_get('max_execution_time'); + // Don't bother if unlimited + if ($max != 0 && $timeout > $max) { + @set_time_limit($timeout); + } + stream_set_timeout($this->smtp_conn, $timeout, 0); + } + // Get any announcement + $announce = $this->get_lines(); + $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); + return true; + } + + /** + * Initiate a TLS (encrypted) session. + * @access public + * @return boolean + */ + public function startTLS() + { + if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) { + return false; + } + + //Allow the best TLS version(s) we can + $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; + + //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT + //so add them back in manually if we can + if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; + } + + // Begin encrypted connection + if (!stream_socket_enable_crypto( + $this->smtp_conn, + true, + $crypto_method + )) { + return false; + } + return true; + } + + /** + * Perform SMTP authentication. + * Must be run after hello(). + * @see hello() + * @param string $username The user name + * @param string $password The password + * @param string $authtype The auth type (PLAIN, LOGIN, CRAM-MD5) + * @param string $realm The auth realm for NTLM + * @param string $workstation The auth workstation for NTLM + * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth) + * @return bool True if successfully authenticated.* @access public + */ + public function authenticate( + $username, + $password, + $authtype = null, + $realm = '', + $workstation = '', + $OAuth = null + ) { + if (!$this->server_caps) { + $this->setError('Authentication is not allowed before HELO/EHLO'); + return false; + } + + if (array_key_exists('EHLO', $this->server_caps)) { + // SMTP extensions are available. Let's try to find a proper authentication method + + if (!array_key_exists('AUTH', $this->server_caps)) { + $this->setError('Authentication is not allowed at this stage'); + // 'at this stage' means that auth may be allowed after the stage changes + // e.g. after STARTTLS + return false; + } + + self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); + self::edebug( + 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), + self::DEBUG_LOWLEVEL + ); + + if (empty($authtype)) { + foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN') as $method) { + if (in_array($method, $this->server_caps['AUTH'])) { + $authtype = $method; + break; + } + } + if (empty($authtype)) { + $this->setError('No supported authentication methods found'); + return false; + } + self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); + } + + if (!in_array($authtype, $this->server_caps['AUTH'])) { + $this->setError("The requested authentication method \"$authtype\" is not supported by the server"); + return false; + } + } elseif (empty($authtype)) { + $authtype = 'LOGIN'; + } + switch ($authtype) { + case 'PLAIN': + // Start authentication + if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) { + return false; + } + // Send encoded username and password + if (!$this->sendCommand( + 'User & Password', + base64_encode("\0" . $username . "\0" . $password), + 235 + ) + ) { + return false; + } + break; + case 'LOGIN': + // Start authentication + if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) { + return false; + } + if (!$this->sendCommand("Username", base64_encode($username), 334)) { + return false; + } + if (!$this->sendCommand("Password", base64_encode($password), 235)) { + return false; + } + break; + case 'CRAM-MD5': + // Start authentication + if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) { + return false; + } + // Get the challenge + $challenge = base64_decode(substr($this->last_reply, 4)); + + // Build the response + $response = $username . ' ' . $this->hmac($challenge, $password); + + // send encoded credentials + return $this->sendCommand('Username', base64_encode($response), 235); + default: + $this->setError("Authentication method \"$authtype\" is not supported"); + return false; + } + return true; + } + + /** + * Calculate an MD5 HMAC hash. + * Works like hash_hmac('md5', $data, $key) + * in case that function is not available + * @param string $data The data to hash + * @param string $key The key to hash with + * @access protected + * @return string + */ + protected function hmac($data, $key) + { + if (function_exists('hash_hmac')) { + return hash_hmac('md5', $data, $key); + } + + // The following borrowed from + // http://php.net/manual/en/function.mhash.php#27225 + + // RFC 2104 HMAC implementation for php. + // Creates an md5 HMAC. + // Eliminates the need to install mhash to compute a HMAC + // by Lance Rushing + + $bytelen = 64; // byte length for md5 + if (strlen($key) > $bytelen) { + $key = pack('H*', md5($key)); + } + $key = str_pad($key, $bytelen, chr(0x00)); + $ipad = str_pad('', $bytelen, chr(0x36)); + $opad = str_pad('', $bytelen, chr(0x5c)); + $k_ipad = $key ^ $ipad; + $k_opad = $key ^ $opad; + + return md5($k_opad . pack('H*', md5($k_ipad . $data))); + } + + /** + * Check connection state. + * @access public + * @return boolean True if connected. + */ + public function connected() + { + if (is_resource($this->smtp_conn)) { + $sock_status = stream_get_meta_data($this->smtp_conn); + if ($sock_status['eof']) { + // The socket is valid but we are not connected + $this->edebug( + 'SMTP NOTICE: EOF caught while checking if connected', + self::DEBUG_CLIENT + ); + $this->close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Close the socket and clean up the state of the class. + * Don't use this function without first trying to use QUIT. + * @see quit() + * @access public + * @return void + */ + public function close() + { + $this->setError(''); + $this->server_caps = null; + $this->helo_rply = null; + if (is_resource($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = null; //Makes for cleaner serialization + $this->edebug('Connection: closed', self::DEBUG_CONNECTION); + } + } + + /** + * Send an SMTP DATA command. + * Issues a data command and sends the msg_data to the server, + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a <CRLF> with the message headers + * and the message body being separated by and additional <CRLF>. + * Implements rfc 821: DATA <CRLF> + * @param string $msg_data Message data to send + * @access public + * @return boolean + */ + public function data($msg_data) + { + //This will use the standard timelimit + if (!$this->sendCommand('DATA', 'DATA', 354)) { + return false; + } + + /* The server is ready to accept data! + * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF) + * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into + * smaller lines to fit within the limit. + * We will also look for lines that start with a '.' and prepend an additional '.'. + * NOTE: this does not count towards line-length limit. + */ + + // Normalize line breaks before exploding + $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data)); + + /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field + * of the first line (':' separated) does not contain a space then it _should_ be a header and we will + * process all lines before a blank line as headers. + */ + + $field = substr($lines[0], 0, strpos($lines[0], ':')); + $in_headers = false; + if (!empty($field) && strpos($field, ' ') === false) { + $in_headers = true; + } + + foreach ($lines as $line) { + $lines_out = array(); + if ($in_headers and $line == '') { + $in_headers = false; + } + //Break this line up into several smaller lines if it's too long + //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len), + while (isset($line[self::MAX_LINE_LENGTH])) { + //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on + //so as to avoid breaking in the middle of a word + $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' '); + //Deliberately matches both false and 0 + if (!$pos) { + //No nice break found, add a hard break + $pos = self::MAX_LINE_LENGTH - 1; + $lines_out[] = substr($line, 0, $pos); + $line = substr($line, $pos); + } else { + //Break at the found point + $lines_out[] = substr($line, 0, $pos); + //Move along by the amount we dealt with + $line = substr($line, $pos + 1); + } + //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 + if ($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + //Send the lines to the server + foreach ($lines_out as $line_out) { + //RFC2821 section 4.5.2 + if (!empty($line_out) and $line_out[0] == '.') { + $line_out = '.' . $line_out; + } + $this->client_send($line_out . self::CRLF); + } + } + + //Message data has been sent, complete the command + //Increase timelimit for end of DATA command + $savetimelimit = $this->Timelimit; + $this->Timelimit = $this->Timelimit * 2; + $result = $this->sendCommand('DATA END', '.', 250); + //Restore timelimit + $this->Timelimit = $savetimelimit; + return $result; + } + + /** + * Send an SMTP HELO or EHLO command. + * Used to identify the sending server to the receiving server. + * This makes sure that client and server are in a known state. + * Implements RFC 821: HELO <SP> <domain> <CRLF> + * and RFC 2821 EHLO. + * @param string $host The host name or IP to connect to + * @access public + * @return boolean + */ + public function hello($host = '') + { + //Try extended hello first (RFC 2821) + return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); + } + + /** + * Send an SMTP HELO or EHLO command. + * Low-level implementation used by hello() + * @see hello() + * @param string $hello The HELO string + * @param string $host The hostname to say we are + * @access protected + * @return boolean + */ + protected function sendHello($hello, $host) + { + $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); + $this->helo_rply = $this->last_reply; + if ($noerror) { + $this->parseHelloFields($hello); + } else { + $this->server_caps = null; + } + return $noerror; + } + + /** + * Parse a reply to HELO/EHLO command to discover server extensions. + * In case of HELO, the only parameter that can be discovered is a server name. + * @access protected + * @param string $type - 'HELO' or 'EHLO' + */ + protected function parseHelloFields($type) + { + $this->server_caps = array(); + $lines = explode("\n", $this->helo_rply); + + foreach ($lines as $n => $s) { + //First 4 chars contain response code followed by - or space + $s = trim(substr($s, 4)); + if (empty($s)) { + continue; + } + $fields = explode(' ', $s); + if (!empty($fields)) { + if (!$n) { + $name = $type; + $fields = $fields[0]; + } else { + $name = array_shift($fields); + switch ($name) { + case 'SIZE': + $fields = ($fields ? $fields[0] : 0); + break; + case 'AUTH': + if (!is_array($fields)) { + $fields = array(); + } + break; + default: + $fields = true; + } + } + $this->server_caps[$name] = $fields; + } + } + } + + /** + * Send an SMTP MAIL command. + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more recipient + * commands may be called followed by a data command. + * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> + * @param string $from Source address of this message + * @access public + * @return boolean + */ + public function mail($from) + { + $useVerp = ($this->do_verp ? ' XVERP' : ''); + return $this->sendCommand( + 'MAIL FROM', + 'MAIL FROM:<' . $from . '>' . $useVerp, + 250 + ); + } + + /** + * Send an SMTP QUIT command. + * Closes the socket if there is no error or the $close_on_error argument is true. + * Implements from rfc 821: QUIT <CRLF> + * @param boolean $close_on_error Should the connection close if an error occurs? + * @access public + * @return boolean + */ + public function quit($close_on_error = true) + { + $noerror = $this->sendCommand('QUIT', 'QUIT', 221); + $err = $this->error; //Save any error + if ($noerror or $close_on_error) { + $this->close(); + $this->error = $err; //Restore any error from the quit command + } + return $noerror; + } + + /** + * Send an SMTP RCPT command. + * Sets the TO argument to $toaddr. + * Returns true if the recipient was accepted false if it was rejected. + * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> + * @param string $address The address the message is being sent to + * @access public + * @return boolean + */ + public function recipient($address) + { + return $this->sendCommand( + 'RCPT TO', + 'RCPT TO:<' . $address . '>', + array(250, 251) + ); + } + + /** + * Send an SMTP RSET command. + * Abort any transaction that is currently in progress. + * Implements rfc 821: RSET <CRLF> + * @access public + * @return boolean True on success. + */ + public function reset() + { + return $this->sendCommand('RSET', 'RSET', 250); + } + + /** + * Send a command to an SMTP server and check its return code. + * @param string $command The command name - not sent to the server + * @param string $commandstring The actual command to send + * @param integer|array $expect One or more expected integer success codes + * @access protected + * @return boolean True on success. + */ + protected function sendCommand($command, $commandstring, $expect) + { + if (!$this->connected()) { + $this->setError("Called $command without being connected"); + return false; + } + //Reject line breaks in all commands + if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) { + $this->setError("Command '$command' contained line breaks"); + return false; + } + $this->client_send($commandstring . self::CRLF); + + $this->last_reply = $this->get_lines(); + // Fetch SMTP code and possible error code explanation + $matches = array(); + if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) { + $code = $matches[1]; + $code_ex = (count($matches) > 2 ? $matches[2] : null); + // Cut off error code from each response line + $detail = preg_replace( + "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", + '', + $this->last_reply + ); + } else { + // Fall back to simple parsing if regex fails + $code = substr($this->last_reply, 0, 3); + $code_ex = null; + $detail = substr($this->last_reply, 4); + } + + $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); + + if (!in_array($code, (array)$expect)) { + $this->setError( + "$command command failed", + $detail, + $code, + $code_ex + ); + $this->edebug( + 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, + self::DEBUG_CLIENT + ); + return false; + } + + $this->setError(''); + return true; + } + + /** + * Send an SMTP SAML command. + * Starts a mail transaction from the email address specified in $from. + * Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more recipient + * commands may be called followed by a data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> + * @param string $from The address the message is from + * @access public + * @return boolean + */ + public function sendAndMail($from) + { + return $this->sendCommand('SAML', "SAML FROM:$from", 250); + } + + /** + * Send an SMTP VRFY command. + * @param string $name The name to verify + * @access public + * @return boolean + */ + public function verify($name) + { + return $this->sendCommand('VRFY', "VRFY $name", array(250, 251)); + } + + /** + * Send an SMTP NOOP command. + * Used to keep keep-alives alive, doesn't actually do anything + * @access public + * @return boolean + */ + public function noop() + { + return $this->sendCommand('NOOP', 'NOOP', 250); + } + + /** + * Send an SMTP TURN command. + * This is an optional command for SMTP that this class does not support. + * This method is here to make the RFC821 Definition complete for this class + * and _may_ be implemented in future + * Implements from rfc 821: TURN <CRLF> + * @access public + * @return boolean + */ + public function turn() + { + $this->setError('The SMTP TURN command is not implemented'); + $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); + return false; + } + + /** + * Send raw data to the server. + * @param string $data The data to send + * @access public + * @return integer|boolean The number of bytes sent to the server or false on error + */ + public function client_send($data) + { + $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); + return fwrite($this->smtp_conn, $data); + } + + /** + * Get the latest error. + * @access public + * @return array + */ + public function getError() + { + return $this->error; + } + + /** + * Get SMTP extensions available on the server + * @access public + * @return array|null + */ + public function getServerExtList() + { + return $this->server_caps; + } + + /** + * A multipurpose method + * The method works in three ways, dependent on argument value and current state + * 1. HELO/EHLO was not sent - returns null and set up $this->error + * 2. HELO was sent + * $name = 'HELO': returns server name + * $name = 'EHLO': returns boolean false + * $name = any string: returns null and set up $this->error + * 3. EHLO was sent + * $name = 'HELO'|'EHLO': returns server name + * $name = any string: if extension $name exists, returns boolean True + * or its options. Otherwise returns boolean False + * In other words, one can use this method to detect 3 conditions: + * - null returned: handshake was not or we don't know about ext (refer to $this->error) + * - false returned: the requested feature exactly not exists + * - positive value returned: the requested feature exists + * @param string $name Name of SMTP extension or 'HELO'|'EHLO' + * @return mixed + */ + public function getServerExt($name) + { + if (!$this->server_caps) { + $this->setError('No HELO/EHLO was sent'); + return null; + } + + // the tight logic knot ;) + if (!array_key_exists($name, $this->server_caps)) { + if ($name == 'HELO') { + return $this->server_caps['EHLO']; + } + if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) { + return false; + } + $this->setError('HELO handshake was used. Client knows nothing about server extensions'); + return null; + } + + return $this->server_caps[$name]; + } + + /** + * Get the last reply from the server. + * @access public + * @return string + */ + public function getLastReply() + { + return $this->last_reply; + } + + /** + * Read the SMTP server's response. + * Either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access protected + * @return string + */ + protected function get_lines() + { + // If the connection is bad, give up straight away + if (!is_resource($this->smtp_conn)) { + return ''; + } + $data = ''; + $endtime = 0; + stream_set_timeout($this->smtp_conn, $this->Timeout); + if ($this->Timelimit > 0) { + $endtime = time() + $this->Timelimit; + } + while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { + $str = @fgets($this->smtp_conn, 515); + $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); + $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); + $data .= $str; + // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen + if ((isset($str[3]) and $str[3] == ' ')) { + break; + } + // Timed-out? Log and break + $info = stream_get_meta_data($this->smtp_conn); + if ($info['timed_out']) { + $this->edebug( + 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', + self::DEBUG_LOWLEVEL + ); + break; + } + // Now check if reads took too long + if ($endtime and time() > $endtime) { + $this->edebug( + 'SMTP -> get_lines(): timelimit reached ('. + $this->Timelimit . ' sec)', + self::DEBUG_LOWLEVEL + ); + break; + } + } + return $data; + } + + /** + * Enable or disable VERP address generation. + * @param boolean $enabled + */ + public function setVerp($enabled = false) + { + $this->do_verp = $enabled; + } + + /** + * Get VERP address generation mode. + * @return boolean + */ + public function getVerp() + { + return $this->do_verp; + } + + /** + * Set error messages and codes. + * @param string $message The error message + * @param string $detail Further detail on the error + * @param string $smtp_code An associated SMTP error code + * @param string $smtp_code_ex Extended SMTP code + */ + protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '') + { + $this->error = array( + 'error' => $message, + 'detail' => $detail, + 'smtp_code' => $smtp_code, + 'smtp_code_ex' => $smtp_code_ex + ); + } + + /** + * Set debug output method. + * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it. + */ + public function setDebugOutput($method = 'echo') + { + $this->Debugoutput = $method; + } + + /** + * Get debug output method. + * @return string + */ + public function getDebugOutput() + { + return $this->Debugoutput; + } + + /** + * Set debug output level. + * @param integer $level + */ + public function setDebugLevel($level = 0) + { + $this->do_debug = $level; + } + + /** + * Get debug output level. + * @return integer + */ + public function getDebugLevel() + { + return $this->do_debug; + } + + /** + * Set SMTP timeout. + * @param integer $timeout + */ + public function setTimeout($timeout = 0) + { + $this->Timeout = $timeout; + } + + /** + * Get SMTP timeout. + * @return integer + */ + public function getTimeout() + { + return $this->Timeout; + } + + /** + * Reports an error number and string. + * @param integer $errno The error number returned by PHP. + * @param string $errmsg The error message returned by PHP. + */ + protected function errorHandler($errno, $errmsg) + { + $notice = 'Connection: Failed to connect to server.'; + $this->setError( + $notice, + $errno, + $errmsg + ); + $this->edebug( + $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg, + self::DEBUG_CONNECTION + ); + } + + /** + * Will return the ID of the last smtp transaction based on a list of patterns provided + * in SMTP::$smtp_transaction_id_patterns. + * If no reply has been received yet, it will return null. + * If no pattern has been matched, it will return false. + * @return bool|null|string + */ + public function getLastTransactionID() + { + $reply = $this->getLastReply(); + + if (empty($reply)) { + return null; + } + + foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { + if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { + return $matches[1]; + } + } + + return false; + } +} diff --git a/backend/wp-includes/class-snoopy.php b/backend/wp-includes/class-snoopy.php new file mode 100644 index 0000000..f26eb0e --- /dev/null +++ b/backend/wp-includes/class-snoopy.php @@ -0,0 +1,1259 @@ +<?php + +/** + * Deprecated. Use WP_HTTP (http.php) instead. + */ +_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/http.php' ); + +if ( ! class_exists( 'Snoopy', false ) ) : +/************************************************* + +Snoopy - the PHP net client +Author: Monte Ohrt <monte@ispi.net> +Copyright (c): 1999-2008 New Digital Group, all rights reserved +Version: 1.2.4 + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +You may contact the author of Snoopy by e-mail at: +monte@ohrt.com + +The latest version of Snoopy can be obtained from: +http://snoopy.sourceforge.net/ + +*************************************************/ + +class Snoopy +{ + /**** Public variables ****/ + + /* user definable vars */ + + var $host = "www.php.net"; // host name we are connecting to + var $port = 80; // port we are connecting to + var $proxy_host = ""; // proxy host to use + var $proxy_port = ""; // proxy port to use + var $proxy_user = ""; // proxy user to use + var $proxy_pass = ""; // proxy password to use + + var $agent = "Snoopy v1.2.4"; // agent we masquerade as + var $referer = ""; // referer info to pass + var $cookies = array(); // array of cookies to pass + // $cookies["username"]="joe"; + var $rawheaders = array(); // array of raw headers to send + // $rawheaders["Content-type"]="text/html"; + + var $maxredirs = 5; // http redirection depth maximum. 0 = disallow + var $lastredirectaddr = ""; // contains address of last redirected address + var $offsiteok = true; // allows redirection off-site + var $maxframes = 0; // frame content depth maximum. 0 = disallow + var $expandlinks = true; // expand links to fully qualified URLs. + // this only applies to fetchlinks() + // submitlinks(), and submittext() + var $passcookies = true; // pass set cookies back through redirects + // NOTE: this currently does not respect + // dates, domains or paths. + + var $user = ""; // user for http authentication + var $pass = ""; // password for http authentication + + // http accept types + var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + + var $results = ""; // where the content is put + + var $error = ""; // error messages sent here + var $response_code = ""; // response code returned from server + var $headers = array(); // headers returned from server sent here + var $maxlength = 500000; // max return data length (body) + var $read_timeout = 0; // timeout on read operations, in seconds + // supported only since PHP 4 Beta 4 + // set to 0 to disallow timeouts + var $timed_out = false; // if a read operation timed out + var $status = 0; // http request status + + var $temp_dir = "/tmp"; // temporary directory that the webserver + // has permission to write to. + // under Windows, this should be C:\temp + + var $curl_path = "/usr/local/bin/curl"; + // Snoopy will use cURL for fetching + // SSL content if a full system path to + // the cURL binary is supplied here. + // set to false if you do not have + // cURL installed. See http://curl.haxx.se + // for details on installing cURL. + // Snoopy does *not* use the cURL + // library functions built into php, + // as these functions are not stable + // as of this Snoopy release. + + /**** Private variables ****/ + + var $_maxlinelen = 4096; // max line length (headers) + + var $_httpmethod = "GET"; // default http request method + var $_httpversion = "HTTP/1.0"; // default http request version + var $_submit_method = "POST"; // default submit method + var $_submit_type = "application/x-www-form-urlencoded"; // default submit type + var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type + var $_redirectaddr = false; // will be set if page fetched is a redirect + var $_redirectdepth = 0; // increments on an http redirect + var $_frameurls = array(); // frame src urls + var $_framedepth = 0; // increments on frame depth + + var $_isproxy = false; // set if using a proxy server + var $_fp_timeout = 30; // timeout for socket connection + +/*======================================================================*\ + Function: fetch + Purpose: fetch the contents of a web page + (and possibly other protocols in the + future like ftp, nntp, gopher, etc.) + Input: $URI the location of the page to fetch + Output: $this->results the output text from the fetch +\*======================================================================*/ + + function fetch($URI) + { + + //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); + $URI_PARTS = parse_url($URI); + if (!empty($URI_PARTS["user"])) + $this->user = $URI_PARTS["user"]; + if (!empty($URI_PARTS["pass"])) + $this->pass = $URI_PARTS["pass"]; + if (empty($URI_PARTS["query"])) + $URI_PARTS["query"] = ''; + if (empty($URI_PARTS["path"])) + $URI_PARTS["path"] = ''; + + switch(strtolower($URI_PARTS["scheme"])) + { + case "http": + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_connect($fp)) + { + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httprequest($path, $fp, $URI, $this->_httpmethod); + } + + $this->_disconnect($fp); + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + } + else + { + return false; + } + return true; + break; + case "https": + if(!$this->curl_path) + return false; + if(function_exists("is_executable")) + if (!is_executable($this->curl_path)) + return false; + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httpsrequest($URI,$URI,$this->_httpmethod); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httpsrequest($path, $URI, $this->_httpmethod); + } + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + $this->fetch($this->_redirectaddr); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + return true; + break; + default: + // not a valid protocol + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; + return false; + break; + } + return true; + } + +/*======================================================================*\ + Function: submit + Purpose: submit an http form + Input: $URI the location to post the data + $formvars the formvars to use. + format: $formvars["var"] = "val"; + $formfiles an array of files to submit + format: $formfiles["var"] = "/dir/filename.ext"; + Output: $this->results the text output from the post +\*======================================================================*/ + + function submit($URI, $formvars="", $formfiles="") + { + unset($postdata); + + $postdata = $this->_prepare_post_body($formvars, $formfiles); + + $URI_PARTS = parse_url($URI); + if (!empty($URI_PARTS["user"])) + $this->user = $URI_PARTS["user"]; + if (!empty($URI_PARTS["pass"])) + $this->pass = $URI_PARTS["pass"]; + if (empty($URI_PARTS["query"])) + $URI_PARTS["query"] = ''; + if (empty($URI_PARTS["path"])) + $URI_PARTS["path"] = ''; + + switch(strtolower($URI_PARTS["scheme"])) + { + case "http": + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_connect($fp)) + { + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + + $this->_disconnect($fp); + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); + + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + if( strpos( $this->_redirectaddr, "?" ) > 0 ) + $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get + else + $this->submit($this->_redirectaddr,$formvars, $formfiles); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + + } + else + { + return false; + } + return true; + break; + case "https": + if(!$this->curl_path) + return false; + if(function_exists("is_executable")) + if (!is_executable($this->curl_path)) + return false; + $this->host = $URI_PARTS["host"]; + if(!empty($URI_PARTS["port"])) + $this->port = $URI_PARTS["port"]; + if($this->_isproxy) + { + // using proxy, send entire URI + $this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + else + { + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); + // no proxy, send only the path + $this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata); + } + + if($this->_redirectaddr) + { + /* url was redirected, check if we've hit the max depth */ + if($this->maxredirs > $this->_redirectdepth) + { + if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); + + // only follow redirect if it's on this site, or offsiteok is true + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) + { + /* follow the redirect */ + $this->_redirectdepth++; + $this->lastredirectaddr=$this->_redirectaddr; + if( strpos( $this->_redirectaddr, "?" ) > 0 ) + $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get + else + $this->submit($this->_redirectaddr,$formvars, $formfiles); + } + } + } + + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) + { + $frameurls = $this->_frameurls; + $this->_frameurls = array(); + + while(list(,$frameurl) = each($frameurls)) + { + if($this->_framedepth < $this->maxframes) + { + $this->fetch($frameurl); + $this->_framedepth++; + } + else + break; + } + } + return true; + break; + + default: + // not a valid protocol + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; + return false; + break; + } + return true; + } + +/*======================================================================*\ + Function: fetchlinks + Purpose: fetch the links from a web page + Input: $URI where you are fetching from + Output: $this->results an array of the URLs +\*======================================================================*/ + + function fetchlinks($URI) + { + if ($this->fetch($URI)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$x<count($this->results);$x++) + $this->results[$x] = $this->_striplinks($this->results[$x]); + } + else + $this->results = $this->_striplinks($this->results); + + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results, $URI); + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: fetchform + Purpose: fetch the form elements from a web page + Input: $URI where you are fetching from + Output: $this->results the resulting html form +\*======================================================================*/ + + function fetchform($URI) + { + + if ($this->fetch($URI)) + { + + if(is_array($this->results)) + { + for($x=0;$x<count($this->results);$x++) + $this->results[$x] = $this->_stripform($this->results[$x]); + } + else + $this->results = $this->_stripform($this->results); + + return true; + } + else + return false; + } + + +/*======================================================================*\ + Function: fetchtext + Purpose: fetch the text from a web page, stripping the links + Input: $URI where you are fetching from + Output: $this->results the text from the web page +\*======================================================================*/ + + function fetchtext($URI) + { + if($this->fetch($URI)) + { + if(is_array($this->results)) + { + for($x=0;$x<count($this->results);$x++) + $this->results[$x] = $this->_striptext($this->results[$x]); + } + else + $this->results = $this->_striptext($this->results); + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: submitlinks + Purpose: grab links from a form submission + Input: $URI where you are submitting from + Output: $this->results an array of the links from the post +\*======================================================================*/ + + function submitlinks($URI, $formvars="", $formfiles="") + { + if($this->submit($URI,$formvars, $formfiles)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$x<count($this->results);$x++) + { + $this->results[$x] = $this->_striplinks($this->results[$x]); + if($this->expandlinks) + $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); + } + } + else + { + $this->results = $this->_striplinks($this->results); + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results,$URI); + } + return true; + } + else + return false; + } + +/*======================================================================*\ + Function: submittext + Purpose: grab text from a form submission + Input: $URI where you are submitting from + Output: $this->results the text from the web page +\*======================================================================*/ + + function submittext($URI, $formvars = "", $formfiles = "") + { + if($this->submit($URI,$formvars, $formfiles)) + { + if($this->lastredirectaddr) + $URI = $this->lastredirectaddr; + if(is_array($this->results)) + { + for($x=0;$x<count($this->results);$x++) + { + $this->results[$x] = $this->_striptext($this->results[$x]); + if($this->expandlinks) + $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); + } + } + else + { + $this->results = $this->_striptext($this->results); + if($this->expandlinks) + $this->results = $this->_expandlinks($this->results,$URI); + } + return true; + } + else + return false; + } + + + +/*======================================================================*\ + Function: set_submit_multipart + Purpose: Set the form submission content type to + multipart/form-data +\*======================================================================*/ + function set_submit_multipart() + { + $this->_submit_type = "multipart/form-data"; + } + + +/*======================================================================*\ + Function: set_submit_normal + Purpose: Set the form submission content type to + application/x-www-form-urlencoded +\*======================================================================*/ + function set_submit_normal() + { + $this->_submit_type = "application/x-www-form-urlencoded"; + } + + + + +/*======================================================================*\ + Private functions +\*======================================================================*/ + + +/*======================================================================*\ + Function: _striplinks + Purpose: strip the hyperlinks from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _striplinks($document) + { + preg_match_all("'<\s*a\s.*?href\s*=\s* # find <a href= + ([\"\'])? # find single or double quote + (?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching + # quote, otherwise match up to next space + 'isx",$document,$links); + + + // catenate the non-empty matches from the conditional subpattern + + while(list($key,$val) = each($links[2])) + { + if(!empty($val)) + $match[] = $val; + } + + while(list($key,$val) = each($links[3])) + { + if(!empty($val)) + $match[] = $val; + } + + // return the links + return $match; + } + +/*======================================================================*\ + Function: _stripform + Purpose: strip the form elements from an html document + Input: $document document to strip. + Output: $match an array of the links +\*======================================================================*/ + + function _stripform($document) + { + preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); + + // catenate the matches + $match = implode("\r\n",$elements[0]); + + // return the links + return $match; + } + + + +/*======================================================================*\ + Function: _striptext + Purpose: strip the text from an html document + Input: $document document to strip. + Output: $text the resulting text +\*======================================================================*/ + + function _striptext($document) + { + + // I didn't use preg eval (//e) since that is only available in PHP 4.0. + // so, list your entities one by one here. I included some of the + // more common ones. + + $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript + "'<[\/\!]*?[^<>]*?>'si", // strip out html tags + "'([\r\n])[\s]+'", // strip out white space + "'&(quot|#34|#034|#x22);'i", // replace html entities + "'&(amp|#38|#038|#x26);'i", // added hexadecimal values + "'&(lt|#60|#060|#x3c);'i", + "'&(gt|#62|#062|#x3e);'i", + "'&(nbsp|#160|#xa0);'i", + "'&(iexcl|#161);'i", + "'&(cent|#162);'i", + "'&(pound|#163);'i", + "'&(copy|#169);'i", + "'&(reg|#174);'i", + "'&(deg|#176);'i", + "'&(#39|#039|#x27);'", + "'&(euro|#8364);'i", // europe + "'&a(uml|UML);'", // german + "'&o(uml|UML);'", + "'&u(uml|UML);'", + "'&A(uml|UML);'", + "'&O(uml|UML);'", + "'&U(uml|UML);'", + "'ß'i", + ); + $replace = array( "", + "", + "\\1", + "\"", + "&", + "<", + ">", + " ", + chr(161), + chr(162), + chr(163), + chr(169), + chr(174), + chr(176), + chr(39), + chr(128), + chr(0xE4), // ANSI ä + chr(0xF6), // ANSI ö + chr(0xFC), // ANSI ü + chr(0xC4), // ANSI Ä + chr(0xD6), // ANSI Ö + chr(0xDC), // ANSI Ü + chr(0xDF), // ANSI ß + ); + + $text = preg_replace($search,$replace,$document); + + return $text; + } + +/*======================================================================*\ + Function: _expandlinks + Purpose: expand each link into a fully qualified URL + Input: $links the links to qualify + $URI the full URI to get the base from + Output: $expandedLinks the expanded links +\*======================================================================*/ + + function _expandlinks($links,$URI) + { + + preg_match("/^[^\?]+/",$URI,$match); + + $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); + $match = preg_replace("|/$|","",$match); + $match_part = parse_url($match); + $match_root = + $match_part["scheme"]."://".$match_part["host"]; + + $search = array( "|^http://".preg_quote($this->host)."|i", + "|^(\/)|i", + "|^(?!http://)(?!mailto:)|i", + "|/\./|", + "|/[^\/]+/\.\./|" + ); + + $replace = array( "", + $match_root."/", + $match."/", + "/", + "/" + ); + + $expandedLinks = preg_replace($search,$replace,$links); + + return $expandedLinks; + } + +/*======================================================================*\ + Function: _httprequest + Purpose: go get the http data from the server + Input: $url the url to fetch + $fp the current open file pointer + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") + { + $cookie_headers = ''; + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; + if(!empty($this->agent)) + $headers .= "User-Agent: ".$this->agent."\r\n"; + if(!empty($this->host) && !isset($this->rawheaders['Host'])) { + $headers .= "Host: ".$this->host; + if(!empty($this->port) && $this->port != 80) + $headers .= ":".$this->port; + $headers .= "\r\n"; + } + if(!empty($this->accept)) + $headers .= "Accept: ".$this->accept."\r\n"; + if(!empty($this->referer)) + $headers .= "Referer: ".$this->referer."\r\n"; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_headers .= 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers .= substr($cookie_headers,0,-2) . "\r\n"; + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers .= $headerKey.": ".$headerVal."\r\n"; + } + if(!empty($content_type)) { + $headers .= "Content-type: $content_type"; + if ($content_type == "multipart/form-data") + $headers .= "; boundary=".$this->_mime_boundary; + $headers .= "\r\n"; + } + if(!empty($body)) + $headers .= "Content-length: ".strlen($body)."\r\n"; + if(!empty($this->user) || !empty($this->pass)) + $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; + + //add proxy auth headers + if(!empty($this->proxy_user)) + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n"; + + + $headers .= "\r\n"; + + // set the read timeout if needed + if ($this->read_timeout > 0) + socket_set_timeout($fp, $this->read_timeout); + $this->timed_out = false; + + fwrite($fp,$headers.$body,strlen($headers.$body)); + + $this->_redirectaddr = false; + unset($this->headers); + + while($currentHeader = fgets($fp,$this->_maxlinelen)) + { + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + if($currentHeader == "\r\n") + break; + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location:|URI:)/i",$currentHeader)) + { + // get URL portion of the redirect + preg_match("/^(Location:|URI:)[ ]+(.*)/i",chop($currentHeader),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$currentHeader)) + { + if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) + { + $this->status= $status[1]; + } + $this->response_code = $currentHeader; + } + + $this->headers[] = $currentHeader; + } + + $results = ''; + do { + $_data = fread($fp, $this->maxlength); + if (strlen($_data) == 0) { + break; + } + $results .= $_data; + } while(true); + + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) + { + $this->status=-100; + return false; + } + + // check if there is a redirect meta tag + + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x<count($match[1]); $x++) + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + return true; + } + +/*======================================================================*\ + Function: _httpsrequest + Purpose: go get the https data from the server using curl + Input: $url the url to fetch + $URI the full URI + $body body contents to send if any (POST) + Output: +\*======================================================================*/ + + function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") + { + if($this->passcookies && $this->_redirectaddr) + $this->setcookies(); + + $headers = array(); + + $URI_PARTS = parse_url($URI); + if(empty($url)) + $url = "/"; + // GET ... header not needed for curl + //$headers[] = $http_method." ".$url." ".$this->_httpversion; + if(!empty($this->agent)) + $headers[] = "User-Agent: ".$this->agent; + if(!empty($this->host)) + if(!empty($this->port)) + $headers[] = "Host: ".$this->host.":".$this->port; + else + $headers[] = "Host: ".$this->host; + if(!empty($this->accept)) + $headers[] = "Accept: ".$this->accept; + if(!empty($this->referer)) + $headers[] = "Referer: ".$this->referer; + if(!empty($this->cookies)) + { + if(!is_array($this->cookies)) + $this->cookies = (array)$this->cookies; + + reset($this->cookies); + if ( count($this->cookies) > 0 ) { + $cookie_str = 'Cookie: '; + foreach ( $this->cookies as $cookieKey => $cookieVal ) { + $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; + } + $headers[] = substr($cookie_str,0,-2); + } + } + if(!empty($this->rawheaders)) + { + if(!is_array($this->rawheaders)) + $this->rawheaders = (array)$this->rawheaders; + while(list($headerKey,$headerVal) = each($this->rawheaders)) + $headers[] = $headerKey.": ".$headerVal; + } + if(!empty($content_type)) { + if ($content_type == "multipart/form-data") + $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; + else + $headers[] = "Content-type: $content_type"; + } + if(!empty($body)) + $headers[] = "Content-length: ".strlen($body); + if(!empty($this->user) || !empty($this->pass)) + $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); + + $headerfile = tempnam( $this->temp_dir, "sno" ); + $cmdline_params = '-k -D ' . escapeshellarg( $headerfile ); + + foreach ( $headers as $header ) { + $cmdline_params .= ' -H ' . escapeshellarg( $header ); + } + + if ( ! empty( $body ) ) { + $cmdline_params .= ' -d ' . escapeshellarg( $body ); + } + + if ( $this->read_timeout > 0 ) { + $cmdline_params .= ' -m ' . escapeshellarg( $this->read_timeout ); + } + + + exec( $this->curl_path . ' ' . $cmdline_params . ' ' . escapeshellarg( $URI ), $results, $return ); + + if($return) + { + $this->error = "Error: cURL could not retrieve the document, error $return."; + return false; + } + + + $results = implode("\r\n",$results); + + $result_headers = file("$headerfile"); + + $this->_redirectaddr = false; + unset($this->headers); + + for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) + { + + // if a header begins with Location: or URI:, set the redirect + if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) + { + // get URL portion of the redirect + preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches); + // look for :// in the Location header to see if hostname is included + if(!preg_match("|\:\/\/|",$matches[2])) + { + // no host in the path, so prepend + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; + // eliminate double slash + if(!preg_match("|^/|",$matches[2])) + $this->_redirectaddr .= "/".$matches[2]; + else + $this->_redirectaddr .= $matches[2]; + } + else + $this->_redirectaddr = $matches[2]; + } + + if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) + $this->response_code = $result_headers[$currentHeader]; + + $this->headers[] = $result_headers[$currentHeader]; + } + + // check if there is a redirect meta tag + + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) + { + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); + } + + // have we hit our frame depth and is there frame src to fetch? + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) + { + $this->results[] = $results; + for($x=0; $x<count($match[1]); $x++) + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); + } + // have we already fetched framed content? + elseif(is_array($this->results)) + $this->results[] = $results; + // no framed content + else + $this->results = $results; + + unlink("$headerfile"); + + return true; + } + +/*======================================================================*\ + Function: setcookies() + Purpose: set cookies for a redirection +\*======================================================================*/ + + function setcookies() + { + for($x=0; $x<count($this->headers); $x++) + { + if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match)) + $this->cookies[$match[1]] = urldecode($match[2]); + } + } + + +/*======================================================================*\ + Function: _check_timeout + Purpose: checks whether timeout has occurred + Input: $fp file pointer +\*======================================================================*/ + + function _check_timeout($fp) + { + if ($this->read_timeout > 0) { + $fp_status = socket_get_status($fp); + if ($fp_status["timed_out"]) { + $this->timed_out = true; + return true; + } + } + return false; + } + +/*======================================================================*\ + Function: _connect + Purpose: make a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _connect(&$fp) + { + if(!empty($this->proxy_host) && !empty($this->proxy_port)) + { + $this->_isproxy = true; + + $host = $this->proxy_host; + $port = $this->proxy_port; + } + else + { + $host = $this->host; + $port = $this->port; + } + + $this->status = 0; + + if($fp = fsockopen( + $host, + $port, + $errno, + $errstr, + $this->_fp_timeout + )) + { + // socket connection succeeded + + return true; + } + else + { + // socket connection failed + $this->status = $errno; + switch($errno) + { + case -3: + $this->error="socket creation failed (-3)"; + case -4: + $this->error="dns lookup failure (-4)"; + case -5: + $this->error="connection refused or timed out (-5)"; + default: + $this->error="connection failed (".$errno.")"; + } + return false; + } + } +/*======================================================================*\ + Function: _disconnect + Purpose: disconnect a socket connection + Input: $fp file pointer +\*======================================================================*/ + + function _disconnect($fp) + { + return(fclose($fp)); + } + + +/*======================================================================*\ + Function: _prepare_post_body + Purpose: Prepare post body according to encoding type + Input: $formvars - form variables + $formfiles - form upload files + Output: post body +\*======================================================================*/ + + function _prepare_post_body($formvars, $formfiles) + { + settype($formvars, "array"); + settype($formfiles, "array"); + $postdata = ''; + + if (count($formvars) == 0 && count($formfiles) == 0) + return; + + switch ($this->_submit_type) { + case "application/x-www-form-urlencoded": + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; + } + } else + $postdata .= urlencode($key)."=".urlencode($val)."&"; + } + break; + + case "multipart/form-data": + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); + + reset($formvars); + while(list($key,$val) = each($formvars)) { + if (is_array($val) || is_object($val)) { + while (list($cur_key, $cur_val) = each($val)) { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; + $postdata .= "$cur_val\r\n"; + } + } else { + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; + $postdata .= "$val\r\n"; + } + } + + reset($formfiles); + while (list($field_name, $file_names) = each($formfiles)) { + settype($file_names, "array"); + while (list(, $file_name) = each($file_names)) { + if (!is_readable($file_name)) continue; + + $fp = fopen($file_name, "r"); + $file_content = fread($fp, filesize($file_name)); + fclose($fp); + $base_name = basename($file_name); + + $postdata .= "--".$this->_mime_boundary."\r\n"; + $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; + $postdata .= "$file_content\r\n"; + } + } + $postdata .= "--".$this->_mime_boundary."--\r\n"; + break; + } + + return $postdata; + } +} +endif; +?> diff --git a/backend/wp-includes/class-walker-category-dropdown.php b/backend/wp-includes/class-walker-category-dropdown.php new file mode 100644 index 0000000..6ff7265 --- /dev/null +++ b/backend/wp-includes/class-walker-category-dropdown.php @@ -0,0 +1,77 @@ +<?php +/** + * Taxonomy API: Walker_CategoryDropdown class + * + * @package WordPress + * @subpackage Template + * @since 4.4.0 + */ + +/** + * Core class used to create an HTML dropdown list of Categories. + * + * @since 2.1.0 + * + * @see Walker + */ +class Walker_CategoryDropdown extends Walker { + + /** + * What the class handles. + * + * @since 2.1.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = 'category'; + + /** + * Database fields to use. + * + * @since 2.1.0 + * @todo Decouple this + * @var array + * + * @see Walker::$db_fields + */ + public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); + + /** + * Starts the element output. + * + * @since 2.1.0 + * + * @see Walker::start_el() + * + * @param string $output Used to append additional content (passed by reference). + * @param object $category Category data object. + * @param int $depth Depth of category. Used for padding. + * @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist. + * See wp_dropdown_categories(). + * @param int $id Optional. ID of the current category. Default 0 (unused). + */ + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + $pad = str_repeat(' ', $depth * 3); + + /** This filter is documented in wp-includes/category-template.php */ + $cat_name = apply_filters( 'list_cats', $category->name, $category ); + + if ( isset( $args['value_field'] ) && isset( $category->{$args['value_field']} ) ) { + $value_field = $args['value_field']; + } else { + $value_field = 'term_id'; + } + + $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\""; + + // Type-juggling causes false matches, so we force everything to a string. + if ( (string) $category->{$value_field} === (string) $args['selected'] ) + $output .= ' selected="selected"'; + $output .= '>'; + $output .= $pad.$cat_name; + if ( $args['show_count'] ) + $output .= '  ('. number_format_i18n( $category->count ) .')'; + $output .= "</option>\n"; + } +} diff --git a/backend/wp-includes/class-walker-category.php b/backend/wp-includes/class-walker-category.php new file mode 100644 index 0000000..341c98c --- /dev/null +++ b/backend/wp-includes/class-walker-category.php @@ -0,0 +1,229 @@ +<?php +/** + * Taxonomy API: Walker_Category class + * + * @package WordPress + * @subpackage Template + * @since 4.4.0 + */ + +/** + * Core class used to create an HTML list of categories. + * + * @since 2.1.0 + * + * @see Walker + */ +class Walker_Category extends Walker { + + /** + * What the class handles. + * + * @since 2.1.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = 'category'; + + /** + * Database fields to use. + * + * @since 2.1.0 + * @var array + * + * @see Walker::$db_fields + * @todo Decouple this + */ + public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); + + /** + * Starts the list before the elements are added. + * + * @since 2.1.0 + * + * @see Walker::start_lvl() + * + * @param string $output Used to append additional content. Passed by reference. + * @param int $depth Optional. Depth of category. Used for tab indentation. Default 0. + * @param array $args Optional. An array of arguments. Will only append content if style argument + * value is 'list'. See wp_list_categories(). Default empty array. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + if ( 'list' != $args['style'] ) + return; + + $indent = str_repeat("\t", $depth); + $output .= "$indent<ul class='children'>\n"; + } + + /** + * Ends the list of after the elements are added. + * + * @since 2.1.0 + * + * @see Walker::end_lvl() + * + * @param string $output Used to append additional content. Passed by reference. + * @param int $depth Optional. Depth of category. Used for tab indentation. Default 0. + * @param array $args Optional. An array of arguments. Will only append content if style argument + * value is 'list'. See wp_list_categories(). Default empty array. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + if ( 'list' != $args['style'] ) + return; + + $indent = str_repeat("\t", $depth); + $output .= "$indent</ul>\n"; + } + + /** + * Starts the element output. + * + * @since 2.1.0 + * + * @see Walker::start_el() + * + * @param string $output Used to append additional content (passed by reference). + * @param object $category Category data object. + * @param int $depth Optional. Depth of category in reference to parents. Default 0. + * @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array. + * @param int $id Optional. ID of the current category. Default 0. + */ + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + /** This filter is documented in wp-includes/category-template.php */ + $cat_name = apply_filters( + 'list_cats', + esc_attr( $category->name ), + $category + ); + + // Don't generate an element if the category name is empty. + if ( ! $cat_name ) { + return; + } + + $link = '<a href="' . esc_url( get_term_link( $category ) ) . '" '; + if ( $args['use_desc_for_title'] && ! empty( $category->description ) ) { + /** + * Filters the category description for display. + * + * @since 1.2.0 + * + * @param string $description Category description. + * @param object $category Category object. + */ + $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"'; + } + + $link .= '>'; + $link .= $cat_name . '</a>'; + + if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) { + $link .= ' '; + + if ( empty( $args['feed_image'] ) ) { + $link .= '('; + } + + $link .= '<a href="' . esc_url( get_term_feed_link( $category->term_id, $category->taxonomy, $args['feed_type'] ) ) . '"'; + + if ( empty( $args['feed'] ) ) { + $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"'; + } else { + $alt = ' alt="' . $args['feed'] . '"'; + $name = $args['feed']; + $link .= empty( $args['title'] ) ? '' : $args['title']; + } + + $link .= '>'; + + if ( empty( $args['feed_image'] ) ) { + $link .= $name; + } else { + $link .= "<img src='" . $args['feed_image'] . "'$alt" . ' />'; + } + $link .= '</a>'; + + if ( empty( $args['feed_image'] ) ) { + $link .= ')'; + } + } + + if ( ! empty( $args['show_count'] ) ) { + $link .= ' (' . number_format_i18n( $category->count ) . ')'; + } + if ( 'list' == $args['style'] ) { + $output .= "\t<li"; + $css_classes = array( + 'cat-item', + 'cat-item-' . $category->term_id, + ); + + if ( ! empty( $args['current_category'] ) ) { + // 'current_category' can be an array, so we use `get_terms()`. + $_current_terms = get_terms( $category->taxonomy, array( + 'include' => $args['current_category'], + 'hide_empty' => false, + ) ); + + foreach ( $_current_terms as $_current_term ) { + if ( $category->term_id == $_current_term->term_id ) { + $css_classes[] = 'current-cat'; + } elseif ( $category->term_id == $_current_term->parent ) { + $css_classes[] = 'current-cat-parent'; + } + while ( $_current_term->parent ) { + if ( $category->term_id == $_current_term->parent ) { + $css_classes[] = 'current-cat-ancestor'; + break; + } + $_current_term = get_term( $_current_term->parent, $category->taxonomy ); + } + } + } + + /** + * Filters the list of CSS classes to include with each category in the list. + * + * @since 4.2.0 + * + * @see wp_list_categories() + * + * @param array $css_classes An array of CSS classes to be applied to each list item. + * @param object $category Category data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of wp_list_categories() arguments. + */ + $css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) ); + + $output .= ' class="' . $css_classes . '"'; + $output .= ">$link\n"; + } elseif ( isset( $args['separator'] ) ) { + $output .= "\t$link" . $args['separator'] . "\n"; + } else { + $output .= "\t$link<br />\n"; + } + } + + /** + * Ends the element output, if needed. + * + * @since 2.1.0 + * + * @see Walker::end_el() + * + * @param string $output Used to append additional content (passed by reference). + * @param object $page Not used. + * @param int $depth Optional. Depth of category. Not used. + * @param array $args Optional. An array of arguments. Only uses 'list' for whether should append + * to output. See wp_list_categories(). Default empty array. + */ + public function end_el( &$output, $page, $depth = 0, $args = array() ) { + if ( 'list' != $args['style'] ) + return; + + $output .= "</li>\n"; + } + +} diff --git a/backend/wp-includes/class-walker-comment.php b/backend/wp-includes/class-walker-comment.php new file mode 100644 index 0000000..2ff35bd --- /dev/null +++ b/backend/wp-includes/class-walker-comment.php @@ -0,0 +1,364 @@ +<?php +/** + * Comment API: Walker_Comment class + * + * @package WordPress + * @subpackage Comments + * @since 4.4.0 + */ + +/** + * Core walker class used to create an HTML list of comments. + * + * @since 2.7.0 + * + * @see Walker + */ +class Walker_Comment extends Walker { + + /** + * What the class handles. + * + * @since 2.7.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = 'comment'; + + /** + * Database fields to use. + * + * @since 2.7.0 + * @var array + * + * @see Walker::$db_fields + * @todo Decouple this + */ + public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); + + /** + * Starts the list before the elements are added. + * + * @since 2.7.0 + * + * @see Walker::start_lvl() + * @global int $comment_depth + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Optional. Depth of the current comment. Default 0. + * @param array $args Optional. Uses 'style' argument for type of HTML list. Default empty array. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $GLOBALS['comment_depth'] = $depth + 1; + + switch ( $args['style'] ) { + case 'div': + break; + case 'ol': + $output .= '<ol class="children">' . "\n"; + break; + case 'ul': + default: + $output .= '<ul class="children">' . "\n"; + break; + } + } + + /** + * Ends the list of items after the elements are added. + * + * @since 2.7.0 + * + * @see Walker::end_lvl() + * @global int $comment_depth + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Optional. Depth of the current comment. Default 0. + * @param array $args Optional. Will only append content if style argument value is 'ol' or 'ul'. + * Default empty array. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + $GLOBALS['comment_depth'] = $depth + 1; + + switch ( $args['style'] ) { + case 'div': + break; + case 'ol': + $output .= "</ol><!-- .children -->\n"; + break; + case 'ul': + default: + $output .= "</ul><!-- .children -->\n"; + break; + } + } + + /** + * Traverses elements to create list from elements. + * + * This function is designed to enhance Walker::display_element() to + * display children of higher nesting levels than selected inline on + * the highest depth level displayed. This prevents them being orphaned + * at the end of the comment list. + * + * Example: max_depth = 2, with 5 levels of nested content. + * 1 + * 1.1 + * 1.1.1 + * 1.1.1.1 + * 1.1.1.1.1 + * 1.1.2 + * 1.1.2.1 + * 2 + * 2.2 + * + * @since 2.7.0 + * + * @see Walker::display_element() + * @see wp_list_comments() + * + * @param WP_Comment $element Comment data object. + * @param array $children_elements List of elements to continue traversing. Passed by reference. + * @param int $max_depth Max depth to traverse. + * @param int $depth Depth of the current element. + * @param array $args An array of arguments. + * @param string $output Used to append additional content. Passed by reference. + */ + public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { + if ( !$element ) + return; + + $id_field = $this->db_fields['id']; + $id = $element->$id_field; + + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); + + /* + * If at the max depth, and the current element still has children, loop over those + * and display them at this level. This is to prevent them being orphaned to the end + * of the list. + */ + if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { + foreach ( $children_elements[ $id ] as $child ) + $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); + + unset( $children_elements[ $id ] ); + } + + } + + /** + * Starts the element output. + * + * @since 2.7.0 + * + * @see Walker::start_el() + * @see wp_list_comments() + * @global int $comment_depth + * @global WP_Comment $comment + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Comment $comment Comment data object. + * @param int $depth Optional. Depth of the current comment in reference to parents. Default 0. + * @param array $args Optional. An array of arguments. Default empty array. + * @param int $id Optional. ID of the current comment. Default 0 (unused). + */ + public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { + $depth++; + $GLOBALS['comment_depth'] = $depth; + $GLOBALS['comment'] = $comment; + + if ( !empty( $args['callback'] ) ) { + ob_start(); + call_user_func( $args['callback'], $comment, $args, $depth ); + $output .= ob_get_clean(); + return; + } + + if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) { + ob_start(); + $this->ping( $comment, $depth, $args ); + $output .= ob_get_clean(); + } elseif ( 'html5' === $args['format'] ) { + ob_start(); + $this->html5_comment( $comment, $depth, $args ); + $output .= ob_get_clean(); + } else { + ob_start(); + $this->comment( $comment, $depth, $args ); + $output .= ob_get_clean(); + } + } + + /** + * Ends the element output, if needed. + * + * @since 2.7.0 + * + * @see Walker::end_el() + * @see wp_list_comments() + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Comment $comment The current comment object. Default current comment. + * @param int $depth Optional. Depth of the current comment. Default 0. + * @param array $args Optional. An array of arguments. Default empty array. + */ + public function end_el( &$output, $comment, $depth = 0, $args = array() ) { + if ( !empty( $args['end-callback'] ) ) { + ob_start(); + call_user_func( $args['end-callback'], $comment, $args, $depth ); + $output .= ob_get_clean(); + return; + } + if ( 'div' == $args['style'] ) + $output .= "</div><!-- #comment-## -->\n"; + else + $output .= "</li><!-- #comment-## -->\n"; + } + + /** + * Outputs a pingback comment. + * + * @since 3.6.0 + * + * @see wp_list_comments() + * + * @param WP_Comment $comment The comment object. + * @param int $depth Depth of the current comment. + * @param array $args An array of arguments. + */ + protected function ping( $comment, $depth, $args ) { + $tag = ( 'div' == $args['style'] ) ? 'div' : 'li'; +?> + <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( '', $comment ); ?>> + <div class="comment-body"> + <?php _e( 'Pingback:' ); ?> <?php comment_author_link( $comment ); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> + </div> +<?php + } + + /** + * Outputs a single comment. + * + * @since 3.6.0 + * + * @see wp_list_comments() + * + * @param WP_Comment $comment Comment to display. + * @param int $depth Depth of the current comment. + * @param array $args An array of arguments. + */ + protected function comment( $comment, $depth, $args ) { + if ( 'div' == $args['style'] ) { + $tag = 'div'; + $add_below = 'comment'; + } else { + $tag = 'li'; + $add_below = 'div-comment'; + } +?> + <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>"> + <?php if ( 'div' != $args['style'] ) : ?> + <div id="div-comment-<?php comment_ID(); ?>" class="comment-body"> + <?php endif; ?> + <div class="comment-author vcard"> + <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> + <?php + /* translators: %s: comment author link */ + printf( __( '%s <span class="says">says:</span>' ), + sprintf( '<cite class="fn">%s</cite>', get_comment_author_link( $comment ) ) + ); + ?> + </div> + <?php if ( '0' == $comment->comment_approved ) : ?> + <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em> + <br /> + <?php endif; ?> + + <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>"> + <?php + /* translators: 1: comment date, 2: comment time */ + printf( __( '%1$s at %2$s' ), get_comment_date( '', $comment ), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '  ', '' ); + ?> + </div> + + <?php comment_text( $comment, array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> + + <?php + comment_reply_link( array_merge( $args, array( + 'add_below' => $add_below, + 'depth' => $depth, + 'max_depth' => $args['max_depth'], + 'before' => '<div class="reply">', + 'after' => '</div>' + ) ) ); + ?> + + <?php if ( 'div' != $args['style'] ) : ?> + </div> + <?php endif; ?> +<?php + } + + /** + * Outputs a comment in the HTML5 format. + * + * @since 3.6.0 + * + * @see wp_list_comments() + * + * @param WP_Comment $comment Comment to display. + * @param int $depth Depth of the current comment. + * @param array $args An array of arguments. + */ + protected function html5_comment( $comment, $depth, $args ) { + $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; +?> + <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> + <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> + <footer class="comment-meta"> + <div class="comment-author vcard"> + <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> + <?php + /* translators: %s: comment author link */ + printf( __( '%s <span class="says">says:</span>' ), + sprintf( '<b class="fn">%s</b>', get_comment_author_link( $comment ) ) + ); + ?> + </div><!-- .comment-author --> + + <div class="comment-metadata"> + <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>"> + <time datetime="<?php comment_time( 'c' ); ?>"> + <?php + /* translators: 1: comment date, 2: comment time */ + printf( __( '%1$s at %2$s' ), get_comment_date( '', $comment ), get_comment_time() ); + ?> + </time> + </a> + <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> + </div><!-- .comment-metadata --> + + <?php if ( '0' == $comment->comment_approved ) : ?> + <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p> + <?php endif; ?> + </footer><!-- .comment-meta --> + + <div class="comment-content"> + <?php comment_text(); ?> + </div><!-- .comment-content --> + + <?php + comment_reply_link( array_merge( $args, array( + 'add_below' => 'div-comment', + 'depth' => $depth, + 'max_depth' => $args['max_depth'], + 'before' => '<div class="reply">', + 'after' => '</div>' + ) ) ); + ?> + </article><!-- .comment-body --> +<?php + } +} diff --git a/backend/wp-includes/class-walker-nav-menu.php b/backend/wp-includes/class-walker-nav-menu.php new file mode 100644 index 0000000..871836f --- /dev/null +++ b/backend/wp-includes/class-walker-nav-menu.php @@ -0,0 +1,264 @@ +<?php +/** + * Nav Menu API: Walker_Nav_Menu class + * + * @package WordPress + * @subpackage Nav_Menus + * @since 4.6.0 + */ + +/** + * Core class used to implement an HTML list of nav menu items. + * + * @since 3.0.0 + * + * @see Walker + */ +class Walker_Nav_Menu extends Walker { + /** + * What the class handles. + * + * @since 3.0.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = array( 'post_type', 'taxonomy', 'custom' ); + + /** + * Database fields to use. + * + * @since 3.0.0 + * @todo Decouple this. + * @var array + * + * @see Walker::$db_fields + */ + public $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' ); + + /** + * Starts the list before the elements are added. + * + * @since 3.0.0 + * + * @see Walker::start_lvl() + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { + $t = ''; + $n = ''; + } else { + $t = "\t"; + $n = "\n"; + } + $indent = str_repeat( $t, $depth ); + + // Default class. + $classes = array( 'sub-menu' ); + + /** + * Filters the CSS class(es) applied to a menu list element. + * + * @since 4.8.0 + * + * @param array $classes The CSS classes that are applied to the menu `<ul>` element. + * @param stdClass $args An object of `wp_nav_menu()` arguments. + * @param int $depth Depth of menu item. Used for padding. + */ + $class_names = join( ' ', apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth ) ); + $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; + + $output .= "{$n}{$indent}<ul$class_names>{$n}"; + } + + /** + * Ends the list of after the elements are added. + * + * @since 3.0.0 + * + * @see Walker::end_lvl() + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { + $t = ''; + $n = ''; + } else { + $t = "\t"; + $n = "\n"; + } + $indent = str_repeat( $t, $depth ); + $output .= "$indent</ul>{$n}"; + } + + /** + * Starts the element output. + * + * @since 3.0.0 + * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added. + * + * @see Walker::start_el() + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $id Current item ID. + */ + public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { + $t = ''; + $n = ''; + } else { + $t = "\t"; + $n = "\n"; + } + $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; + + $classes = empty( $item->classes ) ? array() : (array) $item->classes; + $classes[] = 'menu-item-' . $item->ID; + + /** + * Filters the arguments for a single nav menu item. + * + * @since 4.4.0 + * + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + */ + $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); + + /** + * Filters the CSS class(es) applied to a menu item's list item element. + * + * @since 3.0.0 + * @since 4.1.0 The `$depth` parameter was added. + * + * @param array $classes The CSS classes that are applied to the menu item's `<li>` element. + * @param WP_Post $item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. + */ + $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); + $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; + + /** + * Filters the ID applied to a menu item's list item element. + * + * @since 3.0.1 + * @since 4.1.0 The `$depth` parameter was added. + * + * @param string $menu_id The ID that is applied to the menu item's `<li>` element. + * @param WP_Post $item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. + */ + $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); + $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; + + $output .= $indent . '<li' . $id . $class_names .'>'; + + $atts = array(); + $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; + $atts['target'] = ! empty( $item->target ) ? $item->target : ''; + $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; + $atts['href'] = ! empty( $item->url ) ? $item->url : ''; + + /** + * Filters the HTML attributes applied to a menu item's anchor element. + * + * @since 3.6.0 + * @since 4.1.0 The `$depth` parameter was added. + * + * @param array $atts { + * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored. + * + * @type string $title Title attribute. + * @type string $target Target attribute. + * @type string $rel The rel attribute. + * @type string $href The href attribute. + * } + * @param WP_Post $item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. + */ + $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); + + $attributes = ''; + foreach ( $atts as $attr => $value ) { + if ( ! empty( $value ) ) { + $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); + $attributes .= ' ' . $attr . '="' . $value . '"'; + } + } + + /** This filter is documented in wp-includes/post-template.php */ + $title = apply_filters( 'the_title', $item->title, $item->ID ); + + /** + * Filters a menu item's title. + * + * @since 4.4.0 + * + * @param string $title The menu item's title. + * @param WP_Post $item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. + */ + $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); + + $item_output = $args->before; + $item_output .= '<a'. $attributes .'>'; + $item_output .= $args->link_before . $title . $args->link_after; + $item_output .= '</a>'; + $item_output .= $args->after; + + /** + * Filters a menu item's starting output. + * + * The menu item's starting output only includes `$args->before`, the opening `<a>`, + * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is + * no filter for modifying the opening and closing `<li>` for a menu item. + * + * @since 3.0.0 + * + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + */ + $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); + } + + /** + * Ends the element output, if needed. + * + * @since 3.0.0 + * + * @see Walker::end_el() + * + * @param string $output Used to append additional content (passed by reference). + * @param WP_Post $item Page data object. Not used. + * @param int $depth Depth of page. Not Used. + * @param stdClass $args An object of wp_nav_menu() arguments. + */ + public function end_el( &$output, $item, $depth = 0, $args = array() ) { + if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { + $t = ''; + $n = ''; + } else { + $t = "\t"; + $n = "\n"; + } + $output .= "</li>{$n}"; + } + +} // Walker_Nav_Menu diff --git a/backend/wp-includes/class-walker-page-dropdown.php b/backend/wp-includes/class-walker-page-dropdown.php new file mode 100644 index 0000000..7d2b852 --- /dev/null +++ b/backend/wp-includes/class-walker-page-dropdown.php @@ -0,0 +1,87 @@ +<?php +/** + * Post API: Walker_PageDropdown class + * + * @package WordPress + * @subpackage Post + * @since 4.4.0 + */ + +/** + * Core class used to create an HTML drop-down list of pages. + * + * @since 2.1.0 + * + * @see Walker + */ +class Walker_PageDropdown extends Walker { + + /** + * What the class handles. + * + * @since 2.1.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = 'page'; + + /** + * Database fields to use. + * + * @since 2.1.0 + * @var array + * + * @see Walker::$db_fields + * @todo Decouple this + */ + public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + + /** + * Starts the element output. + * + * @since 2.1.0 + * + * @see Walker::start_el() + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $page Page data object. + * @param int $depth Optional. Depth of page in reference to parent pages. Used for padding. + * Default 0. + * @param array $args Optional. Uses 'selected' argument for selected page to set selected HTML + * attribute for option element. Uses 'value_field' argument to fill "value" + * attribute. See wp_dropdown_pages(). Default empty array. + * @param int $id Optional. ID of the current page. Default 0 (unused). + */ + public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) { + $pad = str_repeat(' ', $depth * 3); + + if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) { + $args['value_field'] = 'ID'; + } + + $output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $page->{$args['value_field']} ) . "\""; + if ( $page->ID == $args['selected'] ) + $output .= ' selected="selected"'; + $output .= '>'; + + $title = $page->post_title; + if ( '' === $title ) { + /* translators: %d: ID of a post */ + $title = sprintf( __( '#%d (no title)' ), $page->ID ); + } + + /** + * Filters the page title when creating an HTML drop-down list of pages. + * + * @since 3.1.0 + * + * @param string $title Page title. + * @param object $page Page data object. + */ + $title = apply_filters( 'list_pages', $title, $page ); + + $output .= $pad . esc_html( $title ); + $output .= "</option>\n"; + } +} diff --git a/backend/wp-includes/class-walker-page.php b/backend/wp-includes/class-walker-page.php new file mode 100644 index 0000000..c573841 --- /dev/null +++ b/backend/wp-includes/class-walker-page.php @@ -0,0 +1,231 @@ +<?php +/** + * Post API: Walker_Page class + * + * @package WordPress + * @subpackage Template + * @since 4.4.0 + */ + +/** + * Core walker class used to create an HTML list of pages. + * + * @since 2.1.0 + * + * @see Walker + */ +class Walker_Page extends Walker { + + /** + * What the class handles. + * + * @since 2.1.0 + * @var string + * + * @see Walker::$tree_type + */ + public $tree_type = 'page'; + + /** + * Database fields to use. + * + * @since 2.1.0 + * @var array + * + * @see Walker::$db_fields + * @todo Decouple this. + */ + public $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); + + /** + * Outputs the beginning of the current level in the tree before elements are output. + * + * @since 2.1.0 + * + * @see Walker::start_lvl() + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Optional. Depth of page. Used for padding. Default 0. + * @param array $args Optional. Arguments for outputting the next level. + * Default empty array. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } + $indent = str_repeat( $t, $depth ); + $output .= "{$n}{$indent}<ul class='children'>{$n}"; + } + + /** + * Outputs the end of the current level in the tree after elements are output. + * + * @since 2.1.0 + * + * @see Walker::end_lvl() + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Optional. Depth of page. Used for padding. Default 0. + * @param array $args Optional. Arguments for outputting the end of the current level. + * Default empty array. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) { + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } + $indent = str_repeat( $t, $depth ); + $output .= "{$indent}</ul>{$n}"; + } + + /** + * Outputs the beginning of the current element in the tree. + * + * @see Walker::start_el() + * @since 2.1.0 + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $page Page data object. + * @param int $depth Optional. Depth of page. Used for padding. Default 0. + * @param array $args Optional. Array of arguments. Default empty array. + * @param int $current_page Optional. Page ID. Default 0. + */ + public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } + if ( $depth ) { + $indent = str_repeat( $t, $depth ); + } else { + $indent = ''; + } + + $css_class = array( 'page_item', 'page-item-' . $page->ID ); + + if ( isset( $args['pages_with_children'][ $page->ID ] ) ) { + $css_class[] = 'page_item_has_children'; + } + + if ( ! empty( $current_page ) ) { + $_current_page = get_post( $current_page ); + if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) { + $css_class[] = 'current_page_ancestor'; + } + if ( $page->ID == $current_page ) { + $css_class[] = 'current_page_item'; + } elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { + $css_class[] = 'current_page_parent'; + } + } elseif ( $page->ID == get_option('page_for_posts') ) { + $css_class[] = 'current_page_parent'; + } + + /** + * Filters the list of CSS classes to include with each page item in the list. + * + * @since 2.8.0 + * + * @see wp_list_pages() + * + * @param array $css_class An array of CSS classes to be applied + * to each list item. + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page ID of the current page. + */ + $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); + + if ( '' === $page->post_title ) { + /* translators: %d: ID of a post */ + $page->post_title = sprintf( __( '#%d (no title)' ), $page->ID ); + } + + $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before']; + $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; + + $atts = array(); + $atts['href'] = get_permalink( $page->ID ); + + /** + * Filters the HTML attributes applied to a page menu item's anchor element. + * + * @since 4.8.0 + * + * @param array $atts { + * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored. + * + * @type string $href The href attribute. + * } + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page ID of the current page. + */ + $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page ); + + $attributes = ''; + foreach ( $atts as $attr => $value ) { + if ( ! empty( $value ) ) { + $value = esc_attr( $value ); + $attributes .= ' ' . $attr . '="' . $value . '"'; + } + } + + $output .= $indent . sprintf( + '<li class="%s"><a%s>%s%s%s</a>', + $css_classes, + $attributes, + $args['link_before'], + /** This filter is documented in wp-includes/post-template.php */ + apply_filters( 'the_title', $page->post_title, $page->ID ), + $args['link_after'] + ); + + if ( ! empty( $args['show_date'] ) ) { + if ( 'modified' == $args['show_date'] ) { + $time = $page->post_modified; + } else { + $time = $page->post_date; + } + + $date_format = empty( $args['date_format'] ) ? '' : $args['date_format']; + $output .= " " . mysql2date( $date_format, $time ); + } + } + + /** + * Outputs the end of the current element in the tree. + * + * @since 2.1.0 + * + * @see Walker::end_el() + * + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $page Page data object. Not used. + * @param int $depth Optional. Depth of page. Default 0 (unused). + * @param array $args Optional. Array of arguments. Default empty array. + */ + public function end_el( &$output, $page, $depth = 0, $args = array() ) { + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { + $t = "\t"; + $n = "\n"; + } else { + $t = ''; + $n = ''; + } + $output .= "</li>{$n}"; + } + +} diff --git a/backend/wp-includes/class-wp-admin-bar.php b/backend/wp-includes/class-wp-admin-bar.php new file mode 100644 index 0000000..734a048 --- /dev/null +++ b/backend/wp-includes/class-wp-admin-bar.php @@ -0,0 +1,603 @@ +<?php +/** + * Toolbar API: WP_Admin_Bar class + * + * @package WordPress + * @subpackage Toolbar + * @since 3.1.0 + */ + +/** + * Core class used to implement the Toolbar API. + * + * @since 3.1.0 + */ +class WP_Admin_Bar { + private $nodes = array(); + private $bound = false; + public $user; + + /** + * @param string $name + * @return string|array|void + */ + public function __get( $name ) { + switch ( $name ) { + case 'proto' : + return is_ssl() ? 'https://' : 'http://'; + + case 'menu' : + _deprecated_argument( 'WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' ); + return array(); // Sorry, folks. + } + } + + /** + */ + public function initialize() { + $this->user = new stdClass; + + if ( is_user_logged_in() ) { + /* Populate settings we need for the menu based on the current user. */ + $this->user->blogs = get_blogs_of_user( get_current_user_id() ); + if ( is_multisite() ) { + $this->user->active_blog = get_active_blog_for_user( get_current_user_id() ); + $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); + $this->user->account_domain = $this->user->domain; + } else { + $this->user->active_blog = $this->user->blogs[get_current_blog_id()]; + $this->user->domain = trailingslashit( home_url() ); + $this->user->account_domain = $this->user->domain; + } + } + + add_action( 'wp_head', 'wp_admin_bar_header' ); + + add_action( 'admin_head', 'wp_admin_bar_header' ); + + if ( current_theme_supports( 'admin-bar' ) ) { + /** + * To remove the default padding styles from WordPress for the Toolbar, use the following code: + * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) ); + */ + $admin_bar_args = get_theme_support( 'admin-bar' ); + $header_callback = $admin_bar_args[0]['callback']; + } + + if ( empty($header_callback) ) + $header_callback = '_admin_bar_bump_cb'; + + add_action('wp_head', $header_callback); + + wp_enqueue_script( 'admin-bar' ); + wp_enqueue_style( 'admin-bar' ); + + /** + * Fires after WP_Admin_Bar is initialized. + * + * @since 3.1.0 + */ + do_action( 'admin_bar_init' ); + } + + /** + * @param array $node + */ + public function add_menu( $node ) { + $this->add_node( $node ); + } + + /** + * @param string $id + */ + public function remove_menu( $id ) { + $this->remove_node( $id ); + } + + /** + * Adds a node to the menu. + * + * @since 3.1.0 + * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data. + * + * @param array $args { + * Arguments for adding a node. + * + * @type string $id ID of the item. + * @type string $title Title of the node. + * @type string $parent Optional. ID of the parent node. + * @type string $href Optional. Link for the item. + * @type bool $group Optional. Whether or not the node is a group. Default false. + * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', + * 'onclick', 'target', 'title', 'tabindex'. Default empty. + * } + */ + public function add_node( $args ) { + // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ) + if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) ) + $args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) ); + + if ( is_object( $args ) ) + $args = get_object_vars( $args ); + + // Ensure we have a valid title. + if ( empty( $args['id'] ) ) { + if ( empty( $args['title'] ) ) + return; + + _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' ); + // Deprecated: Generate an ID from the title. + $args['id'] = esc_attr( sanitize_title( trim( $args['title'] ) ) ); + } + + $defaults = array( + 'id' => false, + 'title' => false, + 'parent' => false, + 'href' => false, + 'group' => false, + 'meta' => array(), + ); + + // If the node already exists, keep any data that isn't provided. + if ( $maybe_defaults = $this->get_node( $args['id'] ) ) + $defaults = get_object_vars( $maybe_defaults ); + + // Do the same for 'meta' items. + if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) + $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] ); + + $args = wp_parse_args( $args, $defaults ); + + $back_compat_parents = array( + 'my-account-with-avatar' => array( 'my-account', '3.3' ), + 'my-blogs' => array( 'my-sites', '3.3' ), + ); + + if ( isset( $back_compat_parents[ $args['parent'] ] ) ) { + list( $new_parent, $version ) = $back_compat_parents[ $args['parent'] ]; + _deprecated_argument( __METHOD__, $version, sprintf( 'Use <code>%s</code> as the parent for the <code>%s</code> admin bar node instead of <code>%s</code>.', $new_parent, $args['id'], $args['parent'] ) ); + $args['parent'] = $new_parent; + } + + $this->_set_node( $args ); + } + + /** + * @param array $args + */ + final protected function _set_node( $args ) { + $this->nodes[ $args['id'] ] = (object) $args; + } + + /** + * Gets a node. + * + * @param string $id + * @return object Node. + */ + final public function get_node( $id ) { + if ( $node = $this->_get_node( $id ) ) + return clone $node; + } + + /** + * @param string $id + * @return object|void + */ + final protected function _get_node( $id ) { + if ( $this->bound ) + return; + + if ( empty( $id ) ) + $id = 'root'; + + if ( isset( $this->nodes[ $id ] ) ) + return $this->nodes[ $id ]; + } + + /** + * @return array|void + */ + final public function get_nodes() { + if ( ! $nodes = $this->_get_nodes() ) + return; + + foreach ( $nodes as &$node ) { + $node = clone $node; + } + return $nodes; + } + + /** + * @return array|void + */ + final protected function _get_nodes() { + if ( $this->bound ) + return; + + return $this->nodes; + } + + /** + * Add a group to a menu node. + * + * @since 3.3.0 + * + * @param array $args { + * Array of arguments for adding a group. + * + * @type string $id ID of the item. + * @type string $parent Optional. ID of the parent node. Default 'root'. + * @type array $meta Meta data for the group including the following keys: + * 'class', 'onclick', 'target', and 'title'. + * } + */ + final public function add_group( $args ) { + $args['group'] = true; + + $this->add_node( $args ); + } + + /** + * Remove a node. + * + * @param string $id The ID of the item. + */ + public function remove_node( $id ) { + $this->_unset_node( $id ); + } + + /** + * @param string $id + */ + final protected function _unset_node( $id ) { + unset( $this->nodes[ $id ] ); + } + + /** + */ + public function render() { + $root = $this->_bind(); + if ( $root ) + $this->_render( $root ); + } + + /** + * @return object|void + */ + final protected function _bind() { + if ( $this->bound ) + return; + + // Add the root node. + // Clear it first, just in case. Don't mess with The Root. + $this->remove_node( 'root' ); + $this->add_node( array( + 'id' => 'root', + 'group' => false, + ) ); + + // Normalize nodes: define internal 'children' and 'type' properties. + foreach ( $this->_get_nodes() as $node ) { + $node->children = array(); + $node->type = ( $node->group ) ? 'group' : 'item'; + unset( $node->group ); + + // The Root wants your orphans. No lonely items allowed. + if ( ! $node->parent ) + $node->parent = 'root'; + } + + foreach ( $this->_get_nodes() as $node ) { + if ( 'root' == $node->id ) + continue; + + // Fetch the parent node. If it isn't registered, ignore the node. + if ( ! $parent = $this->_get_node( $node->parent ) ) { + continue; + } + + // Generate the group class (we distinguish between top level and other level groups). + $group_class = ( $node->parent == 'root' ) ? 'ab-top-menu' : 'ab-submenu'; + + if ( $node->type == 'group' ) { + if ( empty( $node->meta['class'] ) ) + $node->meta['class'] = $group_class; + else + $node->meta['class'] .= ' ' . $group_class; + } + + // Items in items aren't allowed. Wrap nested items in 'default' groups. + if ( $parent->type == 'item' && $node->type == 'item' ) { + $default_id = $parent->id . '-default'; + $default = $this->_get_node( $default_id ); + + // The default group is added here to allow groups that are + // added before standard menu items to render first. + if ( ! $default ) { + // Use _set_node because add_node can be overloaded. + // Make sure to specify default settings for all properties. + $this->_set_node( array( + 'id' => $default_id, + 'parent' => $parent->id, + 'type' => 'group', + 'children' => array(), + 'meta' => array( + 'class' => $group_class, + ), + 'title' => false, + 'href' => false, + ) ); + $default = $this->_get_node( $default_id ); + $parent->children[] = $default; + } + $parent = $default; + + // Groups in groups aren't allowed. Add a special 'container' node. + // The container will invisibly wrap both groups. + } elseif ( $parent->type == 'group' && $node->type == 'group' ) { + $container_id = $parent->id . '-container'; + $container = $this->_get_node( $container_id ); + + // We need to create a container for this group, life is sad. + if ( ! $container ) { + // Use _set_node because add_node can be overloaded. + // Make sure to specify default settings for all properties. + $this->_set_node( array( + 'id' => $container_id, + 'type' => 'container', + 'children' => array( $parent ), + 'parent' => false, + 'title' => false, + 'href' => false, + 'meta' => array(), + ) ); + + $container = $this->_get_node( $container_id ); + + // Link the container node if a grandparent node exists. + $grandparent = $this->_get_node( $parent->parent ); + + if ( $grandparent ) { + $container->parent = $grandparent->id; + + $index = array_search( $parent, $grandparent->children, true ); + if ( $index === false ) + $grandparent->children[] = $container; + else + array_splice( $grandparent->children, $index, 1, array( $container ) ); + } + + $parent->parent = $container->id; + } + + $parent = $container; + } + + // Update the parent ID (it might have changed). + $node->parent = $parent->id; + + // Add the node to the tree. + $parent->children[] = $node; + } + + $root = $this->_get_node( 'root' ); + $this->bound = true; + return $root; + } + + /** + * + * @global bool $is_IE + * @param object $root + */ + final protected function _render( $root ) { + global $is_IE; + + // Add browser classes. + // We have to do this here since admin bar shows on the front end. + $class = 'nojq nojs'; + if ( $is_IE ) { + if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) + $class .= ' ie7'; + elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) + $class .= ' ie8'; + elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) + $class .= ' ie9'; + } elseif ( wp_is_mobile() ) { + $class .= ' mobile'; + } + + ?> + <div id="wpadminbar" class="<?php echo $class; ?>"> + <?php if ( ! is_admin() ) { ?> + <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a> + <?php } ?> + <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>" tabindex="0"> + <?php foreach ( $root->children as $group ) { + $this->_render_group( $group ); + } ?> + </div> + <?php if ( is_user_logged_in() ) : ?> + <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e('Log Out'); ?></a> + <?php endif; ?> + </div> + + <?php + } + + /** + * @param object $node + */ + final protected function _render_container( $node ) { + if ( $node->type != 'container' || empty( $node->children ) ) + return; + + ?><div id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="ab-group-container"><?php + foreach ( $node->children as $group ) { + $this->_render_group( $group ); + } + ?></div><?php + } + + /** + * @param object $node + */ + final protected function _render_group( $node ) { + if ( $node->type == 'container' ) { + $this->_render_container( $node ); + return; + } + if ( $node->type != 'group' || empty( $node->children ) ) + return; + + if ( ! empty( $node->meta['class'] ) ) + $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"'; + else + $class = ''; + + ?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $class; ?>><?php + foreach ( $node->children as $item ) { + $this->_render_item( $item ); + } + ?></ul><?php + } + + /** + * @param object $node + */ + final protected function _render_item( $node ) { + if ( $node->type != 'item' ) + return; + + $is_parent = ! empty( $node->children ); + $has_link = ! empty( $node->href ); + + // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. + $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; + $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; + + $menuclass = ''; + + if ( $is_parent ) { + $menuclass = 'menupop '; + $aria_attributes .= ' aria-haspopup="true"'; + } + + if ( ! empty( $node->meta['class'] ) ) + $menuclass .= $node->meta['class']; + + if ( $menuclass ) + $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; + + ?> + + <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php + if ( $has_link ): + ?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php + if ( ! empty( $node->meta['onclick'] ) ) : + ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['target'] ) ) : + ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['title'] ) ) : + ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['rel'] ) ) : + ?> rel="<?php echo esc_attr( $node->meta['rel'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['lang'] ) ) : + ?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['dir'] ) ) : + ?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php + endif; + ?>><?php + else: + ?><div class="ab-item ab-empty-item"<?php echo $aria_attributes; + if ( ! empty( $node->meta['title'] ) ) : + ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['lang'] ) ) : + ?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php + endif; + if ( ! empty( $node->meta['dir'] ) ) : + ?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php + endif; + ?>><?php + endif; + + echo $node->title; + + if ( $has_link ) : + ?></a><?php + else: + ?></div><?php + endif; + + if ( $is_parent ) : + ?><div class="ab-sub-wrapper"><?php + foreach ( $node->children as $group ) { + $this->_render_group( $group ); + } + ?></div><?php + endif; + + if ( ! empty( $node->meta['html'] ) ) + echo $node->meta['html']; + + ?> + </li><?php + } + + /** + * Renders toolbar items recursively. + * + * @since 3.1.0 + * @deprecated 3.3.0 Use WP_Admin_Bar::_render_item() or WP_Admin_bar::render() instead. + * @see WP_Admin_Bar::_render_item() + * @see WP_Admin_Bar::render() + * + * @param string $id Unused. + * @param object $node + */ + public function recursive_render( $id, $node ) { + _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' ); + $this->_render_item( $node ); + } + + /** + */ + public function add_menus() { + // User related, aligned right. + add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); + + // Site related. + add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 ); + + // Content related. + if ( ! is_network_admin() && ! is_user_admin() ) { + add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 ); + add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 ); + } + add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); + + add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 ); + + /** + * Fires after menus are added to the menu bar. + * + * @since 3.1.0 + */ + do_action( 'add_admin_bar_menus' ); + } +} diff --git a/backend/wp-includes/class-wp-ajax-response.php b/backend/wp-includes/class-wp-ajax-response.php new file mode 100644 index 0000000..7123d10 --- /dev/null +++ b/backend/wp-includes/class-wp-ajax-response.php @@ -0,0 +1,156 @@ +<?php +/** + * Send XML response back to Ajax request. + * + * @package WordPress + * @since 2.1.0 + */ +class WP_Ajax_Response { + /** + * Store XML responses to send. + * + * @since 2.1.0 + * @var array + */ + public $responses = array(); + + /** + * Constructor - Passes args to WP_Ajax_Response::add(). + * + * @since 2.1.0 + * @see WP_Ajax_Response::add() + * + * @param string|array $args Optional. Will be passed to add() method. + */ + public function __construct( $args = '' ) { + if ( !empty($args) ) + $this->add($args); + } + + /** + * Appends data to an XML response based on given arguments. + * + * With `$args` defaults, extra data output would be: + * + * <response action='{$action}_$id'> + * <$what id='$id' position='$position'> + * <response_data><![CDATA[$data]]></response_data> + * </$what> + * </response> + * + * @since 2.1.0 + * + * @param string|array $args { + * Optional. An array or string of XML response arguments. + * + * @type string $what XML-RPC response type. Used as a child element of `<response>`. + * Default 'object' (`<object>`). + * @type string|false $action Value to use for the `action` attribute in `<response>`. Will be + * appended with `_$id` on output. If false, `$action` will default to + * the value of `$_POST['action']`. Default false. + * @type int|WP_Error $id The response ID, used as the response type `id` attribute. Also + * accepts a `WP_Error` object if the ID does not exist. Default 0. + * @type int|false $old_id The previous response ID. Used as the value for the response type + * `old_id` attribute. False hides the attribute. Default false. + * @type string $position Value of the response type `position` attribute. Accepts 1 (bottom), + * -1 (top), html ID (after), or -html ID (before). Default 1 (bottom). + * @type string|WP_Error $data The response content/message. Also accepts a WP_Error object if the + * ID does not exist. Default empty. + * @type array $supplemental An array of extra strings that will be output within a `<supplemental>` + * element as CDATA. Default empty array. + * } + * @return string XML response. + */ + public function add( $args = '' ) { + $defaults = array( + 'what' => 'object', 'action' => false, + 'id' => '0', 'old_id' => false, + 'position' => 1, + 'data' => '', 'supplemental' => array() + ); + + $r = wp_parse_args( $args, $defaults ); + + $position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] ); + $id = $r['id']; + $what = $r['what']; + $action = $r['action']; + $old_id = $r['old_id']; + $data = $r['data']; + + if ( is_wp_error( $id ) ) { + $data = $id; + $id = 0; + } + + $response = ''; + if ( is_wp_error( $data ) ) { + foreach ( (array) $data->get_error_codes() as $code ) { + $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . "]]></wp_error>"; + if ( ! $error_data = $data->get_error_data( $code ) ) { + continue; + } + $class = ''; + if ( is_object( $error_data ) ) { + $class = ' class="' . get_class( $error_data ) . '"'; + $error_data = get_object_vars( $error_data ); + } + + $response .= "<wp_error_data code='$code'$class>"; + + if ( is_scalar( $error_data ) ) { + $response .= "<![CDATA[$error_data]]>"; + } elseif ( is_array( $error_data ) ) { + foreach ( $error_data as $k => $v ) { + $response .= "<$k><![CDATA[$v]]></$k>"; + } + } + + $response .= "</wp_error_data>"; + } + } else { + $response = "<response_data><![CDATA[$data]]></response_data>"; + } + + $s = ''; + if ( is_array( $r['supplemental'] ) ) { + foreach ( $r['supplemental'] as $k => $v ) { + $s .= "<$k><![CDATA[$v]]></$k>"; + } + $s = "<supplemental>$s</supplemental>"; + } + + if ( false === $action ) { + $action = $_POST['action']; + } + $x = ''; + $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action + $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; + $x .= $response; + $x .= $s; + $x .= "</$what>"; + $x .= "</response>"; + + $this->responses[] = $x; + return $x; + } + + /** + * Display XML formatted responses. + * + * Sets the content type header to text/xml. + * + * @since 2.1.0 + */ + public function send() { + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) ); + echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>"; + foreach ( (array) $this->responses as $response ) + echo $response; + echo '</wp_ajax>'; + if ( wp_doing_ajax() ) + wp_die(); + else + die(); + } +} diff --git a/backend/wp-includes/class-wp-comment-query.php b/backend/wp-includes/class-wp-comment-query.php new file mode 100644 index 0000000..d781b88 --- /dev/null +++ b/backend/wp-includes/class-wp-comment-query.php @@ -0,0 +1,1146 @@ +<?php +/** + * Comment API: WP_Comment_Query class + * + * @package WordPress + * @subpackage Comments + * @since 4.4.0 + */ + +/** + * Core class used for querying comments. + * + * @since 3.1.0 + * + * @see WP_Comment_Query::__construct() for accepted arguments. + */ +class WP_Comment_Query { + + /** + * SQL for database query. + * + * @since 4.0.1 + * @var string + */ + public $request; + + /** + * Metadata query container + * + * @since 3.5.0 + * @var object WP_Meta_Query + */ + public $meta_query = false; + + /** + * Metadata query clauses. + * + * @since 4.4.0 + * @var array + */ + protected $meta_query_clauses; + + /** + * SQL query clauses. + * + * @since 4.4.0 + * @var array + */ + protected $sql_clauses = array( + 'select' => '', + 'from' => '', + 'where' => array(), + 'groupby' => '', + 'orderby' => '', + 'limits' => '', + ); + + /** + * SQL WHERE clause. + * + * Stored after the {@see 'comments_clauses'} filter is run on the compiled WHERE sub-clauses. + * + * @since 4.4.2 + * @var string + */ + protected $filtered_where_clause; + + /** + * Date query container + * + * @since 3.7.0 + * @var object WP_Date_Query + */ + public $date_query = false; + + /** + * Query vars set by the user. + * + * @since 3.1.0 + * @var array + */ + public $query_vars; + + /** + * Default values for query vars. + * + * @since 4.2.0 + * @var array + */ + public $query_var_defaults; + + /** + * List of comments located by the query. + * + * @since 4.0.0 + * @var array + */ + public $comments; + + /** + * The amount of found comments for the current query. + * + * @since 4.4.0 + * @var int + */ + public $found_comments = 0; + + /** + * The number of pages. + * + * @since 4.4.0 + * @var int + */ + public $max_num_pages = 0; + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|false Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( 'get_search_sql' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Constructor. + * + * Sets up the comment query, based on the query vars passed. + * + * @since 4.2.0 + * @since 4.4.0 `$parent__in` and `$parent__not_in` were added. + * @since 4.4.0 Order by `comment__in` was added. `$update_comment_meta_cache`, `$no_found_rows`, + * `$hierarchical`, and `$update_comment_post_cache` were added. + * @since 4.5.0 Introduced the `$author_url` argument. + * @since 4.6.0 Introduced the `$cache_domain` argument. + * @since 4.9.0 Introduced the `$paged` argument. + * + * @param string|array $query { + * Optional. Array or query string of comment query parameters. Default empty. + * + * @type string $author_email Comment author email address. Default empty. + * @type string $author_url Comment author URL. Default empty. + * @type array $author__in Array of author IDs to include comments for. Default empty. + * @type array $author__not_in Array of author IDs to exclude comments for. Default empty. + * @type array $comment__in Array of comment IDs to include. Default empty. + * @type array $comment__not_in Array of comment IDs to exclude. Default empty. + * @type bool $count Whether to return a comment count (true) or array of + * comment objects (false). Default false. + * @type array $date_query Date query clauses to limit comments by. See WP_Date_Query. + * Default null. + * @type string $fields Comment fields to return. Accepts 'ids' for comment IDs + * only or empty for all fields. Default empty. + * @type int $ID Currently unused. + * @type array $include_unapproved Array of IDs or email addresses of users whose unapproved + * comments will be returned by the query regardless of + * `$status`. Default empty. + * @type int $karma Karma score to retrieve matching comments for. + * Default empty. + * @type string $meta_key Include comments with a matching comment meta key. + * Default empty. + * @type string $meta_value Include comments with a matching comment meta value. + * Requires `$meta_key` to be set. Default empty. + * @type array $meta_query Meta query clauses to limit retrieved comments by. + * See WP_Meta_Query. Default empty. + * @type int $number Maximum number of comments to retrieve. + * Default empty (no limit). + * @type int $paged When used with $number, defines the page of results to return. + * When used with $offset, $offset takes precedence. Default 1. + * @type int $offset Number of comments to offset the query. Used to build + * LIMIT clause. Default 0. + * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. + * Default: true. + * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' + * or 'meta_value_num', `$meta_key` must also be defined. + * To sort by a specific `$meta_query` clause, use that + * clause's array key. Accepts 'comment_agent', + * 'comment_approved', 'comment_author', + * 'comment_author_email', 'comment_author_IP', + * 'comment_author_url', 'comment_content', 'comment_date', + * 'comment_date_gmt', 'comment_ID', 'comment_karma', + * 'comment_parent', 'comment_post_ID', 'comment_type', + * 'user_id', 'comment__in', 'meta_value', 'meta_value_num', + * the value of $meta_key, and the array keys of + * `$meta_query`. Also accepts false, an empty array, or + * 'none' to disable `ORDER BY` clause. + * Default: 'comment_date_gmt'. + * @type string $order How to order retrieved comments. Accepts 'ASC', 'DESC'. + * Default: 'DESC'. + * @type int $parent Parent ID of comment to retrieve children of. + * Default empty. + * @type array $parent__in Array of parent IDs of comments to retrieve children for. + * Default empty. + * @type array $parent__not_in Array of parent IDs of comments *not* to retrieve + * children for. Default empty. + * @type array $post_author__in Array of author IDs to retrieve comments for. + * Default empty. + * @type array $post_author__not_in Array of author IDs *not* to retrieve comments for. + * Default empty. + * @type int $post_ID Currently unused. + * @type int $post_id Limit results to those affiliated with a given post ID. + * Default 0. + * @type array $post__in Array of post IDs to include affiliated comments for. + * Default empty. + * @type array $post__not_in Array of post IDs to exclude affiliated comments for. + * Default empty. + * @type int $post_author Post author ID to limit results by. Default empty. + * @type string|array $post_status Post status or array of post statuses to retrieve + * affiliated comments for. Pass 'any' to match any value. + * Default empty. + * @type string $post_type Post type or array of post types to retrieve affiliated + * comments for. Pass 'any' to match any value. Default empty. + * @type string $post_name Post name to retrieve affiliated comments for. + * Default empty. + * @type int $post_parent Post parent ID to retrieve affiliated comments for. + * Default empty. + * @type string $search Search term(s) to retrieve matching comments for. + * Default empty. + * @type string $status Comment status to limit results by. Accepts 'hold' + * (`comment_status=0`), 'approve' (`comment_status=1`), + * 'all', or a custom comment status. Default 'all'. + * @type string|array $type Include comments of a given type, or array of types. + * Accepts 'comment', 'pings' (includes 'pingback' and + * 'trackback'), or anycustom type string. Default empty. + * @type array $type__in Include comments from a given array of comment types. + * Default empty. + * @type array $type__not_in Exclude comments from a given array of comment types. + * Default empty. + * @type int $user_id Include comments for a specific user ID. Default empty. + * @type bool|string $hierarchical Whether to include comment descendants in the results. + * 'threaded' returns a tree, with each comment's children + * stored in a `children` property on the `WP_Comment` + * object. 'flat' returns a flat array of found comments plus + * their children. Pass `false` to leave out descendants. + * The parameter is ignored (forced to `false`) when + * `$fields` is 'ids' or 'counts'. Accepts 'threaded', + * 'flat', or false. Default: false. + * @type string $cache_domain Unique cache key to be produced when this query is stored in + * an object cache. Default is 'core'. + * @type bool $update_comment_meta_cache Whether to prime the metadata cache for found comments. + * Default true. + * @type bool $update_comment_post_cache Whether to prime the cache for comment posts. + * Default false. + * } + */ + public function __construct( $query = '' ) { + $this->query_var_defaults = array( + 'author_email' => '', + 'author_url' => '', + 'author__in' => '', + 'author__not_in' => '', + 'include_unapproved' => '', + 'fields' => '', + 'ID' => '', + 'comment__in' => '', + 'comment__not_in' => '', + 'karma' => '', + 'number' => '', + 'offset' => '', + 'no_found_rows' => true, + 'orderby' => '', + 'order' => 'DESC', + 'paged' => 1, + 'parent' => '', + 'parent__in' => '', + 'parent__not_in' => '', + 'post_author__in' => '', + 'post_author__not_in' => '', + 'post_ID' => '', + 'post_id' => 0, + 'post__in' => '', + 'post__not_in' => '', + 'post_author' => '', + 'post_name' => '', + 'post_parent' => '', + 'post_status' => '', + 'post_type' => '', + 'status' => 'all', + 'type' => '', + 'type__in' => '', + 'type__not_in' => '', + 'user_id' => '', + 'search' => '', + 'count' => false, + 'meta_key' => '', + 'meta_value' => '', + 'meta_query' => '', + 'date_query' => null, // See WP_Date_Query + 'hierarchical' => false, + 'cache_domain' => 'core', + 'update_comment_meta_cache' => true, + 'update_comment_post_cache' => false, + ); + + if ( ! empty( $query ) ) { + $this->query( $query ); + } + } + + /** + * Parse arguments passed to the comment query with default query parameters. + * + * @since 4.2.0 Extracted from WP_Comment_Query::query(). + * + * + * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct() + */ + public function parse_query( $query = '' ) { + if ( empty( $query ) ) { + $query = $this->query_vars; + } + + $this->query_vars = wp_parse_args( $query, $this->query_var_defaults ); + + /** + * Fires after the comment query vars have been parsed. + * + * @since 4.2.0 + * + * @param WP_Comment_Query $this The WP_Comment_Query instance (passed by reference). + */ + do_action_ref_array( 'parse_comment_query', array( &$this ) ); + } + + /** + * Sets up the WordPress query for retrieving comments. + * + * @since 3.1.0 + * @since 4.1.0 Introduced 'comment__in', 'comment__not_in', 'post_author__in', + * 'post_author__not_in', 'author__in', 'author__not_in', 'post__in', + * 'post__not_in', 'include_unapproved', 'type__in', and 'type__not_in' + * arguments to $query_vars. + * @since 4.2.0 Moved parsing to WP_Comment_Query::parse_query(). + * + * @param string|array $query Array or URL query string of parameters. + * @return array|int List of comments, or number of comments when 'count' is passed as a query var. + */ + public function query( $query ) { + $this->query_vars = wp_parse_args( $query ); + return $this->get_comments(); + } + + /** + * Get a list of comments matching the query vars. + * + * @since 4.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return int|array List of comments or number of found comments if `$count` argument is true. + */ + public function get_comments() { + global $wpdb; + + $this->parse_query(); + + // Parse meta query + $this->meta_query = new WP_Meta_Query(); + $this->meta_query->parse_query_vars( $this->query_vars ); + + /** + * Fires before comments are retrieved. + * + * @since 3.1.0 + * + * @param WP_Comment_Query $this Current instance of WP_Comment_Query (passed by reference). + */ + do_action_ref_array( 'pre_get_comments', array( &$this ) ); + + // Reparse query vars, in case they were modified in a 'pre_get_comments' callback. + $this->meta_query->parse_query_vars( $this->query_vars ); + if ( ! empty( $this->meta_query->queries ) ) { + $this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this ); + } + + /* + * Only use the args defined in the query_var_defaults to compute the key, + * but ignore 'fields', which does not affect query results. + */ + $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); + unset( $_args['fields'] ); + + $key = md5( serialize( $_args ) ); + $last_changed = wp_cache_get_last_changed( 'comment' ); + + $cache_key = "get_comments:$key:$last_changed"; + $cache_value = wp_cache_get( $cache_key, 'comment' ); + if ( false === $cache_value ) { + $comment_ids = $this->get_comment_ids(); + if ( $comment_ids ) { + $this->set_found_comments(); + } + + $cache_value = array( + 'comment_ids' => $comment_ids, + 'found_comments' => $this->found_comments, + ); + wp_cache_add( $cache_key, $cache_value, 'comment' ); + } else { + $comment_ids = $cache_value['comment_ids']; + $this->found_comments = $cache_value['found_comments']; + } + + if ( $this->found_comments && $this->query_vars['number'] ) { + $this->max_num_pages = ceil( $this->found_comments / $this->query_vars['number'] ); + } + + // If querying for a count only, there's nothing more to do. + if ( $this->query_vars['count'] ) { + // $comment_ids is actually a count in this case. + return intval( $comment_ids ); + } + + $comment_ids = array_map( 'intval', $comment_ids ); + + if ( 'ids' == $this->query_vars['fields'] ) { + $this->comments = $comment_ids; + return $this->comments; + } + + _prime_comment_caches( $comment_ids, $this->query_vars['update_comment_meta_cache'] ); + + // Fetch full comment objects from the primed cache. + $_comments = array(); + foreach ( $comment_ids as $comment_id ) { + if ( $_comment = get_comment( $comment_id ) ) { + $_comments[] = $_comment; + } + } + + // Prime comment post caches. + if ( $this->query_vars['update_comment_post_cache'] ) { + $comment_post_ids = array(); + foreach ( $_comments as $_comment ) { + $comment_post_ids[] = $_comment->comment_post_ID; + } + + _prime_post_caches( $comment_post_ids, false, false ); + } + + /** + * Filters the comment query results. + * + * @since 3.1.0 + * + * @param array $_comments An array of comments. + * @param WP_Comment_Query $this Current instance of WP_Comment_Query (passed by reference). + */ + $_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) ); + + // Convert to WP_Comment instances + $comments = array_map( 'get_comment', $_comments ); + + if ( $this->query_vars['hierarchical'] ) { + $comments = $this->fill_descendants( $comments ); + } + + $this->comments = $comments; + return $this->comments; + } + + /** + * Used internally to get a list of comment IDs matching the query vars. + * + * @since 4.4.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + protected function get_comment_ids() { + global $wpdb; + + // Assemble clauses related to 'comment_approved'. + $approved_clauses = array(); + + // 'status' accepts an array or a comma-separated string. + $status_clauses = array(); + $statuses = $this->query_vars['status']; + if ( ! is_array( $statuses ) ) { + $statuses = preg_split( '/[\s,]+/', $statuses ); + } + + // 'any' overrides other statuses. + if ( ! in_array( 'any', $statuses ) ) { + foreach ( $statuses as $status ) { + switch ( $status ) { + case 'hold' : + $status_clauses[] = "comment_approved = '0'"; + break; + + case 'approve' : + $status_clauses[] = "comment_approved = '1'"; + break; + + case 'all' : + case '' : + $status_clauses[] = "( comment_approved = '0' OR comment_approved = '1' )"; + break; + + default : + $status_clauses[] = $wpdb->prepare( "comment_approved = %s", $status ); + break; + } + } + + if ( ! empty( $status_clauses ) ) { + $approved_clauses[] = '( ' . implode( ' OR ', $status_clauses ) . ' )'; + } + } + + // User IDs or emails whose unapproved comments are included, regardless of $status. + if ( ! empty( $this->query_vars['include_unapproved'] ) ) { + $include_unapproved = $this->query_vars['include_unapproved']; + + // Accepts arrays or comma-separated strings. + if ( ! is_array( $include_unapproved ) ) { + $include_unapproved = preg_split( '/[\s,]+/', $include_unapproved ); + } + + $unapproved_ids = $unapproved_emails = array(); + foreach ( $include_unapproved as $unapproved_identifier ) { + // Numeric values are assumed to be user ids. + if ( is_numeric( $unapproved_identifier ) ) { + $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier ); + + // Otherwise we match against email addresses. + } else { + $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier ); + } + } + } + + // Collapse comment_approved clauses into a single OR-separated clause. + if ( ! empty( $approved_clauses ) ) { + if ( 1 === count( $approved_clauses ) ) { + $this->sql_clauses['where']['approved'] = $approved_clauses[0]; + } else { + $this->sql_clauses['where']['approved'] = '( ' . implode( ' OR ', $approved_clauses ) . ' )'; + } + } + + $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC'; + + // Disable ORDER BY with 'none', an empty array, or boolean false. + if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) { + $orderby = ''; + } elseif ( ! empty( $this->query_vars['orderby'] ) ) { + $ordersby = is_array( $this->query_vars['orderby'] ) ? + $this->query_vars['orderby'] : + preg_split( '/[,\s]/', $this->query_vars['orderby'] ); + + $orderby_array = array(); + $found_orderby_comment_ID = false; + foreach ( $ordersby as $_key => $_value ) { + if ( ! $_value ) { + continue; + } + + if ( is_int( $_key ) ) { + $_orderby = $_value; + $_order = $order; + } else { + $_orderby = $_key; + $_order = $_value; + } + + if ( ! $found_orderby_comment_ID && in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) { + $found_orderby_comment_ID = true; + } + + $parsed = $this->parse_orderby( $_orderby ); + + if ( ! $parsed ) { + continue; + } + + if ( 'comment__in' === $_orderby ) { + $orderby_array[] = $parsed; + continue; + } + + $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); + } + + // If no valid clauses were found, order by comment_date_gmt. + if ( empty( $orderby_array ) ) { + $orderby_array[] = "$wpdb->comments.comment_date_gmt $order"; + } + + // To ensure determinate sorting, always include a comment_ID clause. + if ( ! $found_orderby_comment_ID ) { + $comment_ID_order = ''; + + // Inherit order from comment_date or comment_date_gmt, if available. + foreach ( $orderby_array as $orderby_clause ) { + if ( preg_match( '/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match ) ) { + $comment_ID_order = $match[1]; + break; + } + } + + // If no date-related order is available, use the date from the first available clause. + if ( ! $comment_ID_order ) { + foreach ( $orderby_array as $orderby_clause ) { + if ( false !== strpos( 'ASC', $orderby_clause ) ) { + $comment_ID_order = 'ASC'; + } else { + $comment_ID_order = 'DESC'; + } + + break; + } + } + + // Default to DESC. + if ( ! $comment_ID_order ) { + $comment_ID_order = 'DESC'; + } + + $orderby_array[] = "$wpdb->comments.comment_ID $comment_ID_order"; + } + + $orderby = implode( ', ', $orderby_array ); + } else { + $orderby = "$wpdb->comments.comment_date_gmt $order"; + } + + $number = absint( $this->query_vars['number'] ); + $offset = absint( $this->query_vars['offset'] ); + $paged = absint( $this->query_vars['paged'] ); + + if ( ! empty( $number ) ) { + if ( $offset ) { + $limits = 'LIMIT ' . $offset . ',' . $number; + } else { + $limits = 'LIMIT ' . ( $number * ( $paged - 1 ) ) . ',' . $number; + } + } + + if ( $this->query_vars['count'] ) { + $fields = 'COUNT(*)'; + } else { + $fields = "$wpdb->comments.comment_ID"; + } + + $post_id = absint( $this->query_vars['post_id'] ); + if ( ! empty( $post_id ) ) { + $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id ); + } + + // Parse comment IDs for an IN clause. + if ( ! empty( $this->query_vars['comment__in'] ) ) { + $this->sql_clauses['where']['comment__in'] = "$wpdb->comments.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )'; + } + + // Parse comment IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['comment__not_in'] ) ) { + $this->sql_clauses['where']['comment__not_in'] = "$wpdb->comments.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )'; + } + + // Parse comment parent IDs for an IN clause. + if ( ! empty( $this->query_vars['parent__in'] ) ) { + $this->sql_clauses['where']['parent__in'] = 'comment_parent IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__in'] ) ) . ' )'; + } + + // Parse comment parent IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['parent__not_in'] ) ) { + $this->sql_clauses['where']['parent__not_in'] = 'comment_parent NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__not_in'] ) ) . ' )'; + } + + // Parse comment post IDs for an IN clause. + if ( ! empty( $this->query_vars['post__in'] ) ) { + $this->sql_clauses['where']['post__in'] = 'comment_post_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__in'] ) ) . ' )'; + } + + // Parse comment post IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['post__not_in'] ) ) { + $this->sql_clauses['where']['post__not_in'] = 'comment_post_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__not_in'] ) ) . ' )'; + } + + if ( '' !== $this->query_vars['author_email'] ) { + $this->sql_clauses['where']['author_email'] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] ); + } + + if ( '' !== $this->query_vars['author_url'] ) { + $this->sql_clauses['where']['author_url'] = $wpdb->prepare( 'comment_author_url = %s', $this->query_vars['author_url'] ); + } + + if ( '' !== $this->query_vars['karma'] ) { + $this->sql_clauses['where']['karma'] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] ); + } + + // Filtering by comment_type: 'type', 'type__in', 'type__not_in'. + $raw_types = array( + 'IN' => array_merge( (array) $this->query_vars['type'], (array) $this->query_vars['type__in'] ), + 'NOT IN' => (array) $this->query_vars['type__not_in'], + ); + + $comment_types = array(); + foreach ( $raw_types as $operator => $_raw_types ) { + $_raw_types = array_unique( $_raw_types ); + + foreach ( $_raw_types as $type ) { + switch ( $type ) { + // An empty translates to 'all', for backward compatibility + case '': + case 'all' : + break; + + case 'comment': + case 'comments': + $comment_types[ $operator ][] = "''"; + break; + + case 'pings': + $comment_types[ $operator ][] = "'pingback'"; + $comment_types[ $operator ][] = "'trackback'"; + break; + + default: + $comment_types[ $operator ][] = $wpdb->prepare( '%s', $type ); + break; + } + } + + if ( ! empty( $comment_types[ $operator ] ) ) { + $types_sql = implode( ', ', $comment_types[ $operator ] ); + $this->sql_clauses['where']['comment_type__' . strtolower( str_replace( ' ', '_', $operator ) ) ] = "comment_type $operator ($types_sql)"; + } + } + + $parent = $this->query_vars['parent']; + if ( $this->query_vars['hierarchical'] && ! $parent ) { + $parent = 0; + } + + if ( '' !== $parent ) { + $this->sql_clauses['where']['parent'] = $wpdb->prepare( 'comment_parent = %d', $parent ); + } + + if ( is_array( $this->query_vars['user_id'] ) ) { + $this->sql_clauses['where']['user_id'] = 'user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')'; + } elseif ( '' !== $this->query_vars['user_id'] ) { + $this->sql_clauses['where']['user_id'] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] ); + } + + // Falsy search strings are ignored. + if ( strlen( $this->query_vars['search'] ) ) { + $search_sql = $this->get_search_sql( + $this->query_vars['search'], + array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) + ); + + // Strip leading 'AND'. + $this->sql_clauses['where']['search'] = preg_replace( '/^\s*AND\s*/', '', $search_sql ); + } + + // If any post-related query vars are passed, join the posts table. + $join_posts_table = false; + $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent' ) ); + $post_fields = array_filter( $plucked ); + + if ( ! empty( $post_fields ) ) { + $join_posts_table = true; + foreach ( $post_fields as $field_name => $field_value ) { + // $field_value may be an array. + $esses = array_fill( 0, count( (array) $field_value ), '%s' ); + $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value ); + } + } + + // 'post_status' and 'post_type' are handled separately, due to the specialized behavior of 'any'. + foreach ( array( 'post_status', 'post_type' ) as $field_name ) { + $q_values = array(); + if ( ! empty( $this->query_vars[ $field_name ] ) ) { + $q_values = $this->query_vars[ $field_name ]; + if ( ! is_array( $q_values ) ) { + $q_values = explode( ',', $q_values ); + } + + // 'any' will cause the query var to be ignored. + if ( in_array( 'any', $q_values, true ) || empty( $q_values ) ) { + continue; + } + + $join_posts_table = true; + + $esses = array_fill( 0, count( $q_values ), '%s' ); + $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ")", $q_values ); + } + } + + // Comment author IDs for an IN clause. + if ( ! empty( $this->query_vars['author__in'] ) ) { + $this->sql_clauses['where']['author__in'] = 'user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )'; + } + + // Comment author IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['author__not_in'] ) ) { + $this->sql_clauses['where']['author__not_in'] = 'user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )'; + } + + // Post author IDs for an IN clause. + if ( ! empty( $this->query_vars['post_author__in'] ) ) { + $join_posts_table = true; + $this->sql_clauses['where']['post_author__in'] = 'post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )'; + } + + // Post author IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['post_author__not_in'] ) ) { + $join_posts_table = true; + $this->sql_clauses['where']['post_author__not_in'] = 'post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )'; + } + + $join = ''; + + if ( $join_posts_table ) { + $join .= "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID"; + } + + if ( ! empty( $this->meta_query_clauses ) ) { + $join .= $this->meta_query_clauses['join']; + + // Strip leading 'AND'. + $this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $this->meta_query_clauses['where'] ); + + if ( ! $this->query_vars['count'] ) { + $groupby = "{$wpdb->comments}.comment_ID"; + } + } + + if ( ! empty( $this->query_vars['date_query'] ) && is_array( $this->query_vars['date_query'] ) ) { + $this->date_query = new WP_Date_Query( $this->query_vars['date_query'], 'comment_date' ); + $this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() ); + } + + $where = implode( ' AND ', $this->sql_clauses['where'] ); + + $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); + /** + * Filters the comment query clauses. + * + * @since 3.1.0 + * + * @param array $pieces A compacted array of comment query clauses. + * @param WP_Comment_Query $this Current instance of WP_Comment_Query (passed by reference). + */ + $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); + + $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; + $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; + $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; + $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; + $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; + $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; + + $this->filtered_where_clause = $where; + + if ( $where ) { + $where = 'WHERE ' . $where; + } + + if ( $groupby ) { + $groupby = 'GROUP BY ' . $groupby; + } + + if ( $orderby ) { + $orderby = "ORDER BY $orderby"; + } + + $found_rows = ''; + if ( ! $this->query_vars['no_found_rows'] ) { + $found_rows = 'SQL_CALC_FOUND_ROWS'; + } + + $this->sql_clauses['select'] = "SELECT $found_rows $fields"; + $this->sql_clauses['from'] = "FROM $wpdb->comments $join"; + $this->sql_clauses['groupby'] = $groupby; + $this->sql_clauses['orderby'] = $orderby; + $this->sql_clauses['limits'] = $limits; + + $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + + if ( $this->query_vars['count'] ) { + return intval( $wpdb->get_var( $this->request ) ); + } else { + $comment_ids = $wpdb->get_col( $this->request ); + return array_map( 'intval', $comment_ids ); + } + } + + /** + * Populates found_comments and max_num_pages properties for the current + * query if the limit clause was used. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + private function set_found_comments() { + global $wpdb; + + if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { + /** + * Filters the query used to retrieve found comment count. + * + * @since 4.4.0 + * + * @param string $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'. + * @param WP_Comment_Query $comment_query The `WP_Comment_Query` instance. + */ + $found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this ); + + $this->found_comments = (int) $wpdb->get_var( $found_comments_query ); + } + } + + /** + * Fetch descendants for located comments. + * + * Instead of calling `get_children()` separately on each child comment, we do a single set of queries to fetch + * the descendant trees for all matched top-level comments. + * + * @since 4.4.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $comments Array of top-level comments whose descendants should be filled in. + * @return array + */ + protected function fill_descendants( $comments ) { + global $wpdb; + + $levels = array( + 0 => wp_list_pluck( $comments, 'comment_ID' ), + ); + + $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) ); + $last_changed = wp_cache_get_last_changed( 'comment' ); + + // Fetch an entire level of the descendant tree at a time. + $level = 0; + $exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' ); + do { + // Parent-child relationships may be cached. Only query for those that are not. + $child_ids = $uncached_parent_ids = array(); + $_parent_ids = $levels[ $level ]; + foreach ( $_parent_ids as $parent_id ) { + $cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed"; + $parent_child_ids = wp_cache_get( $cache_key, 'comment' ); + if ( false !== $parent_child_ids ) { + $child_ids = array_merge( $child_ids, $parent_child_ids ); + } else { + $uncached_parent_ids[] = $parent_id; + } + } + + if ( $uncached_parent_ids ) { + // Fetch this level of comments. + $parent_query_args = $this->query_vars; + foreach ( $exclude_keys as $exclude_key ) { + $parent_query_args[ $exclude_key ] = ''; + } + $parent_query_args['parent__in'] = $uncached_parent_ids; + $parent_query_args['no_found_rows'] = true; + $parent_query_args['hierarchical'] = false; + $parent_query_args['offset'] = 0; + $parent_query_args['number'] = 0; + + $level_comments = get_comments( $parent_query_args ); + + // Cache parent-child relationships. + $parent_map = array_fill_keys( $uncached_parent_ids, array() ); + foreach ( $level_comments as $level_comment ) { + $parent_map[ $level_comment->comment_parent ][] = $level_comment->comment_ID; + $child_ids[] = $level_comment->comment_ID; + } + + foreach ( $parent_map as $parent_id => $children ) { + $cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed"; + wp_cache_set( $cache_key, $children, 'comment' ); + } + } + + $level++; + $levels[ $level ] = $child_ids; + } while ( $child_ids ); + + // Prime comment caches for non-top-level comments. + $descendant_ids = array(); + for ( $i = 1, $c = count( $levels ); $i < $c; $i++ ) { + $descendant_ids = array_merge( $descendant_ids, $levels[ $i ] ); + } + + _prime_comment_caches( $descendant_ids, $this->query_vars['update_comment_meta_cache'] ); + + // Assemble a flat array of all comments + descendants. + $all_comments = $comments; + foreach ( $descendant_ids as $descendant_id ) { + $all_comments[] = get_comment( $descendant_id ); + } + + // If a threaded representation was requested, build the tree. + if ( 'threaded' === $this->query_vars['hierarchical'] ) { + $threaded_comments = $ref = array(); + foreach ( $all_comments as $k => $c ) { + $_c = get_comment( $c->comment_ID ); + + // If the comment isn't in the reference array, it goes in the top level of the thread. + if ( ! isset( $ref[ $c->comment_parent ] ) ) { + $threaded_comments[ $_c->comment_ID ] = $_c; + $ref[ $_c->comment_ID ] = $threaded_comments[ $_c->comment_ID ]; + + // Otherwise, set it as a child of its parent. + } else { + + $ref[ $_c->comment_parent ]->add_child( $_c ); + $ref[ $_c->comment_ID ] = $ref[ $_c->comment_parent ]->get_child( $_c->comment_ID ); + } + } + + // Set the 'populated_children' flag, to ensure additional database queries aren't run. + foreach ( $ref as $_ref ) { + $_ref->populated_children( true ); + } + + $comments = $threaded_comments; + } else { + $comments = $all_comments; + } + + return $comments; + } + + /** + * Used internally to generate an SQL string for searching across multiple columns + * + * @since 3.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $string + * @param array $cols + * @return string + */ + protected function get_search_sql( $string, $cols ) { + global $wpdb; + + $like = '%' . $wpdb->esc_like( $string ) . '%'; + + $searches = array(); + foreach ( $cols as $col ) { + $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); + } + + return ' AND (' . implode(' OR ', $searches) . ')'; + } + + /** + * Parse and sanitize 'orderby' keys passed to the comment query. + * + * @since 4.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby Alias for the field to order by. + * @return string|false Value to used in the ORDER clause. False otherwise. + */ + protected function parse_orderby( $orderby ) { + global $wpdb; + + $allowed_keys = array( + 'comment_agent', + 'comment_approved', + 'comment_author', + 'comment_author_email', + 'comment_author_IP', + 'comment_author_url', + 'comment_content', + 'comment_date', + 'comment_date_gmt', + 'comment_ID', + 'comment_karma', + 'comment_parent', + 'comment_post_ID', + 'comment_type', + 'user_id', + ); + + if ( ! empty( $this->query_vars['meta_key'] ) ) { + $allowed_keys[] = $this->query_vars['meta_key']; + $allowed_keys[] = 'meta_value'; + $allowed_keys[] = 'meta_value_num'; + } + + $meta_query_clauses = $this->meta_query->get_clauses(); + if ( $meta_query_clauses ) { + $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_query_clauses ) ); + } + + $parsed = false; + if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) { + $parsed = "$wpdb->commentmeta.meta_value"; + } elseif ( $orderby == 'meta_value_num' ) { + $parsed = "$wpdb->commentmeta.meta_value+0"; + } elseif ( $orderby == 'comment__in' ) { + $comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) ); + $parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )"; + } elseif ( in_array( $orderby, $allowed_keys ) ) { + + if ( isset( $meta_query_clauses[ $orderby ] ) ) { + $meta_clause = $meta_query_clauses[ $orderby ]; + $parsed = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) ); + } else { + $parsed = "$wpdb->comments.$orderby"; + } + } + + return $parsed; + } + + /** + * Parse an 'order' query variable and cast it to ASC or DESC as necessary. + * + * @since 4.2.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'DESC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } +} diff --git a/backend/wp-includes/class-wp-comment.php b/backend/wp-includes/class-wp-comment.php new file mode 100644 index 0000000..d3b96a3 --- /dev/null +++ b/backend/wp-includes/class-wp-comment.php @@ -0,0 +1,369 @@ +<?php +/** + * Comment API: WP_Comment class + * + * @package WordPress + * @subpackage Comments + * @since 4.4.0 + */ + +/** + * Core class used to organize comments as instantiated objects with defined members. + * + * @since 4.4.0 + */ +final class WP_Comment { + + /** + * Comment ID. + * + * @since 4.4.0 + * @var int + */ + public $comment_ID; + + /** + * ID of the post the comment is associated with. + * + * @since 4.4.0 + * @var int + */ + public $comment_post_ID = 0; + + /** + * Comment author name. + * + * @since 4.4.0 + * @var string + */ + public $comment_author = ''; + + /** + * Comment author email address. + * + * @since 4.4.0 + * @var string + */ + public $comment_author_email = ''; + + /** + * Comment author URL. + * + * @since 4.4.0 + * @var string + */ + public $comment_author_url = ''; + + /** + * Comment author IP address (IPv4 format). + * + * @since 4.4.0 + * @var string + */ + public $comment_author_IP = ''; + + /** + * Comment date in YYYY-MM-DD HH:MM:SS format. + * + * @since 4.4.0 + * @var string + */ + public $comment_date = '0000-00-00 00:00:00'; + + /** + * Comment GMT date in YYYY-MM-DD HH::MM:SS format. + * + * @since 4.4.0 + * @var string + */ + public $comment_date_gmt = '0000-00-00 00:00:00'; + + /** + * Comment content. + * + * @since 4.4.0 + * @var string + */ + public $comment_content; + + /** + * Comment karma count. + * + * @since 4.4.0 + * @var int + */ + public $comment_karma = 0; + + /** + * Comment approval status. + * + * @since 4.4.0 + * @var string + */ + public $comment_approved = '1'; + + /** + * Comment author HTTP user agent. + * + * @since 4.4.0 + * @var string + */ + public $comment_agent = ''; + + /** + * Comment type. + * + * @since 4.4.0 + * @var string + */ + public $comment_type = ''; + + /** + * Parent comment ID. + * + * @since 4.4.0 + * @var int + */ + public $comment_parent = 0; + + /** + * Comment author ID. + * + * @since 4.4.0 + * @var int + */ + public $user_id = 0; + + /** + * Comment children. + * + * @since 4.4.0 + * @var array + */ + protected $children; + + /** + * Whether children have been populated for this comment object. + * + * @since 4.4.0 + * @var bool + */ + protected $populated_children = false; + + /** + * Post fields. + * + * @since 4.4.0 + * @var array + */ + protected $post_fields = array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count' ); + + /** + * Retrieves a WP_Comment instance. + * + * @since 4.4.0 + * @static + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $id Comment ID. + * @return WP_Comment|false Comment object, otherwise false. + */ + public static function get_instance( $id ) { + global $wpdb; + + $comment_id = (int) $id; + if ( ! $comment_id ) { + return false; + } + + $_comment = wp_cache_get( $comment_id, 'comment' ); + + if ( ! $_comment ) { + $_comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id ) ); + + if ( ! $_comment ) { + return false; + } + + wp_cache_add( $_comment->comment_ID, $_comment, 'comment' ); + } + + return new WP_Comment( $_comment ); + } + + /** + * Constructor. + * + * Populates properties with object vars. + * + * @since 4.4.0 + * + * @param WP_Comment $comment Comment object. + */ + public function __construct( $comment ) { + foreach ( get_object_vars( $comment ) as $key => $value ) { + $this->$key = $value; + } + } + + /** + * Convert object to array. + * + * @since 4.4.0 + * + * @return array Object as array. + */ + public function to_array() { + return get_object_vars( $this ); + } + + /** + * Get the children of a comment. + * + * @since 4.4.0 + * + * @param array $args { + * Array of arguments used to pass to get_comments() and determine format. + * + * @type string $format Return value format. 'tree' for a hierarchical tree, 'flat' for a flattened array. + * Default 'tree'. + * @type string $status Comment status to limit results by. Accepts 'hold' (`comment_status=0`), + * 'approve' (`comment_status=1`), 'all', or a custom comment status. + * Default 'all'. + * @type string $hierarchical Whether to include comment descendants in the results. + * 'threaded' returns a tree, with each comment's children + * stored in a `children` property on the `WP_Comment` object. + * 'flat' returns a flat array of found comments plus their children. + * Pass `false` to leave out descendants. + * The parameter is ignored (forced to `false`) when `$fields` is 'ids' or 'counts'. + * Accepts 'threaded', 'flat', or false. Default: 'threaded'. + * @type string|array $orderby Comment status or array of statuses. To use 'meta_value' + * or 'meta_value_num', `$meta_key` must also be defined. + * To sort by a specific `$meta_query` clause, use that + * clause's array key. Accepts 'comment_agent', + * 'comment_approved', 'comment_author', + * 'comment_author_email', 'comment_author_IP', + * 'comment_author_url', 'comment_content', 'comment_date', + * 'comment_date_gmt', 'comment_ID', 'comment_karma', + * 'comment_parent', 'comment_post_ID', 'comment_type', + * 'user_id', 'comment__in', 'meta_value', 'meta_value_num', + * the value of $meta_key, and the array keys of + * `$meta_query`. Also accepts false, an empty array, or + * 'none' to disable `ORDER BY` clause. + * } + * @return array Array of `WP_Comment` objects. + */ + public function get_children( $args = array() ) { + $defaults = array( + 'format' => 'tree', + 'status' => 'all', + 'hierarchical' => 'threaded', + 'orderby' => '', + ); + + $_args = wp_parse_args( $args, $defaults ); + $_args['parent'] = $this->comment_ID; + + if ( is_null( $this->children ) ) { + if ( $this->populated_children ) { + $this->children = array(); + } else { + $this->children = get_comments( $_args ); + } + } + + if ( 'flat' === $_args['format'] ) { + $children = array(); + foreach ( $this->children as $child ) { + $child_args = $_args; + $child_args['format'] = 'flat'; + // get_children() resets this value automatically. + unset( $child_args['parent'] ); + + $children = array_merge( $children, array( $child ), $child->get_children( $child_args ) ); + } + } else { + $children = $this->children; + } + + return $children; + } + + /** + * Add a child to the comment. + * + * Used by `WP_Comment_Query` when bulk-filling descendants. + * + * @since 4.4.0 + * + * @param WP_Comment $child Child comment. + */ + public function add_child( WP_Comment $child ) { + $this->children[ $child->comment_ID ] = $child; + } + + /** + * Get a child comment by ID. + * + * @since 4.4.0 + * + * @param int $child_id ID of the child. + * @return WP_Comment|bool Returns the comment object if found, otherwise false. + */ + public function get_child( $child_id ) { + if ( isset( $this->children[ $child_id ] ) ) { + return $this->children[ $child_id ]; + } + + return false; + } + + /** + * Set the 'populated_children' flag. + * + * This flag is important for ensuring that calling `get_children()` on a childless comment will not trigger + * unneeded database queries. + * + * @since 4.4.0 + * + * @param bool $set Whether the comment's children have already been populated. + */ + public function populated_children( $set ) { + $this->populated_children = (bool) $set; + } + + /** + * Check whether a non-public property is set. + * + * If `$name` matches a post field, the comment post will be loaded and the post's value checked. + * + * @since 4.4.0 + * + * @param string $name Property name. + * @return bool + */ + public function __isset( $name ) { + if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) { + $post = get_post( $this->comment_post_ID ); + return property_exists( $post, $name ); + } + } + + /** + * Magic getter. + * + * If `$name` matches a post field, the comment post will be loaded and the post's value returned. + * + * @since 4.4.0 + * + * @param string $name + * @return mixed + */ + public function __get( $name ) { + if ( in_array( $name, $this->post_fields ) ) { + $post = get_post( $this->comment_post_ID ); + return $post->$name; + } + } +} diff --git a/backend/wp-includes/class-wp-customize-control.php b/backend/wp-includes/class-wp-customize-control.php new file mode 100644 index 0000000..4f289cd --- /dev/null +++ b/backend/wp-includes/class-wp-customize-control.php @@ -0,0 +1,794 @@ +<?php +/** + * WordPress Customize Control classes + * + * @package WordPress + * @subpackage Customize + * @since 3.4.0 + */ + +/** + * Customize Control class. + * + * @since 3.4.0 + */ +class WP_Customize_Control { + + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * + * @static + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @var int + */ + public $instance_number; + + /** + * Customizer manager. + * + * @since 3.4.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * Control ID. + * + * @since 3.4.0 + * @var string + */ + public $id; + + /** + * All settings tied to the control. + * + * @since 3.4.0 + * @var array + */ + public $settings; + + /** + * The primary setting for the control (if there is one). + * + * @since 3.4.0 + * @var string + */ + public $setting = 'default'; + + /** + * Capability required to use this control. + * + * Normally this is empty and the capability is derived from the capabilities + * of the associated `$settings`. + * + * @since 4.5.0 + * @var string + */ + public $capability; + + /** + * Order priority to load the control in Customizer. + * + * @since 3.4.0 + * @var int + */ + public $priority = 10; + + /** + * Section the control belongs to. + * + * @since 3.4.0 + * @var string + */ + public $section = ''; + + /** + * Label for the control. + * + * @since 3.4.0 + * @var string + */ + public $label = ''; + + /** + * Description for the control. + * + * @since 4.0.0 + * @var string + */ + public $description = ''; + + /** + * List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values. + * + * @since 3.4.0 + * @var array + */ + public $choices = array(); + + /** + * List of custom input attributes for control output, where attribute names are the keys and values are the values. + * + * Not used for 'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types. + * + * @since 4.0.0 + * @var array + */ + public $input_attrs = array(); + + /** + * Show UI for adding new content, currently only used for the dropdown-pages control. + * + * @since 4.7.0 + * @var bool + */ + public $allow_addition = false; + + /** + * @deprecated It is better to just call the json() method + * @since 3.4.0 + * @var array + */ + public $json = array(); + + /** + * Control's Type. + * + * @since 3.4.0 + * @var string + */ + public $type = 'text'; + + /** + * Callback. + * + * @since 4.0.0 + * + * @see WP_Customize_Control::active() + * + * @var callable Callback is called with one argument, the instance of + * WP_Customize_Control, and returns bool to indicate whether + * the control is active (such as it relates to the URL + * currently being previewed). + */ + public $active_callback = ''; + + /** + * Constructor. + * + * Supplied `$args` override class property defaults. + * + * If `$args['settings']` is not defined, use the $id as the setting ID. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $manager Customizer bootstrap instance. + * @param string $id Control ID. + * @param array $args { + * Optional. Arguments to override class property defaults. + * + * @type int $instance_number Order in which this instance was created in relation + * to other instances. + * @type WP_Customize_Manager $manager Customizer bootstrap instance. + * @type string $id Control ID. + * @type array $settings All settings tied to the control. If undefined, `$id` will + * be used. + * @type string $setting The primary setting for the control (if there is one). + * Default 'default'. + * @type int $priority Order priority to load the control. Default 10. + * @type string $section Section the control belongs to. Default empty. + * @type string $label Label for the control. Default empty. + * @type string $description Description for the control. Default empty. + * @type array $choices List of choices for 'radio' or 'select' type controls, where + * values are the keys, and labels are the values. + * Default empty array. + * @type array $input_attrs List of custom input attributes for control output, where + * attribute names are the keys and values are the values. Not + * used for 'checkbox', 'radio', 'select', 'textarea', or + * 'dropdown-pages' control types. Default empty array. + * @type array $json Deprecated. Use WP_Customize_Control::json() instead. + * @type string $type Control type. Core controls include 'text', 'checkbox', + * 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional + * input types such as 'email', 'url', 'number', 'hidden', and + * 'date' are supported implicitly. Default 'text'. + * } + */ + public function __construct( $manager, $id, $args = array() ) { + $keys = array_keys( get_object_vars( $this ) ); + foreach ( $keys as $key ) { + if ( isset( $args[ $key ] ) ) { + $this->$key = $args[ $key ]; + } + } + + $this->manager = $manager; + $this->id = $id; + if ( empty( $this->active_callback ) ) { + $this->active_callback = array( $this, 'active_callback' ); + } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; + + // Process settings. + if ( ! isset( $this->settings ) ) { + $this->settings = $id; + } + + $settings = array(); + if ( is_array( $this->settings ) ) { + foreach ( $this->settings as $key => $setting ) { + $settings[ $key ] = $this->manager->get_setting( $setting ); + } + } else if ( is_string( $this->settings ) ) { + $this->setting = $this->manager->get_setting( $this->settings ); + $settings['default'] = $this->setting; + } + $this->settings = $settings; + } + + /** + * Enqueue control related scripts/styles. + * + * @since 3.4.0 + */ + public function enqueue() {} + + /** + * Check whether control is active to current Customizer preview. + * + * @since 4.0.0 + * + * @return bool Whether the control is active to the current preview. + */ + final public function active() { + $control = $this; + $active = call_user_func( $this->active_callback, $this ); + + /** + * Filters response of WP_Customize_Control::active(). + * + * @since 4.0.0 + * + * @param bool $active Whether the Customizer control is active. + * @param WP_Customize_Control $control WP_Customize_Control instance. + */ + $active = apply_filters( 'customize_control_active', $active, $control ); + + return $active; + } + + /** + * Default callback used when invoking WP_Customize_Control::active(). + * + * Subclasses can override this with their specific logic, or they may + * provide an 'active_callback' argument to the constructor. + * + * @since 4.0.0 + * + * @return true Always true. + */ + public function active_callback() { + return true; + } + + /** + * Fetch a setting's value. + * Grabs the main setting by default. + * + * @since 3.4.0 + * + * @param string $setting_key + * @return mixed The requested setting's value, if the setting exists. + */ + final public function value( $setting_key = 'default' ) { + if ( isset( $this->settings[ $setting_key ] ) ) { + return $this->settings[ $setting_key ]->value(); + } + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 3.4.0 + */ + public function to_json() { + $this->json['settings'] = array(); + foreach ( $this->settings as $key => $setting ) { + $this->json['settings'][ $key ] = $setting->id; + } + + $this->json['type'] = $this->type; + $this->json['priority'] = $this->priority; + $this->json['active'] = $this->active(); + $this->json['section'] = $this->section; + $this->json['content'] = $this->get_content(); + $this->json['label'] = $this->label; + $this->json['description'] = $this->description; + $this->json['instanceNumber'] = $this->instance_number; + + if ( 'dropdown-pages' === $this->type ) { + $this->json['allow_addition'] = $this->allow_addition; + } + } + + /** + * Get the data to export to the client via JSON. + * + * @since 4.1.0 + * + * @return array Array of parameters passed to the JavaScript. + */ + public function json() { + $this->to_json(); + return $this->json; + } + + /** + * Checks if the user can use this control. + * + * Returns false if the user cannot manipulate one of the associated settings, + * or if one of the associated settings does not exist. Also returns false if + * the associated section does not exist or if its capability check returns + * false. + * + * @since 3.4.0 + * + * @return bool False if theme doesn't support the control or user doesn't have the required permissions, otherwise true. + */ + final public function check_capabilities() { + if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) { + return false; + } + + foreach ( $this->settings as $setting ) { + if ( ! $setting || ! $setting->check_capabilities() ) { + return false; + } + } + + $section = $this->manager->get_section( $this->section ); + if ( isset( $section ) && ! $section->check_capabilities() ) { + return false; + } + + return true; + } + + /** + * Get the control's content for insertion into the Customizer pane. + * + * @since 4.1.0 + * + * @return string Contents of the control. + */ + final public function get_content() { + ob_start(); + $this->maybe_render(); + return trim( ob_get_clean() ); + } + + /** + * Check capabilities and render the control. + * + * @since 3.4.0 + * @uses WP_Customize_Control::render() + */ + final public function maybe_render() { + if ( ! $this->check_capabilities() ) + return; + + /** + * Fires just before the current Customizer control is rendered. + * + * @since 3.4.0 + * + * @param WP_Customize_Control $this WP_Customize_Control instance. + */ + do_action( 'customize_render_control', $this ); + + /** + * Fires just before a specific Customizer control is rendered. + * + * The dynamic portion of the hook name, `$this->id`, refers to + * the control ID. + * + * @since 3.4.0 + * + * @param WP_Customize_Control $this WP_Customize_Control instance. + */ + do_action( "customize_render_control_{$this->id}", $this ); + + $this->render(); + } + + /** + * Renders the control wrapper and calls $this->render_content() for the internals. + * + * @since 3.4.0 + */ + protected function render() { + $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id ); + $class = 'customize-control customize-control-' . $this->type; + + printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) ); + $this->render_content(); + echo '</li>'; + } + + /** + * Get the data link attribute for a setting. + * + * @since 3.4.0 + * @since 4.9.0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key. + * + * @param string $setting_key + * @return string Data link parameter, a `data-customize-setting-link` attribute if the `$setting_key` refers to a pre-registered setting, + * and a `data-customize-setting-key-link` attribute if the setting is not yet registered. + */ + public function get_link( $setting_key = 'default' ) { + if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) { + return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; + } else { + return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"'; + } + } + + /** + * Render the data link attribute for the control's input element. + * + * @since 3.4.0 + * @uses WP_Customize_Control::get_link() + * + * @param string $setting_key + */ + public function link( $setting_key = 'default' ) { + echo $this->get_link( $setting_key ); + } + + /** + * Render the custom attributes for the control's input element. + * + * @since 4.0.0 + */ + public function input_attrs() { + foreach ( $this->input_attrs as $attr => $value ) { + echo $attr . '="' . esc_attr( $value ) . '" '; + } + } + + /** + * Render the control's content. + * + * Allows the content to be overridden without having to rewrite the wrapper in `$this::render()`. + * + * Supports basic input types `text`, `checkbox`, `textarea`, `radio`, `select` and `dropdown-pages`. + * Additional input types such as `email`, `url`, `number`, `hidden` and `date` are supported implicitly. + * + * Control content can alternately be rendered in JS. See WP_Customize_Control::print_template(). + * + * @since 3.4.0 + */ + protected function render_content() { + $input_id = '_customize-input-' . $this->id; + $description_id = '_customize-description-' . $this->id; + $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : ''; + switch ( $this->type ) { + case 'checkbox': + ?> + <span class="customize-inside-control-row"> + <input + id="<?php echo esc_attr( $input_id ); ?>" + <?php echo $describedby_attr; ?> + type="checkbox" + value="<?php echo esc_attr( $this->value() ); ?>" + <?php $this->link(); ?> + <?php checked( $this->value() ); ?> + /> + <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $this->label ); ?></label> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span> + <?php endif; ?> + </span> + <?php + break; + case 'radio': + if ( empty( $this->choices ) ) { + return; + } + + $name = '_customize-radio-' . $this->id; + ?> + <?php if ( ! empty( $this->label ) ) : ?> + <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> + <?php endif; ?> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description ; ?></span> + <?php endif; ?> + + <?php foreach ( $this->choices as $value => $label ) : ?> + <span class="customize-inside-control-row"> + <input + id="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>" + type="radio" + <?php echo $describedby_attr; ?> + value="<?php echo esc_attr( $value ); ?>" + name="<?php echo esc_attr( $name ); ?>" + <?php $this->link(); ?> + <?php checked( $this->value(), $value ); ?> + /> + <label for="<?php echo esc_attr( $input_id . '-radio-' . $value ); ?>"><?php echo esc_html( $label ); ?></label> + </span> + <?php endforeach; ?> + <?php + break; + case 'select': + if ( empty( $this->choices ) ) { + return; + } + + ?> + <?php if ( ! empty( $this->label ) ) : ?> + <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label> + <?php endif; ?> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span> + <?php endif; ?> + + <select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>> + <?php + foreach ( $this->choices as $value => $label ) { + echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; + } + ?> + </select> + <?php + break; + case 'textarea': + ?> + <?php if ( ! empty( $this->label ) ) : ?> + <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label> + <?php endif; ?> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span> + <?php endif; ?> + <textarea + id="<?php echo esc_attr( $input_id ); ?>" + rows="5" + <?php echo $describedby_attr; ?> + <?php $this->input_attrs(); ?> + <?php $this->link(); ?>> + <?php echo esc_textarea( $this->value() ); ?> + </textarea> + <?php + break; + case 'dropdown-pages': + ?> + <?php if ( ! empty( $this->label ) ) : ?> + <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label> + <?php endif; ?> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span> + <?php endif; ?> + + <?php + $dropdown_name = '_customize-dropdown-pages-' . $this->id; + $show_option_none = __( '— Select —' ); + $option_none_value = '0'; + $dropdown = wp_dropdown_pages( + array( + 'name' => $dropdown_name, + 'echo' => 0, + 'show_option_none' => $show_option_none, + 'option_none_value' => $option_none_value, + 'selected' => $this->value(), + ) + ); + if ( empty( $dropdown ) ) { + $dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) ); + $dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) ); + $dropdown .= '</select>'; + } + + // Hackily add in the data link parameter. + $dropdown = str_replace( '<select', '<select ' . $this->get_link() . ' id="' . esc_attr( $input_id ) . '" ' . $describedby_attr, $dropdown ); + + // Even more hacikly add auto-draft page stubs. + // @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. See <https://github.com/xwp/wp-customize-posts/pull/250>. + $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); + if ( $nav_menus_created_posts_setting && current_user_can( 'publish_pages' ) ) { + $auto_draft_page_options = ''; + foreach ( $nav_menus_created_posts_setting->value() as $auto_draft_page_id ) { + $post = get_post( $auto_draft_page_id ); + if ( $post && 'page' === $post->post_type ) { + $auto_draft_page_options .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $post->ID ), esc_html( $post->post_title ) ); + } + } + if ( $auto_draft_page_options ) { + $dropdown = str_replace( '</select>', $auto_draft_page_options . '</select>', $dropdown ); + } + } + + echo $dropdown; + ?> + <?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?> + <button type="button" class="button-link add-new-toggle"> + <?php + /* translators: %s: add new page label */ + printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item ); + ?> + </button> + <div class="new-content-item"> + <label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label> + <input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title…' ); ?>"> + <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> + </div> + <?php endif; ?> + <?php + break; + default: + ?> + <?php if ( ! empty( $this->label ) ) : ?> + <label for="<?php echo esc_attr( $input_id ); ?>" class="customize-control-title"><?php echo esc_html( $this->label ); ?></label> + <?php endif; ?> + <?php if ( ! empty( $this->description ) ) : ?> + <span id="<?php echo esc_attr( $description_id ); ?>" class="description customize-control-description"><?php echo $this->description; ?></span> + <?php endif; ?> + <input + id="<?php echo esc_attr( $input_id ); ?>" + type="<?php echo esc_attr( $this->type ); ?>" + <?php echo $describedby_attr; ?> + <?php $this->input_attrs(); ?> + <?php if ( ! isset( $this->input_attrs['value'] ) ) : ?> + value="<?php echo esc_attr( $this->value() ); ?>" + <?php endif; ?> + <?php $this->link(); ?> + /> + <?php + break; + } + } + + /** + * Render the control's JS template. + * + * This function is only run for control types that have been registered with + * WP_Customize_Manager::register_control_type(). + * + * In the future, this will also print the template for the control's container + * element and be override-able. + * + * @since 4.1.0 + */ + final public function print_template() { + ?> + <script type="text/html" id="tmpl-customize-control-<?php echo $this->type; ?>-content"> + <?php $this->content_template(); ?> + </script> + <?php + } + + /** + * An Underscore (JS) template for this control's content (but not its container). + * + * Class variables for this control class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Control::to_json(). + * + * @see WP_Customize_Control::print_template() + * + * @since 4.1.0 + */ + protected function content_template() {} + +} + +/** + * WP_Customize_Color_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' ); + +/** + * WP_Customize_Media_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' ); + +/** + * WP_Customize_Upload_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' ); + +/** + * WP_Customize_Image_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' ); + +/** + * WP_Customize_Background_Image_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' ); + +/** + * WP_Customize_Background_Position_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' ); + +/** + * WP_Customize_Cropped_Image_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' ); + +/** + * WP_Customize_Site_Icon_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' ); + +/** + * WP_Customize_Header_Image_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' ); + +/** + * WP_Customize_Theme_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' ); + +/** + * WP_Widget_Area_Customize_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' ); + +/** + * WP_Widget_Form_Customize_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' ); + +/** + * WP_Customize_Nav_Menu_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' ); + +/** + * WP_Customize_Nav_Menu_Item_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' ); + +/** + * WP_Customize_Nav_Menu_Location_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' ); + +/** + * WP_Customize_Nav_Menu_Name_Control class. + * + * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent + * release, the require_once() here will be removed and _deprecated_file() will be called if file is + * required at all. + * + * @deprecated 4.9.0 This file is no longer used due to new menu creation UX. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' ); + +/** + * WP_Customize_Nav_Menu_Locations_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php' ); + +/** + * WP_Customize_Nav_Menu_Auto_Add_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' ); + +/** + * WP_Customize_Date_Time_Control class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php' ); diff --git a/backend/wp-includes/class-wp-customize-manager.php b/backend/wp-includes/class-wp-customize-manager.php new file mode 100644 index 0000000..1a5360d --- /dev/null +++ b/backend/wp-includes/class-wp-customize-manager.php @@ -0,0 +1,5701 @@ +<?php +/** + * WordPress Customize Manager classes + * + * @package WordPress + * @subpackage Customize + * @since 3.4.0 + */ + +/** + * Customize Manager class. + * + * Bootstraps the Customize experience on the server-side. + * + * Sets up the theme-switching process if a theme other than the active one is + * being previewed and customized. + * + * Serves as a factory for Customize Controls and Settings, and + * instantiates default Customize Controls and Settings. + * + * @since 3.4.0 + */ +final class WP_Customize_Manager { + /** + * An instance of the theme being previewed. + * + * @since 3.4.0 + * @var WP_Theme + */ + protected $theme; + + /** + * The directory name of the previously active theme (within the theme_root). + * + * @since 3.4.0 + * @var string + */ + protected $original_stylesheet; + + /** + * Whether this is a Customizer pageload. + * + * @since 3.4.0 + * @var bool + */ + protected $previewing = false; + + /** + * Methods and properties dealing with managing widgets in the Customizer. + * + * @since 3.9.0 + * @var WP_Customize_Widgets + */ + public $widgets; + + /** + * Methods and properties dealing with managing nav menus in the Customizer. + * + * @since 4.3.0 + * @var WP_Customize_Nav_Menus + */ + public $nav_menus; + + /** + * Methods and properties dealing with selective refresh in the Customizer preview. + * + * @since 4.5.0 + * @var WP_Customize_Selective_Refresh + */ + public $selective_refresh; + + /** + * Registered instances of WP_Customize_Setting. + * + * @since 3.4.0 + * @var array + */ + protected $settings = array(); + + /** + * Sorted top-level instances of WP_Customize_Panel and WP_Customize_Section. + * + * @since 4.0.0 + * @var array + */ + protected $containers = array(); + + /** + * Registered instances of WP_Customize_Panel. + * + * @since 4.0.0 + * @var array + */ + protected $panels = array(); + + /** + * List of core components. + * + * @since 4.5.0 + * @var array + */ + protected $components = array( 'widgets', 'nav_menus' ); + + /** + * Registered instances of WP_Customize_Section. + * + * @since 3.4.0 + * @var array + */ + protected $sections = array(); + + /** + * Registered instances of WP_Customize_Control. + * + * @since 3.4.0 + * @var array + */ + protected $controls = array(); + + /** + * Panel types that may be rendered from JS templates. + * + * @since 4.3.0 + * @var array + */ + protected $registered_panel_types = array(); + + /** + * Section types that may be rendered from JS templates. + * + * @since 4.3.0 + * @var array + */ + protected $registered_section_types = array(); + + /** + * Control types that may be rendered from JS templates. + * + * @since 4.1.0 + * @var array + */ + protected $registered_control_types = array(); + + /** + * Initial URL being previewed. + * + * @since 4.4.0 + * @var string + */ + protected $preview_url; + + /** + * URL to link the user to when closing the Customizer. + * + * @since 4.4.0 + * @var string + */ + protected $return_url; + + /** + * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused. + * + * @since 4.4.0 + * @var array + */ + protected $autofocus = array(); + + /** + * Messenger channel. + * + * @since 4.7.0 + * @var string + */ + protected $messenger_channel; + + /** + * Whether the autosave revision of the changeset should be loaded. + * + * @since 4.9.0 + * @var bool + */ + protected $autosaved = false; + + /** + * Whether the changeset branching is allowed. + * + * @since 4.9.0 + * @var bool + */ + protected $branching = true; + + /** + * Whether settings should be previewed. + * + * @since 4.9.0 + * @var bool + */ + protected $settings_previewed = true; + + /** + * Whether a starter content changeset was saved. + * + * @since 4.9.0 + * @var bool + */ + protected $saved_starter_content_changeset = false; + + /** + * Unsanitized values for Customize Settings parsed from $_POST['customized']. + * + * @var array + */ + private $_post_values; + + /** + * Changeset UUID. + * + * @since 4.7.0 + * @var string + */ + private $_changeset_uuid; + + /** + * Changeset post ID. + * + * @since 4.7.0 + * @var int|false + */ + private $_changeset_post_id; + + /** + * Changeset data loaded from a customize_changeset post. + * + * @since 4.7.0 + * @var array + */ + private $_changeset_data; + + /** + * Constructor. + * + * @since 3.4.0 + * @since 4.7.0 Added $args param. + * + * @param array $args { + * Args. + * + * @type null|string|false $changeset_uuid Changeset UUID, the `post_name` for the customize_changeset post containing the customized state. + * Defaults to `null` resulting in a UUID to be immediately generated. If `false` is provided, then + * then the changeset UUID will be determined during `after_setup_theme`: when the + * `customize_changeset_branching` filter returns false, then the default UUID will be that + * of the most recent `customize_changeset` post that has a status other than 'auto-draft', + * 'publish', or 'trash'. Otherwise, if changeset branching is enabled, then a random UUID will be used. + * @type string $theme Theme to be previewed (for theme switch). Defaults to customize_theme or theme query params. + * @type string $messenger_channel Messenger channel. Defaults to customize_messenger_channel query param. + * @type bool $settings_previewed If settings should be previewed. Defaults to true. + * @type bool $branching If changeset branching is allowed; otherwise, changesets are linear. Defaults to true. + * @type bool $autosaved If data from a changeset's autosaved revision should be loaded if it exists. Defaults to false. + * } + */ + public function __construct( $args = array() ) { + + $args = array_merge( + array_fill_keys( array( 'changeset_uuid', 'theme', 'messenger_channel', 'settings_previewed', 'autosaved', 'branching' ), null ), + $args + ); + + // Note that the UUID format will be validated in the setup_theme() method. + if ( ! isset( $args['changeset_uuid'] ) ) { + $args['changeset_uuid'] = wp_generate_uuid4(); + } + + // The theme and messenger_channel should be supplied via $args, but they are also looked at in the $_REQUEST global here for back-compat. + if ( ! isset( $args['theme'] ) ) { + if ( isset( $_REQUEST['customize_theme'] ) ) { + $args['theme'] = wp_unslash( $_REQUEST['customize_theme'] ); + } elseif ( isset( $_REQUEST['theme'] ) ) { // Deprecated. + $args['theme'] = wp_unslash( $_REQUEST['theme'] ); + } + } + if ( ! isset( $args['messenger_channel'] ) && isset( $_REQUEST['customize_messenger_channel'] ) ) { + $args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) ); + } + + $this->original_stylesheet = get_stylesheet(); + $this->theme = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null ); + $this->messenger_channel = $args['messenger_channel']; + $this->_changeset_uuid = $args['changeset_uuid']; + + foreach ( array( 'settings_previewed', 'autosaved', 'branching' ) as $key ) { + if ( isset( $args[ $key ] ) ) { + $this->$key = (bool) $args[ $key ]; + } + } + + require_once( ABSPATH . WPINC . '/class-wp-customize-setting.php' ); + require_once( ABSPATH . WPINC . '/class-wp-customize-panel.php' ); + require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' ); + require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' ); + + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-code-editor-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php' ); // @todo Remove in 5.0. See #42364. + + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php' ); + + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-panel.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-section.php' ); // @todo Remove in 5.0. See #42364. + + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-custom-css-setting.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php' ); + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-setting.php' ); + + /** + * Filters the core Customizer components to load. + * + * This allows Core components to be excluded from being instantiated by + * filtering them out of the array. Note that this filter generally runs + * during the {@see 'plugins_loaded'} action, so it cannot be added + * in a theme. + * + * @since 4.4.0 + * + * @see WP_Customize_Manager::__construct() + * + * @param array $components List of core components to load. + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + $components = apply_filters( 'customize_loaded_components', $this->components, $this ); + + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-selective-refresh.php' ); + $this->selective_refresh = new WP_Customize_Selective_Refresh( $this ); + + if ( in_array( 'widgets', $components, true ) ) { + require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' ); + $this->widgets = new WP_Customize_Widgets( $this ); + } + + if ( in_array( 'nav_menus', $components, true ) ) { + require_once( ABSPATH . WPINC . '/class-wp-customize-nav-menus.php' ); + $this->nav_menus = new WP_Customize_Nav_Menus( $this ); + } + + add_action( 'setup_theme', array( $this, 'setup_theme' ) ); + add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); + + // Do not spawn cron (especially the alternate cron) while running the Customizer. + remove_action( 'init', 'wp_cron' ); + + // Do not run update checks when rendering the controls. + remove_action( 'admin_init', '_maybe_update_core' ); + remove_action( 'admin_init', '_maybe_update_plugins' ); + remove_action( 'admin_init', '_maybe_update_themes' ); + + add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); + add_action( 'wp_ajax_customize_trash', array( $this, 'handle_changeset_trash_request' ) ); + add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); + add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) ); + add_filter( 'heartbeat_settings', array( $this, 'add_customize_screen_to_heartbeat_settings' ) ); + add_filter( 'heartbeat_received', array( $this, 'check_changeset_lock_with_heartbeat' ), 10, 3 ); + add_action( 'wp_ajax_customize_override_changeset_lock', array( $this, 'handle_override_changeset_lock_request' ) ); + add_action( 'wp_ajax_customize_dismiss_autosave_or_lock', array( $this, 'handle_dismiss_autosave_or_lock_request' ) ); + + add_action( 'customize_register', array( $this, 'register_controls' ) ); + add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first + add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) ); + + // Render Common, Panel, Section, and Control templates. + add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_panel_templates' ), 1 ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_section_templates' ), 1 ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_control_templates' ), 1 ); + + // Export header video settings with the partial response. + add_filter( 'customize_render_partials_response', array( $this, 'export_header_video_settings' ), 10, 3 ); + + // Export the settings to JS via the _wpCustomizeSettings variable. + add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_pane_settings' ), 1000 ); + + // Add theme update notices. + if ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) ) { + require_once ABSPATH . '/wp-admin/includes/update.php'; + add_action( 'customize_controls_print_footer_scripts', 'wp_print_admin_notice_templates' ); + } + } + + /** + * Return true if it's an Ajax request. + * + * @since 3.4.0 + * @since 4.2.0 Added `$action` param. + * + * @param string|null $action Whether the supplied Ajax action is being run. + * @return bool True if it's an Ajax request, false otherwise. + */ + public function doing_ajax( $action = null ) { + if ( ! wp_doing_ajax() ) { + return false; + } + + if ( ! $action ) { + return true; + } else { + /* + * Note: we can't just use doing_action( "wp_ajax_{$action}" ) because we need + * to check before admin-ajax.php gets to that point. + */ + return isset( $_REQUEST['action'] ) && wp_unslash( $_REQUEST['action'] ) === $action; + } + } + + /** + * Custom wp_die wrapper. Returns either the standard message for UI + * or the Ajax message. + * + * @since 3.4.0 + * + * @param mixed $ajax_message Ajax return + * @param mixed $message UI message + */ + protected function wp_die( $ajax_message, $message = null ) { + if ( $this->doing_ajax() ) { + wp_die( $ajax_message ); + } + + if ( ! $message ) { + $message = __( 'Something went wrong.' ); + } + + if ( $this->messenger_channel ) { + ob_start(); + wp_enqueue_scripts(); + wp_print_scripts( array( 'customize-base' ) ); + + $settings = array( + 'messengerArgs' => array( + 'channel' => $this->messenger_channel, + 'url' => wp_customize_url(), + ), + 'error' => $ajax_message, + ); + ?> + <script> + ( function( api, settings ) { + var preview = new api.Messenger( settings.messengerArgs ); + preview.send( 'iframe-loading-error', settings.error ); + } )( wp.customize, <?php echo wp_json_encode( $settings ) ?> ); + </script> + <?php + $message .= ob_get_clean(); + } + + wp_die( $message ); + } + + /** + * Return the Ajax wp_die() handler if it's a customized request. + * + * @since 3.4.0 + * @deprecated 4.7.0 + * + * @return callable Die handler. + */ + public function wp_die_handler() { + _deprecated_function( __METHOD__, '4.7.0' ); + + if ( $this->doing_ajax() || isset( $_POST['customized'] ) ) { + return '_ajax_wp_die_handler'; + } + + return '_default_wp_die_handler'; + } + + /** + * Start preview and customize theme. + * + * Check if customize query variable exist. Init filters to filter the current theme. + * + * @since 3.4.0 + * + * @global string $pagenow + */ + public function setup_theme() { + global $pagenow; + + // Check permissions for customize.php access since this method is called before customize.php can run any code, + if ( 'customize.php' === $pagenow && ! current_user_can( 'customize' ) ) { + if ( ! is_user_logged_in() ) { + auth_redirect(); + } else { + wp_die( + '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . + '<p>' . __( 'Sorry, you are not allowed to customize this site.' ) . '</p>', + 403 + ); + } + return; + } + + // If a changeset was provided is invalid. + if ( isset( $this->_changeset_uuid ) && false !== $this->_changeset_uuid && ! wp_is_uuid( $this->_changeset_uuid ) ) { + $this->wp_die( -1, __( 'Invalid changeset UUID' ) ); + } + + /* + * Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer + * application will inject the customize_preview_nonce query parameter into all Ajax requests. + * For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out + * a user when a valid nonce isn't present. + */ + $has_post_data_nonce = ( + check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false ) + || + check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false ) + || + check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false ) + ); + if ( ! current_user_can( 'customize' ) || ! $has_post_data_nonce ) { + unset( $_POST['customized'] ); + unset( $_REQUEST['customized'] ); + } + + /* + * If unauthenticated then require a valid changeset UUID to load the preview. + * In this way, the UUID serves as a secret key. If the messenger channel is present, + * then send unauthenticated code to prompt re-auth. + */ + if ( ! current_user_can( 'customize' ) && ! $this->changeset_post_id() ) { + $this->wp_die( $this->messenger_channel ? 0 : -1, __( 'Non-existent changeset UUID.' ) ); + } + + if ( ! headers_sent() ) { + send_origin_headers(); + } + + // Hide the admin bar if we're embedded in the customizer iframe. + if ( $this->messenger_channel ) { + show_admin_bar( false ); + } + + if ( $this->is_theme_active() ) { + // Once the theme is loaded, we'll validate it. + add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); + } else { + // If the requested theme is not the active theme and the user doesn't have the + // switch_themes cap, bail. + if ( ! current_user_can( 'switch_themes' ) ) { + $this->wp_die( -1, __( 'Sorry, you are not allowed to edit theme options on this site.' ) ); + } + + // If the theme has errors while loading, bail. + if ( $this->theme()->errors() ) { + $this->wp_die( -1, $this->theme()->errors()->get_error_message() ); + } + + // If the theme isn't allowed per multisite settings, bail. + if ( ! $this->theme()->is_allowed() ) { + $this->wp_die( -1, __( 'The requested theme does not exist.' ) ); + } + } + + // Make sure changeset UUID is established immediately after the theme is loaded. + add_action( 'after_setup_theme', array( $this, 'establish_loaded_changeset' ), 5 ); + + /* + * Import theme starter content for fresh installations when landing in the customizer. + * Import starter content at after_setup_theme:100 so that any + * add_theme_support( 'starter-content' ) calls will have been made. + */ + if ( get_option( 'fresh_site' ) && 'customize.php' === $pagenow ) { + add_action( 'after_setup_theme', array( $this, 'import_theme_starter_content' ), 100 ); + } + + $this->start_previewing_theme(); + } + + /** + * Establish the loaded changeset. + * + * This method runs right at after_setup_theme and applies the 'customize_changeset_branching' filter to determine + * whether concurrent changesets are allowed. Then if the Customizer is not initialized with a `changeset_uuid` param, + * this method will determine which UUID should be used. If changeset branching is disabled, then the most saved + * changeset will be loaded by default. Otherwise, if there are no existing saved changesets or if changeset branching is + * enabled, then a new UUID will be generated. + * + * @since 4.9.0 + * @global string $pagenow + */ + public function establish_loaded_changeset() { + global $pagenow; + + if ( empty( $this->_changeset_uuid ) ) { + $changeset_uuid = null; + + if ( ! $this->branching() && $this->is_theme_active() ) { + $unpublished_changeset_posts = $this->get_changeset_posts( array( + 'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ), + 'exclude_restore_dismissed' => false, + 'author' => 'any', + 'posts_per_page' => 1, + 'order' => 'DESC', + 'orderby' => 'date', + ) ); + $unpublished_changeset_post = array_shift( $unpublished_changeset_posts ); + if ( ! empty( $unpublished_changeset_post ) && wp_is_uuid( $unpublished_changeset_post->post_name ) ) { + $changeset_uuid = $unpublished_changeset_post->post_name; + } + } + + // If no changeset UUID has been set yet, then generate a new one. + if ( empty( $changeset_uuid ) ) { + $changeset_uuid = wp_generate_uuid4(); + } + + $this->_changeset_uuid = $changeset_uuid; + } + + if ( is_admin() && 'customize.php' === $pagenow ) { + $this->set_changeset_lock( $this->changeset_post_id() ); + } + } + + /** + * Callback to validate a theme once it is loaded + * + * @since 3.4.0 + */ + public function after_setup_theme() { + $doing_ajax_or_is_customized = ( $this->doing_ajax() || isset( $_POST['customized'] ) ); + if ( ! $doing_ajax_or_is_customized && ! validate_current_theme() ) { + wp_redirect( 'themes.php?broken=true' ); + exit; + } + } + + /** + * If the theme to be previewed isn't the active theme, add filter callbacks + * to swap it out at runtime. + * + * @since 3.4.0 + */ + public function start_previewing_theme() { + // Bail if we're already previewing. + if ( $this->is_preview() ) { + return; + } + + $this->previewing = true; + + if ( ! $this->is_theme_active() ) { + add_filter( 'template', array( $this, 'get_template' ) ); + add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); + add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); + + // @link: https://core.trac.wordpress.org/ticket/20027 + add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); + add_filter( 'pre_option_template', array( $this, 'get_template' ) ); + + // Handle custom theme roots. + add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); + add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); + } + + /** + * Fires once the Customizer theme preview has started. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'start_previewing_theme', $this ); + } + + /** + * Stop previewing the selected theme. + * + * Removes filters to change the current theme. + * + * @since 3.4.0 + */ + public function stop_previewing_theme() { + if ( ! $this->is_preview() ) { + return; + } + + $this->previewing = false; + + if ( ! $this->is_theme_active() ) { + remove_filter( 'template', array( $this, 'get_template' ) ); + remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); + remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); + + // @link: https://core.trac.wordpress.org/ticket/20027 + remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); + remove_filter( 'pre_option_template', array( $this, 'get_template' ) ); + + // Handle custom theme roots. + remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); + remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); + } + + /** + * Fires once the Customizer theme preview has stopped. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'stop_previewing_theme', $this ); + } + + /** + * Gets whether settings are or will be previewed. + * + * @since 4.9.0 + * @see WP_Customize_Setting::preview() + * + * @return bool + */ + public function settings_previewed() { + return $this->settings_previewed; + } + + /** + * Gets whether data from a changeset's autosaved revision should be loaded if it exists. + * + * @since 4.9.0 + * @see WP_Customize_Manager::changeset_data() + * + * @return bool Is using autosaved changeset revision. + */ + public function autosaved() { + return $this->autosaved; + } + + /** + * Whether the changeset branching is allowed. + * + * @since 4.9.0 + * @see WP_Customize_Manager::establish_loaded_changeset() + * + * @return bool Is changeset branching. + */ + public function branching() { + + /** + * Filters whether or not changeset branching is allowed. + * + * By default in core, when changeset branching is not allowed, changesets will operate + * linearly in that only one saved changeset will exist at a time (with a 'draft' or + * 'future' status). This makes the Customizer operate in a way that is similar to going to + * "edit" to one existing post: all users will be making changes to the same post, and autosave + * revisions will be made for that post. + * + * By contrast, when changeset branching is allowed, then the model is like users going + * to "add new" for a page and each user makes changes independently of each other since + * they are all operating on their own separate pages, each getting their own separate + * initial auto-drafts and then once initially saved, autosave revisions on top of that + * user's specific post. + * + * Since linear changesets are deemed to be more suitable for the majority of WordPress users, + * they are the default. For WordPress sites that have heavy site management in the Customizer + * by multiple users then branching changesets should be enabled by means of this filter. + * + * @since 4.9.0 + * + * @param bool $allow_branching Whether branching is allowed. If `false`, the default, + * then only one saved changeset exists at a time. + * @param WP_Customize_Manager $wp_customize Manager instance. + */ + $this->branching = apply_filters( 'customize_changeset_branching', $this->branching, $this ); + + return $this->branching; + } + + /** + * Get the changeset UUID. + * + * @since 4.7.0 + * @see WP_Customize_Manager::establish_loaded_changeset() + * + * @return string UUID. + */ + public function changeset_uuid() { + if ( empty( $this->_changeset_uuid ) ) { + $this->establish_loaded_changeset(); + } + return $this->_changeset_uuid; + } + + /** + * Get the theme being customized. + * + * @since 3.4.0 + * + * @return WP_Theme + */ + public function theme() { + if ( ! $this->theme ) { + $this->theme = wp_get_theme(); + } + return $this->theme; + } + + /** + * Get the registered settings. + * + * @since 3.4.0 + * + * @return array + */ + public function settings() { + return $this->settings; + } + + /** + * Get the registered controls. + * + * @since 3.4.0 + * + * @return array + */ + public function controls() { + return $this->controls; + } + + /** + * Get the registered containers. + * + * @since 4.0.0 + * + * @return array + */ + public function containers() { + return $this->containers; + } + + /** + * Get the registered sections. + * + * @since 3.4.0 + * + * @return array + */ + public function sections() { + return $this->sections; + } + + /** + * Get the registered panels. + * + * @since 4.0.0 + * + * @return array Panels. + */ + public function panels() { + return $this->panels; + } + + /** + * Checks if the current theme is active. + * + * @since 3.4.0 + * + * @return bool + */ + public function is_theme_active() { + return $this->get_stylesheet() == $this->original_stylesheet; + } + + /** + * Register styles/scripts and initialize the preview of each setting + * + * @since 3.4.0 + */ + public function wp_loaded() { + + // Unconditionally register core types for panels, sections, and controls in case plugin unhooks all customize_register actions. + $this->register_panel_type( 'WP_Customize_Panel' ); + $this->register_panel_type( 'WP_Customize_Themes_Panel' ); + $this->register_section_type( 'WP_Customize_Section' ); + $this->register_section_type( 'WP_Customize_Sidebar_Section' ); + $this->register_section_type( 'WP_Customize_Themes_Section' ); + $this->register_control_type( 'WP_Customize_Color_Control' ); + $this->register_control_type( 'WP_Customize_Media_Control' ); + $this->register_control_type( 'WP_Customize_Upload_Control' ); + $this->register_control_type( 'WP_Customize_Image_Control' ); + $this->register_control_type( 'WP_Customize_Background_Image_Control' ); + $this->register_control_type( 'WP_Customize_Background_Position_Control' ); + $this->register_control_type( 'WP_Customize_Cropped_Image_Control' ); + $this->register_control_type( 'WP_Customize_Site_Icon_Control' ); + $this->register_control_type( 'WP_Customize_Theme_Control' ); + $this->register_control_type( 'WP_Customize_Code_Editor_Control' ); + $this->register_control_type( 'WP_Customize_Date_Time_Control' ); + + /** + * Fires once WordPress has loaded, allowing scripts and styles to be initialized. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'customize_register', $this ); + + if ( $this->settings_previewed() ) { + foreach ( $this->settings as $setting ) { + $setting->preview(); + } + } + + if ( $this->is_preview() && ! is_admin() ) { + $this->customize_preview_init(); + } + } + + /** + * Prevents Ajax requests from following redirects when previewing a theme + * by issuing a 200 response instead of a 30x. + * + * Instead, the JS will sniff out the location header. + * + * @since 3.4.0 + * @deprecated 4.7.0 + * + * @param int $status Status. + * @return int + */ + public function wp_redirect_status( $status ) { + _deprecated_function( __FUNCTION__, '4.7.0' ); + + if ( $this->is_preview() && ! is_admin() ) { + return 200; + } + + return $status; + } + + /** + * Find the changeset post ID for a given changeset UUID. + * + * @since 4.7.0 + * + * @param string $uuid Changeset UUID. + * @return int|null Returns post ID on success and null on failure. + */ + public function find_changeset_post_id( $uuid ) { + $cache_group = 'customize_changeset_post'; + $changeset_post_id = wp_cache_get( $uuid, $cache_group ); + if ( $changeset_post_id && 'customize_changeset' === get_post_type( $changeset_post_id ) ) { + return $changeset_post_id; + } + + $changeset_post_query = new WP_Query( array( + 'post_type' => 'customize_changeset', + 'post_status' => get_post_stati(), + 'name' => $uuid, + 'posts_per_page' => 1, + 'no_found_rows' => true, + 'cache_results' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'lazy_load_term_meta' => false, + ) ); + if ( ! empty( $changeset_post_query->posts ) ) { + // Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed. + $changeset_post_id = $changeset_post_query->posts[0]->ID; + wp_cache_set( $uuid, $changeset_post_id, $cache_group ); + return $changeset_post_id; + } + + return null; + } + + /** + * Get changeset posts. + * + * @since 4.9.0 + * + * @param array $args { + * Args to pass into `get_posts()` to query changesets. + * + * @type int $posts_per_page Number of posts to return. Defaults to -1 (all posts). + * @type int $author Post author. Defaults to current user. + * @type string $post_status Status of changeset. Defaults to 'auto-draft'. + * @type bool $exclude_restore_dismissed Whether to exclude changeset auto-drafts that have been dismissed. Defaults to true. + * } + * @return WP_Post[] Auto-draft changesets. + */ + protected function get_changeset_posts( $args = array() ) { + $default_args = array( + 'exclude_restore_dismissed' => true, + 'posts_per_page' => -1, + 'post_type' => 'customize_changeset', + 'post_status' => 'auto-draft', + 'order' => 'DESC', + 'orderby' => 'date', + 'no_found_rows' => true, + 'cache_results' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'lazy_load_term_meta' => false, + ); + if ( get_current_user_id() ) { + $default_args['author'] = get_current_user_id(); + } + $args = array_merge( $default_args, $args ); + + if ( ! empty( $args['exclude_restore_dismissed'] ) ) { + unset( $args['exclude_restore_dismissed'] ); + $args['meta_query'] = array( + array( + 'key' => '_customize_restore_dismissed', + 'compare' => 'NOT EXISTS', + ), + ); + } + + return get_posts( $args ); + } + + /** + * Dismiss all of the current user's auto-drafts (other than the present one). + * + * @since 4.9.0 + * @return int The number of auto-drafts that were dismissed. + */ + protected function dismiss_user_auto_draft_changesets() { + $changeset_autodraft_posts = $this->get_changeset_posts( array( + 'post_status' => 'auto-draft', + 'exclude_restore_dismissed' => true, + 'posts_per_page' => -1, + ) ); + $dismissed = 0; + foreach ( $changeset_autodraft_posts as $autosave_autodraft_post ) { + if ( $autosave_autodraft_post->ID === $this->changeset_post_id() ) { + continue; + } + if ( update_post_meta( $autosave_autodraft_post->ID, '_customize_restore_dismissed', true ) ) { + $dismissed++; + } + } + return $dismissed; + } + + /** + * Get the changeset post id for the loaded changeset. + * + * @since 4.7.0 + * + * @return int|null Post ID on success or null if there is no post yet saved. + */ + public function changeset_post_id() { + if ( ! isset( $this->_changeset_post_id ) ) { + $post_id = $this->find_changeset_post_id( $this->changeset_uuid() ); + if ( ! $post_id ) { + $post_id = false; + } + $this->_changeset_post_id = $post_id; + } + if ( false === $this->_changeset_post_id ) { + return null; + } + return $this->_changeset_post_id; + } + + /** + * Get the data stored in a changeset post. + * + * @since 4.7.0 + * + * @param int $post_id Changeset post ID. + * @return array|WP_Error Changeset data or WP_Error on error. + */ + protected function get_changeset_post_data( $post_id ) { + if ( ! $post_id ) { + return new WP_Error( 'empty_post_id' ); + } + $changeset_post = get_post( $post_id ); + if ( ! $changeset_post ) { + return new WP_Error( 'missing_post' ); + } + if ( 'revision' === $changeset_post->post_type ) { + if ( 'customize_changeset' !== get_post_type( $changeset_post->post_parent ) ) { + return new WP_Error( 'wrong_post_type' ); + } + } elseif ( 'customize_changeset' !== $changeset_post->post_type ) { + return new WP_Error( 'wrong_post_type' ); + } + $changeset_data = json_decode( $changeset_post->post_content, true ); + if ( function_exists( 'json_last_error' ) && json_last_error() ) { + return new WP_Error( 'json_parse_error', '', json_last_error() ); + } + if ( ! is_array( $changeset_data ) ) { + return new WP_Error( 'expected_array' ); + } + return $changeset_data; + } + + /** + * Get changeset data. + * + * @since 4.7.0 + * @since 4.9.0 This will return the changeset's data with a user's autosave revision merged on top, if one exists and $autosaved is true. + * + * @return array Changeset data. + */ + public function changeset_data() { + if ( isset( $this->_changeset_data ) ) { + return $this->_changeset_data; + } + $changeset_post_id = $this->changeset_post_id(); + if ( ! $changeset_post_id ) { + $this->_changeset_data = array(); + } else { + if ( $this->autosaved() && is_user_logged_in() ) { + $autosave_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() ); + if ( $autosave_post ) { + $data = $this->get_changeset_post_data( $autosave_post->ID ); + if ( ! is_wp_error( $data ) ) { + $this->_changeset_data = $data; + } + } + } + + // Load data from the changeset if it was not loaded from an autosave. + if ( ! isset( $this->_changeset_data ) ) { + $data = $this->get_changeset_post_data( $changeset_post_id ); + if ( ! is_wp_error( $data ) ) { + $this->_changeset_data = $data; + } else { + $this->_changeset_data = array(); + } + } + } + return $this->_changeset_data; + } + + /** + * Starter content setting IDs. + * + * @since 4.7.0 + * @var array + */ + protected $pending_starter_content_settings_ids = array(); + + /** + * Import theme starter content into the customized state. + * + * @since 4.7.0 + * + * @param array $starter_content Starter content. Defaults to `get_theme_starter_content()`. + */ + function import_theme_starter_content( $starter_content = array() ) { + if ( empty( $starter_content ) ) { + $starter_content = get_theme_starter_content(); + } + + $changeset_data = array(); + if ( $this->changeset_post_id() ) { + /* + * Don't re-import starter content into a changeset saved persistently. + * This will need to be revisited in the future once theme switching + * is allowed with drafted/scheduled changesets, since switching to + * another theme could result in more starter content being applied. + * However, when doing an explicit save it is currently possible for + * nav menus and nav menu items specifically to lose their starter_content + * flags, thus resulting in duplicates being created since they fail + * to get re-used. See #40146. + */ + if ( 'auto-draft' !== get_post_status( $this->changeset_post_id() ) ) { + return; + } + + $changeset_data = $this->get_changeset_post_data( $this->changeset_post_id() ); + } + + $sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array(); + $attachments = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array(); + $posts = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array(); + $options = isset( $starter_content['options'] ) ? $starter_content['options'] : array(); + $nav_menus = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array(); + $theme_mods = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array(); + + // Widgets. + $max_widget_numbers = array(); + foreach ( $sidebars_widgets as $sidebar_id => $widgets ) { + $sidebar_widget_ids = array(); + foreach ( $widgets as $widget ) { + list( $id_base, $instance ) = $widget; + + if ( ! isset( $max_widget_numbers[ $id_base ] ) ) { + + // When $settings is an array-like object, get an intrinsic array for use with array_keys(). + $settings = get_option( "widget_{$id_base}", array() ); + if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) { + $settings = $settings->getArrayCopy(); + } + + // Find the max widget number for this type. + $widget_numbers = array_keys( $settings ); + if ( count( $widget_numbers ) > 0 ) { + $widget_numbers[] = 1; + $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers ); + } else { + $max_widget_numbers[ $id_base ] = 1; + } + } + $max_widget_numbers[ $id_base ] += 1; + + $widget_id = sprintf( '%s-%d', $id_base, $max_widget_numbers[ $id_base ] ); + $setting_id = sprintf( 'widget_%s[%d]', $id_base, $max_widget_numbers[ $id_base ] ); + + $setting_value = $this->widgets->sanitize_widget_js_instance( $instance ); + if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { + $this->set_post_value( $setting_id, $setting_value ); + $this->pending_starter_content_settings_ids[] = $setting_id; + } + $sidebar_widget_ids[] = $widget_id; + } + + $setting_id = sprintf( 'sidebars_widgets[%s]', $sidebar_id ); + if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { + $this->set_post_value( $setting_id, $sidebar_widget_ids ); + $this->pending_starter_content_settings_ids[] = $setting_id; + } + } + + $starter_content_auto_draft_post_ids = array(); + if ( ! empty( $changeset_data['nav_menus_created_posts']['value'] ) ) { + $starter_content_auto_draft_post_ids = array_merge( $starter_content_auto_draft_post_ids, $changeset_data['nav_menus_created_posts']['value'] ); + } + + // Make an index of all the posts needed and what their slugs are. + $needed_posts = array(); + $attachments = $this->prepare_starter_content_attachments( $attachments ); + foreach ( $attachments as $attachment ) { + $key = 'attachment:' . $attachment['post_name']; + $needed_posts[ $key ] = true; + } + foreach ( array_keys( $posts ) as $post_symbol ) { + if ( empty( $posts[ $post_symbol ]['post_name'] ) && empty( $posts[ $post_symbol ]['post_title'] ) ) { + unset( $posts[ $post_symbol ] ); + continue; + } + if ( empty( $posts[ $post_symbol ]['post_name'] ) ) { + $posts[ $post_symbol ]['post_name'] = sanitize_title( $posts[ $post_symbol ]['post_title'] ); + } + if ( empty( $posts[ $post_symbol ]['post_type'] ) ) { + $posts[ $post_symbol ]['post_type'] = 'post'; + } + $needed_posts[ $posts[ $post_symbol ]['post_type'] . ':' . $posts[ $post_symbol ]['post_name'] ] = true; + } + $all_post_slugs = array_merge( + wp_list_pluck( $attachments, 'post_name' ), + wp_list_pluck( $posts, 'post_name' ) + ); + + /* + * Obtain all post types referenced in starter content to use in query. + * This is needed because 'any' will not account for post types not yet registered. + */ + $post_types = array_filter( array_merge( array( 'attachment' ), wp_list_pluck( $posts, 'post_type' ) ) ); + + // Re-use auto-draft starter content posts referenced in the current customized state. + $existing_starter_content_posts = array(); + if ( ! empty( $starter_content_auto_draft_post_ids ) ) { + $existing_posts_query = new WP_Query( array( + 'post__in' => $starter_content_auto_draft_post_ids, + 'post_status' => 'auto-draft', + 'post_type' => $post_types, + 'posts_per_page' => -1, + ) ); + foreach ( $existing_posts_query->posts as $existing_post ) { + $post_name = $existing_post->post_name; + if ( empty( $post_name ) ) { + $post_name = get_post_meta( $existing_post->ID, '_customize_draft_post_name', true ); + } + $existing_starter_content_posts[ $existing_post->post_type . ':' . $post_name ] = $existing_post; + } + } + + // Re-use non-auto-draft posts. + if ( ! empty( $all_post_slugs ) ) { + $existing_posts_query = new WP_Query( array( + 'post_name__in' => $all_post_slugs, + 'post_status' => array_diff( get_post_stati(), array( 'auto-draft' ) ), + 'post_type' => 'any', + 'posts_per_page' => -1, + ) ); + foreach ( $existing_posts_query->posts as $existing_post ) { + $key = $existing_post->post_type . ':' . $existing_post->post_name; + if ( isset( $needed_posts[ $key ] ) && ! isset( $existing_starter_content_posts[ $key ] ) ) { + $existing_starter_content_posts[ $key ] = $existing_post; + } + } + } + + // Attachments are technically posts but handled differently. + if ( ! empty( $attachments ) ) { + + $attachment_ids = array(); + + foreach ( $attachments as $symbol => $attachment ) { + $file_array = array( + 'name' => $attachment['file_name'], + ); + $file_path = $attachment['file_path']; + $attachment_id = null; + $attached_file = null; + if ( isset( $existing_starter_content_posts[ 'attachment:' . $attachment['post_name'] ] ) ) { + $attachment_post = $existing_starter_content_posts[ 'attachment:' . $attachment['post_name'] ]; + $attachment_id = $attachment_post->ID; + $attached_file = get_attached_file( $attachment_id ); + if ( empty( $attached_file ) || ! file_exists( $attached_file ) ) { + $attachment_id = null; + $attached_file = null; + } elseif ( $this->get_stylesheet() !== get_post_meta( $attachment_post->ID, '_starter_content_theme', true ) ) { + + // Re-generate attachment metadata since it was previously generated for a different theme. + $metadata = wp_generate_attachment_metadata( $attachment_post->ID, $attached_file ); + wp_update_attachment_metadata( $attachment_id, $metadata ); + update_post_meta( $attachment_id, '_starter_content_theme', $this->get_stylesheet() ); + } + } + + // Insert the attachment auto-draft because it doesn't yet exist or the attached file is gone. + if ( ! $attachment_id ) { + + // Copy file to temp location so that original file won't get deleted from theme after sideloading. + $temp_file_name = wp_tempnam( basename( $file_path ) ); + if ( $temp_file_name && copy( $file_path, $temp_file_name ) ) { + $file_array['tmp_name'] = $temp_file_name; + } + if ( empty( $file_array['tmp_name'] ) ) { + continue; + } + + $attachment_post_data = array_merge( + wp_array_slice_assoc( $attachment, array( 'post_title', 'post_content', 'post_excerpt' ) ), + array( + 'post_status' => 'auto-draft', // So attachment will be garbage collected in a week if changeset is never published. + ) + ); + + // In PHP < 5.6 filesize() returns 0 for the temp files unless we clear the file status cache. + // Technically, PHP < 5.6.0 || < 5.5.13 || < 5.4.29 but no need to be so targeted. + // See https://bugs.php.net/bug.php?id=65701 + if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { + clearstatcache(); + } + + $attachment_id = media_handle_sideload( $file_array, 0, null, $attachment_post_data ); + if ( is_wp_error( $attachment_id ) ) { + continue; + } + update_post_meta( $attachment_id, '_starter_content_theme', $this->get_stylesheet() ); + update_post_meta( $attachment_id, '_customize_draft_post_name', $attachment['post_name'] ); + } + + $attachment_ids[ $symbol ] = $attachment_id; + } + $starter_content_auto_draft_post_ids = array_merge( $starter_content_auto_draft_post_ids, array_values( $attachment_ids ) ); + } + + // Posts & pages. + if ( ! empty( $posts ) ) { + foreach ( array_keys( $posts ) as $post_symbol ) { + if ( empty( $posts[ $post_symbol ]['post_type'] ) || empty( $posts[ $post_symbol ]['post_name'] ) ) { + continue; + } + $post_type = $posts[ $post_symbol ]['post_type']; + if ( ! empty( $posts[ $post_symbol ]['post_name'] ) ) { + $post_name = $posts[ $post_symbol ]['post_name']; + } elseif ( ! empty( $posts[ $post_symbol ]['post_title'] ) ) { + $post_name = sanitize_title( $posts[ $post_symbol ]['post_title'] ); + } else { + continue; + } + + // Use existing auto-draft post if one already exists with the same type and name. + if ( isset( $existing_starter_content_posts[ $post_type . ':' . $post_name ] ) ) { + $posts[ $post_symbol ]['ID'] = $existing_starter_content_posts[ $post_type . ':' . $post_name ]->ID; + continue; + } + + // Translate the featured image symbol. + if ( ! empty( $posts[ $post_symbol ]['thumbnail'] ) + && preg_match( '/^{{(?P<symbol>.+)}}$/', $posts[ $post_symbol ]['thumbnail'], $matches ) + && isset( $attachment_ids[ $matches['symbol'] ] ) ) { + $posts[ $post_symbol ]['meta_input']['_thumbnail_id'] = $attachment_ids[ $matches['symbol'] ]; + } + + if ( ! empty( $posts[ $post_symbol ]['template'] ) ) { + $posts[ $post_symbol ]['meta_input']['_wp_page_template'] = $posts[ $post_symbol ]['template']; + } + + $r = $this->nav_menus->insert_auto_draft_post( $posts[ $post_symbol ] ); + if ( $r instanceof WP_Post ) { + $posts[ $post_symbol ]['ID'] = $r->ID; + } + } + + $starter_content_auto_draft_post_ids = array_merge( $starter_content_auto_draft_post_ids, wp_list_pluck( $posts, 'ID' ) ); + } + + // The nav_menus_created_posts setting is why nav_menus component is dependency for adding posts. + if ( ! empty( $this->nav_menus ) && ! empty( $starter_content_auto_draft_post_ids ) ) { + $setting_id = 'nav_menus_created_posts'; + $this->set_post_value( $setting_id, array_unique( array_values( $starter_content_auto_draft_post_ids ) ) ); + $this->pending_starter_content_settings_ids[] = $setting_id; + } + + // Nav menus. + $placeholder_id = -1; + $reused_nav_menu_setting_ids = array(); + foreach ( $nav_menus as $nav_menu_location => $nav_menu ) { + + $nav_menu_term_id = null; + $nav_menu_setting_id = null; + $matches = array(); + + // Look for an existing placeholder menu with starter content to re-use. + foreach ( $changeset_data as $setting_id => $setting_params ) { + $can_reuse = ( + ! empty( $setting_params['starter_content'] ) + && + ! in_array( $setting_id, $reused_nav_menu_setting_ids, true ) + && + preg_match( '#^nav_menu\[(?P<nav_menu_id>-?\d+)\]$#', $setting_id, $matches ) + ); + if ( $can_reuse ) { + $nav_menu_term_id = intval( $matches['nav_menu_id'] ); + $nav_menu_setting_id = $setting_id; + $reused_nav_menu_setting_ids[] = $setting_id; + break; + } + } + + if ( ! $nav_menu_term_id ) { + while ( isset( $changeset_data[ sprintf( 'nav_menu[%d]', $placeholder_id ) ] ) ) { + $placeholder_id--; + } + $nav_menu_term_id = $placeholder_id; + $nav_menu_setting_id = sprintf( 'nav_menu[%d]', $placeholder_id ); + } + + $this->set_post_value( $nav_menu_setting_id, array( + 'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location, + ) ); + $this->pending_starter_content_settings_ids[] = $nav_menu_setting_id; + + // @todo Add support for menu_item_parent. + $position = 0; + foreach ( $nav_menu['items'] as $nav_menu_item ) { + $nav_menu_item_setting_id = sprintf( 'nav_menu_item[%d]', $placeholder_id-- ); + if ( ! isset( $nav_menu_item['position'] ) ) { + $nav_menu_item['position'] = $position++; + } + $nav_menu_item['nav_menu_term_id'] = $nav_menu_term_id; + + if ( isset( $nav_menu_item['object_id'] ) ) { + if ( 'post_type' === $nav_menu_item['type'] && preg_match( '/^{{(?P<symbol>.+)}}$/', $nav_menu_item['object_id'], $matches ) && isset( $posts[ $matches['symbol'] ] ) ) { + $nav_menu_item['object_id'] = $posts[ $matches['symbol'] ]['ID']; + if ( empty( $nav_menu_item['title'] ) ) { + $original_object = get_post( $nav_menu_item['object_id'] ); + $nav_menu_item['title'] = $original_object->post_title; + } + } else { + continue; + } + } else { + $nav_menu_item['object_id'] = 0; + } + + if ( empty( $changeset_data[ $nav_menu_item_setting_id ] ) || ! empty( $changeset_data[ $nav_menu_item_setting_id ]['starter_content'] ) ) { + $this->set_post_value( $nav_menu_item_setting_id, $nav_menu_item ); + $this->pending_starter_content_settings_ids[] = $nav_menu_item_setting_id; + } + } + + $setting_id = sprintf( 'nav_menu_locations[%s]', $nav_menu_location ); + if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { + $this->set_post_value( $setting_id, $nav_menu_term_id ); + $this->pending_starter_content_settings_ids[] = $setting_id; + } + } + + // Options. + foreach ( $options as $name => $value ) { + if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) ) { + if ( isset( $posts[ $matches['symbol'] ] ) ) { + $value = $posts[ $matches['symbol'] ]['ID']; + } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) { + $value = $attachment_ids[ $matches['symbol'] ]; + } else { + continue; + } + } + + if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) { + $this->set_post_value( $name, $value ); + $this->pending_starter_content_settings_ids[] = $name; + } + } + + // Theme mods. + foreach ( $theme_mods as $name => $value ) { + if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) ) { + if ( isset( $posts[ $matches['symbol'] ] ) ) { + $value = $posts[ $matches['symbol'] ]['ID']; + } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) { + $value = $attachment_ids[ $matches['symbol'] ]; + } else { + continue; + } + } + + // Handle header image as special case since setting has a legacy format. + if ( 'header_image' === $name ) { + $name = 'header_image_data'; + $metadata = wp_get_attachment_metadata( $value ); + if ( empty( $metadata ) ) { + continue; + } + $value = array( + 'attachment_id' => $value, + 'url' => wp_get_attachment_url( $value ), + 'height' => $metadata['height'], + 'width' => $metadata['width'], + ); + } elseif ( 'background_image' === $name ) { + $value = wp_get_attachment_url( $value ); + } + + if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) { + $this->set_post_value( $name, $value ); + $this->pending_starter_content_settings_ids[] = $name; + } + } + + if ( ! empty( $this->pending_starter_content_settings_ids ) ) { + if ( did_action( 'customize_register' ) ) { + $this->_save_starter_content_changeset(); + } else { + add_action( 'customize_register', array( $this, '_save_starter_content_changeset' ), 1000 ); + } + } + } + + /** + * Prepare starter content attachments. + * + * Ensure that the attachments are valid and that they have slugs and file name/path. + * + * @since 4.7.0 + * + * @param array $attachments Attachments. + * @return array Prepared attachments. + */ + protected function prepare_starter_content_attachments( $attachments ) { + $prepared_attachments = array(); + if ( empty( $attachments ) ) { + return $prepared_attachments; + } + + // Such is The WordPress Way. + require_once( ABSPATH . 'wp-admin/includes/file.php' ); + require_once( ABSPATH . 'wp-admin/includes/media.php' ); + require_once( ABSPATH . 'wp-admin/includes/image.php' ); + + foreach ( $attachments as $symbol => $attachment ) { + + // A file is required and URLs to files are not currently allowed. + if ( empty( $attachment['file'] ) || preg_match( '#^https?://$#', $attachment['file'] ) ) { + continue; + } + + $file_path = null; + if ( file_exists( $attachment['file'] ) ) { + $file_path = $attachment['file']; // Could be absolute path to file in plugin. + } elseif ( is_child_theme() && file_exists( get_stylesheet_directory() . '/' . $attachment['file'] ) ) { + $file_path = get_stylesheet_directory() . '/' . $attachment['file']; + } elseif ( file_exists( get_template_directory() . '/' . $attachment['file'] ) ) { + $file_path = get_template_directory() . '/' . $attachment['file']; + } else { + continue; + } + $file_name = basename( $attachment['file'] ); + + // Skip file types that are not recognized. + $checked_filetype = wp_check_filetype( $file_name ); + if ( empty( $checked_filetype['type'] ) ) { + continue; + } + + // Ensure post_name is set since not automatically derived from post_title for new auto-draft posts. + if ( empty( $attachment['post_name'] ) ) { + if ( ! empty( $attachment['post_title'] ) ) { + $attachment['post_name'] = sanitize_title( $attachment['post_title'] ); + } else { + $attachment['post_name'] = sanitize_title( preg_replace( '/\.\w+$/', '', $file_name ) ); + } + } + + $attachment['file_name'] = $file_name; + $attachment['file_path'] = $file_path; + $prepared_attachments[ $symbol ] = $attachment; + } + return $prepared_attachments; + } + + /** + * Save starter content changeset. + * + * @since 4.7.0 + */ + public function _save_starter_content_changeset() { + + if ( empty( $this->pending_starter_content_settings_ids ) ) { + return; + } + + $this->save_changeset_post( array( + 'data' => array_fill_keys( $this->pending_starter_content_settings_ids, array( 'starter_content' => true ) ), + 'starter_content' => true, + ) ); + $this->saved_starter_content_changeset = true; + + $this->pending_starter_content_settings_ids = array(); + } + + /** + * Get dirty pre-sanitized setting values in the current customized state. + * + * The returned array consists of a merge of three sources: + * 1. If the theme is not currently active, then the base array is any stashed + * theme mods that were modified previously but never published. + * 2. The values from the current changeset, if it exists. + * 3. If the user can customize, the values parsed from the incoming + * `$_POST['customized']` JSON data. + * 4. Any programmatically-set post values via `WP_Customize_Manager::set_post_value()`. + * + * The name "unsanitized_post_values" is a carry-over from when the customized + * state was exclusively sourced from `$_POST['customized']`. Nevertheless, + * the value returned will come from the current changeset post and from the + * incoming post data. + * + * @since 4.1.1 + * @since 4.7.0 Added $args param and merging with changeset values and stashed theme mods. + * + * @param array $args { + * Args. + * + * @type bool $exclude_changeset Whether the changeset values should also be excluded. Defaults to false. + * @type bool $exclude_post_data Whether the post input values should also be excluded. Defaults to false when lacking the customize capability. + * } + * @return array + */ + public function unsanitized_post_values( $args = array() ) { + $args = array_merge( + array( + 'exclude_changeset' => false, + 'exclude_post_data' => ! current_user_can( 'customize' ), + ), + $args + ); + + $values = array(); + + // Let default values be from the stashed theme mods if doing a theme switch and if no changeset is present. + if ( ! $this->is_theme_active() ) { + $stashed_theme_mods = get_option( 'customize_stashed_theme_mods' ); + $stylesheet = $this->get_stylesheet(); + if ( isset( $stashed_theme_mods[ $stylesheet ] ) ) { + $values = array_merge( $values, wp_list_pluck( $stashed_theme_mods[ $stylesheet ], 'value' ) ); + } + } + + if ( ! $args['exclude_changeset'] ) { + foreach ( $this->changeset_data() as $setting_id => $setting_params ) { + if ( ! array_key_exists( 'value', $setting_params ) ) { + continue; + } + if ( isset( $setting_params['type'] ) && 'theme_mod' === $setting_params['type'] ) { + + // Ensure that theme mods values are only used if they were saved under the current theme. + $namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/'; + if ( preg_match( $namespace_pattern, $setting_id, $matches ) && $this->get_stylesheet() === $matches['stylesheet'] ) { + $values[ $matches['setting_id'] ] = $setting_params['value']; + } + } else { + $values[ $setting_id ] = $setting_params['value']; + } + } + } + + if ( ! $args['exclude_post_data'] ) { + if ( ! isset( $this->_post_values ) ) { + if ( isset( $_POST['customized'] ) ) { + $post_values = json_decode( wp_unslash( $_POST['customized'] ), true ); + } else { + $post_values = array(); + } + if ( is_array( $post_values ) ) { + $this->_post_values = $post_values; + } else { + $this->_post_values = array(); + } + } + $values = array_merge( $values, $this->_post_values ); + } + return $values; + } + + /** + * Returns the sanitized value for a given setting from the current customized state. + * + * The name "post_value" is a carry-over from when the customized state was exclusively + * sourced from `$_POST['customized']`. Nevertheless, the value returned will come + * from the current changeset post and from the incoming post data. + * + * @since 3.4.0 + * @since 4.1.1 Introduced the `$default` parameter. + * @since 4.6.0 `$default` is now returned early when the setting post value is invalid. + * + * @see WP_REST_Server::dispatch() + * @see WP_REST_Request::sanitize_params() + * @see WP_REST_Request::has_valid_params() + * + * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object. + * @param mixed $default Value returned $setting has no post value (added in 4.2.0) + * or the post value is invalid (added in 4.6.0). + * @return string|mixed $post_value Sanitized value or the $default provided. + */ + public function post_value( $setting, $default = null ) { + $post_values = $this->unsanitized_post_values(); + if ( ! array_key_exists( $setting->id, $post_values ) ) { + return $default; + } + $value = $post_values[ $setting->id ]; + $valid = $setting->validate( $value ); + if ( is_wp_error( $valid ) ) { + return $default; + } + $value = $setting->sanitize( $value ); + if ( is_null( $value ) || is_wp_error( $value ) ) { + return $default; + } + return $value; + } + + /** + * Override a setting's value in the current customized state. + * + * The name "post_value" is a carry-over from when the customized state was + * exclusively sourced from `$_POST['customized']`. + * + * @since 4.2.0 + * + * @param string $setting_id ID for the WP_Customize_Setting instance. + * @param mixed $value Post value. + */ + public function set_post_value( $setting_id, $value ) { + $this->unsanitized_post_values(); // Populate _post_values from $_POST['customized']. + $this->_post_values[ $setting_id ] = $value; + + /** + * Announce when a specific setting's unsanitized post value has been set. + * + * Fires when the WP_Customize_Manager::set_post_value() method is called. + * + * The dynamic portion of the hook name, `$setting_id`, refers to the setting ID. + * + * @since 4.4.0 + * + * @param mixed $value Unsanitized setting post value. + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( "customize_post_value_set_{$setting_id}", $value, $this ); + + /** + * Announce when any setting's unsanitized post value has been set. + * + * Fires when the WP_Customize_Manager::set_post_value() method is called. + * + * This is useful for `WP_Customize_Setting` instances to watch + * in order to update a cached previewed value. + * + * @since 4.4.0 + * + * @param string $setting_id Setting ID. + * @param mixed $value Unsanitized setting post value. + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'customize_post_value_set', $setting_id, $value, $this ); + } + + /** + * Print JavaScript settings. + * + * @since 3.4.0 + */ + public function customize_preview_init() { + + /* + * Now that Customizer previews are loaded into iframes via GET requests + * and natural URLs with transaction UUIDs added, we need to ensure that + * the responses are never cached by proxies. In practice, this will not + * be needed if the user is logged-in anyway. But if anonymous access is + * allowed then the auth cookies would not be sent and WordPress would + * not send no-cache headers by default. + */ + if ( ! headers_sent() ) { + nocache_headers(); + header( 'X-Robots: noindex, nofollow, noarchive' ); + } + add_action( 'wp_head', 'wp_no_robots' ); + add_filter( 'wp_headers', array( $this, 'filter_iframe_security_headers' ) ); + + /* + * If preview is being served inside the customizer preview iframe, and + * if the user doesn't have customize capability, then it is assumed + * that the user's session has expired and they need to re-authenticate. + */ + if ( $this->messenger_channel && ! current_user_can( 'customize' ) ) { + $this->wp_die( -1, __( 'Unauthorized. You may remove the customize_messenger_channel param to preview as frontend.' ) ); + return; + } + + $this->prepare_controls(); + + add_filter( 'wp_redirect', array( $this, 'add_state_query_params' ) ); + + wp_enqueue_script( 'customize-preview' ); + wp_enqueue_style( 'customize-preview' ); + add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) ); + add_action( 'wp_head', array( $this, 'remove_frameless_preview_messenger_channel' ) ); + add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); + add_filter( 'get_edit_post_link', '__return_empty_string' ); + + /** + * Fires once the Customizer preview has initialized and JavaScript + * settings have been printed. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'customize_preview_init', $this ); + } + + /** + * Filter the X-Frame-Options and Content-Security-Policy headers to ensure frontend can load in customizer. + * + * @since 4.7.0 + * + * @param array $headers Headers. + * @return array Headers. + */ + public function filter_iframe_security_headers( $headers ) { + $customize_url = admin_url( 'customize.php' ); + $headers['X-Frame-Options'] = 'ALLOW-FROM ' . $customize_url; + $headers['Content-Security-Policy'] = 'frame-ancestors ' . preg_replace( '#^(\w+://[^/]+).+?$#', '$1', $customize_url ); + return $headers; + } + + /** + * Add customize state query params to a given URL if preview is allowed. + * + * @since 4.7.0 + * @see wp_redirect() + * @see WP_Customize_Manager::get_allowed_url() + * + * @param string $url URL. + * @return string URL. + */ + public function add_state_query_params( $url ) { + $parsed_original_url = wp_parse_url( $url ); + $is_allowed = false; + foreach ( $this->get_allowed_urls() as $allowed_url ) { + $parsed_allowed_url = wp_parse_url( $allowed_url ); + $is_allowed = ( + $parsed_allowed_url['scheme'] === $parsed_original_url['scheme'] + && + $parsed_allowed_url['host'] === $parsed_original_url['host'] + && + 0 === strpos( $parsed_original_url['path'], $parsed_allowed_url['path'] ) + ); + if ( $is_allowed ) { + break; + } + } + + if ( $is_allowed ) { + $query_params = array( + 'customize_changeset_uuid' => $this->changeset_uuid(), + ); + if ( ! $this->is_theme_active() ) { + $query_params['customize_theme'] = $this->get_stylesheet(); + } + if ( $this->messenger_channel ) { + $query_params['customize_messenger_channel'] = $this->messenger_channel; + } + $url = add_query_arg( $query_params, $url ); + } + + return $url; + } + + /** + * Prevent sending a 404 status when returning the response for the customize + * preview, since it causes the jQuery Ajax to fail. Send 200 instead. + * + * @since 4.0.0 + * @deprecated 4.7.0 + */ + public function customize_preview_override_404_status() { + _deprecated_function( __METHOD__, '4.7.0' ); + } + + /** + * Print base element for preview frame. + * + * @since 3.4.0 + * @deprecated 4.7.0 + */ + public function customize_preview_base() { + _deprecated_function( __METHOD__, '4.7.0' ); + } + + /** + * Print a workaround to handle HTML5 tags in IE < 9. + * + * @since 3.4.0 + * @deprecated 4.7.0 Customizer no longer supports IE8, so all supported browsers recognize HTML5. + */ + public function customize_preview_html5() { + _deprecated_function( __FUNCTION__, '4.7.0' ); + } + + /** + * Print CSS for loading indicators for the Customizer preview. + * + * @since 4.2.0 + */ + public function customize_preview_loading_style() { + ?><style> + body.wp-customizer-unloading { + opacity: 0.25; + cursor: progress !important; + -webkit-transition: opacity 0.5s; + transition: opacity 0.5s; + } + body.wp-customizer-unloading * { + pointer-events: none !important; + } + form.customize-unpreviewable, + form.customize-unpreviewable input, + form.customize-unpreviewable select, + form.customize-unpreviewable button, + a.customize-unpreviewable, + area.customize-unpreviewable { + cursor: not-allowed !important; + } + </style><?php + } + + /** + * Remove customize_messenger_channel query parameter from the preview window when it is not in an iframe. + * + * This ensures that the admin bar will be shown. It also ensures that link navigation will + * work as expected since the parent frame is not being sent the URL to navigate to. + * + * @since 4.7.0 + */ + public function remove_frameless_preview_messenger_channel() { + if ( ! $this->messenger_channel ) { + return; + } + ?> + <script> + ( function() { + var urlParser, oldQueryParams, newQueryParams, i; + if ( parent !== window ) { + return; + } + urlParser = document.createElement( 'a' ); + urlParser.href = location.href; + oldQueryParams = urlParser.search.substr( 1 ).split( /&/ ); + newQueryParams = []; + for ( i = 0; i < oldQueryParams.length; i += 1 ) { + if ( ! /^customize_messenger_channel=/.test( oldQueryParams[ i ] ) ) { + newQueryParams.push( oldQueryParams[ i ] ); + } + } + urlParser.search = newQueryParams.join( '&' ); + if ( urlParser.search !== location.search ) { + location.replace( urlParser.href ); + } + } )(); + </script> + <?php + } + + /** + * Print JavaScript settings for preview frame. + * + * @since 3.4.0 + */ + public function customize_preview_settings() { + $post_values = $this->unsanitized_post_values( array( 'exclude_changeset' => true ) ); + $setting_validities = $this->validate_setting_values( $post_values ); + $exported_setting_validities = array_map( array( $this, 'prepare_setting_validity_for_js' ), $setting_validities ); + + // Note that the REQUEST_URI is not passed into home_url() since this breaks subdirectory installations. + $self_url = empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ); + $state_query_params = array( + 'customize_theme', + 'customize_changeset_uuid', + 'customize_messenger_channel', + ); + $self_url = remove_query_arg( $state_query_params, $self_url ); + + $allowed_urls = $this->get_allowed_urls(); + $allowed_hosts = array(); + foreach ( $allowed_urls as $allowed_url ) { + $parsed = wp_parse_url( $allowed_url ); + if ( empty( $parsed['host'] ) ) { + continue; + } + $host = $parsed['host']; + if ( ! empty( $parsed['port'] ) ) { + $host .= ':' . $parsed['port']; + } + $allowed_hosts[] = $host; + } + + $switched_locale = switch_to_locale( get_user_locale() ); + $l10n = array( + 'shiftClickToEdit' => __( 'Shift-click to edit this element.' ), + 'linkUnpreviewable' => __( 'This link is not live-previewable.' ), + 'formUnpreviewable' => __( 'This form is not live-previewable.' ), + ); + if ( $switched_locale ) { + restore_previous_locale(); + } + + $settings = array( + 'changeset' => array( + 'uuid' => $this->changeset_uuid(), + 'autosaved' => $this->autosaved(), + ), + 'timeouts' => array( + 'selectiveRefresh' => 250, + 'keepAliveSend' => 1000, + ), + 'theme' => array( + 'stylesheet' => $this->get_stylesheet(), + 'active' => $this->is_theme_active(), + ), + 'url' => array( + 'self' => $self_url, + 'allowed' => array_map( 'esc_url_raw', $this->get_allowed_urls() ), + 'allowedHosts' => array_unique( $allowed_hosts ), + 'isCrossDomain' => $this->is_cross_domain(), + ), + 'channel' => $this->messenger_channel, + 'activePanels' => array(), + 'activeSections' => array(), + 'activeControls' => array(), + 'settingValidities' => $exported_setting_validities, + 'nonce' => current_user_can( 'customize' ) ? $this->get_nonces() : array(), + 'l10n' => $l10n, + '_dirty' => array_keys( $post_values ), + ); + + foreach ( $this->panels as $panel_id => $panel ) { + if ( $panel->check_capabilities() ) { + $settings['activePanels'][ $panel_id ] = $panel->active(); + foreach ( $panel->sections as $section_id => $section ) { + if ( $section->check_capabilities() ) { + $settings['activeSections'][ $section_id ] = $section->active(); + } + } + } + } + foreach ( $this->sections as $id => $section ) { + if ( $section->check_capabilities() ) { + $settings['activeSections'][ $id ] = $section->active(); + } + } + foreach ( $this->controls as $id => $control ) { + if ( $control->check_capabilities() ) { + $settings['activeControls'][ $id ] = $control->active(); + } + } + + ?> + <script type="text/javascript"> + var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>; + _wpCustomizeSettings.values = {}; + (function( v ) { + <?php + /* + * Serialize settings separately from the initial _wpCustomizeSettings + * serialization in order to avoid a peak memory usage spike. + * @todo We may not even need to export the values at all since the pane syncs them anyway. + */ + foreach ( $this->settings as $id => $setting ) { + if ( $setting->check_capabilities() ) { + printf( + "v[%s] = %s;\n", + wp_json_encode( $id ), + wp_json_encode( $setting->js_value() ) + ); + } + } + ?> + })( _wpCustomizeSettings.values ); + </script> + <?php + } + + /** + * Prints a signature so we can ensure the Customizer was properly executed. + * + * @since 3.4.0 + * @deprecated 4.7.0 + */ + public function customize_preview_signature() { + _deprecated_function( __METHOD__, '4.7.0' ); + } + + /** + * Removes the signature in case we experience a case where the Customizer was not properly executed. + * + * @since 3.4.0 + * @deprecated 4.7.0 + * + * @param mixed $return Value passed through for {@see 'wp_die_handler'} filter. + * @return mixed Value passed through for {@see 'wp_die_handler'} filter. + */ + public function remove_preview_signature( $return = null ) { + _deprecated_function( __METHOD__, '4.7.0' ); + + return $return; + } + + /** + * Is it a theme preview? + * + * @since 3.4.0 + * + * @return bool True if it's a preview, false if not. + */ + public function is_preview() { + return (bool) $this->previewing; + } + + /** + * Retrieve the template name of the previewed theme. + * + * @since 3.4.0 + * + * @return string Template name. + */ + public function get_template() { + return $this->theme()->get_template(); + } + + /** + * Retrieve the stylesheet name of the previewed theme. + * + * @since 3.4.0 + * + * @return string Stylesheet name. + */ + public function get_stylesheet() { + return $this->theme()->get_stylesheet(); + } + + /** + * Retrieve the template root of the previewed theme. + * + * @since 3.4.0 + * + * @return string Theme root. + */ + public function get_template_root() { + return get_raw_theme_root( $this->get_template(), true ); + } + + /** + * Retrieve the stylesheet root of the previewed theme. + * + * @since 3.4.0 + * + * @return string Theme root. + */ + public function get_stylesheet_root() { + return get_raw_theme_root( $this->get_stylesheet(), true ); + } + + /** + * Filters the current theme and return the name of the previewed theme. + * + * @since 3.4.0 + * + * @param $current_theme {@internal Parameter is not used} + * @return string Theme name. + */ + public function current_theme( $current_theme ) { + return $this->theme()->display('Name'); + } + + /** + * Validates setting values. + * + * Validation is skipped for unregistered settings or for values that are + * already null since they will be skipped anyway. Sanitization is applied + * to values that pass validation, and values that become null or `WP_Error` + * after sanitizing are marked invalid. + * + * @since 4.6.0 + * + * @see WP_REST_Request::has_valid_params() + * @see WP_Customize_Setting::validate() + * + * @param array $setting_values Mapping of setting IDs to values to validate and sanitize. + * @param array $options { + * Options. + * + * @type bool $validate_existence Whether a setting's existence will be checked. + * @type bool $validate_capability Whether the setting capability will be checked. + * } + * @return array Mapping of setting IDs to return value of validate method calls, either `true` or `WP_Error`. + */ + public function validate_setting_values( $setting_values, $options = array() ) { + $options = wp_parse_args( $options, array( + 'validate_capability' => false, + 'validate_existence' => false, + ) ); + + $validities = array(); + foreach ( $setting_values as $setting_id => $unsanitized_value ) { + $setting = $this->get_setting( $setting_id ); + if ( ! $setting ) { + if ( $options['validate_existence'] ) { + $validities[ $setting_id ] = new WP_Error( 'unrecognized', __( 'Setting does not exist or is unrecognized.' ) ); + } + continue; + } + if ( $options['validate_capability'] && ! current_user_can( $setting->capability ) ) { + $validity = new WP_Error( 'unauthorized', __( 'Unauthorized to modify setting due to capability.' ) ); + } else { + if ( is_null( $unsanitized_value ) ) { + continue; + } + $validity = $setting->validate( $unsanitized_value ); + } + if ( ! is_wp_error( $validity ) ) { + /** This filter is documented in wp-includes/class-wp-customize-setting.php */ + $late_validity = apply_filters( "customize_validate_{$setting->id}", new WP_Error(), $unsanitized_value, $setting ); + if ( ! empty( $late_validity->errors ) ) { + $validity = $late_validity; + } + } + if ( ! is_wp_error( $validity ) ) { + $value = $setting->sanitize( $unsanitized_value ); + if ( is_null( $value ) ) { + $validity = false; + } elseif ( is_wp_error( $value ) ) { + $validity = $value; + } + } + if ( false === $validity ) { + $validity = new WP_Error( 'invalid_value', __( 'Invalid value.' ) ); + } + $validities[ $setting_id ] = $validity; + } + return $validities; + } + + /** + * Prepares setting validity for exporting to the client (JS). + * + * Converts `WP_Error` instance into array suitable for passing into the + * `wp.customize.Notification` JS model. + * + * @since 4.6.0 + * + * @param true|WP_Error $validity Setting validity. + * @return true|array If `$validity` was a WP_Error, the error codes will be array-mapped + * to their respective `message` and `data` to pass into the + * `wp.customize.Notification` JS model. + */ + public function prepare_setting_validity_for_js( $validity ) { + if ( is_wp_error( $validity ) ) { + $notification = array(); + foreach ( $validity->errors as $error_code => $error_messages ) { + $notification[ $error_code ] = array( + 'message' => join( ' ', $error_messages ), + 'data' => $validity->get_error_data( $error_code ), + ); + } + return $notification; + } else { + return true; + } + } + + /** + * Handle customize_save WP Ajax request to save/update a changeset. + * + * @since 3.4.0 + * @since 4.7.0 The semantics of this method have changed to update a changeset, optionally to also change the status and other attributes. + */ + public function save() { + if ( ! is_user_logged_in() ) { + wp_send_json_error( 'unauthenticated' ); + } + + if ( ! $this->is_preview() ) { + wp_send_json_error( 'not_preview' ); + } + + $action = 'save-customize_' . $this->get_stylesheet(); + if ( ! check_ajax_referer( $action, 'nonce', false ) ) { + wp_send_json_error( 'invalid_nonce' ); + } + + $changeset_post_id = $this->changeset_post_id(); + $is_new_changeset = empty( $changeset_post_id ); + if ( $is_new_changeset ) { + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->create_posts ) ) { + wp_send_json_error( 'cannot_create_changeset_post' ); + } + } else { + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) { + wp_send_json_error( 'cannot_edit_changeset_post' ); + } + } + + if ( ! empty( $_POST['customize_changeset_data'] ) ) { + $input_changeset_data = json_decode( wp_unslash( $_POST['customize_changeset_data'] ), true ); + if ( ! is_array( $input_changeset_data ) ) { + wp_send_json_error( 'invalid_customize_changeset_data' ); + } + } else { + $input_changeset_data = array(); + } + + // Validate title. + $changeset_title = null; + if ( isset( $_POST['customize_changeset_title'] ) ) { + $changeset_title = sanitize_text_field( wp_unslash( $_POST['customize_changeset_title'] ) ); + } + + // Validate changeset status param. + $is_publish = null; + $changeset_status = null; + if ( isset( $_POST['customize_changeset_status'] ) ) { + $changeset_status = wp_unslash( $_POST['customize_changeset_status'] ); + if ( ! get_post_status_object( $changeset_status ) || ! in_array( $changeset_status, array( 'draft', 'pending', 'publish', 'future' ), true ) ) { + wp_send_json_error( 'bad_customize_changeset_status', 400 ); + } + $is_publish = ( 'publish' === $changeset_status || 'future' === $changeset_status ); + if ( $is_publish && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) { + wp_send_json_error( 'changeset_publish_unauthorized', 403 ); + } + } + + /* + * Validate changeset date param. Date is assumed to be in local time for + * the WP if in MySQL format (YYYY-MM-DD HH:MM:SS). Otherwise, the date + * is parsed with strtotime() so that ISO date format may be supplied + * or a string like "+10 minutes". + */ + $changeset_date_gmt = null; + if ( isset( $_POST['customize_changeset_date'] ) ) { + $changeset_date = wp_unslash( $_POST['customize_changeset_date'] ); + if ( preg_match( '/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/', $changeset_date ) ) { + $mm = substr( $changeset_date, 5, 2 ); + $jj = substr( $changeset_date, 8, 2 ); + $aa = substr( $changeset_date, 0, 4 ); + $valid_date = wp_checkdate( $mm, $jj, $aa, $changeset_date ); + if ( ! $valid_date ) { + wp_send_json_error( 'bad_customize_changeset_date', 400 ); + } + $changeset_date_gmt = get_gmt_from_date( $changeset_date ); + } else { + $timestamp = strtotime( $changeset_date ); + if ( ! $timestamp ) { + wp_send_json_error( 'bad_customize_changeset_date', 400 ); + } + $changeset_date_gmt = gmdate( 'Y-m-d H:i:s', $timestamp ); + } + } + + $lock_user_id = null; + $autosave = ! empty( $_POST['customize_changeset_autosave'] ); + if ( ! $is_new_changeset ) { + $lock_user_id = wp_check_post_lock( $this->changeset_post_id() ); + } + + // Force request to autosave when changeset is locked. + if ( $lock_user_id && ! $autosave ) { + $autosave = true; + $changeset_status = null; + $changeset_date_gmt = null; + } + + if ( $autosave && ! defined( 'DOING_AUTOSAVE' ) ) { // Back-compat. + define( 'DOING_AUTOSAVE', true ); + } + + $autosaved = false; + $r = $this->save_changeset_post( array( + 'status' => $changeset_status, + 'title' => $changeset_title, + 'date_gmt' => $changeset_date_gmt, + 'data' => $input_changeset_data, + 'autosave' => $autosave, + ) ); + if ( $autosave && ! is_wp_error( $r ) ) { + $autosaved = true; + } + + // If the changeset was locked and an autosave request wasn't itself an error, then now explicitly return with a failure. + if ( $lock_user_id && ! is_wp_error( $r ) ) { + $r = new WP_Error( + 'changeset_locked', + __( 'Changeset is being edited by other user.' ), + array( + 'lock_user' => $this->get_lock_user_data( $lock_user_id ), + ) + ); + } + + if ( is_wp_error( $r ) ) { + $response = array( + 'message' => $r->get_error_message(), + 'code' => $r->get_error_code(), + ); + if ( is_array( $r->get_error_data() ) ) { + $response = array_merge( $response, $r->get_error_data() ); + } else { + $response['data'] = $r->get_error_data(); + } + } else { + $response = $r; + $changeset_post = get_post( $this->changeset_post_id() ); + + // Dismiss all other auto-draft changeset posts for this user (they serve like autosave revisions), as there should only be one. + if ( $is_new_changeset ) { + $this->dismiss_user_auto_draft_changesets(); + } + + // Note that if the changeset status was publish, then it will get set to trash if revisions are not supported. + $response['changeset_status'] = $changeset_post->post_status; + if ( $is_publish && 'trash' === $response['changeset_status'] ) { + $response['changeset_status'] = 'publish'; + } + + if ( 'publish' !== $response['changeset_status'] ) { + $this->set_changeset_lock( $changeset_post->ID ); + } + + if ( 'future' === $response['changeset_status'] ) { + $response['changeset_date'] = $changeset_post->post_date; + } + + if ( 'publish' === $response['changeset_status'] || 'trash' === $response['changeset_status'] ) { + $response['next_changeset_uuid'] = wp_generate_uuid4(); + } + } + + if ( $autosave ) { + $response['autosaved'] = $autosaved; + } + + if ( isset( $response['setting_validities'] ) ) { + $response['setting_validities'] = array_map( array( $this, 'prepare_setting_validity_for_js' ), $response['setting_validities'] ); + } + + /** + * Filters response data for a successful customize_save Ajax request. + * + * This filter does not apply if there was a nonce or authentication failure. + * + * @since 4.2.0 + * + * @param array $response Additional information passed back to the 'saved' + * event on `wp.customize`. + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + $response = apply_filters( 'customize_save_response', $response, $this ); + + if ( is_wp_error( $r ) ) { + wp_send_json_error( $response ); + } else { + wp_send_json_success( $response ); + } + } + + /** + * Save the post for the loaded changeset. + * + * @since 4.7.0 + * + * @param array $args { + * Args for changeset post. + * + * @type array $data Optional additional changeset data. Values will be merged on top of any existing post values. + * @type string $status Post status. Optional. If supplied, the save will be transactional and a post revision will be allowed. + * @type string $title Post title. Optional. + * @type string $date_gmt Date in GMT. Optional. + * @type int $user_id ID for user who is saving the changeset. Optional, defaults to the current user ID. + * @type bool $starter_content Whether the data is starter content. If false (default), then $starter_content will be cleared for any $data being saved. + * @type bool $autosave Whether this is a request to create an autosave revision. + * } + * + * @return array|WP_Error Returns array on success and WP_Error with array data on error. + */ + function save_changeset_post( $args = array() ) { + + $args = array_merge( + array( + 'status' => null, + 'title' => null, + 'data' => array(), + 'date_gmt' => null, + 'user_id' => get_current_user_id(), + 'starter_content' => false, + 'autosave' => false, + ), + $args + ); + + $changeset_post_id = $this->changeset_post_id(); + $existing_changeset_data = array(); + if ( $changeset_post_id ) { + $existing_status = get_post_status( $changeset_post_id ); + if ( 'publish' === $existing_status || 'trash' === $existing_status ) { + return new WP_Error( + 'changeset_already_published', + __( 'The previous set of changes has already been published. Please try saving your current set of changes again.' ), + array( + 'next_changeset_uuid' => wp_generate_uuid4(), + ) + ); + } + + $existing_changeset_data = $this->get_changeset_post_data( $changeset_post_id ); + if ( is_wp_error( $existing_changeset_data ) ) { + return $existing_changeset_data; + } + } + + // Fail if attempting to publish but publish hook is missing. + if ( 'publish' === $args['status'] && false === has_action( 'transition_post_status', '_wp_customize_publish_changeset' ) ) { + return new WP_Error( 'missing_publish_callback' ); + } + + // Validate date. + $now = gmdate( 'Y-m-d H:i:59' ); + if ( $args['date_gmt'] ) { + $is_future_dated = ( mysql2date( 'U', $args['date_gmt'], false ) > mysql2date( 'U', $now, false ) ); + if ( ! $is_future_dated ) { + return new WP_Error( 'not_future_date', __( 'You must supply a future date to schedule.' ) ); // Only future dates are allowed. + } + + if ( ! $this->is_theme_active() && ( 'future' === $args['status'] || $is_future_dated ) ) { + return new WP_Error( 'cannot_schedule_theme_switches' ); // This should be allowed in the future, when theme is a regular setting. + } + $will_remain_auto_draft = ( ! $args['status'] && ( ! $changeset_post_id || 'auto-draft' === get_post_status( $changeset_post_id ) ) ); + if ( $will_remain_auto_draft ) { + return new WP_Error( 'cannot_supply_date_for_auto_draft_changeset' ); + } + } elseif ( $changeset_post_id && 'future' === $args['status'] ) { + + // Fail if the new status is future but the existing post's date is not in the future. + $changeset_post = get_post( $changeset_post_id ); + if ( mysql2date( 'U', $changeset_post->post_date_gmt, false ) <= mysql2date( 'U', $now, false ) ) { + return new WP_Error( 'not_future_date', __( 'You must supply a future date to schedule.' ) ); + } + } + + if ( ! empty( $is_future_dated ) && 'publish' === $args['status'] ) { + $args['status'] = 'future'; + } + + // Validate autosave param. See _wp_post_revision_fields() for why these fields are disallowed. + if ( $args['autosave'] ) { + if ( $args['date_gmt'] ) { + return new WP_Error( 'illegal_autosave_with_date_gmt' ); + } elseif ( $args['status'] ) { + return new WP_Error( 'illegal_autosave_with_status' ); + } elseif ( $args['user_id'] && get_current_user_id() !== $args['user_id'] ) { + return new WP_Error( 'illegal_autosave_with_non_current_user' ); + } + } + + // The request was made via wp.customize.previewer.save(). + $update_transactionally = (bool) $args['status']; + $allow_revision = (bool) $args['status']; + + // Amend post values with any supplied data. + foreach ( $args['data'] as $setting_id => $setting_params ) { + if ( is_array( $setting_params ) && array_key_exists( 'value', $setting_params ) ) { + $this->set_post_value( $setting_id, $setting_params['value'] ); // Add to post values so that they can be validated and sanitized. + } + } + + // Note that in addition to post data, this will include any stashed theme mods. + $post_values = $this->unsanitized_post_values( array( + 'exclude_changeset' => true, + 'exclude_post_data' => false, + ) ); + $this->add_dynamic_settings( array_keys( $post_values ) ); // Ensure settings get created even if they lack an input value. + + /* + * Get list of IDs for settings that have values different from what is currently + * saved in the changeset. By skipping any values that are already the same, the + * subset of changed settings can be passed into validate_setting_values to prevent + * an underprivileged modifying a single setting for which they have the capability + * from being blocked from saving. This also prevents a user from touching of the + * previous saved settings and overriding the associated user_id if they made no change. + */ + $changed_setting_ids = array(); + foreach ( $post_values as $setting_id => $setting_value ) { + $setting = $this->get_setting( $setting_id ); + + if ( $setting && 'theme_mod' === $setting->type ) { + $prefixed_setting_id = $this->get_stylesheet() . '::' . $setting->id; + } else { + $prefixed_setting_id = $setting_id; + } + + $is_value_changed = ( + ! isset( $existing_changeset_data[ $prefixed_setting_id ] ) + || + ! array_key_exists( 'value', $existing_changeset_data[ $prefixed_setting_id ] ) + || + $existing_changeset_data[ $prefixed_setting_id ]['value'] !== $setting_value + ); + if ( $is_value_changed ) { + $changed_setting_ids[] = $setting_id; + } + } + + /** + * Fires before save validation happens. + * + * Plugins can add just-in-time {@see 'customize_validate_{$this->ID}'} filters + * at this point to catch any settings registered after `customize_register`. + * The dynamic portion of the hook name, `$this->ID` refers to the setting ID. + * + * @since 4.6.0 + * + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + do_action( 'customize_save_validation_before', $this ); + + // Validate settings. + $validated_values = array_merge( + array_fill_keys( array_keys( $args['data'] ), null ), // Make sure existence/capability checks are done on value-less setting updates. + $post_values + ); + $setting_validities = $this->validate_setting_values( $validated_values, array( + 'validate_capability' => true, + 'validate_existence' => true, + ) ); + $invalid_setting_count = count( array_filter( $setting_validities, 'is_wp_error' ) ); + + /* + * Short-circuit if there are invalid settings the update is transactional. + * A changeset update is transactional when a status is supplied in the request. + */ + if ( $update_transactionally && $invalid_setting_count > 0 ) { + $response = array( + 'setting_validities' => $setting_validities, + /* translators: %s: number of invalid settings */ + 'message' => sprintf( _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', $invalid_setting_count ), number_format_i18n( $invalid_setting_count ) ), + ); + return new WP_Error( 'transaction_fail', '', $response ); + } + + // Obtain/merge data for changeset. + $original_changeset_data = $this->get_changeset_post_data( $changeset_post_id ); + $data = $original_changeset_data; + if ( is_wp_error( $data ) ) { + $data = array(); + } + + // Ensure that all post values are included in the changeset data. + foreach ( $post_values as $setting_id => $post_value ) { + if ( ! isset( $args['data'][ $setting_id ] ) ) { + $args['data'][ $setting_id ] = array(); + } + if ( ! isset( $args['data'][ $setting_id ]['value'] ) ) { + $args['data'][ $setting_id ]['value'] = $post_value; + } + } + + foreach ( $args['data'] as $setting_id => $setting_params ) { + $setting = $this->get_setting( $setting_id ); + if ( ! $setting || ! $setting->check_capabilities() ) { + continue; + } + + // Skip updating changeset for invalid setting values. + if ( isset( $setting_validities[ $setting_id ] ) && is_wp_error( $setting_validities[ $setting_id ] ) ) { + continue; + } + + $changeset_setting_id = $setting_id; + if ( 'theme_mod' === $setting->type ) { + $changeset_setting_id = sprintf( '%s::%s', $this->get_stylesheet(), $setting_id ); + } + + if ( null === $setting_params ) { + // Remove setting from changeset entirely. + unset( $data[ $changeset_setting_id ] ); + } else { + + if ( ! isset( $data[ $changeset_setting_id ] ) ) { + $data[ $changeset_setting_id ] = array(); + } + + // Merge any additional setting params that have been supplied with the existing params. + $merged_setting_params = array_merge( $data[ $changeset_setting_id ], $setting_params ); + + // Skip updating setting params if unchanged (ensuring the user_id is not overwritten). + if ( $data[ $changeset_setting_id ] === $merged_setting_params ) { + continue; + } + + $data[ $changeset_setting_id ] = array_merge( + $merged_setting_params, + array( + 'type' => $setting->type, + 'user_id' => $args['user_id'], + 'date_modified_gmt' => current_time( 'mysql', true ), + ) + ); + + // Clear starter_content flag in data if changeset is not explicitly being updated for starter content. + if ( empty( $args['starter_content'] ) ) { + unset( $data[ $changeset_setting_id ]['starter_content'] ); + } + } + } + + $filter_context = array( + 'uuid' => $this->changeset_uuid(), + 'title' => $args['title'], + 'status' => $args['status'], + 'date_gmt' => $args['date_gmt'], + 'post_id' => $changeset_post_id, + 'previous_data' => is_wp_error( $original_changeset_data ) ? array() : $original_changeset_data, + 'manager' => $this, + ); + + /** + * Filters the settings' data that will be persisted into the changeset. + * + * Plugins may amend additional data (such as additional meta for settings) into the changeset with this filter. + * + * @since 4.7.0 + * + * @param array $data Updated changeset data, mapping setting IDs to arrays containing a $value item and optionally other metadata. + * @param array $context { + * Filter context. + * + * @type string $uuid Changeset UUID. + * @type string $title Requested title for the changeset post. + * @type string $status Requested status for the changeset post. + * @type string $date_gmt Requested date for the changeset post in MySQL format and GMT timezone. + * @type int|false $post_id Post ID for the changeset, or false if it doesn't exist yet. + * @type array $previous_data Previous data contained in the changeset. + * @type WP_Customize_Manager $manager Manager instance. + * } + */ + $data = apply_filters( 'customize_changeset_save_data', $data, $filter_context ); + + // Switch theme if publishing changes now. + if ( 'publish' === $args['status'] && ! $this->is_theme_active() ) { + // Temporarily stop previewing the theme to allow switch_themes() to operate properly. + $this->stop_previewing_theme(); + switch_theme( $this->get_stylesheet() ); + update_option( 'theme_switched_via_customizer', true ); + $this->start_previewing_theme(); + } + + // Gather the data for wp_insert_post()/wp_update_post(). + $json_options = 0; + if ( defined( 'JSON_UNESCAPED_SLASHES' ) ) { + $json_options |= JSON_UNESCAPED_SLASHES; // Introduced in PHP 5.4. This is only to improve readability as slashes needn't be escaped in storage. + } + $json_options |= JSON_PRETTY_PRINT; // Also introduced in PHP 5.4, but WP defines constant for back compat. See WP Trac #30139. + $post_array = array( + 'post_content' => wp_json_encode( $data, $json_options ), + ); + if ( $args['title'] ) { + $post_array['post_title'] = $args['title']; + } + if ( $changeset_post_id ) { + $post_array['ID'] = $changeset_post_id; + } else { + $post_array['post_type'] = 'customize_changeset'; + $post_array['post_name'] = $this->changeset_uuid(); + $post_array['post_status'] = 'auto-draft'; + } + if ( $args['status'] ) { + $post_array['post_status'] = $args['status']; + } + + // Reset post date to now if we are publishing, otherwise pass post_date_gmt and translate for post_date. + if ( 'publish' === $args['status'] ) { + $post_array['post_date_gmt'] = '0000-00-00 00:00:00'; + $post_array['post_date'] = '0000-00-00 00:00:00'; + } elseif ( $args['date_gmt'] ) { + $post_array['post_date_gmt'] = $args['date_gmt']; + $post_array['post_date'] = get_date_from_gmt( $args['date_gmt'] ); + } elseif ( $changeset_post_id && 'auto-draft' === get_post_status( $changeset_post_id ) ) { + /* + * Keep bumping the date for the auto-draft whenever it is modified; + * this extends its life, preserving it from garbage-collection via + * wp_delete_auto_drafts(). + */ + $post_array['post_date'] = current_time( 'mysql' ); + $post_array['post_date_gmt'] = ''; + } + + $this->store_changeset_revision = $allow_revision; + add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ), 5, 3 ); + + // Update the changeset post. The publish_customize_changeset action will cause the settings in the changeset to be saved via WP_Customize_Setting::save(). + $has_kses = ( false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ) ); + if ( $has_kses ) { + kses_remove_filters(); // Prevent KSES from corrupting JSON in post_content. + } + + // Note that updating a post with publish status will trigger WP_Customize_Manager::publish_changeset_values(). + if ( $changeset_post_id ) { + if ( $args['autosave'] && 'auto-draft' !== get_post_status( $changeset_post_id ) ) { + // See _wp_translate_postdata() for why this is required as it will use the edit_post meta capability. + add_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10, 4 ); + $post_array['post_ID'] = $post_array['ID']; + $post_array['post_type'] = 'customize_changeset'; + $r = wp_create_post_autosave( wp_slash( $post_array ) ); + remove_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10 ); + } else { + $post_array['edit_date'] = true; // Prevent date clearing. + $r = wp_update_post( wp_slash( $post_array ), true ); + + // Delete autosave revision for user when the changeset is updated. + if ( ! empty( $args['user_id'] ) ) { + $autosave_draft = wp_get_post_autosave( $changeset_post_id, $args['user_id'] ); + if ( $autosave_draft ) { + wp_delete_post( $autosave_draft->ID, true ); + } + } + } + } else { + $r = wp_insert_post( wp_slash( $post_array ), true ); + if ( ! is_wp_error( $r ) ) { + $this->_changeset_post_id = $r; // Update cached post ID for the loaded changeset. + } + } + if ( $has_kses ) { + kses_init_filters(); + } + $this->_changeset_data = null; // Reset so WP_Customize_Manager::changeset_data() will re-populate with updated contents. + + remove_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_filter_revision_post_has_changed' ) ); + + $response = array( + 'setting_validities' => $setting_validities, + ); + + if ( is_wp_error( $r ) ) { + $response['changeset_post_save_failure'] = $r->get_error_code(); + return new WP_Error( 'changeset_post_save_failure', '', $response ); + } + + return $response; + } + + /** + * Trash or delete a changeset post. + * + * The following re-formulates the logic from `wp_trash_post()` as done in + * `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it + * will mutate the the `post_content` and the `post_name` when they should be + * untouched. + * + * @since 4.9.0 + * @global wpdb $wpdb WordPress database abstraction object. + * @see wp_trash_post() + * + * @param int|WP_Post $post The changeset post. + * @return mixed A WP_Post object for the trashed post or an empty value on failure. + */ + public function trash_changeset_post( $post ) { + global $wpdb; + + $post = get_post( $post ); + + if ( ! ( $post instanceof WP_Post ) ) { + return $post; + } + $post_id = $post->ID; + + if ( ! EMPTY_TRASH_DAYS ) { + return wp_delete_post( $post_id, true ); + } + + if ( 'trash' === get_post_status( $post ) ) { + return false; + } + + /** This filter is documented in wp-includes/post.php */ + $check = apply_filters( 'pre_trash_post', null, $post ); + if ( null !== $check ) { + return $check; + } + + /** This action is documented in wp-includes/post.php */ + do_action( 'wp_trash_post', $post_id ); + + add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status ); + add_post_meta( $post_id, '_wp_trash_meta_time', time() ); + + $old_status = $post->post_status; + $new_status = 'trash'; + $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) ); + clean_post_cache( $post->ID ); + + $post->post_status = $new_status; + wp_transition_post_status( $new_status, $old_status, $post ); + + /** This action is documented in wp-includes/post.php */ + do_action( 'edit_post', $post->ID, $post ); + + /** This action is documented in wp-includes/post.php */ + do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); + + /** This action is documented in wp-includes/post.php */ + do_action( 'save_post', $post->ID, $post, true ); + + /** This action is documented in wp-includes/post.php */ + do_action( 'wp_insert_post', $post->ID, $post, true ); + + wp_trash_post_comments( $post_id ); + + /** This action is documented in wp-includes/post.php */ + do_action( 'trashed_post', $post_id ); + + return $post; + } + + /** + * Handle request to trash a changeset. + * + * @since 4.9.0 + */ + public function handle_changeset_trash_request() { + if ( ! is_user_logged_in() ) { + wp_send_json_error( 'unauthenticated' ); + } + + if ( ! $this->is_preview() ) { + wp_send_json_error( 'not_preview' ); + } + + if ( ! check_ajax_referer( 'trash_customize_changeset', 'nonce', false ) ) { + wp_send_json_error( array( + 'code' => 'invalid_nonce', + 'message' => __( 'There was an authentication problem. Please reload and try again.' ), + ) ); + } + + $changeset_post_id = $this->changeset_post_id(); + + if ( ! $changeset_post_id ) { + wp_send_json_error( array( + 'message' => __( 'No changes saved yet, so there is nothing to trash.' ), + 'code' => 'non_existent_changeset', + ) ); + return; + } + + if ( $changeset_post_id && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) { + wp_send_json_error( array( + 'code' => 'changeset_trash_unauthorized', + 'message' => __( 'Unable to trash changes.' ), + ) ); + } + + if ( 'trash' === get_post_status( $changeset_post_id ) ) { + wp_send_json_error( array( + 'message' => __( 'Changes have already been trashed.' ), + 'code' => 'changeset_already_trashed', + ) ); + return; + } + + $r = $this->trash_changeset_post( $changeset_post_id ); + if ( ! ( $r instanceof WP_Post ) ) { + wp_send_json_error( array( + 'code' => 'changeset_trash_failure', + 'message' => __( 'Unable to trash changes.' ), + ) ); + } + + wp_send_json_success( array( + 'message' => __( 'Changes trashed successfully.' ), + ) ); + } + + /** + * Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps. + * + * There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to + * the 'customize' meta cap which then maps to 'edit_theme_options'. This is currently + * required in core for `wp_create_post_autosave()` because it will call + * `_wp_translate_postdata()` which in turn will check if a user can 'edit_post', but the + * the caps for the customize_changeset post type are all mapping to the meta capability. + * This should be able to be removed once #40922 is addressed in core. + * + * @since 4.9.0 + * @link https://core.trac.wordpress.org/ticket/40922 + * @see WP_Customize_Manager::save_changeset_post() + * @see _wp_translate_postdata() + * + * @param array $caps Returns the user's actual capabilities. + * @param string $cap Capability name. + * @param int $user_id The user ID. + * @param array $args Adds the context to the cap. Typically the object ID. + * @return array Capabilities. + */ + public function grant_edit_post_capability_for_changeset( $caps, $cap, $user_id, $args ) { + if ( 'edit_post' === $cap && ! empty( $args[0] ) && 'customize_changeset' === get_post_type( $args[0] ) ) { + $post_type_obj = get_post_type_object( 'customize_changeset' ); + $caps = map_meta_cap( $post_type_obj->cap->$cap, $user_id ); + } + return $caps; + } + + /** + * Marks the changeset post as being currently edited by the current user. + * + * @since 4.9.0 + * + * @param int $changeset_post_id Changeset post id. + * @param bool $take_over Take over the changeset, default is false. + */ + public function set_changeset_lock( $changeset_post_id, $take_over = false ) { + if ( $changeset_post_id ) { + $can_override = ! (bool) get_post_meta( $changeset_post_id, '_edit_lock', true ); + + if ( $take_over ) { + $can_override = true; + } + + if ( $can_override ) { + $lock = sprintf( '%s:%s', time(), get_current_user_id() ); + update_post_meta( $changeset_post_id, '_edit_lock', $lock ); + } else { + $this->refresh_changeset_lock( $changeset_post_id ); + } + } + } + + /** + * Refreshes changeset lock with the current time if current user edited the changeset before. + * + * @since 4.9.0 + * + * @param int $changeset_post_id Changeset post id. + */ + public function refresh_changeset_lock( $changeset_post_id ) { + if ( ! $changeset_post_id ) { + return; + } + $lock = get_post_meta( $changeset_post_id, '_edit_lock', true ); + $lock = explode( ':', $lock ); + + if ( $lock && ! empty( $lock[1] ) ) { + $user_id = intval( $lock[1] ); + $current_user_id = get_current_user_id(); + if ( $user_id === $current_user_id ) { + $lock = sprintf( '%s:%s', time(), $user_id ); + update_post_meta( $changeset_post_id, '_edit_lock', $lock ); + } + } + } + + /** + * Filter heartbeat settings for the Customizer. + * + * @since 4.9.0 + * @param array $settings Current settings to filter. + * @return array Heartbeat settings. + */ + public function add_customize_screen_to_heartbeat_settings( $settings ) { + global $pagenow; + if ( 'customize.php' === $pagenow ) { + $settings['screenId'] = 'customize'; + } + return $settings; + } + + /** + * Get lock user data. + * + * @since 4.9.0 + * + * @param int $user_id User ID. + * @return array|null User data formatted for client. + */ + protected function get_lock_user_data( $user_id ) { + if ( ! $user_id ) { + return null; + } + $lock_user = get_userdata( $user_id ); + if ( ! $lock_user ) { + return null; + } + return array( + 'id' => $lock_user->ID, + 'name' => $lock_user->display_name, + 'avatar' => get_avatar_url( $lock_user->ID, array( 'size' => 128 ) ), + ); + } + + /** + * Check locked changeset with heartbeat API. + * + * @since 4.9.0 + * + * @param array $response The Heartbeat response. + * @param array $data The $_POST data sent. + * @param string $screen_id The screen id. + * @return array The Heartbeat response. + */ + public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) { + if ( isset( $data['changeset_uuid'] ) ) { + $changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] ); + } else { + $changeset_post_id = $this->changeset_post_id(); + } + + if ( + array_key_exists( 'check_changeset_lock', $data ) + && 'customize' === $screen_id + && $changeset_post_id + && current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) + ) { + $lock_user_id = wp_check_post_lock( $changeset_post_id ); + + if ( $lock_user_id ) { + $response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id ); + } else { + + // Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab. + $this->refresh_changeset_lock( $changeset_post_id ); + } + } + + return $response; + } + + /** + * Removes changeset lock when take over request is sent via Ajax. + * + * @since 4.9.0 + */ + public function handle_override_changeset_lock_request() { + if ( ! $this->is_preview() ) { + wp_send_json_error( 'not_preview', 400 ); + } + + if ( ! check_ajax_referer( 'customize_override_changeset_lock', 'nonce', false ) ) { + wp_send_json_error( array( + 'code' => 'invalid_nonce', + 'message' => __( 'Security check failed.' ), + ) ); + } + + $changeset_post_id = $this->changeset_post_id(); + + if ( empty( $changeset_post_id ) ) { + wp_send_json_error( array( + 'code' => 'no_changeset_found_to_take_over', + 'message' => __( 'No changeset found to take over' ), + ) ); + } + + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) { + wp_send_json_error( array( + 'code' => 'cannot_remove_changeset_lock', + 'message' => __( 'Sorry, you are not allowed to take over.' ), + ) ); + } + + $this->set_changeset_lock( $changeset_post_id, true ); + + wp_send_json_success( 'changeset_taken_over' ); + } + + /** + * Whether a changeset revision should be made. + * + * @since 4.7.0 + * @var bool + */ + protected $store_changeset_revision; + + /** + * Filters whether a changeset has changed to create a new revision. + * + * Note that this will not be called while a changeset post remains in auto-draft status. + * + * @since 4.7.0 + * + * @param bool $post_has_changed Whether the post has changed. + * @param WP_Post $last_revision The last revision post object. + * @param WP_Post $post The post object. + * + * @return bool Whether a revision should be made. + */ + public function _filter_revision_post_has_changed( $post_has_changed, $last_revision, $post ) { + unset( $last_revision ); + if ( 'customize_changeset' === $post->post_type ) { + $post_has_changed = $this->store_changeset_revision; + } + return $post_has_changed; + } + + /** + * Publish changeset values. + * + * This will the values contained in a changeset, even changesets that do not + * correspond to current manager instance. This is called by + * `_wp_customize_publish_changeset()` when a customize_changeset post is + * transitioned to the `publish` status. As such, this method should not be + * called directly and instead `wp_publish_post()` should be used. + * + * Please note that if the settings in the changeset are for a non-activated + * theme, the theme must first be switched to (via `switch_theme()`) before + * invoking this method. + * + * @since 4.7.0 + * @see _wp_customize_publish_changeset() + * @global wpdb $wpdb + * + * @param int $changeset_post_id ID for customize_changeset post. Defaults to the changeset for the current manager instance. + * @return true|WP_Error True or error info. + */ + public function _publish_changeset_values( $changeset_post_id ) { + global $wpdb; + + $publishing_changeset_data = $this->get_changeset_post_data( $changeset_post_id ); + if ( is_wp_error( $publishing_changeset_data ) ) { + return $publishing_changeset_data; + } + + $changeset_post = get_post( $changeset_post_id ); + + /* + * Temporarily override the changeset context so that it will be read + * in calls to unsanitized_post_values() and so that it will be available + * on the $wp_customize object passed to hooks during the save logic. + */ + $previous_changeset_post_id = $this->_changeset_post_id; + $this->_changeset_post_id = $changeset_post_id; + $previous_changeset_uuid = $this->_changeset_uuid; + $this->_changeset_uuid = $changeset_post->post_name; + $previous_changeset_data = $this->_changeset_data; + $this->_changeset_data = $publishing_changeset_data; + + // Parse changeset data to identify theme mod settings and user IDs associated with settings to be saved. + $setting_user_ids = array(); + $theme_mod_settings = array(); + $namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/'; + $matches = array(); + foreach ( $this->_changeset_data as $raw_setting_id => $setting_params ) { + $actual_setting_id = null; + $is_theme_mod_setting = ( + isset( $setting_params['value'] ) + && + isset( $setting_params['type'] ) + && + 'theme_mod' === $setting_params['type'] + && + preg_match( $namespace_pattern, $raw_setting_id, $matches ) + ); + if ( $is_theme_mod_setting ) { + if ( ! isset( $theme_mod_settings[ $matches['stylesheet'] ] ) ) { + $theme_mod_settings[ $matches['stylesheet'] ] = array(); + } + $theme_mod_settings[ $matches['stylesheet'] ][ $matches['setting_id'] ] = $setting_params; + + if ( $this->get_stylesheet() === $matches['stylesheet'] ) { + $actual_setting_id = $matches['setting_id']; + } + } else { + $actual_setting_id = $raw_setting_id; + } + + // Keep track of the user IDs for settings actually for this theme. + if ( $actual_setting_id && isset( $setting_params['user_id'] ) ) { + $setting_user_ids[ $actual_setting_id ] = $setting_params['user_id']; + } + } + + $changeset_setting_values = $this->unsanitized_post_values( array( + 'exclude_post_data' => true, + 'exclude_changeset' => false, + ) ); + $changeset_setting_ids = array_keys( $changeset_setting_values ); + $this->add_dynamic_settings( $changeset_setting_ids ); + + /** + * Fires once the theme has switched in the Customizer, but before settings + * have been saved. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $manager WP_Customize_Manager instance. + */ + do_action( 'customize_save', $this ); + + /* + * Ensure that all settings will allow themselves to be saved. Note that + * this is safe because the setting would have checked the capability + * when the setting value was written into the changeset. So this is why + * an additional capability check is not required here. + */ + $original_setting_capabilities = array(); + foreach ( $changeset_setting_ids as $setting_id ) { + $setting = $this->get_setting( $setting_id ); + if ( $setting && ! isset( $setting_user_ids[ $setting_id ] ) ) { + $original_setting_capabilities[ $setting->id ] = $setting->capability; + $setting->capability = 'exist'; + } + } + + $original_user_id = get_current_user_id(); + foreach ( $changeset_setting_ids as $setting_id ) { + $setting = $this->get_setting( $setting_id ); + if ( $setting ) { + /* + * Set the current user to match the user who saved the value into + * the changeset so that any filters that apply during the save + * process will respect the original user's capabilities. This + * will ensure, for example, that KSES won't strip unsafe HTML + * when a scheduled changeset publishes via WP Cron. + */ + if ( isset( $setting_user_ids[ $setting_id ] ) ) { + wp_set_current_user( $setting_user_ids[ $setting_id ] ); + } else { + wp_set_current_user( $original_user_id ); + } + + $setting->save(); + } + } + wp_set_current_user( $original_user_id ); + + // Update the stashed theme mod settings, removing the active theme's stashed settings, if activated. + if ( did_action( 'switch_theme' ) ) { + $other_theme_mod_settings = $theme_mod_settings; + unset( $other_theme_mod_settings[ $this->get_stylesheet() ] ); + $this->update_stashed_theme_mod_settings( $other_theme_mod_settings ); + } + + /** + * Fires after Customize settings have been saved. + * + * @since 3.6.0 + * + * @param WP_Customize_Manager $manager WP_Customize_Manager instance. + */ + do_action( 'customize_save_after', $this ); + + // Restore original capabilities. + foreach ( $original_setting_capabilities as $setting_id => $capability ) { + $setting = $this->get_setting( $setting_id ); + if ( $setting ) { + $setting->capability = $capability; + } + } + + // Restore original changeset data. + $this->_changeset_data = $previous_changeset_data; + $this->_changeset_post_id = $previous_changeset_post_id; + $this->_changeset_uuid = $previous_changeset_uuid; + + /* + * Convert all autosave revisions into their own auto-drafts so that users can be prompted to + * restore them when a changeset is published, but they had been locked out from including + * their changes in the changeset. + */ + $revisions = wp_get_post_revisions( $changeset_post_id, array( 'check_enabled' => false ) ); + foreach ( $revisions as $revision ) { + if ( false !== strpos( $revision->post_name, "{$changeset_post_id}-autosave" ) ) { + $wpdb->update( + $wpdb->posts, + array( + 'post_status' => 'auto-draft', + 'post_type' => 'customize_changeset', + 'post_name' => wp_generate_uuid4(), + 'post_parent' => 0, + ), + array( + 'ID' => $revision->ID, + ) + ); + clean_post_cache( $revision->ID ); + } + } + + return true; + } + + /** + * Update stashed theme mod settings. + * + * @since 4.7.0 + * + * @param array $inactive_theme_mod_settings Mapping of stylesheet to arrays of theme mod settings. + * @return array|false Returns array of updated stashed theme mods or false if the update failed or there were no changes. + */ + protected function update_stashed_theme_mod_settings( $inactive_theme_mod_settings ) { + $stashed_theme_mod_settings = get_option( 'customize_stashed_theme_mods' ); + if ( empty( $stashed_theme_mod_settings ) ) { + $stashed_theme_mod_settings = array(); + } + + // Delete any stashed theme mods for the active theme since they would have been loaded and saved upon activation. + unset( $stashed_theme_mod_settings[ $this->get_stylesheet() ] ); + + // Merge inactive theme mods with the stashed theme mod settings. + foreach ( $inactive_theme_mod_settings as $stylesheet => $theme_mod_settings ) { + if ( ! isset( $stashed_theme_mod_settings[ $stylesheet ] ) ) { + $stashed_theme_mod_settings[ $stylesheet ] = array(); + } + + $stashed_theme_mod_settings[ $stylesheet ] = array_merge( + $stashed_theme_mod_settings[ $stylesheet ], + $theme_mod_settings + ); + } + + $autoload = false; + $result = update_option( 'customize_stashed_theme_mods', $stashed_theme_mod_settings, $autoload ); + if ( ! $result ) { + return false; + } + return $stashed_theme_mod_settings; + } + + /** + * Refresh nonces for the current preview. + * + * @since 4.2.0 + */ + public function refresh_nonces() { + if ( ! $this->is_preview() ) { + wp_send_json_error( 'not_preview' ); + } + + wp_send_json_success( $this->get_nonces() ); + } + + /** + * Delete a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock. + * + * @since 4.9.0 + */ + public function handle_dismiss_autosave_or_lock_request() { + // Calls to dismiss_user_auto_draft_changesets() and wp_get_post_autosave() require non-zero get_current_user_id(). + if ( ! is_user_logged_in() ) { + wp_send_json_error( 'unauthenticated', 401 ); + } + + if ( ! $this->is_preview() ) { + wp_send_json_error( 'not_preview', 400 ); + } + + if ( ! check_ajax_referer( 'customize_dismiss_autosave_or_lock', 'nonce', false ) ) { + wp_send_json_error( 'invalid_nonce', 403 ); + } + + $changeset_post_id = $this->changeset_post_id(); + $dismiss_lock = ! empty( $_POST['dismiss_lock'] ); + $dismiss_autosave = ! empty( $_POST['dismiss_autosave'] ); + + if ( $dismiss_lock ) { + if ( empty( $changeset_post_id ) && ! $dismiss_autosave ) { + wp_send_json_error( 'no_changeset_to_dismiss_lock', 404 ); + } + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) && ! $dismiss_autosave ) { + wp_send_json_error( 'cannot_remove_changeset_lock', 403 ); + } + + delete_post_meta( $changeset_post_id, '_edit_lock' ); + + if ( ! $dismiss_autosave ) { + wp_send_json_success( 'changeset_lock_dismissed' ); + } + } + + if ( $dismiss_autosave ) { + if ( empty( $changeset_post_id ) || 'auto-draft' === get_post_status( $changeset_post_id ) ) { + $dismissed = $this->dismiss_user_auto_draft_changesets(); + if ( $dismissed > 0 ) { + wp_send_json_success( 'auto_draft_dismissed' ); + } else { + wp_send_json_error( 'no_auto_draft_to_delete', 404 ); + } + } else { + $revision = wp_get_post_autosave( $changeset_post_id, get_current_user_id() ); + + if ( $revision ) { + if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) { + wp_send_json_error( 'cannot_delete_autosave_revision', 403 ); + } + + if ( ! wp_delete_post( $revision->ID, true ) ) { + wp_send_json_error( 'autosave_revision_deletion_failure', 500 ); + } else { + wp_send_json_success( 'autosave_revision_deleted' ); + } + } else { + wp_send_json_error( 'no_autosave_revision_to_delete', 404 ); + } + } + } + + wp_send_json_error( 'unknown_error', 500 ); + } + + /** + * Add a customize setting. + * + * @since 3.4.0 + * @since 4.5.0 Return added WP_Customize_Setting instance. + * + * @param WP_Customize_Setting|string $id Customize Setting object, or ID. + * @param array $args { + * Optional. Array of properties for the new WP_Customize_Setting. Default empty array. + * + * @type string $type Type of the setting. Default 'theme_mod'. + * Default 160. + * @type string $capability Capability required for the setting. Default 'edit_theme_options' + * @type string|array $theme_supports Theme features required to support the panel. Default is none. + * @type string $default Default value for the setting. Default is empty string. + * @type string $transport Options for rendering the live preview of changes in Theme Customizer. + * Using 'refresh' makes the change visible by reloading the whole preview. + * Using 'postMessage' allows a custom JavaScript to handle live changes. + * @link https://developer.wordpress.org/themes/customize-api + * Default is 'refresh' + * @type callable $validate_callback Server-side validation callback for the setting's value. + * @type callable $sanitize_callback Callback to filter a Customize setting value in un-slashed form. + * @type callable $sanitize_js_callback Callback to convert a Customize PHP setting value to a value that is + * JSON serializable. + * @type bool $dirty Whether or not the setting is initially dirty when created. + * } + * @return WP_Customize_Setting The instance of the setting that was added. + */ + public function add_setting( $id, $args = array() ) { + if ( $id instanceof WP_Customize_Setting ) { + $setting = $id; + } else { + $class = 'WP_Customize_Setting'; + + /** This filter is documented in wp-includes/class-wp-customize-manager.php */ + $args = apply_filters( 'customize_dynamic_setting_args', $args, $id ); + + /** This filter is documented in wp-includes/class-wp-customize-manager.php */ + $class = apply_filters( 'customize_dynamic_setting_class', $class, $id, $args ); + + $setting = new $class( $this, $id, $args ); + } + + $this->settings[ $setting->id ] = $setting; + return $setting; + } + + /** + * Register any dynamically-created settings, such as those from $_POST['customized'] + * that have no corresponding setting created. + * + * This is a mechanism to "wake up" settings that have been dynamically created + * on the front end and have been sent to WordPress in `$_POST['customized']`. When WP + * loads, the dynamically-created settings then will get created and previewed + * even though they are not directly created statically with code. + * + * @since 4.2.0 + * + * @param array $setting_ids The setting IDs to add. + * @return array The WP_Customize_Setting objects added. + */ + public function add_dynamic_settings( $setting_ids ) { + $new_settings = array(); + foreach ( $setting_ids as $setting_id ) { + // Skip settings already created + if ( $this->get_setting( $setting_id ) ) { + continue; + } + + $setting_args = false; + $setting_class = 'WP_Customize_Setting'; + + /** + * Filters a dynamic setting's constructor args. + * + * For a dynamic setting to be registered, this filter must be employed + * to override the default false value with an array of args to pass to + * the WP_Customize_Setting constructor. + * + * @since 4.2.0 + * + * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + */ + $setting_args = apply_filters( 'customize_dynamic_setting_args', $setting_args, $setting_id ); + if ( false === $setting_args ) { + continue; + } + + /** + * Allow non-statically created settings to be constructed with custom WP_Customize_Setting subclass. + * + * @since 4.2.0 + * + * @param string $setting_class WP_Customize_Setting or a subclass. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + * @param array $setting_args WP_Customize_Setting or a subclass. + */ + $setting_class = apply_filters( 'customize_dynamic_setting_class', $setting_class, $setting_id, $setting_args ); + + $setting = new $setting_class( $this, $setting_id, $setting_args ); + + $this->add_setting( $setting ); + $new_settings[] = $setting; + } + return $new_settings; + } + + /** + * Retrieve a customize setting. + * + * @since 3.4.0 + * + * @param string $id Customize Setting ID. + * @return WP_Customize_Setting|void The setting, if set. + */ + public function get_setting( $id ) { + if ( isset( $this->settings[ $id ] ) ) { + return $this->settings[ $id ]; + } + } + + /** + * Remove a customize setting. + * + * @since 3.4.0 + * + * @param string $id Customize Setting ID. + */ + public function remove_setting( $id ) { + unset( $this->settings[ $id ] ); + } + + /** + * Add a customize panel. + * + * @since 4.0.0 + * @since 4.5.0 Return added WP_Customize_Panel instance. + * + * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID. + * @param array $args { + * Optional. Array of properties for the new Panel object. Default empty array. + * @type int $priority Priority of the panel, defining the display order of panels and sections. + * Default 160. + * @type string $capability Capability required for the panel. Default `edit_theme_options` + * @type string|array $theme_supports Theme features required to support the panel. + * @type string $title Title of the panel to show in UI. + * @type string $description Description to show in the UI. + * @type string $type Type of the panel. + * @type callable $active_callback Active callback. + * } + * @return WP_Customize_Panel The instance of the panel that was added. + */ + public function add_panel( $id, $args = array() ) { + if ( $id instanceof WP_Customize_Panel ) { + $panel = $id; + } else { + $panel = new WP_Customize_Panel( $this, $id, $args ); + } + + $this->panels[ $panel->id ] = $panel; + return $panel; + } + + /** + * Retrieve a customize panel. + * + * @since 4.0.0 + * + * @param string $id Panel ID to get. + * @return WP_Customize_Panel|void Requested panel instance, if set. + */ + public function get_panel( $id ) { + if ( isset( $this->panels[ $id ] ) ) { + return $this->panels[ $id ]; + } + } + + /** + * Remove a customize panel. + * + * @since 4.0.0 + * + * @param string $id Panel ID to remove. + */ + public function remove_panel( $id ) { + // Removing core components this way is _doing_it_wrong(). + if ( in_array( $id, $this->components, true ) ) { + /* translators: 1: panel id, 2: link to 'customize_loaded_components' filter reference */ + $message = sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ), + $id, + '<a href="' . esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ) . '"><code>customize_loaded_components</code></a>' + ); + + _doing_it_wrong( __METHOD__, $message, '4.5.0' ); + } + unset( $this->panels[ $id ] ); + } + + /** + * Register a customize panel type. + * + * Registered types are eligible to be rendered via JS and created dynamically. + * + * @since 4.3.0 + * + * @see WP_Customize_Panel + * + * @param string $panel Name of a custom panel which is a subclass of WP_Customize_Panel. + */ + public function register_panel_type( $panel ) { + $this->registered_panel_types[] = $panel; + } + + /** + * Render JS templates for all registered panel types. + * + * @since 4.3.0 + */ + public function render_panel_templates() { + foreach ( $this->registered_panel_types as $panel_type ) { + $panel = new $panel_type( $this, 'temp', array() ); + $panel->print_template(); + } + } + + /** + * Add a customize section. + * + * @since 3.4.0 + * @since 4.5.0 Return added WP_Customize_Section instance. + * + * @param WP_Customize_Section|string $id Customize Section object, or Section ID. + * @param array $args { + * Optional. Array of properties for the new Section object. Default empty array. + * @type int $priority Priority of the section, defining the display order of panels and sections. + * Default 160. + * @type string $panel The panel this section belongs to (if any). Default empty. + * @type string $capability Capability required for the section. Default 'edit_theme_options' + * @type string|array $theme_supports Theme features required to support the section. + * @type string $title Title of the section to show in UI. + * @type string $description Description to show in the UI. + * @type string $type Type of the section. + * @type callable $active_callback Active callback. + * @type bool $description_hidden Hide the description behind a help icon, instead of inline above the first control. Default false. + * } + * @return WP_Customize_Section The instance of the section that was added. + */ + public function add_section( $id, $args = array() ) { + if ( $id instanceof WP_Customize_Section ) { + $section = $id; + } else { + $section = new WP_Customize_Section( $this, $id, $args ); + } + + $this->sections[ $section->id ] = $section; + return $section; + } + + /** + * Retrieve a customize section. + * + * @since 3.4.0 + * + * @param string $id Section ID. + * @return WP_Customize_Section|void The section, if set. + */ + public function get_section( $id ) { + if ( isset( $this->sections[ $id ] ) ) + return $this->sections[ $id ]; + } + + /** + * Remove a customize section. + * + * @since 3.4.0 + * + * @param string $id Section ID. + */ + public function remove_section( $id ) { + unset( $this->sections[ $id ] ); + } + + /** + * Register a customize section type. + * + * Registered types are eligible to be rendered via JS and created dynamically. + * + * @since 4.3.0 + * + * @see WP_Customize_Section + * + * @param string $section Name of a custom section which is a subclass of WP_Customize_Section. + */ + public function register_section_type( $section ) { + $this->registered_section_types[] = $section; + } + + /** + * Render JS templates for all registered section types. + * + * @since 4.3.0 + */ + public function render_section_templates() { + foreach ( $this->registered_section_types as $section_type ) { + $section = new $section_type( $this, 'temp', array() ); + $section->print_template(); + } + } + + /** + * Add a customize control. + * + * @since 3.4.0 + * @since 4.5.0 Return added WP_Customize_Control instance. + * + * @param WP_Customize_Control|string $id Customize Control object, or ID. + * @param array $args { + * Optional. Array of properties for the new Control object. Default empty array. + * + * @type array $settings All settings tied to the control. If undefined, defaults to `$setting`. + * IDs in the array correspond to the ID of a registered `WP_Customize_Setting`. + * @type string $setting The primary setting for the control (if there is one). Default is 'default'. + * @type string $capability Capability required to use this control. Normally derived from `$settings`. + * @type int $priority Order priority to load the control. Default 10. + * @type string $section The section this control belongs to. Default empty. + * @type string $label Label for the control. Default empty. + * @type string $description Description for the control. Default empty. + * @type array $choices List of choices for 'radio' or 'select' type controls, where values + * are the keys, and labels are the values. Default empty array. + * @type array $input_attrs List of custom input attributes for control output, where attribute + * names are the keys and values are the values. Default empty array. + * @type bool $allow_addition Show UI for adding new content, currently only used for the + * dropdown-pages control. Default false. + * @type string $type The type of the control. Default 'text'. + * @type callback $active_callback Active callback. + * } + * @return WP_Customize_Control The instance of the control that was added. + */ + public function add_control( $id, $args = array() ) { + if ( $id instanceof WP_Customize_Control ) { + $control = $id; + } else { + $control = new WP_Customize_Control( $this, $id, $args ); + } + + $this->controls[ $control->id ] = $control; + return $control; + } + + /** + * Retrieve a customize control. + * + * @since 3.4.0 + * + * @param string $id ID of the control. + * @return WP_Customize_Control|void The control object, if set. + */ + public function get_control( $id ) { + if ( isset( $this->controls[ $id ] ) ) + return $this->controls[ $id ]; + } + + /** + * Remove a customize control. + * + * @since 3.4.0 + * + * @param string $id ID of the control. + */ + public function remove_control( $id ) { + unset( $this->controls[ $id ] ); + } + + /** + * Register a customize control type. + * + * Registered types are eligible to be rendered via JS and created dynamically. + * + * @since 4.1.0 + * + * @param string $control Name of a custom control which is a subclass of + * WP_Customize_Control. + */ + public function register_control_type( $control ) { + $this->registered_control_types[] = $control; + } + + /** + * Render JS templates for all registered control types. + * + * @since 4.1.0 + */ + public function render_control_templates() { + if ( $this->branching() ) { + $l10n = array( + /* translators: %s: User who is customizing the changeset in customizer. */ + 'locked' => __( '%s is already customizing this changeset. Please wait until they are done to try customizing. Your latest changes have been autosaved.' ), + /* translators: %s: User who is customizing the changeset in customizer. */ + 'locked_allow_override' => __( '%s is already customizing this changeset. Do you want to take over?' ), + ); + } else { + $l10n = array( + /* translators: %s: User who is customizing the changeset in customizer. */ + 'locked' => __( '%s is already customizing this site. Please wait until they are done to try customizing. Your latest changes have been autosaved.' ), + /* translators: %s: User who is customizing the changeset in customizer. */ + 'locked_allow_override' => __( '%s is already customizing this site. Do you want to take over?' ), + ); + } + + foreach ( $this->registered_control_types as $control_type ) { + $control = new $control_type( $this, 'temp', array( + 'settings' => array(), + ) ); + $control->print_template(); + } + ?> + + <script type="text/html" id="tmpl-customize-control-default-content"> + <# + var inputId = _.uniqueId( 'customize-control-default-input-' ); + var descriptionId = _.uniqueId( 'customize-control-default-description-' ); + var describedByAttr = data.description ? ' aria-describedby="' + descriptionId + '" ' : ''; + #> + <# switch ( data.type ) { + case 'checkbox': #> + <span class="customize-inside-control-row"> + <input + id="{{ inputId }}" + {{{ describedByAttr }}} + type="checkbox" + value="{{ data.value }}" + data-customize-setting-key-link="default" + > + <label for="{{ inputId }}"> + {{ data.label }} + </label> + <# if ( data.description ) { #> + <span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span> + <# } #> + </span> + <# + break; + case 'radio': + if ( ! data.choices ) { + return; + } + #> + <# if ( data.label ) { #> + <label for="{{ inputId }}" class="customize-control-title"> + {{ data.label }} + </label> + <# } #> + <# if ( data.description ) { #> + <span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span> + <# } #> + <# _.each( data.choices, function( val, key ) { #> + <span class="customize-inside-control-row"> + <# + var value, text; + if ( _.isObject( val ) ) { + value = val.value; + text = val.text; + } else { + value = key; + text = val; + } + #> + <input + id="{{ inputId + '-' + value }}" + type="radio" + value="{{ value }}" + name="{{ inputId }}" + data-customize-setting-key-link="default" + {{{ describedByAttr }}} + > + <label for="{{ inputId + '-' + value }}">{{ text }}</label> + </span> + <# } ); #> + <# + break; + default: + #> + <# if ( data.label ) { #> + <label for="{{ inputId }}" class="customize-control-title"> + {{ data.label }} + </label> + <# } #> + <# if ( data.description ) { #> + <span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span> + <# } #> + + <# + var inputAttrs = { + id: inputId, + 'data-customize-setting-key-link': 'default' + }; + if ( 'textarea' === data.type ) { + inputAttrs.rows = '5'; + } else if ( 'button' === data.type ) { + inputAttrs['class'] = 'button button-secondary'; + inputAttrs.type = 'button'; + } else { + inputAttrs.type = data.type; + } + if ( data.description ) { + inputAttrs['aria-describedby'] = descriptionId; + } + _.extend( inputAttrs, data.input_attrs ); + #> + + <# if ( 'button' === data.type ) { #> + <button + <# _.each( _.extend( inputAttrs ), function( value, key ) { #> + {{{ key }}}="{{ value }}" + <# } ); #> + >{{ inputAttrs.value }}</button> + <# } else if ( 'textarea' === data.type ) { #> + <textarea + <# _.each( _.extend( inputAttrs ), function( value, key ) { #> + {{{ key }}}="{{ value }}" + <# }); #> + >{{ inputAttrs.value }}</textarea> + <# } else if ( 'select' === data.type ) { #> + <# delete inputAttrs.type; #> + <select + <# _.each( _.extend( inputAttrs ), function( value, key ) { #> + {{{ key }}}="{{ value }}" + <# }); #> + > + <# _.each( data.choices, function( val, key ) { #> + <# + var value, text; + if ( _.isObject( val ) ) { + value = val.value; + text = val.text; + } else { + value = key; + text = val; + } + #> + <option value="{{ value }}">{{ text }}</option> + <# } ); #> + </select> + <# } else { #> + <input + <# _.each( _.extend( inputAttrs ), function( value, key ) { #> + {{{ key }}}="{{ value }}" + <# }); #> + > + <# } #> + <# } #> + </script> + + <script type="text/html" id="tmpl-customize-notification"> + <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}"> + <div class="notification-message">{{{ data.message || data.code }}}</div> + <# if ( data.dismissible ) { #> + <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button> + <# } #> + </li> + </script> + + <script type="text/html" id="tmpl-customize-changeset-locked-notification"> + <li class="notice notice-{{ data.type || 'info' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}"> + <div class="notification-message customize-changeset-locked-message"> + <img class="customize-changeset-locked-avatar" src="{{ data.lockUser.avatar }}" alt="{{ data.lockUser.name }}"> + <p class="currently-editing"> + <# if ( data.message ) { #> + {{{ data.message }}} + <# } else if ( data.allowOverride ) { #> + <?php + echo esc_html( sprintf( $l10n['locked_allow_override'], '{{ data.lockUser.name }}' ) ); + ?> + <# } else { #> + <?php + echo esc_html( sprintf( $l10n['locked'], '{{ data.lockUser.name }}' ) ); + ?> + <# } #> + </p> + <p class="notice notice-error notice-alt" hidden></p> + <p class="action-buttons"> + <# if ( data.returnUrl !== data.previewUrl ) { #> + <a class="button customize-notice-go-back-button" href="{{ data.returnUrl }}"><?php _e( 'Go back' ); ?></a> + <# } #> + <a class="button customize-notice-preview-button" href="{{ data.frontendPreviewUrl }}"><?php _e( 'Preview' ); ?></a> + <# if ( data.allowOverride ) { #> + <button class="button button-primary wp-tab-last customize-notice-take-over-button"><?php _e( 'Take over' ); ?></button> + <# } #> + </p> + </div> + </li> + </script> + + <script type="text/html" id="tmpl-customize-code-editor-lint-error-notification"> + <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}"> + <div class="notification-message">{{{ data.message || data.code }}}</div> + + <p> + <# var elementId = 'el-' + String( Math.random() ); #> + <input id="{{ elementId }}" type="checkbox"> + <label for="{{ elementId }}"><?php _e( 'Update anyway, even though it might break your site?' ); ?></label> + </p> + </li> + </script> + + <?php + /* The following template is obsolete in core but retained for plugins. */ + ?> + <script type="text/html" id="tmpl-customize-control-notifications"> + <ul> + <# _.each( data.notifications, function( notification ) { #> + <li class="notice notice-{{ notification.type || 'info' }} {{ data.altNotice ? 'notice-alt' : '' }}" data-code="{{ notification.code }}" data-type="{{ notification.type }}">{{{ notification.message || notification.code }}}</li> + <# } ); #> + </ul> + </script> + + <script type="text/html" id="tmpl-customize-preview-link-control" > + <# var elementPrefix = _.uniqueId( 'el' ) + '-' #> + <p class="customize-control-title"> + <?php esc_html_e( 'Share Preview Link' ); ?> + </p> + <p class="description customize-control-description"><?php esc_html_e( 'See how changes would look live on your website, and share the preview with people who can\'t access the Customizer.' ); ?></p> + <div class="customize-control-notifications-container"></div> + <div class="preview-link-wrapper"> + <label for="{{ elementPrefix }}customize-preview-link-input" class="screen-reader-text"><?php esc_html_e( 'Preview Link' ); ?></label> + <a href="" target=""> + <span class="preview-control-element" data-component="url"></span> + <span class="screen-reader-text"><?php _e( '(opens in a new window)' ); ?></span> + </a> + <input id="{{ elementPrefix }}customize-preview-link-input" readonly tabindex="-1" class="preview-control-element" data-component="input"> + <button class="customize-copy-preview-link preview-control-element button button-secondary" data-component="button" data-copy-text="<?php esc_attr_e( 'Copy' ); ?>" data-copied-text="<?php esc_attr_e( 'Copied' ); ?>" ><?php esc_html_e( 'Copy' ); ?></button> + </div> + </script> + <script type="text/html" id="tmpl-customize-selected-changeset-status-control"> + <# var inputId = _.uniqueId( 'customize-selected-changeset-status-control-input-' ); #> + <# var descriptionId = _.uniqueId( 'customize-selected-changeset-status-control-description-' ); #> + <# if ( data.label ) { #> + <label for="{{ inputId }}" class="customize-control-title">{{ data.label }}</label> + <# } #> + <# if ( data.description ) { #> + <span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span> + <# } #> + <# _.each( data.choices, function( choice ) { #> + <# var choiceId = inputId + '-' + choice.status; #> + <span class="customize-inside-control-row"> + <input id="{{ choiceId }}" type="radio" value="{{ choice.status }}" name="{{ inputId }}" data-customize-setting-key-link="default"> + <label for="{{ choiceId }}">{{ choice.label }}</label> + </span> + <# } ); #> + </script> + <?php + } + + /** + * Helper function to compare two objects by priority, ensuring sort stability via instance_number. + * + * @since 3.4.0 + * @deprecated 4.7.0 Use wp_list_sort() + * + * @param WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control $a Object A. + * @param WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control $b Object B. + * @return int + */ + protected function _cmp_priority( $a, $b ) { + _deprecated_function( __METHOD__, '4.7.0', 'wp_list_sort' ); + + if ( $a->priority === $b->priority ) { + return $a->instance_number - $b->instance_number; + } else { + return $a->priority - $b->priority; + } + } + + /** + * Prepare panels, sections, and controls. + * + * For each, check if required related components exist, + * whether the user has the necessary capabilities, + * and sort by priority. + * + * @since 3.4.0 + */ + public function prepare_controls() { + + $controls = array(); + $this->controls = wp_list_sort( $this->controls, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ), 'ASC', true ); + + foreach ( $this->controls as $id => $control ) { + if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) { + continue; + } + + $this->sections[ $control->section ]->controls[] = $control; + $controls[ $id ] = $control; + } + $this->controls = $controls; + + // Prepare sections. + $this->sections = wp_list_sort( $this->sections, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ), 'ASC', true ); + $sections = array(); + + foreach ( $this->sections as $section ) { + if ( ! $section->check_capabilities() ) { + continue; + } + + + $section->controls = wp_list_sort( $section->controls, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ) ); + + if ( ! $section->panel ) { + // Top-level section. + $sections[ $section->id ] = $section; + } else { + // This section belongs to a panel. + if ( isset( $this->panels [ $section->panel ] ) ) { + $this->panels[ $section->panel ]->sections[ $section->id ] = $section; + } + } + } + $this->sections = $sections; + + // Prepare panels. + $this->panels = wp_list_sort( $this->panels, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ), 'ASC', true ); + $panels = array(); + + foreach ( $this->panels as $panel ) { + if ( ! $panel->check_capabilities() ) { + continue; + } + + $panel->sections = wp_list_sort( $panel->sections, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ), 'ASC', true ); + $panels[ $panel->id ] = $panel; + } + $this->panels = $panels; + + // Sort panels and top-level sections together. + $this->containers = array_merge( $this->panels, $this->sections ); + $this->containers = wp_list_sort( $this->containers, array( + 'priority' => 'ASC', + 'instance_number' => 'ASC', + ), 'ASC', true ); + } + + /** + * Enqueue scripts for customize controls. + * + * @since 3.4.0 + */ + public function enqueue_control_scripts() { + foreach ( $this->controls as $control ) { + $control->enqueue(); + } + + if ( ! is_multisite() && ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) || current_user_can( 'delete_themes' ) ) ) { + wp_enqueue_script( 'updates' ); + wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( + 'totals' => wp_get_update_data(), + ) ); + } + } + + /** + * Determine whether the user agent is iOS. + * + * @since 4.4.0 + * + * @return bool Whether the user agent is iOS. + */ + public function is_ios() { + return wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ); + } + + /** + * Get the template string for the Customizer pane document title. + * + * @since 4.4.0 + * + * @return string The template string for the document title. + */ + public function get_document_title_template() { + if ( $this->is_theme_active() ) { + /* translators: %s: document title from the preview */ + $document_title_tmpl = __( 'Customize: %s' ); + } else { + /* translators: %s: document title from the preview */ + $document_title_tmpl = __( 'Live Preview: %s' ); + } + $document_title_tmpl = html_entity_decode( $document_title_tmpl, ENT_QUOTES, 'UTF-8' ); // Because exported to JS and assigned to document.title. + return $document_title_tmpl; + } + + /** + * Set the initial URL to be previewed. + * + * URL is validated. + * + * @since 4.4.0 + * + * @param string $preview_url URL to be previewed. + */ + public function set_preview_url( $preview_url ) { + $preview_url = esc_url_raw( $preview_url ); + $this->preview_url = wp_validate_redirect( $preview_url, home_url( '/' ) ); + } + + /** + * Get the initial URL to be previewed. + * + * @since 4.4.0 + * + * @return string URL being previewed. + */ + public function get_preview_url() { + if ( empty( $this->preview_url ) ) { + $preview_url = home_url( '/' ); + } else { + $preview_url = $this->preview_url; + } + return $preview_url; + } + + /** + * Determines whether the admin and the frontend are on different domains. + * + * @since 4.7.0 + * + * @return bool Whether cross-domain. + */ + public function is_cross_domain() { + $admin_origin = wp_parse_url( admin_url() ); + $home_origin = wp_parse_url( home_url() ); + $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) ); + return $cross_domain; + } + + /** + * Get URLs allowed to be previewed. + * + * If the front end and the admin are served from the same domain, load the + * preview over ssl if the Customizer is being loaded over ssl. This avoids + * insecure content warnings. This is not attempted if the admin and front end + * are on different domains to avoid the case where the front end doesn't have + * ssl certs. Domain mapping plugins can allow other urls in these conditions + * using the customize_allowed_urls filter. + * + * @since 4.7.0 + * + * @returns array Allowed URLs. + */ + public function get_allowed_urls() { + $allowed_urls = array( home_url( '/' ) ); + + if ( is_ssl() && ! $this->is_cross_domain() ) { + $allowed_urls[] = home_url( '/', 'https' ); + } + + /** + * Filters the list of URLs allowed to be clicked and followed in the Customizer preview. + * + * @since 3.4.0 + * + * @param array $allowed_urls An array of allowed URLs. + */ + $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) ); + + return $allowed_urls; + } + + /** + * Get messenger channel. + * + * @since 4.7.0 + * + * @return string Messenger channel. + */ + public function get_messenger_channel() { + return $this->messenger_channel; + } + + /** + * Set URL to link the user to when closing the Customizer. + * + * URL is validated. + * + * @since 4.4.0 + * + * @param string $return_url URL for return link. + */ + public function set_return_url( $return_url ) { + $return_url = esc_url_raw( $return_url ); + $return_url = remove_query_arg( wp_removable_query_args(), $return_url ); + $return_url = wp_validate_redirect( $return_url ); + $this->return_url = $return_url; + } + + /** + * Get URL to link the user to when closing the Customizer. + * + * @since 4.4.0 + * + * @return string URL for link to close Customizer. + */ + public function get_return_url() { + $referer = wp_get_referer(); + $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' ); + + if ( $this->return_url ) { + $return_url = $this->return_url; + } else if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) { + $return_url = $referer; + } else if ( $this->preview_url ) { + $return_url = $this->preview_url; + } else { + $return_url = home_url( '/' ); + } + return $return_url; + } + + /** + * Set the autofocused constructs. + * + * @since 4.4.0 + * + * @param array $autofocus { + * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused. + * + * @type string [$control] ID for control to be autofocused. + * @type string [$section] ID for section to be autofocused. + * @type string [$panel] ID for panel to be autofocused. + * } + */ + public function set_autofocus( $autofocus ) { + $this->autofocus = array_filter( wp_array_slice_assoc( $autofocus, array( 'panel', 'section', 'control' ) ), 'is_string' ); + } + + /** + * Get the autofocused constructs. + * + * @since 4.4.0 + * + * @return array { + * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused. + * + * @type string [$control] ID for control to be autofocused. + * @type string [$section] ID for section to be autofocused. + * @type string [$panel] ID for panel to be autofocused. + * } + */ + public function get_autofocus() { + return $this->autofocus; + } + + /** + * Get nonces for the Customizer. + * + * @since 4.5.0 + * + * @return array Nonces. + */ + public function get_nonces() { + $nonces = array( + 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ), + 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ), + 'switch_themes' => wp_create_nonce( 'switch_themes' ), + 'dismiss_autosave_or_lock' => wp_create_nonce( 'customize_dismiss_autosave_or_lock' ), + 'override_lock' => wp_create_nonce( 'customize_override_changeset_lock' ), + 'trash' => wp_create_nonce( 'trash_customize_changeset' ), + ); + + /** + * Filters nonces for Customizer. + * + * @since 4.2.0 + * + * @param array $nonces Array of refreshed nonces for save and + * preview actions. + * @param WP_Customize_Manager $this WP_Customize_Manager instance. + */ + $nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this ); + + return $nonces; + } + + /** + * Print JavaScript settings for parent window. + * + * @since 4.4.0 + */ + public function customize_pane_settings() { + + $login_url = add_query_arg( array( + 'interim-login' => 1, + 'customize-login' => 1, + ), wp_login_url() ); + + // Ensure dirty flags are set for modified settings. + foreach ( array_keys( $this->unsanitized_post_values() ) as $setting_id ) { + $setting = $this->get_setting( $setting_id ); + if ( $setting ) { + $setting->dirty = true; + } + } + + $autosave_revision_post = null; + $autosave_autodraft_post = null; + $changeset_post_id = $this->changeset_post_id(); + if ( ! $this->saved_starter_content_changeset && ! $this->autosaved() ) { + if ( $changeset_post_id ) { + if ( is_user_logged_in() ) { + $autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() ); + } + } else { + $autosave_autodraft_posts = $this->get_changeset_posts( array( + 'posts_per_page' => 1, + 'post_status' => 'auto-draft', + 'exclude_restore_dismissed' => true, + ) ); + if ( ! empty( $autosave_autodraft_posts ) ) { + $autosave_autodraft_post = array_shift( $autosave_autodraft_posts ); + } + } + } + + $current_user_can_publish = current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ); + + // @todo Include all of the status labels here from script-loader.php, and then allow it to be filtered. + $status_choices = array(); + if ( $current_user_can_publish ) { + $status_choices[] = array( + 'status' => 'publish', + 'label' => __( 'Publish' ), + ); + } + $status_choices[] = array( + 'status' => 'draft', + 'label' => __( 'Save Draft' ), + ); + if ( $current_user_can_publish ) { + $status_choices[] = array( + 'status' => 'future', + 'label' => _x( 'Schedule', 'customizer changeset action/button label' ), + ); + } + + // Prepare Customizer settings to pass to JavaScript. + $changeset_post = null; + if ( $changeset_post_id ) { + $changeset_post = get_post( $changeset_post_id ); + } + + // Determine initial date to be at present or future, not past. + $current_time = current_time( 'mysql', false ); + $initial_date = $current_time; + if ( $changeset_post ) { + $initial_date = get_the_time( 'Y-m-d H:i:s', $changeset_post->ID ); + if ( $initial_date < $current_time ) { + $initial_date = $current_time; + } + } + + $lock_user_id = false; + if ( $this->changeset_post_id() ) { + $lock_user_id = wp_check_post_lock( $this->changeset_post_id() ); + } + + $settings = array( + 'changeset' => array( + 'uuid' => $this->changeset_uuid(), + 'branching' => $this->branching(), + 'autosaved' => $this->autosaved(), + 'hasAutosaveRevision' => ! empty( $autosave_revision_post ), + 'latestAutoDraftUuid' => $autosave_autodraft_post ? $autosave_autodraft_post->post_name : null, + 'status' => $changeset_post ? $changeset_post->post_status : '', + 'currentUserCanPublish' => $current_user_can_publish, + 'publishDate' => $initial_date, + 'statusChoices' => $status_choices, + 'lockUser' => $lock_user_id ? $this->get_lock_user_data( $lock_user_id ) : null, + ), + 'initialServerDate' => $current_time, + 'dateFormat' => get_option( 'date_format' ), + 'timeFormat' => get_option( 'time_format' ), + 'initialServerTimestamp' => floor( microtime( true ) * 1000 ), + 'initialClientTimestamp' => -1, // To be set with JS below. + 'timeouts' => array( + 'windowRefresh' => 250, + 'changesetAutoSave' => AUTOSAVE_INTERVAL * 1000, + 'keepAliveCheck' => 2500, + 'reflowPaneContents' => 100, + 'previewFrameSensitivity' => 2000, + ), + 'theme' => array( + 'stylesheet' => $this->get_stylesheet(), + 'active' => $this->is_theme_active(), + '_canInstall' => current_user_can( 'install_themes' ), + ), + 'url' => array( + 'preview' => esc_url_raw( $this->get_preview_url() ), + 'return' => esc_url_raw( $this->get_return_url() ), + 'parent' => esc_url_raw( admin_url() ), + 'activated' => esc_url_raw( home_url( '/' ) ), + 'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ), + 'allowed' => array_map( 'esc_url_raw', $this->get_allowed_urls() ), + 'isCrossDomain' => $this->is_cross_domain(), + 'home' => esc_url_raw( home_url( '/' ) ), + 'login' => esc_url_raw( $login_url ), + ), + 'browser' => array( + 'mobile' => wp_is_mobile(), + 'ios' => $this->is_ios(), + ), + 'panels' => array(), + 'sections' => array(), + 'nonce' => $this->get_nonces(), + 'autofocus' => $this->get_autofocus(), + 'documentTitleTmpl' => $this->get_document_title_template(), + 'previewableDevices' => $this->get_previewable_devices(), + 'l10n' => array( + 'confirmDeleteTheme' => __( 'Are you sure you want to delete this theme?' ), + /* translators: %d: number of theme search results, which cannot currently consider singular vs. plural forms */ + 'themeSearchResults' => __( '%d themes found' ), + /* translators: %d: number of themes being displayed, which cannot currently consider singular vs. plural forms */ + 'announceThemeCount' => __( 'Displaying %d themes' ), + /* translators: %s: theme name */ + 'announceThemeDetails' => __( 'Showing details for theme: %s' ), + ), + ); + + // Temporarily disable installation in Customizer. See #42184. + $filesystem_method = get_filesystem_method(); + ob_start(); + $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); + ob_end_clean(); + if ( 'direct' !== $filesystem_method && ! $filesystem_credentials_are_stored ) { + $settings['theme']['_filesystemCredentialsNeeded'] = true; + } + + // Prepare Customize Section objects to pass to JavaScript. + foreach ( $this->sections() as $id => $section ) { + if ( $section->check_capabilities() ) { + $settings['sections'][ $id ] = $section->json(); + } + } + + // Prepare Customize Panel objects to pass to JavaScript. + foreach ( $this->panels() as $panel_id => $panel ) { + if ( $panel->check_capabilities() ) { + $settings['panels'][ $panel_id ] = $panel->json(); + foreach ( $panel->sections as $section_id => $section ) { + if ( $section->check_capabilities() ) { + $settings['sections'][ $section_id ] = $section->json(); + } + } + } + } + + ?> + <script type="text/javascript"> + var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>; + _wpCustomizeSettings.initialClientTimestamp = _.now(); + _wpCustomizeSettings.controls = {}; + _wpCustomizeSettings.settings = {}; + <?php + + // Serialize settings one by one to improve memory usage. + echo "(function ( s ){\n"; + foreach ( $this->settings() as $setting ) { + if ( $setting->check_capabilities() ) { + printf( + "s[%s] = %s;\n", + wp_json_encode( $setting->id ), + wp_json_encode( $setting->json() ) + ); + } + } + echo "})( _wpCustomizeSettings.settings );\n"; + + // Serialize controls one by one to improve memory usage. + echo "(function ( c ){\n"; + foreach ( $this->controls() as $control ) { + if ( $control->check_capabilities() ) { + printf( + "c[%s] = %s;\n", + wp_json_encode( $control->id ), + wp_json_encode( $control->json() ) + ); + } + } + echo "})( _wpCustomizeSettings.controls );\n"; + ?> + </script> + <?php + } + + /** + * Returns a list of devices to allow previewing. + * + * @since 4.5.0 + * + * @return array List of devices with labels and default setting. + */ + public function get_previewable_devices() { + $devices = array( + 'desktop' => array( + 'label' => __( 'Enter desktop preview mode' ), + 'default' => true, + ), + 'tablet' => array( + 'label' => __( 'Enter tablet preview mode' ), + ), + 'mobile' => array( + 'label' => __( 'Enter mobile preview mode' ), + ), + ); + + /** + * Filters the available devices to allow previewing in the Customizer. + * + * @since 4.5.0 + * + * @see WP_Customize_Manager::get_previewable_devices() + * + * @param array $devices List of devices with labels and default setting. + */ + $devices = apply_filters( 'customize_previewable_devices', $devices ); + + return $devices; + } + + /** + * Register some default controls. + * + * @since 3.4.0 + */ + public function register_controls() { + + /* Themes (controls are loaded via ajax) */ + + $this->add_panel( new WP_Customize_Themes_Panel( $this, 'themes', array( + 'title' => $this->theme()->display( 'Name' ), + 'description' => ( + '<p>' . __( 'Looking for a theme? You can search or browse the WordPress.org theme directory, install and preview themes, then activate them right here.' ) . '</p>' . + '<p>' . __( 'While previewing a new theme, you can continue to tailor things like widgets and menus, and explore theme-specific options.' ) . '</p>' + ), + 'capability' => 'switch_themes', + 'priority' => 0, + ) ) ); + + $this->add_section( new WP_Customize_Themes_Section( $this, 'installed_themes', array( + 'title' => __( 'Installed themes' ), + 'action' => 'installed', + 'capability' => 'switch_themes', + 'panel' => 'themes', + 'priority' => 0, + ) ) ); + + if ( ! is_multisite() ) { + $this->add_section( new WP_Customize_Themes_Section( $this, 'wporg_themes', array( + 'title' => __( 'WordPress.org themes' ), + 'action' => 'wporg', + 'filter_type' => 'remote', + 'capability' => 'install_themes', + 'panel' => 'themes', + 'priority' => 5, + ) ) ); + } + + // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience). + $this->add_setting( new WP_Customize_Filter_Setting( $this, 'active_theme', array( + 'capability' => 'switch_themes', + ) ) ); + + /* Site Identity */ + + $this->add_section( 'title_tagline', array( + 'title' => __( 'Site Identity' ), + 'priority' => 20, + ) ); + + $this->add_setting( 'blogname', array( + 'default' => get_option( 'blogname' ), + 'type' => 'option', + 'capability' => 'manage_options', + ) ); + + $this->add_control( 'blogname', array( + 'label' => __( 'Site Title' ), + 'section' => 'title_tagline', + ) ); + + $this->add_setting( 'blogdescription', array( + 'default' => get_option( 'blogdescription' ), + 'type' => 'option', + 'capability' => 'manage_options', + ) ); + + $this->add_control( 'blogdescription', array( + 'label' => __( 'Tagline' ), + 'section' => 'title_tagline', + ) ); + + // Add a setting to hide header text if the theme doesn't support custom headers. + if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) { + $this->add_setting( 'header_text', array( + 'theme_supports' => array( 'custom-logo', 'header-text' ), + 'default' => 1, + 'sanitize_callback' => 'absint', + ) ); + + $this->add_control( 'header_text', array( + 'label' => __( 'Display Site Title and Tagline' ), + 'section' => 'title_tagline', + 'settings' => 'header_text', + 'type' => 'checkbox', + ) ); + } + + $this->add_setting( 'site_icon', array( + 'type' => 'option', + 'capability' => 'manage_options', + 'transport' => 'postMessage', // Previewed with JS in the Customizer controls window. + ) ); + + $this->add_control( new WP_Customize_Site_Icon_Control( $this, 'site_icon', array( + 'label' => __( 'Site Icon' ), + 'description' => sprintf( + '<p>' . __( 'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. Upload one here!' ) . '</p>' . + /* translators: %s: site icon size in pixels */ + '<p>' . __( 'Site Icons should be square and at least %s pixels.' ) . '</p>', + '<strong>512 × 512</strong>' + ), + 'section' => 'title_tagline', + 'priority' => 60, + 'height' => 512, + 'width' => 512, + ) ) ); + + $this->add_setting( 'custom_logo', array( + 'theme_supports' => array( 'custom-logo' ), + 'transport' => 'postMessage', + ) ); + + $custom_logo_args = get_theme_support( 'custom-logo' ); + $this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', array( + 'label' => __( 'Logo' ), + 'section' => 'title_tagline', + 'priority' => 8, + 'height' => $custom_logo_args[0]['height'], + 'width' => $custom_logo_args[0]['width'], + 'flex_height' => $custom_logo_args[0]['flex-height'], + 'flex_width' => $custom_logo_args[0]['flex-width'], + 'button_labels' => array( + 'select' => __( 'Select logo' ), + 'change' => __( 'Change logo' ), + 'remove' => __( 'Remove' ), + 'default' => __( 'Default' ), + 'placeholder' => __( 'No logo selected' ), + 'frame_title' => __( 'Select logo' ), + 'frame_button' => __( 'Choose logo' ), + ), + ) ) ); + + $this->selective_refresh->add_partial( 'custom_logo', array( + 'settings' => array( 'custom_logo' ), + 'selector' => '.custom-logo-link', + 'render_callback' => array( $this, '_render_custom_logo_partial' ), + 'container_inclusive' => true, + ) ); + + /* Colors */ + + $this->add_section( 'colors', array( + 'title' => __( 'Colors' ), + 'priority' => 40, + ) ); + + $this->add_setting( 'header_textcolor', array( + 'theme_supports' => array( 'custom-header', 'header-text' ), + 'default' => get_theme_support( 'custom-header', 'default-text-color' ), + + 'sanitize_callback' => array( $this, '_sanitize_header_textcolor' ), + 'sanitize_js_callback' => 'maybe_hash_hex_color', + ) ); + + // Input type: checkbox + // With custom value + $this->add_control( 'display_header_text', array( + 'settings' => 'header_textcolor', + 'label' => __( 'Display Site Title and Tagline' ), + 'section' => 'title_tagline', + 'type' => 'checkbox', + 'priority' => 40, + ) ); + + $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array( + 'label' => __( 'Header Text Color' ), + 'section' => 'colors', + ) ) ); + + // Input type: Color + // With sanitize_callback + $this->add_setting( 'background_color', array( + 'default' => get_theme_support( 'custom-background', 'default-color' ), + 'theme_supports' => 'custom-background', + + 'sanitize_callback' => 'sanitize_hex_color_no_hash', + 'sanitize_js_callback' => 'maybe_hash_hex_color', + ) ); + + $this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array( + 'label' => __( 'Background Color' ), + 'section' => 'colors', + ) ) ); + + /* Custom Header */ + + if ( current_theme_supports( 'custom-header', 'video' ) ) { + $title = __( 'Header Media' ); + $description = '<p>' . __( 'If you add a video, the image will be used as a fallback while the video loads.' ) . '</p>'; + + $width = absint( get_theme_support( 'custom-header', 'width' ) ); + $height = absint( get_theme_support( 'custom-header', 'height' ) ); + if ( $width && $height ) { + $control_description = sprintf( + /* translators: 1: .mp4, 2: header size in pixels */ + __( 'Upload your video in %1$s format and minimize its file size for best results. Your theme recommends dimensions of %2$s pixels.' ), + '<code>.mp4</code>', + sprintf( '<strong>%s × %s</strong>', $width, $height ) + ); + } elseif ( $width ) { + $control_description = sprintf( + /* translators: 1: .mp4, 2: header width in pixels */ + __( 'Upload your video in %1$s format and minimize its file size for best results. Your theme recommends a width of %2$s pixels.' ), + '<code>.mp4</code>', + sprintf( '<strong>%s</strong>', $width ) + ); + } else { + $control_description = sprintf( + /* translators: 1: .mp4, 2: header height in pixels */ + __( 'Upload your video in %1$s format and minimize its file size for best results. Your theme recommends a height of %2$s pixels.' ), + '<code>.mp4</code>', + sprintf( '<strong>%s</strong>', $height ) + ); + } + } else { + $title = __( 'Header Image' ); + $description = ''; + $control_description = ''; + } + + $this->add_section( 'header_image', array( + 'title' => $title, + 'description' => $description, + 'theme_supports' => 'custom-header', + 'priority' => 60, + ) ); + + $this->add_setting( 'header_video', array( + 'theme_supports' => array( 'custom-header', 'video' ), + 'transport' => 'postMessage', + 'sanitize_callback' => 'absint', + 'validate_callback' => array( $this, '_validate_header_video' ), + ) ); + + $this->add_setting( 'external_header_video', array( + 'theme_supports' => array( 'custom-header', 'video' ), + 'transport' => 'postMessage', + 'sanitize_callback' => array( $this, '_sanitize_external_header_video' ), + 'validate_callback' => array( $this, '_validate_external_header_video' ), + ) ); + + $this->add_setting( new WP_Customize_Filter_Setting( $this, 'header_image', array( + 'default' => sprintf( get_theme_support( 'custom-header', 'default-image' ), get_template_directory_uri(), get_stylesheet_directory_uri() ), + 'theme_supports' => 'custom-header', + ) ) ); + + $this->add_setting( new WP_Customize_Header_Image_Setting( $this, 'header_image_data', array( + 'theme_supports' => 'custom-header', + ) ) ); + + /* + * Switch image settings to postMessage when video support is enabled since + * it entails that the_custom_header_markup() will be used, and thus selective + * refresh can be utilized. + */ + if ( current_theme_supports( 'custom-header', 'video' ) ) { + $this->get_setting( 'header_image' )->transport = 'postMessage'; + $this->get_setting( 'header_image_data' )->transport = 'postMessage'; + } + + $this->add_control( new WP_Customize_Media_Control( $this, 'header_video', array( + 'theme_supports' => array( 'custom-header', 'video' ), + 'label' => __( 'Header Video' ), + 'description' => $control_description, + 'section' => 'header_image', + 'mime_type' => 'video', + 'active_callback' => 'is_header_video_active', + ) ) ); + + $this->add_control( 'external_header_video', array( + 'theme_supports' => array( 'custom-header', 'video' ), + 'type' => 'url', + 'description' => __( 'Or, enter a YouTube URL:' ), + 'section' => 'header_image', + 'active_callback' => 'is_header_video_active', + ) ); + + $this->add_control( new WP_Customize_Header_Image_Control( $this ) ); + + $this->selective_refresh->add_partial( 'custom_header', array( + 'selector' => '#wp-custom-header', + 'render_callback' => 'the_custom_header_markup', + 'settings' => array( 'header_video', 'external_header_video', 'header_image' ), // The image is used as a video fallback here. + 'container_inclusive' => true, + ) ); + + /* Custom Background */ + + $this->add_section( 'background_image', array( + 'title' => __( 'Background Image' ), + 'theme_supports' => 'custom-background', + 'priority' => 80, + ) ); + + $this->add_setting( 'background_image', array( + 'default' => get_theme_support( 'custom-background', 'default-image' ), + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ); + + $this->add_setting( new WP_Customize_Background_Image_Setting( $this, 'background_image_thumb', array( + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ) ); + + $this->add_control( new WP_Customize_Background_Image_Control( $this ) ); + + $this->add_setting( 'background_preset', array( + 'default' => get_theme_support( 'custom-background', 'default-preset' ), + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ); + + $this->add_control( 'background_preset', array( + 'label' => _x( 'Preset', 'Background Preset' ), + 'section' => 'background_image', + 'type' => 'select', + 'choices' => array( + 'default' => _x( 'Default', 'Default Preset' ), + 'fill' => __( 'Fill Screen' ), + 'fit' => __( 'Fit to Screen' ), + 'repeat' => _x( 'Repeat', 'Repeat Image' ), + 'custom' => _x( 'Custom', 'Custom Preset' ), + ), + ) ); + + $this->add_setting( 'background_position_x', array( + 'default' => get_theme_support( 'custom-background', 'default-position-x' ), + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ); + + $this->add_setting( 'background_position_y', array( + 'default' => get_theme_support( 'custom-background', 'default-position-y' ), + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ); + + $this->add_control( new WP_Customize_Background_Position_Control( $this, 'background_position', array( + 'label' => __( 'Image Position' ), + 'section' => 'background_image', + 'settings' => array( + 'x' => 'background_position_x', + 'y' => 'background_position_y', + ), + ) ) ); + + $this->add_setting( 'background_size', array( + 'default' => get_theme_support( 'custom-background', 'default-size' ), + 'theme_supports' => 'custom-background', + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + ) ); + + $this->add_control( 'background_size', array( + 'label' => __( 'Image Size' ), + 'section' => 'background_image', + 'type' => 'select', + 'choices' => array( + 'auto' => __( 'Original' ), + 'contain' => __( 'Fit to Screen' ), + 'cover' => __( 'Fill Screen' ), + ), + ) ); + + $this->add_setting( 'background_repeat', array( + 'default' => get_theme_support( 'custom-background', 'default-repeat' ), + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + 'theme_supports' => 'custom-background', + ) ); + + $this->add_control( 'background_repeat', array( + 'label' => __( 'Repeat Background Image' ), + 'section' => 'background_image', + 'type' => 'checkbox', + ) ); + + $this->add_setting( 'background_attachment', array( + 'default' => get_theme_support( 'custom-background', 'default-attachment' ), + 'sanitize_callback' => array( $this, '_sanitize_background_setting' ), + 'theme_supports' => 'custom-background', + ) ); + + $this->add_control( 'background_attachment', array( + 'label' => __( 'Scroll with Page' ), + 'section' => 'background_image', + 'type' => 'checkbox', + ) ); + + + // If the theme is using the default background callback, we can update + // the background CSS using postMessage. + if ( get_theme_support( 'custom-background', 'wp-head-callback' ) === '_custom_background_cb' ) { + foreach ( array( 'color', 'image', 'preset', 'position_x', 'position_y', 'size', 'repeat', 'attachment' ) as $prop ) { + $this->get_setting( 'background_' . $prop )->transport = 'postMessage'; + } + } + + /* + * Static Front Page + * See also https://core.trac.wordpress.org/ticket/19627 which introduces the static-front-page theme_support. + * The following replicates behavior from options-reading.php. + */ + + $this->add_section( 'static_front_page', array( + 'title' => __( 'Homepage Settings' ), + 'priority' => 120, + 'description' => __( 'You can choose what’s displayed on the homepage of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static homepage, you first need to create two Pages. One will become the homepage, and the other will be where your posts are displayed.' ), + 'active_callback' => array( $this, 'has_published_pages' ), + ) ); + + $this->add_setting( 'show_on_front', array( + 'default' => get_option( 'show_on_front' ), + 'capability' => 'manage_options', + 'type' => 'option', + ) ); + + $this->add_control( 'show_on_front', array( + 'label' => __( 'Your homepage displays' ), + 'section' => 'static_front_page', + 'type' => 'radio', + 'choices' => array( + 'posts' => __( 'Your latest posts' ), + 'page' => __( 'A static page' ), + ), + ) ); + + $this->add_setting( 'page_on_front', array( + 'type' => 'option', + 'capability' => 'manage_options', + ) ); + + $this->add_control( 'page_on_front', array( + 'label' => __( 'Homepage' ), + 'section' => 'static_front_page', + 'type' => 'dropdown-pages', + 'allow_addition' => true, + ) ); + + $this->add_setting( 'page_for_posts', array( + 'type' => 'option', + 'capability' => 'manage_options', + ) ); + + $this->add_control( 'page_for_posts', array( + 'label' => __( 'Posts page' ), + 'section' => 'static_front_page', + 'type' => 'dropdown-pages', + 'allow_addition' => true, + ) ); + + /* Custom CSS */ + $section_description = '<p>'; + $section_description .= __( 'Add your own CSS code here to customize the appearance and layout of your site.' ); + $section_description .= sprintf( + ' <a href="%1$s" class="external-link" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span></a>', + esc_url( __( 'https://codex.wordpress.org/CSS' ) ), + __( 'Learn more about CSS' ), + /* translators: accessibility text */ + __( '(opens in a new window)' ) + ); + $section_description .= '</p>'; + + $section_description .= '<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>'; + $section_description .= '<ul>'; + $section_description .= '<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>'; + $section_description .= '<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>'; + $section_description .= '<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the escape key twice.' ) . '</li>'; + $section_description .= '</ul>'; + + if ( 'false' !== wp_get_current_user()->syntax_highlighting ) { + $section_description .= '<p>'; + $section_description .= sprintf( + /* translators: 1: link to user profile, 2: additional link attributes, 3: accessibility text */ + __( 'The edit field automatically highlights code syntax. You can disable this in your <a href="%1$s" %2$s>user profile%3$s</a> to work in plain text mode.' ), + esc_url( get_edit_profile_url() ), + 'class="external-link" target="_blank"', + sprintf( '<span class="screen-reader-text"> %s</span>', + /* translators: accessibility text */ + __( '(opens in a new window)' ) + ) + ); + $section_description .= '</p>'; + } + + $section_description .= '<p class="section-description-buttons">'; + $section_description .= '<button type="button" class="button-link section-description-close">' . __( 'Close' ) . '</button>'; + $section_description .= '</p>'; + + $this->add_section( 'custom_css', array( + 'title' => __( 'Additional CSS' ), + 'priority' => 200, + 'description_hidden' => true, + 'description' => $section_description, + ) ); + + $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array( + 'capability' => 'edit_css', + 'default' => '', + ) ); + $this->add_setting( $custom_css_setting ); + + $this->add_control( new WP_Customize_Code_Editor_Control( $this, 'custom_css', array( + 'label' => __( 'CSS code' ), + 'section' => 'custom_css', + 'settings' => array( 'default' => $custom_css_setting->id ), + 'code_type' => 'text/css', + 'input_attrs' => array( + 'aria-describedby' => 'editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4', + ), + ) ) ); + } + + /** + * Return whether there are published pages. + * + * Used as active callback for static front page section and controls. + * + * @since 4.7.0 + * + * @returns bool Whether there are published (or to be published) pages. + */ + public function has_published_pages() { + + $setting = $this->get_setting( 'nav_menus_created_posts' ); + if ( $setting ) { + foreach ( $setting->value() as $post_id ) { + if ( 'page' === get_post_type( $post_id ) ) { + return true; + } + } + } + return 0 !== count( get_pages() ); + } + + /** + * Add settings from the POST data that were not added with code, e.g. dynamically-created settings for Widgets + * + * @since 4.2.0 + * + * @see add_dynamic_settings() + */ + public function register_dynamic_settings() { + $setting_ids = array_keys( $this->unsanitized_post_values() ); + $this->add_dynamic_settings( $setting_ids ); + } + + /** + * Load themes into the theme browsing/installation UI. + * + * @since 4.9.0 + */ + public function handle_load_themes_request() { + check_ajax_referer( 'switch_themes', 'nonce' ); + + if ( ! current_user_can( 'switch_themes' ) ) { + wp_die( -1 ); + } + + if ( empty( $_POST['theme_action'] ) ) { + wp_send_json_error( 'missing_theme_action' ); + } + $theme_action = sanitize_key( $_POST['theme_action'] ); + $themes = array(); + $args = array(); + + // Define query filters based on user input. + if ( ! array_key_exists( 'search', $_POST ) ) { + $args['search'] = ''; + } else { + $args['search'] = sanitize_text_field( wp_unslash( $_POST['search'] ) ); + } + + if ( ! array_key_exists( 'tags', $_POST ) ) { + $args['tag'] = ''; + } else { + $args['tag'] = array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['tags'] ) ); + } + + if ( ! array_key_exists( 'page', $_POST ) ) { + $args['page'] = 1; + } else { + $args['page'] = absint( $_POST['page'] ); + } + + require_once ABSPATH . 'wp-admin/includes/theme.php'; + + if ( 'installed' === $theme_action ) { + + // Load all installed themes from wp_prepare_themes_for_js(). + $themes = array( 'themes' => wp_prepare_themes_for_js() ); + foreach ( $themes['themes'] as &$theme ) { + $theme['type'] = 'installed'; + $theme['active'] = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] ); + } + + } elseif ( 'wporg' === $theme_action ) { + + // Load WordPress.org themes from the .org API and normalize data to match installed theme objects. + if ( ! current_user_can( 'install_themes' ) ) { + wp_die( -1 ); + } + + // Arguments for all queries. + $wporg_args = array( + 'per_page' => 100, + 'fields' => array( + 'screenshot_url' => true, + 'description' => true, + 'rating' => true, + 'downloaded' => true, + 'downloadlink' => true, + 'last_updated' => true, + 'homepage' => true, + 'num_ratings' => true, + 'tags' => true, + 'parent' => true, + // 'extended_author' => true, @todo: WordPress.org throws a 500 server error when this is here. + ), + ); + + $args = array_merge( $wporg_args, $args ); + + if ( '' === $args['search'] && '' === $args['tag'] ) { + $args['browse'] = 'new'; // Sort by latest themes by default. + } + + // Load themes from the .org API. + $themes = themes_api( 'query_themes', $args ); + if ( is_wp_error( $themes ) ) { + wp_send_json_error(); + } + + // This list matches the allowed tags in wp-admin/includes/theme-install.php. + $themes_allowedtags = array_fill_keys( + array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ), + array() + ); + $themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true ); + $themes_allowedtags['acronym']['title'] = true; + $themes_allowedtags['abbr']['title'] = true; + $themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true ); + + // Prepare a list of installed themes to check against before the loop. + $installed_themes = array(); + $wp_themes = wp_get_themes(); + foreach ( $wp_themes as $theme ) { + $installed_themes[] = $theme->get_stylesheet(); + } + $update_php = network_admin_url( 'update.php?action=install-theme' ); + + // Set up properties for themes available on WordPress.org. + foreach ( $themes->themes as &$theme ) { + $theme->install_url = add_query_arg( array( + 'theme' => $theme->slug, + '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ), + ), $update_php ); + + $theme->name = wp_kses( $theme->name, $themes_allowedtags ); + $theme->author = wp_kses( $theme->author, $themes_allowedtags ); + $theme->version = wp_kses( $theme->version, $themes_allowedtags ); + $theme->description = wp_kses( $theme->description, $themes_allowedtags ); + $theme->tags = implode( ', ', $theme->tags ); + $theme->stars = wp_star_rating( array( + 'rating' => $theme->rating, + 'type' => 'percent', + 'number' => $theme->num_ratings, + 'echo' => false, + ) ); + $theme->num_ratings = number_format_i18n( $theme->num_ratings ); + $theme->preview_url = set_url_scheme( $theme->preview_url ); + + // Handle themes that are already installed as installed themes. + if ( in_array( $theme->slug, $installed_themes, true ) ) { + $theme->type = 'installed'; + } else { + $theme->type = $theme_action; + } + + // Set active based on customized theme. + $theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug ); + + // Map available theme properties to installed theme properties. + $theme->id = $theme->slug; + $theme->screenshot = array( $theme->screenshot_url ); + $theme->authorAndUri = $theme->author; + // The .org API can return the full parent theme details if passed the 'parent' arg, or if passed the 'template' option it'll return that in the event it's a child theme. + if ( isset( $theme->parent ) ) { + $theme->parent = $theme->parent['slug']; + } else { + $theme->parent = false; + } + unset( $theme->slug ); + unset( $theme->screenshot_url ); + unset( $theme->author ); + } // End foreach(). + } // End if(). + + /** + * Filters the theme data loaded in the customizer. + * + * This allows theme data to be loading from an external source, + * or modification of data loaded from `wp_prepare_themes_for_js()` + * or WordPress.org via `themes_api()`. + * + * @since 4.9.0 + * + * @see wp_prepare_themes_for_js() + * @see themes_api() + * @see WP_Customize_Manager::__construct() + * + * @param array $themes Nested array of theme data. + * @param array $args List of arguments, such as page, search term, and tags to query for. + * @param WP_Customize_Manager $manager Instance of Customize manager. + */ + $themes = apply_filters( 'customize_load_themes', $themes, $args, $this ); + + wp_send_json_success( $themes ); + } + + + /** + * Callback for validating the header_textcolor value. + * + * Accepts 'blank', and otherwise uses sanitize_hex_color_no_hash(). + * Returns default text color if hex color is empty. + * + * @since 3.4.0 + * + * @param string $color + * @return mixed + */ + public function _sanitize_header_textcolor( $color ) { + if ( 'blank' === $color ) + return 'blank'; + + $color = sanitize_hex_color_no_hash( $color ); + if ( empty( $color ) ) + $color = get_theme_support( 'custom-header', 'default-text-color' ); + + return $color; + } + + /** + * Callback for validating a background setting value. + * + * @since 4.7.0 + * + * @param string $value Repeat value. + * @param WP_Customize_Setting $setting Setting. + * @return string|WP_Error Background value or validation error. + */ + public function _sanitize_background_setting( $value, $setting ) { + if ( 'background_repeat' === $setting->id ) { + if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ) ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background repeat.' ) ); + } + } elseif ( 'background_attachment' === $setting->id ) { + if ( ! in_array( $value, array( 'fixed', 'scroll' ) ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background attachment.' ) ); + } + } elseif ( 'background_position_x' === $setting->id ) { + if ( ! in_array( $value, array( 'left', 'center', 'right' ), true ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background position X.' ) ); + } + } elseif ( 'background_position_y' === $setting->id ) { + if ( ! in_array( $value, array( 'top', 'center', 'bottom' ), true ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background position Y.' ) ); + } + } elseif ( 'background_size' === $setting->id ) { + if ( ! in_array( $value, array( 'auto', 'contain', 'cover' ), true ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); + } + } elseif ( 'background_preset' === $setting->id ) { + if ( ! in_array( $value, array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); + } + } elseif ( 'background_image' === $setting->id || 'background_image_thumb' === $setting->id ) { + $value = empty( $value ) ? '' : esc_url_raw( $value ); + } else { + return new WP_Error( 'unrecognized_setting', __( 'Unrecognized background setting.' ) ); + } + return $value; + } + + /** + * Export header video settings to facilitate selective refresh. + * + * @since 4.7.0 + * + * @param array $response Response. + * @param WP_Customize_Selective_Refresh $selective_refresh Selective refresh component. + * @param array $partials Array of partials. + * @return array + */ + public function export_header_video_settings( $response, $selective_refresh, $partials ) { + if ( isset( $partials['custom_header'] ) ) { + $response['custom_header_settings'] = get_header_video_settings(); + } + + return $response; + } + + /** + * Callback for validating the header_video value. + * + * Ensures that the selected video is less than 8MB and provides an error message. + * + * @since 4.7.0 + * + * @param WP_Error $validity + * @param mixed $value + * @return mixed + */ + public function _validate_header_video( $validity, $value ) { + $video = get_attached_file( absint( $value ) ); + if ( $video ) { + $size = filesize( $video ); + if ( 8 < $size / pow( 1024, 2 ) ) { // Check whether the size is larger than 8MB. + $validity->add( 'size_too_large', + __( 'This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.' ) + ); + } + if ( '.mp4' !== substr( $video, -4 ) && '.mov' !== substr( $video, -4 ) ) { // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats. + $validity->add( 'invalid_file_type', sprintf( + /* translators: 1: .mp4, 2: .mov */ + __( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ), + '<code>.mp4</code>', + '<code>.mov</code>' + ) ); + } + } + return $validity; + } + + /** + * Callback for validating the external_header_video value. + * + * Ensures that the provided URL is supported. + * + * @since 4.7.0 + * + * @param WP_Error $validity + * @param mixed $value + * @return mixed + */ + public function _validate_external_header_video( $validity, $value ) { + $video = esc_url_raw( $value ); + if ( $video ) { + if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video ) ) { + $validity->add( 'invalid_url', __( 'Please enter a valid YouTube URL.' ) ); + } + } + return $validity; + } + + /** + * Callback for sanitizing the external_header_video value. + * + * @since 4.7.1 + * + * @param string $value URL. + * @return string Sanitized URL. + */ + public function _sanitize_external_header_video( $value ) { + return esc_url_raw( trim( $value ) ); + } + + /** + * Callback for rendering the custom logo, used in the custom_logo partial. + * + * This method exists because the partial object and context data are passed + * into a partial's render_callback so we cannot use get_custom_logo() as + * the render_callback directly since it expects a blog ID as the first + * argument. When WP no longer supports PHP 5.3, this method can be removed + * in favor of an anonymous function. + * + * @see WP_Customize_Manager::register_controls() + * + * @since 4.5.0 + * + * @return string Custom logo. + */ + public function _render_custom_logo_partial() { + return get_custom_logo(); + } +} diff --git a/backend/wp-includes/class-wp-customize-nav-menus.php b/backend/wp-includes/class-wp-customize-nav-menus.php new file mode 100644 index 0000000..7326ae8 --- /dev/null +++ b/backend/wp-includes/class-wp-customize-nav-menus.php @@ -0,0 +1,1440 @@ +<?php +/** + * WordPress Customize Nav Menus classes + * + * @package WordPress + * @subpackage Customize + * @since 4.3.0 + */ + +/** + * Customize Nav Menus class. + * + * Implements menu management in the Customizer. + * + * @since 4.3.0 + * + * @see WP_Customize_Manager + */ +final class WP_Customize_Nav_Menus { + + /** + * WP_Customize_Manager instance. + * + * @since 4.3.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * Original nav menu locations before the theme was switched. + * + * @since 4.9.0 + * @var array + */ + protected $original_nav_menu_locations; + + /** + * Constructor. + * + * @since 4.3.0 + * + * @param object $manager An instance of the WP_Customize_Manager class. + */ + public function __construct( $manager ) { + $this->manager = $manager; + $this->original_nav_menu_locations = get_nav_menu_locations(); + + // See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L469-L499 + add_action( 'customize_register', array( $this, 'customize_register' ), 11 ); + add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 ); + add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 ); + add_action( 'customize_save_nav_menus_created_posts', array( $this, 'save_nav_menus_created_posts' ) ); + + // Skip remaining hooks when the user can't manage nav menus anyway. + if ( ! current_user_can( 'edit_theme_options' ) ) { + return; + } + + add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) ); + add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) ); + add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) ); + add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $this, 'ajax_insert_auto_draft_post' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) ); + add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) ); + add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) ); + + // Selective Refresh partials. + add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 ); + } + + /** + * Adds a nonce for customizing menus. + * + * @since 4.5.0 + * + * @param array $nonces Array of nonces. + * @return array $nonces Modified array of nonces. + */ + public function filter_nonces( $nonces ) { + $nonces['customize-menus'] = wp_create_nonce( 'customize-menus' ); + return $nonces; + } + + /** + * Ajax handler for loading available menu items. + * + * @since 4.3.0 + */ + public function ajax_load_available_items() { + check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_die( -1 ); + } + + $all_items = array(); + $item_types = array(); + if ( isset( $_POST['item_types'] ) && is_array( $_POST['item_types'] ) ) { + $item_types = wp_unslash( $_POST['item_types'] ); + } elseif ( isset( $_POST['type'] ) && isset( $_POST['object'] ) ) { // Back compat. + $item_types[] = array( + 'type' => wp_unslash( $_POST['type'] ), + 'object' => wp_unslash( $_POST['object'] ), + 'page' => empty( $_POST['page'] ) ? 0 : absint( $_POST['page'] ), + ); + } else { + wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' ); + } + + foreach ( $item_types as $item_type ) { + if ( empty( $item_type['type'] ) || empty( $item_type['object'] ) ) { + wp_send_json_error( 'nav_menus_missing_type_or_object_parameter' ); + } + $type = sanitize_key( $item_type['type'] ); + $object = sanitize_key( $item_type['object'] ); + $page = empty( $item_type['page'] ) ? 0 : absint( $item_type['page'] ); + $items = $this->load_available_items_query( $type, $object, $page ); + if ( is_wp_error( $items ) ) { + wp_send_json_error( $items->get_error_code() ); + } + $all_items[ $item_type['type'] . ':' . $item_type['object'] ] = $items; + } + + wp_send_json_success( array( 'items' => $all_items ) ); + } + + /** + * Performs the post_type and taxonomy queries for loading available menu items. + * + * @since 4.3.0 + * + * @param string $type Optional. Accepts any custom object type and has built-in support for + * 'post_type' and 'taxonomy'. Default is 'post_type'. + * @param string $object Optional. Accepts any registered taxonomy or post type name. Default is 'page'. + * @param int $page Optional. The page number used to generate the query offset. Default is '0'. + * @return WP_Error|array Returns either a WP_Error object or an array of menu items. + */ + public function load_available_items_query( $type = 'post_type', $object = 'page', $page = 0 ) { + $items = array(); + + if ( 'post_type' === $type ) { + $post_type = get_post_type_object( $object ); + if ( ! $post_type ) { + return new WP_Error( 'nav_menus_invalid_post_type' ); + } + + if ( 0 === $page && 'page' === $object ) { + // Add "Home" link. Treat as a page, but switch to custom on add. + $items[] = array( + 'id' => 'home', + 'title' => _x( 'Home', 'nav menu home label' ), + 'type' => 'custom', + 'type_label' => __( 'Custom Link' ), + 'object' => '', + 'url' => home_url(), + ); + } elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) { + // Add a post type archive link. + $items[] = array( + 'id' => $object . '-archive', + 'title' => $post_type->labels->archives, + 'type' => 'post_type_archive', + 'type_label' => __( 'Post Type Archive' ), + 'object' => $object, + 'url' => get_post_type_archive_link( $object ), + ); + } + + // Prepend posts with nav_menus_created_posts on first page. + $posts = array(); + if ( 0 === $page && $this->manager->get_setting( 'nav_menus_created_posts' ) ) { + foreach ( $this->manager->get_setting( 'nav_menus_created_posts' )->value() as $post_id ) { + $auto_draft_post = get_post( $post_id ); + if ( $post_type->name === $auto_draft_post->post_type ) { + $posts[] = $auto_draft_post; + } + } + } + + $posts = array_merge( $posts, get_posts( array( + 'numberposts' => 10, + 'offset' => 10 * $page, + 'orderby' => 'date', + 'order' => 'DESC', + 'post_type' => $object, + ) ) ); + + foreach ( $posts as $post ) { + $post_title = $post->post_title; + if ( '' === $post_title ) { + /* translators: %d: ID of a post */ + $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); + } + $items[] = array( + 'id' => "post-{$post->ID}", + 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'type' => 'post_type', + 'type_label' => get_post_type_object( $post->post_type )->labels->singular_name, + 'object' => $post->post_type, + 'object_id' => intval( $post->ID ), + 'url' => get_permalink( intval( $post->ID ) ), + ); + } + } elseif ( 'taxonomy' === $type ) { + $terms = get_terms( $object, array( + 'child_of' => 0, + 'exclude' => '', + 'hide_empty' => false, + 'hierarchical' => 1, + 'include' => '', + 'number' => 10, + 'offset' => 10 * $page, + 'order' => 'DESC', + 'orderby' => 'count', + 'pad_counts' => false, + ) ); + if ( is_wp_error( $terms ) ) { + return $terms; + } + + foreach ( $terms as $term ) { + $items[] = array( + 'id' => "term-{$term->term_id}", + 'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'type' => 'taxonomy', + 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, + 'object' => $term->taxonomy, + 'object_id' => intval( $term->term_id ), + 'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), + ); + } + } + + /** + * Filters the available menu items. + * + * @since 4.3.0 + * + * @param array $items The array of menu items. + * @param string $type The object type. + * @param string $object The object name. + * @param int $page The current page number. + */ + $items = apply_filters( 'customize_nav_menu_available_items', $items, $type, $object, $page ); + + return $items; + } + + /** + * Ajax handler for searching available menu items. + * + * @since 4.3.0 + */ + public function ajax_search_available_items() { + check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_die( -1 ); + } + + if ( empty( $_POST['search'] ) ) { + wp_send_json_error( 'nav_menus_missing_search_parameter' ); + } + + $p = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 0; + if ( $p < 1 ) { + $p = 1; + } + + $s = sanitize_text_field( wp_unslash( $_POST['search'] ) ); + $items = $this->search_available_items_query( array( 'pagenum' => $p, 's' => $s ) ); + + if ( empty( $items ) ) { + wp_send_json_error( array( 'message' => __( 'No results found.' ) ) ); + } else { + wp_send_json_success( array( 'items' => $items ) ); + } + } + + /** + * Performs post queries for available-item searching. + * + * Based on WP_Editor::wp_link_query(). + * + * @since 4.3.0 + * + * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. + * @return array Menu items. + */ + public function search_available_items_query( $args = array() ) { + $items = array(); + + $post_type_objects = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' ); + $query = array( + 'post_type' => array_keys( $post_type_objects ), + 'suppress_filters' => true, + 'update_post_term_cache' => false, + 'update_post_meta_cache' => false, + 'post_status' => 'publish', + 'posts_per_page' => 20, + ); + + $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; + $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; + + if ( isset( $args['s'] ) ) { + $query['s'] = $args['s']; + } + + $posts = array(); + + // Prepend list of posts with nav_menus_created_posts search results on first page. + $nav_menus_created_posts_setting = $this->manager->get_setting( 'nav_menus_created_posts' ); + if ( 1 === $args['pagenum'] && $nav_menus_created_posts_setting && count( $nav_menus_created_posts_setting ) > 0 ) { + $stub_post_query = new WP_Query( array_merge( + $query, + array( + 'post_status' => 'auto-draft', + 'post__in' => $nav_menus_created_posts_setting->value(), + 'posts_per_page' => -1, + ) + ) ); + $posts = array_merge( $posts, $stub_post_query->posts ); + } + + // Query posts. + $get_posts = new WP_Query( $query ); + $posts = array_merge( $posts, $get_posts->posts ); + + // Create items for posts. + foreach ( $posts as $post ) { + $post_title = $post->post_title; + if ( '' === $post_title ) { + /* translators: %d: ID of a post */ + $post_title = sprintf( __( '#%d (no title)' ), $post->ID ); + } + $items[] = array( + 'id' => 'post-' . $post->ID, + 'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'type' => 'post_type', + 'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name, + 'object' => $post->post_type, + 'object_id' => intval( $post->ID ), + 'url' => get_permalink( intval( $post->ID ) ), + ); + } + + // Query taxonomy terms. + $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' ); + $terms = get_terms( $taxonomies, array( + 'name__like' => $args['s'], + 'number' => 20, + 'offset' => 20 * ($args['pagenum'] - 1), + ) ); + + // Check if any taxonomies were found. + if ( ! empty( $terms ) ) { + foreach ( $terms as $term ) { + $items[] = array( + 'id' => 'term-' . $term->term_id, + 'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'type' => 'taxonomy', + 'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name, + 'object' => $term->taxonomy, + 'object_id' => intval( $term->term_id ), + 'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ), + ); + } + } + + // Add "Home" link if search term matches. Treat as a page, but switch to custom on add. + if ( isset( $args['s'] ) ) { + $title = _x( 'Home', 'nav menu home label' ); + $matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] ); + if ( $matches ) { + $items[] = array( + 'id' => 'home', + 'title' => $title, + 'type' => 'custom', + 'type_label' => __( 'Custom Link' ), + 'object' => '', + 'url' => home_url(), + ); + } + } + + /** + * Filters the available menu items during a search request. + * + * @since 4.5.0 + * + * @param array $items The array of menu items. + * @param array $args Includes 'pagenum' and 's' (search) arguments. + */ + $items = apply_filters( 'customize_nav_menu_searched_items', $items, $args ); + + return $items; + } + + /** + * Enqueue scripts and styles for Customizer pane. + * + * @since 4.3.0 + */ + public function enqueue_scripts() { + wp_enqueue_style( 'customize-nav-menus' ); + wp_enqueue_script( 'customize-nav-menus' ); + + $temp_nav_menu_setting = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' ); + $temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' ); + + $num_locations = count( get_registered_nav_menus() ); + if ( 1 === $num_locations ) { + $locations_description = __( 'Your theme can display menus in one location.' ); + } else { + /* translators: %s: number of menu locations */ + $locations_description = sprintf( _n( 'Your theme can display menus in %s location.', 'Your theme can display menus in %s locations.', $num_locations ), number_format_i18n( $num_locations ) ); + } + + // Pass data to JS. + $settings = array( + 'allMenus' => wp_get_nav_menus(), + 'itemTypes' => $this->available_item_types(), + 'l10n' => array( + 'untitled' => _x( '(no label)', 'missing menu item navigation label' ), + 'unnamed' => _x( '(unnamed)', 'Missing menu name.' ), + 'custom_label' => __( 'Custom Link' ), + 'page_label' => get_post_type_object( 'page' )->labels->singular_name, + /* translators: %s: menu location */ + 'menuLocation' => _x( '(Currently set to: %s)', 'menu' ), + 'locationsTitle' => 1 === $num_locations ? __( 'Menu Location' ) : __( 'Menu Locations' ), + 'locationsDescription' => $locations_description, + 'menuNameLabel' => __( 'Menu Name' ), + 'newMenuNameDescription' => __( 'If your theme has multiple menus, giving them clear names will help you manage them.' ), + 'itemAdded' => __( 'Menu item added' ), + 'itemDeleted' => __( 'Menu item deleted' ), + 'menuAdded' => __( 'Menu created' ), + 'menuDeleted' => __( 'Menu deleted' ), + 'movedUp' => __( 'Menu item moved up' ), + 'movedDown' => __( 'Menu item moved down' ), + 'movedLeft' => __( 'Menu item moved out of submenu' ), + 'movedRight' => __( 'Menu item is now a sub-item' ), + /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ + 'customizingMenus' => sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ), + /* translators: %s: title of menu item which is invalid */ + 'invalidTitleTpl' => __( '%s (Invalid)' ), + /* translators: %s: title of menu item in draft status */ + 'pendingTitleTpl' => __( '%s (Pending)' ), + 'itemsFound' => __( 'Number of items found: %d' ), + 'itemsFoundMore' => __( 'Additional items found: %d' ), + 'itemsLoadingMore' => __( 'Loading more results... please wait.' ), + 'reorderModeOn' => __( 'Reorder mode enabled' ), + 'reorderModeOff' => __( 'Reorder mode closed' ), + 'reorderLabelOn' => esc_attr__( 'Reorder menu items' ), + 'reorderLabelOff' => esc_attr__( 'Close reorder mode' ), + ), + 'settingTransport' => 'postMessage', + 'phpIntMax' => PHP_INT_MAX, + 'defaultSettingValues' => array( + 'nav_menu' => $temp_nav_menu_setting->default, + 'nav_menu_item' => $temp_nav_menu_item_setting->default, + ), + 'locationSlugMappedToName' => get_registered_nav_menus(), + ); + + $data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) ); + wp_scripts()->add_data( 'customize-nav-menus', 'data', $data ); + + // This is copied from nav-menus.php, and it has an unfortunate object name of `menus`. + $nav_menus_l10n = array( + 'oneThemeLocationNoMenus' => null, + 'moveUp' => __( 'Move up one' ), + 'moveDown' => __( 'Move down one' ), + 'moveToTop' => __( 'Move to the top' ), + /* translators: %s: previous item name */ + 'moveUnder' => __( 'Move under %s' ), + /* translators: %s: previous item name */ + 'moveOutFrom' => __( 'Move out from under %s' ), + /* translators: %s: previous item name */ + 'under' => __( 'Under %s' ), + /* translators: %s: previous item name */ + 'outFrom' => __( 'Out from under %s' ), + /* translators: 1: item name, 2: item position, 3: total number of items */ + 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), + /* translators: 1: item name, 2: item position, 3: parent item name */ + 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), + ); + wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); + } + + /** + * Filters a dynamic setting's constructor args. + * + * For a dynamic setting to be registered, this filter must be employed + * to override the default false value with an array of args to pass to + * the WP_Customize_Setting constructor. + * + * @since 4.3.0 + * + * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + * @return array|false + */ + public function filter_dynamic_setting_args( $setting_args, $setting_id ) { + if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) { + $setting_args = array( + 'type' => WP_Customize_Nav_Menu_Setting::TYPE, + 'transport' => 'postMessage', + ); + } elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) { + $setting_args = array( + 'type' => WP_Customize_Nav_Menu_Item_Setting::TYPE, + 'transport' => 'postMessage', + ); + } + return $setting_args; + } + + /** + * Allow non-statically created settings to be constructed with custom WP_Customize_Setting subclass. + * + * @since 4.3.0 + * + * @param string $setting_class WP_Customize_Setting or a subclass. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + * @param array $setting_args WP_Customize_Setting or a subclass. + * @return string + */ + public function filter_dynamic_setting_class( $setting_class, $setting_id, $setting_args ) { + unset( $setting_id ); + + if ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Setting::TYPE === $setting_args['type'] ) { + $setting_class = 'WP_Customize_Nav_Menu_Setting'; + } elseif ( ! empty( $setting_args['type'] ) && WP_Customize_Nav_Menu_Item_Setting::TYPE === $setting_args['type'] ) { + $setting_class = 'WP_Customize_Nav_Menu_Item_Setting'; + } + return $setting_class; + } + + /** + * Add the customizer settings and controls. + * + * @since 4.3.0 + */ + public function customize_register() { + $changeset = $this->manager->unsanitized_post_values(); + + // Preview settings for nav menus early so that the sections and controls will be added properly. + $nav_menus_setting_ids = array(); + foreach ( array_keys( $changeset ) as $setting_id ) { + if ( preg_match( '/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id ) ) { + $nav_menus_setting_ids[] = $setting_id; + } + } + $settings = $this->manager->add_dynamic_settings( $nav_menus_setting_ids ); + if ( $this->manager->settings_previewed() ) { + foreach ( $settings as $setting ) { + $setting->preview(); + } + } + + // Require JS-rendered control types. + $this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' ); + $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' ); + $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' ); + $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Locations_Control' ); + $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' ); + $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' ); + + // Create a panel for Menus. + $description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>'; + if ( current_theme_supports( 'widgets' ) ) { + /* translators: URL to the widgets panel of the customizer */ + $description .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a “Navigation Menu” widget.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>'; + } else { + $description .= '<p>' . __( 'Menus can be displayed in locations defined by your theme.' ) . '</p>'; + } + $this->manager->add_panel( new WP_Customize_Nav_Menus_Panel( $this->manager, 'nav_menus', array( + 'title' => __( 'Menus' ), + 'description' => $description, + 'priority' => 100, + // 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports + ) ) ); + $menus = wp_get_nav_menus(); + + // Menu locations. + $locations = get_registered_nav_menus(); + $num_locations = count( $locations ); + if ( 1 == $num_locations ) { + $description = '<p>' . __( 'Your theme can display menus in one location. Select which menu you would like to use.' ) . '</p>'; + } else { + /* translators: %s: number of menu locations */ + $description = '<p>' . sprintf( _n( 'Your theme can display menus in %s location. Select which menu you would like to use.', 'Your theme can display menus in %s locations. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>'; + } + + if ( current_theme_supports( 'widgets' ) ) { + /* translators: URL to the widgets panel of the customizer */ + $description .= '<p>' . sprintf( __( 'If your theme has widget areas, you can also add menus there. Visit the <a href="%s">Widgets panel</a> and add a “Navigation Menu widget” to display a menu in a sidebar or footer.' ), "javascript:wp.customize.panel( 'widgets' ).focus();" ) . '</p>'; + } + + $this->manager->add_section( 'menu_locations', array( + 'title' => 1 === $num_locations ? _x( 'View Location', 'menu locations' ) : _x( 'View All Locations', 'menu locations' ), + 'panel' => 'nav_menus', + 'priority' => 30, + 'description' => $description, + ) ); + + $choices = array( '0' => __( '— Select —' ) ); + foreach ( $menus as $menu ) { + $choices[ $menu->term_id ] = wp_html_excerpt( $menu->name, 40, '…' ); + } + + // Attempt to re-map the nav menu location assignments when previewing a theme switch. + $mapped_nav_menu_locations = array(); + if ( ! $this->manager->is_theme_active() ) { + $theme_mods = get_option( 'theme_mods_' . $this->manager->get_stylesheet(), array() ); + + // If there is no data from a previous activation, start fresh. + if ( empty( $theme_mods['nav_menu_locations'] ) ) { + $theme_mods['nav_menu_locations'] = array(); + } + + $mapped_nav_menu_locations = wp_map_nav_menu_locations( $theme_mods['nav_menu_locations'], $this->original_nav_menu_locations ); + } + + foreach ( $locations as $location => $description ) { + $setting_id = "nav_menu_locations[{$location}]"; + + $setting = $this->manager->get_setting( $setting_id ); + if ( $setting ) { + $setting->transport = 'postMessage'; + remove_filter( "customize_sanitize_{$setting_id}", 'absint' ); + add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) ); + } else { + $this->manager->add_setting( $setting_id, array( + 'sanitize_callback' => array( $this, 'intval_base10' ), + 'theme_supports' => 'menus', + 'type' => 'theme_mod', + 'transport' => 'postMessage', + 'default' => 0, + ) ); + } + + // Override the assigned nav menu location if mapped during previewed theme switch. + if ( empty( $changeset[ $setting_id ] ) && isset( $mapped_nav_menu_locations[ $location ] ) ) { + $this->manager->set_post_value( $setting_id, $mapped_nav_menu_locations[ $location ] ); + } + + $this->manager->add_control( new WP_Customize_Nav_Menu_Location_Control( $this->manager, $setting_id, array( + 'label' => $description, + 'location_id' => $location, + 'section' => 'menu_locations', + 'choices' => $choices, + ) ) ); + } + + // Register each menu as a Customizer section, and add each menu item to each menu. + foreach ( $menus as $menu ) { + $menu_id = $menu->term_id; + + // Create a section for each menu. + $section_id = 'nav_menu[' . $menu_id . ']'; + $this->manager->add_section( new WP_Customize_Nav_Menu_Section( $this->manager, $section_id, array( + 'title' => html_entity_decode( $menu->name, ENT_QUOTES, get_bloginfo( 'charset' ) ), + 'priority' => 10, + 'panel' => 'nav_menus', + ) ) ); + + $nav_menu_setting_id = 'nav_menu[' . $menu_id . ']'; + $this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id, array( + 'transport' => 'postMessage', + ) ) ); + + // Add the menu contents. + $menu_items = (array) wp_get_nav_menu_items( $menu_id ); + + foreach ( array_values( $menu_items ) as $i => $item ) { + + // Create a setting for each menu item (which doesn't actually manage data, currently). + $menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']'; + + $value = (array) $item; + if ( empty( $value['post_title'] ) ) { + $value['title'] = ''; + } + + $value['nav_menu_term_id'] = $menu_id; + $this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array( + 'value' => $value, + 'transport' => 'postMessage', + ) ) ); + + // Create a control for each menu item. + $this->manager->add_control( new WP_Customize_Nav_Menu_Item_Control( $this->manager, $menu_item_setting_id, array( + 'label' => $item->title, + 'section' => $section_id, + 'priority' => 10 + $i, + ) ) ); + } + + // Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function. + } + + // Add the add-new-menu section and controls. + $this->manager->add_section( 'add_menu', array( + 'type' => 'new_menu', + 'title' => __( 'New Menu' ), + 'panel' => 'nav_menus', + 'priority' => 20, + ) ); + + $this->manager->add_setting( new WP_Customize_Filter_Setting( $this->manager, 'nav_menus_created_posts', array( + 'transport' => 'postMessage', + 'type' => 'option', // To prevent theme prefix in changeset. + 'default' => array(), + 'sanitize_callback' => array( $this, 'sanitize_nav_menus_created_posts' ), + ) ) ); + } + + /** + * Get the base10 intval. + * + * This is used as a setting's sanitize_callback; we can't use just plain + * intval because the second argument is not what intval() expects. + * + * @since 4.3.0 + * + * @param mixed $value Number to convert. + * @return int Integer. + */ + public function intval_base10( $value ) { + return intval( $value, 10 ); + } + + /** + * Return an array of all the available item types. + * + * @since 4.3.0 + * @since 4.7.0 Each array item now includes a `$type_label` in addition to `$title`, `$type`, and `$object`. + * + * @return array The available menu item types. + */ + public function available_item_types() { + $item_types = array(); + + $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' ); + if ( $post_types ) { + foreach ( $post_types as $slug => $post_type ) { + $item_types[] = array( + 'title' => $post_type->labels->name, + 'type_label' => $post_type->labels->singular_name, + 'type' => 'post_type', + 'object' => $post_type->name, + ); + } + } + + $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' ); + if ( $taxonomies ) { + foreach ( $taxonomies as $slug => $taxonomy ) { + if ( 'post_format' === $taxonomy && ! current_theme_supports( 'post-formats' ) ) { + continue; + } + $item_types[] = array( + 'title' => $taxonomy->labels->name, + 'type_label' => $taxonomy->labels->singular_name, + 'type' => 'taxonomy', + 'object' => $taxonomy->name, + ); + } + } + + /** + * Filters the available menu item types. + * + * @since 4.3.0 + * @since 4.7.0 Each array item now includes a `$type_label` in addition to `$title`, `$type`, and `$object`. + * + * @param array $item_types Navigation menu item types. + */ + $item_types = apply_filters( 'customize_nav_menu_available_item_types', $item_types ); + + return $item_types; + } + + /** + * Add a new `auto-draft` post. + * + * @since 4.7.0 + * + * @param array $postarr { + * Post array. Note that post_status is overridden to be `auto-draft`. + * + * @var string $post_title Post title. Required. + * @var string $post_type Post type. Required. + * @var string $post_name Post name. + * @var string $post_content Post content. + * } + * @return WP_Post|WP_Error Inserted auto-draft post object or error. + */ + public function insert_auto_draft_post( $postarr ) { + if ( ! isset( $postarr['post_type'] ) ) { + return new WP_Error( 'unknown_post_type', __( 'Invalid post type.' ) ); + } + if ( empty( $postarr['post_title'] ) ) { + return new WP_Error( 'empty_title', __( 'Empty title' ) ); + } + if ( ! empty( $postarr['post_status'] ) ) { + return new WP_Error( 'status_forbidden', __( 'Status is forbidden' ) ); + } + + /* + * If the changeset is a draft, this will change to draft the next time the changeset + * is updated; otherwise, auto-draft will persist in autosave revisions, until save. + */ + $postarr['post_status'] = 'auto-draft'; + + // Auto-drafts are allowed to have empty post_names, so it has to be explicitly set. + if ( empty( $postarr['post_name'] ) ) { + $postarr['post_name'] = sanitize_title( $postarr['post_title'] ); + } + if ( ! isset( $postarr['meta_input'] ) ) { + $postarr['meta_input'] = array(); + } + $postarr['meta_input']['_customize_draft_post_name'] = $postarr['post_name']; + $postarr['meta_input']['_customize_changeset_uuid'] = $this->manager->changeset_uuid(); + unset( $postarr['post_name'] ); + + add_filter( 'wp_insert_post_empty_content', '__return_false', 1000 ); + $r = wp_insert_post( wp_slash( $postarr ), true ); + remove_filter( 'wp_insert_post_empty_content', '__return_false', 1000 ); + + if ( is_wp_error( $r ) ) { + return $r; + } else { + return get_post( $r ); + } + } + + /** + * Ajax handler for adding a new auto-draft post. + * + * @since 4.7.0 + */ + public function ajax_insert_auto_draft_post() { + if ( ! check_ajax_referer( 'customize-menus', 'customize-menus-nonce', false ) ) { + wp_send_json_error( 'bad_nonce', 400 ); + } + + if ( ! current_user_can( 'customize' ) ) { + wp_send_json_error( 'customize_not_allowed', 403 ); + } + + if ( empty( $_POST['params'] ) || ! is_array( $_POST['params'] ) ) { + wp_send_json_error( 'missing_params', 400 ); + } + + $params = wp_unslash( $_POST['params'] ); + $illegal_params = array_diff( array_keys( $params ), array( 'post_type', 'post_title' ) ); + if ( ! empty( $illegal_params ) ) { + wp_send_json_error( 'illegal_params', 400 ); + } + + $params = array_merge( + array( + 'post_type' => '', + 'post_title' => '', + ), + $params + ); + + if ( empty( $params['post_type'] ) || ! post_type_exists( $params['post_type'] ) ) { + status_header( 400 ); + wp_send_json_error( 'missing_post_type_param' ); + } + + $post_type_object = get_post_type_object( $params['post_type'] ); + if ( ! current_user_can( $post_type_object->cap->create_posts ) || ! current_user_can( $post_type_object->cap->publish_posts ) ) { + status_header( 403 ); + wp_send_json_error( 'insufficient_post_permissions' ); + } + + $params['post_title'] = trim( $params['post_title'] ); + if ( '' === $params['post_title'] ) { + status_header( 400 ); + wp_send_json_error( 'missing_post_title' ); + } + + $r = $this->insert_auto_draft_post( $params ); + if ( is_wp_error( $r ) ) { + $error = $r; + if ( ! empty( $post_type_object->labels->singular_name ) ) { + $singular_name = $post_type_object->labels->singular_name; + } else { + $singular_name = __( 'Post' ); + } + + $data = array( + /* translators: %1$s is the post type name and %2$s is the error message. */ + 'message' => sprintf( __( '%1$s could not be created: %2$s' ), $singular_name, $error->get_error_message() ), + ); + wp_send_json_error( $data ); + } else { + $post = $r; + $data = array( + 'post_id' => $post->ID, + 'url' => get_permalink( $post->ID ), + ); + wp_send_json_success( $data ); + } + } + + /** + * Print the JavaScript templates used to render Menu Customizer components. + * + * Templates are imported into the JS use wp.template. + * + * @since 4.3.0 + */ + public function print_templates() { + ?> + <script type="text/html" id="tmpl-available-menu-item"> + <li id="menu-item-tpl-{{ data.id }}" class="menu-item-tpl" data-menu-item-id="{{ data.id }}"> + <div class="menu-item-bar"> + <div class="menu-item-handle"> + <span class="item-type" aria-hidden="true">{{ data.type_label }}</span> + <span class="item-title" aria-hidden="true"> + <span class="menu-item-title<# if ( ! data.title ) { #> no-title<# } #>">{{ data.title || wp.customize.Menus.data.l10n.untitled }}</span> + </span> + <button type="button" class="button-link item-add"> + <span class="screen-reader-text"><?php + /* translators: 1: Title of a menu item, 2: Type of a menu item */ + printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' ); + ?></span> + </button> + </div> + </div> + </li> + </script> + + <script type="text/html" id="tmpl-menu-item-reorder-nav"> + <div class="menu-item-reorder-nav"> + <?php + printf( + '<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>', + __( 'Move up' ), + __( 'Move down' ), + __( 'Move one level up' ), + __( 'Move one level down' ) + ); + ?> + </div> + </script> + + <script type="text/html" id="tmpl-nav-menu-delete-button"> + <div class="menu-delete-item"> + <button type="button" class="button-link button-link-delete"> + <?php _e( 'Delete Menu' ); ?> + </button> + </div> + </script> + + <script type="text/html" id="tmpl-nav-menu-submit-new-button"> + <p id="customize-new-menu-submit-description"><?php _e( 'Click “Next” to start adding links to your new menu.' ); ?></p> + <button id="customize-new-menu-submit" type="button" class="button" aria-describedby="customize-new-menu-submit-description"><?php _e( 'Next' ); ?></button> + </script> + + <script type="text/html" id="tmpl-nav-menu-locations-header"> + <span class="customize-control-title customize-section-title-menu_locations-heading">{{ data.l10n.locationsTitle }}</span> + <p class="customize-control-description customize-section-title-menu_locations-description">{{ data.l10n.locationsDescription }}</p> + </script> + + <script type="text/html" id="tmpl-nav-menu-create-menu-section-title"> + <p class="add-new-menu-notice"> + <?php _e( 'It doesn’t look like your site has any menus yet. Want to build one? Click the button to start.' ); ?> + </p> + <p class="add-new-menu-notice"> + <?php _e( 'You’ll create a menu, assign it a location, and add menu items like links to pages and categories. If your theme has multiple menu areas, you might need to create more than one.' ); ?> + </p> + <h3> + <button type="button" class="button customize-add-menu-button"> + <?php _e( 'Create New Menu' ); ?> + </button> + </h3> + </script> + <?php + } + + /** + * Print the html template used to render the add-menu-item frame. + * + * @since 4.3.0 + */ + public function available_items_template() { + ?> + <div id="available-menu-items" class="accordion-container"> + <div class="customize-section-title"> + <button type="button" class="customize-section-back" tabindex="-1"> + <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> + </button> + <h3> + <span class="customize-action"> + <?php + /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ + printf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) ); + ?> + </span> + <?php _e( 'Add Menu Items' ); ?> + </h3> + </div> + <div id="available-menu-items-search" class="accordion-section cannot-expand"> + <div class="accordion-section-title"> + <label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label> + <input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items…' ) ?>" aria-describedby="menu-items-search-desc" /> + <p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p> + <span class="spinner"></span> + </div> + <div class="search-icon" aria-hidden="true"></div> + <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button> + <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul> + </div> + <?php + + // Ensure the page post type comes first in the list. + $item_types = $this->available_item_types(); + $page_item_type = null; + foreach ( $item_types as $i => $item_type ) { + if ( isset( $item_type['object'] ) && 'page' === $item_type['object'] ) { + $page_item_type = $item_type; + unset( $item_types[ $i ] ); + } + } + + $this->print_custom_links_available_menu_item(); + if ( $page_item_type ) { + $this->print_post_type_container( $page_item_type ); + } + // Containers for per-post-type item browsing; items are added with JS. + foreach ( $item_types as $item_type ) { + $this->print_post_type_container( $item_type ); + } + ?> + </div><!-- #available-menu-items --> + <?php + } + + /** + * Print the markup for new menu items. + * + * To be used in the template #available-menu-items. + * + * @since 4.7.0 + * + * @param array $available_item_type Menu item data to output, including title, type, and label. + * @return void + */ + protected function print_post_type_container( $available_item_type ) { + $id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] ); + ?> + <div id="<?php echo esc_attr( $id ); ?>" class="accordion-section"> + <h4 class="accordion-section-title" role="presentation"> + <?php echo esc_html( $available_item_type['title'] ); ?> + <span class="spinner"></span> + <span class="no-items"><?php _e( 'No items' ); ?></span> + <button type="button" class="button-link" aria-expanded="false"> + <span class="screen-reader-text"><?php + /* translators: %s: Title of a section with menu items */ + printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) ); ?></span> + <span class="toggle-indicator" aria-hidden="true"></span> + </button> + </h4> + <div class="accordion-section-content"> + <?php if ( 'post_type' === $available_item_type['type'] ) : ?> + <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?> + <?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?> + <div class="new-content-item"> + <label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="screen-reader-text"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label> + <input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>"> + <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> + </div> + <?php endif; ?> + <?php endif; ?> + <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul> + </div> + </div> + <?php + } + + /** + * Print the markup for available menu item custom links. + * + * @since 4.7.0 + * + * @return void + */ + protected function print_custom_links_available_menu_item() { + ?> + <div id="new-custom-menu-item" class="accordion-section"> + <h4 class="accordion-section-title" role="presentation"> + <?php _e( 'Custom Links' ); ?> + <button type="button" class="button-link" aria-expanded="false"> + <span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span> + <span class="toggle-indicator" aria-hidden="true"></span> + </button> + </h4> + <div class="accordion-section-content customlinkdiv"> + <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" /> + <p id="menu-item-url-wrap" class="wp-clearfix"> + <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> + <input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://"> + </p> + <p id="menu-item-name-wrap" class="wp-clearfix"> + <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> + <input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox"> + </p> + <p class="button-controls"> + <span class="add-to-menu"> + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit"> + <span class="spinner"></span> + </span> + </p> + </div> + </div> + <?php + } + + // + // Start functionality specific to partial-refresh of menu changes in Customizer preview. + // + + /** + * Nav menu args used for each instance, keyed by the args HMAC. + * + * @since 4.3.0 + * @var array + */ + public $preview_nav_menu_instance_args = array(); + + /** + * Filters arguments for dynamic nav_menu selective refresh partials. + * + * @since 4.5.0 + * + * @param array|false $partial_args Partial args. + * @param string $partial_id Partial ID. + * @return array Partial args. + */ + public function customize_dynamic_partial_args( $partial_args, $partial_id ) { + + if ( preg_match( '/^nav_menu_instance\[[0-9a-f]{32}\]$/', $partial_id ) ) { + if ( false === $partial_args ) { + $partial_args = array(); + } + $partial_args = array_merge( + $partial_args, + array( + 'type' => 'nav_menu_instance', + 'render_callback' => array( $this, 'render_nav_menu_partial' ), + 'container_inclusive' => true, + 'settings' => array(), // Empty because the nav menu instance may relate to a menu or a location. + 'capability' => 'edit_theme_options', + ) + ); + } + + return $partial_args; + } + + /** + * Add hooks for the Customizer preview. + * + * @since 4.3.0 + */ + public function customize_preview_init() { + add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) ); + add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 ); + add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 ); + add_filter( 'wp_footer', array( $this, 'export_preview_data' ), 1 ); + add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) ); + } + + /** + * Make the auto-draft status protected so that it can be queried. + * + * @since 4.7.0 + * + * @global array $wp_post_statuses List of post statuses. + */ + public function make_auto_draft_status_previewable() { + global $wp_post_statuses; + $wp_post_statuses['auto-draft']->protected = true; + } + + /** + * Sanitize post IDs for posts created for nav menu items to be published. + * + * @since 4.7.0 + * + * @param array $value Post IDs. + * @returns array Post IDs. + */ + public function sanitize_nav_menus_created_posts( $value ) { + $post_ids = array(); + foreach ( wp_parse_id_list( $value ) as $post_id ) { + if ( empty( $post_id ) ) { + continue; + } + $post = get_post( $post_id ); + if ( 'auto-draft' !== $post->post_status && 'draft' !== $post->post_status ) { + continue; + } + $post_type_obj = get_post_type_object( $post->post_type ); + if ( ! $post_type_obj ) { + continue; + } + if ( ! current_user_can( $post_type_obj->cap->publish_posts ) || ! current_user_can( $post_type_obj->cap->edit_post, $post_id ) ) { + continue; + } + $post_ids[] = $post->ID; + } + return $post_ids; + } + + /** + * Publish the auto-draft posts that were created for nav menu items. + * + * The post IDs will have been sanitized by already by + * `WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts()` to + * remove any post IDs for which the user cannot publish or for which the + * post is not an auto-draft. + * + * @since 4.7.0 + * + * @param WP_Customize_Setting $setting Customizer setting object. + */ + public function save_nav_menus_created_posts( $setting ) { + $post_ids = $setting->post_value(); + if ( ! empty( $post_ids ) ) { + foreach ( $post_ids as $post_id ) { + + // Prevent overriding the status that a user may have prematurely updated the post to. + $current_status = get_post_status( $post_id ); + if ( 'auto-draft' !== $current_status && 'draft' !== $current_status ) { + continue; + } + + $target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish'; + $args = array( + 'ID' => $post_id, + 'post_status' => $target_status, + ); + $post_name = get_post_meta( $post_id, '_customize_draft_post_name', true ); + if ( $post_name ) { + $args['post_name'] = $post_name; + } + + // Note that wp_publish_post() cannot be used because unique slugs need to be assigned. + wp_update_post( wp_slash( $args ) ); + + delete_post_meta( $post_id, '_customize_draft_post_name' ); + } + } + } + + /** + * Keep track of the arguments that are being passed to wp_nav_menu(). + * + * @since 4.3.0 + * @see wp_nav_menu() + * @see WP_Customize_Widgets_Partial_Refresh::filter_dynamic_sidebar_params() + * + * @param array $args An array containing wp_nav_menu() arguments. + * @return array Arguments. + */ + public function filter_wp_nav_menu_args( $args ) { + /* + * The following conditions determine whether or not this instance of + * wp_nav_menu() can use selective refreshed. A wp_nav_menu() can be + * selective refreshed if... + */ + $can_partial_refresh = ( + // ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated), + ! empty( $args['echo'] ) + && + // ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data, + ( empty( $args['fallback_cb'] ) || is_string( $args['fallback_cb'] ) ) + && + // ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well, + ( empty( $args['walker'] ) || is_string( $args['walker'] ) ) + // ...and if it has a theme location assigned or an assigned menu to display, + && ( + ! empty( $args['theme_location'] ) + || + ( ! empty( $args['menu'] ) && ( is_numeric( $args['menu'] ) || is_object( $args['menu'] ) ) ) + ) + && + // ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes). + ( + ! empty( $args['container'] ) + || + ( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) ) + ) + ); + $args['can_partial_refresh'] = $can_partial_refresh; + + $exported_args = $args; + + // Empty out args which may not be JSON-serializable. + if ( ! $can_partial_refresh ) { + $exported_args['fallback_cb'] = ''; + $exported_args['walker'] = ''; + } + + /* + * Replace object menu arg with a term_id menu arg, as this exports better + * to JS and is easier to compare hashes. + */ + if ( ! empty( $exported_args['menu'] ) && is_object( $exported_args['menu'] ) ) { + $exported_args['menu'] = $exported_args['menu']->term_id; + } + + ksort( $exported_args ); + $exported_args['args_hmac'] = $this->hash_nav_menu_args( $exported_args ); + + $args['customize_preview_nav_menus_args'] = $exported_args; + $this->preview_nav_menu_instance_args[ $exported_args['args_hmac'] ] = $exported_args; + return $args; + } + + /** + * Prepares wp_nav_menu() calls for partial refresh. + * + * Injects attributes into container element. + * + * @since 4.3.0 + * + * @see wp_nav_menu() + * + * @param string $nav_menu_content The HTML content for the navigation menu. + * @param object $args An object containing wp_nav_menu() arguments. + * @return string Nav menu HTML with selective refresh attributes added if partial can be refreshed. + */ + public function filter_wp_nav_menu( $nav_menu_content, $args ) { + if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) { + $attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) ); + $attributes .= ' data-customize-partial-type="nav_menu_instance"'; + $attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) ); + $nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . str_replace( '\\', '\\\\', $attributes ), $nav_menu_content, 1 ); + } + return $nav_menu_content; + } + + /** + * Hashes (hmac) the nav menu arguments to ensure they are not tampered with when + * submitted in the Ajax request. + * + * Note that the array is expected to be pre-sorted. + * + * @since 4.3.0 + * + * @param array $args The arguments to hash. + * @return string Hashed nav menu arguments. + */ + public function hash_nav_menu_args( $args ) { + return wp_hash( serialize( $args ) ); + } + + /** + * Enqueue scripts for the Customizer preview. + * + * @since 4.3.0 + */ + public function customize_preview_enqueue_deps() { + wp_enqueue_script( 'customize-preview-nav-menus' ); // Note that we have overridden this. + } + + /** + * Exports data from PHP to JS. + * + * @since 4.3.0 + */ + public function export_preview_data() { + + // Why not wp_localize_script? Because we're not localizing, and it forces values into strings. + $exports = array( + 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args, + ); + printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) ); + } + + /** + * Export any wp_nav_menu() calls during the rendering of any partials. + * + * @since 4.5.0 + * + * @param array $response Response. + * @return array Response. + */ + public function export_partial_rendered_nav_menu_instances( $response ) { + $response['nav_menu_instance_args'] = $this->preview_nav_menu_instance_args; + return $response; + } + + /** + * Render a specific menu via wp_nav_menu() using the supplied arguments. + * + * @since 4.3.0 + * + * @see wp_nav_menu() + * + * @param WP_Customize_Partial $partial Partial. + * @param array $nav_menu_args Nav menu args supplied as container context. + * @return string|false + */ + public function render_nav_menu_partial( $partial, $nav_menu_args ) { + unset( $partial ); + + if ( ! isset( $nav_menu_args['args_hmac'] ) ) { + // Error: missing_args_hmac. + return false; + } + + $nav_menu_args_hmac = $nav_menu_args['args_hmac']; + unset( $nav_menu_args['args_hmac'] ); + + ksort( $nav_menu_args ); + if ( ! hash_equals( $this->hash_nav_menu_args( $nav_menu_args ), $nav_menu_args_hmac ) ) { + // Error: args_hmac_mismatch. + return false; + } + + ob_start(); + wp_nav_menu( $nav_menu_args ); + $content = ob_get_clean(); + + return $content; + } +} diff --git a/backend/wp-includes/class-wp-customize-panel.php b/backend/wp-includes/class-wp-customize-panel.php new file mode 100644 index 0000000..731dd20 --- /dev/null +++ b/backend/wp-includes/class-wp-customize-panel.php @@ -0,0 +1,382 @@ +<?php +/** + * WordPress Customize Panel classes + * + * @package WordPress + * @subpackage Customize + * @since 4.0.0 + */ + +/** + * Customize Panel class. + * + * A UI container for sections, managed by the WP_Customize_Manager. + * + * @since 4.0.0 + * + * @see WP_Customize_Manager + */ +class WP_Customize_Panel { + + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * + * @static + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @var int + */ + public $instance_number; + + /** + * WP_Customize_Manager instance. + * + * @since 4.0.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * Unique identifier. + * + * @since 4.0.0 + * @var string + */ + public $id; + + /** + * Priority of the panel, defining the display order of panels and sections. + * + * @since 4.0.0 + * @var integer + */ + public $priority = 160; + + /** + * Capability required for the panel. + * + * @since 4.0.0 + * @var string + */ + public $capability = 'edit_theme_options'; + + /** + * Theme feature support for the panel. + * + * @since 4.0.0 + * @var string|array + */ + public $theme_supports = ''; + + /** + * Title of the panel to show in UI. + * + * @since 4.0.0 + * @var string + */ + public $title = ''; + + /** + * Description to show in the UI. + * + * @since 4.0.0 + * @var string + */ + public $description = ''; + + /** + * Auto-expand a section in a panel when the panel is expanded when the panel only has the one section. + * + * @since 4.7.4 + * @var bool + */ + public $auto_expand_sole_section = false; + + /** + * Customizer sections for this panel. + * + * @since 4.0.0 + * @var array + */ + public $sections; + + /** + * Type of this panel. + * + * @since 4.1.0 + * @var string + */ + public $type = 'default'; + + /** + * Active callback. + * + * @since 4.1.0 + * + * @see WP_Customize_Section::active() + * + * @var callable Callback is called with one argument, the instance of + * WP_Customize_Section, and returns bool to indicate whether + * the section is active (such as it relates to the URL currently + * being previewed). + */ + public $active_callback = ''; + + /** + * Constructor. + * + * Any supplied $args override class property defaults. + * + * @since 4.0.0 + * + * @param WP_Customize_Manager $manager Customizer bootstrap instance. + * @param string $id An specific ID for the panel. + * @param array $args Panel arguments. + */ + public function __construct( $manager, $id, $args = array() ) { + $keys = array_keys( get_object_vars( $this ) ); + foreach ( $keys as $key ) { + if ( isset( $args[ $key ] ) ) { + $this->$key = $args[ $key ]; + } + } + + $this->manager = $manager; + $this->id = $id; + if ( empty( $this->active_callback ) ) { + $this->active_callback = array( $this, 'active_callback' ); + } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; + + $this->sections = array(); // Users cannot customize the $sections array. + } + + /** + * Check whether panel is active to current Customizer preview. + * + * @since 4.1.0 + * + * @return bool Whether the panel is active to the current preview. + */ + final public function active() { + $panel = $this; + $active = call_user_func( $this->active_callback, $this ); + + /** + * Filters response of WP_Customize_Panel::active(). + * + * @since 4.1.0 + * + * @param bool $active Whether the Customizer panel is active. + * @param WP_Customize_Panel $panel WP_Customize_Panel instance. + */ + $active = apply_filters( 'customize_panel_active', $active, $panel ); + + return $active; + } + + /** + * Default callback used when invoking WP_Customize_Panel::active(). + * + * Subclasses can override this with their specific logic, or they may + * provide an 'active_callback' argument to the constructor. + * + * @since 4.1.0 + * + * @return bool Always true. + */ + public function active_callback() { + return true; + } + + /** + * Gather the parameters passed to client JavaScript via JSON. + * + * @since 4.1.0 + * + * @return array The array to be exported to the client as JSON. + */ + public function json() { + $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type' ) ); + $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); + $array['content'] = $this->get_content(); + $array['active'] = $this->active(); + $array['instanceNumber'] = $this->instance_number; + $array['autoExpandSoleSection'] = $this->auto_expand_sole_section; + return $array; + } + + /** + * Checks required user capabilities and whether the theme has the + * feature support required by the panel. + * + * @since 4.0.0 + * + * @return bool False if theme doesn't support the panel or the user doesn't have the capability. + */ + final public function check_capabilities() { + if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { + return false; + } + + if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { + return false; + } + + return true; + } + + /** + * Get the panel's content template for insertion into the Customizer pane. + * + * @since 4.1.0 + * + * @return string Content for the panel. + */ + final public function get_content() { + ob_start(); + $this->maybe_render(); + return trim( ob_get_clean() ); + } + + /** + * Check capabilities and render the panel. + * + * @since 4.0.0 + */ + final public function maybe_render() { + if ( ! $this->check_capabilities() ) { + return; + } + + /** + * Fires before rendering a Customizer panel. + * + * @since 4.0.0 + * + * @param WP_Customize_Panel $this WP_Customize_Panel instance. + */ + do_action( 'customize_render_panel', $this ); + + /** + * Fires before rendering a specific Customizer panel. + * + * The dynamic portion of the hook name, `$this->id`, refers to + * the ID of the specific Customizer panel to be rendered. + * + * @since 4.0.0 + */ + do_action( "customize_render_panel_{$this->id}" ); + + $this->render(); + } + + /** + * Render the panel container, and then its contents (via `this->render_content()`) in a subclass. + * + * Panel containers are now rendered in JS by default, see WP_Customize_Panel::print_template(). + * + * @since 4.0.0 + */ + protected function render() {} + + /** + * Render the panel UI in a subclass. + * + * Panel contents are now rendered in JS by default, see WP_Customize_Panel::print_template(). + * + * @since 4.1.0 + */ + protected function render_content() {} + + /** + * Render the panel's JS templates. + * + * This function is only run for panel types that have been registered with + * WP_Customize_Manager::register_panel_type(). + * + * @since 4.3.0 + * + * @see WP_Customize_Manager::register_panel_type() + */ + public function print_template() { + ?> + <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>-content"> + <?php $this->content_template(); ?> + </script> + <script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>"> + <?php $this->render_template(); ?> + </script> + <?php + } + + /** + * An Underscore (JS) template for rendering this panel's container. + * + * Class variables for this panel class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Panel::json(). + * + * @see WP_Customize_Panel::print_template() + * + * @since 4.3.0 + */ + protected function render_template() { + ?> + <li id="accordion-panel-{{ data.id }}" class="accordion-section control-section control-panel control-panel-{{ data.type }}"> + <h3 class="accordion-section-title" tabindex="0"> + {{ data.title }} + <span class="screen-reader-text"><?php _e( 'Press return or enter to open this panel' ); ?></span> + </h3> + <ul class="accordion-sub-container control-panel-content"></ul> + </li> + <?php + } + + /** + * An Underscore (JS) template for this panel's content (but not its container). + * + * Class variables for this panel class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Panel::json(). + * + * @see WP_Customize_Panel::print_template() + * + * @since 4.3.0 + */ + protected function content_template() { + ?> + <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>"> + <button class="customize-panel-back" tabindex="-1"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button> + <div class="accordion-section-title"> + <span class="preview-notice"><?php + /* translators: %s: the site/panel title in the Customizer */ + echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' ); + ?></span> + <# if ( data.description ) { #> + <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> + <# } #> + </div> + <# if ( data.description ) { #> + <div class="description customize-panel-description"> + {{{ data.description }}} + </div> + <# } #> + + <div class="customize-control-notifications-container"></div> + </li> + <?php + } +} + +/** WP_Customize_Nav_Menus_Panel class */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menus-panel.php' ); diff --git a/backend/wp-includes/class-wp-customize-section.php b/backend/wp-includes/class-wp-customize-section.php new file mode 100644 index 0000000..a4a6074 --- /dev/null +++ b/backend/wp-includes/class-wp-customize-section.php @@ -0,0 +1,398 @@ +<?php +/** + * WordPress Customize Section classes + * + * @package WordPress + * @subpackage Customize + * @since 3.4.0 + */ + +/** + * Customize Section class. + * + * A UI container for controls, managed by the WP_Customize_Manager class. + * + * @since 3.4.0 + * + * @see WP_Customize_Manager + */ +class WP_Customize_Section { + + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * + * @static + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @var int + */ + public $instance_number; + + /** + * WP_Customize_Manager instance. + * + * @since 3.4.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * Unique identifier. + * + * @since 3.4.0 + * @var string + */ + public $id; + + /** + * Priority of the section which informs load order of sections. + * + * @since 3.4.0 + * @var integer + */ + public $priority = 160; + + /** + * Panel in which to show the section, making it a sub-section. + * + * @since 4.0.0 + * @var string + */ + public $panel = ''; + + /** + * Capability required for the section. + * + * @since 3.4.0 + * @var string + */ + public $capability = 'edit_theme_options'; + + /** + * Theme feature support for the section. + * + * @since 3.4.0 + * @var string|array + */ + public $theme_supports = ''; + + /** + * Title of the section to show in UI. + * + * @since 3.4.0 + * @var string + */ + public $title = ''; + + /** + * Description to show in the UI. + * + * @since 3.4.0 + * @var string + */ + public $description = ''; + + /** + * Customizer controls for this section. + * + * @since 3.4.0 + * @var array + */ + public $controls; + + /** + * Type of this section. + * + * @since 4.1.0 + * @var string + */ + public $type = 'default'; + + /** + * Active callback. + * + * @since 4.1.0 + * + * @see WP_Customize_Section::active() + * + * @var callable Callback is called with one argument, the instance of + * WP_Customize_Section, and returns bool to indicate whether + * the section is active (such as it relates to the URL currently + * being previewed). + */ + public $active_callback = ''; + + /** + * Show the description or hide it behind the help icon. + * + * @since 4.7.0 + * + * @var bool Indicates whether the Section's description should be + * hidden behind a help icon ("?") in the Section header, + * similar to how help icons are displayed on Panels. + */ + public $description_hidden = false; + + /** + * Constructor. + * + * Any supplied $args override class property defaults. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $manager Customizer bootstrap instance. + * @param string $id An specific ID of the section. + * @param array $args Section arguments. + */ + public function __construct( $manager, $id, $args = array() ) { + $keys = array_keys( get_object_vars( $this ) ); + foreach ( $keys as $key ) { + if ( isset( $args[ $key ] ) ) { + $this->$key = $args[ $key ]; + } + } + + $this->manager = $manager; + $this->id = $id; + if ( empty( $this->active_callback ) ) { + $this->active_callback = array( $this, 'active_callback' ); + } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; + + $this->controls = array(); // Users cannot customize the $controls array. + } + + /** + * Check whether section is active to current Customizer preview. + * + * @since 4.1.0 + * + * @return bool Whether the section is active to the current preview. + */ + final public function active() { + $section = $this; + $active = call_user_func( $this->active_callback, $this ); + + /** + * Filters response of WP_Customize_Section::active(). + * + * @since 4.1.0 + * + * @param bool $active Whether the Customizer section is active. + * @param WP_Customize_Section $section WP_Customize_Section instance. + */ + $active = apply_filters( 'customize_section_active', $active, $section ); + + return $active; + } + + /** + * Default callback used when invoking WP_Customize_Section::active(). + * + * Subclasses can override this with their specific logic, or they may provide + * an 'active_callback' argument to the constructor. + * + * @since 4.1.0 + * + * @return true Always true. + */ + public function active_callback() { + return true; + } + + /** + * Gather the parameters passed to client JavaScript via JSON. + * + * @since 4.1.0 + * + * @return array The array to be exported to the client as JSON. + */ + public function json() { + $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden' ) ); + $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); + $array['content'] = $this->get_content(); + $array['active'] = $this->active(); + $array['instanceNumber'] = $this->instance_number; + + if ( $this->panel ) { + /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ + $array['customizeAction'] = sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); + } else { + $array['customizeAction'] = __( 'Customizing' ); + } + + return $array; + } + + /** + * Checks required user capabilities and whether the theme has the + * feature support required by the section. + * + * @since 3.4.0 + * + * @return bool False if theme doesn't support the section or user doesn't have the capability. + */ + final public function check_capabilities() { + if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { + return false; + } + + if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { + return false; + } + + return true; + } + + /** + * Get the section's content for insertion into the Customizer pane. + * + * @since 4.1.0 + * + * @return string Contents of the section. + */ + final public function get_content() { + ob_start(); + $this->maybe_render(); + return trim( ob_get_clean() ); + } + + /** + * Check capabilities and render the section. + * + * @since 3.4.0 + */ + final public function maybe_render() { + if ( ! $this->check_capabilities() ) { + return; + } + + /** + * Fires before rendering a Customizer section. + * + * @since 3.4.0 + * + * @param WP_Customize_Section $this WP_Customize_Section instance. + */ + do_action( 'customize_render_section', $this ); + /** + * Fires before rendering a specific Customizer section. + * + * The dynamic portion of the hook name, `$this->id`, refers to the ID + * of the specific Customizer section to be rendered. + * + * @since 3.4.0 + */ + do_action( "customize_render_section_{$this->id}" ); + + $this->render(); + } + + /** + * Render the section UI in a subclass. + * + * Sections are now rendered in JS by default, see WP_Customize_Section::print_template(). + * + * @since 3.4.0 + */ + protected function render() {} + + /** + * Render the section's JS template. + * + * This function is only run for section types that have been registered with + * WP_Customize_Manager::register_section_type(). + * + * @since 4.3.0 + * + * @see WP_Customize_Manager::render_template() + */ + public function print_template() { + ?> + <script type="text/html" id="tmpl-customize-section-<?php echo $this->type; ?>"> + <?php $this->render_template(); ?> + </script> + <?php + } + + /** + * An Underscore (JS) template for rendering this section. + * + * Class variables for this section class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Section::json(). + * + * @since 4.3.0 + * + * @see WP_Customize_Section::print_template() + */ + protected function render_template() { + ?> + <li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }}"> + <h3 class="accordion-section-title" tabindex="0"> + {{ data.title }} + <span class="screen-reader-text"><?php _e( 'Press return or enter to open this section' ); ?></span> + </h3> + <ul class="accordion-section-content"> + <li class="customize-section-description-container section-meta <# if ( data.description_hidden ) { #>customize-info<# } #>"> + <div class="customize-section-title"> + <button class="customize-section-back" tabindex="-1"> + <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> + </button> + <h3> + <span class="customize-action"> + {{{ data.customizeAction }}} + </span> + {{ data.title }} + </h3> + <# if ( data.description && data.description_hidden ) { #> + <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> + <div class="description customize-section-description"> + {{{ data.description }}} + </div> + <# } #> + + <div class="customize-control-notifications-container"></div> + </div> + + <# if ( data.description && ! data.description_hidden ) { #> + <div class="description customize-section-description"> + {{{ data.description }}} + </div> + <# } #> + </li> + </ul> + </li> + <?php + } +} + +/** WP_Customize_Themes_Section class */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php' ); + +/** WP_Customize_Sidebar_Section class */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php' ); + +/** WP_Customize_Nav_Menu_Section class */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php' ); + +/** + * WP_Customize_New_Menu_Section class + * + * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent + * release, the require_once() here will be removed and _deprecated_file() will be called if file is + * required at all. + * + * @deprecated 4.9.0 This file is no longer used due to new menu creation UX. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-section.php' ); diff --git a/backend/wp-includes/class-wp-customize-setting.php b/backend/wp-includes/class-wp-customize-setting.php new file mode 100644 index 0000000..601990f --- /dev/null +++ b/backend/wp-includes/class-wp-customize-setting.php @@ -0,0 +1,958 @@ +<?php +/** + * WordPress Customize Setting classes + * + * @package WordPress + * @subpackage Customize + * @since 3.4.0 + */ + +/** + * Customize Setting class. + * + * Handles saving and sanitizing of settings. + * + * @since 3.4.0 + * + * @see WP_Customize_Manager + */ +class WP_Customize_Setting { + /** + * Customizer bootstrap instance. + * + * @since 3.4.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * Unique string identifier for the setting. + * + * @since 3.4.0 + * @var string + */ + public $id; + + /** + * Type of customize settings. + * + * @since 3.4.0 + * @var string + */ + public $type = 'theme_mod'; + + /** + * Capability required to edit this setting. + * + * @since 3.4.0 + * @var string|array + */ + public $capability = 'edit_theme_options'; + + /** + * Feature a theme is required to support to enable this setting. + * + * @since 3.4.0 + * @var string + */ + public $theme_supports = ''; + + /** + * The default value for the setting. + * + * @since 3.4.0 + * @var string + */ + public $default = ''; + + /** + * Options for rendering the live preview of changes in Theme Customizer. + * + * Set this value to 'postMessage' to enable a custom Javascript handler to render changes to this setting + * as opposed to reloading the whole page. + * + * @link https://developer.wordpress.org/themes/customize-api + * + * @since 3.4.0 + * @var string + */ + public $transport = 'refresh'; + + /** + * Server-side validation callback for the setting's value. + * + * @since 4.6.0 + * @var callable + */ + public $validate_callback = ''; + + /** + * Callback to filter a Customize setting value in un-slashed form. + * + * @since 3.4.0 + * @var callable + */ + public $sanitize_callback = ''; + + /** + * Callback to convert a Customize PHP setting value to a value that is JSON serializable. + * + * @since 3.4.0 + * @var string + */ + public $sanitize_js_callback = ''; + + /** + * Whether or not the setting is initially dirty when created. + * + * This is used to ensure that a setting will be sent from the pane to the + * preview when loading the Customizer. Normally a setting only is synced to + * the preview if it has been changed. This allows the setting to be sent + * from the start. + * + * @since 4.2.0 + * @var bool + */ + public $dirty = false; + + /** + * ID Data. + * + * @since 3.4.0 + * @var array + */ + protected $id_data = array(); + + /** + * Whether or not preview() was called. + * + * @since 4.4.0 + * @var bool + */ + protected $is_previewed = false; + + /** + * Cache of multidimensional values to improve performance. + * + * @since 4.4.0 + * @static + * @var array + */ + protected static $aggregated_multidimensionals = array(); + + /** + * Whether the multidimensional setting is aggregated. + * + * @since 4.4.0 + * @var bool + */ + protected $is_multidimensional_aggregated = false; + + /** + * Constructor. + * + * Any supplied $args override class property defaults. + * + * @since 3.4.0 + * + * @param WP_Customize_Manager $manager + * @param string $id An specific ID of the setting. Can be a + * theme mod or option name. + * @param array $args Setting arguments. + */ + public function __construct( $manager, $id, $args = array() ) { + $keys = array_keys( get_object_vars( $this ) ); + foreach ( $keys as $key ) { + if ( isset( $args[ $key ] ) ) { + $this->$key = $args[ $key ]; + } + } + + $this->manager = $manager; + $this->id = $id; + + // Parse the ID for array keys. + $this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) ); + $this->id_data['base'] = array_shift( $this->id_data['keys'] ); + + // Rebuild the ID. + $this->id = $this->id_data[ 'base' ]; + if ( ! empty( $this->id_data[ 'keys' ] ) ) { + $this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']'; + } + + if ( $this->validate_callback ) { + add_filter( "customize_validate_{$this->id}", $this->validate_callback, 10, 3 ); + } + if ( $this->sanitize_callback ) { + add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 ); + } + if ( $this->sanitize_js_callback ) { + add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 ); + } + + if ( 'option' === $this->type || 'theme_mod' === $this->type ) { + // Other setting types can opt-in to aggregate multidimensional explicitly. + $this->aggregate_multidimensional(); + + // Allow option settings to indicate whether they should be autoloaded. + if ( 'option' === $this->type && isset( $args['autoload'] ) ) { + self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload']; + } + } + } + + /** + * Get parsed ID data for multidimensional setting. + * + * @since 4.4.0 + * + * @return array { + * ID data for multidimensional setting. + * + * @type string $base ID base + * @type array $keys Keys for multidimensional array. + * } + */ + final public function id_data() { + return $this->id_data; + } + + /** + * Set up the setting for aggregated multidimensional values. + * + * When a multidimensional setting gets aggregated, all of its preview and update + * calls get combined into one call, greatly improving performance. + * + * @since 4.4.0 + */ + protected function aggregate_multidimensional() { + $id_base = $this->id_data['base']; + if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) { + self::$aggregated_multidimensionals[ $this->type ] = array(); + } + if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) { + self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array( + 'previewed_instances' => array(), // Calling preview() will add the $setting to the array. + 'preview_applied_instances' => array(), // Flags for which settings have had their values applied. + 'root_value' => $this->get_root_value( array() ), // Root value for initial state, manipulated by preview and update calls. + ); + } + + if ( ! empty( $this->id_data['keys'] ) ) { + // Note the preview-applied flag is cleared at priority 9 to ensure it is cleared before a deferred-preview runs. + add_action( "customize_post_value_set_{$this->id}", array( $this, '_clear_aggregated_multidimensional_preview_applied_flag' ), 9 ); + $this->is_multidimensional_aggregated = true; + } + } + + /** + * Reset `$aggregated_multidimensionals` static variable. + * + * This is intended only for use by unit tests. + * + * @since 4.5.0 + * @ignore + */ + static public function reset_aggregated_multidimensionals() { + self::$aggregated_multidimensionals = array(); + } + + /** + * The ID for the current site when the preview() method was called. + * + * @since 4.2.0 + * @var int + */ + protected $_previewed_blog_id; + + /** + * Return true if the current site is not the same as the previewed site. + * + * @since 4.2.0 + * + * @return bool If preview() has been called. + */ + public function is_current_blog_previewed() { + if ( ! isset( $this->_previewed_blog_id ) ) { + return false; + } + return ( get_current_blog_id() === $this->_previewed_blog_id ); + } + + /** + * Original non-previewed value stored by the preview method. + * + * @see WP_Customize_Setting::preview() + * @since 4.1.1 + * @var mixed + */ + protected $_original_value; + + /** + * Add filters to supply the setting's value when accessed. + * + * If the setting already has a pre-existing value and there is no incoming + * post value for the setting, then this method will short-circuit since + * there is no change to preview. + * + * @since 3.4.0 + * @since 4.4.0 Added boolean return value. + * + * @return bool False when preview short-circuits due no change needing to be previewed. + */ + public function preview() { + if ( ! isset( $this->_previewed_blog_id ) ) { + $this->_previewed_blog_id = get_current_blog_id(); + } + + // Prevent re-previewing an already-previewed setting. + if ( $this->is_previewed ) { + return true; + } + + $id_base = $this->id_data['base']; + $is_multidimensional = ! empty( $this->id_data['keys'] ); + $multidimensional_filter = array( $this, '_multidimensional_preview_filter' ); + + /* + * Check if the setting has a pre-existing value (an isset check), + * and if doesn't have any incoming post value. If both checks are true, + * then the preview short-circuits because there is nothing that needs + * to be previewed. + */ + $undefined = new stdClass(); + $needs_preview = ( $undefined !== $this->post_value( $undefined ) ); + $value = null; + + // Since no post value was defined, check if we have an initial value set. + if ( ! $needs_preview ) { + if ( $this->is_multidimensional_aggregated ) { + $root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value']; + $value = $this->multidimensional_get( $root, $this->id_data['keys'], $undefined ); + } else { + $default = $this->default; + $this->default = $undefined; // Temporarily set default to undefined so we can detect if existing value is set. + $value = $this->value(); + $this->default = $default; + } + $needs_preview = ( $undefined === $value ); // Because the default needs to be supplied. + } + + // If the setting does not need previewing now, defer to when it has a value to preview. + if ( ! $needs_preview ) { + if ( ! has_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) ) ) { + add_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) ); + } + return false; + } + + switch ( $this->type ) { + case 'theme_mod' : + if ( ! $is_multidimensional ) { + add_filter( "theme_mod_{$id_base}", array( $this, '_preview_filter' ) ); + } else { + if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) { + // Only add this filter once for this ID base. + add_filter( "theme_mod_{$id_base}", $multidimensional_filter ); + } + self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this; + } + break; + case 'option' : + if ( ! $is_multidimensional ) { + add_filter( "pre_option_{$id_base}", array( $this, '_preview_filter' ) ); + } else { + if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) { + // Only add these filters once for this ID base. + add_filter( "option_{$id_base}", $multidimensional_filter ); + add_filter( "default_option_{$id_base}", $multidimensional_filter ); + } + self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this; + } + break; + default : + + /** + * Fires when the WP_Customize_Setting::preview() method is called for settings + * not handled as theme_mods or options. + * + * The dynamic portion of the hook name, `$this->id`, refers to the setting ID. + * + * @since 3.4.0 + * + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + do_action( "customize_preview_{$this->id}", $this ); + + /** + * Fires when the WP_Customize_Setting::preview() method is called for settings + * not handled as theme_mods or options. + * + * The dynamic portion of the hook name, `$this->type`, refers to the setting type. + * + * @since 4.1.0 + * + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + do_action( "customize_preview_{$this->type}", $this ); + } + + $this->is_previewed = true; + + return true; + } + + /** + * Clear out the previewed-applied flag for a multidimensional-aggregated value whenever its post value is updated. + * + * This ensures that the new value will get sanitized and used the next time + * that `WP_Customize_Setting::_multidimensional_preview_filter()` + * is called for this setting. + * + * @since 4.4.0 + * + * @see WP_Customize_Manager::set_post_value() + * @see WP_Customize_Setting::_multidimensional_preview_filter() + */ + final public function _clear_aggregated_multidimensional_preview_applied_flag() { + unset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['preview_applied_instances'][ $this->id ] ); + } + + /** + * Callback function to filter non-multidimensional theme mods and options. + * + * If switch_to_blog() was called after the preview() method, and the current + * site is now not the same site, then this method does a no-op and returns + * the original value. + * + * @since 3.4.0 + * + * @param mixed $original Old value. + * @return mixed New or old value. + */ + public function _preview_filter( $original ) { + if ( ! $this->is_current_blog_previewed() ) { + return $original; + } + + $undefined = new stdClass(); // Symbol hack. + $post_value = $this->post_value( $undefined ); + if ( $undefined !== $post_value ) { + $value = $post_value; + } else { + /* + * Note that we don't use $original here because preview() will + * not add the filter in the first place if it has an initial value + * and there is no post value. + */ + $value = $this->default; + } + return $value; + } + + /** + * Callback function to filter multidimensional theme mods and options. + * + * For all multidimensional settings of a given type, the preview filter for + * the first setting previewed will be used to apply the values for the others. + * + * @since 4.4.0 + * + * @see WP_Customize_Setting::$aggregated_multidimensionals + * @param mixed $original Original root value. + * @return mixed New or old value. + */ + final public function _multidimensional_preview_filter( $original ) { + if ( ! $this->is_current_blog_previewed() ) { + return $original; + } + + $id_base = $this->id_data['base']; + + // If no settings have been previewed yet (which should not be the case, since $this is), just pass through the original value. + if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) { + return $original; + } + + foreach ( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] as $previewed_setting ) { + // Skip applying previewed value for any settings that have already been applied. + if ( ! empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] ) ) { + continue; + } + + // Do the replacements of the posted/default sub value into the root value. + $value = $previewed_setting->post_value( $previewed_setting->default ); + $root = self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value']; + $root = $previewed_setting->multidimensional_replace( $root, $previewed_setting->id_data['keys'], $value ); + self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value'] = $root; + + // Mark this setting having been applied so that it will be skipped when the filter is called again. + self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] = true; + } + + return self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value']; + } + + /** + * Checks user capabilities and theme supports, and then saves + * the value of the setting. + * + * @since 3.4.0 + * + * @return false|void False if cap check fails or value isn't set or is invalid. + */ + final public function save() { + $value = $this->post_value(); + + if ( ! $this->check_capabilities() || ! isset( $value ) ) { + return false; + } + + $id_base = $this->id_data['base']; + + /** + * Fires when the WP_Customize_Setting::save() method is called. + * + * The dynamic portion of the hook name, `$id_base` refers to + * the base slug of the setting name. + * + * @since 3.4.0 + * + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + do_action( "customize_save_{$id_base}", $this ); + + $this->update( $value ); + } + + /** + * Fetch and sanitize the $_POST value for the setting. + * + * During a save request prior to save, post_value() provides the new value while value() does not. + * + * @since 3.4.0 + * + * @param mixed $default A default value which is used as a fallback. Default is null. + * @return mixed The default value on failure, otherwise the sanitized and validated value. + */ + final public function post_value( $default = null ) { + return $this->manager->post_value( $this, $default ); + } + + /** + * Sanitize an input. + * + * @since 3.4.0 + * + * @param string|array $value The value to sanitize. + * @return string|array|null|WP_Error Sanitized value, or `null`/`WP_Error` if invalid. + */ + public function sanitize( $value ) { + + /** + * Filters a Customize setting value in un-slashed form. + * + * @since 3.4.0 + * + * @param mixed $value Value of the setting. + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + return apply_filters( "customize_sanitize_{$this->id}", $value, $this ); + } + + /** + * Validates an input. + * + * @since 4.6.0 + * + * @see WP_REST_Request::has_valid_params() + * + * @param mixed $value Value to validate. + * @return true|WP_Error True if the input was validated, otherwise WP_Error. + */ + public function validate( $value ) { + if ( is_wp_error( $value ) ) { + return $value; + } + if ( is_null( $value ) ) { + return new WP_Error( 'invalid_value', __( 'Invalid value.' ) ); + } + + $validity = new WP_Error(); + + /** + * Validates a Customize setting value. + * + * Plugins should amend the `$validity` object via its `WP_Error::add()` method. + * + * The dynamic portion of the hook name, `$this->ID`, refers to the setting ID. + * + * @since 4.6.0 + * + * @param WP_Error $validity Filtered from `true` to `WP_Error` when invalid. + * @param mixed $value Value of the setting. + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + $validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this ); + + if ( is_wp_error( $validity ) && empty( $validity->errors ) ) { + $validity = true; + } + return $validity; + } + + /** + * Get the root value for a setting, especially for multidimensional ones. + * + * @since 4.4.0 + * + * @param mixed $default Value to return if root does not exist. + * @return mixed + */ + protected function get_root_value( $default = null ) { + $id_base = $this->id_data['base']; + if ( 'option' === $this->type ) { + return get_option( $id_base, $default ); + } elseif ( 'theme_mod' === $this->type ) { + return get_theme_mod( $id_base, $default ); + } else { + /* + * Any WP_Customize_Setting subclass implementing aggregate multidimensional + * will need to override this method to obtain the data from the appropriate + * location. + */ + return $default; + } + } + + /** + * Set the root value for a setting, especially for multidimensional ones. + * + * @since 4.4.0 + * + * @param mixed $value Value to set as root of multidimensional setting. + * @return bool Whether the multidimensional root was updated successfully. + */ + protected function set_root_value( $value ) { + $id_base = $this->id_data['base']; + if ( 'option' === $this->type ) { + $autoload = true; + if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) { + $autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload']; + } + return update_option( $id_base, $value, $autoload ); + } elseif ( 'theme_mod' === $this->type ) { + set_theme_mod( $id_base, $value ); + return true; + } else { + /* + * Any WP_Customize_Setting subclass implementing aggregate multidimensional + * will need to override this method to obtain the data from the appropriate + * location. + */ + return false; + } + } + + /** + * Save the value of the setting, using the related API. + * + * @since 3.4.0 + * + * @param mixed $value The value to update. + * @return bool The result of saving the value. + */ + protected function update( $value ) { + $id_base = $this->id_data['base']; + if ( 'option' === $this->type || 'theme_mod' === $this->type ) { + if ( ! $this->is_multidimensional_aggregated ) { + return $this->set_root_value( $value ); + } else { + $root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value']; + $root = $this->multidimensional_replace( $root, $this->id_data['keys'], $value ); + self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'] = $root; + return $this->set_root_value( $root ); + } + } else { + /** + * Fires when the WP_Customize_Setting::update() method is called for settings + * not handled as theme_mods or options. + * + * The dynamic portion of the hook name, `$this->type`, refers to the type of setting. + * + * @since 3.4.0 + * + * @param mixed $value Value of the setting. + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + do_action( "customize_update_{$this->type}", $value, $this ); + + return has_action( "customize_update_{$this->type}" ); + } + } + + /** + * Deprecated method. + * + * @since 3.4.0 + * @deprecated 4.4.0 Deprecated in favor of update() method. + */ + protected function _update_theme_mod() { + _deprecated_function( __METHOD__, '4.4.0', __CLASS__ . '::update()' ); + } + + /** + * Deprecated method. + * + * @since 3.4.0 + * @deprecated 4.4.0 Deprecated in favor of update() method. + */ + protected function _update_option() { + _deprecated_function( __METHOD__, '4.4.0', __CLASS__ . '::update()' ); + } + + /** + * Fetch the value of the setting. + * + * @since 3.4.0 + * + * @return mixed The value. + */ + public function value() { + $id_base = $this->id_data['base']; + $is_core_type = ( 'option' === $this->type || 'theme_mod' === $this->type ); + + if ( ! $is_core_type && ! $this->is_multidimensional_aggregated ) { + + // Use post value if previewed and a post value is present. + if ( $this->is_previewed ) { + $value = $this->post_value( null ); + if ( null !== $value ) { + return $value; + } + } + + $value = $this->get_root_value( $this->default ); + + /** + * Filters a Customize setting value not handled as a theme_mod or option. + * + * The dynamic portion of the hook name, `$id_base`, refers to + * the base slug of the setting name, initialized from `$this->id_data['base']`. + * + * For settings handled as theme_mods or options, see those corresponding + * functions for available hooks. + * + * @since 3.4.0 + * @since 4.6.0 Added the `$this` setting instance as the second parameter. + * + * @param mixed $default The setting default value. Default empty. + * @param WP_Customize_Setting $this The setting instance. + */ + $value = apply_filters( "customize_value_{$id_base}", $value, $this ); + } elseif ( $this->is_multidimensional_aggregated ) { + $root_value = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value']; + $value = $this->multidimensional_get( $root_value, $this->id_data['keys'], $this->default ); + + // Ensure that the post value is used if the setting is previewed, since preview filters aren't applying on cached $root_value. + if ( $this->is_previewed ) { + $value = $this->post_value( $value ); + } + } else { + $value = $this->get_root_value( $this->default ); + } + return $value; + } + + /** + * Sanitize the setting's value for use in JavaScript. + * + * @since 3.4.0 + * + * @return mixed The requested escaped value. + */ + public function js_value() { + + /** + * Filters a Customize setting value for use in JavaScript. + * + * The dynamic portion of the hook name, `$this->id`, refers to the setting ID. + * + * @since 3.4.0 + * + * @param mixed $value The setting value. + * @param WP_Customize_Setting $this WP_Customize_Setting instance. + */ + $value = apply_filters( "customize_sanitize_js_{$this->id}", $this->value(), $this ); + + if ( is_string( $value ) ) + return html_entity_decode( $value, ENT_QUOTES, 'UTF-8'); + + return $value; + } + + /** + * Retrieves the data to export to the client via JSON. + * + * @since 4.6.0 + * + * @return array Array of parameters passed to JavaScript. + */ + public function json() { + return array( + 'value' => $this->js_value(), + 'transport' => $this->transport, + 'dirty' => $this->dirty, + 'type' => $this->type, + ); + } + + /** + * Validate user capabilities whether the theme supports the setting. + * + * @since 3.4.0 + * + * @return bool False if theme doesn't support the setting or user can't change setting, otherwise true. + */ + final public function check_capabilities() { + if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) + return false; + + if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) + return false; + + return true; + } + + /** + * Multidimensional helper function. + * + * @since 3.4.0 + * + * @param $root + * @param $keys + * @param bool $create Default is false. + * @return array|void Keys are 'root', 'node', and 'key'. + */ + final protected function multidimensional( &$root, $keys, $create = false ) { + if ( $create && empty( $root ) ) + $root = array(); + + if ( ! isset( $root ) || empty( $keys ) ) + return; + + $last = array_pop( $keys ); + $node = &$root; + + foreach ( $keys as $key ) { + if ( $create && ! isset( $node[ $key ] ) ) + $node[ $key ] = array(); + + if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) + return; + + $node = &$node[ $key ]; + } + + if ( $create ) { + if ( ! is_array( $node ) ) { + // account for an array overriding a string or object value + $node = array(); + } + if ( ! isset( $node[ $last ] ) ) { + $node[ $last ] = array(); + } + } + + if ( ! isset( $node[ $last ] ) ) + return; + + return array( + 'root' => &$root, + 'node' => &$node, + 'key' => $last, + ); + } + + /** + * Will attempt to replace a specific value in a multidimensional array. + * + * @since 3.4.0 + * + * @param $root + * @param $keys + * @param mixed $value The value to update. + * @return mixed + */ + final protected function multidimensional_replace( $root, $keys, $value ) { + if ( ! isset( $value ) ) + return $root; + elseif ( empty( $keys ) ) // If there are no keys, we're replacing the root. + return $value; + + $result = $this->multidimensional( $root, $keys, true ); + + if ( isset( $result ) ) + $result['node'][ $result['key'] ] = $value; + + return $root; + } + + /** + * Will attempt to fetch a specific value from a multidimensional array. + * + * @since 3.4.0 + * + * @param $root + * @param $keys + * @param mixed $default A default value which is used as a fallback. Default is null. + * @return mixed The requested value or the default value. + */ + final protected function multidimensional_get( $root, $keys, $default = null ) { + if ( empty( $keys ) ) // If there are no keys, test the root. + return isset( $root ) ? $root : $default; + + $result = $this->multidimensional( $root, $keys ); + return isset( $result ) ? $result['node'][ $result['key'] ] : $default; + } + + /** + * Will attempt to check if a specific value in a multidimensional array is set. + * + * @since 3.4.0 + * + * @param $root + * @param $keys + * @return bool True if value is set, false if not. + */ + final protected function multidimensional_isset( $root, $keys ) { + $result = $this->multidimensional_get( $root, $keys ); + return isset( $result ); + } +} + +/** + * WP_Customize_Filter_Setting class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-filter-setting.php' ); + +/** + * WP_Customize_Header_Image_Setting class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-setting.php' ); + +/** + * WP_Customize_Background_Image_Setting class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-setting.php' ); + +/** + * WP_Customize_Nav_Menu_Item_Setting class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-setting.php' ); + +/** + * WP_Customize_Nav_Menu_Setting class. + */ +require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-setting.php' ); diff --git a/backend/wp-includes/class-wp-customize-widgets.php b/backend/wp-includes/class-wp-customize-widgets.php new file mode 100644 index 0000000..a54794b --- /dev/null +++ b/backend/wp-includes/class-wp-customize-widgets.php @@ -0,0 +1,2029 @@ +<?php +/** + * WordPress Customize Widgets classes + * + * @package WordPress + * @subpackage Customize + * @since 3.9.0 + */ + +/** + * Customize Widgets class. + * + * Implements widget management in the Customizer. + * + * @since 3.9.0 + * + * @see WP_Customize_Manager + */ +final class WP_Customize_Widgets { + + /** + * WP_Customize_Manager instance. + * + * @since 3.9.0 + * @var WP_Customize_Manager + */ + public $manager; + + /** + * All id_bases for widgets defined in core. + * + * @since 3.9.0 + * @var array + */ + protected $core_widget_id_bases = array( + 'archives', + 'calendar', + 'categories', + 'custom_html', + 'links', + 'media_audio', + 'media_image', + 'media_video', + 'meta', + 'nav_menu', + 'pages', + 'recent-comments', + 'recent-posts', + 'rss', + 'search', + 'tag_cloud', + 'text', + ); + + /** + * @since 3.9.0 + * @var array + */ + protected $rendered_sidebars = array(); + + /** + * @since 3.9.0 + * @var array + */ + protected $rendered_widgets = array(); + + /** + * @since 3.9.0 + * @var array + */ + protected $old_sidebars_widgets = array(); + + /** + * Mapping of widget ID base to whether it supports selective refresh. + * + * @since 4.5.0 + * @var array + */ + protected $selective_refreshable_widgets; + + /** + * Mapping of setting type to setting ID pattern. + * + * @since 4.2.0 + * @var array + */ + protected $setting_id_patterns = array( + 'widget_instance' => '/^widget_(?P<id_base>.+?)(?:\[(?P<widget_number>\d+)\])?$/', + 'sidebar_widgets' => '/^sidebars_widgets\[(?P<sidebar_id>.+?)\]$/', + ); + + /** + * Initial loader. + * + * @since 3.9.0 + * + * @param WP_Customize_Manager $manager Customize manager bootstrap instance. + */ + public function __construct( $manager ) { + $this->manager = $manager; + + // See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L420-L449 + add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 ); + add_action( 'widgets_init', array( $this, 'register_settings' ), 95 ); + add_action( 'customize_register', array( $this, 'schedule_customize_register' ), 1 ); + + // Skip remaining hooks when the user can't manage widgets anyway. + if ( ! current_user_can( 'edit_theme_options' ) ) { + return; + } + + add_action( 'wp_loaded', array( $this, 'override_sidebars_widgets_for_theme_switch' ) ); + add_action( 'customize_controls_init', array( $this, 'customize_controls_init' ) ); + add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + add_action( 'customize_controls_print_styles', array( $this, 'print_styles' ) ); + add_action( 'customize_controls_print_scripts', array( $this, 'print_scripts' ) ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_footer_scripts' ) ); + add_action( 'customize_controls_print_footer_scripts', array( $this, 'output_widget_control_templates' ) ); + add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) ); + add_filter( 'customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); + + add_action( 'dynamic_sidebar', array( $this, 'tally_rendered_widgets' ) ); + add_filter( 'is_active_sidebar', array( $this, 'tally_sidebars_via_is_active_sidebar_calls' ), 10, 2 ); + add_filter( 'dynamic_sidebar_has_widgets', array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 ); + + // Selective Refresh. + add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 ); + add_action( 'customize_preview_init', array( $this, 'selective_refresh_init' ) ); + } + + /** + * List whether each registered widget can be use selective refresh. + * + * If the theme does not support the customize-selective-refresh-widgets feature, + * then this will always return an empty array. + * + * @since 4.5.0 + * + * @global WP_Widget_Factory $wp_widget_factory + * + * @return array Mapping of id_base to support. If theme doesn't support + * selective refresh, an empty array is returned. + */ + public function get_selective_refreshable_widgets() { + global $wp_widget_factory; + if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) { + return array(); + } + if ( ! isset( $this->selective_refreshable_widgets ) ) { + $this->selective_refreshable_widgets = array(); + foreach ( $wp_widget_factory->widgets as $wp_widget ) { + $this->selective_refreshable_widgets[ $wp_widget->id_base ] = ! empty( $wp_widget->widget_options['customize_selective_refresh'] ); + } + } + return $this->selective_refreshable_widgets; + } + + /** + * Determines if a widget supports selective refresh. + * + * @since 4.5.0 + * + * @param string $id_base Widget ID Base. + * @return bool Whether the widget can be selective refreshed. + */ + public function is_widget_selective_refreshable( $id_base ) { + $selective_refreshable_widgets = $this->get_selective_refreshable_widgets(); + return ! empty( $selective_refreshable_widgets[ $id_base ] ); + } + + /** + * Retrieves the widget setting type given a setting ID. + * + * @since 4.2.0 + * + * @staticvar array $cache + * + * @param string $setting_id Setting ID. + * @return string|void Setting type. + */ + protected function get_setting_type( $setting_id ) { + static $cache = array(); + if ( isset( $cache[ $setting_id ] ) ) { + return $cache[ $setting_id ]; + } + foreach ( $this->setting_id_patterns as $type => $pattern ) { + if ( preg_match( $pattern, $setting_id ) ) { + $cache[ $setting_id ] = $type; + return $type; + } + } + } + + /** + * Inspects the incoming customized data for any widget settings, and dynamically adds + * them up-front so widgets will be initialized properly. + * + * @since 4.2.0 + */ + public function register_settings() { + $widget_setting_ids = array(); + $incoming_setting_ids = array_keys( $this->manager->unsanitized_post_values() ); + foreach ( $incoming_setting_ids as $setting_id ) { + if ( ! is_null( $this->get_setting_type( $setting_id ) ) ) { + $widget_setting_ids[] = $setting_id; + } + } + if ( $this->manager->doing_ajax( 'update-widget' ) && isset( $_REQUEST['widget-id'] ) ) { + $widget_setting_ids[] = $this->get_setting_id( wp_unslash( $_REQUEST['widget-id'] ) ); + } + + $settings = $this->manager->add_dynamic_settings( array_unique( $widget_setting_ids ) ); + + if ( $this->manager->settings_previewed() ) { + foreach ( $settings as $setting ) { + $setting->preview(); + } + } + } + + /** + * Determines the arguments for a dynamically-created setting. + * + * @since 4.2.0 + * + * @param false|array $args The arguments to the WP_Customize_Setting constructor. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + * @return false|array Setting arguments, false otherwise. + */ + public function filter_customize_dynamic_setting_args( $args, $setting_id ) { + if ( $this->get_setting_type( $setting_id ) ) { + $args = $this->get_setting_args( $setting_id ); + } + return $args; + } + + /** + * Retrieves an unslashed post value or return a default. + * + * @since 3.9.0 + * + * @param string $name Post value. + * @param mixed $default Default post value. + * @return mixed Unslashed post value or default value. + */ + protected function get_post_value( $name, $default = null ) { + if ( ! isset( $_POST[ $name ] ) ) { + return $default; + } + + return wp_unslash( $_POST[ $name ] ); + } + + /** + * Override sidebars_widgets for theme switch. + * + * When switching a theme via the Customizer, supply any previously-configured + * sidebars_widgets from the target theme as the initial sidebars_widgets + * setting. Also store the old theme's existing settings so that they can + * be passed along for storing in the sidebars_widgets theme_mod when the + * theme gets switched. + * + * @since 3.9.0 + * + * @global array $sidebars_widgets + * @global array $_wp_sidebars_widgets + */ + public function override_sidebars_widgets_for_theme_switch() { + global $sidebars_widgets; + + if ( $this->manager->doing_ajax() || $this->manager->is_theme_active() ) { + return; + } + + $this->old_sidebars_widgets = wp_get_sidebars_widgets(); + add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) ); + $this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset. + + // retrieve_widgets() looks at the global $sidebars_widgets + $sidebars_widgets = $this->old_sidebars_widgets; + $sidebars_widgets = retrieve_widgets( 'customize' ); + add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 ); + // reset global cache var used by wp_get_sidebars_widgets() + unset( $GLOBALS['_wp_sidebars_widgets'] ); + } + + /** + * Filters old_sidebars_widgets_data Customizer setting. + * + * When switching themes, filter the Customizer setting old_sidebars_widgets_data + * to supply initial $sidebars_widgets before they were overridden by retrieve_widgets(). + * The value for old_sidebars_widgets_data gets set in the old theme's sidebars_widgets + * theme_mod. + * + * @since 3.9.0 + * + * @see WP_Customize_Widgets::handle_theme_switch() + * + * @param array $old_sidebars_widgets + * @return array + */ + public function filter_customize_value_old_sidebars_widgets_data( $old_sidebars_widgets ) { + return $this->old_sidebars_widgets; + } + + /** + * Filters sidebars_widgets option for theme switch. + * + * When switching themes, the retrieve_widgets() function is run when the Customizer initializes, + * and then the new sidebars_widgets here get supplied as the default value for the sidebars_widgets + * option. + * + * @since 3.9.0 + * + * @see WP_Customize_Widgets::handle_theme_switch() + * @global array $sidebars_widgets + * + * @param array $sidebars_widgets + * @return array + */ + public function filter_option_sidebars_widgets_for_theme_switch( $sidebars_widgets ) { + $sidebars_widgets = $GLOBALS['sidebars_widgets']; + $sidebars_widgets['array_version'] = 3; + return $sidebars_widgets; + } + + /** + * Ensures all widgets get loaded into the Customizer. + * + * Note: these actions are also fired in wp_ajax_update_widget(). + * + * @since 3.9.0 + */ + public function customize_controls_init() { + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'load-widgets.php' ); + + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'widgets.php' ); + + /** This action is documented in wp-admin/widgets.php */ + do_action( 'sidebar_admin_setup' ); + } + + /** + * Ensures widgets are available for all types of previews. + * + * When in preview, hook to {@see 'customize_register'} for settings after WordPress is loaded + * so that all filters have been initialized (e.g. Widget Visibility). + * + * @since 3.9.0 + */ + public function schedule_customize_register() { + if ( is_admin() ) { + $this->customize_register(); + } else { + add_action( 'wp', array( $this, 'customize_register' ) ); + } + } + + /** + * Registers Customizer settings and controls for all sidebars and widgets. + * + * @since 3.9.0 + * + * @global array $wp_registered_widgets + * @global array $wp_registered_widget_controls + * @global array $wp_registered_sidebars + */ + public function customize_register() { + global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_sidebars; + + add_filter( 'sidebars_widgets', array( $this, 'preview_sidebars_widgets' ), 1 ); + + $sidebars_widgets = array_merge( + array( 'wp_inactive_widgets' => array() ), + array_fill_keys( array_keys( $wp_registered_sidebars ), array() ), + wp_get_sidebars_widgets() + ); + + $new_setting_ids = array(); + + /* + * Register a setting for all widgets, including those which are active, + * inactive, and orphaned since a widget may get suppressed from a sidebar + * via a plugin (like Widget Visibility). + */ + foreach ( array_keys( $wp_registered_widgets ) as $widget_id ) { + $setting_id = $this->get_setting_id( $widget_id ); + $setting_args = $this->get_setting_args( $setting_id ); + if ( ! $this->manager->get_setting( $setting_id ) ) { + $this->manager->add_setting( $setting_id, $setting_args ); + } + $new_setting_ids[] = $setting_id; + } + + /* + * Add a setting which will be supplied for the theme's sidebars_widgets + * theme_mod when the theme is switched. + */ + if ( ! $this->manager->is_theme_active() ) { + $setting_id = 'old_sidebars_widgets_data'; + $setting_args = $this->get_setting_args( $setting_id, array( + 'type' => 'global_variable', + 'dirty' => true, + ) ); + $this->manager->add_setting( $setting_id, $setting_args ); + } + + $this->manager->add_panel( 'widgets', array( + 'type' => 'widgets', + 'title' => __( 'Widgets' ), + 'description' => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ), + 'priority' => 110, + 'active_callback' => array( $this, 'is_panel_active' ), + 'auto_expand_sole_section' => true, + ) ); + + foreach ( $sidebars_widgets as $sidebar_id => $sidebar_widget_ids ) { + if ( empty( $sidebar_widget_ids ) ) { + $sidebar_widget_ids = array(); + } + + $is_registered_sidebar = is_registered_sidebar( $sidebar_id ); + $is_inactive_widgets = ( 'wp_inactive_widgets' === $sidebar_id ); + $is_active_sidebar = ( $is_registered_sidebar && ! $is_inactive_widgets ); + + // Add setting for managing the sidebar's widgets. + if ( $is_registered_sidebar || $is_inactive_widgets ) { + $setting_id = sprintf( 'sidebars_widgets[%s]', $sidebar_id ); + $setting_args = $this->get_setting_args( $setting_id ); + if ( ! $this->manager->get_setting( $setting_id ) ) { + if ( ! $this->manager->is_theme_active() ) { + $setting_args['dirty'] = true; + } + $this->manager->add_setting( $setting_id, $setting_args ); + } + $new_setting_ids[] = $setting_id; + + // Add section to contain controls. + $section_id = sprintf( 'sidebar-widgets-%s', $sidebar_id ); + if ( $is_active_sidebar ) { + + $section_args = array( + 'title' => $wp_registered_sidebars[ $sidebar_id ]['name'], + 'description' => $wp_registered_sidebars[ $sidebar_id ]['description'], + 'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ), + 'panel' => 'widgets', + 'sidebar_id' => $sidebar_id, + ); + + /** + * Filters Customizer widget section arguments for a given sidebar. + * + * @since 3.9.0 + * + * @param array $section_args Array of Customizer widget section arguments. + * @param string $section_id Customizer section ID. + * @param int|string $sidebar_id Sidebar ID. + */ + $section_args = apply_filters( 'customizer_widgets_section_args', $section_args, $section_id, $sidebar_id ); + + $section = new WP_Customize_Sidebar_Section( $this->manager, $section_id, $section_args ); + $this->manager->add_section( $section ); + + $control = new WP_Widget_Area_Customize_Control( $this->manager, $setting_id, array( + 'section' => $section_id, + 'sidebar_id' => $sidebar_id, + 'priority' => count( $sidebar_widget_ids ), // place 'Add Widget' and 'Reorder' buttons at end. + ) ); + $new_setting_ids[] = $setting_id; + + $this->manager->add_control( $control ); + } + } + + // Add a control for each active widget (located in a sidebar). + foreach ( $sidebar_widget_ids as $i => $widget_id ) { + + // Skip widgets that may have gone away due to a plugin being deactivated. + if ( ! $is_active_sidebar || ! isset( $wp_registered_widgets[$widget_id] ) ) { + continue; + } + + $registered_widget = $wp_registered_widgets[$widget_id]; + $setting_id = $this->get_setting_id( $widget_id ); + $id_base = $wp_registered_widget_controls[$widget_id]['id_base']; + + $control = new WP_Widget_Form_Customize_Control( $this->manager, $setting_id, array( + 'label' => $registered_widget['name'], + 'section' => $section_id, + 'sidebar_id' => $sidebar_id, + 'widget_id' => $widget_id, + 'widget_id_base' => $id_base, + 'priority' => $i, + 'width' => $wp_registered_widget_controls[$widget_id]['width'], + 'height' => $wp_registered_widget_controls[$widget_id]['height'], + 'is_wide' => $this->is_wide_widget( $widget_id ), + ) ); + $this->manager->add_control( $control ); + } + } + + if ( $this->manager->settings_previewed() ) { + foreach ( $new_setting_ids as $new_setting_id ) { + $this->manager->get_setting( $new_setting_id )->preview(); + } + } + } + + /** + * Determines whether the widgets panel is active, based on whether there are sidebars registered. + * + * @since 4.4.0 + * + * @see WP_Customize_Panel::$active_callback + * + * @global array $wp_registered_sidebars + * @return bool Active. + */ + public function is_panel_active() { + global $wp_registered_sidebars; + return ! empty( $wp_registered_sidebars ); + } + + /** + * Converts a widget_id into its corresponding Customizer setting ID (option name). + * + * @since 3.9.0 + * + * @param string $widget_id Widget ID. + * @return string Maybe-parsed widget ID. + */ + public function get_setting_id( $widget_id ) { + $parsed_widget_id = $this->parse_widget_id( $widget_id ); + $setting_id = sprintf( 'widget_%s', $parsed_widget_id['id_base'] ); + + if ( ! is_null( $parsed_widget_id['number'] ) ) { + $setting_id .= sprintf( '[%d]', $parsed_widget_id['number'] ); + } + return $setting_id; + } + + /** + * Determines whether the widget is considered "wide". + * + * Core widgets which may have controls wider than 250, but can still be shown + * in the narrow Customizer panel. The RSS and Text widgets in Core, for example, + * have widths of 400 and yet they still render fine in the Customizer panel. + * + * This method will return all Core widgets as being not wide, but this can be + * overridden with the {@see 'is_wide_widget_in_customizer'} filter. + * + * @since 3.9.0 + * + * @global $wp_registered_widget_controls + * + * @param string $widget_id Widget ID. + * @return bool Whether or not the widget is a "wide" widget. + */ + public function is_wide_widget( $widget_id ) { + global $wp_registered_widget_controls; + + $parsed_widget_id = $this->parse_widget_id( $widget_id ); + $width = $wp_registered_widget_controls[$widget_id]['width']; + $is_core = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases ); + $is_wide = ( $width > 250 && ! $is_core ); + + /** + * Filters whether the given widget is considered "wide". + * + * @since 3.9.0 + * + * @param bool $is_wide Whether the widget is wide, Default false. + * @param string $widget_id Widget ID. + */ + return apply_filters( 'is_wide_widget_in_customizer', $is_wide, $widget_id ); + } + + /** + * Converts a widget ID into its id_base and number components. + * + * @since 3.9.0 + * + * @param string $widget_id Widget ID. + * @return array Array containing a widget's id_base and number components. + */ + public function parse_widget_id( $widget_id ) { + $parsed = array( + 'number' => null, + 'id_base' => null, + ); + + if ( preg_match( '/^(.+)-(\d+)$/', $widget_id, $matches ) ) { + $parsed['id_base'] = $matches[1]; + $parsed['number'] = intval( $matches[2] ); + } else { + // likely an old single widget + $parsed['id_base'] = $widget_id; + } + return $parsed; + } + + /** + * Converts a widget setting ID (option path) to its id_base and number components. + * + * @since 3.9.0 + * + * @param string $setting_id Widget setting ID. + * @return WP_Error|array Array containing a widget's id_base and number components, + * or a WP_Error object. + */ + public function parse_widget_setting_id( $setting_id ) { + if ( ! preg_match( '/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches ) ) { + return new WP_Error( 'widget_setting_invalid_id' ); + } + + $id_base = $matches[2]; + $number = isset( $matches[3] ) ? intval( $matches[3] ) : null; + + return compact( 'id_base', 'number' ); + } + + /** + * Calls admin_print_styles-widgets.php and admin_print_styles hooks to + * allow custom styles from plugins. + * + * @since 3.9.0 + */ + public function print_styles() { + /** This action is documented in wp-admin/admin-header.php */ + do_action( 'admin_print_styles-widgets.php' ); + + /** This action is documented in wp-admin/admin-header.php */ + do_action( 'admin_print_styles' ); + } + + /** + * Calls admin_print_scripts-widgets.php and admin_print_scripts hooks to + * allow custom scripts from plugins. + * + * @since 3.9.0 + */ + public function print_scripts() { + /** This action is documented in wp-admin/admin-header.php */ + do_action( 'admin_print_scripts-widgets.php' ); + + /** This action is documented in wp-admin/admin-header.php */ + do_action( 'admin_print_scripts' ); + } + + /** + * Enqueues scripts and styles for Customizer panel and export data to JavaScript. + * + * @since 3.9.0 + * + * @global WP_Scripts $wp_scripts + * @global array $wp_registered_sidebars + * @global array $wp_registered_widgets + */ + public function enqueue_scripts() { + global $wp_scripts, $wp_registered_sidebars, $wp_registered_widgets; + + wp_enqueue_style( 'customize-widgets' ); + wp_enqueue_script( 'customize-widgets' ); + + /** This action is documented in wp-admin/admin-header.php */ + do_action( 'admin_enqueue_scripts', 'widgets.php' ); + + /* + * Export available widgets with control_tpl removed from model + * since plugins need templates to be in the DOM. + */ + $available_widgets = array(); + + foreach ( $this->get_available_widgets() as $available_widget ) { + unset( $available_widget['control_tpl'] ); + $available_widgets[] = $available_widget; + } + + $widget_reorder_nav_tpl = sprintf( + '<div class="widget-reorder-nav"><span class="move-widget" tabindex="0">%1$s</span><span class="move-widget-down" tabindex="0">%2$s</span><span class="move-widget-up" tabindex="0">%3$s</span></div>', + __( 'Move to another area…' ), + __( 'Move down' ), + __( 'Move up' ) + ); + + $move_widget_area_tpl = str_replace( + array( '{description}', '{btn}' ), + array( + __( 'Select an area to move this widget into:' ), + _x( 'Move', 'Move widget' ), + ), + '<div class="move-widget-area"> + <p class="description">{description}</p> + <ul class="widget-area-select"> + <% _.each( sidebars, function ( sidebar ){ %> + <li class="" data-id="<%- sidebar.id %>" title="<%- sidebar.description %>" tabindex="0"><%- sidebar.name %></li> + <% }); %> + </ul> + <div class="move-widget-actions"> + <button class="move-widget-btn button" type="button">{btn}</button> + </div> + </div>' + ); + + /* + * Gather all strings in PHP that may be needed by JS on the client. + * Once JS i18n is implemented (in #20491), this can be removed. + */ + $some_non_rendered_areas_messages = array(); + $some_non_rendered_areas_messages[1] = html_entity_decode( + __( 'Your theme has 1 other widget area, but this particular page doesn’t display it.' ), + ENT_QUOTES, + get_bloginfo( 'charset' ) + ); + $registered_sidebar_count = count( $wp_registered_sidebars ); + for ( $non_rendered_count = 2; $non_rendered_count < $registered_sidebar_count; $non_rendered_count++ ) { + $some_non_rendered_areas_messages[ $non_rendered_count ] = html_entity_decode( sprintf( + /* translators: %s: the number of other widget areas registered but not rendered */ + _n( + 'Your theme has %s other widget area, but this particular page doesn’t display it.', + 'Your theme has %s other widget areas, but this particular page doesn’t display them.', + $non_rendered_count + ), + number_format_i18n( $non_rendered_count ) + ), ENT_QUOTES, get_bloginfo( 'charset' ) ); + } + + if ( 1 === $registered_sidebar_count ) { + $no_areas_shown_message = html_entity_decode( sprintf( + __( 'Your theme has 1 widget area, but this particular page doesn’t display it.' ) + ), ENT_QUOTES, get_bloginfo( 'charset' ) ); + } else { + $no_areas_shown_message = html_entity_decode( sprintf( + /* translators: %s: the total number of widget areas registered */ + _n( + 'Your theme has %s widget area, but this particular page doesn’t display it.', + 'Your theme has %s widget areas, but this particular page doesn’t display them.', + $registered_sidebar_count + ), + number_format_i18n( $registered_sidebar_count ) + ), ENT_QUOTES, get_bloginfo( 'charset' ) ); + } + + $settings = array( + 'registeredSidebars' => array_values( $wp_registered_sidebars ), + 'registeredWidgets' => $wp_registered_widgets, + 'availableWidgets' => $available_widgets, // @todo Merge this with registered_widgets + 'l10n' => array( + 'saveBtnLabel' => __( 'Apply' ), + 'saveBtnTooltip' => __( 'Save and preview changes before publishing them.' ), + 'removeBtnLabel' => __( 'Remove' ), + 'removeBtnTooltip' => __( 'Trash widget by moving it to the inactive widgets sidebar.' ), + 'error' => __( 'An error has occurred. Please reload the page and try again.' ), + 'widgetMovedUp' => __( 'Widget moved up' ), + 'widgetMovedDown' => __( 'Widget moved down' ), + 'navigatePreview' => __( 'You can navigate to other pages on your site while using the Customizer to view and edit the widgets displayed on those pages.' ), + 'someAreasShown' => $some_non_rendered_areas_messages, + 'noAreasShown' => $no_areas_shown_message, + 'reorderModeOn' => __( 'Reorder mode enabled' ), + 'reorderModeOff' => __( 'Reorder mode closed' ), + 'reorderLabelOn' => esc_attr__( 'Reorder widgets' ), + /* translators: %d: the number of widgets found */ + 'widgetsFound' => __( 'Number of widgets found: %d' ), + 'noWidgetsFound' => __( 'No widgets found.' ), + ), + 'tpl' => array( + 'widgetReorderNav' => $widget_reorder_nav_tpl, + 'moveWidgetArea' => $move_widget_area_tpl, + ), + 'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(), + ); + + foreach ( $settings['registeredWidgets'] as &$registered_widget ) { + unset( $registered_widget['callback'] ); // may not be JSON-serializeable + } + + $wp_scripts->add_data( + 'customize-widgets', + 'data', + sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings ) ) + ); + } + + /** + * Renders the widget form control templates into the DOM. + * + * @since 3.9.0 + */ + public function output_widget_control_templates() { + ?> + <div id="widgets-left"><!-- compatibility with JS which looks for widget templates here --> + <div id="available-widgets"> + <div class="customize-section-title"> + <button class="customize-section-back" tabindex="-1"> + <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> + </button> + <h3> + <span class="customize-action"><?php + /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ + echo sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( 'widgets' )->title ) ); + ?></span> + <?php _e( 'Add a Widget' ); ?> + </h3> + </div> + <div id="available-widgets-filter"> + <label class="screen-reader-text" for="widgets-search"><?php _e( 'Search Widgets' ); ?></label> + <input type="text" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets…' ) ?>" aria-describedby="widgets-search-desc" /> + <div class="search-icon" aria-hidden="true"></div> + <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button> + <p class="screen-reader-text" id="widgets-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p> + </div> + <div id="available-widgets-list"> + <?php foreach ( $this->get_available_widgets() as $available_widget ): ?> + <div id="widget-tpl-<?php echo esc_attr( $available_widget['id'] ) ?>" data-widget-id="<?php echo esc_attr( $available_widget['id'] ) ?>" class="widget-tpl <?php echo esc_attr( $available_widget['id'] ) ?>" tabindex="0"> + <?php echo $available_widget['control_tpl']; ?> + </div> + <?php endforeach; ?> + <p class="no-widgets-found-message"><?php _e( 'No widgets found.' ); ?></p> + </div><!-- #available-widgets-list --> + </div><!-- #available-widgets --> + </div><!-- #widgets-left --> + <?php + } + + /** + * Calls admin_print_footer_scripts and admin_print_scripts hooks to + * allow custom scripts from plugins. + * + * @since 3.9.0 + */ + public function print_footer_scripts() { + /** This action is documented in wp-admin/admin-footer.php */ + do_action( 'admin_print_footer_scripts-widgets.php' ); + + /** This action is documented in wp-admin/admin-footer.php */ + do_action( 'admin_print_footer_scripts' ); + + /** This action is documented in wp-admin/admin-footer.php */ + do_action( 'admin_footer-widgets.php' ); + } + + /** + * Retrieves common arguments to supply when constructing a Customizer setting. + * + * @since 3.9.0 + * + * @param string $id Widget setting ID. + * @param array $overrides Array of setting overrides. + * @return array Possibly modified setting arguments. + */ + public function get_setting_args( $id, $overrides = array() ) { + $args = array( + 'type' => 'option', + 'capability' => 'edit_theme_options', + 'default' => array(), + ); + + if ( preg_match( $this->setting_id_patterns['sidebar_widgets'], $id, $matches ) ) { + $args['sanitize_callback'] = array( $this, 'sanitize_sidebar_widgets' ); + $args['sanitize_js_callback'] = array( $this, 'sanitize_sidebar_widgets_js_instance' ); + $args['transport'] = current_theme_supports( 'customize-selective-refresh-widgets' ) ? 'postMessage' : 'refresh'; + } elseif ( preg_match( $this->setting_id_patterns['widget_instance'], $id, $matches ) ) { + $args['sanitize_callback'] = array( $this, 'sanitize_widget_instance' ); + $args['sanitize_js_callback'] = array( $this, 'sanitize_widget_js_instance' ); + $args['transport'] = $this->is_widget_selective_refreshable( $matches['id_base'] ) ? 'postMessage' : 'refresh'; + } + + $args = array_merge( $args, $overrides ); + + /** + * Filters the common arguments supplied when constructing a Customizer setting. + * + * @since 3.9.0 + * + * @see WP_Customize_Setting + * + * @param array $args Array of Customizer setting arguments. + * @param string $id Widget setting ID. + */ + return apply_filters( 'widget_customizer_setting_args', $args, $id ); + } + + /** + * Ensures sidebar widget arrays only ever contain widget IDS. + * + * Used as the 'sanitize_callback' for each $sidebars_widgets setting. + * + * @since 3.9.0 + * + * @param array $widget_ids Array of widget IDs. + * @return array Array of sanitized widget IDs. + */ + public function sanitize_sidebar_widgets( $widget_ids ) { + $widget_ids = array_map( 'strval', (array) $widget_ids ); + $sanitized_widget_ids = array(); + foreach ( $widget_ids as $widget_id ) { + $sanitized_widget_ids[] = preg_replace( '/[^a-z0-9_\-]/', '', $widget_id ); + } + return $sanitized_widget_ids; + } + + /** + * Builds up an index of all available widgets for use in Backbone models. + * + * @since 3.9.0 + * + * @global array $wp_registered_widgets + * @global array $wp_registered_widget_controls + * @staticvar array $available_widgets + * + * @see wp_list_widgets() + * + * @return array List of available widgets. + */ + public function get_available_widgets() { + static $available_widgets = array(); + if ( ! empty( $available_widgets ) ) { + return $available_widgets; + } + + global $wp_registered_widgets, $wp_registered_widget_controls; + require_once ABSPATH . '/wp-admin/includes/widgets.php'; // for next_widget_id_number() + + $sort = $wp_registered_widgets; + usort( $sort, array( $this, '_sort_name_callback' ) ); + $done = array(); + + foreach ( $sort as $widget ) { + if ( in_array( $widget['callback'], $done, true ) ) { // We already showed this multi-widget + continue; + } + + $sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false ); + $done[] = $widget['callback']; + + if ( ! isset( $widget['params'][0] ) ) { + $widget['params'][0] = array(); + } + + $available_widget = $widget; + unset( $available_widget['callback'] ); // not serializable to JSON + + $args = array( + 'widget_id' => $widget['id'], + 'widget_name' => $widget['name'], + '_display' => 'template', + ); + + $is_disabled = false; + $is_multi_widget = ( isset( $wp_registered_widget_controls[$widget['id']]['id_base'] ) && isset( $widget['params'][0]['number'] ) ); + if ( $is_multi_widget ) { + $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; + $args['_temp_id'] = "$id_base-__i__"; + $args['_multi_num'] = next_widget_id_number( $id_base ); + $args['_add'] = 'multi'; + } else { + $args['_add'] = 'single'; + + if ( $sidebar && 'wp_inactive_widgets' !== $sidebar ) { + $is_disabled = true; + } + $id_base = $widget['id']; + } + + $list_widget_controls_args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) ); + $control_tpl = $this->get_widget_control( $list_widget_controls_args ); + + // The properties here are mapped to the Backbone Widget model. + $available_widget = array_merge( $available_widget, array( + 'temp_id' => isset( $args['_temp_id'] ) ? $args['_temp_id'] : null, + 'is_multi' => $is_multi_widget, + 'control_tpl' => $control_tpl, + 'multi_number' => ( $args['_add'] === 'multi' ) ? $args['_multi_num'] : false, + 'is_disabled' => $is_disabled, + 'id_base' => $id_base, + 'transport' => $this->is_widget_selective_refreshable( $id_base ) ? 'postMessage' : 'refresh', + 'width' => $wp_registered_widget_controls[$widget['id']]['width'], + 'height' => $wp_registered_widget_controls[$widget['id']]['height'], + 'is_wide' => $this->is_wide_widget( $widget['id'] ), + ) ); + + $available_widgets[] = $available_widget; + } + + return $available_widgets; + } + + /** + * Naturally orders available widgets by name. + * + * @since 3.9.0 + * + * @param array $widget_a The first widget to compare. + * @param array $widget_b The second widget to compare. + * @return int Reorder position for the current widget comparison. + */ + protected function _sort_name_callback( $widget_a, $widget_b ) { + return strnatcasecmp( $widget_a['name'], $widget_b['name'] ); + } + + /** + * Retrieves the widget control markup. + * + * @since 3.9.0 + * + * @param array $args Widget control arguments. + * @return string Widget control form HTML markup. + */ + public function get_widget_control( $args ) { + $args[0]['before_form'] = '<div class="form">'; + $args[0]['after_form'] = '</div><!-- .form -->'; + $args[0]['before_widget_content'] = '<div class="widget-content">'; + $args[0]['after_widget_content'] = '</div><!-- .widget-content -->'; + ob_start(); + call_user_func_array( 'wp_widget_control', $args ); + $control_tpl = ob_get_clean(); + return $control_tpl; + } + + /** + * Retrieves the widget control markup parts. + * + * @since 4.4.0 + * + * @param array $args Widget control arguments. + * @return array { + * @type string $control Markup for widget control wrapping form. + * @type string $content The contents of the widget form itself. + * } + */ + public function get_widget_control_parts( $args ) { + $args[0]['before_widget_content'] = '<div class="widget-content">'; + $args[0]['after_widget_content'] = '</div><!-- .widget-content -->'; + $control_markup = $this->get_widget_control( $args ); + + $content_start_pos = strpos( $control_markup, $args[0]['before_widget_content'] ); + $content_end_pos = strrpos( $control_markup, $args[0]['after_widget_content'] ); + + $control = substr( $control_markup, 0, $content_start_pos + strlen( $args[0]['before_widget_content'] ) ); + $control .= substr( $control_markup, $content_end_pos ); + $content = trim( substr( + $control_markup, + $content_start_pos + strlen( $args[0]['before_widget_content'] ), + $content_end_pos - $content_start_pos - strlen( $args[0]['before_widget_content'] ) + ) ); + + return compact( 'control', 'content' ); + } + + /** + * Adds hooks for the Customizer preview. + * + * @since 3.9.0 + */ + public function customize_preview_init() { + add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue' ) ); + add_action( 'wp_print_styles', array( $this, 'print_preview_css' ), 1 ); + add_action( 'wp_footer', array( $this, 'export_preview_data' ), 20 ); + } + + /** + * Refreshes the nonce for widget updates. + * + * @since 4.2.0 + * + * @param array $nonces Array of nonces. + * @return array $nonces Array of nonces. + */ + public function refresh_nonces( $nonces ) { + $nonces['update-widget'] = wp_create_nonce( 'update-widget' ); + return $nonces; + } + + /** + * When previewing, ensures the proper previewing widgets are used. + * + * Because wp_get_sidebars_widgets() gets called early at {@see 'init' } (via + * wp_convert_widget_settings()) and can set global variable `$_wp_sidebars_widgets` + * to the value of `get_option( 'sidebars_widgets' )` before the Customizer preview + * filter is added, it has to be reset after the filter has been added. + * + * @since 3.9.0 + * + * @param array $sidebars_widgets List of widgets for the current sidebar. + * @return array + */ + public function preview_sidebars_widgets( $sidebars_widgets ) { + $sidebars_widgets = get_option( 'sidebars_widgets', array() ); + + unset( $sidebars_widgets['array_version'] ); + return $sidebars_widgets; + } + + /** + * Enqueues scripts for the Customizer preview. + * + * @since 3.9.0 + */ + public function customize_preview_enqueue() { + wp_enqueue_script( 'customize-preview-widgets' ); + } + + /** + * Inserts default style for highlighted widget at early point so theme + * stylesheet can override. + * + * @since 3.9.0 + */ + public function print_preview_css() { + ?> + <style> + .widget-customizer-highlighted-widget { + outline: none; + -webkit-box-shadow: 0 0 2px rgba(30,140,190,0.8); + box-shadow: 0 0 2px rgba(30,140,190,0.8); + position: relative; + z-index: 1; + } + </style> + <?php + } + + /** + * Communicates the sidebars that appeared on the page at the very end of the page, + * and at the very end of the wp_footer, + * + * @since 3.9.0 + * + * @global array $wp_registered_sidebars + * @global array $wp_registered_widgets + */ + public function export_preview_data() { + global $wp_registered_sidebars, $wp_registered_widgets; + + $switched_locale = switch_to_locale( get_user_locale() ); + $l10n = array( + 'widgetTooltip' => __( 'Shift-click to edit this widget.' ), + ); + if ( $switched_locale ) { + restore_previous_locale(); + } + + // Prepare Customizer settings to pass to JavaScript. + $settings = array( + 'renderedSidebars' => array_fill_keys( array_unique( $this->rendered_sidebars ), true ), + 'renderedWidgets' => array_fill_keys( array_keys( $this->rendered_widgets ), true ), + 'registeredSidebars' => array_values( $wp_registered_sidebars ), + 'registeredWidgets' => $wp_registered_widgets, + 'l10n' => $l10n, + 'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(), + ); + foreach ( $settings['registeredWidgets'] as &$registered_widget ) { + unset( $registered_widget['callback'] ); // may not be JSON-serializeable + } + + ?> + <script type="text/javascript"> + var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode( $settings ); ?>; + </script> + <?php + } + + /** + * Tracks the widgets that were rendered. + * + * @since 3.9.0 + * + * @param array $widget Rendered widget to tally. + */ + public function tally_rendered_widgets( $widget ) { + $this->rendered_widgets[ $widget['id'] ] = true; + } + + /** + * Determine if a widget is rendered on the page. + * + * @since 4.0.0 + * + * @param string $widget_id Widget ID to check. + * @return bool Whether the widget is rendered. + */ + public function is_widget_rendered( $widget_id ) { + return in_array( $widget_id, $this->rendered_widgets ); + } + + /** + * Determines if a sidebar is rendered on the page. + * + * @since 4.0.0 + * + * @param string $sidebar_id Sidebar ID to check. + * @return bool Whether the sidebar is rendered. + */ + public function is_sidebar_rendered( $sidebar_id ) { + return in_array( $sidebar_id, $this->rendered_sidebars ); + } + + /** + * Tallies the sidebars rendered via is_active_sidebar(). + * + * Keep track of the times that is_active_sidebar() is called in the template, + * and assume that this means that the sidebar would be rendered on the template + * if there were widgets populating it. + * + * @since 3.9.0 + * + * @param bool $is_active Whether the sidebar is active. + * @param string $sidebar_id Sidebar ID. + * @return bool Whether the sidebar is active. + */ + public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) { + if ( is_registered_sidebar( $sidebar_id ) ) { + $this->rendered_sidebars[] = $sidebar_id; + } + /* + * We may need to force this to true, and also force-true the value + * for 'dynamic_sidebar_has_widgets' if we want to ensure that there + * is an area to drop widgets into, if the sidebar is empty. + */ + return $is_active; + } + + /** + * Tallies the sidebars rendered via dynamic_sidebar(). + * + * Keep track of the times that dynamic_sidebar() is called in the template, + * and assume this means the sidebar would be rendered on the template if + * there were widgets populating it. + * + * @since 3.9.0 + * + * @param bool $has_widgets Whether the current sidebar has widgets. + * @param string $sidebar_id Sidebar ID. + * @return bool Whether the current sidebar has widgets. + */ + public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) { + if ( is_registered_sidebar( $sidebar_id ) ) { + $this->rendered_sidebars[] = $sidebar_id; + } + + /* + * We may need to force this to true, and also force-true the value + * for 'is_active_sidebar' if we want to ensure there is an area to + * drop widgets into, if the sidebar is empty. + */ + return $has_widgets; + } + + /** + * Retrieves MAC for a serialized widget instance string. + * + * Allows values posted back from JS to be rejected if any tampering of the + * data has occurred. + * + * @since 3.9.0 + * + * @param string $serialized_instance Widget instance. + * @return string MAC for serialized widget instance. + */ + protected function get_instance_hash_key( $serialized_instance ) { + return wp_hash( $serialized_instance ); + } + + /** + * Sanitizes a widget instance. + * + * Unserialize the JS-instance for storing in the options. It's important that this filter + * only get applied to an instance *once*. + * + * @since 3.9.0 + * + * @param array $value Widget instance to sanitize. + * @return array|void Sanitized widget instance. + */ + public function sanitize_widget_instance( $value ) { + if ( $value === array() ) { + return $value; + } + + if ( empty( $value['is_widget_customizer_js_value'] ) + || empty( $value['instance_hash_key'] ) + || empty( $value['encoded_serialized_instance'] ) ) + { + return; + } + + $decoded = base64_decode( $value['encoded_serialized_instance'], true ); + if ( false === $decoded ) { + return; + } + + if ( ! hash_equals( $this->get_instance_hash_key( $decoded ), $value['instance_hash_key'] ) ) { + return; + } + + $instance = unserialize( $decoded ); + if ( false === $instance ) { + return; + } + + return $instance; + } + + /** + * Converts a widget instance into JSON-representable format. + * + * @since 3.9.0 + * + * @param array $value Widget instance to convert to JSON. + * @return array JSON-converted widget instance. + */ + public function sanitize_widget_js_instance( $value ) { + if ( empty( $value['is_widget_customizer_js_value'] ) ) { + $serialized = serialize( $value ); + + $value = array( + 'encoded_serialized_instance' => base64_encode( $serialized ), + 'title' => empty( $value['title'] ) ? '' : $value['title'], + 'is_widget_customizer_js_value' => true, + 'instance_hash_key' => $this->get_instance_hash_key( $serialized ), + ); + } + return $value; + } + + /** + * Strips out widget IDs for widgets which are no longer registered. + * + * One example where this might happen is when a plugin orphans a widget + * in a sidebar upon deactivation. + * + * @since 3.9.0 + * + * @global array $wp_registered_widgets + * + * @param array $widget_ids List of widget IDs. + * @return array Parsed list of widget IDs. + */ + public function sanitize_sidebar_widgets_js_instance( $widget_ids ) { + global $wp_registered_widgets; + $widget_ids = array_values( array_intersect( $widget_ids, array_keys( $wp_registered_widgets ) ) ); + return $widget_ids; + } + + /** + * Finds and invokes the widget update and control callbacks. + * + * Requires that `$_POST` be populated with the instance data. + * + * @since 3.9.0 + * + * @global array $wp_registered_widget_updates + * @global array $wp_registered_widget_controls + * + * @param string $widget_id Widget ID. + * @return WP_Error|array Array containing the updated widget information. + * A WP_Error object, otherwise. + */ + public function call_widget_update( $widget_id ) { + global $wp_registered_widget_updates, $wp_registered_widget_controls; + + $setting_id = $this->get_setting_id( $widget_id ); + + /* + * Make sure that other setting changes have previewed since this widget + * may depend on them (e.g. Menus being present for Navigation Menu widget). + */ + if ( ! did_action( 'customize_preview_init' ) ) { + foreach ( $this->manager->settings() as $setting ) { + if ( $setting->id !== $setting_id ) { + $setting->preview(); + } + } + } + + $this->start_capturing_option_updates(); + $parsed_id = $this->parse_widget_id( $widget_id ); + $option_name = 'widget_' . $parsed_id['id_base']; + + /* + * If a previously-sanitized instance is provided, populate the input vars + * with its values so that the widget update callback will read this instance + */ + $added_input_vars = array(); + if ( ! empty( $_POST['sanitized_widget_setting'] ) ) { + $sanitized_widget_setting = json_decode( $this->get_post_value( 'sanitized_widget_setting' ), true ); + if ( false === $sanitized_widget_setting ) { + $this->stop_capturing_option_updates(); + return new WP_Error( 'widget_setting_malformed' ); + } + + $instance = $this->sanitize_widget_instance( $sanitized_widget_setting ); + if ( is_null( $instance ) ) { + $this->stop_capturing_option_updates(); + return new WP_Error( 'widget_setting_unsanitized' ); + } + + if ( ! is_null( $parsed_id['number'] ) ) { + $value = array(); + $value[$parsed_id['number']] = $instance; + $key = 'widget-' . $parsed_id['id_base']; + $_REQUEST[$key] = $_POST[$key] = wp_slash( $value ); + $added_input_vars[] = $key; + } else { + foreach ( $instance as $key => $value ) { + $_REQUEST[$key] = $_POST[$key] = wp_slash( $value ); + $added_input_vars[] = $key; + } + } + } + + // Invoke the widget update callback. + foreach ( (array) $wp_registered_widget_updates as $name => $control ) { + if ( $name === $parsed_id['id_base'] && is_callable( $control['callback'] ) ) { + ob_start(); + call_user_func_array( $control['callback'], $control['params'] ); + ob_end_clean(); + break; + } + } + + // Clean up any input vars that were manually added + foreach ( $added_input_vars as $key ) { + unset( $_POST[ $key ] ); + unset( $_REQUEST[ $key ] ); + } + + // Make sure the expected option was updated. + if ( 0 !== $this->count_captured_options() ) { + if ( $this->count_captured_options() > 1 ) { + $this->stop_capturing_option_updates(); + return new WP_Error( 'widget_setting_too_many_options' ); + } + + $updated_option_name = key( $this->get_captured_options() ); + if ( $updated_option_name !== $option_name ) { + $this->stop_capturing_option_updates(); + return new WP_Error( 'widget_setting_unexpected_option' ); + } + } + + // Obtain the widget instance. + $option = $this->get_captured_option( $option_name ); + if ( null !== $parsed_id['number'] ) { + $instance = $option[ $parsed_id['number'] ]; + } else { + $instance = $option; + } + + /* + * Override the incoming $_POST['customized'] for a newly-created widget's + * setting with the new $instance so that the preview filter currently + * in place from WP_Customize_Setting::preview() will use this value + * instead of the default widget instance value (an empty array). + */ + $this->manager->set_post_value( $setting_id, $this->sanitize_widget_js_instance( $instance ) ); + + // Obtain the widget control with the updated instance in place. + ob_start(); + $form = $wp_registered_widget_controls[ $widget_id ]; + if ( $form ) { + call_user_func_array( $form['callback'], $form['params'] ); + } + $form = ob_get_clean(); + + $this->stop_capturing_option_updates(); + + return compact( 'instance', 'form' ); + } + + /** + * Updates widget settings asynchronously. + * + * Allows the Customizer to update a widget using its form, but return the new + * instance info via Ajax instead of saving it to the options table. + * + * Most code here copied from wp_ajax_save_widget(). + * + * @since 3.9.0 + * + * @see wp_ajax_save_widget() + */ + public function wp_ajax_update_widget() { + + if ( ! is_user_logged_in() ) { + wp_die( 0 ); + } + + check_ajax_referer( 'update-widget', 'nonce' ); + + if ( ! current_user_can( 'edit_theme_options' ) ) { + wp_die( -1 ); + } + + if ( empty( $_POST['widget-id'] ) ) { + wp_send_json_error( 'missing_widget-id' ); + } + + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'load-widgets.php' ); + + /** This action is documented in wp-admin/includes/ajax-actions.php */ + do_action( 'widgets.php' ); + + /** This action is documented in wp-admin/widgets.php */ + do_action( 'sidebar_admin_setup' ); + + $widget_id = $this->get_post_value( 'widget-id' ); + $parsed_id = $this->parse_widget_id( $widget_id ); + $id_base = $parsed_id['id_base']; + + $is_updating_widget_template = ( + isset( $_POST[ 'widget-' . $id_base ] ) + && + is_array( $_POST[ 'widget-' . $id_base ] ) + && + preg_match( '/__i__|%i%/', key( $_POST[ 'widget-' . $id_base ] ) ) + ); + if ( $is_updating_widget_template ) { + wp_send_json_error( 'template_widget_not_updatable' ); + } + + $updated_widget = $this->call_widget_update( $widget_id ); // => {instance,form} + if ( is_wp_error( $updated_widget ) ) { + wp_send_json_error( $updated_widget->get_error_code() ); + } + + $form = $updated_widget['form']; + $instance = $this->sanitize_widget_js_instance( $updated_widget['instance'] ); + + wp_send_json_success( compact( 'form', 'instance' ) ); + } + + /* + * Selective Refresh Methods + */ + + /** + * Filters arguments for dynamic widget partials. + * + * @since 4.5.0 + * + * @param array|false $partial_args Partial arguments. + * @param string $partial_id Partial ID. + * @return array (Maybe) modified partial arguments. + */ + public function customize_dynamic_partial_args( $partial_args, $partial_id ) { + if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) { + return $partial_args; + } + + if ( preg_match( '/^widget\[(?P<widget_id>.+)\]$/', $partial_id, $matches ) ) { + if ( false === $partial_args ) { + $partial_args = array(); + } + $partial_args = array_merge( + $partial_args, + array( + 'type' => 'widget', + 'render_callback' => array( $this, 'render_widget_partial' ), + 'container_inclusive' => true, + 'settings' => array( $this->get_setting_id( $matches['widget_id'] ) ), + 'capability' => 'edit_theme_options', + ) + ); + } + + return $partial_args; + } + + /** + * Adds hooks for selective refresh. + * + * @since 4.5.0 + */ + public function selective_refresh_init() { + if ( ! current_theme_supports( 'customize-selective-refresh-widgets' ) ) { + return; + } + add_filter( 'dynamic_sidebar_params', array( $this, 'filter_dynamic_sidebar_params' ) ); + add_filter( 'wp_kses_allowed_html', array( $this, 'filter_wp_kses_allowed_data_attributes' ) ); + add_action( 'dynamic_sidebar_before', array( $this, 'start_dynamic_sidebar' ) ); + add_action( 'dynamic_sidebar_after', array( $this, 'end_dynamic_sidebar' ) ); + } + + /** + * Inject selective refresh data attributes into widget container elements. + * + * @param array $params { + * Dynamic sidebar params. + * + * @type array $args Sidebar args. + * @type array $widget_args Widget args. + * } + * @see WP_Customize_Nav_Menus_Partial_Refresh::filter_wp_nav_menu_args() + * + * @return array Params. + */ + public function filter_dynamic_sidebar_params( $params ) { + $sidebar_args = array_merge( + array( + 'before_widget' => '', + 'after_widget' => '', + ), + $params[0] + ); + + // Skip widgets not in a registered sidebar or ones which lack a proper wrapper element to attach the data-* attributes to. + $matches = array(); + $is_valid = ( + isset( $sidebar_args['id'] ) + && + is_registered_sidebar( $sidebar_args['id'] ) + && + ( isset( $this->current_dynamic_sidebar_id_stack[0] ) && $this->current_dynamic_sidebar_id_stack[0] === $sidebar_args['id'] ) + && + preg_match( '#^<(?P<tag_name>\w+)#', $sidebar_args['before_widget'], $matches ) + ); + if ( ! $is_valid ) { + return $params; + } + $this->before_widget_tags_seen[ $matches['tag_name'] ] = true; + + $context = array( + 'sidebar_id' => $sidebar_args['id'], + ); + if ( isset( $this->context_sidebar_instance_number ) ) { + $context['sidebar_instance_number'] = $this->context_sidebar_instance_number; + } else if ( isset( $sidebar_args['id'] ) && isset( $this->sidebar_instance_count[ $sidebar_args['id'] ] ) ) { + $context['sidebar_instance_number'] = $this->sidebar_instance_count[ $sidebar_args['id'] ]; + } + + $attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'widget[' . $sidebar_args['widget_id'] . ']' ) ); + $attributes .= ' data-customize-partial-type="widget"'; + $attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $context ) ) ); + $attributes .= sprintf( ' data-customize-widget-id="%s"', esc_attr( $sidebar_args['widget_id'] ) ); + $sidebar_args['before_widget'] = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $sidebar_args['before_widget'] ); + + $params[0] = $sidebar_args; + return $params; + } + + /** + * List of the tag names seen for before_widget strings. + * + * This is used in the {@see 'filter_wp_kses_allowed_html'} filter to ensure that the + * data-* attributes can be whitelisted. + * + * @since 4.5.0 + * @var array + */ + protected $before_widget_tags_seen = array(); + + /** + * Ensures the HTML data-* attributes for selective refresh are allowed by kses. + * + * This is needed in case the `$before_widget` is run through wp_kses() when printed. + * + * @since 4.5.0 + * + * @param array $allowed_html Allowed HTML. + * @return array (Maybe) modified allowed HTML. + */ + public function filter_wp_kses_allowed_data_attributes( $allowed_html ) { + foreach ( array_keys( $this->before_widget_tags_seen ) as $tag_name ) { + if ( ! isset( $allowed_html[ $tag_name ] ) ) { + $allowed_html[ $tag_name ] = array(); + } + $allowed_html[ $tag_name ] = array_merge( + $allowed_html[ $tag_name ], + array_fill_keys( array( + 'data-customize-partial-id', + 'data-customize-partial-type', + 'data-customize-partial-placement-context', + 'data-customize-partial-widget-id', + 'data-customize-partial-options', + ), true ) + ); + } + return $allowed_html; + } + + /** + * Keep track of the number of times that dynamic_sidebar() was called for a given sidebar index. + * + * This helps facilitate the uncommon scenario where a single sidebar is rendered multiple times on a template. + * + * @since 4.5.0 + * @var array + */ + protected $sidebar_instance_count = array(); + + /** + * The current request's sidebar_instance_number context. + * + * @since 4.5.0 + * @var int + */ + protected $context_sidebar_instance_number; + + /** + * Current sidebar ID being rendered. + * + * @since 4.5.0 + * @var array + */ + protected $current_dynamic_sidebar_id_stack = array(); + + /** + * Begins keeping track of the current sidebar being rendered. + * + * Insert marker before widgets are rendered in a dynamic sidebar. + * + * @since 4.5.0 + * + * @param int|string $index Index, name, or ID of the dynamic sidebar. + */ + public function start_dynamic_sidebar( $index ) { + array_unshift( $this->current_dynamic_sidebar_id_stack, $index ); + if ( ! isset( $this->sidebar_instance_count[ $index ] ) ) { + $this->sidebar_instance_count[ $index ] = 0; + } + $this->sidebar_instance_count[ $index ] += 1; + if ( ! $this->manager->selective_refresh->is_render_partials_request() ) { + printf( "\n<!--dynamic_sidebar_before:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) ); + } + } + + /** + * Finishes keeping track of the current sidebar being rendered. + * + * Inserts a marker after widgets are rendered in a dynamic sidebar. + * + * @since 4.5.0 + * + * @param int|string $index Index, name, or ID of the dynamic sidebar. + */ + public function end_dynamic_sidebar( $index ) { + array_shift( $this->current_dynamic_sidebar_id_stack ); + if ( ! $this->manager->selective_refresh->is_render_partials_request() ) { + printf( "\n<!--dynamic_sidebar_after:%s:%d-->\n", esc_html( $index ), intval( $this->sidebar_instance_count[ $index ] ) ); + } + } + + /** + * Current sidebar being rendered. + * + * @since 4.5.0 + * @var string + */ + protected $rendering_widget_id; + + /** + * Current widget being rendered. + * + * @since 4.5.0 + * @var string + */ + protected $rendering_sidebar_id; + + /** + * Filters sidebars_widgets to ensure the currently-rendered widget is the only widget in the current sidebar. + * + * @since 4.5.0 + * + * @param array $sidebars_widgets Sidebars widgets. + * @return array Filtered sidebars widgets. + */ + public function filter_sidebars_widgets_for_rendering_widget( $sidebars_widgets ) { + $sidebars_widgets[ $this->rendering_sidebar_id ] = array( $this->rendering_widget_id ); + return $sidebars_widgets; + } + + /** + * Renders a specific widget using the supplied sidebar arguments. + * + * @since 4.5.0 + * + * @see dynamic_sidebar() + * + * @param WP_Customize_Partial $partial Partial. + * @param array $context { + * Sidebar args supplied as container context. + * + * @type string $sidebar_id ID for sidebar for widget to render into. + * @type int $sidebar_instance_number Disambiguating instance number. + * } + * @return string|false + */ + public function render_widget_partial( $partial, $context ) { + $id_data = $partial->id_data(); + $widget_id = array_shift( $id_data['keys'] ); + + if ( ! is_array( $context ) + || empty( $context['sidebar_id'] ) + || ! is_registered_sidebar( $context['sidebar_id'] ) + ) { + return false; + } + + $this->rendering_sidebar_id = $context['sidebar_id']; + + if ( isset( $context['sidebar_instance_number'] ) ) { + $this->context_sidebar_instance_number = intval( $context['sidebar_instance_number'] ); + } + + // Filter sidebars_widgets so that only the queried widget is in the sidebar. + $this->rendering_widget_id = $widget_id; + + $filter_callback = array( $this, 'filter_sidebars_widgets_for_rendering_widget' ); + add_filter( 'sidebars_widgets', $filter_callback, 1000 ); + + // Render the widget. + ob_start(); + dynamic_sidebar( $this->rendering_sidebar_id = $context['sidebar_id'] ); + $container = ob_get_clean(); + + // Reset variables for next partial render. + remove_filter( 'sidebars_widgets', $filter_callback, 1000 ); + + $this->context_sidebar_instance_number = null; + $this->rendering_sidebar_id = null; + $this->rendering_widget_id = null; + + return $container; + } + + // + // Option Update Capturing + // + + /** + * List of captured widget option updates. + * + * @since 3.9.0 + * @var array $_captured_options Values updated while option capture is happening. + */ + protected $_captured_options = array(); + + /** + * Whether option capture is currently happening. + * + * @since 3.9.0 + * @var bool $_is_current Whether option capture is currently happening or not. + */ + protected $_is_capturing_option_updates = false; + + /** + * Determines whether the captured option update should be ignored. + * + * @since 3.9.0 + * + * @param string $option_name Option name. + * @return bool Whether the option capture is ignored. + */ + protected function is_option_capture_ignored( $option_name ) { + return ( 0 === strpos( $option_name, '_transient_' ) ); + } + + /** + * Retrieves captured widget option updates. + * + * @since 3.9.0 + * + * @return array Array of captured options. + */ + protected function get_captured_options() { + return $this->_captured_options; + } + + /** + * Retrieves the option that was captured from being saved. + * + * @since 4.2.0 + * + * @param string $option_name Option name. + * @param mixed $default Optional. Default value to return if the option does not exist. Default false. + * @return mixed Value set for the option. + */ + protected function get_captured_option( $option_name, $default = false ) { + if ( array_key_exists( $option_name, $this->_captured_options ) ) { + $value = $this->_captured_options[ $option_name ]; + } else { + $value = $default; + } + return $value; + } + + /** + * Retrieves the number of captured widget option updates. + * + * @since 3.9.0 + * + * @return int Number of updated options. + */ + protected function count_captured_options() { + return count( $this->_captured_options ); + } + + /** + * Begins keeping track of changes to widget options, caching new values. + * + * @since 3.9.0 + */ + protected function start_capturing_option_updates() { + if ( $this->_is_capturing_option_updates ) { + return; + } + + $this->_is_capturing_option_updates = true; + + add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 ); + } + + /** + * Pre-filters captured option values before updating. + * + * @since 3.9.0 + * + * @param mixed $new_value The new option value. + * @param string $option_name Name of the option. + * @param mixed $old_value The old option value. + * @return mixed Filtered option value. + */ + public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) { + if ( $this->is_option_capture_ignored( $option_name ) ) { + return; + } + + if ( ! isset( $this->_captured_options[ $option_name ] ) ) { + add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) ); + } + + $this->_captured_options[ $option_name ] = $new_value; + + return $old_value; + } + + /** + * Pre-filters captured option values before retrieving. + * + * @since 3.9.0 + * + * @param mixed $value Value to return instead of the option value. + * @return mixed Filtered option value. + */ + public function capture_filter_pre_get_option( $value ) { + $option_name = preg_replace( '/^pre_option_/', '', current_filter() ); + + if ( isset( $this->_captured_options[ $option_name ] ) ) { + $value = $this->_captured_options[ $option_name ]; + + /** This filter is documented in wp-includes/option.php */ + $value = apply_filters( 'option_' . $option_name, $value ); + } + + return $value; + } + + /** + * Undoes any changes to the options since options capture began. + * + * @since 3.9.0 + */ + protected function stop_capturing_option_updates() { + if ( ! $this->_is_capturing_option_updates ) { + return; + } + + remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10 ); + + foreach ( array_keys( $this->_captured_options ) as $option_name ) { + remove_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) ); + } + + $this->_captured_options = array(); + $this->_is_capturing_option_updates = false; + } + + /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * + * @since 3.9.0 + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. + */ + public function setup_widget_addition_previews() { + _deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' ); + } + + /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * + * @since 3.9.0 + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. + */ + public function prepreview_added_sidebars_widgets() { + _deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' ); + } + + /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * + * @since 3.9.0 + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. + */ + public function prepreview_added_widget_instance() { + _deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' ); + } + + /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * + * @since 3.9.0 + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. + */ + public function remove_prepreview_filters() { + _deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' ); + } +} diff --git a/backend/wp-includes/class-wp-dependency.php b/backend/wp-includes/class-wp-dependency.php new file mode 100644 index 0000000..cd808e8 --- /dev/null +++ b/backend/wp-includes/class-wp-dependency.php @@ -0,0 +1,97 @@ +<?php +/** + * Dependencies API: _WP_Dependency class + * + * @since 4.7.0 + * + * @package WordPress + * @subpackage Dependencies + */ + +/** + * Class _WP_Dependency + * + * Helper class to register a handle and associated data. + * + * @access private + * @since 2.6.0 + */ +class _WP_Dependency { + /** + * The handle name. + * + * @since 2.6.0 + * @var null + */ + public $handle; + + /** + * The handle source. + * + * @since 2.6.0 + * @var null + */ + public $src; + + /** + * An array of handle dependencies. + * + * @since 2.6.0 + * @var array + */ + public $deps = array(); + + /** + * The handle version. + * + * Used for cache-busting. + * + * @since 2.6.0 + * @var bool|string + */ + public $ver = false; + + /** + * Additional arguments for the handle. + * + * @since 2.6.0 + * @var null + */ + public $args = null; // Custom property, such as $in_footer or $media. + + /** + * Extra data to supply to the handle. + * + * @since 2.6.0 + * @var array + */ + public $extra = array(); + + /** + * Setup dependencies. + * + * @since 2.6.0 + */ + public function __construct() { + @list( $this->handle, $this->src, $this->deps, $this->ver, $this->args ) = func_get_args(); + if ( ! is_array($this->deps) ) + $this->deps = array(); + } + + /** + * Add handle data. + * + * @since 2.6.0 + * + * @param string $name The data key to add. + * @param mixed $data The data value to add. + * @return bool False if not scalar, true otherwise. + */ + public function add_data( $name, $data ) { + if ( !is_scalar($name) ) + return false; + $this->extra[$name] = $data; + return true; + } + +} diff --git a/backend/wp-includes/class-wp-editor.php b/backend/wp-includes/class-wp-editor.php new file mode 100644 index 0000000..298d3ed --- /dev/null +++ b/backend/wp-includes/class-wp-editor.php @@ -0,0 +1,1759 @@ +<?php +/** + * Facilitates adding of the WordPress editor as used on the Write and Edit screens. + * + * @package WordPress + * @since 3.3.0 + * + * Private, not included by default. See wp_editor() in wp-includes/general-template.php. + */ + +final class _WP_Editors { + public static $mce_locale; + + private static $mce_settings = array(); + private static $qt_settings = array(); + private static $plugins = array(); + private static $qt_buttons = array(); + private static $ext_plugins; + private static $baseurl; + private static $first_init; + private static $this_tinymce = false; + private static $this_quicktags = false; + private static $has_tinymce = false; + private static $has_quicktags = false; + private static $has_medialib = false; + private static $editor_buttons_css = true; + private static $drag_drop_upload = false; + private static $old_dfw_compat = false; + private static $translation; + private static $tinymce_scripts_printed = false; + private static $link_dialog_printed = false; + + private function __construct() {} + + /** + * Parse default arguments for the editor instance. + * + * @static + * @param string $editor_id ID for the current editor instance. + * @param array $settings { + * Array of editor arguments. + * + * @type bool $wpautop Whether to use wpautop(). Default true. + * @type bool $media_buttons Whether to show the Add Media/other media buttons. + * @type string $default_editor When both TinyMCE and Quicktags are used, set which + * editor is shown on page load. Default empty. + * @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false. + * Requires the media modal. + * @type string $textarea_name Give the textarea a unique name here. Square brackets + * can be used here. Default $editor_id. + * @type int $textarea_rows Number rows in the editor textarea. Default 20. + * @type string|int $tabindex Tabindex value to use. Default empty. + * @type string $tabfocus_elements The previous and next element ID to move the focus to + * when pressing the Tab key in TinyMCE. Default ':prev,:next'. + * @type string $editor_css Intended for extra styles for both Visual and Text editors. + * Should include `<style>` tags, and can use "scoped". Default empty. + * @type string $editor_class Extra classes to add to the editor textarea element. Default empty. + * @type bool $teeny Whether to output the minimal editor config. Examples include + * Press This and the Comment editor. Default false. + * @type bool $dfw Deprecated in 4.1. Since 4.3 used only to enqueue wp-fullscreen-stub.js + * for backward compatibility. + * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to + * TinyMCE using an array. Default true. + * @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to + * Quicktags using an array. Default true. + * } + * @return array Parsed arguments array. + */ + public static function parse_settings( $editor_id, $settings ) { + + /** + * Filters the wp_editor() settings. + * + * @since 4.0.0 + * + * @see _WP_Editors()::parse_settings() + * + * @param array $settings Array of editor arguments. + * @param string $editor_id ID for the current editor instance. + */ + $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); + + $set = wp_parse_args( $settings, array( + 'wpautop' => true, + 'media_buttons' => true, + 'default_editor' => '', + 'drag_drop_upload' => false, + 'textarea_name' => $editor_id, + 'textarea_rows' => 20, + 'tabindex' => '', + 'tabfocus_elements' => ':prev,:next', + 'editor_css' => '', + 'editor_class' => '', + 'teeny' => false, + 'dfw' => false, + '_content_editor_dfw' => false, + 'tinymce' => true, + 'quicktags' => true + ) ); + + self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); + + if ( self::$this_tinymce ) { + if ( false !== strpos( $editor_id, '[' ) ) { + self::$this_tinymce = false; + _deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' ); + } + } + + self::$this_quicktags = (bool) $set['quicktags']; + + if ( self::$this_tinymce ) + self::$has_tinymce = true; + + if ( self::$this_quicktags ) + self::$has_quicktags = true; + + if ( $set['dfw'] ) { + self::$old_dfw_compat = true; + } + + if ( empty( $set['editor_height'] ) ) + return $set; + + if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { + // A cookie (set when a user resizes the editor) overrides the height. + $cookie = (int) get_user_setting( 'ed_size' ); + + if ( $cookie ) + $set['editor_height'] = $cookie; + } + + if ( $set['editor_height'] < 50 ) + $set['editor_height'] = 50; + elseif ( $set['editor_height'] > 5000 ) + $set['editor_height'] = 5000; + + return $set; + } + + /** + * Outputs the HTML for a single instance of the editor. + * + * @static + * @param string $content The initial content of the editor. + * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). + * @param array $settings See _WP_Editors()::parse_settings() for description. + */ + public static function editor( $content, $editor_id, $settings = array() ) { + $set = self::parse_settings( $editor_id, $settings ); + $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; + $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; + $default_editor = 'html'; + $buttons = $autocomplete = ''; + $editor_id_attr = esc_attr( $editor_id ); + + if ( $set['drag_drop_upload'] ) { + self::$drag_drop_upload = true; + } + + if ( ! empty( $set['editor_height'] ) ) { + $height = ' style="height: ' . (int) $set['editor_height'] . 'px"'; + } else { + $height = ' rows="' . (int) $set['textarea_rows'] . '"'; + } + + if ( ! current_user_can( 'upload_files' ) ) { + $set['media_buttons'] = false; + } + + if ( self::$this_tinymce ) { + $autocomplete = ' autocomplete="off"'; + + if ( self::$this_quicktags ) { + $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor(); + // 'html' is used for the "Text" editor tab. + if ( 'html' !== $default_editor ) { + $default_editor = 'tinymce'; + } + + $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' . + ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n"; + $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' . + ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n"; + } else { + $default_editor = 'tinymce'; + } + } + + $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; + $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; + + if ( $set['_content_editor_dfw'] ) { + $wrap_class .= ' has-dfw'; + } + + echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">'; + + if ( self::$editor_buttons_css ) { + wp_print_styles( 'editor-buttons' ); + self::$editor_buttons_css = false; + } + + if ( ! empty( $set['editor_css'] ) ) { + echo $set['editor_css'] . "\n"; + } + + if ( ! empty( $buttons ) || $set['media_buttons'] ) { + echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; + + if ( $set['media_buttons'] ) { + self::$has_medialib = true; + + if ( ! function_exists( 'media_buttons' ) ) + include( ABSPATH . 'wp-admin/includes/media.php' ); + + echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; + + /** + * Fires after the default media button(s) are displayed. + * + * @since 2.5.0 + * + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + do_action( 'media_buttons', $editor_id ); + echo "</div>\n"; + } + + echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n"; + echo "</div>\n"; + } + + $quicktags_toolbar = ''; + + if ( self::$this_quicktags ) { + if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && $GLOBALS['current_screen']->base === 'post' ) { + $toolbar_id = 'ed_toolbar'; + } else { + $toolbar_id = 'qt_' . $editor_id_attr . '_toolbar'; + } + + $quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>'; + } + + /** + * Filters the HTML markup output that displays the editor. + * + * @since 2.1.0 + * + * @param string $output Editor's HTML markup. + */ + $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . + $quicktags_toolbar . + '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . + 'id="' . $editor_id_attr . '">%s</textarea></div>' ); + + // Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat). + if ( self::$this_tinymce ) { + add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); + } + + /** + * Filters the default editor content. + * + * @since 2.1.0 + * + * @param string $content Default editor content. + * @param string $default_editor The default editor for the current user. + * Either 'html' or 'tinymce'. + */ + $content = apply_filters( 'the_editor_content', $content, $default_editor ); + + // Remove the filter as the next editor on the same page may not need it. + if ( self::$this_tinymce ) { + remove_filter( 'the_editor_content', 'format_for_editor' ); + } + + // Back-compat for the `htmledit_pre` and `richedit_pre` filters + if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) { + // TODO: needs _deprecated_filter(), use _deprecated_function() as substitute for now + _deprecated_function( 'add_filter( htmledit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); + $content = apply_filters( 'htmledit_pre', $content ); + } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) { + _deprecated_function( 'add_filter( richedit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); + $content = apply_filters( 'richedit_pre', $content ); + } + + if ( false !== stripos( $content, 'textarea' ) ) { + $content = preg_replace( '%</textarea%i', '</textarea', $content ); + } + + printf( $the_editor, $content ); + echo "\n</div>\n\n"; + + self::editor_settings( $editor_id, $set ); + } + + /** + * @static + * + * @global string $tinymce_version + * + * @param string $editor_id + * @param array $set + */ + public static function editor_settings($editor_id, $set) { + global $tinymce_version; + + if ( empty(self::$first_init) ) { + if ( is_admin() ) { + add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); + add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); + } else { + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); + } + } + + if ( self::$this_quicktags ) { + + $qtInit = array( + 'id' => $editor_id, + 'buttons' => '' + ); + + if ( is_array($set['quicktags']) ) + $qtInit = array_merge($qtInit, $set['quicktags']); + + if ( empty($qtInit['buttons']) ) + $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; + + if ( $set['_content_editor_dfw'] ) { + $qtInit['buttons'] .= ',dfw'; + } + + /** + * Filters the Quicktags settings. + * + * @since 3.3.0 + * + * @param array $qtInit Quicktags settings. + * @param string $editor_id The unique editor ID, e.g. 'content'. + */ + $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); + + self::$qt_settings[$editor_id] = $qtInit; + + self::$qt_buttons = array_merge( self::$qt_buttons, explode(',', $qtInit['buttons']) ); + } + + if ( self::$this_tinymce ) { + + if ( empty( self::$first_init ) ) { + $baseurl = self::get_baseurl(); + $mce_locale = self::get_mce_locale(); + $ext_plugins = ''; + + if ( $set['teeny'] ) { + + /** + * Filters the list of teenyMCE plugins. + * + * @since 2.7.0 + * + * @param array $plugins An array of teenyMCE plugins. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id ); + } else { + + /** + * Filters the list of TinyMCE external plugins. + * + * The filter takes an associative array of external plugins for + * TinyMCE in the form 'plugin_name' => 'url'. + * + * The url should be absolute, and should include the js filename + * to be loaded. For example: + * 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'. + * + * If the external plugin adds a button, it should be added with + * one of the 'mce_buttons' filters. + * + * @since 2.5.0 + * + * @param array $external_plugins An array of external TinyMCE plugins. + */ + $mce_external_plugins = apply_filters( 'mce_external_plugins', array() ); + + $plugins = array( + 'charmap', + 'colorpicker', + 'hr', + 'lists', + 'media', + 'paste', + 'tabfocus', + 'textcolor', + 'fullscreen', + 'wordpress', + 'wpautoresize', + 'wpeditimage', + 'wpemoji', + 'wpgallery', + 'wplink', + 'wpdialogs', + 'wptextpattern', + 'wpview', + ); + + if ( ! self::$has_medialib ) { + $plugins[] = 'image'; + } + + /** + * Filters the list of default TinyMCE plugins. + * + * The filter specifies which of the default plugins included + * in WordPress should be added to the TinyMCE instance. + * + * @since 3.3.0 + * + * @param array $plugins An array of default TinyMCE plugins. + */ + $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) ); + + if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { + // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. + // It can be added with 'mce_external_plugins'. + unset( $plugins[$key] ); + } + + if ( ! empty( $mce_external_plugins ) ) { + + /** + * Filters the translations loaded for external TinyMCE 3.x plugins. + * + * The filter takes an associative array ('plugin_name' => 'path') + * where 'path' is the include path to the file. + * + * The language file should follow the same format as wp_mce_translation(), + * and should define a variable ($strings) that holds all translated strings. + * + * @since 2.5.0 + * + * @param array $translations Translations for external TinyMCE plugins. + */ + $mce_external_languages = apply_filters( 'mce_external_languages', array() ); + + $loaded_langs = array(); + $strings = ''; + + if ( ! empty( $mce_external_languages ) ) { + foreach ( $mce_external_languages as $name => $path ) { + if ( @is_file( $path ) && @is_readable( $path ) ) { + include_once( $path ); + $ext_plugins .= $strings . "\n"; + $loaded_langs[] = $name; + } + } + } + + foreach ( $mce_external_plugins as $name => $url ) { + if ( in_array( $name, $plugins, true ) ) { + unset( $mce_external_plugins[ $name ] ); + continue; + } + + $url = set_url_scheme( $url ); + $mce_external_plugins[ $name ] = $url; + $plugurl = dirname( $url ); + $strings = ''; + + // Try to load langs/[locale].js and langs/[locale]_dlg.js + if ( ! in_array( $name, $loaded_langs, true ) ) { + $path = str_replace( content_url(), '', $plugurl ); + $path = WP_CONTENT_DIR . $path . '/langs/'; + + if ( function_exists('realpath') ) + $path = trailingslashit( realpath($path) ); + + if ( @is_file( $path . $mce_locale . '.js' ) ) + $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; + + if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) + $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; + + if ( 'en' != $mce_locale && empty( $strings ) ) { + if ( @is_file( $path . 'en.js' ) ) { + $str1 = @file_get_contents( $path . 'en.js' ); + $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; + } + + if ( @is_file( $path . 'en_dlg.js' ) ) { + $str2 = @file_get_contents( $path . 'en_dlg.js' ); + $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; + } + } + + if ( ! empty( $strings ) ) + $ext_plugins .= "\n" . $strings . "\n"; + } + + $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; + $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; + } + } + } + + self::$plugins = $plugins; + self::$ext_plugins = $ext_plugins; + + $settings = self::default_settings(); + $settings['plugins'] = implode( ',', $plugins ); + + if ( ! empty( $mce_external_plugins ) ) { + $settings['external_plugins'] = wp_json_encode( $mce_external_plugins ); + } + + /** This filter is documented in wp-admin/includes/media.php */ + if ( apply_filters( 'disable_captions', '' ) ) { + $settings['wpeditimage_disable_captions'] = true; + } + + $mce_css = $settings['content_css']; + $editor_styles = get_editor_stylesheets(); + + if ( ! empty( $editor_styles ) ) { + // Force urlencoding of commas. + foreach ( $editor_styles as $key => $url ) { + if ( strpos( $url, ',' ) !== false ) { + $editor_styles[ $key ] = str_replace( ',', '%2C', $url ); + } + } + + $mce_css .= ',' . implode( ',', $editor_styles ); + } + + /** + * Filters the comma-delimited list of stylesheets to load in TinyMCE. + * + * @since 2.1.0 + * + * @param string $stylesheets Comma-delimited list of stylesheets. + */ + $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' ); + + if ( ! empty( $mce_css ) ) { + $settings['content_css'] = $mce_css; + } else { + unset( $settings['content_css'] ); + } + + self::$first_init = $settings; + } + + if ( $set['teeny'] ) { + + /** + * Filters the list of teenyMCE buttons (Text tab). + * + * @since 2.7.0 + * + * @param array $buttons An array of teenyMCE buttons. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'fullscreen'), $editor_id ); + $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); + } else { + $mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'wp_more', 'spellchecker' ); + + if ( ! wp_is_mobile() ) { + if ( $set['_content_editor_dfw'] ) { + $mce_buttons[] = 'dfw'; + } else { + $mce_buttons[] = 'fullscreen'; + } + } + + $mce_buttons[] = 'wp_adv'; + + /** + * Filters the first-row list of TinyMCE buttons (Visual tab). + * + * @since 2.0.0 + * + * @param array $buttons First-row list of buttons. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mce_buttons = apply_filters( 'mce_buttons', $mce_buttons, $editor_id ); + + $mce_buttons_2 = array( 'strikethrough', 'hr', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo' ); + + if ( ! wp_is_mobile() ) { + $mce_buttons_2[] = 'wp_help'; + } + + /** + * Filters the second-row list of TinyMCE buttons (Visual tab). + * + * @since 2.0.0 + * + * @param array $buttons Second-row list of buttons. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id ); + + /** + * Filters the third-row list of TinyMCE buttons (Visual tab). + * + * @since 2.0.0 + * + * @param array $buttons Third-row list of buttons. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mce_buttons_3 = apply_filters( 'mce_buttons_3', array(), $editor_id ); + + /** + * Filters the fourth-row list of TinyMCE buttons (Visual tab). + * + * @since 2.5.0 + * + * @param array $buttons Fourth-row list of buttons. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mce_buttons_4 = apply_filters( 'mce_buttons_4', array(), $editor_id ); + } + + $body_class = $editor_id; + + if ( $post = get_post() ) { + $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); + + if ( post_type_supports( $post->post_type, 'post-formats' ) ) { + $post_format = get_post_format( $post ); + if ( $post_format && ! is_wp_error( $post_format ) ) + $body_class .= ' post-format-' . sanitize_html_class( $post_format ); + else + $body_class .= ' post-format-standard'; + } + + $page_template = get_page_template_slug( $post ); + + if ( $page_template !== false ) { + $page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) ); + $body_class .= ' page-template-' . sanitize_html_class( $page_template ); + } + } + + $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); + + if ( ! empty( $set['tinymce']['body_class'] ) ) { + $body_class .= ' ' . $set['tinymce']['body_class']; + unset( $set['tinymce']['body_class'] ); + } + + $mceInit = array ( + 'selector' => "#$editor_id", + 'wpautop' => (bool) $set['wpautop'], + 'indent' => ! $set['wpautop'], + 'toolbar1' => implode( ',', $mce_buttons ), + 'toolbar2' => implode( ',', $mce_buttons_2 ), + 'toolbar3' => implode( ',', $mce_buttons_3 ), + 'toolbar4' => implode( ',', $mce_buttons_4 ), + 'tabfocus_elements' => $set['tabfocus_elements'], + 'body_class' => $body_class + ); + + // Merge with the first part of the init array + $mceInit = array_merge( self::$first_init, $mceInit ); + + if ( is_array( $set['tinymce'] ) ) + $mceInit = array_merge( $mceInit, $set['tinymce'] ); + + /* + * For people who really REALLY know what they're doing with TinyMCE + * You can modify $mceInit to add, remove, change elements of the config + * before tinyMCE.init. Setting "valid_elements", "invalid_elements" + * and "extended_valid_elements" can be done through this filter. Best + * is to use the default cleanup by not specifying valid_elements, + * as TinyMCE checks against the full set of HTML 5.0 elements and attributes. + */ + if ( $set['teeny'] ) { + + /** + * Filters the teenyMCE config before init. + * + * @since 2.7.0 + * + * @param array $mceInit An array with teenyMCE config. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mceInit = apply_filters( 'teeny_mce_before_init', $mceInit, $editor_id ); + } else { + + /** + * Filters the TinyMCE config before init. + * + * @since 2.5.0 + * + * @param array $mceInit An array with TinyMCE config. + * @param string $editor_id Unique editor identifier, e.g. 'content'. + */ + $mceInit = apply_filters( 'tiny_mce_before_init', $mceInit, $editor_id ); + } + + if ( empty( $mceInit['toolbar3'] ) && ! empty( $mceInit['toolbar4'] ) ) { + $mceInit['toolbar3'] = $mceInit['toolbar4']; + $mceInit['toolbar4'] = ''; + } + + self::$mce_settings[$editor_id] = $mceInit; + } // end if self::$this_tinymce + } + + /** + * + * @static + * @param array $init + * @return string + */ + private static function _parse_init( $init ) { + $options = ''; + + foreach ( $init as $key => $value ) { + if ( is_bool( $value ) ) { + $val = $value ? 'true' : 'false'; + $options .= $key . ':' . $val . ','; + continue; + } elseif ( ! empty( $value ) && is_string( $value ) && ( + ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) || + ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) || + preg_match( '/^\(?function ?\(/', $value ) ) ) { + + $options .= $key . ':' . $value . ','; + continue; + } + $options .= $key . ':"' . $value . '",'; + } + + return '{' . trim( $options, ' ,' ) . '}'; + } + + /** + * + * @static + * + * @param bool $default_scripts Optional. Whether default scripts should be enqueued. Default false. + */ + public static function enqueue_scripts( $default_scripts = false ) { + if ( $default_scripts || self::$has_tinymce ) { + wp_enqueue_script( 'editor' ); + } + + if ( $default_scripts || self::$has_quicktags ) { + wp_enqueue_script( 'quicktags' ); + wp_enqueue_style( 'buttons' ); + } + + if ( $default_scripts || in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { + wp_enqueue_script( 'wplink' ); + wp_enqueue_script( 'jquery-ui-autocomplete' ); + } + + if ( self::$old_dfw_compat ) { + wp_enqueue_script( 'wp-fullscreen-stub' ); + } + + if ( self::$has_medialib ) { + add_thickbox(); + wp_enqueue_script( 'media-upload' ); + wp_enqueue_script( 'wp-embed' ); + } elseif ( $default_scripts ) { + wp_enqueue_script( 'media-upload' ); + } + + /** + * Fires when scripts and styles are enqueued for the editor. + * + * @since 3.9.0 + * + * @param array $to_load An array containing boolean values whether TinyMCE + * and Quicktags are being loaded. + */ + do_action( 'wp_enqueue_editor', array( + 'tinymce' => ( $default_scripts || self::$has_tinymce ), + 'quicktags' => ( $default_scripts || self::$has_quicktags ), + ) ); + } + + /** + * Enqueue all editor scripts. + * For use when the editor is going to be initialized after page load. + * + * @since 4.8.0 + */ + public static function enqueue_default_editor() { + // We are past the point where scripts can be enqueued properly. + if ( did_action( 'wp_enqueue_editor' ) ) { + return; + } + + self::enqueue_scripts( true ); + + // Also add wp-includes/css/editor.css + wp_enqueue_style( 'editor-buttons' ); + + if ( is_admin() ) { + add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); + } else { + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); + } + } + + /** + * Print (output) all editor scripts and default settings. + * For use when the editor is going to be initialized after page load. + * + * @since 4.8.0 + * + */ + public static function print_default_editor_scripts() { + $user_can_richedit = user_can_richedit(); + + if ( $user_can_richedit ) { + $settings = self::default_settings(); + + $settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; + $settings['wpautop'] = false; + $settings['indent'] = true; + $settings['elementpath'] = false; + + if ( is_rtl() ) { + $settings['directionality'] = 'rtl'; + } + + // In production all plugins are loaded (they are in wp-editor.js.gz). + // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. + // Can be added from js by using the 'wp-before-tinymce-init' event. + $settings['plugins'] = implode( ',', array( + 'charmap', + 'colorpicker', + 'hr', + 'lists', + 'paste', + 'tabfocus', + 'textcolor', + 'fullscreen', + 'wordpress', + 'wpautoresize', + 'wpeditimage', + 'wpemoji', + 'wpgallery', + 'wplink', + 'wptextpattern', + ) ); + + $settings = self::_parse_init( $settings ); + } else { + $settings = '{}'; + } + + ?> + <script type="text/javascript"> + window.wp = window.wp || {}; + window.wp.editor = window.wp.editor || {}; + window.wp.editor.getDefaultSettings = function() { + return { + tinymce: <?php echo $settings; ?>, + quicktags: { + buttons: 'strong,em,link,ul,ol,li,code' + } + }; + }; + + <?php + + if ( $user_can_richedit ) { + $suffix = SCRIPT_DEBUG ? '' : '.min'; + $baseurl = self::get_baseurl(); + + ?> + var tinyMCEPreInit = { + baseURL: "<?php echo $baseurl; ?>", + suffix: "<?php echo $suffix; ?>", + mceInit: {}, + qtInit: {}, + load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} + }; + <?php + } + ?> + </script> + <?php + + if ( $user_can_richedit ) { + self::print_tinymce_scripts(); + } + + /** + * Fires when the editor scripts are loaded for later initialization, + * after all scripts and settings are printed. + * + * @since 4.8.0 + */ + do_action( 'print_default_editor_scripts' ); + + self::wp_link_dialog(); + } + + public static function get_mce_locale() { + if ( empty( self::$mce_locale ) ) { + $mce_locale = get_user_locale(); + self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 + } + + return self::$mce_locale; + } + + public static function get_baseurl() { + if ( empty( self::$baseurl ) ) { + self::$baseurl = includes_url( 'js/tinymce' ); + } + + return self::$baseurl; + } + + /** + * Returns the default TinyMCE settings. + * Doesn't include plugins, buttons, editor selector. + * + * @global string $tinymce_version + * + * @return array + */ + private static function default_settings() { + global $tinymce_version; + + $shortcut_labels = array(); + + foreach ( self::get_translation() as $name => $value ) { + if ( is_array( $value ) ) { + $shortcut_labels[$name] = $value[1]; + } + } + + $settings = array( + 'theme' => 'modern', + 'skin' => 'lightgray', + 'language' => self::get_mce_locale(), + 'formats' => '{' . + 'alignleft: [' . + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . + '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . + '],' . + 'aligncenter: [' . + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' . + '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' . + '],' . + 'alignright: [' . + '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . + '{selector: "img,table,dl.wp-caption", classes: "alignright"}' . + '],' . + 'strikethrough: {inline: "del"}' . + '}', + 'relative_urls' => false, + 'remove_script_host' => false, + 'convert_urls' => false, + 'browser_spellcheck' => true, + 'fix_list_elements' => true, + 'entities' => '38,amp,60,lt,62,gt', + 'entity_encoding' => 'raw', + 'keep_styles' => false, + 'cache_suffix' => 'wp-mce-' . $tinymce_version, + 'resize' => 'vertical', + 'menubar' => false, + 'branding' => false, + + // Limit the preview styles in the menu/toolbar + 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', + + 'end_container_on_empty_block' => true, + 'wpeditimage_html5_captions' => true, + 'wp_lang_attr' => get_bloginfo( 'language' ), + 'wp_keep_scroll_position' => false, + 'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ), + ); + + $suffix = SCRIPT_DEBUG ? '' : '.min'; + $version = 'ver=' . get_bloginfo( 'version' ); + + // Default stylesheets + $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' . + includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" ); + + return $settings; + } + + private static function get_translation() { + if ( empty( self::$translation ) ) { + self::$translation = array( + // Default TinyMCE strings + 'New document' => __( 'New document' ), + 'Formats' => _x( 'Formats', 'TinyMCE' ), + + 'Headings' => _x( 'Headings', 'TinyMCE' ), + 'Heading 1' => array( __( 'Heading 1' ), 'access1' ), + 'Heading 2' => array( __( 'Heading 2' ), 'access2' ), + 'Heading 3' => array( __( 'Heading 3' ), 'access3' ), + 'Heading 4' => array( __( 'Heading 4' ), 'access4' ), + 'Heading 5' => array( __( 'Heading 5' ), 'access5' ), + 'Heading 6' => array( __( 'Heading 6' ), 'access6' ), + + /* translators: block tags */ + 'Blocks' => _x( 'Blocks', 'TinyMCE' ), + 'Paragraph' => array( __( 'Paragraph' ), 'access7' ), + 'Blockquote' => array( __( 'Blockquote' ), 'accessQ' ), + 'Div' => _x( 'Div', 'HTML tag' ), + 'Pre' => _x( 'Pre', 'HTML tag' ), + 'Preformatted' => _x( 'Preformatted', 'HTML tag' ), + 'Address' => _x( 'Address', 'HTML tag' ), + + 'Inline' => _x( 'Inline', 'HTML elements' ), + 'Underline' => array( __( 'Underline' ), 'metaU' ), + 'Strikethrough' => array( __( 'Strikethrough' ), 'accessD' ), + 'Subscript' => __( 'Subscript' ), + 'Superscript' => __( 'Superscript' ), + 'Clear formatting' => __( 'Clear formatting' ), + 'Bold' => array( __( 'Bold' ), 'metaB' ), + 'Italic' => array( __( 'Italic' ), 'metaI' ), + 'Code' => array( __( 'Code' ), 'accessX' ), + 'Source code' => __( 'Source code' ), + 'Font Family' => __( 'Font Family' ), + 'Font Sizes' => __( 'Font Sizes' ), + + 'Align center' => array( __( 'Align center' ), 'accessC' ), + 'Align right' => array( __( 'Align right' ), 'accessR' ), + 'Align left' => array( __( 'Align left' ), 'accessL' ), + 'Justify' => array( __( 'Justify' ), 'accessJ' ), + 'Increase indent' => __( 'Increase indent' ), + 'Decrease indent' => __( 'Decrease indent' ), + + 'Cut' => array( __( 'Cut' ), 'metaX' ), + 'Copy' => array( __( 'Copy' ), 'metaC' ), + 'Paste' => array( __( 'Paste' ), 'metaV' ), + 'Select all' => array( __( 'Select all' ), 'metaA' ), + 'Undo' => array( __( 'Undo' ), 'metaZ' ), + 'Redo' => array( __( 'Redo' ), 'metaY' ), + + 'Ok' => __( 'OK' ), + 'Cancel' => __( 'Cancel' ), + 'Close' => __( 'Close' ), + 'Visual aids' => __( 'Visual aids' ), + + 'Bullet list' => array( __( 'Bulleted list' ), 'accessU' ), + 'Numbered list' => array( __( 'Numbered list' ), 'accessO' ), + 'Square' => _x( 'Square', 'list style' ), + 'Default' => _x( 'Default', 'list style' ), + 'Circle' => _x( 'Circle', 'list style' ), + 'Disc' => _x('Disc', 'list style' ), + 'Lower Greek' => _x( 'Lower Greek', 'list style' ), + 'Lower Alpha' => _x( 'Lower Alpha', 'list style' ), + 'Upper Alpha' => _x( 'Upper Alpha', 'list style' ), + 'Upper Roman' => _x( 'Upper Roman', 'list style' ), + 'Lower Roman' => _x( 'Lower Roman', 'list style' ), + + // Anchor plugin + 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), + 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), + 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), + 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' => + __( 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' ), + 'Id' => _x( 'Id', 'Id for link anchor (TinyMCE)' ), + + // Fullpage plugin + 'Document properties' => __( 'Document properties' ), + 'Robots' => __( 'Robots' ), + 'Title' => __( 'Title' ), + 'Keywords' => __( 'Keywords' ), + 'Encoding' => __( 'Encoding' ), + 'Description' => __( 'Description' ), + 'Author' => __( 'Author' ), + + // Media, image plugins + 'Image' => __( 'Image' ), + 'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ), + 'General' => __( 'General' ), + 'Advanced' => __( 'Advanced' ), + 'Source' => __( 'Source' ), + 'Border' => __( 'Border' ), + 'Constrain proportions' => __( 'Constrain proportions' ), + 'Vertical space' => __( 'Vertical space' ), + 'Image description' => __( 'Image description' ), + 'Style' => __( 'Style' ), + 'Dimensions' => __( 'Dimensions' ), + 'Insert image' => __( 'Insert image' ), + 'Date/time' => __( 'Date/time' ), + 'Insert date/time' => __( 'Insert date/time' ), + 'Table of Contents' => __( 'Table of Contents' ), + 'Insert/Edit code sample' => __( 'Insert/edit code sample' ), + 'Language' => __( 'Language' ), + 'Media' => __( 'Media' ), + 'Insert/edit media' => __( 'Insert/edit media' ), + 'Poster' => __( 'Poster' ), + 'Alternative source' => __( 'Alternative source' ), + 'Paste your embed code below:' => __( 'Paste your embed code below:' ), + 'Insert video' => __( 'Insert video' ), + 'Embed' => __( 'Embed' ), + + // Each of these have a corresponding plugin + 'Special character' => __( 'Special character' ), + 'Right to left' => _x( 'Right to left', 'editor button' ), + 'Left to right' => _x( 'Left to right', 'editor button' ), + 'Emoticons' => __( 'Emoticons' ), + 'Nonbreaking space' => __( 'Nonbreaking space' ), + 'Page break' => __( 'Page break' ), + 'Paste as text' => __( 'Paste as text' ), + 'Preview' => __( 'Preview' ), + 'Print' => __( 'Print' ), + 'Save' => __( 'Save' ), + 'Fullscreen' => __( 'Fullscreen' ), + 'Horizontal line' => __( 'Horizontal line' ), + 'Horizontal space' => __( 'Horizontal space' ), + 'Restore last draft' => __( 'Restore last draft' ), + 'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ), + 'Remove link' => array( __( 'Remove link' ), 'accessS' ), + + // Link plugin + 'Link' => __( 'Link' ), + 'Insert link' => __( 'Insert link' ), + 'Insert/edit link' => __( 'Insert/edit link' ), + 'Target' => __( 'Target' ), + 'New window' => __( 'New window' ), + 'Text to display' => __( 'Text to display' ), + 'Url' => __( 'URL' ), + 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' => + __( 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' ), + 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' => + __( 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' ), + + 'Color' => __( 'Color' ), + 'Custom color' => __( 'Custom color' ), + 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis + 'No color' => __( 'No color' ), + 'R' => _x( 'R', 'Short for red in RGB' ), + 'G' => _x( 'G', 'Short for green in RGB' ), + 'B' => _x( 'B', 'Short for blue in RGB' ), + + // Spelling, search/replace plugins + 'Could not find the specified string.' => __( 'Could not find the specified string.' ), + 'Replace' => _x( 'Replace', 'find/replace' ), + 'Next' => _x( 'Next', 'find/replace' ), + /* translators: previous */ + 'Prev' => _x( 'Prev', 'find/replace' ), + 'Whole words' => _x( 'Whole words', 'find/replace' ), + 'Find and replace' => __( 'Find and replace' ), + 'Replace with' => _x('Replace with', 'find/replace' ), + 'Find' => _x( 'Find', 'find/replace' ), + 'Replace all' => _x( 'Replace all', 'find/replace' ), + 'Match case' => __( 'Match case' ), + 'Spellcheck' => __( 'Check Spelling' ), + 'Finish' => _x( 'Finish', 'spellcheck' ), + 'Ignore all' => _x( 'Ignore all', 'spellcheck' ), + 'Ignore' => _x( 'Ignore', 'spellcheck' ), + 'Add to Dictionary' => __( 'Add to Dictionary' ), + + // TinyMCE tables + 'Insert table' => __( 'Insert table' ), + 'Delete table' => __( 'Delete table' ), + 'Table properties' => __( 'Table properties' ), + 'Row properties' => __( 'Table row properties' ), + 'Cell properties' => __( 'Table cell properties' ), + 'Border color' => __( 'Border color' ), + + 'Row' => __( 'Row' ), + 'Rows' => __( 'Rows' ), + 'Column' => _x( 'Column', 'table column' ), + 'Cols' => _x( 'Cols', 'table columns' ), + 'Cell' => _x( 'Cell', 'table cell' ), + 'Header cell' => __( 'Header cell' ), + 'Header' => _x( 'Header', 'table header' ), + 'Body' => _x( 'Body', 'table body' ), + 'Footer' => _x( 'Footer', 'table footer' ), + + 'Insert row before' => __( 'Insert row before' ), + 'Insert row after' => __( 'Insert row after' ), + 'Insert column before' => __( 'Insert column before' ), + 'Insert column after' => __( 'Insert column after' ), + 'Paste row before' => __( 'Paste table row before' ), + 'Paste row after' => __( 'Paste table row after' ), + 'Delete row' => __( 'Delete row' ), + 'Delete column' => __( 'Delete column' ), + 'Cut row' => __( 'Cut table row' ), + 'Copy row' => __( 'Copy table row' ), + 'Merge cells' => __( 'Merge table cells' ), + 'Split cell' => __( 'Split table cell' ), + + 'Height' => __( 'Height' ), + 'Width' => __( 'Width' ), + 'Caption' => __( 'Caption' ), + 'Alignment' => __( 'Alignment' ), + 'H Align' => _x( 'H Align', 'horizontal table cell alignment' ), + 'Left' => __( 'Left' ), + 'Center' => __( 'Center' ), + 'Right' => __( 'Right' ), + 'None' => _x( 'None', 'table cell alignment attribute' ), + 'V Align' => _x( 'V Align', 'vertical table cell alignment' ), + 'Top' => __( 'Top' ), + 'Middle' => __( 'Middle' ), + 'Bottom' => __( 'Bottom' ), + + 'Row group' => __( 'Row group' ), + 'Column group' => __( 'Column group' ), + 'Row type' => __( 'Row type' ), + 'Cell type' => __( 'Cell type' ), + 'Cell padding' => __( 'Cell padding' ), + 'Cell spacing' => __( 'Cell spacing' ), + 'Scope' => _x( 'Scope', 'table cell scope attribute' ), + + 'Insert template' => _x( 'Insert template', 'TinyMCE' ), + 'Templates' => _x( 'Templates', 'TinyMCE' ), + + 'Background color' => __( 'Background color' ), + 'Text color' => __( 'Text color' ), + 'Show blocks' => _x( 'Show blocks', 'editor button' ), + 'Show invisible characters' => __( 'Show invisible characters' ), + + /* translators: word count */ + 'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ), + 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => + __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . + __( 'If you’re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ), + 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => + __( 'Rich Text Area. Press Alt-Shift-H for help.' ), + 'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ), + 'You have unsaved changes are you sure you want to navigate away?' => + __( 'The changes you made will be lost if you navigate away from this page.' ), + 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => + __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), + + // TinyMCE menus + 'Insert' => _x( 'Insert', 'TinyMCE menu' ), + 'File' => _x( 'File', 'TinyMCE menu' ), + 'Edit' => _x( 'Edit', 'TinyMCE menu' ), + 'Tools' => _x( 'Tools', 'TinyMCE menu' ), + 'View' => _x( 'View', 'TinyMCE menu' ), + 'Table' => _x( 'Table', 'TinyMCE menu' ), + 'Format' => _x( 'Format', 'TinyMCE menu' ), + + // WordPress strings + 'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ), + 'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ), + 'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ), + 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) + 'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ), + 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar + 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar + 'Edit ' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar + 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog + 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog + 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog + 'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label + 'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label + + // Shortcuts help modal + 'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ), + 'Default shortcuts,' => __( 'Default shortcuts,' ), + 'Additional shortcuts,' => __( 'Additional shortcuts,' ), + 'Focus shortcuts:' => __( 'Focus shortcuts:' ), + 'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ), + 'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ), + 'Editor toolbar' => __( 'Editor toolbar' ), + 'Elements path' => __( 'Elements path' ), + 'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ), + 'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ), + 'Cmd + letter:' => __( 'Cmd + letter:' ), + 'Ctrl + letter:' => __( 'Ctrl + letter:' ), + 'Letter' => __( 'Letter' ), + 'Action' => __( 'Action' ), + 'Warning: the link has been inserted but may have errors. Please test it.' => __( 'Warning: the link has been inserted but may have errors. Please test it.' ), + 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' => + __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ), + 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' => + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ), + 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => + __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ), + 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' => + __( 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' ), + ); + } + + /* + Imagetools plugin (not included): + 'Edit image' => __( 'Edit image' ), + 'Image options' => __( 'Image options' ), + 'Back' => __( 'Back' ), + 'Invert' => __( 'Invert' ), + 'Flip horizontally' => __( 'Flip horizontally' ), + 'Flip vertically' => __( 'Flip vertically' ), + 'Crop' => __( 'Crop' ), + 'Orientation' => __( 'Orientation' ), + 'Resize' => __( 'Resize' ), + 'Rotate clockwise' => __( 'Rotate clockwise' ), + 'Rotate counterclockwise' => __( 'Rotate counterclockwise' ), + 'Sharpen' => __( 'Sharpen' ), + 'Brightness' => __( 'Brightness' ), + 'Color levels' => __( 'Color levels' ), + 'Contrast' => __( 'Contrast' ), + 'Gamma' => __( 'Gamma' ), + 'Zoom in' => __( 'Zoom in' ), + 'Zoom out' => __( 'Zoom out' ), + */ + + return self::$translation; + } + + /** + * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), + * or as JS snippet that should run after tinymce.js is loaded. + * + * @static + * @param string $mce_locale The locale used for the editor. + * @param bool $json_only optional Whether to include the JavaScript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone(). + * @return string Translation object, JSON encoded. + */ + public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { + if ( ! $mce_locale ) { + $mce_locale = self::get_mce_locale(); + } + + $mce_translation = self::get_translation(); + + foreach ( $mce_translation as $name => $value ) { + if ( is_array( $value ) ) { + $mce_translation[$name] = $value[0]; + } + } + + /** + * Filters translated strings prepared for TinyMCE. + * + * @since 3.9.0 + * + * @param array $mce_translation Key/value pairs of strings. + * @param string $mce_locale Locale. + */ + $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); + + foreach ( $mce_translation as $key => $value ) { + // Remove strings that are not translated. + if ( $key === $value ) { + unset( $mce_translation[$key] ); + continue; + } + + if ( false !== strpos( $value, '&' ) ) { + $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); + } + } + + // Set direction + if ( is_rtl() ) { + $mce_translation['_dir'] = 'rtl'; + } + + if ( $json_only ) { + return wp_json_encode( $mce_translation ); + } + + $baseurl = self::get_baseurl(); + + return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . + "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; + } + + /** + * Print (output) the main TinyMCE scripts. + * + * @since 4.8.0 + * + * @static + * @global string $tinymce_version + * @global bool $concatenate_scripts + * @global bool $compress_scripts + */ + public static function print_tinymce_scripts() { + global $tinymce_version, $concatenate_scripts, $compress_scripts; + + if ( self::$tinymce_scripts_printed ) { + return; + } + + self::$tinymce_scripts_printed = true; + + if ( ! isset( $concatenate_scripts ) ) { + script_concat_settings(); + } + + $suffix = SCRIPT_DEBUG ? '' : '.min'; + $version = 'ver=' . $tinymce_version; + $baseurl = self::get_baseurl(); + + $has_custom_theme = false; + foreach ( self::$mce_settings as $init ) { + if ( ! empty( $init['theme_url'] ) ) { + $has_custom_theme = true; + break; + } + } + + $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) + && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $has_custom_theme; + + // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG) + $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min'; + + if ( $compressed ) { + echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n"; + } else { + echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n"; + echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n"; + } + + echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; + } + + /** + * Print (output) the TinyMCE configuration and initialization scripts. + * + * @static + * @global string $tinymce_version + */ + public static function editor_js() { + global $tinymce_version; + + $tmce_on = ! empty( self::$mce_settings ); + $mceInit = $qtInit = ''; + + if ( $tmce_on ) { + foreach ( self::$mce_settings as $editor_id => $init ) { + $options = self::_parse_init( $init ); + $mceInit .= "'$editor_id':{$options},"; + } + $mceInit = '{' . trim( $mceInit, ',' ) . '}'; + } else { + $mceInit = '{}'; + } + + if ( ! empty( self::$qt_settings ) ) { + foreach ( self::$qt_settings as $editor_id => $init ) { + $options = self::_parse_init( $init ); + $qtInit .= "'$editor_id':{$options},"; + } + $qtInit = '{' . trim( $qtInit, ',' ) . '}'; + } else { + $qtInit = '{}'; + } + + $ref = array( + 'plugins' => implode( ',', self::$plugins ), + 'theme' => 'modern', + 'language' => self::$mce_locale + ); + + $suffix = SCRIPT_DEBUG ? '' : '.min'; + $baseurl = self::get_baseurl(); + $version = 'ver=' . $tinymce_version; + + /** + * Fires immediately before the TinyMCE settings are printed. + * + * @since 3.2.0 + * + * @param array $mce_settings TinyMCE settings array. + */ + do_action( 'before_wp_tiny_mce', self::$mce_settings ); + ?> + + <script type="text/javascript"> + tinyMCEPreInit = { + baseURL: "<?php echo $baseurl; ?>", + suffix: "<?php echo $suffix; ?>", + <?php + + if ( self::$drag_drop_upload ) { + echo 'dragDropUpload: true,'; + } + + ?> + mceInit: <?php echo $mceInit; ?>, + qtInit: <?php echo $qtInit; ?>, + ref: <?php echo self::_parse_init( $ref ); ?>, + load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} + }; + </script> + <?php + + if ( $tmce_on ) { + self::print_tinymce_scripts(); + + if ( self::$ext_plugins ) { + // Load the old-format English strings to prevent unsightly labels in old style popups + echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; + } + } + + /** + * Fires after tinymce.js is loaded, but before any TinyMCE editor + * instances are created. + * + * @since 3.9.0 + * + * @param array $mce_settings TinyMCE settings array. + */ + do_action( 'wp_tiny_mce_init', self::$mce_settings ); + + ?> + <script type="text/javascript"> + <?php + + if ( self::$ext_plugins ) + echo self::$ext_plugins . "\n"; + + if ( ! is_admin() ) + echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; + + ?> + + ( function() { + var init, id, $wrap; + + if ( typeof tinymce !== 'undefined' ) { + if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) { + tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' ); + return; + } + + for ( id in tinyMCEPreInit.mceInit ) { + init = tinyMCEPreInit.mceInit[id]; + $wrap = tinymce.$( '#wp-' + id + '-wrap' ); + + if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) { + tinymce.init( init ); + + if ( ! window.wpActiveEditor ) { + window.wpActiveEditor = id; + } + } + } + } + + if ( typeof quicktags !== 'undefined' ) { + for ( id in tinyMCEPreInit.qtInit ) { + quicktags( tinyMCEPreInit.qtInit[id] ); + + if ( ! window.wpActiveEditor ) { + window.wpActiveEditor = id; + } + } + } + }()); + </script> + <?php + + if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { + self::wp_link_dialog(); + } + + /** + * Fires after any core TinyMCE editor instances are created. + * + * @since 3.2.0 + * + * @param array $mce_settings TinyMCE settings array. + */ + do_action( 'after_wp_tiny_mce', self::$mce_settings ); + } + + /** + * Outputs the HTML for distraction-free writing mode. + * + * @since 3.2.0 + * @deprecated 4.3.0 + * + * @static + */ + public static function wp_fullscreen_html() { + _deprecated_function( __FUNCTION__, '4.3.0' ); + } + + /** + * Performs post queries for internal linking. + * + * @since 3.1.0 + * + * @static + * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. + * @return false|array Results. + */ + public static function wp_link_query( $args = array() ) { + $pts = get_post_types( array( 'public' => true ), 'objects' ); + $pt_names = array_keys( $pts ); + + $query = array( + 'post_type' => $pt_names, + 'suppress_filters' => true, + 'update_post_term_cache' => false, + 'update_post_meta_cache' => false, + 'post_status' => 'publish', + 'posts_per_page' => 20, + ); + + $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; + + if ( isset( $args['s'] ) ) + $query['s'] = $args['s']; + + $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; + + /** + * Filters the link query arguments. + * + * Allows modification of the link query arguments before querying. + * + * @see WP_Query for a full list of arguments + * + * @since 3.7.0 + * + * @param array $query An array of WP_Query arguments. + */ + $query = apply_filters( 'wp_link_query_args', $query ); + + // Do main query. + $get_posts = new WP_Query; + $posts = $get_posts->query( $query ); + + // Build results. + $results = array(); + foreach ( $posts as $post ) { + if ( 'post' == $post->post_type ) + $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); + else + $info = $pts[ $post->post_type ]->labels->singular_name; + + $results[] = array( + 'ID' => $post->ID, + 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), + 'permalink' => get_permalink( $post->ID ), + 'info' => $info, + ); + } + + /** + * Filters the link query results. + * + * Allows modification of the returned link query results. + * + * @since 3.7.0 + * + * @see 'wp_link_query_args' filter + * + * @param array $results { + * An associative array of query results. + * + * @type array { + * @type int $ID Post ID. + * @type string $title The trimmed, escaped post title. + * @type string $permalink Post permalink. + * @type string $info A 'Y/m/d'-formatted date for 'post' post type, + * the 'singular_name' post type label otherwise. + * } + * } + * @param array $query An array of WP_Query arguments. + */ + $results = apply_filters( 'wp_link_query', $results, $query ); + + return ! empty( $results ) ? $results : false; + } + + /** + * Dialog for internal linking. + * + * @since 3.1.0 + * + * @static + */ + public static function wp_link_dialog() { + // Run once + if ( self::$link_dialog_printed ) { + return; + } + + self::$link_dialog_printed = true; + + // display: none is required here, see #WP27605 + ?> + <div id="wp-link-backdrop" style="display: none"></div> + <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> + <form id="wp-link" tabindex="-1"> + <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> + <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> + <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> + <div id="link-selector"> + <div id="link-options"> + <p class="howto" id="wplink-enter-url"><?php _e( 'Enter the destination URL' ); ?></p> + <div> + <label><span><?php _e( 'URL' ); ?></span> + <input id="wp-link-url" type="text" aria-describedby="wplink-enter-url" /></label> + </div> + <div class="wp-link-text-field"> + <label><span><?php _e( 'Link Text' ); ?></span> + <input id="wp-link-text" type="text" /></label> + </div> + <div class="link-target"> + <label><span></span> + <input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new tab' ); ?></label> + </div> + </div> + <p class="howto" id="wplink-link-existing-content"><?php _e( 'Or link to existing content' ); ?></p> + <div id="search-panel"> + <div class="link-search-wrapper"> + <label> + <span class="search-label"><?php _e( 'Search' ); ?></span> + <input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" aria-describedby="wplink-link-existing-content" /> + <span class="spinner"></span> + </label> + </div> + <div id="search-results" class="query-results" tabindex="0"> + <ul></ul> + <div class="river-waiting"> + <span class="spinner"></span> + </div> + </div> + <div id="most-recent-results" class="query-results" tabindex="0"> + <div class="query-notice" id="query-notice-message"> + <em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> + <em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em> + </div> + <ul></ul> + <div class="river-waiting"> + <span class="spinner"></span> + </div> + </div> + </div> + </div> + <div class="submitbox"> + <div id="wp-link-cancel"> + <button type="button" class="button"><?php _e( 'Cancel' ); ?></button> + </div> + <div id="wp-link-update"> + <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> + </div> + </div> + </form> + </div> + <?php + } +} diff --git a/backend/wp-includes/class-wp-embed.php b/backend/wp-includes/class-wp-embed.php new file mode 100644 index 0000000..4674cae --- /dev/null +++ b/backend/wp-includes/class-wp-embed.php @@ -0,0 +1,479 @@ +<?php +/** + * API for easily embedding rich media such as videos and images into content. + * + * @package WordPress + * @subpackage Embed + * @since 2.9.0 + */ +class WP_Embed { + public $handlers = array(); + public $post_ID; + public $usecache = true; + public $linkifunknown = true; + public $last_attr = array(); + public $last_url = ''; + + /** + * When a URL cannot be embedded, return false instead of returning a link + * or the URL. + * + * Bypasses the {@see 'embed_maybe_make_link'} filter. + * + * @var bool + */ + public $return_false_on_fail = false; + + /** + * Constructor + */ + public function __construct() { + // Hack to get the [embed] shortcode to run before wpautop() + add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 ); + add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 ); + + // Shortcode placeholder for strip_shortcodes() + add_shortcode( 'embed', '__return_false' ); + + // Attempts to embed all URLs in a post + add_filter( 'the_content', array( $this, 'autoembed' ), 8 ); + add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 ); + + // After a post is saved, cache oEmbed items via Ajax + add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) ); + add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) ); + } + + /** + * Process the [embed] shortcode. + * + * Since the [embed] shortcode needs to be run earlier than other shortcodes, + * this function removes all existing shortcodes, registers the [embed] shortcode, + * calls do_shortcode(), and then re-registers the old shortcodes. + * + * @global array $shortcode_tags + * + * @param string $content Content to parse + * @return string Content with shortcode parsed + */ + public function run_shortcode( $content ) { + global $shortcode_tags; + + // Back up current registered shortcodes and clear them all out + $orig_shortcode_tags = $shortcode_tags; + remove_all_shortcodes(); + + add_shortcode( 'embed', array( $this, 'shortcode' ) ); + + // Do the shortcode (only the [embed] one is registered) + $content = do_shortcode( $content, true ); + + // Put the original shortcodes back + $shortcode_tags = $orig_shortcode_tags; + + return $content; + } + + /** + * If a post/page was saved, then output JavaScript to make + * an Ajax request that will call WP_Embed::cache_oembed(). + */ + public function maybe_run_ajax_cache() { + $post = get_post(); + + if ( ! $post || empty( $_GET['message'] ) ) + return; + +?> +<script type="text/javascript"> + jQuery(document).ready(function($){ + $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>"); + }); +</script> +<?php + } + + /** + * Registers an embed handler. + * + * Do not use this function directly, use wp_embed_register_handler() instead. + * + * This function should probably also only be used for sites that do not support oEmbed. + * + * @param string $id An internal ID/name for the handler. Needs to be unique. + * @param string $regex The regex that will be used to see if this handler should be used for a URL. + * @param callable $callback The callback function that will be called if the regex is matched. + * @param int $priority Optional. Used to specify the order in which the registered handlers will be tested (default: 10). Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action. + */ + public function register_handler( $id, $regex, $callback, $priority = 10 ) { + $this->handlers[$priority][$id] = array( + 'regex' => $regex, + 'callback' => $callback, + ); + } + + /** + * Unregisters a previously-registered embed handler. + * + * Do not use this function directly, use wp_embed_unregister_handler() instead. + * + * @param string $id The handler ID that should be removed. + * @param int $priority Optional. The priority of the handler to be removed (default: 10). + */ + public function unregister_handler( $id, $priority = 10 ) { + unset( $this->handlers[ $priority ][ $id ] ); + } + + /** + * The do_shortcode() callback function. + * + * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of + * the registered embed handlers. If none of the regex matches and it's enabled, then the URL + * will be given to the WP_oEmbed class. + * + * @param array $attr { + * Shortcode attributes. Optional. + * + * @type int $width Width of the embed in pixels. + * @type int $height Height of the embed in pixels. + * } + * @param string $url The URL attempting to be embedded. + * @return string|false The embed HTML on success, otherwise the original URL. + * `->maybe_make_link()` can return false on failure. + */ + public function shortcode( $attr, $url = '' ) { + $post = get_post(); + + if ( empty( $url ) && ! empty( $attr['src'] ) ) { + $url = $attr['src']; + } + + $this->last_url = $url; + + if ( empty( $url ) ) { + $this->last_attr = $attr; + return ''; + } + + $rawattr = $attr; + $attr = wp_parse_args( $attr, wp_embed_defaults( $url ) ); + + $this->last_attr = $attr; + + // kses converts & into & and we need to undo this + // See https://core.trac.wordpress.org/ticket/11311 + $url = str_replace( '&', '&', $url ); + + // Look for known internal handlers + ksort( $this->handlers ); + foreach ( $this->handlers as $priority => $handlers ) { + foreach ( $handlers as $id => $handler ) { + if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { + if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) + /** + * Filters the returned embed handler. + * + * @since 2.9.0 + * + * @see WP_Embed::shortcode() + * + * @param mixed $return The shortcode callback function to call. + * @param string $url The attempted embed URL. + * @param array $attr An array of shortcode attributes. + */ + return apply_filters( 'embed_handler_html', $return, $url, $attr ); + } + } + } + + $post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null; + + // Potentially set by WP_Embed::cache_oembed(). + if ( ! empty( $this->post_ID ) ) { + $post_ID = $this->post_ID; + } + + // Check for a cached result (stored as custom post or in the post meta). + $key_suffix = md5( $url . serialize( $attr ) ); + $cachekey = '_oembed_' . $key_suffix; + $cachekey_time = '_oembed_time_' . $key_suffix; + + /** + * Filters the oEmbed TTL value (time to live). + * + * @since 4.0.0 + * + * @param int $time Time to live (in seconds). + * @param string $url The attempted embed URL. + * @param array $attr An array of shortcode attributes. + * @param int $post_ID Post ID. + */ + $ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_ID ); + + $cache = ''; + $cache_time = 0; + + $cached_post_id = $this->find_oembed_post_id( $key_suffix ); + + if ( $post_ID ) { + $cache = get_post_meta( $post_ID, $cachekey, true ); + $cache_time = get_post_meta( $post_ID, $cachekey_time, true ); + + if ( ! $cache_time ) { + $cache_time = 0; + } + } elseif ( $cached_post_id ) { + $cached_post = get_post( $cached_post_id ); + + $cache = $cached_post->post_content; + $cache_time = strtotime( $cached_post->post_modified_gmt ); + } + + $cached_recently = ( time() - $cache_time ) < $ttl; + + if ( $this->usecache || $cached_recently ) { + // Failures are cached. Serve one if we're using the cache. + if ( '{{unknown}}' === $cache ) { + return $this->maybe_make_link( $url ); + } + + if ( ! empty( $cache ) ) { + /** + * Filters the cached oEmbed HTML. + * + * @since 2.9.0 + * + * @see WP_Embed::shortcode() + * + * @param mixed $cache The cached HTML result, stored in post meta. + * @param string $url The attempted embed URL. + * @param array $attr An array of shortcode attributes. + * @param int $post_ID Post ID. + */ + return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID ); + } + } + + /** + * Filters whether to inspect the given URL for discoverable link tags. + * + * @since 2.9.0 + * @since 4.4.0 The default value changed to true. + * + * @see WP_oEmbed::discover() + * + * @param bool $enable Whether to enable `<link>` tag discovery. Default true. + */ + $attr['discover'] = apply_filters( 'embed_oembed_discover', true ); + + // Use oEmbed to get the HTML. + $html = wp_oembed_get( $url, $attr ); + + if ( $post_ID ) { + if ( $html ) { + update_post_meta( $post_ID, $cachekey, $html ); + update_post_meta( $post_ID, $cachekey_time, time() ); + } elseif ( ! $cache ) { + update_post_meta( $post_ID, $cachekey, '{{unknown}}' ); + } + } else { + $has_kses = false !== has_filter( 'content_save_pre', 'wp_filter_post_kses' ); + + if ( $has_kses ) { + // Prevent KSES from corrupting JSON in post_content. + kses_remove_filters(); + } + + $insert_post_args = array( + 'post_name' => $key_suffix, + 'post_status' => 'publish', + 'post_type' => 'oembed_cache', + ); + + if ( $html ) { + if ( $cached_post_id ) { + wp_update_post( wp_slash( array( + 'ID' => $cached_post_id, + 'post_content' => $html, + ) ) ); + } else { + wp_insert_post( wp_slash( array_merge( + $insert_post_args, + array( + 'post_content' => $html, + ) + ) ) ); + } + } elseif ( ! $cache ) { + wp_insert_post( wp_slash( array_merge( + $insert_post_args, + array( + 'post_content' => '{{unknown}}', + ) + ) ) ); + } + + if ( $has_kses ) { + kses_init_filters(); + } + } + + // If there was a result, return it. + if ( $html ) { + /** This filter is documented in wp-includes/class-wp-embed.php */ + return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID ); + } + + // Still unknown + return $this->maybe_make_link( $url ); + } + + /** + * Delete all oEmbed caches. Unused by core as of 4.0.0. + * + * @param int $post_ID Post ID to delete the caches for. + */ + public function delete_oembed_caches( $post_ID ) { + $post_metas = get_post_custom_keys( $post_ID ); + if ( empty($post_metas) ) + return; + + foreach ( $post_metas as $post_meta_key ) { + if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) + delete_post_meta( $post_ID, $post_meta_key ); + } + } + + /** + * Triggers a caching of all oEmbed results. + * + * @param int $post_ID Post ID to do the caching for. + */ + public function cache_oembed( $post_ID ) { + $post = get_post( $post_ID ); + + $post_types = get_post_types( array( 'show_ui' => true ) ); + /** + * Filters the array of post types to cache oEmbed results for. + * + * @since 2.9.0 + * + * @param array $post_types Array of post types to cache oEmbed results for. Defaults to post types with `show_ui` set to true. + */ + if ( empty( $post->ID ) || ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ){ + return; + } + + // Trigger a caching + if ( ! empty( $post->post_content ) ) { + $this->post_ID = $post->ID; + $this->usecache = false; + + $content = $this->run_shortcode( $post->post_content ); + $this->autoembed( $content ); + + $this->usecache = true; + } + } + + /** + * Passes any unlinked URLs that are on their own line to WP_Embed::shortcode() for potential embedding. + * + * @see WP_Embed::autoembed_callback() + * + * @param string $content The content to be searched. + * @return string Potentially modified $content. + */ + public function autoembed( $content ) { + // Replace line breaks from all HTML elements with placeholders. + $content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) ); + + if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) { + // Find URLs on their own line. + $content = preg_replace_callback( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); + // Find URLs in their own paragraph. + $content = preg_replace_callback( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', array( $this, 'autoembed_callback' ), $content ); + } + + // Put the line breaks back. + return str_replace( '<!-- wp-line-break -->', "\n", $content ); + } + + /** + * Callback function for WP_Embed::autoembed(). + * + * @param array $match A regex match array. + * @return string The embed HTML on success, otherwise the original URL. + */ + public function autoembed_callback( $match ) { + $oldval = $this->linkifunknown; + $this->linkifunknown = false; + $return = $this->shortcode( array(), $match[2] ); + $this->linkifunknown = $oldval; + + return $match[1] . $return . $match[3]; + } + + /** + * Conditionally makes a hyperlink based on an internal class variable. + * + * @param string $url URL to potentially be linked. + * @return false|string Linked URL or the original URL. False if 'return_false_on_fail' is true. + */ + public function maybe_make_link( $url ) { + if ( $this->return_false_on_fail ) { + return false; + } + + $output = ( $this->linkifunknown ) ? '<a href="' . esc_url($url) . '">' . esc_html($url) . '</a>' : $url; + + /** + * Filters the returned, maybe-linked embed URL. + * + * @since 2.9.0 + * + * @param string $output The linked or original URL. + * @param string $url The original URL. + */ + return apply_filters( 'embed_maybe_make_link', $output, $url ); + } + + /** + * Find the oEmbed cache post ID for a given cache key. + * + * @since 4.9.0 + * + * @param string $cache_key oEmbed cache key. + * @return int|null Post ID on success, null on failure. + */ + public function find_oembed_post_id( $cache_key ) { + $cache_group = 'oembed_cache_post'; + $oembed_post_id = wp_cache_get( $cache_key, $cache_group ); + + if ( $oembed_post_id && 'oembed_cache' === get_post_type( $oembed_post_id ) ) { + return $oembed_post_id; + } + + $oembed_post_query = new WP_Query( array( + 'post_type' => 'oembed_cache', + 'post_status' => 'publish', + 'name' => $cache_key, + 'posts_per_page' => 1, + 'no_found_rows' => true, + 'cache_results' => true, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, + 'lazy_load_term_meta' => false, + ) ); + + if ( ! empty( $oembed_post_query->posts ) ) { + // Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed. + $oembed_post_id = $oembed_post_query->posts[0]->ID; + wp_cache_set( $cache_key, $oembed_post_id, $cache_group ); + + return $oembed_post_id; + } + + return null; + } +} diff --git a/backend/wp-includes/class-wp-error.php b/backend/wp-includes/class-wp-error.php new file mode 100644 index 0000000..2906e76 --- /dev/null +++ b/backend/wp-includes/class-wp-error.php @@ -0,0 +1,200 @@ +<?php +/** + * WordPress Error API. + * + * Contains the WP_Error class and the is_wp_error() function. + * + * @package WordPress + */ + +/** + * WordPress Error class. + * + * Container for checking for WordPress errors and error messages. Return + * WP_Error and use is_wp_error() to check if this class is returned. Many + * core WordPress functions pass this class in the event of an error and + * if not handled properly will result in code errors. + * + * @since 2.1.0 + */ +class WP_Error { + /** + * Stores the list of errors. + * + * @since 2.1.0 + * @var array + */ + public $errors = array(); + + /** + * Stores the list of data for error codes. + * + * @since 2.1.0 + * @var array + */ + public $error_data = array(); + + /** + * Initialize the error. + * + * If `$code` is empty, the other parameters will be ignored. + * When `$code` is not empty, `$message` will be used even if + * it is empty. The `$data` parameter will be used only if it + * is not empty. + * + * Though the class is constructed with a single error code and + * message, multiple codes can be added using the `add()` method. + * + * @since 2.1.0 + * + * @param string|int $code Error code + * @param string $message Error message + * @param mixed $data Optional. Error data. + */ + public function __construct( $code = '', $message = '', $data = '' ) { + if ( empty($code) ) + return; + + $this->errors[$code][] = $message; + + if ( ! empty($data) ) + $this->error_data[$code] = $data; + } + + /** + * Retrieve all error codes. + * + * @since 2.1.0 + * + * @return array List of error codes, if available. + */ + public function get_error_codes() { + if ( empty($this->errors) ) + return array(); + + return array_keys($this->errors); + } + + /** + * Retrieve first error code available. + * + * @since 2.1.0 + * + * @return string|int Empty string, if no error codes. + */ + public function get_error_code() { + $codes = $this->get_error_codes(); + + if ( empty($codes) ) + return ''; + + return $codes[0]; + } + + /** + * Retrieve all error messages or error messages matching code. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Retrieve messages matching code, if exists. + * @return array Error strings on success, or empty array on failure (if using code parameter). + */ + public function get_error_messages($code = '') { + // Return all messages if no code specified. + if ( empty($code) ) { + $all_messages = array(); + foreach ( (array) $this->errors as $code => $messages ) + $all_messages = array_merge($all_messages, $messages); + + return $all_messages; + } + + if ( isset($this->errors[$code]) ) + return $this->errors[$code]; + else + return array(); + } + + /** + * Get single error message. + * + * This will get the first message available for the code. If no code is + * given then the first code available will be used. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Error code to retrieve message. + * @return string + */ + public function get_error_message($code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + $messages = $this->get_error_messages($code); + if ( empty($messages) ) + return ''; + return $messages[0]; + } + + /** + * Retrieve error data for error code. + * + * @since 2.1.0 + * + * @param string|int $code Optional. Error code. + * @return mixed Error data, if it exists. + */ + public function get_error_data($code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + + if ( isset($this->error_data[$code]) ) + return $this->error_data[$code]; + } + + /** + * Add an error or append additional message to an existing error. + * + * @since 2.1.0 + * + * @param string|int $code Error code. + * @param string $message Error message. + * @param mixed $data Optional. Error data. + */ + public function add($code, $message, $data = '') { + $this->errors[$code][] = $message; + if ( ! empty($data) ) + $this->error_data[$code] = $data; + } + + /** + * Add data for error code. + * + * The error code can only contain one error data. + * + * @since 2.1.0 + * + * @param mixed $data Error data. + * @param string|int $code Error code. + */ + public function add_data($data, $code = '') { + if ( empty($code) ) + $code = $this->get_error_code(); + + $this->error_data[$code] = $data; + } + + /** + * Removes the specified error. + * + * This function removes all error messages associated with the specified + * error code, along with any error data for that code. + * + * @since 4.1.0 + * + * @param string|int $code Error code. + */ + public function remove( $code ) { + unset( $this->errors[ $code ] ); + unset( $this->error_data[ $code ] ); + } +} diff --git a/backend/wp-includes/class-wp-feed-cache-transient.php b/backend/wp-includes/class-wp-feed-cache-transient.php new file mode 100644 index 0000000..dc929c8 --- /dev/null +++ b/backend/wp-includes/class-wp-feed-cache-transient.php @@ -0,0 +1,132 @@ +<?php +/** + * Feed API: WP_Feed_Cache_Transient class + * + * @package WordPress + * @subpackage Feed + * @since 4.7.0 + */ + +/** + * Core class used to implement feed cache transients. + * + * @since 2.8.0 + */ +class WP_Feed_Cache_Transient { + + /** + * Holds the transient name. + * + * @since 2.8.0 + * @var string + */ + public $name; + + /** + * Holds the transient mod name. + * + * @since 2.8.0 + * @var string + */ + public $mod_name; + + /** + * Holds the cache duration in seconds. + * + * Defaults to 43200 seconds (12 hours). + * + * @since 2.8.0 + * @var int + */ + public $lifetime = 43200; + + /** + * Constructor. + * + * @since 2.8.0 + * @since 3.2.0 Updated to use a PHP5 constructor. + * + * @param string $location URL location (scheme is used to determine handler). + * @param string $filename Unique identifier for cache object. + * @param string $extension 'spi' or 'spc'. + */ + public function __construct($location, $filename, $extension) { + $this->name = 'feed_' . $filename; + $this->mod_name = 'feed_mod_' . $filename; + + $lifetime = $this->lifetime; + /** + * Filters the transient lifetime of the feed cache. + * + * @since 2.8.0 + * + * @param int $lifetime Cache duration in seconds. Default is 43200 seconds (12 hours). + * @param string $filename Unique identifier for the cache object. + */ + $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename); + } + + /** + * Sets the transient. + * + * @since 2.8.0 + * + * @param SimplePie $data Data to save. + * @return true Always true. + */ + public function save($data) { + if ( $data instanceof SimplePie ) { + $data = $data->data; + } + + set_transient($this->name, $data, $this->lifetime); + set_transient($this->mod_name, time(), $this->lifetime); + return true; + } + + /** + * Gets the transient. + * + * @since 2.8.0 + * + * @return mixed Transient value. + */ + public function load() { + return get_transient($this->name); + } + + /** + * Gets mod transient. + * + * @since 2.8.0 + * + * @return mixed Transient value. + */ + public function mtime() { + return get_transient($this->mod_name); + } + + /** + * Sets mod transient. + * + * @since 2.8.0 + * + * @return bool False if value was not set and true if value was set. + */ + public function touch() { + return set_transient($this->mod_name, time(), $this->lifetime); + } + + /** + * Deletes transients. + * + * @since 2.8.0 + * + * @return true Always true. + */ + public function unlink() { + delete_transient($this->name); + delete_transient($this->mod_name); + return true; + } +} diff --git a/backend/wp-includes/class-wp-feed-cache.php b/backend/wp-includes/class-wp-feed-cache.php new file mode 100644 index 0000000..1c7d2b2 --- /dev/null +++ b/backend/wp-includes/class-wp-feed-cache.php @@ -0,0 +1,32 @@ +<?php +/** + * Feed API: WP_Feed_Cache class + * + * @package WordPress + * @subpackage Feed + * @since 4.7.0 + */ + +/** + * Core class used to implement a feed cache. + * + * @since 2.8.0 + * + * @see SimplePie_Cache + */ +class WP_Feed_Cache extends SimplePie_Cache { + + /** + * Creates a new SimplePie_Cache object. + * + * @since 2.8.0 + * + * @param string $location URL location (scheme is used to determine handler). + * @param string $filename Unique identifier for cache object. + * @param string $extension 'spi' or 'spc'. + * @return WP_Feed_Cache_Transient Feed cache handler object that uses transients. + */ + public function create($location, $filename, $extension) { + return new WP_Feed_Cache_Transient($location, $filename, $extension); + } +} diff --git a/backend/wp-includes/class-wp-hook.php b/backend/wp-includes/class-wp-hook.php new file mode 100644 index 0000000..3f79709 --- /dev/null +++ b/backend/wp-includes/class-wp-hook.php @@ -0,0 +1,510 @@ +<?php +/** + * Plugin API: WP_Hook class + * + * @package WordPress + * @subpackage Plugin + * @since 4.7.0 + */ + +/** + * Core class used to implement action and filter hook functionality. + * + * @since 4.7.0 + * + * @see Iterator + * @see ArrayAccess + */ +final class WP_Hook implements Iterator, ArrayAccess { + + /** + * Hook callbacks. + * + * @since 4.7.0 + * @var array + */ + public $callbacks = array(); + + /** + * The priority keys of actively running iterations of a hook. + * + * @since 4.7.0 + * @var array + */ + private $iterations = array(); + + /** + * The current priority of actively running iterations of a hook. + * + * @since 4.7.0 + * @var array + */ + private $current_priority = array(); + + /** + * Number of levels this hook can be recursively called. + * + * @since 4.7.0 + * @var int + */ + private $nesting_level = 0; + + /** + * Flag for if we're current doing an action, rather than a filter. + * + * @since 4.7.0 + * @var bool + */ + private $doing_action = false; + + /** + * Hooks a function or method to a specific filter action. + * + * @since 4.7.0 + * + * @param string $tag The name of the filter to hook the $function_to_add callback to. + * @param callable $function_to_add The callback to be run when the filter is applied. + * @param int $priority The order in which the functions associated with a + * particular action are executed. Lower numbers correspond with + * earlier execution, and functions with the same priority are executed + * in the order in which they were added to the action. + * @param int $accepted_args The number of arguments the function accepts. + */ + public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) { + $idx = _wp_filter_build_unique_id( $tag, $function_to_add, $priority ); + $priority_existed = isset( $this->callbacks[ $priority ] ); + + $this->callbacks[ $priority ][ $idx ] = array( + 'function' => $function_to_add, + 'accepted_args' => $accepted_args + ); + + // if we're adding a new priority to the list, put them back in sorted order + if ( ! $priority_existed && count( $this->callbacks ) > 1 ) { + ksort( $this->callbacks, SORT_NUMERIC ); + } + + if ( $this->nesting_level > 0 ) { + $this->resort_active_iterations( $priority, $priority_existed ); + } + } + + /** + * Handles reseting callback priority keys mid-iteration. + * + * @since 4.7.0 + * + * @param bool|int $new_priority Optional. The priority of the new filter being added. Default false, + * for no priority being added. + * @param bool $priority_existed Optional. Flag for whether the priority already existed before the new + * filter was added. Default false. + */ + private function resort_active_iterations( $new_priority = false, $priority_existed = false ) { + $new_priorities = array_keys( $this->callbacks ); + + // If there are no remaining hooks, clear out all running iterations. + if ( ! $new_priorities ) { + foreach ( $this->iterations as $index => $iteration ) { + $this->iterations[ $index ] = $new_priorities; + } + return; + } + + $min = min( $new_priorities ); + foreach ( $this->iterations as $index => &$iteration ) { + $current = current( $iteration ); + // If we're already at the end of this iteration, just leave the array pointer where it is. + if ( false === $current ) { + continue; + } + + $iteration = $new_priorities; + + if ( $current < $min ) { + array_unshift( $iteration, $current ); + continue; + } + + while ( current( $iteration ) < $current ) { + if ( false === next( $iteration ) ) { + break; + } + } + + // If we have a new priority that didn't exist, but ::apply_filters() or ::do_action() thinks it's the current priority... + if ( $new_priority === $this->current_priority[ $index ] && ! $priority_existed ) { + /* + * ... and the new priority is the same as what $this->iterations thinks is the previous + * priority, we need to move back to it. + */ + + if ( false === current( $iteration ) ) { + // If we've already moved off the end of the array, go back to the last element. + $prev = end( $iteration ); + } else { + // Otherwise, just go back to the previous element. + $prev = prev( $iteration ); + } + if ( false === $prev ) { + // Start of the array. Reset, and go about our day. + reset( $iteration ); + } elseif ( $new_priority !== $prev ) { + // Previous wasn't the same. Move forward again. + next( $iteration ); + } + } + } + unset( $iteration ); + } + + /** + * Unhooks a function or method from a specific filter action. + * + * @since 4.7.0 + * + * @param string $tag The filter hook to which the function to be removed is hooked. Used + * for building the callback ID when SPL is not available. + * @param callable $function_to_remove The callback to be removed from running when the filter is applied. + * @param int $priority The exact priority used when adding the original filter callback. + * @return bool Whether the callback existed before it was removed. + */ + public function remove_filter( $tag, $function_to_remove, $priority ) { + $function_key = _wp_filter_build_unique_id( $tag, $function_to_remove, $priority ); + + $exists = isset( $this->callbacks[ $priority ][ $function_key ] ); + if ( $exists ) { + unset( $this->callbacks[ $priority ][ $function_key ] ); + if ( ! $this->callbacks[ $priority ] ) { + unset( $this->callbacks[ $priority ] ); + if ( $this->nesting_level > 0 ) { + $this->resort_active_iterations(); + } + } + } + return $exists; + } + + /** + * Checks if a specific action has been registered for this hook. + * + * @since 4.7.0 + * + * @param string $tag Optional. The name of the filter hook. Used for building + * the callback ID when SPL is not available. Default empty. + * @param callable|bool $function_to_check Optional. The callback to check for. Default false. + * @return bool|int The priority of that hook is returned, or false if the function is not attached. + */ + public function has_filter( $tag = '', $function_to_check = false ) { + if ( false === $function_to_check ) { + return $this->has_filters(); + } + + $function_key = _wp_filter_build_unique_id( $tag, $function_to_check, false ); + if ( ! $function_key ) { + return false; + } + + foreach ( $this->callbacks as $priority => $callbacks ) { + if ( isset( $callbacks[ $function_key ] ) ) { + return $priority; + } + } + + return false; + } + + /** + * Checks if any callbacks have been registered for this hook. + * + * @since 4.7.0 + * + * @return bool True if callbacks have been registered for the current hook, otherwise false. + */ + public function has_filters() { + foreach ( $this->callbacks as $callbacks ) { + if ( $callbacks ) { + return true; + } + } + return false; + } + + /** + * Removes all callbacks from the current filter. + * + * @since 4.7.0 + * + * @param int|bool $priority Optional. The priority number to remove. Default false. + */ + public function remove_all_filters( $priority = false ) { + if ( ! $this->callbacks ) { + return; + } + + if ( false === $priority ) { + $this->callbacks = array(); + } else if ( isset( $this->callbacks[ $priority ] ) ) { + unset( $this->callbacks[ $priority ] ); + } + + if ( $this->nesting_level > 0 ) { + $this->resort_active_iterations(); + } + } + + /** + * Calls the callback functions added to a filter hook. + * + * @since 4.7.0 + * + * @param mixed $value The value to filter. + * @param array $args Arguments to pass to callbacks. + * @return mixed The filtered value after all hooked functions are applied to it. + */ + public function apply_filters( $value, $args ) { + if ( ! $this->callbacks ) { + return $value; + } + + $nesting_level = $this->nesting_level++; + + $this->iterations[ $nesting_level ] = array_keys( $this->callbacks ); + $num_args = count( $args ); + + do { + $this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] ); + + foreach ( $this->callbacks[ $priority ] as $the_ ) { + if( ! $this->doing_action ) { + $args[ 0 ] = $value; + } + + // Avoid the array_slice if possible. + if ( $the_['accepted_args'] == 0 ) { + $value = call_user_func_array( $the_['function'], array() ); + } elseif ( $the_['accepted_args'] >= $num_args ) { + $value = call_user_func_array( $the_['function'], $args ); + } else { + $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) ); + } + } + } while ( false !== next( $this->iterations[ $nesting_level ] ) ); + + unset( $this->iterations[ $nesting_level ] ); + unset( $this->current_priority[ $nesting_level ] ); + + $this->nesting_level--; + + return $value; + } + + /** + * Executes the callback functions hooked on a specific action hook. + * + * @since 4.7.0 + * + * @param mixed $args Arguments to pass to the hook callbacks. + */ + public function do_action( $args ) { + $this->doing_action = true; + $this->apply_filters( '', $args ); + + // If there are recursive calls to the current action, we haven't finished it until we get to the last one. + if ( ! $this->nesting_level ) { + $this->doing_action = false; + } + } + + /** + * Processes the functions hooked into the 'all' hook. + * + * @since 4.7.0 + * + * @param array $args Arguments to pass to the hook callbacks. Passed by reference. + */ + public function do_all_hook( &$args ) { + $nesting_level = $this->nesting_level++; + $this->iterations[ $nesting_level ] = array_keys( $this->callbacks ); + + do { + $priority = current( $this->iterations[ $nesting_level ] ); + foreach ( $this->callbacks[ $priority ] as $the_ ) { + call_user_func_array( $the_['function'], $args ); + } + } while ( false !== next( $this->iterations[ $nesting_level ] ) ); + + unset( $this->iterations[ $nesting_level ] ); + $this->nesting_level--; + } + + /** + * Return the current priority level of the currently running iteration of the hook. + * + * @since 4.7.0 + * + * @return int|false If the hook is running, return the current priority level. If it isn't running, return false. + */ + public function current_priority() { + if ( false === current( $this->iterations ) ) { + return false; + } + + return current( current( $this->iterations ) ); + } + + /** + * Normalizes filters set up before WordPress has initialized to WP_Hook objects. + * + * @since 4.7.0 + * @static + * + * @param array $filters Filters to normalize. + * @return WP_Hook[] Array of normalized filters. + */ + public static function build_preinitialized_hooks( $filters ) { + /** @var WP_Hook[] $normalized */ + $normalized = array(); + + foreach ( $filters as $tag => $callback_groups ) { + if ( is_object( $callback_groups ) && $callback_groups instanceof WP_Hook ) { + $normalized[ $tag ] = $callback_groups; + continue; + } + $hook = new WP_Hook(); + + // Loop through callback groups. + foreach ( $callback_groups as $priority => $callbacks ) { + + // Loop through callbacks. + foreach ( $callbacks as $cb ) { + $hook->add_filter( $tag, $cb['function'], $priority, $cb['accepted_args'] ); + } + } + $normalized[ $tag ] = $hook; + } + return $normalized; + } + + /** + * Determines whether an offset value exists. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/arrayaccess.offsetexists.php + * + * @param mixed $offset An offset to check for. + * @return bool True if the offset exists, false otherwise. + */ + public function offsetExists( $offset ) { + return isset( $this->callbacks[ $offset ] ); + } + + /** + * Retrieves a value at a specified offset. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/arrayaccess.offsetget.php + * + * @param mixed $offset The offset to retrieve. + * @return mixed If set, the value at the specified offset, null otherwise. + */ + public function offsetGet( $offset ) { + return isset( $this->callbacks[ $offset ] ) ? $this->callbacks[ $offset ] : null; + } + + /** + * Sets a value at a specified offset. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/arrayaccess.offsetset.php + * + * @param mixed $offset The offset to assign the value to. + * @param mixed $value The value to set. + */ + public function offsetSet( $offset, $value ) { + if ( is_null( $offset ) ) { + $this->callbacks[] = $value; + } else { + $this->callbacks[ $offset ] = $value; + } + } + + /** + * Unsets a specified offset. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/arrayaccess.offsetunset.php + * + * @param mixed $offset The offset to unset. + */ + public function offsetUnset( $offset ) { + unset( $this->callbacks[ $offset ] ); + } + + /** + * Returns the current element. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/iterator.current.php + * + * @return array Of callbacks at current priority. + */ + public function current() { + return current( $this->callbacks ); + } + + /** + * Moves forward to the next element. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/iterator.next.php + * + * @return array Of callbacks at next priority. + */ + public function next() { + return next( $this->callbacks ); + } + + /** + * Returns the key of the current element. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/iterator.key.php + * + * @return mixed Returns current priority on success, or NULL on failure + */ + public function key() { + return key( $this->callbacks ); + } + + /** + * Checks if current position is valid. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/iterator.valid.php + * + * @return boolean + */ + public function valid() { + return key( $this->callbacks ) !== null; + } + + /** + * Rewinds the Iterator to the first element. + * + * @since 4.7.0 + * + * @link https://secure.php.net/manual/en/iterator.rewind.php + */ + public function rewind() { + reset( $this->callbacks ); + } + +} diff --git a/backend/wp-includes/class-wp-http-cookie.php b/backend/wp-includes/class-wp-http-cookie.php new file mode 100644 index 0000000..6650e6e --- /dev/null +++ b/backend/wp-includes/class-wp-http-cookie.php @@ -0,0 +1,236 @@ +<?php +/** + * HTTP API: WP_Http_Cookie class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to encapsulate a single cookie object for internal use. + * + * Returned cookies are represented using this class, and when cookies are set, if they are not + * already a WP_Http_Cookie() object, then they are turned into one. + * + * @todo The WordPress convention is to use underscores instead of camelCase for function and method + * names. Need to switch to use underscores instead for the methods. + * + * @since 2.8.0 + */ +class WP_Http_Cookie { + + /** + * Cookie name. + * + * @since 2.8.0 + * @var string + */ + public $name; + + /** + * Cookie value. + * + * @since 2.8.0 + * @var string + */ + public $value; + + /** + * When the cookie expires. + * + * @since 2.8.0 + * @var string + */ + public $expires; + + /** + * Cookie URL path. + * + * @since 2.8.0 + * @var string + */ + public $path; + + /** + * Cookie Domain. + * + * @since 2.8.0 + * @var string + */ + public $domain; + + /** + * Sets up this cookie object. + * + * The parameter $data should be either an associative array containing the indices names below + * or a header string detailing it. + * + * @since 2.8.0 + * + * @param string|array $data { + * Raw cookie data as header string or data array. + * + * @type string $name Cookie name. + * @type mixed $value Value. Should NOT already be urlencoded. + * @type string|int $expires Optional. Unix timestamp or formatted date. Default null. + * @type string $path Optional. Path. Default '/'. + * @type string $domain Optional. Domain. Default host of parsed $requested_url. + * @type int $port Optional. Port. Default null. + * } + * @param string $requested_url The URL which the cookie was set on, used for default $domain + * and $port values. + */ + public function __construct( $data, $requested_url = '' ) { + if ( $requested_url ) + $arrURL = @parse_url( $requested_url ); + if ( isset( $arrURL['host'] ) ) + $this->domain = $arrURL['host']; + $this->path = isset( $arrURL['path'] ) ? $arrURL['path'] : '/'; + if ( '/' != substr( $this->path, -1 ) ) + $this->path = dirname( $this->path ) . '/'; + + if ( is_string( $data ) ) { + // Assume it's a header string direct from a previous request. + $pairs = explode( ';', $data ); + + // Special handling for first pair; name=value. Also be careful of "=" in value. + $name = trim( substr( $pairs[0], 0, strpos( $pairs[0], '=' ) ) ); + $value = substr( $pairs[0], strpos( $pairs[0], '=' ) + 1 ); + $this->name = $name; + $this->value = urldecode( $value ); + + // Removes name=value from items. + array_shift( $pairs ); + + // Set everything else as a property. + foreach ( $pairs as $pair ) { + $pair = rtrim($pair); + + // Handle the cookie ending in ; which results in a empty final pair. + if ( empty($pair) ) + continue; + + list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' ); + $key = strtolower( trim( $key ) ); + if ( 'expires' == $key ) + $val = strtotime( $val ); + $this->$key = $val; + } + } else { + if ( !isset( $data['name'] ) ) + return; + + // Set properties based directly on parameters. + foreach ( array( 'name', 'value', 'path', 'domain', 'port' ) as $field ) { + if ( isset( $data[ $field ] ) ) + $this->$field = $data[ $field ]; + } + + if ( isset( $data['expires'] ) ) + $this->expires = is_int( $data['expires'] ) ? $data['expires'] : strtotime( $data['expires'] ); + else + $this->expires = null; + } + } + + /** + * Confirms that it's OK to send this cookie to the URL checked against. + * + * Decision is based on RFC 2109/2965, so look there for details on validity. + * + * @since 2.8.0 + * + * @param string $url URL you intend to send this cookie to + * @return bool true if allowed, false otherwise. + */ + public function test( $url ) { + if ( is_null( $this->name ) ) + return false; + + // Expires - if expired then nothing else matters. + if ( isset( $this->expires ) && time() > $this->expires ) + return false; + + // Get details on the URL we're thinking about sending to. + $url = parse_url( $url ); + $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' == $url['scheme'] ? 443 : 80 ); + $url['path'] = isset( $url['path'] ) ? $url['path'] : '/'; + + // Values to use for comparison against the URL. + $path = isset( $this->path ) ? $this->path : '/'; + $port = isset( $this->port ) ? $this->port : null; + $domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] ); + if ( false === stripos( $domain, '.' ) ) + $domain .= '.local'; + + // Host - very basic check that the request URL ends with the domain restriction (minus leading dot). + $domain = substr( $domain, 0, 1 ) == '.' ? substr( $domain, 1 ) : $domain; + if ( substr( $url['host'], -strlen( $domain ) ) != $domain ) + return false; + + // Port - supports "port-lists" in the format: "80,8000,8080". + if ( !empty( $port ) && !in_array( $url['port'], explode( ',', $port) ) ) + return false; + + // Path - request path must start with path restriction. + if ( substr( $url['path'], 0, strlen( $path ) ) != $path ) + return false; + + return true; + } + + /** + * Convert cookie name and value back to header string. + * + * @since 2.8.0 + * + * @return string Header encoded cookie name and value. + */ + public function getHeaderValue() { + if ( ! isset( $this->name ) || ! isset( $this->value ) ) + return ''; + + /** + * Filters the header-encoded cookie value. + * + * @since 3.4.0 + * + * @param string $value The cookie value. + * @param string $name The cookie name. + */ + return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); + } + + /** + * Retrieve cookie header for usage in the rest of the WordPress HTTP API. + * + * @since 2.8.0 + * + * @return string + */ + public function getFullHeader() { + return 'Cookie: ' . $this->getHeaderValue(); + } + + /** + * Retrieves cookie attributes. + * + * @since 4.6.0 + * + * @return array { + * List of attributes. + * + * @type string $expires When the cookie expires. + * @type string $path Cookie URL path. + * @type string $domain Cookie domain. + * } + */ + public function get_attributes() { + return array( + 'expires' => $this->expires, + 'path' => $this->path, + 'domain' => $this->domain, + ); + } +} diff --git a/backend/wp-includes/class-wp-http-curl.php b/backend/wp-includes/class-wp-http-curl.php new file mode 100644 index 0000000..3e1d012 --- /dev/null +++ b/backend/wp-includes/class-wp-http-curl.php @@ -0,0 +1,383 @@ +<?php +/** + * HTTP API: WP_Http_Curl class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to integrate Curl as an HTTP transport. + * + * HTTP request method uses Curl extension to retrieve the url. + * + * Requires the Curl extension to be installed. + * + * @since 2.7.0 + */ +class WP_Http_Curl { + + /** + * Temporary header storage for during requests. + * + * @since 3.2.0 + * @var string + */ + private $headers = ''; + + /** + * Temporary body storage for during requests. + * + * @since 3.6.0 + * @var string + */ + private $body = ''; + + /** + * The maximum amount of data to receive from the remote server. + * + * @since 3.6.0 + * @var int + */ + private $max_body_length = false; + + /** + * The file resource used for streaming to file. + * + * @since 3.6.0 + * @var resource + */ + private $stream_handle = false; + + /** + * The total bytes written in the current request. + * + * @since 4.1.0 + * @var int + */ + private $bytes_written_total = 0; + + /** + * Send a HTTP request to a URI using cURL extension. + * + * @since 2.7.0 + * + * @param string $url The request URL. + * @param string|array $args Optional. Override the defaults. + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + public function request($url, $args = array()) { + $defaults = array( + 'method' => 'GET', 'timeout' => 5, + 'redirection' => 5, 'httpversion' => '1.0', + 'blocking' => true, + 'headers' => array(), 'body' => null, 'cookies' => array() + ); + + $r = wp_parse_args( $args, $defaults ); + + if ( isset( $r['headers']['User-Agent'] ) ) { + $r['user-agent'] = $r['headers']['User-Agent']; + unset( $r['headers']['User-Agent'] ); + } elseif ( isset( $r['headers']['user-agent'] ) ) { + $r['user-agent'] = $r['headers']['user-agent']; + unset( $r['headers']['user-agent'] ); + } + + // Construct Cookie: header if any cookies are set. + WP_Http::buildCookieHeader( $r ); + + $handle = curl_init(); + + // cURL offers really easy proxy support. + $proxy = new WP_HTTP_Proxy(); + + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { + + curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP ); + curl_setopt( $handle, CURLOPT_PROXY, $proxy->host() ); + curl_setopt( $handle, CURLOPT_PROXYPORT, $proxy->port() ); + + if ( $proxy->use_authentication() ) { + curl_setopt( $handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY ); + curl_setopt( $handle, CURLOPT_PROXYUSERPWD, $proxy->authentication() ); + } + } + + $is_local = isset($r['local']) && $r['local']; + $ssl_verify = isset($r['sslverify']) && $r['sslverify']; + if ( $is_local ) { + /** This filter is documented in wp-includes/class-wp-http-streams.php */ + $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); + } elseif ( ! $is_local ) { + /** This filter is documented in wp-includes/class-wp-http-streams.php */ + $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); + } + + /* + * CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since. + * a value of 0 will allow an unlimited timeout. + */ + $timeout = (int) ceil( $r['timeout'] ); + curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout ); + curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout ); + + curl_setopt( $handle, CURLOPT_URL, $url); + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); + curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false ); + curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify ); + + if ( $ssl_verify ) { + curl_setopt( $handle, CURLOPT_CAINFO, $r['sslcertificates'] ); + } + + curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); + + /* + * The option doesn't work with safe mode or when open_basedir is set, and there's + * a bug #17490 with redirected POST requests, so handle redirections outside Curl. + */ + curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, false ); + if ( defined( 'CURLOPT_PROTOCOLS' ) ) // PHP 5.2.10 / cURL 7.19.4 + curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS ); + + switch ( $r['method'] ) { + case 'HEAD': + curl_setopt( $handle, CURLOPT_NOBODY, true ); + break; + case 'POST': + curl_setopt( $handle, CURLOPT_POST, true ); + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); + break; + case 'PUT': + curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, 'PUT' ); + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); + break; + default: + curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, $r['method'] ); + if ( ! is_null( $r['body'] ) ) + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); + break; + } + + if ( true === $r['blocking'] ) { + curl_setopt( $handle, CURLOPT_HEADERFUNCTION, array( $this, 'stream_headers' ) ); + curl_setopt( $handle, CURLOPT_WRITEFUNCTION, array( $this, 'stream_body' ) ); + } + + curl_setopt( $handle, CURLOPT_HEADER, false ); + + if ( isset( $r['limit_response_size'] ) ) + $this->max_body_length = intval( $r['limit_response_size'] ); + else + $this->max_body_length = false; + + // If streaming to a file open a file handle, and setup our curl streaming handler. + if ( $r['stream'] ) { + if ( ! WP_DEBUG ) + $this->stream_handle = @fopen( $r['filename'], 'w+' ); + else + $this->stream_handle = fopen( $r['filename'], 'w+' ); + if ( ! $this->stream_handle ) { + return new WP_Error( 'http_request_failed', sprintf( + /* translators: 1: fopen() 2: file name */ + __( 'Could not open handle for %1$s to %2$s.' ), + 'fopen()', + $r['filename'] + ) ); + } + } else { + $this->stream_handle = false; + } + + if ( !empty( $r['headers'] ) ) { + // cURL expects full header strings in each element. + $headers = array(); + foreach ( $r['headers'] as $name => $value ) { + $headers[] = "{$name}: $value"; + } + curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers ); + } + + if ( $r['httpversion'] == '1.0' ) + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 ); + else + curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); + + /** + * Fires before the cURL request is executed. + * + * Cookies are not currently handled by the HTTP API. This action allows + * plugins to handle cookies themselves. + * + * @since 2.8.0 + * + * @param resource $handle The cURL handle returned by curl_init() (passed by reference). + * @param array $r The HTTP request arguments. + * @param string $url The request URL. + */ + do_action_ref_array( 'http_api_curl', array( &$handle, $r, $url ) ); + + // We don't need to return the body, so don't. Just execute request and return. + if ( ! $r['blocking'] ) { + curl_exec( $handle ); + + if ( $curl_error = curl_error( $handle ) ) { + curl_close( $handle ); + return new WP_Error( 'http_request_failed', $curl_error ); + } + if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { + curl_close( $handle ); + return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); + } + + curl_close( $handle ); + return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); + } + + curl_exec( $handle ); + $theHeaders = WP_Http::processHeaders( $this->headers, $url ); + $theBody = $this->body; + $bytes_written_total = $this->bytes_written_total; + + $this->headers = ''; + $this->body = ''; + $this->bytes_written_total = 0; + + $curl_error = curl_errno( $handle ); + + // If an error occurred, or, no response. + if ( $curl_error || ( 0 == strlen( $theBody ) && empty( $theHeaders['headers'] ) ) ) { + if ( CURLE_WRITE_ERROR /* 23 */ == $curl_error ) { + if ( ! $this->max_body_length || $this->max_body_length != $bytes_written_total ) { + if ( $r['stream'] ) { + curl_close( $handle ); + fclose( $this->stream_handle ); + return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); + } else { + curl_close( $handle ); + return new WP_Error( 'http_request_failed', curl_error( $handle ) ); + } + } + } else { + if ( $curl_error = curl_error( $handle ) ) { + curl_close( $handle ); + return new WP_Error( 'http_request_failed', $curl_error ); + } + } + if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array( 301, 302 ) ) ) { + curl_close( $handle ); + return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) ); + } + } + + curl_close( $handle ); + + if ( $r['stream'] ) + fclose( $this->stream_handle ); + + $response = array( + 'headers' => $theHeaders['headers'], + 'body' => null, + 'response' => $theHeaders['response'], + 'cookies' => $theHeaders['cookies'], + 'filename' => $r['filename'] + ); + + // Handle redirects. + if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) ) + return $redirect_response; + + if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) + $theBody = WP_Http_Encoding::decompress( $theBody ); + + $response['body'] = $theBody; + + return $response; + } + + /** + * Grabs the headers of the cURL request. + * + * Each header is sent individually to this callback, so we append to the `$header` property + * for temporary storage + * + * @since 3.2.0 + * + * @param resource $handle cURL handle. + * @param string $headers cURL request headers. + * @return int Length of the request headers. + */ + private function stream_headers( $handle, $headers ) { + $this->headers .= $headers; + return strlen( $headers ); + } + + /** + * Grabs the body of the cURL request. + * + * The contents of the document are passed in chunks, so we append to the `$body` + * property for temporary storage. Returning a length shorter than the length of + * `$data` passed in will cause cURL to abort the request with `CURLE_WRITE_ERROR`. + * + * @since 3.6.0 + * + * @param resource $handle cURL handle. + * @param string $data cURL request body. + * @return int Total bytes of data written. + */ + private function stream_body( $handle, $data ) { + $data_length = strlen( $data ); + + if ( $this->max_body_length && ( $this->bytes_written_total + $data_length ) > $this->max_body_length ) { + $data_length = ( $this->max_body_length - $this->bytes_written_total ); + $data = substr( $data, 0, $data_length ); + } + + if ( $this->stream_handle ) { + $bytes_written = fwrite( $this->stream_handle, $data ); + } else { + $this->body .= $data; + $bytes_written = $data_length; + } + + $this->bytes_written_total += $bytes_written; + + // Upon event of this function returning less than strlen( $data ) curl will error with CURLE_WRITE_ERROR. + return $bytes_written; + } + + /** + * Determines whether this class can be used for retrieving a URL. + * + * @static + * @since 2.7.0 + * + * @param array $args Optional. Array of request arguments. Default empty array. + * @return bool False means this class can not be used, true means it can. + */ + public static function test( $args = array() ) { + if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) + return false; + + $is_ssl = isset( $args['ssl'] ) && $args['ssl']; + + if ( $is_ssl ) { + $curl_version = curl_version(); + // Check whether this cURL version support SSL requests. + if ( ! (CURL_VERSION_SSL & $curl_version['features']) ) + return false; + } + + /** + * Filters whether cURL can be used as a transport for retrieving a URL. + * + * @since 2.7.0 + * + * @param bool $use_class Whether the class can be used. Default true. + * @param array $args An array of request arguments. + */ + return apply_filters( 'use_curl_transport', true, $args ); + } +} diff --git a/backend/wp-includes/class-wp-http-encoding.php b/backend/wp-includes/class-wp-http-encoding.php new file mode 100644 index 0000000..81cfba8 --- /dev/null +++ b/backend/wp-includes/class-wp-http-encoding.php @@ -0,0 +1,228 @@ +<?php +/** + * HTTP API: WP_Http_Encoding class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to implement deflate and gzip transfer encoding support for HTTP requests. + * + * Includes RFC 1950, RFC 1951, and RFC 1952. + * + * @since 2.8.0 + */ +class WP_Http_Encoding { + + /** + * Compress raw string using the deflate format. + * + * Supports the RFC 1951 standard. + * + * @since 2.8.0 + * + * @static + * + * @param string $raw String to compress. + * @param int $level Optional, default is 9. Compression level, 9 is highest. + * @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports. + * @return string|false False on failure. + */ + public static function compress( $raw, $level = 9, $supports = null ) { + return gzdeflate( $raw, $level ); + } + + /** + * Decompression of deflated string. + * + * Will attempt to decompress using the RFC 1950 standard, and if that fails + * then the RFC 1951 standard deflate will be attempted. Finally, the RFC + * 1952 standard gzip decode will be attempted. If all fail, then the + * original compressed string will be returned. + * + * @since 2.8.0 + * + * @static + * + * @param string $compressed String to decompress. + * @param int $length The optional length of the compressed data. + * @return string|bool False on failure. + */ + public static function decompress( $compressed, $length = null ) { + + if ( empty($compressed) ) + return $compressed; + + if ( false !== ( $decompressed = @gzinflate( $compressed ) ) ) + return $decompressed; + + if ( false !== ( $decompressed = self::compatible_gzinflate( $compressed ) ) ) + return $decompressed; + + if ( false !== ( $decompressed = @gzuncompress( $compressed ) ) ) + return $decompressed; + + if ( function_exists('gzdecode') ) { + $decompressed = @gzdecode( $compressed ); + + if ( false !== $decompressed ) + return $decompressed; + } + + return $compressed; + } + + /** + * Decompression of deflated string while staying compatible with the majority of servers. + * + * Certain Servers will return deflated data with headers which PHP's gzinflate() + * function cannot handle out of the box. The following function has been created from + * various snippets on the gzinflate() PHP documentation. + * + * Warning: Magic numbers within. Due to the potential different formats that the compressed + * data may be returned in, some "magic offsets" are needed to ensure proper decompression + * takes place. For a simple progmatic way to determine the magic offset in use, see: + * https://core.trac.wordpress.org/ticket/18273 + * + * @since 2.8.1 + * @link https://core.trac.wordpress.org/ticket/18273 + * @link https://secure.php.net/manual/en/function.gzinflate.php#70875 + * @link https://secure.php.net/manual/en/function.gzinflate.php#77336 + * + * @static + * + * @param string $gzData String to decompress. + * @return string|bool False on failure. + */ + public static function compatible_gzinflate($gzData) { + + // Compressed data might contain a full header, if so strip it for gzinflate(). + if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) { + $i = 10; + $flg = ord( substr($gzData, 3, 1) ); + if ( $flg > 0 ) { + if ( $flg & 4 ) { + list($xlen) = unpack('v', substr($gzData, $i, 2) ); + $i = $i + 2 + $xlen; + } + if ( $flg & 8 ) + $i = strpos($gzData, "\0", $i) + 1; + if ( $flg & 16 ) + $i = strpos($gzData, "\0", $i) + 1; + if ( $flg & 2 ) + $i = $i + 2; + } + $decompressed = @gzinflate( substr($gzData, $i, -8) ); + if ( false !== $decompressed ) + return $decompressed; + } + + // Compressed data from java.util.zip.Deflater amongst others. + $decompressed = @gzinflate( substr($gzData, 2) ); + if ( false !== $decompressed ) + return $decompressed; + + return false; + } + + /** + * What encoding types to accept and their priority values. + * + * @since 2.8.0 + * + * @static + * + * @param string $url + * @param array $args + * @return string Types of encoding to accept. + */ + public static function accept_encoding( $url, $args ) { + $type = array(); + $compression_enabled = self::is_available(); + + if ( ! $args['decompress'] ) // Decompression specifically disabled. + $compression_enabled = false; + elseif ( $args['stream'] ) // Disable when streaming to file. + $compression_enabled = false; + elseif ( isset( $args['limit_response_size'] ) ) // If only partial content is being requested, we won't be able to decompress it. + $compression_enabled = false; + + if ( $compression_enabled ) { + if ( function_exists( 'gzinflate' ) ) + $type[] = 'deflate;q=1.0'; + + if ( function_exists( 'gzuncompress' ) ) + $type[] = 'compress;q=0.5'; + + if ( function_exists( 'gzdecode' ) ) + $type[] = 'gzip;q=0.5'; + } + + /** + * Filters the allowed encoding types. + * + * @since 3.6.0 + * + * @param array $type Encoding types allowed. Accepts 'gzinflate', + * 'gzuncompress', 'gzdecode'. + * @param string $url URL of the HTTP request. + * @param array $args HTTP request arguments. + */ + $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args ); + + return implode(', ', $type); + } + + /** + * What encoding the content used when it was compressed to send in the headers. + * + * @since 2.8.0 + * + * @static + * + * @return string Content-Encoding string to send in the header. + */ + public static function content_encoding() { + return 'deflate'; + } + + /** + * Whether the content be decoded based on the headers. + * + * @since 2.8.0 + * + * @static + * + * @param array|string $headers All of the available headers. + * @return bool + */ + public static function should_decode($headers) { + if ( is_array( $headers ) ) { + if ( array_key_exists('content-encoding', $headers) && ! empty( $headers['content-encoding'] ) ) + return true; + } elseif ( is_string( $headers ) ) { + return ( stripos($headers, 'content-encoding:') !== false ); + } + + return false; + } + + /** + * Whether decompression and compression are supported by the PHP version. + * + * Each function is tested instead of checking for the zlib extension, to + * ensure that the functions all exist in the PHP version and aren't + * disabled. + * + * @since 2.8.0 + * + * @static + * + * @return bool + */ + public static function is_available() { + return ( function_exists('gzuncompress') || function_exists('gzdeflate') || function_exists('gzinflate') ); + } +} diff --git a/backend/wp-includes/class-wp-http-ixr-client.php b/backend/wp-includes/class-wp-http-ixr-client.php new file mode 100644 index 0000000..e4ed550 --- /dev/null +++ b/backend/wp-includes/class-wp-http-ixr-client.php @@ -0,0 +1,124 @@ +<?php +/** + * WP_HTTP_IXR_Client + * + * @package WordPress + * @since 3.1.0 + * + */ +class WP_HTTP_IXR_Client extends IXR_Client { + public $scheme; + /** + * @var IXR_Error + */ + public $error; + + /** + * @param string $server + * @param string|bool $path + * @param int|bool $port + * @param int $timeout + */ + public function __construct($server, $path = false, $port = false, $timeout = 15) { + if ( ! $path ) { + // Assume we have been given a URL instead + $bits = parse_url($server); + $this->scheme = $bits['scheme']; + $this->server = $bits['host']; + $this->port = isset($bits['port']) ? $bits['port'] : $port; + $this->path = !empty($bits['path']) ? $bits['path'] : '/'; + + // Make absolutely sure we have a path + if ( ! $this->path ) { + $this->path = '/'; + } + + if ( ! empty( $bits['query'] ) ) { + $this->path .= '?' . $bits['query']; + } + } else { + $this->scheme = 'http'; + $this->server = $server; + $this->path = $path; + $this->port = $port; + } + $this->useragent = 'The Incutio XML-RPC PHP Library'; + $this->timeout = $timeout; + } + + /** + * @return bool + */ + public function query() { + $args = func_get_args(); + $method = array_shift($args); + $request = new IXR_Request($method, $args); + $xml = $request->getXml(); + + $port = $this->port ? ":$this->port" : ''; + $url = $this->scheme . '://' . $this->server . $port . $this->path; + $args = array( + 'headers' => array('Content-Type' => 'text/xml'), + 'user-agent' => $this->useragent, + 'body' => $xml, + ); + + // Merge Custom headers ala #8145 + foreach ( $this->headers as $header => $value ) { + $args['headers'][$header] = $value; + } + + /** + * Filters the headers collection to be sent to the XML-RPC server. + * + * @since 4.4.0 + * + * @param array $headers Array of headers to be sent. + */ + $args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] ); + + if ( $this->timeout !== false ) { + $args['timeout'] = $this->timeout; + } + + // Now send the request + if ( $this->debug ) { + echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n"; + } + + $response = wp_remote_post($url, $args); + + if ( is_wp_error($response) ) { + $errno = $response->get_error_code(); + $errorstr = $response->get_error_message(); + $this->error = new IXR_Error(-32300, "transport error: $errno $errorstr"); + return false; + } + + if ( 200 != wp_remote_retrieve_response_code( $response ) ) { + $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')'); + return false; + } + + if ( $this->debug ) { + echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n"; + } + + // Now parse what we've got back + $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) ); + if ( ! $this->message->parse() ) { + // XML error + $this->error = new IXR_Error(-32700, 'parse error. not well formed'); + return false; + } + + // Is the message a fault? + if ( $this->message->messageType == 'fault' ) { + $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString); + return false; + } + + // Message must be OK + return true; + } +} diff --git a/backend/wp-includes/class-wp-http-proxy.php b/backend/wp-includes/class-wp-http-proxy.php new file mode 100644 index 0000000..7ae3d4e --- /dev/null +++ b/backend/wp-includes/class-wp-http-proxy.php @@ -0,0 +1,219 @@ +<?php +/** + * HTTP API: WP_HTTP_Proxy class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to implement HTTP API proxy support. + * + * There are caveats to proxy support. It requires that defines be made in the wp-config.php file to + * enable proxy support. There are also a few filters that plugins can hook into for some of the + * constants. + * + * Please note that only BASIC authentication is supported by most transports. + * cURL MAY support more methods (such as NTLM authentication) depending on your environment. + * + * The constants are as follows: + * <ol> + * <li>WP_PROXY_HOST - Enable proxy support and host for connecting.</li> + * <li>WP_PROXY_PORT - Proxy port for connection. No default, must be defined.</li> + * <li>WP_PROXY_USERNAME - Proxy username, if it requires authentication.</li> + * <li>WP_PROXY_PASSWORD - Proxy password, if it requires authentication.</li> + * <li>WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy. + * You do not need to have localhost and the site host in this list, because they will not be passed + * through the proxy. The list should be presented in a comma separated list, wildcards using * are supported, eg. *.wordpress.org</li> + * </ol> + * + * An example can be as seen below. + * + * define('WP_PROXY_HOST', '192.168.84.101'); + * define('WP_PROXY_PORT', '8080'); + * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com, *.wordpress.org'); + * + * @link https://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress. + * @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS + * + * @since 2.8.0 + */ +class WP_HTTP_Proxy { + + /** + * Whether proxy connection should be used. + * + * @since 2.8.0 + * + * @use WP_PROXY_HOST + * @use WP_PROXY_PORT + * + * @return bool + */ + public function is_enabled() { + return defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT'); + } + + /** + * Whether authentication should be used. + * + * @since 2.8.0 + * + * @use WP_PROXY_USERNAME + * @use WP_PROXY_PASSWORD + * + * @return bool + */ + public function use_authentication() { + return defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD'); + } + + /** + * Retrieve the host for the proxy server. + * + * @since 2.8.0 + * + * @return string + */ + public function host() { + if ( defined('WP_PROXY_HOST') ) + return WP_PROXY_HOST; + + return ''; + } + + /** + * Retrieve the port for the proxy server. + * + * @since 2.8.0 + * + * @return string + */ + public function port() { + if ( defined('WP_PROXY_PORT') ) + return WP_PROXY_PORT; + + return ''; + } + + /** + * Retrieve the username for proxy authentication. + * + * @since 2.8.0 + * + * @return string + */ + public function username() { + if ( defined('WP_PROXY_USERNAME') ) + return WP_PROXY_USERNAME; + + return ''; + } + + /** + * Retrieve the password for proxy authentication. + * + * @since 2.8.0 + * + * @return string + */ + public function password() { + if ( defined('WP_PROXY_PASSWORD') ) + return WP_PROXY_PASSWORD; + + return ''; + } + + /** + * Retrieve authentication string for proxy authentication. + * + * @since 2.8.0 + * + * @return string + */ + public function authentication() { + return $this->username() . ':' . $this->password(); + } + + /** + * Retrieve header string for proxy authentication. + * + * @since 2.8.0 + * + * @return string + */ + public function authentication_header() { + return 'Proxy-Authorization: Basic ' . base64_encode( $this->authentication() ); + } + + /** + * Whether URL should be sent through the proxy server. + * + * We want to keep localhost and the site URL from being sent through the proxy server, because + * some proxies can not handle this. We also have the constant available for defining other + * hosts that won't be sent through the proxy. + * + * @since 2.8.0 + * + * @staticvar array|null $bypass_hosts + * @staticvar array $wildcard_regex + * + * @param string $uri URI to check. + * @return bool True, to send through the proxy and false if, the proxy should not be used. + */ + public function send_through_proxy( $uri ) { + /* + * parse_url() only handles http, https type URLs, and will emit E_WARNING on failure. + * This will be displayed on sites, which is not reasonable. + */ + $check = @parse_url($uri); + + // Malformed URL, can not process, but this could mean ssl, so let through anyway. + if ( $check === false ) + return true; + + $home = parse_url( get_option('siteurl') ); + + /** + * Filters whether to preempt sending the request through the proxy server. + * + * Returning false will bypass the proxy; returning true will send + * the request through the proxy. Returning null bypasses the filter. + * + * @since 3.5.0 + * + * @param null $override Whether to override the request result. Default null. + * @param string $uri URL to check. + * @param array $check Associative array result of parsing the URI. + * @param array $home Associative array result of parsing the site URL. + */ + $result = apply_filters( 'pre_http_send_through_proxy', null, $uri, $check, $home ); + if ( ! is_null( $result ) ) + return $result; + + if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) + return false; + + if ( !defined('WP_PROXY_BYPASS_HOSTS') ) + return true; + + static $bypass_hosts = null; + static $wildcard_regex = array(); + if ( null === $bypass_hosts ) { + $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); + + if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { + $wildcard_regex = array(); + foreach ( $bypass_hosts as $host ) + $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) ); + $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; + } + } + + if ( !empty($wildcard_regex) ) + return !preg_match($wildcard_regex, $check['host']); + else + return !in_array( $check['host'], $bypass_hosts ); + } +} diff --git a/backend/wp-includes/class-wp-http-requests-hooks.php b/backend/wp-includes/class-wp-http-requests-hooks.php new file mode 100644 index 0000000..0e46fa3 --- /dev/null +++ b/backend/wp-includes/class-wp-http-requests-hooks.php @@ -0,0 +1,76 @@ +<?php +/** + * HTTP API: Requests hook bridge class + * + * @package WordPress + * @subpackage HTTP + * @since 4.7.0 + */ + +/** + * Bridge to connect Requests internal hooks to WordPress actions. + * + * @since 4.7.0 + * + * @see Requests_Hooks + */ +class WP_HTTP_Requests_Hooks extends Requests_Hooks { + /** + * Requested URL. + * + * @var string Requested URL. + */ + protected $url; + + /** + * WordPress WP_HTTP request data. + * + * @var array Request data in WP_Http format. + */ + protected $request = array(); + + /** + * Constructor. + * + * @param string $url URL to request. + * @param array $request Request data in WP_Http format. + */ + public function __construct( $url, $request ) { + $this->url = $url; + $this->request = $request; + } + + /** + * Dispatch a Requests hook to a native WordPress action. + * + * @param string $hook Hook name. + * @param array $parameters Parameters to pass to callbacks. + * @return boolean True if hooks were run, false if nothing was hooked. + */ + public function dispatch( $hook, $parameters = array() ) { + $result = parent::dispatch( $hook, $parameters ); + + // Handle back-compat actions + switch ( $hook ) { + case 'curl.before_send': + /** This action is documented in wp-includes/class-wp-http-curl.php */ + do_action_ref_array( 'http_api_curl', array( &$parameters[0], $this->request, $this->url ) ); + break; + } + + /** + * Transforms a native Request hook to a WordPress actions. + * + * This action maps Requests internal hook to a native WordPress action. + * + * @see https://github.com/rmccue/Requests/blob/master/docs/hooks.md + * + * @param array $parameters Parameters from Requests internal hook. + * @param array $request Request data in WP_Http format. + * @param string $url URL to request. + */ + do_action_ref_array( "requests-{$hook}", $parameters, $this->request, $this->url ); + + return $result; + } +} diff --git a/backend/wp-includes/class-wp-http-requests-response.php b/backend/wp-includes/class-wp-http-requests-response.php new file mode 100644 index 0000000..630882f --- /dev/null +++ b/backend/wp-includes/class-wp-http-requests-response.php @@ -0,0 +1,196 @@ +<?php +/** + * HTTP API: WP_HTTP_Requests_Response class + * + * @package WordPress + * @subpackage HTTP + * @since 4.6.0 + */ + +/** + * Core wrapper object for a Requests_Response for standardisation. + * + * @since 4.6.0 + * + * @see WP_HTTP_Response + */ +class WP_HTTP_Requests_Response extends WP_HTTP_Response { + /** + * Requests Response object. + * + * @since 4.6.0 + * @var Requests_Response + */ + protected $response; + + /** + * Filename the response was saved to. + * + * @since 4.6.0 + * @var string|null + */ + protected $filename; + + /** + * Constructor. + * + * @since 4.6.0 + * + * @param Requests_Response $response HTTP response. + * @param string $filename Optional. File name. Default empty. + */ + public function __construct( Requests_Response $response, $filename = '' ) { + $this->response = $response; + $this->filename = $filename; + } + + /** + * Retrieves the response object for the request. + * + * @since 4.6.0 + * + * @return Requests_Response HTTP response. + */ + public function get_response_object() { + return $this->response; + } + + /** + * Retrieves headers associated with the response. + * + * @since 4.6.0 + * + * @see \Requests_Utility_CaseInsensitiveDictionary + * + * @return \Requests_Utility_CaseInsensitiveDictionary Map of header name to header value. + */ + public function get_headers() { + // Ensure headers remain case-insensitive. + $converted = new Requests_Utility_CaseInsensitiveDictionary(); + + foreach ( $this->response->headers->getAll() as $key => $value ) { + if ( count( $value ) === 1 ) { + $converted[ $key ] = $value[0]; + } else { + $converted[ $key ] = $value; + } + } + + return $converted; + } + + /** + * Sets all header values. + * + * @since 4.6.0 + * + * @param array $headers Map of header name to header value. + */ + public function set_headers( $headers ) { + $this->response->headers = new Requests_Response_Headers( $headers ); + } + + /** + * Sets a single HTTP header. + * + * @since 4.6.0 + * + * @param string $key Header name. + * @param string $value Header value. + * @param bool $replace Optional. Whether to replace an existing header of the same name. + * Default true. + */ + public function header( $key, $value, $replace = true ) { + if ( $replace ) { + unset( $this->response->headers[ $key ] ); + } + + $this->response->headers[ $key ] = $value; + } + + /** + * Retrieves the HTTP return code for the response. + * + * @since 4.6.0 + * + * @return int The 3-digit HTTP status code. + */ + public function get_status() { + return $this->response->status_code; + } + + /** + * Sets the 3-digit HTTP status code. + * + * @since 4.6.0 + * + * @param int $code HTTP status. + */ + public function set_status( $code ) { + $this->response->status_code = absint( $code ); + } + + /** + * Retrieves the response data. + * + * @since 4.6.0 + * + * @return mixed Response data. + */ + public function get_data() { + return $this->response->body; + } + + /** + * Sets the response data. + * + * @since 4.6.0 + * + * @param mixed $data Response data. + */ + public function set_data( $data ) { + $this->response->body = $data; + } + + /** + * Retrieves cookies from the response. + * + * @since 4.6.0 + * + * @return WP_HTTP_Cookie[] List of cookie objects. + */ + public function get_cookies() { + $cookies = array(); + foreach ( $this->response->cookies as $cookie ) { + $cookies[] = new WP_Http_Cookie( array( + 'name' => $cookie->name, + 'value' => urldecode( $cookie->value ), + 'expires' => isset( $cookie->attributes['expires'] ) ? $cookie->attributes['expires'] : null, + 'path' => isset( $cookie->attributes['path'] ) ? $cookie->attributes['path'] : null, + 'domain' => isset( $cookie->attributes['domain'] ) ? $cookie->attributes['domain'] : null, + )); + } + + return $cookies; + } + + /** + * Converts the object to a WP_Http response array. + * + * @since 4.6.0 + * + * @return array WP_Http response array, per WP_Http::request(). + */ + public function to_array() { + return array( + 'headers' => $this->get_headers(), + 'body' => $this->get_data(), + 'response' => array( + 'code' => $this->get_status(), + 'message' => get_status_header_desc( $this->get_status() ), + ), + 'cookies' => $this->get_cookies(), + 'filename' => $this->filename, + ); + } +} diff --git a/backend/wp-includes/class-wp-http-response.php b/backend/wp-includes/class-wp-http-response.php new file mode 100644 index 0000000..4bf95c3 --- /dev/null +++ b/backend/wp-includes/class-wp-http-response.php @@ -0,0 +1,153 @@ +<?php +/** + * HTTP API: WP_HTTP_Response class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to prepare HTTP responses. + * + * @since 4.4.0 + */ +class WP_HTTP_Response { + + /** + * Response data. + * + * @since 4.4.0 + * @var mixed + */ + public $data; + + /** + * Response headers. + * + * @since 4.4.0 + * @var array + */ + public $headers; + + /** + * Response status. + * + * @since 4.4.0 + * @var int + */ + public $status; + + /** + * Constructor. + * + * @since 4.4.0 + * + * @param mixed $data Response data. Default null. + * @param int $status Optional. HTTP status code. Default 200. + * @param array $headers Optional. HTTP header map. Default empty array. + */ + public function __construct( $data = null, $status = 200, $headers = array() ) { + $this->set_data( $data ); + $this->set_status( $status ); + $this->set_headers( $headers ); + } + + /** + * Retrieves headers associated with the response. + * + * @since 4.4.0 + * + * @return array Map of header name to header value. + */ + public function get_headers() { + return $this->headers; + } + + /** + * Sets all header values. + * + * @since 4.4.0 + * + * @param array $headers Map of header name to header value. + */ + public function set_headers( $headers ) { + $this->headers = $headers; + } + + /** + * Sets a single HTTP header. + * + * @since 4.4.0 + * + * @param string $key Header name. + * @param string $value Header value. + * @param bool $replace Optional. Whether to replace an existing header of the same name. + * Default true. + */ + public function header( $key, $value, $replace = true ) { + if ( $replace || ! isset( $this->headers[ $key ] ) ) { + $this->headers[ $key ] = $value; + } else { + $this->headers[ $key ] .= ', ' . $value; + } + } + + /** + * Retrieves the HTTP return code for the response. + * + * @since 4.4.0 + * + * @return int The 3-digit HTTP status code. + */ + public function get_status() { + return $this->status; + } + + /** + * Sets the 3-digit HTTP status code. + * + * @since 4.4.0 + * + * @param int $code HTTP status. + */ + public function set_status( $code ) { + $this->status = absint( $code ); + } + + /** + * Retrieves the response data. + * + * @since 4.4.0 + * + * @return mixed Response data. + */ + public function get_data() { + return $this->data; + } + + /** + * Sets the response data. + * + * @since 4.4.0 + * + * @param mixed $data Response data. + */ + public function set_data( $data ) { + $this->data = $data; + } + + /** + * Retrieves the response data for JSON serialization. + * + * It is expected that in most implementations, this will return the same as get_data(), + * however this may be different if you want to do custom JSON data handling. + * + * @since 4.4.0 + * + * @return mixed Any JSON-serializable value. + */ + public function jsonSerialize() { + return $this->get_data(); + } +} diff --git a/backend/wp-includes/class-wp-http-streams.php b/backend/wp-includes/class-wp-http-streams.php new file mode 100644 index 0000000..325c509 --- /dev/null +++ b/backend/wp-includes/class-wp-http-streams.php @@ -0,0 +1,432 @@ +<?php +/** + * HTTP API: WP_Http_Streams class + * + * @package WordPress + * @subpackage HTTP + * @since 4.4.0 + */ + +/** + * Core class used to integrate PHP Streams as an HTTP transport. + * + * @since 2.7.0 + * @since 3.7.0 Combined with the fsockopen transport and switched to `stream_socket_client()`. + */ +class WP_Http_Streams { + /** + * Send a HTTP request to a URI using PHP Streams. + * + * @see WP_Http::request For default options descriptions. + * + * @since 2.7.0 + * @since 3.7.0 Combined with the fsockopen transport and switched to stream_socket_client(). + * + * @param string $url The request URL. + * @param string|array $args Optional. Override the defaults. + * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + */ + public function request($url, $args = array()) { + $defaults = array( + 'method' => 'GET', 'timeout' => 5, + 'redirection' => 5, 'httpversion' => '1.0', + 'blocking' => true, + 'headers' => array(), 'body' => null, 'cookies' => array() + ); + + $r = wp_parse_args( $args, $defaults ); + + if ( isset( $r['headers']['User-Agent'] ) ) { + $r['user-agent'] = $r['headers']['User-Agent']; + unset( $r['headers']['User-Agent'] ); + } elseif ( isset( $r['headers']['user-agent'] ) ) { + $r['user-agent'] = $r['headers']['user-agent']; + unset( $r['headers']['user-agent'] ); + } + + // Construct Cookie: header if any cookies are set. + WP_Http::buildCookieHeader( $r ); + + $arrURL = parse_url($url); + + $connect_host = $arrURL['host']; + + $secure_transport = ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ); + if ( ! isset( $arrURL['port'] ) ) { + if ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ) { + $arrURL['port'] = 443; + $secure_transport = true; + } else { + $arrURL['port'] = 80; + } + } + + // Always pass a Path, defaulting to the root in cases such as http://example.com + if ( ! isset( $arrURL['path'] ) ) { + $arrURL['path'] = '/'; + } + + if ( isset( $r['headers']['Host'] ) || isset( $r['headers']['host'] ) ) { + if ( isset( $r['headers']['Host'] ) ) + $arrURL['host'] = $r['headers']['Host']; + else + $arrURL['host'] = $r['headers']['host']; + unset( $r['headers']['Host'], $r['headers']['host'] ); + } + + /* + * Certain versions of PHP have issues with 'localhost' and IPv6, It attempts to connect + * to ::1, which fails when the server is not set up for it. For compatibility, always + * connect to the IPv4 address. + */ + if ( 'localhost' == strtolower( $connect_host ) ) + $connect_host = '127.0.0.1'; + + $connect_host = $secure_transport ? 'ssl://' . $connect_host : 'tcp://' . $connect_host; + + $is_local = isset( $r['local'] ) && $r['local']; + $ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; + if ( $is_local ) { + /** + * Filters whether SSL should be verified for local requests. + * + * @since 2.8.0 + * + * @param bool $ssl_verify Whether to verify the SSL connection. Default true. + */ + $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); + } elseif ( ! $is_local ) { + /** + * Filters whether SSL should be verified for non-local requests. + * + * @since 2.8.0 + * + * @param bool $ssl_verify Whether to verify the SSL connection. Default true. + */ + $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); + } + + $proxy = new WP_HTTP_Proxy(); + + $context = stream_context_create( array( + 'ssl' => array( + 'verify_peer' => $ssl_verify, + //'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate() + 'capture_peer_cert' => $ssl_verify, + 'SNI_enabled' => true, + 'cafile' => $r['sslcertificates'], + 'allow_self_signed' => ! $ssl_verify, + ) + ) ); + + $timeout = (int) floor( $r['timeout'] ); + $utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000; + $connect_timeout = max( $timeout, 1 ); + + // Store error number. + $connection_error = null; + + // Store error string. + $connection_error_str = null; + + if ( !WP_DEBUG ) { + // In the event that the SSL connection fails, silence the many PHP Warnings. + if ( $secure_transport ) + $error_reporting = error_reporting(0); + + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) + $handle = @stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); + else + $handle = @stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); + + if ( $secure_transport ) + error_reporting( $error_reporting ); + + } else { + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) + $handle = stream_socket_client( 'tcp://' . $proxy->host() . ':' . $proxy->port(), $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); + else + $handle = stream_socket_client( $connect_host . ':' . $arrURL['port'], $connection_error, $connection_error_str, $connect_timeout, STREAM_CLIENT_CONNECT, $context ); + } + + if ( false === $handle ) { + // SSL connection failed due to expired/invalid cert, or, OpenSSL configuration is broken. + if ( $secure_transport && 0 === $connection_error && '' === $connection_error_str ) + return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); + + return new WP_Error('http_request_failed', $connection_error . ': ' . $connection_error_str ); + } + + // Verify that the SSL certificate is valid for this request. + if ( $secure_transport && $ssl_verify && ! $proxy->is_enabled() ) { + if ( ! self::verify_ssl_certificate( $handle, $arrURL['host'] ) ) + return new WP_Error( 'http_request_failed', __( 'The SSL certificate for the host could not be verified.' ) ); + } + + stream_set_timeout( $handle, $timeout, $utimeout ); + + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field. + $requestPath = $url; + else + $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); + + $strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n"; + + $include_port_in_host_header = ( + ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) || + ( 'http' == $arrURL['scheme'] && 80 != $arrURL['port'] ) || + ( 'https' == $arrURL['scheme'] && 443 != $arrURL['port'] ) + ); + + if ( $include_port_in_host_header ) { + $strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n"; + } else { + $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n"; + } + + if ( isset($r['user-agent']) ) + $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n"; + + if ( is_array($r['headers']) ) { + foreach ( (array) $r['headers'] as $header => $headerValue ) + $strHeaders .= $header . ': ' . $headerValue . "\r\n"; + } else { + $strHeaders .= $r['headers']; + } + + if ( $proxy->use_authentication() ) + $strHeaders .= $proxy->authentication_header() . "\r\n"; + + $strHeaders .= "\r\n"; + + if ( ! is_null($r['body']) ) + $strHeaders .= $r['body']; + + fwrite($handle, $strHeaders); + + if ( ! $r['blocking'] ) { + stream_set_blocking( $handle, 0 ); + fclose( $handle ); + return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); + } + + $strResponse = ''; + $bodyStarted = false; + $keep_reading = true; + $block_size = 4096; + if ( isset( $r['limit_response_size'] ) ) + $block_size = min( $block_size, $r['limit_response_size'] ); + + // If streaming to a file setup the file handle. + if ( $r['stream'] ) { + if ( ! WP_DEBUG ) + $stream_handle = @fopen( $r['filename'], 'w+' ); + else + $stream_handle = fopen( $r['filename'], 'w+' ); + if ( ! $stream_handle ) { + return new WP_Error( 'http_request_failed', sprintf( + /* translators: 1: fopen() 2: file name */ + __( 'Could not open handle for %1$s to %2$s.' ), + 'fopen()', + $r['filename'] + ) ); + } + + $bytes_written = 0; + while ( ! feof($handle) && $keep_reading ) { + $block = fread( $handle, $block_size ); + if ( ! $bodyStarted ) { + $strResponse .= $block; + if ( strpos( $strResponse, "\r\n\r\n" ) ) { + $process = WP_Http::processResponse( $strResponse ); + $bodyStarted = true; + $block = $process['body']; + unset( $strResponse ); + $process['body'] = ''; + } + } + + $this_block_size = strlen( $block ); + + if ( isset( $r['limit_response_size'] ) && ( $bytes_written + $this_block_size ) > $r['limit_response_size'] ) { + $this_block_size = ( $r['limit_response_size'] - $bytes_written ); + $block = substr( $block, 0, $this_block_size ); + } + + $bytes_written_to_file = fwrite( $stream_handle, $block ); + + if ( $bytes_written_to_file != $this_block_size ) { + fclose( $handle ); + fclose( $stream_handle ); + return new WP_Error( 'http_request_failed', __( 'Failed to write request to temporary file.' ) ); + } + + $bytes_written += $bytes_written_to_file; + + $keep_reading = !isset( $r['limit_response_size'] ) || $bytes_written < $r['limit_response_size']; + } + + fclose( $stream_handle ); + + } else { + $header_length = 0; + while ( ! feof( $handle ) && $keep_reading ) { + $block = fread( $handle, $block_size ); + $strResponse .= $block; + if ( ! $bodyStarted && strpos( $strResponse, "\r\n\r\n" ) ) { + $header_length = strpos( $strResponse, "\r\n\r\n" ) + 4; + $bodyStarted = true; + } + $keep_reading = ( ! $bodyStarted || !isset( $r['limit_response_size'] ) || strlen( $strResponse ) < ( $header_length + $r['limit_response_size'] ) ); + } + + $process = WP_Http::processResponse( $strResponse ); + unset( $strResponse ); + + } + + fclose( $handle ); + + $arrHeaders = WP_Http::processHeaders( $process['headers'], $url ); + + $response = array( + 'headers' => $arrHeaders['headers'], + // Not yet processed. + 'body' => null, + 'response' => $arrHeaders['response'], + 'cookies' => $arrHeaders['cookies'], + 'filename' => $r['filename'] + ); + + // Handle redirects. + if ( false !== ( $redirect_response = WP_Http::handle_redirects( $url, $r, $response ) ) ) + return $redirect_response; + + // If the body was chunk encoded, then decode it. + if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] ) + $process['body'] = WP_Http::chunkTransferDecode($process['body']); + + if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) ) + $process['body'] = WP_Http_Encoding::decompress( $process['body'] ); + + if ( isset( $r['limit_response_size'] ) && strlen( $process['body'] ) > $r['limit_response_size'] ) + $process['body'] = substr( $process['body'], 0, $r['limit_response_size'] ); + + $response['body'] = $process['body']; + + return $response; + } + + /** + * Verifies the received SSL certificate against its Common Names and subjectAltName fields. + * + * PHP's SSL verifications only verify that it's a valid Certificate, it doesn't verify if + * the certificate is valid for the hostname which was requested. + * This function verifies the requested hostname against certificate's subjectAltName field, + * if that is empty, or contains no DNS entries, a fallback to the Common Name field is used. + * + * IP Address support is included if the request is being made to an IP address. + * + * @since 3.7.0 + * @static + * + * @param stream $stream The PHP Stream which the SSL request is being made over + * @param string $host The hostname being requested + * @return bool If the cerficiate presented in $stream is valid for $host + */ + public static function verify_ssl_certificate( $stream, $host ) { + $context_options = stream_context_get_options( $stream ); + + if ( empty( $context_options['ssl']['peer_certificate'] ) ) + return false; + + $cert = openssl_x509_parse( $context_options['ssl']['peer_certificate'] ); + if ( ! $cert ) + return false; + + /* + * If the request is being made to an IP address, we'll validate against IP fields + * in the cert (if they exist) + */ + $host_type = ( WP_Http::is_ip_address( $host ) ? 'ip' : 'dns' ); + + $certificate_hostnames = array(); + if ( ! empty( $cert['extensions']['subjectAltName'] ) ) { + $match_against = preg_split( '/,\s*/', $cert['extensions']['subjectAltName'] ); + foreach ( $match_against as $match ) { + list( $match_type, $match_host ) = explode( ':', $match ); + if ( $host_type == strtolower( trim( $match_type ) ) ) // IP: or DNS: + $certificate_hostnames[] = strtolower( trim( $match_host ) ); + } + } elseif ( !empty( $cert['subject']['CN'] ) ) { + // Only use the CN when the certificate includes no subjectAltName extension. + $certificate_hostnames[] = strtolower( $cert['subject']['CN'] ); + } + + // Exact hostname/IP matches. + if ( in_array( strtolower( $host ), $certificate_hostnames ) ) + return true; + + // IP's can't be wildcards, Stop processing. + if ( 'ip' == $host_type ) + return false; + + // Test to see if the domain is at least 2 deep for wildcard support. + if ( substr_count( $host, '.' ) < 2 ) + return false; + + // Wildcard subdomains certs (*.example.com) are valid for a.example.com but not a.b.example.com. + $wildcard_host = preg_replace( '/^[^.]+\./', '*.', $host ); + + return in_array( strtolower( $wildcard_host ), $certificate_hostnames ); + } + + /** + * Determines whether this class can be used for retrieving a URL. + * + * @static + * @since 2.7.0 + * @since 3.7.0 Combined with the fsockopen transport and switched to stream_socket_client(). + * + * @param array $args Optional. Array of request arguments. Default empty array. + * @return bool False means this class can not be used, true means it can. + */ + public static function test( $args = array() ) { + if ( ! function_exists( 'stream_socket_client' ) ) + return false; + + $is_ssl = isset( $args['ssl'] ) && $args['ssl']; + + if ( $is_ssl ) { + if ( ! extension_loaded( 'openssl' ) ) + return false; + if ( ! function_exists( 'openssl_x509_parse' ) ) + return false; + } + + /** + * Filters whether streams can be used as a transport for retrieving a URL. + * + * @since 2.7.0 + * + * @param bool $use_class Whether the class can be used. Default true. + * @param array $args Request arguments. + */ + return apply_filters( 'use_streams_transport', true, $args ); + } +} + +/** + * Deprecated HTTP Transport method which used fsockopen. + * + * This class is not used, and is included for backward compatibility only. + * All code should make use of WP_Http directly through its API. + * + * @see WP_HTTP::request + * + * @since 2.7.0 + * @deprecated 3.7.0 Please use WP_HTTP::request() directly + */ +class WP_HTTP_Fsockopen extends WP_HTTP_Streams { + // For backward compatibility for users who are using the class directly. +} diff --git a/backend/wp-includes/class-wp-image-editor-gd.php b/backend/wp-includes/class-wp-image-editor-gd.php new file mode 100644 index 0000000..c5050b2 --- /dev/null +++ b/backend/wp-includes/class-wp-image-editor-gd.php @@ -0,0 +1,467 @@ +<?php +/** + * WordPress GD Image Editor + * + * @package WordPress + * @subpackage Image_Editor + */ + +/** + * WordPress Image Editor Class for Image Manipulation through GD + * + * @since 3.5.0 + * + * @see WP_Image_Editor + */ +class WP_Image_Editor_GD extends WP_Image_Editor { + /** + * GD Resource. + * + * @var resource + */ + protected $image; + + public function __destruct() { + if ( $this->image ) { + // we don't need the original in memory anymore + imagedestroy( $this->image ); + } + } + + /** + * Checks to see if current environment supports GD. + * + * @since 3.5.0 + * + * @static + * + * @param array $args + * @return bool + */ + public static function test( $args = array() ) { + if ( ! extension_loaded('gd') || ! function_exists('gd_info') ) + return false; + + // On some setups GD library does not provide imagerotate() - Ticket #11536 + if ( isset( $args['methods'] ) && + in_array( 'rotate', $args['methods'] ) && + ! function_exists('imagerotate') ){ + + return false; + } + + return true; + } + + /** + * Checks to see if editor supports the mime-type specified. + * + * @since 3.5.0 + * + * @static + * + * @param string $mime_type + * @return bool + */ + public static function supports_mime_type( $mime_type ) { + $image_types = imagetypes(); + switch( $mime_type ) { + case 'image/jpeg': + return ($image_types & IMG_JPG) != 0; + case 'image/png': + return ($image_types & IMG_PNG) != 0; + case 'image/gif': + return ($image_types & IMG_GIF) != 0; + } + + return false; + } + + /** + * Loads image from $this->file into new GD Resource. + * + * @since 3.5.0 + * + * @return bool|WP_Error True if loaded successfully; WP_Error on failure. + */ + public function load() { + if ( $this->image ) + return true; + + if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) + return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); + + // Set artificially high because GD uses uncompressed images in memory. + wp_raise_memory_limit( 'image' ); + + $this->image = @imagecreatefromstring( file_get_contents( $this->file ) ); + + if ( ! is_resource( $this->image ) ) + return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file ); + + $size = @getimagesize( $this->file ); + if ( ! $size ) + return new WP_Error( 'invalid_image', __('Could not read image size.'), $this->file ); + + if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { + imagealphablending( $this->image, false ); + imagesavealpha( $this->image, true ); + } + + $this->update_size( $size[0], $size[1] ); + $this->mime_type = $size['mime']; + + return $this->set_quality(); + } + + /** + * Sets or updates current image size. + * + * @since 3.5.0 + * + * @param int $width + * @param int $height + * @return true + */ + protected function update_size( $width = false, $height = false ) { + if ( ! $width ) + $width = imagesx( $this->image ); + + if ( ! $height ) + $height = imagesy( $this->image ); + + return parent::update_size( $width, $height ); + } + + /** + * Resizes current image. + * Wraps _resize, since _resize returns a GD Resource. + * + * At minimum, either a height or width must be provided. + * If one of the two is set to null, the resize will + * maintain aspect ratio according to the provided dimension. + * + * @since 3.5.0 + * + * @param int|null $max_w Image width. + * @param int|null $max_h Image height. + * @param bool $crop + * @return true|WP_Error + */ + public function resize( $max_w, $max_h, $crop = false ) { + if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) + return true; + + $resized = $this->_resize( $max_w, $max_h, $crop ); + + if ( is_resource( $resized ) ) { + imagedestroy( $this->image ); + $this->image = $resized; + return true; + + } elseif ( is_wp_error( $resized ) ) + return $resized; + + return new WP_Error( 'image_resize_error', __('Image resize failed.'), $this->file ); + } + + /** + * + * @param int $max_w + * @param int $max_h + * @param bool|array $crop + * @return resource|WP_Error + */ + protected function _resize( $max_w, $max_h, $crop = false ) { + $dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); + if ( ! $dims ) { + return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions'), $this->file ); + } + list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; + + $resized = wp_imagecreatetruecolor( $dst_w, $dst_h ); + imagecopyresampled( $resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); + + if ( is_resource( $resized ) ) { + $this->update_size( $dst_w, $dst_h ); + return $resized; + } + + return new WP_Error( 'image_resize_error', __('Image resize failed.'), $this->file ); + } + + /** + * Resize multiple images from a single source. + * + * @since 3.5.0 + * + * @param array $sizes { + * An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'. + * + * Either a height or width must be provided. + * If one of the two is set to null, the resize will + * maintain aspect ratio according to the provided dimension. + * + * @type array $size { + * Array of height, width values, and whether to crop. + * + * @type int $width Image width. Optional if `$height` is specified. + * @type int $height Image height. Optional if `$width` is specified. + * @type bool $crop Optional. Whether to crop the image. Default false. + * } + * } + * @return array An array of resized images' metadata by size. + */ + public function multi_resize( $sizes ) { + $metadata = array(); + $orig_size = $this->size; + + foreach ( $sizes as $size => $size_data ) { + if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { + continue; + } + + if ( ! isset( $size_data['width'] ) ) { + $size_data['width'] = null; + } + if ( ! isset( $size_data['height'] ) ) { + $size_data['height'] = null; + } + + if ( ! isset( $size_data['crop'] ) ) { + $size_data['crop'] = false; + } + + $image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); + $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) ); + + if ( ! is_wp_error( $image ) && ! $duplicate ) { + $resized = $this->_save( $image ); + + imagedestroy( $image ); + + if ( ! is_wp_error( $resized ) && $resized ) { + unset( $resized['path'] ); + $metadata[$size] = $resized; + } + } + + $this->size = $orig_size; + } + + return $metadata; + } + + /** + * Crops Image. + * + * @since 3.5.0 + * + * @param int $src_x The start x position to crop from. + * @param int $src_y The start y position to crop from. + * @param int $src_w The width to crop. + * @param int $src_h The height to crop. + * @param int $dst_w Optional. The destination width. + * @param int $dst_h Optional. The destination height. + * @param bool $src_abs Optional. If the source crop points are absolute. + * @return bool|WP_Error + */ + public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { + // If destination width/height isn't specified, use same as + // width/height from source. + if ( ! $dst_w ) + $dst_w = $src_w; + if ( ! $dst_h ) + $dst_h = $src_h; + + $dst = wp_imagecreatetruecolor( $dst_w, $dst_h ); + + if ( $src_abs ) { + $src_w -= $src_x; + $src_h -= $src_y; + } + + if ( function_exists( 'imageantialias' ) ) + imageantialias( $dst, true ); + + imagecopyresampled( $dst, $this->image, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); + + if ( is_resource( $dst ) ) { + imagedestroy( $this->image ); + $this->image = $dst; + $this->update_size(); + return true; + } + + return new WP_Error( 'image_crop_error', __('Image crop failed.'), $this->file ); + } + + /** + * Rotates current image counter-clockwise by $angle. + * Ported from image-edit.php + * + * @since 3.5.0 + * + * @param float $angle + * @return true|WP_Error + */ + public function rotate( $angle ) { + if ( function_exists('imagerotate') ) { + $transparency = imagecolorallocatealpha( $this->image, 255, 255, 255, 127 ); + $rotated = imagerotate( $this->image, $angle, $transparency ); + + if ( is_resource( $rotated ) ) { + imagealphablending( $rotated, true ); + imagesavealpha( $rotated, true ); + imagedestroy( $this->image ); + $this->image = $rotated; + $this->update_size(); + return true; + } + } + return new WP_Error( 'image_rotate_error', __('Image rotate failed.'), $this->file ); + } + + /** + * Flips current image. + * + * @since 3.5.0 + * + * @param bool $horz Flip along Horizontal Axis + * @param bool $vert Flip along Vertical Axis + * @return true|WP_Error + */ + public function flip( $horz, $vert ) { + $w = $this->size['width']; + $h = $this->size['height']; + $dst = wp_imagecreatetruecolor( $w, $h ); + + if ( is_resource( $dst ) ) { + $sx = $vert ? ($w - 1) : 0; + $sy = $horz ? ($h - 1) : 0; + $sw = $vert ? -$w : $w; + $sh = $horz ? -$h : $h; + + if ( imagecopyresampled( $dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) { + imagedestroy( $this->image ); + $this->image = $dst; + return true; + } + } + return new WP_Error( 'image_flip_error', __('Image flip failed.'), $this->file ); + } + + /** + * Saves current in-memory image to file. + * + * @since 3.5.0 + * + * @param string|null $filename + * @param string|null $mime_type + * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} + */ + public function save( $filename = null, $mime_type = null ) { + $saved = $this->_save( $this->image, $filename, $mime_type ); + + if ( ! is_wp_error( $saved ) ) { + $this->file = $saved['path']; + $this->mime_type = $saved['mime-type']; + } + + return $saved; + } + + /** + * @param resource $image + * @param string|null $filename + * @param string|null $mime_type + * @return WP_Error|array + */ + protected function _save( $image, $filename = null, $mime_type = null ) { + list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type ); + + if ( ! $filename ) + $filename = $this->generate_filename( null, null, $extension ); + + if ( 'image/gif' == $mime_type ) { + if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) ) + return new WP_Error( 'image_save_error', __('Image Editor Save Failed') ); + } + elseif ( 'image/png' == $mime_type ) { + // convert from full colors to index colors, like original PNG. + if ( function_exists('imageistruecolor') && ! imageistruecolor( $image ) ) + imagetruecolortopalette( $image, false, imagecolorstotal( $image ) ); + + if ( ! $this->make_image( $filename, 'imagepng', array( $image, $filename ) ) ) + return new WP_Error( 'image_save_error', __('Image Editor Save Failed') ); + } + elseif ( 'image/jpeg' == $mime_type ) { + if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->get_quality() ) ) ) + return new WP_Error( 'image_save_error', __('Image Editor Save Failed') ); + } + else { + return new WP_Error( 'image_save_error', __('Image Editor Save Failed') ); + } + + // Set correct file permissions + $stat = stat( dirname( $filename ) ); + $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + @ chmod( $filename, $perms ); + + /** + * Filters the name of the saved image file. + * + * @since 2.6.0 + * + * @param string $filename Name of the file. + */ + return array( + 'path' => $filename, + 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), + 'width' => $this->size['width'], + 'height' => $this->size['height'], + 'mime-type' => $mime_type, + ); + } + + /** + * Returns stream of current image. + * + * @since 3.5.0 + * + * @param string $mime_type The mime type of the image. + * @return bool True on success, false on failure. + */ + public function stream( $mime_type = null ) { + list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); + + switch ( $mime_type ) { + case 'image/png': + header( 'Content-Type: image/png' ); + return imagepng( $this->image ); + case 'image/gif': + header( 'Content-Type: image/gif' ); + return imagegif( $this->image ); + default: + header( 'Content-Type: image/jpeg' ); + return imagejpeg( $this->image, null, $this->get_quality() ); + } + } + + /** + * Either calls editor's save function or handles file as a stream. + * + * @since 3.5.0 + * + * @param string|stream $filename + * @param callable $function + * @param array $arguments + * @return bool + */ + protected function make_image( $filename, $function, $arguments ) { + if ( wp_is_stream( $filename ) ) + $arguments[1] = null; + + return parent::make_image( $filename, $function, $arguments ); + } +} diff --git a/backend/wp-includes/class-wp-image-editor-imagick.php b/backend/wp-includes/class-wp-image-editor-imagick.php new file mode 100644 index 0000000..9f6a0f3 --- /dev/null +++ b/backend/wp-includes/class-wp-image-editor-imagick.php @@ -0,0 +1,752 @@ +<?php +/** + * WordPress Imagick Image Editor + * + * @package WordPress + * @subpackage Image_Editor + */ + +/** + * WordPress Image Editor Class for Image Manipulation through Imagick PHP Module + * + * @since 3.5.0 + * + * @see WP_Image_Editor + */ +class WP_Image_Editor_Imagick extends WP_Image_Editor { + /** + * Imagick object. + * + * @var Imagick + */ + protected $image; + + public function __destruct() { + if ( $this->image instanceof Imagick ) { + // we don't need the original in memory anymore + $this->image->clear(); + $this->image->destroy(); + } + } + + /** + * Checks to see if current environment supports Imagick. + * + * We require Imagick 2.2.0 or greater, based on whether the queryFormats() + * method can be called statically. + * + * @since 3.5.0 + * + * @static + * + * @param array $args + * @return bool + */ + public static function test( $args = array() ) { + + // First, test Imagick's extension and classes. + if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) ) + return false; + + if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) + return false; + + $required_methods = array( + 'clear', + 'destroy', + 'valid', + 'getimage', + 'writeimage', + 'getimageblob', + 'getimagegeometry', + 'getimageformat', + 'setimageformat', + 'setimagecompression', + 'setimagecompressionquality', + 'setimagepage', + 'setoption', + 'scaleimage', + 'cropimage', + 'rotateimage', + 'flipimage', + 'flopimage', + 'readimage', + ); + + // Now, test for deep requirements within Imagick. + if ( ! defined( 'imagick::COMPRESSION_JPEG' ) ) + return false; + + $class_methods = array_map( 'strtolower', get_class_methods( 'Imagick' ) ); + if ( array_diff( $required_methods, $class_methods ) ) { + return false; + } + + // HHVM Imagick does not support loading from URL, so fail to allow fallback to GD. + if ( defined( 'HHVM_VERSION' ) && isset( $args['path'] ) && preg_match( '|^https?://|', $args['path'] ) ) { + return false; + } + + return true; + } + + /** + * Checks to see if editor supports the mime-type specified. + * + * @since 3.5.0 + * + * @static + * + * @param string $mime_type + * @return bool + */ + public static function supports_mime_type( $mime_type ) { + $imagick_extension = strtoupper( self::get_extension( $mime_type ) ); + + if ( ! $imagick_extension ) + return false; + + // setIteratorIndex is optional unless mime is an animated format. + // Here, we just say no if you are missing it and aren't loading a jpeg. + if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' ) + return false; + + try { + return ( (bool) @Imagick::queryFormats( $imagick_extension ) ); + } + catch ( Exception $e ) { + return false; + } + } + + /** + * Loads image from $this->file into new Imagick Object. + * + * @since 3.5.0 + * + * @return true|WP_Error True if loaded; WP_Error on failure. + */ + public function load() { + if ( $this->image instanceof Imagick ) + return true; + + if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) + return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); + + /* + * Even though Imagick uses less PHP memory than GD, set higher limit + * for users that have low PHP.ini limits. + */ + wp_raise_memory_limit( 'image' ); + + try { + $this->image = new Imagick(); + $file_extension = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) ); + $filename = $this->file; + + if ( 'pdf' == $file_extension ) { + $filename = $this->pdf_setup(); + } + + // Reading image after Imagick instantiation because `setResolution` + // only applies correctly before the image is read. + $this->image->readImage( $filename ); + + if ( ! $this->image->valid() ) + return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); + + // Select the first frame to handle animated images properly + if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) + $this->image->setIteratorIndex(0); + + $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); + } + catch ( Exception $e ) { + return new WP_Error( 'invalid_image', $e->getMessage(), $this->file ); + } + + $updated_size = $this->update_size(); + if ( is_wp_error( $updated_size ) ) { + return $updated_size; + } + + return $this->set_quality(); + } + + /** + * Sets Image Compression quality on a 1-100% scale. + * + * @since 3.5.0 + * + * @param int $quality Compression Quality. Range: [1,100] + * @return true|WP_Error True if set successfully; WP_Error on failure. + */ + public function set_quality( $quality = null ) { + $quality_result = parent::set_quality( $quality ); + if ( is_wp_error( $quality_result ) ) { + return $quality_result; + } else { + $quality = $this->get_quality(); + } + + try { + if ( 'image/jpeg' == $this->mime_type ) { + $this->image->setImageCompressionQuality( $quality ); + $this->image->setImageCompression( imagick::COMPRESSION_JPEG ); + } + else { + $this->image->setImageCompressionQuality( $quality ); + } + } + catch ( Exception $e ) { + return new WP_Error( 'image_quality_error', $e->getMessage() ); + } + + return true; + } + + /** + * Sets or updates current image size. + * + * @since 3.5.0 + * + * @param int $width + * @param int $height + * + * @return true|WP_Error + */ + protected function update_size( $width = null, $height = null ) { + $size = null; + if ( !$width || !$height ) { + try { + $size = $this->image->getImageGeometry(); + } + catch ( Exception $e ) { + return new WP_Error( 'invalid_image', __( 'Could not read image size.' ), $this->file ); + } + } + + if ( ! $width ) + $width = $size['width']; + + if ( ! $height ) + $height = $size['height']; + + return parent::update_size( $width, $height ); + } + + /** + * Resizes current image. + * + * At minimum, either a height or width must be provided. + * If one of the two is set to null, the resize will + * maintain aspect ratio according to the provided dimension. + * + * @since 3.5.0 + * + * @param int|null $max_w Image width. + * @param int|null $max_h Image height. + * @param bool $crop + * @return bool|WP_Error + */ + public function resize( $max_w, $max_h, $crop = false ) { + if ( ( $this->size['width'] == $max_w ) && ( $this->size['height'] == $max_h ) ) + return true; + + $dims = image_resize_dimensions( $this->size['width'], $this->size['height'], $max_w, $max_h, $crop ); + if ( ! $dims ) + return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); + list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; + + if ( $crop ) { + return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h ); + } + + // Execute the resize + $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); + if ( is_wp_error( $thumb_result ) ) { + return $thumb_result; + } + + return $this->update_size( $dst_w, $dst_h ); + } + + /** + * Efficiently resize the current image + * + * This is a WordPress specific implementation of Imagick::thumbnailImage(), + * which resizes an image to given dimensions and removes any associated profiles. + * + * @since 4.5.0 + * + * @param int $dst_w The destination width. + * @param int $dst_h The destination height. + * @param string $filter_name Optional. The Imagick filter to use when resizing. Default 'FILTER_TRIANGLE'. + * @param bool $strip_meta Optional. Strip all profiles, excluding color profiles, from the image. Default true. + * @return bool|WP_Error + */ + protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) { + $allowed_filters = array( + 'FILTER_POINT', + 'FILTER_BOX', + 'FILTER_TRIANGLE', + 'FILTER_HERMITE', + 'FILTER_HANNING', + 'FILTER_HAMMING', + 'FILTER_BLACKMAN', + 'FILTER_GAUSSIAN', + 'FILTER_QUADRATIC', + 'FILTER_CUBIC', + 'FILTER_CATROM', + 'FILTER_MITCHELL', + 'FILTER_LANCZOS', + 'FILTER_BESSEL', + 'FILTER_SINC', + ); + + /** + * Set the filter value if '$filter_name' name is in our whitelist and the related + * Imagick constant is defined or fall back to our default filter. + */ + if ( in_array( $filter_name, $allowed_filters ) && defined( 'Imagick::' . $filter_name ) ) { + $filter = constant( 'Imagick::' . $filter_name ); + } else { + $filter = defined( 'Imagick::FILTER_TRIANGLE' ) ? Imagick::FILTER_TRIANGLE : false; + } + + /** + * Filters whether to strip metadata from images when they're resized. + * + * This filter only applies when resizing using the Imagick editor since GD + * always strips profiles by default. + * + * @since 4.5.0 + * + * @param bool $strip_meta Whether to strip image metadata during resizing. Default true. + */ + if ( apply_filters( 'image_strip_meta', $strip_meta ) ) { + $this->strip_meta(); // Fail silently if not supported. + } + + try { + /* + * To be more efficient, resample large images to 5x the destination size before resizing + * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111), + * unless we would be resampling to a scale smaller than 128x128. + */ + if ( is_callable( array( $this->image, 'sampleImage' ) ) ) { + $resize_ratio = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] ); + $sample_factor = 5; + + if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) { + $this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor ); + } + } + + /* + * Use resizeImage() when it's available and a valid filter value is set. + * Otherwise, fall back to the scaleImage() method for resizing, which + * results in better image quality over resizeImage() with default filter + * settings and retains backward compatibility with pre 4.5 functionality. + */ + if ( is_callable( array( $this->image, 'resizeImage' ) ) && $filter ) { + $this->image->setOption( 'filter:support', '2.0' ); + $this->image->resizeImage( $dst_w, $dst_h, $filter, 1 ); + } else { + $this->image->scaleImage( $dst_w, $dst_h ); + } + + // Set appropriate quality settings after resizing. + if ( 'image/jpeg' == $this->mime_type ) { + if ( is_callable( array( $this->image, 'unsharpMaskImage' ) ) ) { + $this->image->unsharpMaskImage( 0.25, 0.25, 8, 0.065 ); + } + + $this->image->setOption( 'jpeg:fancy-upsampling', 'off' ); + } + + if ( 'image/png' === $this->mime_type ) { + $this->image->setOption( 'png:compression-filter', '5' ); + $this->image->setOption( 'png:compression-level', '9' ); + $this->image->setOption( 'png:compression-strategy', '1' ); + $this->image->setOption( 'png:exclude-chunk', 'all' ); + } + + /* + * If alpha channel is not defined, set it opaque. + * + * Note that Imagick::getImageAlphaChannel() is only available if Imagick + * has been compiled against ImageMagick version 6.4.0 or newer. + */ + if ( is_callable( array( $this->image, 'getImageAlphaChannel' ) ) + && is_callable( array( $this->image, 'setImageAlphaChannel' ) ) + && defined( 'Imagick::ALPHACHANNEL_UNDEFINED' ) + && defined( 'Imagick::ALPHACHANNEL_OPAQUE' ) + ) { + if ( $this->image->getImageAlphaChannel() === Imagick::ALPHACHANNEL_UNDEFINED ) { + $this->image->setImageAlphaChannel( Imagick::ALPHACHANNEL_OPAQUE ); + } + } + + // Limit the bit depth of resized images to 8 bits per channel. + if ( is_callable( array( $this->image, 'getImageDepth' ) ) && is_callable( array( $this->image, 'setImageDepth' ) ) ) { + if ( 8 < $this->image->getImageDepth() ) { + $this->image->setImageDepth( 8 ); + } + } + + if ( is_callable( array( $this->image, 'setInterlaceScheme' ) ) && defined( 'Imagick::INTERLACE_NO' ) ) { + $this->image->setInterlaceScheme( Imagick::INTERLACE_NO ); + } + + } + catch ( Exception $e ) { + return new WP_Error( 'image_resize_error', $e->getMessage() ); + } + } + + /** + * Resize multiple images from a single source. + * + * @since 3.5.0 + * + * @param array $sizes { + * An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'. + * + * Either a height or width must be provided. + * If one of the two is set to null, the resize will + * maintain aspect ratio according to the provided dimension. + * + * @type array $size { + * Array of height, width values, and whether to crop. + * + * @type int $width Image width. Optional if `$height` is specified. + * @type int $height Image height. Optional if `$width` is specified. + * @type bool $crop Optional. Whether to crop the image. Default false. + * } + * } + * @return array An array of resized images' metadata by size. + */ + public function multi_resize( $sizes ) { + $metadata = array(); + $orig_size = $this->size; + $orig_image = $this->image->getImage(); + + foreach ( $sizes as $size => $size_data ) { + if ( ! $this->image ) + $this->image = $orig_image->getImage(); + + if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { + continue; + } + + if ( ! isset( $size_data['width'] ) ) { + $size_data['width'] = null; + } + if ( ! isset( $size_data['height'] ) ) { + $size_data['height'] = null; + } + + if ( ! isset( $size_data['crop'] ) ) { + $size_data['crop'] = false; + } + + $resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); + $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) ); + + if ( ! is_wp_error( $resize_result ) && ! $duplicate ) { + $resized = $this->_save( $this->image ); + + $this->image->clear(); + $this->image->destroy(); + $this->image = null; + + if ( ! is_wp_error( $resized ) && $resized ) { + unset( $resized['path'] ); + $metadata[$size] = $resized; + } + } + + $this->size = $orig_size; + } + + $this->image = $orig_image; + + return $metadata; + } + + /** + * Crops Image. + * + * @since 3.5.0 + * + * @param int $src_x The start x position to crop from. + * @param int $src_y The start y position to crop from. + * @param int $src_w The width to crop. + * @param int $src_h The height to crop. + * @param int $dst_w Optional. The destination width. + * @param int $dst_h Optional. The destination height. + * @param bool $src_abs Optional. If the source crop points are absolute. + * @return bool|WP_Error + */ + public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { + if ( $src_abs ) { + $src_w -= $src_x; + $src_h -= $src_y; + } + + try { + $this->image->cropImage( $src_w, $src_h, $src_x, $src_y ); + $this->image->setImagePage( $src_w, $src_h, 0, 0); + + if ( $dst_w || $dst_h ) { + // If destination width/height isn't specified, use same as + // width/height from source. + if ( ! $dst_w ) + $dst_w = $src_w; + if ( ! $dst_h ) + $dst_h = $src_h; + + $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); + if ( is_wp_error( $thumb_result ) ) { + return $thumb_result; + } + + return $this->update_size(); + } + } + catch ( Exception $e ) { + return new WP_Error( 'image_crop_error', $e->getMessage() ); + } + return $this->update_size(); + } + + /** + * Rotates current image counter-clockwise by $angle. + * + * @since 3.5.0 + * + * @param float $angle + * @return true|WP_Error + */ + public function rotate( $angle ) { + /** + * $angle is 360-$angle because Imagick rotates clockwise + * (GD rotates counter-clockwise) + */ + try { + $this->image->rotateImage( new ImagickPixel('none'), 360-$angle ); + + // Normalise Exif orientation data so that display is consistent across devices. + if ( is_callable( array( $this->image, 'setImageOrientation' ) ) && defined( 'Imagick::ORIENTATION_TOPLEFT' ) ) { + $this->image->setImageOrientation( Imagick::ORIENTATION_TOPLEFT ); + } + + // Since this changes the dimensions of the image, update the size. + $result = $this->update_size(); + if ( is_wp_error( $result ) ) + return $result; + + $this->image->setImagePage( $this->size['width'], $this->size['height'], 0, 0 ); + } + catch ( Exception $e ) { + return new WP_Error( 'image_rotate_error', $e->getMessage() ); + } + return true; + } + + /** + * Flips current image. + * + * @since 3.5.0 + * + * @param bool $horz Flip along Horizontal Axis + * @param bool $vert Flip along Vertical Axis + * @return true|WP_Error + */ + public function flip( $horz, $vert ) { + try { + if ( $horz ) + $this->image->flipImage(); + + if ( $vert ) + $this->image->flopImage(); + } + catch ( Exception $e ) { + return new WP_Error( 'image_flip_error', $e->getMessage() ); + } + return true; + } + + /** + * Saves current image to file. + * + * @since 3.5.0 + * + * @param string $destfilename + * @param string $mime_type + * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} + */ + public function save( $destfilename = null, $mime_type = null ) { + $saved = $this->_save( $this->image, $destfilename, $mime_type ); + + if ( ! is_wp_error( $saved ) ) { + $this->file = $saved['path']; + $this->mime_type = $saved['mime-type']; + + try { + $this->image->setImageFormat( strtoupper( $this->get_extension( $this->mime_type ) ) ); + } + catch ( Exception $e ) { + return new WP_Error( 'image_save_error', $e->getMessage(), $this->file ); + } + } + + return $saved; + } + + /** + * + * @param Imagick $image + * @param string $filename + * @param string $mime_type + * @return array|WP_Error + */ + protected function _save( $image, $filename = null, $mime_type = null ) { + list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type ); + + if ( ! $filename ) + $filename = $this->generate_filename( null, null, $extension ); + + try { + // Store initial Format + $orig_format = $this->image->getImageFormat(); + + $this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) ); + $this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) ); + + // Reset original Format + $this->image->setImageFormat( $orig_format ); + } + catch ( Exception $e ) { + return new WP_Error( 'image_save_error', $e->getMessage(), $filename ); + } + + // Set correct file permissions + $stat = stat( dirname( $filename ) ); + $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + @ chmod( $filename, $perms ); + + /** This filter is documented in wp-includes/class-wp-image-editor-gd.php */ + return array( + 'path' => $filename, + 'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ), + 'width' => $this->size['width'], + 'height' => $this->size['height'], + 'mime-type' => $mime_type, + ); + } + + /** + * Streams current image to browser. + * + * @since 3.5.0 + * + * @param string $mime_type The mime type of the image. + * @return bool|WP_Error True on success, WP_Error object on failure. + */ + public function stream( $mime_type = null ) { + list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); + + try { + // Temporarily change format for stream + $this->image->setImageFormat( strtoupper( $extension ) ); + + // Output stream of image content + header( "Content-Type: $mime_type" ); + print $this->image->getImageBlob(); + + // Reset Image to original Format + $this->image->setImageFormat( $this->get_extension( $this->mime_type ) ); + } + catch ( Exception $e ) { + return new WP_Error( 'image_stream_error', $e->getMessage() ); + } + + return true; + } + + /** + * Strips all image meta except color profiles from an image. + * + * @since 4.5.0 + * + * @return true|WP_Error True if stripping metadata was successful. WP_Error object on error. + */ + protected function strip_meta() { + + if ( ! is_callable( array( $this->image, 'getImageProfiles' ) ) ) { + /* translators: %s: ImageMagick method name */ + return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::getImageProfiles()</code>' ) ); + } + + if ( ! is_callable( array( $this->image, 'removeImageProfile' ) ) ) { + /* translators: %s: ImageMagick method name */ + return new WP_Error( 'image_strip_meta_error', sprintf( __( '%s is required to strip image meta.' ), '<code>Imagick::removeImageProfile()</code>' ) ); + } + + /* + * Protect a few profiles from being stripped for the following reasons: + * + * - icc: Color profile information + * - icm: Color profile information + * - iptc: Copyright data + * - exif: Orientation data + * - xmp: Rights usage data + */ + $protected_profiles = array( + 'icc', + 'icm', + 'iptc', + 'exif', + 'xmp', + ); + + try { + // Strip profiles. + foreach ( $this->image->getImageProfiles( '*', true ) as $key => $value ) { + if ( ! in_array( $key, $protected_profiles ) ) { + $this->image->removeImageProfile( $key ); + } + } + + } catch ( Exception $e ) { + return new WP_Error( 'image_strip_meta_error', $e->getMessage() ); + } + + return true; + } + + /** + * Sets up Imagick for PDF processing. + * Increases rendering DPI and only loads first page. + * + * @since 4.7.0 + * + * @return string|WP_Error File to load or WP_Error on failure. + */ + protected function pdf_setup() { + try { + // By default, PDFs are rendered in a very low resolution. + // We want the thumbnail to be readable, so increase the rendering DPI. + $this->image->setResolution( 128, 128 ); + + // Only load the first page. + return $this->file . '[0]'; + } + catch ( Exception $e ) { + return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file ); + } + } + +} diff --git a/backend/wp-includes/class-wp-image-editor.php b/backend/wp-includes/class-wp-image-editor.php new file mode 100644 index 0000000..85a4916 --- /dev/null +++ b/backend/wp-includes/class-wp-image-editor.php @@ -0,0 +1,470 @@ +<?php +/** + * Base WordPress Image Editor + * + * @package WordPress + * @subpackage Image_Editor + */ + +/** + * Base image editor class from which implementations extend + * + * @since 3.5.0 + */ +abstract class WP_Image_Editor { + protected $file = null; + protected $size = null; + protected $mime_type = null; + protected $default_mime_type = 'image/jpeg'; + protected $quality = false; + protected $default_quality = 82; + + /** + * Each instance handles a single file. + * + * @param string $file Path to the file to load. + */ + public function __construct( $file ) { + $this->file = $file; + } + + /** + * Checks to see if current environment supports the editor chosen. + * Must be overridden in a sub-class. + * + * @since 3.5.0 + * + * @static + * @abstract + * + * @param array $args + * @return bool + */ + public static function test( $args = array() ) { + return false; + } + + /** + * Checks to see if editor supports the mime-type specified. + * Must be overridden in a sub-class. + * + * @since 3.5.0 + * + * @static + * @abstract + * + * @param string $mime_type + * @return bool + */ + public static function supports_mime_type( $mime_type ) { + return false; + } + + /** + * Loads image from $this->file into editor. + * + * @since 3.5.0 + * @abstract + * + * @return bool|WP_Error True if loaded; WP_Error on failure. + */ + abstract public function load(); + + /** + * Saves current image to file. + * + * @since 3.5.0 + * @abstract + * + * @param string $destfilename + * @param string $mime_type + * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} + */ + abstract public function save( $destfilename = null, $mime_type = null ); + + /** + * Resizes current image. + * + * At minimum, either a height or width must be provided. + * If one of the two is set to null, the resize will + * maintain aspect ratio according to the provided dimension. + * + * @since 3.5.0 + * @abstract + * + * @param int|null $max_w Image width. + * @param int|null $max_h Image height. + * @param bool $crop + * @return bool|WP_Error + */ + abstract public function resize( $max_w, $max_h, $crop = false ); + + /** + * Resize multiple images from a single source. + * + * @since 3.5.0 + * @abstract + * + * @param array $sizes { + * An array of image size arrays. Default sizes are 'small', 'medium', 'large'. + * + * @type array $size { + * @type int $width Image width. + * @type int $height Image height. + * @type bool $crop Optional. Whether to crop the image. Default false. + * } + * } + * @return array An array of resized images metadata by size. + */ + abstract public function multi_resize( $sizes ); + + /** + * Crops Image. + * + * @since 3.5.0 + * @abstract + * + * @param int $src_x The start x position to crop from. + * @param int $src_y The start y position to crop from. + * @param int $src_w The width to crop. + * @param int $src_h The height to crop. + * @param int $dst_w Optional. The destination width. + * @param int $dst_h Optional. The destination height. + * @param bool $src_abs Optional. If the source crop points are absolute. + * @return bool|WP_Error + */ + abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ); + + /** + * Rotates current image counter-clockwise by $angle. + * + * @since 3.5.0 + * @abstract + * + * @param float $angle + * @return bool|WP_Error + */ + abstract public function rotate( $angle ); + + /** + * Flips current image. + * + * @since 3.5.0 + * @abstract + * + * @param bool $horz Flip along Horizontal Axis + * @param bool $vert Flip along Vertical Axis + * @return bool|WP_Error + */ + abstract public function flip( $horz, $vert ); + + /** + * Streams current image to browser. + * + * @since 3.5.0 + * @abstract + * + * @param string $mime_type The mime type of the image. + * @return bool|WP_Error True on success, WP_Error object or false on failure. + */ + abstract public function stream( $mime_type = null ); + + /** + * Gets dimensions of image. + * + * @since 3.5.0 + * + * @return array {'width'=>int, 'height'=>int} + */ + public function get_size() { + return $this->size; + } + + /** + * Sets current image size. + * + * @since 3.5.0 + * + * @param int $width + * @param int $height + * @return true + */ + protected function update_size( $width = null, $height = null ) { + $this->size = array( + 'width' => (int) $width, + 'height' => (int) $height + ); + return true; + } + + /** + * Gets the Image Compression quality on a 1-100% scale. + * + * @since 4.0.0 + * + * @return int $quality Compression Quality. Range: [1,100] + */ + public function get_quality() { + if ( ! $this->quality ) { + $this->set_quality(); + } + + return $this->quality; + } + + /** + * Sets Image Compression quality on a 1-100% scale. + * + * @since 3.5.0 + * + * @param int $quality Compression Quality. Range: [1,100] + * @return true|WP_Error True if set successfully; WP_Error on failure. + */ + public function set_quality( $quality = null ) { + if ( null === $quality ) { + /** + * Filters the default image compression quality setting. + * + * Applies only during initial editor instantiation, or when set_quality() is run + * manually without the `$quality` argument. + * + * set_quality() has priority over the filter. + * + * @since 3.5.0 + * + * @param int $quality Quality level between 1 (low) and 100 (high). + * @param string $mime_type Image mime type. + */ + $quality = apply_filters( 'wp_editor_set_quality', $this->default_quality, $this->mime_type ); + + if ( 'image/jpeg' == $this->mime_type ) { + /** + * Filters the JPEG compression quality for backward-compatibility. + * + * Applies only during initial editor instantiation, or when set_quality() is run + * manually without the `$quality` argument. + * + * set_quality() has priority over the filter. + * + * The filter is evaluated under two contexts: 'image_resize', and 'edit_image', + * (when a JPEG image is saved to file). + * + * @since 2.5.0 + * + * @param int $quality Quality level between 0 (low) and 100 (high) of the JPEG. + * @param string $context Context of the filter. + */ + $quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' ); + } + + if ( $quality < 0 || $quality > 100 ) { + $quality = $this->default_quality; + } + } + + // Allow 0, but squash to 1 due to identical images in GD, and for backward compatibility. + if ( 0 === $quality ) { + $quality = 1; + } + + if ( ( $quality >= 1 ) && ( $quality <= 100 ) ) { + $this->quality = $quality; + return true; + } else { + return new WP_Error( 'invalid_image_quality', __('Attempted to set image quality outside of the range [1,100].') ); + } + } + + /** + * Returns preferred mime-type and extension based on provided + * file's extension and mime, or current file's extension and mime. + * + * Will default to $this->default_mime_type if requested is not supported. + * + * Provides corrected filename only if filename is provided. + * + * @since 3.5.0 + * + * @param string $filename + * @param string $mime_type + * @return array { filename|null, extension, mime-type } + */ + protected function get_output_format( $filename = null, $mime_type = null ) { + $new_ext = null; + + // By default, assume specified type takes priority + if ( $mime_type ) { + $new_ext = $this->get_extension( $mime_type ); + } + + if ( $filename ) { + $file_ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ); + $file_mime = $this->get_mime_type( $file_ext ); + } + else { + // If no file specified, grab editor's current extension and mime-type. + $file_ext = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) ); + $file_mime = $this->mime_type; + } + + // Check to see if specified mime-type is the same as type implied by + // file extension. If so, prefer extension from file. + if ( ! $mime_type || ( $file_mime == $mime_type ) ) { + $mime_type = $file_mime; + $new_ext = $file_ext; + } + + // Double-check that the mime-type selected is supported by the editor. + // If not, choose a default instead. + if ( ! $this->supports_mime_type( $mime_type ) ) { + /** + * Filters default mime type prior to getting the file extension. + * + * @see wp_get_mime_types() + * + * @since 3.5.0 + * + * @param string $mime_type Mime type string. + */ + $mime_type = apply_filters( 'image_editor_default_mime_type', $this->default_mime_type ); + $new_ext = $this->get_extension( $mime_type ); + } + + if ( $filename ) { + $dir = pathinfo( $filename, PATHINFO_DIRNAME ); + $ext = pathinfo( $filename, PATHINFO_EXTENSION ); + + $filename = trailingslashit( $dir ) . wp_basename( $filename, ".$ext" ) . ".{$new_ext}"; + } + + return array( $filename, $new_ext, $mime_type ); + } + + /** + * Builds an output filename based on current file, and adding proper suffix + * + * @since 3.5.0 + * + * @param string $suffix + * @param string $dest_path + * @param string $extension + * @return string filename + */ + public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) { + // $suffix will be appended to the destination filename, just before the extension + if ( ! $suffix ) + $suffix = $this->get_suffix(); + + $dir = pathinfo( $this->file, PATHINFO_DIRNAME ); + $ext = pathinfo( $this->file, PATHINFO_EXTENSION ); + + $name = wp_basename( $this->file, ".$ext" ); + $new_ext = strtolower( $extension ? $extension : $ext ); + + if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) ) + $dir = $_dest_path; + + return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}"; + } + + /** + * Builds and returns proper suffix for file based on height and width. + * + * @since 3.5.0 + * + * @return false|string suffix + */ + public function get_suffix() { + if ( ! $this->get_size() ) + return false; + + return "{$this->size['width']}x{$this->size['height']}"; + } + + /** + * Either calls editor's save function or handles file as a stream. + * + * @since 3.5.0 + * + * @param string|stream $filename + * @param callable $function + * @param array $arguments + * @return bool + */ + protected function make_image( $filename, $function, $arguments ) { + if ( $stream = wp_is_stream( $filename ) ) { + ob_start(); + } else { + // The directory containing the original file may no longer exist when using a replication plugin. + wp_mkdir_p( dirname( $filename ) ); + } + + $result = call_user_func_array( $function, $arguments ); + + if ( $result && $stream ) { + $contents = ob_get_contents(); + + $fp = fopen( $filename, 'w' ); + + if ( ! $fp ) + return false; + + fwrite( $fp, $contents ); + fclose( $fp ); + } + + if ( $stream ) { + ob_end_clean(); + } + + return $result; + } + + /** + * Returns first matched mime-type from extension, + * as mapped from wp_get_mime_types() + * + * @since 3.5.0 + * + * @static + * + * @param string $extension + * @return string|false + */ + protected static function get_mime_type( $extension = null ) { + if ( ! $extension ) + return false; + + $mime_types = wp_get_mime_types(); + $extensions = array_keys( $mime_types ); + + foreach ( $extensions as $_extension ) { + if ( preg_match( "/{$extension}/i", $_extension ) ) { + return $mime_types[$_extension]; + } + } + + return false; + } + + /** + * Returns first matched extension from Mime-type, + * as mapped from wp_get_mime_types() + * + * @since 3.5.0 + * + * @static + * + * @param string $mime_type + * @return string|false + */ + protected static function get_extension( $mime_type = null ) { + $extensions = explode( '|', array_search( $mime_type, wp_get_mime_types() ) ); + + if ( empty( $extensions[0] ) ) + return false; + + return $extensions[0]; + } +} + diff --git a/backend/wp-includes/class-wp-list-util.php b/backend/wp-includes/class-wp-list-util.php new file mode 100644 index 0000000..4066e96 --- /dev/null +++ b/backend/wp-includes/class-wp-list-util.php @@ -0,0 +1,261 @@ +<?php +/** + * WordPress List utility class + * + * @package WordPress + * @since 4.7.0 + */ + +/** + * List utility. + * + * Utility class to handle operations on an array of objects. + * + * @since 4.7.0 + */ +class WP_List_Util { + /** + * The input array. + * + * @since 4.7.0 + * @var array + */ + private $input = array(); + + /** + * The output array. + * + * @since 4.7.0 + * @var array + */ + private $output = array(); + + /** + * Temporary arguments for sorting. + * + * @since 4.7.0 + * @var array + */ + private $orderby = array(); + + /** + * Constructor. + * + * Sets the input array. + * + * @since 4.7.0 + * + * @param array $input Array to perform operations on. + */ + public function __construct( $input ) { + $this->output = $this->input = $input; + } + + /** + * Returns the original input array. + * + * @since 4.7.0 + * + * @return array The input array. + */ + public function get_input() { + return $this->input; + } + + /** + * Returns the output array. + * + * @since 4.7.0 + * + * @return array The output array. + */ + public function get_output() { + return $this->output; + } + + /** + * Filters the list, based on a set of key => value arguments. + * + * @since 4.7.0 + * + * @param array $args Optional. An array of key => value arguments to match + * against each object. Default empty array. + * @param string $operator Optional. The logical operation to perform. 'AND' means + * all elements from the array must match. 'OR' means only + * one element needs to match. 'NOT' means no elements may + * match. Default 'AND'. + * @return array Array of found values. + */ + public function filter( $args = array(), $operator = 'AND' ) { + if ( empty( $args ) ) { + return $this->output; + } + + $operator = strtoupper( $operator ); + + if ( ! in_array( $operator, array( 'AND', 'OR', 'NOT' ), true ) ) { + return array(); + } + + $count = count( $args ); + $filtered = array(); + + foreach ( $this->output as $key => $obj ) { + $to_match = (array) $obj; + + $matched = 0; + foreach ( $args as $m_key => $m_value ) { + if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) { + $matched++; + } + } + + if ( + ( 'AND' == $operator && $matched == $count ) || + ( 'OR' == $operator && $matched > 0 ) || + ( 'NOT' == $operator && 0 == $matched ) + ) { + $filtered[$key] = $obj; + } + } + + $this->output = $filtered; + + return $this->output; + } + + /** + * Plucks a certain field out of each object in the list. + * + * This has the same functionality and prototype of + * array_column() (PHP 5.5) but also supports objects. + * + * @since 4.7.0 + * + * @param int|string $field Field from the object to place instead of the entire object + * @param int|string $index_key Optional. Field from the object to use as keys for the new array. + * Default null. + * @return array Array of found values. If `$index_key` is set, an array of found values with keys + * corresponding to `$index_key`. If `$index_key` is null, array keys from the original + * `$list` will be preserved in the results. + */ + public function pluck( $field, $index_key = null ) { + if ( ! $index_key ) { + /* + * This is simple. Could at some point wrap array_column() + * if we knew we had an array of arrays. + */ + foreach ( $this->output as $key => $value ) { + if ( is_object( $value ) ) { + $this->output[ $key ] = $value->$field; + } else { + $this->output[ $key ] = $value[ $field ]; + } + } + return $this->output; + } + + /* + * When index_key is not set for a particular item, push the value + * to the end of the stack. This is how array_column() behaves. + */ + $newlist = array(); + foreach ( $this->output as $value ) { + if ( is_object( $value ) ) { + if ( isset( $value->$index_key ) ) { + $newlist[ $value->$index_key ] = $value->$field; + } else { + $newlist[] = $value->$field; + } + } else { + if ( isset( $value[ $index_key ] ) ) { + $newlist[ $value[ $index_key ] ] = $value[ $field ]; + } else { + $newlist[] = $value[ $field ]; + } + } + } + + $this->output = $newlist; + + return $this->output; + } + + /** + * Sorts the list, based on one or more orderby arguments. + * + * @since 4.7.0 + * + * @param string|array $orderby Optional. Either the field name to order by or an array + * of multiple orderby fields as $orderby => $order. + * @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby + * is a string. + * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. + * @return array The sorted array. + */ + public function sort( $orderby = array(), $order = 'ASC', $preserve_keys = false ) { + if ( empty( $orderby ) ) { + return $this->output; + } + + if ( is_string( $orderby ) ) { + $orderby = array( $orderby => $order ); + } + + foreach ( $orderby as $field => $direction ) { + $orderby[ $field ] = 'DESC' === strtoupper( $direction ) ? 'DESC' : 'ASC'; + } + + $this->orderby = $orderby; + + if ( $preserve_keys ) { + uasort( $this->output, array( $this, 'sort_callback' ) ); + } else { + usort( $this->output, array( $this, 'sort_callback' ) ); + } + + $this->orderby = array(); + + return $this->output; + } + + /** + * Callback to sort the list by specific fields. + * + * @since 4.7.0 + * + * @see WP_List_Util::sort() + * + * @param object|array $a One object to compare. + * @param object|array $b The other object to compare. + * @return int 0 if both objects equal. -1 if second object should come first, 1 otherwise. + */ + private function sort_callback( $a, $b ) { + if ( empty( $this->orderby ) ) { + return 0; + } + + $a = (array) $a; + $b = (array) $b; + + foreach ( $this->orderby as $field => $direction ) { + if ( ! isset( $a[ $field ] ) || ! isset( $b[ $field ] ) ) { + continue; + } + + if ( $a[ $field ] == $b[ $field ] ) { + continue; + } + + $results = 'DESC' === $direction ? array( 1, -1 ) : array( -1, 1 ); + + if ( is_numeric( $a[ $field ] ) && is_numeric( $b[ $field ] ) ) { + return ( $a[ $field ] < $b[ $field ] ) ? $results[0] : $results[1]; + } + + return 0 > strcmp( $a[ $field ], $b[ $field ] ) ? $results[0] : $results[1]; + } + + return 0; + } +} diff --git a/backend/wp-includes/class-wp-locale-switcher.php b/backend/wp-includes/class-wp-locale-switcher.php new file mode 100644 index 0000000..e111892 --- /dev/null +++ b/backend/wp-includes/class-wp-locale-switcher.php @@ -0,0 +1,235 @@ +<?php +/** + * Locale API: WP_Locale_Switcher class + * + * @package WordPress + * @subpackage i18n + * @since 4.7.0 + */ + +/** + * Core class used for switching locales. + * + * @since 4.7.0 + */ +class WP_Locale_Switcher { + /** + * Locale stack. + * + * @since 4.7.0 + * @var string[] + */ + private $locales = array(); + + /** + * Original locale. + * + * @since 4.7.0 + * @var string + */ + private $original_locale; + + /** + * Holds all available languages. + * + * @since 4.7.0 + * @var array An array of language codes (file names without the .mo extension). + */ + private $available_languages = array(); + + /** + * Constructor. + * + * Stores the original locale as well as a list of all available languages. + * + * @since 4.7.0 + */ + public function __construct() { + $this->original_locale = is_admin() ? get_user_locale() : get_locale(); + $this->available_languages = array_merge( array( 'en_US' ), get_available_languages() ); + } + + /** + * Initializes the locale switcher. + * + * Hooks into the {@see 'locale'} filter to change the locale on the fly. + */ + public function init() { + add_filter( 'locale', array( $this, 'filter_locale' ) ); + } + + /** + * Switches the translations according to the given locale. + * + * @since 4.7.0 + * + * @param string $locale The locale to switch to. + * @return bool True on success, false on failure. + */ + public function switch_to_locale( $locale ) { + $current_locale = is_admin() ? get_user_locale() : get_locale(); + if ( $current_locale === $locale ) { + return false; + } + + if ( ! in_array( $locale, $this->available_languages, true ) ) { + return false; + } + + $this->locales[] = $locale; + + $this->change_locale( $locale ); + + /** + * Fires when the locale is switched. + * + * @since 4.7.0 + * + * @param string $locale The new locale. + */ + do_action( 'switch_locale', $locale ); + + return true; + } + + /** + * Restores the translations according to the previous locale. + * + * @since 4.7.0 + * + * @return string|false Locale on success, false on failure. + */ + public function restore_previous_locale() { + $previous_locale = array_pop( $this->locales ); + + if ( null === $previous_locale ) { + // The stack is empty, bail. + return false; + } + + $locale = end( $this->locales ); + + if ( ! $locale ) { + // There's nothing left in the stack: go back to the original locale. + $locale = $this->original_locale; + } + + $this->change_locale( $locale ); + + /** + * Fires when the locale is restored to the previous one. + * + * @since 4.7.0 + * + * @param string $locale The new locale. + * @param string $previous_locale The previous locale. + */ + do_action( 'restore_previous_locale', $locale, $previous_locale ); + + return $locale; + } + + /** + * Restores the translations according to the original locale. + * + * @since 4.7.0 + * + * @return string|false Locale on success, false on failure. + */ + public function restore_current_locale() { + if ( empty( $this->locales ) ) { + return false; + } + + $this->locales = array( $this->original_locale ); + + return $this->restore_previous_locale(); + } + + /** + * Whether switch_to_locale() is in effect. + * + * @since 4.7.0 + * + * @return bool True if the locale has been switched, false otherwise. + */ + public function is_switched() { + return ! empty( $this->locales ); + } + + /** + * Filters the locale of the WordPress installation. + * + * @since 4.7.0 + * + * @param string $locale The locale of the WordPress installation. + * @return string The locale currently being switched to. + */ + public function filter_locale( $locale ) { + $switched_locale = end( $this->locales ); + + if ( $switched_locale ) { + return $switched_locale; + } + + return $locale; + } + + /** + * Load translations for a given locale. + * + * When switching to a locale, translations for this locale must be loaded from scratch. + * + * @since 4.7.0 + * + * @global Mo[] $l10n An array of all currently loaded text domains. + * + * @param string $locale The locale to load translations for. + */ + private function load_translations( $locale ) { + global $l10n; + + $domains = $l10n ? array_keys( $l10n ) : array(); + + load_default_textdomain( $locale ); + + foreach ( $domains as $domain ) { + if ( 'default' === $domain ) { + continue; + } + + unload_textdomain( $domain ); + get_translations_for_domain( $domain ); + } + } + + /** + * Changes the site's locale to the given one. + * + * Loads the translations, changes the global `$wp_locale` object and updates + * all post type labels. + * + * @since 4.7.0 + * + * @global WP_Locale $wp_locale The WordPress date and time locale object. + * + * @param string $locale The locale to change to. + */ + private function change_locale( $locale ) { + // Reset translation availability information. + _get_path_to_translation( null, true ); + + $this->load_translations( $locale ); + + $GLOBALS['wp_locale'] = new WP_Locale(); + + /** + * Fires when the locale is switched to or restored. + * + * @since 4.7.0 + * + * @param string $locale The new locale. + */ + do_action( 'change_locale', $locale ); + } +} diff --git a/backend/wp-includes/class-wp-locale.php b/backend/wp-includes/class-wp-locale.php new file mode 100644 index 0000000..748e54f --- /dev/null +++ b/backend/wp-includes/class-wp-locale.php @@ -0,0 +1,394 @@ +<?php +/** + * Locale API: WP_Locale class + * + * @package WordPress + * @subpackage i18n + * @since 4.6.0 + */ + +/** + * Core class used to store translated data for a locale. + * + * @since 2.1.0 + * @since 4.6.0 Moved to its own file from wp-includes/locale.php. + */ +class WP_Locale { + /** + * Stores the translated strings for the full weekday names. + * + * @since 2.1.0 + * @var array + */ + public $weekday; + + /** + * Stores the translated strings for the one character weekday names. + * + * There is a hack to make sure that Tuesday and Thursday, as well + * as Sunday and Saturday, don't conflict. See init() method for more. + * + * @see WP_Locale::init() for how to handle the hack. + * + * @since 2.1.0 + * @var array + */ + public $weekday_initial; + + /** + * Stores the translated strings for the abbreviated weekday names. + * + * @since 2.1.0 + * @var array + */ + public $weekday_abbrev; + + /** + * Stores the default start of the week. + * + * @since 4.4.0 + * @var string + */ + public $start_of_week; + + /** + * Stores the translated strings for the full month names. + * + * @since 2.1.0 + * @var array + */ + public $month; + + /** + * Stores the translated strings for the month names in genitive case, if the locale specifies. + * + * @since 4.4.0 + * @var array + */ + public $month_genitive; + + /** + * Stores the translated strings for the abbreviated month names. + * + * @since 2.1.0 + * @var array + */ + public $month_abbrev; + + /** + * Stores the translated strings for 'am' and 'pm'. + * + * Also the capitalized versions. + * + * @since 2.1.0 + * @var array + */ + public $meridiem; + + /** + * The text direction of the locale language. + * + * Default is left to right 'ltr'. + * + * @since 2.1.0 + * @var string + */ + public $text_direction = 'ltr'; + + /** + * The thousands separator and decimal point values used for localizing numbers. + * + * @since 2.3.0 + * @var array + */ + public $number_format; + + /** + * Constructor which calls helper methods to set up object variables. + * + * @since 2.1.0 + */ + public function __construct() { + $this->init(); + $this->register_globals(); + } + + /** + * Sets up the translated strings and object properties. + * + * The method creates the translatable strings for various + * calendar elements. Which allows for specifying locale + * specific calendar names and text direction. + * + * @since 2.1.0 + * + * @global string $text_direction + */ + public function init() { + // The Weekdays + $this->weekday[0] = /* translators: weekday */ __('Sunday'); + $this->weekday[1] = /* translators: weekday */ __('Monday'); + $this->weekday[2] = /* translators: weekday */ __('Tuesday'); + $this->weekday[3] = /* translators: weekday */ __('Wednesday'); + $this->weekday[4] = /* translators: weekday */ __('Thursday'); + $this->weekday[5] = /* translators: weekday */ __('Friday'); + $this->weekday[6] = /* translators: weekday */ __('Saturday'); + + // The first letter of each day. + $this->weekday_initial[ __( 'Sunday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Sunday initial' ); + $this->weekday_initial[ __( 'Monday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'M', 'Monday initial' ); + $this->weekday_initial[ __( 'Tuesday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Tuesday initial' ); + $this->weekday_initial[ __( 'Wednesday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'W', 'Wednesday initial' ); + $this->weekday_initial[ __( 'Thursday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Thursday initial' ); + $this->weekday_initial[ __( 'Friday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'F', 'Friday initial' ); + $this->weekday_initial[ __( 'Saturday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Saturday initial' ); + + // Abbreviations for each day. + $this->weekday_abbrev[__('Sunday')] = /* translators: three-letter abbreviation of the weekday */ __('Sun'); + $this->weekday_abbrev[__('Monday')] = /* translators: three-letter abbreviation of the weekday */ __('Mon'); + $this->weekday_abbrev[__('Tuesday')] = /* translators: three-letter abbreviation of the weekday */ __('Tue'); + $this->weekday_abbrev[__('Wednesday')] = /* translators: three-letter abbreviation of the weekday */ __('Wed'); + $this->weekday_abbrev[__('Thursday')] = /* translators: three-letter abbreviation of the weekday */ __('Thu'); + $this->weekday_abbrev[__('Friday')] = /* translators: three-letter abbreviation of the weekday */ __('Fri'); + $this->weekday_abbrev[__('Saturday')] = /* translators: three-letter abbreviation of the weekday */ __('Sat'); + + // The Months + $this->month['01'] = /* translators: month name */ __( 'January' ); + $this->month['02'] = /* translators: month name */ __( 'February' ); + $this->month['03'] = /* translators: month name */ __( 'March' ); + $this->month['04'] = /* translators: month name */ __( 'April' ); + $this->month['05'] = /* translators: month name */ __( 'May' ); + $this->month['06'] = /* translators: month name */ __( 'June' ); + $this->month['07'] = /* translators: month name */ __( 'July' ); + $this->month['08'] = /* translators: month name */ __( 'August' ); + $this->month['09'] = /* translators: month name */ __( 'September' ); + $this->month['10'] = /* translators: month name */ __( 'October' ); + $this->month['11'] = /* translators: month name */ __( 'November' ); + $this->month['12'] = /* translators: month name */ __( 'December' ); + + // The Months, genitive + $this->month_genitive['01'] = /* translators: month name, genitive */ _x( 'January', 'genitive' ); + $this->month_genitive['02'] = /* translators: month name, genitive */ _x( 'February', 'genitive' ); + $this->month_genitive['03'] = /* translators: month name, genitive */ _x( 'March', 'genitive' ); + $this->month_genitive['04'] = /* translators: month name, genitive */ _x( 'April', 'genitive' ); + $this->month_genitive['05'] = /* translators: month name, genitive */ _x( 'May', 'genitive' ); + $this->month_genitive['06'] = /* translators: month name, genitive */ _x( 'June', 'genitive' ); + $this->month_genitive['07'] = /* translators: month name, genitive */ _x( 'July', 'genitive' ); + $this->month_genitive['08'] = /* translators: month name, genitive */ _x( 'August', 'genitive' ); + $this->month_genitive['09'] = /* translators: month name, genitive */ _x( 'September', 'genitive' ); + $this->month_genitive['10'] = /* translators: month name, genitive */ _x( 'October', 'genitive' ); + $this->month_genitive['11'] = /* translators: month name, genitive */ _x( 'November', 'genitive' ); + $this->month_genitive['12'] = /* translators: month name, genitive */ _x( 'December', 'genitive' ); + + // Abbreviations for each month. + $this->month_abbrev[ __( 'January' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Jan', 'January abbreviation' ); + $this->month_abbrev[ __( 'February' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Feb', 'February abbreviation' ); + $this->month_abbrev[ __( 'March' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Mar', 'March abbreviation' ); + $this->month_abbrev[ __( 'April' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Apr', 'April abbreviation' ); + $this->month_abbrev[ __( 'May' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'May', 'May abbreviation' ); + $this->month_abbrev[ __( 'June' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Jun', 'June abbreviation' ); + $this->month_abbrev[ __( 'July' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Jul', 'July abbreviation' ); + $this->month_abbrev[ __( 'August' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Aug', 'August abbreviation' ); + $this->month_abbrev[ __( 'September' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Sep', 'September abbreviation' ); + $this->month_abbrev[ __( 'October' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Oct', 'October abbreviation' ); + $this->month_abbrev[ __( 'November' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Nov', 'November abbreviation' ); + $this->month_abbrev[ __( 'December' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Dec', 'December abbreviation' ); + + // The Meridiems + $this->meridiem['am'] = __('am'); + $this->meridiem['pm'] = __('pm'); + $this->meridiem['AM'] = __('AM'); + $this->meridiem['PM'] = __('PM'); + + // Numbers formatting + // See https://secure.php.net/number_format + + /* translators: $thousands_sep argument for https://secure.php.net/number_format, default is , */ + $thousands_sep = __( 'number_format_thousands_sep' ); + + if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) { + // Replace space with a non-breaking space to avoid wrapping. + $thousands_sep = str_replace( ' ', ' ', $thousands_sep ); + } else { + // PHP < 5.4.0 does not support multiple bytes in thousands separator. + $thousands_sep = str_replace( array( ' ', ' ' ), ' ', $thousands_sep ); + } + + $this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep; + + /* translators: $dec_point argument for https://secure.php.net/number_format, default is . */ + $decimal_point = __( 'number_format_decimal_point' ); + + $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point; + + // Set text direction. + if ( isset( $GLOBALS['text_direction'] ) ) + $this->text_direction = $GLOBALS['text_direction']; + /* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */ + elseif ( 'rtl' == _x( 'ltr', 'text direction' ) ) + $this->text_direction = 'rtl'; + + if ( 'rtl' === $this->text_direction && strpos( get_bloginfo( 'version' ), '-src' ) ) { + $this->text_direction = 'ltr'; + add_action( 'all_admin_notices', array( $this, 'rtl_src_admin_notice' ) ); + } + } + + /** + * Outputs an admin notice if the /build directory must be used for RTL. + * + * @since 3.8.0 + */ + public function rtl_src_admin_notice() { + /* translators: %s: Name of the directory (build) */ + echo '<div class="error"><p>' . sprintf( __( 'The %s directory of the develop repository must be used for RTL.' ), '<code>build</code>' ) . '</p></div>'; + } + + /** + * Retrieve the full translated weekday word. + * + * Week starts on translated Sunday and can be fetched + * by using 0 (zero). So the week starts with 0 (zero) + * and ends on Saturday with is fetched by using 6 (six). + * + * @since 2.1.0 + * + * @param int $weekday_number 0 for Sunday through 6 Saturday + * @return string Full translated weekday + */ + public function get_weekday($weekday_number) { + return $this->weekday[$weekday_number]; + } + + /** + * Retrieve the translated weekday initial. + * + * The weekday initial is retrieved by the translated + * full weekday word. When translating the weekday initial + * pay attention to make sure that the starting letter does + * not conflict. + * + * @since 2.1.0 + * + * @param string $weekday_name + * @return string + */ + public function get_weekday_initial($weekday_name) { + return $this->weekday_initial[$weekday_name]; + } + + /** + * Retrieve the translated weekday abbreviation. + * + * The weekday abbreviation is retrieved by the translated + * full weekday word. + * + * @since 2.1.0 + * + * @param string $weekday_name Full translated weekday word + * @return string Translated weekday abbreviation + */ + public function get_weekday_abbrev($weekday_name) { + return $this->weekday_abbrev[$weekday_name]; + } + + /** + * Retrieve the full translated month by month number. + * + * The $month_number parameter has to be a string + * because it must have the '0' in front of any number + * that is less than 10. Starts from '01' and ends at + * '12'. + * + * You can use an integer instead and it will add the + * '0' before the numbers less than 10 for you. + * + * @since 2.1.0 + * + * @param string|int $month_number '01' through '12' + * @return string Translated full month name + */ + public function get_month($month_number) { + return $this->month[zeroise($month_number, 2)]; + } + + /** + * Retrieve translated version of month abbreviation string. + * + * The $month_name parameter is expected to be the translated or + * translatable version of the month. + * + * @since 2.1.0 + * + * @param string $month_name Translated month to get abbreviated version + * @return string Translated abbreviated month + */ + public function get_month_abbrev($month_name) { + return $this->month_abbrev[$month_name]; + } + + /** + * Retrieve translated version of meridiem string. + * + * The $meridiem parameter is expected to not be translated. + * + * @since 2.1.0 + * + * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. + * @return string Translated version + */ + public function get_meridiem($meridiem) { + return $this->meridiem[$meridiem]; + } + + /** + * Global variables are deprecated. + * + * For backward compatibility only. + * + * @deprecated For backward compatibility only. + * + * @global array $weekday + * @global array $weekday_initial + * @global array $weekday_abbrev + * @global array $month + * @global array $month_abbrev + * + * @since 2.1.0 + */ + public function register_globals() { + $GLOBALS['weekday'] = $this->weekday; + $GLOBALS['weekday_initial'] = $this->weekday_initial; + $GLOBALS['weekday_abbrev'] = $this->weekday_abbrev; + $GLOBALS['month'] = $this->month; + $GLOBALS['month_abbrev'] = $this->month_abbrev; + } + + /** + * Checks if current locale is RTL. + * + * @since 3.0.0 + * @return bool Whether locale is RTL. + */ + public function is_rtl() { + return 'rtl' == $this->text_direction; + } + + /** + * Register date/time format strings for general POT. + * + * Private, unused method to add some date/time formats translated + * on wp-admin/options-general.php to the general POT that would + * otherwise be added to the admin POT. + * + * @since 3.6.0 + */ + public function _strings_for_pot() { + /* translators: localized date format, see https://secure.php.net/date */ + __( 'F j, Y' ); + /* translators: localized time format, see https://secure.php.net/date */ + __( 'g:i a' ); + /* translators: localized date and time format, see https://secure.php.net/date */ + __( 'F j, Y g:i a' ); + } +} diff --git a/backend/wp-includes/class-wp-matchesmapregex.php b/backend/wp-includes/class-wp-matchesmapregex.php new file mode 100644 index 0000000..4557783 --- /dev/null +++ b/backend/wp-includes/class-wp-matchesmapregex.php @@ -0,0 +1,91 @@ +<?php +/** + * WP_MatchesMapRegex helper class + * + * @package WordPress + * @since 4.7.0 + */ + +/** + * Helper class to remove the need to use eval to replace $matches[] in query strings. + * + * @since 2.9.0 + */ +class WP_MatchesMapRegex { + /** + * store for matches + * + * @var array + */ + private $_matches; + + /** + * store for mapping result + * + * @var string + */ + public $output; + + /** + * subject to perform mapping on (query string containing $matches[] references + * + * @var string + */ + private $_subject; + + /** + * regexp pattern to match $matches[] references + * + * @var string + */ + public $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number + + /** + * constructor + * + * @param string $subject subject if regex + * @param array $matches data to use in map + */ + public function __construct($subject, $matches) { + $this->_subject = $subject; + $this->_matches = $matches; + $this->output = $this->_map(); + } + + /** + * Substitute substring matches in subject. + * + * static helper function to ease use + * + * @static + * + * @param string $subject subject + * @param array $matches data used for substitution + * @return string + */ + public static function apply($subject, $matches) { + $oSelf = new WP_MatchesMapRegex($subject, $matches); + return $oSelf->output; + } + + /** + * do the actual mapping + * + * @return string + */ + private function _map() { + $callback = array($this, 'callback'); + return preg_replace_callback($this->_pattern, $callback, $this->_subject); + } + + /** + * preg_replace_callback hook + * + * @param array $matches preg_replace regexp matches + * @return string + */ + public function callback($matches) { + $index = intval(substr($matches[0], 9, -1)); + return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' ); + } +} diff --git a/backend/wp-includes/class-wp-meta-query.php b/backend/wp-includes/class-wp-meta-query.php new file mode 100644 index 0000000..af1fc11 --- /dev/null +++ b/backend/wp-includes/class-wp-meta-query.php @@ -0,0 +1,730 @@ +<?php +/** + * Meta API: WP_Meta_Query class + * + * @package WordPress + * @subpackage Meta + * @since 4.4.0 + */ + +/** + * Core class used to implement meta queries for the Meta API. + * + * Used for generating SQL clauses that filter a primary query according to metadata keys and values. + * + * WP_Meta_Query is a helper that allows primary query classes, such as WP_Query and WP_User_Query, + * + * to filter their results by object metadata, by generating `JOIN` and `WHERE` subclauses to be attached + * to the primary SQL query string. + * + * @since 3.2.0 + */ +class WP_Meta_Query { + /** + * Array of metadata queries. + * + * See WP_Meta_Query::__construct() for information on meta query arguments. + * + * @since 3.2.0 + * @var array + */ + public $queries = array(); + + /** + * The relation between the queries. Can be one of 'AND' or 'OR'. + * + * @since 3.2.0 + * @var string + */ + public $relation; + + /** + * Database table to query for the metadata. + * + * @since 4.1.0 + * @var string + */ + public $meta_table; + + /** + * Column in meta_table that represents the ID of the object the metadata belongs to. + * + * @since 4.1.0 + * @var string + */ + public $meta_id_column; + + /** + * Database table that where the metadata's objects are stored (eg $wpdb->users). + * + * @since 4.1.0 + * @var string + */ + public $primary_table; + + /** + * Column in primary_table that represents the ID of the object. + * + * @since 4.1.0 + * @var string + */ + public $primary_id_column; + + /** + * A flat list of table aliases used in JOIN clauses. + * + * @since 4.1.0 + * @var array + */ + protected $table_aliases = array(); + + /** + * A flat list of clauses, keyed by clause 'name'. + * + * @since 4.2.0 + * @var array + */ + protected $clauses = array(); + + /** + * Whether the query contains any OR relations. + * + * @since 4.3.0 + * @var bool + */ + protected $has_or_relation = false; + + /** + * Constructor. + * + * @since 3.2.0 + * @since 4.2.0 Introduced support for naming query clauses by associative array keys. + * + * + * @param array $meta_query { + * Array of meta query clauses. When first-order clauses or sub-clauses use strings as + * their array keys, they may be referenced in the 'orderby' parameter of the parent query. + * + * @type string $relation Optional. The MySQL keyword used to join + * the clauses of the query. Accepts 'AND', or 'OR'. Default 'AND'. + * @type array { + * Optional. An array of first-order clause parameters, or another fully-formed meta query. + * + * @type string $key Meta key to filter by. + * @type string $value Meta value to filter by. + * @type string $compare MySQL operator used for comparing the $value. Accepts '=', + * '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', + * 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'REGEXP', + * 'NOT REGEXP', 'RLIKE', 'EXISTS' or 'NOT EXISTS'. + * Default is 'IN' when `$value` is an array, '=' otherwise. + * @type string $type MySQL data type that the meta_value column will be CAST to for + * comparisons. Accepts 'NUMERIC', 'BINARY', 'CHAR', 'DATE', + * 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', or 'UNSIGNED'. + * Default is 'CHAR'. + * } + * } + */ + public function __construct( $meta_query = false ) { + if ( !$meta_query ) + return; + + if ( isset( $meta_query['relation'] ) && strtoupper( $meta_query['relation'] ) == 'OR' ) { + $this->relation = 'OR'; + } else { + $this->relation = 'AND'; + } + + $this->queries = $this->sanitize_query( $meta_query ); + } + + /** + * Ensure the 'meta_query' argument passed to the class constructor is well-formed. + * + * Eliminates empty items and ensures that a 'relation' is set. + * + * @since 4.1.0 + * + * @param array $queries Array of query clauses. + * @return array Sanitized array of query clauses. + */ + public function sanitize_query( $queries ) { + $clean_queries = array(); + + if ( ! is_array( $queries ) ) { + return $clean_queries; + } + + foreach ( $queries as $key => $query ) { + if ( 'relation' === $key ) { + $relation = $query; + + } elseif ( ! is_array( $query ) ) { + continue; + + // First-order clause. + } elseif ( $this->is_first_order_clause( $query ) ) { + if ( isset( $query['value'] ) && array() === $query['value'] ) { + unset( $query['value'] ); + } + + $clean_queries[ $key ] = $query; + + // Otherwise, it's a nested query, so we recurse. + } else { + $cleaned_query = $this->sanitize_query( $query ); + + if ( ! empty( $cleaned_query ) ) { + $clean_queries[ $key ] = $cleaned_query; + } + } + } + + if ( empty( $clean_queries ) ) { + return $clean_queries; + } + + // Sanitize the 'relation' key provided in the query. + if ( isset( $relation ) && 'OR' === strtoupper( $relation ) ) { + $clean_queries['relation'] = 'OR'; + $this->has_or_relation = true; + + /* + * If there is only a single clause, call the relation 'OR'. + * This value will not actually be used to join clauses, but it + * simplifies the logic around combining key-only queries. + */ + } elseif ( 1 === count( $clean_queries ) ) { + $clean_queries['relation'] = 'OR'; + + // Default to AND. + } else { + $clean_queries['relation'] = 'AND'; + } + + return $clean_queries; + } + + /** + * Determine whether a query clause is first-order. + * + * A first-order meta query clause is one that has either a 'key' or + * a 'value' array key. + * + * @since 4.1.0 + * + * @param array $query Meta query arguments. + * @return bool Whether the query clause is a first-order clause. + */ + protected function is_first_order_clause( $query ) { + return isset( $query['key'] ) || isset( $query['value'] ); + } + + /** + * Constructs a meta query based on 'meta_*' query vars + * + * @since 3.2.0 + * + * @param array $qv The query variables + */ + public function parse_query_vars( $qv ) { + $meta_query = array(); + + /* + * For orderby=meta_value to work correctly, simple query needs to be + * first (so that its table join is against an unaliased meta table) and + * needs to be its own clause (so it doesn't interfere with the logic of + * the rest of the meta_query). + */ + $primary_meta_query = array(); + foreach ( array( 'key', 'compare', 'type' ) as $key ) { + if ( ! empty( $qv[ "meta_$key" ] ) ) { + $primary_meta_query[ $key ] = $qv[ "meta_$key" ]; + } + } + + // WP_Query sets 'meta_value' = '' by default. + if ( isset( $qv['meta_value'] ) && '' !== $qv['meta_value'] && ( ! is_array( $qv['meta_value'] ) || $qv['meta_value'] ) ) { + $primary_meta_query['value'] = $qv['meta_value']; + } + + $existing_meta_query = isset( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ? $qv['meta_query'] : array(); + + if ( ! empty( $primary_meta_query ) && ! empty( $existing_meta_query ) ) { + $meta_query = array( + 'relation' => 'AND', + $primary_meta_query, + $existing_meta_query, + ); + } elseif ( ! empty( $primary_meta_query ) ) { + $meta_query = array( + $primary_meta_query, + ); + } elseif ( ! empty( $existing_meta_query ) ) { + $meta_query = $existing_meta_query; + } + + $this->__construct( $meta_query ); + } + + /** + * Return the appropriate alias for the given meta type if applicable. + * + * @since 3.7.0 + * + * @param string $type MySQL type to cast meta_value. + * @return string MySQL type. + */ + public function get_cast_for_type( $type = '' ) { + if ( empty( $type ) ) + return 'CHAR'; + + $meta_type = strtoupper( $type ); + + if ( ! preg_match( '/^(?:BINARY|CHAR|DATE|DATETIME|SIGNED|UNSIGNED|TIME|NUMERIC(?:\(\d+(?:,\s?\d+)?\))?|DECIMAL(?:\(\d+(?:,\s?\d+)?\))?)$/', $meta_type ) ) + return 'CHAR'; + + if ( 'NUMERIC' == $meta_type ) + $meta_type = 'SIGNED'; + + return $meta_type; + } + + /** + * Generates SQL clauses to be appended to a main query. + * + * @since 3.2.0 + * + * @param string $type Type of meta, eg 'user', 'post'. + * @param string $primary_table Database table where the object being filtered is stored (eg wp_users). + * @param string $primary_id_column ID column for the filtered object in $primary_table. + * @param object $context Optional. The main query object. + * @return false|array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + public function get_sql( $type, $primary_table, $primary_id_column, $context = null ) { + if ( ! $meta_table = _get_meta_table( $type ) ) { + return false; + } + + $this->table_aliases = array(); + + $this->meta_table = $meta_table; + $this->meta_id_column = sanitize_key( $type . '_id' ); + + $this->primary_table = $primary_table; + $this->primary_id_column = $primary_id_column; + + $sql = $this->get_sql_clauses(); + + /* + * If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should + * be LEFT. Otherwise posts with no metadata will be excluded from results. + */ + if ( false !== strpos( $sql['join'], 'LEFT JOIN' ) ) { + $sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] ); + } + + /** + * Filters the meta query's generated SQL. + * + * @since 3.1.0 + * + * @param array $clauses Array containing the query's JOIN and WHERE clauses. + * @param array $queries Array of meta queries. + * @param string $type Type of meta. + * @param string $primary_table Primary table. + * @param string $primary_id_column Primary column ID. + * @param object $context The main query object. + */ + return apply_filters_ref_array( 'get_meta_sql', array( $sql, $this->queries, $type, $primary_table, $primary_id_column, $context ) ); + } + + /** + * Generate SQL clauses to be appended to a main query. + * + * Called by the public WP_Meta_Query::get_sql(), this method is abstracted + * out to maintain parity with the other Query classes. + * + * @since 4.1.0 + * + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_clauses() { + /* + * $queries are passed by reference to get_sql_for_query() for recursion. + * To keep $this->queries unaltered, pass a copy. + */ + $queries = $this->queries; + $sql = $this->get_sql_for_query( $queries ); + + if ( ! empty( $sql['where'] ) ) { + $sql['where'] = ' AND ' . $sql['where']; + } + + return $sql; + } + + /** + * Generate SQL clauses for a single query array. + * + * If nested subqueries are found, this method recurses the tree to + * produce the properly nested SQL. + * + * @since 4.1.0 + * + * @param array $query Query to parse (passed by reference). + * @param int $depth Optional. Number of tree levels deep we currently are. + * Used to calculate indentation. Default 0. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to a single query array. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_for_query( &$query, $depth = 0 ) { + $sql_chunks = array( + 'join' => array(), + 'where' => array(), + ); + + $sql = array( + 'join' => '', + 'where' => '', + ); + + $indent = ''; + for ( $i = 0; $i < $depth; $i++ ) { + $indent .= " "; + } + + foreach ( $query as $key => &$clause ) { + if ( 'relation' === $key ) { + $relation = $query['relation']; + } elseif ( is_array( $clause ) ) { + + // This is a first-order clause. + if ( $this->is_first_order_clause( $clause ) ) { + $clause_sql = $this->get_sql_for_clause( $clause, $query, $key ); + + $where_count = count( $clause_sql['where'] ); + if ( ! $where_count ) { + $sql_chunks['where'][] = ''; + } elseif ( 1 === $where_count ) { + $sql_chunks['where'][] = $clause_sql['where'][0]; + } else { + $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; + } + + $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); + // This is a subquery, so we recurse. + } else { + $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); + + $sql_chunks['where'][] = $clause_sql['where']; + $sql_chunks['join'][] = $clause_sql['join']; + } + } + } + + // Filter to remove empties. + $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); + $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); + + if ( empty( $relation ) ) { + $relation = 'AND'; + } + + // Filter duplicate JOIN clauses and combine into a single string. + if ( ! empty( $sql_chunks['join'] ) ) { + $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); + } + + // Generate a single WHERE clause with proper brackets and indentation. + if ( ! empty( $sql_chunks['where'] ) ) { + $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; + } + + return $sql; + } + + /** + * Generate SQL JOIN and WHERE clauses for a first-order query clause. + * + * "First-order" means that it's an array with a 'key' or 'value'. + * + * @since 4.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $clause Query clause (passed by reference). + * @param array $parent_query Parent query array. + * @param string $clause_key Optional. The array key used to name the clause in the original `$meta_query` + * parameters. If not provided, a key will be generated automatically. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to a first-order query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) { + global $wpdb; + + $sql_chunks = array( + 'where' => array(), + 'join' => array(), + ); + + if ( isset( $clause['compare'] ) ) { + $clause['compare'] = strtoupper( $clause['compare'] ); + } else { + $clause['compare'] = isset( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '='; + } + + if ( ! in_array( $clause['compare'], array( + '=', '!=', '>', '>=', '<', '<=', + 'LIKE', 'NOT LIKE', + 'IN', 'NOT IN', + 'BETWEEN', 'NOT BETWEEN', + 'EXISTS', 'NOT EXISTS', + 'REGEXP', 'NOT REGEXP', 'RLIKE' + ) ) ) { + $clause['compare'] = '='; + } + + $meta_compare = $clause['compare']; + + // First build the JOIN clause, if one is required. + $join = ''; + + // We prefer to avoid joins if possible. Look for an existing join compatible with this clause. + $alias = $this->find_compatible_table_alias( $clause, $parent_query ); + if ( false === $alias ) { + $i = count( $this->table_aliases ); + $alias = $i ? 'mt' . $i : $this->meta_table; + + // JOIN clauses for NOT EXISTS have their own syntax. + if ( 'NOT EXISTS' === $meta_compare ) { + $join .= " LEFT JOIN $this->meta_table"; + $join .= $i ? " AS $alias" : ''; + $join .= $wpdb->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] ); + + // All other JOIN clauses. + } else { + $join .= " INNER JOIN $this->meta_table"; + $join .= $i ? " AS $alias" : ''; + $join .= " ON ( $this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column )"; + } + + $this->table_aliases[] = $alias; + $sql_chunks['join'][] = $join; + } + + // Save the alias to this clause, for future siblings to find. + $clause['alias'] = $alias; + + // Determine the data type. + $_meta_type = isset( $clause['type'] ) ? $clause['type'] : ''; + $meta_type = $this->get_cast_for_type( $_meta_type ); + $clause['cast'] = $meta_type; + + // Fallback for clause keys is the table alias. Key must be a string. + if ( is_int( $clause_key ) || ! $clause_key ) { + $clause_key = $clause['alias']; + } + + // Ensure unique clause keys, so none are overwritten. + $iterator = 1; + $clause_key_base = $clause_key; + while ( isset( $this->clauses[ $clause_key ] ) ) { + $clause_key = $clause_key_base . '-' . $iterator; + $iterator++; + } + + // Store the clause in our flat array. + $this->clauses[ $clause_key ] =& $clause; + + // Next, build the WHERE clause. + + // meta_key. + if ( array_key_exists( 'key', $clause ) ) { + if ( 'NOT EXISTS' === $meta_compare ) { + $sql_chunks['where'][] = $alias . '.' . $this->meta_id_column . ' IS NULL'; + } else { + $sql_chunks['where'][] = $wpdb->prepare( "$alias.meta_key = %s", trim( $clause['key'] ) ); + } + } + + // meta_value. + if ( array_key_exists( 'value', $clause ) ) { + $meta_value = $clause['value']; + + if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { + if ( ! is_array( $meta_value ) ) { + $meta_value = preg_split( '/[,\s]+/', $meta_value ); + } + } else { + $meta_value = trim( $meta_value ); + } + + switch ( $meta_compare ) { + case 'IN' : + case 'NOT IN' : + $meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')'; + $where = $wpdb->prepare( $meta_compare_string, $meta_value ); + break; + + case 'BETWEEN' : + case 'NOT BETWEEN' : + $meta_value = array_slice( $meta_value, 0, 2 ); + $where = $wpdb->prepare( '%s AND %s', $meta_value ); + break; + + case 'LIKE' : + case 'NOT LIKE' : + $meta_value = '%' . $wpdb->esc_like( $meta_value ) . '%'; + $where = $wpdb->prepare( '%s', $meta_value ); + break; + + // EXISTS with a value is interpreted as '='. + case 'EXISTS' : + $meta_compare = '='; + $where = $wpdb->prepare( '%s', $meta_value ); + break; + + // 'value' is ignored for NOT EXISTS. + case 'NOT EXISTS' : + $where = ''; + break; + + default : + $where = $wpdb->prepare( '%s', $meta_value ); + break; + + } + + if ( $where ) { + if ( 'CHAR' === $meta_type ) { + $sql_chunks['where'][] = "$alias.meta_value {$meta_compare} {$where}"; + } else { + $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; + } + } + } + + /* + * Multiple WHERE clauses (for meta_key and meta_value) should + * be joined in parentheses. + */ + if ( 1 < count( $sql_chunks['where'] ) ) { + $sql_chunks['where'] = array( '( ' . implode( ' AND ', $sql_chunks['where'] ) . ' )' ); + } + + return $sql_chunks; + } + + /** + * Get a flattened list of sanitized meta clauses. + * + * This array should be used for clause lookup, as when the table alias and CAST type must be determined for + * a value of 'orderby' corresponding to a meta clause. + * + * @since 4.2.0 + * + * @return array Meta clauses. + */ + public function get_clauses() { + return $this->clauses; + } + + /** + * Identify an existing table alias that is compatible with the current + * query clause. + * + * We avoid unnecessary table joins by allowing each clause to look for + * an existing table alias that is compatible with the query that it + * needs to perform. + * + * An existing alias is compatible if (a) it is a sibling of `$clause` + * (ie, it's under the scope of the same relation), and (b) the combination + * of operator and relation between the clauses allows for a shared table join. + * In the case of WP_Meta_Query, this only applies to 'IN' clauses that are + * connected by the relation 'OR'. + * + * @since 4.1.0 + * + * @param array $clause Query clause. + * @param array $parent_query Parent query of $clause. + * @return string|bool Table alias if found, otherwise false. + */ + protected function find_compatible_table_alias( $clause, $parent_query ) { + $alias = false; + + foreach ( $parent_query as $sibling ) { + // If the sibling has no alias yet, there's nothing to check. + if ( empty( $sibling['alias'] ) ) { + continue; + } + + // We're only interested in siblings that are first-order clauses. + if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) { + continue; + } + + $compatible_compares = array(); + + // Clauses connected by OR can share joins as long as they have "positive" operators. + if ( 'OR' === $parent_query['relation'] ) { + $compatible_compares = array( '=', 'IN', 'BETWEEN', 'LIKE', 'REGEXP', 'RLIKE', '>', '>=', '<', '<=' ); + + // Clauses joined by AND with "negative" operators share a join only if they also share a key. + } elseif ( isset( $sibling['key'] ) && isset( $clause['key'] ) && $sibling['key'] === $clause['key'] ) { + $compatible_compares = array( '!=', 'NOT IN', 'NOT LIKE' ); + } + + $clause_compare = strtoupper( $clause['compare'] ); + $sibling_compare = strtoupper( $sibling['compare'] ); + if ( in_array( $clause_compare, $compatible_compares ) && in_array( $sibling_compare, $compatible_compares ) ) { + $alias = $sibling['alias']; + break; + } + } + + /** + * Filters the table alias identified as compatible with the current clause. + * + * @since 4.1.0 + * + * @param string|bool $alias Table alias, or false if none was found. + * @param array $clause First-order query clause. + * @param array $parent_query Parent of $clause. + * @param object $this WP_Meta_Query object. + */ + return apply_filters( 'meta_query_find_compatible_table_alias', $alias, $clause, $parent_query, $this ) ; + } + + /** + * Checks whether the current query has any OR relations. + * + * In some cases, the presence of an OR relation somewhere in the query will require + * the use of a `DISTINCT` or `GROUP BY` keyword in the `SELECT` clause. The current + * method can be used in these cases to determine whether such a clause is necessary. + * + * @since 4.3.0 + * + * @return bool True if the query contains any `OR` relations, otherwise false. + */ + public function has_or_relation() { + return $this->has_or_relation; + } +} diff --git a/backend/wp-includes/class-wp-metadata-lazyloader.php b/backend/wp-includes/class-wp-metadata-lazyloader.php new file mode 100644 index 0000000..284bfb9 --- /dev/null +++ b/backend/wp-includes/class-wp-metadata-lazyloader.php @@ -0,0 +1,170 @@ +<?php +/** + * Meta API: WP_Metadata_Lazyloader class + * + * @package WordPress + * @subpackage Meta + * @since 4.5.0 + */ + +/** + * Core class used for lazy-loading object metadata. + * + * When loading many objects of a given type, such as posts in a WP_Query loop, it often makes + * sense to prime various metadata caches at the beginning of the loop. This means fetching all + * relevant metadata with a single database query, a technique that has the potential to improve + * performance dramatically in some cases. + * + * In cases where the given metadata may not even be used in the loop, we can improve performance + * even more by only priming the metadata cache for affected items the first time a piece of metadata + * is requested - ie, by lazy-loading it. So, for example, comment meta may not be loaded into the + * cache in the comments section of a post until the first time get_comment_meta() is called in the + * context of the comment loop. + * + * WP uses the WP_Metadata_Lazyloader class to queue objects for metadata cache priming. The class + * then detects the relevant get_*_meta() function call, and queries the metadata of all queued objects. + * + * Do not access this class directly. Use the wp_metadata_lazyloader() function. + * + * @since 4.5.0 + */ +class WP_Metadata_Lazyloader { + /** + * Pending objects queue. + * + * @since 4.5.0 + * @var array + */ + protected $pending_objects; + + /** + * Settings for supported object types. + * + * @since 4.5.0 + * @var array + */ + protected $settings = array(); + + /** + * Constructor. + * + * @since 4.5.0 + */ + public function __construct() { + $this->settings = array( + 'term' => array( + 'filter' => 'get_term_metadata', + 'callback' => array( $this, 'lazyload_term_meta' ), + ), + 'comment' => array( + 'filter' => 'get_comment_metadata', + 'callback' => array( $this, 'lazyload_comment_meta' ), + ), + ); + } + + /** + * Adds objects to the metadata lazy-load queue. + * + * @since 4.5.0 + * + * @param string $object_type Type of object whose meta is to be lazy-loaded. Accepts 'term' or 'comment'. + * @param array $object_ids Array of object IDs. + * @return bool|WP_Error True on success, WP_Error on failure. + */ + public function queue_objects( $object_type, $object_ids ) { + if ( ! isset( $this->settings[ $object_type ] ) ) { + return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); + } + + $type_settings = $this->settings[ $object_type ]; + + if ( ! isset( $this->pending_objects[ $object_type ] ) ) { + $this->pending_objects[ $object_type ] = array(); + } + + foreach ( $object_ids as $object_id ) { + // Keyed by ID for faster lookup. + if ( ! isset( $this->pending_objects[ $object_type ][ $object_id ] ) ) { + $this->pending_objects[ $object_type ][ $object_id ] = 1; + } + } + + add_filter( $type_settings['filter'], $type_settings['callback'] ); + + /** + * Fires after objects are added to the metadata lazy-load queue. + * + * @since 4.5.0 + * + * @param array $object_ids Object IDs. + * @param string $object_type Type of object being queued. + * @param WP_Metadata_Lazyloader $lazyloader The lazy-loader object. + */ + do_action( 'metadata_lazyloader_queued_objects', $object_ids, $object_type, $this ); + } + + /** + * Resets lazy-load queue for a given object type. + * + * @since 4.5.0 + * + * @param string $object_type Object type. Accepts 'comment' or 'term'. + * @return bool|WP_Error True on success, WP_Error on failure. + */ + public function reset_queue( $object_type ) { + if ( ! isset( $this->settings[ $object_type ] ) ) { + return new WP_Error( 'invalid_object_type', __( 'Invalid object type' ) ); + } + + $type_settings = $this->settings[ $object_type ]; + + $this->pending_objects[ $object_type ] = array(); + remove_filter( $type_settings['filter'], $type_settings['callback'] ); + } + + /** + * Lazy-loads term meta for queued terms. + * + * This method is public so that it can be used as a filter callback. As a rule, there + * is no need to invoke it directly. + * + * @since 4.5.0 + * + * @param mixed $check The `$check` param passed from the 'get_term_metadata' hook. + * @return mixed In order not to short-circuit `get_metadata()`. Generally, this is `null`, but it could be + * another value if filtered by a plugin. + */ + public function lazyload_term_meta( $check ) { + if ( ! empty( $this->pending_objects['term'] ) ) { + update_termmeta_cache( array_keys( $this->pending_objects['term'] ) ); + + // No need to run again for this set of terms. + $this->reset_queue( 'term' ); + } + + return $check; + } + + /** + * Lazy-loads comment meta for queued comments. + * + * This method is public so that it can be used as a filter callback. As a rule, there is no need to invoke it + * directly, from either inside or outside the `WP_Query` object. + * + * @since 4.5.0 + * + * @param mixed $check The `$check` param passed from the {@see 'get_comment_metadata'} hook. + * @return mixed The original value of `$check`, so as not to short-circuit `get_comment_metadata()`. + */ + public function lazyload_comment_meta( $check ) { + if ( ! empty( $this->pending_objects['comment'] ) ) { + update_meta_cache( 'comment', array_keys( $this->pending_objects['comment'] ) ); + + // No need to run again for this set of comments. + $this->reset_queue( 'comment' ); + } + + return $check; + } +} diff --git a/backend/wp-includes/class-wp-network-query.php b/backend/wp-includes/class-wp-network-query.php new file mode 100644 index 0000000..f8ca48f --- /dev/null +++ b/backend/wp-includes/class-wp-network-query.php @@ -0,0 +1,552 @@ +<?php +/** + * Network API: WP_Network_Query class + * + * @package WordPress + * @subpackage Multisite + * @since 4.6.0 + */ + +/** + * Core class used for querying networks. + * + * @since 4.6.0 + * + * @see WP_Network_Query::__construct() for accepted arguments. + */ +class WP_Network_Query { + + /** + * SQL for database query. + * + * @since 4.6.0 + * @var string + */ + public $request; + + /** + * SQL query clauses. + * + * @since 4.6.0 + * @var array + */ + protected $sql_clauses = array( + 'select' => '', + 'from' => '', + 'where' => array(), + 'groupby' => '', + 'orderby' => '', + 'limits' => '', + ); + + /** + * Query vars set by the user. + * + * @since 4.6.0 + * @var array + */ + public $query_vars; + + /** + * Default values for query vars. + * + * @since 4.6.0 + * @var array + */ + public $query_var_defaults; + + /** + * List of networks located by the query. + * + * @since 4.6.0 + * @var array + */ + public $networks; + + /** + * The amount of found networks for the current query. + * + * @since 4.6.0 + * @var int + */ + public $found_networks = 0; + + /** + * The number of pages. + * + * @since 4.6.0 + * @var int + */ + public $max_num_pages = 0; + + /** + * Constructor. + * + * Sets up the network query, based on the query vars passed. + * + * @since 4.6.0 + * + * @param string|array $query { + * Optional. Array or query string of network query parameters. Default empty. + * + * @type array $network__in Array of network IDs to include. Default empty. + * @type array $network__not_in Array of network IDs to exclude. Default empty. + * @type bool $count Whether to return a network count (true) or array of network objects. + * Default false. + * @type string $fields Network fields to return. Accepts 'ids' (returns an array of network IDs) + * or empty (returns an array of complete network objects). Default empty. + * @type int $number Maximum number of networks to retrieve. Default empty (no limit). + * @type int $offset Number of networks to offset the query. Used to build LIMIT clause. + * Default 0. + * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. + * @type string|array $orderby Network status or array of statuses. Accepts 'id', 'domain', 'path', + * 'domain_length', 'path_length' and 'network__in'. Also accepts false, + * an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'. + * @type string $order How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'. + * @type string $domain Limit results to those affiliated with a given domain. Default empty. + * @type array $domain__in Array of domains to include affiliated networks for. Default empty. + * @type array $domain__not_in Array of domains to exclude affiliated networks for. Default empty. + * @type string $path Limit results to those affiliated with a given path. Default empty. + * @type array $path__in Array of paths to include affiliated networks for. Default empty. + * @type array $path__not_in Array of paths to exclude affiliated networks for. Default empty. + * @type string $search Search term(s) to retrieve matching networks for. Default empty. + * @type bool $update_network_cache Whether to prime the cache for found networks. Default true. + * } + */ + public function __construct( $query = '' ) { + $this->query_var_defaults = array( + 'network__in' => '', + 'network__not_in' => '', + 'count' => false, + 'fields' => '', + 'number' => '', + 'offset' => '', + 'no_found_rows' => true, + 'orderby' => 'id', + 'order' => 'ASC', + 'domain' => '', + 'domain__in' => '', + 'domain__not_in' => '', + 'path' => '', + 'path__in' => '', + 'path__not_in' => '', + 'search' => '', + 'update_network_cache' => true, + ); + + if ( ! empty( $query ) ) { + $this->query( $query ); + } + } + + /** + * Parses arguments passed to the network query with default query parameters. + * + * @since 4.6.0 + * + * + * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct() + */ + public function parse_query( $query = '' ) { + if ( empty( $query ) ) { + $query = $this->query_vars; + } + + $this->query_vars = wp_parse_args( $query, $this->query_var_defaults ); + + /** + * Fires after the network query vars have been parsed. + * + * @since 4.6.0 + * + * @param WP_Network_Query $this The WP_Network_Query instance (passed by reference). + */ + do_action_ref_array( 'parse_network_query', array( &$this ) ); + } + + /** + * Sets up the WordPress query for retrieving networks. + * + * @since 4.6.0 + * + * @param string|array $query Array or URL query string of parameters. + * @return array|int List of WP_Network objects, a list of network ids when 'fields' is set to 'ids', + * or the number of networks when 'count' is passed as a query var. + */ + public function query( $query ) { + $this->query_vars = wp_parse_args( $query ); + return $this->get_networks(); + } + + /** + * Gets a list of networks matching the query vars. + * + * @since 4.6.0 + * + * @return array|int List of WP_Network objects, a list of network ids when 'fields' is set to 'ids', + * or the number of networks when 'count' is passed as a query var. + */ + public function get_networks() { + $this->parse_query(); + + /** + * Fires before networks are retrieved. + * + * @since 4.6.0 + * + * @param WP_Network_Query $this Current instance of WP_Network_Query (passed by reference). + */ + do_action_ref_array( 'pre_get_networks', array( &$this ) ); + + // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. + $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); + + // Ignore the $fields argument as the queried result will be the same regardless. + unset( $_args['fields'] ); + + $key = md5( serialize( $_args ) ); + $last_changed = wp_cache_get_last_changed( 'networks' ); + + $cache_key = "get_network_ids:$key:$last_changed"; + $cache_value = wp_cache_get( $cache_key, 'networks' ); + + if ( false === $cache_value ) { + $network_ids = $this->get_network_ids(); + if ( $network_ids ) { + $this->set_found_networks(); + } + + $cache_value = array( + 'network_ids' => $network_ids, + 'found_networks' => $this->found_networks, + ); + wp_cache_add( $cache_key, $cache_value, 'networks' ); + } else { + $network_ids = $cache_value['network_ids']; + $this->found_networks = $cache_value['found_networks']; + } + + if ( $this->found_networks && $this->query_vars['number'] ) { + $this->max_num_pages = ceil( $this->found_networks / $this->query_vars['number'] ); + } + + // If querying for a count only, there's nothing more to do. + if ( $this->query_vars['count'] ) { + // $network_ids is actually a count in this case. + return intval( $network_ids ); + } + + $network_ids = array_map( 'intval', $network_ids ); + + if ( 'ids' == $this->query_vars['fields'] ) { + $this->networks = $network_ids; + return $this->networks; + } + + if ( $this->query_vars['update_network_cache'] ) { + _prime_network_caches( $network_ids ); + } + + // Fetch full network objects from the primed cache. + $_networks = array(); + foreach ( $network_ids as $network_id ) { + if ( $_network = get_network( $network_id ) ) { + $_networks[] = $_network; + } + } + + /** + * Filters the network query results. + * + * @since 4.6.0 + * + * @param array $_networks An array of WP_Network objects. + * @param WP_Network_Query $this Current instance of WP_Network_Query (passed by reference). + */ + $_networks = apply_filters_ref_array( 'the_networks', array( $_networks, &$this ) ); + + // Convert to WP_Network instances + $this->networks = array_map( 'get_network', $_networks ); + + return $this->networks; + } + + /** + * Used internally to get a list of network IDs matching the query vars. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return int|array A single count of network IDs if a count query. An array of network IDs if a full query. + */ + protected function get_network_ids() { + global $wpdb; + + $order = $this->parse_order( $this->query_vars['order'] ); + + // Disable ORDER BY with 'none', an empty array, or boolean false. + if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) { + $orderby = ''; + } elseif ( ! empty( $this->query_vars['orderby'] ) ) { + $ordersby = is_array( $this->query_vars['orderby'] ) ? + $this->query_vars['orderby'] : + preg_split( '/[,\s]/', $this->query_vars['orderby'] ); + + $orderby_array = array(); + foreach ( $ordersby as $_key => $_value ) { + if ( ! $_value ) { + continue; + } + + if ( is_int( $_key ) ) { + $_orderby = $_value; + $_order = $order; + } else { + $_orderby = $_key; + $_order = $_value; + } + + $parsed = $this->parse_orderby( $_orderby ); + + if ( ! $parsed ) { + continue; + } + + if ( 'network__in' === $_orderby ) { + $orderby_array[] = $parsed; + continue; + } + + $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); + } + + $orderby = implode( ', ', $orderby_array ); + } else { + $orderby = "$wpdb->site.id $order"; + } + + $number = absint( $this->query_vars['number'] ); + $offset = absint( $this->query_vars['offset'] ); + + if ( ! empty( $number ) ) { + if ( $offset ) { + $limits = 'LIMIT ' . $offset . ',' . $number; + } else { + $limits = 'LIMIT ' . $number; + } + } + + if ( $this->query_vars['count'] ) { + $fields = 'COUNT(*)'; + } else { + $fields = "$wpdb->site.id"; + } + + // Parse network IDs for an IN clause. + if ( ! empty( $this->query_vars['network__in'] ) ) { + $this->sql_clauses['where']['network__in'] = "$wpdb->site.id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )'; + } + + // Parse network IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['network__not_in'] ) ) { + $this->sql_clauses['where']['network__not_in'] = "$wpdb->site.id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )'; + } + + if ( ! empty( $this->query_vars['domain'] ) ) { + $this->sql_clauses['where']['domain'] = $wpdb->prepare( "$wpdb->site.domain = %s", $this->query_vars['domain'] ); + } + + // Parse network domain for an IN clause. + if ( is_array( $this->query_vars['domain__in'] ) ) { + $this->sql_clauses['where']['domain__in'] = "$wpdb->site.domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )"; + } + + // Parse network domain for a NOT IN clause. + if ( is_array( $this->query_vars['domain__not_in'] ) ) { + $this->sql_clauses['where']['domain__not_in'] = "$wpdb->site.domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )"; + } + + if ( ! empty( $this->query_vars['path'] ) ) { + $this->sql_clauses['where']['path'] = $wpdb->prepare( "$wpdb->site.path = %s", $this->query_vars['path'] ); + } + + // Parse network path for an IN clause. + if ( is_array( $this->query_vars['path__in'] ) ) { + $this->sql_clauses['where']['path__in'] = "$wpdb->site.path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )"; + } + + // Parse network path for a NOT IN clause. + if ( is_array( $this->query_vars['path__not_in'] ) ) { + $this->sql_clauses['where']['path__not_in'] = "$wpdb->site.path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )"; + } + + // Falsey search strings are ignored. + if ( strlen( $this->query_vars['search'] ) ) { + $this->sql_clauses['where']['search'] = $this->get_search_sql( + $this->query_vars['search'], + array( "$wpdb->site.domain", "$wpdb->site.path" ) + ); + } + + $join = ''; + + $where = implode( ' AND ', $this->sql_clauses['where'] ); + + $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); + + /** + * Filters the network query clauses. + * + * @since 4.6.0 + * + * @param array $pieces A compacted array of network query clauses. + * @param WP_Network_Query $this Current instance of WP_Network_Query (passed by reference). + */ + $clauses = apply_filters_ref_array( 'networks_clauses', array( compact( $pieces ), &$this ) ); + + $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; + $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; + $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; + $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : ''; + $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : ''; + $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; + + if ( $where ) { + $where = 'WHERE ' . $where; + } + + if ( $groupby ) { + $groupby = 'GROUP BY ' . $groupby; + } + + if ( $orderby ) { + $orderby = "ORDER BY $orderby"; + } + + $found_rows = ''; + if ( ! $this->query_vars['no_found_rows'] ) { + $found_rows = 'SQL_CALC_FOUND_ROWS'; + } + + $this->sql_clauses['select'] = "SELECT $found_rows $fields"; + $this->sql_clauses['from'] = "FROM $wpdb->site $join"; + $this->sql_clauses['groupby'] = $groupby; + $this->sql_clauses['orderby'] = $orderby; + $this->sql_clauses['limits'] = $limits; + + $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + + if ( $this->query_vars['count'] ) { + return intval( $wpdb->get_var( $this->request ) ); + } + + $network_ids = $wpdb->get_col( $this->request ); + + return array_map( 'intval', $network_ids ); + } + + /** + * Populates found_networks and max_num_pages properties for the current query + * if the limit clause was used. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + private function set_found_networks() { + global $wpdb; + + if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { + /** + * Filters the query used to retrieve found network count. + * + * @since 4.6.0 + * + * @param string $found_networks_query SQL query. Default 'SELECT FOUND_ROWS()'. + * @param WP_Network_Query $network_query The `WP_Network_Query` instance. + */ + $found_networks_query = apply_filters( 'found_networks_query', 'SELECT FOUND_ROWS()', $this ); + + $this->found_networks = (int) $wpdb->get_var( $found_networks_query ); + } + } + + /** + * Used internally to generate an SQL string for searching across multiple columns. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $string Search string. + * @param array $columns Columns to search. + * + * @return string Search SQL. + */ + protected function get_search_sql( $string, $columns ) { + global $wpdb; + + $like = '%' . $wpdb->esc_like( $string ) . '%'; + + $searches = array(); + foreach ( $columns as $column ) { + $searches[] = $wpdb->prepare( "$column LIKE %s", $like ); + } + + return '(' . implode( ' OR ', $searches ) . ')'; + } + + /** + * Parses and sanitizes 'orderby' keys passed to the network query. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby Alias for the field to order by. + * @return string|false Value to used in the ORDER clause. False otherwise. + */ + protected function parse_orderby( $orderby ) { + global $wpdb; + + $allowed_keys = array( + 'id', + 'domain', + 'path', + ); + + $parsed = false; + if ( $orderby == 'network__in' ) { + $network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) ); + $parsed = "FIELD( {$wpdb->site}.id, $network__in )"; + } elseif ( $orderby == 'domain_length' || $orderby == 'path_length' ) { + $field = substr( $orderby, 0, -7 ); + $parsed = "CHAR_LENGTH($wpdb->site.$field)"; + } elseif ( in_array( $orderby, $allowed_keys ) ) { + $parsed = "$wpdb->site.$orderby"; + } + + return $parsed; + } + + /** + * Parses an 'order' query variable and cast it to 'ASC' or 'DESC' as necessary. + * + * @since 4.6.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'ASC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } +} diff --git a/backend/wp-includes/class-wp-network.php b/backend/wp-includes/class-wp-network.php new file mode 100644 index 0000000..cc96f56 --- /dev/null +++ b/backend/wp-includes/class-wp-network.php @@ -0,0 +1,465 @@ +<?php +/** + * Network API: WP_Network class + * + * @package WordPress + * @subpackage Multisite + * @since 4.4.0 + */ + +/** + * Core class used for interacting with a multisite network. + * + * This class is used during load to populate the `$current_site` global and + * setup the current network. + * + * This class is most useful in WordPress multi-network installations where the + * ability to interact with any network of sites is required. + * + * @since 4.4.0 + * + * @property int $id + * @property int $site_id + */ +class WP_Network { + + /** + * Network ID. + * + * @since 4.4.0 + * @since 4.6.0 Converted from public to private to explicitly enable more intuitive + * access via magic methods. As part of the access change, the type was + * also changed from `string` to `int`. + * @var int + */ + private $id; + + /** + * Domain of the network. + * + * @since 4.4.0 + * @var string + */ + public $domain = ''; + + /** + * Path of the network. + * + * @since 4.4.0 + * @var string + */ + public $path = ''; + + /** + * The ID of the network's main site. + * + * Named "blog" vs. "site" for legacy reasons. A main site is mapped to + * the network when the network is created. + * + * A numeric string, for compatibility reasons. + * + * @since 4.4.0 + * @var string + */ + private $blog_id = '0'; + + /** + * Domain used to set cookies for this network. + * + * @since 4.4.0 + * @var string + */ + public $cookie_domain = ''; + + /** + * Name of this network. + * + * Named "site" vs. "network" for legacy reasons. + * + * @since 4.4.0 + * @var string + */ + public $site_name = ''; + + /** + * Retrieve a network from the database by its ID. + * + * @since 4.4.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $network_id The ID of the network to retrieve. + * @return WP_Network|bool The network's object if found. False if not. + */ + public static function get_instance( $network_id ) { + global $wpdb; + + $network_id = (int) $network_id; + if ( ! $network_id ) { + return false; + } + + $_network = wp_cache_get( $network_id, 'networks' ); + + if ( ! $_network ) { + $_network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) ); + + if ( empty( $_network ) || is_wp_error( $_network ) ) { + return false; + } + + wp_cache_add( $network_id, $_network, 'networks' ); + } + + return new WP_Network( $_network ); + } + + /** + * Create a new WP_Network object. + * + * Will populate object properties from the object provided and assign other + * default properties based on that information. + * + * @since 4.4.0 + * + * @param WP_Network|object $network A network object. + */ + public function __construct( $network ) { + foreach( get_object_vars( $network ) as $key => $value ) { + $this->$key = $value; + } + + $this->_set_site_name(); + $this->_set_cookie_domain(); + } + + /** + * Getter. + * + * Allows current multisite naming conventions when getting properties. + * + * @since 4.6.0 + * + * @param string $key Property to get. + * @return mixed Value of the property. Null if not available. + */ + public function __get( $key ) { + switch ( $key ) { + case 'id': + return (int) $this->id; + case 'blog_id': + return (string) $this->get_main_site_id(); + case 'site_id': + return $this->get_main_site_id(); + } + + return null; + } + + /** + * Isset-er. + * + * Allows current multisite naming conventions when checking for properties. + * + * @since 4.6.0 + * + * @param string $key Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $key ) { + switch ( $key ) { + case 'id': + case 'blog_id': + case 'site_id': + return true; + } + + return false; + } + + /** + * Setter. + * + * Allows current multisite naming conventions while setting properties. + * + * @since 4.6.0 + * + * @param string $key Property to set. + * @param mixed $value Value to assign to the property. + */ + public function __set( $key, $value ) { + switch ( $key ) { + case 'id': + $this->id = (int) $value; + break; + case 'blog_id': + case 'site_id': + $this->blog_id = (string) $value; + break; + default: + $this->$key = $value; + } + } + + /** + * Returns the main site ID for the network. + * + * Internal method used by the magic getter for the 'blog_id' and 'site_id' + * properties. + * + * @since 4.9.0 + * + * @return int The ID of the main site. + */ + private function get_main_site_id() { + /** + * Filters the main site ID. + * + * Returning a positive integer will effectively short-circuit the function. + * + * @since 4.9.0 + * + * @param int|null $main_site_id If a positive integer is returned, it is interpreted as the main site ID. + * @param WP_Network $network The network object for which the main site was detected. + */ + $main_site_id = (int) apply_filters( 'pre_get_main_site_id', null, $this ); + if ( 0 < $main_site_id ) { + return $main_site_id; + } + + if ( 0 < (int) $this->blog_id ) { + return (int) $this->blog_id; + } + + if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && $this->domain === DOMAIN_CURRENT_SITE && $this->path === PATH_CURRENT_SITE ) + || ( defined( 'SITE_ID_CURRENT_SITE' ) && $this->id == SITE_ID_CURRENT_SITE ) ) { + if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) { + $this->blog_id = (string) BLOG_ID_CURRENT_SITE; + + return (int) $this->blog_id; + } + + if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated. + $this->blog_id = (string) BLOGID_CURRENT_SITE; + + return (int) $this->blog_id; + } + } + + $site = get_site(); + if ( $site->domain === $this->domain && $site->path === $this->path ) { + $main_site_id = (int) $site->id; + } else { + $cache_key = 'network:' . $this->id . ':main_site'; + + $main_site_id = wp_cache_get( $cache_key, 'site-options' ); + if ( false === $main_site_id ) { + $_sites = get_sites( array( + 'fields' => 'ids', + 'number' => 1, + 'domain' => $this->domain, + 'path' => $this->path, + 'network_id' => $this->id, + ) ); + $main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0; + + wp_cache_add( $cache_key, $main_site_id, 'site-options' ); + } + } + + $this->blog_id = (string) $main_site_id; + + return (int) $this->blog_id; + } + + /** + * Set the site name assigned to the network if one has not been populated. + * + * @since 4.4.0 + */ + private function _set_site_name() { + if ( ! empty( $this->site_name ) ) { + return; + } + + $default = ucfirst( $this->domain ); + $this->site_name = get_network_option( $this->id, 'site_name', $default ); + } + + /** + * Set the cookie domain based on the network domain if one has + * not been populated. + * + * @todo What if the domain of the network doesn't match the current site? + * + * @since 4.4.0 + */ + private function _set_cookie_domain() { + if ( ! empty( $this->cookie_domain ) ) { + return; + } + + $this->cookie_domain = $this->domain; + if ( 'www.' === substr( $this->cookie_domain, 0, 4 ) ) { + $this->cookie_domain = substr( $this->cookie_domain, 4 ); + } + } + + /** + * Retrieve the closest matching network for a domain and path. + * + * This will not necessarily return an exact match for a domain and path. Instead, it + * breaks the domain and path into pieces that are then used to match the closest + * possibility from a query. + * + * The intent of this method is to match a network during bootstrap for a + * requested site address. + * + * @since 4.4.0 + * @static + * + * @param string $domain Domain to check. + * @param string $path Path to check. + * @param int|null $segments Path segments to use. Defaults to null, or the full path. + * @return WP_Network|bool Network object if successful. False when no network is found. + */ + public static function get_by_path( $domain = '', $path = '', $segments = null ) { + $domains = array( $domain ); + $pieces = explode( '.', $domain ); + + /* + * It's possible one domain to search is 'com', but it might as well + * be 'localhost' or some other locally mapped domain. + */ + while ( array_shift( $pieces ) ) { + if ( ! empty( $pieces ) ) { + $domains[] = implode( '.', $pieces ); + } + } + + /* + * If we've gotten to this function during normal execution, there is + * more than one network installed. At this point, who knows how many + * we have. Attempt to optimize for the situation where networks are + * only domains, thus meaning paths never need to be considered. + * + * This is a very basic optimization; anything further could have + * drawbacks depending on the setup, so this is best done per-installation. + */ + $using_paths = true; + if ( wp_using_ext_object_cache() ) { + $using_paths = wp_cache_get( 'networks_have_paths', 'site-options' ); + if ( false === $using_paths ) { + $using_paths = get_networks( array( + 'number' => 1, + 'count' => true, + 'path__not_in' => '/', + ) ); + wp_cache_add( 'networks_have_paths', $using_paths, 'site-options' ); + } + } + + $paths = array(); + if ( $using_paths ) { + $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); + + /** + * Filters the number of path segments to consider when searching for a site. + * + * @since 3.9.0 + * + * @param int|null $segments The number of path segments to consider. WordPress by default looks at + * one path segment. The function default of null only makes sense when you + * know the requested path should match a network. + * @param string $domain The requested domain. + * @param string $path The requested path, in full. + */ + $segments = apply_filters( 'network_by_path_segments_count', $segments, $domain, $path ); + + if ( ( null !== $segments ) && count( $path_segments ) > $segments ) { + $path_segments = array_slice( $path_segments, 0, $segments ); + } + + while ( count( $path_segments ) ) { + $paths[] = '/' . implode( '/', $path_segments ) . '/'; + array_pop( $path_segments ); + } + + $paths[] = '/'; + } + + /** + * Determine a network by its domain and path. + * + * This allows one to short-circuit the default logic, perhaps by + * replacing it with a routine that is more optimal for your setup. + * + * Return null to avoid the short-circuit. Return false if no network + * can be found at the requested domain and path. Otherwise, return + * an object from wp_get_network(). + * + * @since 3.9.0 + * + * @param null|bool|object $network Network value to return by path. + * @param string $domain The requested domain. + * @param string $path The requested path, in full. + * @param int|null $segments The suggested number of paths to consult. + * Default null, meaning the entire path was to be consulted. + * @param array $paths The paths to search for, based on $path and $segments. + */ + $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths ); + if ( null !== $pre ) { + return $pre; + } + + if ( ! $using_paths ) { + $networks = get_networks( array( + 'number' => 1, + 'orderby' => array( + 'domain_length' => 'DESC', + ), + 'domain__in' => $domains, + ) ); + + if ( ! empty( $networks ) ) { + return array_shift( $networks ); + } + + return false; + } + + $networks = get_networks( array( + 'orderby' => array( + 'domain_length' => 'DESC', + 'path_length' => 'DESC', + ), + 'domain__in' => $domains, + 'path__in' => $paths, + ) ); + + /* + * Domains are sorted by length of domain, then by length of path. + * The domain must match for the path to be considered. Otherwise, + * a network with the path of / will suffice. + */ + $found = false; + foreach ( $networks as $network ) { + if ( ( $network->domain === $domain ) || ( "www.{$network->domain}" === $domain ) ) { + if ( in_array( $network->path, $paths, true ) ) { + $found = true; + break; + } + } + if ( $network->path === '/' ) { + $found = true; + break; + } + } + + if ( true === $found ) { + return $network; + } + + return false; + } +} diff --git a/backend/wp-includes/class-wp-oembed-controller.php b/backend/wp-includes/class-wp-oembed-controller.php new file mode 100644 index 0000000..7ee7950 --- /dev/null +++ b/backend/wp-includes/class-wp-oembed-controller.php @@ -0,0 +1,200 @@ +<?php +/** + * WP_oEmbed_Controller class, used to provide an oEmbed endpoint. + * + * @package WordPress + * @subpackage Embeds + * @since 4.4.0 + */ + +/** + * oEmbed API endpoint controller. + * + * Registers the API route and delivers the response data. + * The output format (XML or JSON) is handled by the REST API. + * + * @since 4.4.0 + */ +final class WP_oEmbed_Controller { + /** + * Register the oEmbed REST API route. + * + * @since 4.4.0 + */ + public function register_routes() { + /** + * Filters the maxwidth oEmbed parameter. + * + * @since 4.4.0 + * + * @param int $maxwidth Maximum allowed width. Default 600. + */ + $maxwidth = apply_filters( 'oembed_default_width', 600 ); + + register_rest_route( 'oembed/1.0', '/embed', array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'args' => array( + 'url' => array( + 'required' => true, + 'sanitize_callback' => 'esc_url_raw', + ), + 'format' => array( + 'default' => 'json', + 'sanitize_callback' => 'wp_oembed_ensure_format', + ), + 'maxwidth' => array( + 'default' => $maxwidth, + 'sanitize_callback' => 'absint', + ), + ), + ), + ) ); + + register_rest_route( 'oembed/1.0', '/proxy', array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_proxy_item' ), + 'permission_callback' => array( $this, 'get_proxy_item_permissions_check' ), + 'args' => array( + 'url' => array( + 'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ), + 'type' => 'string', + 'required' => true, + 'sanitize_callback' => 'esc_url_raw', + ), + 'format' => array( + 'description' => __( 'The oEmbed format to use.' ), + 'type' => 'string', + 'default' => 'json', + 'enum' => array( + 'json', + 'xml', + ), + ), + 'maxwidth' => array( + 'description' => __( 'The maximum width of the embed frame in pixels.' ), + 'type' => 'integer', + 'default' => $maxwidth, + 'sanitize_callback' => 'absint', + ), + 'maxheight' => array( + 'description' => __( 'The maximum height of the embed frame in pixels.' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + ), + 'discover' => array( + 'description' => __( 'Whether to perform an oEmbed discovery request for non-whitelisted providers.' ), + 'type' => 'boolean', + 'default' => true, + ), + ), + ), + ) ); + } + + /** + * Callback for the embed API endpoint. + * + * Returns the JSON object for the post. + * + * @since 4.4.0 + * + * @param WP_REST_Request $request Full data about the request. + * @return WP_Error|array oEmbed response data or WP_Error on failure. + */ + public function get_item( $request ) { + $post_id = url_to_postid( $request['url'] ); + + /** + * Filters the determined post ID. + * + * @since 4.4.0 + * + * @param int $post_id The post ID. + * @param string $url The requested URL. + */ + $post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] ); + + $data = get_oembed_response_data( $post_id, $request['maxwidth'] ); + + if ( ! $data ) { + return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) ); + } + + return $data; + } + + /** + * Checks if current user can make a proxy oEmbed request. + * + * @since 4.8.0 + * + * @return true|WP_Error True if the request has read access, WP_Error object otherwise. + */ + public function get_proxy_item_permissions_check() { + if ( ! current_user_can( 'edit_posts' ) ) { + return new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to make proxied oEmbed requests.' ), array( 'status' => rest_authorization_required_code() ) ); + } + return true; + } + + /** + * Callback for the proxy API endpoint. + * + * Returns the JSON object for the proxied item. + * + * @since 4.8.0 + * + * @see WP_oEmbed::get_html() + * @param WP_REST_Request $request Full data about the request. + * @return object|WP_Error oEmbed response data or WP_Error on failure. + */ + public function get_proxy_item( $request ) { + $args = $request->get_params(); + + // Serve oEmbed data from cache if set. + unset( $args['_wpnonce'] ); + $cache_key = 'oembed_' . md5( serialize( $args ) ); + $data = get_transient( $cache_key ); + if ( ! empty( $data ) ) { + return $data; + } + + $url = $request['url']; + unset( $args['url'] ); + + // Copy maxwidth/maxheight to width/height since WP_oEmbed::fetch() uses these arg names. + if ( isset( $args['maxwidth'] ) ) { + $args['width'] = $args['maxwidth']; + } + if ( isset( $args['maxheight'] ) ) { + $args['height'] = $args['maxheight']; + } + + $data = _wp_oembed_get_object()->get_data( $url, $args ); + + if ( false === $data ) { + return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) ); + } + + /** + * Filters the oEmbed TTL value (time to live). + * + * Similar to the {@see 'oembed_ttl'} filter, but for the REST API + * oEmbed proxy endpoint. + * + * @since 4.8.0 + * + * @param int $time Time to live (in seconds). + * @param string $url The attempted embed URL. + * @param array $args An array of embed request arguments. + */ + $ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args ); + + set_transient( $cache_key, $data, $ttl ); + + return $data; + } +} diff --git a/backend/wp-includes/class-wp-post-type.php b/backend/wp-includes/class-wp-post-type.php new file mode 100644 index 0000000..ba37a02 --- /dev/null +++ b/backend/wp-includes/class-wp-post-type.php @@ -0,0 +1,679 @@ +<?php +/** + * Post API: WP_Post_Type class + * + * @package WordPress + * @subpackage Post + * @since 4.6.0 + */ + +/** + * Core class used for interacting with post types. + * + * @since 4.6.0 + * + * @see register_post_type() + */ +final class WP_Post_Type { + /** + * Post type key. + * + * @since 4.6.0 + * @var string $name + */ + public $name; + + /** + * Name of the post type shown in the menu. Usually plural. + * + * @since 4.6.0 + * @var string $label + */ + public $label; + + /** + * Labels object for this post type. + * + * If not set, post labels are inherited for non-hierarchical types + * and page labels for hierarchical ones. + * + * @see get_post_type_labels() + * + * @since 4.6.0 + * @var object $labels + */ + public $labels; + + /** + * A short descriptive summary of what the post type is. + * + * Default empty. + * + * @since 4.6.0 + * @var string $description + */ + public $description = ''; + + /** + * Whether a post type is intended for use publicly either via the admin interface or by front-end users. + * + * While the default settings of $exclude_from_search, $publicly_queryable, $show_ui, and $show_in_nav_menus + * are inherited from public, each does not rely on this relationship and controls a very specific intention. + * + * Default false. + * + * @since 4.6.0 + * @var bool $public + */ + public $public = false; + + /** + * Whether the post type is hierarchical (e.g. page). + * + * Default false. + * + * @since 4.6.0 + * @var bool $hierarchical + */ + public $hierarchical = false; + + /** + * Whether to exclude posts with this post type from front end search + * results. + * + * Default is the opposite value of $public. + * + * @since 4.6.0 + * @var bool $exclude_from_search + */ + public $exclude_from_search = null; + + /** + * Whether queries can be performed on the front end for the post type as part of `parse_request()`. + * + * Endpoints would include: + * - `?post_type={post_type_key}` + * - `?{post_type_key}={single_post_slug}` + * - `?{post_type_query_var}={single_post_slug}` + * + * Default is the value of $public. + * + * @since 4.6.0 + * @var bool $publicly_queryable + */ + public $publicly_queryable = null; + + /** + * Whether to generate and allow a UI for managing this post type in the admin. + * + * Default is the value of $public. + * + * @since 4.6.0 + * @var bool $show_ui + */ + public $show_ui = null; + + /** + * Where to show the post type in the admin menu. + * + * To work, $show_ui must be true. If true, the post type is shown in its own top level menu. If false, no menu is + * shown. If a string of an existing top level menu (eg. 'tools.php' or 'edit.php?post_type=page'), the post type + * will be placed as a sub-menu of that. + * + * Default is the value of $show_ui. + * + * @since 4.6.0 + * @var bool $show_in_menu + */ + public $show_in_menu = null; + + /** + * Makes this post type available for selection in navigation menus. + * + * Default is the value $public. + * + * @since 4.6.0 + * @var bool $show_in_nav_menus + */ + public $show_in_nav_menus = null; + + /** + * Makes this post type available via the admin bar. + * + * Default is the value of $show_in_menu. + * + * @since 4.6.0 + * @var bool $show_in_admin_bar + */ + public $show_in_admin_bar = null; + + /** + * The position in the menu order the post type should appear. + * + * To work, $show_in_menu must be true. Default null (at the bottom). + * + * @since 4.6.0 + * @var int $menu_position + */ + public $menu_position = null; + + /** + * The URL to the icon to be used for this menu. + * + * Pass a base64-encoded SVG using a data URI, which will be colored to match the color scheme. + * This should begin with 'data:image/svg+xml;base64,'. Pass the name of a Dashicons helper class + * to use a font icon, e.g. 'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty + * so an icon can be added via CSS. + * + * Defaults to use the posts icon. + * + * @since 4.6.0 + * @var string $menu_icon + */ + public $menu_icon = null; + + /** + * The string to use to build the read, edit, and delete capabilities. + * + * May be passed as an array to allow for alternative plurals when using + * this argument as a base to construct the capabilities, e.g. + * array( 'story', 'stories' ). Default 'post'. + * + * @since 4.6.0 + * @var string $capability_type + */ + public $capability_type = 'post'; + + /** + * Whether to use the internal default meta capability handling. + * + * Default false. + * + * @since 4.6.0 + * @var bool $map_meta_cap + */ + public $map_meta_cap = false; + + /** + * Provide a callback function that sets up the meta boxes for the edit form. + * + * Do `remove_meta_box()` and `add_meta_box()` calls in the callback. Default null. + * + * @since 4.6.0 + * @var string $register_meta_box_cb + */ + public $register_meta_box_cb = null; + + /** + * An array of taxonomy identifiers that will be registered for the post type. + * + * Taxonomies can be registered later with `register_taxonomy()` or `register_taxonomy_for_object_type()`. + * + * Default empty array. + * + * @since 4.6.0 + * @var array $taxonomies + */ + public $taxonomies = array(); + + /** + * Whether there should be post type archives, or if a string, the archive slug to use. + * + * Will generate the proper rewrite rules if $rewrite is enabled. Default false. + * + * @since 4.6.0 + * @var bool|string $has_archive + */ + public $has_archive = false; + + /** + * Sets the query_var key for this post type. + * + * Defaults to $post_type key. If false, a post type cannot be loaded at `?{query_var}={post_slug}`. + * If specified as a string, the query `?{query_var_string}={post_slug}` will be valid. + * + * @since 4.6.0 + * @var string|bool $query_var + */ + public $query_var; + + /** + * Whether to allow this post type to be exported. + * + * Default true. + * + * @since 4.6.0 + * @var bool $can_export + */ + public $can_export = true; + + /** + * Whether to delete posts of this type when deleting a user. + * + * If true, posts of this type belonging to the user will be moved to trash when then user is deleted. + * If false, posts of this type belonging to the user will *not* be trashed or deleted. + * If not set (the default), posts are trashed if post_type_supports( 'author' ). + * Otherwise posts are not trashed or deleted. Default null. + * + * @since 4.6.0 + * @var bool $delete_with_user + */ + public $delete_with_user = null; + + /** + * Whether this post type is a native or "built-in" post_type. + * + * Default false. + * + * @since 4.6.0 + * @var bool $_builtin + */ + public $_builtin = false; + + /** + * URL segment to use for edit link of this post type. + * + * Default 'post.php?post=%d'. + * + * @since 4.6.0 + * @var string $_edit_link + */ + public $_edit_link = 'post.php?post=%d'; + + /** + * Post type capabilities. + * + * @since 4.6.0 + * @var object $cap + */ + public $cap; + + /** + * Triggers the handling of rewrites for this post type. + * + * Defaults to true, using $post_type as slug. + * + * @since 4.6.0 + * @var array|false $rewrite + */ + public $rewrite; + + /** + * The features supported by the post type. + * + * @since 4.6.0 + * @var array|bool $supports + */ + public $supports; + + /** + * Whether this post type should appear in the REST API. + * + * Default false. If true, standard endpoints will be registered with + * respect to $rest_base and $rest_controller_class. + * + * @since 4.7.4 + * @var bool $show_in_rest + */ + public $show_in_rest; + + /** + * The base path for this post type's REST API endpoints. + * + * @since 4.7.4 + * @var string|bool $rest_base + */ + public $rest_base; + + /** + * The controller for this post type's REST API endpoints. + * + * Custom controllers must extend WP_REST_Controller. + * + * @since 4.7.4 + * @var string|bool $rest_controller_class + */ + public $rest_controller_class; + + /** + * Constructor. + * + * Will populate object properties from the provided arguments and assign other + * default properties based on that information. + * + * @since 4.6.0 + * + * @see register_post_type() + * + * @param string $post_type Post type key. + * @param array|string $args Optional. Array or string of arguments for registering a post type. + * Default empty array. + */ + public function __construct( $post_type, $args = array() ) { + $this->name = $post_type; + + $this->set_props( $args ); + } + + /** + * Sets post type properties. + * + * @since 4.6.0 + * + * @param array|string $args Array or string of arguments for registering a post type. + */ + public function set_props( $args ) { + $args = wp_parse_args( $args ); + + /** + * Filters the arguments for registering a post type. + * + * @since 4.4.0 + * + * @param array $args Array of arguments for registering a post type. + * @param string $post_type Post type key. + */ + $args = apply_filters( 'register_post_type_args', $args, $this->name ); + + $has_edit_link = ! empty( $args['_edit_link'] ); + + // Args prefixed with an underscore are reserved for internal use. + $defaults = array( + 'labels' => array(), + 'description' => '', + 'public' => false, + 'hierarchical' => false, + 'exclude_from_search' => null, + 'publicly_queryable' => null, + 'show_ui' => null, + 'show_in_menu' => null, + 'show_in_nav_menus' => null, + 'show_in_admin_bar' => null, + 'menu_position' => null, + 'menu_icon' => null, + 'capability_type' => 'post', + 'capabilities' => array(), + 'map_meta_cap' => null, + 'supports' => array(), + 'register_meta_box_cb' => null, + 'taxonomies' => array(), + 'has_archive' => false, + 'rewrite' => true, + 'query_var' => true, + 'can_export' => true, + 'delete_with_user' => null, + 'show_in_rest' => false, + 'rest_base' => false, + 'rest_controller_class' => false, + '_builtin' => false, + '_edit_link' => 'post.php?post=%d', + ); + + $args = array_merge( $defaults, $args ); + + $args['name'] = $this->name; + + // If not set, default to the setting for public. + if ( null === $args['publicly_queryable'] ) { + $args['publicly_queryable'] = $args['public']; + } + + // If not set, default to the setting for public. + if ( null === $args['show_ui'] ) { + $args['show_ui'] = $args['public']; + } + + // If not set, default to the setting for show_ui. + if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) { + $args['show_in_menu'] = $args['show_ui']; + } + + // If not set, default to the whether the full UI is shown. + if ( null === $args['show_in_admin_bar'] ) { + $args['show_in_admin_bar'] = (bool) $args['show_in_menu']; + } + + // If not set, default to the setting for public. + if ( null === $args['show_in_nav_menus'] ) { + $args['show_in_nav_menus'] = $args['public']; + } + + // If not set, default to true if not public, false if public. + if ( null === $args['exclude_from_search'] ) { + $args['exclude_from_search'] = ! $args['public']; + } + + // Back compat with quirky handling in version 3.0. #14122. + if ( empty( $args['capabilities'] ) && null === $args['map_meta_cap'] && in_array( $args['capability_type'], array( 'post', 'page' ) ) ) { + $args['map_meta_cap'] = true; + } + + // If not set, default to false. + if ( null === $args['map_meta_cap'] ) { + $args['map_meta_cap'] = false; + } + + // If there's no specified edit link and no UI, remove the edit link. + if ( ! $args['show_ui'] && ! $has_edit_link ) { + $args['_edit_link'] = ''; + } + + $this->cap = get_post_type_capabilities( (object) $args ); + unset( $args['capabilities'] ); + + if ( is_array( $args['capability_type'] ) ) { + $args['capability_type'] = $args['capability_type'][0]; + } + + if ( false !== $args['query_var'] ) { + if ( true === $args['query_var'] ) { + $args['query_var'] = $this->name; + } else { + $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); + } + } + + if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( ! is_array( $args['rewrite'] ) ) { + $args['rewrite'] = array(); + } + if ( empty( $args['rewrite']['slug'] ) ) { + $args['rewrite']['slug'] = $this->name; + } + if ( ! isset( $args['rewrite']['with_front'] ) ) { + $args['rewrite']['with_front'] = true; + } + if ( ! isset( $args['rewrite']['pages'] ) ) { + $args['rewrite']['pages'] = true; + } + if ( ! isset( $args['rewrite']['feeds'] ) || ! $args['has_archive'] ) { + $args['rewrite']['feeds'] = (bool) $args['has_archive']; + } + if ( ! isset( $args['rewrite']['ep_mask'] ) ) { + if ( isset( $args['permalink_epmask'] ) ) { + $args['rewrite']['ep_mask'] = $args['permalink_epmask']; + } else { + $args['rewrite']['ep_mask'] = EP_PERMALINK; + } + } + } + + foreach ( $args as $property_name => $property_value ) { + $this->$property_name = $property_value; + } + + $this->labels = get_post_type_labels( $this ); + $this->label = $this->labels->name; + } + + /** + * Sets the features support for the post type. + * + * @since 4.6.0 + */ + public function add_supports() { + if ( ! empty( $this->supports ) ) { + add_post_type_support( $this->name, $this->supports ); + unset( $this->supports ); + } elseif ( false !== $this->supports ) { + // Add default features. + add_post_type_support( $this->name, array( 'title', 'editor' ) ); + } + } + + /** + * Adds the necessary rewrite rules for the post type. + * + * @since 4.6.0 + * + * @global WP_Rewrite $wp_rewrite WordPress Rewrite Component. + * @global WP $wp Current WordPress environment instance. + */ + public function add_rewrite_rules() { + global $wp_rewrite, $wp; + + if ( false !== $this->query_var && $wp && is_post_type_viewable( $this ) ) { + $wp->add_query_var( $this->query_var ); + } + + if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( $this->hierarchical ) { + add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" ); + } else { + add_rewrite_tag( "%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=" ); + } + + if ( $this->has_archive ) { + $archive_slug = true === $this->has_archive ? $this->rewrite['slug'] : $this->has_archive; + if ( $this->rewrite['with_front'] ) { + $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; + } else { + $archive_slug = $wp_rewrite->root . $archive_slug; + } + + add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$this->name", 'top' ); + if ( $this->rewrite['feeds'] && $wp_rewrite->feeds ) { + $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; + add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' ); + add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' ); + } + if ( $this->rewrite['pages'] ) { + add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$this->name" . '&paged=$matches[1]', 'top' ); + } + } + + $permastruct_args = $this->rewrite; + $permastruct_args['feed'] = $permastruct_args['feeds']; + add_permastruct( $this->name, "{$this->rewrite['slug']}/%$this->name%", $permastruct_args ); + } + } + + /** + * Registers the post type meta box if a custom callback was specified. + * + * @since 4.6.0 + */ + public function register_meta_boxes() { + if ( $this->register_meta_box_cb ) { + add_action( 'add_meta_boxes_' . $this->name, $this->register_meta_box_cb, 10, 1 ); + } + } + + /** + * Adds the future post hook action for the post type. + * + * @since 4.6.0 + */ + public function add_hooks() { + add_action( 'future_' . $this->name, '_future_post_hook', 5, 2 ); + } + + /** + * Registers the taxonomies for the post type. + * + * @since 4.6.0 + */ + public function register_taxonomies() { + foreach ( $this->taxonomies as $taxonomy ) { + register_taxonomy_for_object_type( $taxonomy, $this->name ); + } + } + + /** + * Removes the features support for the post type. + * + * @since 4.6.0 + * + * @global array $_wp_post_type_features Post type features. + */ + public function remove_supports() { + global $_wp_post_type_features; + + unset( $_wp_post_type_features[ $this->name ] ); + } + + /** + * Removes any rewrite rules, permastructs, and rules for the post type. + * + * @since 4.6.0 + * + * @global WP_Rewrite $wp_rewrite WordPress rewrite component. + * @global WP $wp Current WordPress environment instance. + * @global array $post_type_meta_caps Used to remove meta capabilities. + */ + public function remove_rewrite_rules() { + global $wp, $wp_rewrite, $post_type_meta_caps; + + // Remove query var. + if ( false !== $this->query_var ) { + $wp->remove_query_var( $this->query_var ); + } + + // Remove any rewrite rules, permastructs, and rules. + if ( false !== $this->rewrite ) { + remove_rewrite_tag( "%$this->name%" ); + remove_permastruct( $this->name ); + foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) { + if ( false !== strpos( $query, "index.php?post_type=$this->name" ) ) { + unset( $wp_rewrite->extra_rules_top[ $regex ] ); + } + } + } + + // Remove registered custom meta capabilities. + foreach ( $this->cap as $cap ) { + unset( $post_type_meta_caps[ $cap ] ); + } + } + + /** + * Unregisters the post type meta box if a custom callback was specified. + * + * @since 4.6.0 + */ + public function unregister_meta_boxes() { + if ( $this->register_meta_box_cb ) { + remove_action( 'add_meta_boxes_' . $this->name, $this->register_meta_box_cb, 10 ); + } + } + + /** + * Removes the post type from all taxonomies. + * + * @since 4.6.0 + */ + public function unregister_taxonomies() { + foreach ( get_object_taxonomies( $this->name ) as $taxonomy ) { + unregister_taxonomy_for_object_type( $taxonomy, $this->name ); + } + } + + /** + * Removes the future post hook action for the post type. + * + * @since 4.6.0 + */ + public function remove_hooks() { + remove_action( 'future_' . $this->name, '_future_post_hook', 5 ); + } +} diff --git a/backend/wp-includes/class-wp-post.php b/backend/wp-includes/class-wp-post.php new file mode 100644 index 0000000..1b05a73 --- /dev/null +++ b/backend/wp-includes/class-wp-post.php @@ -0,0 +1,374 @@ +<?php +/** + * Post API: WP_Post class + * + * @package WordPress + * @subpackage Post + * @since 4.4.0 + */ + +/** + * Core class used to implement the WP_Post object. + * + * @since 3.5.0 + * + * @property string $page_template + * + * @property-read array $ancestors + * @property-read int $post_category + * @property-read string $tag_input + * + */ +final class WP_Post { + + /** + * Post ID. + * + * @since 3.5.0 + * @var int + */ + public $ID; + + /** + * ID of post author. + * + * A numeric string, for compatibility reasons. + * + * @since 3.5.0 + * @var string + */ + public $post_author = 0; + + /** + * The post's local publication time. + * + * @since 3.5.0 + * @var string + */ + public $post_date = '0000-00-00 00:00:00'; + + /** + * The post's GMT publication time. + * + * @since 3.5.0 + * @var string + */ + public $post_date_gmt = '0000-00-00 00:00:00'; + + /** + * The post's content. + * + * @since 3.5.0 + * @var string + */ + public $post_content = ''; + + /** + * The post's title. + * + * @since 3.5.0 + * @var string + */ + public $post_title = ''; + + /** + * The post's excerpt. + * + * @since 3.5.0 + * @var string + */ + public $post_excerpt = ''; + + /** + * The post's status. + * + * @since 3.5.0 + * @var string + */ + public $post_status = 'publish'; + + /** + * Whether comments are allowed. + * + * @since 3.5.0 + * @var string + */ + public $comment_status = 'open'; + + /** + * Whether pings are allowed. + * + * @since 3.5.0 + * @var string + */ + public $ping_status = 'open'; + + /** + * The post's password in plain text. + * + * @since 3.5.0 + * @var string + */ + public $post_password = ''; + + /** + * The post's slug. + * + * @since 3.5.0 + * @var string + */ + public $post_name = ''; + + /** + * URLs queued to be pinged. + * + * @since 3.5.0 + * @var string + */ + public $to_ping = ''; + + /** + * URLs that have been pinged. + * + * @since 3.5.0 + * @var string + */ + public $pinged = ''; + + /** + * The post's local modified time. + * + * @since 3.5.0 + * @var string + */ + public $post_modified = '0000-00-00 00:00:00'; + + /** + * The post's GMT modified time. + * + * @since 3.5.0 + * @var string + */ + public $post_modified_gmt = '0000-00-00 00:00:00'; + + /** + * A utility DB field for post content. + * + * @since 3.5.0 + * @var string + */ + public $post_content_filtered = ''; + + /** + * ID of a post's parent post. + * + * @since 3.5.0 + * @var int + */ + public $post_parent = 0; + + /** + * The unique identifier for a post, not necessarily a URL, used as the feed GUID. + * + * @since 3.5.0 + * @var string + */ + public $guid = ''; + + /** + * A field used for ordering posts. + * + * @since 3.5.0 + * @var int + */ + public $menu_order = 0; + + /** + * The post's type, like post or page. + * + * @since 3.5.0 + * @var string + */ + public $post_type = 'post'; + + /** + * An attachment's mime type. + * + * @since 3.5.0 + * @var string + */ + public $post_mime_type = ''; + + /** + * Cached comment count. + * + * A numeric string, for compatibility reasons. + * + * @since 3.5.0 + * @var string + */ + public $comment_count = 0; + + /** + * Stores the post object's sanitization level. + * + * Does not correspond to a DB field. + * + * @since 3.5.0 + * @var string + */ + public $filter; + + /** + * Retrieve WP_Post instance. + * + * @since 3.5.0 + * @static + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $post_id Post ID. + * @return WP_Post|false Post object, false otherwise. + */ + public static function get_instance( $post_id ) { + global $wpdb; + + $post_id = (int) $post_id; + if ( ! $post_id ) { + return false; + } + + $_post = wp_cache_get( $post_id, 'posts' ); + + if ( ! $_post ) { + $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) ); + + if ( ! $_post ) + return false; + + $_post = sanitize_post( $_post, 'raw' ); + wp_cache_add( $_post->ID, $_post, 'posts' ); + } elseif ( empty( $_post->filter ) ) { + $_post = sanitize_post( $_post, 'raw' ); + } + + return new WP_Post( $_post ); + } + + /** + * Constructor. + * + * @since 3.5.0 + * + * @param WP_Post|object $post Post object. + */ + public function __construct( $post ) { + foreach ( get_object_vars( $post ) as $key => $value ) + $this->$key = $value; + } + + /** + * Isset-er. + * + * @since 3.5.0 + * + * @param string $key Property to check if set. + * @return bool + */ + public function __isset( $key ) { + if ( 'ancestors' == $key ) + return true; + + if ( 'page_template' == $key ) + return true; + + if ( 'post_category' == $key ) + return true; + + if ( 'tags_input' == $key ) + return true; + + return metadata_exists( 'post', $this->ID, $key ); + } + + /** + * Getter. + * + * @since 3.5.0 + * + * @param string $key Key to get. + * @return mixed + */ + public function __get( $key ) { + if ( 'page_template' == $key && $this->__isset( $key ) ) { + return get_post_meta( $this->ID, '_wp_page_template', true ); + } + + if ( 'post_category' == $key ) { + if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) + $terms = get_the_terms( $this, 'category' ); + + if ( empty( $terms ) ) + return array(); + + return wp_list_pluck( $terms, 'term_id' ); + } + + if ( 'tags_input' == $key ) { + if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) + $terms = get_the_terms( $this, 'post_tag' ); + + if ( empty( $terms ) ) + return array(); + + return wp_list_pluck( $terms, 'name' ); + } + + // Rest of the values need filtering. + if ( 'ancestors' == $key ) + $value = get_post_ancestors( $this ); + else + $value = get_post_meta( $this->ID, $key, true ); + + if ( $this->filter ) + $value = sanitize_post_field( $key, $value, $this->ID, $this->filter ); + + return $value; + } + + /** + * {@Missing Summary} + * + * @since 3.5.0 + * + * @param string $filter Filter. + * @return self|array|bool|object|WP_Post + */ + public function filter( $filter ) { + if ( $this->filter == $filter ) + return $this; + + if ( $filter == 'raw' ) + return self::get_instance( $this->ID ); + + return sanitize_post( $this, $filter ); + } + + /** + * Convert object to array. + * + * @since 3.5.0 + * + * @return array Object as array. + */ + public function to_array() { + $post = get_object_vars( $this ); + + foreach ( array( 'ancestors', 'page_template', 'post_category', 'tags_input' ) as $key ) { + if ( $this->__isset( $key ) ) + $post[ $key ] = $this->__get( $key ); + } + + return $post; + } +} diff --git a/backend/wp-includes/class-wp-query.php b/backend/wp-includes/class-wp-query.php new file mode 100644 index 0000000..a6c248a --- /dev/null +++ b/backend/wp-includes/class-wp-query.php @@ -0,0 +1,4094 @@ +<?php +/** + * Query API: WP_Query class + * + * @package WordPress + * @subpackage Query + * @since 4.7.0 + */ + +/** + * The WordPress Query class. + * + * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page. + * + * @since 1.5.0 + * @since 4.5.0 Removed the `$comments_popup` property. + */ +class WP_Query { + + /** + * Query vars set by the user + * + * @since 1.5.0 + * @var array + */ + public $query; + + /** + * Query vars, after parsing + * + * @since 1.5.0 + * @var array + */ + public $query_vars = array(); + + /** + * Taxonomy query, as passed to get_tax_sql() + * + * @since 3.1.0 + * @var object WP_Tax_Query + */ + public $tax_query; + + /** + * Metadata query container + * + * @since 3.2.0 + * @var object WP_Meta_Query + */ + public $meta_query = false; + + /** + * Date query container + * + * @since 3.7.0 + * @var object WP_Date_Query + */ + public $date_query = false; + + /** + * Holds the data for a single object that is queried. + * + * Holds the contents of a post, page, category, attachment. + * + * @since 1.5.0 + * @var object|array + */ + public $queried_object; + + /** + * The ID of the queried object. + * + * @since 1.5.0 + * @var int + */ + public $queried_object_id; + + /** + * Get post database query. + * + * @since 2.0.1 + * @var string + */ + public $request; + + /** + * List of posts. + * + * @since 1.5.0 + * @var array + */ + public $posts; + + /** + * The amount of posts for the current query. + * + * @since 1.5.0 + * @var int + */ + public $post_count = 0; + + /** + * Index of the current item in the loop. + * + * @since 1.5.0 + * @var int + */ + public $current_post = -1; + + /** + * Whether the loop has started and the caller is in the loop. + * + * @since 2.0.0 + * @var bool + */ + public $in_the_loop = false; + + /** + * The current post. + * + * @since 1.5.0 + * @var WP_Post + */ + public $post; + + /** + * The list of comments for current post. + * + * @since 2.2.0 + * @var array + */ + public $comments; + + /** + * The amount of comments for the posts. + * + * @since 2.2.0 + * @var int + */ + public $comment_count = 0; + + /** + * The index of the comment in the comment loop. + * + * @since 2.2.0 + * @var int + */ + public $current_comment = -1; + + /** + * Current comment ID. + * + * @since 2.2.0 + * @var int + */ + public $comment; + + /** + * The amount of found posts for the current query. + * + * If limit clause was not used, equals $post_count. + * + * @since 2.1.0 + * @var int + */ + public $found_posts = 0; + + /** + * The amount of pages. + * + * @since 2.1.0 + * @var int + */ + public $max_num_pages = 0; + + /** + * The amount of comment pages. + * + * @since 2.7.0 + * @var int + */ + public $max_num_comment_pages = 0; + + /** + * Signifies whether the current query is for a single post. + * + * @since 1.5.0 + * @var bool + */ + public $is_single = false; + + /** + * Signifies whether the current query is for a preview. + * + * @since 2.0.0 + * @var bool + */ + public $is_preview = false; + + /** + * Signifies whether the current query is for a page. + * + * @since 1.5.0 + * @var bool + */ + public $is_page = false; + + /** + * Signifies whether the current query is for an archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_archive = false; + + /** + * Signifies whether the current query is for a date archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_date = false; + + /** + * Signifies whether the current query is for a year archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_year = false; + + /** + * Signifies whether the current query is for a month archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_month = false; + + /** + * Signifies whether the current query is for a day archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_day = false; + + /** + * Signifies whether the current query is for a specific time. + * + * @since 1.5.0 + * @var bool + */ + public $is_time = false; + + /** + * Signifies whether the current query is for an author archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_author = false; + + /** + * Signifies whether the current query is for a category archive. + * + * @since 1.5.0 + * @var bool + */ + public $is_category = false; + + /** + * Signifies whether the current query is for a tag archive. + * + * @since 2.3.0 + * @var bool + */ + public $is_tag = false; + + /** + * Signifies whether the current query is for a taxonomy archive. + * + * @since 2.5.0 + * @var bool + */ + public $is_tax = false; + + /** + * Signifies whether the current query is for a search. + * + * @since 1.5.0 + * @var bool + */ + public $is_search = false; + + /** + * Signifies whether the current query is for a feed. + * + * @since 1.5.0 + * @var bool + */ + public $is_feed = false; + + /** + * Signifies whether the current query is for a comment feed. + * + * @since 2.2.0 + * @var bool + */ + public $is_comment_feed = false; + + /** + * Signifies whether the current query is for trackback endpoint call. + * + * @since 1.5.0 + * @var bool + */ + public $is_trackback = false; + + /** + * Signifies whether the current query is for the site homepage. + * + * @since 1.5.0 + * @var bool + */ + public $is_home = false; + + /** + * Signifies whether the current query couldn't find anything. + * + * @since 1.5.0 + * @var bool + */ + public $is_404 = false; + + /** + * Signifies whether the current query is for an embed. + * + * @since 4.4.0 + * @var bool + */ + public $is_embed = false; + + /** + * Signifies whether the current query is for a paged result and not for the first page. + * + * @since 1.5.0 + * @var bool + */ + public $is_paged = false; + + /** + * Signifies whether the current query is for an administrative interface page. + * + * @since 1.5.0 + * @var bool + */ + public $is_admin = false; + + /** + * Signifies whether the current query is for an attachment page. + * + * @since 2.0.0 + * @var bool + */ + public $is_attachment = false; + + /** + * Signifies whether the current query is for an existing single post of any post type + * (post, attachment, page, custom post types). + * + * @since 2.1.0 + * @var bool + */ + public $is_singular = false; + + /** + * Signifies whether the current query is for the robots.txt file. + * + * @since 2.1.0 + * @var bool + */ + public $is_robots = false; + + /** + * Signifies whether the current query is for the page_for_posts page. + * + * Basically, the homepage if the option isn't set for the static homepage. + * + * @since 2.1.0 + * @var bool + */ + public $is_posts_page = false; + + /** + * Signifies whether the current query is for a post type archive. + * + * @since 3.1.0 + * @var bool + */ + public $is_post_type_archive = false; + + /** + * Stores the ->query_vars state like md5(serialize( $this->query_vars ) ) so we know + * whether we have to re-parse because something has changed + * + * @since 3.1.0 + * @var bool|string + */ + private $query_vars_hash = false; + + /** + * Whether query vars have changed since the initial parse_query() call. Used to catch modifications to query vars made + * via pre_get_posts hooks. + * + * @since 3.1.1 + */ + private $query_vars_changed = true; + + /** + * Set if post thumbnails are cached + * + * @since 3.2.0 + * @var bool + */ + public $thumbnails_cached = false; + + /** + * Cached list of search stopwords. + * + * @since 3.7.0 + * @var array + */ + private $stopwords; + + private $compat_fields = array( 'query_vars_hash', 'query_vars_changed' ); + + private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); + + /** + * Resets query flags to false. + * + * The query flags are what page info WordPress was able to figure out. + * + * @since 2.0.0 + */ + private function init_query_flags() { + $this->is_single = false; + $this->is_preview = false; + $this->is_page = false; + $this->is_archive = false; + $this->is_date = false; + $this->is_year = false; + $this->is_month = false; + $this->is_day = false; + $this->is_time = false; + $this->is_author = false; + $this->is_category = false; + $this->is_tag = false; + $this->is_tax = false; + $this->is_search = false; + $this->is_feed = false; + $this->is_comment_feed = false; + $this->is_trackback = false; + $this->is_home = false; + $this->is_404 = false; + $this->is_paged = false; + $this->is_admin = false; + $this->is_attachment = false; + $this->is_singular = false; + $this->is_robots = false; + $this->is_posts_page = false; + $this->is_post_type_archive = false; + } + + /** + * Initiates object properties and sets default values. + * + * @since 1.5.0 + */ + public function init() { + unset($this->posts); + unset($this->query); + $this->query_vars = array(); + unset($this->queried_object); + unset($this->queried_object_id); + $this->post_count = 0; + $this->current_post = -1; + $this->in_the_loop = false; + unset( $this->request ); + unset( $this->post ); + unset( $this->comments ); + unset( $this->comment ); + $this->comment_count = 0; + $this->current_comment = -1; + $this->found_posts = 0; + $this->max_num_pages = 0; + $this->max_num_comment_pages = 0; + + $this->init_query_flags(); + } + + /** + * Reparse the query vars. + * + * @since 1.5.0 + */ + public function parse_query_vars() { + $this->parse_query(); + } + + /** + * Fills in the query variables, which do not exist within the parameter. + * + * @since 2.1.0 + * @since 4.4.0 Removed the `comments_popup` public query variable. + * + * @param array $array Defined query variables. + * @return array Complete query variables with undefined ones filled in empty. + */ + public function fill_query_vars($array) { + $keys = array( + 'error' + , 'm' + , 'p' + , 'post_parent' + , 'subpost' + , 'subpost_id' + , 'attachment' + , 'attachment_id' + , 'name' + , 'static' + , 'pagename' + , 'page_id' + , 'second' + , 'minute' + , 'hour' + , 'day' + , 'monthnum' + , 'year' + , 'w' + , 'category_name' + , 'tag' + , 'cat' + , 'tag_id' + , 'author' + , 'author_name' + , 'feed' + , 'tb' + , 'paged' + , 'meta_key' + , 'meta_value' + , 'preview' + , 's' + , 'sentence' + , 'title' + , 'fields' + , 'menu_order' + , 'embed' + ); + + foreach ( $keys as $key ) { + if ( !isset($array[$key]) ) + $array[$key] = ''; + } + + $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', + 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in', + 'author__in', 'author__not_in' ); + + foreach ( $array_keys as $key ) { + if ( !isset($array[$key]) ) + $array[$key] = array(); + } + return $array; + } + + /** + * Parse a query string and set query type booleans. + * + * @since 1.5.0 + * @since 4.2.0 Introduced the ability to order by specific clauses of a `$meta_query`, by passing the clause's + * array key to `$orderby`. + * @since 4.4.0 Introduced `$post_name__in` and `$title` parameters. `$s` was updated to support excluded + * search terms, by prepending a hyphen. + * @since 4.5.0 Removed the `$comments_popup` parameter. + * Introduced the `$comment_status` and `$ping_status` parameters. + * Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts. + * @since 4.6.0 Added 'post_name__in' support for `$orderby`. Introduced the `$lazy_load_term_meta` argument. + * @since 4.9.0 Introduced the `$comment_count` parameter. + * + * @param string|array $query { + * Optional. Array or string of Query parameters. + * + * @type int $attachment_id Attachment post ID. Used for 'attachment' post_type. + * @type int|string $author Author ID, or comma-separated list of IDs. + * @type string $author_name User 'user_nicename'. + * @type array $author__in An array of author IDs to query from. + * @type array $author__not_in An array of author IDs not to query from. + * @type bool $cache_results Whether to cache post information. Default true. + * @type int|string $cat Category ID or comma-separated list of IDs (this or any children). + * @type array $category__and An array of category IDs (AND in). + * @type array $category__in An array of category IDs (OR in, no children). + * @type array $category__not_in An array of category IDs (NOT in). + * @type string $category_name Use category slug (not name, this or any children). + * @type array|int $comment_count Filter results by comment count. Provide an integer to match + * comment count exactly. Provide an array with integer 'value' + * and 'compare' operator ('=', '!=', '>', '>=', '<', '<=' ) to + * compare against comment_count in a specific way. + * @type string $comment_status Comment status. + * @type int $comments_per_page The number of comments to return per page. + * Default 'comments_per_page' option. + * @type array $date_query An associative array of WP_Date_Query arguments. + * See WP_Date_Query::__construct(). + * @type int $day Day of the month. Default empty. Accepts numbers 1-31. + * @type bool $exact Whether to search by exact keyword. Default false. + * @type string|array $fields Which fields to return. Single field or all fields (string), + * or array of fields. 'id=>parent' uses 'id' and 'post_parent'. + * Default all fields. Accepts 'ids', 'id=>parent'. + * @type int $hour Hour of the day. Default empty. Accepts numbers 0-23. + * @type int|bool $ignore_sticky_posts Whether to ignore sticky posts or not. Setting this to false + * excludes stickies from 'post__in'. Accepts 1|true, 0|false. + * Default 0|false. + * @type int $m Combination YearMonth. Accepts any four-digit year and month + * numbers 1-12. Default empty. + * @type string $meta_compare Comparison operator to test the 'meta_value'. + * @type string $meta_key Custom field key. + * @type array $meta_query An associative array of WP_Meta_Query arguments. See WP_Meta_Query. + * @type string $meta_value Custom field value. + * @type int $meta_value_num Custom field value number. + * @type int $menu_order The menu order of the posts. + * @type int $monthnum The two-digit month. Default empty. Accepts numbers 1-12. + * @type string $name Post slug. + * @type bool $nopaging Show all posts (true) or paginate (false). Default false. + * @type bool $no_found_rows Whether to skip counting the total rows found. Enabling can improve + * performance. Default false. + * @type int $offset The number of posts to offset before retrieval. + * @type string $order Designates ascending or descending order of posts. Default 'DESC'. + * Accepts 'ASC', 'DESC'. + * @type string|array $orderby Sort retrieved posts by parameter. One or more options may be + * passed. To use 'meta_value', or 'meta_value_num', + * 'meta_key=keyname' must be also be defined. To sort by a + * specific `$meta_query` clause, use that clause's array key. + * Accepts 'none', 'name', 'author', 'date', 'title', + * 'modified', 'menu_order', 'parent', 'ID', 'rand', + * 'relevance', 'RAND(x)' (where 'x' is an integer seed value), + * 'comment_count', 'meta_value', 'meta_value_num', 'post__in', + * 'post_name__in', 'post_parent__in', and the array keys + * of `$meta_query`. Default is 'date', except when a search + * is being performed, when the default is 'relevance'. + * + * @type int $p Post ID. + * @type int $page Show the number of posts that would show up on page X of a + * static front page. + * @type int $paged The number of the current page. + * @type int $page_id Page ID. + * @type string $pagename Page slug. + * @type string $perm Show posts if user has the appropriate capability. + * @type string $ping_status Ping status. + * @type array $post__in An array of post IDs to retrieve, sticky posts will be included + * @type string $post_mime_type The mime type of the post. Used for 'attachment' post_type. + * @type array $post__not_in An array of post IDs not to retrieve. Note: a string of comma- + * separated IDs will NOT work. + * @type int $post_parent Page ID to retrieve child pages for. Use 0 to only retrieve + * top-level pages. + * @type array $post_parent__in An array containing parent page IDs to query child pages from. + * @type array $post_parent__not_in An array containing parent page IDs not to query child pages from. + * @type string|array $post_type A post type slug (string) or array of post type slugs. + * Default 'any' if using 'tax_query'. + * @type string|array $post_status A post status (string) or array of post statuses. + * @type int $posts_per_page The number of posts to query for. Use -1 to request all posts. + * @type int $posts_per_archive_page The number of posts to query for by archive page. Overrides + * 'posts_per_page' when is_archive(), or is_search() are true. + * @type array $post_name__in An array of post slugs that results must match. + * @type string $s Search keyword(s). Prepending a term with a hyphen will + * exclude posts matching that term. Eg, 'pillow -sofa' will + * return posts containing 'pillow' but not 'sofa'. The + * character used for exclusion can be modified using the + * the 'wp_query_search_exclusion_prefix' filter. + * @type int $second Second of the minute. Default empty. Accepts numbers 0-60. + * @type bool $sentence Whether to search by phrase. Default false. + * @type bool $suppress_filters Whether to suppress filters. Default false. + * @type string $tag Tag slug. Comma-separated (either), Plus-separated (all). + * @type array $tag__and An array of tag ids (AND in). + * @type array $tag__in An array of tag ids (OR in). + * @type array $tag__not_in An array of tag ids (NOT in). + * @type int $tag_id Tag id or comma-separated list of IDs. + * @type array $tag_slug__and An array of tag slugs (AND in). + * @type array $tag_slug__in An array of tag slugs (OR in). unless 'ignore_sticky_posts' is + * true. Note: a string of comma-separated IDs will NOT work. + * @type array $tax_query An associative array of WP_Tax_Query arguments. + * See WP_Tax_Query->queries. + * @type string $title Post title. + * @type bool $update_post_meta_cache Whether to update the post meta cache. Default true. + * @type bool $update_post_term_cache Whether to update the post term cache. Default true. + * @type bool $lazy_load_term_meta Whether to lazy-load term meta. Setting to false will + * disable cache priming for term meta, so that each + * get_term_meta() call will hit the database. + * Defaults to the value of `$update_post_term_cache`. + * @type int $w The week number of the year. Default empty. Accepts numbers 0-53. + * @type int $year The four-digit year. Default empty. Accepts any four-digit year. + * } + */ + public function parse_query( $query = '' ) { + if ( ! empty( $query ) ) { + $this->init(); + $this->query = $this->query_vars = wp_parse_args( $query ); + } elseif ( ! isset( $this->query ) ) { + $this->query = $this->query_vars; + } + + $this->query_vars = $this->fill_query_vars($this->query_vars); + $qv = &$this->query_vars; + $this->query_vars_changed = true; + + if ( ! empty($qv['robots']) ) + $this->is_robots = true; + + if ( ! is_scalar( $qv['p'] ) || $qv['p'] < 0 ) { + $qv['p'] = 0; + $qv['error'] = '404'; + } else { + $qv['p'] = intval( $qv['p'] ); + } + + $qv['page_id'] = absint($qv['page_id']); + $qv['year'] = absint($qv['year']); + $qv['monthnum'] = absint($qv['monthnum']); + $qv['day'] = absint($qv['day']); + $qv['w'] = absint($qv['w']); + $qv['m'] = is_scalar( $qv['m'] ) ? preg_replace( '|[^0-9]|', '', $qv['m'] ) : ''; + $qv['paged'] = absint($qv['paged']); + $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers + $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers + $qv['pagename'] = trim( $qv['pagename'] ); + $qv['name'] = trim( $qv['name'] ); + $qv['title'] = trim( $qv['title'] ); + if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']); + if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']); + if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']); + if ( '' !== $qv['menu_order'] ) $qv['menu_order'] = absint($qv['menu_order']); + + // Fairly insane upper bound for search string lengths. + if ( ! is_scalar( $qv['s'] ) || ( ! empty( $qv['s'] ) && strlen( $qv['s'] ) > 1600 ) ) { + $qv['s'] = ''; + } + + // Compat. Map subpost to attachment. + if ( '' != $qv['subpost'] ) + $qv['attachment'] = $qv['subpost']; + if ( '' != $qv['subpost_id'] ) + $qv['attachment_id'] = $qv['subpost_id']; + + $qv['attachment_id'] = absint($qv['attachment_id']); + + if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) { + $this->is_single = true; + $this->is_attachment = true; + } elseif ( '' != $qv['name'] ) { + $this->is_single = true; + } elseif ( $qv['p'] ) { + $this->is_single = true; + } elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) { + // If year, month, day, hour, minute, and second are set, a single + // post is being queried. + $this->is_single = true; + } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) { + $this->is_page = true; + $this->is_single = false; + } else { + // Look for archive queries. Dates, categories, authors, search, post type archives. + + if ( isset( $this->query['s'] ) ) { + $this->is_search = true; + } + + if ( '' !== $qv['second'] ) { + $this->is_time = true; + $this->is_date = true; + } + + if ( '' !== $qv['minute'] ) { + $this->is_time = true; + $this->is_date = true; + } + + if ( '' !== $qv['hour'] ) { + $this->is_time = true; + $this->is_date = true; + } + + if ( $qv['day'] ) { + if ( ! $this->is_date ) { + $date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] ); + if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) { + $qv['error'] = '404'; + } else { + $this->is_day = true; + $this->is_date = true; + } + } + } + + if ( $qv['monthnum'] ) { + if ( ! $this->is_date ) { + if ( 12 < $qv['monthnum'] ) { + $qv['error'] = '404'; + } else { + $this->is_month = true; + $this->is_date = true; + } + } + } + + if ( $qv['year'] ) { + if ( ! $this->is_date ) { + $this->is_year = true; + $this->is_date = true; + } + } + + if ( $qv['m'] ) { + $this->is_date = true; + if ( strlen($qv['m']) > 9 ) { + $this->is_time = true; + } elseif ( strlen( $qv['m'] ) > 7 ) { + $this->is_day = true; + } elseif ( strlen( $qv['m'] ) > 5 ) { + $this->is_month = true; + } else { + $this->is_year = true; + } + } + + if ( '' != $qv['w'] ) { + $this->is_date = true; + } + + $this->query_vars_hash = false; + $this->parse_tax_query( $qv ); + + foreach ( $this->tax_query->queries as $tax_query ) { + if ( ! is_array( $tax_query ) ) { + continue; + } + + if ( isset( $tax_query['operator'] ) && 'NOT IN' != $tax_query['operator'] ) { + switch ( $tax_query['taxonomy'] ) { + case 'category': + $this->is_category = true; + break; + case 'post_tag': + $this->is_tag = true; + break; + default: + $this->is_tax = true; + } + } + } + unset( $tax_query ); + + if ( empty($qv['author']) || ($qv['author'] == '0') ) { + $this->is_author = false; + } else { + $this->is_author = true; + } + + if ( '' != $qv['author_name'] ) + $this->is_author = true; + + if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { + $post_type_obj = get_post_type_object( $qv['post_type'] ); + if ( ! empty( $post_type_obj->has_archive ) ) + $this->is_post_type_archive = true; + } + + if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) + $this->is_archive = true; + } + + if ( '' != $qv['feed'] ) + $this->is_feed = true; + + if ( '' != $qv['embed'] ) { + $this->is_embed = true; + } + + if ( '' != $qv['tb'] ) + $this->is_trackback = true; + + if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) ) + $this->is_paged = true; + + // if we're previewing inside the write screen + if ( '' != $qv['preview'] ) + $this->is_preview = true; + + if ( is_admin() ) + $this->is_admin = true; + + if ( false !== strpos($qv['feed'], 'comments-') ) { + $qv['feed'] = str_replace('comments-', '', $qv['feed']); + $qv['withcomments'] = 1; + } + + $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; + + if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) + $this->is_comment_feed = true; + + if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) + $this->is_home = true; + + // Correct is_* for page_on_front and page_for_posts + if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) { + $_query = wp_parse_args($this->query); + // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. + if ( isset($_query['pagename']) && '' == $_query['pagename'] ) + unset($_query['pagename']); + + unset( $_query['embed'] ); + + if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) { + $this->is_page = true; + $this->is_home = false; + $qv['page_id'] = get_option('page_on_front'); + // Correct <!--nextpage--> for page_on_front + if ( !empty($qv['paged']) ) { + $qv['page'] = $qv['paged']; + unset($qv['paged']); + } + } + } + + if ( '' != $qv['pagename'] ) { + $this->queried_object = get_page_by_path( $qv['pagename'] ); + + if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) { + if ( preg_match( "/^[^%]*%(?:postname)%/", get_option( 'permalink_structure' ) ) ) { + // See if we also have a post with the same slug + $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' ); + if ( $post ) { + $this->queried_object = $post; + $this->is_page = false; + $this->is_single = true; + } + } + } + + if ( ! empty( $this->queried_object ) ) { + $this->queried_object_id = (int) $this->queried_object->ID; + } else { + unset( $this->queried_object ); + } + + if ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) { + $this->is_page = false; + $this->is_home = true; + $this->is_posts_page = true; + } + } + + if ( $qv['page_id'] ) { + if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) { + $this->is_page = false; + $this->is_home = true; + $this->is_posts_page = true; + } + } + + if ( !empty($qv['post_type']) ) { + if ( is_array($qv['post_type']) ) + $qv['post_type'] = array_map('sanitize_key', $qv['post_type']); + else + $qv['post_type'] = sanitize_key($qv['post_type']); + } + + if ( ! empty( $qv['post_status'] ) ) { + if ( is_array( $qv['post_status'] ) ) + $qv['post_status'] = array_map('sanitize_key', $qv['post_status']); + else + $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']); + } + + if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) ) + $this->is_comment_feed = false; + + $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; + // Done correcting is_* for page_on_front and page_for_posts + + if ( '404' == $qv['error'] ) + $this->set_404(); + + $this->is_embed = $this->is_embed && ( $this->is_singular || $this->is_404 ); + + $this->query_vars_hash = md5( serialize( $this->query_vars ) ); + $this->query_vars_changed = false; + + /** + * Fires after the main query vars have been parsed. + * + * @since 1.5.0 + * + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + do_action_ref_array( 'parse_query', array( &$this ) ); + } + + /** + * Parses various taxonomy related query vars. + * + * For BC, this method is not marked as protected. See [28987]. + * + * @since 3.1.0 + * + * @param array $q The query variables. Passed by reference. + */ + public function parse_tax_query( &$q ) { + if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) { + $tax_query = $q['tax_query']; + } else { + $tax_query = array(); + } + + if ( !empty($q['taxonomy']) && !empty($q['term']) ) { + $tax_query[] = array( + 'taxonomy' => $q['taxonomy'], + 'terms' => array( $q['term'] ), + 'field' => 'slug', + ); + } + + foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) { + if ( 'post_tag' == $taxonomy ) + continue; // Handled further down in the $q['tag'] block + + if ( $t->query_var && !empty( $q[$t->query_var] ) ) { + $tax_query_defaults = array( + 'taxonomy' => $taxonomy, + 'field' => 'slug', + ); + + if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { + $q[$t->query_var] = wp_basename( $q[$t->query_var] ); + } + + $term = $q[$t->query_var]; + + if ( is_array( $term ) ) { + $term = implode( ',', $term ); + } + + if ( strpos($term, '+') !== false ) { + $terms = preg_split( '/[+]+/', $term ); + foreach ( $terms as $term ) { + $tax_query[] = array_merge( $tax_query_defaults, array( + 'terms' => array( $term ) + ) ); + } + } else { + $tax_query[] = array_merge( $tax_query_defaults, array( + 'terms' => preg_split( '/[,]+/', $term ) + ) ); + } + } + } + + // If querystring 'cat' is an array, implode it. + if ( is_array( $q['cat'] ) ) { + $q['cat'] = implode( ',', $q['cat'] ); + } + + // Category stuff + if ( ! empty( $q['cat'] ) && ! $this->is_singular ) { + $cat_in = $cat_not_in = array(); + + $cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) ); + $cat_array = array_map( 'intval', $cat_array ); + $q['cat'] = implode( ',', $cat_array ); + + foreach ( $cat_array as $cat ) { + if ( $cat > 0 ) + $cat_in[] = $cat; + elseif ( $cat < 0 ) + $cat_not_in[] = abs( $cat ); + } + + if ( ! empty( $cat_in ) ) { + $tax_query[] = array( + 'taxonomy' => 'category', + 'terms' => $cat_in, + 'field' => 'term_id', + 'include_children' => true + ); + } + + if ( ! empty( $cat_not_in ) ) { + $tax_query[] = array( + 'taxonomy' => 'category', + 'terms' => $cat_not_in, + 'field' => 'term_id', + 'operator' => 'NOT IN', + 'include_children' => true + ); + } + unset( $cat_array, $cat_in, $cat_not_in ); + } + + if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) { + $q['category__and'] = (array) $q['category__and']; + if ( ! isset( $q['category__in'] ) ) + $q['category__in'] = array(); + $q['category__in'][] = absint( reset( $q['category__and'] ) ); + unset( $q['category__and'] ); + } + + if ( ! empty( $q['category__in'] ) ) { + $q['category__in'] = array_map( 'absint', array_unique( (array) $q['category__in'] ) ); + $tax_query[] = array( + 'taxonomy' => 'category', + 'terms' => $q['category__in'], + 'field' => 'term_id', + 'include_children' => false + ); + } + + if ( ! empty($q['category__not_in']) ) { + $q['category__not_in'] = array_map( 'absint', array_unique( (array) $q['category__not_in'] ) ); + $tax_query[] = array( + 'taxonomy' => 'category', + 'terms' => $q['category__not_in'], + 'operator' => 'NOT IN', + 'include_children' => false + ); + } + + if ( ! empty($q['category__and']) ) { + $q['category__and'] = array_map( 'absint', array_unique( (array) $q['category__and'] ) ); + $tax_query[] = array( + 'taxonomy' => 'category', + 'terms' => $q['category__and'], + 'field' => 'term_id', + 'operator' => 'AND', + 'include_children' => false + ); + } + + // If querystring 'tag' is array, implode it. + if ( is_array( $q['tag'] ) ) { + $q['tag'] = implode( ',', $q['tag'] ); + } + + // Tag stuff + if ( '' != $q['tag'] && !$this->is_singular && $this->query_vars_changed ) { + if ( strpos($q['tag'], ',') !== false ) { + $tags = preg_split('/[,\r\n\t ]+/', $q['tag']); + foreach ( (array) $tags as $tag ) { + $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); + $q['tag_slug__in'][] = $tag; + } + } elseif ( preg_match('/[+\r\n\t ]+/', $q['tag'] ) || ! empty( $q['cat'] ) ) { + $tags = preg_split('/[+\r\n\t ]+/', $q['tag']); + foreach ( (array) $tags as $tag ) { + $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); + $q['tag_slug__and'][] = $tag; + } + } else { + $q['tag'] = sanitize_term_field('slug', $q['tag'], 0, 'post_tag', 'db'); + $q['tag_slug__in'][] = $q['tag']; + } + } + + if ( !empty($q['tag_id']) ) { + $q['tag_id'] = absint( $q['tag_id'] ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag_id'] + ); + } + + if ( !empty($q['tag__in']) ) { + $q['tag__in'] = array_map('absint', array_unique( (array) $q['tag__in'] ) ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag__in'] + ); + } + + if ( !empty($q['tag__not_in']) ) { + $q['tag__not_in'] = array_map('absint', array_unique( (array) $q['tag__not_in'] ) ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag__not_in'], + 'operator' => 'NOT IN' + ); + } + + if ( !empty($q['tag__and']) ) { + $q['tag__and'] = array_map('absint', array_unique( (array) $q['tag__and'] ) ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag__and'], + 'operator' => 'AND' + ); + } + + if ( !empty($q['tag_slug__in']) ) { + $q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__in'] ) ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag_slug__in'], + 'field' => 'slug' + ); + } + + if ( !empty($q['tag_slug__and']) ) { + $q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__and'] ) ); + $tax_query[] = array( + 'taxonomy' => 'post_tag', + 'terms' => $q['tag_slug__and'], + 'field' => 'slug', + 'operator' => 'AND' + ); + } + + $this->tax_query = new WP_Tax_Query( $tax_query ); + + /** + * Fires after taxonomy-related query vars have been parsed. + * + * @since 3.7.0 + * + * @param WP_Query $this The WP_Query instance. + */ + do_action( 'parse_tax_query', $this ); + } + + /** + * Generates SQL for the WHERE clause based on passed search terms. + * + * @since 3.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $q Query variables. + * @return string WHERE clause. + */ + protected function parse_search( &$q ) { + global $wpdb; + + $search = ''; + + // added slashes screw with quote grouping when done early, so done later + $q['s'] = stripslashes( $q['s'] ); + if ( empty( $_GET['s'] ) && $this->is_main_query() ) + $q['s'] = urldecode( $q['s'] ); + // there are no line breaks in <input /> fields + $q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] ); + $q['search_terms_count'] = 1; + if ( ! empty( $q['sentence'] ) ) { + $q['search_terms'] = array( $q['s'] ); + } else { + if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches ) ) { + $q['search_terms_count'] = count( $matches[0] ); + $q['search_terms'] = $this->parse_search_terms( $matches[0] ); + // if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence + if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 ) + $q['search_terms'] = array( $q['s'] ); + } else { + $q['search_terms'] = array( $q['s'] ); + } + } + + $n = ! empty( $q['exact'] ) ? '' : '%'; + $searchand = ''; + $q['search_orderby_title'] = array(); + + /** + * Filters the prefix that indicates that a search term should be excluded from results. + * + * @since 4.7.0 + * + * @param string $exclusion_prefix The prefix. Default '-'. Returning + * an empty value disables exclusions. + */ + $exclusion_prefix = apply_filters( 'wp_query_search_exclusion_prefix', '-' ); + + foreach ( $q['search_terms'] as $term ) { + // If there is an $exclusion_prefix, terms prefixed with it should be excluded. + $exclude = $exclusion_prefix && ( $exclusion_prefix === substr( $term, 0, 1 ) ); + if ( $exclude ) { + $like_op = 'NOT LIKE'; + $andor_op = 'AND'; + $term = substr( $term, 1 ); + } else { + $like_op = 'LIKE'; + $andor_op = 'OR'; + } + + if ( $n && ! $exclude ) { + $like = '%' . $wpdb->esc_like( $term ) . '%'; + $q['search_orderby_title'][] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $like ); + } + + $like = $n . $wpdb->esc_like( $term ) . $n; + $search .= $wpdb->prepare( "{$searchand}(({$wpdb->posts}.post_title $like_op %s) $andor_op ({$wpdb->posts}.post_excerpt $like_op %s) $andor_op ({$wpdb->posts}.post_content $like_op %s))", $like, $like, $like ); + $searchand = ' AND '; + } + + if ( ! empty( $search ) ) { + $search = " AND ({$search}) "; + if ( ! is_user_logged_in() ) { + $search .= " AND ({$wpdb->posts}.post_password = '') "; + } + } + + return $search; + } + + /** + * Check if the terms are suitable for searching. + * + * Uses an array of stopwords (terms) that are excluded from the separate + * term matching when searching for posts. The list of English stopwords is + * the approximate search engines list, and is translatable. + * + * @since 3.7.0 + * + * @param array $terms Terms to check. + * @return array Terms that are not stopwords. + */ + protected function parse_search_terms( $terms ) { + $strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower'; + $checked = array(); + + $stopwords = $this->get_search_stopwords(); + + foreach ( $terms as $term ) { + // keep before/after spaces when term is for exact match + if ( preg_match( '/^".+"$/', $term ) ) + $term = trim( $term, "\"'" ); + else + $term = trim( $term, "\"' " ); + + // Avoid single A-Z and single dashes. + if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) ) + continue; + + if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) ) + continue; + + $checked[] = $term; + } + + return $checked; + } + + /** + * Retrieve stopwords used when parsing search terms. + * + * @since 3.7.0 + * + * @return array Stopwords. + */ + protected function get_search_stopwords() { + if ( isset( $this->stopwords ) ) + return $this->stopwords; + + /* translators: This is a comma-separated list of very common words that should be excluded from a search, + * like a, an, and the. These are usually called "stopwords". You should not simply translate these individual + * words into your language. Instead, look for and provide commonly accepted stopwords in your language. + */ + $words = explode( ',', _x( 'about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www', + 'Comma-separated list of search stopwords in your language' ) ); + + $stopwords = array(); + foreach ( $words as $word ) { + $word = trim( $word, "\r\n\t " ); + if ( $word ) + $stopwords[] = $word; + } + + /** + * Filters stopwords used when parsing search terms. + * + * @since 3.7.0 + * + * @param array $stopwords Stopwords. + */ + $this->stopwords = apply_filters( 'wp_search_stopwords', $stopwords ); + return $this->stopwords; + } + + /** + * Generates SQL for the ORDER BY condition based on passed search terms. + * + * @since 3.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $q Query variables. + * @return string ORDER BY clause. + */ + protected function parse_search_order( &$q ) { + global $wpdb; + + if ( $q['search_terms_count'] > 1 ) { + $num_terms = count( $q['search_orderby_title'] ); + + // If the search terms contain negative queries, don't bother ordering by sentence matches. + $like = ''; + if ( ! preg_match( '/(?:\s|^)\-/', $q['s'] ) ) { + $like = '%' . $wpdb->esc_like( $q['s'] ) . '%'; + } + + $search_orderby = ''; + + // sentence match in 'post_title' + if ( $like ) { + $search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_title LIKE %s THEN 1 ", $like ); + } + + // sanity limit, sort as sentence when more than 6 terms + // (few searches are longer than 6 terms and most titles are not) + if ( $num_terms < 7 ) { + // all words in title + $search_orderby .= 'WHEN ' . implode( ' AND ', $q['search_orderby_title'] ) . ' THEN 2 '; + // any word in title, not needed when $num_terms == 1 + if ( $num_terms > 1 ) + $search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 '; + } + + // Sentence match in 'post_content' and 'post_excerpt'. + if ( $like ) { + $search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_excerpt LIKE %s THEN 4 ", $like ); + $search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_content LIKE %s THEN 5 ", $like ); + } + + if ( $search_orderby ) { + $search_orderby = '(CASE ' . $search_orderby . 'ELSE 6 END)'; + } + } else { + // single word or sentence search + $search_orderby = reset( $q['search_orderby_title'] ) . ' DESC'; + } + + return $search_orderby; + } + + /** + * Converts the given orderby alias (if allowed) to a properly-prefixed value. + * + * @since 4.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby Alias for the field to order by. + * @return string|false Table-prefixed value to used in the ORDER clause. False otherwise. + */ + protected function parse_orderby( $orderby ) { + global $wpdb; + + // Used to filter values. + $allowed_keys = array( + 'post_name', 'post_author', 'post_date', 'post_title', 'post_modified', + 'post_parent', 'post_type', 'name', 'author', 'date', 'title', 'modified', + 'parent', 'type', 'ID', 'menu_order', 'comment_count', 'rand', + ); + + $primary_meta_key = ''; + $primary_meta_query = false; + $meta_clauses = $this->meta_query->get_clauses(); + if ( ! empty( $meta_clauses ) ) { + $primary_meta_query = reset( $meta_clauses ); + + if ( ! empty( $primary_meta_query['key'] ) ) { + $primary_meta_key = $primary_meta_query['key']; + $allowed_keys[] = $primary_meta_key; + } + + $allowed_keys[] = 'meta_value'; + $allowed_keys[] = 'meta_value_num'; + $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_clauses ) ); + } + + // If RAND() contains a seed value, sanitize and add to allowed keys. + $rand_with_seed = false; + if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { + $orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) ); + $allowed_keys[] = $orderby; + $rand_with_seed = true; + } + + if ( ! in_array( $orderby, $allowed_keys, true ) ) { + return false; + } + + switch ( $orderby ) { + case 'post_name': + case 'post_author': + case 'post_date': + case 'post_title': + case 'post_modified': + case 'post_parent': + case 'post_type': + case 'ID': + case 'menu_order': + case 'comment_count': + $orderby_clause = "{$wpdb->posts}.{$orderby}"; + break; + case 'rand': + $orderby_clause = 'RAND()'; + break; + case $primary_meta_key: + case 'meta_value': + if ( ! empty( $primary_meta_query['type'] ) ) { + $orderby_clause = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})"; + } else { + $orderby_clause = "{$primary_meta_query['alias']}.meta_value"; + } + break; + case 'meta_value_num': + $orderby_clause = "{$primary_meta_query['alias']}.meta_value+0"; + break; + default: + if ( array_key_exists( $orderby, $meta_clauses ) ) { + // $orderby corresponds to a meta_query clause. + $meta_clause = $meta_clauses[ $orderby ]; + $orderby_clause = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; + } elseif ( $rand_with_seed ) { + $orderby_clause = $orderby; + } else { + // Default: order by post field. + $orderby_clause = "{$wpdb->posts}.post_" . sanitize_key( $orderby ); + } + + break; + } + + return $orderby_clause; + } + + /** + * Parse an 'order' query variable and cast it to ASC or DESC as necessary. + * + * @since 4.0.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'DESC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } + + /** + * Sets the 404 property and saves whether query is feed. + * + * @since 2.0.0 + */ + public function set_404() { + $is_feed = $this->is_feed; + + $this->init_query_flags(); + $this->is_404 = true; + + $this->is_feed = $is_feed; + } + + /** + * Retrieve query variable. + * + * @since 1.5.0 + * @since 3.9.0 The `$default` argument was introduced. + * + * + * @param string $query_var Query variable key. + * @param mixed $default Optional. Value to return if the query variable is not set. Default empty. + * @return mixed Contents of the query variable. + */ + public function get( $query_var, $default = '' ) { + if ( isset( $this->query_vars[ $query_var ] ) ) { + return $this->query_vars[ $query_var ]; + } + + return $default; + } + + /** + * Set query variable. + * + * @since 1.5.0 + * + * @param string $query_var Query variable key. + * @param mixed $value Query variable value. + */ + public function set($query_var, $value) { + $this->query_vars[$query_var] = $value; + } + + /** + * Retrieve the posts based on query variables. + * + * There are a few filters and actions that can be used to modify the post + * database query. + * + * @since 1.5.0 + * + * @return array List of posts. + */ + public function get_posts() { + global $wpdb; + + $this->parse_query(); + + /** + * Fires after the query variable object is created, but before the actual query is run. + * + * Note: If using conditional tags, use the method versions within the passed instance + * (e.g. $this->is_main_query() instead of is_main_query()). This is because the functions + * like is_main_query() test against the global $wp_query instance, not the passed one. + * + * @since 2.0.0 + * + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + do_action_ref_array( 'pre_get_posts', array( &$this ) ); + + // Shorthand. + $q = &$this->query_vars; + + // Fill again in case pre_get_posts unset some vars. + $q = $this->fill_query_vars($q); + + // Parse meta query + $this->meta_query = new WP_Meta_Query(); + $this->meta_query->parse_query_vars( $q ); + + // Set a flag if a pre_get_posts hook changed the query vars. + $hash = md5( serialize( $this->query_vars ) ); + if ( $hash != $this->query_vars_hash ) { + $this->query_vars_changed = true; + $this->query_vars_hash = $hash; + } + unset($hash); + + // First let's clear some variables + $distinct = ''; + $whichauthor = ''; + $whichmimetype = ''; + $where = ''; + $limits = ''; + $join = ''; + $search = ''; + $groupby = ''; + $post_status_join = false; + $page = 1; + + if ( isset( $q['caller_get_posts'] ) ) { + _deprecated_argument( 'WP_Query', '3.1.0', + /* translators: 1: caller_get_posts, 2: ignore_sticky_posts */ + sprintf( __( '%1$s is deprecated. Use %2$s instead.' ), + '<code>caller_get_posts</code>', + '<code>ignore_sticky_posts</code>' + ) + ); + + if ( ! isset( $q['ignore_sticky_posts'] ) ) { + $q['ignore_sticky_posts'] = $q['caller_get_posts']; + } + } + + if ( !isset( $q['ignore_sticky_posts'] ) ) + $q['ignore_sticky_posts'] = false; + + if ( !isset($q['suppress_filters']) ) + $q['suppress_filters'] = false; + + if ( !isset($q['cache_results']) ) { + if ( wp_using_ext_object_cache() ) + $q['cache_results'] = false; + else + $q['cache_results'] = true; + } + + if ( !isset($q['update_post_term_cache']) ) + $q['update_post_term_cache'] = true; + + if ( ! isset( $q['lazy_load_term_meta'] ) ) { + $q['lazy_load_term_meta'] = $q['update_post_term_cache']; + } + + if ( !isset($q['update_post_meta_cache']) ) + $q['update_post_meta_cache'] = true; + + if ( !isset($q['post_type']) ) { + if ( $this->is_search ) + $q['post_type'] = 'any'; + else + $q['post_type'] = ''; + } + $post_type = $q['post_type']; + if ( empty( $q['posts_per_page'] ) ) { + $q['posts_per_page'] = get_option( 'posts_per_page' ); + } + if ( isset($q['showposts']) && $q['showposts'] ) { + $q['showposts'] = (int) $q['showposts']; + $q['posts_per_page'] = $q['showposts']; + } + if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) ) + $q['posts_per_page'] = $q['posts_per_archive_page']; + if ( !isset($q['nopaging']) ) { + if ( $q['posts_per_page'] == -1 ) { + $q['nopaging'] = true; + } else { + $q['nopaging'] = false; + } + } + + if ( $this->is_feed ) { + // This overrides posts_per_page. + if ( ! empty( $q['posts_per_rss'] ) ) { + $q['posts_per_page'] = $q['posts_per_rss']; + } else { + $q['posts_per_page'] = get_option( 'posts_per_rss' ); + } + $q['nopaging'] = false; + } + $q['posts_per_page'] = (int) $q['posts_per_page']; + if ( $q['posts_per_page'] < -1 ) + $q['posts_per_page'] = abs($q['posts_per_page']); + elseif ( $q['posts_per_page'] == 0 ) + $q['posts_per_page'] = 1; + + if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 ) + $q['comments_per_page'] = get_option('comments_per_page'); + + if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) { + $this->is_page = true; + $this->is_home = false; + $q['page_id'] = get_option('page_on_front'); + } + + if ( isset($q['page']) ) { + $q['page'] = trim($q['page'], '/'); + $q['page'] = absint($q['page']); + } + + // If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present. + if ( isset($q['no_found_rows']) ) + $q['no_found_rows'] = (bool) $q['no_found_rows']; + else + $q['no_found_rows'] = false; + + switch ( $q['fields'] ) { + case 'ids': + $fields = "{$wpdb->posts}.ID"; + break; + case 'id=>parent': + $fields = "{$wpdb->posts}.ID, {$wpdb->posts}.post_parent"; + break; + default: + $fields = "{$wpdb->posts}.*"; + } + + if ( '' !== $q['menu_order'] ) { + $where .= " AND {$wpdb->posts}.menu_order = " . $q['menu_order']; + } + // The "m" parameter is meant for months but accepts datetimes of varying specificity + if ( $q['m'] ) { + $where .= " AND YEAR({$wpdb->posts}.post_date)=" . substr($q['m'], 0, 4); + if ( strlen($q['m']) > 5 ) { + $where .= " AND MONTH({$wpdb->posts}.post_date)=" . substr($q['m'], 4, 2); + } + if ( strlen($q['m']) > 7 ) { + $where .= " AND DAYOFMONTH({$wpdb->posts}.post_date)=" . substr($q['m'], 6, 2); + } + if ( strlen($q['m']) > 9 ) { + $where .= " AND HOUR({$wpdb->posts}.post_date)=" . substr($q['m'], 8, 2); + } + if ( strlen($q['m']) > 11 ) { + $where .= " AND MINUTE({$wpdb->posts}.post_date)=" . substr($q['m'], 10, 2); + } + if ( strlen($q['m']) > 13 ) { + $where .= " AND SECOND({$wpdb->posts}.post_date)=" . substr($q['m'], 12, 2); + } + } + + // Handle the other individual date parameters + $date_parameters = array(); + + if ( '' !== $q['hour'] ) + $date_parameters['hour'] = $q['hour']; + + if ( '' !== $q['minute'] ) + $date_parameters['minute'] = $q['minute']; + + if ( '' !== $q['second'] ) + $date_parameters['second'] = $q['second']; + + if ( $q['year'] ) + $date_parameters['year'] = $q['year']; + + if ( $q['monthnum'] ) + $date_parameters['monthnum'] = $q['monthnum']; + + if ( $q['w'] ) + $date_parameters['week'] = $q['w']; + + if ( $q['day'] ) + $date_parameters['day'] = $q['day']; + + if ( $date_parameters ) { + $date_query = new WP_Date_Query( array( $date_parameters ) ); + $where .= $date_query->get_sql(); + } + unset( $date_parameters, $date_query ); + + // Handle complex date queries + if ( ! empty( $q['date_query'] ) ) { + $this->date_query = new WP_Date_Query( $q['date_query'] ); + $where .= $this->date_query->get_sql(); + } + + + // If we've got a post_type AND it's not "any" post_type. + if ( !empty($q['post_type']) && 'any' != $q['post_type'] ) { + foreach ( (array)$q['post_type'] as $_post_type ) { + $ptype_obj = get_post_type_object($_post_type); + if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) ) + continue; + + if ( ! $ptype_obj->hierarchical ) { + // Non-hierarchical post types can directly use 'name'. + $q['name'] = $q[ $ptype_obj->query_var ]; + } else { + // Hierarchical post types will operate through 'pagename'. + $q['pagename'] = $q[ $ptype_obj->query_var ]; + $q['name'] = ''; + } + + // Only one request for a slug is possible, this is why name & pagename are overwritten above. + break; + } //end foreach + unset($ptype_obj); + } + + if ( '' !== $q['title'] ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_title = %s", stripslashes( $q['title'] ) ); + } + + // Parameters related to 'post_name'. + if ( '' != $q['name'] ) { + $q['name'] = sanitize_title_for_query( $q['name'] ); + $where .= " AND {$wpdb->posts}.post_name = '" . $q['name'] . "'"; + } elseif ( '' != $q['pagename'] ) { + if ( isset($this->queried_object_id) ) { + $reqpage = $this->queried_object_id; + } else { + if ( 'page' != $q['post_type'] ) { + foreach ( (array)$q['post_type'] as $_post_type ) { + $ptype_obj = get_post_type_object($_post_type); + if ( !$ptype_obj || !$ptype_obj->hierarchical ) + continue; + + $reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type); + if ( $reqpage ) + break; + } + unset($ptype_obj); + } else { + $reqpage = get_page_by_path($q['pagename']); + } + if ( !empty($reqpage) ) + $reqpage = $reqpage->ID; + else + $reqpage = 0; + } + + $page_for_posts = get_option('page_for_posts'); + if ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) { + $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); + $q['name'] = $q['pagename']; + $where .= " AND ({$wpdb->posts}.ID = '$reqpage')"; + $reqpage_obj = get_post( $reqpage ); + if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) { + $this->is_attachment = true; + $post_type = $q['post_type'] = 'attachment'; + $this->is_page = true; + $q['attachment_id'] = $reqpage; + } + } + } elseif ( '' != $q['attachment'] ) { + $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) ); + $q['name'] = $q['attachment']; + $where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'"; + } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) { + $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] ); + $post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'"; + $where .= " AND {$wpdb->posts}.post_name IN ($post_name__in)"; + } + + // If an attachment is requested by number, let it supersede any post number. + if ( $q['attachment_id'] ) + $q['p'] = absint($q['attachment_id']); + + // If a post number is specified, load that post + if ( $q['p'] ) { + $where .= " AND {$wpdb->posts}.ID = " . $q['p']; + } elseif ( $q['post__in'] ) { + $post__in = implode(',', array_map( 'absint', $q['post__in'] )); + $where .= " AND {$wpdb->posts}.ID IN ($post__in)"; + } elseif ( $q['post__not_in'] ) { + $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] )); + $where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)"; + } + + if ( is_numeric( $q['post_parent'] ) ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_parent = %d ", $q['post_parent'] ); + } elseif ( $q['post_parent__in'] ) { + $post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) ); + $where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)"; + } elseif ( $q['post_parent__not_in'] ) { + $post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) ); + $where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)"; + } + + if ( $q['page_id'] ) { + if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) { + $q['p'] = $q['page_id']; + $where = " AND {$wpdb->posts}.ID = " . $q['page_id']; + } + } + + // If a search pattern is specified, load the posts that match. + if ( strlen( $q['s'] ) ) { + $search = $this->parse_search( $q ); + } + + if ( ! $q['suppress_filters'] ) { + /** + * Filters the search SQL that is used in the WHERE clause of WP_Query. + * + * @since 3.0.0 + * + * @param string $search Search SQL for WHERE clause. + * @param WP_Query $this The current WP_Query object. + */ + $search = apply_filters_ref_array( 'posts_search', array( $search, &$this ) ); + } + + // Taxonomies + if ( !$this->is_singular ) { + $this->parse_tax_query( $q ); + + $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' ); + + $join .= $clauses['join']; + $where .= $clauses['where']; + } + + if ( $this->is_tax ) { + if ( empty($post_type) ) { + // Do a fully inclusive search for currently registered post types of queried taxonomies + $post_type = array(); + $taxonomies = array_keys( $this->tax_query->queried_terms ); + foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) { + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt ); + if ( array_intersect( $taxonomies, $object_taxonomies ) ) + $post_type[] = $pt; + } + if ( ! $post_type ) + $post_type = 'any'; + elseif ( count( $post_type ) == 1 ) + $post_type = $post_type[0]; + + $post_status_join = true; + } elseif ( in_array('attachment', (array) $post_type) ) { + $post_status_join = true; + } + } + + /* + * Ensure that 'taxonomy', 'term', 'term_id', 'cat', and + * 'category_name' vars are set for backward compatibility. + */ + if ( ! empty( $this->tax_query->queried_terms ) ) { + + /* + * Set 'taxonomy', 'term', and 'term_id' to the + * first taxonomy other than 'post_tag' or 'category'. + */ + if ( ! isset( $q['taxonomy'] ) ) { + foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) { + if ( empty( $queried_items['terms'][0] ) ) { + continue; + } + + if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ) ) ) { + $q['taxonomy'] = $queried_taxonomy; + + if ( 'slug' === $queried_items['field'] ) { + $q['term'] = $queried_items['terms'][0]; + } else { + $q['term_id'] = $queried_items['terms'][0]; + } + + // Take the first one we find. + break; + } + } + } + + // 'cat', 'category_name', 'tag_id' + foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) { + if ( empty( $queried_items['terms'][0] ) ) { + continue; + } + + if ( 'category' === $queried_taxonomy ) { + $the_cat = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'category' ); + if ( $the_cat ) { + $this->set( 'cat', $the_cat->term_id ); + $this->set( 'category_name', $the_cat->slug ); + } + unset( $the_cat ); + } + + if ( 'post_tag' === $queried_taxonomy ) { + $the_tag = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'post_tag' ); + if ( $the_tag ) { + $this->set( 'tag_id', $the_tag->term_id ); + } + unset( $the_tag ); + } + } + } + + if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) { + $groupby = "{$wpdb->posts}.ID"; + } + + // Author/user stuff + + if ( ! empty( $q['author'] ) && $q['author'] != '0' ) { + $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) ); + $authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) ); + foreach ( $authors as $author ) { + $key = $author > 0 ? 'author__in' : 'author__not_in'; + $q[$key][] = abs( $author ); + } + $q['author'] = implode( ',', $authors ); + } + + if ( ! empty( $q['author__not_in'] ) ) { + $author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) ); + $where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) "; + } elseif ( ! empty( $q['author__in'] ) ) { + $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) ); + $where .= " AND {$wpdb->posts}.post_author IN ($author__in) "; + } + + // Author stuff for nice URLs + + if ( '' != $q['author_name'] ) { + if ( strpos($q['author_name'], '/') !== false ) { + $q['author_name'] = explode('/', $q['author_name']); + if ( $q['author_name'][ count($q['author_name'])-1 ] ) { + $q['author_name'] = $q['author_name'][count($q['author_name'])-1]; // no trailing slash + } else { + $q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailing slash + } + } + $q['author_name'] = sanitize_title_for_query( $q['author_name'] ); + $q['author'] = get_user_by('slug', $q['author_name']); + if ( $q['author'] ) + $q['author'] = $q['author']->ID; + $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')'; + } + + // Matching by comment count. + if ( isset( $q['comment_count'] ) ) { + // Numeric comment count is converted to array format. + if ( is_numeric( $q['comment_count'] ) ) { + $q['comment_count'] = array( + 'value' => intval( $q['comment_count'] ), + ); + } + + if ( isset( $q['comment_count']['value'] ) ) { + $q['comment_count'] = array_merge( array( + 'compare' => '=', + ), $q['comment_count'] ); + + // Fallback for invalid compare operators is '='. + $compare_operators = array( '=', '!=', '>', '>=', '<', '<=' ); + if ( ! in_array( $q['comment_count']['compare'], $compare_operators, true ) ) { + $q['comment_count']['compare'] = '='; + } + + $where .= $wpdb->prepare( " AND {$wpdb->posts}.comment_count {$q['comment_count']['compare']} %d", $q['comment_count']['value'] ); + } + } + + // MIME-Type stuff for attachment browsing + + if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) { + $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts ); + } + $where .= $search . $whichauthor . $whichmimetype; + + if ( ! empty( $this->meta_query->queries ) ) { + $clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this ); + $join .= $clauses['join']; + $where .= $clauses['where']; + } + + $rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] ); + if ( ! isset( $q['order'] ) ) { + $q['order'] = $rand ? '' : 'DESC'; + } else { + $q['order'] = $rand ? '' : $this->parse_order( $q['order'] ); + } + + // Order by. + if ( empty( $q['orderby'] ) ) { + /* + * Boolean false or empty array blanks out ORDER BY, + * while leaving the value unset or otherwise empty sets the default. + */ + if ( isset( $q['orderby'] ) && ( is_array( $q['orderby'] ) || false === $q['orderby'] ) ) { + $orderby = ''; + } else { + $orderby = "{$wpdb->posts}.post_date " . $q['order']; + } + } elseif ( 'none' == $q['orderby'] ) { + $orderby = ''; + } elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) { + $orderby = "FIELD( {$wpdb->posts}.ID, $post__in )"; + } elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) { + $orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )"; + } elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) { + $orderby = "FIELD( {$wpdb->posts}.post_name, $post_name__in )"; + } else { + $orderby_array = array(); + if ( is_array( $q['orderby'] ) ) { + foreach ( $q['orderby'] as $_orderby => $order ) { + $orderby = addslashes_gpc( urldecode( $_orderby ) ); + $parsed = $this->parse_orderby( $orderby ); + + if ( ! $parsed ) { + continue; + } + + $orderby_array[] = $parsed . ' ' . $this->parse_order( $order ); + } + $orderby = implode( ', ', $orderby_array ); + + } else { + $q['orderby'] = urldecode( $q['orderby'] ); + $q['orderby'] = addslashes_gpc( $q['orderby'] ); + + foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) { + $parsed = $this->parse_orderby( $orderby ); + // Only allow certain values for safety. + if ( ! $parsed ) { + continue; + } + + $orderby_array[] = $parsed; + } + $orderby = implode( ' ' . $q['order'] . ', ', $orderby_array ); + + if ( empty( $orderby ) ) { + $orderby = "{$wpdb->posts}.post_date " . $q['order']; + } elseif ( ! empty( $q['order'] ) ) { + $orderby .= " {$q['order']}"; + } + } + } + + // Order search results by relevance only when another "orderby" is not specified in the query. + if ( ! empty( $q['s'] ) ) { + $search_orderby = ''; + if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) ) + $search_orderby = $this->parse_search_order( $q ); + + if ( ! $q['suppress_filters'] ) { + /** + * Filters the ORDER BY used when ordering search results. + * + * @since 3.7.0 + * + * @param string $search_orderby The ORDER BY clause. + * @param WP_Query $this The current WP_Query instance. + */ + $search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this ); + } + + if ( $search_orderby ) + $orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby; + } + + if ( is_array( $post_type ) && count( $post_type ) > 1 ) { + $post_type_cap = 'multiple_post_type'; + } else { + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + $post_type_object = get_post_type_object( $post_type ); + if ( empty( $post_type_object ) ) + $post_type_cap = $post_type; + } + + if ( isset( $q['post_password'] ) ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_password = %s", $q['post_password'] ); + if ( empty( $q['perm'] ) ) { + $q['perm'] = 'readable'; + } + } elseif ( isset( $q['has_password'] ) ) { + $where .= sprintf( " AND {$wpdb->posts}.post_password %s ''", $q['has_password'] ? '!=' : '=' ); + } + + if ( ! empty( $q['comment_status'] ) ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.comment_status = %s ", $q['comment_status'] ); + } + + if ( ! empty( $q['ping_status'] ) ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.ping_status = %s ", $q['ping_status'] ); + } + + if ( 'any' == $post_type ) { + $in_search_post_types = get_post_types( array('exclude_from_search' => false) ); + if ( empty( $in_search_post_types ) ) { + $where .= ' AND 1=0 '; + } else { + $where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')"; + } + } elseif ( !empty( $post_type ) && is_array( $post_type ) ) { + $where .= " AND {$wpdb->posts}.post_type IN ('" . join("', '", esc_sql( $post_type ) ) . "')"; + } elseif ( ! empty( $post_type ) ) { + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type ); + $post_type_object = get_post_type_object ( $post_type ); + } elseif ( $this->is_attachment ) { + $where .= " AND {$wpdb->posts}.post_type = 'attachment'"; + $post_type_object = get_post_type_object ( 'attachment' ); + } elseif ( $this->is_page ) { + $where .= " AND {$wpdb->posts}.post_type = 'page'"; + $post_type_object = get_post_type_object ( 'page' ); + } else { + $where .= " AND {$wpdb->posts}.post_type = 'post'"; + $post_type_object = get_post_type_object ( 'post' ); + } + + $edit_cap = 'edit_post'; + $read_cap = 'read_post'; + + if ( ! empty( $post_type_object ) ) { + $edit_others_cap = $post_type_object->cap->edit_others_posts; + $read_private_cap = $post_type_object->cap->read_private_posts; + } else { + $edit_others_cap = 'edit_others_' . $post_type_cap . 's'; + $read_private_cap = 'read_private_' . $post_type_cap . 's'; + } + + $user_id = get_current_user_id(); + + $q_status = array(); + if ( ! empty( $q['post_status'] ) ) { + $statuswheres = array(); + $q_status = $q['post_status']; + if ( ! is_array( $q_status ) ) + $q_status = explode(',', $q_status); + $r_status = array(); + $p_status = array(); + $e_status = array(); + if ( in_array( 'any', $q_status ) ) { + foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) { + if ( ! in_array( $status, $q_status ) ) { + $e_status[] = "{$wpdb->posts}.post_status <> '$status'"; + } + } + } else { + foreach ( get_post_stati() as $status ) { + if ( in_array( $status, $q_status ) ) { + if ( 'private' == $status ) { + $p_status[] = "{$wpdb->posts}.post_status = '$status'"; + } else { + $r_status[] = "{$wpdb->posts}.post_status = '$status'"; + } + } + } + } + + if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { + $r_status = array_merge($r_status, $p_status); + unset($p_status); + } + + if ( !empty($e_status) ) { + $statuswheres[] = "(" . join( ' AND ', $e_status ) . ")"; + } + if ( !empty($r_status) ) { + if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) ) { + $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))"; + } else { + $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; + } + } + if ( !empty($p_status) ) { + if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) { + $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))"; + } else { + $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; + } + } + if ( $post_status_join ) { + $join .= " LEFT JOIN {$wpdb->posts} AS p2 ON ({$wpdb->posts}.post_parent = p2.ID) "; + foreach ( $statuswheres as $index => $statuswhere ) { + $statuswheres[$index] = "($statuswhere OR ({$wpdb->posts}.post_status = 'inherit' AND " . str_replace( $wpdb->posts, 'p2', $statuswhere ) . "))"; + } + } + $where_status = implode( ' OR ', $statuswheres ); + if ( ! empty( $where_status ) ) { + $where .= " AND ($where_status)"; + } + } elseif ( !$this->is_singular ) { + $where .= " AND ({$wpdb->posts}.post_status = 'publish'"; + + // Add public states. + $public_states = get_post_stati( array('public' => true) ); + foreach ( (array) $public_states as $state ) { + if ( 'publish' == $state ) // Publish is hard-coded above. + continue; + $where .= " OR {$wpdb->posts}.post_status = '$state'"; + } + + if ( $this->is_admin ) { + // Add protected states that should show in the admin all list. + $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); + foreach ( (array) $admin_all_states as $state ) { + $where .= " OR {$wpdb->posts}.post_status = '$state'"; + } + } + + if ( is_user_logged_in() ) { + // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. + $private_states = get_post_stati( array('private' => true) ); + foreach ( (array) $private_states as $state ) { + $where .= current_user_can( $read_private_cap ) ? " OR {$wpdb->posts}.post_status = '$state'" : " OR {$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$state'"; + } + } + + $where .= ')'; + } + + /* + * Apply filters on where and join prior to paging so that any + * manipulations to them are reflected in the paging by day queries. + */ + if ( !$q['suppress_filters'] ) { + /** + * Filters the WHERE clause of the query. + * + * @since 1.5.0 + * + * @param string $where The WHERE clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) ); + + /** + * Filters the JOIN clause of the query. + * + * @since 1.5.0 + * + * @param string $join The JOIN clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) ); + } + + // Paging + if ( empty($q['nopaging']) && !$this->is_singular ) { + $page = absint($q['paged']); + if ( !$page ) + $page = 1; + + // If 'offset' is provided, it takes precedence over 'paged'. + if ( isset( $q['offset'] ) && is_numeric( $q['offset'] ) ) { + $q['offset'] = absint( $q['offset'] ); + $pgstrt = $q['offset'] . ', '; + } else { + $pgstrt = absint( ( $page - 1 ) * $q['posts_per_page'] ) . ', '; + } + $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; + } + + // Comments feeds + if ( $this->is_comment_feed && ! $this->is_singular ) { + if ( $this->is_archive || $this->is_search ) { + $cjoin = "JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) $join "; + $cwhere = "WHERE comment_approved = '1' $where"; + $cgroupby = "{$wpdb->comments}.comment_id"; + } else { // Other non singular e.g. front + $cjoin = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID )"; + $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1'"; + $cgroupby = ''; + } + + if ( !$q['suppress_filters'] ) { + /** + * Filters the JOIN clause of the comments feed query before sending. + * + * @since 2.2.0 + * + * @param string $cjoin The JOIN clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $cjoin = apply_filters_ref_array( 'comment_feed_join', array( $cjoin, &$this ) ); + + /** + * Filters the WHERE clause of the comments feed query before sending. + * + * @since 2.2.0 + * + * @param string $cwhere The WHERE clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $cwhere = apply_filters_ref_array( 'comment_feed_where', array( $cwhere, &$this ) ); + + /** + * Filters the GROUP BY clause of the comments feed query before sending. + * + * @since 2.2.0 + * + * @param string $cgroupby The GROUP BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( $cgroupby, &$this ) ); + + /** + * Filters the ORDER BY clause of the comments feed query before sending. + * + * @since 2.8.0 + * + * @param string $corderby The ORDER BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); + + /** + * Filters the LIMIT clause of the comments feed query before sending. + * + * @since 2.8.0 + * + * @param string $climits The JOIN clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); + } + $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; + $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; + + $comments = (array) $wpdb->get_results("SELECT $distinct {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"); + // Convert to WP_Comment + $this->comments = array_map( 'get_comment', $comments ); + $this->comment_count = count($this->comments); + + $post_ids = array(); + + foreach ( $this->comments as $comment ) + $post_ids[] = (int) $comment->comment_post_ID; + + $post_ids = join(',', $post_ids); + $join = ''; + if ( $post_ids ) { + $where = "AND {$wpdb->posts}.ID IN ($post_ids) "; + } else { + $where = "AND 0"; + } + } + + $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); + + /* + * Apply post-paging filters on where and join. Only plugins that + * manipulate paging queries should use these hooks. + */ + if ( !$q['suppress_filters'] ) { + /** + * Filters the WHERE clause of the query. + * + * Specifically for manipulating paging queries. + * + * @since 1.5.0 + * + * @param string $where The WHERE clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); + + /** + * Filters the GROUP BY clause of the query. + * + * @since 2.0.0 + * + * @param string $groupby The GROUP BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); + + /** + * Filters the JOIN clause of the query. + * + * Specifically for manipulating paging queries. + * + * @since 1.5.0 + * + * @param string $join The JOIN clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); + + /** + * Filters the ORDER BY clause of the query. + * + * @since 1.5.1 + * + * @param string $orderby The ORDER BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); + + /** + * Filters the DISTINCT clause of the query. + * + * @since 2.1.0 + * + * @param string $distinct The DISTINCT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); + + /** + * Filters the LIMIT clause of the query. + * + * @since 2.1.0 + * + * @param string $limits The LIMIT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); + + /** + * Filters the SELECT clause of the query. + * + * @since 2.1.0 + * + * @param string $fields The SELECT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); + + /** + * Filters all query clauses at once, for convenience. + * + * Covers the WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT, + * fields (SELECT), and LIMITS clauses. + * + * @since 3.1.0 + * + * @param array $clauses The list of clauses for the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) ); + + $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; + $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; + $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; + $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; + $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : ''; + $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; + $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; + } + + /** + * Fires to announce the query's current selection parameters. + * + * For use by caching plugins. + * + * @since 2.3.0 + * + * @param string $selection The assembled selection query. + */ + do_action( 'posts_selection', $where . $groupby . $orderby . $limits . $join ); + + /* + * Filters again for the benefit of caching plugins. + * Regular plugins should use the hooks above. + */ + if ( !$q['suppress_filters'] ) { + /** + * Filters the WHERE clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $where The WHERE clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); + + /** + * Filters the GROUP BY clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $groupby The GROUP BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); + + /** + * Filters the JOIN clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $join The JOIN clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); + + /** + * Filters the ORDER BY clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $orderby The ORDER BY clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); + + /** + * Filters the DISTINCT clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $distinct The DISTINCT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); + + /** + * Filters the SELECT clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $fields The SELECT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); + + /** + * Filters the LIMIT clause of the query. + * + * For use by caching plugins. + * + * @since 2.5.0 + * + * @param string $limits The LIMIT clause of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); + + /** + * Filters all query clauses at once, for convenience. + * + * For use by caching plugins. + * + * Covers the WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT, + * fields (SELECT), and LIMITS clauses. + * + * @since 3.1.0 + * + * @param array $pieces The pieces of the query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) ); + + $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; + $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; + $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; + $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; + $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : ''; + $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; + $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; + } + + if ( ! empty($groupby) ) + $groupby = 'GROUP BY ' . $groupby; + if ( !empty( $orderby ) ) + $orderby = 'ORDER BY ' . $orderby; + + $found_rows = ''; + if ( !$q['no_found_rows'] && !empty($limits) ) + $found_rows = 'SQL_CALC_FOUND_ROWS'; + + $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits"; + + if ( !$q['suppress_filters'] ) { + /** + * Filters the completed SQL query before sending. + * + * @since 2.0.0 + * + * @param string $request The complete SQL query. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) ); + } + + /** + * Filters the posts array before the query takes place. + * + * Return a non-null value to bypass WordPress's default post queries. + * + * Filtering functions that require pagination information are encouraged to set + * the `found_posts` and `max_num_pages` properties of the WP_Query object, + * passed to the filter by reference. If WP_Query does not perform a database + * query, it will not have enough information to generate these values itself. + * + * @since 4.6.0 + * + * @param array|null $posts Return an array of post data to short-circuit WP's query, + * or null to allow WP to run its normal queries. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); + + if ( 'ids' == $q['fields'] ) { + if ( null === $this->posts ) { + $this->posts = $wpdb->get_col( $this->request ); + } + + $this->posts = array_map( 'intval', $this->posts ); + $this->post_count = count( $this->posts ); + $this->set_found_posts( $q, $limits ); + + return $this->posts; + } + + if ( 'id=>parent' == $q['fields'] ) { + if ( null === $this->posts ) { + $this->posts = $wpdb->get_results( $this->request ); + } + + $this->post_count = count( $this->posts ); + $this->set_found_posts( $q, $limits ); + + $r = array(); + foreach ( $this->posts as $key => $post ) { + $this->posts[ $key ]->ID = (int) $post->ID; + $this->posts[ $key ]->post_parent = (int) $post->post_parent; + + $r[ (int) $post->ID ] = (int) $post->post_parent; + } + + return $r; + } + + if ( null === $this->posts ) { + $split_the_query = ( $old_request == $this->request && "{$wpdb->posts}.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 ); + + /** + * Filters whether to split the query. + * + * Splitting the query will cause it to fetch just the IDs of the found posts + * (and then individually fetch each post by ID), rather than fetching every + * complete row at once. One massive result vs. many small results. + * + * @since 3.4.0 + * + * @param bool $split_the_query Whether or not to split the query. + * @param WP_Query $this The WP_Query instance. + */ + $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this ); + + if ( $split_the_query ) { + // First get the IDs and then fill in the objects + + $this->request = "SELECT $found_rows $distinct {$wpdb->posts}.ID FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits"; + + /** + * Filters the Post IDs SQL request before sending. + * + * @since 3.4.0 + * + * @param string $request The post ID request. + * @param WP_Query $this The WP_Query instance. + */ + $this->request = apply_filters( 'posts_request_ids', $this->request, $this ); + + $ids = $wpdb->get_col( $this->request ); + + if ( $ids ) { + $this->posts = $ids; + $this->set_found_posts( $q, $limits ); + _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); + } else { + $this->posts = array(); + } + } else { + $this->posts = $wpdb->get_results( $this->request ); + $this->set_found_posts( $q, $limits ); + } + } + + // Convert to WP_Post objects. + if ( $this->posts ) { + $this->posts = array_map( 'get_post', $this->posts ); + } + + if ( ! $q['suppress_filters'] ) { + /** + * Filters the raw post results array, prior to status checks. + * + * @since 2.3.0 + * + * @param array $posts The post results array. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) ); + } + + if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { + /** This filter is documented in wp-includes/query.php */ + $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) ); + + /** This filter is documented in wp-includes/query.php */ + $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) ); + + /** This filter is documented in wp-includes/query.php */ + $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) ); + $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; + + /** This filter is documented in wp-includes/query.php */ + $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); + $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; + + /** This filter is documented in wp-includes/query.php */ + $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); + + $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"; + $comments = $wpdb->get_results($comments_request); + // Convert to WP_Comment + $this->comments = array_map( 'get_comment', $comments ); + $this->comment_count = count($this->comments); + } + + // Check post status to determine if post should be displayed. + if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { + $status = get_post_status($this->posts[0]); + if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) { + $this->is_page = false; + $this->is_single = true; + $this->is_attachment = true; + } + $post_status_obj = get_post_status_object($status); + + // If the post_status was specifically requested, let it pass through. + if ( !$post_status_obj->public && ! in_array( $status, $q_status ) ) { + + if ( ! is_user_logged_in() ) { + // User must be logged in to view unpublished posts. + $this->posts = array(); + } else { + if ( $post_status_obj->protected ) { + // User must have edit permissions on the draft to preview. + if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) { + $this->posts = array(); + } else { + $this->is_preview = true; + if ( 'future' != $status ) + $this->posts[0]->post_date = current_time('mysql'); + } + } elseif ( $post_status_obj->private ) { + if ( ! current_user_can($read_cap, $this->posts[0]->ID) ) + $this->posts = array(); + } else { + $this->posts = array(); + } + } + } + + if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) ) { + /** + * Filters the single post for preview mode. + * + * @since 2.7.0 + * + * @param WP_Post $post_preview The Post object. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) ); + } + } + + // Put sticky posts at the top of the posts array + $sticky_posts = get_option('sticky_posts'); + if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) { + $num_posts = count($this->posts); + $sticky_offset = 0; + // Loop over posts and relocate stickies to the front. + for ( $i = 0; $i < $num_posts; $i++ ) { + if ( in_array($this->posts[$i]->ID, $sticky_posts) ) { + $sticky_post = $this->posts[$i]; + // Remove sticky from current position + array_splice($this->posts, $i, 1); + // Move to front, after other stickies + array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); + // Increment the sticky offset. The next sticky will be placed at this offset. + $sticky_offset++; + // Remove post from sticky posts array + $offset = array_search($sticky_post->ID, $sticky_posts); + unset( $sticky_posts[$offset] ); + } + } + + // If any posts have been excluded specifically, Ignore those that are sticky. + if ( !empty($sticky_posts) && !empty($q['post__not_in']) ) + $sticky_posts = array_diff($sticky_posts, $q['post__not_in']); + + // Fetch sticky posts that weren't in the query results + if ( !empty($sticky_posts) ) { + $stickies = get_posts( array( + 'post__in' => $sticky_posts, + 'post_type' => $post_type, + 'post_status' => 'publish', + 'nopaging' => true + ) ); + + foreach ( $stickies as $sticky_post ) { + array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); + $sticky_offset++; + } + } + } + + // If comments have been fetched as part of the query, make sure comment meta lazy-loading is set up. + if ( ! empty( $this->comments ) ) { + wp_queue_comments_for_comment_meta_lazyload( $this->comments ); + } + + if ( ! $q['suppress_filters'] ) { + /** + * Filters the array of retrieved posts after they've been fetched and + * internally processed. + * + * @since 1.5.0 + * + * @param array $posts The array of retrieved posts. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); + } + + // Ensure that any posts added/modified via one of the filters above are + // of the type WP_Post and are filtered. + if ( $this->posts ) { + $this->post_count = count( $this->posts ); + + $this->posts = array_map( 'get_post', $this->posts ); + + if ( $q['cache_results'] ) + update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); + + $this->post = reset( $this->posts ); + } else { + $this->post_count = 0; + $this->posts = array(); + } + + if ( $q['lazy_load_term_meta'] ) { + wp_queue_posts_for_term_meta_lazyload( $this->posts ); + } + + return $this->posts; + } + + /** + * Set up the amount of found posts and the number of pages (if limit clause was used) + * for the current query. + * + * @since 3.5.0 + * + * @param array $q Query variables. + * @param string $limits LIMIT clauses of the query. + */ + private function set_found_posts( $q, $limits ) { + global $wpdb; + // Bail if posts is an empty array. Continue if posts is an empty string, + // null, or false to accommodate caching plugins that fill posts later. + if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) + return; + + if ( ! empty( $limits ) ) { + /** + * Filters the query to run for retrieving the found posts. + * + * @since 2.1.0 + * + * @param string $found_posts The query to run to find the found posts. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); + } else { + if ( is_array( $this->posts ) ) { + $this->found_posts = count( $this->posts ); + } else { + if ( null === $this->posts ) { + $this->found_posts = 0; + } else { + $this->found_posts = 1; + } + } + } + + /** + * Filters the number of found posts for the query. + * + * @since 2.1.0 + * + * @param int $found_posts The number of posts found. + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); + + if ( ! empty( $limits ) ) + $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); + } + + /** + * Set up the next post and iterate current post index. + * + * @since 1.5.0 + * + * @return WP_Post Next post. + */ + public function next_post() { + + $this->current_post++; + + $this->post = $this->posts[$this->current_post]; + return $this->post; + } + + /** + * Sets up the current post. + * + * Retrieves the next post, sets up the post, sets the 'in the loop' + * property to true. + * + * @since 1.5.0 + * + * @global WP_Post $post + */ + public function the_post() { + global $post; + $this->in_the_loop = true; + + if ( $this->current_post == -1 ) // loop has just started + /** + * Fires once the loop is started. + * + * @since 2.0.0 + * + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + do_action_ref_array( 'loop_start', array( &$this ) ); + + $post = $this->next_post(); + $this->setup_postdata( $post ); + } + + /** + * Determines whether there are more posts available in the loop. + * + * Calls the {@see 'loop_end'} action when the loop is complete. + * + * @since 1.5.0 + * + * @return bool True if posts are available, false if end of loop. + */ + public function have_posts() { + if ( $this->current_post + 1 < $this->post_count ) { + return true; + } elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) { + /** + * Fires once the loop has ended. + * + * @since 2.0.0 + * + * @param WP_Query $this The WP_Query instance (passed by reference). + */ + do_action_ref_array( 'loop_end', array( &$this ) ); + // Do some cleaning up after the loop + $this->rewind_posts(); + } elseif ( 0 === $this->post_count ) { + /** + * Fires if no results are found in a post query. + * + * @since 4.9.0 + * + * @param WP_Query $this The WP_Query instance. + */ + do_action( 'loop_no_results', $this ); + } + + $this->in_the_loop = false; + return false; + } + + /** + * Rewind the posts and reset post index. + * + * @since 1.5.0 + */ + public function rewind_posts() { + $this->current_post = -1; + if ( $this->post_count > 0 ) { + $this->post = $this->posts[0]; + } + } + + /** + * Iterate current comment index and return WP_Comment object. + * + * @since 2.2.0 + * + * @return WP_Comment Comment object. + */ + public function next_comment() { + $this->current_comment++; + + $this->comment = $this->comments[$this->current_comment]; + return $this->comment; + } + + /** + * Sets up the current comment. + * + * @since 2.2.0 + * @global WP_Comment $comment Current comment. + */ + public function the_comment() { + global $comment; + + $comment = $this->next_comment(); + + if ( $this->current_comment == 0 ) { + /** + * Fires once the comment loop is started. + * + * @since 2.2.0 + */ + do_action( 'comment_loop_start' ); + } + } + + /** + * Whether there are more comments available. + * + * Automatically rewinds comments when finished. + * + * @since 2.2.0 + * + * @return bool True, if more comments. False, if no more posts. + */ + public function have_comments() { + if ( $this->current_comment + 1 < $this->comment_count ) { + return true; + } elseif ( $this->current_comment + 1 == $this->comment_count ) { + $this->rewind_comments(); + } + + return false; + } + + /** + * Rewind the comments, resets the comment index and comment to first. + * + * @since 2.2.0 + */ + public function rewind_comments() { + $this->current_comment = -1; + if ( $this->comment_count > 0 ) { + $this->comment = $this->comments[0]; + } + } + + /** + * Sets up the WordPress query by parsing query string. + * + * @since 1.5.0 + * + * @param string|array $query URL query string or array of query arguments. + * @return array List of posts. + */ + public function query( $query ) { + $this->init(); + $this->query = $this->query_vars = wp_parse_args( $query ); + return $this->get_posts(); + } + + /** + * Retrieve queried object. + * + * If queried object is not set, then the queried object will be set from + * the category, tag, taxonomy, posts page, single post, page, or author + * query variable. After it is set up, it will be returned. + * + * @since 1.5.0 + * + * @return object + */ + public function get_queried_object() { + if ( isset($this->queried_object) ) + return $this->queried_object; + + $this->queried_object = null; + $this->queried_object_id = null; + + if ( $this->is_category || $this->is_tag || $this->is_tax ) { + if ( $this->is_category ) { + if ( $this->get( 'cat' ) ) { + $term = get_term( $this->get( 'cat' ), 'category' ); + } elseif ( $this->get( 'category_name' ) ) { + $term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' ); + } + } elseif ( $this->is_tag ) { + if ( $this->get( 'tag_id' ) ) { + $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); + } elseif ( $this->get( 'tag' ) ) { + $term = get_term_by( 'slug', $this->get( 'tag' ), 'post_tag' ); + } + } else { + // For other tax queries, grab the first term from the first clause. + if ( ! empty( $this->tax_query->queried_terms ) ) { + $queried_taxonomies = array_keys( $this->tax_query->queried_terms ); + $matched_taxonomy = reset( $queried_taxonomies ); + $query = $this->tax_query->queried_terms[ $matched_taxonomy ]; + + if ( ! empty( $query['terms'] ) ) { + if ( 'term_id' == $query['field'] ) { + $term = get_term( reset( $query['terms'] ), $matched_taxonomy ); + } else { + $term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy ); + } + } + } + } + + if ( ! empty( $term ) && ! is_wp_error( $term ) ) { + $this->queried_object = $term; + $this->queried_object_id = (int) $term->term_id; + + if ( $this->is_category && 'category' === $this->queried_object->taxonomy ) + _make_cat_compat( $this->queried_object ); + } + } elseif ( $this->is_post_type_archive ) { + $post_type = $this->get( 'post_type' ); + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + $this->queried_object = get_post_type_object( $post_type ); + } elseif ( $this->is_posts_page ) { + $page_for_posts = get_option('page_for_posts'); + $this->queried_object = get_post( $page_for_posts ); + $this->queried_object_id = (int) $this->queried_object->ID; + } elseif ( $this->is_singular && ! empty( $this->post ) ) { + $this->queried_object = $this->post; + $this->queried_object_id = (int) $this->post->ID; + } elseif ( $this->is_author ) { + $this->queried_object_id = (int) $this->get('author'); + $this->queried_object = get_userdata( $this->queried_object_id ); + } + + return $this->queried_object; + } + + /** + * Retrieve ID of the current queried object. + * + * @since 1.5.0 + * + * @return int + */ + public function get_queried_object_id() { + $this->get_queried_object(); + + if ( isset($this->queried_object_id) ) { + return $this->queried_object_id; + } + + return 0; + } + + /** + * Constructor. + * + * Sets up the WordPress query, if parameter is not empty. + * + * @since 1.5.0 + * + * @param string|array $query URL query string or array of vars. + */ + public function __construct( $query = '' ) { + if ( ! empty( $query ) ) { + $this->query( $query ); + } + } + + /** + * Make private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name; + } + } + + /** + * Make private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } + } + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|false Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( in_array( $name, $this->compat_methods ) ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Is the query for an existing archive page? + * + * Month, Year, Category, Author, Post Type archive... + * + * @since 3.1.0 + * + * @return bool + */ + public function is_archive() { + return (bool) $this->is_archive; + } + + /** + * Is the query for an existing post type archive page? + * + * @since 3.1.0 + * + * @param mixed $post_types Optional. Post type or array of posts types to check against. + * @return bool + */ + public function is_post_type_archive( $post_types = '' ) { + if ( empty( $post_types ) || ! $this->is_post_type_archive ) + return (bool) $this->is_post_type_archive; + + $post_type = $this->get( 'post_type' ); + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + $post_type_object = get_post_type_object( $post_type ); + + return in_array( $post_type_object->name, (array) $post_types ); + } + + /** + * Is the query for an existing attachment page? + * + * @since 3.1.0 + * + * @param mixed $attachment Attachment ID, title, slug, or array of such. + * @return bool + */ + public function is_attachment( $attachment = '' ) { + if ( ! $this->is_attachment ) { + return false; + } + + if ( empty( $attachment ) ) { + return true; + } + + $attachment = array_map( 'strval', (array) $attachment ); + + $post_obj = $this->get_queried_object(); + + if ( in_array( (string) $post_obj->ID, $attachment ) ) { + return true; + } elseif ( in_array( $post_obj->post_title, $attachment ) ) { + return true; + } elseif ( in_array( $post_obj->post_name, $attachment ) ) { + return true; + } + return false; + } + + /** + * Is the query for an existing author archive page? + * + * If the $author parameter is specified, this function will additionally + * check if the query is for one of the authors specified. + * + * @since 3.1.0 + * + * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames + * @return bool + */ + public function is_author( $author = '' ) { + if ( !$this->is_author ) + return false; + + if ( empty($author) ) + return true; + + $author_obj = $this->get_queried_object(); + + $author = array_map( 'strval', (array) $author ); + + if ( in_array( (string) $author_obj->ID, $author ) ) + return true; + elseif ( in_array( $author_obj->nickname, $author ) ) + return true; + elseif ( in_array( $author_obj->user_nicename, $author ) ) + return true; + + return false; + } + + /** + * Is the query for an existing category archive page? + * + * If the $category parameter is specified, this function will additionally + * check if the query is for one of the categories specified. + * + * @since 3.1.0 + * + * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. + * @return bool + */ + public function is_category( $category = '' ) { + if ( !$this->is_category ) + return false; + + if ( empty($category) ) + return true; + + $cat_obj = $this->get_queried_object(); + + $category = array_map( 'strval', (array) $category ); + + if ( in_array( (string) $cat_obj->term_id, $category ) ) + return true; + elseif ( in_array( $cat_obj->name, $category ) ) + return true; + elseif ( in_array( $cat_obj->slug, $category ) ) + return true; + + return false; + } + + /** + * Is the query for an existing tag archive page? + * + * If the $tag parameter is specified, this function will additionally + * check if the query is for one of the tags specified. + * + * @since 3.1.0 + * + * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. + * @return bool + */ + public function is_tag( $tag = '' ) { + if ( ! $this->is_tag ) + return false; + + if ( empty( $tag ) ) + return true; + + $tag_obj = $this->get_queried_object(); + + $tag = array_map( 'strval', (array) $tag ); + + if ( in_array( (string) $tag_obj->term_id, $tag ) ) + return true; + elseif ( in_array( $tag_obj->name, $tag ) ) + return true; + elseif ( in_array( $tag_obj->slug, $tag ) ) + return true; + + return false; + } + + /** + * Is the query for an existing custom taxonomy archive page? + * + * If the $taxonomy parameter is specified, this function will additionally + * check if the query is for that specific $taxonomy. + * + * If the $term parameter is specified in addition to the $taxonomy parameter, + * this function will additionally check if the query is for one of the terms + * specified. + * + * @since 3.1.0 + * + * @global array $wp_taxonomies + * + * @param mixed $taxonomy Optional. Taxonomy slug or slugs. + * @param mixed $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. + * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives). + */ + public function is_tax( $taxonomy = '', $term = '' ) { + global $wp_taxonomies; + + if ( !$this->is_tax ) + return false; + + if ( empty( $taxonomy ) ) + return true; + + $queried_object = $this->get_queried_object(); + $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy ); + $term_array = (array) $term; + + // Check that the taxonomy matches. + if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) + return false; + + // Only a Taxonomy provided. + if ( empty( $term ) ) + return true; + + return isset( $queried_object->term_id ) && + count( array_intersect( + array( $queried_object->term_id, $queried_object->name, $queried_object->slug ), + $term_array + ) ); + } + + /** + * Whether the current URL is within the comments popup window. + * + * @since 3.1.0 + * @deprecated 4.5.0 + * + * @return bool + */ + public function is_comments_popup() { + _deprecated_function( __FUNCTION__, '4.5.0' ); + + return false; + } + + /** + * Is the query for an existing date archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_date() { + return (bool) $this->is_date; + } + + /** + * Is the query for an existing day archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_day() { + return (bool) $this->is_day; + } + + /** + * Is the query for a feed? + * + * @since 3.1.0 + * + * @param string|array $feeds Optional feed types to check. + * @return bool + */ + public function is_feed( $feeds = '' ) { + if ( empty( $feeds ) || ! $this->is_feed ) + return (bool) $this->is_feed; + $qv = $this->get( 'feed' ); + if ( 'feed' == $qv ) + $qv = get_default_feed(); + return in_array( $qv, (array) $feeds ); + } + + /** + * Is the query for a comments feed? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_comment_feed() { + return (bool) $this->is_comment_feed; + } + + /** + * Is the query for the front page of the site? + * + * This is for what is displayed at your site's main URL. + * + * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'. + * + * If you set a static page for the front page of your site, this function will return + * true when viewing that page. + * + * Otherwise the same as @see WP_Query::is_home() + * + * @since 3.1.0 + * + * @return bool True, if front of site. + */ + public function is_front_page() { + // most likely case + if ( 'posts' == get_option( 'show_on_front') && $this->is_home() ) + return true; + elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) + return true; + else + return false; + } + + /** + * Is the query for the blog homepage? + * + * This is the page which shows the time based blog content of your site. + * + * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'. + * + * If you set a static page for the front page of your site, this function will return + * true only on the page you set as the "Posts page". + * + * @see WP_Query::is_front_page() + * + * @since 3.1.0 + * + * @return bool True if blog view homepage. + */ + public function is_home() { + return (bool) $this->is_home; + } + + /** + * Is the query for an existing month archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_month() { + return (bool) $this->is_month; + } + + /** + * Is the query for an existing single page? + * + * If the $page parameter is specified, this function will additionally + * check if the query is for one of the pages specified. + * + * @see WP_Query::is_single() + * @see WP_Query::is_singular() + * + * @since 3.1.0 + * + * @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty. + * @return bool Whether the query is for an existing single page. + */ + public function is_page( $page = '' ) { + if ( !$this->is_page ) + return false; + + if ( empty( $page ) ) + return true; + + $page_obj = $this->get_queried_object(); + + $page = array_map( 'strval', (array) $page ); + + if ( in_array( (string) $page_obj->ID, $page ) ) { + return true; + } elseif ( in_array( $page_obj->post_title, $page ) ) { + return true; + } elseif ( in_array( $page_obj->post_name, $page ) ) { + return true; + } else { + foreach ( $page as $pagepath ) { + if ( ! strpos( $pagepath, '/' ) ) { + continue; + } + $pagepath_obj = get_page_by_path( $pagepath ); + + if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { + return true; + } + } + } + + return false; + } + + /** + * Is the query for paged result and not for the first page? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_paged() { + return (bool) $this->is_paged; + } + + /** + * Is the query for a post or page preview? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_preview() { + return (bool) $this->is_preview; + } + + /** + * Is the query for the robots file? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_robots() { + return (bool) $this->is_robots; + } + + /** + * Is the query for a search? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_search() { + return (bool) $this->is_search; + } + + /** + * Is the query for an existing single post? + * + * Works for any post type excluding pages. + * + * If the $post parameter is specified, this function will additionally + * check if the query is for one of the Posts specified. + * + * @see WP_Query::is_page() + * @see WP_Query::is_singular() + * + * @since 3.1.0 + * + * @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty. + * @return bool Whether the query is for an existing single post. + */ + public function is_single( $post = '' ) { + if ( !$this->is_single ) + return false; + + if ( empty($post) ) + return true; + + $post_obj = $this->get_queried_object(); + + $post = array_map( 'strval', (array) $post ); + + if ( in_array( (string) $post_obj->ID, $post ) ) { + return true; + } elseif ( in_array( $post_obj->post_title, $post ) ) { + return true; + } elseif ( in_array( $post_obj->post_name, $post ) ) { + return true; + } else { + foreach ( $post as $postpath ) { + if ( ! strpos( $postpath, '/' ) ) { + continue; + } + $postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); + + if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { + return true; + } + } + } + return false; + } + + /** + * Is the query for an existing single post of any post type (post, attachment, page, + * custom post types)? + * + * If the $post_types parameter is specified, this function will additionally + * check if the query is for one of the Posts Types specified. + * + * @see WP_Query::is_page() + * @see WP_Query::is_single() + * + * @since 3.1.0 + * + * @param string|array $post_types Optional. Post type or array of post types. Default empty. + * @return bool Whether the query is for an existing single post of any of the given post types. + */ + public function is_singular( $post_types = '' ) { + if ( empty( $post_types ) || !$this->is_singular ) + return (bool) $this->is_singular; + + $post_obj = $this->get_queried_object(); + + return in_array( $post_obj->post_type, (array) $post_types ); + } + + /** + * Is the query for a specific time? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_time() { + return (bool) $this->is_time; + } + + /** + * Is the query for a trackback endpoint call? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_trackback() { + return (bool) $this->is_trackback; + } + + /** + * Is the query for an existing year archive? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_year() { + return (bool) $this->is_year; + } + + /** + * Is the query a 404 (returns no results)? + * + * @since 3.1.0 + * + * @return bool + */ + public function is_404() { + return (bool) $this->is_404; + } + + /** + * Is the query for an embedded post? + * + * @since 4.4.0 + * + * @return bool + */ + public function is_embed() { + return (bool) $this->is_embed; + } + + /** + * Is the query the main query? + * + * @since 3.3.0 + * + * @global WP_Query $wp_query Global WP_Query instance. + * + * @return bool + */ + public function is_main_query() { + global $wp_the_query; + return $wp_the_query === $this; + } + + /** + * Set up global post data. + * + * @since 4.1.0 + * @since 4.4.0 Added the ability to pass a post ID to `$post`. + * + * @global int $id + * @global WP_User $authordata + * @global string|int|bool $currentday + * @global string|int|bool $currentmonth + * @global int $page + * @global array $pages + * @global int $multipage + * @global int $more + * @global int $numpages + * + * @param WP_Post|object|int $post WP_Post instance or Post ID/object. + * @return true True when finished. + */ + public function setup_postdata( $post ) { + global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; + + if ( ! ( $post instanceof WP_Post ) ) { + $post = get_post( $post ); + } + + if ( ! $post ) { + return; + } + + $id = (int) $post->ID; + + $authordata = get_userdata($post->post_author); + + $currentday = mysql2date('d.m.y', $post->post_date, false); + $currentmonth = mysql2date('m', $post->post_date, false); + $numpages = 1; + $multipage = 0; + $page = $this->get( 'page' ); + if ( ! $page ) + $page = 1; + + /* + * Force full post content when viewing the permalink for the $post, + * or when on an RSS feed. Otherwise respect the 'more' tag. + */ + if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) { + $more = 1; + } elseif ( $this->is_feed() ) { + $more = 1; + } else { + $more = 0; + } + + $content = $post->post_content; + if ( false !== strpos( $content, '<!--nextpage-->' ) ) { + $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content ); + $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content ); + $content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content ); + + // Ignore nextpage at the beginning of the content. + if ( 0 === strpos( $content, '<!--nextpage-->' ) ) + $content = substr( $content, 15 ); + + $pages = explode('<!--nextpage-->', $content); + } else { + $pages = array( $post->post_content ); + } + + /** + * Filters the "pages" derived from splitting the post content. + * + * "Pages" are determined by splitting the post content based on the presence + * of `<!-- nextpage -->` tags. + * + * @since 4.4.0 + * + * @param array $pages Array of "pages" derived from the post content. + * of `<!-- nextpage -->` tags.. + * @param WP_Post $post Current post object. + */ + $pages = apply_filters( 'content_pagination', $pages, $post ); + + $numpages = count( $pages ); + + if ( $numpages > 1 ) { + if ( $page > 1 ) { + $more = 1; + } + $multipage = 1; + } else { + $multipage = 0; + } + + /** + * Fires once the post data has been setup. + * + * @since 2.8.0 + * @since 4.1.0 Introduced `$this` parameter. + * + * @param WP_Post $post The Post object (passed by reference). + * @param WP_Query $this The current Query object (passed by reference). + */ + do_action_ref_array( 'the_post', array( &$post, &$this ) ); + + return true; + } + /** + * After looping through a nested query, this function + * restores the $post global to the current post in this query. + * + * @since 3.7.0 + * + * @global WP_Post $post + */ + public function reset_postdata() { + if ( ! empty( $this->post ) ) { + $GLOBALS['post'] = $this->post; + $this->setup_postdata( $this->post ); + } + } + + /** + * Lazyload term meta for posts in the loop. + * + * @since 4.4.0 + * @deprecated 4.5.0 See wp_queue_posts_for_term_meta_lazyload(). + * + * @param mixed $check + * @param int $term_id + * @return mixed + */ + public function lazyload_term_meta( $check, $term_id ) { + _deprecated_function( __METHOD__, '4.5.0' ); + return $check; + } + + /** + * Lazyload comment meta for comments in the loop. + * + * @since 4.4.0 + * @deprecated 4.5.0 See wp_queue_comments_for_comment_meta_lazyload(). + * + * @param mixed $check + * @param int $comment_id + * @return mixed + */ + public function lazyload_comment_meta( $check, $comment_id ) { + _deprecated_function( __METHOD__, '4.5.0' ); + return $check; + } +} diff --git a/backend/wp-includes/class-wp-rewrite.php b/backend/wp-includes/class-wp-rewrite.php new file mode 100644 index 0000000..21beaf6 --- /dev/null +++ b/backend/wp-includes/class-wp-rewrite.php @@ -0,0 +1,1891 @@ +<?php +/** + * Rewrite API: WP_Rewrite class + * + * @package WordPress + * @subpackage Rewrite + * @since 1.5.0 + */ + +/** + * Core class used to implement a rewrite component API. + * + * The WordPress Rewrite class writes the rewrite module rules to the .htaccess + * file. It also handles parsing the request to get the correct setup for the + * WordPress Query class. + * + * The Rewrite along with WP class function as a front controller for WordPress. + * You can add rules to trigger your page view and processing using this + * component. The full functionality of a front controller does not exist, + * meaning you can't define how the template files load based on the rewrite + * rules. + * + * @since 1.5.0 + */ +class WP_Rewrite { + /** + * Permalink structure for posts. + * + * @since 1.5.0 + * @var string + */ + public $permalink_structure; + + /** + * Whether to add trailing slashes. + * + * @since 2.2.0 + * @var bool + */ + public $use_trailing_slashes; + + /** + * Base for the author permalink structure (example.com/$author_base/authorname). + * + * @since 1.5.0 + * @var string + */ + var $author_base = 'author'; + + /** + * Permalink structure for author archives. + * + * @since 1.5.0 + * @var string + */ + var $author_structure; + + /** + * Permalink structure for date archives. + * + * @since 1.5.0 + * @var string + */ + var $date_structure; + + /** + * Permalink structure for pages. + * + * @since 1.5.0 + * @var string + */ + var $page_structure; + + /** + * Base of the search permalink structure (example.com/$search_base/query). + * + * @since 1.5.0 + * @var string + */ + var $search_base = 'search'; + + /** + * Permalink structure for searches. + * + * @since 1.5.0 + * @var string + */ + var $search_structure; + + /** + * Comments permalink base. + * + * @since 1.5.0 + * @var string + */ + var $comments_base = 'comments'; + + /** + * Pagination permalink base. + * + * @since 3.1.0 + * @var string + */ + public $pagination_base = 'page'; + + /** + * Comments pagination permalink base. + * + * @since 4.2.0 + * @var string + */ + var $comments_pagination_base = 'comment-page'; + + /** + * Feed permalink base. + * + * @since 1.5.0 + * @var string + */ + var $feed_base = 'feed'; + + /** + * Comments feed permalink structure. + * + * @since 1.5.0 + * @var string + */ + var $comment_feed_structure; + + /** + * Feed request permalink structure. + * + * @since 1.5.0 + * @var string + */ + var $feed_structure; + + /** + * The static portion of the post permalink structure. + * + * If the permalink structure is "/archive/%post_id%" then the front + * is "/archive/". If the permalink structure is "/%year%/%postname%/" + * then the front is "/". + * + * @since 1.5.0 + * @var string + * + * @see WP_Rewrite::init() + */ + public $front; + + /** + * The prefix for all permalink structures. + * + * If PATHINFO/index permalinks are in use then the root is the value of + * `WP_Rewrite::$index` with a trailing slash appended. Otherwise the root + * will be empty. + * + * @since 1.5.0 + * @var string + * + * @see WP_Rewrite::init() + * @see WP_Rewrite::using_index_permalinks() + */ + public $root = ''; + + /** + * The name of the index file which is the entry point to all requests. + * + * @since 1.5.0 + * @var string + */ + public $index = 'index.php'; + + /** + * Variable name to use for regex matches in the rewritten query. + * + * @since 1.5.0 + * @var string + */ + var $matches = ''; + + /** + * Rewrite rules to match against the request to find the redirect or query. + * + * @since 1.5.0 + * @var array + */ + var $rules; + + /** + * Additional rules added external to the rewrite class. + * + * Those not generated by the class, see add_rewrite_rule(). + * + * @since 2.1.0 + * @var array + */ + var $extra_rules = array(); + + /** + * Additional rules that belong at the beginning to match first. + * + * Those not generated by the class, see add_rewrite_rule(). + * + * @since 2.3.0 + * @var array + */ + var $extra_rules_top = array(); + + /** + * Rules that don't redirect to WordPress' index.php. + * + * These rules are written to the mod_rewrite portion of the .htaccess, + * and are added by add_external_rule(). + * + * @since 2.1.0 + * @var array + */ + var $non_wp_rules = array(); + + /** + * Extra permalink structures, e.g. categories, added by add_permastruct(). + * + * @since 2.1.0 + * @var array + */ + var $extra_permastructs = array(); + + /** + * Endpoints (like /trackback/) added by add_rewrite_endpoint(). + * + * @since 2.1.0 + * @var array + */ + var $endpoints; + + /** + * Whether to write every mod_rewrite rule for WordPress into the .htaccess file. + * + * This is off by default, turning it on might print a lot of rewrite rules + * to the .htaccess file. + * + * @since 2.0.0 + * @var bool + * + * @see WP_Rewrite::mod_rewrite_rules() + */ + public $use_verbose_rules = false; + + /** + * Could post permalinks be confused with those of pages? + * + * If the first rewrite tag in the post permalink structure is one that could + * also match a page name (e.g. %postname% or %author%) then this flag is + * set to true. Prior to WordPress 3.3 this flag indicated that every page + * would have a set of rules added to the top of the rewrite rules array. + * Now it tells WP::parse_request() to check if a URL matching the page + * permastruct is actually a page before accepting it. + * + * @since 2.5.0 + * @var bool + * + * @see WP_Rewrite::init() + */ + public $use_verbose_page_rules = true; + + /** + * Rewrite tags that can be used in permalink structures. + * + * These are translated into the regular expressions stored in + * `WP_Rewrite::$rewritereplace` and are rewritten to the query + * variables listed in WP_Rewrite::$queryreplace. + * + * Additional tags can be added with add_rewrite_tag(). + * + * @since 1.5.0 + * @var array + */ + var $rewritecode = array( + '%year%', + '%monthnum%', + '%day%', + '%hour%', + '%minute%', + '%second%', + '%postname%', + '%post_id%', + '%author%', + '%pagename%', + '%search%' + ); + + /** + * Regular expressions to be substituted into rewrite rules in place + * of rewrite tags, see WP_Rewrite::$rewritecode. + * + * @since 1.5.0 + * @var array + */ + var $rewritereplace = array( + '([0-9]{4})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([0-9]{1,2})', + '([^/]+)', + '([0-9]+)', + '([^/]+)', + '([^/]+?)', + '(.+)' + ); + + /** + * Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode. + * + * @since 1.5.0 + * @var array + */ + var $queryreplace = array( + 'year=', + 'monthnum=', + 'day=', + 'hour=', + 'minute=', + 'second=', + 'name=', + 'p=', + 'author_name=', + 'pagename=', + 's=' + ); + + /** + * Supported default feeds. + * + * @since 1.5.0 + * @var array + */ + public $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); + + /** + * Determines whether permalinks are being used. + * + * This can be either rewrite module or permalink in the HTTP query string. + * + * @since 1.5.0 + * + * @return bool True, if permalinks are enabled. + */ + public function using_permalinks() { + return ! empty($this->permalink_structure); + } + + /** + * Determines whether permalinks are being used and rewrite module is not enabled. + * + * Means that permalink links are enabled and index.php is in the URL. + * + * @since 1.5.0 + * + * @return bool Whether permalink links are enabled and index.php is in the URL. + */ + public function using_index_permalinks() { + if ( empty( $this->permalink_structure ) ) { + return false; + } + + // If the index is not in the permalink, we're using mod_rewrite. + return preg_match( '#^/*' . $this->index . '#', $this->permalink_structure ); + } + + /** + * Determines whether permalinks are being used and rewrite module is enabled. + * + * Using permalinks and index.php is not in the URL. + * + * @since 1.5.0 + * + * @return bool Whether permalink links are enabled and index.php is NOT in the URL. + */ + public function using_mod_rewrite_permalinks() { + return $this->using_permalinks() && ! $this->using_index_permalinks(); + } + + /** + * Indexes for matches for usage in preg_*() functions. + * + * The format of the string is, with empty matches property value, '$NUM'. + * The 'NUM' will be replaced with the value in the $number parameter. With + * the matches property not empty, the value of the returned string will + * contain that value of the matches property. The format then will be + * '$MATCHES[NUM]', with MATCHES as the value in the property and NUM the + * value of the $number parameter. + * + * @since 1.5.0 + * + * @param int $number Index number. + * @return string + */ + public function preg_index($number) { + $match_prefix = '$'; + $match_suffix = ''; + + if ( ! empty($this->matches) ) { + $match_prefix = '$' . $this->matches . '['; + $match_suffix = ']'; + } + + return "$match_prefix$number$match_suffix"; + } + + /** + * Retrieves all page and attachments for pages URIs. + * + * The attachments are for those that have pages as parents and will be + * retrieved. + * + * @since 2.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return array Array of page URIs as first element and attachment URIs as second element. + */ + public function page_uri_index() { + global $wpdb; + + // Get pages in order of hierarchy, i.e. children after parents. + $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page' AND post_status != 'auto-draft'"); + $posts = get_page_hierarchy( $pages ); + + // If we have no pages get out quick. + if ( !$posts ) + return array( array(), array() ); + + // Now reverse it, because we need parents after children for rewrite rules to work properly. + $posts = array_reverse($posts, true); + + $page_uris = array(); + $page_attachment_uris = array(); + + foreach ( $posts as $id => $post ) { + // URL => page name + $uri = get_page_uri($id); + $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id )); + if ( !empty($attachments) ) { + foreach ( $attachments as $attachment ) { + $attach_uri = get_page_uri($attachment->ID); + $page_attachment_uris[$attach_uri] = $attachment->ID; + } + } + + $page_uris[$uri] = $id; + } + + return array( $page_uris, $page_attachment_uris ); + } + + /** + * Retrieves all of the rewrite rules for pages. + * + * @since 1.5.0 + * + * @return array Page rewrite rules. + */ + public function page_rewrite_rules() { + // The extra .? at the beginning prevents clashes with other regular expressions in the rules array. + $this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' ); + + return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false ); + } + + /** + * Retrieves date permalink structure, with year, month, and day. + * + * The permalink structure for the date, if not set already depends on the + * permalink structure. It can be one of three formats. The first is year, + * month, day; the second is day, month, year; and the last format is month, + * day, year. These are matched against the permalink structure for which + * one is used. If none matches, then the default will be used, which is + * year, month, day. + * + * Prevents post ID and date permalinks from overlapping. In the case of + * post_id, the date permalink will be prepended with front permalink with + * 'date/' before the actual permalink to form the complete date permalink + * structure. + * + * @since 1.5.0 + * + * @return string|false False on no permalink structure. Date permalink structure. + */ + public function get_date_permastruct() { + if ( isset($this->date_structure) ) + return $this->date_structure; + + if ( empty($this->permalink_structure) ) { + $this->date_structure = ''; + return false; + } + + // The date permalink must have year, month, and day separated by slashes. + $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%'); + + $this->date_structure = ''; + $date_endian = ''; + + foreach ( $endians as $endian ) { + if ( false !== strpos($this->permalink_structure, $endian) ) { + $date_endian= $endian; + break; + } + } + + if ( empty($date_endian) ) + $date_endian = '%year%/%monthnum%/%day%'; + + /* + * Do not allow the date tags and %post_id% to overlap in the permalink + * structure. If they do, move the date tags to $front/date/. + */ + $front = $this->front; + preg_match_all('/%.+?%/', $this->permalink_structure, $tokens); + $tok_index = 1; + foreach ( (array) $tokens[0] as $token) { + if ( '%post_id%' == $token && ($tok_index <= 3) ) { + $front = $front . 'date/'; + break; + } + $tok_index++; + } + + $this->date_structure = $front . $date_endian; + + return $this->date_structure; + } + + /** + * Retrieves the year permalink structure without month and day. + * + * Gets the date permalink structure and strips out the month and day + * permalink structures. + * + * @since 1.5.0 + * + * @return false|string False on failure. Year structure on success. + */ + public function get_year_permastruct() { + $structure = $this->get_date_permastruct(); + + if ( empty($structure) ) + return false; + + $structure = str_replace('%monthnum%', '', $structure); + $structure = str_replace('%day%', '', $structure); + $structure = preg_replace('#/+#', '/', $structure); + + return $structure; + } + + /** + * Retrieves the month permalink structure without day and with year. + * + * Gets the date permalink structure and strips out the day permalink + * structures. Keeps the year permalink structure. + * + * @since 1.5.0 + * + * @return false|string False on failure. Year/Month structure on success. + */ + public function get_month_permastruct() { + $structure = $this->get_date_permastruct(); + + if ( empty($structure) ) + return false; + + $structure = str_replace('%day%', '', $structure); + $structure = preg_replace('#/+#', '/', $structure); + + return $structure; + } + + /** + * Retrieves the day permalink structure with month and year. + * + * Keeps date permalink structure with all year, month, and day. + * + * @since 1.5.0 + * + * @return string|false False on failure. Year/Month/Day structure on success. + */ + public function get_day_permastruct() { + return $this->get_date_permastruct(); + } + + /** + * Retrieves the permalink structure for categories. + * + * If the category_base property has no value, then the category structure + * will have the front property value, followed by 'category', and finally + * '%category%'. If it does, then the root property will be used, along with + * the category_base property value. + * + * @since 1.5.0 + * + * @return string|false False on failure. Category permalink structure. + */ + public function get_category_permastruct() { + return $this->get_extra_permastruct('category'); + } + + /** + * Retrieve the permalink structure for tags. + * + * If the tag_base property has no value, then the tag structure will have + * the front property value, followed by 'tag', and finally '%tag%'. If it + * does, then the root property will be used, along with the tag_base + * property value. + * + * @since 2.3.0 + * + * @return string|false False on failure. Tag permalink structure. + */ + public function get_tag_permastruct() { + return $this->get_extra_permastruct('post_tag'); + } + + /** + * Retrieves an extra permalink structure by name. + * + * @since 2.5.0 + * + * @param string $name Permalink structure name. + * @return string|false False if not found. Permalink structure string. + */ + public function get_extra_permastruct($name) { + if ( empty($this->permalink_structure) ) + return false; + + if ( isset($this->extra_permastructs[$name]) ) + return $this->extra_permastructs[$name]['struct']; + + return false; + } + + /** + * Retrieves the author permalink structure. + * + * The permalink structure is front property, author base, and finally + * '/%author%'. Will set the author_structure property and then return it + * without attempting to set the value again. + * + * @since 1.5.0 + * + * @return string|false False if not found. Permalink structure string. + */ + public function get_author_permastruct() { + if ( isset($this->author_structure) ) + return $this->author_structure; + + if ( empty($this->permalink_structure) ) { + $this->author_structure = ''; + return false; + } + + $this->author_structure = $this->front . $this->author_base . '/%author%'; + + return $this->author_structure; + } + + /** + * Retrieves the search permalink structure. + * + * The permalink structure is root property, search base, and finally + * '/%search%'. Will set the search_structure property and then return it + * without attempting to set the value again. + * + * @since 1.5.0 + * + * @return string|false False if not found. Permalink structure string. + */ + public function get_search_permastruct() { + if ( isset($this->search_structure) ) + return $this->search_structure; + + if ( empty($this->permalink_structure) ) { + $this->search_structure = ''; + return false; + } + + $this->search_structure = $this->root . $this->search_base . '/%search%'; + + return $this->search_structure; + } + + /** + * Retrieves the page permalink structure. + * + * The permalink structure is root property, and '%pagename%'. Will set the + * page_structure property and then return it without attempting to set the + * value again. + * + * @since 1.5.0 + * + * @return string|false False if not found. Permalink structure string. + */ + public function get_page_permastruct() { + if ( isset($this->page_structure) ) + return $this->page_structure; + + if (empty($this->permalink_structure)) { + $this->page_structure = ''; + return false; + } + + $this->page_structure = $this->root . '%pagename%'; + + return $this->page_structure; + } + + /** + * Retrieves the feed permalink structure. + * + * The permalink structure is root property, feed base, and finally + * '/%feed%'. Will set the feed_structure property and then return it + * without attempting to set the value again. + * + * @since 1.5.0 + * + * @return string|false False if not found. Permalink structure string. + */ + public function get_feed_permastruct() { + if ( isset($this->feed_structure) ) + return $this->feed_structure; + + if ( empty($this->permalink_structure) ) { + $this->feed_structure = ''; + return false; + } + + $this->feed_structure = $this->root . $this->feed_base . '/%feed%'; + + return $this->feed_structure; + } + + /** + * Retrieves the comment feed permalink structure. + * + * The permalink structure is root property, comment base property, feed + * base and finally '/%feed%'. Will set the comment_feed_structure property + * and then return it without attempting to set the value again. + * + * @since 1.5.0 + * + * @return string|false False if not found. Permalink structure string. + */ + public function get_comment_feed_permastruct() { + if ( isset($this->comment_feed_structure) ) + return $this->comment_feed_structure; + + if (empty($this->permalink_structure)) { + $this->comment_feed_structure = ''; + return false; + } + + $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%'; + + return $this->comment_feed_structure; + } + + /** + * Adds or updates existing rewrite tags (e.g. %postname%). + * + * If the tag already exists, replace the existing pattern and query for + * that tag, otherwise add the new tag. + * + * @since 1.5.0 + * + * @see WP_Rewrite::$rewritecode + * @see WP_Rewrite::$rewritereplace + * @see WP_Rewrite::$queryreplace + * + * @param string $tag Name of the rewrite tag to add or update. + * @param string $regex Regular expression to substitute the tag for in rewrite rules. + * @param string $query String to append to the rewritten query. Must end in '='. + */ + public function add_rewrite_tag( $tag, $regex, $query ) { + $position = array_search( $tag, $this->rewritecode ); + if ( false !== $position && null !== $position ) { + $this->rewritereplace[ $position ] = $regex; + $this->queryreplace[ $position ] = $query; + } else { + $this->rewritecode[] = $tag; + $this->rewritereplace[] = $regex; + $this->queryreplace[] = $query; + } + } + + + /** + * Removes an existing rewrite tag. + * + * @since 4.5.0 + * + * @see WP_Rewrite::$rewritecode + * @see WP_Rewrite::$rewritereplace + * @see WP_Rewrite::$queryreplace + * + * @param string $tag Name of the rewrite tag to remove. + */ + public function remove_rewrite_tag( $tag ) { + $position = array_search( $tag, $this->rewritecode ); + if ( false !== $position && null !== $position ) { + unset( $this->rewritecode[ $position ] ); + unset( $this->rewritereplace[ $position ] ); + unset( $this->queryreplace[ $position ] ); + } + } + + /** + * Generates rewrite rules from a permalink structure. + * + * The main WP_Rewrite function for building the rewrite rule list. The + * contents of the function is a mix of black magic and regular expressions, + * so best just ignore the contents and move to the parameters. + * + * @since 1.5.0 + * + * @param string $permalink_structure The permalink structure. + * @param int $ep_mask Optional. Endpoint mask defining what endpoints are added to the structure. + * Accepts `EP_NONE`, `EP_PERMALINK`, `EP_ATTACHMENT`, `EP_DATE`, `EP_YEAR`, + * `EP_MONTH`, `EP_DAY`, `EP_ROOT`, `EP_COMMENTS`, `EP_SEARCH`, `EP_CATEGORIES`, + * `EP_TAGS`, `EP_AUTHORS`, `EP_PAGES`, `EP_ALL_ARCHIVES`, and `EP_ALL`. + * Default `EP_NONE`. + * @param bool $paged Optional. Whether archive pagination rules should be added for the structure. + * Default true. + * @param bool $feed Optional Whether feed rewrite rules should be added for the structure. + * Default true. + * @param bool $forcomments Optional. Whether the feed rules should be a query for a comments feed. + * Default false. + * @param bool $walk_dirs Optional. Whether the 'directories' making up the structure should be walked + * over and rewrite rules built for each in-turn. Default true. + * @param bool $endpoints Optional. Whether endpoints should be applied to the generated rewrite rules. + * Default true. + * @return array Rewrite rule list. + */ + public function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) { + // Build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? + $feedregex2 = ''; + foreach ( (array) $this->feeds as $feed_name) + $feedregex2 .= $feed_name . '|'; + $feedregex2 = '(' . trim($feedregex2, '|') . ')/?$'; + + /* + * $feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom + * and <permalink>/atom are both possible + */ + $feedregex = $this->feed_base . '/' . $feedregex2; + + // Build a regex to match the trackback and page/xx parts of URLs. + $trackbackregex = 'trackback/?$'; + $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$'; + $commentregex = $this->comments_pagination_base . '-([0-9]{1,})/?$'; + $embedregex = 'embed/?$'; + + // Build up an array of endpoint regexes to append => queries to append. + if ( $endpoints ) { + $ep_query_append = array (); + foreach ( (array) $this->endpoints as $endpoint) { + // Match everything after the endpoint name, but allow for nothing to appear there. + $epmatch = $endpoint[1] . '(/(.*))?/?$'; + + // This will be appended on to the rest of the query for each dir. + $epquery = '&' . $endpoint[2] . '='; + $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery ); + } + } + + // Get everything up to the first rewrite tag. + $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); + + // Build an array of the tags (note that said array ends up being in $tokens[0]). + preg_match_all('/%.+?%/', $permalink_structure, $tokens); + + $num_tokens = count($tokens[0]); + + $index = $this->index; //probably 'index.php' + $feedindex = $index; + $trackbackindex = $index; + $embedindex = $index; + + /* + * Build a list from the rewritecode and queryreplace arrays, that will look something + * like tagname=$matches[i] where i is the current $i. + */ + $queries = array(); + for ( $i = 0; $i < $num_tokens; ++$i ) { + if ( 0 < $i ) + $queries[$i] = $queries[$i - 1] . '&'; + else + $queries[$i] = ''; + + $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1); + $queries[$i] .= $query_token; + } + + // Get the structure, minus any cruft (stuff that isn't tags) at the front. + $structure = $permalink_structure; + if ( $front != '/' ) + $structure = str_replace($front, '', $structure); + + /* + * Create a list of dirs to walk over, making rewrite rules for each level + * so for example, a $structure of /%year%/%monthnum%/%postname% would create + * rewrite rules for /%year%/, /%year%/%monthnum%/ and /%year%/%monthnum%/%postname% + */ + $structure = trim($structure, '/'); + $dirs = $walk_dirs ? explode('/', $structure) : array( $structure ); + $num_dirs = count($dirs); + + // Strip slashes from the front of $front. + $front = preg_replace('|^/+|', '', $front); + + // The main workhorse loop. + $post_rewrite = array(); + $struct = $front; + for ( $j = 0; $j < $num_dirs; ++$j ) { + // Get the struct for this dir, and trim slashes off the front. + $struct .= $dirs[$j] . '/'; // Accumulate. see comment near explode('/', $structure) above. + $struct = ltrim($struct, '/'); + + // Replace tags with regexes. + $match = str_replace($this->rewritecode, $this->rewritereplace, $struct); + + // Make a list of tags, and store how many there are in $num_toks. + $num_toks = preg_match_all('/%.+?%/', $struct, $toks); + + // Get the 'tagname=$matches[i]'. + $query = ( ! empty( $num_toks ) && isset( $queries[$num_toks - 1] ) ) ? $queries[$num_toks - 1] : ''; + + // Set up $ep_mask_specific which is used to match more specific URL types. + switch ( $dirs[$j] ) { + case '%year%': + $ep_mask_specific = EP_YEAR; + break; + case '%monthnum%': + $ep_mask_specific = EP_MONTH; + break; + case '%day%': + $ep_mask_specific = EP_DAY; + break; + default: + $ep_mask_specific = EP_NONE; + } + + // Create query for /page/xx. + $pagematch = $match . $pageregex; + $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1); + + // Create query for /comment-page-xx. + $commentmatch = $match . $commentregex; + $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1); + + if ( get_option('page_on_front') ) { + // Create query for Root /comment-page-xx. + $rootcommentmatch = $match . $commentregex; + $rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1); + } + + // Create query for /feed/(feed|atom|rss|rss2|rdf). + $feedmatch = $match . $feedregex; + $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); + + // Create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex). + $feedmatch2 = $match . $feedregex2; + $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1); + + // Create query and regex for embeds. + $embedmatch = $match . $embedregex; + $embedquery = $embedindex . '?' . $query . '&embed=true'; + + // If asked to, turn the feed queries into comment feed ones. + if ( $forcomments ) { + $feedquery .= '&withcomments=1'; + $feedquery2 .= '&withcomments=1'; + } + + // Start creating the array of rewrites for this dir. + $rewrite = array(); + + // ...adding on /feed/ regexes => queries + if ( $feed ) { + $rewrite = array( $feedmatch => $feedquery, $feedmatch2 => $feedquery2, $embedmatch => $embedquery ); + } + + //...and /page/xx ones + if ( $paged ) { + $rewrite = array_merge( $rewrite, array( $pagematch => $pagequery ) ); + } + + // Only on pages with comments add ../comment-page-xx/. + if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) { + $rewrite = array_merge($rewrite, array($commentmatch => $commentquery)); + } elseif ( EP_ROOT & $ep_mask && get_option('page_on_front') ) { + $rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery)); + } + + // Do endpoints. + if ( $endpoints ) { + foreach ( (array) $ep_query_append as $regex => $ep) { + // Add the endpoints on if the mask fits. + if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) + $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); + } + } + + // If we've got some tags in this dir. + if ( $num_toks ) { + $post = false; + $page = false; + + /* + * Check to see if this dir is permalink-level: i.e. the structure specifies an + * individual post. Do this by checking it contains at least one of 1) post name, + * 2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and + * minute all present). Set these flags now as we need them for the endpoints. + */ + if ( strpos($struct, '%postname%') !== false + || strpos($struct, '%post_id%') !== false + || strpos($struct, '%pagename%') !== false + || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false) + ) { + $post = true; + if ( strpos($struct, '%pagename%') !== false ) + $page = true; + } + + if ( ! $post ) { + // For custom post types, we need to add on endpoints as well. + foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) { + if ( strpos($struct, "%$ptype%") !== false ) { + $post = true; + + // This is for page style attachment URLs. + $page = is_post_type_hierarchical( $ptype ); + break; + } + } + } + + // If creating rules for a permalink, do all the endpoints like attachments etc. + if ( $post ) { + // Create query and regex for trackback. + $trackbackmatch = $match . $trackbackregex; + $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; + + // Create query and regex for embeds. + $embedmatch = $match . $embedregex; + $embedquery = $embedindex . '?' . $query . '&embed=true'; + + // Trim slashes from the end of the regex for this dir. + $match = rtrim($match, '/'); + + // Get rid of brackets. + $submatchbase = str_replace( array('(', ')'), '', $match); + + // Add a rule for at attachments, which take the form of <permalink>/some-text. + $sub1 = $submatchbase . '/([^/]+)/'; + + // Add trackback regex <permalink>/trackback/... + $sub1tb = $sub1 . $trackbackregex; + + // And <permalink>/feed/(atom|...) + $sub1feed = $sub1 . $feedregex; + + // And <permalink>/(feed|atom...) + $sub1feed2 = $sub1 . $feedregex2; + + // And <permalink>/comment-page-xx + $sub1comment = $sub1 . $commentregex; + + // And <permalink>/embed/... + $sub1embed = $sub1 . $embedregex; + + /* + * Add another rule to match attachments in the explicit form: + * <permalink>/attachment/some-text + */ + $sub2 = $submatchbase . '/attachment/([^/]+)/'; + + // And add trackbacks <permalink>/attachment/trackback. + $sub2tb = $sub2 . $trackbackregex; + + // Feeds, <permalink>/attachment/feed/(atom|...) + $sub2feed = $sub2 . $feedregex; + + // And feeds again on to this <permalink>/attachment/(feed|atom...) + $sub2feed2 = $sub2 . $feedregex2; + + // And <permalink>/comment-page-xx + $sub2comment = $sub2 . $commentregex; + + // And <permalink>/embed/... + $sub2embed = $sub2 . $embedregex; + + // Create queries for these extra tag-ons we've just dealt with. + $subquery = $index . '?attachment=' . $this->preg_index(1); + $subtbquery = $subquery . '&tb=1'; + $subfeedquery = $subquery . '&feed=' . $this->preg_index(2); + $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2); + $subembedquery = $subquery . '&embed=true'; + + // Do endpoints for attachments. + if ( !empty($endpoints) ) { + foreach ( (array) $ep_query_append as $regex => $ep ) { + if ( $ep[0] & EP_ATTACHMENT ) { + $rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(3); + $rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(3); + } + } + } + + /* + * Now we've finished with endpoints, finish off the $sub1 and $sub2 matches + * add a ? as we don't have to match that last slash, and finally a $ so we + * match to the end of the URL + */ + $sub1 .= '?$'; + $sub2 .= '?$'; + + /* + * Post pagination, e.g. <permalink>/2/ + * Previously: '(/[0-9]+)?/?$', which produced '/2' for page. + * When cast to int, returned 0. + */ + $match = $match . '(?:/([0-9]+))?/?$'; + $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); + + // Not matching a permalink so this is a lot simpler. + } else { + // Close the match and finalise the query. + $match .= '?$'; + $query = $index . '?' . $query; + } + + /* + * Create the final array for this dir by joining the $rewrite array (which currently + * only contains rules/queries for trackback, pages etc) to the main regex/query for + * this dir + */ + $rewrite = array_merge($rewrite, array($match => $query)); + + // If we're matching a permalink, add those extras (attachments etc) on. + if ( $post ) { + // Add trackback. + $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite); + + // Add embed. + $rewrite = array_merge( array( $embedmatch => $embedquery ), $rewrite ); + + // Add regexes/queries for attachments, attachment trackbacks and so on. + if ( ! $page ) { + // Require <permalink>/attachment/stuff form for pages because of confusion with subpages. + $rewrite = array_merge( $rewrite, array( + $sub1 => $subquery, + $sub1tb => $subtbquery, + $sub1feed => $subfeedquery, + $sub1feed2 => $subfeedquery, + $sub1comment => $subcommentquery, + $sub1embed => $subembedquery + ) ); + } + + $rewrite = array_merge( array( $sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery, $sub2embed => $subembedquery ), $rewrite ); + } + } + // Add the rules for this dir to the accumulating $post_rewrite. + $post_rewrite = array_merge($rewrite, $post_rewrite); + } + + // The finished rules. phew! + return $post_rewrite; + } + + /** + * Generates rewrite rules with permalink structure and walking directory only. + * + * Shorten version of WP_Rewrite::generate_rewrite_rules() that allows for shorter + * list of parameters. See the method for longer description of what generating + * rewrite rules does. + * + * @since 1.5.0 + * + * @see WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters. + * + * @param string $permalink_structure The permalink structure to generate rules. + * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over. + * @return array + */ + public function generate_rewrite_rule($permalink_structure, $walk_dirs = false) { + return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs); + } + + /** + * Constructs rewrite matches and queries from permalink structure. + * + * Runs the action {@see 'generate_rewrite_rules'} with the parameter that is an + * reference to the current WP_Rewrite instance to further manipulate the + * permalink structures and rewrite rules. Runs the {@see 'rewrite_rules_array'} + * filter on the full rewrite rule array. + * + * There are two ways to manipulate the rewrite rules, one by hooking into + * the {@see 'generate_rewrite_rules'} action and gaining full control of the + * object or just manipulating the rewrite rule array before it is passed + * from the function. + * + * @since 1.5.0 + * + * @return array An associate array of matches and queries. + */ + public function rewrite_rules() { + $rewrite = array(); + + if ( empty($this->permalink_structure) ) + return $rewrite; + + // robots.txt -only if installed at the root + $home_path = parse_url( home_url() ); + $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); + + // Old feed and service files. + $deprecated_files = array( + '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\.php$' => $this->index . '?feed=old', + '.*wp-app\.php(/.*)?$' => $this->index . '?error=403', + ); + + // Registration rules. + $registration_pages = array(); + if ( is_multisite() && is_main_site() ) { + $registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true'; + $registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true'; + } + + // Deprecated. + $registration_pages['.*wp-register.php$'] = $this->index . '?register=true'; + + // Post rewrite rules. + $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK ); + + /** + * Filters rewrite rules used for "post" archives. + * + * @since 1.5.0 + * + * @param array $post_rewrite The rewrite rules for posts. + */ + $post_rewrite = apply_filters( 'post_rewrite_rules', $post_rewrite ); + + // Date rewrite rules. + $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE); + + /** + * Filters rewrite rules used for date archives. + * + * Likely date archives would include /yyyy/, /yyyy/mm/, and /yyyy/mm/dd/. + * + * @since 1.5.0 + * + * @param array $date_rewrite The rewrite rules for date archives. + */ + $date_rewrite = apply_filters( 'date_rewrite_rules', $date_rewrite ); + + // Root-level rewrite rules. + $root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT); + + /** + * Filters rewrite rules used for root-level archives. + * + * Likely root-level archives would include pagination rules for the homepage + * as well as site-wide post feeds (e.g. /feed/, and /feed/atom/). + * + * @since 1.5.0 + * + * @param array $root_rewrite The root-level rewrite rules. + */ + $root_rewrite = apply_filters( 'root_rewrite_rules', $root_rewrite ); + + // Comments rewrite rules. + $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, false, true, true, false); + + /** + * Filters rewrite rules used for comment feed archives. + * + * Likely comments feed archives include /comments/feed/, and /comments/feed/atom/. + * + * @since 1.5.0 + * + * @param array $comments_rewrite The rewrite rules for the site-wide comments feeds. + */ + $comments_rewrite = apply_filters( 'comments_rewrite_rules', $comments_rewrite ); + + // Search rewrite rules. + $search_structure = $this->get_search_permastruct(); + $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH); + + /** + * Filters rewrite rules used for search archives. + * + * Likely search-related archives include /search/search+query/ as well as + * pagination and feed paths for a search. + * + * @since 1.5.0 + * + * @param array $search_rewrite The rewrite rules for search queries. + */ + $search_rewrite = apply_filters( 'search_rewrite_rules', $search_rewrite ); + + // Author rewrite rules. + $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS); + + /** + * Filters rewrite rules used for author archives. + * + * Likely author archives would include /author/author-name/, as well as + * pagination and feed paths for author archives. + * + * @since 1.5.0 + * + * @param array $author_rewrite The rewrite rules for author archives. + */ + $author_rewrite = apply_filters( 'author_rewrite_rules', $author_rewrite ); + + // Pages rewrite rules. + $page_rewrite = $this->page_rewrite_rules(); + + /** + * Filters rewrite rules used for "page" post type archives. + * + * @since 1.5.0 + * + * @param array $page_rewrite The rewrite rules for the "page" post type. + */ + $page_rewrite = apply_filters( 'page_rewrite_rules', $page_rewrite ); + + // Extra permastructs. + foreach ( $this->extra_permastructs as $permastructname => $struct ) { + if ( is_array( $struct ) ) { + if ( count( $struct ) == 2 ) + $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); + else + $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); + } else { + $rules = $this->generate_rewrite_rules( $struct ); + } + + /** + * Filters rewrite rules used for individual permastructs. + * + * The dynamic portion of the hook name, `$permastructname`, refers + * to the name of the registered permastruct, e.g. 'post_tag' (tags), + * 'category' (categories), etc. + * + * @since 3.1.0 + * + * @param array $rules The rewrite rules generated for the current permastruct. + */ + $rules = apply_filters( "{$permastructname}_rewrite_rules", $rules ); + if ( 'post_tag' == $permastructname ) { + + /** + * Filters rewrite rules used specifically for Tags. + * + * @since 2.3.0 + * @deprecated 3.1.0 Use 'post_tag_rewrite_rules' instead + * + * @param array $rules The rewrite rules generated for tags. + */ + $rules = apply_filters( 'tag_rewrite_rules', $rules ); + } + + $this->extra_rules_top = array_merge($this->extra_rules_top, $rules); + } + + // Put them together. + if ( $this->use_verbose_page_rules ) + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); + else + $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); + + /** + * Fires after the rewrite rules are generated. + * + * @since 1.5.0 + * + * @param WP_Rewrite $this Current WP_Rewrite instance (passed by reference). + */ + do_action_ref_array( 'generate_rewrite_rules', array( &$this ) ); + + /** + * Filters the full set of generated rewrite rules. + * + * @since 1.5.0 + * + * @param array $this->rules The compiled array of rewrite rules. + */ + $this->rules = apply_filters( 'rewrite_rules_array', $this->rules ); + + return $this->rules; + } + + /** + * Retrieves the rewrite rules. + * + * The difference between this method and WP_Rewrite::rewrite_rules() is that + * this method stores the rewrite rules in the 'rewrite_rules' option and retrieves + * it. This prevents having to process all of the permalinks to get the rewrite rules + * in the form of caching. + * + * @since 1.5.0 + * + * @return array Rewrite rules. + */ + public function wp_rewrite_rules() { + $this->rules = get_option('rewrite_rules'); + if ( empty($this->rules) ) { + $this->matches = 'matches'; + $this->rewrite_rules(); + if ( ! did_action( 'wp_loaded' ) ) { + add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); + return $this->rules; + } + update_option('rewrite_rules', $this->rules); + } + + return $this->rules; + } + + /** + * Retrieves mod_rewrite-formatted rewrite rules to write to .htaccess. + * + * Does not actually write to the .htaccess file, but creates the rules for + * the process that will. + * + * Will add the non_wp_rules property rules to the .htaccess file before + * the WordPress rewrite rules one. + * + * @since 1.5.0 + * + * @return string + */ + public function mod_rewrite_rules() { + if ( ! $this->using_permalinks() ) + return ''; + + $site_root = parse_url( site_url() ); + if ( isset( $site_root['path'] ) ) + $site_root = trailingslashit($site_root['path']); + + $home_root = parse_url(home_url()); + if ( isset( $home_root['path'] ) ) + $home_root = trailingslashit($home_root['path']); + else + $home_root = '/'; + + $rules = "<IfModule mod_rewrite.c>\n"; + $rules .= "RewriteEngine On\n"; + $rules .= "RewriteBase $home_root\n"; + + // Prevent -f checks on index.php. + $rules .= "RewriteRule ^index\.php$ - [L]\n"; + + // Add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all). + foreach ( (array) $this->non_wp_rules as $match => $query) { + // Apache 1.3 does not support the reluctant (non-greedy) modifier. + $match = str_replace('.+?', '.+', $match); + + $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; + } + + if ( $this->use_verbose_rules ) { + $this->matches = ''; + $rewrite = $this->rewrite_rules(); + $num_rules = count($rewrite); + $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" . + "RewriteCond %{REQUEST_FILENAME} -d\n" . + "RewriteRule ^.*$ - [S=$num_rules]\n"; + + foreach ( (array) $rewrite as $match => $query) { + // Apache 1.3 does not support the reluctant (non-greedy) modifier. + $match = str_replace('.+?', '.+', $match); + + if ( strpos($query, $this->index) !== false ) + $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; + else + $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; + } + } else { + $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" . + "RewriteCond %{REQUEST_FILENAME} !-d\n" . + "RewriteRule . {$home_root}{$this->index} [L]\n"; + } + + $rules .= "</IfModule>\n"; + + /** + * Filters the list of rewrite rules formatted for output to an .htaccess file. + * + * @since 1.5.0 + * + * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. + */ + $rules = apply_filters( 'mod_rewrite_rules', $rules ); + + /** + * Filters the list of rewrite rules formatted for output to an .htaccess file. + * + * @since 1.5.0 + * @deprecated 1.5.0 Use the mod_rewrite_rules filter instead. + * + * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. + */ + return apply_filters( 'rewrite_rules', $rules ); + } + + /** + * Retrieves IIS7 URL Rewrite formatted rewrite rules to write to web.config file. + * + * Does not actually write to the web.config file, but creates the rules for + * the process that will. + * + * @since 2.8.0 + * + * @param bool $add_parent_tags Optional. Whether to add parent tags to the rewrite rule sets. + * Default false. + * @return string IIS7 URL rewrite rule sets. + */ + public function iis7_url_rewrite_rules( $add_parent_tags = false ) { + if ( ! $this->using_permalinks() ) + return ''; + $rules = ''; + if ( $add_parent_tags ) { + $rules .= '<configuration> + <system.webServer> + <rewrite> + <rules>'; + } + + $rules .= ' + <rule name="WordPress: ' . esc_attr( home_url() ) . '" patternSyntax="Wildcard"> + <match url="*" /> + <conditions> + <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> + <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> + </conditions> + <action type="Rewrite" url="index.php" /> + </rule>'; + + if ( $add_parent_tags ) { + $rules .= ' + </rules> + </rewrite> + </system.webServer> +</configuration>'; + } + + /** + * Filters the list of rewrite rules formatted for output to a web.config. + * + * @since 2.8.0 + * + * @param string $rules Rewrite rules formatted for IIS web.config. + */ + return apply_filters( 'iis7_url_rewrite_rules', $rules ); + } + + /** + * Adds a rewrite rule that transforms a URL structure to a set of query vars. + * + * Any value in the $after parameter that isn't 'bottom' will result in the rule + * being placed at the top of the rewrite rules. + * + * @since 2.1.0 + * @since 4.4.0 Array support was added to the `$query` parameter. + * + * @param string $regex Regular expression to match request against. + * @param string|array $query The corresponding query vars for this rewrite rule. + * @param string $after Optional. Priority of the new rule. Accepts 'top' + * or 'bottom'. Default 'bottom'. + */ + public function add_rule( $regex, $query, $after = 'bottom' ) { + if ( is_array( $query ) ) { + $external = false; + $query = add_query_arg( $query, 'index.php' ); + } else { + $index = false === strpos( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' ); + $front = substr( $query, 0, $index ); + + $external = $front != $this->index; + } + + // "external" = it doesn't correspond to index.php. + if ( $external ) { + $this->add_external_rule( $regex, $query ); + } else { + if ( 'bottom' == $after ) { + $this->extra_rules = array_merge( $this->extra_rules, array( $regex => $query ) ); + } else { + $this->extra_rules_top = array_merge( $this->extra_rules_top, array( $regex => $query ) ); + } + } + } + + /** + * Adds a rewrite rule that doesn't correspond to index.php. + * + * @since 2.1.0 + * + * @param string $regex Regular expression to match request against. + * @param string $query The corresponding query vars for this rewrite rule. + */ + public function add_external_rule( $regex, $query ) { + $this->non_wp_rules[ $regex ] = $query; + } + + /** + * Adds an endpoint, like /trackback/. + * + * @since 2.1.0 + * @since 3.9.0 $query_var parameter added. + * @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`. + * + * @see add_rewrite_endpoint() for full documentation. + * @global WP $wp + * + * @param string $name Name of the endpoint. + * @param int $places Endpoint mask describing the places the endpoint should be added. + * @param string|bool $query_var Optional. Name of the corresponding query variable. Pass `false` to + * skip registering a query_var for this endpoint. Defaults to the + * value of `$name`. + */ + public function add_endpoint( $name, $places, $query_var = true ) { + global $wp; + + // For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`. + if ( true === $query_var || null === func_get_arg( 2 ) ) { + $query_var = $name; + } + $this->endpoints[] = array( $places, $name, $query_var ); + + if ( $query_var ) { + $wp->add_query_var( $query_var ); + } + } + + /** + * Adds a new permalink structure. + * + * A permalink structure (permastruct) is an abstract definition of a set of rewrite rules; + * it is an easy way of expressing a set of regular expressions that rewrite to a set of + * query strings. The new permastruct is added to the WP_Rewrite::$extra_permastructs array. + * + * When the rewrite rules are built by WP_Rewrite::rewrite_rules(), all of these extra + * permastructs are passed to WP_Rewrite::generate_rewrite_rules() which transforms them + * into the regular expressions that many love to hate. + * + * The `$args` parameter gives you control over how WP_Rewrite::generate_rewrite_rules() + * works on the new permastruct. + * + * @since 2.5.0 + * + * @param string $name Name for permalink structure. + * @param string $struct Permalink structure (e.g. category/%category%) + * @param array $args { + * Optional. Arguments for building rewrite rules based on the permalink structure. + * Default empty array. + * + * @type bool $with_front Whether the structure should be prepended with `WP_Rewrite::$front`. + * Default true. + * @type int $ep_mask The endpoint mask defining which endpoints are added to the structure. + * Accepts `EP_NONE`, `EP_PERMALINK`, `EP_ATTACHMENT`, `EP_DATE`, `EP_YEAR`, + * `EP_MONTH`, `EP_DAY`, `EP_ROOT`, `EP_COMMENTS`, `EP_SEARCH`, `EP_CATEGORIES`, + * `EP_TAGS`, `EP_AUTHORS`, `EP_PAGES`, `EP_ALL_ARCHIVES`, and `EP_ALL`. + * Default `EP_NONE`. + * @type bool $paged Whether archive pagination rules should be added for the structure. + * Default true. + * @type bool $feed Whether feed rewrite rules should be added for the structure. Default true. + * @type bool $forcomments Whether the feed rules should be a query for a comments feed. Default false. + * @type bool $walk_dirs Whether the 'directories' making up the structure should be walked over + * and rewrite rules built for each in-turn. Default true. + * @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true. + * } + */ + public function add_permastruct( $name, $struct, $args = array() ) { + // Back-compat for the old parameters: $with_front and $ep_mask. + if ( ! is_array( $args ) ) + $args = array( 'with_front' => $args ); + if ( func_num_args() == 4 ) + $args['ep_mask'] = func_get_arg( 3 ); + + $defaults = array( + 'with_front' => true, + 'ep_mask' => EP_NONE, + 'paged' => true, + 'feed' => true, + 'forcomments' => false, + 'walk_dirs' => true, + 'endpoints' => true, + ); + $args = array_intersect_key( $args, $defaults ); + $args = wp_parse_args( $args, $defaults ); + + if ( $args['with_front'] ) + $struct = $this->front . $struct; + else + $struct = $this->root . $struct; + $args['struct'] = $struct; + + $this->extra_permastructs[ $name ] = $args; + } + + /** + * Removes a permalink structure. + * + * @since 4.5.0 + * + * @param string $name Name for permalink structure. + */ + public function remove_permastruct( $name ) { + unset( $this->extra_permastructs[ $name ] ); + } + + /** + * Removes rewrite rules and then recreate rewrite rules. + * + * Calls WP_Rewrite::wp_rewrite_rules() after removing the 'rewrite_rules' option. + * If the function named 'save_mod_rewrite_rules' exists, it will be called. + * + * @since 2.0.1 + * + * @staticvar bool $do_hard_later + * + * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). + */ + public function flush_rules( $hard = true ) { + static $do_hard_later = null; + + // Prevent this action from running before everyone has registered their rewrites. + if ( ! did_action( 'wp_loaded' ) ) { + add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); + $do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard; + return; + } + + if ( isset( $do_hard_later ) ) { + $hard = $do_hard_later; + unset( $do_hard_later ); + } + + update_option( 'rewrite_rules', '' ); + $this->wp_rewrite_rules(); + + /** + * Filters whether a "hard" rewrite rule flush should be performed when requested. + * + * A "hard" flush updates .htaccess (Apache) or web.config (IIS). + * + * @since 3.7.0 + * + * @param bool $hard Whether to flush rewrite rules "hard". Default true. + */ + if ( ! $hard || ! apply_filters( 'flush_rewrite_rules_hard', true ) ) { + return; + } + if ( function_exists( 'save_mod_rewrite_rules' ) ) + save_mod_rewrite_rules(); + if ( function_exists( 'iis7_save_url_rewrite_rules' ) ) + iis7_save_url_rewrite_rules(); + } + + /** + * Sets up the object's properties. + * + * The 'use_verbose_page_rules' object property will be set to true if the + * permalink structure begins with one of the following: '%postname%', '%category%', + * '%tag%', or '%author%'. + * + * @since 1.5.0 + */ + public function init() { + $this->extra_rules = $this->non_wp_rules = $this->endpoints = array(); + $this->permalink_structure = get_option('permalink_structure'); + $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); + $this->root = ''; + + if ( $this->using_index_permalinks() ) + $this->root = $this->index . '/'; + + unset($this->author_structure); + unset($this->date_structure); + unset($this->page_structure); + unset($this->search_structure); + unset($this->feed_structure); + unset($this->comment_feed_structure); + $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); + + // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. + if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) ) + $this->use_verbose_page_rules = true; + else + $this->use_verbose_page_rules = false; + } + + /** + * Sets the main permalink structure for the site. + * + * Will update the 'permalink_structure' option, if there is a difference + * between the current permalink structure and the parameter value. Calls + * WP_Rewrite::init() after the option is updated. + * + * Fires the {@see 'permalink_structure_changed'} action once the init call has + * processed passing the old and new values + * + * @since 1.5.0 + * + * @param string $permalink_structure Permalink structure. + */ + public function set_permalink_structure($permalink_structure) { + if ( $permalink_structure != $this->permalink_structure ) { + $old_permalink_structure = $this->permalink_structure; + update_option('permalink_structure', $permalink_structure); + + $this->init(); + + /** + * Fires after the permalink structure is updated. + * + * @since 2.8.0 + * + * @param string $old_permalink_structure The previous permalink structure. + * @param string $permalink_structure The new permalink structure. + */ + do_action( 'permalink_structure_changed', $old_permalink_structure, $permalink_structure ); + } + } + + /** + * Sets the category base for the category permalink. + * + * Will update the 'category_base' option, if there is a difference between + * the current category base and the parameter value. Calls WP_Rewrite::init() + * after the option is updated. + * + * @since 1.5.0 + * + * @param string $category_base Category permalink structure base. + */ + public function set_category_base($category_base) { + if ( $category_base != get_option('category_base') ) { + update_option('category_base', $category_base); + $this->init(); + } + } + + /** + * Sets the tag base for the tag permalink. + * + * Will update the 'tag_base' option, if there is a difference between the + * current tag base and the parameter value. Calls WP_Rewrite::init() after + * the option is updated. + * + * @since 2.3.0 + * + * @param string $tag_base Tag permalink structure base. + */ + public function set_tag_base( $tag_base ) { + if ( $tag_base != get_option( 'tag_base') ) { + update_option( 'tag_base', $tag_base ); + $this->init(); + } + } + + /** + * Constructor - Calls init(), which runs setup. + * + * @since 1.5.0 + * + */ + public function __construct() { + $this->init(); + } +} diff --git a/backend/wp-includes/class-wp-role.php b/backend/wp-includes/class-wp-role.php new file mode 100644 index 0000000..33d8dfe --- /dev/null +++ b/backend/wp-includes/class-wp-role.php @@ -0,0 +1,109 @@ +<?php +/** + * User API: WP_Role class + * + * @package WordPress + * @subpackage Users + * @since 4.4.0 + */ + +/** + * Core class used to extend the user roles API. + * + * @since 2.0.0 + */ +class WP_Role { + /** + * Role name. + * + * @since 2.0.0 + * @var string + */ + public $name; + + /** + * List of capabilities the role contains. + * + * @since 2.0.0 + * @var array + */ + public $capabilities; + + /** + * Constructor - Set up object properties. + * + * The list of capabilities, must have the key as the name of the capability + * and the value a boolean of whether it is granted to the role. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @param array $capabilities List of capabilities. + */ + public function __construct( $role, $capabilities ) { + $this->name = $role; + $this->capabilities = $capabilities; + } + + /** + * Assign role a capability. + * + * @since 2.0.0 + * + * @param string $cap Capability name. + * @param bool $grant Whether role has capability privilege. + */ + public function add_cap( $cap, $grant = true ) { + $this->capabilities[$cap] = $grant; + wp_roles()->add_cap( $this->name, $cap, $grant ); + } + + /** + * Removes a capability from a role. + * + * This is a container for WP_Roles::remove_cap() to remove the + * capability from the role. That is to say, that WP_Roles::remove_cap() + * implements the functionality, but it also makes sense to use this class, + * because you don't need to enter the role name. + * + * @since 2.0.0 + * + * @param string $cap Capability name. + */ + public function remove_cap( $cap ) { + unset( $this->capabilities[$cap] ); + wp_roles()->remove_cap( $this->name, $cap ); + } + + /** + * Determines whether the role has the given capability. + * + * The capabilities is passed through the {@see 'role_has_cap'} filter. + * The first parameter for the hook is the list of capabilities the class + * has assigned. The second parameter is the capability name to look for. + * The third and final parameter for the hook is the role name. + * + * @since 2.0.0 + * + * @param string $cap Capability name. + * @return bool True if the role has the given capability. False otherwise. + */ + public function has_cap( $cap ) { + /** + * Filters which capabilities a role has. + * + * @since 2.0.0 + * + * @param array $capabilities Array of role capabilities. + * @param string $cap Capability name. + * @param string $name Role name. + */ + $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name ); + + if ( !empty( $capabilities[$cap] ) ) + return $capabilities[$cap]; + else + return false; + } + +} diff --git a/backend/wp-includes/class-wp-roles.php b/backend/wp-includes/class-wp-roles.php new file mode 100644 index 0000000..9673345 --- /dev/null +++ b/backend/wp-includes/class-wp-roles.php @@ -0,0 +1,361 @@ +<?php +/** + * User API: WP_Roles class + * + * @package WordPress + * @subpackage Users + * @since 4.4.0 + */ + +/** + * Core class used to implement a user roles API. + * + * The role option is simple, the structure is organized by role name that store + * the name in value of the 'name' key. The capabilities are stored as an array + * in the value of the 'capability' key. + * + * array ( + * 'rolename' => array ( + * 'name' => 'rolename', + * 'capabilities' => array() + * ) + * ) + * + * @since 2.0.0 + */ +class WP_Roles { + /** + * List of roles and capabilities. + * + * @since 2.0.0 + * @var array + */ + public $roles; + + /** + * List of the role objects. + * + * @since 2.0.0 + * @var array + */ + public $role_objects = array(); + + /** + * List of role names. + * + * @since 2.0.0 + * @var array + */ + public $role_names = array(); + + /** + * Option name for storing role list. + * + * @since 2.0.0 + * @var string + */ + public $role_key; + + /** + * Whether to use the database for retrieval and storage. + * + * @since 2.1.0 + * @var bool + */ + public $use_db = true; + + /** + * The site ID the roles are initialized for. + * + * @since 4.9.0 + * @var int + */ + protected $site_id = 0; + + /** + * Constructor + * + * @since 2.0.0 + * @since 4.9.0 The $site_id argument was added. + * + * @global array $wp_user_roles Used to set the 'roles' property value. + * + * @param int $site_id Site ID to initialize roles for. Default is the current site. + */ + public function __construct( $site_id = null ) { + global $wp_user_roles; + + $this->use_db = empty( $wp_user_roles ); + + $this->for_site( $site_id ); + } + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|false Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( '_init' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Set up the object properties. + * + * The role key is set to the current prefix for the $wpdb object with + * 'user_roles' appended. If the $wp_user_roles global is set, then it will + * be used and the role option will not be updated or used. + * + * @since 2.1.0 + * @deprecated 4.9.0 Use WP_Roles::for_site() + */ + protected function _init() { + _deprecated_function( __METHOD__, '4.9.0', 'WP_Roles::for_site()' ); + + $this->for_site(); + } + + /** + * Reinitialize the object + * + * Recreates the role objects. This is typically called only by switch_to_blog() + * after switching wpdb to a new site ID. + * + * @since 3.5.0 + * @deprecated 4.7.0 Use WP_Roles::for_site() + */ + public function reinit() { + _deprecated_function( __METHOD__, '4.7.0', 'WP_Roles::for_site()' ); + + $this->for_site(); + } + + /** + * Add role name with capabilities to list. + * + * Updates the list of roles, if the role doesn't already exist. + * + * The capabilities are defined in the following format `array( 'read' => true );` + * To explicitly deny a role a capability you set the value for that capability to false. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @param string $display_name Role display name. + * @param array $capabilities List of role capabilities in the above format. + * @return WP_Role|void WP_Role object, if role is added. + */ + public function add_role( $role, $display_name, $capabilities = array() ) { + if ( empty( $role ) || isset( $this->roles[ $role ] ) ) { + return; + } + + $this->roles[$role] = array( + 'name' => $display_name, + 'capabilities' => $capabilities + ); + if ( $this->use_db ) + update_option( $this->role_key, $this->roles ); + $this->role_objects[$role] = new WP_Role( $role, $capabilities ); + $this->role_names[$role] = $display_name; + return $this->role_objects[$role]; + } + + /** + * Remove role by name. + * + * @since 2.0.0 + * + * @param string $role Role name. + */ + public function remove_role( $role ) { + if ( ! isset( $this->role_objects[$role] ) ) + return; + + unset( $this->role_objects[$role] ); + unset( $this->role_names[$role] ); + unset( $this->roles[$role] ); + + if ( $this->use_db ) + update_option( $this->role_key, $this->roles ); + + if ( get_option( 'default_role' ) == $role ) + update_option( 'default_role', 'subscriber' ); + } + + /** + * Add capability to role. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @param string $cap Capability name. + * @param bool $grant Optional, default is true. Whether role is capable of performing capability. + */ + public function add_cap( $role, $cap, $grant = true ) { + if ( ! isset( $this->roles[$role] ) ) + return; + + $this->roles[$role]['capabilities'][$cap] = $grant; + if ( $this->use_db ) + update_option( $this->role_key, $this->roles ); + } + + /** + * Remove capability from role. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @param string $cap Capability name. + */ + public function remove_cap( $role, $cap ) { + if ( ! isset( $this->roles[$role] ) ) + return; + + unset( $this->roles[$role]['capabilities'][$cap] ); + if ( $this->use_db ) + update_option( $this->role_key, $this->roles ); + } + + /** + * Retrieve role object by name. + * + * @since 2.0.0 + * + * @param string $role Role name. + * @return WP_Role|null WP_Role object if found, null if the role does not exist. + */ + public function get_role( $role ) { + if ( isset( $this->role_objects[$role] ) ) + return $this->role_objects[$role]; + else + return null; + } + + /** + * Retrieve list of role names. + * + * @since 2.0.0 + * + * @return array List of role names. + */ + public function get_names() { + return $this->role_names; + } + + /** + * Whether role name is currently in the list of available roles. + * + * @since 2.0.0 + * + * @param string $role Role name to look up. + * @return bool + */ + public function is_role( $role ) { + return isset( $this->role_names[$role] ); + } + + /** + * Initializes all of the available roles. + * + * @since 4.9.0 + */ + public function init_roles() { + if ( empty( $this->roles ) ) { + return; + } + + $this->role_objects = array(); + $this->role_names = array(); + foreach ( array_keys( $this->roles ) as $role ) { + $this->role_objects[ $role ] = new WP_Role( $role, $this->roles[ $role ]['capabilities'] ); + $this->role_names[ $role ] = $this->roles[ $role ]['name']; + } + + /** + * After the roles have been initialized, allow plugins to add their own roles. + * + * @since 4.7.0 + * + * @param WP_Roles $this A reference to the WP_Roles object. + */ + do_action( 'wp_roles_init', $this ); + } + + /** + * Sets the site to operate on. Defaults to the current site. + * + * @since 4.9.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $site_id Site ID to initialize roles for. Default is the current site. + */ + public function for_site( $site_id = null ) { + global $wpdb; + + if ( ! empty( $site_id ) ) { + $this->site_id = absint( $site_id ); + } else { + $this->site_id = get_current_blog_id(); + } + + $this->role_key = $wpdb->get_blog_prefix( $this->site_id ) . 'user_roles'; + + if ( ! empty( $this->roles ) && ! $this->use_db ) { + return; + } + + $this->roles = $this->get_roles_data(); + + $this->init_roles(); + } + + /** + * Gets the ID of the site for which roles are currently initialized. + * + * @since 4.9.0 + * + * @return int Site ID. + */ + public function get_site_id() { + return $this->site_id; + } + + /** + * Gets the available roles data. + * + * @since 4.9.0 + * + * @global array $wp_user_roles Used to set the 'roles' property value. + * + * @return array Roles array. + */ + protected function get_roles_data() { + global $wp_user_roles; + + if ( ! empty( $wp_user_roles ) ) { + return $wp_user_roles; + } + + if ( is_multisite() && $this->site_id != get_current_blog_id() ) { + remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 ); + + $roles = get_blog_option( $this->site_id, $this->role_key, array() ); + + add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); + + return $roles; + } + + return get_option( $this->role_key, array() ); + } +} diff --git a/backend/wp-includes/class-wp-session-tokens.php b/backend/wp-includes/class-wp-session-tokens.php new file mode 100644 index 0000000..993b81e --- /dev/null +++ b/backend/wp-includes/class-wp-session-tokens.php @@ -0,0 +1,300 @@ +<?php +/** + * Session API: WP_Session_Tokens class + * + * @package WordPress + * @subpackage Session + * @since 4.7.0 + */ + +/** + * Abstract class for managing user session tokens. + * + * @since 4.0.0 + */ +abstract class WP_Session_Tokens { + + /** + * User ID. + * + * @since 4.0.0 + * @var int User ID. + */ + protected $user_id; + + /** + * Protected constructor. + * + * @since 4.0.0 + * + * @param int $user_id User whose session to manage. + */ + protected function __construct( $user_id ) { + $this->user_id = $user_id; + } + + /** + * Retrieves a session token manager instance for a user. + * + * This method contains a {@see 'session_token_manager'} filter, allowing a plugin to swap out + * the session manager for a subclass of `WP_Session_Tokens`. + * + * @since 4.0.0 + * @static + * + * @param int $user_id User whose session to manage. + * @return WP_User_Meta_Session_Tokens WP_User_Meta_Session_Tokens class instance by default. + */ + final public static function get_instance( $user_id ) { + /** + * Filters the session token manager used. + * + * @since 4.0.0 + * + * @param string $session Name of class to use as the manager. + * Default 'WP_User_Meta_Session_Tokens'. + */ + $manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' ); + return new $manager( $user_id ); + } + + /** + * Hashes a session token for storage. + * + * @since 4.0.0 + * + * @param string $token Session token to hash. + * @return string A hash of the session token (a verifier). + */ + final private function hash_token( $token ) { + // If ext/hash is not present, use sha1() instead. + if ( function_exists( 'hash' ) ) { + return hash( 'sha256', $token ); + } else { + return sha1( $token ); + } + } + + /** + * Get a user's session. + * + * @since 4.0.0 + * + * @param string $token Session token + * @return array User session + */ + final public function get( $token ) { + $verifier = $this->hash_token( $token ); + return $this->get_session( $verifier ); + } + + /** + * Validate a user's session token as authentic. + * + * Checks that the given token is present and hasn't expired. + * + * @since 4.0.0 + * + * @param string $token Token to verify. + * @return bool Whether the token is valid for the user. + */ + final public function verify( $token ) { + $verifier = $this->hash_token( $token ); + return (bool) $this->get_session( $verifier ); + } + + /** + * Generate a session token and attach session information to it. + * + * A session token is a long, random string. It is used in a cookie + * link that cookie to an expiration time and to ensure the cookie + * becomes invalidated upon logout. + * + * This function generates a token and stores it with the associated + * expiration time (and potentially other session information via the + * {@see 'attach_session_information'} filter). + * + * @since 4.0.0 + * + * @param int $expiration Session expiration timestamp. + * @return string Session token. + */ + final public function create( $expiration ) { + /** + * Filters the information attached to the newly created session. + * + * Could be used in the future to attach information such as + * IP address or user agent to a session. + * + * @since 4.0.0 + * + * @param array $session Array of extra data. + * @param int $user_id User ID. + */ + $session = apply_filters( 'attach_session_information', array(), $this->user_id ); + $session['expiration'] = $expiration; + + // IP address. + if ( !empty( $_SERVER['REMOTE_ADDR'] ) ) { + $session['ip'] = $_SERVER['REMOTE_ADDR']; + } + + // User-agent. + if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + $session['ua'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); + } + + // Timestamp + $session['login'] = time(); + + $token = wp_generate_password( 43, false, false ); + + $this->update( $token, $session ); + + return $token; + } + + /** + * Update a session token. + * + * @since 4.0.0 + * + * @param string $token Session token to update. + * @param array $session Session information. + */ + final public function update( $token, $session ) { + $verifier = $this->hash_token( $token ); + $this->update_session( $verifier, $session ); + } + + /** + * Destroy a session token. + * + * @since 4.0.0 + * + * @param string $token Session token to destroy. + */ + final public function destroy( $token ) { + $verifier = $this->hash_token( $token ); + $this->update_session( $verifier, null ); + } + + /** + * Destroy all session tokens for this user, + * except a single token, presumably the one in use. + * + * @since 4.0.0 + * + * @param string $token_to_keep Session token to keep. + */ + final public function destroy_others( $token_to_keep ) { + $verifier = $this->hash_token( $token_to_keep ); + $session = $this->get_session( $verifier ); + if ( $session ) { + $this->destroy_other_sessions( $verifier ); + } else { + $this->destroy_all_sessions(); + } + } + + /** + * Determine whether a session token is still valid, + * based on expiration. + * + * @since 4.0.0 + * + * @param array $session Session to check. + * @return bool Whether session is valid. + */ + final protected function is_still_valid( $session ) { + return $session['expiration'] >= time(); + } + + /** + * Destroy all session tokens for a user. + * + * @since 4.0.0 + */ + final public function destroy_all() { + $this->destroy_all_sessions(); + } + + /** + * Destroy all session tokens for all users. + * + * @since 4.0.0 + * @static + */ + final public static function destroy_all_for_all_users() { + /** This filter is documented in wp-includes/class-wp-session-tokens.php */ + $manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' ); + call_user_func( array( $manager, 'drop_sessions' ) ); + } + + /** + * Retrieve all sessions of a user. + * + * @since 4.0.0 + * + * @return array Sessions of a user. + */ + final public function get_all() { + return array_values( $this->get_sessions() ); + } + + /** + * This method should retrieve all sessions of a user, keyed by verifier. + * + * @since 4.0.0 + * + * @return array Sessions of a user, keyed by verifier. + */ + abstract protected function get_sessions(); + + /** + * This method should look up a session by its verifier (token hash). + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to retrieve. + * @return array|null The session, or null if it does not exist. + */ + abstract protected function get_session( $verifier ); + + /** + * This method should update a session by its verifier. + * + * Omitting the second argument should destroy the session. + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to update. + * @param array $session Optional. Session. Omitting this argument destroys the session. + */ + abstract protected function update_session( $verifier, $session = null ); + + /** + * This method should destroy all session tokens for this user, + * except a single session passed. + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to keep. + */ + abstract protected function destroy_other_sessions( $verifier ); + + /** + * This method should destroy all sessions for a user. + * + * @since 4.0.0 + */ + abstract protected function destroy_all_sessions(); + + /** + * This static method should destroy all session tokens for all users. + * + * @since 4.0.0 + * @static + */ + public static function drop_sessions() {} +} diff --git a/backend/wp-includes/class-wp-simplepie-file.php b/backend/wp-includes/class-wp-simplepie-file.php new file mode 100644 index 0000000..49e8003 --- /dev/null +++ b/backend/wp-includes/class-wp-simplepie-file.php @@ -0,0 +1,71 @@ +<?php +/** + * Feed API: WP_SimplePie_File class + * + * @package WordPress + * @subpackage Feed + * @since 4.7.0 + */ + +/** + * Core class for fetching remote files and reading local files with SimplePie. + * + * @since 2.8.0 + * + * @see SimplePie_File + */ +class WP_SimplePie_File extends SimplePie_File { + + /** + * Constructor. + * + * @since 2.8.0 + * @since 3.2.0 Updated to use a PHP5 constructor. + * + * @param string $url Remote file URL. + * @param integer $timeout Optional. How long the connection should stay open in seconds. + * Default 10. + * @param integer $redirects Optional. The number of allowed redirects. Default 5. + * @param string|array $headers Optional. Array or string of headers to send with the request. + * Default null. + * @param string $useragent Optional. User-agent value sent. Default null. + * @param boolean $force_fsockopen Optional. Whether to force opening internet or unix domain socket + * connection or not. Default false. + */ + public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) { + $this->url = $url; + $this->timeout = $timeout; + $this->redirects = $redirects; + $this->headers = $headers; + $this->useragent = $useragent; + + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE; + + if ( preg_match('/^http(s)?:\/\//i', $url) ) { + $args = array( + 'timeout' => $this->timeout, + 'redirection' => $this->redirects, + ); + + if ( !empty($this->headers) ) + $args['headers'] = $this->headers; + + if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified + $args['user-agent'] = $this->useragent; + + $res = wp_safe_remote_request($url, $args); + + if ( is_wp_error($res) ) { + $this->error = 'WP HTTP Error: ' . $res->get_error_message(); + $this->success = false; + } else { + $this->headers = wp_remote_retrieve_headers( $res ); + $this->body = wp_remote_retrieve_body( $res ); + $this->status_code = wp_remote_retrieve_response_code( $res ); + } + } else { + $this->error = ''; + $this->success = false; + } + } +} diff --git a/backend/wp-includes/class-wp-simplepie-sanitize-kses.php b/backend/wp-includes/class-wp-simplepie-sanitize-kses.php new file mode 100644 index 0000000..ff7d7e5 --- /dev/null +++ b/backend/wp-includes/class-wp-simplepie-sanitize-kses.php @@ -0,0 +1,58 @@ +<?php +/** + * Feed API: WP_SimplePie_Sanitize_KSES class + * + * @package WordPress + * @subpackage Feed + * @since 4.7.0 + */ + +/** + * Core class used to implement SimpliePie feed sanitization. + * + * Extends the SimplePie_Sanitize class to use KSES, because + * we cannot universally count on DOMDocument being available. + * + * @since 3.5.0 + * + * @see SimplePie_Sanitize + */ +class WP_SimplePie_Sanitize_KSES extends SimplePie_Sanitize { + + /** + * WordPress SimplePie sanitization using KSES. + * + * Sanitizes the incoming data, to ensure that it matches the type of data expected, using KSES. + * + * @since 3.5.0 + * + * @param mixed $data The data that needs to be sanitized. + * @param integer $type The type of data that it's supposed to be. + * @param string $base Optional. The `xml:base` value to use when converting relative + * URLs to absolute ones. Default empty. + * @return mixed Sanitized data. + */ + public function sanitize( $data, $type, $base = '' ) { + $data = trim( $data ); + if ( $type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML ) { + if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) { + $type |= SIMPLEPIE_CONSTRUCT_HTML; + } + else { + $type |= SIMPLEPIE_CONSTRUCT_TEXT; + } + } + if ( $type & SIMPLEPIE_CONSTRUCT_BASE64 ) { + $data = base64_decode( $data ); + } + if ( $type & ( SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML ) ) { + $data = wp_kses_post( $data ); + if ( $this->output_encoding !== 'UTF-8' ) { + $data = $this->registry->call( 'Misc', 'change_encoding', array( $data, 'UTF-8', $this->output_encoding ) ); + } + return $data; + } else { + return parent::sanitize( $data, $type, $base ); + } + } +} diff --git a/backend/wp-includes/class-wp-site-query.php b/backend/wp-includes/class-wp-site-query.php new file mode 100644 index 0000000..cf2134d --- /dev/null +++ b/backend/wp-includes/class-wp-site-query.php @@ -0,0 +1,701 @@ +<?php +/** + * Site API: WP_Site_Query class + * + * @package WordPress + * @subpackage Sites + * @since 4.6.0 + */ + +/** + * Core class used for querying sites. + * + * @since 4.6.0 + * + * @see WP_Site_Query::__construct() for accepted arguments. + */ +class WP_Site_Query { + + /** + * SQL for database query. + * + * @since 4.6.0 + * @var string + */ + public $request; + + /** + * SQL query clauses. + * + * @since 4.6.0 + * @var array + */ + protected $sql_clauses = array( + 'select' => '', + 'from' => '', + 'where' => array(), + 'groupby' => '', + 'orderby' => '', + 'limits' => '', + ); + + /** + * Date query container. + * + * @since 4.6.0 + * @var object WP_Date_Query + */ + public $date_query = false; + + /** + * Query vars set by the user. + * + * @since 4.6.0 + * @var array + */ + public $query_vars; + + /** + * Default values for query vars. + * + * @since 4.6.0 + * @var array + */ + public $query_var_defaults; + + /** + * List of sites located by the query. + * + * @since 4.6.0 + * @var array + */ + public $sites; + + /** + * The amount of found sites for the current query. + * + * @since 4.6.0 + * @var int + */ + public $found_sites = 0; + + /** + * The number of pages. + * + * @since 4.6.0 + * @var int + */ + public $max_num_pages = 0; + + /** + * Sets up the site query, based on the query vars passed. + * + * @since 4.6.0 + * @since 4.8.0 Introduced the 'lang_id', 'lang__in', and 'lang__not_in' parameters. + * + * @param string|array $query { + * Optional. Array or query string of site query parameters. Default empty. + * + * @type array $site__in Array of site IDs to include. Default empty. + * @type array $site__not_in Array of site IDs to exclude. Default empty. + * @type bool $count Whether to return a site count (true) or array of site objects. + * Default false. + * @type array $date_query Date query clauses to limit sites by. See WP_Date_Query. + * Default null. + * @type string $fields Site fields to return. Accepts 'ids' (returns an array of site IDs) + * or empty (returns an array of complete site objects). Default empty. + * @type int $ID A site ID to only return that site. Default empty. + * @type int $number Maximum number of sites to retrieve. Default 100. + * @type int $offset Number of sites to offset the query. Used to build LIMIT clause. + * Default 0. + * @type bool $no_found_rows Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true. + * @type string|array $orderby Site status or array of statuses. Accepts 'id', 'domain', 'path', + * 'network_id', 'last_updated', 'registered', 'domain_length', + * 'path_length', 'site__in' and 'network__in'. Also accepts false, + * an empty array, or 'none' to disable `ORDER BY` clause. + * Default 'id'. + * @type string $order How to order retrieved sites. Accepts 'ASC', 'DESC'. Default 'ASC'. + * @type int $network_id Limit results to those affiliated with a given network ID. If 0, + * include all networks. Default 0. + * @type array $network__in Array of network IDs to include affiliated sites for. Default empty. + * @type array $network__not_in Array of network IDs to exclude affiliated sites for. Default empty. + * @type string $domain Limit results to those affiliated with a given domain. Default empty. + * @type array $domain__in Array of domains to include affiliated sites for. Default empty. + * @type array $domain__not_in Array of domains to exclude affiliated sites for. Default empty. + * @type string $path Limit results to those affiliated with a given path. Default empty. + * @type array $path__in Array of paths to include affiliated sites for. Default empty. + * @type array $path__not_in Array of paths to exclude affiliated sites for. Default empty. + * @type int $public Limit results to public sites. Accepts '1' or '0'. Default empty. + * @type int $archived Limit results to archived sites. Accepts '1' or '0'. Default empty. + * @type int $mature Limit results to mature sites. Accepts '1' or '0'. Default empty. + * @type int $spam Limit results to spam sites. Accepts '1' or '0'. Default empty. + * @type int $deleted Limit results to deleted sites. Accepts '1' or '0'. Default empty. + * @type int $lang_id Limit results to a language ID. Default empty. + * @type array $lang__in Array of language IDs to include affiliated sites for. Default empty. + * @type array $lang__not_in Array of language IDs to exclude affiliated sites for. Default empty. + * @type string $search Search term(s) to retrieve matching sites for. Default empty. + * @type array $search_columns Array of column names to be searched. Accepts 'domain' and 'path'. + * Default empty array. + * @type bool $update_site_cache Whether to prime the cache for found sites. Default true. + * } + */ + public function __construct( $query = '' ) { + $this->query_var_defaults = array( + 'fields' => '', + 'ID' => '', + 'site__in' => '', + 'site__not_in' => '', + 'number' => 100, + 'offset' => '', + 'no_found_rows' => true, + 'orderby' => 'id', + 'order' => 'ASC', + 'network_id' => 0, + 'network__in' => '', + 'network__not_in' => '', + 'domain' => '', + 'domain__in' => '', + 'domain__not_in' => '', + 'path' => '', + 'path__in' => '', + 'path__not_in' => '', + 'public' => null, + 'archived' => null, + 'mature' => null, + 'spam' => null, + 'deleted' => null, + 'lang_id' => null, + 'lang__in' => '', + 'lang__not_in' => '', + 'search' => '', + 'search_columns' => array(), + 'count' => false, + 'date_query' => null, // See WP_Date_Query + 'update_site_cache' => true, + ); + + if ( ! empty( $query ) ) { + $this->query( $query ); + } + } + + /** + * Parses arguments passed to the site query with default query parameters. + * + * @since 4.6.0 + * + * @see WP_Site_Query::__construct() + * + * @param string|array $query Array or string of WP_Site_Query arguments. See WP_Site_Query::__construct(). + */ + public function parse_query( $query = '' ) { + if ( empty( $query ) ) { + $query = $this->query_vars; + } + + $this->query_vars = wp_parse_args( $query, $this->query_var_defaults ); + + /** + * Fires after the site query vars have been parsed. + * + * @since 4.6.0 + * + * @param WP_Site_Query $this The WP_Site_Query instance (passed by reference). + */ + do_action_ref_array( 'parse_site_query', array( &$this ) ); + } + + /** + * Sets up the WordPress query for retrieving sites. + * + * @since 4.6.0 + * + * @param string|array $query Array or URL query string of parameters. + * @return array|int List of WP_Site objects, a list of site ids when 'fields' is set to 'ids', + * or the number of sites when 'count' is passed as a query var. + */ + public function query( $query ) { + $this->query_vars = wp_parse_args( $query ); + + return $this->get_sites(); + } + + /** + * Retrieves a list of sites matching the query vars. + * + * @since 4.6.0 + * + * @return array|int List of WP_Site objects, a list of site ids when 'fields' is set to 'ids', + * or the number of sites when 'count' is passed as a query var. + */ + public function get_sites() { + $this->parse_query(); + + /** + * Fires before sites are retrieved. + * + * @since 4.6.0 + * + * @param WP_Site_Query $this Current instance of WP_Site_Query (passed by reference). + */ + do_action_ref_array( 'pre_get_sites', array( &$this ) ); + + // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. + $_args = wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ); + + // Ignore the $fields argument as the queried result will be the same regardless. + unset( $_args['fields'] ); + + $key = md5( serialize( $_args ) ); + $last_changed = wp_cache_get_last_changed( 'sites' ); + + $cache_key = "get_sites:$key:$last_changed"; + $cache_value = wp_cache_get( $cache_key, 'sites' ); + + if ( false === $cache_value ) { + $site_ids = $this->get_site_ids(); + if ( $site_ids ) { + $this->set_found_sites(); + } + + $cache_value = array( + 'site_ids' => $site_ids, + 'found_sites' => $this->found_sites, + ); + wp_cache_add( $cache_key, $cache_value, 'sites' ); + } else { + $site_ids = $cache_value['site_ids']; + $this->found_sites = $cache_value['found_sites']; + } + + if ( $this->found_sites && $this->query_vars['number'] ) { + $this->max_num_pages = ceil( $this->found_sites / $this->query_vars['number'] ); + } + + // If querying for a count only, there's nothing more to do. + if ( $this->query_vars['count'] ) { + // $site_ids is actually a count in this case. + return intval( $site_ids ); + } + + $site_ids = array_map( 'intval', $site_ids ); + + if ( 'ids' == $this->query_vars['fields'] ) { + $this->sites = $site_ids; + + return $this->sites; + } + + // Prime site network caches. + if ( $this->query_vars['update_site_cache'] ) { + _prime_site_caches( $site_ids ); + } + + // Fetch full site objects from the primed cache. + $_sites = array(); + foreach ( $site_ids as $site_id ) { + if ( $_site = get_site( $site_id ) ) { + $_sites[] = $_site; + } + } + + /** + * Filters the site query results. + * + * @since 4.6.0 + * + * @param array $_sites An array of WP_Site objects. + * @param WP_Site_Query $this Current instance of WP_Site_Query (passed by reference). + */ + $_sites = apply_filters_ref_array( 'the_sites', array( $_sites, &$this ) ); + + // Convert to WP_Site instances. + $this->sites = array_map( 'get_site', $_sites ); + + return $this->sites; + } + + /** + * Used internally to get a list of site IDs matching the query vars. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return int|array A single count of site IDs if a count query. An array of site IDs if a full query. + */ + protected function get_site_ids() { + global $wpdb; + + $order = $this->parse_order( $this->query_vars['order'] ); + + // Disable ORDER BY with 'none', an empty array, or boolean false. + if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) { + $orderby = ''; + } elseif ( ! empty( $this->query_vars['orderby'] ) ) { + $ordersby = is_array( $this->query_vars['orderby'] ) ? + $this->query_vars['orderby'] : + preg_split( '/[,\s]/', $this->query_vars['orderby'] ); + + $orderby_array = array(); + foreach ( $ordersby as $_key => $_value ) { + if ( ! $_value ) { + continue; + } + + if ( is_int( $_key ) ) { + $_orderby = $_value; + $_order = $order; + } else { + $_orderby = $_key; + $_order = $_value; + } + + $parsed = $this->parse_orderby( $_orderby ); + + if ( ! $parsed ) { + continue; + } + + if ( 'site__in' === $_orderby || 'network__in' === $_orderby ) { + $orderby_array[] = $parsed; + continue; + } + + $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); + } + + $orderby = implode( ', ', $orderby_array ); + } else { + $orderby = "blog_id $order"; + } + + $number = absint( $this->query_vars['number'] ); + $offset = absint( $this->query_vars['offset'] ); + + if ( ! empty( $number ) ) { + if ( $offset ) { + $limits = 'LIMIT ' . $offset . ',' . $number; + } else { + $limits = 'LIMIT ' . $number; + } + } + + if ( $this->query_vars['count'] ) { + $fields = 'COUNT(*)'; + } else { + $fields = 'blog_id'; + } + + // Parse site IDs for an IN clause. + $site_id = absint( $this->query_vars['ID'] ); + if ( ! empty( $site_id ) ) { + $this->sql_clauses['where']['ID'] = $wpdb->prepare( 'blog_id = %d', $site_id ); + } + + // Parse site IDs for an IN clause. + if ( ! empty( $this->query_vars['site__in'] ) ) { + $this->sql_clauses['where']['site__in'] = "blog_id IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['site__in'] ) ) . ' )'; + } + + // Parse site IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['site__not_in'] ) ) { + $this->sql_clauses['where']['site__not_in'] = "blog_id NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['site__not_in'] ) ) . ' )'; + } + + $network_id = absint( $this->query_vars['network_id'] ); + + if ( ! empty( $network_id ) ) { + $this->sql_clauses['where']['network_id'] = $wpdb->prepare( 'site_id = %d', $network_id ); + } + + // Parse site network IDs for an IN clause. + if ( ! empty( $this->query_vars['network__in'] ) ) { + $this->sql_clauses['where']['network__in'] = 'site_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['network__in'] ) ) . ' )'; + } + + // Parse site network IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['network__not_in'] ) ) { + $this->sql_clauses['where']['network__not_in'] = 'site_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['network__not_in'] ) ) . ' )'; + } + + if ( ! empty( $this->query_vars['domain'] ) ) { + $this->sql_clauses['where']['domain'] = $wpdb->prepare( 'domain = %s', $this->query_vars['domain'] ); + } + + // Parse site domain for an IN clause. + if ( is_array( $this->query_vars['domain__in'] ) ) { + $this->sql_clauses['where']['domain__in'] = "domain IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__in'] ) ) . "' )"; + } + + // Parse site domain for a NOT IN clause. + if ( is_array( $this->query_vars['domain__not_in'] ) ) { + $this->sql_clauses['where']['domain__not_in'] = "domain NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['domain__not_in'] ) ) . "' )"; + } + + if ( ! empty( $this->query_vars['path'] ) ) { + $this->sql_clauses['where']['path'] = $wpdb->prepare( 'path = %s', $this->query_vars['path'] ); + } + + // Parse site path for an IN clause. + if ( is_array( $this->query_vars['path__in'] ) ) { + $this->sql_clauses['where']['path__in'] = "path IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__in'] ) ) . "' )"; + } + + // Parse site path for a NOT IN clause. + if ( is_array( $this->query_vars['path__not_in'] ) ) { + $this->sql_clauses['where']['path__not_in'] = "path NOT IN ( '" . implode( "', '", $wpdb->_escape( $this->query_vars['path__not_in'] ) ) . "' )"; + } + + if ( is_numeric( $this->query_vars['archived'] ) ) { + $archived = absint( $this->query_vars['archived'] ); + $this->sql_clauses['where']['archived'] = $wpdb->prepare( "archived = %s ", absint( $archived ) ); + } + + if ( is_numeric( $this->query_vars['mature'] ) ) { + $mature = absint( $this->query_vars['mature'] ); + $this->sql_clauses['where']['mature'] = $wpdb->prepare( "mature = %d ", $mature ); + } + + if ( is_numeric( $this->query_vars['spam'] ) ) { + $spam = absint( $this->query_vars['spam'] ); + $this->sql_clauses['where']['spam'] = $wpdb->prepare( "spam = %d ", $spam ); + } + + if ( is_numeric( $this->query_vars['deleted'] ) ) { + $deleted = absint( $this->query_vars['deleted'] ); + $this->sql_clauses['where']['deleted'] = $wpdb->prepare( "deleted = %d ", $deleted ); + } + + if ( is_numeric( $this->query_vars['public'] ) ) { + $public = absint( $this->query_vars['public'] ); + $this->sql_clauses['where']['public'] = $wpdb->prepare( "public = %d ", $public ); + } + + if ( is_numeric( $this->query_vars['lang_id'] ) ) { + $lang_id = absint( $this->query_vars['lang_id'] ); + $this->sql_clauses['where']['lang_id'] = $wpdb->prepare( "lang_id = %d ", $lang_id ); + } + + // Parse site language IDs for an IN clause. + if ( ! empty( $this->query_vars['lang__in'] ) ) { + $this->sql_clauses['where']['lang__in'] = 'lang_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['lang__in'] ) ) . ' )'; + } + + // Parse site language IDs for a NOT IN clause. + if ( ! empty( $this->query_vars['lang__not_in'] ) ) { + $this->sql_clauses['where']['lang__not_in'] = 'lang_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['lang__not_in'] ) ) . ' )'; + } + + // Falsey search strings are ignored. + if ( strlen( $this->query_vars['search'] ) ) { + $search_columns = array(); + + if ( $this->query_vars['search_columns'] ) { + $search_columns = array_intersect( $this->query_vars['search_columns'], array( 'domain', 'path' ) ); + } + + if ( ! $search_columns ) { + $search_columns = array( 'domain', 'path' ); + } + + /** + * Filters the columns to search in a WP_Site_Query search. + * + * The default columns include 'domain' and 'path. + * + * @since 4.6.0 + * + * @param array $search_columns Array of column names to be searched. + * @param string $search Text being searched. + * @param WP_Site_Query $this The current WP_Site_Query instance. + */ + $search_columns = apply_filters( 'site_search_columns', $search_columns, $this->query_vars['search'], $this ); + + $this->sql_clauses['where']['search'] = $this->get_search_sql( $this->query_vars['search'], $search_columns ); + } + + $date_query = $this->query_vars['date_query']; + if ( ! empty( $date_query ) && is_array( $date_query ) ) { + $this->date_query = new WP_Date_Query( $date_query, 'registered' ); + $this->sql_clauses['where']['date_query'] = preg_replace( '/^\s*AND\s*/', '', $this->date_query->get_sql() ); + } + + $join = ''; + + $where = implode( ' AND ', $this->sql_clauses['where'] ); + + $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); + + /** + * Filters the site query clauses. + * + * @since 4.6.0 + * + * @param array $pieces A compacted array of site query clauses. + * @param WP_Site_Query $this Current instance of WP_Site_Query (passed by reference). + */ + $clauses = apply_filters_ref_array( 'sites_clauses', array( compact( $pieces ), &$this ) ); + + $fields = isset( $clauses['fields'] ) ? $clauses['fields'] : ''; + $join = isset( $clauses['join'] ) ? $clauses['join'] : ''; + $where = isset( $clauses['where'] ) ? $clauses['where'] : ''; + $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : ''; + $limits = isset( $clauses['limits'] ) ? $clauses['limits'] : ''; + $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : ''; + + if ( $where ) { + $where = 'WHERE ' . $where; + } + + if ( $groupby ) { + $groupby = 'GROUP BY ' . $groupby; + } + + if ( $orderby ) { + $orderby = "ORDER BY $orderby"; + } + + $found_rows = ''; + if ( ! $this->query_vars['no_found_rows'] ) { + $found_rows = 'SQL_CALC_FOUND_ROWS'; + } + + $this->sql_clauses['select'] = "SELECT $found_rows $fields"; + $this->sql_clauses['from'] = "FROM $wpdb->blogs $join"; + $this->sql_clauses['groupby'] = $groupby; + $this->sql_clauses['orderby'] = $orderby; + $this->sql_clauses['limits'] = $limits; + + $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + + if ( $this->query_vars['count'] ) { + return intval( $wpdb->get_var( $this->request ) ); + } + + $site_ids = $wpdb->get_col( $this->request ); + + return array_map( 'intval', $site_ids ); + } + + /** + * Populates found_sites and max_num_pages properties for the current query + * if the limit clause was used. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + private function set_found_sites() { + global $wpdb; + + if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) { + /** + * Filters the query used to retrieve found site count. + * + * @since 4.6.0 + * + * @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'. + * @param WP_Site_Query $site_query The `WP_Site_Query` instance. + */ + $found_sites_query = apply_filters( 'found_sites_query', 'SELECT FOUND_ROWS()', $this ); + + $this->found_sites = (int) $wpdb->get_var( $found_sites_query ); + } + } + + /** + * Used internally to generate an SQL string for searching across multiple columns. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $string Search string. + * @param array $columns Columns to search. + * @return string Search SQL. + */ + protected function get_search_sql( $string, $columns ) { + global $wpdb; + + if ( false !== strpos( $string, '*' ) ) { + $like = '%' . implode( '%', array_map( array( $wpdb, 'esc_like' ), explode( '*', $string ) ) ) . '%'; + } else { + $like = '%' . $wpdb->esc_like( $string ) . '%'; + } + + $searches = array(); + foreach ( $columns as $column ) { + $searches[] = $wpdb->prepare( "$column LIKE %s", $like ); + } + + return '(' . implode( ' OR ', $searches ) . ')'; + } + + /** + * Parses and sanitizes 'orderby' keys passed to the site query. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby Alias for the field to order by. + * @return string|false Value to used in the ORDER clause. False otherwise. + */ + protected function parse_orderby( $orderby ) { + global $wpdb; + + $parsed = false; + + switch ( $orderby ) { + case 'site__in': + $site__in = implode( ',', array_map( 'absint', $this->query_vars['site__in'] ) ); + $parsed = "FIELD( {$wpdb->blogs}.blog_id, $site__in )"; + break; + case 'network__in': + $network__in = implode( ',', array_map( 'absint', $this->query_vars['network__in'] ) ); + $parsed = "FIELD( {$wpdb->blogs}.site_id, $network__in )"; + break; + case 'domain': + case 'last_updated': + case 'path': + case 'registered': + $parsed = $orderby; + break; + case 'network_id': + $parsed = 'site_id'; + break; + case 'domain_length': + $parsed = 'CHAR_LENGTH(domain)'; + break; + case 'path_length': + $parsed = 'CHAR_LENGTH(path)'; + break; + case 'id': + $parsed = 'blog_id'; + break; + } + + return $parsed; + } + + /** + * Parses an 'order' query variable and cast it to 'ASC' or 'DESC' as necessary. + * + * @since 4.6.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'ASC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } +} diff --git a/backend/wp-includes/class-wp-site.php b/backend/wp-includes/class-wp-site.php new file mode 100644 index 0000000..f438264 --- /dev/null +++ b/backend/wp-includes/class-wp-site.php @@ -0,0 +1,347 @@ +<?php +/** + * Site API: WP_Site class + * + * @package WordPress + * @subpackage Multisite + * @since 4.5.0 + */ + +/** + * Core class used for interacting with a multisite site. + * + * This class is used during load to populate the `$current_blog` global and + * setup the current site. + * + * @since 4.5.0 + * + * @property int $id + * @property int $network_id + * @property string $blogname + * @property string $siteurl + * @property int $post_count + * @property string $home + */ +final class WP_Site { + + /** + * Site ID. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $blog_id; + + /** + * Domain of the site. + * + * @since 4.5.0 + * @var string + */ + public $domain = ''; + + /** + * Path of the site. + * + * @since 4.5.0 + * @var string + */ + public $path = ''; + + /** + * The ID of the site's parent network. + * + * Named "site" vs. "network" for legacy reasons. An individual site's "site" is + * its network. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $site_id = '0'; + + /** + * The date on which the site was created or registered. + * + * @since 4.5.0 + * @var string Date in MySQL's datetime format. + */ + public $registered = '0000-00-00 00:00:00'; + + /** + * The date and time on which site settings were last updated. + * + * @since 4.5.0 + * @var string Date in MySQL's datetime format. + */ + public $last_updated = '0000-00-00 00:00:00'; + + /** + * Whether the site should be treated as public. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $public = '1'; + + /** + * Whether the site should be treated as archived. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $archived = '0'; + + /** + * Whether the site should be treated as mature. + * + * Handling for this does not exist throughout WordPress core, but custom + * implementations exist that require the property to be present. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $mature = '0'; + + /** + * Whether the site should be treated as spam. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $spam = '0'; + + /** + * Whether the site should be treated as deleted. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $deleted = '0'; + + /** + * The language pack associated with this site. + * + * A numeric string, for compatibility reasons. + * + * @since 4.5.0 + * @var string + */ + public $lang_id = '0'; + + /** + * Retrieves a site from the database by its ID. + * + * @static + * @since 4.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $site_id The ID of the site to retrieve. + * @return WP_Site|false The site's object if found. False if not. + */ + public static function get_instance( $site_id ) { + global $wpdb; + + $site_id = (int) $site_id; + if ( ! $site_id ) { + return false; + } + + $_site = wp_cache_get( $site_id, 'sites' ); + + if ( ! $_site ) { + $_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $site_id ) ); + + if ( empty( $_site ) || is_wp_error( $_site ) ) { + return false; + } + + wp_cache_add( $site_id, $_site, 'sites' ); + } + + return new WP_Site( $_site ); + } + + /** + * Creates a new WP_Site object. + * + * Will populate object properties from the object provided and assign other + * default properties based on that information. + * + * @since 4.5.0 + * + * @param WP_Site|object $site A site object. + */ + public function __construct( $site ) { + foreach( get_object_vars( $site ) as $key => $value ) { + $this->$key = $value; + } + } + + /** + * Converts an object to array. + * + * @since 4.6.0 + * + * @return array Object as array. + */ + public function to_array() { + return get_object_vars( $this ); + } + + /** + * Getter. + * + * Allows current multisite naming conventions when getting properties. + * Allows access to extended site properties. + * + * @since 4.6.0 + * + * @param string $key Property to get. + * @return mixed Value of the property. Null if not available. + */ + public function __get( $key ) { + switch ( $key ) { + case 'id': + return (int) $this->blog_id; + case 'network_id': + return (int) $this->site_id; + case 'blogname': + case 'siteurl': + case 'post_count': + case 'home': + default: // Custom properties added by 'site_details' filter. + if ( ! did_action( 'ms_loaded' ) ) { + return null; + } + + $details = $this->get_details(); + if ( isset( $details->$key ) ) { + return $details->$key; + } + } + + return null; + } + + /** + * Isset-er. + * + * Allows current multisite naming conventions when checking for properties. + * Checks for extended site properties. + * + * @since 4.6.0 + * + * @param string $key Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $key ) { + switch ( $key ) { + case 'id': + case 'network_id': + return true; + case 'blogname': + case 'siteurl': + case 'post_count': + case 'home': + if ( ! did_action( 'ms_loaded' ) ) { + return false; + } + return true; + default: // Custom properties added by 'site_details' filter. + if ( ! did_action( 'ms_loaded' ) ) { + return false; + } + + $details = $this->get_details(); + if ( isset( $details->$key ) ) { + return true; + } + } + + return false; + } + + /** + * Setter. + * + * Allows current multisite naming conventions while setting properties. + * + * @since 4.6.0 + * + * @param string $key Property to set. + * @param mixed $value Value to assign to the property. + */ + public function __set( $key, $value ) { + switch ( $key ) { + case 'id': + $this->blog_id = (string) $value; + break; + case 'network_id': + $this->site_id = (string) $value; + break; + default: + $this->$key = $value; + } + } + + /** + * Retrieves the details for this site. + * + * This method is used internally to lazy-load the extended properties of a site. + * + * @since 4.6.0 + * + * @see WP_Site::__get() + * + * @return stdClass A raw site object with all details included. + */ + private function get_details() { + $details = wp_cache_get( $this->blog_id, 'site-details' ); + + if ( false === $details ) { + + switch_to_blog( $this->blog_id ); + // Create a raw copy of the object for backwards compatibility with the filter below. + $details = new stdClass(); + foreach ( get_object_vars( $this ) as $key => $value ) { + $details->$key = $value; + } + $details->blogname = get_option( 'blogname' ); + $details->siteurl = get_option( 'siteurl' ); + $details->post_count = get_option( 'post_count' ); + $details->home = get_option( 'home' ); + restore_current_blog(); + + wp_cache_set( $this->blog_id, $details, 'site-details' ); + } + + /** This filter is documented in wp-includes/ms-blogs.php */ + $details = apply_filters_deprecated( 'blog_details', array( $details ), '4.7.0', 'site_details' ); + + /** + * Filters a site's extended properties. + * + * @since 4.6.0 + * + * @param stdClass $details The site details. + */ + $details = apply_filters( 'site_details', $details ); + + return $details; + } +} diff --git a/backend/wp-includes/class-wp-tax-query.php b/backend/wp-includes/class-wp-tax-query.php new file mode 100644 index 0000000..ad34c5f --- /dev/null +++ b/backend/wp-includes/class-wp-tax-query.php @@ -0,0 +1,649 @@ +<?php +/** + * Taxonomy API: WP_Tax_Query class + * + * @package WordPress + * @subpackage Taxonomy + * @since 4.4.0 + */ + +/** + * Core class used to implement taxonomy queries for the Taxonomy API. + * + * Used for generating SQL clauses that filter a primary query according to object + * taxonomy terms. + * + * WP_Tax_Query is a helper that allows primary query classes, such as WP_Query, to filter + * their results by object metadata, by generating `JOIN` and `WHERE` subclauses to be + * attached to the primary SQL query string. + * + * @since 3.1.0 + */ +class WP_Tax_Query { + + /** + * Array of taxonomy queries. + * + * See WP_Tax_Query::__construct() for information on tax query arguments. + * + * @since 3.1.0 + * @var array + */ + public $queries = array(); + + /** + * The relation between the queries. Can be one of 'AND' or 'OR'. + * + * @since 3.1.0 + * @var string + */ + public $relation; + + /** + * Standard response when the query should not return any rows. + * + * @since 3.2.0 + * + * @static + * @var string + */ + private static $no_results = array( 'join' => array( '' ), 'where' => array( '0 = 1' ) ); + + /** + * A flat list of table aliases used in the JOIN clauses. + * + * @since 4.1.0 + * @var array + */ + protected $table_aliases = array(); + + /** + * Terms and taxonomies fetched by this query. + * + * We store this data in a flat array because they are referenced in a + * number of places by WP_Query. + * + * @since 4.1.0 + * @var array + */ + public $queried_terms = array(); + + /** + * Database table that where the metadata's objects are stored (eg $wpdb->users). + * + * @since 4.1.0 + * @var string + */ + public $primary_table; + + /** + * Column in 'primary_table' that represents the ID of the object. + * + * @since 4.1.0 + * @var string + */ + public $primary_id_column; + + /** + * Constructor. + * + * @since 3.1.0 + * @since 4.1.0 Added support for `$operator` 'NOT EXISTS' and 'EXISTS' values. + * + * @param array $tax_query { + * Array of taxonomy query clauses. + * + * @type string $relation Optional. The MySQL keyword used to join + * the clauses of the query. Accepts 'AND', or 'OR'. Default 'AND'. + * @type array { + * Optional. An array of first-order clause parameters, or another fully-formed tax query. + * + * @type string $taxonomy Taxonomy being queried. Optional when field=term_taxonomy_id. + * @type string|int|array $terms Term or terms to filter by. + * @type string $field Field to match $terms against. Accepts 'term_id', 'slug', + * 'name', or 'term_taxonomy_id'. Default: 'term_id'. + * @type string $operator MySQL operator to be used with $terms in the WHERE clause. + * Accepts 'AND', 'IN', 'NOT IN', 'EXISTS', 'NOT EXISTS'. + * Default: 'IN'. + * @type bool $include_children Optional. Whether to include child terms. + * Requires a $taxonomy. Default: true. + * } + * } + */ + public function __construct( $tax_query ) { + if ( isset( $tax_query['relation'] ) ) { + $this->relation = $this->sanitize_relation( $tax_query['relation'] ); + } else { + $this->relation = 'AND'; + } + + $this->queries = $this->sanitize_query( $tax_query ); + } + + /** + * Ensure the 'tax_query' argument passed to the class constructor is well-formed. + * + * Ensures that each query-level clause has a 'relation' key, and that + * each first-order clause contains all the necessary keys from `$defaults`. + * + * @since 4.1.0 + * + * @param array $queries Array of queries clauses. + * @return array Sanitized array of query clauses. + */ + public function sanitize_query( $queries ) { + $cleaned_query = array(); + + $defaults = array( + 'taxonomy' => '', + 'terms' => array(), + 'field' => 'term_id', + 'operator' => 'IN', + 'include_children' => true, + ); + + foreach ( $queries as $key => $query ) { + if ( 'relation' === $key ) { + $cleaned_query['relation'] = $this->sanitize_relation( $query ); + + // First-order clause. + } elseif ( self::is_first_order_clause( $query ) ) { + + $cleaned_clause = array_merge( $defaults, $query ); + $cleaned_clause['terms'] = (array) $cleaned_clause['terms']; + $cleaned_query[] = $cleaned_clause; + + /* + * Keep a copy of the clause in the flate + * $queried_terms array, for use in WP_Query. + */ + if ( ! empty( $cleaned_clause['taxonomy'] ) && 'NOT IN' !== $cleaned_clause['operator'] ) { + $taxonomy = $cleaned_clause['taxonomy']; + if ( ! isset( $this->queried_terms[ $taxonomy ] ) ) { + $this->queried_terms[ $taxonomy ] = array(); + } + + /* + * Backward compatibility: Only store the first + * 'terms' and 'field' found for a given taxonomy. + */ + if ( ! empty( $cleaned_clause['terms'] ) && ! isset( $this->queried_terms[ $taxonomy ]['terms'] ) ) { + $this->queried_terms[ $taxonomy ]['terms'] = $cleaned_clause['terms']; + } + + if ( ! empty( $cleaned_clause['field'] ) && ! isset( $this->queried_terms[ $taxonomy ]['field'] ) ) { + $this->queried_terms[ $taxonomy ]['field'] = $cleaned_clause['field']; + } + } + + // Otherwise, it's a nested query, so we recurse. + } elseif ( is_array( $query ) ) { + $cleaned_subquery = $this->sanitize_query( $query ); + + if ( ! empty( $cleaned_subquery ) ) { + // All queries with children must have a relation. + if ( ! isset( $cleaned_subquery['relation'] ) ) { + $cleaned_subquery['relation'] = 'AND'; + } + + $cleaned_query[] = $cleaned_subquery; + } + } + } + + return $cleaned_query; + } + + /** + * Sanitize a 'relation' operator. + * + * @since 4.1.0 + * + * @param string $relation Raw relation key from the query argument. + * @return string Sanitized relation ('AND' or 'OR'). + */ + public function sanitize_relation( $relation ) { + if ( 'OR' === strtoupper( $relation ) ) { + return 'OR'; + } else { + return 'AND'; + } + } + + /** + * Determine whether a clause is first-order. + * + * A "first-order" clause is one that contains any of the first-order + * clause keys ('terms', 'taxonomy', 'include_children', 'field', + * 'operator'). An empty clause also counts as a first-order clause, + * for backward compatibility. Any clause that doesn't meet this is + * determined, by process of elimination, to be a higher-order query. + * + * @since 4.1.0 + * + * @static + * + * @param array $query Tax query arguments. + * @return bool Whether the query clause is a first-order clause. + */ + protected static function is_first_order_clause( $query ) { + return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) ); + } + + /** + * Generates SQL clauses to be appended to a main query. + * + * @since 3.1.0 + * + * @static + * + * @param string $primary_table Database table where the object being filtered is stored (eg wp_users). + * @param string $primary_id_column ID column for the filtered object in $primary_table. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + public function get_sql( $primary_table, $primary_id_column ) { + $this->primary_table = $primary_table; + $this->primary_id_column = $primary_id_column; + + return $this->get_sql_clauses(); + } + + /** + * Generate SQL clauses to be appended to a main query. + * + * Called by the public WP_Tax_Query::get_sql(), this method + * is abstracted out to maintain parity with the other Query classes. + * + * @since 4.1.0 + * + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_clauses() { + /* + * $queries are passed by reference to get_sql_for_query() for recursion. + * To keep $this->queries unaltered, pass a copy. + */ + $queries = $this->queries; + $sql = $this->get_sql_for_query( $queries ); + + if ( ! empty( $sql['where'] ) ) { + $sql['where'] = ' AND ' . $sql['where']; + } + + return $sql; + } + + /** + * Generate SQL clauses for a single query array. + * + * If nested subqueries are found, this method recurses the tree to + * produce the properly nested SQL. + * + * @since 4.1.0 + * + * @param array $query Query to parse (passed by reference). + * @param int $depth Optional. Number of tree levels deep we currently are. + * Used to calculate indentation. Default 0. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to a single query array. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_for_query( &$query, $depth = 0 ) { + $sql_chunks = array( + 'join' => array(), + 'where' => array(), + ); + + $sql = array( + 'join' => '', + 'where' => '', + ); + + $indent = ''; + for ( $i = 0; $i < $depth; $i++ ) { + $indent .= " "; + } + + foreach ( $query as $key => &$clause ) { + if ( 'relation' === $key ) { + $relation = $query['relation']; + } elseif ( is_array( $clause ) ) { + + // This is a first-order clause. + if ( $this->is_first_order_clause( $clause ) ) { + $clause_sql = $this->get_sql_for_clause( $clause, $query ); + + $where_count = count( $clause_sql['where'] ); + if ( ! $where_count ) { + $sql_chunks['where'][] = ''; + } elseif ( 1 === $where_count ) { + $sql_chunks['where'][] = $clause_sql['where'][0]; + } else { + $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; + } + + $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); + // This is a subquery, so we recurse. + } else { + $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); + + $sql_chunks['where'][] = $clause_sql['where']; + $sql_chunks['join'][] = $clause_sql['join']; + } + } + } + + // Filter to remove empties. + $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); + $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); + + if ( empty( $relation ) ) { + $relation = 'AND'; + } + + // Filter duplicate JOIN clauses and combine into a single string. + if ( ! empty( $sql_chunks['join'] ) ) { + $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); + } + + // Generate a single WHERE clause with proper brackets and indentation. + if ( ! empty( $sql_chunks['where'] ) ) { + $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; + } + + return $sql; + } + + /** + * Generate SQL JOIN and WHERE clauses for a "first-order" query clause. + * + * @since 4.1.0 + * + * @global wpdb $wpdb The WordPress database abstraction object. + * + * @param array $clause Query clause (passed by reference). + * @param array $parent_query Parent query array. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to a first-order query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + public function get_sql_for_clause( &$clause, $parent_query ) { + global $wpdb; + + $sql = array( + 'where' => array(), + 'join' => array(), + ); + + $join = $where = ''; + + $this->clean_query( $clause ); + + if ( is_wp_error( $clause ) ) { + return self::$no_results; + } + + $terms = $clause['terms']; + $operator = strtoupper( $clause['operator'] ); + + if ( 'IN' == $operator ) { + + if ( empty( $terms ) ) { + return self::$no_results; + } + + $terms = implode( ',', $terms ); + + /* + * Before creating another table join, see if this clause has a + * sibling with an existing join that can be shared. + */ + $alias = $this->find_compatible_table_alias( $clause, $parent_query ); + if ( false === $alias ) { + $i = count( $this->table_aliases ); + $alias = $i ? 'tt' . $i : $wpdb->term_relationships; + + // Store the alias as part of a flat array to build future iterators. + $this->table_aliases[] = $alias; + + // Store the alias with this clause, so later siblings can use it. + $clause['alias'] = $alias; + + $join .= " LEFT JOIN $wpdb->term_relationships"; + $join .= $i ? " AS $alias" : ''; + $join .= " ON ($this->primary_table.$this->primary_id_column = $alias.object_id)"; + } + + + $where = "$alias.term_taxonomy_id $operator ($terms)"; + + } elseif ( 'NOT IN' == $operator ) { + + if ( empty( $terms ) ) { + return $sql; + } + + $terms = implode( ',', $terms ); + + $where = "$this->primary_table.$this->primary_id_column NOT IN ( + SELECT object_id + FROM $wpdb->term_relationships + WHERE term_taxonomy_id IN ($terms) + )"; + + } elseif ( 'AND' == $operator ) { + + if ( empty( $terms ) ) { + return $sql; + } + + $num_terms = count( $terms ); + + $terms = implode( ',', $terms ); + + $where = "( + SELECT COUNT(1) + FROM $wpdb->term_relationships + WHERE term_taxonomy_id IN ($terms) + AND object_id = $this->primary_table.$this->primary_id_column + ) = $num_terms"; + + } elseif ( 'NOT EXISTS' === $operator || 'EXISTS' === $operator ) { + + $where = $wpdb->prepare( "$operator ( + SELECT 1 + FROM $wpdb->term_relationships + INNER JOIN $wpdb->term_taxonomy + ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id + WHERE $wpdb->term_taxonomy.taxonomy = %s + AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column + )", $clause['taxonomy'] ); + + } + + $sql['join'][] = $join; + $sql['where'][] = $where; + return $sql; + } + + /** + * Identify an existing table alias that is compatible with the current query clause. + * + * We avoid unnecessary table joins by allowing each clause to look for + * an existing table alias that is compatible with the query that it + * needs to perform. + * + * An existing alias is compatible if (a) it is a sibling of `$clause` + * (ie, it's under the scope of the same relation), and (b) the combination + * of operator and relation between the clauses allows for a shared table + * join. In the case of WP_Tax_Query, this only applies to 'IN' + * clauses that are connected by the relation 'OR'. + * + * @since 4.1.0 + * + * @param array $clause Query clause. + * @param array $parent_query Parent query of $clause. + * @return string|false Table alias if found, otherwise false. + */ + protected function find_compatible_table_alias( $clause, $parent_query ) { + $alias = false; + + // Sanity check. Only IN queries use the JOIN syntax . + if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) { + return $alias; + } + + // Since we're only checking IN queries, we're only concerned with OR relations. + if ( ! isset( $parent_query['relation'] ) || 'OR' !== $parent_query['relation'] ) { + return $alias; + } + + $compatible_operators = array( 'IN' ); + + foreach ( $parent_query as $sibling ) { + if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) { + continue; + } + + if ( empty( $sibling['alias'] ) || empty( $sibling['operator'] ) ) { + continue; + } + + // The sibling must both have compatible operator to share its alias. + if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) { + $alias = $sibling['alias']; + break; + } + } + + return $alias; + } + + /** + * Validates a single query. + * + * @since 3.2.0 + * + * @param array $query The single query. Passed by reference. + */ + private function clean_query( &$query ) { + if ( empty( $query['taxonomy'] ) ) { + if ( 'term_taxonomy_id' !== $query['field'] ) { + $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); + return; + } + + // so long as there are shared terms, include_children requires that a taxonomy is set + $query['include_children'] = false; + } elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) { + $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); + return; + } + + $query['terms'] = array_unique( (array) $query['terms'] ); + + if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) { + $this->transform_query( $query, 'term_id' ); + + if ( is_wp_error( $query ) ) + return; + + $children = array(); + foreach ( $query['terms'] as $term ) { + $children = array_merge( $children, get_term_children( $term, $query['taxonomy'] ) ); + $children[] = $term; + } + $query['terms'] = $children; + } + + $this->transform_query( $query, 'term_taxonomy_id' ); + } + + /** + * Transforms a single query, from one field to another. + * + * Operates on the `$query` object by reference. In the case of error, + * `$query` is converted to a WP_Error object. + * + * @since 3.2.0 + * + * @global wpdb $wpdb The WordPress database abstraction object. + * + * @param array $query The single query. Passed by reference. + * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id', + * or 'term_id'. Default 'term_id'. + */ + public function transform_query( &$query, $resulting_field ) { + if ( empty( $query['terms'] ) ) + return; + + if ( $query['field'] == $resulting_field ) + return; + + $resulting_field = sanitize_key( $resulting_field ); + + // Empty 'terms' always results in a null transformation. + $terms = array_filter( $query['terms'] ); + if ( empty( $terms ) ) { + $query['terms'] = array(); + $query['field'] = $resulting_field; + return; + } + + $args = array( + 'get' => 'all', + 'number' => 0, + 'taxonomy' => $query['taxonomy'], + 'update_term_meta_cache' => false, + 'orderby' => 'none', + ); + + // Term query parameter name depends on the 'field' being searched on. + switch ( $query['field'] ) { + case 'slug': + $args['slug'] = $terms; + break; + case 'name': + $args['name'] = $terms; + break; + case 'term_taxonomy_id': + $args['term_taxonomy_id'] = $terms; + break; + default: + $args['include'] = wp_parse_id_list( $terms ); + break; + } + + $term_query = new WP_Term_Query(); + $term_list = $term_query->query( $args ); + + if ( is_wp_error( $term_list ) ) { + $query = $term_list; + return; + } + + if ( 'AND' == $query['operator'] && count( $term_list ) < count( $query['terms'] ) ) { + $query = new WP_Error( 'inexistent_terms', __( 'Inexistent terms.' ) ); + return; + } + + $query['terms'] = wp_list_pluck( $term_list, $resulting_field ); + $query['field'] = $resulting_field; + } +} diff --git a/backend/wp-includes/class-wp-taxonomy.php b/backend/wp-includes/class-wp-taxonomy.php new file mode 100644 index 0000000..e749eef --- /dev/null +++ b/backend/wp-includes/class-wp-taxonomy.php @@ -0,0 +1,424 @@ +<?php +/** + * Taxonomy API: WP_Taxonomy class + * + * @package WordPress + * @subpackage Taxonomy + * @since 4.7.0 + */ + +/** + * Core class used for interacting with taxonomies. + * + * @since 4.7.0 + */ +final class WP_Taxonomy { + /** + * Taxonomy key. + * + * @since 4.7.0 + * @var string + */ + public $name; + + /** + * Name of the taxonomy shown in the menu. Usually plural. + * + * @since 4.7.0 + * @var string + */ + public $label; + + /** + * An array of labels for this taxonomy. + * + * @since 4.7.0 + * @var object + */ + public $labels = array(); + + /** + * A short descriptive summary of what the taxonomy is for. + * + * @since 4.7.0 + * @var string + */ + public $description = ''; + + /** + * Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users. + * + * @since 4.7.0 + * @var bool + */ + public $public = true; + + /** + * Whether the taxonomy is publicly queryable. + * + * @since 4.7.0 + * @var bool + */ + public $publicly_queryable = true; + + /** + * Whether the taxonomy is hierarchical. + * + * @since 4.7.0 + * @var bool + */ + public $hierarchical = false; + + /** + * Whether to generate and allow a UI for managing terms in this taxonomy in the admin. + * + * @since 4.7.0 + * @var bool + */ + public $show_ui = true; + + /** + * Whether to show the taxonomy in the admin menu. + * + * If true, the taxonomy is shown as a submenu of the object type menu. If false, no menu is shown. + * + * @since 4.7.0 + * @var bool + */ + public $show_in_menu = true; + + /** + * Whether the taxonomy is available for selection in navigation menus. + * + * @since 4.7.0 + * @var bool + */ + public $show_in_nav_menus = true; + + /** + * Whether to list the taxonomy in the tag cloud widget controls. + * + * @since 4.7.0 + * @var bool + */ + public $show_tagcloud = true; + + /** + * Whether to show the taxonomy in the quick/bulk edit panel. + * + * @since 4.7.0 + * @var bool + */ + public $show_in_quick_edit = true; + + /** + * Whether to display a column for the taxonomy on its post type listing screens. + * + * @since 4.7.0 + * @var bool + */ + public $show_admin_column = false; + + /** + * The callback function for the meta box display. + * + * @since 4.7.0 + * @var bool|callable + */ + public $meta_box_cb = null; + + /** + * An array of object types this taxonomy is registered for. + * + * @since 4.7.0 + * @var array + */ + public $object_type = null; + + /** + * Capabilities for this taxonomy. + * + * @since 4.7.0 + * @var array + */ + public $cap; + + /** + * Rewrites information for this taxonomy. + * + * @since 4.7.0 + * @var array|false + */ + public $rewrite; + + /** + * Query var string for this taxonomy. + * + * @since 4.7.0 + * @var string|false + */ + public $query_var; + + /** + * Function that will be called when the count is updated. + * + * @since 4.7.0 + * @var callable + */ + public $update_count_callback; + + /** + * Whether this taxonomy should appear in the REST API. + * + * Default false. If true, standard endpoints will be registered with + * respect to $rest_base and $rest_controller_class. + * + * @since 4.7.4 + * @var bool $show_in_rest + */ + public $show_in_rest; + + /** + * The base path for this taxonomy's REST API endpoints. + * + * @since 4.7.4 + * @var string|bool $rest_base + */ + public $rest_base; + + /** + * The controller for this taxonomy's REST API endpoints. + * + * Custom controllers must extend WP_REST_Controller. + * + * @since 4.7.4 + * @var string|bool $rest_controller_class + */ + public $rest_controller_class; + + /** + * Whether it is a built-in taxonomy. + * + * @since 4.7.0 + * @var bool + */ + public $_builtin; + + /** + * Constructor. + * + * @since 4.7.0 + * + * @global WP $wp WP instance. + * + * @param string $taxonomy Taxonomy key, must not exceed 32 characters. + * @param array|string $object_type Name of the object type for the taxonomy object. + * @param array|string $args Optional. Array or query string of arguments for registering a taxonomy. + * Default empty array. + */ + public function __construct( $taxonomy, $object_type, $args = array() ) { + $this->name = $taxonomy; + + $this->set_props( $object_type, $args ); + } + + /** + * Sets taxonomy properties. + * + * @since 4.7.0 + * + * @param array|string $object_type Name of the object type for the taxonomy object. + * @param array|string $args Array or query string of arguments for registering a taxonomy. + */ + public function set_props( $object_type, $args ) { + $args = wp_parse_args( $args ); + + /** + * Filters the arguments for registering a taxonomy. + * + * @since 4.4.0 + * + * @param array $args Array of arguments for registering a taxonomy. + * @param string $taxonomy Taxonomy key. + * @param array $object_type Array of names of object types for the taxonomy. + */ + $args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type ); + + $defaults = array( + 'labels' => array(), + 'description' => '', + 'public' => true, + 'publicly_queryable' => null, + 'hierarchical' => false, + 'show_ui' => null, + 'show_in_menu' => null, + 'show_in_nav_menus' => null, + 'show_tagcloud' => null, + 'show_in_quick_edit' => null, + 'show_admin_column' => false, + 'meta_box_cb' => null, + 'capabilities' => array(), + 'rewrite' => true, + 'query_var' => $this->name, + 'update_count_callback' => '', + 'show_in_rest' => false, + 'rest_base' => false, + 'rest_controller_class' => false, + '_builtin' => false, + ); + + $args = array_merge( $defaults, $args ); + + // If not set, default to the setting for public. + if ( null === $args['publicly_queryable'] ) { + $args['publicly_queryable'] = $args['public']; + } + + if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) ) { + if ( true === $args['query_var'] ) { + $args['query_var'] = $this->name; + } else { + $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); + } + } else { + // Force query_var to false for non-public taxonomies. + $args['query_var'] = false; + } + + if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + $args['rewrite'] = wp_parse_args( $args['rewrite'], array( + 'with_front' => true, + 'hierarchical' => false, + 'ep_mask' => EP_NONE, + ) ); + + if ( empty( $args['rewrite']['slug'] ) ) { + $args['rewrite']['slug'] = sanitize_title_with_dashes( $this->name ); + } + } + + // If not set, default to the setting for public. + if ( null === $args['show_ui'] ) { + $args['show_ui'] = $args['public']; + } + + // If not set, default to the setting for show_ui. + if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) { + $args['show_in_menu'] = $args['show_ui']; + } + + // If not set, default to the setting for public. + if ( null === $args['show_in_nav_menus'] ) { + $args['show_in_nav_menus'] = $args['public']; + } + + // If not set, default to the setting for show_ui. + if ( null === $args['show_tagcloud'] ) { + $args['show_tagcloud'] = $args['show_ui']; + } + + // If not set, default to the setting for show_ui. + if ( null === $args['show_in_quick_edit'] ) { + $args['show_in_quick_edit'] = $args['show_ui']; + } + + $default_caps = array( + 'manage_terms' => 'manage_categories', + 'edit_terms' => 'manage_categories', + 'delete_terms' => 'manage_categories', + 'assign_terms' => 'edit_posts', + ); + + $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] ); + unset( $args['capabilities'] ); + + $args['object_type'] = array_unique( (array) $object_type ); + + // If not set, use the default meta box + if ( null === $args['meta_box_cb'] ) { + if ( $args['hierarchical'] ) { + $args['meta_box_cb'] = 'post_categories_meta_box'; + } else { + $args['meta_box_cb'] = 'post_tags_meta_box'; + } + } + + $args['name'] = $this->name; + + foreach ( $args as $property_name => $property_value ) { + $this->$property_name = $property_value; + } + + $this->labels = get_taxonomy_labels( $this ); + $this->label = $this->labels->name; + } + + /** + * Adds the necessary rewrite rules for the taxonomy. + * + * @since 4.7.0 + * + * @global WP $wp Current WordPress environment instance. + */ + public function add_rewrite_rules() { + /* @var WP $wp */ + global $wp; + + // Non-publicly queryable taxonomies should not register query vars, except in the admin. + if ( false !== $this->query_var && $wp ) { + $wp->add_query_var( $this->query_var ); + } + + if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) { + if ( $this->hierarchical && $this->rewrite['hierarchical'] ) { + $tag = '(.+?)'; + } else { + $tag = '([^/]+)'; + } + + add_rewrite_tag( "%$this->name%", $tag, $this->query_var ? "{$this->query_var}=" : "taxonomy=$this->name&term=" ); + add_permastruct( $this->name, "{$this->rewrite['slug']}/%$this->name%", $this->rewrite ); + } + } + + /** + * Removes any rewrite rules, permastructs, and rules for the taxonomy. + * + * @since 4.7.0 + * + * @global WP $wp Current WordPress environment instance. + */ + public function remove_rewrite_rules() { + /* @var WP $wp */ + global $wp; + + // Remove query var. + if ( false !== $this->query_var ) { + $wp->remove_query_var( $this->query_var ); + } + + // Remove rewrite tags and permastructs. + if ( false !== $this->rewrite ) { + remove_rewrite_tag( "%$this->name%" ); + remove_permastruct( $this->name ); + } + } + + /** + * Registers the ajax callback for the meta box. + * + * @since 4.7.0 + */ + public function add_hooks() { + add_filter( 'wp_ajax_add-' . $this->name, '_wp_ajax_add_hierarchical_term' ); + } + + /** + * Removes the ajax callback for the meta box. + * + * @since 4.7.0 + */ + public function remove_hooks() { + remove_filter( 'wp_ajax_add-' . $this->name, '_wp_ajax_add_hierarchical_term' ); + } +} diff --git a/backend/wp-includes/class-wp-term-query.php b/backend/wp-includes/class-wp-term-query.php new file mode 100644 index 0000000..d704f5e --- /dev/null +++ b/backend/wp-includes/class-wp-term-query.php @@ -0,0 +1,969 @@ +<?php + +/** + * Taxonomy API: WP_Term_Query class. + * + * @package WordPress + * @subpackage Taxonomy + * @since 4.6.0 + */ + +/** + * Class used for querying terms. + * + * @since 4.6.0 + * + * @see WP_Term_Query::__construct() for accepted arguments. + */ +class WP_Term_Query { + + /** + * SQL string used to perform database query. + * + * @since 4.6.0 + * @var string + */ + public $request; + + /** + * Metadata query container. + * + * @since 4.6.0 + * @var object WP_Meta_Query + */ + public $meta_query = false; + + /** + * Metadata query clauses. + * + * @since 4.6.0 + * @var array + */ + protected $meta_query_clauses; + + /** + * SQL query clauses. + * + * @since 4.6.0 + * @var array + */ + protected $sql_clauses = array( + 'select' => '', + 'from' => '', + 'where' => array(), + 'orderby' => '', + 'limits' => '', + ); + + /** + * Query vars set by the user. + * + * @since 4.6.0 + * @var array + */ + public $query_vars; + + /** + * Default values for query vars. + * + * @since 4.6.0 + * @var array + */ + public $query_var_defaults; + + /** + * List of terms located by the query. + * + * @since 4.6.0 + * @var array + */ + public $terms; + + /** + * Constructor. + * + * Sets up the term query, based on the query vars passed. + * + * @since 4.6.0 + * @since 4.6.0 Introduced 'term_taxonomy_id' parameter. + * @since 4.7.0 Introduced 'object_ids' parameter. + * @since 4.9.0 Added 'slug__in' support for 'orderby'. + * + * @param string|array $query { + * Optional. Array or query string of term query parameters. Default empty. + * + * @type string|array $taxonomy Taxonomy name, or array of taxonomies, to which results should + * be limited. + * @type int|array $object_ids Optional. Object ID, or array of object IDs. Results will be + * limited to terms associated with these objects. + * @type string $orderby Field(s) to order terms by. Accepts term fields ('name', + * 'slug', 'term_group', 'term_id', 'id', 'description', 'parent'), + * 'count' for term taxonomy count, 'include' to match the + * 'order' of the $include param, 'slug__in' to match the + * 'order' of the $slug param, 'meta_value', 'meta_value_num', + * the value of `$meta_key`, the array keys of `$meta_query`, or + * 'none' to omit the ORDER BY clause. Defaults to 'name'. + * @type string $order Whether to order terms in ascending or descending order. + * Accepts 'ASC' (ascending) or 'DESC' (descending). + * Default 'ASC'. + * @type bool|int $hide_empty Whether to hide terms not assigned to any posts. Accepts + * 1|true or 0|false. Default 1|true. + * @type array|string $include Array or comma/space-separated string of term ids to include. + * Default empty array. + * @type array|string $exclude Array or comma/space-separated string of term ids to exclude. + * If $include is non-empty, $exclude is ignored. + * Default empty array. + * @type array|string $exclude_tree Array or comma/space-separated string of term ids to exclude + * along with all of their descendant terms. If $include is + * non-empty, $exclude_tree is ignored. Default empty array. + * @type int|string $number Maximum number of terms to return. Accepts ''|0 (all) or any + * positive number. Default ''|0 (all). Note that $number may + * not return accurate results when coupled with $object_ids. + * See #41796 for details. + * @type int $offset The number by which to offset the terms query. Default empty. + * @type string $fields Term fields to query for. Accepts 'all' (returns an array of + * complete term objects), 'all_with_object_id' (returns an + * array of term objects with the 'object_id' param; only works + * when the `$fields` parameter is 'object_ids' ), 'ids' + * (returns an array of ids), 'tt_ids' (returns an array of + * term taxonomy ids), 'id=>parent' (returns an associative + * array with ids as keys, parent term IDs as values), 'names' + * (returns an array of term names), 'count' (returns the number + * of matching terms), 'id=>name' (returns an associative array + * with ids as keys, term names as values), or 'id=>slug' + * (returns an associative array with ids as keys, term slugs + * as values). Default 'all'. + * @type bool $count Whether to return a term count (true) or array of term objects + * (false). Will take precedence over `$fields` if true. + * Default false. + * @type string|array $name Optional. Name or array of names to return term(s) for. + * Default empty. + * @type string|array $slug Optional. Slug or array of slugs to return term(s) for. + * Default empty. + * @type int|array $term_taxonomy_id Optional. Term taxonomy ID, or array of term taxonomy IDs, + * to match when querying terms. + * @type bool $hierarchical Whether to include terms that have non-empty descendants (even + * if $hide_empty is set to true). Default true. + * @type string $search Search criteria to match terms. Will be SQL-formatted with + * wildcards before and after. Default empty. + * @type string $name__like Retrieve terms with criteria by which a term is LIKE + * `$name__like`. Default empty. + * @type string $description__like Retrieve terms where the description is LIKE + * `$description__like`. Default empty. + * @type bool $pad_counts Whether to pad the quantity of a term's children in the + * quantity of each term's "count" object variable. + * Default false. + * @type string $get Whether to return terms regardless of ancestry or whether the + * terms are empty. Accepts 'all' or empty (disabled). + * Default empty. + * @type int $child_of Term ID to retrieve child terms of. If multiple taxonomies + * are passed, $child_of is ignored. Default 0. + * @type int|string $parent Parent term ID to retrieve direct-child terms of. + * Default empty. + * @type bool $childless True to limit results to terms that have no children. + * This parameter has no effect on non-hierarchical taxonomies. + * Default false. + * @type string $cache_domain Unique cache key to be produced when this query is stored in + * an object cache. Default is 'core'. + * @type bool $update_term_meta_cache Whether to prime meta caches for matched terms. Default true. + * @type array $meta_query Optional. Meta query clauses to limit retrieved terms by. + * See `WP_Meta_Query`. Default empty. + * @type string $meta_key Limit terms to those matching a specific metadata key. + * Can be used in conjunction with `$meta_value`. Default empty. + * @type string $meta_value Limit terms to those matching a specific metadata value. + * Usually used in conjunction with `$meta_key`. Default empty. + * @type string $meta_type Type of object metadata is for (e.g., comment, post, or user). + * Default empty. + * @type string $meta_compare Comparison operator to test the 'meta_value'. Default empty. + * } + */ + public function __construct( $query = '' ) { + $this->query_var_defaults = array( + 'taxonomy' => null, + 'object_ids' => null, + 'orderby' => 'name', + 'order' => 'ASC', + 'hide_empty' => true, + 'include' => array(), + 'exclude' => array(), + 'exclude_tree' => array(), + 'number' => '', + 'offset' => '', + 'fields' => 'all', + 'count' => false, + 'name' => '', + 'slug' => '', + 'term_taxonomy_id' => '', + 'hierarchical' => true, + 'search' => '', + 'name__like' => '', + 'description__like' => '', + 'pad_counts' => false, + 'get' => '', + 'child_of' => 0, + 'parent' => '', + 'childless' => false, + 'cache_domain' => 'core', + 'update_term_meta_cache' => true, + 'meta_query' => '', + 'meta_key' => '', + 'meta_value' => '', + 'meta_type' => '', + 'meta_compare' => '', + ); + + if ( ! empty( $query ) ) { + $this->query( $query ); + } + } + + /** + * Parse arguments passed to the term query with default query parameters. + * + * @since 4.6.0 + * + * @param string|array $query WP_Term_Query arguments. See WP_Term_Query::__construct() + */ + public function parse_query( $query = '' ) { + if ( empty( $query ) ) { + $query = $this->query_vars; + } + + $taxonomies = isset( $query['taxonomy'] ) ? (array) $query['taxonomy'] : null; + + /** + * Filters the terms query default arguments. + * + * Use {@see 'get_terms_args'} to filter the passed arguments. + * + * @since 4.4.0 + * + * @param array $defaults An array of default get_terms() arguments. + * @param array $taxonomies An array of taxonomies. + */ + $this->query_var_defaults = apply_filters( 'get_terms_defaults', $this->query_var_defaults, $taxonomies ); + + $query = wp_parse_args( $query, $this->query_var_defaults ); + + $query['number'] = absint( $query['number'] ); + $query['offset'] = absint( $query['offset'] ); + + // 'parent' overrides 'child_of'. + if ( 0 < intval( $query['parent'] ) ) { + $query['child_of'] = false; + } + + if ( 'all' == $query['get'] ) { + $query['childless'] = false; + $query['child_of'] = 0; + $query['hide_empty'] = 0; + $query['hierarchical'] = false; + $query['pad_counts'] = false; + } + + $query['taxonomy'] = $taxonomies; + + $this->query_vars = $query; + + /** + * Fires after term query vars have been parsed. + * + * @since 4.6.0 + * + * @param WP_Term_Query $this Current instance of WP_Term_Query. + */ + do_action( 'parse_term_query', $this ); + } + + /** + * Sets up the query for retrieving terms. + * + * @since 4.6.0 + * + * @param string|array $query Array or URL query string of parameters. + * @return array|int List of terms, or number of terms when 'count' is passed as a query var. + */ + public function query( $query ) { + $this->query_vars = wp_parse_args( $query ); + return $this->get_terms(); + } + + /** + * Get terms, based on query_vars. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return array List of terms. + */ + public function get_terms() { + global $wpdb; + + $this->parse_query( $this->query_vars ); + $args = &$this->query_vars; + + // Set up meta_query so it's available to 'pre_get_terms'. + $this->meta_query = new WP_Meta_Query(); + $this->meta_query->parse_query_vars( $args ); + + /** + * Fires before terms are retrieved. + * + * @since 4.6.0 + * + * @param WP_Term_Query $this Current instance of WP_Term_Query. + */ + do_action( 'pre_get_terms', $this ); + + $taxonomies = (array) $args['taxonomy']; + + // Save queries by not crawling the tree in the case of multiple taxes or a flat tax. + $has_hierarchical_tax = false; + if ( $taxonomies ) { + foreach ( $taxonomies as $_tax ) { + if ( is_taxonomy_hierarchical( $_tax ) ) { + $has_hierarchical_tax = true; + } + } + } + + if ( ! $has_hierarchical_tax ) { + $args['hierarchical'] = false; + $args['pad_counts'] = false; + } + + // 'parent' overrides 'child_of'. + if ( 0 < intval( $args['parent'] ) ) { + $args['child_of'] = false; + } + + if ( 'all' == $args['get'] ) { + $args['childless'] = false; + $args['child_of'] = 0; + $args['hide_empty'] = 0; + $args['hierarchical'] = false; + $args['pad_counts'] = false; + } + + /** + * Filters the terms query arguments. + * + * @since 3.1.0 + * + * @param array $args An array of get_terms() arguments. + * @param array $taxonomies An array of taxonomies. + */ + $args = apply_filters( 'get_terms_args', $args, $taxonomies ); + + // Avoid the query if the queried parent/child_of term has no descendants. + $child_of = $args['child_of']; + $parent = $args['parent']; + + if ( $child_of ) { + $_parent = $child_of; + } elseif ( $parent ) { + $_parent = $parent; + } else { + $_parent = false; + } + + if ( $_parent ) { + $in_hierarchy = false; + foreach ( $taxonomies as $_tax ) { + $hierarchy = _get_term_hierarchy( $_tax ); + + if ( isset( $hierarchy[ $_parent ] ) ) { + $in_hierarchy = true; + } + } + + if ( ! $in_hierarchy ) { + return array(); + } + } + + // 'term_order' is a legal sort order only when joining the relationship table. + $_orderby = $this->query_vars['orderby']; + if ( 'term_order' === $_orderby && empty( $this->query_vars['object_ids'] ) ) { + $_orderby = 'term_id'; + } + $orderby = $this->parse_orderby( $_orderby ); + + if ( $orderby ) { + $orderby = "ORDER BY $orderby"; + } + + $order = $this->parse_order( $this->query_vars['order'] ); + + if ( $taxonomies ) { + $this->sql_clauses['where']['taxonomy'] = "tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')"; + } + + $exclude = $args['exclude']; + $exclude_tree = $args['exclude_tree']; + $include = $args['include']; + + $inclusions = ''; + if ( ! empty( $include ) ) { + $exclude = ''; + $exclude_tree = ''; + $inclusions = implode( ',', wp_parse_id_list( $include ) ); + } + + if ( ! empty( $inclusions ) ) { + $this->sql_clauses['where']['inclusions'] = 't.term_id IN ( ' . $inclusions . ' )'; + } + + $exclusions = array(); + if ( ! empty( $exclude_tree ) ) { + $exclude_tree = wp_parse_id_list( $exclude_tree ); + $excluded_children = $exclude_tree; + foreach ( $exclude_tree as $extrunk ) { + $excluded_children = array_merge( + $excluded_children, + (array) get_terms( reset( $taxonomies ), array( + 'child_of' => intval( $extrunk ), + 'fields' => 'ids', + 'hide_empty' => 0 + ) ) + ); + } + $exclusions = array_merge( $excluded_children, $exclusions ); + } + + if ( ! empty( $exclude ) ) { + $exclusions = array_merge( wp_parse_id_list( $exclude ), $exclusions ); + } + + // 'childless' terms are those without an entry in the flattened term hierarchy. + $childless = (bool) $args['childless']; + if ( $childless ) { + foreach ( $taxonomies as $_tax ) { + $term_hierarchy = _get_term_hierarchy( $_tax ); + $exclusions = array_merge( array_keys( $term_hierarchy ), $exclusions ); + } + } + + if ( ! empty( $exclusions ) ) { + $exclusions = 't.term_id NOT IN (' . implode( ',', array_map( 'intval', $exclusions ) ) . ')'; + } else { + $exclusions = ''; + } + + /** + * Filters the terms to exclude from the terms query. + * + * @since 2.3.0 + * + * @param string $exclusions `NOT IN` clause of the terms query. + * @param array $args An array of terms query arguments. + * @param array $taxonomies An array of taxonomies. + */ + $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies ); + + if ( ! empty( $exclusions ) ) { + // Must do string manipulation here for backward compatibility with filter. + $this->sql_clauses['where']['exclusions'] = preg_replace( '/^\s*AND\s*/', '', $exclusions ); + } + + if ( + ( ! empty( $args['name'] ) ) || + ( is_string( $args['name'] ) && 0 !== strlen( $args['name'] ) ) + ) { + $names = (array) $args['name']; + foreach ( $names as &$_name ) { + // `sanitize_term_field()` returns slashed data. + $_name = stripslashes( sanitize_term_field( 'name', $_name, 0, reset( $taxonomies ), 'db' ) ); + } + + $this->sql_clauses['where']['name'] = "t.name IN ('" . implode( "', '", array_map( 'esc_sql', $names ) ) . "')"; + } + + if ( + ( ! empty( $args['slug'] ) ) || + ( is_string( $args['slug'] ) && 0 !== strlen( $args['slug'] ) ) + ) { + if ( is_array( $args['slug'] ) ) { + $slug = array_map( 'sanitize_title', $args['slug'] ); + $this->sql_clauses['where']['slug'] = "t.slug IN ('" . implode( "', '", $slug ) . "')"; + } else { + $slug = sanitize_title( $args['slug'] ); + $this->sql_clauses['where']['slug'] = "t.slug = '$slug'"; + } + } + + if ( ! empty( $args['term_taxonomy_id'] ) ) { + if ( is_array( $args['term_taxonomy_id'] ) ) { + $tt_ids = implode( ',', array_map( 'intval', $args['term_taxonomy_id'] ) ); + $this->sql_clauses['where']['term_taxonomy_id'] = "tt.term_taxonomy_id IN ({$tt_ids})"; + } else { + $this->sql_clauses['where']['term_taxonomy_id'] = $wpdb->prepare( "tt.term_taxonomy_id = %d", $args['term_taxonomy_id'] ); + } + } + + if ( ! empty( $args['name__like'] ) ) { + $this->sql_clauses['where']['name__like'] = $wpdb->prepare( "t.name LIKE %s", '%' . $wpdb->esc_like( $args['name__like'] ) . '%' ); + } + + if ( ! empty( $args['description__like'] ) ) { + $this->sql_clauses['where']['description__like'] = $wpdb->prepare( "tt.description LIKE %s", '%' . $wpdb->esc_like( $args['description__like'] ) . '%' ); + } + + if ( ! empty( $args['object_ids'] ) ) { + $object_ids = $args['object_ids']; + if ( ! is_array( $object_ids ) ) { + $object_ids = array( $object_ids ); + } + + $object_ids = implode( ', ', array_map( 'intval', $object_ids ) ); + $this->sql_clauses['where']['object_ids'] = "tr.object_id IN ($object_ids)"; + } + + /* + * When querying for object relationships, the 'count > 0' check + * added by 'hide_empty' is superfluous. + */ + if ( ! empty( $args['object_ids'] ) ) { + $args['hide_empty'] = false; + } + + if ( '' !== $parent ) { + $parent = (int) $parent; + $this->sql_clauses['where']['parent'] = "tt.parent = '$parent'"; + } + + $hierarchical = $args['hierarchical']; + if ( 'count' == $args['fields'] ) { + $hierarchical = false; + } + if ( $args['hide_empty'] && !$hierarchical ) { + $this->sql_clauses['where']['count'] = 'tt.count > 0'; + } + + $number = $args['number']; + $offset = $args['offset']; + + // Don't limit the query results when we have to descend the family tree. + if ( $number && ! $hierarchical && ! $child_of && '' === $parent ) { + if ( $offset ) { + $limits = 'LIMIT ' . $offset . ',' . $number; + } else { + $limits = 'LIMIT ' . $number; + } + } else { + $limits = ''; + } + + + if ( ! empty( $args['search'] ) ) { + $this->sql_clauses['where']['search'] = $this->get_search_sql( $args['search'] ); + } + + // Meta query support. + $join = ''; + $distinct = ''; + + // Reparse meta_query query_vars, in case they were modified in a 'pre_get_terms' callback. + $this->meta_query->parse_query_vars( $this->query_vars ); + $mq_sql = $this->meta_query->get_sql( 'term', 't', 'term_id' ); + $meta_clauses = $this->meta_query->get_clauses(); + + if ( ! empty( $meta_clauses ) ) { + $join .= $mq_sql['join']; + $this->sql_clauses['where']['meta_query'] = preg_replace( '/^\s*AND\s*/', '', $mq_sql['where'] ); + $distinct .= "DISTINCT"; + + } + + $selects = array(); + switch ( $args['fields'] ) { + case 'all': + case 'all_with_object_id' : + case 'tt_ids' : + case 'slugs' : + $selects = array( 't.*', 'tt.*' ); + if ( 'all_with_object_id' === $args['fields'] && ! empty( $args['object_ids'] ) ) { + $selects[] = 'tr.object_id'; + } + break; + case 'ids': + case 'id=>parent': + $selects = array( 't.term_id', 'tt.parent', 'tt.count', 'tt.taxonomy' ); + break; + case 'names': + $selects = array( 't.term_id', 'tt.parent', 'tt.count', 't.name', 'tt.taxonomy' ); + break; + case 'count': + $orderby = ''; + $order = ''; + $selects = array( 'COUNT(*)' ); + break; + case 'id=>name': + $selects = array( 't.term_id', 't.name', 'tt.count', 'tt.taxonomy' ); + break; + case 'id=>slug': + $selects = array( 't.term_id', 't.slug', 'tt.count', 'tt.taxonomy' ); + break; + } + + $_fields = $args['fields']; + + /** + * Filters the fields to select in the terms query. + * + * Field lists modified using this filter will only modify the term fields returned + * by the function when the `$fields` parameter set to 'count' or 'all'. In all other + * cases, the term fields in the results array will be determined by the `$fields` + * parameter alone. + * + * Use of this filter can result in unpredictable behavior, and is not recommended. + * + * @since 2.8.0 + * + * @param array $selects An array of fields to select for the terms query. + * @param array $args An array of term query arguments. + * @param array $taxonomies An array of taxonomies. + */ + $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) ); + + $join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id"; + + if ( ! empty( $this->query_vars['object_ids'] ) ) { + $join .= " INNER JOIN {$wpdb->term_relationships} AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id"; + } + + $where = implode( ' AND ', $this->sql_clauses['where'] ); + + /** + * Filters the terms query SQL clauses. + * + * @since 3.1.0 + * + * @param array $pieces Terms query SQL clauses. + * @param array $taxonomies An array of taxonomies. + * @param array $args An array of terms query arguments. + */ + $clauses = apply_filters( 'terms_clauses', compact( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' ), $taxonomies, $args ); + + $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; + $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; + $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; + $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : ''; + $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; + $order = isset( $clauses[ 'order' ] ) ? $clauses[ 'order' ] : ''; + $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; + + if ( $where ) { + $where = "WHERE $where"; + } + + $this->sql_clauses['select'] = "SELECT $distinct $fields"; + $this->sql_clauses['from'] = "FROM $wpdb->terms AS t $join"; + $this->sql_clauses['orderby'] = $orderby ? "$orderby $order" : ''; + $this->sql_clauses['limits'] = $limits; + + $this->request = "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['orderby']} {$this->sql_clauses['limits']}"; + + // $args can be anything. Only use the args defined in defaults to compute the key. + $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $this->query_var_defaults ) ) ) . serialize( $taxonomies ) . $this->request ); + $last_changed = wp_cache_get_last_changed( 'terms' ); + $cache_key = "get_terms:$key:$last_changed"; + $cache = wp_cache_get( $cache_key, 'terms' ); + if ( false !== $cache ) { + if ( 'all' === $_fields ) { + $cache = array_map( 'get_term', $cache ); + } + + $this->terms = $cache; + return $this->terms; + } + + if ( 'count' == $_fields ) { + $count = $wpdb->get_var( $this->request ); + wp_cache_set( $cache_key, $count, 'terms' ); + return $count; + } + + $terms = $wpdb->get_results( $this->request ); + if ( 'all' == $_fields || 'all_with_object_id' === $_fields ) { + update_term_cache( $terms ); + } + + // Prime termmeta cache. + if ( $args['update_term_meta_cache'] ) { + $term_ids = wp_list_pluck( $terms, 'term_id' ); + update_termmeta_cache( $term_ids ); + } + + if ( empty( $terms ) ) { + wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS ); + return array(); + } + + if ( $child_of ) { + foreach ( $taxonomies as $_tax ) { + $children = _get_term_hierarchy( $_tax ); + if ( ! empty( $children ) ) { + $terms = _get_term_children( $child_of, $terms, $_tax ); + } + } + } + + // Update term counts to include children. + if ( $args['pad_counts'] && 'all' == $_fields ) { + foreach ( $taxonomies as $_tax ) { + _pad_term_counts( $terms, $_tax ); + } + } + + // Make sure we show empty categories that have children. + if ( $hierarchical && $args['hide_empty'] && is_array( $terms ) ) { + foreach ( $terms as $k => $term ) { + if ( ! $term->count ) { + $children = get_term_children( $term->term_id, $term->taxonomy ); + if ( is_array( $children ) ) { + foreach ( $children as $child_id ) { + $child = get_term( $child_id, $term->taxonomy ); + if ( $child->count ) { + continue 2; + } + } + } + + // It really is empty. + unset( $terms[ $k ] ); + } + } + } + + /* + * When querying for terms connected to objects, we may get + * duplicate results. The duplicates should be preserved if + * `$fields` is 'all_with_object_id', but should otherwise be + * removed. + */ + if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' != $_fields ) { + $_tt_ids = $_terms = array(); + foreach ( $terms as $term ) { + if ( isset( $_tt_ids[ $term->term_id ] ) ) { + continue; + } + + $_tt_ids[ $term->term_id ] = 1; + $_terms[] = $term; + } + + $terms = $_terms; + } + + $_terms = array(); + if ( 'id=>parent' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->parent; + } + } elseif ( 'ids' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[] = (int) $term->term_id; + } + } elseif ( 'tt_ids' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[] = (int) $term->term_taxonomy_id; + } + } elseif ( 'names' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[] = $term->name; + } + } elseif ( 'slugs' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[] = $term->slug; + } + } elseif ( 'id=>name' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->name; + } + } elseif ( 'id=>slug' == $_fields ) { + foreach ( $terms as $term ) { + $_terms[ $term->term_id ] = $term->slug; + } + } + + if ( ! empty( $_terms ) ) { + $terms = $_terms; + } + + // Hierarchical queries are not limited, so 'offset' and 'number' must be handled now. + if ( $hierarchical && $number && is_array( $terms ) ) { + if ( $offset >= count( $terms ) ) { + $terms = array(); + } else { + $terms = array_slice( $terms, $offset, $number, true ); + } + } + + wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); + + if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) { + $terms = array_map( 'get_term', $terms ); + } + + $this->terms = $terms; + return $this->terms; + } + + /** + * Parse and sanitize 'orderby' keys passed to the term query. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby_raw Alias for the field to order by. + * @return string|false Value to used in the ORDER clause. False otherwise. + */ + protected function parse_orderby( $orderby_raw ) { + $_orderby = strtolower( $orderby_raw ); + $maybe_orderby_meta = false; + + if ( in_array( $_orderby, array( 'term_id', 'name', 'slug', 'term_group' ), true ) ) { + $orderby = "t.$_orderby"; + } elseif ( in_array( $_orderby, array( 'count', 'parent', 'taxonomy', 'term_taxonomy_id', 'description' ), true ) ) { + $orderby = "tt.$_orderby"; + } elseif ( 'term_order' === $_orderby ) { + $orderby = 'tr.term_order'; + } elseif ( 'include' == $_orderby && ! empty( $this->query_vars['include'] ) ) { + $include = implode( ',', wp_parse_id_list( $this->query_vars['include'] ) ); + $orderby = "FIELD( t.term_id, $include )"; + } elseif ( 'slug__in' == $_orderby && ! empty( $this->query_vars['slug'] ) && is_array( $this->query_vars['slug'] ) ) { + $slugs = implode( "', '", array_map( 'sanitize_title_for_query', $this->query_vars['slug'] ) ); + $orderby = "FIELD( t.slug, '" . $slugs . "')"; + } elseif ( 'none' == $_orderby ) { + $orderby = ''; + } elseif ( empty( $_orderby ) || 'id' == $_orderby || 'term_id' === $_orderby ) { + $orderby = 't.term_id'; + } else { + $orderby = 't.name'; + + // This may be a value of orderby related to meta. + $maybe_orderby_meta = true; + } + + /** + * Filters the ORDERBY clause of the terms query. + * + * @since 2.8.0 + * + * @param string $orderby `ORDERBY` clause of the terms query. + * @param array $args An array of terms query arguments. + * @param array $taxonomies An array of taxonomies. + */ + $orderby = apply_filters( 'get_terms_orderby', $orderby, $this->query_vars, $this->query_vars['taxonomy'] ); + + // Run after the 'get_terms_orderby' filter for backward compatibility. + if ( $maybe_orderby_meta ) { + $maybe_orderby_meta = $this->parse_orderby_meta( $_orderby ); + if ( $maybe_orderby_meta ) { + $orderby = $maybe_orderby_meta; + } + } + + return $orderby; + } + + /** + * Generate the ORDER BY clause for an 'orderby' param that is potentially related to a meta query. + * + * @since 4.6.0 + * + * @param string $orderby_raw Raw 'orderby' value passed to WP_Term_Query. + * @return string ORDER BY clause. + */ + protected function parse_orderby_meta( $orderby_raw ) { + $orderby = ''; + + // Tell the meta query to generate its SQL, so we have access to table aliases. + $this->meta_query->get_sql( 'term', 't', 'term_id' ); + $meta_clauses = $this->meta_query->get_clauses(); + if ( ! $meta_clauses || ! $orderby_raw ) { + return $orderby; + } + + $allowed_keys = array(); + $primary_meta_key = null; + $primary_meta_query = reset( $meta_clauses ); + if ( ! empty( $primary_meta_query['key'] ) ) { + $primary_meta_key = $primary_meta_query['key']; + $allowed_keys[] = $primary_meta_key; + } + $allowed_keys[] = 'meta_value'; + $allowed_keys[] = 'meta_value_num'; + $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_clauses ) ); + + if ( ! in_array( $orderby_raw, $allowed_keys, true ) ) { + return $orderby; + } + + switch( $orderby_raw ) { + case $primary_meta_key: + case 'meta_value': + if ( ! empty( $primary_meta_query['type'] ) ) { + $orderby = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})"; + } else { + $orderby = "{$primary_meta_query['alias']}.meta_value"; + } + break; + + case 'meta_value_num': + $orderby = "{$primary_meta_query['alias']}.meta_value+0"; + break; + + default: + if ( array_key_exists( $orderby_raw, $meta_clauses ) ) { + // $orderby corresponds to a meta_query clause. + $meta_clause = $meta_clauses[ $orderby_raw ]; + $orderby = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; + } + break; + } + + return $orderby; + } + + /** + * Parse an 'order' query variable and cast it to ASC or DESC as necessary. + * + * @since 4.6.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'DESC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } + + /** + * Used internally to generate a SQL string related to the 'search' parameter. + * + * @since 4.6.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $string + * @return string + */ + protected function get_search_sql( $string ) { + global $wpdb; + + $like = '%' . $wpdb->esc_like( $string ) . '%'; + + return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like ); + } +} diff --git a/backend/wp-includes/class-wp-term.php b/backend/wp-includes/class-wp-term.php new file mode 100644 index 0000000..a036871 --- /dev/null +++ b/backend/wp-includes/class-wp-term.php @@ -0,0 +1,245 @@ +<?php +/** + * Taxonomy API: WP_Term class + * + * @package WordPress + * @subpackage Taxonomy + * @since 4.4.0 + */ + +/** + * Core class used to implement the WP_Term object. + * + * @since 4.4.0 + * + * @property-read object $data Sanitized term data. + */ +final class WP_Term { + + /** + * Term ID. + * + * @since 4.4.0 + * @var int + */ + public $term_id; + + /** + * The term's name. + * + * @since 4.4.0 + * @var string + */ + public $name = ''; + + /** + * The term's slug. + * + * @since 4.4.0 + * @var string + */ + public $slug = ''; + + /** + * The term's term_group. + * + * @since 4.4.0 + * @var string + */ + public $term_group = ''; + + /** + * Term Taxonomy ID. + * + * @since 4.4.0 + * @var int + */ + public $term_taxonomy_id = 0; + + /** + * The term's taxonomy name. + * + * @since 4.4.0 + * @var string + */ + public $taxonomy = ''; + + /** + * The term's description. + * + * @since 4.4.0 + * @var string + */ + public $description = ''; + + /** + * ID of a term's parent term. + * + * @since 4.4.0 + * @var int + */ + public $parent = 0; + + /** + * Cached object count for this term. + * + * @since 4.4.0 + * @var int + */ + public $count = 0; + + /** + * Stores the term object's sanitization level. + * + * Does not correspond to a database field. + * + * @since 4.4.0 + * @var string + */ + public $filter = 'raw'; + + /** + * Retrieve WP_Term instance. + * + * @since 4.4.0 + * @static + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $term_id Term ID. + * @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for + * disambiguating potentially shared terms. + * @return WP_Term|WP_Error|false Term object, if found. WP_Error if `$term_id` is shared between taxonomies and + * there's insufficient data to distinguish which term is intended. + * False for other failures. + */ + public static function get_instance( $term_id, $taxonomy = null ) { + global $wpdb; + + $term_id = (int) $term_id; + if ( ! $term_id ) { + return false; + } + + $_term = wp_cache_get( $term_id, 'terms' ); + + // If there isn't a cached version, hit the database. + if ( ! $_term || ( $taxonomy && $taxonomy !== $_term->taxonomy ) ) { + // Any term found in the cache is not a match, so don't use it. + $_term = false; + + // Grab all matching terms, in case any are shared between taxonomies. + $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $term_id ) ); + if ( ! $terms ) { + return false; + } + + // If a taxonomy was specified, find a match. + if ( $taxonomy ) { + foreach ( $terms as $match ) { + if ( $taxonomy === $match->taxonomy ) { + $_term = $match; + break; + } + } + + // If only one match was found, it's the one we want. + } elseif ( 1 === count( $terms ) ) { + $_term = reset( $terms ); + + // Otherwise, the term must be shared between taxonomies. + } else { + // If the term is shared only with invalid taxonomies, return the one valid term. + foreach ( $terms as $t ) { + if ( ! taxonomy_exists( $t->taxonomy ) ) { + continue; + } + + // Only hit if we've already identified a term in a valid taxonomy. + if ( $_term ) { + return new WP_Error( 'ambiguous_term_id', __( 'Term ID is shared between multiple taxonomies' ), $term_id ); + } + + $_term = $t; + } + } + + if ( ! $_term ) { + return false; + } + + // Don't return terms from invalid taxonomies. + if ( ! taxonomy_exists( $_term->taxonomy ) ) { + return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); + } + + $_term = sanitize_term( $_term, $_term->taxonomy, 'raw' ); + + // Don't cache terms that are shared between taxonomies. + if ( 1 === count( $terms ) ) { + wp_cache_add( $term_id, $_term, 'terms' ); + } + } + + $term_obj = new WP_Term( $_term ); + $term_obj->filter( $term_obj->filter ); + + return $term_obj; + } + + /** + * Constructor. + * + * @since 4.4.0 + * + * @param WP_Term|object $term Term object. + */ + public function __construct( $term ) { + foreach ( get_object_vars( $term ) as $key => $value ) { + $this->$key = $value; + } + } + + /** + * Sanitizes term fields, according to the filter type provided. + * + * @since 4.4.0 + * + * @param string $filter Filter context. Accepts 'edit', 'db', 'display', 'attribute', 'js', 'raw'. + */ + public function filter( $filter ) { + sanitize_term( $this, $this->taxonomy, $filter ); + } + + /** + * Converts an object to array. + * + * @since 4.4.0 + * + * @return array Object as array. + */ + public function to_array() { + return get_object_vars( $this ); + } + + /** + * Getter. + * + * @since 4.4.0 + * + * @param string $key Property to get. + * @return mixed Property value. + */ + public function __get( $key ) { + switch ( $key ) { + case 'data' : + $data = new stdClass(); + $columns = array( 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count' ); + foreach ( $columns as $column ) { + $data->{$column} = isset( $this->{$column} ) ? $this->{$column} : null; + } + + return sanitize_term( $data, $data->taxonomy, 'raw' ); + } + } +} diff --git a/backend/wp-includes/class-wp-text-diff-renderer-inline.php b/backend/wp-includes/class-wp-text-diff-renderer-inline.php new file mode 100644 index 0000000..236e388 --- /dev/null +++ b/backend/wp-includes/class-wp-text-diff-renderer-inline.php @@ -0,0 +1,33 @@ +<?php +/** + * Diff API: WP_Text_Diff_Renderer_inline class + * + * @package WordPress + * @subpackage Diff + * @since 4.7.0 + */ + +/** + * Better word splitting than the PEAR package provides. + * + * @since 2.6.0 + * @uses Text_Diff_Renderer_inline Extends + */ +class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline { + + /** + * @ignore + * @since 2.6.0 + * + * @param string $string + * @param string $newlineEscape + * @return string + */ + public function _splitOnWords($string, $newlineEscape = "\n") { + $string = str_replace("\0", '', $string); + $words = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE ); + $words = str_replace( "\n", $newlineEscape, $words ); + return $words; + } + +} diff --git a/backend/wp-includes/class-wp-text-diff-renderer-table.php b/backend/wp-includes/class-wp-text-diff-renderer-table.php new file mode 100644 index 0000000..25ce839 --- /dev/null +++ b/backend/wp-includes/class-wp-text-diff-renderer-table.php @@ -0,0 +1,510 @@ +<?php +/** + * Diff API: WP_Text_Diff_Renderer_Table class + * + * @package WordPress + * @subpackage Diff + * @since 4.7.0 + */ + +/** + * Table renderer to display the diff lines. + * + * @since 2.6.0 + * @uses Text_Diff_Renderer Extends + */ +class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { + + /** + * @see Text_Diff_Renderer::_leading_context_lines + * @var int + * @since 2.6.0 + */ + public $_leading_context_lines = 10000; + + /** + * @see Text_Diff_Renderer::_trailing_context_lines + * @var int + * @since 2.6.0 + */ + public $_trailing_context_lines = 10000; + + /** + * Threshold for when a diff should be saved or omitted. + * + * @var float + * @since 2.6.0 + */ + protected $_diff_threshold = 0.6; + + /** + * Inline display helper object name. + * + * @var string + * @since 2.6.0 + */ + protected $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline'; + + /** + * Should we show the split view or not + * + * @var string + * @since 3.6.0 + */ + protected $_show_split_view = true; + + protected $compat_fields = array( '_show_split_view', 'inline_diff_renderer', '_diff_threshold' ); + + /** + * Constructor - Call parent constructor with params array. + * + * This will set class properties based on the key value pairs in the array. + * + * @since 2.6.0 + * + * @param array $params + */ + public function __construct( $params = array() ) { + parent::__construct( $params ); + if ( isset( $params[ 'show_split_view' ] ) ) + $this->_show_split_view = $params[ 'show_split_view' ]; + } + + /** + * @ignore + * + * @param string $header + * @return string + */ + public function _startBlock( $header ) { + return ''; + } + + /** + * @ignore + * + * @param array $lines + * @param string $prefix + */ + public function _lines( $lines, $prefix=' ' ) { + } + + /** + * @ignore + * + * @param string $line HTML-escape the value. + * @return string + */ + public function addedLine( $line ) { + return "<td class='diff-addedline'>{$line}</td>"; + + } + + /** + * @ignore + * + * @param string $line HTML-escape the value. + * @return string + */ + public function deletedLine( $line ) { + return "<td class='diff-deletedline'>{$line}</td>"; + } + + /** + * @ignore + * + * @param string $line HTML-escape the value. + * @return string + */ + public function contextLine( $line ) { + return "<td class='diff-context'>{$line}</td>"; + } + + /** + * @ignore + * + * @return string + */ + public function emptyLine() { + return '<td> </td>'; + } + + /** + * @ignore + * + * @param array $lines + * @param bool $encode + * @return string + */ + public function _added( $lines, $encode = true ) { + $r = ''; + foreach ($lines as $line) { + if ( $encode ) { + $processed_line = htmlspecialchars( $line ); + + /** + * Contextually filters a diffed line. + * + * Filters TextDiff processing of diffed line. By default, diffs are processed with + * htmlspecialchars. Use this filter to remove or change the processing. Passes a context + * indicating if the line is added, deleted or unchanged. + * + * @since 4.1.0 + * + * @param String $processed_line The processed diffed line. + * @param String $line The unprocessed diffed line. + * @param string null The line context. Values are 'added', 'deleted' or 'unchanged'. + */ + $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); + } + + if ( $this->_show_split_view ) { + $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; + } else { + $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; + } + } + return $r; + } + + /** + * @ignore + * + * @param array $lines + * @param bool $encode + * @return string + */ + public function _deleted( $lines, $encode = true ) { + $r = ''; + foreach ($lines as $line) { + if ( $encode ) { + $processed_line = htmlspecialchars( $line ); + + /** This filter is documented in wp-includes/wp-diff.php */ + $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); + } + if ( $this->_show_split_view ) { + $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n"; + } else { + $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; + } + + } + return $r; + } + + /** + * @ignore + * + * @param array $lines + * @param bool $encode + * @return string + */ + public function _context( $lines, $encode = true ) { + $r = ''; + foreach ($lines as $line) { + if ( $encode ) { + $processed_line = htmlspecialchars( $line ); + + /** This filter is documented in wp-includes/wp-diff.php */ + $line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); + } + if ( $this->_show_split_view ) { + $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "</tr>\n"; + } else { + $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; + } + } + return $r; + } + + /** + * Process changed lines to do word-by-word diffs for extra highlighting. + * + * (TRAC style) sometimes these lines can actually be deleted or added rows. + * We do additional processing to figure that out + * + * @since 2.6.0 + * + * @param array $orig + * @param array $final + * @return string + */ + public function _changed( $orig, $final ) { + $r = ''; + + // Does the aforementioned additional processing + // *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes + // match is numeric: an index in other column + // match is 'X': no match. It is a new row + // *_rows are column vectors for the orig column and the final column. + // row >= 0: an indix of the $orig or $final array + // row < 0: a blank row for that column + list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final ); + + // These will hold the word changes as determined by an inline diff + $orig_diffs = array(); + $final_diffs = array(); + + // Compute word diffs for each matched pair using the inline diff + foreach ( $orig_matches as $o => $f ) { + if ( is_numeric($o) && is_numeric($f) ) { + $text_diff = new Text_Diff( 'auto', array( array($orig[$o]), array($final[$f]) ) ); + $renderer = new $this->inline_diff_renderer; + $diff = $renderer->render( $text_diff ); + + // If they're too different, don't include any <ins> or <dels> + if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) { + // length of all text between <ins> or <del> + $stripped_matches = strlen(strip_tags( join(' ', $diff_matches[0]) )); + // since we count lengith of text between <ins> or <del> (instead of picking just one), + // we double the length of chars not in those tags. + $stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches; + $diff_ratio = $stripped_matches / $stripped_diff; + if ( $diff_ratio > $this->_diff_threshold ) + continue; // Too different. Don't save diffs. + } + + // Un-inline the diffs by removing del or ins + $orig_diffs[$o] = preg_replace( '|<ins>.*?</ins>|', '', $diff ); + $final_diffs[$f] = preg_replace( '|<del>.*?</del>|', '', $diff ); + } + } + + foreach ( array_keys($orig_rows) as $row ) { + // Both columns have blanks. Ignore them. + if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 ) + continue; + + // If we have a word based diff, use it. Otherwise, use the normal line. + if ( isset( $orig_diffs[$orig_rows[$row]] ) ) + $orig_line = $orig_diffs[$orig_rows[$row]]; + elseif ( isset( $orig[$orig_rows[$row]] ) ) + $orig_line = htmlspecialchars($orig[$orig_rows[$row]]); + else + $orig_line = ''; + + if ( isset( $final_diffs[$final_rows[$row]] ) ) + $final_line = $final_diffs[$final_rows[$row]]; + elseif ( isset( $final[$final_rows[$row]] ) ) + $final_line = htmlspecialchars($final[$final_rows[$row]]); + else + $final_line = ''; + + if ( $orig_rows[$row] < 0 ) { // Orig is blank. This is really an added row. + $r .= $this->_added( array($final_line), false ); + } elseif ( $final_rows[$row] < 0 ) { // Final is blank. This is really a deleted row. + $r .= $this->_deleted( array($orig_line), false ); + } else { // A true changed row. + if ( $this->_show_split_view ) { + $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n"; + } else { + $r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n"; + } + } + } + + return $r; + } + + /** + * Takes changed blocks and matches which rows in orig turned into which rows in final. + * + * @since 2.6.0 + * + * @param array $orig Lines of the original version of the text. + * @param array $final Lines of the final version of the text. + * @return array { + * Array containing results of comparing the original text to the final text. + * + * @type array $orig_matches Associative array of original matches. Index == row + * number of `$orig`, value == corresponding row number + * of that same line in `$final` or 'x' if there is no + * corresponding row (indicating it is a deleted line). + * @type array $final_matches Associative array of final matches. Index == row + * number of `$final`, value == corresponding row number + * of that same line in `$orig` or 'x' if there is no + * corresponding row (indicating it is a new line). + * @type array $orig_rows Associative array of interleaved rows of `$orig` with + * blanks to keep matches aligned with side-by-side diff + * of `$final`. A value >= 0 corresponds to index of `$orig`. + * Value < 0 indicates a blank row. + * @type array $final_rows Associative array of interleaved rows of `$final` with + * blanks to keep matches aligned with side-by-side diff + * of `$orig`. A value >= 0 corresponds to index of `$final`. + * Value < 0 indicates a blank row. + * } + */ + public function interleave_changed_lines( $orig, $final ) { + + // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array. + $matches = array(); + foreach ( array_keys($orig) as $o ) { + foreach ( array_keys($final) as $f ) { + $matches["$o,$f"] = $this->compute_string_distance( $orig[$o], $final[$f] ); + } + } + asort($matches); // Order by string distance. + + $orig_matches = array(); + $final_matches = array(); + + foreach ( $matches as $keys => $difference ) { + list($o, $f) = explode(',', $keys); + $o = (int) $o; + $f = (int) $f; + + // Already have better matches for these guys + if ( isset($orig_matches[$o]) && isset($final_matches[$f]) ) + continue; + + // First match for these guys. Must be best match + if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) { + $orig_matches[$o] = $f; + $final_matches[$f] = $o; + continue; + } + + // Best match of this final is already taken? Must mean this final is a new row. + if ( isset($orig_matches[$o]) ) + $final_matches[$f] = 'x'; + + // Best match of this orig is already taken? Must mean this orig is a deleted row. + elseif ( isset($final_matches[$f]) ) + $orig_matches[$o] = 'x'; + } + + // We read the text in this order + ksort($orig_matches); + ksort($final_matches); + + // Stores rows and blanks for each column. + $orig_rows = $orig_rows_copy = array_keys($orig_matches); + $final_rows = array_keys($final_matches); + + // Interleaves rows with blanks to keep matches aligned. + // We may end up with some extraneous blank rows, but we'll just ignore them later. + foreach ( $orig_rows_copy as $orig_row ) { + $final_pos = array_search($orig_matches[$orig_row], $final_rows, true); + $orig_pos = (int) array_search($orig_row, $orig_rows, true); + + if ( false === $final_pos ) { // This orig is paired with a blank final. + array_splice( $final_rows, $orig_pos, 0, -1 ); + } elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways. Pad final with blank rows. + $diff_pos = $final_pos - $orig_pos; + while ( $diff_pos < 0 ) + array_splice( $final_rows, $orig_pos, 0, $diff_pos++ ); + } elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways. Pad orig with blank rows. + $diff_pos = $orig_pos - $final_pos; + while ( $diff_pos < 0 ) + array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ ); + } + } + + // Pad the ends with blank rows if the columns aren't the same length + $diff_count = count($orig_rows) - count($final_rows); + if ( $diff_count < 0 ) { + while ( $diff_count < 0 ) + array_push($orig_rows, $diff_count++); + } elseif ( $diff_count > 0 ) { + $diff_count = -1 * $diff_count; + while ( $diff_count < 0 ) + array_push($final_rows, $diff_count++); + } + + return array($orig_matches, $final_matches, $orig_rows, $final_rows); + } + + /** + * Computes a number that is intended to reflect the "distance" between two strings. + * + * @since 2.6.0 + * + * @param string $string1 + * @param string $string2 + * @return int + */ + public function compute_string_distance( $string1, $string2 ) { + // Vectors containing character frequency for all chars in each string + $chars1 = count_chars($string1); + $chars2 = count_chars($string2); + + // L1-norm of difference vector. + $difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) ); + + // $string1 has zero length? Odd. Give huge penalty by not dividing. + if ( !$string1 ) + return $difference; + + // Return distance per character (of string1). + return $difference / strlen($string1); + } + + /** + * @ignore + * @since 2.6.0 + * + * @param int $a + * @param int $b + * @return int + */ + public function difference( $a, $b ) { + return abs( $a - $b ); + } + + /** + * Make private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name; + } + } + + /** + * Make private properties settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set( $name, $value ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name = $value; + } + } + + /** + * Make private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } + } + + /** + * Make private properties un-settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to unset. + */ + public function __unset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + unset( $this->$name ); + } + } +} diff --git a/backend/wp-includes/class-wp-theme.php b/backend/wp-includes/class-wp-theme.php new file mode 100644 index 0000000..b53bdcc --- /dev/null +++ b/backend/wp-includes/class-wp-theme.php @@ -0,0 +1,1489 @@ +<?php +/** + * WP_Theme Class + * + * @package WordPress + * @subpackage Theme + * @since 3.4.0 + */ +final class WP_Theme implements ArrayAccess { + + /** + * Whether the theme has been marked as updateable. + * + * @since 4.4.0 + * @var bool + * + * @see WP_MS_Themes_List_Table + */ + public $update = false; + + /** + * Headers for style.css files. + * + * @static + * @var array + */ + private static $file_headers = array( + 'Name' => 'Theme Name', + 'ThemeURI' => 'Theme URI', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'Version' => 'Version', + 'Template' => 'Template', + 'Status' => 'Status', + 'Tags' => 'Tags', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + ); + + /** + * Default themes. + * + * @static + * @var array + */ + private static $default_themes = array( + 'classic' => 'WordPress Classic', + 'default' => 'WordPress Default', + 'twentyten' => 'Twenty Ten', + 'twentyeleven' => 'Twenty Eleven', + 'twentytwelve' => 'Twenty Twelve', + 'twentythirteen' => 'Twenty Thirteen', + 'twentyfourteen' => 'Twenty Fourteen', + 'twentyfifteen' => 'Twenty Fifteen', + 'twentysixteen' => 'Twenty Sixteen', + 'twentyseventeen' => 'Twenty Seventeen', + ); + + /** + * Renamed theme tags. + * + * @static + * @var array + */ + private static $tag_map = array( + 'fixed-width' => 'fixed-layout', + 'flexible-width' => 'fluid-layout', + ); + + /** + * Absolute path to the theme root, usually wp-content/themes + * + * @var string + */ + private $theme_root; + + /** + * Header data from the theme's style.css file. + * + * @var array + */ + private $headers = array(); + + /** + * Header data from the theme's style.css file after being sanitized. + * + * @var array + */ + private $headers_sanitized; + + /** + * Header name from the theme's style.css after being translated. + * + * Cached due to sorting functions running over the translated name. + * + * @var string + */ + private $name_translated; + + /** + * Errors encountered when initializing the theme. + * + * @var WP_Error + */ + private $errors; + + /** + * The directory name of the theme's files, inside the theme root. + * + * In the case of a child theme, this is directory name of the child theme. + * Otherwise, 'stylesheet' is the same as 'template'. + * + * @var string + */ + private $stylesheet; + + /** + * The directory name of the theme's files, inside the theme root. + * + * In the case of a child theme, this is the directory name of the parent theme. + * Otherwise, 'template' is the same as 'stylesheet'. + * + * @var string + */ + private $template; + + /** + * A reference to the parent theme, in the case of a child theme. + * + * @var WP_Theme + */ + private $parent; + + /** + * URL to the theme root, usually an absolute URL to wp-content/themes + * + * @var string + */ + private $theme_root_uri; + + /** + * Flag for whether the theme's textdomain is loaded. + * + * @var bool + */ + private $textdomain_loaded; + + /** + * Stores an md5 hash of the theme root, to function as the cache key. + * + * @var string + */ + private $cache_hash; + + /** + * Flag for whether the themes cache bucket should be persistently cached. + * + * Default is false. Can be set with the {@see 'wp_cache_themes_persistently'} filter. + * + * @static + * @var bool + */ + private static $persistently_cache; + + /** + * Expiration time for the themes cache bucket. + * + * By default the bucket is not cached, so this value is useless. + * + * @static + * @var bool + */ + private static $cache_expiration = 1800; + + /** + * Constructor for WP_Theme. + * + * @since 3.4.0 + * + * @global array $wp_theme_directories + * + * @param string $theme_dir Directory of the theme within the theme_root. + * @param string $theme_root Theme root. + * @param WP_Error|void $_child If this theme is a parent theme, the child may be passed for validation purposes. + */ + public function __construct( $theme_dir, $theme_root, $_child = null ) { + global $wp_theme_directories; + + // Initialize caching on first run. + if ( ! isset( self::$persistently_cache ) ) { + /** This action is documented in wp-includes/theme.php */ + self::$persistently_cache = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' ); + if ( self::$persistently_cache ) { + wp_cache_add_global_groups( 'themes' ); + if ( is_int( self::$persistently_cache ) ) + self::$cache_expiration = self::$persistently_cache; + } else { + wp_cache_add_non_persistent_groups( 'themes' ); + } + } + + $this->theme_root = $theme_root; + $this->stylesheet = $theme_dir; + + // Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead. + if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) { + $this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet; + $this->theme_root = dirname( $theme_root ); + } + + $this->cache_hash = md5( $this->theme_root . '/' . $this->stylesheet ); + $theme_file = $this->stylesheet . '/style.css'; + + $cache = $this->cache_get( 'theme' ); + + if ( is_array( $cache ) ) { + foreach ( array( 'errors', 'headers', 'template' ) as $key ) { + if ( isset( $cache[ $key ] ) ) + $this->$key = $cache[ $key ]; + } + if ( $this->errors ) + return; + if ( isset( $cache['theme_root_template'] ) ) + $theme_root_template = $cache['theme_root_template']; + } elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) { + $this->headers['Name'] = $this->stylesheet; + if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) + $this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), esc_html( $this->stylesheet ) ) ); + else + $this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) ); + $this->template = $this->stylesheet; + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); + if ( ! file_exists( $this->theme_root ) ) // Don't cache this one. + $this->errors->add( 'theme_root_missing', __( 'ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.' ) ); + return; + } elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) { + $this->headers['Name'] = $this->stylesheet; + $this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) ); + $this->template = $this->stylesheet; + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); + return; + } else { + $this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' ); + // Default themes always trump their pretenders. + // Properly identify default themes that are inside a directory within wp-content/themes. + if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) { + if ( basename( $this->stylesheet ) != $default_theme_slug ) + $this->headers['Name'] .= '/' . $this->stylesheet; + } + } + + if ( ! $this->template && $this->stylesheet === $this->headers['Template'] ) { + /* translators: %s: Template */ + $this->errors = new WP_Error( 'theme_child_invalid', sprintf( __( 'The theme defines itself as its parent theme. Please check the %s header.' ), '<code>Template</code>' ) ); + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) ); + + return; + } + + // (If template is set from cache [and there are no errors], we know it's good.) + if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) { + $this->template = $this->stylesheet; + if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) { + $error_message = sprintf( + /* translators: 1: index.php, 2: Codex URL, 3: style.css */ + __( 'Template is missing. Standalone themes need to have a %1$s template file. <a href="%2$s">Child themes</a> need to have a Template header in the %3$s stylesheet.' ), + '<code>index.php</code>', + __( 'https://codex.wordpress.org/Child_Themes' ), + '<code>style.css</code>' + ); + $this->errors = new WP_Error( 'theme_no_index', $error_message ); + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); + return; + } + } + + // If we got our data from cache, we can assume that 'template' is pointing to the right place. + if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) { + // If we're in a directory of themes inside /themes, look for the parent nearby. + // wp-content/themes/directory-of-themes/* + $parent_dir = dirname( $this->stylesheet ); + if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) { + $this->template = $parent_dir . '/' . $this->template; + } elseif ( ( $directories = search_theme_directories() ) && isset( $directories[ $this->template ] ) ) { + // Look for the template in the search_theme_directories() results, in case it is in another theme root. + // We don't look into directories of themes, just the theme root. + $theme_root_template = $directories[ $this->template ]['theme_root']; + } else { + // Parent theme is missing. + $this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), esc_html( $this->template ) ) ); + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); + $this->parent = new WP_Theme( $this->template, $this->theme_root, $this ); + return; + } + } + + // Set the parent, if we're a child theme. + if ( $this->template != $this->stylesheet ) { + // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out. + if ( $_child instanceof WP_Theme && $_child->template == $this->stylesheet ) { + $_child->parent = null; + $_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $_child->template ) ) ); + $_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) ); + // The two themes actually reference each other with the Template header. + if ( $_child->stylesheet == $this->template ) { + $this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), esc_html( $this->template ) ) ); + $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); + } + return; + } + // Set the parent. Pass the current instance so we can do the crazy checks above and assess errors. + $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this ); + } + + // We're good. If we didn't retrieve from cache, set it. + if ( ! is_array( $cache ) ) { + $cache = array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ); + // If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above. + if ( isset( $theme_root_template ) ) + $cache['theme_root_template'] = $theme_root_template; + $this->cache_add( 'theme', $cache ); + } + } + + /** + * When converting the object to a string, the theme name is returned. + * + * @since 3.4.0 + * + * @return string Theme name, ready for display (translated) + */ + public function __toString() { + return (string) $this->display('Name'); + } + + /** + * __isset() magic method for properties formerly returned by current_theme_info() + * + * @staticvar array $properties + * + * @since 3.4.0 + * + * @param string $offset Property to check if set. + * @return bool Whether the given property is set. + */ + public function __isset( $offset ) { + static $properties = array( + 'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet', + 'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri', + ); + + return in_array( $offset, $properties ); + } + + /** + * __get() magic method for properties formerly returned by current_theme_info() + * + * @since 3.4.0 + * + * @param string $offset Property to get. + * @return mixed Property value. + */ + public function __get( $offset ) { + switch ( $offset ) { + case 'name' : + case 'title' : + return $this->get('Name'); + case 'version' : + return $this->get('Version'); + case 'parent_theme' : + return $this->parent() ? $this->parent()->get('Name') : ''; + case 'template_dir' : + return $this->get_template_directory(); + case 'stylesheet_dir' : + return $this->get_stylesheet_directory(); + case 'template' : + return $this->get_template(); + case 'stylesheet' : + return $this->get_stylesheet(); + case 'screenshot' : + return $this->get_screenshot( 'relative' ); + // 'author' and 'description' did not previously return translated data. + case 'description' : + return $this->display('Description'); + case 'author' : + return $this->display('Author'); + case 'tags' : + return $this->get( 'Tags' ); + case 'theme_root' : + return $this->get_theme_root(); + case 'theme_root_uri' : + return $this->get_theme_root_uri(); + // For cases where the array was converted to an object. + default : + return $this->offsetGet( $offset ); + } + } + + /** + * Method to implement ArrayAccess for keys formerly returned by get_themes() + * + * @since 3.4.0 + * + * @param mixed $offset + * @param mixed $value + */ + public function offsetSet( $offset, $value ) {} + + /** + * Method to implement ArrayAccess for keys formerly returned by get_themes() + * + * @since 3.4.0 + * + * @param mixed $offset + */ + public function offsetUnset( $offset ) {} + + /** + * Method to implement ArrayAccess for keys formerly returned by get_themes() + * + * @staticvar array $keys + * + * @since 3.4.0 + * + * @param mixed $offset + * @return bool + */ + public function offsetExists( $offset ) { + static $keys = array( + 'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description', + 'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir', + 'Screenshot', 'Tags', 'Theme Root', 'Theme Root URI', 'Parent Theme', + ); + + return in_array( $offset, $keys ); + } + + /** + * Method to implement ArrayAccess for keys formerly returned by get_themes(). + * + * Author, Author Name, Author URI, and Description did not previously return + * translated data. We are doing so now as it is safe to do. However, as + * Name and Title could have been used as the key for get_themes(), both remain + * untranslated for back compatibility. This means that ['Name'] is not ideal, + * and care should be taken to use `$theme::display( 'Name' )` to get a properly + * translated header. + * + * @since 3.4.0 + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet( $offset ) { + switch ( $offset ) { + case 'Name' : + case 'Title' : + /* + * See note above about using translated data. get() is not ideal. + * It is only for backward compatibility. Use display(). + */ + return $this->get('Name'); + case 'Author' : + return $this->display( 'Author'); + case 'Author Name' : + return $this->display( 'Author', false); + case 'Author URI' : + return $this->display('AuthorURI'); + case 'Description' : + return $this->display( 'Description'); + case 'Version' : + case 'Status' : + return $this->get( $offset ); + case 'Template' : + return $this->get_template(); + case 'Stylesheet' : + return $this->get_stylesheet(); + case 'Template Files' : + return $this->get_files( 'php', 1, true ); + case 'Stylesheet Files' : + return $this->get_files( 'css', 0, false ); + case 'Template Dir' : + return $this->get_template_directory(); + case 'Stylesheet Dir' : + return $this->get_stylesheet_directory(); + case 'Screenshot' : + return $this->get_screenshot( 'relative' ); + case 'Tags' : + return $this->get('Tags'); + case 'Theme Root' : + return $this->get_theme_root(); + case 'Theme Root URI' : + return $this->get_theme_root_uri(); + case 'Parent Theme' : + return $this->parent() ? $this->parent()->get('Name') : ''; + default : + return null; + } + } + + /** + * Returns errors property. + * + * @since 3.4.0 + * + * @return WP_Error|false WP_Error if there are errors, or false. + */ + public function errors() { + return is_wp_error( $this->errors ) ? $this->errors : false; + } + + /** + * Whether the theme exists. + * + * A theme with errors exists. A theme with the error of 'theme_not_found', + * meaning that the theme's directory was not found, does not exist. + * + * @since 3.4.0 + * + * @return bool Whether the theme exists. + */ + public function exists() { + return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) ); + } + + /** + * Returns reference to the parent theme. + * + * @since 3.4.0 + * + * @return WP_Theme|false Parent theme, or false if the current theme is not a child theme. + */ + public function parent() { + return isset( $this->parent ) ? $this->parent : false; + } + + /** + * Adds theme data to cache. + * + * Cache entries keyed by the theme and the type of data. + * + * @since 3.4.0 + * + * @param string $key Type of data to store (theme, screenshot, headers, post_templates) + * @param string $data Data to store + * @return bool Return value from wp_cache_add() + */ + private function cache_add( $key, $data ) { + return wp_cache_add( $key . '-' . $this->cache_hash, $data, 'themes', self::$cache_expiration ); + } + + /** + * Gets theme data from cache. + * + * Cache entries are keyed by the theme and the type of data. + * + * @since 3.4.0 + * + * @param string $key Type of data to retrieve (theme, screenshot, headers, post_templates) + * @return mixed Retrieved data + */ + private function cache_get( $key ) { + return wp_cache_get( $key . '-' . $this->cache_hash, 'themes' ); + } + + /** + * Clears the cache for the theme. + * + * @since 3.4.0 + */ + public function cache_delete() { + foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) + wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); + $this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null; + $this->headers = array(); + $this->__construct( $this->stylesheet, $this->theme_root ); + } + + /** + * Get a raw, unformatted theme header. + * + * The header is sanitized, but is not translated, and is not marked up for display. + * To get a theme header for display, use the display() method. + * + * Use the get_template() method, not the 'Template' header, for finding the template. + * The 'Template' header is only good for what was written in the style.css, while + * get_template() takes into account where WordPress actually located the theme and + * whether it is actually valid. + * + * @since 3.4.0 + * + * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. + * @return string|false String on success, false on failure. + */ + public function get( $header ) { + if ( ! isset( $this->headers[ $header ] ) ) + return false; + + if ( ! isset( $this->headers_sanitized ) ) { + $this->headers_sanitized = $this->cache_get( 'headers' ); + if ( ! is_array( $this->headers_sanitized ) ) + $this->headers_sanitized = array(); + } + + if ( isset( $this->headers_sanitized[ $header ] ) ) + return $this->headers_sanitized[ $header ]; + + // If themes are a persistent group, sanitize everything and cache it. One cache add is better than many cache sets. + if ( self::$persistently_cache ) { + foreach ( array_keys( $this->headers ) as $_header ) + $this->headers_sanitized[ $_header ] = $this->sanitize_header( $_header, $this->headers[ $_header ] ); + $this->cache_add( 'headers', $this->headers_sanitized ); + } else { + $this->headers_sanitized[ $header ] = $this->sanitize_header( $header, $this->headers[ $header ] ); + } + + return $this->headers_sanitized[ $header ]; + } + + /** + * Gets a theme header, formatted and translated for display. + * + * @since 3.4.0 + * + * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. + * @param bool $markup Optional. Whether to mark up the header. Defaults to true. + * @param bool $translate Optional. Whether to translate the header. Defaults to true. + * @return string|false Processed header, false on failure. + */ + public function display( $header, $markup = true, $translate = true ) { + $value = $this->get( $header ); + if ( false === $value ) { + return false; + } + + if ( $translate && ( empty( $value ) || ! $this->load_textdomain() ) ) + $translate = false; + + if ( $translate ) + $value = $this->translate_header( $header, $value ); + + if ( $markup ) + $value = $this->markup_header( $header, $value, $translate ); + + return $value; + } + + /** + * Sanitize a theme header. + * + * @since 3.4.0 + * + * @staticvar array $header_tags + * @staticvar array $header_tags_with_a + * + * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. + * @param string $value Value to sanitize. + * @return mixed + */ + private function sanitize_header( $header, $value ) { + switch ( $header ) { + case 'Status' : + if ( ! $value ) { + $value = 'publish'; + break; + } + // Fall through otherwise. + case 'Name' : + static $header_tags = array( + 'abbr' => array( 'title' => true ), + 'acronym' => array( 'title' => true ), + 'code' => true, + 'em' => true, + 'strong' => true, + ); + $value = wp_kses( $value, $header_tags ); + break; + case 'Author' : + // There shouldn't be anchor tags in Author, but some themes like to be challenging. + case 'Description' : + static $header_tags_with_a = array( + 'a' => array( 'href' => true, 'title' => true ), + 'abbr' => array( 'title' => true ), + 'acronym' => array( 'title' => true ), + 'code' => true, + 'em' => true, + 'strong' => true, + ); + $value = wp_kses( $value, $header_tags_with_a ); + break; + case 'ThemeURI' : + case 'AuthorURI' : + $value = esc_url_raw( $value ); + break; + case 'Tags' : + $value = array_filter( array_map( 'trim', explode( ',', strip_tags( $value ) ) ) ); + break; + case 'Version' : + $value = strip_tags( $value ); + break; + } + + return $value; + } + + /** + * Mark up a theme header. + * + * @since 3.4.0 + * + * @staticvar string $comma + * + * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. + * @param string $value Value to mark up. + * @param string $translate Whether the header has been translated. + * @return string Value, marked up. + */ + private function markup_header( $header, $value, $translate ) { + switch ( $header ) { + case 'Name' : + if ( empty( $value ) ) { + $value = esc_html( $this->get_stylesheet() ); + } + break; + case 'Description' : + $value = wptexturize( $value ); + break; + case 'Author' : + if ( $this->get('AuthorURI') ) { + $value = sprintf( '<a href="%1$s">%2$s</a>', $this->display( 'AuthorURI', true, $translate ), $value ); + } elseif ( ! $value ) { + $value = __( 'Anonymous' ); + } + break; + case 'Tags' : + static $comma = null; + if ( ! isset( $comma ) ) { + /* translators: used between list items, there is a space after the comma */ + $comma = __( ', ' ); + } + $value = implode( $comma, $value ); + break; + case 'ThemeURI' : + case 'AuthorURI' : + $value = esc_url( $value ); + break; + } + + return $value; + } + + /** + * Translate a theme header. + * + * @since 3.4.0 + * + * @staticvar array $tags_list + * + * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. + * @param string $value Value to translate. + * @return string Translated value. + */ + private function translate_header( $header, $value ) { + switch ( $header ) { + case 'Name' : + // Cached for sorting reasons. + if ( isset( $this->name_translated ) ) + return $this->name_translated; + $this->name_translated = translate( $value, $this->get('TextDomain' ) ); + return $this->name_translated; + case 'Tags' : + if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) { + return $value; + } + + static $tags_list; + if ( ! isset( $tags_list ) ) { + $tags_list = array( + // As of 4.6, deprecated tags which are only used to provide translation for older themes. + 'black' => __( 'Black' ), 'blue' => __( 'Blue' ), 'brown' => __( 'Brown' ), + 'gray' => __( 'Gray' ), 'green' => __( 'Green' ), 'orange' => __( 'Orange' ), + 'pink' => __( 'Pink' ), 'purple' => __( 'Purple' ), 'red' => __( 'Red' ), + 'silver' => __( 'Silver' ), 'tan' => __( 'Tan' ), 'white' => __( 'White' ), + 'yellow' => __( 'Yellow' ), 'dark' => __( 'Dark' ), 'light' => __( 'Light' ), + 'fixed-layout' => __( 'Fixed Layout' ), 'fluid-layout' => __( 'Fluid Layout' ), + 'responsive-layout' => __( 'Responsive Layout' ), 'blavatar' => __( 'Blavatar' ), + 'photoblogging' => __( 'Photoblogging' ), 'seasonal' => __( 'Seasonal' ), + ); + + $feature_list = get_theme_feature_list( false ); // No API + foreach ( $feature_list as $tags ) { + $tags_list += $tags; + } + } + + foreach ( $value as &$tag ) { + if ( isset( $tags_list[ $tag ] ) ) { + $tag = $tags_list[ $tag ]; + } elseif ( isset( self::$tag_map[ $tag ] ) ) { + $tag = $tags_list[ self::$tag_map[ $tag ] ]; + } + } + + return $value; + + default : + $value = translate( $value, $this->get('TextDomain') ); + } + return $value; + } + + /** + * The directory name of the theme's "stylesheet" files, inside the theme root. + * + * In the case of a child theme, this is directory name of the child theme. + * Otherwise, get_stylesheet() is the same as get_template(). + * + * @since 3.4.0 + * + * @return string Stylesheet + */ + public function get_stylesheet() { + return $this->stylesheet; + } + + /** + * The directory name of the theme's "template" files, inside the theme root. + * + * In the case of a child theme, this is the directory name of the parent theme. + * Otherwise, the get_template() is the same as get_stylesheet(). + * + * @since 3.4.0 + * + * @return string Template + */ + public function get_template() { + return $this->template; + } + + /** + * Returns the absolute path to the directory of a theme's "stylesheet" files. + * + * In the case of a child theme, this is the absolute path to the directory + * of the child theme's files. + * + * @since 3.4.0 + * + * @return string Absolute path of the stylesheet directory. + */ + public function get_stylesheet_directory() { + if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) + return ''; + + return $this->theme_root . '/' . $this->stylesheet; + } + + /** + * Returns the absolute path to the directory of a theme's "template" files. + * + * In the case of a child theme, this is the absolute path to the directory + * of the parent theme's files. + * + * @since 3.4.0 + * + * @return string Absolute path of the template directory. + */ + public function get_template_directory() { + if ( $this->parent() ) + $theme_root = $this->parent()->theme_root; + else + $theme_root = $this->theme_root; + + return $theme_root . '/' . $this->template; + } + + /** + * Returns the URL to the directory of a theme's "stylesheet" files. + * + * In the case of a child theme, this is the URL to the directory of the + * child theme's files. + * + * @since 3.4.0 + * + * @return string URL to the stylesheet directory. + */ + public function get_stylesheet_directory_uri() { + return $this->get_theme_root_uri() . '/' . str_replace( '%2F', '/', rawurlencode( $this->stylesheet ) ); + } + + /** + * Returns the URL to the directory of a theme's "template" files. + * + * In the case of a child theme, this is the URL to the directory of the + * parent theme's files. + * + * @since 3.4.0 + * + * @return string URL to the template directory. + */ + public function get_template_directory_uri() { + if ( $this->parent() ) + $theme_root_uri = $this->parent()->get_theme_root_uri(); + else + $theme_root_uri = $this->get_theme_root_uri(); + + return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) ); + } + + /** + * The absolute path to the directory of the theme root. + * + * This is typically the absolute path to wp-content/themes. + * + * @since 3.4.0 + * + * @return string Theme root. + */ + public function get_theme_root() { + return $this->theme_root; + } + + /** + * Returns the URL to the directory of the theme root. + * + * This is typically the absolute URL to wp-content/themes. This forms the basis + * for all other URLs returned by WP_Theme, so we pass it to the public function + * get_theme_root_uri() and allow it to run the {@see 'theme_root_uri'} filter. + * + * @since 3.4.0 + * + * @return string Theme root URI. + */ + public function get_theme_root_uri() { + if ( ! isset( $this->theme_root_uri ) ) + $this->theme_root_uri = get_theme_root_uri( $this->stylesheet, $this->theme_root ); + return $this->theme_root_uri; + } + + /** + * Returns the main screenshot file for the theme. + * + * The main screenshot is called screenshot.png. gif and jpg extensions are also allowed. + * + * Screenshots for a theme must be in the stylesheet directory. (In the case of child + * themes, parent theme screenshots are not inherited.) + * + * @since 3.4.0 + * + * @param string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI. + * @return string|false Screenshot file. False if the theme does not have a screenshot. + */ + public function get_screenshot( $uri = 'uri' ) { + $screenshot = $this->cache_get( 'screenshot' ); + if ( $screenshot ) { + if ( 'relative' == $uri ) + return $screenshot; + return $this->get_stylesheet_directory_uri() . '/' . $screenshot; + } elseif ( 0 === $screenshot ) { + return false; + } + + foreach ( array( 'png', 'gif', 'jpg', 'jpeg' ) as $ext ) { + if ( file_exists( $this->get_stylesheet_directory() . "/screenshot.$ext" ) ) { + $this->cache_add( 'screenshot', 'screenshot.' . $ext ); + if ( 'relative' == $uri ) + return 'screenshot.' . $ext; + return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext; + } + } + + $this->cache_add( 'screenshot', 0 ); + return false; + } + + /** + * Return files in the theme's directory. + * + * @since 3.4.0 + * + * @param mixed $type Optional. Array of extensions to return. Defaults to all files (null). + * @param int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite. + * @param bool $search_parent Optional. Whether to return parent files. Defaults to false. + * @return array Array of files, keyed by the path to the file relative to the theme's directory, with the values + * being absolute paths. + */ + public function get_files( $type = null, $depth = 0, $search_parent = false ) { + $files = (array) self::scandir( $this->get_stylesheet_directory(), $type, $depth ); + + if ( $search_parent && $this->parent() ) { + $files += (array) self::scandir( $this->get_template_directory(), $type, $depth ); + } + + return $files; + } + + /** + * Returns the theme's post templates. + * + * @since 4.7.0 + * + * @return array Array of page templates, keyed by filename and post type, + * with the value of the translated header name. + */ + public function get_post_templates() { + // If you screw up your current theme and we invalidate your parent, most things still work. Let it slide. + if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) { + return array(); + } + + $post_templates = $this->cache_get( 'post_templates' ); + + if ( ! is_array( $post_templates ) ) { + $post_templates = array(); + + $files = (array) $this->get_files( 'php', 1, true); + + foreach ( $files as $file => $full_path ) { + if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) { + continue; + } + + $types = array( 'page' ); + if ( preg_match( '|Template Post Type:(.*)$|mi', file_get_contents( $full_path ), $type ) ) { + $types = explode( ',', _cleanup_header_comment( $type[1] ) ); + } + + foreach ( $types as $type ) { + $type = sanitize_key( $type ); + if ( ! isset( $post_templates[ $type ] ) ) { + $post_templates[ $type ] = array(); + } + + $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] ); + } + } + + $this->cache_add( 'post_templates', $post_templates ); + } + + if ( $this->load_textdomain() ) { + foreach ( $post_templates as &$post_type ) { + foreach ( $post_type as &$post_template ) { + $post_template = $this->translate_header( 'Template Name', $post_template ); + } + } + } + + return $post_templates; + } + + /** + * Returns the theme's post templates for a given post type. + * + * @since 3.4.0 + * @since 4.7.0 Added the `$post_type` parameter. + * + * @param WP_Post|null $post Optional. The post being edited, provided for context. + * @param string $post_type Optional. Post type to get the templates for. Default 'page'. + * If a post is provided, its post type is used. + * @return array Array of page templates, keyed by filename, with the value of the translated header name. + */ + public function get_page_templates( $post = null, $post_type = 'page' ) { + if ( $post ) { + $post_type = get_post_type( $post ); + } + + $post_templates = $this->get_post_templates(); + $post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array(); + + /** + * Filters list of page templates for a theme. + * + * @since 4.9.6 + * + * @param string[] $post_templates Array of page templates. Keys are filenames, + * values are translated names. + * @param WP_Theme $this The theme object. + * @param WP_Post|null $post The post being edited, provided for context, or null. + * @param string $post_type Post type to get the templates for. + */ + $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type ); + + /** + * Filters list of page templates for a theme. + * + * The dynamic portion of the hook name, `$post_type`, refers to the post type. + * + * @since 3.9.0 + * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. + * @since 4.7.0 Added the `$post_type` parameter. + * + * @param array $post_templates Array of page templates. Keys are filenames, + * values are translated names. + * @param WP_Theme $this The theme object. + * @param WP_Post|null $post The post being edited, provided for context, or null. + * @param string $post_type Post type to get the templates for. + */ + $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type ); + + return $post_templates; + } + + /** + * Scans a directory for files of a certain extension. + * + * @since 3.4.0 + * + * @static + * + * @param string $path Absolute path to search. + * @param array|string|null $extensions Optional. Array of extensions to find, string of a single extension, + * or null for all extensions. Default null. + * @param int $depth Optional. How many levels deep to search for files. Accepts 0, 1+, or + * -1 (infinite depth). Default 0. + * @param string $relative_path Optional. The basename of the absolute path. Used to control the + * returned path for the found files, particularly when this function + * recurses to lower depths. Default empty. + * @return array|false Array of files, keyed by the path to the file relative to the `$path` directory prepended + * with `$relative_path`, with the values being absolute paths. False otherwise. + */ + private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) { + if ( ! is_dir( $path ) ) { + return false; + } + + if ( $extensions ) { + $extensions = (array) $extensions; + $_extensions = implode( '|', $extensions ); + } + + $relative_path = trailingslashit( $relative_path ); + if ( '/' == $relative_path ) { + $relative_path = ''; + } + + $results = scandir( $path ); + $files = array(); + + /** + * Filters the array of excluded directories and files while scanning theme folder. + * + * @since 4.7.4 + * + * @param array $exclusions Array of excluded directories and files. + */ + $exclusions = (array) apply_filters( 'theme_scandir_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) ); + + foreach ( $results as $result ) { + if ( '.' == $result[0] || in_array( $result, $exclusions, true ) ) { + continue; + } + if ( is_dir( $path . '/' . $result ) ) { + if ( ! $depth ) { + continue; + } + $found = self::scandir( $path . '/' . $result, $extensions, $depth - 1 , $relative_path . $result ); + $files = array_merge_recursive( $files, $found ); + } elseif ( ! $extensions || preg_match( '~\.(' . $_extensions . ')$~', $result ) ) { + $files[ $relative_path . $result ] = $path . '/' . $result; + } + } + + return $files; + } + + /** + * Loads the theme's textdomain. + * + * Translation files are not inherited from the parent theme. Todo: if this fails for the + * child theme, it should probably try to load the parent theme's translations. + * + * @since 3.4.0 + * + * @return bool True if the textdomain was successfully loaded or has already been loaded. + * False if no textdomain was specified in the file headers, or if the domain could not be loaded. + */ + public function load_textdomain() { + if ( isset( $this->textdomain_loaded ) ) + return $this->textdomain_loaded; + + $textdomain = $this->get('TextDomain'); + if ( ! $textdomain ) { + $this->textdomain_loaded = false; + return false; + } + + if ( is_textdomain_loaded( $textdomain ) ) { + $this->textdomain_loaded = true; + return true; + } + + $path = $this->get_stylesheet_directory(); + if ( $domainpath = $this->get('DomainPath') ) + $path .= $domainpath; + else + $path .= '/languages'; + + $this->textdomain_loaded = load_theme_textdomain( $textdomain, $path ); + return $this->textdomain_loaded; + } + + /** + * Whether the theme is allowed (multisite only). + * + * @since 3.4.0 + * + * @param string $check Optional. Whether to check only the 'network'-wide settings, the 'site' + * settings, or 'both'. Defaults to 'both'. + * @param int $blog_id Optional. Ignored if only network-wide settings are checked. Defaults to current site. + * @return bool Whether the theme is allowed for the network. Returns true in single-site. + */ + public function is_allowed( $check = 'both', $blog_id = null ) { + if ( ! is_multisite() ) + return true; + + if ( 'both' == $check || 'network' == $check ) { + $allowed = self::get_allowed_on_network(); + if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) + return true; + } + + if ( 'both' == $check || 'site' == $check ) { + $allowed = self::get_allowed_on_site( $blog_id ); + if ( ! empty( $allowed[ $this->get_stylesheet() ] ) ) + return true; + } + + return false; + } + + /** + * Determines the latest WordPress default theme that is installed. + * + * This hits the filesystem. + * + * @since 4.4.0 + * + * @return WP_Theme|false Object, or false if no theme is installed, which would be bad. + */ + public static function get_core_default_theme() { + foreach ( array_reverse( self::$default_themes ) as $slug => $name ) { + $theme = wp_get_theme( $slug ); + if ( $theme->exists() ) { + return $theme; + } + } + return false; + } + + /** + * Returns array of stylesheet names of themes allowed on the site or network. + * + * @since 3.4.0 + * + * @static + * + * @param int $blog_id Optional. ID of the site. Defaults to the current site. + * @return array Array of stylesheet names. + */ + public static function get_allowed( $blog_id = null ) { + /** + * Filters the array of themes allowed on the network. + * + * Site is provided as context so that a list of network allowed themes can + * be filtered further. + * + * @since 4.5.0 + * + * @param array $allowed_themes An array of theme stylesheet names. + * @param int $blog_id ID of the site. + */ + $network = (array) apply_filters( 'network_allowed_themes', self::get_allowed_on_network(), $blog_id ); + return $network + self::get_allowed_on_site( $blog_id ); + } + + /** + * Returns array of stylesheet names of themes allowed on the network. + * + * @since 3.4.0 + * + * @static + * + * @staticvar array $allowed_themes + * + * @return array Array of stylesheet names. + */ + public static function get_allowed_on_network() { + static $allowed_themes; + if ( ! isset( $allowed_themes ) ) { + $allowed_themes = (array) get_site_option( 'allowedthemes' ); + } + + /** + * Filters the array of themes allowed on the network. + * + * @since MU (3.0.0) + * + * @param array $allowed_themes An array of theme stylesheet names. + */ + $allowed_themes = apply_filters( 'allowed_themes', $allowed_themes ); + + return $allowed_themes; + } + + /** + * Returns array of stylesheet names of themes allowed on the site. + * + * @since 3.4.0 + * + * @static + * + * @staticvar array $allowed_themes + * + * @param int $blog_id Optional. ID of the site. Defaults to the current site. + * @return array Array of stylesheet names. + */ + public static function get_allowed_on_site( $blog_id = null ) { + static $allowed_themes = array(); + + if ( ! $blog_id || ! is_multisite() ) + $blog_id = get_current_blog_id(); + + if ( isset( $allowed_themes[ $blog_id ] ) ) { + /** + * Filters the array of themes allowed on the site. + * + * @since 4.5.0 + * + * @param array $allowed_themes An array of theme stylesheet names. + * @param int $blog_id ID of the site. Defaults to current site. + */ + return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); + } + + $current = $blog_id == get_current_blog_id(); + + if ( $current ) { + $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); + } else { + switch_to_blog( $blog_id ); + $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); + restore_current_blog(); + } + + // This is all super old MU back compat joy. + // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. + if ( false === $allowed_themes[ $blog_id ] ) { + if ( $current ) { + $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); + } else { + switch_to_blog( $blog_id ); + $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); + restore_current_blog(); + } + + if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { + $allowed_themes[ $blog_id ] = array(); + } else { + $converted = array(); + $themes = wp_get_themes(); + foreach ( $themes as $stylesheet => $theme_data ) { + if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) ) + $converted[ $stylesheet ] = true; + } + $allowed_themes[ $blog_id ] = $converted; + } + // Set the option so we never have to go through this pain again. + if ( is_admin() && $allowed_themes[ $blog_id ] ) { + if ( $current ) { + update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); + delete_option( 'allowed_themes' ); + } else { + switch_to_blog( $blog_id ); + update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); + delete_option( 'allowed_themes' ); + restore_current_blog(); + } + } + } + + /** This filter is documented in wp-includes/class-wp-theme.php */ + return (array) apply_filters( 'site_allowed_themes', $allowed_themes[ $blog_id ], $blog_id ); + } + + /** + * Enables a theme for all sites on the current network. + * + * @since 4.6.0 + * @static + * + * @param string|array $stylesheets Stylesheet name or array of stylesheet names. + */ + public static function network_enable_theme( $stylesheets ) { + if ( ! is_multisite() ) { + return; + } + + if ( ! is_array( $stylesheets ) ) { + $stylesheets = array( $stylesheets ); + } + + $allowed_themes = get_site_option( 'allowedthemes' ); + foreach ( $stylesheets as $stylesheet ) { + $allowed_themes[ $stylesheet ] = true; + } + + update_site_option( 'allowedthemes', $allowed_themes ); + } + + /** + * Disables a theme for all sites on the current network. + * + * @since 4.6.0 + * @static + * + * @param string|array $stylesheets Stylesheet name or array of stylesheet names. + */ + public static function network_disable_theme( $stylesheets ) { + if ( ! is_multisite() ) { + return; + } + + if ( ! is_array( $stylesheets ) ) { + $stylesheets = array( $stylesheets ); + } + + $allowed_themes = get_site_option( 'allowedthemes' ); + foreach ( $stylesheets as $stylesheet ) { + if ( isset( $allowed_themes[ $stylesheet ] ) ) { + unset( $allowed_themes[ $stylesheet ] ); + } + } + + update_site_option( 'allowedthemes', $allowed_themes ); + } + + /** + * Sorts themes by name. + * + * @since 3.4.0 + * + * @static + * + * @param array $themes Array of themes to sort (passed by reference). + */ + public static function sort_by_name( &$themes ) { + if ( 0 === strpos( get_user_locale(), 'en_' ) ) { + uasort( $themes, array( 'WP_Theme', '_name_sort' ) ); + } else { + uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) ); + } + } + + /** + * Callback function for usort() to naturally sort themes by name. + * + * Accesses the Name header directly from the class for maximum speed. + * Would choke on HTML but we don't care enough to slow it down with strip_tags(). + * + * @since 3.4.0 + * + * @static + * + * @param string $a First name. + * @param string $b Second name. + * @return int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally. + * Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort(). + */ + private static function _name_sort( $a, $b ) { + return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] ); + } + + /** + * Name sort (with translation). + * + * @since 3.4.0 + * + * @static + * + * @param string $a First name. + * @param string $b Second name. + * @return int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally. + * Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort(). + */ + private static function _name_sort_i18n( $a, $b ) { + // Don't mark up; Do translate. + return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) ); + } +} diff --git a/backend/wp-includes/class-wp-user-meta-session-tokens.php b/backend/wp-includes/class-wp-user-meta-session-tokens.php new file mode 100644 index 0000000..1cb5cca --- /dev/null +++ b/backend/wp-includes/class-wp-user-meta-session-tokens.php @@ -0,0 +1,132 @@ +<?php +/** + * Session API: WP_User_Meta_Session_Tokens class + * + * @package WordPress + * @subpackage Session + * @since 4.7.0 + */ + +/** + * Meta-based user sessions token manager. + * + * @since 4.0.0 + */ +class WP_User_Meta_Session_Tokens extends WP_Session_Tokens { + + /** + * Get all sessions of a user. + * + * @since 4.0.0 + * + * @return array Sessions of a user. + */ + protected function get_sessions() { + $sessions = get_user_meta( $this->user_id, 'session_tokens', true ); + + if ( ! is_array( $sessions ) ) { + return array(); + } + + $sessions = array_map( array( $this, 'prepare_session' ), $sessions ); + return array_filter( $sessions, array( $this, 'is_still_valid' ) ); + } + + /** + * Converts an expiration to an array of session information. + * + * @param mixed $session Session or expiration. + * @return array Session. + */ + protected function prepare_session( $session ) { + if ( is_int( $session ) ) { + return array( 'expiration' => $session ); + } + + return $session; + } + + /** + * Retrieve a session by its verifier (token hash). + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to retrieve. + * @return array|null The session, or null if it does not exist + */ + protected function get_session( $verifier ) { + $sessions = $this->get_sessions(); + + if ( isset( $sessions[ $verifier ] ) ) { + return $sessions[ $verifier ]; + } + + return null; + } + + /** + * Update a session by its verifier. + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to update. + * @param array $session Optional. Session. Omitting this argument destroys the session. + */ + protected function update_session( $verifier, $session = null ) { + $sessions = $this->get_sessions(); + + if ( $session ) { + $sessions[ $verifier ] = $session; + } else { + unset( $sessions[ $verifier ] ); + } + + $this->update_sessions( $sessions ); + } + + /** + * Update a user's sessions in the usermeta table. + * + * @since 4.0.0 + * + * @param array $sessions Sessions. + */ + protected function update_sessions( $sessions ) { + if ( $sessions ) { + update_user_meta( $this->user_id, 'session_tokens', $sessions ); + } else { + delete_user_meta( $this->user_id, 'session_tokens' ); + } + } + + /** + * Destroy all session tokens for a user, except a single session passed. + * + * @since 4.0.0 + * + * @param string $verifier Verifier of the session to keep. + */ + protected function destroy_other_sessions( $verifier ) { + $session = $this->get_session( $verifier ); + $this->update_sessions( array( $verifier => $session ) ); + } + + /** + * Destroy all session tokens for a user. + * + * @since 4.0.0 + */ + protected function destroy_all_sessions() { + $this->update_sessions( array() ); + } + + /** + * Destroy all session tokens for all users. + * + * @since 4.0.0 + * @static + */ + public static function drop_sessions() { + delete_metadata( 'user', 0, 'session_tokens', false, true ); + } +} diff --git a/backend/wp-includes/class-wp-user-query.php b/backend/wp-includes/class-wp-user-query.php new file mode 100644 index 0000000..b2462dc --- /dev/null +++ b/backend/wp-includes/class-wp-user-query.php @@ -0,0 +1,860 @@ +<?php +/** + * User API: WP_User_Query class + * + * @package WordPress + * @subpackage Users + * @since 4.4.0 + */ + +/** + * Core class used for querying users. + * + * @since 3.1.0 + * + * @see WP_User_Query::prepare_query() for information on accepted arguments. + */ +class WP_User_Query { + + /** + * Query vars, after parsing + * + * @since 3.5.0 + * @var array + */ + public $query_vars = array(); + + /** + * List of found user ids + * + * @since 3.1.0 + * @var array + */ + private $results; + + /** + * Total number of found users for the current query + * + * @since 3.1.0 + * @var int + */ + private $total_users = 0; + + /** + * Metadata query container. + * + * @since 4.2.0 + * @var WP_Meta_Query + */ + public $meta_query = false; + + /** + * The SQL query used to fetch matching users. + * + * @since 4.4.0 + * @var string + */ + public $request; + + private $compat_fields = array( 'results', 'total_users' ); + + // SQL clauses + public $query_fields; + public $query_from; + public $query_where; + public $query_orderby; + public $query_limit; + + /** + * PHP5 constructor. + * + * @since 3.1.0 + * + * @param null|string|array $query Optional. The query variables. + */ + public function __construct( $query = null ) { + if ( ! empty( $query ) ) { + $this->prepare_query( $query ); + $this->query(); + } + } + + /** + * Fills in missing query variables with default values. + * + * @since 4.4.0 + * + * @param array $args Query vars, as passed to `WP_User_Query`. + * @return array Complete query variables with undefined ones filled in with defaults. + */ + public static function fill_query_vars( $args ) { + $defaults = array( + 'blog_id' => get_current_blog_id(), + 'role' => '', + 'role__in' => array(), + 'role__not_in' => array(), + 'meta_key' => '', + 'meta_value' => '', + 'meta_compare' => '', + 'include' => array(), + 'exclude' => array(), + 'search' => '', + 'search_columns' => array(), + 'orderby' => 'login', + 'order' => 'ASC', + 'offset' => '', + 'number' => '', + 'paged' => 1, + 'count_total' => true, + 'fields' => 'all', + 'who' => '', + 'has_published_posts' => null, + 'nicename' => '', + 'nicename__in' => array(), + 'nicename__not_in' => array(), + 'login' => '', + 'login__in' => array(), + 'login__not_in' => array() + ); + + return wp_parse_args( $args, $defaults ); + } + + /** + * Prepare the query variables. + * + * @since 3.1.0 + * @since 4.1.0 Added the ability to order by the `include` value. + * @since 4.2.0 Added 'meta_value_num' support for `$orderby` parameter. Added multi-dimensional array syntax + * for `$orderby` parameter. + * @since 4.3.0 Added 'has_published_posts' parameter. + * @since 4.4.0 Added 'paged', 'role__in', and 'role__not_in' parameters. The 'role' parameter was updated to + * permit an array or comma-separated list of values. The 'number' parameter was updated to support + * querying for all users with using -1. + * @since 4.7.0 Added 'nicename', 'nicename__in', 'nicename__not_in', 'login', 'login__in', + * and 'login__not_in' parameters. + * + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global int $blog_id + * + * @param string|array $query { + * Optional. Array or string of Query parameters. + * + * @type int $blog_id The site ID. Default is the current site. + * @type string|array $role An array or a comma-separated list of role names that users must match + * to be included in results. Note that this is an inclusive list: users + * must match *each* role. Default empty. + * @type array $role__in An array of role names. Matched users must have at least one of these + * roles. Default empty array. + * @type array $role__not_in An array of role names to exclude. Users matching one or more of these + * roles will not be included in results. Default empty array. + * @type string $meta_key User meta key. Default empty. + * @type string $meta_value User meta value. Default empty. + * @type string $meta_compare Comparison operator to test the `$meta_value`. Accepts '=', '!=', + * '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', + * 'BETWEEN', 'NOT BETWEEN', 'EXISTS', 'NOT EXISTS', 'REGEXP', + * 'NOT REGEXP', or 'RLIKE'. Default '='. + * @type array $include An array of user IDs to include. Default empty array. + * @type array $exclude An array of user IDs to exclude. Default empty array. + * @type string $search Search keyword. Searches for possible string matches on columns. + * When `$search_columns` is left empty, it tries to determine which + * column to search in based on search string. Default empty. + * @type array $search_columns Array of column names to be searched. Accepts 'ID', 'login', + * 'nicename', 'email', 'url'. Default empty array. + * @type string|array $orderby Field(s) to sort the retrieved users by. May be a single value, + * an array of values, or a multi-dimensional array with fields as + * keys and orders ('ASC' or 'DESC') as values. Accepted values are + * 'ID', 'display_name' (or 'name'), 'include', 'user_login' + * (or 'login'), 'login__in', 'user_nicename' (or 'nicename'), + * 'nicename__in', 'user_email (or 'email'), 'user_url' (or 'url'), + * 'user_registered' (or 'registered'), 'post_count', 'meta_value', + * 'meta_value_num', the value of `$meta_key`, or an array key of + * `$meta_query`. To use 'meta_value' or 'meta_value_num', `$meta_key` + * must be also be defined. Default 'user_login'. + * @type string $order Designates ascending or descending order of users. Order values + * passed as part of an `$orderby` array take precedence over this + * parameter. Accepts 'ASC', 'DESC'. Default 'ASC'. + * @type int $offset Number of users to offset in retrieved results. Can be used in + * conjunction with pagination. Default 0. + * @type int $number Number of users to limit the query for. Can be used in + * conjunction with pagination. Value -1 (all) is supported, but + * should be used with caution on larger sites. + * Default empty (all users). + * @type int $paged When used with number, defines the page of results to return. + * Default 1. + * @type bool $count_total Whether to count the total number of users found. If pagination + * is not needed, setting this to false can improve performance. + * Default true. + * @type string|array $fields Which fields to return. Single or all fields (string), or array + * of fields. Accepts 'ID', 'display_name', 'user_login', + * 'user_nicename', 'user_email', 'user_url', 'user_registered'. + * Use 'all' for all fields and 'all_with_meta' to include + * meta fields. Default 'all'. + * @type string $who Type of users to query. Accepts 'authors'. + * Default empty (all users). + * @type bool|array $has_published_posts Pass an array of post types to filter results to users who have + * published posts in those post types. `true` is an alias for all + * public post types. + * @type string $nicename The user nicename. Default empty. + * @type array $nicename__in An array of nicenames to include. Users matching one of these + * nicenames will be included in results. Default empty array. + * @type array $nicename__not_in An array of nicenames to exclude. Users matching one of these + * nicenames will not be included in results. Default empty array. + * @type string $login The user login. Default empty. + * @type array $login__in An array of logins to include. Users matching one of these + * logins will be included in results. Default empty array. + * @type array $login__not_in An array of logins to exclude. Users matching one of these + * logins will not be included in results. Default empty array. + * } + */ + public function prepare_query( $query = array() ) { + global $wpdb; + + if ( empty( $this->query_vars ) || ! empty( $query ) ) { + $this->query_limit = null; + $this->query_vars = $this->fill_query_vars( $query ); + } + + /** + * Fires before the WP_User_Query has been parsed. + * + * The passed WP_User_Query object contains the query variables, not + * yet passed into SQL. + * + * @since 4.0.0 + * + * @param WP_User_Query $this The current WP_User_Query instance, + * passed by reference. + */ + do_action( 'pre_get_users', $this ); + + // Ensure that query vars are filled after 'pre_get_users'. + $qv =& $this->query_vars; + $qv = $this->fill_query_vars( $qv ); + + if ( is_array( $qv['fields'] ) ) { + $qv['fields'] = array_unique( $qv['fields'] ); + + $this->query_fields = array(); + foreach ( $qv['fields'] as $field ) { + $field = 'ID' === $field ? 'ID' : sanitize_key( $field ); + $this->query_fields[] = "$wpdb->users.$field"; + } + $this->query_fields = implode( ',', $this->query_fields ); + } elseif ( 'all' == $qv['fields'] ) { + $this->query_fields = "$wpdb->users.*"; + } else { + $this->query_fields = "$wpdb->users.ID"; + } + + if ( isset( $qv['count_total'] ) && $qv['count_total'] ) + $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; + + $this->query_from = "FROM $wpdb->users"; + $this->query_where = "WHERE 1=1"; + + // Parse and sanitize 'include', for use by 'orderby' as well as 'include' below. + if ( ! empty( $qv['include'] ) ) { + $include = wp_parse_id_list( $qv['include'] ); + } else { + $include = false; + } + + $blog_id = 0; + if ( isset( $qv['blog_id'] ) ) { + $blog_id = absint( $qv['blog_id'] ); + } + + if ( $qv['has_published_posts'] && $blog_id ) { + if ( true === $qv['has_published_posts'] ) { + $post_types = get_post_types( array( 'public' => true ) ); + } else { + $post_types = (array) $qv['has_published_posts']; + } + + foreach ( $post_types as &$post_type ) { + $post_type = $wpdb->prepare( '%s', $post_type ); + } + + $posts_table = $wpdb->get_blog_prefix( $blog_id ) . 'posts'; + $this->query_where .= " AND $wpdb->users.ID IN ( SELECT DISTINCT $posts_table.post_author FROM $posts_table WHERE $posts_table.post_status = 'publish' AND $posts_table.post_type IN ( " . join( ", ", $post_types ) . " ) )"; + } + + // nicename + if ( '' !== $qv['nicename']) { + $this->query_where .= $wpdb->prepare( ' AND user_nicename = %s', $qv['nicename'] ); + } + + if ( ! empty( $qv['nicename__in'] ) ) { + $sanitized_nicename__in = array_map( 'esc_sql', $qv['nicename__in'] ); + $nicename__in = implode( "','", $sanitized_nicename__in ); + $this->query_where .= " AND user_nicename IN ( '$nicename__in' )"; + } + + if ( ! empty( $qv['nicename__not_in'] ) ) { + $sanitized_nicename__not_in = array_map( 'esc_sql', $qv['nicename__not_in'] ); + $nicename__not_in = implode( "','", $sanitized_nicename__not_in ); + $this->query_where .= " AND user_nicename NOT IN ( '$nicename__not_in' )"; + } + + // login + if ( '' !== $qv['login']) { + $this->query_where .= $wpdb->prepare( ' AND user_login = %s', $qv['login'] ); + } + + if ( ! empty( $qv['login__in'] ) ) { + $sanitized_login__in = array_map( 'esc_sql', $qv['login__in'] ); + $login__in = implode( "','", $sanitized_login__in ); + $this->query_where .= " AND user_login IN ( '$login__in' )"; + } + + if ( ! empty( $qv['login__not_in'] ) ) { + $sanitized_login__not_in = array_map( 'esc_sql', $qv['login__not_in'] ); + $login__not_in = implode( "','", $sanitized_login__not_in ); + $this->query_where .= " AND user_login NOT IN ( '$login__not_in' )"; + } + + // Meta query. + $this->meta_query = new WP_Meta_Query(); + $this->meta_query->parse_query_vars( $qv ); + + if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) { + $who_query = array( + 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'user_level', + 'value' => 0, + 'compare' => '!=', + ); + + // Prevent extra meta query. + $qv['blog_id'] = $blog_id = 0; + + if ( empty( $this->meta_query->queries ) ) { + $this->meta_query->queries = array( $who_query ); + } else { + // Append the cap query to the original queries and reparse the query. + $this->meta_query->queries = array( + 'relation' => 'AND', + array( $this->meta_query->queries, $who_query ), + ); + } + + $this->meta_query->parse_query_vars( $this->meta_query->queries ); + } + + $roles = array(); + if ( isset( $qv['role'] ) ) { + if ( is_array( $qv['role'] ) ) { + $roles = $qv['role']; + } elseif ( is_string( $qv['role'] ) && ! empty( $qv['role'] ) ) { + $roles = array_map( 'trim', explode( ',', $qv['role'] ) ); + } + } + + $role__in = array(); + if ( isset( $qv['role__in'] ) ) { + $role__in = (array) $qv['role__in']; + } + + $role__not_in = array(); + if ( isset( $qv['role__not_in'] ) ) { + $role__not_in = (array) $qv['role__not_in']; + } + + if ( $blog_id && ( ! empty( $roles ) || ! empty( $role__in ) || ! empty( $role__not_in ) || is_multisite() ) ) { + $role_queries = array(); + + $roles_clauses = array( 'relation' => 'AND' ); + if ( ! empty( $roles ) ) { + foreach ( $roles as $role ) { + $roles_clauses[] = array( + 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', + 'value' => '"' . $role . '"', + 'compare' => 'LIKE', + ); + } + + $role_queries[] = $roles_clauses; + } + + $role__in_clauses = array( 'relation' => 'OR' ); + if ( ! empty( $role__in ) ) { + foreach ( $role__in as $role ) { + $role__in_clauses[] = array( + 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', + 'value' => '"' . $role . '"', + 'compare' => 'LIKE', + ); + } + + $role_queries[] = $role__in_clauses; + } + + $role__not_in_clauses = array( 'relation' => 'AND' ); + if ( ! empty( $role__not_in ) ) { + foreach ( $role__not_in as $role ) { + $role__not_in_clauses[] = array( + 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', + 'value' => '"' . $role . '"', + 'compare' => 'NOT LIKE', + ); + } + + $role_queries[] = $role__not_in_clauses; + } + + // If there are no specific roles named, make sure the user is a member of the site. + if ( empty( $role_queries ) ) { + $role_queries[] = array( + 'key' => $wpdb->get_blog_prefix( $blog_id ) . 'capabilities', + 'compare' => 'EXISTS', + ); + } + + // Specify that role queries should be joined with AND. + $role_queries['relation'] = 'AND'; + + if ( empty( $this->meta_query->queries ) ) { + $this->meta_query->queries = $role_queries; + } else { + // Append the cap query to the original queries and reparse the query. + $this->meta_query->queries = array( + 'relation' => 'AND', + array( $this->meta_query->queries, $role_queries ), + ); + } + + $this->meta_query->parse_query_vars( $this->meta_query->queries ); + } + + if ( ! empty( $this->meta_query->queries ) ) { + $clauses = $this->meta_query->get_sql( 'user', $wpdb->users, 'ID', $this ); + $this->query_from .= $clauses['join']; + $this->query_where .= $clauses['where']; + + if ( $this->meta_query->has_or_relation() ) { + $this->query_fields = 'DISTINCT ' . $this->query_fields; + } + } + + // sorting + $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; + $order = $this->parse_order( $qv['order'] ); + + if ( empty( $qv['orderby'] ) ) { + // Default order is by 'user_login'. + $ordersby = array( 'user_login' => $order ); + } elseif ( is_array( $qv['orderby'] ) ) { + $ordersby = $qv['orderby']; + } else { + // 'orderby' values may be a comma- or space-separated list. + $ordersby = preg_split( '/[,\s]+/', $qv['orderby'] ); + } + + $orderby_array = array(); + foreach ( $ordersby as $_key => $_value ) { + if ( ! $_value ) { + continue; + } + + if ( is_int( $_key ) ) { + // Integer key means this is a flat array of 'orderby' fields. + $_orderby = $_value; + $_order = $order; + } else { + // Non-integer key means this the key is the field and the value is ASC/DESC. + $_orderby = $_key; + $_order = $_value; + } + + $parsed = $this->parse_orderby( $_orderby ); + + if ( ! $parsed ) { + continue; + } + + if ( 'nicename__in' === $_orderby || 'login__in' === $_orderby ) { + $orderby_array[] = $parsed; + } else { + $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); + } + } + + // If no valid clauses were found, order by user_login. + if ( empty( $orderby_array ) ) { + $orderby_array[] = "user_login $order"; + } + + $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); + + // limit + if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { + if ( $qv['offset'] ) { + $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']); + } else { + $this->query_limit = $wpdb->prepare( "LIMIT %d, %d", $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); + } + } + + $search = ''; + if ( isset( $qv['search'] ) ) + $search = trim( $qv['search'] ); + + if ( $search ) { + $leading_wild = ( ltrim($search, '*') != $search ); + $trailing_wild = ( rtrim($search, '*') != $search ); + if ( $leading_wild && $trailing_wild ) + $wild = 'both'; + elseif ( $leading_wild ) + $wild = 'leading'; + elseif ( $trailing_wild ) + $wild = 'trailing'; + else + $wild = false; + if ( $wild ) + $search = trim($search, '*'); + + $search_columns = array(); + if ( $qv['search_columns'] ) { + $search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name' ) ); + } + if ( ! $search_columns ) { + if ( false !== strpos( $search, '@') ) + $search_columns = array('user_email'); + elseif ( is_numeric($search) ) + $search_columns = array('user_login', 'ID'); + elseif ( preg_match('|^https?://|', $search) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) ) + $search_columns = array('user_url'); + else + $search_columns = array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name'); + } + + /** + * Filters the columns to search in a WP_User_Query search. + * + * The default columns depend on the search term, and include 'user_email', + * 'user_login', 'ID', 'user_url', 'display_name', and 'user_nicename'. + * + * @since 3.6.0 + * + * @param array $search_columns Array of column names to be searched. + * @param string $search Text being searched. + * @param WP_User_Query $this The current WP_User_Query instance. + */ + $search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this ); + + $this->query_where .= $this->get_search_sql( $search, $search_columns, $wild ); + } + + if ( ! empty( $include ) ) { + // Sanitized earlier. + $ids = implode( ',', $include ); + $this->query_where .= " AND $wpdb->users.ID IN ($ids)"; + } elseif ( ! empty( $qv['exclude'] ) ) { + $ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) ); + $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)"; + } + + // Date queries are allowed for the user_registered field. + if ( ! empty( $qv['date_query'] ) && is_array( $qv['date_query'] ) ) { + $date_query = new WP_Date_Query( $qv['date_query'], 'user_registered' ); + $this->query_where .= $date_query->get_sql(); + } + + /** + * Fires after the WP_User_Query has been parsed, and before + * the query is executed. + * + * The passed WP_User_Query object contains SQL parts formed + * from parsing the given query. + * + * @since 3.1.0 + * + * @param WP_User_Query $this The current WP_User_Query instance, + * passed by reference. + */ + do_action_ref_array( 'pre_user_query', array( &$this ) ); + } + + /** + * Execute the query, with the current variables. + * + * @since 3.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + public function query() { + global $wpdb; + + $qv =& $this->query_vars; + + $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; + + if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { + $this->results = $wpdb->get_results( $this->request ); + } else { + $this->results = $wpdb->get_col( $this->request ); + } + + /** + * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance. + * + * @since 3.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query. + */ + if ( isset( $qv['count_total'] ) && $qv['count_total'] ) + $this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); + + if ( !$this->results ) + return; + + if ( 'all_with_meta' == $qv['fields'] ) { + cache_users( $this->results ); + + $r = array(); + foreach ( $this->results as $userid ) + $r[ $userid ] = new WP_User( $userid, '', $qv['blog_id'] ); + + $this->results = $r; + } elseif ( 'all' == $qv['fields'] ) { + foreach ( $this->results as $key => $user ) { + $this->results[ $key ] = new WP_User( $user, '', $qv['blog_id'] ); + } + } + } + + /** + * Retrieve query variable. + * + * @since 3.5.0 + * + * @param string $query_var Query variable key. + * @return mixed + */ + public function get( $query_var ) { + if ( isset( $this->query_vars[$query_var] ) ) + return $this->query_vars[$query_var]; + + return null; + } + + /** + * Set query variable. + * + * @since 3.5.0 + * + * @param string $query_var Query variable key. + * @param mixed $value Query variable value. + */ + public function set( $query_var, $value ) { + $this->query_vars[$query_var] = $value; + } + + /** + * Used internally to generate an SQL string for searching across multiple columns + * + * @since 3.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $string + * @param array $cols + * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site. + * Single site allows leading and trailing wildcards, Network Admin only trailing. + * @return string + */ + protected function get_search_sql( $string, $cols, $wild = false ) { + global $wpdb; + + $searches = array(); + $leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : ''; + $trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : ''; + $like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild; + + foreach ( $cols as $col ) { + if ( 'ID' == $col ) { + $searches[] = $wpdb->prepare( "$col = %s", $string ); + } else { + $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); + } + } + + return ' AND (' . implode(' OR ', $searches) . ')'; + } + + /** + * Return the list of users. + * + * @since 3.1.0 + * + * @return array Array of results. + */ + public function get_results() { + return $this->results; + } + + /** + * Return the total number of users for the current query. + * + * @since 3.1.0 + * + * @return int Number of total users. + */ + public function get_total() { + return $this->total_users; + } + + /** + * Parse and sanitize 'orderby' keys passed to the user query. + * + * @since 4.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $orderby Alias for the field to order by. + * @return string Value to used in the ORDER clause, if `$orderby` is valid. + */ + protected function parse_orderby( $orderby ) { + global $wpdb; + + $meta_query_clauses = $this->meta_query->get_clauses(); + + $_orderby = ''; + if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ) ) ) { + $_orderby = 'user_' . $orderby; + } elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ) ) { + $_orderby = $orderby; + } elseif ( 'name' == $orderby || 'display_name' == $orderby ) { + $_orderby = 'display_name'; + } elseif ( 'post_count' == $orderby ) { + // todo: avoid the JOIN + $where = get_posts_by_author_sql( 'post' ); + $this->query_from .= " LEFT OUTER JOIN ( + SELECT post_author, COUNT(*) as post_count + FROM $wpdb->posts + $where + GROUP BY post_author + ) p ON ({$wpdb->users}.ID = p.post_author) + "; + $_orderby = 'post_count'; + } elseif ( 'ID' == $orderby || 'id' == $orderby ) { + $_orderby = 'ID'; + } elseif ( 'meta_value' == $orderby || $this->get( 'meta_key' ) == $orderby ) { + $_orderby = "$wpdb->usermeta.meta_value"; + } elseif ( 'meta_value_num' == $orderby ) { + $_orderby = "$wpdb->usermeta.meta_value+0"; + } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) { + $include = wp_parse_id_list( $this->query_vars['include'] ); + $include_sql = implode( ',', $include ); + $_orderby = "FIELD( $wpdb->users.ID, $include_sql )"; + } elseif ( 'nicename__in' === $orderby ) { + $sanitized_nicename__in = array_map( 'esc_sql', $this->query_vars['nicename__in'] ); + $nicename__in = implode( "','", $sanitized_nicename__in ); + $_orderby = "FIELD( user_nicename, '$nicename__in' )"; + } elseif ( 'login__in' === $orderby ) { + $sanitized_login__in = array_map( 'esc_sql', $this->query_vars['login__in'] ); + $login__in = implode( "','", $sanitized_login__in ); + $_orderby = "FIELD( user_login, '$login__in' )"; + } elseif ( isset( $meta_query_clauses[ $orderby ] ) ) { + $meta_clause = $meta_query_clauses[ $orderby ]; + $_orderby = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) ); + } + + return $_orderby; + } + + /** + * Parse an 'order' query variable and cast it to ASC or DESC as necessary. + * + * @since 4.2.0 + * + * @param string $order The 'order' query variable. + * @return string The sanitized 'order' query variable. + */ + protected function parse_order( $order ) { + if ( ! is_string( $order ) || empty( $order ) ) { + return 'DESC'; + } + + if ( 'ASC' === strtoupper( $order ) ) { + return 'ASC'; + } else { + return 'DESC'; + } + } + + /** + * Make private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name; + } + } + + /** + * Make private properties settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set( $name, $value ) { + if ( in_array( $name, $this->compat_fields ) ) { + return $this->$name = $value; + } + } + + /** + * Make private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + return isset( $this->$name ); + } + } + + /** + * Make private properties un-settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to unset. + */ + public function __unset( $name ) { + if ( in_array( $name, $this->compat_fields ) ) { + unset( $this->$name ); + } + } + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( 'get_search_sql' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } +} diff --git a/backend/wp-includes/class-wp-user.php b/backend/wp-includes/class-wp-user.php new file mode 100644 index 0000000..4a90439 --- /dev/null +++ b/backend/wp-includes/class-wp-user.php @@ -0,0 +1,841 @@ +<?php +/** + * User API: WP_User class + * + * @package WordPress + * @subpackage Users + * @since 4.4.0 + */ + +/** + * Core class used to implement the WP_User object. + * + * @since 2.0.0 + * + * @property string $nickname + * @property string $description + * @property string $user_description + * @property string $first_name + * @property string $user_firstname + * @property string $last_name + * @property string $user_lastname + * @property string $user_login + * @property string $user_pass + * @property string $user_nicename + * @property string $user_email + * @property string $user_url + * @property string $user_registered + * @property string $user_activation_key + * @property string $user_status + * @property int $user_level + * @property string $display_name + * @property string $spam + * @property string $deleted + * @property string $locale + * @property string $rich_editing + * @property string $syntax_highlighting + */ +class WP_User { + /** + * User data container. + * + * @since 2.0.0 + * @var object + */ + public $data; + + /** + * The user's ID. + * + * @since 2.1.0 + * @var int + */ + public $ID = 0; + + /** + * The individual capabilities the user has been given. + * + * @since 2.0.0 + * @var array + */ + public $caps = array(); + + /** + * User metadata option name. + * + * @since 2.0.0 + * @var string + */ + public $cap_key; + + /** + * The roles the user is part of. + * + * @since 2.0.0 + * @var array + */ + public $roles = array(); + + /** + * All capabilities the user has, including individual and role based. + * + * @since 2.0.0 + * @var array + */ + public $allcaps = array(); + + /** + * The filter context applied to user data fields. + * + * @since 2.9.0 + * @var string + */ + public $filter = null; + + /** + * The site ID the capabilities of this user are initialized for. + * + * @since 4.9.0 + * @var int + */ + private $site_id = 0; + + /** + * @static + * @since 3.3.0 + * @var array + */ + private static $back_compat_keys; + + /** + * Constructor. + * + * Retrieves the userdata and passes it to WP_User::init(). + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. + * @param string $name Optional. User's username + * @param int $site_id Optional Site ID, defaults to current site. + */ + public function __construct( $id = 0, $name = '', $site_id = '' ) { + if ( ! isset( self::$back_compat_keys ) ) { + $prefix = $GLOBALS['wpdb']->prefix; + self::$back_compat_keys = array( + 'user_firstname' => 'first_name', + 'user_lastname' => 'last_name', + 'user_description' => 'description', + 'user_level' => $prefix . 'user_level', + $prefix . 'usersettings' => $prefix . 'user-settings', + $prefix . 'usersettingstime' => $prefix . 'user-settings-time', + ); + } + + if ( $id instanceof WP_User ) { + $this->init( $id->data, $site_id ); + return; + } elseif ( is_object( $id ) ) { + $this->init( $id, $site_id ); + return; + } + + if ( ! empty( $id ) && ! is_numeric( $id ) ) { + $name = $id; + $id = 0; + } + + if ( $id ) { + $data = self::get_data_by( 'id', $id ); + } else { + $data = self::get_data_by( 'login', $name ); + } + + if ( $data ) { + $this->init( $data, $site_id ); + } else { + $this->data = new stdClass; + } + } + + /** + * Sets up object properties, including capabilities. + * + * @since 3.3.0 + * + * @param object $data User DB row object. + * @param int $site_id Optional. The site ID to initialize for. + */ + public function init( $data, $site_id = '' ) { + $this->data = $data; + $this->ID = (int) $data->ID; + + $this->for_site( $site_id ); + } + + /** + * Return only the main user fields + * + * @since 3.3.0 + * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter. + * + * @static + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'. + * @param string|int $value The field value + * @return object|false Raw user object + */ + public static function get_data_by( $field, $value ) { + global $wpdb; + + // 'ID' is an alias of 'id'. + if ( 'ID' === $field ) { + $field = 'id'; + } + + if ( 'id' == $field ) { + // Make sure the value is numeric to avoid casting objects, for example, + // to int 1. + if ( ! is_numeric( $value ) ) + return false; + $value = intval( $value ); + if ( $value < 1 ) + return false; + } else { + $value = trim( $value ); + } + + if ( !$value ) + return false; + + switch ( $field ) { + case 'id': + $user_id = $value; + $db_field = 'ID'; + break; + case 'slug': + $user_id = wp_cache_get($value, 'userslugs'); + $db_field = 'user_nicename'; + break; + case 'email': + $user_id = wp_cache_get($value, 'useremail'); + $db_field = 'user_email'; + break; + case 'login': + $value = sanitize_user( $value ); + $user_id = wp_cache_get($value, 'userlogins'); + $db_field = 'user_login'; + break; + default: + return false; + } + + if ( false !== $user_id ) { + if ( $user = wp_cache_get( $user_id, 'users' ) ) + return $user; + } + + if ( !$user = $wpdb->get_row( $wpdb->prepare( + "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value + ) ) ) + return false; + + update_user_caches( $user ); + + return $user; + } + + /** + * Magic method for checking the existence of a certain custom field. + * + * @since 3.3.0 + * + * @param string $key User meta key to check if set. + * @return bool Whether the given user meta key is set. + */ + public function __isset( $key ) { + if ( 'id' == $key ) { + _deprecated_argument( 'WP_User->id', '2.1.0', + sprintf( + /* translators: %s: WP_User->ID */ + __( 'Use %s instead.' ), + '<code>WP_User->ID</code>' + ) + ); + $key = 'ID'; + } + + if ( isset( $this->data->$key ) ) + return true; + + if ( isset( self::$back_compat_keys[ $key ] ) ) + $key = self::$back_compat_keys[ $key ]; + + return metadata_exists( 'user', $this->ID, $key ); + } + + /** + * Magic method for accessing custom fields. + * + * @since 3.3.0 + * + * @param string $key User meta key to retrieve. + * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID. + */ + public function __get( $key ) { + if ( 'id' == $key ) { + _deprecated_argument( 'WP_User->id', '2.1.0', + sprintf( + /* translators: %s: WP_User->ID */ + __( 'Use %s instead.' ), + '<code>WP_User->ID</code>' + ) + ); + return $this->ID; + } + + if ( isset( $this->data->$key ) ) { + $value = $this->data->$key; + } else { + if ( isset( self::$back_compat_keys[ $key ] ) ) + $key = self::$back_compat_keys[ $key ]; + $value = get_user_meta( $this->ID, $key, true ); + } + + if ( $this->filter ) { + $value = sanitize_user_field( $key, $value, $this->ID, $this->filter ); + } + + return $value; + } + + /** + * Magic method for setting custom user fields. + * + * This method does not update custom fields in the database. It only stores + * the value on the WP_User instance. + * + * @since 3.3.0 + * + * @param string $key User meta key. + * @param mixed $value User meta value. + */ + public function __set( $key, $value ) { + if ( 'id' == $key ) { + _deprecated_argument( 'WP_User->id', '2.1.0', + sprintf( + /* translators: %s: WP_User->ID */ + __( 'Use %s instead.' ), + '<code>WP_User->ID</code>' + ) + ); + $this->ID = $value; + return; + } + + $this->data->$key = $value; + } + + /** + * Magic method for unsetting a certain custom field. + * + * @since 4.4.0 + * + * @param string $key User meta key to unset. + */ + public function __unset( $key ) { + if ( 'id' == $key ) { + _deprecated_argument( 'WP_User->id', '2.1.0', + sprintf( + /* translators: %s: WP_User->ID */ + __( 'Use %s instead.' ), + '<code>WP_User->ID</code>' + ) + ); + } + + if ( isset( $this->data->$key ) ) { + unset( $this->data->$key ); + } + + if ( isset( self::$back_compat_keys[ $key ] ) ) { + unset( self::$back_compat_keys[ $key ] ); + } + } + + /** + * Determine whether the user exists in the database. + * + * @since 3.4.0 + * + * @return bool True if user exists in the database, false if not. + */ + public function exists() { + return ! empty( $this->ID ); + } + + /** + * Retrieve the value of a property or meta key. + * + * Retrieves from the users and usermeta table. + * + * @since 3.3.0 + * + * @param string $key Property + * @return mixed + */ + public function get( $key ) { + return $this->__get( $key ); + } + + /** + * Determine whether a property or meta key is set + * + * Consults the users and usermeta tables. + * + * @since 3.3.0 + * + * @param string $key Property + * @return bool + */ + public function has_prop( $key ) { + return $this->__isset( $key ); + } + + /** + * Return an array representation. + * + * @since 3.5.0 + * + * @return array Array representation. + */ + public function to_array() { + return get_object_vars( $this->data ); + } + + /** + * Makes private/protected methods readable for backward compatibility. + * + * @since 4.3.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|false Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( '_init_caps' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Set up capability object properties. + * + * Will set the value for the 'cap_key' property to current database table + * prefix, followed by 'capabilities'. Will then check to see if the + * property matching the 'cap_key' exists and is an array. If so, it will be + * used. + * + * @since 2.1.0 + * @deprecated 4.9.0 Use WP_User::for_site() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $cap_key Optional capability key + */ + protected function _init_caps( $cap_key = '' ) { + global $wpdb; + + _deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' ); + + if ( empty( $cap_key ) ) { + $this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities'; + } else { + $this->cap_key = $cap_key; + } + + $this->caps = $this->get_caps_data(); + + $this->get_role_caps(); + } + + /** + * Retrieve all of the role capabilities and merge with individual capabilities. + * + * All of the capabilities of the roles the user belongs to are merged with + * the users individual roles. This also means that the user can be denied + * specific roles that their role might have, but the specific user isn't + * granted permission to. + * + * @since 2.0.0 + * + * @return array List of all capabilities for the user. + */ + public function get_role_caps() { + $switch_site = false; + if ( is_multisite() && $this->site_id != get_current_blog_id() ) { + $switch_site = true; + + switch_to_blog( $this->site_id ); + } + + $wp_roles = wp_roles(); + + //Filter out caps that are not role names and assign to $this->roles + if ( is_array( $this->caps ) ) + $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) ); + + //Build $allcaps from role caps, overlay user's $caps + $this->allcaps = array(); + foreach ( (array) $this->roles as $role ) { + $the_role = $wp_roles->get_role( $role ); + $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities ); + } + $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); + + if ( $switch_site ) { + restore_current_blog(); + } + + return $this->allcaps; + } + + /** + * Add role to user. + * + * Updates the user's meta data option with capabilities and roles. + * + * @since 2.0.0 + * + * @param string $role Role name. + */ + public function add_role( $role ) { + if ( empty( $role ) ) { + return; + } + + $this->caps[$role] = true; + update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + + /** + * Fires immediately after the user has been given a new role. + * + * @since 4.3.0 + * + * @param int $user_id The user ID. + * @param string $role The new role. + */ + do_action( 'add_user_role', $this->ID, $role ); + } + + /** + * Remove role from user. + * + * @since 2.0.0 + * + * @param string $role Role name. + */ + public function remove_role( $role ) { + if ( !in_array($role, $this->roles) ) + return; + unset( $this->caps[$role] ); + update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + + /** + * Fires immediately after a role as been removed from a user. + * + * @since 4.3.0 + * + * @param int $user_id The user ID. + * @param string $role The removed role. + */ + do_action( 'remove_user_role', $this->ID, $role ); + } + + /** + * Set the role of the user. + * + * This will remove the previous roles of the user and assign the user the + * new one. You can set the role to an empty string and it will remove all + * of the roles from the user. + * + * @since 2.0.0 + * + * @param string $role Role name. + */ + public function set_role( $role ) { + if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) + return; + + foreach ( (array) $this->roles as $oldrole ) + unset( $this->caps[$oldrole] ); + + $old_roles = $this->roles; + if ( !empty( $role ) ) { + $this->caps[$role] = true; + $this->roles = array( $role => true ); + } else { + $this->roles = false; + } + update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + + /** + * Fires after the user's role has changed. + * + * @since 2.9.0 + * @since 3.6.0 Added $old_roles to include an array of the user's previous roles. + * + * @param int $user_id The user ID. + * @param string $role The new role. + * @param array $old_roles An array of the user's previous roles. + */ + do_action( 'set_user_role', $this->ID, $role, $old_roles ); + } + + /** + * Choose the maximum level the user has. + * + * Will compare the level from the $item parameter against the $max + * parameter. If the item is incorrect, then just the $max parameter value + * will be returned. + * + * Used to get the max level based on the capabilities the user has. This + * is also based on roles, so if the user is assigned the Administrator role + * then the capability 'level_10' will exist and the user will get that + * value. + * + * @since 2.0.0 + * + * @param int $max Max level of user. + * @param string $item Level capability name. + * @return int Max Level. + */ + public function level_reduction( $max, $item ) { + if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { + $level = intval( $matches[1] ); + return max( $max, $level ); + } else { + return $max; + } + } + + /** + * Update the maximum user level for the user. + * + * Updates the 'user_level' user metadata (includes prefix that is the + * database table prefix) with the maximum user level. Gets the value from + * the all of the capabilities that the user has. + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + public function update_user_level_from_caps() { + global $wpdb; + $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 ); + update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level ); + } + + /** + * Add capability and grant or deny access to capability. + * + * @since 2.0.0 + * + * @param string $cap Capability name. + * @param bool $grant Whether to grant capability to user. + */ + public function add_cap( $cap, $grant = true ) { + $this->caps[$cap] = $grant; + update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + } + + /** + * Remove capability from user. + * + * @since 2.0.0 + * + * @param string $cap Capability name. + */ + public function remove_cap( $cap ) { + if ( ! isset( $this->caps[ $cap ] ) ) { + return; + } + unset( $this->caps[ $cap ] ); + update_user_meta( $this->ID, $this->cap_key, $this->caps ); + $this->get_role_caps(); + $this->update_user_level_from_caps(); + } + + /** + * Remove all of the capabilities of the user. + * + * @since 2.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ + public function remove_all_caps() { + global $wpdb; + $this->caps = array(); + delete_user_meta( $this->ID, $this->cap_key ); + delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' ); + $this->get_role_caps(); + } + + /** + * Whether the user has a specific capability. + * + * While checking against a role in place of a capability is supported in part, this practice is discouraged as it + * may produce unreliable results. + * + * @since 2.0.0 + * + * @see map_meta_cap() + * + * @param string $cap Capability name. + * @param int $object_id,... Optional. ID of a specific object to check against if `$cap` is a "meta" capability. + * Meta capabilities such as `edit_post` and `edit_user` are capabilities used by + * by the `map_meta_cap()` function to map to primitive capabilities that a user or + * role has, such as `edit_posts` and `edit_others_posts`. + * @return bool Whether the user has the given capability, or, if `$object_id` is passed, whether the user has + * the given capability for that object. + */ + public function has_cap( $cap ) { + if ( is_numeric( $cap ) ) { + _deprecated_argument( __FUNCTION__, '2.0.0', __( 'Usage of user levels is deprecated. Use capabilities instead.' ) ); + $cap = $this->translate_level_to_cap( $cap ); + } + + $args = array_slice( func_get_args(), 1 ); + $args = array_merge( array( $cap, $this->ID ), $args ); + $caps = call_user_func_array( 'map_meta_cap', $args ); + + // Multisite super admin has all caps by definition, Unless specifically denied. + if ( is_multisite() && is_super_admin( $this->ID ) ) { + if ( in_array('do_not_allow', $caps) ) + return false; + return true; + } + + /** + * Dynamically filter a user's capabilities. + * + * @since 2.0.0 + * @since 3.7.0 Added the user object. + * + * @param array $allcaps An array of all the user's capabilities. + * @param array $caps Actual capabilities for meta capability. + * @param array $args Optional parameters passed to has_cap(), typically object ID. + * @param WP_User $user The user object. + */ + $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); + + // Everyone is allowed to exist. + $capabilities['exist'] = true; + + // Nobody is allowed to do things they are not allowed to do. + unset( $capabilities['do_not_allow'] ); + + // Must have ALL requested caps. + foreach ( (array) $caps as $cap ) { + if ( empty( $capabilities[ $cap ] ) ) + return false; + } + + return true; + } + + /** + * Convert numeric level to level capability name. + * + * Prepends 'level_' to level number. + * + * @since 2.0.0 + * + * @param int $level Level number, 1 to 10. + * @return string + */ + public function translate_level_to_cap( $level ) { + return 'level_' . $level; + } + + /** + * Set the site to operate on. Defaults to the current site. + * + * @since 3.0.0 + * @deprecated 4.9.0 Use WP_User::for_site() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $blog_id Optional. Site ID, defaults to current site. + */ + public function for_blog( $blog_id = '' ) { + _deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' ); + + $this->for_site( $blog_id ); + } + + /** + * Sets the site to operate on. Defaults to the current site. + * + * @since 4.9.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $site_id Site ID to initialize user capabilities for. Default is the current site. + */ + public function for_site( $site_id = '' ) { + global $wpdb; + + if ( ! empty( $site_id ) ) { + $this->site_id = absint( $site_id ); + } else { + $this->site_id = get_current_blog_id(); + } + + $this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities'; + + $this->caps = $this->get_caps_data(); + + $this->get_role_caps(); + } + + /** + * Gets the ID of the site for which the user's capabilities are currently initialized. + * + * @since 4.9.0 + * + * @return int Site ID. + */ + public function get_site_id() { + return $this->site_id; + } + + /** + * Gets the available user capabilities data. + * + * @since 4.9.0 + * + * @return array User capabilities array. + */ + private function get_caps_data() { + $caps = get_user_meta( $this->ID, $this->cap_key, true ); + + if ( ! is_array( $caps ) ) { + return array(); + } + + return $caps; + } +} diff --git a/backend/wp-includes/class-wp-walker.php b/backend/wp-includes/class-wp-walker.php new file mode 100644 index 0000000..b73ee0d --- /dev/null +++ b/backend/wp-includes/class-wp-walker.php @@ -0,0 +1,425 @@ +<?php +/** + * A class for displaying various tree-like structures. + * + * Extend the Walker class to use it, see examples below. Child classes + * do not need to implement all of the abstract methods in the class. The child + * only needs to implement the methods that are needed. + * + * @since 2.1.0 + * + * @package WordPress + * @abstract + */ +class Walker { + /** + * What the class handles. + * + * @since 2.1.0 + * @var string + */ + public $tree_type; + + /** + * DB fields to use. + * + * @since 2.1.0 + * @var array + */ + public $db_fields; + + /** + * Max number of pages walked by the paged walker + * + * @since 2.7.0 + * @var int + */ + public $max_pages = 1; + + /** + * Whether the current element has children or not. + * + * To be used in start_el(). + * + * @since 4.0.0 + * @var bool + */ + public $has_children; + + /** + * Starts the list before the elements are added. + * + * The $args parameter holds additional values that may be used with the child + * class methods. This method is called at the start of the output list. + * + * @since 2.1.0 + * @abstract + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of the item. + * @param array $args An array of additional arguments. + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) {} + + /** + * Ends the list of after the elements are added. + * + * The $args parameter holds additional values that may be used with the child + * class methods. This method finishes the list at the end of output of the elements. + * + * @since 2.1.0 + * @abstract + * + * @param string $output Used to append additional content (passed by reference). + * @param int $depth Depth of the item. + * @param array $args An array of additional arguments. + */ + public function end_lvl( &$output, $depth = 0, $args = array() ) {} + + /** + * Start the element output. + * + * The $args parameter holds additional values that may be used with the child + * class methods. Includes the element output also. + * + * @since 2.1.0 + * @abstract + * + * @param string $output Used to append additional content (passed by reference). + * @param object $object The data object. + * @param int $depth Depth of the item. + * @param array $args An array of additional arguments. + * @param int $current_object_id ID of the current item. + */ + public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {} + + /** + * Ends the element output, if needed. + * + * The $args parameter holds additional values that may be used with the child class methods. + * + * @since 2.1.0 + * @abstract + * + * @param string $output Used to append additional content (passed by reference). + * @param object $object The data object. + * @param int $depth Depth of the item. + * @param array $args An array of additional arguments. + */ + public function end_el( &$output, $object, $depth = 0, $args = array() ) {} + + /** + * Traverse elements to create list from elements. + * + * Display one element if the element doesn't have any children otherwise, + * display the element and its children. Will only traverse up to the max + * depth and no ignore elements under that depth. It is possible to set the + * max depth to include all depths, see walk() method. + * + * This method should not be called directly, use the walk() method instead. + * + * @since 2.5.0 + * + * @param object $element Data object. + * @param array $children_elements List of elements to continue traversing (passed by reference). + * @param int $max_depth Max depth to traverse. + * @param int $depth Depth of current element. + * @param array $args An array of arguments. + * @param string $output Used to append additional content (passed by reference). + */ + public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { + if ( ! $element ) { + return; + } + + $id_field = $this->db_fields['id']; + $id = $element->$id_field; + + //display this element + $this->has_children = ! empty( $children_elements[ $id ] ); + if ( isset( $args[0] ) && is_array( $args[0] ) ) { + $args[0]['has_children'] = $this->has_children; // Back-compat. + } + + $cb_args = array_merge( array(&$output, $element, $depth), $args); + call_user_func_array(array($this, 'start_el'), $cb_args); + + // descend only when the depth is right and there are childrens for this element + if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { + + foreach ( $children_elements[ $id ] as $child ){ + + if ( !isset($newlevel) ) { + $newlevel = true; + //start the child delimiter + $cb_args = array_merge( array(&$output, $depth), $args); + call_user_func_array(array($this, 'start_lvl'), $cb_args); + } + $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); + } + unset( $children_elements[ $id ] ); + } + + if ( isset($newlevel) && $newlevel ){ + //end the child delimiter + $cb_args = array_merge( array(&$output, $depth), $args); + call_user_func_array(array($this, 'end_lvl'), $cb_args); + } + + //end this element + $cb_args = array_merge( array(&$output, $element, $depth), $args); + call_user_func_array(array($this, 'end_el'), $cb_args); + } + + /** + * Display array of elements hierarchically. + * + * Does not assume any existing order of elements. + * + * $max_depth = -1 means flatly display every element. + * $max_depth = 0 means display all levels. + * $max_depth > 0 specifies the number of display levels. + * + * @since 2.1.0 + * + * @param array $elements An array of elements. + * @param int $max_depth The maximum hierarchical depth. + * @return string The hierarchical item output. + */ + public function walk( $elements, $max_depth ) { + $args = array_slice(func_get_args(), 2); + $output = ''; + + //invalid parameter or nothing to walk + if ( $max_depth < -1 || empty( $elements ) ) { + return $output; + } + + $parent_field = $this->db_fields['parent']; + + // flat display + if ( -1 == $max_depth ) { + $empty_array = array(); + foreach ( $elements as $e ) + $this->display_element( $e, $empty_array, 1, 0, $args, $output ); + return $output; + } + + /* + * Need to display in hierarchical order. + * Separate elements into two buckets: top level and children elements. + * Children_elements is two dimensional array, eg. + * Children_elements[10][] contains all sub-elements whose parent is 10. + */ + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( empty( $e->$parent_field ) ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + + /* + * When none of the elements is top level. + * Assume the first one must be root of the sub elements. + */ + if ( empty($top_level_elements) ) { + + $first = array_slice( $elements, 0, 1 ); + $root = $first[0]; + + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( $root->$parent_field == $e->$parent_field ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + } + + foreach ( $top_level_elements as $e ) + $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); + + /* + * If we are displaying all levels, and remaining children_elements is not empty, + * then we got orphans, which should be displayed regardless. + */ + if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) { + $empty_array = array(); + foreach ( $children_elements as $orphans ) + foreach ( $orphans as $op ) + $this->display_element( $op, $empty_array, 1, 0, $args, $output ); + } + + return $output; + } + + /** + * paged_walk() - produce a page of nested elements + * + * Given an array of hierarchical elements, the maximum depth, a specific page number, + * and number of elements per page, this function first determines all top level root elements + * belonging to that page, then lists them and all of their children in hierarchical order. + * + * $max_depth = 0 means display all levels. + * $max_depth > 0 specifies the number of display levels. + * + * @since 2.7.0 + * + * @param array $elements + * @param int $max_depth The maximum hierarchical depth. + * @param int $page_num The specific page number, beginning with 1. + * @param int $per_page + * @return string XHTML of the specified page of elements + */ + public function paged_walk( $elements, $max_depth, $page_num, $per_page ) { + if ( empty( $elements ) || $max_depth < -1 ) { + return ''; + } + + $args = array_slice( func_get_args(), 4 ); + $output = ''; + + $parent_field = $this->db_fields['parent']; + + $count = -1; + if ( -1 == $max_depth ) + $total_top = count( $elements ); + if ( $page_num < 1 || $per_page < 0 ) { + // No paging + $paging = false; + $start = 0; + if ( -1 == $max_depth ) + $end = $total_top; + $this->max_pages = 1; + } else { + $paging = true; + $start = ( (int)$page_num - 1 ) * (int)$per_page; + $end = $start + $per_page; + if ( -1 == $max_depth ) + $this->max_pages = ceil($total_top / $per_page); + } + + // flat display + if ( -1 == $max_depth ) { + if ( !empty($args[0]['reverse_top_level']) ) { + $elements = array_reverse( $elements ); + $oldstart = $start; + $start = $total_top - $end; + $end = $total_top - $oldstart; + } + + $empty_array = array(); + foreach ( $elements as $e ) { + $count++; + if ( $count < $start ) + continue; + if ( $count >= $end ) + break; + $this->display_element( $e, $empty_array, 1, 0, $args, $output ); + } + return $output; + } + + /* + * Separate elements into two buckets: top level and children elements. + * Children_elements is two dimensional array, e.g. + * $children_elements[10][] contains all sub-elements whose parent is 10. + */ + $top_level_elements = array(); + $children_elements = array(); + foreach ( $elements as $e) { + if ( 0 == $e->$parent_field ) + $top_level_elements[] = $e; + else + $children_elements[ $e->$parent_field ][] = $e; + } + + $total_top = count( $top_level_elements ); + if ( $paging ) + $this->max_pages = ceil($total_top / $per_page); + else + $end = $total_top; + + if ( !empty($args[0]['reverse_top_level']) ) { + $top_level_elements = array_reverse( $top_level_elements ); + $oldstart = $start; + $start = $total_top - $end; + $end = $total_top - $oldstart; + } + if ( !empty($args[0]['reverse_children']) ) { + foreach ( $children_elements as $parent => $children ) + $children_elements[$parent] = array_reverse( $children ); + } + + foreach ( $top_level_elements as $e ) { + $count++; + + // For the last page, need to unset earlier children in order to keep track of orphans. + if ( $end >= $total_top && $count < $start ) + $this->unset_children( $e, $children_elements ); + + if ( $count < $start ) + continue; + + if ( $count >= $end ) + break; + + $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); + } + + if ( $end >= $total_top && count( $children_elements ) > 0 ) { + $empty_array = array(); + foreach ( $children_elements as $orphans ) + foreach ( $orphans as $op ) + $this->display_element( $op, $empty_array, 1, 0, $args, $output ); + } + + return $output; + } + + /** + * Calculates the total number of root elements. + * + * @since 2.7.0 + * + * @param array $elements Elements to list. + * @return int Number of root elements. + */ + public function get_number_of_root_elements( $elements ){ + $num = 0; + $parent_field = $this->db_fields['parent']; + + foreach ( $elements as $e) { + if ( 0 == $e->$parent_field ) + $num++; + } + return $num; + } + + /** + * Unset all the children for a given top level element. + * + * @since 2.7.0 + * + * @param object $e + * @param array $children_elements + */ + public function unset_children( $e, &$children_elements ){ + if ( ! $e || ! $children_elements ) { + return; + } + + $id_field = $this->db_fields['id']; + $id = $e->$id_field; + + if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) ) + foreach ( (array) $children_elements[$id] as $child ) + $this->unset_children( $child, $children_elements ); + + unset( $children_elements[ $id ] ); + } + +} // Walker diff --git a/backend/wp-includes/class-wp-widget-factory.php b/backend/wp-includes/class-wp-widget-factory.php new file mode 100644 index 0000000..1c0f797 --- /dev/null +++ b/backend/wp-includes/class-wp-widget-factory.php @@ -0,0 +1,144 @@ +<?php +/** + * Widget API: WP_Widget_Factory class + * + * @package WordPress + * @subpackage Widgets + * @since 4.4.0 + */ + +/** + * Singleton that registers and instantiates WP_Widget classes. + * + * @since 2.8.0 + * @since 4.4.0 Moved to its own file from wp-includes/widgets.php + */ +class WP_Widget_Factory { + + /** + * Widgets array. + * + * @since 2.8.0 + * @var array + */ + public $widgets = array(); + + /** + * PHP5 constructor. + * + * @since 4.3.0 + */ + public function __construct() { + add_action( 'widgets_init', array( $this, '_register_widgets' ), 100 ); + } + + /** + * PHP4 constructor. + * + * @since 2.8.0 + */ + public function WP_Widget_Factory() { + _deprecated_constructor( 'WP_Widget_Factory', '4.2.0' ); + self::__construct(); + } + + /** + * Memory for the number of times unique class instances have been hashed. + * + * This can be eliminated in favor of straight spl_object_hash() when 5.3 + * is the minimum requirement for PHP. + * + * @since 4.6.0 + * @var array + * + * @see WP_Widget_Factory::hash_object() + */ + private $hashed_class_counts = array(); + + /** + * Hashes an object, doing fallback of `spl_object_hash()` if not available. + * + * This can be eliminated in favor of straight spl_object_hash() when 5.3 + * is the minimum requirement for PHP. + * + * @since 4.6.0 + * + * @param WP_Widget $widget Widget. + * @return string Object hash. + */ + private function hash_object( $widget ) { + if ( function_exists( 'spl_object_hash' ) ) { + return spl_object_hash( $widget ); + } else { + $class_name = get_class( $widget ); + $hash = $class_name; + if ( ! isset( $widget->_wp_widget_factory_hash_id ) ) { + if ( ! isset( $this->hashed_class_counts[ $class_name ] ) ) { + $this->hashed_class_counts[ $class_name ] = 0; + } + $this->hashed_class_counts[ $class_name ] += 1; + $widget->_wp_widget_factory_hash_id = $this->hashed_class_counts[ $class_name ]; + } + $hash .= ':' . $widget->_wp_widget_factory_hash_id; + return $hash; + } + } + + /** + * Registers a widget subclass. + * + * @since 2.8.0 + * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object + * instead of simply a `WP_Widget` subclass name. + * + * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + */ + public function register( $widget ) { + if ( $widget instanceof WP_Widget ) { + $this->widgets[ $this->hash_object( $widget ) ] = $widget; + } else { + $this->widgets[ $widget ] = new $widget(); + } + } + + /** + * Un-registers a widget subclass. + * + * @since 2.8.0 + * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object + * instead of simply a `WP_Widget` subclass name. + * + * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + */ + public function unregister( $widget ) { + if ( $widget instanceof WP_Widget ) { + unset( $this->widgets[ $this->hash_object( $widget ) ] ); + } else { + unset( $this->widgets[ $widget ] ); + } + } + + /** + * Serves as a utility method for adding widgets to the registered widgets global. + * + * @since 2.8.0 + * + * @global array $wp_registered_widgets + */ + public function _register_widgets() { + global $wp_registered_widgets; + $keys = array_keys($this->widgets); + $registered = array_keys($wp_registered_widgets); + $registered = array_map('_get_widget_id_base', $registered); + + foreach ( $keys as $key ) { + // don't register new widget if old widget with the same id is already registered + if ( in_array($this->widgets[$key]->id_base, $registered, true) ) { + unset($this->widgets[$key]); + continue; + } + + $this->widgets[$key]->_register(); + } + } +} diff --git a/backend/wp-includes/class-wp-widget.php b/backend/wp-includes/class-wp-widget.php new file mode 100644 index 0000000..c7da819 --- /dev/null +++ b/backend/wp-includes/class-wp-widget.php @@ -0,0 +1,588 @@ +<?php +/** + * Widget API: WP_Widget base class + * + * @package WordPress + * @subpackage Widgets + * @since 4.4.0 + */ + +/** + * Core base class extended to register widgets. + * + * This class must be extended for each widget, and WP_Widget::widget() must be overridden. + * + * If adding widget options, WP_Widget::update() and WP_Widget::form() should also be overridden. + * + * @since 2.8.0 + * @since 4.4.0 Moved to its own file from wp-includes/widgets.php + */ +class WP_Widget { + + /** + * Root ID for all widgets of this type. + * + * @since 2.8.0 + * @var mixed|string + */ + public $id_base; + + /** + * Name for this widget type. + * + * @since 2.8.0 + * @var string + */ + public $name; + + /** + * Option name for this widget type. + * + * @since 2.8.0 + * @var string + */ + public $option_name; + + /** + * Alt option name for this widget type. + * + * @since 2.8.0 + * @var string + */ + public $alt_option_name; + + /** + * Option array passed to wp_register_sidebar_widget(). + * + * @since 2.8.0 + * @var array + */ + public $widget_options; + + /** + * Option array passed to wp_register_widget_control(). + * + * @since 2.8.0 + * @var array + */ + public $control_options; + + /** + * Unique ID number of the current instance. + * + * @since 2.8.0 + * @var bool|int + */ + public $number = false; + + /** + * Unique ID string of the current instance (id_base-number). + * + * @since 2.8.0 + * @var bool|string + */ + public $id = false; + + /** + * Whether the widget data has been updated. + * + * Set to true when the data is updated after a POST submit - ensures it does + * not happen twice. + * + * @since 2.8.0 + * @var bool + */ + public $updated = false; + + // + // Member functions that must be overridden by subclasses. + // + + /** + * Echoes the widget content. + * + * Sub-classes should over-ride this function to generate their widget code. + * + * @since 2.8.0 + * + * @param array $args Display arguments including 'before_title', 'after_title', + * 'before_widget', and 'after_widget'. + * @param array $instance The settings for the particular instance of the widget. + */ + public function widget( $args, $instance ) { + die('function WP_Widget::widget() must be over-ridden in a sub-class.'); + } + + /** + * Updates a particular instance of a widget. + * + * This function should check that `$new_instance` is set correctly. The newly-calculated + * value of `$instance` should be returned. If false is returned, the instance won't be + * saved/updated. + * + * @since 2.8.0 + * + * @param array $new_instance New settings for this instance as input by the user via + * WP_Widget::form(). + * @param array $old_instance Old settings for this instance. + * @return array Settings to save or bool false to cancel saving. + */ + public function update( $new_instance, $old_instance ) { + return $new_instance; + } + + /** + * Outputs the settings update form. + * + * @since 2.8.0 + * + * @param array $instance Current settings. + * @return string Default return is 'noform'. + */ + public function form( $instance ) { + echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>'; + return 'noform'; + } + + // Functions you'll need to call. + + /** + * PHP5 constructor. + * + * @since 2.8.0 + * + * @param string $id_base Optional Base ID for the widget, lowercase and unique. If left empty, + * a portion of the widget's class name will be used Has to be unique. + * @param string $name Name for the widget displayed on the configuration page. + * @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for information + * on accepted arguments. Default empty array. + * @param array $control_options Optional. Widget control options. See wp_register_widget_control() for + * information on accepted arguments. Default empty array. + */ + public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) { + $this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base); + $this->name = $name; + $this->option_name = 'widget_' . $this->id_base; + $this->widget_options = wp_parse_args( $widget_options, array( 'classname' => $this->option_name, 'customize_selective_refresh' => false ) ); + $this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) ); + } + + /** + * PHP4 constructor. + * + * @since 2.8.0 + * + * @see __construct() + * + * @param string $id_base Optional Base ID for the widget, lowercase and unique. If left empty, + * a portion of the widget's class name will be used Has to be unique. + * @param string $name Name for the widget displayed on the configuration page. + * @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for information + * on accepted arguments. Default empty array. + * @param array $control_options Optional. Widget control options. See wp_register_widget_control() for + * information on accepted arguments. Default empty array. + */ + public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) { + _deprecated_constructor( 'WP_Widget', '4.3.0', get_class( $this ) ); + WP_Widget::__construct( $id_base, $name, $widget_options, $control_options ); + } + + /** + * Constructs name attributes for use in form() fields + * + * This function should be used in form() methods to create name attributes for fields + * to be saved by update() + * + * @since 2.8.0 + * @since 4.4.0 Array format field names are now accepted. + * + * @param string $field_name Field name + * @return string Name attribute for $field_name + */ + public function get_field_name($field_name) { + if ( false === $pos = strpos( $field_name, '[' ) ) { + return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'; + } else { + return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) ); + } + } + + /** + * Constructs id attributes for use in WP_Widget::form() fields. + * + * This function should be used in form() methods to create id attributes + * for fields to be saved by WP_Widget::update(). + * + * @since 2.8.0 + * @since 4.4.0 Array format field IDs are now accepted. + * + * @param string $field_name Field name. + * @return string ID attribute for `$field_name`. + */ + public function get_field_id( $field_name ) { + return 'widget-' . $this->id_base . '-' . $this->number . '-' . trim( str_replace( array( '[]', '[', ']' ), array( '', '-', '' ), $field_name ), '-' ); + } + + /** + * Register all widget instances of this widget class. + * + * @since 2.8.0 + */ + public function _register() { + $settings = $this->get_settings(); + $empty = true; + + // When $settings is an array-like object, get an intrinsic array for use with array_keys(). + if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) { + $settings = $settings->getArrayCopy(); + } + + if ( is_array( $settings ) ) { + foreach ( array_keys( $settings ) as $number ) { + if ( is_numeric( $number ) ) { + $this->_set( $number ); + $this->_register_one( $number ); + $empty = false; + } + } + } + + if ( $empty ) { + // If there are none, we register the widget's existence with a generic template. + $this->_set( 1 ); + $this->_register_one(); + } + } + + /** + * Sets the internal order number for the widget instance. + * + * @since 2.8.0 + * + * @param int $number The unique order number of this widget instance compared to other + * instances of the same class. + */ + public function _set($number) { + $this->number = $number; + $this->id = $this->id_base . '-' . $number; + } + + /** + * Retrieves the widget display callback. + * + * @since 2.8.0 + * + * @return callable Display callback. + */ + public function _get_display_callback() { + return array($this, 'display_callback'); + } + + /** + * Retrieves the widget update callback. + * + * @since 2.8.0 + * + * @return callable Update callback. + */ + public function _get_update_callback() { + return array($this, 'update_callback'); + } + + /** + * Retrieves the form callback. + * + * @since 2.8.0 + * + * @return callable Form callback. + */ + public function _get_form_callback() { + return array($this, 'form_callback'); + } + + /** + * Determines whether the current request is inside the Customizer preview. + * + * If true -- the current request is inside the Customizer preview, then + * the object cache gets suspended and widgets should check this to decide + * whether they should store anything persistently to the object cache, + * to transients, or anywhere else. + * + * @since 3.9.0 + * + * @global WP_Customize_Manager $wp_customize + * + * @return bool True if within the Customizer preview, false if not. + */ + public function is_preview() { + global $wp_customize; + return ( isset( $wp_customize ) && $wp_customize->is_preview() ) ; + } + + /** + * Generates the actual widget content (Do NOT override). + * + * Finds the instance and calls WP_Widget::widget(). + * + * @since 2.8.0 + * + * @param array $args Display arguments. See WP_Widget::widget() for information + * on accepted arguments. + * @param int|array $widget_args { + * Optional. Internal order number of the widget instance, or array of multi-widget arguments. + * Default 1. + * + * @type int $number Number increment used for multiples of the same widget. + * } + */ + public function display_callback( $args, $widget_args = 1 ) { + if ( is_numeric( $widget_args ) ) { + $widget_args = array( 'number' => $widget_args ); + } + + $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); + $this->_set( $widget_args['number'] ); + $instances = $this->get_settings(); + + if ( array_key_exists( $this->number, $instances ) ) { + $instance = $instances[ $this->number ]; + + /** + * Filters the settings for a particular widget instance. + * + * Returning false will effectively short-circuit display of the widget. + * + * @since 2.8.0 + * + * @param array $instance The current widget instance's settings. + * @param WP_Widget $this The current widget instance. + * @param array $args An array of default widget arguments. + */ + $instance = apply_filters( 'widget_display_callback', $instance, $this, $args ); + + if ( false === $instance ) { + return; + } + + $was_cache_addition_suspended = wp_suspend_cache_addition(); + if ( $this->is_preview() && ! $was_cache_addition_suspended ) { + wp_suspend_cache_addition( true ); + } + + $this->widget( $args, $instance ); + + if ( $this->is_preview() ) { + wp_suspend_cache_addition( $was_cache_addition_suspended ); + } + } + } + + /** + * Handles changed settings (Do NOT override). + * + * @since 2.8.0 + * + * @global array $wp_registered_widgets + * + * @param int $deprecated Not used. + */ + public function update_callback( $deprecated = 1 ) { + global $wp_registered_widgets; + + $all_instances = $this->get_settings(); + + // We need to update the data + if ( $this->updated ) + return; + + if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) { + // Delete the settings for this instance of the widget + if ( isset($_POST['the-widget-id']) ) + $del_id = $_POST['the-widget-id']; + else + return; + + if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) { + $number = $wp_registered_widgets[$del_id]['params'][0]['number']; + + if ( $this->id_base . '-' . $number == $del_id ) + unset($all_instances[$number]); + } + } else { + if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) { + $settings = $_POST['widget-' . $this->id_base]; + } elseif ( isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base ) { + $num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number']; + $settings = array( $num => array() ); + } else { + return; + } + + foreach ( $settings as $number => $new_instance ) { + $new_instance = stripslashes_deep($new_instance); + $this->_set($number); + + $old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array(); + + $was_cache_addition_suspended = wp_suspend_cache_addition(); + if ( $this->is_preview() && ! $was_cache_addition_suspended ) { + wp_suspend_cache_addition( true ); + } + + $instance = $this->update( $new_instance, $old_instance ); + + if ( $this->is_preview() ) { + wp_suspend_cache_addition( $was_cache_addition_suspended ); + } + + /** + * Filters a widget's settings before saving. + * + * Returning false will effectively short-circuit the widget's ability + * to update settings. + * + * @since 2.8.0 + * + * @param array $instance The current widget instance's settings. + * @param array $new_instance Array of new widget settings. + * @param array $old_instance Array of old widget settings. + * @param WP_Widget $this The current widget instance. + */ + $instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this ); + if ( false !== $instance ) { + $all_instances[$number] = $instance; + } + + break; // run only once + } + } + + $this->save_settings($all_instances); + $this->updated = true; + } + + /** + * Generates the widget control form (Do NOT override). + * + * @since 2.8.0 + * + * @param int|array $widget_args { + * Optional. Internal order number of the widget instance, or array of multi-widget arguments. + * Default 1. + * + * @type int $number Number increment used for multiples of the same widget. + * } + * @return string|null + */ + public function form_callback( $widget_args = 1 ) { + if ( is_numeric($widget_args) ) + $widget_args = array( 'number' => $widget_args ); + + $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); + $all_instances = $this->get_settings(); + + if ( -1 == $widget_args['number'] ) { + // We echo out a form where 'number' can be set later + $this->_set('__i__'); + $instance = array(); + } else { + $this->_set($widget_args['number']); + $instance = $all_instances[ $widget_args['number'] ]; + } + + /** + * Filters the widget instance's settings before displaying the control form. + * + * Returning false effectively short-circuits display of the control form. + * + * @since 2.8.0 + * + * @param array $instance The current widget instance's settings. + * @param WP_Widget $this The current widget instance. + */ + $instance = apply_filters( 'widget_form_callback', $instance, $this ); + + $return = null; + if ( false !== $instance ) { + $return = $this->form($instance); + + /** + * Fires at the end of the widget control form. + * + * Use this hook to add extra fields to the widget form. The hook + * is only fired if the value passed to the 'widget_form_callback' + * hook is not false. + * + * Note: If the widget has no form, the text echoed from the default + * form method can be hidden using CSS. + * + * @since 2.8.0 + * + * @param WP_Widget $this The widget instance (passed by reference). + * @param null $return Return null if new fields are added. + * @param array $instance An array of the widget's settings. + */ + do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) ); + } + return $return; + } + + /** + * Registers an instance of the widget class. + * + * @since 2.8.0 + * + * @param integer $number Optional. The unique order number of this widget instance + * compared to other instances of the same class. Default -1. + */ + public function _register_one( $number = -1 ) { + wp_register_sidebar_widget( $this->id, $this->name, $this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) ); + _register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) ); + _register_widget_form_callback( $this->id, $this->name, $this->_get_form_callback(), $this->control_options, array( 'number' => $number ) ); + } + + /** + * Saves the settings for all instances of the widget class. + * + * @since 2.8.0 + * + * @param array $settings Multi-dimensional array of widget instance settings. + */ + public function save_settings( $settings ) { + $settings['_multiwidget'] = 1; + update_option( $this->option_name, $settings ); + } + + /** + * Retrieves the settings for all instances of the widget class. + * + * @since 2.8.0 + * + * @return array Multi-dimensional array of widget instance settings. + */ + public function get_settings() { + + $settings = get_option( $this->option_name ); + + if ( false === $settings ) { + if ( isset( $this->alt_option_name ) ) { + $settings = get_option( $this->alt_option_name ); + } else { + // Save an option so it can be autoloaded next time. + $this->save_settings( array() ); + } + } + + if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) { + $settings = array(); + } + + if ( ! empty( $settings ) && ! isset( $settings['_multiwidget'] ) ) { + // Old format, convert if single widget. + $settings = wp_convert_widget_settings( $this->id_base, $this->option_name, $settings ); + } + + unset( $settings['_multiwidget'], $settings['__i__'] ); + return $settings; + } +} diff --git a/backend/wp-includes/class-wp-xmlrpc-server.php b/backend/wp-includes/class-wp-xmlrpc-server.php new file mode 100644 index 0000000..826f2ef --- /dev/null +++ b/backend/wp-includes/class-wp-xmlrpc-server.php @@ -0,0 +1,6573 @@ +<?php +/** + * XML-RPC protocol support for WordPress + * + * @package WordPress + * @subpackage Publishing + */ + +/** + * WordPress XMLRPC server implementation. + * + * Implements compatibility for Blogger API, MetaWeblog API, MovableType, and + * pingback. Additional WordPress API for managing comments, pages, posts, + * options, etc. + * + * As of WordPress 3.5.0, XML-RPC is enabled by default. It can be disabled + * via the {@see 'xmlrpc_enabled'} filter found in wp_xmlrpc_server::login(). + * + * @since 1.5.0 + * + * @see IXR_Server + */ +class wp_xmlrpc_server extends IXR_Server { + /** + * Methods. + * + * @var array + */ + public $methods; + + /** + * Blog options. + * + * @var array + */ + public $blog_options; + + /** + * IXR_Error instance. + * + * @var IXR_Error + */ + public $error; + + /** + * Flags that the user authentication has failed in this instance of wp_xmlrpc_server. + * + * @var bool + */ + protected $auth_failed = false; + + /** + * Registers all of the XMLRPC methods that XMLRPC server understands. + * + * Sets up server and method property. Passes XMLRPC + * methods through the {@see 'xmlrpc_methods'} filter to allow plugins to extend + * or replace XML-RPC methods. + * + * @since 1.5.0 + */ + public function __construct() { + $this->methods = array( + // WordPress API + 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs', + 'wp.newPost' => 'this:wp_newPost', + 'wp.editPost' => 'this:wp_editPost', + 'wp.deletePost' => 'this:wp_deletePost', + 'wp.getPost' => 'this:wp_getPost', + 'wp.getPosts' => 'this:wp_getPosts', + 'wp.newTerm' => 'this:wp_newTerm', + 'wp.editTerm' => 'this:wp_editTerm', + 'wp.deleteTerm' => 'this:wp_deleteTerm', + 'wp.getTerm' => 'this:wp_getTerm', + 'wp.getTerms' => 'this:wp_getTerms', + 'wp.getTaxonomy' => 'this:wp_getTaxonomy', + 'wp.getTaxonomies' => 'this:wp_getTaxonomies', + 'wp.getUser' => 'this:wp_getUser', + 'wp.getUsers' => 'this:wp_getUsers', + 'wp.getProfile' => 'this:wp_getProfile', + 'wp.editProfile' => 'this:wp_editProfile', + 'wp.getPage' => 'this:wp_getPage', + 'wp.getPages' => 'this:wp_getPages', + 'wp.newPage' => 'this:wp_newPage', + 'wp.deletePage' => 'this:wp_deletePage', + 'wp.editPage' => 'this:wp_editPage', + 'wp.getPageList' => 'this:wp_getPageList', + 'wp.getAuthors' => 'this:wp_getAuthors', + 'wp.getCategories' => 'this:mw_getCategories', // Alias + 'wp.getTags' => 'this:wp_getTags', + 'wp.newCategory' => 'this:wp_newCategory', + 'wp.deleteCategory' => 'this:wp_deleteCategory', + 'wp.suggestCategories' => 'this:wp_suggestCategories', + 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias + 'wp.deleteFile' => 'this:wp_deletePost', // Alias + 'wp.getCommentCount' => 'this:wp_getCommentCount', + 'wp.getPostStatusList' => 'this:wp_getPostStatusList', + 'wp.getPageStatusList' => 'this:wp_getPageStatusList', + 'wp.getPageTemplates' => 'this:wp_getPageTemplates', + 'wp.getOptions' => 'this:wp_getOptions', + 'wp.setOptions' => 'this:wp_setOptions', + 'wp.getComment' => 'this:wp_getComment', + 'wp.getComments' => 'this:wp_getComments', + 'wp.deleteComment' => 'this:wp_deleteComment', + 'wp.editComment' => 'this:wp_editComment', + 'wp.newComment' => 'this:wp_newComment', + 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList', + 'wp.getMediaItem' => 'this:wp_getMediaItem', + 'wp.getMediaLibrary' => 'this:wp_getMediaLibrary', + 'wp.getPostFormats' => 'this:wp_getPostFormats', + 'wp.getPostType' => 'this:wp_getPostType', + 'wp.getPostTypes' => 'this:wp_getPostTypes', + 'wp.getRevisions' => 'this:wp_getRevisions', + 'wp.restoreRevision' => 'this:wp_restoreRevision', + + // Blogger API + 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', + 'blogger.getUserInfo' => 'this:blogger_getUserInfo', + 'blogger.getPost' => 'this:blogger_getPost', + 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts', + 'blogger.newPost' => 'this:blogger_newPost', + 'blogger.editPost' => 'this:blogger_editPost', + 'blogger.deletePost' => 'this:blogger_deletePost', + + // MetaWeblog API (with MT extensions to structs) + 'metaWeblog.newPost' => 'this:mw_newPost', + 'metaWeblog.editPost' => 'this:mw_editPost', + 'metaWeblog.getPost' => 'this:mw_getPost', + 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts', + 'metaWeblog.getCategories' => 'this:mw_getCategories', + 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', + + // MetaWeblog API aliases for Blogger API + // see http://www.xmlrpc.com/stories/storyReader$2460 + 'metaWeblog.deletePost' => 'this:blogger_deletePost', + 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', + + // MovableType API + 'mt.getCategoryList' => 'this:mt_getCategoryList', + 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', + 'mt.getPostCategories' => 'this:mt_getPostCategories', + 'mt.setPostCategories' => 'this:mt_setPostCategories', + 'mt.supportedMethods' => 'this:mt_supportedMethods', + 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters', + 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', + 'mt.publishPost' => 'this:mt_publishPost', + + // PingBack + 'pingback.ping' => 'this:pingback_ping', + 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', + + 'demo.sayHello' => 'this:sayHello', + 'demo.addTwoNumbers' => 'this:addTwoNumbers' + ); + + $this->initialise_blog_option_info(); + + /** + * Filters the methods exposed by the XML-RPC server. + * + * This filter can be used to add new methods, and remove built-in methods. + * + * @since 1.5.0 + * + * @param array $methods An array of XML-RPC methods. + */ + $this->methods = apply_filters( 'xmlrpc_methods', $this->methods ); + } + + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param callable $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return array|IXR_Error|false Return value of the callback, false otherwise. + */ + public function __call( $name, $arguments ) { + if ( '_multisite_getUsersBlogs' === $name ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } + return false; + } + + /** + * Serves the XML-RPC request. + * + * @since 2.9.0 + */ + public function serve_request() { + $this->IXR_Server($this->methods); + } + + /** + * Test XMLRPC API by saying, "Hello!" to client. + * + * @since 1.5.0 + * + * @return string Hello string response. + */ + public function sayHello() { + return 'Hello!'; + } + + /** + * Test XMLRPC API by adding two numbers for client. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $number1 A number to add. + * @type int $number2 A second number to add. + * } + * @return int Sum of the two given numbers. + */ + public function addTwoNumbers( $args ) { + $number1 = $args[0]; + $number2 = $args[1]; + return $number1 + $number2; + } + + /** + * Log user in. + * + * @since 2.8.0 + * + * @param string $username User's username. + * @param string $password User's password. + * @return WP_User|bool WP_User object if authentication passed, false otherwise + */ + public function login( $username, $password ) { + /* + * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc' + * option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead. + */ + $enabled = apply_filters( 'pre_option_enable_xmlrpc', false ); + if ( false === $enabled ) { + $enabled = apply_filters( 'option_enable_xmlrpc', true ); + } + + /** + * Filters whether XML-RPC methods requiring authentication are enabled. + * + * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully* + * enabled, rather, it only controls whether XML-RPC methods requiring authentication - such + * as for publishing purposes - are enabled. + * + * Further, the filter does not control whether pingbacks or other custom endpoints that don't + * require authentication are enabled. This behavior is expected, and due to how parity was matched + * with the `enable_xmlrpc` UI option the filter replaced when it was introduced in 3.5. + * + * To disable XML-RPC methods that require authentication, use: + * + * add_filter( 'xmlrpc_enabled', '__return_false' ); + * + * For more granular control over all XML-RPC methods and requests, see the {@see 'xmlrpc_methods'} + * and {@see 'xmlrpc_element_limit'} hooks. + * + * @since 3.5.0 + * + * @param bool $enabled Whether XML-RPC is enabled. Default true. + */ + $enabled = apply_filters( 'xmlrpc_enabled', $enabled ); + + if ( ! $enabled ) { + $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) ); + return false; + } + + if ( $this->auth_failed ) { + $user = new WP_Error( 'login_prevented' ); + } else { + $user = wp_authenticate( $username, $password ); + } + + if ( is_wp_error( $user ) ) { + $this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) ); + + // Flag that authentication has failed once on this wp_xmlrpc_server instance + $this->auth_failed = true; + + /** + * Filters the XML-RPC user login error message. + * + * @since 3.5.0 + * + * @param string $error The XML-RPC error message. + * @param WP_User $user WP_User object. + */ + $this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user ); + return false; + } + + wp_set_current_user( $user->ID ); + return $user; + } + + /** + * Check user's credentials. Deprecated. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use wp_xmlrpc_server::login() + * @see wp_xmlrpc_server::login() + * + * @param string $username User's username. + * @param string $password User's password. + * @return bool Whether authentication passed. + */ + public function login_pass_ok( $username, $password ) { + return (bool) $this->login( $username, $password ); + } + + /** + * Escape string or array of strings for database. + * + * @since 1.5.2 + * + * @param string|array $data Escape single string or array of strings. + * @return string|void Returns with string is passed, alters by-reference + * when array is passed. + */ + public function escape( &$data ) { + if ( ! is_array( $data ) ) + return wp_slash( $data ); + + foreach ( $data as &$v ) { + if ( is_array( $v ) ) + $this->escape( $v ); + elseif ( ! is_object( $v ) ) + $v = wp_slash( $v ); + } + } + + /** + * Retrieve custom fields for post. + * + * @since 2.5.0 + * + * @param int $post_id Post ID. + * @return array Custom fields, if exist. + */ + public function get_custom_fields($post_id) { + $post_id = (int) $post_id; + + $custom_fields = array(); + + foreach ( (array) has_meta($post_id) as $meta ) { + // Don't expose protected fields. + if ( ! current_user_can( 'edit_post_meta', $post_id , $meta['meta_key'] ) ) + continue; + + $custom_fields[] = array( + "id" => $meta['meta_id'], + "key" => $meta['meta_key'], + "value" => $meta['meta_value'] + ); + } + + return $custom_fields; + } + + /** + * Set custom fields for post. + * + * @since 2.5.0 + * + * @param int $post_id Post ID. + * @param array $fields Custom fields. + */ + public function set_custom_fields($post_id, $fields) { + $post_id = (int) $post_id; + + foreach ( (array) $fields as $meta ) { + if ( isset($meta['id']) ) { + $meta['id'] = (int) $meta['id']; + $pmeta = get_metadata_by_mid( 'post', $meta['id'] ); + + if ( ! $pmeta || $pmeta->post_id != $post_id ) { + continue; + } + + if ( isset($meta['key']) ) { + $meta['key'] = wp_unslash( $meta['key'] ); + if ( $meta['key'] !== $pmeta->meta_key ) + continue; + $meta['value'] = wp_unslash( $meta['value'] ); + if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) ) + update_metadata_by_mid( 'post', $meta['id'], $meta['value'] ); + } elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) { + delete_metadata_by_mid( 'post', $meta['id'] ); + } + } elseif ( current_user_can( 'add_post_meta', $post_id, wp_unslash( $meta['key'] ) ) ) { + add_post_meta( $post_id, $meta['key'], $meta['value'] ); + } + } + } + + /** + * Retrieve custom fields for a term. + * + * @since 4.9.0 + * + * @param int $term_id Term ID. + * @return array Array of custom fields, if they exist. + */ + public function get_term_custom_fields( $term_id ) { + $term_id = (int) $term_id; + + $custom_fields = array(); + + foreach ( (array) has_term_meta( $term_id ) as $meta ) { + + if ( ! current_user_can( 'edit_term_meta', $term_id ) ) { + continue; + } + + $custom_fields[] = array( + 'id' => $meta['meta_id'], + 'key' => $meta['meta_key'], + 'value' => $meta['meta_value'], + ); + } + + return $custom_fields; + } + + /** + * Set custom fields for a term. + * + * @since 4.9.0 + * + * @param int $term_id Term ID. + * @param array $fields Custom fields. + */ + public function set_term_custom_fields( $term_id, $fields ) { + $term_id = (int) $term_id; + + foreach ( (array) $fields as $meta ) { + if ( isset( $meta['id'] ) ) { + $meta['id'] = (int) $meta['id']; + $pmeta = get_metadata_by_mid( 'term', $meta['id'] ); + if ( isset( $meta['key'] ) ) { + $meta['key'] = wp_unslash( $meta['key'] ); + if ( $meta['key'] !== $pmeta->meta_key ) { + continue; + } + $meta['value'] = wp_unslash( $meta['value'] ); + if ( current_user_can( 'edit_term_meta', $term_id ) ) { + update_metadata_by_mid( 'term', $meta['id'], $meta['value'] ); + } + } elseif ( current_user_can( 'delete_term_meta', $term_id ) ) { + delete_metadata_by_mid( 'term', $meta['id'] ); + } + } elseif ( current_user_can( 'add_term_meta', $term_id ) ) { + add_term_meta( $term_id, $meta['key'], $meta['value'] ); + } + } + } + + /** + * Set up blog options property. + * + * Passes property through {@see 'xmlrpc_blog_options'} filter. + * + * @since 2.6.0 + */ + public function initialise_blog_option_info() { + $this->blog_options = array( + // Read only options + 'software_name' => array( + 'desc' => __( 'Software Name' ), + 'readonly' => true, + 'value' => 'WordPress' + ), + 'software_version' => array( + 'desc' => __( 'Software Version' ), + 'readonly' => true, + 'value' => get_bloginfo( 'version' ) + ), + 'blog_url' => array( + 'desc' => __( 'WordPress Address (URL)' ), + 'readonly' => true, + 'option' => 'siteurl' + ), + 'home_url' => array( + 'desc' => __( 'Site Address (URL)' ), + 'readonly' => true, + 'option' => 'home' + ), + 'login_url' => array( + 'desc' => __( 'Login Address (URL)' ), + 'readonly' => true, + 'value' => wp_login_url( ) + ), + 'admin_url' => array( + 'desc' => __( 'The URL to the admin area' ), + 'readonly' => true, + 'value' => get_admin_url( ) + ), + 'image_default_link_type' => array( + 'desc' => __( 'Image default link type' ), + 'readonly' => true, + 'option' => 'image_default_link_type' + ), + 'image_default_size' => array( + 'desc' => __( 'Image default size' ), + 'readonly' => true, + 'option' => 'image_default_size' + ), + 'image_default_align' => array( + 'desc' => __( 'Image default align' ), + 'readonly' => true, + 'option' => 'image_default_align' + ), + 'template' => array( + 'desc' => __( 'Template' ), + 'readonly' => true, + 'option' => 'template' + ), + 'stylesheet' => array( + 'desc' => __( 'Stylesheet' ), + 'readonly' => true, + 'option' => 'stylesheet' + ), + 'post_thumbnail' => array( + 'desc' => __('Post Thumbnail'), + 'readonly' => true, + 'value' => current_theme_supports( 'post-thumbnails' ) + ), + + // Updatable options + 'time_zone' => array( + 'desc' => __( 'Time Zone' ), + 'readonly' => false, + 'option' => 'gmt_offset' + ), + 'blog_title' => array( + 'desc' => __( 'Site Title' ), + 'readonly' => false, + 'option' => 'blogname' + ), + 'blog_tagline' => array( + 'desc' => __( 'Site Tagline' ), + 'readonly' => false, + 'option' => 'blogdescription' + ), + 'date_format' => array( + 'desc' => __( 'Date Format' ), + 'readonly' => false, + 'option' => 'date_format' + ), + 'time_format' => array( + 'desc' => __( 'Time Format' ), + 'readonly' => false, + 'option' => 'time_format' + ), + 'users_can_register' => array( + 'desc' => __( 'Allow new users to sign up' ), + 'readonly' => false, + 'option' => 'users_can_register' + ), + 'thumbnail_size_w' => array( + 'desc' => __( 'Thumbnail Width' ), + 'readonly' => false, + 'option' => 'thumbnail_size_w' + ), + 'thumbnail_size_h' => array( + 'desc' => __( 'Thumbnail Height' ), + 'readonly' => false, + 'option' => 'thumbnail_size_h' + ), + 'thumbnail_crop' => array( + 'desc' => __( 'Crop thumbnail to exact dimensions' ), + 'readonly' => false, + 'option' => 'thumbnail_crop' + ), + 'medium_size_w' => array( + 'desc' => __( 'Medium size image width' ), + 'readonly' => false, + 'option' => 'medium_size_w' + ), + 'medium_size_h' => array( + 'desc' => __( 'Medium size image height' ), + 'readonly' => false, + 'option' => 'medium_size_h' + ), + 'medium_large_size_w' => array( + 'desc' => __( 'Medium-Large size image width' ), + 'readonly' => false, + 'option' => 'medium_large_size_w' + ), + 'medium_large_size_h' => array( + 'desc' => __( 'Medium-Large size image height' ), + 'readonly' => false, + 'option' => 'medium_large_size_h' + ), + 'large_size_w' => array( + 'desc' => __( 'Large size image width' ), + 'readonly' => false, + 'option' => 'large_size_w' + ), + 'large_size_h' => array( + 'desc' => __( 'Large size image height' ), + 'readonly' => false, + 'option' => 'large_size_h' + ), + 'default_comment_status' => array( + 'desc' => __( 'Allow people to post comments on new articles' ), + 'readonly' => false, + 'option' => 'default_comment_status' + ), + 'default_ping_status' => array( + 'desc' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles' ), + 'readonly' => false, + 'option' => 'default_ping_status' + ) + ); + + /** + * Filters the XML-RPC blog options property. + * + * @since 2.6.0 + * + * @param array $blog_options An array of XML-RPC blog options. + */ + $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options ); + } + + /** + * Retrieve the blogs of the user. + * + * @since 2.6.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type string $username Username. + * @type string $password Password. + * } + * @return array|IXR_Error Array contains: + * - 'isAdmin' + * - 'isPrimary' - whether the blog is the user's primary blog + * - 'url' + * - 'blogid' + * - 'blogName' + * - 'xmlrpc' - url of xmlrpc endpoint + */ + public function wp_getUsersBlogs( $args ) { + if ( ! $this->minimum_args( $args, 2 ) ) { + return $this->error; + } + + // If this isn't on WPMU then just use blogger_getUsersBlogs + if ( !is_multisite() ) { + array_unshift( $args, 1 ); + return $this->blogger_getUsersBlogs( $args ); + } + + $this->escape( $args ); + + $username = $args[0]; + $password = $args[1]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** + * Fires after the XML-RPC user has been authenticated but before the rest of + * the method logic begins. + * + * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter + * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc. + * + * @since 2.5.0 + * + * @param string $name The method name. + */ + do_action( 'xmlrpc_call', 'wp.getUsersBlogs' ); + + $blogs = (array) get_blogs_of_user( $user->ID ); + $struct = array(); + $primary_blog_id = 0; + $active_blog = get_active_blog_for_user( $user->ID ); + if ( $active_blog ) { + $primary_blog_id = (int) $active_blog->blog_id; + } + + foreach ( $blogs as $blog ) { + // Don't include blogs that aren't hosted at this site. + if ( $blog->site_id != get_current_network_id() ) + continue; + + $blog_id = $blog->userblog_id; + + switch_to_blog( $blog_id ); + + $is_admin = current_user_can( 'manage_options' ); + $is_primary = ( (int) $blog_id === $primary_blog_id ); + + $struct[] = array( + 'isAdmin' => $is_admin, + 'isPrimary' => $is_primary, + 'url' => home_url( '/' ), + 'blogid' => (string) $blog_id, + 'blogName' => get_option( 'blogname' ), + 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), + ); + + restore_current_blog(); + } + + return $struct; + } + + /** + * Checks if the method received at least the minimum number of arguments. + * + * @since 3.4.0 + * + * @param string|array $args Sanitize single string or array of strings. + * @param int $count Minimum number of arguments. + * @return bool if `$args` contains at least $count arguments. + */ + protected function minimum_args( $args, $count ) { + if ( count( $args ) < $count ) { + $this->error = new IXR_Error( 400, __( 'Insufficient arguments passed to this XML-RPC method.' ) ); + return false; + } + + return true; + } + + /** + * Prepares taxonomy data for return in an XML-RPC object. + * + * + * @param object $taxonomy The unprepared taxonomy data. + * @param array $fields The subset of taxonomy fields to return. + * @return array The prepared taxonomy data. + */ + protected function _prepare_taxonomy( $taxonomy, $fields ) { + $_taxonomy = array( + 'name' => $taxonomy->name, + 'label' => $taxonomy->label, + 'hierarchical' => (bool) $taxonomy->hierarchical, + 'public' => (bool) $taxonomy->public, + 'show_ui' => (bool) $taxonomy->show_ui, + '_builtin' => (bool) $taxonomy->_builtin, + ); + + if ( in_array( 'labels', $fields ) ) + $_taxonomy['labels'] = (array) $taxonomy->labels; + + if ( in_array( 'cap', $fields ) ) + $_taxonomy['cap'] = (array) $taxonomy->cap; + + if ( in_array( 'menu', $fields ) ) + $_taxonomy['show_in_menu'] = (bool) $_taxonomy->show_in_menu; + + if ( in_array( 'object_type', $fields ) ) + $_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type ); + + /** + * Filters XML-RPC-prepared data for the given taxonomy. + * + * @since 3.4.0 + * + * @param array $_taxonomy An array of taxonomy data. + * @param WP_Taxonomy $taxonomy Taxonomy object. + * @param array $fields The subset of taxonomy fields to return. + */ + return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields ); + } + + /** + * Prepares term data for return in an XML-RPC object. + * + * + * @param array|object $term The unprepared term data. + * @return array The prepared term data. + */ + protected function _prepare_term( $term ) { + $_term = $term; + if ( ! is_array( $_term ) ) + $_term = get_object_vars( $_term ); + + // For integers which may be larger than XML-RPC supports ensure we return strings. + $_term['term_id'] = strval( $_term['term_id'] ); + $_term['term_group'] = strval( $_term['term_group'] ); + $_term['term_taxonomy_id'] = strval( $_term['term_taxonomy_id'] ); + $_term['parent'] = strval( $_term['parent'] ); + + // Count we are happy to return as an integer because people really shouldn't use terms that much. + $_term['count'] = intval( $_term['count'] ); + + // Get term meta. + $_term['custom_fields'] = $this->get_term_custom_fields( $_term['term_id'] ); + + /** + * Filters XML-RPC-prepared data for the given term. + * + * @since 3.4.0 + * + * @param array $_term An array of term data. + * @param array|object $term Term object or array. + */ + return apply_filters( 'xmlrpc_prepare_term', $_term, $term ); + } + + /** + * Convert a WordPress date string to an IXR_Date object. + * + * + * @param string $date Date string to convert. + * @return IXR_Date IXR_Date object. + */ + protected function _convert_date( $date ) { + if ( $date === '0000-00-00 00:00:00' ) { + return new IXR_Date( '00000000T00:00:00Z' ); + } + return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) ); + } + + /** + * Convert a WordPress GMT date string to an IXR_Date object. + * + * + * @param string $date_gmt WordPress GMT date string. + * @param string $date Date string. + * @return IXR_Date IXR_Date object. + */ + protected function _convert_date_gmt( $date_gmt, $date ) { + if ( $date !== '0000-00-00 00:00:00' && $date_gmt === '0000-00-00 00:00:00' ) { + return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) ); + } + return $this->_convert_date( $date_gmt ); + } + + /** + * Prepares post data for return in an XML-RPC object. + * + * + * @param array $post The unprepared post data. + * @param array $fields The subset of post type fields to return. + * @return array The prepared post data. + */ + protected function _prepare_post( $post, $fields ) { + // Holds the data for this post. built up based on $fields. + $_post = array( 'post_id' => strval( $post['ID'] ) ); + + // Prepare common post fields. + $post_fields = array( + 'post_title' => $post['post_title'], + 'post_date' => $this->_convert_date( $post['post_date'] ), + 'post_date_gmt' => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ), + 'post_modified' => $this->_convert_date( $post['post_modified'] ), + 'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ), + 'post_status' => $post['post_status'], + 'post_type' => $post['post_type'], + 'post_name' => $post['post_name'], + 'post_author' => $post['post_author'], + 'post_password' => $post['post_password'], + 'post_excerpt' => $post['post_excerpt'], + 'post_content' => $post['post_content'], + 'post_parent' => strval( $post['post_parent'] ), + 'post_mime_type' => $post['post_mime_type'], + 'link' => get_permalink( $post['ID'] ), + 'guid' => $post['guid'], + 'menu_order' => intval( $post['menu_order'] ), + 'comment_status' => $post['comment_status'], + 'ping_status' => $post['ping_status'], + 'sticky' => ( $post['post_type'] === 'post' && is_sticky( $post['ID'] ) ), + ); + + // Thumbnail. + $post_fields['post_thumbnail'] = array(); + $thumbnail_id = get_post_thumbnail_id( $post['ID'] ); + if ( $thumbnail_id ) { + $thumbnail_size = current_theme_supports('post-thumbnail') ? 'post-thumbnail' : 'thumbnail'; + $post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size ); + } + + // Consider future posts as published. + if ( $post_fields['post_status'] === 'future' ) + $post_fields['post_status'] = 'publish'; + + // Fill in blank post format. + $post_fields['post_format'] = get_post_format( $post['ID'] ); + if ( empty( $post_fields['post_format'] ) ) + $post_fields['post_format'] = 'standard'; + + // Merge requested $post_fields fields into $_post. + if ( in_array( 'post', $fields ) ) { + $_post = array_merge( $_post, $post_fields ); + } else { + $requested_fields = array_intersect_key( $post_fields, array_flip( $fields ) ); + $_post = array_merge( $_post, $requested_fields ); + } + + $all_taxonomy_fields = in_array( 'taxonomies', $fields ); + + if ( $all_taxonomy_fields || in_array( 'terms', $fields ) ) { + $post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' ); + $terms = wp_get_object_terms( $post['ID'], $post_type_taxonomies ); + $_post['terms'] = array(); + foreach ( $terms as $term ) { + $_post['terms'][] = $this->_prepare_term( $term ); + } + } + + if ( in_array( 'custom_fields', $fields ) ) + $_post['custom_fields'] = $this->get_custom_fields( $post['ID'] ); + + if ( in_array( 'enclosure', $fields ) ) { + $_post['enclosure'] = array(); + $enclosures = (array) get_post_meta( $post['ID'], 'enclosure' ); + if ( ! empty( $enclosures ) ) { + $encdata = explode( "\n", $enclosures[0] ); + $_post['enclosure']['url'] = trim( htmlspecialchars( $encdata[0] ) ); + $_post['enclosure']['length'] = (int) trim( $encdata[1] ); + $_post['enclosure']['type'] = trim( $encdata[2] ); + } + } + + /** + * Filters XML-RPC-prepared date for the given post. + * + * @since 3.4.0 + * + * @param array $_post An array of modified post data. + * @param array $post An array of post data. + * @param array $fields An array of post fields. + */ + return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields ); + } + + /** + * Prepares post data for return in an XML-RPC object. + * + * @since 3.4.0 + * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. + * + * @param WP_Post_Type $post_type Post type object. + * @param array $fields The subset of post fields to return. + * @return array The prepared post type data. + */ + protected function _prepare_post_type( $post_type, $fields ) { + $_post_type = array( + 'name' => $post_type->name, + 'label' => $post_type->label, + 'hierarchical' => (bool) $post_type->hierarchical, + 'public' => (bool) $post_type->public, + 'show_ui' => (bool) $post_type->show_ui, + '_builtin' => (bool) $post_type->_builtin, + 'has_archive' => (bool) $post_type->has_archive, + 'supports' => get_all_post_type_supports( $post_type->name ), + ); + + if ( in_array( 'labels', $fields ) ) { + $_post_type['labels'] = (array) $post_type->labels; + } + + if ( in_array( 'cap', $fields ) ) { + $_post_type['cap'] = (array) $post_type->cap; + $_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap; + } + + if ( in_array( 'menu', $fields ) ) { + $_post_type['menu_position'] = (int) $post_type->menu_position; + $_post_type['menu_icon'] = $post_type->menu_icon; + $_post_type['show_in_menu'] = (bool) $post_type->show_in_menu; + } + + if ( in_array( 'taxonomies', $fields ) ) + $_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' ); + + /** + * Filters XML-RPC-prepared date for the given post type. + * + * @since 3.4.0 + * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object. + * + * @param array $_post_type An array of post type data. + * @param WP_Post_Type $post_type Post type object. + */ + return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type ); + } + + /** + * Prepares media item data for return in an XML-RPC object. + * + * + * @param object $media_item The unprepared media item data. + * @param string $thumbnail_size The image size to use for the thumbnail URL. + * @return array The prepared media item data. + */ + protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) { + $_media_item = array( + 'attachment_id' => strval( $media_item->ID ), + 'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ), + 'parent' => $media_item->post_parent, + 'link' => wp_get_attachment_url( $media_item->ID ), + 'title' => $media_item->post_title, + 'caption' => $media_item->post_excerpt, + 'description' => $media_item->post_content, + 'metadata' => wp_get_attachment_metadata( $media_item->ID ), + 'type' => $media_item->post_mime_type + ); + + $thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size ); + if ( $thumbnail_src ) + $_media_item['thumbnail'] = $thumbnail_src[0]; + else + $_media_item['thumbnail'] = $_media_item['link']; + + /** + * Filters XML-RPC-prepared data for the given media item. + * + * @since 3.4.0 + * + * @param array $_media_item An array of media item data. + * @param object $media_item Media item object. + * @param string $thumbnail_size Image size. + */ + return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size ); + } + + /** + * Prepares page data for return in an XML-RPC object. + * + * + * @param object $page The unprepared page data. + * @return array The prepared page data. + */ + protected function _prepare_page( $page ) { + // Get all of the page content and link. + $full_page = get_extended( $page->post_content ); + $link = get_permalink( $page->ID ); + + // Get info the page parent if there is one. + $parent_title = ""; + if ( ! empty( $page->post_parent ) ) { + $parent = get_post( $page->post_parent ); + $parent_title = $parent->post_title; + } + + // Determine comment and ping settings. + $allow_comments = comments_open( $page->ID ) ? 1 : 0; + $allow_pings = pings_open( $page->ID ) ? 1 : 0; + + // Format page date. + $page_date = $this->_convert_date( $page->post_date ); + $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); + + // Pull the categories info together. + $categories = array(); + if ( is_object_in_taxonomy( 'page', 'category' ) ) { + foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) { + $categories[] = get_cat_name( $cat_id ); + } + } + + // Get the author info. + $author = get_userdata( $page->post_author ); + + $page_template = get_page_template_slug( $page->ID ); + if ( empty( $page_template ) ) + $page_template = 'default'; + + $_page = array( + 'dateCreated' => $page_date, + 'userid' => $page->post_author, + 'page_id' => $page->ID, + 'page_status' => $page->post_status, + 'description' => $full_page['main'], + 'title' => $page->post_title, + 'link' => $link, + 'permaLink' => $link, + 'categories' => $categories, + 'excerpt' => $page->post_excerpt, + 'text_more' => $full_page['extended'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings, + 'wp_slug' => $page->post_name, + 'wp_password' => $page->post_password, + 'wp_author' => $author->display_name, + 'wp_page_parent_id' => $page->post_parent, + 'wp_page_parent_title' => $parent_title, + 'wp_page_order' => $page->menu_order, + 'wp_author_id' => (string) $author->ID, + 'wp_author_display_name' => $author->display_name, + 'date_created_gmt' => $page_date_gmt, + 'custom_fields' => $this->get_custom_fields( $page->ID ), + 'wp_page_template' => $page_template + ); + + /** + * Filters XML-RPC-prepared data for the given page. + * + * @since 3.4.0 + * + * @param array $_page An array of page data. + * @param WP_Post $page Page object. + */ + return apply_filters( 'xmlrpc_prepare_page', $_page, $page ); + } + + /** + * Prepares comment data for return in an XML-RPC object. + * + * + * @param object $comment The unprepared comment data. + * @return array The prepared comment data. + */ + protected function _prepare_comment( $comment ) { + // Format page date. + $comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date ); + + if ( '0' == $comment->comment_approved ) { + $comment_status = 'hold'; + } elseif ( 'spam' == $comment->comment_approved ) { + $comment_status = 'spam'; + } elseif ( '1' == $comment->comment_approved ) { + $comment_status = 'approve'; + } else { + $comment_status = $comment->comment_approved; + } + $_comment = array( + 'date_created_gmt' => $comment_date_gmt, + 'user_id' => $comment->user_id, + 'comment_id' => $comment->comment_ID, + 'parent' => $comment->comment_parent, + 'status' => $comment_status, + 'content' => $comment->comment_content, + 'link' => get_comment_link($comment), + 'post_id' => $comment->comment_post_ID, + 'post_title' => get_the_title($comment->comment_post_ID), + 'author' => $comment->comment_author, + 'author_url' => $comment->comment_author_url, + 'author_email' => $comment->comment_author_email, + 'author_ip' => $comment->comment_author_IP, + 'type' => $comment->comment_type, + ); + + /** + * Filters XML-RPC-prepared data for the given comment. + * + * @since 3.4.0 + * + * @param array $_comment An array of prepared comment data. + * @param WP_Comment $comment Comment object. + */ + return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment ); + } + + /** + * Prepares user data for return in an XML-RPC object. + * + * + * @param WP_User $user The unprepared user object. + * @param array $fields The subset of user fields to return. + * @return array The prepared user data. + */ + protected function _prepare_user( $user, $fields ) { + $_user = array( 'user_id' => strval( $user->ID ) ); + + $user_fields = array( + 'username' => $user->user_login, + 'first_name' => $user->user_firstname, + 'last_name' => $user->user_lastname, + 'registered' => $this->_convert_date( $user->user_registered ), + 'bio' => $user->user_description, + 'email' => $user->user_email, + 'nickname' => $user->nickname, + 'nicename' => $user->user_nicename, + 'url' => $user->user_url, + 'display_name' => $user->display_name, + 'roles' => $user->roles, + ); + + if ( in_array( 'all', $fields ) ) { + $_user = array_merge( $_user, $user_fields ); + } else { + if ( in_array( 'basic', $fields ) ) { + $basic_fields = array( 'username', 'email', 'registered', 'display_name', 'nicename' ); + $fields = array_merge( $fields, $basic_fields ); + } + $requested_fields = array_intersect_key( $user_fields, array_flip( $fields ) ); + $_user = array_merge( $_user, $requested_fields ); + } + + /** + * Filters XML-RPC-prepared data for the given user. + * + * @since 3.5.0 + * + * @param array $_user An array of user data. + * @param WP_User $user User object. + * @param array $fields An array of user fields. + */ + return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields ); + } + + /** + * Create a new post for any registered post type. + * + * @since 3.4.0 + * + * @link https://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures. + * + * @param array $args { + * Method arguments. Note: top-level arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type array $content_struct { + * Content struct for adding a new post. See wp_insert_post() for information on + * additional post fields + * + * @type string $post_type Post type. Default 'post'. + * @type string $post_status Post status. Default 'draft' + * @type string $post_title Post title. + * @type int $post_author Post author ID. + * @type string $post_excerpt Post excerpt. + * @type string $post_content Post content. + * @type string $post_date_gmt Post date in GMT. + * @type string $post_date Post date. + * @type string $post_password Post password (20-character limit). + * @type string $comment_status Post comment enabled status. Accepts 'open' or 'closed'. + * @type string $ping_status Post ping status. Accepts 'open' or 'closed'. + * @type bool $sticky Whether the post should be sticky. Automatically false if + * `$post_status` is 'private'. + * @type int $post_thumbnail ID of an image to use as the post thumbnail/featured image. + * @type array $custom_fields Array of meta key/value pairs to add to the post. + * @type array $terms Associative array with taxonomy names as keys and arrays + * of term IDs as values. + * @type array $terms_names Associative array with taxonomy names as keys and arrays + * of term names as values. + * @type array $enclosure { + * Array of feed enclosure data to add to post meta. + * + * @type string $url URL for the feed enclosure. + * @type int $length Size in bytes of the enclosure. + * @type string $type Mime-type for the enclosure. + * } + * } + * } + * @return int|IXR_Error Post ID on success, IXR_Error instance otherwise. + */ + public function wp_newPost( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + // convert the date field back to IXR form + if ( isset( $content_struct['post_date'] ) && ! ( $content_struct['post_date'] instanceof IXR_Date ) ) { + $content_struct['post_date'] = $this->_convert_date( $content_struct['post_date'] ); + } + + // ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, + // since _insert_post will ignore the non-GMT date if the GMT date is set + if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { + if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { + unset( $content_struct['post_date_gmt'] ); + } else { + $content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] ); + } + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.newPost' ); + + unset( $content_struct['ID'] ); + + return $this->_insert_post( $user, $content_struct ); + } + + /** + * Helper method for filtering out elements from an array. + * + * @since 3.4.0 + * + * @param int $count Number to compare to one. + */ + private function _is_greater_than_one( $count ) { + return $count > 1; + } + + /** + * Encapsulate the logic for sticking a post + * and determining if the user has permission to do so + * + * @since 4.3.0 + * + * @param array $post_data + * @param bool $update + * @return void|IXR_Error + */ + private function _toggle_sticky( $post_data, $update = false ) { + $post_type = get_post_type_object( $post_data['post_type'] ); + + // Private and password-protected posts cannot be stickied. + if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) { + // Error if the client tried to stick the post, otherwise, silently unstick. + if ( ! empty( $post_data['sticky'] ) ) { + return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) ); + } + + if ( $update ) { + unstick_post( $post_data['ID'] ); + } + } elseif ( isset( $post_data['sticky'] ) ) { + if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to make posts sticky.' ) ); + } + + $sticky = wp_validate_boolean( $post_data['sticky'] ); + if ( $sticky ) { + stick_post( $post_data['ID'] ); + } else { + unstick_post( $post_data['ID'] ); + } + } + } + + /** + * Helper method for wp_newPost() and wp_editPost(), containing shared logic. + * + * @since 3.4.0 + * + * @see wp_insert_post() + * + * @param WP_User $user The post author if post_author isn't set in $content_struct. + * @param array|IXR_Error $content_struct Post data to insert. + * @return IXR_Error|string + */ + protected function _insert_post( $user, $content_struct ) { + $defaults = array( + 'post_status' => 'draft', + 'post_type' => 'post', + 'post_author' => null, + 'post_password' => null, + 'post_excerpt' => null, + 'post_content' => null, + 'post_title' => null, + 'post_date' => null, + 'post_date_gmt' => null, + 'post_format' => null, + 'post_name' => null, + 'post_thumbnail' => null, + 'post_parent' => null, + 'ping_status' => null, + 'comment_status' => null, + 'custom_fields' => null, + 'terms_names' => null, + 'terms' => null, + 'sticky' => null, + 'enclosure' => null, + 'ID' => null, + ); + + $post_data = wp_parse_args( array_intersect_key( $content_struct, $defaults ), $defaults ); + + $post_type = get_post_type_object( $post_data['post_type'] ); + if ( ! $post_type ) + return new IXR_Error( 403, __( 'Invalid post type.' ) ); + + $update = ! empty( $post_data['ID'] ); + + if ( $update ) { + if ( ! get_post( $post_data['ID'] ) ) + return new IXR_Error( 401, __( 'Invalid post ID.' ) ); + if ( ! current_user_can( 'edit_post', $post_data['ID'] ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) ) + return new IXR_Error( 401, __( 'The post type may not be changed.' ) ); + } else { + if ( ! current_user_can( $post_type->cap->create_posts ) || ! current_user_can( $post_type->cap->edit_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); + } + + switch ( $post_data['post_status'] ) { + case 'draft': + case 'pending': + break; + case 'private': + if ( ! current_user_can( $post_type->cap->publish_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type.' ) ); + break; + case 'publish': + case 'future': + if ( ! current_user_can( $post_type->cap->publish_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type.' ) ); + break; + default: + if ( ! get_post_status_object( $post_data['post_status'] ) ) + $post_data['post_status'] = 'draft'; + break; + } + + if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type.' ) ); + + $post_data['post_author'] = absint( $post_data['post_author'] ); + if ( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) { + if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) ); + + $author = get_userdata( $post_data['post_author'] ); + + if ( ! $author ) + return new IXR_Error( 404, __( 'Invalid author ID.' ) ); + } else { + $post_data['post_author'] = $user->ID; + } + + if ( isset( $post_data['comment_status'] ) && $post_data['comment_status'] != 'open' && $post_data['comment_status'] != 'closed' ) + unset( $post_data['comment_status'] ); + + if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' ) + unset( $post_data['ping_status'] ); + + // Do some timestamp voodoo. + if ( ! empty( $post_data['post_date_gmt'] ) ) { + // We know this is supposed to be GMT, so we're going to slap that Z on there by force. + $dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z'; + } elseif ( ! empty( $post_data['post_date'] ) ) { + $dateCreated = $post_data['post_date']->getIso(); + } + + // Default to not flagging the post date to be edited unless it's intentional. + $post_data['edit_date'] = false; + + if ( ! empty( $dateCreated ) ) { + $post_data['post_date'] = get_date_from_gmt( iso8601_to_datetime( $dateCreated ) ); + $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'GMT' ); + + // Flag the post date to be edited. + $post_data['edit_date'] = true; + } + + if ( ! isset( $post_data['ID'] ) ) + $post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID; + $post_ID = $post_data['ID']; + + if ( $post_data['post_type'] == 'post' ) { + $error = $this->_toggle_sticky( $post_data, $update ); + if ( $error ) { + return $error; + } + } + + if ( isset( $post_data['post_thumbnail'] ) ) { + // empty value deletes, non-empty value adds/updates. + if ( ! $post_data['post_thumbnail'] ) + delete_post_thumbnail( $post_ID ); + elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) + return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + set_post_thumbnail( $post_ID, $post_data['post_thumbnail'] ); + unset( $content_struct['post_thumbnail'] ); + } + + if ( isset( $post_data['custom_fields'] ) ) + $this->set_custom_fields( $post_ID, $post_data['custom_fields'] ); + + if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) { + $post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' ); + + // Accumulate term IDs from terms and terms_names. + $terms = array(); + + // First validate the terms specified by ID. + if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) { + $taxonomies = array_keys( $post_data['terms'] ); + + // Validating term ids. + foreach ( $taxonomies as $taxonomy ) { + if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) ) + return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) ); + + if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->assign_terms ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) ); + + $term_ids = $post_data['terms'][$taxonomy]; + $terms[ $taxonomy ] = array(); + foreach ( $term_ids as $term_id ) { + $term = get_term_by( 'id', $term_id, $taxonomy ); + + if ( ! $term ) + return new IXR_Error( 403, __( 'Invalid term ID.' ) ); + + $terms[$taxonomy][] = (int) $term_id; + } + } + } + + // Now validate terms specified by name. + if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) { + $taxonomies = array_keys( $post_data['terms_names'] ); + + foreach ( $taxonomies as $taxonomy ) { + if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) ) + return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) ); + + if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->assign_terms ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) ); + + /* + * For hierarchical taxonomies, we can't assign a term when multiple terms + * in the hierarchy share the same name. + */ + $ambiguous_terms = array(); + if ( is_taxonomy_hierarchical( $taxonomy ) ) { + $tax_term_names = get_terms( $taxonomy, array( 'fields' => 'names', 'hide_empty' => false ) ); + + // Count the number of terms with the same name. + $tax_term_names_count = array_count_values( $tax_term_names ); + + // Filter out non-ambiguous term names. + $ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') ); + + $ambiguous_terms = array_keys( $ambiguous_tax_term_counts ); + } + + $term_names = $post_data['terms_names'][$taxonomy]; + foreach ( $term_names as $term_name ) { + if ( in_array( $term_name, $ambiguous_terms ) ) + return new IXR_Error( 401, __( 'Ambiguous term name used in a hierarchical taxonomy. Please use term ID instead.' ) ); + + $term = get_term_by( 'name', $term_name, $taxonomy ); + + if ( ! $term ) { + // Term doesn't exist, so check that the user is allowed to create new terms. + if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->edit_terms ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) ); + + // Create the new term. + $term_info = wp_insert_term( $term_name, $taxonomy ); + if ( is_wp_error( $term_info ) ) + return new IXR_Error( 500, $term_info->get_error_message() ); + + $terms[$taxonomy][] = (int) $term_info['term_id']; + } else { + $terms[$taxonomy][] = (int) $term->term_id; + } + } + } + } + + $post_data['tax_input'] = $terms; + unset( $post_data['terms'], $post_data['terms_names'] ); + } + + if ( isset( $post_data['post_format'] ) ) { + $format = set_post_format( $post_ID, $post_data['post_format'] ); + + if ( is_wp_error( $format ) ) + return new IXR_Error( 500, $format->get_error_message() ); + + unset( $post_data['post_format'] ); + } + + // Handle enclosures. + $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null; + $this->add_enclosure_if_new( $post_ID, $enclosure ); + + $this->attach_uploads( $post_ID, $post_data['post_content'] ); + + /** + * Filters post data array to be inserted via XML-RPC. + * + * @since 3.4.0 + * + * @param array $post_data Parsed array of post data. + * @param array $content_struct Post data array. + */ + $post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct ); + + $post_ID = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true ); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error( 500, $post_ID->get_error_message() ); + + if ( ! $post_ID ) + return new IXR_Error( 401, __( 'Sorry, your entry could not be posted.' ) ); + + return strval( $post_ID ); + } + + /** + * Edit a post for any registered post type. + * + * The $content_struct parameter only needs to contain fields that + * should be changed. All other fields will retain their existing values. + * + * @since 3.4.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type int $post_id Post ID. + * @type array $content_struct Extra content arguments. + * } + * @return true|IXR_Error True on success, IXR_Error on failure. + */ + public function wp_editPost( $args ) { + if ( ! $this->minimum_args( $args, 5 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + $content_struct = $args[4]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.editPost' ); + + $post = get_post( $post_id, ARRAY_A ); + + if ( empty( $post['ID'] ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( isset( $content_struct['if_not_modified_since'] ) ) { + // If the post has been modified since the date provided, return an error. + if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) { + return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) ); + } + } + + // Convert the date field back to IXR form. + $post['post_date'] = $this->_convert_date( $post['post_date'] ); + + /* + * Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, + * since _insert_post() will ignore the non-GMT date if the GMT date is set. + */ + if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) + unset( $post['post_date_gmt'] ); + else + $post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] ); + + $this->escape( $post ); + $merged_content_struct = array_merge( $post, $content_struct ); + + $retval = $this->_insert_post( $user, $merged_content_struct ); + if ( $retval instanceof IXR_Error ) + return $retval; + + return true; + } + + /** + * Delete a post for any registered post type. + * + * @since 3.4.0 + * + * @see wp_delete_post() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type int $post_id Post ID. + * } + * @return true|IXR_Error True on success, IXR_Error instance on failure. + */ + public function wp_deletePost( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.deletePost' ); + + $post = get_post( $post_id, ARRAY_A ); + if ( empty( $post['ID'] ) ) { + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + } + + if ( ! current_user_can( 'delete_post', $post_id ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); + } + + $result = wp_delete_post( $post_id ); + + if ( ! $result ) { + return new IXR_Error( 500, __( 'The post cannot be deleted.' ) ); + } + + return true; + } + + /** + * Retrieve a post. + * + * @since 3.4.0 + * + * The optional $fields parameter specifies what fields will be included + * in the response array. This should be a list of field names. 'post_id' will + * always be included in the response regardless of the value of $fields. + * + * Instead of, or in addition to, individual field names, conceptual group + * names can be used to specify multiple fields. The available conceptual + * groups are 'post' (all basic fields), 'taxonomies', 'custom_fields', + * and 'enclosure'. + * + * @see get_post() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type int $post_id Post ID. + * @type array $fields The subset of post type fields to return. + * } + * @return array|IXR_Error Array contains (based on $fields parameter): + * - 'post_id' + * - 'post_title' + * - 'post_date' + * - 'post_date_gmt' + * - 'post_modified' + * - 'post_modified_gmt' + * - 'post_status' + * - 'post_type' + * - 'post_name' + * - 'post_author' + * - 'post_password' + * - 'post_excerpt' + * - 'post_content' + * - 'link' + * - 'comment_status' + * - 'ping_status' + * - 'sticky' + * - 'custom_fields' + * - 'terms' + * - 'categories' + * - 'tags' + * - 'enclosure' + */ + public function wp_getPost( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** + * Filters the list of post query fields used by the given XML-RPC method. + * + * @since 3.4.0 + * + * @param array $fields Array of post fields. Default array contains 'post', 'terms', and 'custom_fields'. + * @param string $method Method name. + */ + $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPost' ); + + $post = get_post( $post_id, ARRAY_A ); + + if ( empty( $post['ID'] ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! current_user_can( 'edit_post', $post_id ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + return $this->_prepare_post( $post, $fields ); + } + + /** + * Retrieve posts. + * + * @since 3.4.0 + * + * @see wp_get_recent_posts() + * @see wp_getPost() for more on `$fields` + * @see get_posts() for more on `$filter` values + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'post_type', + * 'post_status', 'number', 'offset', 'orderby', 's', and 'order'. + * Default empty array. + * @type array $fields Optional. The subset of post type fields to return in the response array. + * } + * @return array|IXR_Error Array contains a collection of posts. + */ + public function wp_getPosts( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $filter = isset( $args[3] ) ? $args[3] : array(); + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + $fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPosts' ); + + $query = array(); + + if ( isset( $filter['post_type'] ) ) { + $post_type = get_post_type_object( $filter['post_type'] ); + if ( ! ( (bool) $post_type ) ) + return new IXR_Error( 403, __( 'Invalid post type.' ) ); + } else { + $post_type = get_post_type_object( 'post' ); + } + + if ( ! current_user_can( $post_type->cap->edit_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); + + $query['post_type'] = $post_type->name; + + if ( isset( $filter['post_status'] ) ) + $query['post_status'] = $filter['post_status']; + + if ( isset( $filter['number'] ) ) + $query['numberposts'] = absint( $filter['number'] ); + + if ( isset( $filter['offset'] ) ) + $query['offset'] = absint( $filter['offset'] ); + + if ( isset( $filter['orderby'] ) ) { + $query['orderby'] = $filter['orderby']; + + if ( isset( $filter['order'] ) ) + $query['order'] = $filter['order']; + } + + if ( isset( $filter['s'] ) ) { + $query['s'] = $filter['s']; + } + + $posts_list = wp_get_recent_posts( $query ); + + if ( ! $posts_list ) + return array(); + + // Holds all the posts data. + $struct = array(); + + foreach ( $posts_list as $post ) { + if ( ! current_user_can( 'edit_post', $post['ID'] ) ) + continue; + + $struct[] = $this->_prepare_post( $post, $fields ); + } + + return $struct; + } + + /** + * Create a new term. + * + * @since 3.4.0 + * + * @see wp_insert_term() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type array $content_struct Content struct for adding a new term. The struct must contain + * the term 'name' and 'taxonomy'. Optional accepted values include + * 'parent', 'description', and 'slug'. + * } + * @return int|IXR_Error The term ID on success, or an IXR_Error object on failure. + */ + public function wp_newTerm( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.newTerm' ); + + if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); + + if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) ); + } + + $taxonomy = (array) $taxonomy; + + // hold the data of the term + $term_data = array(); + + $term_data['name'] = trim( $content_struct['name'] ); + if ( empty( $term_data['name'] ) ) + return new IXR_Error( 403, __( 'The term name cannot be empty.' ) ); + + if ( isset( $content_struct['parent'] ) ) { + if ( ! $taxonomy['hierarchical'] ) + return new IXR_Error( 403, __( 'This taxonomy is not hierarchical.' ) ); + + $parent_term_id = (int) $content_struct['parent']; + $parent_term = get_term( $parent_term_id , $taxonomy['name'] ); + + if ( is_wp_error( $parent_term ) ) + return new IXR_Error( 500, $parent_term->get_error_message() ); + + if ( ! $parent_term ) + return new IXR_Error( 403, __( 'Parent term does not exist.' ) ); + + $term_data['parent'] = $content_struct['parent']; + } + + if ( isset( $content_struct['description'] ) ) + $term_data['description'] = $content_struct['description']; + + if ( isset( $content_struct['slug'] ) ) + $term_data['slug'] = $content_struct['slug']; + + $term = wp_insert_term( $term_data['name'] , $taxonomy['name'] , $term_data ); + + if ( is_wp_error( $term ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $term ) + return new IXR_Error( 500, __( 'Sorry, your term could not be created.' ) ); + + // Add term meta. + if ( isset( $content_struct['custom_fields'] ) ) { + $this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] ); + } + + return strval( $term['term_id'] ); + } + + /** + * Edit a term. + * + * @since 3.4.0 + * + * @see wp_update_term() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type int $term_id Term ID. + * @type array $content_struct Content struct for editing a term. The struct must contain the + * term ''taxonomy'. Optional accepted values include 'name', 'parent', + * 'description', and 'slug'. + * } + * @return true|IXR_Error True on success, IXR_Error instance on failure. + */ + public function wp_editTerm( $args ) { + if ( ! $this->minimum_args( $args, 5 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $term_id = (int) $args[3]; + $content_struct = $args[4]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.editTerm' ); + + if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $content_struct['taxonomy'] ); + + $taxonomy = (array) $taxonomy; + + // hold the data of the term + $term_data = array(); + + $term = get_term( $term_id , $content_struct['taxonomy'] ); + + if ( is_wp_error( $term ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $term ) + return new IXR_Error( 404, __( 'Invalid term ID.' ) ); + + if ( ! current_user_can( 'edit_term', $term_id ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this term.' ) ); + } + + if ( isset( $content_struct['name'] ) ) { + $term_data['name'] = trim( $content_struct['name'] ); + + if ( empty( $term_data['name'] ) ) + return new IXR_Error( 403, __( 'The term name cannot be empty.' ) ); + } + + if ( ! empty( $content_struct['parent'] ) ) { + if ( ! $taxonomy['hierarchical'] ) + return new IXR_Error( 403, __( 'Cannot set parent term, taxonomy is not hierarchical.' ) ); + + $parent_term_id = (int) $content_struct['parent']; + $parent_term = get_term( $parent_term_id , $taxonomy['name'] ); + + if ( is_wp_error( $parent_term ) ) + return new IXR_Error( 500, $parent_term->get_error_message() ); + + if ( ! $parent_term ) + return new IXR_Error( 403, __( 'Parent term does not exist.' ) ); + + $term_data['parent'] = $content_struct['parent']; + } + + if ( isset( $content_struct['description'] ) ) + $term_data['description'] = $content_struct['description']; + + if ( isset( $content_struct['slug'] ) ) + $term_data['slug'] = $content_struct['slug']; + + $term = wp_update_term( $term_id , $taxonomy['name'] , $term_data ); + + if ( is_wp_error( $term ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $term ) + return new IXR_Error( 500, __( 'Sorry, editing the term failed.' ) ); + + // Update term meta. + if ( isset( $content_struct['custom_fields'] ) ) { + $this->set_term_custom_fields( $term_id, $content_struct['custom_fields'] ); + } + + return true; + } + + /** + * Delete a term. + * + * @since 3.4.0 + * + * @see wp_delete_term() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type string $taxnomy_name Taxonomy name. + * @type int $term_id Term ID. + * } + * @return bool|IXR_Error True on success, IXR_Error instance on failure. + */ + public function wp_deleteTerm( $args ) { + if ( ! $this->minimum_args( $args, 5 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $taxonomy = $args[3]; + $term_id = (int) $args[4]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.deleteTerm' ); + + if ( ! taxonomy_exists( $taxonomy ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $taxonomy ); + $term = get_term( $term_id, $taxonomy->name ); + + if ( is_wp_error( $term ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $term ) + return new IXR_Error( 404, __( 'Invalid term ID.' ) ); + + if ( ! current_user_can( 'delete_term', $term_id ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this term.' ) ); + } + + $result = wp_delete_term( $term_id, $taxonomy->name ); + + if ( is_wp_error( $result ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $result ) + return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) ); + + return $result; + } + + /** + * Retrieve a term. + * + * @since 3.4.0 + * + * @see get_term() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type string $taxnomy Taxonomy name. + * @type string $term_id Term ID. + * } + * @return array|IXR_Error IXR_Error on failure, array on success, containing: + * - 'term_id' + * - 'name' + * - 'slug' + * - 'term_group' + * - 'term_taxonomy_id' + * - 'taxonomy' + * - 'description' + * - 'parent' + * - 'count' + */ + public function wp_getTerm( $args ) { + if ( ! $this->minimum_args( $args, 5 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $taxonomy = $args[3]; + $term_id = (int) $args[4]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getTerm' ); + + if ( ! taxonomy_exists( $taxonomy ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $taxonomy ); + + $term = get_term( $term_id , $taxonomy->name, ARRAY_A ); + + if ( is_wp_error( $term ) ) + return new IXR_Error( 500, $term->get_error_message() ); + + if ( ! $term ) + return new IXR_Error( 404, __( 'Invalid term ID.' ) ); + + if ( ! current_user_can( 'assign_term', $term_id ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign this term.' ) ); + } + + return $this->_prepare_term( $term ); + } + + /** + * Retrieve all terms for a taxonomy. + * + * @since 3.4.0 + * + * The optional $filter parameter modifies the query used to retrieve terms. + * Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'. + * + * @see get_terms() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type string $taxnomy Taxonomy name. + * @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'number', + * 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array. + * } + * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise. + */ + public function wp_getTerms( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $taxonomy = $args[3]; + $filter = isset( $args[4] ) ? $args[4] : array(); + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getTerms' ); + + if ( ! taxonomy_exists( $taxonomy ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $taxonomy ); + + if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); + + $query = array(); + + if ( isset( $filter['number'] ) ) + $query['number'] = absint( $filter['number'] ); + + if ( isset( $filter['offset'] ) ) + $query['offset'] = absint( $filter['offset'] ); + + if ( isset( $filter['orderby'] ) ) { + $query['orderby'] = $filter['orderby']; + + if ( isset( $filter['order'] ) ) + $query['order'] = $filter['order']; + } + + if ( isset( $filter['hide_empty'] ) ) + $query['hide_empty'] = $filter['hide_empty']; + else + $query['get'] = 'all'; + + if ( isset( $filter['search'] ) ) + $query['search'] = $filter['search']; + + $terms = get_terms( $taxonomy->name, $query ); + + if ( is_wp_error( $terms ) ) + return new IXR_Error( 500, $terms->get_error_message() ); + + $struct = array(); + + foreach ( $terms as $term ) { + $struct[] = $this->_prepare_term( $term ); + } + + return $struct; + } + + /** + * Retrieve a taxonomy. + * + * @since 3.4.0 + * + * @see get_taxonomy() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type string $taxnomy Taxonomy name. + * @type array $fields Optional. Array of taxonomy fields to limit to in the return. + * Accepts 'labels', 'cap', 'menu', and 'object_type'. + * Default empty array. + * } + * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise. + */ + public function wp_getTaxonomy( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $taxonomy = $args[3]; + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** + * Filters the taxonomy query fields used by the given XML-RPC method. + * + * @since 3.4.0 + * + * @param array $fields An array of taxonomy fields to retrieve. + * @param string $method The method name. + */ + $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getTaxonomy' ); + + if ( ! taxonomy_exists( $taxonomy ) ) + return new IXR_Error( 403, __( 'Invalid taxonomy.' ) ); + + $taxonomy = get_taxonomy( $taxonomy ); + + if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) ); + + return $this->_prepare_taxonomy( $taxonomy, $fields ); + } + + /** + * Retrieve all taxonomies. + * + * @since 3.4.0 + * + * @see get_taxonomies() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id Blog ID (unused). + * @type string $username Username. + * @type string $password Password. + * @type array $filter Optional. An array of arguments for retrieving taxonomies. + * @type array $fields Optional. The subset of taxonomy fields to return. + * } + * @return array|IXR_Error An associative array of taxonomy data with returned fields determined + * by `$fields`, or an IXR_Error instance on failure. + */ + public function wp_getTaxonomies( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + $fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getTaxonomies' ); + + $taxonomies = get_taxonomies( $filter, 'objects' ); + + // holds all the taxonomy data + $struct = array(); + + foreach ( $taxonomies as $taxonomy ) { + // capability check for post_types + if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) + continue; + + $struct[] = $this->_prepare_taxonomy( $taxonomy, $fields ); + } + + return $struct; + } + + /** + * Retrieve a user. + * + * The optional $fields parameter specifies what fields will be included + * in the response array. This should be a list of field names. 'user_id' will + * always be included in the response regardless of the value of $fields. + * + * Instead of, or in addition to, individual field names, conceptual group + * names can be used to specify multiple fields. The available conceptual + * groups are 'basic' and 'all'. + * + * @uses get_userdata() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $user_id + * @type array $fields (optional) + * } + * @return array|IXR_Error Array contains (based on $fields parameter): + * - 'user_id' + * - 'username' + * - 'first_name' + * - 'last_name' + * - 'registered' + * - 'bio' + * - 'email' + * - 'nickname' + * - 'nicename' + * - 'url' + * - 'display_name' + * - 'roles' + */ + public function wp_getUser( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $user_id = (int) $args[3]; + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** + * Filters the default user query fields used by the given XML-RPC method. + * + * @since 3.5.0 + * + * @param array $fields User query fields for given method. Default 'all'. + * @param string $method The method name. + */ + $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getUser' ); + + if ( ! current_user_can( 'edit_user', $user_id ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) ); + + $user_data = get_userdata( $user_id ); + + if ( ! $user_data ) + return new IXR_Error( 404, __( 'Invalid user ID.' ) ); + + return $this->_prepare_user( $user_data, $fields ); + } + + /** + * Retrieve users. + * + * The optional $filter parameter modifies the query used to retrieve users. + * Accepted keys are 'number' (default: 50), 'offset' (default: 0), 'role', + * 'who', 'orderby', and 'order'. + * + * The optional $fields parameter specifies what fields will be included + * in the response array. + * + * @uses get_users() + * @see wp_getUser() for more on $fields and return values + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $filter (optional) + * @type array $fields (optional) + * } + * @return array|IXR_Error users data + */ + public function wp_getUsers( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $filter = isset( $args[3] ) ? $args[3] : array(); + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getUsers' ); + + if ( ! current_user_can( 'list_users' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) ); + + $query = array( 'fields' => 'all_with_meta' ); + + $query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50; + $query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0; + + if ( isset( $filter['orderby'] ) ) { + $query['orderby'] = $filter['orderby']; + + if ( isset( $filter['order'] ) ) + $query['order'] = $filter['order']; + } + + if ( isset( $filter['role'] ) ) { + if ( get_role( $filter['role'] ) === null ) + return new IXR_Error( 403, __( 'Invalid role.' ) ); + + $query['role'] = $filter['role']; + } + + if ( isset( $filter['who'] ) ) { + $query['who'] = $filter['who']; + } + + $users = get_users( $query ); + + $_users = array(); + foreach ( $users as $user_data ) { + if ( current_user_can( 'edit_user', $user_data->ID ) ) + $_users[] = $this->_prepare_user( $user_data, $fields ); + } + return $_users; + } + + /** + * Retrieve information about the requesting user. + * + * @uses get_userdata() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $fields (optional) + * } + * @return array|IXR_Error (@see wp_getUser) + */ + public function wp_getProfile( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( isset( $args[3] ) ) { + $fields = $args[3]; + } else { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + $fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getProfile' ); + + if ( ! current_user_can( 'edit_user', $user->ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); + + $user_data = get_userdata( $user->ID ); + + return $this->_prepare_user( $user_data, $fields ); + } + + /** + * Edit user's profile. + * + * @uses wp_update_user() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $content_struct It can optionally contain: + * - 'first_name' + * - 'last_name' + * - 'website' + * - 'display_name' + * - 'nickname' + * - 'nicename' + * - 'bio' + * } + * @return true|IXR_Error True, on success. + */ + public function wp_editProfile( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.editProfile' ); + + if ( ! current_user_can( 'edit_user', $user->ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); + + // holds data of the user + $user_data = array(); + $user_data['ID'] = $user->ID; + + // only set the user details if it was given + if ( isset( $content_struct['first_name'] ) ) + $user_data['first_name'] = $content_struct['first_name']; + + if ( isset( $content_struct['last_name'] ) ) + $user_data['last_name'] = $content_struct['last_name']; + + if ( isset( $content_struct['url'] ) ) + $user_data['user_url'] = $content_struct['url']; + + if ( isset( $content_struct['display_name'] ) ) + $user_data['display_name'] = $content_struct['display_name']; + + if ( isset( $content_struct['nickname'] ) ) + $user_data['nickname'] = $content_struct['nickname']; + + if ( isset( $content_struct['nicename'] ) ) + $user_data['user_nicename'] = $content_struct['nicename']; + + if ( isset( $content_struct['bio'] ) ) + $user_data['description'] = $content_struct['bio']; + + $result = wp_update_user( $user_data ); + + if ( is_wp_error( $result ) ) + return new IXR_Error( 500, $result->get_error_message() ); + + if ( ! $result ) + return new IXR_Error( 500, __( 'Sorry, the user cannot be updated.' ) ); + + return true; + } + + /** + * Retrieve page. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $page_id + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getPage( $args ) { + $this->escape( $args ); + + $page_id = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + + if ( !$user = $this->login($username, $password) ) { + return $this->error; + } + + $page = get_post($page_id); + if ( ! $page ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can( 'edit_page', $page_id ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPage' ); + + // If we found the page then format the data. + if ( $page->ID && ($page->post_type == 'page') ) { + return $this->_prepare_page( $page ); + } + // If the page doesn't exist indicate that. + else { + return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); + } + } + + /** + * Retrieve Pages. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $num_pages + * } + * @return array|IXR_Error + */ + public function wp_getPages( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $num_pages = isset($args[3]) ? (int) $args[3] : 10; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPages' ); + + $pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) ); + $num_pages = count($pages); + + // If we have pages, put together their info. + if ( $num_pages >= 1 ) { + $pages_struct = array(); + + foreach ($pages as $page) { + if ( current_user_can( 'edit_page', $page->ID ) ) + $pages_struct[] = $this->_prepare_page( $page ); + } + + return $pages_struct; + } + + return array(); + } + + /** + * Create new page. + * + * @since 2.2.0 + * + * @see wp_xmlrpc_server::mw_newPost() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $content_struct + * } + * @return int|IXR_Error + */ + public function wp_newPage( $args ) { + // Items not escaped here will be escaped in newPost. + $username = $this->escape( $args[1] ); + $password = $this->escape( $args[2] ); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.newPage' ); + + // Mark this as content for a page. + $args[3]["post_type"] = 'page'; + + // Let mw_newPost do all of the heavy lifting. + return $this->mw_newPost( $args ); + } + + /** + * Delete page. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $page_id + * } + * @return true|IXR_Error True, if success. + */ + public function wp_deletePage( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $page_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.deletePage' ); + + // Get the current page based on the page_id and + // make sure it is a page and not a post. + $actual_page = get_post($page_id, ARRAY_A); + if ( !$actual_page || ($actual_page['post_type'] != 'page') ) + return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); + + // Make sure the user can delete pages. + if ( !current_user_can('delete_page', $page_id) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) ); + + // Attempt to delete the page. + $result = wp_delete_post($page_id); + if ( !$result ) + return new IXR_Error( 500, __( 'Failed to delete the page.' ) ); + + /** + * Fires after a page has been successfully deleted via XML-RPC. + * + * @since 3.4.0 + * + * @param int $page_id ID of the deleted page. + * @param array $args An array of arguments to delete the page. + */ + do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); + + return true; + } + + /** + * Edit page. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $page_id + * @type string $username + * @type string $password + * @type string $content + * @type string $publish + * } + * @return array|IXR_Error + */ + public function wp_editPage( $args ) { + // Items will be escaped in mw_editPost. + $page_id = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + $escaped_username = $this->escape( $username ); + $escaped_password = $this->escape( $password ); + + if ( !$user = $this->login( $escaped_username, $escaped_password ) ) { + return $this->error; + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.editPage' ); + + // Get the page data and make sure it is a page. + $actual_page = get_post($page_id, ARRAY_A); + if ( !$actual_page || ($actual_page['post_type'] != 'page') ) + return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); + + // Make sure the user is allowed to edit pages. + if ( !current_user_can('edit_page', $page_id) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) ); + + // Mark this as content for a page. + $content['post_type'] = 'page'; + + // Arrange args in the way mw_editPost understands. + $args = array( + $page_id, + $username, + $password, + $content, + $publish + ); + + // Let mw_editPost do all of the heavy lifting. + return $this->mw_editPost( $args ); + } + + /** + * Retrieve page list. + * + * @since 2.2.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getPageList( $args ) { + global $wpdb; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPageList' ); + + // Get list of pages ids and titles + $page_list = $wpdb->get_results(" + SELECT ID page_id, + post_title page_title, + post_parent page_parent_id, + post_date_gmt, + post_date, + post_status + FROM {$wpdb->posts} + WHERE post_type = 'page' + ORDER BY ID + "); + + // The date needs to be formatted properly. + $num_pages = count($page_list); + for ( $i = 0; $i < $num_pages; $i++ ) { + $page_list[$i]->dateCreated = $this->_convert_date( $page_list[$i]->post_date ); + $page_list[$i]->date_created_gmt = $this->_convert_date_gmt( $page_list[$i]->post_date_gmt, $page_list[$i]->post_date ); + + unset($page_list[$i]->post_date_gmt); + unset($page_list[$i]->post_date); + unset($page_list[$i]->post_status); + } + + return $page_list; + } + + /** + * Retrieve authors list. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getAuthors( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can('edit_posts') ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getAuthors' ); + + $authors = array(); + foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) { + $authors[] = array( + 'user_id' => $user->ID, + 'user_login' => $user->user_login, + 'display_name' => $user->display_name + ); + } + + return $authors; + } + + /** + * Get list of all tags + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getTags( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getKeywords' ); + + $tags = array(); + + if ( $all_tags = get_tags() ) { + foreach ( (array) $all_tags as $tag ) { + $struct = array(); + $struct['tag_id'] = $tag->term_id; + $struct['name'] = $tag->name; + $struct['count'] = $tag->count; + $struct['slug'] = $tag->slug; + $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) ); + $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) ); + + $tags[] = $struct; + } + } + + return $tags; + } + + /** + * Create new category. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $category + * } + * @return int|IXR_Error Category ID. + */ + public function wp_newCategory( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $category = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.newCategory' ); + + // Make sure the user is allowed to add a category. + if ( ! current_user_can( 'manage_categories' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); + } + + // If no slug was provided make it empty so that + // WordPress will generate one. + if ( empty($category['slug']) ) + $category['slug'] = ''; + + // If no parent_id was provided make it empty + // so that it will be a top level page (no parent). + if ( !isset($category['parent_id']) ) + $category['parent_id'] = ''; + + // If no description was provided make it empty. + if ( empty($category["description"]) ) + $category["description"] = ""; + + $new_category = array( + 'cat_name' => $category['name'], + 'category_nicename' => $category['slug'], + 'category_parent' => $category['parent_id'], + 'category_description' => $category['description'] + ); + + $cat_id = wp_insert_category($new_category, true); + if ( is_wp_error( $cat_id ) ) { + if ( 'term_exists' == $cat_id->get_error_code() ) + return (int) $cat_id->get_error_data(); + else + return new IXR_Error(500, __('Sorry, the new category failed.')); + } elseif ( ! $cat_id ) { + return new IXR_Error(500, __('Sorry, the new category failed.')); + } + + /** + * Fires after a new category has been successfully created via XML-RPC. + * + * @since 3.4.0 + * + * @param int $cat_id ID of the new category. + * @param array $args An array of new category arguments. + */ + do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args ); + + return $cat_id; + } + + /** + * Remove category. + * + * @since 2.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $category_id + * } + * @return bool|IXR_Error See wp_delete_term() for return info. + */ + public function wp_deleteCategory( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $category_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.deleteCategory' ); + + if ( ! current_user_can( 'delete_term', $category_id ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) ); + } + + $status = wp_delete_term( $category_id, 'category' ); + + if ( true == $status ) { + /** + * Fires after a category has been successfully deleted via XML-RPC. + * + * @since 3.4.0 + * + * @param int $category_id ID of the deleted category. + * @param array $args An array of arguments to delete the category. + */ + do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); + } + + return $status; + } + + /** + * Retrieve category list. + * + * @since 2.2.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $category + * @type int $max_results + * } + * @return array|IXR_Error + */ + public function wp_suggestCategories( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $category = $args[3]; + $max_results = (int) $args[4]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.suggestCategories' ); + + $category_suggestions = array(); + $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category); + foreach ( (array) get_categories($args) as $cat ) { + $category_suggestions[] = array( + 'category_id' => $cat->term_id, + 'category_name' => $cat->name + ); + } + + return $category_suggestions; + } + + /** + * Retrieve comment. + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $comment_id + * } + * @return array|IXR_Error + */ + public function wp_getComment($args) { + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + $comment_id = (int) $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getComment' ); + + if ( ! $comment = get_comment( $comment_id ) ) { + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + } + + if ( ! current_user_can( 'edit_comment', $comment_id ) ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); + } + + return $this->_prepare_comment( $comment ); + } + + /** + * Retrieve comments. + * + * Besides the common blog_id (unused), username, and password arguments, it takes a filter + * array as last argument. + * + * Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'. + * + * The defaults are as follows: + * - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold') + * - 'post_id' - Default is ''. The post where the comment is posted. Empty string shows all comments. + * - 'number' - Default is 10. Total number of media items to retrieve. + * - 'offset' - Default is 0. See WP_Query::query() for more. + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $struct + * } + * @return array|IXR_Error Contains a collection of comments. See wp_xmlrpc_server::wp_getComment() for a description of each item contents + */ + public function wp_getComments( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $struct = isset( $args[3] ) ? $args[3] : array(); + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getComments' ); + + if ( isset( $struct['status'] ) ) { + $status = $struct['status']; + } else { + $status = ''; + } + + if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) { + return new IXR_Error( 401, __( 'Invalid comment status.' ) ); + } + + $post_id = ''; + if ( isset( $struct['post_id'] ) ) { + $post_id = absint( $struct['post_id'] ); + } + + $post_type = ''; + if ( isset( $struct['post_type'] ) ) { + $post_type_object = get_post_type_object( $struct['post_type'] ); + if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) { + return new IXR_Error( 404, __( 'Invalid post type.' ) ); + } + $post_type = $struct['post_type']; + } + + $offset = 0; + if ( isset( $struct['offset'] ) ) { + $offset = absint( $struct['offset'] ); + } + + $number = 10; + if ( isset( $struct['number'] ) ) { + $number = absint( $struct['number'] ); + } + + $comments = get_comments( array( + 'status' => $status, + 'post_id' => $post_id, + 'offset' => $offset, + 'number' => $number, + 'post_type' => $post_type, + ) ); + + $comments_struct = array(); + if ( is_array( $comments ) ) { + foreach ( $comments as $comment ) { + $comments_struct[] = $this->_prepare_comment( $comment ); + } + } + + return $comments_struct; + } + + /** + * Delete a comment. + * + * By default, the comment will be moved to the trash instead of deleted. + * See wp_delete_comment() for more information on this behavior. + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $comment_ID + * } + * @return bool|IXR_Error See wp_delete_comment(). + */ + public function wp_deleteComment( $args ) { + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + $comment_ID = (int) $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + if ( ! get_comment( $comment_ID ) ) { + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + } + + if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) ); + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.deleteComment' ); + + $status = wp_delete_comment( $comment_ID ); + + if ( $status ) { + /** + * Fires after a comment has been successfully deleted via XML-RPC. + * + * @since 3.4.0 + * + * @param int $comment_ID ID of the deleted comment. + * @param array $args An array of arguments to delete the comment. + */ + do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_ID, $args ); + } + + return $status; + } + + /** + * Edit comment. + * + * Besides the common blog_id (unused), username, and password arguments, it takes a + * comment_id integer and a content_struct array as last argument. + * + * The allowed keys in the content_struct array are: + * - 'author' + * - 'author_url' + * - 'author_email' + * - 'content' + * - 'date_created_gmt' + * - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $comment_ID + * @type array $content_struct + * } + * @return true|IXR_Error True, on success. + */ + public function wp_editComment( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $comment_ID = (int) $args[3]; + $content_struct = $args[4]; + + if ( !$user = $this->login( $username, $password ) ) { + return $this->error; + } + + if ( ! get_comment( $comment_ID ) ) { + return new IXR_Error( 404, __( 'Invalid comment ID.' ) ); + } + + if ( ! current_user_can( 'edit_comment', $comment_ID ) ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) ); + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.editComment' ); + + if ( isset($content_struct['status']) ) { + $statuses = get_comment_statuses(); + $statuses = array_keys($statuses); + + if ( ! in_array($content_struct['status'], $statuses) ) + return new IXR_Error( 401, __( 'Invalid comment status.' ) ); + $comment_approved = $content_struct['status']; + } + + // Do some timestamp voodoo + if ( !empty( $content_struct['date_created_gmt'] ) ) { + // We know this is supposed to be GMT, so we're going to slap that Z on there by force + $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; + $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + } + + if ( isset($content_struct['content']) ) + $comment_content = $content_struct['content']; + + if ( isset($content_struct['author']) ) + $comment_author = $content_struct['author']; + + if ( isset($content_struct['author_url']) ) + $comment_author_url = $content_struct['author_url']; + + if ( isset($content_struct['author_email']) ) + $comment_author_email = $content_struct['author_email']; + + // We've got all the data -- post it: + $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url'); + + $result = wp_update_comment($comment); + if ( is_wp_error( $result ) ) + return new IXR_Error(500, $result->get_error_message()); + + if ( !$result ) + return new IXR_Error(500, __('Sorry, the comment could not be edited.')); + + /** + * Fires after a comment has been successfully updated via XML-RPC. + * + * @since 3.4.0 + * + * @param int $comment_ID ID of the updated comment. + * @param array $args An array of arguments to update the comment. + */ + do_action( 'xmlrpc_call_success_wp_editComment', $comment_ID, $args ); + + return true; + } + + /** + * Create new comment. + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type string|int $post + * @type array $content_struct + * } + * @return int|IXR_Error See wp_new_comment(). + */ + public function wp_newComment($args) { + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + $post = $args[3]; + $content_struct = $args[4]; + + /** + * Filters whether to allow anonymous comments over XML-RPC. + * + * @since 2.7.0 + * + * @param bool $allow Whether to allow anonymous commenting via XML-RPC. + * Default false. + */ + $allow_anon = apply_filters( 'xmlrpc_allow_anonymous_comments', false ); + + $user = $this->login($username, $password); + + if ( !$user ) { + $logged_in = false; + if ( $allow_anon && get_option('comment_registration') ) { + return new IXR_Error( 403, __( 'You must be registered to comment.' ) ); + } elseif ( ! $allow_anon ) { + return $this->error; + } + } else { + $logged_in = true; + } + + if ( is_numeric($post) ) + $post_id = absint($post); + else + $post_id = url_to_postid($post); + + if ( ! $post_id ) { + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + } + + if ( ! get_post( $post_id ) ) { + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + } + + if ( ! comments_open( $post_id ) ) { + return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) ); + } + + if ( empty( $content_struct['content'] ) ) { + return new IXR_Error( 403, __( 'Comment is required.' ) ); + } + + $comment = array( + 'comment_post_ID' => $post_id, + 'comment_content' => $content_struct['content'], + ); + + if ( $logged_in ) { + $display_name = $user->display_name; + $user_email = $user->user_email; + $user_url = $user->user_url; + + $comment['comment_author'] = $this->escape( $display_name ); + $comment['comment_author_email'] = $this->escape( $user_email ); + $comment['comment_author_url'] = $this->escape( $user_url ); + $comment['user_ID'] = $user->ID; + } else { + $comment['comment_author'] = ''; + if ( isset($content_struct['author']) ) + $comment['comment_author'] = $content_struct['author']; + + $comment['comment_author_email'] = ''; + if ( isset($content_struct['author_email']) ) + $comment['comment_author_email'] = $content_struct['author_email']; + + $comment['comment_author_url'] = ''; + if ( isset($content_struct['author_url']) ) + $comment['comment_author_url'] = $content_struct['author_url']; + + $comment['user_ID'] = 0; + + if ( get_option('require_name_email') ) { + if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] ) + return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); + elseif ( !is_email($comment['comment_author_email']) ) + return new IXR_Error( 403, __( 'A valid email address is required.' ) ); + } + } + + $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.newComment' ); + + $comment_ID = wp_new_comment( $comment, true ); + if ( is_wp_error( $comment_ID ) ) { + return new IXR_Error( 403, $comment_ID->get_error_message() ); + } + + if ( ! $comment_ID ) { + return new IXR_Error( 403, __( 'Something went wrong.' ) ); + } + + /** + * Fires after a new comment has been successfully created via XML-RPC. + * + * @since 3.4.0 + * + * @param int $comment_ID ID of the new comment. + * @param array $args An array of new comment arguments. + */ + do_action( 'xmlrpc_call_success_wp_newComment', $comment_ID, $args ); + + return $comment_ID; + } + + /** + * Retrieve all of the comment status. + * + * @since 2.7.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getCommentStatusList( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + if ( ! current_user_can( 'publish_posts' ) ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getCommentStatusList' ); + + return get_comment_statuses(); + } + + /** + * Retrieve comment count. + * + * @since 2.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $post_id + * } + * @return array|IXR_Error + */ + public function wp_getCommentCount( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + $post = get_post( $post_id, ARRAY_A ); + if ( empty( $post['ID'] ) ) { + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + } + + if ( ! current_user_can( 'edit_post', $post_id ) ) { + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details of this post.' ) ); + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getCommentCount' ); + + $count = wp_count_comments( $post_id ); + + return array( + 'approved' => $count->approved, + 'awaiting_moderation' => $count->moderated, + 'spam' => $count->spam, + 'total_comments' => $count->total_comments + ); + } + + /** + * Retrieve post statuses. + * + * @since 2.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getPostStatusList( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPostStatusList' ); + + return get_post_statuses(); + } + + /** + * Retrieve page statuses. + * + * @since 2.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getPageStatusList( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPageStatusList' ); + + return get_page_statuses(); + } + + /** + * Retrieve page templates. + * + * @since 2.6.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function wp_getPageTemplates( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_pages' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); + + $templates = get_page_templates(); + $templates['Default'] = 'default'; + + return $templates; + } + + /** + * Retrieve blog options. + * + * @since 2.6.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $options + * } + * @return array|IXR_Error + */ + public function wp_getOptions( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $options = isset( $args[3] ) ? (array) $args[3] : array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + // If no specific options where asked for, return all of them + if ( count( $options ) == 0 ) + $options = array_keys($this->blog_options); + + return $this->_getOptions($options); + } + + /** + * Retrieve blog options value from list. + * + * @since 2.6.0 + * + * @param array $options Options to retrieve. + * @return array + */ + public function _getOptions($options) { + $data = array(); + $can_manage = current_user_can( 'manage_options' ); + foreach ( $options as $option ) { + if ( array_key_exists( $option, $this->blog_options ) ) { + $data[$option] = $this->blog_options[$option]; + //Is the value static or dynamic? + if ( isset( $data[$option]['option'] ) ) { + $data[$option]['value'] = get_option( $data[$option]['option'] ); + unset($data[$option]['option']); + } + + if ( ! $can_manage ) + $data[$option]['readonly'] = true; + } + } + + return $data; + } + + /** + * Update blog options. + * + * @since 2.6.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $options + * } + * @return array|IXR_Error + */ + public function wp_setOptions( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $options = (array) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'manage_options' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed to update options.' ) ); + + $option_names = array(); + foreach ( $options as $o_name => $o_value ) { + $option_names[] = $o_name; + if ( !array_key_exists( $o_name, $this->blog_options ) ) + continue; + + if ( $this->blog_options[$o_name]['readonly'] == true ) + continue; + + update_option( $this->blog_options[$o_name]['option'], wp_unslash( $o_value ) ); + } + + //Now return the updated values + return $this->_getOptions($option_names); + } + + /** + * Retrieve a media item by ID + * + * @since 3.1.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $attachment_id + * } + * @return array|IXR_Error Associative array contains: + * - 'date_created_gmt' + * - 'parent' + * - 'link' + * - 'thumbnail' + * - 'title' + * - 'caption' + * - 'description' + * - 'metadata' + */ + public function wp_getMediaItem( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $attachment_id = (int) $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'upload_files' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getMediaItem' ); + + if ( ! $attachment = get_post($attachment_id) ) + return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + + return $this->_prepare_media_item( $attachment ); + } + + /** + * Retrieves a collection of media library items (or attachments) + * + * Besides the common blog_id (unused), username, and password arguments, it takes a filter + * array as last argument. + * + * Accepted 'filter' keys are 'parent_id', 'mime_type', 'offset', and 'number'. + * + * The defaults are as follows: + * - 'number' - Default is 5. Total number of media items to retrieve. + * - 'offset' - Default is 0. See WP_Query::query() for more. + * - 'parent_id' - Default is ''. The post where the media item is attached. Empty string shows all media items. 0 shows unattached media items. + * - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf') + * + * @since 3.1.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $struct + * } + * @return array|IXR_Error Contains a collection of media items. See wp_xmlrpc_server::wp_getMediaItem() for a description of each item contents + */ + public function wp_getMediaLibrary($args) { + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + $struct = isset( $args[3] ) ? $args[3] : array() ; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'upload_files' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getMediaLibrary' ); + + $parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ; + $mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ; + $offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ; + $number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ; + + $attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) ); + + $attachments_struct = array(); + + foreach ($attachments as $attachment ) + $attachments_struct[] = $this->_prepare_media_item( $attachment ); + + return $attachments_struct; + } + + /** + * Retrieves a list of post formats used by the site. + * + * @since 3.1.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error List of post formats, otherwise IXR_Error object. + */ + public function wp_getPostFormats( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login( $username, $password ) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 403, __( 'Sorry, you are not allowed access to details about this site.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPostFormats' ); + + $formats = get_post_format_strings(); + + // find out if they want a list of currently supports formats + if ( isset( $args[3] ) && is_array( $args[3] ) ) { + if ( $args[3]['show-supported'] ) { + if ( current_theme_supports( 'post-formats' ) ) { + $supported = get_theme_support( 'post-formats' ); + + $data = array(); + $data['all'] = $formats; + $data['supported'] = $supported[0]; + + $formats = $data; + } + } + } + + return $formats; + } + + /** + * Retrieves a post type + * + * @since 3.4.0 + * + * @see get_post_type_object() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type string $post_type_name + * @type array $fields (optional) + * } + * @return array|IXR_Error Array contains: + * - 'labels' + * - 'description' + * - 'capability_type' + * - 'cap' + * - 'map_meta_cap' + * - 'hierarchical' + * - 'menu_position' + * - 'taxonomies' + * - 'supports' + */ + public function wp_getPostType( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_type_name = $args[3]; + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** + * Filters the default query fields used by the given XML-RPC method. + * + * @since 3.4.0 + * + * @param array $fields An array of post type query fields for the given method. + * @param string $method The method name. + */ + $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' ); + } + + if ( !$user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPostType' ); + + if ( ! post_type_exists( $post_type_name ) ) + return new IXR_Error( 403, __( 'Invalid post type.' ) ); + + $post_type = get_post_type_object( $post_type_name ); + + if ( ! current_user_can( $post_type->cap->edit_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); + + return $this->_prepare_post_type( $post_type, $fields ); + } + + /** + * Retrieves a post types + * + * @since 3.4.0 + * + * @see get_post_types() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $filter (optional) + * @type array $fields (optional) + * } + * @return array|IXR_Error + */ + public function wp_getPostTypes( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $filter = isset( $args[3] ) ? $args[3] : array( 'public' => true ); + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + $fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getPostTypes' ); + + $post_types = get_post_types( $filter, 'objects' ); + + $struct = array(); + + foreach ( $post_types as $post_type ) { + if ( ! current_user_can( $post_type->cap->edit_posts ) ) + continue; + + $struct[$post_type->name] = $this->_prepare_post_type( $post_type, $fields ); + } + + return $struct; + } + + /** + * Retrieve revisions for a specific post. + * + * @since 3.5.0 + * + * The optional $fields parameter specifies what fields will be included + * in the response array. + * + * @uses wp_get_post_revisions() + * @see wp_getPost() for more on $fields + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $post_id + * @type array $fields (optional) + * } + * @return array|IXR_Error contains a collection of posts. + */ + public function wp_getRevisions( $args ) { + if ( ! $this->minimum_args( $args, 4 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $post_id = (int) $args[3]; + + if ( isset( $args[4] ) ) { + $fields = $args[4]; + } else { + /** + * Filters the default revision query fields used by the given XML-RPC method. + * + * @since 3.5.0 + * + * @param array $field An array of revision query fields. + * @param string $method The method name. + */ + $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' ); + } + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.getRevisions' ); + + if ( ! $post = get_post( $post_id ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! current_user_can( 'edit_post', $post_id ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); + + // Check if revisions are enabled. + if ( ! wp_revisions_enabled( $post ) ) + return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); + + $revisions = wp_get_post_revisions( $post_id ); + + if ( ! $revisions ) + return array(); + + $struct = array(); + + foreach ( $revisions as $revision ) { + if ( ! current_user_can( 'read_post', $revision->ID ) ) + continue; + + // Skip autosaves + if ( wp_is_post_autosave( $revision ) ) + continue; + + $struct[] = $this->_prepare_post( get_object_vars( $revision ), $fields ); + } + + return $struct; + } + + /** + * Restore a post revision + * + * @since 3.5.0 + * + * @uses wp_restore_post_revision() + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $revision_id + * } + * @return bool|IXR_Error false if there was an error restoring, true if success. + */ + public function wp_restoreRevision( $args ) { + if ( ! $this->minimum_args( $args, 3 ) ) + return $this->error; + + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + $revision_id = (int) $args[3]; + + if ( ! $user = $this->login( $username, $password ) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'wp.restoreRevision' ); + + if ( ! $revision = wp_get_post_revision( $revision_id ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( wp_is_post_autosave( $revision ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! $post = get_post( $revision->post_parent ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + // Check if revisions are disabled. + if ( ! wp_revisions_enabled( $post ) ) + return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) ); + + $post = wp_restore_post_revision( $revision_id ); + + return (bool) $post; + } + + /* Blogger API functions. + * specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/ + */ + + /** + * Retrieve blogs that user owns. + * + * Will make more sense once we support multiple blogs. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function blogger_getUsersBlogs($args) { + if ( ! $this->minimum_args( $args, 3 ) ) { + return $this->error; + } + + if ( is_multisite() ) { + return $this->_multisite_getUsersBlogs($args); + } + + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.getUsersBlogs' ); + + $is_admin = current_user_can('manage_options'); + + $struct = array( + 'isAdmin' => $is_admin, + 'url' => get_option('home') . '/', + 'blogid' => '1', + 'blogName' => get_option('blogname'), + 'xmlrpc' => site_url( 'xmlrpc.php', 'rpc' ), + ); + + return array($struct); + } + + /** + * Private function for retrieving a users blogs for multisite setups + * + * @since 3.0.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type string $username Username. + * @type string $password Password. + * } + * @return array|IXR_Error + */ + protected function _multisite_getUsersBlogs( $args ) { + $current_blog = get_site(); + + $domain = $current_blog->domain; + $path = $current_blog->path . 'xmlrpc.php'; + + $rpc = new IXR_Client( set_url_scheme( "http://{$domain}{$path}" ) ); + $rpc->query('wp.getUsersBlogs', $args[1], $args[2]); + $blogs = $rpc->getResponse(); + + if ( isset($blogs['faultCode']) ) + return new IXR_Error($blogs['faultCode'], $blogs['faultString']); + + if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { + return $blogs; + } else { + foreach ( (array) $blogs as $blog ) { + if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) + return array($blog); + } + return array(); + } + } + + /** + * Retrieve user's data. + * + * Gives your client some info about you, so you don't have to. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function blogger_getUserInfo( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.getUserInfo' ); + + $struct = array( + 'nickname' => $user->nickname, + 'userid' => $user->ID, + 'url' => $user->user_url, + 'lastname' => $user->last_name, + 'firstname' => $user->first_name + ); + + return $struct; + } + + /** + * Retrieve post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $post_ID + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function blogger_getPost( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + $post_data = get_post($post_ID, ARRAY_A); + if ( ! $post_data ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.getPost' ); + + $categories = implode(',', wp_get_post_categories($post_ID)); + + $content = '<title>'.wp_unslash($post_data['post_title']).''; + $content .= ''.$categories.''; + $content .= wp_unslash($post_data['post_content']); + + $struct = array( + 'userid' => $post_data['post_author'], + 'dateCreated' => $this->_convert_date( $post_data['post_date'] ), + 'content' => $content, + 'postid' => (string) $post_data['ID'] + ); + + return $struct; + } + + /** + * Retrieve list of recent posts. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type string $appkey (unused) + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $numberposts (optional) + * } + * @return array|IXR_Error + */ + public function blogger_getRecentPosts( $args ) { + + $this->escape($args); + + // $args[0] = appkey - ignored + $username = $args[2]; + $password = $args[3]; + if ( isset( $args[4] ) ) + $query = array( 'numberposts' => absint( $args[4] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( ! current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.getRecentPosts' ); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) { + $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); + return $this->error; + } + + $recent_posts = array(); + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = $this->_convert_date( $entry['post_date'] ); + $categories = implode(',', wp_get_post_categories($entry['ID'])); + + $content = ''.wp_unslash($entry['post_title']).''; + $content .= ''.$categories.''; + $content .= wp_unslash($entry['post_content']); + + $recent_posts[] = array( + 'userid' => $entry['post_author'], + 'dateCreated' => $post_date, + 'content' => $content, + 'postid' => (string) $entry['ID'], + ); + } + + return $recent_posts; + } + + /** + * Deprecated. + * + * @since 1.5.0 + * @deprecated 3.5.0 + * + * @param array $args Unused. + * @return IXR_Error Error object. + */ + public function blogger_getTemplate($args) { + return new IXR_Error( 403, __('Sorry, that file cannot be edited.' ) ); + } + + /** + * Deprecated. + * + * @since 1.5.0 + * @deprecated 3.5.0 + * + * @param array $args Unused. + * @return IXR_Error Error object. + */ + public function blogger_setTemplate($args) { + return new IXR_Error( 403, __('Sorry, that file cannot be edited.' ) ); + } + + /** + * Creates new post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type string $appkey (unused) + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type string $content + * @type string $publish + * } + * @return int|IXR_Error + */ + public function blogger_newPost( $args ) { + $this->escape( $args ); + + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.newPost' ); + + $cap = ($publish) ? 'publish_posts' : 'edit_posts'; + if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || !current_user_can($cap) ) + return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.')); + + $post_status = ($publish) ? 'publish' : 'draft'; + + $post_author = $user->ID; + + $post_title = xmlrpc_getposttitle($content); + $post_category = xmlrpc_getpostcategory($content); + $post_content = xmlrpc_removepostdata($content); + + $post_date = current_time('mysql'); + $post_date_gmt = current_time('mysql', 1); + + $post_data = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); + + $post_ID = wp_insert_post($post_data); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); + + if ( !$post_ID ) + return new IXR_Error(500, __('Sorry, your entry could not be posted.')); + + $this->attach_uploads( $post_ID, $post_content ); + + /** + * Fires after a new post has been successfully created via the XML-RPC Blogger API. + * + * @since 3.4.0 + * + * @param int $post_ID ID of the new post. + * @param array $args An array of new post arguments. + */ + do_action( 'xmlrpc_call_success_blogger_newPost', $post_ID, $args ); + + return $post_ID; + } + + /** + * Edit a post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $post_ID + * @type string $username + * @type string $password + * @type string $content + * @type bool $publish + * } + * @return true|IXR_Error true when done. + */ + public function blogger_editPost( $args ) { + + $this->escape($args); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + $content = $args[4]; + $publish = $args[5]; + + if ( ! $user = $this->login( $username, $password ) ) { + return $this->error; + } + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.editPost' ); + + $actual_post = get_post( $post_ID, ARRAY_A ); + + if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { + return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); + } + + $this->escape($actual_post); + + if ( ! current_user_can( 'edit_post', $post_ID ) ) { + return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); + } + if ( 'publish' == $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); + } + + $postdata = array(); + $postdata['ID'] = $actual_post['ID']; + $postdata['post_content'] = xmlrpc_removepostdata( $content ); + $postdata['post_title'] = xmlrpc_getposttitle( $content ); + $postdata['post_category'] = xmlrpc_getpostcategory( $content ); + $postdata['post_status'] = $actual_post['post_status']; + $postdata['post_excerpt'] = $actual_post['post_excerpt']; + $postdata['post_status'] = $publish ? 'publish' : 'draft'; + + $result = wp_update_post( $postdata ); + + if ( ! $result ) { + return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.')); + } + $this->attach_uploads( $actual_post['ID'], $postdata['post_content'] ); + + /** + * Fires after a post has been successfully updated via the XML-RPC Blogger API. + * + * @since 3.4.0 + * + * @param int $post_ID ID of the updated post. + * @param array $args An array of arguments for the post to edit. + */ + do_action( 'xmlrpc_call_success_blogger_editPost', $post_ID, $args ); + + return true; + } + + /** + * Remove a post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $post_ID + * @type string $username + * @type string $password + * } + * @return true|IXR_Error True when post is deleted. + */ + public function blogger_deletePost( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[1]; + $username = $args[2]; + $password = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'blogger.deletePost' ); + + $actual_post = get_post( $post_ID, ARRAY_A ); + + if ( ! $actual_post || $actual_post['post_type'] != 'post' ) { + return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); + } + + if ( ! current_user_can( 'delete_post', $post_ID ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); + } + + $result = wp_delete_post( $post_ID ); + + if ( ! $result ) { + return new IXR_Error( 500, __( 'The post cannot be deleted.' ) ); + } + + /** + * Fires after a post has been successfully deleted via the XML-RPC Blogger API. + * + * @since 3.4.0 + * + * @param int $post_ID ID of the deleted post. + * @param array $args An array of arguments to delete the post. + */ + do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ID, $args ); + + return true; + } + + /* MetaWeblog API functions + * specs on wherever Dave Winer wants them to be + */ + + /** + * Create a new post. + * + * The 'content_struct' argument must contain: + * - title + * - description + * - mt_excerpt + * - mt_text_more + * - mt_keywords + * - mt_tb_ping_urls + * - categories + * + * Also, it can optionally contain: + * - wp_slug + * - wp_password + * - wp_page_parent_id + * - wp_page_order + * - wp_author_id + * - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending' + * - mt_allow_comments - can be 'open' or 'closed' + * - mt_allow_pings - can be 'open' or 'closed' + * - date_created_gmt + * - dateCreated + * - wp_post_thumbnail + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $content_struct + * @type int $publish + * } + * @return int|IXR_Error + */ + public function mw_newPost($args) { + $this->escape($args); + + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + $publish = isset( $args[4] ) ? $args[4] : 0; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.newPost' ); + + $page_template = ''; + if ( !empty( $content_struct['post_type'] ) ) { + if ( $content_struct['post_type'] == 'page' ) { + if ( $publish ) + $cap = 'publish_pages'; + elseif ( isset( $content_struct['page_status'] ) && 'publish' == $content_struct['page_status'] ) + $cap = 'publish_pages'; + else + $cap = 'edit_pages'; + $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); + $post_type = 'page'; + if ( !empty( $content_struct['wp_page_template'] ) ) + $page_template = $content_struct['wp_page_template']; + } elseif ( $content_struct['post_type'] == 'post' ) { + if ( $publish ) + $cap = 'publish_posts'; + elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status'] ) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } else { + // No other post_type values are allowed here + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + } + } else { + if ( $publish ) + $cap = 'publish_posts'; + elseif ( isset( $content_struct['post_status'] ) && 'publish' == $content_struct['post_status']) + $cap = 'publish_posts'; + else + $cap = 'edit_posts'; + $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); + $post_type = 'post'; + } + + if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) ); + if ( !current_user_can( $cap ) ) + return new IXR_Error( 401, $error_message ); + + // Check for a valid post format if one was given + if ( isset( $content_struct['wp_post_format'] ) ) { + $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); + if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { + return new IXR_Error( 404, __( 'Invalid post format.' ) ); + } + } + + // Let WordPress generate the post_name (slug) unless + // one has been provided. + $post_name = ""; + if ( isset($content_struct['wp_slug']) ) + $post_name = $content_struct['wp_slug']; + + // Only use a password if one was given. + if ( isset($content_struct['wp_password']) ) + $post_password = $content_struct['wp_password']; + + // Only set a post parent if one was provided. + if ( isset($content_struct['wp_page_parent_id']) ) + $post_parent = $content_struct['wp_page_parent_id']; + + // Only set the menu_order if it was provided. + if ( isset($content_struct['wp_page_order']) ) + $menu_order = $content_struct['wp_page_order']; + + $post_author = $user->ID; + + // If an author id was provided then use it instead. + if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID != $content_struct['wp_author_id'] ) ) { + switch ( $post_type ) { + case "post": + if ( !current_user_can( 'edit_others_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) ); + break; + case "page": + if ( !current_user_can( 'edit_others_pages' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) ); + break; + default: + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + } + $author = get_userdata( $content_struct['wp_author_id'] ); + if ( ! $author ) + return new IXR_Error( 404, __( 'Invalid author ID.' ) ); + $post_author = $content_struct['wp_author_id']; + } + + $post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null; + $post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : null; + + $post_status = $publish ? 'publish' : 'draft'; + + if ( isset( $content_struct["{$post_type}_status"] ) ) { + switch ( $content_struct["{$post_type}_status"] ) { + case 'draft': + case 'pending': + case 'private': + case 'publish': + $post_status = $content_struct["{$post_type}_status"]; + break; + default: + $post_status = $publish ? 'publish' : 'draft'; + break; + } + } + + $post_excerpt = isset($content_struct['mt_excerpt']) ? $content_struct['mt_excerpt'] : null; + $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null; + + $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; + + if ( isset($content_struct['mt_allow_comments']) ) { + if ( !is_numeric($content_struct['mt_allow_comments']) ) { + switch ( $content_struct['mt_allow_comments'] ) { + case 'closed': + $comment_status = 'closed'; + break; + case 'open': + $comment_status = 'open'; + break; + default: + $comment_status = get_default_comment_status( $post_type ); + break; + } + } else { + switch ( (int) $content_struct['mt_allow_comments'] ) { + case 0: + case 2: + $comment_status = 'closed'; + break; + case 1: + $comment_status = 'open'; + break; + default: + $comment_status = get_default_comment_status( $post_type ); + break; + } + } + } else { + $comment_status = get_default_comment_status( $post_type ); + } + + if ( isset($content_struct['mt_allow_pings']) ) { + if ( !is_numeric($content_struct['mt_allow_pings']) ) { + switch ( $content_struct['mt_allow_pings'] ) { + case 'closed': + $ping_status = 'closed'; + break; + case 'open': + $ping_status = 'open'; + break; + default: + $ping_status = get_default_comment_status( $post_type, 'pingback' ); + break; + } + } else { + switch ( (int) $content_struct['mt_allow_pings'] ) { + case 0: + $ping_status = 'closed'; + break; + case 1: + $ping_status = 'open'; + break; + default: + $ping_status = get_default_comment_status( $post_type, 'pingback' ); + break; + } + } + } else { + $ping_status = get_default_comment_status( $post_type, 'pingback' ); + } + + if ( $post_more ) + $post_content = $post_content . '' . $post_more; + + $to_ping = null; + if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { + $to_ping = $content_struct['mt_tb_ping_urls']; + if ( is_array($to_ping) ) + $to_ping = implode(' ', $to_ping); + } + + // Do some timestamp voodoo + if ( !empty( $content_struct['date_created_gmt'] ) ) + // We know this is supposed to be GMT, so we're going to slap that Z on there by force + $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; + elseif ( !empty( $content_struct['dateCreated']) ) + $dateCreated = $content_struct['dateCreated']->getIso(); + + if ( !empty( $dateCreated ) ) { + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + } else { + $post_date = ''; + $post_date_gmt = ''; + } + + $post_category = array(); + if ( isset( $content_struct['categories'] ) ) { + $catnames = $content_struct['categories']; + + if ( is_array($catnames) ) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + } + + $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); + + $post_ID = $postdata['ID'] = get_default_post_to_edit( $post_type, true )->ID; + + // Only posts can be sticky + if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { + $data = $postdata; + $data['sticky'] = $content_struct['sticky']; + $error = $this->_toggle_sticky( $data ); + if ( $error ) { + return $error; + } + } + + if ( isset($content_struct['custom_fields']) ) + $this->set_custom_fields($post_ID, $content_struct['custom_fields']); + + if ( isset ( $content_struct['wp_post_thumbnail'] ) ) { + if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) + return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + + unset( $content_struct['wp_post_thumbnail'] ); + } + + // Handle enclosures + $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; + $this->add_enclosure_if_new($post_ID, $thisEnclosure); + + $this->attach_uploads( $post_ID, $post_content ); + + // Handle post formats if assigned, value is validated earlier + // in this function + if ( isset( $content_struct['wp_post_format'] ) ) + set_post_format( $post_ID, $content_struct['wp_post_format'] ); + + $post_ID = wp_insert_post( $postdata, true ); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); + + if ( !$post_ID ) + return new IXR_Error(500, __('Sorry, your entry could not be posted.')); + + /** + * Fires after a new post has been successfully created via the XML-RPC MovableType API. + * + * @since 3.4.0 + * + * @param int $post_ID ID of the new post. + * @param array $args An array of arguments to create the new post. + */ + do_action( 'xmlrpc_call_success_mw_newPost', $post_ID, $args ); + + return strval($post_ID); + } + + /** + * Adds an enclosure to a post if it's new. + * + * @since 2.8.0 + * + * @param integer $post_ID Post ID. + * @param array $enclosure Enclosure data. + */ + public function add_enclosure_if_new( $post_ID, $enclosure ) { + if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) { + $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n"; + $found = false; + if ( $enclosures = get_post_meta( $post_ID, 'enclosure' ) ) { + foreach ( $enclosures as $enc ) { + // This method used to omit the trailing new line. #23219 + if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) { + $found = true; + break; + } + } + } + if ( ! $found ) + add_post_meta( $post_ID, 'enclosure', $encstring ); + } + } + + /** + * Attach upload to a post. + * + * @since 2.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $post_ID Post ID. + * @param string $post_content Post Content for attachment. + */ + public function attach_uploads( $post_ID, $post_content ) { + global $wpdb; + + // find any unattached files + $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); + if ( is_array( $attachments ) ) { + foreach ( $attachments as $file ) { + if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) + $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); + } + } + } + + /** + * Edit a post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $content_struct + * @type int $publish + * } + * @return bool|IXR_Error True on success. + */ + public function mw_editPost( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $content_struct = $args[3]; + $publish = isset( $args[4] ) ? $args[4] : 0; + + if ( ! $user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.editPost' ); + + $postdata = get_post( $post_ID, ARRAY_A ); + + /* + * If there is no post data for the give post id, stop now and return an error. + * Otherwise a new post will be created (which was the old behavior). + */ + if ( ! $postdata || empty( $postdata[ 'ID' ] ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( ! current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + // Use wp.editPost to edit post types other than post and page. + if ( ! in_array( $postdata[ 'post_type' ], array( 'post', 'page' ) ) ) + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + + // Thwart attempt to change the post type. + if ( ! empty( $content_struct[ 'post_type' ] ) && ( $content_struct['post_type'] != $postdata[ 'post_type' ] ) ) + return new IXR_Error( 401, __( 'The post type may not be changed.' ) ); + + // Check for a valid post format if one was given + if ( isset( $content_struct['wp_post_format'] ) ) { + $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); + if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { + return new IXR_Error( 404, __( 'Invalid post format.' ) ); + } + } + + $this->escape($postdata); + + $ID = $postdata['ID']; + $post_content = $postdata['post_content']; + $post_title = $postdata['post_title']; + $post_excerpt = $postdata['post_excerpt']; + $post_password = $postdata['post_password']; + $post_parent = $postdata['post_parent']; + $post_type = $postdata['post_type']; + $menu_order = $postdata['menu_order']; + + // Let WordPress manage slug if none was provided. + $post_name = $postdata['post_name']; + if ( isset($content_struct['wp_slug']) ) + $post_name = $content_struct['wp_slug']; + + // Only use a password if one was given. + if ( isset($content_struct['wp_password']) ) + $post_password = $content_struct['wp_password']; + + // Only set a post parent if one was given. + if ( isset($content_struct['wp_page_parent_id']) ) + $post_parent = $content_struct['wp_page_parent_id']; + + // Only set the menu_order if it was given. + if ( isset($content_struct['wp_page_order']) ) + $menu_order = $content_struct['wp_page_order']; + + $page_template = null; + if ( ! empty( $content_struct['wp_page_template'] ) && 'page' == $post_type ) + $page_template = $content_struct['wp_page_template']; + + $post_author = $postdata['post_author']; + + // Only set the post_author if one is set. + if ( isset( $content_struct['wp_author_id'] ) ) { + // Check permissions if attempting to switch author to or from another user. + if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) { + switch ( $post_type ) { + case 'post': + if ( ! current_user_can( 'edit_others_posts' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) ); + } + break; + case 'page': + if ( ! current_user_can( 'edit_others_pages' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) ); + } + break; + default: + return new IXR_Error( 401, __( 'Invalid post type.' ) ); + } + $post_author = $content_struct['wp_author_id']; + } + } + + if ( isset($content_struct['mt_allow_comments']) ) { + if ( !is_numeric($content_struct['mt_allow_comments']) ) { + switch ( $content_struct['mt_allow_comments'] ) { + case 'closed': + $comment_status = 'closed'; + break; + case 'open': + $comment_status = 'open'; + break; + default: + $comment_status = get_default_comment_status( $post_type ); + break; + } + } else { + switch ( (int) $content_struct['mt_allow_comments'] ) { + case 0: + case 2: + $comment_status = 'closed'; + break; + case 1: + $comment_status = 'open'; + break; + default: + $comment_status = get_default_comment_status( $post_type ); + break; + } + } + } + + if ( isset($content_struct['mt_allow_pings']) ) { + if ( !is_numeric($content_struct['mt_allow_pings']) ) { + switch ( $content_struct['mt_allow_pings'] ) { + case 'closed': + $ping_status = 'closed'; + break; + case 'open': + $ping_status = 'open'; + break; + default: + $ping_status = get_default_comment_status( $post_type, 'pingback' ); + break; + } + } else { + switch ( (int) $content_struct["mt_allow_pings"] ) { + case 0: + $ping_status = 'closed'; + break; + case 1: + $ping_status = 'open'; + break; + default: + $ping_status = get_default_comment_status( $post_type, 'pingback' ); + break; + } + } + } + + if ( isset( $content_struct['title'] ) ) + $post_title = $content_struct['title']; + + if ( isset( $content_struct['description'] ) ) + $post_content = $content_struct['description']; + + $post_category = array(); + if ( isset( $content_struct['categories'] ) ) { + $catnames = $content_struct['categories']; + if ( is_array($catnames) ) { + foreach ($catnames as $cat) { + $post_category[] = get_cat_ID($cat); + } + } + } + + if ( isset( $content_struct['mt_excerpt'] ) ) + $post_excerpt = $content_struct['mt_excerpt']; + + $post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : null; + + $post_status = $publish ? 'publish' : 'draft'; + if ( isset( $content_struct["{$post_type}_status"] ) ) { + switch( $content_struct["{$post_type}_status"] ) { + case 'draft': + case 'pending': + case 'private': + case 'publish': + $post_status = $content_struct["{$post_type}_status"]; + break; + default: + $post_status = $publish ? 'publish' : 'draft'; + break; + } + } + + $tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null; + + if ( 'publish' == $post_status || 'private' == $post_status ) { + if ( 'page' == $post_type && ! current_user_can( 'publish_pages' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) ); + } elseif ( ! current_user_can( 'publish_posts' ) ) { + return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); + } + } + + if ( $post_more ) + $post_content = $post_content . "" . $post_more; + + $to_ping = null; + if ( isset( $content_struct['mt_tb_ping_urls'] ) ) { + $to_ping = $content_struct['mt_tb_ping_urls']; + if ( is_array($to_ping) ) + $to_ping = implode(' ', $to_ping); + } + + // Do some timestamp voodoo. + if ( !empty( $content_struct['date_created_gmt'] ) ) + // We know this is supposed to be GMT, so we're going to slap that Z on there by force. + $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; + elseif ( !empty( $content_struct['dateCreated']) ) + $dateCreated = $content_struct['dateCreated']->getIso(); + + // Default to not flagging the post date to be edited unless it's intentional. + $edit_date = false; + + if ( !empty( $dateCreated ) ) { + $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); + $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); + + // Flag the post date to be edited. + $edit_date = true; + } else { + $post_date = $postdata['post_date']; + $post_date_gmt = $postdata['post_date_gmt']; + } + + // We've got all the data -- post it. + $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'edit_date', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template'); + + $result = wp_update_post($newpost, true); + if ( is_wp_error( $result ) ) + return new IXR_Error(500, $result->get_error_message()); + + if ( !$result ) + return new IXR_Error(500, __('Sorry, your entry could not be edited.')); + + // Only posts can be sticky + if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { + $data = $newpost; + $data['sticky'] = $content_struct['sticky']; + $data['post_type'] = 'post'; + $error = $this->_toggle_sticky( $data, true ); + if ( $error ) { + return $error; + } + } + + if ( isset($content_struct['custom_fields']) ) + $this->set_custom_fields($post_ID, $content_struct['custom_fields']); + + if ( isset ( $content_struct['wp_post_thumbnail'] ) ) { + + // Empty value deletes, non-empty value adds/updates. + if ( empty( $content_struct['wp_post_thumbnail'] ) ) { + delete_post_thumbnail( $post_ID ); + } else { + if ( set_post_thumbnail( $post_ID, $content_struct['wp_post_thumbnail'] ) === false ) + return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); + } + unset( $content_struct['wp_post_thumbnail'] ); + } + + // Handle enclosures. + $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; + $this->add_enclosure_if_new($post_ID, $thisEnclosure); + + $this->attach_uploads( $ID, $post_content ); + + // Handle post formats if assigned, validation is handled earlier in this function. + if ( isset( $content_struct['wp_post_format'] ) ) + set_post_format( $post_ID, $content_struct['wp_post_format'] ); + + /** + * Fires after a post has been successfully updated via the XML-RPC MovableType API. + * + * @since 3.4.0 + * + * @param int $post_ID ID of the updated post. + * @param array $args An array of arguments to update the post. + */ + do_action( 'xmlrpc_call_success_mw_editPost', $post_ID, $args ); + + return true; + } + + /** + * Retrieve post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type int $post_ID + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function mw_getPost( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + $postdata = get_post($post_ID, ARRAY_A); + if ( ! $postdata ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.getPost' ); + + if ($postdata['post_date'] != '') { + $post_date = $this->_convert_date( $postdata['post_date'] ); + $post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] ); + $post_modified = $this->_convert_date( $postdata['post_modified'] ); + $post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] ); + + $categories = array(); + $catids = wp_get_post_categories($post_ID); + foreach ($catids as $catid) + $categories[] = get_cat_name($catid); + + $tagnames = array(); + $tags = wp_get_post_tags( $post_ID ); + if ( !empty( $tags ) ) { + foreach ( $tags as $tag ) + $tagnames[] = $tag->name; + $tagnames = implode( ', ', $tagnames ); + } else { + $tagnames = ''; + } + + $post = get_extended($postdata['post_content']); + $link = get_permalink($postdata['ID']); + + // Get the author info. + $author = get_userdata($postdata['post_author']); + + $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; + + // Consider future posts as published + if ( $postdata['post_status'] === 'future' ) + $postdata['post_status'] = 'publish'; + + // Get post format + $post_format = get_post_format( $post_ID ); + if ( empty( $post_format ) ) + $post_format = 'standard'; + + $sticky = false; + if ( is_sticky( $post_ID ) ) + $sticky = true; + + $enclosure = array(); + foreach ( (array) get_post_custom($post_ID) as $key => $val) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + $encdata = explode("\n", $enc); + $enclosure['url'] = trim(htmlspecialchars($encdata[0])); + $enclosure['length'] = (int) trim($encdata[1]); + $enclosure['type'] = trim($encdata[2]); + break 2; + } + } + } + + $resp = array( + 'dateCreated' => $post_date, + 'userid' => $postdata['post_author'], + 'postid' => $postdata['ID'], + 'description' => $post['main'], + 'title' => $postdata['post_title'], + 'link' => $link, + 'permaLink' => $link, + // commented out because no other tool seems to use this + // 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $postdata['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'wp_more_text' => $post['more_text'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings, + 'mt_keywords' => $tagnames, + 'wp_slug' => $postdata['post_name'], + 'wp_password' => $postdata['post_password'], + 'wp_author_id' => (string) $author->ID, + 'wp_author_display_name' => $author->display_name, + 'date_created_gmt' => $post_date_gmt, + 'post_status' => $postdata['post_status'], + 'custom_fields' => $this->get_custom_fields($post_ID), + 'wp_post_format' => $post_format, + 'sticky' => $sticky, + 'date_modified' => $post_modified, + 'date_modified_gmt' => $post_modified_gmt + ); + + if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure; + + $resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] ); + + return $resp; + } else { + return new IXR_Error(404, __('Sorry, no such post.')); + } + } + + /** + * Retrieve list of recent posts. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $numberposts + * } + * @return array|IXR_Error + */ + public function mw_getRecentPosts( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( ! current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts' ); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) + return array(); + + $recent_posts = array(); + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = $this->_convert_date( $entry['post_date'] ); + $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); + $post_modified = $this->_convert_date( $entry['post_modified'] ); + $post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] ); + + $categories = array(); + $catids = wp_get_post_categories($entry['ID']); + foreach ( $catids as $catid ) + $categories[] = get_cat_name($catid); + + $tagnames = array(); + $tags = wp_get_post_tags( $entry['ID'] ); + if ( !empty( $tags ) ) { + foreach ( $tags as $tag ) { + $tagnames[] = $tag->name; + } + $tagnames = implode( ', ', $tagnames ); + } else { + $tagnames = ''; + } + + $post = get_extended($entry['post_content']); + $link = get_permalink($entry['ID']); + + // Get the post author info. + $author = get_userdata($entry['post_author']); + + $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; + $allow_pings = ('open' == $entry['ping_status']) ? 1 : 0; + + // Consider future posts as published + if ( $entry['post_status'] === 'future' ) + $entry['post_status'] = 'publish'; + + // Get post format + $post_format = get_post_format( $entry['ID'] ); + if ( empty( $post_format ) ) + $post_format = 'standard'; + + $recent_posts[] = array( + 'dateCreated' => $post_date, + 'userid' => $entry['post_author'], + 'postid' => (string) $entry['ID'], + 'description' => $post['main'], + 'title' => $entry['post_title'], + 'link' => $link, + 'permaLink' => $link, + // commented out because no other tool seems to use this + // 'content' => $entry['post_content'], + 'categories' => $categories, + 'mt_excerpt' => $entry['post_excerpt'], + 'mt_text_more' => $post['extended'], + 'wp_more_text' => $post['more_text'], + 'mt_allow_comments' => $allow_comments, + 'mt_allow_pings' => $allow_pings, + 'mt_keywords' => $tagnames, + 'wp_slug' => $entry['post_name'], + 'wp_password' => $entry['post_password'], + 'wp_author_id' => (string) $author->ID, + 'wp_author_display_name' => $author->display_name, + 'date_created_gmt' => $post_date_gmt, + 'post_status' => $entry['post_status'], + 'custom_fields' => $this->get_custom_fields($entry['ID']), + 'wp_post_format' => $post_format, + 'date_modified' => $post_modified, + 'date_modified_gmt' => $post_modified_gmt, + 'sticky' => ( $entry['post_type'] === 'post' && is_sticky( $entry['ID'] ) ), + 'wp_post_thumbnail' => get_post_thumbnail_id( $entry['ID'] ) + ); + } + + return $recent_posts; + } + + /** + * Retrieve the list of categories on a given blog. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function mw_getCategories( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.getCategories' ); + + $categories_struct = array(); + + if ( $cats = get_categories(array('get' => 'all')) ) { + foreach ( $cats as $cat ) { + $struct = array(); + $struct['categoryId'] = $cat->term_id; + $struct['parentId'] = $cat->parent; + $struct['description'] = $cat->name; + $struct['categoryDescription'] = $cat->description; + $struct['categoryName'] = $cat->name; + $struct['htmlUrl'] = esc_html(get_category_link($cat->term_id)); + $struct['rssUrl'] = esc_html(get_category_feed_link($cat->term_id, 'rss2')); + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + /** + * Uploads a file, following your settings. + * + * Adapted from a patch by Johann Richard. + * + * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/ + * + * @since 1.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type array $data + * } + * @return array|IXR_Error + */ + public function mw_newMediaObject( $args ) { + global $wpdb; + + $username = $this->escape( $args[1] ); + $password = $this->escape( $args[2] ); + $data = $args[3]; + + $name = sanitize_file_name( $data['name'] ); + $type = $data['type']; + $bits = $data['bits']; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject' ); + + if ( !current_user_can('upload_files') ) { + $this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) ); + return $this->error; + } + + if ( is_multisite() && upload_is_user_over_quota( false ) ) { + $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); + return $this->error; + } + + /** + * Filters whether to preempt the XML-RPC media upload. + * + * Passing a truthy value will effectively short-circuit the media upload, + * returning that value as a 500 error instead. + * + * @since 2.1.0 + * + * @param bool $error Whether to pre-empt the media upload. Default false. + */ + if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) { + return new IXR_Error( 500, $upload_err ); + } + + $upload = wp_upload_bits($name, null, $bits); + if ( ! empty($upload['error']) ) { + /* translators: 1: file name, 2: error message */ + $errorString = sprintf( __( 'Could not write file %1$s (%2$s).' ), $name, $upload['error'] ); + return new IXR_Error( 500, $errorString ); + } + // Construct the attachment array + $post_id = 0; + if ( ! empty( $data['post_id'] ) ) { + $post_id = (int) $data['post_id']; + + if ( ! current_user_can( 'edit_post', $post_id ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + } + $attachment = array( + 'post_title' => $name, + 'post_content' => '', + 'post_type' => 'attachment', + 'post_parent' => $post_id, + 'post_mime_type' => $type, + 'guid' => $upload[ 'url' ] + ); + + // Save the data + $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); + + /** + * Fires after a new attachment has been added via the XML-RPC MovableType API. + * + * @since 3.4.0 + * + * @param int $id ID of the new attachment. + * @param array $args An array of arguments to add the attachment. + */ + do_action( 'xmlrpc_call_success_mw_newMediaObject', $id, $args ); + + $struct = $this->_prepare_media_item( get_post( $id ) ); + + // Deprecated values + $struct['id'] = $struct['attachment_id']; + $struct['file'] = $struct['title']; + $struct['url'] = $struct['link']; + + return $struct; + } + + /* MovableType API functions + * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html + */ + + /** + * Retrieve the post titles of recent posts. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * @type int $numberposts + * } + * @return array|IXR_Error + */ + public function mt_getRecentPostTitles( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + if ( isset( $args[3] ) ) + $query = array( 'numberposts' => absint( $args[3] ) ); + else + $query = array(); + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.getRecentPostTitles' ); + + $posts_list = wp_get_recent_posts( $query ); + + if ( !$posts_list ) { + $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); + return $this->error; + } + + $recent_posts = array(); + + foreach ($posts_list as $entry) { + if ( !current_user_can( 'edit_post', $entry['ID'] ) ) + continue; + + $post_date = $this->_convert_date( $entry['post_date'] ); + $post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] ); + + $recent_posts[] = array( + 'dateCreated' => $post_date, + 'userid' => $entry['post_author'], + 'postid' => (string) $entry['ID'], + 'title' => $entry['post_title'], + 'post_status' => $entry['post_status'], + 'date_created_gmt' => $post_date_gmt + ); + } + + return $recent_posts; + } + + /** + * Retrieve list of all categories on blog. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $blog_id (unused) + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function mt_getCategoryList( $args ) { + $this->escape( $args ); + + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( !current_user_can( 'edit_posts' ) ) + return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.getCategoryList' ); + + $categories_struct = array(); + + if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) { + foreach ( $cats as $cat ) { + $struct = array(); + $struct['categoryId'] = $cat->term_id; + $struct['categoryName'] = $cat->name; + + $categories_struct[] = $struct; + } + } + + return $categories_struct; + } + + /** + * Retrieve post categories. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $post_ID + * @type string $username + * @type string $password + * } + * @return array|IXR_Error + */ + public function mt_getPostCategories( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + if ( ! get_post( $post_ID ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can( 'edit_post', $post_ID ) ) + return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.getPostCategories' ); + + $categories = array(); + $catids = wp_get_post_categories(intval($post_ID)); + // first listed category will be the primary category + $isPrimary = true; + foreach ( $catids as $catid ) { + $categories[] = array( + 'categoryName' => get_cat_name($catid), + 'categoryId' => (string) $catid, + 'isPrimary' => $isPrimary + ); + $isPrimary = false; + } + + return $categories; + } + + /** + * Sets categories for a post. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $post_ID + * @type string $username + * @type string $password + * @type array $categories + * } + * @return true|IXR_Error True on success. + */ + public function mt_setPostCategories( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + $categories = $args[3]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.setPostCategories' ); + + if ( ! get_post( $post_ID ) ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you are not allowed to edit this post.')); + + $catids = array(); + foreach ( $categories as $cat ) { + $catids[] = $cat['categoryId']; + } + + wp_set_post_categories($post_ID, $catids); + + return true; + } + + /** + * Retrieve an array of methods supported by this server. + * + * @since 1.5.0 + * + * @return array + */ + public function mt_supportedMethods() { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.supportedMethods' ); + + return array_keys( $this->methods ); + } + + /** + * Retrieve an empty array because we don't support per-post text filters. + * + * @since 1.5.0 + */ + public function mt_supportedTextFilters() { + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.supportedTextFilters' ); + + /** + * Filters the MoveableType text filters list for XML-RPC. + * + * @since 2.2.0 + * + * @param array $filters An array of text filters. + */ + return apply_filters( 'xmlrpc_text_filters', array() ); + } + + /** + * Retrieve trackbacks sent to a given post. + * + * @since 1.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $post_ID + * @return array|IXR_Error + */ + public function mt_getTrackbackPings( $post_ID ) { + global $wpdb; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); + + $actual_post = get_post($post_ID, ARRAY_A); + + if ( !$actual_post ) + return new IXR_Error(404, __('Sorry, no such post.')); + + $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + + if ( !$comments ) + return array(); + + $trackback_pings = array(); + foreach ( $comments as $comment ) { + if ( 'trackback' == $comment->comment_type ) { + $content = $comment->comment_content; + $title = substr($content, 8, (strpos($content, '') - 8)); + $trackback_pings[] = array( + 'pingTitle' => $title, + 'pingURL' => $comment->comment_author_url, + 'pingIP' => $comment->comment_author_IP + ); + } + } + + return $trackback_pings; + } + + /** + * Sets a post's publish status to 'publish'. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type int $post_ID + * @type string $username + * @type string $password + * } + * @return int|IXR_Error + */ + public function mt_publishPost( $args ) { + $this->escape( $args ); + + $post_ID = (int) $args[0]; + $username = $args[1]; + $password = $args[2]; + + if ( !$user = $this->login($username, $password) ) + return $this->error; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'mt.publishPost' ); + + $postdata = get_post($post_ID, ARRAY_A); + if ( ! $postdata ) + return new IXR_Error( 404, __( 'Invalid post ID.' ) ); + + if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) ) + return new IXR_Error(401, __('Sorry, you are not allowed to publish this post.')); + + $postdata['post_status'] = 'publish'; + + // retain old cats + $cats = wp_get_post_categories($post_ID); + $postdata['post_category'] = $cats; + $this->escape($postdata); + + return wp_update_post( $postdata ); + } + + /* PingBack functions + * specs on www.hixie.ch/specs/pingback/pingback + */ + + /** + * Retrieves a pingback and registers it. + * + * @since 1.5.0 + * + * @param array $args { + * Method arguments. Note: arguments must be ordered as documented. + * + * @type string $pagelinkedfrom + * @type string $pagelinkedto + * } + * @return string|IXR_Error + */ + public function pingback_ping( $args ) { + global $wpdb; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'pingback.ping' ); + + $this->escape( $args ); + + $pagelinkedfrom = str_replace( '&', '&', $args[0] ); + $pagelinkedto = str_replace( '&', '&', $args[1] ); + $pagelinkedto = str_replace( '&', '&', $pagelinkedto ); + + /** + * Filters the pingback source URI. + * + * @since 3.6.0 + * + * @param string $pagelinkedfrom URI of the page linked from. + * @param string $pagelinkedto URI of the page linked to. + */ + $pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto ); + + if ( ! $pagelinkedfrom ) + return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) ); + + // Check if the page linked to is in our site + $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); + if ( !$pos1 ) + return $this->pingback_error( 0, __( 'Is there no link to us?' ) ); + + // let's find which post is linked to + // FIXME: does url_to_postid() cover all these cases already? + // if so, then let's use it and drop the old code. + $urltest = parse_url($pagelinkedto); + if ( $post_ID = url_to_postid($pagelinkedto) ) { + // $way + } elseif ( isset( $urltest['path'] ) && preg_match('#p/[0-9]{1,}#', $urltest['path'], $match) ) { + // the path defines the post_ID (archives/p/XXXX) + $blah = explode('/', $match[0]); + $post_ID = (int) $blah[1]; + } elseif ( isset( $urltest['query'] ) && preg_match('#p=[0-9]{1,}#', $urltest['query'], $match) ) { + // the querystring defines the post_ID (?p=XXXX) + $blah = explode('=', $match[0]); + $post_ID = (int) $blah[1]; + } elseif ( isset($urltest['fragment']) ) { + // an #anchor is there, it's either... + if ( intval($urltest['fragment']) ) { + // ...an integer #XXXX (simplest case) + $post_ID = (int) $urltest['fragment']; + } elseif ( preg_match('/post-[0-9]+/',$urltest['fragment']) ) { + // ...a post id in the form 'post-###' + $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); + } elseif ( is_string($urltest['fragment']) ) { + // ...or a string #title, a little more complicated + $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); + $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title ); + if (! ($post_ID = $wpdb->get_var($sql)) ) { + // returning unknown error '0' is better than die()ing + return $this->pingback_error( 0, '' ); + } + } + } else { + // TODO: Attempt to extract a post ID from the given URL + return $this->pingback_error( 33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); + } + $post_ID = (int) $post_ID; + + $post = get_post($post_ID); + + if ( !$post ) // Post_ID not found + return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); + + if ( $post_ID == url_to_postid($pagelinkedfrom) ) + return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); + + // Check if pings are on + if ( !pings_open($post) ) + return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); + + // Let's check that the remote site didn't already pingback this entry + if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) ) + return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); + + // very stupid, but gives time to the 'from' server to publish ! + sleep(1); + + $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); + + /** This filter is documented in wp-includes/class-http.php */ + $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) ); + + // Let's check the remote site + $http_api_args = array( + 'timeout' => 10, + 'redirection' => 0, + 'limit_response_size' => 153600, // 150 KB + 'user-agent' => "$user_agent; verifying pingback from $remote_ip", + 'headers' => array( + 'X-Pingback-Forwarded-For' => $remote_ip, + ), + ); + + $request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args ); + $remote_source = $remote_source_original = wp_remote_retrieve_body( $request ); + + if ( ! $remote_source ) { + return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); + } + + /** + * Filters the pingback remote source. + * + * @since 2.5.0 + * + * @param string $remote_source Response source for the page linked from. + * @param string $pagelinkedto URL of the page linked to. + */ + $remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto ); + + // Work around bug in strip_tags(): + $remote_source = str_replace( ']*>/", "\n\n", $remote_source ); + + preg_match( '|([^<]*?)|is', $remote_source, $matchtitle ); + $title = isset( $matchtitle[1] ) ? $matchtitle[1] : ''; + if ( empty( $title ) ) { + return $this->pingback_error( 32, __( 'We cannot find a title on that page.' ) ); + } + + $remote_source = strip_tags( $remote_source, '' ); // just keep the tag we need + + $p = explode( "\n\n", $remote_source ); + + $preg_target = preg_quote($pagelinkedto, '|'); + + foreach ( $p as $para ) { + if ( strpos($para, $pagelinkedto) !== false ) { // it exists, but is it a link? + preg_match("|]+?".$preg_target."[^>]*>([^>]+?)|", $para, $context); + + // If the URL isn't in a link context, keep looking + if ( empty($context) ) + continue; + + // We're going to use this fake tag to mark the context in a bit + // the marker is needed in case the link text appears more than once in the paragraph + $excerpt = preg_replace('|\|', '', $para); + + // prevent really long link text + if ( strlen($context[1]) > 100 ) + $context[1] = substr($context[1], 0, 100) . '…'; + + $marker = ''.$context[1].''; // set up our marker + $excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker + $excerpt = strip_tags($excerpt, ''); // strip all tags but our context marker + $excerpt = trim($excerpt); + $preg_marker = preg_quote($marker, '|'); + $excerpt = preg_replace("|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt); + $excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper + break; + } + } + + if ( empty($context) ) // Link to target not found + return $this->pingback_error( 17, __( 'The source URL does not contain a link to the target URL, and so cannot be used as a source.' ) ); + + $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); + + $context = '[…] ' . esc_html( $excerpt ) . ' […]'; + $pagelinkedfrom = $this->escape( $pagelinkedfrom ); + + $comment_post_ID = (int) $post_ID; + $comment_author = $title; + $comment_author_email = ''; + $this->escape($comment_author); + $comment_author_url = $pagelinkedfrom; + $comment_content = $context; + $this->escape($comment_content); + $comment_type = 'pingback'; + + $commentdata = compact( + 'comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', + 'comment_content', 'comment_type', 'remote_source', 'remote_source_original' + ); + + $comment_ID = wp_new_comment($commentdata); + + if ( is_wp_error( $comment_ID ) ) { + return $this->pingback_error( 0, $comment_ID->get_error_message() ); + } + + /** + * Fires after a post pingback has been sent. + * + * @since 0.71 + * + * @param int $comment_ID Comment ID. + */ + do_action( 'pingback_post', $comment_ID ); + + /* translators: 1: URL of the page linked from, 2: URL of the page linked to */ + return sprintf( __( 'Pingback from %1$s to %2$s registered. Keep the web talking! :-)' ), $pagelinkedfrom, $pagelinkedto ); + } + + /** + * Retrieve array of URLs that pingbacked the given URL. + * + * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html + * + * @since 1.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $url + * @return array|IXR_Error + */ + public function pingback_extensions_getPingbacks( $url ) { + global $wpdb; + + /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ + do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); + + $url = $this->escape( $url ); + + $post_ID = url_to_postid($url); + if ( !$post_ID ) { + // We aren't sure that the resource is available and/or pingback enabled + return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); + } + + $actual_post = get_post($post_ID, ARRAY_A); + + if ( !$actual_post ) { + // No such post = resource not found + return $this->pingback_error( 32, __('The specified target URL does not exist.' ) ); + } + + $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); + + if ( !$comments ) + return array(); + + $pingbacks = array(); + foreach ( $comments as $comment ) { + if ( 'pingback' == $comment->comment_type ) + $pingbacks[] = $comment->comment_author_url; + } + + return $pingbacks; + } + + /** + * Sends a pingback error based on the given error code and message. + * + * @since 3.6.0 + * + * @param int $code Error code. + * @param string $message Error message. + * @return IXR_Error Error object. + */ + protected function pingback_error( $code, $message ) { + /** + * Filters the XML-RPC pingback error return. + * + * @since 3.5.1 + * + * @param IXR_Error $error An IXR_Error object containing the error code and message. + */ + return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) ); + } +} diff --git a/backend/wp-includes/class-wp.php b/backend/wp-includes/class-wp.php new file mode 100644 index 0000000..3172486 --- /dev/null +++ b/backend/wp-includes/class-wp.php @@ -0,0 +1,728 @@ +public_query_vars) ) + $this->public_query_vars[] = $qv; + } + + /** + * Removes a query variable from a list of public query variables. + * + * @since 4.5.0 + * + * @param string $name Query variable name. + */ + public function remove_query_var( $name ) { + $this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) ); + } + + /** + * Set the value of a query variable. + * + * @since 2.3.0 + * + * @param string $key Query variable name. + * @param mixed $value Query variable value. + */ + public function set_query_var($key, $value) { + $this->query_vars[$key] = $value; + } + + /** + * Parse request to find correct WordPress query. + * + * Sets up the query variables based on the request. There are also many + * filters and actions that can be used to further manipulate the result. + * + * @since 2.0.0 + * + * @global WP_Rewrite $wp_rewrite + * + * @param array|string $extra_query_vars Set the extra query variables. + */ + public function parse_request($extra_query_vars = '') { + global $wp_rewrite; + + /** + * Filters whether to parse the request. + * + * @since 3.5.0 + * + * @param bool $bool Whether or not to parse the request. Default true. + * @param WP $this Current WordPress environment instance. + * @param array|string $extra_query_vars Extra passed query variables. + */ + if ( ! apply_filters( 'do_parse_request', true, $this, $extra_query_vars ) ) + return; + + $this->query_vars = array(); + $post_type_query_vars = array(); + + if ( is_array( $extra_query_vars ) ) { + $this->extra_query_vars = & $extra_query_vars; + } elseif ( ! empty( $extra_query_vars ) ) { + parse_str( $extra_query_vars, $this->extra_query_vars ); + } + // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. + + // Fetch the rewrite rules. + $rewrite = $wp_rewrite->wp_rewrite_rules(); + + if ( ! empty($rewrite) ) { + // If we match a rewrite rule, this will be cleared. + $error = '404'; + $this->did_permalink = true; + + $pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : ''; + list( $pathinfo ) = explode( '?', $pathinfo ); + $pathinfo = str_replace( "%", "%25", $pathinfo ); + + list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); + $self = $_SERVER['PHP_SELF']; + $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); + $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); + + // Trim path info from the end and the leading home path from the + // front. For path info requests, this leaves us with the requesting + // filename, if any. For 404 requests, this leaves us with the + // requested permalink. + $req_uri = str_replace($pathinfo, '', $req_uri); + $req_uri = trim($req_uri, '/'); + $req_uri = preg_replace( $home_path_regex, '', $req_uri ); + $req_uri = trim($req_uri, '/'); + $pathinfo = trim($pathinfo, '/'); + $pathinfo = preg_replace( $home_path_regex, '', $pathinfo ); + $pathinfo = trim($pathinfo, '/'); + $self = trim($self, '/'); + $self = preg_replace( $home_path_regex, '', $self ); + $self = trim($self, '/'); + + // The requested permalink is in $pathinfo for path info requests and + // $req_uri for other requests. + if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) { + $requested_path = $pathinfo; + } else { + // If the request uri is the index, blank it out so that we don't try to match it against a rule. + if ( $req_uri == $wp_rewrite->index ) + $req_uri = ''; + $requested_path = $req_uri; + } + $requested_file = $req_uri; + + $this->request = $requested_path; + + // Look for matches. + $request_match = $requested_path; + if ( empty( $request_match ) ) { + // An empty request could only match against ^$ regex + if ( isset( $rewrite['$'] ) ) { + $this->matched_rule = '$'; + $query = $rewrite['$']; + $matches = array(''); + } + } else { + foreach ( (array) $rewrite as $match => $query ) { + // If the requested file is the anchor of the match, prepend it to the path info. + if ( ! empty($requested_file) && strpos($match, $requested_file) === 0 && $requested_file != $requested_path ) + $request_match = $requested_file . '/' . $requested_path; + + if ( preg_match("#^$match#", $request_match, $matches) || + preg_match("#^$match#", urldecode($request_match), $matches) ) { + + if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { + // This is a verbose page match, let's check to be sure about it. + $page = get_page_by_path( $matches[ $varmatch[1] ] ); + if ( ! $page ) { + continue; + } + + $post_status_obj = get_post_status_object( $page->post_status ); + if ( ! $post_status_obj->public && ! $post_status_obj->protected + && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) { + continue; + } + } + + // Got a match. + $this->matched_rule = $match; + break; + } + } + } + + if ( isset( $this->matched_rule ) ) { + // Trim the query of everything up to the '?'. + $query = preg_replace("!^.+\?!", '', $query); + + // Substitute the substring matches into the query. + $query = addslashes(WP_MatchesMapRegex::apply($query, $matches)); + + $this->matched_query = $query; + + // Parse the query. + parse_str($query, $perma_query_vars); + + // If we're processing a 404 request, clear the error var since we found something. + if ( '404' == $error ) + unset( $error, $_GET['error'] ); + } + + // If req_uri is empty or if it is a request for ourself, unset error. + if ( empty($requested_path) || $requested_file == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) { + unset( $error, $_GET['error'] ); + + if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) + unset( $perma_query_vars ); + + $this->did_permalink = false; + } + } + + /** + * Filters the query variables whitelist before processing. + * + * Allows (publicly allowed) query vars to be added, removed, or changed prior + * to executing the query. Needed to allow custom rewrite rules using your own arguments + * to work, or any other custom query variables you want to be publicly available. + * + * @since 1.5.0 + * + * @param array $public_query_vars The array of whitelisted query variables. + */ + $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars ); + + foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) { + if ( is_post_type_viewable( $t ) && $t->query_var ) { + $post_type_query_vars[$t->query_var] = $post_type; + } + } + + foreach ( $this->public_query_vars as $wpvar ) { + if ( isset( $this->extra_query_vars[$wpvar] ) ) + $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; + elseif ( isset( $_POST[$wpvar] ) ) + $this->query_vars[$wpvar] = $_POST[$wpvar]; + elseif ( isset( $_GET[$wpvar] ) ) + $this->query_vars[$wpvar] = $_GET[$wpvar]; + elseif ( isset( $perma_query_vars[$wpvar] ) ) + $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; + + if ( !empty( $this->query_vars[$wpvar] ) ) { + if ( ! is_array( $this->query_vars[$wpvar] ) ) { + $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; + } else { + foreach ( $this->query_vars[$wpvar] as $vkey => $v ) { + if ( !is_object( $v ) ) { + $this->query_vars[$wpvar][$vkey] = (string) $v; + } + } + } + + if ( isset($post_type_query_vars[$wpvar] ) ) { + $this->query_vars['post_type'] = $post_type_query_vars[$wpvar]; + $this->query_vars['name'] = $this->query_vars[$wpvar]; + } + } + } + + // Convert urldecoded spaces back into + + foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) + if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) + $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); + + // Don't allow non-publicly queryable taxonomies to be queried from the front end. + if ( ! is_admin() ) { + foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { + /* + * Disallow when set to the 'taxonomy' query var. + * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). + */ + if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { + unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); + } + } + } + + // Limit publicly queried post_types to those that are publicly_queryable + if ( isset( $this->query_vars['post_type']) ) { + $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); + if ( ! is_array( $this->query_vars['post_type'] ) ) { + if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) + unset( $this->query_vars['post_type'] ); + } else { + $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); + } + } + + // Resolve conflicts between posts with numeric slugs and date archive queries. + $this->query_vars = wp_resolve_numeric_slug_conflicts( $this->query_vars ); + + foreach ( (array) $this->private_query_vars as $var) { + if ( isset($this->extra_query_vars[$var]) ) + $this->query_vars[$var] = $this->extra_query_vars[$var]; + } + + if ( isset($error) ) + $this->query_vars['error'] = $error; + + /** + * Filters the array of parsed query variables. + * + * @since 2.1.0 + * + * @param array $query_vars The array of requested query variables. + */ + $this->query_vars = apply_filters( 'request', $this->query_vars ); + + /** + * Fires once all query variables for the current request have been parsed. + * + * @since 2.1.0 + * + * @param WP $this Current WordPress environment instance (passed by reference). + */ + do_action_ref_array( 'parse_request', array( &$this ) ); + } + + /** + * Sends additional HTTP headers for caching, content type, etc. + * + * Sets the Content-Type header. Sets the 'error' status (if passed) and optionally exits. + * If showing a feed, it will also send Last-Modified, ETag, and 304 status if needed. + * + * @since 2.0.0 + * @since 4.4.0 `X-Pingback` header is added conditionally after posts have been queried in handle_404(). + */ + public function send_headers() { + $headers = array(); + $status = null; + $exit_required = false; + + if ( is_user_logged_in() ) + $headers = array_merge($headers, wp_get_nocache_headers()); + if ( ! empty( $this->query_vars['error'] ) ) { + $status = (int) $this->query_vars['error']; + if ( 404 === $status ) { + if ( ! is_user_logged_in() ) + $headers = array_merge($headers, wp_get_nocache_headers()); + $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); + } elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) { + $exit_required = true; + } + } elseif ( empty( $this->query_vars['feed'] ) ) { + $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset'); + } else { + // Set the correct content type for feeds + $type = $this->query_vars['feed']; + if ( 'feed' == $this->query_vars['feed'] ) { + $type = get_default_feed(); + } + $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); + + // We're showing a feed, so WP is indeed the only thing that last changed. + if ( ! empty( $this->query_vars['withcomments'] ) + || false !== strpos( $this->query_vars['feed'], 'comments-' ) + || ( empty( $this->query_vars['withoutcomments'] ) + && ( ! empty( $this->query_vars['p'] ) + || ! empty( $this->query_vars['name'] ) + || ! empty( $this->query_vars['page_id'] ) + || ! empty( $this->query_vars['pagename'] ) + || ! empty( $this->query_vars['attachment'] ) + || ! empty( $this->query_vars['attachment_id'] ) + ) + ) + ) { + $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastcommentmodified( 'GMT' ), false ); + } else { + $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastpostmodified( 'GMT' ), false ); + } + + if ( ! $wp_last_modified ) { + $wp_last_modified = date( 'D, d M Y H:i:s' ); + } + + $wp_last_modified .= ' GMT'; + + $wp_etag = '"' . md5($wp_last_modified) . '"'; + $headers['Last-Modified'] = $wp_last_modified; + $headers['ETag'] = $wp_etag; + + // Support for Conditional GET + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) + $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); + else $client_etag = false; + + $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']); + // If string is empty, return 0. If not, attempt to parse into a timestamp + $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; + + // Make a timestamp for our most recent modification... + $wp_modified_timestamp = strtotime($wp_last_modified); + + if ( ($client_last_modified && $client_etag) ? + (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : + (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { + $status = 304; + $exit_required = true; + } + } + + /** + * Filters the HTTP headers before they're sent to the browser. + * + * @since 2.8.0 + * + * @param array $headers The list of headers to be sent. + * @param WP $this Current WordPress environment instance. + */ + $headers = apply_filters( 'wp_headers', $headers, $this ); + + if ( ! empty( $status ) ) + status_header( $status ); + + // If Last-Modified is set to false, it should not be sent (no-cache situation). + if ( isset( $headers['Last-Modified'] ) && false === $headers['Last-Modified'] ) { + unset( $headers['Last-Modified'] ); + + // In PHP 5.3+, make sure we are not sending a Last-Modified header. + if ( function_exists( 'header_remove' ) ) { + @header_remove( 'Last-Modified' ); + } else { + // In PHP 5.2, send an empty Last-Modified header, but only as a + // last resort to override a header already sent. #WP23021 + foreach ( headers_list() as $header ) { + if ( 0 === stripos( $header, 'Last-Modified' ) ) { + $headers['Last-Modified'] = ''; + break; + } + } + } + } + + foreach ( (array) $headers as $name => $field_value ) + @header("{$name}: {$field_value}"); + + if ( $exit_required ) + exit(); + + /** + * Fires once the requested HTTP headers for caching, content type, etc. have been sent. + * + * @since 2.1.0 + * + * @param WP $this Current WordPress environment instance (passed by reference). + */ + do_action_ref_array( 'send_headers', array( &$this ) ); + } + + /** + * Sets the query string property based off of the query variable property. + * + * The {@see 'query_string'} filter is deprecated, but still works. Plugins should + * use the {@see 'request'} filter instead. + * + * @since 2.0.0 + */ + public function build_query_string() { + $this->query_string = ''; + foreach ( (array) array_keys($this->query_vars) as $wpvar) { + if ( '' != $this->query_vars[$wpvar] ) { + $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; + if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars. + continue; + $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); + } + } + + if ( has_filter( 'query_string' ) ) { // Don't bother filtering and parsing if no plugins are hooked in. + /** + * Filters the query string before parsing. + * + * @since 1.5.0 + * @deprecated 2.1.0 Use 'query_vars' or 'request' filters instead. + * + * @param string $query_string The query string to modify. + */ + $this->query_string = apply_filters( 'query_string', $this->query_string ); + parse_str($this->query_string, $this->query_vars); + } + } + + /** + * Set up the WordPress Globals. + * + * The query_vars property will be extracted to the GLOBALS. So care should + * be taken when naming global variables that might interfere with the + * WordPress environment. + * + * @since 2.0.0 + * + * @global WP_Query $wp_query + * @global string $query_string Query string for the loop. + * @global array $posts The found posts. + * @global WP_Post|null $post The current post, if available. + * @global string $request The SQL statement for the request. + * @global int $more Only set, if single page or post. + * @global int $single If single page or post. Only set, if single page or post. + * @global WP_User $authordata Only set, if author archive. + */ + public function register_globals() { + global $wp_query; + + // Extract updated query vars back into global namespace. + foreach ( (array) $wp_query->query_vars as $key => $value ) { + $GLOBALS[ $key ] = $value; + } + + $GLOBALS['query_string'] = $this->query_string; + $GLOBALS['posts'] = & $wp_query->posts; + $GLOBALS['post'] = isset( $wp_query->post ) ? $wp_query->post : null; + $GLOBALS['request'] = $wp_query->request; + + if ( $wp_query->is_single() || $wp_query->is_page() ) { + $GLOBALS['more'] = 1; + $GLOBALS['single'] = 1; + } + + if ( $wp_query->is_author() && isset( $wp_query->post ) ) + $GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author ); + } + + /** + * Set up the current user. + * + * @since 2.0.0 + */ + public function init() { + wp_get_current_user(); + } + + /** + * Set up the Loop based on the query variables. + * + * @since 2.0.0 + * + * @global WP_Query $wp_the_query + */ + public function query_posts() { + global $wp_the_query; + $this->build_query_string(); + $wp_the_query->query($this->query_vars); + } + + /** + * Set the Headers for 404, if nothing is found for requested URL. + * + * Issue a 404 if a request doesn't match any posts and doesn't match + * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already + * issued, and if the request was not a search or the homepage. + * + * Otherwise, issue a 200. + * + * This sets headers after posts have been queried. handle_404() really means "handle status." + * By inspecting the result of querying posts, seemingly successful requests can be switched to + * a 404 so that canonical redirection logic can kick in. + * + * @since 2.0.0 + * + * @global WP_Query $wp_query + */ + public function handle_404() { + global $wp_query; + + /** + * Filters whether to short-circuit default header status handling. + * + * Returning a non-false value from the filter will short-circuit the handling + * and return early. + * + * @since 4.5.0 + * + * @param bool $preempt Whether to short-circuit default header status handling. Default false. + * @param WP_Query $wp_query WordPress Query object. + */ + if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) { + return; + } + + // If we've already issued a 404, bail. + if ( is_404() ) + return; + + // Never 404 for the admin, robots, or if we found posts. + if ( is_admin() || is_robots() || $wp_query->posts ) { + + $success = true; + if ( is_singular() ) { + $p = false; + + if ( $wp_query->post instanceof WP_Post ) { + $p = clone $wp_query->post; + } + + // Only set X-Pingback for single posts that allow pings. + if ( $p && pings_open( $p ) ) { + @header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) ); + } + + // check for paged content that exceeds the max number of pages + $next = ''; + if ( $p && false !== strpos( $p->post_content, $next ) && ! empty( $this->query_vars['page'] ) ) { + $page = trim( $this->query_vars['page'], '/' ); + $success = (int) $page <= ( substr_count( $p->post_content, $next ) + 1 ); + } + } + + if ( $success ) { + status_header( 200 ); + return; + } + } + + // We will 404 for paged queries, as no posts were found. + if ( ! is_paged() ) { + + // Don't 404 for authors without posts as long as they matched an author on this site. + $author = get_query_var( 'author' ); + if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author ) ) { + status_header( 200 ); + return; + } + + // Don't 404 for these queries if they matched an object. + if ( ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object() ) { + status_header( 200 ); + return; + } + + // Don't 404 for these queries either. + if ( is_home() || is_search() || is_feed() ) { + status_header( 200 ); + return; + } + } + + // Guess it's time to 404. + $wp_query->set_404(); + status_header( 404 ); + nocache_headers(); + } + + /** + * Sets up all of the variables required by the WordPress environment. + * + * The action {@see 'wp'} has one parameter that references the WP object. It + * allows for accessing the properties and methods to further manipulate the + * object. + * + * @since 2.0.0 + * + * @param string|array $query_args Passed to parse_request(). + */ + public function main($query_args = '') { + $this->init(); + $this->parse_request($query_args); + $this->send_headers(); + $this->query_posts(); + $this->handle_404(); + $this->register_globals(); + + /** + * Fires once the WordPress environment has been set up. + * + * @since 2.1.0 + * + * @param WP $this Current WordPress environment instance (passed by reference). + */ + do_action_ref_array( 'wp', array( &$this ) ); + } +} diff --git a/backend/wp-includes/class.wp-dependencies.php b/backend/wp-includes/class.wp-dependencies.php new file mode 100644 index 0000000..ba64258 --- /dev/null +++ b/backend/wp-includes/class.wp-dependencies.php @@ -0,0 +1,396 @@ +queue : (array) $handles; + $this->all_deps( $handles ); + + foreach ( $this->to_do as $key => $handle ) { + if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) { + /* + * Attempt to process the item. If successful, + * add the handle to the done array. + * + * Unset the item from the to_do array. + */ + if ( $this->do_item( $handle, $group ) ) + $this->done[] = $handle; + + unset( $this->to_do[$key] ); + } + } + + return $this->done; + } + + /** + * Processes a dependency. + * + * @since 2.6.0 + * + * @param string $handle Name of the item. Should be unique. + * @return bool True on success, false if not set. + */ + public function do_item( $handle ) { + return isset($this->registered[$handle]); + } + + /** + * Determines dependencies. + * + * Recursively builds an array of items to process taking + * dependencies into account. Does NOT catch infinite loops. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * @since 2.8.0 Added the `$group` parameter. + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + * @param bool $recursion Internal flag that function is calling itself. + * @param int|false $group Group level: (int) level, (false) no groups. + * @return bool True on success, false on failure. + */ + public function all_deps( $handles, $recursion = false, $group = false ) { + if ( !$handles = (array) $handles ) + return false; + + foreach ( $handles as $handle ) { + $handle_parts = explode('?', $handle); + $handle = $handle_parts[0]; + $queued = in_array($handle, $this->to_do, true); + + if ( in_array($handle, $this->done, true) ) // Already done + continue; + + $moved = $this->set_group( $handle, $recursion, $group ); + $new_group = $this->groups[ $handle ]; + + if ( $queued && !$moved ) // already queued and in the right group + continue; + + $keep_going = true; + if ( !isset($this->registered[$handle]) ) + $keep_going = false; // Item doesn't exist. + elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) ) + $keep_going = false; // Item requires dependencies that don't exist. + elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $new_group ) ) + $keep_going = false; // Item requires dependencies that don't exist. + + if ( ! $keep_going ) { // Either item or its dependencies don't exist. + if ( $recursion ) + return false; // Abort this branch. + else + continue; // We're at the top level. Move on to the next one. + } + + if ( $queued ) // Already grabbed it and its dependencies. + continue; + + if ( isset($handle_parts[1]) ) + $this->args[$handle] = $handle_parts[1]; + + $this->to_do[] = $handle; + } + + return true; + } + + /** + * Register an item. + * + * Registers the item if no item of that name already exists. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * + * @param string $handle Name of the item. Should be unique. + * @param string $src Full URL of the item, or path of the item relative to the WordPress root directory. + * @param array $deps Optional. An array of registered item handles this item depends on. Default empty array. + * @param string|bool|null $ver Optional. String specifying item version number, if it has one, which is added to the URL + * as a query string for cache busting purposes. If version is set to false, a version + * number is automatically added equal to current installed WordPress version. + * If set to null, no version is added. + * @param mixed $args Optional. Custom property of the item. NOT the class property $args. Examples: $media, $in_footer. + * @return bool Whether the item has been registered. True on success, false on failure. + */ + public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) { + if ( isset($this->registered[$handle]) ) + return false; + $this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args ); + return true; + } + + /** + * Add extra item data. + * + * Adds data to a registered item. + * + * @since 2.6.0 + * + * @param string $handle Name of the item. Should be unique. + * @param string $key The data key. + * @param mixed $value The data value. + * @return bool True on success, false on failure. + */ + public function add_data( $handle, $key, $value ) { + if ( !isset( $this->registered[$handle] ) ) + return false; + + return $this->registered[$handle]->add_data( $key, $value ); + } + + /** + * Get extra item data. + * + * Gets data associated with a registered item. + * + * @since 3.3.0 + * + * @param string $handle Name of the item. Should be unique. + * @param string $key The data key. + * @return mixed Extra item data (string), false otherwise. + */ + public function get_data( $handle, $key ) { + if ( !isset( $this->registered[$handle] ) ) + return false; + + if ( !isset( $this->registered[$handle]->extra[$key] ) ) + return false; + + return $this->registered[$handle]->extra[$key]; + } + + /** + * Un-register an item or items. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + * @return void + */ + public function remove( $handles ) { + foreach ( (array) $handles as $handle ) + unset($this->registered[$handle]); + } + + /** + * Queue an item or items. + * + * Decodes handles and arguments, then queues handles and stores + * arguments in the class property $args. For example in extending + * classes, $args is appended to the item url as a query string. + * Note $args is NOT the $args property of items in the $registered array. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + */ + public function enqueue( $handles ) { + foreach ( (array) $handles as $handle ) { + $handle = explode('?', $handle); + if ( !in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]]) ) { + $this->queue[] = $handle[0]; + if ( isset($handle[1]) ) + $this->args[$handle[0]] = $handle[1]; + } + } + } + + /** + * Dequeue an item or items. + * + * Decodes handles and arguments, then dequeues handles + * and removes arguments from the class property $args. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + */ + public function dequeue( $handles ) { + foreach ( (array) $handles as $handle ) { + $handle = explode('?', $handle); + $key = array_search($handle[0], $this->queue); + if ( false !== $key ) { + unset($this->queue[$key]); + unset($this->args[$handle[0]]); + } + } + } + + /** + * Recursively search the passed dependency tree for $handle + * + * @since 4.0.0 + * + * @param array $queue An array of queued _WP_Dependency handle objects. + * @param string $handle Name of the item. Should be unique. + * @return bool Whether the handle is found after recursively searching the dependency tree. + */ + protected function recurse_deps( $queue, $handle ) { + foreach ( $queue as $queued ) { + if ( ! isset( $this->registered[ $queued ] ) ) { + continue; + } + + if ( in_array( $handle, $this->registered[ $queued ]->deps ) ) { + return true; + } elseif ( $this->recurse_deps( $this->registered[ $queued ]->deps, $handle ) ) { + return true; + } + } + + return false; + } + + /** + * Query list for an item. + * + * @since 2.1.0 + * @since 2.6.0 Moved from `WP_Scripts`. + * + * @param string $handle Name of the item. Should be unique. + * @param string $list Property name of list array. + * @return bool|_WP_Dependency Found, or object Item data. + */ + public function query( $handle, $list = 'registered' ) { + switch ( $list ) { + case 'registered' : + case 'scripts': // back compat + if ( isset( $this->registered[ $handle ] ) ) + return $this->registered[ $handle ]; + return false; + + case 'enqueued' : + case 'queue' : + if ( in_array( $handle, $this->queue ) ) { + return true; + } + return $this->recurse_deps( $this->queue, $handle ); + + case 'to_do' : + case 'to_print': // back compat + return in_array( $handle, $this->to_do ); + + case 'done' : + case 'printed': // back compat + return in_array( $handle, $this->done ); + } + return false; + } + + /** + * Set item group, unless already in a lower group. + * + * @since 2.8.0 + * + * @param string $handle Name of the item. Should be unique. + * @param bool $recursion Internal flag that calling function was called recursively. + * @param mixed $group Group level. + * @return bool Not already in the group or a lower group + */ + public function set_group( $handle, $recursion, $group ) { + $group = (int) $group; + + if ( isset( $this->groups[ $handle ] ) && $this->groups[ $handle ] <= $group ) { + return false; + } + + $this->groups[ $handle ] = $group; + + return true; + } + +} diff --git a/backend/wp-includes/class.wp-scripts.php b/backend/wp-includes/class.wp-scripts.php new file mode 100644 index 0000000..a9299f0 --- /dev/null +++ b/backend/wp-includes/class.wp-scripts.php @@ -0,0 +1,560 @@ +init(); + add_action( 'init', array( $this, 'init' ), 0 ); + } + + /** + * Initialize the class. + * + * @since 3.4.0 + */ + public function init() { + /** + * Fires when the WP_Scripts instance is initialized. + * + * @since 2.6.0 + * + * @param WP_Scripts $this WP_Scripts instance (passed by reference). + */ + do_action_ref_array( 'wp_default_scripts', array(&$this) ); + } + + /** + * Prints scripts. + * + * Prints the scripts passed to it or the print queue. Also prints all necessary dependencies. + * + * @since 2.1.0 + * @since 2.8.0 Added the `$group` parameter. + * + * @param mixed $handles Optional. Scripts to be printed. (void) prints queue, (string) prints + * that script, (array of strings) prints those scripts. Default false. + * @param int $group Optional. If scripts were queued in groups prints this group number. + * Default false. + * @return array Scripts that have been printed. + */ + public function print_scripts( $handles = false, $group = false ) { + return $this->do_items( $handles, $group ); + } + + /** + * Prints extra scripts of a registered script. + * + * @since 2.1.0 + * @since 2.8.0 Added the `$echo` parameter. + * @deprecated 3.3.0 + * + * @see print_extra_script() + * + * @param string $handle The script's registered handle. + * @param bool $echo Optional. Whether to echo the extra script instead of just returning it. + * Default true. + * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise. + */ + public function print_scripts_l10n( $handle, $echo = true ) { + _deprecated_function( __FUNCTION__, '3.3.0', 'WP_Scripts::print_extra_script()' ); + return $this->print_extra_script( $handle, $echo ); + } + + /** + * Prints extra scripts of a registered script. + * + * @since 3.3.0 + * + * @param string $handle The script's registered handle. + * @param bool $echo Optional. Whether to echo the extra script instead of just returning it. + * Default true. + * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise. + */ + public function print_extra_script( $handle, $echo = true ) { + if ( !$output = $this->get_data( $handle, 'data' ) ) + return; + + if ( !$echo ) + return $output; + + echo "\n"; + + return true; + } + + /** + * Processes a script dependency. + * + * @since 2.6.0 + * @since 2.8.0 Added the `$group` parameter. + * + * @see WP_Dependencies::do_item() + * + * @param string $handle The script's registered handle. + * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. + * @return bool True on success, false on failure. + */ + public function do_item( $handle, $group = false ) { + if ( !parent::do_item($handle) ) + return false; + + if ( 0 === $group && $this->groups[$handle] > 0 ) { + $this->in_footer[] = $handle; + return false; + } + + if ( false === $group && in_array($handle, $this->in_footer, true) ) + $this->in_footer = array_diff( $this->in_footer, (array) $handle ); + + $obj = $this->registered[$handle]; + + if ( null === $obj->ver ) { + $ver = ''; + } else { + $ver = $obj->ver ? $obj->ver : $this->default_version; + } + + if ( isset($this->args[$handle]) ) + $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; + + $src = $obj->src; + $cond_before = $cond_after = ''; + $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; + + if ( $conditional ) { + $cond_before = "\n"; + } + + $before_handle = $this->print_inline_script( $handle, 'before', false ); + $after_handle = $this->print_inline_script( $handle, 'after', false ); + + if ( $before_handle ) { + $before_handle = sprintf( "\n", $before_handle ); + } + + if ( $after_handle ) { + $after_handle = sprintf( "\n", $after_handle ); + } + + if ( $this->do_concat ) { + /** + * Filters the script loader source. + * + * @since 2.2.0 + * + * @param string $src Script loader source path. + * @param string $handle Script handle. + */ + $srce = apply_filters( 'script_loader_src', $src, $handle ); + + if ( $this->in_default_dir( $srce ) && ( $before_handle || $after_handle ) ) { + $this->do_concat = false; + + // Have to print the so-far concatenated scripts right away to maintain the right order. + _print_scripts(); + $this->reset(); + } elseif ( $this->in_default_dir( $srce ) && ! $conditional ) { + $this->print_code .= $this->print_extra_script( $handle, false ); + $this->concat .= "$handle,"; + $this->concat_version .= "$handle$ver"; + return true; + } else { + $this->ext_handles .= "$handle,"; + $this->ext_version .= "$handle$ver"; + } + } + + $has_conditional_data = $conditional && $this->get_data( $handle, 'data' ); + + if ( $has_conditional_data ) { + echo $cond_before; + } + + $this->print_extra_script( $handle ); + + if ( $has_conditional_data ) { + echo $cond_after; + } + + // A single item may alias a set of items, by having dependencies, but no source. + if ( ! $obj->src ) { + return true; + } + + if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) { + $src = $this->base_url . $src; + } + + if ( ! empty( $ver ) ) + $src = add_query_arg( 'ver', $ver, $src ); + + /** This filter is documented in wp-includes/class.wp-scripts.php */ + $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); + + if ( ! $src ) + return true; + + $tag = "{$cond_before}{$before_handle}\n{$after_handle}{$cond_after}"; + + /** + * Filters the HTML script tag of an enqueued script. + * + * @since 4.1.0 + * + * @param string $tag The `\n", $output ); + } + + return $output; + } + + /** + * Localizes a script, only if the script has already been added. + * + * @since 2.1.0 + * + * @param string $handle + * @param string $object_name + * @param array $l10n + * @return bool + */ + public function localize( $handle, $object_name, $l10n ) { + if ( $handle === 'jquery' ) + $handle = 'jquery-core'; + + if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present + $after = $l10n['l10n_print_after']; + unset($l10n['l10n_print_after']); + } + + foreach ( (array) $l10n as $key => $value ) { + if ( !is_scalar($value) ) + continue; + + $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8'); + } + + $script = "var $object_name = " . wp_json_encode( $l10n ) . ';'; + + if ( !empty($after) ) + $script .= "\n$after;"; + + $data = $this->get_data( $handle, 'data' ); + + if ( !empty( $data ) ) + $script = "$data\n$script"; + + return $this->add_data( $handle, 'data', $script ); + } + + /** + * Sets handle group. + * + * @since 2.8.0 + * + * @see WP_Dependencies::set_group() + * + * @param string $handle Name of the item. Should be unique. + * @param bool $recursion Internal flag that calling function was called recursively. + * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. + * @return bool Not already in the group or a lower group + */ + public function set_group( $handle, $recursion, $group = false ) { + if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 ) + $grp = 1; + else + $grp = (int) $this->get_data( $handle, 'group' ); + + if ( false !== $group && $grp > $group ) + $grp = $group; + + return parent::set_group( $handle, $recursion, $grp ); + } + + /** + * Determines script dependencies. + * + * @since 2.1.0 + * + * @see WP_Dependencies::all_deps() + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + * @param bool $recursion Internal flag that function is calling itself. + * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false. + * @return bool True on success, false on failure. + */ + public function all_deps( $handles, $recursion = false, $group = false ) { + $r = parent::all_deps( $handles, $recursion, $group ); + if ( ! $recursion ) { + /** + * Filters the list of script dependencies left to print. + * + * @since 2.3.0 + * + * @param array $to_do An array of script dependencies. + */ + $this->to_do = apply_filters( 'print_scripts_array', $this->to_do ); + } + return $r; + } + + /** + * Processes items and dependencies for the head group. + * + * @since 2.8.0 + * + * @see WP_Dependencies::do_items() + * + * @return array Handles of items that have been processed. + */ + public function do_head_items() { + $this->do_items(false, 0); + return $this->done; + } + + /** + * Processes items and dependencies for the footer group. + * + * @since 2.8.0 + * + * @see WP_Dependencies::do_items() + * + * @return array Handles of items that have been processed. + */ + public function do_footer_items() { + $this->do_items(false, 1); + return $this->done; + } + + /** + * Whether a handle's source is in a default directory. + * + * @since 2.8.0 + * + * @param string $src The source of the enqueued script. + * @return bool True if found, false if not. + */ + public function in_default_dir( $src ) { + if ( ! $this->default_dirs ) { + return true; + } + + if ( 0 === strpos( $src, '/' . WPINC . '/js/l10n' ) ) { + return false; + } + + foreach ( (array) $this->default_dirs as $test ) { + if ( 0 === strpos( $src, $test ) ) { + return true; + } + } + return false; + } + + /** + * Resets class properties. + * + * @since 2.8.0 + */ + public function reset() { + $this->do_concat = false; + $this->print_code = ''; + $this->concat = ''; + $this->concat_version = ''; + $this->print_html = ''; + $this->ext_version = ''; + $this->ext_handles = ''; + } +} diff --git a/backend/wp-includes/class.wp-styles.php b/backend/wp-includes/class.wp-styles.php new file mode 100644 index 0000000..93e008a --- /dev/null +++ b/backend/wp-includes/class.wp-styles.php @@ -0,0 +1,388 @@ +registered[$handle]; + if ( null === $obj->ver ) + $ver = ''; + else + $ver = $obj->ver ? $obj->ver : $this->default_version; + + if ( isset($this->args[$handle]) ) + $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; + + if ( $this->do_concat ) { + if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) { + $this->concat .= "$handle,"; + $this->concat_version .= "$handle$ver"; + + $this->print_code .= $this->print_inline_style( $handle, false ); + + return true; + } + } + + if ( isset($obj->args) ) + $media = esc_attr( $obj->args ); + else + $media = 'all'; + + // A single item may alias a set of items, by having dependencies, but no source. + if ( ! $obj->src ) { + if ( $inline_style = $this->print_inline_style( $handle, false ) ) { + $inline_style = sprintf( "\n", esc_attr( $handle ), $inline_style ); + if ( $this->do_concat ) { + $this->print_html .= $inline_style; + } else { + echo $inline_style; + } + } + return true; + } + + $href = $this->_css_href( $obj->src, $ver, $handle ); + if ( ! $href ) { + return true; + } + + $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; + $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; + + /** + * Filters the HTML link tag of an enqueued style. + * + * @since 2.6.0 + * @since 4.3.0 Introduced the `$href` parameter. + * @since 4.5.0 Introduced the `$media` parameter. + * + * @param string $html The link tag for the enqueued style. + * @param string $handle The style's registered handle. + * @param string $href The stylesheet's source URL. + * @param string $media The stylesheet's media attribute. + */ + $tag = apply_filters( 'style_loader_tag', "\n", $handle, $href, $media); + if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) { + if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) { + $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : ''; + $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" )); + } else { + $rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" ); + } + + /** This filter is documented in wp-includes/class.wp-styles.php */ + $rtl_tag = apply_filters( 'style_loader_tag', "\n", $handle, $rtl_href, $media ); + + if ( $obj->extra['rtl'] === 'replace' ) { + $tag = $rtl_tag; + } else { + $tag .= $rtl_tag; + } + } + + $conditional_pre = $conditional_post = ''; + if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) { + $conditional_pre = "\n"; + } + + if ( $this->do_concat ) { + $this->print_html .= $conditional_pre; + $this->print_html .= $tag; + if ( $inline_style = $this->print_inline_style( $handle, false ) ) { + $this->print_html .= sprintf( "\n", esc_attr( $handle ), $inline_style ); + } + $this->print_html .= $conditional_post; + } else { + echo $conditional_pre; + echo $tag; + $this->print_inline_style( $handle ); + echo $conditional_post; + } + + return true; + } + + /** + * Adds extra CSS styles to a registered stylesheet. + * + * @since 3.3.0 + * + * @param string $handle The style's registered handle. + * @param string $code String containing the CSS styles to be added. + * @return bool True on success, false on failure. + */ + public function add_inline_style( $handle, $code ) { + if ( ! $code ) { + return false; + } + + $after = $this->get_data( $handle, 'after' ); + if ( ! $after ) { + $after = array(); + } + + $after[] = $code; + + return $this->add_data( $handle, 'after', $after ); + } + + /** + * Prints extra CSS styles of a registered stylesheet. + * + * @since 3.3.0 + * + * @param string $handle The style's registered handle. + * @param bool $echo Optional. Whether to echo the inline style instead of just returning it. + * Default true. + * @return string|bool False if no data exists, inline styles if `$echo` is true, true otherwise. + */ + public function print_inline_style( $handle, $echo = true ) { + $output = $this->get_data( $handle, 'after' ); + + if ( empty( $output ) ) { + return false; + } + + $output = implode( "\n", $output ); + + if ( ! $echo ) { + return $output; + } + + printf( "\n", esc_attr( $handle ), $output ); + + return true; + } + + /** + * Determines style dependencies. + * + * @since 2.6.0 + * + * @see WP_Dependencies::all_deps() + * + * @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings). + * @param bool $recursion Internal flag that function is calling itself. + * @param int|false $group Group level: (int) level, (false) no groups. + * @return bool True on success, false on failure. + */ + public function all_deps( $handles, $recursion = false, $group = false ) { + $r = parent::all_deps( $handles, $recursion, $group ); + if ( ! $recursion ) { + /** + * Filters the array of enqueued styles before processing for output. + * + * @since 2.6.0 + * + * @param array $to_do The list of enqueued styles about to be processed. + */ + $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); + } + return $r; + } + + /** + * Generates an enqueued style's fully-qualified URL. + * + * @since 2.6.0 + * + * @param string $src The source of the enqueued style. + * @param string $ver The version of the enqueued style. + * @param string $handle The style's registered handle. + * @return string Style's fully-qualified URL. + */ + public function _css_href( $src, $ver, $handle ) { + if ( !is_bool($src) && !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { + $src = $this->base_url . $src; + } + + if ( !empty($ver) ) + $src = add_query_arg('ver', $ver, $src); + + /** + * Filters an enqueued style's fully-qualified URL. + * + * @since 2.6.0 + * + * @param string $src The source URL of the enqueued style. + * @param string $handle The style's registered handle. + */ + $src = apply_filters( 'style_loader_src', $src, $handle ); + return esc_url( $src ); + } + + /** + * Whether a handle's source is in a default directory. + * + * @since 2.8.0 + * + * @param string $src The source of the enqueued style. + * @return bool True if found, false if not. + */ + public function in_default_dir( $src ) { + if ( ! $this->default_dirs ) + return true; + + foreach ( (array) $this->default_dirs as $test ) { + if ( 0 === strpos($src, $test) ) + return true; + } + return false; + } + + /** + * Processes items and dependencies for the footer group. + * + * HTML 5 allows styles in the body, grab late enqueued items and output them in the footer. + * + * @since 3.3.0 + * + * @see WP_Dependencies::do_items() + * + * @return array Handles of items that have been processed. + */ + public function do_footer_items() { + $this->do_items(false, 1); + return $this->done; + } + + /** + * Resets class properties. + * + * @since 3.3.0 + */ + public function reset() { + $this->do_concat = false; + $this->concat = ''; + $this->concat_version = ''; + $this->print_html = ''; + } +} diff --git a/backend/wp-includes/comment-template.php b/backend/wp-includes/comment-template.php new file mode 100644 index 0000000..51193ce --- /dev/null +++ b/backend/wp-includes/comment-template.php @@ -0,0 +1,2469 @@ +comment_author ) ) { + if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) + $author = $user->display_name; + else + $author = __('Anonymous'); + } else { + $author = $comment->comment_author; + } + + /** + * Filters the returned comment author name. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $author The comment author's username. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment ); +} + +/** + * Displays the author of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author. + * Default current comment. + */ +function comment_author( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $author = get_comment_author( $comment ); + + /** + * Filters the comment author's name for display. + * + * @since 1.2.0 + * @since 4.1.0 The `$comment_ID` parameter was added. + * + * @param string $author The comment author's username. + * @param int $comment_ID The comment ID. + */ + echo apply_filters( 'comment_author', $author, $comment->comment_ID ); +} + +/** + * Retrieve the email of the author of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. + * Default current comment. + * @return string The current comment author's email + */ +function get_comment_author_email( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + + /** + * Filters the comment author's returned email address. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $comment_author_email The comment author's email address. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); +} + +/** + * Display the email of the author of the current global $comment. + * + * Care should be taken to protect the email address and assure that email + * harvesters do not capture your commentors' email address. Most assume that + * their email address will not appear in raw form on the site. Doing so will + * enable anyone, including those that people don't want to get the email + * address and use it for their own means good and bad. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email. + * Default current comment. + */ +function comment_author_email( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $author_email = get_comment_author_email( $comment ); + + /** + * Filters the comment author's email for display. + * + * @since 1.2.0 + * @since 4.1.0 The `$comment_ID` parameter was added. + * + * @param string $author_email The comment author's email address. + * @param int $comment_ID The comment ID. + */ + echo apply_filters( 'author_email', $author_email, $comment->comment_ID ); +} + +/** + * Display the html email link to the author of the current comment. + * + * Care should be taken to protect the email address and assure that email + * harvesters do not capture your commentors' email address. Most assume that + * their email address will not appear in raw form on the site. Doing so will + * enable anyone, including those that people don't want to get the email + * address and use it for their own means good and bad. + * + * @since 0.71 + * @since 4.6.0 Added the `$comment` parameter. + * + * @param string $linktext Optional. Text to display instead of the comment author's email address. + * Default empty. + * @param string $before Optional. Text or HTML to display before the email link. Default empty. + * @param string $after Optional. Text or HTML to display after the email link. Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. + */ +function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { + if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) { + echo $link; + } +} + +/** + * Return the html email link to the author of the current comment. + * + * Care should be taken to protect the email address and assure that email + * harvesters do not capture your commentors' email address. Most assume that + * their email address will not appear in raw form on the site. Doing so will + * enable anyone, including those that people don't want to get the email + * address and use it for their own means good and bad. + * + * @since 2.7.0 + * @since 4.6.0 Added the `$comment` parameter. + * + * @param string $linktext Optional. Text to display instead of the comment author's email address. + * Default empty. + * @param string $before Optional. Text or HTML to display before the email link. Default empty. + * @param string $after Optional. Text or HTML to display after the email link. Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. + * @return string HTML markup for the comment author email link. By default, the email address is obfuscated + * via the {@see 'comment_email'} filter with antispambot(). + */ +function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { + $comment = get_comment( $comment ); + + /** + * Filters the comment author's email for display. + * + * Care should be taken to protect the email address and assure that email + * harvesters do not capture your commenter's email address. + * + * @since 1.2.0 + * @since 4.1.0 The `$comment` parameter was added. + * + * @param string $comment_author_email The comment author's email address. + * @param WP_Comment $comment The comment object. + */ + $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); + + if ((!empty($email)) && ($email != '@')) { + $display = ($linktext != '') ? $linktext : $email; + $return = $before; + $return .= sprintf( '%2$s', esc_url( 'mailto:' . $email ), esc_html( $display ) ); + $return .= $after; + return $return; + } else { + return ''; + } +} + +/** + * Retrieve the HTML link to the URL of the author of the current comment. + * + * Both get_comment_author_url() and get_comment_author() rely on get_comment(), + * which falls back to the global comment variable if the $comment_ID argument is empty. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. + * Default current comment. + * @return string The comment author name or HTML link for author's URL. + */ +function get_comment_author_link( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $url = get_comment_author_url( $comment ); + $author = get_comment_author( $comment ); + + if ( empty( $url ) || 'http://' == $url ) + $return = $author; + else + $return = "$author"; + + /** + * Filters the comment author's link for display. + * + * @since 1.5.0 + * @since 4.1.0 The `$author` and `$comment_ID` parameters were added. + * + * @param string $return The HTML-formatted comment author link. + * Empty for an invalid URL. + * @param string $author The comment author's username. + * @param int $comment_ID The comment ID. + */ + return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); +} + +/** + * Display the html link to the url of the author of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link. + * Default current comment. + */ +function comment_author_link( $comment_ID = 0 ) { + echo get_comment_author_link( $comment_ID ); +} + +/** + * Retrieve the IP address of the author of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. + * Default current comment. + * @return string Comment author's IP address. + */ +function get_comment_author_IP( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + + /** + * Filters the comment author's returned IP address. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $comment_author_IP The comment author's IP address. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); +} + +/** + * Display the IP address of the author of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address. + * Default current comment. + */ +function comment_author_IP( $comment_ID = 0 ) { + echo esc_html( get_comment_author_IP( $comment_ID ) ); +} + +/** + * Retrieve the url of the author of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. + * Default current comment. + * @return string Comment author URL. + */ +function get_comment_author_url( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $url = ''; + $id = 0; + if ( ! empty( $comment ) ) { + $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; + $url = esc_url( $author_url, array( 'http', 'https' ) ); + $id = $comment->comment_ID; + } + + /** + * Filters the comment author's URL. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $url The comment author's URL. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_author_url', $url, $id, $comment ); +} + +/** + * Display the url of the author of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL. + * Default current comment. + */ +function comment_author_url( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $author_url = get_comment_author_url( $comment ); + + /** + * Filters the comment author's URL for display. + * + * @since 1.2.0 + * @since 4.1.0 The `$comment_ID` parameter was added. + * + * @param string $author_url The comment author's URL. + * @param int $comment_ID The comment ID. + */ + echo apply_filters( 'comment_url', $author_url, $comment->comment_ID ); +} + +/** + * Retrieves the HTML link of the url of the author of the current comment. + * + * $linktext parameter is only used if the URL does not exist for the comment + * author. If the URL does exist then the URL will be used and the $linktext + * will be ignored. + * + * Encapsulate the HTML link between the $before and $after. So it will appear + * in the order of $before, link, and finally $after. + * + * @since 1.5.0 + * @since 4.6.0 Added the `$comment` parameter. + * + * @param string $linktext Optional. The text to display instead of the comment + * author's email address. Default empty. + * @param string $before Optional. The text or HTML to display before the email link. + * Default empty. + * @param string $after Optional. The text or HTML to display after the email link. + * Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. + * Default is the current comment. + * @return string The HTML link between the $before and $after parameters. + */ +function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { + $url = get_comment_author_url( $comment ); + $display = ($linktext != '') ? $linktext : $url; + $display = str_replace( 'http://www.', '', $display ); + $display = str_replace( 'http://', '', $display ); + + if ( '/' == substr($display, -1) ) { + $display = substr($display, 0, -1); + } + + $return = "$before$display$after"; + + /** + * Filters the comment author's returned URL link. + * + * @since 1.5.0 + * + * @param string $return The HTML-formatted comment author URL link. + */ + return apply_filters( 'get_comment_author_url_link', $return ); +} + +/** + * Displays the HTML link of the url of the author of the current comment. + * + * @since 0.71 + * @since 4.6.0 Added the `$comment` parameter. + * + * @param string $linktext Optional. Text to display instead of the comment author's + * email address. Default empty. + * @param string $before Optional. Text or HTML to display before the email link. + * Default empty. + * @param string $after Optional. Text or HTML to display after the email link. + * Default empty. + * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. + * Default is the current comment. + */ +function comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { + echo get_comment_author_url_link( $linktext, $before, $after, $comment ); +} + +/** + * Generates semantic classes for each comment element. + * + * @since 2.7.0 + * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. + * + * @param string|array $class Optional. One or more classes to add to the class list. + * Default empty. + * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. + * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. + * @param bool $echo Optional. Whether to cho or return the output. + * Default true. + * @return string If `$echo` is false, the class will be returned. Void otherwise. + */ +function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { + // Separates classes with a single space, collates classes for comment DIV + $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; + if ( $echo) + echo $class; + else + return $class; +} + +/** + * Returns the classes for the comment div as an array. + * + * @since 2.7.0 + * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object. + * + * @global int $comment_alt + * @global int $comment_depth + * @global int $comment_thread_alt + * + * @param string|array $class Optional. One or more classes to add to the class list. Default empty. + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. + * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. + * @return array An array of classes. + */ +function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { + global $comment_alt, $comment_depth, $comment_thread_alt; + + $classes = array(); + + $comment = get_comment( $comment_id ); + if ( ! $comment ) { + return $classes; + } + + // Get the comment type (comment, trackback), + $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; + + // Add classes for comment authors that are registered users. + if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { + $classes[] = 'byuser'; + $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); + // For comment authors who are the author of the post + if ( $post = get_post($post_id) ) { + if ( $comment->user_id === $post->post_author ) { + $classes[] = 'bypostauthor'; + } + } + } + + if ( empty($comment_alt) ) + $comment_alt = 0; + if ( empty($comment_depth) ) + $comment_depth = 1; + if ( empty($comment_thread_alt) ) + $comment_thread_alt = 0; + + if ( $comment_alt % 2 ) { + $classes[] = 'odd'; + $classes[] = 'alt'; + } else { + $classes[] = 'even'; + } + + $comment_alt++; + + // Alt for top-level comments + if ( 1 == $comment_depth ) { + if ( $comment_thread_alt % 2 ) { + $classes[] = 'thread-odd'; + $classes[] = 'thread-alt'; + } else { + $classes[] = 'thread-even'; + } + $comment_thread_alt++; + } + + $classes[] = "depth-$comment_depth"; + + if ( !empty($class) ) { + if ( !is_array( $class ) ) + $class = preg_split('#\s+#', $class); + $classes = array_merge($classes, $class); + } + + $classes = array_map('esc_attr', $classes); + + /** + * Filters the returned CSS classes for the current comment. + * + * @since 2.7.0 + * + * @param array $classes An array of comment classes. + * @param string $class A comma-separated list of additional classes added to the list. + * @param int $comment_id The comment id. + * @param WP_Comment $comment The comment object. + * @param int|WP_Post $post_id The post ID or WP_Post object. + */ + return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id ); +} + +/** + * Retrieve the comment date of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param string $d Optional. The format of the date. Default user's setting. + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date. + * Default current comment. + * @return string The comment's date. + */ +function get_comment_date( $d = '', $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + if ( '' == $d ) + $date = mysql2date(get_option('date_format'), $comment->comment_date); + else + $date = mysql2date($d, $comment->comment_date); + /** + * Filters the returned comment date. + * + * @since 1.5.0 + * + * @param string|int $date Formatted date string or Unix timestamp. + * @param string $d The format of the date. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_date', $date, $d, $comment ); +} + +/** + * Display the comment date of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param string $d Optional. The format of the date. Default user's settings. + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. + * Default current comment. + */ +function comment_date( $d = '', $comment_ID = 0 ) { + echo get_comment_date( $d, $comment_ID ); +} + +/** + * Retrieve the excerpt of the current comment. + * + * Will cut each word and only output the first 20 words with '…' at the end. + * If the word count is less than 20, then no truncating is done and no '…' + * will appear. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. + * Default current comment. + * @return string The maybe truncated comment with 20 words or less. + */ +function get_comment_excerpt( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); + $words = explode( ' ', $comment_text ); + + /** + * Filters the amount of words used in the comment excerpt. + * + * @since 4.4.0 + * + * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt. + */ + $comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 ); + + $use_ellipsis = count( $words ) > $comment_excerpt_length; + if ( $use_ellipsis ) { + $words = array_slice( $words, 0, $comment_excerpt_length ); + } + + $excerpt = trim( join( ' ', $words ) ); + if ( $use_ellipsis ) { + $excerpt .= '…'; + } + /** + * Filters the retrieved comment excerpt. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $excerpt The comment excerpt text. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); +} + +/** + * Display the excerpt of the current comment. + * + * @since 1.2.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt. + * Default current comment. + */ +function comment_excerpt( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + $comment_excerpt = get_comment_excerpt( $comment ); + + /** + * Filters the comment excerpt for display. + * + * @since 1.2.0 + * @since 4.1.0 The `$comment_ID` parameter was added. + * + * @param string $comment_excerpt The comment excerpt text. + * @param int $comment_ID The comment ID. + */ + echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); +} + +/** + * Retrieve the comment id of the current comment. + * + * @since 1.5.0 + * + * @return int The comment ID. + */ +function get_comment_ID() { + $comment = get_comment(); + + /** + * Filters the returned comment ID. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` parameter was added. + * + * @param int $comment_ID The current comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); +} + +/** + * Display the comment id of the current comment. + * + * @since 0.71 + */ +function comment_ID() { + echo get_comment_ID(); +} + +/** + * Retrieve the link to a given comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument. + * + * @see get_page_of_comment() + * + * @global WP_Rewrite $wp_rewrite + * @global bool $in_comment_loop + * + * @param WP_Comment|int|null $comment Comment to retrieve. Default current comment. + * @param array $args { + * An array of optional arguments to override the defaults. + * + * @type string $type Passed to get_page_of_comment(). + * @type int $page Current page of comments, for calculating comment pagination. + * @type int $per_page Per-page value for comment pagination. + * @type int $max_depth Passed to get_page_of_comment(). + * @type int|string $cpage Value to use for the comment's "comment-page" or "cpage" value. + * If provided, this value overrides any value calculated from `$page` + * and `$per_page`. + * } + * @return string The permalink to the given comment. + */ +function get_comment_link( $comment = null, $args = array() ) { + global $wp_rewrite, $in_comment_loop; + + $comment = get_comment($comment); + + // Back-compat. + if ( ! is_array( $args ) ) { + $args = array( 'page' => $args ); + } + + $defaults = array( + 'type' => 'all', + 'page' => '', + 'per_page' => '', + 'max_depth' => '', + 'cpage' => null, + ); + $args = wp_parse_args( $args, $defaults ); + + $link = get_permalink( $comment->comment_post_ID ); + + // The 'cpage' param takes precedence. + if ( ! is_null( $args['cpage'] ) ) { + $cpage = $args['cpage']; + + // No 'cpage' is provided, so we calculate one. + } else { + if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { + $args['per_page'] = get_option('comments_per_page'); + } + + if ( empty( $args['per_page'] ) ) { + $args['per_page'] = 0; + $args['page'] = 0; + } + + $cpage = $args['page']; + + if ( '' == $cpage ) { + if ( ! empty( $in_comment_loop ) ) { + $cpage = get_query_var( 'cpage' ); + } else { + // Requires a database hit, so we only do it when we can't figure out from context. + $cpage = get_page_of_comment( $comment->comment_ID, $args ); + } + } + + /* + * If the default page displays the oldest comments, the permalinks for comments on the default page + * do not need a 'cpage' query var. + */ + if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) { + $cpage = ''; + } + } + + if ( $cpage && get_option( 'page_comments' ) ) { + if ( $wp_rewrite->using_permalinks() ) { + if ( $cpage ) { + $link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage; + } + + $link = user_trailingslashit( $link, 'comment' ); + } elseif ( $cpage ) { + $link = add_query_arg( 'cpage', $cpage, $link ); + } + + } + + if ( $wp_rewrite->using_permalinks() ) { + $link = user_trailingslashit( $link, 'comment' ); + } + + $link = $link . '#comment-' . $comment->comment_ID; + + /** + * Filters the returned single comment permalink. + * + * @since 2.8.0 + * @since 4.4.0 Added the `$cpage` parameter. + * + * @see get_page_of_comment() + * + * @param string $link The comment permalink with '#comment-$id' appended. + * @param WP_Comment $comment The current comment object. + * @param array $args An array of arguments to override the defaults. + * @param int $cpage The calculated 'cpage' value. + */ + return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage ); +} + +/** + * Retrieves the link to the current post comments. + * + * @since 1.5.0 + * + * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. + * @return string The link to the comments. + */ +function get_comments_link( $post_id = 0 ) { + $hash = get_comments_number( $post_id ) ? '#comments' : '#respond'; + $comments_link = get_permalink( $post_id ) . $hash; + + /** + * Filters the returned post comments permalink. + * + * @since 3.6.0 + * + * @param string $comments_link Post comments permalink with '#comments' appended. + * @param int|WP_Post $post_id Post ID or WP_Post object. + */ + return apply_filters( 'get_comments_link', $comments_link, $post_id ); +} + +/** + * Display the link to the current post comments. + * + * @since 0.71 + * + * @param string $deprecated Not Used. + * @param string $deprecated_2 Not Used. + */ +function comments_link( $deprecated = '', $deprecated_2 = '' ) { + if ( !empty( $deprecated ) ) + _deprecated_argument( __FUNCTION__, '0.72' ); + if ( !empty( $deprecated_2 ) ) + _deprecated_argument( __FUNCTION__, '1.3.0' ); + echo esc_url( get_comments_link() ); +} + +/** + * Retrieves the amount of comments a post has. + * + * @since 1.5.0 + * + * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`. + * @return string|int If the post exists, a numeric string representing the number of comments + * the post has, otherwise 0. + */ +function get_comments_number( $post_id = 0 ) { + $post = get_post( $post_id ); + + if ( ! $post ) { + $count = 0; + } else { + $count = $post->comment_count; + $post_id = $post->ID; + } + + /** + * Filters the returned comment count for a post. + * + * @since 1.5.0 + * + * @param string|int $count A string representing the number of comments a post has, otherwise 0. + * @param int $post_id Post ID. + */ + return apply_filters( 'get_comments_number', $count, $post_id ); +} + +/** + * Display the language string for the number of comments the current post has. + * + * @since 0.71 + * + * @param string $zero Optional. Text for no comments. Default false. + * @param string $one Optional. Text for one comment. Default false. + * @param string $more Optional. Text for more than one comment. Default false. + * @param string $deprecated Not used. + */ +function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __FUNCTION__, '1.3.0' ); + } + echo get_comments_number_text( $zero, $one, $more ); +} + +/** + * Display the language string for the number of comments the current post has. + * + * @since 4.0.0 + * + * @param string $zero Optional. Text for no comments. Default false. + * @param string $one Optional. Text for one comment. Default false. + * @param string $more Optional. Text for more than one comment. Default false. + */ +function get_comments_number_text( $zero = false, $one = false, $more = false ) { + $number = get_comments_number(); + + if ( $number > 1 ) { + if ( false === $more ) { + /* translators: %s: number of comments */ + $output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) ); + } else { + // % Comments + /* translators: If comment number in your language requires declension, + * translate this to 'on'. Do not translate into your own language. + */ + if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) { + $text = preg_replace( '#.+?#', '', $more ); + $text = preg_replace( '/&.+?;/', '', $text ); // Kill entities + $text = trim( strip_tags( $text ), '% ' ); + + // Replace '% Comments' with a proper plural form + if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { + /* translators: %s: number of comments */ + $new_text = _n( '%s Comment', '%s Comments', $number ); + $new_text = trim( sprintf( $new_text, '' ) ); + + $more = str_replace( $text, $new_text, $more ); + if ( false === strpos( $more, '%' ) ) { + $more = '% ' . $more; + } + } + } + + $output = str_replace( '%', number_format_i18n( $number ), $more ); + } + } elseif ( $number == 0 ) { + $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; + } else { // must be one + $output = ( false === $one ) ? __( '1 Comment' ) : $one; + } + /** + * Filters the comments count for display. + * + * @since 1.5.0 + * + * @see _n() + * + * @param string $output A translatable string formatted based on whether the count + * is equal to 0, 1, or 1+. + * @param int $number The number of post comments. + */ + return apply_filters( 'comments_number', $output, $number ); +} + +/** + * Retrieve the text of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @see Walker_Comment::comment() + * + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the text. + * Default current comment. + * @param array $args Optional. An array of arguments. Default empty. + * @return string The comment content. + */ +function get_comment_text( $comment_ID = 0, $args = array() ) { + $comment = get_comment( $comment_ID ); + + /** + * Filters the text of a comment. + * + * @since 1.5.0 + * + * @see Walker_Comment::comment() + * + * @param string $comment_content Text of the comment. + * @param WP_Comment $comment The comment object. + * @param array $args An array of arguments. + */ + return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); +} + +/** + * Display the text of the current comment. + * + * @since 0.71 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @see Walker_Comment::comment() + * + * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text. + * Default current comment. + * @param array $args Optional. An array of arguments. Default empty array. Default empty. + */ +function comment_text( $comment_ID = 0, $args = array() ) { + $comment = get_comment( $comment_ID ); + + $comment_text = get_comment_text( $comment, $args ); + /** + * Filters the text of a comment to be displayed. + * + * @since 1.2.0 + * + * @see Walker_Comment::comment() + * + * @param string $comment_text Text of the current comment. + * @param WP_Comment|null $comment The comment object. + * @param array $args An array of arguments. + */ + echo apply_filters( 'comment_text', $comment_text, $comment, $args ); +} + +/** + * Retrieve the comment time of the current comment. + * + * @since 1.5.0 + * + * @param string $d Optional. The format of the time. Default user's settings. + * @param bool $gmt Optional. Whether to use the GMT date. Default false. + * @param bool $translate Optional. Whether to translate the time (for use in feeds). + * Default true. + * @return string The formatted time. + */ +function get_comment_time( $d = '', $gmt = false, $translate = true ) { + $comment = get_comment(); + + $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; + if ( '' == $d ) + $date = mysql2date(get_option('time_format'), $comment_date, $translate); + else + $date = mysql2date($d, $comment_date, $translate); + + /** + * Filters the returned comment time. + * + * @since 1.5.0 + * + * @param string|int $date The comment time, formatted as a date string or Unix timestamp. + * @param string $d Date format. + * @param bool $gmt Whether the GMT date is in use. + * @param bool $translate Whether the time is translated. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment ); +} + +/** + * Display the comment time of the current comment. + * + * @since 0.71 + * + * @param string $d Optional. The format of the time. Default user's settings. + */ +function comment_time( $d = '' ) { + echo get_comment_time($d); +} + +/** + * Retrieve the comment type of the current comment. + * + * @since 1.5.0 + * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. + * + * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type. + * Default current comment. + * @return string The comment type. + */ +function get_comment_type( $comment_ID = 0 ) { + $comment = get_comment( $comment_ID ); + if ( '' == $comment->comment_type ) + $comment->comment_type = 'comment'; + + /** + * Filters the returned comment type. + * + * @since 1.5.0 + * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. + * + * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment The comment object. + */ + return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); +} + +/** + * Display the comment type of the current comment. + * + * @since 0.71 + * + * @param string $commenttxt Optional. String to display for comment type. Default false. + * @param string $trackbacktxt Optional. String to display for trackback type. Default false. + * @param string $pingbacktxt Optional. String to display for pingback type. Default false. + */ +function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { + if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); + if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); + if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); + $type = get_comment_type(); + switch( $type ) { + case 'trackback' : + echo $trackbacktxt; + break; + case 'pingback' : + echo $pingbacktxt; + break; + default : + echo $commenttxt; + } +} + +/** + * Retrieve The current post's trackback URL. + * + * There is a check to see if permalink's have been enabled and if so, will + * retrieve the pretty path. If permalinks weren't enabled, the ID of the + * current post is used and appended to the correct page to go to. + * + * @since 1.5.0 + * + * @return string The trackback URL after being filtered. + */ +function get_trackback_url() { + if ( '' != get_option('permalink_structure') ) + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); + else + $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); + + /** + * Filters the returned trackback URL. + * + * @since 2.2.0 + * + * @param string $tb_url The trackback URL. + */ + return apply_filters( 'trackback_url', $tb_url ); +} + +/** + * Display the current post's trackback URL. + * + * @since 0.71 + * + * @param bool $deprecated_echo Not used. + * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() + * for the result instead. + */ +function trackback_url( $deprecated_echo = true ) { + if ( true !== $deprecated_echo ) { + _deprecated_argument( __FUNCTION__, '2.5.0', + /* translators: %s: get_trackback_url() */ + sprintf( __( 'Use %s instead if you do not want the value echoed.' ), + 'get_trackback_url()' + ) + ); + } + + if ( $deprecated_echo ) { + echo get_trackback_url(); + } else { + return get_trackback_url(); + } +} + +/** + * Generate and display the RDF for the trackback information of current post. + * + * Deprecated in 3.0.0, and restored in 3.0.1. + * + * @since 0.71 + * + * @param int $deprecated Not used (Was $timezone = 0). + */ +function trackback_rdf( $deprecated = '' ) { + if ( ! empty( $deprecated ) ) { + _deprecated_argument( __FUNCTION__, '2.5.0' ); + } + + if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) { + return; + } + + echo ' + \n"; + echo ''; +} + +/** + * Whether the current post is open for comments. + * + * @since 1.5.0 + * + * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. + * @return bool True if the comments are open. + */ +function comments_open( $post_id = null ) { + + $_post = get_post($post_id); + + $post_id = $_post ? $_post->ID : 0; + $open = ( 'open' == $_post->comment_status ); + + /** + * Filters whether the current post is open for comments. + * + * @since 2.5.0 + * + * @param bool $open Whether the current post is open for comments. + * @param int $post_id The post ID. + */ + return apply_filters( 'comments_open', $open, $post_id ); +} + +/** + * Whether the current post is open for pings. + * + * @since 1.5.0 + * + * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. + * @return bool True if pings are accepted + */ +function pings_open( $post_id = null ) { + + $_post = get_post($post_id); + + $post_id = $_post ? $_post->ID : 0; + $open = ( 'open' == $_post->ping_status ); + + /** + * Filters whether the current post is open for pings. + * + * @since 2.5.0 + * + * @param bool $open Whether the current post is open for pings. + * @param int $post_id The post ID. + */ + return apply_filters( 'pings_open', $open, $post_id ); +} + +/** + * Display form token for unfiltered comments. + * + * Will only display nonce token if the current user has permissions for + * unfiltered html. Won't display the token for other users. + * + * The function was backported to 2.0.10 and was added to versions 2.1.3 and + * above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in + * the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0. + * + * Backported to 2.0.10. + * + * @since 2.1.3 + */ +function wp_comment_form_unfiltered_html_nonce() { + $post = get_post(); + $post_id = $post ? $post->ID : 0; + + if ( current_user_can( 'unfiltered_html' ) ) { + wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); + echo "\n"; + } +} + +/** + * Load the comment template specified in $file. + * + * Will not display the comments template if not on single post or page, or if + * the post does not have comments. + * + * Uses the WordPress database object to query for the comments. The comments + * are passed through the {@see 'comments_array'} filter hook with the list of comments + * and the post ID respectively. + * + * The `$file` path is passed through a filter hook called {@see 'comments_template'}, + * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path + * first and if it fails it will require the default comment template from the + * default theme. If either does not exist, then the WordPress process will be + * halted. It is advised for that reason, that the default theme is not deleted. + * + * Will not try to get the comments if the post has none. + * + * @since 1.5.0 + * + * @global WP_Query $wp_query + * @global WP_Post $post + * @global wpdb $wpdb + * @global int $id + * @global WP_Comment $comment + * @global string $user_login + * @global int $user_ID + * @global string $user_identity + * @global bool $overridden_cpage + * @global bool $withcomments + * + * @param string $file Optional. The file to load. Default '/comments.php'. + * @param bool $separate_comments Optional. Whether to separate the comments by comment type. + * Default false. + */ +function comments_template( $file = '/comments.php', $separate_comments = false ) { + global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; + + if ( !(is_single() || is_page() || $withcomments) || empty($post) ) + return; + + if ( empty($file) ) + $file = '/comments.php'; + + $req = get_option('require_name_email'); + + /* + * Comment author information fetched from the comment cookies. + */ + $commenter = wp_get_current_commenter(); + + /* + * The name of the current comment author escaped for use in attributes. + * Escaped by sanitize_comment_cookies(). + */ + $comment_author = $commenter['comment_author']; + + /* + * The email address of the current comment author escaped for use in attributes. + * Escaped by sanitize_comment_cookies(). + */ + $comment_author_email = $commenter['comment_author_email']; + + /* + * The url of the current comment author escaped for use in attributes. + */ + $comment_author_url = esc_url($commenter['comment_author_url']); + + $comment_args = array( + 'orderby' => 'comment_date_gmt', + 'order' => 'ASC', + 'status' => 'approve', + 'post_id' => $post->ID, + 'no_found_rows' => false, + 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. + ); + + if ( get_option('thread_comments') ) { + $comment_args['hierarchical'] = 'threaded'; + } else { + $comment_args['hierarchical'] = false; + } + + if ( $user_ID ) { + $comment_args['include_unapproved'] = array( $user_ID ); + } elseif ( ! empty( $comment_author_email ) ) { + $comment_args['include_unapproved'] = array( $comment_author_email ); + } + + $per_page = 0; + if ( get_option( 'page_comments' ) ) { + $per_page = (int) get_query_var( 'comments_per_page' ); + if ( 0 === $per_page ) { + $per_page = (int) get_option( 'comments_per_page' ); + } + + $comment_args['number'] = $per_page; + $page = (int) get_query_var( 'cpage' ); + + if ( $page ) { + $comment_args['offset'] = ( $page - 1 ) * $per_page; + } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { + $comment_args['offset'] = 0; + } else { + // If fetching the first page of 'newest', we need a top-level comment count. + $top_level_query = new WP_Comment_Query(); + $top_level_args = array( + 'count' => true, + 'orderby' => false, + 'post_id' => $post->ID, + 'status' => 'approve', + ); + + if ( $comment_args['hierarchical'] ) { + $top_level_args['parent'] = 0; + } + + if ( isset( $comment_args['include_unapproved'] ) ) { + $top_level_args['include_unapproved'] = $comment_args['include_unapproved']; + } + + $top_level_count = $top_level_query->query( $top_level_args ); + + $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; + } + } + + /** + * Filters the arguments used to query comments in comments_template(). + * + * @since 4.5.0 + * + * @see WP_Comment_Query::__construct() + * + * @param array $comment_args { + * Array of WP_Comment_Query arguments. + * + * @type string|array $orderby Field(s) to order by. + * @type string $order Order of results. Accepts 'ASC' or 'DESC'. + * @type string $status Comment status. + * @type array $include_unapproved Array of IDs or email addresses whose unapproved comments + * will be included in results. + * @type int $post_id ID of the post. + * @type bool $no_found_rows Whether to refrain from querying for found rows. + * @type bool $update_comment_meta_cache Whether to prime cache for comment meta. + * @type bool|string $hierarchical Whether to query for comments hierarchically. + * @type int $offset Comment offset. + * @type int $number Number of comments to fetch. + * } + */ + $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); + $comment_query = new WP_Comment_Query( $comment_args ); + $_comments = $comment_query->comments; + + // Trees must be flattened before they're passed to the walker. + if ( $comment_args['hierarchical'] ) { + $comments_flat = array(); + foreach ( $_comments as $_comment ) { + $comments_flat[] = $_comment; + $comment_children = $_comment->get_children( array( + 'format' => 'flat', + 'status' => $comment_args['status'], + 'orderby' => $comment_args['orderby'] + ) ); + + foreach ( $comment_children as $comment_child ) { + $comments_flat[] = $comment_child; + } + } + } else { + $comments_flat = $_comments; + } + + /** + * Filters the comments array. + * + * @since 2.1.0 + * + * @param array $comments Array of comments supplied to the comments template. + * @param int $post_ID Post ID. + */ + $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); + + $comments = &$wp_query->comments; + $wp_query->comment_count = count($wp_query->comments); + $wp_query->max_num_comment_pages = $comment_query->max_num_pages; + + if ( $separate_comments ) { + $wp_query->comments_by_type = separate_comments($comments); + $comments_by_type = &$wp_query->comments_by_type; + } else { + $wp_query->comments_by_type = array(); + } + + $overridden_cpage = false; + if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { + set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); + $overridden_cpage = true; + } + + if ( !defined('COMMENTS_TEMPLATE') ) + define('COMMENTS_TEMPLATE', true); + + $theme_template = STYLESHEETPATH . $file; + /** + * Filters the path to the theme template file used for the comments template. + * + * @since 1.5.1 + * + * @param string $theme_template The path to the theme template file. + */ + $include = apply_filters( 'comments_template', $theme_template ); + if ( file_exists( $include ) ) + require( $include ); + elseif ( file_exists( TEMPLATEPATH . $file ) ) + require( TEMPLATEPATH . $file ); + else // Backward compat code will be removed in a future release + require( ABSPATH . WPINC . '/theme-compat/comments.php'); +} + +/** + * Displays the link to the comments for the current post ID. + * + * @since 0.71 + * + * @param string $zero Optional. String to display when no comments. Default false. + * @param string $one Optional. String to display when only one comment is available. + * Default false. + * @param string $more Optional. String to display when there are more than one comment. + * Default false. + * @param string $css_class Optional. CSS class to use for comments. Default empty. + * @param string $none Optional. String to display when comments have been turned off. + * Default false. + */ +function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { + $id = get_the_ID(); + $title = get_the_title(); + $number = get_comments_number( $id ); + + if ( false === $zero ) { + /* translators: %s: post title */ + $zero = sprintf( __( 'No Comments on %s' ), $title ); + } + + if ( false === $one ) { + /* translators: %s: post title */ + $one = sprintf( __( '1 Comment on %s' ), $title ); + } + + if ( false === $more ) { + /* translators: 1: Number of comments 2: post title */ + $more = _n( '%1$s Comment on %2$s', '%1$s Comments on %2$s', $number ); + $more = sprintf( $more, number_format_i18n( $number ), $title ); + } + + if ( false === $none ) { + /* translators: %s: post title */ + $none = sprintf( __( 'Comments Off on %s' ), $title ); + } + + if ( 0 == $number && !comments_open() && !pings_open() ) { + echo '' . $none . ''; + return; + } + + if ( post_password_required() ) { + _e( 'Enter your password to view comments.' ); + return; + } + + echo ''; + comments_number( $zero, $one, $more ); + echo ''; +} + +/** + * Retrieve HTML content for reply to comment link. + * + * @since 2.7.0 + * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. + * + * @param array $args { + * Optional. Override default arguments. + * + * @type string $add_below The first part of the selector used to identify the comment to respond below. + * The resulting value is passed as the first parameter to addComment.moveForm(), + * concatenated as $add_below-$comment->comment_ID. Default 'comment'. + * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter + * to addComment.moveForm(), and appended to the link URL as a hash value. + * Default 'respond'. + * @type string $reply_text The text of the Reply link. Default 'Reply'. + * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'. + * @type int $max_depth The max depth of the comment tree. Default 0. + * @type int $depth The depth of the new comment. Must be greater than 0 and less than the value + * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0. + * @type string $before The text or HTML to add before the reply link. Default empty. + * @type string $after The text or HTML to add after the reply link. Default empty. + * } + * @param int|WP_Comment $comment Comment being replied to. Default current comment. + * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. + * Default current post. + * @return void|false|string Link to show comment form, if successful. False, if comments are closed. + */ +function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { + $defaults = array( + 'add_below' => 'comment', + 'respond_id' => 'respond', + 'reply_text' => __( 'Reply' ), + /* translators: Comment reply button text. 1: Comment author name */ + 'reply_to_text' => __( 'Reply to %s' ), + 'login_text' => __( 'Log in to Reply' ), + 'max_depth' => 0, + 'depth' => 0, + 'before' => '', + 'after' => '' + ); + + $args = wp_parse_args( $args, $defaults ); + + if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { + return; + } + + $comment = get_comment( $comment ); + + if ( empty( $post ) ) { + $post = $comment->comment_post_ID; + } + + $post = get_post( $post ); + + if ( ! comments_open( $post->ID ) ) { + return false; + } + + /** + * Filters the comment reply link arguments. + * + * @since 4.1.0 + * + * @param array $args Comment reply link arguments. See get_comment_reply_link() + * for more information on accepted arguments. + * @param WP_Comment $comment The object of the comment being replied to. + * @param WP_Post $post The WP_Post object. + */ + $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); + + if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { + $link = sprintf( '', + esc_url( wp_login_url( get_permalink() ) ), + $args['login_text'] + ); + } else { + $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', + $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID + ); + + $link = sprintf( "%s", + esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'], + $onclick, + esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), + $args['reply_text'] + ); + } + + /** + * Filters the comment reply link. + * + * @since 2.7.0 + * + * @param string $link The HTML markup for the comment reply link. + * @param array $args An array of arguments overriding the defaults. + * @param object $comment The object of the comment being replied. + * @param WP_Post $post The WP_Post object. + */ + return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); +} + +/** + * Displays the HTML content for reply to comment link. + * + * @since 2.7.0 + * + * @see get_comment_reply_link() + * + * @param array $args Optional. Override default options. + * @param int $comment Comment being replied to. Default current comment. + * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. + * Default current post. + * @return mixed Link to show comment form, if successful. False, if comments are closed. + */ +function comment_reply_link($args = array(), $comment = null, $post = null) { + echo get_comment_reply_link($args, $comment, $post); +} + +/** + * Retrieve HTML content for reply to post link. + * + * @since 2.7.0 + * + * @param array $args { + * Optional. Override default arguments. + * + * @type string $add_below The first part of the selector used to identify the comment to respond below. + * The resulting value is passed as the first parameter to addComment.moveForm(), + * concatenated as $add_below-$comment->comment_ID. Default is 'post'. + * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter + * to addComment.moveForm(), and appended to the link URL as a hash value. + * Default 'respond'. + * @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'. + * @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'. + * @type string $before Text or HTML to add before the reply link. Default empty. + * @type string $after Text or HTML to add after the reply link. Default empty. + * } + * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. + * Default current post. + * @return false|null|string Link to show comment form, if successful. False, if comments are closed. + */ +function get_post_reply_link($args = array(), $post = null) { + $defaults = array( + 'add_below' => 'post', + 'respond_id' => 'respond', + 'reply_text' => __('Leave a Comment'), + 'login_text' => __('Log in to leave a Comment'), + 'before' => '', + 'after' => '', + ); + + $args = wp_parse_args($args, $defaults); + + $post = get_post($post); + + if ( ! comments_open( $post->ID ) ) { + return false; + } + + if ( get_option('comment_registration') && ! is_user_logged_in() ) { + $link = sprintf( '', + wp_login_url( get_permalink() ), + $args['login_text'] + ); + } else { + $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', + $args['add_below'], $post->ID, $args['respond_id'] + ); + + $link = sprintf( "%s", + get_permalink( $post->ID ) . '#' . $args['respond_id'], + $onclick, + $args['reply_text'] + ); + } + $formatted_link = $args['before'] . $link . $args['after']; + + /** + * Filters the formatted post comments link HTML. + * + * @since 2.7.0 + * + * @param string $formatted The HTML-formatted post comments link. + * @param int|WP_Post $post The post ID or WP_Post object. + */ + return apply_filters( 'post_comments_link', $formatted_link, $post ); +} + +/** + * Displays the HTML content for reply to post link. + * + * @since 2.7.0 + * + * @see get_post_reply_link() + * + * @param array $args Optional. Override default options, + * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. + * Default current post. + * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. + */ +function post_reply_link($args = array(), $post = null) { + echo get_post_reply_link($args, $post); +} + +/** + * Retrieve HTML content for cancel comment reply link. + * + * @since 2.7.0 + * + * @param string $text Optional. Text to display for cancel reply link. Default empty. + * @return string + */ +function get_cancel_comment_reply_link( $text = '' ) { + if ( empty($text) ) + $text = __('Click here to cancel reply.'); + + $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; + $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; + + $formatted_link = '' . $text . ''; + + /** + * Filters the cancel comment reply link HTML. + * + * @since 2.7.0 + * + * @param string $formatted_link The HTML-formatted cancel comment reply link. + * @param string $link Cancel comment reply link URL. + * @param string $text Cancel comment reply link text. + */ + return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); +} + +/** + * Display HTML content for cancel comment reply link. + * + * @since 2.7.0 + * + * @param string $text Optional. Text to display for cancel reply link. Default empty. + */ +function cancel_comment_reply_link( $text = '' ) { + echo get_cancel_comment_reply_link($text); +} + +/** + * Retrieve hidden input HTML for replying to comments. + * + * @since 3.0.0 + * + * @param int $id Optional. Post ID. Default current post ID. + * @return string Hidden input HTML for replying to comments + */ +function get_comment_id_fields( $id = 0 ) { + if ( empty( $id ) ) + $id = get_the_ID(); + + $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; + $result = "\n"; + $result .= "\n"; + + /** + * Filters the returned comment id fields. + * + * @since 3.0.0 + * + * @param string $result The HTML-formatted hidden id field comment elements. + * @param int $id The post ID. + * @param int $replytoid The id of the comment being replied to. + */ + return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); +} + +/** + * Output hidden input HTML for replying to comments. + * + * @since 2.7.0 + * + * @param int $id Optional. Post ID. Default current post ID. + */ +function comment_id_fields( $id = 0 ) { + echo get_comment_id_fields( $id ); +} + +/** + * Display text based on comment reply status. + * + * Only affects users with JavaScript disabled. + * + * @internal The $comment global must be present to allow template tags access to the current + * comment. See https://core.trac.wordpress.org/changeset/36512. + * + * @since 2.7.0 + * + * @global WP_Comment $comment Current comment. + * + * @param string $noreplytext Optional. Text to display when not replying to a comment. + * Default false. + * @param string $replytext Optional. Text to display when replying to a comment. + * Default false. Accepts "%s" for the author of the comment + * being replied to. + * @param string $linktoparent Optional. Boolean to control making the author's name a link + * to their comment. Default true. + */ +function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { + global $comment; + + if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); + if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); + + $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; + + if ( 0 == $replytoid ) + echo $noreplytext; + else { + // Sets the global so that template tags can be used in the comment form. + $comment = get_comment($replytoid); + $author = ( $linktoparent ) ? '' . get_comment_author( $comment ) . '' : get_comment_author( $comment ); + printf( $replytext, $author ); + } +} + +/** + * List comments. + * + * Used in the comments.php template to list comments for a particular post. + * + * @since 2.7.0 + * + * @see WP_Query->comments + * + * @global WP_Query $wp_query + * @global int $comment_alt + * @global int $comment_depth + * @global int $comment_thread_alt + * @global bool $overridden_cpage + * @global bool $in_comment_loop + * + * @param string|array $args { + * Optional. Formatting options. + * + * @type object $walker Instance of a Walker class to list comments. Default null. + * @type int $max_depth The maximum comments depth. Default empty. + * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. + * @type string $callback Callback function to use. Default null. + * @type string $end-callback Callback function to use at the end. Default null. + * @type string $type Type of comments to list. + * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. + * @type int $page Page ID to list comments for. Default empty. + * @type int $per_page Number of comments to list per page. Default empty. + * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. + * @type bool $reverse_top_level Ordering of the listed comments. If true, will display newest comments first. + * @type bool $reverse_children Whether to reverse child comments in the list. Default null. + * @type string $format How to format the comments list. + * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. + * @type bool $short_ping Whether to output short pings. Default false. + * @type bool $echo Whether to echo the output or return it. Default true. + * } + * @param array $comments Optional. Array of WP_Comment objects. + */ +function wp_list_comments( $args = array(), $comments = null ) { + global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; + + $in_comment_loop = true; + + $comment_alt = $comment_thread_alt = 0; + $comment_depth = 1; + + $defaults = array( + 'walker' => null, + 'max_depth' => '', + 'style' => 'ul', + 'callback' => null, + 'end-callback' => null, + 'type' => 'all', + 'page' => '', + 'per_page' => '', + 'avatar_size' => 32, + 'reverse_top_level' => null, + 'reverse_children' => '', + 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', + 'short_ping' => false, + 'echo' => true, + ); + + $r = wp_parse_args( $args, $defaults ); + + /** + * Filters the arguments used in retrieving the comment list. + * + * @since 4.0.0 + * + * @see wp_list_comments() + * + * @param array $r An array of arguments for displaying comments. + */ + $r = apply_filters( 'wp_list_comments_args', $r ); + + // Figure out what comments we'll be looping through ($_comments) + if ( null !== $comments ) { + $comments = (array) $comments; + if ( empty($comments) ) + return; + if ( 'all' != $r['type'] ) { + $comments_by_type = separate_comments($comments); + if ( empty($comments_by_type[$r['type']]) ) + return; + $_comments = $comments_by_type[$r['type']]; + } else { + $_comments = $comments; + } + } else { + /* + * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, + * perform a separate comment query and allow Walker_Comment to paginate. + */ + if ( $r['page'] || $r['per_page'] ) { + $current_cpage = get_query_var( 'cpage' ); + if ( ! $current_cpage ) { + $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; + } + + $current_per_page = get_query_var( 'comments_per_page' ); + if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { + $comment_args = array( + 'post_id' => get_the_ID(), + 'orderby' => 'comment_date_gmt', + 'order' => 'ASC', + 'status' => 'approve', + ); + + if ( is_user_logged_in() ) { + $comment_args['include_unapproved'] = get_current_user_id(); + } else { + $commenter = wp_get_current_commenter(); + if ( $commenter['comment_author_email'] ) { + $comment_args['include_unapproved'] = $commenter['comment_author_email']; + } + } + + $comments = get_comments( $comment_args ); + + if ( 'all' != $r['type'] ) { + $comments_by_type = separate_comments( $comments ); + if ( empty( $comments_by_type[ $r['type'] ] ) ) { + return; + } + + $_comments = $comments_by_type[ $r['type'] ]; + } else { + $_comments = $comments; + } + } + + // Otherwise, fall back on the comments from `$wp_query->comments`. + } else { + if ( empty($wp_query->comments) ) + return; + if ( 'all' != $r['type'] ) { + if ( empty($wp_query->comments_by_type) ) + $wp_query->comments_by_type = separate_comments($wp_query->comments); + if ( empty($wp_query->comments_by_type[$r['type']]) ) + return; + $_comments = $wp_query->comments_by_type[$r['type']]; + } else { + $_comments = $wp_query->comments; + } + + if ( $wp_query->max_num_comment_pages ) { + $default_comments_page = get_option( 'default_comments_page' ); + $cpage = get_query_var( 'cpage' ); + if ( 'newest' === $default_comments_page ) { + $r['cpage'] = $cpage; + + /* + * When first page shows oldest comments, post permalink is the same as + * the comment permalink. + */ + } elseif ( $cpage == 1 ) { + $r['cpage'] = ''; + } else { + $r['cpage'] = $cpage; + } + + $r['page'] = 0; + $r['per_page'] = 0; + } + } + } + + if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { + $r['per_page'] = get_query_var('comments_per_page'); + } + + if ( empty($r['per_page']) ) { + $r['per_page'] = 0; + $r['page'] = 0; + } + + if ( '' === $r['max_depth'] ) { + if ( get_option('thread_comments') ) + $r['max_depth'] = get_option('thread_comments_depth'); + else + $r['max_depth'] = -1; + } + + if ( '' === $r['page'] ) { + if ( empty($overridden_cpage) ) { + $r['page'] = get_query_var('cpage'); + } else { + $threaded = ( -1 != $r['max_depth'] ); + $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; + set_query_var( 'cpage', $r['page'] ); + } + } + // Validation check + $r['page'] = intval($r['page']); + if ( 0 == $r['page'] && 0 != $r['per_page'] ) + $r['page'] = 1; + + if ( null === $r['reverse_top_level'] ) + $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); + + wp_queue_comments_for_comment_meta_lazyload( $_comments ); + + if ( empty( $r['walker'] ) ) { + $walker = new Walker_Comment; + } else { + $walker = $r['walker']; + } + + $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); + + $in_comment_loop = false; + + if ( $r['echo'] ) { + echo $output; + } else { + return $output; + } +} + +/** + * Outputs a complete commenting form for use within a template. + * + * Most strings and form fields may be controlled through the $args array passed + * into the function, while you may also choose to use the {@see 'comment_form_default_fields'} + * filter to modify the array of default fields if you'd just like to add a new + * one or remove a single field. All fields are also individually passed through + * a filter of the {@see 'comment_form_field_$name'} where $name is the key used + * in the array of fields. + * + * @since 3.0.0 + * @since 4.1.0 Introduced the 'class_submit' argument. + * @since 4.2.0 Introduced the 'submit_button' and 'submit_fields' arguments. + * @since 4.4.0 Introduced the 'class_form', 'title_reply_before', 'title_reply_after', + * 'cancel_reply_before', and 'cancel_reply_after' arguments. + * @since 4.5.0 The 'author', 'email', and 'url' form fields are limited to 245, 100, + * and 200 characters, respectively. + * @since 4.6.0 Introduced the 'action' argument. + * + * @param array $args { + * Optional. Default arguments and form fields to override. + * + * @type array $fields { + * Default comment fields, filterable by default via the {@see 'comment_form_default_fields'} hook. + * + * @type string $author Comment author field HTML. + * @type string $email Comment author email field HTML. + * @type string $url Comment author URL field HTML. + * } + * @type string $comment_field The comment textarea field HTML. + * @type string $must_log_in HTML element for a 'must be logged in to comment' message. + * @type string $logged_in_as HTML element for a 'logged in as [user]' message. + * @type string $comment_notes_before HTML element for a message displayed before the comment fields + * if the user is not logged in. + * Default 'Your email address will not be published.'. + * @type string $comment_notes_after HTML element for a message displayed after the textarea field. + * @type string $action The comment form element action attribute. Default '/wp-comments-post.php'. + * @type string $id_form The comment form element id attribute. Default 'commentform'. + * @type string $id_submit The comment submit element id attribute. Default 'submit'. + * @type string $class_form The comment form element class attribute. Default 'comment-form'. + * @type string $class_submit The comment submit element class attribute. Default 'submit'. + * @type string $name_submit The comment submit element name attribute. Default 'submit'. + * @type string $title_reply The translatable 'reply' button label. Default 'Leave a Reply'. + * @type string $title_reply_to The translatable 'reply-to' button label. Default 'Leave a Reply to %s', + * where %s is the author of the comment being replied to. + * @type string $title_reply_before HTML displayed before the comment form title. + * Default: '

      '. + * @type string $title_reply_after HTML displayed after the comment form title. + * Default: '

      '. + * @type string $cancel_reply_before HTML displayed before the cancel reply link. + * @type string $cancel_reply_after HTML displayed after the cancel reply link. + * @type string $cancel_reply_link The translatable 'cancel reply' button label. Default 'Cancel reply'. + * @type string $label_submit The translatable 'submit' button label. Default 'Post a comment'. + * @type string $submit_button HTML format for the Submit button. + * Default: ''. + * @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden + * fields. Default: '

      %1$s %2$s

      ', where %1$s is the + * submit button markup and %2$s is the comment hidden fields. + * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. + * } + * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. + */ +function comment_form( $args = array(), $post_id = null ) { + if ( null === $post_id ) + $post_id = get_the_ID(); + + // Exit the function when comments for the post are closed. + if ( ! comments_open( $post_id ) ) { + /** + * Fires after the comment form if comments are closed. + * + * @since 3.0.0 + */ + do_action( 'comment_form_comments_closed' ); + + return; + } + + $commenter = wp_get_current_commenter(); + $user = wp_get_current_user(); + $user_identity = $user->exists() ? $user->display_name : ''; + + $args = wp_parse_args( $args ); + if ( ! isset( $args['format'] ) ) + $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; + + $req = get_option( 'require_name_email' ); + $html_req = ( $req ? " required='required'" : '' ); + $html5 = 'html5' === $args['format']; + $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; + $fields = array( + 'author' => '

      ' . ' ' . + '

      ', + 'email' => '', + 'url' => '

      ' . + '

      ', + 'cookies' => '', + ); + + $required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' ); + + /** + * Filters the default comment form fields. + * + * @since 3.0.0 + * + * @param array $fields The default comment fields. + */ + $fields = apply_filters( 'comment_form_default_fields', $fields ); + $defaults = array( + 'fields' => $fields, + 'comment_field' => '

      ', + /** This filter is documented in wp-includes/link-template.php */ + 'must_log_in' => '', + /** This filter is documented in wp-includes/link-template.php */ + 'logged_in_as' => '

      ' . sprintf( + /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ + __( 'Logged in as %3$s. Log out?' ), + get_edit_user_link(), + /* translators: %s: user name */ + esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), + $user_identity, + wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) + ) . '

      ', + 'comment_notes_before' => '

      ' . __( 'Your email address will not be published.' ) . ''. ( $req ? $required_text : '' ) . '

      ', + 'comment_notes_after' => '', + 'action' => site_url( '/wp-comments-post.php' ), + 'id_form' => 'commentform', + 'id_submit' => 'submit', + 'class_form' => 'comment-form', + 'class_submit' => 'submit', + 'name_submit' => 'submit', + 'title_reply' => __( 'Leave a Reply' ), + 'title_reply_to' => __( 'Leave a Reply to %s' ), + 'title_reply_before' => '

      ', + 'title_reply_after' => '

      ', + 'cancel_reply_before' => ' ', + 'cancel_reply_after' => '', + 'cancel_reply_link' => __( 'Cancel reply' ), + 'label_submit' => __( 'Post Comment' ), + 'submit_button' => '', + 'submit_field' => '

      %1$s %2$s

      ', + 'format' => 'xhtml', + ); + + /** + * Filters the comment form default arguments. + * + * Use {@see 'comment_form_default_fields'} to filter the comment fields. + * + * @since 3.0.0 + * + * @param array $defaults The default comment form arguments. + */ + $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); + + // Ensure that the filtered args contain all required default values. + $args = array_merge( $defaults, $args ); + + /** + * Fires before the comment form. + * + * @since 3.0.0 + */ + do_action( 'comment_form_before' ); + ?> +
      + +
      > + $args['comment_field'] ) + (array) $args['fields']; + + /** + * Filters the comment form fields, including the textarea. + * + * @since 4.4.0 + * + * @param array $comment_fields The comment fields. + */ + $comment_fields = apply_filters( 'comment_form_fields', $comment_fields ); + + // Get an array of field names, excluding the textarea + $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) ); + + // Get the first and the last field name, excluding the textarea + $first_field = reset( $comment_field_keys ); + $last_field = end( $comment_field_keys ); + + foreach ( $comment_fields as $name => $field ) { + + if ( 'comment' === $name ) { + + /** + * Filters the content of the comment textarea field for display. + * + * @since 3.0.0 + * + * @param string $args_comment_field The content of the comment textarea field. + */ + echo apply_filters( 'comment_form_field_comment', $field ); + + echo $args['comment_notes_after']; + + } elseif ( ! is_user_logged_in() ) { + + if ( $first_field === $name ) { + /** + * Fires before the comment fields in the comment form, excluding the textarea. + * + * @since 3.0.0 + */ + do_action( 'comment_form_before_fields' ); + } + + /** + * Filters a comment form field for display. + * + * The dynamic portion of the filter hook, `$name`, refers to the name + * of the comment form field. Such as 'author', 'email', or 'url'. + * + * @since 3.0.0 + * + * @param string $field The HTML-formatted output of the comment form field. + */ + echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; + + if ( $last_field === $name ) { + /** + * Fires after the comment fields in the comment form, excluding the textarea. + * + * @since 3.0.0 + */ + do_action( 'comment_form_after_fields' ); + } + } + } + + $submit_button = sprintf( + $args['submit_button'], + esc_attr( $args['name_submit'] ), + esc_attr( $args['id_submit'] ), + esc_attr( $args['class_submit'] ), + esc_attr( $args['label_submit'] ) + ); + + /** + * Filters the submit button for the comment form to display. + * + * @since 4.2.0 + * + * @param string $submit_button HTML markup for the submit button. + * @param array $args Arguments passed to `comment_form()`. + */ + $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); + + $submit_field = sprintf( + $args['submit_field'], + $submit_button, + get_comment_id_fields( $post_id ) + ); + + /** + * Filters the submit field for the comment form to display. + * + * The submit field includes the submit button, hidden fields for the + * comment form, and any wrapper markup. + * + * @since 4.2.0 + * + * @param string $submit_field HTML markup for the submit field. + * @param array $args Arguments passed to comment_form(). + */ + echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); + + /** + * Fires at the bottom of the comment form, inside the closing
      tag. + * + * @since 1.5.0 + * + * @param int $post_id The post ID. + */ + do_action( 'comment_form', $post_id ); + ?> + + +
      + ]*href/i', $comment, $out ); + + /** + * Filters the number of links found in a comment. + * + * @since 3.0.0 + * @since 4.7.0 Added the `$comment` parameter. + * + * @param int $num_links The number of links found. + * @param string $url Comment author's URL. Included in allowed links total. + * @param string $comment Content of the comment. + */ + $num_links = apply_filters( 'comment_max_links_url', $num_links, $url, $comment ); + + /* + * If the number of links in the comment exceeds the allowed amount, + * fail the check by returning false. + */ + if ( $num_links >= $max_links ) + return false; + } + + $mod_keys = trim(get_option('moderation_keys')); + + // If moderation 'keys' (keywords) are set, process them. + if ( !empty($mod_keys) ) { + $words = explode("\n", $mod_keys ); + + foreach ( (array) $words as $word) { + $word = trim($word); + + // Skip empty lines. + if ( empty($word) ) + continue; + + /* + * Do some escaping magic so that '#' (number of) characters in the spam + * words don't break things: + */ + $word = preg_quote($word, '#'); + + /* + * Check the comment fields for moderation keywords. If any are found, + * fail the check for the given field by returning false. + */ + $pattern = "#$word#i"; + if ( preg_match($pattern, $author) ) return false; + if ( preg_match($pattern, $email) ) return false; + if ( preg_match($pattern, $url) ) return false; + if ( preg_match($pattern, $comment) ) return false; + if ( preg_match($pattern, $user_ip) ) return false; + if ( preg_match($pattern, $user_agent) ) return false; + } + } + + /* + * Check if the option to approve comments by previously-approved authors is enabled. + * + * If it is enabled, check whether the comment author has a previously-approved comment, + * as well as whether there are any moderation keywords (if set) present in the author + * email address. If both checks pass, return true. Otherwise, return false. + */ + if ( 1 == get_option('comment_whitelist')) { + if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) { + $comment_user = get_user_by( 'email', wp_unslash( $email ) ); + if ( ! empty( $comment_user->ID ) ) { + $ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE user_id = %d AND comment_approved = '1' LIMIT 1", $comment_user->ID ) ); + } else { + // expected_slashed ($author, $email) + $ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email ) ); + } + if ( ( 1 == $ok_to_comment ) && + ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) + return true; + else + return false; + } else { + return false; + } + } + return true; +} + +/** + * Retrieve the approved comments for post $post_id. + * + * @since 2.0.0 + * @since 4.1.0 Refactored to leverage WP_Comment_Query over a direct query. + * + * @param int $post_id The ID of the post. + * @param array $args Optional. See WP_Comment_Query::__construct() for information on accepted arguments. + * @return int|array $comments The approved comments, or number of comments if `$count` + * argument is true. + */ +function get_approved_comments( $post_id, $args = array() ) { + if ( ! $post_id ) { + return array(); + } + + $defaults = array( + 'status' => 1, + 'post_id' => $post_id, + 'order' => 'ASC', + ); + $r = wp_parse_args( $args, $defaults ); + + $query = new WP_Comment_Query; + return $query->query( $r ); +} + +/** + * Retrieves comment data given a comment ID or comment object. + * + * If an object is passed then the comment data will be cached and then returned + * after being passed through a filter. If the comment is empty, then the global + * comment variable will be used, if it is set. + * + * @since 2.0.0 + * + * @global WP_Comment $comment + * + * @param WP_Comment|string|int $comment Comment to retrieve. + * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to + * a WP_Comment object, an associative array, or a numeric array, respectively. Default OBJECT. + * @return WP_Comment|array|null Depends on $output value. + */ +function get_comment( &$comment = null, $output = OBJECT ) { + if ( empty( $comment ) && isset( $GLOBALS['comment'] ) ) { + $comment = $GLOBALS['comment']; + } + + if ( $comment instanceof WP_Comment ) { + $_comment = $comment; + } elseif ( is_object( $comment ) ) { + $_comment = new WP_Comment( $comment ); + } else { + $_comment = WP_Comment::get_instance( $comment ); + } + + if ( ! $_comment ) { + return null; + } + + /** + * Fires after a comment is retrieved. + * + * @since 2.3.0 + * + * @param mixed $_comment Comment data. + */ + $_comment = apply_filters( 'get_comment', $_comment ); + + if ( $output == OBJECT ) { + return $_comment; + } elseif ( $output == ARRAY_A ) { + return $_comment->to_array(); + } elseif ( $output == ARRAY_N ) { + return array_values( $_comment->to_array() ); + } + return $_comment; +} + +/** + * Retrieve a list of comments. + * + * The comment list can be for the blog as a whole or for an individual post. + * + * @since 2.7.0 + * + * @param string|array $args Optional. Array or string of arguments. See WP_Comment_Query::__construct() + * for information on accepted arguments. Default empty. + * @return int|array List of comments or number of found comments if `$count` argument is true. + */ +function get_comments( $args = '' ) { + $query = new WP_Comment_Query; + return $query->query( $args ); +} + +/** + * Retrieve all of the WordPress supported comment statuses. + * + * Comments have a limited set of valid status values, this provides the comment + * status values and descriptions. + * + * @since 2.7.0 + * + * @return array List of comment statuses. + */ +function get_comment_statuses() { + $status = array( + 'hold' => __( 'Unapproved' ), + 'approve' => _x( 'Approved', 'comment status' ), + 'spam' => _x( 'Spam', 'comment status' ), + 'trash' => _x( 'Trash', 'comment status' ), + ); + + return $status; +} + +/** + * Gets the default comment status for a post type. + * + * @since 4.3.0 + * + * @param string $post_type Optional. Post type. Default 'post'. + * @param string $comment_type Optional. Comment type. Default 'comment'. + * @return string Expected return value is 'open' or 'closed'. + */ +function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { + switch ( $comment_type ) { + case 'pingback' : + case 'trackback' : + $supports = 'trackbacks'; + $option = 'ping'; + break; + default : + $supports = 'comments'; + $option = 'comment'; + } + + // Set the status. + if ( 'page' === $post_type ) { + $status = 'closed'; + } elseif ( post_type_supports( $post_type, $supports ) ) { + $status = get_option( "default_{$option}_status" ); + } else { + $status = 'closed'; + } + + /** + * Filters the default comment status for the given post type. + * + * @since 4.3.0 + * + * @param string $status Default status for the given post type, + * either 'open' or 'closed'. + * @param string $post_type Post type. Default is `post`. + * @param string $comment_type Type of comment. Default is `comment`. + */ + return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); +} + +/** + * The date the last comment was modified. + * + * @since 1.5.0 + * @since 4.7.0 Replaced caching the modified date in a local static variable + * with the Object Cache API. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations. + * @return string|false Last comment modified date on success, false on failure. + */ +function get_lastcommentmodified( $timezone = 'server' ) { + global $wpdb; + + $timezone = strtolower( $timezone ); + $key = "lastcommentmodified:$timezone"; + + $comment_modified_date = wp_cache_get( $key, 'timeinfo' ); + if ( false !== $comment_modified_date ) { + return $comment_modified_date; + } + + switch ( $timezone ) { + case 'gmt': + $comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); + break; + case 'blog': + $comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); + break; + case 'server': + $add_seconds_server = date( 'Z' ); + + $comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) ); + break; + } + + if ( $comment_modified_date ) { + wp_cache_set( $key, $comment_modified_date, 'timeinfo' ); + + return $comment_modified_date; + } + + return false; +} + +/** + * The amount of comments in a post or total comments. + * + * A lot like wp_count_comments(), in that they both return comment stats (albeit with different types). + * The wp_count_comments() actually caches, but this function does not. + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide. + * @return array The amount of spam, approved, awaiting moderation, and total comments. + */ +function get_comment_count( $post_id = 0 ) { + global $wpdb; + + $post_id = (int) $post_id; + + $where = ''; + if ( $post_id > 0 ) { + $where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id); + } + + $totals = (array) $wpdb->get_results(" + SELECT comment_approved, COUNT( * ) AS total + FROM {$wpdb->comments} + {$where} + GROUP BY comment_approved + ", ARRAY_A); + + $comment_count = array( + 'approved' => 0, + 'awaiting_moderation' => 0, + 'spam' => 0, + 'trash' => 0, + 'post-trashed' => 0, + 'total_comments' => 0, + 'all' => 0, + ); + + foreach ( $totals as $row ) { + switch ( $row['comment_approved'] ) { + case 'trash': + $comment_count['trash'] = $row['total']; + break; + case 'post-trashed': + $comment_count['post-trashed'] = $row['total']; + break; + case 'spam': + $comment_count['spam'] = $row['total']; + $comment_count['total_comments'] += $row['total']; + break; + case '1': + $comment_count['approved'] = $row['total']; + $comment_count['total_comments'] += $row['total']; + $comment_count['all'] += $row['total']; + break; + case '0': + $comment_count['awaiting_moderation'] = $row['total']; + $comment_count['total_comments'] += $row['total']; + $comment_count['all'] += $row['total']; + break; + default: + break; + } + } + + return $comment_count; +} + +// +// Comment meta functions +// + +/** + * Add meta data field to a comment. + * + * @since 2.9.0 + * @link https://codex.wordpress.org/Function_Reference/add_comment_meta + * + * @param int $comment_id Comment ID. + * @param string $meta_key Metadata name. + * @param mixed $meta_value Metadata value. + * @param bool $unique Optional, default is false. Whether the same key should not be added. + * @return int|bool Meta ID on success, false on failure. + */ +function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) { + $added = add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique ); + if ( $added ) { + wp_cache_set( 'last_changed', microtime(), 'comment' ); + } + return $added; +} + +/** + * Remove metadata matching criteria from a comment. + * + * You can match based on the key, or key and value. Removing based on key and + * value, will keep from removing duplicate metadata with the same key. It also + * allows removing all metadata matching key, if needed. + * + * @since 2.9.0 + * @link https://codex.wordpress.org/Function_Reference/delete_comment_meta + * + * @param int $comment_id comment ID + * @param string $meta_key Metadata name. + * @param mixed $meta_value Optional. Metadata value. + * @return bool True on success, false on failure. + */ +function delete_comment_meta($comment_id, $meta_key, $meta_value = '') { + $deleted = delete_metadata( 'comment', $comment_id, $meta_key, $meta_value ); + if ( $deleted ) { + wp_cache_set( 'last_changed', microtime(), 'comment' ); + } + return $deleted; +} + +/** + * Retrieve comment meta field for a comment. + * + * @since 2.9.0 + * @link https://codex.wordpress.org/Function_Reference/get_comment_meta + * + * @param int $comment_id Comment ID. + * @param string $key Optional. The meta key to retrieve. By default, returns data for all keys. + * @param bool $single Whether to return a single value. + * @return mixed Will be an array if $single is false. Will be value of meta data field if $single + * is true. + */ +function get_comment_meta($comment_id, $key = '', $single = false) { + return get_metadata('comment', $comment_id, $key, $single); +} + +/** + * Update comment meta field based on comment ID. + * + * Use the $prev_value parameter to differentiate between meta fields with the + * same key and comment ID. + * + * If the meta field for the comment does not exist, it will be added. + * + * @since 2.9.0 + * @link https://codex.wordpress.org/Function_Reference/update_comment_meta + * + * @param int $comment_id Comment ID. + * @param string $meta_key Metadata key. + * @param mixed $meta_value Metadata value. + * @param mixed $prev_value Optional. Previous value to check before removing. + * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. + */ +function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') { + $updated = update_metadata( 'comment', $comment_id, $meta_key, $meta_value, $prev_value ); + if ( $updated ) { + wp_cache_set( 'last_changed', microtime(), 'comment' ); + } + return $updated; +} + +/** + * Queues comments for metadata lazy-loading. + * + * @since 4.5.0 + * + * @param array $comments Array of comment objects. + */ +function wp_queue_comments_for_comment_meta_lazyload( $comments ) { + // Don't use `wp_list_pluck()` to avoid by-reference manipulation. + $comment_ids = array(); + if ( is_array( $comments ) ) { + foreach ( $comments as $comment ) { + if ( $comment instanceof WP_Comment ) { + $comment_ids[] = $comment->comment_ID; + } + } + } + + if ( $comment_ids ) { + $lazyloader = wp_metadata_lazyloader(); + $lazyloader->queue_objects( 'comment', $comment_ids ); + } +} + +/** + * Sets the cookies used to store an unauthenticated commentator's identity. Typically used + * to recall previous comments by this commentator that are still held in moderation. + * + * @since 3.4.0 + * @since 4.9.6 The `$cookies_consent` parameter was added. + * + * @param WP_Comment $comment Comment object. + * @param WP_User $user Comment author's user object. The user may not exist. + * @param boolean $cookies_consent Optional. Comment author's consent to store cookies. Default true. + */ +function wp_set_comment_cookies( $comment, $user, $cookies_consent = true ) { + // If the user already exists, or the user opted out of cookies, don't set cookies. + if ( $user->exists() ) { + return; + } + + if ( false === $cookies_consent ) { + // Remove any existing cookies. + $past = time() - YEAR_IN_SECONDS; + setcookie( 'comment_author_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); + setcookie( 'comment_author_email_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); + setcookie( 'comment_author_url_' . COOKIEHASH, ' ', $past, COOKIEPATH, COOKIE_DOMAIN ); + + return; + } + + /** + * Filters the lifetime of the comment cookie in seconds. + * + * @since 2.8.0 + * + * @param int $seconds Comment cookie lifetime. Default 30000000. + */ + $comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 ); + $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); + setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); + setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); + setcookie( 'comment_author_url_' . COOKIEHASH, esc_url( $comment->comment_author_url ), $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); +} + +/** + * Sanitizes the cookies sent to the user already. + * + * Will only do anything if the cookies have already been created for the user. + * Mostly used after cookies had been sent to use elsewhere. + * + * @since 2.0.4 + */ +function sanitize_comment_cookies() { + if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) { + /** + * Filters the comment author's name cookie before it is set. + * + * When this filter hook is evaluated in wp_filter_comment(), + * the comment author's name string is passed. + * + * @since 1.5.0 + * + * @param string $author_cookie The comment author name cookie. + */ + $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] ); + $comment_author = wp_unslash($comment_author); + $comment_author = esc_attr($comment_author); + $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author; + } + + if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) { + /** + * Filters the comment author's email cookie before it is set. + * + * When this filter hook is evaluated in wp_filter_comment(), + * the comment author's email string is passed. + * + * @since 1.5.0 + * + * @param string $author_email_cookie The comment author email cookie. + */ + $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] ); + $comment_author_email = wp_unslash($comment_author_email); + $comment_author_email = esc_attr($comment_author_email); + $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; + } + + if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) { + /** + * Filters the comment author's URL cookie before it is set. + * + * When this filter hook is evaluated in wp_filter_comment(), + * the comment author's URL string is passed. + * + * @since 1.5.0 + * + * @param string $author_url_cookie The comment author URL cookie. + */ + $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] ); + $comment_author_url = wp_unslash($comment_author_url); + $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; + } +} + +/** + * Validates whether this comment is allowed to be made. + * + * @since 2.0.0 + * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to + * return a WP_Error object instead of dying. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $commentdata Contains information on the comment. + * @param bool $avoid_die When true, a disallowed comment will result in the function + * returning a WP_Error object, rather than executing wp_die(). + * Default false. + * @return int|string|WP_Error Allowed comments return the approval status (0|1|'spam'). + * If `$avoid_die` is true, disallowed comments return a WP_Error. + */ +function wp_allow_comment( $commentdata, $avoid_die = false ) { + global $wpdb; + + // Simple duplicate check + // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) + $dupe = $wpdb->prepare( + "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", + wp_unslash( $commentdata['comment_post_ID'] ), + wp_unslash( $commentdata['comment_parent'] ), + wp_unslash( $commentdata['comment_author'] ) + ); + if ( $commentdata['comment_author_email'] ) { + $dupe .= $wpdb->prepare( + "AND comment_author_email = %s ", + wp_unslash( $commentdata['comment_author_email'] ) + ); + } + $dupe .= $wpdb->prepare( + ") AND comment_content = %s LIMIT 1", + wp_unslash( $commentdata['comment_content'] ) + ); + + $dupe_id = $wpdb->get_var( $dupe ); + + /** + * Filters the ID, if any, of the duplicate comment found when creating a new comment. + * + * Return an empty value from this filter to allow what WP considers a duplicate comment. + * + * @since 4.4.0 + * + * @param int $dupe_id ID of the comment identified as a duplicate. + * @param array $commentdata Data for the comment being created. + */ + $dupe_id = apply_filters( 'duplicate_comment_id', $dupe_id, $commentdata ); + + if ( $dupe_id ) { + /** + * Fires immediately after a duplicate comment is detected. + * + * @since 3.0.0 + * + * @param array $commentdata Comment data. + */ + do_action( 'comment_duplicate_trigger', $commentdata ); + if ( true === $avoid_die ) { + return new WP_Error( 'comment_duplicate', __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 ); + } else { + if ( wp_doing_ajax() ) { + die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); + } + + wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 ); + } + } + + /** + * Fires immediately before a comment is marked approved. + * + * Allows checking for comment flooding. + * + * @since 2.3.0 + * @since 4.7.0 The `$avoid_die` parameter was added. + * + * @param string $comment_author_IP Comment author's IP address. + * @param string $comment_author_email Comment author's email. + * @param string $comment_date_gmt GMT date the comment was posted. + * @param bool $avoid_die Whether to prevent executing wp_die() + * or die() if a comment flood is occurring. + */ + do_action( + 'check_comment_flood', + $commentdata['comment_author_IP'], + $commentdata['comment_author_email'], + $commentdata['comment_date_gmt'], + $avoid_die + ); + + /** + * Filters whether a comment is part of a comment flood. + * + * The default check is wp_check_comment_flood(). See check_comment_flood_db(). + * + * @since 4.7.0 + * + * @param bool $is_flood Is a comment flooding occurring? Default false. + * @param string $comment_author_IP Comment author's IP address. + * @param string $comment_author_email Comment author's email. + * @param string $comment_date_gmt GMT date the comment was posted. + * @param bool $avoid_die Whether to prevent executing wp_die() + * or die() if a comment flood is occurring. + */ + $is_flood = apply_filters( + 'wp_is_comment_flood', + false, + $commentdata['comment_author_IP'], + $commentdata['comment_author_email'], + $commentdata['comment_date_gmt'], + $avoid_die + ); + + if ( $is_flood ) { + return new WP_Error( 'comment_flood', __( 'You are posting comments too quickly. Slow down.' ), 429 ); + } + + if ( ! empty( $commentdata['user_id'] ) ) { + $user = get_userdata( $commentdata['user_id'] ); + $post_author = $wpdb->get_var( $wpdb->prepare( + "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", + $commentdata['comment_post_ID'] + ) ); + } + + if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { + // The author and the admins get respect. + $approved = 1; + } else { + // Everyone else's comments will be checked. + if ( check_comment( + $commentdata['comment_author'], + $commentdata['comment_author_email'], + $commentdata['comment_author_url'], + $commentdata['comment_content'], + $commentdata['comment_author_IP'], + $commentdata['comment_agent'], + $commentdata['comment_type'] + ) ) { + $approved = 1; + } else { + $approved = 0; + } + + if ( wp_blacklist_check( + $commentdata['comment_author'], + $commentdata['comment_author_email'], + $commentdata['comment_author_url'], + $commentdata['comment_content'], + $commentdata['comment_author_IP'], + $commentdata['comment_agent'] + ) ) { + $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam'; + } + } + + /** + * Filters a comment's approval status before it is set. + * + * @since 2.1.0 + * @since 4.9.0 Returning a WP_Error value from the filter will shortcircuit comment insertion and + * allow skipping further processing. + * + * @param bool|string|WP_Error $approved The approval status. Accepts 1, 0, 'spam' or WP_Error. + * @param array $commentdata Comment data. + */ + $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); + return $approved; +} + +/** + * Hooks WP's native database-based comment-flood check. + * + * This wrapper maintains backward compatibility with plugins that expect to + * be able to unhook the legacy check_comment_flood_db() function from + * 'check_comment_flood' using remove_action(). + * + * @since 2.3.0 + * @since 4.7.0 Converted to be an add_filter() wrapper. + */ +function check_comment_flood_db() { + add_filter( 'wp_is_comment_flood', 'wp_check_comment_flood', 10, 5 ); +} + +/** + * Checks whether comment flooding is occurring. + * + * Won't run, if current user can manage options, so to not block + * administrators. + * + * @since 4.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param bool $is_flood Is a comment flooding occurring? + * @param string $ip Comment author's IP address. + * @param string $email Comment author's email address. + * @param string $date MySQL time string. + * @param bool $avoid_die When true, a disallowed comment will result in the function + * returning a WP_Error object, rather than executing wp_die(). + * Default false. + * @return bool Whether comment flooding is occurring. + */ +function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) { + + global $wpdb; + + // Another callback has declared a flood. Trust it. + if ( true === $is_flood ) { + return $is_flood; + } + + // don't throttle admins or moderators + if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) { + return false; + } + $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); + + if ( is_user_logged_in() ) { + $user = get_current_user_id(); + $check_column = '`user_id`'; + } else { + $user = $ip; + $check_column = '`comment_author_IP`'; + } + + $sql = $wpdb->prepare( + "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", + $hour_ago, + $user, + $email + ); + $lasttime = $wpdb->get_var( $sql ); + if ( $lasttime ) { + $time_lastcomment = mysql2date('U', $lasttime, false); + $time_newcomment = mysql2date('U', $date, false); + /** + * Filters the comment flood status. + * + * @since 2.1.0 + * + * @param bool $bool Whether a comment flood is occurring. Default false. + * @param int $time_lastcomment Timestamp of when the last comment was posted. + * @param int $time_newcomment Timestamp of when the new comment was posted. + */ + $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); + if ( $flood_die ) { + /** + * Fires before the comment flood message is triggered. + * + * @since 1.5.0 + * + * @param int $time_lastcomment Timestamp of when the last comment was posted. + * @param int $time_newcomment Timestamp of when the new comment was posted. + */ + do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); + if ( true === $avoid_die ) { + return true; + } else { + if ( wp_doing_ajax() ) { + die( __('You are posting comments too quickly. Slow down.') ); + } + + wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); + } + } + } + + return false; +} + +/** + * Separates an array of comments into an array keyed by comment_type. + * + * @since 2.7.0 + * + * @param array $comments Array of comments + * @return array Array of comments keyed by comment_type. + */ +function separate_comments(&$comments) { + $comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array()); + $count = count($comments); + for ( $i = 0; $i < $count; $i++ ) { + $type = $comments[$i]->comment_type; + if ( empty($type) ) + $type = 'comment'; + $comments_by_type[$type][] = &$comments[$i]; + if ( 'trackback' == $type || 'pingback' == $type ) + $comments_by_type['pings'][] = &$comments[$i]; + } + + return $comments_by_type; +} + +/** + * Calculate the total number of comment pages. + * + * @since 2.7.0 + * + * @uses Walker_Comment + * + * @global WP_Query $wp_query + * + * @param array $comments Optional array of WP_Comment objects. Defaults to $wp_query->comments + * @param int $per_page Optional comments per page. + * @param bool $threaded Optional control over flat or threaded comments. + * @return int Number of comment pages. + */ +function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { + global $wp_query; + + if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) + return $wp_query->max_num_comment_pages; + + if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) + $comments = $wp_query->comments; + + if ( empty($comments) ) + return 0; + + if ( ! get_option( 'page_comments' ) ) { + return 1; + } + + if ( !isset($per_page) ) + $per_page = (int) get_query_var('comments_per_page'); + if ( 0 === $per_page ) + $per_page = (int) get_option('comments_per_page'); + if ( 0 === $per_page ) + return 1; + + if ( !isset($threaded) ) + $threaded = get_option('thread_comments'); + + if ( $threaded ) { + $walker = new Walker_Comment; + $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page ); + } else { + $count = ceil( count( $comments ) / $per_page ); + } + + return $count; +} + +/** + * Calculate what page number a comment will appear on for comment paging. + * + * @since 2.7.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $comment_ID Comment ID. + * @param array $args { + * Array of optional arguments. + * @type string $type Limit paginated comments to those matching a given type. Accepts 'comment', + * 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'. + * Default is 'all'. + * @type int $per_page Per-page count to use when calculating pagination. Defaults to the value of the + * 'comments_per_page' option. + * @type int|string $max_depth If greater than 1, comment page will be determined for the top-level parent of + * `$comment_ID`. Defaults to the value of the 'thread_comments_depth' option. + * } * + * @return int|null Comment page number or null on error. + */ +function get_page_of_comment( $comment_ID, $args = array() ) { + global $wpdb; + + $page = null; + + if ( !$comment = get_comment( $comment_ID ) ) + return; + + $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); + $args = wp_parse_args( $args, $defaults ); + $original_args = $args; + + // Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option. + if ( get_option( 'page_comments' ) ) { + if ( '' === $args['per_page'] ) { + $args['per_page'] = get_query_var( 'comments_per_page' ); + } + + if ( '' === $args['per_page'] ) { + $args['per_page'] = get_option( 'comments_per_page' ); + } + } + + if ( empty($args['per_page']) ) { + $args['per_page'] = 0; + $args['page'] = 0; + } + + if ( $args['per_page'] < 1 ) { + $page = 1; + } + + if ( null === $page ) { + if ( '' === $args['max_depth'] ) { + if ( get_option('thread_comments') ) + $args['max_depth'] = get_option('thread_comments_depth'); + else + $args['max_depth'] = -1; + } + + // Find this comment's top level parent if threading is enabled + if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) + return get_page_of_comment( $comment->comment_parent, $args ); + + $comment_args = array( + 'type' => $args['type'], + 'post_id' => $comment->comment_post_ID, + 'fields' => 'ids', + 'count' => true, + 'status' => 'approve', + 'parent' => 0, + 'date_query' => array( + array( + 'column' => "$wpdb->comments.comment_date_gmt", + 'before' => $comment->comment_date_gmt, + ) + ), + ); + + $comment_query = new WP_Comment_Query(); + $older_comment_count = $comment_query->query( $comment_args ); + + // No older comments? Then it's page #1. + if ( 0 == $older_comment_count ) { + $page = 1; + + // Divide comments older than this one by comments per page to get this comment's page number + } else { + $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] ); + } + } + + /** + * Filters the calculated page on which a comment appears. + * + * @since 4.4.0 + * @since 4.7.0 Introduced the `$comment_ID` parameter. + * + * @param int $page Comment page. + * @param array $args { + * Arguments used to calculate pagination. These include arguments auto-detected by the function, + * based on query vars, system settings, etc. For pristine arguments passed to the function, + * see `$original_args`. + * + * @type string $type Type of comments to count. + * @type int $page Calculated current page. + * @type int $per_page Calculated number of comments per page. + * @type int $max_depth Maximum comment threading depth allowed. + * } + * @param array $original_args { + * Array of arguments passed to the function. Some or all of these may not be set. + * + * @type string $type Type of comments to count. + * @type int $page Current comment page. + * @type int $per_page Number of comments per page. + * @type int $max_depth Maximum comment threading depth allowed. + * } + * @param int $comment_ID ID of the comment. + */ + return apply_filters( 'get_page_of_comment', (int) $page, $args, $original_args, $comment_ID ); +} + +/** + * Retrieves the maximum character lengths for the comment form fields. + * + * @since 4.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @return array Maximum character length for the comment form fields. + */ +function wp_get_comment_fields_max_lengths() { + global $wpdb; + + $lengths = array( + 'comment_author' => 245, + 'comment_author_email' => 100, + 'comment_author_url' => 200, + 'comment_content' => 65525, + ); + + if ( $wpdb->is_mysql ) { + foreach ( $lengths as $column => $length ) { + $col_length = $wpdb->get_col_length( $wpdb->comments, $column ); + $max_length = 0; + + // No point if we can't get the DB column lengths + if ( is_wp_error( $col_length ) ) { + break; + } + + if ( ! is_array( $col_length ) && (int) $col_length > 0 ) { + $max_length = (int) $col_length; + } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) && intval( $col_length['length'] ) > 0 ) { + $max_length = (int) $col_length['length']; + + if ( ! empty( $col_length['type'] ) && 'byte' === $col_length['type'] ) { + $max_length = $max_length - 10; + } + } + + if ( $max_length > 0 ) { + $lengths[ $column ] = $max_length; + } + } + } + + /** + * Filters the lengths for the comment form fields. + * + * @since 4.5.0 + * + * @param array $lengths Associative array `'field_name' => 'maximum length'`. + */ + return apply_filters( 'wp_get_comment_fields_max_lengths', $lengths ); +} + +/** + * Compares the lengths of comment data against the maximum character limits. + * + * @since 4.7.0 + * + * @param array $comment_data Array of arguments for inserting a comment. + * @return WP_Error|true WP_Error when a comment field exceeds the limit, + * otherwise true. + */ +function wp_check_comment_data_max_lengths( $comment_data ) { + $max_lengths = wp_get_comment_fields_max_lengths(); + + if ( isset( $comment_data['comment_author'] ) && mb_strlen( $comment_data['comment_author'], '8bit' ) > $max_lengths['comment_author'] ) { + return new WP_Error( 'comment_author_column_length', __( 'ERROR: your name is too long.' ), 200 ); + } + + if ( isset( $comment_data['comment_author_email'] ) && strlen( $comment_data['comment_author_email'] ) > $max_lengths['comment_author_email'] ) { + return new WP_Error( 'comment_author_email_column_length', __( 'ERROR: your email address is too long.' ), 200 ); + } + + if ( isset( $comment_data['comment_author_url'] ) && strlen( $comment_data['comment_author_url'] ) > $max_lengths['comment_author_url'] ) { + return new WP_Error( 'comment_author_url_column_length', __( 'ERROR: your url is too long.' ), 200 ); + } + + if ( isset( $comment_data['comment_content'] ) && mb_strlen( $comment_data['comment_content'], '8bit' ) > $max_lengths['comment_content'] ) { + return new WP_Error( 'comment_content_column_length', __( 'ERROR: your comment is too long.' ), 200 ); + } + + return true; +} + +/** + * Does comment contain blacklisted characters or words. + * + * @since 1.5.0 + * + * @param string $author The author of the comment + * @param string $email The email of the comment + * @param string $url The url used in the comment + * @param string $comment The comment content + * @param string $user_ip The comment author's IP address + * @param string $user_agent The author's browser user agent + * @return bool True if comment contains blacklisted content, false if comment does not + */ +function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { + /** + * Fires before the comment is tested for blacklisted characters or words. + * + * @since 1.5.0 + * + * @param string $author Comment author. + * @param string $email Comment author's email. + * @param string $url Comment author's URL. + * @param string $comment Comment content. + * @param string $user_ip Comment author's IP address. + * @param string $user_agent Comment author's browser user agent. + */ + do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); + + $mod_keys = trim( get_option('blacklist_keys') ); + if ( '' == $mod_keys ) + return false; // If moderation keys are empty + + // Ensure HTML tags are not being used to bypass the blacklist. + $comment_without_html = wp_strip_all_tags( $comment ); + + $words = explode("\n", $mod_keys ); + + foreach ( (array) $words as $word ) { + $word = trim($word); + + // Skip empty lines + if ( empty($word) ) { continue; } + + // Do some escaping magic so that '#' chars in the + // spam words don't break things: + $word = preg_quote($word, '#'); + + $pattern = "#$word#i"; + if ( + preg_match($pattern, $author) + || preg_match($pattern, $email) + || preg_match($pattern, $url) + || preg_match($pattern, $comment) + || preg_match($pattern, $comment_without_html) + || preg_match($pattern, $user_ip) + || preg_match($pattern, $user_agent) + ) + return true; + } + return false; +} + +/** + * Retrieve total comments for blog or single post. + * + * The properties of the returned object contain the 'moderated', 'approved', + * and spam comments for either the entire blog or single post. Those properties + * contain the amount of comments that match the status. The 'total_comments' + * property contains the integer of total comments. + * + * The comment stats are cached and then retrieved, if they already exist in the + * cache. + * + * @since 2.5.0 + * + * @param int $post_id Optional. Post ID. + * @return object|array Comment stats. + */ +function wp_count_comments( $post_id = 0 ) { + $post_id = (int) $post_id; + + /** + * Filters the comments count for a given post. + * + * @since 2.7.0 + * + * @param array $count An empty array. + * @param int $post_id The post ID. + */ + $filtered = apply_filters( 'wp_count_comments', array(), $post_id ); + if ( ! empty( $filtered ) ) { + return $filtered; + } + + $count = wp_cache_get( "comments-{$post_id}", 'counts' ); + if ( false !== $count ) { + return $count; + } + + $stats = get_comment_count( $post_id ); + $stats['moderated'] = $stats['awaiting_moderation']; + unset( $stats['awaiting_moderation'] ); + + $stats_object = (object) $stats; + wp_cache_set( "comments-{$post_id}", $stats_object, 'counts' ); + + return $stats_object; +} + +/** + * Trashes or deletes a comment. + * + * The comment is moved to trash instead of permanently deleted unless trash is + * disabled, item is already in the trash, or $force_delete is true. + * + * The post comment count will be updated if the comment was approved and has a + * post ID available. + * + * @since 2.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. + * @return bool True on success, false on failure. + */ +function wp_delete_comment($comment_id, $force_delete = false) { + global $wpdb; + if (!$comment = get_comment($comment_id)) + return false; + + if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) + return wp_trash_comment($comment_id); + + /** + * Fires immediately before a comment is deleted from the database. + * + * @since 1.2.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment to be deleted. + */ + do_action( 'delete_comment', $comment->comment_ID, $comment ); + + // Move children up a level. + $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) ); + if ( !empty($children) ) { + $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment->comment_ID)); + clean_comment_cache($children); + } + + // Delete metadata + $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); + foreach ( $meta_ids as $mid ) + delete_metadata_by_mid( 'comment', $mid ); + + if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) + return false; + + /** + * Fires immediately after a comment is deleted from the database. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The deleted comment. + */ + do_action( 'deleted_comment', $comment->comment_ID, $comment ); + + $post_id = $comment->comment_post_ID; + if ( $post_id && $comment->comment_approved == 1 ) + wp_update_comment_count($post_id); + + clean_comment_cache( $comment->comment_ID ); + + /** This action is documented in wp-includes/comment.php */ + do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' ); + + wp_transition_comment_status('delete', $comment->comment_approved, $comment); + return true; +} + +/** + * Moves a comment to the Trash + * + * If trash is disabled, comment is permanently deleted. + * + * @since 2.9.0 + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @return bool True on success, false on failure. + */ +function wp_trash_comment($comment_id) { + if ( !EMPTY_TRASH_DAYS ) + return wp_delete_comment($comment_id, true); + + if ( !$comment = get_comment($comment_id) ) + return false; + + /** + * Fires immediately before a comment is sent to the Trash. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment to be trashed. + */ + do_action( 'trash_comment', $comment->comment_ID, $comment ); + + if ( wp_set_comment_status( $comment, 'trash' ) ) { + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); + add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); + add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); + + /** + * Fires immediately after a comment is sent to Trash. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The trashed comment. + */ + do_action( 'trashed_comment', $comment->comment_ID, $comment ); + return true; + } + + return false; +} + +/** + * Removes a comment from the Trash + * + * @since 2.9.0 + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @return bool True on success, false on failure. + */ +function wp_untrash_comment($comment_id) { + $comment = get_comment( $comment_id ); + if ( ! $comment ) { + return false; + } + + /** + * Fires immediately before a comment is restored from the Trash. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment to be untrashed. + */ + do_action( 'untrash_comment', $comment->comment_ID, $comment ); + + $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); + if ( empty($status) ) + $status = '0'; + + if ( wp_set_comment_status( $comment, $status ) ) { + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); + /** + * Fires immediately after a comment is restored from the Trash. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The untrashed comment. + */ + do_action( 'untrashed_comment', $comment->comment_ID, $comment ); + return true; + } + + return false; +} + +/** + * Marks a comment as Spam + * + * @since 2.9.0 + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @return bool True on success, false on failure. + */ +function wp_spam_comment( $comment_id ) { + $comment = get_comment( $comment_id ); + if ( ! $comment ) { + return false; + } + + /** + * Fires immediately before a comment is marked as Spam. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment to be marked as spam. + */ + do_action( 'spam_comment', $comment->comment_ID, $comment ); + + if ( wp_set_comment_status( $comment, 'spam' ) ) { + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); + add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); + add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); + /** + * Fires immediately after a comment is marked as Spam. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment marked as spam. + */ + do_action( 'spammed_comment', $comment->comment_ID, $comment ); + return true; + } + + return false; +} + +/** + * Removes a comment from the Spam + * + * @since 2.9.0 + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @return bool True on success, false on failure. + */ +function wp_unspam_comment( $comment_id ) { + $comment = get_comment( $comment_id ); + if ( ! $comment ) { + return false; + } + + /** + * Fires immediately before a comment is unmarked as Spam. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment to be unmarked as spam. + */ + do_action( 'unspam_comment', $comment->comment_ID, $comment ); + + $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); + if ( empty($status) ) + $status = '0'; + + if ( wp_set_comment_status( $comment, $status ) ) { + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); + delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); + /** + * Fires immediately after a comment is unmarked as Spam. + * + * @since 2.9.0 + * @since 4.9.0 Added the `$comment` parameter. + * + * @param int $comment_id The comment ID. + * @param WP_Comment $comment The comment unmarked as spam. + */ + do_action( 'unspammed_comment', $comment->comment_ID, $comment ); + return true; + } + + return false; +} + +/** + * The status of a comment by ID. + * + * @since 1.0.0 + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object + * @return false|string Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure. + */ +function wp_get_comment_status($comment_id) { + $comment = get_comment($comment_id); + if ( !$comment ) + return false; + + $approved = $comment->comment_approved; + + if ( $approved == null ) + return false; + elseif ( $approved == '1' ) + return 'approved'; + elseif ( $approved == '0' ) + return 'unapproved'; + elseif ( $approved == 'spam' ) + return 'spam'; + elseif ( $approved == 'trash' ) + return 'trash'; + else + return false; +} + +/** + * Call hooks for when a comment status transition occurs. + * + * Calls hooks for comment status transitions. If the new comment status is not the same + * as the previous comment status, then two hooks will be ran, the first is + * {@see 'transition_comment_status'} with new status, old status, and comment data. The + * next action called is {@see comment_$old_status_to_$new_status'}. It has the + * comment data. + * + * The final action will run whether or not the comment statuses are the same. The + * action is named {@see 'comment_$new_status_$comment->comment_type'}. + * + * @since 2.7.0 + * + * @param string $new_status New comment status. + * @param string $old_status Previous comment status. + * @param object $comment Comment data. + */ +function wp_transition_comment_status($new_status, $old_status, $comment) { + /* + * Translate raw statuses to human readable formats for the hooks. + * This is not a complete list of comment status, it's only the ones + * that need to be renamed + */ + $comment_statuses = array( + 0 => 'unapproved', + 'hold' => 'unapproved', // wp_set_comment_status() uses "hold" + 1 => 'approved', + 'approve' => 'approved', // wp_set_comment_status() uses "approve" + ); + if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; + if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; + + // Call the hooks + if ( $new_status != $old_status ) { + /** + * Fires when the comment status is in transition. + * + * @since 2.7.0 + * + * @param int|string $new_status The new comment status. + * @param int|string $old_status The old comment status. + * @param object $comment The comment data. + */ + do_action( 'transition_comment_status', $new_status, $old_status, $comment ); + /** + * Fires when the comment status is in transition from one specific status to another. + * + * The dynamic portions of the hook name, `$old_status`, and `$new_status`, + * refer to the old and new comment statuses, respectively. + * + * @since 2.7.0 + * + * @param WP_Comment $comment Comment object. + */ + do_action( "comment_{$old_status}_to_{$new_status}", $comment ); + } + /** + * Fires when the status of a specific comment type is in transition. + * + * The dynamic portions of the hook name, `$new_status`, and `$comment->comment_type`, + * refer to the new comment status, and the type of comment, respectively. + * + * Typical comment types include an empty string (standard comment), 'pingback', + * or 'trackback'. + * + * @since 2.7.0 + * + * @param int $comment_ID The comment ID. + * @param WP_Comment $comment Comment object. + */ + do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); +} + +/** + * Clear the lastcommentmodified cached value when a comment status is changed. + * + * Deletes the lastcommentmodified cache key when a comment enters or leaves + * 'approved' status. + * + * @since 4.7.0 + * @access private + * + * @param string $new_status The new comment status. + * @param string $old_status The old comment status. + */ +function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) { + if ( 'approved' === $new_status || 'approved' === $old_status ) { + foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { + wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' ); + } + } +} + +/** + * Get current commenter's name, email, and URL. + * + * Expects cookies content to already be sanitized. User of this function might + * wish to recheck the returned array for validity. + * + * @see sanitize_comment_cookies() Use to sanitize cookies + * + * @since 2.0.4 + * + * @return array Comment author, email, url respectively. + */ +function wp_get_current_commenter() { + // Cookies should already be sanitized. + + $comment_author = ''; + if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) + $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; + + $comment_author_email = ''; + if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) + $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; + + $comment_author_url = ''; + if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) + $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; + + /** + * Filters the current commenter's name, email, and URL. + * + * @since 3.1.0 + * + * @param array $comment_author_data { + * An array of current commenter variables. + * + * @type string $comment_author The name of the author of the comment. Default empty. + * @type string $comment_author_email The email address of the `$comment_author`. Default empty. + * @type string $comment_author_url The URL address of the `$comment_author`. Default empty. + * } + */ + return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') ); +} + +/** + * Inserts a comment into the database. + * + * @since 2.0.0 + * @since 4.4.0 Introduced `$comment_meta` argument. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $commentdata { + * Array of arguments for inserting a new comment. + * + * @type string $comment_agent The HTTP user agent of the `$comment_author` when + * the comment was submitted. Default empty. + * @type int|string $comment_approved Whether the comment has been approved. Default 1. + * @type string $comment_author The name of the author of the comment. Default empty. + * @type string $comment_author_email The email address of the `$comment_author`. Default empty. + * @type string $comment_author_IP The IP address of the `$comment_author`. Default empty. + * @type string $comment_author_url The URL address of the `$comment_author`. Default empty. + * @type string $comment_content The content of the comment. Default empty. + * @type string $comment_date The date the comment was submitted. To set the date + * manually, `$comment_date_gmt` must also be specified. + * Default is the current time. + * @type string $comment_date_gmt The date the comment was submitted in the GMT timezone. + * Default is `$comment_date` in the site's GMT timezone. + * @type int $comment_karma The karma of the comment. Default 0. + * @type int $comment_parent ID of this comment's parent, if any. Default 0. + * @type int $comment_post_ID ID of the post that relates to the comment, if any. + * Default 0. + * @type string $comment_type Comment type. Default empty. + * @type array $comment_meta Optional. Array of key/value pairs to be stored in commentmeta for the + * new comment. + * @type int $user_id ID of the user who submitted the comment. Default 0. + * } + * @return int|false The new comment's ID on success, false on failure. + */ +function wp_insert_comment( $commentdata ) { + global $wpdb; + $data = wp_unslash( $commentdata ); + + $comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author']; + $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email']; + $comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url']; + $comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP']; + + $comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date']; + $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt']; + + $comment_post_ID = ! isset( $data['comment_post_ID'] ) ? 0 : $data['comment_post_ID']; + $comment_content = ! isset( $data['comment_content'] ) ? '' : $data['comment_content']; + $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma']; + $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved']; + $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent']; + $comment_type = ! isset( $data['comment_type'] ) ? '' : $data['comment_type']; + $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent']; + + $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id']; + + $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' ); + if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) { + return false; + } + + $id = (int) $wpdb->insert_id; + + if ( $comment_approved == 1 ) { + wp_update_comment_count( $comment_post_ID ); + + foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { + wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' ); + } + } + + clean_comment_cache( $id ); + + $comment = get_comment( $id ); + + // If metadata is provided, store it. + if ( isset( $commentdata['comment_meta'] ) && is_array( $commentdata['comment_meta'] ) ) { + foreach ( $commentdata['comment_meta'] as $meta_key => $meta_value ) { + add_comment_meta( $comment->comment_ID, $meta_key, $meta_value, true ); + } + } + + /** + * Fires immediately after a comment is inserted into the database. + * + * @since 2.8.0 + * + * @param int $id The comment ID. + * @param WP_Comment $comment Comment object. + */ + do_action( 'wp_insert_comment', $id, $comment ); + + return $id; +} + +/** + * Filters and sanitizes comment data. + * + * Sets the comment data 'filtered' field to true when finished. This can be + * checked as to whether the comment should be filtered and to keep from + * filtering the same comment more than once. + * + * @since 2.0.0 + * + * @param array $commentdata Contains information on the comment. + * @return array Parsed comment information. + */ +function wp_filter_comment($commentdata) { + if ( isset( $commentdata['user_ID'] ) ) { + /** + * Filters the comment author's user id before it is set. + * + * The first time this filter is evaluated, 'user_ID' is checked + * (for back-compat), followed by the standard 'user_id' value. + * + * @since 1.5.0 + * + * @param int $user_ID The comment author's user ID. + */ + $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] ); + } elseif ( isset( $commentdata['user_id'] ) ) { + /** This filter is documented in wp-includes/comment.php */ + $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] ); + } + + /** + * Filters the comment author's browser user agent before it is set. + * + * @since 1.5.0 + * + * @param string $comment_agent The comment author's browser user agent. + */ + $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); + /** This filter is documented in wp-includes/comment.php */ + $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); + /** + * Filters the comment content before it is set. + * + * @since 1.5.0 + * + * @param string $comment_content The comment content. + */ + $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] ); + /** + * Filters the comment author's IP address before it is set. + * + * @since 1.5.0 + * + * @param string $comment_author_ip The comment author's IP address. + */ + $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] ); + /** This filter is documented in wp-includes/comment.php */ + $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] ); + /** This filter is documented in wp-includes/comment.php */ + $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] ); + $commentdata['filtered'] = true; + return $commentdata; +} + +/** + * Whether a comment should be blocked because of comment flood. + * + * @since 2.1.0 + * + * @param bool $block Whether plugin has already blocked comment. + * @param int $time_lastcomment Timestamp for last comment. + * @param int $time_newcomment Timestamp for new comment. + * @return bool Whether comment should be blocked. + */ +function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { + if ( $block ) // a plugin has already blocked... we'll let that decision stand + return $block; + if ( ($time_newcomment - $time_lastcomment) < 15 ) + return true; + return false; +} + +/** + * Adds a new comment to the database. + * + * Filters new comment to ensure that the fields are sanitized and valid before + * inserting comment into database. Calls {@see 'comment_post'} action with comment ID + * and whether comment is approved by WordPress. Also has {@see 'preprocess_comment'} + * filter for processing the comment data before the function handles it. + * + * We use `REMOTE_ADDR` here directly. If you are behind a proxy, you should ensure + * that it is properly set, such as in wp-config.php, for your environment. + * + * See {@link https://core.trac.wordpress.org/ticket/9235} + * + * @since 1.5.0 + * @since 4.3.0 'comment_agent' and 'comment_author_IP' can be set via `$commentdata`. + * @since 4.7.0 The `$avoid_die` parameter was added, allowing the function to + * return a WP_Error object instead of dying. + * + * @see wp_insert_comment() + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $commentdata { + * Comment data. + * + * @type string $comment_author The name of the comment author. + * @type string $comment_author_email The comment author email address. + * @type string $comment_author_url The comment author URL. + * @type string $comment_content The content of the comment. + * @type string $comment_date The date the comment was submitted. Default is the current time. + * @type string $comment_date_gmt The date the comment was submitted in the GMT timezone. + * Default is `$comment_date` in the GMT timezone. + * @type int $comment_parent The ID of this comment's parent, if any. Default 0. + * @type int $comment_post_ID The ID of the post that relates to the comment. + * @type int $user_id The ID of the user who submitted the comment. Default 0. + * @type int $user_ID Kept for backward-compatibility. Use `$user_id` instead. + * @type string $comment_agent Comment author user agent. Default is the value of 'HTTP_USER_AGENT' + * in the `$_SERVER` superglobal sent in the original request. + * @type string $comment_author_IP Comment author IP address in IPv4 format. Default is the value of + * 'REMOTE_ADDR' in the `$_SERVER` superglobal sent in the original request. + * } + * @param bool $avoid_die Should errors be returned as WP_Error objects instead of + * executing wp_die()? Default false. + * @return int|false|WP_Error The ID of the comment on success, false or WP_Error on failure. + */ +function wp_new_comment( $commentdata, $avoid_die = false ) { + global $wpdb; + + if ( isset( $commentdata['user_ID'] ) ) { + $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; + } + + $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0; + + /** + * Filters a comment's data before it is sanitized and inserted into the database. + * + * @since 1.5.0 + * + * @param array $commentdata Comment data. + */ + $commentdata = apply_filters( 'preprocess_comment', $commentdata ); + + $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; + if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) { + $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; + } elseif ( isset( $commentdata['user_id'] ) ) { + $commentdata['user_id'] = (int) $commentdata['user_id']; + } + + $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; + $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; + $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; + + if ( ! isset( $commentdata['comment_author_IP'] ) ) { + $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; + } + $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] ); + + if ( ! isset( $commentdata['comment_agent'] ) ) { + $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: ''; + } + $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 ); + + if ( empty( $commentdata['comment_date'] ) ) { + $commentdata['comment_date'] = current_time('mysql'); + } + + if ( empty( $commentdata['comment_date_gmt'] ) ) { + $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 ); + } + + $commentdata = wp_filter_comment($commentdata); + + $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die ); + if ( is_wp_error( $commentdata['comment_approved'] ) ) { + return $commentdata['comment_approved']; + } + + $comment_ID = wp_insert_comment($commentdata); + if ( ! $comment_ID ) { + $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' ); + + foreach ( $fields as $field ) { + if ( isset( $commentdata[ $field ] ) ) { + $commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] ); + } + } + + $commentdata = wp_filter_comment( $commentdata ); + + $commentdata['comment_approved'] = wp_allow_comment( $commentdata, $avoid_die ); + if ( is_wp_error( $commentdata['comment_approved'] ) ) { + return $commentdata['comment_approved']; + } + + $comment_ID = wp_insert_comment( $commentdata ); + if ( ! $comment_ID ) { + return false; + } + } + + /** + * Fires immediately after a comment is inserted into the database. + * + * @since 1.2.0 + * @since 4.5.0 The `$commentdata` parameter was added. + * + * @param int $comment_ID The comment ID. + * @param int|string $comment_approved 1 if the comment is approved, 0 if not, 'spam' if spam. + * @param array $commentdata Comment data. + */ + do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'], $commentdata ); + + return $comment_ID; +} + +/** + * Send a comment moderation notification to the comment moderator. + * + * @since 4.4.0 + * + * @param int $comment_ID ID of the comment. + * @return bool True on success, false on failure. + */ +function wp_new_comment_notify_moderator( $comment_ID ) { + $comment = get_comment( $comment_ID ); + + // Only send notifications for pending comments. + $maybe_notify = ( '0' == $comment->comment_approved ); + + /** This filter is documented in wp-includes/comment.php */ + $maybe_notify = apply_filters( 'notify_moderator', $maybe_notify, $comment_ID ); + + if ( ! $maybe_notify ) { + return false; + } + + return wp_notify_moderator( $comment_ID ); +} + +/** + * Send a notification of a new comment to the post author. + * + * @since 4.4.0 + * + * Uses the {@see 'notify_post_author'} filter to determine whether the post author + * should be notified when a new comment is added, overriding site setting. + * + * @param int $comment_ID Comment ID. + * @return bool True on success, false on failure. + */ +function wp_new_comment_notify_postauthor( $comment_ID ) { + $comment = get_comment( $comment_ID ); + + $maybe_notify = get_option( 'comments_notify' ); + + /** + * Filters whether to send the post author new comment notification emails, + * overriding the site setting. + * + * @since 4.4.0 + * + * @param bool $maybe_notify Whether to notify the post author about the new comment. + * @param int $comment_ID The ID of the comment for the notification. + */ + $maybe_notify = apply_filters( 'notify_post_author', $maybe_notify, $comment_ID ); + + /* + * wp_notify_postauthor() checks if notifying the author of their own comment. + * By default, it won't, but filters can override this. + */ + if ( ! $maybe_notify ) { + return false; + } + + // Only send notifications for approved comments. + if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) { + return false; + } + + return wp_notify_postauthor( $comment_ID ); +} + +/** + * Sets the status of a comment. + * + * The {@see 'wp_set_comment_status'} action is called after the comment is handled. + * If the comment status is not in the list, then false is returned. + * + * @since 1.0.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. + * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'. + * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false. + * @return bool|WP_Error True on success, false or WP_Error on failure. + */ +function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { + global $wpdb; + + switch ( $comment_status ) { + case 'hold': + case '0': + $status = '0'; + break; + case 'approve': + case '1': + $status = '1'; + add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' ); + break; + case 'spam': + $status = 'spam'; + break; + case 'trash': + $status = 'trash'; + break; + default: + return false; + } + + $comment_old = clone get_comment($comment_id); + + if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) { + if ( $wp_error ) + return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); + else + return false; + } + + clean_comment_cache( $comment_old->comment_ID ); + + $comment = get_comment( $comment_old->comment_ID ); + + /** + * Fires immediately before transitioning a comment's status from one to another + * in the database. + * + * @since 1.5.0 + * + * @param int $comment_id Comment ID. + * @param string|bool $comment_status Current comment status. Possible values include + * 'hold', 'approve', 'spam', 'trash', or false. + */ + do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status ); + + wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); + + wp_update_comment_count($comment->comment_post_ID); + + return true; +} + +/** + * Updates an existing comment in the database. + * + * Filters the comment and makes sure certain fields are valid before updating. + * + * @since 2.0.0 + * @since 4.9.0 Add updating comment meta during comment update. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $commentarr Contains information on the comment. + * @return int Comment was updated if value is 1, or was not updated if value is 0. + */ +function wp_update_comment($commentarr) { + global $wpdb; + + // First, get all of the original fields + $comment = get_comment($commentarr['comment_ID'], ARRAY_A); + if ( empty( $comment ) ) { + return 0; + } + + // Make sure that the comment post ID is valid (if specified). + if ( ! empty( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) { + return 0; + } + + // Escape data pulled from DB. + $comment = wp_slash($comment); + + $old_status = $comment['comment_approved']; + + // Merge old and new fields with new fields overwriting old ones. + $commentarr = array_merge($comment, $commentarr); + + $commentarr = wp_filter_comment( $commentarr ); + + // Now extract the merged array. + $data = wp_unslash( $commentarr ); + + /** + * Filters the comment content before it is updated in the database. + * + * @since 1.5.0 + * + * @param string $comment_content The comment data. + */ + $data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] ); + + $data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] ); + + if ( ! isset( $data['comment_approved'] ) ) { + $data['comment_approved'] = 1; + } elseif ( 'hold' == $data['comment_approved'] ) { + $data['comment_approved'] = 0; + } elseif ( 'approve' == $data['comment_approved'] ) { + $data['comment_approved'] = 1; + } + + $comment_ID = $data['comment_ID']; + $comment_post_ID = $data['comment_post_ID']; + + /** + * Filters the comment data immediately before it is updated in the database. + * + * Note: data being passed to the filter is already unslashed. + * + * @since 4.7.0 + * + * @param array $data The new, processed comment data. + * @param array $comment The old, unslashed comment data. + * @param array $commentarr The new, raw comment data. + */ + $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr ); + + $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' ); + $data = wp_array_slice_assoc( $data, $keys ); + + $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); + + // If metadata is provided, store it. + if ( isset( $commentarr['comment_meta'] ) && is_array( $commentarr['comment_meta'] ) ) { + foreach ( $commentarr['comment_meta'] as $meta_key => $meta_value ) { + update_comment_meta( $comment_ID, $meta_key, $meta_value ); + } + } + + clean_comment_cache( $comment_ID ); + wp_update_comment_count( $comment_post_ID ); + /** + * Fires immediately after a comment is updated in the database. + * + * The hook also fires immediately before comment status transition hooks are fired. + * + * @since 1.2.0 + * @since 4.6.0 Added the `$data` parameter. + * + * @param int $comment_ID The comment ID. + * @param array $data Comment data. + */ + do_action( 'edit_comment', $comment_ID, $data ); + $comment = get_comment($comment_ID); + wp_transition_comment_status($comment->comment_approved, $old_status, $comment); + return $rval; +} + +/** + * Whether to defer comment counting. + * + * When setting $defer to true, all post comment counts will not be updated + * until $defer is set to false. When $defer is set to false, then all + * previously deferred updated post comment counts will then be automatically + * updated without having to call wp_update_comment_count() after. + * + * @since 2.5.0 + * @staticvar bool $_defer + * + * @param bool $defer + * @return bool + */ +function wp_defer_comment_counting($defer=null) { + static $_defer = false; + + if ( is_bool($defer) ) { + $_defer = $defer; + // flush any deferred counts + if ( !$defer ) + wp_update_comment_count( null, true ); + } + + return $_defer; +} + +/** + * Updates the comment count for post(s). + * + * When $do_deferred is false (is by default) and the comments have been set to + * be deferred, the post_id will be added to a queue, which will be updated at a + * later date and only updated once per post ID. + * + * If the comments have not be set up to be deferred, then the post will be + * updated. When $do_deferred is set to true, then all previous deferred post + * IDs will be updated along with the current $post_id. + * + * @since 2.1.0 + * @see wp_update_comment_count_now() For what could cause a false return value + * + * @staticvar array $_deferred + * + * @param int|null $post_id Post ID. + * @param bool $do_deferred Optional. Whether to process previously deferred + * post comment counts. Default false. + * @return bool|void True on success, false on failure or if post with ID does + * not exist. + */ +function wp_update_comment_count($post_id, $do_deferred=false) { + static $_deferred = array(); + + if ( empty( $post_id ) && ! $do_deferred ) { + return false; + } + + if ( $do_deferred ) { + $_deferred = array_unique($_deferred); + foreach ( $_deferred as $i => $_post_id ) { + wp_update_comment_count_now($_post_id); + unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ + } + } + + if ( wp_defer_comment_counting() ) { + $_deferred[] = $post_id; + return true; + } + elseif ( $post_id ) { + return wp_update_comment_count_now($post_id); + } + +} + +/** + * Updates the comment count for the post. + * + * @since 2.5.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $post_id Post ID + * @return bool True on success, false on '0' $post_id or if post with ID does not exist. + */ +function wp_update_comment_count_now($post_id) { + global $wpdb; + $post_id = (int) $post_id; + if ( !$post_id ) + return false; + + wp_cache_delete( 'comments-0', 'counts' ); + wp_cache_delete( "comments-{$post_id}", 'counts' ); + + if ( !$post = get_post($post_id) ) + return false; + + $old = (int) $post->comment_count; + + /** + * Filters a post's comment count before it is updated in the database. + * + * @since 4.5.0 + * + * @param int $new The new comment count. Default null. + * @param int $old The old comment count. + * @param int $post_id Post ID. + */ + $new = apply_filters( 'pre_wp_update_comment_count_now', null, $old, $post_id ); + + if ( is_null( $new ) ) { + $new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id ) ); + } else { + $new = (int) $new; + } + + $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); + + clean_post_cache( $post ); + + /** + * Fires immediately after a post's comment count is updated in the database. + * + * @since 2.3.0 + * + * @param int $post_id Post ID. + * @param int $new The new comment count. + * @param int $old The old comment count. + */ + do_action( 'wp_update_comment_count', $post_id, $new, $old ); + /** This action is documented in wp-includes/post.php */ + do_action( 'edit_post', $post_id, $post ); + + return true; +} + +// +// Ping and trackback functions. +// + +/** + * Finds a pingback server URI based on the given URL. + * + * Checks the HTML for the rel="pingback" link and x-pingback headers. It does + * a check for the x-pingback headers first and returns that, if available. The + * check for the rel="pingback" has more overhead than just the header. + * + * @since 1.5.0 + * + * @param string $url URL to ping. + * @param int $deprecated Not Used. + * @return false|string False on failure, string containing URI on success. + */ +function discover_pingback_server_uri( $url, $deprecated = '' ) { + if ( !empty( $deprecated ) ) + _deprecated_argument( __FUNCTION__, '2.7.0' ); + + $pingback_str_dquote = 'rel="pingback"'; + $pingback_str_squote = 'rel=\'pingback\''; + + /** @todo Should use Filter Extension or custom preg_match instead. */ + $parsed_url = parse_url($url); + + if ( ! isset( $parsed_url['host'] ) ) // Not a URL. This should never happen. + return false; + + //Do not search for a pingback server on our own uploads + $uploads_dir = wp_get_upload_dir(); + if ( 0 === strpos($url, $uploads_dir['baseurl']) ) + return false; + + $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); + + if ( is_wp_error( $response ) ) + return false; + + if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) + return wp_remote_retrieve_header( $response, 'x-pingback' ); + + // Not an (x)html, sgml, or xml page, no use going further. + if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) + return false; + + // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) + $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); + + if ( is_wp_error( $response ) ) + return false; + + $contents = wp_remote_retrieve_body( $response ); + + $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); + $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); + if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) { + $quote = ($pingback_link_offset_dquote) ? '"' : '\''; + $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; + $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset); + $pingback_href_start = $pingback_href_pos+6; + $pingback_href_end = @strpos($contents, $quote, $pingback_href_start); + $pingback_server_url_len = $pingback_href_end - $pingback_href_start; + $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len); + + // We may find rel="pingback" but an incomplete pingback URL + if ( $pingback_server_url_len > 0 ) { // We got it! + return $pingback_server_url; + } + } + + return false; +} + +/** + * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. + * + * @since 2.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + */ +function do_all_pings() { + global $wpdb; + + // Do pingbacks + while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { + delete_metadata_by_mid( 'post', $ping->meta_id ); + pingback( $ping->post_content, $ping->ID ); + } + + // Do Enclosures + while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { + delete_metadata_by_mid( 'post', $enclosure->meta_id ); + do_enclose( $enclosure->post_content, $enclosure->ID ); + } + + // Do Trackbacks + $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); + if ( is_array($trackbacks) ) + foreach ( $trackbacks as $trackback ) + do_trackbacks($trackback); + + //Do Update Services/Generic Pings + generic_ping(); +} + +/** + * Perform trackbacks. + * + * @since 1.5.0 + * @since 4.7.0 $post_id can be a WP_Post object. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int|WP_Post $post_id Post object or ID to do trackbacks on. + */ +function do_trackbacks( $post_id ) { + global $wpdb; + $post = get_post( $post_id ); + if ( ! $post ) { + return false; + } + + $to_ping = get_to_ping( $post ); + $pinged = get_pung( $post ); + if ( empty( $to_ping ) ) { + $wpdb->update($wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) ); + return; + } + + if ( empty($post->post_excerpt) ) { + /** This filter is documented in wp-includes/post-template.php */ + $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); + } else { + /** This filter is documented in wp-includes/post-template.php */ + $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); + } + + $excerpt = str_replace(']]>', ']]>', $excerpt); + $excerpt = wp_html_excerpt($excerpt, 252, '…'); + + /** This filter is documented in wp-includes/post-template.php */ + $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); + $post_title = strip_tags($post_title); + + if ( $to_ping ) { + foreach ( (array) $to_ping as $tb_ping ) { + $tb_ping = trim($tb_ping); + if ( !in_array($tb_ping, $pinged) ) { + trackback( $tb_ping, $post_title, $excerpt, $post->ID ); + $pinged[] = $tb_ping; + } else { + $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, + '')) WHERE ID = %d", $tb_ping, $post->ID ) ); + } + } + } +} + +/** + * Sends pings to all of the ping site services. + * + * @since 1.2.0 + * + * @param int $post_id Post ID. + * @return int Same as Post ID from parameter + */ +function generic_ping( $post_id = 0 ) { + $services = get_option('ping_sites'); + + $services = explode("\n", $services); + foreach ( (array) $services as $service ) { + $service = trim($service); + if ( '' != $service ) + weblog_ping($service); + } + + return $post_id; +} + +/** + * Pings back the links found in a post. + * + * @since 0.71 + * @since 4.7.0 $post_id can be a WP_Post object. + * + * @param string $content Post content to check for links. If empty will retrieve from post. + * @param int|WP_Post $post_id Post Object or ID. + */ +function pingback( $content, $post_id ) { + include_once( ABSPATH . WPINC . '/class-IXR.php' ); + include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); + + // original code by Mort (http://mort.mine.nu:8080) + $post_links = array(); + + $post = get_post( $post_id ); + if ( ! $post ) { + return; + } + + $pung = get_pung( $post ); + + if ( empty( $content ) ) { + $content = $post->post_content; + } + + // Step 1 + // Parsing the post, external links (if any) are stored in the $post_links array + $post_links_temp = wp_extract_urls( $content ); + + // Step 2. + // Walking thru the links array + // first we get rid of links pointing to sites, not to specific files + // Example: + // http://dummy-weblog.org + // http://dummy-weblog.org/ + // http://dummy-weblog.org/post.php + // We don't wanna ping first and second types, even if they have a valid + + foreach ( (array) $post_links_temp as $link_test ) : + if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself + && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. + if ( $test = @parse_url($link_test) ) { + if ( isset($test['query']) ) + $post_links[] = $link_test; + elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) + $post_links[] = $link_test; + } + endif; + endforeach; + + $post_links = array_unique( $post_links ); + /** + * Fires just before pinging back links found in a post. + * + * @since 2.0.0 + * + * @param array $post_links An array of post links to be checked (passed by reference). + * @param array $pung Whether a link has already been pinged (passed by reference). + * @param int $post_ID The post ID. + */ + do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post->ID ) ); + + foreach ( (array) $post_links as $pagelinkedto ) { + $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); + + if ( $pingback_server_url ) { + @ set_time_limit( 60 ); + // Now, the RPC call + $pagelinkedfrom = get_permalink( $post ); + + // using a timeout of 3 seconds should be enough to cover slow servers + $client = new WP_HTTP_IXR_Client($pingback_server_url); + $client->timeout = 3; + /** + * Filters the user agent sent when pinging-back a URL. + * + * @since 2.9.0 + * + * @param string $concat_useragent The user agent concatenated with ' -- WordPress/' + * and the WordPress version. + * @param string $useragent The useragent. + * @param string $pingback_server_url The server URL being linked to. + * @param string $pagelinkedto URL of page linked to. + * @param string $pagelinkedfrom URL of page linked from. + */ + $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . get_bloginfo( 'version' ), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); + // when set to true, this outputs debug messages by itself + $client->debug = false; + + if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered + add_ping( $post, $pagelinkedto ); + } + } +} + +/** + * Check whether blog is public before returning sites. + * + * @since 2.1.0 + * + * @param mixed $sites Will return if blog is public, will not return if not public. + * @return mixed Empty string if blog is not public, returns $sites, if site is public. + */ +function privacy_ping_filter($sites) { + if ( '0' != get_option('blog_public') ) + return $sites; + else + return ''; +} + +/** + * Send a Trackback. + * + * Updates database when sending trackback to prevent duplicates. + * + * @since 0.71 + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $trackback_url URL to send trackbacks. + * @param string $title Title of post. + * @param string $excerpt Excerpt of post. + * @param int $ID Post ID. + * @return int|false|void Database query from update. + */ +function trackback($trackback_url, $title, $excerpt, $ID) { + global $wpdb; + + if ( empty($trackback_url) ) + return; + + $options = array(); + $options['timeout'] = 10; + $options['body'] = array( + 'title' => $title, + 'url' => get_permalink($ID), + 'blog_name' => get_option('blogname'), + 'excerpt' => $excerpt + ); + + $response = wp_safe_remote_post( $trackback_url, $options ); + + if ( is_wp_error( $response ) ) + return; + + $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); + return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); +} + +/** + * Send a pingback. + * + * @since 1.2.0 + * + * @param string $server Host of blog to connect to. + * @param string $path Path to send the ping. + */ +function weblog_ping($server = '', $path = '') { + include_once( ABSPATH . WPINC . '/class-IXR.php' ); + include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); + + // using a timeout of 3 seconds should be enough to cover slow servers + $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); + $client->timeout = 3; + $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); + + // when set to true, this outputs debug messages by itself + $client->debug = false; + $home = trailingslashit( home_url() ); + if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping + $client->query('weblogUpdates.ping', get_option('blogname'), $home); +} + +/** + * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI + * + * @since 3.5.1 + * @see wp_http_validate_url() + * + * @param string $source_uri + * @return string + */ +function pingback_ping_source_uri( $source_uri ) { + return (string) wp_http_validate_url( $source_uri ); +} + +/** + * Default filter attached to xmlrpc_pingback_error. + * + * Returns a generic pingback error code unless the error code is 48, + * which reports that the pingback is already registered. + * + * @since 3.5.1 + * @link https://www.hixie.ch/specs/pingback/pingback#TOC3 + * + * @param IXR_Error $ixr_error + * @return IXR_Error + */ +function xmlrpc_pingback_error( $ixr_error ) { + if ( $ixr_error->code === 48 ) + return $ixr_error; + return new IXR_Error( 0, '' ); +} + +// +// Cache +// + +/** + * Removes a comment from the object cache. + * + * @since 2.3.0 + * + * @param int|array $ids Comment ID or an array of comment IDs to remove from cache. + */ +function clean_comment_cache($ids) { + foreach ( (array) $ids as $id ) { + wp_cache_delete( $id, 'comment' ); + + /** + * Fires immediately after a comment has been removed from the object cache. + * + * @since 4.5.0 + * + * @param int $id Comment ID. + */ + do_action( 'clean_comment_cache', $id ); + } + + wp_cache_set( 'last_changed', microtime(), 'comment' ); +} + +/** + * Updates the comment cache of given comments. + * + * Will add the comments in $comments to the cache. If comment ID already exists + * in the comment cache then it will not be updated. The comment is added to the + * cache using the comment group with the key using the ID of the comments. + * + * @since 2.3.0 + * @since 4.4.0 Introduced the `$update_meta_cache` parameter. + * + * @param array $comments Array of comment row objects + * @param bool $update_meta_cache Whether to update commentmeta cache. Default true. + */ +function update_comment_cache( $comments, $update_meta_cache = true ) { + foreach ( (array) $comments as $comment ) + wp_cache_add($comment->comment_ID, $comment, 'comment'); + + if ( $update_meta_cache ) { + // Avoid `wp_list_pluck()` in case `$comments` is passed by reference. + $comment_ids = array(); + foreach ( $comments as $comment ) { + $comment_ids[] = $comment->comment_ID; + } + update_meta_cache( 'comment', $comment_ids ); + } +} + +/** + * Adds any comments from the given IDs to the cache that do not already exist in cache. + * + * @since 4.4.0 + * @access private + * + * @see update_comment_cache() + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param array $comment_ids Array of comment IDs. + * @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true. + */ +function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) { + global $wpdb; + + $non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' ); + if ( !empty( $non_cached_ids ) ) { + $fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) ); + + update_comment_cache( $fresh_comments, $update_meta_cache ); + } +} + +// +// Internal +// + +/** + * Close comments on old posts on the fly, without any extra DB queries. Hooked to the_posts. + * + * @access private + * @since 2.7.0 + * + * @param WP_Post $posts Post data object. + * @param WP_Query $query Query object. + * @return array + */ +function _close_comments_for_old_posts( $posts, $query ) { + if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) + return $posts; + + /** + * Filters the list of post types to automatically close comments for. + * + * @since 3.2.0 + * + * @param array $post_types An array of registered post types. Default array with 'post'. + */ + $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); + if ( ! in_array( $posts[0]->post_type, $post_types ) ) + return $posts; + + $days_old = (int) get_option( 'close_comments_days_old' ); + if ( ! $days_old ) + return $posts; + + if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { + $posts[0]->comment_status = 'closed'; + $posts[0]->ping_status = 'closed'; + } + + return $posts; +} + +/** + * Close comments on an old post. Hooked to comments_open and pings_open. + * + * @access private + * @since 2.7.0 + * + * @param bool $open Comments open or closed + * @param int $post_id Post ID + * @return bool $open + */ +function _close_comments_for_old_post( $open, $post_id ) { + if ( ! $open ) + return $open; + + if ( !get_option('close_comments_for_old_posts') ) + return $open; + + $days_old = (int) get_option('close_comments_days_old'); + if ( !$days_old ) + return $open; + + $post = get_post($post_id); + + /** This filter is documented in wp-includes/comment.php */ + $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); + if ( ! in_array( $post->post_type, $post_types ) ) + return $open; + + // Undated drafts should not show up as comments closed. + if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { + return $open; + } + + if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) + return false; + + return $open; +} + +/** + * Handles the submission of a comment, usually posted to wp-comments-post.php via a comment form. + * + * This function expects unslashed data, as opposed to functions such as `wp_new_comment()` which + * expect slashed data. + * + * @since 4.4.0 + * + * @param array $comment_data { + * Comment data. + * + * @type string|int $comment_post_ID The ID of the post that relates to the comment. + * @type string $author The name of the comment author. + * @type string $email The comment author email address. + * @type string $url The comment author URL. + * @type string $comment The content of the comment. + * @type string|int $comment_parent The ID of this comment's parent, if any. Default 0. + * @type string $_wp_unfiltered_html_comment The nonce value for allowing unfiltered HTML. + * } + * @return WP_Comment|WP_Error A WP_Comment object on success, a WP_Error object on failure. + */ +function wp_handle_comment_submission( $comment_data ) { + + $comment_post_ID = $comment_parent = 0; + $comment_author = $comment_author_email = $comment_author_url = $comment_content = null; + + if ( isset( $comment_data['comment_post_ID'] ) ) { + $comment_post_ID = (int) $comment_data['comment_post_ID']; + } + if ( isset( $comment_data['author'] ) && is_string( $comment_data['author'] ) ) { + $comment_author = trim( strip_tags( $comment_data['author'] ) ); + } + if ( isset( $comment_data['email'] ) && is_string( $comment_data['email'] ) ) { + $comment_author_email = trim( $comment_data['email'] ); + } + if ( isset( $comment_data['url'] ) && is_string( $comment_data['url'] ) ) { + $comment_author_url = trim( $comment_data['url'] ); + } + if ( isset( $comment_data['comment'] ) && is_string( $comment_data['comment'] ) ) { + $comment_content = trim( $comment_data['comment'] ); + } + if ( isset( $comment_data['comment_parent'] ) ) { + $comment_parent = absint( $comment_data['comment_parent'] ); + } + + $post = get_post( $comment_post_ID ); + + if ( empty( $post->comment_status ) ) { + + /** + * Fires when a comment is attempted on a post that does not exist. + * + * @since 1.5.0 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'comment_id_not_found', $comment_post_ID ); + + return new WP_Error( 'comment_id_not_found' ); + + } + + // get_post_status() will get the parent status for attachments. + $status = get_post_status( $post ); + + if ( ( 'private' == $status ) && ! current_user_can( 'read_post', $comment_post_ID ) ) { + return new WP_Error( 'comment_id_not_found' ); + } + + $status_obj = get_post_status_object( $status ); + + if ( ! comments_open( $comment_post_ID ) ) { + + /** + * Fires when a comment is attempted on a post that has comments closed. + * + * @since 1.5.0 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'comment_closed', $comment_post_ID ); + + return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 ); + + } elseif ( 'trash' == $status ) { + + /** + * Fires when a comment is attempted on a trashed post. + * + * @since 2.9.0 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'comment_on_trash', $comment_post_ID ); + + return new WP_Error( 'comment_on_trash' ); + + } elseif ( ! $status_obj->public && ! $status_obj->private ) { + + /** + * Fires when a comment is attempted on a post in draft mode. + * + * @since 1.5.1 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'comment_on_draft', $comment_post_ID ); + + if ( current_user_can( 'read_post', $comment_post_ID ) ) { + return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 ); + } else { + return new WP_Error( 'comment_on_draft' ); + } + + } elseif ( post_password_required( $comment_post_ID ) ) { + + /** + * Fires when a comment is attempted on a password-protected post. + * + * @since 2.9.0 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'comment_on_password_protected', $comment_post_ID ); + + return new WP_Error( 'comment_on_password_protected' ); + + } else { + + /** + * Fires before a comment is posted. + * + * @since 2.8.0 + * + * @param int $comment_post_ID Post ID. + */ + do_action( 'pre_comment_on_post', $comment_post_ID ); + + } + + // If the user is logged in + $user = wp_get_current_user(); + if ( $user->exists() ) { + if ( empty( $user->display_name ) ) { + $user->display_name=$user->user_login; + } + $comment_author = $user->display_name; + $comment_author_email = $user->user_email; + $comment_author_url = $user->user_url; + $user_ID = $user->ID; + if ( current_user_can( 'unfiltered_html' ) ) { + if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] ) + || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID ) + ) { + kses_remove_filters(); // start with a clean slate + kses_init_filters(); // set up the filters + } + } + } else { + if ( get_option( 'comment_registration' ) ) { + return new WP_Error( 'not_logged_in', __( 'Sorry, you must be logged in to comment.' ), 403 ); + } + } + + $comment_type = ''; + + if ( get_option( 'require_name_email' ) && ! $user->exists() ) { + if ( '' == $comment_author_email || '' == $comment_author ) { + return new WP_Error( 'require_name_email', __( 'ERROR: please fill the required fields (name, email).' ), 200 ); + } elseif ( ! is_email( $comment_author_email ) ) { + return new WP_Error( 'require_valid_email', __( 'ERROR: please enter a valid email address.' ), 200 ); + } + } + + if ( '' == $comment_content ) { + return new WP_Error( 'require_valid_comment', __( 'ERROR: please type a comment.' ), 200 ); + } + + $commentdata = compact( + 'comment_post_ID', + 'comment_author', + 'comment_author_email', + 'comment_author_url', + 'comment_content', + 'comment_type', + 'comment_parent', + 'user_ID' + ); + + $check_max_lengths = wp_check_comment_data_max_lengths( $commentdata ); + if ( is_wp_error( $check_max_lengths ) ) { + return $check_max_lengths; + } + + $comment_id = wp_new_comment( wp_slash( $commentdata ), true ); + if ( is_wp_error( $comment_id ) ) { + return $comment_id; + } + + if ( ! $comment_id ) { + return new WP_Error( 'comment_save_error', __( 'ERROR: The comment could not be saved. Please try again later.' ), 500 ); + } + + return get_comment( $comment_id ); +} + +/** + * Registers the personal data exporter for comments. + * + * @since 4.9.6 + * + * @param array $exporters An array of personal data exporters. + * @return array $exporters An array of personal data exporters. + */ +function wp_register_comment_personal_data_exporter( $exporters ) { + $exporters['wordpress-comments'] = array( + 'exporter_friendly_name' => __( 'WordPress Comments' ), + 'callback' => 'wp_comments_personal_data_exporter', + ); + + return $exporters; +} + +/** + * Finds and exports personal data associated with an email address from the comments table. + * + * @since 4.9.6 + * + * @param string $email_address The comment author email address. + * @param int $page Comment page. + * @return array $return An array of personal data. + */ +function wp_comments_personal_data_exporter( $email_address, $page = 1 ) { + // Limit us to 500 comments at a time to avoid timing out. + $number = 500; + $page = (int) $page; + + $data_to_export = array(); + + $comments = get_comments( + array( + 'author_email' => $email_address, + 'number' => $number, + 'paged' => $page, + 'order_by' => 'comment_ID', + 'order' => 'ASC', + 'update_comment_meta_cache' => false, + ) + ); + + $comment_prop_to_export = array( + 'comment_author' => __( 'Comment Author' ), + 'comment_author_email' => __( 'Comment Author Email' ), + 'comment_author_url' => __( 'Comment Author URL' ), + 'comment_author_IP' => __( 'Comment Author IP' ), + 'comment_agent' => __( 'Comment Author User Agent' ), + 'comment_date' => __( 'Comment Date' ), + 'comment_content' => __( 'Comment Content' ), + 'comment_link' => __( 'Comment URL' ), + ); + + foreach ( (array) $comments as $comment ) { + $comment_data_to_export = array(); + + foreach ( $comment_prop_to_export as $key => $name ) { + $value = ''; + + switch ( $key ) { + case 'comment_author': + case 'comment_author_email': + case 'comment_author_url': + case 'comment_author_IP': + case 'comment_agent': + case 'comment_date': + $value = $comment->{$key}; + break; + + case 'comment_content': + $value = get_comment_text( $comment->comment_ID ); + break; + + case 'comment_link': + $value = get_comment_link( $comment->comment_ID ); + $value = sprintf( + '%s', + esc_url( $value ), + esc_html( $value ) + ); + break; + } + + if ( ! empty( $value ) ) { + $comment_data_to_export[] = array( + 'name' => $name, + 'value' => $value, + ); + } + } + + $data_to_export[] = array( + 'group_id' => 'comments', + 'group_label' => __( 'Comments' ), + 'item_id' => "comment-{$comment->comment_ID}", + 'data' => $comment_data_to_export, + ); + } + + $done = count( $comments ) < $number; + + return array( + 'data' => $data_to_export, + 'done' => $done, + ); +} + +/** + * Registers the personal data eraser for comments. + * + * @since 4.9.6 + * + * @param array $erasers An array of personal data erasers. + * @return array $erasers An array of personal data erasers. + */ +function wp_register_comment_personal_data_eraser( $erasers ) { + $erasers['wordpress-comments'] = array( + 'eraser_friendly_name' => __( 'WordPress Comments' ), + 'callback' => 'wp_comments_personal_data_eraser', + ); + + return $erasers; +} + +/** + * Erases personal data associated with an email address from the comments table. + * + * @since 4.9.6 + * + * @param string $email_address The comment author email address. + * @param int $page Comment page. + * @return array + */ +function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { + global $wpdb; + + if ( empty( $email_address ) ) { + return array( + 'items_removed' => false, + 'items_retained' => false, + 'messages' => array(), + 'done' => true, + ); + } + + // Limit us to 500 comments at a time to avoid timing out. + $number = 500; + $page = (int) $page; + $items_removed = false; + $items_retained = false; + + $comments = get_comments( + array( + 'author_email' => $email_address, + 'number' => $number, + 'paged' => $page, + 'order_by' => 'comment_ID', + 'order' => 'ASC', + 'include_unapproved' => true, + ) + ); + + $anon_author = __( 'Anonymous' ); + $messages = array(); + + foreach ( (array) $comments as $comment ) { + $anonymized_comment = array(); + $anonymized_comment['comment_agent'] = ''; + $anonymized_comment['comment_author'] = $anon_author; + $anonymized_comment['comment_author_email'] = wp_privacy_anonymize_data( 'email', $comment->comment_author_email ); + $anonymized_comment['comment_author_IP'] = wp_privacy_anonymize_data( 'ip', $comment->comment_author_IP ); + $anonymized_comment['comment_author_url'] = wp_privacy_anonymize_data( 'url', $comment->comment_author_url ); + $anonymized_comment['user_id'] = 0; + + $comment_id = (int) $comment->comment_ID; + + /** + * Filters whether to anonymize the comment. + * + * @since 4.9.6 + * + * @param bool|string Whether to apply the comment anonymization (bool). + * Custom prevention message (string). Default true. + * @param WP_Comment $comment WP_Comment object. + * @param array $anonymized_comment Anonymized comment data. + */ + $anon_message = apply_filters( 'wp_anonymize_comment', true, $comment, $anonymized_comment ); + + if ( true !== $anon_message ) { + if ( $anon_message && is_string( $anon_message ) ) { + $messages[] = esc_html( $anon_message ); + } else { + /* translators: %d: Comment ID */ + $messages[] = sprintf( __( 'Comment %d contains personal data but could not be anonymized.' ), $comment_id ); + } + + $items_retained = true; + + continue; + } + + $args = array( + 'comment_ID' => $comment_id, + ); + + $updated = $wpdb->update( $wpdb->comments, $anonymized_comment, $args ); + + if ( $updated ) { + $items_removed = true; + clean_comment_cache( $comment_id ); + } else { + $items_retained = true; + } + } + + $done = count( $comments ) < $number; + + return array( + 'items_removed' => $items_removed, + 'items_retained' => $items_retained, + 'messages' => $messages, + 'done' => $done, + ); +} diff --git a/backend/wp-includes/compat.php b/backend/wp-includes/compat.php new file mode 100644 index 0000000..596da97 --- /dev/null +++ b/backend/wp-includes/compat.php @@ -0,0 +1,539 @@ + 1 && $str = array_pop( $pieces ) ); + + return join( '', array_slice( $chars, $start, $length ) ); +} + +if ( ! function_exists( 'mb_strlen' ) ) : + /** + * Compat function to mimic mb_strlen(). + * + * @ignore + * @since 4.2.0 + * + * @see _mb_strlen() + * + * @param string $str The string to retrieve the character length from. + * @param string|null $encoding Optional. Character encoding to use. Default null. + * @return int String length of `$str`. + */ + function mb_strlen( $str, $encoding = null ) { + return _mb_strlen( $str, $encoding ); + } +endif; + +/** + * Internal compat function to mimic mb_strlen(). + * + * Only understands UTF-8 and 8bit. All other character sets will be treated as 8bit. + * For $encoding === UTF-8, the `$str` input is expected to be a valid UTF-8 byte + * sequence. The behavior of this function for invalid inputs is undefined. + * + * @ignore + * @since 4.2.0 + * + * @param string $str The string to retrieve the character length from. + * @param string|null $encoding Optional. Character encoding to use. Default null. + * @return int String length of `$str`. + */ +function _mb_strlen( $str, $encoding = null ) { + if ( null === $encoding ) { + $encoding = get_option( 'blog_charset' ); + } + + /* + * The solution below works only for UTF-8, so in case of a different charset + * just use built-in strlen(). + */ + if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { + return strlen( $str ); + } + + if ( _wp_can_use_pcre_u() ) { + // Use the regex unicode support to separate the UTF-8 characters into an array. + preg_match_all( '/./us', $str, $match ); + return count( $match[0] ); + } + + $regex = '/(?: + [\x00-\x7F] # single-byte sequences 0xxxxxxx + | [\xC2-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx + | \xE0[\xA0-\xBF][\x80-\xBF] # triple-byte sequences 1110xxxx 10xxxxxx * 2 + | [\xE1-\xEC][\x80-\xBF]{2} + | \xED[\x80-\x9F][\x80-\xBF] + | [\xEE-\xEF][\x80-\xBF]{2} + | \xF0[\x90-\xBF][\x80-\xBF]{2} # four-byte sequences 11110xxx 10xxxxxx * 3 + | [\xF1-\xF3][\x80-\xBF]{3} + | \xF4[\x80-\x8F][\x80-\xBF]{2} + )/x'; + + // Start at 1 instead of 0 since the first thing we do is decrement. + $count = 1; + do { + // We had some string left over from the last round, but we counted it in that last round. + $count--; + + /* + * Split by UTF-8 character, limit to 1000 characters (last array element will contain + * the rest of the string). + */ + $pieces = preg_split( $regex, $str, 1000 ); + + // Increment. + $count += count( $pieces ); + + // If there's anything left over, repeat the loop. + } while ( $str = array_pop( $pieces ) ); + + // Fencepost: preg_split() always returns one extra item in the array. + return --$count; +} + +if ( !function_exists('hash_hmac') ): +/** + * Compat function to mimic hash_hmac(). + * + * @ignore + * @since 3.2.0 + * + * @see _hash_hmac() + * + * @param string $algo Hash algorithm. Accepts 'md5' or 'sha1'. + * @param string $data Data to be hashed. + * @param string $key Secret key to use for generating the hash. + * @param bool $raw_output Optional. Whether to output raw binary data (true), + * or lowercase hexits (false). Default false. + * @return string|false The hash in output determined by `$raw_output`. False if `$algo` + * is unknown or invalid. + */ +function hash_hmac($algo, $data, $key, $raw_output = false) { + return _hash_hmac($algo, $data, $key, $raw_output); +} +endif; + +/** + * Internal compat function to mimic hash_hmac(). + * + * @ignore + * @since 3.2.0 + * + * @param string $algo Hash algorithm. Accepts 'md5' or 'sha1'. + * @param string $data Data to be hashed. + * @param string $key Secret key to use for generating the hash. + * @param bool $raw_output Optional. Whether to output raw binary data (true), + * or lowercase hexits (false). Default false. + * @return string|false The hash in output determined by `$raw_output`. False if `$algo` + * is unknown or invalid. + */ +function _hash_hmac($algo, $data, $key, $raw_output = false) { + $packs = array('md5' => 'H32', 'sha1' => 'H40'); + + if ( !isset($packs[$algo]) ) + return false; + + $pack = $packs[$algo]; + + if (strlen($key) > 64) + $key = pack($pack, $algo($key)); + + $key = str_pad($key, 64, chr(0)); + + $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64)); + $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64)); + + $hmac = $algo($opad . pack($pack, $algo($ipad . $data))); + + if ( $raw_output ) + return pack( $pack, $hmac ); + return $hmac; +} + +if ( !function_exists('json_encode') ) { + function json_encode( $string ) { + global $wp_json; + + if ( ! ( $wp_json instanceof Services_JSON ) ) { + require_once( ABSPATH . WPINC . '/class-json.php' ); + $wp_json = new Services_JSON(); + } + + return $wp_json->encodeUnsafe( $string ); + } +} + +if ( !function_exists('json_decode') ) { + /** + * @global Services_JSON $wp_json + * @param string $string + * @param bool $assoc_array + * @return object|array + */ + function json_decode( $string, $assoc_array = false ) { + global $wp_json; + + if ( ! ($wp_json instanceof Services_JSON ) ) { + require_once( ABSPATH . WPINC . '/class-json.php' ); + $wp_json = new Services_JSON(); + } + + $res = $wp_json->decode( $string ); + if ( $assoc_array ) + $res = _json_decode_object_helper( $res ); + return $res; + } + + /** + * @param object $data + * @return array + */ + function _json_decode_object_helper($data) { + if ( is_object($data) ) + $data = get_object_vars($data); + return is_array($data) ? array_map(__FUNCTION__, $data) : $data; + } +} + +if ( ! function_exists( 'hash_equals' ) ) : +/** + * Timing attack safe string comparison + * + * Compares two strings using the same time whether they're equal or not. + * + * This function was added in PHP 5.6. + * + * Note: It can leak the length of a string when arguments of differing length are supplied. + * + * @since 3.9.2 + * + * @param string $a Expected string. + * @param string $b Actual, user supplied, string. + * @return bool Whether strings are equal. + */ +function hash_equals( $a, $b ) { + $a_length = strlen( $a ); + if ( $a_length !== strlen( $b ) ) { + return false; + } + $result = 0; + + // Do not attempt to "optimize" this. + for ( $i = 0; $i < $a_length; $i++ ) { + $result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] ); + } + + return $result === 0; +} +endif; + +// JSON_PRETTY_PRINT was introduced in PHP 5.4 +// Defined here to prevent a notice when using it with wp_json_encode() +if ( ! defined( 'JSON_PRETTY_PRINT' ) ) { + define( 'JSON_PRETTY_PRINT', 128 ); +} + +if ( ! function_exists( 'json_last_error_msg' ) ) : + /** + * Retrieves the error string of the last json_encode() or json_decode() call. + * + * @since 4.4.0 + * + * @internal This is a compatibility function for PHP <5.5 + * + * @return bool|string Returns the error message on success, "No Error" if no error has occurred, + * or false on failure. + */ + function json_last_error_msg() { + // See https://core.trac.wordpress.org/ticket/27799. + if ( ! function_exists( 'json_last_error' ) ) { + return false; + } + + $last_error_code = json_last_error(); + + // Just in case JSON_ERROR_NONE is not defined. + $error_code_none = defined( 'JSON_ERROR_NONE' ) ? JSON_ERROR_NONE : 0; + + switch ( true ) { + case $last_error_code === $error_code_none: + return 'No error'; + + case defined( 'JSON_ERROR_DEPTH' ) && JSON_ERROR_DEPTH === $last_error_code: + return 'Maximum stack depth exceeded'; + + case defined( 'JSON_ERROR_STATE_MISMATCH' ) && JSON_ERROR_STATE_MISMATCH === $last_error_code: + return 'State mismatch (invalid or malformed JSON)'; + + case defined( 'JSON_ERROR_CTRL_CHAR' ) && JSON_ERROR_CTRL_CHAR === $last_error_code: + return 'Control character error, possibly incorrectly encoded'; + + case defined( 'JSON_ERROR_SYNTAX' ) && JSON_ERROR_SYNTAX === $last_error_code: + return 'Syntax error'; + + case defined( 'JSON_ERROR_UTF8' ) && JSON_ERROR_UTF8 === $last_error_code: + return 'Malformed UTF-8 characters, possibly incorrectly encoded'; + + case defined( 'JSON_ERROR_RECURSION' ) && JSON_ERROR_RECURSION === $last_error_code: + return 'Recursion detected'; + + case defined( 'JSON_ERROR_INF_OR_NAN' ) && JSON_ERROR_INF_OR_NAN === $last_error_code: + return 'Inf and NaN cannot be JSON encoded'; + + case defined( 'JSON_ERROR_UNSUPPORTED_TYPE' ) && JSON_ERROR_UNSUPPORTED_TYPE === $last_error_code: + return 'Type is not supported'; + + default: + return 'An unknown error occurred'; + } + } +endif; + +if ( ! interface_exists( 'JsonSerializable' ) ) { + define( 'WP_JSON_SERIALIZE_COMPATIBLE', true ); + /** + * JsonSerializable interface. + * + * Compatibility shim for PHP <5.4 + * + * @link https://secure.php.net/jsonserializable + * + * @since 4.4.0 + */ + interface JsonSerializable { + public function jsonSerialize(); + } +} + +// random_int was introduced in PHP 7.0 +if ( ! function_exists( 'random_int' ) ) { + require ABSPATH . WPINC . '/random_compat/random.php'; +} + +if ( ! function_exists( 'array_replace_recursive' ) ) : + /** + * PHP-agnostic version of {@link array_replace_recursive()}. + * + * The array_replace_recursive() function is a PHP 5.3 function. WordPress + * currently supports down to PHP 5.2, so this method is a workaround + * for PHP 5.2. + * + * Note: array_replace_recursive() supports infinite arguments, but for our use- + * case, we only need to support two arguments. + * + * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement. + * + * @since 4.5.3 + * + * @see https://secure.php.net/manual/en/function.array-replace-recursive.php#109390 + * + * @param array $base Array with keys needing to be replaced. + * @param array $replacements Array with the replaced keys. + * + * @return array + */ + function array_replace_recursive( $base = array(), $replacements = array() ) { + foreach ( array_slice( func_get_args(), 1 ) as $replacements ) { + $bref_stack = array( &$base ); + $head_stack = array( $replacements ); + + do { + end( $bref_stack ); + + $bref = &$bref_stack[ key( $bref_stack ) ]; + $head = array_pop( $head_stack ); + + unset( $bref_stack[ key( $bref_stack ) ] ); + + foreach ( array_keys( $head ) as $key ) { + if ( isset( $key, $bref ) && + isset( $bref[ $key ] ) && is_array( $bref[ $key ] ) && + isset( $head[ $key ] ) && is_array( $head[ $key ] ) + ) { + $bref_stack[] = &$bref[ $key ]; + $head_stack[] = $head[ $key ]; + } else { + $bref[ $key ] = $head[ $key ]; + } + } + } while ( count( $head_stack ) ); + } + + return $base; + } +endif; + +/** + * Polyfill for the SPL autoloader. In PHP 5.2 (but not 5.3 and later), SPL can + * be disabled, and PHP 7.2 raises notices if the compiler finds an __autoload() + * function declaration. Function availability is checked here, and the + * autoloader is included only if necessary. + */ +if ( ! function_exists( 'spl_autoload_register' ) ) { + require_once ABSPATH . WPINC . '/spl-autoload-compat.php'; +} + +if ( ! function_exists( 'is_countable' ) ) { + /** + * Polyfill for is_countable() function added in PHP 7.3. + * + * Verify that the content of a variable is an array or an object + * implementing the Countable interface. + * + * @since 4.9.6 + * + * @param mixed $var The value to check. + * + * @return bool True if `$var` is countable, false otherwise. + */ + function is_countable( $var ) { + return ( is_array( $var ) + || $var instanceof Countable + || $var instanceof SimpleXMLElement + || $var instanceof ResourceBundle + ); + } +} + +if ( ! function_exists( 'is_iterable' ) ) { + /** + * Polyfill for is_iterable() function added in PHP 7.1. + * + * Verify that the content of a variable is an array or an object + * implementing the Traversable interface. + * + * @since 4.9.6 + * + * @param mixed $var The value to check. + * + * @return bool True if `$var` is iterable, false otherwise. + */ + function is_iterable( $var ) { + return ( is_array( $var ) || $var instanceof Traversable ); + } +} diff --git a/backend/wp-includes/cron.php b/backend/wp-includes/cron.php new file mode 100644 index 0000000..0875904 --- /dev/null +++ b/backend/wp-includes/cron.php @@ -0,0 +1,530 @@ + $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args ); + /** + * Filters a single event before it is scheduled. + * + * @since 3.1.0 + * + * @param stdClass $event { + * An object containing an event's data. + * + * @type string $hook Action hook to execute when event is run. + * @type int $timestamp Unix timestamp (UTC) for when to run the event. + * @type string|false $schedule How often the event should recur. See `wp_get_schedules()`. + * @type array $args Arguments to pass to the hook's callback function. + * } + */ + $event = apply_filters( 'schedule_event', $event ); + + // A plugin disallowed this event + if ( ! $event ) + return false; + + $key = md5(serialize($event->args)); + + $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args ); + uksort( $crons, "strnatcasecmp" ); + _set_cron_array( $crons ); +} + +/** + * Schedule a recurring event. + * + * Schedules a hook which will be executed by the WordPress actions core on a + * specific interval, specified by you. The action will trigger when someone + * visits your WordPress site, if the scheduled time has passed. + * + * Valid values for the recurrence are hourly, daily, and twicedaily. These can + * be extended using the {@see 'cron_schedules'} filter in wp_get_schedules(). + * + * Use wp_next_scheduled() to prevent duplicates + * + * @since 2.1.0 + * + * @param int $timestamp Unix timestamp (UTC) for when to run the event. + * @param string $recurrence How often the event should recur. + * @param string $hook Action hook to execute when event is run. + * @param array $args Optional. Arguments to pass to the hook's callback function. + * @return false|void False if the event does not get scheduled. + */ +function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { + // Make sure timestamp is a positive integer + if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { + return false; + } + + $crons = _get_cron_array(); + $schedules = wp_get_schedules(); + + if ( !isset( $schedules[$recurrence] ) ) + return false; + + $event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); + /** This filter is documented in wp-includes/cron.php */ + $event = apply_filters( 'schedule_event', $event ); + + // A plugin disallowed this event + if ( ! $event ) + return false; + + $key = md5(serialize($event->args)); + + $crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval ); + uksort( $crons, "strnatcasecmp" ); + _set_cron_array( $crons ); +} + +/** + * Reschedule a recurring event. + * + * @since 2.1.0 + * + * @param int $timestamp Unix timestamp (UTC) for when to run the event. + * @param string $recurrence How often the event should recur. + * @param string $hook Action hook to execute when event is run. + * @param array $args Optional. Arguments to pass to the hook's callback function. + * @return false|void False if the event does not get rescheduled. + */ +function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) { + // Make sure timestamp is a positive integer + if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { + return false; + } + + $crons = _get_cron_array(); + $schedules = wp_get_schedules(); + $key = md5( serialize( $args ) ); + $interval = 0; + + // First we try to get it from the schedule + if ( isset( $schedules[ $recurrence ] ) ) { + $interval = $schedules[ $recurrence ]['interval']; + } + // Now we try to get it from the saved interval in case the schedule disappears + if ( 0 == $interval ) { + $interval = $crons[ $timestamp ][ $hook ][ $key ]['interval']; + } + // Now we assume something is wrong and fail to schedule + if ( 0 == $interval ) { + return false; + } + + $now = time(); + + if ( $timestamp >= $now ) { + $timestamp = $now + $interval; + } else { + $timestamp = $now + ( $interval - ( ( $now - $timestamp ) % $interval ) ); + } + + wp_schedule_event( $timestamp, $recurrence, $hook, $args ); +} + +/** + * Unschedule a previously scheduled event. + * + * The $timestamp and $hook parameters are required so that the event can be + * identified. + * + * @since 2.1.0 + * + * @param int $timestamp Unix timestamp (UTC) for when to run the event. + * @param string $hook Action hook, the execution of which will be unscheduled. + * @param array $args Arguments to pass to the hook's callback function. + * Although not passed to a callback function, these arguments are used + * to uniquely identify the scheduled event, so they should be the same + * as those used when originally scheduling the event. + * @return false|void False if the event does not get unscheduled. + */ +function wp_unschedule_event( $timestamp, $hook, $args = array() ) { + // Make sure timestamp is a positive integer + if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { + return false; + } + + $crons = _get_cron_array(); + $key = md5(serialize($args)); + unset( $crons[$timestamp][$hook][$key] ); + if ( empty($crons[$timestamp][$hook]) ) + unset( $crons[$timestamp][$hook] ); + if ( empty($crons[$timestamp]) ) + unset( $crons[$timestamp] ); + _set_cron_array( $crons ); +} + +/** + * Unschedules all events attached to the hook with the specified arguments. + * + * @since 2.1.0 + * + * @param string $hook Action hook, the execution of which will be unscheduled. + * @param array $args Optional. Arguments that were to be passed to the hook's callback function. + */ +function wp_clear_scheduled_hook( $hook, $args = array() ) { + // Backward compatibility + // Previously this function took the arguments as discrete vars rather than an array like the rest of the API + if ( !is_array($args) ) { + _deprecated_argument( __FUNCTION__, '3.0.0', __('This argument has changed to an array to match the behavior of the other cron functions.') ); + $args = array_slice( func_get_args(), 1 ); + } + + // This logic duplicates wp_next_scheduled() + // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing, + // and, wp_next_scheduled() returns the same schedule in an infinite loop. + $crons = _get_cron_array(); + if ( empty( $crons ) ) + return; + + $key = md5( serialize( $args ) ); + foreach ( $crons as $timestamp => $cron ) { + if ( isset( $cron[ $hook ][ $key ] ) ) { + wp_unschedule_event( $timestamp, $hook, $args ); + } + } +} + +/** + * Unschedules all events attached to the hook. + * + * Can be useful for plugins when deactivating to clean up the cron queue. + * + * @since 4.9.0 + * + * @param string $hook Action hook, the execution of which will be unscheduled. + */ +function wp_unschedule_hook( $hook ) { + $crons = _get_cron_array(); + + foreach( $crons as $timestamp => $args ) { + unset( $crons[ $timestamp ][ $hook ] ); + + if ( empty( $crons[ $timestamp ] ) ) { + unset( $crons[ $timestamp ] ); + } + } + + _set_cron_array( $crons ); +} + +/** + * Retrieve the next timestamp for an event. + * + * @since 2.1.0 + * + * @param string $hook Action hook to execute when event is run. + * @param array $args Optional. Arguments to pass to the hook's callback function. + * @return false|int The Unix timestamp of the next time the scheduled event will occur. + */ +function wp_next_scheduled( $hook, $args = array() ) { + $crons = _get_cron_array(); + $key = md5(serialize($args)); + if ( empty($crons) ) + return false; + foreach ( $crons as $timestamp => $cron ) { + if ( isset( $cron[$hook][$key] ) ) + return $timestamp; + } + return false; +} + +/** + * Sends a request to run cron through HTTP request that doesn't halt page loading. + * + * @since 2.1.0 + * + * @param int $gmt_time Optional. Unix timestamp (UTC). Default 0 (current time is used). + */ +function spawn_cron( $gmt_time = 0 ) { + if ( ! $gmt_time ) + $gmt_time = microtime( true ); + + if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) + return; + + /* + * Get the cron lock, which is a Unix timestamp of when the last cron was spawned + * and has not finished running. + * + * Multiple processes on multiple web servers can run this code concurrently, + * this lock attempts to make spawning as atomic as possible. + */ + $lock = get_transient('doing_cron'); + + if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) + $lock = 0; + + // don't run if another process is currently running it or more than once every 60 sec. + if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) + return; + + //sanity check + $crons = _get_cron_array(); + if ( !is_array($crons) ) + return; + + $keys = array_keys( $crons ); + if ( isset($keys[0]) && $keys[0] > $gmt_time ) + return; + + if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) { + if ( 'GET' !== $_SERVER['REQUEST_METHOD'] || defined( 'DOING_AJAX' ) || defined( 'XMLRPC_REQUEST' ) ) { + return; + } + + $doing_wp_cron = sprintf( '%.22F', $gmt_time ); + set_transient( 'doing_cron', $doing_wp_cron ); + + ob_start(); + wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); + echo ' '; + + // flush any buffers and send the headers + while ( @ob_end_flush() ); + flush(); + + WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' ); + return; + } + + // Set the cron lock with the current unix timestamp, when the cron is being spawned. + $doing_wp_cron = sprintf( '%.22F', $gmt_time ); + set_transient( 'doing_cron', $doing_wp_cron ); + + /** + * Filters the cron request arguments. + * + * @since 3.5.0 + * @since 4.5.0 The `$doing_wp_cron` parameter was added. + * + * @param array $cron_request_array { + * An array of cron request URL arguments. + * + * @type string $url The cron request URL. + * @type int $key The 22 digit GMT microtime. + * @type array $args { + * An array of cron request arguments. + * + * @type int $timeout The request timeout in seconds. Default .01 seconds. + * @type bool $blocking Whether to set blocking for the request. Default false. + * @type bool $sslverify Whether SSL should be verified for the request. Default false. + * } + * } + * @param string $doing_wp_cron The unix timestamp of the cron lock. + */ + $cron_request = apply_filters( 'cron_request', array( + 'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ), + 'key' => $doing_wp_cron, + 'args' => array( + 'timeout' => 0.01, + 'blocking' => false, + /** This filter is documented in wp-includes/class-wp-http-streams.php */ + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ) + ) + ), $doing_wp_cron ); + + wp_remote_post( $cron_request['url'], $cron_request['args'] ); +} + +/** + * Run scheduled callbacks or spawn cron for all scheduled events. + * + * @since 2.1.0 + */ +function wp_cron() { + // Prevent infinite loops caused by lack of wp-cron.php + if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) ) + return; + + if ( false === $crons = _get_cron_array() ) + return; + + $gmt_time = microtime( true ); + $keys = array_keys( $crons ); + if ( isset($keys[0]) && $keys[0] > $gmt_time ) + return; + + $schedules = wp_get_schedules(); + foreach ( $crons as $timestamp => $cronhooks ) { + if ( $timestamp > $gmt_time ) break; + foreach ( (array) $cronhooks as $hook => $args ) { + if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) + continue; + spawn_cron( $gmt_time ); + break 2; + } + } +} + +/** + * Retrieve supported event recurrence schedules. + * + * The default supported recurrences are 'hourly', 'twicedaily', and 'daily'. A plugin may + * add more by hooking into the {@see 'cron_schedules'} filter. The filter accepts an array + * of arrays. The outer array has a key that is the name of the schedule or for + * example 'weekly'. The value is an array with two keys, one is 'interval' and + * the other is 'display'. + * + * The 'interval' is a number in seconds of when the cron job should run. So for + * 'hourly', the time is 3600 or 60*60. For weekly, the value would be + * 60*60*24*7 or 604800. The value of 'interval' would then be 604800. + * + * The 'display' is the description. For the 'weekly' key, the 'display' would + * be `__( 'Once Weekly' )`. + * + * For your plugin, you will be passed an array. you can easily add your + * schedule by doing the following. + * + * // Filter parameter variable name is 'array'. + * $array['weekly'] = array( + * 'interval' => 604800, + * 'display' => __( 'Once Weekly' ) + * ); + * + * + * @since 2.1.0 + * + * @return array + */ +function wp_get_schedules() { + $schedules = array( + 'hourly' => array( 'interval' => HOUR_IN_SECONDS, 'display' => __( 'Once Hourly' ) ), + 'twicedaily' => array( 'interval' => 12 * HOUR_IN_SECONDS, 'display' => __( 'Twice Daily' ) ), + 'daily' => array( 'interval' => DAY_IN_SECONDS, 'display' => __( 'Once Daily' ) ), + ); + /** + * Filters the non-default cron schedules. + * + * @since 2.1.0 + * + * @param array $new_schedules An array of non-default cron schedules. Default empty. + */ + return array_merge( apply_filters( 'cron_schedules', array() ), $schedules ); +} + +/** + * Retrieve the recurrence schedule for an event. + * + * @see wp_get_schedules() for available schedules. + * + * @since 2.1.0 + * + * @param string $hook Action hook to identify the event. + * @param array $args Optional. Arguments passed to the event's callback function. + * @return string|false False, if no schedule. Schedule name on success. + */ +function wp_get_schedule($hook, $args = array()) { + $crons = _get_cron_array(); + $key = md5(serialize($args)); + if ( empty($crons) ) + return false; + foreach ( $crons as $timestamp => $cron ) { + if ( isset( $cron[$hook][$key] ) ) + return $cron[$hook][$key]['schedule']; + } + return false; +} + +// +// Private functions +// + +/** + * Retrieve cron info array option. + * + * @since 2.1.0 + * @access private + * + * @return false|array CRON info array. + */ +function _get_cron_array() { + $cron = get_option('cron'); + if ( ! is_array($cron) ) + return false; + + if ( !isset($cron['version']) ) + $cron = _upgrade_cron_array($cron); + + unset($cron['version']); + + return $cron; +} + +/** + * Updates the CRON option with the new CRON array. + * + * @since 2.1.0 + * @access private + * + * @param array $cron Cron info array from _get_cron_array(). + */ +function _set_cron_array($cron) { + $cron['version'] = 2; + update_option( 'cron', $cron ); +} + +/** + * Upgrade a Cron info array. + * + * This function upgrades the Cron info array to version 2. + * + * @since 2.1.0 + * @access private + * + * @param array $cron Cron info array from _get_cron_array(). + * @return array An upgraded Cron info array. + */ +function _upgrade_cron_array($cron) { + if ( isset($cron['version']) && 2 == $cron['version']) + return $cron; + + $new_cron = array(); + + foreach ( (array) $cron as $timestamp => $hooks) { + foreach ( (array) $hooks as $hook => $args ) { + $key = md5(serialize($args['args'])); + $new_cron[$timestamp][$hook][$key] = $args; + } + } + + $new_cron['version'] = 2; + update_option( 'cron', $new_cron ); + return $new_cron; +} diff --git a/backend/wp-includes/css/admin-bar-rtl.css b/backend/wp-includes/css/admin-bar-rtl.css new file mode 100644 index 0000000..84c0f4b --- /dev/null +++ b/backend/wp-includes/css/admin-bar-rtl.css @@ -0,0 +1,1141 @@ +#wpadminbar * { + height: auto; + width: auto; + margin: 0; + padding: 0; + position: static; + text-shadow: none; + text-transform: none; + letter-spacing: normal; + font-size: 13px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + border-radius: 0; + box-sizing: content-box; + transition: none; + -webkit-font-smoothing: subpixel-antialiased; /* Prevent Safari from switching to standard antialiasing on hover */ + -moz-osx-font-smoothing: auto; /* Prevent Firefox from inheriting from themes that use other values */ +} + +.rtl #wpadminbar * { + font-family: Tahoma, sans-serif; +} + +html:lang(he-il) .rtl #wpadminbar * { + font-family: Arial, sans-serif; +} + +#wpadminbar .ab-empty-item { + cursor: default; +} + +#wpadminbar .ab-empty-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #eee; +} + +#wpadminbar #wp-admin-bar-site-name a.ab-item, +#wpadminbar #wp-admin-bar-my-sites a.ab-item { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +#wpadminbar ul li:before, +#wpadminbar ul li:after { + content: normal; +} + +#wpadminbar a, +#wpadminbar a:hover, +#wpadminbar a img, +#wpadminbar a img:hover { + outline: none; + border: none; + text-decoration: none; + background: none; +} + +#wpadminbar a:focus, +#wpadminbar a:active, +#wpadminbar input[type="text"], +#wpadminbar input[type="password"], +#wpadminbar input[type="number"], +#wpadminbar input[type="search"], +#wpadminbar input[type="email"], +#wpadminbar input[type="url"], +#wpadminbar select, +#wpadminbar textarea, +#wpadminbar div { + box-shadow: none; + outline: none; +} + +#wpadminbar { + direction: rtl; + color: #ccc; + font-size: 13px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + height: 32px; + position: fixed; + top: 0; + right: 0; + width: 100%; + min-width: 600px; /* match the min-width of the body in wp-admin.css */ + z-index: 99999; + background: #23282d; +} + +#wpadminbar .ab-sub-wrapper, +#wpadminbar ul, +#wpadminbar ul li { + background: none; + clear: none; + list-style: none; + margin: 0; + padding: 0; + position: relative; + text-indent: 0; + z-index: 99999; +} + +#wpadminbar ul#wp-admin-bar-root-default>li { + margin-left: 0; +} + +#wpadminbar .quicklinks ul { + text-align: right; +} + +#wpadminbar li { + float: right; +} + +#wpadminbar .ab-empty-item { + outline: none; +} + +#wpadminbar .quicklinks .ab-top-secondary > li { + float: left; +} + +#wpadminbar .quicklinks a, +#wpadminbar .quicklinks .ab-empty-item, +#wpadminbar .shortlink-input { + height: 32px; + display: block; + padding: 0 10px; + margin: 0; +} + +#wpadminbar .quicklinks > ul > li > a { + padding: 0 7px 0 8px; +} + +#wpadminbar .menupop .ab-sub-wrapper, +#wpadminbar .shortlink-input { + margin: 0; + padding: 0; + box-shadow: 0 3px 5px rgba(0,0,0,0.2); + background: #32373c; + display: none; + position: absolute; + float: none; +} + +#wpadminbar.ie7 .menupop .ab-sub-wrapper, +#wpadminbar.ie7 .shortlink-input { + top: 32px; + right: 0; +} + +#wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + min-width: 100%; +} + +#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper { + left: 0; + right: auto; +} + +#wpadminbar .ab-submenu { + padding: 6px 0; +} + +#wpadminbar .selected .shortlink-input { + display: block; +} + +#wpadminbar .quicklinks .menupop ul li { + float: none; +} + +#wpadminbar .quicklinks .menupop ul li a strong { + font-weight: 600; +} + +#wpadminbar .quicklinks .menupop ul li .ab-item, +#wpadminbar .quicklinks .menupop ul li a strong, +#wpadminbar .quicklinks .menupop.hover ul li .ab-item, +#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item, +#wpadminbar .shortlink-input { + line-height: 26px; + height: 26px; + white-space: nowrap; + min-width: 140px; +} + +#wpadminbar .shortlink-input { + width: 200px; +} + +#wpadminbar.nojs li:hover > .ab-sub-wrapper, +#wpadminbar li.hover > .ab-sub-wrapper { + display: block; +} + +#wpadminbar .menupop li:hover > .ab-sub-wrapper, +#wpadminbar .menupop li.hover > .ab-sub-wrapper { + margin-right: 100%; + margin-top: -32px; +} + +#wpadminbar .ab-top-secondary .menupop li:hover > .ab-sub-wrapper, +#wpadminbar .ab-top-secondary .menupop li.hover > .ab-sub-wrapper { + margin-right: 0; + right: inherit; + left: 100%; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar .ab-top-menu > li.hover > .ab-item { + background: #32373c; + color: #00b9eb; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #00b9eb; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon, +#wpadminbar .ab-icon, +#wpadminbar .ab-item:before { + position: relative; + float: right; + font: normal 20px/1 dashicons; + speak: none; + padding: 4px 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + background-image: none !important; + margin-left: 6px; +} + +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar #adminbarsearch:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); +} + +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar #adminbarsearch:before { + position: relative; + transition: all .1s ease-in-out; +} + +#wpadminbar .ab-label { + display: inline-block; + height: 32px; +} + +#wpadminbar .ab-submenu .ab-item { + color: #b4b9be; + color: rgba(240,245,250,0.7); +} + +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop ul li a strong, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #b4b9be; + color: rgba(240,245,250,0.7); +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover, +#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #00b9eb; +} + +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #b4b9be; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #00b9eb; +} + +#wpadminbar .menupop .menupop > .ab-item:before, +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + position: absolute; + font: normal 17px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#wpadminbar .menupop .menupop > .ab-item { + display: block; + padding-left: 2em; +} + +#wpadminbar .menupop .menupop > .ab-item:before { + top: 1px; + left: 4px; + content: "\f141"; + color: inherit; +} + +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item { + padding-right: 2em; + padding-left: 1em; +} + +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + top: 1px; + right: 6px; + content: "\f139"; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary { + display: block; + position: relative; + left: auto; + margin: 0; + box-shadow: none; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #464b50; +} + +#wpadminbar .quicklinks .menupop .ab-sub-secondary > li > a:hover, +#wpadminbar .quicklinks .menupop .ab-sub-secondary > li .ab-item:focus a { + color: #00b9eb; +} + +#wpadminbar .quicklinks a span#ab-updates { + background: #eee; + color: #32373c; + display: inline; + padding: 2px 5px; + font-size: 10px; + font-weight: 600; + border-radius: 10px; +} + +#wpadminbar .quicklinks a:hover span#ab-updates { + background: #fff; + color: #000; +} + +#wpadminbar .ab-top-secondary { + float: left; +} + +#wpadminbar ul li:last-child, +#wpadminbar ul li:last-child .ab-item { + box-shadow: none; +} + +/** + * My Account + */ +#wp-admin-bar-my-account > ul { + min-width: 198px; +} + +#wp-admin-bar-my-account > .ab-item:before { + content: "\f110"; + top: 2px; + float: left; + margin-right: 6px; + margin-left: 0; +} + +#wp-admin-bar-my-account.with-avatar > .ab-item:before { + display: none; + content: none; +} + +#wp-admin-bar-my-account.with-avatar > ul { + min-width: 270px; +} + +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar .ab-item { + white-space: nowrap; +} + +#wpadminbar #wp-admin-bar-user-actions > li { + margin-right: 16px; + margin-left: 16px; +} + +#wpadminbar #wp-admin-bar-user-actions.ab-submenu { + padding: 6px 0 12px; +} + +#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li { + margin-right: 88px; +} + +#wpadminbar #wp-admin-bar-user-info { + margin-top: 6px; + margin-bottom: 15px; + height: auto; + background: none; +} + +#wp-admin-bar-user-info .avatar { + position: absolute; + right: -72px; + top: 4px; + width: 64px; + height: 64px; +} + +#wpadminbar #wp-admin-bar-user-info a { + background: none; + height: auto; +} + +#wpadminbar #wp-admin-bar-user-info span { + background: none; + padding: 0; + height: 18px; +} + +#wpadminbar #wp-admin-bar-user-info .display-name, +#wpadminbar #wp-admin-bar-user-info .username { + display: block; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #a0a5aa; + font-size: 11px; +} + +#wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-empty-item img, +#wpadminbar #wp-admin-bar-my-account.with-avatar > a img { + width: auto; + height: 16px; + padding: 0; + border: 1px solid #82878c; + background: #eee; + line-height: 24px; + vertical-align: middle; + margin: -4px 6px 0 0; + float: none; + display: inline; +} + +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > .ab-empty-item img, +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > a img { + width: auto; +} + +/** + * WP Logo + */ +#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon { + width: 15px; + height: 20px; + margin-left: 0; + padding: 6px 0 5px; +} + +#wpadminbar #wp-admin-bar-wp-logo > .ab-item { + padding: 0 7px; +} + +#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { + content: "\f120"; + top: 2px; +} + +/* + * My Sites & Site Title + */ +#wpadminbar .quicklinks li .blavatar { + float: right; + font: normal 16px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + color: #eee; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar { + color: #00b9eb; +} + +#wpadminbar .quicklinks li .blavatar:before { + content: "\f120"; + height: 16px; + width: 16px; + display: inline-block; + margin: 6px -2px 0 8px; +} + +#wpadminbar #wp-admin-bar-appearance { + margin-top: -12px; +} + +#wpadminbar #wp-admin-bar-my-sites > .ab-item:before, +#wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f541"; + top: 2px; +} + +#wpadminbar #wp-admin-bar-customize > .ab-item:before { + content: "\f540"; + top: 2px; +} + + +#wpadminbar #wp-admin-bar-edit > .ab-item:before { + content: "\f464"; + top: 2px; +} + +#wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f226"; +} + +.wp-admin #wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f102"; +} + + + +/** + * Comments + */ +#wpadminbar #wp-admin-bar-comments .ab-icon { + margin-left: 6px; +} + +#wpadminbar #wp-admin-bar-comments .ab-icon:before { + content: "\f101"; + top: 3px; +} + +#wpadminbar #wp-admin-bar-comments .count-0 { + opacity: .5; +} + +/** + * New Content + */ +#wpadminbar #wp-admin-bar-new-content .ab-icon:before { + content: "\f132"; + top: 4px; +} + +/** + * Updates + */ +#wpadminbar #wp-admin-bar-updates .ab-icon:before { + content: "\f463"; + top: 2px; +} + +/** + * Search + */ +#wpadminbar.ie8 #wp-admin-bar-search { + display: block; + min-width: 32px; +} +#wpadminbar #wp-admin-bar-search .ab-item { + padding: 0; + background: transparent; +} + +#wpadminbar #adminbarsearch { + position: relative; + height: 32px; + padding: 0 2px; + z-index: 1; +} + +#wpadminbar #adminbarsearch:before { + position: absolute; + top: 6px; + right: 5px; + z-index: 20; + font: normal 20px/1 dashicons !important; + content: "\f179"; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* The admin bar search field needs to reset many styles that might be inherited from the active Theme CSS. See ticket #40313. */ +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + display: inline-block; + float: none; + position: relative; + z-index: 30; + font-size: 13px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 24px; + text-indent: 0; + height: 24px; + width: 24px; + max-width: none; + padding: 0 24px 0 3px; + margin: 0; + color: #ccc; + background-color: rgba( 255, 255, 255, 0 ); + border: none; + outline: none; + cursor: pointer; + box-shadow: none; + box-sizing: border-box; + transition-duration: 400ms; + transition-property: width, background; + transition-timing-function: ease; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + z-index: 10; + color: #000; + width: 200px; + background-color: rgba( 255, 255, 255, 0.9 ); + cursor: text; + border: 0; +} + +#wpadminbar.ie7 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + margin-top: 3px; + width: 120px; +} + +#wpadminbar.ie8 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + /* IE8 z-index bug with transparent / empty elements - fill in with an encoded transparent GIF */ + background: transparent 100% 0 repeat scroll url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBR‌​AA7"); +} + +/* IE8 doesn't redraw the pseudo elements unless you make a change to the content */ +#wpadminbar.ie8 #adminbarsearch.adminbar-focused:before { + content: "\f179 "; /* extra space */ +} + +#wpadminbar.ie8 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + background: #fff; + z-index: -1; +} + +#wpadminbar #adminbarsearch .adminbar-button { + display: none; +} + +/** + * Customize support classes + */ +.no-customize-support .hide-if-no-customize, +.customize-support .hide-if-customize, +.no-customize-support #wpadminbar .hide-if-no-customize, +.no-customize-support.wp-core-ui .hide-if-no-customize, +.no-customize-support .wp-core-ui .hide-if-no-customize, +.customize-support #wpadminbar .hide-if-customize, +.customize-support.wp-core-ui .hide-if-customize, +.customize-support .wp-core-ui .hide-if-customize { + display: none; +} + +/* Skip link */ +#wpadminbar .screen-reader-text, +#wpadminbar .screen-reader-text span { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +#wpadminbar .screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +#wpadminbar .screen-reader-shortcut:focus { + right: 6px; + top: 7px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + text-decoration: none; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); +} + +/** + * IE 6-targeted rules + */ +* html #wpadminbar { + overflow: hidden; + position: absolute; +} + +* html #wpadminbar .quicklinks ul li a { + float: right; +} + +* html #wpadminbar .menupop a span { + background-image: none; +} + +/* No @font-face support */ +.no-font-face #wpadminbar ul.ab-top-menu > li > a.ab-item { + display: block; + width: 45px; + text-align: center; + overflow: hidden; + margin: 0 3px; +} + +.no-font-face #wpadminbar #wp-admin-bar-my-sites > .ab-item, +.no-font-face #wpadminbar #wp-admin-bar-site-name > .ab-item, +.no-font-face #wpadminbar #wp-admin-bar-edit > .ab-item { + text-indent: 0; +} + +.no-font-face #wpadminbar .ab-icon, +.no-font-face #wpadminbar .ab-icon:before, +.no-font-face #wpadminbar a.ab-item:before, +.no-font-face #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + display: none !important; +} + +.no-font-face #wpadminbar ul.ab-top-menu > li > a > span.ab-label { + display: inline; +} + +.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon { + display: inline !important; +} + +.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon:before { + content: "Menu"; + font: 14px/45px sans-serif !important; + display: inline-block !important; + color: #fff; +} + +.no-font-face #wpadminbar #wp-admin-bar-site-name a.ab-item { + color: #fff; +} +/* End no @font-face */ + +@media screen and ( max-width: 782px ) { + /* Toolbar Touchification*/ + html #wpadminbar { + height: 46px; + min-width: 300px; + } + + #wpadminbar * { + font-size: 14px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + } + + #wpadminbar .quicklinks > ul > li > a, + #wpadminbar .quicklinks .ab-empty-item { + padding: 0; + height: 46px; + line-height: 46px; + width: auto; + } + + #wpadminbar .ab-icon { + font: 40px/1 dashicons !important; + margin: 0; + padding: 0; + width: 52px; + height: 46px; + text-align: center; + } + + #wpadminbar .ab-icon:before { + text-align: center; + } + + #wpadminbar .ab-submenu { + padding: 0; + } + + #wpadminbar #wp-admin-bar-site-name a.ab-item, + #wpadminbar #wp-admin-bar-my-sites a.ab-item, + #wpadminbar #wp-admin-bar-my-account a.ab-item { + text-overflow: clip; + } + + #wpadminbar .ab-label { + display: none; + } + + #wpadminbar .menupop li:hover > .ab-sub-wrapper, + #wpadminbar .menupop li.hover > .ab-sub-wrapper { + margin-top: -46px; + } + + #wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .menupop > .ab-item { + padding-left: 30px; + } + + #wpadminbar .menupop .menupop > .ab-item:before { + top: 10px; + left: 6px; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper .ab-item { + font-size: 16px; + padding: 8px 16px; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper a:empty { + display: none; + } + + /* WP logo */ + #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + padding: 0; + } + + #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon { + padding: 0; + width: 52px; + height: 46px; + text-align: center; + vertical-align: top; + } + + #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { + font: 28px/1 dashicons !important; + top: -3px; + } + + #wpadminbar .ab-icon, + #wpadminbar .ab-item:before { + padding: 0; + } + + /* My Sites and "Site Title" menu */ + #wpadminbar #wp-admin-bar-my-sites > .ab-item, + #wpadminbar #wp-admin-bar-site-name > .ab-item, + #wpadminbar #wp-admin-bar-customize > .ab-item, + #wpadminbar #wp-admin-bar-edit > .ab-item, + #wpadminbar #wp-admin-bar-my-account > .ab-item { + text-indent: 100%; + white-space: nowrap; + overflow: hidden; + width: 52px; + padding: 0; + color: #a0a5aa; /* @todo not needed? this text is hidden */ + position: relative; + } + + #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon, + #wpadminbar .ab-icon, + #wpadminbar .ab-item:before { + padding: 0; + margin-left: 0; + } + + #wpadminbar #wp-admin-bar-edit > .ab-item:before, + #wpadminbar #wp-admin-bar-my-sites > .ab-item:before, + #wpadminbar #wp-admin-bar-site-name > .ab-item:before, + #wpadminbar #wp-admin-bar-customize > .ab-item:before, + #wpadminbar #wp-admin-bar-my-account > .ab-item:before { + display: block; + text-indent: 0; + font: normal 32px/1 dashicons; + speak: none; + top: 7px; + width: 52px; + text-align: center; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } + + #wpadminbar #wp-admin-bar-appearance { + margin-top: 0; + } + + #wpadminbar .quicklinks li .blavatar:before { + display: none; + } + + /* Search */ + #wpadminbar #wp-admin-bar-search { + display: none; + } + + /* New Content */ + #wpadminbar #wp-admin-bar-new-content .ab-icon:before { + top: 0; + line-height: 53px; + height: 46px !important; + text-align: center; + width: 52px; + display: block; + } + + /* Updates */ + #wpadminbar #wp-admin-bar-updates { + text-align: center; + } + + #wpadminbar #wp-admin-bar-updates .ab-icon:before { + top: 3px; + } + + /* Comments */ + #wpadminbar #wp-admin-bar-comments .ab-icon { + margin: 0; + } + + #wpadminbar #wp-admin-bar-comments .ab-icon:before { + display: block; + font-size: 34px; + height: 46px; + line-height: 47px; + top: 0; + } + + /* My Account */ + #wpadminbar #wp-admin-bar-my-account > a { + position: relative; + white-space: nowrap; + text-indent: 150%; /* More than 100% indention is needed since this element has padding */ + width: 28px; + padding: 0 10px; + overflow: hidden; /* Prevent link text from forcing horizontal scrolling on mobile */ + } + + #wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + position: absolute; + top: 13px; + left: 10px; + width: 26px; + height: 26px; + } + + #wpadminbar #wp-admin-bar-user-actions.ab-submenu { + padding: 0; + } + + #wpadminbar #wp-admin-bar-user-actions.ab-submenu img.avatar { + display: none; + } + + #wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li { + margin: 0; + } + + #wpadminbar #wp-admin-bar-user-info .display-name { + height: auto; + font-size: 16px; + line-height: 24px; + color: #eee; + } + + #wpadminbar #wp-admin-bar-user-info a { + padding-top: 4px; + } + + #wpadminbar #wp-admin-bar-user-info .username { + line-height: 0.8 !important; + margin-bottom: -2px; + } + + /* Show only default top level items */ + #wp-toolbar > ul > li { + display: none; + } + + #wpadminbar li#wp-admin-bar-menu-toggle, + #wpadminbar li#wp-admin-bar-wp-logo, + #wpadminbar li#wp-admin-bar-my-sites, + #wpadminbar li#wp-admin-bar-updates, + #wpadminbar li#wp-admin-bar-site-name, + #wpadminbar li#wp-admin-bar-customize, + #wpadminbar li#wp-admin-bar-new-content, + #wpadminbar li#wp-admin-bar-edit, + #wpadminbar li#wp-admin-bar-comments, + #wpadminbar li#wp-admin-bar-my-account { + display: block; + } + + /* Allow dropdown list items to appear normally */ + #wpadminbar li:hover ul li, + #wpadminbar li.hover ul li, + #wpadminbar li:hover ul li:hover ul li { + display: list-item; + } + + /* Override default min-width so dropdown lists aren't stretched + to 100% viewport width at responsive sizes. */ + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + min-width: -webkit-fit-content; + min-width: -moz-fit-content; + min-width: fit-content; + } + + #wpadminbar ul#wp-admin-bar-root-default > li { + margin-left: 0; + } + + /* Experimental fix for touch toolbar dropdown positioning */ + #wpadminbar .ab-top-menu, + #wpadminbar .ab-top-secondary, + #wpadminbar #wp-admin-bar-wp-logo, + #wpadminbar #wp-admin-bar-my-sites, + #wpadminbar #wp-admin-bar-site-name, + #wpadminbar #wp-admin-bar-updates, + #wpadminbar #wp-admin-bar-comments, + #wpadminbar #wp-admin-bar-new-content, + #wpadminbar #wp-admin-bar-edit, + #wpadminbar #wp-admin-bar-my-account { + position: static; + } + + #wpadminbar #wp-admin-bar-my-account { + float: left; + } + + .network-admin #wpadminbar ul#wp-admin-bar-top-secondary > li#wp-admin-bar-my-account { + margin-left: 0; + } + + /* Realign arrows on taller responsive submenus */ + + #wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + top: 10px; + right: 0; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + #wpadminbar { + position: absolute; + } + + #wp-responsive-overlay { + position: fixed; + top: 0; + right: 0; + width: 100%; + height: 100%; + z-index: 400; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + width: 100%; + right: 0; + } + + #wpadminbar .menupop .menupop > .ab-item:before { + display: none; + } + + #wpadminbar #wp-admin-bar-wp-logo.menupop .ab-sub-wrapper { + margin-right: 0; + } + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper { + margin: 0; + width: 100%; + top: auto; + right: auto; + position: relative; + } + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper .ab-item { + font-size: 16px; + padding: 6px 30px 19px 15px; + } + + #wpadminbar li:hover ul li ul li { + display: list-item; + } + + #wpadminbar li#wp-admin-bar-wp-logo, + #wpadminbar li#wp-admin-bar-updates { + display: none; + } + + /* Make submenus full-width at this size */ + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper { + position: static; + box-shadow: none; + } +} + +/* Very narrow screens */ +@media screen and (max-width: 400px) { + #wpadminbar li#wp-admin-bar-comments { + display: none; + } +} diff --git a/backend/wp-includes/css/admin-bar-rtl.min.css b/backend/wp-includes/css/admin-bar-rtl.min.css new file mode 100644 index 0000000..fa9b968 --- /dev/null +++ b/backend/wp-includes/css/admin-bar-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#wpadminbar,#wpadminbar *{font-size:13px;font-weight:400;line-height:32px}#wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-shadow:none;text-transform:none;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;border-radius:0;box-sizing:content-box;transition:none;-webkit-font-smoothing:subpixel-antialiased;-moz-osx-font-smoothing:auto}.rtl #wpadminbar *{font-family:Tahoma,sans-serif}html:lang(he-il) .rtl #wpadminbar *{font-family:Arial,sans-serif}#wpadminbar .ab-empty-item{cursor:default;outline:0}#wpadminbar .ab-empty-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#eee}#wpadminbar #wp-admin-bar-my-sites a.ab-item,#wpadminbar #wp-admin-bar-site-name a.ab-item{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#wpadminbar ul li:after,#wpadminbar ul li:before{content:normal}#wpadminbar a,#wpadminbar a img,#wpadminbar a img:hover,#wpadminbar a:hover{outline:0;border:none;text-decoration:none;background:0 0}#wpadminbar a:active,#wpadminbar a:focus,#wpadminbar div,#wpadminbar input[type=text],#wpadminbar input[type=password],#wpadminbar input[type=number],#wpadminbar input[type=search],#wpadminbar input[type=email],#wpadminbar input[type=url],#wpadminbar select,#wpadminbar textarea{box-shadow:none;outline:0}#wpadminbar{direction:rtl;color:#ccc;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;height:32px;position:fixed;top:0;right:0;width:100%;min-width:600px;z-index:99999;background:#23282d}#wpadminbar .ab-sub-wrapper,#wpadminbar ul,#wpadminbar ul li{background:0 0;clear:none;list-style:none;margin:0;padding:0;position:relative;text-indent:0;z-index:99999}#wpadminbar ul#wp-admin-bar-root-default>li{margin-left:0}#wpadminbar .quicklinks ul{text-align:right}#wpadminbar li{float:right}#wpadminbar .quicklinks .ab-top-secondary>li{float:left}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:32px;display:block;padding:0 10px;margin:0}#wpadminbar .quicklinks>ul>li>a{padding:0 7px 0 8px}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{margin:0;padding:0;box-shadow:0 3px 5px rgba(0,0,0,.2);background:#32373c;display:none;position:absolute;float:none}#wpadminbar .selected .shortlink-input,#wpadminbar li.hover>.ab-sub-wrapper,#wpadminbar.nojs li:hover>.ab-sub-wrapper{display:block}#wpadminbar.ie7 .menupop .ab-sub-wrapper,#wpadminbar.ie7 .shortlink-input{top:32px;right:0}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{min-width:100%}#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper{left:0;right:auto}#wpadminbar .ab-submenu{padding:6px 0}#wpadminbar .quicklinks .menupop ul li{float:none}#wpadminbar .quicklinks .menupop ul li a strong{font-weight:600}#wpadminbar .quicklinks .menupop ul li .ab-item,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .quicklinks .menupop.hover ul li .ab-item,#wpadminbar .shortlink-input,#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item{line-height:26px;height:26px;white-space:nowrap;min-width:140px}#wpadminbar .shortlink-input{width:200px}#wpadminbar .menupop li.hover>.ab-sub-wrapper,#wpadminbar .menupop li:hover>.ab-sub-wrapper{margin-right:100%;margin-top:-32px}#wpadminbar .ab-top-secondary .menupop li.hover>.ab-sub-wrapper,#wpadminbar .ab-top-secondary .menupop li:hover>.ab-sub-wrapper{margin-right:0;right:inherit;left:100%}#wpadminbar .ab-top-menu>li.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{background:#32373c;color:#00b9eb}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label,#wpadminbar>#wp-toolbar li.hover span.ab-label{color:#00b9eb}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{position:relative;float:right;font:400 20px/1 dashicons;speak:none;padding:4px 0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:none!important;margin-left:6px}#wpadminbar #adminbarsearch:before,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:before{color:#a0a5aa;color:rgba(240,245,250,.6);position:relative;transition:all .1s ease-in-out}#wpadminbar .ab-label{display:inline-block;height:32px}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#b4b9be;color:rgba(240,245,250,.7)}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus,#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#00b9eb}#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#b4b9be}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#00b9eb}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before,#wpadminbar .menupop .menupop>.ab-item:before{position:absolute;font:400 17px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar .menupop .menupop>.ab-item{display:block;padding-left:2em}#wpadminbar .menupop .menupop>.ab-item:before{top:1px;left:4px;content:"\f141";color:inherit}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item{padding-right:2em;padding-left:1em}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before{top:1px;right:6px;content:"\f139"}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary{display:block;position:relative;left:auto;margin:0;box-shadow:none}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#464b50}#wpadminbar .quicklinks .menupop .ab-sub-secondary>li .ab-item:focus a,#wpadminbar .quicklinks .menupop .ab-sub-secondary>li>a:hover{color:#00b9eb}#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#32373c;display:inline;padding:2px 5px;font-size:10px;font-weight:600;border-radius:10px}#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000}#wpadminbar .ab-top-secondary{float:left}#wpadminbar ul li:last-child,#wpadminbar ul li:last-child .ab-item{box-shadow:none}#wp-admin-bar-my-account>ul{min-width:198px}#wp-admin-bar-my-account>.ab-item:before{content:"\f110";top:2px;float:left;margin-right:6px;margin-left:0}#wp-admin-bar-my-account.with-avatar>.ab-item:before{display:none;content:none}#wp-admin-bar-my-account.with-avatar>ul{min-width:270px}#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar .ab-item{white-space:nowrap}#wpadminbar #wp-admin-bar-user-actions>li{margin-right:16px;margin-left:16px}#wpadminbar #wp-admin-bar-user-actions.ab-submenu{padding:6px 0 12px}#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions>li{margin-right:88px}#wpadminbar #wp-admin-bar-user-info{margin-top:6px;margin-bottom:15px;height:auto;background:0 0}#wp-admin-bar-user-info .avatar{position:absolute;right:-72px;top:4px;width:64px;height:64px}#wpadminbar #wp-admin-bar-user-info a{background:0 0;height:auto}#wpadminbar #wp-admin-bar-user-info span{background:0 0;padding:0;height:18px}#wpadminbar #wp-admin-bar-user-info .display-name,#wpadminbar #wp-admin-bar-user-info .username{display:block}#wpadminbar #wp-admin-bar-user-info .username{color:#a0a5aa;font-size:11px}#wpadminbar #wp-admin-bar-my-account.with-avatar>.ab-empty-item img,#wpadminbar #wp-admin-bar-my-account.with-avatar>a img{width:auto;height:16px;padding:0;border:1px solid #82878c;background:#eee;line-height:24px;vertical-align:middle;margin:-4px 6px 0 0;float:none;display:inline}#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar>.ab-empty-item img,#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar>a img{width:auto}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon{width:15px;height:20px;margin-left:0;padding:6px 0 5px}#wpadminbar #wp-admin-bar-wp-logo>.ab-item{padding:0 7px}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon:before{content:"\f120";top:2px}#wpadminbar .quicklinks li .blavatar{float:right;font:400 16px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#eee}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar{color:#00b9eb}#wpadminbar .quicklinks li .blavatar:before{content:"\f120";height:16px;width:16px;display:inline-block;margin:6px -2px 0 8px}#wpadminbar #wp-admin-bar-appearance{margin-top:-12px}#wpadminbar #wp-admin-bar-my-sites>.ab-item:before,#wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f541";top:2px}#wpadminbar #wp-admin-bar-customize>.ab-item:before{content:"\f540";top:2px}#wpadminbar #wp-admin-bar-edit>.ab-item:before{content:"\f464";top:2px}#wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f226"}.wp-admin #wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f102"}#wpadminbar #wp-admin-bar-comments .ab-icon{margin-left:6px}#wpadminbar #wp-admin-bar-comments .ab-icon:before{content:"\f101";top:3px}#wpadminbar #wp-admin-bar-comments .count-0{opacity:.5}#wpadminbar #wp-admin-bar-new-content .ab-icon:before{content:"\f132";top:4px}#wpadminbar #wp-admin-bar-updates .ab-icon:before{content:"\f463";top:2px}#wpadminbar.ie8 #wp-admin-bar-search{display:block;min-width:32px}#wpadminbar #wp-admin-bar-search .ab-item{padding:0;background:0 0}#wpadminbar #adminbarsearch{position:relative;height:32px;padding:0 2px;z-index:1}#wpadminbar #adminbarsearch:before{position:absolute;top:6px;right:5px;z-index:20;font:400 20px/1 dashicons!important;content:"\f179";speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{display:inline-block;float:none;position:relative;z-index:30;font-size:13px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;line-height:24px;text-indent:0;height:24px;width:24px;max-width:none;padding:0 24px 0 3px;margin:0;color:#ccc;background-color:rgba(255,255,255,0);border:none;outline:0;cursor:pointer;box-shadow:none;box-sizing:border-box;transition-duration:.4s;transition-property:width,background;transition-timing-function:ease}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{z-index:10;color:#000;width:200px;background-color:rgba(255,255,255,.9);cursor:text;border:0}#wpadminbar.ie7>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{margin-top:3px;width:120px}#wpadminbar.ie8>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBR‌​AA7) 100% 0}#wpadminbar.ie8 #adminbarsearch.adminbar-focused:before{content:"\f179 "}#wpadminbar.ie8>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{background:#fff;z-index:-1}#wpadminbar #adminbarsearch .adminbar-button,.customize-support #wpadminbar .hide-if-customize,.customize-support .hide-if-customize,.customize-support .wp-core-ui .hide-if-customize,.customize-support.wp-core-ui .hide-if-customize,.no-customize-support #wpadminbar .hide-if-no-customize,.no-customize-support .hide-if-no-customize,.no-customize-support .wp-core-ui .hide-if-no-customize,.no-customize-support.wp-core-ui .hide-if-no-customize{display:none}#wpadminbar .screen-reader-text,#wpadminbar .screen-reader-text span{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}#wpadminbar .screen-reader-shortcut{position:absolute;top:-1000em}#wpadminbar .screen-reader-shortcut:focus{right:6px;top:7px;height:auto;width:auto;display:block;font-size:14px;font-weight:600;padding:15px 23px 14px;background:#f1f1f1;color:#0073aa;z-index:100000;line-height:normal;text-decoration:none;box-shadow:0 0 2px 2px rgba(0,0,0,.6)}* html #wpadminbar{overflow:hidden;position:absolute}* html #wpadminbar .quicklinks ul li a{float:right}* html #wpadminbar .menupop a span{background-image:none}.no-font-face #wpadminbar ul.ab-top-menu>li>a.ab-item{display:block;width:45px;text-align:center;overflow:hidden;margin:0 3px}.no-font-face #wpadminbar #wp-admin-bar-edit>.ab-item,.no-font-face #wpadminbar #wp-admin-bar-my-sites>.ab-item,.no-font-face #wpadminbar #wp-admin-bar-site-name>.ab-item{text-indent:0}.no-font-face #wpadminbar #wp-admin-bar-wp-logo>.ab-item,.no-font-face #wpadminbar .ab-icon,.no-font-face #wpadminbar .ab-icon:before,.no-font-face #wpadminbar a.ab-item:before{display:none!important}.no-font-face #wpadminbar ul.ab-top-menu>li>a>span.ab-label{display:inline}.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon{display:inline!important}.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon:before{content:"Menu";font:14px/45px sans-serif!important;display:inline-block!important;color:#fff}.no-font-face #wpadminbar #wp-admin-bar-site-name a.ab-item{color:#fff}@media screen and (max-width:782px){#wpadminbar ul#wp-admin-bar-root-default>li,.network-admin #wpadminbar ul#wp-admin-bar-top-secondary>li#wp-admin-bar-my-account{margin-left:0}html #wpadminbar{height:46px;min-width:300px}#wpadminbar *{font-size:14px;font-weight:400;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;line-height:32px}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks>ul>li>a{padding:0;height:46px;line-height:46px;width:auto}#wpadminbar .ab-icon{font:40px/1 dashicons!important;margin:0;padding:0;width:52px;height:46px;text-align:center}#wpadminbar .ab-icon:before{text-align:center}#wpadminbar .ab-submenu{padding:0}#wpadminbar #wp-admin-bar-my-account a.ab-item,#wpadminbar #wp-admin-bar-my-sites a.ab-item,#wpadminbar #wp-admin-bar-site-name a.ab-item{text-overflow:clip}#wpadminbar .ab-label{display:none}#wpadminbar .menupop li.hover>.ab-sub-wrapper,#wpadminbar .menupop li:hover>.ab-sub-wrapper{margin-top:-46px}#wpadminbar #wp-admin-bar-comments .ab-icon,#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions>li{margin:0}#wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .menupop>.ab-item{padding-left:30px}#wpadminbar .menupop .menupop>.ab-item:before{top:10px;left:6px}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper .ab-item{font-size:16px;padding:8px 16px}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper a:empty{display:none}#wpadminbar #wp-admin-bar-wp-logo>.ab-item{padding:0}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon{padding:0;width:52px;height:46px;text-align:center;vertical-align:top}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon:before{font:28px/1 dashicons!important;top:-3px}#wpadminbar .ab-icon,#wpadminbar .ab-item:before{padding:0}#wpadminbar #wp-admin-bar-customize>.ab-item,#wpadminbar #wp-admin-bar-edit>.ab-item,#wpadminbar #wp-admin-bar-my-account>.ab-item,#wpadminbar #wp-admin-bar-my-sites>.ab-item,#wpadminbar #wp-admin-bar-site-name>.ab-item{text-indent:100%;white-space:nowrap;overflow:hidden;width:52px;padding:0;color:#a0a5aa;position:relative}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{padding:0;margin-left:0}#wpadminbar #wp-admin-bar-customize>.ab-item:before,#wpadminbar #wp-admin-bar-edit>.ab-item:before,#wpadminbar #wp-admin-bar-my-account>.ab-item:before,#wpadminbar #wp-admin-bar-my-sites>.ab-item:before,#wpadminbar #wp-admin-bar-site-name>.ab-item:before{display:block;text-indent:0;font:400 32px/1 dashicons;speak:none;top:7px;width:52px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar #wp-admin-bar-appearance{margin-top:0}#wpadminbar .quicklinks li .blavatar:before{display:none}#wpadminbar #wp-admin-bar-search{display:none}#wpadminbar #wp-admin-bar-new-content .ab-icon:before{top:0;line-height:53px;height:46px!important;text-align:center;width:52px;display:block}#wpadminbar #wp-admin-bar-updates{text-align:center}#wpadminbar #wp-admin-bar-updates .ab-icon:before{top:3px}#wpadminbar #wp-admin-bar-comments .ab-icon:before{display:block;font-size:34px;height:46px;line-height:47px;top:0}#wp-toolbar>ul>li,#wpadminbar #wp-admin-bar-user-actions.ab-submenu img.avatar{display:none}#wpadminbar #wp-admin-bar-my-account>a{position:relative;white-space:nowrap;text-indent:150%;width:28px;padding:0 10px;overflow:hidden}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{position:absolute;top:13px;left:10px;width:26px;height:26px}#wpadminbar #wp-admin-bar-user-actions.ab-submenu{padding:0}#wpadminbar #wp-admin-bar-user-info .display-name{height:auto;font-size:16px;line-height:24px;color:#eee}#wpadminbar #wp-admin-bar-user-info a{padding-top:4px}#wpadminbar #wp-admin-bar-user-info .username{line-height:.8!important;margin-bottom:-2px}#wpadminbar li#wp-admin-bar-comments,#wpadminbar li#wp-admin-bar-customize,#wpadminbar li#wp-admin-bar-edit,#wpadminbar li#wp-admin-bar-menu-toggle,#wpadminbar li#wp-admin-bar-my-account,#wpadminbar li#wp-admin-bar-my-sites,#wpadminbar li#wp-admin-bar-new-content,#wpadminbar li#wp-admin-bar-site-name,#wpadminbar li#wp-admin-bar-updates,#wpadminbar li#wp-admin-bar-wp-logo{display:block}#wpadminbar li.hover ul li,#wpadminbar li:hover ul li,#wpadminbar li:hover ul li:hover ul li{display:list-item}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{min-width:-webkit-fit-content;min-width:-moz-fit-content;min-width:fit-content}#wpadminbar #wp-admin-bar-comments,#wpadminbar #wp-admin-bar-edit,#wpadminbar #wp-admin-bar-my-account,#wpadminbar #wp-admin-bar-my-sites,#wpadminbar #wp-admin-bar-new-content,#wpadminbar #wp-admin-bar-site-name,#wpadminbar #wp-admin-bar-updates,#wpadminbar #wp-admin-bar-wp-logo,#wpadminbar .ab-top-menu,#wpadminbar .ab-top-secondary{position:static}#wpadminbar #wp-admin-bar-my-account{float:left}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before{top:10px;right:0}}@media screen and (max-width:600px){#wpadminbar{position:absolute}#wp-responsive-overlay{position:fixed;top:0;right:0;width:100%;height:100%;z-index:400}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{width:100%;right:0}#wpadminbar .menupop .menupop>.ab-item:before{display:none}#wpadminbar #wp-admin-bar-wp-logo.menupop .ab-sub-wrapper{margin-right:0}#wpadminbar .ab-top-menu>.menupop li>.ab-sub-wrapper{margin:0;width:100%;top:auto;right:auto;position:static;box-shadow:none}#wpadminbar .ab-top-menu>.menupop li>.ab-sub-wrapper .ab-item{font-size:16px;padding:6px 30px 19px 15px}#wpadminbar li:hover ul li ul li{display:list-item}#wpadminbar li#wp-admin-bar-updates,#wpadminbar li#wp-admin-bar-wp-logo{display:none}}@media screen and (max-width:400px){#wpadminbar li#wp-admin-bar-comments{display:none}} \ No newline at end of file diff --git a/backend/wp-includes/css/admin-bar.css b/backend/wp-includes/css/admin-bar.css new file mode 100644 index 0000000..31241de --- /dev/null +++ b/backend/wp-includes/css/admin-bar.css @@ -0,0 +1,1141 @@ +#wpadminbar * { + height: auto; + width: auto; + margin: 0; + padding: 0; + position: static; + text-shadow: none; + text-transform: none; + letter-spacing: normal; + font-size: 13px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + border-radius: 0; + box-sizing: content-box; + transition: none; + -webkit-font-smoothing: subpixel-antialiased; /* Prevent Safari from switching to standard antialiasing on hover */ + -moz-osx-font-smoothing: auto; /* Prevent Firefox from inheriting from themes that use other values */ +} + +.rtl #wpadminbar * { + font-family: Tahoma, sans-serif; +} + +html:lang(he-il) .rtl #wpadminbar * { + font-family: Arial, sans-serif; +} + +#wpadminbar .ab-empty-item { + cursor: default; +} + +#wpadminbar .ab-empty-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #eee; +} + +#wpadminbar #wp-admin-bar-site-name a.ab-item, +#wpadminbar #wp-admin-bar-my-sites a.ab-item { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +#wpadminbar ul li:before, +#wpadminbar ul li:after { + content: normal; +} + +#wpadminbar a, +#wpadminbar a:hover, +#wpadminbar a img, +#wpadminbar a img:hover { + outline: none; + border: none; + text-decoration: none; + background: none; +} + +#wpadminbar a:focus, +#wpadminbar a:active, +#wpadminbar input[type="text"], +#wpadminbar input[type="password"], +#wpadminbar input[type="number"], +#wpadminbar input[type="search"], +#wpadminbar input[type="email"], +#wpadminbar input[type="url"], +#wpadminbar select, +#wpadminbar textarea, +#wpadminbar div { + box-shadow: none; + outline: none; +} + +#wpadminbar { + direction: ltr; + color: #ccc; + font-size: 13px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + height: 32px; + position: fixed; + top: 0; + left: 0; + width: 100%; + min-width: 600px; /* match the min-width of the body in wp-admin.css */ + z-index: 99999; + background: #23282d; +} + +#wpadminbar .ab-sub-wrapper, +#wpadminbar ul, +#wpadminbar ul li { + background: none; + clear: none; + list-style: none; + margin: 0; + padding: 0; + position: relative; + text-indent: 0; + z-index: 99999; +} + +#wpadminbar ul#wp-admin-bar-root-default>li { + margin-right: 0; +} + +#wpadminbar .quicklinks ul { + text-align: left; +} + +#wpadminbar li { + float: left; +} + +#wpadminbar .ab-empty-item { + outline: none; +} + +#wpadminbar .quicklinks .ab-top-secondary > li { + float: right; +} + +#wpadminbar .quicklinks a, +#wpadminbar .quicklinks .ab-empty-item, +#wpadminbar .shortlink-input { + height: 32px; + display: block; + padding: 0 10px; + margin: 0; +} + +#wpadminbar .quicklinks > ul > li > a { + padding: 0 8px 0 7px; +} + +#wpadminbar .menupop .ab-sub-wrapper, +#wpadminbar .shortlink-input { + margin: 0; + padding: 0; + box-shadow: 0 3px 5px rgba(0,0,0,0.2); + background: #32373c; + display: none; + position: absolute; + float: none; +} + +#wpadminbar.ie7 .menupop .ab-sub-wrapper, +#wpadminbar.ie7 .shortlink-input { + top: 32px; + left: 0; +} + +#wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + min-width: 100%; +} + +#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper { + right: 0; + left: auto; +} + +#wpadminbar .ab-submenu { + padding: 6px 0; +} + +#wpadminbar .selected .shortlink-input { + display: block; +} + +#wpadminbar .quicklinks .menupop ul li { + float: none; +} + +#wpadminbar .quicklinks .menupop ul li a strong { + font-weight: 600; +} + +#wpadminbar .quicklinks .menupop ul li .ab-item, +#wpadminbar .quicklinks .menupop ul li a strong, +#wpadminbar .quicklinks .menupop.hover ul li .ab-item, +#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item, +#wpadminbar .shortlink-input { + line-height: 26px; + height: 26px; + white-space: nowrap; + min-width: 140px; +} + +#wpadminbar .shortlink-input { + width: 200px; +} + +#wpadminbar.nojs li:hover > .ab-sub-wrapper, +#wpadminbar li.hover > .ab-sub-wrapper { + display: block; +} + +#wpadminbar .menupop li:hover > .ab-sub-wrapper, +#wpadminbar .menupop li.hover > .ab-sub-wrapper { + margin-left: 100%; + margin-top: -32px; +} + +#wpadminbar .ab-top-secondary .menupop li:hover > .ab-sub-wrapper, +#wpadminbar .ab-top-secondary .menupop li.hover > .ab-sub-wrapper { + margin-left: 0; + left: inherit; + right: 100%; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar .ab-top-menu > li.hover > .ab-item { + background: #32373c; + color: #00b9eb; +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { + color: #00b9eb; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon, +#wpadminbar .ab-icon, +#wpadminbar .ab-item:before { + position: relative; + float: left; + font: normal 20px/1 dashicons; + speak: none; + padding: 4px 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + background-image: none !important; + margin-right: 6px; +} + +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar #adminbarsearch:before { + color: #a0a5aa; + color: rgba(240,245,250,0.6); +} + +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar #adminbarsearch:before { + position: relative; + transition: all .1s ease-in-out; +} + +#wpadminbar .ab-label { + display: inline-block; + height: 32px; +} + +#wpadminbar .ab-submenu .ab-item { + color: #b4b9be; + color: rgba(240,245,250,0.7); +} + +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop ul li a strong, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #b4b9be; + color: rgba(240,245,250,0.7); +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover, +#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #00b9eb; +} + +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #b4b9be; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #00b9eb; +} + +#wpadminbar .menupop .menupop > .ab-item:before, +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + position: absolute; + font: normal 17px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#wpadminbar .menupop .menupop > .ab-item { + display: block; + padding-right: 2em; +} + +#wpadminbar .menupop .menupop > .ab-item:before { + top: 1px; + right: 4px; + content: "\f139"; + color: inherit; +} + +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item { + padding-left: 2em; + padding-right: 1em; +} + +#wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + top: 1px; + left: 6px; + content: "\f141"; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary { + display: block; + position: relative; + right: auto; + margin: 0; + box-shadow: none; +} + +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #464b50; +} + +#wpadminbar .quicklinks .menupop .ab-sub-secondary > li > a:hover, +#wpadminbar .quicklinks .menupop .ab-sub-secondary > li .ab-item:focus a { + color: #00b9eb; +} + +#wpadminbar .quicklinks a span#ab-updates { + background: #eee; + color: #32373c; + display: inline; + padding: 2px 5px; + font-size: 10px; + font-weight: 600; + border-radius: 10px; +} + +#wpadminbar .quicklinks a:hover span#ab-updates { + background: #fff; + color: #000; +} + +#wpadminbar .ab-top-secondary { + float: right; +} + +#wpadminbar ul li:last-child, +#wpadminbar ul li:last-child .ab-item { + box-shadow: none; +} + +/** + * My Account + */ +#wp-admin-bar-my-account > ul { + min-width: 198px; +} + +#wp-admin-bar-my-account > .ab-item:before { + content: "\f110"; + top: 2px; + float: right; + margin-left: 6px; + margin-right: 0; +} + +#wp-admin-bar-my-account.with-avatar > .ab-item:before { + display: none; + content: none; +} + +#wp-admin-bar-my-account.with-avatar > ul { + min-width: 270px; +} + +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar .ab-item { + white-space: nowrap; +} + +#wpadminbar #wp-admin-bar-user-actions > li { + margin-left: 16px; + margin-right: 16px; +} + +#wpadminbar #wp-admin-bar-user-actions.ab-submenu { + padding: 6px 0 12px; +} + +#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li { + margin-left: 88px; +} + +#wpadminbar #wp-admin-bar-user-info { + margin-top: 6px; + margin-bottom: 15px; + height: auto; + background: none; +} + +#wp-admin-bar-user-info .avatar { + position: absolute; + left: -72px; + top: 4px; + width: 64px; + height: 64px; +} + +#wpadminbar #wp-admin-bar-user-info a { + background: none; + height: auto; +} + +#wpadminbar #wp-admin-bar-user-info span { + background: none; + padding: 0; + height: 18px; +} + +#wpadminbar #wp-admin-bar-user-info .display-name, +#wpadminbar #wp-admin-bar-user-info .username { + display: block; +} + +#wpadminbar #wp-admin-bar-user-info .username { + color: #a0a5aa; + font-size: 11px; +} + +#wpadminbar #wp-admin-bar-my-account.with-avatar > .ab-empty-item img, +#wpadminbar #wp-admin-bar-my-account.with-avatar > a img { + width: auto; + height: 16px; + padding: 0; + border: 1px solid #82878c; + background: #eee; + line-height: 24px; + vertical-align: middle; + margin: -4px 0 0 6px; + float: none; + display: inline; +} + +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > .ab-empty-item img, +#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar > a img { + width: auto; +} + +/** + * WP Logo + */ +#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon { + width: 15px; + height: 20px; + margin-right: 0; + padding: 6px 0 5px; +} + +#wpadminbar #wp-admin-bar-wp-logo > .ab-item { + padding: 0 7px; +} + +#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { + content: "\f120"; + top: 2px; +} + +/* + * My Sites & Site Title + */ +#wpadminbar .quicklinks li .blavatar { + float: left; + font: normal 16px/1 dashicons !important; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + color: #eee; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar { + color: #00b9eb; +} + +#wpadminbar .quicklinks li .blavatar:before { + content: "\f120"; + height: 16px; + width: 16px; + display: inline-block; + margin: 6px 8px 0 -2px; +} + +#wpadminbar #wp-admin-bar-appearance { + margin-top: -12px; +} + +#wpadminbar #wp-admin-bar-my-sites > .ab-item:before, +#wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f541"; + top: 2px; +} + +#wpadminbar #wp-admin-bar-customize > .ab-item:before { + content: "\f540"; + top: 2px; +} + + +#wpadminbar #wp-admin-bar-edit > .ab-item:before { + content: "\f464"; + top: 2px; +} + +#wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f226"; +} + +.wp-admin #wpadminbar #wp-admin-bar-site-name > .ab-item:before { + content: "\f102"; +} + + + +/** + * Comments + */ +#wpadminbar #wp-admin-bar-comments .ab-icon { + margin-right: 6px; +} + +#wpadminbar #wp-admin-bar-comments .ab-icon:before { + content: "\f101"; + top: 3px; +} + +#wpadminbar #wp-admin-bar-comments .count-0 { + opacity: .5; +} + +/** + * New Content + */ +#wpadminbar #wp-admin-bar-new-content .ab-icon:before { + content: "\f132"; + top: 4px; +} + +/** + * Updates + */ +#wpadminbar #wp-admin-bar-updates .ab-icon:before { + content: "\f463"; + top: 2px; +} + +/** + * Search + */ +#wpadminbar.ie8 #wp-admin-bar-search { + display: block; + min-width: 32px; +} +#wpadminbar #wp-admin-bar-search .ab-item { + padding: 0; + background: transparent; +} + +#wpadminbar #adminbarsearch { + position: relative; + height: 32px; + padding: 0 2px; + z-index: 1; +} + +#wpadminbar #adminbarsearch:before { + position: absolute; + top: 6px; + left: 5px; + z-index: 20; + font: normal 20px/1 dashicons !important; + content: "\f179"; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* The admin bar search field needs to reset many styles that might be inherited from the active Theme CSS. See ticket #40313. */ +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + display: inline-block; + float: none; + position: relative; + z-index: 30; + font-size: 13px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 24px; + text-indent: 0; + height: 24px; + width: 24px; + max-width: none; + padding: 0 3px 0 24px; + margin: 0; + color: #ccc; + background-color: rgba( 255, 255, 255, 0 ); + border: none; + outline: none; + cursor: pointer; + box-shadow: none; + box-sizing: border-box; + transition-duration: 400ms; + transition-property: width, background; + transition-timing-function: ease; +} + +#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + z-index: 10; + color: #000; + width: 200px; + background-color: rgba( 255, 255, 255, 0.9 ); + cursor: text; + border: 0; +} + +#wpadminbar.ie7 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + margin-top: 3px; + width: 120px; +} + +#wpadminbar.ie8 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input { + /* IE8 z-index bug with transparent / empty elements - fill in with an encoded transparent GIF */ + background: transparent 0 0 repeat scroll url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBR‌​AA7"); +} + +/* IE8 doesn't redraw the pseudo elements unless you make a change to the content */ +#wpadminbar.ie8 #adminbarsearch.adminbar-focused:before { + content: "\f179 "; /* extra space */ +} + +#wpadminbar.ie8 > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input:focus { + background: #fff; + z-index: -1; +} + +#wpadminbar #adminbarsearch .adminbar-button { + display: none; +} + +/** + * Customize support classes + */ +.no-customize-support .hide-if-no-customize, +.customize-support .hide-if-customize, +.no-customize-support #wpadminbar .hide-if-no-customize, +.no-customize-support.wp-core-ui .hide-if-no-customize, +.no-customize-support .wp-core-ui .hide-if-no-customize, +.customize-support #wpadminbar .hide-if-customize, +.customize-support.wp-core-ui .hide-if-customize, +.customize-support .wp-core-ui .hide-if-customize { + display: none; +} + +/* Skip link */ +#wpadminbar .screen-reader-text, +#wpadminbar .screen-reader-text span { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +#wpadminbar .screen-reader-shortcut { + position: absolute; + top: -1000em; +} + +#wpadminbar .screen-reader-shortcut:focus { + left: 6px; + top: 7px; + height: auto; + width: auto; + display: block; + font-size: 14px; + font-weight: 600; + padding: 15px 23px 14px; + background: #f1f1f1; + color: #0073aa; + z-index: 100000; + line-height: normal; + text-decoration: none; + box-shadow: 0 0 2px 2px rgba(0,0,0,.6); +} + +/** + * IE 6-targeted rules + */ +* html #wpadminbar { + overflow: hidden; + position: absolute; +} + +* html #wpadminbar .quicklinks ul li a { + float: left; +} + +* html #wpadminbar .menupop a span { + background-image: none; +} + +/* No @font-face support */ +.no-font-face #wpadminbar ul.ab-top-menu > li > a.ab-item { + display: block; + width: 45px; + text-align: center; + overflow: hidden; + margin: 0 3px; +} + +.no-font-face #wpadminbar #wp-admin-bar-my-sites > .ab-item, +.no-font-face #wpadminbar #wp-admin-bar-site-name > .ab-item, +.no-font-face #wpadminbar #wp-admin-bar-edit > .ab-item { + text-indent: 0; +} + +.no-font-face #wpadminbar .ab-icon, +.no-font-face #wpadminbar .ab-icon:before, +.no-font-face #wpadminbar a.ab-item:before, +.no-font-face #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + display: none !important; +} + +.no-font-face #wpadminbar ul.ab-top-menu > li > a > span.ab-label { + display: inline; +} + +.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon { + display: inline !important; +} + +.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon:before { + content: "Menu"; + font: 14px/45px sans-serif !important; + display: inline-block !important; + color: #fff; +} + +.no-font-face #wpadminbar #wp-admin-bar-site-name a.ab-item { + color: #fff; +} +/* End no @font-face */ + +@media screen and ( max-width: 782px ) { + /* Toolbar Touchification*/ + html #wpadminbar { + height: 46px; + min-width: 300px; + } + + #wpadminbar * { + font-size: 14px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 32px; + } + + #wpadminbar .quicklinks > ul > li > a, + #wpadminbar .quicklinks .ab-empty-item { + padding: 0; + height: 46px; + line-height: 46px; + width: auto; + } + + #wpadminbar .ab-icon { + font: 40px/1 dashicons !important; + margin: 0; + padding: 0; + width: 52px; + height: 46px; + text-align: center; + } + + #wpadminbar .ab-icon:before { + text-align: center; + } + + #wpadminbar .ab-submenu { + padding: 0; + } + + #wpadminbar #wp-admin-bar-site-name a.ab-item, + #wpadminbar #wp-admin-bar-my-sites a.ab-item, + #wpadminbar #wp-admin-bar-my-account a.ab-item { + text-overflow: clip; + } + + #wpadminbar .ab-label { + display: none; + } + + #wpadminbar .menupop li:hover > .ab-sub-wrapper, + #wpadminbar .menupop li.hover > .ab-sub-wrapper { + margin-top: -46px; + } + + #wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .menupop > .ab-item { + padding-right: 30px; + } + + #wpadminbar .menupop .menupop > .ab-item:before { + top: 10px; + right: 6px; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper .ab-item { + font-size: 16px; + padding: 8px 16px; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper a:empty { + display: none; + } + + /* WP logo */ + #wpadminbar #wp-admin-bar-wp-logo > .ab-item { + padding: 0; + } + + #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon { + padding: 0; + width: 52px; + height: 46px; + text-align: center; + vertical-align: top; + } + + #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { + font: 28px/1 dashicons !important; + top: -3px; + } + + #wpadminbar .ab-icon, + #wpadminbar .ab-item:before { + padding: 0; + } + + /* My Sites and "Site Title" menu */ + #wpadminbar #wp-admin-bar-my-sites > .ab-item, + #wpadminbar #wp-admin-bar-site-name > .ab-item, + #wpadminbar #wp-admin-bar-customize > .ab-item, + #wpadminbar #wp-admin-bar-edit > .ab-item, + #wpadminbar #wp-admin-bar-my-account > .ab-item { + text-indent: 100%; + white-space: nowrap; + overflow: hidden; + width: 52px; + padding: 0; + color: #a0a5aa; /* @todo not needed? this text is hidden */ + position: relative; + } + + #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon, + #wpadminbar .ab-icon, + #wpadminbar .ab-item:before { + padding: 0; + margin-right: 0; + } + + #wpadminbar #wp-admin-bar-edit > .ab-item:before, + #wpadminbar #wp-admin-bar-my-sites > .ab-item:before, + #wpadminbar #wp-admin-bar-site-name > .ab-item:before, + #wpadminbar #wp-admin-bar-customize > .ab-item:before, + #wpadminbar #wp-admin-bar-my-account > .ab-item:before { + display: block; + text-indent: 0; + font: normal 32px/1 dashicons; + speak: none; + top: 7px; + width: 52px; + text-align: center; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } + + #wpadminbar #wp-admin-bar-appearance { + margin-top: 0; + } + + #wpadminbar .quicklinks li .blavatar:before { + display: none; + } + + /* Search */ + #wpadminbar #wp-admin-bar-search { + display: none; + } + + /* New Content */ + #wpadminbar #wp-admin-bar-new-content .ab-icon:before { + top: 0; + line-height: 53px; + height: 46px !important; + text-align: center; + width: 52px; + display: block; + } + + /* Updates */ + #wpadminbar #wp-admin-bar-updates { + text-align: center; + } + + #wpadminbar #wp-admin-bar-updates .ab-icon:before { + top: 3px; + } + + /* Comments */ + #wpadminbar #wp-admin-bar-comments .ab-icon { + margin: 0; + } + + #wpadminbar #wp-admin-bar-comments .ab-icon:before { + display: block; + font-size: 34px; + height: 46px; + line-height: 47px; + top: 0; + } + + /* My Account */ + #wpadminbar #wp-admin-bar-my-account > a { + position: relative; + white-space: nowrap; + text-indent: 150%; /* More than 100% indention is needed since this element has padding */ + width: 28px; + padding: 0 10px; + overflow: hidden; /* Prevent link text from forcing horizontal scrolling on mobile */ + } + + #wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar > a img { + position: absolute; + top: 13px; + right: 10px; + width: 26px; + height: 26px; + } + + #wpadminbar #wp-admin-bar-user-actions.ab-submenu { + padding: 0; + } + + #wpadminbar #wp-admin-bar-user-actions.ab-submenu img.avatar { + display: none; + } + + #wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions > li { + margin: 0; + } + + #wpadminbar #wp-admin-bar-user-info .display-name { + height: auto; + font-size: 16px; + line-height: 24px; + color: #eee; + } + + #wpadminbar #wp-admin-bar-user-info a { + padding-top: 4px; + } + + #wpadminbar #wp-admin-bar-user-info .username { + line-height: 0.8 !important; + margin-bottom: -2px; + } + + /* Show only default top level items */ + #wp-toolbar > ul > li { + display: none; + } + + #wpadminbar li#wp-admin-bar-menu-toggle, + #wpadminbar li#wp-admin-bar-wp-logo, + #wpadminbar li#wp-admin-bar-my-sites, + #wpadminbar li#wp-admin-bar-updates, + #wpadminbar li#wp-admin-bar-site-name, + #wpadminbar li#wp-admin-bar-customize, + #wpadminbar li#wp-admin-bar-new-content, + #wpadminbar li#wp-admin-bar-edit, + #wpadminbar li#wp-admin-bar-comments, + #wpadminbar li#wp-admin-bar-my-account { + display: block; + } + + /* Allow dropdown list items to appear normally */ + #wpadminbar li:hover ul li, + #wpadminbar li.hover ul li, + #wpadminbar li:hover ul li:hover ul li { + display: list-item; + } + + /* Override default min-width so dropdown lists aren't stretched + to 100% viewport width at responsive sizes. */ + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + min-width: -webkit-fit-content; + min-width: -moz-fit-content; + min-width: fit-content; + } + + #wpadminbar ul#wp-admin-bar-root-default > li { + margin-right: 0; + } + + /* Experimental fix for touch toolbar dropdown positioning */ + #wpadminbar .ab-top-menu, + #wpadminbar .ab-top-secondary, + #wpadminbar #wp-admin-bar-wp-logo, + #wpadminbar #wp-admin-bar-my-sites, + #wpadminbar #wp-admin-bar-site-name, + #wpadminbar #wp-admin-bar-updates, + #wpadminbar #wp-admin-bar-comments, + #wpadminbar #wp-admin-bar-new-content, + #wpadminbar #wp-admin-bar-edit, + #wpadminbar #wp-admin-bar-my-account { + position: static; + } + + #wpadminbar #wp-admin-bar-my-account { + float: right; + } + + .network-admin #wpadminbar ul#wp-admin-bar-top-secondary > li#wp-admin-bar-my-account { + margin-right: 0; + } + + /* Realign arrows on taller responsive submenus */ + + #wpadminbar .ab-top-secondary .menupop .menupop > .ab-item:before { + top: 10px; + left: 0; + } +} + +/* Smartphone */ +@media screen and (max-width: 600px) { + #wpadminbar { + position: absolute; + } + + #wp-responsive-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 400; + } + + #wpadminbar .ab-top-menu > .menupop > .ab-sub-wrapper { + width: 100%; + left: 0; + } + + #wpadminbar .menupop .menupop > .ab-item:before { + display: none; + } + + #wpadminbar #wp-admin-bar-wp-logo.menupop .ab-sub-wrapper { + margin-left: 0; + } + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper { + margin: 0; + width: 100%; + top: auto; + left: auto; + position: relative; + } + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper .ab-item { + font-size: 16px; + padding: 6px 15px 19px 30px; + } + + #wpadminbar li:hover ul li ul li { + display: list-item; + } + + #wpadminbar li#wp-admin-bar-wp-logo, + #wpadminbar li#wp-admin-bar-updates { + display: none; + } + + /* Make submenus full-width at this size */ + + #wpadminbar .ab-top-menu > .menupop li > .ab-sub-wrapper { + position: static; + box-shadow: none; + } +} + +/* Very narrow screens */ +@media screen and (max-width: 400px) { + #wpadminbar li#wp-admin-bar-comments { + display: none; + } +} diff --git a/backend/wp-includes/css/admin-bar.min.css b/backend/wp-includes/css/admin-bar.min.css new file mode 100644 index 0000000..8c8e020 --- /dev/null +++ b/backend/wp-includes/css/admin-bar.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#wpadminbar,#wpadminbar *{font-size:13px;font-weight:400;line-height:32px}#wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-shadow:none;text-transform:none;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;border-radius:0;box-sizing:content-box;transition:none;-webkit-font-smoothing:subpixel-antialiased;-moz-osx-font-smoothing:auto}.rtl #wpadminbar *{font-family:Tahoma,sans-serif}html:lang(he-il) .rtl #wpadminbar *{font-family:Arial,sans-serif}#wpadminbar .ab-empty-item{cursor:default;outline:0}#wpadminbar .ab-empty-item,#wpadminbar a.ab-item,#wpadminbar>#wp-toolbar span.ab-label,#wpadminbar>#wp-toolbar span.noticon{color:#eee}#wpadminbar #wp-admin-bar-my-sites a.ab-item,#wpadminbar #wp-admin-bar-site-name a.ab-item{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#wpadminbar ul li:after,#wpadminbar ul li:before{content:normal}#wpadminbar a,#wpadminbar a img,#wpadminbar a img:hover,#wpadminbar a:hover{outline:0;border:none;text-decoration:none;background:0 0}#wpadminbar a:active,#wpadminbar a:focus,#wpadminbar div,#wpadminbar input[type=text],#wpadminbar input[type=password],#wpadminbar input[type=number],#wpadminbar input[type=search],#wpadminbar input[type=email],#wpadminbar input[type=url],#wpadminbar select,#wpadminbar textarea{box-shadow:none;outline:0}#wpadminbar{direction:ltr;color:#ccc;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;height:32px;position:fixed;top:0;left:0;width:100%;min-width:600px;z-index:99999;background:#23282d}#wpadminbar .ab-sub-wrapper,#wpadminbar ul,#wpadminbar ul li{background:0 0;clear:none;list-style:none;margin:0;padding:0;position:relative;text-indent:0;z-index:99999}#wpadminbar ul#wp-admin-bar-root-default>li{margin-right:0}#wpadminbar .quicklinks ul{text-align:left}#wpadminbar li{float:left}#wpadminbar .quicklinks .ab-top-secondary>li{float:right}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{height:32px;display:block;padding:0 10px;margin:0}#wpadminbar .quicklinks>ul>li>a{padding:0 8px 0 7px}#wpadminbar .menupop .ab-sub-wrapper,#wpadminbar .shortlink-input{margin:0;padding:0;box-shadow:0 3px 5px rgba(0,0,0,.2);background:#32373c;display:none;position:absolute;float:none}#wpadminbar .selected .shortlink-input,#wpadminbar li.hover>.ab-sub-wrapper,#wpadminbar.nojs li:hover>.ab-sub-wrapper{display:block}#wpadminbar.ie7 .menupop .ab-sub-wrapper,#wpadminbar.ie7 .shortlink-input{top:32px;left:0}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{min-width:100%}#wpadminbar .ab-top-secondary .menupop .ab-sub-wrapper{right:0;left:auto}#wpadminbar .ab-submenu{padding:6px 0}#wpadminbar .quicklinks .menupop ul li{float:none}#wpadminbar .quicklinks .menupop ul li a strong{font-weight:600}#wpadminbar .quicklinks .menupop ul li .ab-item,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .quicklinks .menupop.hover ul li .ab-item,#wpadminbar .shortlink-input,#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item{line-height:26px;height:26px;white-space:nowrap;min-width:140px}#wpadminbar .shortlink-input{width:200px}#wpadminbar .menupop li.hover>.ab-sub-wrapper,#wpadminbar .menupop li:hover>.ab-sub-wrapper{margin-left:100%;margin-top:-32px}#wpadminbar .ab-top-secondary .menupop li.hover>.ab-sub-wrapper,#wpadminbar .ab-top-secondary .menupop li:hover>.ab-sub-wrapper{margin-left:0;left:inherit;right:100%}#wpadminbar .ab-top-menu>li.hover>.ab-item,#wpadminbar.nojq .quicklinks .ab-top-menu>li>.ab-item:focus,#wpadminbar:not(.mobile) .ab-top-menu>li:hover>.ab-item,#wpadminbar:not(.mobile) .ab-top-menu>li>.ab-item:focus{background:#32373c;color:#00b9eb}#wpadminbar:not(.mobile)>#wp-toolbar a:focus span.ab-label,#wpadminbar:not(.mobile)>#wp-toolbar li:hover span.ab-label,#wpadminbar>#wp-toolbar li.hover span.ab-label{color:#00b9eb}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{position:relative;float:left;font:400 20px/1 dashicons;speak:none;padding:4px 0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:none!important;margin-right:6px}#wpadminbar #adminbarsearch:before,#wpadminbar .ab-icon:before,#wpadminbar .ab-item:before{color:#a0a5aa;color:rgba(240,245,250,.6);position:relative;transition:all .1s ease-in-out}#wpadminbar .ab-label{display:inline-block;height:32px}#wpadminbar .ab-submenu .ab-item,#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .quicklinks .menupop ul li a strong,#wpadminbar .quicklinks .menupop.hover ul li a,#wpadminbar.nojs .quicklinks .menupop:hover ul li a{color:#b4b9be;color:rgba(240,245,250,.7)}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a,#wpadminbar .quicklinks .menupop ul li a:focus,#wpadminbar .quicklinks .menupop ul li a:focus strong,#wpadminbar .quicklinks .menupop ul li a:hover,#wpadminbar .quicklinks .menupop ul li a:hover strong,#wpadminbar .quicklinks .menupop.hover ul li a:focus,#wpadminbar .quicklinks .menupop.hover ul li a:hover,#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:focus,#wpadminbar .quicklinks .menupop.hover ul li div[tabindex]:hover,#wpadminbar li #adminbarsearch.adminbar-focused:before,#wpadminbar li .ab-item:focus .ab-icon:before,#wpadminbar li .ab-item:focus:before,#wpadminbar li a:focus .ab-icon:before,#wpadminbar li.hover .ab-icon:before,#wpadminbar li.hover .ab-item:before,#wpadminbar li:hover #adminbarsearch:before,#wpadminbar li:hover .ab-icon:before,#wpadminbar li:hover .ab-item:before,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus,#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover{color:#00b9eb}#wpadminbar.mobile .quicklinks .ab-icon:before,#wpadminbar.mobile .quicklinks .ab-item:before{color:#b4b9be}#wpadminbar.mobile .quicklinks .hover .ab-icon:before,#wpadminbar.mobile .quicklinks .hover .ab-item:before{color:#00b9eb}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before,#wpadminbar .menupop .menupop>.ab-item:before{position:absolute;font:400 17px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar .menupop .menupop>.ab-item{display:block;padding-right:2em}#wpadminbar .menupop .menupop>.ab-item:before{top:1px;right:4px;content:"\f139";color:inherit}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item{padding-left:2em;padding-right:1em}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before{top:1px;left:6px;content:"\f141"}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary{display:block;position:relative;right:auto;margin:0;box-shadow:none}#wpadminbar .quicklinks .menupop ul.ab-sub-secondary,#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu{background:#464b50}#wpadminbar .quicklinks .menupop .ab-sub-secondary>li .ab-item:focus a,#wpadminbar .quicklinks .menupop .ab-sub-secondary>li>a:hover{color:#00b9eb}#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#32373c;display:inline;padding:2px 5px;font-size:10px;font-weight:600;border-radius:10px}#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000}#wpadminbar .ab-top-secondary{float:right}#wpadminbar ul li:last-child,#wpadminbar ul li:last-child .ab-item{box-shadow:none}#wp-admin-bar-my-account>ul{min-width:198px}#wp-admin-bar-my-account>.ab-item:before{content:"\f110";top:2px;float:right;margin-left:6px;margin-right:0}#wp-admin-bar-my-account.with-avatar>.ab-item:before{display:none;content:none}#wp-admin-bar-my-account.with-avatar>ul{min-width:270px}#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar .ab-item{white-space:nowrap}#wpadminbar #wp-admin-bar-user-actions>li{margin-left:16px;margin-right:16px}#wpadminbar #wp-admin-bar-user-actions.ab-submenu{padding:6px 0 12px}#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions>li{margin-left:88px}#wpadminbar #wp-admin-bar-user-info{margin-top:6px;margin-bottom:15px;height:auto;background:0 0}#wp-admin-bar-user-info .avatar{position:absolute;left:-72px;top:4px;width:64px;height:64px}#wpadminbar #wp-admin-bar-user-info a{background:0 0;height:auto}#wpadminbar #wp-admin-bar-user-info span{background:0 0;padding:0;height:18px}#wpadminbar #wp-admin-bar-user-info .display-name,#wpadminbar #wp-admin-bar-user-info .username{display:block}#wpadminbar #wp-admin-bar-user-info .username{color:#a0a5aa;font-size:11px}#wpadminbar #wp-admin-bar-my-account.with-avatar>.ab-empty-item img,#wpadminbar #wp-admin-bar-my-account.with-avatar>a img{width:auto;height:16px;padding:0;border:1px solid #82878c;background:#eee;line-height:24px;vertical-align:middle;margin:-4px 0 0 6px;float:none;display:inline}#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar>.ab-empty-item img,#wpadminbar.ie8 #wp-admin-bar-my-account.with-avatar>a img{width:auto}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon{width:15px;height:20px;margin-right:0;padding:6px 0 5px}#wpadminbar #wp-admin-bar-wp-logo>.ab-item{padding:0 7px}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon:before{content:"\f120";top:2px}#wpadminbar .quicklinks li .blavatar{float:left;font:400 16px/1 dashicons!important;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#eee}#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover>a .blavatar,#wpadminbar .quicklinks li a:focus .blavatar,#wpadminbar .quicklinks li a:hover .blavatar{color:#00b9eb}#wpadminbar .quicklinks li .blavatar:before{content:"\f120";height:16px;width:16px;display:inline-block;margin:6px 8px 0 -2px}#wpadminbar #wp-admin-bar-appearance{margin-top:-12px}#wpadminbar #wp-admin-bar-my-sites>.ab-item:before,#wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f541";top:2px}#wpadminbar #wp-admin-bar-customize>.ab-item:before{content:"\f540";top:2px}#wpadminbar #wp-admin-bar-edit>.ab-item:before{content:"\f464";top:2px}#wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f226"}.wp-admin #wpadminbar #wp-admin-bar-site-name>.ab-item:before{content:"\f102"}#wpadminbar #wp-admin-bar-comments .ab-icon{margin-right:6px}#wpadminbar #wp-admin-bar-comments .ab-icon:before{content:"\f101";top:3px}#wpadminbar #wp-admin-bar-comments .count-0{opacity:.5}#wpadminbar #wp-admin-bar-new-content .ab-icon:before{content:"\f132";top:4px}#wpadminbar #wp-admin-bar-updates .ab-icon:before{content:"\f463";top:2px}#wpadminbar.ie8 #wp-admin-bar-search{display:block;min-width:32px}#wpadminbar #wp-admin-bar-search .ab-item{padding:0;background:0 0}#wpadminbar #adminbarsearch{position:relative;height:32px;padding:0 2px;z-index:1}#wpadminbar #adminbarsearch:before{position:absolute;top:6px;left:5px;z-index:20;font:400 20px/1 dashicons!important;content:"\f179";speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{display:inline-block;float:none;position:relative;z-index:30;font-size:13px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;line-height:24px;text-indent:0;height:24px;width:24px;max-width:none;padding:0 3px 0 24px;margin:0;color:#ccc;background-color:rgba(255,255,255,0);border:none;outline:0;cursor:pointer;box-shadow:none;box-sizing:border-box;transition-duration:.4s;transition-property:width,background;transition-timing-function:ease}#wpadminbar>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{z-index:10;color:#000;width:200px;background-color:rgba(255,255,255,.9);cursor:text;border:0}#wpadminbar.ie7>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{margin-top:3px;width:120px}#wpadminbar.ie8>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input{background:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBR‌​AA7)}#wpadminbar.ie8 #adminbarsearch.adminbar-focused:before{content:"\f179 "}#wpadminbar.ie8>#wp-toolbar>#wp-admin-bar-top-secondary>#wp-admin-bar-search #adminbarsearch input.adminbar-input:focus{background:#fff;z-index:-1}#wpadminbar #adminbarsearch .adminbar-button,.customize-support #wpadminbar .hide-if-customize,.customize-support .hide-if-customize,.customize-support .wp-core-ui .hide-if-customize,.customize-support.wp-core-ui .hide-if-customize,.no-customize-support #wpadminbar .hide-if-no-customize,.no-customize-support .hide-if-no-customize,.no-customize-support .wp-core-ui .hide-if-no-customize,.no-customize-support.wp-core-ui .hide-if-no-customize{display:none}#wpadminbar .screen-reader-text,#wpadminbar .screen-reader-text span{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}#wpadminbar .screen-reader-shortcut{position:absolute;top:-1000em}#wpadminbar .screen-reader-shortcut:focus{left:6px;top:7px;height:auto;width:auto;display:block;font-size:14px;font-weight:600;padding:15px 23px 14px;background:#f1f1f1;color:#0073aa;z-index:100000;line-height:normal;text-decoration:none;box-shadow:0 0 2px 2px rgba(0,0,0,.6)}* html #wpadminbar{overflow:hidden;position:absolute}* html #wpadminbar .quicklinks ul li a{float:left}* html #wpadminbar .menupop a span{background-image:none}.no-font-face #wpadminbar ul.ab-top-menu>li>a.ab-item{display:block;width:45px;text-align:center;overflow:hidden;margin:0 3px}.no-font-face #wpadminbar #wp-admin-bar-edit>.ab-item,.no-font-face #wpadminbar #wp-admin-bar-my-sites>.ab-item,.no-font-face #wpadminbar #wp-admin-bar-site-name>.ab-item{text-indent:0}.no-font-face #wpadminbar #wp-admin-bar-wp-logo>.ab-item,.no-font-face #wpadminbar .ab-icon,.no-font-face #wpadminbar .ab-icon:before,.no-font-face #wpadminbar a.ab-item:before{display:none!important}.no-font-face #wpadminbar ul.ab-top-menu>li>a>span.ab-label{display:inline}.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon{display:inline!important}.no-font-face #wpadminbar #wp-admin-bar-menu-toggle span.ab-icon:before{content:"Menu";font:14px/45px sans-serif!important;display:inline-block!important;color:#fff}.no-font-face #wpadminbar #wp-admin-bar-site-name a.ab-item{color:#fff}@media screen and (max-width:782px){#wpadminbar ul#wp-admin-bar-root-default>li,.network-admin #wpadminbar ul#wp-admin-bar-top-secondary>li#wp-admin-bar-my-account{margin-right:0}html #wpadminbar{height:46px;min-width:300px}#wpadminbar *{font-size:14px;font-weight:400;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;line-height:32px}#wpadminbar .quicklinks .ab-empty-item,#wpadminbar .quicklinks>ul>li>a{padding:0;height:46px;line-height:46px;width:auto}#wpadminbar .ab-icon{font:40px/1 dashicons!important;margin:0;padding:0;width:52px;height:46px;text-align:center}#wpadminbar .ab-icon:before{text-align:center}#wpadminbar .ab-submenu{padding:0}#wpadminbar #wp-admin-bar-my-account a.ab-item,#wpadminbar #wp-admin-bar-my-sites a.ab-item,#wpadminbar #wp-admin-bar-site-name a.ab-item{text-overflow:clip}#wpadminbar .ab-label{display:none}#wpadminbar .menupop li.hover>.ab-sub-wrapper,#wpadminbar .menupop li:hover>.ab-sub-wrapper{margin-top:-46px}#wpadminbar #wp-admin-bar-comments .ab-icon,#wpadminbar #wp-admin-bar-my-account.with-avatar #wp-admin-bar-user-actions>li{margin:0}#wpadminbar .ab-top-menu .menupop .ab-sub-wrapper .menupop>.ab-item{padding-right:30px}#wpadminbar .menupop .menupop>.ab-item:before{top:10px;right:6px}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper .ab-item{font-size:16px;padding:8px 16px}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper a:empty{display:none}#wpadminbar #wp-admin-bar-wp-logo>.ab-item{padding:0}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon{padding:0;width:52px;height:46px;text-align:center;vertical-align:top}#wpadminbar #wp-admin-bar-wp-logo>.ab-item .ab-icon:before{font:28px/1 dashicons!important;top:-3px}#wpadminbar .ab-icon,#wpadminbar .ab-item:before{padding:0}#wpadminbar #wp-admin-bar-customize>.ab-item,#wpadminbar #wp-admin-bar-edit>.ab-item,#wpadminbar #wp-admin-bar-my-account>.ab-item,#wpadminbar #wp-admin-bar-my-sites>.ab-item,#wpadminbar #wp-admin-bar-site-name>.ab-item{text-indent:100%;white-space:nowrap;overflow:hidden;width:52px;padding:0;color:#a0a5aa;position:relative}#wpadminbar .ab-icon,#wpadminbar .ab-item:before,#wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon{padding:0;margin-right:0}#wpadminbar #wp-admin-bar-customize>.ab-item:before,#wpadminbar #wp-admin-bar-edit>.ab-item:before,#wpadminbar #wp-admin-bar-my-account>.ab-item:before,#wpadminbar #wp-admin-bar-my-sites>.ab-item:before,#wpadminbar #wp-admin-bar-site-name>.ab-item:before{display:block;text-indent:0;font:400 32px/1 dashicons;speak:none;top:7px;width:52px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar #wp-admin-bar-appearance{margin-top:0}#wpadminbar .quicklinks li .blavatar:before{display:none}#wpadminbar #wp-admin-bar-search{display:none}#wpadminbar #wp-admin-bar-new-content .ab-icon:before{top:0;line-height:53px;height:46px!important;text-align:center;width:52px;display:block}#wpadminbar #wp-admin-bar-updates{text-align:center}#wpadminbar #wp-admin-bar-updates .ab-icon:before{top:3px}#wpadminbar #wp-admin-bar-comments .ab-icon:before{display:block;font-size:34px;height:46px;line-height:47px;top:0}#wp-toolbar>ul>li,#wpadminbar #wp-admin-bar-user-actions.ab-submenu img.avatar{display:none}#wpadminbar #wp-admin-bar-my-account>a{position:relative;white-space:nowrap;text-indent:150%;width:28px;padding:0 10px;overflow:hidden}#wpadminbar .quicklinks li#wp-admin-bar-my-account.with-avatar>a img{position:absolute;top:13px;right:10px;width:26px;height:26px}#wpadminbar #wp-admin-bar-user-actions.ab-submenu{padding:0}#wpadminbar #wp-admin-bar-user-info .display-name{height:auto;font-size:16px;line-height:24px;color:#eee}#wpadminbar #wp-admin-bar-user-info a{padding-top:4px}#wpadminbar #wp-admin-bar-user-info .username{line-height:.8!important;margin-bottom:-2px}#wpadminbar li#wp-admin-bar-comments,#wpadminbar li#wp-admin-bar-customize,#wpadminbar li#wp-admin-bar-edit,#wpadminbar li#wp-admin-bar-menu-toggle,#wpadminbar li#wp-admin-bar-my-account,#wpadminbar li#wp-admin-bar-my-sites,#wpadminbar li#wp-admin-bar-new-content,#wpadminbar li#wp-admin-bar-site-name,#wpadminbar li#wp-admin-bar-updates,#wpadminbar li#wp-admin-bar-wp-logo{display:block}#wpadminbar li.hover ul li,#wpadminbar li:hover ul li,#wpadminbar li:hover ul li:hover ul li{display:list-item}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{min-width:-webkit-fit-content;min-width:-moz-fit-content;min-width:fit-content}#wpadminbar #wp-admin-bar-comments,#wpadminbar #wp-admin-bar-edit,#wpadminbar #wp-admin-bar-my-account,#wpadminbar #wp-admin-bar-my-sites,#wpadminbar #wp-admin-bar-new-content,#wpadminbar #wp-admin-bar-site-name,#wpadminbar #wp-admin-bar-updates,#wpadminbar #wp-admin-bar-wp-logo,#wpadminbar .ab-top-menu,#wpadminbar .ab-top-secondary{position:static}#wpadminbar #wp-admin-bar-my-account{float:right}#wpadminbar .ab-top-secondary .menupop .menupop>.ab-item:before{top:10px;left:0}}@media screen and (max-width:600px){#wpadminbar{position:absolute}#wp-responsive-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:400}#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper{width:100%;left:0}#wpadminbar .menupop .menupop>.ab-item:before{display:none}#wpadminbar #wp-admin-bar-wp-logo.menupop .ab-sub-wrapper{margin-left:0}#wpadminbar .ab-top-menu>.menupop li>.ab-sub-wrapper{margin:0;width:100%;top:auto;left:auto;position:static;box-shadow:none}#wpadminbar .ab-top-menu>.menupop li>.ab-sub-wrapper .ab-item{font-size:16px;padding:6px 15px 19px 30px}#wpadminbar li:hover ul li ul li{display:list-item}#wpadminbar li#wp-admin-bar-updates,#wpadminbar li#wp-admin-bar-wp-logo{display:none}}@media screen and (max-width:400px){#wpadminbar li#wp-admin-bar-comments{display:none}} \ No newline at end of file diff --git a/backend/wp-includes/css/buttons-rtl.css b/backend/wp-includes/css/buttons-rtl.css new file mode 100644 index 0000000..b27f286 --- /dev/null +++ b/backend/wp-includes/css/buttons-rtl.css @@ -0,0 +1,396 @@ +/* ---------------------------------------------------------------------------- + +NOTE: If you edit this file, you should make sure that the CSS rules for +buttons in the following files are updated. + +* jquery-ui-dialog.css +* editor.css + +WordPress-style Buttons +======================= +Create a button by adding the `.button` class to an element. For backward +compatibility, we support several other classes (such as `.button-secondary`), +but these will *not* work with the stackable classes described below. + +Button Styles +------------- +To display a primary button style, add the `.button-primary` class to a button. + +Button Sizes +------------ +Adjust a button's size by adding the `.button-large` or `.button-small` class. + +Button States +------------- +Lock the state of a button by adding the name of the pseudoclass as +an actual class (e.g. `.hover` for `:hover`). + + +TABLE OF CONTENTS: +------------------ + 1.0 - Button Layouts + 2.0 - Default Button Style + 3.0 - Primary Button Style + 4.0 - Button Groups + 5.0 - Responsive Button Styles + +---------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------------- + 1.0 - Button Layouts +---------------------------------------------------------------------------- */ + +.wp-core-ui .button, +.wp-core-ui .button-primary, +.wp-core-ui .button-secondary { + display: inline-block; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0 10px 1px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-sizing: border-box; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.wp-core-ui button::-moz-focus-inner, +.wp-core-ui input[type="reset"]::-moz-focus-inner, +.wp-core-ui input[type="button"]::-moz-focus-inner, +.wp-core-ui input[type="submit"]::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.wp-core-ui .button.button-large, +.wp-core-ui .button-group.button-large .button { + height: 30px; + line-height: 28px; + padding: 0 12px 2px; +} + +.wp-core-ui .button.button-small, +.wp-core-ui .button-group.button-small .button { + height: 24px; + line-height: 22px; + padding: 0 8px 1px; + font-size: 11px; +} + +.wp-core-ui .button.button-hero, +.wp-core-ui .button-group.button-hero .button { + font-size: 14px; + height: 46px; + line-height: 44px; + padding: 0 36px; +} + +.wp-core-ui .button:active, +.wp-core-ui .button:focus { + outline: none; +} + +.wp-core-ui .button.hidden { + display: none; +} + +/* Style Reset buttons as simple text links */ + +.wp-core-ui input[type="reset"], +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active, +.wp-core-ui input[type="reset"]:focus { + background: none; + border: none; + box-shadow: none; + padding: 0 2px 1px; + width: auto; +} + +/* ---------------------------------------------------------------------------- + 2.0 - Default Button Style +---------------------------------------------------------------------------- */ + +.wp-core-ui .button, +.wp-core-ui .button-secondary { + color: #555; + border-color: #cccccc; + background: #f7f7f7; + box-shadow: 0 1px 0 #cccccc; + vertical-align: top; +} + +.wp-core-ui p .button { + vertical-align: baseline; +} + +.wp-core-ui .button.hover, +.wp-core-ui .button:hover, +.wp-core-ui .button-secondary:hover, +.wp-core-ui .button.focus, +.wp-core-ui .button:focus, +.wp-core-ui .button-secondary:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.wp-core-ui .button.focus, +.wp-core-ui .button:focus, +.wp-core-ui .button-secondary:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui .button.active, +.wp-core-ui .button.active:hover, +.wp-core-ui .button:active, +.wp-core-ui .button-secondary:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.wp-core-ui .button.active:focus { + border-color: #5b9dd9; + box-shadow: + inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ), + 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui .button[disabled], +.wp-core-ui .button:disabled, +.wp-core-ui .button.disabled, +.wp-core-ui .button-secondary[disabled], +.wp-core-ui .button-secondary:disabled, +.wp-core-ui .button-secondary.disabled, +.wp-core-ui .button-disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +/* Buttons that look like links, for a cross of good semantics with the visual */ +.wp-core-ui .button-link { + margin: 0; + padding: 0; + box-shadow: none; + border: 0; + border-radius: 0; + background: none; + outline: none; + cursor: pointer; + text-align: right; + /* Mimics the default link style in common.css */ + color: #0073aa; + text-decoration: underline; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +.wp-core-ui .button-link:hover, +.wp-core-ui .button-link:active { + color: #00a0d2; +} + +.wp-core-ui .button-link:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.wp-core-ui .button-link-delete { + color: #a00; +} + +.wp-core-ui .button-link-delete:hover, +.wp-core-ui .button-link-delete:focus { + color: #dc3232; +} + +.ie8 .wp-core-ui .button-link:focus { + outline: #5b9dd9 solid 1px; +} + +/* ---------------------------------------------------------------------------- + 3.0 - Primary Button Style +---------------------------------------------------------------------------- */ + +.wp-core-ui .button-primary { + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: 0 -1px 1px #006799, + -1px 0 1px #006799, + 0 1px 1px #006799, + 1px 0 1px #006799; +} + +.wp-core-ui .button-primary.hover, +.wp-core-ui .button-primary:hover, +.wp-core-ui .button-primary.focus, +.wp-core-ui .button-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.wp-core-ui .button-primary.focus, +.wp-core-ui .button-primary:focus { + box-shadow: 0 1px 0 #0073aa, + 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary.active, +.wp-core-ui .button-primary.active:hover, +.wp-core-ui .button-primary.active:focus, +.wp-core-ui .button-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; + vertical-align: top; +} + +.wp-core-ui .button-primary[disabled], +.wp-core-ui .button-primary:disabled, +.wp-core-ui .button-primary-disabled, +.wp-core-ui .button-primary.disabled { + color: #66c6e4 !important; + background: #008ec2 !important; + border-color: #007cb2 !important; + box-shadow: none !important; + text-shadow: 0 -1px 0 rgba( 0, 0, 0, 0.1 ) !important; + cursor: default; +} + +.wp-core-ui .button.button-primary.button-hero { + box-shadow: 0 2px 0 #006799; +} + +.wp-core-ui .button.button-primary.button-hero.active, +.wp-core-ui .button.button-primary.button-hero.active:hover, +.wp-core-ui .button.button-primary.button-hero.active:focus, +.wp-core-ui .button.button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #006799; +} + +/* ---------------------------------------------------------------------------- + 4.0 - Button Groups +---------------------------------------------------------------------------- */ + +.wp-core-ui .button-group { + position: relative; + display: inline-block; + white-space: nowrap; + font-size: 0; + vertical-align: middle; +} + +.wp-core-ui .button-group > .button { + display: inline-block; + border-radius: 0; + margin-left: -1px; + z-index: 10; +} + +.wp-core-ui .button-group > .button-primary { + z-index: 100; +} + +.wp-core-ui .button-group > .button:hover { + z-index: 20; +} + +.wp-core-ui .button-group > .button:first-child { + border-radius: 0 3px 3px 0; +} + +.wp-core-ui .button-group > .button:last-child { + border-radius: 3px 0 0 3px; +} + +.wp-core-ui .button-group > .button:focus { + position: relative; + z-index: 1; +} + +/* ---------------------------------------------------------------------------- + 5.0 - Responsive Button Styles +---------------------------------------------------------------------------- */ + +@media screen and ( max-width: 782px ) { + + .wp-core-ui .button, + .wp-core-ui .button.button-large, + .wp-core-ui .button.button-small, + input#publish, + input#save-post, + a.preview { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + margin-bottom: 4px; + } + + #media-upload.wp-core-ui .button { + padding: 0 10px 1px; + height: 24px; + line-height: 22px; + font-size: 13px; + } + + .media-frame.mode-grid .bulk-select .button { + margin-bottom: 0; + } + + /* Publish Metabox Options */ + .wp-core-ui .save-post-status.button { + position: relative; + margin: 0 10px 0 14px; /* 14px right margin to match all other buttons */ + } + + /* Reset responsive styles in Press This, Customizer */ + + .wp-core-ui.wp-customizer .button { + padding: 0 10px 1px; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + vertical-align: inherit; + } + + .media-modal-content .media-toolbar-primary .media-button { + margin-top: 10px; + margin-right: 5px; + } + + /* Reset responsive styles on Log in button on iframed login form */ + + .interim-login .button.button-large { + height: 30px; + line-height: 28px; + padding: 0 12px 2px; + } + +} diff --git a/backend/wp-includes/css/buttons-rtl.min.css b/backend/wp-includes/css/buttons-rtl.min.css new file mode 100644 index 0000000..187da48 --- /dev/null +++ b/backend/wp-includes/css/buttons-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-core-ui .button,.wp-core-ui .button-primary,.wp-core-ui .button-secondary{display:inline-block;text-decoration:none;font-size:13px;line-height:26px;height:28px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-sizing:border-box}.wp-core-ui button::-moz-focus-inner,.wp-core-ui input[type=reset]::-moz-focus-inner,.wp-core-ui input[type=button]::-moz-focus-inner,.wp-core-ui input[type=submit]::-moz-focus-inner{border-width:0;border-style:none;padding:0}.wp-core-ui .button-group.button-large .button,.wp-core-ui .button.button-large{height:30px;line-height:28px;padding:0 12px 2px}.wp-core-ui .button-group.button-small .button,.wp-core-ui .button.button-small{height:24px;line-height:22px;padding:0 8px 1px;font-size:11px}.wp-core-ui .button-group.button-hero .button,.wp-core-ui .button.button-hero{font-size:14px;height:46px;line-height:44px;padding:0 36px}.wp-core-ui .button:active,.wp-core-ui .button:focus{outline:0}.wp-core-ui .button.hidden{display:none}.wp-core-ui input[type=reset],.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:focus,.wp-core-ui input[type=reset]:hover{background:0 0;border:none;box-shadow:none;padding:0 2px 1px;width:auto}.wp-core-ui .button,.wp-core-ui .button-secondary{color:#555;border-color:#ccc;background:#f7f7f7;box-shadow:0 1px 0 #ccc;vertical-align:top}.wp-core-ui p .button{vertical-align:baseline}.wp-core-ui .button-secondary:focus,.wp-core-ui .button-secondary:hover,.wp-core-ui .button.focus,.wp-core-ui .button.hover,.wp-core-ui .button:focus,.wp-core-ui .button:hover{background:#fafafa;border-color:#999;color:#23282d}.wp-core-ui .button-secondary:focus,.wp-core-ui .button.focus,.wp-core-ui .button:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-core-ui .button-secondary:active,.wp-core-ui .button.active,.wp-core-ui .button.active:hover,.wp-core-ui .button:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.wp-core-ui .button.active:focus{border-color:#5b9dd9;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5),0 0 3px rgba(0,115,170,.8)}.wp-core-ui .button-disabled,.wp-core-ui .button-secondary.disabled,.wp-core-ui .button-secondary:disabled,.wp-core-ui .button-secondary[disabled],.wp-core-ui .button.disabled,.wp-core-ui .button:disabled,.wp-core-ui .button[disabled]{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}.wp-core-ui .button-link{margin:0;padding:0;box-shadow:none;border:0;border-radius:0;background:0 0;outline:0;cursor:pointer;text-align:right;color:#0073aa;text-decoration:underline;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}.wp-core-ui .button-link:active,.wp-core-ui .button-link:hover{color:#00a0d2}.wp-core-ui .button-link:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.wp-core-ui .button-link-delete{color:#a00}.wp-core-ui .button-link-delete:focus,.wp-core-ui .button-link-delete:hover{color:#dc3232}.ie8 .wp-core-ui .button-link:focus{outline:#5b9dd9 solid 1px}.wp-core-ui .button-primary{background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,-1px 0 1px #006799,0 1px 1px #006799,1px 0 1px #006799}.wp-core-ui .button-primary.focus,.wp-core-ui .button-primary.hover,.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.wp-core-ui .button-primary.focus,.wp-core-ui .button-primary:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799;vertical-align:top}.wp-core-ui .button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#66c6e4!important;background:#008ec2!important;border-color:#007cb2!important;box-shadow:none!important;text-shadow:0 -1px 0 rgba(0,0,0,.1)!important;cursor:default}.wp-core-ui .button.button-primary.button-hero{box-shadow:0 2px 0 #006799}.wp-core-ui .button.button-primary.button-hero.active,.wp-core-ui .button.button-primary.button-hero.active:focus,.wp-core-ui .button.button-primary.button-hero.active:hover,.wp-core-ui .button.button-primary.button-hero:active{box-shadow:inset 0 3px 0 #006799}.wp-core-ui .button-group{position:relative;display:inline-block;white-space:nowrap;font-size:0;vertical-align:middle}.wp-core-ui .button-group>.button{display:inline-block;border-radius:0;margin-left:-1px;z-index:10}.wp-core-ui .button-group>.button-primary{z-index:100}.wp-core-ui .button-group>.button:hover{z-index:20}.wp-core-ui .button-group>.button:first-child{border-radius:0 3px 3px 0}.wp-core-ui .button-group>.button:last-child{border-radius:3px 0 0 3px}.wp-core-ui .button-group>.button:focus{position:relative;z-index:1}@media screen and (max-width:782px){.wp-core-ui .button,.wp-core-ui .button.button-large,.wp-core-ui .button.button-small,a.preview,input#publish,input#save-post{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto;margin-bottom:4px}#media-upload.wp-core-ui .button{padding:0 10px 1px;height:24px;line-height:22px;font-size:13px}.media-frame.mode-grid .bulk-select .button{margin-bottom:0}.wp-core-ui .save-post-status.button{position:relative;margin:0 10px 0 14px}.wp-core-ui.wp-customizer .button{padding:0 10px 1px;font-size:13px;line-height:26px;height:28px;margin:0;vertical-align:inherit}.media-modal-content .media-toolbar-primary .media-button{margin-top:10px;margin-right:5px}.interim-login .button.button-large{height:30px;line-height:28px;padding:0 12px 2px}} \ No newline at end of file diff --git a/backend/wp-includes/css/buttons.css b/backend/wp-includes/css/buttons.css new file mode 100644 index 0000000..9b78343 --- /dev/null +++ b/backend/wp-includes/css/buttons.css @@ -0,0 +1,396 @@ +/* ---------------------------------------------------------------------------- + +NOTE: If you edit this file, you should make sure that the CSS rules for +buttons in the following files are updated. + +* jquery-ui-dialog.css +* editor.css + +WordPress-style Buttons +======================= +Create a button by adding the `.button` class to an element. For backward +compatibility, we support several other classes (such as `.button-secondary`), +but these will *not* work with the stackable classes described below. + +Button Styles +------------- +To display a primary button style, add the `.button-primary` class to a button. + +Button Sizes +------------ +Adjust a button's size by adding the `.button-large` or `.button-small` class. + +Button States +------------- +Lock the state of a button by adding the name of the pseudoclass as +an actual class (e.g. `.hover` for `:hover`). + + +TABLE OF CONTENTS: +------------------ + 1.0 - Button Layouts + 2.0 - Default Button Style + 3.0 - Primary Button Style + 4.0 - Button Groups + 5.0 - Responsive Button Styles + +---------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------------- + 1.0 - Button Layouts +---------------------------------------------------------------------------- */ + +.wp-core-ui .button, +.wp-core-ui .button-primary, +.wp-core-ui .button-secondary { + display: inline-block; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0 10px 1px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-sizing: border-box; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.wp-core-ui button::-moz-focus-inner, +.wp-core-ui input[type="reset"]::-moz-focus-inner, +.wp-core-ui input[type="button"]::-moz-focus-inner, +.wp-core-ui input[type="submit"]::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.wp-core-ui .button.button-large, +.wp-core-ui .button-group.button-large .button { + height: 30px; + line-height: 28px; + padding: 0 12px 2px; +} + +.wp-core-ui .button.button-small, +.wp-core-ui .button-group.button-small .button { + height: 24px; + line-height: 22px; + padding: 0 8px 1px; + font-size: 11px; +} + +.wp-core-ui .button.button-hero, +.wp-core-ui .button-group.button-hero .button { + font-size: 14px; + height: 46px; + line-height: 44px; + padding: 0 36px; +} + +.wp-core-ui .button:active, +.wp-core-ui .button:focus { + outline: none; +} + +.wp-core-ui .button.hidden { + display: none; +} + +/* Style Reset buttons as simple text links */ + +.wp-core-ui input[type="reset"], +.wp-core-ui input[type="reset"]:hover, +.wp-core-ui input[type="reset"]:active, +.wp-core-ui input[type="reset"]:focus { + background: none; + border: none; + box-shadow: none; + padding: 0 2px 1px; + width: auto; +} + +/* ---------------------------------------------------------------------------- + 2.0 - Default Button Style +---------------------------------------------------------------------------- */ + +.wp-core-ui .button, +.wp-core-ui .button-secondary { + color: #555; + border-color: #cccccc; + background: #f7f7f7; + box-shadow: 0 1px 0 #cccccc; + vertical-align: top; +} + +.wp-core-ui p .button { + vertical-align: baseline; +} + +.wp-core-ui .button.hover, +.wp-core-ui .button:hover, +.wp-core-ui .button-secondary:hover, +.wp-core-ui .button.focus, +.wp-core-ui .button:focus, +.wp-core-ui .button-secondary:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.wp-core-ui .button.focus, +.wp-core-ui .button:focus, +.wp-core-ui .button-secondary:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui .button.active, +.wp-core-ui .button.active:hover, +.wp-core-ui .button:active, +.wp-core-ui .button-secondary:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.wp-core-ui .button.active:focus { + border-color: #5b9dd9; + box-shadow: + inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ), + 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui .button[disabled], +.wp-core-ui .button:disabled, +.wp-core-ui .button.disabled, +.wp-core-ui .button-secondary[disabled], +.wp-core-ui .button-secondary:disabled, +.wp-core-ui .button-secondary.disabled, +.wp-core-ui .button-disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +/* Buttons that look like links, for a cross of good semantics with the visual */ +.wp-core-ui .button-link { + margin: 0; + padding: 0; + box-shadow: none; + border: 0; + border-radius: 0; + background: none; + outline: none; + cursor: pointer; + text-align: left; + /* Mimics the default link style in common.css */ + color: #0073aa; + text-decoration: underline; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; +} + +.wp-core-ui .button-link:hover, +.wp-core-ui .button-link:active { + color: #00a0d2; +} + +.wp-core-ui .button-link:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.wp-core-ui .button-link-delete { + color: #a00; +} + +.wp-core-ui .button-link-delete:hover, +.wp-core-ui .button-link-delete:focus { + color: #dc3232; +} + +.ie8 .wp-core-ui .button-link:focus { + outline: #5b9dd9 solid 1px; +} + +/* ---------------------------------------------------------------------------- + 3.0 - Primary Button Style +---------------------------------------------------------------------------- */ + +.wp-core-ui .button-primary { + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: 0 -1px 1px #006799, + 1px 0 1px #006799, + 0 1px 1px #006799, + -1px 0 1px #006799; +} + +.wp-core-ui .button-primary.hover, +.wp-core-ui .button-primary:hover, +.wp-core-ui .button-primary.focus, +.wp-core-ui .button-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.wp-core-ui .button-primary.focus, +.wp-core-ui .button-primary:focus { + box-shadow: 0 1px 0 #0073aa, + 0 0 2px 1px #33b3db; +} + +.wp-core-ui .button-primary.active, +.wp-core-ui .button-primary.active:hover, +.wp-core-ui .button-primary.active:focus, +.wp-core-ui .button-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; + vertical-align: top; +} + +.wp-core-ui .button-primary[disabled], +.wp-core-ui .button-primary:disabled, +.wp-core-ui .button-primary-disabled, +.wp-core-ui .button-primary.disabled { + color: #66c6e4 !important; + background: #008ec2 !important; + border-color: #007cb2 !important; + box-shadow: none !important; + text-shadow: 0 -1px 0 rgba( 0, 0, 0, 0.1 ) !important; + cursor: default; +} + +.wp-core-ui .button.button-primary.button-hero { + box-shadow: 0 2px 0 #006799; +} + +.wp-core-ui .button.button-primary.button-hero.active, +.wp-core-ui .button.button-primary.button-hero.active:hover, +.wp-core-ui .button.button-primary.button-hero.active:focus, +.wp-core-ui .button.button-primary.button-hero:active { + box-shadow: inset 0 3px 0 #006799; +} + +/* ---------------------------------------------------------------------------- + 4.0 - Button Groups +---------------------------------------------------------------------------- */ + +.wp-core-ui .button-group { + position: relative; + display: inline-block; + white-space: nowrap; + font-size: 0; + vertical-align: middle; +} + +.wp-core-ui .button-group > .button { + display: inline-block; + border-radius: 0; + margin-right: -1px; + z-index: 10; +} + +.wp-core-ui .button-group > .button-primary { + z-index: 100; +} + +.wp-core-ui .button-group > .button:hover { + z-index: 20; +} + +.wp-core-ui .button-group > .button:first-child { + border-radius: 3px 0 0 3px; +} + +.wp-core-ui .button-group > .button:last-child { + border-radius: 0 3px 3px 0; +} + +.wp-core-ui .button-group > .button:focus { + position: relative; + z-index: 1; +} + +/* ---------------------------------------------------------------------------- + 5.0 - Responsive Button Styles +---------------------------------------------------------------------------- */ + +@media screen and ( max-width: 782px ) { + + .wp-core-ui .button, + .wp-core-ui .button.button-large, + .wp-core-ui .button.button-small, + input#publish, + input#save-post, + a.preview { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + margin-bottom: 4px; + } + + #media-upload.wp-core-ui .button { + padding: 0 10px 1px; + height: 24px; + line-height: 22px; + font-size: 13px; + } + + .media-frame.mode-grid .bulk-select .button { + margin-bottom: 0; + } + + /* Publish Metabox Options */ + .wp-core-ui .save-post-status.button { + position: relative; + margin: 0 14px 0 10px; /* 14px right margin to match all other buttons */ + } + + /* Reset responsive styles in Press This, Customizer */ + + .wp-core-ui.wp-customizer .button { + padding: 0 10px 1px; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + vertical-align: inherit; + } + + .media-modal-content .media-toolbar-primary .media-button { + margin-top: 10px; + margin-left: 5px; + } + + /* Reset responsive styles on Log in button on iframed login form */ + + .interim-login .button.button-large { + height: 30px; + line-height: 28px; + padding: 0 12px 2px; + } + +} diff --git a/backend/wp-includes/css/buttons.min.css b/backend/wp-includes/css/buttons.min.css new file mode 100644 index 0000000..5fe69c0 --- /dev/null +++ b/backend/wp-includes/css/buttons.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-core-ui .button,.wp-core-ui .button-primary,.wp-core-ui .button-secondary{display:inline-block;text-decoration:none;font-size:13px;line-height:26px;height:28px;margin:0;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-sizing:border-box}.wp-core-ui button::-moz-focus-inner,.wp-core-ui input[type=reset]::-moz-focus-inner,.wp-core-ui input[type=button]::-moz-focus-inner,.wp-core-ui input[type=submit]::-moz-focus-inner{border-width:0;border-style:none;padding:0}.wp-core-ui .button-group.button-large .button,.wp-core-ui .button.button-large{height:30px;line-height:28px;padding:0 12px 2px}.wp-core-ui .button-group.button-small .button,.wp-core-ui .button.button-small{height:24px;line-height:22px;padding:0 8px 1px;font-size:11px}.wp-core-ui .button-group.button-hero .button,.wp-core-ui .button.button-hero{font-size:14px;height:46px;line-height:44px;padding:0 36px}.wp-core-ui .button:active,.wp-core-ui .button:focus{outline:0}.wp-core-ui .button.hidden{display:none}.wp-core-ui input[type=reset],.wp-core-ui input[type=reset]:active,.wp-core-ui input[type=reset]:focus,.wp-core-ui input[type=reset]:hover{background:0 0;border:none;box-shadow:none;padding:0 2px 1px;width:auto}.wp-core-ui .button,.wp-core-ui .button-secondary{color:#555;border-color:#ccc;background:#f7f7f7;box-shadow:0 1px 0 #ccc;vertical-align:top}.wp-core-ui p .button{vertical-align:baseline}.wp-core-ui .button-secondary:focus,.wp-core-ui .button-secondary:hover,.wp-core-ui .button.focus,.wp-core-ui .button.hover,.wp-core-ui .button:focus,.wp-core-ui .button:hover{background:#fafafa;border-color:#999;color:#23282d}.wp-core-ui .button-secondary:focus,.wp-core-ui .button.focus,.wp-core-ui .button:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-core-ui .button-secondary:active,.wp-core-ui .button.active,.wp-core-ui .button.active:hover,.wp-core-ui .button:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.wp-core-ui .button.active:focus{border-color:#5b9dd9;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5),0 0 3px rgba(0,115,170,.8)}.wp-core-ui .button-disabled,.wp-core-ui .button-secondary.disabled,.wp-core-ui .button-secondary:disabled,.wp-core-ui .button-secondary[disabled],.wp-core-ui .button.disabled,.wp-core-ui .button:disabled,.wp-core-ui .button[disabled]{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}.wp-core-ui .button-link{margin:0;padding:0;box-shadow:none;border:0;border-radius:0;background:0 0;outline:0;cursor:pointer;text-align:left;color:#0073aa;text-decoration:underline;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}.wp-core-ui .button-link:active,.wp-core-ui .button-link:hover{color:#00a0d2}.wp-core-ui .button-link:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.wp-core-ui .button-link-delete{color:#a00}.wp-core-ui .button-link-delete:focus,.wp-core-ui .button-link-delete:hover{color:#dc3232}.ie8 .wp-core-ui .button-link:focus{outline:#5b9dd9 solid 1px}.wp-core-ui .button-primary{background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799}.wp-core-ui .button-primary.focus,.wp-core-ui .button-primary.hover,.wp-core-ui .button-primary:focus,.wp-core-ui .button-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.wp-core-ui .button-primary.focus,.wp-core-ui .button-primary:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}.wp-core-ui .button-primary.active,.wp-core-ui .button-primary.active:focus,.wp-core-ui .button-primary.active:hover,.wp-core-ui .button-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799;vertical-align:top}.wp-core-ui .button-primary-disabled,.wp-core-ui .button-primary.disabled,.wp-core-ui .button-primary:disabled,.wp-core-ui .button-primary[disabled]{color:#66c6e4!important;background:#008ec2!important;border-color:#007cb2!important;box-shadow:none!important;text-shadow:0 -1px 0 rgba(0,0,0,.1)!important;cursor:default}.wp-core-ui .button.button-primary.button-hero{box-shadow:0 2px 0 #006799}.wp-core-ui .button.button-primary.button-hero.active,.wp-core-ui .button.button-primary.button-hero.active:focus,.wp-core-ui .button.button-primary.button-hero.active:hover,.wp-core-ui .button.button-primary.button-hero:active{box-shadow:inset 0 3px 0 #006799}.wp-core-ui .button-group{position:relative;display:inline-block;white-space:nowrap;font-size:0;vertical-align:middle}.wp-core-ui .button-group>.button{display:inline-block;border-radius:0;margin-right:-1px;z-index:10}.wp-core-ui .button-group>.button-primary{z-index:100}.wp-core-ui .button-group>.button:hover{z-index:20}.wp-core-ui .button-group>.button:first-child{border-radius:3px 0 0 3px}.wp-core-ui .button-group>.button:last-child{border-radius:0 3px 3px 0}.wp-core-ui .button-group>.button:focus{position:relative;z-index:1}@media screen and (max-width:782px){.wp-core-ui .button,.wp-core-ui .button.button-large,.wp-core-ui .button.button-small,a.preview,input#publish,input#save-post{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto;margin-bottom:4px}#media-upload.wp-core-ui .button{padding:0 10px 1px;height:24px;line-height:22px;font-size:13px}.media-frame.mode-grid .bulk-select .button{margin-bottom:0}.wp-core-ui .save-post-status.button{position:relative;margin:0 14px 0 10px}.wp-core-ui.wp-customizer .button{padding:0 10px 1px;font-size:13px;line-height:26px;height:28px;margin:0;vertical-align:inherit}.media-modal-content .media-toolbar-primary .media-button{margin-top:10px;margin-left:5px}.interim-login .button.button-large{height:30px;line-height:28px;padding:0 12px 2px}} \ No newline at end of file diff --git a/backend/wp-includes/css/customize-preview-rtl.css b/backend/wp-includes/css/customize-preview-rtl.css new file mode 100644 index 0000000..691475c --- /dev/null +++ b/backend/wp-includes/css/customize-preview-rtl.css @@ -0,0 +1,251 @@ +.customize-partial-refreshing { + opacity: 0.25; + transition: opacity 0.25s; + cursor: progress; +} + +/* Override highlight when refreshing */ +.customize-partial-refreshing.widget-customizer-highlighted-widget { + box-shadow: none; +} + +/* Make shortcut buttons essentially invisible */ +.widget .customize-partial-edit-shortcut, +.customize-partial-edit-shortcut { + position: absolute; + float: right; + width: 1px; /* required to have a size to be focusable in Safari */ + height: 1px; + padding: 0; + margin: -1px -1px 0 0; + border: 0; + background: transparent; + color: transparent; + box-shadow: none; + outline: none; + z-index: 5; +} + +/** + * Styles for the actual shortcut + * + * Note that some properties are overly verbose to prevent theme interference. + */ +.widget .customize-partial-edit-shortcut button, +.customize-partial-edit-shortcut button { + position: absolute; + right: -30px; + top: 2px; + color: #fff; + width: 30px; + height: 30px; + min-width: 30px; + min-height: 30px; + line-height: 1em !important; + font-size: 18px; + z-index: 5; + background: #0085ba !important; + border-radius: 50%; + border: 2px solid #fff; + box-shadow: 0 2px 1px rgba(46,68,83,0.15); + text-align: center; + cursor: pointer; + box-sizing: border-box; + padding: 3px; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + -webkit-animation-duration: .4s; + animation-duration: .4s; + opacity: 0; + pointer-events: none; + text-shadow: 0 -1px 1px #006799, + -1px 0 1px #006799, + 0 1px 1px #006799, + 1px 0 1px #006799; +} +.wp-custom-header .customize-partial-edit-shortcut button { + right: 2px +} + +.customize-partial-edit-shortcut button svg { + fill: #fff; + min-width: 20px; + min-height: 20px; + width: 20px; + height: 20px; + margin: auto; +} + +.customize-partial-edit-shortcut button:hover { + background: #008ec2 !important; /* matches primary buttons */ +} + +.customize-partial-edit-shortcut button:focus { + box-shadow: 0 0 0 2px #008ec2; +} + +body.customize-partial-edit-shortcuts-shown .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-appear; + animation-name: customize-partial-edit-shortcut-bounce-appear; + pointer-events: auto; +} +body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-disappear; + animation-name: customize-partial-edit-shortcut-bounce-disappear; + pointer-events: none; +} + +.page-sidebar-collapsed .customize-partial-edit-shortcut button, +.customize-partial-edit-shortcut-hidden .customize-partial-edit-shortcut button { + visibility: hidden; +} + +@-webkit-keyframes customize-partial-edit-shortcut-bounce-appear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes customize-partial-edit-shortcut-bounce-appear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@-webkit-keyframes customize-partial-edit-shortcut-bounce-disappear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + 20% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + 40% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 60% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +@keyframes customize-partial-edit-shortcut-bounce-disappear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + 20% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + 40% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 60% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +@media screen and (max-width:800px) { + .widget .customize-partial-edit-shortcut button, + .customize-partial-edit-shortcut button { + right: -32px; + } +} + +@media screen and (max-width:320px) { + .widget .customize-partial-edit-shortcut button, + .customize-partial-edit-shortcut button { + right: -30px; + } +} diff --git a/backend/wp-includes/css/customize-preview-rtl.min.css b/backend/wp-includes/css/customize-preview-rtl.min.css new file mode 100644 index 0000000..f309420 --- /dev/null +++ b/backend/wp-includes/css/customize-preview-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.customize-partial-refreshing{opacity:.25;transition:opacity .25s;cursor:progress}.customize-partial-refreshing.widget-customizer-highlighted-widget{box-shadow:none}.customize-partial-edit-shortcut,.widget .customize-partial-edit-shortcut{position:absolute;float:right;width:1px;height:1px;padding:0;margin:-1px -1px 0 0;border:0;background:0 0;color:transparent;box-shadow:none;outline:0;z-index:5}.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{position:absolute;right:-30px;top:2px;color:#fff;width:30px;height:30px;min-width:30px;min-height:30px;line-height:1em!important;font-size:18px;z-index:5;background:#0085ba!important;border-radius:50%;border:2px solid #fff;box-shadow:0 2px 1px rgba(46,68,83,.15);text-align:center;cursor:pointer;box-sizing:border-box;padding:3px;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.4s;animation-duration:.4s;opacity:0;pointer-events:none;text-shadow:0 -1px 1px #006799,-1px 0 1px #006799,0 1px 1px #006799,1px 0 1px #006799}.wp-custom-header .customize-partial-edit-shortcut button{right:2px}.customize-partial-edit-shortcut button svg{fill:#fff;min-width:20px;min-height:20px;width:20px;height:20px;margin:auto}.customize-partial-edit-shortcut button:hover{background:#008ec2!important}.customize-partial-edit-shortcut button:focus{box-shadow:0 0 0 2px #008ec2}body.customize-partial-edit-shortcuts-shown .customize-partial-edit-shortcut button{-webkit-animation-name:customize-partial-edit-shortcut-bounce-appear;animation-name:customize-partial-edit-shortcut-bounce-appear;pointer-events:auto}body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut button{-webkit-animation-name:customize-partial-edit-shortcut-bounce-disappear;animation-name:customize-partial-edit-shortcut-bounce-disappear;pointer-events:none}.customize-partial-edit-shortcut-hidden .customize-partial-edit-shortcut button,.page-sidebar-collapsed .customize-partial-edit-shortcut button{visibility:hidden}@-webkit-keyframes customize-partial-edit-shortcut-bounce-appear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}20%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}40%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}60%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}80%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}to{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}}@keyframes customize-partial-edit-shortcut-bounce-appear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}20%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}40%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}60%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}80%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}to{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}}@-webkit-keyframes customize-partial-edit-shortcut-bounce-disappear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}20%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}40%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}80%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}to{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}}@keyframes customize-partial-edit-shortcut-bounce-disappear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}20%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}40%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}80%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}to{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}}@media screen and (max-width:800px){.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{right:-32px}}@media screen and (max-width:320px){.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{right:-30px}} \ No newline at end of file diff --git a/backend/wp-includes/css/customize-preview.css b/backend/wp-includes/css/customize-preview.css new file mode 100644 index 0000000..26c4a72 --- /dev/null +++ b/backend/wp-includes/css/customize-preview.css @@ -0,0 +1,251 @@ +.customize-partial-refreshing { + opacity: 0.25; + transition: opacity 0.25s; + cursor: progress; +} + +/* Override highlight when refreshing */ +.customize-partial-refreshing.widget-customizer-highlighted-widget { + box-shadow: none; +} + +/* Make shortcut buttons essentially invisible */ +.widget .customize-partial-edit-shortcut, +.customize-partial-edit-shortcut { + position: absolute; + float: left; + width: 1px; /* required to have a size to be focusable in Safari */ + height: 1px; + padding: 0; + margin: -1px 0 0 -1px; + border: 0; + background: transparent; + color: transparent; + box-shadow: none; + outline: none; + z-index: 5; +} + +/** + * Styles for the actual shortcut + * + * Note that some properties are overly verbose to prevent theme interference. + */ +.widget .customize-partial-edit-shortcut button, +.customize-partial-edit-shortcut button { + position: absolute; + left: -30px; + top: 2px; + color: #fff; + width: 30px; + height: 30px; + min-width: 30px; + min-height: 30px; + line-height: 1em !important; + font-size: 18px; + z-index: 5; + background: #0085ba !important; + border-radius: 50%; + border: 2px solid #fff; + box-shadow: 0 2px 1px rgba(46,68,83,0.15); + text-align: center; + cursor: pointer; + box-sizing: border-box; + padding: 3px; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + -webkit-animation-duration: .4s; + animation-duration: .4s; + opacity: 0; + pointer-events: none; + text-shadow: 0 -1px 1px #006799, + 1px 0 1px #006799, + 0 1px 1px #006799, + -1px 0 1px #006799; +} +.wp-custom-header .customize-partial-edit-shortcut button { + left: 2px +} + +.customize-partial-edit-shortcut button svg { + fill: #fff; + min-width: 20px; + min-height: 20px; + width: 20px; + height: 20px; + margin: auto; +} + +.customize-partial-edit-shortcut button:hover { + background: #008ec2 !important; /* matches primary buttons */ +} + +.customize-partial-edit-shortcut button:focus { + box-shadow: 0 0 0 2px #008ec2; +} + +body.customize-partial-edit-shortcuts-shown .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-appear; + animation-name: customize-partial-edit-shortcut-bounce-appear; + pointer-events: auto; +} +body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut button { + -webkit-animation-name: customize-partial-edit-shortcut-bounce-disappear; + animation-name: customize-partial-edit-shortcut-bounce-disappear; + pointer-events: none; +} + +.page-sidebar-collapsed .customize-partial-edit-shortcut button, +.customize-partial-edit-shortcut-hidden .customize-partial-edit-shortcut button { + visibility: hidden; +} + +@-webkit-keyframes customize-partial-edit-shortcut-bounce-appear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@keyframes customize-partial-edit-shortcut-bounce-appear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } + 20% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + 40% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 60% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 80% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + to { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } +} + +@-webkit-keyframes customize-partial-edit-shortcut-bounce-disappear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + 20% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + 40% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 60% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +@keyframes customize-partial-edit-shortcut-bounce-disappear { + from, 20%, 40%, 60%, 80%, to { + -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); + } + 0% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + } + 20% { + -webkit-transform: scale3d(.97, .97, .97); + transform: scale3d(.97, .97, .97); + } + 40% { + opacity: 1; + -webkit-transform: scale3d(1.03, 1.03, 1.03); + transform: scale3d(1.03, 1.03, 1.03); + } + 60% { + -webkit-transform: scale3d(.9, .9, .9); + transform: scale3d(.9, .9, .9); + } + 80% { + -webkit-transform: scale3d(1.1, 1.1, 1.1); + transform: scale3d(1.1, 1.1, 1.1); + } + to { + opacity: 0; + -webkit-transform: scale3d(.3, .3, .3); + transform: scale3d(.3, .3, .3); + } +} + +@media screen and (max-width:800px) { + .widget .customize-partial-edit-shortcut button, + .customize-partial-edit-shortcut button { + left: -32px; + } +} + +@media screen and (max-width:320px) { + .widget .customize-partial-edit-shortcut button, + .customize-partial-edit-shortcut button { + left: -30px; + } +} diff --git a/backend/wp-includes/css/customize-preview.min.css b/backend/wp-includes/css/customize-preview.min.css new file mode 100644 index 0000000..1addff6 --- /dev/null +++ b/backend/wp-includes/css/customize-preview.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.customize-partial-refreshing{opacity:.25;transition:opacity .25s;cursor:progress}.customize-partial-refreshing.widget-customizer-highlighted-widget{box-shadow:none}.customize-partial-edit-shortcut,.widget .customize-partial-edit-shortcut{position:absolute;float:left;width:1px;height:1px;padding:0;margin:-1px 0 0 -1px;border:0;background:0 0;color:transparent;box-shadow:none;outline:0;z-index:5}.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{position:absolute;left:-30px;top:2px;color:#fff;width:30px;height:30px;min-width:30px;min-height:30px;line-height:1em!important;font-size:18px;z-index:5;background:#0085ba!important;border-radius:50%;border:2px solid #fff;box-shadow:0 2px 1px rgba(46,68,83,.15);text-align:center;cursor:pointer;box-sizing:border-box;padding:3px;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.4s;animation-duration:.4s;opacity:0;pointer-events:none;text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799}.wp-custom-header .customize-partial-edit-shortcut button{left:2px}.customize-partial-edit-shortcut button svg{fill:#fff;min-width:20px;min-height:20px;width:20px;height:20px;margin:auto}.customize-partial-edit-shortcut button:hover{background:#008ec2!important}.customize-partial-edit-shortcut button:focus{box-shadow:0 0 0 2px #008ec2}body.customize-partial-edit-shortcuts-shown .customize-partial-edit-shortcut button{-webkit-animation-name:customize-partial-edit-shortcut-bounce-appear;animation-name:customize-partial-edit-shortcut-bounce-appear;pointer-events:auto}body.customize-partial-edit-shortcuts-hidden .customize-partial-edit-shortcut button{-webkit-animation-name:customize-partial-edit-shortcut-bounce-disappear;animation-name:customize-partial-edit-shortcut-bounce-disappear;pointer-events:none}.customize-partial-edit-shortcut-hidden .customize-partial-edit-shortcut button,.page-sidebar-collapsed .customize-partial-edit-shortcut button{visibility:hidden}@-webkit-keyframes customize-partial-edit-shortcut-bounce-appear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}20%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}40%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}60%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}80%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}to{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}}@keyframes customize-partial-edit-shortcut-bounce-appear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}20%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}40%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}60%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}80%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}to{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}}@-webkit-keyframes customize-partial-edit-shortcut-bounce-disappear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}20%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}40%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}80%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}to{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}}@keyframes customize-partial-edit-shortcut-bounce-disappear{20%,40%,60%,80%,from,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:1;-webkit-transform:scale3d(1,1,1);transform:scale3d(1,1,1)}20%{-webkit-transform:scale3d(.97,.97,.97);transform:scale3d(.97,.97,.97)}40%{opacity:1;-webkit-transform:scale3d(1.03,1.03,1.03);transform:scale3d(1.03,1.03,1.03)}60%{-webkit-transform:scale3d(.9,.9,.9);transform:scale3d(.9,.9,.9)}80%{-webkit-transform:scale3d(1.1,1.1,1.1);transform:scale3d(1.1,1.1,1.1)}to{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}}@media screen and (max-width:800px){.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{left:-32px}}@media screen and (max-width:320px){.customize-partial-edit-shortcut button,.widget .customize-partial-edit-shortcut button{left:-30px}} \ No newline at end of file diff --git a/backend/wp-includes/css/dashicons.css b/backend/wp-includes/css/dashicons.css new file mode 100644 index 0000000..8436fa3 --- /dev/null +++ b/backend/wp-includes/css/dashicons.css @@ -0,0 +1,1026 @@ +@font-face { + font-family: dashicons; + src: url(../fonts/dashicons.eot); +} + +@font-face { + font-family: dashicons; + src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAGYMAA4AAAAAowAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABRAAAABwAAAAcckwii0dERUYAAAFgAAAAHwAAACABMwAET1MvMgAAAYAAAABAAAAAYJYFacxjbWFwAAABwAAAAUEAAAKi6kAXkmdhc3AAAAMEAAAACAAAAAj//wADZ2x5ZgAAAwwAAFnuAACMgOFsk4doZWFkAABc/AAAAC4AAAA2DP0UgmhoZWEAAF0sAAAAGgAAACQPogeuaG10eAAAXUgAAAEHAAACFodAcgtsb2NhAABeUAAAAg4AAAIO/oLadm1heHAAAGBgAAAAHwAAACABWQC1bmFtZQAAYIAAAAGbAAADVi8qdoNwb3N0AABiHAAAA+cAAApGwPo//ndlYmYAAGYEAAAABgAAAAayr1bhAAAAAQAAAADMPaLPAAAAANMHHI4AAAAA0wdjLXjaY2BkYGDgA2IJBhBgYmBkYGRkBZIsYB4DAASNADkAeNpjYGY/xTiBgZWBhVWEZQMDA8M0CM20h8GIKQLIB0phB6He4X4MDqp/vrqzXwDxgaQGkGJEUqLAwAgANrQKyHja3ZC9SwNBEMXnkqgcuzcGxOIgxYGkuO78JMHmNMQkoCKmkIhI/GhiFRshXRoLO1vBv0U7tdFGFAzWaqXO7o426nkkYGFv44N5w4Ph92AAIAm9yYAVO1jHcbK6OWW1470GIfRBJvtBNg2RSyPkU0BTlKcCFalMNdqgBrVoX1nKVq7yVV6Falbb2tW+zuuKqZgVUzN10zAtc2COOMU2u+zzKOe4wKUoAojpQGkaJo+yMX2MchTG9BJVqU5btEttBSqp0spTQZdu6bT2dKBDUzZLXfqmaZq2OWTgfk6zxwGPc8jFKOoMDKbwCz/xHd/wFV/wGZ/wER/wHm/xBq/wAhdxAUs4g9M4iRPOntN0dpxtZ13W5aqsyapclvNyToaiI+7EtbgU5+JMnIqT3sf+TlY//FRYidgSvw/g3+sbNnmNdAAAAAAAAAH//wACeNqsvQl8FFW2OFy3qquqO1un01u27nSntyydtTeydQKEPWwBIYogS7MvRpFNAm4RUUFQFEURN0RcRqMi45Jh3EbbbUQm6uhDxXFkGHVGncdzIElf/+fc6k46yMyb9/2+dKrurVtVt27d5eznFCdy8EdO892cwEmchkvjtBxXpbPrBL1db9YReyrR6cnp3sfoE9HH6C1k+mPRx/juWDO5mfuZ9vxMaOxD7mfipTz3M0e4pL8qjuO5CBeTX5R6oc4Ax2lIKExMZisxW4VgSENkyVBATAY5g5cl2Fn5MAkFQ2E+FKyG8uqQeDDWsDtn/e21ZQ9NK62f3bqyNvZIrOFpi2WZxZI3arFphMM/pVIeu+Syy/yFvvQWf75lGpyaZhE286/tzk93uK1byrPz7ekkLfYI/9rT7Ox0S15wbGaVw3/ZZUvGypWT/YXNulUj81idHCFeLio1yWouC/rEXm0y6gxSKSE6R6E7oPMHyWmhs3Xt2tYoTYtCKqvXtsaaW9fSNHJ6bSvf3boWXlvg/gl1fCJ9BH2Zweoxyxri0ZCATyTQrbhJTXuWxTbENizjfyQ7o7GDfFvfFMFG21Wb9yzjb2DltD16d+zR2OP8BVRLTtM0qDfK7ZZXyLVcNufm6qFeU6aWZBAPaSRBv8ddqCXEHYS8TcOOJZlIBrMpKBOTpCWSzePObCRhYmal1dLfN2/e0/qnZURqaWlsbHymcSJ90lLTetdVZGH/t7ypoKCwrSD2LSblZJ8VT9C9Vym30PlNTY3PSN1YcldrjZWIE1uggqamFvrksj+17tncNxMquKjAxltj37D0TXIfO7F5M1m0GW6x0HmNzzQ1cpwK5kcE3mkFp+fyuGKcI0Tnd5cSj112FErQ+yafvTrIVZsMUqHbL9p1LA36qs06O3TowKFoqCt+5Hrafv0jxXV1xcKp4rpY09Hbbjt6m3CYnIbktiXmPNoDfarkhU6+u7guGq0rjjXDDfyzWHxU1XdyCd4jkrNUXkofZAccPzAnBBhRDodPtBvtOh/fJpzqOyTY+rOj5LRo6P0uEhUNOP7fcCelP0unODW8kxNnvYcEcdaLISJnEIddlgo9bn8jvGlQo5yRiVhAu18izbkXuz1Z/W/MEq5fV/3tPNrR4e3wer0dDYJEmnPwXC7tlvKVS/Ue96x32vs3Tq8eAReVbvJ2kM65p+l+OJUFp3LpS7D+otwbUkzq54ycHdouqTwEeyxE3FmhoNOs4U0SLjQ2f2A1Sp0L6N+vjH01/tjt4/ltfv+COUS1ln5Bcom1eFjvXut0i9VqmW61CD8v8PtjV4y//dg43nolyVowZ5iXfkFPkoI1P8cKLJb4hZxAvMQrq6X9sP5LuTHK6DrsgyNLfDi0pcSIA9lAHDiaddgxsPQSRwE8siSuZEMekNV1xb3f4ViLhuK6/uwIZiOWEstAhpw+T9lOVRfm+6bgoFvqWut2Gy0W427I8G7M0QeTy2KfYo6BR24n96A8Wm6DEeUIDKNbwqVnlqE7VdCVxBMyBXF1qQyH+Y5fT3p11IRmvf/XP9JTQfph8O0AMf8Ihc0TRumlBw/Hrj/s14+aMOqVyYd/pH8Nvh0kZXDBP1hh86sw3wzcC1I3zLdsrhyeXViuqiDusOCrhnmSIQouSC0kQ+UodFZA34SJT2W6eGrQm6MTBEkqbVwUXry1PIOodNmlgc0k84o/bNIGHt7/p4UP0t2RyBUfXKnyuRvGjWvQ60PLF0woW/vYbDlnzPApNfSPh7ccW3lW1Hqs2TX5+Wfbf3+tAr8jshra4uEq4M0dkgzvLMlGe8DtkT0ht8eh8wVDnpA5GArYjSZzyCybzD6uOuh3F0oGWf1pbujuY3e3LaY9i9vu7rk7lP3pJ+YaKLlgBfGykhrzJ/3VZ7q6znQJtuUz4Axc8ml2CM60LSbFC2dDSTAvXjJ7IR3ehdeydkXlQnkqwFcYEc6UBRhE5RFEwe5RpnZWdTDA2iA1vjxq1Nx2+tbWl+iHu2lPRMgbU7V6LuErVk2atGqSXP4ypfTnue2BJvpcAd0WFcjNpHH13FGxE5OGheAKfBYpklfAHNbhaibVKrNcDnNTkn0a4gtmOfWFTk/ICvMzGHJoiCNDEE7dTXTzHw+/uOzeHwtP0Qfpg0ezXyVlv7qH/jBQSuaQOUezNh7+Xtq/uf211rmv30Hbyc6DJGtfb2e8gOyk7Zs/u382h3AyCu+rrKMcWMnFv1xJnE1lllQ2pyeoYu9tqiYApQLwY2tlK1sr62GthEgr8W/cSN+lT9J3N27kH167f+3a/TB3vb1biVewIVjDi/uzYS+M23fLLftgO4EXrY0djEQi0J50LgrregXMCy1AbjOMQQHMkFKYIyGujmuElT7hPGvdrrProUm++JaA6iFopwvODTmG86qkY3kFvIOTvcPx4rpeJwO3xKv8960sscDqjmKH8W2ILPtjSSXdQ68gOxFkxMGH6hMo8EbZH02zsKsiEcDn3kQeTsSz8N6ICyLSfkYfWIdSCPY4heAJwcKAVQJLAaiFU3FqgfZARtjf2xtJ/CPt0H8iQTsItta1/U8mnUY8wsGYH4VnydDLBYhH9A490BFONrpBv+Aymd2OQpXsdjoK5WBIOBUzlUcrbxdOCaf6h7fWAQSL8GXt2f7ibvrK7Nn0le6iQHa7cIqU9B1WranDvoiwV4v97os7npNf2Lv3Bfm5OxR8J4+U1wIlqEPqBQg0RHp2oN0QlcnSnu0WC23tO6QqPWSdFvsLn3NL7NQYuW070Fd0an+NePyQhfTfxmffEvtLDwc0JfzBexyFmeLg2mDlLuPaoSiTLydOmyqD8JlZVgIzN0xgDpuyMnmcxm4oDTJ60S1LjkJP0OmDheeWjAagHk1mEyAMoHfCBIEuu8INQFIyFRC9hoRVHjjPa4ibD/iJHm+Xjy584Sf6Pn2Rvv/TCwshT6rIaFL10wt9b5BVZOKPt9zyI32W3kafxRxpoO8vNWTojddMt+tXkfm/v5uYV/hnm025olDdaLPRH41utdqgNRiune5Y6nAaIDu9nTxPREFt0sgpcz7sPU42v/0/QsnXazYtXiyMUh618JwmiDOHPHQia0hfsRBQ874KkkIOvLpqgTxhvGV4UbFanLml/kRrK/93olYJfMhPUiVeIIEQUdOjsXz+BTmntfXqmsf+8F90m3Bb36kF5IZvn6XvxHaUWDkxPmdXwIySuVS2YjlciwQg9pDNK67v3apq6T8BNA3b+LbYQXnFmTPielgTPYMbwMQLyE5ZlDOAriiF2vyecsCJWSFPhsqMkDAUdP2ySJgxtvpX43J+/8BD85/bt7I6M/erx+6cN1946nyl/EfXXtzoztxBhk/9c8WWQ++dvfoP/W1tu89XiNNLHKAjVUB1pXGZ+I56oLXtBAAJ2+AFNcQOyCx2sG8K8aq6+qaoumIHYwcFG0IMeUXflNhB8Ti8YDsCAEzJaaybT6JR3YgDCyXLIEfgYyBgAA7oSLxc1dI69Ubag1xCK9/WuhY3hAQ9EUjF9beMf572EO/aVnIay2k7bGkADAbKYMkwHIfP1QC81UFP53AWzobvhU9zwUNEwae3OwQfSWywTDU8EKvFdWfO1JEXohEA05FoBGihxA6B/GllXOuKz77MS+Hiugg+dnADmvZUf7bQSdtpO6N9lPePIAwiriCQYvCqNncmo8JFXQa+snLgD/IvqSYV1b1HP3/vvVvHTezvyIp23sqyw6S9UamxNNr3dzgmhe85+NXR/s6rn2B5oa4okMQLaBk3MDzxpgbJkQCu8H5cArv5w7Jv4Fy1VVUA677aypu/lDL848b5z/4D9uI/e7fy3QqCe5CIKUZLeW1rpYLbiifW+h05kqTKHNa0pH3xSF+qvCJ+mx+rOPsyLgehlyE+2qPObZ2yYvackSUMLxbz3d4xF1wwxmRKK148eTiUGBNzJcrwop5Riue03wd4jrMFM902KVM8TtzecNh79l3cEzdQyjvpbaTlm2/ooW+kprC3b0FZc3OZ6l5vONr73TfKCXyGBM/YPcAzOWD9+QDncgA7rbwhgwfYWc77w3xWnAZTnZMmsKwUT4U8cjepfetqv//qt+gbdBF9Q8nLHW1tHW18bnISk1jyW4Zb5BUjVz/64p9efHT1yEQm5mhjFyT9x65lSXsd3gP89U5ymuHPVIWTSvyk/YgjERcCFDIkcozvVfgv5R4z3uUIIPsFDFggZHQYHQFHwAf0hLQfFld/h6oFUDYg7YhoALwe6XUKnVF2HI0ib478iLQf6CgFFsIIBezYDgFTBf51AT+HGfF4tD8bVwpwjQzGnHNvHI4q92Oqw/xAPUInNmZwTQ2pkjH9+P/v6tXF6y4m8TyrF2sT1/d3II2COVYrqwwrjtf5r94zJ6l9sMZ/8ZoEyT9xvbgeZjKn4fEIgOJ6upKu5gjfDeeOq7qUc+JxLEUQyrfFzxkS94kGLAVSbBfZzs51i8eBNWbngByDUrw+dvDfnpMVmleuhf4oYLSlj1GXDHdBfyhcoZIa7UYkiRoITnExKY/959I5YK9ssOq8Z18mXpiUZCfs+jsU4o7vVlKyE3p4Z5Rvw3+pCbpnfSTc1haOsH0v8oNDd72rcaAjKBBLbAgz+RH8SGmq+BekfoiZOEhIFN/ZEntpC+3eQoj4lzn9L5I3Nv2gwIw/cn+UzkhnFKwF/MUgDRTwZzkBpwin7ieFxzo6jtHP6cv082MdPWQpuSf2onRmsKjjGCm8/0Oy9FjfCkFNr+IY7x9lvJuW8Ujn0lY8kJKyhpg1hBEoRR9dddVH9I9AnvwRc8JvceLCkgIchhMtqnDyyZeQInZbvw9PRYdePgRvavC9NEQkAjyLuIheJHqXqCcu4RTtgcVw72U4WdrJXpiEPd+QD+irM6mXemfSV8kH8orYwQm0OrYUa+XvJL+fQNbT0lq6Nxb75hsggSK1XBKOwmexJwEVyOonXr6NRtoRz19GF/Btv6wO24nlbA6KOLtIMSFABWUjBIIWpsFshnFl/Ym88AouQ+EDTZmMssTJGCb6OL9pNJhRMGBCbpCYxNe3HDmyxe5aBjj1Rc2h62dfd92L1+XRI47rswTZ9rSVNFfKK35LTx9RL+v7Sjx+6z2x/+q8eHZn5+xgFVz0epZqI1yCQI88Q56RrJIV1zIbNhi8EAyeqpvM66H30X09ZD7bkfk90Ob7esi8xCHdB5dw/+t84GxhkllObBkk03S+CUFGksyTW7acpD/A/rwToW/5lpMD1yAM2hmXm5lh/ZbBS/iGYkMm57GZjIKOdZyOeMIk3ocmswwLb4ALLY4g/osCHiZep6cC1m2Fx6lqiUvvilGWR7wHvvnmAE5CRk/1xJo/zhrnxUXrHZf18VAaEekoF9fMTRzapgaSTNMhlBmgNcKSD4YZqIsCzCKVAWiI3WaUml4vbWgo7T1d2sAyYlppQ+93qpa+Q+Q0Q33ExqsttmDNxOL+jmGtbhMhREjPsnvqCismFOeL/MuRhtL+q6UmpY6G0teVOhpK+6arWmiU4VHak+JccsnqaTVIk8NLFRSotMXucrsZCY9YJczWq0sbgEHVJNFQZkYdeBjcRJ6cCwEPHkjiybPiFADy2vx/kGd0JRKNsI8yEkBc33fox3+bi9QVD94lNTEqoA5Y7fZ/l0seq8H34FznSjwSbYOh4ZPyCmWLD8VHn+07T7OSX0USleciyuo/MZjnOIUHx3YcBX7fyGUPpVmQhYJ5ABPFjA8Fcrmn/wTKFwDodAPdjfJmYCbITsGGWUwZkdfOzsWagbrBsxynyMEVHjkFnpTN5SOfARMxUMgZHZrEQ0WWoKiE735tx12n6A/PEEmaTtOQ2hBsAEkBENM0oN1Picdv3HOM/vUz+iv+q96tNE04BXRQrBnYD8Cs/+J5Gngk5zBWm0j87fQsEZA8q3uNNBHpGfrDqbt29BZjbVgrQwoRfBr9FZn2GTEf20Pk/g4EnUhGYT/0dyT6UsX68iiMaSrTiwDBTIwKKse9y65BgZVoJ/JR2gO19yCd0neS76YP8t2IiOmD0GdzVC1RZE6jyJ9Gyc7Y2kgvY1Pi74RjhTSUUn8c7wOtCK/h0AkaAQYK7mM1VOOdMCqnaLu0P/FAxAv4MCAEc1Fyh3I6htIBx0S5Y3IKtN/MdC+yCyC+x40/hw7GqBrFEtJLkyfTb0Ih//x5mzq346u/++LhrTcJn79Il7y4pnP7Lddumj8vEIJnvUpepR9NnnjTVqXuN6BudbzuYAh+PqyzUJbwB0hFdGcSI1x9+MV3kTra3tkxf74/FKLfTBY+hwdMnExKaJiGiTcUmDd/07W3bO9c8yK5i9EX0P1A0AIczmQz2CDJOhSe6MpRsm4zqZgwyV0orn/0ukh19XWPIqyNHWQLQVx/00eFsbu9kfx8obzwo5sAxuawBcLWhrJG1QMSSTsuQgW6M9E9wlGg0Ig9sTqd8ZRvEzoTwD2KGeItrgOyv72/o53BO+G4wnZ0YytgurEE5297EmsR54Wi58ghHefnG5nkESn1eDoUBPRuRVGiYEPRACRDRaYKMS/YIgqj3K6kcboDqSLxOOP2rKjGYM/0B0O4A544zDCMQXzv+sPv3dqffet7XddKty2pKq/+7eUHvhG+znjjBuSPr39dl5u/5Db9gvXfHKhU+pbcADTJHwCim1HCAny/WYKdJyj6ccplwKOQxuBszlA5QXEXcOQBfyiDyCb+Vb6F/PnKK2l+7BDNv/JK4X/8RTpbVXNLIDiB2skpcs/SUT/sXfk3+szfVu79YdRS8Q/02Jkz9BgpP3NG7W1O43nVOF+gpSV25z+6Nz5evOa+R/72t0fuW1P8+MZuBY8O0hF6xn02/VLW64FFJ7Lhd+h8RtwGR4Nj/K/JJpitit4Hu2toj0dwCfaFVLkF3gj8eQv6ThZ4vUIb8sYwPQ9MDDUDMdAcwhXLZLnxO+HKTUCB0p5NcHkB3h7j4yw13706O9KAxEFDJJutC2IgROqWjnBebhiu6CxZES0mfjJ0pqQs8PhPcnrcmaGgUyUEMz1umyxlmk021ZGb3UuFHHVhRVjVYK9yOM0mlTCisqra7/dV2b18mS0723A3veva++9fRvJInmPRosX080WLFy8ihVL5zXTDfYJJyrOVqsrsVUg1llWOEAST0e2ostcLjeU2q2Ga/5oHyFv3L5swIZa7mNgXwx/9YvFihHm/4B0HMJSQSDuRg2OcISaqFgQfuCniPcZqwToCfgfm8fokHtSs1OUC2ImIAKg1x4Ck8LRwqve7KMBgFJv3KLXAogaQHElUqrC5uFQAoUsDOlQtwOUChs9LFYihsHA+IKGrTaK9HPqE2BNLN5lzU3UhkOj9DoGFbsehHfQa4s28YP4FdC4Sgv0dSAICNsV/oDOKI0A9zrj88hmlNTX00TgROZRJUw/MY3znzLh8zQ6UIeeKc/Tw/oqC2RyAReyK8+SJTVajiAjFiP0dxIuKqRMo50OcktjwJLw3XGdAcqCnAxVd0ejaVhQvAsWDwkYuQZuzcZQUvIVMoBEfP0igO4VTO4jw0qUwbt2XvkRj9E809tKll75EBOGUUrID+rx5R6IUwBFczTG7gcH3TFXeLtGvspq1A/+xmUi24igy2gf4d694XGoCXJqPvQLNqQ4pOC+AlLrHbRd0AOIQ+DhkX7XRIEulBO564/11633+1RcsWrOaxjZsXen3zVmy+/4/+qqXHwSW+rvIgmc2T2jJ02h3X/HEpMmxGLHb7OOnjP6vB2aVIqQj5F2Y0yp4LsotHMQn20M+4gjZxTc+pKd6wrHZ4Y9I9odh/iEUg8Ak7MT5tZOtgyb2hnrGcThQd+pG6YABNUj8v8pHGDqJIIjvPm9WNCgiLCCdzs0weRw8O5eNHcpp/QBLFnPLmZxKNgMil4GyMdqFgCMQYng9gIJxh4LYzYjnWQfioZYY2aXQsXBeOWdkyvHENcBuuj1Gk29gGOAaM75D26hrisrTsniSjw3e+IRvWIZRk5KZUe+wmHQ5xryybKMx25yWLslpqRULyA686hqXq3FSqChPbzDWeisLCnzZZoOxJM+ak1fdPKWkNDenqijHfI3SAWTnYp8rJauE/nc0EvvVaFWlX59rNufbYZOEtDRzUJ+akpqWrdVm6tKrIrWvRegn5Tm5RfVZolxekD0iLc1i02rVcvp4k91eV5SdLfGa/PzmCMBgJ9kpfQrjZmAUxKDSgOd/qUgYKBOeayi9PWx86qabl710+1id6bVbr54+TXANFu6CwlexkD9w2cSAPeNKkjXqNd/ed2hs66GPJ4y/5rKJQdu5hdy/gKfnaElwtSfke3H5Ga6ege0/qQMm7glVi6JrwfT/Sx3SfiBJOhFPxtNz6zi/XBEhW4AphtnGjJH2K1JFlPjD1oM6Ahxy5F4UzShCckZkJ2RymZyVc3O13Cjgodu4OSgNAYwZcivzmpEmoYCkTFigSoLEJzgEX8in1w2Zu5hxyIGB6S06YIVARWKipJQwMZVU6XTkuh2TZs0YMbywcFtn21hbidt5YVlFZVX/k0tOLDuxuPbrY58sHDbMmj+8Oj9/WHDTlAuaLQWW/AY67cmgWaNVa8iWBU2FNltBeAnNQCuuCLJqUneqWjfV43KNab7kjn2501M06ppg+9L6+hhTkRwgz8QOlntb6x2ONJXG4fJNcjrPHNBnlZYbDIv2Di/z5+ZsM5vLfdnZsReBxbJFkAND+ihu8yKyXjcy2lDWu2RdMdF5RD2zIDK7BHMxCQliSMe3bfqS3rgJENzOTfTGL/vf5Nv6Dm0i677cRNtVXZu+JOs2SfvxzCYcBTzuP8uUt+y2+IUcYLAELZyMw/MGsG1CftoYnwWMFkZZ+tDt/OfsAYHNF+UYdYLSfpSjRsnppP+d5xQD45sWwSmOB6h5A+yYpnDA0YE/YFhhAiNWA8zcNlDao6RIp51G/gVobBOXixgBqQPGY+gMVqE6LAR0bElFty1ddkc0Z/iC+6IPLBiRC6vzeOx3O+7Zu41viD3XsG7j7NqaWVeua4ihgEE1MEYD60sPL5n8Y/hwyLY/mmgStomcFv/K8E0KSpEQT+ntHrteLD1CF8AC7F5OHiylr9wBnDCKgrx3k5ODdhwwRiLgCgdXidI81E4mtDWK9ZsZikJJ9m9EcKSifi+PwL/qIyIBb61+jTFiQmdd8d3BvimhexK0M/ZcJHL05SgqQiKA4HsiEVzejKHrM6IFVOPf/h6OW0EJ45ggIg3Y7DRMFZ1ncju1gPvLktoZF9G5fiHNQ6sggelmfLqhjeSvv2eQSr8nBDRR/wmYAoNtqy3BMyUl2KiS2toSpZF/i12H0wOaFLfBk7pgDniYTYKFGGQiFVbw7gbiDxFEo2j2WEEQBhFmV1ot3rGqoSG2tP7J+kshw99ZP3NGA+X5ay2WjyylJZbYZsxcIImX1s/smVkfW9rQsIplG/jdDQ19UbhwuvUjC1xnnQ4XYr/oGJ3RxHRR/3p9jYzbvzAQq2OgNrGaUFosx/PiOem/Oyc1IZmNsBmpsv7siHAqEkFrHEiB6B7Yn69MVkcivc5IBLX4EWbccpplogO785WhLSzDH6sYZlYAcgYbZDuCbmCA7MAB6QwAr/FFgQtloF44dWRhZJR95RRY6ztuGzH+4QNAqH758MPjwrfT2/i26ausIyMLxEMrVrz38g3hBb5odOH1ew6T1HvuuXcvPfPcXdcui0ZDkfD1v/n98hVIo0eScBhKjRAGWLlCBR+KsMmOAJrWupJQoyOewpxuR/QYiSItHhVO9XcgkGEKG0B1NtojNUWYhU8URT0JsKMsIMa3qJnWY8W/ej7avBEfPt+R/HzfgEEF4BkEd8zuKIo6dWQ+ENxBMS4BRNoR9qx/0YAhujwtzLEGZjnjdBSqJGAKTCpftZM4sN9DCXxaKHuSiErAxkJcFMFKCqX93fTIkQEuYccRMoKO3pttGtFgMOTn+9ram667bf3YMZa86aFM7a48v68iPy8vb65QQjrIyJcGGY+XyMrSYSWe6tL8XKfLqK+5enxt7bwRZWUNRWaTg76TW1FdnZtbWZGTF5cZ8IekP4pmrpmbxF3IzQYaGeYUtNmoELWOOLoPOMwOj0N2hBwBIBfMvjhtoCU+RShWbZbdHoXMgEkHTDqRfR6ceh7JZfQlugCqMYoeh1EhNqTyokJ70ei260bXaeZkhWoWfLx99uK6P9cumT37utnLLn7m6dXhUJ76GrXZGW6aObsFKQ3ntEqHhrjoJxpHWd/JrCUmPlWVxmeQZ9Z5cvKt1pH0kl/xvxFeXlJvKxBkWU6fnjt5ZLutYkp5WW/vI4/0Rs6e7S12TvQ7NOHKMQ6Xe2p6Wmqdd2RkYskwMi7YIBamFafU1T0kaPUVJfoseoYQwh80Z1ejuWecL1X0FPkAXQq5IFfD1TO8jRbfkuxp5BWDb8Gj2HvzPlStuUjILMftvM1axcw7JGoANek1RGQG32WNHz6asPdu2T+8oBztvXvbUHYcZTppZvVzomn8TYq5983fjroLjb0bhbMoLkDCEoXkgk36O7P+Li8Yvj9h/N3y6EeN3j2bEU4p9kOMfoy9OerbmxXD75vGN+1hl05W6oAFsBMeGn9nspPh43Sgl1A7Uw5vHeZGIxQN6vy822mDCW/MTMj8VedIFDVxu+CBgkQ6oMJZrzrRNai04v/JEBN9XEGis5SjCWQq2nqMYUeqb5VCRS1Bdv4XyXkooRR7iP5F+JCVb1cUBuyfZpI3YwdRxHTBx8nFJxMi04QtA4MnOuTEHUBrhYFTD4Z0GaScR7LJO63nkxN01bTvvvj53ah4vNeJgpV8YrHwef0nHOrCArUCE3YyfndAv4+idGVT9PuJTWqKMolYNP58vk3az/T0IuJ0HUwNLIsivSt8TXaxgUN1P1y7kxCG65DWR30hj4o5qwgAPxgKiyGUAfAqmykTjYFUN0PHfvfAtstUHkORxZV5vcVyfabLUmTwqC7b9kDsJZL/9tv0z2/L6gfodw/dcna+YM9yWUqMT86b96SxxOLKsgvzz97yEDFcgle9TfIH5BbSR1wacIdobalP0g8mlFfEpRNdos4l6kXDmvpxtx29bVx9iPHuZAQZS7Nje5kpyeO/4p/kW+1rRi+57bYlo9fYyeWMg6frr+/veOcdlCFsj7kH+RvE7wjrUR5UCjMRuXmmRWASZGiB3e/GIgKpA60MHDrnAGVEAoXlIpzbGQVCJ9o3Bc25yM41/T9GBBuk09DmMyLccWAN6jN3Lnx0/apV6x9dGNc299AeVJyouta2TlsDKwRJMu+0NWtjMzAbwbvhTKwvag80NQXsNC0hA4c5lcq0ZWgj5mZWEg6jA4mxALMLS8hCgELTob4Czf/wDU4D5Rzt3RqNioa+KcJHzNop0ncogq3pz+a7ISvt7zsUjSqKF8CdZCczqIpVw/sgLgO6JI1lFbk1ruMmZoNng1kTFwszOhamG5HPERQLtrpimlZc1+Ahp4v5XYyvqSvuP8HcOGzFdeKzKPovqUUMDh2Dphl4KnYQ9szGgJyWVwBvEOduh1YOrBbBnkQfHcU/RxFPdivWeGytkhYahn4Powwujuu1zGvnnLpc0PYVa1t7v8M7RUPr2r5DaGusWPj2Z8P+MII8RU8UlT6COeRiVgIKXAq5JEfcc8XlZjYryMV4RJNBFoPiY0wwqKHjL+yEXMe1s8hhDQoUIUfHazTk8IWCjR0XOk4ugMyCk45CdgtkmqFIkSG+yb3F5m4B8hUc6nnsRHkWIFczPprESYGQ0SToiEmRvoc82BIiq33FvXnkgBFWhrizbASQ2Ivq2sI5+WLxdvprLCUPFVVm59GXpfsvnqDr/ZJ/wOVBBbvO0Fit4a/xjg+3pWhSdb0jVBfFnlVOyWMtKVRQdHMKb4qwBGE750pezUi1A14LDhYkAP25AF9Wk7IgzL9GH13gbwpHzB9lrDmwJlBGP5LMDMz23aywHJ2KMln1bt6sIA5R3bzs2Cp387A9ha5pa9ZMC16UF/tePM4AdOwqlvyo2KjhHNbAPHiT6c1xQE0ZJEkLoFBVcdoKyBCdPRga+CV0Bwm0I7rR4W3gF0q6NBAMwb2oY0j8Ek+QZjjMSzY4jIXOAldRSclFF5cWF7ns9kJTto6kpVIfSdEIJVW++sbhY0bfeefoMcMb631V9DDzYYqVwL1XFir3OitnXlLpxHsLcnK1cC95j/7Ey/GbmybeeefEJnazuM2/YbTZX+AsNOZk6mWDXpOVmWOyF9qdRTxvLSHeTFW4yldUmmdNt9nSrXmlRb6q2GHmYPWY/8rR2fE7M1P0+pRMvLPAWezAO2kPnxG/NS/TZsvMY7eytabg+zTUMwBgyFDJWYAPCTC+qLZQyXbgDtNmXH/31TeGTWQ+aUZrumivU3iK/v0RekzVBQChlM9wN64YT9JJpZFUA4y6P3ZU1VJ5F67BZUQnL5KOoBMiUEww01OIpHLYXCafjSnMgDQsJw0wNqgFDZlU5vjKCIYkOSgvmrCCzOg6TR97jR6lscoi7ufoupecHmtF1VWPTJkxoa36JnLjlykf33X/is3LS9ctl7LaJ2ltu+gn9B9HOx4W7+VvuVROz327U1Uq+B6YE5n+6DupZZ47P74it7FzdCrTG5Kb4vqQApRSI5CRDVnmagZpGNwJ6OI5wLGHntxIvv2STxF4zYyOjhmxE1Y+zDKvyuqNM/uvkIQP6M8S6Xhyo4dUbHyy4/czFdsFBX9+D3xLHmIEl92fQjgvceiq00guEe1+nnPCgcpsyhIHsJdJ7CH+1e/DuzxA531yjNxEwt9fFztB/Afp13TDR7tJ5vJll8X+2rZpU9emjuhH5C5yIXG8exk9ds239E268f0/kGuI+WF6rH3JEvqP266cOWPjxhkzr4zrzxXc6ky2jNX5gNZnbl5uZlkNVPuAL4Vd3OHy+Vx0ydGC76tHXz1i/S2PfvBBjHf5AQz4XL3tTj+/4se76+r+qHnkrmd+jN3ud4o7XT5mf4c67zvhWQZ8b51Pb2fP0MWfofMJk4jrf1z0ZF3rnZd0PPLmTz9F+U9J/uFRo7ifU3/37DH6Z+w/wC2KjEjDPCEUeSmseG5Aj017xOP9HVGaJqiZExMydP3ZiCo7FIh9hpOIBsb6Dek5wIj5wEsP48ZybTgrrYKvOswzbYAkSlZSHSYe1H9h3pc4EPRBdoFZzzyMCGQQkXgEN85WyVVtkgW0wPbogwA6goJDFp2V44ur2yrN6ZmXjWxup63phRdefmFhesbcy+cKS+BgWI1ydMm4Ta7w4Rvef7Vms25Ty4RNsaeWD28PjBy+VLu8cn9XsTtVqOp6uGq5dunwkYFLR65M17qlrKJZsydUjF22vnLsrFkPhrYuWrQ11DBpUsNArq+FPLn5mfmfPk9bA83NQuWuHnp9QU05Wbn3eSlV9/xeuqu8poBs+Pi2LK3E5sRE7rC8TlrObMvNBD3KNCjWIcxH0eU0WzVm6Zvt9OFbpgfnUV/sH5Zp1vUWi2rcX2gX2ftTTrXHl+/Xh1JrBbHtFvr4La3XLIqtpCUWywZ0Az5xq7DpkpQ8c6lpmH5k+gQB4M5dZJh0u/QEV8LVMo19hgBgOawKIRFuthIe4bGqHEclLOsZvE7AfLNJmGngs535qRa3uWX8rJYpOZ5ZC2YX2DPLLnnqsjU09tNnXT6LMdM7ZubiVVdc+qR17qzWuQJJy51/8fQ5Mi/tk63FlaHAMLMuu3rimJEZpszMSSPHHqex/lNjxjdlz35i9Yjdt+6+4apIa0l6bHFzWtrYGQsLC4bbLNPmTMxUdIRkB6OtUBIxYCGst6OhiJ3sVJgqYOTQmBINHoGw65v8FsqLaBpSkYr8npSyOtIB7tq5CuAsRzI7uCFcFlFoBpji4kCOBJ2NJIPwivPqYLnrPLlzma1uhRWiaUpKXneR0Tt3Wmf/xtXY1RimJqWYbxuaktLPSPaDpJixXB8/SE8J7UxKWFu7L57Sj1xPjRrV9Aq9x9XYGH56fry45JxUkWcqtptZzCcXdc8+ZkKO/pPVSBtZiRElN36UuyJhUkqAACIALKBM2h85+3Jky8mtSy+5ZOnWk1v6pkQX8R1dwqmuDn4R7YkAod93CBY9nCopgcui0f1bu2h3tKNr6/4oOXBRZzTayYkkyE2R7pZ1zP7SBW2oYr7hBcC2N8LMryCyRyaFCh7CfvQUJghFUfboQz5iDgkeBzkSDL618eTJjW8Fg9GOk19vIgse+ebbAw9/880jHU89debpLiJcfTS2rbfvnU0f9m3rFd89+XUHXPpWx9cnO94KBaOxlG8egYsfPvBt5KlNjIZcdaIi9sJx3vilL/ab4xzMrWR9cQoc6wCKJiSdboBgXvQF1aP5G2oyQixxeYA+NntkZjRWDCWick4IeUSzTkvsUUX0BgyFdTftQacbyJDTu3f37ibeaKxZamKysWyaptqMbpq7d5M57JysTmjte3crMmpIe4h39+7q3cig4BkmwNy9m7bvhj/i7d2tyM3ifk8J+1PjOd4YOPg2KxGNdob7SCCJIjWKxwcI+1bFrjXWzDgfkh0cAcmIIKyvZNYCR5+NPRT0/eqT7AX1SGfWL8j+hPHSgAOGM18+XLuMj/TpoI+AEdOJG4YuVOgKRRDTFsV1jOuZS65DUupQ7o2r8lGaiUoJFL9EVU+/hTcpYCCaAAwKDmZ6jybmyc4MRMzQEHRfP/sy3w3DEBEN/dmiIYrc3KCNF9ph1nGTmOxRARIoe7Q5g8TpCXKuDN5klspVCCPhZ1XJvBgsFz1hgVhVGYKWlKsAhK7YkfB227Ej4e3WP5JueWw8uZlw9vKsEr+juSrgrjS0lVc/Ex4774ZJJWlEou18XlXDiLqq1BSde4RwbUGFNVNWiVq1WjaG64aVpXiEKlbXjiH193qO/ECGpYZu2bvHJ5rcJVZRN2pq2zBDuq7CP25UNf3oiRlbpjcW24vMJb6x9eTtygUzLh491TciLzvbd2H9sKbCG4f689gTVMugD3rcbFnJOwrLCUwnDc8X8X9h1iYDEqDSjUc3bDgqvMPczNRQoDiuJ7miF/PTNxz96eiGvikoEWPPXcW9I4uyCHCimuGpLKRfnSjqDDFEFRbKAe/LZiKYw8SpYoxdwJFHiCvkFi+49fcXm24/Q0/QI7fe9Eb1/sL7Vl/60/HfXJ419t7PIa3ppjrPM+PPEjsZTo9bVGTePFJBw3y61DX+DP2C/pZ+/t5s0/gxf96+eP3r9TW6MfvgriOXQ3rpPPouP3oWVG/uP2gpUaUJ5EtaQF/p4WWAsRqYW68AvYT+GvXceOwvJFyyALn67Ci2hUNZtIdVdcAWmwksxOpgSB9kRC47qeXxCkAxRLkI7ax30iPWUtXeF5zqGjuvGi3r6+hz+WUyeQMmhqQ35KV/aKzWxh6omii5ikLqg2JRHv2NJ49uNXtTUsbQMTlFqvvSdaoP6Xhek5vj1H5tKDRqBfF4has/hz/xtLPwqHlUoXWrKqMw11Sd03ftBK9HaHG4d2ndFm3GLXnm2PzGi4Xl7LTRYknlkn3iVcC94CrSkITDu6oFQVisWfUqk6Mg6EIQFZeYoBw84QubBVTgBdzFaLMKa4qDNcXxRgM6wvqqnZzrvI6vqn/n9iqGBT9ze5WziJvT+UMwHOz+LPnoffQ0vYUuo9vp6X3M9/Whd8jlJK3vE/r4muxMU/atF7uMG8jNf3mChK6sXa5RZ6c4VKHRDgf9ILsYjuCKnXM8V3g82abM7Is3CxlpqSZZs/Tvb/+z79U/0e/Hkink74S//qYNK/IfFSxkN9Z9H3vmOw8xZ9d9JM0l7FILwwIklbz4xyvbNRe0ZnlyKzJrpbm7R/RefLEwiqhVKj5cR9IkQSD1YaKmj5fbrLMmb2p+5dT/0Euu4O+Itawkh4n0+kP9i8n9sdFl9mnkb4oNZsJP+oLz+RigPuY/KkMjtMAQr05me4M5Wc18ESijP9A59F8eofMmOyY72THK/oD8KaEfldTVlZCSEgw68q+PAIsoOaUU8IsyZyJMLmXmcoFunczNVLxQZcEu+FCGkOy14NCL5xq/BuC1kLYBuAGcAkYbgWUH3IQ7zDcCveEJk5Ds9vhgYrlVLXeWz8y9iH75/aPjSR56pCq4jTa+HSGvYS6O8QQPfe0K+trVmhGBphtsophKws+3TutuJCpJEnj7tuG+4Zr/acn5IHe8ShANngKSEWuOoperUgcw765XkpEnTVvxyScrRmwbluvMzR1rGl5dPTzD47anprpyh20b/srojR2jBB7x0a3cTrlRbkrYs2iISZKJqOdCQRP6MvEeIkbJpGLi6nfHWncIj1Y6rqWfxKbcyD9GtXxXZ2yybKBPe9e7+507+C7hiSqXim6OTbyRf6F/O/8snMZnPM2tkgvEKGBZC+o+OSY/Q85RSxQNQ/IhZ+P0HmaaK2fxSw+syR8b8c4wGvP59wbz9Hq+nLxxUWcLvY566XUtnReJ0TXT/JWGFFGs9COZMJDvyyPNRF3+Of2BZH5eTs8gHYO2BsfF4wOy/mRLouNo7a9sgLUHrX8UfluhefUKtZuYJpCTUKYpNUV7v0NxIwp1GUZqQeuNrg5VV0dX71ZUWQz6POmgL5iWYWgt+gQSNAFvyoLgYIWYQoU/xn3qvNGkOtGCH53n+g7BPkknAuvXwvkQ16l8hhSSwQPZIPMB4JBDesAGAaAhdHarUECEU2llu+4+2T6x4447OjxuTcHcizevXDWpqv2rh66zF5LTDFYbRv36zjvyaVp+x9arS0pktTpvVKD0BL2c/u3kzXP1epU2PKHzzv/6bzLiafSg6T+typq06MV2lbasrDE/1qxUFde9npb2n7/v0W5qQNNyTt8nvdP53ujfvsP/1lpW/1lyVvxY/Jj5g/ED/mDix3Qfmb+d7qP33ULmsR2ZL46H433bE8fzbqH3kXkKL6jI6gWgjqsAeqJedl48NkBcSNkIrGCAscBxk0X4FSRLNKsZne9hJy0D5tOoeMVIXqi2VZwkHGJcX8909mo0qel7QZ+RkZKuEkWJyKlphQ6fJS9Xq0tJ4QnP8ypAX6npaVq9vlL4iabFTt7UEAjkWwy5lmJP4YiQv7qmsjqYn+nk09UFNn+gVtiSMGBBD05VF61LTc/Myk1NN2bzEikrKwXsnZZlyM7Oy3JpUjOsQpYeiEG1xo0qh2ltNrvfH9okqqUUWZYlSdSkyEKKit8U8gfs9veZTUSUhT4BynmQP8J+C8T7bSG3lMma/g99l7Bh+L/0HxnSh/2W/7QPy5XuoU8O6cdhvnP7kT+SiASAxsvA6QI38vF/1pVEYp3063/fmcvZRWj5o3To4Pov5qbD7PO4ExJyH3OpQY33wI8ZC8R/hBkBJQToiTMYE0npOrOsM4d0nhDUwn8qAF1hMlnt1f6Gxc2jTKZ0gaTI6enGLEtOiaeivLgkJyfblJYha4Q7qi1yvXVV6IJV7QsXXnbRCm97aWNe+fALKp6Z/MjIRfObH/5g6lxxvT4UGFZZ7fQYzXX10y+YrU9x252FMNC5Jr3eaMl3O12efHvsgQuuOavS8DqgqLRpaWlqvTo3RZ96dsvU1QFL7iPX054VK4j3+kf8DawfDgO/mgew1o5wkLOpsowGBBoZBN4z7qHod3vKVQF/lh5mAJInuAFEBrJFmEyqiXBnSV290ZjjUAgSR446b3TAu7udb7OV5oQqouX+nFKbvOJOSvf4O1dHLFb7smIlOlbxMnuqZ/WyG/x7CN8bmTkzUF8eDFTUJ/GM+zk189hiTsNEViOzElGY73ZVCzMN6AYWUokZwWzH1zMbSAU+ieuZjRFeLx5HNpddzQ2BlVC/y6FDUCaTITVGUdzPzPfj/nJkQI/N6oc7kipVQgBF4q7YQ9sP/YZw0kOGVCl0MuuHZqBR4vUPbT/ckVQp4mNyml3+i/YDnkWP6hAZUuXQzvpl++GOpEqTuipJjs98J8zn9dyN65r0KAY4j+cuXxF3rDyv1y59g51UvEHiPo/QX0cH/QUGLELRPu3omcrEhr70zH97YA/XJ8f6Qc+g8cDjXKZEpyDQ6AwM9FOOIX/CJC5HSCM2J5eVmYLHQ95LLJTRQUhmUhlRCXoEOSIjFeDzlwO76MlA3sceBOLgX0XZ4e+gm+n9P+/ezf1M5pJryVwO8j/HqslFpO7PW7b8mf6OHqC/wxy/d9rYtfeEFlz7ON2z4fHH//HE46TCN2J+hYUXrja5qgKBKlfqZz09zavGALwUELxOT8mvbZk80vgvowv5dv9M7//F86uTn0rqWEtcZfkvb4rMNN23ZMPjkSf+8fjjG658nKbW6S9cMLvA2rJp+ghnjlogrR98oHLXTZg6dWxIl7lo/8IJhQYSt1uPz0Ez9HsFi7RnV6LnuZnig9GsLIKeOOCl5w/qf5EvZUphBlNQEgrl4uhYM6py79O0hSPhNs19cNCfliS82J4ULuxHRTu/Mn7tSjhg3hMWI1ZhtKBLRVwW3JOUJk4zKxmU1b4nL5ZnAHedy5Wj3RPnLowHswyRoDn5wK8nqIrBqFQsrCGKS2XiL+crgN4yGkzw5kFVU1uHN/a211u+sZQPer/3biodOCptJA962zaV0jlPezvavHAa9n2PFVZV6XRa74SJNbbwWIm24e0dXi/B+1d74ah0k9fLl8D9m2Lb6By8iTz4NFTk5QNefFpP2epIW25uwYI/Bi9adSGsi31AR1dLf+KmcBdx87nLuWu47dwe1C0bUNthyJDkcjGgvATzHUQpDzBmis1AIgJiPFUGSrkAxxVyJBHuzpSIDkYko5Xg64eAfoABFf1MACNLijmDmFA0wrHZh3m4BvLSp21dZ9sK9bkV7gZHvSZ1on9CeWFh29mutkUrtqqzOhcFdrl0yLVhODXYMKtz7qla1Jml3lq5xNJ/uzuMI0s2K8N7WM/n6yP6fF6v1Ua0RKPXZtKeTK3eYiReo4U+iHuLkfbAfkMEs7gT3sEH+kdcMa2lrMrkkNSVzqkX7WrzY9NGNj7/VUXguq9b82ultfvXVuM91coeDqWGnNavrwtUfPV8/vAsckV9UTGDfIqan+py9Xl5eqMptdcM6FgH3MnXCosSD/EWtwFBfqeOG8nktCgWMAZ9unj0SYsi+2sgkiMRsjKeFnqMcUmgomlMiIQEW/T5K2atxLBPrTj3fVXxBlX5MEBbV0eUr4jH0wFcsfqFGTNoD5rgEJqOS+nTLOYgG1X2WZ8qsoVIRxdiIsVggfkgJWTdKZwRIEAVN5NZLvgHHEVdg1lm2RI3bEG7luQj9C6Nv0chtN4Rf1t2q9nKV4dRMMWxRAjBSYTVAZ0VHXOEzkhRPXY4NE/J0HZUv+BGdg7mjtwPUEBdmFmohvT+I/fut+3p7OjcY3toX0zcfOOdruaFY0ssL9Hf0E76m5dcIzbNdOyR9l+8ougKr6uxviiRiR0lc9BqiD7IbIcG8w0rnw/8hOCElBJCP8TcT4HnV656yp/S5HYPT/E9RSd7win6qhGBMtqz8vnly59fSby14ybmpIQ5NfM1OM58pe3Qi8O5Udw4biI3FfuSARUVCy7jSj5QbPaVLsQF5zrnmISMsgs2MZ4Ky50+f1aWnF1f7p7xzAy+bchh7BUYZzbYxagJG8ijqxu6R8QOKqm4w7Ns7gU5uSmF8y5c4Zk/YcL8c477fkb7qWRbqnievwYjJDErbyVFPvdVwB8ZspEzcPlcEcpVMvjCcqCTYNObENDoAfEiX+KRBIApHqZzlk2q8eT1yu5jR491V5JXaz7f/dOb831rFv36ZRqcPWbam3sXbp29q3fi/Im9u2Ze2HiXWNL/9txtTU3b5grVs5epiHP7kSmLrPRP5TTr0cxLDk+LfRaZ0TVjoXH11IS/fVS6D8aCSQWAC8BYxw4iAQmMLJZZwkDSkqzXof1vmLDwqETW6ZlEK+gJSpoLJ9qa6t6aQc8spf+84IOGJtukC5sn8BrDfcuttW8telZvGNt1umusQf/sovcbnSsfNGj4ceIl5QdfvWjaYjVNJ/+dtmTmRa8eLCsUwnXX/BSe4aHX8cH8U52df9627c+dnafyY78lV9vnNZy9tq6RT4qvko7xFDgWLQRIprAABKqsdwmeeLSd2w9+9c6zgeDZlw1j3usWztCbyZrSP2X37yp/007W0INF/Dp+u6xevGuXz49aRUPzE529TxAnyXZdS57y09pLCugp+lUpuYvO486Js6P9ZZydfxdj598F18FYXUKn1KRqYRQh2pXuZEHzWqKK3d2FzD/dxnnxLKAhzlHo5AP+MM+MtB2K0R8KO+yupDBd/AN8voZ+8NNeembPrD09a764/57ZN+w6enTXlKvGeiTarXpn/0P79z8knPKX/pO+eTdR37OmZ8+s3bsv7Nl9R49/6iTn6/sfggv2YxumkLHy1dJWTsfsHatVWWaMyKrEZvUEnfrCct7jIKYss0OJzmqWVEL/r0jZq9lH0dz+VOGP9y57Mfz4fKK7/NrvD2/MApBS99fagWL6g7R1H/37QTQ9vOP1ua2vtW/ufXn2/Z9tJjtH0p9Gxotg7VQTn7RPeuB8MkkhLpNcSbSFxNr/RaznCv6Mx7L0+9gHl/IldCVfvjz2gbSJ/uCYX9D/+RV8Od9XZBXom7H3L+UDMT9fuSJ2VLHtAy5iBfOJVeLKAXBhVkJ+DWGWIjC33MAFm8zkOrGsu7v3D91CK/+gMc1gHJMTeyP2Zs4YoyHNKDU923/42WeF8c/27+eLdTV2q2ygm8m1QEPYa3TJz9GyeL/nGmviKoTXYysRYx8Dvw28kbIcNSQor2gL996AIFfcEG67Tiump9BlZEuuQePW0AkffUgnQMaQS7bQZSnporYoxLfzl4V4t9CJ9/R3wF54T+vITqHb6DKrMZVXkzWvvUZvVvOpQMzsJlekZDu0RRVUTc5UsPW2UtbIc6CtdqWtMiIqaGsI+gTWQDkPyKqAiBwkZpOsWdvaNxmFraqnp63ZEdsfWyynaVI19rRUfi35Kj/NmWMXLhcWXDjVTh32Jy/q33fRFDv5zP4robl/FnlX1Fq0manoa32lU5uabkaf+QG+zMRs1r2Mbz9XQ6qXZFeYENHt0VtJwgpXdJnMQjkRhWBIBKB13rha4++YV0ZvDhxR6enNZfPu2HiEqphWqf85soYdCwvgCrImcOR8XJ9qUuKuN+NXxQ4yLdRr8Wr/O17LuTxmHsL/X0aHcsIhvBccEIzORFKJzwBL/LyhovAFDA88QL9jNuEPkPYMDU9epR/Mm0dU5w8dJT9ADMk3kfYUke8hjaheJJl8CZPFJnAzrjLTL6MrsigfdoLm8oO47uvYQeaCMzS+RN+UeIjLNMVOQOGd/n29Q4KHq9b0ZzNb4nMjhSggktU70KeWQe2xUi9qn5S4B6iLGvqUeEQLmoY4PxtQP1pH14kNfVOYMzo+j4VNUUIcRJVg94pjE8YeGLB1kfYPeCudL04xhrA3s3g7CmBn5ClNYybRqn2IdyIo/8OQioAF9p/7nYM44UAGZMjquEUN2iJJTdG+Q3gt4o/+DtqDWu14TLjE9WJCcq0CAIKexygfOYhiF2YCHo872M4cTvg2tPxm/ikYM3AglkQ543JR+IdOaEBr6ZjLCwa5CgXRb2jgOOF1LB6PmTqWLK1vaKhfunhTqaVgSoEVdxYr7hYWWa3WAlldH168+MziJfUNsSeKMJh9saoL2ANLQREMvRVT0WDNL4HsEBhQyF3CreQ2cFvOu3qCWQm4YGSNReV2ZgYPRBQQKwp6CjIjaH0Qrc0yiCkUtDJrNCNDpnJWiJ0IOokvaCXsBDp2cSz8KqqDfdViUt4kjCbNCdsp2k0/ZqutGn7Gt9ate4t+S39Pv31r3ZXFwSXkVzf2Hlq+/FDvjb8/OOm2gGH9rGs/y7VcvqlskWcJn5o+7PGsdF2WKSdTJaUCjK+5pnyhJyIIqeklN84hGrpYys3LENJTycI63l2+bnqoWVeoXVnfyleY1uOBQ7uivjXEVv1gO4pZ23ovW/cWMQ42ac8XLzUMWyrmQlPo36FJl6laGmqnd3Vc9URJAfkiQ6vS6nhrPiEqnbk8WCqQ/54N5e9lpWeqUrUrN9KPidpcMrKSJ7Tq2tvep7uObm2d8EjTjG+WKOm1LF7QuX6/SpyTeJBg+zkpytgRUEhNlIUQhNl8AoN6oCuw4hs/uAfOK8Jw5/7z+l8PxGVJpPpznpfws8bIg2g3gGtRVvcdivSfkNWwiNoxiBdGM4+iW6O0fyDMSNpA5F6lLT2R+F88jpCX4fOELA+eoI/HfkYv7ogS9QNfDW9FYwW8UQ005Wz5PfkNLocrZjqOGq6BcUPoexsmODPZl1sIyl4UwYtZJiEmui/Hr7lIKsVENijK+L2EoZvqwLbqXcvXtZi1WmmbxdK/1DrN0v8T8P13WabNrCXf12ZrBClVVblwXFnFclJSWzu9tjb2wRh+0+j+n0bzHWP6f2L5f45J5MfIj26TtFpzy7rlu6q3WaC2JVBbimWaVbjTQmuprnbC8oqycQsrVamSoCnC+qbXDh8du24M+X5MrHM0+X4gz/bXjVHsraB7gK5OYxzIgKYTmWYDJxt9g8IztF7mEoZ7eIGSV3WtObBmbev0K2CYvvo4iiaJzHGlOPoR/RNyw98+fOAbTDEqz7Q166Yi+F039TP6jPMDRTz2gZNM+gzvwOiGzOUF2jWdWKUO6V0YUQ/TTiuOUH5nI1Ex+5BKfZYsIYNaKfMepuV3Co8pcQR5Mv7hh/nbT7RfWjfLq5s8szUvb+7TZTq1u1Sno03Su20dF17YQTssblGVOtwy2migv4/FdPKie+4dNuwV+lhmxsOx7y64YAIXtyVVZCUol8Y50sDiQXDn8sOJ6F8KNWlMqDKS6UpYD4mvFjgTnhMmWyiD2NyqrkEe+Me4yzsGeJw/iv40aj6Lq9+K6CvSu5VvY2IcMk6Jav/WneSbOzP/RN/9E0qqGVLtgT25QPGE92DMffuo+fNH2ZVI/Gv5xxAD/TjouVdnnDy5BQMtqWAtZ8i/lQ9z2Uw7U89xepQ8hwkXhi7mtKRcLZ7nMy/nfuVFb3r70nZLhKSf/HZjppVmn/xapa0uGxVsLikTv6e/e47U5Vzocmf1f9YmrLii6s9z6A0bStfPKN1Qx/8QP5VLfydenXXmitVQi/Yf/fdrdPTWl38rqC3Zrhxrmno5/d1huDLL7brwdyv775ha1bShdMZ673qyfs7f6K9IXS6cacuhr8P4pcXj8aEtko0bH5dMbuZu4+7i7uMOck/DSAoBhakwCtD0MAESlgSR21bJEsbKcgomM35oSALqGuad3mwKogLOnYFazgIiKwUeZMjFYEhfTogeFXvIPwh6gxk1dmjLVocwkQkwHTqfLCLjaMMjl1lS6hHQGsrBrJlkP9bjUpyCQwbElyHApnnEYDLDBfLRhZN2W/LHTF7Ya10wafewMZMWCa8WOm5etJd+OAzTe4g3en2TKrtMk6LVaDXDxquLMtQZNY42OUVUSUDc7oECOWOYQ9CP6aI7cgKqsWXk18eqDCo5o8C+6yGe1NdXFZMJx7KWjSRnX54Gy3tpPnliKQbN42Orb08l6Vn6YZOuK9ZIak2dS6vWT7Y9fvGl5KEn0vIdh+a1rpJlv0CrV1xKSH1dhXiYniT5YydN2p1P6Ek+l5jzx+y9I58U9N+x4q0DrtAt96x4+4AzdAu/pnIjr8nJzm8Ml+SNW0juShXyVdp0pyBp0gS1+qHXyT1KCZGD+WfGBWna2DfpzUQO1aTkXDTz4o2kkh5R8cYsK31oQtNUQBZF6EhIKqfctXoPQhZV2t8CQjbhyd3fkS0C0WaIxPJVy2haUvbkT2GLLb9t/afzD1SQsCFXr6O7SS39gAgEA1VxvyE2WS89waJWBYHjzfK4UQqDk0SWsswmTjj1A1m6eJ5++s6vFxwZP/7Igq93TtcvWEiWEttCMu63vyYtq56ThclNTZMF+blV9NCvf0t/DdjqAZibZnk+cKEjmb2TEo3NgT+7HmYbwBDgPQWHR2JaX9S2J/TuuNQER9wXHFljSTFMFYLKhyPwWLkpTGTziOaCDZMys6U0KTPW9rmgSzfSY8Z0nRC5kne1Oqbm2AvyJvNCp0Gl0eoLJj42oWXdV3xt+Yz86qtrr629srIyWLdhc6fVNsJZkmYdltuYU2vIzk0pFzf/9eO515glno99mpWZmanT8W5eZbdPWrVq1Rwnz+enqSQpRW0KjGyOxvwZw5ZEL1725qZhlZn2R/b+sad9Hf+VlJI/dvocr3NqutqcU3vxtAsdvmT/1KE0BrPGziF2HUYk0CdRGXYl0uHZl4F6Zv9ISeOGrqgY/EsJ7cPoBmYekKbEbcMQLUCxqwZi+KrgeXnKV0hYcDQi6BIKBUZm+zA2mKiTjRjGBj9mhvdHgFamPUhDFxQRL6RK0I92oKCa8AkYGEU5G7+qnpxGcSSnTnru0FgbyvPNjIxhltskya5EZPGZ8PnAQLDAIsgU4QsnbKQUlk1pQUSJ4zhojDBo4yEN2D0p/ZyIPJ5k/eMS0f9Px2w7kKRnJhs6V6KAEQHYRUnWQk705kbDbkkTO5iVmlkQnlozbFjN1HHDhmnIf5cUX1xTc/nUKZdnZvYPU8YgQWfi9no70OLZNJBRM6x16rCayiogWi6l+/U1w+CWy6fwz+RkZsUejdOi8jntz2MxK9znvMG5fG4ZObexyhd14sE6OxjyJBPpszBP2s9tXzRZ0hxrjkeyUMyh/n/h+zKHzAn0LzawyLU24K2LOC9XyWKv1WM0Sk1CXS0yktrByOv/S16ZRMBTM7U2c49n0Xz/o2zyDIdOiAwGVjlvEo8hl7TOshIxRhJrjQXilX0hs8+TECC54qxD8nJjUXWUmmlMcaHZiTN8cMori459KAD+iFcJYaAwDdiOlH+57hgPc561Z+HtLGSUK2kpnn8JoocS829ATyXmt3H+hRg/YtmElRA/pH8G+iX55ZNfMSn2uAr4sszEHZ6QR0PsGoD6snIrgJsoexrG9UFHnoHBQ493FrKRhTjGWSwMaUNZ8ujAMpdVv4AGAegUN5NN4NEQuJiWoqOr852Z3hpPUZGnZnhBE/HOrPF4ipqhYMhgUV7UpaXxY2S5jD4le0qCoaKi3JoQaak/mVvjaS/yeErOGTf02Uln3xIwAffmVmJMKS0VjSGzbHYl7YXqIGDICh6pvIT3VsCf3Fbafmj9oUO0Z3C/u+kSDZ+TmvpmmSzOsTR5vU3e5CZXRyPVkUjynrbPG6GbYrOteq2lbsn3ZQW2sjJbAcCE97n3ZSCKlXj0RPmGm9Pj5vH7baohXwfx3tvefu8+ehG9aB/LkQPkAP2BhahjkbUl7zknMdd7Fkc1cRHz51R4f5wROdgr7HsdPthEu1n2OLDAEzIj348QCDnrKFrlYFDg1e2Lo/h+NA1yZKe4jn4Iy41FQP3k0O9iI+EQUiU2WCJeT/wrojoPzDxi1+uYZ7OMIVnhttjR7fw8uiQaxYibUYSl/ScixB/7YDs/HyNARGPNqhbYJdkvYS/pdUII0Lxod5l1drOg00N9sssuenR2yfMlRoLbRNYBul+HuS8xZNwmeiM0/EbIiWVkXe/WoacA2OKpTezWIf4+ZsB5v5Bm/2fc5vl9fd77T1jQ8znzqE79p2xpehzv1ULrPUOicU3mpgEdOYu7ZPD7IUxGyMSwirTQblTEhQ1E+RqmeM7xQFQ8n9GBX7ATz8mLjoCPbfFvjHiZychOlvR3aDNKMrTadG+6lu/OyCzKzMjQlmgz4t8bgX/cWETzRA6VvHgkNSEujtSXe73l9ZF42mvUQgXGXlM61GnqNUB1mYZeIzwho1eryLZZrLpI0v6cuPoDFNX5omUnRxBOjpTNn4w9Im7AaMIsGRpqv//LgdjCXwzGFhYHfKgGv2LF6ZUhiFOQRAmUphPiSC2Cgi9HYRWtrCp0YNAsNImLKm6A0q7egLh+WqWjsLCQHkJvaxSLxUkN1BnfJI+StwAvy4VMYSmE7Gqw2ooOvh7mkoZi1AwJo0ghQ2FVyUxcxdjzDBZHKimfQqL5nV0ffvJhV2eeM2fWWNuo+uE14aC1vMyYVlXe6p2b7mybO5wIN4/K8Trz8jNzxMzW0KLxhBTVNpammibdd1fN6NkHt2vl1BSX9qYnxjTee6VWSklxZa65e8dN9+bp6pZcub3zqvL6e+4Zb3RUBjwZ2uyNZbkeU5akIRpXzZSSUZvUgqnUM9I9If2LsaUp00IFjVX1wXGu+nHawrKOZ+akOrWZcuqcp5eu3TdNyU+5i56kqH4GeskLhMV+4O//13iQ6K9JErMXtv8ojxG+IdVhXvkykTJ12Qbz93/NI/OBpAFOTYz5H48GeZ6kvwMXAxwotCTHLWRyCzusak7PJPxxQX8C8yYWLn7/zRD/nAGwgnzAwD41XXjebKThmYZIfHdRWzxLe3q/Q6wGeGAnOe2vdDvy0mx5ltpZs+oT2YsvSmSrfMKp0tLxm68aN3Q/7irF0vSqfr8Sa1F25tlqiqxet9lYwnuH5muLCjDvVHPKtxMV3ybU5RRy5QDNLuS4gD1g+n91XQtwU1Uavuc+82qamzQPmtwkTdKkadO0pE1DW1r6hBZahD7Doy+20EJl1wWppeiKghXE1bogsjIq1OKs7EMcH1utKOqOG3V12FVBZ3d2cUd2GB+wKI4IzXHPOTeJBd3p5N705D7am3P/+z++//silQztC7JCmHTaAjJfxUqcTuFMuJZA8jImPB4EuApqIqBoPLV5MxmMXDfKnLv42eibY4sU+bn7pv95bgTbkJkzXHXR6bVBZ8XTbWsb4LTOn4biZDEHLUFFx9vdGSaVxyge3NGQq87Riyp1qX7jlduMFpZ1m0zvHVtbr/KLeqW6KZa5oDP/0LufAzC6+cSO5YItkxC8z7y1tiFkygZbql3+otMGdGR0/DRe1PnhzlKPhfPkGDnW2jG3XlSq1H5x5enGcAbrRlaZZS3DtUPoyCq/fjQZXyQxvpipQRSQdUGPc/LMNSqBETl6bBOJMHBpimiAwvf30/fE4HvoyY3d/P3x4RiKgPJiCT0G8EuB5ytkvR0R/7jFIhGwf5Cp0zH3OfsBGESuwSA8AM5AJ3sMOsGZBN5YjnW+37cIMy3hHlxcnMR3AX0ZHkB7HEB7o73QUdARrtkXffMGed8Yc46Qc6El3l4+4/XbJs4jKGYs5CTn0L80mDxFAgON23sw3hg578gZjOH5jAM5TPWLb95EHTjFXRvEqCd5W2DnM7ScjLFH84UPFwcZMq0MGbi9NznOysOk2m42pU7Afq2QaqsaSzyeksaqWkmhULvVCp1BpS8vrMy1lzZ2BhQGnc67vyDclmkESqUrTRANvFSS73Lll0i8Af1XXsMDpfbkH8osZbSByKoN+5/Yv2FVJKBlWIfBq+AUvkBz5231vZM9jWZG4fXq4qcWbquvTENhphN9Tmv9JSsHV5b4tTQ6HDpo1Y6FFIZdjxOOc6I/humccLWHxJt06jNsP2UUNK6cXEpGCwk8DHql+jpvRHepH8Wgq6kNqeypOZE+TXBJGABh6sBoDQbDNXCiQInzpZjHA+OtIgZcvwMmOSsaSaVFZWgDTpdXoOvLkabFpOCEcHJt8wGbze0hec/mpsWSzeO6YR3z5W69yVQY1xX2iLv1gUL6vyajrzq+hL4gadPUu1WlUlyUrOrdQo5ZTb8QxgnNttJyktF0+EKNxYyzuLFVf/WZgKOVsQQcM2ccAa5Fzlg2Ny1JpSzRqZqbGiXguPp7MFJQGEQTVwwUwF1zu0V4XhFkHPCC2maT4C6bTQ306KxgxGS9WuHHecjy0jaSiFynqfbDm7D24lP26mVg3BGAZ084AgE8J9dRu4QW4RbktZdSDbhDBANOQCVnRwZMCewsLyD7TQO00AI0A0mFCuMTK2kf2haLIUaICWSfN2ZqDFagU2dpLWlGvSXdiEzBlNEfzp7DGbKKO23/hvf417Q35Q0OrOmtsoOpYV11rdO8p+8myZmXbrlqMKaLtEmTqwJ6f74/gxvJsOZ4rMCgdmuNDKvSaTOgFkzZFnT1DazPb2od8MLv4ITUWWIXaasn7DWCqQlzWsBpvrfvZoezplqcucuos8zR2tJyVEDnE9xGmSuToj4WThIesnI0k4aozRSFe/wJTlMuBmeB63uJEh1Dicaja/qOMHwe82ynmoxCs3dBG3MJMjI81XyVgJJJJ1zCySWvjPU+mpPjb9hsmVEx9SpAM+iHVjAapTZNrzcZ9TqtRqVEzw4a0AB5OQ5ngWS2aDXg2bLCgsit2+cVFlitehDKcTnml+bmlJU5UJSpBrWbDh/eNLQsOxzMGoOBgfGBgXF+8uqysVfWd+jaapitFrPVrNAJCrPalK5LVyiVCq0mI12P/BuFwHJ+v9dmVanF9PieTXPX2B1tLXZ7QWHRJk6r5HmBQ3aKSdMwwuFPDjfPqy39iX0xigzxKQaoRD+jmv+YqqYaCastQVEXhewMllIWcNHOjEFOQRpfOxVyRov1aPp43U4OK7CbzEEGb+ZJ9lwwKwtc0eVgXqzdv7R9UYX4+Ftv7Chb8rNXPS7l/HKh75GO2pqN+2uhputg7NSGrhXwFfiNrX/7nsVdR0stKzZtqfr56hqQSxcSMkL+Y63v9P3NBwyhpbcv716hq68sO3LQM/jysLcGnoZ3nj0EQhffHnOnvzY00ROsn79sS4XN3bVrpoiEVdSsHIlE+E3keqWbSKyJ17U7F12rtcYeG54cjuESxizNNTo6S2pNllWTJdZmy65dJ7MmP4dNhC8Bs9+VEFealen/cHM67mbCnE8lGJMF0GORvay15man0ZLFJkYLQCA/0h8K6UrsMz89JYEik67k6nmclKGV2qV5woobehvSvZWRfCucODzhrWR2SuCNgN0X/93MrSTOeFO4kX+csiAPN0jVkC4Is1ykxoRCC4DXhyZ8VsiM4j2A0zQRIuoCMHM9CgLRzZEdMZnRKsvli6Dbw4M+d3mV+F7jp3SSdOU7qc0mStJjX9yy9auLwPfUkfNSWzzqcjybMcernjvz98E3tzdv/PW2rex/eh+Ook3gRx19Q5Xar8HD6+u2Aj5+Ej04tgzzY6LUKl2BkoTXhx768psDD82/IMGW7KI87zMGgQEs3PfCyPbBnYduzumIru698xm0hX6I+/KlrVE2/jcwPrllWNY8XIPiqg2YZzGlGul2eXzZGE9C8FrYVpg50YzzKdOg4eyOHWfh1PTncOh2wLTDByaA8fBh+NnEeLz9+fhvjt8B7hQ23PcVfA6Ow+e+uu/01IHNu44g32k+MB4Z2/xQjH7p0SdOIHv8C2paaBeMlJLKlFUbvE65ZgcwEQgmMy3RI7uLLqwHF+6Qucahlp4bScj3fHr1L4v6fAZ/ZPqd/vs7Wv3b9x5iNo2DqtYwGOpeeGjvdn9rB3fXkc9wdfxT+OecO/YeWtg9BMKtoGp8Idox7mrtuL//nemI3+DrWzgOT1yDXzNgNOD1CBxgyLICUhBKJOhCP9opNd8NP3R/lO3Jvseb7fXu+nFc3gf0WHwUHnNXVLrdbteCCrfr/+JKkjoy6MXNWn+vHINxHuCSTL4++31So5XAveVFstdsP4rpyki9LVzJFoVYB/qGcHADCpCrFtDOPfjIv9Y9Drq7uqFmdCDYaTTy2liC3mJOLF4dX6QMmRZZLOAiOd4lqp+7RVhPFODEbAb3GiKTyGQxGcgC0mER0zTitkPkGu0AXdvAaDeAvwV1Xl89PAq6Rkf5AQAAhBkPrgmt2ZcBIfyuGe4DNzYDdGzagEcfvEYzapYWBcGhzHphebsYiY+iieU4qU9dwlAYzKKPswIYWwcuYVgO1Mi9dDR1L/UnoUDACj7Y5sgzDnmlFHILiCtQggZZuS6IPASv4Gd4baalwqBfFT+9LdiWWVB8/PW8MTD67e6almxHeWHd0wuKQF3Tex/xQ0p7wxyzhufy4d13F794PBLMaM0bo4uv/DVvfV/XaldIUxv5x6KFC1SkL1iO1ZyzdB+c6C/yk1xxQm0VBSVc2G00kIZtjiyzQQI2J3KkCuE2cnthO2xvxKnHfjgEt8jwuZg1Nco8lnqLazQoShvBSxQgs8diHEaR72kEz8PFn8AnwarFoBtOvHv0KNyYGm9MvYslNe7k9ZWkvgH1IuEOnEzoIfHErWdlmhZkK/UEZIZ8EnyRAebToz+cbcfh+0k7zvzqlATfQXac1aNDX2/GQTc24zO3SrAMmXG6jdlJpXjnJxN4JUxwFMZsSfxkQuYYU9GStawhnMppmROZbkKMlLimifdEnhHXY75fkouaXOIc0o+NyyoohDsNUE9QfxRyhVb0ZJGz1UBLphrJWAM56CEPG4KHIqYGS8FioESJPOAjFJ8JolD+yZ7a2p74gtWXr/TSWgb/As7XvtwStkej0CC1lkngC0mytdmgvtbht9QUtRyvo1/t7GzdotFkm9FtanQbjK/xr/XAOIQ98Yqu+vIoUDM9yBOje8GFOntOpjN6OQpFqaxVAhfQo0aSoFj3cktRjcVvr6Nfj34bXc4BwJns7XajwHCqFE8r8T1x/cD5QzQsJ9+tuNaTEKdApio/Esm/sgstueoEahRNycuXq4J8IFjFT0byZyx4E+ZcfgQHvy+h+7quvz8wbx5F/Q+5ZZ0FAAB42mNgZGBgYGTsZNzX+iqe3+YrAzf7BaAIw2X2ZD1kmv0CWJyDgQnEAwA0+QnKAAB42mNgZGBgv/D/BohkYACTjAyogBUAdckEZAAAeNpFUTFuQjEMfQ5Dxcw/AEPHP3XgAOxIHUD6B4g6dOgROABiCBtiQGLp3g4MCBYGfoZK7dgzdP4SYqvtOCFPSZzEfn52qIMOtwGI7YcfeKpxRdT9D5HXQBW8IuoZNmd2a6BAdUZv6I4JiG6MX+FLDPTJM9gJZY24uKZwRaqYX3JFgWvoi9kDPWZ+vfesOMoUT8kumnOMeYbkmdWjNeuVFomZPfuYYG1RI+MKFvWGviqUscJHySa4mb1XhZo57+Ku+1Y9OjqbYqn8mZ5YR2sZu6y41Ju7OWV7wEQn7KRnVotad+Db4rxF6g/x4I5mXs0iP/0i96W2uemXmpb8cpAO4h3+H/MQhcAAAAAAJgAmACYALgCGAKgA1AE+AZABqAHuAi4CkgLIAw4DWgOQA9IEGgSWBMwFCAUwBfAGGgZiBpAGzAcQB0QHpgfYCDYIUAh2CJQIwAjqCQYJFAkiCTAJPglMCaoJwAnsCiwKYgqACpQK0gr0CywLdAvmDEoMjgzCDPoNNA1kDZQNwg3wDhwOXg6eDsoPGA98D94QAhAyEHwQwhDwEQwRSBFiEaASPhKGEqgSyhLsExYTqBPkFFAUehSaFLYVChVSFZYWDBZOFo4W0BcyF8gYQhi2GNoY9hkMGUwZhhngGiYaXhqEGqga5BsyG4gcOhxqHLoc7B00HWodjB2wHj4edh7UHvYfch+0IAggbCCyINQg9iEOIY4hyiIkIpgitiNgI9AkViSIJNAk7CUOJUAljiWqJdol/CaYJ0AnxCgQKCooQChaKHAoiiigKLoo0CkIKSYp4ipIKrIrhiviLIYtAi1MLaQt4C4MLhouXC6gLtIvBi9cL5wwAjBUMIAwrDDoMR4xNjFYMZ4ydjKkMu4zCjOMM9g0HDSSNPw2HjZKNtY3DjdKN4o36jgyOFQ4wjkGOVI5ajmUOeI6PDp0Oqg60DsGO2Y79jwwPGY87D1YPc4+Yj6KPqg+xj7cPvI/Bj9+P4w/okBQQMhBdkHkQiZCZELcQxhDYkOiQ9ZD/kQyRGBEpEUKRUhFYEWURgZGQAAAeNpjYGRgYGRj2MQgyAACTEDMCIQMDA5gPgMAFeABEAB42o1Su04CQRQ9u6ARYywsLIzFRhs14SEqIrSKhWiIqNgu8jIirMvyMLG09lP8Dh+NrY3fYPwA45m7AyFsYyYze+7h3HvuzAXAPJ4RghGOAPji9rGBBUY+Nqn51jiENH41DmPFSGk8hYFxqfE0+Q+NI9gwfjSew5K5rPELFs1h7isSZl7jN8yYDxq/Y9Z89PFniLlPOEQBeVjooQoXHVyjjRbjJHebjAWb8T2/TSJPVEF1n8hDg6gmjEdUxQBXPB1GQ90aNR6XgwziXH1ZMdT5a5df5Vgn32SGym3Ro8odJ+uQjbK+jTsqVZ1bMqvIaceDgN869qnuUKuqtaXaKRV1eqnbuNhkpQRXClmc4wglnBAFs6ITeUGFNaG4mHihcacCimRUNM42qPR0vd4oI4Zdnlne1cYNaypNjax6oTKnFMOO7DS2GO39o/eSvHKFXbjytqr3iqBrmYMlU7bp2NdKZ6QcTqjEuDw2a7/XM/p2GR2Lj2ITciY57W32mCFOy39L3Twl91HzUjX9d8qNKhY55S5ZV7ybf2Gphc8AeNptlGWUHEUYRfduQoK7u7tsV9XX3YNDILi7uwQJGhyCu7u7uwV3d3d3d/dwwt79x/zYd+Zs163Zt+9OV3fXf6+RI7pS1/+8GDDqR1c33fSjP6MxgIGMzhiMyViMzTiMy3iMzwRMyERMzCRMymRMzhRMyVRMzTRMy3RMzwzMyEzMzCzMymzMzhzMyVzMzTzMy3z0UJHIFIKahpYO87MAC7IQC7MIi7IYizOIJViSwSzF0izDsizH8qzAiqzEyqzCqqzG6qzBmqzF2qzDuqzH+mzAhmzExmzCpmzG5mzBlmzF1gxhG7ZlO7ZnKDuwIzuxM7uwK8PYjd3Zgz3Zi73Zh33Zj+HszwEcyEEczCEcymEczhEcyVEczTEcy3EczwmcyEmczCmcymmczhmcyVmczTmcy3mczwVcyEVczCVcymVczhVcyVVczTVcy3Vczw3cyE3czAhu4VZu43bu4E7u4m7u4V7u434e4EEe4mEe4VEe43Ge4Eme4mme4Vme43le4EVe4mVe4VVe43Xe4E3e4m3e4V3e430+4EM+4mM+4VM+43O+4Eu+4mu+4Vu+43t+4Ed+4md+4Vd+43f+4E/+4m/+YWT3qH9/d3e/7v4Dhw0dkmLwoFE5uOrpMSszmdksZpi12Zit2enNSl4lr5JXyavkVHIqOZWcSk6Sk+QkOUlOkpPkJDlJTpKT5WTPZ89n/64sJ8vJns+eL54vfo4ip8gpni/eXzwf/j68J3wuvCd8Pvqe977a+2rvq+XUcmo5tZxaTi2nltN4vvHzNnIaOY2cRk4jp5HTyGn9PK28Vl4rr5XX9vKSe0ruKbmj5I5ST99ztdmYrdl7b3JHyR0ld5TcUarkuafknpJ7Su4puafknpJ7Su4puaeU5Lmr5K6Su0ruKrmr5K5Slue+kvtK7iu5r+S+UpbnzpI7S+4sua9sf7mn7302ixlmbTZma/Zysz1me8z2mO0x22O2x2yP2R6zPWZ7zPaY7THbY7bHbI/ZHrM9ZnvM9pjtMdtjtsdsj9kesz1me8z2mO0x22O2x2yPWV9zX5/6mos8vc1Fnv5m/c2ll1d8X/reR49ZmcnMZjHDrM3GlKPnpfa8nhc9L3pe9LzoedHzouelkaPvRd+Lvhd9L/pe9L3oe9H3ou9F34u+F30v+l70veh7aeW18lp5rbyOvI68jryOvI68jryOvI68jrxOLy/8fgn9CP0I/Qj9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQh9CH0IfQh9CH0IfQg9CD0IPQg9CPcf7j9K8y+BQLz/AAABVuGyrgAA) format('woff'), + url(../fonts/dashicons.ttf) format("truetype"), + url(../fonts/dashicons.svg#dashicons) format("svg"); + font-weight: normal; + font-style: normal; +} + +.dashicons, +.dashicons-before:before { + display: inline-block; + width: 20px; + height: 20px; + font-size: 20px; + line-height: 1; + font-family: dashicons; + text-decoration: inherit; + font-weight: normal; + font-style: normal; + vertical-align: top; + text-align: center; + transition: color .1s ease-in 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* Admin Menu Icons */ + +.dashicons-menu:before { + content: "\f333"; +} + +.dashicons-admin-site:before { + content: "\f319"; +} + +.dashicons-dashboard:before { + content: "\f226"; +} + +.dashicons-admin-media:before { + content: "\f104"; +} + +.dashicons-admin-page:before { + content: "\f105"; +} + +.dashicons-admin-comments:before { + content: "\f101"; +} + +.dashicons-admin-appearance:before { + content: "\f100"; +} + +.dashicons-admin-plugins:before { + content: "\f106"; +} + +.dashicons-admin-users:before { + content: "\f110"; +} + +.dashicons-admin-tools:before { + content: "\f107"; +} + +.dashicons-admin-settings:before { + content: "\f108"; +} + +.dashicons-admin-network:before { + content: "\f112"; +} + +.dashicons-admin-generic:before { + content: "\f111"; +} + +.dashicons-admin-home:before { + content: "\f102"; +} + +.dashicons-admin-collapse:before { + content: "\f148"; +} + +.dashicons-filter:before { + content: "\f536"; +} + +.dashicons-admin-customizer:before { + content: "\f540"; +} + +.dashicons-admin-multisite:before { + content: "\f541"; +} + + +/* Both Admin Menu and Post Formats */ + +.dashicons-admin-links:before, +.dashicons-format-links:before { + content: "\f103"; +} + +.dashicons-admin-post:before, +.dashicons-format-standard:before { + content: "\f109"; +} + + +/* Post Format Icons */ + +.dashicons-format-image:before { + content: "\f128"; +} + +.dashicons-format-gallery:before { + content: "\f161"; +} + +.dashicons-format-audio:before { + content: "\f127"; +} + +.dashicons-format-video:before { + content: "\f126"; +} + +.dashicons-format-chat:before { + content: "\f125"; +} + +.dashicons-format-status:before { + content: "\f130"; +} + +.dashicons-format-aside:before { + content: "\f123"; +} + +.dashicons-format-quote:before { + content: "\f122"; +} + + +/* Welcome Screen Icons */ + +.dashicons-welcome-write-blog:before, +.dashicons-welcome-edit-page:before { + content: "\f119"; +} + +.dashicons-welcome-add-page:before { + content: "\f133"; +} + +.dashicons-welcome-view-site:before { + content: "\f115"; +} + +.dashicons-welcome-widgets-menus:before { + content: "\f116"; +} + +.dashicons-welcome-comments:before { + content: "\f117"; +} + +.dashicons-welcome-learn-more:before { + content: "\f118"; +} + + +/* Image Editing Icons */ + +.dashicons-image-crop:before { + content: "\f165"; +} + +.dashicons-image-rotate:before { + content: "\f531"; +} + + +.dashicons-image-rotate-left:before { + content: "\f166"; +} + +.dashicons-image-rotate-right:before { + content: "\f167"; +} + +.dashicons-image-flip-vertical:before { + content: "\f168"; +} + +.dashicons-image-flip-horizontal:before { + content: "\f169"; +} + +.dashicons-image-filter:before { + content: "\f533"; +} + + +/* Both Image Editing and TinyMCE */ + +.dashicons-undo:before { + content: "\f171"; +} + +.dashicons-redo:before { + content: "\f172"; +} + +/* TinyMCE Icons */ + +.dashicons-editor-bold:before { + content: "\f200"; +} + +.dashicons-editor-italic:before { + content: "\f201"; +} + +.dashicons-editor-ul:before { + content: "\f203"; +} + +.dashicons-editor-ol:before { + content: "\f204"; +} + +.dashicons-editor-quote:before { + content: "\f205"; +} + +.dashicons-editor-alignleft:before { + content: "\f206"; +} + +.dashicons-editor-aligncenter:before { + content: "\f207"; +} + +.dashicons-editor-alignright:before { + content: "\f208"; +} + +.dashicons-editor-insertmore:before { + content: "\f209"; +} + +.dashicons-editor-spellcheck:before { + content: "\f210"; +} + +.dashicons-editor-distractionfree:before, +.dashicons-editor-expand:before { + content: "\f211"; +} + +.dashicons-editor-contract:before { + content: "\f506"; +} + +.dashicons-editor-kitchensink:before { + content: "\f212"; +} + +.dashicons-editor-underline:before { + content: "\f213"; +} + +.dashicons-editor-justify:before { + content: "\f214"; +} + +.dashicons-editor-textcolor:before { + content: "\f215"; +} + +.dashicons-editor-paste-word:before { + content: "\f216"; +} + +.dashicons-editor-paste-text:before { + content: "\f217"; +} + +.dashicons-editor-removeformatting:before { + content: "\f218"; +} + +.dashicons-editor-video:before { + content: "\f219"; +} + +.dashicons-editor-customchar:before { + content: "\f220"; +} + +.dashicons-editor-outdent:before { + content: "\f221"; +} + +.dashicons-editor-indent:before { + content: "\f222"; +} + +.dashicons-editor-help:before { + content: "\f223"; +} + +.dashicons-editor-strikethrough:before { + content: "\f224"; +} + +.dashicons-editor-unlink:before { + content: "\f225"; +} + +.dashicons-editor-rtl:before { + content: "\f320"; +} + +.dashicons-editor-break:before { + content: "\f474"; +} + +.dashicons-editor-code:before { + content: "\f475"; +} + +.dashicons-editor-paragraph:before { + content: "\f476"; +} + +.dashicons-editor-table:before { + content: "\f535"; +} + +/* Post Icons */ + +.dashicons-align-left:before { + content: "\f135"; +} + +.dashicons-align-right:before { + content: "\f136"; +} + +.dashicons-align-center:before { + content: "\f134"; +} + +.dashicons-align-none:before { + content: "\f138"; +} + +.dashicons-lock:before { + content: "\f160"; +} + +.dashicons-unlock:before { + content: "\f528"; +} + +.dashicons-calendar:before { + content: "\f145"; +} + +.dashicons-calendar-alt:before { + content: "\f508"; +} + +.dashicons-visibility:before { + content: "\f177"; +} + +.dashicons-hidden:before { + content: "\f530"; +} + +.dashicons-post-status:before { + content: "\f173"; +} + +.dashicons-edit:before { + content: "\f464"; +} + +.dashicons-post-trash:before, +.dashicons-trash:before { + content: "\f182"; +} + +.dashicons-sticky:before { + content: "\f537"; +} + + +/* Sorting */ + +.dashicons-external:before { + content: "\f504"; +} + +.dashicons-arrow-up:before { + content: "\f142"; +} + +.dashicons-arrow-down:before { + content: "\f140"; +} + +.dashicons-arrow-left:before { + content: "\f141"; +} + +.dashicons-arrow-right:before { + content: "\f139"; +} + +.dashicons-arrow-up-alt:before { + content: "\f342"; +} + +.dashicons-arrow-down-alt:before { + content: "\f346"; +} + +.dashicons-arrow-left-alt:before { + content: "\f340"; +} + +.dashicons-arrow-right-alt:before { + content: "\f344"; +} + +.dashicons-arrow-up-alt2:before { + content: "\f343"; +} + +.dashicons-arrow-down-alt2:before { + content: "\f347"; +} + +.dashicons-arrow-left-alt2:before { + content: "\f341"; +} + +.dashicons-arrow-right-alt2:before { + content: "\f345"; +} + +.dashicons-leftright:before { + content: "\f229"; +} + +.dashicons-sort:before { + content: "\f156"; +} + +.dashicons-randomize:before { + content: "\f503"; +} + +.dashicons-list-view:before { + content: "\f163"; +} + +.dashicons-exerpt-view:before, /* Misspelled. Use .dashicons-excerpt-view instead. */ +.dashicons-excerpt-view:before { + content: "\f164"; +} + +.dashicons-grid-view:before { + content: "\f509"; +} + +.dashicons-move:before { + content: "\f545"; +} + + +/* WPorg specific icons: Jobs, Profiles, WordCamps */ + +.dashicons-hammer:before { + content: "\f308"; +} + +.dashicons-art:before { + content: "\f309"; +} + +.dashicons-migrate:before { + content: "\f310"; +} + +.dashicons-performance:before { + content: "\f311"; +} + +.dashicons-universal-access:before { + content: "\f483"; +} + +.dashicons-universal-access-alt:before { + content: "\f507"; +} + +.dashicons-tickets:before { + content: "\f486"; +} + +.dashicons-nametag:before { + content: "\f484"; +} + +.dashicons-clipboard:before { + content: "\f481"; +} + +.dashicons-heart:before { + content: "\f487"; +} + +.dashicons-megaphone:before { + content: "\f488"; +} + +.dashicons-schedule:before { + content: "\f489"; +} + + +/* Internal/Products */ + +.dashicons-wordpress:before { + content: "\f120"; +} + +.dashicons-wordpress-alt:before { + content: "\f324"; +} + +.dashicons-pressthis:before { + content: "\f157"; +} + +.dashicons-update:before { + content: "\f463"; +} + +.dashicons-screenoptions:before { + content: "\f180"; +} + +.dashicons-cart:before { + content: "\f174"; +} + +.dashicons-feedback:before { + content: "\f175"; +} + +.dashicons-cloud:before { + content: "\f176"; +} + +.dashicons-translation:before { + content: "\f326"; +} + + +/* Taxonomies */ + +.dashicons-tag:before { + content: "\f323"; +} + +.dashicons-category:before { + content: "\f318"; +} + + +/* Widget icons */ + +.dashicons-archive:before { + content: "\f480"; +} + +.dashicons-tagcloud:before { + content: "\f479"; +} + +.dashicons-text:before { + content: "\f478"; +} + + +/* Media icons */ + +.dashicons-media-archive:before { + content: "\f501"; +} + +.dashicons-media-audio:before { + content: "\f500"; +} + +.dashicons-media-code:before { + content: "\f499"; +} + +.dashicons-media-default:before { + content: "\f498"; +} + +.dashicons-media-document:before { + content: "\f497"; +} + +.dashicons-media-interactive:before { + content: "\f496"; +} + +.dashicons-media-spreadsheet:before { + content: "\f495"; +} + +.dashicons-media-text:before { + content: "\f491"; +} + +.dashicons-media-video:before { + content: "\f490"; +} + +.dashicons-playlist-audio:before { + content: "\f492"; +} + +.dashicons-playlist-video:before { + content: "\f493"; +} + +.dashicons-controls-play:before { + content: "\f522"; +} + +.dashicons-controls-pause:before { + content: "\f523"; +} + +.dashicons-controls-forward:before { + content: "\f519"; +} + +.dashicons-controls-skipforward:before { + content: "\f517"; +} + +.dashicons-controls-back:before { + content: "\f518"; +} + +.dashicons-controls-skipback:before { + content: "\f516"; +} + +.dashicons-controls-repeat:before { + content: "\f515"; +} + +.dashicons-controls-volumeon:before { + content: "\f521"; +} + +.dashicons-controls-volumeoff:before { + content: "\f520"; +} + + +/* Alerts/Notifications/Flags */ + +.dashicons-yes:before { + content: "\f147"; +} + +.dashicons-no:before { + content: "\f158"; +} + +.dashicons-no-alt:before { + content: "\f335"; +} + +.dashicons-plus:before { + content: "\f132"; +} + +.dashicons-plus-alt:before { + content: "\f502"; +} + +.dashicons-plus-alt2:before { + content: "\f543"; +} + +.dashicons-minus:before { + content: "\f460"; +} + +.dashicons-dismiss:before { + content: "\f153"; +} + +.dashicons-marker:before { + content: "\f159"; +} + +.dashicons-star-filled:before { + content: "\f155"; +} + +.dashicons-star-half:before { + content: "\f459"; +} + +.dashicons-star-empty:before { + content: "\f154"; +} + +.dashicons-flag:before { + content: "\f227"; +} + +.dashicons-info:before { + content: "\f348"; +} + +.dashicons-warning:before { + content: "\f534"; +} + + +/* Social Icons */ + +.dashicons-share:before { + content: "\f237"; +} + +.dashicons-share1:before { + content: "\f237"; +} + +.dashicons-share-alt:before { + content: "\f240"; +} + +.dashicons-share-alt2:before { + content: "\f242"; +} + +.dashicons-twitter:before { + content: "\f301"; +} + +.dashicons-rss:before { + content: "\f303"; +} + +.dashicons-email:before { + content: "\f465"; +} + +.dashicons-email-alt:before { + content: "\f466"; +} + +.dashicons-facebook:before { + content: "\f304"; +} + +.dashicons-facebook-alt:before { + content: "\f305"; +} + +.dashicons-networking:before { + content: "\f325"; +} + +.dashicons-googleplus:before { + content: "\f462"; +} + + +/* Misc/CPT */ + +.dashicons-location:before { + content: "\f230"; +} + +.dashicons-location-alt:before { + content: "\f231"; +} + +.dashicons-camera:before { + content: "\f306"; +} + +.dashicons-images-alt:before { + content: "\f232"; +} + +.dashicons-images-alt2:before { + content: "\f233"; +} + +.dashicons-video-alt:before { + content: "\f234"; +} + +.dashicons-video-alt2:before { + content: "\f235"; +} + +.dashicons-video-alt3:before { + content: "\f236"; +} + +.dashicons-vault:before { + content: "\f178"; +} + +.dashicons-shield:before { + content: "\f332"; +} + +.dashicons-shield-alt:before { + content: "\f334"; +} + +.dashicons-sos:before { + content: "\f468"; +} + +.dashicons-search:before { + content: "\f179"; +} + +.dashicons-slides:before { + content: "\f181"; +} + +.dashicons-analytics:before { + content: "\f183"; +} + +.dashicons-chart-pie:before { + content: "\f184"; +} + +.dashicons-chart-bar:before { + content: "\f185"; +} + +.dashicons-chart-line:before { + content: "\f238"; +} + +.dashicons-chart-area:before { + content: "\f239"; +} + +.dashicons-groups:before { + content: "\f307"; +} + +.dashicons-businessman:before { + content: "\f338"; +} + +.dashicons-id:before { + content: "\f336"; +} + +.dashicons-id-alt:before { + content: "\f337"; +} + +.dashicons-products:before { + content: "\f312"; +} + +.dashicons-awards:before { + content: "\f313"; +} + +.dashicons-forms:before { + content: "\f314"; +} + +.dashicons-testimonial:before { + content: "\f473"; +} + +.dashicons-portfolio:before { + content: "\f322"; +} + +.dashicons-book:before { + content: "\f330"; +} + +.dashicons-book-alt:before { + content: "\f331"; +} + +.dashicons-download:before { + content: "\f316"; +} + +.dashicons-upload:before { + content: "\f317"; +} + +.dashicons-backup:before { + content: "\f321"; +} + +.dashicons-clock:before { + content: "\f469"; +} + +.dashicons-lightbulb:before { + content: "\f339"; +} + +.dashicons-microphone:before { + content: "\f482"; +} + +.dashicons-desktop:before { + content: "\f472"; +} + +.dashicons-laptop:before { + content: "\f547"; +} + +.dashicons-tablet:before { + content: "\f471"; +} + +.dashicons-smartphone:before { + content: "\f470"; +} + +.dashicons-phone:before { + content: "\f525"; +} + +.dashicons-smiley:before { + content: "\f328"; +} + +.dashicons-index-card:before { + content: "\f510"; +} + +.dashicons-carrot:before { + content: "\f511"; +} + +.dashicons-building:before { + content: "\f512"; +} + +.dashicons-store:before { + content: "\f513"; +} + +.dashicons-album:before { + content: "\f514"; +} + +.dashicons-palmtree:before { + content: "\f527"; +} + +.dashicons-tickets-alt:before { + content: "\f524"; +} + +.dashicons-money:before { + content: "\f526"; +} + +.dashicons-thumbs-up:before { + content: "\f529"; +} + +.dashicons-thumbs-down:before { + content: "\f542"; +} + +.dashicons-layout:before { + content: "\f538"; +} + +.dashicons-paperclip:before { + content: "\f546"; +} \ No newline at end of file diff --git a/backend/wp-includes/css/dashicons.min.css b/backend/wp-includes/css/dashicons.min.css new file mode 100644 index 0000000..13cca14 --- /dev/null +++ b/backend/wp-includes/css/dashicons.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +@font-face{font-family:dashicons;src:url(../fonts/dashicons.eot)}@font-face{font-family:dashicons;src:url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAGYMAA4AAAAAowAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABRAAAABwAAAAcckwii0dERUYAAAFgAAAAHwAAACABMwAET1MvMgAAAYAAAABAAAAAYJYFacxjbWFwAAABwAAAAUEAAAKi6kAXkmdhc3AAAAMEAAAACAAAAAj//wADZ2x5ZgAAAwwAAFnuAACMgOFsk4doZWFkAABc/AAAAC4AAAA2DP0UgmhoZWEAAF0sAAAAGgAAACQPogeuaG10eAAAXUgAAAEHAAACFodAcgtsb2NhAABeUAAAAg4AAAIO/oLadm1heHAAAGBgAAAAHwAAACABWQC1bmFtZQAAYIAAAAGbAAADVi8qdoNwb3N0AABiHAAAA+cAAApGwPo//ndlYmYAAGYEAAAABgAAAAayr1bhAAAAAQAAAADMPaLPAAAAANMHHI4AAAAA0wdjLXjaY2BkYGDgA2IJBhBgYmBkYGRkBZIsYB4DAASNADkAeNpjYGY/xTiBgZWBhVWEZQMDA8M0CM20h8GIKQLIB0phB6He4X4MDqp/vrqzXwDxgaQGkGJEUqLAwAgANrQKyHja3ZC9SwNBEMXnkqgcuzcGxOIgxYGkuO78JMHmNMQkoCKmkIhI/GhiFRshXRoLO1vBv0U7tdFGFAzWaqXO7o426nkkYGFv44N5w4Ph92AAIAm9yYAVO1jHcbK6OWW1470GIfRBJvtBNg2RSyPkU0BTlKcCFalMNdqgBrVoX1nKVq7yVV6Falbb2tW+zuuKqZgVUzN10zAtc2COOMU2u+zzKOe4wKUoAojpQGkaJo+yMX2MchTG9BJVqU5btEttBSqp0spTQZdu6bT2dKBDUzZLXfqmaZq2OWTgfk6zxwGPc8jFKOoMDKbwCz/xHd/wFV/wGZ/wER/wHm/xBq/wAhdxAUs4g9M4iRPOntN0dpxtZ13W5aqsyapclvNyToaiI+7EtbgU5+JMnIqT3sf+TlY//FRYidgSvw/g3+sbNnmNdAAAAAAAAAH//wACeNqsvQl8FFW2OFy3qquqO1un01u27nSntyydtTeydQKEPWwBIYogS7MvRpFNAm4RUUFQFEURN0RcRqMi45Jh3EbbbUQm6uhDxXFkGHVGncdzIElf/+fc6k46yMyb9/2+dKrurVtVt27d5eznFCdy8EdO892cwEmchkvjtBxXpbPrBL1db9YReyrR6cnp3sfoE9HH6C1k+mPRx/juWDO5mfuZ9vxMaOxD7mfipTz3M0e4pL8qjuO5CBeTX5R6oc4Ax2lIKExMZisxW4VgSENkyVBATAY5g5cl2Fn5MAkFQ2E+FKyG8uqQeDDWsDtn/e21ZQ9NK62f3bqyNvZIrOFpi2WZxZI3arFphMM/pVIeu+Syy/yFvvQWf75lGpyaZhE286/tzk93uK1byrPz7ekkLfYI/9rT7Ox0S15wbGaVw3/ZZUvGypWT/YXNulUj81idHCFeLio1yWouC/rEXm0y6gxSKSE6R6E7oPMHyWmhs3Xt2tYoTYtCKqvXtsaaW9fSNHJ6bSvf3boWXlvg/gl1fCJ9BH2Zweoxyxri0ZCATyTQrbhJTXuWxTbENizjfyQ7o7GDfFvfFMFG21Wb9yzjb2DltD16d+zR2OP8BVRLTtM0qDfK7ZZXyLVcNufm6qFeU6aWZBAPaSRBv8ddqCXEHYS8TcOOJZlIBrMpKBOTpCWSzePObCRhYmal1dLfN2/e0/qnZURqaWlsbHymcSJ90lLTetdVZGH/t7ypoKCwrSD2LSblZJ8VT9C9Vym30PlNTY3PSN1YcldrjZWIE1uggqamFvrksj+17tncNxMquKjAxltj37D0TXIfO7F5M1m0GW6x0HmNzzQ1cpwK5kcE3mkFp+fyuGKcI0Tnd5cSj112FErQ+yafvTrIVZsMUqHbL9p1LA36qs06O3TowKFoqCt+5Hrafv0jxXV1xcKp4rpY09Hbbjt6m3CYnIbktiXmPNoDfarkhU6+u7guGq0rjjXDDfyzWHxU1XdyCd4jkrNUXkofZAccPzAnBBhRDodPtBvtOh/fJpzqOyTY+rOj5LRo6P0uEhUNOP7fcCelP0unODW8kxNnvYcEcdaLISJnEIddlgo9bn8jvGlQo5yRiVhAu18izbkXuz1Z/W/MEq5fV/3tPNrR4e3wer0dDYJEmnPwXC7tlvKVS/Ue96x32vs3Tq8eAReVbvJ2kM65p+l+OJUFp3LpS7D+otwbUkzq54ycHdouqTwEeyxE3FmhoNOs4U0SLjQ2f2A1Sp0L6N+vjH01/tjt4/ltfv+COUS1ln5Bcom1eFjvXut0i9VqmW61CD8v8PtjV4y//dg43nolyVowZ5iXfkFPkoI1P8cKLJb4hZxAvMQrq6X9sP5LuTHK6DrsgyNLfDi0pcSIA9lAHDiaddgxsPQSRwE8siSuZEMekNV1xb3f4ViLhuK6/uwIZiOWEstAhpw+T9lOVRfm+6bgoFvqWut2Gy0W427I8G7M0QeTy2KfYo6BR24n96A8Wm6DEeUIDKNbwqVnlqE7VdCVxBMyBXF1qQyH+Y5fT3p11IRmvf/XP9JTQfph8O0AMf8Ihc0TRumlBw/Hrj/s14+aMOqVyYd/pH8Nvh0kZXDBP1hh86sw3wzcC1I3zLdsrhyeXViuqiDusOCrhnmSIQouSC0kQ+UodFZA34SJT2W6eGrQm6MTBEkqbVwUXry1PIOodNmlgc0k84o/bNIGHt7/p4UP0t2RyBUfXKnyuRvGjWvQ60PLF0woW/vYbDlnzPApNfSPh7ccW3lW1Hqs2TX5+Wfbf3+tAr8jshra4uEq4M0dkgzvLMlGe8DtkT0ht8eh8wVDnpA5GArYjSZzyCybzD6uOuh3F0oGWf1pbujuY3e3LaY9i9vu7rk7lP3pJ+YaKLlgBfGykhrzJ/3VZ7q6znQJtuUz4Axc8ml2CM60LSbFC2dDSTAvXjJ7IR3ehdeydkXlQnkqwFcYEc6UBRhE5RFEwe5RpnZWdTDA2iA1vjxq1Nx2+tbWl+iHu2lPRMgbU7V6LuErVk2atGqSXP4ypfTnue2BJvpcAd0WFcjNpHH13FGxE5OGheAKfBYpklfAHNbhaibVKrNcDnNTkn0a4gtmOfWFTk/ICvMzGHJoiCNDEE7dTXTzHw+/uOzeHwtP0Qfpg0ezXyVlv7qH/jBQSuaQOUezNh7+Xtq/uf211rmv30Hbyc6DJGtfb2e8gOyk7Zs/u382h3AyCu+rrKMcWMnFv1xJnE1lllQ2pyeoYu9tqiYApQLwY2tlK1sr62GthEgr8W/cSN+lT9J3N27kH167f+3a/TB3vb1biVewIVjDi/uzYS+M23fLLftgO4EXrY0djEQi0J50LgrregXMCy1AbjOMQQHMkFKYIyGujmuElT7hPGvdrrProUm++JaA6iFopwvODTmG86qkY3kFvIOTvcPx4rpeJwO3xKv8960sscDqjmKH8W2ILPtjSSXdQ68gOxFkxMGH6hMo8EbZH02zsKsiEcDn3kQeTsSz8N6ICyLSfkYfWIdSCPY4heAJwcKAVQJLAaiFU3FqgfZARtjf2xtJ/CPt0H8iQTsItta1/U8mnUY8wsGYH4VnydDLBYhH9A490BFONrpBv+Aymd2OQpXsdjoK5WBIOBUzlUcrbxdOCaf6h7fWAQSL8GXt2f7ibvrK7Nn0le6iQHa7cIqU9B1WranDvoiwV4v97os7npNf2Lv3Bfm5OxR8J4+U1wIlqEPqBQg0RHp2oN0QlcnSnu0WC23tO6QqPWSdFvsLn3NL7NQYuW070Fd0an+NePyQhfTfxmffEvtLDwc0JfzBexyFmeLg2mDlLuPaoSiTLydOmyqD8JlZVgIzN0xgDpuyMnmcxm4oDTJ60S1LjkJP0OmDheeWjAagHk1mEyAMoHfCBIEuu8INQFIyFRC9hoRVHjjPa4ibD/iJHm+Xjy584Sf6Pn2Rvv/TCwshT6rIaFL10wt9b5BVZOKPt9zyI32W3kafxRxpoO8vNWTojddMt+tXkfm/v5uYV/hnm025olDdaLPRH41utdqgNRiune5Y6nAaIDu9nTxPREFt0sgpcz7sPU42v/0/QsnXazYtXiyMUh618JwmiDOHPHQia0hfsRBQ874KkkIOvLpqgTxhvGV4UbFanLml/kRrK/93olYJfMhPUiVeIIEQUdOjsXz+BTmntfXqmsf+8F90m3Bb36kF5IZvn6XvxHaUWDkxPmdXwIySuVS2YjlciwQg9pDNK67v3apq6T8BNA3b+LbYQXnFmTPielgTPYMbwMQLyE5ZlDOAriiF2vyecsCJWSFPhsqMkDAUdP2ySJgxtvpX43J+/8BD85/bt7I6M/erx+6cN1946nyl/EfXXtzoztxBhk/9c8WWQ++dvfoP/W1tu89XiNNLHKAjVUB1pXGZ+I56oLXtBAAJ2+AFNcQOyCx2sG8K8aq6+qaoumIHYwcFG0IMeUXflNhB8Ti8YDsCAEzJaaybT6JR3YgDCyXLIEfgYyBgAA7oSLxc1dI69Ubag1xCK9/WuhY3hAQ9EUjF9beMf572EO/aVnIay2k7bGkADAbKYMkwHIfP1QC81UFP53AWzobvhU9zwUNEwae3OwQfSWywTDU8EKvFdWfO1JEXohEA05FoBGihxA6B/GllXOuKz77MS+Hiugg+dnADmvZUf7bQSdtpO6N9lPePIAwiriCQYvCqNncmo8JFXQa+snLgD/IvqSYV1b1HP3/vvVvHTezvyIp23sqyw6S9UamxNNr3dzgmhe85+NXR/s6rn2B5oa4okMQLaBk3MDzxpgbJkQCu8H5cArv5w7Jv4Fy1VVUA677aypu/lDL848b5z/4D9uI/e7fy3QqCe5CIKUZLeW1rpYLbiifW+h05kqTKHNa0pH3xSF+qvCJ+mx+rOPsyLgehlyE+2qPObZ2yYvackSUMLxbz3d4xF1wwxmRKK148eTiUGBNzJcrwop5Riue03wd4jrMFM902KVM8TtzecNh79l3cEzdQyjvpbaTlm2/ooW+kprC3b0FZc3OZ6l5vONr73TfKCXyGBM/YPcAzOWD9+QDncgA7rbwhgwfYWc77w3xWnAZTnZMmsKwUT4U8cjepfetqv//qt+gbdBF9Q8nLHW1tHW18bnISk1jyW4Zb5BUjVz/64p9efHT1yEQm5mhjFyT9x65lSXsd3gP89U5ymuHPVIWTSvyk/YgjERcCFDIkcozvVfgv5R4z3uUIIPsFDFggZHQYHQFHwAf0hLQfFld/h6oFUDYg7YhoALwe6XUKnVF2HI0ib478iLQf6CgFFsIIBezYDgFTBf51AT+HGfF4tD8bVwpwjQzGnHNvHI4q92Oqw/xAPUInNmZwTQ2pkjH9+P/v6tXF6y4m8TyrF2sT1/d3II2COVYrqwwrjtf5r94zJ6l9sMZ/8ZoEyT9xvbgeZjKn4fEIgOJ6upKu5gjfDeeOq7qUc+JxLEUQyrfFzxkS94kGLAVSbBfZzs51i8eBNWbngByDUrw+dvDfnpMVmleuhf4oYLSlj1GXDHdBfyhcoZIa7UYkiRoITnExKY/959I5YK9ssOq8Z18mXpiUZCfs+jsU4o7vVlKyE3p4Z5Rvw3+pCbpnfSTc1haOsH0v8oNDd72rcaAjKBBLbAgz+RH8SGmq+BekfoiZOEhIFN/ZEntpC+3eQoj4lzn9L5I3Nv2gwIw/cn+UzkhnFKwF/MUgDRTwZzkBpwin7ieFxzo6jtHP6cv082MdPWQpuSf2onRmsKjjGCm8/0Oy9FjfCkFNr+IY7x9lvJuW8Ujn0lY8kJKyhpg1hBEoRR9dddVH9I9AnvwRc8JvceLCkgIchhMtqnDyyZeQInZbvw9PRYdePgRvavC9NEQkAjyLuIheJHqXqCcu4RTtgcVw72U4WdrJXpiEPd+QD+irM6mXemfSV8kH8orYwQm0OrYUa+XvJL+fQNbT0lq6Nxb75hsggSK1XBKOwmexJwEVyOonXr6NRtoRz19GF/Btv6wO24nlbA6KOLtIMSFABWUjBIIWpsFshnFl/Ym88AouQ+EDTZmMssTJGCb6OL9pNJhRMGBCbpCYxNe3HDmyxe5aBjj1Rc2h62dfd92L1+XRI47rswTZ9rSVNFfKK35LTx9RL+v7Sjx+6z2x/+q8eHZn5+xgFVz0epZqI1yCQI88Q56RrJIV1zIbNhi8EAyeqpvM66H30X09ZD7bkfk90Ob7esi8xCHdB5dw/+t84GxhkllObBkk03S+CUFGksyTW7acpD/A/rwToW/5lpMD1yAM2hmXm5lh/ZbBS/iGYkMm57GZjIKOdZyOeMIk3ocmswwLb4ALLY4g/osCHiZep6cC1m2Fx6lqiUvvilGWR7wHvvnmAE5CRk/1xJo/zhrnxUXrHZf18VAaEekoF9fMTRzapgaSTNMhlBmgNcKSD4YZqIsCzCKVAWiI3WaUml4vbWgo7T1d2sAyYlppQ+93qpa+Q+Q0Q33ExqsttmDNxOL+jmGtbhMhREjPsnvqCismFOeL/MuRhtL+q6UmpY6G0teVOhpK+6arWmiU4VHak+JccsnqaTVIk8NLFRSotMXucrsZCY9YJczWq0sbgEHVJNFQZkYdeBjcRJ6cCwEPHkjiybPiFADy2vx/kGd0JRKNsI8yEkBc33fox3+bi9QVD94lNTEqoA5Y7fZ/l0seq8H34FznSjwSbYOh4ZPyCmWLD8VHn+07T7OSX0USleciyuo/MZjnOIUHx3YcBX7fyGUPpVmQhYJ5ABPFjA8Fcrmn/wTKFwDodAPdjfJmYCbITsGGWUwZkdfOzsWagbrBsxynyMEVHjkFnpTN5SOfARMxUMgZHZrEQ0WWoKiE735tx12n6A/PEEmaTtOQ2hBsAEkBENM0oN1Picdv3HOM/vUz+iv+q96tNE04BXRQrBnYD8Cs/+J5Gngk5zBWm0j87fQsEZA8q3uNNBHpGfrDqbt29BZjbVgrQwoRfBr9FZn2GTEf20Pk/g4EnUhGYT/0dyT6UsX68iiMaSrTiwDBTIwKKse9y65BgZVoJ/JR2gO19yCd0neS76YP8t2IiOmD0GdzVC1RZE6jyJ9Gyc7Y2kgvY1Pi74RjhTSUUn8c7wOtCK/h0AkaAQYK7mM1VOOdMCqnaLu0P/FAxAv4MCAEc1Fyh3I6htIBx0S5Y3IKtN/MdC+yCyC+x40/hw7GqBrFEtJLkyfTb0Ih//x5mzq346u/++LhrTcJn79Il7y4pnP7Lddumj8vEIJnvUpepR9NnnjTVqXuN6BudbzuYAh+PqyzUJbwB0hFdGcSI1x9+MV3kTra3tkxf74/FKLfTBY+hwdMnExKaJiGiTcUmDd/07W3bO9c8yK5i9EX0P1A0AIczmQz2CDJOhSe6MpRsm4zqZgwyV0orn/0ukh19XWPIqyNHWQLQVx/00eFsbu9kfx8obzwo5sAxuawBcLWhrJG1QMSSTsuQgW6M9E9wlGg0Ig9sTqd8ZRvEzoTwD2KGeItrgOyv72/o53BO+G4wnZ0YytgurEE5297EmsR54Wi58ghHefnG5nkESn1eDoUBPRuRVGiYEPRACRDRaYKMS/YIgqj3K6kcboDqSLxOOP2rKjGYM/0B0O4A544zDCMQXzv+sPv3dqffet7XddKty2pKq/+7eUHvhG+znjjBuSPr39dl5u/5Db9gvXfHKhU+pbcADTJHwCim1HCAny/WYKdJyj6ccplwKOQxuBszlA5QXEXcOQBfyiDyCb+Vb6F/PnKK2l+7BDNv/JK4X/8RTpbVXNLIDiB2skpcs/SUT/sXfk3+szfVu79YdRS8Q/02Jkz9BgpP3NG7W1O43nVOF+gpSV25z+6Nz5evOa+R/72t0fuW1P8+MZuBY8O0hF6xn02/VLW64FFJ7Lhd+h8RtwGR4Nj/K/JJpitit4Hu2toj0dwCfaFVLkF3gj8eQv6ThZ4vUIb8sYwPQ9MDDUDMdAcwhXLZLnxO+HKTUCB0p5NcHkB3h7j4yw13706O9KAxEFDJJutC2IgROqWjnBebhiu6CxZES0mfjJ0pqQs8PhPcnrcmaGgUyUEMz1umyxlmk021ZGb3UuFHHVhRVjVYK9yOM0mlTCisqra7/dV2b18mS0723A3veva++9fRvJInmPRosX080WLFy8ihVL5zXTDfYJJyrOVqsrsVUg1llWOEAST0e2ostcLjeU2q2Ga/5oHyFv3L5swIZa7mNgXwx/9YvFihHm/4B0HMJSQSDuRg2OcISaqFgQfuCniPcZqwToCfgfm8fokHtSs1OUC2ImIAKg1x4Ck8LRwqve7KMBgFJv3KLXAogaQHElUqrC5uFQAoUsDOlQtwOUChs9LFYihsHA+IKGrTaK9HPqE2BNLN5lzU3UhkOj9DoGFbsehHfQa4s28YP4FdC4Sgv0dSAICNsV/oDOKI0A9zrj88hmlNTX00TgROZRJUw/MY3znzLh8zQ6UIeeKc/Tw/oqC2RyAReyK8+SJTVajiAjFiP0dxIuKqRMo50OcktjwJLw3XGdAcqCnAxVd0ejaVhQvAsWDwkYuQZuzcZQUvIVMoBEfP0igO4VTO4jw0qUwbt2XvkRj9E809tKll75EBOGUUrID+rx5R6IUwBFczTG7gcH3TFXeLtGvspq1A/+xmUi24igy2gf4d694XGoCXJqPvQLNqQ4pOC+AlLrHbRd0AOIQ+DhkX7XRIEulBO564/11633+1RcsWrOaxjZsXen3zVmy+/4/+qqXHwSW+rvIgmc2T2jJ02h3X/HEpMmxGLHb7OOnjP6vB2aVIqQj5F2Y0yp4LsotHMQn20M+4gjZxTc+pKd6wrHZ4Y9I9odh/iEUg8Ak7MT5tZOtgyb2hnrGcThQd+pG6YABNUj8v8pHGDqJIIjvPm9WNCgiLCCdzs0weRw8O5eNHcpp/QBLFnPLmZxKNgMil4GyMdqFgCMQYng9gIJxh4LYzYjnWQfioZYY2aXQsXBeOWdkyvHENcBuuj1Gk29gGOAaM75D26hrisrTsniSjw3e+IRvWIZRk5KZUe+wmHQ5xryybKMx25yWLslpqRULyA686hqXq3FSqChPbzDWeisLCnzZZoOxJM+ak1fdPKWkNDenqijHfI3SAWTnYp8rJauE/nc0EvvVaFWlX59rNufbYZOEtDRzUJ+akpqWrdVm6tKrIrWvRegn5Tm5RfVZolxekD0iLc1i02rVcvp4k91eV5SdLfGa/PzmCMBgJ9kpfQrjZmAUxKDSgOd/qUgYKBOeayi9PWx86qabl710+1id6bVbr54+TXANFu6CwlexkD9w2cSAPeNKkjXqNd/ed2hs66GPJ4y/5rKJQdu5hdy/gKfnaElwtSfke3H5Ga6ege0/qQMm7glVi6JrwfT/Sx3SfiBJOhFPxtNz6zi/XBEhW4AphtnGjJH2K1JFlPjD1oM6Ahxy5F4UzShCckZkJ2RymZyVc3O13Cjgodu4OSgNAYwZcivzmpEmoYCkTFigSoLEJzgEX8in1w2Zu5hxyIGB6S06YIVARWKipJQwMZVU6XTkuh2TZs0YMbywcFtn21hbidt5YVlFZVX/k0tOLDuxuPbrY58sHDbMmj+8Oj9/WHDTlAuaLQWW/AY67cmgWaNVa8iWBU2FNltBeAnNQCuuCLJqUneqWjfV43KNab7kjn2501M06ppg+9L6+hhTkRwgz8QOlntb6x2ONJXG4fJNcjrPHNBnlZYbDIv2Di/z5+ZsM5vLfdnZsReBxbJFkAND+ihu8yKyXjcy2lDWu2RdMdF5RD2zIDK7BHMxCQliSMe3bfqS3rgJENzOTfTGL/vf5Nv6Dm0i677cRNtVXZu+JOs2SfvxzCYcBTzuP8uUt+y2+IUcYLAELZyMw/MGsG1CftoYnwWMFkZZ+tDt/OfsAYHNF+UYdYLSfpSjRsnppP+d5xQD45sWwSmOB6h5A+yYpnDA0YE/YFhhAiNWA8zcNlDao6RIp51G/gVobBOXixgBqQPGY+gMVqE6LAR0bElFty1ddkc0Z/iC+6IPLBiRC6vzeOx3O+7Zu41viD3XsG7j7NqaWVeua4ihgEE1MEYD60sPL5n8Y/hwyLY/mmgStomcFv/K8E0KSpEQT+ntHrteLD1CF8AC7F5OHiylr9wBnDCKgrx3k5ODdhwwRiLgCgdXidI81E4mtDWK9ZsZikJJ9m9EcKSifi+PwL/qIyIBb61+jTFiQmdd8d3BvimhexK0M/ZcJHL05SgqQiKA4HsiEVzejKHrM6IFVOPf/h6OW0EJ45ggIg3Y7DRMFZ1ncju1gPvLktoZF9G5fiHNQ6sggelmfLqhjeSvv2eQSr8nBDRR/wmYAoNtqy3BMyUl2KiS2toSpZF/i12H0wOaFLfBk7pgDniYTYKFGGQiFVbw7gbiDxFEo2j2WEEQBhFmV1ot3rGqoSG2tP7J+kshw99ZP3NGA+X5ay2WjyylJZbYZsxcIImX1s/smVkfW9rQsIplG/jdDQ19UbhwuvUjC1xnnQ4XYr/oGJ3RxHRR/3p9jYzbvzAQq2OgNrGaUFosx/PiOem/Oyc1IZmNsBmpsv7siHAqEkFrHEiB6B7Yn69MVkcivc5IBLX4EWbccpplogO785WhLSzDH6sYZlYAcgYbZDuCbmCA7MAB6QwAr/FFgQtloF44dWRhZJR95RRY6ztuGzH+4QNAqH758MPjwrfT2/i26ausIyMLxEMrVrz38g3hBb5odOH1ew6T1HvuuXcvPfPcXdcui0ZDkfD1v/n98hVIo0eScBhKjRAGWLlCBR+KsMmOAJrWupJQoyOewpxuR/QYiSItHhVO9XcgkGEKG0B1NtojNUWYhU8URT0JsKMsIMa3qJnWY8W/ej7avBEfPt+R/HzfgEEF4BkEd8zuKIo6dWQ+ENxBMS4BRNoR9qx/0YAhujwtzLEGZjnjdBSqJGAKTCpftZM4sN9DCXxaKHuSiErAxkJcFMFKCqX93fTIkQEuYccRMoKO3pttGtFgMOTn+9ram667bf3YMZa86aFM7a48v68iPy8vb65QQjrIyJcGGY+XyMrSYSWe6tL8XKfLqK+5enxt7bwRZWUNRWaTg76TW1FdnZtbWZGTF5cZ8IekP4pmrpmbxF3IzQYaGeYUtNmoELWOOLoPOMwOj0N2hBwBIBfMvjhtoCU+RShWbZbdHoXMgEkHTDqRfR6ceh7JZfQlugCqMYoeh1EhNqTyokJ70ei260bXaeZkhWoWfLx99uK6P9cumT37utnLLn7m6dXhUJ76GrXZGW6aObsFKQ3ntEqHhrjoJxpHWd/JrCUmPlWVxmeQZ9Z5cvKt1pH0kl/xvxFeXlJvKxBkWU6fnjt5ZLutYkp5WW/vI4/0Rs6e7S12TvQ7NOHKMQ6Xe2p6Wmqdd2RkYskwMi7YIBamFafU1T0kaPUVJfoseoYQwh80Z1ejuWecL1X0FPkAXQq5IFfD1TO8jRbfkuxp5BWDb8Gj2HvzPlStuUjILMftvM1axcw7JGoANek1RGQG32WNHz6asPdu2T+8oBztvXvbUHYcZTppZvVzomn8TYq5983fjroLjb0bhbMoLkDCEoXkgk36O7P+Li8Yvj9h/N3y6EeN3j2bEU4p9kOMfoy9OerbmxXD75vGN+1hl05W6oAFsBMeGn9nspPh43Sgl1A7Uw5vHeZGIxQN6vy822mDCW/MTMj8VedIFDVxu+CBgkQ6oMJZrzrRNai04v/JEBN9XEGis5SjCWQq2nqMYUeqb5VCRS1Bdv4XyXkooRR7iP5F+JCVb1cUBuyfZpI3YwdRxHTBx8nFJxMi04QtA4MnOuTEHUBrhYFTD4Z0GaScR7LJO63nkxN01bTvvvj53ah4vNeJgpV8YrHwef0nHOrCArUCE3YyfndAv4+idGVT9PuJTWqKMolYNP58vk3az/T0IuJ0HUwNLIsivSt8TXaxgUN1P1y7kxCG65DWR30hj4o5qwgAPxgKiyGUAfAqmykTjYFUN0PHfvfAtstUHkORxZV5vcVyfabLUmTwqC7b9kDsJZL/9tv0z2/L6gfodw/dcna+YM9yWUqMT86b96SxxOLKsgvzz97yEDFcgle9TfIH5BbSR1wacIdobalP0g8mlFfEpRNdos4l6kXDmvpxtx29bVx9iPHuZAQZS7Nje5kpyeO/4p/kW+1rRi+57bYlo9fYyeWMg6frr+/veOcdlCFsj7kH+RvE7wjrUR5UCjMRuXmmRWASZGiB3e/GIgKpA60MHDrnAGVEAoXlIpzbGQVCJ9o3Bc25yM41/T9GBBuk09DmMyLccWAN6jN3Lnx0/apV6x9dGNc299AeVJyouta2TlsDKwRJMu+0NWtjMzAbwbvhTKwvag80NQXsNC0hA4c5lcq0ZWgj5mZWEg6jA4mxALMLS8hCgELTob4Czf/wDU4D5Rzt3RqNioa+KcJHzNop0ncogq3pz+a7ISvt7zsUjSqKF8CdZCczqIpVw/sgLgO6JI1lFbk1ruMmZoNng1kTFwszOhamG5HPERQLtrpimlZc1+Ahp4v5XYyvqSvuP8HcOGzFdeKzKPovqUUMDh2Dphl4KnYQ9szGgJyWVwBvEOduh1YOrBbBnkQfHcU/RxFPdivWeGytkhYahn4Powwujuu1zGvnnLpc0PYVa1t7v8M7RUPr2r5DaGusWPj2Z8P+MII8RU8UlT6COeRiVgIKXAq5JEfcc8XlZjYryMV4RJNBFoPiY0wwqKHjL+yEXMe1s8hhDQoUIUfHazTk8IWCjR0XOk4ugMyCk45CdgtkmqFIkSG+yb3F5m4B8hUc6nnsRHkWIFczPprESYGQ0SToiEmRvoc82BIiq33FvXnkgBFWhrizbASQ2Ivq2sI5+WLxdvprLCUPFVVm59GXpfsvnqDr/ZJ/wOVBBbvO0Fit4a/xjg+3pWhSdb0jVBfFnlVOyWMtKVRQdHMKb4qwBGE750pezUi1A14LDhYkAP25AF9Wk7IgzL9GH13gbwpHzB9lrDmwJlBGP5LMDMz23aywHJ2KMln1bt6sIA5R3bzs2Cp387A9ha5pa9ZMC16UF/tePM4AdOwqlvyo2KjhHNbAPHiT6c1xQE0ZJEkLoFBVcdoKyBCdPRga+CV0Bwm0I7rR4W3gF0q6NBAMwb2oY0j8Ek+QZjjMSzY4jIXOAldRSclFF5cWF7ns9kJTto6kpVIfSdEIJVW++sbhY0bfeefoMcMb631V9DDzYYqVwL1XFir3OitnXlLpxHsLcnK1cC95j/7Ey/GbmybeeefEJnazuM2/YbTZX+AsNOZk6mWDXpOVmWOyF9qdRTxvLSHeTFW4yldUmmdNt9nSrXmlRb6q2GHmYPWY/8rR2fE7M1P0+pRMvLPAWezAO2kPnxG/NS/TZsvMY7eytabg+zTUMwBgyFDJWYAPCTC+qLZQyXbgDtNmXH/31TeGTWQ+aUZrumivU3iK/v0RekzVBQChlM9wN64YT9JJpZFUA4y6P3ZU1VJ5F67BZUQnL5KOoBMiUEww01OIpHLYXCafjSnMgDQsJw0wNqgFDZlU5vjKCIYkOSgvmrCCzOg6TR97jR6lscoi7ufoupecHmtF1VWPTJkxoa36JnLjlykf33X/is3LS9ctl7LaJ2ltu+gn9B9HOx4W7+VvuVROz327U1Uq+B6YE5n+6DupZZ47P74it7FzdCrTG5Kb4vqQApRSI5CRDVnmagZpGNwJ6OI5wLGHntxIvv2STxF4zYyOjhmxE1Y+zDKvyuqNM/uvkIQP6M8S6Xhyo4dUbHyy4/czFdsFBX9+D3xLHmIEl92fQjgvceiq00guEe1+nnPCgcpsyhIHsJdJ7CH+1e/DuzxA531yjNxEwt9fFztB/Afp13TDR7tJ5vJll8X+2rZpU9emjuhH5C5yIXG8exk9ds239E268f0/kGuI+WF6rH3JEvqP266cOWPjxhkzr4zrzxXc6ky2jNX5gNZnbl5uZlkNVPuAL4Vd3OHy+Vx0ydGC76tHXz1i/S2PfvBBjHf5AQz4XL3tTj+/4se76+r+qHnkrmd+jN3ud4o7XT5mf4c67zvhWQZ8b51Pb2fP0MWfofMJk4jrf1z0ZF3rnZd0PPLmTz9F+U9J/uFRo7ifU3/37DH6Z+w/wC2KjEjDPCEUeSmseG5Aj017xOP9HVGaJqiZExMydP3ZiCo7FIh9hpOIBsb6Dek5wIj5wEsP48ZybTgrrYKvOswzbYAkSlZSHSYe1H9h3pc4EPRBdoFZzzyMCGQQkXgEN85WyVVtkgW0wPbogwA6goJDFp2V44ur2yrN6ZmXjWxup63phRdefmFhesbcy+cKS+BgWI1ydMm4Ta7w4Rvef7Vms25Ty4RNsaeWD28PjBy+VLu8cn9XsTtVqOp6uGq5dunwkYFLR65M17qlrKJZsydUjF22vnLsrFkPhrYuWrQ11DBpUsNArq+FPLn5mfmfPk9bA83NQuWuHnp9QU05Wbn3eSlV9/xeuqu8poBs+Pi2LK3E5sRE7rC8TlrObMvNBD3KNCjWIcxH0eU0WzVm6Zvt9OFbpgfnUV/sH5Zp1vUWi2rcX2gX2ftTTrXHl+/Xh1JrBbHtFvr4La3XLIqtpCUWywZ0Az5xq7DpkpQ8c6lpmH5k+gQB4M5dZJh0u/QEV8LVMo19hgBgOawKIRFuthIe4bGqHEclLOsZvE7AfLNJmGngs535qRa3uWX8rJYpOZ5ZC2YX2DPLLnnqsjU09tNnXT6LMdM7ZubiVVdc+qR17qzWuQJJy51/8fQ5Mi/tk63FlaHAMLMuu3rimJEZpszMSSPHHqex/lNjxjdlz35i9Yjdt+6+4apIa0l6bHFzWtrYGQsLC4bbLNPmTMxUdIRkB6OtUBIxYCGst6OhiJ3sVJgqYOTQmBINHoGw65v8FsqLaBpSkYr8npSyOtIB7tq5CuAsRzI7uCFcFlFoBpji4kCOBJ2NJIPwivPqYLnrPLlzma1uhRWiaUpKXneR0Tt3Wmf/xtXY1RimJqWYbxuaktLPSPaDpJixXB8/SE8J7UxKWFu7L57Sj1xPjRrV9Aq9x9XYGH56fry45JxUkWcqtptZzCcXdc8+ZkKO/pPVSBtZiRElN36UuyJhUkqAACIALKBM2h85+3Jky8mtSy+5ZOnWk1v6pkQX8R1dwqmuDn4R7YkAod93CBY9nCopgcui0f1bu2h3tKNr6/4oOXBRZzTayYkkyE2R7pZ1zP7SBW2oYr7hBcC2N8LMryCyRyaFCh7CfvQUJghFUfboQz5iDgkeBzkSDL618eTJjW8Fg9GOk19vIgse+ebbAw9/880jHU89debpLiJcfTS2rbfvnU0f9m3rFd89+XUHXPpWx9cnO94KBaOxlG8egYsfPvBt5KlNjIZcdaIi9sJx3vilL/ab4xzMrWR9cQoc6wCKJiSdboBgXvQF1aP5G2oyQixxeYA+NntkZjRWDCWick4IeUSzTkvsUUX0BgyFdTftQacbyJDTu3f37ibeaKxZamKysWyaptqMbpq7d5M57JysTmjte3crMmpIe4h39+7q3cig4BkmwNy9m7bvhj/i7d2tyM3ifk8J+1PjOd4YOPg2KxGNdob7SCCJIjWKxwcI+1bFrjXWzDgfkh0cAcmIIKyvZNYCR5+NPRT0/eqT7AX1SGfWL8j+hPHSgAOGM18+XLuMj/TpoI+AEdOJG4YuVOgKRRDTFsV1jOuZS65DUupQ7o2r8lGaiUoJFL9EVU+/hTcpYCCaAAwKDmZ6jybmyc4MRMzQEHRfP/sy3w3DEBEN/dmiIYrc3KCNF9ph1nGTmOxRARIoe7Q5g8TpCXKuDN5klspVCCPhZ1XJvBgsFz1hgVhVGYKWlKsAhK7YkfB227Ej4e3WP5JueWw8uZlw9vKsEr+juSrgrjS0lVc/Ex4774ZJJWlEou18XlXDiLqq1BSde4RwbUGFNVNWiVq1WjaG64aVpXiEKlbXjiH193qO/ECGpYZu2bvHJ5rcJVZRN2pq2zBDuq7CP25UNf3oiRlbpjcW24vMJb6x9eTtygUzLh491TciLzvbd2H9sKbCG4f689gTVMugD3rcbFnJOwrLCUwnDc8X8X9h1iYDEqDSjUc3bDgqvMPczNRQoDiuJ7miF/PTNxz96eiGvikoEWPPXcW9I4uyCHCimuGpLKRfnSjqDDFEFRbKAe/LZiKYw8SpYoxdwJFHiCvkFi+49fcXm24/Q0/QI7fe9Eb1/sL7Vl/60/HfXJ419t7PIa3ppjrPM+PPEjsZTo9bVGTePFJBw3y61DX+DP2C/pZ+/t5s0/gxf96+eP3r9TW6MfvgriOXQ3rpPPouP3oWVG/uP2gpUaUJ5EtaQF/p4WWAsRqYW68AvYT+GvXceOwvJFyyALn67Ci2hUNZtIdVdcAWmwksxOpgSB9kRC47qeXxCkAxRLkI7ax30iPWUtXeF5zqGjuvGi3r6+hz+WUyeQMmhqQ35KV/aKzWxh6omii5ikLqg2JRHv2NJ49uNXtTUsbQMTlFqvvSdaoP6Xhek5vj1H5tKDRqBfF4has/hz/xtLPwqHlUoXWrKqMw11Sd03ftBK9HaHG4d2ndFm3GLXnm2PzGi4Xl7LTRYknlkn3iVcC94CrSkITDu6oFQVisWfUqk6Mg6EIQFZeYoBw84QubBVTgBdzFaLMKa4qDNcXxRgM6wvqqnZzrvI6vqn/n9iqGBT9ze5WziJvT+UMwHOz+LPnoffQ0vYUuo9vp6X3M9/Whd8jlJK3vE/r4muxMU/atF7uMG8jNf3mChK6sXa5RZ6c4VKHRDgf9ILsYjuCKnXM8V3g82abM7Is3CxlpqSZZs/Tvb/+z79U/0e/Hkink74S//qYNK/IfFSxkN9Z9H3vmOw8xZ9d9JM0l7FILwwIklbz4xyvbNRe0ZnlyKzJrpbm7R/RefLEwiqhVKj5cR9IkQSD1YaKmj5fbrLMmb2p+5dT/0Euu4O+Itawkh4n0+kP9i8n9sdFl9mnkb4oNZsJP+oLz+RigPuY/KkMjtMAQr05me4M5Wc18ESijP9A59F8eofMmOyY72THK/oD8KaEfldTVlZCSEgw68q+PAIsoOaUU8IsyZyJMLmXmcoFunczNVLxQZcEu+FCGkOy14NCL5xq/BuC1kLYBuAGcAkYbgWUH3IQ7zDcCveEJk5Ds9vhgYrlVLXeWz8y9iH75/aPjSR56pCq4jTa+HSGvYS6O8QQPfe0K+trVmhGBphtsophKws+3TutuJCpJEnj7tuG+4Zr/acn5IHe8ShANngKSEWuOoperUgcw765XkpEnTVvxyScrRmwbluvMzR1rGl5dPTzD47anprpyh20b/srojR2jBB7x0a3cTrlRbkrYs2iISZKJqOdCQRP6MvEeIkbJpGLi6nfHWncIj1Y6rqWfxKbcyD9GtXxXZ2yybKBPe9e7+507+C7hiSqXim6OTbyRf6F/O/8snMZnPM2tkgvEKGBZC+o+OSY/Q85RSxQNQ/IhZ+P0HmaaK2fxSw+syR8b8c4wGvP59wbz9Hq+nLxxUWcLvY566XUtnReJ0TXT/JWGFFGs9COZMJDvyyPNRF3+Of2BZH5eTs8gHYO2BsfF4wOy/mRLouNo7a9sgLUHrX8UfluhefUKtZuYJpCTUKYpNUV7v0NxIwp1GUZqQeuNrg5VV0dX71ZUWQz6POmgL5iWYWgt+gQSNAFvyoLgYIWYQoU/xn3qvNGkOtGCH53n+g7BPkknAuvXwvkQ16l8hhSSwQPZIPMB4JBDesAGAaAhdHarUECEU2llu+4+2T6x4447OjxuTcHcizevXDWpqv2rh66zF5LTDFYbRv36zjvyaVp+x9arS0pktTpvVKD0BL2c/u3kzXP1epU2PKHzzv/6bzLiafSg6T+typq06MV2lbasrDE/1qxUFde9npb2n7/v0W5qQNNyTt8nvdP53ujfvsP/1lpW/1lyVvxY/Jj5g/ED/mDix3Qfmb+d7qP33ULmsR2ZL46H433bE8fzbqH3kXkKL6jI6gWgjqsAeqJedl48NkBcSNkIrGCAscBxk0X4FSRLNKsZne9hJy0D5tOoeMVIXqi2VZwkHGJcX8909mo0qel7QZ+RkZKuEkWJyKlphQ6fJS9Xq0tJ4QnP8ypAX6npaVq9vlL4iabFTt7UEAjkWwy5lmJP4YiQv7qmsjqYn+nk09UFNn+gVtiSMGBBD05VF61LTc/Myk1NN2bzEikrKwXsnZZlyM7Oy3JpUjOsQpYeiEG1xo0qh2ltNrvfH9okqqUUWZYlSdSkyEKKit8U8gfs9veZTUSUhT4BynmQP8J+C8T7bSG3lMma/g99l7Bh+L/0HxnSh/2W/7QPy5XuoU8O6cdhvnP7kT+SiASAxsvA6QI38vF/1pVEYp3063/fmcvZRWj5o3To4Pov5qbD7PO4ExJyH3OpQY33wI8ZC8R/hBkBJQToiTMYE0npOrOsM4d0nhDUwn8qAF1hMlnt1f6Gxc2jTKZ0gaTI6enGLEtOiaeivLgkJyfblJYha4Q7qi1yvXVV6IJV7QsXXnbRCm97aWNe+fALKp6Z/MjIRfObH/5g6lxxvT4UGFZZ7fQYzXX10y+YrU9x252FMNC5Jr3eaMl3O12efHvsgQuuOavS8DqgqLRpaWlqvTo3RZ96dsvU1QFL7iPX054VK4j3+kf8DawfDgO/mgew1o5wkLOpsowGBBoZBN4z7qHod3vKVQF/lh5mAJInuAFEBrJFmEyqiXBnSV290ZjjUAgSR446b3TAu7udb7OV5oQqouX+nFKbvOJOSvf4O1dHLFb7smIlOlbxMnuqZ/WyG/x7CN8bmTkzUF8eDFTUJ/GM+zk189hiTsNEViOzElGY73ZVCzMN6AYWUokZwWzH1zMbSAU+ieuZjRFeLx5HNpddzQ2BlVC/y6FDUCaTITVGUdzPzPfj/nJkQI/N6oc7kipVQgBF4q7YQ9sP/YZw0kOGVCl0MuuHZqBR4vUPbT/ckVQp4mNyml3+i/YDnkWP6hAZUuXQzvpl++GOpEqTuipJjs98J8zn9dyN65r0KAY4j+cuXxF3rDyv1y59g51UvEHiPo/QX0cH/QUGLELRPu3omcrEhr70zH97YA/XJ8f6Qc+g8cDjXKZEpyDQ6AwM9FOOIX/CJC5HSCM2J5eVmYLHQ95LLJTRQUhmUhlRCXoEOSIjFeDzlwO76MlA3sceBOLgX0XZ4e+gm+n9P+/ezf1M5pJryVwO8j/HqslFpO7PW7b8mf6OHqC/wxy/d9rYtfeEFlz7ON2z4fHH//HE46TCN2J+hYUXrja5qgKBKlfqZz09zavGALwUELxOT8mvbZk80vgvowv5dv9M7//F86uTn0rqWEtcZfkvb4rMNN23ZMPjkSf+8fjjG658nKbW6S9cMLvA2rJp+ghnjlogrR98oHLXTZg6dWxIl7lo/8IJhQYSt1uPz0Ez9HsFi7RnV6LnuZnig9GsLIKeOOCl5w/qf5EvZUphBlNQEgrl4uhYM6py79O0hSPhNs19cNCfliS82J4ULuxHRTu/Mn7tSjhg3hMWI1ZhtKBLRVwW3JOUJk4zKxmU1b4nL5ZnAHedy5Wj3RPnLowHswyRoDn5wK8nqIrBqFQsrCGKS2XiL+crgN4yGkzw5kFVU1uHN/a211u+sZQPer/3biodOCptJA962zaV0jlPezvavHAa9n2PFVZV6XRa74SJNbbwWIm24e0dXi/B+1d74ah0k9fLl8D9m2Lb6By8iTz4NFTk5QNefFpP2epIW25uwYI/Bi9adSGsi31AR1dLf+KmcBdx87nLuWu47dwe1C0bUNthyJDkcjGgvATzHUQpDzBmis1AIgJiPFUGSrkAxxVyJBHuzpSIDkYko5Xg64eAfoABFf1MACNLijmDmFA0wrHZh3m4BvLSp21dZ9sK9bkV7gZHvSZ1on9CeWFh29mutkUrtqqzOhcFdrl0yLVhODXYMKtz7qla1Jml3lq5xNJ/uzuMI0s2K8N7WM/n6yP6fF6v1Ua0RKPXZtKeTK3eYiReo4U+iHuLkfbAfkMEs7gT3sEH+kdcMa2lrMrkkNSVzqkX7WrzY9NGNj7/VUXguq9b82ultfvXVuM91coeDqWGnNavrwtUfPV8/vAsckV9UTGDfIqan+py9Xl5eqMptdcM6FgH3MnXCosSD/EWtwFBfqeOG8nktCgWMAZ9unj0SYsi+2sgkiMRsjKeFnqMcUmgomlMiIQEW/T5K2atxLBPrTj3fVXxBlX5MEBbV0eUr4jH0wFcsfqFGTNoD5rgEJqOS+nTLOYgG1X2WZ8qsoVIRxdiIsVggfkgJWTdKZwRIEAVN5NZLvgHHEVdg1lm2RI3bEG7luQj9C6Nv0chtN4Rf1t2q9nKV4dRMMWxRAjBSYTVAZ0VHXOEzkhRPXY4NE/J0HZUv+BGdg7mjtwPUEBdmFmohvT+I/fut+3p7OjcY3toX0zcfOOdruaFY0ssL9Hf0E76m5dcIzbNdOyR9l+8ougKr6uxviiRiR0lc9BqiD7IbIcG8w0rnw/8hOCElBJCP8TcT4HnV656yp/S5HYPT/E9RSd7win6qhGBMtqz8vnly59fSby14ybmpIQ5NfM1OM58pe3Qi8O5Udw4biI3FfuSARUVCy7jSj5QbPaVLsQF5zrnmISMsgs2MZ4Ky50+f1aWnF1f7p7xzAy+bchh7BUYZzbYxagJG8ijqxu6R8QOKqm4w7Ns7gU5uSmF8y5c4Zk/YcL8c477fkb7qWRbqnievwYjJDErbyVFPvdVwB8ZspEzcPlcEcpVMvjCcqCTYNObENDoAfEiX+KRBIApHqZzlk2q8eT1yu5jR491V5JXaz7f/dOb831rFv36ZRqcPWbam3sXbp29q3fi/Im9u2Ze2HiXWNL/9txtTU3b5grVs5epiHP7kSmLrPRP5TTr0cxLDk+LfRaZ0TVjoXH11IS/fVS6D8aCSQWAC8BYxw4iAQmMLJZZwkDSkqzXof1vmLDwqETW6ZlEK+gJSpoLJ9qa6t6aQc8spf+84IOGJtukC5sn8BrDfcuttW8telZvGNt1umusQf/sovcbnSsfNGj4ceIl5QdfvWjaYjVNJ/+dtmTmRa8eLCsUwnXX/BSe4aHX8cH8U52df9627c+dnafyY78lV9vnNZy9tq6RT4qvko7xFDgWLQRIprAABKqsdwmeeLSd2w9+9c6zgeDZlw1j3usWztCbyZrSP2X37yp/007W0INF/Dp+u6xevGuXz49aRUPzE529TxAnyXZdS57y09pLCugp+lUpuYvO486Js6P9ZZydfxdj598F18FYXUKn1KRqYRQh2pXuZEHzWqKK3d2FzD/dxnnxLKAhzlHo5AP+MM+MtB2K0R8KO+yupDBd/AN8voZ+8NNeembPrD09a764/57ZN+w6enTXlKvGeiTarXpn/0P79z8knPKX/pO+eTdR37OmZ8+s3bsv7Nl9R49/6iTn6/sfggv2YxumkLHy1dJWTsfsHatVWWaMyKrEZvUEnfrCct7jIKYss0OJzmqWVEL/r0jZq9lH0dz+VOGP9y57Mfz4fKK7/NrvD2/MApBS99fagWL6g7R1H/37QTQ9vOP1ua2vtW/ufXn2/Z9tJjtH0p9Gxotg7VQTn7RPeuB8MkkhLpNcSbSFxNr/RaznCv6Mx7L0+9gHl/IldCVfvjz2gbSJ/uCYX9D/+RV8Od9XZBXom7H3L+UDMT9fuSJ2VLHtAy5iBfOJVeLKAXBhVkJ+DWGWIjC33MAFm8zkOrGsu7v3D91CK/+gMc1gHJMTeyP2Zs4YoyHNKDU923/42WeF8c/27+eLdTV2q2ygm8m1QEPYa3TJz9GyeL/nGmviKoTXYysRYx8Dvw28kbIcNSQor2gL996AIFfcEG67Tiump9BlZEuuQePW0AkffUgnQMaQS7bQZSnporYoxLfzl4V4t9CJ9/R3wF54T+vITqHb6DKrMZVXkzWvvUZvVvOpQMzsJlekZDu0RRVUTc5UsPW2UtbIc6CtdqWtMiIqaGsI+gTWQDkPyKqAiBwkZpOsWdvaNxmFraqnp63ZEdsfWyynaVI19rRUfi35Kj/NmWMXLhcWXDjVTh32Jy/q33fRFDv5zP4robl/FnlX1Fq0manoa32lU5uabkaf+QG+zMRs1r2Mbz9XQ6qXZFeYENHt0VtJwgpXdJnMQjkRhWBIBKB13rha4++YV0ZvDhxR6enNZfPu2HiEqphWqf85soYdCwvgCrImcOR8XJ9qUuKuN+NXxQ4yLdRr8Wr/O17LuTxmHsL/X0aHcsIhvBccEIzORFKJzwBL/LyhovAFDA88QL9jNuEPkPYMDU9epR/Mm0dU5w8dJT9ADMk3kfYUke8hjaheJJl8CZPFJnAzrjLTL6MrsigfdoLm8oO47uvYQeaCMzS+RN+UeIjLNMVOQOGd/n29Q4KHq9b0ZzNb4nMjhSggktU70KeWQe2xUi9qn5S4B6iLGvqUeEQLmoY4PxtQP1pH14kNfVOYMzo+j4VNUUIcRJVg94pjE8YeGLB1kfYPeCudL04xhrA3s3g7CmBn5ClNYybRqn2IdyIo/8OQioAF9p/7nYM44UAGZMjquEUN2iJJTdG+Q3gt4o/+DtqDWu14TLjE9WJCcq0CAIKexygfOYhiF2YCHo872M4cTvg2tPxm/ikYM3AglkQ543JR+IdOaEBr6ZjLCwa5CgXRb2jgOOF1LB6PmTqWLK1vaKhfunhTqaVgSoEVdxYr7hYWWa3WAlldH168+MziJfUNsSeKMJh9saoL2ANLQREMvRVT0WDNL4HsEBhQyF3CreQ2cFvOu3qCWQm4YGSNReV2ZgYPRBQQKwp6CjIjaH0Qrc0yiCkUtDJrNCNDpnJWiJ0IOokvaCXsBDp2cSz8KqqDfdViUt4kjCbNCdsp2k0/ZqutGn7Gt9ate4t+S39Pv31r3ZXFwSXkVzf2Hlq+/FDvjb8/OOm2gGH9rGs/y7VcvqlskWcJn5o+7PGsdF2WKSdTJaUCjK+5pnyhJyIIqeklN84hGrpYys3LENJTycI63l2+bnqoWVeoXVnfyleY1uOBQ7uivjXEVv1gO4pZ23ovW/cWMQ42ac8XLzUMWyrmQlPo36FJl6laGmqnd3Vc9URJAfkiQ6vS6nhrPiEqnbk8WCqQ/54N5e9lpWeqUrUrN9KPidpcMrKSJ7Tq2tvep7uObm2d8EjTjG+WKOm1LF7QuX6/SpyTeJBg+zkpytgRUEhNlIUQhNl8AoN6oCuw4hs/uAfOK8Jw5/7z+l8PxGVJpPpznpfws8bIg2g3gGtRVvcdivSfkNWwiNoxiBdGM4+iW6O0fyDMSNpA5F6lLT2R+F88jpCX4fOELA+eoI/HfkYv7ogS9QNfDW9FYwW8UQ005Wz5PfkNLocrZjqOGq6BcUPoexsmODPZl1sIyl4UwYtZJiEmui/Hr7lIKsVENijK+L2EoZvqwLbqXcvXtZi1WmmbxdK/1DrN0v8T8P13WabNrCXf12ZrBClVVblwXFnFclJSWzu9tjb2wRh+0+j+n0bzHWP6f2L5f45J5MfIj26TtFpzy7rlu6q3WaC2JVBbimWaVbjTQmuprnbC8oqycQsrVamSoCnC+qbXDh8du24M+X5MrHM0+X4gz/bXjVHsraB7gK5OYxzIgKYTmWYDJxt9g8IztF7mEoZ7eIGSV3WtObBmbev0K2CYvvo4iiaJzHGlOPoR/RNyw98+fOAbTDEqz7Q166Yi+F039TP6jPMDRTz2gZNM+gzvwOiGzOUF2jWdWKUO6V0YUQ/TTiuOUH5nI1Ex+5BKfZYsIYNaKfMepuV3Co8pcQR5Mv7hh/nbT7RfWjfLq5s8szUvb+7TZTq1u1Sno03Su20dF17YQTssblGVOtwy2migv4/FdPKie+4dNuwV+lhmxsOx7y64YAIXtyVVZCUol8Y50sDiQXDn8sOJ6F8KNWlMqDKS6UpYD4mvFjgTnhMmWyiD2NyqrkEe+Me4yzsGeJw/iv40aj6Lq9+K6CvSu5VvY2IcMk6Jav/WneSbOzP/RN/9E0qqGVLtgT25QPGE92DMffuo+fNH2ZVI/Gv5xxAD/TjouVdnnDy5BQMtqWAtZ8i/lQ9z2Uw7U89xepQ8hwkXhi7mtKRcLZ7nMy/nfuVFb3r70nZLhKSf/HZjppVmn/xapa0uGxVsLikTv6e/e47U5Vzocmf1f9YmrLii6s9z6A0bStfPKN1Qx/8QP5VLfydenXXmitVQi/Yf/fdrdPTWl38rqC3Zrhxrmno5/d1huDLL7brwdyv775ha1bShdMZ673qyfs7f6K9IXS6cacuhr8P4pcXj8aEtko0bH5dMbuZu4+7i7uMOck/DSAoBhakwCtD0MAESlgSR21bJEsbKcgomM35oSALqGuad3mwKogLOnYFazgIiKwUeZMjFYEhfTogeFXvIPwh6gxk1dmjLVocwkQkwHTqfLCLjaMMjl1lS6hHQGsrBrJlkP9bjUpyCQwbElyHApnnEYDLDBfLRhZN2W/LHTF7Ya10wafewMZMWCa8WOm5etJd+OAzTe4g3en2TKrtMk6LVaDXDxquLMtQZNY42OUVUSUDc7oECOWOYQ9CP6aI7cgKqsWXk18eqDCo5o8C+6yGe1NdXFZMJx7KWjSRnX54Gy3tpPnliKQbN42Orb08l6Vn6YZOuK9ZIak2dS6vWT7Y9fvGl5KEn0vIdh+a1rpJlv0CrV1xKSH1dhXiYniT5YydN2p1P6Ek+l5jzx+y9I58U9N+x4q0DrtAt96x4+4AzdAu/pnIjr8nJzm8Ml+SNW0juShXyVdp0pyBp0gS1+qHXyT1KCZGD+WfGBWna2DfpzUQO1aTkXDTz4o2kkh5R8cYsK31oQtNUQBZF6EhIKqfctXoPQhZV2t8CQjbhyd3fkS0C0WaIxPJVy2haUvbkT2GLLb9t/afzD1SQsCFXr6O7SS39gAgEA1VxvyE2WS89waJWBYHjzfK4UQqDk0SWsswmTjj1A1m6eJ5++s6vFxwZP/7Igq93TtcvWEiWEttCMu63vyYtq56ThclNTZMF+blV9NCvf0t/DdjqAZibZnk+cKEjmb2TEo3NgT+7HmYbwBDgPQWHR2JaX9S2J/TuuNQER9wXHFljSTFMFYLKhyPwWLkpTGTziOaCDZMys6U0KTPW9rmgSzfSY8Z0nRC5kne1Oqbm2AvyJvNCp0Gl0eoLJj42oWXdV3xt+Yz86qtrr629srIyWLdhc6fVNsJZkmYdltuYU2vIzk0pFzf/9eO515glno99mpWZmanT8W5eZbdPWrVq1Rwnz+enqSQpRW0KjGyOxvwZw5ZEL1725qZhlZn2R/b+sad9Hf+VlJI/dvocr3NqutqcU3vxtAsdvmT/1KE0BrPGziF2HUYk0CdRGXYl0uHZl4F6Zv9ISeOGrqgY/EsJ7cPoBmYekKbEbcMQLUCxqwZi+KrgeXnKV0hYcDQi6BIKBUZm+zA2mKiTjRjGBj9mhvdHgFamPUhDFxQRL6RK0I92oKCa8AkYGEU5G7+qnpxGcSSnTnru0FgbyvPNjIxhltskya5EZPGZ8PnAQLDAIsgU4QsnbKQUlk1pQUSJ4zhojDBo4yEN2D0p/ZyIPJ5k/eMS0f9Px2w7kKRnJhs6V6KAEQHYRUnWQk705kbDbkkTO5iVmlkQnlozbFjN1HHDhmnIf5cUX1xTc/nUKZdnZvYPU8YgQWfi9no70OLZNJBRM6x16rCayiogWi6l+/U1w+CWy6fwz+RkZsUejdOi8jntz2MxK9znvMG5fG4ZObexyhd14sE6OxjyJBPpszBP2s9tXzRZ0hxrjkeyUMyh/n/h+zKHzAn0LzawyLU24K2LOC9XyWKv1WM0Sk1CXS0yktrByOv/S16ZRMBTM7U2c49n0Xz/o2zyDIdOiAwGVjlvEo8hl7TOshIxRhJrjQXilX0hs8+TECC54qxD8nJjUXWUmmlMcaHZiTN8cMori459KAD+iFcJYaAwDdiOlH+57hgPc561Z+HtLGSUK2kpnn8JoocS829ATyXmt3H+hRg/YtmElRA/pH8G+iX55ZNfMSn2uAr4sszEHZ6QR0PsGoD6snIrgJsoexrG9UFHnoHBQ493FrKRhTjGWSwMaUNZ8ujAMpdVv4AGAegUN5NN4NEQuJiWoqOr852Z3hpPUZGnZnhBE/HOrPF4ipqhYMhgUV7UpaXxY2S5jD4le0qCoaKi3JoQaak/mVvjaS/yeErOGTf02Uln3xIwAffmVmJMKS0VjSGzbHYl7YXqIGDICh6pvIT3VsCf3Fbafmj9oUO0Z3C/u+kSDZ+TmvpmmSzOsTR5vU3e5CZXRyPVkUjynrbPG6GbYrOteq2lbsn3ZQW2sjJbAcCE97n3ZSCKlXj0RPmGm9Pj5vH7baohXwfx3tvefu8+ehG9aB/LkQPkAP2BhahjkbUl7zknMdd7Fkc1cRHz51R4f5wROdgr7HsdPthEu1n2OLDAEzIj348QCDnrKFrlYFDg1e2Lo/h+NA1yZKe4jn4Iy41FQP3k0O9iI+EQUiU2WCJeT/wrojoPzDxi1+uYZ7OMIVnhttjR7fw8uiQaxYibUYSl/ScixB/7YDs/HyNARGPNqhbYJdkvYS/pdUII0Lxod5l1drOg00N9sssuenR2yfMlRoLbRNYBul+HuS8xZNwmeiM0/EbIiWVkXe/WoacA2OKpTezWIf4+ZsB5v5Bm/2fc5vl9fd77T1jQ8znzqE79p2xpehzv1ULrPUOicU3mpgEdOYu7ZPD7IUxGyMSwirTQblTEhQ1E+RqmeM7xQFQ8n9GBX7ATz8mLjoCPbfFvjHiZychOlvR3aDNKMrTadG+6lu/OyCzKzMjQlmgz4t8bgX/cWETzRA6VvHgkNSEujtSXe73l9ZF42mvUQgXGXlM61GnqNUB1mYZeIzwho1eryLZZrLpI0v6cuPoDFNX5omUnRxBOjpTNn4w9Im7AaMIsGRpqv//LgdjCXwzGFhYHfKgGv2LF6ZUhiFOQRAmUphPiSC2Cgi9HYRWtrCp0YNAsNImLKm6A0q7egLh+WqWjsLCQHkJvaxSLxUkN1BnfJI+StwAvy4VMYSmE7Gqw2ooOvh7mkoZi1AwJo0ghQ2FVyUxcxdjzDBZHKimfQqL5nV0ffvJhV2eeM2fWWNuo+uE14aC1vMyYVlXe6p2b7mybO5wIN4/K8Trz8jNzxMzW0KLxhBTVNpammibdd1fN6NkHt2vl1BSX9qYnxjTee6VWSklxZa65e8dN9+bp6pZcub3zqvL6e+4Zb3RUBjwZ2uyNZbkeU5akIRpXzZSSUZvUgqnUM9I9If2LsaUp00IFjVX1wXGu+nHawrKOZ+akOrWZcuqcp5eu3TdNyU+5i56kqH4GeskLhMV+4O//13iQ6K9JErMXtv8ojxG+IdVhXvkykTJ12Qbz93/NI/OBpAFOTYz5H48GeZ6kvwMXAxwotCTHLWRyCzusak7PJPxxQX8C8yYWLn7/zRD/nAGwgnzAwD41XXjebKThmYZIfHdRWzxLe3q/Q6wGeGAnOe2vdDvy0mx5ltpZs+oT2YsvSmSrfMKp0tLxm68aN3Q/7irF0vSqfr8Sa1F25tlqiqxet9lYwnuH5muLCjDvVHPKtxMV3ybU5RRy5QDNLuS4gD1g+n91XQtwU1Uavuc+82qamzQPmtwkTdKkadO0pE1DW1r6hBZahD7Doy+20EJl1wWppeiKghXE1bogsjIq1OKs7EMcH1utKOqOG3V12FVBZ3d2cUd2GB+wKI4IzXHPOTeJBd3p5N705D7am3P/+z++//silQztC7JCmHTaAjJfxUqcTuFMuJZA8jImPB4EuApqIqBoPLV5MxmMXDfKnLv42eibY4sU+bn7pv95bgTbkJkzXHXR6bVBZ8XTbWsb4LTOn4biZDEHLUFFx9vdGSaVxyge3NGQq87Riyp1qX7jlduMFpZ1m0zvHVtbr/KLeqW6KZa5oDP/0LufAzC6+cSO5YItkxC8z7y1tiFkygZbql3+otMGdGR0/DRe1PnhzlKPhfPkGDnW2jG3XlSq1H5x5enGcAbrRlaZZS3DtUPoyCq/fjQZXyQxvpipQRSQdUGPc/LMNSqBETl6bBOJMHBpimiAwvf30/fE4HvoyY3d/P3x4RiKgPJiCT0G8EuB5ytkvR0R/7jFIhGwf5Cp0zH3OfsBGESuwSA8AM5AJ3sMOsGZBN5YjnW+37cIMy3hHlxcnMR3AX0ZHkB7HEB7o73QUdARrtkXffMGed8Yc46Qc6El3l4+4/XbJs4jKGYs5CTn0L80mDxFAgON23sw3hg578gZjOH5jAM5TPWLb95EHTjFXRvEqCd5W2DnM7ScjLFH84UPFwcZMq0MGbi9NznOysOk2m42pU7Afq2QaqsaSzyeksaqWkmhULvVCp1BpS8vrMy1lzZ2BhQGnc67vyDclmkESqUrTRANvFSS73Lll0i8Af1XXsMDpfbkH8osZbSByKoN+5/Yv2FVJKBlWIfBq+AUvkBz5231vZM9jWZG4fXq4qcWbquvTENhphN9Tmv9JSsHV5b4tTQ6HDpo1Y6FFIZdjxOOc6I/humccLWHxJt06jNsP2UUNK6cXEpGCwk8DHql+jpvRHepH8Wgq6kNqeypOZE+TXBJGABh6sBoDQbDNXCiQInzpZjHA+OtIgZcvwMmOSsaSaVFZWgDTpdXoOvLkabFpOCEcHJt8wGbze0hec/mpsWSzeO6YR3z5W69yVQY1xX2iLv1gUL6vyajrzq+hL4gadPUu1WlUlyUrOrdQo5ZTb8QxgnNttJyktF0+EKNxYyzuLFVf/WZgKOVsQQcM2ccAa5Fzlg2Ny1JpSzRqZqbGiXguPp7MFJQGEQTVwwUwF1zu0V4XhFkHPCC2maT4C6bTQ306KxgxGS9WuHHecjy0jaSiFynqfbDm7D24lP26mVg3BGAZ084AgE8J9dRu4QW4RbktZdSDbhDBANOQCVnRwZMCewsLyD7TQO00AI0A0mFCuMTK2kf2haLIUaICWSfN2ZqDFagU2dpLWlGvSXdiEzBlNEfzp7DGbKKO23/hvf417Q35Q0OrOmtsoOpYV11rdO8p+8myZmXbrlqMKaLtEmTqwJ6f74/gxvJsOZ4rMCgdmuNDKvSaTOgFkzZFnT1DazPb2od8MLv4ITUWWIXaasn7DWCqQlzWsBpvrfvZoezplqcucuos8zR2tJyVEDnE9xGmSuToj4WThIesnI0k4aozRSFe/wJTlMuBmeB63uJEh1Dicaja/qOMHwe82ynmoxCs3dBG3MJMjI81XyVgJJJJ1zCySWvjPU+mpPjb9hsmVEx9SpAM+iHVjAapTZNrzcZ9TqtRqVEzw4a0AB5OQ5ngWS2aDXg2bLCgsit2+cVFlitehDKcTnml+bmlJU5UJSpBrWbDh/eNLQsOxzMGoOBgfGBgXF+8uqysVfWd+jaapitFrPVrNAJCrPalK5LVyiVCq0mI12P/BuFwHJ+v9dmVanF9PieTXPX2B1tLXZ7QWHRJk6r5HmBQ3aKSdMwwuFPDjfPqy39iX0xigzxKQaoRD+jmv+YqqYaCastQVEXhewMllIWcNHOjEFOQRpfOxVyRov1aPp43U4OK7CbzEEGb+ZJ9lwwKwtc0eVgXqzdv7R9UYX4+Ftv7Chb8rNXPS7l/HKh75GO2pqN+2uhputg7NSGrhXwFfiNrX/7nsVdR0stKzZtqfr56hqQSxcSMkL+Y63v9P3NBwyhpbcv716hq68sO3LQM/jysLcGnoZ3nj0EQhffHnOnvzY00ROsn79sS4XN3bVrpoiEVdSsHIlE+E3keqWbSKyJ17U7F12rtcYeG54cjuESxizNNTo6S2pNllWTJdZmy65dJ7MmP4dNhC8Bs9+VEFealen/cHM67mbCnE8lGJMF0GORvay15man0ZLFJkYLQCA/0h8K6UrsMz89JYEik67k6nmclKGV2qV5woobehvSvZWRfCucODzhrWR2SuCNgN0X/93MrSTOeFO4kX+csiAPN0jVkC4Is1ykxoRCC4DXhyZ8VsiM4j2A0zQRIuoCMHM9CgLRzZEdMZnRKsvli6Dbw4M+d3mV+F7jp3SSdOU7qc0mStJjX9yy9auLwPfUkfNSWzzqcjybMcernjvz98E3tzdv/PW2rex/eh+Ook3gRx19Q5Xar8HD6+u2Aj5+Ej04tgzzY6LUKl2BkoTXhx768psDD82/IMGW7KI87zMGgQEs3PfCyPbBnYduzumIru698xm0hX6I+/KlrVE2/jcwPrllWNY8XIPiqg2YZzGlGul2eXzZGE9C8FrYVpg50YzzKdOg4eyOHWfh1PTncOh2wLTDByaA8fBh+NnEeLz9+fhvjt8B7hQ23PcVfA6Ow+e+uu/01IHNu44g32k+MB4Z2/xQjH7p0SdOIHv8C2paaBeMlJLKlFUbvE65ZgcwEQgmMy3RI7uLLqwHF+6Qucahlp4bScj3fHr1L4v6fAZ/ZPqd/vs7Wv3b9x5iNo2DqtYwGOpeeGjvdn9rB3fXkc9wdfxT+OecO/YeWtg9BMKtoGp8Idox7mrtuL//nemI3+DrWzgOT1yDXzNgNOD1CBxgyLICUhBKJOhCP9opNd8NP3R/lO3Jvseb7fXu+nFc3gf0WHwUHnNXVLrdbteCCrfr/+JKkjoy6MXNWn+vHINxHuCSTL4++31So5XAveVFstdsP4rpyki9LVzJFoVYB/qGcHADCpCrFtDOPfjIv9Y9Drq7uqFmdCDYaTTy2liC3mJOLF4dX6QMmRZZLOAiOd4lqp+7RVhPFODEbAb3GiKTyGQxGcgC0mER0zTitkPkGu0AXdvAaDeAvwV1Xl89PAq6Rkf5AQAAhBkPrgmt2ZcBIfyuGe4DNzYDdGzagEcfvEYzapYWBcGhzHphebsYiY+iieU4qU9dwlAYzKKPswIYWwcuYVgO1Mi9dDR1L/UnoUDACj7Y5sgzDnmlFHILiCtQggZZuS6IPASv4Gd4baalwqBfFT+9LdiWWVB8/PW8MTD67e6almxHeWHd0wuKQF3Tex/xQ0p7wxyzhufy4d13F794PBLMaM0bo4uv/DVvfV/XaldIUxv5x6KFC1SkL1iO1ZyzdB+c6C/yk1xxQm0VBSVc2G00kIZtjiyzQQI2J3KkCuE2cnthO2xvxKnHfjgEt8jwuZg1Nco8lnqLazQoShvBSxQgs8diHEaR72kEz8PFn8AnwarFoBtOvHv0KNyYGm9MvYslNe7k9ZWkvgH1IuEOnEzoIfHErWdlmhZkK/UEZIZ8EnyRAebToz+cbcfh+0k7zvzqlATfQXac1aNDX2/GQTc24zO3SrAMmXG6jdlJpXjnJxN4JUxwFMZsSfxkQuYYU9GStawhnMppmROZbkKMlLimifdEnhHXY75fkouaXOIc0o+NyyoohDsNUE9QfxRyhVb0ZJGz1UBLphrJWAM56CEPG4KHIqYGS8FioESJPOAjFJ8JolD+yZ7a2p74gtWXr/TSWgb/As7XvtwStkej0CC1lkngC0mytdmgvtbht9QUtRyvo1/t7GzdotFkm9FtanQbjK/xr/XAOIQ98Yqu+vIoUDM9yBOje8GFOntOpjN6OQpFqaxVAhfQo0aSoFj3cktRjcVvr6Nfj34bXc4BwJns7XajwHCqFE8r8T1x/cD5QzQsJ9+tuNaTEKdApio/Esm/sgstueoEahRNycuXq4J8IFjFT0byZyx4E+ZcfgQHvy+h+7quvz8wbx5F/Q+5ZZ0FAAB42mNgZGBgYGTsZNzX+iqe3+YrAzf7BaAIw2X2ZD1kmv0CWJyDgQnEAwA0+QnKAAB42mNgZGBgv/D/BohkYACTjAyogBUAdckEZAAAeNpFUTFuQjEMfQ5Dxcw/AEPHP3XgAOxIHUD6B4g6dOgROABiCBtiQGLp3g4MCBYGfoZK7dgzdP4SYqvtOCFPSZzEfn52qIMOtwGI7YcfeKpxRdT9D5HXQBW8IuoZNmd2a6BAdUZv6I4JiG6MX+FLDPTJM9gJZY24uKZwRaqYX3JFgWvoi9kDPWZ+vfesOMoUT8kumnOMeYbkmdWjNeuVFomZPfuYYG1RI+MKFvWGviqUscJHySa4mb1XhZo57+Ku+1Y9OjqbYqn8mZ5YR2sZu6y41Ju7OWV7wEQn7KRnVotad+Db4rxF6g/x4I5mXs0iP/0i96W2uemXmpb8cpAO4h3+H/MQhcAAAAAAJgAmACYALgCGAKgA1AE+AZABqAHuAi4CkgLIAw4DWgOQA9IEGgSWBMwFCAUwBfAGGgZiBpAGzAcQB0QHpgfYCDYIUAh2CJQIwAjqCQYJFAkiCTAJPglMCaoJwAnsCiwKYgqACpQK0gr0CywLdAvmDEoMjgzCDPoNNA1kDZQNwg3wDhwOXg6eDsoPGA98D94QAhAyEHwQwhDwEQwRSBFiEaASPhKGEqgSyhLsExYTqBPkFFAUehSaFLYVChVSFZYWDBZOFo4W0BcyF8gYQhi2GNoY9hkMGUwZhhngGiYaXhqEGqga5BsyG4gcOhxqHLoc7B00HWodjB2wHj4edh7UHvYfch+0IAggbCCyINQg9iEOIY4hyiIkIpgitiNgI9AkViSIJNAk7CUOJUAljiWqJdol/CaYJ0AnxCgQKCooQChaKHAoiiigKLoo0CkIKSYp4ipIKrIrhiviLIYtAi1MLaQt4C4MLhouXC6gLtIvBi9cL5wwAjBUMIAwrDDoMR4xNjFYMZ4ydjKkMu4zCjOMM9g0HDSSNPw2HjZKNtY3DjdKN4o36jgyOFQ4wjkGOVI5ajmUOeI6PDp0Oqg60DsGO2Y79jwwPGY87D1YPc4+Yj6KPqg+xj7cPvI/Bj9+P4w/okBQQMhBdkHkQiZCZELcQxhDYkOiQ9ZD/kQyRGBEpEUKRUhFYEWURgZGQAAAeNpjYGRgYGRj2MQgyAACTEDMCIQMDA5gPgMAFeABEAB42o1Su04CQRQ9u6ARYywsLIzFRhs14SEqIrSKhWiIqNgu8jIirMvyMLG09lP8Dh+NrY3fYPwA45m7AyFsYyYze+7h3HvuzAXAPJ4RghGOAPji9rGBBUY+Nqn51jiENH41DmPFSGk8hYFxqfE0+Q+NI9gwfjSew5K5rPELFs1h7isSZl7jN8yYDxq/Y9Z89PFniLlPOEQBeVjooQoXHVyjjRbjJHebjAWb8T2/TSJPVEF1n8hDg6gmjEdUxQBXPB1GQ90aNR6XgwziXH1ZMdT5a5df5Vgn32SGym3Ro8odJ+uQjbK+jTsqVZ1bMqvIaceDgN869qnuUKuqtaXaKRV1eqnbuNhkpQRXClmc4wglnBAFs6ITeUGFNaG4mHihcacCimRUNM42qPR0vd4oI4Zdnlne1cYNaypNjax6oTKnFMOO7DS2GO39o/eSvHKFXbjytqr3iqBrmYMlU7bp2NdKZ6QcTqjEuDw2a7/XM/p2GR2Lj2ITciY57W32mCFOy39L3Twl91HzUjX9d8qNKhY55S5ZV7ybf2Gphc8AeNptlGWUHEUYRfduQoK7u7tsV9XX3YNDILi7uwQJGhyCu7u7uwV3d3d3d/dwwt79x/zYd+Zs163Zt+9OV3fXf6+RI7pS1/+8GDDqR1c33fSjP6MxgIGMzhiMyViMzTiMy3iMzwRMyERMzCRMymRMzhRMyVRMzTRMy3RMzwzMyEzMzCzMymzMzhzMyVzMzTzMy3z0UJHIFIKahpYO87MAC7IQC7MIi7IYizOIJViSwSzF0izDsizH8qzAiqzEyqzCqqzG6qzBmqzF2qzDuqzH+mzAhmzExmzCpmzG5mzBlmzF1gxhG7ZlO7ZnKDuwIzuxM7uwK8PYjd3Zgz3Zi73Zh33Zj+HszwEcyEEczCEcymEczhEcyVEczTEcy3EczwmcyEmczCmcymmczhmcyVmczTmcy3mczwVcyEVczCVcymVczhVcyVVczTVcy3Vczw3cyE3czAhu4VZu43bu4E7u4m7u4V7u434e4EEe4mEe4VEe43Ge4Eme4mme4Vme43le4EVe4mVe4VVe43Xe4E3e4m3e4V3e430+4EM+4mM+4VM+43O+4Eu+4mu+4Vu+43t+4Ed+4md+4Vd+43f+4E/+4m/+YWT3qH9/d3e/7v4Dhw0dkmLwoFE5uOrpMSszmdksZpi12Zit2enNSl4lr5JXyavkVHIqOZWcSk6Sk+QkOUlOkpPkJDlJTpKT5WTPZ89n/64sJ8vJns+eL54vfo4ip8gpni/eXzwf/j68J3wuvCd8Pvqe977a+2rvq+XUcmo5tZxaTi2nltN4vvHzNnIaOY2cRk4jp5HTyGn9PK28Vl4rr5XX9vKSe0ruKbmj5I5ST99ztdmYrdl7b3JHyR0ld5TcUarkuafknpJ7Su4puafknpJ7Su4puaeU5Lmr5K6Su0ruKrmr5K5Slue+kvtK7iu5r+S+UpbnzpI7S+4sua9sf7mn7302ixlmbTZma/Zysz1me8z2mO0x22O2x2yP2R6zPWZ7zPaY7THbY7bHbI/ZHrM9ZnvM9pjtMdtjtsdsj9kesz1me8z2mO0x22O2x2yPWV9zX5/6mos8vc1Fnv5m/c2ll1d8X/reR49ZmcnMZjHDrM3GlKPnpfa8nhc9L3pe9LzoedHzouelkaPvRd+Lvhd9L/pe9L3oe9H3ou9F34u+F30v+l70veh7aeW18lp5rbyOvI68jryOvI68jryOvI68jrxOLy/8fgn9CP0I/Qj9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQi9CL0IvQh9CH0IfQh9CH0IfQg9CD0IPQg9CPcf7j9K8y+BQLz/AAABVuGyrgAA) format('woff'),url(../fonts/dashicons.ttf) format("truetype"),url(../fonts/dashicons.svg#dashicons) format("svg");font-weight:400;font-style:normal}.dashicons,.dashicons-before:before{display:inline-block;width:20px;height:20px;font-size:20px;line-height:1;font-family:dashicons;text-decoration:inherit;font-weight:400;font-style:normal;vertical-align:top;text-align:center;transition:color .1s ease-in 0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-menu:before{content:"\f333"}.dashicons-admin-site:before{content:"\f319"}.dashicons-dashboard:before{content:"\f226"}.dashicons-admin-media:before{content:"\f104"}.dashicons-admin-page:before{content:"\f105"}.dashicons-admin-comments:before{content:"\f101"}.dashicons-admin-appearance:before{content:"\f100"}.dashicons-admin-plugins:before{content:"\f106"}.dashicons-admin-users:before{content:"\f110"}.dashicons-admin-tools:before{content:"\f107"}.dashicons-admin-settings:before{content:"\f108"}.dashicons-admin-network:before{content:"\f112"}.dashicons-admin-generic:before{content:"\f111"}.dashicons-admin-home:before{content:"\f102"}.dashicons-admin-collapse:before{content:"\f148"}.dashicons-filter:before{content:"\f536"}.dashicons-admin-customizer:before{content:"\f540"}.dashicons-admin-multisite:before{content:"\f541"}.dashicons-admin-links:before,.dashicons-format-links:before{content:"\f103"}.dashicons-admin-post:before,.dashicons-format-standard:before{content:"\f109"}.dashicons-format-image:before{content:"\f128"}.dashicons-format-gallery:before{content:"\f161"}.dashicons-format-audio:before{content:"\f127"}.dashicons-format-video:before{content:"\f126"}.dashicons-format-chat:before{content:"\f125"}.dashicons-format-status:before{content:"\f130"}.dashicons-format-aside:before{content:"\f123"}.dashicons-format-quote:before{content:"\f122"}.dashicons-welcome-edit-page:before,.dashicons-welcome-write-blog:before{content:"\f119"}.dashicons-welcome-add-page:before{content:"\f133"}.dashicons-welcome-view-site:before{content:"\f115"}.dashicons-welcome-widgets-menus:before{content:"\f116"}.dashicons-welcome-comments:before{content:"\f117"}.dashicons-welcome-learn-more:before{content:"\f118"}.dashicons-image-crop:before{content:"\f165"}.dashicons-image-rotate:before{content:"\f531"}.dashicons-image-rotate-left:before{content:"\f166"}.dashicons-image-rotate-right:before{content:"\f167"}.dashicons-image-flip-vertical:before{content:"\f168"}.dashicons-image-flip-horizontal:before{content:"\f169"}.dashicons-image-filter:before{content:"\f533"}.dashicons-undo:before{content:"\f171"}.dashicons-redo:before{content:"\f172"}.dashicons-editor-bold:before{content:"\f200"}.dashicons-editor-italic:before{content:"\f201"}.dashicons-editor-ul:before{content:"\f203"}.dashicons-editor-ol:before{content:"\f204"}.dashicons-editor-quote:before{content:"\f205"}.dashicons-editor-alignleft:before{content:"\f206"}.dashicons-editor-aligncenter:before{content:"\f207"}.dashicons-editor-alignright:before{content:"\f208"}.dashicons-editor-insertmore:before{content:"\f209"}.dashicons-editor-spellcheck:before{content:"\f210"}.dashicons-editor-distractionfree:before,.dashicons-editor-expand:before{content:"\f211"}.dashicons-editor-contract:before{content:"\f506"}.dashicons-editor-kitchensink:before{content:"\f212"}.dashicons-editor-underline:before{content:"\f213"}.dashicons-editor-justify:before{content:"\f214"}.dashicons-editor-textcolor:before{content:"\f215"}.dashicons-editor-paste-word:before{content:"\f216"}.dashicons-editor-paste-text:before{content:"\f217"}.dashicons-editor-removeformatting:before{content:"\f218"}.dashicons-editor-video:before{content:"\f219"}.dashicons-editor-customchar:before{content:"\f220"}.dashicons-editor-outdent:before{content:"\f221"}.dashicons-editor-indent:before{content:"\f222"}.dashicons-editor-help:before{content:"\f223"}.dashicons-editor-strikethrough:before{content:"\f224"}.dashicons-editor-unlink:before{content:"\f225"}.dashicons-editor-rtl:before{content:"\f320"}.dashicons-editor-break:before{content:"\f474"}.dashicons-editor-code:before{content:"\f475"}.dashicons-editor-paragraph:before{content:"\f476"}.dashicons-editor-table:before{content:"\f535"}.dashicons-align-left:before{content:"\f135"}.dashicons-align-right:before{content:"\f136"}.dashicons-align-center:before{content:"\f134"}.dashicons-align-none:before{content:"\f138"}.dashicons-lock:before{content:"\f160"}.dashicons-unlock:before{content:"\f528"}.dashicons-calendar:before{content:"\f145"}.dashicons-calendar-alt:before{content:"\f508"}.dashicons-visibility:before{content:"\f177"}.dashicons-hidden:before{content:"\f530"}.dashicons-post-status:before{content:"\f173"}.dashicons-edit:before{content:"\f464"}.dashicons-post-trash:before,.dashicons-trash:before{content:"\f182"}.dashicons-sticky:before{content:"\f537"}.dashicons-external:before{content:"\f504"}.dashicons-arrow-up:before{content:"\f142"}.dashicons-arrow-down:before{content:"\f140"}.dashicons-arrow-left:before{content:"\f141"}.dashicons-arrow-right:before{content:"\f139"}.dashicons-arrow-up-alt:before{content:"\f342"}.dashicons-arrow-down-alt:before{content:"\f346"}.dashicons-arrow-left-alt:before{content:"\f340"}.dashicons-arrow-right-alt:before{content:"\f344"}.dashicons-arrow-up-alt2:before{content:"\f343"}.dashicons-arrow-down-alt2:before{content:"\f347"}.dashicons-arrow-left-alt2:before{content:"\f341"}.dashicons-arrow-right-alt2:before{content:"\f345"}.dashicons-leftright:before{content:"\f229"}.dashicons-sort:before{content:"\f156"}.dashicons-randomize:before{content:"\f503"}.dashicons-list-view:before{content:"\f163"}.dashicons-excerpt-view:before,.dashicons-exerpt-view:before{content:"\f164"}.dashicons-grid-view:before{content:"\f509"}.dashicons-move:before{content:"\f545"}.dashicons-hammer:before{content:"\f308"}.dashicons-art:before{content:"\f309"}.dashicons-migrate:before{content:"\f310"}.dashicons-performance:before{content:"\f311"}.dashicons-universal-access:before{content:"\f483"}.dashicons-universal-access-alt:before{content:"\f507"}.dashicons-tickets:before{content:"\f486"}.dashicons-nametag:before{content:"\f484"}.dashicons-clipboard:before{content:"\f481"}.dashicons-heart:before{content:"\f487"}.dashicons-megaphone:before{content:"\f488"}.dashicons-schedule:before{content:"\f489"}.dashicons-wordpress:before{content:"\f120"}.dashicons-wordpress-alt:before{content:"\f324"}.dashicons-pressthis:before{content:"\f157"}.dashicons-update:before{content:"\f463"}.dashicons-screenoptions:before{content:"\f180"}.dashicons-cart:before{content:"\f174"}.dashicons-feedback:before{content:"\f175"}.dashicons-cloud:before{content:"\f176"}.dashicons-translation:before{content:"\f326"}.dashicons-tag:before{content:"\f323"}.dashicons-category:before{content:"\f318"}.dashicons-archive:before{content:"\f480"}.dashicons-tagcloud:before{content:"\f479"}.dashicons-text:before{content:"\f478"}.dashicons-media-archive:before{content:"\f501"}.dashicons-media-audio:before{content:"\f500"}.dashicons-media-code:before{content:"\f499"}.dashicons-media-default:before{content:"\f498"}.dashicons-media-document:before{content:"\f497"}.dashicons-media-interactive:before{content:"\f496"}.dashicons-media-spreadsheet:before{content:"\f495"}.dashicons-media-text:before{content:"\f491"}.dashicons-media-video:before{content:"\f490"}.dashicons-playlist-audio:before{content:"\f492"}.dashicons-playlist-video:before{content:"\f493"}.dashicons-controls-play:before{content:"\f522"}.dashicons-controls-pause:before{content:"\f523"}.dashicons-controls-forward:before{content:"\f519"}.dashicons-controls-skipforward:before{content:"\f517"}.dashicons-controls-back:before{content:"\f518"}.dashicons-controls-skipback:before{content:"\f516"}.dashicons-controls-repeat:before{content:"\f515"}.dashicons-controls-volumeon:before{content:"\f521"}.dashicons-controls-volumeoff:before{content:"\f520"}.dashicons-yes:before{content:"\f147"}.dashicons-no:before{content:"\f158"}.dashicons-no-alt:before{content:"\f335"}.dashicons-plus:before{content:"\f132"}.dashicons-plus-alt:before{content:"\f502"}.dashicons-plus-alt2:before{content:"\f543"}.dashicons-minus:before{content:"\f460"}.dashicons-dismiss:before{content:"\f153"}.dashicons-marker:before{content:"\f159"}.dashicons-star-filled:before{content:"\f155"}.dashicons-star-half:before{content:"\f459"}.dashicons-star-empty:before{content:"\f154"}.dashicons-flag:before{content:"\f227"}.dashicons-info:before{content:"\f348"}.dashicons-warning:before{content:"\f534"}.dashicons-share:before{content:"\f237"}.dashicons-share1:before{content:"\f237"}.dashicons-share-alt:before{content:"\f240"}.dashicons-share-alt2:before{content:"\f242"}.dashicons-twitter:before{content:"\f301"}.dashicons-rss:before{content:"\f303"}.dashicons-email:before{content:"\f465"}.dashicons-email-alt:before{content:"\f466"}.dashicons-facebook:before{content:"\f304"}.dashicons-facebook-alt:before{content:"\f305"}.dashicons-networking:before{content:"\f325"}.dashicons-googleplus:before{content:"\f462"}.dashicons-location:before{content:"\f230"}.dashicons-location-alt:before{content:"\f231"}.dashicons-camera:before{content:"\f306"}.dashicons-images-alt:before{content:"\f232"}.dashicons-images-alt2:before{content:"\f233"}.dashicons-video-alt:before{content:"\f234"}.dashicons-video-alt2:before{content:"\f235"}.dashicons-video-alt3:before{content:"\f236"}.dashicons-vault:before{content:"\f178"}.dashicons-shield:before{content:"\f332"}.dashicons-shield-alt:before{content:"\f334"}.dashicons-sos:before{content:"\f468"}.dashicons-search:before{content:"\f179"}.dashicons-slides:before{content:"\f181"}.dashicons-analytics:before{content:"\f183"}.dashicons-chart-pie:before{content:"\f184"}.dashicons-chart-bar:before{content:"\f185"}.dashicons-chart-line:before{content:"\f238"}.dashicons-chart-area:before{content:"\f239"}.dashicons-groups:before{content:"\f307"}.dashicons-businessman:before{content:"\f338"}.dashicons-id:before{content:"\f336"}.dashicons-id-alt:before{content:"\f337"}.dashicons-products:before{content:"\f312"}.dashicons-awards:before{content:"\f313"}.dashicons-forms:before{content:"\f314"}.dashicons-testimonial:before{content:"\f473"}.dashicons-portfolio:before{content:"\f322"}.dashicons-book:before{content:"\f330"}.dashicons-book-alt:before{content:"\f331"}.dashicons-download:before{content:"\f316"}.dashicons-upload:before{content:"\f317"}.dashicons-backup:before{content:"\f321"}.dashicons-clock:before{content:"\f469"}.dashicons-lightbulb:before{content:"\f339"}.dashicons-microphone:before{content:"\f482"}.dashicons-desktop:before{content:"\f472"}.dashicons-laptop:before{content:"\f547"}.dashicons-tablet:before{content:"\f471"}.dashicons-smartphone:before{content:"\f470"}.dashicons-phone:before{content:"\f525"}.dashicons-smiley:before{content:"\f328"}.dashicons-index-card:before{content:"\f510"}.dashicons-carrot:before{content:"\f511"}.dashicons-building:before{content:"\f512"}.dashicons-store:before{content:"\f513"}.dashicons-album:before{content:"\f514"}.dashicons-palmtree:before{content:"\f527"}.dashicons-tickets-alt:before{content:"\f524"}.dashicons-money:before{content:"\f526"}.dashicons-thumbs-up:before{content:"\f529"}.dashicons-thumbs-down:before{content:"\f542"}.dashicons-layout:before{content:"\f538"}.dashicons-paperclip:before{content:"\f546"} \ No newline at end of file diff --git a/backend/wp-includes/css/editor-rtl.css b/backend/wp-includes/css/editor-rtl.css new file mode 100644 index 0000000..b4b1d3c --- /dev/null +++ b/backend/wp-includes/css/editor-rtl.css @@ -0,0 +1,1851 @@ +/*------------------------------------------------------------------------------ + TinyMCE and Quicklinks toolbars +------------------------------------------------------------------------------*/ + +/* TinyMCE widgets/containers */ + +.mce-tinymce { + box-shadow: none; +} + +.mce-container, +.mce-container *, +.mce-widget, +.mce-widget * { + color: inherit; + font-family: inherit; +} + +.mce-container .mce-monospace, +.mce-widget .mce-monospace { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + line-height: 150%; +} + +/* TinyMCE windows */ +#mce-modal-block, +#mce-modal-block.mce-fade { + opacity: 0.7; + filter: alpha(opacity=70); + transition: none; + background: #000; +} + +.mce-window { + border-radius: 0; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + -webkit-font-smoothing: subpixel-antialiased; + transition: none; +} + +.mce-window .mce-container-body.mce-abs-layout { + overflow: visible; +} + +.mce-window .mce-window-head { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + padding: 0; + min-height: 36px; +} + +.mce-window .mce-window-head .mce-title { + color: #444; + font-size: 18px; + font-weight: 600; + line-height: 36px; + margin: 0; + padding: 0 16px 0 36px; +} + +.mce-window .mce-window-head .mce-close, +.mce-window-head .mce-close .mce-i-remove { + color: transparent; + top: 0; + left: 0; + width: 36px; + height: 36px; + padding: 0; + line-height: 36px; + text-align: center; +} + +.mce-window-head .mce-close .mce-i-remove:before { + font: normal 20px/36px dashicons; + text-align: center; + color: #666; + width: 36px; + height: 36px; + display: block; +} + +.mce-window-head .mce-close:hover .mce-i-remove:before, +.mce-window-head .mce-close:focus .mce-i-remove:before { + color: #00a0d2; +} + +.mce-window-head .mce-close:focus .mce-i-remove, +div.mce-tab:focus { + box-shadow: 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.mce-window .mce-window-head .mce-dragh { + width: calc( 100% - 36px ); +} + +.mce-window .mce-foot { + border-top: 1px solid #ddd; +} + +.mce-textbox, +.mce-checkbox i.mce-i-checkbox, +#wp-link .query-results { + border: 1px solid #ddd; + border-radius: 0; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.07); + transition: .05s all ease-in-out; +} + +.mce-textbox:focus, +.mce-textbox.mce-focus, +.mce-checkbox:focus i.mce-i-checkbox, +#wp-link .query-results:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba(30,140,190,0.8); +} + +.mce-window .mce-wp-help { + height: 360px; + width: 460px; + overflow: auto; +} + +.mce-window .mce-wp-help * { + box-sizing: border-box; +} + +.mce-window .mce-wp-help > .mce-container-body { + width: auto !important; +} + +.mce-window .wp-editor-help { + padding: 10px 20px 0 10px; +} + +.mce-window .wp-editor-help h2, +.mce-window .wp-editor-help p { + margin: 8px 0; + white-space: normal; + font-size: 14px; + font-weight: 400; +} + +.mce-window .wp-editor-help table { + width: 100%; + margin-bottom: 20px; +} + +.mce-window .wp-editor-help table.wp-help-single { + margin: 0 8px 20px; +} + +.mce-window .wp-editor-help table.fixed { + table-layout: fixed; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(odd), +.mce-window .wp-editor-help table.fixed td:nth-child(odd) { + width: 12%; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(even), +.mce-window .wp-editor-help table.fixed td:nth-child(even) { + width: 38%; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(odd) { + padding: 5px 0 0; +} + +.mce-window .wp-editor-help td, +.mce-window .wp-editor-help th { + font-size: 13px; + padding: 5px; + vertical-align: middle; + word-wrap: break-word; + white-space: normal; +} + +.mce-window .wp-editor-help th { + font-weight: 600; + padding-bottom: 0; +} + +.mce-window .wp-editor-help kbd { + font-family: monospace; + padding: 2px 7px 3px; + font-weight: 600; + margin: 0; + background: #eaeaea; + background: rgba(0,0,0,0.08); +} + +.mce-window .wp-help-th-center td:nth-child(odd), +.mce-window .wp-help-th-center th:nth-child(odd) { + text-align: center; +} + +/* TinyMCE menus */ +.mce-menu, +.mce-floatpanel.mce-popover { + border-color: rgba(0,0,0,0.15); + border-radius: 0; + box-shadow: 0 3px 5px rgba( 0, 0, 0, 0.2 ); +} + +.mce-menu, +.mce-floatpanel.mce-popover.mce-bottom { + margin-top: 2px; +} + +.mce-floatpanel .mce-arrow { + display: none; +} + +.mce-menu .mce-container-body { + min-width: 160px; +} + +.mce-menu-item { + border: none; + margin-bottom: 2px; + padding: 6px 12px 6px 15px; +} + +.mce-menu-has-icons i.mce-ico { + line-height: 20px; +} + +/* TinyMCE panel */ +div.mce-panel { + border: 0; + background: #fff; +} + +.mce-panel.mce-menu { + border: 1px solid #ddd; +} + +div.mce-tab { + line-height: 13px; +} + +/* TinyMCE toolbars */ +div.mce-toolbar-grp { + border-bottom: 1px solid #ddd; + background: #f5f5f5; + padding: 0; + position: relative; +} + +div.mce-inline-toolbar-grp { + border: 1px solid #a0a5aa; + border-radius: 2px; + box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.15 ); + box-sizing: border-box; + margin-bottom: 8px; + position: absolute; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + max-width: 98%; + z-index: 100100; /* Same as the other TinyMCE "panels" */ +} + +div.mce-inline-toolbar-grp > div.mce-stack-layout { + padding: 1px; +} + +div.mce-inline-toolbar-grp.mce-arrow-up { + margin-bottom: 0; + margin-top: 8px; +} + +div.mce-inline-toolbar-grp:before, +div.mce-inline-toolbar-grp:after { + position: absolute; + right: 50%; + display: block; + width: 0; + height: 0; + border-style: solid; + border-color: transparent; + content: ""; +} + +div.mce-inline-toolbar-grp.mce-arrow-up:before { + top: -9px; + border-bottom-color: #a0a5aa; + border-width: 0 9px 9px; + margin-right: -9px; +} + +div.mce-inline-toolbar-grp.mce-arrow-down:before { + bottom: -9px; + border-top-color: #a0a5aa; + border-width: 9px 9px 0; + margin-right: -9px; +} + +div.mce-inline-toolbar-grp.mce-arrow-up:after { + top: -8px; + border-bottom-color: #f5f5f5; + border-width: 0 8px 8px; + margin-right: -8px; +} + +div.mce-inline-toolbar-grp.mce-arrow-down:after { + bottom: -8px; + border-top-color: #f5f5f5; + border-width: 8px 8px 0; + margin-right: -8px; +} + +div.mce-inline-toolbar-grp.mce-arrow-left:before, +div.mce-inline-toolbar-grp.mce-arrow-left:after { + margin: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-left:before { + right: 20px; +} +div.mce-inline-toolbar-grp.mce-arrow-left:after { + right: 21px; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:before, +div.mce-inline-toolbar-grp.mce-arrow-right:after { + right: auto; + margin: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:before { + left: 20px; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:after { + left: 21px; +} + +div.mce-inline-toolbar-grp.mce-arrow-full { + left: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-full > div { + width: 100%; + overflow-x: auto; +} + +div.mce-toolbar-grp > div { + padding: 3px; +} + +.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first { + padding-left: 32px; +} + +.mce-toolbar .mce-btn-group { + margin: 0; +} + +div.mce-statusbar { + border-top: 1px solid #e5e5e5; +} + +div.mce-path { + padding: 2px 10px; + margin: 0; +} + +.mce-path, +.mce-path-item, +.mce-path .mce-divider { + font-size: 12px; +} + +.mce-toolbar .mce-btn, +.qt-dfw { + border-color: transparent; + background: transparent; + box-shadow: none; + text-shadow: none; + cursor: pointer; +} + +.mce-btn .mce-txt { + direction: inherit; + text-align: inherit; +} + +.mce-toolbar .mce-btn-group .mce-btn, +.qt-dfw { + border: 1px solid transparent; + margin: 2px; + border-radius: 2px; +} + +.mce-toolbar .mce-btn-group .mce-btn:hover, +.mce-toolbar .mce-btn-group .mce-btn:focus, +.qt-dfw:hover, +.qt-dfw:focus { + background: #fafafa; + border-color: #555d66; + color: #23282d; + box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 ); + outline: none; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-active, +.mce-toolbar .mce-btn-group .mce-btn:active, +.qt-dfw.active { + background: #ebebeb; + border-color: #555d66; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.3 ); +} + +.mce-btn.mce-active, +.mce-btn.mce-active button, +.mce-btn.mce-active:hover button, +.mce-btn.mce-active i, +.mce-btn.mce-active:hover i { + color: inherit; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-active:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-active:focus { + border-color: #23282d; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus { + color: #a0a5aa; + background: none; + border-color: #ddd; + text-shadow: 0 1px 0 #fff; + box-shadow: none; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus { + border-color: #555d66; +} + +.mce-toolbar .mce-btn-group .mce-first, +.mce-toolbar .mce-btn-group .mce-last { + border-color: transparent; +} + +.mce-toolbar .mce-btn button, +.qt-dfw { + padding: 2px 3px; + line-height: normal; +} + +.mce-toolbar .mce-listbox button { + font-size: 13px; + line-height: 20px; + padding-right: 6px; + padding-left: 20px; +} + +.mce-toolbar .mce-btn i { + text-shadow: none; +} + +.mce-toolbar .mce-btn-group > div { + white-space: normal; +} + +.mce-toolbar .mce-colorbutton .mce-open { + border-left: 0; +} + +.mce-toolbar .mce-colorbutton .mce-preview { + margin: 0; + padding: 0; + top: auto; + bottom: 2px; + right: 3px; + height: 3px; + width: 20px; + background: #555d66; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary { + min-width: 0; + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: none; +} + +/* Compensate for the extra box shadow at the bottom of .mce-btn.mce-primary */ +.mce-toolbar .mce-btn-group .mce-btn.mce-primary button { + padding: 2px 3px 1px; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico { + color: #fff; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { + box-shadow: 0 0 1px 1px #33b3db; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; +} + +/* mce listbox */ +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox { + border-radius: 0; + direction: rtl; + background: #fff; + border: 1px solid #ddd; + box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2); +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:focus { + border-color: #b4b9be; +} + +.mce-panel .mce-btn i.mce-caret { + border-top: 6px solid #555d66; + margin-right: 2px; + margin-left: 2px; +} + +.mce-listbox i.mce-caret { + left: 4px; +} + +.mce-panel .mce-btn:hover i.mce-caret, +.mce-panel .mce-btn:focus i.mce-caret { + border-top-color: #23282d; +} + +.mce-panel .mce-active i.mce-caret { + border-top: 0; + border-bottom: 6px solid #23282d; + margin-top: 7px; +} + +.mce-listbox.mce-active i.mce-caret { + margin-top: -3px; +} + +.mce-toolbar .mce-splitbtn:hover .mce-open { + border-left-color: transparent; +} + +.mce-toolbar .mce-splitbtn .mce-open.mce-active { + background: transparent; + outline: none; +} + +.mce-menu .mce-menu-item:hover, +.mce-menu .mce-menu-item.mce-selected, +.mce-menu .mce-menu-item:focus, +.mce-menu .mce-menu-item-normal.mce-active, +.mce-menu .mce-menu-item-preview.mce-active { + background: #0073aa; /* See color scheme. */ + color: #fff; +} + +.mce-menu-item:hover .mce-text, +.mce-menu-item:focus .mce-text, +.mce-menu-item:hover .mce-ico, +.mce-menu-item:focus .mce-ico, +.mce-menu-item:hover .mce-menu-shortcut, +.mce-menu-item:focus .mce-menu-shortcut, +.mce-menu-item.mce-active .mce-menu-shortcut, +.mce-menu-item.mce-disabled:hover .mce-text, +.mce-menu-item.mce-disabled:hover .mce-ico { + color: inherit; +} + +.mce-menu .mce-menu-item.mce-disabled { + cursor: default; +} + +.mce-menu .mce-menu-item.mce-disabled:hover { + background: #ccc; +} + +/* Menubar */ +div.mce-menubar { + border-color: #e5e5e5; + background: #fff; + border-width: 0px 0px 1px; +} + +.mce-menubar .mce-menubtn:hover, +.mce-menubar .mce-menubtn.mce-active, +.mce-menubar .mce-menubtn:focus { + border-color: transparent; + background: transparent; +} + +.mce-menubar .mce-menubtn:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +div.mce-menu .mce-menu-item-sep, +.mce-menu-item-sep:hover { + border-bottom: 1px solid #ddd; + height: 0px; + margin: 5px 0; +} + +.mce-menubtn span { + margin-left: 0; + padding-right: 3px; +} + +.mce-menu-has-icons i.mce-ico:before { + margin-right: -2px; +} + +/* Keyboard shortcuts position */ +.mce-menu.mce-menu-align .mce-menu-item-normal { + position: relative; +} + +.mce-menu.mce-menu-align .mce-menu-shortcut { + bottom: 0.6em; + font-size: 0.9em; +} + +/* Buttons in modals */ +.mce-primary button, +.mce-primary button i { + text-align: center; + color: #fff; + text-shadow: none; + padding: 0; + line-height: 26px; +} + +.mce-window .mce-btn { + color: #555; + background: #f7f7f7; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0; + cursor: pointer; + border: 1px solid #cccccc; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-shadow: 0 1px 0 #cccccc; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.mce-window .mce-btn::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.mce-window .mce-btn:hover, +.mce-window .mce-btn:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.mce-window .mce-btn:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.mce-window .mce-btn:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.mce-window .mce-btn.mce-disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +.mce-window .mce-btn.mce-primary { + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: 0 -1px 1px #006799, + -1px 0 1px #006799, + 0 1px 1px #006799, + 1px 0 1px #006799; +} + +.mce-window .mce-btn.mce-primary:hover, +.mce-window .mce-btn.mce-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.mce-window .mce-btn.mce-primary:focus { + box-shadow: 0 1px 0 #0073aa, + 0 0 2px 1px #33b3db; +} + +.mce-window .mce-btn.mce-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; + vertical-align: top; +} + +.mce-window .mce-btn.mce-primary.mce-disabled { + color: #66c6e4 !important; + background: #008ec2 !important; + border-color: #007cb2 !important; + box-shadow: none !important; + text-shadow: 0 -1px 0 rgba( 0, 0, 0, 0.1 ) !important; + cursor: default; +} + +.mce-menubtn.mce-fixed-width span { + overflow-x: hidden; + text-overflow: ellipsis; + width: 82px; +} + +/* Charmap modal */ +.mce-charmap { + margin: 3px; +} + +.mce-charmap td { + padding: 0; + border-color: #ddd; + cursor: pointer; +} + +.mce-charmap td:hover { + background: #f3f3f3; +} + +.mce-charmap td div { + width: 18px; + height: 22px; + line-height: 22px; +} + +/* TinyMCE tooltips */ +.mce-tooltip { + margin-top: 2px; +} + +/* Don't show the tooltip. Used in Chrome RTL, see #42018 */ +.rtl .mce-tooltip.wp-hide-mce-tooltip { + display: none !important; +} + +.mce-tooltip-inner { + border-radius: 3px; + box-shadow: 0 3px 5px rgba( 0, 0, 0, 0.2 ); + color: #fff; + font-size: 12px; +} + +/* TinyMCE icons */ +.mce-ico { + font-family: 'tinymce', Arial; +} + +.mce-btn-small .mce-ico { + font-family: 'tinymce-small', Arial; +} + +.mce-toolbar .mce-ico { + color: #555d66; + line-height: 20px; + width: 20px; + height: 20px; + text-align: center; + text-shadow: none; + margin: 0; + padding: 0; +} + +.qt-dfw { + color: #555d66; + line-height: 20px; + width: 28px; + height: 26px; + text-align: center; + text-shadow: none; +} + +.mce-toolbar .mce-btn .mce-open { + line-height: 20px; +} + +.mce-toolbar .mce-btn:hover .mce-open, +.mce-toolbar .mce-btn:focus .mce-open, +.mce-toolbar .mce-btn.mce-active .mce-open { + border-right-color: #23282d; +} + +div.mce-notification { + right: 10% !important; + left: 10%; +} + +.mce-notification button.mce-close { + left: 6px; + top: 3px; + font-weight: 400; + color: #555d66; +} + +.mce-notification button.mce-close:hover, +.mce-notification button.mce-close:focus { + color: #000; +} + +i.mce-i-bold, +i.mce-i-italic, +i.mce-i-bullist, +i.mce-i-numlist, +i.mce-i-blockquote, +i.mce-i-alignleft, +i.mce-i-aligncenter, +i.mce-i-alignright, +i.mce-i-link, +i.mce-i-unlink, +i.mce-i-wp_more, +i.mce-i-strikethrough, +i.mce-i-spellchecker, +i.mce-i-fullscreen, +i.mce-i-wp_fullscreen, +i.mce-i-dfw, +i.mce-i-wp_adv, +i.mce-i-underline, +i.mce-i-alignjustify, +i.mce-i-forecolor, +i.mce-i-backcolor, +i.mce-i-pastetext, +i.mce-i-pasteword, +i.mce-i-removeformat, +i.mce-i-charmap, +i.mce-i-outdent, +i.mce-i-indent, +i.mce-i-undo, +i.mce-i-redo, +i.mce-i-help, +i.mce-i-wp_help, +i.mce-i-wp-media-library, +i.mce-i-ltr, +i.mce-i-wp_page, +i.mce-i-hr, +i.mce-i-wp_code, +i.mce-i-dashicon, +i.mce-i-remove { + font: normal 20px/1 dashicons; + padding: 0; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + margin-right: -2px; + padding-left: 2px; +} + +.qt-dfw { + font: normal 20px/1 dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +i.mce-i-bold:before { + content: "\f200"; +} + +i.mce-i-italic:before { + content: "\f201"; +} + +i.mce-i-bullist:before { + content: "\f203"; +} + +i.mce-i-numlist:before { + content: "\f204"; +} + +i.mce-i-blockquote:before { + content: "\f205"; +} + +i.mce-i-alignleft:before { + content: "\f206"; +} + +i.mce-i-aligncenter:before { + content: "\f207"; +} + +i.mce-i-alignright:before { + content: "\f208"; +} + +i.mce-i-link:before { + content: "\f103"; +} + +i.mce-i-unlink:before { + content: "\f225"; +} + +i.mce-i-wp_more:before { + content: "\f209"; +} + +i.mce-i-strikethrough:before { + content: "\f224"; +} + +i.mce-i-spellchecker:before { + content: "\f210"; +} + +i.mce-i-fullscreen:before, +i.mce-i-wp_fullscreen:before, +i.mce-i-dfw:before, +.qt-dfw:before { + content: "\f211"; +} + +i.mce-i-wp_adv:before { + content: "\f212"; +} + +i.mce-i-underline:before { + content: "\f213"; +} + +i.mce-i-alignjustify:before { + content: "\f214"; +} + +i.mce-i-forecolor:before, +i.mce-i-backcolor:before { + content: "\f215"; +} + +i.mce-i-pastetext:before { + content: "\f217"; +} + +i.mce-i-removeformat:before { + content: "\f218"; +} + +i.mce-i-charmap:before { + content: "\f220"; +} + +i.mce-i-outdent:before { + content: "\f221"; +} + +i.mce-i-indent:before { + content: "\f222"; +} + +i.mce-i-undo:before { + content: "\f171"; +} + +i.mce-i-redo:before { + content: "\f172"; +} + +i.mce-i-help:before, +i.mce-i-wp_help:before { + content: "\f223"; +} + +i.mce-i-wp-media-library:before { + content: "\f104"; +} + +i.mce-i-ltr:before { + content: "\f320"; +} + +i.mce-i-wp_page:before { + content: "\f105"; +} + +i.mce-i-hr:before { + content: "\f460"; +} + +i.mce-i-remove:before { + content: "\f158"; +} + +i.mce-i-wp_code:before { + content: "\f475"; +} + +/* RTL button icons */ +.rtl i.mce-i-outdent:before { + content: "\f222"; +} + +.rtl i.mce-i-indent:before { + content: "\f221"; +} + +/* Editors */ +.wp-editor-wrap { + position: relative; +} + +.wp-editor-tools { + position: relative; + z-index: 1; +} + +.wp-editor-tools:after { + clear: both; + content: ""; + display: table; +} + +.wp-editor-container { + clear: both; + border: 1px solid #e5e5e5; +} + +.wp-editor-area { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + padding: 10px; + margin: 1px 0 0; + line-height: 150%; + border: 0; + outline: none; + display: block; + resize: vertical; + box-sizing: border-box; +} + +.rtl .wp-editor-area { + font-family: Tahoma, Monaco, monospace; +} + +.locale-he-il .wp-editor-area { + font-family: Arial, Monaco, monospace; +} + +.wp-editor-container textarea.wp-editor-area { + width: 100%; + margin: 0; + box-shadow: none; +} + +.wp-editor-tabs { + float: left; +} + +.wp-switch-editor { + float: right; + box-sizing: content-box; + position: relative; + top: 1px; + background: #ebebeb; + color: #666; + cursor: pointer; + font-size: 13px; + line-height: 19px; + height: 20px; + margin: 5px 5px 0 0; + padding: 3px 8px 4px; + border: 1px solid #e5e5e5; +} + +.wp-switch-editor:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); + outline: none; + color: #23282d; +} + +.wp-switch-editor:active, +.html-active .switch-html:focus, +.tmce-active .switch-tmce:focus { + box-shadow: none; +} + +.wp-switch-editor:active { + background-color: #f5f5f5; + box-shadow: none; +} + +.js .tmce-active .wp-editor-area { + color: #fff; +} + +.tmce-active .quicktags-toolbar { + display: none; +} + +.tmce-active .switch-tmce, +.html-active .switch-html { + background: #f5f5f5; + color: #555; + border-bottom-color: #f5f5f5; +} + +.wp-media-buttons { + float: right; +} + +.wp-media-buttons .button { + margin-left: 5px; + margin-bottom: 4px; + padding-right: 7px; + padding-left: 7px; +} + +.wp-media-buttons .button:active { + position: relative; + top: 1px; + margin-top: -1px; + margin-bottom: 1px; +} + +.wp-media-buttons .insert-media { + padding-right: 5px; +} + +.wp-media-buttons a { + text-decoration: none; + color: #444; + font-size: 12px; +} + +.wp-media-buttons img { + padding: 0 4px; + vertical-align: middle; +} + +.wp-media-buttons span.wp-media-buttons-icon { + display: inline-block; + width: 18px; + height: 18px; + vertical-align: text-top; + margin: 0 2px; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon { + background: none; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon:before { + font: normal 18px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon:before { + content: "\f104"; +} + +/* Quicktags */ +.quicktags-toolbar { + padding: 3px; + position: relative; + border-bottom: 1px solid #ddd; + background: #f5f5f5; + min-height: 30px; +} + +.has-dfw .quicktags-toolbar { + padding-left: 35px; +} + +.wp-core-ui .quicktags-toolbar input.button.button-small { + margin: 2px; +} + +.quicktags-toolbar input[value="link"] { + text-decoration: underline; +} + +.quicktags-toolbar input[value="del"] { + text-decoration: line-through; +} + +.quicktags-toolbar input[value="i"] { + font-style: italic; +} + +.quicktags-toolbar input[value="b"] { + font-weight: 600; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw, +.qt-dfw { + position: absolute; + top: 0; + left: 0; + margin: 5px 0 0 5px; +} + +.qt-fullscreen { + position: static; + margin: 2px; +} + +@media screen and ( max-width: 782px ) { + .mce-toolbar .mce-btn button, + .qt-dfw { + padding: 6px 7px; + } + + /* Compensate for the extra box shadow at the bottom of .mce-btn.mce-primary */ + .mce-toolbar .mce-btn-group .mce-btn.mce-primary button { + padding: 6px 7px 5px; + } + + .mce-toolbar .mce-btn-group .mce-btn { + margin: 1px; + } + + .qt-dfw { + width: 36px; + height: 34px; + } + + .mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw { + margin: 4px 0 0 4px; + } + + .mce-toolbar .mce-colorbutton .mce-preview { + right: 8px; + bottom: 6px; + } + + .mce-window .mce-btn { + padding: 2px 0; + } + + .has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first, + .has-dfw .quicktags-toolbar { + padding-left: 40px; + } +} + +@media screen and ( min-width: 782px ) { + .wp-core-ui .quicktags-toolbar input.button.button-small { + /* .button-small is normally 11px, but a bit too small for these buttons. */ + font-size: 12px; + height: 26px; + line-height: 24px; + } +} + +#wp_editbtns, +#wp_gallerybtns { + padding: 2px; + position: absolute; + display: none; + z-index: 100020; +} + +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { + border-color: #999; + background-color: #eee; + margin: 2px; + padding: 2px; + border-width: 1px; + border-style: solid; + border-radius: 3px; +} + +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { + border-color: #555; + background-color: #ccc; +} + +/*------------------------------------------------------------------------------ + wp-link +------------------------------------------------------------------------------*/ + +#wp-link-wrap { + display: none; + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + width: 500px; + overflow: hidden; + margin-right: -250px; + margin-top: -125px; + position: fixed; + top: 50%; + right: 50%; + z-index: 100105; + transition: height 0.2s, margin-top 0.2s; +} + +#wp-link-backdrop { + display: none; + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100100; +} + +#wp-link { + position: relative; + height: 100%; +} + +#wp-link-wrap { + height: 500px; + margin-top: -250px; +} + +#wp-link-wrap .wp-link-text-field { + display: none; +} + +#wp-link-wrap.has-text-field .wp-link-text-field { + display: block; +} + +#link-modal-title { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + margin: 0; + padding: 0 16px 0 36px; +} + +#wp-link-close { + color: #666; + padding: 0; + position: absolute; + top: 0; + left: 0; + width: 36px; + height: 36px; + text-align: center; + background: none; + border: none; + cursor: pointer; +} + +#wp-link-close:before { + font: normal 20px/36px dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + width: 36px; + height: 36px; + content: "\f158"; +} + +#wp-link-close:hover, +#wp-link-close:focus { + color: #00a0d2; +} + +#wp-link-close:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#wp-link-wrap #link-selector { + -webkit-overflow-scrolling: touch; + padding: 0 16px; + position: absolute; + top: 37px; + right: 0; + left: 0; + bottom: 44px; +} + +#wp-link ol, +#wp-link ul { + list-style: none; + margin: 0; + padding: 0; +} + +#wp-link input[type="text"] { + box-sizing: border-box; +} + +#wp-link #link-options { + padding: 8px 0 12px; +} + +#wp-link p.howto { + margin: 3px 0; +} + +#wp-link p.howto a { + text-decoration: none; + color: inherit; +} + +#wp-link label input[type="text"] { + margin-top: 5px; + width: 70%; +} + +#wp-link #link-options label span, +#wp-link #search-panel label span.search-label { + display: inline-block; + width: 80px; + text-align: left; + padding-left: 5px; + max-width: 24%; + vertical-align: middle; + word-wrap: break-word; +} + +#wp-link .link-search-field { + float: right; + width: 250px; + max-width: 70%; +} + +#wp-link .link-search-wrapper { + margin: 5px 0 9px; + display: block; + overflow: hidden; +} + +#wp-link .link-search-wrapper span { + float: right; + margin-top: 4px; +} + +#wp-link .link-search-wrapper .spinner { + margin-top: 5px; +} + +#wp-link .link-target { + padding: 3px 0 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +#wp-link .link-target label { + max-width: 70%; +} + +#wp-link .query-results { + border: 1px #dfdfdf solid; + margin: 0 0 12px; + background: #fff; + overflow: auto; + position: absolute; + right: 16px; + left: 16px; + bottom: 0; + top: 166px; +} + +.has-text-field #wp-link .query-results { + top: 200px; +} + +#wp-link li { + clear: both; + margin-bottom: 0; + border-bottom: 1px solid #f1f1f1; + color: #32373c; + padding: 4px 10px 4px 6px; + cursor: pointer; + position: relative; +} + +#wp-link .query-notice { + padding: 0; + border-bottom: 1px solid #dfdfdf; + background-color: #f7fcfe; + color: #000; +} + +#wp-link .query-notice .query-notice-default, +#wp-link .query-notice .query-notice-hint { + display: block; + padding: 6px; + border-right: 4px solid #00a0d2; +} + +#wp-link .unselectable.no-matches-found { + padding: 0; + border-bottom: 1px solid #dfdfdf; + background-color: #fef7f1; +} + +#wp-link .no-matches-found .item-title { + display: block; + padding: 6px; + border-right: 4px solid #d54e21; +} + +#wp-link .query-results em { + font-style: normal; +} + +#wp-link li:hover { + background: #eaf2fa; + color: #151515; +} + +#wp-link li.unselectable { + border-bottom: 1px solid #dfdfdf; +} + +#wp-link li.unselectable:hover { + background: #fff; + cursor: auto; + color: #32373c; +} + +#wp-link li.selected { + background: #ddd; + color: #32373c; +} + +#wp-link li.selected .item-title { + font-weight: 600; +} + +#wp-link li:last-child { + border: none; +} + +#wp-link .item-title { + display: inline-block; + width: 80%; + width: calc(100% - 68px); + word-wrap: break-word; +} + +#wp-link .item-info { + text-transform: uppercase; + color: #666; + font-size: 11px; + position: absolute; + left: 5px; + top: 5px; +} + +#wp-link .river-waiting { + display: none; + padding: 10px 0; +} + +#wp-link .submitbox { + padding: 8px 16px; + background: #fcfcfc; + border-top: 1px solid #ddd; + position: absolute; + bottom: 0; + right: 0; + left: 0; +} + +#wp-link-cancel { + line-height: 25px; + float: right; +} + +#wp-link-update { + line-height: 23px; + float: left; +} + +#wp-link-submit { + float: left; +} + +@media screen and ( max-width: 782px ) { + #wp-link-wrap { + margin-top: -140px; + } + + #wp-link-wrap .query-results { + top: 195px; + } + + #wp-link-wrap.has-text-field .query-results { + top: 235px; + } + + #link-selector { + padding: 0 16px 60px; + } + + #wp-link-wrap #link-selector { + bottom: 52px; + } + + #wp-link-cancel { + line-height: 32px; + } + + #wp-link .link-target { + padding-top: 10px; + } + + #wp-link .submitbox .button { + margin-bottom: 0; + } +} + +@media screen and ( max-width: 520px ) { + #wp-link-wrap { + width: auto; + margin-right: 0; + right: 10px; + left: 10px; + max-width: 500px; + } +} + +@media screen and ( max-height: 520px ) { + #wp-link-wrap { + transition: none; + height: auto; + margin-top: 0; + top: 10px; + bottom: 10px; + } + + #link-selector { + overflow: auto; + } + + #search-panel .query-results { + position: static; + } +} + +@media screen and ( max-height: 290px ) { + #wp-link-wrap { + height: auto; + margin-top: 0; + top: 10px; + bottom: 10px; + } + + #link-selector { + overflow: auto; + height: calc(100% - 92px); + padding-bottom: 2px; + } + + #search-panel .query-results { + position: static; + } +} + +div.wp-link-preview { + float: right; + margin: 5px; + max-width: 694px; + overflow: hidden; + text-overflow: ellipsis; +} + +div.wp-link-preview a { + color: #0073aa; + text-decoration: underline; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; + cursor: pointer; +} + +div.wp-link-preview a.wplink-url-error { + color: #dc3232; +} + +div.wp-link-input { + float: right; + margin: 2px; + max-width: 694px; +} + +div.wp-link-input input { + width: 300px; + padding: 3px; + box-sizing: border-box; +} + +.mce-toolbar div.wp-link-preview ~ .mce-btn, +.mce-toolbar div.wp-link-input ~ .mce-btn { + margin: 2px 1px; +} + +.mce-inline-toolbar-grp .mce-btn-group .mce-btn:last-child { + margin-left: 2px; +} + +.ui-autocomplete.wplink-autocomplete { + z-index: 100110; + max-height: 200px; + overflow-y: auto; + padding: 0; + margin: 0; + list-style: none; + position: absolute; + border: 1px solid #5b9dd9; + box-shadow: 0 1px 2px rgba( 30, 140, 190, 0.8 ); + background-color: #fff; +} + +.ui-autocomplete.wplink-autocomplete li { + margin-bottom: 0; + padding: 4px 10px; + clear: both; + white-space: normal; + text-align: right; +} + +.ui-autocomplete.wplink-autocomplete li .wp-editor-float-right { + float: left; +} + +.ui-autocomplete.wplink-autocomplete li.ui-state-focus { + background-color: #ddd; + cursor: pointer; +} + +@media screen and ( max-width: 782px ) { + div.wp-link-preview, + div.wp-link-input { + max-width: 70%; + max-width: calc(100% - 86px); + } + + div.wp-link-preview { + margin: 8px 5px 8px 0; + } + + div.wp-link-input { + width: 300px; + } + + div.wp-link-input input { + width: 100%; + font-size: 16px; + padding: 5px; + } +} + +/* =Overlay Body +-------------------------------------------------------------- */ + +.mce-fullscreen { + z-index: 100010; +} + +/* =Localization +-------------------------------------------------------------- */ +.rtl .wp-switch-editor, +.rtl .quicktags-toolbar input { + font-family: Tahoma, sans-serif; +} + +/* rtl:ignore */ +.mce-rtl .mce-flow-layout .mce-flow-layout-item > div { + direction: rtl; +} + +/* rtl:ignore */ +.mce-rtl .mce-listbox i.mce-caret { + left: 6px; +} + +html:lang(he-il) .rtl .wp-switch-editor, +html:lang(he-il) .rtl .quicktags-toolbar input { + font-family: Arial, sans-serif; +} + +/* HiDPI */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .wp-media-buttons .add_media span.wp-media-buttons-icon { + background: none; + } +} diff --git a/backend/wp-includes/css/editor-rtl.min.css b/backend/wp-includes/css/editor-rtl.min.css new file mode 100644 index 0000000..12e2d34 --- /dev/null +++ b/backend/wp-includes/css/editor-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.mce-window .mce-wp-help *,.wp-editor-area{box-sizing:border-box}.mce-tinymce{box-shadow:none}#wp-link-wrap,.mce-window{box-shadow:0 3px 6px rgba(0,0,0,.3)}.mce-container,.mce-container *,.mce-widget,.mce-widget *{color:inherit;font-family:inherit}.mce-container .mce-monospace,.mce-widget .mce-monospace{font-family:Consolas,Monaco,monospace;font-size:13px;line-height:150%}#mce-modal-block,#mce-modal-block.mce-fade{opacity:.7;filter:alpha(opacity=70);transition:none;background:#000}.mce-window{border-radius:0;-webkit-font-smoothing:subpixel-antialiased;transition:none}.mce-window .mce-container-body.mce-abs-layout{overflow:visible}.mce-window .mce-window-head{background:#fcfcfc;border-bottom:1px solid #ddd;padding:0;min-height:36px}.mce-window .mce-window-head .mce-title{color:#444;font-size:18px;font-weight:600;line-height:36px;margin:0;padding:0 16px 0 36px}.mce-window .mce-window-head .mce-close,.mce-window-head .mce-close .mce-i-remove{color:transparent;top:0;left:0;width:36px;height:36px;padding:0;line-height:36px;text-align:center}.mce-window-head .mce-close .mce-i-remove:before{font:400 20px/36px dashicons;text-align:center;color:#666;width:36px;height:36px;display:block}.mce-window-head .mce-close:focus .mce-i-remove:before,.mce-window-head .mce-close:hover .mce-i-remove:before{color:#00a0d2}.mce-window-head .mce-close:focus .mce-i-remove,div.mce-tab:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.mce-window .mce-window-head .mce-dragh{width:calc(100% - 36px)}.mce-window .mce-foot{border-top:1px solid #ddd}#wp-link .query-results,.mce-checkbox i.mce-i-checkbox,.mce-textbox{border:1px solid #ddd;border-radius:0;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);transition:.05s all ease-in-out}#wp-link .query-results:focus,.mce-checkbox:focus i.mce-i-checkbox,.mce-textbox.mce-focus,.mce-textbox:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.mce-window .mce-wp-help{height:360px;width:460px;overflow:auto}.mce-window .mce-wp-help>.mce-container-body{width:auto!important}.mce-window .wp-editor-help{padding:10px 20px 0 10px}.mce-window .wp-editor-help h2,.mce-window .wp-editor-help p{margin:8px 0;white-space:normal;font-size:14px;font-weight:400}.mce-window .wp-editor-help table{width:100%;margin-bottom:20px}.mce-window .wp-editor-help table.wp-help-single{margin:0 8px 20px}.mce-window .wp-editor-help table.fixed{table-layout:fixed}.mce-window .wp-editor-help table.fixed td:nth-child(odd),.mce-window .wp-editor-help table.fixed th:nth-child(odd){width:12%}.mce-window .wp-editor-help table.fixed td:nth-child(even),.mce-window .wp-editor-help table.fixed th:nth-child(even){width:38%}.mce-window .wp-editor-help table.fixed th:nth-child(odd){padding:5px 0 0}.mce-window .wp-editor-help td,.mce-window .wp-editor-help th{font-size:13px;padding:5px;vertical-align:middle;word-wrap:break-word;white-space:normal}.mce-window .wp-editor-help th{font-weight:600;padding-bottom:0}.mce-window .wp-editor-help kbd{font-family:monospace;padding:2px 7px 3px;font-weight:600;margin:0;background:#eaeaea;background:rgba(0,0,0,.08)}.mce-window .wp-help-th-center td:nth-child(odd),.mce-window .wp-help-th-center th:nth-child(odd){text-align:center}.mce-floatpanel.mce-popover,.mce-menu{border-color:rgba(0,0,0,.15);border-radius:0;box-shadow:0 3px 5px rgba(0,0,0,.2)}.mce-floatpanel.mce-popover.mce-bottom,.mce-menu{margin-top:2px}.mce-floatpanel .mce-arrow{display:none}.mce-menu .mce-container-body{min-width:160px}.mce-menu-item{border:none;margin-bottom:2px;padding:6px 12px 6px 15px}.mce-menu-has-icons i.mce-ico{line-height:20px}div.mce-panel{border:0;background:#fff}.mce-panel.mce-menu{border:1px solid #ddd}div.mce-tab{line-height:13px}div.mce-toolbar-grp{border-bottom:1px solid #ddd;background:#f5f5f5;padding:0;position:relative}div.mce-inline-toolbar-grp{border:1px solid #a0a5aa;border-radius:2px;box-shadow:0 1px 3px rgba(0,0,0,.15);box-sizing:border-box;margin-bottom:8px;position:absolute;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;max-width:98%;z-index:100100}div.mce-inline-toolbar-grp>div.mce-stack-layout{padding:1px}div.mce-inline-toolbar-grp.mce-arrow-up{margin-bottom:0;margin-top:8px}div.mce-inline-toolbar-grp:after,div.mce-inline-toolbar-grp:before{position:absolute;right:50%;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.mce-menu.mce-menu-align .mce-menu-item-normal,.quicktags-toolbar,.wp-editor-tools,.wp-editor-wrap,.wp-switch-editor{position:relative}div.mce-inline-toolbar-grp.mce-arrow-up:before{top:-9px;border-bottom-color:#a0a5aa;border-width:0 9px 9px;margin-right:-9px}div.mce-inline-toolbar-grp.mce-arrow-down:before{bottom:-9px;border-top-color:#a0a5aa;border-width:9px 9px 0;margin-right:-9px}div.mce-inline-toolbar-grp.mce-arrow-up:after{top:-8px;border-bottom-color:#f5f5f5;border-width:0 8px 8px;margin-right:-8px}div.mce-inline-toolbar-grp.mce-arrow-down:after{bottom:-8px;border-top-color:#f5f5f5;border-width:8px 8px 0;margin-right:-8px}div.mce-inline-toolbar-grp.mce-arrow-left:after,div.mce-inline-toolbar-grp.mce-arrow-left:before{margin:0}div.mce-inline-toolbar-grp.mce-arrow-left:before{right:20px}div.mce-inline-toolbar-grp.mce-arrow-left:after{right:21px}div.mce-inline-toolbar-grp.mce-arrow-right:after,div.mce-inline-toolbar-grp.mce-arrow-right:before{right:auto;margin:0}div.mce-inline-toolbar-grp.mce-arrow-right:before{left:20px}div.mce-inline-toolbar-grp.mce-arrow-right:after{left:21px}div.mce-inline-toolbar-grp.mce-arrow-full{left:0}div.mce-inline-toolbar-grp.mce-arrow-full>div{width:100%;overflow-x:auto}div.mce-toolbar-grp>div{padding:3px}.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first{padding-left:32px}.mce-toolbar .mce-btn-group{margin:0}div.mce-statusbar{border-top:1px solid #e5e5e5}div.mce-path{padding:2px 10px;margin:0}.mce-path,.mce-path .mce-divider,.mce-path-item{font-size:12px}.mce-toolbar .mce-btn,.qt-dfw{border-color:transparent;background:0 0;box-shadow:none;text-shadow:none;cursor:pointer}.mce-btn .mce-txt{direction:inherit;text-align:inherit}.mce-toolbar .mce-btn-group .mce-btn,.qt-dfw{border:1px solid transparent;margin:2px;border-radius:2px}.mce-toolbar .mce-btn-group .mce-btn:focus,.mce-toolbar .mce-btn-group .mce-btn:hover,.qt-dfw:focus,.qt-dfw:hover{background:#fafafa;border-color:#555d66;color:#23282d;box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,.08);outline:0}.mce-toolbar .mce-btn-group .mce-btn.mce-active,.mce-toolbar .mce-btn-group .mce-btn:active,.qt-dfw.active{background:#ebebeb;border-color:#555d66;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.3)}.mce-btn.mce-active,.mce-btn.mce-active button,.mce-btn.mce-active i,.mce-btn.mce-active:hover button,.mce-btn.mce-active:hover i{color:inherit}.mce-toolbar .mce-btn-group .mce-btn.mce-active:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-active:hover{border-color:#23282d}.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:hover{color:#a0a5aa;background:0 0;border-color:#ddd;text-shadow:0 1px 0 #fff;box-shadow:none}.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus{border-color:#555d66}.mce-toolbar .mce-btn-group .mce-first,.mce-toolbar .mce-btn-group .mce-last{border-color:transparent}.mce-toolbar .mce-btn button,.qt-dfw{padding:2px 3px;line-height:normal}.mce-toolbar .mce-listbox button{font-size:13px;line-height:20px;padding-right:6px;padding-left:20px}.mce-toolbar .mce-btn i{text-shadow:none}.mce-toolbar .mce-btn-group>div{white-space:normal}.mce-toolbar .mce-colorbutton .mce-open{border-left:0}.mce-toolbar .mce-colorbutton .mce-preview{margin:0;padding:0;top:auto;bottom:2px;right:3px;height:3px;width:20px;background:#555d66}.mce-toolbar .mce-btn-group .mce-btn.mce-primary{min-width:0;background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:none}.mce-toolbar .mce-btn-group .mce-btn.mce-primary button{padding:2px 3px 1px}.mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico{color:#fff}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus{box-shadow:0 0 1px 1px #33b3db}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799}.mce-toolbar .mce-btn-group .mce-btn.mce-listbox{border-radius:0;direction:rtl;background:#fff;border:1px solid #ddd;box-shadow:inset 0 1px 1px -1px rgba(0,0,0,.2)}.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:hover{border-color:#b4b9be}.mce-panel .mce-btn i.mce-caret{border-top:6px solid #555d66;margin-right:2px;margin-left:2px}.mce-listbox i.mce-caret{left:4px}.mce-panel .mce-btn:focus i.mce-caret,.mce-panel .mce-btn:hover i.mce-caret{border-top-color:#23282d}.mce-panel .mce-active i.mce-caret{border-top:0;border-bottom:6px solid #23282d;margin-top:7px}.mce-listbox.mce-active i.mce-caret{margin-top:-3px}.mce-toolbar .mce-splitbtn:hover .mce-open{border-left-color:transparent}.mce-toolbar .mce-splitbtn .mce-open.mce-active{background:0 0;outline:0}.mce-menu .mce-menu-item-normal.mce-active,.mce-menu .mce-menu-item-preview.mce-active,.mce-menu .mce-menu-item.mce-selected,.mce-menu .mce-menu-item:focus,.mce-menu .mce-menu-item:hover{background:#0073aa;color:#fff}.mce-menu-item.mce-active .mce-menu-shortcut,.mce-menu-item.mce-disabled:hover .mce-ico,.mce-menu-item.mce-disabled:hover .mce-text,.mce-menu-item:focus .mce-ico,.mce-menu-item:focus .mce-menu-shortcut,.mce-menu-item:focus .mce-text,.mce-menu-item:hover .mce-ico,.mce-menu-item:hover .mce-menu-shortcut,.mce-menu-item:hover .mce-text{color:inherit}.mce-menu .mce-menu-item.mce-disabled{cursor:default}.mce-menu .mce-menu-item.mce-disabled:hover{background:#ccc}div.mce-menubar{border-color:#e5e5e5;background:#fff;border-width:0 0 1px}.mce-menubar .mce-menubtn.mce-active,.mce-menubar .mce-menubtn:focus,.mce-menubar .mce-menubtn:hover{border-color:transparent;background:0 0}.mce-menubar .mce-menubtn:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.mce-menu-item-sep:hover,div.mce-menu .mce-menu-item-sep{border-bottom:1px solid #ddd;height:0;margin:5px 0}.mce-menubtn span{margin-left:0;padding-right:3px}.mce-menu-has-icons i.mce-ico:before{margin-right:-2px}.mce-menu.mce-menu-align .mce-menu-shortcut{bottom:.6em;font-size:.9em}.mce-primary button,.mce-primary button i{text-align:center;color:#fff;text-shadow:none;padding:0;line-height:26px}.mce-window .mce-btn{color:#555;background:#f7f7f7;text-decoration:none;font-size:13px;line-height:26px;height:28px;margin:0;padding:0;cursor:pointer;border:1px solid #ccc;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-shadow:0 1px 0 #ccc}.mce-window .mce-btn::-moz-focus-inner{border-width:0;border-style:none;padding:0}.mce-window .mce-btn:focus,.mce-window .mce-btn:hover{background:#fafafa;border-color:#999;color:#23282d}.mce-window .mce-btn:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.mce-window .mce-btn:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.mce-window .mce-btn.mce-disabled{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}.mce-window .mce-btn.mce-primary{background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,-1px 0 1px #006799,0 1px 1px #006799,1px 0 1px #006799}.mce-window .mce-btn.mce-primary:focus,.mce-window .mce-btn.mce-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.mce-window .mce-btn.mce-primary:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}.mce-window .mce-btn.mce-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799;vertical-align:top}.mce-window .mce-btn.mce-primary.mce-disabled{color:#66c6e4!important;background:#008ec2!important;border-color:#007cb2!important;box-shadow:none!important;text-shadow:0 -1px 0 rgba(0,0,0,.1)!important;cursor:default}.mce-toolbar .mce-ico,.qt-dfw{text-shadow:none;text-align:center}.mce-menubtn.mce-fixed-width span{overflow-x:hidden;text-overflow:ellipsis;width:82px}.mce-charmap{margin:3px}.mce-charmap td{padding:0;border-color:#ddd;cursor:pointer}.mce-charmap td:hover{background:#f3f3f3}.mce-charmap td div{width:18px;height:22px;line-height:22px}.mce-toolbar .mce-btn .mce-open,.qt-dfw{line-height:20px}.mce-tooltip{margin-top:2px}.rtl .mce-tooltip.wp-hide-mce-tooltip{display:none!important}.mce-tooltip-inner{border-radius:3px;box-shadow:0 3px 5px rgba(0,0,0,.2);color:#fff;font-size:12px}.mce-ico{font-family:tinymce,Arial}.mce-btn-small .mce-ico{font-family:tinymce-small,Arial}.mce-toolbar .mce-ico{color:#555d66;line-height:20px;width:20px;height:20px;margin:0;padding:0}.qt-dfw{color:#555d66;width:28px;height:26px}.mce-toolbar .mce-btn.mce-active .mce-open,.mce-toolbar .mce-btn:focus .mce-open,.mce-toolbar .mce-btn:hover .mce-open{border-right-color:#23282d}div.mce-notification{right:10%!important;left:10%}.mce-notification button.mce-close{left:6px;top:3px;font-weight:400;color:#555d66}.mce-notification button.mce-close:focus,.mce-notification button.mce-close:hover{color:#000}i.mce-i-aligncenter,i.mce-i-alignjustify,i.mce-i-alignleft,i.mce-i-alignright,i.mce-i-backcolor,i.mce-i-blockquote,i.mce-i-bold,i.mce-i-bullist,i.mce-i-charmap,i.mce-i-dashicon,i.mce-i-dfw,i.mce-i-forecolor,i.mce-i-fullscreen,i.mce-i-help,i.mce-i-hr,i.mce-i-indent,i.mce-i-italic,i.mce-i-link,i.mce-i-ltr,i.mce-i-numlist,i.mce-i-outdent,i.mce-i-pastetext,i.mce-i-pasteword,i.mce-i-redo,i.mce-i-remove,i.mce-i-removeformat,i.mce-i-spellchecker,i.mce-i-strikethrough,i.mce-i-underline,i.mce-i-undo,i.mce-i-unlink,i.mce-i-wp-media-library,i.mce-i-wp_adv,i.mce-i-wp_code,i.mce-i-wp_fullscreen,i.mce-i-wp_help,i.mce-i-wp_more,i.mce-i-wp_page{font:400 20px/1 dashicons;padding:0 0 0 2px;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin-right:-2px}.qt-dfw{font:400 20px/1 dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}i.mce-i-bold:before{content:"\f200"}i.mce-i-italic:before{content:"\f201"}i.mce-i-bullist:before{content:"\f203"}i.mce-i-numlist:before{content:"\f204"}i.mce-i-blockquote:before{content:"\f205"}i.mce-i-alignleft:before{content:"\f206"}i.mce-i-aligncenter:before{content:"\f207"}i.mce-i-alignright:before{content:"\f208"}i.mce-i-link:before{content:"\f103"}i.mce-i-unlink:before{content:"\f225"}i.mce-i-wp_more:before{content:"\f209"}i.mce-i-strikethrough:before{content:"\f224"}i.mce-i-spellchecker:before{content:"\f210"}.qt-dfw:before,i.mce-i-dfw:before,i.mce-i-fullscreen:before,i.mce-i-wp_fullscreen:before{content:"\f211"}i.mce-i-wp_adv:before{content:"\f212"}i.mce-i-underline:before{content:"\f213"}i.mce-i-alignjustify:before{content:"\f214"}i.mce-i-backcolor:before,i.mce-i-forecolor:before{content:"\f215"}i.mce-i-pastetext:before{content:"\f217"}i.mce-i-removeformat:before{content:"\f218"}i.mce-i-charmap:before{content:"\f220"}i.mce-i-outdent:before{content:"\f221"}i.mce-i-indent:before{content:"\f222"}i.mce-i-undo:before{content:"\f171"}i.mce-i-redo:before{content:"\f172"}i.mce-i-help:before,i.mce-i-wp_help:before{content:"\f223"}i.mce-i-wp-media-library:before{content:"\f104"}i.mce-i-ltr:before{content:"\f320"}i.mce-i-wp_page:before{content:"\f105"}i.mce-i-hr:before{content:"\f460"}i.mce-i-remove:before{content:"\f158"}i.mce-i-wp_code:before{content:"\f475"}.rtl i.mce-i-outdent:before{content:"\f222"}.rtl i.mce-i-indent:before{content:"\f221"}.wp-editor-tools{z-index:1}.wp-editor-tools:after{clear:both;content:"";display:table}.wp-editor-container{clear:both;border:1px solid #e5e5e5}.wp-editor-area{font-family:Consolas,Monaco,monospace;font-size:13px;padding:10px;margin:1px 0 0;line-height:150%;border:0;outline:0;display:block;resize:vertical}.rtl .wp-editor-area{font-family:Tahoma,Monaco,monospace}.locale-he-il .wp-editor-area{font-family:Arial,Monaco,monospace}.wp-editor-container textarea.wp-editor-area{width:100%;margin:0;box-shadow:none}.wp-editor-tabs{float:left}.wp-switch-editor{float:right;box-sizing:content-box;top:1px;background:#ebebeb;color:#666;cursor:pointer;font-size:13px;line-height:19px;height:20px;margin:5px 5px 0 0;padding:3px 8px 4px;border:1px solid #e5e5e5}.wp-switch-editor:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8);outline:0;color:#23282d}.html-active .switch-html:focus,.tmce-active .switch-tmce:focus,.wp-switch-editor:active{box-shadow:none}.wp-switch-editor:active{background-color:#f5f5f5;box-shadow:none}.js .tmce-active .wp-editor-area{color:#fff}.tmce-active .quicktags-toolbar{display:none}.html-active .switch-html,.tmce-active .switch-tmce{background:#f5f5f5;color:#555;border-bottom-color:#f5f5f5}.wp-media-buttons{float:right}.wp-media-buttons .button{margin-left:5px;margin-bottom:4px;padding-right:7px;padding-left:7px}.wp-media-buttons .button:active{position:relative;top:1px;margin-top:-1px;margin-bottom:1px}.wp-media-buttons .insert-media{padding-right:5px}.wp-media-buttons a{text-decoration:none;color:#444;font-size:12px}.wp-media-buttons img{padding:0 4px;vertical-align:middle}.wp-media-buttons span.wp-media-buttons-icon{display:inline-block;width:18px;height:18px;vertical-align:text-top;margin:0 2px}.wp-media-buttons .add_media span.wp-media-buttons-icon{background:0 0}.wp-media-buttons .add_media span.wp-media-buttons-icon:before{font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f104"}.quicktags-toolbar{padding:3px;border-bottom:1px solid #ddd;background:#f5f5f5;min-height:30px}.has-dfw .quicktags-toolbar{padding-left:35px}.wp-core-ui .quicktags-toolbar input.button.button-small{margin:2px}.quicktags-toolbar input[value=link]{text-decoration:underline}.quicktags-toolbar input[value=del]{text-decoration:line-through}.quicktags-toolbar input[value="i"]{font-style:italic}.quicktags-toolbar input[value="b"]{font-weight:600}.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw,.qt-dfw{position:absolute;top:0;left:0;margin:5px 0 0 5px}.qt-fullscreen{position:static;margin:2px}@media screen and (max-width:782px){.mce-toolbar .mce-btn button,.qt-dfw{padding:6px 7px}.mce-toolbar .mce-btn-group .mce-btn.mce-primary button{padding:6px 7px 5px}.mce-toolbar .mce-btn-group .mce-btn{margin:1px}.qt-dfw{width:36px;height:34px}.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw{margin:4px 0 0 4px}.mce-toolbar .mce-colorbutton .mce-preview{right:8px;bottom:6px}.mce-window .mce-btn{padding:2px 0}.has-dfw .quicktags-toolbar,.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first{padding-left:40px}}@media screen and (min-width:782px){.wp-core-ui .quicktags-toolbar input.button.button-small{font-size:12px;height:26px;line-height:24px}}#wp_editbtns,#wp_gallerybtns{padding:2px;position:absolute;display:none;z-index:100020}#wp_delgallery,#wp_delimgbtn,#wp_editgallery,#wp_editimgbtn{border-color:#999;background-color:#eee;margin:2px;padding:2px;border-width:1px;border-style:solid;border-radius:3px}#wp_delgallery:hover,#wp_delimgbtn:hover,#wp_editgallery:hover,#wp_editimgbtn:hover{border-color:#555;background-color:#ccc}#wp-link-wrap{display:none;background-color:#fff;width:500px;overflow:hidden;margin-right:-250px;position:fixed;top:50%;right:50%;z-index:100105;transition:height .2s,margin-top .2s;height:500px;margin-top:-250px}#wp-link-backdrop{display:none;position:fixed;top:0;right:0;left:0;bottom:0;min-height:360px;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100100}#wp-link{position:relative;height:100%}#wp-link-wrap .wp-link-text-field{display:none}#wp-link-wrap.has-text-field .wp-link-text-field{display:block}#link-modal-title{background:#fcfcfc;border-bottom:1px solid #ddd;height:36px;font-size:18px;font-weight:600;line-height:36px;margin:0;padding:0 16px 0 36px}#wp-link-close{color:#666;padding:0;position:absolute;top:0;left:0;width:36px;height:36px;text-align:center;background:0 0;border:none;cursor:pointer}#wp-link-close:before{font:400 20px/36px dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:36px;height:36px;content:"\f158"}#wp-link-close:focus,#wp-link-close:hover{color:#00a0d2}#wp-link-close:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#wp-link-wrap #link-selector{-webkit-overflow-scrolling:touch;padding:0 16px;position:absolute;top:37px;right:0;left:0;bottom:44px}#wp-link ol,#wp-link ul{list-style:none;margin:0;padding:0}#wp-link input[type=text]{box-sizing:border-box}#wp-link #link-options{padding:8px 0 12px}#wp-link p.howto{margin:3px 0}#wp-link p.howto a{text-decoration:none;color:inherit}#wp-link label input[type=text]{margin-top:5px;width:70%}#wp-link #link-options label span,#wp-link #search-panel label span.search-label{display:inline-block;width:80px;text-align:left;padding-left:5px;max-width:24%;vertical-align:middle;word-wrap:break-word}#wp-link .link-search-field{float:right;width:250px;max-width:70%}#wp-link .link-search-wrapper{margin:5px 0 9px;display:block;overflow:hidden}#wp-link .link-search-wrapper span{float:right;margin-top:4px}#wp-link .link-search-wrapper .spinner{margin-top:5px}#wp-link .link-target{padding:3px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#wp-link .link-target label{max-width:70%}#wp-link .query-results{border:1px solid #dfdfdf;margin:0 0 12px;background:#fff;overflow:auto;position:absolute;right:16px;left:16px;bottom:0;top:166px}.has-text-field #wp-link .query-results{top:200px}#wp-link li{clear:both;margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#32373c;padding:4px 10px 4px 6px;cursor:pointer;position:relative}#wp-link .query-notice,#wp-link li.unselectable{border-bottom:1px solid #dfdfdf}#wp-link .query-notice{padding:0;background-color:#f7fcfe;color:#000}#wp-link .query-notice .query-notice-default,#wp-link .query-notice .query-notice-hint{display:block;padding:6px;border-right:4px solid #00a0d2}#wp-link .unselectable.no-matches-found{padding:0;border-bottom:1px solid #dfdfdf;background-color:#fef7f1}#wp-link .no-matches-found .item-title{display:block;padding:6px;border-right:4px solid #d54e21}#wp-link .query-results em{font-style:normal}#wp-link li:hover{background:#eaf2fa;color:#151515}#wp-link li.unselectable:hover{background:#fff;cursor:auto;color:#32373c}#wp-link li.selected{background:#ddd;color:#32373c}#wp-link li.selected .item-title{font-weight:600}#wp-link li:last-child{border:none}#wp-link .item-title{display:inline-block;width:80%;width:calc(100% - 68px);word-wrap:break-word}#wp-link .item-info{text-transform:uppercase;color:#666;font-size:11px;position:absolute;left:5px;top:5px}#wp-link .river-waiting{display:none;padding:10px 0}#wp-link .submitbox{padding:8px 16px;background:#fcfcfc;border-top:1px solid #ddd;position:absolute;bottom:0;right:0;left:0}#wp-link-cancel{line-height:25px;float:right}#wp-link-update{line-height:23px;float:left}#wp-link-submit{float:left}@media screen and (max-width:782px){#wp-link-wrap{margin-top:-140px}#wp-link-wrap .query-results{top:195px}#wp-link-wrap.has-text-field .query-results{top:235px}#link-selector{padding:0 16px 60px}#wp-link-wrap #link-selector{bottom:52px}#wp-link-cancel{line-height:32px}#wp-link .link-target{padding-top:10px}#wp-link .submitbox .button{margin-bottom:0}}@media screen and (max-width:520px){#wp-link-wrap{width:auto;margin-right:0;right:10px;left:10px;max-width:500px}}@media screen and (max-height:520px){#wp-link-wrap{transition:none;height:auto;margin-top:0;top:10px;bottom:10px}#link-selector{overflow:auto}#search-panel .query-results{position:static}}@media screen and (max-height:290px){#wp-link-wrap{height:auto;margin-top:0;top:10px;bottom:10px}#link-selector{overflow:auto;height:calc(100% - 92px);padding-bottom:2px}#search-panel .query-results{position:static}}div.wp-link-preview{float:right;margin:5px;max-width:694px;overflow:hidden;text-overflow:ellipsis}div.wp-link-preview a{color:#0073aa;text-decoration:underline;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out;cursor:pointer}div.wp-link-preview a.wplink-url-error{color:#dc3232}div.wp-link-input{float:right;margin:2px;max-width:694px}div.wp-link-input input{width:300px;padding:3px;box-sizing:border-box}.mce-toolbar div.wp-link-input~.mce-btn,.mce-toolbar div.wp-link-preview~.mce-btn{margin:2px 1px}.mce-inline-toolbar-grp .mce-btn-group .mce-btn:last-child{margin-left:2px}.ui-autocomplete.wplink-autocomplete{z-index:100110;max-height:200px;overflow-y:auto;padding:0;margin:0;list-style:none;position:absolute;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete.wplink-autocomplete li{margin-bottom:0;padding:4px 10px;clear:both;white-space:normal;text-align:right}.ui-autocomplete.wplink-autocomplete li .wp-editor-float-right{float:left}.ui-autocomplete.wplink-autocomplete li.ui-state-focus{background-color:#ddd;cursor:pointer}@media screen and (max-width:782px){div.wp-link-input,div.wp-link-preview{max-width:70%;max-width:calc(100% - 86px)}div.wp-link-preview{margin:8px 5px 8px 0}div.wp-link-input{width:300px}div.wp-link-input input{width:100%;font-size:16px;padding:5px}}.mce-fullscreen{z-index:100010}.rtl .quicktags-toolbar input,.rtl .wp-switch-editor{font-family:Tahoma,sans-serif}.mce-rtl .mce-flow-layout .mce-flow-layout-item>div{direction:rtl}.mce-rtl .mce-listbox i.mce-caret{left:6px}html:lang(he-il) .rtl .quicktags-toolbar input,html:lang(he-il) .rtl .wp-switch-editor{font-family:Arial,sans-serif}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-media-buttons .add_media span.wp-media-buttons-icon{background:0 0}} \ No newline at end of file diff --git a/backend/wp-includes/css/editor.css b/backend/wp-includes/css/editor.css new file mode 100644 index 0000000..d8cba05 --- /dev/null +++ b/backend/wp-includes/css/editor.css @@ -0,0 +1,1851 @@ +/*------------------------------------------------------------------------------ + TinyMCE and Quicklinks toolbars +------------------------------------------------------------------------------*/ + +/* TinyMCE widgets/containers */ + +.mce-tinymce { + box-shadow: none; +} + +.mce-container, +.mce-container *, +.mce-widget, +.mce-widget * { + color: inherit; + font-family: inherit; +} + +.mce-container .mce-monospace, +.mce-widget .mce-monospace { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + line-height: 150%; +} + +/* TinyMCE windows */ +#mce-modal-block, +#mce-modal-block.mce-fade { + opacity: 0.7; + filter: alpha(opacity=70); + transition: none; + background: #000; +} + +.mce-window { + border-radius: 0; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + -webkit-font-smoothing: subpixel-antialiased; + transition: none; +} + +.mce-window .mce-container-body.mce-abs-layout { + overflow: visible; +} + +.mce-window .mce-window-head { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + padding: 0; + min-height: 36px; +} + +.mce-window .mce-window-head .mce-title { + color: #444; + font-size: 18px; + font-weight: 600; + line-height: 36px; + margin: 0; + padding: 0 36px 0 16px; +} + +.mce-window .mce-window-head .mce-close, +.mce-window-head .mce-close .mce-i-remove { + color: transparent; + top: 0; + right: 0; + width: 36px; + height: 36px; + padding: 0; + line-height: 36px; + text-align: center; +} + +.mce-window-head .mce-close .mce-i-remove:before { + font: normal 20px/36px dashicons; + text-align: center; + color: #666; + width: 36px; + height: 36px; + display: block; +} + +.mce-window-head .mce-close:hover .mce-i-remove:before, +.mce-window-head .mce-close:focus .mce-i-remove:before { + color: #00a0d2; +} + +.mce-window-head .mce-close:focus .mce-i-remove, +div.mce-tab:focus { + box-shadow: 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.mce-window .mce-window-head .mce-dragh { + width: calc( 100% - 36px ); +} + +.mce-window .mce-foot { + border-top: 1px solid #ddd; +} + +.mce-textbox, +.mce-checkbox i.mce-i-checkbox, +#wp-link .query-results { + border: 1px solid #ddd; + border-radius: 0; + box-shadow: inset 0 1px 2px rgba(0,0,0,0.07); + transition: .05s all ease-in-out; +} + +.mce-textbox:focus, +.mce-textbox.mce-focus, +.mce-checkbox:focus i.mce-i-checkbox, +#wp-link .query-results:focus { + border-color: #5b9dd9; + box-shadow: 0 0 2px rgba(30,140,190,0.8); +} + +.mce-window .mce-wp-help { + height: 360px; + width: 460px; + overflow: auto; +} + +.mce-window .mce-wp-help * { + box-sizing: border-box; +} + +.mce-window .mce-wp-help > .mce-container-body { + width: auto !important; +} + +.mce-window .wp-editor-help { + padding: 10px 10px 0 20px; +} + +.mce-window .wp-editor-help h2, +.mce-window .wp-editor-help p { + margin: 8px 0; + white-space: normal; + font-size: 14px; + font-weight: 400; +} + +.mce-window .wp-editor-help table { + width: 100%; + margin-bottom: 20px; +} + +.mce-window .wp-editor-help table.wp-help-single { + margin: 0 8px 20px; +} + +.mce-window .wp-editor-help table.fixed { + table-layout: fixed; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(odd), +.mce-window .wp-editor-help table.fixed td:nth-child(odd) { + width: 12%; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(even), +.mce-window .wp-editor-help table.fixed td:nth-child(even) { + width: 38%; +} + +.mce-window .wp-editor-help table.fixed th:nth-child(odd) { + padding: 5px 0 0; +} + +.mce-window .wp-editor-help td, +.mce-window .wp-editor-help th { + font-size: 13px; + padding: 5px; + vertical-align: middle; + word-wrap: break-word; + white-space: normal; +} + +.mce-window .wp-editor-help th { + font-weight: 600; + padding-bottom: 0; +} + +.mce-window .wp-editor-help kbd { + font-family: monospace; + padding: 2px 7px 3px; + font-weight: 600; + margin: 0; + background: #eaeaea; + background: rgba(0,0,0,0.08); +} + +.mce-window .wp-help-th-center td:nth-child(odd), +.mce-window .wp-help-th-center th:nth-child(odd) { + text-align: center; +} + +/* TinyMCE menus */ +.mce-menu, +.mce-floatpanel.mce-popover { + border-color: rgba(0,0,0,0.15); + border-radius: 0; + box-shadow: 0 3px 5px rgba( 0, 0, 0, 0.2 ); +} + +.mce-menu, +.mce-floatpanel.mce-popover.mce-bottom { + margin-top: 2px; +} + +.mce-floatpanel .mce-arrow { + display: none; +} + +.mce-menu .mce-container-body { + min-width: 160px; +} + +.mce-menu-item { + border: none; + margin-bottom: 2px; + padding: 6px 15px 6px 12px; +} + +.mce-menu-has-icons i.mce-ico { + line-height: 20px; +} + +/* TinyMCE panel */ +div.mce-panel { + border: 0; + background: #fff; +} + +.mce-panel.mce-menu { + border: 1px solid #ddd; +} + +div.mce-tab { + line-height: 13px; +} + +/* TinyMCE toolbars */ +div.mce-toolbar-grp { + border-bottom: 1px solid #ddd; + background: #f5f5f5; + padding: 0; + position: relative; +} + +div.mce-inline-toolbar-grp { + border: 1px solid #a0a5aa; + border-radius: 2px; + box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.15 ); + box-sizing: border-box; + margin-bottom: 8px; + position: absolute; + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + max-width: 98%; + z-index: 100100; /* Same as the other TinyMCE "panels" */ +} + +div.mce-inline-toolbar-grp > div.mce-stack-layout { + padding: 1px; +} + +div.mce-inline-toolbar-grp.mce-arrow-up { + margin-bottom: 0; + margin-top: 8px; +} + +div.mce-inline-toolbar-grp:before, +div.mce-inline-toolbar-grp:after { + position: absolute; + left: 50%; + display: block; + width: 0; + height: 0; + border-style: solid; + border-color: transparent; + content: ""; +} + +div.mce-inline-toolbar-grp.mce-arrow-up:before { + top: -9px; + border-bottom-color: #a0a5aa; + border-width: 0 9px 9px; + margin-left: -9px; +} + +div.mce-inline-toolbar-grp.mce-arrow-down:before { + bottom: -9px; + border-top-color: #a0a5aa; + border-width: 9px 9px 0; + margin-left: -9px; +} + +div.mce-inline-toolbar-grp.mce-arrow-up:after { + top: -8px; + border-bottom-color: #f5f5f5; + border-width: 0 8px 8px; + margin-left: -8px; +} + +div.mce-inline-toolbar-grp.mce-arrow-down:after { + bottom: -8px; + border-top-color: #f5f5f5; + border-width: 8px 8px 0; + margin-left: -8px; +} + +div.mce-inline-toolbar-grp.mce-arrow-left:before, +div.mce-inline-toolbar-grp.mce-arrow-left:after { + margin: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-left:before { + left: 20px; +} +div.mce-inline-toolbar-grp.mce-arrow-left:after { + left: 21px; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:before, +div.mce-inline-toolbar-grp.mce-arrow-right:after { + left: auto; + margin: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:before { + right: 20px; +} + +div.mce-inline-toolbar-grp.mce-arrow-right:after { + right: 21px; +} + +div.mce-inline-toolbar-grp.mce-arrow-full { + right: 0; +} + +div.mce-inline-toolbar-grp.mce-arrow-full > div { + width: 100%; + overflow-x: auto; +} + +div.mce-toolbar-grp > div { + padding: 3px; +} + +.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first { + padding-right: 32px; +} + +.mce-toolbar .mce-btn-group { + margin: 0; +} + +div.mce-statusbar { + border-top: 1px solid #e5e5e5; +} + +div.mce-path { + padding: 2px 10px; + margin: 0; +} + +.mce-path, +.mce-path-item, +.mce-path .mce-divider { + font-size: 12px; +} + +.mce-toolbar .mce-btn, +.qt-dfw { + border-color: transparent; + background: transparent; + box-shadow: none; + text-shadow: none; + cursor: pointer; +} + +.mce-btn .mce-txt { + direction: inherit; + text-align: inherit; +} + +.mce-toolbar .mce-btn-group .mce-btn, +.qt-dfw { + border: 1px solid transparent; + margin: 2px; + border-radius: 2px; +} + +.mce-toolbar .mce-btn-group .mce-btn:hover, +.mce-toolbar .mce-btn-group .mce-btn:focus, +.qt-dfw:hover, +.qt-dfw:focus { + background: #fafafa; + border-color: #555d66; + color: #23282d; + box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 ); + outline: none; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-active, +.mce-toolbar .mce-btn-group .mce-btn:active, +.qt-dfw.active { + background: #ebebeb; + border-color: #555d66; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.3 ); +} + +.mce-btn.mce-active, +.mce-btn.mce-active button, +.mce-btn.mce-active:hover button, +.mce-btn.mce-active i, +.mce-btn.mce-active:hover i { + color: inherit; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-active:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-active:focus { + border-color: #23282d; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus { + color: #a0a5aa; + background: none; + border-color: #ddd; + text-shadow: 0 1px 0 #fff; + box-shadow: none; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus { + border-color: #555d66; +} + +.mce-toolbar .mce-btn-group .mce-first, +.mce-toolbar .mce-btn-group .mce-last { + border-color: transparent; +} + +.mce-toolbar .mce-btn button, +.qt-dfw { + padding: 2px 3px; + line-height: normal; +} + +.mce-toolbar .mce-listbox button { + font-size: 13px; + line-height: 20px; + padding-left: 6px; + padding-right: 20px; +} + +.mce-toolbar .mce-btn i { + text-shadow: none; +} + +.mce-toolbar .mce-btn-group > div { + white-space: normal; +} + +.mce-toolbar .mce-colorbutton .mce-open { + border-right: 0; +} + +.mce-toolbar .mce-colorbutton .mce-preview { + margin: 0; + padding: 0; + top: auto; + bottom: 2px; + left: 3px; + height: 3px; + width: 20px; + background: #555d66; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary { + min-width: 0; + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: none; +} + +/* Compensate for the extra box shadow at the bottom of .mce-btn.mce-primary */ +.mce-toolbar .mce-btn-group .mce-btn.mce-primary button { + padding: 2px 3px 1px; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico { + color: #fff; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus { + box-shadow: 0 0 1px 1px #33b3db; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; +} + +/* mce listbox */ +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox { + border-radius: 0; + direction: ltr; + background: #fff; + border: 1px solid #ddd; + box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2); +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:hover, +.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:focus { + border-color: #b4b9be; +} + +.mce-panel .mce-btn i.mce-caret { + border-top: 6px solid #555d66; + margin-left: 2px; + margin-right: 2px; +} + +.mce-listbox i.mce-caret { + right: 4px; +} + +.mce-panel .mce-btn:hover i.mce-caret, +.mce-panel .mce-btn:focus i.mce-caret { + border-top-color: #23282d; +} + +.mce-panel .mce-active i.mce-caret { + border-top: 0; + border-bottom: 6px solid #23282d; + margin-top: 7px; +} + +.mce-listbox.mce-active i.mce-caret { + margin-top: -3px; +} + +.mce-toolbar .mce-splitbtn:hover .mce-open { + border-right-color: transparent; +} + +.mce-toolbar .mce-splitbtn .mce-open.mce-active { + background: transparent; + outline: none; +} + +.mce-menu .mce-menu-item:hover, +.mce-menu .mce-menu-item.mce-selected, +.mce-menu .mce-menu-item:focus, +.mce-menu .mce-menu-item-normal.mce-active, +.mce-menu .mce-menu-item-preview.mce-active { + background: #0073aa; /* See color scheme. */ + color: #fff; +} + +.mce-menu-item:hover .mce-text, +.mce-menu-item:focus .mce-text, +.mce-menu-item:hover .mce-ico, +.mce-menu-item:focus .mce-ico, +.mce-menu-item:hover .mce-menu-shortcut, +.mce-menu-item:focus .mce-menu-shortcut, +.mce-menu-item.mce-active .mce-menu-shortcut, +.mce-menu-item.mce-disabled:hover .mce-text, +.mce-menu-item.mce-disabled:hover .mce-ico { + color: inherit; +} + +.mce-menu .mce-menu-item.mce-disabled { + cursor: default; +} + +.mce-menu .mce-menu-item.mce-disabled:hover { + background: #ccc; +} + +/* Menubar */ +div.mce-menubar { + border-color: #e5e5e5; + background: #fff; + border-width: 0px 0px 1px; +} + +.mce-menubar .mce-menubtn:hover, +.mce-menubar .mce-menubtn.mce-active, +.mce-menubar .mce-menubtn:focus { + border-color: transparent; + background: transparent; +} + +.mce-menubar .mce-menubtn:focus { + color: #124964; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +div.mce-menu .mce-menu-item-sep, +.mce-menu-item-sep:hover { + border-bottom: 1px solid #ddd; + height: 0px; + margin: 5px 0; +} + +.mce-menubtn span { + margin-right: 0; + padding-left: 3px; +} + +.mce-menu-has-icons i.mce-ico:before { + margin-left: -2px; +} + +/* Keyboard shortcuts position */ +.mce-menu.mce-menu-align .mce-menu-item-normal { + position: relative; +} + +.mce-menu.mce-menu-align .mce-menu-shortcut { + bottom: 0.6em; + font-size: 0.9em; +} + +/* Buttons in modals */ +.mce-primary button, +.mce-primary button i { + text-align: center; + color: #fff; + text-shadow: none; + padding: 0; + line-height: 26px; +} + +.mce-window .mce-btn { + color: #555; + background: #f7f7f7; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0; + cursor: pointer; + border: 1px solid #cccccc; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-shadow: 0 1px 0 #cccccc; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.mce-window .mce-btn::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.mce-window .mce-btn:hover, +.mce-window .mce-btn:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.mce-window .mce-btn:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.mce-window .mce-btn:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.mce-window .mce-btn.mce-disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +.mce-window .mce-btn.mce-primary { + background: #0085ba; + border-color: #0073aa #006799 #006799; + box-shadow: 0 1px 0 #006799; + color: #fff; + text-decoration: none; + text-shadow: 0 -1px 1px #006799, + 1px 0 1px #006799, + 0 1px 1px #006799, + -1px 0 1px #006799; +} + +.mce-window .mce-btn.mce-primary:hover, +.mce-window .mce-btn.mce-primary:focus { + background: #008ec2; + border-color: #006799; + color: #fff; +} + +.mce-window .mce-btn.mce-primary:focus { + box-shadow: 0 1px 0 #0073aa, + 0 0 2px 1px #33b3db; +} + +.mce-window .mce-btn.mce-primary:active { + background: #0073aa; + border-color: #006799; + box-shadow: inset 0 2px 0 #006799; + vertical-align: top; +} + +.mce-window .mce-btn.mce-primary.mce-disabled { + color: #66c6e4 !important; + background: #008ec2 !important; + border-color: #007cb2 !important; + box-shadow: none !important; + text-shadow: 0 -1px 0 rgba( 0, 0, 0, 0.1 ) !important; + cursor: default; +} + +.mce-menubtn.mce-fixed-width span { + overflow-x: hidden; + text-overflow: ellipsis; + width: 82px; +} + +/* Charmap modal */ +.mce-charmap { + margin: 3px; +} + +.mce-charmap td { + padding: 0; + border-color: #ddd; + cursor: pointer; +} + +.mce-charmap td:hover { + background: #f3f3f3; +} + +.mce-charmap td div { + width: 18px; + height: 22px; + line-height: 22px; +} + +/* TinyMCE tooltips */ +.mce-tooltip { + margin-top: 2px; +} + +/* Don't show the tooltip. Used in Chrome RTL, see #42018 */ +.rtl .mce-tooltip.wp-hide-mce-tooltip { + display: none !important; +} + +.mce-tooltip-inner { + border-radius: 3px; + box-shadow: 0 3px 5px rgba( 0, 0, 0, 0.2 ); + color: #fff; + font-size: 12px; +} + +/* TinyMCE icons */ +.mce-ico { + font-family: 'tinymce', Arial; +} + +.mce-btn-small .mce-ico { + font-family: 'tinymce-small', Arial; +} + +.mce-toolbar .mce-ico { + color: #555d66; + line-height: 20px; + width: 20px; + height: 20px; + text-align: center; + text-shadow: none; + margin: 0; + padding: 0; +} + +.qt-dfw { + color: #555d66; + line-height: 20px; + width: 28px; + height: 26px; + text-align: center; + text-shadow: none; +} + +.mce-toolbar .mce-btn .mce-open { + line-height: 20px; +} + +.mce-toolbar .mce-btn:hover .mce-open, +.mce-toolbar .mce-btn:focus .mce-open, +.mce-toolbar .mce-btn.mce-active .mce-open { + border-left-color: #23282d; +} + +div.mce-notification { + left: 10% !important; + right: 10%; +} + +.mce-notification button.mce-close { + right: 6px; + top: 3px; + font-weight: 400; + color: #555d66; +} + +.mce-notification button.mce-close:hover, +.mce-notification button.mce-close:focus { + color: #000; +} + +i.mce-i-bold, +i.mce-i-italic, +i.mce-i-bullist, +i.mce-i-numlist, +i.mce-i-blockquote, +i.mce-i-alignleft, +i.mce-i-aligncenter, +i.mce-i-alignright, +i.mce-i-link, +i.mce-i-unlink, +i.mce-i-wp_more, +i.mce-i-strikethrough, +i.mce-i-spellchecker, +i.mce-i-fullscreen, +i.mce-i-wp_fullscreen, +i.mce-i-dfw, +i.mce-i-wp_adv, +i.mce-i-underline, +i.mce-i-alignjustify, +i.mce-i-forecolor, +i.mce-i-backcolor, +i.mce-i-pastetext, +i.mce-i-pasteword, +i.mce-i-removeformat, +i.mce-i-charmap, +i.mce-i-outdent, +i.mce-i-indent, +i.mce-i-undo, +i.mce-i-redo, +i.mce-i-help, +i.mce-i-wp_help, +i.mce-i-wp-media-library, +i.mce-i-ltr, +i.mce-i-wp_page, +i.mce-i-hr, +i.mce-i-wp_code, +i.mce-i-dashicon, +i.mce-i-remove { + font: normal 20px/1 dashicons; + padding: 0; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + margin-left: -2px; + padding-right: 2px; +} + +.qt-dfw { + font: normal 20px/1 dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +i.mce-i-bold:before { + content: "\f200"; +} + +i.mce-i-italic:before { + content: "\f201"; +} + +i.mce-i-bullist:before { + content: "\f203"; +} + +i.mce-i-numlist:before { + content: "\f204"; +} + +i.mce-i-blockquote:before { + content: "\f205"; +} + +i.mce-i-alignleft:before { + content: "\f206"; +} + +i.mce-i-aligncenter:before { + content: "\f207"; +} + +i.mce-i-alignright:before { + content: "\f208"; +} + +i.mce-i-link:before { + content: "\f103"; +} + +i.mce-i-unlink:before { + content: "\f225"; +} + +i.mce-i-wp_more:before { + content: "\f209"; +} + +i.mce-i-strikethrough:before { + content: "\f224"; +} + +i.mce-i-spellchecker:before { + content: "\f210"; +} + +i.mce-i-fullscreen:before, +i.mce-i-wp_fullscreen:before, +i.mce-i-dfw:before, +.qt-dfw:before { + content: "\f211"; +} + +i.mce-i-wp_adv:before { + content: "\f212"; +} + +i.mce-i-underline:before { + content: "\f213"; +} + +i.mce-i-alignjustify:before { + content: "\f214"; +} + +i.mce-i-forecolor:before, +i.mce-i-backcolor:before { + content: "\f215"; +} + +i.mce-i-pastetext:before { + content: "\f217"; +} + +i.mce-i-removeformat:before { + content: "\f218"; +} + +i.mce-i-charmap:before { + content: "\f220"; +} + +i.mce-i-outdent:before { + content: "\f221"; +} + +i.mce-i-indent:before { + content: "\f222"; +} + +i.mce-i-undo:before { + content: "\f171"; +} + +i.mce-i-redo:before { + content: "\f172"; +} + +i.mce-i-help:before, +i.mce-i-wp_help:before { + content: "\f223"; +} + +i.mce-i-wp-media-library:before { + content: "\f104"; +} + +i.mce-i-ltr:before { + content: "\f320"; +} + +i.mce-i-wp_page:before { + content: "\f105"; +} + +i.mce-i-hr:before { + content: "\f460"; +} + +i.mce-i-remove:before { + content: "\f158"; +} + +i.mce-i-wp_code:before { + content: "\f475"; +} + +/* RTL button icons */ +.rtl i.mce-i-outdent:before { + content: "\f222"; +} + +.rtl i.mce-i-indent:before { + content: "\f221"; +} + +/* Editors */ +.wp-editor-wrap { + position: relative; +} + +.wp-editor-tools { + position: relative; + z-index: 1; +} + +.wp-editor-tools:after { + clear: both; + content: ""; + display: table; +} + +.wp-editor-container { + clear: both; + border: 1px solid #e5e5e5; +} + +.wp-editor-area { + font-family: Consolas, Monaco, monospace; + font-size: 13px; + padding: 10px; + margin: 1px 0 0; + line-height: 150%; + border: 0; + outline: none; + display: block; + resize: vertical; + box-sizing: border-box; +} + +.rtl .wp-editor-area { + font-family: Tahoma, Monaco, monospace; +} + +.locale-he-il .wp-editor-area { + font-family: Arial, Monaco, monospace; +} + +.wp-editor-container textarea.wp-editor-area { + width: 100%; + margin: 0; + box-shadow: none; +} + +.wp-editor-tabs { + float: right; +} + +.wp-switch-editor { + float: left; + box-sizing: content-box; + position: relative; + top: 1px; + background: #ebebeb; + color: #666; + cursor: pointer; + font-size: 13px; + line-height: 19px; + height: 20px; + margin: 5px 0 0 5px; + padding: 3px 8px 4px; + border: 1px solid #e5e5e5; +} + +.wp-switch-editor:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); + outline: none; + color: #23282d; +} + +.wp-switch-editor:active, +.html-active .switch-html:focus, +.tmce-active .switch-tmce:focus { + box-shadow: none; +} + +.wp-switch-editor:active { + background-color: #f5f5f5; + box-shadow: none; +} + +.js .tmce-active .wp-editor-area { + color: #fff; +} + +.tmce-active .quicktags-toolbar { + display: none; +} + +.tmce-active .switch-tmce, +.html-active .switch-html { + background: #f5f5f5; + color: #555; + border-bottom-color: #f5f5f5; +} + +.wp-media-buttons { + float: left; +} + +.wp-media-buttons .button { + margin-right: 5px; + margin-bottom: 4px; + padding-left: 7px; + padding-right: 7px; +} + +.wp-media-buttons .button:active { + position: relative; + top: 1px; + margin-top: -1px; + margin-bottom: 1px; +} + +.wp-media-buttons .insert-media { + padding-left: 5px; +} + +.wp-media-buttons a { + text-decoration: none; + color: #444; + font-size: 12px; +} + +.wp-media-buttons img { + padding: 0 4px; + vertical-align: middle; +} + +.wp-media-buttons span.wp-media-buttons-icon { + display: inline-block; + width: 18px; + height: 18px; + vertical-align: text-top; + margin: 0 2px; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon { + background: none; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon:before { + font: normal 18px/1 dashicons; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-media-buttons .add_media span.wp-media-buttons-icon:before { + content: "\f104"; +} + +/* Quicktags */ +.quicktags-toolbar { + padding: 3px; + position: relative; + border-bottom: 1px solid #ddd; + background: #f5f5f5; + min-height: 30px; +} + +.has-dfw .quicktags-toolbar { + padding-right: 35px; +} + +.wp-core-ui .quicktags-toolbar input.button.button-small { + margin: 2px; +} + +.quicktags-toolbar input[value="link"] { + text-decoration: underline; +} + +.quicktags-toolbar input[value="del"] { + text-decoration: line-through; +} + +.quicktags-toolbar input[value="i"] { + font-style: italic; +} + +.quicktags-toolbar input[value="b"] { + font-weight: 600; +} + +.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw, +.qt-dfw { + position: absolute; + top: 0; + right: 0; + margin: 5px 5px 0 0; +} + +.qt-fullscreen { + position: static; + margin: 2px; +} + +@media screen and ( max-width: 782px ) { + .mce-toolbar .mce-btn button, + .qt-dfw { + padding: 6px 7px; + } + + /* Compensate for the extra box shadow at the bottom of .mce-btn.mce-primary */ + .mce-toolbar .mce-btn-group .mce-btn.mce-primary button { + padding: 6px 7px 5px; + } + + .mce-toolbar .mce-btn-group .mce-btn { + margin: 1px; + } + + .qt-dfw { + width: 36px; + height: 34px; + } + + .mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw { + margin: 4px 4px 0 0; + } + + .mce-toolbar .mce-colorbutton .mce-preview { + left: 8px; + bottom: 6px; + } + + .mce-window .mce-btn { + padding: 2px 0; + } + + .has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first, + .has-dfw .quicktags-toolbar { + padding-right: 40px; + } +} + +@media screen and ( min-width: 782px ) { + .wp-core-ui .quicktags-toolbar input.button.button-small { + /* .button-small is normally 11px, but a bit too small for these buttons. */ + font-size: 12px; + height: 26px; + line-height: 24px; + } +} + +#wp_editbtns, +#wp_gallerybtns { + padding: 2px; + position: absolute; + display: none; + z-index: 100020; +} + +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { + border-color: #999; + background-color: #eee; + margin: 2px; + padding: 2px; + border-width: 1px; + border-style: solid; + border-radius: 3px; +} + +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { + border-color: #555; + background-color: #ccc; +} + +/*------------------------------------------------------------------------------ + wp-link +------------------------------------------------------------------------------*/ + +#wp-link-wrap { + display: none; + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); + width: 500px; + overflow: hidden; + margin-left: -250px; + margin-top: -125px; + position: fixed; + top: 50%; + left: 50%; + z-index: 100105; + transition: height 0.2s, margin-top 0.2s; +} + +#wp-link-backdrop { + display: none; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100100; +} + +#wp-link { + position: relative; + height: 100%; +} + +#wp-link-wrap { + height: 500px; + margin-top: -250px; +} + +#wp-link-wrap .wp-link-text-field { + display: none; +} + +#wp-link-wrap.has-text-field .wp-link-text-field { + display: block; +} + +#link-modal-title { + background: #fcfcfc; + border-bottom: 1px solid #ddd; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + margin: 0; + padding: 0 36px 0 16px; +} + +#wp-link-close { + color: #666; + padding: 0; + position: absolute; + top: 0; + right: 0; + width: 36px; + height: 36px; + text-align: center; + background: none; + border: none; + cursor: pointer; +} + +#wp-link-close:before { + font: normal 20px/36px dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + width: 36px; + height: 36px; + content: "\f158"; +} + +#wp-link-close:hover, +#wp-link-close:focus { + color: #00a0d2; +} + +#wp-link-close:focus { + outline: none; + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); +} + +#wp-link-wrap #link-selector { + -webkit-overflow-scrolling: touch; + padding: 0 16px; + position: absolute; + top: 37px; + left: 0; + right: 0; + bottom: 44px; +} + +#wp-link ol, +#wp-link ul { + list-style: none; + margin: 0; + padding: 0; +} + +#wp-link input[type="text"] { + box-sizing: border-box; +} + +#wp-link #link-options { + padding: 8px 0 12px; +} + +#wp-link p.howto { + margin: 3px 0; +} + +#wp-link p.howto a { + text-decoration: none; + color: inherit; +} + +#wp-link label input[type="text"] { + margin-top: 5px; + width: 70%; +} + +#wp-link #link-options label span, +#wp-link #search-panel label span.search-label { + display: inline-block; + width: 80px; + text-align: right; + padding-right: 5px; + max-width: 24%; + vertical-align: middle; + word-wrap: break-word; +} + +#wp-link .link-search-field { + float: left; + width: 250px; + max-width: 70%; +} + +#wp-link .link-search-wrapper { + margin: 5px 0 9px; + display: block; + overflow: hidden; +} + +#wp-link .link-search-wrapper span { + float: left; + margin-top: 4px; +} + +#wp-link .link-search-wrapper .spinner { + margin-top: 5px; +} + +#wp-link .link-target { + padding: 3px 0 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +#wp-link .link-target label { + max-width: 70%; +} + +#wp-link .query-results { + border: 1px #dfdfdf solid; + margin: 0 0 12px; + background: #fff; + overflow: auto; + position: absolute; + left: 16px; + right: 16px; + bottom: 0; + top: 166px; +} + +.has-text-field #wp-link .query-results { + top: 200px; +} + +#wp-link li { + clear: both; + margin-bottom: 0; + border-bottom: 1px solid #f1f1f1; + color: #32373c; + padding: 4px 6px 4px 10px; + cursor: pointer; + position: relative; +} + +#wp-link .query-notice { + padding: 0; + border-bottom: 1px solid #dfdfdf; + background-color: #f7fcfe; + color: #000; +} + +#wp-link .query-notice .query-notice-default, +#wp-link .query-notice .query-notice-hint { + display: block; + padding: 6px; + border-left: 4px solid #00a0d2; +} + +#wp-link .unselectable.no-matches-found { + padding: 0; + border-bottom: 1px solid #dfdfdf; + background-color: #fef7f1; +} + +#wp-link .no-matches-found .item-title { + display: block; + padding: 6px; + border-left: 4px solid #d54e21; +} + +#wp-link .query-results em { + font-style: normal; +} + +#wp-link li:hover { + background: #eaf2fa; + color: #151515; +} + +#wp-link li.unselectable { + border-bottom: 1px solid #dfdfdf; +} + +#wp-link li.unselectable:hover { + background: #fff; + cursor: auto; + color: #32373c; +} + +#wp-link li.selected { + background: #ddd; + color: #32373c; +} + +#wp-link li.selected .item-title { + font-weight: 600; +} + +#wp-link li:last-child { + border: none; +} + +#wp-link .item-title { + display: inline-block; + width: 80%; + width: calc(100% - 68px); + word-wrap: break-word; +} + +#wp-link .item-info { + text-transform: uppercase; + color: #666; + font-size: 11px; + position: absolute; + right: 5px; + top: 5px; +} + +#wp-link .river-waiting { + display: none; + padding: 10px 0; +} + +#wp-link .submitbox { + padding: 8px 16px; + background: #fcfcfc; + border-top: 1px solid #ddd; + position: absolute; + bottom: 0; + left: 0; + right: 0; +} + +#wp-link-cancel { + line-height: 25px; + float: left; +} + +#wp-link-update { + line-height: 23px; + float: right; +} + +#wp-link-submit { + float: right; +} + +@media screen and ( max-width: 782px ) { + #wp-link-wrap { + margin-top: -140px; + } + + #wp-link-wrap .query-results { + top: 195px; + } + + #wp-link-wrap.has-text-field .query-results { + top: 235px; + } + + #link-selector { + padding: 0 16px 60px; + } + + #wp-link-wrap #link-selector { + bottom: 52px; + } + + #wp-link-cancel { + line-height: 32px; + } + + #wp-link .link-target { + padding-top: 10px; + } + + #wp-link .submitbox .button { + margin-bottom: 0; + } +} + +@media screen and ( max-width: 520px ) { + #wp-link-wrap { + width: auto; + margin-left: 0; + left: 10px; + right: 10px; + max-width: 500px; + } +} + +@media screen and ( max-height: 520px ) { + #wp-link-wrap { + transition: none; + height: auto; + margin-top: 0; + top: 10px; + bottom: 10px; + } + + #link-selector { + overflow: auto; + } + + #search-panel .query-results { + position: static; + } +} + +@media screen and ( max-height: 290px ) { + #wp-link-wrap { + height: auto; + margin-top: 0; + top: 10px; + bottom: 10px; + } + + #link-selector { + overflow: auto; + height: calc(100% - 92px); + padding-bottom: 2px; + } + + #search-panel .query-results { + position: static; + } +} + +div.wp-link-preview { + float: left; + margin: 5px; + max-width: 694px; + overflow: hidden; + text-overflow: ellipsis; +} + +div.wp-link-preview a { + color: #0073aa; + text-decoration: underline; + transition-property: border, background, color; + transition-duration: .05s; + transition-timing-function: ease-in-out; + cursor: pointer; +} + +div.wp-link-preview a.wplink-url-error { + color: #dc3232; +} + +div.wp-link-input { + float: left; + margin: 2px; + max-width: 694px; +} + +div.wp-link-input input { + width: 300px; + padding: 3px; + box-sizing: border-box; +} + +.mce-toolbar div.wp-link-preview ~ .mce-btn, +.mce-toolbar div.wp-link-input ~ .mce-btn { + margin: 2px 1px; +} + +.mce-inline-toolbar-grp .mce-btn-group .mce-btn:last-child { + margin-right: 2px; +} + +.ui-autocomplete.wplink-autocomplete { + z-index: 100110; + max-height: 200px; + overflow-y: auto; + padding: 0; + margin: 0; + list-style: none; + position: absolute; + border: 1px solid #5b9dd9; + box-shadow: 0 1px 2px rgba( 30, 140, 190, 0.8 ); + background-color: #fff; +} + +.ui-autocomplete.wplink-autocomplete li { + margin-bottom: 0; + padding: 4px 10px; + clear: both; + white-space: normal; + text-align: left; +} + +.ui-autocomplete.wplink-autocomplete li .wp-editor-float-right { + float: right; +} + +.ui-autocomplete.wplink-autocomplete li.ui-state-focus { + background-color: #ddd; + cursor: pointer; +} + +@media screen and ( max-width: 782px ) { + div.wp-link-preview, + div.wp-link-input { + max-width: 70%; + max-width: calc(100% - 86px); + } + + div.wp-link-preview { + margin: 8px 0 8px 5px; + } + + div.wp-link-input { + width: 300px; + } + + div.wp-link-input input { + width: 100%; + font-size: 16px; + padding: 5px; + } +} + +/* =Overlay Body +-------------------------------------------------------------- */ + +.mce-fullscreen { + z-index: 100010; +} + +/* =Localization +-------------------------------------------------------------- */ +.rtl .wp-switch-editor, +.rtl .quicktags-toolbar input { + font-family: Tahoma, sans-serif; +} + +/* rtl:ignore */ +.mce-rtl .mce-flow-layout .mce-flow-layout-item > div { + direction: rtl; +} + +/* rtl:ignore */ +.mce-rtl .mce-listbox i.mce-caret { + left: 6px; +} + +html:lang(he-il) .rtl .wp-switch-editor, +html:lang(he-il) .rtl .quicktags-toolbar input { + font-family: Arial, sans-serif; +} + +/* HiDPI */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + .wp-media-buttons .add_media span.wp-media-buttons-icon { + background: none; + } +} diff --git a/backend/wp-includes/css/editor.min.css b/backend/wp-includes/css/editor.min.css new file mode 100644 index 0000000..ffcfce2 --- /dev/null +++ b/backend/wp-includes/css/editor.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.mce-window .mce-wp-help *,.wp-editor-area{box-sizing:border-box}.mce-tinymce{box-shadow:none}#wp-link-wrap,.mce-window{box-shadow:0 3px 6px rgba(0,0,0,.3)}.mce-container,.mce-container *,.mce-widget,.mce-widget *{color:inherit;font-family:inherit}.mce-container .mce-monospace,.mce-widget .mce-monospace{font-family:Consolas,Monaco,monospace;font-size:13px;line-height:150%}#mce-modal-block,#mce-modal-block.mce-fade{opacity:.7;filter:alpha(opacity=70);transition:none;background:#000}.mce-window{border-radius:0;-webkit-font-smoothing:subpixel-antialiased;transition:none}.mce-window .mce-container-body.mce-abs-layout{overflow:visible}.mce-window .mce-window-head{background:#fcfcfc;border-bottom:1px solid #ddd;padding:0;min-height:36px}.mce-window .mce-window-head .mce-title{color:#444;font-size:18px;font-weight:600;line-height:36px;margin:0;padding:0 36px 0 16px}.mce-window .mce-window-head .mce-close,.mce-window-head .mce-close .mce-i-remove{color:transparent;top:0;right:0;width:36px;height:36px;padding:0;line-height:36px;text-align:center}.mce-window-head .mce-close .mce-i-remove:before{font:400 20px/36px dashicons;text-align:center;color:#666;width:36px;height:36px;display:block}.mce-window-head .mce-close:focus .mce-i-remove:before,.mce-window-head .mce-close:hover .mce-i-remove:before{color:#00a0d2}.mce-window-head .mce-close:focus .mce-i-remove,div.mce-tab:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.mce-window .mce-window-head .mce-dragh{width:calc(100% - 36px)}.mce-window .mce-foot{border-top:1px solid #ddd}#wp-link .query-results,.mce-checkbox i.mce-i-checkbox,.mce-textbox{border:1px solid #ddd;border-radius:0;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);transition:.05s all ease-in-out}#wp-link .query-results:focus,.mce-checkbox:focus i.mce-i-checkbox,.mce-textbox.mce-focus,.mce-textbox:focus{border-color:#5b9dd9;box-shadow:0 0 2px rgba(30,140,190,.8)}.mce-window .mce-wp-help{height:360px;width:460px;overflow:auto}.mce-window .mce-wp-help>.mce-container-body{width:auto!important}.mce-window .wp-editor-help{padding:10px 10px 0 20px}.mce-window .wp-editor-help h2,.mce-window .wp-editor-help p{margin:8px 0;white-space:normal;font-size:14px;font-weight:400}.mce-window .wp-editor-help table{width:100%;margin-bottom:20px}.mce-window .wp-editor-help table.wp-help-single{margin:0 8px 20px}.mce-window .wp-editor-help table.fixed{table-layout:fixed}.mce-window .wp-editor-help table.fixed td:nth-child(odd),.mce-window .wp-editor-help table.fixed th:nth-child(odd){width:12%}.mce-window .wp-editor-help table.fixed td:nth-child(even),.mce-window .wp-editor-help table.fixed th:nth-child(even){width:38%}.mce-window .wp-editor-help table.fixed th:nth-child(odd){padding:5px 0 0}.mce-window .wp-editor-help td,.mce-window .wp-editor-help th{font-size:13px;padding:5px;vertical-align:middle;word-wrap:break-word;white-space:normal}.mce-window .wp-editor-help th{font-weight:600;padding-bottom:0}.mce-window .wp-editor-help kbd{font-family:monospace;padding:2px 7px 3px;font-weight:600;margin:0;background:#eaeaea;background:rgba(0,0,0,.08)}.mce-window .wp-help-th-center td:nth-child(odd),.mce-window .wp-help-th-center th:nth-child(odd){text-align:center}.mce-floatpanel.mce-popover,.mce-menu{border-color:rgba(0,0,0,.15);border-radius:0;box-shadow:0 3px 5px rgba(0,0,0,.2)}.mce-floatpanel.mce-popover.mce-bottom,.mce-menu{margin-top:2px}.mce-floatpanel .mce-arrow{display:none}.mce-menu .mce-container-body{min-width:160px}.mce-menu-item{border:none;margin-bottom:2px;padding:6px 15px 6px 12px}.mce-menu-has-icons i.mce-ico{line-height:20px}div.mce-panel{border:0;background:#fff}.mce-panel.mce-menu{border:1px solid #ddd}div.mce-tab{line-height:13px}div.mce-toolbar-grp{border-bottom:1px solid #ddd;background:#f5f5f5;padding:0;position:relative}div.mce-inline-toolbar-grp{border:1px solid #a0a5aa;border-radius:2px;box-shadow:0 1px 3px rgba(0,0,0,.15);box-sizing:border-box;margin-bottom:8px;position:absolute;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;max-width:98%;z-index:100100}div.mce-inline-toolbar-grp>div.mce-stack-layout{padding:1px}div.mce-inline-toolbar-grp.mce-arrow-up{margin-bottom:0;margin-top:8px}div.mce-inline-toolbar-grp:after,div.mce-inline-toolbar-grp:before{position:absolute;left:50%;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.mce-menu.mce-menu-align .mce-menu-item-normal,.quicktags-toolbar,.wp-editor-tools,.wp-editor-wrap,.wp-switch-editor{position:relative}div.mce-inline-toolbar-grp.mce-arrow-up:before{top:-9px;border-bottom-color:#a0a5aa;border-width:0 9px 9px;margin-left:-9px}div.mce-inline-toolbar-grp.mce-arrow-down:before{bottom:-9px;border-top-color:#a0a5aa;border-width:9px 9px 0;margin-left:-9px}div.mce-inline-toolbar-grp.mce-arrow-up:after{top:-8px;border-bottom-color:#f5f5f5;border-width:0 8px 8px;margin-left:-8px}div.mce-inline-toolbar-grp.mce-arrow-down:after{bottom:-8px;border-top-color:#f5f5f5;border-width:8px 8px 0;margin-left:-8px}div.mce-inline-toolbar-grp.mce-arrow-left:after,div.mce-inline-toolbar-grp.mce-arrow-left:before{margin:0}div.mce-inline-toolbar-grp.mce-arrow-left:before{left:20px}div.mce-inline-toolbar-grp.mce-arrow-left:after{left:21px}div.mce-inline-toolbar-grp.mce-arrow-right:after,div.mce-inline-toolbar-grp.mce-arrow-right:before{left:auto;margin:0}div.mce-inline-toolbar-grp.mce-arrow-right:before{right:20px}div.mce-inline-toolbar-grp.mce-arrow-right:after{right:21px}div.mce-inline-toolbar-grp.mce-arrow-full{right:0}div.mce-inline-toolbar-grp.mce-arrow-full>div{width:100%;overflow-x:auto}div.mce-toolbar-grp>div{padding:3px}.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first{padding-right:32px}.mce-toolbar .mce-btn-group{margin:0}div.mce-statusbar{border-top:1px solid #e5e5e5}div.mce-path{padding:2px 10px;margin:0}.mce-path,.mce-path .mce-divider,.mce-path-item{font-size:12px}.mce-toolbar .mce-btn,.qt-dfw{border-color:transparent;background:0 0;box-shadow:none;text-shadow:none;cursor:pointer}.mce-btn .mce-txt{direction:inherit;text-align:inherit}.mce-toolbar .mce-btn-group .mce-btn,.qt-dfw{border:1px solid transparent;margin:2px;border-radius:2px}.mce-toolbar .mce-btn-group .mce-btn:focus,.mce-toolbar .mce-btn-group .mce-btn:hover,.qt-dfw:focus,.qt-dfw:hover{background:#fafafa;border-color:#555d66;color:#23282d;box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,.08);outline:0}.mce-toolbar .mce-btn-group .mce-btn.mce-active,.mce-toolbar .mce-btn-group .mce-btn:active,.qt-dfw.active{background:#ebebeb;border-color:#555d66;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.3)}.mce-btn.mce-active,.mce-btn.mce-active button,.mce-btn.mce-active i,.mce-btn.mce-active:hover button,.mce-btn.mce-active:hover i{color:inherit}.mce-toolbar .mce-btn-group .mce-btn.mce-active:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-active:hover{border-color:#23282d}.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:hover{color:#a0a5aa;background:0 0;border-color:#ddd;text-shadow:0 1px 0 #fff;box-shadow:none}.mce-toolbar .mce-btn-group .mce-btn.mce-disabled:focus{border-color:#555d66}.mce-toolbar .mce-btn-group .mce-first,.mce-toolbar .mce-btn-group .mce-last{border-color:transparent}.mce-toolbar .mce-btn button,.qt-dfw{padding:2px 3px;line-height:normal}.mce-toolbar .mce-listbox button{font-size:13px;line-height:20px;padding-left:6px;padding-right:20px}.mce-toolbar .mce-btn i{text-shadow:none}.mce-toolbar .mce-btn-group>div{white-space:normal}.mce-toolbar .mce-colorbutton .mce-open{border-right:0}.mce-toolbar .mce-colorbutton .mce-preview{margin:0;padding:0;top:auto;bottom:2px;left:3px;height:3px;width:20px;background:#555d66}.mce-toolbar .mce-btn-group .mce-btn.mce-primary{min-width:0;background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:none}.mce-toolbar .mce-btn-group .mce-btn.mce-primary button{padding:2px 3px 1px}.mce-toolbar .mce-btn-group .mce-btn.mce-primary .mce-ico{color:#fff}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:focus{box-shadow:0 0 1px 1px #33b3db}.mce-toolbar .mce-btn-group .mce-btn.mce-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799}.mce-toolbar .mce-btn-group .mce-btn.mce-listbox{border-radius:0;direction:ltr;background:#fff;border:1px solid #ddd;box-shadow:inset 0 1px 1px -1px rgba(0,0,0,.2)}.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:focus,.mce-toolbar .mce-btn-group .mce-btn.mce-listbox:hover{border-color:#b4b9be}.mce-panel .mce-btn i.mce-caret{border-top:6px solid #555d66;margin-left:2px;margin-right:2px}.mce-listbox i.mce-caret{right:4px}.mce-panel .mce-btn:focus i.mce-caret,.mce-panel .mce-btn:hover i.mce-caret{border-top-color:#23282d}.mce-panel .mce-active i.mce-caret{border-top:0;border-bottom:6px solid #23282d;margin-top:7px}.mce-listbox.mce-active i.mce-caret{margin-top:-3px}.mce-toolbar .mce-splitbtn:hover .mce-open{border-right-color:transparent}.mce-toolbar .mce-splitbtn .mce-open.mce-active{background:0 0;outline:0}.mce-menu .mce-menu-item-normal.mce-active,.mce-menu .mce-menu-item-preview.mce-active,.mce-menu .mce-menu-item.mce-selected,.mce-menu .mce-menu-item:focus,.mce-menu .mce-menu-item:hover{background:#0073aa;color:#fff}.mce-menu-item.mce-active .mce-menu-shortcut,.mce-menu-item.mce-disabled:hover .mce-ico,.mce-menu-item.mce-disabled:hover .mce-text,.mce-menu-item:focus .mce-ico,.mce-menu-item:focus .mce-menu-shortcut,.mce-menu-item:focus .mce-text,.mce-menu-item:hover .mce-ico,.mce-menu-item:hover .mce-menu-shortcut,.mce-menu-item:hover .mce-text{color:inherit}.mce-menu .mce-menu-item.mce-disabled{cursor:default}.mce-menu .mce-menu-item.mce-disabled:hover{background:#ccc}div.mce-menubar{border-color:#e5e5e5;background:#fff;border-width:0 0 1px}.mce-menubar .mce-menubtn.mce-active,.mce-menubar .mce-menubtn:focus,.mce-menubar .mce-menubtn:hover{border-color:transparent;background:0 0}.mce-menubar .mce-menubtn:focus{color:#124964;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}.mce-menu-item-sep:hover,div.mce-menu .mce-menu-item-sep{border-bottom:1px solid #ddd;height:0;margin:5px 0}.mce-menubtn span{margin-right:0;padding-left:3px}.mce-menu-has-icons i.mce-ico:before{margin-left:-2px}.mce-menu.mce-menu-align .mce-menu-shortcut{bottom:.6em;font-size:.9em}.mce-primary button,.mce-primary button i{text-align:center;color:#fff;text-shadow:none;padding:0;line-height:26px}.mce-window .mce-btn{color:#555;background:#f7f7f7;text-decoration:none;font-size:13px;line-height:26px;height:28px;margin:0;padding:0;cursor:pointer;border:1px solid #ccc;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-shadow:0 1px 0 #ccc}.mce-window .mce-btn::-moz-focus-inner{border-width:0;border-style:none;padding:0}.mce-window .mce-btn:focus,.mce-window .mce-btn:hover{background:#fafafa;border-color:#999;color:#23282d}.mce-window .mce-btn:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.mce-window .mce-btn:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.mce-window .mce-btn.mce-disabled{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}.mce-window .mce-btn.mce-primary{background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799}.mce-window .mce-btn.mce-primary:focus,.mce-window .mce-btn.mce-primary:hover{background:#008ec2;border-color:#006799;color:#fff}.mce-window .mce-btn.mce-primary:focus{box-shadow:0 1px 0 #0073aa,0 0 2px 1px #33b3db}.mce-window .mce-btn.mce-primary:active{background:#0073aa;border-color:#006799;box-shadow:inset 0 2px 0 #006799;vertical-align:top}.mce-window .mce-btn.mce-primary.mce-disabled{color:#66c6e4!important;background:#008ec2!important;border-color:#007cb2!important;box-shadow:none!important;text-shadow:0 -1px 0 rgba(0,0,0,.1)!important;cursor:default}.mce-toolbar .mce-ico,.qt-dfw{text-shadow:none;text-align:center}.mce-menubtn.mce-fixed-width span{overflow-x:hidden;text-overflow:ellipsis;width:82px}.mce-charmap{margin:3px}.mce-charmap td{padding:0;border-color:#ddd;cursor:pointer}.mce-charmap td:hover{background:#f3f3f3}.mce-charmap td div{width:18px;height:22px;line-height:22px}.mce-toolbar .mce-btn .mce-open,.qt-dfw{line-height:20px}.mce-tooltip{margin-top:2px}.rtl .mce-tooltip.wp-hide-mce-tooltip{display:none!important}.mce-tooltip-inner{border-radius:3px;box-shadow:0 3px 5px rgba(0,0,0,.2);color:#fff;font-size:12px}.mce-ico{font-family:tinymce,Arial}.mce-btn-small .mce-ico{font-family:tinymce-small,Arial}.mce-toolbar .mce-ico{color:#555d66;line-height:20px;width:20px;height:20px;margin:0;padding:0}.qt-dfw{color:#555d66;width:28px;height:26px}.mce-toolbar .mce-btn.mce-active .mce-open,.mce-toolbar .mce-btn:focus .mce-open,.mce-toolbar .mce-btn:hover .mce-open{border-left-color:#23282d}div.mce-notification{left:10%!important;right:10%}.mce-notification button.mce-close{right:6px;top:3px;font-weight:400;color:#555d66}.mce-notification button.mce-close:focus,.mce-notification button.mce-close:hover{color:#000}i.mce-i-aligncenter,i.mce-i-alignjustify,i.mce-i-alignleft,i.mce-i-alignright,i.mce-i-backcolor,i.mce-i-blockquote,i.mce-i-bold,i.mce-i-bullist,i.mce-i-charmap,i.mce-i-dashicon,i.mce-i-dfw,i.mce-i-forecolor,i.mce-i-fullscreen,i.mce-i-help,i.mce-i-hr,i.mce-i-indent,i.mce-i-italic,i.mce-i-link,i.mce-i-ltr,i.mce-i-numlist,i.mce-i-outdent,i.mce-i-pastetext,i.mce-i-pasteword,i.mce-i-redo,i.mce-i-remove,i.mce-i-removeformat,i.mce-i-spellchecker,i.mce-i-strikethrough,i.mce-i-underline,i.mce-i-undo,i.mce-i-unlink,i.mce-i-wp-media-library,i.mce-i-wp_adv,i.mce-i-wp_code,i.mce-i-wp_fullscreen,i.mce-i-wp_help,i.mce-i-wp_more,i.mce-i-wp_page{font:400 20px/1 dashicons;padding:0 2px 0 0;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin-left:-2px}.qt-dfw{font:400 20px/1 dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}i.mce-i-bold:before{content:"\f200"}i.mce-i-italic:before{content:"\f201"}i.mce-i-bullist:before{content:"\f203"}i.mce-i-numlist:before{content:"\f204"}i.mce-i-blockquote:before{content:"\f205"}i.mce-i-alignleft:before{content:"\f206"}i.mce-i-aligncenter:before{content:"\f207"}i.mce-i-alignright:before{content:"\f208"}i.mce-i-link:before{content:"\f103"}i.mce-i-unlink:before{content:"\f225"}i.mce-i-wp_more:before{content:"\f209"}i.mce-i-strikethrough:before{content:"\f224"}i.mce-i-spellchecker:before{content:"\f210"}.qt-dfw:before,i.mce-i-dfw:before,i.mce-i-fullscreen:before,i.mce-i-wp_fullscreen:before{content:"\f211"}i.mce-i-wp_adv:before{content:"\f212"}i.mce-i-underline:before{content:"\f213"}i.mce-i-alignjustify:before{content:"\f214"}i.mce-i-backcolor:before,i.mce-i-forecolor:before{content:"\f215"}i.mce-i-pastetext:before{content:"\f217"}i.mce-i-removeformat:before{content:"\f218"}i.mce-i-charmap:before{content:"\f220"}i.mce-i-outdent:before{content:"\f221"}i.mce-i-indent:before{content:"\f222"}i.mce-i-undo:before{content:"\f171"}i.mce-i-redo:before{content:"\f172"}i.mce-i-help:before,i.mce-i-wp_help:before{content:"\f223"}i.mce-i-wp-media-library:before{content:"\f104"}i.mce-i-ltr:before{content:"\f320"}i.mce-i-wp_page:before{content:"\f105"}i.mce-i-hr:before{content:"\f460"}i.mce-i-remove:before{content:"\f158"}i.mce-i-wp_code:before{content:"\f475"}.rtl i.mce-i-outdent:before{content:"\f222"}.rtl i.mce-i-indent:before{content:"\f221"}.wp-editor-tools{z-index:1}.wp-editor-tools:after{clear:both;content:"";display:table}.wp-editor-container{clear:both;border:1px solid #e5e5e5}.wp-editor-area{font-family:Consolas,Monaco,monospace;font-size:13px;padding:10px;margin:1px 0 0;line-height:150%;border:0;outline:0;display:block;resize:vertical}.rtl .wp-editor-area{font-family:Tahoma,Monaco,monospace}.locale-he-il .wp-editor-area{font-family:Arial,Monaco,monospace}.wp-editor-container textarea.wp-editor-area{width:100%;margin:0;box-shadow:none}.wp-editor-tabs{float:right}.wp-switch-editor{float:left;box-sizing:content-box;top:1px;background:#ebebeb;color:#666;cursor:pointer;font-size:13px;line-height:19px;height:20px;margin:5px 0 0 5px;padding:3px 8px 4px;border:1px solid #e5e5e5}.wp-switch-editor:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8);outline:0;color:#23282d}.html-active .switch-html:focus,.tmce-active .switch-tmce:focus,.wp-switch-editor:active{box-shadow:none}.wp-switch-editor:active{background-color:#f5f5f5;box-shadow:none}.js .tmce-active .wp-editor-area{color:#fff}.tmce-active .quicktags-toolbar{display:none}.html-active .switch-html,.tmce-active .switch-tmce{background:#f5f5f5;color:#555;border-bottom-color:#f5f5f5}.wp-media-buttons{float:left}.wp-media-buttons .button{margin-right:5px;margin-bottom:4px;padding-left:7px;padding-right:7px}.wp-media-buttons .button:active{position:relative;top:1px;margin-top:-1px;margin-bottom:1px}.wp-media-buttons .insert-media{padding-left:5px}.wp-media-buttons a{text-decoration:none;color:#444;font-size:12px}.wp-media-buttons img{padding:0 4px;vertical-align:middle}.wp-media-buttons span.wp-media-buttons-icon{display:inline-block;width:18px;height:18px;vertical-align:text-top;margin:0 2px}.wp-media-buttons .add_media span.wp-media-buttons-icon{background:0 0}.wp-media-buttons .add_media span.wp-media-buttons-icon:before{font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f104"}.quicktags-toolbar{padding:3px;border-bottom:1px solid #ddd;background:#f5f5f5;min-height:30px}.has-dfw .quicktags-toolbar{padding-right:35px}.wp-core-ui .quicktags-toolbar input.button.button-small{margin:2px}.quicktags-toolbar input[value=link]{text-decoration:underline}.quicktags-toolbar input[value=del]{text-decoration:line-through}.quicktags-toolbar input[value="i"]{font-style:italic}.quicktags-toolbar input[value="b"]{font-weight:600}.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw,.qt-dfw{position:absolute;top:0;right:0;margin:5px 5px 0 0}.qt-fullscreen{position:static;margin:2px}@media screen and (max-width:782px){.mce-toolbar .mce-btn button,.qt-dfw{padding:6px 7px}.mce-toolbar .mce-btn-group .mce-btn.mce-primary button{padding:6px 7px 5px}.mce-toolbar .mce-btn-group .mce-btn{margin:1px}.qt-dfw{width:36px;height:34px}.mce-toolbar .mce-btn-group .mce-btn.mce-wp-dfw{margin:4px 4px 0 0}.mce-toolbar .mce-colorbutton .mce-preview{left:8px;bottom:6px}.mce-window .mce-btn{padding:2px 0}.has-dfw .quicktags-toolbar,.has-dfw div.mce-toolbar-grp .mce-toolbar.mce-first{padding-right:40px}}@media screen and (min-width:782px){.wp-core-ui .quicktags-toolbar input.button.button-small{font-size:12px;height:26px;line-height:24px}}#wp_editbtns,#wp_gallerybtns{padding:2px;position:absolute;display:none;z-index:100020}#wp_delgallery,#wp_delimgbtn,#wp_editgallery,#wp_editimgbtn{border-color:#999;background-color:#eee;margin:2px;padding:2px;border-width:1px;border-style:solid;border-radius:3px}#wp_delgallery:hover,#wp_delimgbtn:hover,#wp_editgallery:hover,#wp_editimgbtn:hover{border-color:#555;background-color:#ccc}#wp-link-wrap{display:none;background-color:#fff;width:500px;overflow:hidden;margin-left:-250px;position:fixed;top:50%;left:50%;z-index:100105;transition:height .2s,margin-top .2s;height:500px;margin-top:-250px}#wp-link-backdrop{display:none;position:fixed;top:0;left:0;right:0;bottom:0;min-height:360px;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100100}#wp-link{position:relative;height:100%}#wp-link-wrap .wp-link-text-field{display:none}#wp-link-wrap.has-text-field .wp-link-text-field{display:block}#link-modal-title{background:#fcfcfc;border-bottom:1px solid #ddd;height:36px;font-size:18px;font-weight:600;line-height:36px;margin:0;padding:0 36px 0 16px}#wp-link-close{color:#666;padding:0;position:absolute;top:0;right:0;width:36px;height:36px;text-align:center;background:0 0;border:none;cursor:pointer}#wp-link-close:before{font:400 20px/36px dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;width:36px;height:36px;content:"\f158"}#wp-link-close:focus,#wp-link-close:hover{color:#00a0d2}#wp-link-close:focus{outline:0;box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8)}#wp-link-wrap #link-selector{-webkit-overflow-scrolling:touch;padding:0 16px;position:absolute;top:37px;left:0;right:0;bottom:44px}#wp-link ol,#wp-link ul{list-style:none;margin:0;padding:0}#wp-link input[type=text]{box-sizing:border-box}#wp-link #link-options{padding:8px 0 12px}#wp-link p.howto{margin:3px 0}#wp-link p.howto a{text-decoration:none;color:inherit}#wp-link label input[type=text]{margin-top:5px;width:70%}#wp-link #link-options label span,#wp-link #search-panel label span.search-label{display:inline-block;width:80px;text-align:right;padding-right:5px;max-width:24%;vertical-align:middle;word-wrap:break-word}#wp-link .link-search-field{float:left;width:250px;max-width:70%}#wp-link .link-search-wrapper{margin:5px 0 9px;display:block;overflow:hidden}#wp-link .link-search-wrapper span{float:left;margin-top:4px}#wp-link .link-search-wrapper .spinner{margin-top:5px}#wp-link .link-target{padding:3px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#wp-link .link-target label{max-width:70%}#wp-link .query-results{border:1px solid #dfdfdf;margin:0 0 12px;background:#fff;overflow:auto;position:absolute;left:16px;right:16px;bottom:0;top:166px}.has-text-field #wp-link .query-results{top:200px}#wp-link li{clear:both;margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#32373c;padding:4px 6px 4px 10px;cursor:pointer;position:relative}#wp-link .query-notice,#wp-link li.unselectable{border-bottom:1px solid #dfdfdf}#wp-link .query-notice{padding:0;background-color:#f7fcfe;color:#000}#wp-link .query-notice .query-notice-default,#wp-link .query-notice .query-notice-hint{display:block;padding:6px;border-left:4px solid #00a0d2}#wp-link .unselectable.no-matches-found{padding:0;border-bottom:1px solid #dfdfdf;background-color:#fef7f1}#wp-link .no-matches-found .item-title{display:block;padding:6px;border-left:4px solid #d54e21}#wp-link .query-results em{font-style:normal}#wp-link li:hover{background:#eaf2fa;color:#151515}#wp-link li.unselectable:hover{background:#fff;cursor:auto;color:#32373c}#wp-link li.selected{background:#ddd;color:#32373c}#wp-link li.selected .item-title{font-weight:600}#wp-link li:last-child{border:none}#wp-link .item-title{display:inline-block;width:80%;width:calc(100% - 68px);word-wrap:break-word}#wp-link .item-info{text-transform:uppercase;color:#666;font-size:11px;position:absolute;right:5px;top:5px}#wp-link .river-waiting{display:none;padding:10px 0}#wp-link .submitbox{padding:8px 16px;background:#fcfcfc;border-top:1px solid #ddd;position:absolute;bottom:0;left:0;right:0}#wp-link-cancel{line-height:25px;float:left}#wp-link-update{line-height:23px;float:right}#wp-link-submit{float:right}@media screen and (max-width:782px){#wp-link-wrap{margin-top:-140px}#wp-link-wrap .query-results{top:195px}#wp-link-wrap.has-text-field .query-results{top:235px}#link-selector{padding:0 16px 60px}#wp-link-wrap #link-selector{bottom:52px}#wp-link-cancel{line-height:32px}#wp-link .link-target{padding-top:10px}#wp-link .submitbox .button{margin-bottom:0}}@media screen and (max-width:520px){#wp-link-wrap{width:auto;margin-left:0;left:10px;right:10px;max-width:500px}}@media screen and (max-height:520px){#wp-link-wrap{transition:none;height:auto;margin-top:0;top:10px;bottom:10px}#link-selector{overflow:auto}#search-panel .query-results{position:static}}@media screen and (max-height:290px){#wp-link-wrap{height:auto;margin-top:0;top:10px;bottom:10px}#link-selector{overflow:auto;height:calc(100% - 92px);padding-bottom:2px}#search-panel .query-results{position:static}}div.wp-link-preview{float:left;margin:5px;max-width:694px;overflow:hidden;text-overflow:ellipsis}div.wp-link-preview a{color:#0073aa;text-decoration:underline;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out;cursor:pointer}div.wp-link-preview a.wplink-url-error{color:#dc3232}div.wp-link-input{float:left;margin:2px;max-width:694px}div.wp-link-input input{width:300px;padding:3px;box-sizing:border-box}.mce-toolbar div.wp-link-input~.mce-btn,.mce-toolbar div.wp-link-preview~.mce-btn{margin:2px 1px}.mce-inline-toolbar-grp .mce-btn-group .mce-btn:last-child{margin-right:2px}.ui-autocomplete.wplink-autocomplete{z-index:100110;max-height:200px;overflow-y:auto;padding:0;margin:0;list-style:none;position:absolute;border:1px solid #5b9dd9;box-shadow:0 1px 2px rgba(30,140,190,.8);background-color:#fff}.ui-autocomplete.wplink-autocomplete li{margin-bottom:0;padding:4px 10px;clear:both;white-space:normal;text-align:left}.ui-autocomplete.wplink-autocomplete li .wp-editor-float-right{float:right}.ui-autocomplete.wplink-autocomplete li.ui-state-focus{background-color:#ddd;cursor:pointer}@media screen and (max-width:782px){div.wp-link-input,div.wp-link-preview{max-width:70%;max-width:calc(100% - 86px)}div.wp-link-preview{margin:8px 0 8px 5px}div.wp-link-input{width:300px}div.wp-link-input input{width:100%;font-size:16px;padding:5px}}.mce-fullscreen{z-index:100010}.rtl .quicktags-toolbar input,.rtl .wp-switch-editor{font-family:Tahoma,sans-serif}.mce-rtl .mce-flow-layout .mce-flow-layout-item>div{direction:rtl}.mce-rtl .mce-listbox i.mce-caret{left:6px}html:lang(he-il) .rtl .quicktags-toolbar input,html:lang(he-il) .rtl .wp-switch-editor{font-family:Arial,sans-serif}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-media-buttons .add_media span.wp-media-buttons-icon{background:0 0}} \ No newline at end of file diff --git a/backend/wp-includes/css/jquery-ui-dialog-rtl.css b/backend/wp-includes/css/jquery-ui-dialog-rtl.css new file mode 100644 index 0000000..84d8bd6 --- /dev/null +++ b/backend/wp-includes/css/jquery-ui-dialog-rtl.css @@ -0,0 +1,351 @@ +/*! + * jQuery UI CSS Framework 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/theming/ + */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { + display: none; +} +.ui-helper-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} +.ui-helper-reset { + margin: 0; + padding: 0; + border: 0; + outline: 0; + line-height: 1.3; + text-decoration: none; + font-size: 100%; + list-style: none; +} +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} +.ui-helper-clearfix { + min-height: 0; /* support: IE7 */ +} +.ui-helper-zfix { + width: 100%; + height: 100%; + top: 0; + right: 0; + position: absolute; + opacity: 0; + filter:Alpha(Opacity=0); /* support: IE8 */ +} + +.ui-front { + z-index: 100; +} + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { + display: block; + text-indent: -99999px; + overflow: hidden; + background-repeat: no-repeat; +} + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { + position: fixed; + top: 0; + right: 0; + width: 100%; + height: 100%; +} + +/*! + * jQuery UI Resizable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-resizable { + position: relative; +} +.ui-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; + touch-action: none; +} +.ui-resizable-disabled .ui-resizable-handle, +.ui-resizable-autohide .ui-resizable-handle { + display: none; +} +.ui-resizable-n { + cursor: n-resize; + height: 7px; + width: 100%; + top: -5px; + right: 0; +} +.ui-resizable-s { + cursor: s-resize; + height: 7px; + width: 100%; + bottom: -5px; + right: 0; +} +/* rtl:ignore */ +.ui-resizable-e { + cursor: e-resize; + width: 7px; + right: -5px; + top: 0; + height: 100%; +} +/* rtl:ignore */ +.ui-resizable-w { + cursor: w-resize; + width: 7px; + left: -5px; + top: 0; + height: 100%; +} +/* rtl:ignore */ +.ui-resizable-se { + cursor: se-resize; + width: 12px; + height: 12px; + right: 1px; + bottom: 1px; +} +/* rtl:ignore */ +.ui-resizable-sw { + cursor: sw-resize; + width: 9px; + height: 9px; + left: -5px; + bottom: -5px; +} +/* rtl:ignore */ +.ui-resizable-nw { + cursor: nw-resize; + width: 9px; + height: 9px; + left: -5px; + top: -5px; +} +/* rtl:ignore */ +.ui-resizable-ne { + cursor: ne-resize; + width: 9px; + height: 9px; + right: -5px; + top: -5px; +} + +/* WP buttons: see buttons.css. */ + +.ui-button { + display: inline-block; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0 10px 1px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-sizing: border-box; + color: #555; + border-color: #cccccc; + background: #f7f7f7; + box-shadow: 0 1px 0 #cccccc; + vertical-align: top; +} + +.ui-button:active, +.ui-button:focus { + outline: none; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.ui-button::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.ui-button:hover, +.ui-button:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.ui-button:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.ui-button:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.ui-button[disabled], +.ui-button:disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +@media screen and ( max-width: 782px ) { + + .ui-button { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + margin-bottom: 4px; + } + +} + +/* WP Theme */ + +.ui-dialog { + position: absolute; + top: 0; + right: 0; + z-index: 100102; + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); +} + +.ui-dialog-titlebar { + background: #fcfcfc; + border-bottom: 1px solid #dfdfdf; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + padding: 0 16px 0 36px; +} + +.ui-button.ui-dialog-titlebar-close { + background: none; + border: none; + box-shadow: none; + color: #666; + cursor: pointer; + display: block; + padding: 0; + position: absolute; + top: 0; + left: 0; + width: 36px; + height: 36px; + text-align: center; +} + +.ui-dialog-titlebar-close:before { + font: normal 20px/1 dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 36px; + width: 36px; + height: 36px; + content: '\f158'; +} + +.ui-button.ui-dialog-titlebar-close:hover { + color: #00a0d2; +} + +.ui-dialog-titlebar-close .ui-button-text { + display: none; +} + +.ui-dialog-content { + padding: 16px; + overflow: auto; +} + +.ui-dialog-buttonpane { + background: #fcfcfc; + border-top: 1px solid #dfdfdf; + padding: 16px; +} + +.ui-dialog-buttonpane .ui-button { + margin-right: 16px; +} + +.ui-dialog-buttonpane .ui-dialog-buttonset { + float: left; +} + +.ui-draggable .ui-dialog-titlebar { + cursor: move; +} + +.ui-widget-overlay { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100101; +} diff --git a/backend/wp-includes/css/jquery-ui-dialog-rtl.min.css b/backend/wp-includes/css/jquery-ui-dialog-rtl.min.css new file mode 100644 index 0000000..c37c355 --- /dev/null +++ b/backend/wp-includes/css/jquery-ui-dialog-rtl.min.css @@ -0,0 +1,18 @@ +/*! This file is auto-generated */ +/*! + * jQuery UI CSS Framework 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/theming/ + */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-button,.ui-helper-reset{text-decoration:none;margin:0}.ui-helper-reset{padding:0;border:0;outline:0;line-height:1.3;font-size:100%;list-style:none}.ui-helper-clearfix:after,.ui-helper-clearfix:before{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;right:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{width:100%;height:100%}/*! + * jQuery UI Resizable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;display:block;touch-action:none}.ui-resizable-autohide .ui-resizable-handle,.ui-resizable-disabled .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;right:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;right:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-button{display:inline-block;font-size:13px;line-height:26px;height:28px;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-sizing:border-box;color:#555;border-color:#ccc;background:#f7f7f7;box-shadow:0 1px 0 #ccc;vertical-align:top}.ui-button:active,.ui-button:focus{outline:0}.ui-button::-moz-focus-inner{border-width:0;border-style:none;padding:0}.ui-button:focus,.ui-button:hover{background:#fafafa;border-color:#999;color:#23282d}.ui-button:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.ui-button:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.ui-button:disabled,.ui-button[disabled]{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}@media screen and (max-width:782px){.ui-button{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto;margin-bottom:4px}}.ui-dialog{position:absolute;top:0;right:0;z-index:100102;background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3)}.ui-dialog-titlebar{background:#fcfcfc;border-bottom:1px solid #dfdfdf;height:36px;font-size:18px;font-weight:600;line-height:36px;padding:0 16px 0 36px}.ui-button.ui-dialog-titlebar-close{background:0 0;border:none;box-shadow:none;color:#666;cursor:pointer;display:block;padding:0;position:absolute;top:0;left:0;width:36px;height:36px;text-align:center}.ui-dialog-titlebar-close:before{font:400 20px/1 dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:36px;width:36px;height:36px;content:'\f158'}.ui-button.ui-dialog-titlebar-close:hover{color:#00a0d2}.ui-dialog-titlebar-close .ui-button-text{display:none}.ui-dialog-content{padding:16px;overflow:auto}.ui-dialog-buttonpane{background:#fcfcfc;border-top:1px solid #dfdfdf;padding:16px}.ui-dialog-buttonpane .ui-button{margin-right:16px}.ui-dialog-buttonpane .ui-dialog-buttonset{float:left}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-widget-overlay{position:fixed;top:0;right:0;left:0;bottom:0;min-height:360px;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100101} \ No newline at end of file diff --git a/backend/wp-includes/css/jquery-ui-dialog.css b/backend/wp-includes/css/jquery-ui-dialog.css new file mode 100644 index 0000000..0249f51 --- /dev/null +++ b/backend/wp-includes/css/jquery-ui-dialog.css @@ -0,0 +1,351 @@ +/*! + * jQuery UI CSS Framework 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/theming/ + */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { + display: none; +} +.ui-helper-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} +.ui-helper-reset { + margin: 0; + padding: 0; + border: 0; + outline: 0; + line-height: 1.3; + text-decoration: none; + font-size: 100%; + list-style: none; +} +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} +.ui-helper-clearfix { + min-height: 0; /* support: IE7 */ +} +.ui-helper-zfix { + width: 100%; + height: 100%; + top: 0; + left: 0; + position: absolute; + opacity: 0; + filter:Alpha(Opacity=0); /* support: IE8 */ +} + +.ui-front { + z-index: 100; +} + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { + display: block; + text-indent: -99999px; + overflow: hidden; + background-repeat: no-repeat; +} + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +/*! + * jQuery UI Resizable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-resizable { + position: relative; +} +.ui-resizable-handle { + position: absolute; + font-size: 0.1px; + display: block; + touch-action: none; +} +.ui-resizable-disabled .ui-resizable-handle, +.ui-resizable-autohide .ui-resizable-handle { + display: none; +} +.ui-resizable-n { + cursor: n-resize; + height: 7px; + width: 100%; + top: -5px; + left: 0; +} +.ui-resizable-s { + cursor: s-resize; + height: 7px; + width: 100%; + bottom: -5px; + left: 0; +} +/* rtl:ignore */ +.ui-resizable-e { + cursor: e-resize; + width: 7px; + right: -5px; + top: 0; + height: 100%; +} +/* rtl:ignore */ +.ui-resizable-w { + cursor: w-resize; + width: 7px; + left: -5px; + top: 0; + height: 100%; +} +/* rtl:ignore */ +.ui-resizable-se { + cursor: se-resize; + width: 12px; + height: 12px; + right: 1px; + bottom: 1px; +} +/* rtl:ignore */ +.ui-resizable-sw { + cursor: sw-resize; + width: 9px; + height: 9px; + left: -5px; + bottom: -5px; +} +/* rtl:ignore */ +.ui-resizable-nw { + cursor: nw-resize; + width: 9px; + height: 9px; + left: -5px; + top: -5px; +} +/* rtl:ignore */ +.ui-resizable-ne { + cursor: ne-resize; + width: 9px; + height: 9px; + right: -5px; + top: -5px; +} + +/* WP buttons: see buttons.css. */ + +.ui-button { + display: inline-block; + text-decoration: none; + font-size: 13px; + line-height: 26px; + height: 28px; + margin: 0; + padding: 0 10px 1px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -webkit-appearance: none; + border-radius: 3px; + white-space: nowrap; + box-sizing: border-box; + color: #555; + border-color: #cccccc; + background: #f7f7f7; + box-shadow: 0 1px 0 #cccccc; + vertical-align: top; +} + +.ui-button:active, +.ui-button:focus { + outline: none; +} + +/* Remove the dotted border on :focus and the extra padding in Firefox */ +.ui-button::-moz-focus-inner { + border-width: 0; + border-style: none; + padding: 0; +} + +.ui-button:hover, +.ui-button:focus { + background: #fafafa; + border-color: #999; + color: #23282d; +} + +.ui-button:focus { + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.ui-button:active { + background: #eee; + border-color: #999; + box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); + -webkit-transform: translateY(1px); + transform: translateY(1px); +} + +.ui-button[disabled], +.ui-button:disabled { + color: #a0a5aa !important; + border-color: #ddd !important; + background: #f7f7f7 !important; + box-shadow: none !important; + text-shadow: 0 1px 0 #fff !important; + cursor: default; + -webkit-transform: none !important; + transform: none !important; +} + +@media screen and ( max-width: 782px ) { + + .ui-button { + padding: 6px 14px; + line-height: normal; + font-size: 14px; + vertical-align: middle; + height: auto; + margin-bottom: 4px; + } + +} + +/* WP Theme */ + +.ui-dialog { + position: absolute; + top: 0; + left: 0; + z-index: 100102; + background-color: #fff; + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); +} + +.ui-dialog-titlebar { + background: #fcfcfc; + border-bottom: 1px solid #dfdfdf; + height: 36px; + font-size: 18px; + font-weight: 600; + line-height: 36px; + padding: 0 36px 0 16px; +} + +.ui-button.ui-dialog-titlebar-close { + background: none; + border: none; + box-shadow: none; + color: #666; + cursor: pointer; + display: block; + padding: 0; + position: absolute; + top: 0; + right: 0; + width: 36px; + height: 36px; + text-align: center; +} + +.ui-dialog-titlebar-close:before { + font: normal 20px/1 dashicons; + vertical-align: top; + speak: none; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + line-height: 36px; + width: 36px; + height: 36px; + content: '\f158'; +} + +.ui-button.ui-dialog-titlebar-close:hover { + color: #00a0d2; +} + +.ui-dialog-titlebar-close .ui-button-text { + display: none; +} + +.ui-dialog-content { + padding: 16px; + overflow: auto; +} + +.ui-dialog-buttonpane { + background: #fcfcfc; + border-top: 1px solid #dfdfdf; + padding: 16px; +} + +.ui-dialog-buttonpane .ui-button { + margin-left: 16px; +} + +.ui-dialog-buttonpane .ui-dialog-buttonset { + float: right; +} + +.ui-draggable .ui-dialog-titlebar { + cursor: move; +} + +.ui-widget-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 100101; +} diff --git a/backend/wp-includes/css/jquery-ui-dialog.min.css b/backend/wp-includes/css/jquery-ui-dialog.min.css new file mode 100644 index 0000000..6f1472f --- /dev/null +++ b/backend/wp-includes/css/jquery-ui-dialog.min.css @@ -0,0 +1,18 @@ +/*! This file is auto-generated */ +/*! + * jQuery UI CSS Framework 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/theming/ + */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-button,.ui-helper-reset{text-decoration:none;margin:0}.ui-helper-reset{padding:0;border:0;outline:0;line-height:1.3;font-size:100%;list-style:none}.ui-helper-clearfix:after,.ui-helper-clearfix:before{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{width:100%;height:100%}/*! + * jQuery UI Resizable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;display:block;touch-action:none}.ui-resizable-autohide .ui-resizable-handle,.ui-resizable-disabled .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-button{display:inline-block;font-size:13px;line-height:26px;height:28px;padding:0 10px 1px;cursor:pointer;border-width:1px;border-style:solid;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-sizing:border-box;color:#555;border-color:#ccc;background:#f7f7f7;box-shadow:0 1px 0 #ccc;vertical-align:top}.ui-button:active,.ui-button:focus{outline:0}.ui-button::-moz-focus-inner{border-width:0;border-style:none;padding:0}.ui-button:focus,.ui-button:hover{background:#fafafa;border-color:#999;color:#23282d}.ui-button:focus{border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.ui-button:active{background:#eee;border-color:#999;box-shadow:inset 0 2px 5px -3px rgba(0,0,0,.5);-webkit-transform:translateY(1px);transform:translateY(1px)}.ui-button:disabled,.ui-button[disabled]{color:#a0a5aa!important;border-color:#ddd!important;background:#f7f7f7!important;box-shadow:none!important;text-shadow:0 1px 0 #fff!important;cursor:default;-webkit-transform:none!important;transform:none!important}@media screen and (max-width:782px){.ui-button{padding:6px 14px;line-height:normal;font-size:14px;vertical-align:middle;height:auto;margin-bottom:4px}}.ui-dialog{position:absolute;top:0;left:0;z-index:100102;background-color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.3)}.ui-dialog-titlebar{background:#fcfcfc;border-bottom:1px solid #dfdfdf;height:36px;font-size:18px;font-weight:600;line-height:36px;padding:0 36px 0 16px}.ui-button.ui-dialog-titlebar-close{background:0 0;border:none;box-shadow:none;color:#666;cursor:pointer;display:block;padding:0;position:absolute;top:0;right:0;width:36px;height:36px;text-align:center}.ui-dialog-titlebar-close:before{font:400 20px/1 dashicons;vertical-align:top;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:36px;width:36px;height:36px;content:'\f158'}.ui-button.ui-dialog-titlebar-close:hover{color:#00a0d2}.ui-dialog-titlebar-close .ui-button-text{display:none}.ui-dialog-content{padding:16px;overflow:auto}.ui-dialog-buttonpane{background:#fcfcfc;border-top:1px solid #dfdfdf;padding:16px}.ui-dialog-buttonpane .ui-button{margin-left:16px}.ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-widget-overlay{position:fixed;top:0;left:0;right:0;bottom:0;min-height:360px;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:100101} \ No newline at end of file diff --git a/backend/wp-includes/css/media-views-rtl.css b/backend/wp-includes/css/media-views-rtl.css new file mode 100644 index 0000000..aee6e6a --- /dev/null +++ b/backend/wp-includes/css/media-views-rtl.css @@ -0,0 +1,2633 @@ +/** + * Base Styles + */ +.media-modal * { + box-sizing: content-box; +} + +.media-modal input, +.media-modal select, +.media-modal textarea { + box-sizing: border-box; +} + +.media-modal, +.media-frame { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 12px; + -webkit-overflow-scrolling: touch; +} + +.media-modal legend, +.media-modal label { + font-size: 13px; +} + +.media-frame input, +.media-frame textarea { + padding: 6px 8px; +} + +.media-frame select, +.wp-admin .media-frame select { + line-height: 28px; + margin-top: 3px; +} + +.media-frame a { + border-bottom: none; + color: #0073aa; +} + +.media-frame a:hover, +.media-frame a:active { + color: #00a0d2; +} + +.media-frame a:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); + outline: none; + color: #124964; +} + +.media-frame a.button { + color: #32373c; +} + +.media-frame a.button:hover { + color: #23282d; +} + +.media-frame a.button-primary, +.media-frame a.button-primary:hover { + color: #fff; +} + +.media-frame input[type="text"], +.media-frame input[type="password"], +.media-frame input[type="number"], +.media-frame input[type="search"], +.media-frame input[type="email"], +.media-frame input[type="url"], +.media-frame textarea, +.media-frame select { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 12px; + border-width: 1px; + border-style: solid; + border-color: #ddd; +} + +.media-frame input[type="text"]:focus, +.media-frame input[type="password"]:focus, +.media-frame input[type="number"]:focus, +.media-frame input[type="search"]:focus, +.media-frame input[type="email"]:focus, +.media-frame input[type="url"]:focus, +.media-frame textarea:focus, +.media-frame select:focus { + border-color: #5b9dd9; +} + +.media-frame select { + height: 24px; + padding: 2px; +} + +.media-frame input:disabled, +.media-frame textarea:disabled, +.media-frame input[readonly], +.media-frame textarea[readonly] { + background-color: #eee; +} + +.media-frame input[type="search"] { + -webkit-appearance: textfield; +} + +.media-frame ::-webkit-input-placeholder { + color: #72777c; +} + +.media-frame ::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +.media-frame :-ms-input-placeholder { + color: #72777c; +} + +.media-frame .hidden { + display: none; +} + +/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-draggable-handle, +.ui-sortable-handle { + touch-action: none; +} + +/** + * Modal + */ +.media-modal { + position: fixed; + top: 30px; + right: 30px; + left: 30px; + bottom: 30px; + z-index: 160000; +} + +.wp-customizer .media-modal { + z-index: 560000; +} + +.media-modal-backdrop { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + z-index: 159900; +} + +.wp-customizer .media-modal-backdrop { + z-index: 559900; +} + +.media-modal-close { + position: absolute; + top: 0; + left: 0; + width: 50px; + height: 50px; + margin: 0; + padding: 0; + border: 1px solid transparent; + background: none; + color: #666; + z-index: 1000; + cursor: pointer; + outline: none; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.media-modal-close:hover, +.media-modal-close:active { + color: #00a0d2; +} + +.media-modal-close:focus { + color: #00a0d2; + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.media-modal-close span.media-modal-icon { + background-image: none; +} + +.media-modal-close .media-modal-icon:before { + content: "\f158"; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.media-modal-content { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + overflow: auto; + min-height: 300px; + box-shadow: 0 5px 15px rgba(0,0,0,0.7); + background: #fcfcfc; + -webkit-font-smoothing: subpixel-antialiased; +} + +.media-modal-content .media-frame select.attachment-filters { + margin-top: 11px; + margin-left: 2%; + width: 42%; + width: calc(48% - 12px); +} + +.media-modal-content .media-toolbar-primary .media-button { + float: left; +} + +.media-modal-content .attachments-browser .search { + width: 100%; +} + +/* higher specificity */ +.wp-core-ui .media-modal-icon { + background-image: url(../images/uploader-icons.png); + background-repeat: no-repeat; +} + +/** + * Toolbar + */ +.media-toolbar { + position: absolute; + top: 0; + right: 0; + left: 0; + z-index: 100; + height: 60px; + padding: 0 16px; + border: 0 solid #ddd; + overflow: hidden; +} + +.media-frame-toolbar .media-toolbar { + top: initial; + bottom: -45px; + height: auto; + overflow: initial; + border-top: 1px solid #ddd; +} + +@media screen and (max-width: 782px) { + .media-frame-toolbar .media-toolbar { + bottom: -48px; + } +} + +.media-toolbar-primary { + float: left; + height: 100%; +} + +.media-toolbar-secondary { + float: right; + height: 100%; +} + +.media-toolbar-primary > .media-button, +.media-toolbar-primary > .media-button-group { + margin-right: 10px; + float: right; + margin-top: 15px; +} + +.media-toolbar-secondary > .media-button, +.media-toolbar-secondary > .media-button-group { + margin-left: 10px; + margin-top: 15px; +} + +/** + * Sidebar + */ +.media-sidebar { + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 267px; + padding: 0 16px 24px; + z-index: 75; + background: #f3f3f3; + border-right: 1px solid #ddd; + overflow: auto; + -webkit-overflow-scrolling: touch; +} + +.hide-toolbar .media-sidebar { + bottom: 0; +} + +.media-sidebar .sidebar-title { + font-size: 20px; + margin: 0; + padding: 12px 10px 10px; + line-height: 28px; +} + +.media-sidebar .sidebar-content { + padding: 0 10px; + margin-bottom: 130px; +} + +.media-sidebar .search { + display: block; + width: 100%; +} + +.media-sidebar h3, /* Back-compat for pre-4.4 */ +.image-details h3, /* Back-compat for pre-4.4 */ +.media-sidebar h2, +.image-details h2 { + position: relative; + font-weight: 600; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 24px 0 8px; +} + +.media-sidebar .setting, +.attachment-details .setting { + display: block; + float: right; + width: 100%; + margin: 1px 0; +} + +.media-sidebar .setting label, +.attachment-details .setting label { + display: block; +} + +.media-sidebar .setting .link-to-custom, +.attachment-details .setting .link-to-custom { + margin: 3px 2px 0; +} + +.media-sidebar .setting span, +.attachment-details .setting span { + min-width: 30%; + margin-left: 4%; + font-size: 12px; + text-align: left; + word-wrap: break-word; +} + +.media-sidebar .setting .name { + max-width: 80px; +} + +.media-sidebar .setting select, +.attachment-details .setting select { + max-width: 65%; +} + +.media-sidebar .setting input[type="checkbox"], +.media-sidebar .field input[type="checkbox"], +.media-sidebar .setting input[type="radio"], +.media-sidebar .field input[type="radio"], +.attachment-details .setting input[type="checkbox"], +.attachment-details .field input[type="checkbox"], +.attachment-details .setting input[type="radio"], +.attachment-details .field input[type="radio"] { + float: none; + margin: 8px 3px 0; + padding: 0; +} + +.media-sidebar .setting span, +.attachment-details .setting span, +.compat-item label span { + float: right; + min-height: 22px; + padding-top: 8px; + line-height: 16px; + font-weight: 400; + color: #666; +} + +.compat-item label span { + text-align: left; +} + +.media-sidebar .setting input[type="text"], +.media-sidebar .setting input[type="password"], +.media-sidebar .setting input[type="email"], +.media-sidebar .setting input[type="number"], +.media-sidebar .setting input[type="search"], +.media-sidebar .setting input[type="tel"], +.media-sidebar .setting input[type="url"], +.media-sidebar .setting textarea, +.media-sidebar .setting .value, +.attachment-details .setting input[type="text"], +.attachment-details .setting input[type="password"], +.attachment-details .setting input[type="email"], +.attachment-details .setting input[type="number"], +.attachment-details .setting input[type="search"], +.attachment-details .setting input[type="tel"], +.attachment-details .setting input[type="url"], +.attachment-details .setting textarea, +.attachment-details .setting .value { + box-sizing: border-box; + margin: 1px; + width: 65%; + float: left; +} + +.media-sidebar .setting .value, +.attachment-details .setting .value { + margin: 0 1px; + text-align: right; +} + +.media-sidebar .setting textarea, +.attachment-details .setting textarea, +.compat-item .field textarea { + height: 62px; + resize: vertical; +} + +.media-sidebar select, +.attachment-details select { + margin-top: 3px; +} + +.compat-item { + float: right; + width: 100%; + overflow: hidden; +} + +.compat-item table { + width: 100%; + table-layout: fixed; + border-spacing: 0; + border: 0; +} + +.compat-item tr { + padding: 2px 0; + display: block; + overflow: hidden; +} + +.compat-item .label, +.compat-item .field { + display: block; + margin: 0; + padding: 0; +} + +.compat-item .label { + min-width: 30%; + margin-left: 4%; + float: right; + text-align: left; +} + +.compat-item .label span { + display: block; + width: 100%; +} + +.compat-item .field { + float: left; + width: 65%; + margin: 1px; +} + +.compat-item .field input[type="text"], +.compat-item .field input[type="password"], +.compat-item .field input[type="email"], +.compat-item .field input[type="number"], +.compat-item .field input[type="search"], +.compat-item .field input[type="tel"], +.compat-item .field input[type="url"], +.compat-item .field textarea { + width: 100%; + margin: 0; + box-sizing: border-box; +} + +.sidebar-for-errors .attachment-details, +.sidebar-for-errors .compat-item, +.sidebar-for-errors .media-sidebar .media-progress-bar, +.sidebar-for-errors .upload-details { + display: none !important; +} + +/** + * Menu + */ +.media-menu { + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + margin: 0; + padding: 10px 0; + background: #f3f3f3; + border-left-width: 1px; + border-left-style: solid; + border-left-color: #ccc; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.media-menu > a { + display: block; + position: relative; + padding: 8px 20px; + margin: 0; + line-height: 18px; + font-size: 14px; + color: #0073aa; + text-decoration: none; +} + +.media-menu > a:hover { + color: #0073aa; + background: rgba( 0, 0, 0, 0.04 ); +} + +.media-menu > a:active { + outline: none; +} + +.media-menu .active, +.media-menu .active:hover { + color: #23282d; + font-weight: 600; +} + +.media-menu .separator { + height: 0; + margin: 12px 20px; + padding: 0; + border-top: 1px solid #ddd; +} + +/** + * Menu + */ +.media-router { + position: relative; + padding: 0 6px; + margin: 0; + clear: both; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.media-router a { + transition: none; +} + +.media-router > a { + position: relative; + float: right; + padding: 8px 10px 9px; + margin: 0; + height: 18px; + line-height: 18px; + font-size: 14px; + text-decoration: none; +} + +.media-router > a:last-child { + border-left: 0; +} + +.media-router > a:active { + outline: none; +} + +.media-router .active, +.media-router .active:hover { + color: #32373c; +} + +.media-router .active, +.media-router > a.active:last-child { + margin: -1px -1px 0; + background: #fff; + border: 1px solid #ddd; + border-bottom: none; +} + +.media-router .active:after { + display: none; +} + +/** + * Frame + */ +.media-frame { + overflow: hidden; + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; +} + +.media-frame-menu { + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 200px; + z-index: 150; +} + +.media-frame-title { + position: absolute; + top: 0; + right: 200px; + left: 0; + height: 50px; + z-index: 200; +} + +.media-frame-router { + position: absolute; + top: 50px; + right: 200px; + left: 0; + height: 36px; + z-index: 200; +} + +.media-frame-content { + position: absolute; + top: 84px; + right: 200px; + left: 0; + bottom: 61px; + height: auto; + width: auto; + margin: 0; + overflow: auto; + background: #fff; + border-top: 1px solid #ddd; +} + +.media-frame-toolbar { + position: absolute; + right: 200px; + left: 0; + bottom: 0; + height: 60px; + z-index: 100; + bottom: 60px; + height: auto; +} + +.media-frame.hide-menu .media-frame-title, +.media-frame.hide-menu .media-frame-router, +.media-frame.hide-menu .media-frame-toolbar, +.media-frame.hide-menu .media-frame-content { + right: 0; +} + +.media-frame.hide-toolbar .media-frame-content { + bottom: 0; +} + +.media-frame.hide-router .media-frame-content { + top: 50px; +} + +.media-frame.hide-menu .media-frame-menu, +.media-frame.hide-router .media-frame-router, +.media-frame.hide-toolbar .media-frame-toolbar { + display: none; +} + +.media-frame.hide-router .media-frame-title { + border-bottom: 1px solid #ddd; + box-shadow: 0 4px 4px -4px rgba( 0, 0, 0, 0.1 ); +} + +.media-frame-title .dashicons { + display: none; +} + +.media-frame-title h1 { + padding: 0 16px; + font-size: 22px; + line-height: 50px; + margin: 0; +} + +.media-frame-title .suggested-dimensions { + font-size: 14px; + float: left; + margin-left: 20px; +} + +.media-frame-content .crop-content { + height: 100%; +} + +.wp-customizer:not(.mobile) .media-frame-content .crop-content.site-icon { + margin-left: 300px; +} + +.media-frame-content .crop-content .crop-image { + display: block; + margin: auto; + max-width: 100%; + max-height: 100%; +} + +.media-frame-content .crop-content .upload-errors +{ + position: absolute; + width: 300px; + top: 50%; + right: 50%; + margin-right: -150px; + margin-left: -150px; + z-index: 600000; +} + +/** + * Iframes + */ +.media-frame .media-iframe { + overflow: hidden; +} + +.media-frame .media-iframe, +.media-frame .media-iframe iframe { + height: 100%; + width: 100%; + border: 0; +} + +/** + * Attachment Browser Filters + */ +.media-frame select.attachment-filters { + margin-top: 11px; + margin-left: 2%; + max-width: 42%; + max-width: calc(48% - 12px); +} + +.media-frame select.attachment-filters:last-of-type { + margin-left: 0; +} + +/** + * Search + */ +.media-frame .search { + margin-top: 11px; + padding: 4px; + font-size: 13px; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + -webkit-appearance: none; +} + +.media-toolbar-primary .search { + max-width: 100%; +} + +/** + * Attachments + */ +.wp-core-ui .attachments { + margin: 0; + -webkit-overflow-scrolling: touch; +} + +/** + * Attachment + */ +.wp-core-ui .attachment { + position: relative; + float: right; + padding: 8px; + margin: 0; + color: #444; + cursor: pointer; + list-style: none; + text-align: center; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + width: 25%; + box-sizing: border-box; +} + +.wp-core-ui .attachment:focus, +.wp-core-ui .selected.attachment:focus, +.wp-core-ui .attachment.details:focus { + box-shadow: + inset 0 0 2px 3px #fff, + inset 0 0 0 7px #5b9dd9; + outline: none; +} + +.wp-core-ui .selected.attachment { + box-shadow: + inset 0 0 0 5px #fff, + inset 0 0 0 7px #ccc; +} + +.wp-core-ui .attachment.details { + box-shadow: + inset 0 0 0 3px #fff, + inset 0 0 0 7px #0073aa; +} + +.wp-core-ui .attachment-preview { + position: relative; + box-shadow: + inset 0 0 15px rgba( 0, 0, 0, 0.1 ), + inset 0 0 0 1px rgba( 0, 0, 0, 0.05 ); + background: #eee; + cursor: pointer; +} + +.wp-core-ui .attachment-preview:before { + content: ""; + display: block; + padding-top: 100%; +} + +.wp-core-ui .attachment .icon { + margin: 0 auto; + overflow: hidden; +} + +.wp-core-ui .attachment .thumbnail { + overflow: hidden; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + opacity: 1; + transition: opacity .1s; +} + +.wp-core-ui .attachment .portrait img { + max-width: 100%; +} + +.wp-core-ui .attachment .landscape img { + max-height: 100%; +} + +.wp-core-ui .attachment .thumbnail:after { + content: ""; + display: block; + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 ); + overflow: hidden; +} + +.wp-core-ui .attachment .thumbnail img { + top: 0; + right: 0; +} + +.wp-core-ui .attachment .thumbnail .centered { + position: absolute; + top: 0; + right: 0; + width: 100%; + height: 100%; + -webkit-transform: translate( -50%, 50% ); /* Fails with spaces?? Weird! */ + transform: translate( -50%, 50% ); +} + +.wp-core-ui .attachment .thumbnail .centered img { + -webkit-transform: translate( 50%, -50% ); + transform: translate( 50%, -50% ); +} + +.wp-core-ui .attachments-browser .attachment .thumbnail .centered img.icon { + -webkit-transform: translate( 50%, -70% ); + transform: translate( 50%, -70% ); +} + +.ie8 .wp-core-ui .attachment img.icon { + top: 20%; + position: relative; +} + +.wp-core-ui .attachment .filename { + position: absolute; + right: 0; + left: 0; + bottom: 0; + overflow: hidden; + max-height: 100%; + word-wrap: break-word; + text-align: center; + font-weight: 600; + background: rgba( 255, 255, 255, 0.8 ); + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 ); +} + +.wp-core-ui .attachment .filename div { + padding: 5px 10px; +} + +.wp-core-ui .attachment .thumbnail img { + position: absolute; +} + +.wp-core-ui .attachment-close { + display: block; + position: absolute; + top: 5px; + left: 5px; + height: 22px; + width: 22px; + padding: 0; + background-color: #fff; + background-position: -96px 4px; + border-radius: 3px; + box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.3 ); + transition: none; +} + +.wp-core-ui .attachment-close:hover, +.wp-core-ui .attachment-close:focus { + background-position: -36px 4px; +} + +.wp-core-ui .attachment .check { + display: none; + height: 24px; + width: 24px; + padding: 0; + border: 0; + position: absolute; + z-index: 10; + top: 0; + left: 0; + outline: none; + background: #eee; + cursor: pointer; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 ); +} + +.wp-core-ui .attachment .check .media-modal-icon { + display: block; + background-position: -1px 0; + height: 15px; + width: 15px; + margin: 5px; +} + +.wp-core-ui .attachment .check:hover .media-modal-icon { + background-position: -40px 0; +} + +.wp-core-ui .attachment.selected .check { + display: block; +} + +.wp-core-ui .attachment.details .check, +.wp-core-ui .attachment.selected .check:focus, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check { + background-color: #0073aa; + box-shadow: + 0 0 0 1px #fff, + 0 0 0 2px #0073aa; +} + +.wp-core-ui .attachment.details .check .media-modal-icon, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check .media-modal-icon { + background-position: -21px 0; +} + +.wp-core-ui .attachment.details .check:hover .media-modal-icon, +.wp-core-ui .attachment.selected .check:focus .media-modal-icon, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check:hover .media-modal-icon { + background-position: -60px 0; +} + +.wp-core-ui .media-frame .attachment .describe { + position: relative; + display: block; + width: 100%; + margin: 0; + padding: 8px; + font-size: 12px; + border-radius: 0; +} + +/** + * Attachments Browser + */ +.media-frame .attachments-browser { + position: relative; + width: 100%; + height: 100%; + overflow: hidden; +} + +.attachments-browser .media-toolbar { + left: 300px; + height: 50px; +} + +.attachments-browser.hide-sidebar .media-toolbar { + left: 0; +} + +.attachments-browser .media-toolbar-primary > .media-button, +.attachments-browser .media-toolbar-primary > .media-button-group, +.attachments-browser .media-toolbar-secondary > .media-button, +.attachments-browser .media-toolbar-secondary > .media-button-group { + margin: 11px 0; +} + +.attachments-browser .attachments { + padding: 2px 8px 8px; +} + +.attachments-browser .attachments, +.attachments-browser .uploader-inline { + position: absolute; + top: 50px; + right: 0; + left: 300px; + bottom: 0; + overflow: auto; + outline: none; +} + +.attachments-browser .uploader-inline.hidden { + display: none; +} + +.attachments-browser .media-toolbar-primary { + max-width: 33%; +} + +.attachments-browser .media-toolbar-secondary { + max-width: 66%; +} + +.uploader-inline .close { + background-color: transparent; + border: 0; + cursor: pointer; + height: 48px; + outline: none; + padding: 0; + position: absolute; + left: 2px; + text-align: center; + top: 2px; + width: 48px; + z-index: 1; +} + +.uploader-inline .close:before { + font: normal 30px/1 dashicons !important; + color: #555d66; + display: inline-block; + content: "\f335"; + font-weight: 300; + margin-top: 1px; +} + +.uploader-inline .close:focus { + outline: 1px solid #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.attachments-browser.hide-sidebar .attachments, +.attachments-browser.hide-sidebar .uploader-inline { + left: 0; + margin-left: 0; +} + +.attachments-browser .instructions { + display: inline-block; + margin-top: 16px; + line-height: 18px; + font-size: 13px; + color: #666; + margin-left: 0.5em; +} + +.attachments-browser .no-media { + padding: 2em 2em 0 0; +} + +/** + * Progress Bar + */ +.media-progress-bar { + position: relative; + height: 10px; + width: 70%; + margin: 10px auto; + border-radius: 10px; + background: #ddd; + background: rgba( 0, 0, 0, 0.1 ); +} + +.media-progress-bar div { + height: 10px; + min-width: 20px; + width: 0; + background: #0073aa; + border-radius: 10px; + transition: width 300ms; +} + +.media-uploader-status .media-progress-bar { + display: none; + width: 100%; +} + +.uploading.media-uploader-status .media-progress-bar { + display: block; +} + +.attachment-preview .media-progress-bar { + position: absolute; + top: 50%; + right: 15%; + width: 70%; + margin: -5px 0 0 0; +} + +.media-uploader-status { + position: relative; + margin: 0 auto; + padding-bottom: 10px; + max-width: 400px; +} + +.uploader-inline .media-uploader-status h3, /* Back-compat for pre-4.4 */ +.uploader-inline .media-uploader-status h2 { + display: none; +} + +.media-uploader-status .upload-details { + display: none; + font-size: 12px; + color: #666; +} + +.uploading.media-uploader-status .upload-details { + display: block; +} + +.media-uploader-status .upload-detail-separator { + padding: 0 4px; +} + +.media-uploader-status .upload-count { + color: #444; +} + +.media-uploader-status .upload-dismiss-errors, +.media-uploader-status .upload-errors { + display: none; +} + +.errors.media-uploader-status .upload-dismiss-errors, +.errors.media-uploader-status .upload-errors { + display: block; +} + +.media-uploader-status .upload-dismiss-errors { + text-decoration: none; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors { + position: absolute; + top: -10px; + left: -10px; + padding: 10px; + transition: none; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors:before { + content: "\f153"; + display: block; + font: normal 16px/1 dashicons; + color: #72777c; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before, +.media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before { + color: #c00; +} + +.upload-errors .upload-error { + padding: 12px; + margin-bottom: 12px; + background: #fff; + border-right: 4px solid #dc3232; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); +} + +.uploader-inline .upload-errors .upload-error { + background-color: #fbeaea; + box-shadow: none; +} + +.upload-errors .upload-error-filename { + font-weight: 600; +} + +.upload-errors .upload-error-message { + display: block; + padding-top: 8px; + word-wrap: break-word; +} + +.uploader-window { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + background: rgba( 0, 86, 132, 0.9 ); + z-index: 250000; + display: none; + text-align: center; + opacity: 0; + transition: opacity 250ms; +} + +.uploader-window-content { + position: absolute; + top: 10px; + right: 10px; + left: 10px; + bottom: 10px; + border: 1px dashed #fff; +} + +.uploader-window h3, /* Back-compat for pre-4.4 */ +.uploader-window h1 { + margin: -0.5em 0 0; + position: absolute; + top: 50%; + right: 0; + left: 0; + -webkit-transform: translateY( -50% ); + transform: translateY( -50% ); + font-size: 40px; + color: #fff; + padding: 0; +} + +.uploader-window .media-progress-bar { + margin-top: 20px; + max-width: 300px; + background: transparent; + border-color: #fff; + display: none; +} + +.uploader-window .media-progress-bar div { + background: #fff; +} + +.uploading .uploader-window .media-progress-bar { + display: block; +} + +.media-frame .uploader-inline { + margin-bottom: 20px; + padding: 0; + text-align: center; +} + +.uploader-inline-content { + position: absolute; + top: 30%; + right: 0; + left: 0; +} + +.uploader-inline-content .upload-ui { + margin: 2em 0; +} + +.uploader-inline-content .post-upload-ui { + margin-bottom: 2em; +} + +.uploader-inline .has-upload-message .upload-ui { + margin: 0 0 4em; +} + +.uploader-inline h3, /* Back-compat for pre-4.4 */ +.uploader-inline h2 { + font-size: 20px; + line-height: 28px; + font-weight: 400; + margin: 0; +} + +.uploader-inline .has-upload-message .upload-instructions { + font-size: 14px; + color: #444; + font-weight: 400; +} + +.uploader-inline .drop-instructions { + display: none; +} + +.supports-drag-drop .uploader-inline .drop-instructions { + display: block; +} + +.uploader-inline p { + font-size: 12px; + margin: 0.5em 0; +} + +.uploader-inline .media-progress-bar { + display: none; +} + +.uploading.uploader-inline .media-progress-bar { + display: block; +} + +.uploader-inline .browser { + display: inline-block !important; +} + +/** + * Selection + */ +.media-selection { + position: absolute; + top: 0; + right: 0; + left: 350px; + height: 60px; + padding: 0 16px 0 0; + overflow: hidden; + white-space: nowrap; +} + +.media-selection .selection-info { + display: inline-block; + font-size: 12px; + height: 60px; + margin-left: 10px; + vertical-align: top; +} + +.media-selection.empty, +.media-selection.editing { + display: none; +} + +.media-selection.one .edit-selection { + display: none; +} + +.media-selection .count { + display: block; + padding-top: 12px; + font-size: 14px; + line-height: 20px; + font-weight: 600; +} + +.media-selection .button-link { + float: right; + padding: 1px 8px; + margin: 1px -8px 1px 8px; + line-height: 16px; + border-left: 1px solid #ddd; + color: #0073aa; + text-decoration: none; +} + +.media-selection .button-link:hover, +.media-selection .button-link:focus { + color: #00a0d2; +} + +.media-selection .button-link:last-child { + border-left: 0; + margin-left: 0; +} + +.selection-info .clear-selection { + color: #bc0b0b; +} + +.selection-info .clear-selection:hover, +.selection-info .clear-selection:focus { + color: #dc3232; +} + +.media-selection .selection-view { + display: inline-block; + vertical-align: top; +} + +.media-selection .attachments { + display: inline-block; + height: 48px; + margin: 6px; + padding: 0; + overflow: hidden; + vertical-align: top; +} + +.media-selection .attachment { + width: 40px; + padding: 0; + margin: 4px; +} + +.media-selection .attachment .thumbnail { + top: 0; + left: 0; + bottom: 0; + right: 0; +} + +.media-selection .attachment .icon { + width: 50%; +} + +.media-selection .attachment-preview { + box-shadow: none; + background: none; +} + +.wp-core-ui .media-selection .attachment:focus, +.wp-core-ui .media-selection .selected.attachment:focus, +.wp-core-ui .media-selection .attachment.details:focus { + box-shadow: + 0 0 0 1px #fff, + 0 0 2px 3px #5b9dd9; +} + +.wp-core-ui .media-selection .selected.attachment { + box-shadow: none; +} + +.wp-core-ui .media-selection .attachment.details { + box-shadow: + 0 0 0 1px #fff, + 0 0 0 3px #0073aa; +} + +.media-selection:after { + content: ""; + display: block; + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 25px; + background-image: linear-gradient(to right, rgba( 255, 255, 255, 1 ), rgba( 255, 255, 255, 0 )); +} + +.media-selection .attachment .filename { + display: none; +} + +/** + * Spinner + */ +.media-frame .spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + float: left; + display: inline-block; + visibility: hidden; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 0; + vertical-align: middle; +} + +.media-frame .spinner.is-active { + visibility: visible; +} + +.media-toolbar .spinner { + margin-top: 14px; +} + +/** + * Attachment Details + */ +.attachment-details { + position: relative; + overflow: auto; +} + +.attachment-details .settings-save-status { + float: left; + text-transform: none; + z-index: 10; +} + +.attachment-details .settings-save-status .spinner { + margin-right: 5px; +} + +.attachment-details .settings-save-status .saved { + float: left; + display: none; +} + +.attachment-details.save-waiting .settings-save-status .spinner { + visibility: visible; +} + +.attachment-details.save-complete .settings-save-status .saved { + display: block; +} + +.attachment-info { + overflow: hidden; + min-height: 60px; + margin-bottom: 16px; + line-height: 18px; + color: #666; + border-bottom: 1px solid #ddd; + padding-bottom: 11px; +} + +.attachment-info .filename { + font-weight: 600; + color: #444; + word-wrap: break-word; +} + +.attachment-info .thumbnail { + position: relative; + float: right; + max-width: 120px; + max-height: 120px; + margin-top: 5px; + margin-left: 10px; + margin-bottom: 5px; +} + +.uploading .attachment-info .thumbnail { + width: 120px; + height: 80px; + box-shadow: inset 0 0 15px rgba( 0, 0, 0, 0.1 ); +} + +.uploading .attachment-info .media-progress-bar { + margin-top: 35px; +} + +.attachment-info .thumbnail-image:after { + content: ""; + display: block; + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 ); + overflow: hidden; +} + +.attachment-info .thumbnail img { + display: block; + max-width: 120px; + max-height: 120px; + margin: 0 auto; +} + +.attachment-info .details { + float: right; + font-size: 12px; + max-width: 100%; +} + +.attachment-info .edit-attachment, +.attachment-info .delete-attachment, +.attachment-info .trash-attachment, +.attachment-info .untrash-attachment { + display: block; + text-decoration: none; + white-space: nowrap; +} + +.attachment-details.needs-refresh .attachment-info .edit-attachment { + display: none; +} + +.attachment-info .edit-attachment { + display: block; +} + +.media-modal .delete-attachment, +.media-modal .trash-attachment, +.media-modal .untrash-attachment { + display: inline; + padding: 0; + color: #bc0b0b; +} + +.media-modal .delete-attachment:hover, +.media-modal .delete-attachment:focus, +.media-modal .trash-attachment:hover, +.media-modal .trash-attachment:focus, +.media-modal .untrash-attachment:hover, +.media-modal .untrash-attachment:focus { + color: #dc3232; +} + +/** + * Attachment Display Settings + */ +.attachment-display-settings { + width: 100%; + float: right; + overflow: hidden; +} + +.attachment-display-settings h4 { + margin: 1.4em 0 0.4em; +} + +.collection-settings { + overflow: hidden; +} + +.collection-settings .setting input[type="checkbox"] { + float: right; + margin-left: 8px; +} + +.collection-settings .setting span { + min-width: inherit; +} + +/** + * Image Editor + */ +.media-modal .imgedit-wrap { + position: static; +} + +.media-modal .imgedit-wrap .imgedit-panel-content { + padding: 16px; + position: absolute; + top: 0; + left: 282px; + bottom: 0; + right: 0; + overflow: auto; +} + +.media-modal .imgedit-wrap .imgedit-settings { + background: #f3f3f3; + border-right: 1px solid #ddd; + padding: 20px 16px 16px; + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 250px; + overflow: auto; +} + +.media-modal .imgedit-group { + background: none; + border: none; + border-bottom: 1px solid #ddd; + box-shadow: none; + margin: 0; + margin-bottom: 16px; + padding: 0; + padding-bottom: 16px; + position: relative; /* RTL fix, #WP29352 */ +} + +.media-modal .imgedit-group:last-of-type { + border: none; + margin: 0; + padding: 0; +} + +.media-modal .imgedit-group-top { + margin: 0; +} + +.media-modal .imgedit-group-top h3, /* Back-compat for pre-4.4 */ +.media-modal .imgedit-group-top h2, +.media-modal .imgedit-group-top h2 .button-link { + display: inline-block; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 0; + margin-top: 3px; +} + +.media-modal .imgedit-group-top h3 a, /* Back-compat for pre-4.4 */ +.media-modal .imgedit-group-top h2 a, +.media-modal .imgedit-group-top h2 .button-link { + text-decoration: none; + color: #666; +} + +/* higher specificity than media.css */ +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle, +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:hover, +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:active { + border: 1px solid transparent; + margin: 0; + padding: 0; + background: transparent; + color: #0074a2; + font-size: 20px; + line-height: 1; + cursor: pointer; + box-sizing: content-box; + box-shadow: none; +} + +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:focus { + color: #0074a2; + border-color: #5b9dd9; + outline: none; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui.media-modal .imgedit-group-top .dashicons-arrow-down.imgedit-help-toggle { + margin-top: -3px; +} + +.wp-core-ui.media-modal .image-editor h3 .imgedit-help-toggle { + margin-top: -2px; +} + +.media-modal .imgedit-help-toggled span.dashicons:before { + content: "\f142"; +} + +.media-modal .imgedit-thumbnail-preview { + margin: 10px 0 0 8px; +} + +.imgedit-thumbnail-preview-caption { + display: block; +} + +.media-modal .imgedit-wrap div.updated { + margin: 0; + margin-bottom: 16px; +} + + +/** + * Embed from URL and Image Details + */ +.embed-url { + display: block; + position: relative; + padding: 16px; + margin: 0; + z-index: 250; + background: #fff; + font-size: 18px; +} + +.media-frame .embed-url input { + font-size: 18px; + padding: 12px 14px; + width: 100%; + min-width: 200px; + box-shadow: inset -2px 2px 4px -2px rgba( 0, 0, 0, 0.1 ); +} + +.media-frame .embed-url .spinner { + position: absolute; + top: 32px; + left: 26px; +} + +.media-frame .embed-loading .embed-url .spinner { + visibility: visible; +} + +.embed-link-settings, +.embed-media-settings { + position: absolute; + top: 70px; + right: 0; + left: 0; + bottom: 0; + padding: 16px 16px 32px; + overflow: auto; +} + +.media-embed .embed-link-settings { + /* avoid Firefox to give focus to the embed preview container parent */ + overflow: visible; +} + +.embed-preview img, +.embed-preview iframe, +.embed-preview embed, +.mejs-container video { + max-width: 100%; + vertical-align: middle; +} + +.embed-preview a { + display: inline-block; +} + +.embed-preview img { + display: block; + height: auto; +} + +.mejs-container:focus { + outline: 1px solid #5b9dd9; + box-shadow: 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.image-details .media-modal { + right: 140px; + left: 140px; +} + +.image-details .media-frame-title, +.image-details .media-frame-content, +.image-details .media-frame-router { + right: 0; +} + +.image-details .embed-media-settings { + top: 0; + overflow: visible; + padding: 0; +} + +.image-details .embed-media-settings, +.image-details .embed-media-settings div { + box-sizing: border-box; +} + +.image-details .column-settings { + background: #f3f3f3; + border-left: 1px solid #ddd; + min-height: 100%; + width: 55%; + position: absolute; + top: 0; + right: 0; +} + +.image-details .column-settings h3, /* Back-compat for pre-4.4 */ +.image-details .column-settings h2 { + margin: 20px; + padding-top: 20px; + border-top: 1px solid #ddd; + color: #23282d; +} + +.image-details .column-image { + width: 45%; + position: absolute; + right: 55%; + top: 0; +} + +.image-details .image { + margin: 20px; +} + +.image-details .image img { + max-width: 100%; + max-height: 500px; +} + +.image-details .advanced-toggle { + padding: 0; + color: #666; + text-transform: uppercase; + text-decoration: none; +} + +.image-details .advanced-toggle:hover, +.image-details .advanced-toggle:active { + color: #666; +} + +.image-details .advanced-toggle:after { + font: normal 20px/1 dashicons; + speak: none; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + content: "\f140"; + display: inline-block; + margin-top: -2px; +} + +.image-details .advanced-visible .advanced-toggle:after { + content: "\f142"; +} + +.image-details .embed-media-settings .size { + margin-bottom: 4px; +} + +.image-details .custom-size span { + display: block; +} + +.image-details .custom-size label { + display: block; + float: right; +} + +.image-details .custom-size span small { + color: #555d66; /* #f3f3f3 background */ + font-size: inherit; +} + +.image-details .custom-size input { + width: 5em; +} + +.image-details .custom-size .sep { + float: right; + margin: 26px 6px 0 6px; +} + +.image-details .custom-size:after { + content: ""; + display: table; + clear: both; +} + +.media-embed .thumbnail { + max-width: 100%; + max-height: 200px; + position: relative; + float: right; +} + +.media-embed .thumbnail img { + max-height: 200px; + display: block; +} + +.media-embed .thumbnail:after { + content: ""; + display: block; + position: absolute; + top: 0; + right: 0; + left: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 ); + overflow: hidden; +} + +.media-embed .setting { + width: 100%; + margin: 10px 0; + float: right; + display: block; + clear: both; +} + +.image-details .embed-media-settings .setting { + float: none; + width: auto; +} + +.image-details .actions { + margin: 10px 0; +} + +.image-details .hidden { + display: none; +} + +.media-embed .setting input[type="text"], +.media-embed .setting textarea { + display: block; + width: 100%; + max-width: 400px; + margin: 1px 0; +} + +.image-details .embed-media-settings .setting input[type="text"], +.image-details .embed-media-settings .setting textarea { + max-width: inherit; + width: 70%; +} + +.image-details .embed-media-settings .setting input.link-to-custom, +.image-details .embed-media-settings .link-target, +.image-details .embed-media-settings .custom-size { + margin-right: 27%; + width: 70%; +} + +.image-details .embed-media-settings .link-target { + margin-top: 24px; +} + +.media-embed .setting input.hidden, +.media-embed .setting textarea.hidden { + display: none; +} + +.media-embed .setting span { + display: block; + width: 200px; + font-size: 13px; + line-height: 24px; + color: #666; +} + +.image-details .embed-media-settings .setting span { + float: right; + width: 25%; + text-align: left; + margin: 8px 1% 0 1%; + line-height: 1.1; +} + +.media-embed .setting .button-group { + margin: 2px 0; +} + +.media-embed-sidebar { + position: absolute; + top: 0; + right: 440px; +} + +.advanced-section, +.link-settings { + margin-top: 10px; +} + +/* Drag & drop on the editor upload */ +.wp-editor-wrap .uploader-editor { + background: rgba( 150, 150, 150, 0.9 ); + position: absolute; + top: 0; + right: 0; + width: 100%; + height: 100%; + z-index: 99998; /* under the toolbar */ + display: none; + text-align: center; +} + +.wp-editor-wrap .uploader-editor-content { + border: 1px dashed #fff; + position: absolute; + top: 10px; + right: 10px; + left: 10px; + bottom: 10px; +} + +.wp-editor-wrap .uploader-editor .uploader-editor-title { + position: absolute; + top: 50%; + right: 0; + left: 0; + -webkit-transform: translateY( -50% ); + transform: translateY( -50% ); + font-size: 3em; + line-height: 1.3; + font-weight: 600; + color: #fff; + padding: 0; + margin: 0; + display: none; +} + +.wp-editor-wrap .uploader-editor.droppable { + background: rgba( 0, 86, 132, 0.9 ); +} + +.wp-editor-wrap .uploader-editor.droppable .uploader-editor-title { + display: block; +} + +/** + * IE7 Fixes + */ +.ie7 .media-frame .attachments-browser { + position: static; +} + +.ie7 .media-frame .embed-url input { + margin-top: 4px; + width: 90%; +} + +.ie7 .compat-item { + width: 99%; +} + +.ie7 .attachment-display-settings { + width: auto; +} + +.ie7 .attachment-preview, +.ie7 .attachment-preview .thumbnail { + width: 120px; + height: 120px; +} + +.ie7 .media-frame .attachment .describe { + width: 102px; +} + +.ie7 .media-sidebar .setting select { + max-width: 55%; +} + +.ie7 .media-sidebar .setting input[type="text"], +.ie7 .media-sidebar .setting input[type="password"], +.ie7 .media-sidebar .setting input[type="email"], +.ie7 .media-sidebar .setting input[type="number"], +.ie7 .media-sidebar .setting input[type="search"], +.ie7 .media-sidebar .setting input[type="tel"], +.ie7 .media-sidebar .setting input[type="url"], +.ie7 .media-sidebar .setting textarea { + width: 55%; +} + +.ie7 .media-sidebar .setting .link-to-custom { + float: right; +} + +/** + * Localization + */ +.rtl .media-modal, +.rtl .media-frame, +.rtl .media-frame .search, +.rtl .media-frame input[type="text"], +.rtl .media-frame input[type="password"], +.rtl .media-frame input[type="number"], +.rtl .media-frame input[type="search"], +.rtl .media-frame input[type="email"], +.rtl .media-frame input[type="url"], +.rtl .media-frame input[type="tel"], +.rtl .media-frame textarea, +.rtl .media-frame select { + font-family: Tahoma, sans-serif; +} + +:lang(he-il) .rtl .media-modal, +:lang(he-il) .rtl .media-frame, +:lang(he-il) .rtl .media-frame .search, +:lang(he-il) .rtl .media-frame input[type="text"], +:lang(he-il) .rtl .media-frame input[type="password"], +:lang(he-il) .rtl .media-frame input[type="number"], +:lang(he-il) .rtl .media-frame input[type="search"], +:lang(he-il) .rtl .media-frame input[type="email"], +:lang(he-il) .rtl .media-frame input[type="url"], +:lang(he-il) .rtl .media-frame textarea, +:lang(he-il) .rtl .media-frame select { + font-family: Arial, sans-serif; +} + +/** + * Responsive layout + */ +@media only screen and (max-width: 900px) { + + /* Drop-down menu */ + .media-frame:not(.hide-menu) .media-frame-title, + .media-frame:not(.hide-menu) .media-frame-router, + .media-frame:not(.hide-menu) .media-frame-content, + .media-frame:not(.hide-menu) .media-frame-toolbar { + right: 0; + } + + .media-frame:not(.hide-menu) .media-frame-menu { + position: static; + width: 0; + } + + .media-frame:not(.hide-menu) .media-menu { + width: auto; + max-width: 80%; + overflow: auto; + z-index: 2000; + top: 50px; + right: -300px; + left: auto; + bottom: auto; + padding: 5px 0; + border: 1px solid #ccc; + } + + .media-frame:not(.hide-menu) .media-menu.visible { + right: 0; + } + + .media-frame:not(.hide-menu) .media-menu > a { + padding: 12px 16px; + font-size: 16px; + } + + .media-frame:not(.hide-menu) .media-menu > a.active { + display: none; + } + + .media-frame:not(.hide-menu) .media-menu .separator { + margin: 5px 10px; + } + + .media-frame:not(.hide-menu) .media-frame-title { + right: 0; + } + + .media-frame:not(.hide-menu) .media-frame-title .dashicons { + display: inline-block; + line-height: 50px; + } + + .media-frame:not(.hide-menu) .media-frame-title h1 { + color: #0073aa; + line-height: 3; + font-size: 18px; + float: right; + cursor: pointer; + } + /* End drop-down menu */ + + .media-sidebar { + width: 230px; + } + + .attachments-browser .attachments, + .attachments-browser .uploader-inline, + .attachments-browser .media-toolbar { + left: 262px; + } + + .media-sidebar .setting, + .attachment-details .setting { + margin: 6px 0px; + } + + .media-sidebar .setting input, + .media-sidebar .setting textarea, + .media-sidebar .setting span, + .attachment-details .setting input, + .attachment-details .setting textarea, + .attachment-details .setting span, + .compat-item label span { + float: none; + } + + .media-sidebar .setting span, + .attachment-details .setting span, + .compat-item label span { + text-align: inherit; + min-height: 16px; + margin: 0; + padding: 8px 2px 0; + } + + .media-sidebar .setting .value, + .attachment-details .setting .value { + float: none; + width: auto; + } + + .media-sidebar .setting input[type="text"], + .media-sidebar .setting input[type="password"], + .media-sidebar .setting input[type="email"], + .media-sidebar .setting input[type="number"], + .media-sidebar .setting input[type="search"], + .media-sidebar .setting input[type="tel"], + .media-sidebar .setting input[type="url"], + .media-sidebar .setting textarea, + .media-sidebar .setting select, + .attachment-details .setting input[type="text"], + .attachment-details .setting input[type="password"], + .attachment-details .setting input[type="email"], + .attachment-details .setting input[type="number"], + .attachment-details .setting input[type="search"], + .attachment-details .setting input[type="tel"], + .attachment-details .setting input[type="url"], + .attachment-details .setting textarea, + .attachment-details .setting select { + float: none; + width: 98%; + max-width: none; + height: auto; + } + + .media-sidebar .setting select.columns, + .attachment-details .setting select.columns { + width: auto; + } + + .media-frame input, + .media-frame textarea, + .media-frame .search { + padding: 3px 6px; + } + + .image-details .column-image { + width: 30%; + right: 70%; + } + + .image-details .column-settings { + width: 70%; + } + + .image-details .media-modal { + right: 30px; + left: 30px; + } + + .image-details .embed-media-settings .setting { + margin: 20px; + } + + .image-details .embed-media-settings .setting span { + float: none; + text-align: right; + width: 100%; + margin-bottom: 4px; + } + + .image-details .embed-media-settings .setting input.link-to-custom, + .image-details .embed-media-settings .setting input[type="text"], + .image-details .embed-media-settings .setting textarea { + width: 100%; + margin-right: 0; + } + + .image-details .embed-media-settings .custom-size { + margin-right: 20px; + } + + .collection-settings .setting input[type="checkbox"] { + margin-top: 0; + } + + .media-selection { + min-width: 120px; + } + + .media-selection:after { + background: none; + } + + .media-selection .attachments { + display: none; + } + + .media-modal .attachments-browser .media-toolbar .search { + max-width: 100%; + height: auto; + float: left; + } + + .media-modal .attachments-browser .media-toolbar .attachment-filters { + height: auto; + } + + .media-modal .attachments-browser .media-toolbar .spinner { + margin: 14px 2px 0; + } + + /* Text inputs need to be 16px, or they force zooming on iOS */ + .media-frame input[type="text"], + .media-frame input[type="password"], + .media-frame input[type="number"], + .media-frame input[type="search"], + .media-frame input[type="email"], + .media-frame input[type="url"], + .media-frame textarea, + .media-frame select { + font-size: 16px; + } +} + +/* Responsive on portrait and landscape */ +@media only screen and (max-width: 640px), screen and (max-height: 400px) { + /* Full-bleed modal */ + .media-modal, + .image-details .media-modal { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + } + + .media-modal-backdrop { + position: fixed; + } + + .media-sidebar { + z-index: 1900; + max-width: 70%; + bottom: 120%; + box-sizing: border-box; + padding-bottom: 0; + } + + .media-sidebar.visible { + bottom: 0; + } + + .attachments-browser .attachments, + .attachments-browser .uploader-inline, + .attachments-browser .media-toolbar { + left: 0; + } + + .image-details .media-frame-title { + display: block; + top: 0; + font-size: 14px; + } + + .image-details .column-image, + .image-details .column-settings { + width: 100%; + position: relative; + right: 0; + } + + .image-details .column-settings { + padding: 4px 0; + } + + /* Media tabs on the top */ + .media-frame-content .media-toolbar .instructions { + display: none; + } +} + +/* Landscape specific header override */ +@media screen and (max-height: 400px) { + .media-menu { + padding: 0; + } + + .media-frame-router { + top: 44px; + } + + .media-frame-content { + top: 78px; + } + + .attachments-browser .attachments { + top: 40px; + } + + /* Prevent unnecessary scrolling on title input */ + .embed-link-settings { + overflow: visible; + } +} + +@media only screen and (max-width: 480px) { + .media-modal-close { + top: -5px; + } + + .media-modal .media-frame-title { + height: 40px; + } + + .wp-core-ui.wp-customizer .media-button { + margin-top: 13px; + } + + .media-modal .media-frame-title h1, + .media-frame:not(.hide-menu) .media-frame-title h1 { + font-size: 18px; + line-height: 40px; + } + + .media-frame:not(.hide-menu) .media-frame-title .dashicons { + line-height: 40px; + } + + .media-frame-router, + .media-frame:not(.hide-menu) .media-menu { + top: 40px; + } + + .media-frame-content { + top: 74px; + } + + .media-frame.hide-router .media-frame-content { + top: 40px; + } +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .wp-core-ui .media-modal-icon { + background-image: url(../images/uploader-icons-2x.png); + background-size: 134px 15px; + } + + .media-frame .spinner { + background-image: url(../images/spinner-2x.gif); + } +} + +.media-frame-content[data-columns="1"] .attachment { + width: 100%; +} + +.media-frame-content[data-columns="2"] .attachment { + width: 50%; +} + +.media-frame-content[data-columns="3"] .attachment { + width: 33.33%; +} + +.media-frame-content[data-columns="4"] .attachment { + width: 25%; +} + +.media-frame-content[data-columns="5"] .attachment { + width: 20%; +} + +.media-frame-content[data-columns="6"] .attachment { + width: 16.66%; +} + +.media-frame-content[data-columns="7"] .attachment { + width: 14.28%; +} + +.media-frame-content[data-columns="8"] .attachment { + width: 12.5%; +} + +.media-frame-content[data-columns="9"] .attachment { + width: 11.11%; +} + +.media-frame-content[data-columns="10"] .attachment { + width: 10%; +} + +.media-frame-content[data-columns="11"] .attachment { + width: 9.09%; +} + +.media-frame-content[data-columns="12"] .attachment { + width: 8.33%; +} diff --git a/backend/wp-includes/css/media-views-rtl.min.css b/backend/wp-includes/css/media-views-rtl.min.css new file mode 100644 index 0000000..fd65280 --- /dev/null +++ b/backend/wp-includes/css/media-views-rtl.min.css @@ -0,0 +1,9 @@ +/*! This file is auto-generated */ +.media-menu,.media-router{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.media-modal *{box-sizing:content-box}.media-modal input,.media-modal select,.media-modal textarea{box-sizing:border-box}.media-frame,.media-modal{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:12px;-webkit-overflow-scrolling:touch}.media-modal label,.media-modal legend{font-size:13px}.media-frame input,.media-frame textarea{padding:6px 8px}.media-frame select,.wp-admin .media-frame select{line-height:28px;margin-top:3px}.media-frame a{border-bottom:none;color:#0073aa}.media-frame a:active,.media-frame a:hover{color:#00a0d2}.media-frame a:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8);outline:0;color:#124964}.media-frame a.button{color:#32373c}.media-frame a.button:hover{color:#23282d}.media-frame a.button-primary,.media-frame a.button-primary:hover{color:#fff}.media-frame input[type=text],.media-frame input[type=password],.media-frame input[type=number],.media-frame input[type=search],.media-frame input[type=email],.media-frame input[type=url],.media-frame select,.media-frame textarea{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:12px;border-width:1px;border-style:solid;border-color:#ddd}.media-frame input[type=text]:focus,.media-frame input[type=password]:focus,.media-frame input[type=number]:focus,.media-frame input[type=search]:focus,.media-frame input[type=email]:focus,.media-frame input[type=url]:focus,.media-frame select:focus,.media-frame textarea:focus{border-color:#5b9dd9}.media-frame select{height:24px;padding:2px}.media-frame input:disabled,.media-frame input[readonly],.media-frame textarea:disabled,.media-frame textarea[readonly]{background-color:#eee}.media-frame input[type=search]{-webkit-appearance:textfield}.media-frame ::-webkit-input-placeholder{color:#72777c}.media-frame ::-moz-placeholder{color:#72777c;opacity:1}.media-frame :-ms-input-placeholder{color:#72777c}.media-frame .hidden{display:none}/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-draggable-handle,.ui-sortable-handle{touch-action:none}.media-modal{position:fixed;top:30px;right:30px;left:30px;bottom:30px;z-index:160000}.wp-customizer .media-modal{z-index:560000}.media-modal-backdrop{position:fixed;top:0;right:0;left:0;bottom:0;min-height:360px;background:#000;opacity:.7;z-index:159900}.wp-customizer .media-modal-backdrop{z-index:559900}.media-modal-close{position:absolute;top:0;left:0;width:50px;height:50px;margin:0;padding:0;border:1px solid transparent;background:0 0;color:#666;z-index:1000;cursor:pointer;outline:0;transition:color .1s ease-in-out,background .1s ease-in-out}.media-modal-close:active,.media-modal-close:hover{color:#00a0d2}.media-modal-close:focus{color:#00a0d2;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.media-modal-close span.media-modal-icon{background-image:none}.media-modal-close .media-modal-icon:before{content:"\f158";font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.media-modal-content{position:absolute;top:0;right:0;left:0;bottom:0;overflow:auto;min-height:300px;box-shadow:0 5px 15px rgba(0,0,0,.7);background:#fcfcfc;-webkit-font-smoothing:subpixel-antialiased}.media-modal-content .media-frame select.attachment-filters{margin-top:11px;margin-left:2%;width:42%;width:calc(48% - 12px)}.media-modal-content .media-toolbar-primary .media-button{float:left}.media-modal-content .attachments-browser .search{width:100%}.wp-core-ui .media-modal-icon{background-image:url(../images/uploader-icons.png);background-repeat:no-repeat}.media-toolbar{position:absolute;top:0;right:0;left:0;z-index:100;height:60px;padding:0 16px;border:0 solid #ddd;overflow:hidden}.media-frame-toolbar .media-toolbar{top:initial;bottom:-45px;height:auto;overflow:initial;border-top:1px solid #ddd}.media-menu,.media-sidebar{top:0;background:#f3f3f3;left:0}@media screen and (max-width:782px){.media-frame-toolbar .media-toolbar{bottom:-48px}}.media-toolbar-primary{float:left;height:100%}.media-toolbar-secondary{float:right;height:100%}.media-toolbar-primary>.media-button,.media-toolbar-primary>.media-button-group{margin-right:10px;float:right;margin-top:15px}.media-toolbar-secondary>.media-button,.media-toolbar-secondary>.media-button-group{margin-left:10px;margin-top:15px}.media-sidebar{position:absolute;bottom:0;width:267px;padding:0 16px 24px;z-index:75;border-right:1px solid #ddd;overflow:auto;-webkit-overflow-scrolling:touch}.hide-toolbar .media-sidebar{bottom:0}.media-sidebar .sidebar-title{font-size:20px;margin:0;padding:12px 10px 10px;line-height:28px}.media-sidebar .sidebar-content{padding:0 10px;margin-bottom:130px}.media-sidebar .search{display:block;width:100%}.image-details h2,.image-details h3,.media-sidebar h2,.media-sidebar h3{position:relative;font-weight:600;text-transform:uppercase;font-size:12px;color:#666;margin:24px 0 8px}.attachment-details .setting,.media-sidebar .setting{display:block;float:right;width:100%;margin:1px 0}.attachment-details .setting label,.media-sidebar .setting label{display:block}.attachment-details .setting .link-to-custom,.media-sidebar .setting .link-to-custom{margin:3px 2px 0}.attachment-details .setting span,.media-sidebar .setting span{min-width:30%;margin-left:4%;font-size:12px;text-align:left;word-wrap:break-word}.media-sidebar .setting .name{max-width:80px}.attachment-details .setting select,.media-sidebar .setting select{max-width:65%}.attachment-details .field input[type=radio],.attachment-details .field input[type=checkbox],.attachment-details .setting input[type=radio],.attachment-details .setting input[type=checkbox],.media-sidebar .field input[type=radio],.media-sidebar .field input[type=checkbox],.media-sidebar .setting input[type=radio],.media-sidebar .setting input[type=checkbox]{float:none;margin:8px 3px 0;padding:0}.attachment-details .setting span,.compat-item label span,.media-sidebar .setting span{float:right;min-height:22px;padding-top:8px;line-height:16px;font-weight:400;color:#666}.media-menu>a,.media-router>a{line-height:18px;font-size:14px;text-decoration:none}.compat-item label span{text-align:left}.attachment-details .setting .value,.attachment-details .setting input[type=tel],.attachment-details .setting input[type=text],.attachment-details .setting input[type=password],.attachment-details .setting input[type=number],.attachment-details .setting input[type=search],.attachment-details .setting input[type=email],.attachment-details .setting input[type=url],.attachment-details .setting textarea,.media-sidebar .setting .value,.media-sidebar .setting input[type=tel],.media-sidebar .setting input[type=text],.media-sidebar .setting input[type=password],.media-sidebar .setting input[type=number],.media-sidebar .setting input[type=search],.media-sidebar .setting input[type=email],.media-sidebar .setting input[type=url],.media-sidebar .setting textarea{box-sizing:border-box;margin:1px;width:65%;float:left}.attachment-details .setting .value,.media-sidebar .setting .value{margin:0 1px;text-align:right}.attachment-details .setting textarea,.compat-item .field textarea,.media-sidebar .setting textarea{height:62px;resize:vertical}.attachment-details select,.media-sidebar select{margin-top:3px}.compat-item{float:right;width:100%;overflow:hidden}.compat-item table{width:100%;table-layout:fixed;border-spacing:0;border:0}.compat-item tr{padding:2px 0;display:block;overflow:hidden}.compat-item .field,.compat-item .label{display:block;margin:0;padding:0}.compat-item .label{min-width:30%;margin-left:4%;float:right;text-align:left}.compat-item .label span{display:block;width:100%}.compat-item .field{float:left;width:65%;margin:1px}.compat-item .field input[type=tel],.compat-item .field input[type=text],.compat-item .field input[type=password],.compat-item .field input[type=number],.compat-item .field input[type=search],.compat-item .field input[type=email],.compat-item .field input[type=url],.compat-item .field textarea{width:100%;margin:0;box-sizing:border-box}.sidebar-for-errors .attachment-details,.sidebar-for-errors .compat-item,.sidebar-for-errors .media-sidebar .media-progress-bar,.sidebar-for-errors .upload-details{display:none!important}.media-menu{position:absolute;right:0;bottom:0;margin:0;padding:10px 0;border-left-width:1px;border-left-style:solid;border-left-color:#ccc;user-select:none}.media-menu>a{display:block;position:relative;padding:8px 20px;margin:0;color:#0073aa}.media-frame-title .dashicons,.media-frame.hide-menu .media-frame-menu,.media-frame.hide-router .media-frame-router,.media-frame.hide-toolbar .media-frame-toolbar{display:none}.media-menu>a:hover{color:#0073aa;background:rgba(0,0,0,.04)}.media-menu>a:active{outline:0}.media-menu .active,.media-menu .active:hover{color:#23282d;font-weight:600}.media-menu .separator{height:0;margin:12px 20px;padding:0;border-top:1px solid #ddd}.media-router{position:relative;padding:0 6px;margin:0;clear:both;user-select:none}.media-router a{transition:none}.media-router>a{position:relative;float:right;padding:8px 10px 9px;margin:0;height:18px}.media-frame,.media-frame-menu{position:absolute;right:0;bottom:0;top:0}.media-router>a:last-child{border-left:0}.media-router>a:active{outline:0}.media-router .active,.media-router .active:hover{color:#32373c}.media-router .active,.media-router>a.active:last-child{margin:-1px -1px 0;background:#fff;border:1px solid #ddd;border-bottom:none}.media-router .active:after{display:none}.media-frame{overflow:hidden;left:0}.media-frame-menu{width:200px;z-index:150}.media-frame-router,.media-frame-title{position:absolute;right:200px;left:0;z-index:200}.media-frame-title{top:0;height:50px}.media-frame-router{top:50px;height:36px}.media-frame-content,.media-frame-toolbar{right:200px;height:auto;position:absolute;left:0}.media-frame-content{top:84px;bottom:61px;width:auto;margin:0;overflow:auto;background:#fff;border-top:1px solid #ddd}.media-frame-toolbar{z-index:100;bottom:60px}.media-frame.hide-menu .media-frame-content,.media-frame.hide-menu .media-frame-router,.media-frame.hide-menu .media-frame-title,.media-frame.hide-menu .media-frame-toolbar{right:0}.media-frame.hide-toolbar .media-frame-content{bottom:0}.media-frame.hide-router .media-frame-content{top:50px}.media-frame.hide-router .media-frame-title{border-bottom:1px solid #ddd;box-shadow:0 4px 4px -4px rgba(0,0,0,.1)}.media-frame-title h1{padding:0 16px;font-size:22px;line-height:50px;margin:0}.media-frame-title .suggested-dimensions{font-size:14px;float:left;margin-left:20px}.media-frame-content .crop-content{height:100%}.wp-customizer:not(.mobile) .media-frame-content .crop-content.site-icon{margin-left:300px}.media-frame-content .crop-content .crop-image{display:block;margin:auto;max-width:100%;max-height:100%}.media-frame-content .crop-content .upload-errors{position:absolute;width:300px;top:50%;right:50%;margin-right:-150px;margin-left:-150px;z-index:600000}.media-frame .media-iframe{overflow:hidden}.media-frame .media-iframe,.media-frame .media-iframe iframe{height:100%;width:100%;border:0}.media-frame select.attachment-filters{margin-top:11px;margin-left:2%;max-width:42%;max-width:calc(48% - 12px)}.media-toolbar-primary .search,.wp-core-ui .attachment .portrait img{max-width:100%}.media-frame select.attachment-filters:last-of-type{margin-left:0}.media-frame .search{margin-top:11px;padding:4px;font-size:13px;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;-webkit-appearance:none}.wp-core-ui .attachments{margin:0;-webkit-overflow-scrolling:touch}.wp-core-ui .attachment{position:relative;float:right;padding:8px;margin:0;color:#444;cursor:pointer;list-style:none;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:25%;box-sizing:border-box}.wp-core-ui .attachment.details:focus,.wp-core-ui .attachment:focus,.wp-core-ui .selected.attachment:focus{box-shadow:inset 0 0 2px 3px #fff,inset 0 0 0 7px #5b9dd9;outline:0}.wp-core-ui .selected.attachment{box-shadow:inset 0 0 0 5px #fff,inset 0 0 0 7px #ccc}.wp-core-ui .attachment.details{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #0073aa}.wp-core-ui .attachment-preview{position:relative;box-shadow:inset 0 0 15px rgba(0,0,0,.1),inset 0 0 0 1px rgba(0,0,0,.05);background:#eee;cursor:pointer}.wp-core-ui .attachment-preview:before{content:"";display:block;padding-top:100%}.wp-core-ui .attachment .icon{margin:0 auto;overflow:hidden}.wp-core-ui .attachment .thumbnail{overflow:hidden;position:absolute;top:0;left:0;bottom:0;right:0;opacity:1;transition:opacity .1s}.wp-core-ui .attachment .landscape img{max-height:100%}.wp-core-ui .attachment .thumbnail:after{content:"";display:block;position:absolute;top:0;right:0;left:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);overflow:hidden}.wp-core-ui .attachment .thumbnail img{top:0;right:0}.wp-core-ui .attachment .thumbnail .centered{position:absolute;top:0;right:0;width:100%;height:100%;-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%)}.wp-core-ui .attachment .thumbnail .centered img{-webkit-transform:translate(50%,-50%);transform:translate(50%,-50%)}.wp-core-ui .attachments-browser .attachment .thumbnail .centered img.icon{-webkit-transform:translate(50%,-70%);transform:translate(50%,-70%)}.ie8 .wp-core-ui .attachment img.icon{top:20%;position:relative}.wp-core-ui .attachment .filename{position:absolute;right:0;left:0;bottom:0;overflow:hidden;max-height:100%;word-wrap:break-word;text-align:center;font-weight:600;background:rgba(255,255,255,.8);box-shadow:inset 0 0 0 1px rgba(0,0,0,.15)}.wp-core-ui .attachment .filename div{padding:5px 10px}.wp-core-ui .attachment .thumbnail img{position:absolute}.wp-core-ui .attachment-close{display:block;position:absolute;top:5px;left:5px;height:22px;width:22px;padding:0;background-color:#fff;background-position:-96px 4px;border-radius:3px;box-shadow:0 0 0 1px rgba(0,0,0,.3);transition:none}.wp-core-ui .attachment-close:focus,.wp-core-ui .attachment-close:hover{background-position:-36px 4px}.wp-core-ui .attachment .check{display:none;height:24px;width:24px;padding:0;border:0;position:absolute;z-index:10;top:0;left:0;outline:0;background:#eee;cursor:pointer;box-shadow:0 0 0 1px #fff,0 0 0 2px rgba(0,0,0,.15)}.wp-core-ui .attachment .check .media-modal-icon{display:block;background-position:-1px 0;height:15px;width:15px;margin:5px}.wp-core-ui .attachment .check:hover .media-modal-icon{background-position:-40px 0}.wp-core-ui .attachment.selected .check{display:block}.wp-core-ui .attachment.details .check,.wp-core-ui .attachment.selected .check:focus,.wp-core-ui .media-frame.mode-grid .attachment.selected .check{background-color:#0073aa;box-shadow:0 0 0 1px #fff,0 0 0 2px #0073aa}.wp-core-ui .attachment.details .check .media-modal-icon,.wp-core-ui .media-frame.mode-grid .attachment.selected .check .media-modal-icon{background-position:-21px 0}.wp-core-ui .attachment.details .check:hover .media-modal-icon,.wp-core-ui .attachment.selected .check:focus .media-modal-icon,.wp-core-ui .media-frame.mode-grid .attachment.selected .check:hover .media-modal-icon{background-position:-60px 0}.wp-core-ui .media-frame .attachment .describe{position:relative;display:block;width:100%;margin:0;padding:8px;font-size:12px;border-radius:0}.media-frame .attachments-browser{position:relative;width:100%;height:100%;overflow:hidden}.attachments-browser .media-toolbar{left:300px;height:50px}.attachments-browser.hide-sidebar .media-toolbar{left:0}.attachments-browser .media-toolbar-primary>.media-button,.attachments-browser .media-toolbar-primary>.media-button-group,.attachments-browser .media-toolbar-secondary>.media-button,.attachments-browser .media-toolbar-secondary>.media-button-group{margin:11px 0}.attachments-browser .attachments{padding:2px 8px 8px}.attachments-browser .attachments,.attachments-browser .uploader-inline{position:absolute;top:50px;right:0;left:300px;bottom:0;overflow:auto;outline:0}.attachments-browser .uploader-inline.hidden{display:none}.attachments-browser .media-toolbar-primary{max-width:33%}.attachments-browser .media-toolbar-secondary{max-width:66%}.uploader-inline .close{background-color:transparent;border:0;cursor:pointer;height:48px;outline:0;padding:0;position:absolute;left:2px;text-align:center;top:2px;width:48px;z-index:1}.uploader-inline .close:before{font:400 30px/1 dashicons!important;color:#555d66;display:inline-block;content:"\f335";font-weight:300;margin-top:1px}.uploader-inline .close:focus{outline:#5b9dd9 solid 1px;box-shadow:0 0 3px rgba(0,115,170,.8)}.attachments-browser.hide-sidebar .attachments,.attachments-browser.hide-sidebar .uploader-inline{left:0;margin-left:0}.attachments-browser .instructions{display:inline-block;margin-top:16px;line-height:18px;font-size:13px;color:#666;margin-left:.5em}.attachments-browser .no-media{padding:2em 2em 0 0}.media-progress-bar{position:relative;height:10px;width:70%;margin:10px auto;border-radius:10px;background:#ddd;background:rgba(0,0,0,.1)}.media-progress-bar div{height:10px;min-width:20px;width:0;background:#0073aa;border-radius:10px;transition:width .3s}.media-uploader-status .media-progress-bar{display:none;width:100%}.uploading.media-uploader-status .media-progress-bar{display:block}.attachment-preview .media-progress-bar{position:absolute;top:50%;right:15%;width:70%;margin:-5px 0 0}.media-uploader-status{position:relative;margin:0 auto;padding-bottom:10px;max-width:400px}.uploader-inline .media-uploader-status h2,.uploader-inline .media-uploader-status h3{display:none}.media-uploader-status .upload-details{display:none;font-size:12px;color:#666}.uploading.media-uploader-status .upload-details{display:block}.media-uploader-status .upload-detail-separator{padding:0 4px}.media-uploader-status .upload-count{color:#444}.media-uploader-status .upload-dismiss-errors,.media-uploader-status .upload-errors{display:none}.errors.media-uploader-status .upload-dismiss-errors,.errors.media-uploader-status .upload-errors{display:block}.media-uploader-status .upload-dismiss-errors{text-decoration:none}.media-sidebar .media-uploader-status .upload-dismiss-errors{position:absolute;top:-10px;left:-10px;padding:10px;transition:none}.media-sidebar .media-uploader-status .upload-dismiss-errors:before{content:"\f153";display:block;font:400 16px/1 dashicons;color:#72777c}.media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before,.media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before{color:#c00}.upload-errors .upload-error{padding:12px;margin-bottom:12px;background:#fff;border-right:4px solid #dc3232;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.uploader-inline .upload-errors .upload-error{background-color:#fbeaea;box-shadow:none}.upload-errors .upload-error-filename{font-weight:600}.upload-errors .upload-error-message{display:block;padding-top:8px;word-wrap:break-word}.uploader-window{position:fixed;top:0;right:0;left:0;bottom:0;background:rgba(0,86,132,.9);z-index:250000;display:none;text-align:center;opacity:0;transition:opacity 250ms}.uploader-window-content{position:absolute;top:10px;right:10px;left:10px;bottom:10px;border:1px dashed #fff}.uploader-window h1,.uploader-window h3{margin:-.5em 0 0;position:absolute;top:50%;right:0;left:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:40px;color:#fff;padding:0}.uploader-window .media-progress-bar{margin-top:20px;max-width:300px;background:0 0;border-color:#fff;display:none}.uploader-window .media-progress-bar div{background:#fff}.uploading .uploader-window .media-progress-bar{display:block}.media-frame .uploader-inline{margin-bottom:20px;padding:0;text-align:center}.uploader-inline-content{position:absolute;top:30%;right:0;left:0}.uploader-inline-content .upload-ui{margin:2em 0}.uploader-inline-content .post-upload-ui{margin-bottom:2em}.uploader-inline .has-upload-message .upload-ui{margin:0 0 4em}.uploader-inline h2,.uploader-inline h3{font-size:20px;line-height:28px;font-weight:400;margin:0}.uploader-inline .has-upload-message .upload-instructions{font-size:14px;color:#444;font-weight:400}.uploader-inline .drop-instructions{display:none}.supports-drag-drop .uploader-inline .drop-instructions{display:block}.uploader-inline p{font-size:12px;margin:.5em 0}.uploader-inline .media-progress-bar{display:none}.uploading.uploader-inline .media-progress-bar{display:block}.uploader-inline .browser{display:inline-block!important}.media-selection{position:absolute;top:0;right:0;left:350px;height:60px;padding:0 16px 0 0;overflow:hidden;white-space:nowrap}.media-selection .selection-info{display:inline-block;font-size:12px;height:60px;margin-left:10px;vertical-align:top}.media-selection.editing,.media-selection.empty,.media-selection.one .edit-selection{display:none}.media-selection .count{display:block;padding-top:12px;font-size:14px;line-height:20px;font-weight:600}.media-selection .attachments,.media-selection .selection-view{display:inline-block;vertical-align:top}.media-selection .button-link{float:right;padding:1px 8px;margin:1px -8px 1px 8px;line-height:16px;border-left:1px solid #ddd;color:#0073aa;text-decoration:none}.media-selection .button-link:focus,.media-selection .button-link:hover{color:#00a0d2}.media-selection .button-link:last-child{border-left:0;margin-left:0}.selection-info .clear-selection{color:#bc0b0b}.selection-info .clear-selection:focus,.selection-info .clear-selection:hover{color:#dc3232}.media-selection .attachments{height:48px;margin:6px;padding:0;overflow:hidden}.media-selection .attachment{width:40px;padding:0;margin:4px}.media-selection .attachment .thumbnail{top:0;left:0;bottom:0;right:0}.media-selection .attachment .icon{width:50%}.media-selection .attachment-preview{box-shadow:none;background:0 0}.wp-core-ui .media-selection .attachment.details:focus,.wp-core-ui .media-selection .attachment:focus,.wp-core-ui .media-selection .selected.attachment:focus{box-shadow:0 0 0 1px #fff,0 0 2px 3px #5b9dd9}.wp-core-ui .media-selection .selected.attachment{box-shadow:none}.wp-core-ui .media-selection .attachment.details{box-shadow:0 0 0 1px #fff,0 0 0 3px #0073aa}.media-selection:after{content:"";display:block;position:absolute;top:0;left:0;bottom:0;width:25px;background-image:linear-gradient(to right,rgba(255,255,255,1),rgba(255,255,255,0))}.media-selection .attachment .filename{display:none}.media-frame .spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;float:left;display:inline-block;visibility:hidden;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:0;vertical-align:middle}.attachment-details.save-waiting .settings-save-status .spinner,.media-frame .embed-loading .embed-url .spinner,.media-frame .spinner.is-active{visibility:visible}.media-toolbar .spinner{margin-top:14px}.attachment-details{position:relative;overflow:auto}.attachment-details .settings-save-status{float:left;text-transform:none;z-index:10}.attachment-details .settings-save-status .spinner{margin-right:5px}.attachment-details .settings-save-status .saved{float:left;display:none}.attachment-details.save-complete .settings-save-status .saved{display:block}.attachment-info{overflow:hidden;min-height:60px;margin-bottom:16px;line-height:18px;color:#666;border-bottom:1px solid #ddd;padding-bottom:11px}.attachment-info .filename{font-weight:600;color:#444;word-wrap:break-word}.attachment-info .thumbnail{position:relative;float:right;max-width:120px;max-height:120px;margin-top:5px;margin-left:10px;margin-bottom:5px}.uploading .attachment-info .thumbnail{width:120px;height:80px;box-shadow:inset 0 0 15px rgba(0,0,0,.1)}.uploading .attachment-info .media-progress-bar{margin-top:35px}.attachment-info .thumbnail-image:after{content:"";display:block;position:absolute;top:0;right:0;left:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);overflow:hidden}.attachment-info .thumbnail img{display:block;max-width:120px;max-height:120px;margin:0 auto}.attachment-info .details{float:right;font-size:12px;max-width:100%}.attachment-info .delete-attachment,.attachment-info .edit-attachment,.attachment-info .trash-attachment,.attachment-info .untrash-attachment{display:block;text-decoration:none;white-space:nowrap}.attachment-details.needs-refresh .attachment-info .edit-attachment{display:none}.attachment-info .edit-attachment{display:block}.media-modal .delete-attachment,.media-modal .trash-attachment,.media-modal .untrash-attachment{display:inline;padding:0;color:#bc0b0b}.media-modal .delete-attachment:focus,.media-modal .delete-attachment:hover,.media-modal .trash-attachment:focus,.media-modal .trash-attachment:hover,.media-modal .untrash-attachment:focus,.media-modal .untrash-attachment:hover{color:#dc3232}.attachment-display-settings{width:100%;float:right;overflow:hidden}.attachment-display-settings h4{margin:1.4em 0 .4em}.collection-settings{overflow:hidden}.collection-settings .setting input[type=checkbox]{float:right;margin-left:8px}.collection-settings .setting span{min-width:inherit}.media-modal .imgedit-wrap{position:static}.media-modal .imgedit-wrap .imgedit-panel-content{padding:16px;position:absolute;top:0;left:282px;bottom:0;right:0;overflow:auto}.media-modal .imgedit-wrap .imgedit-settings{background:#f3f3f3;border-right:1px solid #ddd;padding:20px 16px 16px;position:absolute;top:0;left:0;bottom:0;width:250px;overflow:auto}.media-modal .imgedit-group{background:0 0;border:none;border-bottom:1px solid #ddd;box-shadow:none;margin:0 0 16px;padding:0 0 16px;position:relative}.media-modal .imgedit-group:last-of-type{border:none;margin:0;padding:0}.media-modal .imgedit-group-top{margin:0}.media-modal .imgedit-group-top h2,.media-modal .imgedit-group-top h2 .button-link,.media-modal .imgedit-group-top h3{display:inline-block;text-transform:uppercase;font-size:12px;color:#666;margin:3px 0 0}.embed-url,.imgedit-thumbnail-preview-caption{display:block}.media-modal .imgedit-group-top h2 .button-link,.media-modal .imgedit-group-top h2 a,.media-modal .imgedit-group-top h3 a{text-decoration:none;color:#666}.wp-core-ui.media-modal .image-editor .imgedit-help-toggle,.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:active,.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:hover{border:1px solid transparent;margin:0;padding:0;background:0 0;color:#0074a2;font-size:20px;line-height:1;cursor:pointer;box-sizing:content-box;box-shadow:none}.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:focus{color:#0074a2;border-color:#5b9dd9;outline:0;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-core-ui.media-modal .imgedit-group-top .dashicons-arrow-down.imgedit-help-toggle{margin-top:-3px}.wp-core-ui.media-modal .image-editor h3 .imgedit-help-toggle{margin-top:-2px}.media-modal .imgedit-help-toggled span.dashicons:before{content:"\f142"}.media-modal .imgedit-thumbnail-preview{margin:10px 0 0 8px}.media-modal .imgedit-wrap div.updated{margin:0 0 16px}.embed-url{position:relative;padding:16px;margin:0;z-index:250;background:#fff;font-size:18px}.media-frame .embed-url input{font-size:18px;padding:12px 14px;width:100%;min-width:200px;box-shadow:inset -2px 2px 4px -2px rgba(0,0,0,.1)}.media-frame .embed-url .spinner{position:absolute;top:32px;left:26px}.embed-link-settings,.embed-media-settings{position:absolute;top:70px;right:0;left:0;bottom:0;padding:16px 16px 32px;overflow:auto}.media-embed .embed-link-settings{overflow:visible}.embed-preview embed,.embed-preview iframe,.embed-preview img,.mejs-container video{max-width:100%;vertical-align:middle}.embed-preview a{display:inline-block}.embed-preview img{display:block;height:auto}.mejs-container:focus{outline:#5b9dd9 solid 1px;box-shadow:0 0 2px 1px rgba(30,140,190,.8)}.image-details .media-modal{right:140px;left:140px}.image-details .media-frame-content,.image-details .media-frame-router,.image-details .media-frame-title{right:0}.image-details .embed-media-settings{top:0;overflow:visible;padding:0}.image-details .embed-media-settings,.image-details .embed-media-settings div{box-sizing:border-box}.image-details .column-settings{background:#f3f3f3;border-left:1px solid #ddd;min-height:100%;width:55%;position:absolute;top:0;right:0}.image-details .column-settings h2,.image-details .column-settings h3{margin:20px;padding-top:20px;border-top:1px solid #ddd;color:#23282d}.image-details .column-image{width:45%;position:absolute;right:55%;top:0}.image-details .image{margin:20px}.image-details .image img{max-width:100%;max-height:500px}.image-details .advanced-toggle{padding:0;color:#666;text-transform:uppercase;text-decoration:none}.image-details .advanced-toggle:active,.image-details .advanced-toggle:hover{color:#666}.image-details .advanced-toggle:after{font:400 20px/1 dashicons;speak:none;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f140";display:inline-block;margin-top:-2px}.image-details .advanced-visible .advanced-toggle:after{content:"\f142"}.image-details .embed-media-settings .size{margin-bottom:4px}.image-details .custom-size span{display:block}.image-details .custom-size label{display:block;float:right}.image-details .custom-size span small{color:#555d66;font-size:inherit}.image-details .custom-size input{width:5em}.image-details .custom-size .sep{float:right;margin:26px 6px 0}.image-details .custom-size:after{content:"";display:table;clear:both}.media-embed .thumbnail{max-width:100%;max-height:200px;position:relative;float:right}.media-embed .thumbnail img{max-height:200px;display:block}.media-embed .thumbnail:after{content:"";display:block;position:absolute;top:0;right:0;left:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);overflow:hidden}.media-embed .setting{width:100%;margin:10px 0;float:right;display:block;clear:both}.image-details .embed-media-settings .setting{float:none;width:auto}.image-details .actions{margin:10px 0}.image-details .hidden{display:none}.media-embed .setting input[type=text],.media-embed .setting textarea{display:block;width:100%;max-width:400px;margin:1px 0}.image-details .embed-media-settings .setting input[type=text],.image-details .embed-media-settings .setting textarea{max-width:inherit;width:70%}.image-details .embed-media-settings .custom-size,.image-details .embed-media-settings .link-target,.image-details .embed-media-settings .setting input.link-to-custom{margin-right:27%;width:70%}.image-details .embed-media-settings .link-target{margin-top:24px}.media-embed .setting input.hidden,.media-embed .setting textarea.hidden{display:none}.media-embed .setting span{display:block;width:200px;font-size:13px;line-height:24px;color:#666}.image-details .embed-media-settings .setting span{float:right;width:25%;text-align:left;margin:8px 1% 0;line-height:1.1}.media-embed .setting .button-group{margin:2px 0}.media-embed-sidebar{position:absolute;top:0;right:440px}.advanced-section,.link-settings{margin-top:10px}.wp-editor-wrap .uploader-editor{background:rgba(150,150,150,.9);position:absolute;top:0;right:0;width:100%;height:100%;z-index:99998;display:none;text-align:center}.wp-editor-wrap .uploader-editor-content{border:1px dashed #fff;position:absolute;top:10px;right:10px;left:10px;bottom:10px}.wp-editor-wrap .uploader-editor .uploader-editor-title{position:absolute;top:50%;right:0;left:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:3em;line-height:1.3;font-weight:600;color:#fff;padding:0;margin:0;display:none}.wp-editor-wrap .uploader-editor.droppable{background:rgba(0,86,132,.9)}.wp-editor-wrap .uploader-editor.droppable .uploader-editor-title{display:block}.ie7 .media-frame .attachments-browser{position:static}.ie7 .media-frame .embed-url input{margin-top:4px;width:90%}.ie7 .compat-item{width:99%}.ie7 .attachment-display-settings{width:auto}.ie7 .attachment-preview,.ie7 .attachment-preview .thumbnail{width:120px;height:120px}.ie7 .media-frame .attachment .describe{width:102px}.ie7 .media-sidebar .setting select{max-width:55%}.ie7 .media-sidebar .setting input[type=tel],.ie7 .media-sidebar .setting input[type=text],.ie7 .media-sidebar .setting input[type=password],.ie7 .media-sidebar .setting input[type=number],.ie7 .media-sidebar .setting input[type=search],.ie7 .media-sidebar .setting input[type=email],.ie7 .media-sidebar .setting input[type=url],.ie7 .media-sidebar .setting textarea{width:55%}.ie7 .media-sidebar .setting .link-to-custom{float:right}.rtl .media-frame,.rtl .media-frame .search,.rtl .media-frame input[type=tel],.rtl .media-frame input[type=text],.rtl .media-frame input[type=password],.rtl .media-frame input[type=number],.rtl .media-frame input[type=search],.rtl .media-frame input[type=email],.rtl .media-frame input[type=url],.rtl .media-frame select,.rtl .media-frame textarea,.rtl .media-modal{font-family:Tahoma,sans-serif}:lang(he-il) .rtl .media-frame,:lang(he-il) .rtl .media-frame .search,:lang(he-il) .rtl .media-frame input[type=text],:lang(he-il) .rtl .media-frame input[type=password],:lang(he-il) .rtl .media-frame input[type=number],:lang(he-il) .rtl .media-frame input[type=search],:lang(he-il) .rtl .media-frame input[type=email],:lang(he-il) .rtl .media-frame input[type=url],:lang(he-il) .rtl .media-frame select,:lang(he-il) .rtl .media-frame textarea,:lang(he-il) .rtl .media-modal{font-family:Arial,sans-serif}@media only screen and (max-width:900px){.media-frame:not(.hide-menu) .media-frame-content,.media-frame:not(.hide-menu) .media-frame-router,.media-frame:not(.hide-menu) .media-frame-title,.media-frame:not(.hide-menu) .media-frame-toolbar{right:0}.media-frame:not(.hide-menu) .media-frame-menu{position:static;width:0}.media-frame:not(.hide-menu) .media-menu{width:auto;max-width:80%;overflow:auto;z-index:2000;top:50px;right:-300px;left:auto;bottom:auto;padding:5px 0;border:1px solid #ccc}.media-frame:not(.hide-menu) .media-menu.visible{right:0}.media-frame:not(.hide-menu) .media-menu>a{padding:12px 16px;font-size:16px}.media-frame:not(.hide-menu) .media-menu>a.active{display:none}.media-frame:not(.hide-menu) .media-menu .separator{margin:5px 10px}.media-frame:not(.hide-menu) .media-frame-title{right:0}.media-frame:not(.hide-menu) .media-frame-title .dashicons{display:inline-block;line-height:50px}.media-frame:not(.hide-menu) .media-frame-title h1{color:#0073aa;line-height:3;font-size:18px;float:right;cursor:pointer}.media-sidebar{width:230px}.attachments-browser .attachments,.attachments-browser .media-toolbar,.attachments-browser .uploader-inline{left:262px}.attachment-details .setting,.media-sidebar .setting{margin:6px 0}.attachment-details .setting input,.attachment-details .setting span,.attachment-details .setting textarea,.compat-item label span,.media-sidebar .setting input,.media-sidebar .setting span,.media-sidebar .setting textarea{float:none}.attachment-details .setting span,.compat-item label span,.media-sidebar .setting span{text-align:inherit;min-height:16px;margin:0;padding:8px 2px 0}.attachment-details .setting .value,.media-sidebar .setting .value{float:none;width:auto}.attachment-details .setting input[type=tel],.attachment-details .setting input[type=text],.attachment-details .setting input[type=password],.attachment-details .setting input[type=number],.attachment-details .setting input[type=search],.attachment-details .setting input[type=email],.attachment-details .setting input[type=url],.attachment-details .setting select,.attachment-details .setting textarea,.media-sidebar .setting input[type=tel],.media-sidebar .setting input[type=text],.media-sidebar .setting input[type=password],.media-sidebar .setting input[type=number],.media-sidebar .setting input[type=search],.media-sidebar .setting input[type=email],.media-sidebar .setting input[type=url],.media-sidebar .setting select,.media-sidebar .setting textarea{float:none;width:98%;max-width:none;height:auto}.attachment-details .setting select.columns,.media-sidebar .setting select.columns{width:auto}.media-frame .search,.media-frame input,.media-frame textarea{padding:3px 6px}.image-details .column-image{width:30%;right:70%}.image-details .column-settings{width:70%}.image-details .media-modal{right:30px;left:30px}.image-details .embed-media-settings .setting{margin:20px}.image-details .embed-media-settings .setting span{float:none;text-align:right;width:100%;margin-bottom:4px}.image-details .embed-media-settings .setting input.link-to-custom,.image-details .embed-media-settings .setting input[type=text],.image-details .embed-media-settings .setting textarea{width:100%;margin-right:0}.image-details .embed-media-settings .custom-size{margin-right:20px}.collection-settings .setting input[type=checkbox]{margin-top:0}.media-selection{min-width:120px}.media-selection:after{background:0 0}.media-selection .attachments{display:none}.media-modal .attachments-browser .media-toolbar .search{max-width:100%;height:auto;float:left}.media-modal .attachments-browser .media-toolbar .attachment-filters{height:auto}.media-modal .attachments-browser .media-toolbar .spinner{margin:14px 2px 0}.media-frame input[type=text],.media-frame input[type=password],.media-frame input[type=number],.media-frame input[type=search],.media-frame input[type=email],.media-frame input[type=url],.media-frame select,.media-frame textarea{font-size:16px}}@media only screen and (max-width:640px),screen and (max-height:400px){.image-details .media-modal,.media-modal{position:fixed;top:0;right:0;left:0;bottom:0}.media-modal-backdrop{position:fixed}.media-sidebar{z-index:1900;max-width:70%;bottom:120%;box-sizing:border-box;padding-bottom:0}.media-sidebar.visible{bottom:0}.attachments-browser .attachments,.attachments-browser .media-toolbar,.attachments-browser .uploader-inline{left:0}.image-details .media-frame-title{display:block;top:0;font-size:14px}.image-details .column-image,.image-details .column-settings{width:100%;position:relative;right:0}.image-details .column-settings{padding:4px 0}.media-frame-content .media-toolbar .instructions{display:none}}@media screen and (max-height:400px){.media-menu{padding:0}.media-frame-router{top:44px}.media-frame-content{top:78px}.attachments-browser .attachments{top:40px}.embed-link-settings{overflow:visible}}@media only screen and (max-width:480px){.media-modal-close{top:-5px}.media-modal .media-frame-title{height:40px}.wp-core-ui.wp-customizer .media-button{margin-top:13px}.media-frame:not(.hide-menu) .media-frame-title h1,.media-modal .media-frame-title h1{font-size:18px;line-height:40px}.media-frame:not(.hide-menu) .media-frame-title .dashicons{line-height:40px}.media-frame-router,.media-frame:not(.hide-menu) .media-menu{top:40px}.media-frame-content{top:74px}.media-frame.hide-router .media-frame-content{top:40px}}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-core-ui .media-modal-icon{background-image:url(../images/uploader-icons-2x.png);background-size:134px 15px}.media-frame .spinner{background-image:url(../images/spinner-2x.gif)}}.media-frame-content[data-columns="1"] .attachment{width:100%}.media-frame-content[data-columns="2"] .attachment{width:50%}.media-frame-content[data-columns="3"] .attachment{width:33.33%}.media-frame-content[data-columns="4"] .attachment{width:25%}.media-frame-content[data-columns="5"] .attachment{width:20%}.media-frame-content[data-columns="6"] .attachment{width:16.66%}.media-frame-content[data-columns="7"] .attachment{width:14.28%}.media-frame-content[data-columns="8"] .attachment{width:12.5%}.media-frame-content[data-columns="9"] .attachment{width:11.11%}.media-frame-content[data-columns="10"] .attachment{width:10%}.media-frame-content[data-columns="11"] .attachment{width:9.09%}.media-frame-content[data-columns="12"] .attachment{width:8.33%} \ No newline at end of file diff --git a/backend/wp-includes/css/media-views.css b/backend/wp-includes/css/media-views.css new file mode 100644 index 0000000..d86c2bd --- /dev/null +++ b/backend/wp-includes/css/media-views.css @@ -0,0 +1,2633 @@ +/** + * Base Styles + */ +.media-modal * { + box-sizing: content-box; +} + +.media-modal input, +.media-modal select, +.media-modal textarea { + box-sizing: border-box; +} + +.media-modal, +.media-frame { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 12px; + -webkit-overflow-scrolling: touch; +} + +.media-modal legend, +.media-modal label { + font-size: 13px; +} + +.media-frame input, +.media-frame textarea { + padding: 6px 8px; +} + +.media-frame select, +.wp-admin .media-frame select { + line-height: 28px; + margin-top: 3px; +} + +.media-frame a { + border-bottom: none; + color: #0073aa; +} + +.media-frame a:hover, +.media-frame a:active { + color: #00a0d2; +} + +.media-frame a:focus { + box-shadow: + 0 0 0 1px #5b9dd9, + 0 0 2px 1px rgba(30, 140, 190, .8); + outline: none; + color: #124964; +} + +.media-frame a.button { + color: #32373c; +} + +.media-frame a.button:hover { + color: #23282d; +} + +.media-frame a.button-primary, +.media-frame a.button-primary:hover { + color: #fff; +} + +.media-frame input[type="text"], +.media-frame input[type="password"], +.media-frame input[type="number"], +.media-frame input[type="search"], +.media-frame input[type="email"], +.media-frame input[type="url"], +.media-frame textarea, +.media-frame select { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + font-size: 12px; + border-width: 1px; + border-style: solid; + border-color: #ddd; +} + +.media-frame input[type="text"]:focus, +.media-frame input[type="password"]:focus, +.media-frame input[type="number"]:focus, +.media-frame input[type="search"]:focus, +.media-frame input[type="email"]:focus, +.media-frame input[type="url"]:focus, +.media-frame textarea:focus, +.media-frame select:focus { + border-color: #5b9dd9; +} + +.media-frame select { + height: 24px; + padding: 2px; +} + +.media-frame input:disabled, +.media-frame textarea:disabled, +.media-frame input[readonly], +.media-frame textarea[readonly] { + background-color: #eee; +} + +.media-frame input[type="search"] { + -webkit-appearance: textfield; +} + +.media-frame ::-webkit-input-placeholder { + color: #72777c; +} + +.media-frame ::-moz-placeholder { + color: #72777c; + opacity: 1; +} + +.media-frame :-ms-input-placeholder { + color: #72777c; +} + +.media-frame .hidden { + display: none; +} + +/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ +.ui-draggable-handle, +.ui-sortable-handle { + touch-action: none; +} + +/** + * Modal + */ +.media-modal { + position: fixed; + top: 30px; + left: 30px; + right: 30px; + bottom: 30px; + z-index: 160000; +} + +.wp-customizer .media-modal { + z-index: 560000; +} + +.media-modal-backdrop { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 360px; + background: #000; + opacity: 0.7; + z-index: 159900; +} + +.wp-customizer .media-modal-backdrop { + z-index: 559900; +} + +.media-modal-close { + position: absolute; + top: 0; + right: 0; + width: 50px; + height: 50px; + margin: 0; + padding: 0; + border: 1px solid transparent; + background: none; + color: #666; + z-index: 1000; + cursor: pointer; + outline: none; + transition: color .1s ease-in-out, background .1s ease-in-out; +} + +.media-modal-close:hover, +.media-modal-close:active { + color: #00a0d2; +} + +.media-modal-close:focus { + color: #00a0d2; + border-color: #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.media-modal-close span.media-modal-icon { + background-image: none; +} + +.media-modal-close .media-modal-icon:before { + content: "\f158"; + font: normal 20px/1 dashicons; + speak: none; + vertical-align: middle; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.media-modal-content { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: auto; + min-height: 300px; + box-shadow: 0 5px 15px rgba(0,0,0,0.7); + background: #fcfcfc; + -webkit-font-smoothing: subpixel-antialiased; +} + +.media-modal-content .media-frame select.attachment-filters { + margin-top: 11px; + margin-right: 2%; + width: 42%; + width: calc(48% - 12px); +} + +.media-modal-content .media-toolbar-primary .media-button { + float: right; +} + +.media-modal-content .attachments-browser .search { + width: 100%; +} + +/* higher specificity */ +.wp-core-ui .media-modal-icon { + background-image: url(../images/uploader-icons.png); + background-repeat: no-repeat; +} + +/** + * Toolbar + */ +.media-toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + z-index: 100; + height: 60px; + padding: 0 16px; + border: 0 solid #ddd; + overflow: hidden; +} + +.media-frame-toolbar .media-toolbar { + top: initial; + bottom: -45px; + height: auto; + overflow: initial; + border-top: 1px solid #ddd; +} + +@media screen and (max-width: 782px) { + .media-frame-toolbar .media-toolbar { + bottom: -48px; + } +} + +.media-toolbar-primary { + float: right; + height: 100%; +} + +.media-toolbar-secondary { + float: left; + height: 100%; +} + +.media-toolbar-primary > .media-button, +.media-toolbar-primary > .media-button-group { + margin-left: 10px; + float: left; + margin-top: 15px; +} + +.media-toolbar-secondary > .media-button, +.media-toolbar-secondary > .media-button-group { + margin-right: 10px; + margin-top: 15px; +} + +/** + * Sidebar + */ +.media-sidebar { + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 267px; + padding: 0 16px 24px; + z-index: 75; + background: #f3f3f3; + border-left: 1px solid #ddd; + overflow: auto; + -webkit-overflow-scrolling: touch; +} + +.hide-toolbar .media-sidebar { + bottom: 0; +} + +.media-sidebar .sidebar-title { + font-size: 20px; + margin: 0; + padding: 12px 10px 10px; + line-height: 28px; +} + +.media-sidebar .sidebar-content { + padding: 0 10px; + margin-bottom: 130px; +} + +.media-sidebar .search { + display: block; + width: 100%; +} + +.media-sidebar h3, /* Back-compat for pre-4.4 */ +.image-details h3, /* Back-compat for pre-4.4 */ +.media-sidebar h2, +.image-details h2 { + position: relative; + font-weight: 600; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 24px 0 8px; +} + +.media-sidebar .setting, +.attachment-details .setting { + display: block; + float: left; + width: 100%; + margin: 1px 0; +} + +.media-sidebar .setting label, +.attachment-details .setting label { + display: block; +} + +.media-sidebar .setting .link-to-custom, +.attachment-details .setting .link-to-custom { + margin: 3px 2px 0; +} + +.media-sidebar .setting span, +.attachment-details .setting span { + min-width: 30%; + margin-right: 4%; + font-size: 12px; + text-align: right; + word-wrap: break-word; +} + +.media-sidebar .setting .name { + max-width: 80px; +} + +.media-sidebar .setting select, +.attachment-details .setting select { + max-width: 65%; +} + +.media-sidebar .setting input[type="checkbox"], +.media-sidebar .field input[type="checkbox"], +.media-sidebar .setting input[type="radio"], +.media-sidebar .field input[type="radio"], +.attachment-details .setting input[type="checkbox"], +.attachment-details .field input[type="checkbox"], +.attachment-details .setting input[type="radio"], +.attachment-details .field input[type="radio"] { + float: none; + margin: 8px 3px 0; + padding: 0; +} + +.media-sidebar .setting span, +.attachment-details .setting span, +.compat-item label span { + float: left; + min-height: 22px; + padding-top: 8px; + line-height: 16px; + font-weight: 400; + color: #666; +} + +.compat-item label span { + text-align: right; +} + +.media-sidebar .setting input[type="text"], +.media-sidebar .setting input[type="password"], +.media-sidebar .setting input[type="email"], +.media-sidebar .setting input[type="number"], +.media-sidebar .setting input[type="search"], +.media-sidebar .setting input[type="tel"], +.media-sidebar .setting input[type="url"], +.media-sidebar .setting textarea, +.media-sidebar .setting .value, +.attachment-details .setting input[type="text"], +.attachment-details .setting input[type="password"], +.attachment-details .setting input[type="email"], +.attachment-details .setting input[type="number"], +.attachment-details .setting input[type="search"], +.attachment-details .setting input[type="tel"], +.attachment-details .setting input[type="url"], +.attachment-details .setting textarea, +.attachment-details .setting .value { + box-sizing: border-box; + margin: 1px; + width: 65%; + float: right; +} + +.media-sidebar .setting .value, +.attachment-details .setting .value { + margin: 0 1px; + text-align: left; +} + +.media-sidebar .setting textarea, +.attachment-details .setting textarea, +.compat-item .field textarea { + height: 62px; + resize: vertical; +} + +.media-sidebar select, +.attachment-details select { + margin-top: 3px; +} + +.compat-item { + float: left; + width: 100%; + overflow: hidden; +} + +.compat-item table { + width: 100%; + table-layout: fixed; + border-spacing: 0; + border: 0; +} + +.compat-item tr { + padding: 2px 0; + display: block; + overflow: hidden; +} + +.compat-item .label, +.compat-item .field { + display: block; + margin: 0; + padding: 0; +} + +.compat-item .label { + min-width: 30%; + margin-right: 4%; + float: left; + text-align: right; +} + +.compat-item .label span { + display: block; + width: 100%; +} + +.compat-item .field { + float: right; + width: 65%; + margin: 1px; +} + +.compat-item .field input[type="text"], +.compat-item .field input[type="password"], +.compat-item .field input[type="email"], +.compat-item .field input[type="number"], +.compat-item .field input[type="search"], +.compat-item .field input[type="tel"], +.compat-item .field input[type="url"], +.compat-item .field textarea { + width: 100%; + margin: 0; + box-sizing: border-box; +} + +.sidebar-for-errors .attachment-details, +.sidebar-for-errors .compat-item, +.sidebar-for-errors .media-sidebar .media-progress-bar, +.sidebar-for-errors .upload-details { + display: none !important; +} + +/** + * Menu + */ +.media-menu { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + margin: 0; + padding: 10px 0; + background: #f3f3f3; + border-right-width: 1px; + border-right-style: solid; + border-right-color: #ccc; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.media-menu > a { + display: block; + position: relative; + padding: 8px 20px; + margin: 0; + line-height: 18px; + font-size: 14px; + color: #0073aa; + text-decoration: none; +} + +.media-menu > a:hover { + color: #0073aa; + background: rgba( 0, 0, 0, 0.04 ); +} + +.media-menu > a:active { + outline: none; +} + +.media-menu .active, +.media-menu .active:hover { + color: #23282d; + font-weight: 600; +} + +.media-menu .separator { + height: 0; + margin: 12px 20px; + padding: 0; + border-top: 1px solid #ddd; +} + +/** + * Menu + */ +.media-router { + position: relative; + padding: 0 6px; + margin: 0; + clear: both; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.media-router a { + transition: none; +} + +.media-router > a { + position: relative; + float: left; + padding: 8px 10px 9px; + margin: 0; + height: 18px; + line-height: 18px; + font-size: 14px; + text-decoration: none; +} + +.media-router > a:last-child { + border-right: 0; +} + +.media-router > a:active { + outline: none; +} + +.media-router .active, +.media-router .active:hover { + color: #32373c; +} + +.media-router .active, +.media-router > a.active:last-child { + margin: -1px -1px 0; + background: #fff; + border: 1px solid #ddd; + border-bottom: none; +} + +.media-router .active:after { + display: none; +} + +/** + * Frame + */ +.media-frame { + overflow: hidden; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.media-frame-menu { + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 200px; + z-index: 150; +} + +.media-frame-title { + position: absolute; + top: 0; + left: 200px; + right: 0; + height: 50px; + z-index: 200; +} + +.media-frame-router { + position: absolute; + top: 50px; + left: 200px; + right: 0; + height: 36px; + z-index: 200; +} + +.media-frame-content { + position: absolute; + top: 84px; + left: 200px; + right: 0; + bottom: 61px; + height: auto; + width: auto; + margin: 0; + overflow: auto; + background: #fff; + border-top: 1px solid #ddd; +} + +.media-frame-toolbar { + position: absolute; + left: 200px; + right: 0; + bottom: 0; + height: 60px; + z-index: 100; + bottom: 60px; + height: auto; +} + +.media-frame.hide-menu .media-frame-title, +.media-frame.hide-menu .media-frame-router, +.media-frame.hide-menu .media-frame-toolbar, +.media-frame.hide-menu .media-frame-content { + left: 0; +} + +.media-frame.hide-toolbar .media-frame-content { + bottom: 0; +} + +.media-frame.hide-router .media-frame-content { + top: 50px; +} + +.media-frame.hide-menu .media-frame-menu, +.media-frame.hide-router .media-frame-router, +.media-frame.hide-toolbar .media-frame-toolbar { + display: none; +} + +.media-frame.hide-router .media-frame-title { + border-bottom: 1px solid #ddd; + box-shadow: 0 4px 4px -4px rgba( 0, 0, 0, 0.1 ); +} + +.media-frame-title .dashicons { + display: none; +} + +.media-frame-title h1 { + padding: 0 16px; + font-size: 22px; + line-height: 50px; + margin: 0; +} + +.media-frame-title .suggested-dimensions { + font-size: 14px; + float: right; + margin-right: 20px; +} + +.media-frame-content .crop-content { + height: 100%; +} + +.wp-customizer:not(.mobile) .media-frame-content .crop-content.site-icon { + margin-right: 300px; +} + +.media-frame-content .crop-content .crop-image { + display: block; + margin: auto; + max-width: 100%; + max-height: 100%; +} + +.media-frame-content .crop-content .upload-errors +{ + position: absolute; + width: 300px; + top: 50%; + left: 50%; + margin-left: -150px; + margin-right: -150px; + z-index: 600000; +} + +/** + * Iframes + */ +.media-frame .media-iframe { + overflow: hidden; +} + +.media-frame .media-iframe, +.media-frame .media-iframe iframe { + height: 100%; + width: 100%; + border: 0; +} + +/** + * Attachment Browser Filters + */ +.media-frame select.attachment-filters { + margin-top: 11px; + margin-right: 2%; + max-width: 42%; + max-width: calc(48% - 12px); +} + +.media-frame select.attachment-filters:last-of-type { + margin-right: 0; +} + +/** + * Search + */ +.media-frame .search { + margin-top: 11px; + padding: 4px; + font-size: 13px; + color: #444; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + -webkit-appearance: none; +} + +.media-toolbar-primary .search { + max-width: 100%; +} + +/** + * Attachments + */ +.wp-core-ui .attachments { + margin: 0; + -webkit-overflow-scrolling: touch; +} + +/** + * Attachment + */ +.wp-core-ui .attachment { + position: relative; + float: left; + padding: 8px; + margin: 0; + color: #444; + cursor: pointer; + list-style: none; + text-align: center; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + width: 25%; + box-sizing: border-box; +} + +.wp-core-ui .attachment:focus, +.wp-core-ui .selected.attachment:focus, +.wp-core-ui .attachment.details:focus { + box-shadow: + inset 0 0 2px 3px #fff, + inset 0 0 0 7px #5b9dd9; + outline: none; +} + +.wp-core-ui .selected.attachment { + box-shadow: + inset 0 0 0 5px #fff, + inset 0 0 0 7px #ccc; +} + +.wp-core-ui .attachment.details { + box-shadow: + inset 0 0 0 3px #fff, + inset 0 0 0 7px #0073aa; +} + +.wp-core-ui .attachment-preview { + position: relative; + box-shadow: + inset 0 0 15px rgba( 0, 0, 0, 0.1 ), + inset 0 0 0 1px rgba( 0, 0, 0, 0.05 ); + background: #eee; + cursor: pointer; +} + +.wp-core-ui .attachment-preview:before { + content: ""; + display: block; + padding-top: 100%; +} + +.wp-core-ui .attachment .icon { + margin: 0 auto; + overflow: hidden; +} + +.wp-core-ui .attachment .thumbnail { + overflow: hidden; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 1; + transition: opacity .1s; +} + +.wp-core-ui .attachment .portrait img { + max-width: 100%; +} + +.wp-core-ui .attachment .landscape img { + max-height: 100%; +} + +.wp-core-ui .attachment .thumbnail:after { + content: ""; + display: block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 ); + overflow: hidden; +} + +.wp-core-ui .attachment .thumbnail img { + top: 0; + left: 0; +} + +.wp-core-ui .attachment .thumbnail .centered { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + -webkit-transform: translate( 50%, 50% ); /* Fails with spaces?? Weird! */ + transform: translate( 50%, 50% ); +} + +.wp-core-ui .attachment .thumbnail .centered img { + -webkit-transform: translate( -50%, -50% ); + transform: translate( -50%, -50% ); +} + +.wp-core-ui .attachments-browser .attachment .thumbnail .centered img.icon { + -webkit-transform: translate( -50%, -70% ); + transform: translate( -50%, -70% ); +} + +.ie8 .wp-core-ui .attachment img.icon { + top: 20%; + position: relative; +} + +.wp-core-ui .attachment .filename { + position: absolute; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + max-height: 100%; + word-wrap: break-word; + text-align: center; + font-weight: 600; + background: rgba( 255, 255, 255, 0.8 ); + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 ); +} + +.wp-core-ui .attachment .filename div { + padding: 5px 10px; +} + +.wp-core-ui .attachment .thumbnail img { + position: absolute; +} + +.wp-core-ui .attachment-close { + display: block; + position: absolute; + top: 5px; + right: 5px; + height: 22px; + width: 22px; + padding: 0; + background-color: #fff; + background-position: -96px 4px; + border-radius: 3px; + box-shadow: 0 0 0 1px rgba( 0, 0, 0, 0.3 ); + transition: none; +} + +.wp-core-ui .attachment-close:hover, +.wp-core-ui .attachment-close:focus { + background-position: -36px 4px; +} + +.wp-core-ui .attachment .check { + display: none; + height: 24px; + width: 24px; + padding: 0; + border: 0; + position: absolute; + z-index: 10; + top: 0; + right: 0; + outline: none; + background: #eee; + cursor: pointer; + box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 ); +} + +.wp-core-ui .attachment .check .media-modal-icon { + display: block; + background-position: -1px 0; + height: 15px; + width: 15px; + margin: 5px; +} + +.wp-core-ui .attachment .check:hover .media-modal-icon { + background-position: -40px 0; +} + +.wp-core-ui .attachment.selected .check { + display: block; +} + +.wp-core-ui .attachment.details .check, +.wp-core-ui .attachment.selected .check:focus, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check { + background-color: #0073aa; + box-shadow: + 0 0 0 1px #fff, + 0 0 0 2px #0073aa; +} + +.wp-core-ui .attachment.details .check .media-modal-icon, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check .media-modal-icon { + background-position: -21px 0; +} + +.wp-core-ui .attachment.details .check:hover .media-modal-icon, +.wp-core-ui .attachment.selected .check:focus .media-modal-icon, +.wp-core-ui .media-frame.mode-grid .attachment.selected .check:hover .media-modal-icon { + background-position: -60px 0; +} + +.wp-core-ui .media-frame .attachment .describe { + position: relative; + display: block; + width: 100%; + margin: 0; + padding: 8px; + font-size: 12px; + border-radius: 0; +} + +/** + * Attachments Browser + */ +.media-frame .attachments-browser { + position: relative; + width: 100%; + height: 100%; + overflow: hidden; +} + +.attachments-browser .media-toolbar { + right: 300px; + height: 50px; +} + +.attachments-browser.hide-sidebar .media-toolbar { + right: 0; +} + +.attachments-browser .media-toolbar-primary > .media-button, +.attachments-browser .media-toolbar-primary > .media-button-group, +.attachments-browser .media-toolbar-secondary > .media-button, +.attachments-browser .media-toolbar-secondary > .media-button-group { + margin: 11px 0; +} + +.attachments-browser .attachments { + padding: 2px 8px 8px; +} + +.attachments-browser .attachments, +.attachments-browser .uploader-inline { + position: absolute; + top: 50px; + left: 0; + right: 300px; + bottom: 0; + overflow: auto; + outline: none; +} + +.attachments-browser .uploader-inline.hidden { + display: none; +} + +.attachments-browser .media-toolbar-primary { + max-width: 33%; +} + +.attachments-browser .media-toolbar-secondary { + max-width: 66%; +} + +.uploader-inline .close { + background-color: transparent; + border: 0; + cursor: pointer; + height: 48px; + outline: none; + padding: 0; + position: absolute; + right: 2px; + text-align: center; + top: 2px; + width: 48px; + z-index: 1; +} + +.uploader-inline .close:before { + font: normal 30px/1 dashicons !important; + color: #555d66; + display: inline-block; + content: "\f335"; + font-weight: 300; + margin-top: 1px; +} + +.uploader-inline .close:focus { + outline: 1px solid #5b9dd9; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.attachments-browser.hide-sidebar .attachments, +.attachments-browser.hide-sidebar .uploader-inline { + right: 0; + margin-right: 0; +} + +.attachments-browser .instructions { + display: inline-block; + margin-top: 16px; + line-height: 18px; + font-size: 13px; + color: #666; + margin-right: 0.5em; +} + +.attachments-browser .no-media { + padding: 2em 0 0 2em; +} + +/** + * Progress Bar + */ +.media-progress-bar { + position: relative; + height: 10px; + width: 70%; + margin: 10px auto; + border-radius: 10px; + background: #ddd; + background: rgba( 0, 0, 0, 0.1 ); +} + +.media-progress-bar div { + height: 10px; + min-width: 20px; + width: 0; + background: #0073aa; + border-radius: 10px; + transition: width 300ms; +} + +.media-uploader-status .media-progress-bar { + display: none; + width: 100%; +} + +.uploading.media-uploader-status .media-progress-bar { + display: block; +} + +.attachment-preview .media-progress-bar { + position: absolute; + top: 50%; + left: 15%; + width: 70%; + margin: -5px 0 0 0; +} + +.media-uploader-status { + position: relative; + margin: 0 auto; + padding-bottom: 10px; + max-width: 400px; +} + +.uploader-inline .media-uploader-status h3, /* Back-compat for pre-4.4 */ +.uploader-inline .media-uploader-status h2 { + display: none; +} + +.media-uploader-status .upload-details { + display: none; + font-size: 12px; + color: #666; +} + +.uploading.media-uploader-status .upload-details { + display: block; +} + +.media-uploader-status .upload-detail-separator { + padding: 0 4px; +} + +.media-uploader-status .upload-count { + color: #444; +} + +.media-uploader-status .upload-dismiss-errors, +.media-uploader-status .upload-errors { + display: none; +} + +.errors.media-uploader-status .upload-dismiss-errors, +.errors.media-uploader-status .upload-errors { + display: block; +} + +.media-uploader-status .upload-dismiss-errors { + text-decoration: none; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors { + position: absolute; + top: -10px; + right: -10px; + padding: 10px; + transition: none; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors:before { + content: "\f153"; + display: block; + font: normal 16px/1 dashicons; + color: #72777c; +} + +.media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before, +.media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before { + color: #c00; +} + +.upload-errors .upload-error { + padding: 12px; + margin-bottom: 12px; + background: #fff; + border-left: 4px solid #dc3232; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); +} + +.uploader-inline .upload-errors .upload-error { + background-color: #fbeaea; + box-shadow: none; +} + +.upload-errors .upload-error-filename { + font-weight: 600; +} + +.upload-errors .upload-error-message { + display: block; + padding-top: 8px; + word-wrap: break-word; +} + +.uploader-window { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba( 0, 86, 132, 0.9 ); + z-index: 250000; + display: none; + text-align: center; + opacity: 0; + transition: opacity 250ms; +} + +.uploader-window-content { + position: absolute; + top: 10px; + left: 10px; + right: 10px; + bottom: 10px; + border: 1px dashed #fff; +} + +.uploader-window h3, /* Back-compat for pre-4.4 */ +.uploader-window h1 { + margin: -0.5em 0 0; + position: absolute; + top: 50%; + left: 0; + right: 0; + -webkit-transform: translateY( -50% ); + transform: translateY( -50% ); + font-size: 40px; + color: #fff; + padding: 0; +} + +.uploader-window .media-progress-bar { + margin-top: 20px; + max-width: 300px; + background: transparent; + border-color: #fff; + display: none; +} + +.uploader-window .media-progress-bar div { + background: #fff; +} + +.uploading .uploader-window .media-progress-bar { + display: block; +} + +.media-frame .uploader-inline { + margin-bottom: 20px; + padding: 0; + text-align: center; +} + +.uploader-inline-content { + position: absolute; + top: 30%; + left: 0; + right: 0; +} + +.uploader-inline-content .upload-ui { + margin: 2em 0; +} + +.uploader-inline-content .post-upload-ui { + margin-bottom: 2em; +} + +.uploader-inline .has-upload-message .upload-ui { + margin: 0 0 4em; +} + +.uploader-inline h3, /* Back-compat for pre-4.4 */ +.uploader-inline h2 { + font-size: 20px; + line-height: 28px; + font-weight: 400; + margin: 0; +} + +.uploader-inline .has-upload-message .upload-instructions { + font-size: 14px; + color: #444; + font-weight: 400; +} + +.uploader-inline .drop-instructions { + display: none; +} + +.supports-drag-drop .uploader-inline .drop-instructions { + display: block; +} + +.uploader-inline p { + font-size: 12px; + margin: 0.5em 0; +} + +.uploader-inline .media-progress-bar { + display: none; +} + +.uploading.uploader-inline .media-progress-bar { + display: block; +} + +.uploader-inline .browser { + display: inline-block !important; +} + +/** + * Selection + */ +.media-selection { + position: absolute; + top: 0; + left: 0; + right: 350px; + height: 60px; + padding: 0 0 0 16px; + overflow: hidden; + white-space: nowrap; +} + +.media-selection .selection-info { + display: inline-block; + font-size: 12px; + height: 60px; + margin-right: 10px; + vertical-align: top; +} + +.media-selection.empty, +.media-selection.editing { + display: none; +} + +.media-selection.one .edit-selection { + display: none; +} + +.media-selection .count { + display: block; + padding-top: 12px; + font-size: 14px; + line-height: 20px; + font-weight: 600; +} + +.media-selection .button-link { + float: left; + padding: 1px 8px; + margin: 1px 8px 1px -8px; + line-height: 16px; + border-right: 1px solid #ddd; + color: #0073aa; + text-decoration: none; +} + +.media-selection .button-link:hover, +.media-selection .button-link:focus { + color: #00a0d2; +} + +.media-selection .button-link:last-child { + border-right: 0; + margin-right: 0; +} + +.selection-info .clear-selection { + color: #bc0b0b; +} + +.selection-info .clear-selection:hover, +.selection-info .clear-selection:focus { + color: #dc3232; +} + +.media-selection .selection-view { + display: inline-block; + vertical-align: top; +} + +.media-selection .attachments { + display: inline-block; + height: 48px; + margin: 6px; + padding: 0; + overflow: hidden; + vertical-align: top; +} + +.media-selection .attachment { + width: 40px; + padding: 0; + margin: 4px; +} + +.media-selection .attachment .thumbnail { + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.media-selection .attachment .icon { + width: 50%; +} + +.media-selection .attachment-preview { + box-shadow: none; + background: none; +} + +.wp-core-ui .media-selection .attachment:focus, +.wp-core-ui .media-selection .selected.attachment:focus, +.wp-core-ui .media-selection .attachment.details:focus { + box-shadow: + 0 0 0 1px #fff, + 0 0 2px 3px #5b9dd9; +} + +.wp-core-ui .media-selection .selected.attachment { + box-shadow: none; +} + +.wp-core-ui .media-selection .attachment.details { + box-shadow: + 0 0 0 1px #fff, + 0 0 0 3px #0073aa; +} + +.media-selection:after { + content: ""; + display: block; + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 25px; + background-image: linear-gradient(to left, rgba( 255, 255, 255, 1 ), rgba( 255, 255, 255, 0 )); +} + +.media-selection .attachment .filename { + display: none; +} + +/** + * Spinner + */ +.media-frame .spinner { + background: url(../images/spinner.gif) no-repeat; + background-size: 20px 20px; + float: right; + display: inline-block; + visibility: hidden; + opacity: 0.7; + filter: alpha(opacity=70); + width: 20px; + height: 20px; + margin: 0; + vertical-align: middle; +} + +.media-frame .spinner.is-active { + visibility: visible; +} + +.media-toolbar .spinner { + margin-top: 14px; +} + +/** + * Attachment Details + */ +.attachment-details { + position: relative; + overflow: auto; +} + +.attachment-details .settings-save-status { + float: right; + text-transform: none; + z-index: 10; +} + +.attachment-details .settings-save-status .spinner { + margin-left: 5px; +} + +.attachment-details .settings-save-status .saved { + float: right; + display: none; +} + +.attachment-details.save-waiting .settings-save-status .spinner { + visibility: visible; +} + +.attachment-details.save-complete .settings-save-status .saved { + display: block; +} + +.attachment-info { + overflow: hidden; + min-height: 60px; + margin-bottom: 16px; + line-height: 18px; + color: #666; + border-bottom: 1px solid #ddd; + padding-bottom: 11px; +} + +.attachment-info .filename { + font-weight: 600; + color: #444; + word-wrap: break-word; +} + +.attachment-info .thumbnail { + position: relative; + float: left; + max-width: 120px; + max-height: 120px; + margin-top: 5px; + margin-right: 10px; + margin-bottom: 5px; +} + +.uploading .attachment-info .thumbnail { + width: 120px; + height: 80px; + box-shadow: inset 0 0 15px rgba( 0, 0, 0, 0.1 ); +} + +.uploading .attachment-info .media-progress-bar { + margin-top: 35px; +} + +.attachment-info .thumbnail-image:after { + content: ""; + display: block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.15 ); + overflow: hidden; +} + +.attachment-info .thumbnail img { + display: block; + max-width: 120px; + max-height: 120px; + margin: 0 auto; +} + +.attachment-info .details { + float: left; + font-size: 12px; + max-width: 100%; +} + +.attachment-info .edit-attachment, +.attachment-info .delete-attachment, +.attachment-info .trash-attachment, +.attachment-info .untrash-attachment { + display: block; + text-decoration: none; + white-space: nowrap; +} + +.attachment-details.needs-refresh .attachment-info .edit-attachment { + display: none; +} + +.attachment-info .edit-attachment { + display: block; +} + +.media-modal .delete-attachment, +.media-modal .trash-attachment, +.media-modal .untrash-attachment { + display: inline; + padding: 0; + color: #bc0b0b; +} + +.media-modal .delete-attachment:hover, +.media-modal .delete-attachment:focus, +.media-modal .trash-attachment:hover, +.media-modal .trash-attachment:focus, +.media-modal .untrash-attachment:hover, +.media-modal .untrash-attachment:focus { + color: #dc3232; +} + +/** + * Attachment Display Settings + */ +.attachment-display-settings { + width: 100%; + float: left; + overflow: hidden; +} + +.attachment-display-settings h4 { + margin: 1.4em 0 0.4em; +} + +.collection-settings { + overflow: hidden; +} + +.collection-settings .setting input[type="checkbox"] { + float: left; + margin-right: 8px; +} + +.collection-settings .setting span { + min-width: inherit; +} + +/** + * Image Editor + */ +.media-modal .imgedit-wrap { + position: static; +} + +.media-modal .imgedit-wrap .imgedit-panel-content { + padding: 16px; + position: absolute; + top: 0; + right: 282px; + bottom: 0; + left: 0; + overflow: auto; +} + +.media-modal .imgedit-wrap .imgedit-settings { + background: #f3f3f3; + border-left: 1px solid #ddd; + padding: 20px 16px 16px; + position: absolute; + top: 0; + right: 0; + bottom: 0; + width: 250px; + overflow: auto; +} + +.media-modal .imgedit-group { + background: none; + border: none; + border-bottom: 1px solid #ddd; + box-shadow: none; + margin: 0; + margin-bottom: 16px; + padding: 0; + padding-bottom: 16px; + position: relative; /* RTL fix, #WP29352 */ +} + +.media-modal .imgedit-group:last-of-type { + border: none; + margin: 0; + padding: 0; +} + +.media-modal .imgedit-group-top { + margin: 0; +} + +.media-modal .imgedit-group-top h3, /* Back-compat for pre-4.4 */ +.media-modal .imgedit-group-top h2, +.media-modal .imgedit-group-top h2 .button-link { + display: inline-block; + text-transform: uppercase; + font-size: 12px; + color: #666; + margin: 0; + margin-top: 3px; +} + +.media-modal .imgedit-group-top h3 a, /* Back-compat for pre-4.4 */ +.media-modal .imgedit-group-top h2 a, +.media-modal .imgedit-group-top h2 .button-link { + text-decoration: none; + color: #666; +} + +/* higher specificity than media.css */ +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle, +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:hover, +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:active { + border: 1px solid transparent; + margin: 0; + padding: 0; + background: transparent; + color: #0074a2; + font-size: 20px; + line-height: 1; + cursor: pointer; + box-sizing: content-box; + box-shadow: none; +} + +.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:focus { + color: #0074a2; + border-color: #5b9dd9; + outline: none; + box-shadow: 0 0 3px rgba( 0, 115, 170, .8 ); +} + +.wp-core-ui.media-modal .imgedit-group-top .dashicons-arrow-down.imgedit-help-toggle { + margin-top: -3px; +} + +.wp-core-ui.media-modal .image-editor h3 .imgedit-help-toggle { + margin-top: -2px; +} + +.media-modal .imgedit-help-toggled span.dashicons:before { + content: "\f142"; +} + +.media-modal .imgedit-thumbnail-preview { + margin: 10px 8px 0 0; +} + +.imgedit-thumbnail-preview-caption { + display: block; +} + +.media-modal .imgedit-wrap div.updated { + margin: 0; + margin-bottom: 16px; +} + + +/** + * Embed from URL and Image Details + */ +.embed-url { + display: block; + position: relative; + padding: 16px; + margin: 0; + z-index: 250; + background: #fff; + font-size: 18px; +} + +.media-frame .embed-url input { + font-size: 18px; + padding: 12px 14px; + width: 100%; + min-width: 200px; + box-shadow: inset 2px 2px 4px -2px rgba( 0, 0, 0, 0.1 ); +} + +.media-frame .embed-url .spinner { + position: absolute; + top: 32px; + right: 26px; +} + +.media-frame .embed-loading .embed-url .spinner { + visibility: visible; +} + +.embed-link-settings, +.embed-media-settings { + position: absolute; + top: 70px; + left: 0; + right: 0; + bottom: 0; + padding: 16px 16px 32px; + overflow: auto; +} + +.media-embed .embed-link-settings { + /* avoid Firefox to give focus to the embed preview container parent */ + overflow: visible; +} + +.embed-preview img, +.embed-preview iframe, +.embed-preview embed, +.mejs-container video { + max-width: 100%; + vertical-align: middle; +} + +.embed-preview a { + display: inline-block; +} + +.embed-preview img { + display: block; + height: auto; +} + +.mejs-container:focus { + outline: 1px solid #5b9dd9; + box-shadow: 0 0 2px 1px rgba(30, 140, 190, .8); +} + +.image-details .media-modal { + left: 140px; + right: 140px; +} + +.image-details .media-frame-title, +.image-details .media-frame-content, +.image-details .media-frame-router { + left: 0; +} + +.image-details .embed-media-settings { + top: 0; + overflow: visible; + padding: 0; +} + +.image-details .embed-media-settings, +.image-details .embed-media-settings div { + box-sizing: border-box; +} + +.image-details .column-settings { + background: #f3f3f3; + border-right: 1px solid #ddd; + min-height: 100%; + width: 55%; + position: absolute; + top: 0; + left: 0; +} + +.image-details .column-settings h3, /* Back-compat for pre-4.4 */ +.image-details .column-settings h2 { + margin: 20px; + padding-top: 20px; + border-top: 1px solid #ddd; + color: #23282d; +} + +.image-details .column-image { + width: 45%; + position: absolute; + left: 55%; + top: 0; +} + +.image-details .image { + margin: 20px; +} + +.image-details .image img { + max-width: 100%; + max-height: 500px; +} + +.image-details .advanced-toggle { + padding: 0; + color: #666; + text-transform: uppercase; + text-decoration: none; +} + +.image-details .advanced-toggle:hover, +.image-details .advanced-toggle:active { + color: #666; +} + +.image-details .advanced-toggle:after { + font: normal 20px/1 dashicons; + speak: none; + vertical-align: top; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + content: "\f140"; + display: inline-block; + margin-top: -2px; +} + +.image-details .advanced-visible .advanced-toggle:after { + content: "\f142"; +} + +.image-details .embed-media-settings .size { + margin-bottom: 4px; +} + +.image-details .custom-size span { + display: block; +} + +.image-details .custom-size label { + display: block; + float: left; +} + +.image-details .custom-size span small { + color: #555d66; /* #f3f3f3 background */ + font-size: inherit; +} + +.image-details .custom-size input { + width: 5em; +} + +.image-details .custom-size .sep { + float: left; + margin: 26px 6px 0 6px; +} + +.image-details .custom-size:after { + content: ""; + display: table; + clear: both; +} + +.media-embed .thumbnail { + max-width: 100%; + max-height: 200px; + position: relative; + float: left; +} + +.media-embed .thumbnail img { + max-height: 200px; + display: block; +} + +.media-embed .thumbnail:after { + content: ""; + display: block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.1 ); + overflow: hidden; +} + +.media-embed .setting { + width: 100%; + margin: 10px 0; + float: left; + display: block; + clear: both; +} + +.image-details .embed-media-settings .setting { + float: none; + width: auto; +} + +.image-details .actions { + margin: 10px 0; +} + +.image-details .hidden { + display: none; +} + +.media-embed .setting input[type="text"], +.media-embed .setting textarea { + display: block; + width: 100%; + max-width: 400px; + margin: 1px 0; +} + +.image-details .embed-media-settings .setting input[type="text"], +.image-details .embed-media-settings .setting textarea { + max-width: inherit; + width: 70%; +} + +.image-details .embed-media-settings .setting input.link-to-custom, +.image-details .embed-media-settings .link-target, +.image-details .embed-media-settings .custom-size { + margin-left: 27%; + width: 70%; +} + +.image-details .embed-media-settings .link-target { + margin-top: 24px; +} + +.media-embed .setting input.hidden, +.media-embed .setting textarea.hidden { + display: none; +} + +.media-embed .setting span { + display: block; + width: 200px; + font-size: 13px; + line-height: 24px; + color: #666; +} + +.image-details .embed-media-settings .setting span { + float: left; + width: 25%; + text-align: right; + margin: 8px 1% 0 1%; + line-height: 1.1; +} + +.media-embed .setting .button-group { + margin: 2px 0; +} + +.media-embed-sidebar { + position: absolute; + top: 0; + left: 440px; +} + +.advanced-section, +.link-settings { + margin-top: 10px; +} + +/* Drag & drop on the editor upload */ +.wp-editor-wrap .uploader-editor { + background: rgba( 150, 150, 150, 0.9 ); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 99998; /* under the toolbar */ + display: none; + text-align: center; +} + +.wp-editor-wrap .uploader-editor-content { + border: 1px dashed #fff; + position: absolute; + top: 10px; + left: 10px; + right: 10px; + bottom: 10px; +} + +.wp-editor-wrap .uploader-editor .uploader-editor-title { + position: absolute; + top: 50%; + left: 0; + right: 0; + -webkit-transform: translateY( -50% ); + transform: translateY( -50% ); + font-size: 3em; + line-height: 1.3; + font-weight: 600; + color: #fff; + padding: 0; + margin: 0; + display: none; +} + +.wp-editor-wrap .uploader-editor.droppable { + background: rgba( 0, 86, 132, 0.9 ); +} + +.wp-editor-wrap .uploader-editor.droppable .uploader-editor-title { + display: block; +} + +/** + * IE7 Fixes + */ +.ie7 .media-frame .attachments-browser { + position: static; +} + +.ie7 .media-frame .embed-url input { + margin-top: 4px; + width: 90%; +} + +.ie7 .compat-item { + width: 99%; +} + +.ie7 .attachment-display-settings { + width: auto; +} + +.ie7 .attachment-preview, +.ie7 .attachment-preview .thumbnail { + width: 120px; + height: 120px; +} + +.ie7 .media-frame .attachment .describe { + width: 102px; +} + +.ie7 .media-sidebar .setting select { + max-width: 55%; +} + +.ie7 .media-sidebar .setting input[type="text"], +.ie7 .media-sidebar .setting input[type="password"], +.ie7 .media-sidebar .setting input[type="email"], +.ie7 .media-sidebar .setting input[type="number"], +.ie7 .media-sidebar .setting input[type="search"], +.ie7 .media-sidebar .setting input[type="tel"], +.ie7 .media-sidebar .setting input[type="url"], +.ie7 .media-sidebar .setting textarea { + width: 55%; +} + +.ie7 .media-sidebar .setting .link-to-custom { + float: left; +} + +/** + * Localization + */ +.rtl .media-modal, +.rtl .media-frame, +.rtl .media-frame .search, +.rtl .media-frame input[type="text"], +.rtl .media-frame input[type="password"], +.rtl .media-frame input[type="number"], +.rtl .media-frame input[type="search"], +.rtl .media-frame input[type="email"], +.rtl .media-frame input[type="url"], +.rtl .media-frame input[type="tel"], +.rtl .media-frame textarea, +.rtl .media-frame select { + font-family: Tahoma, sans-serif; +} + +:lang(he-il) .rtl .media-modal, +:lang(he-il) .rtl .media-frame, +:lang(he-il) .rtl .media-frame .search, +:lang(he-il) .rtl .media-frame input[type="text"], +:lang(he-il) .rtl .media-frame input[type="password"], +:lang(he-il) .rtl .media-frame input[type="number"], +:lang(he-il) .rtl .media-frame input[type="search"], +:lang(he-il) .rtl .media-frame input[type="email"], +:lang(he-il) .rtl .media-frame input[type="url"], +:lang(he-il) .rtl .media-frame textarea, +:lang(he-il) .rtl .media-frame select { + font-family: Arial, sans-serif; +} + +/** + * Responsive layout + */ +@media only screen and (max-width: 900px) { + + /* Drop-down menu */ + .media-frame:not(.hide-menu) .media-frame-title, + .media-frame:not(.hide-menu) .media-frame-router, + .media-frame:not(.hide-menu) .media-frame-content, + .media-frame:not(.hide-menu) .media-frame-toolbar { + left: 0; + } + + .media-frame:not(.hide-menu) .media-frame-menu { + position: static; + width: 0; + } + + .media-frame:not(.hide-menu) .media-menu { + width: auto; + max-width: 80%; + overflow: auto; + z-index: 2000; + top: 50px; + left: -300px; + right: auto; + bottom: auto; + padding: 5px 0; + border: 1px solid #ccc; + } + + .media-frame:not(.hide-menu) .media-menu.visible { + left: 0; + } + + .media-frame:not(.hide-menu) .media-menu > a { + padding: 12px 16px; + font-size: 16px; + } + + .media-frame:not(.hide-menu) .media-menu > a.active { + display: none; + } + + .media-frame:not(.hide-menu) .media-menu .separator { + margin: 5px 10px; + } + + .media-frame:not(.hide-menu) .media-frame-title { + left: 0; + } + + .media-frame:not(.hide-menu) .media-frame-title .dashicons { + display: inline-block; + line-height: 50px; + } + + .media-frame:not(.hide-menu) .media-frame-title h1 { + color: #0073aa; + line-height: 3; + font-size: 18px; + float: left; + cursor: pointer; + } + /* End drop-down menu */ + + .media-sidebar { + width: 230px; + } + + .attachments-browser .attachments, + .attachments-browser .uploader-inline, + .attachments-browser .media-toolbar { + right: 262px; + } + + .media-sidebar .setting, + .attachment-details .setting { + margin: 6px 0px; + } + + .media-sidebar .setting input, + .media-sidebar .setting textarea, + .media-sidebar .setting span, + .attachment-details .setting input, + .attachment-details .setting textarea, + .attachment-details .setting span, + .compat-item label span { + float: none; + } + + .media-sidebar .setting span, + .attachment-details .setting span, + .compat-item label span { + text-align: inherit; + min-height: 16px; + margin: 0; + padding: 8px 2px 0; + } + + .media-sidebar .setting .value, + .attachment-details .setting .value { + float: none; + width: auto; + } + + .media-sidebar .setting input[type="text"], + .media-sidebar .setting input[type="password"], + .media-sidebar .setting input[type="email"], + .media-sidebar .setting input[type="number"], + .media-sidebar .setting input[type="search"], + .media-sidebar .setting input[type="tel"], + .media-sidebar .setting input[type="url"], + .media-sidebar .setting textarea, + .media-sidebar .setting select, + .attachment-details .setting input[type="text"], + .attachment-details .setting input[type="password"], + .attachment-details .setting input[type="email"], + .attachment-details .setting input[type="number"], + .attachment-details .setting input[type="search"], + .attachment-details .setting input[type="tel"], + .attachment-details .setting input[type="url"], + .attachment-details .setting textarea, + .attachment-details .setting select { + float: none; + width: 98%; + max-width: none; + height: auto; + } + + .media-sidebar .setting select.columns, + .attachment-details .setting select.columns { + width: auto; + } + + .media-frame input, + .media-frame textarea, + .media-frame .search { + padding: 3px 6px; + } + + .image-details .column-image { + width: 30%; + left: 70%; + } + + .image-details .column-settings { + width: 70%; + } + + .image-details .media-modal { + left: 30px; + right: 30px; + } + + .image-details .embed-media-settings .setting { + margin: 20px; + } + + .image-details .embed-media-settings .setting span { + float: none; + text-align: left; + width: 100%; + margin-bottom: 4px; + } + + .image-details .embed-media-settings .setting input.link-to-custom, + .image-details .embed-media-settings .setting input[type="text"], + .image-details .embed-media-settings .setting textarea { + width: 100%; + margin-left: 0; + } + + .image-details .embed-media-settings .custom-size { + margin-left: 20px; + } + + .collection-settings .setting input[type="checkbox"] { + margin-top: 0; + } + + .media-selection { + min-width: 120px; + } + + .media-selection:after { + background: none; + } + + .media-selection .attachments { + display: none; + } + + .media-modal .attachments-browser .media-toolbar .search { + max-width: 100%; + height: auto; + float: right; + } + + .media-modal .attachments-browser .media-toolbar .attachment-filters { + height: auto; + } + + .media-modal .attachments-browser .media-toolbar .spinner { + margin: 14px 2px 0; + } + + /* Text inputs need to be 16px, or they force zooming on iOS */ + .media-frame input[type="text"], + .media-frame input[type="password"], + .media-frame input[type="number"], + .media-frame input[type="search"], + .media-frame input[type="email"], + .media-frame input[type="url"], + .media-frame textarea, + .media-frame select { + font-size: 16px; + } +} + +/* Responsive on portrait and landscape */ +@media only screen and (max-width: 640px), screen and (max-height: 400px) { + /* Full-bleed modal */ + .media-modal, + .image-details .media-modal { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + } + + .media-modal-backdrop { + position: fixed; + } + + .media-sidebar { + z-index: 1900; + max-width: 70%; + bottom: 120%; + box-sizing: border-box; + padding-bottom: 0; + } + + .media-sidebar.visible { + bottom: 0; + } + + .attachments-browser .attachments, + .attachments-browser .uploader-inline, + .attachments-browser .media-toolbar { + right: 0; + } + + .image-details .media-frame-title { + display: block; + top: 0; + font-size: 14px; + } + + .image-details .column-image, + .image-details .column-settings { + width: 100%; + position: relative; + left: 0; + } + + .image-details .column-settings { + padding: 4px 0; + } + + /* Media tabs on the top */ + .media-frame-content .media-toolbar .instructions { + display: none; + } +} + +/* Landscape specific header override */ +@media screen and (max-height: 400px) { + .media-menu { + padding: 0; + } + + .media-frame-router { + top: 44px; + } + + .media-frame-content { + top: 78px; + } + + .attachments-browser .attachments { + top: 40px; + } + + /* Prevent unnecessary scrolling on title input */ + .embed-link-settings { + overflow: visible; + } +} + +@media only screen and (max-width: 480px) { + .media-modal-close { + top: -5px; + } + + .media-modal .media-frame-title { + height: 40px; + } + + .wp-core-ui.wp-customizer .media-button { + margin-top: 13px; + } + + .media-modal .media-frame-title h1, + .media-frame:not(.hide-menu) .media-frame-title h1 { + font-size: 18px; + line-height: 40px; + } + + .media-frame:not(.hide-menu) .media-frame-title .dashicons { + line-height: 40px; + } + + .media-frame-router, + .media-frame:not(.hide-menu) .media-menu { + top: 40px; + } + + .media-frame-content { + top: 74px; + } + + .media-frame.hide-router .media-frame-content { + top: 40px; + } +} + +/** + * HiDPI Displays + */ +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + .wp-core-ui .media-modal-icon { + background-image: url(../images/uploader-icons-2x.png); + background-size: 134px 15px; + } + + .media-frame .spinner { + background-image: url(../images/spinner-2x.gif); + } +} + +.media-frame-content[data-columns="1"] .attachment { + width: 100%; +} + +.media-frame-content[data-columns="2"] .attachment { + width: 50%; +} + +.media-frame-content[data-columns="3"] .attachment { + width: 33.33%; +} + +.media-frame-content[data-columns="4"] .attachment { + width: 25%; +} + +.media-frame-content[data-columns="5"] .attachment { + width: 20%; +} + +.media-frame-content[data-columns="6"] .attachment { + width: 16.66%; +} + +.media-frame-content[data-columns="7"] .attachment { + width: 14.28%; +} + +.media-frame-content[data-columns="8"] .attachment { + width: 12.5%; +} + +.media-frame-content[data-columns="9"] .attachment { + width: 11.11%; +} + +.media-frame-content[data-columns="10"] .attachment { + width: 10%; +} + +.media-frame-content[data-columns="11"] .attachment { + width: 9.09%; +} + +.media-frame-content[data-columns="12"] .attachment { + width: 8.33%; +} diff --git a/backend/wp-includes/css/media-views.min.css b/backend/wp-includes/css/media-views.min.css new file mode 100644 index 0000000..54e825f --- /dev/null +++ b/backend/wp-includes/css/media-views.min.css @@ -0,0 +1,9 @@ +/*! This file is auto-generated */ +.media-menu,.media-router{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.media-modal *{box-sizing:content-box}.media-modal input,.media-modal select,.media-modal textarea{box-sizing:border-box}.media-frame,.media-modal{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:12px;-webkit-overflow-scrolling:touch}.media-modal label,.media-modal legend{font-size:13px}.media-frame input,.media-frame textarea{padding:6px 8px}.media-frame select,.wp-admin .media-frame select{line-height:28px;margin-top:3px}.media-frame a{border-bottom:none;color:#0073aa}.media-frame a:active,.media-frame a:hover{color:#00a0d2}.media-frame a:focus{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8);outline:0;color:#124964}.media-frame a.button{color:#32373c}.media-frame a.button:hover{color:#23282d}.media-frame a.button-primary,.media-frame a.button-primary:hover{color:#fff}.media-frame input[type=text],.media-frame input[type=password],.media-frame input[type=number],.media-frame input[type=search],.media-frame input[type=email],.media-frame input[type=url],.media-frame select,.media-frame textarea{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:12px;border-width:1px;border-style:solid;border-color:#ddd}.media-frame input[type=text]:focus,.media-frame input[type=password]:focus,.media-frame input[type=number]:focus,.media-frame input[type=search]:focus,.media-frame input[type=email]:focus,.media-frame input[type=url]:focus,.media-frame select:focus,.media-frame textarea:focus{border-color:#5b9dd9}.media-frame select{height:24px;padding:2px}.media-frame input:disabled,.media-frame input[readonly],.media-frame textarea:disabled,.media-frame textarea[readonly]{background-color:#eee}.media-frame input[type=search]{-webkit-appearance:textfield}.media-frame ::-webkit-input-placeholder{color:#72777c}.media-frame ::-moz-placeholder{color:#72777c;opacity:1}.media-frame :-ms-input-placeholder{color:#72777c}.media-frame .hidden{display:none}/*! + * jQuery UI Draggable/Sortable 1.11.4 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */.ui-draggable-handle,.ui-sortable-handle{touch-action:none}.media-modal{position:fixed;top:30px;left:30px;right:30px;bottom:30px;z-index:160000}.wp-customizer .media-modal{z-index:560000}.media-modal-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;min-height:360px;background:#000;opacity:.7;z-index:159900}.wp-customizer .media-modal-backdrop{z-index:559900}.media-modal-close{position:absolute;top:0;right:0;width:50px;height:50px;margin:0;padding:0;border:1px solid transparent;background:0 0;color:#666;z-index:1000;cursor:pointer;outline:0;transition:color .1s ease-in-out,background .1s ease-in-out}.media-modal-close:active,.media-modal-close:hover{color:#00a0d2}.media-modal-close:focus{color:#00a0d2;border-color:#5b9dd9;box-shadow:0 0 3px rgba(0,115,170,.8)}.media-modal-close span.media-modal-icon{background-image:none}.media-modal-close .media-modal-icon:before{content:"\f158";font:400 20px/1 dashicons;speak:none;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.media-modal-content{position:absolute;top:0;left:0;right:0;bottom:0;overflow:auto;min-height:300px;box-shadow:0 5px 15px rgba(0,0,0,.7);background:#fcfcfc;-webkit-font-smoothing:subpixel-antialiased}.media-modal-content .media-frame select.attachment-filters{margin-top:11px;margin-right:2%;width:42%;width:calc(48% - 12px)}.media-modal-content .media-toolbar-primary .media-button{float:right}.media-modal-content .attachments-browser .search{width:100%}.wp-core-ui .media-modal-icon{background-image:url(../images/uploader-icons.png);background-repeat:no-repeat}.media-toolbar{position:absolute;top:0;left:0;right:0;z-index:100;height:60px;padding:0 16px;border:0 solid #ddd;overflow:hidden}.media-frame-toolbar .media-toolbar{top:initial;bottom:-45px;height:auto;overflow:initial;border-top:1px solid #ddd}.media-menu,.media-sidebar{top:0;background:#f3f3f3;right:0}@media screen and (max-width:782px){.media-frame-toolbar .media-toolbar{bottom:-48px}}.media-toolbar-primary{float:right;height:100%}.media-toolbar-secondary{float:left;height:100%}.media-toolbar-primary>.media-button,.media-toolbar-primary>.media-button-group{margin-left:10px;float:left;margin-top:15px}.media-toolbar-secondary>.media-button,.media-toolbar-secondary>.media-button-group{margin-right:10px;margin-top:15px}.media-sidebar{position:absolute;bottom:0;width:267px;padding:0 16px 24px;z-index:75;border-left:1px solid #ddd;overflow:auto;-webkit-overflow-scrolling:touch}.hide-toolbar .media-sidebar{bottom:0}.media-sidebar .sidebar-title{font-size:20px;margin:0;padding:12px 10px 10px;line-height:28px}.media-sidebar .sidebar-content{padding:0 10px;margin-bottom:130px}.media-sidebar .search{display:block;width:100%}.image-details h2,.image-details h3,.media-sidebar h2,.media-sidebar h3{position:relative;font-weight:600;text-transform:uppercase;font-size:12px;color:#666;margin:24px 0 8px}.attachment-details .setting,.media-sidebar .setting{display:block;float:left;width:100%;margin:1px 0}.attachment-details .setting label,.media-sidebar .setting label{display:block}.attachment-details .setting .link-to-custom,.media-sidebar .setting .link-to-custom{margin:3px 2px 0}.attachment-details .setting span,.media-sidebar .setting span{min-width:30%;margin-right:4%;font-size:12px;text-align:right;word-wrap:break-word}.media-sidebar .setting .name{max-width:80px}.attachment-details .setting select,.media-sidebar .setting select{max-width:65%}.attachment-details .field input[type=radio],.attachment-details .field input[type=checkbox],.attachment-details .setting input[type=radio],.attachment-details .setting input[type=checkbox],.media-sidebar .field input[type=radio],.media-sidebar .field input[type=checkbox],.media-sidebar .setting input[type=radio],.media-sidebar .setting input[type=checkbox]{float:none;margin:8px 3px 0;padding:0}.attachment-details .setting span,.compat-item label span,.media-sidebar .setting span{float:left;min-height:22px;padding-top:8px;line-height:16px;font-weight:400;color:#666}.media-menu>a,.media-router>a{line-height:18px;font-size:14px;text-decoration:none}.compat-item label span{text-align:right}.attachment-details .setting .value,.attachment-details .setting input[type=tel],.attachment-details .setting input[type=text],.attachment-details .setting input[type=password],.attachment-details .setting input[type=number],.attachment-details .setting input[type=search],.attachment-details .setting input[type=email],.attachment-details .setting input[type=url],.attachment-details .setting textarea,.media-sidebar .setting .value,.media-sidebar .setting input[type=tel],.media-sidebar .setting input[type=text],.media-sidebar .setting input[type=password],.media-sidebar .setting input[type=number],.media-sidebar .setting input[type=search],.media-sidebar .setting input[type=email],.media-sidebar .setting input[type=url],.media-sidebar .setting textarea{box-sizing:border-box;margin:1px;width:65%;float:right}.attachment-details .setting .value,.media-sidebar .setting .value{margin:0 1px;text-align:left}.attachment-details .setting textarea,.compat-item .field textarea,.media-sidebar .setting textarea{height:62px;resize:vertical}.attachment-details select,.media-sidebar select{margin-top:3px}.compat-item{float:left;width:100%;overflow:hidden}.compat-item table{width:100%;table-layout:fixed;border-spacing:0;border:0}.compat-item tr{padding:2px 0;display:block;overflow:hidden}.compat-item .field,.compat-item .label{display:block;margin:0;padding:0}.compat-item .label{min-width:30%;margin-right:4%;float:left;text-align:right}.compat-item .label span{display:block;width:100%}.compat-item .field{float:right;width:65%;margin:1px}.compat-item .field input[type=tel],.compat-item .field input[type=text],.compat-item .field input[type=password],.compat-item .field input[type=number],.compat-item .field input[type=search],.compat-item .field input[type=email],.compat-item .field input[type=url],.compat-item .field textarea{width:100%;margin:0;box-sizing:border-box}.sidebar-for-errors .attachment-details,.sidebar-for-errors .compat-item,.sidebar-for-errors .media-sidebar .media-progress-bar,.sidebar-for-errors .upload-details{display:none!important}.media-menu{position:absolute;left:0;bottom:0;margin:0;padding:10px 0;border-right-width:1px;border-right-style:solid;border-right-color:#ccc;user-select:none}.media-menu>a{display:block;position:relative;padding:8px 20px;margin:0;color:#0073aa}.media-frame-title .dashicons,.media-frame.hide-menu .media-frame-menu,.media-frame.hide-router .media-frame-router,.media-frame.hide-toolbar .media-frame-toolbar{display:none}.media-menu>a:hover{color:#0073aa;background:rgba(0,0,0,.04)}.media-menu>a:active{outline:0}.media-menu .active,.media-menu .active:hover{color:#23282d;font-weight:600}.media-menu .separator{height:0;margin:12px 20px;padding:0;border-top:1px solid #ddd}.media-router{position:relative;padding:0 6px;margin:0;clear:both;user-select:none}.media-router a{transition:none}.media-router>a{position:relative;float:left;padding:8px 10px 9px;margin:0;height:18px}.media-frame,.media-frame-menu{position:absolute;left:0;bottom:0;top:0}.media-router>a:last-child{border-right:0}.media-router>a:active{outline:0}.media-router .active,.media-router .active:hover{color:#32373c}.media-router .active,.media-router>a.active:last-child{margin:-1px -1px 0;background:#fff;border:1px solid #ddd;border-bottom:none}.media-router .active:after{display:none}.media-frame{overflow:hidden;right:0}.media-frame-menu{width:200px;z-index:150}.media-frame-router,.media-frame-title{position:absolute;left:200px;right:0;z-index:200}.media-frame-title{top:0;height:50px}.media-frame-router{top:50px;height:36px}.media-frame-content,.media-frame-toolbar{left:200px;height:auto;position:absolute;right:0}.media-frame-content{top:84px;bottom:61px;width:auto;margin:0;overflow:auto;background:#fff;border-top:1px solid #ddd}.media-frame-toolbar{z-index:100;bottom:60px}.media-frame.hide-menu .media-frame-content,.media-frame.hide-menu .media-frame-router,.media-frame.hide-menu .media-frame-title,.media-frame.hide-menu .media-frame-toolbar{left:0}.media-frame.hide-toolbar .media-frame-content{bottom:0}.media-frame.hide-router .media-frame-content{top:50px}.media-frame.hide-router .media-frame-title{border-bottom:1px solid #ddd;box-shadow:0 4px 4px -4px rgba(0,0,0,.1)}.media-frame-title h1{padding:0 16px;font-size:22px;line-height:50px;margin:0}.media-frame-title .suggested-dimensions{font-size:14px;float:right;margin-right:20px}.media-frame-content .crop-content{height:100%}.wp-customizer:not(.mobile) .media-frame-content .crop-content.site-icon{margin-right:300px}.media-frame-content .crop-content .crop-image{display:block;margin:auto;max-width:100%;max-height:100%}.media-frame-content .crop-content .upload-errors{position:absolute;width:300px;top:50%;left:50%;margin-left:-150px;margin-right:-150px;z-index:600000}.media-frame .media-iframe{overflow:hidden}.media-frame .media-iframe,.media-frame .media-iframe iframe{height:100%;width:100%;border:0}.media-frame select.attachment-filters{margin-top:11px;margin-right:2%;max-width:42%;max-width:calc(48% - 12px)}.media-toolbar-primary .search,.wp-core-ui .attachment .portrait img{max-width:100%}.media-frame select.attachment-filters:last-of-type{margin-right:0}.media-frame .search{margin-top:11px;padding:4px;font-size:13px;color:#444;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;-webkit-appearance:none}.wp-core-ui .attachments{margin:0;-webkit-overflow-scrolling:touch}.wp-core-ui .attachment{position:relative;float:left;padding:8px;margin:0;color:#444;cursor:pointer;list-style:none;text-align:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:25%;box-sizing:border-box}.wp-core-ui .attachment.details:focus,.wp-core-ui .attachment:focus,.wp-core-ui .selected.attachment:focus{box-shadow:inset 0 0 2px 3px #fff,inset 0 0 0 7px #5b9dd9;outline:0}.wp-core-ui .selected.attachment{box-shadow:inset 0 0 0 5px #fff,inset 0 0 0 7px #ccc}.wp-core-ui .attachment.details{box-shadow:inset 0 0 0 3px #fff,inset 0 0 0 7px #0073aa}.wp-core-ui .attachment-preview{position:relative;box-shadow:inset 0 0 15px rgba(0,0,0,.1),inset 0 0 0 1px rgba(0,0,0,.05);background:#eee;cursor:pointer}.wp-core-ui .attachment-preview:before{content:"";display:block;padding-top:100%}.wp-core-ui .attachment .icon{margin:0 auto;overflow:hidden}.wp-core-ui .attachment .thumbnail{overflow:hidden;position:absolute;top:0;right:0;bottom:0;left:0;opacity:1;transition:opacity .1s}.wp-core-ui .attachment .landscape img{max-height:100%}.wp-core-ui .attachment .thumbnail:after{content:"";display:block;position:absolute;top:0;left:0;right:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);overflow:hidden}.wp-core-ui .attachment .thumbnail img{top:0;left:0}.wp-core-ui .attachment .thumbnail .centered{position:absolute;top:0;left:0;width:100%;height:100%;-webkit-transform:translate(50%,50%);transform:translate(50%,50%)}.wp-core-ui .attachment .thumbnail .centered img{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.wp-core-ui .attachments-browser .attachment .thumbnail .centered img.icon{-webkit-transform:translate(-50%,-70%);transform:translate(-50%,-70%)}.ie8 .wp-core-ui .attachment img.icon{top:20%;position:relative}.wp-core-ui .attachment .filename{position:absolute;left:0;right:0;bottom:0;overflow:hidden;max-height:100%;word-wrap:break-word;text-align:center;font-weight:600;background:rgba(255,255,255,.8);box-shadow:inset 0 0 0 1px rgba(0,0,0,.15)}.wp-core-ui .attachment .filename div{padding:5px 10px}.wp-core-ui .attachment .thumbnail img{position:absolute}.wp-core-ui .attachment-close{display:block;position:absolute;top:5px;right:5px;height:22px;width:22px;padding:0;background-color:#fff;background-position:-96px 4px;border-radius:3px;box-shadow:0 0 0 1px rgba(0,0,0,.3);transition:none}.wp-core-ui .attachment-close:focus,.wp-core-ui .attachment-close:hover{background-position:-36px 4px}.wp-core-ui .attachment .check{display:none;height:24px;width:24px;padding:0;border:0;position:absolute;z-index:10;top:0;right:0;outline:0;background:#eee;cursor:pointer;box-shadow:0 0 0 1px #fff,0 0 0 2px rgba(0,0,0,.15)}.wp-core-ui .attachment .check .media-modal-icon{display:block;background-position:-1px 0;height:15px;width:15px;margin:5px}.wp-core-ui .attachment .check:hover .media-modal-icon{background-position:-40px 0}.wp-core-ui .attachment.selected .check{display:block}.wp-core-ui .attachment.details .check,.wp-core-ui .attachment.selected .check:focus,.wp-core-ui .media-frame.mode-grid .attachment.selected .check{background-color:#0073aa;box-shadow:0 0 0 1px #fff,0 0 0 2px #0073aa}.wp-core-ui .attachment.details .check .media-modal-icon,.wp-core-ui .media-frame.mode-grid .attachment.selected .check .media-modal-icon{background-position:-21px 0}.wp-core-ui .attachment.details .check:hover .media-modal-icon,.wp-core-ui .attachment.selected .check:focus .media-modal-icon,.wp-core-ui .media-frame.mode-grid .attachment.selected .check:hover .media-modal-icon{background-position:-60px 0}.wp-core-ui .media-frame .attachment .describe{position:relative;display:block;width:100%;margin:0;padding:8px;font-size:12px;border-radius:0}.media-frame .attachments-browser{position:relative;width:100%;height:100%;overflow:hidden}.attachments-browser .media-toolbar{right:300px;height:50px}.attachments-browser.hide-sidebar .media-toolbar{right:0}.attachments-browser .media-toolbar-primary>.media-button,.attachments-browser .media-toolbar-primary>.media-button-group,.attachments-browser .media-toolbar-secondary>.media-button,.attachments-browser .media-toolbar-secondary>.media-button-group{margin:11px 0}.attachments-browser .attachments{padding:2px 8px 8px}.attachments-browser .attachments,.attachments-browser .uploader-inline{position:absolute;top:50px;left:0;right:300px;bottom:0;overflow:auto;outline:0}.attachments-browser .uploader-inline.hidden{display:none}.attachments-browser .media-toolbar-primary{max-width:33%}.attachments-browser .media-toolbar-secondary{max-width:66%}.uploader-inline .close{background-color:transparent;border:0;cursor:pointer;height:48px;outline:0;padding:0;position:absolute;right:2px;text-align:center;top:2px;width:48px;z-index:1}.uploader-inline .close:before{font:400 30px/1 dashicons!important;color:#555d66;display:inline-block;content:"\f335";font-weight:300;margin-top:1px}.uploader-inline .close:focus{outline:#5b9dd9 solid 1px;box-shadow:0 0 3px rgba(0,115,170,.8)}.attachments-browser.hide-sidebar .attachments,.attachments-browser.hide-sidebar .uploader-inline{right:0;margin-right:0}.attachments-browser .instructions{display:inline-block;margin-top:16px;line-height:18px;font-size:13px;color:#666;margin-right:.5em}.attachments-browser .no-media{padding:2em 0 0 2em}.media-progress-bar{position:relative;height:10px;width:70%;margin:10px auto;border-radius:10px;background:#ddd;background:rgba(0,0,0,.1)}.media-progress-bar div{height:10px;min-width:20px;width:0;background:#0073aa;border-radius:10px;transition:width .3s}.media-uploader-status .media-progress-bar{display:none;width:100%}.uploading.media-uploader-status .media-progress-bar{display:block}.attachment-preview .media-progress-bar{position:absolute;top:50%;left:15%;width:70%;margin:-5px 0 0}.media-uploader-status{position:relative;margin:0 auto;padding-bottom:10px;max-width:400px}.uploader-inline .media-uploader-status h2,.uploader-inline .media-uploader-status h3{display:none}.media-uploader-status .upload-details{display:none;font-size:12px;color:#666}.uploading.media-uploader-status .upload-details{display:block}.media-uploader-status .upload-detail-separator{padding:0 4px}.media-uploader-status .upload-count{color:#444}.media-uploader-status .upload-dismiss-errors,.media-uploader-status .upload-errors{display:none}.errors.media-uploader-status .upload-dismiss-errors,.errors.media-uploader-status .upload-errors{display:block}.media-uploader-status .upload-dismiss-errors{text-decoration:none}.media-sidebar .media-uploader-status .upload-dismiss-errors{position:absolute;top:-10px;right:-10px;padding:10px;transition:none}.media-sidebar .media-uploader-status .upload-dismiss-errors:before{content:"\f153";display:block;font:400 16px/1 dashicons;color:#72777c}.media-sidebar .media-uploader-status .upload-dismiss-errors:focus:before,.media-sidebar .media-uploader-status .upload-dismiss-errors:hover:before{color:#c00}.upload-errors .upload-error{padding:12px;margin-bottom:12px;background:#fff;border-left:4px solid #dc3232;box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}.uploader-inline .upload-errors .upload-error{background-color:#fbeaea;box-shadow:none}.upload-errors .upload-error-filename{font-weight:600}.upload-errors .upload-error-message{display:block;padding-top:8px;word-wrap:break-word}.uploader-window{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,86,132,.9);z-index:250000;display:none;text-align:center;opacity:0;transition:opacity 250ms}.uploader-window-content{position:absolute;top:10px;left:10px;right:10px;bottom:10px;border:1px dashed #fff}.uploader-window h1,.uploader-window h3{margin:-.5em 0 0;position:absolute;top:50%;left:0;right:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:40px;color:#fff;padding:0}.uploader-window .media-progress-bar{margin-top:20px;max-width:300px;background:0 0;border-color:#fff;display:none}.uploader-window .media-progress-bar div{background:#fff}.uploading .uploader-window .media-progress-bar{display:block}.media-frame .uploader-inline{margin-bottom:20px;padding:0;text-align:center}.uploader-inline-content{position:absolute;top:30%;left:0;right:0}.uploader-inline-content .upload-ui{margin:2em 0}.uploader-inline-content .post-upload-ui{margin-bottom:2em}.uploader-inline .has-upload-message .upload-ui{margin:0 0 4em}.uploader-inline h2,.uploader-inline h3{font-size:20px;line-height:28px;font-weight:400;margin:0}.uploader-inline .has-upload-message .upload-instructions{font-size:14px;color:#444;font-weight:400}.uploader-inline .drop-instructions{display:none}.supports-drag-drop .uploader-inline .drop-instructions{display:block}.uploader-inline p{font-size:12px;margin:.5em 0}.uploader-inline .media-progress-bar{display:none}.uploading.uploader-inline .media-progress-bar{display:block}.uploader-inline .browser{display:inline-block!important}.media-selection{position:absolute;top:0;left:0;right:350px;height:60px;padding:0 0 0 16px;overflow:hidden;white-space:nowrap}.media-selection .selection-info{display:inline-block;font-size:12px;height:60px;margin-right:10px;vertical-align:top}.media-selection.editing,.media-selection.empty,.media-selection.one .edit-selection{display:none}.media-selection .count{display:block;padding-top:12px;font-size:14px;line-height:20px;font-weight:600}.media-selection .attachments,.media-selection .selection-view{display:inline-block;vertical-align:top}.media-selection .button-link{float:left;padding:1px 8px;margin:1px 8px 1px -8px;line-height:16px;border-right:1px solid #ddd;color:#0073aa;text-decoration:none}.media-selection .button-link:focus,.media-selection .button-link:hover{color:#00a0d2}.media-selection .button-link:last-child{border-right:0;margin-right:0}.selection-info .clear-selection{color:#bc0b0b}.selection-info .clear-selection:focus,.selection-info .clear-selection:hover{color:#dc3232}.media-selection .attachments{height:48px;margin:6px;padding:0;overflow:hidden}.media-selection .attachment{width:40px;padding:0;margin:4px}.media-selection .attachment .thumbnail{top:0;right:0;bottom:0;left:0}.media-selection .attachment .icon{width:50%}.media-selection .attachment-preview{box-shadow:none;background:0 0}.wp-core-ui .media-selection .attachment.details:focus,.wp-core-ui .media-selection .attachment:focus,.wp-core-ui .media-selection .selected.attachment:focus{box-shadow:0 0 0 1px #fff,0 0 2px 3px #5b9dd9}.wp-core-ui .media-selection .selected.attachment{box-shadow:none}.wp-core-ui .media-selection .attachment.details{box-shadow:0 0 0 1px #fff,0 0 0 3px #0073aa}.media-selection:after{content:"";display:block;position:absolute;top:0;right:0;bottom:0;width:25px;background-image:linear-gradient(to left,rgba(255,255,255,1),rgba(255,255,255,0))}.media-selection .attachment .filename{display:none}.media-frame .spinner{background:url(../images/spinner.gif) no-repeat;background-size:20px 20px;float:right;display:inline-block;visibility:hidden;opacity:.7;filter:alpha(opacity=70);width:20px;height:20px;margin:0;vertical-align:middle}.attachment-details.save-waiting .settings-save-status .spinner,.media-frame .embed-loading .embed-url .spinner,.media-frame .spinner.is-active{visibility:visible}.media-toolbar .spinner{margin-top:14px}.attachment-details{position:relative;overflow:auto}.attachment-details .settings-save-status{float:right;text-transform:none;z-index:10}.attachment-details .settings-save-status .spinner{margin-left:5px}.attachment-details .settings-save-status .saved{float:right;display:none}.attachment-details.save-complete .settings-save-status .saved{display:block}.attachment-info{overflow:hidden;min-height:60px;margin-bottom:16px;line-height:18px;color:#666;border-bottom:1px solid #ddd;padding-bottom:11px}.attachment-info .filename{font-weight:600;color:#444;word-wrap:break-word}.attachment-info .thumbnail{position:relative;float:left;max-width:120px;max-height:120px;margin-top:5px;margin-right:10px;margin-bottom:5px}.uploading .attachment-info .thumbnail{width:120px;height:80px;box-shadow:inset 0 0 15px rgba(0,0,0,.1)}.uploading .attachment-info .media-progress-bar{margin-top:35px}.attachment-info .thumbnail-image:after{content:"";display:block;position:absolute;top:0;left:0;right:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);overflow:hidden}.attachment-info .thumbnail img{display:block;max-width:120px;max-height:120px;margin:0 auto}.attachment-info .details{float:left;font-size:12px;max-width:100%}.attachment-info .delete-attachment,.attachment-info .edit-attachment,.attachment-info .trash-attachment,.attachment-info .untrash-attachment{display:block;text-decoration:none;white-space:nowrap}.attachment-details.needs-refresh .attachment-info .edit-attachment{display:none}.attachment-info .edit-attachment{display:block}.media-modal .delete-attachment,.media-modal .trash-attachment,.media-modal .untrash-attachment{display:inline;padding:0;color:#bc0b0b}.media-modal .delete-attachment:focus,.media-modal .delete-attachment:hover,.media-modal .trash-attachment:focus,.media-modal .trash-attachment:hover,.media-modal .untrash-attachment:focus,.media-modal .untrash-attachment:hover{color:#dc3232}.attachment-display-settings{width:100%;float:left;overflow:hidden}.attachment-display-settings h4{margin:1.4em 0 .4em}.collection-settings{overflow:hidden}.collection-settings .setting input[type=checkbox]{float:left;margin-right:8px}.collection-settings .setting span{min-width:inherit}.media-modal .imgedit-wrap{position:static}.media-modal .imgedit-wrap .imgedit-panel-content{padding:16px;position:absolute;top:0;right:282px;bottom:0;left:0;overflow:auto}.media-modal .imgedit-wrap .imgedit-settings{background:#f3f3f3;border-left:1px solid #ddd;padding:20px 16px 16px;position:absolute;top:0;right:0;bottom:0;width:250px;overflow:auto}.media-modal .imgedit-group{background:0 0;border:none;border-bottom:1px solid #ddd;box-shadow:none;margin:0 0 16px;padding:0 0 16px;position:relative}.media-modal .imgedit-group:last-of-type{border:none;margin:0;padding:0}.media-modal .imgedit-group-top{margin:0}.media-modal .imgedit-group-top h2,.media-modal .imgedit-group-top h2 .button-link,.media-modal .imgedit-group-top h3{display:inline-block;text-transform:uppercase;font-size:12px;color:#666;margin:3px 0 0}.embed-url,.imgedit-thumbnail-preview-caption{display:block}.media-modal .imgedit-group-top h2 .button-link,.media-modal .imgedit-group-top h2 a,.media-modal .imgedit-group-top h3 a{text-decoration:none;color:#666}.wp-core-ui.media-modal .image-editor .imgedit-help-toggle,.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:active,.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:hover{border:1px solid transparent;margin:0;padding:0;background:0 0;color:#0074a2;font-size:20px;line-height:1;cursor:pointer;box-sizing:content-box;box-shadow:none}.wp-core-ui.media-modal .image-editor .imgedit-help-toggle:focus{color:#0074a2;border-color:#5b9dd9;outline:0;box-shadow:0 0 3px rgba(0,115,170,.8)}.wp-core-ui.media-modal .imgedit-group-top .dashicons-arrow-down.imgedit-help-toggle{margin-top:-3px}.wp-core-ui.media-modal .image-editor h3 .imgedit-help-toggle{margin-top:-2px}.media-modal .imgedit-help-toggled span.dashicons:before{content:"\f142"}.media-modal .imgedit-thumbnail-preview{margin:10px 8px 0 0}.media-modal .imgedit-wrap div.updated{margin:0 0 16px}.embed-url{position:relative;padding:16px;margin:0;z-index:250;background:#fff;font-size:18px}.media-frame .embed-url input{font-size:18px;padding:12px 14px;width:100%;min-width:200px;box-shadow:inset 2px 2px 4px -2px rgba(0,0,0,.1)}.media-frame .embed-url .spinner{position:absolute;top:32px;right:26px}.embed-link-settings,.embed-media-settings{position:absolute;top:70px;left:0;right:0;bottom:0;padding:16px 16px 32px;overflow:auto}.media-embed .embed-link-settings{overflow:visible}.embed-preview embed,.embed-preview iframe,.embed-preview img,.mejs-container video{max-width:100%;vertical-align:middle}.embed-preview a{display:inline-block}.embed-preview img{display:block;height:auto}.mejs-container:focus{outline:#5b9dd9 solid 1px;box-shadow:0 0 2px 1px rgba(30,140,190,.8)}.image-details .media-modal{left:140px;right:140px}.image-details .media-frame-content,.image-details .media-frame-router,.image-details .media-frame-title{left:0}.image-details .embed-media-settings{top:0;overflow:visible;padding:0}.image-details .embed-media-settings,.image-details .embed-media-settings div{box-sizing:border-box}.image-details .column-settings{background:#f3f3f3;border-right:1px solid #ddd;min-height:100%;width:55%;position:absolute;top:0;left:0}.image-details .column-settings h2,.image-details .column-settings h3{margin:20px;padding-top:20px;border-top:1px solid #ddd;color:#23282d}.image-details .column-image{width:45%;position:absolute;left:55%;top:0}.image-details .image{margin:20px}.image-details .image img{max-width:100%;max-height:500px}.image-details .advanced-toggle{padding:0;color:#666;text-transform:uppercase;text-decoration:none}.image-details .advanced-toggle:active,.image-details .advanced-toggle:hover{color:#666}.image-details .advanced-toggle:after{font:400 20px/1 dashicons;speak:none;vertical-align:top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:"\f140";display:inline-block;margin-top:-2px}.image-details .advanced-visible .advanced-toggle:after{content:"\f142"}.image-details .embed-media-settings .size{margin-bottom:4px}.image-details .custom-size span{display:block}.image-details .custom-size label{display:block;float:left}.image-details .custom-size span small{color:#555d66;font-size:inherit}.image-details .custom-size input{width:5em}.image-details .custom-size .sep{float:left;margin:26px 6px 0}.image-details .custom-size:after{content:"";display:table;clear:both}.media-embed .thumbnail{max-width:100%;max-height:200px;position:relative;float:left}.media-embed .thumbnail img{max-height:200px;display:block}.media-embed .thumbnail:after{content:"";display:block;position:absolute;top:0;left:0;right:0;bottom:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);overflow:hidden}.media-embed .setting{width:100%;margin:10px 0;float:left;display:block;clear:both}.image-details .embed-media-settings .setting{float:none;width:auto}.image-details .actions{margin:10px 0}.image-details .hidden{display:none}.media-embed .setting input[type=text],.media-embed .setting textarea{display:block;width:100%;max-width:400px;margin:1px 0}.image-details .embed-media-settings .setting input[type=text],.image-details .embed-media-settings .setting textarea{max-width:inherit;width:70%}.image-details .embed-media-settings .custom-size,.image-details .embed-media-settings .link-target,.image-details .embed-media-settings .setting input.link-to-custom{margin-left:27%;width:70%}.image-details .embed-media-settings .link-target{margin-top:24px}.media-embed .setting input.hidden,.media-embed .setting textarea.hidden{display:none}.media-embed .setting span{display:block;width:200px;font-size:13px;line-height:24px;color:#666}.image-details .embed-media-settings .setting span{float:left;width:25%;text-align:right;margin:8px 1% 0;line-height:1.1}.media-embed .setting .button-group{margin:2px 0}.media-embed-sidebar{position:absolute;top:0;left:440px}.advanced-section,.link-settings{margin-top:10px}.wp-editor-wrap .uploader-editor{background:rgba(150,150,150,.9);position:absolute;top:0;left:0;width:100%;height:100%;z-index:99998;display:none;text-align:center}.wp-editor-wrap .uploader-editor-content{border:1px dashed #fff;position:absolute;top:10px;left:10px;right:10px;bottom:10px}.wp-editor-wrap .uploader-editor .uploader-editor-title{position:absolute;top:50%;left:0;right:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);font-size:3em;line-height:1.3;font-weight:600;color:#fff;padding:0;margin:0;display:none}.wp-editor-wrap .uploader-editor.droppable{background:rgba(0,86,132,.9)}.wp-editor-wrap .uploader-editor.droppable .uploader-editor-title{display:block}.ie7 .media-frame .attachments-browser{position:static}.ie7 .media-frame .embed-url input{margin-top:4px;width:90%}.ie7 .compat-item{width:99%}.ie7 .attachment-display-settings{width:auto}.ie7 .attachment-preview,.ie7 .attachment-preview .thumbnail{width:120px;height:120px}.ie7 .media-frame .attachment .describe{width:102px}.ie7 .media-sidebar .setting select{max-width:55%}.ie7 .media-sidebar .setting input[type=tel],.ie7 .media-sidebar .setting input[type=text],.ie7 .media-sidebar .setting input[type=password],.ie7 .media-sidebar .setting input[type=number],.ie7 .media-sidebar .setting input[type=search],.ie7 .media-sidebar .setting input[type=email],.ie7 .media-sidebar .setting input[type=url],.ie7 .media-sidebar .setting textarea{width:55%}.ie7 .media-sidebar .setting .link-to-custom{float:left}.rtl .media-frame,.rtl .media-frame .search,.rtl .media-frame input[type=tel],.rtl .media-frame input[type=text],.rtl .media-frame input[type=password],.rtl .media-frame input[type=number],.rtl .media-frame input[type=search],.rtl .media-frame input[type=email],.rtl .media-frame input[type=url],.rtl .media-frame select,.rtl .media-frame textarea,.rtl .media-modal{font-family:Tahoma,sans-serif}:lang(he-il) .rtl .media-frame,:lang(he-il) .rtl .media-frame .search,:lang(he-il) .rtl .media-frame input[type=text],:lang(he-il) .rtl .media-frame input[type=password],:lang(he-il) .rtl .media-frame input[type=number],:lang(he-il) .rtl .media-frame input[type=search],:lang(he-il) .rtl .media-frame input[type=email],:lang(he-il) .rtl .media-frame input[type=url],:lang(he-il) .rtl .media-frame select,:lang(he-il) .rtl .media-frame textarea,:lang(he-il) .rtl .media-modal{font-family:Arial,sans-serif}@media only screen and (max-width:900px){.media-frame:not(.hide-menu) .media-frame-content,.media-frame:not(.hide-menu) .media-frame-router,.media-frame:not(.hide-menu) .media-frame-title,.media-frame:not(.hide-menu) .media-frame-toolbar{left:0}.media-frame:not(.hide-menu) .media-frame-menu{position:static;width:0}.media-frame:not(.hide-menu) .media-menu{width:auto;max-width:80%;overflow:auto;z-index:2000;top:50px;left:-300px;right:auto;bottom:auto;padding:5px 0;border:1px solid #ccc}.media-frame:not(.hide-menu) .media-menu.visible{left:0}.media-frame:not(.hide-menu) .media-menu>a{padding:12px 16px;font-size:16px}.media-frame:not(.hide-menu) .media-menu>a.active{display:none}.media-frame:not(.hide-menu) .media-menu .separator{margin:5px 10px}.media-frame:not(.hide-menu) .media-frame-title{left:0}.media-frame:not(.hide-menu) .media-frame-title .dashicons{display:inline-block;line-height:50px}.media-frame:not(.hide-menu) .media-frame-title h1{color:#0073aa;line-height:3;font-size:18px;float:left;cursor:pointer}.media-sidebar{width:230px}.attachments-browser .attachments,.attachments-browser .media-toolbar,.attachments-browser .uploader-inline{right:262px}.attachment-details .setting,.media-sidebar .setting{margin:6px 0}.attachment-details .setting input,.attachment-details .setting span,.attachment-details .setting textarea,.compat-item label span,.media-sidebar .setting input,.media-sidebar .setting span,.media-sidebar .setting textarea{float:none}.attachment-details .setting span,.compat-item label span,.media-sidebar .setting span{text-align:inherit;min-height:16px;margin:0;padding:8px 2px 0}.attachment-details .setting .value,.media-sidebar .setting .value{float:none;width:auto}.attachment-details .setting input[type=tel],.attachment-details .setting input[type=text],.attachment-details .setting input[type=password],.attachment-details .setting input[type=number],.attachment-details .setting input[type=search],.attachment-details .setting input[type=email],.attachment-details .setting input[type=url],.attachment-details .setting select,.attachment-details .setting textarea,.media-sidebar .setting input[type=tel],.media-sidebar .setting input[type=text],.media-sidebar .setting input[type=password],.media-sidebar .setting input[type=number],.media-sidebar .setting input[type=search],.media-sidebar .setting input[type=email],.media-sidebar .setting input[type=url],.media-sidebar .setting select,.media-sidebar .setting textarea{float:none;width:98%;max-width:none;height:auto}.attachment-details .setting select.columns,.media-sidebar .setting select.columns{width:auto}.media-frame .search,.media-frame input,.media-frame textarea{padding:3px 6px}.image-details .column-image{width:30%;left:70%}.image-details .column-settings{width:70%}.image-details .media-modal{left:30px;right:30px}.image-details .embed-media-settings .setting{margin:20px}.image-details .embed-media-settings .setting span{float:none;text-align:left;width:100%;margin-bottom:4px}.image-details .embed-media-settings .setting input.link-to-custom,.image-details .embed-media-settings .setting input[type=text],.image-details .embed-media-settings .setting textarea{width:100%;margin-left:0}.image-details .embed-media-settings .custom-size{margin-left:20px}.collection-settings .setting input[type=checkbox]{margin-top:0}.media-selection{min-width:120px}.media-selection:after{background:0 0}.media-selection .attachments{display:none}.media-modal .attachments-browser .media-toolbar .search{max-width:100%;height:auto;float:right}.media-modal .attachments-browser .media-toolbar .attachment-filters{height:auto}.media-modal .attachments-browser .media-toolbar .spinner{margin:14px 2px 0}.media-frame input[type=text],.media-frame input[type=password],.media-frame input[type=number],.media-frame input[type=search],.media-frame input[type=email],.media-frame input[type=url],.media-frame select,.media-frame textarea{font-size:16px}}@media only screen and (max-width:640px),screen and (max-height:400px){.image-details .media-modal,.media-modal{position:fixed;top:0;left:0;right:0;bottom:0}.media-modal-backdrop{position:fixed}.media-sidebar{z-index:1900;max-width:70%;bottom:120%;box-sizing:border-box;padding-bottom:0}.media-sidebar.visible{bottom:0}.attachments-browser .attachments,.attachments-browser .media-toolbar,.attachments-browser .uploader-inline{right:0}.image-details .media-frame-title{display:block;top:0;font-size:14px}.image-details .column-image,.image-details .column-settings{width:100%;position:relative;left:0}.image-details .column-settings{padding:4px 0}.media-frame-content .media-toolbar .instructions{display:none}}@media screen and (max-height:400px){.media-menu{padding:0}.media-frame-router{top:44px}.media-frame-content{top:78px}.attachments-browser .attachments{top:40px}.embed-link-settings{overflow:visible}}@media only screen and (max-width:480px){.media-modal-close{top:-5px}.media-modal .media-frame-title{height:40px}.wp-core-ui.wp-customizer .media-button{margin-top:13px}.media-frame:not(.hide-menu) .media-frame-title h1,.media-modal .media-frame-title h1{font-size:18px;line-height:40px}.media-frame:not(.hide-menu) .media-frame-title .dashicons{line-height:40px}.media-frame-router,.media-frame:not(.hide-menu) .media-menu{top:40px}.media-frame-content{top:74px}.media-frame.hide-router .media-frame-content{top:40px}}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){.wp-core-ui .media-modal-icon{background-image:url(../images/uploader-icons-2x.png);background-size:134px 15px}.media-frame .spinner{background-image:url(../images/spinner-2x.gif)}}.media-frame-content[data-columns="1"] .attachment{width:100%}.media-frame-content[data-columns="2"] .attachment{width:50%}.media-frame-content[data-columns="3"] .attachment{width:33.33%}.media-frame-content[data-columns="4"] .attachment{width:25%}.media-frame-content[data-columns="5"] .attachment{width:20%}.media-frame-content[data-columns="6"] .attachment{width:16.66%}.media-frame-content[data-columns="7"] .attachment{width:14.28%}.media-frame-content[data-columns="8"] .attachment{width:12.5%}.media-frame-content[data-columns="9"] .attachment{width:11.11%}.media-frame-content[data-columns="10"] .attachment{width:10%}.media-frame-content[data-columns="11"] .attachment{width:9.09%}.media-frame-content[data-columns="12"] .attachment{width:8.33%} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-auth-check-rtl.css b/backend/wp-includes/css/wp-auth-check-rtl.css new file mode 100644 index 0000000..e2158f5 --- /dev/null +++ b/backend/wp-includes/css/wp-auth-check-rtl.css @@ -0,0 +1,124 @@ +/*------------------------------------------------------------------------------ + Interim login dialog +------------------------------------------------------------------------------*/ + +#wp-auth-check-wrap.hidden { + display: none; +} + +#wp-auth-check-wrap #wp-auth-check-bg { + position: fixed; + top: 0; + bottom: 0; + right: 0; + left: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 1000010; /* needs to appear above .notification-dialog */ +} + +#wp-auth-check-wrap #wp-auth-check { + position: fixed; + right: 50%; + overflow: hidden; + top: 40px; + bottom: 20px; + max-height: 415px; + width: 380px; + margin: 0 -190px 0 0; + padding: 30px 0 0; + background-color: #f1f1f1; + z-index: 1000011; /* needs to appear above #wp-auth-check-bg */ + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); +} + +@media screen and ( max-width: 380px ) { + #wp-auth-check-wrap #wp-auth-check { + right: 0; + width: 100%; + margin: 0; + } +} + +#wp-auth-check-wrap.fallback #wp-auth-check { + max-height: 180px; + overflow: auto; +} + +#wp-auth-check-wrap #wp-auth-check-form { + height: 100%; + position: relative; + overflow: auto; + -webkit-overflow-scrolling: touch; +} + +#wp-auth-check-form.loading:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + right: 50%; + top: 50%; + margin: -10px -10px 0 0; + background: url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + #wp-auth-check-form.loading:before { + background-image: url(../images/spinner-2x.gif); + } + +} + +#wp-auth-check-wrap #wp-auth-check-form iframe { + height: 98%; /* Scrollbar fix */ + width: 100%; +} + +#wp-auth-check-wrap .wp-auth-check-close { + position: absolute; + top: 5px; + left: 5px; + height: 22px; + width: 22px; + color: #72777c; + text-decoration: none; + text-align: center; +} + +#wp-auth-check-wrap .wp-auth-check-close:before { + content: "\f158"; + font: normal 20px/22px dashicons; + speak: none; + -webkit-font-smoothing: antialiased !important; + -moz-osx-font-smoothing: grayscale; +} + +#wp-auth-check-wrap .wp-auth-check-close:hover, +#wp-auth-check-wrap .wp-auth-check-close:focus { + color: #0073aa; +} + +#wp-auth-check-wrap .wp-auth-fallback-expired { + outline: 0; +} + +#wp-auth-check-wrap .wp-auth-fallback { + font-size: 14px; + line-height: 21px; + padding: 0 25px; + display: none; +} + +#wp-auth-check-wrap.fallback .wp-auth-fallback, +#wp-auth-check-wrap.fallback .wp-auth-check-close { + display: block; +} diff --git a/backend/wp-includes/css/wp-auth-check-rtl.min.css b/backend/wp-includes/css/wp-auth-check-rtl.min.css new file mode 100644 index 0000000..db3d5d2 --- /dev/null +++ b/backend/wp-includes/css/wp-auth-check-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#wp-auth-check-wrap.hidden{display:none}#wp-auth-check-wrap #wp-auth-check-bg{position:fixed;top:0;bottom:0;right:0;left:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:1000010}#wp-auth-check-wrap #wp-auth-check{position:fixed;right:50%;overflow:hidden;top:40px;bottom:20px;max-height:415px;width:380px;margin:0 -190px 0 0;padding:30px 0 0;background-color:#f1f1f1;z-index:1000011;box-shadow:0 3px 6px rgba(0,0,0,.3)}@media screen and (max-width:380px){#wp-auth-check-wrap #wp-auth-check{right:0;width:100%;margin:0}}#wp-auth-check-wrap.fallback #wp-auth-check{max-height:180px;overflow:auto}#wp-auth-check-wrap #wp-auth-check-form{height:100%;position:relative;overflow:auto;-webkit-overflow-scrolling:touch}#wp-auth-check-form.loading:before{content:"";display:block;width:20px;height:20px;position:absolute;right:50%;top:50%;margin:-10px -10px 0 0;background:url(../images/spinner.gif) center no-repeat;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#wp-auth-check-form.loading:before{background-image:url(../images/spinner-2x.gif)}}#wp-auth-check-wrap #wp-auth-check-form iframe{height:98%;width:100%}#wp-auth-check-wrap .wp-auth-check-close{position:absolute;top:5px;left:5px;height:22px;width:22px;color:#72777c;text-decoration:none;text-align:center}#wp-auth-check-wrap .wp-auth-check-close:before{content:"\f158";font:400 20px/22px dashicons;speak:none;-webkit-font-smoothing:antialiased!important;-moz-osx-font-smoothing:grayscale}#wp-auth-check-wrap .wp-auth-check-close:focus,#wp-auth-check-wrap .wp-auth-check-close:hover{color:#0073aa}#wp-auth-check-wrap .wp-auth-fallback-expired{outline:0}#wp-auth-check-wrap .wp-auth-fallback{font-size:14px;line-height:21px;padding:0 25px;display:none}#wp-auth-check-wrap.fallback .wp-auth-check-close,#wp-auth-check-wrap.fallback .wp-auth-fallback{display:block} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-auth-check.css b/backend/wp-includes/css/wp-auth-check.css new file mode 100644 index 0000000..7be3663 --- /dev/null +++ b/backend/wp-includes/css/wp-auth-check.css @@ -0,0 +1,124 @@ +/*------------------------------------------------------------------------------ + Interim login dialog +------------------------------------------------------------------------------*/ + +#wp-auth-check-wrap.hidden { + display: none; +} + +#wp-auth-check-wrap #wp-auth-check-bg { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: #000; + opacity: 0.7; + filter: alpha(opacity=70); + z-index: 1000010; /* needs to appear above .notification-dialog */ +} + +#wp-auth-check-wrap #wp-auth-check { + position: fixed; + left: 50%; + overflow: hidden; + top: 40px; + bottom: 20px; + max-height: 415px; + width: 380px; + margin: 0 0 0 -190px; + padding: 30px 0 0; + background-color: #f1f1f1; + z-index: 1000011; /* needs to appear above #wp-auth-check-bg */ + box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); +} + +@media screen and ( max-width: 380px ) { + #wp-auth-check-wrap #wp-auth-check { + left: 0; + width: 100%; + margin: 0; + } +} + +#wp-auth-check-wrap.fallback #wp-auth-check { + max-height: 180px; + overflow: auto; +} + +#wp-auth-check-wrap #wp-auth-check-form { + height: 100%; + position: relative; + overflow: auto; + -webkit-overflow-scrolling: touch; +} + +#wp-auth-check-form.loading:before { + content: ""; + display: block; + width: 20px; + height: 20px; + position: absolute; + left: 50%; + top: 50%; + margin: -10px 0 0 -10px; + background: url(../images/spinner.gif) no-repeat center; + background-size: 20px 20px; + -webkit-transform: translateZ(0); + transform: translateZ(0); +} + +@media print, + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + + #wp-auth-check-form.loading:before { + background-image: url(../images/spinner-2x.gif); + } + +} + +#wp-auth-check-wrap #wp-auth-check-form iframe { + height: 98%; /* Scrollbar fix */ + width: 100%; +} + +#wp-auth-check-wrap .wp-auth-check-close { + position: absolute; + top: 5px; + right: 5px; + height: 22px; + width: 22px; + color: #72777c; + text-decoration: none; + text-align: center; +} + +#wp-auth-check-wrap .wp-auth-check-close:before { + content: "\f158"; + font: normal 20px/22px dashicons; + speak: none; + -webkit-font-smoothing: antialiased !important; + -moz-osx-font-smoothing: grayscale; +} + +#wp-auth-check-wrap .wp-auth-check-close:hover, +#wp-auth-check-wrap .wp-auth-check-close:focus { + color: #0073aa; +} + +#wp-auth-check-wrap .wp-auth-fallback-expired { + outline: 0; +} + +#wp-auth-check-wrap .wp-auth-fallback { + font-size: 14px; + line-height: 21px; + padding: 0 25px; + display: none; +} + +#wp-auth-check-wrap.fallback .wp-auth-fallback, +#wp-auth-check-wrap.fallback .wp-auth-check-close { + display: block; +} diff --git a/backend/wp-includes/css/wp-auth-check.min.css b/backend/wp-includes/css/wp-auth-check.min.css new file mode 100644 index 0000000..7e38423 --- /dev/null +++ b/backend/wp-includes/css/wp-auth-check.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +#wp-auth-check-wrap.hidden{display:none}#wp-auth-check-wrap #wp-auth-check-bg{position:fixed;top:0;bottom:0;left:0;right:0;background:#000;opacity:.7;filter:alpha(opacity=70);z-index:1000010}#wp-auth-check-wrap #wp-auth-check{position:fixed;left:50%;overflow:hidden;top:40px;bottom:20px;max-height:415px;width:380px;margin:0 0 0 -190px;padding:30px 0 0;background-color:#f1f1f1;z-index:1000011;box-shadow:0 3px 6px rgba(0,0,0,.3)}@media screen and (max-width:380px){#wp-auth-check-wrap #wp-auth-check{left:0;width:100%;margin:0}}#wp-auth-check-wrap.fallback #wp-auth-check{max-height:180px;overflow:auto}#wp-auth-check-wrap #wp-auth-check-form{height:100%;position:relative;overflow:auto;-webkit-overflow-scrolling:touch}#wp-auth-check-form.loading:before{content:"";display:block;width:20px;height:20px;position:absolute;left:50%;top:50%;margin:-10px 0 0 -10px;background:url(../images/spinner.gif) center no-repeat;background-size:20px 20px;-webkit-transform:translateZ(0);transform:translateZ(0)}@media print,(-webkit-min-device-pixel-ratio:1.25),(min-resolution:120dpi){#wp-auth-check-form.loading:before{background-image:url(../images/spinner-2x.gif)}}#wp-auth-check-wrap #wp-auth-check-form iframe{height:98%;width:100%}#wp-auth-check-wrap .wp-auth-check-close{position:absolute;top:5px;right:5px;height:22px;width:22px;color:#72777c;text-decoration:none;text-align:center}#wp-auth-check-wrap .wp-auth-check-close:before{content:"\f158";font:400 20px/22px dashicons;speak:none;-webkit-font-smoothing:antialiased!important;-moz-osx-font-smoothing:grayscale}#wp-auth-check-wrap .wp-auth-check-close:focus,#wp-auth-check-wrap .wp-auth-check-close:hover{color:#0073aa}#wp-auth-check-wrap .wp-auth-fallback-expired{outline:0}#wp-auth-check-wrap .wp-auth-fallback{font-size:14px;line-height:21px;padding:0 25px;display:none}#wp-auth-check-wrap.fallback .wp-auth-check-close,#wp-auth-check-wrap.fallback .wp-auth-fallback{display:block} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-embed-template-ie.css b/backend/wp-includes/css/wp-embed-template-ie.css new file mode 100644 index 0000000..cec05c9 --- /dev/null +++ b/backend/wp-includes/css/wp-embed-template-ie.css @@ -0,0 +1,19 @@ +.dashicons-no { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAAcElEQVR4AdXRVxmEMBAGwJMQCUhAIhKQECmRsFJwMFfp7HfP/E8pk0173CuKpt/0R+WaBaaZqogLagBMuh+DdoKbyRCwqZ/SnM0R5oQuZ2UHS8Z6k23qPxZCTrV5UlHMi8bsfHVXP7K/GXZHaTO7S54CWLdHlN2YIwAAAABJRU5ErkJggg==); +} + +.dashicons-admin-comments { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATUlEQVR4AWMYWqCpvUcAiA8A8X9iMFStAD4DG0AKScQNVDZw1MBRAwvIMLCA5jmFlCD4AMQGlOTtBgoNwzQQ3TCKDaTcMMxYN2AYVgAAYPKsEBxN0PIAAAAASUVORK5CYII=); +} + +.wp-embed-comments a:hover .dashicons-admin-comments { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATElEQVR4AWMYYqB4lQAQHwDi/8RgqFoBfAY2gBSSiBuobOCogaMGFpBhYAEdcwrhIPgAxAaU5O0GCg3DNBDdMIoNpNwwzFg3YBhWAABG71qAFYcFqgAAAABJRU5ErkJggg==); +} + +.dashicons-share { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYfqCpvccAiBcA8X8gfgDEBZQaeAFkGBoOoMR1/7HgDeQa2ECZgQiDHID4AMwAor0MCmBoQP+HBnwAskFQdgBRkQJViGk7wiAHUr21AYdhDTA1dDOQHl6mPFLokmwoT9j0z3qUFw70L77oDwAiuzCIub1XpQAAAABJRU5ErkJggg==); +} + +.wp-embed-share-dialog-open:hover .dashicons-share { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYhqB4lQEQLwDi/0D8AIgLKDXwAsgwNBxAiev+Y8EbyDWwgTIDEQY5APEBmAFEexkUwNCA/g8N+ABkg6DsAKIiBaoQ03aEQQ6kemsDDsMaYEroZiA9vEx5pNAl2VCesOmf9SgvHOhffNEfAAAMqPR5IEZH5wAAAABJRU5ErkJggg==); +} diff --git a/backend/wp-includes/css/wp-embed-template-ie.min.css b/backend/wp-includes/css/wp-embed-template-ie.min.css new file mode 100644 index 0000000..6228217 --- /dev/null +++ b/backend/wp-includes/css/wp-embed-template-ie.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.dashicons-no{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAAcElEQVR4AdXRVxmEMBAGwJMQCUhAIhKQECmRsFJwMFfp7HfP/E8pk0173CuKpt/0R+WaBaaZqogLagBMuh+DdoKbyRCwqZ/SnM0R5oQuZ2UHS8Z6k23qPxZCTrV5UlHMi8bsfHVXP7K/GXZHaTO7S54CWLdHlN2YIwAAAABJRU5ErkJggg==)}.dashicons-admin-comments{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATUlEQVR4AWMYWqCpvUcAiA8A8X9iMFStAD4DG0AKScQNVDZw1MBRAwvIMLCA5jmFlCD4AMQGlOTtBgoNwzQQ3TCKDaTcMMxYN2AYVgAAYPKsEBxN0PIAAAAASUVORK5CYII=)}.wp-embed-comments a:hover .dashicons-admin-comments{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATElEQVR4AWMYYqB4lQAQHwDi/8RgqFoBfAY2gBSSiBuobOCogaMGFpBhYAEdcwrhIPgAxAaU5O0GCg3DNBDdMIoNpNwwzFg3YBhWAABG71qAFYcFqgAAAABJRU5ErkJggg==)}.dashicons-share{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYfqCpvccAiBcA8X8gfgDEBZQaeAFkGBoOoMR1/7HgDeQa2ECZgQiDHID4AMwAor0MCmBoQP+HBnwAskFQdgBRkQJViGk7wiAHUr21AYdhDTA1dDOQHl6mPFLokmwoT9j0z3qUFw70L77oDwAiuzCIub1XpQAAAABJRU5ErkJggg==)}.wp-embed-share-dialog-open:hover .dashicons-share{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYhqB4lQEQLwDi/0D8AIgLKDXwAsgwNBxAiev+Y8EbyDWwgTIDEQY5APEBmAFEexkUwNCA/g8N+ABkg6DsAKIiBaoQ03aEQQ6kemsDDsMaYEroZiA9vEx5pNAl2VCesOmf9SgvHOhffNEfAAAMqPR5IEZH5wAAAABJRU5ErkJggg==)} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-embed-template.css b/backend/wp-includes/css/wp-embed-template.css new file mode 100644 index 0000000..b1fd593 --- /dev/null +++ b/backend/wp-includes/css/wp-embed-template.css @@ -0,0 +1,361 @@ +html, body { + padding: 0; + margin: 0; +} + +body { + font-family: sans-serif; +} + +/* Text meant only for screen readers */ +.screen-reader-text { + border: 0; + clip: rect(1px, 1px, 1px, 1px); + -webkit-clip-path: inset(50%); + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +/* Dashicons */ +.dashicons { + display: inline-block; + width: 20px; + height: 20px; + background-color: transparent; + background-repeat: no-repeat; + background-size: 20px; + background-position: center; + transition: background .1s ease-in; + position: relative; + top: 5px; +} + +.dashicons-no { + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M15.55%2013.7l-2.19%202.06-3.42-3.65-3.64%203.43-2.06-2.18%203.64-3.43-3.42-3.64%202.18-2.06%203.43%203.64%203.64-3.42%202.05%202.18-3.64%203.43z%27%20fill%3D%27%23fff%27%2F%3E%3C%2Fsvg%3E"); +} + +.dashicons-admin-comments { + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E"); +} + +.wp-embed-comments a:hover .dashicons-admin-comments { + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E"); +} + +.dashicons-share { + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E"); + display: none; +} + +.js .dashicons-share { + display: inline-block; +} + +.wp-embed-share-dialog-open:hover .dashicons-share { + background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E"); +} + +.wp-embed { + padding: 25px; + font-size: 14px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 1.5; + color: #82878c; + background: #fff; + border: 1px solid #e5e5e5; + box-shadow: 0 1px 1px rgba(0, 0, 0, .05); + /* Clearfix */ + overflow: auto; + zoom: 1; +} + +.wp-embed a { + color: #82878c; + text-decoration: none; +} + +.wp-embed a:hover { + text-decoration: underline; +} + +.wp-embed-featured-image { + margin-bottom: 20px; +} + +.wp-embed-featured-image img { + width: 100%; + height: auto; + border: none; +} + +.wp-embed-featured-image.square { + float: left; + max-width: 160px; + margin-right: 20px; +} + +.wp-embed p { + margin: 0; +} + +p.wp-embed-heading { + margin: 0 0 15px; + font-weight: 600; + font-size: 22px; + line-height: 1.3; +} + +.wp-embed-heading a { + color: #32373c; +} + +.wp-embed .wp-embed-more { + color: #b4b9be; +} + +.wp-embed-footer { + display: table; + width: 100%; + margin-top: 30px; +} + +.wp-embed-site-icon { + position: absolute; + top: 50%; + left: 0; + -webkit-transform: translateY(-50%); + transform: translateY(-50%); + height: 25px; + width: 25px; + border: 0; +} + +.wp-embed-site-title { + font-weight: 600; + line-height: 25px; +} + +.wp-embed-site-title a { + position: relative; + display: inline-block; + padding-left: 35px; +} + +.wp-embed-site-title, +.wp-embed-meta { + display: table-cell; +} + +.wp-embed-meta { + text-align: right; + white-space: nowrap; + vertical-align: middle; +} + +.wp-embed-comments, +.wp-embed-share { + display: inline; +} + +.wp-embed-meta a:hover { + text-decoration: none; + color: #0073aa; +} + +.wp-embed-comments a { + line-height: 25px; + display: inline-block; +} + +.wp-embed-comments + .wp-embed-share { + margin-left: 10px; +} + +.wp-embed-share-dialog { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #222; + background-color: rgba(10, 10, 10, 0.9); + color: #fff; + opacity: 1; + transition: opacity .25s ease-in-out; +} + +.wp-embed-share-dialog.hidden { + opacity: 0; + visibility: hidden; +} + +.wp-embed-share-dialog-open, +.wp-embed-share-dialog-close { + margin: -8px 0 0; + padding: 0; + background: transparent; + border: none; + cursor: pointer; + outline: none; +} + +.wp-embed-share-dialog-open .dashicons, +.wp-embed-share-dialog-close .dashicons { + padding: 4px; +} + +.wp-embed-share-dialog-open .dashicons { + top: 8px; +} + +.wp-embed-share-dialog-open:focus .dashicons, +.wp-embed-share-dialog-close:focus .dashicons { + box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); + border-radius: 100%; +} + +.wp-embed-share-dialog-close { + position: absolute; + top: 20px; + right: 20px; + font-size: 22px; +} + +.wp-embed-share-dialog-close:hover { + text-decoration: none; +} + +.wp-embed-share-dialog-close .dashicons { + height: 24px; + width: 24px; + background-size: 24px; +} + +.wp-embed-share-dialog-content { + height: 100%; + -webkit-transform-style: preserve-3d; + transform-style: preserve-3d; + overflow: hidden; +} + +.wp-embed-share-dialog-text { + margin-top: 25px; + padding: 20px; +} + +.wp-embed-share-tabs { + margin: 0 0 20px; + padding: 0; + list-style: none; +} + +.wp-embed-share-tab-button { + display: inline-block; +} + +.wp-embed-share-tab-button button { + margin: 0; + padding: 0; + border: none; + background: transparent; + font-size: 16px; + line-height: 1.3; + color: #aaa; + cursor: pointer; + transition: color .1s ease-in; +} + +.wp-embed-share-tab-button [aria-selected="true"] { + color: #fff; +} + +.wp-embed-share-tab-button button:hover { + color: #fff; +} + +.wp-embed-share-tab-button + .wp-embed-share-tab-button { + margin: 0 0 0 10px; + padding: 0 0 0 11px; + border-left: 1px solid #aaa; +} + +.wp-embed-share-tab[aria-hidden="true"] { + display: none; +} + +p.wp-embed-share-description { + margin: 0; + font-size: 14px; + line-height: 1; + font-style: italic; + color: #aaa; +} + +.wp-embed-share-input { + box-sizing: border-box; + width: 100%; + border: none; + height: 28px; + margin: 0 0 10px 0; + padding: 0 5px; + font-size: 14px; + font-weight: 400; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; + line-height: 1.5; + resize: none; + cursor: text; +} + +textarea.wp-embed-share-input { + height: 72px; +} + +html[dir="rtl"] .wp-embed-featured-image.square { + float: right; + margin-right: 0; + + margin-left: 20px; +} + +html[dir="rtl"] .wp-embed-site-title a { + padding-left: 0; + padding-right: 35px; +} + +html[dir="rtl"] .wp-embed-site-icon { + margin-right: 0; + margin-left: 10px; + left: auto; + right: 0; +} + +html[dir="rtl"] .wp-embed-meta { + text-align: left; +} + +html[dir="rtl"] .wp-embed-footer { +} + +html[dir="rtl"] .wp-embed-share { + margin-left: 0; + margin-right: 10px; +} + +html[dir="rtl"] .wp-embed-share-dialog-close { + right: auto; + left: 20px; +} + +html[dir="rtl"] .wp-embed-share-tab-button + .wp-embed-share-tab-button { + margin: 0 10px 0 0; + padding: 0 11px 0 0; + border-left: none; + border-right: 1px solid #aaa; +} diff --git a/backend/wp-includes/css/wp-embed-template.min.css b/backend/wp-includes/css/wp-embed-template.min.css new file mode 100644 index 0000000..6b4a23a --- /dev/null +++ b/backend/wp-includes/css/wp-embed-template.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +body,html{padding:0;margin:0}body{font-family:sans-serif}.wp-embed,.wp-embed-share-input{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif}.screen-reader-text{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal!important}.dashicons{display:inline-block;width:20px;height:20px;background-color:transparent;background-repeat:no-repeat;background-size:20px;background-position:center;transition:background .1s ease-in;position:relative;top:5px}.dashicons-no{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M15.55%2013.7l-2.19%202.06-3.42-3.65-3.64%203.43-2.06-2.18%203.64-3.43-3.42-3.64%202.18-2.06%203.43%203.64%203.64-3.42%202.05%202.18-3.64%203.43z%27%20fill%3D%27%23fff%27%2F%3E%3C%2Fsvg%3E")}.dashicons-admin-comments{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E")}.wp-embed-comments a:hover .dashicons-admin-comments{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M5%202h9q.82%200%201.41.59T16%204v7q0%20.82-.59%201.41T14%2013h-2l-5%205v-5H5q-.82%200-1.41-.59T3%2011V4q0-.82.59-1.41T5%202z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E")}.dashicons-share{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%2382878c%27%2F%3E%3C%2Fsvg%3E");display:none}.js .dashicons-share{display:inline-block}.wp-embed-share-dialog-open:hover .dashicons-share{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.5%2012q1.24%200%202.12.88T17.5%2015t-.88%202.12-2.12.88-2.12-.88T11.5%2015q0-.34.09-.69l-4.38-2.3Q6.32%2013%205%2013q-1.24%200-2.12-.88T2%2010t.88-2.12T5%207q1.3%200%202.21.99l4.38-2.3q-.09-.35-.09-.69%200-1.24.88-2.12T14.5%202t2.12.88T17.5%205t-.88%202.12T14.5%208q-1.3%200-2.21-.99l-4.38%202.3Q8%209.66%208%2010t-.09.69l4.38%202.3q.89-.99%202.21-.99z%27%20fill%3D%27%230073aa%27%2F%3E%3C%2Fsvg%3E")}.wp-embed{padding:25px;font-size:14px;font-weight:400;line-height:1.5;color:#82878c;background:#fff;border:1px solid #e5e5e5;box-shadow:0 1px 1px rgba(0,0,0,.05);overflow:auto;zoom:1}.wp-embed a{color:#82878c;text-decoration:none}.wp-embed a:hover{text-decoration:underline}.wp-embed-featured-image{margin-bottom:20px}.wp-embed-featured-image img{width:100%;height:auto;border:none}.wp-embed-featured-image.square{float:left;max-width:160px;margin-right:20px}.wp-embed p{margin:0}p.wp-embed-heading{margin:0 0 15px;font-weight:600;font-size:22px;line-height:1.3}.wp-embed-heading a{color:#32373c}.wp-embed .wp-embed-more{color:#b4b9be}.wp-embed-footer{display:table;width:100%;margin-top:30px}.wp-embed-site-icon{position:absolute;top:50%;left:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);height:25px;width:25px;border:0}.wp-embed-site-title{font-weight:600;line-height:25px}.wp-embed-site-title a{position:relative;display:inline-block;padding-left:35px}.wp-embed-meta,.wp-embed-site-title{display:table-cell}.wp-embed-meta{text-align:right;white-space:nowrap;vertical-align:middle}.wp-embed-comments,.wp-embed-share{display:inline}.wp-embed-comments a,.wp-embed-share-tab-button{display:inline-block}.wp-embed-meta a:hover{text-decoration:none;color:#0073aa}.wp-embed-comments a{line-height:25px}.wp-embed-comments+.wp-embed-share{margin-left:10px}.wp-embed-share-dialog{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#222;background-color:rgba(10,10,10,.9);color:#fff;opacity:1;transition:opacity .25s ease-in-out}.wp-embed-share-dialog.hidden{opacity:0;visibility:hidden}.wp-embed-share-dialog-close,.wp-embed-share-dialog-open{margin:-8px 0 0;padding:0;background:0 0;border:none;cursor:pointer;outline:0}.wp-embed-share-dialog-close .dashicons,.wp-embed-share-dialog-open .dashicons{padding:4px}.wp-embed-share-dialog-open .dashicons{top:8px}.wp-embed-share-dialog-close:focus .dashicons,.wp-embed-share-dialog-open:focus .dashicons{box-shadow:0 0 0 1px #5b9dd9,0 0 2px 1px rgba(30,140,190,.8);border-radius:100%}.wp-embed-share-dialog-close{position:absolute;top:20px;right:20px;font-size:22px}.wp-embed-share-dialog-close:hover{text-decoration:none}.wp-embed-share-dialog-close .dashicons{height:24px;width:24px;background-size:24px}.wp-embed-share-dialog-content{height:100%;-webkit-transform-style:preserve-3d;transform-style:preserve-3d;overflow:hidden}.wp-embed-share-dialog-text{margin-top:25px;padding:20px}.wp-embed-share-tabs{margin:0 0 20px;padding:0;list-style:none}.wp-embed-share-tab-button button{margin:0;padding:0;border:none;background:0 0;font-size:16px;line-height:1.3;color:#aaa;cursor:pointer;transition:color .1s ease-in}.wp-embed-share-tab-button [aria-selected=true],.wp-embed-share-tab-button button:hover{color:#fff}.wp-embed-share-tab-button+.wp-embed-share-tab-button{margin:0 0 0 10px;padding:0 0 0 11px;border-left:1px solid #aaa}.wp-embed-share-tab[aria-hidden=true]{display:none}p.wp-embed-share-description{margin:0;font-size:14px;line-height:1;font-style:italic;color:#aaa}.wp-embed-share-input{box-sizing:border-box;width:100%;border:none;height:28px;margin:0 0 10px;padding:0 5px;font-size:14px;font-weight:400;line-height:1.5;resize:none;cursor:text}textarea.wp-embed-share-input{height:72px}html[dir=rtl] .wp-embed-featured-image.square{float:right;margin-right:0;margin-left:20px}html[dir=rtl] .wp-embed-site-title a{padding-left:0;padding-right:35px}html[dir=rtl] .wp-embed-site-icon{margin-right:0;margin-left:10px;left:auto;right:0}html[dir=rtl] .wp-embed-meta{text-align:left}html[dir=rtl] .wp-embed-share{margin-left:0;margin-right:10px}html[dir=rtl] .wp-embed-share-dialog-close{right:auto;left:20px}html[dir=rtl] .wp-embed-share-tab-button+.wp-embed-share-tab-button{margin:0 10px 0 0;padding:0 11px 0 0;border-left:none;border-right:1px solid #aaa} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-pointer-rtl.css b/backend/wp-includes/css/wp-pointer-rtl.css new file mode 100644 index 0000000..15c8a19 --- /dev/null +++ b/backend/wp-includes/css/wp-pointer-rtl.css @@ -0,0 +1,224 @@ +.wp-pointer-content { + padding: 0 0 10px; + position: relative; + font-size: 13px; + background: #fff; + border: 1px solid #ddd; + box-shadow: 0 3px 6px rgba(0,0,0,0.075); +} + +.wp-pointer-content h3 { + position: relative; + margin: -1px -1px 5px; + padding: 15px 60px 14px 18px; + border: 1px solid #3592b6; + border-bottom: none; + line-height: 1.4em; + font-size: 14px; + color: #fff; + background: #00a0d2; +} + +.wp-pointer-content h3:before { + background: #fff; + border-radius: 50%; + color: #00a0d2; + content: "\f227"; + font: normal 20px/1.6 dashicons; + position: absolute; + top: 8px; + right: 15px; + speak: none; + text-align: center; + width: 32px; + height: 32px; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-pointer-content h4 { + margin: 1.33em 20px 1em; + font-size: 1.15em; +} + +.wp-pointer-content p { + padding: 0 20px; +} + +.wp-pointer-buttons { + margin: 0; + padding: 5px 15px; + overflow: auto; +} + +.wp-pointer-buttons a { + float: left; + display: inline-block; + text-decoration: none; +} + +.wp-pointer-buttons a.close { + padding-right: 3px; + position: relative; +} + +.wp-pointer-buttons a.close:before { + background: none; + color: #72777c; + content: "\f153"; + display: block !important; + font: normal 16px/1 dashicons; + speak: none; + margin: 1px 0; + text-align: center; + -webkit-font-smoothing: antialiased !important; + width: 10px; + height: 100%; + position: absolute; + right: -15px; + top: 1px; +} + +.wp-pointer-buttons a.close:hover:before { + color: #c00; +} + +/* The arrow base class must take up no space, even with transparent borders. */ +.wp-pointer-arrow, +.wp-pointer-arrow-inner { + position: absolute; + width: 0; + height: 0; +} + +.wp-pointer-arrow { + z-index: 10; + width: 0; + height: 0; + border: 0 solid transparent; +} + +.wp-pointer-arrow-inner { + z-index: 20; +} + +/* Make Room for the Arrow! */ +.wp-pointer-top, +.wp-pointer-undefined { + padding-top: 13px; +} + +.wp-pointer-bottom { + margin-top: -13px; + padding-bottom: 13px; +} + +/* rtl:ignore */ +.wp-pointer-left { + padding-left: 13px; +} +/* rtl:ignore */ +.wp-pointer-right { + margin-left: -13px; + padding-right: 13px; +} + +/* Base Size & Positioning */ +.wp-pointer-top .wp-pointer-arrow, +.wp-pointer-bottom .wp-pointer-arrow, +.wp-pointer-undefined .wp-pointer-arrow { + right: 50px; +} + +.wp-pointer-left .wp-pointer-arrow, +.wp-pointer-right .wp-pointer-arrow { + top: 50%; + margin-top: -15px; +} + +/* Arrow Sprite */ +.wp-pointer-top .wp-pointer-arrow, +.wp-pointer-undefined .wp-pointer-arrow { + top: 0; + border-width: 0 13px 13px 13px; + border-bottom-color: #3592b6; +} + +.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer-undefined .wp-pointer-arrow-inner { + top: 1px; + margin-right: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-bottom-color: #00a0d2; + display: block; + content: " "; +} + +.wp-pointer-bottom .wp-pointer-arrow { + bottom: 0; + border-width: 13px 13px 0 13px; + border-top-color: #ccc; +} + +.wp-pointer-bottom .wp-pointer-arrow-inner { + bottom: 1px; + margin-right: -13px; + margin-bottom: -13px; + border: 13px solid transparent; + border-top-color: #fff; + display: block; + content: " "; +} + +/* rtl:ignore */ +.wp-pointer-left .wp-pointer-arrow { + left: 0; + border-width: 13px 13px 13px 0; + border-right-color: #ccc; +} + +/* rtl:ignore */ +.wp-pointer-left .wp-pointer-arrow-inner { + left: 1px; + margin-left: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-right-color: #fff; + display: block; + content: " "; +} + +/* rtl:ignore */ +.wp-pointer-right .wp-pointer-arrow { + right: 0; + border-width: 13px 0 13px 13px; + border-left-color: #ccc; +} + +/* rtl:ignore */ +.wp-pointer-right .wp-pointer-arrow-inner { + right: 1px; + margin-right: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-left-color: #fff; + display: block; + content: " "; +} + +.wp-pointer.arrow-bottom .wp-pointer-content { + margin-bottom: -45px; +} + +.wp-pointer.arrow-bottom .wp-pointer-arrow { + top: 100%; + margin-top: -30px; +} + +/* Disable pointers at responsive sizes */ +@media screen and ( max-width: 782px ) { + .wp-pointer { + display: none; + } +} diff --git a/backend/wp-includes/css/wp-pointer-rtl.min.css b/backend/wp-includes/css/wp-pointer-rtl.min.css new file mode 100644 index 0000000..9fac286 --- /dev/null +++ b/backend/wp-includes/css/wp-pointer-rtl.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-pointer-content{padding:0 0 10px;position:relative;font-size:13px;background:#fff;border:1px solid #ddd;box-shadow:0 3px 6px rgba(0,0,0,.075)}.wp-pointer-content h3{position:relative;margin:-1px -1px 5px;padding:15px 60px 14px 18px;border:1px solid #3592b6;border-bottom:none;line-height:1.4em;font-size:14px;color:#fff;background:#00a0d2}.wp-pointer-content h3:before{background:#fff;border-radius:50%;color:#00a0d2;content:"\f227";font:400 20px/1.6 dashicons;position:absolute;top:8px;right:15px;speak:none;text-align:center;width:32px;height:32px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-pointer-content h4{margin:1.33em 20px 1em;font-size:1.15em}.wp-pointer-content p{padding:0 20px}.wp-pointer-buttons{margin:0;padding:5px 15px;overflow:auto}.wp-pointer-buttons a{float:left;display:inline-block;text-decoration:none}.wp-pointer-buttons a.close{padding-right:3px;position:relative}.wp-pointer-buttons a.close:before{background:0 0;color:#72777c;content:"\f153";display:block!important;font:400 16px/1 dashicons;speak:none;margin:1px 0;text-align:center;-webkit-font-smoothing:antialiased!important;width:10px;height:100%;position:absolute;right:-15px;top:1px}.wp-pointer-buttons a.close:hover:before{color:#c00}.wp-pointer-arrow,.wp-pointer-arrow-inner{position:absolute;width:0;height:0}.wp-pointer-arrow{z-index:10;width:0;height:0;border:0 solid transparent}.wp-pointer-arrow-inner{z-index:20}.wp-pointer-top,.wp-pointer-undefined{padding-top:13px}.wp-pointer-bottom{margin-top:-13px;padding-bottom:13px}.wp-pointer-left{padding-left:13px}.wp-pointer-right{margin-left:-13px;padding-right:13px}.wp-pointer-bottom .wp-pointer-arrow,.wp-pointer-top .wp-pointer-arrow,.wp-pointer-undefined .wp-pointer-arrow{right:50px}.wp-pointer-left .wp-pointer-arrow,.wp-pointer-right .wp-pointer-arrow{top:50%;margin-top:-15px}.wp-pointer-top .wp-pointer-arrow,.wp-pointer-undefined .wp-pointer-arrow{top:0;border-width:0 13px 13px;border-bottom-color:#3592b6}.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer-undefined .wp-pointer-arrow-inner{top:1px;margin-right:-13px;margin-top:-13px;border:13px solid transparent;border-bottom-color:#00a0d2;display:block;content:" "}.wp-pointer-bottom .wp-pointer-arrow{bottom:0;border-width:13px 13px 0;border-top-color:#ccc}.wp-pointer-bottom .wp-pointer-arrow-inner{bottom:1px;margin-right:-13px;margin-bottom:-13px;border:13px solid transparent;border-top-color:#fff;display:block;content:" "}.wp-pointer-left .wp-pointer-arrow{left:0;border-width:13px 13px 13px 0;border-right-color:#ccc}.wp-pointer-left .wp-pointer-arrow-inner{left:1px;margin-left:-13px;margin-top:-13px;border:13px solid transparent;border-right-color:#fff;display:block;content:" "}.wp-pointer-right .wp-pointer-arrow{right:0;border-width:13px 0 13px 13px;border-left-color:#ccc}.wp-pointer-right .wp-pointer-arrow-inner{right:1px;margin-right:-13px;margin-top:-13px;border:13px solid transparent;border-left-color:#fff;display:block;content:" "}.wp-pointer.arrow-bottom .wp-pointer-content{margin-bottom:-45px}.wp-pointer.arrow-bottom .wp-pointer-arrow{top:100%;margin-top:-30px}@media screen and (max-width:782px){.wp-pointer{display:none}} \ No newline at end of file diff --git a/backend/wp-includes/css/wp-pointer.css b/backend/wp-includes/css/wp-pointer.css new file mode 100644 index 0000000..f8d58be --- /dev/null +++ b/backend/wp-includes/css/wp-pointer.css @@ -0,0 +1,224 @@ +.wp-pointer-content { + padding: 0 0 10px; + position: relative; + font-size: 13px; + background: #fff; + border: 1px solid #ddd; + box-shadow: 0 3px 6px rgba(0,0,0,0.075); +} + +.wp-pointer-content h3 { + position: relative; + margin: -1px -1px 5px; + padding: 15px 18px 14px 60px; + border: 1px solid #3592b6; + border-bottom: none; + line-height: 1.4em; + font-size: 14px; + color: #fff; + background: #00a0d2; +} + +.wp-pointer-content h3:before { + background: #fff; + border-radius: 50%; + color: #00a0d2; + content: "\f227"; + font: normal 20px/1.6 dashicons; + position: absolute; + top: 8px; + left: 15px; + speak: none; + text-align: center; + width: 32px; + height: 32px; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.wp-pointer-content h4 { + margin: 1.33em 20px 1em; + font-size: 1.15em; +} + +.wp-pointer-content p { + padding: 0 20px; +} + +.wp-pointer-buttons { + margin: 0; + padding: 5px 15px; + overflow: auto; +} + +.wp-pointer-buttons a { + float: right; + display: inline-block; + text-decoration: none; +} + +.wp-pointer-buttons a.close { + padding-left: 3px; + position: relative; +} + +.wp-pointer-buttons a.close:before { + background: none; + color: #72777c; + content: "\f153"; + display: block !important; + font: normal 16px/1 dashicons; + speak: none; + margin: 1px 0; + text-align: center; + -webkit-font-smoothing: antialiased !important; + width: 10px; + height: 100%; + position: absolute; + left: -15px; + top: 1px; +} + +.wp-pointer-buttons a.close:hover:before { + color: #c00; +} + +/* The arrow base class must take up no space, even with transparent borders. */ +.wp-pointer-arrow, +.wp-pointer-arrow-inner { + position: absolute; + width: 0; + height: 0; +} + +.wp-pointer-arrow { + z-index: 10; + width: 0; + height: 0; + border: 0 solid transparent; +} + +.wp-pointer-arrow-inner { + z-index: 20; +} + +/* Make Room for the Arrow! */ +.wp-pointer-top, +.wp-pointer-undefined { + padding-top: 13px; +} + +.wp-pointer-bottom { + margin-top: -13px; + padding-bottom: 13px; +} + +/* rtl:ignore */ +.wp-pointer-left { + padding-left: 13px; +} +/* rtl:ignore */ +.wp-pointer-right { + margin-left: -13px; + padding-right: 13px; +} + +/* Base Size & Positioning */ +.wp-pointer-top .wp-pointer-arrow, +.wp-pointer-bottom .wp-pointer-arrow, +.wp-pointer-undefined .wp-pointer-arrow { + left: 50px; +} + +.wp-pointer-left .wp-pointer-arrow, +.wp-pointer-right .wp-pointer-arrow { + top: 50%; + margin-top: -15px; +} + +/* Arrow Sprite */ +.wp-pointer-top .wp-pointer-arrow, +.wp-pointer-undefined .wp-pointer-arrow { + top: 0; + border-width: 0 13px 13px 13px; + border-bottom-color: #3592b6; +} + +.wp-pointer-top .wp-pointer-arrow-inner, +.wp-pointer-undefined .wp-pointer-arrow-inner { + top: 1px; + margin-left: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-bottom-color: #00a0d2; + display: block; + content: " "; +} + +.wp-pointer-bottom .wp-pointer-arrow { + bottom: 0; + border-width: 13px 13px 0 13px; + border-top-color: #ccc; +} + +.wp-pointer-bottom .wp-pointer-arrow-inner { + bottom: 1px; + margin-left: -13px; + margin-bottom: -13px; + border: 13px solid transparent; + border-top-color: #fff; + display: block; + content: " "; +} + +/* rtl:ignore */ +.wp-pointer-left .wp-pointer-arrow { + left: 0; + border-width: 13px 13px 13px 0; + border-right-color: #ccc; +} + +/* rtl:ignore */ +.wp-pointer-left .wp-pointer-arrow-inner { + left: 1px; + margin-left: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-right-color: #fff; + display: block; + content: " "; +} + +/* rtl:ignore */ +.wp-pointer-right .wp-pointer-arrow { + right: 0; + border-width: 13px 0 13px 13px; + border-left-color: #ccc; +} + +/* rtl:ignore */ +.wp-pointer-right .wp-pointer-arrow-inner { + right: 1px; + margin-right: -13px; + margin-top: -13px; + border: 13px solid transparent; + border-left-color: #fff; + display: block; + content: " "; +} + +.wp-pointer.arrow-bottom .wp-pointer-content { + margin-bottom: -45px; +} + +.wp-pointer.arrow-bottom .wp-pointer-arrow { + top: 100%; + margin-top: -30px; +} + +/* Disable pointers at responsive sizes */ +@media screen and ( max-width: 782px ) { + .wp-pointer { + display: none; + } +} diff --git a/backend/wp-includes/css/wp-pointer.min.css b/backend/wp-includes/css/wp-pointer.min.css new file mode 100644 index 0000000..3c047e5 --- /dev/null +++ b/backend/wp-includes/css/wp-pointer.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-pointer-content{padding:0 0 10px;position:relative;font-size:13px;background:#fff;border:1px solid #ddd;box-shadow:0 3px 6px rgba(0,0,0,.075)}.wp-pointer-content h3{position:relative;margin:-1px -1px 5px;padding:15px 18px 14px 60px;border:1px solid #3592b6;border-bottom:none;line-height:1.4em;font-size:14px;color:#fff;background:#00a0d2}.wp-pointer-content h3:before{background:#fff;border-radius:50%;color:#00a0d2;content:"\f227";font:400 20px/1.6 dashicons;position:absolute;top:8px;left:15px;speak:none;text-align:center;width:32px;height:32px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wp-pointer-content h4{margin:1.33em 20px 1em;font-size:1.15em}.wp-pointer-content p{padding:0 20px}.wp-pointer-buttons{margin:0;padding:5px 15px;overflow:auto}.wp-pointer-buttons a{float:right;display:inline-block;text-decoration:none}.wp-pointer-buttons a.close{padding-left:3px;position:relative}.wp-pointer-buttons a.close:before{background:0 0;color:#72777c;content:"\f153";display:block!important;font:400 16px/1 dashicons;speak:none;margin:1px 0;text-align:center;-webkit-font-smoothing:antialiased!important;width:10px;height:100%;position:absolute;left:-15px;top:1px}.wp-pointer-buttons a.close:hover:before{color:#c00}.wp-pointer-arrow,.wp-pointer-arrow-inner{position:absolute;width:0;height:0}.wp-pointer-arrow{z-index:10;width:0;height:0;border:0 solid transparent}.wp-pointer-arrow-inner{z-index:20}.wp-pointer-top,.wp-pointer-undefined{padding-top:13px}.wp-pointer-bottom{margin-top:-13px;padding-bottom:13px}.wp-pointer-left{padding-left:13px}.wp-pointer-right{margin-left:-13px;padding-right:13px}.wp-pointer-bottom .wp-pointer-arrow,.wp-pointer-top .wp-pointer-arrow,.wp-pointer-undefined .wp-pointer-arrow{left:50px}.wp-pointer-left .wp-pointer-arrow,.wp-pointer-right .wp-pointer-arrow{top:50%;margin-top:-15px}.wp-pointer-top .wp-pointer-arrow,.wp-pointer-undefined .wp-pointer-arrow{top:0;border-width:0 13px 13px;border-bottom-color:#3592b6}.wp-pointer-top .wp-pointer-arrow-inner,.wp-pointer-undefined .wp-pointer-arrow-inner{top:1px;margin-left:-13px;margin-top:-13px;border:13px solid transparent;border-bottom-color:#00a0d2;display:block;content:" "}.wp-pointer-bottom .wp-pointer-arrow{bottom:0;border-width:13px 13px 0;border-top-color:#ccc}.wp-pointer-bottom .wp-pointer-arrow-inner{bottom:1px;margin-left:-13px;margin-bottom:-13px;border:13px solid transparent;border-top-color:#fff;display:block;content:" "}.wp-pointer-left .wp-pointer-arrow{left:0;border-width:13px 13px 13px 0;border-right-color:#ccc}.wp-pointer-left .wp-pointer-arrow-inner{left:1px;margin-left:-13px;margin-top:-13px;border:13px solid transparent;border-right-color:#fff;display:block;content:" "}.wp-pointer-right .wp-pointer-arrow{right:0;border-width:13px 0 13px 13px;border-left-color:#ccc}.wp-pointer-right .wp-pointer-arrow-inner{right:1px;margin-right:-13px;margin-top:-13px;border:13px solid transparent;border-left-color:#fff;display:block;content:" "}.wp-pointer.arrow-bottom .wp-pointer-content{margin-bottom:-45px}.wp-pointer.arrow-bottom .wp-pointer-arrow{top:100%;margin-top:-30px}@media screen and (max-width:782px){.wp-pointer{display:none}} \ No newline at end of file diff --git a/backend/wp-includes/customize/class-wp-customize-background-image-control.php b/backend/wp-includes/customize/class-wp-customize-background-image-control.php new file mode 100644 index 0000000..50956f8 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-background-image-control.php @@ -0,0 +1,51 @@ + __( 'Background Image' ), + 'section' => 'background_image', + ) ); + } + + /** + * Enqueue control related scripts/styles. + * + * @since 4.1.0 + */ + public function enqueue() { + parent::enqueue(); + + $custom_background = get_theme_support( 'custom-background' ); + wp_localize_script( 'customize-controls', '_wpCustomizeBackground', array( + 'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(), + 'nonces' => array( + 'add' => wp_create_nonce( 'background-add' ), + ), + ) ); + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-background-image-setting.php b/backend/wp-includes/customize/class-wp-customize-background-image-setting.php new file mode 100644 index 0000000..e7867d1 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-background-image-setting.php @@ -0,0 +1,28 @@ + array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ), + 'right top' => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), + array( + 'left center' => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ), + 'right center' => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), + array( + 'left bottom' => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ), + 'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ), + 'right bottom' => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ), + ), + ); + ?> + <# if ( data.label ) { #> + {{{ data.label }}} + <# } #> + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> +
      +
      + +
      + +
      + $input ) : ?> + + +
      + +
      +
      +
      + editor_settings = wp_enqueue_code_editor( array_merge( + array( + 'type' => $this->code_type, + 'codemirror' => array( + 'indentUnit' => 2, + 'tabSize' => 2, + ), + ), + $this->editor_settings + ) ); + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 4.9.0 + * @see WP_Customize_Control::json() + * + * @return array Array of parameters passed to the JavaScript. + */ + public function json() { + $json = parent::json(); + $json['editor_settings'] = $this->editor_settings; + $json['input_attrs'] = $this->input_attrs; + return $json; + } + + /** + * Don't render the control content from PHP, as it's rendered via JS on load. + * + * @since 4.9.0 + */ + public function render_content() {} + + /** + * Render a JS template for control display. + * + * @since 4.9.0 + */ + public function content_template() { + ?> + <# var elementIdPrefix = 'el' + String( Math.random() ); #> + <# if ( data.label ) { #> + + <# } #> + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> +
      + + statuses = array( '' => __('Default') ); + parent::__construct( $manager, $id, $args ); + } + + /** + * Enqueue scripts/styles for the color picker. + * + * @since 3.4.0 + */ + public function enqueue() { + wp_enqueue_script( 'wp-color-picker' ); + wp_enqueue_style( 'wp-color-picker' ); + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 3.4.0 + * @uses WP_Customize_Control::to_json() + */ + public function to_json() { + parent::to_json(); + $this->json['statuses'] = $this->statuses; + $this->json['defaultValue'] = $this->setting->default; + $this->json['mode'] = $this->mode; + } + + /** + * Don't render the control content from PHP, as it's rendered via JS on load. + * + * @since 3.4.0 + */ + public function render_content() {} + + /** + * Render a JS template for the content of the color picker control. + * + * @since 4.1.0 + */ + public function content_template() { + ?> + <# var defaultValue = '#RRGGBB', defaultValueAttr = '', + isHueSlider = data.mode === 'hue'; + if ( data.defaultValue && _.isString( data.defaultValue ) && ! isHueSlider ) { + if ( '#' !== data.defaultValue.substring( 0, 1 ) ) { + defaultValue = '#' + data.defaultValue; + } else { + defaultValue = data.defaultValue; + } + defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically. + } #> + <# if ( data.label ) { #> + {{{ data.label }}} + <# } #> + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> +
      + +
      + json['width'] = absint( $this->width ); + $this->json['height'] = absint( $this->height ); + $this->json['flex_width'] = absint( $this->flex_width ); + $this->json['flex_height'] = absint( $this->flex_height ); + } + +} diff --git a/backend/wp-includes/customize/class-wp-customize-custom-css-setting.php b/backend/wp-includes/customize/class-wp-customize-custom-css-setting.php new file mode 100644 index 0000000..7df3fb0 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -0,0 +1,199 @@ +id_data['base'] ) { + throw new Exception( 'Expected custom_css id_base.' ); + } + if ( 1 !== count( $this->id_data['keys'] ) || empty( $this->id_data['keys'][0] ) ) { + throw new Exception( 'Expected single stylesheet key.' ); + } + $this->stylesheet = $this->id_data['keys'][0]; + } + + /** + * Add filter to preview post value. + * + * @since 4.7.9 + * + * @return bool False when preview short-circuits due no change needing to be previewed. + */ + public function preview() { + if ( $this->is_previewed ) { + return false; + } + $this->is_previewed = true; + add_filter( 'wp_get_custom_css', array( $this, 'filter_previewed_wp_get_custom_css' ), 9, 2 ); + return true; + } + + /** + * Filter `wp_get_custom_css` for applying the customized value. + * + * This is used in the preview when `wp_get_custom_css()` is called for rendering the styles. + * + * @since 4.7.0 + * @see wp_get_custom_css() + * + * @param string $css Original CSS. + * @param string $stylesheet Current stylesheet. + * @return string CSS. + */ + public function filter_previewed_wp_get_custom_css( $css, $stylesheet ) { + if ( $stylesheet === $this->stylesheet ) { + $customized_value = $this->post_value( null ); + if ( ! is_null( $customized_value ) ) { + $css = $customized_value; + } + } + return $css; + } + + /** + * Fetch the value of the setting. Will return the previewed value when `preview()` is called. + * + * @since 4.7.0 + * @see WP_Customize_Setting::value() + * + * @return string + */ + public function value() { + if ( $this->is_previewed ) { + $post_value = $this->post_value( null ); + if ( null !== $post_value ) { + return $post_value; + } + } + $id_base = $this->id_data['base']; + $value = ''; + $post = wp_get_custom_css_post( $this->stylesheet ); + if ( $post ) { + $value = $post->post_content; + } + if ( empty( $value ) ) { + $value = $this->default; + } + + /** This filter is documented in wp-includes/class-wp-customize-setting.php */ + $value = apply_filters( "customize_value_{$id_base}", $value, $this ); + + return $value; + } + + /** + * Validate CSS. + * + * Checks for imbalanced braces, brackets, and comments. + * Notifications are rendered when the customizer state is saved. + * + * @since 4.7.0 + * @since 4.9.0 Checking for balanced characters has been moved client-side via linting in code editor. + * + * @param string $css The input string. + * @return true|WP_Error True if the input was validated, otherwise WP_Error. + */ + public function validate( $css ) { + $validity = new WP_Error(); + + if ( preg_match( '#add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) ); + } + + if ( empty( $validity->errors ) ) { + $validity = parent::validate( $css ); + } + return $validity; + } + + /** + * Store the CSS setting value in the custom_css custom post type for the stylesheet. + * + * @since 4.7.0 + * + * @param string $css The input value. + * @return int|false The post ID or false if the value could not be saved. + */ + public function update( $css ) { + if ( empty( $css ) ) { + $css = ''; + } + + $r = wp_update_custom_css_post( $css, array( + 'stylesheet' => $this->stylesheet, + ) ); + + if ( $r instanceof WP_Error ) { + return false; + } + $post_id = $r->ID; + + // Cache post ID in theme mod for performance to avoid additional DB query. + if ( $this->manager->get_stylesheet() === $this->stylesheet ) { + set_theme_mod( 'custom_css_post_id', $post_id ); + } + + return $post_id; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-date-time-control.php b/backend/wp-includes/customize/class-wp-customize-date-time-control.php new file mode 100644 index 0000000..fdaa683 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-date-time-control.php @@ -0,0 +1,271 @@ +max_year ); + $data['minYear'] = intval( $this->min_year ); + $data['allowPastDate'] = (bool) $this->allow_past_date; + $data['twelveHourFormat'] = (bool) $this->twelve_hour_format; + $data['includeTime'] = (bool) $this->include_time; + + return $data; + } + + /** + * Renders a JS template for the content of date time control. + * + * @since 4.9.0 + */ + public function content_template() { + $data = array_merge( $this->json(), $this->get_month_choices() ); + $timezone_info = $this->get_timezone_info(); + + $date_format = get_option( 'date_format' ); + $date_format = preg_replace( '/(? + + <# _.defaults( data, ); #> + <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> + + <# if ( data.label ) { #> + + {{ data.label }} + + <# } #> +
      + <# if ( data.description ) { #> + {{ data.description }} + <# } #> +
      +
      + +
      + + + + + + + + + + + + + + + + +
      +
      + <# if ( data.includeTime ) { #> +
      + +
      + + <# var maxHour = data.twelveHourFormat ? 12 : 23; #> + <# var minHour = data.twelveHourFormat ? 1 : 0; #> + + : + + + <# if ( data.twelveHourFormat ) { #> + + + <# } #> + +
      +
      + <# } #> +
      + get_month_abbrev( $wp_locale->get_month( $i ) ); + + /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ + $months[ $i ]['text'] = sprintf( __( '%1$s-%2$s' ), $i, $month_text ); + $months[ $i ]['value'] = $i; + } + return array( + 'month_choices' => $months, + ); + } + + /** + * Get timezone info. + * + * @since 4.9.0 + * + * @return array abbr and description. + */ + public function get_timezone_info() { + $tz_string = get_option( 'timezone_string' ); + $timezone_info = array(); + + if ( $tz_string ) { + try { + $tz = new DateTimezone( $tz_string ); + } catch ( Exception $e ) { + $tz = ''; + } + + if ( $tz ) { + $now = new DateTime( 'now', $tz ); + $formatted_gmt_offset = sprintf( 'UTC%s', $this->format_gmt_offset( $tz->getOffset( $now ) / 3600 ) ); + $tz_name = str_replace( '_', ' ', $tz->getName() ); + $timezone_info['abbr'] = $now->format( 'T' ); + + /* translators: 1: timezone name, 2: timezone abbreviation, 3: gmt offset */ + $timezone_info['description'] = sprintf( __( 'Timezone is %1$s (%2$s), currently %3$s.' ), $tz_name, $timezone_info['abbr'], $formatted_gmt_offset ); + } else { + $timezone_info['description'] = ''; + } + } else { + $formatted_gmt_offset = $this->format_gmt_offset( intval( get_option( 'gmt_offset', 0 ) ) ); + $timezone_info['abbr'] = sprintf( 'UTC%s', $formatted_gmt_offset ); + + /* translators: %s: UTC offset */ + $timezone_info['description'] = sprintf( __( 'Timezone is %s.' ), $timezone_info['abbr'] ); + } + + return $timezone_info; + } + + /** + * Format GMT Offset. + * + * @since 4.9.0 + * @see wp_timezone_choice() + * + * @param float $offset Offset in hours. + * @return string Formatted offset. + */ + public function format_gmt_offset( $offset ) { + if ( 0 <= $offset ) { + $formatted_offset = '+' . (string) $offset; + } else { + $formatted_offset = (string) $offset; + } + $formatted_offset = str_replace( + array( '.25', '.5', '.75' ), + array( ':15', ':30', ':45' ), + $formatted_offset + ); + return $formatted_offset; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-filter-setting.php b/backend/wp-includes/customize/class-wp-customize-filter-setting.php new file mode 100644 index 0000000..ad70f4f --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-filter-setting.php @@ -0,0 +1,29 @@ + __( 'Header Image' ), + 'settings' => array( + 'default' => 'header_image', + 'data' => 'header_image_data', + ), + 'section' => 'header_image', + 'removed' => 'remove-header', + 'get_url' => 'get_header_image', + ) ); + + } + + /** + */ + public function enqueue() { + wp_enqueue_media(); + wp_enqueue_script( 'customize-views' ); + + $this->prepare_control(); + + wp_localize_script( 'customize-views', '_wpCustomizeHeader', array( + 'data' => array( + 'width' => absint( get_theme_support( 'custom-header', 'width' ) ), + 'height' => absint( get_theme_support( 'custom-header', 'height' ) ), + 'flex-width' => absint( get_theme_support( 'custom-header', 'flex-width' ) ), + 'flex-height' => absint( get_theme_support( 'custom-header', 'flex-height' ) ), + 'currentImgSrc' => $this->get_current_image_src(), + ), + 'nonces' => array( + 'add' => wp_create_nonce( 'header-add' ), + 'remove' => wp_create_nonce( 'header-remove' ), + ), + 'uploads' => $this->uploaded_headers, + 'defaults' => $this->default_headers + ) ); + + parent::enqueue(); + } + + /** + * + * @global Custom_Image_Header $custom_image_header + */ + public function prepare_control() { + global $custom_image_header; + if ( empty( $custom_image_header ) ) { + return; + } + + add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_header_image_template' ) ); + + // Process default headers and uploaded headers. + $custom_image_header->process_default_headers(); + $this->default_headers = $custom_image_header->get_default_header_images(); + $this->uploaded_headers = $custom_image_header->get_uploaded_header_images(); + } + + /** + */ + public function print_header_image_template() { + ?> + + + + value(); + if ( isset( $this->get_url ) ) { + $src = call_user_func( $this->get_url, $src ); + return $src; + } + } + + /** + */ + public function render_content() { + $visibility = $this->get_current_image_src() ? '' : ' style="display:none" '; + $width = absint( get_theme_support( 'custom-header', 'width' ) ); + $height = absint( get_theme_support( 'custom-header', 'height' ) ); + ?> +
      + ' . $this->label . ''; + } ?> +
      +

      + %s × %s', $width, $height ) + ); + } elseif ( $width ) { + /* translators: %s: header width in pixels */ + printf( __( 'Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels — you’ll be able to crop your image once you upload it for a perfect fit.' ), + sprintf( '%s', $width ) + ); + } else { + /* translators: %s: header height in pixels */ + printf( __( 'Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels — you’ll be able to crop your image once you upload it for a perfect fit.' ), + sprintf( '%s', $height ) + ); + } + ?> +

      +
      + +
      +
      +
      +
      + + + + +
      +
      + + + +
      +
      +
      +
      + + + +
      +
      +
      +
      +
      +
      + manager->get_setting('header_image')->post_value(); + + if ( is_array( $value ) && isset( $value['choice'] ) ) + $custom_image_header->set_header_image( $value['choice'] ); + else + $custom_image_header->set_header_image( $value ); + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-image-control.php b/backend/wp-includes/customize/class-wp-customize-image-control.php new file mode 100644 index 0000000..d056f8b --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-image-control.php @@ -0,0 +1,59 @@ +button_labels = wp_parse_args( $this->button_labels, $this->get_default_button_labels() ); + } + + /** + * Enqueue control related scripts/styles. + * + * @since 3.4.0 + * @since 4.2.0 Moved from WP_Customize_Upload_Control. + */ + public function enqueue() { + wp_enqueue_media(); + } + + /** + * Refresh the parameters passed to the JavaScript via JSON. + * + * @since 3.4.0 + * @since 4.2.0 Moved from WP_Customize_Upload_Control. + * + * @see WP_Customize_Control::to_json() + */ + public function to_json() { + parent::to_json(); + $this->json['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) ); + $this->json['mime_type'] = $this->mime_type; + $this->json['button_labels'] = $this->button_labels; + $this->json['canUpload'] = current_user_can( 'upload_files' ); + + $value = $this->value(); + + if ( is_object( $this->setting ) ) { + if ( $this->setting->default ) { + // Fake an attachment model - needs all fields used by template. + // Note that the default value must be a URL, NOT an attachment ID. + $type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document'; + $default_attachment = array( + 'id' => 1, + 'url' => $this->setting->default, + 'type' => $type, + 'icon' => wp_mime_type_icon( $type ), + 'title' => basename( $this->setting->default ), + ); + + if ( 'image' === $type ) { + $default_attachment['sizes'] = array( + 'full' => array( 'url' => $this->setting->default ), + ); + } + + $this->json['defaultAttachment'] = $default_attachment; + } + + if ( $value && $this->setting->default && $value === $this->setting->default ) { + // Set the default as the attachment. + $this->json['attachment'] = $this->json['defaultAttachment']; + } elseif ( $value ) { + $this->json['attachment'] = wp_prepare_attachment_for_js( $value ); + } + } + } + + /** + * Don't render any content for this control from PHP. + * + * @since 3.4.0 + * @since 4.2.0 Moved from WP_Customize_Upload_Control. + * + * @see WP_Customize_Media_Control::content_template() + */ + public function render_content() {} + + /** + * Render a JS template for the content of the media control. + * + * @since 4.1.0 + * @since 4.2.0 Moved from WP_Customize_Upload_Control. + */ + public function content_template() { + ?> + <# + var selectButtonId = _.uniqueId( 'customize-media-control-button-' ); + var descriptionId = _.uniqueId( 'customize-media-control-description-' ); + var describedByAttr = data.description ? ' aria-describedby="' + descriptionId + '" ' : ''; + #> + <# if ( data.label ) { #> + + <# } #> +
      + <# if ( data.description ) { #> + {{{ data.description }}} + <# } #> + + <# if ( data.attachment && data.attachment.id ) { #> +
      +
      + <# if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.medium ) { #> + + <# } else if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.full ) { #> + + <# } else if ( 'audio' === data.attachment.type ) { #> + <# if ( data.attachment.image && data.attachment.image.src && data.attachment.image.src !== data.attachment.icon ) { #> + + <# } else { #> + + <# } #> +

      “{{ data.attachment.title }}”

      + <# if ( data.attachment.album || data.attachment.meta.album ) { #> +

      {{ data.attachment.album || data.attachment.meta.album }}

      + <# } #> + <# if ( data.attachment.artist || data.attachment.meta.artist ) { #> +

      {{ data.attachment.artist || data.attachment.meta.artist }}

      + <# } #> + + <# } else if ( 'video' === data.attachment.type ) { #> +
      + +
      + <# } else { #> + +

      {{ data.attachment.title }}

      + <# } #> +
      +
      + <# if ( data.canUpload ) { #> + + + <# } #> +
      +
      + <# } else { #> +
      +
      + {{ data.button_labels.placeholder }} +
      +
      + <# if ( data.defaultAttachment ) { #> + + <# } #> + <# if ( data.canUpload ) { #> + + <# } #> +
      +
      + <# } #> + mime_type ) ? strtok( ltrim( $this->mime_type, '/' ), '/' ) : 'default'; + + switch ( $mime_type ) { + case 'video': + return array( + 'select' => __( 'Select video' ), + 'change' => __( 'Change video' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No video selected' ), + 'frame_title' => __( 'Select video' ), + 'frame_button' => __( 'Choose video' ), + ); + case 'audio': + return array( + 'select' => __( 'Select audio' ), + 'change' => __( 'Change audio' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No audio selected' ), + 'frame_title' => __( 'Select audio' ), + 'frame_button' => __( 'Choose audio' ), + ); + case 'image': + return array( + 'select' => __( 'Select image' ), + 'change' => __( 'Change image' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No image selected' ), + 'frame_title' => __( 'Select image' ), + 'frame_button' => __( 'Choose image' ), + ); + default: + return array( + 'select' => __( 'Select file' ), + 'change' => __( 'Change file' ), + 'default' => __( 'Default' ), + 'remove' => __( 'Remove' ), + 'placeholder' => __( 'No file selected' ), + 'frame_title' => __( 'Select file' ), + 'frame_button' => __( 'Choose file' ), + ); + } // End switch(). + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php b/backend/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php new file mode 100644 index 0000000..c47fed4 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menu-auto-add-control.php @@ -0,0 +1,51 @@ + + <# var elementId = _.uniqueId( 'customize-nav-menu-auto-add-control-' ); #> + + + + + + +

      + +

      +
      + + +
      +

      + setting->term_id; + + return $exported; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menu-item-control.php b/backend/wp-includes/customize/class-wp-customize-nav-menu-item-control.php new file mode 100644 index 0000000..424c8ba --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menu-item-control.php @@ -0,0 +1,162 @@ + + + + + + setting->post_id; + + return $exported; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/backend/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php new file mode 100644 index 0000000..b3a9954 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -0,0 +1,889 @@ +-?\d+)\]$/'; + + const POST_TYPE = 'nav_menu_item'; + + const TYPE = 'nav_menu_item'; + + /** + * Setting type. + * + * @since 4.3.0 + * @var string + */ + public $type = self::TYPE; + + /** + * Default setting value. + * + * @since 4.3.0 + * @var array + * + * @see wp_setup_nav_menu_item() + */ + public $default = array( + // The $menu_item_data for wp_update_nav_menu_item(). + 'object_id' => 0, + 'object' => '', // Taxonomy name. + 'menu_item_parent' => 0, // A.K.A. menu-item-parent-id; note that post_parent is different, and not included. + 'position' => 0, // A.K.A. menu_order. + 'type' => 'custom', // Note that type_label is not included here. + 'title' => '', + 'url' => '', + 'target' => '', + 'attr_title' => '', + 'description' => '', + 'classes' => '', + 'xfn' => '', + 'status' => 'publish', + 'original_title' => '', + 'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item(). + '_invalid' => false, + ); + + /** + * Default transport. + * + * @since 4.3.0 + * @since 4.5.0 Default changed to 'refresh' + * @var string + */ + public $transport = 'refresh'; + + /** + * The post ID represented by this setting instance. This is the db_id. + * + * A negative value represents a placeholder ID for a new menu not yet saved. + * + * @since 4.3.0 + * @var int + */ + public $post_id; + + /** + * Storage of pre-setup menu item to prevent wasted calls to wp_setup_nav_menu_item(). + * + * @since 4.3.0 + * @var array + */ + protected $value; + + /** + * Previous (placeholder) post ID used before creating a new menu item. + * + * This value will be exported to JS via the customize_save_response filter + * so that JavaScript can update the settings to refer to the newly-assigned + * post ID. This value is always negative to indicate it does not refer to + * a real post. + * + * @since 4.3.0 + * @var int + * + * @see WP_Customize_Nav_Menu_Item_Setting::update() + * @see WP_Customize_Nav_Menu_Item_Setting::amend_customize_save_response() + */ + public $previous_post_id; + + /** + * When previewing or updating a menu item, this stores the previous nav_menu_term_id + * which ensures that we can apply the proper filters. + * + * @since 4.3.0 + * @var int + */ + public $original_nav_menu_term_id; + + /** + * Whether or not update() was called. + * + * @since 4.3.0 + * @var bool + */ + protected $is_updated = false; + + /** + * Status for calling the update method, used in customize_save_response filter. + * + * See {@see 'customize_save_response'}. + * + * When status is inserted, the placeholder post ID is stored in $previous_post_id. + * When status is error, the error is stored in $update_error. + * + * @since 4.3.0 + * @var string updated|inserted|deleted|error + * + * @see WP_Customize_Nav_Menu_Item_Setting::update() + * @see WP_Customize_Nav_Menu_Item_Setting::amend_customize_save_response() + */ + public $update_status; + + /** + * Any error object returned by wp_update_nav_menu_item() when setting is updated. + * + * @since 4.3.0 + * @var WP_Error + * + * @see WP_Customize_Nav_Menu_Item_Setting::update() + * @see WP_Customize_Nav_Menu_Item_Setting::amend_customize_save_response() + */ + public $update_error; + + /** + * Constructor. + * + * Any supplied $args override class property defaults. + * + * @since 4.3.0 + * + * @param WP_Customize_Manager $manager Bootstrap Customizer instance. + * @param string $id An specific ID of the setting. Can be a + * theme mod or option name. + * @param array $args Optional. Setting arguments. + * + * @throws Exception If $id is not valid for this setting type. + */ + public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) { + if ( empty( $manager->nav_menus ) ) { + throw new Exception( 'Expected WP_Customize_Manager::$nav_menus to be set.' ); + } + + if ( ! preg_match( self::ID_PATTERN, $id, $matches ) ) { + throw new Exception( "Illegal widget setting ID: $id" ); + } + + $this->post_id = intval( $matches['id'] ); + add_action( 'wp_update_nav_menu_item', array( $this, 'flush_cached_value' ), 10, 2 ); + + parent::__construct( $manager, $id, $args ); + + // Ensure that an initially-supplied value is valid. + if ( isset( $this->value ) ) { + $this->populate_value(); + foreach ( array_diff( array_keys( $this->default ), array_keys( $this->value ) ) as $missing ) { + throw new Exception( "Supplied nav_menu_item value missing property: $missing" ); + } + } + + } + + /** + * Clear the cached value when this nav menu item is updated. + * + * @since 4.3.0 + * + * @param int $menu_id The term ID for the menu. + * @param int $menu_item_id The post ID for the menu item. + */ + public function flush_cached_value( $menu_id, $menu_item_id ) { + unset( $menu_id ); + if ( $menu_item_id === $this->post_id ) { + $this->value = null; + } + } + + /** + * Get the instance data for a given nav_menu_item setting. + * + * @since 4.3.0 + * + * @see wp_setup_nav_menu_item() + * + * @return array|false Instance data array, or false if the item is marked for deletion. + */ + public function value() { + if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) { + $undefined = new stdClass(); // Symbol. + $post_value = $this->post_value( $undefined ); + + if ( $undefined === $post_value ) { + $value = $this->_original_value; + } else { + $value = $post_value; + } + if ( ! empty( $value ) && empty( $value['original_title'] ) ) { + $value['original_title'] = $this->get_original_title( (object) $value ); + } + } elseif ( isset( $this->value ) ) { + $value = $this->value; + } else { + $value = false; + + // Note that a ID of less than one indicates a nav_menu not yet inserted. + if ( $this->post_id > 0 ) { + $post = get_post( $this->post_id ); + if ( $post && self::POST_TYPE === $post->post_type ) { + $is_title_empty = empty( $post->post_title ); + $value = (array) wp_setup_nav_menu_item( $post ); + if ( $is_title_empty ) { + $value['title'] = ''; + } + } + } + + if ( ! is_array( $value ) ) { + $value = $this->default; + } + + // Cache the value for future calls to avoid having to re-call wp_setup_nav_menu_item(). + $this->value = $value; + $this->populate_value(); + $value = $this->value; + } + + if ( ! empty( $value ) && empty( $value['type_label'] ) ) { + $value['type_label'] = $this->get_type_label( (object) $value ); + } + + return $value; + } + + /** + * Get original title. + * + * @since 4.7.0 + * + * @param object $item Nav menu item. + * @return string The original title. + */ + protected function get_original_title( $item ) { + $original_title = ''; + if ( 'post_type' === $item->type && ! empty( $item->object_id ) ) { + $original_object = get_post( $item->object_id ); + if ( $original_object ) { + /** This filter is documented in wp-includes/post-template.php */ + $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID ); + + if ( '' === $original_title ) { + /* translators: %d: ID of a post */ + $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID ); + } + } + } elseif ( 'taxonomy' === $item->type && ! empty( $item->object_id ) ) { + $original_term_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); + if ( ! is_wp_error( $original_term_title ) ) { + $original_title = $original_term_title; + } + } elseif ( 'post_type_archive' === $item->type ) { + $original_object = get_post_type_object( $item->object ); + if ( $original_object ) { + $original_title = $original_object->labels->archives; + } + } + $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) ); + return $original_title; + } + + /** + * Get type label. + * + * @since 4.7.0 + * + * @param object $item Nav menu item. + * @returns string The type label. + */ + protected function get_type_label( $item ) { + if ( 'post_type' === $item->type ) { + $object = get_post_type_object( $item->object ); + if ( $object ) { + $type_label = $object->labels->singular_name; + } else { + $type_label = $item->object; + } + } elseif ( 'taxonomy' === $item->type ) { + $object = get_taxonomy( $item->object ); + if ( $object ) { + $type_label = $object->labels->singular_name; + } else { + $type_label = $item->object; + } + } elseif ( 'post_type_archive' === $item->type ) { + $type_label = __( 'Post Type Archive' ); + } else { + $type_label = __( 'Custom Link' ); + } + return $type_label; + } + + /** + * Ensure that the value is fully populated with the necessary properties. + * + * Translates some properties added by wp_setup_nav_menu_item() and removes others. + * + * @since 4.3.0 + * + * @see WP_Customize_Nav_Menu_Item_Setting::value() + */ + protected function populate_value() { + if ( ! is_array( $this->value ) ) { + return; + } + + if ( isset( $this->value['menu_order'] ) ) { + $this->value['position'] = $this->value['menu_order']; + unset( $this->value['menu_order'] ); + } + if ( isset( $this->value['post_status'] ) ) { + $this->value['status'] = $this->value['post_status']; + unset( $this->value['post_status'] ); + } + + if ( ! isset( $this->value['original_title'] ) ) { + $this->value['original_title'] = $this->get_original_title( (object) $this->value ); + } + + if ( ! isset( $this->value['nav_menu_term_id'] ) && $this->post_id > 0 ) { + $menus = wp_get_post_terms( $this->post_id, WP_Customize_Nav_Menu_Setting::TAXONOMY, array( + 'fields' => 'ids', + ) ); + if ( ! empty( $menus ) ) { + $this->value['nav_menu_term_id'] = array_shift( $menus ); + } else { + $this->value['nav_menu_term_id'] = 0; + } + } + + foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { + if ( ! is_int( $this->value[ $key ] ) ) { + $this->value[ $key ] = intval( $this->value[ $key ] ); + } + } + foreach ( array( 'classes', 'xfn' ) as $key ) { + if ( is_array( $this->value[ $key ] ) ) { + $this->value[ $key ] = implode( ' ', $this->value[ $key ] ); + } + } + + if ( ! isset( $this->value['title'] ) ) { + $this->value['title'] = ''; + } + + if ( ! isset( $this->value['_invalid'] ) ) { + $this->value['_invalid'] = false; + $is_known_invalid = ( + ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) ) + || + ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) ) + ); + if ( $is_known_invalid ) { + $this->value['_invalid'] = true; + } + } + + // Remove remaining properties available on a setup nav_menu_item post object which aren't relevant to the setting value. + $irrelevant_properties = array( + 'ID', + 'comment_count', + 'comment_status', + 'db_id', + 'filter', + 'guid', + 'ping_status', + 'pinged', + 'post_author', + 'post_content', + 'post_content_filtered', + 'post_date', + 'post_date_gmt', + 'post_excerpt', + 'post_mime_type', + 'post_modified', + 'post_modified_gmt', + 'post_name', + 'post_parent', + 'post_password', + 'post_title', + 'post_type', + 'to_ping', + ); + foreach ( $irrelevant_properties as $property ) { + unset( $this->value[ $property ] ); + } + } + + /** + * Handle previewing the setting. + * + * @since 4.3.0 + * @since 4.4.0 Added boolean return value. + * + * @see WP_Customize_Manager::post_value() + * + * @return bool False if method short-circuited due to no-op. + */ + public function preview() { + if ( $this->is_previewed ) { + return false; + } + + $undefined = new stdClass(); + $is_placeholder = ( $this->post_id < 0 ); + $is_dirty = ( $undefined !== $this->post_value( $undefined ) ); + if ( ! $is_placeholder && ! $is_dirty ) { + return false; + } + + $this->is_previewed = true; + $this->_original_value = $this->value(); + $this->original_nav_menu_term_id = $this->_original_value['nav_menu_term_id']; + $this->_previewed_blog_id = get_current_blog_id(); + + add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_wp_get_nav_menu_items' ), 10, 3 ); + + $sort_callback = array( __CLASS__, 'sort_wp_get_nav_menu_items' ); + if ( ! has_filter( 'wp_get_nav_menu_items', $sort_callback ) ) { + add_filter( 'wp_get_nav_menu_items', array( __CLASS__, 'sort_wp_get_nav_menu_items' ), 1000, 3 ); + } + + // @todo Add get_post_metadata filters for plugins to add their data. + + return true; + } + + /** + * Filters the wp_get_nav_menu_items() result to supply the previewed menu items. + * + * @since 4.3.0 + * + * @see wp_get_nav_menu_items() + * + * @param array $items An array of menu item post objects. + * @param object $menu The menu object. + * @param array $args An array of arguments used to retrieve menu item objects. + * @return array Array of menu items, + */ + public function filter_wp_get_nav_menu_items( $items, $menu, $args ) { + $this_item = $this->value(); + $current_nav_menu_term_id = $this_item['nav_menu_term_id']; + unset( $this_item['nav_menu_term_id'] ); + + $should_filter = ( + $menu->term_id === $this->original_nav_menu_term_id + || + $menu->term_id === $current_nav_menu_term_id + ); + if ( ! $should_filter ) { + return $items; + } + + // Handle deleted menu item, or menu item moved to another menu. + $should_remove = ( + false === $this_item + || + true === $this_item['_invalid'] + || + ( + $this->original_nav_menu_term_id === $menu->term_id + && + $current_nav_menu_term_id !== $this->original_nav_menu_term_id + ) + ); + if ( $should_remove ) { + $filtered_items = array(); + foreach ( $items as $item ) { + if ( $item->db_id !== $this->post_id ) { + $filtered_items[] = $item; + } + } + return $filtered_items; + } + + $mutated = false; + $should_update = ( + is_array( $this_item ) + && + $current_nav_menu_term_id === $menu->term_id + ); + if ( $should_update ) { + foreach ( $items as $item ) { + if ( $item->db_id === $this->post_id ) { + foreach ( get_object_vars( $this->value_as_wp_post_nav_menu_item() ) as $key => $value ) { + $item->$key = $value; + } + $mutated = true; + } + } + + // Not found so we have to append it.. + if ( ! $mutated ) { + $items[] = $this->value_as_wp_post_nav_menu_item(); + } + } + + return $items; + } + + /** + * Re-apply the tail logic also applied on $items by wp_get_nav_menu_items(). + * + * @since 4.3.0 + * @static + * + * @see wp_get_nav_menu_items() + * + * @param array $items An array of menu item post objects. + * @param object $menu The menu object. + * @param array $args An array of arguments used to retrieve menu item objects. + * @return array Array of menu items, + */ + public static function sort_wp_get_nav_menu_items( $items, $menu, $args ) { + // @todo We should probably re-apply some constraints imposed by $args. + unset( $args['include'] ); + + // Remove invalid items only in front end. + if ( ! is_admin() ) { + $items = array_filter( $items, '_is_valid_nav_menu_item' ); + } + + if ( ARRAY_A === $args['output'] ) { + $items = wp_list_sort( $items, array( + $args['output_key'] => 'ASC', + ) ); + $i = 1; + + foreach ( $items as $k => $item ) { + $items[ $k ]->{$args['output_key']} = $i++; + } + } + + return $items; + } + + /** + * Get the value emulated into a WP_Post and set up as a nav_menu_item. + * + * @since 4.3.0 + * + * @return WP_Post With wp_setup_nav_menu_item() applied. + */ + public function value_as_wp_post_nav_menu_item() { + $item = (object) $this->value(); + unset( $item->nav_menu_term_id ); + + $item->post_status = $item->status; + unset( $item->status ); + + $item->post_type = 'nav_menu_item'; + $item->menu_order = $item->position; + unset( $item->position ); + + if ( empty( $item->original_title ) ) { + $item->original_title = $this->get_original_title( $item ); + } + if ( empty( $item->title ) && ! empty( $item->original_title ) ) { + $item->title = $item->original_title; + } + if ( $item->title ) { + $item->post_title = $item->title; + } + + $item->ID = $this->post_id; + $item->db_id = $this->post_id; + $post = new WP_Post( (object) $item ); + + if ( empty( $post->post_author ) ) { + $post->post_author = get_current_user_id(); + } + + if ( ! isset( $post->type_label ) ) { + $post->type_label = $this->get_type_label( $post ); + } + + // Ensure nav menu item URL is set according to linked object. + if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) { + $post->url = get_permalink( $post->object_id ); + } elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) { + $post->url = get_term_link( (int) $post->object_id, $post->object ); + } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) { + $post->url = get_post_type_archive_link( $post->object ); + } + if ( is_wp_error( $post->url ) ) { + $post->url = ''; + } + + /** This filter is documented in wp-includes/nav-menu.php */ + $post->attr_title = apply_filters( 'nav_menu_attr_title', $post->attr_title ); + + /** This filter is documented in wp-includes/nav-menu.php */ + $post->description = apply_filters( 'nav_menu_description', wp_trim_words( $post->description, 200 ) ); + + /** This filter is documented in wp-includes/nav-menu.php */ + $post = apply_filters( 'wp_setup_nav_menu_item', $post ); + + return $post; + } + + /** + * Sanitize an input. + * + * Note that parent::sanitize() erroneously does wp_unslash() on $value, but + * we remove that in this override. + * + * @since 4.3.0 + * + * @param array $menu_item_value The value to sanitize. + * @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion. + * Otherwise the sanitized value. + */ + public function sanitize( $menu_item_value ) { + // Menu is marked for deletion. + if ( false === $menu_item_value ) { + return $menu_item_value; + } + + // Invalid. + if ( ! is_array( $menu_item_value ) ) { + return null; + } + + $default = array( + 'object_id' => 0, + 'object' => '', + 'menu_item_parent' => 0, + 'position' => 0, + 'type' => 'custom', + 'title' => '', + 'url' => '', + 'target' => '', + 'attr_title' => '', + 'description' => '', + 'classes' => '', + 'xfn' => '', + 'status' => 'publish', + 'original_title' => '', + 'nav_menu_term_id' => 0, + '_invalid' => false, + ); + $menu_item_value = array_merge( $default, $menu_item_value ); + $menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) ); + $menu_item_value['position'] = intval( $menu_item_value['position'] ); + + foreach ( array( 'object_id', 'menu_item_parent', 'nav_menu_term_id' ) as $key ) { + // Note we need to allow negative-integer IDs for previewed objects not inserted yet. + $menu_item_value[ $key ] = intval( $menu_item_value[ $key ] ); + } + + foreach ( array( 'type', 'object', 'target' ) as $key ) { + $menu_item_value[ $key ] = sanitize_key( $menu_item_value[ $key ] ); + } + + foreach ( array( 'xfn', 'classes' ) as $key ) { + $value = $menu_item_value[ $key ]; + if ( ! is_array( $value ) ) { + $value = explode( ' ', $value ); + } + $menu_item_value[ $key ] = implode( ' ', array_map( 'sanitize_html_class', $value ) ); + } + + $menu_item_value['original_title'] = sanitize_text_field( $menu_item_value['original_title'] ); + + // Apply the same filters as when calling wp_insert_post(). + + /** This filter is documented in wp-includes/post.php */ + $menu_item_value['title'] = wp_unslash( apply_filters( 'title_save_pre', wp_slash( $menu_item_value['title'] ) ) ); + + /** This filter is documented in wp-includes/post.php */ + $menu_item_value['attr_title'] = wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $menu_item_value['attr_title'] ) ) ); + + /** This filter is documented in wp-includes/post.php */ + $menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) ); + + if ( '' !== $menu_item_value['url'] ) { + $menu_item_value['url'] = esc_url_raw( $menu_item_value['url'] ); + if ( '' === $menu_item_value['url'] ) { + return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); // Fail sanitization if URL is invalid. + } + } + if ( 'publish' !== $menu_item_value['status'] ) { + $menu_item_value['status'] = 'draft'; + } + + $menu_item_value['_invalid'] = (bool) $menu_item_value['_invalid']; + + /** This filter is documented in wp-includes/class-wp-customize-setting.php */ + return apply_filters( "customize_sanitize_{$this->id}", $menu_item_value, $this ); + } + + /** + * Creates/updates the nav_menu_item post for this setting. + * + * Any created menu items will have their assigned post IDs exported to the client + * via the {@see 'customize_save_response'} filter. Likewise, any errors will be + * exported to the client via the customize_save_response() filter. + * + * To delete a menu, the client can send false as the value. + * + * @since 4.3.0 + * + * @see wp_update_nav_menu_item() + * + * @param array|false $value The menu item array to update. If false, then the menu item will be deleted + * entirely. See WP_Customize_Nav_Menu_Item_Setting::$default for what the value + * should consist of. + * @return null|void + */ + protected function update( $value ) { + if ( $this->is_updated ) { + return; + } + + $this->is_updated = true; + $is_placeholder = ( $this->post_id < 0 ); + $is_delete = ( false === $value ); + + // Update the cached value. + $this->value = $value; + + add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) ); + + if ( $is_delete ) { + // If the current setting post is a placeholder, a delete request is a no-op. + if ( $is_placeholder ) { + $this->update_status = 'deleted'; + } else { + $r = wp_delete_post( $this->post_id, true ); + + if ( false === $r ) { + $this->update_error = new WP_Error( 'delete_failure' ); + $this->update_status = 'error'; + } else { + $this->update_status = 'deleted'; + } + // @todo send back the IDs for all associated nav menu items deleted, so these settings (and controls) can be removed from Customizer? + } + } else { + + // Handle saving menu items for menus that are being newly-created. + if ( $value['nav_menu_term_id'] < 0 ) { + $nav_menu_setting_id = sprintf( 'nav_menu[%s]', $value['nav_menu_term_id'] ); + $nav_menu_setting = $this->manager->get_setting( $nav_menu_setting_id ); + + if ( ! $nav_menu_setting || ! ( $nav_menu_setting instanceof WP_Customize_Nav_Menu_Setting ) ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'unexpected_nav_menu_setting' ); + return; + } + + if ( false === $nav_menu_setting->save() ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'nav_menu_setting_failure' ); + return; + } + + if ( $nav_menu_setting->previous_term_id !== intval( $value['nav_menu_term_id'] ) ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'unexpected_previous_term_id' ); + return; + } + + $value['nav_menu_term_id'] = $nav_menu_setting->term_id; + } + + // Handle saving a nav menu item that is a child of a nav menu item being newly-created. + if ( $value['menu_item_parent'] < 0 ) { + $parent_nav_menu_item_setting_id = sprintf( 'nav_menu_item[%s]', $value['menu_item_parent'] ); + $parent_nav_menu_item_setting = $this->manager->get_setting( $parent_nav_menu_item_setting_id ); + + if ( ! $parent_nav_menu_item_setting || ! ( $parent_nav_menu_item_setting instanceof WP_Customize_Nav_Menu_Item_Setting ) ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'unexpected_nav_menu_item_setting' ); + return; + } + + if ( false === $parent_nav_menu_item_setting->save() ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'nav_menu_item_setting_failure' ); + return; + } + + if ( $parent_nav_menu_item_setting->previous_post_id !== intval( $value['menu_item_parent'] ) ) { + $this->update_status = 'error'; + $this->update_error = new WP_Error( 'unexpected_previous_post_id' ); + return; + } + + $value['menu_item_parent'] = $parent_nav_menu_item_setting->post_id; + } + + // Insert or update menu. + $menu_item_data = array( + 'menu-item-object-id' => $value['object_id'], + 'menu-item-object' => $value['object'], + 'menu-item-parent-id' => $value['menu_item_parent'], + 'menu-item-position' => $value['position'], + 'menu-item-type' => $value['type'], + 'menu-item-title' => $value['title'], + 'menu-item-url' => $value['url'], + 'menu-item-description' => $value['description'], + 'menu-item-attr-title' => $value['attr_title'], + 'menu-item-target' => $value['target'], + 'menu-item-classes' => $value['classes'], + 'menu-item-xfn' => $value['xfn'], + 'menu-item-status' => $value['status'], + ); + + $r = wp_update_nav_menu_item( + $value['nav_menu_term_id'], + $is_placeholder ? 0 : $this->post_id, + wp_slash( $menu_item_data ) + ); + + if ( is_wp_error( $r ) ) { + $this->update_status = 'error'; + $this->update_error = $r; + } else { + if ( $is_placeholder ) { + $this->previous_post_id = $this->post_id; + $this->post_id = $r; + $this->update_status = 'inserted'; + } else { + $this->update_status = 'updated'; + } + } + } + + } + + /** + * Export data for the JS client. + * + * @since 4.3.0 + * + * @see WP_Customize_Nav_Menu_Item_Setting::update() + * + * @param array $data Additional information passed back to the 'saved' event on `wp.customize`. + * @return array Save response data. + */ + public function amend_customize_save_response( $data ) { + if ( ! isset( $data['nav_menu_item_updates'] ) ) { + $data['nav_menu_item_updates'] = array(); + } + + $data['nav_menu_item_updates'][] = array( + 'post_id' => $this->post_id, + 'previous_post_id' => $this->previous_post_id, + 'error' => $this->update_error ? $this->update_error->get_error_code() : null, + 'status' => $this->update_status, + ); + return $data; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menu-location-control.php b/backend/wp-includes/customize/class-wp-customize-nav-menu-location-control.php new file mode 100644 index 0000000..40ea69e --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menu-location-control.php @@ -0,0 +1,81 @@ +json['locationId'] = $this->location_id; + } + + /** + * Render content just like a normal select control. + * + * @since 4.3.0 + * @since 4.9.0 Added a button to create menus. + */ + public function render_content() { + if ( empty( $this->choices ) ) { + return; + } + ?> + + + + + <# var elementId; #> + + + + <# if ( data.description ) { #> +

      {{ data.description }}

      + <# } #> + id ) ); + + return $exported; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/backend/wp-includes/customize/class-wp-customize-nav-menu-setting.php new file mode 100644 index 0000000..e3205e0 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menu-setting.php @@ -0,0 +1,640 @@ +-?\d+)\]$/'; + + const TAXONOMY = 'nav_menu'; + + const TYPE = 'nav_menu'; + + /** + * Setting type. + * + * @since 4.3.0 + * @var string + */ + public $type = self::TYPE; + + /** + * Default setting value. + * + * @since 4.3.0 + * @var array + * + * @see wp_get_nav_menu_object() + */ + public $default = array( + 'name' => '', + 'description' => '', + 'parent' => 0, + 'auto_add' => false, + ); + + /** + * Default transport. + * + * @since 4.3.0 + * @var string + */ + public $transport = 'postMessage'; + + /** + * The term ID represented by this setting instance. + * + * A negative value represents a placeholder ID for a new menu not yet saved. + * + * @since 4.3.0 + * @var int + */ + public $term_id; + + /** + * Previous (placeholder) term ID used before creating a new menu. + * + * This value will be exported to JS via the {@see 'customize_save_response'} filter + * so that JavaScript can update the settings to refer to the newly-assigned + * term ID. This value is always negative to indicate it does not refer to + * a real term. + * + * @since 4.3.0 + * @var int + * + * @see WP_Customize_Nav_Menu_Setting::update() + * @see WP_Customize_Nav_Menu_Setting::amend_customize_save_response() + */ + public $previous_term_id; + + /** + * Whether or not update() was called. + * + * @since 4.3.0 + * @var bool + */ + protected $is_updated = false; + + /** + * Status for calling the update method, used in customize_save_response filter. + * + * See {@see 'customize_save_response'}. + * + * When status is inserted, the placeholder term ID is stored in `$previous_term_id`. + * When status is error, the error is stored in `$update_error`. + * + * @since 4.3.0 + * @var string updated|inserted|deleted|error + * + * @see WP_Customize_Nav_Menu_Setting::update() + * @see WP_Customize_Nav_Menu_Setting::amend_customize_save_response() + */ + public $update_status; + + /** + * Any error object returned by wp_update_nav_menu_object() when setting is updated. + * + * @since 4.3.0 + * @var WP_Error + * + * @see WP_Customize_Nav_Menu_Setting::update() + * @see WP_Customize_Nav_Menu_Setting::amend_customize_save_response() + */ + public $update_error; + + /** + * Constructor. + * + * Any supplied $args override class property defaults. + * + * @since 4.3.0 + * + * @param WP_Customize_Manager $manager Bootstrap Customizer instance. + * @param string $id An specific ID of the setting. Can be a + * theme mod or option name. + * @param array $args Optional. Setting arguments. + * + * @throws Exception If $id is not valid for this setting type. + */ + public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) { + if ( empty( $manager->nav_menus ) ) { + throw new Exception( 'Expected WP_Customize_Manager::$nav_menus to be set.' ); + } + + if ( ! preg_match( self::ID_PATTERN, $id, $matches ) ) { + throw new Exception( "Illegal widget setting ID: $id" ); + } + + $this->term_id = intval( $matches['id'] ); + + parent::__construct( $manager, $id, $args ); + } + + /** + * Get the instance data for a given widget setting. + * + * @since 4.3.0 + * + * @see wp_get_nav_menu_object() + * + * @return array Instance data. + */ + public function value() { + if ( $this->is_previewed && $this->_previewed_blog_id === get_current_blog_id() ) { + $undefined = new stdClass(); // Symbol. + $post_value = $this->post_value( $undefined ); + + if ( $undefined === $post_value ) { + $value = $this->_original_value; + } else { + $value = $post_value; + } + } else { + $value = false; + + // Note that a term_id of less than one indicates a nav_menu not yet inserted. + if ( $this->term_id > 0 ) { + $term = wp_get_nav_menu_object( $this->term_id ); + + if ( $term ) { + $value = wp_array_slice_assoc( (array) $term, array_keys( $this->default ) ); + + $nav_menu_options = (array) get_option( 'nav_menu_options', array() ); + $value['auto_add'] = false; + + if ( isset( $nav_menu_options['auto_add'] ) && is_array( $nav_menu_options['auto_add'] ) ) { + $value['auto_add'] = in_array( $term->term_id, $nav_menu_options['auto_add'] ); + } + } + } + + if ( ! is_array( $value ) ) { + $value = $this->default; + } + } + return $value; + } + + /** + * Handle previewing the setting. + * + * @since 4.3.0 + * @since 4.4.0 Added boolean return value + * + * @see WP_Customize_Manager::post_value() + * + * @return bool False if method short-circuited due to no-op. + */ + public function preview() { + if ( $this->is_previewed ) { + return false; + } + + $undefined = new stdClass(); + $is_placeholder = ( $this->term_id < 0 ); + $is_dirty = ( $undefined !== $this->post_value( $undefined ) ); + if ( ! $is_placeholder && ! $is_dirty ) { + return false; + } + + $this->is_previewed = true; + $this->_original_value = $this->value(); + $this->_previewed_blog_id = get_current_blog_id(); + + add_filter( 'wp_get_nav_menus', array( $this, 'filter_wp_get_nav_menus' ), 10, 2 ); + add_filter( 'wp_get_nav_menu_object', array( $this, 'filter_wp_get_nav_menu_object' ), 10, 2 ); + add_filter( 'default_option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) ); + add_filter( 'option_nav_menu_options', array( $this, 'filter_nav_menu_options' ) ); + + return true; + } + + /** + * Filters the wp_get_nav_menus() result to ensure the inserted menu object is included, and the deleted one is removed. + * + * @since 4.3.0 + * + * @see wp_get_nav_menus() + * + * @param array $menus An array of menu objects. + * @param array $args An array of arguments used to retrieve menu objects. + * @return array + */ + public function filter_wp_get_nav_menus( $menus, $args ) { + if ( get_current_blog_id() !== $this->_previewed_blog_id ) { + return $menus; + } + + $setting_value = $this->value(); + $is_delete = ( false === $setting_value ); + $index = -1; + + // Find the existing menu item's position in the list. + foreach ( $menus as $i => $menu ) { + if ( (int) $this->term_id === (int) $menu->term_id || (int) $this->previous_term_id === (int) $menu->term_id ) { + $index = $i; + break; + } + } + + if ( $is_delete ) { + // Handle deleted menu by removing it from the list. + if ( -1 !== $index ) { + array_splice( $menus, $index, 1 ); + } + } else { + // Handle menus being updated or inserted. + $menu_obj = (object) array_merge( array( + 'term_id' => $this->term_id, + 'term_taxonomy_id' => $this->term_id, + 'slug' => sanitize_title( $setting_value['name'] ), + 'count' => 0, + 'term_group' => 0, + 'taxonomy' => self::TAXONOMY, + 'filter' => 'raw', + ), $setting_value ); + + array_splice( $menus, $index, ( -1 === $index ? 0 : 1 ), array( $menu_obj ) ); + } + + // Make sure the menu objects get re-sorted after an update/insert. + if ( ! $is_delete && ! empty( $args['orderby'] ) ) { + $menus = wp_list_sort( $menus, array( + $args['orderby'] => 'ASC', + ) ); + } + // @todo add support for $args['hide_empty'] === true + + return $menus; + } + + /** + * Temporary non-closure passing of orderby value to function. + * + * @since 4.3.0 + * @var string + * + * @see WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus() + * @see WP_Customize_Nav_Menu_Setting::_sort_menus_by_orderby() + */ + protected $_current_menus_sort_orderby; + + /** + * Sort menu objects by the class-supplied orderby property. + * + * This is a workaround for a lack of closures. + * + * @since 4.3.0 + * @deprecated 4.7.0 Use wp_list_sort() + * + * @param object $menu1 + * @param object $menu2 + * @return int + * + * @see WP_Customize_Nav_Menu_Setting::filter_wp_get_nav_menus() + */ + protected function _sort_menus_by_orderby( $menu1, $menu2 ) { + _deprecated_function( __METHOD__, '4.7.0', 'wp_list_sort' ); + + $key = $this->_current_menus_sort_orderby; + return strcmp( $menu1->$key, $menu2->$key ); + } + + /** + * Filters the wp_get_nav_menu_object() result to supply the previewed menu object. + * + * Requesting a nav_menu object by anything but ID is not supported. + * + * @since 4.3.0 + * + * @see wp_get_nav_menu_object() + * + * @param object|null $menu_obj Object returned by wp_get_nav_menu_object(). + * @param string $menu_id ID of the nav_menu term. Requests by slug or name will be ignored. + * @return object|null + */ + public function filter_wp_get_nav_menu_object( $menu_obj, $menu_id ) { + $ok = ( + get_current_blog_id() === $this->_previewed_blog_id + && + is_int( $menu_id ) + && + $menu_id === $this->term_id + ); + if ( ! $ok ) { + return $menu_obj; + } + + $setting_value = $this->value(); + + // Handle deleted menus. + if ( false === $setting_value ) { + return false; + } + + // Handle sanitization failure by preventing short-circuiting. + if ( null === $setting_value ) { + return $menu_obj; + } + + $menu_obj = (object) array_merge( array( + 'term_id' => $this->term_id, + 'term_taxonomy_id' => $this->term_id, + 'slug' => sanitize_title( $setting_value['name'] ), + 'count' => 0, + 'term_group' => 0, + 'taxonomy' => self::TAXONOMY, + 'filter' => 'raw', + ), $setting_value ); + + return $menu_obj; + } + + /** + * Filters the nav_menu_options option to include this menu's auto_add preference. + * + * @since 4.3.0 + * + * @param array $nav_menu_options Nav menu options including auto_add. + * @return array (Kaybe) modified nav menu options. + */ + public function filter_nav_menu_options( $nav_menu_options ) { + if ( $this->_previewed_blog_id !== get_current_blog_id() ) { + return $nav_menu_options; + } + + $menu = $this->value(); + $nav_menu_options = $this->filter_nav_menu_options_value( + $nav_menu_options, + $this->term_id, + false === $menu ? false : $menu['auto_add'] + ); + + return $nav_menu_options; + } + + /** + * Sanitize an input. + * + * Note that parent::sanitize() erroneously does wp_unslash() on $value, but + * we remove that in this override. + * + * @since 4.3.0 + * + * @param array $value The value to sanitize. + * @return array|false|null Null if an input isn't valid. False if it is marked for deletion. + * Otherwise the sanitized value. + */ + public function sanitize( $value ) { + // Menu is marked for deletion. + if ( false === $value ) { + return $value; + } + + // Invalid. + if ( ! is_array( $value ) ) { + return null; + } + + $default = array( + 'name' => '', + 'description' => '', + 'parent' => 0, + 'auto_add' => false, + ); + $value = array_merge( $default, $value ); + $value = wp_array_slice_assoc( $value, array_keys( $default ) ); + + $value['name'] = trim( esc_html( $value['name'] ) ); // This sanitization code is used in wp-admin/nav-menus.php. + $value['description'] = sanitize_text_field( $value['description'] ); + $value['parent'] = max( 0, intval( $value['parent'] ) ); + $value['auto_add'] = ! empty( $value['auto_add'] ); + + if ( '' === $value['name'] ) { + $value['name'] = _x( '(unnamed)', 'Missing menu name.' ); + } + + /** This filter is documented in wp-includes/class-wp-customize-setting.php */ + return apply_filters( "customize_sanitize_{$this->id}", $value, $this ); + } + + /** + * Storage for data to be sent back to client in customize_save_response filter. + * + * See {@see 'customize_save_response'}. + * + * @since 4.3.0 + * @var array + * + * @see WP_Customize_Nav_Menu_Setting::amend_customize_save_response() + */ + protected $_widget_nav_menu_updates = array(); + + /** + * Create/update the nav_menu term for this setting. + * + * Any created menus will have their assigned term IDs exported to the client + * via the {@see 'customize_save_response'} filter. Likewise, any errors will be exported + * to the client via the customize_save_response() filter. + * + * To delete a menu, the client can send false as the value. + * + * @since 4.3.0 + * + * @see wp_update_nav_menu_object() + * + * @param array|false $value { + * The value to update. Note that slug cannot be updated via wp_update_nav_menu_object(). + * If false, then the menu will be deleted entirely. + * + * @type string $name The name of the menu to save. + * @type string $description The term description. Default empty string. + * @type int $parent The id of the parent term. Default 0. + * @type bool $auto_add Whether pages will auto_add to this menu. Default false. + * } + * @return null|void + */ + protected function update( $value ) { + if ( $this->is_updated ) { + return; + } + + $this->is_updated = true; + $is_placeholder = ( $this->term_id < 0 ); + $is_delete = ( false === $value ); + + add_filter( 'customize_save_response', array( $this, 'amend_customize_save_response' ) ); + + $auto_add = null; + if ( $is_delete ) { + // If the current setting term is a placeholder, a delete request is a no-op. + if ( $is_placeholder ) { + $this->update_status = 'deleted'; + } else { + $r = wp_delete_nav_menu( $this->term_id ); + + if ( is_wp_error( $r ) ) { + $this->update_status = 'error'; + $this->update_error = $r; + } else { + $this->update_status = 'deleted'; + $auto_add = false; + } + } + } else { + // Insert or update menu. + $menu_data = wp_array_slice_assoc( $value, array( 'description', 'parent' ) ); + $menu_data['menu-name'] = $value['name']; + + $menu_id = $is_placeholder ? 0 : $this->term_id; + $r = wp_update_nav_menu_object( $menu_id, wp_slash( $menu_data ) ); + $original_name = $menu_data['menu-name']; + $name_conflict_suffix = 1; + while ( is_wp_error( $r ) && 'menu_exists' === $r->get_error_code() ) { + $name_conflict_suffix += 1; + /* translators: 1: original menu name, 2: duplicate count */ + $menu_data['menu-name'] = sprintf( __( '%1$s (%2$d)' ), $original_name, $name_conflict_suffix ); + $r = wp_update_nav_menu_object( $menu_id, wp_slash( $menu_data ) ); + } + + if ( is_wp_error( $r ) ) { + $this->update_status = 'error'; + $this->update_error = $r; + } else { + if ( $is_placeholder ) { + $this->previous_term_id = $this->term_id; + $this->term_id = $r; + $this->update_status = 'inserted'; + } else { + $this->update_status = 'updated'; + } + + $auto_add = $value['auto_add']; + } + } + + if ( null !== $auto_add ) { + $nav_menu_options = $this->filter_nav_menu_options_value( + (array) get_option( 'nav_menu_options', array() ), + $this->term_id, + $auto_add + ); + update_option( 'nav_menu_options', $nav_menu_options ); + } + + if ( 'inserted' === $this->update_status ) { + // Make sure that new menus assigned to nav menu locations use their new IDs. + foreach ( $this->manager->settings() as $setting ) { + if ( ! preg_match( '/^nav_menu_locations\[/', $setting->id ) ) { + continue; + } + + $post_value = $setting->post_value( null ); + if ( ! is_null( $post_value ) && $this->previous_term_id === intval( $post_value ) ) { + $this->manager->set_post_value( $setting->id, $this->term_id ); + $setting->save(); + } + } + + // Make sure that any nav_menu widgets referencing the placeholder nav menu get updated and sent back to client. + foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) { + $nav_menu_widget_setting = $this->manager->get_setting( $setting_id ); + if ( ! $nav_menu_widget_setting || ! preg_match( '/^widget_nav_menu\[/', $nav_menu_widget_setting->id ) ) { + continue; + } + + $widget_instance = $nav_menu_widget_setting->post_value(); // Note that this calls WP_Customize_Widgets::sanitize_widget_instance(). + if ( empty( $widget_instance['nav_menu'] ) || intval( $widget_instance['nav_menu'] ) !== $this->previous_term_id ) { + continue; + } + + $widget_instance['nav_menu'] = $this->term_id; + $updated_widget_instance = $this->manager->widgets->sanitize_widget_js_instance( $widget_instance ); + $this->manager->set_post_value( $nav_menu_widget_setting->id, $updated_widget_instance ); + $nav_menu_widget_setting->save(); + + $this->_widget_nav_menu_updates[ $nav_menu_widget_setting->id ] = $updated_widget_instance; + } + } + } + + /** + * Updates a nav_menu_options array. + * + * @since 4.3.0 + * + * @see WP_Customize_Nav_Menu_Setting::filter_nav_menu_options() + * @see WP_Customize_Nav_Menu_Setting::update() + * + * @param array $nav_menu_options Array as returned by get_option( 'nav_menu_options' ). + * @param int $menu_id The term ID for the given menu. + * @param bool $auto_add Whether to auto-add or not. + * @return array (Maybe) modified nav_menu_otions array. + */ + protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add ) { + $nav_menu_options = (array) $nav_menu_options; + if ( ! isset( $nav_menu_options['auto_add'] ) ) { + $nav_menu_options['auto_add'] = array(); + } + + $i = array_search( $menu_id, $nav_menu_options['auto_add'] ); + if ( $auto_add && false === $i ) { + array_push( $nav_menu_options['auto_add'], $this->term_id ); + } elseif ( ! $auto_add && false !== $i ) { + array_splice( $nav_menu_options['auto_add'], $i, 1 ); + } + + return $nav_menu_options; + } + + /** + * Export data for the JS client. + * + * @since 4.3.0 + * + * @see WP_Customize_Nav_Menu_Setting::update() + * + * @param array $data Additional information passed back to the 'saved' event on `wp.customize`. + * @return array Export data. + */ + public function amend_customize_save_response( $data ) { + if ( ! isset( $data['nav_menu_updates'] ) ) { + $data['nav_menu_updates'] = array(); + } + if ( ! isset( $data['widget_nav_menu_updates'] ) ) { + $data['widget_nav_menu_updates'] = array(); + } + + $data['nav_menu_updates'][] = array( + 'term_id' => $this->term_id, + 'previous_term_id' => $this->previous_term_id, + 'error' => $this->update_error ? $this->update_error->get_error_code() : null, + 'status' => $this->update_status, + 'saved_value' => 'deleted' === $this->update_status ? null : $this->value(), + ); + + $data['widget_nav_menu_updates'] = array_merge( + $data['widget_nav_menu_updates'], + $this->_widget_nav_menu_updates + ); + $this->_widget_nav_menu_updates = array(); + + return $data; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-nav-menus-panel.php b/backend/wp-includes/customize/class-wp-customize-nav-menus-panel.php new file mode 100644 index 0000000..5b85f47 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-nav-menus-panel.php @@ -0,0 +1,101 @@ +render_screen_options( array( 'wrap' => false ) ); + } + + /** + * Returns the advanced options for the nav menus page. + * + * Link title attribute added as it's a relatively advanced concept for new users. + * + * @since 4.3.0 + * @deprecated 4.5.0 Deprecated in favor of wp_nav_menu_manage_columns(). + */ + public function wp_nav_menu_manage_columns() { + _deprecated_function( __METHOD__, '4.5.0', 'wp_nav_menu_manage_columns' ); + require_once ABSPATH . 'wp-admin/includes/nav-menu.php'; + return wp_nav_menu_manage_columns(); + } + + /** + * An Underscore (JS) template for this panel's content (but not its container). + * + * Class variables for this panel class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Panel::json(). + * + * @since 4.3.0 + * + * @see WP_Customize_Panel::print_template() + */ + protected function content_template() { + ?> +
    • + +
      + + {{ data.title }}' ); + ?> + + + +
      + <# if ( data.description ) { #> +
      {{{ data.description }}}
      + <# } #> +
      + render_screen_options(); ?> +
      +
    • + +
    • + + + + +
    • + +
        +
      • + $key = $args[ $key ]; + } + } + + $this->component = $component; + $this->id = $id; + $this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) ); + $this->id_data['base'] = array_shift( $this->id_data['keys'] ); + + if ( empty( $this->render_callback ) ) { + $this->render_callback = array( $this, 'render_callback' ); + } + + // Process settings. + if ( ! isset( $this->settings ) ) { + $this->settings = array( $id ); + } else if ( is_string( $this->settings ) ) { + $this->settings = array( $this->settings ); + } + + if ( empty( $this->primary_setting ) ) { + $this->primary_setting = current( $this->settings ); + } + } + + /** + * Retrieves parsed ID data for multidimensional setting. + * + * @since 4.5.0 + * + * @return array { + * ID data for multidimensional partial. + * + * @type string $base ID base. + * @type array $keys Keys for multidimensional array. + * } + */ + final public function id_data() { + return $this->id_data; + } + + /** + * Renders the template partial involving the associated settings. + * + * @since 4.5.0 + * + * @param array $container_context Optional. Array of context data associated with the target container (placement). + * Default empty array. + * @return string|array|false The rendered partial as a string, raw data array (for client-side JS template), + * or false if no render applied. + */ + final public function render( $container_context = array() ) { + $partial = $this; + $rendered = false; + + if ( ! empty( $this->render_callback ) ) { + ob_start(); + $return_render = call_user_func( $this->render_callback, $this, $container_context ); + $ob_render = ob_get_clean(); + + if ( null !== $return_render && '' !== $ob_render ) { + _doing_it_wrong( __FUNCTION__, __( 'Partial render must echo the content or return the content string (or array), but not both.' ), '4.5.0' ); + } + + /* + * Note that the string return takes precedence because the $ob_render may just\ + * include PHP warnings or notices. + */ + $rendered = null !== $return_render ? $return_render : $ob_render; + } + + /** + * Filters partial rendering. + * + * @since 4.5.0 + * + * @param string|array|false $rendered The partial value. Default false. + * @param WP_Customize_Partial $partial WP_Customize_Setting instance. + * @param array $container_context Optional array of context data associated with + * the target container. + */ + $rendered = apply_filters( 'customize_partial_render', $rendered, $partial, $container_context ); + + /** + * Filters partial rendering for a specific partial. + * + * The dynamic portion of the hook name, `$partial->ID` refers to the partial ID. + * + * @since 4.5.0 + * + * @param string|array|false $rendered The partial value. Default false. + * @param WP_Customize_Partial $partial WP_Customize_Setting instance. + * @param array $container_context Optional array of context data associated with + * the target container. + */ + $rendered = apply_filters( "customize_partial_render_{$partial->id}", $rendered, $partial, $container_context ); + + return $rendered; + } + + /** + * Default callback used when invoking WP_Customize_Control::render(). + * + * Note that this method may echo the partial *or* return the partial as + * a string or array, but not both. Output buffering is performed when this + * is called. Subclasses can override this with their specific logic, or they + * may provide an 'render_callback' argument to the constructor. + * + * This method may return an HTML string for straight DOM injection, or it + * may return an array for supporting Partial JS subclasses to render by + * applying to client-side templating. + * + * @since 4.5.0 + * + * @param WP_Customize_Partial $partial Partial. + * @param array $context Context. + * @return string|array|false + */ + public function render_callback( WP_Customize_Partial $partial, $context = array() ) { + unset( $partial, $context ); + return false; + } + + /** + * Retrieves the data to export to the client via JSON. + * + * @since 4.5.0 + * + * @return array Array of parameters passed to the JavaScript. + */ + public function json() { + $exports = array( + 'settings' => $this->settings, + 'primarySetting' => $this->primary_setting, + 'selector' => $this->selector, + 'type' => $this->type, + 'fallbackRefresh' => $this->fallback_refresh, + 'containerInclusive' => $this->container_inclusive, + ); + return $exports; + } + + /** + * Checks if the user can refresh this partial. + * + * Returns false if the user cannot manipulate one of the associated settings, + * or if one of the associated settings does not exist. + * + * @since 4.5.0 + * + * @return bool False if user can't edit one of the related settings, + * or if one of the associated settings does not exist. + */ + final public function check_capabilities() { + if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) { + return false; + } + foreach ( $this->settings as $setting_id ) { + $setting = $this->component->manager->get_setting( $setting_id ); + if ( ! $setting || ! $setting->check_capabilities() ) { + return false; + } + } + return true; + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-selective-refresh.php b/backend/wp-includes/customize/class-wp-customize-selective-refresh.php new file mode 100644 index 0000000..3115663 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-selective-refresh.php @@ -0,0 +1,456 @@ +manager = $manager; + require_once( ABSPATH . WPINC . '/customize/class-wp-customize-partial.php' ); + + add_action( 'customize_preview_init', array( $this, 'init_preview' ) ); + } + + /** + * Retrieves the registered partials. + * + * @since 4.5.0 + * + * @return array Partials. + */ + public function partials() { + return $this->partials; + } + + /** + * Adds a partial. + * + * @since 4.5.0 + * + * @param WP_Customize_Partial|string $id Customize Partial object, or Panel ID. + * @param array $args { + * Optional. Array of properties for the new Partials object. Default empty array. + * + * @type string $type Type of the partial to be created. + * @type string $selector The jQuery selector to find the container element for the partial, that is, a partial's placement. + * @type array $settings IDs for settings tied to the partial. + * @type string $primary_setting The ID for the setting that this partial is primarily responsible for + * rendering. If not supplied, it will default to the ID of the first setting. + * @type string $capability Capability required to edit this partial. + * Normally this is empty and the capability is derived from the capabilities + * of the associated `$settings`. + * @type callable $render_callback Render callback. + * Callback is called with one argument, the instance of WP_Customize_Partial. + * The callback can either echo the partial or return the partial as a string, + * or return false if error. + * @type bool $container_inclusive Whether the container element is included in the partial, or if only + * the contents are rendered. + * @type bool $fallback_refresh Whether to refresh the entire preview in case a partial cannot be refreshed. + * A partial render is considered a failure if the render_callback returns + * false. + * } + * @return WP_Customize_Partial The instance of the panel that was added. + */ + public function add_partial( $id, $args = array() ) { + if ( $id instanceof WP_Customize_Partial ) { + $partial = $id; + } else { + $class = 'WP_Customize_Partial'; + + /** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */ + $args = apply_filters( 'customize_dynamic_partial_args', $args, $id ); + + /** This filter is documented in wp-includes/customize/class-wp-customize-selective-refresh.php */ + $class = apply_filters( 'customize_dynamic_partial_class', $class, $id, $args ); + + $partial = new $class( $this, $id, $args ); + } + + $this->partials[ $partial->id ] = $partial; + return $partial; + } + + /** + * Retrieves a partial. + * + * @since 4.5.0 + * + * @param string $id Customize Partial ID. + * @return WP_Customize_Partial|null The partial, if set. Otherwise null. + */ + public function get_partial( $id ) { + if ( isset( $this->partials[ $id ] ) ) { + return $this->partials[ $id ]; + } else { + return null; + } + } + + /** + * Removes a partial. + * + * @since 4.5.0 + * + * @param string $id Customize Partial ID. + */ + public function remove_partial( $id ) { + unset( $this->partials[ $id ] ); + } + + /** + * Initializes the Customizer preview. + * + * @since 4.5.0 + */ + public function init_preview() { + add_action( 'template_redirect', array( $this, 'handle_render_partials_request' ) ); + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); + } + + /** + * Enqueues preview scripts. + * + * @since 4.5.0 + */ + public function enqueue_preview_scripts() { + wp_enqueue_script( 'customize-selective-refresh' ); + add_action( 'wp_footer', array( $this, 'export_preview_data' ), 1000 ); + } + + /** + * Exports data in preview after it has finished rendering so that partials can be added at runtime. + * + * @since 4.5.0 + */ + public function export_preview_data() { + $partials = array(); + + foreach ( $this->partials() as $partial ) { + if ( $partial->check_capabilities() ) { + $partials[ $partial->id ] = $partial->json(); + } + } + + $switched_locale = switch_to_locale( get_user_locale() ); + $l10n = array( + 'shiftClickToEdit' => __( 'Shift-click to edit this element.' ), + 'clickEditMenu' => __( 'Click to edit this menu.' ), + 'clickEditWidget' => __( 'Click to edit this widget.' ), + 'clickEditTitle' => __( 'Click to edit the site title.' ), + 'clickEditMisc' => __( 'Click to edit this element.' ), + /* translators: %s: document.write() */ + 'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ), + ); + if ( $switched_locale ) { + restore_previous_locale(); + } + + $exports = array( + 'partials' => $partials, + 'renderQueryVar' => self::RENDER_QUERY_VAR, + 'l10n' => $l10n, + ); + + // Export data to JS. + echo sprintf( '', wp_json_encode( $exports ) ); + } + + /** + * Registers dynamically-created partials. + * + * @since 4.5.0 + * + * @see WP_Customize_Manager::add_dynamic_settings() + * + * @param array $partial_ids The partial ID to add. + * @return array Added WP_Customize_Partial instances. + */ + public function add_dynamic_partials( $partial_ids ) { + $new_partials = array(); + + foreach ( $partial_ids as $partial_id ) { + + // Skip partials already created. + $partial = $this->get_partial( $partial_id ); + if ( $partial ) { + continue; + } + + $partial_args = false; + $partial_class = 'WP_Customize_Partial'; + + /** + * Filters a dynamic partial's constructor arguments. + * + * For a dynamic partial to be registered, this filter must be employed + * to override the default false value with an array of args to pass to + * the WP_Customize_Partial constructor. + * + * @since 4.5.0 + * + * @param false|array $partial_args The arguments to the WP_Customize_Partial constructor. + * @param string $partial_id ID for dynamic partial. + */ + $partial_args = apply_filters( 'customize_dynamic_partial_args', $partial_args, $partial_id ); + if ( false === $partial_args ) { + continue; + } + + /** + * Filters the class used to construct partials. + * + * Allow non-statically created partials to be constructed with custom WP_Customize_Partial subclass. + * + * @since 4.5.0 + * + * @param string $partial_class WP_Customize_Partial or a subclass. + * @param string $partial_id ID for dynamic partial. + * @param array $partial_args The arguments to the WP_Customize_Partial constructor. + */ + $partial_class = apply_filters( 'customize_dynamic_partial_class', $partial_class, $partial_id, $partial_args ); + + $partial = new $partial_class( $this, $partial_id, $partial_args ); + + $this->add_partial( $partial ); + $new_partials[] = $partial; + } + return $new_partials; + } + + /** + * Checks whether the request is for rendering partials. + * + * Note that this will not consider whether the request is authorized or valid, + * just that essentially the route is a match. + * + * @since 4.5.0 + * + * @return bool Whether the request is for rendering partials. + */ + public function is_render_partials_request() { + return ! empty( $_POST[ self::RENDER_QUERY_VAR ] ); + } + + /** + * Handles PHP errors triggered during rendering the partials. + * + * These errors will be relayed back to the client in the Ajax response. + * + * @since 4.5.0 + * + * @param int $errno Error number. + * @param string $errstr Error string. + * @param string $errfile Error file. + * @param string $errline Error line. + * @return true Always true. + */ + public function handle_error( $errno, $errstr, $errfile = null, $errline = null ) { + $this->triggered_errors[] = array( + 'partial' => $this->current_partial_id, + 'error_number' => $errno, + 'error_string' => $errstr, + 'error_file' => $errfile, + 'error_line' => $errline, + ); + return true; + } + + /** + * Handles the Ajax request to return the rendered partials for the requested placements. + * + * @since 4.5.0 + */ + public function handle_render_partials_request() { + if ( ! $this->is_render_partials_request() ) { + return; + } + + /* + * Note that is_customize_preview() returning true will entail that the + * user passed the 'customize' capability check and the nonce check, since + * WP_Customize_Manager::setup_theme() is where the previewing flag is set. + */ + if ( ! is_customize_preview() ) { + wp_send_json_error( 'expected_customize_preview', 403 ); + } elseif ( ! isset( $_POST['partials'] ) ) { + wp_send_json_error( 'missing_partials', 400 ); + } + + // Ensure that doing selective refresh on 404 template doesn't result in fallback rendering behavior (full refreshes). + status_header( 200 ); + + $partials = json_decode( wp_unslash( $_POST['partials'] ), true ); + + if ( ! is_array( $partials ) ) { + wp_send_json_error( 'malformed_partials' ); + } + + $this->add_dynamic_partials( array_keys( $partials ) ); + + /** + * Fires immediately before partials are rendered. + * + * Plugins may do things like call wp_enqueue_scripts() and gather a list of the scripts + * and styles which may get enqueued in the response. + * + * @since 4.5.0 + * + * @param WP_Customize_Selective_Refresh $this Selective refresh component. + * @param array $partials Placements' context data for the partials rendered in the request. + * The array is keyed by partial ID, with each item being an array of + * the placements' context data. + */ + do_action( 'customize_render_partials_before', $this, $partials ); + + set_error_handler( array( $this, 'handle_error' ), error_reporting() ); + + $contents = array(); + + foreach ( $partials as $partial_id => $container_contexts ) { + $this->current_partial_id = $partial_id; + + if ( ! is_array( $container_contexts ) ) { + wp_send_json_error( 'malformed_container_contexts' ); + } + + $partial = $this->get_partial( $partial_id ); + + if ( ! $partial || ! $partial->check_capabilities() ) { + $contents[ $partial_id ] = null; + continue; + } + + $contents[ $partial_id ] = array(); + + // @todo The array should include not only the contents, but also whether the container is included? + if ( empty( $container_contexts ) ) { + // Since there are no container contexts, render just once. + $contents[ $partial_id ][] = $partial->render( null ); + } else { + foreach ( $container_contexts as $container_context ) { + $contents[ $partial_id ][] = $partial->render( $container_context ); + } + } + } + $this->current_partial_id = null; + + restore_error_handler(); + + /** + * Fires immediately after partials are rendered. + * + * Plugins may do things like call wp_footer() to scrape scripts output and return them + * via the {@see 'customize_render_partials_response'} filter. + * + * @since 4.5.0 + * + * @param WP_Customize_Selective_Refresh $this Selective refresh component. + * @param array $partials Placements' context data for the partials rendered in the request. + * The array is keyed by partial ID, with each item being an array of + * the placements' context data. + */ + do_action( 'customize_render_partials_after', $this, $partials ); + + $response = array( + 'contents' => $contents, + ); + + if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) { + $response['errors'] = $this->triggered_errors; + } + + $setting_validities = $this->manager->validate_setting_values( $this->manager->unsanitized_post_values() ); + $exported_setting_validities = array_map( array( $this->manager, 'prepare_setting_validity_for_js' ), $setting_validities ); + $response['setting_validities'] = $exported_setting_validities; + + /** + * Filters the response from rendering the partials. + * + * Plugins may use this filter to inject `$scripts` and `$styles`, which are dependencies + * for the partials being rendered. The response data will be available to the client via + * the `render-partials-response` JS event, so the client can then inject the scripts and + * styles into the DOM if they have not already been enqueued there. + * + * If plugins do this, they'll need to take care for any scripts that do `document.write()` + * and make sure that these are not injected, or else to override the function to no-op, + * or else the page will be destroyed. + * + * Plugins should be aware that `$scripts` and `$styles` may eventually be included by + * default in the response. + * + * @since 4.5.0 + * + * @param array $response { + * Response. + * + * @type array $contents Associative array mapping a partial ID its corresponding array of contents + * for the containers requested. + * @type array $errors List of errors triggered during rendering of partials, if `WP_DEBUG_DISPLAY` + * is enabled. + * } + * @param WP_Customize_Selective_Refresh $this Selective refresh component. + * @param array $partials Placements' context data for the partials rendered in the request. + * The array is keyed by partial ID, with each item being an array of + * the placements' context data. + */ + $response = apply_filters( 'customize_render_partials_response', $response, $this, $partials ); + + wp_send_json_success( $response ); + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-sidebar-section.php b/backend/wp-includes/customize/class-wp-customize-sidebar-section.php new file mode 100644 index 0000000..2813251 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-sidebar-section.php @@ -0,0 +1,58 @@ +sidebar_id; + return $json; + } + + /** + * Whether the current sidebar is rendered on the page. + * + * @since 4.1.0 + * + * @return bool Whether sidebar is rendered. + */ + public function active_callback() { + return $this->manager->widgets->is_sidebar_rendered( $this->sidebar_id ); + } +} diff --git a/backend/wp-includes/customize/class-wp-customize-site-icon-control.php b/backend/wp-includes/customize/class-wp-customize-site-icon-control.php new file mode 100644 index 0000000..4d7bcf5 --- /dev/null +++ b/backend/wp-includes/customize/class-wp-customize-site-icon-control.php @@ -0,0 +1,98 @@ + + + + <# if ( data.attachment && data.attachment.id ) { #> +
        + <# if ( data.attachment.sizes ) { #> +
        +
        + + +
        + <?php esc_attr_e( 'Preview as a browser icon' ); ?> +
        + +
        + <?php esc_attr_e( 'Preview as an app icon' ); ?> +
        + <# } #> +
        + <# if ( data.canUpload ) { #> + + + <# } #> +
        +
        + <# } else { #> +
        +
        + button_labels['placeholder']; ?> +
        +
        + <# if ( data.defaultAttachment ) { #> + + <# } #> + <# if ( data.canUpload ) { #> + + <# } #> +
        +
        + <# } #> + json['theme'] = $this->theme; + } + + /** + * Don't render the control content from PHP, as it's rendered via JS on load. + * + * @since 4.2.0 + */ + public function render_content() {} + + /** + * Render a JS template for theme display. + * + * @since 4.2.0 + */ + public function content_template() { + /* translators: %s: theme name */ + $details_label = sprintf( __( 'Details for theme: %s' ), '{{ data.theme.name }}' ); + /* translators: %s: theme name */ + $customize_label = sprintf( __( 'Customize theme: %s' ), '{{ data.theme.name }}' ); + /* translators: %s: theme name */ + $preview_label = sprintf( __( 'Live preview theme: %s' ), '{{ data.theme.name }}' ); + /* translators: %s: theme name */ + $install_label = sprintf( __( 'Install and preview theme: %s' ), '{{ data.theme.name }}' ); + ?> + <# if ( data.theme.active ) { #> +
        + <# } else { #> +
        + <# } #> + + <# if ( data.theme.screenshot && data.theme.screenshot[0] ) { #> +
        + +
        + <# } else { #> +
        + <# } #> + + + +
        + + <# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #> +
        +

        + ' . __( 'Update now' ) . '' ); + ?> +

        +
        + <# } #> + + <# if ( data.theme.active ) { #> +
        +

        + Previewing: %s' ), '{{ data.theme.name }}' ); + ?> +

        +
        + +
        +
        +

        + <# } else if ( 'installed' === data.theme.type ) { #> +
        +

        {{ data.theme.name }}

        +
        + +
        +
        +

        + <# } else { #> +
        +

        {{ data.theme.name }}

        +
        + +
        +
        + <# } #> +
        + +
      • +

        + manager->is_theme_active() ) { + echo '' . __( 'Active theme' ) . ' {{ data.title }}'; + } else { + echo '' . __( 'Previewing theme' ) . ' {{ data.title }}'; + } + ?> + + + + +

        +
          +
        • + +
        • + +
          + + ' . __( 'Themes' ) . '' ); // Separate strings for consistency with other panels. + ?> + + + <# if ( data.description ) { #> + + <# } #> + +
          + + <# if ( data.description ) { #> +
          + {{{ data.description }}} +
          + <# } #> + + +
          +
        • +
        • +
          +
          +
          +
        • + action; + $exported['filter_type'] = $this->filter_type; + + return $exported; + } + + /** + * Render a themes section as a JS template. + * + * The template is only rendered by PHP once, so all actions are prepared at once on the server side. + * + * @since 4.9.0 + */ + protected function render_template() { + ?> +
        • + + + +
          + +
          +
          + filter_bar_content_template(); ?> +
          + filter_drawer_content_template(); ?> + +
            +
          +

          +

          + %s', __( 'Search WordPress.org themes' ) ) + ); + ?> +

          +

          +
          +
          +
        • + + + <# if ( 'wporg' === data.action ) { #> +
          + + + + +
          + + <# } else { #> +
          + + + + +
          + <# } #> +
          + + 0' ); + ?> + +
          + + <# if ( 'wporg' === data.action ) { #> +
          + $features ) : ?> +
          + +
          + $feature_name ) : ?> + + + +
          +
          + +
          + <# } #> + value(); + if ( $value ) { + // Get the attachment model for the existing file. + $attachment_id = attachment_url_to_postid( $value ); + if ( $attachment_id ) { + $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); + } + } + } +} diff --git a/backend/wp-includes/customize/class-wp-widget-area-customize-control.php b/backend/wp-includes/customize/class-wp-widget-area-customize-control.php new file mode 100644 index 0000000..bed0f8a --- /dev/null +++ b/backend/wp-includes/customize/class-wp-widget-area-customize-control.php @@ -0,0 +1,66 @@ +json[ $key ] = $this->$key; + } + } + + /** + * Renders the control's content. + * + * @since 3.9.0 + */ + public function render_content() { + $id = 'reorder-widgets-desc-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id ); + ?> + + +

          + json[ $key ] = $this->$key; + } + + // Get the widget_control and widget_content. + require_once ABSPATH . '/wp-admin/includes/widgets.php'; + + $widget = $wp_registered_widgets[ $this->widget_id ]; + if ( ! isset( $widget['params'][0] ) ) { + $widget['params'][0] = array(); + } + + $args = array( + 'widget_id' => $widget['id'], + 'widget_name' => $widget['name'], + ); + + $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) ); + $widget_control_parts = $this->manager->widgets->get_widget_control_parts( $args ); + + $this->json['widget_control'] = $widget_control_parts['control']; + $this->json['widget_content'] = $widget_control_parts['content']; + } + + /** + * Override render_content to be no-op since content is exported via to_json for deferred embedding. + * + * @since 3.9.0 + */ + public function render_content() {} + + /** + * Whether the current widget is rendered on the page. + * + * @since 4.0.0 + * + * @return bool Whether the widget is rendered. + */ + public function active_callback() { + return $this->manager->widgets->is_widget_rendered( $this->widget_id ); + } +} diff --git a/backend/wp-includes/date.php b/backend/wp-includes/date.php new file mode 100644 index 0000000..591cf79 --- /dev/null +++ b/backend/wp-includes/date.php @@ -0,0 +1,1001 @@ +', '>=', '<', '<=', + * 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default '='. + * @type string $relation Optional. The boolean relationship between the date queries. Accepts 'OR' or 'AND'. + * Default 'OR'. + * @type array { + * Optional. An array of first-order clause parameters, or another fully-formed date query. + * + * @type string|array $before { + * Optional. Date to retrieve posts before. Accepts `strtotime()`-compatible string, + * or array of 'year', 'month', 'day' values. + * + * @type string $year The four-digit year. Default empty. Accepts any four-digit year. + * @type string $month Optional when passing array.The month of the year. + * Default (string:empty)|(array:1). Accepts numbers 1-12. + * @type string $day Optional when passing array.The day of the month. + * Default (string:empty)|(array:1). Accepts numbers 1-31. + * } + * @type string|array $after { + * Optional. Date to retrieve posts after. Accepts `strtotime()`-compatible string, + * or array of 'year', 'month', 'day' values. + * + * @type string $year The four-digit year. Accepts any four-digit year. Default empty. + * @type string $month Optional when passing array. The month of the year. Accepts numbers 1-12. + * Default (string:empty)|(array:12). + * @type string $day Optional when passing array.The day of the month. Accepts numbers 1-31. + * Default (string:empty)|(array:last day of month). + * } + * @type string $column Optional. Used to add a clause comparing a column other than the + * column specified in the top-level `$column` parameter. Accepts + * 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt', + * 'comment_date', 'comment_date_gmt'. Default is the value of + * top-level `$column`. + * @type string $compare Optional. The comparison operator. Accepts '=', '!=', '>', '>=', + * '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. 'IN', + * 'NOT IN', 'BETWEEN', and 'NOT BETWEEN'. Comparisons support + * arrays in some time-related parameters. Default '='. + * @type bool $inclusive Optional. Include results from dates specified in 'before' or + * 'after'. Default false. + * @type int|array $year Optional. The four-digit year number. Accepts any four-digit year + * or an array of years if `$compare` supports it. Default empty. + * @type int|array $month Optional. The two-digit month number. Accepts numbers 1-12 or an + * array of valid numbers if `$compare` supports it. Default empty. + * @type int|array $week Optional. The week number of the year. Accepts numbers 0-53 or an + * array of valid numbers if `$compare` supports it. Default empty. + * @type int|array $dayofyear Optional. The day number of the year. Accepts numbers 1-366 or an + * array of valid numbers if `$compare` supports it. + * @type int|array $day Optional. The day of the month. Accepts numbers 1-31 or an array + * of valid numbers if `$compare` supports it. Default empty. + * @type int|array $dayofweek Optional. The day number of the week. Accepts numbers 1-7 (1 is + * Sunday) or an array of valid numbers if `$compare` supports it. + * Default empty. + * @type int|array $dayofweek_iso Optional. The day number of the week (ISO). Accepts numbers 1-7 + * (1 is Monday) or an array of valid numbers if `$compare` supports it. + * Default empty. + * @type int|array $hour Optional. The hour of the day. Accepts numbers 0-23 or an array + * of valid numbers if `$compare` supports it. Default empty. + * @type int|array $minute Optional. The minute of the hour. Accepts numbers 0-60 or an array + * of valid numbers if `$compare` supports it. Default empty. + * @type int|array $second Optional. The second of the minute. Accepts numbers 0-60 or an + * array of valid numbers if `$compare` supports it. Default empty. + * } + * } + * } + * @param array $default_column Optional. Default column to query against. Default 'post_date'. + * Accepts 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt', + * 'comment_date', 'comment_date_gmt'. + */ + public function __construct( $date_query, $default_column = 'post_date' ) { + if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { + $this->relation = 'OR'; + } else { + $this->relation = 'AND'; + } + + if ( ! is_array( $date_query ) ) { + return; + } + + // Support for passing time-based keys in the top level of the $date_query array. + if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) { + $date_query = array( $date_query ); + } + + if ( empty( $date_query ) ) { + return; + } + + if ( ! empty( $date_query['column'] ) ) { + $date_query['column'] = esc_sql( $date_query['column'] ); + } else { + $date_query['column'] = esc_sql( $default_column ); + } + + $this->column = $this->validate_column( $this->column ); + + $this->compare = $this->get_compare( $date_query ); + + $this->queries = $this->sanitize_query( $date_query ); + } + + /** + * Recursive-friendly query sanitizer. + * + * Ensures that each query-level clause has a 'relation' key, and that + * each first-order clause contains all the necessary keys from + * `$defaults`. + * + * @since 4.1.0 + * + * @param array $queries + * @param array $parent_query + * + * @return array Sanitized queries. + */ + public function sanitize_query( $queries, $parent_query = null ) { + $cleaned_query = array(); + + $defaults = array( + 'column' => 'post_date', + 'compare' => '=', + 'relation' => 'AND', + ); + + // Numeric keys should always have array values. + foreach ( $queries as $qkey => $qvalue ) { + if ( is_numeric( $qkey ) && ! is_array( $qvalue ) ) { + unset( $queries[ $qkey ] ); + } + } + + // Each query should have a value for each default key. Inherit from the parent when possible. + foreach ( $defaults as $dkey => $dvalue ) { + if ( isset( $queries[ $dkey ] ) ) { + continue; + } + + if ( isset( $parent_query[ $dkey ] ) ) { + $queries[ $dkey ] = $parent_query[ $dkey ]; + } else { + $queries[ $dkey ] = $dvalue; + } + } + + // Validate the dates passed in the query. + if ( $this->is_first_order_clause( $queries ) ) { + $this->validate_date_values( $queries ); + } + + foreach ( $queries as $key => $q ) { + if ( ! is_array( $q ) || in_array( $key, $this->time_keys, true ) ) { + // This is a first-order query. Trust the values and sanitize when building SQL. + $cleaned_query[ $key ] = $q; + } else { + // Any array without a time key is another query, so we recurse. + $cleaned_query[] = $this->sanitize_query( $q, $queries ); + } + } + + return $cleaned_query; + } + + /** + * Determine whether this is a first-order clause. + * + * Checks to see if the current clause has any time-related keys. + * If so, it's first-order. + * + * @since 4.1.0 + * + * @param array $query Query clause. + * @return bool True if this is a first-order clause. + */ + protected function is_first_order_clause( $query ) { + $time_keys = array_intersect( $this->time_keys, array_keys( $query ) ); + return ! empty( $time_keys ); + } + + /** + * Determines and validates what comparison operator to use. + * + * @since 3.7.0 + * + * @param array $query A date query or a date subquery. + * @return string The comparison operator. + */ + public function get_compare( $query ) { + if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) + return strtoupper( $query['compare'] ); + + return $this->compare; + } + + /** + * Validates the given date_query values and triggers errors if something is not valid. + * + * Note that date queries with invalid date ranges are allowed to + * continue (though of course no items will be found for impossible dates). + * This method only generates debug notices for these cases. + * + * @since 4.1.0 + * + * @param array $date_query The date_query array. + * @return bool True if all values in the query are valid, false if one or more fail. + */ + public function validate_date_values( $date_query = array() ) { + if ( empty( $date_query ) ) { + return false; + } + + $valid = true; + + /* + * Validate 'before' and 'after' up front, then let the + * validation routine continue to be sure that all invalid + * values generate errors too. + */ + if ( array_key_exists( 'before', $date_query ) && is_array( $date_query['before'] ) ){ + $valid = $this->validate_date_values( $date_query['before'] ); + } + + if ( array_key_exists( 'after', $date_query ) && is_array( $date_query['after'] ) ){ + $valid = $this->validate_date_values( $date_query['after'] ); + } + + // Array containing all min-max checks. + $min_max_checks = array(); + + // Days per year. + if ( array_key_exists( 'year', $date_query ) ) { + /* + * If a year exists in the date query, we can use it to get the days. + * If multiple years are provided (as in a BETWEEN), use the first one. + */ + if ( is_array( $date_query['year'] ) ) { + $_year = reset( $date_query['year'] ); + } else { + $_year = $date_query['year']; + } + + $max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1; + } else { + // otherwise we use the max of 366 (leap-year) + $max_days_of_year = 366; + } + + $min_max_checks['dayofyear'] = array( + 'min' => 1, + 'max' => $max_days_of_year + ); + + // Days per week. + $min_max_checks['dayofweek'] = array( + 'min' => 1, + 'max' => 7 + ); + + // Days per week. + $min_max_checks['dayofweek_iso'] = array( + 'min' => 1, + 'max' => 7 + ); + + // Months per year. + $min_max_checks['month'] = array( + 'min' => 1, + 'max' => 12 + ); + + // Weeks per year. + if ( isset( $_year ) ) { + /* + * If we have a specific year, use it to calculate number of weeks. + * Note: the number of weeks in a year is the date in which Dec 28 appears. + */ + $week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) ); + + } else { + // Otherwise set the week-count to a maximum of 53. + $week_count = 53; + } + + $min_max_checks['week'] = array( + 'min' => 1, + 'max' => $week_count + ); + + // Days per month. + $min_max_checks['day'] = array( + 'min' => 1, + 'max' => 31 + ); + + // Hours per day. + $min_max_checks['hour'] = array( + 'min' => 0, + 'max' => 23 + ); + + // Minutes per hour. + $min_max_checks['minute'] = array( + 'min' => 0, + 'max' => 59 + ); + + // Seconds per minute. + $min_max_checks['second'] = array( + 'min' => 0, + 'max' => 59 + ); + + // Concatenate and throw a notice for each invalid value. + foreach ( $min_max_checks as $key => $check ) { + if ( ! array_key_exists( $key, $date_query ) ) { + continue; + } + + // Throw a notice for each failing value. + foreach ( (array) $date_query[ $key ] as $_value ) { + $is_between = $_value >= $check['min'] && $_value <= $check['max']; + + if ( ! is_numeric( $_value ) || ! $is_between ) { + $error = sprintf( + /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */ + __( 'Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.' ), + '' . esc_html( $_value ) . '', + '' . esc_html( $key ) . '', + '' . esc_html( $check['min'] ) . '', + '' . esc_html( $check['max'] ) . '' + ); + + _doing_it_wrong( __CLASS__, $error, '4.1.0' ); + + $valid = false; + } + } + } + + // If we already have invalid date messages, don't bother running through checkdate(). + if ( ! $valid ) { + return $valid; + } + + $day_month_year_error_msg = ''; + + $day_exists = array_key_exists( 'day', $date_query ) && is_numeric( $date_query['day'] ); + $month_exists = array_key_exists( 'month', $date_query ) && is_numeric( $date_query['month'] ); + $year_exists = array_key_exists( 'year', $date_query ) && is_numeric( $date_query['year'] ); + + if ( $day_exists && $month_exists && $year_exists ) { + // 1. Checking day, month, year combination. + if ( ! wp_checkdate( $date_query['month'], $date_query['day'], $date_query['year'], sprintf( '%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day'] ) ) ) { + /* translators: 1: year, 2: month, 3: day of month */ + $day_month_year_error_msg = sprintf( + __( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ), + '' . esc_html( $date_query['year'] ) . '', + '' . esc_html( $date_query['month'] ) . '', + '' . esc_html( $date_query['day'] ) . '' + ); + + $valid = false; + } + + } elseif ( $day_exists && $month_exists ) { + /* + * 2. checking day, month combination + * We use 2012 because, as a leap year, it's the most permissive. + */ + if ( ! wp_checkdate( $date_query['month'], $date_query['day'], 2012, sprintf( '2012-%s-%s', $date_query['month'], $date_query['day'] ) ) ) { + /* translators: 1: month, 2: day of month */ + $day_month_year_error_msg = sprintf( + __( 'The following values do not describe a valid date: month %1$s, day %2$s.' ), + '' . esc_html( $date_query['month'] ) . '', + '' . esc_html( $date_query['day'] ) . '' + ); + + $valid = false; + } + } + + if ( ! empty( $day_month_year_error_msg ) ) { + _doing_it_wrong( __CLASS__, $day_month_year_error_msg, '4.1.0' ); + } + + return $valid; + } + + /** + * Validates a column name parameter. + * + * Column names without a table prefix (like 'post_date') are checked against a whitelist of + * known tables, and then, if found, have a table prefix (such as 'wp_posts.') prepended. + * Prefixed column names (such as 'wp_posts.post_date') bypass this whitelist check, + * and are only sanitized to remove illegal characters. + * + * @since 3.7.0 + * + * @param string $column The user-supplied column name. + * @return string A validated column name value. + */ + public function validate_column( $column ) { + global $wpdb; + + $valid_columns = array( + 'post_date', 'post_date_gmt', 'post_modified', + 'post_modified_gmt', 'comment_date', 'comment_date_gmt', + 'user_registered', 'registered', 'last_updated', + ); + + // Attempt to detect a table prefix. + if ( false === strpos( $column, '.' ) ) { + /** + * Filters the list of valid date query columns. + * + * @since 3.7.0 + * @since 4.1.0 Added 'user_registered' to the default recognized columns. + * + * @param array $valid_columns An array of valid date query columns. Defaults + * are 'post_date', 'post_date_gmt', 'post_modified', + * 'post_modified_gmt', 'comment_date', 'comment_date_gmt', + * 'user_registered' + */ + if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) { + $column = 'post_date'; + } + + $known_columns = array( + $wpdb->posts => array( + 'post_date', + 'post_date_gmt', + 'post_modified', + 'post_modified_gmt', + ), + $wpdb->comments => array( + 'comment_date', + 'comment_date_gmt', + ), + $wpdb->users => array( + 'user_registered', + ), + $wpdb->blogs => array( + 'registered', + 'last_updated', + ), + ); + + // If it's a known column name, add the appropriate table prefix. + foreach ( $known_columns as $table_name => $table_columns ) { + if ( in_array( $column, $table_columns ) ) { + $column = $table_name . '.' . $column; + break; + } + } + + } + + // Remove unsafe characters. + return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column ); + } + + /** + * Generate WHERE clause to be appended to a main query. + * + * @since 3.7.0 + * + * @return string MySQL WHERE clause. + */ + public function get_sql() { + $sql = $this->get_sql_clauses(); + + $where = $sql['where']; + + /** + * Filters the date query WHERE clause. + * + * @since 3.7.0 + * + * @param string $where WHERE clause of the date query. + * @param WP_Date_Query $this The WP_Date_Query instance. + */ + return apply_filters( 'get_date_sql', $where, $this ); + } + + /** + * Generate SQL clauses to be appended to a main query. + * + * Called by the public WP_Date_Query::get_sql(), this method is abstracted + * out to maintain parity with the other Query classes. + * + * @since 4.1.0 + * + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_clauses() { + $sql = $this->get_sql_for_query( $this->queries ); + + if ( ! empty( $sql['where'] ) ) { + $sql['where'] = ' AND ' . $sql['where']; + } + + return $sql; + } + + /** + * Generate SQL clauses for a single query array. + * + * If nested subqueries are found, this method recurses the tree to + * produce the properly nested SQL. + * + * @since 4.1.0 + * + * @param array $query Query to parse. + * @param int $depth Optional. Number of tree levels deep we currently are. + * Used to calculate indentation. Default 0. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to a single query array. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_for_query( $query, $depth = 0 ) { + $sql_chunks = array( + 'join' => array(), + 'where' => array(), + ); + + $sql = array( + 'join' => '', + 'where' => '', + ); + + $indent = ''; + for ( $i = 0; $i < $depth; $i++ ) { + $indent .= " "; + } + + foreach ( $query as $key => $clause ) { + if ( 'relation' === $key ) { + $relation = $query['relation']; + } elseif ( is_array( $clause ) ) { + + // This is a first-order clause. + if ( $this->is_first_order_clause( $clause ) ) { + $clause_sql = $this->get_sql_for_clause( $clause, $query ); + + $where_count = count( $clause_sql['where'] ); + if ( ! $where_count ) { + $sql_chunks['where'][] = ''; + } elseif ( 1 === $where_count ) { + $sql_chunks['where'][] = $clause_sql['where'][0]; + } else { + $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; + } + + $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); + // This is a subquery, so we recurse. + } else { + $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); + + $sql_chunks['where'][] = $clause_sql['where']; + $sql_chunks['join'][] = $clause_sql['join']; + } + } + } + + // Filter to remove empties. + $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); + $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); + + if ( empty( $relation ) ) { + $relation = 'AND'; + } + + // Filter duplicate JOIN clauses and combine into a single string. + if ( ! empty( $sql_chunks['join'] ) ) { + $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); + } + + // Generate a single WHERE clause with proper brackets and indentation. + if ( ! empty( $sql_chunks['where'] ) ) { + $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; + } + + return $sql; + } + + /** + * Turns a single date clause into pieces for a WHERE clause. + * + * A wrapper for get_sql_for_clause(), included here for backward + * compatibility while retaining the naming convention across Query classes. + * + * @since 3.7.0 + * + * @param array $query Date query arguments. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_for_subquery( $query ) { + return $this->get_sql_for_clause( $query, '' ); + } + + /** + * Turns a first-order date query into SQL for a WHERE clause. + * + * @since 4.1.0 + * + * @param array $query Date query clause. + * @param array $parent_query Parent query of the current date query. + * @return array { + * Array containing JOIN and WHERE SQL clauses to append to the main query. + * + * @type string $join SQL fragment to append to the main JOIN clause. + * @type string $where SQL fragment to append to the main WHERE clause. + * } + */ + protected function get_sql_for_clause( $query, $parent_query ) { + global $wpdb; + + // The sub-parts of a $where part. + $where_parts = array(); + + $column = ( ! empty( $query['column'] ) ) ? esc_sql( $query['column'] ) : $this->column; + + $column = $this->validate_column( $column ); + + $compare = $this->get_compare( $query ); + + $inclusive = ! empty( $query['inclusive'] ); + + // Assign greater- and less-than values. + $lt = '<'; + $gt = '>'; + + if ( $inclusive ) { + $lt .= '='; + $gt .= '='; + } + + // Range queries. + if ( ! empty( $query['after'] ) ) { + $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); + } + if ( ! empty( $query['before'] ) ) { + $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); + } + // Specific value queries. + + if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) + $where_parts[] = "YEAR( $column ) $compare $value"; + + if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { + $where_parts[] = "MONTH( $column ) $compare $value"; + } elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) { + $where_parts[] = "MONTH( $column ) $compare $value"; + } + if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) { + $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; + } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { + $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; + } + if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) + $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; + + if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) + $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; + + if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) + $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; + + if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) + $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; + + if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { + // Avoid notices. + foreach ( array( 'hour', 'minute', 'second' ) as $unit ) { + if ( ! isset( $query[ $unit ] ) ) { + $query[ $unit ] = null; + } + } + + if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) { + $where_parts[] = $time_query; + } + } + + /* + * Return an array of 'join' and 'where' for compatibility + * with other query classes. + */ + return array( + 'where' => $where_parts, + 'join' => array(), + ); + } + + /** + * Builds and validates a value string based on the comparison operator. + * + * @since 3.7.0 + * + * @param string $compare The compare operator to use + * @param string|array $value The value + * @return string|false|int The value to be used in SQL or false on error. + */ + public function build_value( $compare, $value ) { + if ( ! isset( $value ) ) + return false; + + switch ( $compare ) { + case 'IN': + case 'NOT IN': + $value = (array) $value; + + // Remove non-numeric values. + $value = array_filter( $value, 'is_numeric' ); + + if ( empty( $value ) ) { + return false; + } + + return '(' . implode( ',', array_map( 'intval', $value ) ) . ')'; + + case 'BETWEEN': + case 'NOT BETWEEN': + if ( ! is_array( $value ) || 2 != count( $value ) ) { + $value = array( $value, $value ); + } else { + $value = array_values( $value ); + } + + // If either value is non-numeric, bail. + foreach ( $value as $v ) { + if ( ! is_numeric( $v ) ) { + return false; + } + } + + $value = array_map( 'intval', $value ); + + return $value[0] . ' AND ' . $value[1]; + + default: + if ( ! is_numeric( $value ) ) { + return false; + } + + return (int) $value; + } + } + + /** + * Builds a MySQL format date/time based on some query parameters. + * + * You can pass an array of values (year, month, etc.) with missing parameter values being defaulted to + * either the maximum or minimum values (controlled by the $default_to parameter). Alternatively you can + * pass a string that will be run through strtotime(). + * + * @since 3.7.0 + * + * @param string|array $datetime An array of parameters or a strotime() string + * @param bool $default_to_max Whether to round up incomplete dates. Supported by values + * of $datetime that are arrays, or string values that are a + * subset of MySQL date format ('Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i'). + * Default: false. + * @return string|false A MySQL format date/time or false on failure + */ + public function build_mysql_datetime( $datetime, $default_to_max = false ) { + $now = current_time( 'timestamp' ); + + if ( ! is_array( $datetime ) ) { + + /* + * Try to parse some common date formats, so we can detect + * the level of precision and support the 'inclusive' parameter. + */ + if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) { + // Y + $datetime = array( + 'year' => intval( $matches[1] ), + ); + + } elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) { + // Y-m + $datetime = array( + 'year' => intval( $matches[1] ), + 'month' => intval( $matches[2] ), + ); + + } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) { + // Y-m-d + $datetime = array( + 'year' => intval( $matches[1] ), + 'month' => intval( $matches[2] ), + 'day' => intval( $matches[3] ), + ); + + } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) { + // Y-m-d H:i + $datetime = array( + 'year' => intval( $matches[1] ), + 'month' => intval( $matches[2] ), + 'day' => intval( $matches[3] ), + 'hour' => intval( $matches[4] ), + 'minute' => intval( $matches[5] ), + ); + } + + // If no match is found, we don't support default_to_max. + if ( ! is_array( $datetime ) ) { + // @todo Timezone issues here possibly + return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) ); + } + } + + $datetime = array_map( 'absint', $datetime ); + + if ( ! isset( $datetime['year'] ) ) + $datetime['year'] = gmdate( 'Y', $now ); + + if ( ! isset( $datetime['month'] ) ) + $datetime['month'] = ( $default_to_max ) ? 12 : 1; + + if ( ! isset( $datetime['day'] ) ) + $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; + + if ( ! isset( $datetime['hour'] ) ) + $datetime['hour'] = ( $default_to_max ) ? 23 : 0; + + if ( ! isset( $datetime['minute'] ) ) + $datetime['minute'] = ( $default_to_max ) ? 59 : 0; + + if ( ! isset( $datetime['second'] ) ) + $datetime['second'] = ( $default_to_max ) ? 59 : 0; + + return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); + } + + /** + * Builds a query string for comparing time values (hour, minute, second). + * + * If just hour, minute, or second is set than a normal comparison will be done. + * However if multiple values are passed, a pseudo-decimal time will be created + * in order to be able to accurately compare against. + * + * @since 3.7.0 + * + * @param string $column The column to query against. Needs to be pre-validated! + * @param string $compare The comparison operator. Needs to be pre-validated! + * @param int|null $hour Optional. An hour value (0-23). + * @param int|null $minute Optional. A minute value (0-59). + * @param int|null $second Optional. A second value (0-59). + * @return string|false A query part or false on failure. + */ + public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { + global $wpdb; + + // Have to have at least one + if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) + return false; + + // Complex combined queries aren't supported for multi-value queries + if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { + $return = array(); + + if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) + $return[] = "HOUR( $column ) $compare $value"; + + if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) + $return[] = "MINUTE( $column ) $compare $value"; + + if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) + $return[] = "SECOND( $column ) $compare $value"; + + return implode( ' AND ', $return ); + } + + // Cases where just one unit is set + if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { + return "HOUR( $column ) $compare $value"; + } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { + return "MINUTE( $column ) $compare $value"; + } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { + return "SECOND( $column ) $compare $value"; + } + + // Single units were already handled. Since hour & second isn't allowed, minute must to be set. + if ( ! isset( $minute ) ) + return false; + + $format = $time = ''; + + // Hour + if ( null !== $hour ) { + $format .= '%H.'; + $time .= sprintf( '%02d', $hour ) . '.'; + } else { + $format .= '0.'; + $time .= '0.'; + } + + // Minute + $format .= '%i'; + $time .= sprintf( '%02d', $minute ); + + if ( isset( $second ) ) { + $format .= '%s'; + $time .= sprintf( '%02d', $second ); + } + + return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); + } +} diff --git a/backend/wp-includes/default-constants.php b/backend/wp-includes/default-constants.php new file mode 100644 index 0000000..94da94d --- /dev/null +++ b/backend/wp-includes/default-constants.php @@ -0,0 +1,363 @@ + 268435456 /* = 256M */ ) { + define( 'WP_MAX_MEMORY_LIMIT', $current_limit ); + } else { + define( 'WP_MAX_MEMORY_LIMIT', '256M' ); + } + } + + // Set memory limits. + $wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT ); + if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) { + @ini_set( 'memory_limit', WP_MEMORY_LIMIT ); + } + + if ( ! isset($blog_id) ) + $blog_id = 1; + + if ( !defined('WP_CONTENT_DIR') ) + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down + + // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development. + if ( !defined('WP_DEBUG') ) + define( 'WP_DEBUG', false ); + + // Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for + // display_errors and not force errors to be displayed. Use false to force display_errors off. + if ( !defined('WP_DEBUG_DISPLAY') ) + define( 'WP_DEBUG_DISPLAY', true ); + + // Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log. + if ( !defined('WP_DEBUG_LOG') ) + define('WP_DEBUG_LOG', false); + + if ( !defined('WP_CACHE') ) + define('WP_CACHE', false); + + // Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified, + // non-concatenated scripts and stylesheets. + if ( ! defined( 'SCRIPT_DEBUG' ) ) { + if ( ! empty( $GLOBALS['wp_version'] ) ) { + $develop_src = false !== strpos( $GLOBALS['wp_version'], '-src' ); + } else { + $develop_src = false; + } + + define( 'SCRIPT_DEBUG', $develop_src ); + } + + /** + * Private + */ + if ( !defined('MEDIA_TRASH') ) + define('MEDIA_TRASH', false); + + if ( !defined('SHORTINIT') ) + define('SHORTINIT', false); + + // Constants for features added to WP that should short-circuit their plugin implementations + define( 'WP_FEATURE_BETTER_PASSWORDS', true ); + + /**#@+ + * Constants for expressing human-readable intervals + * in their respective number of seconds. + * + * Please note that these values are approximate and are provided for convenience. + * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and + * YEAR_IN_SECONDS does not take leap years into account. + * + * If you need more accuracy please consider using the DateTime class (https://secure.php.net/manual/en/class.datetime.php). + * + * @since 3.5.0 + * @since 4.4.0 Introduced `MONTH_IN_SECONDS`. + */ + define( 'MINUTE_IN_SECONDS', 60 ); + define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS ); + define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS ); + define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS ); + define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS ); + define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS ); + /**#@-*/ +} + +/** + * Defines plugin directory WordPress constants + * + * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in + * + * @since 3.0.0 + */ +function wp_plugin_directory_constants() { + if ( !defined('WP_CONTENT_URL') ) + define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up + + /** + * Allows for the plugins directory to be moved from the default location. + * + * @since 2.6.0 + */ + if ( !defined('WP_PLUGIN_DIR') ) + define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash + + /** + * Allows for the plugins directory to be moved from the default location. + * + * @since 2.6.0 + */ + if ( !defined('WP_PLUGIN_URL') ) + define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash + + /** + * Allows for the plugins directory to be moved from the default location. + * + * @since 2.1.0 + * @deprecated + */ + if ( !defined('PLUGINDIR') ) + define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat. + + /** + * Allows for the mu-plugins directory to be moved from the default location. + * + * @since 2.8.0 + */ + if ( !defined('WPMU_PLUGIN_DIR') ) + define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash + + /** + * Allows for the mu-plugins directory to be moved from the default location. + * + * @since 2.8.0 + */ + if ( !defined('WPMU_PLUGIN_URL') ) + define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash + + /** + * Allows for the mu-plugins directory to be moved from the default location. + * + * @since 2.8.0 + * @deprecated + */ + if ( !defined( 'MUPLUGINDIR' ) ) + define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat. +} + +/** + * Defines cookie related WordPress constants + * + * Defines constants after multisite is loaded. + * @since 3.0.0 + */ +function wp_cookie_constants() { + /** + * Used to guarantee unique hash cookies + * + * @since 1.5.0 + */ + if ( !defined( 'COOKIEHASH' ) ) { + $siteurl = get_site_option( 'siteurl' ); + if ( $siteurl ) + define( 'COOKIEHASH', md5( $siteurl ) ); + else + define( 'COOKIEHASH', '' ); + } + + /** + * @since 2.0.0 + */ + if ( !defined('USER_COOKIE') ) + define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH); + + /** + * @since 2.0.0 + */ + if ( !defined('PASS_COOKIE') ) + define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH); + + /** + * @since 2.5.0 + */ + if ( !defined('AUTH_COOKIE') ) + define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH); + + /** + * @since 2.6.0 + */ + if ( !defined('SECURE_AUTH_COOKIE') ) + define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH); + + /** + * @since 2.6.0 + */ + if ( !defined('LOGGED_IN_COOKIE') ) + define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH); + + /** + * @since 2.3.0 + */ + if ( !defined('TEST_COOKIE') ) + define('TEST_COOKIE', 'wordpress_test_cookie'); + + /** + * @since 1.2.0 + */ + if ( !defined('COOKIEPATH') ) + define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) ); + + /** + * @since 1.5.0 + */ + if ( !defined('SITECOOKIEPATH') ) + define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) ); + + /** + * @since 2.6.0 + */ + if ( !defined('ADMIN_COOKIE_PATH') ) + define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' ); + + /** + * @since 2.6.0 + */ + if ( !defined('PLUGINS_COOKIE_PATH') ) + define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) ); + + /** + * @since 2.0.0 + */ + if ( !defined('COOKIE_DOMAIN') ) + define('COOKIE_DOMAIN', false); +} + +/** + * Defines cookie related WordPress constants + * + * @since 3.0.0 + */ +function wp_ssl_constants() { + /** + * @since 2.6.0 + */ + if ( !defined( 'FORCE_SSL_ADMIN' ) ) { + if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) { + define( 'FORCE_SSL_ADMIN', true ); + } else { + define( 'FORCE_SSL_ADMIN', false ); + } + } + force_ssl_admin( FORCE_SSL_ADMIN ); + + /** + * @since 2.6.0 + * @deprecated 4.0.0 + */ + if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) { + force_ssl_admin( true ); + } +} + +/** + * Defines functionality related WordPress constants + * + * @since 3.0.0 + */ +function wp_functionality_constants() { + /** + * @since 2.5.0 + */ + if ( !defined( 'AUTOSAVE_INTERVAL' ) ) + define( 'AUTOSAVE_INTERVAL', 60 ); + + /** + * @since 2.9.0 + */ + if ( !defined( 'EMPTY_TRASH_DAYS' ) ) + define( 'EMPTY_TRASH_DAYS', 30 ); + + if ( !defined('WP_POST_REVISIONS') ) + define('WP_POST_REVISIONS', true); + + /** + * @since 3.3.0 + */ + if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) ) + define('WP_CRON_LOCK_TIMEOUT', 60); // In seconds +} + +/** + * Defines templating related WordPress constants + * + * @since 3.0.0 + */ +function wp_templating_constants() { + /** + * Filesystem path to the current active template directory + * @since 1.5.0 + */ + define('TEMPLATEPATH', get_template_directory()); + + /** + * Filesystem path to the current active template stylesheet directory + * @since 2.1.0 + */ + define('STYLESHEETPATH', get_stylesheet_directory()); + + /** + * Slug of the default theme for this installation. + * Used as the default theme when installing new sites. + * It will be used as the fallback if the current theme doesn't exist. + * + * @since 3.0.0 + * @see WP_Theme::get_core_default_theme() + */ + if ( !defined('WP_DEFAULT_THEME') ) + define( 'WP_DEFAULT_THEME', 'twentyseventeen' ); + +} diff --git a/backend/wp-includes/default-filters.php b/backend/wp-includes/default-filters.php new file mode 100644 index 0000000..e012beb --- /dev/null +++ b/backend/wp-includes/default-filters.php @@ -0,0 +1,537 @@ + $post->ID, + 'Author_ID' => $post->post_author, + 'Date' => $post->post_date, + 'Content' => $post->post_content, + 'Excerpt' => $post->post_excerpt, + 'Title' => $post->post_title, + 'Category' => $post->post_category, + 'post_status' => $post->post_status, + 'comment_status' => $post->comment_status, + 'ping_status' => $post->ping_status, + 'post_password' => $post->post_password, + 'to_ping' => $post->to_ping, + 'pinged' => $post->pinged, + 'post_type' => $post->post_type, + 'post_name' => $post->post_name + ); + + return $postdata; +} + +/** + * Sets up the WordPress Loop. + * + * Use The Loop instead. + * + * @link https://codex.wordpress.org/The_Loop + * + * @since 1.0.1 + * @deprecated 1.5.0 + */ +function start_wp() { + global $wp_query; + + _deprecated_function( __FUNCTION__, '1.5.0', __('new WordPress Loop') ); + + // Since the old style loop is being used, advance the query iterator here. + $wp_query->next_post(); + + setup_postdata( get_post() ); +} + +/** + * Returns or prints a category ID. + * + * @since 0.71 + * @deprecated 0.71 Use get_the_category() + * @see get_the_category() + * + * @param bool $echo Optional. Whether to echo the output. Default true. + * @return int Category ID. + */ +function the_category_ID($echo = true) { + _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); + + // Grab the first cat in the list. + $categories = get_the_category(); + $cat = $categories[0]->term_id; + + if ( $echo ) + echo $cat; + + return $cat; +} + +/** + * Prints a category with optional text before and after. + * + * @since 0.71 + * @deprecated 0.71 Use get_the_category_by_ID() + * @see get_the_category_by_ID() + * + * @param string $before Optional. Text to display before the category. Default empty. + * @param string $after Optional. Text to display after the category. Default empty. + */ +function the_category_head( $before = '', $after = '' ) { + global $currentcat, $previouscat; + + _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); + + // Grab the first cat in the list. + $categories = get_the_category(); + $currentcat = $categories[0]->category_id; + if ( $currentcat != $previouscat ) { + echo $before; + echo get_the_category_by_ID($currentcat); + echo $after; + $previouscat = $currentcat; + } +} + +/** + * Prints a link to the previous post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use previous_post_link() + * @see previous_post_link() + * + * @param string $format + * @param string $previous + * @param string $title + * @param string $in_same_cat + * @param int $limitprev + * @param string $excluded_categories + */ +function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { + + _deprecated_function( __FUNCTION__, '2.0.0', 'previous_post_link()' ); + + if ( empty($in_same_cat) || 'no' == $in_same_cat ) + $in_same_cat = false; + else + $in_same_cat = true; + + $post = get_previous_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $string = ''.$previous; + if ( 'yes' == $title ) + $string .= apply_filters('the_title', $post->post_title, $post->ID); + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; +} + +/** + * Prints link to the next post. + * + * @since 0.71 + * @deprecated 2.0.0 Use next_post_link() + * @see next_post_link() + * + * @param string $format + * @param string $next + * @param string $title + * @param string $in_same_cat + * @param int $limitnext + * @param string $excluded_categories + */ +function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { + _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); + + if ( empty($in_same_cat) || 'no' == $in_same_cat ) + $in_same_cat = false; + else + $in_same_cat = true; + + $post = get_next_post($in_same_cat, $excluded_categories); + + if ( !$post ) + return; + + $string = ''.$next; + if ( 'yes' == $title ) + $string .= apply_filters('the_title', $post->post_title, $post->ID); + $string .= ''; + $format = str_replace('%', $string, $format); + echo $format; +} + +/** + * Whether user can create a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ +function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $author_data = get_userdata($user_id); + return ($author_data->user_level > 1); +} + +/** + * Whether user can create a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ +function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $author_data = get_userdata($user_id); + return ($author_data->user_level >= 1); +} + +/** + * Whether user can edit a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ +function user_can_edit_post($user_id, $post_id, $blog_id = 1) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $author_data = get_userdata($user_id); + $post = get_post($post_id); + $post_author_data = get_userdata($post->post_author); + + if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) + || ($author_data->user_level > $post_author_data->user_level) + || ($author_data->user_level >= 10) ) { + return true; + } else { + return false; + } +} + +/** + * Whether user can delete a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool + */ +function user_can_delete_post($user_id, $post_id, $blog_id = 1) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + // right now if one can edit, one can delete + return user_can_edit_post($user_id, $post_id, $blog_id); +} + +/** + * Whether user can set new posts' dates. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $blog_id Not Used + * @param int $category_id Not Used + * @return bool + */ +function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $author_data = get_userdata($user_id); + return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); +} + +/** + * Whether user can delete a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool returns true if $user_id can edit $post_id's date + */ +function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $author_data = get_userdata($user_id); + return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); +} + +/** + * Whether user can delete a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool returns true if $user_id can edit $post_id's comments + */ +function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + // right now if one can edit a post, one can edit comments made on it + return user_can_edit_post($user_id, $post_id, $blog_id); +} + +/** + * Whether user can delete a post. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $post_id + * @param int $blog_id Not Used + * @return bool returns true if $user_id can delete $post_id's comments + */ +function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + // right now if one can edit comments, one can delete comments + return user_can_edit_post_comments($user_id, $post_id, $blog_id); +} + +/** + * Can user can edit other user. + * + * @since 1.5.0 + * @deprecated 2.0.0 Use current_user_can() + * @see current_user_can() + * + * @param int $user_id + * @param int $other_user + * @return bool + */ +function user_can_edit_user($user_id, $other_user) { + _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); + + $user = get_userdata($user_id); + $other = get_userdata($other_user); + if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) + return true; + else + return false; +} + +/** + * Gets the links associated with category $cat_name. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param string $cat_name Optional. The category name to use. If no match is found uses all. + * @param string $before Optional. The html to output before the link. + * @param string $after Optional. The html to output after the link. + * @param string $between Optional. The html to output between the link/image and its description. Not used if no image or $show_images is true. + * @param bool $show_images Optional. Whether to show images (if defined). + * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner. + * If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a + * random order. + * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined. + * @param bool $show_rating Optional. Show rating stars/chars. + * @param int $limit Optional. Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Optional. Whether to show last updated timestamp + */ +function get_linksbyname($cat_name = "noname", $before = '', $after = '
          ', $between = " ", $show_images = true, $orderby = 'id', + $show_description = true, $show_rating = false, + $limit = -1, $show_updated = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + $cat_id = -1; + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + + get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); +} + +/** + * Gets the links associated with the named category. + * + * @since 1.0.1 + * @deprecated 2.1.0 Use wp_list_bookmarks() + * @see wp_list_bookmarks() + * + * @param string $category The category to use. + * @param string $args + * @return string|null + */ +function wp_get_linksbyname($category, $args = '') { + _deprecated_function(__FUNCTION__, '2.1.0', 'wp_list_bookmarks()'); + + $defaults = array( + 'after' => '
          ', + 'before' => '', + 'categorize' => 0, + 'category_after' => '', + 'category_before' => '', + 'category_name' => $category, + 'show_description' => 1, + 'title_li' => '', + ); + + $r = wp_parse_args( $args, $defaults ); + + return wp_list_bookmarks($r); +} + +/** + * Gets an array of link objects associated with category $cat_name. + * + * $links = get_linkobjectsbyname( 'fred' ); + * foreach ( $links as $link ) { + * echo '
        • ' . $link->link_name . '
        • '; + * } + * + * @since 1.0.1 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param string $cat_name The category name to use. If no match is found uses all. + * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'. + * Or maybe owner. If you start the name with an underscore the order will be reversed. You can also + * specify 'rand' as the order which will return links in a random order. + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @return array + */ +function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + $cat_id = -1; + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + + return get_linkobjects($cat_id, $orderby, $limit); +} + +/** + * Gets an array of link objects associated with category n. + * + * Usage: + * + * $links = get_linkobjects(1); + * if ($links) { + * foreach ($links as $link) { + * echo '
        • '.$link->link_name.'
          '.$link->link_description.'
        • '; + * } + * } + * + * Fields are: + * + * - link_id + * - link_url + * - link_name + * - link_image + * - link_target + * - link_category + * - link_description + * - link_visible + * - link_owner + * - link_rating + * - link_updated + * - link_rel + * - link_notes + * + * @since 1.0.1 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @return array + */ +function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; + + $links_array = array(); + foreach ($links as $link) + $links_array[] = $link; + + return $links_array; +} + +/** + * Gets the links associated with category 'cat_name' and display rating stars/chars. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param string $cat_name The category name to use. If no match is found uses all + * @param string $before The html to output before the link + * @param string $after The html to output after the link + * @param string $between The html to output between the link/image and its description. Not used if no image or show_images is true + * @param bool $show_images Whether to show images (if defined). + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param bool $show_description Whether to show the description if show_images=false/not defined + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Whether to show last updated timestamp + */ +function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '
          ', $between = " ", + $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); +} + +/** + * Gets the links associated with category n and display rating stars/chars. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $before The html to output before the link + * @param string $after The html to output after the link + * @param string $between The html to output between the link/image and its description. Not used if no image or show_images == true + * @param bool $show_images Whether to show images (if defined). + * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the + * order which will return links in a random order. + * @param bool $show_description Whether to show the description if show_images=false/not defined. + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated Whether to show last updated timestamp + */ +function get_links_withrating($category = -1, $before = '', $after = '
          ', $between = " ", $show_images = true, + $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); +} + +/** + * Gets the auto_toggle setting. + * + * @since 0.71 + * @deprecated 2.1.0 + * + * @param int $id The category to get. If no category supplied uses 0 + * @return int Only returns 0. + */ +function get_autotoggle($id = 0) { + _deprecated_function( __FUNCTION__, '2.1.0' ); + return 0; +} + +/** + * Lists categories. + * + * @since 0.71 + * @deprecated 2.1.0 Use wp_list_categories() + * @see wp_list_categories() + * + * @param int $optionall + * @param string $all + * @param string $sort_column + * @param string $sort_order + * @param string $file + * @param bool $list + * @param int $optiondates + * @param int $optioncount + * @param int $hide_empty + * @param int $use_desc_for_title + * @param bool $children + * @param int $child_of + * @param int $categories + * @param int $recurse + * @param string $feed + * @param string $feed_image + * @param string $exclude + * @param bool $hierarchical + * @return false|null + */ +function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, + $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, + $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); + + $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', + 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); + return wp_list_cats($query); +} + +/** + * Lists categories. + * + * @since 1.2.0 + * @deprecated 2.1.0 Use wp_list_categories() + * @see wp_list_categories() + * + * @param string|array $args + * @return false|null|string + */ +function wp_list_cats($args = '') { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_categories()' ); + + $r = wp_parse_args( $args ); + + // Map to new names. + if ( isset($r['optionall']) && isset($r['all'])) + $r['show_option_all'] = $r['all']; + if ( isset($r['sort_column']) ) + $r['orderby'] = $r['sort_column']; + if ( isset($r['sort_order']) ) + $r['order'] = $r['sort_order']; + if ( isset($r['optiondates']) ) + $r['show_last_update'] = $r['optiondates']; + if ( isset($r['optioncount']) ) + $r['show_count'] = $r['optioncount']; + if ( isset($r['list']) ) + $r['style'] = $r['list'] ? 'list' : 'break'; + $r['title_li'] = ''; + + return wp_list_categories($r); +} + +/** + * Deprecated method for generating a drop-down of categories. + * + * @since 0.71 + * @deprecated 2.1.0 Use wp_dropdown_categories() + * @see wp_dropdown_categories() + * + * @param int $optionall + * @param string $all + * @param string $orderby + * @param string $order + * @param int $show_last_update + * @param int $show_count + * @param int $hide_empty + * @param bool $optionnone + * @param int $selected + * @param int $exclude + * @return string + */ +function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', + $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, + $selected = 0, $exclude = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_dropdown_categories()' ); + + $show_option_all = ''; + if ( $optionall ) + $show_option_all = $all; + + $show_option_none = ''; + if ( $optionnone ) + $show_option_none = __('None'); + + $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', + 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); + $query = add_query_arg($vars, ''); + return wp_dropdown_categories($query); +} + +/** + * Lists authors. + * + * @since 1.2.0 + * @deprecated 2.1.0 Use wp_list_authors() + * @see wp_list_authors() + * + * @param bool $optioncount + * @param bool $exclude_admin + * @param bool $show_fullname + * @param bool $hide_empty + * @param string $feed + * @param string $feed_image + * @return null|string + */ +function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_authors()' ); + + $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); + return wp_list_authors($args); +} + +/** + * Retrieves a list of post categories. + * + * @since 1.0.1 + * @deprecated 2.1.0 Use wp_get_post_categories() + * @see wp_get_post_categories() + * + * @param int $blogid Not Used + * @param int $post_ID + * @return array + */ +function wp_get_post_cats($blogid = '1', $post_ID = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' ); + return wp_get_post_categories($post_ID); +} + +/** + * Sets the categories that the post id belongs to. + * + * @since 1.0.1 + * @deprecated 2.1.0 + * @deprecated Use wp_set_post_categories() + * @see wp_set_post_categories() + * + * @param int $blogid Not used + * @param int $post_ID + * @param array $post_categories + * @return bool|mixed + */ +function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' ); + return wp_set_post_categories($post_ID, $post_categories); +} + +/** + * Retrieves a list of archives. + * + * @since 0.71 + * @deprecated 2.1.0 Use wp_get_archives() + * @see wp_get_archives() + * + * @param string $type + * @param string $limit + * @param string $format + * @param string $before + * @param string $after + * @param bool $show_post_count + * @return string|null + */ +function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_archives()' ); + $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); + return wp_get_archives($args); +} + +/** + * Returns or Prints link to the author's posts. + * + * @since 1.2.0 + * @deprecated 2.1.0 Use get_author_posts_url() + * @see get_author_posts_url() + * + * @param bool $echo + * @param int $author_id + * @param string $author_nicename Optional. + * @return string|null + */ +function get_author_link($echo, $author_id, $author_nicename = '') { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_author_posts_url()' ); + + $link = get_author_posts_url($author_id, $author_nicename); + + if ( $echo ) + echo $link; + return $link; +} + +/** + * Print list of pages based on arguments. + * + * @since 0.71 + * @deprecated 2.1.0 Use wp_link_pages() + * @see wp_link_pages() + * + * @param string $before + * @param string $after + * @param string $next_or_number + * @param string $nextpagelink + * @param string $previouspagelink + * @param string $pagelink + * @param string $more_file + * @return string + */ +function link_pages($before='
          ', $after='
          ', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', + $pagelink='%', $more_file='') { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_link_pages()' ); + + $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); + return wp_link_pages($args); +} + +/** + * Get value based on option. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_option() + * @see get_option() + * + * @param string $option + * @return string + */ +function get_settings($option) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_option()' ); + + return get_option($option); +} + +/** + * Print the permalink of the current post in the loop. + * + * @since 0.71 + * @deprecated 1.2.0 Use the_permalink() + * @see the_permalink() + */ +function permalink_link() { + _deprecated_function( __FUNCTION__, '1.2.0', 'the_permalink()' ); + the_permalink(); +} + +/** + * Print the permalink to the RSS feed. + * + * @since 0.71 + * @deprecated 2.3.0 Use the_permalink_rss() + * @see the_permalink_rss() + * + * @param string $deprecated + */ +function permalink_single_rss($deprecated = '') { + _deprecated_function( __FUNCTION__, '2.3.0', 'the_permalink_rss()' ); + the_permalink_rss(); +} + +/** + * Gets the links associated with category. + * + * @since 1.0.1 + * @deprecated 2.1.0 Use wp_list_bookmarks() + * @see wp_list_bookmarks() + * + * @param string $args a query string + * @return null|string + */ +function wp_get_links($args = '') { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); + + if ( strpos( $args, '=' ) === false ) { + $cat_id = $args; + $args = add_query_arg( 'category', $cat_id, $args ); + } + + $defaults = array( + 'after' => '
          ', + 'before' => '', + 'between' => ' ', + 'categorize' => 0, + 'category' => '', + 'echo' => true, + 'limit' => -1, + 'orderby' => 'name', + 'show_description' => true, + 'show_images' => true, + 'show_rating' => false, + 'show_updated' => true, + 'title_li' => '', + ); + + $r = wp_parse_args( $args, $defaults ); + + return wp_list_bookmarks($r); +} + +/** + * Gets the links associated with category by id. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_bookmarks() + * @see get_bookmarks() + * + * @param int $category The category to use. If no category supplied uses all + * @param string $before the html to output before the link + * @param string $after the html to output after the link + * @param string $between the html to output between the link/image and its description. + * Not used if no image or show_images == true + * @param bool $show_images whether to show images (if defined). + * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url', + * 'description', or 'rating'. Or maybe owner. If you start the name with an + * underscore the order will be reversed. You can also specify 'rand' as the order + * which will return links in a random order. + * @param bool $show_description whether to show the description if show_images=false/not defined. + * @param bool $show_rating show rating stars/chars + * @param int $limit Limit to X entries. If not specified, all entries are shown. + * @param int $show_updated whether to show last updated timestamp + * @param bool $echo whether to echo the results, or return them instead + * @return null|string + */ +function get_links($category = -1, $before = '', $after = '
          ', $between = ' ', $show_images = true, $orderby = 'name', + $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); + + $order = 'ASC'; + if ( substr($orderby, 0, 1) == '_' ) { + $order = 'DESC'; + $orderby = substr($orderby, 1); + } + + if ( $category == -1 ) //get_bookmarks uses '' to signify all categories + $category = ''; + + $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); + + if ( !$results ) + return; + + $output = ''; + + foreach ( (array) $results as $row ) { + if ( !isset($row->recently_updated) ) + $row->recently_updated = false; + $output .= $before; + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_prepend'); + $the_link = '#'; + if ( !empty($row->link_url) ) + $the_link = esc_url($row->link_url); + $rel = $row->link_rel; + if ( '' != $rel ) + $rel = ' rel="' . $rel . '"'; + + $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); + $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); + $title = $desc; + + if ( $show_updated ) + if (substr($row->link_updated_f, 0, 2) != '00') + $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; + + if ( '' != $title ) + $title = ' title="' . $title . '"'; + + $alt = ' alt="' . $name . '"'; + + $target = $row->link_target; + if ( '' != $target ) + $target = ' target="' . $target . '"'; + + $output .= ''; + + if ( $row->link_image != null && $show_images ) { + if ( strpos($row->link_image, 'http') !== false ) + $output .= "link_image\" $alt $title />"; + else // If it's a relative path + $output .= "link_image\" $alt $title />"; + } else { + $output .= $name; + } + + $output .= ''; + + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_append'); + + if ( $show_description && '' != $desc ) + $output .= $between . $desc; + + if ($show_rating) { + $output .= $between . get_linkrating($row); + } + + $output .= "$after\n"; + } // end while + + if ( !$echo ) + return $output; + echo $output; +} + +/** + * Output entire list of links by category. + * + * Output a list of all links, listed by category, using the settings in + * $wpdb->linkcategories and output it as a nested HTML unordered list. + * + * @since 1.0.1 + * @deprecated 2.1.0 Use wp_list_bookmarks() + * @see wp_list_bookmarks() + * + * @param string $order Sort link categories by 'name' or 'id' + */ +function get_links_list($order = 'name') { + _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); + + $order = strtolower($order); + + // Handle link category sorting + $direction = 'ASC'; + if ( '_' == substr($order,0,1) ) { + $direction = 'DESC'; + $order = substr($order,1); + } + + if ( !isset($direction) ) + $direction = ''; + + $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); + + // Display each category + if ( $cats ) { + foreach ( (array) $cats as $cat ) { + // Handle each category. + + // Display the category name + echo '
        • ' . apply_filters('link_category', $cat->name ) . "

          \n\t
            \n"; + // Call get_links() with all the appropriate params + get_links($cat->term_id, '
          • ', "
          • ", "\n", true, 'name', false); + + // Close the last category + echo "\n\t
          \n
        • \n"; + } + } +} + +/** + * Show the link to the links popup and the number of links. + * + * @since 0.71 + * @deprecated 2.1.0 + * + * @param string $text the text of the link + * @param int $width the width of the popup window + * @param int $height the height of the popup window + * @param string $file the page to open in the popup window + * @param bool $count the number of links in the db + */ +function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { + _deprecated_function( __FUNCTION__, '2.1.0' ); +} + +/** + * Legacy function that retrieved the value of a link's link_rating field. + * + * @since 1.0.1 + * @deprecated 2.1.0 Use sanitize_bookmark_field() + * @see sanitize_bookmark_field() + * + * @param object $link Link object. + * @return mixed Value of the 'link_rating' field, false otherwise. + */ +function get_linkrating( $link ) { + _deprecated_function( __FUNCTION__, '2.1.0', 'sanitize_bookmark_field()' ); + return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); +} + +/** + * Gets the name of category by id. + * + * @since 0.71 + * @deprecated 2.1.0 Use get_category() + * @see get_category() + * + * @param int $id The category to get. If no category supplied uses 0 + * @return string + */ +function get_linkcatname($id = 0) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); + + $id = (int) $id; + + if ( empty($id) ) + return ''; + + $cats = wp_get_link_cats($id); + + if ( empty($cats) || ! is_array($cats) ) + return ''; + + $cat_id = (int) $cats[0]; // Take the first cat. + + $cat = get_category($cat_id); + return $cat->name; +} + +/** + * Print RSS comment feed link. + * + * @since 1.0.1 + * @deprecated 2.5.0 Use post_comments_feed_link() + * @see post_comments_feed_link() + * + * @param string $link_text + */ +function comments_rss_link($link_text = 'Comments RSS') { + _deprecated_function( __FUNCTION__, '2.5.0', 'post_comments_feed_link()' ); + post_comments_feed_link($link_text); +} + +/** + * Print/Return link to category RSS2 feed. + * + * @since 1.2.0 + * @deprecated 2.5.0 Use get_category_feed_link() + * @see get_category_feed_link() + * + * @param bool $echo + * @param int $cat_ID + * @return string + */ +function get_category_rss_link($echo = false, $cat_ID = 1) { + _deprecated_function( __FUNCTION__, '2.5.0', 'get_category_feed_link()' ); + + $link = get_category_feed_link($cat_ID, 'rss2'); + + if ( $echo ) + echo $link; + return $link; +} + +/** + * Print/Return link to author RSS feed. + * + * @since 1.2.0 + * @deprecated 2.5.0 Use get_author_feed_link() + * @see get_author_feed_link() + * + * @param bool $echo + * @param int $author_id + * @return string + */ +function get_author_rss_link($echo = false, $author_id = 1) { + _deprecated_function( __FUNCTION__, '2.5.0', 'get_author_feed_link()' ); + + $link = get_author_feed_link($author_id); + if ( $echo ) + echo $link; + return $link; +} + +/** + * Return link to the post RSS feed. + * + * @since 1.5.0 + * @deprecated 2.2.0 Use get_post_comments_feed_link() + * @see get_post_comments_feed_link() + * + * @return string + */ +function comments_rss() { + _deprecated_function( __FUNCTION__, '2.2.0', 'get_post_comments_feed_link()' ); + return esc_url( get_post_comments_feed_link() ); +} + +/** + * An alias of wp_create_user(). + * + * @since 2.0.0 + * @deprecated 2.0.0 Use wp_create_user() + * @see wp_create_user() + * + * @param string $username The user's username. + * @param string $password The user's password. + * @param string $email The user's email. + * @return int The new user's ID. + */ +function create_user($username, $password, $email) { + _deprecated_function( __FUNCTION__, '2.0.0', 'wp_create_user()' ); + return wp_create_user($username, $password, $email); +} + +/** + * Unused function. + * + * @deprecated 2.5.0 + */ +function gzip_compression() { + _deprecated_function( __FUNCTION__, '2.5.0' ); + return false; +} + +/** + * Retrieve an array of comment data about comment $comment_ID. + * + * @since 0.71 + * @deprecated 2.7.0 Use get_comment() + * @see get_comment() + * + * @param int $comment_ID The ID of the comment + * @param int $no_cache Whether to use the cache (cast to bool) + * @param bool $include_unapproved Whether to include unapproved comments + * @return array The comment data + */ +function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { + _deprecated_function( __FUNCTION__, '2.7.0', 'get_comment()' ); + return get_comment($comment_ID, ARRAY_A); +} + +/** + * Retrieve the category name by the category ID. + * + * @since 0.71 + * @deprecated 2.8.0 Use get_cat_name() + * @see get_cat_name() + * + * @param int $cat_ID Category ID + * @return string category name + */ +function get_catname( $cat_ID ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_cat_name()' ); + return get_cat_name( $cat_ID ); +} + +/** + * Retrieve category children list separated before and after the term IDs. + * + * @since 1.2.0 + * @deprecated 2.8.0 Use get_term_children() + * @see get_term_children() + * + * @param int $id Category ID to retrieve children. + * @param string $before Optional. Prepend before category term ID. + * @param string $after Optional, default is empty string. Append after category term ID. + * @param array $visited Optional. Category Term IDs that have already been added. + * @return string + */ +function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); + if ( 0 == $id ) + return ''; + + $chain = ''; + /** TODO: consult hierarchy */ + $cat_ids = get_all_category_ids(); + foreach ( (array) $cat_ids as $cat_id ) { + if ( $cat_id == $id ) + continue; + + $category = get_category( $cat_id ); + if ( is_wp_error( $category ) ) + return $category; + if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { + $visited[] = $category->term_id; + $chain .= $before.$category->term_id.$after; + $chain .= get_category_children( $category->term_id, $before, $after ); + } + } + return $chain; +} + +/** + * Retrieves all category IDs. + * + * @since 2.0.0 + * @deprecated 4.0.0 Use get_terms() + * @see get_terms() + * + * @link https://codex.wordpress.org/Function_Reference/get_all_category_ids + * + * @return object List of all of the category IDs. + */ +function get_all_category_ids() { + _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' ); + + if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) { + $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') ); + wp_cache_add( 'all_category_ids', $cat_ids, 'category' ); + } + + return $cat_ids; +} + +/** + * Retrieve the description of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's description. + */ +function get_the_author_description() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'description\')' ); + return get_the_author_meta('description'); +} + +/** + * Display the description of the author of the current post. + * + * @since 1.0.0 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_description() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'description\')' ); + the_author_meta('description'); +} + +/** + * Retrieve the login name of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's login name (username). + */ +function get_the_author_login() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'login\')' ); + return get_the_author_meta('login'); +} + +/** + * Display the login name of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_login() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'login\')' ); + the_author_meta('login'); +} + +/** + * Retrieve the first name of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's first name. + */ +function get_the_author_firstname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'first_name\')' ); + return get_the_author_meta('first_name'); +} + +/** + * Display the first name of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_firstname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'first_name\')' ); + the_author_meta('first_name'); +} + +/** + * Retrieve the last name of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's last name. + */ +function get_the_author_lastname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'last_name\')' ); + return get_the_author_meta('last_name'); +} + +/** + * Display the last name of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_lastname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'last_name\')' ); + the_author_meta('last_name'); +} + +/** + * Retrieve the nickname of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's nickname. + */ +function get_the_author_nickname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'nickname\')' ); + return get_the_author_meta('nickname'); +} + +/** + * Display the nickname of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_nickname() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'nickname\')' ); + the_author_meta('nickname'); +} + +/** + * Retrieve the email of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's username. + */ +function get_the_author_email() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'email\')' ); + return get_the_author_meta('email'); +} + +/** + * Display the email of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_email() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'email\')' ); + the_author_meta('email'); +} + +/** + * Retrieve the ICQ number of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's ICQ number. + */ +function get_the_author_icq() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'icq\')' ); + return get_the_author_meta('icq'); +} + +/** + * Display the ICQ number of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_icq() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'icq\')' ); + the_author_meta('icq'); +} + +/** + * Retrieve the Yahoo! IM name of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's Yahoo! IM name. + */ +function get_the_author_yim() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'yim\')' ); + return get_the_author_meta('yim'); +} + +/** + * Display the Yahoo! IM name of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_yim() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'yim\')' ); + the_author_meta('yim'); +} + +/** + * Retrieve the MSN address of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's MSN address. + */ +function get_the_author_msn() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'msn\')' ); + return get_the_author_meta('msn'); +} + +/** + * Display the MSN address of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_msn() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'msn\')' ); + the_author_meta('msn'); +} + +/** + * Retrieve the AIM address of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The author's AIM address. + */ +function get_the_author_aim() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'aim\')' ); + return get_the_author_meta('aim'); +} + +/** + * Display the AIM address of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta('aim') + * @see the_author_meta() + */ +function the_author_aim() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'aim\')' ); + the_author_meta('aim'); +} + +/** + * Retrieve the specified author's preferred display name. + * + * @since 1.0.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @param int $auth_id The ID of the author. + * @return string The author's display name. + */ +function get_author_name( $auth_id = false ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'display_name\')' ); + return get_the_author_meta('display_name', $auth_id); +} + +/** + * Retrieve the URL to the home page of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string The URL to the author's page. + */ +function get_the_author_url() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'url\')' ); + return get_the_author_meta('url'); +} + +/** + * Display the URL to the home page of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_url() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'url\')' ); + the_author_meta('url'); +} + +/** + * Retrieve the ID of the author of the current post. + * + * @since 1.5.0 + * @deprecated 2.8.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @return string|int The author's ID. + */ +function get_the_author_ID() { + _deprecated_function( __FUNCTION__, '2.8.0', 'get_the_author_meta(\'ID\')' ); + return get_the_author_meta('ID'); +} + +/** + * Display the ID of the author of the current post. + * + * @since 0.71 + * @deprecated 2.8.0 Use the_author_meta() + * @see the_author_meta() + */ +function the_author_ID() { + _deprecated_function( __FUNCTION__, '2.8.0', 'the_author_meta(\'ID\')' ); + the_author_meta('ID'); +} + +/** + * Display the post content for the feed. + * + * For encoding the html or the $encode_html parameter, there are three possible + * values. '0' will make urls footnotes and use make_url_footnote(). '1' will + * encode special characters and automatically display all of the content. The + * value of '2' will strip all HTML tags from the content. + * + * Also note that you cannot set the amount of words and not set the html + * encoding. If that is the case, then the html encoding will default to 2, + * which will strip all HTML tags. + * + * To restrict the amount of words of the content, you can use the cut + * parameter. If the content is less than the amount, then there won't be any + * dots added to the end. If there is content left over, then dots will be added + * and the rest of the content will be removed. + * + * @since 0.71 + * + * @deprecated 2.9.0 Use the_content_feed() + * @see the_content_feed() + * + * @param string $more_link_text Optional. Text to display when more content is available but not displayed. + * @param int $stripteaser Optional. Default is 0. + * @param string $more_file Optional. + * @param int $cut Optional. Amount of words to keep for the content. + * @param int $encode_html Optional. How to encode the content. + */ +function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { + _deprecated_function( __FUNCTION__, '2.9.0', 'the_content_feed()' ); + $content = get_the_content($more_link_text, $stripteaser); + + /** + * Filters the post content in the context of an RSS feed. + * + * @since 0.71 + * + * @param string $content Content of the current post. + */ + $content = apply_filters('the_content_rss', $content); + if ( $cut && !$encode_html ) + $encode_html = 2; + if ( 1== $encode_html ) { + $content = esc_html($content); + $cut = 0; + } elseif ( 0 == $encode_html ) { + $content = make_url_footnote($content); + } elseif ( 2 == $encode_html ) { + $content = strip_tags($content); + } + if ( $cut ) { + $blah = explode(' ', $content); + if ( count($blah) > $cut ) { + $k = $cut; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + + /** @todo Check performance, might be faster to use array slice instead. */ + for ( $i=0; $i<$k; $i++ ) + $excerpt .= $blah[$i].' '; + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $content = $excerpt; + } + $content = str_replace(']]>', ']]>', $content); + echo $content; +} + +/** + * Strip HTML and put links at the bottom of stripped content. + * + * Searches for all of the links, strips them out of the content, and places + * them at the bottom of the content with numbers. + * + * @since 0.71 + * @deprecated 2.9.0 + * + * @param string $content Content to get links + * @return string HTML stripped out of content with links at the bottom. + */ +function make_url_footnote( $content ) { + _deprecated_function( __FUNCTION__, '2.9.0', '' ); + preg_match_all( '/(.+?)<\/a>/', $content, $matches ); + $links_summary = "\n"; + for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { + $link_match = $matches[0][$i]; + $link_number = '['.($i+1).']'; + $link_url = $matches[2][$i]; + $link_text = $matches[4][$i]; + $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); + $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; + $links_summary .= "\n" . $link_number . ' ' . $link_url; + } + $content = strip_tags( $content ); + $content .= $links_summary; + return $content; +} + +/** + * Retrieve translated string with vertical bar context + * + * Quite a few times, there will be collisions with similar translatable text + * found in more than two places but with different translated context. + * + * In order to use the separate contexts, the _c() function is used and the + * translatable string uses a pipe ('|') which has the context the string is in. + * + * When the translated string is returned, it is everything before the pipe, not + * including the pipe character. If there is no pipe in the translated text then + * everything is returned. + * + * @since 2.2.0 + * @deprecated 2.9.0 Use _x() + * @see _x() + * + * @param string $text Text to translate + * @param string $domain Optional. Domain to retrieve the translated text + * @return string Translated context string without pipe + */ +function _c( $text, $domain = 'default' ) { + _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); + return before_last_bar( translate( $text, $domain ) ); +} + +/** + * Translates $text like translate(), but assumes that the text + * contains a context after its last vertical bar. + * + * @since 2.5.0 + * @deprecated 3.0.0 Use _x() + * @see _x() + * + * @param string $text Text to translate + * @param string $domain Domain to retrieve the translated text + * @return string Translated text + */ +function translate_with_context( $text, $domain = 'default' ) { + _deprecated_function( __FUNCTION__, '2.9.0', '_x()' ); + return before_last_bar( translate( $text, $domain ) ); +} + +/** + * Legacy version of _n(), which supports contexts. + * + * Strips everything from the translation after the last bar. + * + * @since 2.7.0 + * @deprecated 3.0.0 Use _nx() + * @see _nx() + * + * @param string $single The text to be used if the number is singular. + * @param string $plural The text to be used if the number is plural. + * @param int $number The number to compare against to use either the singular or plural form. + * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. + * Default 'default'. + * @return string The translated singular or plural form. + */ +function _nc( $single, $plural, $number, $domain = 'default' ) { + _deprecated_function( __FUNCTION__, '2.9.0', '_nx()' ); + return before_last_bar( _n( $single, $plural, $number, $domain ) ); +} + +/** + * Retrieve the plural or single form based on the amount. + * + * @since 1.2.0 + * @deprecated 2.8.0 Use _n() + * @see _n() + */ +function __ngettext() { + _deprecated_function( __FUNCTION__, '2.8.0', '_n()' ); + $args = func_get_args(); + return call_user_func_array('_n', $args); +} + +/** + * Register plural strings in POT file, but don't translate them. + * + * @since 2.5.0 + * @deprecated 2.8.0 Use _n_noop() + * @see _n_noop() + */ +function __ngettext_noop() { + _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' ); + $args = func_get_args(); + return call_user_func_array('_n_noop', $args); + +} + +/** + * Retrieve all autoload options, or all options if no autoloaded ones exist. + * + * @since 1.0.0 + * @deprecated 3.0.0 Use wp_load_alloptions()) + * @see wp_load_alloptions() + * + * @return array List of all options. + */ +function get_alloptions() { + _deprecated_function( __FUNCTION__, '3.0.0', 'wp_load_alloptions()' ); + return wp_load_alloptions(); +} + +/** + * Retrieve HTML content of attachment image with link. + * + * @since 2.0.0 + * @deprecated 2.5.0 Use wp_get_attachment_link() + * @see wp_get_attachment_link() + * + * @param int $id Optional. Post ID. + * @param bool $fullsize Optional, default is false. Whether to use full size image. + * @param array $max_dims Optional. Max image dimensions. + * @param bool $permalink Optional, default is false. Whether to include permalink to image. + * @return string + */ +function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { + _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); + $id = (int) $id; + $_post = get_post($id); + + if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) + return __('Missing Attachment'); + + if ( $permalink ) + $url = get_attachment_link($_post->ID); + + $post_title = esc_attr($_post->post_title); + + $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); + return "$innerHTML"; +} + +/** + * Retrieve icon URL and Path. + * + * @since 2.1.0 + * @deprecated 2.5.0 Use wp_get_attachment_image_src() + * @see wp_get_attachment_image_src() + * + * @param int $id Optional. Post ID. + * @param bool $fullsize Optional, default to false. Whether to have full image. + * @return array Icon URL and full path to file, respectively. + */ +function get_attachment_icon_src( $id = 0, $fullsize = false ) { + _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); + $id = (int) $id; + if ( !$post = get_post($id) ) + return false; + + $file = get_attached_file( $post->ID ); + + if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { + // We have a thumbnail desired, specified and existing + + $src_file = basename($src); + } elseif ( wp_attachment_is_image( $post->ID ) ) { + // We have an image without a thumbnail + + $src = wp_get_attachment_url( $post->ID ); + $src_file = & $file; + } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { + // No thumb, no image. We'll look for a mime-related icon instead. + + $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); + $src_file = $icon_dir . '/' . basename($src); + } + + if ( !isset($src) || !$src ) + return false; + + return array($src, $src_file); +} + +/** + * Retrieve HTML content of icon attachment image element. + * + * @since 2.0.0 + * @deprecated 2.5.0 Use wp_get_attachment_image() + * @see wp_get_attachment_image() + * + * @param int $id Optional. Post ID. + * @param bool $fullsize Optional, default to false. Whether to have full size image. + * @param array $max_dims Optional. Dimensions of image. + * @return false|string HTML content. + */ +function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { + _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); + $id = (int) $id; + if ( !$post = get_post($id) ) + return false; + + if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) + return false; + + list($src, $src_file) = $src; + + // Do we need to constrain the image? + if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { + + $imagesize = getimagesize($src_file); + + if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { + $actual_aspect = $imagesize[0] / $imagesize[1]; + $desired_aspect = $max_dims[0] / $max_dims[1]; + + if ( $actual_aspect >= $desired_aspect ) { + $height = $actual_aspect * $max_dims[0]; + $constraint = "width='{$max_dims[0]}' "; + $post->iconsize = array($max_dims[0], $height); + } else { + $width = $max_dims[1] / $actual_aspect; + $constraint = "height='{$max_dims[1]}' "; + $post->iconsize = array($width, $max_dims[1]); + } + } else { + $post->iconsize = array($imagesize[0], $imagesize[1]); + $constraint = ''; + } + } else { + $constraint = ''; + } + + $post_title = esc_attr($post->post_title); + + $icon = "$post_title"; + + return apply_filters( 'attachment_icon', $icon, $post->ID ); +} + +/** + * Retrieve HTML content of image element. + * + * @since 2.0.0 + * @deprecated 2.5.0 Use wp_get_attachment_image() + * @see wp_get_attachment_image() + * + * @param int $id Optional. Post ID. + * @param bool $fullsize Optional, default to false. Whether to have full size image. + * @param array $max_dims Optional. Dimensions of image. + * @return false|string + */ +function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { + _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image()' ); + $id = (int) $id; + if ( !$post = get_post($id) ) + return false; + + if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) + return $innerHTML; + + $innerHTML = esc_attr($post->post_title); + + return apply_filters('attachment_innerHTML', $innerHTML, $post->ID); +} + +/** + * Retrieves bookmark data based on ID. + * + * @since 2.0.0 + * @deprecated 2.1.0 Use get_bookmark() + * @see get_bookmark() + * + * @param int $bookmark_id ID of link + * @param string $output Optional. Type of output. Accepts OBJECT, ARRAY_N, or ARRAY_A. + * Default OBJECT. + * @param string $filter Optional. How to filter the link for output. Accepts 'raw', 'edit', + * 'attribute', 'js', 'db', or 'display'. Default 'raw'. + * @return object|array Bookmark object or array, depending on the type specified by `$output`. + */ +function get_link( $bookmark_id, $output = OBJECT, $filter = 'raw' ) { + _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmark()' ); + return get_bookmark($bookmark_id, $output, $filter); +} + +/** + * Performs esc_url() for database or redirect usage. + * + * @since 2.3.1 + * @deprecated 2.8.0 Use esc_url_raw() + * @see esc_url_raw() + * + * @param string $url The URL to be cleaned. + * @param array $protocols An array of acceptable protocols. + * @return string The cleaned URL. + */ +function sanitize_url( $url, $protocols = null ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'esc_url_raw()' ); + return esc_url_raw( $url, $protocols ); +} + +/** + * Checks and cleans a URL. + * + * A number of characters are removed from the URL. If the URL is for displaying + * (the default behaviour) ampersands are also replaced. The 'clean_url' filter + * is applied to the returned cleaned URL. + * + * @since 1.2.0 + * @deprecated 3.0.0 Use esc_url() + * @see esc_url() + * + * @param string $url The URL to be cleaned. + * @param array $protocols Optional. An array of acceptable protocols. + * @param string $context Optional. How the URL will be used. Default is 'display'. + * @return string The cleaned $url after the {@see 'clean_url'} filter is applied. + */ +function clean_url( $url, $protocols = null, $context = 'display' ) { + if ( $context == 'db' ) + _deprecated_function( 'clean_url( $context = \'db\' )', '3.0.0', 'esc_url_raw()' ); + else + _deprecated_function( __FUNCTION__, '3.0.0', 'esc_url()' ); + return esc_url( $url, $protocols, $context ); +} + +/** + * Escape single quotes, specialchar double quotes, and fix line endings. + * + * The filter {@see 'js_escape'} is also applied by esc_js(). + * + * @since 2.0.4 + * @deprecated 2.8.0 Use esc_js() + * @see esc_js() + * + * @param string $text The text to be escaped. + * @return string Escaped text. + */ +function js_escape( $text ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' ); + return esc_js( $text ); +} + +/** + * Legacy escaping for HTML blocks. + * + * @deprecated 2.8.0 Use esc_html() + * @see esc_html() + * + * @param string $string String to escape. + * @param string $quote_style Unused. + * @param false|string $charset Unused. + * @param false $double_encode Whether to double encode. Unused. + * @return string Escaped `$string`. + */ +function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'esc_html()' ); + if ( func_num_args() > 1 ) { // Maintain back-compat for people passing additional arguments. + $args = func_get_args(); + return call_user_func_array( '_wp_specialchars', $args ); + } else { + return esc_html( $string ); + } +} + +/** + * Escaping for HTML attributes. + * + * @since 2.0.6 + * @deprecated 2.8.0 Use esc_attr() + * @see esc_attr() + * + * @param string $text + * @return string + */ +function attribute_escape( $text ) { + _deprecated_function( __FUNCTION__, '2.8.0', 'esc_attr()' ); + return esc_attr( $text ); +} + +/** + * Register widget for sidebar with backward compatibility. + * + * Allows $name to be an array that accepts either three elements to grab the + * first element and the third for the name or just uses the first element of + * the array for the name. + * + * Passes to wp_register_sidebar_widget() after argument list and backward + * compatibility is complete. + * + * @since 2.2.0 + * @deprecated 2.8.0 Use wp_register_sidebar_widget() + * @see wp_register_sidebar_widget() + * + * @param string|int $name Widget ID. + * @param callable $output_callback Run when widget is called. + * @param string $classname Optional. Classname widget option. Default empty. + * @param mixed $params ,... Widget parameters. + */ +function register_sidebar_widget($name, $output_callback, $classname = '') { + _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); + // Compat + if ( is_array($name) ) { + if ( count($name) == 3 ) + $name = sprintf($name[0], $name[2]); + else + $name = $name[0]; + } + + $id = sanitize_title($name); + $options = array(); + if ( !empty($classname) && is_string($classname) ) + $options['classname'] = $classname; + $params = array_slice(func_get_args(), 2); + $args = array($id, $name, $output_callback, $options); + if ( !empty($params) ) + $args = array_merge($args, $params); + + call_user_func_array('wp_register_sidebar_widget', $args); +} + +/** + * Serves as an alias of wp_unregister_sidebar_widget(). + * + * @since 2.2.0 + * @deprecated 2.8.0 Use wp_unregister_sidebar_widget() + * @see wp_unregister_sidebar_widget() + * + * @param int|string $id Widget ID. + */ +function unregister_sidebar_widget($id) { + _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_sidebar_widget()' ); + return wp_unregister_sidebar_widget($id); +} + +/** + * Registers widget control callback for customizing options. + * + * Allows $name to be an array that accepts either three elements to grab the + * first element and the third for the name or just uses the first element of + * the array for the name. + * + * Passes to wp_register_widget_control() after the argument list has + * been compiled. + * + * @since 2.2.0 + * @deprecated 2.8.0 Use wp_register_widget_control() + * @see wp_register_widget_control() + * + * @param int|string $name Sidebar ID. + * @param callable $control_callback Widget control callback to display and process form. + * @param int $width Widget width. + * @param int $height Widget height. + */ +function register_widget_control($name, $control_callback, $width = '', $height = '') { + _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); + // Compat + if ( is_array($name) ) { + if ( count($name) == 3 ) + $name = sprintf($name[0], $name[2]); + else + $name = $name[0]; + } + + $id = sanitize_title($name); + $options = array(); + if ( !empty($width) ) + $options['width'] = $width; + if ( !empty($height) ) + $options['height'] = $height; + $params = array_slice(func_get_args(), 4); + $args = array($id, $name, $control_callback, $options); + if ( !empty($params) ) + $args = array_merge($args, $params); + + call_user_func_array('wp_register_widget_control', $args); +} + +/** + * Alias of wp_unregister_widget_control(). + * + * @since 2.2.0 + * @deprecated 2.8.0 Use wp_unregister_widget_control() + * @see wp_unregister_widget_control() + * + * @param int|string $id Widget ID. + */ +function unregister_widget_control($id) { + _deprecated_function( __FUNCTION__, '2.8.0', 'wp_unregister_widget_control()' ); + return wp_unregister_widget_control($id); +} + +/** + * Remove user meta data. + * + * @since 2.0.0 + * @deprecated 3.0.0 Use delete_user_meta() + * @see delete_user_meta() + * + * @param int $user_id User ID. + * @param string $meta_key Metadata key. + * @param mixed $meta_value Metadata value. + * @return bool True deletion completed and false if user_id is not a number. + */ +function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'delete_user_meta()' ); + global $wpdb; + if ( !is_numeric( $user_id ) ) + return false; + $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); + + if ( is_array($meta_value) || is_object($meta_value) ) + $meta_value = serialize($meta_value); + $meta_value = trim( $meta_value ); + + $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); + + if ( $cur && $cur->umeta_id ) + do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); + + if ( ! empty($meta_value) ) + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); + else + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); + + clean_user_cache( $user_id ); + wp_cache_delete( $user_id, 'user_meta' ); + + if ( $cur && $cur->umeta_id ) + do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); + + return true; +} + +/** + * Retrieve user metadata. + * + * If $user_id is not a number, then the function will fail over with a 'false' + * boolean return value. Other returned values depend on whether there is only + * one item to be returned, which be that single item type. If there is more + * than one metadata value, then it will be list of metadata values. + * + * @since 2.0.0 + * @deprecated 3.0.0 Use get_user_meta() + * @see get_user_meta() + * + * @param int $user_id User ID + * @param string $meta_key Optional. Metadata key. + * @return mixed + */ +function get_usermeta( $user_id, $meta_key = '' ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' ); + global $wpdb; + $user_id = (int) $user_id; + + if ( !$user_id ) + return false; + + if ( !empty($meta_key) ) { + $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); + $user = wp_cache_get($user_id, 'users'); + // Check the cached user object + if ( false !== $user && isset($user->$meta_key) ) + $metas = array($user->$meta_key); + else + $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); + } else { + $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); + } + + if ( empty($metas) ) { + if ( empty($meta_key) ) + return array(); + else + return ''; + } + + $metas = array_map('maybe_unserialize', $metas); + + if ( count($metas) == 1 ) + return $metas[0]; + else + return $metas; +} + +/** + * Update metadata of user. + * + * There is no need to serialize values, they will be serialized if it is + * needed. The metadata key can only be a string with underscores. All else will + * be removed. + * + * Will remove the metadata, if the meta value is empty. + * + * @since 2.0.0 + * @deprecated 3.0.0 Use update_user_meta() + * @see update_user_meta() + * + * @param int $user_id User ID + * @param string $meta_key Metadata key. + * @param mixed $meta_value Metadata value. + * @return bool True on successful update, false on failure. + */ +function update_usermeta( $user_id, $meta_key, $meta_value ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' ); + global $wpdb; + if ( !is_numeric( $user_id ) ) + return false; + $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); + + /** @todo Might need fix because usermeta data is assumed to be already escaped */ + if ( is_string($meta_value) ) + $meta_value = stripslashes($meta_value); + $meta_value = maybe_serialize($meta_value); + + if (empty($meta_value)) { + return delete_usermeta($user_id, $meta_key); + } + + $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); + + if ( $cur ) + do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); + + if ( !$cur ) + $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); + elseif ( $cur->meta_value != $meta_value ) + $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); + else + return false; + + clean_user_cache( $user_id ); + wp_cache_delete( $user_id, 'user_meta' ); + + if ( !$cur ) + do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); + else + do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); + + return true; +} + +/** + * Get users for the site. + * + * For setups that use the multisite feature. Can be used outside of the + * multisite feature. + * + * @since 2.2.0 + * @deprecated 3.1.0 Use get_users() + * @see get_users() + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param int $id Site ID. + * @return array List of users that are part of that site ID + */ +function get_users_of_blog( $id = '' ) { + _deprecated_function( __FUNCTION__, '3.1.0', 'get_users()' ); + + global $wpdb; + if ( empty( $id ) ) { + $id = get_current_blog_id(); + } + $blog_prefix = $wpdb->get_blog_prefix($id); + $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); + return $users; +} + +/** + * Enable/disable automatic general feed link outputting. + * + * @since 2.8.0 + * @deprecated 3.0.0 Use add_theme_support() + * @see add_theme_support() + * + * @param bool $add Optional, default is true. Add or remove links. Defaults to true. + */ +function automatic_feed_links( $add = true ) { + _deprecated_function( __FUNCTION__, '3.0.0', "add_theme_support( 'automatic-feed-links' )" ); + + if ( $add ) + add_theme_support( 'automatic-feed-links' ); + else + remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ +} + +/** + * Retrieve user data based on field. + * + * @since 1.5.0 + * @deprecated 3.0.0 Use get_the_author_meta() + * @see get_the_author_meta() + * + * @param string $field User meta field. + * @param false|int $user Optional. User ID to retrieve the field for. Default false (current user). + * @return string The author's field from the current author's DB object. + */ +function get_profile( $field, $user = false ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'get_the_author_meta()' ); + if ( $user ) { + $user = get_user_by( 'login', $user ); + $user = $user->ID; + } + return get_the_author_meta( $field, $user ); +} + +/** + * Retrieves the number of posts a user has written. + * + * @since 0.71 + * @deprecated 3.0.0 Use count_user_posts() + * @see count_user_posts() + * + * @param int $userid User to count posts for. + * @return int Number of posts the given user has written. + */ +function get_usernumposts( $userid ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'count_user_posts()' ); + return count_user_posts( $userid ); +} + +/** + * Callback used to change %uXXXX to &#YYY; syntax + * + * @since 2.8.0 + * @access private + * @deprecated 3.0.0 + * + * @param array $matches Single Match + * @return string An HTML entity + */ +function funky_javascript_callback($matches) { + return "&#".base_convert($matches[1],16,10).";"; +} + +/** + * Fixes JavaScript bugs in browsers. + * + * Converts unicode characters to HTML numbered entities. + * + * @since 1.5.0 + * @deprecated 3.0.0 + * + * @global $is_macIE + * @global $is_winIE + * + * @param string $text Text to be made safe. + * @return string Fixed text. + */ +function funky_javascript_fix($text) { + _deprecated_function( __FUNCTION__, '3.0.0' ); + // Fixes for browsers' JavaScript bugs. + global $is_macIE, $is_winIE; + + if ( $is_winIE || $is_macIE ) + $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", + "funky_javascript_callback", + $text); + + return $text; +} + +/** + * Checks that the taxonomy name exists. + * + * @since 2.3.0 + * @deprecated 3.0.0 Use taxonomy_exists() + * @see taxonomy_exists() + * + * @param string $taxonomy Name of taxonomy object + * @return bool Whether the taxonomy exists. + */ +function is_taxonomy( $taxonomy ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'taxonomy_exists()' ); + return taxonomy_exists( $taxonomy ); +} + +/** + * Check if Term exists. + * + * @since 2.3.0 + * @deprecated 3.0.0 Use term_exists() + * @see term_exists() + * + * @param int|string $term The term to check + * @param string $taxonomy The taxonomy name to use + * @param int $parent ID of parent term under which to confine the exists search. + * @return mixed Get the term id or Term Object, if exists. + */ +function is_term( $term, $taxonomy = '', $parent = 0 ) { + _deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' ); + return term_exists( $term, $taxonomy, $parent ); +} + +/** + * Is the current admin page generated by a plugin? + * + * Use global $plugin_page and/or get_plugin_page_hookname() hooks. + * + * @since 1.5.0 + * @deprecated 3.1.0 + * + * @global $plugin_page + * + * @return bool + */ +function is_plugin_page() { + _deprecated_function( __FUNCTION__, '3.1.0' ); + + global $plugin_page; + + if ( isset($plugin_page) ) + return true; + + return false; +} + +/** + * Update the categories cache. + * + * This function does not appear to be used anymore or does not appear to be + * needed. It might be a legacy function left over from when there was a need + * for updating the category cache. + * + * @since 1.5.0 + * @deprecated 3.1.0 + * + * @return bool Always return True + */ +function update_category_cache() { + _deprecated_function( __FUNCTION__, '3.1.0' ); + + return true; +} + +/** + * Check for PHP timezone support + * + * @since 2.9.0 + * @deprecated 3.2.0 + * + * @return bool + */ +function wp_timezone_supported() { + _deprecated_function( __FUNCTION__, '3.2.0' ); + + return true; +} + +/** + * Displays an editor: TinyMCE, HTML, or both. + * + * @since 2.1.0 + * @deprecated 3.3.0 Use wp_editor() + * @see wp_editor() + * + * @param string $content Textarea content. + * @param string $id Optional. HTML ID attribute value. Default 'content'. + * @param string $prev_id Optional. Unused. + * @param bool $media_buttons Optional. Whether to display media buttons. Default true. + * @param int $tab_index Optional. Unused. + * @param bool $extended Optional. Unused. + */ +function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { + _deprecated_function( __FUNCTION__, '3.3.0', 'wp_editor()' ); + + wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); +} + +/** + * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users + * + * @since 3.0.0 + * @deprecated 3.3.0 + * + * @param array $ids User ID numbers list. + * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. + */ +function get_user_metavalues($ids) { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + $objects = array(); + + $ids = array_map('intval', $ids); + foreach ( $ids as $id ) + $objects[$id] = array(); + + $metas = update_meta_cache('user', $ids); + + foreach ( $metas as $id => $meta ) { + foreach ( $meta as $key => $metavalues ) { + foreach ( $metavalues as $value ) { + $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); + } + } + } + + return $objects; +} + +/** + * Sanitize every user field. + * + * If the context is 'raw', then the user object or array will get minimal santization of the int fields. + * + * @since 2.3.0 + * @deprecated 3.3.0 + * + * @param object|array $user The User Object or Array + * @param string $context Optional, default is 'display'. How to sanitize user fields. + * @return object|array The now sanitized User Object or Array (will be the same type as $user) + */ +function sanitize_user_object($user, $context = 'display') { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + if ( is_object($user) ) { + if ( !isset($user->ID) ) + $user->ID = 0; + if ( ! ( $user instanceof WP_User ) ) { + $vars = get_object_vars($user); + foreach ( array_keys($vars) as $field ) { + if ( is_string($user->$field) || is_numeric($user->$field) ) + $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); + } + } + $user->filter = $context; + } else { + if ( !isset($user['ID']) ) + $user['ID'] = 0; + foreach ( array_keys($user) as $field ) + $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); + $user['filter'] = $context; + } + + return $user; +} + +/** + * Get boundary post relational link. + * + * Can either be start or end post relational link. + * + * @since 2.8.0 + * @deprecated 3.3.0 + * + * @param string $title Optional. Link title format. + * @param bool $in_same_cat Optional. Whether link should be in a same category. + * @param string $excluded_categories Optional. Excluded categories IDs. + * @param bool $start Optional, default is true. Whether to display link to first or last post. + * @return string + */ +function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); + // If there is no post stop. + if ( empty($posts) ) + return; + + // Even though we limited get_posts to return only 1 item it still returns an array of objects. + $post = $posts[0]; + + if ( empty($post->post_title) ) + $post->post_title = $start ? __('First Post') : __('Last Post'); + + $date = mysql2date(get_option('date_format'), $post->post_date); + + $title = str_replace('%title', $post->post_title, $title); + $title = str_replace('%date', $date, $title); + $title = apply_filters('the_title', $title, $post->ID); + + $link = $start ? "\n"; + + $boundary = $start ? 'start' : 'end'; + return apply_filters( "{$boundary}_post_rel_link", $link ); +} + +/** + * Display relational link for the first post. + * + * @since 2.8.0 + * @deprecated 3.3.0 + * + * @param string $title Optional. Link title format. + * @param bool $in_same_cat Optional. Whether link should be in a same category. + * @param string $excluded_categories Optional. Excluded categories IDs. + */ +function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); +} + +/** + * Get site index relational link. + * + * @since 2.8.0 + * @deprecated 3.3.0 + * + * @return string + */ +function get_index_rel_link() { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + $link = "\n"; + return apply_filters( "index_rel_link", $link ); +} + +/** + * Display relational link for the site index. + * + * @since 2.8.0 + * @deprecated 3.3.0 + */ +function index_rel_link() { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + echo get_index_rel_link(); +} + +/** + * Get parent post relational link. + * + * @since 2.8.0 + * @deprecated 3.3.0 + * + * @param string $title Optional. Link title format. Default '%title'. + * @return string + */ +function get_parent_post_rel_link( $title = '%title' ) { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) + $post = get_post($GLOBALS['post']->post_parent); + + if ( empty($post) ) + return; + + $date = mysql2date(get_option('date_format'), $post->post_date); + + $title = str_replace('%title', $post->post_title, $title); + $title = str_replace('%date', $date, $title); + $title = apply_filters('the_title', $title, $post->ID); + + $link = "\n"; + + return apply_filters( "parent_post_rel_link", $link ); +} + +/** + * Display relational link for parent item + * + * @since 2.8.0 + * @deprecated 3.3.0 + * + * @param string $title Optional. Link title format. Default '%title'. + */ +function parent_post_rel_link( $title = '%title' ) { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + echo get_parent_post_rel_link($title); +} + +/** + * Add the "Dashboard"/"Visit Site" menu. + * + * @since 3.2.0 + * @deprecated 3.3.0 + * + * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. + */ +function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { + _deprecated_function( __FUNCTION__, '3.3.0' ); + + $user_id = get_current_user_id(); + + if ( 0 != $user_id ) { + if ( is_admin() ) + $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); + elseif ( is_multisite() ) + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); + else + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); + } +} + +/** + * Checks if the current user belong to a given site. + * + * @since MU (3.0.0) + * @deprecated 3.3.0 Use is_user_member_of_blog() + * @see is_user_member_of_blog() + * + * @param int $blog_id Site ID + * @return bool True if the current users belong to $blog_id, false if not. + */ +function is_blog_user( $blog_id = 0 ) { + _deprecated_function( __FUNCTION__, '3.3.0', 'is_user_member_of_blog()' ); + + return is_user_member_of_blog( get_current_user_id(), $blog_id ); +} + +/** + * Open the file handle for debugging. + * + * @since 0.71 + * @deprecated 3.4.0 Use error_log() + * @see error_log() + * + * @link https://secure.php.net/manual/en/function.error-log.php + * + * @param string $filename File name. + * @param string $mode Type of access you required to the stream. + * @return false Always false. + */ +function debug_fopen( $filename, $mode ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); + return false; +} + +/** + * Write contents to the file used for debugging. + * + * @since 0.71 + * @deprecated 3.4.0 Use error_log() + * @see error_log() + * + * @link https://secure.php.net/manual/en/function.error-log.php + * + * @param mixed $fp Unused. + * @param string $string Message to log. + */ +function debug_fwrite( $fp, $string ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); + if ( ! empty( $GLOBALS['debug'] ) ) + error_log( $string ); +} + +/** + * Close the debugging file handle. + * + * @since 0.71 + * @deprecated 3.4.0 Use error_log() + * @see error_log() + * + * @link https://secure.php.net/manual/en/function.error-log.php + * + * @param mixed $fp Unused. + */ +function debug_fclose( $fp ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); +} + +/** + * Retrieve list of themes with theme data in theme directory. + * + * The theme is broken, if it doesn't have a parent theme and is missing either + * style.css and, or index.php. If the theme has a parent theme then it is + * broken, if it is missing style.css; index.php is optional. + * + * @since 1.5.0 + * @deprecated 3.4.0 Use wp_get_themes() + * @see wp_get_themes() + * + * @return array Theme list with theme data. + */ +function get_themes() { + _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_themes()' ); + + global $wp_themes; + if ( isset( $wp_themes ) ) + return $wp_themes; + + $themes = wp_get_themes(); + $wp_themes = array(); + + foreach ( $themes as $theme ) { + $name = $theme->get('Name'); + if ( isset( $wp_themes[ $name ] ) ) + $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; + else + $wp_themes[ $name ] = $theme; + } + + return $wp_themes; +} + +/** + * Retrieve theme data. + * + * @since 1.5.0 + * @deprecated 3.4.0 Use wp_get_theme() + * @see wp_get_theme() + * + * @param string $theme Theme name. + * @return array|null Null, if theme name does not exist. Theme data, if exists. + */ +function get_theme( $theme ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme( $stylesheet )' ); + + $themes = get_themes(); + if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) + return $themes[ $theme ]; + return null; +} + +/** + * Retrieve current theme name. + * + * @since 1.5.0 + * @deprecated 3.4.0 Use wp_get_theme() + * @see wp_get_theme() + * + * @return string + */ +function get_current_theme() { + _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); + + if ( $theme = get_option( 'current_theme' ) ) + return $theme; + + return wp_get_theme()->get('Name'); +} + +/** + * Accepts matches array from preg_replace_callback in wpautop() or a string. + * + * Ensures that the contents of a `
          ...
          ` HTML block are not + * converted into paragraphs or line-breaks. + * + * @since 1.2.0 + * @deprecated 3.4.0 + * + * @param array|string $matches The array or string + * @return string The pre block without paragraph/line-break conversion. + */ +function clean_pre($matches) { + _deprecated_function( __FUNCTION__, '3.4.0' ); + + if ( is_array($matches) ) + $text = $matches[1] . $matches[2] . ""; + else + $text = $matches; + + $text = str_replace(array('
          ', '
          ', '
          '), array('', '', ''), $text); + $text = str_replace('

          ', "\n", $text); + $text = str_replace('

          ', '', $text); + + return $text; +} + + +/** + * Add callbacks for image header display. + * + * @since 2.1.0 + * @deprecated 3.4.0 Use add_theme_support() + * @see add_theme_support() + * + * @param callable $wp_head_callback Call on the {@see 'wp_head'} action. + * @param callable $admin_head_callback Call on custom header administration screen. + * @param callable $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. + */ +function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-header\', $args )' ); + $args = array( + 'wp-head-callback' => $wp_head_callback, + 'admin-head-callback' => $admin_head_callback, + ); + if ( $admin_preview_callback ) + $args['admin-preview-callback'] = $admin_preview_callback; + return add_theme_support( 'custom-header', $args ); +} + +/** + * Remove image header support. + * + * @since 3.1.0 + * @deprecated 3.4.0 Use remove_theme_support() + * @see remove_theme_support() + * + * @return null|bool Whether support was removed. + */ +function remove_custom_image_header() { + _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-header\' )' ); + return remove_theme_support( 'custom-header' ); +} + +/** + * Add callbacks for background image display. + * + * @since 3.0.0 + * @deprecated 3.4.0 Use add_theme_support() + * @see add_theme_support() + * + * @param callable $wp_head_callback Call on the {@see 'wp_head'} action. + * @param callable $admin_head_callback Call on custom background administration screen. + * @param callable $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. + */ +function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'add_theme_support( \'custom-background\', $args )' ); + $args = array(); + if ( $wp_head_callback ) + $args['wp-head-callback'] = $wp_head_callback; + if ( $admin_head_callback ) + $args['admin-head-callback'] = $admin_head_callback; + if ( $admin_preview_callback ) + $args['admin-preview-callback'] = $admin_preview_callback; + return add_theme_support( 'custom-background', $args ); +} + +/** + * Remove custom background support. + * + * @since 3.1.0 + * @deprecated 3.4.0 Use add_custom_background() + * @see add_custom_background() + * + * @return null|bool Whether support was removed. + */ +function remove_custom_background() { + _deprecated_function( __FUNCTION__, '3.4.0', 'remove_theme_support( \'custom-background\' )' ); + return remove_theme_support( 'custom-background' ); +} + +/** + * Retrieve theme data from parsed theme file. + * + * @since 1.5.0 + * @deprecated 3.4.0 Use wp_get_theme() + * @see wp_get_theme() + * + * @param string $theme_file Theme file path. + * @return array Theme data. + */ +function get_theme_data( $theme_file ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'wp_get_theme()' ); + $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); + + $theme_data = array( + 'Name' => $theme->get('Name'), + 'URI' => $theme->display('ThemeURI', true, false), + 'Description' => $theme->display('Description', true, false), + 'Author' => $theme->display('Author', true, false), + 'AuthorURI' => $theme->display('AuthorURI', true, false), + 'Version' => $theme->get('Version'), + 'Template' => $theme->get('Template'), + 'Status' => $theme->get('Status'), + 'Tags' => $theme->get('Tags'), + 'Title' => $theme->get('Name'), + 'AuthorName' => $theme->get('Author'), + ); + + foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { + if ( ! isset( $theme_data[ $extra_header ] ) ) + $theme_data[ $extra_header ] = $theme->get( $extra_header ); + } + + return $theme_data; +} + +/** + * Alias of update_post_cache(). + * + * @see update_post_cache() Posts and pages are the same, alias is intentional + * + * @since 1.5.1 + * @deprecated 3.4.0 Use update_post_cache() + * @see update_post_cache() + * + * @param array $pages list of page objects + */ +function update_page_cache( &$pages ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' ); + + update_post_cache( $pages ); +} + +/** + * Will clean the page in the cache. + * + * Clean (read: delete) page from cache that matches $id. Will also clean cache + * associated with 'all_page_ids' and 'get_pages'. + * + * @since 2.0.0 + * @deprecated 3.4.0 Use clean_post_cache + * @see clean_post_cache() + * + * @param int $id Page ID to clean + */ +function clean_page_cache( $id ) { + _deprecated_function( __FUNCTION__, '3.4.0', 'clean_post_cache()' ); + + clean_post_cache( $id ); +} + +/** + * Retrieve nonce action "Are you sure" message. + * + * Deprecated in 3.4.1 and 3.5.0. Backported to 3.3.3. + * + * @since 2.0.4 + * @deprecated 3.4.1 Use wp_nonce_ays() + * @see wp_nonce_ays() + * + * @param string $action Nonce action. + * @return string Are you sure message. + */ +function wp_explain_nonce( $action ) { + _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); + return __( 'Are you sure you want to do this?' ); +} + +/** + * Display "sticky" CSS class, if a post is sticky. + * + * @since 2.7.0 + * @deprecated 3.5.0 Use post_class() + * @see post_class() + * + * @param int $post_id An optional post ID. + */ +function sticky_class( $post_id = null ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); + if ( is_sticky( $post_id ) ) + echo ' sticky'; +} + +/** + * Retrieve post ancestors. + * + * This is no longer needed as WP_Post lazy-loads the ancestors + * property with get_post_ancestors(). + * + * @since 2.3.4 + * @deprecated 3.5.0 Use get_post_ancestors() + * @see get_post_ancestors() + * + * @param WP_Post $post Post object, passed by reference (unused). + */ +function _get_post_ancestors( &$post ) { + _deprecated_function( __FUNCTION__, '3.5.0' ); +} + +/** + * Load an image from a string, if PHP supports it. + * + * @since 2.1.0 + * @deprecated 3.5.0 Use wp_get_image_editor() + * @see wp_get_image_editor() + * + * @param string $file Filename of the image to load. + * @return resource The resulting image resource on success, Error string on failure. + */ +function wp_load_image( $file ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); + + if ( is_numeric( $file ) ) + $file = get_attached_file( $file ); + + if ( ! is_file( $file ) ) { + /* translators: %s: file name */ + return sprintf( __( 'File “%s” doesn’t exist?' ), $file ); + } + + if ( ! function_exists('imagecreatefromstring') ) + return __('The GD image library is not installed.'); + + // Set artificially high because GD uses uncompressed images in memory. + wp_raise_memory_limit( 'image' ); + + $image = imagecreatefromstring( file_get_contents( $file ) ); + + if ( ! is_resource( $image ) ) { + /* translators: %s: file name */ + return sprintf( __( 'File “%s” is not an image.' ), $file ); + } + + return $image; +} + +/** + * Scale down an image to fit a particular size and save a new copy of the image. + * + * The PNG transparency will be preserved using the function, as well as the + * image type. If the file going in is PNG, then the resized image is going to + * be PNG. The only supported image types are PNG, GIF, and JPEG. + * + * Some functionality requires API to exist, so some PHP version may lose out + * support. This is not the fault of WordPress (where functionality is + * downgraded, not actual defects), but of your PHP version. + * + * @since 2.5.0 + * @deprecated 3.5.0 Use wp_get_image_editor() + * @see wp_get_image_editor() + * + * @param string $file Image file path. + * @param int $max_w Maximum width to resize to. + * @param int $max_h Maximum height to resize to. + * @param bool $crop Optional. Whether to crop image or resize. + * @param string $suffix Optional. File suffix. + * @param string $dest_path Optional. New image file path. + * @param int $jpeg_quality Optional, default is 90. Image quality percentage. + * @return mixed WP_Error on failure. String with new destination path. + */ +function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); + + $editor = wp_get_image_editor( $file ); + if ( is_wp_error( $editor ) ) + return $editor; + $editor->set_quality( $jpeg_quality ); + + $resized = $editor->resize( $max_w, $max_h, $crop ); + if ( is_wp_error( $resized ) ) + return $resized; + + $dest_file = $editor->generate_filename( $suffix, $dest_path ); + $saved = $editor->save( $dest_file ); + + if ( is_wp_error( $saved ) ) + return $saved; + + return $dest_file; +} + +/** + * Retrieve a single post, based on post ID. + * + * Has categories in 'post_category' property or key. Has tags in 'tags_input' + * property or key. + * + * @since 1.0.0 + * @deprecated 3.5.0 Use get_post() + * @see get_post() + * + * @param int $postid Post ID. + * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. + * @return WP_Post|null Post object or array holding post contents and information + */ +function wp_get_single_post( $postid = 0, $mode = OBJECT ) { + _deprecated_function( __FUNCTION__, '3.5.0', 'get_post()' ); + return get_post( $postid, $mode ); +} + +/** + * Check that the user login name and password is correct. + * + * @since 0.71 + * @deprecated 3.5.0 Use wp_authenticate() + * @see wp_authenticate() + * + * @param string $user_login User name. + * @param string $user_pass User password. + * @return bool False if does not authenticate, true if username and password authenticates. + */ +function user_pass_ok($user_login, $user_pass) { + _deprecated_function( __FUNCTION__, '3.5.0', 'wp_authenticate()' ); + $user = wp_authenticate( $user_login, $user_pass ); + if ( is_wp_error( $user ) ) + return false; + + return true; +} + +/** + * Callback formerly fired on the save_post hook. No longer needed. + * + * @since 2.3.0 + * @deprecated 3.5.0 + */ +function _save_post_hook() {} + +/** + * Check if the installed version of GD supports particular image type + * + * @since 2.9.0 + * @deprecated 3.5.0 Use wp_image_editor_supports() + * @see wp_image_editor_supports() + * + * @param string $mime_type + * @return bool + */ +function gd_edit_image_support($mime_type) { + _deprecated_function( __FUNCTION__, '3.5.0', 'wp_image_editor_supports()' ); + + if ( function_exists('imagetypes') ) { + switch( $mime_type ) { + case 'image/jpeg': + return (imagetypes() & IMG_JPG) != 0; + case 'image/png': + return (imagetypes() & IMG_PNG) != 0; + case 'image/gif': + return (imagetypes() & IMG_GIF) != 0; + } + } else { + switch( $mime_type ) { + case 'image/jpeg': + return function_exists('imagecreatefromjpeg'); + case 'image/png': + return function_exists('imagecreatefrompng'); + case 'image/gif': + return function_exists('imagecreatefromgif'); + } + } + return false; +} + +/** + * Converts an integer byte value to a shorthand byte value. + * + * @since 2.3.0 + * @deprecated 3.6.0 Use size_format() + * @see size_format() + * + * @param int $bytes An integer byte value. + * @return string A shorthand byte value. + */ +function wp_convert_bytes_to_hr( $bytes ) { + _deprecated_function( __FUNCTION__, '3.6.0', 'size_format()' ); + + $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); + $log = log( $bytes, KB_IN_BYTES ); + $power = (int) $log; + $size = pow( KB_IN_BYTES, $log - $power ); + + if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { + $unit = $units[ $power ]; + } else { + $size = $bytes; + $unit = $units[0]; + } + + return $size . $unit; +} + +/** + * Formerly used internally to tidy up the search terms. + * + * @since 2.9.0 + * @access private + * @deprecated 3.7.0 + * + * @param string $t Search terms to "tidy", e.g. trim. + * @return string Trimmed search terms. + */ +function _search_terms_tidy( $t ) { + _deprecated_function( __FUNCTION__, '3.7.0' ); + return trim( $t, "\"'\n\r " ); +} + +/** + * Determine if TinyMCE is available. + * + * Checks to see if the user has deleted the tinymce files to slim down + * their WordPress installation. + * + * @since 2.1.0 + * @deprecated 3.9.0 + * + * @return bool Whether TinyMCE exists. + */ +function rich_edit_exists() { + global $wp_rich_edit_exists; + _deprecated_function( __FUNCTION__, '3.9.0' ); + + if ( ! isset( $wp_rich_edit_exists ) ) + $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); + + return $wp_rich_edit_exists; +} + +/** + * Old callback for tag link tooltips. + * + * @since 2.7.0 + * @access private + * @deprecated 3.9.0 + * + * @param int $count Number of topics. + * @return int Number of topics. + */ +function default_topic_count_text( $count ) { + return $count; +} + +/** + * Formerly used to escape strings before inserting into the DB. + * + * Has not performed this function for many, many years. Use wpdb::prepare() instead. + * + * @since 0.71 + * @deprecated 3.9.0 + * + * @param string $content The text to format. + * @return string The very same text. + */ +function format_to_post( $content ) { + _deprecated_function( __FUNCTION__, '3.9.0' ); + return $content; +} + +/** + * Formerly used to escape strings before searching the DB. It was poorly documented and never worked as described. + * + * @since 2.5.0 + * @deprecated 4.0.0 Use wpdb::esc_like() + * @see wpdb::esc_like() + * + * @param string $text The text to be escaped. + * @return string text, safe for inclusion in LIKE query. + */ +function like_escape($text) { + _deprecated_function( __FUNCTION__, '4.0.0', 'wpdb::esc_like()' ); + return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); +} + +/** + * Determines if the URL can be accessed over SSL. + * + * Determines if the URL can be accessed over SSL by using the WordPress HTTP API to access + * the URL using https as the scheme. + * + * @since 2.5.0 + * @deprecated 4.0.0 + * + * @param string $url The URL to test. + * @return bool Whether SSL access is available. + */ +function url_is_accessable_via_ssl( $url ) { + _deprecated_function( __FUNCTION__, '4.0.0' ); + + $response = wp_remote_get( set_url_scheme( $url, 'https' ) ); + + if ( !is_wp_error( $response ) ) { + $status = wp_remote_retrieve_response_code( $response ); + if ( 200 == $status || 401 == $status ) { + return true; + } + } + + return false; +} + +/** + * Start preview theme output buffer. + * + * Will only perform task if the user has permissions and template and preview + * query variables exist. + * + * @since 2.6.0 + * @deprecated 4.3.0 + */ +function preview_theme() { + _deprecated_function( __FUNCTION__, '4.3.0' ); +} + +/** + * Private function to modify the current template when previewing a theme + * + * @since 2.9.0 + * @deprecated 4.3.0 + * @access private + * + * @return string + */ +function _preview_theme_template_filter() { + _deprecated_function( __FUNCTION__, '4.3.0' ); + return ''; +} + +/** + * Private function to modify the current stylesheet when previewing a theme + * + * @since 2.9.0 + * @deprecated 4.3.0 + * @access private + * + * @return string + */ +function _preview_theme_stylesheet_filter() { + _deprecated_function( __FUNCTION__, '4.3.0' ); + return ''; +} + +/** + * Callback function for ob_start() to capture all links in the theme. + * + * @since 2.6.0 + * @deprecated 4.3.0 + * @access private + * + * @param string $content + * @return string + */ +function preview_theme_ob_filter( $content ) { + _deprecated_function( __FUNCTION__, '4.3.0' ); + return $content; +} + +/** + * Manipulates preview theme links in order to control and maintain location. + * + * Callback function for preg_replace_callback() to accept and filter matches. + * + * @since 2.6.0 + * @deprecated 4.3.0 + * @access private + * + * @param array $matches + * @return string + */ +function preview_theme_ob_filter_callback( $matches ) { + _deprecated_function( __FUNCTION__, '4.3.0' ); + return ''; +} + +/** + * Formats text for the rich text editor. + * + * The {@see 'richedit_pre'} filter is applied here. If $text is empty the filter will + * be applied to an empty string. + * + * @since 2.0.0 + * @deprecated 4.3.0 Use format_for_editor() + * @see format_for_editor() + * + * @param string $text The text to be formatted. + * @return string The formatted text after filter is applied. + */ +function wp_richedit_pre($text) { + _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); + + if ( empty( $text ) ) { + /** + * Filters text returned for the rich text editor. + * + * This filter is first evaluated, and the value returned, if an empty string + * is passed to wp_richedit_pre(). If an empty string is passed, it results + * in a break tag and line feed. + * + * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre() + * return after being formatted. + * + * @since 2.0.0 + * @deprecated 4.3.0 + * + * @param string $output Text for the rich text editor. + */ + return apply_filters( 'richedit_pre', '' ); + } + + $output = convert_chars($text); + $output = wpautop($output); + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); + + /** This filter is documented in wp-includes/deprecated.php */ + return apply_filters( 'richedit_pre', $output ); +} + +/** + * Formats text for the HTML editor. + * + * Unless $output is empty it will pass through htmlspecialchars before the + * {@see 'htmledit_pre'} filter is applied. + * + * @since 2.5.0 + * @deprecated 4.3.0 Use format_for_editor() + * @see format_for_editor() + * + * @param string $output The text to be formatted. + * @return string Formatted text after filter applied. + */ +function wp_htmledit_pre($output) { + _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); + + if ( !empty($output) ) + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & + + /** + * Filters the text before it is formatted for the HTML editor. + * + * @since 2.5.0 + * @deprecated 4.3.0 + * + * @param string $output The HTML-formatted text. + */ + return apply_filters( 'htmledit_pre', $output ); +} + +/** + * Retrieve permalink from post ID. + * + * @since 1.0.0 + * @deprecated 4.4.0 Use get_permalink() + * @see get_permalink() + * + * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. + * @return string|false + */ +function post_permalink( $post_id = 0 ) { + _deprecated_function( __FUNCTION__, '4.4.0', 'get_permalink()' ); + + return get_permalink( $post_id ); +} + +/** + * Perform a HTTP HEAD or GET request. + * + * If $file_path is a writable filename, this will do a GET request and write + * the file to that path. + * + * @since 2.5.0 + * @deprecated 4.4.0 Use WP_Http + * @see WP_Http + * + * @param string $url URL to fetch. + * @param string|bool $file_path Optional. File path to write request to. Default false. + * @param int $red Optional. The number of Redirects followed, Upon 5 being hit, + * returns false. Default 1. + * @return bool|string False on failure and string of headers if HEAD request. + */ +function wp_get_http( $url, $file_path = false, $red = 1 ) { + _deprecated_function( __FUNCTION__, '4.4.0', 'WP_Http' ); + + @set_time_limit( 60 ); + + if ( $red > 5 ) + return false; + + $options = array(); + $options['redirection'] = 5; + + if ( false == $file_path ) + $options['method'] = 'HEAD'; + else + $options['method'] = 'GET'; + + $response = wp_safe_remote_request( $url, $options ); + + if ( is_wp_error( $response ) ) + return false; + + $headers = wp_remote_retrieve_headers( $response ); + $headers['response'] = wp_remote_retrieve_response_code( $response ); + + // WP_HTTP no longer follows redirects for HEAD requests. + if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { + return wp_get_http( $headers['location'], $file_path, ++$red ); + } + + if ( false == $file_path ) + return $headers; + + // GET request - write it to the supplied filename + $out_fp = fopen($file_path, 'w'); + if ( !$out_fp ) + return $headers; + + fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); + fclose($out_fp); + clearstatcache(); + + return $headers; +} + +/** + * Whether SSL login should be forced. + * + * @since 2.6.0 + * @deprecated 4.4.0 Use force_ssl_admin() + * @see force_ssl_admin() + * + * @param string|bool $force Optional Whether to force SSL login. Default null. + * @return bool True if forced, false if not forced. + */ +function force_ssl_login( $force = null ) { + _deprecated_function( __FUNCTION__, '4.4.0', 'force_ssl_admin()' ); + return force_ssl_admin( $force ); +} + +/** + * Retrieve path of comment popup template in current or parent template. + * + * @since 1.5.0 + * @deprecated 4.5.0 + * + * @return string Full path to comments popup template file. + */ +function get_comments_popup_template() { + _deprecated_function( __FUNCTION__, '4.5.0' ); + + return ''; +} + +/** + * Whether the current URL is within the comments popup window. + * + * @since 1.5.0 + * @deprecated 4.5.0 + * + * @return bool + */ +function is_comments_popup() { + _deprecated_function( __FUNCTION__, '4.5.0' ); + + return false; +} + +/** + * Display the JS popup script to show a comment. + * + * @since 0.71 + * @deprecated 4.5.0 + */ +function comments_popup_script() { + _deprecated_function( __FUNCTION__, '4.5.0' ); +} + +/** + * Adds element attributes to open links in new windows. + * + * @since 0.71 + * @deprecated 4.5.0 + * + * @param string $text Content to replace links to open in a new window. + * @return string Content that has filtered links. + */ +function popuplinks( $text ) { + _deprecated_function( __FUNCTION__, '4.5.0' ); + $text = preg_replace('//i', "", $text); + return $text; +} + +/** + * The Google Video embed handler callback. + * + * Deprecated function that previously assisted in turning Google Video URLs + * into embeds but that service has since been shut down. + * + * @since 2.9.0 + * @deprecated 4.6.0 + * + * @return string An empty string. + */ +function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { + _deprecated_function( __FUNCTION__, '4.6.0' ); + + return ''; +} + +/** + * Retrieve path of paged template in current or parent template. + * + * @since 1.5.0 + * @deprecated 4.7.0 The paged.php template is no longer part of the theme template hierarchy. + * + * @return string Full path to paged template file. + */ +function get_paged_template() { + _deprecated_function( __FUNCTION__, '4.7.0' ); + + return get_query_template( 'paged' ); +} + +/** + * Removes the HTML JavaScript entities found in early versions of Netscape 4. + * + * Previously, this function was pulled in from the original + * import of kses and removed a specific vulnerability only + * existent in early version of Netscape 4. However, this + * vulnerability never affected any other browsers and can + * be considered safe for the modern web. + * + * The regular expression which sanitized this vulnerability + * has been removed in consideration of the performance and + * energy demands it placed, now merely passing through its + * input to the return. + * + * @since 1.0.0 + * @deprecated 4.7.0 Officially dropped security support for Netscape 4. + * + * @param string $string + * @return string + */ +function wp_kses_js_entities( $string ) { + _deprecated_function( __FUNCTION__, '4.7.0' ); + + return preg_replace( '%&\s*\{[^}]*(\}\s*;?|$)%', '', $string ); +} + +/** + * Sort categories by ID. + * + * Used by usort() as a callback, should not be used directly. Can actually be + * used to sort any term object. + * + * @since 2.3.0 + * @deprecated 4.7.0 Use wp_list_sort() + * @access private + * + * @param object $a + * @param object $b + * @return int + */ +function _usort_terms_by_ID( $a, $b ) { + _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); + + if ( $a->term_id > $b->term_id ) + return 1; + elseif ( $a->term_id < $b->term_id ) + return -1; + else + return 0; +} + +/** + * Sort categories by name. + * + * Used by usort() as a callback, should not be used directly. Can actually be + * used to sort any term object. + * + * @since 2.3.0 + * @deprecated 4.7.0 Use wp_list_sort() + * @access private + * + * @param object $a + * @param object $b + * @return int + */ +function _usort_terms_by_name( $a, $b ) { + _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); + + return strcmp( $a->name, $b->name ); +} + +/** + * Sort menu items by the desired key. + * + * @since 3.0.0 + * @deprecated 4.7.0 Use wp_list_sort() + * @access private + * + * @global string $_menu_item_sort_prop + * + * @param object $a The first object to compare + * @param object $b The second object to compare + * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b. + */ +function _sort_nav_menu_items( $a, $b ) { + global $_menu_item_sort_prop; + + _deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' ); + + if ( empty( $_menu_item_sort_prop ) ) + return 0; + + if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) ) + return 0; + + $_a = (int) $a->$_menu_item_sort_prop; + $_b = (int) $b->$_menu_item_sort_prop; + + if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop ) + return 0; + elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop ) + return $_a < $_b ? -1 : 1; + else + return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop ); +} + +/** + * Retrieves the Press This bookmarklet link. + * + * @since 2.6.0 + * @deprecated 4.9.0 + * + */ +function get_shortcut_link() { + _deprecated_function( __FUNCTION__, '4.9.0' ); + + $link = ''; + + /** + * Filters the Press This bookmarklet link. + * + * @since 2.6.0 + * @deprecated 4.9.0 + * + * @param string $link The Press This bookmarklet link. + */ + return apply_filters( 'shortcut_link', $link ); +} + +/** +* Ajax handler for saving a post from Press This. +* +* @since 4.2.0 +* @deprecated 4.9.0 +*/ +function wp_ajax_press_this_save_post() { + _deprecated_function( __FUNCTION__, '4.9.0' ); + if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { + include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' ); + $wp_press_this = new WP_Press_This_Plugin(); + $wp_press_this->save_post(); + } else { + wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); + } +} + +/** +* Ajax handler for creating new category from Press This. +* +* @since 4.2.0 +* @deprecated 4.9.0 +*/ +function wp_ajax_press_this_add_category() { + _deprecated_function( __FUNCTION__, '4.9.0' ); + if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) { + include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' ); + $wp_press_this = new WP_Press_This_Plugin(); + $wp_press_this->add_category(); + } else { + wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) ); + } +} diff --git a/backend/wp-includes/embed-template.php b/backend/wp-includes/embed-template.php new file mode 100644 index 0000000..fb20991 --- /dev/null +++ b/backend/wp-includes/embed-template.php @@ -0,0 +1,13 @@ +register_handler( $id, $regex, $callback, $priority ); +} + +/** + * Unregisters a previously-registered embed handler. + * + * @since 2.9.0 + * + * @global WP_Embed $wp_embed + * + * @param string $id The handler ID that should be removed. + * @param int $priority Optional. The priority of the handler to be removed. Default 10. + */ +function wp_embed_unregister_handler( $id, $priority = 10 ) { + global $wp_embed; + $wp_embed->unregister_handler( $id, $priority ); +} + +/** + * Creates default array of embed parameters. + * + * The width defaults to the content width as specified by the theme. If the + * theme does not specify a content width, then 500px is used. + * + * The default height is 1.5 times the width, or 1000px, whichever is smaller. + * + * The {@see 'embed_defaults'} filter can be used to adjust either of these values. + * + * @since 2.9.0 + * + * @global int $content_width + * + * @param string $url Optional. The URL that should be embedded. Default empty. + * + * @return array Default embed parameters. + */ +function wp_embed_defaults( $url = '' ) { + if ( ! empty( $GLOBALS['content_width'] ) ) + $width = (int) $GLOBALS['content_width']; + + if ( empty( $width ) ) + $width = 500; + + $height = min( ceil( $width * 1.5 ), 1000 ); + + /** + * Filters the default array of embed dimensions. + * + * @since 2.9.0 + * + * @param array $size An array of embed width and height values + * in pixels (in that order). + * @param string $url The URL that should be embedded. + */ + return apply_filters( 'embed_defaults', compact( 'width', 'height' ), $url ); +} + +/** + * Attempts to fetch the embed HTML for a provided URL using oEmbed. + * + * @since 2.9.0 + * + * @see WP_oEmbed + * + * @param string $url The URL that should be embedded. + * @param array $args Optional. Additional arguments and parameters for retrieving embed HTML. + * Default empty. + * @return false|string False on failure or the embed HTML on success. + */ +function wp_oembed_get( $url, $args = '' ) { + $oembed = _wp_oembed_get_object(); + return $oembed->get_html( $url, $args ); +} + +/** + * Returns the initialized WP_oEmbed object. + * + * @since 2.9.0 + * @access private + * + * @staticvar WP_oEmbed $wp_oembed + * + * @return WP_oEmbed object. + */ +function _wp_oembed_get_object() { + static $wp_oembed = null; + + if ( is_null( $wp_oembed ) ) { + $wp_oembed = new WP_oEmbed(); + } + return $wp_oembed; +} + +/** + * Adds a URL format and oEmbed provider URL pair. + * + * @since 2.9.0 + * + * @see WP_oEmbed + * + * @param string $format The format of URL that this provider can handle. You can use asterisks + * as wildcards. + * @param string $provider The URL to the oEmbed provider. + * @param boolean $regex Optional. Whether the `$format` parameter is in a RegEx format. Default false. + */ +function wp_oembed_add_provider( $format, $provider, $regex = false ) { + if ( did_action( 'plugins_loaded' ) ) { + $oembed = _wp_oembed_get_object(); + $oembed->providers[$format] = array( $provider, $regex ); + } else { + WP_oEmbed::_add_provider_early( $format, $provider, $regex ); + } +} + +/** + * Removes an oEmbed provider. + * + * @since 3.5.0 + * + * @see WP_oEmbed + * + * @param string $format The URL format for the oEmbed provider to remove. + * @return bool Was the provider removed successfully? + */ +function wp_oembed_remove_provider( $format ) { + if ( did_action( 'plugins_loaded' ) ) { + $oembed = _wp_oembed_get_object(); + + if ( isset( $oembed->providers[ $format ] ) ) { + unset( $oembed->providers[ $format ] ); + return true; + } + } else { + WP_oEmbed::_remove_provider_early( $format ); + } + + return false; +} + +/** + * Determines if default embed handlers should be loaded. + * + * Checks to make sure that the embeds library hasn't already been loaded. If + * it hasn't, then it will load the embeds library. + * + * @since 2.9.0 + * + * @see wp_embed_register_handler() + */ +function wp_maybe_load_embeds() { + /** + * Filters whether to load the default embed handlers. + * + * Returning a falsey value will prevent loading the default embed handlers. + * + * @since 2.9.0 + * + * @param bool $maybe_load_embeds Whether to load the embeds library. Default true. + */ + if ( ! apply_filters( 'load_default_embeds', true ) ) { + return; + } + + wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); + + /** + * Filters the audio embed handler callback. + * + * @since 3.6.0 + * + * @param callable $handler Audio embed handler callback function. + */ + wp_embed_register_handler( 'audio', '#^https?://.+?\.(' . join( '|', wp_get_audio_extensions() ) . ')$#i', apply_filters( 'wp_audio_embed_handler', 'wp_embed_handler_audio' ), 9999 ); + + /** + * Filters the video embed handler callback. + * + * @since 3.6.0 + * + * @param callable $handler Video embed handler callback function. + */ + wp_embed_register_handler( 'video', '#^https?://.+?\.(' . join( '|', wp_get_video_extensions() ) . ')$#i', apply_filters( 'wp_video_embed_handler', 'wp_embed_handler_video' ), 9999 ); +} + +/** + * YouTube iframe embed handler callback. + * + * Catches YouTube iframe embed URLs that are not parsable by oEmbed but can be translated into a URL that is. + * + * @since 4.0.0 + * + * @global WP_Embed $wp_embed + * + * @param array $matches The RegEx matches from the provided regex when calling + * wp_embed_register_handler(). + * @param array $attr Embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + * @return string The embed HTML. + */ +function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { + global $wp_embed; + $embed = $wp_embed->autoembed( sprintf( "https://youtube.com/watch?v=%s", urlencode( $matches[2] ) ) ); + + /** + * Filters the YoutTube embed output. + * + * @since 4.0.0 + * + * @see wp_embed_handler_youtube() + * + * @param string $embed YouTube embed output. + * @param array $attr An array of embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + */ + return apply_filters( 'wp_embed_handler_youtube', $embed, $attr, $url, $rawattr ); +} + +/** + * Audio embed handler callback. + * + * @since 3.6.0 + * + * @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler(). + * @param array $attr Embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + * @return string The embed HTML. + */ +function wp_embed_handler_audio( $matches, $attr, $url, $rawattr ) { + $audio = sprintf( '[audio src="%s" /]', esc_url( $url ) ); + + /** + * Filters the audio embed output. + * + * @since 3.6.0 + * + * @param string $audio Audio embed output. + * @param array $attr An array of embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + */ + return apply_filters( 'wp_embed_handler_audio', $audio, $attr, $url, $rawattr ); +} + +/** + * Video embed handler callback. + * + * @since 3.6.0 + * + * @param array $matches The RegEx matches from the provided regex when calling wp_embed_register_handler(). + * @param array $attr Embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + * @return string The embed HTML. + */ +function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { + $dimensions = ''; + if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { + $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); + $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); + } + $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); + + /** + * Filters the video embed output. + * + * @since 3.6.0 + * + * @param string $video Video embed output. + * @param array $attr An array of embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + */ + return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); +} + +/** + * Registers the oEmbed REST API route. + * + * @since 4.4.0 + */ +function wp_oembed_register_route() { + $controller = new WP_oEmbed_Controller(); + $controller->register_routes(); +} + +/** + * Adds oEmbed discovery links in the website . + * + * @since 4.4.0 + */ +function wp_oembed_add_discovery_links() { + $output = ''; + + if ( is_singular() ) { + $output .= '' . "\n"; + + if ( class_exists( 'SimpleXMLElement' ) ) { + $output .= '' . "\n"; + } + } + + /** + * Filters the oEmbed discovery links HTML. + * + * @since 4.4.0 + * + * @param string $output HTML of the discovery links. + */ + echo apply_filters( 'oembed_discovery_links', $output ); +} + +/** + * Adds the necessary JavaScript to communicate with the embedded iframes. + * + * @since 4.4.0 + */ +function wp_oembed_add_host_js() { + wp_enqueue_script( 'wp-embed' ); +} + +/** + * Retrieves the URL to embed a specific post in an iframe. + * + * @since 4.4.0 + * + * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post. + * @return string|false The post embed URL on success, false if the post doesn't exist. + */ +function get_post_embed_url( $post = null ) { + $post = get_post( $post ); + + if ( ! $post ) { + return false; + } + + $embed_url = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' ); + $path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) ); + + if ( ! get_option( 'permalink_structure' ) || $path_conflict ) { + $embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) ); + } + + /** + * Filters the URL to embed a specific post. + * + * @since 4.4.0 + * + * @param string $embed_url The post embed URL. + * @param WP_Post $post The corresponding post object. + */ + return esc_url_raw( apply_filters( 'post_embed_url', $embed_url, $post ) ); +} + +/** + * Retrieves the oEmbed endpoint URL for a given permalink. + * + * Pass an empty string as the first argument to get the endpoint base URL. + * + * @since 4.4.0 + * + * @param string $permalink Optional. The permalink used for the `url` query arg. Default empty. + * @param string $format Optional. The requested response format. Default 'json'. + * @return string The oEmbed endpoint URL. + */ +function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) { + $url = rest_url( 'oembed/1.0/embed' ); + + if ( '' !== $permalink ) { + $url = add_query_arg( array( + 'url' => urlencode( $permalink ), + 'format' => ( 'json' !== $format ) ? $format : false, + ), $url ); + } + + /** + * Filters the oEmbed endpoint URL. + * + * @since 4.4.0 + * + * @param string $url The URL to the oEmbed endpoint. + * @param string $permalink The permalink used for the `url` query arg. + * @param string $format The requested response format. + */ + return apply_filters( 'oembed_endpoint_url', $url, $permalink, $format ); +} + +/** + * Retrieves the embed code for a specific post. + * + * @since 4.4.0 + * + * @param int $width The width for the response. + * @param int $height The height for the response. + * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`. + * @return string|false Embed code on success, false if post doesn't exist. + */ +function get_post_embed_html( $width, $height, $post = null ) { + $post = get_post( $post ); + + if ( ! $post ) { + return false; + } + + $embed_url = get_post_embed_url( $post ); + + $output = '
          ' . get_the_title( $post ) . "
          \n"; + + $output .= ""; + + $output .= sprintf( + '', + esc_url( $embed_url ), + absint( $width ), + absint( $height ), + esc_attr( + sprintf( + /* translators: 1: post title, 2: site name */ + __( '“%1$s” — %2$s' ), + get_the_title( $post ), + get_bloginfo( 'name' ) + ) + ) + ); + + /** + * Filters the embed HTML output for a given post. + * + * @since 4.4.0 + * + * @param string $output The default iframe tag to display embedded content. + * @param WP_Post $post Current post object. + * @param int $width Width of the response. + * @param int $height Height of the response. + */ + return apply_filters( 'embed_html', $output, $post, $width, $height ); +} + +/** + * Retrieves the oEmbed response data for a given post. + * + * @since 4.4.0 + * + * @param WP_Post|int $post Post object or ID. + * @param int $width The requested width. + * @return array|false Response data on success, false if post doesn't exist. + */ +function get_oembed_response_data( $post, $width ) { + $post = get_post( $post ); + $width = absint( $width ); + + if ( ! $post ) { + return false; + } + + if ( 'publish' !== get_post_status( $post ) ) { + return false; + } + + /** + * Filters the allowed minimum and maximum widths for the oEmbed response. + * + * @since 4.4.0 + * + * @param array $min_max_width { + * Minimum and maximum widths for the oEmbed response. + * + * @type int $min Minimum width. Default 200. + * @type int $max Maximum width. Default 600. + * } + */ + $min_max_width = apply_filters( 'oembed_min_max_width', array( + 'min' => 200, + 'max' => 600 + ) ); + + $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); + $height = max( ceil( $width / 16 * 9 ), 200 ); + + $data = array( + 'version' => '1.0', + 'provider_name' => get_bloginfo( 'name' ), + 'provider_url' => get_home_url(), + 'author_name' => get_bloginfo( 'name' ), + 'author_url' => get_home_url(), + 'title' => $post->post_title, + 'type' => 'link', + ); + + $author = get_userdata( $post->post_author ); + + if ( $author ) { + $data['author_name'] = $author->display_name; + $data['author_url'] = get_author_posts_url( $author->ID ); + } + + /** + * Filters the oEmbed response data. + * + * @since 4.4.0 + * + * @param array $data The response data. + * @param WP_Post $post The post object. + * @param int $width The requested width. + * @param int $height The calculated height. + */ + return apply_filters( 'oembed_response_data', $data, $post, $width, $height ); +} + +/** + * Filters the oEmbed response data to return an iframe embed code. + * + * @since 4.4.0 + * + * @param array $data The response data. + * @param WP_Post $post The post object. + * @param int $width The requested width. + * @param int $height The calculated height. + * @return array The modified response data. + */ +function get_oembed_response_data_rich( $data, $post, $width, $height ) { + $data['width'] = absint( $width ); + $data['height'] = absint( $height ); + $data['type'] = 'rich'; + $data['html'] = get_post_embed_html( $width, $height, $post ); + + // Add post thumbnail to response if available. + $thumbnail_id = false; + + if ( has_post_thumbnail( $post->ID ) ) { + $thumbnail_id = get_post_thumbnail_id( $post->ID ); + } + + if ( 'attachment' === get_post_type( $post ) ) { + if ( wp_attachment_is_image( $post ) ) { + $thumbnail_id = $post->ID; + } else if ( wp_attachment_is( 'video', $post ) ) { + $thumbnail_id = get_post_thumbnail_id( $post ); + $data['type'] = 'video'; + } + } + + if ( $thumbnail_id ) { + list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); + $data['thumbnail_url'] = $thumbnail_url; + $data['thumbnail_width'] = $thumbnail_width; + $data['thumbnail_height'] = $thumbnail_height; + } + + return $data; +} + +/** + * Ensures that the specified format is either 'json' or 'xml'. + * + * @since 4.4.0 + * + * @param string $format The oEmbed response format. Accepts 'json' or 'xml'. + * @return string The format, either 'xml' or 'json'. Default 'json'. + */ +function wp_oembed_ensure_format( $format ) { + if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) { + return 'json'; + } + + return $format; +} + +/** + * Hooks into the REST API output to print XML instead of JSON. + * + * This is only done for the oEmbed API endpoint, + * which supports both formats. + * + * @access private + * @since 4.4.0 + * + * @param bool $served Whether the request has already been served. + * @param WP_HTTP_ResponseInterface $result Result to send to the client. Usually a WP_REST_Response. + * @param WP_REST_Request $request Request used to generate the response. + * @param WP_REST_Server $server Server instance. + * @return true + */ +function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) { + $params = $request->get_params(); + + if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) { + return $served; + } + + if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) { + return $served; + } + + // Embed links inside the request. + $data = $server->response_to_data( $result, false ); + + if ( ! class_exists( 'SimpleXMLElement' ) ) { + status_header( 501 ); + die( get_status_header_desc( 501 ) ); + } + + $result = _oembed_create_xml( $data ); + + // Bail if there's no XML. + if ( ! $result ) { + status_header( 501 ); + return get_status_header_desc( 501 ); + } + + if ( ! headers_sent() ) { + $server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) ); + } + + echo $result; + + return true; +} + +/** + * Creates an XML string from a given array. + * + * @since 4.4.0 + * @access private + * + * @param array $data The original oEmbed response data. + * @param SimpleXMLElement $node Optional. XML node to append the result to recursively. + * @return string|false XML string on success, false on error. + */ +function _oembed_create_xml( $data, $node = null ) { + if ( ! is_array( $data ) || empty( $data ) ) { + return false; + } + + if ( null === $node ) { + $node = new SimpleXMLElement( '' ); + } + + foreach ( $data as $key => $value ) { + if ( is_numeric( $key ) ) { + $key = 'oembed'; + } + + if ( is_array( $value ) ) { + $item = $node->addChild( $key ); + _oembed_create_xml( $value, $item ); + } else { + $node->addChild( $key, esc_html( $value ) ); + } + } + + return $node->asXML(); +} + +/** + * Filters the given oEmbed HTML. + * + * If the `$url` isn't on the trusted providers list, + * we need to filter the HTML heavily for security. + * + * Only filters 'rich' and 'html' response types. + * + * @since 4.4.0 + * + * @param string $result The oEmbed HTML result. + * @param object $data A data object result from an oEmbed provider. + * @param string $url The URL of the content to be embedded. + * @return string The filtered and sanitized oEmbed result. + */ +function wp_filter_oembed_result( $result, $data, $url ) { + if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ) ) ) { + return $result; + } + + $wp_oembed = _wp_oembed_get_object(); + + // Don't modify the HTML for trusted providers. + if ( false !== $wp_oembed->get_provider( $url, array( 'discover' => false ) ) ) { + return $result; + } + + $allowed_html = array( + 'a' => array( + 'href' => true, + ), + 'blockquote' => array(), + 'iframe' => array( + 'src' => true, + 'width' => true, + 'height' => true, + 'frameborder' => true, + 'marginwidth' => true, + 'marginheight' => true, + 'scrolling' => true, + 'title' => true, + ), + ); + + $html = wp_kses( $result, $allowed_html ); + + preg_match( '|(
          .*?
          )?.*()|ms', $html, $content ); + // We require at least the iframe to exist. + if ( empty( $content[2] ) ) { + return false; + } + $html = $content[1] . $content[2]; + + preg_match( '/ src=([\'"])(.*?)\1/', $html, $results ); + + if ( ! empty( $results ) ) { + $secret = wp_generate_password( 10, false ); + + $url = esc_url( "{$results[2]}#?secret=$secret" ); + $q = $results[1]; + + $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html ); + $html = str_replace( '%2$s', + esc_url( get_permalink() ), + /* translators: %s: Name of current post */ + sprintf( __( 'Continue reading %s' ), '' . get_the_title() . '' ) + ); + return ' … ' . $link; +} + +/** + * Displays the post excerpt for the embed template. + * + * Intended to be used in 'The Loop'. + * + * @since 4.4.0 + */ +function the_excerpt_embed() { + $output = get_the_excerpt(); + + /** + * Filters the post excerpt for the embed template. + * + * @since 4.4.0 + * + * @param string $output The current post excerpt. + */ + echo apply_filters( 'the_excerpt_embed', $output ); +} + +/** + * Filters the post excerpt for the embed template. + * + * Shows players for video and audio attachments. + * + * @since 4.4.0 + * + * @param string $content The current post excerpt. + * @return string The modified post excerpt. + */ +function wp_embed_excerpt_attachment( $content ) { + if ( is_attachment() ) { + return prepend_attachment( '' ); + } + + return $content; +} + +/** + * Enqueue embed iframe default CSS and JS & fire do_action('enqueue_embed_scripts') + * + * Enqueue PNG fallback CSS for embed iframe for legacy versions of IE. + * + * Allows plugins to queue scripts for the embed iframe end using wp_enqueue_script(). + * Runs first in oembed_head(). + * + * @since 4.4.0 + */ +function enqueue_embed_scripts() { + wp_enqueue_style( 'wp-embed-template-ie' ); + + /** + * Fires when scripts and styles are enqueued for the embed iframe. + * + * @since 4.4.0 + */ + do_action( 'enqueue_embed_scripts' ); +} + +/** + * Prints the CSS in the embed iframe header. + * + * @since 4.4.0 + */ +function print_embed_styles() { + ?> + + + + + + +
          + +
          + + + %s', + esc_url( home_url() ), + esc_url( get_site_icon_url( 32, admin_url( 'images/w-logo-blue.png' ) ) ), + esc_url( get_site_icon_url( 64, admin_url( 'images/w-logo-blue.png' ) ) ), + esc_html( get_bloginfo( 'name' ) ) + ); + + $site_title = '
          ' . $site_title . '
          '; + + /** + * Filters the site title HTML in the embed footer. + * + * @since 4.4.0 + * + * @param string $site_title The site title HTML. + */ + echo apply_filters( 'embed_site_title_html', $site_title ); +} + +/** + * Filters the oEmbed result before any HTTP requests are made. + * + * If the URL belongs to the current site, the result is fetched directly instead of + * going through the oEmbed discovery process. + * + * @since 4.5.3 + * + * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. + * @param string $url The URL that should be inspected for discovery `` tags. + * @param array $args oEmbed remote get arguments. + * @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. + * Null if the URL does not belong to the current site. + */ +function wp_filter_pre_oembed_result( $result, $url, $args ) { + $switched_blog = false; + + if ( is_multisite() ) { + $url_parts = wp_parse_args( wp_parse_url( $url ), array( + 'host' => '', + 'path' => '/', + ) ); + + $qv = array( 'domain' => $url_parts['host'], 'path' => '/' ); + + // In case of subdirectory configs, set the path. + if ( ! is_subdomain_install() ) { + $path = explode( '/', ltrim( $url_parts['path'], '/' ) ); + $path = reset( $path ); + + if ( $path ) { + $qv['path'] = get_network()->path . $path . '/'; + } + } + + $sites = get_sites( $qv ); + $site = reset( $sites ); + + if ( $site && (int) $site->blog_id !== get_current_blog_id() ) { + switch_to_blog( $site->blog_id ); + $switched_blog = true; + } + } + + $post_id = url_to_postid( $url ); + + /** This filter is documented in wp-includes/class-wp-oembed-controller.php */ + $post_id = apply_filters( 'oembed_request_post_id', $post_id, $url ); + + if ( ! $post_id ) { + if ( $switched_blog ) { + restore_current_blog(); + } + + return $result; + } + + $width = isset( $args['width'] ) ? $args['width'] : 0; + + $data = get_oembed_response_data( $post_id, $width ); + $data = _wp_oembed_get_object()->data2html( (object) $data, $url ); + + if ( $switched_blog ) { + restore_current_blog(); + } + + if ( ! $data ) { + return $result; + } + + return $data; +} diff --git a/backend/wp-includes/feed-atom-comments.php b/backend/wp-includes/feed-atom-comments.php new file mode 100644 index 0000000..cfdae4a --- /dev/null +++ b/backend/wp-includes/feed-atom-comments.php @@ -0,0 +1,124 @@ +'; + +/** This action is documented in wp-includes/feed-rss2.php */ +do_action( 'rss_tag_pre', 'atom-comments' ); +?> + +> + <?php + if ( is_singular() ) { + /* translators: Comments feed title. 1: Post title */ + printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() ); + } elseif ( is_search() ) { + /* translators: Comments feed title. 1: Site name, 2: Search query */ + printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() ); + } else { + /* translators: Comments feed title. 1: Site name */ + printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() ); + } + ?> + + + + + + + + + + + + + + + + + + +comment_post_ID ); +?> + + <?php + if ( !is_singular() ) { + $title = get_the_title($comment_post->ID); + /** This filter is documented in wp-includes/feed.php */ + $title = apply_filters( 'the_title_rss', $title ); + /* translators: Individual comment title. 1: Post title, 2: Comment author name */ + printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss()); + } else { + /* translators: Comment author title. 1: Comment author name */ + printf(ent2ncr(__('By: %s')), get_comment_author_rss()); + } + ?> + + + + + ' . get_comment_author_url() . ''; ?> + + + + + + + + ]]> + + ]]> +comment_parent == 0 ) : // This comment is top level ?> + +comment_parent); + // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, it's more important that they both use the same system +?> + +comment_ID, $comment_post->ID ); +?> + + + diff --git a/backend/wp-includes/feed-atom.php b/backend/wp-includes/feed-atom.php new file mode 100644 index 0000000..2c93aba --- /dev/null +++ b/backend/wp-includes/feed-atom.php @@ -0,0 +1,93 @@ +'; + +/** This action is documented in wp-includes/feed-rss2.php */ +do_action( 'rss_tag_pre', 'atom' ); +?> + + > + <?php wp_title_rss(); ?> + + + + + + + + + + + + + + + + + <![CDATA[<?php the_title_rss() ?>]]> + + + + + + ]]> + + ]]> + + + + + + + + + diff --git a/backend/wp-includes/feed-rdf.php b/backend/wp-includes/feed-rdf.php new file mode 100644 index 0000000..b748400 --- /dev/null +++ b/backend/wp-includes/feed-rdf.php @@ -0,0 +1,88 @@ +'; + +/** This action is documented in wp-includes/feed-rss2.php */ +do_action( 'rss_tag_pre', 'rdf' ); +?> + +> +"> + <?php wp_title_rss(); ?> + + + + + + 2000-01-01T12:00+00:00 + + + + + + + + + + + + <?php the_title_rss() ?> + + post_date_gmt, false); ?> + ]]> + + + ]]> + + ]]> + ]]> + + + + + diff --git a/backend/wp-includes/feed-rss.php b/backend/wp-includes/feed-rss.php new file mode 100644 index 0000000..39202b8 --- /dev/null +++ b/backend/wp-includes/feed-rss.php @@ -0,0 +1,49 @@ +'; ?> + + + <?php wp_title_rss(); ?> + + + + http://backend.userland.com/rss092 + + + + + + + <?php the_title_rss() ?> + ]]> + + + + + + diff --git a/backend/wp-includes/feed-rss2-comments.php b/backend/wp-includes/feed-rss2-comments.php new file mode 100644 index 0000000..d6137ba --- /dev/null +++ b/backend/wp-includes/feed-rss2-comments.php @@ -0,0 +1,110 @@ +'; + +/** This action is documented in wp-includes/feed-rss2.php */ +do_action( 'rss_tag_pre', 'rss2-comments' ); +?> + + + +> + + <?php + if ( is_singular() ) { + /* translators: Comments feed title. 1: Post title */ + printf( ent2ncr( __( 'Comments on: %s' ) ), get_the_title_rss() ); + } elseif ( is_search() ) { + /* translators: Comments feed title. 1: Site name, 2: Search query */ + printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() ); + } else { + /* translators: Comments feed title. 1: Site name */ + printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() ); + } + ?> + + + + + + + comment_post_ID ); + ?> + + <?php + if ( !is_singular() ) { + $title = get_the_title($comment_post->ID); + /** This filter is documented in wp-includes/feed.php */ + $title = apply_filters( 'the_title_rss', $title ); + /* translators: Individual comment title. 1: Post title, 2: Comment author name */ + printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss()); + } else { + /* translators: Comment author title. 1: Comment author name */ + printf(ent2ncr(__('By: %s')), get_comment_author_rss()); + } + ?> + + ]]> + + + + + ]]> + + ]]> + ]]> +comment_ID The ID of the comment being displayed. + * @param int $comment_post->ID The ID of the post the comment is connected to. + */ + do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID ); +?> + + + + diff --git a/backend/wp-includes/feed-rss2.php b/backend/wp-includes/feed-rss2.php new file mode 100644 index 0000000..2e53b17 --- /dev/null +++ b/backend/wp-includes/feed-rss2.php @@ -0,0 +1,124 @@ +'; + +/** + * Fires between the xml and rss tags in a feed. + * + * @since 4.0.0 + * + * @param string $context Type of feed. Possible values include 'rss2', 'rss2-comments', + * 'rdf', 'atom', and 'atom-comments'. + */ +do_action( 'rss_tag_pre', 'rss2' ); +?> + +> + + + <?php wp_title_rss(); ?> + + + + + + + + + + <?php the_title_rss() ?> + + + + + + ]]> + + + + + ]]> + + ]]> + + 0 ) : ?> + ]]> + + ]]> + + + + + + + + + + + + diff --git a/backend/wp-includes/feed.php b/backend/wp-includes/feed.php new file mode 100644 index 0000000..ef6bf29 --- /dev/null +++ b/backend/wp-includes/feed.php @@ -0,0 +1,710 @@ +document_title_separator' ) ); + } + + /** + * Filters the blog title for use as the feed title. + * + * @since 2.2.0 + * @since 4.4.0 The `$sep` parameter was deprecated and renamed to `$deprecated`. + * + * @param string $title The current blog title. + * @param string $deprecated Unused. + */ + return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated ); +} + +/** + * Display the blog title for display of the feed title. + * + * @since 2.2.0 + * @since 4.4.0 The optional `$sep` parameter was deprecated and renamed to `$deprecated`. + * + * @param string $deprecated Unused. + */ +function wp_title_rss( $deprecated = '–' ) { + if ( '–' !== $deprecated ) { + /* translators: %s: 'document_title_separator' filter name */ + _deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), 'document_title_separator' ) ); + } + + /** + * Filters the blog title for display of the feed title. + * + * @since 2.2.0 + * @since 4.4.0 The `$sep` parameter was deprecated and renamed to `$deprecated`. + * + * @see get_wp_title_rss() + * + * @param string $wp_title_rss The current blog title. + * @param string $deprecated Unused. + */ + echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated ); +} + +/** + * Retrieve the current post title for the feed. + * + * @since 2.0.0 + * + * @return string Current post title. + */ +function get_the_title_rss() { + $title = get_the_title(); + + /** + * Filters the post title for use in a feed. + * + * @since 1.2.0 + * + * @param string $title The current post title. + */ + $title = apply_filters( 'the_title_rss', $title ); + return $title; +} + +/** + * Display the post title in the feed. + * + * @since 0.71 + */ +function the_title_rss() { + echo get_the_title_rss(); +} + +/** + * Retrieve the post content for feeds. + * + * @since 2.9.0 + * @see get_the_content() + * + * @param string $feed_type The type of feed. rss2 | atom | rss | rdf + * @return string The filtered content. + */ +function get_the_content_feed($feed_type = null) { + if ( !$feed_type ) + $feed_type = get_default_feed(); + + /** This filter is documented in wp-includes/post-template.php */ + $content = apply_filters( 'the_content', get_the_content() ); + $content = str_replace(']]>', ']]>', $content); + /** + * Filters the post content for use in feeds. + * + * @since 2.9.0 + * + * @param string $content The current post content. + * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'. + * Default 'rss2'. + */ + return apply_filters( 'the_content_feed', $content, $feed_type ); +} + +/** + * Display the post content for feeds. + * + * @since 2.9.0 + * + * @param string $feed_type The type of feed. rss2 | atom | rss | rdf + */ +function the_content_feed($feed_type = null) { + echo get_the_content_feed($feed_type); +} + +/** + * Display the post excerpt for the feed. + * + * @since 0.71 + */ +function the_excerpt_rss() { + $output = get_the_excerpt(); + /** + * Filters the post excerpt for a feed. + * + * @since 1.2.0 + * + * @param string $output The current post excerpt. + */ + echo apply_filters( 'the_excerpt_rss', $output ); +} + +/** + * Display the permalink to the post for use in feeds. + * + * @since 2.3.0 + */ +function the_permalink_rss() { + /** + * Filters the permalink to the post for use in feeds. + * + * @since 2.3.0 + * + * @param string $post_permalink The current post permalink. + */ + echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) ); +} + +/** + * Outputs the link to the comments for the current post in an xml safe way + * + * @since 3.0.0 + * @return none + */ +function comments_link_feed() { + /** + * Filters the comments permalink for the current post. + * + * @since 3.6.0 + * + * @param string $comment_permalink The current comment permalink with + * '#comments' appended. + */ + echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) ); +} + +/** + * Display the feed GUID for the current comment. + * + * @since 2.5.0 + * + * @param int|WP_Comment $comment_id Optional comment object or id. Defaults to global comment object. + */ +function comment_guid($comment_id = null) { + echo esc_url( get_comment_guid($comment_id) ); +} + +/** + * Retrieve the feed GUID for the current comment. + * + * @since 2.5.0 + * + * @param int|WP_Comment $comment_id Optional comment object or id. Defaults to global comment object. + * @return false|string false on failure or guid for comment on success. + */ +function get_comment_guid($comment_id = null) { + $comment = get_comment($comment_id); + + if ( !is_object($comment) ) + return false; + + return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; +} + +/** + * Display the link to the comments. + * + * @since 1.5.0 + * @since 4.4.0 Introduced the `$comment` argument. + * + * @param int|WP_Comment $comment Optional. Comment object or id. Defaults to global comment object. + */ +function comment_link( $comment = null ) { + /** + * Filters the current comment's permalink. + * + * @since 3.6.0 + * + * @see get_comment_link() + * + * @param string $comment_permalink The current comment permalink. + */ + echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) ); +} + +/** + * Retrieve the current comment author for use in the feeds. + * + * @since 2.0.0 + * + * @return string Comment Author + */ +function get_comment_author_rss() { + /** + * Filters the current comment author for use in a feed. + * + * @since 1.5.0 + * + * @see get_comment_author() + * + * @param string $comment_author The current comment author. + */ + return apply_filters( 'comment_author_rss', get_comment_author() ); +} + +/** + * Display the current comment author in the feed. + * + * @since 1.0.0 + */ +function comment_author_rss() { + echo get_comment_author_rss(); +} + +/** + * Display the current comment content for use in the feeds. + * + * @since 1.0.0 + */ +function comment_text_rss() { + $comment_text = get_comment_text(); + /** + * Filters the current comment content for use in a feed. + * + * @since 1.5.0 + * + * @param string $comment_text The content of the current comment. + */ + $comment_text = apply_filters( 'comment_text_rss', $comment_text ); + echo $comment_text; +} + +/** + * Retrieve all of the post categories, formatted for use in feeds. + * + * All of the categories for the current post in the feed loop, will be + * retrieved and have feed markup added, so that they can easily be added to the + * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds. + * + * @since 2.1.0 + * + * @param string $type Optional, default is the type returned by get_default_feed(). + * @return string All of the post categories for displaying in the feed. + */ +function get_the_category_rss($type = null) { + if ( empty($type) ) + $type = get_default_feed(); + $categories = get_the_category(); + $tags = get_the_tags(); + $the_list = ''; + $cat_names = array(); + + $filter = 'rss'; + if ( 'atom' == $type ) + $filter = 'raw'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + } + + $cat_names = array_unique($cat_names); + + foreach ( $cat_names as $cat_name ) { + if ( 'rdf' == $type ) + $the_list .= "\t\t\n"; + elseif ( 'atom' == $type ) + $the_list .= sprintf( '', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); + else + $the_list .= "\t\t\n"; + } + + /** + * Filters all of the post categories for display in a feed. + * + * @since 1.2.0 + * + * @param string $the_list All of the RSS post categories. + * @param string $type Type of feed. Possible values include 'rss2', 'atom'. + * Default 'rss2'. + */ + return apply_filters( 'the_category_rss', $the_list, $type ); +} + +/** + * Display the post categories in the feed. + * + * @since 0.71 + * @see get_the_category_rss() For better explanation. + * + * @param string $type Optional, default is the type returned by get_default_feed(). + */ +function the_category_rss($type = null) { + echo get_the_category_rss($type); +} + +/** + * Display the HTML type based on the blog setting. + * + * The two possible values are either 'xhtml' or 'html'. + * + * @since 2.2.0 + */ +function html_type_rss() { + $type = get_bloginfo('html_type'); + if (strpos($type, 'xhtml') !== false) + $type = 'xhtml'; + else + $type = 'html'; + echo $type; +} + +/** + * Display the rss enclosure for the current post. + * + * Uses the global $post to check whether the post requires a password and if + * the user has the password for the post. If not then it will return before + * displaying. + * + * Also uses the function get_post_custom() to get the post's 'enclosure' + * metadata field and parses the value to display the enclosure(s). The + * enclosure(s) consist of enclosure HTML tag(s) with a URI and other + * attributes. + * + * @since 1.5.0 + */ +function rss_enclosure() { + if ( post_password_required() ) + return; + + foreach ( (array) get_post_custom() as $key => $val) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + $enclosure = explode("\n", $enc); + + // only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3' + $t = preg_split('/[ \t]/', trim($enclosure[2]) ); + $type = $t[0]; + + /** + * Filters the RSS enclosure HTML link tag for the current post. + * + * @since 2.2.0 + * + * @param string $html_link_tag The HTML link tag with a URI and other attributes. + */ + echo apply_filters( 'rss_enclosure', '' . "\n" ); + } + } + } +} + +/** + * Display the atom enclosure for the current post. + * + * Uses the global $post to check whether the post requires a password and if + * the user has the password for the post. If not then it will return before + * displaying. + * + * Also uses the function get_post_custom() to get the post's 'enclosure' + * metadata field and parses the value to display the enclosure(s). The + * enclosure(s) consist of link HTML tag(s) with a URI and other attributes. + * + * @since 2.2.0 + */ +function atom_enclosure() { + if ( post_password_required() ) + return; + + foreach ( (array) get_post_custom() as $key => $val ) { + if ($key == 'enclosure') { + foreach ( (array) $val as $enc ) { + $enclosure = explode("\n", $enc); + /** + * Filters the atom enclosure HTML link tag for the current post. + * + * @since 2.2.0 + * + * @param string $html_link_tag The HTML link tag with a URI and other attributes. + */ + echo apply_filters( 'atom_enclosure', '' . "\n" ); + } + } + } +} + +/** + * Determine the type of a string of data with the data formatted. + * + * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1. + * + * In the case of WordPress, text is defined as containing no markup, + * xhtml is defined as "well formed", and html as tag soup (i.e., the rest). + * + * Container div tags are added to xhtml values, per section 3.1.1.3. + * + * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1 + * + * @since 2.5.0 + * + * @param string $data Input string + * @return array array(type, value) + */ +function prep_atom_text_construct($data) { + if (strpos($data, '<') === false && strpos($data, '&') === false) { + return array('text', $data); + } + + if ( ! function_exists( 'xml_parser_create' ) ) { + trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); + + return array( 'html', "" ); + } + + $parser = xml_parser_create(); + xml_parse($parser, '
          ' . $data . '
          ', true); + $code = xml_get_error_code($parser); + xml_parser_free($parser); + + if (!$code) { + if (strpos($data, '<') === false) { + return array('text', $data); + } else { + $data = "
          $data
          "; + return array('xhtml', $data); + } + } + + if (strpos($data, ']]>') === false) { + return array('html', ""); + } else { + return array('html', htmlspecialchars($data)); + } +} + +/** + * Displays Site Icon in atom feeds. + * + * @since 4.3.0 + * + * @see get_site_icon_url() + */ +function atom_site_icon() { + $url = get_site_icon_url( 32 ); + if ( $url ) { + echo "$url\n"; + } +} + +/** + * Displays Site Icon in RSS2. + * + * @since 4.3.0 + */ +function rss2_site_icon() { + $rss_title = get_wp_title_rss(); + if ( empty( $rss_title ) ) { + $rss_title = get_bloginfo_rss( 'name' ); + } + + $url = get_site_icon_url( 32 ); + if ( $url ) { + echo ' + + ' . convert_chars( $url ) . ' + ' . $rss_title . ' + ' . get_bloginfo_rss( 'url' ) . ' + 32 + 32 + ' . "\n"; + } +} + +/** + * Display the link for the currently displayed feed in a XSS safe way. + * + * Generate a correct link for the atom:self element. + * + * @since 2.5.0 + */ +function self_link() { + $host = @parse_url(home_url()); + /** + * Filters the current feed URL. + * + * @since 3.6.0 + * + * @see set_url_scheme() + * @see wp_unslash() + * + * @param string $feed_link The link for the feed with set URL scheme. + */ + echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); +} + +/** + * Return the content type for specified feed type. + * + * @since 2.8.0 + * + * @param string $type Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'. + */ +function feed_content_type( $type = '' ) { + if ( empty($type) ) + $type = get_default_feed(); + + $types = array( + 'rss' => 'application/rss+xml', + 'rss2' => 'application/rss+xml', + 'rss-http' => 'text/xml', + 'atom' => 'application/atom+xml', + 'rdf' => 'application/rdf+xml' + ); + + $content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream'; + + /** + * Filters the content type for a specific feed type. + * + * @since 2.8.0 + * + * @param string $content_type Content type indicating the type of data that a feed contains. + * @param string $type Type of feed. Possible values include 'rss', rss2', 'atom', and 'rdf'. + */ + return apply_filters( 'feed_content_type', $content_type, $type ); +} + +/** + * Build SimplePie object based on RSS or Atom feed from URL. + * + * @since 2.8.0 + * + * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged + * using SimplePie's multifeed feature. + * See also {@link ​http://simplepie.org/wiki/faq/typical_multifeed_gotchas} + * + * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success + */ +function fetch_feed( $url ) { + if ( ! class_exists( 'SimplePie', false ) ) { + require_once( ABSPATH . WPINC . '/class-simplepie.php' ); + } + + require_once( ABSPATH . WPINC . '/class-wp-feed-cache.php' ); + require_once( ABSPATH . WPINC . '/class-wp-feed-cache-transient.php' ); + require_once( ABSPATH . WPINC . '/class-wp-simplepie-file.php' ); + require_once( ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php' ); + + $feed = new SimplePie(); + + $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); + // We must manually overwrite $feed->sanitize because SimplePie's + // constructor sets it before we have a chance to set the sanitization class + $feed->sanitize = new WP_SimplePie_Sanitize_KSES(); + + $feed->set_cache_class( 'WP_Feed_Cache' ); + $feed->set_file_class( 'WP_SimplePie_File' ); + + $feed->set_feed_url( $url ); + /** This filter is documented in wp-includes/class-wp-feed-cache-transient.php */ + $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) ); + /** + * Fires just before processing the SimplePie feed object. + * + * @since 3.0.0 + * + * @param object $feed SimplePie feed object (passed by reference). + * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged. + */ + do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); + $feed->init(); + $feed->set_output_encoding( get_option( 'blog_charset' ) ); + + if ( $feed->error() ) + return new WP_Error( 'simplepie-error', $feed->error() ); + + return $feed; +} diff --git a/backend/wp-includes/fonts/dashicons.eot b/backend/wp-includes/fonts/dashicons.eot new file mode 100644 index 0000000..3bdfdc4 Binary files /dev/null and b/backend/wp-includes/fonts/dashicons.eot differ diff --git a/backend/wp-includes/fonts/dashicons.svg b/backend/wp-includes/fonts/dashicons.svg new file mode 100644 index 0000000..45852aa --- /dev/null +++ b/backend/wp-includes/fonts/dashicons.svg @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/wp-includes/fonts/dashicons.ttf b/backend/wp-includes/fonts/dashicons.ttf new file mode 100644 index 0000000..89112fa Binary files /dev/null and b/backend/wp-includes/fonts/dashicons.ttf differ diff --git a/backend/wp-includes/fonts/dashicons.woff b/backend/wp-includes/fonts/dashicons.woff new file mode 100644 index 0000000..a13f9cf Binary files /dev/null and b/backend/wp-includes/fonts/dashicons.woff differ diff --git a/backend/wp-includes/formatting.php b/backend/wp-includes/formatting.php new file mode 100644 index 0000000..d5daaa2 --- /dev/null +++ b/backend/wp-includes/formatting.php @@ -0,0 +1,5410 @@ +', + $open_sq_flag = '', + $apos_flag = ''; + + // If there's nothing to do, just stop. + if ( empty( $text ) || false === $run_texturize ) { + return $text; + } + + // Set up static variables. Run once only. + if ( $reset || ! isset( $static_characters ) ) { + /** + * Filters whether to skip running wptexturize(). + * + * Passing false to the filter will effectively short-circuit wptexturize(). + * returning the original text passed to the function instead. + * + * The filter runs only once, the first time wptexturize() is called. + * + * @since 4.0.0 + * + * @see wptexturize() + * + * @param bool $run_texturize Whether to short-circuit wptexturize(). + */ + $run_texturize = apply_filters( 'run_wptexturize', $run_texturize ); + if ( false === $run_texturize ) { + return $text; + } + + /* translators: opening curly double quote */ + $opening_quote = _x( '“', 'opening curly double quote' ); + /* translators: closing curly double quote */ + $closing_quote = _x( '”', 'closing curly double quote' ); + + /* translators: apostrophe, for example in 'cause or can't */ + $apos = _x( '’', 'apostrophe' ); + + /* translators: prime, for example in 9' (nine feet) */ + $prime = _x( '′', 'prime' ); + /* translators: double prime, for example in 9" (nine inches) */ + $double_prime = _x( '″', 'double prime' ); + + /* translators: opening curly single quote */ + $opening_single_quote = _x( '‘', 'opening curly single quote' ); + /* translators: closing curly single quote */ + $closing_single_quote = _x( '’', 'closing curly single quote' ); + + /* translators: en dash */ + $en_dash = _x( '–', 'en dash' ); + /* translators: em dash */ + $em_dash = _x( '—', 'em dash' ); + + $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); + $default_no_texturize_shortcodes = array('code'); + + // if a plugin has provided an autocorrect array, use it + if ( isset($wp_cockneyreplace) ) { + $cockney = array_keys( $wp_cockneyreplace ); + $cockneyreplace = array_values( $wp_cockneyreplace ); + } else { + /* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, + * for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write + * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. + */ + $cockney = explode( ',', _x( "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", + 'Comma-separated list of words to texturize in your language' ) ); + + $cockneyreplace = explode( ',', _x( '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', + 'Comma-separated list of replacement words in your language' ) ); + } + + $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); + $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); + + + // Pattern-based replacements of characters. + // Sort the remaining patterns into several arrays for performance tuning. + $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); + $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); + $dynamic = array(); + $spaces = wp_spaces_regexp(); + + // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. + if ( "'" !== $apos || "'" !== $closing_single_quote ) { + $dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote; + } + if ( "'" !== $apos || '"' !== $closing_quote ) { + $dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote; + } + + // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. + if ( "'" !== $apos ) { + $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos_flag; + } + + // Quoted Numbers like '0.42' + if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { + $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; + } + + // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. + if ( "'" !== $opening_single_quote ) { + $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; + } + + // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. + if ( "'" !== $apos ) { + $dynamic[ '/(?&/\[\]\x00-\x20=]++)@', $text, $matches ); + $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); + $found_shortcodes = ! empty( $tagnames ); + $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; + $regex = _get_wptexturize_split_regex( $shortcode_regex ); + + $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); + + foreach ( $textarr as &$curl ) { + // Only call _wptexturize_pushpop_element if $curl is a delimiter. + $first = $curl[0]; + if ( '<' === $first ) { + if ( ''; + $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ")/"; + $prime_pattern = "/(?<=\\d)$needle/"; + $flag_after_digit = "/(?<=\\d)$flag/"; + $flag_no_digit = "/(? &$sentence ) { + if ( false === strpos( $sentence, $needle ) ) { + continue; + } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { + $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); + if ( $count > 1 ) { + // This sentence appears to have multiple closing quotes. Attempt Vulcan logic. + $sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); + if ( 0 === $count2 ) { + // Try looking for a quote followed by a period. + $count2 = substr_count( $sentence, "$flag." ); + if ( $count2 > 0 ) { + // Assume the rightmost quote-period match is the end of quotation. + $pos = strrpos( $sentence, "$flag." ); + } else { + // When all else fails, make the rightmost candidate a closing quote. + // This is most likely to be problematic in the context of bug #18549. + $pos = strrpos( $sentence, $flag ); + } + $sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) ); + } + // Use conventional replacement on any remaining primes and quotes. + $sentence = preg_replace( $prime_pattern, $prime, $sentence ); + $sentence = preg_replace( $flag_after_digit, $prime, $sentence ); + $sentence = str_replace( $flag, $close_quote, $sentence ); + } elseif ( 1 == $count ) { + // Found only one closing quote candidate, so give it priority over primes. + $sentence = str_replace( $flag, $close_quote, $sentence ); + $sentence = preg_replace( $prime_pattern, $prime, $sentence ); + } else { + // No closing quotes found. Just run primes pattern. + $sentence = preg_replace( $prime_pattern, $prime, $sentence ); + } + } else { + $sentence = preg_replace( $prime_pattern, $prime, $sentence ); + $sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); + } + if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) { + $sentence = str_replace( '"', $close_quote, $sentence ); + } + } + + return implode( $open_quote, $sentences ); +} + +/** + * Search for disabled element tags. Push element to stack on tag open and pop + * on tag close. + * + * Assumes first char of $text is tag opening and last char is tag closing. + * Assumes second char of $text is optionally '/' to indicate closing as in . + * + * @since 2.9.0 + * @access private + * + * @param string $text Text to check. Must be a tag like `` or `[shortcode]`. + * @param array $stack List of open tag elements. + * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names. + */ +function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { + // Is it an opening tag or closing tag? + if ( isset( $text[1] ) && '/' !== $text[1] ) { + $opening_tag = true; + $name_offset = 1; + } elseif ( 0 == count( $stack ) ) { + // Stack is empty. Just stop. + return; + } else { + $opening_tag = false; + $name_offset = 2; + } + + // Parse out the tag name. + $space = strpos( $text, ' ' ); + if ( false === $space ) { + $space = -1; + } else { + $space -= $name_offset; + } + $tag = substr( $text, $name_offset, $space ); + + // Handle disabled tags. + if ( in_array( $tag, $disabled_elements ) ) { + if ( $opening_tag ) { + /* + * This disables texturize until we find a closing tag of our type + * (e.g.
          ) even if there was invalid nesting before that
          +			 *
          +			 * Example: in the case 
          sadsadasd"baba"
          + * "baba" won't be texturize + */ + + array_push( $stack, $tag ); + } elseif ( end( $stack ) == $tag ) { + array_pop( $stack ); + } + } +} + +/** + * Replaces double line-breaks with paragraph elements. + * + * A group of regex replaces used to identify text formatted with newlines and + * replace double line-breaks with HTML paragraph tags. The remaining line-breaks + * after conversion become <
          > tags, unless $br is set to '0' or 'false'. + * + * @since 0.71 + * + * @param string $pee The text which has to be formatted. + * @param bool $br Optional. If set, this will convert all remaining line-breaks + * after paragraphing. Default true. + * @return string Text which has been converted into correct paragraph tags. + */ +function wpautop( $pee, $br = true ) { + $pre_tags = array(); + + if ( trim($pee) === '' ) + return ''; + + // Just to make things a little easier, pad the end. + $pee = $pee . "\n"; + + /* + * Pre tags shouldn't be touched by autop. + * Replace pre tags with placeholders and bring them back after autop. + */ + if ( strpos($pee, '', $pee ); + $last_pee = array_pop($pee_parts); + $pee = ''; + $i = 0; + + foreach ( $pee_parts as $pee_part ) { + $start = strpos($pee_part, ''; + + $pee .= substr( $pee_part, 0, $start ) . $name; + $i++; + } + + $pee .= $last_pee; + } + // Change multiple
          s into two line breaks, which will turn into paragraphs. + $pee = preg_replace('|\s*|', "\n\n", $pee); + + $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; + + // Add a double line break above block-level opening tags. + $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee); + + // Add a double line break below block-level closing tags. + $pee = preg_replace('!()!', "$1\n\n", $pee); + + // Standardize newline characters to "\n". + $pee = str_replace(array("\r\n", "\r"), "\n", $pee); + + // Find newlines in all elements and add placeholders. + $pee = wp_replace_in_html_tags( $pee, array( "\n" => " " ) ); + + // Collapse line breaks before and after ', $pee ); + } + + /* + * Collapse line breaks inside elements, before and elements + * so they don't get autop'd. + */ + if ( strpos( $pee, '' ) !== false ) { + $pee = preg_replace( '|(]*>)\s*|', '$1', $pee ); + $pee = preg_replace( '|\s*|', '', $pee ); + $pee = preg_replace( '%\s*(]*>)\s*%', '$1', $pee ); + } + + /* + * Collapse line breaks inside
        • "+a+"
          ';for(var b=0;b<10;b++){a+="";for(var c=0;c<10;c++)a+='';a+=""}return a+="
          ",a+=''},y=function(a,b,c,d){var e,f,g,h,i,j=d.getEl().getElementsByTagName("table")[0],k=d.isRtl()||"tl-tr"==d.parent().rel;for(j.nextSibling.innerHTML=b+1+" x "+(c+1),k&&(b=9-b),f=0;f<10;f++)for(e=0;e<10;e++)h=j.rows[f].childNodes[e].firstChild,i=(k?e>=b:e<=b)&&f<=c,a.dom.toggleClass(h,"mce-active",i),i&&(g=h);return g.parentNode},z=i.settings.table_grid===!1?{text:"Table",icon:"table",context:"table",onclick:a.curry(h.open,i)}:{text:"Table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(a){a.aria&&(this.parent().hideAll(),a.stopImmediatePropagation(),h.open(i))},onshow:function(){y(i,0,0,this.menu.items()[0])},onhide:function(){var a=this.menu.items()[0].getEl().getElementsByTagName("a");i.dom.removeClass(a,"mce-active"),i.dom.addClass(a[0],"mce-active")},menu:[{type:"container",html:x(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(a){var b,c,d=a.target;"A"==d.tagName.toUpperCase()&&(b=parseInt(d.getAttribute("data-mce-x"),10),c=parseInt(d.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(b=9-b),b===this.lastX&&c===this.lastY||(y(i,b,c,a.control),this.lastX=b,this.lastY=c))},onclick:function(a){var b=this;"A"==a.target.tagName.toUpperCase()&&(a.preventDefault(),a.stopPropagation(),b.parent().cancel(),i.undoManager.transact(function(){f.insert(i,b.lastX+1,b.lastY+1)}),i.addVisual())}}]},A={text:"Table properties",context:"table",onPostRender:s,onclick:a.curry(h.open,i,!0)},B={text:"Delete table",context:"table",onPostRender:s,cmd:"mceTableDelete"},C={text:"Row",context:"table",menu:[{text:"Insert row before",onclick:k("mceTableInsertRowBefore"),onPostRender:t},{text:"Insert row after",onclick:k("mceTableInsertRowAfter"),onPostRender:t},{text:"Delete row",onclick:k("mceTableDeleteRow"),onPostRender:t},{text:"Row properties",onclick:k("mceTableRowProps"),onPostRender:t},{text:"-"},{text:"Cut row",onclick:k("mceTableCutRow"),onPostRender:t},{text:"Copy row",onclick:k("mceTableCopyRow"),onPostRender:t},{text:"Paste row before",onclick:k("mceTablePasteRowBefore"),onPostRender:t},{text:"Paste row after",onclick:k("mceTablePasteRowAfter"),onPostRender:t}]},D={text:"Column",context:"table",menu:[{text:"Insert column before",onclick:k("mceTableInsertColBefore"),onPostRender:t},{text:"Insert column after",onclick:k("mceTableInsertColAfter"),onPostRender:t},{text:"Delete column",onclick:k("mceTableDeleteCol"),onPostRender:t}]},E={separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:k("mceTableCellProps"),onPostRender:t},{text:"Merge cells",onclick:k("mceTableMergeCells"),onPostRender:u},{text:"Split cell",onclick:k("mceTableSplitCells"),onPostRender:v}]};i.addMenuItem("inserttable",z),i.addMenuItem("tableprops",A),i.addMenuItem("deletetable",B),i.addMenuItem("row",C),i.addMenuItem("column",D),i.addMenuItem("cell",E)};return{addMenuItems:i}}),g("0",["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){function w(i){var w=this,x=function(){return C},y=function(){return D.getOr(c.only(f.fromDom(i.getBody())))},z=r(i,x),A=m(i,y),B=t(i);n.registerCommands(i,A,z,B),k.registerEvents(i,B,A,z),v.addMenuItems(i,B),u.addButtons(i),u.addToolbars(i);var C=b.none(),D=b.none(),E=b.none();i.on("init",function(){var c=d(p.directionAt),f=o.get(i);if(D=b.some(f),i.settings.object_resizing&&i.settings.table_resize_bars!==!1&&(i.settings.object_resizing===!0||"table"===i.settings.object_resizing)){var j=e(f,c);j.on(),j.events.startDrag.bind(function(a){E=b.some(i.selection.getRng())}),j.events.afterResize.bind(function(b){var c=b.table(),d=h.descendants(c,"td[data-mce-style],th[data-mce-style]");a.each(d,function(a){g.remove(a,"data-mce-style")}),E.each(function(a){i.selection.setRng(a),i.focus()}),i.undoManager.add()}),C=b.some(j)}}),i.on("ObjectResized",function(a){var b=a.target;if("TABLE"===b.nodeName){var c=[];j.each(b.rows,function(a){j.each(a.cells,function(a){var b=i.dom.getStyle(a,"width",!0);c.push({cell:a,width:b})})}),j.each(c,function(a){i.dom.setStyle(a.cell,"width",a.width),i.dom.setAttrib(a.cell,"width",null)})}}),i.on("PreInit",function(){i.serializer.addTempAttr(s.firstSelected()),i.serializer.addTempAttr(s.lastSelected())}),i.settings.table_tab_navigation!==!1&&i.on("keydown",function(a){q.handle(a,i,A,y)}),i.on("remove",function(){C.each(function(a){a.destroy()}),D.each(function(a){o.remove(i,a)}),z.destroy()}),w.insertTable=function(a,b){l.insert(i,a,b)},w.setClipboardRows=n.setClipboardRows,w.getClipboardRows=n.getClipboardRows}return i.add("table",w),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/template/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/template/plugin.min.js new file mode 100644 index 0000000..5ff6257 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/template/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0&&(j=l.create("div",null),j.appendChild(k[0].cloneNode(!0))),a.each(l.select("*",j),function(a){h(a,c.getCreationDateClasses(b).replace(/\s+/g,"|"))&&(a.innerHTML=d.getDateTime(b,c.getCdateFormat(b))),h(a,c.getModificationDateClasses(b).replace(/\s+/g,"|"))&&(a.innerHTML=d.getDateTime(b,c.getMdateFormat(b))),h(a,c.getSelectedContentClasses(b).replace(/\s+/g,"|"))&&(a.innerHTML=m)}),g(b,j),b.execCommand("mceInsertContent",!1,j.innerHTML),b.addVisual()};return{createTemplateList:e,replaceTemplateValues:f,replaceVals:g,insertTemplate:i}}),g("2",["6","7"],function(a,b){var c=function(c){c.addCommand("mceInsertTemplate",a.curry(b.insertTemplate,c))};return{register:c}}),g("3",["8","9","a","7"],function(a,b,c,d){var e=function(e){e.on("PreProcess",function(f){var g=e.dom,h=b.getMdateFormat(e);a.each(g.select("div",f.node),function(b){g.hasClass(b,"mceTmpl")&&(a.each(g.select("*",b),function(a){g.hasClass(a,e.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(a.innerHTML=c.getDateTime(e,h))}),d.replaceVals(e,b))})})};return{setup:e}}),g("b",["f","8","e","9","7"],function(a,b,c,d,e){var f=function(a,c,f){if(f.indexOf("")===-1){var g="";b.each(a.contentCSS,function(b){g+=''});var h=a.settings.body_class||"";h.indexOf("=")!==-1&&(h=a.getParam("body_class","","hash"),h=h[a.id]||""),f=""+g+''+f+""}f=e.replaceTemplateValues(a,f,d.getPreviewReplaceValues(a));var i=c.find("iframe")[0].getEl().contentWindow.document;i.open(),i.write(f),i.close()},g=function(a,g){var h,i,j=[];if(!g||0===g.length){var k=a.translate("No templates defined.");return void a.notificationManager.open({text:k,type:"info"})}b.each(g,function(a){j.push({selected:!j.length,text:a.title,value:{url:a.url,content:a.content,description:a.description}})});var l=function(b){var d=b.control.value();d.url?c.send({url:d.url,success:function(b){i=b,f(a,h,i)}}):(i=d.content,f(a,h,i)),h.find("#description")[0].text(b.control.value().description)};h=a.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:j,onselect:l}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){e.insertTemplate(a,!1,i)},minWidth:d.getDialogWidth(a),minHeight:d.getDialogHeight(a)}),h.find("listbox")[0].fire("select")};return{open:g}}),g("4",["7","b"],function(a,b){var c=function(a){return function(c){b.open(a,c)}},d=function(b){b.addButton("template",{title:"Insert template",onclick:a.createTemplateList(b.settings,c(b))}),b.addMenuItem("template",{text:"Template",onclick:a.createTemplateList(b.settings,c(b)),icon:"template",context:"insert"})};return{register:d}}),g("0",["1","2","3","4"],function(a,b,c,d){return a.add("template",function(a){d.register(a),b.register(a),c.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/textcolor/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/textcolor/plugin.min.js new file mode 100644 index 0000000..89b3f62 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/textcolor/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i
          '+(d?"×":"")+"
          ',k=h.length-1,m=0;m",l=0;lk?j+="":(i=h[n],j+=q(i.color,i.text));j+=""}if(g){for(j+='",j+="",l=0;lb.start.length?-1:a.start.length0},e=function(b,e,f,g){var h,i,j=a(b);for(i=0;i0?a.splitText(d):a,a.splitText(c-d+b.end.length),a.deleteData(0,b.start.length),a.deleteData(a.data.length-b.end.length,b.end.length),a},f=function(b,c,e){if(c.collapsed!==!1){var f=c.startContainer,g=f.data,h=e===!0?1:0;if(3===f.nodeType){var i=d.findEndPattern(b,g,c.startOffset,h);if(void 0!==i){var j=g.lastIndexOf(i.end,c.startOffset-h),k=g.lastIndexOf(i.start,j-i.end.length);if(j=g.indexOf(i.end,k+i.start.length),k!==-1){var l=a.createRange();l.setStart(f,k),l.setEnd(f,j+i.end.length);var m=d.findPattern(b,l.toString());if(!(void 0===i||m!==i||f.data.length<=i.start.length+i.end.length))return{pattern:i,startOffset:k,endOffset:j}}}}}},g=function(a,b,d,f){var g=c.isArray(d.pattern.format)?d.pattern.format:[d.pattern.format],h=c.grep(g,function(b){var c=a.formatter.get(b);return c&&c[0].inline});if(0!==h.length)return a.undoManager.transact(function(){b=e(b,d.pattern,d.endOffset,d.startOffset,f),g.forEach(function(c){a.formatter.apply(c,{},b)})}),b},h=function(a,b,c){var d=a.selection.getRng(!0),e=f(b,d,c);if(e)return g(a,d.startContainer,e,c)},i=function(a,b){return h(a,b,!0)},j=function(a,b){return h(a,b,!1)},k=function(a,e){var f,g,h,i,j,k,l,m,n,o,p;if(f=a.selection,g=a.dom,f.isCollapsed()&&(l=g.getParent(f.getStart(),"p"))){for(n=new b(l,l);j=n.next();)if(3===j.nodeType){i=j;break}if(i){if(m=d.findPattern(e,i.data),!m)return;if(o=f.getRng(!0),h=o.startContainer,p=o.startOffset,i===h&&(p=Math.max(0,p-m.start.length)),c.trim(i.data).length===m.start.length)return;m.format&&(k=a.formatter.get(m.format),k&&k[0].block&&(i.deleteData(0,m.start.length),a.formatter.apply(m.format,{},i),o.setStart(h,p),o.collapse(!0),f.setRng(o))),m.cmd&&a.undoManager.transact(function(){i.deleteData(0,m.start.length),a.execCommand(m.cmd)})}}};return{patternFromRng:f,applyInlineFormatSpace:i,applyInlineFormatEnter:j,applyBlockFormat:k}}),g("9",["8","a"],function(a,b){function c(a,c){var d,e;d=b.applyInlineFormatEnter(a,c),d&&(e=a.dom.createRng(),e.setStart(d,d.data.length),e.setEnd(d,d.data.length),a.selection.setRng(e)),b.applyBlockFormat(a,c)}function d(a,c){var d,e,f,g,h;d=b.applyInlineFormatSpace(a,c),d&&(h=a.dom,e=d.data.slice(-1),/[\u00a0 ]/.test(e)&&(d.deleteData(d.data.length-1,1),f=h.doc.createTextNode(e),h.insertAfter(f,d.parentNode),g=h.createRng(),g.setStart(f,1),g.setEnd(f,1),a.selection.setRng(g)))}var e=function(a,b,c){for(var d=0;d=1&&b<=9?b:3};return{getTocClass:a,getTocHeader:b,getTocDepth:c}}),g("b",[],function(){var a=function(a){var b=0;return function(){var c=(new Date).getTime().toString(32);return a+c+(b++).toString(32)}};return{create:a}}),g("7",["8","9","a","3","b"],function(a,b,c,d,e){var f=e.create("mcetoc_"),g=function(a){var b,c=[];for(b=1;b<=a;b++)c.push("h"+b);return c.join(",")},h=function(a){return i(a).length>0},i=function(a){var b=d.getTocClass(a),e=d.getTocHeader(a),h=g(d.getTocDepth(a)),i=a.$(h);return i.length&&/^h[1-9]$/i.test(e)&&(i=i.filter(function(c,d){return!a.dom.hasClass(d.parentNode,b)})),c.map(i,function(b){return{id:b.id?b.id:f(),level:parseInt(b.nodeName.replace(/^H/i,""),10),title:a.$.text(b),element:b}})},j=function(a){var b,c=9;for(b=0;b',e="";return d+a.DOM.encode(c)+e},l=function(a){var b=m(a);return'
          '+b+"
          "},m=function(a){var c,e,f,g,h="",l=i(a),m=j(l)-1;if(!l.length)return"";for(h+=k(d.getTocHeader(a),b.translate("Table of Contents")),c=0;c";else for(e=m;e
        • ";if(h+=''+f.title+"",g!==f.level&&g)for(e=f.level;e>g;e--)h+="
        • ";else h+="
        • ",g||(h+="");m=f.level}return h},n=function(a,b){return!b.length||a.dom.getParents(b[0],".mce-offscreen-selection").length>0},o=function(a){var b=d.getTocClass(a),c=a.$("."+b);n(a,c)?a.insertContent(l(a)):p(a)},p=function(a){var b=d.getTocClass(a),c=a.$("."+b);c.length&&a.undoManager.transact(function(){c.html(m(a))})};return{hasHeaders:h,insertToc:o,updateToc:p}}),g("2",["7"],function(a){var b=function(b){b.addCommand("mceInsertToc",function(){a.insertToc(b)}),b.addCommand("mceUpdateToc",function(){a.updateToc(b)})};return{register:b}}),g("4",["3"],function(a){var b=function(b){var c=b.$,d=a.getTocClass(b);b.on("PreProcess",function(a){var b=c("."+d,a.node);b.length&&(b.removeAttr("contentEditable"),b.find("[contenteditable]").removeAttr("contentEditable"))}),b.on("SetContent",function(){var a=c("."+d);a.length&&(a.attr("contentEditable",!1),a.children(":first-child").attr("contentEditable",!0))})};return{setup:b}}),g("5",["3","7"],function(a,b){var c=function(a){return function(c){var d=c.control;a.on("LoadContent SetContent change",function(){d.disabled(a.readonly||!b.hasHeaders(a))})}},d=function(b){return function(c){return c&&b.dom.is(c,"."+a.getTocClass(b))&&b.getBody().contains(c)}},e=function(a){a.addButton("toc",{tooltip:"Table of Contents",cmd:"mceInsertToc",icon:"toc",onPostRender:c(a)}),a.addButton("tocupdate",{tooltip:"Update",cmd:"mceUpdateToc",icon:"reload"}),a.addMenuItem("toc",{text:"Table of Contents",context:"insert",cmd:"mceInsertToc",onPostRender:c(a)}),a.addContextToolbar(d(a),"tocupdate")};return{register:e}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return a.add("toc",function(a){b.register(a),e.register(a),d.setup(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/visualblocks/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/visualblocks/plugin.min.js new file mode 100644 index 0000000..577b510 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/visualblocks/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("o",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("g",["o"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("p",["c"],function(a){var b=function(b){return''+b+""};return{wrapCharWithSpan:b}}),g("d",["e","f","g","c","p"],function(a,b,c,d,e){var f=function(a){return c.isText(a)&&void 0!==c.value(a)&&d.regExp.test(c.value(a))},g=function(c,d){var e=[],f=c.dom(),h=a.map(f.childNodes,b.fromDom);return a.each(h,function(a){d(a)&&(e=e.concat([a])),e=e.concat(g(a,d))}),e},h=function(a,b){for(;a.parentNode;){if(a.parentNode===b)return a;a=a.parentNode}},i=function(a){return a.replace(d.regExpGlobal,e.wrapCharWithSpan)};return{isMatch:f,filterDescendants:g,findParentElm:h,replaceWithSpans:i}}),g("a",["c","d","e","f","g"],function(a,b,c,d,e){var f=function(a,f){var g,h,i=b.filterDescendants(d.fromDom(f),b.isMatch);c.each(i,function(c){var d=b.replaceWithSpans(e.value(c));for(h=a.dom.create("div",null,d);g=h.lastChild;)a.dom.insertAfter(g,c.dom());a.dom.remove(c.dom())})},g=function(b,d){var e=b.dom.select(a.selector,d);c.each(e,function(a){b.dom.remove(a,1)})},h=function(a){var c=a.getBody(),d=a.selection.getBookmark(),e=b.findParentElm(a.selection.getNode(),c);e=void 0!==e?e:c,g(a,e),f(a,e),a.selection.moveToBookmark(d)};return{show:f,hide:g,toggle:h}}),g("8",["b","a"],function(a,b){var c=function(c,d){var e,f=c.getBody(),g=c.selection;d.set(!d.get()),a.fireVisualChars(c,d.get()),e=g.getBookmark(),d.get()===!0?b.show(c,f):b.hide(c,f),g.moveToBookmark(e)};return{toggleVisualChars:c}}),g("4",["8"],function(a){var b=function(b,c){b.addCommand("mceVisualChars",function(){a.toggleVisualChars(b,c)})};return{register:b}}),g("9",["7"],function(a){return a("tinymce.util.Delay")}),g("5",["9","a"],function(a,b){var c=function(c,d){var e=a.debounce(function(){b.toggle(c)},300);c.settings.forced_root_block!==!1&&c.on("keydown",function(a){d.get()===!0&&(13===a.keyCode?b.toggle(c):e())})};return{setup:c}}),g("6",[],function(){var a=function(a){return function(b){var c=b.control;a.on("VisualChars",function(a){c.active(a.state)})}},b=function(b){b.addButton("visualchars",{active:!1,title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:a(b)}),b.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:a(b),selectable:!0,context:"view",prependToContext:!0})};return{register:b}}),g("0",["1","2","3","4","5","6"],function(a,b,c,d,e,f){return b.add("visualchars",function(b){var g=a(!1);return d.register(b,g),f.register(b),e.setup(b,g),c.get(g)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/plugins/wordcount/plugin.min.js b/frontend/public/static/js/tinymce/js/tinymce/plugins/wordcount/plugin.min.js new file mode 100644 index 0000000..0d0dd93 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/plugins/wordcount/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i]",punctuation:"[!-#%-*,-\\/:;?@\\[-\\]_{}\xa1\xab\xb7\xbb\xbf;\xb7\u055a-\u055f\u0589\u058a\u05be\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1361-\u1368\u1400\u166d\u166e\u169b\u169c\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cd3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205e\u207d\u207e\u208d\u208e\u3008\u3009\u2768-\u2775\u27c5\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc\u29fd\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e2e\u2e30\u2e31\u3001-\u3003\u3008-\u3011\u3014-\u301f\u3030\u303d\u30a0\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uabeb\ufd3e\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a\uff1b\uff1f\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]"},b={ALETTER:0,MIDNUMLET:1,MIDLETTER:2,MIDNUM:3,NUMERIC:4,CR:5,LF:6,NEWLINE:7,EXTEND:8,FORMAT:9,KATAKANA:10,EXTENDNUMLET:11,AT:12,OTHER:13},c=[new RegExp(a.aletter),new RegExp(a.midnumlet),new RegExp(a.midletter),new RegExp(a.midnum),new RegExp(a.numeric),new RegExp(a.cr),new RegExp(a.lf),new RegExp(a.newline),new RegExp(a.extend),new RegExp(a.format),new RegExp(a.katakana),new RegExp(a.extendnumlet),new RegExp("@")],d="",e=new RegExp("^"+a.punctuation+"$"),f=/^\s+$/;return{characterIndices:b,SETS:c,EMPTY_STRING:d,PUNCTUATION:e,WHITESPACE:f}}),g("c",[],function(){var a=function(a,b,c){var d,e;if(!a)return 0;if(c=c||a,void 0!==a.length){for(d=0,e=a.length;da.length-1&&0!==c)&&((f!==b.ALETTER||g!==b.ALETTER)&&(e=a[c+2],(f!==b.ALETTER||g!==b.MIDLETTER&&g!==b.MIDNUMLET&&g!==b.AT||e!==b.ALETTER)&&(d=a[c-1],(f!==b.MIDLETTER&&f!==b.MIDNUMLET&&g!==b.AT||g!==b.ALETTER||d!==b.ALETTER)&&((f!==b.NUMERIC&&f!==b.ALETTER||g!==b.NUMERIC&&g!==b.ALETTER)&&((f!==b.MIDNUM&&f!==b.MIDNUMLET||g!==b.NUMERIC||d!==b.NUMERIC)&&((f!==b.NUMERIC||g!==b.MIDNUM&&g!==b.MIDNUMLET||e!==b.NUMERIC)&&(f!==b.EXTEND&&f!==b.FORMAT&&d!==b.EXTEND&&d!==b.FORMAT&&g!==b.EXTEND&&g!==b.FORMAT&&((f!==b.CR||g!==b.LF)&&(f===b.NEWLINE||f===b.CR||f===b.LF||(g===b.NEWLINE||g===b.CR||g===b.LF||(f!==b.KATAKANA||g!==b.KATAKANA)&&((g!==b.EXTENDNUMLET||f!==b.ALETTER&&f!==b.NUMERIC&&f!==b.KATAKANA&&f!==b.EXTENDNUMLET)&&((f!==b.EXTENDNUMLET||g!==b.ALETTER&&g!==b.NUMERIC&&g!==b.KATAKANA)&&f!==b.AT))))))))))))};return{isWordBoundary:c}}),g("8",["9","a","b"],function(a,b,c){var d=a.EMPTY_STRING,e=a.WHITESPACE,f=a.PUNCTUATION,g=function(a){return"http"===a||"https"===a},h=function(a,b){var c;for(c=b;c + + +Generated by IcoMoon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.ttf b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.ttf new file mode 100644 index 0000000..a983e2d Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.ttf differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.woff b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.woff new file mode 100644 index 0000000..d8962df Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.woff differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.eot b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.eot new file mode 100644 index 0000000..f99c13f Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.eot differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.svg b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.svg new file mode 100644 index 0000000..5727cea --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.svg @@ -0,0 +1,131 @@ + + + +Generated by IcoMoon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.ttf b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.ttf new file mode 100644 index 0000000..16536bf Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.ttf differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.woff b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.woff new file mode 100644 index 0000000..74b50f4 Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.woff differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/anchor.gif b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/anchor.gif new file mode 100644 index 0000000..606348c Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/anchor.gif differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/loader.gif b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/loader.gif new file mode 100644 index 0000000..c69e937 Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/loader.gif differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/object.gif b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/object.gif new file mode 100644 index 0000000..cccd7f0 Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/object.gif differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/trans.gif b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/trans.gif new file mode 100644 index 0000000..3884865 Binary files /dev/null and b/frontend/public/static/js/tinymce/js/tinymce/skins/lightgray/img/trans.gif differ diff --git a/frontend/public/static/js/tinymce/js/tinymce/themes/inlite/theme.min.js b/frontend/public/static/js/tinymce/js/tinymce/themes/inlite/theme.min.js new file mode 100644 index 0000000..1c5d3a0 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/themes/inlite/theme.min.js @@ -0,0 +1,5 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0})},e=function(b,c){var e=function(a){return"string"==typeof a?d(a,/[ ,]/):a},f=function(a,b){return a===!1?[]:b};return a.isArray(b)?b:a.isString(b)?e(b):a.isBoolean(b)?f(b,c):c},f=function(a){return function(c,d,f){var g=d in c.settings?c.settings[d]:f;return b(f,a),e(g,f)}};return{getStringOr:c(a.isString),getBoolOr:c(a.isBoolean),getNumberOr:c(a.isNumber),getHandlerOr:c(a.isFunction),getToolbarItemsOr:f(a.isArray)}}),g("39",["8"],function(a){return a("tinymce.geom.Rect")}),g("i",["39","3a"],function(a,b){var c=function(a,b){return{rect:a,position:b}},d=function(a,b){return{x:b.x,y:b.y,w:a.w,h:a.h}},e=function(b,e,f,g,h){var i,j,k,l={x:g.x,y:g.y,w:g.w+(g.w-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e0&&(a+=" "),a+=this.prefix+this.cls[b];return a},c}),g("2g",["32"],function(a){"use strict";function b(a){for(var b,c=[],d=a.length;d--;)b=a[d],b.__checked||(c.push(b),b.__checked=1);for(d=c.length;d--;)delete c[d].__checked;return c}var c,d=/^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i,e=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,f=/^\s*|\s*$/g,g=a.extend({init:function(a){function b(a){if(a)return a=a.toLowerCase(),function(b){return"*"===a||b.type===a}}function c(a){if(a)return function(b){return b._name===a}}function g(a){if(a)return a=a.split("."),function(b){for(var c=a.length;c--;)if(!b.classes.contains(a[c]))return!1;return!0}}function h(a,b,c){if(a)return function(d){var e=d[a]?d[a]():"";return b?"="===b?e===c:"*="===b?e.indexOf(c)>=0:"~="===b?(" "+e+" ").indexOf(" "+c+" ")>=0:"!="===b?e!=c:"^="===b?0===e.indexOf(c):"$="===b&&e.substr(e.length-c.length)===c:!!c}}function i(a){var b;if(a)return a=/(?:not\((.+)\))|(.+)/i.exec(a),a[1]?(b=k(a[1],[]),function(a){return!l(a,b)}):(a=a[2],function(b,c,d){return"first"===a?0===c:"last"===a?c===d-1:"even"===a?c%2===0:"odd"===a?c%2===1:!!b[a]&&b[a]()})}function j(a,e,j){function k(a){a&&e.push(a)}var l;return l=d.exec(a.replace(f,"")),k(b(l[1])),k(c(l[2])),k(g(l[3])),k(h(l[4],l[5],l[6])),k(i(l[7])),e.pseudo=!!l[7],e.direct=j,e}function k(a,b){var c,d,f,g=[];do if(e.exec(""),d=e.exec(a),d&&(a=d[3],g.push(d[1]),d[2])){c=d[3];break}while(d);for(c&&k(c,b),a=[],f=0;f"!=g[f]&&a.push(j(g[f],[],">"===g[f-1]));return b.push(a),b}var l=this.match;this._selectors=k(a,[])},match:function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;for(b=b||this._selectors,c=0,d=b.length;c=0;e--)for(j=g[e];o;){if(j.pseudo)for(m=o.parent().items(),k=l=m.length;k--&&m[k]!==o;);for(h=0,i=j.length;h1&&(h=b(h))}return c||(c=g.Collection),new c(h)}});return g}),g("u",["e","2g","32"],function(a,b,c){"use strict";var d,e,f=Array.prototype.push,g=Array.prototype.slice;return e={length:0,init:function(a){a&&this.add(a)},add:function(b){var c=this;return a.isArray(b)?f.apply(c,b):b instanceof d?c.add(b.toArray()):f.call(c,b),c},set:function(a){var b,c=this,d=c.length;for(c.length=0,c.add(a),b=c.length;b0}function f(a,b){var c,g;if(a===b)return!0;if(null===a||null===b)return a===b;if("object"!=typeof a||"object"!=typeof b)return a===b;if(d.isArray(b)){if(a.length!==b.length)return!1;for(c=a.length;c--;)if(!f(a[c],b[c]))return!1}if(e(a)||e(b))return a===b;g={};for(c in b){if(!f(a[c],b[c]))return!1;g[c]=!0}for(c in a)if(!g[c]&&!f(a[c],b[c]))return!1;return!0}return b.extend({Mixins:[c],init:function(b){var c,d;b=b||{};for(c in b)d=b[c],d instanceof a&&(b[c]=d.create(this,c));this.data=b},set:function(b,c){var d,e,g=this.data[b];if(c instanceof a&&(c=c.create(this,b)),"object"==typeof b){for(d in b)this.set(d,b[d]);return this}return f(g,c)||(this.data[b]=c,e={target:this,name:b,value:c,oldValue:g},this.fire("change:"+b,e),this.fire("change",e)),this},get:function(a){return this.data[a]},has:function(a){return a in this.data},bind:function(b){return a.create(this,b)},destroy:function(){this.fire("destroy")}})}),g("2b",["1e","2r"],function(a,b){var c,d={};return{add:function(e){var f=e.parent();if(f){if(!f._layout||f._layout.isNative())return;d[f._id]||(d[f._id]=f),c||(c=!0,b.requestAnimationFrame(function(){var a,b;c=!1;for(a in d)b=d[a],b.state.get("rendered")&&b.reflow();d={}},a.body))}},remove:function(a){d[a._id]&&delete d[a._id]}}}),g("10",["1e","31","32","33","e","34","35","u","36","30","2b"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";function l(a){return a._eventDispatcher||(a._eventDispatcher=new d({scope:a,toggleEvent:function(b,c){c&&d.isNative(b)&&(a._nativeEvents||(a._nativeEvents={}),a._nativeEvents[b]=!0,a.state.get("rendered")&&m(a))}})),a._eventDispatcher}function m(a){function c(b){var c=a.getParentCtrl(b.target);c&&c.fire(b.type,b)}function d(){var a=j._lastHoverCtrl;a&&(a.fire("mouseleave",{target:a.getEl()}),a.parents().each(function(a){a.fire("mouseleave",{target:a.getEl()})}),j._lastHoverCtrl=null)}function e(b){var c,d,e,f=a.getParentCtrl(b.target),g=j._lastHoverCtrl,h=0;if(f!==g){if(j._lastHoverCtrl=f,d=f.parents().toArray().reverse(),d.push(f),g){for(e=g.parents().toArray().reverse(),e.push(g),h=0;h=h;c--)g=e[c],g.fire("mouseleave",{target:g.getEl()})}for(c=h;ci.maxW?i.maxW:c,i.w=c,i.innerW=c-d),c=a.h,c!==f&&(c=ci.maxH?i.maxH:c,i.h=c,i.innerH=c-e),c=a.innerW,c!==f&&(c=ci.maxW-d?i.maxW-d:c,i.innerW=c,i.w=c+d),c=a.innerH,c!==f&&(c=ci.maxH-e?i.maxH-e:c,i.innerH=c,i.h=c+e),a.contentW!==f&&(i.contentW=a.contentW),a.contentH!==f&&(i.contentH=a.contentH),b=h._lastLayoutRect,b.x===i.x&&b.y===i.y&&b.w===i.w&&b.h===i.h||(g=n.repaintControls,g&&g.map&&!g.map[h._id]&&(g.push(h),g.map[h._id]=!0),b.x=i.x,b.y=i.y,b.w=i.w,b.h=i.h),h):i},repaint:function(){var b,c,d,e,f,g,h,i,j,k,l=this;j=a.createRange?function(a){return a}:Math.round,b=l.getEl().style,e=l._layoutRect,i=l._lastRepaintRect||{},f=l.borderBox,g=f.left+f.right,h=f.top+f.bottom,e.x!==i.x&&(b.left=j(e.x)+"px",i.x=e.x),e.y!==i.y&&(b.top=j(e.y)+"px",i.y=e.y),e.w!==i.w&&(k=j(e.w-g),b.width=(k>=0?k:0)+"px",i.w=e.w),e.h!==i.h&&(k=j(e.h-h),b.height=(k>=0?k:0)+"px",i.h=e.h),l._hasBody&&e.innerW!==i.innerW&&(k=j(e.innerW),d=l.getEl("body"),d&&(c=d.style,c.width=(k>=0?k:0)+"px"),i.innerW=e.innerW),l._hasBody&&e.innerH!==i.innerH&&(k=j(e.innerH),d=d||l.getEl("body"),d&&(c=c||d.style,c.height=(k>=0?k:0)+"px"),i.innerH=e.innerH),l._lastRepaintRect=i,l.fire("repaint",{},!1)},updateLayoutRect:function(){var a=this;a.parent()._lastRect=null,j.css(a.getEl(),{width:"",height:""}),a._layoutRect=a._lastRepaintRect=a._lastLayoutRect=null,a.initLayoutRect()},on:function(a,b){function c(a){var b,c;return"string"!=typeof a?a:function(e){return b||d.parentsAndSelf().each(function(d){var e=d.settings.callbacks;if(e&&(b=e[a]))return c=d,!1}),b?b.call(c,e):(e.action=a,void this.fire("execute",e))}}var d=this;return l(d).on(a,c(b)),d},off:function(a,b){return l(this).off(a,b),this},fire:function(a,b,c){var d=this;if(b=b||{},b.control||(b.control=d),b=l(d).fire(a,b),c!==!1&&d.parent)for(var e=d.parent();e&&!b.isPropagationStopped();)e.fire(a,b,!1),e=e.parent();return b},hasEventListeners:function(a){return l(this).has(a)},parents:function(a){var b,c=this,d=new h;for(b=c.parent();b;b=b.parent())d.add(b);return a&&(d=d.filter(a)),d},parentsAndSelf:function(a){return new h(this).add(this.parents(a))},next:function(){var a=this.parent().items();return a[a.indexOf(this)+1]},prev:function(){var a=this.parent().items();return a[a.indexOf(this)-1]},innerHtml:function(a){return this.$el.html(a),this},getEl:function(a){var c=a?this._id+"-"+a:this._id;return this._elmCache[c]||(this._elmCache[c]=b("#"+c)[0]),this._elmCache[c]},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(a){}return this},blur:function(){return this.getEl().blur(),this},aria:function(a,b){var c=this,d=c.getEl(c.ariaTarget);return"undefined"==typeof b?c._aria[a]:(c._aria[a]=b,c.state.get("rendered")&&d.setAttribute("role"==a?a:"aria-"+a,b),c)},encode:function(a,b){return b!==!1&&(a=this.translate(a)),(a||"").replace(/[&<>"]/g,function(a){return"&#"+a.charCodeAt(0)+";"})},translate:function(a){return n.translate?n.translate(a):a},before:function(a){var b=this,c=b.parent();return c&&c.insert(a,c.items().indexOf(b),!0),b},after:function(a){var b=this,c=b.parent();return c&&c.insert(a,c.items().indexOf(b)),b},remove:function(){var a,c,d=this,e=d.getEl(),f=d.parent();if(d.items){var g=d.items().toArray();for(c=g.length;c--;)g[c].remove()}f&&f.items&&(a=[],f.items().each(function(b){b!==d&&a.push(b)}),f.items().set(a),f._lastRect=null),d._eventsRoot&&d._eventsRoot==d&&b(e).off();var h=d.getRoot().controlIdLookup;return h&&delete h[d._id],e&&e.parentNode&&e.parentNode.removeChild(e),d.state.set("rendered",!1),d.state.destroy(),d.fire("remove"),d},renderBefore:function(a){return b(a).before(this.renderHtml()),this.postRender(),this},renderTo:function(a){return b(a||this.getContainerElm()).append(this.renderHtml()),this.postRender(),this},preRender:function(){},render:function(){},renderHtml:function(){return'
          '},postRender:function(){var a,c,d,e,f,g=this,h=g.settings;g.$el=b(g.getEl()),g.state.set("rendered",!0);for(e in h)0===e.indexOf("on")&&g.on(e.substr(2),h[e]);if(g._eventsRoot){for(d=g.parent();!f&&d;d=d.parent())f=d._eventsRoot;if(f)for(e in f._nativeEvents)g._nativeEvents[e]=!0}m(g),h.style&&(a=g.getEl(),a&&(a.setAttribute("style",h.style),a.style.cssText=h.style)),g.settings.border&&(c=g.borderBox,g.$el.css({"border-top-width":c.top,"border-right-width":c.right,"border-bottom-width":c.bottom,"border-left-width":c.left}));var i=g.getRoot();i.controlIdLookup||(i.controlIdLookup={}),i.controlIdLookup[g._id]=g;for(var j in g._aria)g.aria(j,g._aria[j]);g.state.get("visible")===!1&&(g.getEl().style.display="none"),g.bindStates(),g.state.on("change:visible",function(a){var b,c=a.value;g.state.get("rendered")&&(g.getEl().style.display=c===!1?"none":"",g.getEl().getBoundingClientRect()),b=g.parent(),b&&(b._lastRect=null),g.fire(c?"show":"hide"),k.add(g)}),g.fire("postrender",{},!1)},bindStates:function(){},scrollIntoView:function(a){function b(a,b){var c,d,e=a;for(c=d=0;e&&e!=b&&e.nodeType;)c+=e.offsetLeft||0,d+=e.offsetTop||0,e=e.offsetParent;return{x:c,y:d}}var c,d,e,f,g,h,i=this.getEl(),j=i.parentNode,k=b(i,j);return c=k.x,d=k.y,e=i.offsetWidth,f=i.offsetHeight,g=j.clientWidth,h=j.clientHeight,"end"==a?(c-=g-e,d-=h-f):"center"==a&&(c-=g/2-e/2,d-=h/2-f/2),j.scrollLeft=c,j.scrollTop=d,this},getRoot:function(){for(var a,b=this,c=[];b;){if(b.rootControl){a=b.rootControl;break}c.push(b),a=b,b=b.parent()}a||(a=this);for(var d=c.length;d--;)c[d].rootControl=a;return a},reflow:function(){k.remove(this);var a=this.parent();return a&&a._layout&&!a._layout.isNative()&&a.reflow(),this}};return e.each("text title visible disabled active value".split(" "),function(a){s[a]=function(b){return 0===arguments.length?this.state.get(a):("undefined"!=typeof b&&this.state.set(a,b),this)}}),n=c.extend(s)}),g("24",["1e","1","30"],function(a,b,c){"use strict";function d(b,d,e){var f,g,h,i,j,k,l,m,n,o;return n=c.getViewPort(),g=c.getPos(d),h=g.x,i=g.y,b.state.get("fixed")&&"static"==c.getRuntimeStyle(a.body,"position")&&(h-=n.x,i-=n.y),f=b.getEl(),o=c.getSize(f),j=o.width,k=o.height,o=c.getSize(d),l=o.width,m=o.height,e=(e||"").split(""),"b"===e[0]&&(i+=m),"r"===e[1]&&(h+=l),"c"===e[0]&&(i+=Math.round(m/2)),"c"===e[1]&&(h+=Math.round(l/2)),"b"===e[3]&&(i-=k),"r"===e[4]&&(h-=j), +"c"===e[3]&&(i-=Math.round(k/2)),"c"===e[4]&&(h-=Math.round(j/2)),{x:h,y:i,w:j,h:k}}return{testMoveRel:function(a,b){for(var e=c.getViewPort(),f=0;f0&&g.x+g.w0&&g.y+g.he.x&&g.x+g.we.y&&g.y+g.hb?(a=b-c,a<0?0:a):a}var f=this;if(f.settings.constrainToViewport){var g=c.getViewPort(b),h=f.layoutRect();a=e(a,g.w+g.x,h.w),d=e(d,g.h+g.y,h.h)}return f.state.get("rendered")?f.layoutRect({x:a,y:d}).repaint():(f.settings.x=a,f.settings.y=d),f.fire("move",{x:a,y:d}),f}}}),g("2p",["10","24"],function(a,b){return a.extend({Mixins:[b],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var a=this,b=a.classPrefix;return'"},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl().lastChild.innerHTML=a.encode(b.value)}),a._super()},repaint:function(){var a,b,c=this;a=c.getEl().style,b=c._layoutRect,a.left=b.x+"px",a.top=b.y+"px",a.zIndex=131070}})}),g("1h",["10","2p"],function(a,b){"use strict";var c,d=a.extend({init:function(a){var b=this;b._super(a),a=b.settings,b.canFocus=!0,a.tooltip&&d.tooltips!==!1&&(b.on("mouseenter",function(c){var d=b.tooltip().moveTo(-65535);if(c.control==b){var e=d.text(a.tooltip).show().testMoveRel(b.getEl(),["bc-tc","bc-tl","bc-tr"]);d.classes.toggle("tooltip-n","bc-tc"==e),d.classes.toggle("tooltip-nw","bc-tl"==e),d.classes.toggle("tooltip-ne","bc-tr"==e),d.moveRel(b.getEl(),e)}else d.hide()}),b.on("mouseleave mousedown click",function(){b.tooltip().hide()})),b.aria("label",a.ariaLabel||a.tooltip)},tooltip:function(){return c||(c=new b({type:"tooltip"}),c.renderTo()),c},postRender:function(){var a=this,b=a.settings;a._super(),a.parent()||!b.width&&!b.height||(a.initLayoutRect(),a.repaint()),b.autofocus&&a.focus()},bindStates:function(){function a(a){c.aria("disabled",a),c.classes.toggle("disabled",a)}function b(a){c.aria("pressed",a),c.classes.toggle("active",a)}var c=this;return c.state.on("change:disabled",function(b){a(b.value)}),c.state.on("change:active",function(a){b(a.value)}),c.state.get("disabled")&&a(!0),c.state.get("active")&&b(!0),c._super()},remove:function(){this._super(),c&&(c.remove(),c=null)}});return d}),g("29",["1h"],function(a){"use strict";return a.extend({Defaults:{value:0},init:function(a){var b=this;b._super(a),b.classes.add("progress"),b.settings.filter||(b.settings.filter=function(a){return Math.round(a)})},renderHtml:function(){var a=this,b=a._id,c=this.classPrefix;return'
          0%
          '},postRender:function(){var a=this;return a._super(),a.value(a.settings.value),a},bindStates:function(){function a(a){a=b.settings.filter(a),b.getEl().lastChild.innerHTML=a+"%",b.getEl().firstChild.firstChild.style.width=a+"%"}var b=this;return b.state.on("change:value",function(b){a(b.value)}),a(b.state.get("value")),b._super()}})}),g("25",["10","24","29","2r"],function(a,b,c,d){var e=function(a,b){a.getEl().lastChild.textContent=b+(a.progressBar?" "+a.progressBar.value()+"%":"")};return a.extend({Mixins:[b],Defaults:{classes:"widget notification"},init:function(a){var b=this;b._super(a),b.maxWidth=a.maxWidth,a.text&&b.text(a.text),a.icon&&(b.icon=a.icon),a.color&&(b.color=a.color),a.type&&b.classes.add("notification-"+a.type),a.timeout&&(a.timeout<0||a.timeout>0)&&!a.closeButton?b.closeButton=!1:(b.classes.add("has-close"),b.closeButton=!0),a.progressBar&&(b.progressBar=new c),b.on("click",function(a){a.target.className.indexOf(b.classPrefix+"close")!=-1&&b.close()})},renderHtml:function(){var a=this,b=a.classPrefix,c="",d="",e="",f="";return a.icon&&(c=''),f=' style="max-width: '+a.maxWidth+"px;"+(a.color?"background-color: "+a.color+';"':'"'),a.closeButton&&(d=''),a.progressBar&&(e=a.progressBar.renderHtml()),''},postRender:function(){var a=this;return d.setTimeout(function(){a.$el.addClass(a.classPrefix+"in"),e(a,a.state.get("text"))},100),a._super()},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl().firstChild.innerHTML=b.value,e(a,b.value)}),a.progressBar&&(a.progressBar.bindStates(),a.progressBar.state.on("change:value",function(b){e(a,a.state.get("text"))})),a._super()},close:function(){var a=this;return a.fire("close").isDefaultPrevented()||a.remove(),a},repaint:function(){var a,b,c=this;a=c.getEl().style,b=c._layoutRect,a.left=b.x+"px",a.top=b.y+"px",a.zIndex=65534}})}),g("a",["2y","2z","e","30","25"],function(a,b,c,d,e){return function(f){var g=function(a){return a.inline?a.getElement():a.getContentAreaContainer()},h=function(){var a=g(f);return d.getSize(a).width},i=function(b){a.each(b,function(a){a.moveTo(0,0)})},j=function(b){if(b.length>0){var c=b.slice(0,1)[0],d=g(f);c.moveRel(d,"tc-tc"),a.each(b,function(a,c){c>0&&a.moveRel(b[c-1].getEl(),"bc-tc")})}},k=function(a){i(a),j(a)},l=function(a,d){var f=c.extend(a,{maxWidth:h()}),g=new e(f);return g.args=f,f.timeout>0&&(g.timer=b(function(){g.close(),d()},f.timeout)),g.on("close",function(){d()}),g.renderTo(),g},m=function(a){a.close()},n=function(a){return a.args};return{open:l,close:m,reposition:k,getArgs:n}}}),g("11",["1e","1","31"],function(a,b,c){"use strict";function d(a){var b,c,d,e,f,g,h,i,j=Math.max;return b=a.documentElement,c=a.body,d=j(b.scrollWidth,c.scrollWidth),e=j(b.clientWidth,c.clientWidth),f=j(b.offsetWidth,c.offsetWidth),g=j(b.scrollHeight,c.scrollHeight),h=j(b.clientHeight,c.clientHeight),i=j(b.offsetHeight,c.offsetHeight),{width:d").css({position:"absolute",top:0,left:0,width:q.width,height:q.height,zIndex:2147483647,opacity:1e-4,cursor:k}).appendTo(p.body),c(p).on("mousemove touchmove",m).on("mouseup touchend",l),g.start(a)},m=function(a){return e(a),a.button!==j?l(a):(a.deltaX=a.screenX-n,a.deltaY=a.screenY-o,a.preventDefault(),void g.drag(a))},l=function(a){e(a),c(p).off("mousemove touchmove",m).off("mouseup touchend",l),i.remove(),g.stop&&g.stop(a)},this.destroy=function(){c(h()).off()},c(h()).on("mousedown touchstart",k)}}),g("d",["8"],function(a){return a("tinymce.ui.Factory")}),g("1v",["1e"],function(a){"use strict";var b=function(a){return!!a.getAttribute("data-mce-tabstop")};return function(c){function d(a){return a&&1===a.nodeType}function e(a){return a=a||v,d(a)?a.getAttribute("role"):null}function f(a){for(var b,c=a||v;c=c.parentNode;)if(b=e(c))return b}function g(a){var b=v;if(d(b))return b.getAttribute("aria-"+a)}function h(a){var b=a.tagName.toUpperCase();return"INPUT"==b||"TEXTAREA"==b||"SELECT"==b}function i(a){return!(!h(a)||a.hidden)||(!!b(a)||!!/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(e(a)))}function j(a){function b(a){if(1==a.nodeType&&"none"!=a.style.display&&!a.disabled){i(a)&&c.push(a);for(var d=0;d=b.length&&(a=0),b[a]&&b[a].focus(),a}function n(a,b){var c=-1,d=k();b=b||j(d.getEl());for(var e=0;e=0&&(c=b.getEl(),c&&c.parentNode.removeChild(c),c=a.getEl(),c&&c.parentNode.removeChild(c)),b.parent(this)},create:function(b){var c,e=this,g=[];return f.isArray(b)||(b=[b]),f.each(b,function(b){b&&(b instanceof a||("string"==typeof b&&(b={type:b}),c=f.extend({},e.settings.defaults,b),b.type=c.type=c.type||b.type||e.settings.defaultType||(c.defaults?c.defaults.type:null),b=d.create(c)),g.push(b))}),g},renderNew:function(){var a=this;return a.items().each(function(b,c){var d;b.parent(a),b.state.get("rendered")||(d=a.getEl("body"),d.hasChildNodes()&&c<=d.childNodes.length-1?g(d.childNodes[c]).before(b.renderHtml()):g(d).append(b.renderHtml()),b.postRender(),i.add(b))}),a._layout.applyClasses(a.items().filter(":visible")),a._lastRect=null,a},append:function(a){return this.add(a).renderNew()},prepend:function(a){var b=this;return b.items().set(b.create(a).concat(b.items().toArray())),b.renderNew()},insert:function(a,b,c){var d,e,f,g=this;return a=g.create(a),d=g.items(),!c&&b=0&&b
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "},postRender:function(){var a,b=this;return b.items().exec("postRender"),b._super(),b._layout.postRender(b),b.state.set("rendered",!0),b.settings.style&&b.$el.css(b.settings.style),b.settings.border&&(a=b.borderBox,b.$el.css({"border-top-width":a.top,"border-right-width":a.right,"border-bottom-width":a.bottom,"border-left-width":a.left})),b.parent()||(b.keyboardNav=new e({root:b})),b},initLayoutRect:function(){var a=this,b=a._super();return a._layout.recalc(a),b},recalc:function(){var a=this,b=a._layoutRect,c=a._lastRect;if(!c||c.w!=b.w||c.h!=b.h)return a._layout.recalc(a),b=a.layoutRect(),a._lastRect={x:b.x,y:b.y,w:b.w,h:b.h},!0},reflow:function(){var b;if(i.remove(this),this.visible()){for(a.repaintControls=[],a.repaintControls.map={},this.recalc(),b=a.repaintControls.length;b--;)a.repaintControls[b].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),a.repaintControls=[]}return this}})}),g("2e",["31","11"],function(a,b){"use strict";return{init:function(){var a=this;a.on("repaint",a.renderScroll)},renderScroll:function(){function c(){function b(b,g,h,i,j,k){var l,m,n,o,p,q,r,s,t;if(m=e.getEl("scroll"+b)){if(s=g.toLowerCase(),t=h.toLowerCase(),a(e.getEl("absend")).css(s,e.layoutRect()[i]-1),!j)return void a(m).css("display","none");a(m).css("display","block"),l=e.getEl("body"),n=e.getEl("scroll"+b+"t"),o=l["client"+h]-2*f,o-=c&&d?m["client"+k]:0,p=l["scroll"+h],q=o/p,r={},r[s]=l["offset"+g]+f,r[t]=o,a(m).css(r),r={},r[s]=l["scroll"+g]*q,r[t]=o*q,a(n).css(r)}}var c,d,g;g=e.getEl("body"),c=g.scrollWidth>g.clientWidth,d=g.scrollHeight>g.clientHeight,b("h","Left","Width","contentW",c,"Height"),b("v","Top","Height","contentH",d,"Width")}function d(){function c(c,d,g,h,i){var j,k=e._id+"-scroll"+c,l=e.classPrefix;a(e.getEl()).append('
          '),e.draghelper=new b(k+"t",{start:function(){j=e.getEl("body")["scroll"+d],a("#"+k).addClass(l+"active")},drag:function(a){var b,k,l,m,n=e.layoutRect();k=n.contentW>n.innerW,l=n.contentH>n.innerH,m=e.getEl("body")["client"+g]-2*f,m-=k&&l?e.getEl("scroll"+c)["client"+i]:0,b=m/e.getEl("body")["scroll"+g],e.getEl("body")["scroll"+d]=j+a["delta"+h]/b},stop:function(){a("#"+k).removeClass(l+"active")}})}e.classes.add("scroll"),c("v","Top","Height","Y","Width"),c("h","Left","Width","X","Height")}var e=this,f=2;e.settings.autoScroll&&(e._hasScroll||(e._hasScroll=!0,d(),e.on("wheel",function(a){var b=e.getEl("body");b.scrollLeft+=10*(a.deltaX||0),b.scrollTop+=10*a.deltaY,c()}),a(e.getEl("body")).on("scroll",c)),c())}}}),g("26",["z","2e"],function(a,b){"use strict";return a.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[b],renderHtml:function(){var a=this,b=a._layout,c=a.settings.html;return a.preRender(),b.preRender(a),"undefined"==typeof c?c='
          '+b.renderHtml(a)+"
          ":("function"==typeof c&&(c=c.call(a)),a._hasBody=!1),'
          '+(a._preBodyHtml||"")+c+"
          "}})}),g("2c",["30"],function(a){"use strict";return{resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(b,c){if(b<=1||c<=1){var d=a.getWindowSize();b=b<=1?b*d.w:b,c=c<=1?c*d.h:c}return this._layoutRect.autoResize=!1,this.layoutRect({minW:b,minH:c,w:b,h:c}).reflow()},resizeBy:function(a,b){var c=this,d=c.layoutRect();return c.resizeTo(d.w+a,d.h+b)}}}),g("18",["1e","1","31","2r","30","24","26","2c"],function(a,b,c,d,e,f,g,h){"use strict";function i(a,b){for(;a;){if(a==b)return!0;a=a.parent()}}function j(a){for(var b=u.length;b--;){var c=u[b],d=c.getParentCtrl(a.target);if(c.settings.autohide){if(d&&(i(d,c)||c.parent()===d))continue;a=c.fire("autohide",{target:a.target}),a.isDefaultPrevented()||c.hide()}}}function k(){q||(q=function(a){2!=a.button&&j(a)},c(a).on("click touchstart",q))}function l(){r||(r=function(){var a;for(a=u.length;a--;)n(u[a])},c(b).on("scroll",r))}function m(){if(!s){var d=a.documentElement,e=d.clientWidth,f=d.clientHeight;s=function(){a.all&&e==d.clientWidth&&f==d.clientHeight||(e=d.clientWidth,f=d.clientHeight,w.hideAll())},c(b).on("resize",s)}}function n(a){function b(b,c){for(var d,e=0;ec&&(a.fixed(!1).layoutRect({y:a._autoFixY}).repaint(),b(!1,a._autoFixY-c)):(a._autoFixY=a.layoutRect().y,a._autoFixY').appendTo(b.getContainerElm())),d.setTimeout(function(){e.addClass(f+"in"),c(b.getEl()).addClass(f+"in")}),t=!0),o(!0,b)}}),b.on("show",function(){b.parents().each(function(a){if(a.state.get("fixed"))return b.fixed(!0),!1})}),a.popover&&(b._preBodyHtml='
          ',b.classes.add("popover").add("bottom").add(b.isRtl()?"end":"start")),b.aria("label",a.ariaLabel),b.aria("labelledby",b._id),b.aria("describedby",b.describedBy||b._id+"-none")},fixed:function(a){var b=this;if(b.state.get("fixed")!=a){if(b.state.get("rendered")){var c=e.getViewPort();a?b.layoutRect().y-=c.y:b.layoutRect().y+=c.y}b.classes.toggle("fixed",a),b.state.set("fixed",a)}return b},show:function(){var a,b=this,c=b._super();for(a=u.length;a--&&u[a]!==b;);return a===-1&&u.push(b),c},hide:function(){return p(this),o(!1,this),this._super()},hideAll:function(){w.hideAll()},close:function(){var a=this;return a.fire("close").isDefaultPrevented()||(a.remove(),o(!1,a)),a},remove:function(){p(this),this._super()},postRender:function(){var a=this;return a.settings.bodyRole&&this.getEl("body").setAttribute("role",a.settings.bodyRole),a._super()}});return w.hideAll=function(){for(var a=u.length;a--;){var b=u[a];b&&b.settings.autohide&&(b.hide(),u.splice(a,1))}},w}),g("2q",["1e","2z","1","31","1g","2r","34","30","11","18","26"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";function l(b){var c,f="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0",g=d("meta[name=viewport]")[0];e.overrideViewPort!==!1&&(g||(g=a.createElement("meta"),g.setAttribute("name","viewport"),a.getElementsByTagName("head")[0].appendChild(g)),c=g.getAttribute("content"),c&&"undefined"!=typeof q&&(q=c),g.setAttribute("content",b?f:q))}function m(b,c){n()&&c===!1&&d([a.documentElement,a.body]).removeClass(b+"fullscreen")}function n(){for(var a=0;aa.w&&(c=a.x-Math.max(0,b/2),e.layoutRect({w:b,x:c}),d=!0)),f&&(f.layoutRect({w:e.layoutRect().innerW}).recalc(),b=f.layoutRect().minW+a.deltaW,b>a.w&&(c=a.x-Math.max(0,b-a.w),e.layoutRect({w:b,x:c}),d=!0)),d&&e.recalc()},initLayoutRect:function(){var a,b=this,c=b._super(),d=0;if(b.settings.title&&!b._fullscreen){a=b.getEl("head");var e=h.getSize(a);c.headerW=e.width,c.headerH=e.height,d+=c.headerH}b.statusbar&&(d+=b.statusbar.layoutRect().h),c.deltaH+=d,c.minH+=d,c.h+=d;var f=h.getWindowSize();return c.x=b.settings.x||Math.max(0,f.w/2-c.w/2),c.y=b.settings.y||Math.max(0,f.h/2-c.h/2),c},renderHtml:function(){var a=this,b=a._layout,c=a._id,d=a.classPrefix,e=a.settings,f="",g="",h=e.html;return a.preRender(),b.preRender(a),e.title&&(f='
          '+a.encode(e.title)+'
          '),e.url&&(h=''),"undefined"==typeof h&&(h=b.renderHtml(a)),a.statusbar&&(g=a.statusbar.renderHtml()),'
          '+f+'
          '+h+"
          "+g+"
          "},fullscreen:function(b){var e,i,j=this,k=a.documentElement,l=j.classPrefix;if(b!=j._fullscreen)if(d(c).on("resize",function(){var a;if(j._fullscreen)if(e)j._timer||(j._timer=f.setTimeout(function(){var a=h.getWindowSize();j.moveTo(0,0).resizeTo(a.w,a.h),j._timer=0},50));else{a=(new Date).getTime();var b=h.getWindowSize();j.moveTo(0,0).resizeTo(b.w,b.h),(new Date).getTime()-a>50&&(e=!0)}}),i=j.layoutRect(),j._fullscreen=b,b){j._initial={x:i.x,y:i.y,w:i.w,h:i.h},j.borderBox=g.parseBox("0"),j.getEl("head").style.display="none",i.deltaH-=i.headerH+2,d([k,a.body]).addClass(l+"fullscreen"),j.classes.add("fullscreen");var m=h.getWindowSize();j.moveTo(0,0).resizeTo(m.w,m.h)}else j.borderBox=g.parseBox(j.settings.border),j.getEl("head").style.display="",i.deltaH+=i.headerH,d([k,a.body]).removeClass(l+"fullscreen"),j.classes.remove("fullscreen"),j.moveTo(j._initial.x,j._initial.y).resizeTo(j._initial.w,j._initial.h);return j.reflow()},postRender:function(){var a,c=this;b(function(){c.classes.add("in"),c.fire("open")},0),c._super(),c.statusbar&&c.statusbar.postRender(),c.focus(),this.dragHelper=new i(c._id+"-dragh",{start:function(){a={x:c.layoutRect().x,y:c.layoutRect().y}},drag:function(b){c.moveTo(a.x+b.deltaX,a.y+b.deltaY)}}),c.on("submit",function(a){a.isDefaultPrevented()||c.close()}),p.push(c),l(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var a,b=this;for(b.dragHelper.destroy(),b._super(),b.statusbar&&this.statusbar.remove(),m(b.classPrefix,!1),a=p.length;a--;)p[a]===b&&p.splice(a,1);l(p.length>0)},getContentWindow:function(){var a=this.getEl().getElementsByTagName("iframe")[0];return a?a.contentWindow:null}});return o(),r}),g("23",["1e","2q"],function(a,b){"use strict";var c=b.extend({init:function(a){a={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}},this._super(a)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(d){function e(a,b,c){return{type:"button",text:a,subtype:c?"primary":"",onClick:function(a){a.control.parents()[1].close(),g(b)}}}var f,g=d.callback||function(){};switch(d.buttons){case c.OK_CANCEL:f=[e("Ok",!0,!0),e("Cancel",!1)];break;case c.YES_NO:case c.YES_NO_CANCEL:f=[e("Yes",1,!0),e("No",0)],d.buttons==c.YES_NO_CANCEL&&f.push(e("Cancel",-1));break;default:f=[e("Ok",!0,!0)]}return new b({padding:20,x:d.x,y:d.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:f,title:d.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:d.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:d.onClose,onCancel:function(){g(!1)}}).renderTo(a.body).reflow()},alert:function(a,b){return"string"==typeof a&&(a={text:a}),a.callback=b,c.msgBox(a)},confirm:function(a,b){return"string"==typeof a&&(a={text:a}),a.callback=b,a.buttons=c.OK_CANCEL,c.msgBox(a)}}});return c}),g("b",["2q","23"],function(a,b){return function(c){var d=function(b,c,d){var e;return b.title=b.title||" ",b.url=b.url||b.file,b.url&&(b.width=parseInt(b.width||320,10),b.height=parseInt(b.height||240,10)),b.body&&(b.items={defaults:b.defaults,type:b.bodyType||"form",items:b.body,data:b.data,callbacks:b.commands}),b.url||b.buttons||(b.buttons=[{text:"Ok",subtype:"primary",onclick:function(){e.find("form")[0].submit()}},{text:"Cancel",onclick:function(){e.close()}}]),e=new a(b),e.on("close",function(){d(e)}),b.data&&e.on("postRender",function(){this.find("*").each(function(a){var c=a.name();c in b.data&&a.value(b.data[c])})}),e.features=b||{},e.params=c||{},e=e.renderTo().reflow()},e=function(a,c,d){var e;return e=b.alert(a,function(){c()}),e.on("close",function(){d(e)}),e},f=function(a,c,d){var e;return e=b.confirm(a,function(a){c(a)}),e.on("close",function(){d(e)}),e},g=function(a){a.close()},h=function(a){return a.params},i=function(a,b){a.params=b};return{open:d,alert:e,confirm:f,close:g,getParams:h,setParams:i}}}),g("3",["9","a","b"],function(a,b,c){var d=function(d,e){var f=function(){return a.renderUI(d,e)};return{renderUI:f,getNotificationManagerImpl:function(){return b(d)},getWindowManagerImpl:function(){return c(d)}}};return{get:d}}),g("f",["37","1g","c"],function(a,b,c){var d=function(){var d=b.container;if(d&&"static"!==c.DOM.getStyle(d,"position",!0)){var e=c.DOM.getPos(d),f=e.x-d.scrollLeft,g=e.y-d.scrollTop;return a.some({x:f,y:g})}return a.none()};return{getUiContainerDelta:d}}),g("3b",["8"],function(a){return a("tinymce.util.Promise")}),g("3c",[],function(){var a=0,b=function(){var a=function(){return Math.round(4294967295*Math.random()).toString(36)};return"s"+Date.now().toString(36)+a()+a()+a()},c=function(c){return c+a++ +b()};return{uuid:c}}),g("3x",[],function(){var a=function(a,b){function c(c){var e,f,g;f=b[c?"startContainer":"endContainer"],g=b[c?"startOffset":"endOffset"],1==f.nodeType&&(e=a.create("span",{"data-mce-type":"bookmark"}),f.hasChildNodes()?(g=Math.min(g,f.childNodes.length-1),c?f.insertBefore(e,f.childNodes[g]):a.insertAfter(e,f.childNodes[g])):f.appendChild(e),f=e,g=0),d[c?"startContainer":"endContainer"]=f,d[c?"startOffset":"endOffset"]=g}var d={};return c(!0),b.collapsed||c(),d},b=function(a,b){function c(c){function d(a){for(var b=a.parentNode.firstChild,c=0;b;){if(b==a)return c;1==b.nodeType&&"bookmark"==b.getAttribute("data-mce-type")||c++,b=b.nextSibling}return-1}var e,f,g;e=g=b[c?"startContainer":"endContainer"],f=b[c?"startOffset":"endOffset"],e&&(1==e.nodeType&&(f=d(e),e=e.parentNode,a.remove(g)),b[c?"startContainer":"endContainer"]=e,b[c?"startOffset":"endOffset"]=f)}c(!0),c();var d=a.createRng();return d.setStart(b.startContainer,b.startOffset),b.endContainer&&d.setEnd(b.endContainer,b.endOffset),d};return{create:a,resolve:b}}),g("3y",["8"],function(a){return a("tinymce.dom.TreeWalker")}),g("3z",["8"],function(a){return a("tinymce.dom.RangeUtils")}),g("3d",["3x","e","3y","3z"],function(a,b,c,d){var e=function(a,b,d){var e,f,g=[];for(e=new c(b,a),f=b;f&&(1===f.nodeType&&g.push(f),f!==d);f=e.next());return g},f=function(c,d){var e,f,g;f=c.dom,g=c.selection,e=a.create(f,g.getRng()),b.each(d,function(a){c.dom.remove(a,!0)}),g.setRng(a.resolve(f,e))},g=function(a){return"A"===a.nodeName&&a.hasAttribute("href")},h=function(a,b){var c=a.getParent(b,g);return c?c:b},i=function(a){var c,f,i,j,k,l,m;return k=a.selection,l=a.dom,m=k.getRng(),c=h(l,d.getNode(m.startContainer,m.startOffset)),f=d.getNode(m.endContainer,m.endOffset),i=a.getBody(),j=b.grep(e(i,c,f),g)},j=function(a){f(a,i(a))};return{unlinkSelection:j}}),g("o",["3c","3d"],function(a,b){var c=function(a,b){var c,d,e;for(e='
          ',e+="",d=0;d",c=0;c
          ";e+=""}return e+="
          ",e+="
          "},d=function(a){var b=a.dom.select("*[data-mce-id]");return b[0]},e=function(a,b,e){a.undoManager.transact(function(){var f,g;a.insertContent(c(b,e)),f=d(a),f.removeAttribute("data-mce-id"),g=a.dom.select("td,th",f),a.selection.setCursorLocation(g[0],0)})},f=function(a,b){a.execCommand("FormatBlock",!1,b)},g=function(b,c,d){var e,f;e=b.editorUpload.blobCache,f=e.create(a.uuid("mceu"),d,c),e.add(f),b.insertContent(b.dom.createHTML("img",{src:f.blobUri()}))},h=function(a){a.selection.collapse(!1)},i=function(a){a.focus(),b.unlinkSelection(a),h(a)},j=function(a,b,c){a.focus(),a.dom.setAttrib(b,"href",c),h(a)},k=function(a,b){a.execCommand("mceInsertLink",!1,{href:b}),h(a)},l=function(a,b){var c=a.dom.getParent(a.selection.getStart(),"a[href]");c?j(a,c,b):k(a,b)},m=function(a,b){0===b.trim().length?i(a):l(a,b)};return{insertTable:e,formatBlock:f,insertBlob:g,createLink:m,unlink:i}}),g("3e",[],function(){var a=function(a){return/^www\.|\.(com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil)$/i.test(a.trim())},b=function(a){return/^https?:\/\//.test(a.trim())};return{isDomainLike:a,isAbsolute:b}}),g("k",["e","d","3b","o","3e"],function(a,b,c,d,e){var f=function(a){a.find("textbox").eq(0).each(function(a){a.focus()})},g=function(c,d){var e=b.create(a.extend({type:"form",layout:"flex",direction:"row",padding:5,name:c,spacing:3},d));return e.on("show",function(){f(e)}),e},h=function(a,b){return b?a.show():a.hide()},i=function(a,b){return new c(function(c){a.windowManager.confirm("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(a){var d=a===!0?"http://"+b:b;c(d)})})},j=function(a,b){return!e.isAbsolute(b)&&e.isDomainLike(b)?i(a,b):c.resolve(b)},k=function(a,b){var c={},e=function(){a.focus(),d.unlink(a),b()},f=function(a){var b=a.meta;b&&b.attach&&(c={href:this.value(),attach:b.attach})},i=function(b){if(b.control===this){var c,d="";c=a.dom.getParent(a.selection.getStart(),"a[href]"),c&&(d=a.dom.getAttrib(c,"href")),this.fromJSON({linkurl:d}),h(this.find("#unlink"),c),this.find("#linkurl")[0].focus()}};return g("quicklink",{items:[{type:"button",name:"unlink",icon:"unlink",onclick:e,tooltip:"Remove link"},{type:"filepicker",name:"linkurl",placeholder:"Paste or type a link",filetype:"file",onchange:f +},{type:"button",icon:"checkmark",subtype:"primary",tooltip:"Ok",onclick:"submit"}],onshow:i,onsubmit:function(e){j(a,e.data.linkurl).then(function(e){a.undoManager.transact(function(){e===c.href&&(c.attach(),c={}),d.createLink(a,e)}),b()})}})};return{createQuickLinkForm:k}}),g("l",["e","d","3f"],function(a,b,c){var d=function(a,b){var c=function(a,b){return{selector:a,handler:b}},d=function(a){b.active(a)},e=function(a){b.disabled(a)};return b.settings.stateSelector?c(b.settings.stateSelector,d):b.settings.disabledStateSelector?c(b.settings.disabledStateSelector,e):null},e=function(a,b,c){return function(){var e=d(b,c);null!==e&&a.selection.selectorChanged(e.selector,e.handler)}},f=function(a){return c.isArray(a)?a:c.isString(a)?a.split(/[ ,]/):[]},g=function(c,d,g){var h,i=[];if(g)return a.each(f(g),function(a){var d;"|"==a?h=null:c.buttons[a]&&(h||(h={type:"buttongroup",items:[]},i.push(h)),d=a,a=c.buttons[d],"function"==typeof a&&(a=a()),a.type=a.type||"button",a=b.create(a),a.on("postRender",e(c,d,a)),h.items.push(a))}),b.create({type:"toolbar",layout:"flow",name:d,items:i})};return{create:g}}),g("5",["c","d","e","f","g","h","i","j","k","l"],function(a,b,c,d,e,f,g,h,i,j){return function(){var k,l,m=function(a,b){return c.map(b,function(b){return j.create(a,b.id,b.items)})},n=function(a){return a.items().length>0},o=function(a,d){var e=m(a,d).concat([j.create(a,"text",f.getTextSelectionToolbarItems(a)),j.create(a,"insert",f.getInsertToolbarItems(a)),i.createQuickLinkForm(a,z)]);return b.create({type:"floatpanel",role:"dialog",classes:"tinymce tinymce-inline arrow",ariaLabel:"Inline toolbar",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:!0,fixed:!0,border:1,items:c.grep(e,n),oncancel:function(){a.focus()}})},p=function(a){a&&a.show()},q=function(a,b){a.moveTo(b.x,b.y)},r=function(a,b){b=b?b.substr(0,2):"",c.each({t:"down",b:"up",c:"center"},function(c,d){a.classes.toggle("arrow-"+c,d===b.substr(0,1))}),"cr"===b?(a.classes.toggle("arrow-left",!0),a.classes.toggle("arrow-right",!1)):"cl"===b?(a.classes.toggle("arrow-left",!0),a.classes.toggle("arrow-right",!0)):c.each({l:"left",r:"right"},function(c,d){a.classes.toggle("arrow-"+c,d===b.substr(1,1))})},s=function(a,b){var c=a.items().filter("#"+b);return c.length>0&&(c[0].show(),a.reflow(),!0)},t=function(b,c,e,i){var j,k,m,n;if(n=f.getPositionHandler(e),j=h.getContentAreaRect(e),k=a.DOM.getRect(b.getEl()),m="insert"===c?g.calcInsert(i,j,k):g.calc(i,j,k)){var o=d.getUiContainerDelta().getOr({x:0,y:0}),p={x:m.rect.x-o.x,y:m.rect.y-o.y,w:m.rect.w,h:m.rect.h};return l=i,q(b,g.userConstrain(n,i,j,p)),r(b,m.position),!0}return!1},u=function(a,b,c,d){return p(a),a.items().hide(),s(a,b)?void(t(a,b,c,d)===!1&&z(a)):void z(a)},v=function(){return k.items().filter("form:visible").length>0},w=function(b,c){if(k){if(k.items().hide(),!s(k,c))return void z(k);var d,e,i,j;p(k),k.items().hide(),s(k,c),j=f.getPositionHandler(b),d=h.getContentAreaRect(b),e=a.DOM.getRect(k.getEl()),i=g.calc(l,d,e),i&&(e=i.rect,q(k,g.userConstrain(j,l,d,e)),r(k,i.position))}},x=function(a,b,c,d){k||(e.fireBeforeRenderUI(a),k=o(a,d),k.renderTo().reflow().moveTo(c.x,c.y),a.nodeChanged()),u(k,b,a,c)},y=function(a,b,c){k&&t(k,b,a,c)},z=function(){k&&k.hide()},A=function(){k&&k.find("toolbar:visible").eq(0).each(function(a){a.focus(!0)})},B=function(){k&&(k.remove(),k=null)},C=function(){return k&&k.visible()&&v()};return{show:x,showForm:w,reposition:y,inForm:C,hide:z,focus:A,remove:B}}}),g("4f",[],function(){return"undefined"!=typeof window?window:Function("return this;")()}),g("48",["4f"],function(a){var b=function(b,c){for(var d=void 0!==c?c:a,e=0;e
          '+this._super(a)}})}),g("r",["1e","1","1h"],function(a,b,c){"use strict";return c.extend({Defaults:{classes:"widget btn",role:"button"},init:function(a){var b,c=this;c._super(a),a=c.settings,b=c.settings.size,c.on("click mousedown",function(a){a.preventDefault()}),c.on("touchstart",function(a){c.fire("click",a),a.preventDefault()}),a.subtype&&c.classes.add(a.subtype),b&&c.classes.add("btn-"+b),a.icon&&c.icon(a.icon)},icon:function(a){return arguments.length?(this.state.set("icon",a),this):this.state.get("icon")},repaint:function(){var a,b=this.getEl().firstChild;b&&(a=b.style,a.width=a.height="100%"),this._super()},renderHtml:function(){var a,c,d=this,e=d._id,f=d.classPrefix,g=d.state.get("icon"),h=d.state.get("text"),i="",j=d.settings;return a=j.image,a?(g="none","string"!=typeof a&&(a=b.getSelection?a[0]:a[1]),a=" style=\"background-image: url('"+a+"')\""):a="",h&&(d.classes.add("btn-has-text"),i=''+d.encode(h)+""),g=g?f+"ico "+f+"i-"+g:"",c="boolean"==typeof j.active?' aria-pressed="'+j.active+'"':"",'
          "},bindStates:function(){function b(a){var b=d("span."+e,c.getEl());a?(b[0]||(d("button:first",c.getEl()).append(''),b=d("span."+e,c.getEl())),b.html(c.encode(a))):b.remove(),c.classes.toggle("btn-has-text",!!a)}var c=this,d=c.$,e=c.classPrefix+"txt";return c.state.on("change:text",function(a){b(a.value)}),c.state.on("change:icon",function(d){var e=d.value,f=c.classPrefix;c.settings.icon=e,e=e?f+"ico "+f+"i-"+c.settings.icon:"";var g=c.getEl().firstChild,h=g.getElementsByTagName("i")[0];e?(h&&h==g.firstChild||(h=a.createElement("i"),g.insertBefore(h,g.firstChild)),h.className=e):h&&g.removeChild(h),b(c.state.get("text"))}),c._super()}})}),h("3h",RegExp),g("q",["r","e","30","31","3h"],function(a,b,c,d,e){return a.extend({init:function(a){var c=this;a=b.extend({text:"Browse...",multiple:!1,accept:null},a),c._super(a),c.classes.add("browsebutton"),a.multiple&&c.classes.add("multiple")},postRender:function(){var a=this,b=c.create("input",{type:"file",id:a._id+"-browse",accept:a.settings.accept});a._super(),d(b).on("change",function(b){var c=b.target.files;a.value=function(){return c.length?a.settings.multiple?c:c[0]:null},b.preventDefault(),c.length&&a.fire("change",b)}),d(b).on("click",function(a){a.stopPropagation()}),d(a.getEl("button")).on("click",function(a){a.stopPropagation(),b.click()}),a.getEl().appendChild(b)},remove:function(){d(this.getEl("button")).off(),d(this.getEl("input")).off(),this._super()}})}),g("s",["z"],function(a){"use strict";return a.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var a=this,b=a._layout;return a.classes.add("btn-group"),a.preRender(),b.preRender(a),'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),g("t",["1e","1h"],function(a,b){"use strict";return b.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(a){var b=this;b._super(a),b.on("click mousedown",function(a){a.preventDefault()}),b.on("click",function(a){a.preventDefault(),b.disabled()||b.checked(!b.checked())}),b.checked(b.settings.checked)},checked:function(a){return arguments.length?(this.state.set("checked",a),this):this.state.get("checked")},value:function(a){return arguments.length?this.checked(a):this.checked()},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix;return'
          '+a.encode(a.state.get("text"))+"
          "},bindStates:function(){function b(a){c.classes.toggle("checked",a),c.aria("checked",a)}var c=this;return c.state.on("change:text",function(a){c.getEl("al").firstChild.data=c.translate(a.value)}),c.state.on("change:checked change:value",function(a){c.fire("change"),b(a.value)}),c.state.on("change:icon",function(b){var d=b.value,e=c.classPrefix;if("undefined"==typeof d)return c.settings.icon;c.settings.icon=d,d=d?e+"ico "+e+"i-"+c.settings.icon:"";var f=c.getEl().firstChild,g=f.getElementsByTagName("i")[0];d?(g&&g==f.firstChild||(g=a.createElement("i"),f.insertBefore(g,f.firstChild)),g.className=d):g&&f.removeChild(g)}),c.state.get("checked")&&b(!0),c._super()}})}),g("3i",["8"],function(a){return a("tinymce.util.VK")}),g("y",["1e","31","d","e","3i","30","1h"],function(a,b,c,d,e,f,g){"use strict";return g.extend({init:function(a){var c=this;c._super(a),a=c.settings,c.classes.add("combobox"),c.subinput=!0,c.ariaTarget="inp",a.menu=a.menu||a.values,a.menu&&(a.icon="caret"),c.on("click",function(d){var e=d.target,f=c.getEl();if(b.contains(f,e)||e==f)for(;e&&e!=f;)e.id&&e.id.indexOf("-open")!=-1&&(c.fire("action"),a.menu&&(c.showMenu(),d.aria&&c.menu.items()[0].focus())),e=e.parentNode}),c.on("keydown",function(a){var b;13==a.keyCode&&"INPUT"===a.target.nodeName&&(a.preventDefault(),c.parents().reverse().each(function(a){if(a.toJSON)return b=a,!1}),c.fire("submit",{data:b.toJSON()}))}),c.on("keyup",function(a){if("INPUT"==a.target.nodeName){var b=c.state.get("value"),d=a.target.value;d!==b&&(c.state.set("value",d),c.fire("autocomplete",a))}}),c.on("mouseover",function(a){var b=c.tooltip().moveTo(-65535);if(c.statusLevel()&&a.target.className.indexOf(c.classPrefix+"status")!==-1){var d=c.statusMessage()||"Ok",e=b.text(d).show().testMoveRel(a.target,["bc-tc","bc-tl","bc-tr"]);b.classes.toggle("tooltip-n","bc-tc"==e),b.classes.toggle("tooltip-nw","bc-tl"==e),b.classes.toggle("tooltip-ne","bc-tr"==e),b.moveRel(a.target,e)}})},statusLevel:function(a){return arguments.length>0&&this.state.set("statusLevel",a),this.state.get("statusLevel")},statusMessage:function(a){return arguments.length>0&&this.state.set("statusMessage",a),this.state.get("statusMessage")},showMenu:function(){var a,b=this,d=b.settings;b.menu||(a=d.menu||[],a.length?a={type:"menu",items:a}:a.type=a.type||"menu",b.menu=c.create(a).parent(b).renderTo(b.getContainerElm()),b.fire("createmenu"),b.menu.reflow(),b.menu.on("cancel",function(a){a.control===b.menu&&b.focus()}),b.menu.on("show hide",function(a){a.control.items().each(function(a){a.active(a.value()==b.value())})}).fire("show"),b.menu.on("select",function(a){b.value(a.control.value())}),b.on("focusin",function(a){"INPUT"==a.target.tagName.toUpperCase()&&b.menu.hide()}),b.aria("expanded",!0)),b.menu.show(),b.menu.layoutRect({w:b.layoutRect().w}),b.menu.moveRel(b.getEl(),b.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},focus:function(){this.getEl("inp").focus()},repaint:function(){var c,d,e=this,g=e.getEl(),h=e.getEl("open"),i=e.layoutRect(),j=0,k=g.firstChild;e.statusLevel()&&"none"!==e.statusLevel()&&(j=parseInt(f.getRuntimeStyle(k,"padding-right"),10)-parseInt(f.getRuntimeStyle(k,"padding-left"),10)),c=h?i.w-f.getSize(h).width-10:i.w-10;var l=a;return l.all&&(!l.documentMode||l.documentMode<=8)&&(d=e.layoutRect().h-2+"px"),b(k).css({width:c-j,lineHeight:d}),e._super(),e},postRender:function(){var a=this;return b(this.getEl("inp")).on("change",function(b){a.state.set("value",b.target.value),a.fire("change",b)}),a._super()},renderHtml:function(){var a,b,c=this,d=c._id,e=c.settings,f=c.classPrefix,g=c.state.get("value")||"",h="",i="",j="";return"spellcheck"in e&&(i+=' spellcheck="'+e.spellcheck+'"'),e.maxLength&&(i+=' maxlength="'+e.maxLength+'"'),e.size&&(i+=' size="'+e.size+'"'),e.subtype&&(i+=' type="'+e.subtype+'"'),j='',c.disabled()&&(i+=' disabled="disabled"'),a=e.icon,a&&"caret"!=a&&(a=f+"ico "+f+"i-"+e.icon),b=c.state.get("text"),(a||b)&&(h='
          ",c.classes.add("has-open")),'
          '+j+h+"
          "},value:function(a){return arguments.length?(this.state.set("value",a),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value),this.state.get("value"))},showAutoComplete:function(a,b){var e=this;if(0===a.length)return void e.hideMenu();var f=function(a,b){return function(){e.fire("selectitem",{title:b,value:a})}};e.menu?e.menu.items().remove():e.menu=c.create({type:"menu",classes:"combobox-menu",layout:"flow"}).parent(e).renderTo(),d.each(a,function(a){e.menu.add({text:a.title,url:a.previewUrl,match:b,classes:"menu-item-ellipsis",onclick:f(a.value,a.title)})}),e.menu.renderNew(),e.hideMenu(),e.menu.on("cancel",function(a){a.control.parent()===e.menu&&(a.stopPropagation(),e.focus(),e.hideMenu())}),e.menu.on("select",function(){e.focus()});var g=e.layoutRect().w;e.menu.layoutRect({w:g,minW:0,maxW:g}),e.menu.reflow(),e.menu.show(),e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},hideMenu:function(){this.menu&&this.menu.hide()},bindStates:function(){var a=this;a.state.on("change:value",function(b){a.getEl("inp").value!=b.value&&(a.getEl("inp").value=b.value)}),a.state.on("change:disabled",function(b){a.getEl("inp").disabled=b.value}),a.state.on("change:statusLevel",function(b){var c=a.getEl("status"),d=a.classPrefix,e=b.value;f.css(c,"display","none"===e?"none":""),f.toggleClass(c,d+"i-checkmark","ok"===e),f.toggleClass(c,d+"i-warning","warn"===e),f.toggleClass(c,d+"i-error","error"===e),a.classes.toggle("has-status","none"!==e),a.repaint()}),f.on(a.getEl("status"),"mouseleave",function(){a.tooltip().hide()}),a.on("cancel",function(b){a.menu&&a.menu.visible()&&(b.stopPropagation(),a.hideMenu())});var b=function(a,b){b&&b.items().length>0&&b.items().eq(a)[0].focus()};return a.on("keydown",function(c){var d=c.keyCode;"INPUT"===c.target.nodeName&&(d===e.DOWN?(c.preventDefault(),a.fire("autocomplete"),b(0,a.menu)):d===e.UP&&(c.preventDefault(),b(-1,a.menu)))}),a._super()},remove:function(){b(this.getEl("inp")).off(),this.menu&&this.menu.remove(),this._super()}})}),g("v",["y"],function(a){"use strict";return a.extend({init:function(a){var b=this;a.spellcheck=!1,a.onaction&&(a.icon="none"),b._super(a),b.classes.add("colorbox"),b.on("change keyup postrender",function(){b.repaintColor(b.value())})},repaintColor:function(a){var b=this.getEl("open"),c=b?b.getElementsByTagName("i")[0]:null;if(c)try{c.style.background=a}catch(a){}},bindStates:function(){var a=this;return a.state.on("change:value",function(b){a.state.get("rendered")&&a.repaintColor(b.value)}),a._super()}})}),g("27",["r","18"],function(a,b){"use strict";return a.extend({showPanel:function(){var a=this,c=a.settings;if(a.classes.add("opened"),a.panel)a.panel.show();else{var d=c.panel;d.type&&(d={layout:"grid",items:d}),d.role=d.role||"dialog",d.popover=!0,d.autohide=!0,d.ariaRoot=!0,a.panel=new b(d).on("hide",function(){a.classes.remove("opened")}).on("cancel",function(b){b.stopPropagation(),a.focus(),a.hidePanel()}).parent(a).renderTo(a.getContainerElm()),a.panel.fire("show"),a.panel.reflow()}var e=a.panel.testMoveRel(a.getEl(),c.popoverAlign||(a.isRtl()?["bc-tc","bc-tl","bc-tr"]:["bc-tc","bc-tr","bc-tl"]));a.panel.classes.toggle("start","bc-tl"===e),a.panel.classes.toggle("end","bc-tr"===e),a.panel.moveRel(a.getEl(),e)},hidePanel:function(){var a=this;a.panel&&a.panel.hide()},postRender:function(){var a=this;return a.aria("haspopup",!0),a.on("click",function(b){b.control===a&&(a.panel&&a.panel.visible()?a.hidePanel():(a.showPanel(),a.panel.focus(!!b.aria)))}),a._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})}),g("w",["27","c"],function(a,b){"use strict";var c=b.DOM;return a.extend({init:function(a){this._super(a),this.classes.add("splitbtn"),this.classes.add("colorbutton")},color:function(a){return a?(this._color=a,this.getEl("preview").style.backgroundColor=a,this):this._color},resetColor:function(){return this._color=null,this.getEl("preview").style.backgroundColor=null,this},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix,d=a.state.get("text"),e=a.settings.icon?c+"ico "+c+"i-"+a.settings.icon:"",f=a.settings.image?" style=\"background-image: url('"+a.settings.image+"')\"":"",g="";return d&&(a.classes.add("btn-has-text"),g=''+a.encode(d)+""),'
          '},postRender:function(){var a=this,b=a.settings.onclick;return a.on("click",function(d){d.aria&&"down"===d.aria.key||d.control!=a||c.getParent(d.target,"."+a.classPrefix+"open")||(d.stopImmediatePropagation(),b.call(a,d))}),delete a.settings.onclick,a._super()}})}),g("3j",["8"],function(a){return a("tinymce.util.Color")}),g("x",["1h","11","30","3j"],function(a,b,c,d){"use strict";return a.extend({Defaults:{classes:"widget colorpicker"},init:function(a){this._super(a)},postRender:function(){function a(a,b){var d,e,f=c.getPos(a);return d=b.pageX-f.x,e=b.pageY-f.y,d=Math.max(0,Math.min(d/a.clientWidth,1)),e=Math.max(0,Math.min(e/a.clientHeight,1)),{x:d,y:e}}function e(a,b){var e=(360-a.h)/360;c.css(j,{top:100*e+"%"}),b||c.css(l,{left:a.s+"%",top:100-a.v+"%"}),k.style.background=new d({s:100,v:100,h:a.h}).toHex(),m.color().parse({s:a.s,v:a.v,h:a.h})}function f(b){var c;c=a(k,b),h.s=100*c.x,h.v=100*(1-c.y),e(h),m.fire("change")}function g(b){var c;c=a(i,b),h=n.toHsv(),h.h=360*(1-c.y),e(h,!0),m.fire("change")}var h,i,j,k,l,m=this,n=m.color();i=m.getEl("h"),j=m.getEl("hp"),k=m.getEl("sv"),l=m.getEl("svp"),m._repaint=function(){h=n.toHsv(),e(h)},m._super(),m._svdraghelper=new b(m._id+"-sv",{start:f,drag:f}),m._hdraghelper=new b(m._id+"-h",{start:g,drag:g}),m._repaint()},rgb:function(){return this.color().toRgb()},value:function(a){var b=this;return arguments.length?(b.color().parse(a),void(b._rendered&&b._repaint())):b.color().toHex()},color:function(){return this._color||(this._color=new d),this._color},renderHtml:function(){function a(){var a,b,c,d,g="";for(c="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",d=f.split(","),a=0,b=d.length-1;a';return g}var b,c=this,d=c._id,e=c.classPrefix,f="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",g="background: -ms-linear-gradient(top,"+f+");background: linear-gradient(to bottom,"+f+");";return b='
          '+a()+'
          ','
          '+b+"
          "}})}),g("12",["1h","e","30","3h"],function(a,b,c,d){return a.extend({init:function(a){var c=this;a=b.extend({height:100,text:"Drop an image here",multiple:!1,accept:null},a),c._super(a),c.classes.add("dropzone"),a.multiple&&c.classes.add("multiple")},renderHtml:function(){var a,b,d=this,e=d.settings;return a={id:d._id,hidefocus:"1"},b=c.create("div",a,""+this.translate(e.text)+""),e.height&&c.css(b,"height",e.height+"px"),e.width&&c.css(b,"width",e.width+"px"),b.className=d.classes,b.outerHTML},postRender:function(){var a=this,c=function(b){b.preventDefault(),a.classes.toggle("dragenter"),a.getEl().className=a.classes},e=function(c){var e=a.settings.accept;if("string"!=typeof e)return c;var f=new d("("+e.split(/\s*,\s*/).join("|")+")$","i");return b.grep(c,function(a){return f.test(a.name)})};a._super(),a.$el.on("dragover",function(a){a.preventDefault()}),a.$el.on("dragenter",c),a.$el.on("dragleave",c),a.$el.on("drop",function(b){if(b.preventDefault(),!a.state.get("disabled")){var c=e(b.dataTransfer.files);a.value=function(){return c.length?a.settings.multiple?c:c[0]:null},c.length&&a.fire("change",b)}})},remove:function(){this.$el.off(),this._super()}})}),g("28",["1h"],function(a){"use strict";return a.extend({init:function(a){var b=this;a.delimiter||(a.delimiter="\xbb"),b._super(a),b.classes.add("path"),b.canFocus=!0,b.on("click",function(a){var c,d=a.target;(c=d.getAttribute("data-index"))&&b.fire("select",{value:b.row()[c],index:c})}),b.row(b.settings.row)},focus:function(){var a=this;return a.getEl().firstChild.focus(),a},row:function(a){return arguments.length?(this.state.set("row",a),this):this.state.get("row")},renderHtml:function(){var a=this;return'
          '+a._getDataPathHtml(a.state.get("row"))+"
          "},bindStates:function(){var a=this;return a.state.on("change:row",function(b){a.innerHtml(a._getDataPathHtml(b.value))}),a._super()},_getDataPathHtml:function(a){var b,c,d=this,e=a||[],f="",g=d.classPrefix;for(b=0,c=e.length;b0?'":"")+'
          '+e[b].name+"
          ";return f||(f='
          \xa0
          '),f}})}),g("13",["28"],function(a){return a.extend({postRender:function(){function a(a){if(1===a.nodeType){if("BR"==a.nodeName||a.getAttribute("data-mce-bogus"))return!0;if("bookmark"===a.getAttribute("data-mce-type"))return!0}return!1}var b=this,c=b.settings.editor;return c.settings.elementpath!==!1&&(b.on("select",function(a){c.focus(),c.selection.select(this.row()[a.index].element),c.nodeChanged()}),c.on("nodeChange",function(d){for(var e=[],f=d.parents,g=f.length;g--;)if(1==f[g].nodeType&&!a(f[g])){var h=c.fire("ResolveName",{name:f[g].nodeName.toLowerCase(),target:f[g]});if(h.isDefaultPrevented()||e.push({name:h.name,element:f[g]}),h.isPropagationStopped())break}b.row(e)})),b._super()}})}),g("1r",["z"],function(a){"use strict";return a.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var a=this,b=a._layout,c=a.classPrefix;return a.classes.add("formitem"),b.preRender(a),'
          '+(a.settings.title?'
          '+a.settings.title+"
          ":"")+'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),g("1a",["z","1r","e"],function(a,b,c){"use strict";return a.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:15,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var a=this,d=a.items();a.settings.formItemDefaults||(a.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),d.each(function(d){var e,f=d.settings.label;f&&(e=new b(c.extend({items:{type:"label",id:d._id+"-l",text:f,flex:0,forId:d._id,disabled:d.disabled()}},a.settings.formItemDefaults)),e.type="formitem",d.aria("labelledby",d._id+"-l"),"undefined"==typeof d.settings.flex&&(d.settings.flex=1),a.replace(d,e),e.add(d))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var a=this;a._super(),a.fromJSON(a.settings.data)},bindStates:function(){function a(){var a,c,d,e=0,f=[];if(b.settings.labelGapCalc!==!1)for(d="children"==b.settings.labelGapCalc?b.find("formitem"):b.items(),d.filter("formitem").each(function(a){var b=a.items()[0],c=b.getEl().clientWidth;e=c>e?c:e,f.push(b)}),c=b.settings.labelGap||0,a=f.length;a--;)f[a].settings.minWidth=e+c}var b=this;b._super(),b.on("show",a),a()}})}),g("14",["1a"],function(a){"use strict";return a.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var a=this,b=a._layout,c=a.classPrefix;return a.preRender(),b.preRender(a),'
          '+(a.settings.title?''+a.settings.title+"":"")+'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),h("49",Date),h("4a",Math),g("41",["49","4a","3u"],function(a,b,c){var d=0,e=function(e){var f=new a,g=f.getTime(),h=b.floor(1e9*b.random());return d++,e+"_"+h+d+c(g)};return{generate:e}}),g("3n",[],function(){return"undefined"==typeof console&&(console={log:function(){}}),console}),g("1c",["1b","3l","3n","1e"],function(a,b,c,d){var e=function(a,b){var e=b||d,f=e.createElement("div");if(f.innerHTML=a,!f.hasChildNodes()||f.childNodes.length>1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("4c",[],function(){var a=function(a){var b,c=!1;return function(){return c||(c=!0,b=a.apply(null,arguments)),b}};return{cached:a}}),g("46",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("47",["46"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("44",["4c","1c","47","1e"],function(a,b,c,d){var e=function(a){var b=c.isText(a)?a.dom().parentNode:a.dom();return void 0!==b&&null!==b&&b.ownerDocument.body.contains(b)},f=a.cached(function(){return g(b.fromDom(d))}),g=function(a){var c=a.dom().body;if(null===c||void 0===c)throw"Body is not available yet";return b.fromDom(c)};return{body:f,getBody:g,inBody:e}}),g("43",["3k","3u"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("4q",["2y","1b","3k","3l"],function(a,b,c,d){return function(){var e=arguments;return function(){for(var f=new c(arguments.length),g=0;g0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("4j",["4q","4r"],function(a,b){return{immutable:a,immutableBag:b}}),g("4k",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("4d",["40"],function(a){var b=function(){var b=a.getOrDie("Node");return b},c=function(a,b,c){return 0!==(a.compareDocumentPosition(b)&c)},d=function(a,d){return c(a,d,b().DOCUMENT_POSITION_PRECEDING)},e=function(a,d){return c(a,d,b().DOCUMENT_POSITION_CONTAINED_BY)};return{documentPositionPreceding:d,documentPositionContainedBy:e}}),h("4w",Number),g("4s",["2y","4w","3u"],function(a,b,c){var d=function(a,b){for(var c=0;c0&&b0},C=function(b){var c=A(b);return a.filter(y(c).concat(z(c)),B)};return{find:C}}),g("15",["2y","1b","1","3m","1f","y","e"],function(a,b,c,d,e,f,g){"use strict";var h=function(){return c.tinymce?c.tinymce.activeEditor:e.activeEditor},i={},j=5,k=function(){i={}},l=function(a){return{title:a.title,value:{title:{raw:a.title},url:a.url,attach:a.attach}}},m=function(a){return g.map(a,l)},n=function(a,c){return{title:a,value:{title:a,url:c,attach:b.noop}}},o=function(b,c){var d=a.exists(c,function(a){return a.url===b});return!d},p=function(a,b,c){var d=b in a?a[b]:c;return d===!1?null:d},q=function(c,d,e,f){var h={title:"-"},j=function(c){var f=c.hasOwnProperty(e)?c[e]:[],h=a.filter(f,function(a){return o(a,d)});return g.map(h,function(a){return{title:a,value:{title:a,url:a,attach:b.noop}}})},k=function(b){var c=a.filter(d,function(a){return a.type===b});return m(c)},l=function(){var a=k("anchor"),b=p(f,"anchor_top","#top"),c=p(f,"anchor_bottom","#bottom");return null!==b&&a.unshift(n("",b)),null!==c&&a.push(n("",c)),a},q=function(b){return a.foldl(b,function(a,b){var c=0===a.length||0===b.length;return c?a.concat(b):a.concat(h,b)},[])};return f.typeahead_urls===!1?[]:"file"===e?q([s(c,j(i)),s(c,k("header")),s(c,l())]):s(c,j(i))},r=function(b,c){var d=i[c];/^https?/.test(b)&&(d?a.indexOf(d,b)===-1&&(i[c]=d.slice(0,j).concat(b)):i[c]=[b])},s=function(a,b){var c=a.toLowerCase(),d=g.grep(b,function(a){return a.title.toLowerCase().indexOf(c)!==-1});return 1===d.length&&d[0].title===a?[]:d},t=function(a){var b=a.title;return b.raw?b.raw:b},u=function(a,b,c,e){var f=function(f){var g=d.find(c),h=q(f,g,e,b);a.showAutoComplete(h,f)};a.on("autocomplete",function(){f(a.value())}),a.on("selectitem",function(b){var c=b.value;a.value(c.url);var d=t(c);"image"===e?a.fire("change",{meta:{alt:d,attach:c.attach}}):a.fire("change",{meta:{text:d,attach:c.attach}}),a.focus()}),a.on("click",function(b){0===a.value().length&&"INPUT"===b.target.nodeName&&f("")}),a.on("PostRender",function(){a.getRoot().on("submit",function(b){b.isDefaultPrevented()||r(a.value(),e)})})},v=function(a){var b=a.status,c=a.message;return"valid"===b?{status:"ok",message:c}:"unknown"===b?{status:"warn",message:c}:"invalid"===b?{status:"warn",message:c}:{status:"none",message:""}},w=function(a,b,c){var d=b.filepicker_validator_handler;if(d){var e=function(b){return 0===b.length?void a.statusLevel("none"):void d({url:b,type:c},function(b){var c=v(b);a.statusMessage(c.message),a.statusLevel(c.status)})};a.state.on("change:value",function(a){e(a.value)})}};return f.extend({Statics:{clearHistory:k},init:function(a){var b,d,e,f=this,i=h(),j=i.settings,k=a.filetype;a.spellcheck=!1,e=j.file_picker_types||j.file_browser_callback_types,e&&(e=g.makeMap(e,/[, ]/)),e&&!e[k]||(d=j.file_picker_callback,!d||e&&!e[k]?(d=j.file_browser_callback,!d||e&&!e[k]||(b=function(){d(f.getEl("inp").id,f.value(),k,c)})):b=function(){var a=f.fire("beforecall").meta;a=g.extend({filetype:k},a),d.call(i,function(a,b){f.value(a).fire("change",{meta:b})},f.value(),a)}),b&&(a.icon="browse",a.onaction=b),f._super(a),u(f,j,i.getBody(),k),w(f,j,k)}})}),g("16",["p"],function(a){"use strict";return a.extend({recalc:function(a){var b=a.layoutRect(),c=a.paddingBox;a.items().filter(":visible").each(function(a){a.layoutRect({x:c.left,y:c.top,w:b.innerW-c.right-c.left,h:b.innerH-c.top-c.bottom}),a.recalc&&a.recalc()})}})}),g("17",["p"],function(a){"use strict";return a.extend({recalc:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N=[],O=Math.max,P=Math.min;for(d=a.items().filter(":visible"),e=a.layoutRect(),f=a.paddingBox,g=a.settings,m=a.isRtl()?g.direction||"row-reversed":g.direction,h=g.align,i=a.isRtl()?g.pack||"end":g.pack,j=g.spacing||0,"row-reversed"!=m&&"column-reverse"!=m||(d=d.set(d.toArray().reverse()),m=m.split("-")[0]),"column"==m?(z="y",x="h",y="minH",A="maxH",C="innerH",B="top",D="deltaH",E="contentH",J="left",H="w",F="x",G="innerW",I="minW",K="right",L="deltaW",M="contentW"):(z="x",x="w",y="minW",A="maxW",C="innerW",B="left",D="deltaW",E="contentW",J="top",H="h",F="y",G="innerH",I="minH",K="bottom",L="deltaH",M="contentH"),l=e[C]-f[B]-f[B],w=k=0,b=0,c=d.length;b0&&(k+=q,o[A]&&N.push(n),o.flex=q),l-=o[y],r=f[J]+o[I]+f[K],r>w&&(w=r);if(u={},l<0?u[y]=e[y]-l+e[D]:u[y]=e[C]-l+e[D],u[I]=w+e[L],u[E]=e[C]-l,u[M]=w,u.minW=P(u.minW,e.maxW),u.minH=P(u.minH,e.maxH),u.minW=O(u.minW,e.startMinWidth),u.minH=O(u.minH,e.startMinHeight),!e.autoResize||u.minW==e.minW&&u.minH==e.minH){for(t=l/k,b=0,c=N.length;bs?(l-=o[A]-o[y],k-=o.flex,o.flex=0,o.maxFlexSize=s):o.maxFlexSize=0;for(t=l/k,v=f[B],u={},0===k&&("end"==i?v=l+f[B]:"center"==i?(v=Math.round(e[C]/2-(e[C]-l)/2)+f[B],v<0&&(v=f[B])):"justify"==i&&(v=f[B],j=Math.floor(l/(d.length-1)))),u[F]=f[J],b=0,c=d.length;b0&&(r+=o.flex*t),u[x]=r,u[z]=v,n.layoutRect(u),n.recalc&&n.recalc(),v+=r+j}else if(u.w=u.minW,u.h=u.minH,a.layoutRect(u),this.recalc(a),null===a._lastRect){var Q=a.parent();Q&&(Q._lastRect=null,Q.recalc())}}})}),g("19",["1x"],function(a){return a.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(a){a.items().filter(":visible").each(function(a){a.recalc&&a.recalc()})},isNative:function(){return!0}})}),g("3q",["43","37"],function(a,b){return function(c,d,e,f,g){return c(e,f)?b.some(e):a.isFunction(g)&&g(e)?b.none():d(e,f,g)}}),g("3o",["43","2y","1b","37","44","45","1c","3q"],function(a,b,c,d,e,f,g,h){var i=function(a){return n(e.body(),a)},j=function(b,e,f){for(var h=b.dom(),i=a.isFunction(f)?f:c.constant(!1);h.parentNode;){h=h.parentNode;var j=g.fromDom(h);if(e(j))return d.some(j);if(i(j))break}return d.none()},k=function(a,b,c){var d=function(a){return b(a)};return h(d,j,a,b,c)},l=function(a,b){var c=a.dom();return c.parentNode?m(g.fromDom(c.parentNode),function(c){return!f.eq(a,c)&&b(c)}):d.none()},m=function(a,d){var e=b.find(a.dom().childNodes,c.compose(d,g.fromDom));return e.map(g.fromDom)},n=function(a,b){var c=function(a){for(var e=0;e=0;i--)h=b.toPt(g,i),j=c(d,h,g);e.value(j?j:null),j||e.text(h)})}},e=function(b){var c="8pt 10pt 12pt 14pt 18pt 24pt 36pt",d=b.settings.fontsize_formats||c;return a.map(d.split(" "),function(a){var b=a,c=a,d=a.split("=");return d.length>1&&(b=d[0],c=d[1]),{text:b,value:c}})},f=function(a){a.addButton("fontsizeselect",function(){var b=e(a);return{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:b,fixedWidth:!0,onPostRender:d(a,b),onclick:function(b){b.control.settings.value&&a.execCommand("FontSize",!1,b.control.settings.value)}}})},g=function(a){f(a)};return{register:g}}),g("1l",["e","3r"],function(a,b){var c="Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre",d=function(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a},e=function(b,c,d){return function(){var e=this;b.on("nodeChange",function(f){var g=b.formatter,h=null;a.each(f.parents,function(b){if(a.each(c,function(a){if(d?g.matchNode(b,d,{value:a.value})&&(h=a.value):g.matchNode(b,a.value)&&(h=a.value),h)return!1}),h)return!1}),e.value(h)})}},f=function(c,d){return function(){var f=[];return a.each(d,function(a){f.push({text:a[0],value:a[1],textStyle:function(){return c.formatter.getCssText(a[1])}})}),{type:"listbox",text:d[0][0],values:f,fixedWidth:!0,onselect:function(a){if(a.control){var d=a.control.value();b.toggleFormat(c,d)()}},onPostRender:e(c,f)}}},g=function(c,d){return a.map(d,function(a){return{text:a[0],onclick:b.toggleFormat(c,a[1]),textStyle:function(){return c.formatter.getCssText(a[1])}}})},h=function(a){var b=d(a.settings.block_formats||c);a.addMenuItem("blockformats",{text:"Blocks",menu:g(a,b)}),a.addButton("formatselect",f(a,b))};return{register:h}}),g("1m",["e","3r"],function(a,b){var c=function(b,d){var e=d.length;return a.each(d,function(a){a.menu&&(a.hidden=0===c(b,a.menu));var d=a.format;d&&(a.hidden=!b.formatter.canApply(d)),a.hidden&&e--}),e},d=function(a,b){var e=b.items().length;return b.items().each(function(b){b.menu&&b.visible(d(a,b.menu)>0),!b.menu&&b.settings.menu&&b.visible(c(a,b.settings.menu)>0);var f=b.settings.format;f&&b.visible(a.formatter.canApply(f)),b.visible()||e--}),e},e=function(c){var d=0,e=[],f=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],g=function(b){var c=[];if(b)return a.each(b,function(a){var b={text:a.title,icon:a.icon};if(a.items)b.menu=g(a.items);else{var f=a.format||"custom"+d++;a.format||(a.name=f,e.push(a)),b.format=f,b.cmd=a.cmd}c.push(b)}),c},h=function(){var a;return a=g(c.settings.style_formats_merge?c.settings.style_formats?f.concat(c.settings.style_formats):f:c.settings.style_formats||f)};return c.on("init",function(){a.each(e,function(a){c.formatter.register(a.name,a)})}),{type:"menu",items:h(),onPostRender:function(a){c.fire("renderFormatsMenu",{control:a.control})},itemDefaults:{preview:!0,textStyle:function(){if(this.settings.format)return c.formatter.getCssText(this.settings.format)},onPostRender:function(){var a=this;a.parent().on("show",function(){var b,d;b=a.settings.format,b&&(a.disabled(!c.formatter.canApply(b)),a.active(c.formatter.match(b))),d=a.settings.cmd,d&&a.active(c.queryCommandState(d))})},onclick:function(){this.settings.format&&b.toggleFormat(c,this.settings.format)(),this.settings.cmd&&c.execCommand(this.settings.cmd)}}}},f=function(a,b){a.addMenuItem("formats",{text:"Formats",menu:b})},g=function(a,b){a.addButton("styleselect",{type:"menubutton",text:"Formats",menu:b,onShowMenu:function(){a.settings.style_formats_autohide&&d(a,this.menu)}})},h=function(a){var b=e(a);f(a,b),g(a,b)};return{register:h}}),g("1n",["2y","e"],function(a,b){var c=function(d,e){var f,g;if("string"==typeof e)g=e.split(" ");else if(b.isArray(e))return a.flatten(b.map(e,function(a){return c(d,a)}));return f=b.grep(g,function(a){return"|"===a||a in d.menuItems}),b.map(f,function(a){return"|"===a?{text:"-"}:d.menuItems[a]})},d=function(a){return a&&"-"===a.text},e=function(b){var c=a.filter(b,function(a,b,c){return!d(a)||!d(c[b-1])});return a.filter(c,function(a,b,c){return!d(a)||b>0&&bE[l]?y:E[l],F[m]=z>F[m]?z:F[m];for(A=f.innerW-q.left-q.right,w=0,l=0;l0?s:0),A-=(l>0?s:0)+E[l];for(B=f.innerH-q.top-q.bottom,x=0,m=0;m0?t:0),B-=(m>0?t:0)+F[m];if(w+=q.left+q.right,x+=q.top+q.bottom,i={},i.minW=w+(f.w-f.innerW),i.minH=x+(f.h-f.innerH),i.contentW=i.minW-f.deltaW,i.contentH=i.minH-f.deltaH,i.minW=Math.min(i.minW,f.maxW),i.minH=Math.min(i.minH,f.maxH),i.minW=Math.max(i.minW,f.startMinWidth),i.minH=Math.max(i.minH,f.startMinHeight),!f.autoResize||i.minW==f.minW&&i.minH==f.minH){f.autoResize&&(i=a.layoutRect(i),i.contentW=i.minW-f.deltaW,i.contentH=i.minH-f.deltaH);var G;G="start"==b.packV?0:B>0?Math.floor(B/c):0;var H=0,I=b.flexWidths;if(I)for(l=0;l'},src:function(a){this.getEl().src=a},html:function(a,c){var d=this,e=this.getEl().contentWindow.document.body;return e?(e.innerHTML=a,c&&c()):b.setTimeout(function(){d.html(a)}),this}})}),g("1u",["1h"],function(a){"use strict";return a.extend({init:function(a){var b=this;b._super(a),b.classes.add("widget").add("infobox"),b.canFocus=!1},severity:function(a){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(a)},help:function(a){this.state.set("help",a)},renderHtml:function(){var a=this,b=a.classPrefix;return'
          '+a.encode(a.state.get("text"))+'
          '},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl("body").firstChild.data=a.encode(b.value),a.state.get("rendered")&&a.updateLayoutRect()}),a.state.on("change:help",function(b){a.classes.toggle("has-help",b.value),a.state.get("rendered")&&a.updateLayoutRect()}),a._super()}})}),g("1w",["1h","30"],function(a,b){"use strict";return a.extend({init:function(a){var b=this;b._super(a),b.classes.add("widget").add("label"),b.canFocus=!1,a.multiline&&b.classes.add("autoscroll"),a.strong&&b.classes.add("strong")},initLayoutRect:function(){var a=this,c=a._super();if(a.settings.multiline){var d=b.getSize(a.getEl());d.width>c.maxW&&(c.minW=c.maxW,a.classes.add("multiline")),a.getEl().style.width=c.minW+"px",c.startMinH=c.h=c.minH=Math.min(c.maxH,b.getSize(a.getEl()).height)}return c},repaint:function(){var a=this;return a.settings.multiline||(a.getEl().style.lineHeight=a.layoutRect().h+"px"),a._super()},severity:function(a){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(a)},renderHtml:function(){var a,b,c=this,d=c.settings.forId,e=c.settings.html?c.settings.html:c.encode(c.state.get("text"));return!d&&(b=c.settings.forName)&&(a=c.getRoot().find("#"+b)[0],a&&(d=a._id)),d?'":''+e+""},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.innerHtml(a.encode(b.value)),a.state.get("rendered")&&a.updateLayoutRect()}),a._super()}})}),g("2o",["z"],function(a){"use strict";return a.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(a){var b=this;b._super(a),b.classes.add("toolbar")},postRender:function(){var a=this;return a.items().each(function(a){a.classes.add("toolbar-item")}),a._super()}})}),g("20",["2o"],function(a){"use strict";return a.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})}),g("21",["1","d","r","20"],function(a,b,c,d){"use strict";function e(a,b){for(;a;){if(b===a)return!0;a=a.parentNode}return!1}var f=c.extend({init:function(a){var b=this;b._renderOpen=!0,b._super(a),a=b.settings,b.classes.add("menubtn"),a.fixedWidth&&b.classes.add("fixed-width"),b.aria("haspopup",!0),b.state.set("menu",a.menu||b.render())},showMenu:function(a){var c,d=this;return d.menu&&d.menu.visible()&&a!==!1?d.hideMenu():(d.menu||(c=d.state.get("menu")||[],d.classes.add("opened"),c.length?c={type:"menu",animate:!0,items:c}:(c.type=c.type||"menu",c.animate=!0),c.renderTo?d.menu=c.parent(d).show().renderTo():d.menu=b.create(c).parent(d).renderTo(),d.fire("createmenu"),d.menu.reflow(),d.menu.on("cancel",function(a){a.control.parent()===d.menu&&(a.stopPropagation(),d.focus(),d.hideMenu())}),d.menu.on("select",function(){d.focus()}),d.menu.on("show hide",function(a){a.control===d.menu&&(d.activeMenu("show"==a.type),d.classes.toggle("opened","show"==a.type)),d.aria("expanded","show"==a.type)}).fire("show")),d.menu.show(),d.menu.layoutRect({w:d.layoutRect().w}),d.menu.moveRel(d.getEl(),d.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]),void d.fire("showmenu"))},hideMenu:function(){var a=this;a.menu&&(a.menu.items().each(function(a){a.hideMenu&&a.hideMenu()}),a.menu.hide())},activeMenu:function(a){this.classes.toggle("active",a)},renderHtml:function(){var b,c=this,e=c._id,f=c.classPrefix,g=c.settings.icon,h=c.state.get("text"),i="";return b=c.settings.image,b?(g="none","string"!=typeof b&&(b=a.getSelection?b[0]:b[1]),b=" style=\"background-image: url('"+b+"')\""):b="",h&&(c.classes.add("btn-has-text"),i=''+c.encode(h)+""),g=c.settings.icon?f+"ico "+f+"i-"+g:"",c.aria("role",c.parent()instanceof d?"menuitem":"button"),'
          '},postRender:function(){var a=this;return a.on("click",function(b){b.control===a&&e(b.target,a.getEl())&&(a.focus(),a.showMenu(!b.aria),b.aria&&a.menu.items().filter(":visible")[0].focus())}),a.on("mouseenter",function(b){var c,d=b.control,e=a.parent();d&&e&&d instanceof f&&d.parent()==e&&(e.items().filter("MenuButton").each(function(a){a.hideMenu&&a!=d&&(a.menu&&a.menu.visible()&&(c=!0),a.hideMenu())}),c&&(d.focus(),d.showMenu()))}),a._super()},bindStates:function(){var a=this;return a.state.on("change:menu",function(){a.menu&&a.menu.remove(),a.menu=null}),a._super()},remove:function(){this._super(),this.menu&&this.menu.remove()}});return f}),g("22",["1h","d","1g","2r"],function(a,b,c,d){"use strict";var e=function(a,b){var c=a._textStyle;if(c){var d=a.getEl("text");d.setAttribute("style",c),b&&(d.style.color="",d.style.backgroundColor="")}};return a.extend({Defaults:{border:0,role:"menuitem"},init:function(a){var b,c=this;c._super(a),a=c.settings,c.classes.add("menu-item"),a.menu&&c.classes.add("menu-item-expand"),a.preview&&c.classes.add("menu-item-preview"),b=c.state.get("text"),"-"!==b&&"|"!==b||(c.classes.add("menu-item-sep"),c.aria("role","separator"),c.state.set("text","-")),a.selectable&&(c.aria("role","menuitemcheckbox"),c.classes.add("menu-item-checkbox"),a.icon="selected"),a.preview||a.selectable||c.classes.add("menu-item-normal"),c.on("mousedown",function(a){a.preventDefault()}),a.menu&&!a.ariaHideMenu&&c.aria("haspopup",!0)},hasMenus:function(){return!!this.settings.menu},showMenu:function(){var a,c=this,d=c.settings,e=c.parent();if(e.items().each(function(a){a!==c&&a.hideMenu()}),d.menu){a=c.menu,a?a.show():(a=d.menu,a.length?a={type:"menu",animate:!0,items:a}:(a.type=a.type||"menu",a.animate=!0),e.settings.itemDefaults&&(a.itemDefaults=e.settings.itemDefaults),a=c.menu=b.create(a).parent(c).renderTo(),a.reflow(),a.on("cancel",function(b){b.stopPropagation(),c.focus(),a.hide()}),a.on("show hide",function(a){a.control.items&&a.control.items().each(function(a){a.active(a.settings.selected)})}).fire("show"),a.on("hide",function(b){b.control===a&&c.classes.remove("selected")}),a.submenu=!0),a._parentMenu=e,a.classes.add("menu-sub");var f=a.testMoveRel(c.getEl(),c.isRtl()?["tl-tr","bl-br","tr-tl","br-bl"]:["tr-tl","br-bl","tl-tr","bl-br"]);a.moveRel(c.getEl(),f),a.rel=f,f="menu-sub-"+f,a.classes.remove(a._lastRel).add(f),a._lastRel=f,c.classes.add("selected"),c.aria("expanded",!0)}},hideMenu:function(){var a=this;return a.menu&&(a.menu.items().each(function(a){a.hideMenu&&a.hideMenu()}),a.menu.hide(),a.aria("expanded",!1)),a},renderHtml:function(){function a(a){var b,d,e={};for(e=c.mac?{alt:"⌥",ctrl:"⌘",shift:"⇧",meta:"⌘"}:{meta:"Ctrl"},a=a.split("+"),b=0;b").replace(new RegExp(b("]mce~match!"),"g"),"")}var f=this,g=f._id,h=f.settings,i=f.classPrefix,j=f.state.get("text"),k=f.settings.icon,l="",m=h.shortcut,n=f.encode(h.url),o="";return k&&f.parent().classes.add("menu-has-icons"),h.image&&(l=" style=\"background-image: url('"+h.image+"')\""),m&&(m=a(m)),k=i+"ico "+i+"i-"+(f.settings.icon||"none"),o="-"!==j?'\xa0":"",j=e(f.encode(d(j))),n=e(f.encode(d(n))),'
          '+o+("-"!==j?''+j+"":"")+(m?'
          '+m+"
          ":"")+(h.menu?'
          ':"")+(n?'":"")+"
          "},postRender:function(){var a=this,b=a.settings,c=b.textStyle;if("function"==typeof c&&(c=c.call(this)),c){var e=a.getEl("text");e&&(e.setAttribute("style",c),a._textStyle=c)}return a.on("mouseenter click",function(c){c.control===a&&(b.menu||"click"!==c.type?(a.showMenu(),c.aria&&a.menu.focus(!0)):(a.fire("select"),d.requestAnimationFrame(function(){a.parent().hideAll()})))}),a._super(),a},hover:function(){var a=this;return a.parent().items().each(function(a){a.classes.remove("selected")}),a.classes.toggle("selected",!0),a},active:function(a){return e(this,a),"undefined"!=typeof a&&this.aria("checked",a),this._super(a)},remove:function(){this._super(),this.menu&&this.menu.remove()}})}),g("2n",["31","10","2r"],function(a,b,c){"use strict";return function(d,e){var f,g,h=this,i=b.classPrefix;h.show=function(b,j){function k(){f&&(a(d).append('
          '),j&&j())}return h.hide(),f=!0,b?g=c.setTimeout(k,b):k(),h},h.hide=function(){var a=d.lastChild;return c.clearTimeout(g),a&&a.className.indexOf("throbber")!=-1&&a.parentNode.removeChild(a),f=!1,h}}}),g("1z",["1g","2r","e","18","22","2n"],function(a,b,c,d,e,f){"use strict";return d.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(b){var d=this;if(b.autohide=!0,b.constrainToViewport=!0,"function"==typeof b.items&&(b.itemsFactory=b.items,b.items=[]),b.itemDefaults)for(var e=b.items,f=e.length;f--;)e[f]=c.extend({},b.itemDefaults,e[f]);d._super(b),d.classes.add("menu"),b.animate&&11!==a.ie&&d.classes.add("animate")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var a=this;a.hideAll(),a.fire("select")},load:function(){function a(){d.throbber&&(d.throbber.hide(),d.throbber=null)}var b,c,d=this;c=d.settings.itemsFactory,c&&(d.throbber||(d.throbber=new f(d.getEl("body"),!0),0===d.items().length?(d.throbber.show(),d.fire("loading")):d.throbber.show(100,function(){d.items().remove(),d.fire("loading")}),d.on("hide close",a)),d.requestTime=b=(new Date).getTime(),d.settings.itemsFactory(function(c){return 0===c.length?void d.hide():void(d.requestTime===b&&(d.getEl().style.width="",d.getEl("body").style.width="",a(),d.items().remove(),d.getEl("body").innerHTML="",d.add(c),d.renderNew(),d.fire("loaded")))}))},hideAll:function(){var a=this;return this.find("menuitem").exec("hideMenu"),a._super()},preRender:function(){var a=this;return a.items().each(function(b){var c=b.settings;if(c.icon||c.image||c.selectable)return a._hasIcons=!0,!1}),a.settings.itemsFactory&&a.on("postrender",function(){a.settings.itemsFactory&&a.load()}),a.on("show hide",function(c){c.control===a&&("show"===c.type?b.setTimeout(function(){a.classes.add("in")},0):a.classes.remove("in"))}),a._super()}})}),g("1y",["21","1z"],function(a,b){"use strict";return a.extend({init:function(a){function b(c){for(var f=0;f0&&(e=c[0].text,g.state.set("value",c[0].value)),g.state.set("menu",c)),g.state.set("text",a.text||e),g.classes.add("listbox"),g.on("select",function(b){var c=b.control;f&&(b.lastControl=f),a.multiple?c.active(!c.active()):g.value(b.control.value()),f=c})},bindStates:function(){function a(a,c){a instanceof b&&a.items().each(function(a){a.hasMenus()||a.active(a.value()===c)})}function c(a,b){var d;if(a)for(var e=0;e'},postRender:function(){var a=this;a._super(),a.resizeDragHelper=new b(this._id,{start:function(){a.fire("ResizeStart")},drag:function(b){"both"!=a.settings.direction&&(b.deltaX=0),a.fire("Resize",b)},stop:function(){a.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})}),g("2f",["1h"],function(a){"use strict";function b(a){var b="";if(a)for(var c=0;c'+a[c]+"";return b}return a.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(a){var b=this;b._super(a),b.settings.size&&(b.size=b.settings.size),b.settings.options&&(b._options=b.settings.options),b.on("keydown",function(a){var c;13==a.keyCode&&(a.preventDefault(),b.parents().reverse().each(function(a){if(a.toJSON)return c=a,!1}),b.fire("submit",{data:c.toJSON()}))})},options:function(a){return arguments.length?(this.state.set("options",a),this):this.state.get("options")},renderHtml:function(){var a,c=this,d="";return a=b(c._options),c.size&&(d=' size = "'+c.size+'"'),'"},bindStates:function(){var a=this;return a.state.on("change:options",function(c){a.getEl().innerHTML=b(c.value)}),a._super()}})}),g("2h",["1h","11","30"],function(a,b,c){"use strict";function d(a,b,c){return ac&&(a=c),a}function e(a,b,c){a.setAttribute("aria-"+b,c)}function f(a,b){var d,f,g,h,i,j;"v"==a.settings.orientation?(h="top",g="height",f="h"):(h="left",g="width",f="w"),j=a.getEl("handle"),d=(a.layoutRect()[f]||100)-c.getSize(j)[g],i=d*((b-a._minValue)/(a._maxValue-a._minValue))+"px",j.style[h]=i,j.style.height=a.layoutRect().h+"px",e(j,"valuenow",b),e(j,"valuetext",""+a.settings.previewFilter(b)),e(j,"valuemin",a._minValue),e(j,"valuemax",a._maxValue)}return a.extend({init:function(a){var b=this;a.previewFilter||(a.previewFilter=function(a){return Math.round(100*a)/100}),b._super(a),b.classes.add("slider"),"v"==a.orientation&&b.classes.add("vertical"),b._minValue=a.minValue||0,b._maxValue=a.maxValue||100,b._initValue=b.state.get("value")},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix;return'
          '},reset:function(){this.value(this._initValue).repaint()},postRender:function(){function a(a,b,c){return(c+a)/(b-a)}function e(a,b,c){return c*(b-a)-a}function f(b,c){function f(f){var g;g=n.value(),g=e(b,c,a(b,c,g)+.05*f),g=d(g,b,c),n.value(g),n.fire("dragstart",{value:g}),n.fire("drag",{value:g}),n.fire("dragend",{value:g})}n.on("keydown",function(a){switch(a.keyCode){case 37:case 38:f(-1);break;case 39:case 40:f(1)}})}function g(a,e,f){var g,h,i,o,p;n._dragHelper=new b(n._id,{handle:n._id+"-handle",start:function(a){g=a[j],h=parseInt(n.getEl("handle").style[k],10),i=(n.layoutRect()[m]||100)-c.getSize(f)[l],n.fire("dragstart",{value:p})},drag:function(b){var c=b[j]-g;o=d(h+c,0,i),f.style[k]=o+"px",p=a+o/i*(e-a),n.value(p),n.tooltip().text(""+n.settings.previewFilter(p)).show().moveRel(f,"bc tc"),n.fire("drag",{value:p})},stop:function(){n.tooltip().hide(),n.fire("dragend",{value:p})}})}var h,i,j,k,l,m,n=this;h=n._minValue,i=n._maxValue,"v"==n.settings.orientation?(j="screenY",k="top",l="height",m="h"):(j="screenX",k="left",l="width",m="w"),n._super(),f(h,i,n.getEl("handle")),g(h,i,n.getEl("handle"))},repaint:function(){this._super(),f(this,this.value())},bindStates:function(){var a=this;return a.state.on("change:value",function(b){f(a,b.value)}),a._super()}})}),g("2i",["1h"],function(a){"use strict";return a.extend({renderHtml:function(){var a=this;return a.classes.add("spacer"),a.canFocus=!1,'
          '}})}),g("2j",["1","31","30","21"],function(a,b,c,d){return d.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var a,d,e=this,f=e.getEl(),g=e.layoutRect();return e._super(),a=f.firstChild,d=f.lastChild,b(a).css({width:g.w-c.getSize(d).width,height:g.h-2}),b(d).css({height:g.h-2}),e},activeMenu:function(a){var c=this;b(c.getEl().lastChild).toggleClass(c.classPrefix+"active",a)},renderHtml:function(){var b,c,d=this,e=d._id,f=d.classPrefix,g=d.state.get("icon"),h=d.state.get("text"),i=d.settings,j="";return b=i.image,b?(g="none","string"!=typeof b&&(b=a.getSelection?b[0]:b[1]),b=" style=\"background-image: url('"+b+"')\""):b="",g=i.icon?f+"ico "+f+"i-"+g:"",h&&(d.classes.add("btn-has-text"),j=''+d.encode(h)+""),c="boolean"==typeof i.active?' aria-pressed="'+i.active+'"':"",'
          '},postRender:function(){var a=this,b=a.settings.onclick;return a.on("click",function(a){var c=a.target;if(a.control==this)for(;c;){if(a.aria&&"down"!=a.aria.key||"BUTTON"==c.nodeName&&c.className.indexOf("open")==-1)return a.stopImmediatePropagation(),void(b&&b.call(this,a));c=c.parentNode}}),delete a.settings.onclick,a._super()}})}),g("2k",["19"],function(a){"use strict";return a.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}})}),g("2l",["26","31","30"],function(a,b,c){"use strict";return a.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(a){var c;this.activeTabId&&(c=this.getEl(this.activeTabId),b(c).removeClass(this.classPrefix+"active"),c.setAttribute("aria-selected","false")),this.activeTabId="t"+a,c=this.getEl("t"+a),c.setAttribute("aria-selected","true"),b(c).addClass(this.classPrefix+"active"),this.items()[a].show().fire("showtab"),this.reflow(),this.items().each(function(b,c){a!=c&&b.hide()})},renderHtml:function(){var a=this,b=a._layout,c="",d=a.classPrefix;return a.preRender(),b.preRender(a),a.items().each(function(b,e){var f=a._id+"-t"+e;b.aria("role","tabpanel"),b.aria("labelledby",f),c+='"}),'
          '+c+'
          '+b.renderHtml(a)+"
          "},postRender:function(){var a=this;a._super(),a.settings.activeTab=a.settings.activeTab||0,a.activateTab(a.settings.activeTab),this.on("click",function(b){var c=b.target.parentNode;if(c&&c.id==a._id+"-head")for(var d=c.childNodes.length;d--;)c.childNodes[d]==b.target&&a.activateTab(d)})},initLayoutRect:function(){var a,b,d,e=this;b=c.getSize(e.getEl("head")).width,b=b<0?0:b,d=0,e.items().each(function(a){b=Math.max(b,a.layoutRect().minW),d=Math.max(d,a.layoutRect().minH)}),e.items().each(function(a){a.settings.x=0,a.settings.y=0,a.settings.w=b,a.settings.h=d,a.layoutRect({x:0,y:0,w:b,h:d})});var f=c.getSize(e.getEl("head")).height;return e.settings.minWidth=b,e.settings.minHeight=d+f,a=e._super(),a.deltaH+=f,a.innerH=a.h-a.deltaH,a}})}),g("2m",["1e","e","30","1h"],function(a,b,c,d){return d.extend({init:function(a){var b=this;b._super(a),b.classes.add("textbox"),a.multiline?b.classes.add("multiline"):(b.on("keydown",function(a){var c;13==a.keyCode&&(a.preventDefault(),b.parents().reverse().each(function(a){if(a.toJSON)return c=a,!1}),b.fire("submit",{data:c.toJSON()}))}),b.on("keyup",function(a){b.state.set("value",a.target.value)}))},repaint:function(){var b,c,d,e,f,g=this,h=0;b=g.getEl().style,c=g._layoutRect,f=g._lastRepaintRect||{};var i=a;return!g.settings.multiline&&i.all&&(!i.documentMode||i.documentMode<=8)&&(b.lineHeight=c.h-h+"px"),d=g.borderBox,e=d.left+d.right+8,h=d.top+d.bottom+(g.settings.multiline?8:0),c.x!==f.x&&(b.left=c.x+"px",f.x=c.x),c.y!==f.y&&(b.top=c.y+"px",f.y=c.y),c.w!==f.w&&(b.width=c.w-e+"px",f.w=c.w),c.h!==f.h&&(b.height=c.h-h+"px",f.h=c.h),g._lastRepaintRect=f,g.fire("repaint",{},!1),g},renderHtml:function(){var a,d,e=this,f=e.settings;return a={id:e._id,hidefocus:"1"},b.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(b){a[b]=f[b]}),e.disabled()&&(a.disabled="disabled"),f.subtype&&(a.type=f.subtype),d=c.create(f.multiline?"textarea":"input",a),d.value=e.state.get("value"),d.className=e.classes,d.outerHTML},value:function(a){return arguments.length?(this.state.set("value",a),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var a=this;a.getEl().value=a.state.get("value"),a._super(),a.$el.on("change",function(b){a.state.set("value",b.target.value),a.fire("change",b)})},bindStates:function(){var a=this;return a.state.on("change:value",function(b){a.getEl().value!=b.value&&(a.getEl().value=b.value)}),a.state.on("change:disabled",function(b){a.getEl().disabled=b.value}),a._super()},remove:function(){this.$el.off(),this._super()}})}),g("6",["d","e","p","q","r","s","t","u","v","w","x","y","z","10","11","12","13","14","15","16","17","18","19","1a","7","1r","1s","1t","1u","1v","1w","1x","1y","1z","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","2g","2h","2i","2j","2k","2l","2m","2n","2o","2p","1h","2q"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha){var ia=function(){return{Selector:Y,Collection:h,ReflowQueue:T,Control:n,Factory:a,KeyboardNavigation:D,Container:m,DragHelper:o,Scrollable:W,Panel:O,Movable:M,Resizable:U,FloatPanel:v,Window:ha,MessageBox:L,Tooltip:fa,Widget:ga,Progress:R,Notification:N,Layout:F,AbsoluteLayout:c,Button:e,ButtonGroup:f,Checkbox:g,ComboBox:l,ColorBox:i,PanelButton:P,ColorButton:j,ColorPicker:k,Path:Q,ElementPath:q,FormItem:z,Form:x,FieldSet:r,FilePicker:s,FitLayout:t,FlexLayout:u,FlowLayout:w,FormatControls:y,GridLayout:A,Iframe:B,InfoBox:C,Label:E,Toolbar:ea,MenuBar:I,MenuButton:J,MenuItem:K,Throbber:da,Menu:H,ListBox:G,Radio:S,ResizeHandle:V,SelectBox:X,Slider:Z,Spacer:$,SplitButton:_,StackLayout:aa,TabPanel:ba,TextBox:ca,DropZone:p,BrowseButton:d}},ja=function(a){a.ui?b.each(ia(),function(b,c){a.ui[c]=b}):a.ui=ia()},ka=function(){b.each(ia(),function(b,c){a.add(c,b)})},la={appendTo:ja,registerToFactory:ka};return la}),g("0",["1","2","3","4","5","6","7"],function(a,b,c,d,e,f,g){return f.registerToFactory(),f.appendTo(a.tinymce?a.tinymce:{}),b.add("inlite",function(a){var b=new e;return g.setup(a),d.addToEditor(a,b),c.get(a,b)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/themes/mobile/theme.min.js b/frontend/public/static/js/tinymce/js/tinymce/themes/mobile/theme.min.js new file mode 100644 index 0000000..05f9c92 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/themes/mobile/theme.min.js @@ -0,0 +1,8 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("1d",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("2r",["y","z","a","1d","v","1b"],function(a,b,c,d,e,f){var g=d.ELEMENT,h=d.DOCUMENT,i=function(a,b){var c=a.dom();if(c.nodeType!==g)return!1;if(void 0!==c.matches)return c.matches(b);if(void 0!==c.msMatchesSelector)return c.msMatchesSelector(b);if(void 0!==c.webkitMatchesSelector)return c.webkitMatchesSelector(b);if(void 0!==c.mozMatchesSelector)return c.mozMatchesSelector(b);throw new e("Browser lacks native selectors")},j=function(a){return a.nodeType!==g&&a.nodeType!==h||0===a.childElementCount},k=function(b,d){var e=void 0===d?f:d.dom();return j(e)?[]:a.map(e.querySelectorAll(b),c.fromDom)},l=function(a,d){var e=void 0===d?f:d.dom();return j(e)?b.none():b.from(e.querySelector(a)).map(c.fromDom)};return{all:k,is:i,one:l}}),g("1a",["y","6","2q","7","2r"],function(a,b,c,d,e){var f=function(a,b){return a.dom()===b.dom()},g=function(a,b){return a.dom().isEqualNode(b.dom())},h=function(c,d){return a.exists(d,b.curry(f,c))},i=function(a,b){var c=a.dom(),d=b.dom();return c!==d&&c.contains(d)},j=function(a,b){return c.documentPositionContainedBy(a.dom(),b.dom())},k=d.detect().browser,l=k.isIE()?j:i;return{eq:f,isEqualNode:g,member:h,contains:l,is:e.is}}),g("43",["1a"],function(a){var b=function(b,c){return a.eq(b.element(),c.event().target())};return{isSource:b}}),g("2g",["6"],function(a){return{contextmenu:a.constant("contextmenu"),touchstart:a.constant("touchstart"),touchmove:a.constant("touchmove"),touchend:a.constant("touchend"),gesturestart:a.constant("gesturestart"),mousedown:a.constant("mousedown"),mousemove:a.constant("mousemove"),mouseout:a.constant("mouseout"),mouseup:a.constant("mouseup"),mouseover:a.constant("mouseover"),focusin:a.constant("focusin"),keydown:a.constant("keydown"),input:a.constant("input"),change:a.constant("change"),focus:a.constant("focus"),click:a.constant("click"),transitionend:a.constant("transitionend"),selectstart:a.constant("selectstart")}}),g("t",["2g","6","7"],function(a,b,c){var d={tap:b.constant("alloy.tap")};return{focus:b.constant("alloy.focus"),postBlur:b.constant("alloy.blur.post"),receive:b.constant("alloy.receive"),execute:b.constant("alloy.execute"),focusItem:b.constant("alloy.focus.item"),tap:d.tap,tapOrClick:c.detect().deviceType.isTouch()?d.tap:a.click,longpress:b.constant("alloy.longpress"),sandboxClose:b.constant("alloy.sandbox.close"),systemInit:b.constant("alloy.system.init"),windowScroll:b.constant("alloy.system.scroll"),attachedToDom:b.constant("alloy.system.attached"),detachedFromDom:b.constant("alloy.system.detached"),changeTab:b.constant("alloy.change.tab"),dismissTab:b.constant("alloy.dismiss.tab")}}),g("1i",["u","2m"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("w",["1i","u","v"],function(a,b,c){var d=function(a,b){return b},e=function(b,c){var d=a.isObject(b)&&a.isObject(c);return d?g(b,c):c},f=function(a){return function(){for(var d=new b(arguments.length),e=0;e0?g(c.errors):f(c.values,b)},i=function(a){var b=e.partition(a);return b.errors.length>0?g(b.errors):d.value(b.values)};return{consolidateObj:h,consolidateArr:i}}),g("2b",["y","x"],function(a,b){var c=function(b,c){var d={};return a.each(c,function(a){void 0!==b[a]&&b.hasOwnProperty(a)&&(d[a]=b[a])}),d},d=function(b,c){var d={};return a.each(b,function(a){var b=a[c];d[b]=a}),d},e=function(c,d){var e={};return b.each(c,function(b,c){a.contains(d,c)||(e[c]=b)}),e};return{narrow:c,exclude:e,indexOnKey:d}}),g("2c",["z"],function(a){var b=function(b){return function(c){return c.hasOwnProperty(b)?a.from(c[b]):a.none()}},c=function(a,c){return function(d){return b(a)(d).getOr(c)}},d=function(a,c){return b(c)(a)},e=function(a,b){return a.hasOwnProperty(b)&&void 0!==a[b]&&null!==a[b]};return{readOpt:b,readOr:c,readOptFrom:d,hasKey:e}}),g("2d",["y"],function(a){var b=function(a,b){var c={};return c[a]=b,c},c=function(b){var c={};return a.each(b,function(a){c[a.key]=a.value}),c};return{wrap:b,wrapAll:c}}),g("14",["2a","2b","2c","2d"],function(a,b,c,d){var e=function(a,c){return b.narrow(a,c)},f=function(a,c){return b.exclude(a,c)},g=function(a){return c.readOpt(a)},h=function(a,b){return c.readOr(a,b)},i=function(a,b){return c.readOptFrom(a,b)},j=function(a,b){return d.wrap(a,b)},k=function(a){return d.wrapAll(a)},l=function(a,c){return b.indexOnKey(a,c)},m=function(b,c){return a.consolidateObj(b,c)},n=function(a,b){return c.hasKey(a,b)};return{narrow:e,exclude:f,readOpt:g,readOr:h,readOptFrom:i,wrap:j,wrapAll:k,indexOnKey:l,hasKey:n,consolidate:m}}),g("6n",["4m"],function(a){var b=function(){return a.getOrDie("JSON")},c=function(a){return b().parse(a)},d=function(a,c,d){return b().stringify(a,c,d)};return{parse:c,stringify:d}}),g("4f",["y","x","1i","6n"],function(a,b,c,d){var e=function(a){return c.isObject(a)&&b.keys(a).length>100?" removed due to size":d.stringify(a,null,2)},f=function(b){var c=b.length>10?b.slice(0,10).concat([{path:[],getErrorInfo:function(){return"... (only showing first ten failures)"}}]):b;return a.map(c,function(a){return"Failed path: ("+a.path.join(" > ")+")\n"+a.getErrorInfo()})};return{formatObj:e,formatErrors:f}}),g("6l",["4f","48"],function(a,b){var c=function(a,c){return b.error([{path:a,getErrorInfo:c}])},d=function(b,d,e){return c(b,function(){return'Could not find valid *strict* value for "'+d+'" in '+a.formatObj(e)})},e=function(a,b){return c(a,function(){return'Choice schema did not contain choice key: "'+b+'"'})},f=function(b,d,e){return c(b,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+a.formatObj(d)})},g=function(a,b){return c(a,function(){return"There are unsupported fields: ["+b.join(", ")+"] specified"})},h=function(a,b){return c(a,function(){return b})},i=function(a){return"Failed path: ("+a.path.join(" > ")+")\n"+a.getErrorInfo()};return{missingStrict:d,missingKey:e,missingBranch:f,unsupportedFields:g,custom:h,toString:i}}),g("6m",["6k"],function(a){var b=a.generate([{setOf:["validator","valueType"]},{arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branches"]}]),c=a.generate([{field:["name","presence","type"]},{state:["name"]}]);return{typeAdt:b,fieldAdt:c}}),g("4d",["4c","14","2a","2c","2d","6l","6m","6k","y","6","w","x","z","48","1i"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=h.generate([{field:["key","okey","presence","prop"]},{state:["okey","instantiator"]}]),q=function(a,b){return p.state(a,j.constant(b))},r=function(a){return p.state(a,j.identity)},s=function(a,b,c){return d.readOptFrom(b,c).fold(function(){return f.missingStrict(a,c,b)},n.value)},t=function(a,b,c){var e=d.readOptFrom(a,b).fold(function(){return c(a)},j.identity);return n.value(e)},u=function(a,b){return n.value(d.readOptFrom(a,b))},v=function(a,b,c){var e=d.readOptFrom(a,b).map(function(b){return b===!0?c(a):b});return n.value(e)},w=function(a,b,c,d){return c.fold(function(c,f,g,h){var i=function(b){return h.extract(a.concat([c]),d,b).map(function(a){return e.wrap(f,d(a))})},l=function(b){return b.fold(function(){var a=e.wrap(f,d(m.none()));return n.value(a)},function(b){return h.extract(a.concat([c]),d,b).map(function(a){return e.wrap(f,d(m.some(a)))})})};return function(){return g.fold(function(){return s(a,b,c).bind(i)},function(a){return t(b,c,a).bind(i)},function(){return u(b,c).bind(l)},function(a){return v(b,c,a).bind(l)},function(a){var d=a(b);return t(b,c,j.constant({})).map(function(a){return k.deepMerge(d,a)}).bind(i)})}()},function(a,c){var f=c(b);return n.value(e.wrap(a,d(f)))})},x=function(a,b,d,e){var f=i.map(d,function(c){return w(a,b,c,e)});return c.consolidateObj(f,{})},y=function(a){var b=function(b,c,d){return a(d).fold(function(a){return f.custom(b,a)},n.value)},c=function(){return"val"},d=function(){return g.typeAdt.itemOf(a)};return{extract:b,toString:c,toDsl:d}},z=function(a){var c=l.keys(a);return i.filter(c,function(c){return b.hasKey(a,c)})},A=function(a){var c=B(a),d=i.foldr(a,function(a,c){return c.fold(function(c){return k.deepMerge(a,b.wrap(c,!0))},j.constant(a))},{}),e=function(a,e,g){var h=o.isBoolean(g)?[]:z(g),j=i.filter(h,function(a){return!b.hasKey(d,a)});return 0===j.length?c.extract(a,e,g):f.unsupportedFields(a,j)};return{extract:e,toString:c.toString,toDsl:c.toDsl}},B=function(a){var b=function(b,c,d){return x(b,d,a,c)},c=function(){var b=i.map(a,function(a){return a.fold(function(a,b,c,d){return a+" -> "+d.toString()},function(a,b){return"state("+a+")"})});return"obj{\n"+b.join("\n")+"}"},d=function(){return g.typeAdt.objOf(i.map(a,function(a){return a.fold(function(a,b,c,d){return g.fieldAdt.field(a,c,d)},function(a,b){return g.fieldAdt.state(a)})}))};return{extract:b,toString:c,toDsl:d}},C=function(a){var b=function(b,d,e){var f=i.map(e,function(c,e){return a.extract(b.concat(["["+e+"]"]),d,c)});return c.consolidateArr(f)},d=function(){return"array("+a.toString()+")"},e=function(){return g.typeAdt.arrOf(a)};return{extract:b,toString:d,toDsl:e}},D=function(b,c){var d=function(a,c){return C(y(b)).extract(a,j.identity,c)},e=function(b,e,f){var g=l.keys(f);return d(b,g).bind(function(d){var g=i.map(d,function(b){return p.field(b,b,a.strict(),c)});return B(g).extract(b,e,f)})},f=function(){return"setOf("+c.toString()+")"},h=function(){return g.typeAdt.setOf(b,c)};return{extract:e,toString:f,toDsl:h}},E=y(n.value),F=j.compose(C,B);return{anyValue:j.constant(E),value:y,obj:B,objOnly:A,arr:C,setOf:D,arrOfObj:F,state:p.state,field:p.field,output:q,snapshot:r}}),g("29",["4c","4d","48","1i"],function(a,b,c,d){var e=function(c){return b.field(c,c,a.strict(),b.anyValue())},f=function(c,d){return b.field(c,c,a.strict(),d)},g=function(e){return b.field(e,e,a.strict(),b.value(function(a){return d.isFunction(a)?c.value(a):c.error("Not a function")}))},h=function(d,e){return b.field(d,d,a.asOption(),b.value(function(a){return c.error("The field: "+d+" is forbidden. "+e)}))},i=function(a,b){return f(a,b)},j=function(c,d){return b.field(c,c,a.strict(),b.obj(d))},k=function(c,d){return b.field(c,c,a.strict(),b.arrOfObj(d))},l=function(c){return b.field(c,c,a.asOption(),b.anyValue())},m=function(c,d){return b.field(c,c,a.asOption(),d)},n=function(c,d){return b.field(c,c,a.asOption(),b.obj(d))},o=function(c,d){return b.field(c,c,a.asOption(),b.objOnly(d))},p=function(c,d){return b.field(c,c,a.defaulted(d),b.anyValue())},q=function(c,d,e){return b.field(c,c,a.defaulted(d),e)},r=function(c,d,e){return b.field(c,c,a.defaulted(d),b.obj(e))},s=function(a,c,d,e){return b.field(a,c,d,e)},t=function(a,c){return b.state(a,c)};return{strict:e,strictOf:f,strictObjOf:j,strictArrayOf:i,strictArrayOfObj:k,strictFunction:g,forbid:h,option:l,optionOf:m,optionObjOf:n,optionObjOfOnly:o,defaulted:p,defaultedOf:q,defaultedObjOf:r,field:s,state:t}}),g("4e",["14","6l","4d","6m","x"],function(a,b,c,d,e){var f=function(d,e,f,g,h){var i=a.readOptFrom(g,h);return i.fold(function(){return b.missingBranch(d,g,h)},function(a){return c.obj(a).extract(d.concat(["branch: "+h]),e,f)})},g=function(c,g){var h=function(d,e,h){var i=a.readOptFrom(h,c);return i.fold(function(){return b.missingKey(d,c)},function(a){return f(d,e,h,g,a)})},i=function(){return"chooseOn("+c+"). Possible values: "+e.keys(g)},j=function(){return d.typeAdt.choiceOf(c,g)};return{extract:h,toString:i,toDsl:j}};return{choose:g}}),g("2e",["4e","4d","4f","6","48","v"],function(a,b,c,d,e,f){var g=b.value(e.value),h=function(a){return b.arrOfObj(a)},i=function(){return b.arr(g)},j=b.arr,k=b.obj,l=b.objOnly,m=b.setOf,n=function(a){return b.value(a)},o=function(a,b,c,d){return b.extract([a],c,d).fold(function(a){return e.error({input:d,errors:a})},e.value)},p=function(a,b,c){return o(a,b,d.constant,c)},q=function(a,b,c){return o(a,b,d.identity,c)},r=function(a){return a.fold(function(a){throw new f(u(a))},d.identity)},s=function(a,b,c){return r(q(a,b,c))},t=function(a,b,c){return r(p(a,b,c))},u=function(a){return"Errors: \n"+c.formatErrors(a.errors)+"\n\nInput object: "+c.formatObj(a.input)},v=function(b,c){return a.choose(b,c)};return{anyValue:d.constant(g),arrOfObj:h,arrOf:j,arrOfVal:i,valueOf:n,setOf:m,objOf:k,objOfOnly:l,asStruct:p,asRaw:q,asStructOrDie:t,asRawOrDie:s,getOrDie:r,formatError:u,choose:v}}),g("47",["29","14","2e","1i","y","6n","6","u","v"],function(a,b,c,d,e,f,g,h,i){var j=function(d){if(!b.hasKey(d,"can")&&!b.hasKey(d,"abort")&&!b.hasKey(d,"run"))throw new i("EventHandler defined by: "+f.stringify(d,null,2)+" does not have can, abort, or run!");return c.asRawOrDie("Extracting event.handler",c.objOfOnly([a.defaulted("can",g.constant(!0)),a.defaulted("abort",g.constant(!1)),a.defaulted("run",g.noop)]),d)},k=function(a,b){return function(){var c=h.prototype.slice.call(arguments,0);return e.foldl(a,function(a,d){return a&&b(d).apply(void 0,c)},!0)}},l=function(a,b){return function(){var c=h.prototype.slice.call(arguments,0);return e.foldl(a,function(a,d){return a||b(d).apply(void 0,c)},!1)}},m=function(a){ +return d.isFunction(a)?{can:g.constant(!0),abort:g.constant(!1),run:a}:a},n=function(a){var b=k(a,function(a){return a.can}),c=l(a,function(a){return a.abort}),d=function(){var b=h.prototype.slice.call(arguments,0);e.each(a,function(a){a.run.apply(void 0,b)})};return j({can:b,abort:c,run:d})};return{read:m,fuse:n,nu:j}}),g("3d",["43","2","t","47","14"],function(a,b,c,d,e){var f=e.wrapAll,g=function(a,b){return{key:a,value:d.nu({abort:b})}},h=function(a,b){return{key:a,value:d.nu({can:b})}},i=function(a){return{key:a,value:d.nu({run:function(a,b){b.event().prevent()}})}},j=function(a,b){return{key:a,value:d.nu({run:b})}},k=function(a,b,c){return{key:a,value:d.nu({run:function(a){b.apply(void 0,[a].concat(c))}})}},l=function(a){return function(b){return j(a,b)}},m=function(b){return function(c){return{key:b,value:d.nu({run:function(b,d){a.isSource(b,d)&&c(b,d)}})}}},n=function(a,c){return j(a,function(d,e){d.getSystem().getByUid(c).each(function(c){b.dispatchEvent(c,c.element(),a,e)})})},o=function(a,b,c){var d=b.partUids()[c];return n(a,d)},p=function(a,b){return j(a,function(a,c){a.getSystem().getByDom(c.event().target()).each(function(d){b(a,d,c)})})},q=function(a){return j(a,function(a,b){b.cut()})},r=function(a){return j(a,function(a,b){b.stop()})};return{derive:f,run:j,preventDefault:i,runActionExtra:k,runOnAttached:m(c.attachedToDom()),runOnDetached:m(c.detachedFromDom()),runOnInit:m(c.systemInit()),runOnExecute:l(c.execute()),redirectToUid:n,redirectToPart:o,runWithTarget:p,abort:g,can:h,cutter:q,stopper:r}}),g("4a",["z"],function(a){var b=function(a,b,c){return a},c=function(a,b){return a},d=function(a,b){return a},e=a.none;return{markAsBehaviourApi:b,markAsExtraApi:c,markAsSketchApi:d,getAnnotation:e}}),g("4k",["y","6","u","v"],function(a,b,c,d){return function(){var e=arguments;return function(){for(var f=new c(arguments.length),g=0;g0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("2o",["4k","4l"],function(a,b){return{immutable:a,immutableBag:b}}),g("6o",["6n","2o","2m"],function(a,b,c){var d=b.immutableBag(["tag"],["classes","attributes","styles","value","innerHtml","domChildren","defChildren"]),e=function(b){var c=f(b);return a.stringify(c,null,2)},f=function(a){return{tag:a.tag(),classes:a.classes().getOr([]),attributes:a.attributes().getOr({}),styles:a.styles().getOr({}),value:a.value().getOr(""),innerHtml:a.innerHtml().getOr(""),defChildren:a.defChildren().getOr(""),domChildren:a.domChildren().fold(function(){return""},function(a){return 0===a.length?"0 children, but still specified":c(a.length)})}};return{nu:d,defToStr:e,defToRaw:f}}),g("4b",["6o","14","y","x","w","6n","2o"],function(a,b,c,d,e,f,g){var h=["classes","attributes","styles","value","innerHtml","defChildren","domChildren"],i=g.immutableBag([],h),j=function(a){var b={},e=d.keys(a);return c.each(e,function(c){a[c].each(function(a){b[c]=a})}),i(b)},k=function(a){var b=l(a);return f.stringify(b,null,2)},l=function(a){return{classes:a.classes().getOr(""),attributes:a.attributes().getOr(""),styles:a.styles().getOr(""),value:a.value().getOr(""),innerHtml:a.innerHtml().getOr(""),defChildren:a.defChildren().getOr(""),domChildren:a.domChildren().fold(function(){return""},function(a){return 0===a.length?"0 children, but still specified":String(a.length)})}},m=function(a,c,d){return c.fold(function(){return d.fold(function(){return{}},function(c){return b.wrap(a,c)})},function(c){return d.fold(function(){return b.wrap(a,c)},function(c){return b.wrap(a,c)})})},n=function(c,d){var f=e.deepMerge({tag:c.tag(),classes:d.classes().getOr([]).concat(c.classes().getOr([])),attributes:e.merge(c.attributes().getOr({}),d.attributes().getOr({})),styles:e.merge(c.styles().getOr({}),d.styles().getOr({}))},d.innerHtml().or(c.innerHtml()).map(function(a){return b.wrap("innerHtml",a)}).getOr({}),m("domChildren",d.domChildren(),c.domChildren()),m("defChildren",d.defChildren(),c.defChildren()),d.value().or(c.value()).map(function(a){return b.wrap("value",a)}).getOr({}));return a.nu(f)};return{nu:i,derive:j,merge:n,modToStr:k,modToRaw:l}}),g("27",["3d","4a","4b","29","14","2e","6","w","x","z","17","u","16","v"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=function(b,c,d){return a.runOnExecute(function(a){d(a,b,c)})},p=function(b,c,d){return a.runOnInit(function(a,e){d(a,b,c)})},q=function(a,b,c,e,g,h){var i=f.objOfOnly(a),j=d.optionObjOf(b,[d.optionObjOfOnly("config",a)]);return u(i,j,b,c,e,g,h)},r=function(a,b,c,e,f,g){var h=a,i=d.optionObjOf(b,[d.optionOf("config",a)]);return u(h,i,b,c,e,f,g)},s=function(a,c,d){var e=function(b){var e=arguments;return b.config({name:g.constant(a)}).fold(function(){throw new n("We could not find any behaviour configuration for: "+a+". Using API: "+d)},function(a){var d=l.prototype.slice.call(e,1);return c.apply(void 0,[b,a.config,a.state].concat(d))})};return b.markAsBehaviourApi(e,d,c)},t=function(a){return{key:a,value:void 0}},u=function(a,d,l,m,n,o,p){var q=function(a){return e.hasKey(a,l)?a[l]():j.none()},r=i.map(n,function(a,b){return s(l,a,b)}),u=i.map(o,function(a,c){return b.markAsExtraApi(a,c)}),v=h.deepMerge(u,r,{revoke:g.curry(t,l),config:function(b){var c=f.asStructOrDie(l+"-config",a,b);return{key:l,value:{config:c,me:v,configAsRaw:k.cached(function(){return f.asRawOrDie(l+"-config",a,b)}),initialConfig:b,state:p}}},schema:function(){return d},exhibit:function(a,b){return q(a).bind(function(a){return e.readOptFrom(m,"exhibit").map(function(c){return c(b,a.config,a.state)})}).getOr(c.nu({}))},name:function(){return l},handlers:function(a){return q(a).bind(function(a){return e.readOptFrom(m,"events").map(function(b){return b(a.config,a.state)})}).getOr({})}});return v};return{executeEvent:o,loadEvent:p,create:q,createModes:r}}),g("6q",["y","6","x","1i","6p","v"],function(a,b,c,d,e,f){var g=function(a,b){return h(a,b,{validate:d.isFunction,label:"function"})},h=function(b,d,g){if(0===d.length)throw new f("You must specify at least one required field.");return e.validateStrArr("required",d),e.checkDupes(d),function(f){var h=c.keys(f),i=a.forall(d,function(b){return a.contains(h,b)});i||e.reqMessage(d,h),b(d,h);var j=a.filter(d,function(a){return!g.validate(f[a],a)});return j.length>0&&e.invalidTypeMessage(j,g.label),f}},i=function(b,c){var d=a.filter(c,function(c){return!a.contains(b,c)});d.length>0&&e.unsuppMessage(d)},j=b.noop;return{exactly:b.curry(g,i),ensure:b.curry(g,j),ensureWith:b.curry(h,j)}}),g("4g",["6q"],function(a){return a.ensure(["readState"])}),h("1w",Math),g("28",["4g","1w"],function(a,b){var c=function(){return a({readState:function(){return"No State required"}})};return{init:c}}),g("q",["27","28","29","14","2e","6"],function(a,b,c,d,e,f){var g=function(a){return d.wrapAll(a)},h=e.objOfOnly([c.strict("fields"),c.strict("name"),c.defaulted("active",{}),c.defaulted("apis",{}),c.defaulted("extra",{}),c.defaulted("state",b)]),i=function(b){var c=e.asRawOrDie("Creating behaviour: "+b.name,h,b);return a.create(c.fields,c.name,c.active,c.apis,c.extra,c.state)},j=e.objOfOnly([c.strict("branchKey"),c.strict("branches"),c.strict("name"),c.defaulted("active",{}),c.defaulted("apis",{}),c.defaulted("extra",{}),c.defaulted("state",b)]),k=function(b){var c=e.asRawOrDie("Creating behaviour: "+b.name,j,b);return a.createModes(e.choose(c.branchKey,c.branches),c.name,c.active,c.apis,c.extra,c.state)};return{derive:g,revoke:f.constant(void 0),noActive:f.constant({}),noApis:f.constant({}),noExtra:f.constant({}),noState:f.constant(b),create:i,createModes:k}}),g("4h",[],function(){return function(a,b,c){var d=c||!1,e=function(){b(),d=!0},f=function(){a(),d=!1},g=function(){var a=d?f:e;a()},h=function(){return d};return{on:e,off:f,toggle:g,isOn:h}}}),g("b",["1d"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("4i",["1i","y","x","b","v","16"],function(a,b,c,d,e,f){var g=function(b,c,d){if(!(a.isString(d)||a.isBoolean(d)||a.isNumber(d)))throw f.error("Invalid call to Attr.set. Key ",c,":: Value ",d,":: Element ",b),new e("Attribute value was not simple");b.setAttribute(c,d+"")},h=function(a,b,c){g(a.dom(),b,c)},i=function(a,b){var d=a.dom();c.each(b,function(a,b){g(d,b,a)})},j=function(a,b){var c=a.dom().getAttribute(b);return null===c?void 0:c},k=function(a,b){var c=a.dom();return!(!c||!c.hasAttribute)&&c.hasAttribute(b)},l=function(a,b){a.dom().removeAttribute(b)},m=function(a){var b=a.dom().attributes;return void 0===b||null===b||0===b.length},n=function(a){return b.foldl(a.dom().attributes,function(a,b){return a[b.name]=b.value,a},{})},o=function(a,b,c){k(a,c)&&!k(b,c)&&h(b,c,j(a,c))},p=function(a,c,e){d.isElement(a)&&d.isElement(c)&&b.each(e,function(b){o(a,c,b)})};return{clone:n,set:h,setAll:i,get:j,has:k,remove:l,hasNone:m,transfer:p}}),g("6r",["y","4i"],function(a,b){var c=function(a,c){var d=b.get(a,c);return void 0===d||""===d?[]:d.split(" ")},d=function(a,d,e){var f=c(a,d),g=f.concat([e]);b.set(a,d,g.join(" "))},e=function(d,e,f){var g=a.filter(c(d,e),function(a){return a!==f});g.length>0?b.set(d,e,g.join(" ")):b.remove(d,e)};return{read:c,add:d,remove:e}}),g("4j",["y","6r"],function(a,b){var c=function(a){return void 0!==a.dom().classList},d=function(a){return b.read(a,"class")},e=function(a,c){return b.add(a,"class",c)},f=function(a,c){return b.remove(a,"class",c)},g=function(b,c){a.contains(d(b),c)?f(b,c):e(b,c)};return{get:d,add:e,remove:f,toggle:g,supports:c}}),g("2f",["4h","4i","4j"],function(a,b,c){var d=function(a,b){c.supports(a)?a.dom().classList.add(b):c.add(a,b)},e=function(a){var d=c.supports(a)?a.dom().classList:c.get(a);0===d.length&&b.remove(a,"class")},f=function(a,b){if(c.supports(a)){var d=a.dom().classList;d.remove(b)}else c.remove(a,b);e(a)},g=function(a,b){return c.supports(a)?a.dom().classList.toggle(b):c.toggle(a,b)},h=function(b,d){var e=c.supports(b),f=b.dom().classList,g=function(){e?f.remove(d):c.remove(b,d)},h=function(){e?f.add(d):c.add(b,d)};return a(g,h,i(b,d))},i=function(a,b){return c.supports(a)&&a.dom().classList.contains(b)};return{add:d,remove:f,toggle:g,toggler:h,has:i}}),g("r",["2f"],function(a){var b=function(b,c,d){a.remove(b,d),a.add(b,c)},c=function(a,c,d){b(a.element(),c.alpha(),c.omega())},d=function(a,c,d){b(a.element(),c.omega(),c.alpha())},e=function(b,c,d){a.remove(b.element(),c.alpha()),a.remove(b.element(),c.omega())},f=function(b,c,d){return a.has(b.element(),c.alpha())},g=function(b,c,d){return a.has(b.element(),c.omega())};return{toAlpha:c,toOmega:d,isAlpha:f,isOmega:g,clear:e}}),g("s",["29"],function(a){return[a.strict("alpha"),a.strict("omega")]}),g("1",["q","r","s"],function(a,b,c){return a.create({fields:c,name:"swapping",apis:b})}),g("2p",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("10",["1i","y","6","z","2o","2p","1a","a"],function(a,b,c,d,e,f,g,h){var i=function(a){return h.fromDom(a.dom().ownerDocument)},j=function(a){var b=i(a);return h.fromDom(b.dom().documentElement)},k=function(a){var b=a.dom(),c=b.ownerDocument.defaultView;return h.fromDom(c)},l=function(a){var b=a.dom();return d.from(b.parentNode).map(h.fromDom)},m=function(a){return l(a).bind(function(c){var d=u(c);return b.findIndex(d,function(b){return g.eq(a,b)})})},n=function(b,d){for(var e=a.isFunction(d)?d:c.constant(!1),f=b.dom(),g=[];null!==f.parentNode&&void 0!==f.parentNode;){var i=f.parentNode,j=h.fromDom(i);if(g.push(j),e(j)===!0)break;f=i}return g},o=function(a){var c=function(c){return b.filter(c,function(b){return!g.eq(a,b)})};return l(a).map(u).map(c).getOr([])},p=function(a){var b=a.dom();return d.from(b.offsetParent).map(h.fromDom)},q=function(a){var b=a.dom();return d.from(b.previousSibling).map(h.fromDom)},r=function(a){var b=a.dom();return d.from(b.nextSibling).map(h.fromDom)},s=function(a){return b.reverse(f.toArray(a,q))},t=function(a){return f.toArray(a,r)},u=function(a){var c=a.dom();return b.map(c.childNodes,h.fromDom)},v=function(a,b){var c=a.dom().childNodes;return d.from(c[b]).map(h.fromDom)},w=function(a){return v(a,0)},x=function(a){return v(a,a.dom().childNodes.length-1)},y=function(a,b){return a.dom().childNodes.length},z=e.immutable("element","offset"),A=function(a,b){var c=u(a);return c.length>0&&b0&&b.before(a,d),e(a)};return{empty:d,remove:e,unwrap:f}}),g("12",["17","a","b","1b"],function(a,b,c,d){var e=function(a){var b=c.isText(a)?a.dom().parentNode:a.dom();return void 0!==b&&null!==b&&b.ownerDocument.body.contains(b)},f=a.cached(function(){return g(b.fromDom(d))}),g=function(a){var c=a.dom().body;if(null===c||void 0===c)throw"Body is not available yet";return b.fromDom(c)};return{body:f,getBody:g,inBody:e}}),g("3",["2","t","y","z","9","11","12","10"],function(a,b,c,d,e,f,g,h){var i=function(d){a.emit(d,b.detachedFromDom());var e=d.components();c.each(e,i)},j=function(d){var e=d.components();c.each(e,j),a.emit(d,b.attachedToDom())},k=function(a,b){l(a,b,e.append)},l=function(a,b,c){a.getSystem().addToWorld(b),c(a.element(),b.element()),g.inBody(a.element())&&j(b),a.syncComponents()},m=function(a){i(a),f.remove(a.element()),a.getSystem().removeFromWorld(a)},n=function(a){var b=h.parent(a.element()).bind(function(b){return a.getSystem().getByDom(b).fold(d.none,d.some)});m(a),b.each(function(a){a.syncComponents()})},o=function(a){var b=a.components();c.each(b,m),f.empty(a.element()),a.syncComponents()},p=function(a,b){e.append(a,b.element());var d=h.children(b.element());c.each(d,function(a){b.getByDom(a).each(j)})},q=function(a){var b=h.children(a.element());c.each(b,function(b){a.getByDom(b).each(i)}),f.remove(a.element())};return{attach:k,attachWith:l,detach:n,detachChildren:o,attachSystem:p,detachSystem:q}}),g("6s",["y","a","10","1b"],function(a,b,c,d){var e=function(a,e){var f=e||d,g=f.createElement("div");return g.innerHTML=a,c.children(b.fromDom(g))},f=function(c,d){return a.map(c,function(a){return b.fromTag(a,d)})},g=function(c,d){return a.map(c,function(a){return b.fromText(a,d)})},h=function(c){return a.map(c,b.fromDom)};return{fromHtml:e,fromTags:f,fromText:g,fromDom:h}}),g("4n",["a","6s","9","2s","11","10"],function(a,b,c,d,e,f){var g=function(a){return a.dom().innerHTML},h=function(g,h){var i=f.owner(g),j=i.dom(),k=a.fromDom(j.createDocumentFragment()),l=b.fromHtml(h,j);d.append(k,l),e.empty(g),c.append(g,k)},i=function(b){var d=a.fromTag("div"),e=a.fromDom(b.dom().cloneNode(!0));return c.append(d,e),g(d)};return{get:g,set:h,getOuter:i}}),g("4o",["4i","a","9","2s","11","10"],function(a,b,c,d,e,f){var g=function(a,c){return b.fromDom(a.dom().cloneNode(c))},h=function(a){return g(a,!1)},i=function(a){return g(a,!0)},j=function(c,d){var e=b.fromTag(d),f=a.clone(c);return a.setAll(e,f),e},k=function(a,b){var c=j(a,b),e=f.children(i(a));return d.append(c,e),c},l=function(a,b){var g=j(a,b);c.before(a,g);var h=f.children(a);return d.append(g,h),e.remove(a),g};return{shallow:h,shallowAs:j,deep:i,copy:k,mutate:l}}),g("2t",["4n","4o"],function(a,b){var c=function(c){var d=b.shallow(c);return a.getOuter(d)};return{getHtml:c}}),g("13",["2t"],function(a){var b=function(b){return a.getHtml(b)};return{element:b}}),g("15",["z"],function(a){var b=function(a){for(var b=[],c=function(a){b.push(a)},d=0;d0&&!d.exists(n,function(b){return a.indexOf(b)>-1})}).getOr(j)}return j},p=function(a,b,c){},q={logEventCut:e.noop,logEventStopped:e.noop,logNoParent:e.noop,logEventNoHandlers:e.noop,logEventResponse:e.noop,write:e.noop},r=function(c,e,f){var g=k&&("*"===m||d.contains(m,c))?function(){var f=[];return{logEventCut:function(a,b,c){f.push({outcome:"cut",target:b,purpose:c})},logEventStopped:function(a,b,c){f.push({outcome:"stopped",target:b,purpose:c})},logNoParent:function(a,b,c){f.push({outcome:"no-parent",target:b,purpose:c})},logEventNoHandlers:function(a,b){f.push({outcome:"no-handlers-left",target:b})},logEventResponse:function(a,b,c){f.push({outcome:"response",purpose:c,target:b})},write:function(){d.contains(["mousemove","mouseover","mouseout",a.systemInit()],c)||h.log(c,{event:c,target:e.dom(),sequence:d.map(f,function(a){return d.contains(["cut","stopped","response"],a.outcome)?"{"+a.purpose+"} "+a.outcome+" at ("+b.element(a.target)+")":a.outcome})})}}}():q,i=f(g);return g.write(),i},s=function(a){var c=function(a){var e=a.spec();return{"(original.spec)":e,"(dom.ref)":a.element().dom(),"(element)":b.element(a.element()),"(initComponents)":d.map(void 0!==e.components?e.components:[],c),"(components)":d.map(a.components(),c),"(bound.events)":f.mapToArray(a.events(),function(a,b){return[b]}).join(", "),"(behaviours)":void 0!==e.behaviours?f.map(e.behaviours,function(b,c){return void 0===b?"--revoked--":{config:b.configAsRaw(),"original-config":b.initialConfig,state:a.readState(c)}}):"none"}};return c(a)},t=function(){return void 0!==window[l]?window[l]:(window[l]={systems:{},lookup:function(a){var d=window[l].systems,e=f.keys(d);return g.findMap(e,function(e){var f=d[e];return f.getByUid(a).toOption().map(function(a){return c.wrap(b.element(a.element()),s(a))})})}},window[l])},u=function(a,b){var c=t();c.systems[a]=b};return{logHandler:p,noLogger:e.constant(q),getTrace:o,monitorEvent:r,isDebugging:e.constant(k),registerInspector:u}}),g("5",[],function(){var a=function(b){var c=b,d=function(){return c},e=function(a){c=a},f=function(){return a(d())};return{get:d,set:e,clone:f}};return a}),g("4p",["1i","z"],function(a,b){return function(c,d,e,f,g){return c(e,f)?b.some(e):a.isFunction(g)&&g(e)?b.none():d(e,f,g)}}),g("2u",["1i","y","6","z","12","1a","a","4p"],function(a,b,c,d,e,f,g,h){var i=function(a){return n(e.body(),a)},j=function(b,e,f){for(var h=b.dom(),i=a.isFunction(f)?f:c.constant(!1);h.parentNode;){h=h.parentNode;var j=g.fromDom(h);if(e(j))return d.some(j);if(i(j))break}return d.none()},k=function(a,b,c){var d=function(a){return b(a)};return h(d,j,a,b,c)},l=function(a,b){var c=a.dom();return c.parentNode?m(g.fromDom(c.parentNode),function(c){return!f.eq(a,c)&&b(c)}):d.none()},m=function(a,d){var e=b.find(a.dom().childNodes,c.compose(d,g.fromDom));return e.map(g.fromDom)},n=function(a,b){var c=function(a){for(var e=0;ed?c:e=c?c:a};return{cycleBy:a,cap:b}}),g("7p",["y","12","10"],function(a,b,c){var d=function(a){return h(b.body(),a)},e=function(b,d,e){return a.filter(c.parents(b,e),d)},f=function(b,d){return a.filter(c.siblings(b),d)},g=function(b,d){return a.filter(c.children(b),d)},h=function(b,d){var e=[];return a.each(c.children(b),function(a){d(a)&&(e=e.concat([a])),e=e.concat(h(a,d))}),e};return{all:d,ancestors:e,siblings:f,children:g,descendants:h}}),g("5l",["7p","2r"],function(a,b){var c=function(a){return b.all(a)},d=function(c,d,e){return a.ancestors(c,function(a){return b.is(a,d)},e)},e=function(c,d){return a.siblings(c,function(a){return b.is(a,d)})},f=function(c,d){return a.children(c,function(a){return b.is(a,d)})},g=function(a,c){return b.all(c,a)};return{all:c,ancestors:d,siblings:e,children:f,descendants:g}}),g("7n",["95","y","z","48","2f","5l","4u","v"],function(a,b,c,d,e,f,g,h){var i=function(a,c,d){var g=f.descendants(a.element(),"."+c.highlightClass());b.each(g,function(b){e.remove(b,c.highlightClass()),a.getSystem().getByDom(b).each(function(b){c.onDehighlight()(a,b)})})},j=function(a,b,c,d){var f=o(a,b,c,d);e.remove(d.element(),b.highlightClass()),f&&b.onDehighlight()(a,d)},k=function(a,b,c,d){var f=o(a,b,c,d);i(a,b,c),e.add(d.element(),b.highlightClass()),f||b.onHighlight()(a,d)},l=function(a,b,c){r(a,b,c).each(function(d){k(a,b,c,d)})},m=function(a,b,c){s(a,b,c).each(function(d){k(a,b,c,d)})},n=function(a,b,c,d){q(a,b,c,d).fold(function(a){throw new h(a)},function(d){k(a,b,c,d)})},o=function(a,b,c,d){return e.has(d.element(),b.highlightClass())},p=function(a,b,c){return g.descendant(a.element(),"."+b.highlightClass()).bind(a.getSystem().getByDom)},q=function(a,b,e,g){var h=f.descendants(a.element(),"."+b.itemClass());return c.from(h[g]).fold(function(){return d.error("No element found with index "+g)},a.getSystem().getByDom)},r=function(a,b,c){return g.descendant(a.element(),"."+b.itemClass()).bind(a.getSystem().getByDom)},s=function(a,b,d){var e=f.descendants(a.element(),"."+b.itemClass()),g=e.length>0?c.some(e[e.length-1]):c.none();return g.bind(a.getSystem().getByDom)},t=function(c,d,g,h){var i=f.descendants(c.element(),"."+d.itemClass()),j=b.findIndex(i,function(a){return e.has(a,d.highlightClass())});return j.bind(function(b){var d=a.cycleBy(b,h,0,i.length-1);return c.getSystem().getByDom(i[d])})},u=function(a,b,c){return t(a,b,c,-1)},v=function(a,b,c){return t(a,b,c,1)};return{dehighlightAll:i,dehighlight:j,highlight:k,highlightFirst:l,highlightLast:m,highlightAt:n,isHighlighted:o,getHighlighted:p,getFirst:r,getLast:s,getPrevious:u,getNext:v}}),g("7o",["4q","29"],function(a,b){return[b.strict("highlightClass"),b.strict("itemClass"),a.onHandler("onHighlight"),a.onHandler("onDehighlight")]}),g("5j",["q","7n","7o","u"],function(a,b,c,d){return a.create({fields:c,name:"highlighting",apis:b})}),g("98",["5j","6","8"],function(a,b,c){var d=function(){var a=function(a){return c.search(a.element())},b=function(a,b){a.getSystem().triggerFocus(b,a.element())};return{get:a,set:b}},e=function(){var c=function(b){return a.getHighlighted(b).map(function(a){return a.element()})},d=function(c,d){c.getSystem().getByDom(d).fold(b.noop,function(b){a.highlight(c,b)})};return{get:c,set:d}};return{dom:d,highlights:e}}),g("8u",["y","6"],function(a,b){var c=function(b){return function(c){return a.contains(b,c.raw().which)}},d=function(b){return function(c){return a.forall(b,function(a){return a(c)})}},e=function(a){return function(b){return b.raw().which===a}},f=function(a){return a.raw().shiftKey===!0};return{inSet:c,and:d,is:e,isShift:f,isNotShift:b.not(f)}}),g("8v",["8u","y"],function(a,b){var c=function(b,c){return{matches:a.is(b),classification:c}},d=function(a,b){return{matches:a,classification:b}},e=function(a,c){var d=b.find(a,function(a){return a.matches(c)});return d.map(function(a){return a.classification})};return{basic:c,rule:d,choose:e}}),g("8s",["3d","2g","t","98","4q","8v","29","w"],function(a,b,c,d,e,f,g,h){var i=function(i,j,k,l,m,n){var o=function(){return i.concat([g.defaulted("focusManager",d.dom()),e.output("handler",r),e.output("state",j)])},p=function(a,b,c,d){var e=k(a,b,c,d);return f.choose(e,b.event()).bind(function(e){return e(a,b,c,d)})},q=function(d,e){var f=l(d,e),g=a.derive(n.map(function(b){return a.run(c.focus(),function(a,c){b(a,d,e,c),c.stop()})}).toArray().concat([a.run(b.keydown(),function(a,b){p(a,b,d,e).each(function(a){b.stop()})})]));return h.deepMerge(f,g)},r={schema:o,processKey:p,toEvents:q,toApis:m};return r};return{typical:i}}),g("8t",["y","1w"],function(a,b){var c=function(b,c,d){var e=a.reverse(b.slice(0,c)),f=a.reverse(b.slice(c+1));return a.find(e.concat(f),d)},d=function(b,c,d){var e=a.reverse(b.slice(0,c));return a.find(e,d)},e=function(b,c,d){var e=b.slice(0,c),f=b.slice(c+1);return a.find(f.concat(e),d)},f=function(b,c,d){var e=b.slice(c+1);return a.find(e,d)};return{cyclePrev:c,cycleNext:e,tryPrev:d,tryNext:f}}),g("57",[],function(){var a=function(a){return void 0!==a.style};return{isSupported:a}}),g("39",["1i","y","x","z","4i","12","a","b","57","37","v","16","1k"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(b,c,d){if(!a.isString(d))throw l.error("Invalid call to CSS.set. Property ",c,":: Value ",d,":: Element ",b),new k("CSS value must be a string: "+d);i.isSupported(b)&&b.style.setProperty(c,d)},o=function(a,b){i.isSupported(a)&&a.style.removeProperty(b)},p=function(a,b,c){var d=a.dom();n(d,b,c)},q=function(a,b){var d=a.dom();c.each(b,function(a,b){n(d,b,a)})},r=function(a,b){var d=a.dom();c.each(b,function(a,b){a.fold(function(){o(d,b)},function(a){n(d,b,a)})})},s=function(a,b){var c=a.dom(),d=m.getComputedStyle(c),e=d.getPropertyValue(b),g=""!==e||f.inBody(a)?e:t(c,b);return null===g?void 0:g},t=function(a,b){return i.isSupported(a)?a.style.getPropertyValue(b):""},u=function(a,b){var c=a.dom(),e=t(c,b);return d.from(e).filter(function(a){return a.length>0})},v=function(a){var b={},c=a.dom();if(i.isSupported(c))for(var d=0;dd?b-d:0;return e};return{set:g,get:h,getOuter:i,aggregate:j,max:k}}}),g("8b",["12","39","78"],function(a,b,c){var d=c("height",function(b){return a.inBody(b)?b.dom().getBoundingClientRect().height:b.dom().offsetHeight}),e=function(a,b){d.set(a,b)},f=function(a){return d.get(a)},g=function(a){return d.getOuter(a)},h=function(a,c){var e=["margin-top","border-top-width","padding-top","padding-bottom","border-bottom-width","margin-bottom"],f=d.max(a,c,e);b.set(a,"max-height",f+"px")};return{set:e,get:f,getOuter:g,setMax:h}}),g("6u",["8c","28","4q","8s","13","8t","8u","8v","29","y","6","z","1a","8","5l","4u","8b"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=[i.defaulted("selector",'[data-alloy-tabstop="true"]'),i.option("onEscape"),i.option("onEnter"),i.defaulted("firstTabstop",0),i.defaulted("useTabstopAt",k.constant(!0)),i.option("visibilitySelector")],s=function(a,b,c){var d=o.descendants(a.element(),b.selector()),e=j.filter(d,function(a){return t(b,a)}),f=l.from(e[b.firstTabstop()]);f.each(function(b){var c=a.element();a.getSystem().triggerFocus(b,c)})},t=function(a,b){var c=a.visibilitySelector().bind(function(a){return p.closest(b,a)}).getOr(b);return q.get(c)>0},u=function(a,b){return n.search(a.element()).bind(function(a){return p.closest(a,b.selector())})},v=function(a,b,c,d,e){return e(b,c,function(a){return t(d,a)&&d.useTabstopAt(a)}).fold(function(){return l.some(!0)},function(b){var c=a.getSystem(),d=a.element();return c.triggerFocus(b,d),l.some(!0)})},w=function(a,b,c,d){var e=o.descendants(a.element(),c.selector());return u(a,c).bind(function(b){var f=j.findIndex(e,k.curry(m.eq,b));return f.bind(function(b){return v(a,e,b,c,d)})})},x=function(a,b,c,d){return w(a,b,c,f.cyclePrev)},y=function(a,b,c,d){return w(a,b,c,f.cycleNext)},z=function(a,b,c,d){return c.onEnter().bind(function(c){return c(a,b)})},A=function(a,b,c,d){return c.onEscape().bind(function(c){return c(a,b)})},B=k.constant([h.rule(g.and([g.isShift,g.inSet(a.TAB())]),x),h.rule(g.inSet(a.TAB()),y),h.rule(g.inSet(a.ESCAPE()),A),h.rule(g.and([g.isNotShift,g.inSet(a.ENTER())]),z)]),C=k.constant({}),D=k.constant({});return d.typical(r,b.init,B,C,D,l.some(s))}),g("8w",["4i","b"],function(a,b){var c=function(c){return"input"===b.name(c)&&"radio"!==a.get(c,"type")||"textarea"===b.name(c)};return{inside:c}}),g("8x",["8w","8c","2","t","8u","z"],function(a,b,c,d,e,f){var g=function(a,b,e){return c.dispatch(a,e,d.execute()),f.some(!0)},h=function(c,d,h){return a.inside(h)&&e.inSet(b.SPACE())(d.event())?f.none():g(c,d,h)};return{defaultExecute:h}}),g("6v",["8w","8c","28","8s","8x","13","8u","8v","29","6","z"],function(a,b,c,d,e,f,g,h,i,j,k){var l=[i.defaulted("execute",e.defaultExecute),i.defaulted("useSpace",!1),i.defaulted("useEnter",!0),i.defaulted("useDown",!1)],m=function(a,b,c,d){return c.execute()(a,b,a.element())},n=function(c,d,e,f){var i=e.useSpace()&&!a.inside(c.element())?b.SPACE():[],j=e.useEnter()?b.ENTER():[],k=e.useDown()?b.DOWN():[],l=i.concat(j).concat(k);return[h.rule(g.inSet(l),m)]},o=j.constant({}),p=j.constant({});return d.typical(l,c.init,n,o,p,k.none())}),g("4z",["4g","5","6","z"],function(a,b,c,d){var e=function(e){var f=b(d.none()),g=function(a,b){f.set(d.some({numRows:c.constant(a),numColumns:c.constant(b)}))},h=function(){return f.get().map(function(a){return a.numRows()})},i=function(){return f.get().map(function(a){return a.numColumns()})};return a({readState:c.constant({}),setGridSize:g,getNumRows:h,getNumColumns:i})},f=function(a){return a.state()(a)};return{flatgrid:e,init:f}}),g("9z",["39"],function(a){var b=function(a,b){return function(d){return"rtl"===c(d)?b:a}},c=function(b){return"rtl"===a.get(b,"direction")?"rtl":"ltr"};return{onDirection:b,getDirection:c}}),g("8y",["9z"],function(a){var b=function(a){return function(b,c,d,e){var g=a(b.element());return f(g,b,c,d,e)}},c=function(c,d){var e=a.onDirection(c,d);return b(e)},d=function(c,d){var e=a.onDirection(d,c);return b(e)},e=function(a){return function(b,c,d,e){return f(a,b,c,d,e)}},f=function(a,b,c,d,e){var f=d.focusManager().get(b).bind(function(c){return a(b.element(),c,d,e)});return f.map(function(a){return d.focusManager().set(b,a),!0})};return{east:d,west:c,north:e,south:e,move:e}}),g("a0",["y","2o"],function(a,b){var c=b.immutableBag(["index","candidates"],[]),d=function(b,d){return a.findIndex(b,d).map(function(a){return c({index:a,candidates:b})})};return{locate:d}}),g("a1",["6","4h","39"],function(a,b,c){var d=function(d,e,f,g){var h=c.get(d,e);void 0===h&&(h="");var i=h===f?g:f,j=a.curry(c.set,d,e,h),k=a.curry(c.set,d,e,i);return b(j,k,!1)},e=function(a){return d(a,"visibility","hidden","visible")},f=function(a,b){return d(a,"display","none",b)},g=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},h=function(a){var b=a.dom();return!g(b)};return{toggler:e,displayToggler:f,isVisible:h}}),g("8z",["a0","y","6","1a","5l","a1"],function(a,b,c,d,e,f){var g=function(a,b,c){var d=f.isVisible;return h(a,b,c,d)},h=function(g,h,i,j){var k=c.curry(d.eq,h),l=e.descendants(g,i),m=b.filter(l,f.isVisible);return a.locate(m,k)},i=function(a,c){return b.findIndex(a,function(a){return d.eq(c,a)})};return{locateVisible:g,locateIn:h,findIndex:i}}),g("90",["95","6","z","1w"],function(a,b,c,d){var e=function(a,b,e,f){var g=d.floor(b/e),h=b%e;return f(g,h).bind(function(b){var d=b.row()*e+b.column();return d>=0&&d"}),c.anyValue()),m=b.defaulted("defaults",e.constant({})),n=b.defaulted("overrides",e.constant({})),o=c.objOf([i,j,k,l,m,n]),p=c.objOf([i,j,k,m,n]),q=c.objOf([i,j,k,l,m,n]),r=c.objOf([i,j,k,b.strict("unit"),l,m,n]),s=function(a){return a.fold(g.some,g.none,g.some,g.some)},t=function(a){var b=function(a){return a.name()};return a.fold(b,b,b,b)},u=function(a){return a.fold(e.identity,e.identity,e.identity,e.identity)},v=function(a,b){return function(d){var e=c.asStructOrDie("Converting part type",b,d);return a(e)}};return{required:v(h.required,o),external:v(h.external,p),optional:v(h.optional,q),group:v(h.group,r),asNamedPart:s,name:t,asCommon:u,original:e.constant("entirety")}}),g("72",["14","y","x","w","6n","6","6k","v"],function(a,b,c,d,e,f,g,h){var i="placeholder",j=g.generate([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),k=function(a){return b.contains([i],a)},l=function(b,d,g,i){return b.exists(function(a){return a!==g.owner})?j.single(!0,f.constant(g)):a.readOptFrom(i,g.name).fold(function(){throw new h("Unknown placeholder component: "+g.name+"\nKnown: ["+c.keys(i)+"]\nNamespace: "+b.getOr("none")+"\nSpec: "+e.stringify(g,null,2))},function(a){return a.replace()})},m=function(a,b,c,d){return c.uiType===i?l(a,b,c,d):j.single(!1,f.constant(c))},n=function(c,e,f,g){var h=m(c,e,f,g);return h.fold(function(h,i){var j=i(e,f.config,f.validated),k=a.readOptFrom(j,"components").getOr([]),l=b.bind(k,function(a){return n(c,e,a,g)});return[d.deepMerge(j,{components:l})]},function(a,b){var c=b(e,f.config,f.validated);return c})},o=function(a,c,d,e){return b.bind(d,function(b){return n(a,c,b,e)})},p=function(a,b){var c=!1,d=function(){return c},e=function(){if(c===!0)throw new h("Trying to use the same placeholder more than once: "+a);return c=!0,b},g=function(){return b.fold(function(a,b){return a},function(a,b){return a})};return{name:f.constant(a),required:g,used:d,replace:e}},q=function(a,b,d,f){var g=c.map(f,function(a,b){return p(b,a)}),i=o(a,b,d,g);return c.each(g,function(c){if(c.used()===!1&&c.required())throw new h("Placeholder: "+c.name()+" was not found in components list\nNamespace: "+a.getOr("none")+"\nComponents: "+e.stringify(b.components(),null,2))}),i},r=function(a,b){var c=b;return c.fold(function(b,c){return[c(a)]},function(b,c){return c(a)})};return{single:j.single,multiple:j.multiple,isSubstitute:k,placeholder:f.constant(i),substituteAll:o,substitutePlaces:q,singleReplace:r}}),g("71",["53","72","14","y","6","w"],function(a,b,c,d,e,f){var g=function(a,b,d,e){var g=d;return f.deepMerge(b.defaults()(a,d,e),d,{uid:a.partUids()[b.name()]},b.overrides()(a,d,e),{"debug.sketcher":c.wrap("part-"+b.name(),g)})},h=function(c,h,i){var j={},k={};return d.each(i,function(c){c.fold(function(a){j[a.pname()]=b.single(!0,function(b,c,d){return a.factory().sketch(g(b,a,c,d))})},function(b){var c=h.parts()[b.name()]();k[b.name()]=e.constant(g(h,b,c[a.original()]()))},function(a){j[a.pname()]=b.single(!1,function(b,c,d){return a.factory().sketch(g(b,a,c,d))})},function(a){j[a.pname()]=b.multiple(!0,function(b,c,e){var g=b[a.name()]();return d.map(g,function(c){return a.factory().sketch(f.deepMerge(a.defaults()(b,c),c,a.overrides()(b,c)))})})})}),{internals:e.constant(j),externals:e.constant(k)}};return{subs:h}}),g("52",["4q","71","53","72","4c","29","14","2e","y","6","w","x","z"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(a,b){var d={};return i.each(b,function(b){c.asNamedPart(b).each(function(b){var c=o(a,b.pname());d[b.name()]=function(d){var e=h.asRawOrDie("Part: "+b.name()+" in "+a,h.objOf(b.schema()),d);return k.deepMerge(c,{config:d,validated:e})}})}),d},o=function(a,b){return{uiType:d.placeholder(),owner:a,name:b}},p=function(a,b,c){return{uiType:d.placeholder(),owner:a,name:b,config:c,validated:{}}},q=function(b){return i.bind(b,function(b){return b.fold(m.none,m.some,m.none,m.none).map(function(b){return f.strictObjOf(b.name(),b.schema().concat([a.snapshot(c.original())]))}).toArray()})},r=function(a){return i.map(a,c.name)},s=function(a,c,d){return b.subs(a,c,d)},t=function(a,b,c){return d.substitutePlaces(m.some(a),b,b.components(),c)},u=function(a,b,c){var d=b.partUids()[c];return a.getSystem().getByUid(d).toOption()},v=function(a,b,c){return u(a,b,c).getOrDie("Could not find part: "+c)},w=function(a,b,c){var d={},e=b.partUids(),f=a.getSystem();return i.each(c,function(a){d[a]=f.getByUid(e[a])}),l.map(d,j.constant)},x=function(a,b){var c=a.getSystem();return l.map(b.partUids(),function(a,b){return j.constant(c.getByUid(a))})},y=function(a,b,c){var d={},e=b.partUids(),f=a.getSystem();return i.each(c,function(a){d[a]=f.getByUid(e[a]).getOrDie()}),l.map(d,j.constant)},z=function(a,b){var c=r(b);return g.wrapAll(i.map(c,function(b){return{key:b,value:a+"-"+b}}))},A=function(a){return f.field("partUids","partUids",e.mergeWithThunk(function(b){return z(b.uid,a)}),h.anyValue())};return{generate:n,generateOne:p,schemas:q,names:r,substitutes:s,components:t,defaultUids:z,defaultUidsSchema:A,getAllParts:x,getPart:u,getPartOrDie:v,getParts:w,getPartsOrDie:y}}),g("73",["4q","72","29","14","2e","y","6","w","x","6n","v"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(e,g,h){var l=void 0!==h?h:"Unknown owner",m=function(){return[a.output("partUids",{})]},n=void 0!==g?g:m();if(0===e.length&&0===n.length)return m();var o=c.strictObjOf("parts",f.flatten([f.map(e,c.strict),f.map(n,function(a){return c.defaulted(a,b.single(!1,function(){throw new k("The optional part: "+a+" was not specified in the config, but it was used in components")}))})])),p=c.state("partUids",function(a){if(!d.hasKey(a,"parts"))throw new k("Part uid definition for owner: "+l+' requires "parts"\nExpected parts: '+e.join(", ")+"\nSpec: "+j.stringify(a,null,2));var b=i.map(a.parts,function(b,c){return d.readOptFrom(b,"uid").getOrThunk(function(){return a.uid+"-"+c})});return b});return[o,p]},m=function(b,d,e,f){var g=d.length>0?[c.strictObjOf("parts",d)]:[];return g.concat([c.strict("uid"),c.defaulted("dom",{}),c.defaulted("components",[]),a.snapshot("originalSpec"),c.defaulted("debug.sketcher",{})]).concat(e)},n=function(a,b,c,d){var f=m(a,d,c);return e.asRawOrDie(a+" [SpecSchema]",e.objOfOnly(f.concat(b)),c)},o=function(a,b,c,d,f){var g=m(a,d,f,c);return e.asStructOrDie(a+" [SpecSchema]",e.objOfOnly(g.concat(b)),c)},p=function(a,b,c){var d=h.deepMerge(b,c);return a(d)},q=function(a,b){return h.deepMerge(a,b)};return{asRawOrDie:n,asStructOrDie:o,addBehaviours:q,getPartsSchema:l,extend:p}}),g("51",["52","30","73","14","w"],function(a,b,c,d,e){var f=function(a,b,f,g){var i=h(g),j=c.asStructOrDie(a,b,i,[],[]);return e.deepMerge(f(j,i),{"debug.sketcher":d.wrap(a,g)})},g=function(b,f,g,i,j){var k=h(j),l=a.schemas(g),m=a.defaultUidsSchema(g),n=c.asStructOrDie(b,f,k,l,[m]),o=a.substitutes(b,n,g),p=a.components(b,n,o.internals());return e.deepMerge(i(n,p,k,o.externals()),{"debug.sketcher":d.wrap(b,j)})},h=function(a){return e.deepMerge({uid:b.generate("uid")},a)};return{supplyUid:h,single:f,composite:g}}),g("34",["50","51","4a","52","53","29","2e","6","w","x"],function(a,b,c,d,e,f,g,h,i,j){var k=g.objOfOnly([f.strict("name"),f.strict("factory"),f.strict("configFields"),f.defaulted("apis",{}),f.defaulted("extraApis",{})]),l=g.objOfOnly([f.strict("name"),f.strict("factory"),f.strict("configFields"),f.strict("partFields"),f.defaulted("apis",{}),f.defaulted("extraApis",{})]),m=function(d){var e=g.asRawOrDie("Sketcher for "+d.name,k,d),f=function(a){return b.single(e.name,e.configFields,e.factory,a)},l=j.map(e.apis,a.makeApi),m=j.map(e.extraApis,function(a,b){return c.markAsExtraApi(a,b)});return i.deepMerge({name:h.constant(e.name),partFields:h.constant([]),configFields:h.constant(e.configFields),sketch:f},l,m)},n=function(e){var f=g.asRawOrDie("Sketcher for "+e.name,l,e),k=function(a){return b.composite(f.name,f.configFields,f.partFields,f.factory,a)},m=d.generate(f.name,f.partFields),n=j.map(f.apis,a.makeApi),o=j.map(f.extraApis,function(a,b){return c.markAsExtraApi(a,b)});return i.deepMerge({name:h.constant(f.name),partFields:h.constant(f.partFields),configFields:h.constant(f.configFields),sketch:k,parts:h.constant(m)},n,o)};return{single:m,composite:n}}),g("35",["3d","2","2g","t","y","7"],function(a,b,c,d,e,f){var g=function(g){var h=function(b){return a.run(d.execute(),function(a,c){b(a),c.stop()})},i=function(a,c){c.stop(),b.emitExecute(a)},j=function(a,b){b.cut()},k=f.detect().deviceType.isTouch()?[a.run(d.tap(),i)]:[a.run(c.click(),i),a.run(c.mousedown(),j)];return a.derive(e.flatten([g.map(h).toArray(),k]))};return{events:g}}),g("1n",["q","32","33","34","35","29","w"],function(a,b,c,d,e,f,g){var h=function(d,f){var h=e.events(d.action());return{uid:d.uid(),dom:d.dom(),components:d.components(),events:h,behaviours:g.deepMerge(a.derive([b.config({}),c.config({mode:"execution",useSpace:!0,useEnter:!0})]),d.buttonBehaviours()),domModification:{attributes:{type:"button",role:d.role().getOr("button")}},eventOrder:d.eventOrder()}};return d.single({name:"Button",factory:h,configFields:[f.defaulted("uid",void 0),f.strict("dom"),f.defaulted("components",[]),f.defaulted("buttonBehaviours",{}),f.option("action"),f.option("role"),f.defaulted("eventOrder",{})]})}),g("36",["14","y","w","a","b","4n","10","u"],function(a,b,c,d,e,f,g,h){var i=function(d){var e=void 0!==d.dom().attributes?d.dom().attributes:[];return b.foldl(e,function(b,d){return"class"===d.name?b:c.deepMerge(b,a.wrap(d.name,d.value))},{})},j=function(a){return h.prototype.slice.call(a.dom().classList,0)},k=function(a){var b=d.fromHtml(a),h=g.children(b),k=i(b),l=j(b),m=0===h.length?{}:{innerHtml:f.get(b)};return c.deepMerge({tag:e.name(b),classes:l,attributes:k},m)},l=function(a,b,d){return a.sketch(c.deepMerge({dom:k(b)},d))};return{fromHtml:k,sketch:l}}),g("1o",["36","37","i"],function(a,b,c){var d=function(d){var e=b.supplant(d,{prefix:c.prefix()});return a.fromHtml(e)},e=function(a){var b=d(a);return{dom:b}};return{dom:d,spec:e}}),g("l",["q","1g","1m","1n","w","1l","i","1o"],function(a,b,c,d,e,f,g,h){var i=function(a,b){return m(b,function(){a.execCommand(b); +},{})},j=function(c){return a.derive([b.config({toggleClass:g.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),f.format(c,function(a,c){var d=c?b.on:b.off;d(a)})])},k=function(a,b){var c=j(b);return m(b,function(){a.execCommand(b)},c)},l=function(a,b,c,d){var e=j(c);return m(b,d,e)},m=function(b,f,g){return d.sketch({dom:h.dom(''),action:f,buttonBehaviours:e.deepMerge(a.derive([c.config({})]),g)})};return{forToolbar:m,forToolbarCommand:i,forToolbarStateAction:l,forToolbarStateCommand:k}}),g("93",["1w"],function(a){var b=function(b,c,d,e){return bd?d:b===c?c-1:a.max(c,b-e)},c=function(b,c,d,e){return b>d?b:bb.right)return f+1;var l=a.min(b.right,a.max(g,b.left))-b.left,m=d(l/b.width*k+c,c-1,f+1),n=a.round(m);return i&&m>=c&&m<=f?e(b,m,c,f,h,j):n};return{reduceBy:b,increaseBy:c,findValueOfX:f}}),g("74",["2","93","6","z","7","1w"],function(a,b,c,d,e,f){var g="slider.change.value",h=e.detect().deviceType.isTouch(),i=function(a){var b=a.event().raw();return h&&void 0!==b.touches&&1===b.touches.length?d.some(b.touches[0]):h&&void 0!==b.touches?d.none():h||void 0===b.clientX?d.none():d.some(b)},j=function(a){var b=i(a);return b.map(function(a){return a.clientX})},k=function(b,c){a.emitWith(b,g,{value:c})},l=function(a,b){k(a,b.min(),d.none())},m=function(a,b){k(a,b.max(),d.none())},n=function(a,b){k(a,b.max()+1,d.none())},o=function(a,b){k(a,b.min()-1,d.none())},p=function(a,c,d,e){var f=b.findValueOfX(c,d.min(),d.max(),e,d.stepSize(),d.snapToGrid(),d.snapStart());k(a,f)},q=function(a,b,c,d){return j(d).map(function(d){return p(a,c,b,d),d})},r=function(a,c){var e=b.reduceBy(c.value().get(),c.min(),c.max(),c.stepSize());k(a,e,d.none())},s=function(a,c){var e=b.increaseBy(c.value().get(),c.min(),c.max(),c.stepSize());k(a,e,d.none())};return{setXFromEvent:q,setToLedge:o,setToRedge:n,moveLeftFromRedge:m,moveRightFromLedge:l,moveLeft:r,moveRight:s,changeEvent:c.constant(g)}}),g("54",["q","32","33","3d","2g","53","74","29","5","6","z","7"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=l.detect(),n=m.deviceType.isTouch(),o=function(a,b){return f.optional({name:""+a+"-edge",overrides:function(a){var c=d.derive([d.runActionExtra(e.touchstart(),b,[a])]),f=d.derive([d.runActionExtra(e.mousedown(),b,[a]),d.runActionExtra(e.mousemove(),function(a,c){c.mouseIsDown().get()&&b(a,c)},[a])]);return{events:n?c:f}}})},p=o("left",g.setToLedge),q=o("right",g.setToRedge),r=f.required({name:"thumb",defaults:j.constant({dom:{styles:{position:"absolute"}}}),overrides:function(a){return{events:d.derive([d.redirectToPart(e.touchstart(),a,"spectrum"),d.redirectToPart(e.touchmove(),a,"spectrum"),d.redirectToPart(e.touchend(),a,"spectrum")])}}}),s=f.required({schema:[h.state("mouseIsDown",function(){return i(!1)})],name:"spectrum",overrides:function(f){var h=function(a,b){var c=a.element().dom().getBoundingClientRect();g.setXFromEvent(a,f,c,b)},i=d.derive([d.run(e.touchstart(),h),d.run(e.touchmove(),h)]),j=d.derive([d.run(e.mousedown(),h),d.run(e.mousemove(),function(a,b){f.mouseIsDown().get()&&h(a,b)})]);return{behaviours:a.derive(n?[]:[c.config({mode:"special",onLeft:function(a){return g.moveLeft(a,f),k.some(!0)},onRight:function(a){return g.moveRight(a,f),k.some(!0)}}),b.config({})]),events:n?i:j}}});return[p,q,r,s]}),g("55",["29","5","6","7"],function(a,b,c,d){var e=d.detect().deviceType.isTouch();return[a.strict("min"),a.strict("max"),a.defaulted("stepSize",1),a.defaulted("onChange",c.noop),a.defaulted("onInit",c.noop),a.defaulted("onDragStart",c.noop),a.defaulted("onDragEnd",c.noop),a.defaulted("snapToGrid",!1),a.option("snapStart"),a.strict("getInitialValue"),a.defaulted("sliderBehaviours",{}),a.state("value",function(a){return b(a.min)})].concat(e?[]:[a.state("mouseIsDown",function(){return b(!1)})])}),g("5b",[],function(){var a=function(a,b,c){b.store().manager().onLoad(a,b,c)},b=function(a,b,c){b.store().manager().onUnload(a,b,c)},c=function(a,b,c,d){b.store().manager().setValue(a,b,c,d)},d=function(a,b,c){return b.store().manager().getValue(a,b,c)};return{onLoad:a,onUnload:b,setValue:c,getValue:d}}),g("5a",["3d","27","5b"],function(a,b,c){var d=function(d,e){var f=d.resetOnDom()?[a.runOnAttached(function(a,b){c.onLoad(a,d,e)}),a.runOnDetached(function(a,b){c.onUnload(a,d,e)})]:[b.loadEvent(d,e,c.onLoad)];return a.derive(f)};return{events:d}}),g("5d",["4g","5"],function(a,b){var c=function(){var c=b(null),d=function(){return{mode:"memory",value:c.get()}},e=function(){return null===c.get()},f=function(){c.set(null)};return a({set:c.set,get:c.get,isNotSet:e,clear:f,readState:d})},d=function(){var b=function(){};return a({readState:b})},e=function(){var c=b({}),d=function(){return{mode:"dataset",dataset:c.get()}};return a({readState:d,set:c.set,get:c.get})},f=function(a){return a.store().manager().state(a)};return{memory:c,dataset:e,manual:d,init:f}}),g("75",["5d","4q","29","14","6"],function(a,b,c,d,e){var f=function(a,b,c,d){b.store().getDataKey();c.set({}),b.store().setData()(a,d),b.onSetValue()(a,d)},g=function(a,b,c){var e=b.store().getDataKey()(a),f=c.get();return d.readOptFrom(f,e).fold(function(){return b.store().getFallbackEntry()(e)},function(a){return a})},h=function(a,b,c){b.store().initialValue().each(function(d){f(a,b,c,d)})},i=function(a,b,c){c.set({})};return[c.option("initialValue"),c.strict("getFallbackEntry"),c.strict("getDataKey"),c.strict("setData"),b.output("manager",{setValue:f,getValue:g,onLoad:h,onUnload:i,state:a.dataset})]}),g("76",["28","4q","29","6"],function(a,b,c,d){var e=function(a,b,c){return b.store().getValue()(a)},f=function(a,b,c,d){b.store().setValue()(a,d),b.onSetValue()(a,d)},g=function(a,b,c){b.store().initialValue().each(function(c){b.store().setValue()(a,c)})};return[c.strict("getValue"),c.defaulted("setValue",d.noop),c.option("initialValue"),b.output("manager",{setValue:f,getValue:e,onLoad:g,onUnload:d.noop,state:a.init})]}),g("77",["5d","4q","29"],function(a,b,c){var d=function(a,b,c,d){c.set(d),b.onSetValue()(a,d)},e=function(a,b,c){return c.get()},f=function(a,b,c){b.store().initialValue().each(function(a){c.isNotSet()&&c.set(a)})},g=function(a,b,c){c.clear()};return[c.option("initialValue"),b.output("manager",{setValue:d,getValue:e,onLoad:f,onUnload:g,state:a.memory})]}),g("5c",["75","76","77","4q","29","2e"],function(a,b,c,d,e,f){return[e.defaultedOf("store",{mode:"memory"},f.choose("mode",{memory:c,manual:b,dataset:a})),d.onHandler("onSetValue"),e.defaulted("resetOnDom",!1)]}),g("3g",["q","5a","5b","5c","5d"],function(a,b,c,d,e){var f=a.create({fields:d,name:"representing",active:b,apis:c,extra:{setValueFrom:function(a,b){var c=f.getValue(b);f.setValue(a,c)}},state:e});return f}),g("5m",["39","78"],function(a,b){var c=b("width",function(a){return a.dom().offsetWidth}),d=function(a,b){c.set(a,b)},e=function(a){return c.get(a)},f=function(a){return c.getOuter(a)},g=function(b,d){var e=["margin-left","border-left-width","padding-left","padding-right","border-right-width","margin-right"],f=c.max(b,d,e);a.set(b,"max-width",f+"px")};return{set:d,get:e,getOuter:f,setMax:g}}),g("56",["q","33","3g","3d","2g","52","74","y","6","w","z","7","39","5m"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=l.detect().deviceType.isTouch(),p=function(l,p,q,r){var s=l.max()-l.min(),t=function(a){var b=a.element().dom().getBoundingClientRect();return(b.left+b.right)/2},u=function(a){return f.getPartOrDie(a,l,"thumb")},v=function(a,b,c){var d=c.value().get();return dc.max()?f.getPart(a,c,"right-edge").fold(function(){return b.width},function(a){return t(a)-b.left}):(c.value().get()-c.min())/s*b.width},w=function(a){var b=f.getPartOrDie(a,l,"spectrum"),c=b.element().dom().getBoundingClientRect(),d=a.element().dom().getBoundingClientRect(),e=v(a,c,l);return c.left-d.left+e},x=function(a){var b=w(a),c=u(a),d=n.get(c.element())/2;m.set(c.element(),"left",b-d+"px")},y=function(a,b){var c=l.value().get(),d=u(a);return c!==b||m.getRaw(d.element(),"left").isNone()?(l.value().set(b),x(a),l.onChange()(a,d,b),k.some(!0)):k.none()},z=function(a){y(a,l.min(),k.none())},A=function(a){y(a,l.max(),k.none())},B=o?[d.run(e.touchstart(),function(a,b){l.onDragStart()(a,u(a))}),d.run(e.touchend(),function(a,b){l.onDragEnd()(a,u(a))})]:[d.run(e.mousedown(),function(a,b){b.stop(),l.onDragStart()(a,u(a)),l.mouseIsDown().set(!0)}),d.run(e.mouseup(),function(a,b){l.onDragEnd()(a,u(a)),l.mouseIsDown().set(!1)})];return{uid:l.uid(),dom:l.dom(),components:p,behaviours:j.deepMerge(a.derive(h.flatten([o?[]:[b.config({mode:"special",focusIn:function(a){return f.getPart(a,l,"spectrum").map(b.focusIn).map(i.constant(!0))}})],[c.config({store:{mode:"manual",getValue:function(a){return l.value().get()}}})]])),l.sliderBehaviours()),events:d.derive([d.run(g.changeEvent(),function(a,b){y(a,b.event().value())}),d.runOnAttached(function(a,b){l.value().set(l.getInitialValue()());var c=u(a);x(a),l.onInit()(a,c,l.value().get())})].concat(B)),apis:{resetToMin:z,resetToMax:A,refresh:x},domModification:{styles:{position:"relative"}}}};return{sketch:p}}),g("38",["34","54","55","56","1w"],function(a,b,c,d,e){return a.composite({name:"Slider",configFields:c,partFields:b,factory:d.sketch,apis:{resetToMin:function(a,b){a.resetToMin(b)},resetToMax:function(a,b){a.resetToMax(b)},refresh:function(a,b){a.refresh(b)}}})}),g("3a",["l"],function(a){var b=function(b,c,d){return a.forToolbar(c,function(){var a=d();b.setContextToolbar([{label:c+" group",items:a}])},{})};return{button:b}}),g("1p",["q","1f","1g","38","39","1l","i","3a","1o"],function(a,b,c,d,e,f,g,h,i){var j=-1,k=function(b){var h=function(a){return a<0?"black":a>360?"white":"hsl("+a+", 100%, 50%)"},j=function(a,b,c){var d=h(c);e.set(b.element(),"background-color",d)},k=function(a,c,d){var f=h(d);e.set(c.element(),"background-color",f),b.onChange(a,c,f)};return d.sketch({dom:i.dom('
          '),components:[d.parts()["left-edge"](i.spec('
          ')),d.parts().spectrum({dom:i.dom('
          '),components:[i.spec('
          ')],behaviours:a.derive([c.config({toggleClass:g.resolve("thumb-active")})])}),d.parts()["right-edge"](i.spec('
          ')),d.parts().thumb({dom:i.dom('
          '),behaviours:a.derive([c.config({toggleClass:g.resolve("thumb-active")})])})],onChange:k,onDragStart:function(a,b){c.on(b)},onDragEnd:function(a,b){c.off(b)},onInit:j,stepSize:10,min:0,max:360,getInitialValue:b.getInitialValue,sliderBehaviours:a.derive([f.orientation(d.refresh)])})},l=function(a){return[k(a)]},m=function(a,b){var c={onChange:function(a,c,d){b.undoManager.transact(function(){b.formatter.apply("forecolor",{value:d}),b.nodeChanged()})},getInitialValue:function(){return j}};return h.button(a,"color",function(){return l(c)})};return{makeItems:l,sketch:m}}),g("3b",["q","1f","1g","38","29","2e","1l","i","1o"],function(a,b,c,d,e,f,g,h,i){var j=f.objOfOnly([e.strict("getInitialValue"),e.strict("onChange"),e.strict("category"),e.strict("sizes")]),k=function(b){var e=f.asRawOrDie("SizeSlider",j,b),k=function(a){return a>=0&&a'),components:[i.spec('
          ')]}),d.parts().thumb({dom:i.dom('
          '),behaviours:a.derive([c.config({toggleClass:h.resolve("thumb-active")})])})]})};return{sketch:k}}),g("58",["1i","6","z","a"],function(a,b,c,d){var e=function(e,f,g){for(var h=e.dom(),i=a.isFunction(g)?g:b.constant(!1);h.parentNode;){h=h.parentNode;var j=d.fromDom(h),k=f(j);if(k.isSome())return k;if(i(j))break}return c.none()},f=function(a,b,d){var f=b(a);return f.orThunk(function(){return d(a)?c.none():e(a,b,d)})};return{ancestor:e,closest:f}}),g("3c",["y","6","z","1a","a","b","39","58","10"],function(a,b,c,d,e,f,g,h,i){var j=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],k="medium",l=2,m=function(a){return c.from(j[a])},n=function(b){return a.findIndex(j,function(a){return a===b})},o=function(a,b){var d=f.isElement(b)?c.some(b):i.parent(b);return d.map(function(b){var c=h.closest(b,function(a){return g.getRaw(a,"font-size")},a);return c.getOrThunk(function(){return g.get(b,"font-size")})}).getOr("")},p=function(b){var c=b.selection.getStart(),f=e.fromDom(c),g=e.fromDom(b.getBody()),h=function(a){return d.eq(g,a)},i=o(h,f);return a.find(j,function(a){return i===a}).getOr(k)},q=function(a,b){var c=p(a);c!==b&&a.execCommand("fontSize",!1,b)},r=function(a){var b=p(a);return n(b).getOr(l)},s=function(a,b){m(b).each(function(b){q(a,b)})};return{candidates:b.constant(j),get:r,apply:s}}),g("1q",["3b","3a","3c","1o"],function(a,b,c,d){var e=c.candidates(),f=function(b){return a.sketch({onChange:b.onChange,sizes:e,category:"font",getInitialValue:b.getInitialValue})},g=function(a){return[d.spec(''),f(a),d.spec('')]},h=function(a,d){var e={onChange:function(a){c.apply(d,a)},getInitialValue:function(){return c.get(d)}};return b.button(a,"font-size",function(){return g(e)})};return{makeItems:g,sketch:h}});g("79",[],function(){function a(a,b){return e(document.createElement("canvas"),a,b)}function b(b){var d,e;return d=a(b.width,b.height),e=c(d),e.drawImage(b,0,0),d}function c(a){return a.getContext("2d")}function d(a){var b=null;try{b=a.getContext("webgl")||a.getContext("experimental-webgl")}catch(a){}return b||(b=null),b}function e(a,b,c){return a.width=b,a.height=c,a}return{create:a,clone:b,resize:e,get2dContext:c,get3dContext:d}});g("7a",[],function(){function a(a){return a.naturalWidth||a.width}function b(a){return a.naturalHeight||a.height}return{getWidth:a,getHeight:b}}),g("7b",[],function(){function a(a){var b=document.createElement("a");return b.href=a,b.pathname}function b(b){var c,d,e,f;return 0===b.indexOf("data:")?(b=b.split(","),f=/data:([^;]+)/.exec(b[0]),f?f[1]:""):(e={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png"},c=a(b).split("."),d=c[c.length-1],d&&(d=d.toLowerCase()),e[d])}return{guessMimeType:b}}),g("7c",[],function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void i(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(b){return void a.reject(b)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(a){e.call(this,a)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;a'),components:[g.asSpec()],action:function(a){var b=g.get(a);b.element().dom().click()}})};return{sketch:k}}),g("5e",[],function(){var a=function(a){return a.dom().textContent},b=function(a,b){a.dom().textContent=b};return{get:a,set:b}}),g("3h",["6","z","a","4i","5e","4u"],function(a,b,c,d,e,f){var g=function(a){return a.length>0},h=function(a){return void 0===a||null===a?"":a},i=function(a){var c=a.selection.getContent({format:"text"});return{url:"",text:c,title:"",target:"",link:b.none()}},j=function(a){var c=e.get(a),f=d.get(a,"href"),g=d.get(a,"title"),i=d.get(a,"target");return{url:h(f),text:c!==f?h(c):"",title:h(g),target:h(i),link:b.some(a)}},k=function(a){return q(a).fold(function(){return i(a)},function(a){return j(a)})},l=function(a){var b=d.get(a,"href"),c=e.get(a);return b===c},m=function(a,c,d){return d.text.filter(g).fold(function(){return l(a)?b.some(c):b.none()},b.some)},n=function(b,c){var d=c.link.bind(a.identity);d.each(function(a){b.execCommand("unlink")})},o=function(a,b){var c={};return c.href=a,b.title.filter(g).each(function(a){c.title=a}),b.target.filter(g).each(function(a){c.target=a}),c},p=function(b,c){c.url.filter(g).fold(function(){n(b,c)},function(f){var h=o(f,c),i=c.link.bind(a.identity);i.fold(function(){var a=c.text.filter(g).getOr(f);b.insertContent(b.dom.createHTML("a",h,b.dom.encode(a)))},function(a){var b=m(a,f,c);d.setAll(a,h),b.each(function(b){e.set(a,b)})})})},q=function(a){var b=c.fromDom(a.selection.getStart());return f.closest(b,"a")};return{getInfo:k,applyInfo:p,query:q}}),g("3u",["q","3d","29","6"],function(a,b,c,d){var e=function(e,f){var g=b.derive(f);return a.create({fields:[c.strict("enabled")],name:e,active:{events:d.constant(g)}})},f=function(b,c){var f=e(b,c);return{key:b,value:{config:{},me:f,configAsRaw:d.constant({}),initialConfig:{},state:a.noState()}}};return{events:e,config:f}}),g("7h",[],function(){var a=function(a,b,c){return b.find()(a)};return{getCurrent:a}}),g("7i",["29"],function(a){return[a.strict("find")]}),g("5f",["q","7h","7i"],function(a,b,c){return a.create({fields:c,name:"composing",apis:b})}),g("3v",["34","29","w"],function(a,b,c){var d=function(a,b){return{uid:a.uid(),dom:c.deepMerge({tag:"div",attributes:{role:"presentation"}},a.dom()),components:a.components(),behaviours:a.containerBehaviours(),events:a.events(),domModification:a.domModification(),eventOrder:a.eventOrder()}};return a.single({name:"Container",factory:d,configFields:[b.defaulted("components",[]),b.defaulted("containerBehaviours",{}),b.defaulted("events",{}),b.defaulted("domModification",{}),b.defaulted("eventOrder",{})]})}),g("5g",["q","5f","3g","3d","34","29","z"],function(a,b,c,d,e,f,g){var h=function(e,f){return{uid:e.uid(),dom:e.dom(),behaviours:a.derive([c.config({store:{mode:"memory",initialValue:e.getInitialValue()()}}),b.config({find:g.some})]),events:d.derive([d.runOnAttached(function(a,b){c.setValue(a,e.getInitialValue()())})])}};return e.single({name:"DataField",factory:h,configFields:[f.strict("uid"),f.strict("dom"),f.strict("getInitialValue")]})}),g("88",["4b","14"],function(a,b){var c=function(c,d){return a.nu({attributes:b.wrapAll([{key:d.tabAttr(),value:"true"}])})};return{exhibit:c}}),g("89",["29"],function(a){return[a.defaulted("tabAttr","data-alloy-tabstop")]}),g("64",["q","88","89"],function(a,b,c){return a.create({fields:c,name:"tabstopping",active:b})}),g("94",["v"],function(a){var b=function(a){return a.dom().value},c=function(b,c){if(void 0===c)throw new a("Value.set was undefined");b.dom().value=c};return{set:c,get:b}}),g("7j",["q","32","3g","64","4q","29","14","6","w","94"],function(a,b,c,d,e,f,g,h,i,j){var k=[f.option("data"),f.defaulted("inputAttributes",{}),f.defaulted("inputStyles",{}),f.defaulted("type","input"),f.defaulted("tag","input"),e.onHandler("onSetValue"),f.defaulted("styles",{}),f.option("placeholder"),f.defaulted("eventOrder",{}),f.defaulted("hasTabstop",!0),f.defaulted("inputBehaviours",{}),f.defaulted("selectOnFocus",!0)],l=function(e){return i.deepMerge(a.derive([c.config({store:{mode:"manual",initialValue:e.data().getOr(void 0),getValue:function(a){return j.get(a.element())},setValue:function(a,b){var c=j.get(a.element());c!==b&&j.set(a.element(),b)}},onSetValue:e.onSetValue()}),b.config({onFocus:e.selectOnFocus()===!1?h.noop:function(a){var b=a.element(),c=j.get(b);b.dom().setSelectionRange(0,c.length)}}),e.hasTabstop()?d.config({}):d.revoke()]),e.inputBehaviours())},m=function(a){return{tag:a.tag(),attributes:i.deepMerge(g.wrapAll([{key:"type",value:a.type()}].concat(a.placeholder().map(function(a){return{key:"placeholder",value:a}}).toArray())),a.inputAttributes()),styles:a.inputStyles()}};return{schema:h.constant(k),behaviours:l,dom:m}}),g("5h",["34","7j"],function(a,b){var c=function(a,c){return{uid:a.uid(),dom:b.dom(a),components:[],behaviours:b.behaviours(a),eventOrder:a.eventOrder()}};return a.single({name:"Input",configFields:b.schema(),factory:c})}),g("3i",["3u","q","5f","3g","1g","1h","3d","2","2g","1n","3v","5g","5h","z","i","1o"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q="input-clearing",r=function(l,r){var s=f.record(m.sketch({placeholder:r,onSetValue:function(a,b){h.emit(a,i.input())},inputBehaviours:b.derive([c.config({find:n.some})]),selectOnFocus:!1})),t=f.record(j.sketch({dom:p.dom(''),action:function(a){var b=s.get(a);d.setValue(b,"")}}));return{name:l,spec:k.sketch({dom:p.dom('
          '),components:[s.asSpec(),t.asSpec()],containerBehaviours:b.derive([e.config({toggleClass:o.resolve("input-container-empty")}),c.config({find:function(a){return n.some(s.get(a))}}),a.config(q,[g.run(i.input(),function(a){var b=s.get(a),c=d.getValue(b),f=c.length>0?e.off:e.on;f(a)})])])})}},s=function(a){return{name:a,spec:l.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return n.none()}})}};return{field:r,hidden:s}}),g("7l",["y","4i","2f","b"],function(a,b,c,d){var e=["input","button","textarea"],f=function(a,b,c){b.disabled()&&n(a,b,c)},g=function(b){return a.contains(e,d.name(b.element()))},h=function(a){return b.has(a.element(),"disabled")},i=function(a){b.set(a.element(),"disabled","disabled")},j=function(a){b.remove(a.element(),"disabled")},k=function(a){return"true"===b.get(a.element(),"aria-disabled")},l=function(a){b.set(a.element(),"aria-disabled","true")},m=function(a){b.set(a.element(),"aria-disabled","false")},n=function(a,b,d){b.disableClass().each(function(b){c.add(a.element(),b)});var e=g(a)?i:l;e(a)},o=function(a,b,d){b.disableClass().each(function(b){c.remove(a.element(),b)});var e=g(a)?j:m;e(a)},p=function(a){return g(a)?h(a):k(a)};return{enable:o,disable:n,isDisabled:p,onLoad:f}}),g("7k",["3d","t","27","7l","4b","y"],function(a,b,c,d,e,f){var g=function(a,b,c){return e.nu({classes:b.disabled()?b.disableClass().map(f.pure).getOr([]):[]})},h=function(e,f){return a.derive([a.abort(b.execute(),function(a,b){return d.isDisabled(a,e,f)}),c.loadEvent(e,f,d.onLoad)])};return{exhibit:g,events:h}}),g("7m",["29"],function(a){return[a.defaulted("disabled",!1),a.option("disableClass")]}),g("5i",["q","7k","7l","7m"],function(a,b,c,d){return a.create({fields:d,name:"disabling",active:b,apis:c})}),g("5k",["q","5f","3g","51","52","53","29","y","w","x"],function(a,b,c,d,e,f,g,h,i,j){var k="form",l=[g.defaulted("formBehaviours",{})],m=function(a){return""},n=function(a){var b=function(){var a=[],b=function(b,c){return a.push(b),e.generateOne(k,m(b),c)};return{field:b,record:function(){return a}}}(),c=a(b),g=b.record(),i=h.map(g,function(a){return f.required({name:a,pname:m(a)})});return d.composite(k,l,i,o,c)},o=function(d,f,g){return i.deepMerge({"debug.sketcher":{Form:g},uid:d.uid(),dom:d.dom(),components:f,behaviours:i.deepMerge(a.derive([c.config({store:{mode:"manual",getValue:function(a){var f=e.getAllParts(a,d);return j.map(f,function(a,d){return a().bind(b.getCurrent).map(c.getValue)})},setValue:function(a,f){j.each(f,function(f,g){e.getPart(a,d,g).each(function(a){b.getCurrent(a).each(function(a){c.setValue(a,f)})})})}}})]),d.formBehaviours())})};return{sketch:n}}),g("1z",["z","5"],function(a,b){var c=function(c){var d=b(a.none()),e=function(){d.get().each(c)},f=function(){e(),d.set(a.none())},g=function(b){e(),d.set(a.some(b))},h=function(){return d.get().isSome()};return{clear:f,isSet:h,set:g}},d=function(){return c(function(a){a.destroy()})},e=function(){return c(function(a){a.unbind()})},f=function(){var c=b(a.none()),d=function(){c.get().each(function(a){a.destroy()})},e=function(){d(),c.set(a.none())},f=function(b){d(),c.set(a.some(b))},g=function(a){c.get().each(a)},h=function(){return c.get().isSome()};return{clear:e,isSet:h,set:f,run:g}},g=function(){var c=b(a.none()),d=function(){c.set(a.none())},e=function(b){c.set(a.some(b))},f=function(a){c.get().each(a)},g=function(){return c.get().isSome()};return{clear:d,set:e,isSet:g,on:f}};return{destroyable:d,unbindable:e,api:f,value:g}}),g("5n",[],function(){var a=1,b=-1,c=0,d=function(a){return{xValue:a,points:[]}},e=function(c,d){if(d===c.xValue)return c;var e=d-c.xValue>0?a:b,f={direction:e,xValue:d},g=function(){if(0===c.points.length)return[];var a=c.points[c.points.length-1];return a.direction===e?c.points.slice(0,c.points.length-1):c.points}();return{xValue:d,points:g.concat([f])}},f=function(d){if(0===d.points.length)return c;var e=d.points[0].direction,f=d.points[d.points.length-1].direction;return e===b&&f===b?b:e===a&&f==a?a:c};return{init:d,move:e,complete:f}}),g("3j",["3u","q","5i","5j","33","1f","3g","1h","3d","2","2g","1n","3v","5k","29","2e","y","5","z","1z","39","5l","4u","5m","1l","5n","i","1o"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B){var C=function(f){var C="navigateEvent",D="serializer-wrapper-events",E="form-events",F=p.objOf([o.strict("fields"),o.defaulted("maxFieldIndex",f.fields.length-1),o.strict("onExecute"),o.strict("getInitialValue"),o.state("state",function(){return{dialogSwipeState:t.value(),currentScreen:r(0)}})]),G=p.asRawOrDie("SerialisedDialog",F,f),H=function(a,d,e){return l.sketch({dom:B.dom(''),action:function(b){j.emitWith(b,C,{direction:a})},buttonBehaviours:b.derive([c.config({disableClass:A.resolve("toolbar-navigation-disabled"),disabled:!e})])})},I=function(a,b){w.descendant(a.element(),"."+A.resolve("serialised-dialog-chain")).each(function(a){u.set(a,"left",-G.state.currentScreen.get()*b.width+"px")})},J=function(a,b){var c=v.descendants(a.element(),"."+A.resolve("serialised-dialog-screen"));w.descendant(a.element(),"."+A.resolve("serialised-dialog-chain")).each(function(a){G.state.currentScreen.get()+b>=0&&G.state.currentScreen.get()+b'),components:[m.sketch({dom:B.dom('
          '),components:q.map(G.fields,function(a,b){return b<=G.maxFieldIndex?m.sketch({dom:B.dom('
          '),components:q.flatten([[H(-1,"previous",b>0)],[c.field(a.name,a.spec)],[H(1,"next",b'),behaviours:b.derive([d.config({highlightClass:A.resolve("dot-active"),itemClass:A.resolve("dot-item")})]),components:q.bind(G.fields,function(a,b){return b<=G.maxFieldIndex?[B.spec('
          ')]:[]})});return{dom:B.dom('
          '),components:[M.asSpec(),N.asSpec()],behaviours:b.derive([e.config({mode:"special",focusIn:function(a){var b=M.get(a);e.focusIn(b)}}),a.config(D,[i.run(k.touchstart(),function(a,b){G.state.dialogSwipeState.set(z.init(b.event().raw().touches[0].clientX))}),i.run(k.touchmove(),function(a,b){G.state.dialogSwipeState.on(function(a){b.event().prevent(),G.state.dialogSwipeState.set(z.move(a,b.event().raw().touches[0].clientX))})}),i.run(k.touchend(),function(a){G.state.dialogSwipeState.on(function(b){var c=M.get(a),d=-1*z.complete(b);J(c,d)})})])])}};return{sketch:C}}),g("3k",["6","7"],function(a,b){var c=b.detect(),d=function(a,b){var c=b.selection.getRng();a(),b.selection.setRng(c)},e=function(b,e){var f=c.os.isAndroid()?d:a.apply;f(e,b)};return{forAndroid:e}}),g("1s",["3g","z","17","3h","l","3i","3j","3k"],function(a,b,c,d,e,f,g,h){var i=c.cached(function(c,e){return[{label:"the link group",items:[g.sketch({fields:[f.field("url","Type or paste URL"),f.field("text","Link text"),f.field("title","Link title"),f.field("target","Link target"),f.hidden("link")],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return b.some(d.getInfo(e))},onExecute:function(b){var f=a.getValue(b);d.applyInfo(e,f),c.restoreToolbar(),e.focus()}})]}]}),j=function(a,b){return e.forToolbarStateAction(b,"link","link",function(){var c=i(a,b);a.setContextToolbar(c),h.forAndroid(b,function(){a.focusToolbar()}),d.query(b).each(function(a){b.selection.select(a.dom())})})};return{sketch:j}}),g("3l",[],function(){return[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}]}),g("7r",["14","6","z","4i","2f"],function(a,b,c,d,e){var f=function(c,d,e,f){return a.readOptFrom(d.routes(),f.start()).map(b.apply).bind(function(c){return a.readOptFrom(c,f.destination()).map(b.apply)})},g=function(a,b,c){var d=k(a,b,c);return d.bind(function(d){return h(a,b,c,d)})},h=function(a,c,d,e){return f(a,c,d,e).bind(function(a){return a.transition().map(function(c){return{transition:b.constant(c),route:b.constant(a)}})})},i=function(a,b,c){g(a,b,c).each(function(c){var f=c.transition();e.remove(a.element(),f.transitionClass()),d.remove(a.element(),b.destinationAttr())})},j=function(a,c,e,f){return{start:b.constant(d.get(a.element(),c.stateAttr())),destination:b.constant(f)}},k=function(a,e,f){var g=a.element();return d.has(g,e.destinationAttr())?c.some({start:b.constant(d.get(a.element(),e.stateAttr())),destination:b.constant(d.get(a.element(),e.destinationAttr()))}):c.none()},l=function(a,b,c,e){i(a,b,c),d.has(a.element(),b.stateAttr())&&d.get(a.element(),b.stateAttr())!==e&&b.onFinish()(a,e),d.set(a.element(),b.stateAttr(),e)},m=function(a,b,c,e){d.has(a.element(),b.destinationAttr())&&(d.set(a.element(),b.stateAttr(),d.get(a.element(),b.destinationAttr())),d.remove(a.element(),b.destinationAttr()))},n=function(a,b,c,f){m(a,b,c,f);var g=j(a,b,c,f);h(a,b,c,g).fold(function(){l(a,b,c,f)},function(g){i(a,b,c);var h=g.transition();e.add(a.element(),h.transitionClass()),d.set(a.element(),b.destinationAttr(),f)})},o=function(a,b,e){var f=a.element();return d.has(f,b.stateAttr())?c.some(d.get(f,b.stateAttr())):c.none()};return{findRoute:f,disableTransition:i,getCurrentRoute:k,jumpTo:l,progressTo:n,getState:o}}),g("7q",["3d","2g","7r"],function(a,b,c){var d=function(d,e){return a.derive([a.run(b.transitionend(),function(a,b){var f=b.event().raw();c.getCurrentRoute(a,d,e).each(function(b){c.findRoute(a,d,e,b).each(function(g){g.transition().each(function(g){f.propertyName===g.property()&&(c.jumpTo(a,d,e,b.destination()),d.onTransition()(a,b))})})})}),a.runOnAttached(function(a,b){c.jumpTo(a,d,e,d.initialState())})])};return{events:d}}),g("7s",["4q","29","2e","48"],function(a,b,c,d){return[b.defaulted("destinationAttr","data-transitioning-destination"),b.defaulted("stateAttr","data-transitioning-state"),b.strict("initialState"),a.onHandler("onTransition"),a.onHandler("onFinish"),b.strictOf("routes",c.setOf(d.value,c.setOf(d.value,c.objOfOnly([b.optionObjOfOnly("transition",[b.strict("property"),b.strict("transitionClass")])]))))]}),g("5o",["q","7q","7r","7s","14","x"],function(a,b,c,d,e,f){var g=function(a){var b={};return f.each(a,function(a,c){var d=c.split("<->");b[d[0]]=e.wrap(d[1],a),b[d[1]]=e.wrap(d[0],a)}),b},h=function(a,b,c){return e.wrapAll([{key:a,value:e.wrap(b,c)},{key:b,value:e.wrap(a,c)}])},i=function(a,b,c,d){return e.wrapAll([{key:a,value:e.wrapAll([{key:b,value:d},{key:c,value:d}])},{key:b,value:e.wrapAll([{key:a,value:d},{key:c,value:d}])},{key:c,value:e.wrapAll([{key:a,value:d},{key:b,value:d}])}])};return a.create({fields:d,name:"transitioning",active:b,apis:c,extra:{createRoutes:g,createBistate:h,createTristate:i}})}),g("7u",["28","4c","29","2e","y","6","x","6n","v"],function(a,b,c,d,e,f,g,h,i){var j=function(j,k){var l=e.map(k,function(e){return c.field(e.name(),e.name(),b.asOption(),d.objOf([c.strict("config"),c.defaulted("state",a)]))}),m=d.asStruct("component.behaviours",d.objOf(l),j.behaviours).fold(function(a){throw new i(d.formatError(a)+"\nComplete spec:\n"+h.stringify(j,null,2))},f.identity);return{list:k,data:g.map(m,function(a){var b=a();return f.constant(b.map(function(a){return{config:a.config(),state:a.state().init(a.config())}}))})}},k=function(a){return a.list},l=function(a){return a.data};return{generateFrom:j,getBehaviours:k,getData:l}}),g("7t",["7u","14","y","x","v"],function(a,b,c,d,e){var f=function(a){var e=b.readOptFrom(a,"behaviours").getOr({}),f=c.filter(d.keys(e),function(a){return void 0!==e[a]});return c.map(f,function(b){return a.behaviours[b].me})},g=function(b,c){return a.generateFrom(b,c)},h=function(a){var b=f(a);return g(a,b)};return{generate:h,generateFrom:g}}),g("5q",["6q"],function(a){return a.exactly(["getSystem","config","spec","connect","disconnect","element","syncComponents","readState","components","events"])}),g("6a",["6q"],function(a){return a.exactly(["debugInfo","triggerFocus","triggerEvent","triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","getByUid","getByDom","broadcast","broadcastOn"])}),g("5r",["6a","13","6","v"],function(a,b,c,d){return function(e){var f=function(a){return function(){throw new d("The component must be in a context to send: "+a+"\n"+b.element(e().element())+" is not in context.")}};return a({debugInfo:c.constant("fake"),triggerEvent:f("triggerEvent"),triggerFocus:f("triggerFocus"),triggerEscape:f("triggerEscape"),build:f("build"),addToWorld:f("addToWorld"),removeFromWorld:f("removeFromWorld"),addToGui:f("addToGui"),removeFromGui:f("removeFromGui"),getByUid:f("getByUid"),getByDom:f("getByDom"),broadcast:f("broadcast"),broadcastOn:f("broadcastOn")})}}),g("96",["14","x"],function(a,b){var c=function(c,d){var e={};return b.each(c,function(c,f){b.each(c,function(b,c){var g=a.readOr(c,[])(e);e[c]=g.concat([d(f,b)])})}),e};return{byInnerKey:c}}),g("7v",["96","4b","14","y","x","w","6n","6","48"],function(a,b,c,d,e,f,g,h,i){var j=function(a,b){return{name:h.constant(a),modification:b}},k=function(a,b){var e=d.bind(a,function(a){return a.modification().getOr([])});return i.value(c.wrap(b,e))},l=function(a,b,e){return a.length>1?i.error('Multiple behaviours have tried to change DOM "'+b+'". The guilty behaviours are: '+g.stringify(d.map(a,function(a){return a.name()}))+". At this stage, this is not supported. Future releases might provide strategies for resolving this."):0===a.length?i.value({}):i.value(a[0].modification().fold(function(){return{}},function(a){return c.wrap(b,a)}))},m=function(a,b,c,e){return i.error("Mulitple behaviours have tried to change the _"+b+'_ "'+a+'". The guilty behaviours are: '+g.stringify(d.bind(e,function(a){return void 0!==a.modification().getOr({})[b]?[a.name()]:[]}),null,2)+". This is not currently supported.")},n=function(a,b){var f=d.foldl(a,function(d,f){var g=f.modification().getOr({});return d.bind(function(d){var f=e.mapToArray(g,function(e,f){return void 0!==d[f]?m(b,f,g,a):i.value(c.wrap(f,e))});return c.consolidate(f,d)})},i.value({}));return f.map(function(a){return c.wrap(b,a)})},o={classes:k,attributes:n,styles:n,domChildren:l,defChildren:l,innerHtml:l,value:l},p=function(g,h,k,l){var m=f.deepMerge({},h);d.each(k,function(a){m[a.name()]=a.exhibit(g,l)});var n=a.byInnerKey(m,j),p=e.map(n,function(a,b){return d.bind(a,function(a){return a.modification().fold(function(){return[]},function(b){return[a]})})}),q=e.mapToArray(p,function(a,b){return c.readOptFrom(o,b).fold(function(){return i.error("Unknown field type: "+b)},function(c){return c(a,b)})}),r=c.consolidate(q,{});return r.map(b.nu)};return{combine:p}}),g("97",["6n","48","v"],function(a,b,c){var d=function(d,e,f,g){var h=f.slice(0);try{var i=h.sort(function(b,f){var h=b[e](),i=f[e](),j=g.indexOf(h),k=g.indexOf(i);if(j===-1)throw new c("The ordering for "+d+" does not have an entry for "+h+".\nOrder specified: "+a.stringify(g,null,2));if(k===-1)throw new c("The ordering for "+d+" does not have an entry for "+i+".\nOrder specified: "+a.stringify(g,null,2));return j1?f.filter(b,function(b){return f.contains(a,function(a){return a.name()===b})}).join(" > "):a[0].name();return e.wrap(c,d.nu(h,i))})});return e.consolidate(c,{})};return{combine:q}}),g("7x",["4q","6o","4b","4s","4c","29","14","2e","y","6","w","v"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=function(b){return h.asStruct("custom.definition",h.objOfOnly([f.field("dom","dom",e.strict(),h.objOfOnly([f.strict("tag"),f.defaulted("styles",{}),f.defaulted("classes",[]),f.defaulted("attributes",{}),f.option("value"),f.option("innerHtml")])),f.strict("components"),f.strict("uid"),f.defaulted("events",{}),f.defaulted("apis",j.constant({})),f.field("eventOrder","eventOrder",e.mergeWith({"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"alloy.focus":["alloy.base.behaviour","keying","focusing"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing"]}),h.anyValue()),f.option("domModification"),a.snapshot("originalSpec"),f.defaulted("debug.sketcher","unknown")]),b)},n=function(a){return g.wrap(d.idAttr(),a.uid())},o=function(a){var c={tag:a.dom().tag(),classes:a.dom().classes(),attributes:k.deepMerge(n(a),a.dom().attributes()),styles:a.dom().styles(),domChildren:i.map(a.components(),function(a){return a.element()})};return b.nu(k.deepMerge(c,a.dom().innerHtml().map(function(a){return g.wrap("innerHtml",a)}).getOr({}),a.dom().value().map(function(a){return g.wrap("value",a)}).getOr({})))},p=function(a){return a.domModification().fold(function(){return c.nu({})},c.nu)},q=function(a){return a.apis()},r=function(a){return a.events()};return{toInfo:m,toDefinition:o,toModification:p,toApis:q,toEvents:r}}),g("8a",["y","2f","4j","u"],function(a,b,c,d){var e=function(c,d){a.each(d,function(a){b.add(c,a)})},f=function(c,d){a.each(d,function(a){b.remove(c,a)})},g=function(c,d){a.each(d,function(a){b.toggle(c,a)})},h=function(c,d){return a.forall(d,function(a){return b.has(c,a)})},i=function(c,d){return a.exists(d,function(a){return b.has(c,a)})},j=function(a){for(var b=a.dom().classList,c=new d(b.length),e=0;e1?f.some(a.slice(1)):f.none()})},r=function(a){return b.readOptFrom(j.get(),a)},s=function(a){return b.readOptFrom(i.get(),a)},t=function(a){var b=l.get()(i.get());return c.difference(d.keys(b),a)},u=function(){return k.get().bind(s)},v=function(){return i.get()};return{setContents:o,expand:p,refresh:r,collapse:q,lookupMenu:s,otherMenus:t,getPrimary:u,getMenus:v,clear:m,isClear:n}}}),g("81",["8w","q","5f","5j","33","1y","3g","3q","3d","2","t","98","5u","9e","9c","9d","14","y","6","w","x","z","15","12","2f","8a","4u"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A){var B=function(s,B){var C=function(a,b){return u.map(b,function(b,c){var d=m.sketch(t.deepMerge(b,{value:c,items:b.items,markers:q.narrow(B.markers,["item","selectedItem"]),fakeFocus:s.fakeFocus(),onHighlight:s.onHighlight(),focusManager:s.fakeFocus()?l.highlights():l.dom()}));return a.getSystem().build(d)})},D=n(),E=function(a){var b=C(a,s.data().menus());return D.setContents(s.data().primary(),b,s.data().expansions(),function(b){return G(a,b)}),D.getPrimary()},F=function(a){return g.getValue(a).value},G=function(a,b){return u.map(s.data().menus(),function(a,b){return r.bind(a.items,function(a){return"separator"===a.type?[]:[a.data.value]})})},H=function(a,b){d.highlight(a,b),d.getHighlighted(b).orThunk(function(){return d.getFirst(b)}).each(function(b){j.dispatch(a,b.element(),k.focusItem())})},I=function(a,b){return w.cat(r.map(b,a.lookupMenu))},J=function(a,b,c){return v.from(c[0]).bind(b.lookupMenu).map(function(d){var e=I(b,c.slice(1));r.each(e,function(a){y.add(a.element(),s.markers().backgroundMenu())}),x.inBody(d.element())||f.append(a,h.premade(d)),z.remove(d.element(),[s.markers().backgroundMenu()]),H(a,d);var g=I(b,b.otherMenus(c));return r.each(g,function(b){z.remove(b.element(),[s.markers().backgroundMenu()]),s.stayInDom()||f.remove(a,b)}),d})},K=function(a,b){var c=F(b);return D.expand(c).bind(function(c){return v.from(c[0]).bind(D.lookupMenu).each(function(c){x.inBody(c.element())||f.append(a,h.premade(c)),s.onOpenSubmenu()(a,b,c),d.highlightFirst(c)}),J(a,D,c)})},L=function(a,b){var c=F(b);return D.collapse(c).bind(function(c){return J(a,D,c).map(function(c){return s.onCollapseMenu()(a,b,c),c})})},M=function(a,b){var c=F(b);return D.refresh(c).bind(function(b){return J(a,D,b)})},N=function(b,c){return a.inside(c.element())?v.none():K(b,c)},O=function(b,c){return a.inside(c.element())?v.none():L(b,c)},P=function(a,b){return L(a,b).orThunk(function(){return s.onEscape()(a,b)})},Q=function(a){return function(b,c){return A.closest(c.getSource(),"."+s.markers().item()).bind(function(c){return b.getSystem().getByDom(c).bind(function(c){return a(b,c)})})}},R=i.derive([i.run(p.focus(),function(a,b){var c=b.event().menu();d.highlight(a,c)}),i.runOnExecute(function(a,b){var c=b.event().target();return a.getSystem().getByDom(c).bind(function(b){var c=F(b);return 0===c.indexOf("collapse-item")?L(a,b):K(a,b).orThunk(function(){return s.onExecute()(a,b)})})}),i.runOnAttached(function(a,b){E(a).each(function(b){f.append(a,h.premade(b)),s.openImmediately()&&(H(a,b),s.onOpenMenu()(a,b))})})].concat(s.navigateOnHover()?[i.run(o.hover(),function(a,b){var c=b.event().item();M(a,c),K(a,c),s.onHover()(a,c)})]:[])),S=function(a){d.getHighlighted(a).each(function(b){d.getHighlighted(b).each(function(b){L(a,b)})})};return{uid:s.uid(),dom:s.dom(),behaviours:t.deepMerge(b.derive([e.config({mode:"special",onRight:Q(N),onLeft:Q(O),onEscape:Q(P),focusIn:function(a,b){D.getPrimary().each(function(b){j.dispatch(a,b.element(),k.focusItem())})}}),d.config({highlightClass:s.markers().selectedMenu(),itemClass:s.markers().menu()}),c.config({find:function(a){return d.getHighlighted(a)}}),f.config({})]),s.tmenuBehaviours()),eventOrder:s.eventOrder(),apis:{collapseMenu:S},events:R}};return{make:B,collapseItem:s.constant("collapse-item")}}),g("5v",["34","4q","81","29","14","3f"],function(a,b,c,d,e,f){var g=function(a,b,c){return{primary:a,menus:b,expansions:c}},h=function(a,b){return{primary:a,menus:e.wrap(a,b),expansions:{}}},i=function(a){return{value:f.generate(c.collapseItem()),text:a}};return a.single({name:"TieredMenu",configFields:[b.onStrictKeyboardHandler("onExecute"),b.onStrictKeyboardHandler("onEscape"),b.onStrictHandler("onOpenMenu"),b.onStrictHandler("onOpenSubmenu"),b.onHandler("onCollapseMenu"),d.defaulted("openImmediately",!0),d.strictObjOf("data",[d.strict("primary"),d.strict("menus"),d.strict("expansions")]),d.defaulted("fakeFocus",!1),b.onHandler("onHighlight"),b.onHandler("onHover"),b.tieredMenuMarkers(),d.strict("dom"),d.defaulted("navigateOnHover",!0),d.defaulted("stayInDom",!1),d.defaulted("tmenuBehaviours",{}),d.defaulted("eventOrder",{})],apis:{collapseMenu:function(a,b){a.collapseMenu(b)}},factory:c.make,extraApis:{tieredData:g,singleData:h,collapseItem:i}})}),g("3z",["6","2f","i"],function(a,b,c){var d=c.resolve("scrollable"),e=function(a){b.add(a,d)},f=function(a){b.remove(a,d)};return{register:e,deregister:f,scrollable:a.constant(d)}}),g("3m",["3u","q","3g","1g","5o","3q","1h","3d","1n","5u","5v","14","y","w","x","39","4u","5m","1l","i","3z"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){var v=function(a){return l.readOptFrom(a,"format").getOr(a.title)},w=function(a,b){var c=y("Styles",[].concat(m.map(a.items,function(b){return x(v(b),b.title,b.isSelected(),b.getPreview(),l.hasKey(a.expansions,v(b)))})),b,!1),d=o.map(a.menus,function(c,d){ +var e=m.map(c,function(b){return x(v(b),b.title,void 0!==b.isSelected&&b.isSelected(),void 0!==b.getPreview?b.getPreview():"",l.hasKey(a.expansions,v(b)))});return y(d,e,b,!0)}),e=n.deepMerge(d,l.wrap("styles",c)),f=k.tieredData("styles",e,a.expansions);return{tmenu:f}},x=function(a,c,e,f,g){return{data:{value:a,text:c},type:"item",dom:{tag:"div",classes:g?[t.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:t.resolve("format-matches"),selected:e},itemBehaviours:b.derive(g?[]:[s.format(a,function(a,b){var c=b?d.on:d.off;c(a)})]),components:[{dom:{tag:"div",attributes:{style:f},innerHtml:c}}]}},y=function(c,d,g,l){return{value:c,dom:{tag:"div"},components:[i.sketch({dom:{tag:"div",classes:[t.resolve("styles-collapser")]},components:l?[{dom:{tag:"span",classes:[t.resolve("styles-collapse-icon")]}},f.text(c)]:[f.text(c)],action:function(a){if(l){var b=g().get(a);k.collapseMenu(b)}}}),{dom:{tag:"div",classes:[t.resolve("styles-menu-items-container")]},components:[j.parts().items({})],behaviours:b.derive([a.config("adhoc-scrollable-menu",[h.runOnAttached(function(a,b){p.set(a.element(),"overflow-y","auto"),p.set(a.element(),"-webkit-overflow-scrolling","touch"),u.register(a.element())}),h.runOnDetached(function(a){p.remove(a.element(),"overflow-y"),p.remove(a.element(),"-webkit-overflow-scrolling"),u.deregister(a.element())})])])}],items:d,menuBehaviours:b.derive([e.config({initialState:"after",routes:e.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},z=function(a){var b=w(a.formats,function(){return d}),d=g.record(k.sketch({dom:{tag:"div",classes:[t.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(b,d){var e=c.getValue(d);a.handle(d,e.value)},onEscape:function(){},onOpenMenu:function(a,b){var c=r.get(a.element());r.set(b.element(),c),e.jumpTo(b,"current")},onOpenSubmenu:function(a,b,c){var d=r.get(a.element()),f=q.ancestor(b.element(),'[role="menu"]').getOrDie("hacky"),g=a.getSystem().getByDom(f).getOrDie();r.set(c.element(),d),e.progressTo(g,"before"),e.jumpTo(c,"after"),e.progressTo(c,"current")},onCollapseMenu:function(a,b,c){var d=q.ancestor(b.element(),'[role="menu"]').getOrDie("hacky"),f=a.getSystem().getByDom(d).getOrDie();e.progressTo(f,"after"),e.progressTo(c,"current")},navigateOnHover:!1,openImmediately:!0,data:b.tmenu,markers:{backgroundMenu:t.resolve("styles-background-menu"),menu:t.resolve("styles-menu"),selectedMenu:t.resolve("styles-selected-menu"),item:t.resolve("styles-item"),selectedItem:t.resolve("styles-selected-item")}}));return d.asSpec()};return{sketch:z}}),g("3n",["14","y","w"],function(a,b,c){var d=function(b){var d=c.deepMerge(a.exclude(b,["items"]),{menu:!0}),e=f(b.items,b.title),g=c.deepMerge(e.menus,a.wrap(b.title,e.items)),h=c.deepMerge(e.expansions,a.wrap(b.title,b.title));return{item:d,menus:g,expansions:h}},e=function(b){return a.hasKey(b,"items")?d(b):{item:b,menus:{},expansions:{}}},f=function(a){return b.foldr(a,function(a,b){var d=e(b);return{menus:c.deepMerge(a.menus,d.menus),items:[d.item].concat(a.items),expansions:c.deepMerge(a.expansions,d.expansions)}},{menus:{},expansions:{},items:[]})};return{expand:f}}),g("1t",["1g","14","y","6","3f","w","3l","3m","3n"],function(a,b,c,d,e,f,g,h,i){var j=function(a,h){var i=function(b){return function(){return a.formatter.match(b)}},j=function(b){return function(){var c=a.formatter.getCssText(b);return c}},k=function(a){return f.deepMerge(a,{isSelected:i(a.format),getPreview:j(a.format)})},l=function(a){return f.deepMerge(a,{isSelected:d.constant(!1),getPreview:d.constant("")})},m=function(b){var c=e.generate(b.title),d=f.deepMerge(b,{format:c,isSelected:i(c),getPreview:j(c)});return a.formatter.register(c,d),d},n=b.readOptFrom(h,"style_formats").getOr(g),o=function(a){return c.map(a,function(a){if(b.hasKey(a,"items")){var c=o(a.items);return f.deepMerge(l(a),{items:c})}return b.hasKey(a,"format")?k(a):m(a)})};return o(n)},k=function(a,d){var e=function(d){return c.bind(d,function(c){if(void 0!==c.items){var d=e(c.items);return d.length>0?[c]:[]}var f=!b.hasKey(c,"format")||a.formatter.canApply(c.format);return f?[c]:[]})},f=e(d);return i.expand(f)},l=function(b,c,d){var e=k(b,c);return h.sketch({formats:e,handle:function(c,e){b.undoManager.transact(function(){a.isOn(c)?b.formatter.remove(e):b.formatter.apply(e)}),d()}})};return{register:j,ui:l}}),g("h",["q","1f","1g","1h","14","y","6","z","1i","1j","1k","1l","g","i","l","1p","1q","1r","1s","1t"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=["undo","bold","italic","link","image","bullist","styleselect"],v=function(a){var b=a.replace(/\|/g," ").trim();return b.length>0?b.split(/\s+/):[]},w=function(a){return f.bind(a,function(a){return i.isArray(a)?w(a):v(a)})},x=function(a){var b=void 0!==a.toolbar?a.toolbar:u;return i.isArray(b)?w(b):v(b)},y=function(d,f){var g=function(a){return function(){return o.forToolbarCommand(f,a)}},i=function(a){return function(){return o.forToolbarStateCommand(f,a)}},j=function(a,b,c){return function(){return o.forToolbarStateAction(f,a,b,c)}},k=g("undo"),u=g("redo"),v=i("bold"),w=i("italic"),x=i("underline"),y=g("removeformat"),z=function(){return s.sketch(d,f)},A=j("unlink","link",function(){f.execCommand("unlink",null,!1)}),B=function(){return r.sketch(f)},C=j("unordered-list","ul",function(){f.execCommand("InsertUnorderedList",null,!1)}),D=j("ordered-list","ol",function(){f.execCommand("InsertOrderedList",null,!1)}),E=function(){return q.sketch(d,f)},F=function(){return p.sketch(d,f)},G=t.register(f,f.settings),H=function(){return t.ui(f,G,function(){f.fire("scrollIntoView")})},I=function(){return o.forToolbar("style-formats",function(a){f.fire("toReading"),d.dropup().appear(H,c.on,a)},a.derive([c.config({toggleClass:n.resolve("toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),b.config({channels:e.wrapAll([l.receive(m.orientationChanged(),c.off),l.receive(m.dropupDismissed(),c.off)])})]))},J=function(a,b){return{isSupported:function(){return a.forall(function(a){return e.hasKey(f.buttons,a)})},sketch:b}};return{undo:J(h.none(),k),redo:J(h.none(),u),bold:J(h.none(),v),italic:J(h.none(),w),underline:J(h.none(),x),removeformat:J(h.none(),y),link:J(h.none(),z),unlink:J(h.none(),A),image:J(h.none(),B),bullist:J(h.some("bullist"),C),numlist:J(h.some("numlist"),D),fontsizeselect:J(h.none(),E),forecolor:J(h.none(),F),styleselect:J(h.none(),I)}},z=function(a,b){var c=x(a),d={};return f.bind(c,function(a){var c=!e.hasKey(d,a)&&e.hasKey(b,a)&&b[a].isSupported()?[b[a].sketch()]:[];return d[a]=!0,c})};return{identify:x,setup:y,detect:z}}),g("3o",["6","a"],function(a,b){var c=function(b,c,d,e,f,g,h){return{target:a.constant(b),x:a.constant(c),y:a.constant(d),stop:e,prevent:f,kill:g,raw:a.constant(h)}},d=function(d,e){return function(f){if(d(f)){var g=b.fromDom(f.target),h=function(){f.stopPropagation()},i=function(){f.preventDefault()},j=a.compose(i,h),k=c(g,f.clientX,f.clientY,h,i,j,f);e(k)}}},e=function(b,c,e,f,g){var i=d(e,f);return b.dom().addEventListener(c,i,g),{unbind:a.curry(h,b,c,i,g)}},f=function(a,b,c,d){return e(a,b,c,d,!1)},g=function(a,b,c,d){return e(a,b,c,d,!0)},h=function(a,b,c,d){a.dom().removeEventListener(b,c,d)};return{bind:f,capture:g}}),g("1u",["6","3o"],function(a,b){var c=a.constant(!0),d=function(a,d,e){return b.bind(a,d,c,e)},e=function(a,d,e){return b.capture(a,d,c,e)};return{bind:d,capture:e}}),h("1v",clearInterval),h("1x",setInterval),g("j",["6","z","7","1u","a","1v","1w","1x"],function(a,b,c,d,e,f,g,h){var i=50,j=1e3/i,k=function(b){var c=b.matchMedia("(orientation: portrait)").matches;return{isPortrait:a.constant(c)}},l=function(a){var b=c.detect().os.isiOS(),d=k(a).isPortrait();return b&&!d?a.screen.height:a.screen.width},m=function(a,c){var g=e.fromDom(a),l=null,m=function(){f(l);var b=k(a);c.onChange(b),o(function(){c.onReady(b)})},n=d.bind(g,"orientationchange",m),o=function(c){f(l);var d=a.innerHeight,e=0;l=h(function(){d!==a.innerHeight?(f(l),c(b.some(a.innerHeight))):e>j&&(f(l),c(b.none())),e++},i)},p=function(){n.unbind()};return{onAdjustment:o,destroy:p}};return{get:k,onChange:m,getActualWidth:l}}),h("87",clearTimeout),g("9f",["87","1j"],function(a,b){return function(c,d){var e=null,f=function(){var a=arguments;e=b(function(){c.apply(null,a),e=null},d)},g=function(){null!==e&&(a(e),e=null)};return{cancel:g,schedule:f}}}),g("8d",["9f","2g","t","14","5","6","z","1a","1w"],function(a,b,c,d,e,f,g,h,i){var j=5,k=400,l=function(a){return void 0===a.raw().touches||1!==a.raw().touches.length?g.none():g.some(a.raw().touches[0])},m=function(a,b){var c=i.abs(a.clientX-b.x()),d=i.abs(a.clientY-b.y());return c>j||d>j},n=function(i){var j=e(g.none()),n=a(function(a){j.set(g.none()),i.triggerEvent(c.longpress(),a)},k),o=function(a){return l(a).each(function(b){n.cancel();var c={x:f.constant(b.clientX),y:f.constant(b.clientY),target:a.target};n.schedule(c),j.set(g.some(c))}),g.none()},p=function(a){return n.cancel(),l(a).each(function(a){j.get().each(function(b){m(a,b)&&j.set(g.none())})}),g.none()},q=function(a){n.cancel();var b=function(b){return h.eq(b.target(),a.target())};return j.get().filter(b).map(function(b){return i.triggerEvent(c.tap(),a)})},r=d.wrapAll([{key:b.touchstart(),value:o},{key:b.touchmove(),value:p},{key:b.touchend(),value:q}]),s=function(a,b){return d.readOptFrom(r,b).bind(function(b){return b(a)})};return{fireIfReady:s}};return{monitor:n}}),g("82",["8d","1u"],function(a,b){var c=function(c){var d=a.monitor({triggerEvent:function(a,b){c.onTapContent(b)}}),e=function(){return b.bind(c.body(),"touchend",function(a){d.fireIfReady(a,"touchend")})},f=function(){return b.bind(c.body(),"touchmove",function(a){d.fireIfReady(a,"touchmove")})},g=function(a){d.fireIfReady(a,"touchstart")};return{fireTouchstart:g,onTouchend:e,onTouchmove:f}};return{monitor:c}}),g("5x",["1g","y","6","7","1a","8","1u","a","b","10","82"],function(a,b,c,d,e,f,g,h,i,j,k){var l=d.detect().os.version.major>=6,m=function(d,m,n){var o=k.monitor(d),p=j.owner(m),q=function(a){return!e.eq(a.start(),a.finish())||a.soffset()!==a.foffset()},r=function(){return f.active(p).filter(function(a){return"input"===i.name(a)}).exists(function(a){return a.dom().selectionStart!==a.dom().selectionEnd})},s=function(){var b=d.doc().dom().hasFocus()&&d.getSelection().exists(q);n.getByDom(m).each((b||r())===!0?a.on:a.off)},t=[g.bind(d.body(),"touchstart",function(a){d.onTouchContent(),o.fireTouchstart(a)}),o.onTouchmove(),o.onTouchend(),g.bind(m,"touchstart",function(a){d.onTouchToolstrip()}),d.onToReading(function(){f.blur(d.body())}),d.onToEditing(c.noop),d.onScrollToCursor(function(a){a.preventDefault(),d.getCursorBox().each(function(a){var b=d.win(),c=a.top()>b.innerHeight||a.bottom()>b.innerHeight,e=c?a.bottom()-b.innerHeight+50:0;0!==e&&b.scrollTo(b.pageXOffset,b.pageYOffset+e)})})].concat(l===!0?[]:[g.bind(h.fromDom(d.win()),"blur",function(){n.getByDom(m).each(a.off)}),g.bind(p,"select",s),g.bind(d.doc(),"selectionchange",s)]),u=function(){b.each(t,function(a){a.unbind()})};return{destroy:u}};return{initEvents:m}}),g("83",["y","6","8","a","b","1j"],function(a,b,c,d,e,f){var g=function(){return function(a){f(function(){a()},0)}},h=function(f){f.focus();var h=d.fromDom(f.document.body),i=c.active().exists(function(b){return a.contains(["input","textarea"],e.name(b))}),j=i?g(h):b.apply;j(function(){c.active().each(c.blur),c.focus(h)})};return{resume:h}}),h("9g",isNaN),h("8i",parseInt),g("84",["4i","9g","8i"],function(a,b,c){var d=function(d,e){var f=c(a.get(d,e),10);return b(f)?0:f};return{safeParse:d}}),g("ab",["7","z","v"],function(a,b,c){return function(d,e){var f=function(a){if(!d(a))throw new c("Can only get "+e+" value of a "+e+" node");return j(a).getOr("")},g=function(a){try{return h(a)}catch(a){return b.none()}},h=function(a){return d(a)?b.from(a.dom().nodeValue):b.none()},i=a.detect().browser,j=i.isIE()&&10===i.version.major?g:h,k=function(a,b){if(!d(a))throw new c("Can only set raw "+e+" value of a "+e+" node");a.dom().nodeValue=b};return{get:f,getOption:j,set:k}}}),g("a4",["b","ab"],function(a,b){var c=b(a.isText,"text"),d=function(a){return c.get(a)},e=function(a){return c.getOption(a)},f=function(a,b){c.set(a,b)};return{get:d,getOption:e,set:f}}),g("9h",["y","b","a4","10"],function(a,b,c,d){var e=function(a){return"img"===b.name(a)?1:c.getOption(a).fold(function(){return d.children(a).length},function(a){return a.length})},f=function(a,b){return e(a)===b},g=function(a,b){return 0===b},h="\xa0",i=function(a){return c.getOption(a).filter(function(a){return 0!==a.trim().length||a.indexOf(h)>-1}).isSome()},j=["img","br"],k=function(c){var d=i(c);return d||a.contains(j,b.name(c))};return{getEnd:e,isEnd:f,isStart:g,isCursorPosition:k}}),g("a5",["6k","6"],function(a,b){var c=a.generate([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),d=function(a,b,c,d){return a.fold(b,c,d)},e=function(a){return a.fold(b.identity,b.identity,b.identity)};return{before:c.before,on:c.on,after:c.after,cata:d,getStart:e}}),g("9i",["6k","2o","a","10","a5"],function(a,b,c,d,e){var f=a.generate([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),g=b.immutable("start","soffset","finish","foffset"),h=function(a){return f.exact(a.start(),a.soffset(),a.finish(),a.foffset())},i=function(a){return a.match({domRange:function(a){return c.fromDom(a.startContainer)},relative:function(a,b){return e.getStart(a)},exact:function(a,b,c,d){return a}})},j=function(a){var b=i(a);return d.defaultView(b)};return{domRange:f.domRange,relative:f.relative,exact:f.exact,exactFromRange:h,range:g,getWin:j}}),g("9j",["1a","a","10"],function(a,b,c){var d=function(a,b,d,e){var f=c.owner(a),g=f.dom().createRange();return g.setStart(a.dom(),b),g.setEnd(d.dom(),e),g},e=function(a,c,e,f){var g=d(a,c,e,f);return b.fromDom(g.commonAncestorContainer)},f=function(b,c,e,f){var g=d(b,c,e,f),h=a.eq(b,e)&&c===f;return g.collapsed&&!h};return{after:f,commonAncestorContainer:e}}),g("9k",["y","a","1b"],function(a,b,c){var d=function(d,e){var f=e||c,g=f.createDocumentFragment();return a.each(d,function(a){g.appendChild(a.dom())}),b.fromDom(g)};return{fromElements:d}}),g("9l",["6","z","1a","a"],function(a,b,c,d){var e=function(a,b){var c=a.document.createRange();return f(c,b),c},f=function(a,b){a.selectNodeContents(b.dom())},g=function(a,b){return b.compareBoundaryPoints(a.END_TO_START,a)<1&&b.compareBoundaryPoints(a.START_TO_END,a)>-1},h=function(a){return a.document.createRange()},i=function(a,b){b.fold(function(b){a.setStartBefore(b.dom())},function(b,c){a.setStart(b.dom(),c)},function(b){a.setStartAfter(b.dom())})},j=function(a,b){b.fold(function(b){a.setEndBefore(b.dom())},function(b,c){a.setEnd(b.dom(),c)},function(b){a.setEndAfter(b.dom())})},k=function(a,b){o(a),a.insertNode(b.dom())},l=function(a,b,d,e){return c.eq(a,d)&&b===e},m=function(a,b,c){var d=a.document.createRange();return i(d,b),j(d,c),d},n=function(a,b,c,d,e){var f=a.document.createRange();return f.setStart(b.dom(),c),f.setEnd(d.dom(),e),f},o=function(a){a.deleteContents()},p=function(a){var b=a.cloneContents();return d.fromDom(b)},q=function(b){return{left:a.constant(b.left),top:a.constant(b.top),right:a.constant(b.right),bottom:a.constant(b.bottom),width:a.constant(b.width),height:a.constant(b.height)}},r=function(a){var c=a.getClientRects(),d=c.length>0?c[0]:a.getBoundingClientRect();return d.width>0||d.height>0?b.some(d).map(q):b.none()},s=function(a){var c=a.getBoundingClientRect();return c.width>0||c.height>0?b.some(c).map(q):b.none()},t=function(a){return a.toString()};return{create:h,replaceWith:k,selectNodeContents:e,selectNodeContentsUsing:f,isCollapsed:l,relativeToNative:m,exactToNative:n,deleteContents:o,cloneFragment:p,getFirstRect:r,getBounds:s,isWithin:g,toString:t}}),g("9m",["6k","6","z","17","a","9l"],function(a,b,c,d,e,f){var g=a.generate([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),h=function(a,b,c){return b(e.fromDom(c.startContainer),c.startOffset,e.fromDom(c.endContainer),c.endOffset)},i=function(a,e){return e.match({domRange:function(a){return{ltr:b.constant(a),rtl:c.none}},relative:function(b,e){return{ltr:d.cached(function(){return f.relativeToNative(a,b,e)}),rtl:d.cached(function(){return c.some(f.relativeToNative(a,e,b))})}},exact:function(b,e,g,h){return{ltr:d.cached(function(){return f.exactToNative(a,b,e,g,h)}),rtl:d.cached(function(){return c.some(f.exactToNative(a,g,h,b,e))})}}})},j=function(a,b){var c=b.ltr();if(c.collapsed){var d=b.rtl().filter(function(a){return a.collapsed===!1});return d.map(function(a){return g.rtl(e.fromDom(a.endContainer),a.endOffset,e.fromDom(a.startContainer),a.startOffset)}).getOrThunk(function(){return h(a,g.ltr,c)})}return h(a,g.ltr,c)},k=function(a,b){var c=i(a,b);return j(a,c)},l=function(a,b){var c=k(a,b);return c.match({ltr:function(b,c,d,e){var f=a.document.createRange();return f.setStart(b.dom(),c),f.setEnd(d.dom(),e),f},rtl:function(b,c,d,e){var f=a.document.createRange();return f.setStart(d.dom(),e),f.setEnd(b.dom(),c),f}})};return{ltr:g.ltr,rtl:g.rtl,diagnose:k,asLtrRange:l}}),g("ac",["1w"],function(a){var b=function(b,c,d,e,f){if(0===f)return 0;if(c===e)return f-1;for(var g=e,h=1;hi.bottom);else{if(dg)return h-1;g=j}}return 0},c=function(a,b,c){return b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom};return{inRect:c,searchForPoint:b}}),g("ad",["z","15","a4","ac","1w"],function(a,b,c,d,e){var f=function(a,b,e,f,g){var h=function(c){var d=a.dom().createRange();return d.setStart(b.dom(),c),d.collapse(!0),d},i=function(a){var b=h(a);return b.getBoundingClientRect()},j=c.get(b).length,k=d.searchForPoint(i,e,f,g.right,j);return h(k)},g=function(c,e,g,h){var i=c.dom().createRange();i.selectNode(e.dom());var j=i.getClientRects(),k=b.findMap(j,function(b){return d.inRect(b,g,h)?a.some(b):a.none()});return k.map(function(a){return f(c,e,g,h,a)})};return{locate:g}}),g("a6",["z","15","b","10","ac","ad","1w"],function(a,b,c,d,e,f,g){var h=function(c,f,g,h){var j=c.dom().createRange(),k=d.children(f);return b.findMap(k,function(b){return j.selectNode(b.dom()),e.inRect(j.getBoundingClientRect(),g,h)?i(c,b,g,h):a.none()})},i=function(a,b,d,e){var g=c.isText(b)?f.locate:h;return g(a,b,d,e)},j=function(a,b,c,d){var e=a.dom().createRange();e.selectNode(b.dom());var f=e.getBoundingClientRect(),h=g.max(f.left,g.min(f.right,c)),j=g.max(f.top,g.min(f.bottom,d));return i(a,b,h,j)};return{locate:j}}),g("ae",["z","2u","10","9h"],function(a,b,c,d){var e=function(a){return b.descendant(a,d.isCursorPosition)},f=function(a){return g(a,d.isCursorPosition)},g=function(b,d){var e=function(b){for(var f=c.children(b),g=f.length-1;g>=0;g--){var h=f[g];if(d(h))return a.some(h);var i=e(h);if(i.isSome())return i}return a.none()};return e(b)};return{first:e,last:f}}),g("a7",["z","10","ae"],function(a,b,c){var d=!0,e=!1,f=function(a,b){return b-a.left0){var d=b.getRangeAt(0),e=b.getRangeAt(b.rangeCount-1);return a.some(f.range(c.fromDom(d.startContainer),d.startOffset,c.fromDom(e.endContainer),e.endOffset))}return a.none()},t=function(d){var e=c.fromDom(d.anchorNode),g=c.fromDom(d.focusNode);return b.after(e,d.anchorOffset,g,d.focusOffset)?a.some(f.range(c.fromDom(d.anchorNode),d.anchorOffset,c.fromDom(d.focusNode),d.focusOffset)):s(d)},u=function(a,b){var c=g.selectNodeContents(a,b);l(a,c)},v=function(a,b){var d=g.selectNodeContents(a,b);return f.range(c.fromDom(d.startContainer),d.startOffset,c.fromDom(d.endContainer),d.endOffset)},w=function(b){var c=b.getSelection();return c.rangeCount>0?t(c):a.none()},x=function(a){return w(a).map(function(a){return f.exact(a.start(),a.soffset(),a.finish(),a.foffset())})},y=function(a,b){var c=h.asLtrRange(a,b);return g.getFirstRect(c)},z=function(a,b){var c=h.asLtrRange(a,b);return g.getBounds(c)},A=function(a,b,c){return i.fromPoint(a,b,c)},B=function(a,b){var c=h.asLtrRange(a,b);return g.toString(c)},C=function(a){var b=a.getSelection();b.removeAllRanges()},D=function(a,b){var c=h.asLtrRange(a,b);return g.cloneFragment(c)},E=function(a,b,c){var e=h.asLtrRange(a,b),f=d.fromElements(c,a.document);g.replaceWith(e,f)},F=function(a,b){var c=h.asLtrRange(a,b);g.deleteContents(c)};return{setExact:p,getExact:w,get:x,setRelative:q,toNative:r,setToElement:u,clear:C,clone:D,replace:E,deleteAt:F,forElement:v,getFirstRect:y,getBounds:z,getAtPoint:A,findWithin:n,getAsString:B}}),g("85",["y","6","a","10","9h","9i","86"],function(a,b,c,d,e,f,g){var h=2,i=function(a){return{left:a.left,top:a.top,right:a.right,bottom:a.bottom,width:b.constant(h),height:a.height}},j=function(a){return{left:b.constant(a.left),top:b.constant(a.top),right:b.constant(a.right),bottom:b.constant(a.bottom),width:b.constant(a.width),height:b.constant(a.height)}},k=function(b){if(b.collapsed){var h=c.fromDom(b.startContainer);return d.parent(h).bind(function(c){var d=f.exact(h,b.startOffset,c,e.getEnd(c)),j=g.getFirstRect(b.startContainer.ownerDocument.defaultView,d);return j.map(i).map(a.pure)}).getOr([])}return a.map(b.getClientRects(),j)},l=function(a){var b=a.getSelection();return void 0!==b&&b.rangeCount>0?k(b.getRangeAt(0)):[]};return{getRectangles:l}}),g("5y",["6","z","1u","a","4i","1w","83","i","84","85"],function(a,b,c,d,e,f,g,h,i,j){var k=50,l="data-"+h.resolve("last-outer-height"),m=function(a,b){e.set(a,l,b)},n=function(a){return i.safeParse(a,l)},o=function(b){return{top:a.constant(b.top()),bottom:a.constant(b.top()+b.height())}},p=function(a){var c=j.getRectangles(a);return c.length>0?b.some(c[0]).map(o):b.none()},q=function(a,c){var d=n(c),e=a.innerHeight;return d>e?b.some(d-e):b.none()},r=function(a,b,c){var d=b.top()>a.innerHeight||b.bottom()>a.innerHeight;return d?f.min(c,b.bottom()-a.innerHeight+k):0},s=function(a,b){var e=d.fromDom(b.document.body),f=function(){g.resume(b)},h=c.bind(d.fromDom(a),"resize",function(){q(a,e).each(function(a){p(b).each(function(c){var d=r(b,c,a);0!==d&&b.scrollTo(b.pageXOffset,b.pageYOffset+d)})}),m(e,a.innerHeight)});m(e,a.innerHeight);var i=function(){h.unbind()};return{toEditing:f,destroy:i}};return{setup:s}}),g("5z",["6","z","1a","1u","a","86"],function(a,b,c,d,e,f){var g=function(a){return b.some(e.fromDom(a.dom().contentWindow.document.body))},h=function(a){return b.some(e.fromDom(a.dom().contentWindow.document))},i=function(a){return b.from(a.dom().contentWindow)},j=function(a){var b=i(a);return b.bind(f.getExact)},k=function(a){return a.getFrame()},l=function(a,b){return function(c){var d=c[a].getOrThunk(function(){var a=k(c);return function(){return b(a)}});return d()}},m=function(a,b,c,e){return a[c].getOrThunk(function(){return function(a){return d.bind(b,e,a)}})},n=function(b){return{left:a.constant(b.left),top:a.constant(b.top),right:a.constant(b.right),bottom:a.constant(b.bottom),width:a.constant(b.width),height:a.constant(b.height)}},o=function(d){var l=k(d),o=function(a){var d=function(a){return c.eq(a.start(),a.finish())&&a.soffset()===a.foffset()},e=function(a){var c=a.start().dom().getBoundingClientRect();return c.width>0||c.height>0?b.some(c).map(n):b.none()};return f.getExact(a).filter(d).bind(e)};return g(l).bind(function(b){return h(l).bind(function(c){return i(l).map(function(g){var h=e.fromDom(c.dom().documentElement),i=d.getCursorBox.getOrThunk(function(){return function(){return f.get(g).bind(function(a){return f.getFirstRect(g,a).orThunk(function(){return o(g)})})}}),k=d.setSelection.getOrThunk(function(){return function(a,b,c,d){f.setExact(g,a,b,c,d)}}),n=d.clearSelection.getOrThunk(function(){return function(){f.clear(g)}});return{body:a.constant(b),doc:a.constant(c),win:a.constant(g),html:a.constant(h),getSelection:a.curry(j,l),setSelection:k,clearSelection:n,frame:a.constant(l),onKeyup:m(d,c,"onKeyup","keyup"),onNodeChanged:m(d,c,"onNodeChanged","selectionchange"),onDomChanged:d.onDomChanged,onScrollToCursor:d.onScrollToCursor,onScrollToElement:d.onScrollToElement,onToReading:d.onToReading,onToEditing:d.onToEditing,onToolbarScrollStart:d.onToolbarScrollStart,onTouchContent:d.onTouchContent,onTapContent:d.onTapContent,onTouchToolstrip:d.onTouchToolstrip,getCursorBox:i}})})})};return{getBody:l("getBody",g),getDoc:l("getDoc",h),getWin:l("getWin",i),getSelection:l("getSelection",j),getFrame:k,getActiveApi:o}}),g("60",["y","7","4i","39","5l"],function(a,b,c,d,e){var f="data-ephox-mobile-fullscreen-style",g="display:none!important;",h="position:absolute!important;",i="top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;",j="background-color:rgb(255,255,255)!important;",k=b.detect().os.isAndroid(),l=function(a){var b=d.get(a,"background-color");return void 0!==b&&""!==b?"background-color:"+b+"!important":j},m=function(b,d){var j=function(a){var b=e.siblings(a,"*");return b},m=function(a){return function(b){var d=c.get(b,"style"),e=void 0===d?"no-styles":d.trim();e!==a&&(c.set(b,f,e),c.set(b,"style",a))}},n=e.ancestors(b,"*"),o=a.bind(n,j),p=l(d);a.each(o,m(g)),a.each(n,m(h+i+p));var q=k===!0?"":h;m(q+i+p)(b)},n=function(){var b=e.all("["+f+"]");a.each(b,function(a){var b=c.get(a,f);"no-styles"!==b?c.set(a,"style",b):c.remove(a,"style"),c.remove(a,f)})};return{clobberStyles:m,restoreStyles:n}}),g("61",["9","a","4i","4u"],function(a,b,c,d){var e=function(){var e=d.first("head").getOrDie(),f=function(){var d=b.fromTag("meta");return c.set(d,"name","viewport"),a.append(e,d),d},g=d.first('meta[name="viewport"]').getOrThunk(f),h=c.get(g,"content"),i=function(){c.set(g,"content","width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0")},j=function(){void 0!==h&&null!==h&&h.length>0?c.set(g,"content",h):c.set(g,"content","user-scalable=yes")};return{maximize:i,restore:j}};return{tag:e}}),g("3r",["1z","2f","5x","5y","5z","60","i","61"],function(a,b,c,d,e,f,g,h){var i=function(i,j){var k=h.tag(),l=a.api(),m=a.api(),n=function(){j.hide(),b.add(i.container,g.resolve("fullscreen-maximized")),b.add(i.container,g.resolve("android-maximized")),k.maximize(),b.add(i.body,g.resolve("android-scroll-reload")),l.set(d.setup(i.win,e.getWin(i.editor).getOrDie("no"))),e.getActiveApi(i.editor).each(function(a){f.clobberStyles(i.container,a.body()),m.set(c.initEvents(a,i.toolstrip,i.alloy))})},o=function(){k.restore(),j.show(),b.remove(i.container,g.resolve("fullscreen-maximized")),b.remove(i.container,g.resolve("android-maximized")),f.restoreStyles(),b.remove(i.body,g.resolve("android-scroll-reload")),m.clear(),l.clear()};return{enter:n,exit:o}};return{create:i}}),g("3s",["29","2e","6","a","10","1k"],function(a,b,c,d,e,f){return b.objOf([a.strictObjOf("editor",[a.strict("getFrame"),a.option("getBody"),a.option("getDoc"),a.option("getWin"),a.option("getSelection"),a.option("setSelection"),a.option("clearSelection"),a.option("cursorSaver"),a.option("onKeyup"),a.option("onNodeChanged"),a.option("getCursorBox"),a.strict("onDomChanged"),a.defaulted("onTouchContent",c.noop),a.defaulted("onTapContent",c.noop),a.defaulted("onTouchToolstrip",c.noop),a.defaulted("onScrollToCursor",c.constant({unbind:c.noop})),a.defaulted("onScrollToElement",c.constant({unbind:c.noop})),a.defaulted("onToEditing",c.constant({unbind:c.noop})),a.defaulted("onToReading",c.constant({unbind:c.noop})),a.defaulted("onToolbarScrollStart",c.identity)]),a.strict("socket"),a.strict("toolstrip"),a.strict("dropup"),a.strict("toolbar"),a.strict("container"),a.strict("alloy"),a.state("win",function(a){return e.owner(a.socket).dom().defaultView}),a.state("body",function(a){return d.fromDom(a.socket.dom().ownerDocument.body)}),a.defaulted("translate",c.identity),a.defaulted("setReadOnly",c.noop)])}),g("62",["87","1j"],function(a,b){var c=function(c,d){var e=null,f=null,g=function(){null!==e&&(a(e),e=null,f=null)},h=function(){f=arguments,null===e&&(e=b(function(){c.apply(null,f),e=null,f=null},d))};return{cancel:g,throttle:h}},d=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var a=arguments;null===e&&(e=b(function(){c.apply(null,a),e=null,a=null},d))};return{cancel:f,throttle:g}},e=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var f=arguments;null!==e&&a(e),e=b(function(){c.apply(null,f),e=null,f=null},d)};return{cancel:f,throttle:g}};return{adaptable:c,first:d,last:e}}),g("3t",["q","1g","1h","1n","3v","62","1j","i","1o"],function(a,b,c,d,e,f,g,h,i){var j=function(g,j){var k=c.record(e.sketch({dom:i.dom(''),containerBehaviours:a.derive([b.config({toggleClass:h.resolve("mask-tap-icon-selected"),toggleOnExecute:!1})])})),l=f.first(g,200);return e.sketch({dom:i.dom('
          '),components:[e.sketch({ +dom:i.dom('
          '),components:[d.sketch({dom:i.dom('
          '),components:[k.asSpec()],action:function(a){l.throttle()},buttonBehaviours:a.derive([b.config({toggleClass:h.resolve("mask-tap-icon-selected")})])})]})]})};return{sketch:j}}),g("20",["3q","2e","6","9","39","3r","3s","3t"],function(a,b,c,d,e,f,g,h){var i=function(i){var j=b.asRawOrDie("Getting AndroidWebapp schema",g,i);e.set(j.toolstrip,"width","100%");var k=function(){j.setReadOnly(!0),n.enter()},l=a.build(h.sketch(k,j.translate));j.alloy.add(l);var m={show:function(){j.alloy.add(l)},hide:function(){j.alloy.remove(l)}};d.append(j.container,l.element());var n=f.create(j,m);return{setReadOnly:j.setReadOnly,refreshStructure:c.noop,enter:n.enter,exit:n.exit,destroy:c.noop}};return{produce:i}}),g("63",["q","1y","4q","53","29","6"],function(a,b,c,d,e,f){var g=[e.defaulted("shell",!0),e.defaulted("toolbarBehaviours",{})],h=function(c){return{behaviours:a.derive([b.config({})])}},i=[d.optional({name:"groups",overrides:h})];return{name:f.constant("Toolbar"),schema:f.constant(g),parts:f.constant(i)}}),g("3w",["q","1y","34","52","63","w","z","16","v"],function(a,b,c,d,e,f,g,h,i){var j=function(c,e,j,k){var l=function(a,c){m(a).fold(function(){throw h.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new i("Toolbar was defined to not be a shell, but no groups container was specified in components")},function(a){b.set(a,c)})},m=function(a){return c.shell()?g.some(a):d.getPart(a,c,"groups")},n=c.shell()?{behaviours:[b.config({})],components:[]}:{behaviours:[],components:e};return{uid:c.uid(),dom:c.dom(),components:n.components,behaviours:f.deepMerge(a.derive(n.behaviours),c.toolbarBehaviours()),apis:{setGroups:l},domModification:{attributes:{role:"group"}}}};return c.composite({name:"Toolbar",configFields:e.schema(),partFields:e.parts(),factory:j,apis:{setGroups:function(a,b,c){a.setGroups(b,c)}}})}),g("65",["4q","53","29","6"],function(a,b,c,d){var e=[c.strict("items"),a.markers(["itemClass"]),c.defaulted("hasTabstop",!0),c.defaulted("tgroupBehaviours",{})],f=[b.group({name:"items",unit:"item",overrides:function(a){return{domModification:{classes:[a.markers().itemClass()]}}}})];return{name:d.constant("ToolbarGroup"),schema:d.constant(e),parts:d.constant(f)}}),g("3x",["q","33","64","34","65","w","v"],function(a,b,c,d,e,f,g){var h=function(d,e,g,h){return f.deepMerge({dom:{attributes:{role:"toolbar"}}},{uid:d.uid(),dom:d.dom(),components:e,behaviours:f.deepMerge(a.derive([b.config({mode:"flow",selector:"."+d.markers().itemClass()}),d.hasTabstop()?c.config({}):c.revoke()]),d.tgroupBehaviours()),"debug.sketcher":g["debug.sketcher"]})};return d.composite({name:"ToolbarGroup",configFields:e.schema(),partFields:e.parts(),factory:h})}),g("3y",["6","1u","4i","4u","i"],function(a,b,c,d,e){var f="data-"+e.resolve("horizontal-scroll"),g=function(a){a.dom().scrollTop=1;var b=0!==a.dom().scrollTop;return a.dom().scrollTop=0,b},h=function(a){a.dom().scrollLeft=1;var b=0!==a.dom().scrollLeft;return a.dom().scrollLeft=0,b},i=function(a){return a.dom().scrollTop>0||g(a)},j=function(a){return a.dom().scrollLeft>0||h(a)},k=function(a){c.set(a,f,"true")},l=function(a){return"true"===c.get(a,f)?j:i},m=function(c,e){return b.bind(c,"touchmove",function(b){d.closest(b.target(),e).filter(l).fold(function(){b.raw().preventDefault()},a.noop)})};return{exclusive:m,markAsHorizontal:k}}),g("21",["3u","q","33","1g","3q","3d","3v","3w","3x","y","5","6","39","3y","i","3z","1o"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){return function(){var r=function(c){var d=c.scrollable===!0?"${prefix}-toolbar-scrollable-group":"";return{dom:q.dom('
          '),tgroupBehaviours:b.derive([a.config("adhoc-scrollable-toolbar",c.scrollable===!0?[f.runOnInit(function(a,b){m.set(a.element(),"overflow-x","auto"),n.markAsHorizontal(a.element()),p.register(a.element())})]:[])]),components:[g.sketch({components:[i.parts().items({})]})],markers:{itemClass:o.resolve("toolbar-group-item")},items:c.items}},s=e.build(h.sketch({dom:q.dom('
          '),components:[h.parts().groups({})],toolbarBehaviours:b.derive([d.config({toggleClass:o.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),c.config({mode:"cyclic"})]),shell:!0})),t=e.build(g.sketch({dom:{classes:[o.resolve("toolstrip")]},components:[e.premade(s)],containerBehaviours:b.derive([d.config({toggleClass:o.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),u=function(){h.setGroups(s,v.get()),d.off(s)},v=k([]),w=function(a){v.set(a),u()},x=function(a){return j.map(a,l.compose(i.sketch,r))},y=function(){h.refresh(s)},z=function(a){d.on(s),h.setGroups(s,a)},A=function(){d.isOn(s)&&u()},B=function(){c.focusIn(s)};return{wrapper:l.constant(t),toolbar:l.constant(s),createGroups:x,setGroups:w,setContextToolbar:z,restoreToolbar:A,refresh:y,focus:B}}}),g("22",["q","1y","1","3q","1n","3v","6","2f","i","1o"],function(a,b,c,d,e,f,g,h,i,j){var k=function(a){return d.build(e.sketch({dom:j.dom('
          '),action:function(){a.run(function(a){a.setReadOnly(!1)})}}))},l=function(){return d.build(f.sketch({dom:j.dom('
          '),components:[],containerBehaviours:a.derive([b.config({})])}))},m=function(a,c){b.append(a,d.premade(c))},n=function(a,c){b.remove(a,c)},o=function(a,b,d,e){var f=d===!0?c.toAlpha:c.toOmega;f(e);var g=d?m:n;g(a,b)};return{makeEditSwitch:k,makeSocket:l,updateMode:o}}),g("67",["2f","8a","39"],function(a,b,c){var d=function(a,b){return b.getAnimationRoot().fold(function(){return a.element()},function(b){return b(a)})},e=function(a){return a.dimension().property()},f=function(a,b){return a.dimension().getDimension()(b)},g=function(a,c){var e=d(a,c);b.remove(e,[c.shrinkingClass(),c.growingClass()])},h=function(b,d){a.remove(b.element(),d.openClass()),a.add(b.element(),d.closedClass()),c.set(b.element(),e(d),"0px"),c.reflow(b.element())},i=function(a,b){j(a,b);var c=f(b,a.element());return h(a,b),c},j=function(b,d){a.remove(b.element(),d.closedClass()),a.add(b.element(),d.openClass()),c.remove(b.element(),e(d))},k=function(a,b,d){d.setCollapsed(),c.set(a.element(),e(b),f(b,a.element())),c.reflow(a.element()),g(a,b),h(a,b),b.onStartShrink()(a),b.onShrunk()(a)},l=function(b,g,i){i.setCollapsed(),c.set(b.element(),e(g),f(g,b.element())),c.reflow(b.element());var j=d(b,g);a.add(j,g.shrinkingClass()),h(b,g),g.onStartShrink()(b)},m=function(b,f,g){var h=i(b,f),k=d(b,f);a.add(k,f.growingClass()),j(b,f),c.set(b.element(),e(f),h),g.setExpanded(),f.onStartGrow()(b)},n=function(a,b,c){c.isExpanded()||m(a,b,c)},o=function(a,b,c){c.isExpanded()&&l(a,b,c)},p=function(a,b,c){c.isExpanded()&&k(a,b,c)},q=function(a,b,c){return c.isExpanded()},r=function(a,b,c){return c.isCollapsed()},s=function(b,c,e){var f=d(b,c);return a.has(f,c.growingClass())===!0},t=function(b,c,e){var f=d(b,c);return a.has(f,c.shrinkingClass())===!0},u=function(a,b,c){return s(a,b,c)===!0||t(a,b,c)===!0},v=function(a,b,c){var d=c.isExpanded()?l:m;d(a,b,c)};return{grow:n,shrink:o,immediateShrink:p,hasGrown:q,hasShrunk:r,isGrowing:s,isShrinking:t,isTransitioning:u,toggleGrow:v,disableTransitions:g}}),g("66",["3d","2g","67","4b","14","39"],function(a,b,c,d,e,f){var g=function(a,b){var c=b.expanded();return c?d.nu({classes:[b.openClass()],styles:{}}):d.nu({classes:[b.closedClass()],styles:e.wrap(b.dimension().property(),"0px")})},h=function(d,e){return a.derive([a.run(b.transitionend(),function(a,b){var g=b.event().raw();if(g.propertyName===d.dimension().property()){c.disableTransitions(a,d,e),e.isExpanded()&&f.remove(a.element(),d.dimension().property());var h=e.isExpanded()?d.onGrown():d.onShrunk();h(a,b)}})])};return{exhibit:g,events:h}}),g("68",["4q","29","2e","8b","5m"],function(a,b,c,d,e){return[b.strict("closedClass"),b.strict("openClass"),b.strict("shrinkingClass"),b.strict("growingClass"),b.option("getAnimationRoot"),a.onHandler("onShrunk"),a.onHandler("onStartShrink"),a.onHandler("onGrown"),a.onHandler("onStartGrow"),b.defaulted("expanded",!1),b.strictOf("dimension",c.choose("property",{width:[a.output("property","width"),a.output("getDimension",function(a){return e.get(a)+"px"})],height:[a.output("property","height"),a.output("getDimension",function(a){return d.get(a)+"px"})]}))]}),g("69",["4g","5","6"],function(a,b,c){var d=function(d){var e=b(d.expanded()),f=function(){return"expanded: "+e.get()};return a({isExpanded:function(){return e.get()===!0},isCollapsed:function(){return e.get()===!1},setCollapsed:c.curry(e.set,!1),setExpanded:c.curry(e.set,!0),readState:f})};return{init:d}}),g("40",["q","66","67","68","69"],function(a,b,c,d,e){return a.create({fields:d,name:"sliding",active:b,apis:c,state:e})}),g("23",["q","1y","40","3q","3v","6","1k","1l","i"],function(a,b,c,d,e,f,g,h,i){var j=function(j,k){var l=d.build(e.sketch({dom:{tag:"div",classes:i.resolve("dropup")},components:[],containerBehaviours:a.derive([b.config({}),c.config({closedClass:i.resolve("dropup-closed"),openClass:i.resolve("dropup-open"),shrinkingClass:i.resolve("dropup-shrinking"),growingClass:i.resolve("dropup-growing"),dimension:{property:"height"},onShrunk:function(a){j(),k(),b.set(a,[])},onGrown:function(a){j(),k()}}),h.orientation(function(a,b){n(f.noop)})])})),m=function(a,d,e){c.hasShrunk(l)===!0&&c.isTransitioning(l)===!1&&g.requestAnimationFrame(function(){d(e),b.set(l,[a()]),c.grow(l)})},n=function(a){g.requestAnimationFrame(function(){a(),c.shrink(l)})};return{appear:m,disappear:n,component:f.constant(l),element:l.element}};return{build:j}}),g("6c",["8c","t","8d","29","2e","y","7","1u","b","10","1j"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(b){return b.raw().which===a.BACKSPACE()[0]&&!f.contains(["input","textarea"],i.name(b.target()))},m=g.detect().browser.isFirefox(),n=e.objOfOnly([d.strictFunction("triggerEvent"),d.strictFunction("broadcastEvent"),d.defaulted("stopBackspace",!0)]),o=function(a,b){return m?h.capture(a,"focus",b):h.bind(a,"focusin",b)},p=function(a,b){return m?h.capture(a,"blur",b):h.bind(a,"focusout",b)},q=function(a,d){var i=e.asRawOrDie("Getting GUI events settings",n,d),m=g.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove","mouseout","click"],q=c.monitor(i),r=f.map(m.concat(["selectstart","input","contextmenu","change","transitionend","dragstart","dragover","drop"]),function(b){return h.bind(a,b,function(a){q.fireIfReady(a,b).each(function(b){b&&a.kill()});var c=i.triggerEvent(b,a);c&&a.kill()})}),s=h.bind(a,"keydown",function(a){var b=i.triggerEvent("keydown",a);b?a.kill():i.stopBackspace===!0&&l(a)&&a.prevent()}),t=o(a,function(a){var b=i.triggerEvent("focusin",a);b&&a.kill()}),u=p(a,function(a){var c=i.triggerEvent("focusout",a);c&&a.kill(),k(function(){i.triggerEvent(b.postBlur(),a)},0)}),v=j.defaultView(a),w=h.bind(v,"scroll",function(a){var c=i.broadcastEvent(b.windowScroll(),a);c&&a.kill()}),x=function(){f.each(r,function(a){a.unbind()}),s.unbind(),t.unbind(),u.unbind(),w.unbind()};return{unbind:x}};return{setup:q}}),g("8e",["14","5"],function(a,b){var c=function(c,d){var e=a.readOptFrom(c,"target").map(function(a){return a()}).getOr(d);return b(e)};return{derive:c}}),g("8f",["5","6","v"],function(a,b,c){var d=function(c,d){var e=a(!1),f=a(!1),g=function(){e.set(!0)},h=function(){f.set(!0)};return{stop:g,cut:h,isStopped:e.get,isCut:f.get,event:b.constant(c),setSource:d.set,getSource:d.get}},e=function(d){var e=a(!1),f=function(){e.set(!0)};return{stop:f,cut:b.noop,isStopped:e.get,isCut:b.constant(!1),event:b.constant(d),setTarget:b.die(new c("Cannot set target of a broadcasted event")),getTarget:b.die(new c("Cannot get target of a broadcasted event"))}},f=function(b,c){var e=a(c);return d(b,e)};return{fromSource:d,fromExternal:e,fromTarget:f}}),g("6d",["6b","8e","8f","6k","y","10","v"],function(a,b,c,d,e,f,g){var h=d.generate([{stopped:[]},{resume:["element"]},{complete:[]}]),i=function(b,d,e,g,i,j){var k=b(d,g),l=c.fromSource(e,i);return k.fold(function(){return j.logEventNoHandlers(d,g),h.complete()},function(b){var c=b.descHandler(),e=a.getHandler(c);return e(l),l.isStopped()?(j.logEventStopped(d,b.element(),c.purpose()),h.stopped()):l.isCut()?(j.logEventCut(d,b.element(),c.purpose()),h.complete()):f.parent(b.element()).fold(function(){return j.logNoParent(d,b.element(),c.purpose()),h.complete()},function(a){return j.logEventResponse(d,b.element(),c.purpose()),h.resume(a)})})},j=function(a,b,c,d,e,f){return i(a,b,c,d,e,f).fold(function(){return!0},function(d){return j(a,b,c,d,e,f)},function(){return!1})},k=function(a,c,d,e,f){var g=b.derive(d,e);return i(a,c,d,e,g,f)},l=function(b,d,f){var g=c.fromExternal(d);return e.each(b,function(b){var c=b.descHandler(),d=a.getHandler(c);d(g)}),g.isStopped()},m=function(a,b,c,d){var e=c.target();return n(a,b,c,e,d)},n=function(a,c,d,e,f){var g=b.derive(d,e);return j(a,c,d,e,g,f)};return{triggerHandler:k,triggerUntilStopped:m,triggerOnUntilStopped:n,broadcast:l}}),g("9q",["2u"],function(a){var b=function(b,c,d){var e=a.closest(b,function(a){return c(a).isSome()},d);return e.bind(c)};return{closest:b}}),g("8g",["9q","6b","30","14","6","x","z","2o","16"],function(a,b,c,d,e,f,g,h,i){var j=h.immutable("element","descHandler"),k=function(a,b){return{id:e.constant(a),descHandler:e.constant(b)}};return function(){var e={},h=function(a,c,d){f.each(d,function(d,f){var g=void 0!==e[f]?e[f]:{};g[c]=b.curryArgs(d,a),e[f]=g})},i=function(a,b){return c.read(b).fold(function(a){return g.none()},function(c){var e=d.readOpt(c);return a.bind(e).map(function(a){return j(b,a)})})},l=function(a){return d.readOptFrom(e,a).map(function(a){return f.mapToArray(a,function(a,b){return k(b,a)})}).getOr([])},m=function(b,c,f){var g=d.readOpt(c),h=g(e);return a.closest(f,function(a){return i(h,a)},b)},n=function(a){f.each(e,function(b,c){b.hasOwnProperty(a)&&delete b[a]})};return{registerId:h,unregisterId:n,filterByType:l,find:m}}}),g("6e",["8g","13","30","14","12","v"],function(a,b,c,d,e,f){return function(){var g=a(),h={},i=function(a){var b=a.element();return c.read(b).fold(function(){return c.write("uid-",a.element())},function(a){return a})},j=function(a,c){var d=h[c];if(d!==a)throw new f('The tagId "'+c+'" is already used by: '+b.element(d.element())+"\nCannot use it for: "+b.element(a.element())+"\nThe conflicting element is"+(e.inBody(d.element())?" ":" not ")+"already in the DOM");l(a)},k=function(a){var b=i(a);d.hasKey(h,b)&&j(a,b);var c=[a];g.registerId(c,b,a.events()),h[b]=a},l=function(a){c.read(a.element()).each(function(a){h[a]=void 0,g.unregisterId(a)})},m=function(a){return g.filterByType(a)},n=function(a,b,c){return g.find(a,b,c)},o=function(a){return d.readOpt(a)(h)};return{find:n,filter:m,register:k,unregister:l,getById:o}}}),g("41",["3q","t","3","6a","3v","4","6b","6c","6d","13","6e","30","y","6","48","1a","8","9","11","b","2f","10","v"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){var x=function(){var b=a.build(e.sketch({dom:{tag:"div"}}));return y(b)},y=function(e){var j=function(a){return v.parent(e.element()).fold(function(){return!0},function(b){return p.eq(a,b)})},r=k(),u=function(a,b){return r.find(j,a,b)},x=h.setup(e.element(),{triggerEvent:function(a,b){return f.monitorEvent(a,b.target(),function(c){return i.triggerUntilStopped(u,a,b,c)})},broadcastEvent:function(a,b){var c=r.filter(a);return i.broadcast(c,b)}}),y=d({debugInfo:n.constant("real"),triggerEvent:function(a,b,c){f.monitorEvent(a,b,function(d){i.triggerOnUntilStopped(u,a,c,b,d)})},triggerFocus:function(a,c){l.read(a).fold(function(){q.focus(a)},function(d){f.monitorEvent(b.focus(),a,function(d){i.triggerHandler(u,b.focus(),{originator:n.constant(c),target:n.constant(a)},a,d)})})},triggerEscape:function(a,b){y.triggerEvent("keydown",a.element(),b.event())},getByUid:function(a){return H(a)},getByDom:function(a){return I(a)},build:a.build,addToGui:function(a){B(a)},removeFromGui:function(a){C(a)},addToWorld:function(a){z(a)},removeFromWorld:function(a){A(a)},broadcast:function(a){F(a)},broadcastOn:function(a,b){G(a,b)}}),z=function(a){a.connect(y),t.isText(a.element())||(r.register(a),m.each(a.components(),z),y.triggerEvent(b.systemInit(),a.element(),{target:n.constant(a.element())}))},A=function(a){t.isText(a.element())||(m.each(a.components(),A),r.unregister(a)),a.disconnect()},B=function(a){c.attach(e,a)},C=function(a){c.detach(a)},D=function(){x.unbind(),s.remove(e.element())},E=function(a){var c=r.filter(b.receive());m.each(c,function(b){var c=b.descHandler(),d=g.getHandler(c);d(a)})},F=function(a){E({universal:n.constant(!0),data:n.constant(a)})},G=function(a,b){E({universal:n.constant(!1),channels:n.constant(a),data:n.constant(b)})},H=function(a){return r.getById(a).fold(function(){return o.error(new w('Could not find component with uid: "'+a+'" in system.'))},o.value)},I=function(a){return l.read(a).bind(H)};return z(e),{root:n.constant(e),element:e.element,destroy:D,add:B,remove:C,getByUid:H,getByDom:I,addToWorld:z,removeFromWorld:A,broadcast:F,broadcastOn:G}};return{create:x,takeover:y}}),g("24",["q","1","3q","41","3v","6","i"],function(a,b,c,d,e,f,g){var h=f.constant(g.resolve("readonly-mode")),i=f.constant(g.resolve("edit-mode"));return function(f){var j=c.build(e.sketch({dom:{classes:[g.resolve("outer-container")].concat(f.classes)},containerBehaviours:a.derive([b.config({alpha:h(),omega:i()})])}));return d.takeover(j)}}),g("k",["1y","1","6","1z","20","i","21","22","23","24"],function(a,b,c,d,e,f,g,h,i,j){return function(b){var k=j({classes:[f.resolve("android-container")]}),l=g(),m=d.api(),n=h.makeEditSwitch(m),o=h.makeSocket(),p=i.build(c.noop,b);k.add(l.wrapper()),k.add(o),k.add(p.component());var q=function(a){var b=l.createGroups(a);l.setGroups(b)},r=function(a){var b=l.createGroups(a);l.setContextToolbar(b)},s=function(){l.focus()},t=function(){l.restoreToolbar()},u=function(a){m.set(e.produce(a))},v=function(){m.run(function(b){b.exit(),a.remove(o,n)})},w=function(a){h.updateMode(o,n,a,k.root())};return{system:c.constant(k),element:k.element,init:u,exit:v,setToolbarGroups:q,setContextToolbar:r,focusToolbar:s,restoreToolbar:t,updateMode:w,socket:c.constant(o),dropup:c.constant(p)}}}),g("9r",["6"],function(a){var b=function(c,d){var e=function(a,e){return b(c+a,d+e)};return{left:a.constant(c),top:a.constant(d),translate:e}};return b}),g("9s",["6","1a","a","b","2u","1b"],function(a,b,c,d,e,f){var g=function(d,g){var h=g||c.fromDom(f.documentElement);return e.ancestor(d,a.curry(b.eq,h)).isSome()},h=function(a){var b=a.dom();return b===b.window?a:d.isDocument(a)?b.defaultView||b.parentWindow:null};return{attached:g,windowOf:h}}),g("8h",["9r","9s","a"],function(a,b,c){var d=function(b){var c=b.getBoundingClientRect();return a(c.left,c.top)},e=function(a,b){return void 0!==a?a:void 0!==b?b:0},f=function(a){var d=a.dom().ownerDocument,f=d.body,g=b.windowOf(c.fromDom(d)),i=d.documentElement,j=e(g.pageYOffset,i.scrollTop),k=e(g.pageXOffset,i.scrollLeft),l=e(i.clientTop,f.clientTop),m=e(i.clientLeft,f.clientLeft);return h(a).translate(k-m,j-l)},g=function(b){var c=b.dom();return a(c.offsetLeft,c.offsetTop)},h=function(e){var f=e.dom(),g=f.ownerDocument,h=g.body,i=c.fromDom(g.documentElement);return h===f?a(h.offsetLeft,h.offsetTop):b.attached(e,i)?d(f):a(0,0)};return{absolute:f,relative:g,viewport:h}}),g("6f",["8d","y","62","1a","1u","8b","8h","82"],function(a,b,c,d,e,f,g,h){var i=function(a,i,j,k,l){var m=function(){i.run(function(a){a.highlightSelection()})},n=function(){i.run(function(a){a.refreshSelection()})},o=function(a,b){var c=a-k.dom().scrollTop;i.run(function(a){a.scrollIntoView(c,c+b)})},p=function(a){var b=g.absolute(a).top(),c=f.get(a);o(i,k,b,c)},q=function(){a.getCursorBox().each(function(a){o(a.top(),a.height())})},r=function(){i.run(function(a){a.clearSelection()})},s=function(){r(),z.throttle()},t=function(){q(a,i,k),i.run(function(a){a.syncHeight()})},u=function(){var b=f.get(j);i.run(function(a){a.setViewportOffset(b)}),n(i),t(a,i,k)},v=function(){i.run(function(a){a.toEditing()})},w=function(){i.run(function(a){a.toReading()})},x=function(a){i.run(function(b){b.onToolbarTouch(a)})},y=h.monitor(a),z=c.last(t,300),A=[a.onKeyup(s),a.onNodeChanged(n),a.onDomChanged(z.throttle),a.onDomChanged(n),a.onScrollToCursor(function(a){a.preventDefault(),z.throttle()}),a.onScrollToElement(function(a){p(a.element())}),a.onToEditing(v),a.onToReading(w),e.bind(a.doc(),"touchend",function(b){d.eq(a.html(),b.target())||d.eq(a.body(),b.target())}),e.bind(j,"transitionend",function(a){"height"===a.raw().propertyName&&u()}),e.capture(j,"touchstart",function(b){m(),x(b),a.onTouchToolstrip()}),e.bind(a.body(),"touchstart",function(b){r(),a.onTouchContent(),y.fireTouchstart(b)}),y.onTouchmove(),y.onTouchend(),e.bind(a.body(),"click",function(a){a.kill()}),e.bind(j,"touchmove",function(){a.onToolbarScrollStart()})],B=function(){b.each(A,function(a){a.unbind()})};return{destroy:B}};return{initEvents:i}}),g("9t",["8","1j"],function(a,b){var c=function(c){var d=c.dom().selectionStart,e=c.dom().selectionEnd,f=c.dom().selectionDirection;b(function(){c.dom().setSelectionRange(d,e,f),a.focus(c)},50)},d=function(a){var b=a.getSelection();if(b.rangeCount>0){var c=b.getRangeAt(0),d=a.document.createRange();d.setStart(c.startContainer,c.startOffset),d.setEnd(c.endContainer,c.endOffset),b.removeAllRanges(),b.addRange(d)}};return{refreshInput:c,refresh:d}}),g("8q",["1a","8","a","9t"],function(a,b,c,d){var e=function(e,f){b.active().each(function(c){a.eq(c,f)||b.blur(c)}),e.focus(),b.focus(c.fromDom(e.document.body)),d.refresh(e)};return{resume:e}}),g("8j",["y","9","2s","11","1u","a","2f","8a","39","10","8q","i","85"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){return function(n,o){var p=n.document,q=f.fromTag("div");g.add(q,l.resolve("unfocused-selections")),b.append(f.fromDom(p.documentElement),q);var r=e.bind(q,"touchstart",function(a){a.prevent(),k.resume(n,o),u()}),s=function(a){var b=f.fromTag("span");return h.add(b,[l.resolve("layer-editor"),l.resolve("unfocused-selection")]),i.setAll(b,{left:a.left()+"px",top:a.top()+"px",width:a.width()+"px",height:a.height()+"px"}),b},t=function(){u();var b=m.getRectangles(n),d=a.map(b,s);c.append(q,d)},u=function(){d.empty(q)},v=function(){r.unbind(),d.remove(q)},w=function(){return j.children(q).length>0};return{update:t,isActive:w,destroy:v,clear:u}}}),g("9x",["y","z","1j"],function(a,b,c){var d=function(e){var f=b.none(),g=[],h=function(a){return d(function(b){i(function(c){b(a(c))})})},i=function(a){k()?m(a):g.push(a)},j=function(a){f=b.some(a),l(g),g=[]},k=function(){return f.isSome()},l=function(b){a.each(b,m)},m=function(a){f.each(function(b){c(function(){a(b)},0)})};return e(j),{get:i,map:h,isReady:k}},e=function(a){return d(function(b){b(a)})};return{nu:d,pure:e}}),g("a8",["u","1j"],function(a,b){var c=function(c){return function(){var d=a.prototype.slice.call(arguments),e=this;b(function(){c.apply(e,d)},0)}};return{bounce:c}}),g("9u",["9x","a8"],function(a,b){var c=function(d){var e=function(a){d(b.bounce(a))},f=function(a){return c(function(b){e(function(c){var d=a(c);b(d)})})},g=function(a){return c(function(b){e(function(c){a(c).get(b)})})},h=function(a){return c(function(b){e(function(c){a.get(b)})})},i=function(){return a.nu(e)};return{map:f,bind:g,anonBind:h,toLazy:i,get:e}},d=function(a){return c(function(b){b(a)})};return{nu:c,pure:d}}),g("9v",["z","1v","1w","1x"],function(a,b,c,d){var e=function(b,d,e){return c.abs(b-d)<=e?a.none():bc.abs(d-g))&&(b(a),m(g))}})},k)};return{animate:f}};return{create:f,adjust:e}}),g("a9",["z","15"],function(a,b){var c=function(c,d){var e=[{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,keyboard:{portrait:380,landscape:460}}];return b.findMap(e,function(b){return c<=b.width&&d<=b.height?a.some(b.keyboard):a.none()}).getOr({portrait:d/5,landscape:c/4})};return{findDevice:c}}),g("9w",["39","10","8b","a9","j"],function(a,b,c,d,e){var f=function(a){return d.findDevice(a.screen.width,a.screen.height)},g=function(a){var b=e.get(a).isPortrait(),c=f(a),d=b?c.portrait:c.landscape,g=b?a.screen.height:a.screen.width;return g-a.innerHeight>d?0:d},h=function(a,d){var e=b.owner(a).dom().defaultView,f=c.get(a)+c.get(d),h=g(e);return f-h},i=function(b,d,e){var f=h(d,e),g=c.get(d)+c.get(e)-f;a.set(b,"padding-bottom",g+"px")};return{getGreenzone:h,updatePadding:i}}),g("8o",["6k","y","6","4i","39","5l","10","8b","9w","i","3z","84"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=a.generate([{fixed:["element","property","offsetY"]},{scroller:["element","offsetY"]}]),n="data-"+j.resolve("position-y-fixed"),o="data-"+j.resolve("y-property"),p="data-"+j.resolve("scrolling"),q="data-"+j.resolve("last-window-height"),r=function(a){return l.safeParse(a,n)},s=function(a){return d.get(a,o)},t=function(a){return l.safeParse(a,q)},u=function(a,b){var c=s(a);return m.fixed(a,c,b)},v=function(a,b){return m.scroller(a,b)},w=function(a){var b=r(a),c="true"===d.get(a,p)?v:u;return c(a,b)},x=function(a){var c=f.descendants(a,"["+n+"]");return b.map(c,w)},y=function(a){var b=d.get(a,"style");e.setAll(a,{position:"absolute",top:"0px"}),d.set(a,n,"0px"),d.set(a,o,"top");var c=function(){d.set(a,"style",b||""),d.remove(a,n),d.remove(a,o)};return{restore:c}},z=function(a,b,c){var f=d.get(c,"style");k.register(c),e.setAll(c,{position:"absolute",height:b+"px",width:"100%",top:a+"px"}),d.set(c,n,a+"px"),d.set(c,p,"true"),d.set(c,o,"top");var g=function(){k.deregister(c),d.set(c,"style",f||""),d.remove(c,n),d.remove(c,p),d.remove(c,o)};return{restore:g}},A=function(a,b,c){var f=d.get(a,"style");e.setAll(a,{position:"absolute",bottom:"0px"}),d.set(a,n,"0px"),d.set(a,o,"bottom");var g=function(){d.set(a,"style",f||""),d.remove(a,n),d.remove(a,o)};return{restore:g}},B=function(a,b,c){var e=g.owner(a).dom().defaultView,f=e.innerHeight;return d.set(a,q,f+"px"),f-b-c},C=function(a,b,f,j){var k=g.owner(a).dom().defaultView,l=y(f),m=h.get(f),o=h.get(j),p=B(a,m,o),q=z(m,p,a),r=A(j,m,p),s=!0,u=function(){s=!1,l.restore(),q.restore(),r.restore()},v=function(){var b=k.innerHeight,c=t(a);return b>c},w=function(){if(s){var c=h.get(f),g=h.get(j),k=B(a,c,g);d.set(a,n,c+"px"),e.set(a,"height",k+"px"),e.set(j,"bottom",-(c+k+g)+"px"),i.updatePadding(b,a,j)}},x=function(b){var c=b+"px";d.set(a,n,c),w()};return i.updatePadding(b,a,j),{setViewportOffset:x,isExpanding:v,isShrinking:c.not(v),refresh:w,restore:u}};return{findFixtures:x,takeover:C,getYFixedData:r}}),g("8k",["6","9u","4i","8a","39","10","1w","9v","8o","i","84"],function(a,b,c,d,e,f,g,h,i,j,k){var l=h.create(),m=15,n=10,o=10,p="data-"+j.resolve("last-scroll-top"),q=function(a){var b=e.getRaw(a,"top").getOr(0);return parseInt(b,10)},r=function(a){return parseInt(a.dom().scrollTop,10)},s=function(c,d,f){return b.nu(function(b){var g=a.curry(r,c),h=function(a){c.dom().scrollTop=a,e.set(c,"top",q(c)+m+"px")},i=function(){c.dom().scrollTop=d,e.set(c,"top",f+"px"),b(d)};l.animate(g,d,m,h,i,o)})},t=function(d,e){return b.nu(function(b){var f=a.curry(r,d);c.set(d,p,f());var h=function(a,b){var e=k.safeParse(d,p);e!==d.dom().scrollTop?b(d.dom().scrollTop):(d.dom().scrollTop=a,c.set(d,p,a))},i=function(){d.dom().scrollTop=e,c.set(d,p,e),b(e)},j=g.abs(e-f()),m=g.ceil(j/n);l.animate(f,e,m,h,i,o)})},u=function(c,d){return b.nu(function(b){var f=a.curry(q,c),h=function(a){e.set(c,"top",a+"px")},i=function(){h(d),b(d)},j=g.abs(d-f()),k=g.ceil(j/n);l.animate(f,d,k,h,i,o)})},v=function(a,b){var c=b+i.getYFixedData(a)+"px";e.set(a,"top",c)},w=function(a,c,d){var e=f.owner(a).dom().defaultView;return b.nu(function(b){v(a,d),v(c,d),e.scrollTo(0,d),b(d)})};return{moveScrollAndTop:s,moveOnlyScroll:t,moveOnlyTop:u,moveWindowScroll:w}}),g("8l",["5","9x"],function(a,b){return function(c){var d=a(b.pure({})),e=function(a){var e=b.nu(function(b){return c(a).get(b)});d.set(e)},f=function(a){d.get().get(function(){a()})};return{start:e,idle:f}}}),g("8m",["6","8i","8k","9w","9t"],function(a,b,c,d,e){var f=function(b,f,g,h,i){var j=d.getGreenzone(f,g),k=a.curry(e.refresh,b);h>j||i>j?c.moveOnlyScroll(f,f.dom().scrollTop-j+i).get(k):h<0&&c.moveOnlyScroll(f,f.dom().scrollTop+h).get(k)};return{scrollIntoView:f}}),g("aa",["y"],function(a){var b=function(b,c){return c(function(c){var d=[],e=0,f=function(a){return function(f){d[a]=f,e++,e>=b.length&&c(d)}};0===b.length?c([]):a.each(b,function(a,b){a.get(f(b))})})};return{par:b}}),g("9y",["y","9u","aa"],function(a,b,c){var d=function(a){return c.par(a,b.nu)},e=function(b,c){var e=a.map(b,c);return d(e)},f=function(a,b){return function(c){return b(c).bind(a)}};return{par:d,mapM:e,compose:f}}),g("8n",["y","9u","9y","39","8k","8o"],function(a,b,c,d,e,f){var g=function(a,c,e,f){var g=e+f;return d.set(a,c,g+"px"),b.pure(f)},h=function(a,b,c){var f=b+c,g=d.getRaw(a,"top").getOr(c),h=f-parseInt(g,10),i=a.dom().scrollTop+h;return e.moveScrollAndTop(a,i,f)},i=function(a,b){return a.fold(function(a,c,d){return g(a,c,b,d)},function(a,c){return h(a,b,c)})},j=function(b,d){var e=f.findFixtures(b),g=a.map(e,function(a){return i(a,d)});return c.par(g)};return{updatePositions:j}}),g("8p",["8","9","11","a","39"],function(a,b,c,d,e){var f=function(f,g){var h=d.fromTag("input");e.setAll(h,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"}),b.append(f,h),a.focus(h),g(h),c.remove(h)};return{input:f}}),g("6g",["6","z","62","8","1u","12","a","39","1v","87","16","1w","8i","1x","1j","8j","8k","8l","8m","8n","8o","j","8p","85"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x){var y=5,z=function(d,f,h,i,j,k){var l=r(function(a){return q.moveWindowScroll(d,f,a)}),m=function(){var c=x.getRectangles(k);return b.from(c[0]).bind(function(c){var d=c.top()-f.dom().scrollTop,e=d>i.innerHeight+y||d<-y;return e?b.some({top:a.constant(d),bottom:a.constant(d+c.height())}):b.none()})},n=c.last(function(){l.idle(function(){t.updatePositions(h,i.pageYOffset).get(function(){var a=m();a.each(function(a){f.dom().scrollTop=f.dom().scrollTop+a.top()}),l.start(0),j.refresh()})})},1e3),o=e.bind(g.fromDom(i),"scroll",function(){i.pageYOffset<0||n.throttle()});return t.updatePositions(h,i.pageYOffset).get(a.identity),{unbind:o.unbind}},A=function(b){var c=b.cWin(),i=b.ceBody(),j=b.socket(),k=b.toolstrip(),l=b.toolbar(),m=b.contentElement(),n=b.keyboardType(),o=b.outerWindow(),r=b.dropup(),t=u.takeover(j,i,k,r),x=n(b.outerBody(),c,f.body(),m,k,l),y=function(){x.toEditing(),I()},A=function(){x.toReading()},B=function(a){x.onToolbarTouch(a)},C=v.onChange(o,{onChange:a.noop,onReady:t.refresh});C.onAdjustment(function(){t.refresh()});var D=e.bind(g.fromDom(o),"resize",function(){t.isExpanding()&&t.refresh()}),E=z(k,j,b.outerBody(),o,t,c),F=p(c,m),G=function(){F.isActive()&&F.update()},H=function(){F.update()},I=function(){F.clear()},J=function(a,b){s.scrollIntoView(c,j,r,a,b)},K=function(){h.set(m,"height",m.dom().contentWindow.document.body.scrollHeight+"px")},L=function(b){t.setViewportOffset(b),q.moveOnlyTop(j,b).get(a.identity)},M=function(){t.restore(),C.destroy(),E.unbind(),D.unbind(),x.destroy(),F.destroy(),w.input(f.body(),d.blur)};return{toEditing:y,toReading:A,onToolbarTouch:B,refreshSelection:G,clearSelection:I,highlightSelection:H,scrollIntoView:J,updateToolbarPadding:a.noop,setViewportOffset:L,syncHeight:K,refreshStructure:t.refresh,destroy:M}};return{ +setup:A}}),g("6h",["y","6","8","1u","12","b","8q","8p"],function(a,b,c,d,e,f,g,h){var i=function(b,e,i,j){var k=function(){g.resume(e,j)},l=function(){h.input(b,c.blur)},m=d.bind(i,"keydown",function(b){a.contains(["input","textarea"],f.name(b.target()))||k()}),n=function(){},o=function(){m.unbind()};return{toReading:l,toEditing:k,onToolbarTouch:n,destroy:o}},j=function(a,d,e,f){var h=function(){c.blur(f)},i=function(){h()},j=function(){h()},k=function(){g.resume(d,f)};return{toReading:j,toEditing:k,onToolbarTouch:i,destroy:b.noop}};return{stubborn:i,timid:j}}),g("42",["6","1z","2o","8","a","2f","39","1b","6f","6g","5z","3y","6h","60","i","3z","61"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=function(r,s){var t=q.tag(),u=b.value(),v=b.value(),w=b.api(),x=b.api(),y=function(){s.hide();var b=e.fromDom(h);k.getActiveApi(r.editor).each(function(e){u.set({socketHeight:g.getRaw(r.socket,"height"),iframeHeight:g.getRaw(e.frame(),"height"),outerScroll:h.body.scrollTop}),v.set({exclusives:l.exclusive(b,"."+p.scrollable())}),f.add(r.container,o.resolve("fullscreen-maximized")),n.clobberStyles(r.container,e.body()),t.maximize(),g.set(r.socket,"overflow","scroll"),g.set(r.socket,"-webkit-overflow-scrolling","touch"),d.focus(e.body());var k=c.immutableBag(["cWin","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindow","outerBody"],[]);w.set(j.setup(k({cWin:e.win(),ceBody:e.body(),socket:r.socket,toolstrip:r.toolstrip,toolbar:r.toolbar,dropup:r.dropup.element(),contentElement:e.frame(),cursor:a.noop,outerBody:r.body,outerWindow:r.win,keyboardType:m.stubborn,isScrolling:function(){return v.get().exists(function(a){return a.socket.isScrolling()})}}))),w.run(function(a){a.syncHeight()}),x.set(i.initEvents(e,w,r.toolstrip,r.socket,r.dropup))})},z=function(){t.restore(),x.clear(),w.clear(),s.show(),u.on(function(a){a.socketHeight.each(function(a){g.set(r.socket,"height",a)}),a.iframeHeight.each(function(a){g.set(r.editor.getFrame(),"height",a)}),h.body.scrollTop=a.scrollTop}),u.clear(),v.on(function(a){a.exclusives.unbind()}),v.clear(),f.remove(r.container,o.resolve("fullscreen-maximized")),n.restoreStyles(),p.deregister(r.toolbar),g.remove(r.socket,"overflow"),g.remove(r.socket,"-webkit-overflow-scrolling"),d.blur(r.editor.getFrame()),k.getActiveApi(r.editor).each(function(a){a.clearSelection()})},A=function(){w.run(function(a){a.refreshStructure()})};return{enter:y,refreshStructure:A,exit:z}};return{create:r}}),g("25",["3q","2e","6","39","3s","42","3t"],function(a,b,c,d,e,f,g){var h=function(h){var i=b.asRawOrDie("Getting IosWebapp schema",e,h);d.set(i.toolstrip,"width","100%"),d.set(i.container,"position","relative");var j=function(){i.setReadOnly(!0),m.enter()},k=a.build(g.sketch(j,i.translate));i.alloy.add(k);var l={show:function(){i.alloy.add(k)},hide:function(){i.alloy.remove(k)}},m=f.create(i,l);return{setReadOnly:i.setReadOnly,refreshStructure:m.refreshStructure,enter:m.enter,exit:m.exit,destroy:c.noop}};return{produce:h}}),g("m",["1y","6","1z","25","i","21","22","23","24"],function(a,b,c,d,e,f,g,h,i){return function(j){var k=i({classes:[e.resolve("ios-container")]}),l=f(),m=c.api(),n=g.makeEditSwitch(m),o=g.makeSocket(),p=h.build(function(){m.run(function(a){a.refreshStructure()})},j);k.add(l.wrapper()),k.add(o),k.add(p.component());var q=function(a){var b=l.createGroups(a);l.setGroups(b)},r=function(a){var b=l.createGroups(a);l.setContextToolbar(b)},s=function(){l.focus()},t=function(){l.restoreToolbar()},u=function(a){m.set(d.produce(a))},v=function(){m.run(function(b){a.remove(o,n),b.exit()})},w=function(a){g.updateMode(o,n,a,k.root())};return{system:b.constant(k),element:k.element,init:u,exit:v,setToolbarGroups:q,setContextToolbar:r,focusToolbar:s,restoreToolbar:t,updateMode:w,socket:b.constant(o),dropup:b.constant(p)}}}),g("26",["1e"],function(a){return a("tinymce.EditorManager")}),g("n",["14","26"],function(a,b){var c=function(c){var d=a.readOptFrom(c.settings,"skin_url").fold(function(){return b.baseURL+"/skins/lightgray"},function(a){return a});return{content:d+"/content.mobile.min.css",ui:d+"/skin.mobile.min.css"}};return{derive:c}}),g("o",["y","6","x","g"],function(a,b,c,d){var e=["x-small","small","medium","large","x-large"],f=function(a,b,c){a.system().broadcastOn([d.formatChanged()],{command:b,state:c})},g=function(b,d){var e=c.keys(d.formatter.get());a.each(e,function(a){d.formatter.formatChanged(a,function(c){f(b,a,c)})}),a.each(["ul","ol"],function(a){d.selection.selectorChanged(a,function(c,d){f(b,a,c)})})};return{init:g,fontSizes:b.constant(e)}}),g("p",[],function(){var a=function(a){var b=function(){a._skinLoaded=!0,a.fire("SkinLoaded")};return function(){a.initialized?b():a.on("init",b)}};return{fireSkinLoaded:a}}),g("0",["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){var z=f.constant("toReading"),A=f.constant("toEditing");return l.add("mobile",function(l){var B=function(B){var C=w.derive(l);o.isSkinDisabled(l)===!1?(l.contentCSS.push(C.content),m.DOM.styleSheetLoader.load(C.ui,y.fireSkinLoaded(l))):y.fireSkinLoaded(l)();var D=function(){l.fire("scrollIntoView")},E=j.fromTag("div"),F=g.detect().os.isAndroid()?t(D):v(D),G=j.fromDom(B.targetNode);i.after(G,E),c.attachSystem(E,F.system());var H=function(a){return h.search(a).bind(function(a){return F.system().getByDom(a).toOption()})},I=B.targetNode.ownerDocument.defaultView,J=s.onChange(I,{onChange:function(){var a=F.system();a.broadcastOn([p.orientationChanged()],{width:s.getActualWidth(I)})},onReady:f.noop}),K=function(a,b,c){c===!1&&l.selection.collapse(),F.setToolbarGroups(c?a.get():b.get()),l.setMode(c===!0?"readonly":"design"),l.fire(c===!0?z():A()),F.updateMode(c)},L=function(a,b){return l.on(a,b),{unbind:function(){l.off(a)}}};return l.on("init",function(){F.init({editor:{getFrame:function(){return j.fromDom(l.contentAreaContainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:f.noop}},onToReading:function(a){return L(z(),a)},onToEditing:function(a){return L(A(),a)},onScrollToCursor:function(a){l.on("scrollIntoView",function(b){a(b)});var b=function(){l.off("scrollIntoView"),J.destroy()};return{unbind:b}},onTouchToolstrip:function(){c()},onTouchContent:function(){var a=j.fromDom(l.editorContainer.querySelector("."+r.resolve("toolbar")));H(a).each(b.emitExecute),F.restoreToolbar(),c()},onTapContent:function(b){var c=b.target();if("img"===k.name(c))l.selection.select(c.dom()),b.kill();else if("a"===k.name(c)){var d=F.system().getByDom(j.fromDom(l.editorContainer));d.each(function(b){a.isAlpha(b)&&n.openLink(c.dom())})}}},container:j.fromDom(l.editorContainer),socket:j.fromDom(l.contentAreaContainer),toolstrip:j.fromDom(l.editorContainer.querySelector("."+r.resolve("toolstrip"))),toolbar:j.fromDom(l.editorContainer.querySelector("."+r.resolve("toolbar"))),dropup:F.dropup(),alloy:F.system(),translate:f.noop,setReadOnly:function(a){K(w,v,a)}});var c=function(){F.dropup().disappear(function(){F.system().broadcastOn([p.dropupDismissed()],{})})};d.registerInspector("remove this",F.system());var g={label:"The first group",scrollable:!1,items:[u.forToolbar("back",function(){l.selection.collapse(),F.exit()},{})]},h={label:"Back to read only",scrollable:!1,items:[u.forToolbar("readonly-back",function(){K(w,v,!0)},{})]},i={label:"The read only mode group",scrollable:!0,items:[]},m=q.setup(F,l),o=q.detect(l.settings,m),s={label:"the action group",scrollable:!0,items:o},t={label:"The extra group",scrollable:!1,items:[]},v=e([h,s,t]),w=e([g,i,t]);x.init(F,l)}),{iframeContainer:F.socket().element().dom(),editorContainer:F.element().dom()}};return{getNotificationManagerImpl:function(){return{open:f.identity,close:f.noop,reposition:f.noop,getArgs:f.identity}},renderUI:B}}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/themes/modern/theme.min.js b/frontend/public/static/js/tinymce/js/tinymce/themes/modern/theme.min.js new file mode 100644 index 0000000..19a50ce --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/themes/modern/theme.min.js @@ -0,0 +1,5 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i0?c:f},v=function(a){var c=a.getParam("toolbar"),d="undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image";return c===!1?[]:b.isArray(c)?b.grep(c,function(a){return a.length>0}):u(a.settings,d)};return{isBrandingEnabled:c,hasMenubar:d,getMenubar:e,hasStatusbar:f,getToolbarSize:g,getResize:h,isReadOnly:i,getFixedToolbarContainer:j,getInlineToolbarPositionHandler:k,getMenu:l,getRemovedMenuItems:m,getMinWidth:n,getMinHeight:o,getMaxWidth:p,getMaxHeight:q,getSkinUrl:r,isSkinDisabled:s,isInline:t,getToolbars:v}}),g("2j",["6"],function(a){return a("tinymce.dom.DOMUtils")}),g("b",["6"],function(a){return a("tinymce.ui.Factory")}),g("37",["6"],function(a){return a("tinymce.util.I18n")}),g("2k",[],function(){var a=function(a){return a.fire("SkinLoaded")},b=function(a){return a.fire("ResizeEditor")},c=function(a){return a.fire("BeforeRenderUI")};return{fireSkinLoaded:a,fireResizeEditor:b,fireBeforeRenderUI:c}}),g("38",[],function(){var a=function(a,b){return function(){var c=a.find(b)[0];c&&c.focus(!0)}},b=function(b,c){b.shortcuts.add("Alt+F9","",a(c,"menubar")),b.shortcuts.add("Alt+F10,F10","",a(c,"toolbar")),b.shortcuts.add("Alt+F11","",a(c,"elementpath")),c.on("cancel",function(){b.focus()})};return{addKeys:b}}),g("14",["6"],function(a){return a("tinymce.Env")}),g("3p",["6"],function(a){return a("tinymce.geom.Rect")}),g("2u",["6"],function(a){return a("tinymce.util.Delay")}),h("2y",Array),h("2z",Error),g("z",["2y","2z"],function(a,b){var c=function(){},d=function(a,b){return function(){return a(b.apply(null,arguments))}},e=function(a){return function(){return a}},f=function(a){return a},g=function(a,b){return a===b},h=function(b){for(var c=new a(arguments.length-1),d=1;d=0;c--)for(d=f.length-1;d>=0;d--)if(f[d].predicate(e[c]))return{toolbar:f[d],element:e[c]};return null};b.on("click keyup setContent ObjectResized",function(a){("setcontent"!==a.type||a.selection)&&e.setEditorTimeout(b,function(){var a;a=w(b.selection.getNode()),a?(v(),u(a)):v()})}),b.on("blur hide contextmenu",v),b.on("ObjectResizeStart",function(){var a=w(b.selection.getNode());a&&a.toolbar.panel&&a.toolbar.panel.hide()}),b.on("ResizeEditor ResizeWindow",s(!0)),b.on("nodeChange",s(!1)),b.on("remove",function(){f.each(p(),function(a){a.panel&&a.panel.remove()}),b.contextToolbars={}}),b.shortcuts.add("ctrl+shift+e > ctrl+shift+p","",function(){var a=w(b.selection.getNode());a&&a.toolbar.panel&&a.toolbar.panel.items()[0].focus()})};return{addContextualToolbars:p}}),h("3h",String),g("2l",["3g","2y","2z","3h"],function(a,b,c,d){var e=function(){var a=b.prototype.indexOf,c=function(b,c){return a.call(b,c)},d=function(a,b){return u(a,b)};return void 0===a?d:c}(),f=function(b,c){var d=e(b,c);return d===-1?a.none():a.some(d)},g=function(a,b){return e(a,b)>-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e0&&b=11},l=function(a){return!(!k()||!a.sidebars)&&a.sidebars.length>0},m=function(a){var b=c.map(a.sidebars,function(b){var c=b.settings;return{type:"button",icon:c.icon,image:c.image,tooltip:c.tooltip,onclick:j(a,b.name,a.sidebars)}});return{type:"panel",name:"sidebar",layout:"stack",classes:"sidebar",items:[{type:"toolbar",layout:"stack",classes:"sidebar-toolbar",items:b}]}};return{hasSidebar:l,createSidebar:m}}),g("3c",["2k"],function(a){var b=function(b){var c=function(){b._skinLoaded=!0,a.fireSkinLoaded(b)};return function(){b.initialized?c():b.on("init",c)}};return{fireSkinLoaded:b}}),g("2g",["2j","b","37","c","2k","2f","38","39","3a","8","3b","3c","3d"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=a.DOM,o=function(a){return function(b){a.find("*").disabled("readonly"===b.mode)}},p=function(a){return{type:"panel",name:"iframe",layout:"stack",classes:"edit-area",border:a,html:""}},q=function(a){return{type:"panel",layout:"stack",classes:"edit-aria-container",border:"1 0 0 0",items:[p("0"),k.createSidebar(a)]}},r=function(a,d,r){var s,t,u;if(f.isSkinDisabled(a)===!1&&r.skinUiCss?n.styleSheetLoader.load(r.skinUiCss,l.fireSkinLoaded(a)):l.fireSkinLoaded(a)(),s=d.panel=b.create({type:"panel",role:"application",classes:"tinymce",style:"visibility: hidden",layout:"stack",border:1,items:[{type:"container",classes:"top-part",items:[f.hasMenubar(a)===!1?null:{type:"menubar",border:"0 0 1 0",items:i.createMenuButtons(a)},m.createToolbars(a,f.getToolbarSize(a))]},k.hasSidebar(a)?q(a):p("1 0 0 0")]}),"none"!==f.getResize(a)&&(t={type:"resizehandle",direction:f.getResize(a),onResizeStart:function(){var b=a.getContentAreaContainer().firstChild;u={width:b.clientWidth,height:b.clientHeight}},onResize:function(b){"both"===f.getResize(a)?j.resizeTo(a,u.width+b.deltaX,u.height+b.deltaY):j.resizeTo(a,null,u.height+b.deltaY)}}),f.hasStatusbar(a)){var v='tinymce',w=c.translate(["Powered by {0}",v]),x=f.isBrandingEnabled(a)?{type:"label",classes:"branding",html:" "+w}:null;s.add({type:"panel",name:"statusbar",classes:"statusbar",layout:"flow",border:"1 0 0 0",ariaRoot:!0,items:[{type:"elementpath",editor:a},t,x]})}return e.fireBeforeRenderUI(a),a.on("SwitchMode",o(s)),s.renderBefore(r.targetNode).reflow(),f.isReadOnly(a)&&a.setMode("readonly"),r.width&&n.setStyle(s.getEl(),"width",r.width),a.on("remove",function(){s.remove(),s=null}),g.addKeys(a,s),h.addContextualToolbars(a),{iframeContainer:s.find("#iframe")[0].getEl(),editorContainer:s.getEl()}};return{render:r}}),h("12",document),g("2o",["6"],function(a){return a("tinymce.dom.DomQuery")}),g("2n",["12","2j","14","c"],function(a,b,c,d){"use strict";var e=0,f={id:function(){return"mceu_"+e++},create:function(c,e,f){var g=a.createElement(c);return b.DOM.setAttribs(g,e),"string"==typeof f?g.innerHTML=f:d.each(f,function(a){a.nodeType&&g.appendChild(a)}),g},createFragment:function(a){return b.DOM.createFragment(a)},getWindowSize:function(){return b.DOM.getViewPort()},getSize:function(a){var b,c;if(a.getBoundingClientRect){var d=a.getBoundingClientRect();b=Math.max(d.width||d.right-d.left,a.offsetWidth),c=Math.max(d.height||d.bottom-d.bottom,a.offsetHeight)}else b=a.offsetWidth,c=a.offsetHeight;return{width:b,height:c}},getPos:function(a,c){return b.DOM.getPos(a,c||f.getContainer())},getContainer:function(){return c.container?c.container:a.body},getViewPort:function(a){return b.DOM.getViewPort(a)},get:function(b){return a.getElementById(b)},addClass:function(a,c){return b.DOM.addClass(a,c)},removeClass:function(a,c){return b.DOM.removeClass(a,c)},hasClass:function(a,c){return b.DOM.hasClass(a,c)},toggleClass:function(a,c,d){return b.DOM.toggleClass(a,c,d)},css:function(a,c,d){return b.DOM.setStyle(a,c,d)},getRuntimeStyle:function(a,c){return b.DOM.getStyle(a,c,!0)},on:function(a,c,d,e){return b.DOM.bind(a,c,d,e)},off:function(a,c,d){return b.DOM.unbind(a,c,d)},fire:function(a,c,d){return b.DOM.fire(a,c,d)},innerHtml:function(a,c){b.DOM.setHTML(a,c)}};return f}),g("1s",["12","1","2n"],function(a,b,c){"use strict";function d(b,d,e){var f,g,h,i,j,k,l,m,n,o;return n=c.getViewPort(),g=c.getPos(d),h=g.x,i=g.y,b.state.get("fixed")&&"static"==c.getRuntimeStyle(a.body,"position")&&(h-=n.x,i-=n.y),f=b.getEl(),o=c.getSize(f),j=o.width,k=o.height,o=c.getSize(d),l=o.width,m=o.height,e=(e||"").split(""),"b"===e[0]&&(i+=m),"r"===e[1]&&(h+=l),"c"===e[0]&&(i+=Math.round(m/2)),"c"===e[1]&&(h+=Math.round(l/2)),"b"===e[3]&&(i-=k),"r"===e[4]&&(h-=j),"c"===e[3]&&(i-=Math.round(k/2)),"c"===e[4]&&(h-=Math.round(j/2)),{x:h,y:i,w:j,h:k}}return{testMoveRel:function(a,b){for(var e=c.getViewPort(),f=0;f0&&g.x+g.w0&&g.y+g.he.x&&g.x+g.we.y&&g.y+g.hb?(a=b-c,a<0?0:a):a}var f=this;if(f.settings.constrainToViewport){var g=c.getViewPort(b),h=f.layoutRect();a=e(a,g.w+g.x,h.w),d=e(d,g.h+g.y,h.h)}return f.state.get("rendered")?f.layoutRect({x:a,y:d}).repaint():(f.settings.x=a,f.settings.y=d),f.fire("move",{x:a,y:d}),f}}}),g("2p",["6"],function(a){return a("tinymce.util.Class")}),g("2q",["6"],function(a){return a("tinymce.util.EventDispatcher")}),g("2r",["12"],function(a){"use strict";return{parseBox:function(a){var b,c=10;if(a)return"number"==typeof a?(a=a||0,{top:a,left:a,bottom:a,right:a}):(a=a.split(" "),b=a.length,1===b?a[1]=a[2]=a[3]=a[0]:2===b?(a[2]=a[0],a[3]=a[1]):3===b&&(a[3]=a[1]),{top:parseInt(a[0],c)||0,right:parseInt(a[1],c)||0,bottom:parseInt(a[2],c)||0,left:parseInt(a[3],c)||0})},measureBox:function(b,c){function d(c){var d=a.defaultView;return d?(c=c.replace(/[A-Z]/g,function(a){return"-"+a}),d.getComputedStyle(b,null).getPropertyValue(c)):b.currentStyle[c]}function e(a){var b=parseFloat(d(a),10);return isNaN(b)?0:b}return{top:e(c+"TopWidth"),right:e(c+"RightWidth"),bottom:e(c+"BottomWidth"),left:e(c+"LeftWidth")}}}}),g("2s",["c"],function(a){"use strict";function b(){}function c(a){this.cls=[],this.cls._map={},this.onchange=a||b,this.prefix=""}return a.extend(c.prototype,{add:function(a){return a&&!this.contains(a)&&(this.cls._map[a]=!0,this.cls.push(a),this._change()),this},remove:function(a){if(this.contains(a)){for(var b=0;b0&&(a+=" "),a+=this.prefix+this.cls[b];return a},c}),g("24",["2p"],function(a){"use strict";function b(a){for(var b,c=[],d=a.length;d--;)b=a[d],b.__checked||(c.push(b),b.__checked=1);for(d=c.length;d--;)delete c[d].__checked;return c}var c,d=/^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i,e=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,f=/^\s*|\s*$/g,g=a.extend({init:function(a){function b(a){if(a)return a=a.toLowerCase(),function(b){return"*"===a||b.type===a}}function c(a){if(a)return function(b){return b._name===a}}function g(a){if(a)return a=a.split("."),function(b){for(var c=a.length;c--;)if(!b.classes.contains(a[c]))return!1;return!0}}function h(a,b,c){if(a)return function(d){var e=d[a]?d[a]():"";return b?"="===b?e===c:"*="===b?e.indexOf(c)>=0:"~="===b?(" "+e+" ").indexOf(" "+c+" ")>=0:"!="===b?e!=c:"^="===b?0===e.indexOf(c):"$="===b&&e.substr(e.length-c.length)===c:!!c}}function i(a){var b;if(a)return a=/(?:not\((.+)\))|(.+)/i.exec(a),a[1]?(b=k(a[1],[]),function(a){return!l(a,b)}):(a=a[2],function(b,c,d){return"first"===a?0===c:"last"===a?c===d-1:"even"===a?c%2===0:"odd"===a?c%2===1:!!b[a]&&b[a]()})}function j(a,e,j){function k(a){a&&e.push(a)}var l;return l=d.exec(a.replace(f,"")),k(b(l[1])),k(c(l[2])),k(g(l[3])),k(h(l[4],l[5],l[6])),k(i(l[7])),e.pseudo=!!l[7],e.direct=j,e}function k(a,b){var c,d,f,g=[];do if(e.exec(""),d=e.exec(a),d&&(a=d[3],g.push(d[1]),d[2])){c=d[3];break}while(d);for(c&&k(c,b),a=[],f=0;f"!=g[f]&&a.push(j(g[f],[],">"===g[f-1]));return b.push(a),b}var l=this.match;this._selectors=k(a,[])},match:function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;for(b=b||this._selectors,c=0,d=b.length;c=0;e--)for(j=g[e];o;){if(j.pseudo)for(m=o.parent().items(),k=l=m.length;k--&&m[k]!==o;);for(h=0,i=j.length;h1&&(h=b(h))}return c||(c=g.Collection),new c(h)}});return g}),g("i",["c","24","2p"],function(a,b,c){"use strict";var d,e,f=Array.prototype.push,g=Array.prototype.slice;return e={length:0,init:function(a){a&&this.add(a)},add:function(b){var c=this;return a.isArray(b)?f.apply(c,b):b instanceof d?c.add(b.toArray()):f.call(c,b),c},set:function(a){var b,c=this,d=c.length;for(c.length=0,c.add(a),b=c.length;b0}function f(a,b){var c,g;if(a===b)return!0;if(null===a||null===b)return a===b;if("object"!=typeof a||"object"!=typeof b)return a===b;if(d.isArray(b)){if(a.length!==b.length)return!1;for(c=a.length;c--;)if(!f(a[c],b[c]))return!1}if(e(a)||e(b))return a===b;g={};for(c in b){if(!f(a[c],b[c]))return!1;g[c]=!0}for(c in a)if(!g[c]&&!f(a[c],b[c]))return!1;return!0}return b.extend({Mixins:[c],init:function(b){var c,d;b=b||{};for(c in b)d=b[c],d instanceof a&&(b[c]=d.create(this,c));this.data=b},set:function(b,c){var d,e,g=this.data[b];if(c instanceof a&&(c=c.create(this,b)),"object"==typeof b){for(d in b)this.set(d,b[d]);return this}return f(g,c)||(this.data[b]=c,e={target:this,name:b,value:c,oldValue:g},this.fire("change:"+b,e),this.fire("change",e)),this},get:function(a){return this.data[a]},has:function(a){return a in this.data},bind:function(b){return a.create(this,b)},destroy:function(){this.fire("destroy")}})}),g("1z",["12","2u"],function(a,b){var c,d={};return{add:function(e){var f=e.parent();if(f){if(!f._layout||f._layout.isNative())return;d[f._id]||(d[f._id]=f),c||(c=!0,b.requestAnimationFrame(function(){var a,b;c=!1;for(a in d)b=d[a],b.state.get("rendered")&&b.reflow();d={}},a.body))}},remove:function(a){d[a._id]&&delete d[a._id]}}}),g("o",["12","2o","2p","2q","c","2r","2s","i","2t","2n","1z"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";function l(a){return a._eventDispatcher||(a._eventDispatcher=new d({scope:a,toggleEvent:function(b,c){c&&d.isNative(b)&&(a._nativeEvents||(a._nativeEvents={}),a._nativeEvents[b]=!0,a.state.get("rendered")&&m(a))}})),a._eventDispatcher}function m(a){function c(b){var c=a.getParentCtrl(b.target);c&&c.fire(b.type,b)}function d(){var a=j._lastHoverCtrl;a&&(a.fire("mouseleave",{target:a.getEl()}),a.parents().each(function(a){a.fire("mouseleave",{target:a.getEl()})}),j._lastHoverCtrl=null)}function e(b){var c,d,e,f=a.getParentCtrl(b.target),g=j._lastHoverCtrl,h=0;if(f!==g){if(j._lastHoverCtrl=f,d=f.parents().toArray().reverse(),d.push(f),g){for(e=g.parents().toArray().reverse(),e.push(g),h=0;h=h;c--)g=e[c],g.fire("mouseleave",{target:g.getEl()})}for(c=h;ci.maxW?i.maxW:c,i.w=c,i.innerW=c-d),c=a.h,c!==f&&(c=ci.maxH?i.maxH:c,i.h=c,i.innerH=c-e),c=a.innerW,c!==f&&(c=ci.maxW-d?i.maxW-d:c,i.innerW=c,i.w=c+d),c=a.innerH,c!==f&&(c=ci.maxH-e?i.maxH-e:c,i.innerH=c,i.h=c+e),a.contentW!==f&&(i.contentW=a.contentW),a.contentH!==f&&(i.contentH=a.contentH),b=h._lastLayoutRect,b.x===i.x&&b.y===i.y&&b.w===i.w&&b.h===i.h||(g=n.repaintControls,g&&g.map&&!g.map[h._id]&&(g.push(h),g.map[h._id]=!0),b.x=i.x,b.y=i.y,b.w=i.w,b.h=i.h),h):i},repaint:function(){var b,c,d,e,f,g,h,i,j,k,l=this;j=a.createRange?function(a){return a}:Math.round,b=l.getEl().style,e=l._layoutRect,i=l._lastRepaintRect||{},f=l.borderBox,g=f.left+f.right,h=f.top+f.bottom,e.x!==i.x&&(b.left=j(e.x)+"px",i.x=e.x),e.y!==i.y&&(b.top=j(e.y)+"px",i.y=e.y),e.w!==i.w&&(k=j(e.w-g),b.width=(k>=0?k:0)+"px",i.w=e.w),e.h!==i.h&&(k=j(e.h-h),b.height=(k>=0?k:0)+"px",i.h=e.h),l._hasBody&&e.innerW!==i.innerW&&(k=j(e.innerW),d=l.getEl("body"),d&&(c=d.style,c.width=(k>=0?k:0)+"px"),i.innerW=e.innerW),l._hasBody&&e.innerH!==i.innerH&&(k=j(e.innerH),d=d||l.getEl("body"),d&&(c=c||d.style,c.height=(k>=0?k:0)+"px"),i.innerH=e.innerH),l._lastRepaintRect=i,l.fire("repaint",{},!1)},updateLayoutRect:function(){var a=this;a.parent()._lastRect=null,j.css(a.getEl(),{width:"",height:""}),a._layoutRect=a._lastRepaintRect=a._lastLayoutRect=null,a.initLayoutRect()},on:function(a,b){function c(a){var b,c;return"string"!=typeof a?a:function(e){return b||d.parentsAndSelf().each(function(d){var e=d.settings.callbacks;if(e&&(b=e[a]))return c=d,!1}),b?b.call(c,e):(e.action=a,void this.fire("execute",e))}}var d=this;return l(d).on(a,c(b)),d},off:function(a,b){return l(this).off(a,b),this},fire:function(a,b,c){var d=this;if(b=b||{},b.control||(b.control=d),b=l(d).fire(a,b),c!==!1&&d.parent)for(var e=d.parent();e&&!b.isPropagationStopped();)e.fire(a,b,!1),e=e.parent();return b},hasEventListeners:function(a){return l(this).has(a)},parents:function(a){var b,c=this,d=new h;for(b=c.parent();b;b=b.parent())d.add(b);return a&&(d=d.filter(a)),d},parentsAndSelf:function(a){return new h(this).add(this.parents(a))},next:function(){var a=this.parent().items();return a[a.indexOf(this)+1]},prev:function(){var a=this.parent().items();return a[a.indexOf(this)-1]},innerHtml:function(a){return this.$el.html(a),this},getEl:function(a){var c=a?this._id+"-"+a:this._id;return this._elmCache[c]||(this._elmCache[c]=b("#"+c)[0]),this._elmCache[c]},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(a){}return this},blur:function(){return this.getEl().blur(),this},aria:function(a,b){var c=this,d=c.getEl(c.ariaTarget);return"undefined"==typeof b?c._aria[a]:(c._aria[a]=b,c.state.get("rendered")&&d.setAttribute("role"==a?a:"aria-"+a,b),c)},encode:function(a,b){return b!==!1&&(a=this.translate(a)),(a||"").replace(/[&<>"]/g,function(a){return"&#"+a.charCodeAt(0)+";"})},translate:function(a){return n.translate?n.translate(a):a},before:function(a){var b=this,c=b.parent();return c&&c.insert(a,c.items().indexOf(b),!0),b},after:function(a){var b=this,c=b.parent();return c&&c.insert(a,c.items().indexOf(b)),b},remove:function(){var a,c,d=this,e=d.getEl(),f=d.parent();if(d.items){var g=d.items().toArray();for(c=g.length;c--;)g[c].remove()}f&&f.items&&(a=[],f.items().each(function(b){b!==d&&a.push(b)}),f.items().set(a),f._lastRect=null),d._eventsRoot&&d._eventsRoot==d&&b(e).off();var h=d.getRoot().controlIdLookup;return h&&delete h[d._id],e&&e.parentNode&&e.parentNode.removeChild(e),d.state.set("rendered",!1),d.state.destroy(),d.fire("remove"),d},renderBefore:function(a){return b(a).before(this.renderHtml()),this.postRender(),this},renderTo:function(a){return b(a||this.getContainerElm()).append(this.renderHtml()),this.postRender(),this},preRender:function(){},render:function(){},renderHtml:function(){return'
          '},postRender:function(){var a,c,d,e,f,g=this,h=g.settings;g.$el=b(g.getEl()),g.state.set("rendered",!0);for(e in h)0===e.indexOf("on")&&g.on(e.substr(2),h[e]);if(g._eventsRoot){for(d=g.parent();!f&&d;d=d.parent())f=d._eventsRoot;if(f)for(e in f._nativeEvents)g._nativeEvents[e]=!0}m(g),h.style&&(a=g.getEl(),a&&(a.setAttribute("style",h.style),a.style.cssText=h.style)),g.settings.border&&(c=g.borderBox,g.$el.css({"border-top-width":c.top,"border-right-width":c.right,"border-bottom-width":c.bottom,"border-left-width":c.left}));var i=g.getRoot();i.controlIdLookup||(i.controlIdLookup={}),i.controlIdLookup[g._id]=g;for(var j in g._aria)g.aria(j,g._aria[j]);g.state.get("visible")===!1&&(g.getEl().style.display="none"),g.bindStates(),g.state.on("change:visible",function(a){var b,c=a.value;g.state.get("rendered")&&(g.getEl().style.display=c===!1?"none":"",g.getEl().getBoundingClientRect()),b=g.parent(),b&&(b._lastRect=null),g.fire(c?"show":"hide"),k.add(g)}),g.fire("postrender",{},!1)},bindStates:function(){},scrollIntoView:function(a){function b(a,b){var c,d,e=a;for(c=d=0;e&&e!=b&&e.nodeType;)c+=e.offsetLeft||0,d+=e.offsetTop||0,e=e.offsetParent;return{x:c,y:d}}var c,d,e,f,g,h,i=this.getEl(),j=i.parentNode,k=b(i,j);return c=k.x,d=k.y,e=i.offsetWidth,f=i.offsetHeight,g=j.clientWidth,h=j.clientHeight,"end"==a?(c-=g-e,d-=h-f):"center"==a&&(c-=g/2-e/2,d-=h/2-f/2),j.scrollLeft=c,j.scrollTop=d,this},getRoot:function(){for(var a,b=this,c=[];b;){if(b.rootControl){a=b.rootControl;break}c.push(b),a=b,b=b.parent()}a||(a=this);for(var d=c.length;d--;)c[d].rootControl=a;return a},reflow:function(){k.remove(this);var a=this.parent();return a&&a._layout&&!a._layout.isNative()&&a.reflow(),this}};return e.each("text title visible disabled active value".split(" "),function(a){s[a]=function(b){return 0===arguments.length?this.state.get(a):("undefined"!=typeof b&&this.state.set(a,b),this)}}),n=c.extend(s)}),g("1j",["12"],function(a){"use strict";var b=function(a){return!!a.getAttribute("data-mce-tabstop")};return function(c){function d(a){return a&&1===a.nodeType}function e(a){return a=a||v,d(a)?a.getAttribute("role"):null}function f(a){for(var b,c=a||v;c=c.parentNode;)if(b=e(c))return b}function g(a){var b=v;if(d(b))return b.getAttribute("aria-"+a)}function h(a){var b=a.tagName.toUpperCase();return"INPUT"==b||"TEXTAREA"==b||"SELECT"==b}function i(a){return!(!h(a)||a.hidden)||(!!b(a)||!!/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(e(a)))}function j(a){function b(a){if(1==a.nodeType&&"none"!=a.style.display&&!a.disabled){i(a)&&c.push(a);for(var d=0;d=b.length&&(a=0),b[a]&&b[a].focus(),a}function n(a,b){var c=-1,d=k();b=b||j(d.getEl());for(var e=0;e=0&&(c=b.getEl(),c&&c.parentNode.removeChild(c),c=a.getEl(),c&&c.parentNode.removeChild(c)),b.parent(this)},create:function(b){var c,e=this,g=[];return f.isArray(b)||(b=[b]),f.each(b,function(b){b&&(b instanceof a||("string"==typeof b&&(b={type:b}),c=f.extend({},e.settings.defaults,b),b.type=c.type=c.type||b.type||e.settings.defaultType||(c.defaults?c.defaults.type:null),b=d.create(c)),g.push(b))}),g},renderNew:function(){var a=this;return a.items().each(function(b,c){var d;b.parent(a),b.state.get("rendered")||(d=a.getEl("body"),d.hasChildNodes()&&c<=d.childNodes.length-1?g(d.childNodes[c]).before(b.renderHtml()):g(d).append(b.renderHtml()),b.postRender(),i.add(b))}),a._layout.applyClasses(a.items().filter(":visible")),a._lastRect=null,a},append:function(a){return this.add(a).renderNew()},prepend:function(a){var b=this;return b.items().set(b.create(a).concat(b.items().toArray())),b.renderNew()},insert:function(a,b,c){var d,e,f,g=this;return a=g.create(a),d=g.items(),!c&&b=0&&b
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "},postRender:function(){var a,b=this;return b.items().exec("postRender"),b._super(),b._layout.postRender(b),b.state.set("rendered",!0),b.settings.style&&b.$el.css(b.settings.style),b.settings.border&&(a=b.borderBox,b.$el.css({"border-top-width":a.top,"border-right-width":a.right,"border-bottom-width":a.bottom,"border-left-width":a.left})),b.parent()||(b.keyboardNav=new e({root:b})),b},initLayoutRect:function(){var a=this,b=a._super();return a._layout.recalc(a),b},recalc:function(){var a=this,b=a._layoutRect,c=a._lastRect;if(!c||c.w!=b.w||c.h!=b.h)return a._layout.recalc(a),b=a.layoutRect(),a._lastRect={x:b.x,y:b.y,w:b.w,h:b.h},!0},reflow:function(){var b;if(i.remove(this),this.visible()){for(a.repaintControls=[],a.repaintControls.map={},this.recalc(),b=a.repaintControls.length;b--;)a.repaintControls[b].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),a.repaintControls=[]}return this}})}),g("p",["12","1","2o"],function(a,b,c){"use strict";function d(a){var b,c,d,e,f,g,h,i,j=Math.max;return b=a.documentElement,c=a.body,d=j(b.scrollWidth,c.scrollWidth),e=j(b.clientWidth,c.clientWidth),f=j(b.offsetWidth,c.offsetWidth),g=j(b.scrollHeight,c.scrollHeight),h=j(b.clientHeight,c.clientHeight),i=j(b.offsetHeight,c.offsetHeight),{width:d").css({position:"absolute",top:0,left:0,width:q.width,height:q.height,zIndex:2147483647,opacity:1e-4,cursor:k}).appendTo(p.body),c(p).on("mousemove touchmove",m).on("mouseup touchend",l),g.start(a)},m=function(a){return e(a),a.button!==j?l(a):(a.deltaX=a.screenX-n,a.deltaY=a.screenY-o,a.preventDefault(),void g.drag(a))},l=function(a){e(a),c(p).off("mousemove touchmove",m).off("mouseup touchend",l),i.remove(),g.stop&&g.stop(a)},this.destroy=function(){c(h()).off()},c(h()).on("mousedown touchstart",k)}}),g("22",["2o","p"],function(a,b){"use strict";return{init:function(){var a=this;a.on("repaint",a.renderScroll)},renderScroll:function(){function c(){function b(b,g,h,i,j,k){var l,m,n,o,p,q,r,s,t;if(m=e.getEl("scroll"+b)){if(s=g.toLowerCase(),t=h.toLowerCase(),a(e.getEl("absend")).css(s,e.layoutRect()[i]-1),!j)return void a(m).css("display","none");a(m).css("display","block"),l=e.getEl("body"),n=e.getEl("scroll"+b+"t"),o=l["client"+h]-2*f,o-=c&&d?m["client"+k]:0,p=l["scroll"+h],q=o/p,r={},r[s]=l["offset"+g]+f,r[t]=o,a(m).css(r),r={},r[s]=l["scroll"+g]*q,r[t]=o*q,a(n).css(r)}}var c,d,g;g=e.getEl("body"),c=g.scrollWidth>g.clientWidth,d=g.scrollHeight>g.clientHeight,b("h","Left","Width","contentW",c,"Height"),b("v","Top","Height","contentH",d,"Width")}function d(){function c(c,d,g,h,i){var j,k=e._id+"-scroll"+c,l=e.classPrefix;a(e.getEl()).append('
          '),e.draghelper=new b(k+"t",{start:function(){j=e.getEl("body")["scroll"+d],a("#"+k).addClass(l+"active")},drag:function(a){var b,k,l,m,n=e.layoutRect();k=n.contentW>n.innerW,l=n.contentH>n.innerH,m=e.getEl("body")["client"+g]-2*f,m-=k&&l?e.getEl("scroll"+c)["client"+i]:0,b=m/e.getEl("body")["scroll"+g],e.getEl("body")["scroll"+d]=j+a["delta"+h]/b},stop:function(){a("#"+k).removeClass(l+"active")}})}e.classes.add("scroll"),c("v","Top","Height","Y","Width"),c("h","Left","Width","X","Height")}var e=this,f=2;e.settings.autoScroll&&(e._hasScroll||(e._hasScroll=!0,d(),e.on("wheel",function(a){var b=e.getEl("body");b.scrollLeft+=10*(a.deltaX||0),b.scrollTop+=10*a.deltaY,c()}),a(e.getEl("body")).on("scroll",c)),c())}}}),g("1u",["n","22"],function(a,b){"use strict";return a.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[b],renderHtml:function(){var a=this,b=a._layout,c=a.settings.html;return a.preRender(),b.preRender(a),"undefined"==typeof c?c='
          '+b.renderHtml(a)+"
          ":("function"==typeof c&&(c=c.call(a)),a._hasBody=!1),'
          '+(a._preBodyHtml||"")+c+"
          "}})}),g("20",["2n"],function(a){"use strict";return{resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(b,c){if(b<=1||c<=1){var d=a.getWindowSize();b=b<=1?b*d.w:b,c=c<=1?c*d.h:c}return this._layoutRect.autoResize=!1,this.layoutRect({minW:b,minH:c,w:b,h:c}).reflow()},resizeBy:function(a,b){var c=this,d=c.layoutRect();return c.resizeTo(d.w+a,d.h+b)}}}),g("w",["12","1","2o","2u","2n","1s","1u","20"],function(a,b,c,d,e,f,g,h){"use strict";function i(a,b){for(;a;){if(a==b)return!0;a=a.parent()}}function j(a){for(var b=u.length;b--;){var c=u[b],d=c.getParentCtrl(a.target);if(c.settings.autohide){if(d&&(i(d,c)||c.parent()===d))continue;a=c.fire("autohide",{target:a.target}),a.isDefaultPrevented()||c.hide()}}}function k(){q||(q=function(a){2!=a.button&&j(a)},c(a).on("click touchstart",q))}function l(){r||(r=function(){var a;for(a=u.length;a--;)n(u[a])},c(b).on("scroll",r))}function m(){if(!s){var d=a.documentElement,e=d.clientWidth,f=d.clientHeight;s=function(){a.all&&e==d.clientWidth&&f==d.clientHeight||(e=d.clientWidth,f=d.clientHeight,w.hideAll())},c(b).on("resize",s)}}function n(a){function b(b,c){for(var d,e=0;ec&&(a.fixed(!1).layoutRect({y:a._autoFixY}).repaint(),b(!1,a._autoFixY-c)):(a._autoFixY=a.layoutRect().y,a._autoFixY').appendTo(b.getContainerElm())),d.setTimeout(function(){e.addClass(f+"in"),c(b.getEl()).addClass(f+"in")}),t=!0),o(!0,b)}}),b.on("show",function(){b.parents().each(function(a){if(a.state.get("fixed"))return b.fixed(!0),!1})}),a.popover&&(b._preBodyHtml='
          ',b.classes.add("popover").add("bottom").add(b.isRtl()?"end":"start")),b.aria("label",a.ariaLabel),b.aria("labelledby",b._id),b.aria("describedby",b.describedBy||b._id+"-none")},fixed:function(a){var b=this;if(b.state.get("fixed")!=a){if(b.state.get("rendered")){var c=e.getViewPort();a?b.layoutRect().y-=c.y:b.layoutRect().y+=c.y}b.classes.toggle("fixed",a),b.state.set("fixed",a)}return b},show:function(){var a,b=this,c=b._super();for(a=u.length;a--&&u[a]!==b;);return a===-1&&u.push(b),c},hide:function(){return p(this),o(!1,this),this._super()},hideAll:function(){w.hideAll()},close:function(){var a=this;return a.fire("close").isDefaultPrevented()||(a.remove(),o(!1,a)),a},remove:function(){p(this),this._super()},postRender:function(){var a=this;return a.settings.bodyRole&&this.getEl("body").setAttribute("role",a.settings.bodyRole),a._super()}});return w.hideAll=function(){for(var a=u.length;a--;){var b=u[a];b&&b.settings.autohide&&(b.hide(),u.splice(a,1))}},w}),g("2h",["12","14","2j","b","2k","2f","38","39","3a","3c","3d","w"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=function(a){return!(!a||b.container)},n=function(a,b,n){var o,p,q=c.DOM,r=f.getFixedToolbarContainer(a);r&&(p=q.select(r)[0]);var s=function(){if(o&&o.moveRel&&o.visible()&&!o._fixed){var b=a.selection.getScrollContainer(),c=a.getBody(),d=0,e=0;if(b){var f=q.getPos(c),g=q.getPos(b);d=Math.max(0,g.x-f.x),e=Math.max(0,g.y-f.y)}o.fixed(!1).moveRel(c,a.rtl?["tr-br","br-tr"]:["tl-bl","bl-tl","tr-br"]).moveBy(d,e)}},t=function(){o&&(o.show(),s(),q.addClass(a.getBody(),"mce-edit-focus"))},u=function(){o&&(o.hide(),l.hideAll(),q.removeClass(a.getBody(),"mce-edit-focus"))},v=function(){return o?void(o.visible()||t()):(o=b.panel=d.create({type:p?"panel":"floatpanel",role:"application",classes:"tinymce tinymce-inline",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:m(p),fixed:m(p),border:1,items:[f.hasMenubar(a)===!1?null:{type:"menubar",border:"0 0 1 0",items:i.createMenuButtons(a)},k.createToolbars(a,f.getToolbarSize(a))]}),e.fireBeforeRenderUI(a),p?o.renderTo(p).reflow():o.renderTo().reflow(),g.addKeys(a,o),t(),h.addContextualToolbars(a),a.on("nodeChange",s),a.on("activate",t),a.on("deactivate",u),void a.nodeChanged())};return a.settings.content_editable=!0,a.on("focus",function(){f.isSkinDisabled(a)===!1&&n.skinUiCss?q.styleSheetLoader.load(n.skinUiCss,v,v):v()}),a.on("blur hide",u),a.on("remove",function(){o&&(o.remove(),o=null)}),f.isSkinDisabled(a)===!1&&n.skinUiCss?q.styleSheetLoader.load(n.skinUiCss,j.fireSkinLoaded(a)):j.fireSkinLoaded(a)(),{}};return{render:n}}),g("2b",["2o","o","2u"],function(a,b,c){"use strict";return function(d,e){var f,g,h=this,i=b.classPrefix;h.show=function(b,j){function k(){f&&(a(d).append('
          '),j&&j())}return h.hide(),f=!0,b?g=c.setTimeout(k,b):k(),h},h.hide=function(){var a=d.lastChild;return c.clearTimeout(g),a&&a.className.indexOf("throbber")!=-1&&a.parentNode.removeChild(a),f=!1,h}}}),g("2i",["2b"],function(a){var b=function(b,c){var d;b.on("ProgressState",function(b){d=d||new a(c.panel.getEl("body")),b.state?d.show(b.time):d.hide()})};return{setup:b}}),g("7",["2f","2g","2h","2i"],function(a,b,c,d){var e=function(e,f,g){var h=a.getSkinUrl(e);return h&&(g.skinUiCss=h+"/skin.min.css",e.contentCSS.push(h+"/content"+(e.inline?".inline":"")+".min.css")),d.setup(e,f),a.isInline(e)?c.render(e,f,g):b.render(e,f,g)};return{renderUI:e}}),h("2m",setTimeout),g("2d",["o","1s"],function(a,b){return a.extend({Mixins:[b],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var a=this,b=a.classPrefix;return'"},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl().lastChild.innerHTML=a.encode(b.value)}),a._super()},repaint:function(){var a,b,c=this;a=c.getEl().style,b=c._layoutRect,a.left=b.x+"px",a.top=b.y+"px",a.zIndex=131070}})}),g("15",["o","2d"],function(a,b){"use strict";var c,d=a.extend({init:function(a){var b=this;b._super(a),a=b.settings,b.canFocus=!0,a.tooltip&&d.tooltips!==!1&&(b.on("mouseenter",function(c){var d=b.tooltip().moveTo(-65535);if(c.control==b){var e=d.text(a.tooltip).show().testMoveRel(b.getEl(),["bc-tc","bc-tl","bc-tr"]);d.classes.toggle("tooltip-n","bc-tc"==e),d.classes.toggle("tooltip-nw","bc-tl"==e),d.classes.toggle("tooltip-ne","bc-tr"==e),d.moveRel(b.getEl(),e)}else d.hide()}),b.on("mouseleave mousedown click",function(){b.tooltip().hide()})),b.aria("label",a.ariaLabel||a.tooltip)},tooltip:function(){return c||(c=new b({type:"tooltip"}),c.renderTo()),c},postRender:function(){var a=this,b=a.settings;a._super(),a.parent()||!b.width&&!b.height||(a.initLayoutRect(),a.repaint()),b.autofocus&&a.focus()},bindStates:function(){function a(a){c.aria("disabled",a),c.classes.toggle("disabled",a)}function b(a){c.aria("pressed",a),c.classes.toggle("active",a)}var c=this;return c.state.on("change:disabled",function(b){a(b.value)}),c.state.on("change:active",function(a){b(a.value)}),c.state.get("disabled")&&a(!0),c.state.get("active")&&b(!0),c._super()},remove:function(){this._super(),c&&(c.remove(),c=null)}});return d}),g("1x",["15"],function(a){"use strict";return a.extend({Defaults:{value:0},init:function(a){var b=this;b._super(a),b.classes.add("progress"),b.settings.filter||(b.settings.filter=function(a){return Math.round(a)})},renderHtml:function(){var a=this,b=a._id,c=this.classPrefix;return'
          0%
          '},postRender:function(){var a=this;return a._super(),a.value(a.settings.value),a},bindStates:function(){function a(a){a=b.settings.filter(a),b.getEl().lastChild.innerHTML=a+"%",b.getEl().firstChild.firstChild.style.width=a+"%"}var b=this;return b.state.on("change:value",function(b){a(b.value)}),a(b.state.get("value")),b._super()}})}),g("1t",["o","1s","1x","2u"],function(a,b,c,d){var e=function(a,b){a.getEl().lastChild.textContent=b+(a.progressBar?" "+a.progressBar.value()+"%":"")};return a.extend({Mixins:[b],Defaults:{classes:"widget notification"},init:function(a){var b=this;b._super(a),b.maxWidth=a.maxWidth,a.text&&b.text(a.text),a.icon&&(b.icon=a.icon),a.color&&(b.color=a.color),a.type&&b.classes.add("notification-"+a.type),a.timeout&&(a.timeout<0||a.timeout>0)&&!a.closeButton?b.closeButton=!1:(b.classes.add("has-close"),b.closeButton=!0),a.progressBar&&(b.progressBar=new c),b.on("click",function(a){a.target.className.indexOf(b.classPrefix+"close")!=-1&&b.close()})},renderHtml:function(){var a=this,b=a.classPrefix,c="",d="",e="",f="";return a.icon&&(c=''),f=' style="max-width: '+a.maxWidth+"px;"+(a.color?"background-color: "+a.color+';"':'"'),a.closeButton&&(d=''),a.progressBar&&(e=a.progressBar.renderHtml()),''},postRender:function(){var a=this;return d.setTimeout(function(){a.$el.addClass(a.classPrefix+"in"),e(a,a.state.get("text"))},100),a._super()},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl().firstChild.innerHTML=b.value,e(a,b.value)}),a.progressBar&&(a.progressBar.bindStates(),a.progressBar.state.on("change:value",function(b){e(a,a.state.get("text"))})),a._super()},close:function(){var a=this;return a.fire("close").isDefaultPrevented()||a.remove(),a},repaint:function(){var a,b,c=this;a=c.getEl().style,b=c._layoutRect,a.left=b.x+"px",a.top=b.y+"px",a.zIndex=65534}})}),g("9",["2l","2m","c","2n","1t"],function(a,b,c,d,e){return function(f){var g=function(a){return a.inline?a.getElement():a.getContentAreaContainer()},h=function(){var a=g(f);return d.getSize(a).width},i=function(b){a.each(b,function(a){a.moveTo(0,0)})},j=function(b){if(b.length>0){var c=b.slice(0,1)[0],d=g(f);c.moveRel(d,"tc-tc"),a.each(b,function(a,c){c>0&&a.moveRel(b[c-1].getEl(),"bc-tc")})}},k=function(a){i(a),j(a)},l=function(a,d){var f=c.extend(a,{maxWidth:h()}),g=new e(f);return g.args=f,f.timeout>0&&(g.timer=b(function(){g.close(),d()},f.timeout)),g.on("close",function(){d()}),g.renderTo(),g},m=function(a){a.close()},n=function(a){return a.args};return{open:l,close:m,reposition:k,getArgs:n}}}),g("2e",["12","2m","1","2o","14","2u","2r","2n","p","w","1u"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";function l(b){var c,f="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0",g=d("meta[name=viewport]")[0];e.overrideViewPort!==!1&&(g||(g=a.createElement("meta"),g.setAttribute("name","viewport"),a.getElementsByTagName("head")[0].appendChild(g)),c=g.getAttribute("content"),c&&"undefined"!=typeof q&&(q=c),g.setAttribute("content",b?f:q))}function m(b,c){n()&&c===!1&&d([a.documentElement,a.body]).removeClass(b+"fullscreen")}function n(){for(var a=0;aa.w&&(c=a.x-Math.max(0,b/2),e.layoutRect({w:b,x:c}),d=!0)),f&&(f.layoutRect({w:e.layoutRect().innerW}).recalc(),b=f.layoutRect().minW+a.deltaW,b>a.w&&(c=a.x-Math.max(0,b-a.w),e.layoutRect({w:b,x:c}),d=!0)),d&&e.recalc()},initLayoutRect:function(){var a,b=this,c=b._super(),d=0;if(b.settings.title&&!b._fullscreen){a=b.getEl("head");var e=h.getSize(a);c.headerW=e.width,c.headerH=e.height,d+=c.headerH}b.statusbar&&(d+=b.statusbar.layoutRect().h),c.deltaH+=d,c.minH+=d,c.h+=d;var f=h.getWindowSize();return c.x=b.settings.x||Math.max(0,f.w/2-c.w/2),c.y=b.settings.y||Math.max(0,f.h/2-c.h/2),c},renderHtml:function(){var a=this,b=a._layout,c=a._id,d=a.classPrefix,e=a.settings,f="",g="",h=e.html;return a.preRender(),b.preRender(a),e.title&&(f='
          '+a.encode(e.title)+'
          '),e.url&&(h=''),"undefined"==typeof h&&(h=b.renderHtml(a)),a.statusbar&&(g=a.statusbar.renderHtml()),'
          '+f+'
          '+h+"
          "+g+"
          "},fullscreen:function(b){var e,i,j=this,k=a.documentElement,l=j.classPrefix;if(b!=j._fullscreen)if(d(c).on("resize",function(){var a;if(j._fullscreen)if(e)j._timer||(j._timer=f.setTimeout(function(){var a=h.getWindowSize();j.moveTo(0,0).resizeTo(a.w,a.h),j._timer=0},50));else{a=(new Date).getTime();var b=h.getWindowSize();j.moveTo(0,0).resizeTo(b.w,b.h),(new Date).getTime()-a>50&&(e=!0)}}),i=j.layoutRect(),j._fullscreen=b,b){j._initial={x:i.x,y:i.y,w:i.w,h:i.h},j.borderBox=g.parseBox("0"), +j.getEl("head").style.display="none",i.deltaH-=i.headerH+2,d([k,a.body]).addClass(l+"fullscreen"),j.classes.add("fullscreen");var m=h.getWindowSize();j.moveTo(0,0).resizeTo(m.w,m.h)}else j.borderBox=g.parseBox(j.settings.border),j.getEl("head").style.display="",i.deltaH+=i.headerH,d([k,a.body]).removeClass(l+"fullscreen"),j.classes.remove("fullscreen"),j.moveTo(j._initial.x,j._initial.y).resizeTo(j._initial.w,j._initial.h);return j.reflow()},postRender:function(){var a,c=this;b(function(){c.classes.add("in"),c.fire("open")},0),c._super(),c.statusbar&&c.statusbar.postRender(),c.focus(),this.dragHelper=new i(c._id+"-dragh",{start:function(){a={x:c.layoutRect().x,y:c.layoutRect().y}},drag:function(b){c.moveTo(a.x+b.deltaX,a.y+b.deltaY)}}),c.on("submit",function(a){a.isDefaultPrevented()||c.close()}),p.push(c),l(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var a,b=this;for(b.dragHelper.destroy(),b._super(),b.statusbar&&this.statusbar.remove(),m(b.classPrefix,!1),a=p.length;a--;)p[a]===b&&p.splice(a,1);l(p.length>0)},getContentWindow:function(){var a=this.getEl().getElementsByTagName("iframe")[0];return a?a.contentWindow:null}});return o(),r}),g("1r",["12","2e"],function(a,b){"use strict";var c=b.extend({init:function(a){a={border:1,padding:20,layout:"flex",pack:"center",align:"center",containerCls:"panel",autoScroll:!0,buttons:{type:"button",text:"Ok",action:"ok"},items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200}},this._super(a)},Statics:{OK:1,OK_CANCEL:2,YES_NO:3,YES_NO_CANCEL:4,msgBox:function(d){function e(a,b,c){return{type:"button",text:a,subtype:c?"primary":"",onClick:function(a){a.control.parents()[1].close(),g(b)}}}var f,g=d.callback||function(){};switch(d.buttons){case c.OK_CANCEL:f=[e("Ok",!0,!0),e("Cancel",!1)];break;case c.YES_NO:case c.YES_NO_CANCEL:f=[e("Yes",1,!0),e("No",0)],d.buttons==c.YES_NO_CANCEL&&f.push(e("Cancel",-1));break;default:f=[e("Ok",!0,!0)]}return new b({padding:20,x:d.x,y:d.y,minWidth:300,minHeight:100,layout:"flex",pack:"center",align:"center",buttons:f,title:d.title,role:"alertdialog",items:{type:"label",multiline:!0,maxWidth:500,maxHeight:200,text:d.text},onPostRender:function(){this.aria("describedby",this.items()[0]._id)},onClose:d.onClose,onCancel:function(){g(!1)}}).renderTo(a.body).reflow()},alert:function(a,b){return"string"==typeof a&&(a={text:a}),a.callback=b,c.msgBox(a)},confirm:function(a,b){return"string"==typeof a&&(a={text:a}),a.callback=b,a.buttons=c.OK_CANCEL,c.msgBox(a)}}});return c}),g("a",["2e","1r"],function(a,b){return function(c){var d=function(b,c,d){var e;return b.title=b.title||" ",b.url=b.url||b.file,b.url&&(b.width=parseInt(b.width||320,10),b.height=parseInt(b.height||240,10)),b.body&&(b.items={defaults:b.defaults,type:b.bodyType||"form",items:b.body,data:b.data,callbacks:b.commands}),b.url||b.buttons||(b.buttons=[{text:"Ok",subtype:"primary",onclick:function(){e.find("form")[0].submit()}},{text:"Cancel",onclick:function(){e.close()}}]),e=new a(b),e.on("close",function(){d(e)}),b.data&&e.on("postRender",function(){this.find("*").each(function(a){var c=a.name();c in b.data&&a.value(b.data[c])})}),e.features=b||{},e.params=c||{},e=e.renderTo().reflow()},e=function(a,c,d){var e;return e=b.alert(a,function(){c()}),e.on("close",function(){d(e)}),e},f=function(a,c,d){var e;return e=b.confirm(a,function(a){c(a)}),e.on("close",function(){d(e)}),e},g=function(a){a.close()},h=function(a){return a.params},i=function(a,b){a.params=b};return{open:d,alert:e,confirm:f,close:g,getParams:h,setParams:i}}}),g("3",["7","8","9","a"],function(a,b,c,d){var e=function(e){var f=function(b){return a.renderUI(e,this,b)},g=function(a,c){return b.resizeTo(e,a,c)},h=function(a,c){return b.resizeBy(e,a,c)},i=function(){return c(e)},j=function(){return d(e)};return{renderUI:f,resizeTo:g,resizeBy:h,getNotificationManagerImpl:i,getWindowManagerImpl:j}};return{get:e}}),g("1l",["2p","c"],function(a,b){"use strict";return a.extend({Defaults:{firstControlClass:"first",lastControlClass:"last"},init:function(a){this.settings=b.extend({},this.Defaults,a)},preRender:function(a){a.bodyClasses.add(this.settings.containerClass)},applyClasses:function(a){var b,c,d,e,f=this,g=f.settings;b=g.firstControlClass,c=g.lastControlClass,a.each(function(a){a.classes.remove(b).remove(c).add(g.controlClass),a.visible()&&(d||(d=a),e=a)}),d&&d.classes.add(b),e&&e.classes.add(c)},renderHtml:function(a){var b=this,c="";return b.applyClasses(a.items()),a.items().each(function(a){c+=a.renderHtml()}),c},recalc:function(){},postRender:function(){},isNative:function(){return!1}})}),g("d",["1l"],function(a){"use strict";return a.extend({Defaults:{containerClass:"abs-layout",controlClass:"abs-layout-item"},recalc:function(a){a.items().filter(":visible").each(function(a){var b=a.settings;a.layoutRect({x:b.x,y:b.y,w:b.w,h:b.h}),a.recalc&&a.recalc()})},renderHtml:function(a){return'
          '+this._super(a)}})}),g("f",["12","1","15"],function(a,b,c){"use strict";return c.extend({Defaults:{classes:"widget btn",role:"button"},init:function(a){var b,c=this;c._super(a),a=c.settings,b=c.settings.size,c.on("click mousedown",function(a){a.preventDefault()}),c.on("touchstart",function(a){c.fire("click",a),a.preventDefault()}),a.subtype&&c.classes.add(a.subtype),b&&c.classes.add("btn-"+b),a.icon&&c.icon(a.icon)},icon:function(a){return arguments.length?(this.state.set("icon",a),this):this.state.get("icon")},repaint:function(){var a,b=this.getEl().firstChild;b&&(a=b.style,a.width=a.height="100%"),this._super()},renderHtml:function(){var a,c,d=this,e=d._id,f=d.classPrefix,g=d.state.get("icon"),h=d.state.get("text"),i="",j=d.settings;return a=j.image,a?(g="none","string"!=typeof a&&(a=b.getSelection?a[0]:a[1]),a=" style=\"background-image: url('"+a+"')\""):a="",h&&(d.classes.add("btn-has-text"),i=''+d.encode(h)+""),g=g?f+"ico "+f+"i-"+g:"",c="boolean"==typeof j.active?' aria-pressed="'+j.active+'"':"",'
          "},bindStates:function(){function b(a){var b=d("span."+e,c.getEl());a?(b[0]||(d("button:first",c.getEl()).append(''),b=d("span."+e,c.getEl())),b.html(c.encode(a))):b.remove(),c.classes.toggle("btn-has-text",!!a)}var c=this,d=c.$,e=c.classPrefix+"txt";return c.state.on("change:text",function(a){b(a.value)}),c.state.on("change:icon",function(d){var e=d.value,f=c.classPrefix;c.settings.icon=e,e=e?f+"ico "+f+"i-"+c.settings.icon:"";var g=c.getEl().firstChild,h=g.getElementsByTagName("i")[0];e?(h&&h==g.firstChild||(h=a.createElement("i"),g.insertBefore(h,g.firstChild)),h.className=e):h&&g.removeChild(h),b(c.state.get("text"))}),c._super()}})}),h("2v",RegExp),g("e",["f","c","2n","2o","2v"],function(a,b,c,d,e){return a.extend({init:function(a){var c=this;a=b.extend({text:"Browse...",multiple:!1,accept:null},a),c._super(a),c.classes.add("browsebutton"),a.multiple&&c.classes.add("multiple")},postRender:function(){var a=this,b=c.create("input",{type:"file",id:a._id+"-browse",accept:a.settings.accept});a._super(),d(b).on("change",function(b){var c=b.target.files;a.value=function(){return c.length?a.settings.multiple?c:c[0]:null},b.preventDefault(),c.length&&a.fire("change",b)}),d(b).on("click",function(a){a.stopPropagation()}),d(a.getEl("button")).on("click",function(a){a.stopPropagation(),b.click()}),a.getEl().appendChild(b)},remove:function(){d(this.getEl("button")).off(),d(this.getEl("input")).off(),this._super()}})}),g("g",["n"],function(a){"use strict";return a.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var a=this,b=a._layout;return a.classes.add("btn-group"),a.preRender(),b.preRender(a),'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),g("h",["12","15"],function(a,b){"use strict";return b.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(a){var b=this;b._super(a),b.on("click mousedown",function(a){a.preventDefault()}),b.on("click",function(a){a.preventDefault(),b.disabled()||b.checked(!b.checked())}),b.checked(b.settings.checked)},checked:function(a){return arguments.length?(this.state.set("checked",a),this):this.state.get("checked")},value:function(a){return arguments.length?this.checked(a):this.checked()},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix;return'
          '+a.encode(a.state.get("text"))+"
          "},bindStates:function(){function b(a){c.classes.toggle("checked",a),c.aria("checked",a)}var c=this;return c.state.on("change:text",function(a){c.getEl("al").firstChild.data=c.translate(a.value)}),c.state.on("change:checked change:value",function(a){c.fire("change"),b(a.value)}),c.state.on("change:icon",function(b){var d=b.value,e=c.classPrefix;if("undefined"==typeof d)return c.settings.icon;c.settings.icon=d,d=d?e+"ico "+e+"i-"+c.settings.icon:"";var f=c.getEl().firstChild,g=f.getElementsByTagName("i")[0];d?(g&&g==f.firstChild||(g=a.createElement("i"),f.insertBefore(g,f.firstChild)),g.className=d):g&&f.removeChild(g)}),c.state.get("checked")&&b(!0),c._super()}})}),g("2w",["6"],function(a){return a("tinymce.util.VK")}),g("m",["12","2o","b","c","2w","2n","15"],function(a,b,c,d,e,f,g){"use strict";return g.extend({init:function(a){var c=this;c._super(a),a=c.settings,c.classes.add("combobox"),c.subinput=!0,c.ariaTarget="inp",a.menu=a.menu||a.values,a.menu&&(a.icon="caret"),c.on("click",function(d){var e=d.target,f=c.getEl();if(b.contains(f,e)||e==f)for(;e&&e!=f;)e.id&&e.id.indexOf("-open")!=-1&&(c.fire("action"),a.menu&&(c.showMenu(),d.aria&&c.menu.items()[0].focus())),e=e.parentNode}),c.on("keydown",function(a){var b;13==a.keyCode&&"INPUT"===a.target.nodeName&&(a.preventDefault(),c.parents().reverse().each(function(a){if(a.toJSON)return b=a,!1}),c.fire("submit",{data:b.toJSON()}))}),c.on("keyup",function(a){if("INPUT"==a.target.nodeName){var b=c.state.get("value"),d=a.target.value;d!==b&&(c.state.set("value",d),c.fire("autocomplete",a))}}),c.on("mouseover",function(a){var b=c.tooltip().moveTo(-65535);if(c.statusLevel()&&a.target.className.indexOf(c.classPrefix+"status")!==-1){var d=c.statusMessage()||"Ok",e=b.text(d).show().testMoveRel(a.target,["bc-tc","bc-tl","bc-tr"]);b.classes.toggle("tooltip-n","bc-tc"==e),b.classes.toggle("tooltip-nw","bc-tl"==e),b.classes.toggle("tooltip-ne","bc-tr"==e),b.moveRel(a.target,e)}})},statusLevel:function(a){return arguments.length>0&&this.state.set("statusLevel",a),this.state.get("statusLevel")},statusMessage:function(a){return arguments.length>0&&this.state.set("statusMessage",a),this.state.get("statusMessage")},showMenu:function(){var a,b=this,d=b.settings;b.menu||(a=d.menu||[],a.length?a={type:"menu",items:a}:a.type=a.type||"menu",b.menu=c.create(a).parent(b).renderTo(b.getContainerElm()),b.fire("createmenu"),b.menu.reflow(),b.menu.on("cancel",function(a){a.control===b.menu&&b.focus()}),b.menu.on("show hide",function(a){a.control.items().each(function(a){a.active(a.value()==b.value())})}).fire("show"),b.menu.on("select",function(a){b.value(a.control.value())}),b.on("focusin",function(a){"INPUT"==a.target.tagName.toUpperCase()&&b.menu.hide()}),b.aria("expanded",!0)),b.menu.show(),b.menu.layoutRect({w:b.layoutRect().w}),b.menu.moveRel(b.getEl(),b.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},focus:function(){this.getEl("inp").focus()},repaint:function(){var c,d,e=this,g=e.getEl(),h=e.getEl("open"),i=e.layoutRect(),j=0,k=g.firstChild;e.statusLevel()&&"none"!==e.statusLevel()&&(j=parseInt(f.getRuntimeStyle(k,"padding-right"),10)-parseInt(f.getRuntimeStyle(k,"padding-left"),10)),c=h?i.w-f.getSize(h).width-10:i.w-10;var l=a;return l.all&&(!l.documentMode||l.documentMode<=8)&&(d=e.layoutRect().h-2+"px"),b(k).css({width:c-j,lineHeight:d}),e._super(),e},postRender:function(){var a=this;return b(this.getEl("inp")).on("change",function(b){a.state.set("value",b.target.value),a.fire("change",b)}),a._super()},renderHtml:function(){var a,b,c=this,d=c._id,e=c.settings,f=c.classPrefix,g=c.state.get("value")||"",h="",i="",j="";return"spellcheck"in e&&(i+=' spellcheck="'+e.spellcheck+'"'),e.maxLength&&(i+=' maxlength="'+e.maxLength+'"'),e.size&&(i+=' size="'+e.size+'"'),e.subtype&&(i+=' type="'+e.subtype+'"'),j='',c.disabled()&&(i+=' disabled="disabled"'),a=e.icon,a&&"caret"!=a&&(a=f+"ico "+f+"i-"+e.icon),b=c.state.get("text"),(a||b)&&(h='
          ",c.classes.add("has-open")),'
          '+j+h+"
          "},value:function(a){return arguments.length?(this.state.set("value",a),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value),this.state.get("value"))},showAutoComplete:function(a,b){var e=this;if(0===a.length)return void e.hideMenu();var f=function(a,b){return function(){e.fire("selectitem",{title:b,value:a})}};e.menu?e.menu.items().remove():e.menu=c.create({type:"menu",classes:"combobox-menu",layout:"flow"}).parent(e).renderTo(),d.each(a,function(a){e.menu.add({text:a.title,url:a.previewUrl,match:b,classes:"menu-item-ellipsis",onclick:f(a.value,a.title)})}),e.menu.renderNew(),e.hideMenu(),e.menu.on("cancel",function(a){a.control.parent()===e.menu&&(a.stopPropagation(),e.focus(),e.hideMenu())}),e.menu.on("select",function(){e.focus()});var g=e.layoutRect().w;e.menu.layoutRect({w:g,minW:0,maxW:g}),e.menu.reflow(),e.menu.show(),e.menu.moveRel(e.getEl(),e.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])},hideMenu:function(){this.menu&&this.menu.hide()},bindStates:function(){var a=this;a.state.on("change:value",function(b){a.getEl("inp").value!=b.value&&(a.getEl("inp").value=b.value)}),a.state.on("change:disabled",function(b){a.getEl("inp").disabled=b.value}),a.state.on("change:statusLevel",function(b){var c=a.getEl("status"),d=a.classPrefix,e=b.value;f.css(c,"display","none"===e?"none":""),f.toggleClass(c,d+"i-checkmark","ok"===e),f.toggleClass(c,d+"i-warning","warn"===e),f.toggleClass(c,d+"i-error","error"===e),a.classes.toggle("has-status","none"!==e),a.repaint()}),f.on(a.getEl("status"),"mouseleave",function(){a.tooltip().hide()}),a.on("cancel",function(b){a.menu&&a.menu.visible()&&(b.stopPropagation(),a.hideMenu())});var b=function(a,b){b&&b.items().length>0&&b.items().eq(a)[0].focus()};return a.on("keydown",function(c){var d=c.keyCode;"INPUT"===c.target.nodeName&&(d===e.DOWN?(c.preventDefault(),a.fire("autocomplete"),b(0,a.menu)):d===e.UP&&(c.preventDefault(),b(-1,a.menu)))}),a._super()},remove:function(){b(this.getEl("inp")).off(),this.menu&&this.menu.remove(),this._super()}})}),g("j",["m"],function(a){"use strict";return a.extend({init:function(a){var b=this;a.spellcheck=!1,a.onaction&&(a.icon="none"),b._super(a),b.classes.add("colorbox"),b.on("change keyup postrender",function(){b.repaintColor(b.value())})},repaintColor:function(a){var b=this.getEl("open"),c=b?b.getElementsByTagName("i")[0]:null;if(c)try{c.style.background=a}catch(a){}},bindStates:function(){var a=this;return a.state.on("change:value",function(b){a.state.get("rendered")&&a.repaintColor(b.value)}),a._super()}})}),g("1v",["f","w"],function(a,b){"use strict";return a.extend({showPanel:function(){var a=this,c=a.settings;if(a.classes.add("opened"),a.panel)a.panel.show();else{var d=c.panel;d.type&&(d={layout:"grid",items:d}),d.role=d.role||"dialog",d.popover=!0,d.autohide=!0,d.ariaRoot=!0,a.panel=new b(d).on("hide",function(){a.classes.remove("opened")}).on("cancel",function(b){b.stopPropagation(),a.focus(),a.hidePanel()}).parent(a).renderTo(a.getContainerElm()),a.panel.fire("show"),a.panel.reflow()}var e=a.panel.testMoveRel(a.getEl(),c.popoverAlign||(a.isRtl()?["bc-tc","bc-tl","bc-tr"]:["bc-tc","bc-tr","bc-tl"]));a.panel.classes.toggle("start","bc-tl"===e),a.panel.classes.toggle("end","bc-tr"===e),a.panel.moveRel(a.getEl(),e)},hidePanel:function(){var a=this;a.panel&&a.panel.hide()},postRender:function(){var a=this;return a.aria("haspopup",!0),a.on("click",function(b){b.control===a&&(a.panel&&a.panel.visible()?a.hidePanel():(a.showPanel(),a.panel.focus(!!b.aria)))}),a._super()},remove:function(){return this.panel&&(this.panel.remove(),this.panel=null),this._super()}})}),g("k",["1v","2j"],function(a,b){"use strict";var c=b.DOM;return a.extend({init:function(a){this._super(a),this.classes.add("splitbtn"),this.classes.add("colorbutton")},color:function(a){return a?(this._color=a,this.getEl("preview").style.backgroundColor=a,this):this._color},resetColor:function(){return this._color=null,this.getEl("preview").style.backgroundColor=null,this},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix,d=a.state.get("text"),e=a.settings.icon?c+"ico "+c+"i-"+a.settings.icon:"",f=a.settings.image?" style=\"background-image: url('"+a.settings.image+"')\"":"",g="";return d&&(a.classes.add("btn-has-text"),g=''+a.encode(d)+""),'
          '},postRender:function(){var a=this,b=a.settings.onclick;return a.on("click",function(d){d.aria&&"down"===d.aria.key||d.control!=a||c.getParent(d.target,"."+a.classPrefix+"open")||(d.stopImmediatePropagation(),b.call(a,d))}),delete a.settings.onclick,a._super()}})}),g("2x",["6"],function(a){return a("tinymce.util.Color")}),g("l",["15","p","2n","2x"],function(a,b,c,d){"use strict";return a.extend({Defaults:{classes:"widget colorpicker"},init:function(a){this._super(a)},postRender:function(){function a(a,b){var d,e,f=c.getPos(a);return d=b.pageX-f.x,e=b.pageY-f.y,d=Math.max(0,Math.min(d/a.clientWidth,1)),e=Math.max(0,Math.min(e/a.clientHeight,1)),{x:d,y:e}}function e(a,b){var e=(360-a.h)/360;c.css(j,{top:100*e+"%"}),b||c.css(l,{left:a.s+"%",top:100-a.v+"%"}),k.style.background=new d({s:100,v:100,h:a.h}).toHex(),m.color().parse({s:a.s,v:a.v,h:a.h})}function f(b){var c;c=a(k,b),h.s=100*c.x,h.v=100*(1-c.y),e(h),m.fire("change")}function g(b){var c;c=a(i,b),h=n.toHsv(),h.h=360*(1-c.y),e(h,!0),m.fire("change")}var h,i,j,k,l,m=this,n=m.color();i=m.getEl("h"),j=m.getEl("hp"),k=m.getEl("sv"),l=m.getEl("svp"),m._repaint=function(){h=n.toHsv(),e(h)},m._super(),m._svdraghelper=new b(m._id+"-sv",{start:f,drag:f}),m._hdraghelper=new b(m._id+"-h",{start:g,drag:g}),m._repaint()},rgb:function(){return this.color().toRgb()},value:function(a){var b=this;return arguments.length?(b.color().parse(a),void(b._rendered&&b._repaint())):b.color().toHex()},color:function(){return this._color||(this._color=new d),this._color},renderHtml:function(){function a(){var a,b,c,d,g="";for(c="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",d=f.split(","),a=0,b=d.length-1;a';return g}var b,c=this,d=c._id,e=c.classPrefix,f="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000",g="background: -ms-linear-gradient(top,"+f+");background: linear-gradient(to bottom,"+f+");";return b='
          '+a()+'
          ','
          '+b+"
          "}})}),g("q",["15","c","2n","2v"],function(a,b,c,d){return a.extend({init:function(a){var c=this;a=b.extend({height:100,text:"Drop an image here",multiple:!1,accept:null},a),c._super(a),c.classes.add("dropzone"),a.multiple&&c.classes.add("multiple")},renderHtml:function(){var a,b,d=this,e=d.settings;return a={id:d._id,hidefocus:"1"},b=c.create("div",a,""+this.translate(e.text)+""),e.height&&c.css(b,"height",e.height+"px"),e.width&&c.css(b,"width",e.width+"px"),b.className=d.classes,b.outerHTML},postRender:function(){var a=this,c=function(b){b.preventDefault(),a.classes.toggle("dragenter"),a.getEl().className=a.classes},e=function(c){var e=a.settings.accept;if("string"!=typeof e)return c;var f=new d("("+e.split(/\s*,\s*/).join("|")+")$","i");return b.grep(c,function(a){return f.test(a.name)})};a._super(),a.$el.on("dragover",function(a){a.preventDefault()}),a.$el.on("dragenter",c),a.$el.on("dragleave",c),a.$el.on("drop",function(b){if(b.preventDefault(),!a.state.get("disabled")){var c=e(b.dataTransfer.files);a.value=function(){return c.length?a.settings.multiple?c:c[0]:null},c.length&&a.fire("change",b)}})},remove:function(){this.$el.off(),this._super()}})}),g("1w",["15"],function(a){"use strict";return a.extend({init:function(a){var b=this;a.delimiter||(a.delimiter="\xbb"),b._super(a),b.classes.add("path"),b.canFocus=!0,b.on("click",function(a){var c,d=a.target;(c=d.getAttribute("data-index"))&&b.fire("select",{value:b.row()[c],index:c})}),b.row(b.settings.row)},focus:function(){var a=this;return a.getEl().firstChild.focus(),a},row:function(a){return arguments.length?(this.state.set("row",a),this):this.state.get("row")},renderHtml:function(){var a=this;return'
          '+a._getDataPathHtml(a.state.get("row"))+"
          "},bindStates:function(){var a=this;return a.state.on("change:row",function(b){a.innerHtml(a._getDataPathHtml(b.value))}),a._super()},_getDataPathHtml:function(a){var b,c,d=this,e=a||[],f="",g=d.classPrefix;for(b=0,c=e.length;b0?'":"")+'
          '+e[b].name+"
          ";return f||(f='
          \xa0
          '),f}})}),g("r",["1w"],function(a){return a.extend({postRender:function(){function a(a){if(1===a.nodeType){if("BR"==a.nodeName||a.getAttribute("data-mce-bogus"))return!0;if("bookmark"===a.getAttribute("data-mce-type"))return!0}return!1}var b=this,c=b.settings.editor;return c.settings.elementpath!==!1&&(b.on("select",function(a){c.focus(),c.selection.select(this.row()[a.index].element),c.nodeChanged()}),c.on("nodeChange",function(d){for(var e=[],f=d.parents,g=f.length;g--;)if(1==f[g].nodeType&&!a(f[g])){var h=c.fire("ResolveName",{name:f[g].nodeName.toLowerCase(),target:f[g]});if(h.isDefaultPrevented()||e.push({name:h.name,element:f[g]}),h.isPropagationStopped())break}b.row(e)})),b._super()}})}),g("1f",["n"],function(a){"use strict";return a.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var a=this,b=a._layout,c=a.classPrefix;return a.classes.add("formitem"),b.preRender(a),'
          '+(a.settings.title?'
          '+a.settings.title+"
          ":"")+'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),g("y",["n","1f","c"],function(a,b,c){"use strict";return a.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:15,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var a=this,d=a.items();a.settings.formItemDefaults||(a.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),d.each(function(d){var e,f=d.settings.label;f&&(e=new b(c.extend({items:{type:"label",id:d._id+"-l",text:f,flex:0,forId:d._id,disabled:d.disabled()}},a.settings.formItemDefaults)),e.type="formitem",d.aria("labelledby",d._id+"-l"),"undefined"==typeof d.settings.flex&&(d.settings.flex=1),a.replace(d,e),e.add(d))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){var a=this;a._super(),a.fromJSON(a.settings.data)},bindStates:function(){function a(){var a,c,d,e=0,f=[];if(b.settings.labelGapCalc!==!1)for(d="children"==b.settings.labelGapCalc?b.find("formitem"):b.items(),d.filter("formitem").each(function(a){var b=a.items()[0],c=b.getEl().clientWidth;e=c>e?c:e,f.push(b)}),c=b.settings.labelGap||0,a=f.length;a--;)f[a].settings.minWidth=e+c}var b=this;b._super(),b.on("show",a),a()}})}),g("s",["y"],function(a){"use strict";return a.extend({Defaults:{containerCls:"fieldset",layout:"flex",direction:"column",align:"stretch",flex:1,padding:"25 15 5 15",labelGap:30,spacing:10,border:1},renderHtml:function(){var a=this,b=a._layout,c=a.classPrefix;return a.preRender(),b.preRender(a),'
          '+(a.settings.title?''+a.settings.title+"":"")+'
          '+(a.settings.html||"")+b.renderHtml(a)+"
          "}})}),h("3s",Date),h("3t",Math),g("3i",["3s","3t","3h"],function(a,b,c){var d=0,e=function(e){var f=new a,g=f.getTime(),h=b.floor(1e9*b.random());return d++,e+"_"+h+d+c(g)};return{generate:e}}),g("31",[],function(){return"undefined"==typeof console&&(console={log:function(){}}),console}),g("10",["z","2z","31","12"],function(a,b,c,d){var e=function(a,b){var e=b||d,f=e.createElement("div");if(f.innerHTML=a,!f.hasChildNodes()||f.childNodes.length>1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("3v",[],function(){var a=function(a){var b,c=!1;return function(){return c||(c=!0,b=a.apply(null,arguments)),b}};return{cached:a}}),g("3n",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("3o",["3n"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("3l",["3v","10","3o","12"],function(a,b,c,d){var e=function(a){var b=c.isText(a)?a.dom().parentNode:a.dom();return void 0!==b&&null!==b&&b.ownerDocument.body.contains(b)},f=a.cached(function(){return g(b.fromDom(d))}),g=function(a){var c=a.dom().body;if(null===c||void 0===c)throw"Body is not available yet";return b.fromDom(c)};return{body:f,getBody:g,inBody:e}}),g("3k",["2y","3h"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("4a",["2l","z","2y","2z"],function(a,b,c,d){return function(){var e=arguments;return function(){for(var f=new c(arguments.length),g=0;g0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("42",["4a","4b"],function(a,b){return{immutable:a,immutableBag:b}}),g("43",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("4c",[],function(){return"undefined"!=typeof window?window:Function("return this;")()}),g("44",["4c"],function(a){var b=function(b,c){for(var d=void 0!==c?c:a,e=0;e0&&b0},C=function(b){var c=A(b);return a.filter(y(c).concat(z(c)),B)};return{find:C}}),g("t",["2l","z","1","30","13","m","c"],function(a,b,c,d,e,f,g){"use strict";var h=function(){return c.tinymce?c.tinymce.activeEditor:e.activeEditor},i={},j=5,k=function(){i={}},l=function(a){return{title:a.title,value:{title:{raw:a.title},url:a.url,attach:a.attach}}},m=function(a){return g.map(a,l)},n=function(a,c){return{title:a,value:{title:a,url:c,attach:b.noop}}},o=function(b,c){var d=a.exists(c,function(a){return a.url===b});return!d},p=function(a,b,c){var d=b in a?a[b]:c;return d===!1?null:d},q=function(c,d,e,f){var h={title:"-"},j=function(c){var f=c.hasOwnProperty(e)?c[e]:[],h=a.filter(f,function(a){return o(a,d)});return g.map(h,function(a){return{title:a,value:{title:a,url:a,attach:b.noop}}})},k=function(b){var c=a.filter(d,function(a){return a.type===b});return m(c)},l=function(){var a=k("anchor"),b=p(f,"anchor_top","#top"),c=p(f,"anchor_bottom","#bottom");return null!==b&&a.unshift(n("",b)),null!==c&&a.push(n("",c)),a},q=function(b){return a.foldl(b,function(a,b){var c=0===a.length||0===b.length;return c?a.concat(b):a.concat(h,b)},[])};return f.typeahead_urls===!1?[]:"file"===e?q([s(c,j(i)),s(c,k("header")),s(c,l())]):s(c,j(i))},r=function(b,c){var d=i[c];/^https?/.test(b)&&(d?a.indexOf(d,b)===-1&&(i[c]=d.slice(0,j).concat(b)):i[c]=[b])},s=function(a,b){var c=a.toLowerCase(),d=g.grep(b,function(a){return a.title.toLowerCase().indexOf(c)!==-1});return 1===d.length&&d[0].title===a?[]:d},t=function(a){var b=a.title;return b.raw?b.raw:b},u=function(a,b,c,e){var f=function(f){var g=d.find(c),h=q(f,g,e,b);a.showAutoComplete(h,f)};a.on("autocomplete",function(){f(a.value())}),a.on("selectitem",function(b){var c=b.value;a.value(c.url);var d=t(c);"image"===e?a.fire("change",{meta:{alt:d,attach:c.attach}}):a.fire("change",{meta:{text:d,attach:c.attach}}),a.focus()}),a.on("click",function(b){0===a.value().length&&"INPUT"===b.target.nodeName&&f("")}),a.on("PostRender",function(){a.getRoot().on("submit",function(b){b.isDefaultPrevented()||r(a.value(),e)})})},v=function(a){var b=a.status,c=a.message;return"valid"===b?{status:"ok",message:c}:"unknown"===b?{status:"warn",message:c}:"invalid"===b?{status:"warn",message:c}:{status:"none",message:""}},w=function(a,b,c){var d=b.filepicker_validator_handler;if(d){var e=function(b){return 0===b.length?void a.statusLevel("none"):void d({url:b,type:c},function(b){var c=v(b);a.statusMessage(c.message),a.statusLevel(c.status)})};a.state.on("change:value",function(a){e(a.value)})}};return f.extend({Statics:{clearHistory:k},init:function(a){var b,d,e,f=this,i=h(),j=i.settings,k=a.filetype;a.spellcheck=!1,e=j.file_picker_types||j.file_browser_callback_types,e&&(e=g.makeMap(e,/[, ]/)),e&&!e[k]||(d=j.file_picker_callback,!d||e&&!e[k]?(d=j.file_browser_callback,!d||e&&!e[k]||(b=function(){d(f.getEl("inp").id,f.value(),k,c)})):b=function(){var a=f.fire("beforecall").meta;a=g.extend({filetype:k},a),d.call(i,function(a,b){f.value(a).fire("change",{meta:b})},f.value(),a)}),b&&(a.icon="browse",a.onaction=b),f._super(a),u(f,j,i.getBody(),k),w(f,j,k)}})}),g("u",["d"],function(a){"use strict";return a.extend({recalc:function(a){var b=a.layoutRect(),c=a.paddingBox;a.items().filter(":visible").each(function(a){a.layoutRect({x:c.left,y:c.top,w:b.innerW-c.right-c.left,h:b.innerH-c.top-c.bottom}),a.recalc&&a.recalc()})}})}),g("v",["d"],function(a){"use strict";return a.extend({recalc:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N=[],O=Math.max,P=Math.min;for(d=a.items().filter(":visible"),e=a.layoutRect(),f=a.paddingBox,g=a.settings,m=a.isRtl()?g.direction||"row-reversed":g.direction,h=g.align,i=a.isRtl()?g.pack||"end":g.pack,j=g.spacing||0,"row-reversed"!=m&&"column-reverse"!=m||(d=d.set(d.toArray().reverse()),m=m.split("-")[0]),"column"==m?(z="y",x="h",y="minH",A="maxH",C="innerH",B="top",D="deltaH",E="contentH",J="left",H="w",F="x",G="innerW",I="minW",K="right",L="deltaW",M="contentW"):(z="x",x="w",y="minW",A="maxW",C="innerW",B="left",D="deltaW",E="contentW",J="top",H="h",F="y",G="innerH",I="minH",K="bottom",L="deltaH",M="contentH"),l=e[C]-f[B]-f[B],w=k=0,b=0,c=d.length;b0&&(k+=q,o[A]&&N.push(n),o.flex=q),l-=o[y],r=f[J]+o[I]+f[K],r>w&&(w=r);if(u={},l<0?u[y]=e[y]-l+e[D]:u[y]=e[C]-l+e[D],u[I]=w+e[L],u[E]=e[C]-l,u[M]=w,u.minW=P(u.minW,e.maxW),u.minH=P(u.minH,e.maxH),u.minW=O(u.minW,e.startMinWidth),u.minH=O(u.minH,e.startMinHeight),!e.autoResize||u.minW==e.minW&&u.minH==e.minH){for(t=l/k,b=0,c=N.length;bs?(l-=o[A]-o[y],k-=o.flex,o.flex=0,o.maxFlexSize=s):o.maxFlexSize=0;for(t=l/k,v=f[B],u={},0===k&&("end"==i?v=l+f[B]:"center"==i?(v=Math.round(e[C]/2-(e[C]-l)/2)+f[B],v<0&&(v=f[B])):"justify"==i&&(v=f[B],j=Math.floor(l/(d.length-1)))),u[F]=f[J],b=0,c=d.length;b0&&(r+=o.flex*t),u[x]=r,u[z]=v,n.layoutRect(u),n.recalc&&n.recalc(),v+=r+j}else if(u.w=u.minW,u.h=u.minH,a.layoutRect(u),this.recalc(a),null===a._lastRect){var Q=a.parent();Q&&(Q._lastRect=null,Q.recalc())}}})}),g("x",["1l"],function(a){return a.extend({Defaults:{containerClass:"flow-layout",controlClass:"flow-layout-item",endClass:"break"},recalc:function(a){a.items().filter(":visible").each(function(a){a.recalc&&a.recalc()})},isNative:function(){return!0}})}),g("34",["3k","3g"],function(a,b){return function(c,d,e,f,g){return c(e,f)?b.some(e):a.isFunction(g)&&g(e)?b.none():d(e,f,g)}}),g("32",["3k","2l","z","3g","3l","3m","10","34"],function(a,b,c,d,e,f,g,h){var i=function(a){return n(e.body(),a)},j=function(b,e,f){for(var h=b.dom(),i=a.isFunction(f)?f:c.constant(!1);h.parentNode;){h=h.parentNode;var j=g.fromDom(h);if(e(j))return d.some(j);if(i(j))break}return d.none()},k=function(a,b,c){var d=function(a){return b(a)};return h(d,j,a,b,c)},l=function(a,b){var c=a.dom();return c.parentNode?m(g.fromDom(c.parentNode),function(c){return!f.eq(a,c)&&b(c)}):d.none()},m=function(a,d){var e=b.find(a.dom().childNodes,c.compose(d,g.fromDom));return e.map(g.fromDom)},n=function(a,b){var c=function(a){for(var e=0;e=0;i--)h=b.toPt(g,i),j=c(d,h,g);e.value(j?j:null),j||e.text(h)})}},e=function(b){var c="8pt 10pt 12pt 14pt 18pt 24pt 36pt",d=b.settings.fontsize_formats||c;return a.map(d.split(" "),function(a){var b=a,c=a,d=a.split("=");return d.length>1&&(b=d[0],c=d[1]),{text:b,value:c}})},f=function(a){a.addButton("fontsizeselect",function(){var b=e(a);return{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:b,fixedWidth:!0,onPostRender:d(a,b),onclick:function(b){b.control.settings.value&&a.execCommand("FontSize",!1,b.control.settings.value)}}})},g=function(a){f(a)};return{register:g}}),g("19",["c","35"],function(a,b){var c="Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre",d=function(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a},e=function(b,c,d){return function(){var e=this;b.on("nodeChange",function(f){var g=b.formatter,h=null;a.each(f.parents,function(b){if(a.each(c,function(a){if(d?g.matchNode(b,d,{value:a.value})&&(h=a.value):g.matchNode(b,a.value)&&(h=a.value),h)return!1}),h)return!1}),e.value(h)})}},f=function(c,d){return function(){var f=[];return a.each(d,function(a){f.push({text:a[0],value:a[1],textStyle:function(){return c.formatter.getCssText(a[1])}})}),{type:"listbox",text:d[0][0],values:f,fixedWidth:!0,onselect:function(a){if(a.control){var d=a.control.value();b.toggleFormat(c,d)()}},onPostRender:e(c,f)}}},g=function(c,d){return a.map(d,function(a){return{text:a[0],onclick:b.toggleFormat(c,a[1]),textStyle:function(){return c.formatter.getCssText(a[1])}}})},h=function(a){var b=d(a.settings.block_formats||c);a.addMenuItem("blockformats",{text:"Blocks",menu:g(a,b)}),a.addButton("formatselect",f(a,b))};return{register:h}}),g("1a",["c","35"],function(a,b){var c=function(b,d){var e=d.length;return a.each(d,function(a){a.menu&&(a.hidden=0===c(b,a.menu));var d=a.format;d&&(a.hidden=!b.formatter.canApply(d)),a.hidden&&e--}),e},d=function(a,b){var e=b.items().length;return b.items().each(function(b){b.menu&&b.visible(d(a,b.menu)>0),!b.menu&&b.settings.menu&&b.visible(c(a,b.settings.menu)>0);var f=b.settings.format;f&&b.visible(a.formatter.canApply(f)),b.visible()||e--}),e},e=function(c){var d=0,e=[],f=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],g=function(b){var c=[];if(b)return a.each(b,function(a){var b={text:a.title,icon:a.icon};if(a.items)b.menu=g(a.items);else{var f=a.format||"custom"+d++;a.format||(a.name=f,e.push(a)),b.format=f,b.cmd=a.cmd}c.push(b)}),c},h=function(){var a;return a=g(c.settings.style_formats_merge?c.settings.style_formats?f.concat(c.settings.style_formats):f:c.settings.style_formats||f)};return c.on("init",function(){a.each(e,function(a){c.formatter.register(a.name,a)})}),{type:"menu",items:h(),onPostRender:function(a){c.fire("renderFormatsMenu",{control:a.control})},itemDefaults:{preview:!0,textStyle:function(){if(this.settings.format)return c.formatter.getCssText(this.settings.format)},onPostRender:function(){var a=this;a.parent().on("show",function(){var b,d;b=a.settings.format,b&&(a.disabled(!c.formatter.canApply(b)),a.active(c.formatter.match(b))),d=a.settings.cmd,d&&a.active(c.queryCommandState(d))})},onclick:function(){this.settings.format&&b.toggleFormat(c,this.settings.format)(),this.settings.cmd&&c.execCommand(this.settings.cmd)}}}},f=function(a,b){a.addMenuItem("formats",{text:"Formats",menu:b})},g=function(a,b){a.addButton("styleselect",{type:"menubutton",text:"Formats",menu:b,onShowMenu:function(){a.settings.style_formats_autohide&&d(a,this.menu)}})},h=function(a){var b=e(a);f(a,b),g(a,b)};return{register:h}}),g("1b",["2l","c"],function(a,b){var c=function(d,e){var f,g;if("string"==typeof e)g=e.split(" ");else if(b.isArray(e))return a.flatten(b.map(e,function(a){return c(d,a)}));return f=b.grep(g,function(a){return"|"===a||a in d.menuItems}),b.map(f,function(a){return"|"===a?{text:"-"}:d.menuItems[a]})},d=function(a){return a&&"-"===a.text},e=function(b){var c=a.filter(b,function(a,b,c){return!d(a)||!d(c[b-1])});return a.filter(c,function(a,b,c){return!d(a)||b>0&&bE[l]?y:E[l],F[m]=z>F[m]?z:F[m];for(A=f.innerW-q.left-q.right,w=0,l=0;l0?s:0),A-=(l>0?s:0)+E[l];for(B=f.innerH-q.top-q.bottom,x=0,m=0;m0?t:0),B-=(m>0?t:0)+F[m];if(w+=q.left+q.right,x+=q.top+q.bottom,i={},i.minW=w+(f.w-f.innerW),i.minH=x+(f.h-f.innerH),i.contentW=i.minW-f.deltaW,i.contentH=i.minH-f.deltaH,i.minW=Math.min(i.minW,f.maxW),i.minH=Math.min(i.minH,f.maxH),i.minW=Math.max(i.minW,f.startMinWidth), +i.minH=Math.max(i.minH,f.startMinHeight),!f.autoResize||i.minW==f.minW&&i.minH==f.minH){f.autoResize&&(i=a.layoutRect(i),i.contentW=i.minW-f.deltaW,i.contentH=i.minH-f.deltaH);var G;G="start"==b.packV?0:B>0?Math.floor(B/c):0;var H=0,I=b.flexWidths;if(I)for(l=0;l'},src:function(a){this.getEl().src=a},html:function(a,c){var d=this,e=this.getEl().contentWindow.document.body;return e?(e.innerHTML=a,c&&c()):b.setTimeout(function(){d.html(a)}),this}})}),g("1i",["15"],function(a){"use strict";return a.extend({init:function(a){var b=this;b._super(a),b.classes.add("widget").add("infobox"),b.canFocus=!1},severity:function(a){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(a)},help:function(a){this.state.set("help",a)},renderHtml:function(){var a=this,b=a.classPrefix;return'
          '+a.encode(a.state.get("text"))+'
          '},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.getEl("body").firstChild.data=a.encode(b.value),a.state.get("rendered")&&a.updateLayoutRect()}),a.state.on("change:help",function(b){a.classes.toggle("has-help",b.value),a.state.get("rendered")&&a.updateLayoutRect()}),a._super()}})}),g("1k",["15","2n"],function(a,b){"use strict";return a.extend({init:function(a){var b=this;b._super(a),b.classes.add("widget").add("label"),b.canFocus=!1,a.multiline&&b.classes.add("autoscroll"),a.strong&&b.classes.add("strong")},initLayoutRect:function(){var a=this,c=a._super();if(a.settings.multiline){var d=b.getSize(a.getEl());d.width>c.maxW&&(c.minW=c.maxW,a.classes.add("multiline")),a.getEl().style.width=c.minW+"px",c.startMinH=c.h=c.minH=Math.min(c.maxH,b.getSize(a.getEl()).height)}return c},repaint:function(){var a=this;return a.settings.multiline||(a.getEl().style.lineHeight=a.layoutRect().h+"px"),a._super()},severity:function(a){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(a)},renderHtml:function(){var a,b,c=this,d=c.settings.forId,e=c.settings.html?c.settings.html:c.encode(c.state.get("text"));return!d&&(b=c.settings.forName)&&(a=c.getRoot().find("#"+b)[0],a&&(d=a._id)),d?'":''+e+""},bindStates:function(){var a=this;return a.state.on("change:text",function(b){a.innerHtml(a.encode(b.value)),a.state.get("rendered")&&a.updateLayoutRect()}),a._super()}})}),g("2c",["n"],function(a){"use strict";return a.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(a){var b=this;b._super(a),b.classes.add("toolbar")},postRender:function(){var a=this;return a.items().each(function(a){a.classes.add("toolbar-item")}),a._super()}})}),g("1o",["2c"],function(a){"use strict";return a.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}})}),g("1p",["1","b","f","1o"],function(a,b,c,d){"use strict";function e(a,b){for(;a;){if(b===a)return!0;a=a.parentNode}return!1}var f=c.extend({init:function(a){var b=this;b._renderOpen=!0,b._super(a),a=b.settings,b.classes.add("menubtn"),a.fixedWidth&&b.classes.add("fixed-width"),b.aria("haspopup",!0),b.state.set("menu",a.menu||b.render())},showMenu:function(a){var c,d=this;return d.menu&&d.menu.visible()&&a!==!1?d.hideMenu():(d.menu||(c=d.state.get("menu")||[],d.classes.add("opened"),c.length?c={type:"menu",animate:!0,items:c}:(c.type=c.type||"menu",c.animate=!0),c.renderTo?d.menu=c.parent(d).show().renderTo():d.menu=b.create(c).parent(d).renderTo(),d.fire("createmenu"),d.menu.reflow(),d.menu.on("cancel",function(a){a.control.parent()===d.menu&&(a.stopPropagation(),d.focus(),d.hideMenu())}),d.menu.on("select",function(){d.focus()}),d.menu.on("show hide",function(a){a.control===d.menu&&(d.activeMenu("show"==a.type),d.classes.toggle("opened","show"==a.type)),d.aria("expanded","show"==a.type)}).fire("show")),d.menu.show(),d.menu.layoutRect({w:d.layoutRect().w}),d.menu.moveRel(d.getEl(),d.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]),void d.fire("showmenu"))},hideMenu:function(){var a=this;a.menu&&(a.menu.items().each(function(a){a.hideMenu&&a.hideMenu()}),a.menu.hide())},activeMenu:function(a){this.classes.toggle("active",a)},renderHtml:function(){var b,c=this,e=c._id,f=c.classPrefix,g=c.settings.icon,h=c.state.get("text"),i="";return b=c.settings.image,b?(g="none","string"!=typeof b&&(b=a.getSelection?b[0]:b[1]),b=" style=\"background-image: url('"+b+"')\""):b="",h&&(c.classes.add("btn-has-text"),i=''+c.encode(h)+""),g=c.settings.icon?f+"ico "+f+"i-"+g:"",c.aria("role",c.parent()instanceof d?"menuitem":"button"),'
          '},postRender:function(){var a=this;return a.on("click",function(b){b.control===a&&e(b.target,a.getEl())&&(a.focus(),a.showMenu(!b.aria),b.aria&&a.menu.items().filter(":visible")[0].focus())}),a.on("mouseenter",function(b){var c,d=b.control,e=a.parent();d&&e&&d instanceof f&&d.parent()==e&&(e.items().filter("MenuButton").each(function(a){a.hideMenu&&a!=d&&(a.menu&&a.menu.visible()&&(c=!0),a.hideMenu())}),c&&(d.focus(),d.showMenu()))}),a._super()},bindStates:function(){var a=this;return a.state.on("change:menu",function(){a.menu&&a.menu.remove(),a.menu=null}),a._super()},remove:function(){this._super(),this.menu&&this.menu.remove()}});return f}),g("1q",["15","b","14","2u"],function(a,b,c,d){"use strict";var e=function(a,b){var c=a._textStyle;if(c){var d=a.getEl("text");d.setAttribute("style",c),b&&(d.style.color="",d.style.backgroundColor="")}};return a.extend({Defaults:{border:0,role:"menuitem"},init:function(a){var b,c=this;c._super(a),a=c.settings,c.classes.add("menu-item"),a.menu&&c.classes.add("menu-item-expand"),a.preview&&c.classes.add("menu-item-preview"),b=c.state.get("text"),"-"!==b&&"|"!==b||(c.classes.add("menu-item-sep"),c.aria("role","separator"),c.state.set("text","-")),a.selectable&&(c.aria("role","menuitemcheckbox"),c.classes.add("menu-item-checkbox"),a.icon="selected"),a.preview||a.selectable||c.classes.add("menu-item-normal"),c.on("mousedown",function(a){a.preventDefault()}),a.menu&&!a.ariaHideMenu&&c.aria("haspopup",!0)},hasMenus:function(){return!!this.settings.menu},showMenu:function(){var a,c=this,d=c.settings,e=c.parent();if(e.items().each(function(a){a!==c&&a.hideMenu()}),d.menu){a=c.menu,a?a.show():(a=d.menu,a.length?a={type:"menu",animate:!0,items:a}:(a.type=a.type||"menu",a.animate=!0),e.settings.itemDefaults&&(a.itemDefaults=e.settings.itemDefaults),a=c.menu=b.create(a).parent(c).renderTo(),a.reflow(),a.on("cancel",function(b){b.stopPropagation(),c.focus(),a.hide()}),a.on("show hide",function(a){a.control.items&&a.control.items().each(function(a){a.active(a.settings.selected)})}).fire("show"),a.on("hide",function(b){b.control===a&&c.classes.remove("selected")}),a.submenu=!0),a._parentMenu=e,a.classes.add("menu-sub");var f=a.testMoveRel(c.getEl(),c.isRtl()?["tl-tr","bl-br","tr-tl","br-bl"]:["tr-tl","br-bl","tl-tr","bl-br"]);a.moveRel(c.getEl(),f),a.rel=f,f="menu-sub-"+f,a.classes.remove(a._lastRel).add(f),a._lastRel=f,c.classes.add("selected"),c.aria("expanded",!0)}},hideMenu:function(){var a=this;return a.menu&&(a.menu.items().each(function(a){a.hideMenu&&a.hideMenu()}),a.menu.hide(),a.aria("expanded",!1)),a},renderHtml:function(){function a(a){var b,d,e={};for(e=c.mac?{alt:"⌥",ctrl:"⌘",shift:"⇧",meta:"⌘"}:{meta:"Ctrl"},a=a.split("+"),b=0;b").replace(new RegExp(b("]mce~match!"),"g"),"")}var f=this,g=f._id,h=f.settings,i=f.classPrefix,j=f.state.get("text"),k=f.settings.icon,l="",m=h.shortcut,n=f.encode(h.url),o="";return k&&f.parent().classes.add("menu-has-icons"),h.image&&(l=" style=\"background-image: url('"+h.image+"')\""),m&&(m=a(m)),k=i+"ico "+i+"i-"+(f.settings.icon||"none"),o="-"!==j?'\xa0":"",j=e(f.encode(d(j))),n=e(f.encode(d(n))),'
          '+o+("-"!==j?''+j+"":"")+(m?'
          '+m+"
          ":"")+(h.menu?'
          ':"")+(n?'":"")+"
          "},postRender:function(){var a=this,b=a.settings,c=b.textStyle;if("function"==typeof c&&(c=c.call(this)),c){var e=a.getEl("text");e&&(e.setAttribute("style",c),a._textStyle=c)}return a.on("mouseenter click",function(c){c.control===a&&(b.menu||"click"!==c.type?(a.showMenu(),c.aria&&a.menu.focus(!0)):(a.fire("select"),d.requestAnimationFrame(function(){a.parent().hideAll()})))}),a._super(),a},hover:function(){var a=this;return a.parent().items().each(function(a){a.classes.remove("selected")}),a.classes.toggle("selected",!0),a},active:function(a){return e(this,a),"undefined"!=typeof a&&this.aria("checked",a),this._super(a)},remove:function(){this._super(),this.menu&&this.menu.remove()}})}),g("1n",["14","2u","c","w","1q","2b"],function(a,b,c,d,e,f){"use strict";return d.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(b){var d=this;if(b.autohide=!0,b.constrainToViewport=!0,"function"==typeof b.items&&(b.itemsFactory=b.items,b.items=[]),b.itemDefaults)for(var e=b.items,f=e.length;f--;)e[f]=c.extend({},b.itemDefaults,e[f]);d._super(b),d.classes.add("menu"),b.animate&&11!==a.ie&&d.classes.add("animate")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){var a=this;a.hideAll(),a.fire("select")},load:function(){function a(){d.throbber&&(d.throbber.hide(),d.throbber=null)}var b,c,d=this;c=d.settings.itemsFactory,c&&(d.throbber||(d.throbber=new f(d.getEl("body"),!0),0===d.items().length?(d.throbber.show(),d.fire("loading")):d.throbber.show(100,function(){d.items().remove(),d.fire("loading")}),d.on("hide close",a)),d.requestTime=b=(new Date).getTime(),d.settings.itemsFactory(function(c){return 0===c.length?void d.hide():void(d.requestTime===b&&(d.getEl().style.width="",d.getEl("body").style.width="",a(),d.items().remove(),d.getEl("body").innerHTML="",d.add(c),d.renderNew(),d.fire("loaded")))}))},hideAll:function(){var a=this;return this.find("menuitem").exec("hideMenu"),a._super()},preRender:function(){var a=this;return a.items().each(function(b){var c=b.settings;if(c.icon||c.image||c.selectable)return a._hasIcons=!0,!1}),a.settings.itemsFactory&&a.on("postrender",function(){a.settings.itemsFactory&&a.load()}),a.on("show hide",function(c){c.control===a&&("show"===c.type?b.setTimeout(function(){a.classes.add("in")},0):a.classes.remove("in"))}),a._super()}})}),g("1m",["1p","1n"],function(a,b){"use strict";return a.extend({init:function(a){function b(c){for(var f=0;f0&&(e=c[0].text,g.state.set("value",c[0].value)),g.state.set("menu",c)),g.state.set("text",a.text||e),g.classes.add("listbox"),g.on("select",function(b){var c=b.control;f&&(b.lastControl=f),a.multiple?c.active(!c.active()):g.value(b.control.value()),f=c})},bindStates:function(){function a(a,c){a instanceof b&&a.items().each(function(a){a.hasMenus()||a.active(a.value()===c)})}function c(a,b){var d;if(a)for(var e=0;e'},postRender:function(){var a=this;a._super(),a.resizeDragHelper=new b(this._id,{start:function(){a.fire("ResizeStart")},drag:function(b){"both"!=a.settings.direction&&(b.deltaX=0),a.fire("Resize",b)},stop:function(){a.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}})}),g("23",["15"],function(a){"use strict";function b(a){var b="";if(a)for(var c=0;c'+a[c]+"";return b}return a.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(a){var b=this;b._super(a),b.settings.size&&(b.size=b.settings.size),b.settings.options&&(b._options=b.settings.options),b.on("keydown",function(a){var c;13==a.keyCode&&(a.preventDefault(),b.parents().reverse().each(function(a){if(a.toJSON)return c=a,!1}),b.fire("submit",{data:c.toJSON()}))})},options:function(a){return arguments.length?(this.state.set("options",a),this):this.state.get("options")},renderHtml:function(){var a,c=this,d="";return a=b(c._options),c.size&&(d=' size = "'+c.size+'"'),'"},bindStates:function(){var a=this;return a.state.on("change:options",function(c){a.getEl().innerHTML=b(c.value)}),a._super()}})}),g("25",["15","p","2n"],function(a,b,c){"use strict";function d(a,b,c){return ac&&(a=c),a}function e(a,b,c){a.setAttribute("aria-"+b,c)}function f(a,b){var d,f,g,h,i,j;"v"==a.settings.orientation?(h="top",g="height",f="h"):(h="left",g="width",f="w"),j=a.getEl("handle"),d=(a.layoutRect()[f]||100)-c.getSize(j)[g],i=d*((b-a._minValue)/(a._maxValue-a._minValue))+"px",j.style[h]=i,j.style.height=a.layoutRect().h+"px",e(j,"valuenow",b),e(j,"valuetext",""+a.settings.previewFilter(b)),e(j,"valuemin",a._minValue),e(j,"valuemax",a._maxValue)}return a.extend({init:function(a){var b=this;a.previewFilter||(a.previewFilter=function(a){return Math.round(100*a)/100}),b._super(a),b.classes.add("slider"),"v"==a.orientation&&b.classes.add("vertical"),b._minValue=a.minValue||0,b._maxValue=a.maxValue||100,b._initValue=b.state.get("value")},renderHtml:function(){var a=this,b=a._id,c=a.classPrefix;return'
          '},reset:function(){this.value(this._initValue).repaint()},postRender:function(){function a(a,b,c){return(c+a)/(b-a)}function e(a,b,c){return c*(b-a)-a}function f(b,c){function f(f){var g;g=n.value(),g=e(b,c,a(b,c,g)+.05*f),g=d(g,b,c),n.value(g),n.fire("dragstart",{value:g}),n.fire("drag",{value:g}),n.fire("dragend",{value:g})}n.on("keydown",function(a){switch(a.keyCode){case 37:case 38:f(-1);break;case 39:case 40:f(1)}})}function g(a,e,f){var g,h,i,o,p;n._dragHelper=new b(n._id,{handle:n._id+"-handle",start:function(a){g=a[j],h=parseInt(n.getEl("handle").style[k],10),i=(n.layoutRect()[m]||100)-c.getSize(f)[l],n.fire("dragstart",{value:p})},drag:function(b){var c=b[j]-g;o=d(h+c,0,i),f.style[k]=o+"px",p=a+o/i*(e-a),n.value(p),n.tooltip().text(""+n.settings.previewFilter(p)).show().moveRel(f,"bc tc"),n.fire("drag",{value:p})},stop:function(){n.tooltip().hide(),n.fire("dragend",{value:p})}})}var h,i,j,k,l,m,n=this;h=n._minValue,i=n._maxValue,"v"==n.settings.orientation?(j="screenY",k="top",l="height",m="h"):(j="screenX",k="left",l="width",m="w"),n._super(),f(h,i,n.getEl("handle")),g(h,i,n.getEl("handle"))},repaint:function(){this._super(),f(this,this.value())},bindStates:function(){var a=this;return a.state.on("change:value",function(b){f(a,b.value)}),a._super()}})}),g("26",["15"],function(a){"use strict";return a.extend({renderHtml:function(){var a=this;return a.classes.add("spacer"),a.canFocus=!1,'
          '}})}),g("27",["1","2o","2n","1p"],function(a,b,c,d){return d.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var a,d,e=this,f=e.getEl(),g=e.layoutRect();return e._super(),a=f.firstChild,d=f.lastChild,b(a).css({width:g.w-c.getSize(d).width,height:g.h-2}),b(d).css({height:g.h-2}),e},activeMenu:function(a){var c=this;b(c.getEl().lastChild).toggleClass(c.classPrefix+"active",a)},renderHtml:function(){var b,c,d=this,e=d._id,f=d.classPrefix,g=d.state.get("icon"),h=d.state.get("text"),i=d.settings,j="";return b=i.image,b?(g="none","string"!=typeof b&&(b=a.getSelection?b[0]:b[1]),b=" style=\"background-image: url('"+b+"')\""):b="",g=i.icon?f+"ico "+f+"i-"+g:"",h&&(d.classes.add("btn-has-text"),j=''+d.encode(h)+""),c="boolean"==typeof i.active?' aria-pressed="'+i.active+'"':"",'
          '},postRender:function(){var a=this,b=a.settings.onclick;return a.on("click",function(a){var c=a.target;if(a.control==this)for(;c;){if(a.aria&&"down"!=a.aria.key||"BUTTON"==c.nodeName&&c.className.indexOf("open")==-1)return a.stopImmediatePropagation(),void(b&&b.call(this,a));c=c.parentNode}}),delete a.settings.onclick,a._super()}})}),g("28",["x"],function(a){"use strict";return a.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}})}),g("29",["1u","2o","2n"],function(a,b,c){"use strict";return a.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(a){var c;this.activeTabId&&(c=this.getEl(this.activeTabId),b(c).removeClass(this.classPrefix+"active"),c.setAttribute("aria-selected","false")),this.activeTabId="t"+a,c=this.getEl("t"+a),c.setAttribute("aria-selected","true"),b(c).addClass(this.classPrefix+"active"),this.items()[a].show().fire("showtab"),this.reflow(),this.items().each(function(b,c){a!=c&&b.hide()})},renderHtml:function(){var a=this,b=a._layout,c="",d=a.classPrefix;return a.preRender(),b.preRender(a),a.items().each(function(b,e){var f=a._id+"-t"+e;b.aria("role","tabpanel"),b.aria("labelledby",f),c+='"}),'
          '+c+'
          '+b.renderHtml(a)+"
          "},postRender:function(){var a=this;a._super(),a.settings.activeTab=a.settings.activeTab||0,a.activateTab(a.settings.activeTab),this.on("click",function(b){var c=b.target.parentNode;if(c&&c.id==a._id+"-head")for(var d=c.childNodes.length;d--;)c.childNodes[d]==b.target&&a.activateTab(d)})},initLayoutRect:function(){var a,b,d,e=this;b=c.getSize(e.getEl("head")).width,b=b<0?0:b,d=0,e.items().each(function(a){b=Math.max(b,a.layoutRect().minW),d=Math.max(d,a.layoutRect().minH)}),e.items().each(function(a){a.settings.x=0,a.settings.y=0,a.settings.w=b,a.settings.h=d,a.layoutRect({x:0,y:0,w:b,h:d})});var f=c.getSize(e.getEl("head")).height;return e.settings.minWidth=b,e.settings.minHeight=d+f,a=e._super(),a.deltaH+=f,a.innerH=a.h-a.deltaH,a}})}),g("2a",["12","c","2n","15"],function(a,b,c,d){return d.extend({init:function(a){var b=this;b._super(a),b.classes.add("textbox"),a.multiline?b.classes.add("multiline"):(b.on("keydown",function(a){var c;13==a.keyCode&&(a.preventDefault(),b.parents().reverse().each(function(a){if(a.toJSON)return c=a,!1}),b.fire("submit",{data:c.toJSON()}))}),b.on("keyup",function(a){b.state.set("value",a.target.value)}))},repaint:function(){var b,c,d,e,f,g=this,h=0;b=g.getEl().style,c=g._layoutRect,f=g._lastRepaintRect||{};var i=a;return!g.settings.multiline&&i.all&&(!i.documentMode||i.documentMode<=8)&&(b.lineHeight=c.h-h+"px"),d=g.borderBox,e=d.left+d.right+8,h=d.top+d.bottom+(g.settings.multiline?8:0),c.x!==f.x&&(b.left=c.x+"px",f.x=c.x),c.y!==f.y&&(b.top=c.y+"px",f.y=c.y),c.w!==f.w&&(b.width=c.w-e+"px",f.w=c.w),c.h!==f.h&&(b.height=c.h-h+"px",f.h=c.h),g._lastRepaintRect=f,g.fire("repaint",{},!1),g},renderHtml:function(){var a,d,e=this,f=e.settings;return a={id:e._id,hidefocus:"1"},b.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(b){a[b]=f[b]}),e.disabled()&&(a.disabled="disabled"),f.subtype&&(a.type=f.subtype),d=c.create(f.multiline?"textarea":"input",a),d.value=e.state.get("value"),d.className=e.classes,d.outerHTML},value:function(a){return arguments.length?(this.state.set("value",a),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var a=this;a.getEl().value=a.state.get("value"),a._super(),a.$el.on("change",function(b){a.state.set("value",b.target.value),a.fire("change",b)})},bindStates:function(){var a=this;return a.state.on("change:value",function(b){a.getEl().value!=b.value&&(a.getEl().value=b.value)}),a.state.on("change:disabled",function(b){a.getEl().disabled=b.value}),a._super()},remove:function(){this.$el.off(),this._super()}})}),g("4",["b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","5","1f","1g","1h","1i","1j","1k","1l","1m","1n","1o","1p","1q","1r","1s","1t","1u","1v","1w","1x","1y","1z","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","15","2e"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha){var ia=function(){return{Selector:Y,Collection:h,ReflowQueue:T,Control:n,Factory:a,KeyboardNavigation:D,Container:m,DragHelper:o,Scrollable:W,Panel:O,Movable:M,Resizable:U,FloatPanel:v,Window:ha,MessageBox:L,Tooltip:fa,Widget:ga,Progress:R,Notification:N,Layout:F,AbsoluteLayout:c,Button:e,ButtonGroup:f,Checkbox:g,ComboBox:l,ColorBox:i,PanelButton:P,ColorButton:j,ColorPicker:k,Path:Q,ElementPath:q,FormItem:z,Form:x,FieldSet:r,FilePicker:s,FitLayout:t,FlexLayout:u,FlowLayout:w,FormatControls:y,GridLayout:A,Iframe:B,InfoBox:C,Label:E,Toolbar:ea,MenuBar:I,MenuButton:J,MenuItem:K,Throbber:da,Menu:H,ListBox:G,Radio:S,ResizeHandle:V,SelectBox:X,Slider:Z,Spacer:$,SplitButton:_,StackLayout:aa,TabPanel:ba,TextBox:ca,DropZone:p,BrowseButton:d}},ja=function(a){a.ui?b.each(ia(),function(b,c){a.ui[c]=b}):a.ui=ia()},ka=function(){b.each(ia(),function(b,c){a.add(c,b)})},la={appendTo:ja,registerToFactory:ka};return la}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return d.registerToFactory(),d.appendTo(a.tinymce?a.tinymce:{}),b.add("modern",function(a){return e.setup(a),c.get(a)}),function(){}}),d("0")()}(); \ No newline at end of file diff --git a/frontend/public/static/js/tinymce/js/tinymce/tinymce.min.js b/frontend/public/static/js/tinymce/js/tinymce/tinymce.min.js new file mode 100644 index 0000000..0c1d1b1 --- /dev/null +++ b/frontend/public/static/js/tinymce/js/tinymce/tinymce.min.js @@ -0,0 +1,13 @@ +// 4.7.3 (2017-11-23) +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e=534;return{opera:f,webkit:g,ie:h,gecko:k,mac:l,iOS:m,android:n,contentEditable:v,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:8!=h,range:e.getSelection&&"Range"in e,documentMode:h&&!j?b.documentMode||7:10,fileApi:o,ceFalse:h===!1||h>8,canHaveCSP:h===!1||h>11,desktop:!p&&!q,windowsPhone:r}}),h("1n",clearInterval),h("1o",clearTimeout),h("1p",setInterval),h("1q",setTimeout),g("1d",[],function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void i(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(b){return void a.reject(b)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(a){e.call(this,a)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;a0&&(d=c[0]),a.deepPath&&(c=a.deepPath(),c&&c.length>0&&(d=c[0])),d},n=function(b,d){var e,k,l=d||{};for(e in b)g[e]||(l[e]=b[e]);if(l.target||(l.target=l.srcElement||a),c.experimentalShadowDom&&(l.target=m(b,l.target)),b&&f.test(b.type)&&b.pageX===k&&b.clientX!==k){var n=l.target.ownerDocument||a,o=n.documentElement,p=n.body;l.pageX=b.clientX+(o&&o.scrollLeft||p&&p.scrollLeft||0)-(o&&o.clientLeft||p&&p.clientLeft||0),l.pageY=b.clientY+(o&&o.scrollTop||p&&p.scrollTop||0)-(o&&o.clientTop||p&&p.clientTop||0)}return l.preventDefault=function(){l.isDefaultPrevented=j,b&&(b.preventDefault?b.preventDefault():b.returnValue=!1)},l.stopPropagation=function(){l.isPropagationStopped=j,b&&(b.stopPropagation?b.stopPropagation():b.cancelBubble=!0)},l.stopImmediatePropagation=function(){l.isImmediatePropagationStopped=j,l.stopPropagation()},h(l)===!1&&(l.isDefaultPrevented=i,l.isPropagationStopped=i,l.isImmediatePropagationStopped=i),"undefined"==typeof l.metaKey&&(l.metaKey=!1),l},o=function(a,b,e){var f=a.document,g={type:"ready"};if(e.domLoaded)return void b(g);var h=function(){return"complete"===f.readyState||"interactive"===f.readyState&&f.body},i=function(){e.domLoaded||(e.domLoaded=!0,b(g))},j=function(){h()&&(l(f,"readystatechange",j),i())},m=function(){try{f.documentElement.doScroll("left")}catch(a){return void d.setTimeout(m)}i()};!f.addEventListener||c.ie&&c.ie<11?(k(f,"readystatechange",j),f.documentElement.doScroll&&a.self===a.top&&m()):h()?i():k(a,"DOMContentLoaded",i),k(a,"load",i)},p=function(){var c,d,f,g,h,i=this,j={};d=e+(+new Date).toString(32),g="onmouseenter"in a.documentElement,f="onfocusin"in a.documentElement,h={mouseenter:"mouseover",mouseleave:"mouseout"},c=1,i.domLoaded=!1,i.events=j;var m=function(a,b){var c,d,e,f,g=j[b];if(c=g&&g[a.type])for(d=0,e=c.length;dt.cacheLength&&delete a[b.shift()],a[c+" "]=d}var b=[];return a}function c(a){return a[K]=!0,a}function d(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||T)-(~a.sourceIndex||T);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function e(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function f(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function g(a){return c(function(b){return b=+b,c(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function h(a){return a&&typeof a.getElementsByTagName!==S&&a}function i(){}function j(a){for(var b=0,c=a.length,d="";b1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function m(b,c,d){for(var e=0,f=c.length;e-1&&(c[j]=!(g[j]=l))}}else t=n(t===g?t.splice(q,t.length):t),f?f(null,g,t,i):Y.apply(g,t)})}function p(a){for(var b,c,d,e=a.length,f=t.relative[a[0].type],g=f||t.relative[" "],h=f?1:0,i=k(function(a){return a===b},g,!0),m=k(function(a){return $.call(b,a)>-1},g,!0),n=[function(a,c,d){return!f&&(d||c!==z)||((b=c).nodeType?i(a,c,d):m(a,c,d))}];h1&&l(n),h>1&&j(a.slice(0,h-1).concat({value:" "===a[h-2].type?"*":""})).replace(ea,"$1"),c,h0,f=b.length>0,g=function(c,g,h,i,j){var k,l,m,o=0,p="0",q=c&&[],r=[],s=z,u=c||f&&t.find.TAG("*",j),v=M+=null==s?1:Math.random()||.1,w=u.length;for(j&&(z=g!==D&&g);p!==w&&null!=(k=u[p]);p++){if(f&&k){for(l=0;m=b[l++];)if(m(k,g,h)){i.push(k);break}j&&(M=v)}e&&((k=!m&&k)&&o--,c&&q.push(k))}if(o+=p,e&&p!==o){for(l=0;m=d[l++];)m(q,r,g,h);if(c){if(o>0)for(;p--;)q[p]||r[p]||(r[p]=W.call(i));r=n(r)}Y.apply(i,r),j&&!c&&r.length>0&&o+d.length>1&&a.uniqueSort(i)}return j&&(M=v,z=s),q};return e?c(g):g}var r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K="sizzle"+-new Date,L=window.document,M=0,N=0,O=b(),P=b(),Q=b(),R=function(a,b){return a===b&&(B=!0),0},S="undefined",T=1<<31,U={}.hasOwnProperty,V=[],W=V.pop,X=V.push,Y=V.push,Z=V.slice,$=V.indexOf||function(a){for(var b=0,c=this.length;b+~]|"+aa+")"+aa+"*"),ha=new RegExp("="+aa+"*([^\\]'\"]*?)"+aa+"*\\]","g"),ia=new RegExp(da),ja=new RegExp("^"+ba+"$"),ka={ID:new RegExp("^#("+ba+")"),CLASS:new RegExp("^\\.("+ba+")"),TAG:new RegExp("^("+ba+"|[*])"),ATTR:new RegExp("^"+ca),PSEUDO:new RegExp("^"+da),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+aa+"*(even|odd|(([+-]|)(\\d*)n|)"+aa+"*(?:([+-]|)"+aa+"*(\\d+)|))"+aa+"*\\)|)","i"),bool:new RegExp("^(?:"+_+")$","i"),needsContext:new RegExp("^"+aa+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+aa+"*((?:-\\d)?\\d*)"+aa+"*\\)|)(?=[^-]|$)","i")},la=/^(?:input|select|textarea|button)$/i,ma=/^h\d$/i,na=/^[^{]+\{\s*\[native \w/,oa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,pa=/[+~]/,qa=/'|\\/g,ra=new RegExp("\\\\([\\da-f]{1,6}"+aa+"?|("+aa+")|.)","ig"),sa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{Y.apply(V=Z.call(L.childNodes),L.childNodes),V[L.childNodes.length].nodeType}catch(a){Y={apply:V.length?function(a,b){X.apply(a,Z.call(b))}:function(a,b){for(var c=a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}s=a.support={},v=a.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},C=a.setDocument=function(a){function b(a){try{return a.top}catch(a){}return null}var c,e=a?a.ownerDocument||a:L,f=e.defaultView;return e!==D&&9===e.nodeType&&e.documentElement?(D=e,E=e.documentElement,F=!v(e),f&&f!==b(f)&&(f.addEventListener?f.addEventListener("unload",function(){C()},!1):f.attachEvent&&f.attachEvent("onunload",function(){C()})),s.attributes=!0,s.getElementsByTagName=!0,s.getElementsByClassName=na.test(e.getElementsByClassName),s.getById=!0,t.find.ID=function(a,b){if(typeof b.getElementById!==S&&F){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},t.filter.ID=function(a){var b=a.replace(ra,sa);return function(a){return a.getAttribute("id")===b}},t.find.TAG=s.getElementsByTagName?function(a,b){if(typeof b.getElementsByTagName!==S)return b.getElementsByTagName(a)}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},t.find.CLASS=s.getElementsByClassName&&function(a,b){if(F)return b.getElementsByClassName(a)},H=[],G=[],s.disconnectedMatch=!0,G=G.length&&new RegExp(G.join("|")),H=H.length&&new RegExp(H.join("|")),c=na.test(E.compareDocumentPosition),J=c||na.test(E.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},R=c?function(a,b){if(a===b)return B=!0,0;var c=!a.compareDocumentPosition-!b.compareDocumentPosition;return c?c:(c=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&c||!s.sortDetached&&b.compareDocumentPosition(a)===c?a===e||a.ownerDocument===L&&J(L,a)?-1:b===e||b.ownerDocument===L&&J(L,b)?1:A?$.call(A,a)-$.call(A,b):0:4&c?-1:1)}:function(a,b){if(a===b)return B=!0,0;var c,f=0,g=a.parentNode,h=b.parentNode,i=[a],j=[b];if(!g||!h)return a===e?-1:b===e?1:g?-1:h?1:A?$.call(A,a)-$.call(A,b):0;if(g===h)return d(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[f]===j[f];)f++;return f?d(i[f],j[f]):i[f]===L?-1:j[f]===L?1:0},e):D},a.matches=function(b,c){return a(b,null,null,c)},a.matchesSelector=function(b,c){if((b.ownerDocument||b)!==D&&C(b),c=c.replace(ha,"='$1']"),s.matchesSelector&&F&&(!H||!H.test(c))&&(!G||!G.test(c)))try{var d=I.call(b,c);if(d||s.disconnectedMatch||b.document&&11!==b.document.nodeType)return d}catch(a){}return a(c,D,null,[b]).length>0},a.contains=function(a,b){return(a.ownerDocument||a)!==D&&C(a),J(a,b)},a.attr=function(a,b){(a.ownerDocument||a)!==D&&C(a);var c=t.attrHandle[b.toLowerCase()],d=c&&U.call(t.attrHandle,b.toLowerCase())?c(a,b,!F):void 0;return void 0!==d?d:s.attributes||!F?a.getAttribute(b):(d=a.getAttributeNode(b))&&d.specified?d.value:null},a.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},a.uniqueSort=function(a){var b,c=[],d=0,e=0;if(B=!s.detectDuplicates,A=!s.sortStable&&a.slice(0),a.sort(R),B){for(;b=a[e++];)b===a[e]&&(d=c.push(e));for(;d--;)a.splice(c[d],1)}return A=null,a},u=a.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=u(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d++];)c+=u(b);return c},t=a.selectors={cacheLength:50,createPseudo:c,match:ka,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ra,sa),a[3]=(a[3]||a[4]||a[5]||"").replace(ra,sa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(b){return b[1]=b[1].toLowerCase(),"nth"===b[1].slice(0,3)?(b[3]||a.error(b[0]),b[4]=+(b[4]?b[5]+(b[6]||1):2*("even"===b[3]||"odd"===b[3])),b[5]=+(b[7]+b[8]||"odd"===b[3])):b[3]&&a.error(b[0]),b},PSEUDO:function(a){var b,c=!a[6]&&a[2];return ka.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&ia.test(c)&&(b=w(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ra,sa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=O[a+" "];return b||(b=new RegExp("(^|"+aa+")"+a+"("+aa+"|$)"))&&O(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==S&&a.getAttribute("class")||"")})},ATTR:function(b,c,d){return function(e){var f=a.attr(e,b);return null==f?"!="===c:!c||(f+="","="===c?f===d:"!="===c?f!==d:"^="===c?d&&0===f.indexOf(d):"*="===c?d&&f.indexOf(d)>-1:"$="===c?d&&f.slice(-d.length)===d:"~="===c?(" "+f+" ").indexOf(d)>-1:"|="===c&&(f===d||f.slice(0,d.length+1)===d+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[K]||(q[K]={}),j=k[a]||[],n=j[0]===M&&j[1],m=j[0]===M&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[M,n,m];break}}else if(s&&(j=(b[K]||(b[K]={}))[a])&&j[0]===M)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[K]||(l[K]={}))[a]=[M,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(b,d){var e,f=t.pseudos[b]||t.setFilters[b.toLowerCase()]||a.error("unsupported pseudo: "+b);return f[K]?f(d):f.length>1?(e=[b,b,"",d],t.setFilters.hasOwnProperty(b.toLowerCase())?c(function(a,b){for(var c,e=f(a,d),g=e.length;g--;)c=$.call(a,e[g]),a[c]=!(b[c]=e[g])}):function(a){return f(a,0,e)}):f}},pseudos:{not:c(function(a){var b=[],d=[],e=x(a.replace(ea,"$1"));return e[K]?c(function(a,b,c,d){for(var f,g=e(a,null,d,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,c,f){return b[0]=a,e(b,null,f,d),!d.pop()}}),has:c(function(b){return function(c){return a(b,c).length>0}}),contains:c(function(a){return a=a.replace(ra,sa),function(b){return(b.textContent||b.innerText||u(b)).indexOf(a)>-1}}),lang:c(function(b){return ja.test(b||"")||a.error("unsupported lang: "+b),b=b.replace(ra,sa).toLowerCase(),function(a){var c;do if(c=F?a.lang:a.getAttribute("xml:lang")||a.getAttribute("lang"))return c=c.toLowerCase(),c===b||0===c.indexOf(b+"-");while((a=a.parentNode)&&1===a.nodeType);return!1}}),target:function(a){var b=window.location&&window.location.hash;return b&&b.slice(1)===a.id},root:function(a){return a===E},focus:function(a){return a===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!t.pseudos.empty(a)},header:function(a){return ma.test(a.nodeName)},input:function(a){return la.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:g(function(){return[0]}),last:g(function(a,b){return[b-1]}),eq:g(function(a,b,c){return[c<0?c+b:c]}),even:g(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:g(function(a,b,c){for(var d=c<0?c+b:c;++d2&&"ID"===(g=f[0]).type&&s.getById&&9===b.nodeType&&F&&t.relative[f[1].type]){if(b=(t.find.ID(g.matches[0].replace(ra,sa),b)||[])[0],!b)return c;l&&(b=b.parentNode),a=a.slice(f.shift().value.length)}for(e=ka.needsContext.test(a)?0:f.length;e--&&(g=f[e],!t.relative[i=g.type]);)if((k=t.find[i])&&(d=k(g.matches[0].replace(ra,sa),pa.test(f[0].type)&&h(b.parentNode)||b))){if(f.splice(e,1),a=d.length&&j(f),!a)return Y.apply(c,d),c;break}}return(l||x(a,m))(d,b,!F,c,pa.test(a)&&h(b.parentNode)||b),c},s.sortStable=K.split("").sort(R).join("")===K,s.detectDuplicates=!!B,C(),s.sortDetached=!0,a}),g("1r",[],function(){var a=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},b=function(b){var c,d,e=b;if(!a(b))for(e=[],c=0,d=b.length;c)[^>]*$|#([\w\-]*)$)/,k=b.Event,l=e.makeMap("children,contents,next,prev"),m=function(a){return"undefined"!=typeof a},n=function(a){return"string"==typeof a},o=function(a){return a&&a==a.window},p=function(a,b){var c,d,e;for(b=b||g,e=b.createElement("div"),c=b.createDocumentFragment(),e.innerHTML=a;d=e.firstChild;)c.appendChild(d);return c},q=function(a,b,c,d){var e;if(n(b))b=p(b,F(a[0]));else if(b.length&&!b.nodeType){if(b=z.makeArray(b),d)for(e=b.length-1;e>=0;e--)q(a,b[e],c,d);else for(e=0;e"===b.charAt(b.length-1)&&b.length>=3?[null,b,null]:j.exec(b),!d)return z(c).find(b);if(d[1])for(e=p(b,F(c)).firstChild;e;)h.call(f,e),e=e.nextSibling;else{if(e=F(c).getElementById(d[2]),!e)return f;if(e.id!==d[2])return f.find(b);f.length=1,f[0]=e}}else this.add(b,!1);return f},toArray:function(){return e.toArray(this)},add:function(a,b){var c,d,e=this;if(n(a))return e.add(z(a));if(b!==!1)for(c=z.unique(e.toArray().concat(z.makeArray(a))),e.length=c.length,d=0;d1&&(l[a]||(e=z.unique(e)),0===a.indexOf("parents")&&(e=e.reverse())),e=z(e),c?e.filter(c):e}}),D({parentsUntil:function(a,b){return G(a,"parentNode",b)},nextUntil:function(a,b){return H(a,"nextSibling",1,b).slice(1)},prevUntil:function(a,b){return H(a,"previousSibling",1,b).slice(1)}},function(a,b){z.fn[a]=function(c,d){var e=this,f=[];return e.each(function(){var a=b.call(f,this,c,f);a&&(z.isArray(a)?f.push.apply(f,a):f.push(a))}),this.length>1&&(f=z.unique(f),0!==a.indexOf("parents")&&"prevUntil"!==a||(f=f.reverse())),f=z(f),d?f.filter(d):f}}),z.fn.is=function(a){return!!a&&this.filter(a).length>0},z.fn.init.prototype=z.fn,z.overrideDefaults=function(a){var b,c=function(d,e){return b=b||a(),0===arguments.length&&(d=b.element),e||(e=b.context),new c.fn.init(d,e)};return z.extend(c,this),c};var J=function(a,b,c){D(c,function(c,d){a[c]=a[c]||{},a[c][b]=d})};return d.ie&&d.ie<8&&(J(x,"get",{maxlength:function(a){var b=a.maxLength;return 2147483647===b?f:b},size:function(a){var b=a.size;return 20===b?f:b},"class":function(a){return a.className},style:function(a){var b=a.style.cssText;return 0===b.length?f:b}}),J(x,"set",{"class":function(a,b){a.className=b},style:function(a,b){a.style.cssText=b}})),d.ie&&d.ie<9&&(w["float"]="styleFloat",J(y,"set",{opacity:function(a,b){var c=a.style;null===b||""===b?c.removeAttribute("filter"):(c.zoom=1,c.filter="alpha(opacity="+100*b+")")}})),z.attrHooks=x,z.cssHooks=y,z}),g("4z",[],function(){var a=function(a){var b,c=!1;return function(){return c||(c=!0,b=a.apply(null,arguments)),b}};return{cached:a}}),h("74",Number),g("6q",["1i","74","3b"],function(a,b,c){var d=function(a,b){for(var c=0;c1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("4d",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("3f",["4d"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("28",["4","3b"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("4g",["2n","3a"],function(a,b){var c=function(){var a=b.keys,c=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b};return void 0===a?c:a}(),d=function(a,b){for(var d=c(a),e=0,f=d.length;e0})},v=function(a){var b={},c=a.dom();if(i.isSupported(c))for(var d=0;d0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("45",["55","56"],function(a,b){return{immutable:a,immutableBag:b}}),g("57",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("4c",["3c"],function(a){var b=function(){var b=a.getOrDie("Node");return b},c=function(a,b,c){return 0!==(a.compareDocumentPosition(b)&c)},d=function(a,d){return c(a,d,b().DOCUMENT_POSITION_PRECEDING)},e=function(a,d){return c(a,d,b().DOCUMENT_POSITION_CONTAINED_BY)};return{documentPositionPreceding:d,documentPositionContainedBy:e}}),g("2z",["1i","2n","1v","4d","5","1j"],function(a,b,c,d,e,f){var g=d.ELEMENT,h=d.DOCUMENT,i=function(a,b){var c=a.dom();if(c.nodeType!==g)return!1;if(void 0!==c.matches)return c.matches(b);if(void 0!==c.msMatchesSelector)return c.msMatchesSelector(b);if(void 0!==c.webkitMatchesSelector)return c.webkitMatchesSelector(b);if(void 0!==c.mozMatchesSelector)return c.mozMatchesSelector(b);throw new e("Browser lacks native selectors")},j=function(a){return a.nodeType!==g&&a.nodeType!==h||0===a.childElementCount},k=function(b,d){var e=void 0===d?f:d.dom();return j(e)?[]:a.map(e.querySelectorAll(b),c.fromDom)},l=function(a,d){var e=void 0===d?f:d.dom();return j(e)?b.none():b.from(e.querySelector(a)).map(c.fromDom)};return{all:k,is:i,one:l}}),g("31",["1i","1","4c","3d","2z"],function(a,b,c,d,e){var f=function(a,b){return a.dom()===b.dom()},g=function(a,b){return a.dom().isEqualNode(b.dom())},h=function(c,d){return a.exists(d,b.curry(f,c))},i=function(a,b){var c=a.dom(),d=b.dom();return c!==d&&c.contains(d)},j=function(a,b){return c.documentPositionContainedBy(a.dom(),b.dom())},k=d.detect().browser,l=k.isIE()?j:i;return{eq:f,isEqualNode:g,member:h,contains:l,is:e.is}}),g("3h",["28","1i","1","2n","45","57","31","1v"],function(a,b,c,d,e,f,g,h){var i=function(a){return h.fromDom(a.dom().ownerDocument)},j=function(a){var b=i(a);return h.fromDom(b.dom().documentElement)},k=function(a){var b=a.dom(),c=b.ownerDocument.defaultView;return h.fromDom(c)},l=function(a){var b=a.dom();return d.from(b.parentNode).map(h.fromDom)},m=function(a){return l(a).bind(function(c){var d=u(c);return b.findIndex(d,function(b){return g.eq(a,b)})})},n=function(b,d){for(var e=a.isFunction(d)?d:c.constant(!1),f=b.dom(),g=[];null!==f.parentNode&&void 0!==f.parentNode;){var i=f.parentNode,j=h.fromDom(i);if(g.push(j),e(j)===!0)break;f=i}return g},o=function(a){var c=function(c){return b.filter(c,function(b){return!g.eq(a,b)})};return l(a).map(u).map(c).getOr([])},p=function(a){var b=a.dom();return d.from(b.offsetParent).map(h.fromDom)},q=function(a){var b=a.dom();return d.from(b.previousSibling).map(h.fromDom)},r=function(a){var b=a.dom();return d.from(b.nextSibling).map(h.fromDom)},s=function(a){return b.reverse(f.toArray(a,q))},t=function(a){return f.toArray(a,r)},u=function(a){var c=a.dom();return b.map(c.childNodes,h.fromDom)},v=function(a,b){var c=a.dom().childNodes;return d.from(c[b]).map(h.fromDom)},w=function(a){return v(a,0)},x=function(a){return v(a,a.dom().childNodes.length-1)},y=function(a,b){return a.dom().childNodes.length},z=e.immutable("element","offset"),A=function(a,b){var c=u(a);return c.length>0&&b=b.length&&c(d)}};0===b.length?c([]):a.each(b,function(a,b){a.get(f(b))})})};return{par:b}}),g("3j",["1i","3i","5a"],function(a,b,c){var d=function(a){return c.par(a,b.nu)},e=function(b,c){var e=a.map(b,c);return d(e)},f=function(a,b){return function(c){return b(c).bind(a)}};return{par:d,mapM:e,compose:f}}),g("3k",["1","2n"],function(a,b){var c=function(d){var e=function(a){return d===a},f=function(a){return c(d)},g=function(a){return c(d)},h=function(a){return c(a(d))},i=function(a){a(d)},j=function(a){return a(d)},k=function(a,b){return b(d)},l=function(a){return a(d)},m=function(a){return a(d)},n=function(){return b.some(d)};return{is:e,isValue:a.constant(!0),isError:a.constant(!1),getOr:a.constant(d),getOrThunk:a.constant(d),getOrDie:a.constant(d),or:f,orThunk:g,fold:k,map:h,each:i,bind:j,exists:l,forall:m,toOption:n}},d=function(c){var e=function(a){return a()},f=function(){return a.die(c)()},g=function(a){return a},h=function(a){return a()},i=function(a){return d(c)},j=function(a){return d(c)},k=function(a,b){return a(c)};return{is:a.constant(!1),isValue:a.constant(!1),isError:a.constant(!0),getOr:a.identity,getOrThunk:e,getOrDie:f,or:g,orThunk:h,fold:k,map:i,each:a.noop,bind:j,exists:a.constant(!1),forall:a.constant(!0),toOption:b.none}};return{value:c,error:d}}),g("1t",["1i","1","3i","3j","3k","1m","15","1e"],function(a,b,c,d,e,f,g,h){"use strict";return function(i,j){var k,l=0,m={};j=j||{},k=j.maxLoadTime||5e3;var n=function(a){i.getElementsByTagName("head")[0].appendChild(a)},o=function(a,b,c){var d,e,j,o,p=function(){for(var a=o.passed,b=a.length;b--;)a[b]();o.status=2,o.passed=[],o.failed=[]},q=function(){for(var a=o.failed,b=a.length;b--;)a[b]();o.status=3,o.passed=[],o.failed=[]},r=function(){var a=f.userAgent.match(/WebKit\/(\d*)/);return!!(a&&a[1]<536)},s=function(a,b){a()||((new Date).getTime()-j0)return e=i.createElement("style"),e.textContent='@import "'+a+'"',u(),void n(e);t()}n(d),d.href=a}},p=function(a){return c.nu(function(c){o(a,b.compose(c,b.constant(e.value(a))),b.compose(c,b.constant(e.error(a))))})},q=function(a){return a.fold(b.identity,b.identity)},r=function(b,c,e){d.par(a.map(b,p)).get(function(b){var d=a.partition(b,function(a){return a.isValue()});d.fail.length>0?e(d.fail.map(q)):c(d.pass.map(q))})};return{load:o,loadAll:r}}}),g("s",[],function(){return function(a,b){var c=a,d=function(a,c,d,e){var f,g;if(a){if(!e&&a[c])return a[c];if(a!=b){if(f=a[d])return f;for(g=a.parentNode;g&&g!=b;g=g.parentNode)if(f=g[d])return f}}},e=function(a,c,d,e){var f,g,h;if(a){if(f=a[d],b&&f===b)return;if(f){if(!e)for(h=f[c];h;h=h[c])if(!h[c])return h;return f}if(g=a.parentNode,g&&g!==b)return g}};this.current=function(){return c},this.next=function(a){return c=d(c,"firstChild","nextSibling",a)},this.prev=function(a){return c=d(c,"lastChild","previousSibling",a)},this.prev2=function(a){return c=e(c,"lastChild","previousSibling",a)}}}),g("3l",["1i","1","3f"],function(a,b,c){var d=["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"],e=["area","base","basefont","br","col","frame","hr","img","input","isindex","link","meta","param","embed","source","wbr","track"],f=["td","th"],g=["thead","tbody","tfoot"],h=["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"],i=["h1","h2","h3","h4","h5","h6"],j=["li","dd","dt"],k=["ul","ol","dl"],l=function(d){var e;return function(f){return e=e?e:a.mapToObject(d,b.constant(!0)),e.hasOwnProperty(c.name(f))}},m=l(i),n=l(d),o=function(a){return c.isElement(a)&&!n(a)},p=function(a){return c.isElement(a)&&"br"===c.name(a)};return{isBlock:n,isInline:o,isHeading:m,isTextBlock:l(h),isList:l(k),isListItem:l(j),isVoid:l(e),isTableSection:l(g),isTableCell:l(f),isBr:p}}),g("1y",[],function(){var a=function(a){return function(b){return!!b&&b.nodeType==a}},b=a(1),c=function(a){return a=a.toLowerCase().split(" "),function(b){var c,d;if(b&&b.nodeType)for(d=b.nodeName.toLowerCase(),c=0;c=0;j--)g(h,k[j]);if(c.isDocument(i)===!1){if(c.isText(i)&&i.nodeValue.length>0){var l=d.trim(i.nodeValue).length;if(h.isBlock(i.parentNode)||l>0)return;if(0===l&&e(i))return}else if(c.isElement(i)&&(k=i.childNodes,1===k.length&&f(k[0])&&i.parentNode.insertBefore(k[0],i),k.length||b.isVoid(a.fromDom(i))))return;h.remove(i)}return i}};return{trimNode:g}}),g("v",["1v","1e"],function(a,b){var c,d,e,f=b.makeMap,g=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,h=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,i=/[<>&\"\']/g,j=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,k={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"};d={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},e={"<":"<",">":">","&":"&",""":'"',"'":"'"};var l=function(b){var c;return c=a.fromTag("div").dom(),c.innerHTML=b,c.textContent||c.innerText||b},m=function(a,b){var c,e,f,g={};if(a){for(a=a.split(","),b=b||10,c=0;c1?"&#"+(1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320)+65536)+";":d[a]||"&#"+a.charCodeAt(0)+";"})},encodeNamed:function(a,b,e){return e=e||c,a.replace(b?g:h,function(a){return d[a]||e[a]||a})},getEncodeFunc:function(a,b){b=m(b)||c;var e=function(a,c){return a.replace(c?g:h,function(a){return void 0!==d[a]?d[a]:void 0!==b[a]?b[a]:a.length>1?"&#"+(1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320)+65536)+";":"&#"+a.charCodeAt(0)+";"})},i=function(a,c){return n.encodeNamed(a,c,b)};return a=f(a.replace(/\+/g,",")),a.named&&a.numeric?e:a.named?b?i:n.encodeNamed:a.numeric?n.encodeNumeric:n.encodeRaw},decode:function(a){return a.replace(j,function(a,b){return b?(b="x"===b.charAt(0).toLowerCase()?parseInt(b.substr(1),16):parseInt(b,10),b>65535?(b-=65536,String.fromCharCode(55296+(b>>10),56320+(1023&b))):k[b]||String.fromCharCode(b)):e[a]||c[a]||l(a)})}};return n}),g("y",["1e"],function(a){var b={},c={},d=a.makeMap,e=a.each,f=a.extend,g=a.explode,h=a.inArray,i=function(b,c){return b=a.trim(b),b?b.split(c||" "):[]},j=function(a){var d,f,g,h,j,k,l={},m=function(a,b,e){var f,g,h,j=function(a,b){var c,d,e={};for(c=0,d=a.length;c